summaryrefslogtreecommitdiff
path: root/spec/ruby/library/socket/option/inspect_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/socket/option/inspect_spec.rb')
0 files changed, 0 insertions, 0 deletions
td class='mode'>-rw-r--r--.gdbinit154
-rw-r--r--.git-blame-ignore-revs30
-rw-r--r--.gitattributes6
-rw-r--r--.github/actions/capiext/action.yml86
-rw-r--r--.github/actions/compilers/action.yml164
-rwxr-xr-x.github/actions/compilers/entrypoint.sh90
-rw-r--r--.github/actions/launchable/setup/action.yml337
-rw-r--r--.github/actions/make-snapshot/action.yml77
-rw-r--r--.github/actions/setup/baseruby/action.yml73
-rw-r--r--.github/actions/setup/directories/action.yml205
-rw-r--r--.github/actions/setup/macos/action.yml29
-rw-r--r--.github/actions/setup/ubuntu/action.yml72
-rw-r--r--.github/actions/slack/action.yml51
-rw-r--r--.github/auto_request_review.yml27
-rw-r--r--.github/codeql/codeql-config.yml22
-rw-r--r--.github/dependabot.yml23
-rw-r--r--.github/labeler.yml7
-rw-r--r--.github/workflows/annocheck.yml177
-rw-r--r--.github/workflows/auto_request_review.yml7
-rw-r--r--.github/workflows/auto_review_pr.yml41
-rw-r--r--.github/workflows/baseruby.yml65
-rw-r--r--.github/workflows/bundled_gems.yml185
-rw-r--r--.github/workflows/check_dependencies.yml71
-rw-r--r--.github/workflows/check_misc.yml186
-rw-r--r--.github/workflows/check_sast.yml133
-rw-r--r--.github/workflows/cirrus-notify.yml46
-rw-r--r--.github/workflows/codeql-analysis.yml110
-rw-r--r--.github/workflows/compilers.yml513
-rw-r--r--.github/workflows/crosscompile.yml123
-rw-r--r--.github/workflows/cygwin.yml75
-rw-r--r--.github/workflows/default_gems_list.yml99
-rw-r--r--.github/workflows/dependabot_automerge.yml22
-rw-r--r--.github/workflows/labeler.yml15
-rw-r--r--.github/workflows/macos.yml207
-rw-r--r--.github/workflows/mingw.yml268
-rw-r--r--.github/workflows/modgc.yml179
-rw-r--r--.github/workflows/parse_y.yml101
-rw-r--r--.github/workflows/post_push.yml97
-rw-r--r--.github/workflows/pr-playground.yml131
-rw-r--r--.github/workflows/publish.yml114
-rw-r--r--.github/workflows/release.yml21
-rw-r--r--.github/workflows/rjit-bindgen.yml97
-rw-r--r--.github/workflows/rjit.yml126
-rw-r--r--.github/workflows/rust-warnings.yml62
-rw-r--r--.github/workflows/scorecards.yml40
-rw-r--r--.github/workflows/spec_guards.yml49
-rw-r--r--.github/workflows/sync_default_gems.yml80
-rw-r--r--.github/workflows/tarball-macos.yml101
-rw-r--r--.github/workflows/tarball-non-development.yml87
-rw-r--r--.github/workflows/tarball-test-schedule.yml26
-rw-r--r--.github/workflows/tarball-test.yml104
-rw-r--r--.github/workflows/tarball-ubuntu.yml151
-rw-r--r--.github/workflows/tarball-windows.yml163
-rw-r--r--.github/workflows/ubuntu.yml304
-rw-r--r--.github/workflows/wasm.yml166
-rw-r--r--.github/workflows/windows.yml256
-rw-r--r--.github/workflows/wsl.yml73
-rw-r--r--.github/workflows/yjit-macos.yml201
-rw-r--r--.github/workflows/yjit-ubuntu.yml262
-rw-r--r--.github/workflows/zjit-macos.yml239
-rw-r--r--.github/workflows/zjit-ubuntu.yml293
-rw-r--r--.github/zizmor.yml26
-rw-r--r--.gitignore54
-rw-r--r--.mailmap431
-rw-r--r--.rdoc_options35
-rw-r--r--.travis.yml235
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--COPYING2
-rw-r--r--COPYING.ja2
-rw-r--r--Cargo.lock766
-rw-r--r--Cargo.toml64
-rw-r--r--LEGAL311
-rw-r--r--NEWS.md259
-rw-r--r--README.EXT1
-rw-r--r--README.EXT.ja1
-rw-r--r--README.ja.md26
-rw-r--r--README.md17
-rw-r--r--addr2line.c1328
-rw-r--r--addr2line.h4
-rw-r--r--array.c4020
-rw-r--r--array.rb312
-rw-r--r--ast.c837
-rw-r--r--ast.rb80
-rwxr-xr-xautogen.sh21
-rwxr-xr-xbasictest/test.rb18
-rw-r--r--benchmark/README.md3
-rw-r--r--benchmark/app_aobench.rb4
-rw-r--r--benchmark/app_fib.rb2
-rw-r--r--benchmark/array_large_literal.yml19
-rw-r--r--benchmark/class_superclass.yml23
-rw-r--r--benchmark/dir_pwd.yml2
-rw-r--r--benchmark/enum_sort_by.yml53
-rw-r--r--benchmark/file_basename.yml6
-rw-r--r--benchmark/file_dirname.yml6
-rw-r--r--benchmark/file_expand_path.yml4
-rw-r--r--benchmark/file_extname.yml6
-rw-r--r--benchmark/file_join.yml7
-rw-r--r--benchmark/float_predicate.yml12
-rw-r--r--benchmark/hash_aref_str_lit.yml20
-rw-r--r--benchmark/hash_key.yml5
-rw-r--r--benchmark/hash_new.yml16
-rw-r--r--benchmark/int_to_s.yml25
-rw-r--r--benchmark/integer_predicate.yml9
-rw-r--r--benchmark/io_close.yml13
-rw-r--r--benchmark/io_close_contended.yml21
-rw-r--r--benchmark/lib/benchmark_driver/runner/ractor.rb2
-rw-r--r--benchmark/loop_each.yml4
-rw-r--r--benchmark/loop_times_megamorphic.yml7
-rw-r--r--benchmark/module_eqq.yml7
-rw-r--r--benchmark/nilclass.yml10
-rw-r--r--benchmark/object_allocate.yml28
-rw-r--r--benchmark/object_class.yml40
-rw-r--r--benchmark/object_id.yml4
-rw-r--r--benchmark/pathname.yml15
-rw-r--r--benchmark/ractor_string_fstring.yml18
-rw-r--r--benchmark/range_bsearch_bignum.yml10
-rw-r--r--benchmark/range_bsearch_endpointless.yml21
-rw-r--r--benchmark/range_bsearch_fixnum.yml10
-rw-r--r--benchmark/range_count.yml11
-rw-r--r--benchmark/range_overlap.yml19
-rw-r--r--benchmark/range_reverse_each.yml16
-rw-r--r--benchmark/realpath.yml3
-rw-r--r--benchmark/regexp_dup.yml6
-rw-r--r--benchmark/regexp_new.yml7
-rw-r--r--benchmark/scan.yaml16
-rw-r--r--benchmark/search.yaml16
-rw-r--r--benchmark/set.yml261
-rw-r--r--benchmark/so_count_words.yml33
-rw-r--r--benchmark/string_casecmp.yml2
-rw-r--r--benchmark/string_codepoints.yml9
-rw-r--r--benchmark/string_coderange_scan.yml10
-rw-r--r--benchmark/string_concat.yml8
-rw-r--r--benchmark/string_dup.yml7
-rw-r--r--benchmark/string_fstring.yml16
-rw-r--r--benchmark/string_gsub.yml54
-rw-r--r--benchmark/string_memsearch.yml75
-rw-r--r--benchmark/string_rpartition.yml18
-rw-r--r--benchmark/string_scrub.yml48
-rw-r--r--benchmark/struct_accessor.yml37
-rw-r--r--benchmark/time_now.yml1
-rw-r--r--benchmark/time_strftime.yml7
-rw-r--r--benchmark/time_xmlschema.yml27
-rw-r--r--benchmark/vm_call_bmethod.yml37
-rw-r--r--benchmark/vm_call_kw_and_kw_splat.yml25
-rw-r--r--benchmark/vm_call_method_missing.yml62
-rw-r--r--benchmark/vm_call_send_iseq.yml77
-rw-r--r--benchmark/vm_call_symproc.yml83
-rw-r--r--benchmark/vm_ivar_get.yml67
-rw-r--r--benchmark/vm_ivar_ic_miss.yml20
-rw-r--r--benchmark/vm_ivar_memoize.yml85
-rw-r--r--benchmark/vm_ivar_set_on_instance.yml63
-rw-r--r--benchmark/vm_method_splat_calls.yml13
-rw-r--r--benchmark/vm_method_splat_calls2.yml27
-rw-r--r--benchmark/vm_regexp.yml6
-rw-r--r--benchmark/vm_send_cfunc.yml15
-rw-r--r--benchmark/vm_super_splat_calls.yml25
-rw-r--r--benchmark/vm_zsuper_splat_calls.yml28
-rw-r--r--bignum.c529
-rwxr-xr-xbin/gem2
-rwxr-xr-xbootstraptest/runner.rb234
-rw-r--r--bootstraptest/test_autoload.rb12
-rw-r--r--bootstraptest/test_eval.rb43
-rw-r--r--bootstraptest/test_exception.rb2
-rw-r--r--bootstraptest/test_fiber.rb5
-rw-r--r--bootstraptest/test_finalizer.rb8
-rw-r--r--bootstraptest/test_flow.rb6
-rw-r--r--bootstraptest/test_fork.rb27
-rw-r--r--bootstraptest/test_gc.rb2
-rw-r--r--bootstraptest/test_insns.rb82
-rw-r--r--bootstraptest/test_io.rb4
-rw-r--r--bootstraptest/test_jump.rb2
-rw-r--r--bootstraptest/test_literal.rb9
-rw-r--r--bootstraptest/test_literal_suffix.rb12
-rw-r--r--bootstraptest/test_load.rb12
-rw-r--r--bootstraptest/test_method.rb296
-rw-r--r--bootstraptest/test_ractor.rb1937
-rw-r--r--bootstraptest/test_rjit.rb16
-rw-r--r--bootstraptest/test_syntax.rb58
-rw-r--r--bootstraptest/test_thread.rb25
-rw-r--r--bootstraptest/test_yjit.rb2135
-rw-r--r--bootstraptest/test_yjit_rust_port.rb8
-rw-r--r--box.c1299
-rw-r--r--builtin.c100
-rw-r--r--builtin.h12
-rw-r--r--ccan/list/list.h6
-rw-r--r--class.c1252
-rw-r--r--common.mk17324
-rw-r--r--compar.c87
-rw-r--r--compile.c4775
-rw-r--r--complex.c1177
-rw-r--r--concurrent_set.c518
-rw-r--r--configure.ac989
-rw-r--r--cont.c896
-rw-r--r--coroutine/amd64/Context.S82
-rw-r--r--coroutine/amd64/Context.h2
-rw-r--r--coroutine/arm32/Context.S7
-rw-r--r--coroutine/arm32/Context.h2
-rw-r--r--coroutine/arm64/Context.S153
-rw-r--r--coroutine/arm64/Context.asm81
-rw-r--r--coroutine/arm64/Context.h43
-rw-r--r--coroutine/asyncify/Context.h8
-rw-r--r--coroutine/loongarch64/Context.S5
-rw-r--r--coroutine/loongarch64/Context.h2
-rw-r--r--coroutine/ppc/Context.S7
-rw-r--r--coroutine/ppc/Context.h2
-rw-r--r--coroutine/ppc64/Context.S5
-rw-r--r--coroutine/ppc64/Context.h2
-rw-r--r--coroutine/ppc64le/Context.S28
-rw-r--r--coroutine/ppc64le/Context.h2
-rw-r--r--coroutine/riscv64/Context.S5
-rw-r--r--coroutine/riscv64/Context.h2
-rw-r--r--coroutine/win32/Context.h3
-rw-r--r--coroutine/win64/Context.h5
-rw-r--r--coroutine/x86/Context.S5
-rw-r--r--coroutine/x86/Context.h2
-rw-r--r--cygwin/GNUmakefile.in8
-rw-r--r--darray.h230
-rw-r--r--debug.c209
-rw-r--r--debug_counter.h32
-rw-r--r--defs/gmake.mk248
-rw-r--r--defs/id.def12
-rw-r--r--defs/jit.mk107
-rw-r--r--defs/known_errors.def314
-rw-r--r--defs/opt_insn_unif.def8
-rw-r--r--depend21719
-rw-r--r--dir.c1432
-rw-r--r--dir.rb384
-rw-r--r--dln.c173
-rw-r--r--dln.h2
-rw-r--r--dln_find.c13
-rw-r--r--dmydln.c21
-rw-r--r--dmyenc.c14
-rw-r--r--dmyext.c14
-rw-r--r--doc/.document14
-rw-r--r--doc/ChangeLog/ChangeLog-1.9.32
-rw-r--r--doc/ChangeLog/ChangeLog-2.0.02
-rw-r--r--doc/ChangeLog/ChangeLog-2.1.06
-rw-r--r--doc/ChangeLog/ChangeLog-2.2.02
-rw-r--r--doc/ChangeLog/ChangeLog-2.3.08
-rw-r--r--doc/ChangeLog/ChangeLog-2.4.06
-rw-r--r--doc/NEWS/NEWS-3.0.0.md6
-rw-r--r--doc/NEWS/NEWS-3.1.0.md4
-rw-r--r--doc/NEWS/NEWS-3.2.0.md4
-rw-r--r--doc/NEWS/NEWS-3.3.0.md529
-rw-r--r--doc/NEWS/NEWS-3.4.0.md962
-rw-r--r--doc/NEWS/NEWS-4.0.0.md802
-rw-r--r--doc/_regexp.rdoc1291
-rw-r--r--doc/_timezones.rdoc163
-rw-r--r--doc/bsearch.rdoc120
-rw-r--r--doc/case_mapping.rdoc116
-rw-r--r--doc/character_selectors.rdoc97
-rw-r--r--doc/command_injection.rdoc29
-rw-r--r--doc/contributing.md12
-rw-r--r--doc/contributing/bug_triaging.rdoc (renamed from doc/bug_triaging.rdoc)0
-rw-r--r--doc/contributing/building_ruby.md287
-rw-r--r--doc/contributing/concurrency_guide.md154
-rw-r--r--doc/contributing/contributing.md35
-rw-r--r--doc/contributing/documentation_guide.md363
-rw-r--r--doc/contributing/dtrace_probes.rdoc (renamed from doc/dtrace_probes.rdoc)0
-rw-r--r--doc/contributing/glossary.md20
-rw-r--r--doc/contributing/making_changes_to_stdlibs.md16
-rw-r--r--doc/contributing/memory_view.md (renamed from doc/memory_view.md)0
-rw-r--r--doc/contributing/reporting_issues.md37
-rw-r--r--doc/contributing/testing_ruby.md123
-rw-r--r--doc/contributing/vm_stack_and_frames.md163
-rw-r--r--doc/csv/arguments/io.rdoc5
-rw-r--r--doc/csv/options/common/col_sep.rdoc63
-rw-r--r--doc/csv/options/common/quote_char.rdoc42
-rw-r--r--doc/csv/options/common/row_sep.rdoc100
-rw-r--r--doc/csv/options/generating/force_quotes.rdoc17
-rw-r--r--doc/csv/options/generating/quote_empty.rdoc12
-rw-r--r--doc/csv/options/generating/write_converters.rdoc33
-rw-r--r--doc/csv/options/generating/write_empty_value.rdoc15
-rw-r--r--doc/csv/options/generating/write_headers.rdoc29
-rw-r--r--doc/csv/options/generating/write_nil_value.rdoc14
-rw-r--r--doc/csv/options/parsing/converters.rdoc46
-rw-r--r--doc/csv/options/parsing/empty_value.rdoc13
-rw-r--r--doc/csv/options/parsing/field_size_limit.rdoc39
-rw-r--r--doc/csv/options/parsing/header_converters.rdoc43
-rw-r--r--doc/csv/options/parsing/headers.rdoc63
-rw-r--r--doc/csv/options/parsing/liberal_parsing.rdoc19
-rw-r--r--doc/csv/options/parsing/nil_value.rdoc12
-rw-r--r--doc/csv/options/parsing/return_headers.rdoc22
-rw-r--r--doc/csv/options/parsing/skip_blanks.rdoc31
-rw-r--r--doc/csv/options/parsing/skip_lines.rdoc37
-rw-r--r--doc/csv/options/parsing/strip.rdoc15
-rw-r--r--doc/csv/options/parsing/unconverted_fields.rdoc27
-rw-r--r--doc/csv/recipes/filtering.rdoc156
-rw-r--r--doc/csv/recipes/generating.rdoc244
-rw-r--r--doc/csv/recipes/parsing.rdoc543
-rw-r--r--doc/csv/recipes/recipes.rdoc6
-rw-r--r--doc/date/calendars.rdoc62
-rw-r--r--doc/distribution.md47
-rw-r--r--doc/distribution/distribution.md48
-rw-r--r--doc/distribution/windows.md304
-rw-r--r--doc/encodings.rdoc479
-rw-r--r--doc/examples/files.rdoc8
-rw-r--r--doc/extension.ja.rdoc54
-rw-r--r--doc/extension.rdoc308
-rw-r--r--doc/fiber.md232
-rw-r--r--doc/file/timestamps.md83
-rw-r--r--doc/float.rb128
-rw-r--r--doc/format_specifications.rdoc348
-rw-r--r--doc/forwardable.rd.ja80
-rw-r--r--doc/globals.rdoc69
-rw-r--r--doc/implicit_conversion.rdoc221
-rw-r--r--doc/index.md65
-rw-r--r--doc/irb/irb-tools.rd.ja184
-rw-r--r--doc/irb/irb.rd.ja427
-rw-r--r--doc/jit/yjit.md547
-rw-r--r--doc/jit/zjit.md461
-rw-r--r--doc/keywords.rdoc162
-rw-r--r--doc/language/box.md357
-rw-r--r--doc/language/bsearch.rdoc120
-rw-r--r--doc/language/calendars.rdoc62
-rw-r--r--doc/language/case_mapping.rdoc106
-rw-r--r--doc/language/character_selectors.rdoc100
-rw-r--r--doc/language/dig_methods.rdoc (renamed from doc/dig_methods.rdoc)0
-rw-r--r--doc/language/encodings.rdoc482
-rw-r--r--doc/language/exceptions.md521
-rw-r--r--doc/language/fiber.md290
-rw-r--r--doc/language/format_specifications.rdoc354
-rw-r--r--doc/language/globals.md611
-rw-r--r--doc/language/hash_inclusion.rdoc31
-rw-r--r--doc/language/implicit_conversion.rdoc221
-rw-r--r--doc/language/marshal.rdoc318
-rw-r--r--doc/language/option_dump.md265
-rw-r--r--doc/language/options.md744
-rw-r--r--doc/language/packed_data.md886
-rw-r--r--doc/language/ractor.md797
-rw-r--r--doc/language/regexp/methods.rdoc41
-rw-r--r--doc/language/regexp/unicode_properties.rdoc718
-rw-r--r--doc/language/signals.rdoc106
-rw-r--r--doc/language/strftime_formatting.rdoc525
-rw-r--r--doc/maintainers.md684
-rw-r--r--doc/marshal.rdoc313
-rw-r--r--doc/matchdata/begin.rdoc12
-rw-r--r--doc/matchdata/bytebegin.rdoc30
-rw-r--r--doc/matchdata/byteend.rdoc30
-rw-r--r--doc/matchdata/end.rdoc12
-rw-r--r--doc/matchdata/offset.rdoc12
-rw-r--r--doc/math/math.rdoc2
-rw-r--r--doc/optparse/argument_converters.rdoc72
-rw-r--r--doc/optparse/option_params.rdoc45
-rw-r--r--doc/optparse/ruby/argument_abbreviation.rb9
-rw-r--r--doc/optparse/ruby/matched_values.rb6
-rw-r--r--doc/optparse/tutorial.rdoc123
-rw-r--r--doc/packed_data.rdoc590
-rw-r--r--doc/pty/README.expect.ja32
-rw-r--r--doc/pty/README.ja50
-rw-r--r--doc/ractor.md952
-rw-r--r--doc/rdoc/markup_reference.rb1257
-rw-r--r--doc/regexp.rdoc810
-rw-r--r--doc/rjit/rjit.md45
-rw-r--r--doc/security.rdoc139
-rw-r--r--doc/security/command_injection.rdoc15
-rw-r--r--doc/security/security.rdoc127
-rw-r--r--doc/signals.rdoc106
-rw-r--r--doc/standard_library.md223
-rw-r--r--doc/standard_library.rdoc132
-rw-r--r--doc/strftime_formatting.rdoc527
-rw-r--r--doc/string.rb421
-rw-r--r--doc/string/aref.rdoc96
-rw-r--r--doc/string/aset.rdoc179
-rw-r--r--doc/string/b.rdoc2
-rw-r--r--doc/string/bytes.rdoc5
-rw-r--r--doc/string/bytesize.rdoc17
-rw-r--r--doc/string/byteslice.rdoc54
-rw-r--r--doc/string/bytesplice.rdoc65
-rw-r--r--doc/string/capitalize.rdoc26
-rw-r--r--doc/string/center.rdoc21
-rw-r--r--doc/string/chars.rdoc4
-rw-r--r--doc/string/chomp.rdoc8
-rw-r--r--doc/string/chop.rdoc7
-rw-r--r--doc/string/chr.rdoc7
-rw-r--r--doc/string/codepoints.rdoc4
-rw-r--r--doc/string/concat.rdoc11
-rw-r--r--doc/string/count.rdoc74
-rw-r--r--doc/string/delete.rdoc75
-rw-r--r--doc/string/delete_prefix.rdoc11
-rw-r--r--doc/string/delete_suffix.rdoc10
-rw-r--r--doc/string/downcase.rdoc20
-rw-r--r--doc/string/dump.rdoc89
-rw-r--r--doc/string/each_byte.rdoc22
-rw-r--r--doc/string/each_char.rdoc26
-rw-r--r--doc/string/each_codepoint.rdoc28
-rw-r--r--doc/string/each_grapheme_cluster.rdoc19
-rw-r--r--doc/string/each_line.rdoc24
-rw-r--r--doc/string/encode.rdoc5
-rw-r--r--doc/string/end_with_p.rdoc16
-rw-r--r--doc/string/eql_p.rdoc18
-rw-r--r--doc/string/force_encoding.rdoc15
-rw-r--r--doc/string/getbyte.rdoc23
-rw-r--r--doc/string/grapheme_clusters.rdoc15
-rw-r--r--doc/string/hash.rdoc19
-rw-r--r--doc/string/index.rdoc30
-rw-r--r--doc/string/insert.rdoc15
-rw-r--r--doc/string/inspect.rdoc38
-rw-r--r--doc/string/intern.rdoc8
-rw-r--r--doc/string/length.rdoc7
-rw-r--r--doc/string/ljust.rdoc15
-rw-r--r--doc/string/new.rdoc44
-rw-r--r--doc/string/ord.rdoc3
-rw-r--r--doc/string/partition.rdoc51
-rw-r--r--doc/string/rindex.rdoc51
-rw-r--r--doc/string/rjust.rdoc9
-rw-r--r--doc/string/rpartition.rdoc55
-rw-r--r--doc/string/scan.rdoc35
-rw-r--r--doc/string/scrub.rdoc27
-rw-r--r--doc/string/split.rdoc131
-rw-r--r--doc/string/squeeze.rdoc33
-rw-r--r--doc/string/start_with_p.rdoc12
-rw-r--r--doc/string/sub.rdoc33
-rw-r--r--doc/string/succ.rdoc52
-rw-r--r--doc/string/sum.rdoc5
-rw-r--r--doc/string/swapcase.rdoc31
-rw-r--r--doc/string/unicode_normalize.rdoc28
-rw-r--r--doc/string/upcase.rdoc27
-rw-r--r--doc/string/upto.rdoc38
-rw-r--r--doc/string/valid_encoding_p.rdoc8
-rw-r--r--doc/stringio/each_byte.rdoc31
-rw-r--r--doc/stringio/each_char.rdoc31
-rw-r--r--doc/stringio/each_codepoint.rdoc33
-rw-r--r--doc/stringio/each_line.md189
-rw-r--r--doc/stringio/getbyte.rdoc24
-rw-r--r--doc/stringio/getc.rdoc30
-rw-r--r--doc/stringio/gets.rdoc99
-rw-r--r--doc/stringio/pread.rdoc65
-rw-r--r--doc/stringio/putc.rdoc82
-rw-r--r--doc/stringio/read.rdoc83
-rw-r--r--doc/stringio/size.rdoc4
-rw-r--r--doc/stringio/stringio.md702
-rw-r--r--doc/strscan/.document1
-rw-r--r--doc/strscan/helper_methods.md124
-rw-r--r--doc/strscan/link_refs.txt17
-rw-r--r--doc/strscan/methods/get_byte.md27
-rw-r--r--doc/strscan/methods/get_charpos.md16
-rw-r--r--doc/strscan/methods/get_pos.md11
-rw-r--r--doc/strscan/methods/getch.md40
-rw-r--r--doc/strscan/methods/scan.md48
-rw-r--r--doc/strscan/methods/scan_until.md49
-rw-r--r--doc/strscan/methods/set_pos.md23
-rw-r--r--doc/strscan/methods/skip.md40
-rw-r--r--doc/strscan/methods/skip_until.md48
-rw-r--r--doc/strscan/methods/terminate.md27
-rw-r--r--doc/strscan/strscan.md544
-rw-r--r--doc/syntax.rdoc8
-rw-r--r--doc/syntax/assignment.rdoc8
-rw-r--r--doc/syntax/calling_methods.rdoc101
-rw-r--r--doc/syntax/comments.rdoc4
-rw-r--r--doc/syntax/control_expressions.rdoc72
-rw-r--r--doc/syntax/exceptions.rdoc10
-rw-r--r--doc/syntax/keywords.rdoc162
-rw-r--r--doc/syntax/layout.rdoc118
-rw-r--r--doc/syntax/literals.rdoc224
-rw-r--r--doc/syntax/methods.rdoc1
-rw-r--r--doc/syntax/modules_and_classes.rdoc28
-rw-r--r--doc/syntax/operators.rdoc75
-rw-r--r--doc/syntax/pattern_matching.rdoc16
-rw-r--r--doc/syntax/refinements.rdoc71
-rw-r--r--doc/timezones.rdoc108
-rw-r--r--doc/windows.md234
-rw-r--r--doc/yarvarch.en7
-rw-r--r--doc/yarvarch.ja454
-rw-r--r--doc/yjit/yjit.md360
-rw-r--r--doc/yjit/yjit_hacking.md75
-rw-r--r--enc/Makefile.in13
-rw-r--r--enc/ascii.c4
-rw-r--r--enc/big5.c12
-rw-r--r--enc/cesu_8.c23
-rw-r--r--enc/cp949.c4
-rw-r--r--enc/depend151
-rw-r--r--enc/ebcdic.h2
-rw-r--r--enc/emacs_mule.c4
-rw-r--r--enc/encinit.c.erb3
-rw-r--r--enc/euc_jp.c4
-rw-r--r--enc/euc_kr.c8
-rw-r--r--enc/euc_tw.c4
-rw-r--r--enc/gb18030.c4
-rw-r--r--enc/gbk.c4
-rw-r--r--enc/iso_8859_1.c6
-rw-r--r--enc/iso_8859_10.c6
-rw-r--r--enc/iso_8859_11.c4
-rw-r--r--enc/iso_8859_13.c6
-rw-r--r--enc/iso_8859_14.c6
-rw-r--r--enc/iso_8859_15.c6
-rw-r--r--enc/iso_8859_16.c6
-rw-r--r--enc/iso_8859_2.c6
-rw-r--r--enc/iso_8859_3.c6
-rw-r--r--enc/iso_8859_4.c6
-rw-r--r--enc/iso_8859_5.c6
-rw-r--r--enc/iso_8859_6.c4
-rw-r--r--enc/iso_8859_7.c6
-rw-r--r--enc/iso_8859_8.c4
-rw-r--r--enc/iso_8859_9.c6
-rw-r--r--enc/jis/props.h.blt17
-rw-r--r--enc/koi8_r.c4
-rw-r--r--enc/koi8_u.c4
-rwxr-xr-xenc/make_encmake.rb36
-rw-r--r--enc/shift_jis.c4
-rw-r--r--enc/trans/ibm864-tbl.rb126
-rw-r--r--enc/trans/iso2022.trans148
-rw-r--r--enc/trans/single_byte.trans1
-rw-r--r--enc/unicode.c12
-rw-r--r--enc/unicode/15.0.0/casefold.h7629
-rw-r--r--enc/unicode/15.0.0/name2ctype.h45690
-rw-r--r--enc/unicode/17.0.0/casefold.h8013
-rw-r--r--enc/unicode/17.0.0/name2ctype.h49725
-rw-r--r--enc/us_ascii.c4
-rw-r--r--enc/utf_16be.c4
-rw-r--r--enc/utf_16le.c4
-rw-r--r--enc/utf_32be.c4
-rw-r--r--enc/utf_32le.c4
-rw-r--r--enc/utf_8.c4
-rw-r--r--enc/windows_1250.c6
-rw-r--r--enc/windows_1251.c6
-rw-r--r--enc/windows_1252.c6
-rw-r--r--enc/windows_1253.c6
-rw-r--r--enc/windows_1254.c6
-rw-r--r--enc/windows_1257.c6
-rw-r--r--enc/windows_31j.c4
-rw-r--r--encoding.c468
-rw-r--r--enum.c773
-rw-r--r--enumerator.c903
-rw-r--r--error.c1461
-rw-r--r--eval.c588
-rw-r--r--eval_error.c43
-rw-r--r--eval_intern.h73
-rw-r--r--eval_jump.c30
-rw-r--r--ext/-test-/RUBY_ALIGNOF/depend2
-rw-r--r--ext/-test-/abi/depend3
-rw-r--r--ext/-test-/arith_seq/beg_len_step/depend2
-rw-r--r--ext/-test-/arith_seq/extract/depend2
-rw-r--r--ext/-test-/array/concat/depend2
-rw-r--r--ext/-test-/array/resize/depend2
-rw-r--r--ext/-test-/bignum/depend26
-rw-r--r--ext/-test-/box/yay1/extconf.rb1
-rw-r--r--ext/-test-/box/yay1/yay1.c28
-rw-r--r--ext/-test-/box/yay1/yay1.def3
-rw-r--r--ext/-test-/box/yay1/yay1.h4
-rw-r--r--ext/-test-/box/yay2/extconf.rb1
-rw-r--r--ext/-test-/box/yay2/yay2.c28
-rw-r--r--ext/-test-/box/yay2/yay2.def3
-rw-r--r--ext/-test-/box/yay2/yay2.h4
-rw-r--r--ext/-test-/bug-14834/bug-14384.c39
-rw-r--r--ext/-test-/bug-14834/bug-14834.c39
-rw-r--r--ext/-test-/bug-14834/depend320
-rw-r--r--ext/-test-/bug-3571/depend2
-rw-r--r--ext/-test-/bug-5832/depend2
-rw-r--r--ext/-test-/bug_reporter/depend2
-rw-r--r--ext/-test-/class/depend4
-rw-r--r--ext/-test-/class/init.c1
-rw-r--r--ext/-test-/cxxanyargs/cxxanyargs.cpp26
-rw-r--r--ext/-test-/debug/depend6
-rw-r--r--ext/-test-/debug/profile_frames.c21
-rw-r--r--ext/-test-/dln/empty/depend2
-rw-r--r--ext/-test-/econv/append.c2
-rw-r--r--ext/-test-/econv/depend336
-rw-r--r--ext/-test-/ensure_and_callcc/depend163
-rw-r--r--ext/-test-/ensure_and_callcc/ensure_and_callcc.c58
-rw-r--r--ext/-test-/ensure_and_callcc/extconf.rb5
-rw-r--r--ext/-test-/enumerator_kw/depend2
-rw-r--r--ext/-test-/eval/depend162
-rw-r--r--ext/-test-/exception/depend8
-rw-r--r--ext/-test-/fatal/depend325
-rw-r--r--ext/-test-/fatal/extconf.rb3
-rw-r--r--ext/-test-/fatal/init.c10
-rw-r--r--ext/-test-/fatal/invalid.c22
-rw-r--r--ext/-test-/fatal/rb_fatal.c3
-rw-r--r--ext/-test-/file/depend179
-rw-r--r--ext/-test-/file/newline_conv.c73
-rw-r--r--ext/-test-/float/depend4
-rw-r--r--ext/-test-/funcall/depend2
-rw-r--r--ext/-test-/gvl/call_without_gvl/depend2
-rw-r--r--ext/-test-/hash/depend4
-rw-r--r--ext/-test-/integer/depend9
-rw-r--r--ext/-test-/integer/my_integer.c6
-rw-r--r--ext/-test-/iseq_load/depend2
-rw-r--r--ext/-test-/iter/depend6
-rw-r--r--ext/-test-/load/dot.dot/depend2
-rw-r--r--ext/-test-/load/protect/depend2
-rw-r--r--ext/-test-/load/resolve_symbol_resolver/depend163
-rw-r--r--ext/-test-/load/resolve_symbol_resolver/extconf.rb1
-rw-r--r--ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c56
-rw-r--r--ext/-test-/load/resolve_symbol_target/depend164
-rw-r--r--ext/-test-/load/resolve_symbol_target/extconf.rb1
-rw-r--r--ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c15
-rw-r--r--ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h4
-rw-r--r--ext/-test-/load/stringify_symbols/depend164
-rw-r--r--ext/-test-/load/stringify_symbols/extconf.rb1
-rw-r--r--ext/-test-/load/stringify_symbols/stringify_symbols.c29
-rw-r--r--ext/-test-/load/stringify_target/depend164
-rw-r--r--ext/-test-/load/stringify_target/extconf.rb1
-rw-r--r--ext/-test-/load/stringify_target/stringify_target.c15
-rw-r--r--ext/-test-/load/stringify_target/stringify_target.h4
-rw-r--r--ext/-test-/marshal/compat/depend2
-rw-r--r--ext/-test-/marshal/internal_ivar/depend2
-rw-r--r--ext/-test-/marshal/internal_ivar/internal_ivar.c15
-rw-r--r--ext/-test-/marshal/usr/depend2
-rw-r--r--ext/-test-/memory_status/depend1
-rw-r--r--ext/-test-/memory_view/depend2
-rw-r--r--ext/-test-/memory_view/memory_view.c4
-rw-r--r--ext/-test-/method/depend4
-rw-r--r--ext/-test-/notimplement/depend2
-rw-r--r--ext/-test-/num2int/depend2
-rw-r--r--ext/-test-/path_to_class/depend2
-rw-r--r--ext/-test-/popen_deadlock/depend2
-rw-r--r--ext/-test-/postponed_job/depend2
-rw-r--r--ext/-test-/postponed_job/postponed_job.c133
-rw-r--r--ext/-test-/printf/depend2
-rw-r--r--ext/-test-/proc/depend6
-rw-r--r--ext/-test-/public_header_warnings/extconf.rb28
-rw-r--r--ext/-test-/random/depend6
-rw-r--r--ext/-test-/random/loop.c11
-rw-r--r--ext/-test-/rational/depend5
-rw-r--r--ext/-test-/rb_call_super_kw/depend2
-rw-r--r--ext/-test-/recursion/depend2
-rw-r--r--ext/-test-/regexp/depend4
-rw-r--r--ext/-test-/sanitizers/depend162
-rw-r--r--ext/-test-/sanitizers/extconf.rb2
-rw-r--r--ext/-test-/sanitizers/sanitizers.c36
-rw-r--r--ext/-test-/scan_args/depend2
-rw-r--r--ext/-test-/scheduler/extconf.rb2
-rw-r--r--ext/-test-/scheduler/scheduler.c92
-rw-r--r--ext/-test-/st/foreach/depend2
-rw-r--r--ext/-test-/st/foreach/foreach.c30
-rw-r--r--ext/-test-/st/numhash/depend2
-rw-r--r--ext/-test-/st/update/depend2
-rw-r--r--ext/-test-/stack/depend179
-rw-r--r--ext/-test-/stack/extconf.rb3
-rw-r--r--ext/-test-/stack/stack.c35
-rw-r--r--ext/-test-/string/cstr.c17
-rw-r--r--ext/-test-/string/depend200
-rw-r--r--ext/-test-/string/fstring.c18
-rw-r--r--ext/-test-/string/set_len.c18
-rw-r--r--ext/-test-/struct/data.c13
-rw-r--r--ext/-test-/struct/depend169
-rw-r--r--ext/-test-/struct/member.c2
-rw-r--r--ext/-test-/symbol/depend4
-rw-r--r--ext/-test-/thread/id/depend163
-rw-r--r--ext/-test-/thread/id/extconf.rb3
-rw-r--r--ext/-test-/thread/id/id.c15
-rw-r--r--ext/-test-/thread/instrumentation/depend2
-rw-r--r--ext/-test-/thread/instrumentation/instrumentation.c213
-rw-r--r--ext/-test-/thread/lock_native_thread/depend163
-rw-r--r--ext/-test-/thread/lock_native_thread/extconf.rb2
-rw-r--r--ext/-test-/thread/lock_native_thread/lock_native_thread.c50
-rw-r--r--ext/-test-/thread_fd/depend160
-rw-r--r--ext/-test-/thread_fd/extconf.rb2
-rw-r--r--ext/-test-/thread_fd/thread_fd.c30
-rw-r--r--ext/-test-/time/depend6
-rw-r--r--ext/-test-/time/leap_second.c15
-rw-r--r--ext/-test-/tracepoint/depend4
-rw-r--r--ext/-test-/tracepoint/gc_hook.c30
-rw-r--r--ext/-test-/tracepoint/tracepoint.c10
-rw-r--r--ext/-test-/typeddata/depend2
-rw-r--r--ext/-test-/vm/depend2
-rw-r--r--ext/-test-/wait/depend2
-rw-r--r--ext/-test-/win32/dln/extconf.rb1
-rw-r--r--ext/.document26
-rw-r--r--ext/Setup13
-rw-r--r--ext/Setup.atheos21
-rw-r--r--ext/Setup.nt22
-rw-r--r--ext/bigdecimal/bigdecimal.c7737
-rw-r--r--ext/bigdecimal/bigdecimal.gemspec54
-rw-r--r--ext/bigdecimal/bigdecimal.h313
-rw-r--r--ext/bigdecimal/bits.h141
-rw-r--r--ext/bigdecimal/depend327
-rw-r--r--ext/bigdecimal/extconf.rb62
-rw-r--r--ext/bigdecimal/feature.h68
-rw-r--r--ext/bigdecimal/lib/bigdecimal.rb5
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb90
-rw-r--r--ext/bigdecimal/lib/bigdecimal/ludcmp.rb89
-rw-r--r--ext/bigdecimal/lib/bigdecimal/math.rb232
-rw-r--r--ext/bigdecimal/lib/bigdecimal/newton.rb80
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb185
-rw-r--r--ext/bigdecimal/missing.c27
-rw-r--r--ext/bigdecimal/missing.h196
-rw-r--r--ext/bigdecimal/missing/dtoa.c3462
-rw-r--r--ext/bigdecimal/sample/linear.rb74
-rw-r--r--ext/bigdecimal/sample/nlsolve.rb40
-rw-r--r--ext/bigdecimal/sample/pi.rb21
-rw-r--r--ext/bigdecimal/static_assert.h54
-rw-r--r--ext/cgi/escape/depend2
-rw-r--r--ext/cgi/escape/escape.c61
-rw-r--r--ext/cgi/escape/extconf.rb6
-rw-r--r--ext/continuation/depend2
-rw-r--r--ext/coverage/coverage.c304
-rw-r--r--ext/coverage/depend17
-rw-r--r--ext/coverage/lib/coverage.rb5
-rw-r--r--ext/date/date.gemspec8
-rw-r--r--ext/date/date_core.c563
-rw-r--r--ext/date/date_parse.c3
-rw-r--r--ext/date/date_strptime.c12
-rw-r--r--ext/date/depend8
-rw-r--r--ext/date/extconf.rb1
-rw-r--r--ext/date/lib/date.rb2
-rw-r--r--ext/date/prereq.mk2
-rw-r--r--ext/date/zonetab.h1250
-rw-r--r--ext/date/zonetab.list7
-rw-r--r--ext/digest/.document3
-rw-r--r--ext/digest/bubblebabble/bubblebabble.c7
-rw-r--r--ext/digest/bubblebabble/depend2
-rw-r--r--ext/digest/defs.h22
-rw-r--r--ext/digest/depend2
-rw-r--r--ext/digest/digest.c44
-rw-r--r--ext/digest/digest.h40
-rw-r--r--ext/digest/digest_conf.rb18
-rw-r--r--ext/digest/lib/digest/version.rb3
-rw-r--r--ext/digest/md5/depend4
-rw-r--r--ext/digest/md5/md5cc.h12
-rw-r--r--ext/digest/md5/md5init.c4
-rw-r--r--ext/digest/rmd160/depend4
-rw-r--r--ext/digest/rmd160/rmd160init.c3
-rw-r--r--ext/digest/sha1/depend4
-rw-r--r--ext/digest/sha1/sha1.c14
-rw-r--r--ext/digest/sha1/sha1cc.h8
-rw-r--r--ext/digest/sha1/sha1init.c3
-rw-r--r--ext/digest/sha2/depend4
-rw-r--r--ext/digest/sha2/sha2cc.h39
-rw-r--r--ext/digest/sha2/sha2init.c47
-rw-r--r--ext/digest/test.sh30
-rw-r--r--ext/erb/escape/escape.c41
-rw-r--r--ext/erb/escape/extconf.rb4
-rw-r--r--ext/etc/.document2
-rw-r--r--ext/etc/depend2
-rw-r--r--ext/etc/etc.c194
-rw-r--r--ext/etc/etc.gemspec5
-rw-r--r--ext/etc/extconf.rb60
-rw-r--r--ext/etc/mkconstants.rb32
-rwxr-xr-xext/extmk.rb116
-rw-r--r--ext/fcntl/depend2
-rw-r--r--ext/fcntl/fcntl.c150
-rw-r--r--ext/fcntl/fcntl.gemspec15
-rw-r--r--ext/fiddle/closure.c433
-rw-r--r--ext/fiddle/closure.h8
-rw-r--r--ext/fiddle/conversions.c330
-rw-r--r--ext/fiddle/conversions.h53
-rw-r--r--ext/fiddle/depend1388
-rw-r--r--ext/fiddle/extconf.rb251
-rw-r--r--ext/fiddle/fiddle.c692
-rw-r--r--ext/fiddle/fiddle.gemspec59
-rw-r--r--ext/fiddle/fiddle.h236
-rw-r--r--ext/fiddle/function.c491
-rw-r--r--ext/fiddle/function.h8
-rw-r--r--ext/fiddle/handle.c586
-rw-r--r--ext/fiddle/lib/fiddle.rb103
-rw-r--r--ext/fiddle/lib/fiddle/closure.rb74
-rw-r--r--ext/fiddle/lib/fiddle/cparser.rb264
-rw-r--r--ext/fiddle/lib/fiddle/function.rb29
-rw-r--r--ext/fiddle/lib/fiddle/import.rb320
-rw-r--r--ext/fiddle/lib/fiddle/pack.rb137
-rw-r--r--ext/fiddle/lib/fiddle/struct.rb539
-rw-r--r--ext/fiddle/lib/fiddle/types.rb73
-rw-r--r--ext/fiddle/lib/fiddle/value.rb120
-rw-r--r--ext/fiddle/lib/fiddle/version.rb3
-rw-r--r--ext/fiddle/memory_view.c321
-rw-r--r--ext/fiddle/pinned.c123
-rw-r--r--ext/fiddle/pointer.c853
-rw-r--r--ext/fiddle/win32/fficonfig.h29
-rw-r--r--ext/fiddle/win32/libffi-3.2.1-mswin.patch191
-rwxr-xr-xext/fiddle/win32/libffi-config.rb48
-rw-r--r--ext/fiddle/win32/libffi.mk.tmpl96
-rw-r--r--ext/io/console/.document2
-rw-r--r--ext/io/console/console.c1016
-rw-r--r--ext/io/console/depend5
-rw-r--r--ext/io/console/extconf.rb27
-rw-r--r--ext/io/console/io-console.gemspec32
-rw-r--r--ext/io/console/win32_vk.inc325
-rw-r--r--ext/io/console/win32_vk.list2
-rw-r--r--ext/io/nonblock/depend2
-rw-r--r--ext/io/nonblock/extconf.rb7
-rw-r--r--ext/io/nonblock/io-nonblock.gemspec4
-rw-r--r--ext/io/nonblock/nonblock.c75
-rw-r--r--ext/io/wait/depend3
-rw-r--r--ext/io/wait/extconf.rb22
-rw-r--r--ext/io/wait/io-wait.gemspec23
-rw-r--r--ext/io/wait/wait.c411
-rw-r--r--ext/json/VERSION1
-rw-r--r--ext/json/fbuffer/fbuffer.h303
-rw-r--r--ext/json/generator/depend9
-rw-r--r--ext/json/generator/extconf.rb18
-rw-r--r--ext/json/generator/generator.c2539
-rw-r--r--ext/json/generator/generator.h174
-rw-r--r--ext/json/json.gemspec101
-rw-r--r--ext/json/json.h116
-rw-r--r--ext/json/lib/json.rb138
-rw-r--r--ext/json/lib/json/add/bigdecimal.rb49
-rw-r--r--ext/json/lib/json/add/complex.rb35
-rw-r--r--ext/json/lib/json/add/core.rb3
-rw-r--r--ext/json/lib/json/add/date.rb34
-rw-r--r--ext/json/lib/json/add/date_time.rb35
-rw-r--r--ext/json/lib/json/add/exception.rb32
-rw-r--r--ext/json/lib/json/add/ostruct.rb41
-rw-r--r--ext/json/lib/json/add/range.rb41
-rw-r--r--ext/json/lib/json/add/rational.rb34
-rw-r--r--ext/json/lib/json/add/regexp.rb34
-rw-r--r--ext/json/lib/json/add/set.rb31
-rw-r--r--ext/json/lib/json/add/string.rb35
-rw-r--r--ext/json/lib/json/add/struct.rb36
-rw-r--r--ext/json/lib/json/add/symbol.rb41
-rw-r--r--ext/json/lib/json/add/time.rb44
-rw-r--r--ext/json/lib/json/common.rb1004
-rw-r--r--ext/json/lib/json/ext.rb40
-rw-r--r--ext/json/lib/json/ext/generator/state.rb103
-rw-r--r--ext/json/lib/json/generic_object.rb18
-rw-r--r--ext/json/lib/json/version.rb10
-rw-r--r--ext/json/parser/depend9
-rw-r--r--ext/json/parser/extconf.rb36
-rw-r--r--ext/json/parser/parser.c4938
-rw-r--r--ext/json/parser/parser.h96
-rw-r--r--ext/json/parser/parser.rl986
-rw-r--r--ext/json/parser/prereq.mk13
-rw-r--r--ext/json/simd/conf.rb24
-rw-r--r--ext/json/simd/simd.h208
-rw-r--r--ext/json/vendor/fpconv.c480
-rw-r--r--ext/json/vendor/jeaiii-ltoa.h267
-rw-r--r--ext/json/vendor/ryu.h819
-rw-r--r--ext/monitor/depend160
-rw-r--r--ext/monitor/extconf.rb2
-rw-r--r--ext/monitor/lib/monitor.rb283
-rw-r--r--ext/monitor/monitor.c225
-rw-r--r--ext/nkf/depend181
-rw-r--r--ext/nkf/extconf.rb3
-rw-r--r--ext/nkf/lib/kconv.rb283
-rw-r--r--ext/nkf/nkf-utf8/config.h51
-rw-r--r--ext/nkf/nkf-utf8/nkf.c7205
-rw-r--r--ext/nkf/nkf-utf8/nkf.h189
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c14638
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.h72
-rw-r--r--ext/nkf/nkf.c503
-rw-r--r--ext/nkf/nkf.gemspec24
-rw-r--r--ext/objspace/depend74
-rw-r--r--ext/objspace/object_tracing.c49
-rw-r--r--ext/objspace/objspace.c400
-rw-r--r--ext/objspace/objspace_dump.c271
-rw-r--r--ext/openssl/History.md333
-rw-r--r--ext/openssl/depend324
-rw-r--r--ext/openssl/extconf.rb137
-rw-r--r--ext/openssl/lib/openssl.rb16
-rw-r--r--ext/openssl/lib/openssl/bn.rb2
-rw-r--r--ext/openssl/lib/openssl/buffering.rb90
-rw-r--r--ext/openssl/lib/openssl/cipher.rb2
-rw-r--r--ext/openssl/lib/openssl/digest.rb28
-rw-r--r--ext/openssl/lib/openssl/marshal.rb2
-rw-r--r--ext/openssl/lib/openssl/pkey.rb120
-rw-r--r--ext/openssl/lib/openssl/ssl.rb165
-rw-r--r--ext/openssl/lib/openssl/version.rb3
-rw-r--r--ext/openssl/lib/openssl/x509.rb21
-rw-r--r--ext/openssl/openssl.gemspec13
-rw-r--r--ext/openssl/openssl_missing.c40
-rw-r--r--ext/openssl/openssl_missing.h231
-rw-r--r--ext/openssl/ossl.c859
-rw-r--r--ext/openssl/ossl.h54
-rw-r--r--ext/openssl/ossl_asn1.c959
-rw-r--r--ext/openssl/ossl_asn1.h36
-rw-r--r--ext/openssl/ossl_bio.c14
-rw-r--r--ext/openssl/ossl_bio.h2
-rw-r--r--ext/openssl/ossl_bn.c597
-rw-r--r--ext/openssl/ossl_bn.h3
-rw-r--r--ext/openssl/ossl_cipher.c507
-rw-r--r--ext/openssl/ossl_cipher.h16
-rw-r--r--ext/openssl/ossl_config.c26
-rw-r--r--ext/openssl/ossl_config.h2
-rw-r--r--ext/openssl/ossl_digest.c174
-rw-r--r--ext/openssl/ossl_digest.h15
-rw-r--r--ext/openssl/ossl_engine.c150
-rw-r--r--ext/openssl/ossl_engine.h5
-rw-r--r--ext/openssl/ossl_hmac.c74
-rw-r--r--ext/openssl/ossl_hmac.h5
-rw-r--r--ext/openssl/ossl_kdf.c219
-rw-r--r--ext/openssl/ossl_ns_spki.c86
-rw-r--r--ext/openssl/ossl_ns_spki.h6
-rw-r--r--ext/openssl/ossl_ocsp.c484
-rw-r--r--ext/openssl/ossl_ocsp.h9
-rw-r--r--ext/openssl/ossl_pkcs12.c118
-rw-r--r--ext/openssl/ossl_pkcs12.h5
-rw-r--r--ext/openssl/ossl_pkcs7.c427
-rw-r--r--ext/openssl/ossl_pkcs7.h24
-rw-r--r--ext/openssl/ossl_pkey.c546
-rw-r--r--ext/openssl/ossl_pkey.h212
-rw-r--r--ext/openssl/ossl_pkey_dh.c130
-rw-r--r--ext/openssl/ossl_pkey_dsa.c136
-rw-r--r--ext/openssl/ossl_pkey_ec.c500
-rw-r--r--ext/openssl/ossl_pkey_rsa.c242
-rw-r--r--ext/openssl/ossl_provider.c204
-rw-r--r--ext/openssl/ossl_provider.h5
-rw-r--r--ext/openssl/ossl_rand.c27
-rw-r--r--ext/openssl/ossl_rand.h5
-rw-r--r--ext/openssl/ossl_ssl.c1210
-rw-r--r--ext/openssl/ossl_ssl.h18
-rw-r--r--ext/openssl/ossl_ssl_session.c192
-rw-r--r--ext/openssl/ossl_ts.c335
-rw-r--r--ext/openssl/ossl_ts.h2
-rw-r--r--ext/openssl/ossl_x509.c39
-rw-r--r--ext/openssl/ossl_x509.h33
-rw-r--r--ext/openssl/ossl_x509attr.c156
-rw-r--r--ext/openssl/ossl_x509cert.c210
-rw-r--r--ext/openssl/ossl_x509crl.c175
-rw-r--r--ext/openssl/ossl_x509ext.c142
-rw-r--r--ext/openssl/ossl_x509name.c170
-rw-r--r--ext/openssl/ossl_x509req.c125
-rw-r--r--ext/openssl/ossl_x509revoked.c79
-rw-r--r--ext/openssl/ossl_x509store.c134
-rw-r--r--ext/pathname/depend173
-rw-r--r--ext/pathname/extconf.rb4
-rw-r--r--ext/pathname/lib/pathname.rb604
-rw-r--r--ext/pathname/pathname.c1701
-rw-r--r--ext/pathname/pathname.gemspec25
-rw-r--r--ext/psych/depend10
-rw-r--r--ext/psych/extconf.rb7
-rw-r--r--ext/psych/lib/psych.rb115
-rw-r--r--ext/psych/lib/psych/class_loader.rb1
-rw-r--r--ext/psych/lib/psych/core_ext.rb21
-rw-r--r--ext/psych/lib/psych/nodes/node.rb7
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb22
-rw-r--r--ext/psych/lib/psych/versions.rb4
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb57
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb77
-rw-r--r--ext/psych/psych.c3
-rw-r--r--ext/psych/psych.gemspec49
-rw-r--r--ext/psych/psych_emitter.c276
-rw-r--r--ext/psych/psych_parser.c536
-rw-r--r--ext/psych/psych_to_ruby.c5
-rw-r--r--ext/psych/psych_yaml_tree.c1
-rw-r--r--ext/pty/depend3
-rw-r--r--ext/pty/extconf.rb9
-rw-r--r--ext/pty/pty.c229
-rw-r--r--ext/racc/cparse/README11
-rw-r--r--ext/racc/cparse/cparse.c861
-rw-r--r--ext/racc/cparse/depend161
-rw-r--r--ext/racc/cparse/extconf.rb9
-rw-r--r--ext/rbconfig/sizeof/depend4
-rw-r--r--ext/readline/.gitignore1
-rw-r--r--ext/readline/README10
-rw-r--r--ext/readline/README.ja386
-rw-r--r--ext/readline/depend174
-rw-r--r--ext/readline/depend-gem4
-rw-r--r--ext/readline/extconf.rb112
-rw-r--r--ext/readline/readline-ext.gemspec22
-rw-r--r--ext/readline/readline.c2144
-rw-r--r--ext/ripper/README1
-rw-r--r--ext/ripper/depend588
-rw-r--r--ext/ripper/eventids2.c15
-rw-r--r--ext/ripper/eventids2.h8
-rw-r--r--ext/ripper/extconf.rb15
-rw-r--r--ext/ripper/lib/ripper/lexer.rb11
-rw-r--r--ext/ripper/ripper_init.c.tmpl680
-rw-r--r--ext/ripper/ripper_init.h6
-rw-r--r--ext/ripper/tools/dsl.rb173
-rw-r--r--ext/ripper/tools/generate.rb51
-rw-r--r--ext/ripper/tools/preproc.rb115
-rw-r--r--ext/socket/ancdata.c14
-rw-r--r--ext/socket/basicsocket.c6
-rw-r--r--ext/socket/depend375
-rw-r--r--ext/socket/extconf.rb8
-rw-r--r--ext/socket/getaddrinfo.c10
-rw-r--r--ext/socket/getnameinfo.c18
-rw-r--r--ext/socket/ifaddr.c2
-rw-r--r--ext/socket/init.c135
-rw-r--r--ext/socket/ipsocket.c1325
-rw-r--r--ext/socket/lib/socket.rb526
-rw-r--r--ext/socket/mkconstants.rb46
-rw-r--r--ext/socket/raddrinfo.c770
-rw-r--r--ext/socket/rubysocket.h66
-rw-r--r--ext/socket/socket.c103
-rw-r--r--ext/socket/sockssocket.c7
-rw-r--r--ext/socket/tcpserver.c2
-rw-r--r--ext/socket/tcpsocket.c47
-rw-r--r--ext/socket/udpsocket.c57
-rw-r--r--ext/socket/unixsocket.c43
-rw-r--r--ext/stringio/.document1
-rw-r--r--ext/stringio/depend3
-rw-r--r--ext/stringio/extconf.rb9
-rw-r--r--ext/stringio/stringio.c741
-rw-r--r--ext/stringio/stringio.gemspec16
-rw-r--r--ext/strscan/depend2
-rw-r--r--ext/strscan/extconf.rb7
-rw-r--r--ext/strscan/lib/strscan.rb20
-rw-r--r--ext/strscan/lib/strscan/strscan.rb55
-rw-r--r--ext/strscan/strscan.c1908
-rw-r--r--ext/strscan/strscan.gemspec20
-rw-r--r--ext/syslog/depend161
-rw-r--r--ext/syslog/extconf.rb13
-rw-r--r--ext/syslog/lib/syslog/logger.rb209
-rw-r--r--ext/syslog/syslog.c588
-rw-r--r--ext/syslog/syslog.gemspec23
-rw-r--r--ext/syslog/syslog.txt124
-rw-r--r--ext/win32/lib/win32/registry.rb913
-rw-r--r--ext/win32/lib/win32/resolv.rb116
-rw-r--r--ext/win32/lib/win32/sspi.rb338
-rw-r--r--ext/win32/resolv/extconf.rb6
-rw-r--r--ext/win32/resolv/resolv.c212
-rw-r--r--ext/win32ole/depend12
-rw-r--r--ext/win32ole/extconf.rb45
-rw-r--r--ext/win32ole/lib/win32ole.rb33
-rw-r--r--ext/win32ole/lib/win32ole/property.rb17
-rw-r--r--ext/win32ole/sample/excel1.rb37
-rw-r--r--ext/win32ole/sample/excel2.rb31
-rw-r--r--ext/win32ole/sample/excel3.rb21
-rw-r--r--ext/win32ole/sample/ie.rb12
-rw-r--r--ext/win32ole/sample/ieconst.rb33
-rw-r--r--ext/win32ole/sample/ienavi.rb41
-rw-r--r--ext/win32ole/sample/ienavi2.rb41
-rw-r--r--ext/win32ole/sample/oledirs.rb24
-rw-r--r--ext/win32ole/sample/olegen.rb348
-rw-r--r--ext/win32ole/sample/xml.rb7307
-rw-r--r--ext/win32ole/win32ole.c4142
-rw-r--r--ext/win32ole/win32ole.gemspec22
-rw-r--r--ext/win32ole/win32ole.h155
-rw-r--r--ext/win32ole/win32ole_error.c87
-rw-r--r--ext/win32ole/win32ole_error.h9
-rw-r--r--ext/win32ole/win32ole_event.c1278
-rw-r--r--ext/win32ole/win32ole_event.h6
-rw-r--r--ext/win32ole/win32ole_method.c953
-rw-r--r--ext/win32ole/win32ole_method.h16
-rw-r--r--ext/win32ole/win32ole_param.c439
-rw-r--r--ext/win32ole/win32ole_param.h8
-rw-r--r--ext/win32ole/win32ole_record.c607
-rw-r--r--ext/win32ole/win32ole_record.h10
-rw-r--r--ext/win32ole/win32ole_type.c918
-rw-r--r--ext/win32ole/win32ole_type.h8
-rw-r--r--ext/win32ole/win32ole_typelib.c847
-rw-r--r--ext/win32ole/win32ole_typelib.h11
-rw-r--r--ext/win32ole/win32ole_variable.c384
-rw-r--r--ext/win32ole/win32ole_variable.h8
-rw-r--r--ext/win32ole/win32ole_variant.c736
-rw-r--r--ext/win32ole/win32ole_variant.h9
-rw-r--r--ext/win32ole/win32ole_variant_m.c151
-rw-r--r--ext/win32ole/win32ole_variant_m.h7
-rw-r--r--ext/zlib/depend2
-rw-r--r--ext/zlib/extconf.rb10
-rw-r--r--ext/zlib/zlib.c499
-rw-r--r--ext/zlib/zlib.gemspec4
-rw-r--r--file.c2484
-rw-r--r--gc.c14853
-rw-r--r--gc.rb700
-rw-r--r--gc/README.md37
-rw-r--r--gc/default/default.c9834
-rw-r--r--gc/default/extconf.rb5
-rw-r--r--gc/extconf_base.rb14
-rw-r--r--gc/gc.h293
-rw-r--r--gc/gc_impl.h127
-rw-r--r--gc/mmtk/.gitignore1
-rw-r--r--gc/mmtk/Cargo.lock1108
-rw-r--r--gc/mmtk/Cargo.toml42
-rw-r--r--gc/mmtk/cbindgen.toml36
-rw-r--r--gc/mmtk/depend18
-rw-r--r--gc/mmtk/extconf.rb24
-rw-r--r--gc/mmtk/mmtk.c1656
-rw-r--r--gc/mmtk/mmtk.h175
-rw-r--r--gc/mmtk/src/abi.rs335
-rw-r--r--gc/mmtk/src/active_plan.rs56
-rw-r--r--gc/mmtk/src/api.rs551
-rw-r--r--gc/mmtk/src/binding.rs129
-rw-r--r--gc/mmtk/src/collection.rs122
-rw-r--r--gc/mmtk/src/heap/cpu_heap_trigger.rs370
-rw-r--r--gc/mmtk/src/heap/mod.rs9
-rw-r--r--gc/mmtk/src/heap/ruby_heap_trigger.rs105
-rw-r--r--gc/mmtk/src/lib.rs161
-rw-r--r--gc/mmtk/src/object_model.rs124
-rw-r--r--gc/mmtk/src/pinning_registry.rs187
-rw-r--r--gc/mmtk/src/reference_glue.rs26
-rw-r--r--gc/mmtk/src/scanning.rs291
-rw-r--r--gc/mmtk/src/utils.rs161
-rw-r--r--gc/mmtk/src/weak_proc.rs328
-rw-r--r--gc/wbcheck/extconf.rb3
-rw-r--r--gc/wbcheck/wbcheck.c1936
-rw-r--r--gem_prelude.rb3
-rw-r--r--gems/bundled_gems55
-rw-r--r--gems/lib/core_assertions.rb1
-rw-r--r--gems/lib/envutil.rb1
-rw-r--r--gems/lib/rake/extensiontask.rb14
-rw-r--r--goruby.c10
-rw-r--r--hash.c3090
-rw-r--r--hash.rb40
-rw-r--r--hrtime.h14
-rw-r--r--id_table.c212
-rw-r--r--id_table.h34
-rw-r--r--imemo.c744
-rw-r--r--include/ruby/assert.h112
-rw-r--r--include/ruby/atomic.h503
-rw-r--r--include/ruby/backward.h6
-rw-r--r--include/ruby/backward/2/rmodule.h2
-rw-r--r--include/ruby/backward/cxxanyargs.hpp29
-rw-r--r--include/ruby/debug.h194
-rw-r--r--include/ruby/fiber/scheduler.h187
-rw-r--r--include/ruby/intern.h1
-rw-r--r--include/ruby/internal/abi.h4
-rw-r--r--include/ruby/internal/anyargs.h22
-rw-r--r--include/ruby/internal/arithmetic/int.h2
-rw-r--r--include/ruby/internal/arithmetic/intptr_t.h12
-rw-r--r--include/ruby/internal/arithmetic/long.h14
-rw-r--r--include/ruby/internal/arithmetic/long_long.h2
-rw-r--r--include/ruby/internal/arithmetic/st_data_t.h4
-rw-r--r--include/ruby/internal/attr/deprecated.h9
-rw-r--r--include/ruby/internal/attr/forceinline.h2
-rw-r--r--include/ruby/internal/attr/format.h4
-rw-r--r--include/ruby/internal/attr/noexcept.h4
-rw-r--r--include/ruby/internal/attr/nonstring.h40
-rw-r--r--include/ruby/internal/attr/restrict.h2
-rw-r--r--include/ruby/internal/compiler_is/msvc.h13
-rw-r--r--include/ruby/internal/config.h6
-rw-r--r--include/ruby/internal/core/rarray.h202
-rw-r--r--include/ruby/internal/core/rbasic.h34
-rw-r--r--include/ruby/internal/core/rclass.h2
-rw-r--r--include/ruby/internal/core/rdata.h314
-rw-r--r--include/ruby/internal/core/rfile.h4
-rw-r--r--include/ruby/internal/core/rmatch.h57
-rw-r--r--include/ruby/internal/core/robject.h71
-rw-r--r--include/ruby/internal/core/rstring.h163
-rw-r--r--include/ruby/internal/core/rstruct.h12
-rw-r--r--include/ruby/internal/core/rtypeddata.h314
-rw-r--r--include/ruby/internal/ctype.h4
-rw-r--r--include/ruby/internal/encoding/coderange.h2
-rw-r--r--include/ruby/internal/encoding/encoding.h3
-rw-r--r--include/ruby/internal/encoding/string.h37
-rw-r--r--include/ruby/internal/error.h47
-rw-r--r--include/ruby/internal/eval.h15
-rw-r--r--include/ruby/internal/event.h5
-rw-r--r--include/ruby/internal/fl_type.h327
-rw-r--r--include/ruby/internal/gc.h206
-rw-r--r--include/ruby/internal/globals.h4
-rw-r--r--include/ruby/internal/has/builtin.h4
-rw-r--r--include/ruby/internal/has/c_attribute.h12
-rw-r--r--include/ruby/internal/intern/array.h10
-rw-r--r--include/ruby/internal/intern/bignum.h49
-rw-r--r--include/ruby/internal/intern/class.h8
-rw-r--r--include/ruby/internal/intern/complex.h4
-rw-r--r--include/ruby/internal/intern/cont.h11
-rw-r--r--include/ruby/internal/intern/enumerator.h12
-rw-r--r--include/ruby/internal/intern/error.h18
-rw-r--r--include/ruby/internal/intern/file.h3
-rw-r--r--include/ruby/internal/intern/hash.h14
-rw-r--r--include/ruby/internal/intern/io.h2
-rw-r--r--include/ruby/internal/intern/load.h37
-rw-r--r--include/ruby/internal/intern/object.h6
-rw-r--r--include/ruby/internal/intern/proc.h12
-rw-r--r--include/ruby/internal/intern/process.h11
-rw-r--r--include/ruby/internal/intern/re.h5
-rw-r--r--include/ruby/internal/intern/select.h4
-rw-r--r--include/ruby/internal/intern/select/win32.h4
-rw-r--r--include/ruby/internal/intern/set.h111
-rw-r--r--include/ruby/internal/intern/signal.h8
-rw-r--r--include/ruby/internal/intern/string.h33
-rw-r--r--include/ruby/internal/intern/struct.h38
-rw-r--r--include/ruby/internal/intern/thread.h8
-rw-r--r--include/ruby/internal/intern/variable.h1
-rw-r--r--include/ruby/internal/intern/vm.h10
-rw-r--r--include/ruby/internal/interpreter.h2
-rw-r--r--include/ruby/internal/iterator.h45
-rw-r--r--include/ruby/internal/memory.h150
-rw-r--r--include/ruby/internal/module.h16
-rw-r--r--include/ruby/internal/newobj.h87
-rw-r--r--include/ruby/internal/scan_args.h8
-rw-r--r--include/ruby/internal/special_consts.h8
-rw-r--r--include/ruby/internal/static_assert.h5
-rw-r--r--include/ruby/internal/stdbool.h16
-rw-r--r--include/ruby/internal/stdckdint.h68
-rw-r--r--include/ruby/internal/symbol.h75
-rw-r--r--include/ruby/internal/value_type.h33
-rw-r--r--include/ruby/internal/warning_push.h2
-rw-r--r--include/ruby/internal/xmalloc.h249
-rw-r--r--include/ruby/io.h365
-rw-r--r--include/ruby/io/buffer.h30
-rw-r--r--include/ruby/memory_view.h4
-rw-r--r--include/ruby/onigmo.h19
-rw-r--r--include/ruby/ractor.h16
-rw-r--r--include/ruby/random.h5
-rw-r--r--include/ruby/re.h25
-rw-r--r--include/ruby/ruby.h139
-rw-r--r--include/ruby/st.h7
-rw-r--r--include/ruby/thread.h120
-rw-r--r--include/ruby/thread_native.h5
-rw-r--r--include/ruby/util.h4
-rw-r--r--include/ruby/version.h4
-rw-r--r--include/ruby/vm.h7
-rw-r--r--include/ruby/win32.h60
-rw-r--r--inits.c29
-rw-r--r--insns.def527
-rw-r--r--internal.h7
-rw-r--r--internal/array.h34
-rw-r--r--internal/basic_operators.h4
-rw-r--r--internal/bignum.h42
-rw-r--r--internal/bits.h133
-rw-r--r--internal/box.h96
-rw-r--r--internal/class.h711
-rw-r--r--internal/cmdlineopt.h13
-rw-r--r--internal/compar.h1
-rw-r--r--internal/compile.h1
-rw-r--r--internal/concurrent_set.h21
-rw-r--r--internal/cont.h4
-rw-r--r--internal/encoding.h9
-rw-r--r--internal/error.h76
-rw-r--r--internal/eval.h11
-rw-r--r--internal/file.h2
-rw-r--r--internal/fixnum.h1
-rw-r--r--internal/gc.h221
-rw-r--r--internal/hash.h74
-rw-r--r--internal/imemo.h201
-rw-r--r--internal/inits.h7
-rw-r--r--internal/io.h136
-rw-r--r--internal/load.h2
-rw-r--r--internal/missing.h1
-rw-r--r--internal/numeric.h58
-rw-r--r--internal/object.h13
-rw-r--r--internal/parse.h120
-rw-r--r--internal/proc.h2
-rw-r--r--internal/process.h14
-rw-r--r--internal/ractor.h4
-rw-r--r--internal/random.h1
-rw-r--r--internal/range.h6
-rw-r--r--internal/rational.h23
-rw-r--r--internal/re.h59
-rw-r--r--internal/ruby_parser.h102
-rw-r--r--internal/sanitizers.h258
-rw-r--r--internal/set_table.h74
-rw-r--r--internal/signal.h6
-rw-r--r--internal/st.h20
-rw-r--r--internal/string.h112
-rw-r--r--internal/struct.h118
-rw-r--r--internal/symbol.h4
-rw-r--r--internal/thread.h55
-rw-r--r--internal/time.h4
-rw-r--r--internal/transcode.h3
-rw-r--r--internal/variable.h80
-rw-r--r--internal/vm.h32
-rw-r--r--io.c2138
-rw-r--r--io.rb13
-rw-r--r--io_buffer.c2417
-rw-r--r--iseq.c1368
-rw-r--r--iseq.h50
-rw-r--r--jit.c844
-rw-r--r--jit/Cargo.toml6
-rw-r--r--jit/src/lib.rs38
-rw-r--r--jit_hook.rb12
-rw-r--r--jit_undef.rb4
-rw-r--r--kernel.rb165
-rw-r--r--lex.c.blt85
-rw-r--r--lib/English.gemspec11
-rw-r--r--lib/English.rb72
-rw-r--r--lib/abbrev.gemspec22
-rw-r--r--lib/abbrev.rb132
-rw-r--r--lib/base64.gemspec20
-rw-r--r--lib/base64.rb110
-rw-r--r--lib/benchmark.rb582
-rw-r--r--lib/benchmark/benchmark.gemspec29
-rw-r--r--lib/benchmark/version.rb4
-rw-r--r--lib/bundled_gems.rb275
-rw-r--r--lib/bundler.rb281
-rw-r--r--lib/bundler/build_metadata.rb20
-rw-r--r--lib/bundler/bundler.gemspec14
-rw-r--r--lib/bundler/capistrano.rb20
-rw-r--r--lib/bundler/checksum.rb270
-rw-r--r--lib/bundler/ci_detector.rb75
-rw-r--r--lib/bundler/cli.rb716
-rw-r--r--lib/bundler/cli/add.rb23
-rw-r--r--lib/bundler/cli/binstubs.rb8
-rw-r--r--lib/bundler/cli/cache.rb15
-rw-r--r--lib/bundler/cli/check.rb8
-rw-r--r--lib/bundler/cli/common.rb41
-rw-r--r--lib/bundler/cli/config.rb25
-rw-r--r--lib/bundler/cli/console.rb22
-rw-r--r--lib/bundler/cli/doctor.rb178
-rw-r--r--lib/bundler/cli/doctor/diagnose.rb167
-rw-r--r--lib/bundler/cli/doctor/ssl.rb249
-rw-r--r--lib/bundler/cli/exec.rb34
-rw-r--r--lib/bundler/cli/fund.rb2
-rw-r--r--lib/bundler/cli/gem.rb221
-rw-r--r--lib/bundler/cli/info.rb27
-rw-r--r--lib/bundler/cli/inject.rb60
-rw-r--r--lib/bundler/cli/install.rb120
-rw-r--r--lib/bundler/cli/issue.rb10
-rw-r--r--lib/bundler/cli/list.rb35
-rw-r--r--lib/bundler/cli/lock.rb80
-rw-r--r--lib/bundler/cli/open.rb12
-rw-r--r--lib/bundler/cli/outdated.rb100
-rw-r--r--lib/bundler/cli/plugin.rb28
-rw-r--r--lib/bundler/cli/pristine.rb68
-rw-r--r--lib/bundler/cli/show.rb16
-rw-r--r--lib/bundler/cli/update.rb21
-rw-r--r--lib/bundler/cli/viz.rb31
-rw-r--r--lib/bundler/compact_index_client.rb135
-rw-r--r--lib/bundler/compact_index_client/cache.rb117
-rw-r--r--lib/bundler/compact_index_client/cache_file.rb148
-rw-r--r--lib/bundler/compact_index_client/gem_parser.rb28
-rw-r--r--lib/bundler/compact_index_client/parser.rb87
-rw-r--r--lib/bundler/compact_index_client/updater.rb152
-rw-r--r--lib/bundler/constants.rb9
-rw-r--r--lib/bundler/current_ruby.rb72
-rw-r--r--lib/bundler/definition.rb1068
-rw-r--r--lib/bundler/dependency.rb147
-rw-r--r--lib/bundler/deployment.rb65
-rw-r--r--lib/bundler/digest.rb4
-rw-r--r--lib/bundler/dsl.rb343
-rw-r--r--lib/bundler/endpoint_specification.rb53
-rw-r--r--lib/bundler/env.rb6
-rw-r--r--lib/bundler/environment_preserver.rb29
-rw-r--r--lib/bundler/errors.rb135
-rw-r--r--lib/bundler/feature_flag.rb46
-rw-r--r--lib/bundler/fetcher.rb201
-rw-r--r--lib/bundler/fetcher/base.rb8
-rw-r--r--lib/bundler/fetcher/compact_index.rb57
-rw-r--r--lib/bundler/fetcher/dependency.rb19
-rw-r--r--lib/bundler/fetcher/downloader.rb67
-rw-r--r--lib/bundler/fetcher/gem_remote_fetcher.rb22
-rw-r--r--lib/bundler/fetcher/index.rb5
-rw-r--r--lib/bundler/force_platform.rb2
-rw-r--r--lib/bundler/friendly_errors.rb19
-rw-r--r--lib/bundler/gem_helper.rb4
-rw-r--r--lib/bundler/gem_helpers.rb117
-rw-r--r--lib/bundler/gem_version_promoter.rb84
-rw-r--r--lib/bundler/graph.rb152
-rw-r--r--lib/bundler/index.rb102
-rw-r--r--lib/bundler/injector.rb43
-rw-r--r--lib/bundler/inline.rb117
-rw-r--r--lib/bundler/installer.rb107
-rw-r--r--lib/bundler/installer/gem_installer.rb48
-rw-r--r--lib/bundler/installer/parallel_installer.rb147
-rw-r--r--lib/bundler/installer/standalone.rb26
-rw-r--r--lib/bundler/lazy_specification.rb249
-rw-r--r--lib/bundler/lockfile_generator.rb30
-rw-r--r--lib/bundler/lockfile_parser.rb198
-rw-r--r--lib/bundler/man/bundle-add.1102
-rw-r--r--lib/bundler/man/bundle-add.1.ronn85
-rw-r--r--lib/bundler/man/bundle-binstubs.132
-rw-r--r--lib/bundler/man/bundle-binstubs.1.ronn15
-rw-r--r--lib/bundler/man/bundle-cache.151
-rw-r--r--lib/bundler/man/bundle-cache.1.ronn28
-rw-r--r--lib/bundler/man/bundle-check.124
-rw-r--r--lib/bundler/man/bundle-check.1.ronn10
-rw-r--r--lib/bundler/man/bundle-clean.113
-rw-r--r--lib/bundler/man/bundle-config.1414
-rw-r--r--lib/bundler/man/bundle-config.1.ronn313
-rw-r--r--lib/bundler/man/bundle-console.130
-rw-r--r--lib/bundler/man/bundle-console.1.ronn9
-rw-r--r--lib/bundler/man/bundle-doctor.169
-rw-r--r--lib/bundler/man/bundle-doctor.1.ronn54
-rw-r--r--lib/bundler/man/bundle-env.19
-rw-r--r--lib/bundler/man/bundle-env.1.ronn10
-rw-r--r--lib/bundler/man/bundle-exec.191
-rw-r--r--lib/bundler/man/bundle-exec.1.ronn12
-rw-r--r--lib/bundler/man/bundle-fund.122
-rw-r--r--lib/bundler/man/bundle-fund.1.ronn25
-rw-r--r--lib/bundler/man/bundle-gem.1144
-rw-r--r--lib/bundler/man/bundle-gem.1.ronn47
-rw-r--r--lib/bundler/man/bundle-help.110
-rw-r--r--lib/bundler/man/bundle-info.119
-rw-r--r--lib/bundler/man/bundle-info.1.ronn14
-rw-r--r--lib/bundler/man/bundle-init.119
-rw-r--r--lib/bundler/man/bundle-init.1.ronn5
-rw-r--r--lib/bundler/man/bundle-inject.136
-rw-r--r--lib/bundler/man/bundle-inject.1.ronn24
-rw-r--r--lib/bundler/man/bundle-install.1221
-rw-r--r--lib/bundler/man/bundle-install.1.ronn160
-rw-r--r--lib/bundler/man/bundle-issue.145
-rw-r--r--lib/bundler/man/bundle-issue.1.ronn37
-rw-r--r--lib/bundler/man/bundle-licenses.19
-rw-r--r--lib/bundler/man/bundle-licenses.1.ronn10
-rw-r--r--lib/bundler/man/bundle-list.128
-rw-r--r--lib/bundler/man/bundle-list.1.ronn10
-rw-r--r--lib/bundler/man/bundle-lock.159
-rw-r--r--lib/bundler/man/bundle-lock.1.ronn29
-rw-r--r--lib/bundler/man/bundle-open.136
-rw-r--r--lib/bundler/man/bundle-open.1.ronn3
-rw-r--r--lib/bundler/man/bundle-outdated.192
-rw-r--r--lib/bundler/man/bundle-outdated.1.ronn39
-rw-r--r--lib/bundler/man/bundle-platform.132
-rw-r--r--lib/bundler/man/bundle-plugin.191
-rw-r--r--lib/bundler/man/bundle-plugin.1.ronn57
-rw-r--r--lib/bundler/man/bundle-pristine.121
-rw-r--r--lib/bundler/man/bundle-pristine.1.ronn2
-rw-r--r--lib/bundler/man/bundle-remove.124
-rw-r--r--lib/bundler/man/bundle-remove.1.ronn11
-rw-r--r--lib/bundler/man/bundle-show.113
-rw-r--r--lib/bundler/man/bundle-update.1180
-rw-r--r--lib/bundler/man/bundle-update.1.ronn34
-rw-r--r--lib/bundler/man/bundle-version.119
-rw-r--r--lib/bundler/man/bundle-viz.142
-rw-r--r--lib/bundler/man/bundle-viz.1.ronn32
-rw-r--r--lib/bundler/man/bundle.158
-rw-r--r--lib/bundler/man/bundle.1.ronn9
-rw-r--r--lib/bundler/man/gemfile.5410
-rw-r--r--lib/bundler/man/gemfile.5.ronn103
-rw-r--r--lib/bundler/man/index.txt6
-rw-r--r--lib/bundler/match_metadata.rb37
-rw-r--r--lib/bundler/match_platform.rb43
-rw-r--r--lib/bundler/match_remote_metadata.rb27
-rw-r--r--lib/bundler/materialization.rb59
-rw-r--r--lib/bundler/mirror.rb6
-rw-r--r--lib/bundler/override.rb69
-rw-r--r--lib/bundler/plugin.rb51
-rw-r--r--lib/bundler/plugin/api/source.rb22
-rw-r--r--lib/bundler/plugin/events.rb78
-rw-r--r--lib/bundler/plugin/index.rb66
-rw-r--r--lib/bundler/plugin/installer.rb58
-rw-r--r--lib/bundler/plugin/installer/path.rb26
-rw-r--r--lib/bundler/plugin/source_list.rb10
-rw-r--r--lib/bundler/process_lock.rb24
-rw-r--r--lib/bundler/remote_specification.rb19
-rw-r--r--lib/bundler/resolver.rb366
-rw-r--r--lib/bundler/resolver/base.rb64
-rw-r--r--lib/bundler/resolver/candidate.rb45
-rw-r--r--lib/bundler/resolver/incompatibility.rb2
-rw-r--r--lib/bundler/resolver/package.rb29
-rw-r--r--lib/bundler/resolver/spec_group.rb52
-rw-r--r--lib/bundler/resolver/strategy.rb43
-rw-r--r--lib/bundler/retry.rb36
-rw-r--r--lib/bundler/ruby_dsl.rb63
-rw-r--r--lib/bundler/ruby_version.rb25
-rw-r--r--lib/bundler/rubygems_ext.rb548
-rw-r--r--lib/bundler/rubygems_gem_installer.rb154
-rw-r--r--lib/bundler/rubygems_integration.rb222
-rw-r--r--lib/bundler/runtime.rb104
-rw-r--r--lib/bundler/safe_marshal.rb31
-rw-r--r--lib/bundler/self_manager.rb83
-rw-r--r--lib/bundler/settings.rb208
-rw-r--r--lib/bundler/settings/validator.rb26
-rw-r--r--lib/bundler/setup.rb11
-rw-r--r--lib/bundler/shared_helpers.rb142
-rw-r--r--lib/bundler/similarity_detector.rb63
-rw-r--r--lib/bundler/source.rb10
-rw-r--r--lib/bundler/source/gemspec.rb5
-rw-r--r--lib/bundler/source/git.rb217
-rw-r--r--lib/bundler/source/git/git_proxy.rb206
-rw-r--r--lib/bundler/source/metadata.rb35
-rw-r--r--lib/bundler/source/path.rb60
-rw-r--r--lib/bundler/source/path/installer.rb2
-rw-r--r--lib/bundler/source/rubygems.rb347
-rw-r--r--lib/bundler/source/rubygems/remote.rb30
-rw-r--r--lib/bundler/source/rubygems_aggregate.rb5
-rw-r--r--lib/bundler/source_list.rb117
-rw-r--r--lib/bundler/source_map.rb15
-rw-r--r--lib/bundler/spec_set.rb354
-rw-r--r--lib/bundler/stub_specification.rb39
-rw-r--r--lib/bundler/templates/Executable11
-rw-r--r--lib/bundler/templates/Executable.bundler109
-rw-r--r--lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt88
-rw-r--r--lib/bundler/templates/newgem/Cargo.toml.tt6
-rw-r--r--lib/bundler/templates/newgem/Gemfile.tt12
-rw-r--r--lib/bundler/templates/newgem/README.md.tt10
-rw-r--r--lib/bundler/templates/newgem/Rakefile.tt21
-rw-r--r--lib/bundler/templates/newgem/bin/console.tt4
-rw-r--r--lib/bundler/templates/newgem/circleci/config.yml.tt12
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt9
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/build.rs.tt5
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt5
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt11
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/go.mod.tt5
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt2
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem.c.tt2
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem.go.tt31
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt21
-rw-r--r--lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt69
-rw-r--r--lib/bundler/templates/newgem/github/workflows/main.yml.tt41
-rw-r--r--lib/bundler/templates/newgem/gitlab-ci.yml.tt9
-rw-r--r--lib/bundler/templates/newgem/lib/newgem.rb.tt2
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt42
-rw-r--r--lib/bundler/templates/newgem/rubocop.yml.tt5
-rw-r--r--lib/bundler/templates/newgem/spec/newgem_spec.rb.tt8
-rw-r--r--lib/bundler/templates/newgem/standard.yml.tt2
-rw-r--r--lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt6
-rw-r--r--lib/bundler/ui/shell.rb48
-rw-r--r--lib/bundler/ui/silent.rb13
-rw-r--r--lib/bundler/uri_credentials_filter.rb6
-rw-r--r--lib/bundler/uri_normalizer.rb23
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool.rb125
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb117
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb2
-rw-r--r--lib/bundler/vendor/fileutils/lib/fileutils.rb161
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb262
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb7
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb34
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb5
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb28
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb1
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb42
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb28
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb59
-rw-r--r--lib/bundler/vendor/securerandom/lib/securerandom.rb102
-rw-r--r--lib/bundler/vendor/thor/lib/thor.rb176
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions.rb30
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_file.rb5
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/directory.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb74
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb19
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb154
-rw-r--r--lib/bundler/vendor/thor/lib/thor/command.rb17
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb41
-rw-r--r--lib/bundler/vendor/thor/lib/thor/group.rb13
-rw-r--r--lib/bundler/vendor/thor/lib/thor/invocation.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/nested_context.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/argument.rb18
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/arguments.rb50
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/option.rb37
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb53
-rw-r--r--lib/bundler/vendor/thor/lib/thor/rake_compat.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb74
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/basic.rb204
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/color.rb47
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb29
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/html.rb47
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb118
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/terminal.rb42
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb38
-rw-r--r--lib/bundler/vendor/thor/lib/thor/util.rb15
-rw-r--r--lib/bundler/vendor/thor/lib/thor/version.rb2
-rw-r--r--lib/bundler/vendor/tsort/lib/tsort.rb3
-rw-r--r--lib/bundler/vendor/uri/lib/uri.rb18
-rw-r--r--lib/bundler/vendor/uri/lib/uri/common.rb509
-rw-r--r--lib/bundler/vendor/uri/lib/uri/file.rb8
-rw-r--r--lib/bundler/vendor/uri/lib/uri/ftp.rb2
-rw-r--r--lib/bundler/vendor/uri/lib/uri/generic.rb115
-rw-r--r--lib/bundler/vendor/uri/lib/uri/http.rb16
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb46
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb157
-rw-r--r--lib/bundler/vendor/uri/lib/uri/version.rb4
-rw-r--r--lib/bundler/vendored_net_http.rb23
-rw-r--r--lib/bundler/vendored_persistent.rb4
-rw-r--r--lib/bundler/vendored_securerandom.rb12
-rw-r--r--lib/bundler/vendored_timeout.rb12
-rw-r--r--lib/bundler/vendored_uri.rb19
-rw-r--r--lib/bundler/version.rb12
-rw-r--r--lib/bundler/vlad.rb15
-rw-r--r--lib/bundler/worker.rb16
-rw-r--r--lib/bundler/yaml_serializer.rb35
-rw-r--r--lib/cgi.rb300
-rw-r--r--lib/cgi/cgi.gemspec42
-rw-r--r--lib/cgi/cookie.rb209
-rw-r--r--lib/cgi/core.rb900
-rw-r--r--lib/cgi/escape.rb232
-rw-r--r--lib/cgi/html.rb1035
-rw-r--r--lib/cgi/session.rb562
-rw-r--r--lib/cgi/session/pstore.rb88
-rw-r--r--lib/cgi/util.rb255
-rw-r--r--lib/csv.rb2881
-rw-r--r--lib/csv/core_ext/array.rb9
-rw-r--r--lib/csv/core_ext/string.rb9
-rw-r--r--lib/csv/csv.gemspec64
-rw-r--r--lib/csv/delete_suffix.rb18
-rw-r--r--lib/csv/fields_converter.rb89
-rw-r--r--lib/csv/input_record_separator.rb18
-rw-r--r--lib/csv/match_p.rb20
-rw-r--r--lib/csv/parser.rb1288
-rw-r--r--lib/csv/row.rb757
-rw-r--r--lib/csv/table.rb1055
-rw-r--r--lib/csv/version.rb6
-rw-r--r--lib/csv/writer.rb210
-rw-r--r--lib/delegate.gemspec29
-rw-r--r--lib/delegate.rb71
-rw-r--r--lib/delegate/delegate.gemspec29
-rw-r--r--lib/did_you_mean.rb28
-rw-r--r--lib/did_you_mean/did_you_mean.gemspec2
-rw-r--r--lib/did_you_mean/jaro_winkler.rb7
-rw-r--r--lib/did_you_mean/spell_checkers/key_error_checker.rb10
-rw-r--r--lib/did_you_mean/spell_checkers/pattern_key_name_checker.rb10
-rw-r--r--lib/did_you_mean/version.rb2
-rw-r--r--lib/drb.rb3
-rw-r--r--lib/drb/acl.rb239
-rw-r--r--lib/drb/drb.gemspec43
-rw-r--r--lib/drb/drb.rb1942
-rw-r--r--lib/drb/eq.rb15
-rw-r--r--lib/drb/extserv.rb44
-rw-r--r--lib/drb/extservm.rb94
-rw-r--r--lib/drb/gw.rb161
-rw-r--r--lib/drb/invokemethod.rb35
-rw-r--r--lib/drb/observer.rb26
-rw-r--r--lib/drb/ssl.rb344
-rw-r--r--lib/drb/timeridconv.rb97
-rw-r--r--lib/drb/unix.rb118
-rw-r--r--lib/drb/version.rb3
-rw-r--r--lib/drb/weakidconv.rb59
-rw-r--r--lib/erb.gemspec38
-rw-r--r--lib/erb.rb1275
-rw-r--r--lib/erb/compiler.rb26
-rw-r--r--lib/erb/def_method.rb3
-rw-r--r--lib/erb/erb.gemspec37
-rw-r--r--lib/erb/util.rb69
-rw-r--r--lib/erb/version.rb4
-rw-r--r--lib/error_highlight/base.rb437
-rw-r--r--lib/error_highlight/core_ext.rb35
-rw-r--r--lib/error_highlight/error_highlight.gemspec2
-rw-r--r--lib/error_highlight/formatter.rb63
-rw-r--r--lib/error_highlight/version.rb2
-rw-r--r--lib/fileutils.gemspec2
-rw-r--r--lib/fileutils.rb135
-rw-r--r--lib/find.gemspec13
-rw-r--r--lib/find.rb85
-rw-r--r--lib/forwardable.rb51
-rw-r--r--lib/forwardable/forwardable.gemspec2
-rw-r--r--lib/forwardable/impl.rb17
-rw-r--r--lib/getoptlong.rb867
-rw-r--r--lib/getoptlong/getoptlong.gemspec30
-rw-r--r--lib/ipaddr.gemspec4
-rw-r--r--lib/ipaddr.rb168
-rw-r--r--lib/irb.rb997
-rw-r--r--lib/irb/.document1
-rw-r--r--lib/irb/cmd/backtrace.rb21
-rw-r--r--lib/irb/cmd/break.rb21
-rw-r--r--lib/irb/cmd/catch.rb21
-rw-r--r--lib/irb/cmd/chws.rb36
-rw-r--r--lib/irb/cmd/continue.rb17
-rw-r--r--lib/irb/cmd/debug.rb136
-rw-r--r--lib/irb/cmd/delete.rb17
-rw-r--r--lib/irb/cmd/edit.rb61
-rw-r--r--lib/irb/cmd/finish.rb17
-rw-r--r--lib/irb/cmd/fork.rb34
-rw-r--r--lib/irb/cmd/help.rb57
-rw-r--r--lib/irb/cmd/info.rb21
-rw-r--r--lib/irb/cmd/irb_info.rb37
-rw-r--r--lib/irb/cmd/load.rb76
-rw-r--r--lib/irb/cmd/ls.rb129
-rw-r--r--lib/irb/cmd/measure.rb48
-rw-r--r--lib/irb/cmd/next.rb17
-rw-r--r--lib/irb/cmd/nop.rb66
-rw-r--r--lib/irb/cmd/pushws.rb45
-rw-r--r--lib/irb/cmd/show_cmds.rb39
-rw-r--r--lib/irb/cmd/show_source.rb112
-rw-r--r--lib/irb/cmd/step.rb17
-rw-r--r--lib/irb/cmd/subirb.rb66
-rw-r--r--lib/irb/cmd/whereami.rb25
-rw-r--r--lib/irb/color.rb266
-rw-r--r--lib/irb/color_printer.rb55
-rw-r--r--lib/irb/completion.rb479
-rw-r--r--lib/irb/context.rb555
-rw-r--r--lib/irb/easter-egg.rb138
-rw-r--r--lib/irb/ext/change-ws.rb39
-rw-r--r--lib/irb/ext/history.rb149
-rw-r--r--lib/irb/ext/loader.rb148
-rw-r--r--lib/irb/ext/multi-irb.rb258
-rw-r--r--lib/irb/ext/save-history.rb125
-rw-r--r--lib/irb/ext/tracer.rb79
-rw-r--r--lib/irb/ext/use-loader.rb69
-rw-r--r--lib/irb/ext/workspaces.rb60
-rw-r--r--lib/irb/extend-command.rb428
-rw-r--r--lib/irb/frame.rb80
-rw-r--r--lib/irb/help.rb30
-rw-r--r--lib/irb/init.rb442
-rw-r--r--lib/irb/input-method.rb478
-rw-r--r--lib/irb/inspector.rb131
-rw-r--r--lib/irb/irb.gemspec45
-rw-r--r--lib/irb/lc/error.rb62
-rw-r--r--lib/irb/lc/help-message51
-rw-r--r--lib/irb/lc/ja/encoding_aliases.rb13
-rw-r--r--lib/irb/lc/ja/error.rb63
-rw-r--r--lib/irb/lc/ja/help-message45
-rw-r--r--lib/irb/locale.rb186
-rw-r--r--lib/irb/magic-file.rb38
-rw-r--r--lib/irb/notifier.rb230
-rw-r--r--lib/irb/output-method.rb86
-rw-r--r--lib/irb/ruby-lex.rb851
-rw-r--r--lib/irb/ruby_logo.aa37
-rw-r--r--lib/irb/src_encoding.rb7
-rw-r--r--lib/irb/version.rb11
-rw-r--r--lib/irb/workspace.rb169
-rw-r--r--lib/irb/ws-for-case-2.rb9
-rw-r--r--lib/irb/xmp.rb164
-rw-r--r--lib/logger.rb748
-rw-r--r--lib/logger/errors.rb9
-rw-r--r--lib/logger/formatter.rb36
-rw-r--r--lib/logger/log_device.rb207
-rw-r--r--lib/logger/logger.gemspec26
-rw-r--r--lib/logger/period.rb47
-rw-r--r--lib/logger/severity.rb38
-rw-r--r--lib/logger/version.rb5
-rw-r--r--lib/mkmf.rb338
-rw-r--r--lib/monitor.rb216
-rw-r--r--lib/mutex_m.gemspec28
-rw-r--r--lib/mutex_m.rb116
-rw-r--r--lib/net/http.rb289
-rw-r--r--lib/net/http/backward.rb40
-rw-r--r--lib/net/http/exceptions.rb5
-rw-r--r--lib/net/http/generic_request.rb55
-rw-r--r--lib/net/http/header.rb36
-rw-r--r--lib/net/http/net-http.gemspec10
-rw-r--r--lib/net/http/proxy_delta.rb2
-rw-r--r--lib/net/http/request.rb2
-rw-r--r--lib/net/http/requests.rb71
-rw-r--r--lib/net/http/response.rb12
-rw-r--r--lib/net/http/responses.rb72
-rw-r--r--lib/net/https.rb2
-rw-r--r--lib/net/net-protocol.gemspec6
-rw-r--r--lib/net/protocol.rb17
-rw-r--r--lib/observer.rb229
-rw-r--r--lib/observer/observer.gemspec32
-rw-r--r--lib/open-uri.gemspec11
-rw-r--r--lib/open-uri.rb94
-rw-r--r--lib/open3.rb1268
-rw-r--r--lib/open3/open3.gemspec2
-rw-r--r--lib/open3/version.rb3
-rw-r--r--lib/optparse.rb364
-rw-r--r--lib/optparse/ac.rb16
-rw-r--r--lib/optparse/kwargs.rb11
-rw-r--r--lib/optparse/optparse.gemspec12
-rw-r--r--lib/optparse/version.rb9
-rw-r--r--lib/ostruct.rb477
-rw-r--r--lib/ostruct/ostruct.gemspec27
-rw-r--r--lib/pathname.rb97
-rw-r--r--lib/pp.gemspec14
-rw-r--r--lib/pp.rb171
-rw-r--r--lib/prettyprint.gemspec11
-rw-r--r--lib/prettyprint.rb25
-rw-r--r--lib/prism.rb145
-rw-r--r--lib/prism/desugar_compiler.rb463
-rw-r--r--lib/prism/ffi.rb611
-rw-r--r--lib/prism/lex_compat.rb906
-rw-r--r--lib/prism/node_ext.rb388
-rw-r--r--lib/prism/node_find.rb185
-rw-r--r--lib/prism/parse_result.rb1211
-rw-r--r--lib/prism/parse_result/comments.rb219
-rw-r--r--lib/prism/parse_result/errors.rb72
-rw-r--r--lib/prism/parse_result/newlines.rb204
-rw-r--r--lib/prism/pattern.rb314
-rw-r--r--lib/prism/polyfill/append_as_bytes.rb15
-rw-r--r--lib/prism/polyfill/byteindex.rb13
-rw-r--r--lib/prism/polyfill/scan_byte.rb14
-rw-r--r--lib/prism/polyfill/unpack1.rb14
-rw-r--r--lib/prism/polyfill/warn.rb36
-rw-r--r--lib/prism/prism.gemspec232
-rw-r--r--lib/prism/relocation.rb665
-rw-r--r--lib/prism/string_query.rb46
-rw-r--r--lib/prism/translation.rb20
-rw-r--r--lib/prism/translation/parser.rb376
-rw-r--r--lib/prism/translation/parser/builder.rb70
-rw-r--r--lib/prism/translation/parser/compiler.rb2219
-rw-r--r--lib/prism/translation/parser/lexer.rb819
-rw-r--r--lib/prism/translation/parser_current.rb26
-rw-r--r--lib/prism/translation/parser_versions.rb36
-rw-r--r--lib/prism/translation/ripper.rb4266
-rw-r--r--lib/prism/translation/ripper/filter.rb53
-rw-r--r--lib/prism/translation/ripper/lexer.rb133
-rw-r--r--lib/prism/translation/ripper/sexp.rb118
-rw-r--r--lib/prism/translation/ripper/shim.rb7
-rw-r--r--lib/prism/translation/ruby_parser.rb1676
-rw-r--r--lib/pstore.rb731
-rw-r--r--lib/pstore/pstore.gemspec32
-rw-r--r--lib/racc.rb6
-rw-r--r--lib/racc/compat.rb33
-rw-r--r--lib/racc/debugflags.rb60
-rw-r--r--lib/racc/exception.rb16
-rw-r--r--lib/racc/grammar.rb1118
-rw-r--r--lib/racc/grammarfileparser.rb561
-rw-r--r--lib/racc/info.rb17
-rw-r--r--lib/racc/iset.rb92
-rw-r--r--lib/racc/logfilegenerator.rb212
-rw-r--r--lib/racc/parser-text.rb637
-rw-r--r--lib/racc/parser.rb632
-rw-r--r--lib/racc/parserfilegenerator.rb470
-rw-r--r--lib/racc/racc.gemspec58
-rw-r--r--lib/racc/sourcetext.rb35
-rw-r--r--lib/racc/state.rb972
-rw-r--r--lib/racc/statetransitiontable.rb311
-rw-r--r--lib/racc/static.rb5
-rw-r--r--lib/random/formatter.rb145
-rw-r--r--lib/rdoc.rb201
-rw-r--r--lib/rdoc/.document2
-rw-r--r--lib/rdoc/alias.rb112
-rw-r--r--lib/rdoc/anon_class.rb11
-rw-r--r--lib/rdoc/any_method.rb364
-rw-r--r--lib/rdoc/attr.rb176
-rw-r--r--lib/rdoc/class_module.rb802
-rw-r--r--lib/rdoc/code_object.rb421
-rw-r--r--lib/rdoc/code_objects.rb5
-rw-r--r--lib/rdoc/comment.rb250
-rw-r--r--lib/rdoc/constant.rb187
-rw-r--r--lib/rdoc/context.rb1264
-rw-r--r--lib/rdoc/context/section.rb234
-rw-r--r--lib/rdoc/cross_reference.rb226
-rw-r--r--lib/rdoc/encoding.rb136
-rw-r--r--lib/rdoc/erb_partial.rb19
-rw-r--r--lib/rdoc/erbio.rb42
-rw-r--r--lib/rdoc/extend.rb10
-rw-r--r--lib/rdoc/generator.rb51
-rw-r--r--lib/rdoc/generator/darkfish.rb790
-rw-r--r--lib/rdoc/generator/json_index.rb300
-rw-r--r--lib/rdoc/generator/markup.rb160
-rw-r--r--lib/rdoc/generator/pot.rb98
-rw-r--r--lib/rdoc/generator/pot/message_extractor.rb68
-rw-r--r--lib/rdoc/generator/pot/po.rb84
-rw-r--r--lib/rdoc/generator/pot/po_entry.rb141
-rw-r--r--lib/rdoc/generator/ri.rb31
-rw-r--r--lib/rdoc/generator/template/darkfish/_footer.rhtml5
-rw-r--r--lib/rdoc/generator/template/darkfish/_head.rhtml20
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml19
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml33
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml15
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml9
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml15
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml15
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml12
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml11
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml32
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml11
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml14
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml11
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml39
-rw-r--r--lib/rdoc/generator/template/darkfish/class.rhtml174
-rw-r--r--lib/rdoc/generator/template/darkfish/css/fonts.css167
-rw-r--r--lib/rdoc/generator/template/darkfish/css/rdoc.css662
-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttfbin94668 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttfbin94196 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttfbin96184 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttfbin95316 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttfbin138268 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttfbin138680 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/add.pngbin733 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/arrow_up.pngbin372 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/brick.pngbin452 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/brick_link.pngbin764 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/bug.pngbin774 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/bullet_black.pngbin211 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.pngbin207 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.pngbin209 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/date.pngbin626 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/delete.pngbin715 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/find.pngbin659 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/loadingAnimation.gifbin5886 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/macFFBgHack.pngbin207 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/package.pngbin853 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/page_green.pngbin621 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/page_white_text.pngbin342 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/page_white_width.pngbin309 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/plugin.pngbin591 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/ruby.pngbin592 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/tag_blue.pngbin1880 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/tag_green.pngbin613 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/transparent.pngbin97 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/wrench.pngbin610 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/wrench_orange.pngbin584 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/images/zoom.pngbin692 -> 0 bytes-rw-r--r--lib/rdoc/generator/template/darkfish/index.rhtml22
-rw-r--r--lib/rdoc/generator/template/darkfish/js/darkfish.js84
-rw-r--r--lib/rdoc/generator/template/darkfish/js/search.js110
-rw-r--r--lib/rdoc/generator/template/darkfish/page.rhtml18
-rw-r--r--lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml18
-rw-r--r--lib/rdoc/generator/template/darkfish/servlet_root.rhtml62
-rw-r--r--lib/rdoc/generator/template/darkfish/table_of_contents.rhtml58
-rw-r--r--lib/rdoc/generator/template/json_index/.document1
-rw-r--r--lib/rdoc/generator/template/json_index/js/navigation.js105
-rw-r--r--lib/rdoc/generator/template/json_index/js/searcher.js229
-rw-r--r--lib/rdoc/ghost_method.rb7
-rw-r--r--lib/rdoc/i18n.rb10
-rw-r--r--lib/rdoc/i18n/locale.rb102
-rw-r--r--lib/rdoc/i18n/text.rb126
-rw-r--r--lib/rdoc/include.rb10
-rw-r--r--lib/rdoc/known_classes.rb74
-rw-r--r--lib/rdoc/markdown.rb16783
-rw-r--r--lib/rdoc/markdown/entities.rb2132
-rw-r--r--lib/rdoc/markdown/literals.rb455
-rw-r--r--lib/rdoc/markup.rb235
-rw-r--r--lib/rdoc/markup/attr_changer.rb23
-rw-r--r--lib/rdoc/markup/attr_span.rb36
-rw-r--r--lib/rdoc/markup/attribute_manager.rb403
-rw-r--r--lib/rdoc/markup/attributes.rb71
-rw-r--r--lib/rdoc/markup/blank_line.rb28
-rw-r--r--lib/rdoc/markup/block_quote.rb15
-rw-r--r--lib/rdoc/markup/document.rb165
-rw-r--r--lib/rdoc/markup/formatter.rb266
-rw-r--r--lib/rdoc/markup/hard_break.rb32
-rw-r--r--lib/rdoc/markup/heading.rb79
-rw-r--r--lib/rdoc/markup/include.rb43
-rw-r--r--lib/rdoc/markup/indented_paragraph.rb48
-rw-r--r--lib/rdoc/markup/list.rb102
-rw-r--r--lib/rdoc/markup/list_item.rb100
-rw-r--r--lib/rdoc/markup/paragraph.rb29
-rw-r--r--lib/rdoc/markup/parser.rb581
-rw-r--r--lib/rdoc/markup/pre_process.rb298
-rw-r--r--lib/rdoc/markup/raw.rb70
-rw-r--r--lib/rdoc/markup/regexp_handling.rb41
-rw-r--r--lib/rdoc/markup/rule.rb21
-rw-r--r--lib/rdoc/markup/table.rb47
-rw-r--r--lib/rdoc/markup/to_ansi.rb94
-rw-r--r--lib/rdoc/markup/to_bs.rb77
-rw-r--r--lib/rdoc/markup/to_html.rb448
-rw-r--r--lib/rdoc/markup/to_html_crossref.rb176
-rw-r--r--lib/rdoc/markup/to_html_snippet.rb285
-rw-r--r--lib/rdoc/markup/to_joined_paragraph.rb47
-rw-r--r--lib/rdoc/markup/to_label.rb75
-rw-r--r--lib/rdoc/markup/to_markdown.rb192
-rw-r--r--lib/rdoc/markup/to_rdoc.rb345
-rw-r--r--lib/rdoc/markup/to_table_of_contents.rb89
-rw-r--r--lib/rdoc/markup/to_test.rb70
-rw-r--r--lib/rdoc/markup/to_tt_only.rb121
-rw-r--r--lib/rdoc/markup/verbatim.rb84
-rw-r--r--lib/rdoc/meta_method.rb7
-rw-r--r--lib/rdoc/method_attr.rb419
-rw-r--r--lib/rdoc/mixin.rb121
-rw-r--r--lib/rdoc/normal_class.rb93
-rw-r--r--lib/rdoc/normal_module.rb74
-rw-r--r--lib/rdoc/options.rb1329
-rw-r--r--lib/rdoc/parser.rb294
-rw-r--r--lib/rdoc/parser/c.rb1225
-rw-r--r--lib/rdoc/parser/changelog.rb335
-rw-r--r--lib/rdoc/parser/markdown.rb24
-rw-r--r--lib/rdoc/parser/rd.rb23
-rw-r--r--lib/rdoc/parser/ripper_state_lex.rb590
-rw-r--r--lib/rdoc/parser/ruby.rb2360
-rw-r--r--lib/rdoc/parser/ruby_tools.rb167
-rw-r--r--lib/rdoc/parser/simple.rb61
-rw-r--r--lib/rdoc/parser/text.rb12
-rw-r--r--lib/rdoc/rd.rb99
-rw-r--r--lib/rdoc/rd/block_parser.rb1062
-rw-r--r--lib/rdoc/rd/inline.rb72
-rw-r--r--lib/rdoc/rd/inline_parser.rb1210
-rw-r--r--lib/rdoc/rdoc.gemspec233
-rw-r--r--lib/rdoc/rdoc.rb565
-rw-r--r--lib/rdoc/require.rb52
-rw-r--r--lib/rdoc/ri.rb20
-rw-r--r--lib/rdoc/ri/driver.rb1512
-rw-r--r--lib/rdoc/ri/formatter.rb6
-rw-r--r--lib/rdoc/ri/paths.rb171
-rw-r--r--lib/rdoc/ri/store.rb7
-rw-r--r--lib/rdoc/ri/task.rb71
-rw-r--r--lib/rdoc/rubygems_hook.rb248
-rw-r--r--lib/rdoc/servlet.rb451
-rw-r--r--lib/rdoc/single_class.rb31
-rw-r--r--lib/rdoc/stats.rb461
-rw-r--r--lib/rdoc/stats/normal.rb58
-rw-r--r--lib/rdoc/stats/quiet.rb60
-rw-r--r--lib/rdoc/stats/verbose.rb46
-rw-r--r--lib/rdoc/store.rb979
-rw-r--r--lib/rdoc/task.rb355
-rw-r--r--lib/rdoc/text.rb312
-rw-r--r--lib/rdoc/token_stream.rb119
-rw-r--r--lib/rdoc/tom_doc.rb263
-rw-r--r--lib/rdoc/top_level.rb289
-rw-r--r--lib/rdoc/version.rb10
-rw-r--r--lib/readline.gemspec33
-rw-r--r--lib/readline.rb7
-rw-r--r--lib/reline.rb603
-rw-r--r--lib/reline/ansi.rb355
-rw-r--r--lib/reline/config.rb401
-rw-r--r--lib/reline/general_io.rb113
-rw-r--r--lib/reline/history.rb76
-rw-r--r--lib/reline/key_actor.rb7
-rw-r--r--lib/reline/key_actor/base.rb19
-rw-r--r--lib/reline/key_actor/emacs.rb517
-rw-r--r--lib/reline/key_actor/vi_command.rb518
-rw-r--r--lib/reline/key_actor/vi_insert.rb517
-rw-r--r--lib/reline/key_stroke.rb105
-rw-r--r--lib/reline/kill_ring.rb125
-rw-r--r--lib/reline/line_editor.rb3347
-rw-r--r--lib/reline/reline.gemspec25
-rw-r--r--lib/reline/terminfo.rb174
-rw-r--r--lib/reline/unicode.rb665
-rw-r--r--lib/reline/unicode/east_asian_width.rb1196
-rw-r--r--lib/reline/version.rb3
-rw-r--r--lib/reline/windows.rb501
-rw-r--r--lib/resolv-replace.gemspec22
-rw-r--r--lib/resolv-replace.rb76
-rw-r--r--lib/resolv.gemspec17
-rw-r--r--lib/resolv.rb863
-rw-r--r--lib/rinda/rinda.gemspec28
-rw-r--r--lib/rinda/rinda.rb327
-rw-r--r--lib/rinda/ring.rb484
-rw-r--r--lib/rinda/tuplespace.rb641
-rw-r--r--lib/ruby_vm/rjit/assembler.rb1097
-rw-r--r--lib/ruby_vm/rjit/block.rb11
-rw-r--r--lib/ruby_vm/rjit/branch_stub.rb24
-rw-r--r--lib/ruby_vm/rjit/c_pointer.rb360
-rw-r--r--lib/ruby_vm/rjit/c_type.rb91
-rw-r--r--lib/ruby_vm/rjit/code_block.rb87
-rw-r--r--lib/ruby_vm/rjit/compiler.rb330
-rw-r--r--lib/ruby_vm/rjit/context.rb30
-rw-r--r--lib/ruby_vm/rjit/exit_compiler.rb152
-rw-r--r--lib/ruby_vm/rjit/hooks.rb36
-rw-r--r--lib/ruby_vm/rjit/insn_compiler.rb4051
-rw-r--r--lib/ruby_vm/rjit/invariants.rb144
-rw-r--r--lib/ruby_vm/rjit/jit_state.rb57
-rw-r--r--lib/ruby_vm/rjit/stats.rb186
-rw-r--r--lib/rubygems.rb358
-rw-r--r--lib/rubygems/available_set.rb7
-rw-r--r--lib/rubygems/basic_specification.rb133
-rw-r--r--lib/rubygems/bundler_version_finder.rb84
-rw-r--r--lib/rubygems/ci_detector.rb75
-rw-r--r--lib/rubygems/command.rb61
-rw-r--r--lib/rubygems/command_manager.rb30
-rw-r--r--lib/rubygems/commands/build_command.rb21
-rw-r--r--lib/rubygems/commands/cert_command.rb11
-rw-r--r--lib/rubygems/commands/check_command.rb15
-rw-r--r--lib/rubygems/commands/cleanup_command.rb39
-rw-r--r--lib/rubygems/commands/contents_command.rb36
-rw-r--r--lib/rubygems/commands/dependency_command.rb12
-rw-r--r--lib/rubygems/commands/environment_command.rb11
-rw-r--r--lib/rubygems/commands/exec_command.rb33
-rw-r--r--lib/rubygems/commands/fetch_command.rb21
-rw-r--r--lib/rubygems/commands/generate_index_command.rb114
-rw-r--r--lib/rubygems/commands/help_command.rb17
-rw-r--r--lib/rubygems/commands/info_command.rb4
-rw-r--r--lib/rubygems/commands/install_command.rb38
-rw-r--r--lib/rubygems/commands/list_command.rb5
-rw-r--r--lib/rubygems/commands/lock_command.rb3
-rw-r--r--lib/rubygems/commands/mirror_command.rb1
-rw-r--r--lib/rubygems/commands/open_command.rb5
-rw-r--r--lib/rubygems/commands/outdated_command.rb1
-rw-r--r--lib/rubygems/commands/owner_command.rb24
-rw-r--r--lib/rubygems/commands/pristine_command.rb84
-rw-r--r--lib/rubygems/commands/push_command.rb88
-rw-r--r--lib/rubygems/commands/query_command.rb43
-rw-r--r--lib/rubygems/commands/rdoc_command.rb18
-rw-r--r--lib/rubygems/commands/rebuild_command.rb261
-rw-r--r--lib/rubygems/commands/search_command.rb5
-rw-r--r--lib/rubygems/commands/server_command.rb1
-rw-r--r--lib/rubygems/commands/setup_command.rb105
-rw-r--r--lib/rubygems/commands/signin_command.rb1
-rw-r--r--lib/rubygems/commands/signout_command.rb1
-rw-r--r--lib/rubygems/commands/sources_command.rb190
-rw-r--r--lib/rubygems/commands/specification_command.rb21
-rw-r--r--lib/rubygems/commands/stale_command.rb1
-rw-r--r--lib/rubygems/commands/uninstall_command.rb43
-rw-r--r--lib/rubygems/commands/unpack_command.rb29
-rw-r--r--lib/rubygems/commands/update_command.rb56
-rw-r--r--lib/rubygems/commands/which_command.rb3
-rw-r--r--lib/rubygems/commands/yank_command.rb5
-rw-r--r--lib/rubygems/compatibility.rb41
-rw-r--r--lib/rubygems/config_file.rb173
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb78
-rw-r--r--lib/rubygems/core_ext/kernel_warn.rb17
-rw-r--r--lib/rubygems/core_ext/tcpsocket_init.rb4
-rw-r--r--lib/rubygems/defaults.rb50
-rw-r--r--lib/rubygems/dependency.rb55
-rw-r--r--lib/rubygems/dependency_installer.rb150
-rw-r--r--lib/rubygems/dependency_list.rb8
-rw-r--r--lib/rubygems/deprecate.rb292
-rw-r--r--lib/rubygems/doctor.rb13
-rw-r--r--lib/rubygems/errors.rb12
-rw-r--r--lib/rubygems/exceptions.rb93
-rw-r--r--lib/rubygems/ext.rb1
-rw-r--r--lib/rubygems/ext/build_error.rb1
-rw-r--r--lib/rubygems/ext/builder.rb98
-rw-r--r--lib/rubygems/ext/cargo_builder.rb57
-rw-r--r--lib/rubygems/ext/cmake_builder.rb106
-rw-r--r--lib/rubygems/ext/configure_builder.rb10
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb24
-rw-r--r--lib/rubygems/ext/rake_builder.rb15
-rw-r--r--lib/rubygems/gem_runner.rb17
-rw-r--r--lib/rubygems/gemcutter_utilities.rb160
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_listener.rb112
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb163
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_poller.rb80
-rw-r--r--lib/rubygems/gemspec_helpers.rb19
-rw-r--r--lib/rubygems/indexer.rb427
-rw-r--r--lib/rubygems/install_default_message.rb12
-rw-r--r--lib/rubygems/install_message.rb1
-rw-r--r--lib/rubygems/install_update_options.rb38
-rw-r--r--lib/rubygems/installer.rb409
-rw-r--r--lib/rubygems/local_remote_options.rb21
-rw-r--r--lib/rubygems/mock_gem_ui.rb85
-rw-r--r--lib/rubygems/name_tuple.rb21
-rw-r--r--lib/rubygems/optparse.rb3
-rw-r--r--lib/rubygems/optparse/lib/optparse.rb2308
-rw-r--r--lib/rubygems/optparse/lib/optparse/ac.rb54
-rw-r--r--lib/rubygems/optparse/lib/optparse/kwargs.rb22
-rw-r--r--lib/rubygems/optparse/lib/optparse/uri.rb7
-rw-r--r--lib/rubygems/optparse/lib/optparse/version.rb71
-rw-r--r--lib/rubygems/package.rb174
-rw-r--r--lib/rubygems/package/digest_io.rb3
-rw-r--r--lib/rubygems/package/file_source.rb1
-rw-r--r--lib/rubygems/package/io_source.rb1
-rw-r--r--lib/rubygems/package/old.rb5
-rw-r--r--lib/rubygems/package/source.rb1
-rw-r--r--lib/rubygems/package/tar_header.rb126
-rw-r--r--lib/rubygems/package/tar_reader.rb25
-rw-r--r--lib/rubygems/package/tar_reader/entry.rb52
-rw-r--r--lib/rubygems/package/tar_writer.rb48
-rw-r--r--lib/rubygems/package_task.rb5
-rw-r--r--lib/rubygems/path_support.rb22
-rw-r--r--lib/rubygems/platform.rb273
-rw-r--r--lib/rubygems/psych_tree.rb7
-rw-r--r--lib/rubygems/query_utils.rb10
-rw-r--r--lib/rubygems/rdoc.rb20
-rw-r--r--lib/rubygems/remote_fetcher.rb83
-rw-r--r--lib/rubygems/request.rb45
-rw-r--r--lib/rubygems/request/connection_pools.rb13
-rw-r--r--lib/rubygems/request/http_pool.rb16
-rw-r--r--lib/rubygems/request/https_pool.rb1
-rw-r--r--lib/rubygems/request_set.rb95
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb237
-rw-r--r--lib/rubygems/request_set/lockfile.rb22
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb343
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb112
-rw-r--r--lib/rubygems/requirement.rb35
-rw-r--r--lib/rubygems/resolver.rb542
-rw-r--r--lib/rubygems/resolver/activation_request.rb13
-rw-r--r--lib/rubygems/resolver/api_set.rb32
-rw-r--r--lib/rubygems/resolver/api_set/gem_parser.rb9
-rw-r--r--lib/rubygems/resolver/api_specification.rb7
-rw-r--r--lib/rubygems/resolver/best_set.rb31
-rw-r--r--lib/rubygems/resolver/composed_set.rb7
-rw-r--r--lib/rubygems/resolver/conflict.rb153
-rw-r--r--lib/rubygems/resolver/current_set.rb1
-rw-r--r--lib/rubygems/resolver/dependency_request.rb1
-rw-r--r--lib/rubygems/resolver/git_set.rb2
-rw-r--r--lib/rubygems/resolver/git_specification.rb1
-rw-r--r--lib/rubygems/resolver/incompatibility.rb10
-rw-r--r--lib/rubygems/resolver/index_set.rb14
-rw-r--r--lib/rubygems/resolver/index_specification.rb5
-rw-r--r--lib/rubygems/resolver/installed_specification.rb1
-rw-r--r--lib/rubygems/resolver/installer_set.rb15
-rw-r--r--lib/rubygems/resolver/local_specification.rb1
-rw-r--r--lib/rubygems/resolver/lock_set.rb3
-rw-r--r--lib/rubygems/resolver/lock_specification.rb1
-rw-r--r--lib/rubygems/resolver/molinillo.rb2
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo.rb11
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb57
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb88
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb255
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb36
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb66
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb62
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb63
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb61
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb126
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb46
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb36
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb164
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb149
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb6
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb112
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb67
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb839
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb46
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/state.rb58
-rw-r--r--lib/rubygems/resolver/requirement_list.rb1
-rw-r--r--lib/rubygems/resolver/set.rb1
-rw-r--r--lib/rubygems/resolver/source_set.rb4
-rw-r--r--lib/rubygems/resolver/spec_specification.rb8
-rw-r--r--lib/rubygems/resolver/specification.rb1
-rw-r--r--lib/rubygems/resolver/stats.rb45
-rw-r--r--lib/rubygems/resolver/strategy.rb44
-rw-r--r--lib/rubygems/resolver/vendor_set.rb1
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb1
-rw-r--r--lib/rubygems/s3_uri_signer.rb87
-rw-r--r--lib/rubygems/safe_marshal.rb75
-rw-r--r--lib/rubygems/safe_marshal/elements.rb146
-rw-r--r--lib/rubygems/safe_marshal/reader.rb325
-rw-r--r--lib/rubygems/safe_marshal/visitors/stream_printer.rb31
-rw-r--r--lib/rubygems/safe_marshal/visitors/to_ruby.rb428
-rw-r--r--lib/rubygems/safe_marshal/visitors/visitor.rb74
-rw-r--r--lib/rubygems/safe_yaml.rb27
-rw-r--r--lib/rubygems/security.rb19
-rw-r--r--lib/rubygems/security/policies.rb73
-rw-r--r--lib/rubygems/security/policy.rb17
-rw-r--r--lib/rubygems/security/signer.rb17
-rw-r--r--lib/rubygems/security/trust_dir.rb21
-rw-r--r--lib/rubygems/security_option.rb1
-rw-r--r--lib/rubygems/source.rb100
-rw-r--r--lib/rubygems/source/git.rb43
-rw-r--r--lib/rubygems/source/installed.rb7
-rw-r--r--lib/rubygems/source/local.rb98
-rw-r--r--lib/rubygems/source/lock.rb5
-rw-r--r--lib/rubygems/source/specific_file.rb10
-rw-r--r--lib/rubygems/source/vendor.rb3
-rw-r--r--lib/rubygems/source_list.rb40
-rw-r--r--lib/rubygems/spec_fetcher.rb147
-rw-r--r--lib/rubygems/specification.rb736
-rw-r--r--lib/rubygems/specification_policy.rb220
-rw-r--r--lib/rubygems/specification_record.rb225
-rw-r--r--lib/rubygems/ssl_certs/rubygems.org/GlobalSign.pem (renamed from lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem)0
-rw-r--r--lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem21
-rw-r--r--lib/rubygems/stub_specification.rb71
-rw-r--r--lib/rubygems/target_rbconfig.rb50
-rw-r--r--lib/rubygems/text.rb4
-rw-r--r--lib/rubygems/tsort.rb3
-rw-r--r--lib/rubygems/tsort/.document1
-rw-r--r--lib/rubygems/tsort/lib/tsort.rb452
-rw-r--r--lib/rubygems/uninstaller.rb102
-rw-r--r--lib/rubygems/update_suggestion.rb25
-rw-r--r--lib/rubygems/uri.rb12
-rw-r--r--lib/rubygems/uri_formatter.rb5
-rw-r--r--lib/rubygems/user_interaction.rb34
-rw-r--r--lib/rubygems/util.rb31
-rw-r--r--lib/rubygems/util/atomic_file_writer.rb76
-rw-r--r--lib/rubygems/util/licenses.rb368
-rw-r--r--lib/rubygems/util/list.rb39
-rw-r--r--lib/rubygems/validator.rb21
-rw-r--r--lib/rubygems/vendor/.document (renamed from lib/rubygems/optparse/.document)0
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http.rb2608
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb35
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb429
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/header.rb985
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb17
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/request.rb88
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/requests.rb444
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/response.rb739
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/responses.rb1242
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/status.rb84
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/https.rb23
-rw-r--r--lib/rubygems/vendor/net-protocol/lib/net/protocol.rb544
-rw-r--r--lib/rubygems/vendor/optparse/lib/optionparser.rb (renamed from lib/rubygems/optparse/lib/optionparser.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse.rb2467
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/ac.rb70
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/date.rb (renamed from lib/rubygems/optparse/lib/optparse/date.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb27
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/shellwords.rb (renamed from lib/rubygems/optparse/lib/optparse/shellwords.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/time.rb (renamed from lib/rubygems/optparse/lib/optparse/time.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/uri.rb7
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/version.rb80
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub.rb53
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/assignment.rb20
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/basic_package_source.rb169
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/failure_writer.rb182
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/incompatibility.rb150
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/package.rb43
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/partial_solution.rb121
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/rubygems.rb45
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/solve_failure.rb19
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/static_package_source.rb61
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/strategy.rb42
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb105
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/version.rb3
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/version_constraint.rb129
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/version_range.rb423
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/version_solver.rb236
-rw-r--r--lib/rubygems/vendor/pub_grub/lib/pub_grub/version_union.rb178
-rw-r--r--lib/rubygems/vendor/resolv/lib/resolv.rb3499
-rw-r--r--lib/rubygems/vendor/securerandom/lib/securerandom.rb102
-rw-r--r--lib/rubygems/vendor/timeout/lib/timeout.rb201
-rw-r--r--lib/rubygems/vendor/tsort/lib/tsort.rb455
-rw-r--r--lib/rubygems/vendor/uri/lib/uri.rb104
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/common.rb922
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/file.rb100
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ftp.rb267
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/generic.rb1592
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/http.rb137
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/https.rb23
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ldap.rb261
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ldaps.rb22
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/mailto.rb293
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb547
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb206
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/version.rb6
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ws.rb83
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/wss.rb23
-rw-r--r--lib/rubygems/vendored_net_http.rb5
-rw-r--r--lib/rubygems/vendored_optparse.rb3
-rw-r--r--lib/rubygems/vendored_pub_grub.rb3
-rw-r--r--lib/rubygems/vendored_securerandom.rb3
-rw-r--r--lib/rubygems/vendored_timeout.rb5
-rw-r--r--lib/rubygems/vendored_tsort.rb3
-rw-r--r--lib/rubygems/version.rb416
-rw-r--r--lib/rubygems/version_option.rb1
-rw-r--r--lib/rubygems/win_platform.rb30
-rw-r--r--lib/rubygems/yaml_serializer.rb845
-rw-r--r--lib/securerandom.gemspec23
-rw-r--r--lib/securerandom.rb31
-rw-r--r--lib/set.rb858
-rw-r--r--lib/set/set.gemspec23
-rw-r--r--lib/set/sorted_set.rb6
-rw-r--r--lib/set/subclass_compatible.rb347
-rw-r--r--lib/shellwords.gemspec19
-rw-r--r--lib/shellwords.rb32
-rw-r--r--lib/singleton.gemspec30
-rw-r--r--lib/singleton.rb115
-rw-r--r--lib/singleton/singleton.gemspec30
-rw-r--r--lib/syntax_suggest/api.rb23
-rw-r--r--lib/syntax_suggest/around_block_scan.rb290
-rw-r--r--lib/syntax_suggest/block_expand.rb113
-rw-r--r--lib/syntax_suggest/capture/before_after_keyword_ends.rb85
-rw-r--r--lib/syntax_suggest/capture/falling_indent_lines.rb71
-rw-r--r--lib/syntax_suggest/capture_code_context.rb28
-rw-r--r--lib/syntax_suggest/clean_document.rb119
-rw-r--r--lib/syntax_suggest/code_block.rb2
-rw-r--r--lib/syntax_suggest/code_frontier.rb4
-rw-r--r--lib/syntax_suggest/code_line.rb133
-rw-r--r--lib/syntax_suggest/code_search.rb4
-rw-r--r--lib/syntax_suggest/core_ext.rb143
-rw-r--r--lib/syntax_suggest/display_invalid_blocks.rb2
-rw-r--r--lib/syntax_suggest/explain_syntax.rb22
-rw-r--r--lib/syntax_suggest/left_right_lex_count.rb168
-rw-r--r--lib/syntax_suggest/left_right_token_count.rb162
-rw-r--r--lib/syntax_suggest/lex_all.rb55
-rw-r--r--lib/syntax_suggest/lex_value.rb70
-rw-r--r--lib/syntax_suggest/mini_stringio.rb30
-rw-r--r--lib/syntax_suggest/parse_blocks_from_indent_line.rb6
-rw-r--r--lib/syntax_suggest/pathname_from_message.rb2
-rw-r--r--lib/syntax_suggest/ripper_errors.rb36
-rw-r--r--lib/syntax_suggest/scan_history.rb134
-rw-r--r--lib/syntax_suggest/syntax_suggest.gemspec4
-rw-r--r--lib/syntax_suggest/token.rb49
-rw-r--r--lib/syntax_suggest/version.rb2
-rw-r--r--lib/syntax_suggest/visitor.rb80
-rw-r--r--lib/tempfile.gemspec19
-rw-r--r--lib/tempfile.rb305
-rw-r--r--lib/time.gemspec22
-rw-r--r--lib/time.rb92
-rw-r--r--lib/timeout.gemspec33
-rw-r--r--lib/timeout.rb307
-rw-r--r--lib/timeout/timeout.gemspec30
-rw-r--r--lib/tmpdir.gemspec10
-rw-r--r--lib/tmpdir.rb55
-rw-r--r--lib/tsort.gemspec22
-rw-r--r--lib/tsort.rb452
-rw-r--r--lib/un.gemspec11
-rw-r--r--lib/un.rb4
-rw-r--r--lib/unicode_normalize/normalize.rb30
-rw-r--r--lib/unicode_normalize/tables.rb186
-rw-r--r--lib/uri.rb18
-rw-r--r--lib/uri/common.rb123
-rw-r--r--lib/uri/file.rb8
-rw-r--r--lib/uri/ftp.rb2
-rw-r--r--lib/uri/generic.rb117
-rw-r--r--lib/uri/http.rb16
-rw-r--r--lib/uri/rfc2396_parser.rb46
-rw-r--r--lib/uri/rfc3986_parser.rb157
-rw-r--r--lib/uri/uri.gemspec7
-rw-r--r--lib/uri/version.rb4
-rw-r--r--lib/weakref.gemspec32
-rw-r--r--lib/weakref.rb5
-rw-r--r--lib/weakref/weakref.gemspec34
-rw-r--r--lib/yaml.rb2
-rw-r--r--lib/yaml/dbm.rb31
-rw-r--r--lib/yaml/store.rb20
-rw-r--r--lib/yaml/yaml.gemspec13
-rwxr-xr-xlibexec/bundle27
-rwxr-xr-xlibexec/erb50
-rwxr-xr-xlibexec/irb9
-rwxr-xr-xlibexec/racc320
-rwxr-xr-xlibexec/rdoc43
-rwxr-xr-xlibexec/ri12
-rwxr-xr-xlibexec/syntax_suggest2
-rw-r--r--load.c755
-rw-r--r--main.c12
-rw-r--r--man/erb.14
-rw-r--r--man/goruby.14
-rw-r--r--man/index.txt25
-rw-r--r--man/irb.1250
-rw-r--r--man/ri.1247
-rw-r--r--man/ruby.1212
-rw-r--r--marshal.c422
-rw-r--r--math.c156
-rw-r--r--memory_view.c33
-rw-r--r--method.h45
-rw-r--r--mini_builtin.c130
-rw-r--r--miniinit.c58
-rw-r--r--misc/.vscode/settings.json5
-rw-r--r--misc/call_fuzzer.rb372
-rwxr-xr-xmisc/call_fuzzer.sh13
-rwxr-xr-xmisc/expand_tabs.rb34
-rw-r--r--misc/gdb.py181
-rwxr-xr-xmisc/jit_perf.py116
-rw-r--r--[-rwxr-xr-x]misc/lldb_cruby.py87
-rw-r--r--misc/lldb_rb/commands/heap_page_command.py5
-rw-r--r--misc/lldb_rb/commands/print_flags_command.py6
-rw-r--r--misc/lldb_rb/commands/rb_id2str_command.py49
-rw-r--r--misc/lldb_rb/commands/rp_command.py15
-rw-r--r--misc/lldb_rb/constants.py2
-rw-r--r--misc/lldb_rb/lldb_interface.py18
-rw-r--r--misc/lldb_rb/rb_base_command.py19
-rw-r--r--misc/lldb_rb/rb_heap_structs.py152
-rw-r--r--misc/lldb_rb/utils.py506
-rw-r--r--misc/lldb_yjit.py47
-rw-r--r--misc/ruby-style.el15
-rw-r--r--misc/tsan_suppressions.txt109
-rw-r--r--missing/dtoa.c325
-rw-r--r--missing/explicit_bzero.c5
-rw-r--r--missing/procstat_vm.c34
-rw-r--r--missing/setproctitle.c68
-rw-r--r--nilclass.rb38
-rw-r--r--node.c1587
-rw-r--r--node.h550
-rw-r--r--node_dump.c1325
-rw-r--r--numeric.c1468
-rw-r--r--numeric.rb351
-rw-r--r--object.c1024
-rw-r--r--pack.c315
-rw-r--r--pack.rb25
-rw-r--r--parse.y12546
-rw-r--r--parser_bits.h647
-rw-r--r--parser_node.h32
-rw-r--r--parser_st.c171
-rw-r--r--parser_st.h161
-rw-r--r--parser_value.h106
-rw-r--r--pathname.c372
-rw-r--r--pathname_builtin.rb1895
-rw-r--r--prelude.rb28
-rw-r--r--prism/arena.c117
-rw-r--r--prism/arena.h37
-rw-r--r--prism/buffer.c374
-rw-r--r--prism/buffer.h52
-rw-r--r--prism/char.c274
-rw-r--r--prism/comments.h43
-rw-r--r--prism/compiler/accel.h19
-rw-r--r--prism/compiler/align.h36
-rw-r--r--prism/compiler/exported.h24
-rw-r--r--prism/compiler/fallthrough.h22
-rw-r--r--prism/compiler/filesystem.h32
-rw-r--r--prism/compiler/flex_array.h19
-rw-r--r--prism/compiler/force_inline.h21
-rw-r--r--prism/compiler/format.h25
-rw-r--r--prism/compiler/inline.h17
-rw-r--r--prism/compiler/nodiscard.h22
-rw-r--r--prism/compiler/nonnull.h18
-rw-r--r--prism/compiler/unused.h18
-rw-r--r--prism/config.yml4740
-rw-r--r--prism/constant_pool.c360
-rw-r--r--prism/constant_pool.h81
-rw-r--r--prism/diagnostic.h93
-rw-r--r--prism/encoding.c5345
-rw-r--r--prism/excludes.h29
-rw-r--r--prism/extension.c1489
-rw-r--r--prism/extension.h19
-rw-r--r--prism/integer.c681
-rw-r--r--prism/integer.h41
-rw-r--r--prism/internal/allocator.h68
-rw-r--r--prism/internal/allocator_debug.h88
-rw-r--r--prism/internal/arena.h108
-rw-r--r--prism/internal/bit.h42
-rw-r--r--prism/internal/buffer.h91
-rw-r--r--prism/internal/char.h139
-rw-r--r--prism/internal/comments.h20
-rw-r--r--prism/internal/constant_pool.h117
-rw-r--r--prism/internal/encoding.h242
-rw-r--r--prism/internal/integer.h68
-rw-r--r--prism/internal/isinf.h16
-rw-r--r--prism/internal/line_offset_list.h34
-rw-r--r--prism/internal/list.h62
-rw-r--r--prism/internal/magic_comments.h23
-rw-r--r--prism/internal/memchr.h15
-rw-r--r--prism/internal/node.h32
-rw-r--r--prism/internal/options.h212
-rw-r--r--prism/internal/parser.h958
-rw-r--r--prism/internal/regexp.h41
-rw-r--r--prism/internal/serialize.h34
-rw-r--r--prism/internal/source.h72
-rw-r--r--prism/internal/static_literals.h98
-rw-r--r--prism/internal/stringy.h30
-rw-r--r--prism/internal/strncasecmp.h18
-rw-r--r--prism/internal/strpbrk.h33
-rw-r--r--prism/internal/tokens.h11
-rw-r--r--prism/json.h32
-rw-r--r--prism/line_offset_list.c100
-rw-r--r--prism/line_offset_list.h61
-rw-r--r--prism/list.c24
-rw-r--r--prism/magic_comments.h35
-rw-r--r--prism/memchr.c37
-rw-r--r--prism/node.h94
-rw-r--r--prism/options.c420
-rw-r--r--prism/options.h319
-rw-r--r--prism/parser.c302
-rw-r--r--prism/parser.h348
-rw-r--r--prism/prettyprint.h31
-rw-r--r--prism/prism.c22943
-rw-r--r--prism/prism.h130
-rw-r--r--prism/regexp.c1717
-rw-r--r--prism/serialize.h96
-rw-r--r--prism/source.c491
-rw-r--r--prism/source.h148
-rw-r--r--prism/srcs.mk160
-rw-r--r--prism/srcs.mk.in52
-rw-r--r--prism/static_literals.c641
-rw-r--r--prism/stream.h28
-rw-r--r--prism/string_query.c166
-rw-r--r--prism/string_query.h63
-rw-r--r--prism/stringy.c91
-rw-r--r--prism/stringy.h72
-rw-r--r--prism/strncasecmp.c37
-rw-r--r--prism/strpbrk.c439
-rw-r--r--prism/templates/ext/prism/api_node.c.erb296
-rw-r--r--prism/templates/include/prism/ast.h.erb278
-rw-r--r--prism/templates/include/prism/internal/diagnostic.h.erb60
-rw-r--r--prism/templates/lib/prism/compiler.rb.erb52
-rw-r--r--prism/templates/lib/prism/dispatcher.rb.erb111
-rw-r--r--prism/templates/lib/prism/dot_visitor.rb.erb215
-rw-r--r--prism/templates/lib/prism/dsl.rb.erb172
-rw-r--r--prism/templates/lib/prism/inspect_visitor.rb.erb147
-rw-r--r--prism/templates/lib/prism/mutation_compiler.rb.erb22
-rw-r--r--prism/templates/lib/prism/node.rb.erb748
-rw-r--r--prism/templates/lib/prism/reflection.rb.erb145
-rw-r--r--prism/templates/lib/prism/serialize.rb.erb702
-rw-r--r--prism/templates/lib/prism/visitor.rb.erb73
-rw-r--r--prism/templates/src/diagnostic.c.erb554
-rw-r--r--prism/templates/src/json.c.erb130
-rw-r--r--prism/templates/src/node.c.erb166
-rw-r--r--prism/templates/src/prettyprint.c.erb177
-rw-r--r--prism/templates/src/serialize.c.erb404
-rw-r--r--prism/templates/src/tokens.c.erb367
-rwxr-xr-xprism/templates/template.rb723
-rw-r--r--prism/version.h38
-rw-r--r--prism_compile.c11720
-rw-r--r--prism_compile.h198
-rw-r--r--prism_init.c9
-rw-r--r--prism_xallocator.h6
-rw-r--r--proc.c1038
-rw-r--r--process.c3140
-rw-r--r--ractor.c2713
-rw-r--r--ractor.rb1081
-rw-r--r--ractor_core.h223
-rw-r--r--ractor_sync.c1489
-rw-r--r--random.c329
-rw-r--r--range.c976
-rw-r--r--rational.c306
-rw-r--r--re.c1249
-rw-r--r--regcomp.c2521
-rw-r--r--regenc.c105
-rw-r--r--regenc.h17
-rw-r--r--regerror.c107
-rw-r--r--regexec.c3627
-rw-r--r--regint.h96
-rw-r--r--regparse.c2933
-rw-r--r--regparse.h9
-rw-r--r--rjit.c454
-rw-r--r--rjit.h101
-rw-r--r--rjit.rb41
-rw-r--r--rjit_c.c502
-rw-r--r--rjit_c.h125
-rw-r--r--rjit_c.rb1433
-rw-r--r--ruby-runner.c25
-rw-r--r--ruby.c1840
-rw-r--r--ruby.rs4
-rw-r--r--ruby_atomic.h90
-rw-r--r--ruby_parser.c1119
-rw-r--r--rubyparser.h1376
-rw-r--r--sample/drb/README.ja.rdoc59
-rw-r--r--sample/drb/README.rdoc56
-rw-r--r--sample/drb/acl.rb15
-rw-r--r--sample/drb/darray.rb12
-rw-r--r--sample/drb/darrayc.rb47
-rw-r--r--sample/drb/dbiff.rb51
-rw-r--r--sample/drb/dcdbiff.rb43
-rw-r--r--sample/drb/dchatc.rb41
-rw-r--r--sample/drb/dchats.rb69
-rw-r--r--sample/drb/dhasen.rb41
-rw-r--r--sample/drb/dhasenc.rb14
-rw-r--r--sample/drb/dlogc.rb16
-rw-r--r--sample/drb/dlogd.rb38
-rw-r--r--sample/drb/dqin.rb13
-rw-r--r--sample/drb/dqlib.rb14
-rw-r--r--sample/drb/dqout.rb14
-rw-r--r--sample/drb/dqueue.rb11
-rw-r--r--sample/drb/drbc.rb45
-rw-r--r--sample/drb/drbch.rb48
-rw-r--r--sample/drb/drbm.rb60
-rw-r--r--sample/drb/drbmc.rb22
-rw-r--r--sample/drb/drbs-acl.rb51
-rw-r--r--sample/drb/drbs.rb64
-rw-r--r--sample/drb/drbssl_c.rb19
-rw-r--r--sample/drb/drbssl_s.rb31
-rw-r--r--sample/drb/extserv_test.rb80
-rw-r--r--sample/drb/gw_ct.rb29
-rw-r--r--sample/drb/gw_cu.rb28
-rw-r--r--sample/drb/gw_s.rb10
-rw-r--r--sample/drb/holderc.rb22
-rw-r--r--sample/drb/holders.rb63
-rw-r--r--sample/drb/http0.rb77
-rw-r--r--sample/drb/http0serv.rb120
-rw-r--r--sample/drb/name.rb117
-rw-r--r--sample/drb/namec.rb36
-rw-r--r--sample/drb/old_tuplespace.rb212
-rw-r--r--sample/drb/rinda_ts.rb7
-rw-r--r--sample/drb/rindac.rb17
-rw-r--r--sample/drb/rindas.rb18
-rw-r--r--sample/drb/ring_echo.rb29
-rw-r--r--sample/drb/ring_inspect.rb30
-rw-r--r--sample/drb/ring_place.rb25
-rw-r--r--sample/drb/simpletuple.rb89
-rw-r--r--sample/drb/speedc.rb21
-rw-r--r--sample/drb/speeds.rb31
-rw-r--r--sample/getoptlong/abbrev.rb9
-rw-r--r--sample/getoptlong/aliases.rb8
-rw-r--r--sample/getoptlong/argv.rb12
-rw-r--r--sample/getoptlong/each.rb12
-rw-r--r--sample/getoptlong/fibonacci.rb62
-rw-r--r--sample/getoptlong/permute.rb12
-rw-r--r--sample/getoptlong/require_order.rb13
-rw-r--r--sample/getoptlong/return_in_order.rb13
-rw-r--r--sample/getoptlong/simple.rb7
-rw-r--r--sample/getoptlong/types.rb10
-rw-r--r--sample/net-imap.rb167
-rw-r--r--sample/openssl/c_rehash.rb2
-rw-r--r--sample/prism/find_calls.rb105
-rw-r--r--sample/prism/find_comments.rb100
-rw-r--r--sample/prism/locate_nodes.rb84
-rw-r--r--sample/prism/make_tags.rb302
-rw-r--r--sample/prism/multiplex_constants.rb138
-rw-r--r--sample/prism/relocate_constants.rb43
-rw-r--r--sample/prism/visit_nodes.rb63
-rw-r--r--sample/trick2025/01-omoikane/authors.markdown5
-rw-r--r--sample/trick2025/01-omoikane/bf.rb81
-rw-r--r--sample/trick2025/01-omoikane/entry.rb32
-rw-r--r--sample/trick2025/01-omoikane/remarks.markdown71
-rw-r--r--sample/trick2025/01-omoikane/sample_input.txt35
-rw-r--r--sample/trick2025/01-omoikane/spoiler_rot13.txt470
-rw-r--r--sample/trick2025/02-mame/authors.markdown3
-rw-r--r--sample/trick2025/02-mame/entry.rb34
-rw-r--r--sample/trick2025/02-mame/remarks.markdown141
-rw-r--r--sample/trick2025/02-mame/sample.orig.rb8
-rw-r--r--sample/trick2025/02-mame/test.patch16
-rw-r--r--sample/trick2025/03-tompng/authors.markdown3
-rw-r--r--sample/trick2025/03-tompng/entry.rb74
-rw-r--r--sample/trick2025/03-tompng/remarks.markdown146
-rw-r--r--sample/trick2025/04-tompng/authors.markdown3
-rw-r--r--sample/trick2025/04-tompng/entry.rb36
-rw-r--r--sample/trick2025/04-tompng/remarks.markdown43
-rw-r--r--sample/trick2025/05-tompng/authors.markdown3
-rw-r--r--sample/trick2025/05-tompng/entry.rb118
-rw-r--r--sample/trick2025/05-tompng/remarks.markdown106
-rw-r--r--sample/trick2025/README.md16
-rw-r--r--sample/uumerge.rb2
-rw-r--r--scheduler.c710
-rw-r--r--set.c2311
-rw-r--r--shape.c1761
-rw-r--r--shape.h674
-rw-r--r--signal.c289
-rw-r--r--siphash.c3
-rw-r--r--spec/README.md8
-rwxr-xr-xspec/bin/bundle6
-rwxr-xr-xspec/bin/parallel_rspec7
-rwxr-xr-xspec/bin/rspec7
-rw-r--r--spec/bundled_gems.mspec14
-rw-r--r--spec/bundled_gems_spec.rb422
-rw-r--r--spec/bundler/bundler/build_metadata_spec.rb23
-rw-r--r--spec/bundler/bundler/bundler_spec.rb140
-rw-r--r--spec/bundler/bundler/ci_detector_spec.rb21
-rw-r--r--spec/bundler/bundler/cli_common_spec.rb22
-rw-r--r--spec/bundler/bundler/cli_spec.rb114
-rw-r--r--spec/bundler/bundler/compact_index_client/parser_spec.rb249
-rw-r--r--spec/bundler/bundler/compact_index_client/updater_spec.rb206
-rw-r--r--spec/bundler/bundler/current_ruby_spec.rb157
-rw-r--r--spec/bundler/bundler/definition_spec.rb200
-rw-r--r--spec/bundler/bundler/dependency_spec.rb127
-rw-r--r--spec/bundler/bundler/digest_spec.rb2
-rw-r--r--spec/bundler/bundler/dsl_spec.rb332
-rw-r--r--spec/bundler/bundler/endpoint_specification_spec.rb48
-rw-r--r--spec/bundler/bundler/env_spec.rb49
-rw-r--r--spec/bundler/bundler/environment_preserver_spec.rb16
-rw-r--r--spec/bundler/bundler/errors_spec.rb91
-rw-r--r--spec/bundler/bundler/fetcher/base_spec.rb11
-rw-r--r--spec/bundler/bundler/fetcher/compact_index_spec.rb18
-rw-r--r--spec/bundler/bundler/fetcher/dependency_spec.rb55
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb187
-rw-r--r--spec/bundler/bundler/fetcher/gem_remote_fetcher_spec.rb60
-rw-r--r--spec/bundler/bundler/fetcher/index_spec.rb52
-rw-r--r--spec/bundler/bundler/fetcher_spec.rb98
-rw-r--r--spec/bundler/bundler/friendly_errors_spec.rb37
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb53
-rw-r--r--spec/bundler/bundler/gem_version_promoter_spec.rb235
-rw-r--r--spec/bundler/bundler/installer/gem_installer_spec.rb21
-rw-r--r--spec/bundler/bundler/installer/parallel_installer_spec.rb97
-rw-r--r--spec/bundler/bundler/installer/spec_installation_spec.rb77
-rw-r--r--spec/bundler/bundler/lockfile_parser_spec.rb166
-rw-r--r--spec/bundler/bundler/mirror_spec.rb16
-rw-r--r--spec/bundler/bundler/override_spec.rb175
-rw-r--r--spec/bundler/bundler/plugin/api/source_spec.rb4
-rw-r--r--spec/bundler/bundler/plugin/dsl_spec.rb6
-rw-r--r--spec/bundler/bundler/plugin/events_spec.rb12
-rw-r--r--spec/bundler/bundler/plugin/index_spec.rb83
-rw-r--r--spec/bundler/bundler/plugin/installer_spec.rb28
-rw-r--r--spec/bundler/bundler/plugin_spec.rb61
-rw-r--r--spec/bundler/bundler/remote_specification_spec.rb12
-rw-r--r--spec/bundler/bundler/resolver/candidate_spec.rb19
-rw-r--r--spec/bundler/bundler/resolver/cooldown_spec.rb148
-rw-r--r--spec/bundler/bundler/retry_spec.rb113
-rw-r--r--spec/bundler/bundler/ruby_dsl_spec.rb163
-rw-r--r--spec/bundler/bundler/ruby_version_spec.rb32
-rw-r--r--spec/bundler/bundler/rubygems_ext_spec.rb39
-rw-r--r--spec/bundler/bundler/rubygems_integration_spec.rb78
-rw-r--r--spec/bundler/bundler/settings/validator_spec.rb6
-rw-r--r--spec/bundler/bundler/settings_spec.rb103
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb68
-rw-r--r--spec/bundler/bundler/source/git/git_proxy_spec.rb274
-rw-r--r--spec/bundler/bundler/source/git_spec.rb54
-rw-r--r--spec/bundler/bundler/source/rubygems/remote_spec.rb55
-rw-r--r--spec/bundler/bundler/source/rubygems_spec.rb57
-rw-r--r--spec/bundler/bundler/source_list_spec.rb48
-rw-r--r--spec/bundler/bundler/source_spec.rb20
-rw-r--r--spec/bundler/bundler/spec_set_spec.rb97
-rw-r--r--spec/bundler/bundler/specifications/foo.gemspec13
-rw-r--r--spec/bundler/bundler/stub_specification_spec.rb39
-rw-r--r--spec/bundler/bundler/ui/shell_spec.rb54
-rw-r--r--spec/bundler/bundler/uri_credentials_filter_spec.rb20
-rw-r--r--spec/bundler/bundler/uri_normalizer_spec.rb25
-rw-r--r--spec/bundler/bundler/worker_spec.rb20
-rw-r--r--spec/bundler/bundler/yaml_serializer_spec.rb61
-rw-r--r--spec/bundler/cache/cache_path_spec.rb14
-rw-r--r--spec/bundler/cache/gems_spec.rb330
-rw-r--r--spec/bundler/cache/git_spec.rb305
-rw-r--r--spec/bundler/cache/path_spec.rb74
-rw-r--r--spec/bundler/cache/platform_spec.rb18
-rw-r--r--spec/bundler/commands/add_spec.rb269
-rw-r--r--spec/bundler/commands/binstubs_spec.rb405
-rw-r--r--spec/bundler/commands/cache_spec.rb430
-rw-r--r--spec/bundler/commands/check_spec.rb371
-rw-r--r--spec/bundler/commands/clean_spec.rb450
-rw-r--r--spec/bundler/commands/config_spec.rb144
-rw-r--r--spec/bundler/commands/console_spec.rb217
-rw-r--r--spec/bundler/commands/doctor_spec.rb89
-rw-r--r--spec/bundler/commands/exec_spec.rb632
-rw-r--r--spec/bundler/commands/fund_spec.rb50
-rw-r--r--spec/bundler/commands/help_spec.rb14
-rw-r--r--spec/bundler/commands/info_spec.rb66
-rw-r--r--spec/bundler/commands/init_spec.rb44
-rw-r--r--spec/bundler/commands/inject_spec.rb117
-rw-r--r--spec/bundler/commands/install_spec.rb1597
-rw-r--r--spec/bundler/commands/issue_spec.rb2
-rw-r--r--spec/bundler/commands/licenses_spec.rb6
-rw-r--r--spec/bundler/commands/list_spec.rb178
-rw-r--r--spec/bundler/commands/lock_spec.rb2234
-rw-r--r--spec/bundler/commands/newgem_spec.rb1947
-rw-r--r--spec/bundler/commands/open_spec.rb71
-rw-r--r--spec/bundler/commands/outdated_spec.rb475
-rw-r--r--spec/bundler/commands/platform_spec.rb605
-rw-r--r--spec/bundler/commands/post_bundle_message_spec.rb228
-rw-r--r--spec/bundler/commands/pristine_spec.rb96
-rw-r--r--spec/bundler/commands/remove_spec.rb364
-rw-r--r--spec/bundler/commands/show_spec.rb89
-rw-r--r--spec/bundler/commands/ssl_spec.rb373
-rw-r--r--spec/bundler/commands/update_spec.rb1109
-rw-r--r--spec/bundler/commands/version_spec.rb54
-rw-r--r--spec/bundler/commands/viz_spec.rb144
-rw-r--r--spec/bundler/install/allow_offline_install_spec.rb52
-rw-r--r--spec/bundler/install/binstubs_spec.rb22
-rw-r--r--spec/bundler/install/bundler_spec.rb78
-rw-r--r--spec/bundler/install/cooldown_spec.rb272
-rw-r--r--spec/bundler/install/deploy_spec.rb436
-rw-r--r--spec/bundler/install/failure_spec.rb42
-rw-r--r--spec/bundler/install/force_spec.rb71
-rw-r--r--spec/bundler/install/gemfile/eval_gemfile_spec.rb42
-rw-r--r--spec/bundler/install/gemfile/force_ruby_platform_spec.rb86
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb414
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb694
-rw-r--r--spec/bundler/install/gemfile/groups_spec.rb190
-rw-r--r--spec/bundler/install/gemfile/install_if_spec.rb25
-rw-r--r--spec/bundler/install/gemfile/lockfile_spec.rb32
-rw-r--r--spec/bundler/install/gemfile/override_spec.rb401
-rw-r--r--spec/bundler/install/gemfile/path_spec.rb455
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb490
-rw-r--r--spec/bundler/install/gemfile/ruby_spec.rb98
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb1405
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb1335
-rw-r--r--spec/bundler/install/gemfile_spec.rb128
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb685
-rw-r--r--spec/bundler/install/gems/dependency_api_fallback_spec.rb19
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb397
-rw-r--r--spec/bundler/install/gems/env_spec.rb36
-rw-r--r--spec/bundler/install/gems/flex_spec.rb239
-rw-r--r--spec/bundler/install/gems/fund_spec.rb30
-rw-r--r--spec/bundler/install/gems/gemfile_source_header_spec.rb24
-rw-r--r--spec/bundler/install/gems/mirror_probe_spec.rb68
-rw-r--r--spec/bundler/install/gems/mirror_spec.rb24
-rw-r--r--spec/bundler/install/gems/native_extensions_spec.rb36
-rw-r--r--spec/bundler/install/gems/no_build_extension_spec.rb54
-rw-r--r--spec/bundler/install/gems/no_install_plugin_spec.rb53
-rw-r--r--spec/bundler/install/gems/post_install_spec.rb46
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb368
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb253
-rw-r--r--spec/bundler/install/gems/win32_spec.rb10
-rw-r--r--spec/bundler/install/gemspecs_spec.rb84
-rw-r--r--spec/bundler/install/git_spec.rb341
-rw-r--r--spec/bundler/install/global_cache_spec.rb225
-rw-r--r--spec/bundler/install/path_spec.rb154
-rw-r--r--spec/bundler/install/prereleases_spec.rb18
-rw-r--r--spec/bundler/install/process_lock_spec.rb70
-rw-r--r--spec/bundler/install/redownload_spec.rb91
-rw-r--r--spec/bundler/install/security_policy_spec.rb20
-rw-r--r--spec/bundler/install/yanked_spec.rb165
-rw-r--r--spec/bundler/lock/git_spec.rb126
-rw-r--r--spec/bundler/lock/lockfile_spec.rb1688
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb12
-rw-r--r--spec/bundler/other/cli_man_pages_spec.rb100
-rw-r--r--spec/bundler/other/ext_spec.rb71
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb643
-rw-r--r--spec/bundler/plugins/command_spec.rb44
-rw-r--r--spec/bundler/plugins/hook_spec.rb256
-rw-r--r--spec/bundler/plugins/install_spec.rb186
-rw-r--r--spec/bundler/plugins/list_spec.rb4
-rw-r--r--spec/bundler/plugins/source/example_spec.rb68
-rw-r--r--spec/bundler/plugins/source_spec.rb16
-rw-r--r--spec/bundler/plugins/uninstall_spec.rb29
-rw-r--r--spec/bundler/quality_es_spec.rb4
-rw-r--r--spec/bundler/quality_spec.rb50
-rw-r--r--spec/bundler/realworld/dependency_api_spec.rb46
-rw-r--r--spec/bundler/realworld/double_check_spec.rb6
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb457
-rw-r--r--spec/bundler/realworld/ffi_spec.rb6
-rw-r--r--spec/bundler/realworld/fixtures/tapioca/Gemfile5
-rw-r--r--spec/bundler/realworld/fixtures/tapioca/Gemfile.lock49
-rw-r--r--spec/bundler/realworld/fixtures/warbler/Gemfile6
-rw-r--r--spec/bundler/realworld/fixtures/warbler/Gemfile.lock31
-rw-r--r--spec/bundler/realworld/gemfile_source_header_spec.rb53
-rw-r--r--spec/bundler/realworld/git_spec.rb2
-rw-r--r--spec/bundler/realworld/mirror_probe_spec.rb131
-rw-r--r--spec/bundler/realworld/parallel_spec.rb8
-rw-r--r--spec/bundler/realworld/slow_perf_spec.rb8
-rw-r--r--spec/bundler/resolver/basic_spec.rb124
-rw-r--r--spec/bundler/resolver/platform_spec.rb64
-rw-r--r--spec/bundler/runtime/env_helpers_spec.rb236
-rw-r--r--spec/bundler/runtime/executable_spec.rb116
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb86
-rw-r--r--spec/bundler/runtime/inline_spec.rb382
-rw-r--r--spec/bundler/runtime/load_spec.rb30
-rw-r--r--spec/bundler/runtime/platform_spec.rb184
-rw-r--r--spec/bundler/runtime/require_spec.rb149
-rw-r--r--spec/bundler/runtime/requiring_spec.rb15
-rw-r--r--spec/bundler/runtime/self_management_spec.rb217
-rw-r--r--spec/bundler/runtime/setup_spec.rb707
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb302
-rw-r--r--spec/bundler/spec_helper.rb97
-rw-r--r--spec/bundler/support/activate.rb9
-rw-r--r--spec/bundler/support/api_request_limit_hax.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_checksum_mismatch.rb4
-rw-r--r--spec/bundler/support/artifice/compact_index_concurrent_download.rb7
-rw-r--r--spec/bundler/support/artifice/compact_index_cooldown.rb6
-rw-r--r--spec/bundler/support/artifice/compact_index_creds_diff_host.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_etag_match.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_host_redirect.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_mirror_down.rb21
-rw-r--r--spec/bundler/support/artifice/compact_index_no_checksums.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_bad_digest.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_no_digest_not_incremental.rb42
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_range_ignored.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb3
-rw-r--r--spec/bundler/support/artifice/endpoint_500.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_creds_diff_host.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_host_redirect.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_mirror_source.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb2
-rw-r--r--spec/bundler/support/artifice/fail.rb14
-rw-r--r--spec/bundler/support/artifice/helpers/artifice.rb6
-rw-r--r--spec/bundler/support/artifice/helpers/compact_index.rb48
-rw-r--r--spec/bundler/support/artifice/helpers/compact_index_cooldown.rb13
-rw-r--r--spec/bundler/support/artifice/helpers/endpoint.rb17
-rw-r--r--spec/bundler/support/artifice/helpers/rack_request.rb24
-rw-r--r--spec/bundler/support/artifice/vcr.rb16
-rw-r--r--spec/bundler/support/artifice/windows.rb2
-rw-r--r--spec/bundler/support/build_metadata.rb20
-rw-r--r--spec/bundler/support/builders.rb360
-rwxr-xr-xspec/bundler/support/bundle6
-rw-r--r--spec/bundler/support/bundle.rb11
-rw-r--r--spec/bundler/support/checksums.rb135
-rw-r--r--spec/bundler/support/command_execution.rb47
-rw-r--r--spec/bundler/support/env.rb13
-rw-r--r--spec/bundler/support/filters.rb42
-rw-r--r--spec/bundler/support/hax.rb51
-rw-r--r--spec/bundler/support/helpers.rb550
-rw-r--r--spec/bundler/support/indexes.rb33
-rw-r--r--spec/bundler/support/matchers.rb26
-rw-r--r--spec/bundler/support/options.rb15
-rw-r--r--spec/bundler/support/path.rb202
-rw-r--r--spec/bundler/support/platforms.rb77
-rw-r--r--spec/bundler/support/rubygems_ext.rb165
-rw-r--r--spec/bundler/support/rubygems_version_manager.rb38
-rw-r--r--spec/bundler/support/setup.rb9
-rw-r--r--spec/bundler/support/shards.rb200
-rw-r--r--spec/bundler/support/silent_logger.rb10
-rw-r--r--spec/bundler/support/subprocess.rb115
-rw-r--r--spec/bundler/support/switch_rubygems.rb1
-rw-r--r--spec/bundler/support/the_bundle.rb16
-rw-r--r--spec/bundler/support/vendored_net_http.rb23
-rw-r--r--spec/bundler/update/force_spec.rb30
-rw-r--r--spec/bundler/update/gemfile_spec.rb26
-rw-r--r--spec/bundler/update/gems/fund_spec.rb6
-rw-r--r--spec/bundler/update/gems/post_install_spec.rb24
-rw-r--r--spec/bundler/update/git_spec.rb149
-rw-r--r--spec/bundler/update/path_spec.rb6
-rw-r--r--spec/bundler/update/redownload_spec.rb34
-rw-r--r--spec/default.mspec124
-rw-r--r--spec/mmtk.mspec12
-rw-r--r--[-rwxr-xr-x]spec/mspec/lib/mspec/commands/mkspec.rb2
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-ci.rb5
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-run.rb8
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-tag.rb3
-rw-r--r--[-rwxr-xr-x]spec/mspec/lib/mspec/commands/mspec.rb7
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb24
-rw-r--r--spec/mspec/lib/mspec/helpers/io.rb4
-rw-r--r--spec/mspec/lib/mspec/helpers/numeric.rb26
-rw-r--r--spec/mspec/lib/mspec/helpers/tmp.rb18
-rw-r--r--spec/mspec/lib/mspec/matchers/base.rb16
-rw-r--r--spec/mspec/lib/mspec/matchers/complain.rb2
-rw-r--r--spec/mspec/lib/mspec/matchers/raise_error.rb63
-rw-r--r--spec/mspec/lib/mspec/mocks/mock.rb25
-rw-r--r--spec/mspec/lib/mspec/runner/actions/leakchecker.rb64
-rw-r--r--spec/mspec/lib/mspec/runner/actions/timeout.rb30
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/base.rb8
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/launchable.rb88
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/multi.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/mspec.rb3
-rw-r--r--spec/mspec/lib/mspec/utils/name_map.rb13
-rw-r--r--spec/mspec/lib/mspec/utils/options.rb19
-rw-r--r--spec/mspec/lib/mspec/utils/script.rb8
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb43
-rw-r--r--spec/mspec/spec/commands/mspec_ci_spec.rb5
-rw-r--r--spec/mspec/spec/commands/mspec_run_spec.rb5
-rw-r--r--spec/mspec/spec/commands/mspec_spec.rb27
-rw-r--r--spec/mspec/spec/guards/platform_spec.rb38
-rw-r--r--spec/mspec/spec/integration/run_spec.rb9
-rw-r--r--spec/mspec/spec/integration/tag_spec.rb9
-rw-r--r--spec/mspec/spec/matchers/raise_error_spec.rb73
-rw-r--r--spec/mspec/spec/mocks/mock_spec.rb21
-rw-r--r--spec/mspec/spec/runner/context_spec.rb2
-rw-r--r--spec/mspec/spec/spec_helper.rb2
-rw-r--r--spec/mspec/spec/utils/fixtures/this_file_raises.rb1
-rw-r--r--spec/mspec/spec/utils/fixtures/this_file_raises2.rb1
-rw-r--r--spec/mspec/spec/utils/name_map_spec.rb12
-rwxr-xr-x[-rw-r--r--]spec/mspec/tool/remove_old_guards.rb79
-rw-r--r--spec/mspec/tool/sync/sync-rubyspec.rb50
-rwxr-xr-xspec/mspec/tool/tag_from_output.rb12
-rw-r--r--spec/ruby/.mspec.constants2
-rw-r--r--spec/ruby/.rubocop.yml23
-rw-r--r--spec/ruby/.rubocop_todo.yml69
-rw-r--r--spec/ruby/CONTRIBUTING.md76
-rw-r--r--spec/ruby/README.md20
-rwxr-xr-xspec/ruby/bin/rubocop12
-rw-r--r--spec/ruby/command_line/backtrace_limit_spec.rb49
-rwxr-xr-xspec/ruby/command_line/dash_0_spec.rb13
-rw-r--r--spec/ruby/command_line/dash_a_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_l_spec.rb8
-rw-r--r--spec/ruby/command_line/dash_n_spec.rb8
-rw-r--r--spec/ruby/command_line/dash_p_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_r_spec.rb8
-rw-r--r--spec/ruby/command_line/dash_upper_f_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_i_spec.rb10
-rw-r--r--spec/ruby/command_line/dash_upper_s_spec.rb40
-rw-r--r--spec/ruby/command_line/dash_upper_u_spec.rb31
-rw-r--r--spec/ruby/command_line/dash_v_spec.rb6
-rw-r--r--spec/ruby/command_line/dash_x_spec.rb2
-rw-r--r--spec/ruby/command_line/error_message_spec.rb5
-rw-r--r--spec/ruby/command_line/feature_spec.rb10
-rw-r--r--spec/ruby/command_line/fixtures/bin/bad_embedded_ruby.txt2
-rw-r--r--spec/ruby/command_line/fixtures/bin/embedded_ruby.txt4
-rw-r--r--spec/ruby/command_line/fixtures/debug_info.rb1
-rw-r--r--spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rbbin121 -> 90 bytes-rw-r--r--spec/ruby/command_line/fixtures/string_literal_frozen_comment.rb4
-rw-r--r--spec/ruby/command_line/fixtures/string_literal_mutable_comment.rb4
-rw-r--r--spec/ruby/command_line/fixtures/string_literal_raw.rb3
-rw-r--r--spec/ruby/command_line/frozen_strings_spec.rb73
-rw-r--r--spec/ruby/command_line/rubylib_spec.rb16
-rw-r--r--spec/ruby/command_line/rubyopt_spec.rb20
-rw-r--r--spec/ruby/command_line/syntax_error_spec.rb4
-rw-r--r--spec/ruby/core/argf/argf_spec.rb4
-rw-r--r--spec/ruby/core/argf/argv_spec.rb2
-rw-r--r--spec/ruby/core/argf/binmode_spec.rb2
-rw-r--r--spec/ruby/core/argf/bytes_spec.rb16
-rw-r--r--spec/ruby/core/argf/chars_spec.rb16
-rw-r--r--spec/ruby/core/argf/close_spec.rb8
-rw-r--r--spec/ruby/core/argf/closed_spec.rb2
-rw-r--r--spec/ruby/core/argf/codepoints_spec.rb16
-rw-r--r--spec/ruby/core/argf/each_byte_spec.rb58
-rw-r--r--spec/ruby/core/argf/each_char_spec.rb58
-rw-r--r--spec/ruby/core/argf/each_codepoint_spec.rb58
-rw-r--r--spec/ruby/core/argf/each_line_spec.rb62
-rw-r--r--spec/ruby/core/argf/each_spec.rb5
-rw-r--r--spec/ruby/core/argf/eof_spec.rb28
-rw-r--r--spec/ruby/core/argf/filename_spec.rb28
-rw-r--r--spec/ruby/core/argf/fileno_spec.rb24
-rw-r--r--spec/ruby/core/argf/inspect_spec.rb7
-rw-r--r--spec/ruby/core/argf/lines_spec.rb16
-rw-r--r--spec/ruby/core/argf/path_spec.rb5
-rw-r--r--spec/ruby/core/argf/pos_spec.rb31
-rw-r--r--spec/ruby/core/argf/read_nonblock_spec.rb2
-rw-r--r--spec/ruby/core/argf/readchar_spec.rb2
-rw-r--r--spec/ruby/core/argf/readline_spec.rb2
-rw-r--r--spec/ruby/core/argf/readlines_spec.rb22
-rw-r--r--spec/ruby/core/argf/readpartial_spec.rb10
-rw-r--r--spec/ruby/core/argf/rewind_spec.rb2
-rw-r--r--spec/ruby/core/argf/seek_spec.rb2
-rw-r--r--spec/ruby/core/argf/shared/each_byte.rb58
-rw-r--r--spec/ruby/core/argf/shared/each_char.rb58
-rw-r--r--spec/ruby/core/argf/shared/each_codepoint.rb58
-rw-r--r--spec/ruby/core/argf/shared/each_line.rb62
-rw-r--r--spec/ruby/core/argf/shared/eof.rb24
-rw-r--r--spec/ruby/core/argf/shared/filename.rb28
-rw-r--r--spec/ruby/core/argf/shared/fileno.rb24
-rw-r--r--spec/ruby/core/argf/shared/getc.rb2
-rw-r--r--spec/ruby/core/argf/shared/pos.rb31
-rw-r--r--spec/ruby/core/argf/shared/read.rb4
-rw-r--r--spec/ruby/core/argf/shared/readlines.rb22
-rw-r--r--spec/ruby/core/argf/skip_spec.rb2
-rw-r--r--spec/ruby/core/argf/tell_spec.rb5
-rw-r--r--spec/ruby/core/argf/to_a_spec.rb5
-rw-r--r--spec/ruby/core/argf/to_i_spec.rb5
-rw-r--r--spec/ruby/core/argf/to_io_spec.rb2
-rw-r--r--spec/ruby/core/array/allocate_spec.rb4
-rw-r--r--spec/ruby/core/array/append_spec.rb11
-rw-r--r--spec/ruby/core/array/assoc_spec.rb40
-rw-r--r--spec/ruby/core/array/at_spec.rb4
-rw-r--r--spec/ruby/core/array/bsearch_index_spec.rb32
-rw-r--r--spec/ruby/core/array/bsearch_spec.rb26
-rw-r--r--spec/ruby/core/array/clear_spec.rb8
-rw-r--r--spec/ruby/core/array/clone_spec.rb8
-rw-r--r--spec/ruby/core/array/collect_spec.rb138
-rw-r--r--spec/ruby/core/array/combination_spec.rb6
-rw-r--r--spec/ruby/core/array/compact_spec.rb14
-rw-r--r--spec/ruby/core/array/comparison_spec.rb2
-rw-r--r--spec/ruby/core/array/concat_spec.rb10
-rw-r--r--spec/ruby/core/array/constructor_spec.rb4
-rw-r--r--spec/ruby/core/array/cycle_spec.rb20
-rw-r--r--spec/ruby/core/array/deconstruct_spec.rb2
-rw-r--r--spec/ruby/core/array/delete_at_spec.rb2
-rw-r--r--spec/ruby/core/array/delete_if_spec.rb16
-rw-r--r--spec/ruby/core/array/delete_spec.rb2
-rw-r--r--spec/ruby/core/array/difference_spec.rb4
-rw-r--r--spec/ruby/core/array/dig_spec.rb8
-rw-r--r--spec/ruby/core/array/drop_spec.rb18
-rw-r--r--spec/ruby/core/array/drop_while_spec.rb12
-rw-r--r--spec/ruby/core/array/dup_spec.rb12
-rw-r--r--spec/ruby/core/array/each_index_spec.rb2
-rw-r--r--spec/ruby/core/array/each_spec.rb4
-rw-r--r--spec/ruby/core/array/element_reference_spec.rb861
-rw-r--r--spec/ruby/core/array/element_set_spec.rb48
-rw-r--r--spec/ruby/core/array/eql_spec.rb4
-rw-r--r--spec/ruby/core/array/equal_value_spec.rb10
-rw-r--r--spec/ruby/core/array/fetch_spec.rb10
-rw-r--r--spec/ruby/core/array/fetch_values_spec.rb55
-rw-r--r--spec/ruby/core/array/fill_spec.rb92
-rw-r--r--spec/ruby/core/array/filter_spec.rb11
-rw-r--r--spec/ruby/core/array/find_index_spec.rb40
-rw-r--r--spec/ruby/core/array/first_spec.rb24
-rw-r--r--spec/ruby/core/array/fixtures/classes.rb754
-rw-r--r--spec/ruby/core/array/fixtures/encoded_strings.rb18
-rw-r--r--spec/ruby/core/array/flatten_spec.rb52
-rw-r--r--spec/ruby/core/array/hash_spec.rb8
-rw-r--r--spec/ruby/core/array/index_spec.rb5
-rw-r--r--spec/ruby/core/array/initialize_spec.rb32
-rw-r--r--spec/ruby/core/array/insert_spec.rb14
-rw-r--r--spec/ruby/core/array/inspect_spec.rb105
-rw-r--r--spec/ruby/core/array/intersect_spec.rb92
-rw-r--r--spec/ruby/core/array/join_spec.rb102
-rw-r--r--spec/ruby/core/array/keep_if_spec.rb2
-rw-r--r--spec/ruby/core/array/last_spec.rb22
-rw-r--r--spec/ruby/core/array/length_spec.rb11
-rw-r--r--spec/ruby/core/array/map_spec.rb10
-rw-r--r--spec/ruby/core/array/max_spec.rb8
-rw-r--r--spec/ruby/core/array/min_spec.rb10
-rw-r--r--spec/ruby/core/array/multiply_spec.rb34
-rw-r--r--spec/ruby/core/array/new_spec.rb28
-rw-r--r--spec/ruby/core/array/pack/a_spec.rb10
-rw-r--r--spec/ruby/core/array/pack/at_spec.rb2
-rw-r--r--spec/ruby/core/array/pack/b_spec.rb6
-rw-r--r--spec/ruby/core/array/pack/buffer_spec.rb26
-rw-r--r--spec/ruby/core/array/pack/c_spec.rb18
-rw-r--r--spec/ruby/core/array/pack/comment_spec.rb2
-rw-r--r--spec/ruby/core/array/pack/h_spec.rb6
-rw-r--r--spec/ruby/core/array/pack/l_spec.rb16
-rw-r--r--spec/ruby/core/array/pack/m_spec.rb14
-rw-r--r--spec/ruby/core/array/pack/percent_spec.rb2
-rw-r--r--spec/ruby/core/array/pack/r_spec.rb89
-rw-r--r--spec/ruby/core/array/pack/shared/basic.rb56
-rw-r--r--spec/ruby/core/array/pack/shared/encodings.rb4
-rw-r--r--spec/ruby/core/array/pack/shared/float.rb82
-rw-r--r--spec/ruby/core/array/pack/shared/integer.rb108
-rw-r--r--spec/ruby/core/array/pack/shared/numeric_basic.rb16
-rw-r--r--spec/ruby/core/array/pack/shared/string.rb10
-rw-r--r--spec/ruby/core/array/pack/shared/unicode.rb24
-rw-r--r--spec/ruby/core/array/pack/u_spec.rb12
-rw-r--r--spec/ruby/core/array/pack/w_spec.rb20
-rw-r--r--spec/ruby/core/array/pack/x_spec.rb6
-rw-r--r--spec/ruby/core/array/pack/z_spec.rb6
-rw-r--r--spec/ruby/core/array/partition_spec.rb6
-rw-r--r--spec/ruby/core/array/permutation_spec.rb10
-rw-r--r--spec/ruby/core/array/plus_spec.rb27
-rw-r--r--spec/ruby/core/array/pop_spec.rb24
-rw-r--r--spec/ruby/core/array/prepend_spec.rb6
-rw-r--r--spec/ruby/core/array/product_spec.rb19
-rw-r--r--spec/ruby/core/array/push_spec.rb33
-rw-r--r--spec/ruby/core/array/rassoc_spec.rb16
-rw-r--r--spec/ruby/core/array/reject_spec.rb16
-rw-r--r--spec/ruby/core/array/repeated_combination_spec.rb8
-rw-r--r--spec/ruby/core/array/repeated_permutation_spec.rb4
-rw-r--r--spec/ruby/core/array/replace_spec.rb60
-rw-r--r--spec/ruby/core/array/reverse_each_spec.rb2
-rw-r--r--spec/ruby/core/array/reverse_spec.rb6
-rw-r--r--spec/ruby/core/array/rindex_spec.rb4
-rw-r--r--spec/ruby/core/array/rotate_spec.rb42
-rw-r--r--spec/ruby/core/array/sample_spec.rb39
-rw-r--r--spec/ruby/core/array/select_spec.rb35
-rw-r--r--spec/ruby/core/array/shared/clone.rb8
-rw-r--r--spec/ruby/core/array/shared/collect.rb141
-rw-r--r--spec/ruby/core/array/shared/difference.rb8
-rw-r--r--spec/ruby/core/array/shared/enumeratorize.rb2
-rw-r--r--spec/ruby/core/array/shared/eql.rb66
-rw-r--r--spec/ruby/core/array/shared/index.rb41
-rw-r--r--spec/ruby/core/array/shared/inspect.rb107
-rw-r--r--spec/ruby/core/array/shared/intersection.rb6
-rw-r--r--spec/ruby/core/array/shared/join.rb97
-rw-r--r--spec/ruby/core/array/shared/keep_if.rb16
-rw-r--r--spec/ruby/core/array/shared/length.rb11
-rw-r--r--spec/ruby/core/array/shared/push.rb33
-rw-r--r--spec/ruby/core/array/shared/replace.rb60
-rw-r--r--spec/ruby/core/array/shared/select.rb35
-rw-r--r--spec/ruby/core/array/shared/slice.rb889
-rw-r--r--spec/ruby/core/array/shared/union.rb6
-rw-r--r--spec/ruby/core/array/shared/unshift.rb64
-rw-r--r--spec/ruby/core/array/shift_spec.rb20
-rw-r--r--spec/ruby/core/array/shuffle_spec.rb51
-rw-r--r--spec/ruby/core/array/size_spec.rb6
-rw-r--r--spec/ruby/core/array/slice_spec.rb71
-rw-r--r--spec/ruby/core/array/sort_by_spec.rb16
-rw-r--r--spec/ruby/core/array/sort_spec.rb40
-rw-r--r--spec/ruby/core/array/sum_spec.rb16
-rw-r--r--spec/ruby/core/array/take_spec.rb14
-rw-r--r--spec/ruby/core/array/take_while_spec.rb12
-rw-r--r--spec/ruby/core/array/to_a_spec.rb4
-rw-r--r--spec/ruby/core/array/to_ary_spec.rb4
-rw-r--r--spec/ruby/core/array/to_h_spec.rb22
-rw-r--r--spec/ruby/core/array/to_s_spec.rb7
-rw-r--r--spec/ruby/core/array/transpose_spec.rb10
-rw-r--r--spec/ruby/core/array/try_convert_spec.rb16
-rw-r--r--spec/ruby/core/array/union_spec.rb2
-rw-r--r--spec/ruby/core/array/uniq_spec.rb22
-rw-r--r--spec/ruby/core/array/unshift_spec.rb64
-rw-r--r--spec/ruby/core/array/values_at_spec.rb2
-rw-r--r--spec/ruby/core/array/zip_spec.rb8
-rw-r--r--spec/ruby/core/basicobject/__send___spec.rb2
-rw-r--r--spec/ruby/core/basicobject/basicobject_spec.rb20
-rw-r--r--spec/ruby/core/basicobject/equal_spec.rb20
-rw-r--r--spec/ruby/core/basicobject/equal_value_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/initialize_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/instance_eval_spec.rb76
-rw-r--r--spec/ruby/core/basicobject/instance_exec_spec.rb48
-rw-r--r--spec/ruby/core/basicobject/method_missing_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/not_equal_spec.rb16
-rw-r--r--spec/ruby/core/basicobject/not_spec.rb4
-rw-r--r--spec/ruby/core/basicobject/singleton_method_added_spec.rb14
-rw-r--r--spec/ruby/core/basicobject/singleton_method_removed_spec.rb2
-rw-r--r--spec/ruby/core/basicobject/singleton_method_undefined_spec.rb2
-rw-r--r--spec/ruby/core/binding/clone_spec.rb6
-rw-r--r--spec/ruby/core/binding/dup_spec.rb23
-rw-r--r--spec/ruby/core/binding/eval_spec.rb103
-rw-r--r--spec/ruby/core/binding/fixtures/irb.rb3
-rw-r--r--spec/ruby/core/binding/fixtures/irbrc1
-rw-r--r--spec/ruby/core/binding/irb_spec.rb16
-rw-r--r--spec/ruby/core/binding/local_variable_get_spec.rb10
-rw-r--r--spec/ruby/core/binding/local_variable_set_spec.rb8
-rw-r--r--spec/ruby/core/binding/local_variables_spec.rb2
-rw-r--r--spec/ruby/core/binding/shared/clone.rb22
-rw-r--r--spec/ruby/core/binding/source_location_spec.rb5
-rw-r--r--spec/ruby/core/builtin_constants/builtin_constants_spec.rb116
-rw-r--r--spec/ruby/core/class/allocate_spec.rb6
-rw-r--r--spec/ruby/core/class/attached_object_spec.rb40
-rw-r--r--spec/ruby/core/class/dup_spec.rb7
-rw-r--r--spec/ruby/core/class/inherited_spec.rb21
-rw-r--r--spec/ruby/core/class/initialize_spec.rb10
-rw-r--r--spec/ruby/core/class/new_spec.rb24
-rw-r--r--spec/ruby/core/class/subclasses_spec.rb109
-rw-r--r--spec/ruby/core/class/superclass_spec.rb2
-rw-r--r--spec/ruby/core/comparable/clamp_spec.rb179
-rw-r--r--spec/ruby/core/comparable/equal_value_spec.rb10
-rw-r--r--spec/ruby/core/comparable/fixtures/classes.rb1
-rw-r--r--spec/ruby/core/comparable/gt_spec.rb2
-rw-r--r--spec/ruby/core/comparable/gte_spec.rb2
-rw-r--r--spec/ruby/core/comparable/lt_spec.rb6
-rw-r--r--spec/ruby/core/comparable/lte_spec.rb2
-rw-r--r--spec/ruby/core/complex/abs_spec.rb10
-rw-r--r--spec/ruby/core/complex/angle_spec.rb5
-rw-r--r--spec/ruby/core/complex/arg_spec.rb9
-rw-r--r--spec/ruby/core/complex/coerce_spec.rb32
-rw-r--r--spec/ruby/core/complex/comparison_spec.rb12
-rw-r--r--spec/ruby/core/complex/conj_spec.rb5
-rw-r--r--spec/ruby/core/complex/conjugate_spec.rb8
-rw-r--r--spec/ruby/core/complex/constants_spec.rb2
-rw-r--r--spec/ruby/core/complex/divide_spec.rb82
-rw-r--r--spec/ruby/core/complex/eql_spec.rb12
-rw-r--r--spec/ruby/core/complex/equal_value_spec.rb10
-rw-r--r--spec/ruby/core/complex/exponent_spec.rb4
-rw-r--r--spec/ruby/core/complex/fdiv_spec.rb42
-rw-r--r--spec/ruby/core/complex/imag_spec.rb5
-rw-r--r--spec/ruby/core/complex/imaginary_spec.rb8
-rw-r--r--spec/ruby/core/complex/inspect_spec.rb21
-rw-r--r--spec/ruby/core/complex/integer_spec.rb4
-rw-r--r--spec/ruby/core/complex/magnitude_spec.rb5
-rw-r--r--spec/ruby/core/complex/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/core/complex/negative_spec.rb4
-rw-r--r--spec/ruby/core/complex/phase_spec.rb5
-rw-r--r--spec/ruby/core/complex/polar_spec.rb28
-rw-r--r--spec/ruby/core/complex/positive_spec.rb4
-rw-r--r--spec/ruby/core/complex/quo_spec.rb5
-rw-r--r--spec/ruby/core/complex/rationalize_spec.rb8
-rw-r--r--spec/ruby/core/complex/real_spec.rb8
-rw-r--r--spec/ruby/core/complex/rect_spec.rb9
-rw-r--r--spec/ruby/core/complex/rectangular_spec.rb110
-rw-r--r--spec/ruby/core/complex/shared/abs.rb10
-rw-r--r--spec/ruby/core/complex/shared/arg.rb9
-rw-r--r--spec/ruby/core/complex/shared/conjugate.rb8
-rw-r--r--spec/ruby/core/complex/shared/divide.rb82
-rw-r--r--spec/ruby/core/complex/shared/image.rb8
-rw-r--r--spec/ruby/core/complex/shared/rect.rb94
-rw-r--r--spec/ruby/core/complex/to_c_spec.rb2
-rw-r--r--spec/ruby/core/complex/to_f_spec.rb4
-rw-r--r--spec/ruby/core/complex/to_i_spec.rb4
-rw-r--r--spec/ruby/core/complex/to_r_spec.rb14
-rw-r--r--spec/ruby/core/complex/to_s_spec.rb11
-rw-r--r--spec/ruby/core/conditionvariable/broadcast_spec.rb3
-rw-r--r--spec/ruby/core/conditionvariable/marshal_dump_spec.rb3
-rw-r--r--spec/ruby/core/conditionvariable/signal_spec.rb3
-rw-r--r--spec/ruby/core/conditionvariable/wait_spec.rb3
-rw-r--r--spec/ruby/core/data/constants_spec.rb34
-rw-r--r--spec/ruby/core/data/deconstruct_keys_spec.rb110
-rw-r--r--spec/ruby/core/data/deconstruct_spec.rb8
-rw-r--r--spec/ruby/core/data/define_spec.rb42
-rw-r--r--spec/ruby/core/data/eql_spec.rb63
-rw-r--r--spec/ruby/core/data/equal_value_spec.rb63
-rw-r--r--spec/ruby/core/data/fixtures/classes.rb38
-rw-r--r--spec/ruby/core/data/hash_spec.rb25
-rw-r--r--spec/ruby/core/data/initialize_spec.rb212
-rw-r--r--spec/ruby/core/data/inspect_spec.rb63
-rw-r--r--spec/ruby/core/data/members_spec.rb21
-rw-r--r--spec/ruby/core/data/to_h_spec.rb63
-rw-r--r--spec/ruby/core/data/to_s_spec.rb9
-rw-r--r--spec/ruby/core/data/with_spec.rb55
-rw-r--r--spec/ruby/core/dir/chdir_spec.rb126
-rw-r--r--spec/ruby/core/dir/children_spec.rb31
-rw-r--r--spec/ruby/core/dir/chroot_spec.rb6
-rw-r--r--spec/ruby/core/dir/close_spec.rb42
-rw-r--r--spec/ruby/core/dir/each_child_spec.rb19
-rw-r--r--spec/ruby/core/dir/each_spec.rb15
-rw-r--r--spec/ruby/core/dir/empty_spec.rb8
-rw-r--r--spec/ruby/core/dir/entries_spec.rb10
-rw-r--r--spec/ruby/core/dir/exist_spec.rb63
-rw-r--r--spec/ruby/core/dir/fchdir_spec.rb71
-rw-r--r--spec/ruby/core/dir/fileno_spec.rb4
-rw-r--r--spec/ruby/core/dir/fixtures/common.rb49
-rw-r--r--spec/ruby/core/dir/for_fd_spec.rb77
-rw-r--r--spec/ruby/core/dir/foreach_spec.rb6
-rw-r--r--spec/ruby/core/dir/getwd_spec.rb12
-rw-r--r--spec/ruby/core/dir/glob_spec.rb159
-rw-r--r--spec/ruby/core/dir/home_spec.rb31
-rw-r--r--spec/ruby/core/dir/inspect_spec.rb4
-rw-r--r--spec/ruby/core/dir/mkdir_spec.rb10
-rw-r--r--spec/ruby/core/dir/open_spec.rb73
-rw-r--r--spec/ruby/core/dir/path_spec.rb26
-rw-r--r--spec/ruby/core/dir/pos_spec.rb23
-rw-r--r--spec/ruby/core/dir/pwd_spec.rb45
-rw-r--r--spec/ruby/core/dir/read_spec.rb4
-rw-r--r--spec/ruby/core/dir/scan_spec.rb224
-rw-r--r--spec/ruby/core/dir/shared/chroot.rb6
-rw-r--r--spec/ruby/core/dir/shared/closed.rb2
-rw-r--r--spec/ruby/core/dir/shared/delete.rb24
-rw-r--r--spec/ruby/core/dir/shared/exist.rb56
-rw-r--r--spec/ruby/core/dir/shared/glob.rb93
-rw-r--r--spec/ruby/core/dir/shared/open.rb73
-rw-r--r--spec/ruby/core/dir/shared/path.rb30
-rw-r--r--spec/ruby/core/dir/shared/pos.rb27
-rw-r--r--spec/ruby/core/dir/shared/pwd.rb45
-rw-r--r--spec/ruby/core/dir/tell_spec.rb27
-rw-r--r--spec/ruby/core/dir/to_path_spec.rb12
-rw-r--r--spec/ruby/core/encoding/aliases_spec.rb10
-rw-r--r--spec/ruby/core/encoding/ascii_compatible_spec.rb15
-rw-r--r--spec/ruby/core/encoding/compatible_spec.rb499
-rw-r--r--spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb6
-rw-r--r--spec/ruby/core/encoding/converter/constants_spec.rb52
-rw-r--r--spec/ruby/core/encoding/converter/convert_spec.rb22
-rw-r--r--spec/ruby/core/encoding/converter/finish_spec.rb6
-rw-r--r--spec/ruby/core/encoding/converter/last_error_spec.rb50
-rw-r--r--spec/ruby/core/encoding/converter/new_spec.rb14
-rw-r--r--spec/ruby/core/encoding/converter/primitive_convert_spec.rb31
-rw-r--r--spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb7
-rw-r--r--spec/ruby/core/encoding/converter/putback_spec.rb18
-rw-r--r--spec/ruby/core/encoding/converter/replacement_spec.rb28
-rw-r--r--spec/ruby/core/encoding/converter/search_convpath_spec.rb6
-rw-r--r--spec/ruby/core/encoding/default_external_spec.rb14
-rw-r--r--spec/ruby/core/encoding/default_internal_spec.rb12
-rw-r--r--spec/ruby/core/encoding/dummy_spec.rb21
-rw-r--r--spec/ruby/core/encoding/find_spec.rb8
-rw-r--r--spec/ruby/core/encoding/fixtures/classes.rb2
-rw-r--r--spec/ruby/core/encoding/inspect_spec.rb22
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb4
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb4
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb6
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb12
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb10
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb2
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb4
-rw-r--r--spec/ruby/core/encoding/list_spec.rb10
-rw-r--r--spec/ruby/core/encoding/locale_charmap_spec.rb76
-rw-r--r--spec/ruby/core/encoding/name_list_spec.rb8
-rw-r--r--spec/ruby/core/encoding/name_spec.rb13
-rw-r--r--spec/ruby/core/encoding/names_spec.rb6
-rw-r--r--spec/ruby/core/encoding/replicate_spec.rb73
-rw-r--r--spec/ruby/core/encoding/shared/name.rb15
-rw-r--r--spec/ruby/core/encoding/to_s_spec.rb5
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb2
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb2
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb4
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb2
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/all_spec.rb20
-rw-r--r--spec/ruby/core/enumerable/any_spec.rb20
-rw-r--r--spec/ruby/core/enumerable/chain_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/chunk_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/chunk_while_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/collect_concat_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/collect_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/compact_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/cycle_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/detect_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/drop_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/drop_while_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/each_cons_spec.rb24
-rw-r--r--spec/ruby/core/enumerable/each_entry_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/each_slice_spec.rb26
-rw-r--r--spec/ruby/core/enumerable/each_with_index_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/each_with_object_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/entries_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/filter_map_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/filter_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/find_all_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/find_index_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/find_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/first_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/fixtures/classes.rb5
-rw-r--r--spec/ruby/core/enumerable/flat_map_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/grep_spec.rb51
-rw-r--r--spec/ruby/core/enumerable/grep_v_spec.rb53
-rw-r--r--spec/ruby/core/enumerable/group_by_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/lazy_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/map_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/max_by_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/max_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/min_by_spec.rb8
-rw-r--r--spec/ruby/core/enumerable/min_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/minmax_by_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/none_spec.rb28
-rw-r--r--spec/ruby/core/enumerable/one_spec.rb32
-rw-r--r--spec/ruby/core/enumerable/partition_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/reject_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/reverse_each_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/select_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/collect.rb4
-rw-r--r--spec/ruby/core/enumerable/shared/collect_concat.rb4
-rw-r--r--spec/ruby/core/enumerable/shared/find.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/find_all.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/include.rb2
-rw-r--r--spec/ruby/core/enumerable/shared/inject.rb56
-rw-r--r--spec/ruby/core/enumerable/shared/take.rb8
-rw-r--r--spec/ruby/core/enumerable/shared/value_packing.rb26
-rw-r--r--spec/ruby/core/enumerable/slice_after_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/slice_before_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/slice_when_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/sort_by_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/sort_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/take_spec.rb10
-rw-r--r--spec/ruby/core/enumerable/take_while_spec.rb4
-rw-r--r--spec/ruby/core/enumerable/tally_spec.rb103
-rw-r--r--spec/ruby/core/enumerable/to_a_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/to_h_spec.rb20
-rw-r--r--spec/ruby/core/enumerable/to_set_spec.rb30
-rw-r--r--spec/ruby/core/enumerable/zip_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/chain/initialize_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/chain/rewind_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/each_spec.rb47
-rw-r--r--spec/ruby/core/enumerator/each_with_index_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/each_with_object_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/enum_for_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/feed_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/fixtures/classes.rb (renamed from spec/ruby/fixtures/enumerator/classes.rb)0
-rw-r--r--spec/ruby/core/enumerator/generator/each_spec.rb40
-rw-r--r--spec/ruby/core/enumerator/generator/initialize_spec.rb26
-rw-r--r--spec/ruby/core/enumerator/initialize_spec.rb24
-rw-r--r--spec/ruby/core/enumerator/lazy/chunk_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/chunk_while_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/compact_spec.rb18
-rw-r--r--spec/ruby/core/enumerator/lazy/drop_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/drop_while_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/grep_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/lazy/grep_v_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/lazy/initialize_spec.rb16
-rw-r--r--spec/ruby/core/enumerator/lazy/lazy_spec.rb17
-rw-r--r--spec/ruby/core/enumerator/lazy/reject_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/collect.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/collect_concat.rb10
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/select.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/shared/to_enum.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_after_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_before_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/slice_when_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/take_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/take_while_spec.rb6
-rw-r--r--spec/ruby/core/enumerator/lazy/uniq_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/lazy/with_index_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/lazy/zip_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/new_spec.rb106
-rw-r--r--spec/ruby/core/enumerator/next_spec.rb8
-rw-r--r--spec/ruby/core/enumerator/next_values_spec.rb10
-rw-r--r--spec/ruby/core/enumerator/peek_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/peek_values_spec.rb10
-rw-r--r--spec/ruby/core/enumerator/plus_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/produce_spec.rb44
-rw-r--r--spec/ruby/core/enumerator/product/each_spec.rb85
-rw-r--r--spec/ruby/core/enumerator/product/initialize_copy_spec.rb52
-rw-r--r--spec/ruby/core/enumerator/product/initialize_spec.rb31
-rw-r--r--spec/ruby/core/enumerator/product/inspect_spec.rb20
-rw-r--r--spec/ruby/core/enumerator/product/rewind_spec.rb62
-rw-r--r--spec/ruby/core/enumerator/product/size_spec.rb64
-rw-r--r--spec/ruby/core/enumerator/product_spec.rb91
-rw-r--r--spec/ruby/core/enumerator/rewind_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/shared/enum_for.rb57
-rw-r--r--spec/ruby/core/enumerator/shared/with_index.rb33
-rw-r--r--spec/ruby/core/enumerator/shared/with_object.rb42
-rw-r--r--spec/ruby/core/enumerator/size_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/to_enum_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/with_index_spec.rb27
-rw-r--r--spec/ruby/core/enumerator/with_object_spec.rb2
-rw-r--r--spec/ruby/core/enumerator/yielder/append_spec.rb35
-rw-r--r--spec/ruby/core/enumerator/yielder/initialize_spec.rb18
-rw-r--r--spec/ruby/core/enumerator/yielder/to_proc_spec.rb16
-rw-r--r--spec/ruby/core/enumerator/yielder/yield_spec.rb33
-rw-r--r--spec/ruby/core/env/assoc_spec.rb2
-rw-r--r--spec/ruby/core/env/clear_spec.rb2
-rw-r--r--spec/ruby/core/env/clone_spec.rb21
-rw-r--r--spec/ruby/core/env/delete_if_spec.rb10
-rw-r--r--spec/ruby/core/env/delete_spec.rb18
-rw-r--r--spec/ruby/core/env/dup_spec.rb9
-rw-r--r--spec/ruby/core/env/each_key_spec.rb8
-rw-r--r--spec/ruby/core/env/each_value_spec.rb8
-rw-r--r--spec/ruby/core/env/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/env/except_spec.rb44
-rw-r--r--spec/ruby/core/env/fetch_spec.rb6
-rw-r--r--spec/ruby/core/env/fetch_values_spec.rb51
-rw-r--r--spec/ruby/core/env/index_spec.rb14
-rw-r--r--spec/ruby/core/env/indexes_spec.rb1
-rw-r--r--spec/ruby/core/env/indices_spec.rb1
-rw-r--r--spec/ruby/core/env/inspect_spec.rb2
-rw-r--r--spec/ruby/core/env/keep_if_spec.rb10
-rw-r--r--spec/ruby/core/env/key_spec.rb32
-rw-r--r--spec/ruby/core/env/length_spec.rb2
-rw-r--r--spec/ruby/core/env/rassoc_spec.rb2
-rw-r--r--spec/ruby/core/env/reject_spec.rb14
-rw-r--r--spec/ruby/core/env/replace_spec.rb16
-rw-r--r--spec/ruby/core/env/shared/each.rb12
-rw-r--r--spec/ruby/core/env/shared/include.rb9
-rw-r--r--spec/ruby/core/env/shared/key.rb31
-rw-r--r--spec/ruby/core/env/shared/select.rb4
-rw-r--r--spec/ruby/core/env/shared/store.rb14
-rw-r--r--spec/ruby/core/env/shared/to_hash.rb4
-rw-r--r--spec/ruby/core/env/shared/update.rb24
-rw-r--r--spec/ruby/core/env/shared/value.rb7
-rw-r--r--spec/ruby/core/env/shift_spec.rb8
-rw-r--r--spec/ruby/core/env/size_spec.rb2
-rw-r--r--spec/ruby/core/env/slice_spec.rb12
-rw-r--r--spec/ruby/core/env/to_a_spec.rb5
-rw-r--r--spec/ruby/core/env/to_h_spec.rb20
-rw-r--r--spec/ruby/core/env/values_at_spec.rb2
-rw-r--r--spec/ruby/core/exception/backtrace_locations_spec.rb6
-rw-r--r--spec/ruby/core/exception/backtrace_spec.rb37
-rw-r--r--spec/ruby/core/exception/case_compare_spec.rb2
-rw-r--r--spec/ruby/core/exception/cause_spec.rb54
-rw-r--r--spec/ruby/core/exception/detailed_message_spec.rb50
-rw-r--r--spec/ruby/core/exception/dup_spec.rb14
-rw-r--r--spec/ruby/core/exception/equal_value_spec.rb18
-rw-r--r--spec/ruby/core/exception/errno_spec.rb12
-rw-r--r--spec/ruby/core/exception/exception_spec.rb4
-rw-r--r--spec/ruby/core/exception/exit_value_spec.rb2
-rw-r--r--spec/ruby/core/exception/fixtures/common.rb7
-rw-r--r--spec/ruby/core/exception/fixtures/syntax_error.rb3
-rw-r--r--spec/ruby/core/exception/frozen_error_spec.rb38
-rw-r--r--spec/ruby/core/exception/full_message_spec.rb144
-rw-r--r--spec/ruby/core/exception/interrupt_spec.rb2
-rw-r--r--spec/ruby/core/exception/io_error_spec.rb16
-rw-r--r--spec/ruby/core/exception/name_spec.rb12
-rw-r--r--spec/ruby/core/exception/no_method_error_spec.rb189
-rw-r--r--spec/ruby/core/exception/reason_spec.rb2
-rw-r--r--spec/ruby/core/exception/receiver_spec.rb16
-rw-r--r--spec/ruby/core/exception/result_spec.rb4
-rw-r--r--spec/ruby/core/exception/set_backtrace_spec.rb51
-rw-r--r--spec/ruby/core/exception/shared/new.rb4
-rw-r--r--spec/ruby/core/exception/shared/set_backtrace.rb64
-rw-r--r--spec/ruby/core/exception/signal_exception_spec.rb10
-rw-r--r--spec/ruby/core/exception/signm_spec.rb2
-rw-r--r--spec/ruby/core/exception/signo_spec.rb2
-rw-r--r--spec/ruby/core/exception/standard_error_spec.rb2
-rw-r--r--spec/ruby/core/exception/status_spec.rb2
-rw-r--r--spec/ruby/core/exception/success_spec.rb4
-rw-r--r--spec/ruby/core/exception/syntax_error_spec.rb25
-rw-r--r--spec/ruby/core/exception/system_call_error_spec.rb60
-rw-r--r--spec/ruby/core/exception/to_s_spec.rb2
-rw-r--r--spec/ruby/core/exception/top_level_spec.rb30
-rw-r--r--spec/ruby/core/false/dup_spec.rb2
-rw-r--r--spec/ruby/core/false/falseclass_spec.rb4
-rw-r--r--spec/ruby/core/false/singleton_method_spec.rb13
-rw-r--r--spec/ruby/core/false/to_s_spec.rb2
-rw-r--r--spec/ruby/core/fiber/alive_spec.rb44
-rw-r--r--spec/ruby/core/fiber/blocking_spec.rb86
-rw-r--r--spec/ruby/core/fiber/current_spec.rb50
-rw-r--r--spec/ruby/core/fiber/fixtures/classes.rb16
-rw-r--r--spec/ruby/core/fiber/fixtures/scheduler.rb35
-rw-r--r--spec/ruby/core/fiber/inspect_spec.rb35
-rw-r--r--spec/ruby/core/fiber/kill_spec.rb88
-rw-r--r--spec/ruby/core/fiber/new_spec.rb8
-rw-r--r--spec/ruby/core/fiber/raise_spec.rb92
-rw-r--r--spec/ruby/core/fiber/resume_spec.rb30
-rw-r--r--spec/ruby/core/fiber/scheduler_spec.rb8
-rw-r--r--spec/ruby/core/fiber/set_scheduler_spec.rb8
-rw-r--r--spec/ruby/core/fiber/shared/resume.rb58
-rw-r--r--spec/ruby/core/fiber/shared/scheduler.rb51
-rw-r--r--spec/ruby/core/fiber/storage_spec.rb203
-rw-r--r--spec/ruby/core/fiber/transfer_spec.rb84
-rw-r--r--spec/ruby/core/fiber/yield_spec.rb4
-rw-r--r--spec/ruby/core/file/absolute_path_spec.rb26
-rw-r--r--spec/ruby/core/file/atime_spec.rb9
-rw-r--r--spec/ruby/core/file/basename_spec.rb36
-rw-r--r--spec/ruby/core/file/birthtime_spec.rb68
-rw-r--r--spec/ruby/core/file/chmod_spec.rb12
-rw-r--r--spec/ruby/core/file/chown_spec.rb18
-rw-r--r--spec/ruby/core/file/constants/constants_spec.rb8
-rw-r--r--spec/ruby/core/file/ctime_spec.rb9
-rw-r--r--spec/ruby/core/file/dirname_spec.rb88
-rw-r--r--spec/ruby/core/file/empty_spec.rb6
-rw-r--r--spec/ruby/core/file/exist_spec.rb6
-rw-r--r--spec/ruby/core/file/expand_path_spec.rb22
-rw-r--r--spec/ruby/core/file/extname_spec.rb12
-rw-r--r--spec/ruby/core/file/flock_spec.rb36
-rw-r--r--spec/ruby/core/file/ftype_spec.rb8
-rw-r--r--spec/ruby/core/file/inspect_spec.rb2
-rw-r--r--spec/ruby/core/file/join_spec.rb14
-rw-r--r--spec/ruby/core/file/lchmod_spec.rb2
-rw-r--r--spec/ruby/core/file/link_spec.rb12
-rw-r--r--spec/ruby/core/file/lutime_spec.rb9
-rw-r--r--spec/ruby/core/file/mkfifo_spec.rb4
-rw-r--r--spec/ruby/core/file/mtime_spec.rb9
-rw-r--r--spec/ruby/core/file/new_spec.rb74
-rw-r--r--spec/ruby/core/file/open_spec.rb146
-rw-r--r--spec/ruby/core/file/path_spec.rb41
-rw-r--r--spec/ruby/core/file/readlink_spec.rb6
-rw-r--r--spec/ruby/core/file/realdirpath_spec.rb6
-rw-r--r--spec/ruby/core/file/realpath_spec.rb10
-rw-r--r--spec/ruby/core/file/rename_spec.rb8
-rw-r--r--spec/ruby/core/file/setuid_spec.rb4
-rw-r--r--spec/ruby/core/file/shared/fnmatch.rb75
-rw-r--r--spec/ruby/core/file/shared/open.rb2
-rw-r--r--spec/ruby/core/file/shared/path.rb18
-rw-r--r--spec/ruby/core/file/shared/read.rb4
-rw-r--r--spec/ruby/core/file/shared/stat.rb6
-rw-r--r--spec/ruby/core/file/shared/unlink.rb4
-rw-r--r--spec/ruby/core/file/shared/update_time.rb105
-rw-r--r--spec/ruby/core/file/size_spec.rb6
-rw-r--r--spec/ruby/core/file/socket_spec.rb32
-rw-r--r--spec/ruby/core/file/split_spec.rb6
-rw-r--r--spec/ruby/core/file/stat/atime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/birthtime_spec.rb36
-rw-r--r--spec/ruby/core/file/stat/blocks_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/ctime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/dev_major_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/dev_minor_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/dev_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/ftype_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/ino_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/mtime_spec.rb2
-rw-r--r--spec/ruby/core/file/stat/new_spec.rb4
-rw-r--r--spec/ruby/core/file/stat/rdev_major_spec.rb17
-rw-r--r--spec/ruby/core/file/stat/rdev_minor_spec.rb17
-rw-r--r--spec/ruby/core/file/stat/rdev_spec.rb2
-rw-r--r--spec/ruby/core/file/stat_spec.rb12
-rw-r--r--spec/ruby/core/file/symlink_spec.rb12
-rw-r--r--spec/ruby/core/file/truncate_spec.rb24
-rw-r--r--spec/ruby/core/file/umask_spec.rb8
-rw-r--r--spec/ruby/core/file/utime_spec.rb98
-rw-r--r--spec/ruby/core/file/world_readable_spec.rb2
-rw-r--r--spec/ruby/core/file/world_writable_spec.rb2
-rw-r--r--spec/ruby/core/file/zero_spec.rb6
-rw-r--r--spec/ruby/core/filetest/exist_spec.rb6
-rw-r--r--spec/ruby/core/filetest/grpowned_spec.rb2
-rw-r--r--spec/ruby/core/filetest/socket_spec.rb4
-rw-r--r--spec/ruby/core/filetest/zero_spec.rb6
-rw-r--r--spec/ruby/core/float/ceil_spec.rb31
-rw-r--r--spec/ruby/core/float/comparison_spec.rb14
-rw-r--r--spec/ruby/core/float/constants_spec.rb2
-rw-r--r--spec/ruby/core/float/denominator_spec.rb2
-rw-r--r--spec/ruby/core/float/divide_spec.rb20
-rw-r--r--spec/ruby/core/float/divmod_spec.rb22
-rw-r--r--spec/ruby/core/float/dup_spec.rb2
-rw-r--r--spec/ruby/core/float/eql_spec.rb8
-rw-r--r--spec/ruby/core/float/float_spec.rb4
-rw-r--r--spec/ruby/core/float/floor_spec.rb31
-rw-r--r--spec/ruby/core/float/gt_spec.rb4
-rw-r--r--spec/ruby/core/float/gte_spec.rb4
-rw-r--r--spec/ruby/core/float/lt_spec.rb4
-rw-r--r--spec/ruby/core/float/lte_spec.rb4
-rw-r--r--spec/ruby/core/float/multiply_spec.rb4
-rw-r--r--spec/ruby/core/float/negative_spec.rb10
-rw-r--r--spec/ruby/core/float/next_float_spec.rb2
-rw-r--r--spec/ruby/core/float/numerator_spec.rb4
-rw-r--r--spec/ruby/core/float/positive_spec.rb10
-rw-r--r--spec/ruby/core/float/prev_float_spec.rb2
-rw-r--r--spec/ruby/core/float/rationalize_spec.rb8
-rw-r--r--spec/ruby/core/float/round_spec.rb232
-rw-r--r--spec/ruby/core/float/shared/abs.rb2
-rw-r--r--spec/ruby/core/float/shared/arg.rb4
-rw-r--r--spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb2
-rw-r--r--spec/ruby/core/float/shared/comparison_exception_in_coerce.rb2
-rw-r--r--spec/ruby/core/float/shared/modulo.rb12
-rw-r--r--spec/ruby/core/float/shared/quo.rb8
-rw-r--r--spec/ruby/core/float/shared/to_i.rb14
-rw-r--r--spec/ruby/core/float/shared/to_s.rb4
-rw-r--r--spec/ruby/core/float/truncate_spec.rb10
-rw-r--r--spec/ruby/core/float/uplus_spec.rb2
-rw-r--r--spec/ruby/core/gc/auto_compact_spec.rb36
-rw-r--r--spec/ruby/core/gc/config_spec.rb97
-rw-r--r--spec/ruby/core/gc/count_spec.rb2
-rw-r--r--spec/ruby/core/gc/measure_total_time_spec.rb24
-rw-r--r--spec/ruby/core/gc/profiler/enabled_spec.rb4
-rw-r--r--spec/ruby/core/gc/profiler/result_spec.rb2
-rw-r--r--spec/ruby/core/gc/profiler/total_time_spec.rb2
-rw-r--r--spec/ruby/core/gc/stat_spec.rb28
-rw-r--r--spec/ruby/core/gc/stress_spec.rb8
-rw-r--r--spec/ruby/core/gc/total_time_spec.rb18
-rw-r--r--spec/ruby/core/hash/allocate_spec.rb2
-rw-r--r--spec/ruby/core/hash/assoc_spec.rb14
-rw-r--r--spec/ruby/core/hash/clear_spec.rb6
-rw-r--r--spec/ruby/core/hash/clone_spec.rb2
-rw-r--r--spec/ruby/core/hash/compact_spec.rb30
-rw-r--r--spec/ruby/core/hash/compare_by_identity_spec.rb47
-rw-r--r--spec/ruby/core/hash/constructor_spec.rb53
-rw-r--r--spec/ruby/core/hash/deconstruct_keys_spec.rb4
-rw-r--r--spec/ruby/core/hash/default_proc_spec.rb20
-rw-r--r--spec/ruby/core/hash/default_spec.rb4
-rw-r--r--spec/ruby/core/hash/delete_if_spec.rb8
-rw-r--r--spec/ruby/core/hash/delete_spec.rb20
-rw-r--r--spec/ruby/core/hash/dig_spec.rb18
-rw-r--r--spec/ruby/core/hash/each_key_spec.rb2
-rw-r--r--spec/ruby/core/hash/each_pair_spec.rb106
-rw-r--r--spec/ruby/core/hash/each_spec.rb10
-rw-r--r--spec/ruby/core/hash/each_value_spec.rb2
-rw-r--r--spec/ruby/core/hash/element_reference_spec.rb6
-rw-r--r--spec/ruby/core/hash/element_set_spec.rb118
-rw-r--r--spec/ruby/core/hash/equal_value_spec.rb2
-rw-r--r--spec/ruby/core/hash/except_spec.rb60
-rw-r--r--spec/ruby/core/hash/fetch_spec.rb8
-rw-r--r--spec/ruby/core/hash/fetch_values_spec.rb2
-rw-r--r--spec/ruby/core/hash/filter_spec.rb9
-rw-r--r--spec/ruby/core/hash/flatten_spec.rb4
-rw-r--r--spec/ruby/core/hash/gt_spec.rb2
-rw-r--r--spec/ruby/core/hash/gte_spec.rb2
-rw-r--r--spec/ruby/core/hash/has_key_spec.rb6
-rw-r--r--spec/ruby/core/hash/has_value_spec.rb15
-rw-r--r--spec/ruby/core/hash/hash_spec.rb10
-rw-r--r--spec/ruby/core/hash/include_spec.rb39
-rw-r--r--spec/ruby/core/hash/index_spec.rb9
-rw-r--r--spec/ruby/core/hash/initialize_spec.rb12
-rw-r--r--spec/ruby/core/hash/inspect_spec.rb122
-rw-r--r--spec/ruby/core/hash/invert_spec.rb21
-rw-r--r--spec/ruby/core/hash/keep_if_spec.rb10
-rw-r--r--spec/ruby/core/hash/key_spec.rb30
-rw-r--r--spec/ruby/core/hash/keys_spec.rb4
-rw-r--r--spec/ruby/core/hash/length_spec.rb6
-rw-r--r--spec/ruby/core/hash/lt_spec.rb2
-rw-r--r--spec/ruby/core/hash/lte_spec.rb2
-rw-r--r--spec/ruby/core/hash/member_spec.rb6
-rw-r--r--spec/ruby/core/hash/merge_spec.rb39
-rw-r--r--spec/ruby/core/hash/new_spec.rb40
-rw-r--r--spec/ruby/core/hash/rassoc_spec.rb10
-rw-r--r--spec/ruby/core/hash/rehash_spec.rb36
-rw-r--r--spec/ruby/core/hash/reject_spec.rb31
-rw-r--r--spec/ruby/core/hash/replace_spec.rb76
-rw-r--r--spec/ruby/core/hash/ruby2_keywords_hash_spec.rb26
-rw-r--r--spec/ruby/core/hash/select_spec.rb108
-rw-r--r--spec/ruby/core/hash/shared/comparison.rb10
-rw-r--r--spec/ruby/core/hash/shared/each.rb124
-rw-r--r--spec/ruby/core/hash/shared/eql.rb88
-rw-r--r--spec/ruby/core/hash/shared/equal.rb90
-rw-r--r--spec/ruby/core/hash/shared/greater_than.rb6
-rw-r--r--spec/ruby/core/hash/shared/index.rb37
-rw-r--r--spec/ruby/core/hash/shared/iteration.rb6
-rw-r--r--spec/ruby/core/hash/shared/key.rb38
-rw-r--r--spec/ruby/core/hash/shared/length.rb12
-rw-r--r--spec/ruby/core/hash/shared/less_than.rb6
-rw-r--r--spec/ruby/core/hash/shared/replace.rb51
-rw-r--r--spec/ruby/core/hash/shared/select.rb91
-rw-r--r--spec/ruby/core/hash/shared/store.rb115
-rw-r--r--spec/ruby/core/hash/shared/to_s.rb89
-rw-r--r--spec/ruby/core/hash/shared/update.rb76
-rw-r--r--spec/ruby/core/hash/shared/value.rb14
-rw-r--r--spec/ruby/core/hash/shared/values_at.rb9
-rw-r--r--spec/ruby/core/hash/shift_spec.rb47
-rw-r--r--spec/ruby/core/hash/size_spec.rb13
-rw-r--r--spec/ruby/core/hash/slice_spec.rb25
-rw-r--r--spec/ruby/core/hash/store_spec.rb6
-rw-r--r--spec/ruby/core/hash/to_a_spec.rb14
-rw-r--r--spec/ruby/core/hash/to_h_spec.rb50
-rw-r--r--spec/ruby/core/hash/to_hash_spec.rb4
-rw-r--r--spec/ruby/core/hash/to_proc_spec.rb32
-rw-r--r--spec/ruby/core/hash/to_s_spec.rb6
-rw-r--r--spec/ruby/core/hash/transform_keys_spec.rb93
-rw-r--r--spec/ruby/core/hash/transform_values_spec.rb39
-rw-r--r--spec/ruby/core/hash/try_convert_spec.rb16
-rw-r--r--spec/ruby/core/hash/update_spec.rb76
-rw-r--r--spec/ruby/core/hash/value_spec.rb6
-rw-r--r--spec/ruby/core/hash/values_at_spec.rb10
-rw-r--r--spec/ruby/core/hash/values_spec.rb2
-rw-r--r--spec/ruby/core/integer/allbits_spec.rb6
-rw-r--r--spec/ruby/core/integer/anybits_spec.rb6
-rw-r--r--spec/ruby/core/integer/bit_and_spec.rb10
-rw-r--r--spec/ruby/core/integer/bit_or_spec.rb16
-rw-r--r--spec/ruby/core/integer/bit_xor_spec.rb14
-rw-r--r--spec/ruby/core/integer/ceil_spec.rb12
-rw-r--r--spec/ruby/core/integer/ceildiv_spec.rb20
-rw-r--r--spec/ruby/core/integer/chr_spec.rb62
-rw-r--r--spec/ruby/core/integer/coerce_spec.rb41
-rw-r--r--spec/ruby/core/integer/comparison_spec.rb14
-rw-r--r--spec/ruby/core/integer/constants_spec.rb36
-rw-r--r--spec/ruby/core/integer/digits_spec.rb6
-rw-r--r--spec/ruby/core/integer/div_spec.rb48
-rw-r--r--spec/ruby/core/integer/divide_spec.rb53
-rw-r--r--spec/ruby/core/integer/divmod_spec.rb34
-rw-r--r--spec/ruby/core/integer/downto_spec.rb8
-rw-r--r--spec/ruby/core/integer/dup_spec.rb4
-rw-r--r--spec/ruby/core/integer/element_reference_spec.rb14
-rw-r--r--spec/ruby/core/integer/eql_spec.rb25
-rw-r--r--spec/ruby/core/integer/even_spec.rb26
-rw-r--r--spec/ruby/core/integer/fdiv_spec.rb8
-rw-r--r--spec/ruby/core/integer/fixtures/classes.rb10
-rw-r--r--spec/ruby/core/integer/floor_spec.rb12
-rw-r--r--spec/ruby/core/integer/gcd_spec.rb16
-rw-r--r--spec/ruby/core/integer/gcdlcm_spec.rb16
-rw-r--r--spec/ruby/core/integer/gt_spec.rb13
-rw-r--r--spec/ruby/core/integer/gte_spec.rb13
-rw-r--r--spec/ruby/core/integer/integer_spec.rb4
-rw-r--r--spec/ruby/core/integer/lcm_spec.rb16
-rw-r--r--spec/ruby/core/integer/left_shift_spec.rb34
-rw-r--r--spec/ruby/core/integer/lt_spec.rb13
-rw-r--r--spec/ruby/core/integer/lte_spec.rb13
-rw-r--r--spec/ruby/core/integer/minus_spec.rb29
-rw-r--r--spec/ruby/core/integer/multiply_spec.rb12
-rw-r--r--spec/ruby/core/integer/nobits_spec.rb6
-rw-r--r--spec/ruby/core/integer/odd_spec.rb26
-rw-r--r--spec/ruby/core/integer/ord_spec.rb16
-rw-r--r--spec/ruby/core/integer/plus_spec.rb29
-rw-r--r--spec/ruby/core/integer/pow_spec.rb28
-rw-r--r--spec/ruby/core/integer/pred_spec.rb10
-rw-r--r--spec/ruby/core/integer/rationalize_spec.rb6
-rw-r--r--spec/ruby/core/integer/remainder_spec.rb18
-rw-r--r--spec/ruby/core/integer/right_shift_spec.rb34
-rw-r--r--spec/ruby/core/integer/round_spec.rb66
-rw-r--r--spec/ruby/core/integer/shared/arithmetic_coerce.rb22
-rw-r--r--spec/ruby/core/integer/shared/comparison_coerce.rb2
-rw-r--r--spec/ruby/core/integer/shared/equal.rb5
-rw-r--r--spec/ruby/core/integer/shared/exponent.rb134
-rw-r--r--spec/ruby/core/integer/shared/integer_ceil_precision.rb54
-rw-r--r--spec/ruby/core/integer/shared/integer_floor_precision.rb42
-rw-r--r--spec/ruby/core/integer/shared/integer_rounding.rb6
-rw-r--r--spec/ruby/core/integer/shared/modulo.rb78
-rw-r--r--spec/ruby/core/integer/shared/to_i.rb8
-rw-r--r--spec/ruby/core/integer/size_spec.rb4
-rw-r--r--spec/ruby/core/integer/sqrt_spec.rb6
-rw-r--r--spec/ruby/core/integer/to_f_spec.rb6
-rw-r--r--spec/ruby/core/integer/to_r_spec.rb8
-rw-r--r--spec/ruby/core/integer/to_s_spec.rb24
-rw-r--r--spec/ruby/core/integer/truncate_spec.rb12
-rw-r--r--spec/ruby/core/integer/try_convert_spec.rb68
-rw-r--r--spec/ruby/core/integer/upto_spec.rb8
-rw-r--r--spec/ruby/core/integer/zero_spec.rb12
-rw-r--r--spec/ruby/core/io/advise_spec.rb28
-rw-r--r--spec/ruby/core/io/autoclose_spec.rb77
-rw-r--r--spec/ruby/core/io/binmode_spec.rb10
-rw-r--r--spec/ruby/core/io/binread_spec.rb14
-rw-r--r--spec/ruby/core/io/buffer/and_spec.rb62
-rw-r--r--spec/ruby/core/io/buffer/bit_count_spec.rb64
-rw-r--r--spec/ruby/core/io/buffer/empty_spec.rb27
-rw-r--r--spec/ruby/core/io/buffer/external_spec.rb23
-rw-r--r--spec/ruby/core/io/buffer/for_spec.rb95
-rw-r--r--spec/ruby/core/io/buffer/free_spec.rb102
-rw-r--r--spec/ruby/core/io/buffer/initialize_spec.rb119
-rw-r--r--spec/ruby/core/io/buffer/internal_spec.rb23
-rw-r--r--spec/ruby/core/io/buffer/locked_spec.rb75
-rw-r--r--spec/ruby/core/io/buffer/map_spec.rb343
-rw-r--r--spec/ruby/core/io/buffer/mapped_spec.rb23
-rw-r--r--spec/ruby/core/io/buffer/not_spec.rb37
-rw-r--r--spec/ruby/core/io/buffer/null_spec.rb27
-rw-r--r--spec/ruby/core/io/buffer/or_spec.rb62
-rw-r--r--spec/ruby/core/io/buffer/private_spec.rb23
-rw-r--r--spec/ruby/core/io/buffer/readonly_spec.rb28
-rw-r--r--spec/ruby/core/io/buffer/resize_spec.rb151
-rw-r--r--spec/ruby/core/io/buffer/shared/null_and_empty.rb57
-rw-r--r--spec/ruby/core/io/buffer/shared_spec.rb33
-rw-r--r--spec/ruby/core/io/buffer/string_spec.rb62
-rw-r--r--spec/ruby/core/io/buffer/transfer_spec.rb117
-rw-r--r--spec/ruby/core/io/buffer/valid_spec.rb99
-rw-r--r--spec/ruby/core/io/buffer/xor_spec.rb62
-rw-r--r--spec/ruby/core/io/bytes_spec.rb47
-rw-r--r--spec/ruby/core/io/chars_spec.rb30
-rw-r--r--spec/ruby/core/io/close_on_exec_spec.rb4
-rw-r--r--spec/ruby/core/io/close_read_spec.rb13
-rw-r--r--spec/ruby/core/io/close_spec.rb12
-rw-r--r--spec/ruby/core/io/close_write_spec.rb24
-rw-r--r--spec/ruby/core/io/closed_spec.rb4
-rw-r--r--spec/ruby/core/io/codepoints_spec.rb38
-rw-r--r--spec/ruby/core/io/copy_stream_spec.rb53
-rw-r--r--spec/ruby/core/io/dup_spec.rb36
-rw-r--r--spec/ruby/core/io/each_byte_spec.rb6
-rw-r--r--spec/ruby/core/io/each_codepoint_spec.rb4
-rw-r--r--spec/ruby/core/io/eof_spec.rb8
-rw-r--r--spec/ruby/core/io/external_encoding_spec.rb54
-rw-r--r--spec/ruby/core/io/fcntl_spec.rb2
-rw-r--r--spec/ruby/core/io/fileno_spec.rb2
-rw-r--r--spec/ruby/core/io/flush_spec.rb6
-rw-r--r--spec/ruby/core/io/foreach_spec.rb55
-rw-r--r--spec/ruby/core/io/fsync_spec.rb2
-rw-r--r--spec/ruby/core/io/getbyte_spec.rb18
-rw-r--r--spec/ruby/core/io/getc_spec.rb6
-rw-r--r--spec/ruby/core/io/gets_spec.rb79
-rw-r--r--spec/ruby/core/io/initialize_spec.rb26
-rw-r--r--spec/ruby/core/io/inspect_spec.rb4
-rw-r--r--spec/ruby/core/io/internal_encoding_spec.rb36
-rw-r--r--spec/ruby/core/io/ioctl_spec.rb8
-rw-r--r--spec/ruby/core/io/lineno_spec.rb24
-rw-r--r--spec/ruby/core/io/lines_spec.rb46
-rw-r--r--spec/ruby/core/io/new_spec.rb8
-rw-r--r--spec/ruby/core/io/nonblock_spec.rb46
-rw-r--r--spec/ruby/core/io/open_spec.rb19
-rw-r--r--spec/ruby/core/io/output_spec.rb2
-rw-r--r--spec/ruby/core/io/path_spec.rb14
-rw-r--r--spec/ruby/core/io/pid_spec.rb4
-rw-r--r--spec/ruby/core/io/pipe_spec.rb32
-rw-r--r--spec/ruby/core/io/popen_spec.rb34
-rw-r--r--spec/ruby/core/io/pread_spec.rb162
-rw-r--r--spec/ruby/core/io/print_spec.rb4
-rw-r--r--spec/ruby/core/io/printf_spec.rb2
-rw-r--r--spec/ruby/core/io/puts_spec.rb6
-rw-r--r--spec/ruby/core/io/pwrite_spec.rb86
-rw-r--r--spec/ruby/core/io/read_nonblock_spec.rb30
-rw-r--r--spec/ruby/core/io/read_spec.rb250
-rw-r--r--spec/ruby/core/io/readbyte_spec.rb2
-rw-r--r--spec/ruby/core/io/readchar_spec.rb10
-rw-r--r--spec/ruby/core/io/readline_spec.rb18
-rw-r--r--spec/ruby/core/io/readlines_spec.rb89
-rw-r--r--spec/ruby/core/io/readpartial_spec.rb38
-rw-r--r--spec/ruby/core/io/reopen_spec.rb26
-rw-r--r--spec/ruby/core/io/rewind_spec.rb2
-rw-r--r--spec/ruby/core/io/seek_spec.rb2
-rw-r--r--spec/ruby/core/io/select_spec.rb110
-rw-r--r--spec/ruby/core/io/set_encoding_by_bom_spec.rb18
-rw-r--r--spec/ruby/core/io/set_encoding_spec.rb42
-rw-r--r--spec/ruby/core/io/shared/binwrite.rb14
-rw-r--r--spec/ruby/core/io/shared/chars.rb10
-rw-r--r--spec/ruby/core/io/shared/codepoints.rb6
-rw-r--r--spec/ruby/core/io/shared/each.rb54
-rw-r--r--spec/ruby/core/io/shared/gets_ascii.rb2
-rw-r--r--spec/ruby/core/io/shared/new.rb124
-rw-r--r--spec/ruby/core/io/shared/pos.rb8
-rw-r--r--spec/ruby/core/io/shared/readlines.rb48
-rw-r--r--spec/ruby/core/io/shared/tty.rb2
-rw-r--r--spec/ruby/core/io/shared/write.rb61
-rw-r--r--spec/ruby/core/io/stat_spec.rb9
-rw-r--r--spec/ruby/core/io/sync_spec.rb4
-rw-r--r--spec/ruby/core/io/sysopen_spec.rb16
-rw-r--r--spec/ruby/core/io/sysread_spec.rb41
-rw-r--r--spec/ruby/core/io/sysseek_spec.rb4
-rw-r--r--spec/ruby/core/io/syswrite_spec.rb1
-rw-r--r--spec/ruby/core/io/to_i_spec.rb2
-rw-r--r--spec/ruby/core/io/to_io_spec.rb4
-rw-r--r--spec/ruby/core/io/try_convert_spec.rb12
-rw-r--r--spec/ruby/core/io/ungetbyte_spec.rb12
-rw-r--r--spec/ruby/core/io/ungetc_spec.rb28
-rw-r--r--spec/ruby/core/io/write_nonblock_spec.rb11
-rw-r--r--spec/ruby/core/io/write_spec.rb87
-rw-r--r--spec/ruby/core/kernel/Array_spec.rb6
-rw-r--r--spec/ruby/core/kernel/Complex_spec.rb64
-rw-r--r--spec/ruby/core/kernel/Float_spec.rb240
-rw-r--r--spec/ruby/core/kernel/Hash_spec.rb6
-rw-r--r--spec/ruby/core/kernel/Integer_spec.rb255
-rw-r--r--spec/ruby/core/kernel/Rational_spec.rb234
-rw-r--r--spec/ruby/core/kernel/String_spec.rb16
-rw-r--r--spec/ruby/core/kernel/__dir___spec.rb16
-rw-r--r--spec/ruby/core/kernel/abort_spec.rb2
-rw-r--r--spec/ruby/core/kernel/at_exit_spec.rb4
-rw-r--r--spec/ruby/core/kernel/autoload_relative_spec.rb114
-rw-r--r--spec/ruby/core/kernel/autoload_spec.rb19
-rw-r--r--spec/ruby/core/kernel/backtick_spec.rb14
-rw-r--r--spec/ruby/core/kernel/binding_spec.rb4
-rw-r--r--spec/ruby/core/kernel/block_given_spec.rb7
-rw-r--r--spec/ruby/core/kernel/caller_locations_spec.rb47
-rw-r--r--spec/ruby/core/kernel/caller_spec.rb83
-rw-r--r--spec/ruby/core/kernel/case_compare_spec.rb14
-rw-r--r--spec/ruby/core/kernel/catch_spec.rb10
-rw-r--r--spec/ruby/core/kernel/chomp_spec.rb2
-rw-r--r--spec/ruby/core/kernel/chop_spec.rb2
-rw-r--r--spec/ruby/core/kernel/class_spec.rb22
-rw-r--r--spec/ruby/core/kernel/clone_spec.rb96
-rw-r--r--spec/ruby/core/kernel/comparison_spec.rb6
-rw-r--r--spec/ruby/core/kernel/define_singleton_method_spec.rb24
-rw-r--r--spec/ruby/core/kernel/dup_spec.rb8
-rw-r--r--spec/ruby/core/kernel/eql_spec.rb2
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb225
-rw-r--r--spec/ruby/core/kernel/exec_spec.rb6
-rw-r--r--spec/ruby/core/kernel/exit_spec.rb4
-rw-r--r--spec/ruby/core/kernel/extend_spec.rb20
-rw-r--r--spec/ruby/core/kernel/fail_spec.rb10
-rw-r--r--spec/ruby/core/kernel/fixtures/autoload_relative_b.rb7
-rw-r--r--spec/ruby/core/kernel/fixtures/autoload_relative_d.rb5
-rw-r--r--spec/ruby/core/kernel/fixtures/classes.rb73
-rw-r--r--spec/ruby/core/kernel/fork_spec.rb2
-rw-r--r--spec/ruby/core/kernel/format_spec.rb34
-rw-r--r--spec/ruby/core/kernel/freeze_spec.rb28
-rw-r--r--spec/ruby/core/kernel/frozen_spec.rb22
-rw-r--r--spec/ruby/core/kernel/gets_spec.rb2
-rw-r--r--spec/ruby/core/kernel/global_variables_spec.rb6
-rw-r--r--spec/ruby/core/kernel/gsub_spec.rb8
-rw-r--r--spec/ruby/core/kernel/initialize_clone_spec.rb12
-rw-r--r--spec/ruby/core/kernel/initialize_copy_spec.rb21
-rw-r--r--spec/ruby/core/kernel/initialize_dup_spec.rb2
-rw-r--r--spec/ruby/core/kernel/inspect_spec.rb76
-rw-r--r--spec/ruby/core/kernel/instance_of_spec.rb6
-rw-r--r--spec/ruby/core/kernel/instance_variable_defined_spec.rb12
-rw-r--r--spec/ruby/core/kernel/instance_variable_get_spec.rb28
-rw-r--r--spec/ruby/core/kernel/instance_variable_set_spec.rb28
-rw-r--r--spec/ruby/core/kernel/instance_variables_spec.rb2
-rw-r--r--spec/ruby/core/kernel/is_a_spec.rb2
-rw-r--r--spec/ruby/core/kernel/iterator_spec.rb14
-rw-r--r--spec/ruby/core/kernel/itself_spec.rb2
-rw-r--r--spec/ruby/core/kernel/kind_of_spec.rb2
-rw-r--r--spec/ruby/core/kernel/lambda_spec.rb82
-rw-r--r--spec/ruby/core/kernel/load_spec.rb2
-rw-r--r--spec/ruby/core/kernel/local_variables_spec.rb11
-rw-r--r--spec/ruby/core/kernel/loop_spec.rb6
-rw-r--r--spec/ruby/core/kernel/match_spec.rb27
-rw-r--r--spec/ruby/core/kernel/method_spec.rb37
-rw-r--r--spec/ruby/core/kernel/methods_spec.rb34
-rw-r--r--spec/ruby/core/kernel/not_match_spec.rb4
-rw-r--r--spec/ruby/core/kernel/open_spec.rb138
-rw-r--r--spec/ruby/core/kernel/p_spec.rb2
-rw-r--r--spec/ruby/core/kernel/print_spec.rb2
-rw-r--r--spec/ruby/core/kernel/printf_spec.rb9
-rw-r--r--spec/ruby/core/kernel/private_methods_spec.rb10
-rw-r--r--spec/ruby/core/kernel/proc_spec.rb30
-rw-r--r--spec/ruby/core/kernel/protected_methods_spec.rb10
-rw-r--r--spec/ruby/core/kernel/public_method_spec.rb6
-rw-r--r--spec/ruby/core/kernel/public_methods_spec.rb19
-rw-r--r--spec/ruby/core/kernel/public_send_spec.rb16
-rw-r--r--spec/ruby/core/kernel/putc_spec.rb2
-rw-r--r--spec/ruby/core/kernel/puts_spec.rb2
-rw-r--r--spec/ruby/core/kernel/raise_spec.rb201
-rw-r--r--spec/ruby/core/kernel/rand_spec.rb94
-rw-r--r--spec/ruby/core/kernel/readline_spec.rb2
-rw-r--r--spec/ruby/core/kernel/readlines_spec.rb2
-rw-r--r--spec/ruby/core/kernel/remove_instance_variable_spec.rb20
-rw-r--r--spec/ruby/core/kernel/require_relative_spec.rb140
-rw-r--r--spec/ruby/core/kernel/require_spec.rb35
-rw-r--r--spec/ruby/core/kernel/respond_to_missing_spec.rb20
-rw-r--r--spec/ruby/core/kernel/respond_to_spec.rb33
-rw-r--r--spec/ruby/core/kernel/select_spec.rb6
-rw-r--r--spec/ruby/core/kernel/set_trace_func_spec.rb2
-rw-r--r--spec/ruby/core/kernel/shared/dup_clone.rb8
-rw-r--r--spec/ruby/core/kernel/shared/kind_of.rb8
-rw-r--r--spec/ruby/core/kernel/shared/lambda.rb2
-rw-r--r--spec/ruby/core/kernel/shared/load.rb128
-rw-r--r--spec/ruby/core/kernel/shared/method.rb12
-rw-r--r--spec/ruby/core/kernel/shared/require.rb312
-rw-r--r--spec/ruby/core/kernel/shared/sprintf.rb125
-rw-r--r--spec/ruby/core/kernel/shared/sprintf_encoding.rb20
-rw-r--r--spec/ruby/core/kernel/shared/then.rb12
-rw-r--r--spec/ruby/core/kernel/singleton_class_spec.rb43
-rw-r--r--spec/ruby/core/kernel/singleton_method_spec.rb52
-rw-r--r--spec/ruby/core/kernel/singleton_methods_spec.rb65
-rw-r--r--spec/ruby/core/kernel/sleep_spec.rb79
-rw-r--r--spec/ruby/core/kernel/spawn_spec.rb2
-rw-r--r--spec/ruby/core/kernel/sprintf_spec.rb48
-rw-r--r--spec/ruby/core/kernel/srand_spec.rb8
-rw-r--r--spec/ruby/core/kernel/sub_spec.rb4
-rw-r--r--spec/ruby/core/kernel/syscall_spec.rb2
-rw-r--r--spec/ruby/core/kernel/system_spec.rb35
-rw-r--r--spec/ruby/core/kernel/taint_spec.rb15
-rw-r--r--spec/ruby/core/kernel/tainted_spec.rb17
-rw-r--r--spec/ruby/core/kernel/tap_spec.rb4
-rw-r--r--spec/ruby/core/kernel/test_spec.rb16
-rw-r--r--spec/ruby/core/kernel/throw_spec.rb14
-rw-r--r--spec/ruby/core/kernel/trace_var_spec.rb4
-rw-r--r--spec/ruby/core/kernel/trap_spec.rb2
-rw-r--r--spec/ruby/core/kernel/trust_spec.rb16
-rw-r--r--spec/ruby/core/kernel/untaint_spec.rb16
-rw-r--r--spec/ruby/core/kernel/untrace_var_spec.rb2
-rw-r--r--spec/ruby/core/kernel/untrust_spec.rb15
-rw-r--r--spec/ruby/core/kernel/untrusted_spec.rb16
-rw-r--r--spec/ruby/core/kernel/warn_spec.rb163
-rw-r--r--spec/ruby/core/main/define_method_spec.rb6
-rw-r--r--spec/ruby/core/main/include_spec.rb4
-rw-r--r--spec/ruby/core/main/private_spec.rb32
-rw-r--r--spec/ruby/core/main/public_spec.rb32
-rw-r--r--spec/ruby/core/main/ruby2_keywords_spec.rb2
-rw-r--r--spec/ruby/core/main/using_spec.rb22
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb552
-rw-r--r--spec/ruby/core/marshal/fixtures/marshal_data.rb155
-rw-r--r--spec/ruby/core/marshal/fixtures/marshal_multibyte_data.rb12
-rw-r--r--spec/ruby/core/marshal/float_spec.rb2
-rw-r--r--spec/ruby/core/marshal/shared/load.rb712
-rw-r--r--spec/ruby/core/matchdata/allocate_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/begin_spec.rb30
-rw-r--r--spec/ruby/core/matchdata/bytebegin_spec.rb132
-rw-r--r--spec/ruby/core/matchdata/byteend_spec.rb104
-rw-r--r--spec/ruby/core/matchdata/byteoffset_spec.rb93
-rw-r--r--spec/ruby/core/matchdata/captures_spec.rb13
-rw-r--r--spec/ruby/core/matchdata/deconstruct_keys_spec.rb78
-rw-r--r--spec/ruby/core/matchdata/deconstruct_spec.rb6
-rw-r--r--spec/ruby/core/matchdata/element_reference_spec.rb24
-rw-r--r--spec/ruby/core/matchdata/end_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/inspect_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/integer_at_spec.rb38
-rw-r--r--spec/ruby/core/matchdata/match_length_spec.rb46
-rw-r--r--spec/ruby/core/matchdata/match_spec.rb46
-rw-r--r--spec/ruby/core/matchdata/named_captures_spec.rb10
-rw-r--r--spec/ruby/core/matchdata/names_spec.rb4
-rw-r--r--spec/ruby/core/matchdata/offset_spec.rb106
-rw-r--r--spec/ruby/core/matchdata/post_match_spec.rb16
-rw-r--r--spec/ruby/core/matchdata/pre_match_spec.rb16
-rw-r--r--spec/ruby/core/matchdata/regexp_spec.rb2
-rw-r--r--spec/ruby/core/matchdata/shared/captures.rb13
-rw-r--r--spec/ruby/core/matchdata/shared/eql.rb8
-rw-r--r--spec/ruby/core/matchdata/string_spec.rb7
-rw-r--r--spec/ruby/core/matchdata/to_a_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/to_s_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/values_at_spec.rb8
-rw-r--r--spec/ruby/core/math/acos_spec.rb14
-rw-r--r--spec/ruby/core/math/acosh_spec.rb14
-rw-r--r--spec/ruby/core/math/asin_spec.rb12
-rw-r--r--spec/ruby/core/math/asinh_spec.rb8
-rw-r--r--spec/ruby/core/math/atan2_spec.rb14
-rw-r--r--spec/ruby/core/math/atan_spec.rb8
-rw-r--r--spec/ruby/core/math/atanh_spec.rb4
-rw-r--r--spec/ruby/core/math/cbrt_spec.rb6
-rw-r--r--spec/ruby/core/math/cos_spec.rb32
-rw-r--r--spec/ruby/core/math/cosh_spec.rb8
-rw-r--r--spec/ruby/core/math/erf_spec.rb8
-rw-r--r--spec/ruby/core/math/erfc_spec.rb8
-rw-r--r--spec/ruby/core/math/exp_spec.rb8
-rw-r--r--spec/ruby/core/math/expm1_spec.rb37
-rw-r--r--spec/ruby/core/math/fixtures/common.rb (renamed from spec/ruby/fixtures/math/common.rb)0
-rw-r--r--spec/ruby/core/math/frexp_spec.rb6
-rw-r--r--spec/ruby/core/math/gamma_spec.rb6
-rw-r--r--spec/ruby/core/math/hypot_spec.rb12
-rw-r--r--spec/ruby/core/math/ldexp_spec.rb14
-rw-r--r--spec/ruby/core/math/lgamma_spec.rb13
-rw-r--r--spec/ruby/core/math/log10_spec.rb14
-rw-r--r--spec/ruby/core/math/log1p_spec.rb49
-rw-r--r--spec/ruby/core/math/log2_spec.rb10
-rw-r--r--spec/ruby/core/math/log_spec.rb16
-rw-r--r--spec/ruby/core/math/shared/atanh.rb44
-rw-r--r--spec/ruby/core/math/sin_spec.rb8
-rw-r--r--spec/ruby/core/math/sinh_spec.rb8
-rw-r--r--spec/ruby/core/math/sqrt_spec.rb10
-rw-r--r--spec/ruby/core/math/tan_spec.rb8
-rw-r--r--spec/ruby/core/math/tanh_spec.rb8
-rw-r--r--spec/ruby/core/method/clone_spec.rb15
-rw-r--r--spec/ruby/core/method/compose_spec.rb3
-rw-r--r--spec/ruby/core/method/curry_spec.rb18
-rw-r--r--spec/ruby/core/method/dup_spec.rb15
-rw-r--r--spec/ruby/core/method/fixtures/classes.rb1
-rw-r--r--spec/ruby/core/method/inspect_spec.rb2
-rw-r--r--spec/ruby/core/method/original_name_spec.rb37
-rw-r--r--spec/ruby/core/method/owner_spec.rb6
-rw-r--r--spec/ruby/core/method/parameters_spec.rb67
-rw-r--r--spec/ruby/core/method/private_spec.rb20
-rw-r--r--spec/ruby/core/method/protected_spec.rb20
-rw-r--r--spec/ruby/core/method/public_spec.rb20
-rw-r--r--spec/ruby/core/method/receiver_spec.rb8
-rw-r--r--spec/ruby/core/method/shared/aliased_inspect.rb31
-rw-r--r--spec/ruby/core/method/shared/call.rb4
-rw-r--r--spec/ruby/core/method/shared/dup.rb32
-rw-r--r--spec/ruby/core/method/shared/eql.rb32
-rw-r--r--spec/ruby/core/method/shared/to_s.rb34
-rw-r--r--spec/ruby/core/method/source_location_spec.rb21
-rw-r--r--spec/ruby/core/method/super_method_spec.rb10
-rw-r--r--spec/ruby/core/method/to_proc_spec.rb2
-rw-r--r--spec/ruby/core/method/to_s_spec.rb2
-rw-r--r--spec/ruby/core/method/unbind_spec.rb14
-rw-r--r--spec/ruby/core/module/alias_method_spec.rb62
-rw-r--r--spec/ruby/core/module/ancestors_spec.rb40
-rw-r--r--spec/ruby/core/module/append_features_spec.rb14
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb35
-rw-r--r--spec/ruby/core/module/attr_reader_spec.rb27
-rw-r--r--spec/ruby/core/module/attr_spec.rb37
-rw-r--r--spec/ruby/core/module/attr_writer_spec.rb29
-rw-r--r--spec/ruby/core/module/autoload_relative_spec.rb128
-rw-r--r--spec/ruby/core/module/autoload_spec.rb378
-rw-r--r--spec/ruby/core/module/class_variable_defined_spec.rb12
-rw-r--r--spec/ruby/core/module/class_variable_get_spec.rb16
-rw-r--r--spec/ruby/core/module/class_variable_set_spec.rb12
-rw-r--r--spec/ruby/core/module/class_variables_spec.rb8
-rw-r--r--spec/ruby/core/module/const_added_spec.rb253
-rw-r--r--spec/ruby/core/module/const_defined_spec.rb79
-rw-r--r--spec/ruby/core/module/const_get_spec.rb72
-rw-r--r--spec/ruby/core/module/const_missing_spec.rb2
-rw-r--r--spec/ruby/core/module/const_set_spec.rb55
-rw-r--r--spec/ruby/core/module/const_source_location_spec.rb77
-rw-r--r--spec/ruby/core/module/constants_spec.rb7
-rw-r--r--spec/ruby/core/module/define_method_spec.rb161
-rw-r--r--spec/ruby/core/module/deprecate_constant_spec.rb17
-rw-r--r--spec/ruby/core/module/extend_object_spec.rb10
-rw-r--r--spec/ruby/core/module/extended_spec.rb2
-rw-r--r--spec/ruby/core/module/fixtures/autoload_const_source_location.rb6
-rw-r--r--spec/ruby/core/module/fixtures/autoload_during_autoload_after_define.rb6
-rw-r--r--spec/ruby/core/module/fixtures/autoload_relative_a.rb9
-rw-r--r--spec/ruby/core/module/fixtures/classes.rb28
-rw-r--r--spec/ruby/core/module/fixtures/const_added.rb4
-rw-r--r--spec/ruby/core/module/fixtures/module.rb4
-rw-r--r--spec/ruby/core/module/fixtures/name.rb3
-rw-r--r--spec/ruby/core/module/fixtures/set_temporary_name.rb4
-rw-r--r--spec/ruby/core/module/gt_spec.rb10
-rw-r--r--spec/ruby/core/module/gte_spec.rb2
-rw-r--r--spec/ruby/core/module/include_spec.rb85
-rw-r--r--spec/ruby/core/module/included_modules_spec.rb8
-rw-r--r--spec/ruby/core/module/included_spec.rb2
-rw-r--r--spec/ruby/core/module/instance_method_spec.rb37
-rw-r--r--spec/ruby/core/module/instance_methods_spec.rb30
-rw-r--r--spec/ruby/core/module/lt_spec.rb10
-rw-r--r--spec/ruby/core/module/lte_spec.rb2
-rw-r--r--spec/ruby/core/module/method_added_spec.rb4
-rw-r--r--spec/ruby/core/module/method_defined_spec.rb6
-rw-r--r--spec/ruby/core/module/method_removed_spec.rb2
-rw-r--r--spec/ruby/core/module/method_undefined_spec.rb2
-rw-r--r--spec/ruby/core/module/module_function_spec.rb191
-rw-r--r--spec/ruby/core/module/name_spec.rb117
-rw-r--r--spec/ruby/core/module/new_spec.rb4
-rw-r--r--spec/ruby/core/module/prepend_features_spec.rb8
-rw-r--r--spec/ruby/core/module/prepend_spec.rb146
-rw-r--r--spec/ruby/core/module/prepended_spec.rb2
-rw-r--r--spec/ruby/core/module/private_class_method_spec.rb34
-rw-r--r--spec/ruby/core/module/private_constant_spec.rb8
-rw-r--r--spec/ruby/core/module/private_instance_methods_spec.rb18
-rw-r--r--spec/ruby/core/module/private_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/private_spec.rb40
-rw-r--r--spec/ruby/core/module/protected_instance_methods_spec.rb12
-rw-r--r--spec/ruby/core/module/protected_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/protected_spec.rb38
-rw-r--r--spec/ruby/core/module/public_class_method_spec.rb34
-rw-r--r--spec/ruby/core/module/public_constant_spec.rb2
-rw-r--r--spec/ruby/core/module/public_instance_method_spec.rb20
-rw-r--r--spec/ruby/core/module/public_instance_methods_spec.rb14
-rw-r--r--spec/ruby/core/module/public_method_defined_spec.rb10
-rw-r--r--spec/ruby/core/module/public_spec.rb36
-rw-r--r--spec/ruby/core/module/refine_spec.rb370
-rw-r--r--spec/ruby/core/module/refinements_spec.rb43
-rw-r--r--spec/ruby/core/module/remove_class_variable_spec.rb12
-rw-r--r--spec/ruby/core/module/remove_const_spec.rb32
-rw-r--r--spec/ruby/core/module/remove_method_spec.rb16
-rw-r--r--spec/ruby/core/module/ruby2_keywords_spec.rb197
-rw-r--r--spec/ruby/core/module/set_temporary_name_spec.rb145
-rw-r--r--spec/ruby/core/module/shared/attr_added.rb34
-rw-r--r--spec/ruby/core/module/shared/class_eval.rb20
-rw-r--r--spec/ruby/core/module/shared/class_exec.rb12
-rw-r--r--spec/ruby/core/module/shared/set_visibility.rb60
-rw-r--r--spec/ruby/core/module/to_s_spec.rb2
-rw-r--r--spec/ruby/core/module/undef_method_spec.rb34
-rw-r--r--spec/ruby/core/module/undefined_instance_methods_spec.rb25
-rw-r--r--spec/ruby/core/module/used_refinements_spec.rb85
-rw-r--r--spec/ruby/core/module/using_spec.rb14
-rw-r--r--spec/ruby/core/mutex/lock_spec.rb70
-rw-r--r--spec/ruby/core/mutex/locked_spec.rb8
-rw-r--r--spec/ruby/core/mutex/owned_spec.rb22
-rw-r--r--spec/ruby/core/mutex/sleep_spec.rb28
-rw-r--r--spec/ruby/core/mutex/synchronize_spec.rb8
-rw-r--r--spec/ruby/core/mutex/try_lock_spec.rb8
-rw-r--r--spec/ruby/core/mutex/unlock_spec.rb6
-rw-r--r--spec/ruby/core/nil/dup_spec.rb2
-rw-r--r--spec/ruby/core/nil/match_spec.rb14
-rw-r--r--spec/ruby/core/nil/nilclass_spec.rb4
-rw-r--r--spec/ruby/core/nil/rationalize_spec.rb4
-rw-r--r--spec/ruby/core/nil/singleton_method_spec.rb13
-rw-r--r--spec/ruby/core/nil/to_c_spec.rb2
-rw-r--r--spec/ruby/core/nil/to_s_spec.rb2
-rw-r--r--spec/ruby/core/numeric/abs2_spec.rb4
-rw-r--r--spec/ruby/core/numeric/clone_spec.rb18
-rw-r--r--spec/ruby/core/numeric/coerce_spec.rb12
-rw-r--r--spec/ruby/core/numeric/comparison_spec.rb8
-rw-r--r--spec/ruby/core/numeric/div_spec.rb6
-rw-r--r--spec/ruby/core/numeric/dup_spec.rb4
-rw-r--r--spec/ruby/core/numeric/eql_spec.rb12
-rw-r--r--spec/ruby/core/numeric/fdiv_spec.rb5
-rw-r--r--spec/ruby/core/numeric/finite_spec.rb2
-rw-r--r--spec/ruby/core/numeric/i_spec.rb2
-rw-r--r--spec/ruby/core/numeric/negative_spec.rb12
-rw-r--r--spec/ruby/core/numeric/polar_spec.rb6
-rw-r--r--spec/ruby/core/numeric/positive_spec.rb12
-rw-r--r--spec/ruby/core/numeric/quo_spec.rb25
-rw-r--r--spec/ruby/core/numeric/real_spec.rb4
-rw-r--r--spec/ruby/core/numeric/remainder_spec.rb10
-rw-r--r--spec/ruby/core/numeric/shared/conj.rb2
-rw-r--r--spec/ruby/core/numeric/shared/imag.rb6
-rw-r--r--spec/ruby/core/numeric/shared/quo.rb7
-rw-r--r--spec/ruby/core/numeric/shared/rect.rb28
-rw-r--r--spec/ruby/core/numeric/shared/step.rb98
-rw-r--r--spec/ruby/core/numeric/singleton_method_added_spec.rb8
-rw-r--r--spec/ruby/core/numeric/step_spec.rb93
-rw-r--r--spec/ruby/core/numeric/to_c_spec.rb4
-rw-r--r--spec/ruby/core/objectspace/_id2ref_spec.rb87
-rw-r--r--spec/ruby/core/objectspace/add_finalizer_spec.rb5
-rw-r--r--spec/ruby/core/objectspace/call_finalizer_spec.rb5
-rw-r--r--spec/ruby/core/objectspace/define_finalizer_spec.rb155
-rw-r--r--spec/ruby/core/objectspace/each_object_spec.rb46
-rw-r--r--spec/ruby/core/objectspace/finalizers_spec.rb5
-rw-r--r--spec/ruby/core/objectspace/garbage_collect_spec.rb4
-rw-r--r--spec/ruby/core/objectspace/remove_finalizer_spec.rb5
-rw-r--r--spec/ruby/core/objectspace/undefine_finalizer_spec.rb30
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/clear_spec.rb25
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/delete_spec.rb49
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb105
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb80
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/fixtures/classes.rb5
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb26
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb19
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/key_spec.rb42
-rw-r--r--spec/ruby/core/objectspace/weakmap/delete_spec.rb28
-rw-r--r--spec/ruby/core/objectspace/weakmap/shared/each.rb2
-rw-r--r--spec/ruby/core/proc/allocate_spec.rb2
-rw-r--r--spec/ruby/core/proc/arity_spec.rb16
-rw-r--r--spec/ruby/core/proc/binding_spec.rb2
-rw-r--r--spec/ruby/core/proc/block_pass_spec.rb4
-rw-r--r--spec/ruby/core/proc/clone_spec.rb22
-rw-r--r--spec/ruby/core/proc/compose_spec.rb46
-rw-r--r--spec/ruby/core/proc/curry_spec.rb69
-rw-r--r--spec/ruby/core/proc/dup_spec.rb20
-rw-r--r--spec/ruby/core/proc/element_reference_spec.rb10
-rw-r--r--spec/ruby/core/proc/eql_spec.rb8
-rw-r--r--spec/ruby/core/proc/equal_value_spec.rb8
-rw-r--r--spec/ruby/core/proc/fixtures/common.rb23
-rw-r--r--spec/ruby/core/proc/fixtures/proc_aref.rb1
-rw-r--r--spec/ruby/core/proc/hash_spec.rb6
-rw-r--r--spec/ruby/core/proc/lambda_spec.rb43
-rw-r--r--spec/ruby/core/proc/new_spec.rb57
-rw-r--r--spec/ruby/core/proc/parameters_spec.rb111
-rw-r--r--spec/ruby/core/proc/ruby2_keywords_spec.rb38
-rw-r--r--spec/ruby/core/proc/shared/call.rb8
-rw-r--r--spec/ruby/core/proc/shared/compose.rb4
-rw-r--r--spec/ruby/core/proc/shared/dup.rb31
-rw-r--r--spec/ruby/core/proc/shared/equal.rb51
-rw-r--r--spec/ruby/core/proc/shared/to_s.rb14
-rw-r--r--spec/ruby/core/proc/source_location_spec.rb37
-rw-r--r--spec/ruby/core/proc/to_proc_spec.rb2
-rw-r--r--spec/ruby/core/process/_fork_spec.rb30
-rw-r--r--spec/ruby/core/process/argv0_spec.rb23
-rw-r--r--spec/ruby/core/process/clock_gettime_spec.rb62
-rw-r--r--spec/ruby/core/process/constants_spec.rb134
-rw-r--r--spec/ruby/core/process/daemon_spec.rb5
-rw-r--r--spec/ruby/core/process/detach_spec.rb26
-rw-r--r--spec/ruby/core/process/egid_spec.rb8
-rw-r--r--spec/ruby/core/process/euid_spec.rb8
-rw-r--r--spec/ruby/core/process/exec_spec.rb62
-rw-r--r--spec/ruby/core/process/fixtures/argv0.rb6
-rw-r--r--spec/ruby/core/process/fixtures/clocks.rb2
-rw-r--r--spec/ruby/core/process/fixtures/kill.rb2
-rw-r--r--spec/ruby/core/process/getpriority_spec.rb8
-rw-r--r--spec/ruby/core/process/getrlimit_spec.rb14
-rw-r--r--spec/ruby/core/process/gid_spec.rb4
-rw-r--r--spec/ruby/core/process/groups_spec.rb4
-rw-r--r--spec/ruby/core/process/initgroups_spec.rb2
-rw-r--r--spec/ruby/core/process/kill_spec.rb8
-rw-r--r--spec/ruby/core/process/last_status_spec.rb2
-rw-r--r--spec/ruby/core/process/maxgroups_spec.rb2
-rw-r--r--spec/ruby/core/process/pid_spec.rb2
-rw-r--r--spec/ruby/core/process/set_proctitle_spec.rb2
-rw-r--r--spec/ruby/core/process/setrlimit_spec.rb108
-rw-r--r--spec/ruby/core/process/spawn_spec.rb108
-rw-r--r--spec/ruby/core/process/status/bit_and_spec.rb37
-rw-r--r--spec/ruby/core/process/status/exited_spec.rb6
-rw-r--r--spec/ruby/core/process/status/right_shift_spec.rb36
-rw-r--r--spec/ruby/core/process/status/signaled_spec.rb6
-rw-r--r--spec/ruby/core/process/status/success_spec.rb8
-rw-r--r--spec/ruby/core/process/status/termsig_spec.rb6
-rw-r--r--spec/ruby/core/process/status/to_i_spec.rb4
-rw-r--r--spec/ruby/core/process/status/wait_spec.rb158
-rw-r--r--spec/ruby/core/process/times_spec.rb22
-rw-r--r--spec/ruby/core/process/tms/cstime_spec.rb17
-rw-r--r--spec/ruby/core/process/tms/cutime_spec.rb17
-rw-r--r--spec/ruby/core/process/tms/stime_spec.rb17
-rw-r--r--spec/ruby/core/process/tms/utime_spec.rb17
-rw-r--r--spec/ruby/core/process/uid_spec.rb6
-rw-r--r--spec/ruby/core/process/wait2_spec.rb10
-rw-r--r--spec/ruby/core/process/wait_spec.rb16
-rw-r--r--spec/ruby/core/process/waitall_spec.rb10
-rw-r--r--spec/ruby/core/process/waitpid_spec.rb3
-rw-r--r--spec/ruby/core/process/warmup_spec.rb9
-rw-r--r--spec/ruby/core/queue/deq_spec.rb5
-rw-r--r--spec/ruby/core/queue/freeze_spec.rb6
-rw-r--r--spec/ruby/core/queue/initialize_spec.rb45
-rw-r--r--spec/ruby/core/queue/pop_spec.rb5
-rw-r--r--spec/ruby/core/queue/shift_spec.rb5
-rw-r--r--spec/ruby/core/random/bytes_spec.rb3
-rw-r--r--spec/ruby/core/random/default_spec.rb42
-rw-r--r--spec/ruby/core/random/new_seed_spec.rb2
-rw-r--r--spec/ruby/core/random/new_spec.rb8
-rw-r--r--spec/ruby/core/random/rand_spec.rb34
-rw-r--r--spec/ruby/core/random/seed_spec.rb2
-rw-r--r--spec/ruby/core/random/shared/bytes.rb2
-rw-r--r--spec/ruby/core/random/shared/rand.rb4
-rw-r--r--spec/ruby/core/random/urandom_spec.rb4
-rw-r--r--spec/ruby/core/range/bsearch_spec.rb136
-rw-r--r--spec/ruby/core/range/case_compare_spec.rb4
-rw-r--r--spec/ruby/core/range/cover_spec.rb6
-rw-r--r--spec/ruby/core/range/each_spec.rb45
-rw-r--r--spec/ruby/core/range/eql_spec.rb2
-rw-r--r--spec/ruby/core/range/first_spec.rb10
-rw-r--r--spec/ruby/core/range/frozen_spec.rb34
-rw-r--r--spec/ruby/core/range/hash_spec.rb8
-rw-r--r--spec/ruby/core/range/include_spec.rb6
-rw-r--r--spec/ruby/core/range/initialize_spec.rb31
-rw-r--r--spec/ruby/core/range/last_spec.rb16
-rw-r--r--spec/ruby/core/range/max_spec.rb54
-rw-r--r--spec/ruby/core/range/member_spec.rb2
-rw-r--r--spec/ruby/core/range/min_spec.rb26
-rw-r--r--spec/ruby/core/range/minmax_spec.rb38
-rw-r--r--spec/ruby/core/range/new_spec.rb20
-rw-r--r--spec/ruby/core/range/overlap_spec.rb87
-rw-r--r--spec/ruby/core/range/reverse_each_spec.rb125
-rw-r--r--spec/ruby/core/range/shared/cover.rb144
-rw-r--r--spec/ruby/core/range/shared/cover_and_include.rb48
-rw-r--r--spec/ruby/core/range/shared/include.rb34
-rw-r--r--spec/ruby/core/range/size_spec.rb79
-rw-r--r--spec/ruby/core/range/step_spec.rb532
-rw-r--r--spec/ruby/core/range/to_a_spec.rb6
-rw-r--r--spec/ruby/core/range/to_set_spec.rb54
-rw-r--r--spec/ruby/core/rational/abs_spec.rb2
-rw-r--r--spec/ruby/core/rational/ceil_spec.rb46
-rw-r--r--spec/ruby/core/rational/coerce_spec.rb6
-rw-r--r--spec/ruby/core/rational/comparison_spec.rb84
-rw-r--r--spec/ruby/core/rational/denominator_spec.rb12
-rw-r--r--spec/ruby/core/rational/div_spec.rb46
-rw-r--r--spec/ruby/core/rational/divide_spec.rb66
-rw-r--r--spec/ruby/core/rational/divmod_spec.rb36
-rw-r--r--spec/ruby/core/rational/equal_value_spec.rb31
-rw-r--r--spec/ruby/core/rational/exponent_spec.rb234
-rw-r--r--spec/ruby/core/rational/fdiv_spec.rb3
-rw-r--r--spec/ruby/core/rational/fixtures/rational.rb (renamed from spec/ruby/fixtures/rational.rb)0
-rw-r--r--spec/ruby/core/rational/floor_spec.rb47
-rw-r--r--spec/ruby/core/rational/hash_spec.rb7
-rw-r--r--spec/ruby/core/rational/inspect_spec.rb12
-rw-r--r--spec/ruby/core/rational/integer_spec.rb4
-rw-r--r--spec/ruby/core/rational/magnitude_spec.rb2
-rw-r--r--spec/ruby/core/rational/marshal_dump_spec.rb2
-rw-r--r--spec/ruby/core/rational/minus_spec.rb16
-rw-r--r--spec/ruby/core/rational/modulo_spec.rb41
-rw-r--r--spec/ruby/core/rational/multiply_spec.rb57
-rw-r--r--spec/ruby/core/rational/numerator_spec.rb8
-rw-r--r--spec/ruby/core/rational/plus_spec.rb43
-rw-r--r--spec/ruby/core/rational/quo_spec.rb23
-rw-r--r--spec/ruby/core/rational/rational_spec.rb2
-rw-r--r--spec/ruby/core/rational/rationalize_spec.rb4
-rw-r--r--spec/ruby/core/rational/remainder_spec.rb3
-rw-r--r--spec/ruby/core/rational/round_spec.rb104
-rw-r--r--spec/ruby/core/rational/shared/abs.rb11
-rw-r--r--spec/ruby/core/rational/shared/arithmetic_exception_in_coerce.rb11
-rw-r--r--spec/ruby/core/rational/to_f_spec.rb14
-rw-r--r--spec/ruby/core/rational/to_i_spec.rb10
-rw-r--r--spec/ruby/core/rational/to_r_spec.rb13
-rw-r--r--spec/ruby/core/rational/to_s_spec.rb12
-rw-r--r--spec/ruby/core/rational/truncate_spec.rb69
-rw-r--r--spec/ruby/core/rational/zero_spec.rb6
-rw-r--r--spec/ruby/core/refinement/append_features_spec.rb24
-rw-r--r--spec/ruby/core/refinement/extend_object_spec.rb26
-rw-r--r--spec/ruby/core/refinement/fixtures/classes.rb10
-rw-r--r--spec/ruby/core/refinement/import_methods_spec.rb293
-rw-r--r--spec/ruby/core/refinement/include_spec.rb26
-rw-r--r--spec/ruby/core/refinement/prepend_features_spec.rb24
-rw-r--r--spec/ruby/core/refinement/prepend_spec.rb26
-rw-r--r--spec/ruby/core/refinement/refined_class_spec.rb34
-rw-r--r--spec/ruby/core/refinement/shared/target.rb13
-rw-r--r--spec/ruby/core/refinement/target_spec.rb6
-rw-r--r--spec/ruby/core/regexp/case_compare_spec.rb14
-rw-r--r--spec/ruby/core/regexp/compile_spec.rb2
-rw-r--r--spec/ruby/core/regexp/encoding_spec.rb2
-rw-r--r--spec/ruby/core/regexp/fixed_encoding_spec.rb16
-rw-r--r--spec/ruby/core/regexp/initialize_spec.rb24
-rw-r--r--spec/ruby/core/regexp/last_match_spec.rb6
-rw-r--r--spec/ruby/core/regexp/linear_time_spec.rb80
-rw-r--r--spec/ruby/core/regexp/match_spec.rb38
-rw-r--r--spec/ruby/core/regexp/named_captures_spec.rb4
-rw-r--r--spec/ruby/core/regexp/names_spec.rb4
-rw-r--r--spec/ruby/core/regexp/new_spec.rb2
-rw-r--r--spec/ruby/core/regexp/options_spec.rb6
-rw-r--r--spec/ruby/core/regexp/shared/new.rb426
-rw-r--r--spec/ruby/core/regexp/shared/quote.rb20
-rw-r--r--spec/ruby/core/regexp/source_spec.rb4
-rw-r--r--spec/ruby/core/regexp/timeout_spec.rb48
-rw-r--r--spec/ruby/core/regexp/try_convert_spec.rb8
-rw-r--r--spec/ruby/core/regexp/union_spec.rb51
-rw-r--r--spec/ruby/core/set/add_spec.rb34
-rw-r--r--spec/ruby/core/set/append_spec.rb6
-rw-r--r--spec/ruby/core/set/case_compare_spec.rb11
-rw-r--r--spec/ruby/core/set/case_equality_spec.rb6
-rw-r--r--spec/ruby/core/set/classify_spec.rb26
-rw-r--r--spec/ruby/core/set/clear_spec.rb16
-rw-r--r--spec/ruby/core/set/collect_spec.rb6
-rw-r--r--spec/ruby/core/set/compare_by_identity_spec.rb153
-rw-r--r--spec/ruby/core/set/comparison_spec.rb26
-rw-r--r--spec/ruby/core/set/constructor_spec.rb14
-rw-r--r--spec/ruby/core/set/delete_if_spec.rb37
-rw-r--r--spec/ruby/core/set/delete_spec.rb36
-rw-r--r--spec/ruby/core/set/difference_spec.rb6
-rw-r--r--spec/ruby/core/set/disjoint_spec.rb22
-rw-r--r--spec/ruby/core/set/divide_spec.rb68
-rw-r--r--spec/ruby/core/set/each_spec.rb26
-rw-r--r--spec/ruby/core/set/empty_spec.rb9
-rw-r--r--spec/ruby/core/set/enumerable/to_set_spec.rb12
-rw-r--r--spec/ruby/core/set/eql_spec.rb14
-rw-r--r--spec/ruby/core/set/equal_value_spec.rb34
-rw-r--r--spec/ruby/core/set/exclusion_spec.rb17
-rw-r--r--spec/ruby/core/set/filter_spec.rb (renamed from spec/ruby/library/set/filter_spec.rb)0
-rw-r--r--spec/ruby/core/set/fixtures/set_like.rb30
-rw-r--r--spec/ruby/core/set/flatten_merge_spec.rb24
-rw-r--r--spec/ruby/core/set/flatten_spec.rb49
-rw-r--r--spec/ruby/core/set/hash_spec.rb19
-rw-r--r--spec/ruby/core/set/include_spec.rb6
-rw-r--r--spec/ruby/core/set/initialize_clone_spec.rb15
-rw-r--r--spec/ruby/core/set/initialize_spec.rb88
-rw-r--r--spec/ruby/core/set/inspect_spec.rb6
-rw-r--r--spec/ruby/core/set/intersect_spec.rb22
-rw-r--r--spec/ruby/core/set/intersection_spec.rb10
-rw-r--r--spec/ruby/core/set/join_spec.rb30
-rw-r--r--spec/ruby/core/set/keep_if_spec.rb37
-rw-r--r--spec/ruby/core/set/length_spec.rb6
-rw-r--r--spec/ruby/core/set/map_spec.rb6
-rw-r--r--spec/ruby/core/set/member_spec.rb6
-rw-r--r--spec/ruby/core/set/merge_spec.rb29
-rw-r--r--spec/ruby/core/set/minus_spec.rb6
-rw-r--r--spec/ruby/core/set/plus_spec.rb6
-rw-r--r--spec/ruby/core/set/pretty_print_cycle_spec.rb14
-rw-r--r--spec/ruby/core/set/proper_subset_spec.rb35
-rw-r--r--spec/ruby/core/set/proper_superset_spec.rb42
-rw-r--r--spec/ruby/core/set/reject_spec.rb41
-rw-r--r--spec/ruby/core/set/replace_spec.rb24
-rw-r--r--spec/ruby/core/set/select_spec.rb (renamed from spec/ruby/library/set/select_spec.rb)0
-rw-r--r--spec/ruby/core/set/set_spec.rb10
-rw-r--r--spec/ruby/core/set/shared/add.rb14
-rw-r--r--spec/ruby/core/set/shared/collect.rb20
-rw-r--r--spec/ruby/core/set/shared/difference.rb15
-rw-r--r--spec/ruby/core/set/shared/include.rb29
-rw-r--r--spec/ruby/core/set/shared/inspect.rb45
-rw-r--r--spec/ruby/core/set/shared/intersection.rb15
-rw-r--r--spec/ruby/core/set/shared/length.rb (renamed from spec/ruby/library/set/shared/length.rb)0
-rw-r--r--spec/ruby/core/set/shared/select.rb41
-rw-r--r--spec/ruby/core/set/shared/union.rb15
-rw-r--r--spec/ruby/core/set/size_spec.rb6
-rw-r--r--spec/ruby/core/set/sortedset/sortedset_spec.rb13
-rw-r--r--spec/ruby/core/set/subset_spec.rb35
-rw-r--r--spec/ruby/core/set/subtract_spec.rb16
-rw-r--r--spec/ruby/core/set/superset_spec.rb42
-rw-r--r--spec/ruby/core/set/to_a_spec.rb7
-rw-r--r--spec/ruby/core/set/to_s_spec.rb11
-rw-r--r--spec/ruby/core/set/union_spec.rb10
-rw-r--r--spec/ruby/core/signal/signame_spec.rb14
-rw-r--r--spec/ruby/core/signal/trap_spec.rb59
-rw-r--r--spec/ruby/core/sizedqueue/append_spec.rb5
-rw-r--r--spec/ruby/core/sizedqueue/deq_spec.rb5
-rw-r--r--spec/ruby/core/sizedqueue/enq_spec.rb5
-rw-r--r--spec/ruby/core/sizedqueue/freeze_spec.rb6
-rw-r--r--spec/ruby/core/sizedqueue/pop_spec.rb5
-rw-r--r--spec/ruby/core/sizedqueue/push_spec.rb5
-rw-r--r--spec/ruby/core/sizedqueue/shift_spec.rb5
-rw-r--r--spec/ruby/core/string/allocate_spec.rb2
-rw-r--r--spec/ruby/core/string/append_as_bytes_spec.rb60
-rw-r--r--spec/ruby/core/string/append_spec.rb5
-rw-r--r--spec/ruby/core/string/ascii_only_spec.rb41
-rw-r--r--spec/ruby/core/string/b_spec.rb3
-rw-r--r--spec/ruby/core/string/byteindex_spec.rb298
-rw-r--r--spec/ruby/core/string/byterindex_spec.rb353
-rw-r--r--spec/ruby/core/string/bytes_spec.rb8
-rw-r--r--spec/ruby/core/string/bytesize_spec.rb10
-rw-r--r--spec/ruby/core/string/byteslice_spec.rb12
-rw-r--r--spec/ruby/core/string/bytesplice_spec.rb290
-rw-r--r--spec/ruby/core/string/capitalize_spec.rb63
-rw-r--r--spec/ruby/core/string/casecmp_spec.rb10
-rw-r--r--spec/ruby/core/string/center_spec.rb53
-rw-r--r--spec/ruby/core/string/chilled_string_spec.rb151
-rw-r--r--spec/ruby/core/string/chomp_spec.rb54
-rw-r--r--spec/ruby/core/string/chop_spec.rb23
-rw-r--r--spec/ruby/core/string/chr_spec.rb4
-rw-r--r--spec/ruby/core/string/clear_spec.rb7
-rw-r--r--spec/ruby/core/string/clone_spec.rb4
-rw-r--r--spec/ruby/core/string/codepoints_spec.rb8
-rw-r--r--spec/ruby/core/string/comparison_spec.rb12
-rw-r--r--spec/ruby/core/string/concat_spec.rb9
-rw-r--r--spec/ruby/core/string/count_spec.rb14
-rw-r--r--spec/ruby/core/string/crypt_spec.rb30
-rw-r--r--spec/ruby/core/string/dedup_spec.rb4
-rw-r--r--spec/ruby/core/string/delete_prefix_spec.rb30
-rw-r--r--spec/ruby/core/string/delete_spec.rb33
-rw-r--r--spec/ruby/core/string/delete_suffix_spec.rb30
-rw-r--r--spec/ruby/core/string/downcase_spec.rb37
-rw-r--r--spec/ruby/core/string/dump_spec.rb12
-rw-r--r--spec/ruby/core/string/dup_spec.rb8
-rw-r--r--spec/ruby/core/string/each_byte_spec.rb20
-rw-r--r--spec/ruby/core/string/each_grapheme_cluster_spec.rb10
-rw-r--r--spec/ruby/core/string/element_set_spec.rb87
-rw-r--r--spec/ruby/core/string/encode_spec.rb78
-rw-r--r--spec/ruby/core/string/encoding_spec.rb36
-rw-r--r--spec/ruby/core/string/eql_spec.rb8
-rw-r--r--spec/ruby/core/string/fixtures/utf-8-encoding.rb7
-rw-r--r--spec/ruby/core/string/force_encoding_spec.rb11
-rw-r--r--spec/ruby/core/string/freeze_spec.rb5
-rw-r--r--spec/ruby/core/string/getbyte_spec.rb12
-rw-r--r--spec/ruby/core/string/gsub_spec.rb68
-rw-r--r--spec/ruby/core/string/include_spec.rb20
-rw-r--r--spec/ruby/core/string/index_spec.rb34
-rw-r--r--spec/ruby/core/string/initialize_spec.rb4
-rw-r--r--spec/ruby/core/string/insert_spec.rb18
-rw-r--r--spec/ruby/core/string/inspect_spec.rb4
-rw-r--r--spec/ruby/core/string/ljust_spec.rb51
-rw-r--r--spec/ruby/core/string/lstrip_spec.rb45
-rw-r--r--spec/ruby/core/string/match_spec.rb34
-rw-r--r--spec/ruby/core/string/modulo_spec.rb207
-rw-r--r--spec/ruby/core/string/new_spec.rb10
-rw-r--r--spec/ruby/core/string/ord_spec.rb8
-rw-r--r--spec/ruby/core/string/partition_spec.rb8
-rw-r--r--spec/ruby/core/string/plus_spec.rb23
-rw-r--r--spec/ruby/core/string/prepend_spec.rb13
-rw-r--r--spec/ruby/core/string/reverse_spec.rb31
-rw-r--r--spec/ruby/core/string/rindex_spec.rb30
-rw-r--r--spec/ruby/core/string/rjust_spec.rb51
-rw-r--r--spec/ruby/core/string/rpartition_spec.rb8
-rw-r--r--spec/ruby/core/string/rstrip_spec.rb47
-rw-r--r--spec/ruby/core/string/scan_spec.rb40
-rw-r--r--spec/ruby/core/string/scrub_spec.rb43
-rw-r--r--spec/ruby/core/string/setbyte_spec.rb17
-rw-r--r--spec/ruby/core/string/shared/byte_index_common.rb63
-rw-r--r--spec/ruby/core/string/shared/chars.rb38
-rw-r--r--spec/ruby/core/string/shared/codepoints.rb27
-rw-r--r--spec/ruby/core/string/shared/concat.rb63
-rw-r--r--spec/ruby/core/string/shared/dedup.rb32
-rw-r--r--spec/ruby/core/string/shared/each_char_without_block.rb2
-rw-r--r--spec/ruby/core/string/shared/each_codepoint_without_block.rb14
-rw-r--r--spec/ruby/core/string/shared/each_line.rb78
-rw-r--r--spec/ruby/core/string/shared/each_line_without_block.rb2
-rw-r--r--spec/ruby/core/string/shared/encode.rb215
-rw-r--r--spec/ruby/core/string/shared/eql.rb20
-rw-r--r--spec/ruby/core/string/shared/equal_value.rb10
-rw-r--r--spec/ruby/core/string/shared/grapheme_clusters.rb11
-rw-r--r--spec/ruby/core/string/shared/length.rb10
-rw-r--r--spec/ruby/core/string/shared/partition.rb34
-rw-r--r--spec/ruby/core/string/shared/replace.rb15
-rw-r--r--spec/ruby/core/string/shared/slice.rb189
-rw-r--r--spec/ruby/core/string/shared/strip.rb18
-rw-r--r--spec/ruby/core/string/shared/succ.rb27
-rw-r--r--spec/ruby/core/string/shared/to_a.rb9
-rw-r--r--spec/ruby/core/string/shared/to_s.rb4
-rw-r--r--spec/ruby/core/string/shared/to_sym.rb38
-rw-r--r--spec/ruby/core/string/slice_spec.rb137
-rw-r--r--spec/ruby/core/string/split_spec.rb166
-rw-r--r--spec/ruby/core/string/squeeze_spec.rb35
-rw-r--r--spec/ruby/core/string/start_with_spec.rb6
-rw-r--r--spec/ruby/core/string/strip_spec.rb25
-rw-r--r--spec/ruby/core/string/sub_spec.rb72
-rw-r--r--spec/ruby/core/string/swapcase_spec.rb46
-rw-r--r--spec/ruby/core/string/to_c_spec.rb32
-rw-r--r--spec/ruby/core/string/to_f_spec.rb104
-rw-r--r--spec/ruby/core/string/to_i_spec.rb30
-rw-r--r--spec/ruby/core/string/to_r_spec.rb6
-rw-r--r--spec/ruby/core/string/tr_s_spec.rb26
-rw-r--r--spec/ruby/core/string/tr_spec.rb30
-rw-r--r--spec/ruby/core/string/try_convert_spec.rb16
-rw-r--r--spec/ruby/core/string/undump_spec.rb36
-rw-r--r--spec/ruby/core/string/unicode_normalize_spec.rb9
-rw-r--r--spec/ruby/core/string/unicode_normalized_spec.rb21
-rw-r--r--spec/ruby/core/string/unpack/a_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/at_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/b_spec.rb38
-rw-r--r--spec/ruby/core/string/unpack/c_spec.rb18
-rw-r--r--spec/ruby/core/string/unpack/carret_spec.rb43
-rw-r--r--spec/ruby/core/string/unpack/comment_spec.rb2
-rw-r--r--spec/ruby/core/string/unpack/h_spec.rb34
-rw-r--r--spec/ruby/core/string/unpack/l_spec.rb16
-rw-r--r--spec/ruby/core/string/unpack/m_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/p_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/percent_spec.rb2
-rw-r--r--spec/ruby/core/string/unpack/r_spec.rb85
-rw-r--r--spec/ruby/core/string/unpack/shared/basic.rb14
-rw-r--r--spec/ruby/core/string/unpack/shared/float.rb76
-rw-r--r--spec/ruby/core/string/unpack/shared/integer.rb100
-rw-r--r--spec/ruby/core/string/unpack/shared/unicode.rb16
-rw-r--r--spec/ruby/core/string/unpack/u_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/w_spec.rb18
-rw-r--r--spec/ruby/core/string/unpack/x_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/z_spec.rb2
-rw-r--r--spec/ruby/core/string/unpack1_spec.rb57
-rw-r--r--spec/ruby/core/string/unpack_spec.rb46
-rw-r--r--spec/ruby/core/string/upcase_spec.rb39
-rw-r--r--spec/ruby/core/string/uplus_spec.rb48
-rw-r--r--spec/ruby/core/string/upto_spec.rb14
-rw-r--r--spec/ruby/core/string/valid_encoding_spec.rb210
-rw-r--r--spec/ruby/core/struct/constants_spec.rb13
-rw-r--r--spec/ruby/core/struct/deconstruct_keys_spec.rb64
-rw-r--r--spec/ruby/core/struct/dig_spec.rb4
-rw-r--r--spec/ruby/core/struct/each_pair_spec.rb4
-rw-r--r--spec/ruby/core/struct/each_spec.rb2
-rw-r--r--spec/ruby/core/struct/element_reference_spec.rb14
-rw-r--r--spec/ruby/core/struct/element_set_spec.rb15
-rw-r--r--spec/ruby/core/struct/eql_spec.rb2
-rw-r--r--spec/ruby/core/struct/fixtures/classes.rb9
-rw-r--r--spec/ruby/core/struct/hash_spec.rb4
-rw-r--r--spec/ruby/core/struct/initialize_spec.rb39
-rw-r--r--spec/ruby/core/struct/instance_variable_get_spec.rb2
-rw-r--r--spec/ruby/core/struct/keyword_init_spec.rb52
-rw-r--r--spec/ruby/core/struct/members_spec.rb12
-rw-r--r--spec/ruby/core/struct/new_spec.rb139
-rw-r--r--spec/ruby/core/struct/shared/inspect.rb12
-rw-r--r--spec/ruby/core/struct/shared/select.rb6
-rw-r--r--spec/ruby/core/struct/struct_spec.rb9
-rw-r--r--spec/ruby/core/struct/to_h_spec.rb20
-rw-r--r--spec/ruby/core/struct/values_at_spec.rb8
-rw-r--r--spec/ruby/core/symbol/all_symbols_spec.rb8
-rw-r--r--spec/ruby/core/symbol/capitalize_spec.rb2
-rw-r--r--spec/ruby/core/symbol/casecmp_spec.rb6
-rw-r--r--spec/ruby/core/symbol/comparison_spec.rb6
-rw-r--r--spec/ruby/core/symbol/downcase_spec.rb2
-rw-r--r--spec/ruby/core/symbol/dup_spec.rb2
-rw-r--r--spec/ruby/core/symbol/empty_spec.rb4
-rw-r--r--spec/ruby/core/symbol/inspect_spec.rb34
-rw-r--r--spec/ruby/core/symbol/intern_spec.rb2
-rw-r--r--spec/ruby/core/symbol/match_spec.rb18
-rw-r--r--spec/ruby/core/symbol/name_spec.rb24
-rw-r--r--spec/ruby/core/symbol/shared/id2name.rb14
-rw-r--r--spec/ruby/core/symbol/shared/slice.rb58
-rw-r--r--spec/ruby/core/symbol/swapcase_spec.rb2
-rw-r--r--spec/ruby/core/symbol/symbol_spec.rb4
-rw-r--r--spec/ruby/core/symbol/to_proc_spec.rb87
-rw-r--r--spec/ruby/core/symbol/upcase_spec.rb2
-rw-r--r--spec/ruby/core/thread/abort_on_exception_spec.rb10
-rw-r--r--spec/ruby/core/thread/allocate_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace/limit_spec.rb18
-rw-r--r--spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb21
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/classes.rb104
-rw-r--r--spec/ruby/core/thread/backtrace/location/inspect_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace/location/label_spec.rb204
-rw-r--r--spec/ruby/core/thread/backtrace/location/lineno_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace/location/path_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace/location/to_s_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace_locations_spec.rb14
-rw-r--r--spec/ruby/core/thread/backtrace_spec.rb6
-rw-r--r--spec/ruby/core/thread/current_spec.rb10
-rw-r--r--spec/ruby/core/thread/each_caller_location_spec.rb47
-rw-r--r--spec/ruby/core/thread/element_reference_spec.rb15
-rw-r--r--spec/ruby/core/thread/element_set_spec.rb31
-rw-r--r--spec/ruby/core/thread/exclusive_spec.rb49
-rw-r--r--spec/ruby/core/thread/exit_spec.rb2
-rw-r--r--spec/ruby/core/thread/fetch_spec.rb36
-rw-r--r--spec/ruby/core/thread/fixtures/classes.rb27
-rw-r--r--spec/ruby/core/thread/group_spec.rb15
-rw-r--r--spec/ruby/core/thread/handle_interrupt_spec.rb6
-rw-r--r--spec/ruby/core/thread/ignore_deadlock_spec.rb26
-rw-r--r--spec/ruby/core/thread/initialize_spec.rb2
-rw-r--r--spec/ruby/core/thread/join_spec.rb20
-rw-r--r--spec/ruby/core/thread/key_spec.rb23
-rw-r--r--spec/ruby/core/thread/keys_spec.rb12
-rw-r--r--spec/ruby/core/thread/kill_spec.rb2
-rw-r--r--spec/ruby/core/thread/list_spec.rb12
-rw-r--r--spec/ruby/core/thread/name_spec.rb2
-rw-r--r--spec/ruby/core/thread/native_thread_id_spec.rb45
-rw-r--r--spec/ruby/core/thread/new_spec.rb4
-rw-r--r--spec/ruby/core/thread/pending_interrupt_spec.rb2
-rw-r--r--spec/ruby/core/thread/priority_spec.rb8
-rw-r--r--spec/ruby/core/thread/raise_spec.rb67
-rw-r--r--spec/ruby/core/thread/report_on_exception_spec.rb58
-rw-r--r--spec/ruby/core/thread/shared/exit.rb6
-rw-r--r--spec/ruby/core/thread/shared/start.rb8
-rw-r--r--spec/ruby/core/thread/shared/to_s.rb20
-rw-r--r--spec/ruby/core/thread/shared/wakeup.rb2
-rw-r--r--spec/ruby/core/thread/thread_variable_get_spec.rb45
-rw-r--r--spec/ruby/core/thread/thread_variable_set_spec.rb44
-rw-r--r--spec/ruby/core/thread/thread_variable_spec.rb47
-rw-r--r--spec/ruby/core/thread/thread_variables_spec.rb25
-rw-r--r--spec/ruby/core/thread/value_spec.rb2
-rw-r--r--spec/ruby/core/threadgroup/default_spec.rb2
-rw-r--r--spec/ruby/core/threadgroup/enclose_spec.rb2
-rw-r--r--spec/ruby/core/threadgroup/enclosed_spec.rb4
-rw-r--r--spec/ruby/core/threadgroup/list_spec.rb4
-rw-r--r--spec/ruby/core/time/_dump_spec.rb6
-rw-r--r--spec/ruby/core/time/_load_spec.rb7
-rw-r--r--spec/ruby/core/time/at_spec.rb73
-rw-r--r--spec/ruby/core/time/ceil_spec.rb4
-rw-r--r--spec/ruby/core/time/comparison_spec.rb28
-rw-r--r--spec/ruby/core/time/deconstruct_keys_spec.rb43
-rw-r--r--spec/ruby/core/time/dup_spec.rb14
-rw-r--r--spec/ruby/core/time/eql_spec.rb16
-rw-r--r--spec/ruby/core/time/fixtures/classes.rb1
-rw-r--r--spec/ruby/core/time/floor_spec.rb4
-rw-r--r--spec/ruby/core/time/getlocal_spec.rb67
-rw-r--r--spec/ruby/core/time/hash_spec.rb2
-rw-r--r--spec/ruby/core/time/iso8601_spec.rb6
-rw-r--r--spec/ruby/core/time/localtime_spec.rb69
-rw-r--r--spec/ruby/core/time/minus_spec.rb16
-rw-r--r--spec/ruby/core/time/new_spec.rb509
-rw-r--r--spec/ruby/core/time/now_spec.rb134
-rw-r--r--spec/ruby/core/time/plus_spec.rb16
-rw-r--r--spec/ruby/core/time/round_spec.rb4
-rw-r--r--spec/ruby/core/time/shared/gmtime.rb15
-rw-r--r--spec/ruby/core/time/shared/inspect.rb2
-rw-r--r--spec/ruby/core/time/shared/now.rb4
-rw-r--r--spec/ruby/core/time/shared/time_params.rb36
-rw-r--r--spec/ruby/core/time/shared/xmlschema.rb31
-rw-r--r--spec/ruby/core/time/strftime_spec.rb62
-rw-r--r--spec/ruby/core/time/subsec_spec.rb12
-rw-r--r--spec/ruby/core/time/succ_spec.rb40
-rw-r--r--spec/ruby/core/time/to_r_spec.rb4
-rw-r--r--spec/ruby/core/time/utc_spec.rb20
-rw-r--r--spec/ruby/core/time/xmlschema_spec.rb6
-rw-r--r--spec/ruby/core/time/yday_spec.rb13
-rw-r--r--spec/ruby/core/time/zone_spec.rb21
-rw-r--r--spec/ruby/core/tracepoint/allow_reentry_spec.rb44
-rw-r--r--spec/ruby/core/tracepoint/binding_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/defined_class_spec.rb10
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb91
-rw-r--r--spec/ruby/core/tracepoint/event_spec.rb6
-rw-r--r--spec/ruby/core/tracepoint/inspect_spec.rb27
-rw-r--r--spec/ruby/core/tracepoint/lineno_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/method_id_spec.rb2
-rw-r--r--spec/ruby/core/tracepoint/new_spec.rb22
-rw-r--r--spec/ruby/core/tracepoint/path_spec.rb4
-rw-r--r--spec/ruby/core/tracepoint/raised_exception_spec.rb18
-rw-r--r--spec/ruby/core/tracepoint/self_spec.rb4
-rw-r--r--spec/ruby/core/true/dup_spec.rb2
-rw-r--r--spec/ruby/core/true/singleton_method_spec.rb13
-rw-r--r--spec/ruby/core/true/to_s_spec.rb2
-rw-r--r--spec/ruby/core/true/trueclass_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/bind_call_spec.rb4
-rw-r--r--spec/ruby/core/unboundmethod/bind_spec.rb16
-rw-r--r--spec/ruby/core/unboundmethod/clone_spec.rb13
-rw-r--r--spec/ruby/core/unboundmethod/dup_spec.rb15
-rw-r--r--spec/ruby/core/unboundmethod/equal_value_spec.rb66
-rw-r--r--spec/ruby/core/unboundmethod/fixtures/classes.rb17
-rw-r--r--spec/ruby/core/unboundmethod/inspect_spec.rb2
-rw-r--r--spec/ruby/core/unboundmethod/original_name_spec.rb37
-rw-r--r--spec/ruby/core/unboundmethod/owner_spec.rb6
-rw-r--r--spec/ruby/core/unboundmethod/private_spec.rb20
-rw-r--r--spec/ruby/core/unboundmethod/protected_spec.rb20
-rw-r--r--spec/ruby/core/unboundmethod/public_spec.rb20
-rw-r--r--spec/ruby/core/unboundmethod/shared/dup.rb32
-rw-r--r--spec/ruby/core/unboundmethod/shared/to_s.rb19
-rw-r--r--spec/ruby/core/unboundmethod/source_location_spec.rb13
-rw-r--r--spec/ruby/core/unboundmethod/super_method_spec.rb10
-rw-r--r--spec/ruby/core/unboundmethod/to_s_spec.rb2
-rw-r--r--spec/ruby/core/warning/categories_spec.rb12
-rw-r--r--spec/ruby/core/warning/element_reference_spec.rb25
-rw-r--r--spec/ruby/core/warning/element_set_spec.rb26
-rw-r--r--spec/ruby/core/warning/performance_warning_spec.rb28
-rw-r--r--spec/ruby/core/warning/warn_spec.rb139
-rw-r--r--spec/ruby/default.mspec6
-rw-r--r--spec/ruby/fixtures/code/d/load_fixture.rb.rb1
-rw-r--r--spec/ruby/fixtures/constants.rb2
-rw-r--r--spec/ruby/fixtures/io.rb12
-rw-r--r--spec/ruby/language/BEGIN_spec.rb2
-rw-r--r--spec/ruby/language/alias_spec.rb34
-rw-r--r--spec/ruby/language/and_spec.rb16
-rw-r--r--spec/ruby/language/array_spec.rb18
-rw-r--r--spec/ruby/language/assignments_spec.rb582
-rw-r--r--spec/ruby/language/block_spec.rb538
-rw-r--r--spec/ruby/language/break_spec.rb37
-rw-r--r--spec/ruby/language/case_spec.rb201
-rw-r--r--spec/ruby/language/class_spec.rb121
-rw-r--r--spec/ruby/language/class_variable_spec.rb70
-rw-r--r--spec/ruby/language/constants_spec.rb231
-rw-r--r--spec/ruby/language/def_spec.rb161
-rw-r--r--spec/ruby/language/defined_spec.rb375
-rw-r--r--spec/ruby/language/delegation_spec.rb143
-rw-r--r--spec/ruby/language/encoding_spec.rb12
-rw-r--r--spec/ruby/language/ensure_spec.rb47
-rw-r--r--spec/ruby/language/execution_spec.rb78
-rw-r--r--spec/ruby/language/file_spec.rb6
-rw-r--r--spec/ruby/language/fixtures/class_with_class_variable.rb9
-rw-r--r--spec/ruby/language/fixtures/defined.rb33
-rw-r--r--spec/ruby/language/fixtures/delegation.rb4
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_across_files.rb3
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_across_files_diff_enc.rb3
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_across_files_no_comment.rb3
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_one_literal.rb4
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_required.rb2
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_required_diff_enc.rbbin181 -> 107 bytes-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_required_no_comment.rb2
-rw-r--r--spec/ruby/language/fixtures/module.rb9
-rw-r--r--spec/ruby/language/fixtures/private.rb26
-rw-r--r--spec/ruby/language/fixtures/rescue/top_level.rb7
-rw-r--r--spec/ruby/language/fixtures/send.rb16
-rw-r--r--spec/ruby/language/fixtures/super.rb50
-rw-r--r--spec/ruby/language/fixtures/variables.rb72
-rw-r--r--spec/ruby/language/for_spec.rb202
-rw-r--r--spec/ruby/language/hash_spec.rb208
-rw-r--r--spec/ruby/language/heredoc_spec.rb12
-rw-r--r--spec/ruby/language/if_spec.rb12
-rw-r--r--spec/ruby/language/it_parameter_spec.rb108
-rw-r--r--spec/ruby/language/keyword_arguments_spec.rb573
-rw-r--r--spec/ruby/language/lambda_spec.rb229
-rw-r--r--spec/ruby/language/line_spec.rb2
-rw-r--r--spec/ruby/language/loop_spec.rb2
-rw-r--r--spec/ruby/language/magic_comment_spec.rb3
-rw-r--r--spec/ruby/language/match_spec.rb8
-rw-r--r--spec/ruby/language/metaclass_spec.rb22
-rw-r--r--spec/ruby/language/method_spec.rb1063
-rw-r--r--spec/ruby/language/module_spec.rb93
-rw-r--r--spec/ruby/language/next_spec.rb4
-rw-r--r--spec/ruby/language/not_spec.rb32
-rw-r--r--spec/ruby/language/numbered_parameters_spec.rb97
-rw-r--r--spec/ruby/language/numbers_spec.rb6
-rw-r--r--spec/ruby/language/optional_assignments_spec.rb306
-rw-r--r--spec/ruby/language/or_spec.rb32
-rw-r--r--spec/ruby/language/pattern_matching_spec.rb1569
-rw-r--r--spec/ruby/language/precedence_spec.rb36
-rw-r--r--spec/ruby/language/predefined_spec.rb477
-rw-r--r--spec/ruby/language/private_spec.rb22
-rw-r--r--spec/ruby/language/proc_spec.rb72
-rw-r--r--spec/ruby/language/redo_spec.rb2
-rw-r--r--spec/ruby/language/regexp/anchors_spec.rb62
-rw-r--r--spec/ruby/language/regexp/back-references_spec.rb63
-rw-r--r--spec/ruby/language/regexp/character_classes_spec.rb237
-rw-r--r--spec/ruby/language/regexp/encoding_spec.rb56
-rw-r--r--spec/ruby/language/regexp/escapes_spec.rb12
-rw-r--r--spec/ruby/language/regexp/grouping_spec.rb6
-rw-r--r--spec/ruby/language/regexp/interpolation_spec.rb6
-rw-r--r--spec/ruby/language/regexp/modifiers_spec.rb40
-rw-r--r--spec/ruby/language/regexp/repetition_spec.rb10
-rw-r--r--spec/ruby/language/regexp_spec.rb34
-rw-r--r--spec/ruby/language/rescue_spec.rb135
-rw-r--r--spec/ruby/language/reserved_keywords.rb149
-rw-r--r--spec/ruby/language/retry_spec.rb7
-rw-r--r--spec/ruby/language/return_spec.rb29
-rw-r--r--spec/ruby/language/safe_navigator_spec.rb84
-rw-r--r--spec/ruby/language/safe_spec.rb28
-rw-r--r--spec/ruby/language/send_spec.rb107
-rw-r--r--spec/ruby/language/shared/__FILE__.rb4
-rw-r--r--spec/ruby/language/shared/__LINE__.rb2
-rw-r--r--spec/ruby/language/singleton_class_spec.rb112
-rw-r--r--spec/ruby/language/source_encoding_spec.rb6
-rw-r--r--spec/ruby/language/string_spec.rb58
-rw-r--r--spec/ruby/language/super_spec.rb50
-rw-r--r--spec/ruby/language/symbol_spec.rb34
-rw-r--r--spec/ruby/language/throw_spec.rb10
-rw-r--r--spec/ruby/language/undef_spec.rb23
-rw-r--r--spec/ruby/language/variables_spec.rb144
-rw-r--r--spec/ruby/language/while_spec.rb16
-rw-r--r--spec/ruby/language/yield_spec.rb69
-rw-r--r--spec/ruby/library/English/English_spec.rb62
-rw-r--r--spec/ruby/library/English/alias_spec.rb6
-rw-r--r--spec/ruby/library/base64/strict_decode64_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/BigDecimal_spec.rb80
-rw-r--r--spec/ruby/library/bigdecimal/add_spec.rb18
-rw-r--r--spec/ruby/library/bigdecimal/ceil_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/constants_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/core_spec.rb62
-rw-r--r--spec/ruby/library/bigdecimal/div_spec.rb28
-rw-r--r--spec/ruby/library/bigdecimal/divmod_spec.rb88
-rw-r--r--spec/ruby/library/bigdecimal/fix_spec.rb30
-rw-r--r--spec/ruby/library/bigdecimal/floor_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/gt_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/gte_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/lt_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/lte_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/mode_spec.rb10
-rw-r--r--spec/ruby/library/bigdecimal/mult_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/nonzero_spec.rb10
-rw-r--r--spec/ruby/library/bigdecimal/precs_spec.rb55
-rw-r--r--spec/ruby/library/bigdecimal/remainder_spec.rb29
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb24
-rw-r--r--spec/ruby/library/bigdecimal/shared/clone.rb2
-rw-r--r--spec/ruby/library/bigdecimal/shared/modulo.rb22
-rw-r--r--spec/ruby/library/bigdecimal/shared/power.rb4
-rw-r--r--spec/ruby/library/bigdecimal/shared/quo.rb1
-rw-r--r--spec/ruby/library/bigdecimal/shared/to_int.rb6
-rw-r--r--spec/ruby/library/bigdecimal/split_spec.rb20
-rw-r--r--spec/ruby/library/bigdecimal/sqrt_spec.rb24
-rw-r--r--spec/ruby/library/bigdecimal/sub_spec.rb8
-rw-r--r--spec/ruby/library/bigdecimal/to_f_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/to_i_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/to_r_spec.rb14
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb27
-rw-r--r--spec/ruby/library/bigdecimal/truncate_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/util_spec.rb2
-rw-r--r--spec/ruby/library/bigmath/log_spec.rb10
-rw-r--r--spec/ruby/library/cgi/cookie/domain_spec.rb33
-rw-r--r--spec/ruby/library/cgi/cookie/expires_spec.rb33
-rw-r--r--spec/ruby/library/cgi/cookie/initialize_spec.rb235
-rw-r--r--spec/ruby/library/cgi/cookie/name_spec.rb33
-rw-r--r--spec/ruby/library/cgi/cookie/parse_spec.rb41
-rw-r--r--spec/ruby/library/cgi/cookie/path_spec.rb33
-rw-r--r--spec/ruby/library/cgi/cookie/secure_spec.rb99
-rw-r--r--spec/ruby/library/cgi/cookie/to_s_spec.rb51
-rw-r--r--spec/ruby/library/cgi/cookie/value_spec.rb121
-rw-r--r--spec/ruby/library/cgi/escapeElement_spec.rb8
-rw-r--r--spec/ruby/library/cgi/escapeHTML_spec.rb6
-rw-r--r--spec/ruby/library/cgi/escapeURIComponent_spec.rb78
-rw-r--r--spec/ruby/library/cgi/escape_spec.rb6
-rw-r--r--spec/ruby/library/cgi/htmlextension/a_spec.rb73
-rw-r--r--spec/ruby/library/cgi/htmlextension/base_spec.rb47
-rw-r--r--spec/ruby/library/cgi/htmlextension/blockquote_spec.rb47
-rw-r--r--spec/ruby/library/cgi/htmlextension/br_spec.rb31
-rw-r--r--spec/ruby/library/cgi/htmlextension/caption_spec.rb47
-rw-r--r--spec/ruby/library/cgi/htmlextension/checkbox_group_spec.rb121
-rw-r--r--spec/ruby/library/cgi/htmlextension/checkbox_spec.rb113
-rw-r--r--spec/ruby/library/cgi/htmlextension/doctype_spec.rb41
-rw-r--r--spec/ruby/library/cgi/htmlextension/file_field_spec.rb105
-rw-r--r--spec/ruby/library/cgi/htmlextension/form_spec.rb85
-rw-r--r--spec/ruby/library/cgi/htmlextension/frame_spec.rb21
-rw-r--r--spec/ruby/library/cgi/htmlextension/frameset_spec.rb21
-rw-r--r--spec/ruby/library/cgi/htmlextension/hidden_spec.rb87
-rw-r--r--spec/ruby/library/cgi/htmlextension/html_spec.rb99
-rw-r--r--spec/ruby/library/cgi/htmlextension/image_button_spec.rb101
-rw-r--r--spec/ruby/library/cgi/htmlextension/img_spec.rb123
-rw-r--r--spec/ruby/library/cgi/htmlextension/multipart_form_spec.rb93
-rw-r--r--spec/ruby/library/cgi/htmlextension/password_field_spec.rb123
-rw-r--r--spec/ruby/library/cgi/htmlextension/popup_menu_spec.rb13
-rw-r--r--spec/ruby/library/cgi/htmlextension/radio_button_spec.rb113
-rw-r--r--spec/ruby/library/cgi/htmlextension/radio_group_spec.rb123
-rw-r--r--spec/ruby/library/cgi/htmlextension/reset_spec.rb83
-rw-r--r--spec/ruby/library/cgi/htmlextension/scrolling_list_spec.rb13
-rw-r--r--spec/ruby/library/cgi/htmlextension/submit_spec.rb83
-rw-r--r--spec/ruby/library/cgi/htmlextension/text_field_spec.rb123
-rw-r--r--spec/ruby/library/cgi/htmlextension/textarea_spec.rb107
-rw-r--r--spec/ruby/library/cgi/http_header_spec.rb11
-rw-r--r--spec/ruby/library/cgi/initialize_spec.rb209
-rw-r--r--spec/ruby/library/cgi/out_spec.rb97
-rw-r--r--spec/ruby/library/cgi/parse_spec.rb37
-rw-r--r--spec/ruby/library/cgi/pretty_spec.rb19
-rw-r--r--spec/ruby/library/cgi/print_spec.rb39
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_charset_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_encoding_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_language_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/accept_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/auth_type_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/cache_control_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/content_length_spec.rb39
-rw-r--r--spec/ruby/library/cgi/queryextension/content_type_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/cookies_spec.rb15
-rw-r--r--spec/ruby/library/cgi/queryextension/element_reference_spec.rb41
-rw-r--r--spec/ruby/library/cgi/queryextension/from_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/gateway_interface_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/has_key_spec.rb11
-rw-r--r--spec/ruby/library/cgi/queryextension/host_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/include_spec.rb11
-rw-r--r--spec/ruby/library/cgi/queryextension/key_spec.rb11
-rw-r--r--spec/ruby/library/cgi/queryextension/keys_spec.rb29
-rw-r--r--spec/ruby/library/cgi/queryextension/multipart_spec.rb47
-rw-r--r--spec/ruby/library/cgi/queryextension/negotiate_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/params_spec.rb55
-rw-r--r--spec/ruby/library/cgi/queryextension/path_info_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/path_translated_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/pragma_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/query_string_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/raw_cookie2_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/raw_cookie_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/referer_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_addr_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_host_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_ident_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/remote_user_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/request_method_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/script_name_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/server_name_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/server_port_spec.rb39
-rw-r--r--spec/ruby/library/cgi/queryextension/server_protocol_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/server_software_spec.rb33
-rw-r--r--spec/ruby/library/cgi/queryextension/shared/has_key.rb6
-rw-r--r--spec/ruby/library/cgi/queryextension/user_agent_spec.rb33
-rw-r--r--spec/ruby/library/cgi/rfc1123_date_spec.rb15
-rw-r--r--spec/ruby/library/cgi/shared/http_header.rb10
-rw-r--r--spec/ruby/library/cgi/unescapeElement_spec.rb8
-rw-r--r--spec/ruby/library/cgi/unescapeHTML_spec.rb6
-rw-r--r--spec/ruby/library/cgi/unescapeURIComponent_spec.rb128
-rw-r--r--spec/ruby/library/cgi/unescape_spec.rb8
-rw-r--r--spec/ruby/library/coverage/fixtures/code_with_begin.rb3
-rw-r--r--spec/ruby/library/coverage/result_spec.rb316
-rw-r--r--spec/ruby/library/coverage/start_spec.rb87
-rw-r--r--spec/ruby/library/coverage/supported_spec.rb30
-rw-r--r--spec/ruby/library/csv/generate_spec.rb4
-rw-r--r--spec/ruby/library/csv/parse_spec.rb4
-rw-r--r--spec/ruby/library/csv/readlines_spec.rb2
-rw-r--r--spec/ruby/library/date/accessor_spec.rb2
-rw-r--r--spec/ruby/library/date/add_month_spec.rb8
-rw-r--r--spec/ruby/library/date/add_spec.rb8
-rw-r--r--spec/ruby/library/date/constants_spec.rb4
-rw-r--r--spec/ruby/library/date/deconstruct_keys_spec.rb42
-rw-r--r--spec/ruby/library/date/eql_spec.rb4
-rw-r--r--spec/ruby/library/date/friday_spec.rb4
-rw-r--r--spec/ruby/library/date/gregorian_leap_spec.rb10
-rw-r--r--spec/ruby/library/date/gregorian_spec.rb6
-rw-r--r--spec/ruby/library/date/iso8601_spec.rb23
-rw-r--r--spec/ruby/library/date/julian_leap_spec.rb10
-rw-r--r--spec/ruby/library/date/julian_spec.rb4
-rw-r--r--spec/ruby/library/date/minus_month_spec.rb8
-rw-r--r--spec/ruby/library/date/minus_spec.rb6
-rw-r--r--spec/ruby/library/date/mon_spec.rb3
-rw-r--r--spec/ruby/library/date/monday_spec.rb2
-rw-r--r--spec/ruby/library/date/month_spec.rb6
-rw-r--r--spec/ruby/library/date/new_spec.rb1
-rw-r--r--spec/ruby/library/date/parse_spec.rb16
-rw-r--r--spec/ruby/library/date/plus_spec.rb2
-rw-r--r--spec/ruby/library/date/saturday_spec.rb2
-rw-r--r--spec/ruby/library/date/shared/civil.rb16
-rw-r--r--spec/ruby/library/date/shared/commercial.rb18
-rw-r--r--spec/ruby/library/date/shared/month.rb6
-rw-r--r--spec/ruby/library/date/shared/new_bang.rb14
-rw-r--r--spec/ruby/library/date/shared/parse.rb4
-rw-r--r--spec/ruby/library/date/shared/parse_eu.rb8
-rw-r--r--spec/ruby/library/date/shared/parse_us.rb8
-rw-r--r--spec/ruby/library/date/shared/valid_civil.rb16
-rw-r--r--spec/ruby/library/date/shared/valid_commercial.rb24
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb14
-rw-r--r--spec/ruby/library/date/strftime_spec.rb17
-rw-r--r--spec/ruby/library/date/sunday_spec.rb2
-rw-r--r--spec/ruby/library/date/thursday_spec.rb2
-rw-r--r--spec/ruby/library/date/time/to_date_spec.rb42
-rw-r--r--spec/ruby/library/date/today_spec.rb2
-rw-r--r--spec/ruby/library/date/tuesday_spec.rb2
-rw-r--r--spec/ruby/library/date/wednesday_spec.rb2
-rw-r--r--spec/ruby/library/date/yday_spec.rb3
-rw-r--r--spec/ruby/library/datetime/deconstruct_keys_spec.rb44
-rw-r--r--spec/ruby/library/datetime/hour_spec.rb10
-rw-r--r--spec/ruby/library/datetime/new_spec.rb2
-rw-r--r--spec/ruby/library/datetime/now_spec.rb2
-rw-r--r--spec/ruby/library/datetime/parse_spec.rb12
-rw-r--r--spec/ruby/library/datetime/rfc2822_spec.rb4
-rw-r--r--spec/ruby/library/datetime/shared/min.rb10
-rw-r--r--spec/ruby/library/datetime/shared/sec.rb6
-rw-r--r--spec/ruby/library/datetime/strftime_spec.rb17
-rw-r--r--spec/ruby/library/datetime/time/to_datetime_spec.rb40
-rw-r--r--spec/ruby/library/datetime/to_date_spec.rb2
-rw-r--r--spec/ruby/library/datetime/to_s_spec.rb2
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb24
-rw-r--r--spec/ruby/library/datetime/yday_spec.rb7
-rw-r--r--spec/ruby/library/delegate/delegate_class/instance_method_spec.rb14
-rw-r--r--spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb12
-rw-r--r--spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb12
-rw-r--r--spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb12
-rw-r--r--spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb10
-rw-r--r--spec/ruby/library/delegate/delegator/eql_spec.rb8
-rw-r--r--spec/ruby/library/delegate/delegator/equal_spec.rb6
-rw-r--r--spec/ruby/library/delegate/delegator/equal_value_spec.rb6
-rw-r--r--spec/ruby/library/delegate/delegator/frozen_spec.rb14
-rw-r--r--spec/ruby/library/delegate/delegator/marshal_spec.rb2
-rw-r--r--spec/ruby/library/delegate/delegator/method_spec.rb18
-rw-r--r--spec/ruby/library/delegate/delegator/methods_spec.rb14
-rw-r--r--spec/ruby/library/delegate/delegator/not_equal_spec.rb6
-rw-r--r--spec/ruby/library/delegate/delegator/private_methods_spec.rb8
-rw-r--r--spec/ruby/library/delegate/delegator/protected_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/public_methods_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegator/send_spec.rb8
-rw-r--r--spec/ruby/library/delegate/delegator/tap_spec.rb2
-rw-r--r--spec/ruby/library/digest/bubblebabble_spec.rb6
-rw-r--r--spec/ruby/library/digest/hexencode_spec.rb4
-rw-r--r--spec/ruby/library/digest/instance/shared/update.rb2
-rw-r--r--spec/ruby/library/digest/md5/append_spec.rb2
-rw-r--r--spec/ruby/library/digest/md5/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/md5/shared/constants.rb2
-rw-r--r--spec/ruby/library/digest/md5/shared/sample.rb17
-rw-r--r--spec/ruby/library/digest/sha1/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha1/shared/constants.rb2
-rw-r--r--spec/ruby/library/digest/sha256/append_spec.rb2
-rw-r--r--spec/ruby/library/digest/sha256/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha256/shared/constants.rb2
-rw-r--r--spec/ruby/library/digest/sha384/append_spec.rb2
-rw-r--r--spec/ruby/library/digest/sha384/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha384/shared/constants.rb2
-rw-r--r--spec/ruby/library/digest/sha512/append_spec.rb2
-rw-r--r--spec/ruby/library/digest/sha512/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha512/shared/constants.rb2
-rw-r--r--spec/ruby/library/drb/start_service_spec.rb47
-rw-r--r--spec/ruby/library/erb/def_class_spec.rb2
-rw-r--r--spec/ruby/library/erb/def_module_spec.rb3
-rw-r--r--spec/ruby/library/erb/defmethod/def_erb_method_spec.rb2
-rw-r--r--spec/ruby/library/erb/filename_spec.rb4
-rw-r--r--spec/ruby/library/erb/new_spec.rb10
-rw-r--r--spec/ruby/library/erb/result_spec.rb4
-rw-r--r--spec/ruby/library/erb/run_spec.rb6
-rw-r--r--spec/ruby/library/etc/confstr_spec.rb4
-rw-r--r--spec/ruby/library/etc/getgrgid_spec.rb8
-rw-r--r--spec/ruby/library/etc/getgrnam_spec.rb2
-rw-r--r--spec/ruby/library/etc/getlogin_spec.rb4
-rw-r--r--spec/ruby/library/etc/getpwnam_spec.rb2
-rw-r--r--spec/ruby/library/etc/getpwuid_spec.rb2
-rw-r--r--spec/ruby/library/etc/group_spec.rb4
-rw-r--r--spec/ruby/library/etc/nprocessors_spec.rb2
-rw-r--r--spec/ruby/library/etc/passwd_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconf_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconfdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/systmpdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/uname_spec.rb14
-rw-r--r--spec/ruby/library/expect/expect_spec.rb4
-rw-r--r--spec/ruby/library/fiber/alive_spec.rb46
-rw-r--r--spec/ruby/library/fiber/current_spec.rb63
-rw-r--r--spec/ruby/library/fiber/resume_spec.rb35
-rw-r--r--spec/ruby/library/fiber/transfer_spec.rb128
-rw-r--r--spec/ruby/library/fiddle/handle/initialize_spec.rb2
-rw-r--r--spec/ruby/library/find/find_spec.rb2
-rw-r--r--spec/ruby/library/find/fixtures/common.rb14
-rw-r--r--spec/ruby/library/getoptlong/error_message_spec.rb2
-rw-r--r--spec/ruby/library/getoptlong/ordering_spec.rb4
-rw-r--r--spec/ruby/library/getoptlong/set_options_spec.rb14
-rw-r--r--spec/ruby/library/getoptlong/shared/get.rb2
-rw-r--r--spec/ruby/library/io-wait/wait_readable_spec.rb23
-rw-r--r--spec/ruby/library/io-wait/wait_spec.rb162
-rw-r--r--spec/ruby/library/io-wait/wait_writable_spec.rb25
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb46
-rw-r--r--spec/ruby/library/ipaddr/operator_spec.rb16
-rw-r--r--spec/ruby/library/ipaddr/reverse_spec.rb4
-rw-r--r--spec/ruby/library/irb/fixtures/irb.rb3
-rw-r--r--spec/ruby/library/irb/irb_spec.rb19
-rw-r--r--spec/ruby/library/logger/device/close_spec.rb15
-rw-r--r--spec/ruby/library/logger/device/new_spec.rb8
-rw-r--r--spec/ruby/library/logger/device/write_spec.rb15
-rw-r--r--spec/ruby/library/logger/logger/add_spec.rb6
-rw-r--r--spec/ruby/library/logger/logger/datetime_format_spec.rb2
-rw-r--r--spec/ruby/library/logger/logger/new_spec.rb32
-rw-r--r--spec/ruby/library/logger/logger/unknown_spec.rb2
-rw-r--r--spec/ruby/library/matrix/I_spec.rb9
-rw-r--r--spec/ruby/library/matrix/antisymmetric_spec.rb54
-rw-r--r--spec/ruby/library/matrix/build_spec.rb117
-rw-r--r--spec/ruby/library/matrix/clone_spec.rb37
-rw-r--r--spec/ruby/library/matrix/coerce_spec.rb11
-rw-r--r--spec/ruby/library/matrix/collect_spec.rb9
-rw-r--r--spec/ruby/library/matrix/column_size_spec.rb19
-rw-r--r--spec/ruby/library/matrix/column_spec.rb53
-rw-r--r--spec/ruby/library/matrix/column_vector_spec.rb37
-rw-r--r--spec/ruby/library/matrix/column_vectors_spec.rb37
-rw-r--r--spec/ruby/library/matrix/columns_spec.rb67
-rw-r--r--spec/ruby/library/matrix/conj_spec.rb9
-rw-r--r--spec/ruby/library/matrix/conjugate_spec.rb9
-rw-r--r--spec/ruby/library/matrix/constructor_spec.rb101
-rw-r--r--spec/ruby/library/matrix/det_spec.rb11
-rw-r--r--spec/ruby/library/matrix/determinant_spec.rb11
-rw-r--r--spec/ruby/library/matrix/diagonal_spec.rb105
-rw-r--r--spec/ruby/library/matrix/divide_spec.rb83
-rw-r--r--spec/ruby/library/matrix/each_spec.rb119
-rw-r--r--spec/ruby/library/matrix/each_with_index_spec.rb133
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb13
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb35
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb33
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb37
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb39
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb27
-rw-r--r--spec/ruby/library/matrix/element_reference_spec.rb31
-rw-r--r--spec/ruby/library/matrix/empty_spec.rb107
-rw-r--r--spec/ruby/library/matrix/eql_spec.rb15
-rw-r--r--spec/ruby/library/matrix/equal_value_spec.rb15
-rw-r--r--spec/ruby/library/matrix/exponent_spec.rb97
-rw-r--r--spec/ruby/library/matrix/find_index_spec.rb221
-rw-r--r--spec/ruby/library/matrix/hash_spec.rb21
-rw-r--r--spec/ruby/library/matrix/hermitian_spec.rb53
-rw-r--r--spec/ruby/library/matrix/identity_spec.rb9
-rw-r--r--spec/ruby/library/matrix/imag_spec.rb9
-rw-r--r--spec/ruby/library/matrix/imaginary_spec.rb9
-rw-r--r--spec/ruby/library/matrix/inspect_spec.rb39
-rw-r--r--spec/ruby/library/matrix/inv_spec.rb11
-rw-r--r--spec/ruby/library/matrix/inverse_from_spec.rb9
-rw-r--r--spec/ruby/library/matrix/inverse_spec.rb11
-rw-r--r--spec/ruby/library/matrix/lower_triangular_spec.rb39
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb33
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb21
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/l_spec.rb27
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/p_spec.rb27
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/solve_spec.rb85
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb53
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/u_spec.rb27
-rw-r--r--spec/ruby/library/matrix/map_spec.rb9
-rw-r--r--spec/ruby/library/matrix/minor_spec.rb135
-rw-r--r--spec/ruby/library/matrix/minus_spec.rb65
-rw-r--r--spec/ruby/library/matrix/multiply_spec.rb104
-rw-r--r--spec/ruby/library/matrix/new_spec.rb11
-rw-r--r--spec/ruby/library/matrix/normal_spec.rb41
-rw-r--r--spec/ruby/library/matrix/orthogonal_spec.rb41
-rw-r--r--spec/ruby/library/matrix/permutation_spec.rb51
-rw-r--r--spec/ruby/library/matrix/plus_spec.rb65
-rw-r--r--spec/ruby/library/matrix/rank_spec.rb29
-rw-r--r--spec/ruby/library/matrix/real_spec.rb63
-rw-r--r--spec/ruby/library/matrix/rect_spec.rb9
-rw-r--r--spec/ruby/library/matrix/rectangular_spec.rb9
-rw-r--r--spec/ruby/library/matrix/regular_spec.rb45
-rw-r--r--spec/ruby/library/matrix/round_spec.rb31
-rw-r--r--spec/ruby/library/matrix/row_size_spec.rb19
-rw-r--r--spec/ruby/library/matrix/row_spec.rb55
-rw-r--r--spec/ruby/library/matrix/row_vector_spec.rb33
-rw-r--r--spec/ruby/library/matrix/row_vectors_spec.rb37
-rw-r--r--spec/ruby/library/matrix/rows_spec.rb65
-rw-r--r--spec/ruby/library/matrix/scalar/Fail_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/Raise_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/divide_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/exponent_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/included_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/initialize_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/minus_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/multiply_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar/plus_spec.rb9
-rw-r--r--spec/ruby/library/matrix/scalar_spec.rb93
-rw-r--r--spec/ruby/library/matrix/shared/collect.rb6
-rw-r--r--spec/ruby/library/matrix/shared/conjugate.rb2
-rw-r--r--spec/ruby/library/matrix/shared/determinant.rb4
-rw-r--r--spec/ruby/library/matrix/shared/equal_value.rb20
-rw-r--r--spec/ruby/library/matrix/shared/identity.rb4
-rw-r--r--spec/ruby/library/matrix/shared/imaginary.rb2
-rw-r--r--spec/ruby/library/matrix/shared/inverse.rb6
-rw-r--r--spec/ruby/library/matrix/shared/rectangular.rb2
-rw-r--r--spec/ruby/library/matrix/shared/trace.rb2
-rw-r--r--spec/ruby/library/matrix/shared/transpose.rb2
-rw-r--r--spec/ruby/library/matrix/singular_spec.rb47
-rw-r--r--spec/ruby/library/matrix/square_spec.rb41
-rw-r--r--spec/ruby/library/matrix/symmetric_spec.rb45
-rw-r--r--spec/ruby/library/matrix/t_spec.rb9
-rw-r--r--spec/ruby/library/matrix/to_a_spec.rb17
-rw-r--r--spec/ruby/library/matrix/to_s_spec.rb9
-rw-r--r--spec/ruby/library/matrix/tr_spec.rb11
-rw-r--r--spec/ruby/library/matrix/trace_spec.rb11
-rw-r--r--spec/ruby/library/matrix/transpose_spec.rb9
-rw-r--r--spec/ruby/library/matrix/unit_spec.rb9
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb50
-rw-r--r--spec/ruby/library/matrix/upper_triangular_spec.rb39
-rw-r--r--spec/ruby/library/matrix/vector/cross_product_spec.rb21
-rw-r--r--spec/ruby/library/matrix/vector/each2_spec.rb81
-rw-r--r--spec/ruby/library/matrix/vector/eql_spec.rb23
-rw-r--r--spec/ruby/library/matrix/vector/inner_product_spec.rb33
-rw-r--r--spec/ruby/library/matrix/vector/normalize_spec.rb29
-rw-r--r--spec/ruby/library/matrix/zero_spec.rb75
-rw-r--r--spec/ruby/library/monitor/exit_spec.rb10
-rw-r--r--spec/ruby/library/monitor/mon_initialize_spec.rb2
-rw-r--r--spec/ruby/library/monitor/synchronize_spec.rb4
-rw-r--r--spec/ruby/library/net-ftp/FTPError_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/FTPPermError_spec.rb15
-rw-r--r--spec/ruby/library/net-ftp/FTPProtoError_spec.rb15
-rw-r--r--spec/ruby/library/net-ftp/FTPReplyError_spec.rb15
-rw-r--r--spec/ruby/library/net-ftp/FTPTempError_spec.rb15
-rw-r--r--spec/ruby/library/net-ftp/abort_spec.rb65
-rw-r--r--spec/ruby/library/net-ftp/acct_spec.rb61
-rw-r--r--spec/ruby/library/net-ftp/binary_spec.rb27
-rw-r--r--spec/ruby/library/net-ftp/chdir_spec.rb102
-rw-r--r--spec/ruby/library/net-ftp/close_spec.rb33
-rw-r--r--spec/ruby/library/net-ftp/closed_spec.rb24
-rw-r--r--spec/ruby/library/net-ftp/connect_spec.rb46
-rw-r--r--spec/ruby/library/net-ftp/debug_mode_spec.rb26
-rw-r--r--spec/ruby/library/net-ftp/default_passive_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/delete_spec.rb62
-rw-r--r--spec/ruby/library/net-ftp/dir_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/fixtures/default_passive.rb (renamed from spec/ruby/library/net/ftp/fixtures/default_passive.rb)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/passive.rb (renamed from spec/ruby/library/net/ftp/fixtures/passive.rb)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/putbinaryfile (renamed from spec/ruby/library/net/ftp/fixtures/putbinaryfile)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/puttextfile (renamed from spec/ruby/library/net/ftp/fixtures/puttextfile)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/server.rb279
-rw-r--r--spec/ruby/library/net-ftp/get_spec.rb24
-rw-r--r--spec/ruby/library/net-ftp/getbinaryfile_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/getdir_spec.rb10
-rw-r--r--spec/ruby/library/net-ftp/gettextfile_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/help_spec.rb69
-rw-r--r--spec/ruby/library/net-ftp/initialize_spec.rb408
-rw-r--r--spec/ruby/library/net-ftp/last_response_code_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/last_response_spec.rb28
-rw-r--r--spec/ruby/library/net-ftp/lastresp_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/list_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/login_spec.rb198
-rw-r--r--spec/ruby/library/net-ftp/ls_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/mdtm_spec.rb41
-rw-r--r--spec/ruby/library/net-ftp/mkdir_spec.rb64
-rw-r--r--spec/ruby/library/net-ftp/mtime_spec.rb53
-rw-r--r--spec/ruby/library/net-ftp/nlst_spec.rb95
-rw-r--r--spec/ruby/library/net-ftp/noop_spec.rb41
-rw-r--r--spec/ruby/library/net-ftp/open_spec.rb58
-rw-r--r--spec/ruby/library/net-ftp/passive_spec.rb31
-rw-r--r--spec/ruby/library/net-ftp/put_spec.rb24
-rw-r--r--spec/ruby/library/net-ftp/putbinaryfile_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/puttextfile_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/pwd_spec.rb56
-rw-r--r--spec/ruby/library/net-ftp/quit_spec.rb36
-rw-r--r--spec/ruby/library/net-ftp/rename_spec.rb97
-rw-r--r--spec/ruby/library/net-ftp/resume_spec.rb26
-rw-r--r--spec/ruby/library/net-ftp/retrbinary_spec.rb33
-rw-r--r--spec/ruby/library/net-ftp/retrlines_spec.rb37
-rw-r--r--spec/ruby/library/net-ftp/return_code_spec.rb27
-rw-r--r--spec/ruby/library/net-ftp/rmdir_spec.rb61
-rw-r--r--spec/ruby/library/net-ftp/sendcmd_spec.rb57
-rw-r--r--spec/ruby/library/net-ftp/set_socket_spec.rb11
-rw-r--r--spec/ruby/library/net-ftp/shared/getbinaryfile.rb152
-rw-r--r--spec/ruby/library/net-ftp/shared/gettextfile.rb102
-rw-r--r--spec/ruby/library/net-ftp/shared/last_response_code.rb27
-rw-r--r--spec/ruby/library/net-ftp/shared/list.rb106
-rw-r--r--spec/ruby/library/net-ftp/shared/putbinaryfile.rb169
-rw-r--r--spec/ruby/library/net-ftp/shared/puttextfile.rb130
-rw-r--r--spec/ruby/library/net-ftp/shared/pwd.rb5
-rw-r--r--spec/ruby/library/net-ftp/site_spec.rb56
-rw-r--r--spec/ruby/library/net-ftp/size_spec.rb51
-rw-r--r--spec/ruby/library/net-ftp/spec_helper.rb7
-rw-r--r--spec/ruby/library/net-ftp/status_spec.rb70
-rw-r--r--spec/ruby/library/net-ftp/storbinary_spec.rb52
-rw-r--r--spec/ruby/library/net-ftp/storlines_spec.rb47
-rw-r--r--spec/ruby/library/net-ftp/system_spec.rb51
-rw-r--r--spec/ruby/library/net-ftp/voidcmd_spec.rb57
-rw-r--r--spec/ruby/library/net-ftp/welcome_spec.rb28
-rw-r--r--spec/ruby/library/net-http/HTTPBadResponse_spec.rb8
-rw-r--r--spec/ruby/library/net-http/HTTPClientExcepton_spec.rb12
-rw-r--r--spec/ruby/library/net-http/HTTPError_spec.rb12
-rw-r--r--spec/ruby/library/net-http/HTTPFatalError_spec.rb12
-rw-r--r--spec/ruby/library/net-http/HTTPHeaderSyntaxError_spec.rb8
-rw-r--r--spec/ruby/library/net-http/HTTPRetriableError_spec.rb12
-rw-r--r--spec/ruby/library/net-http/HTTPServerException_spec.rb12
-rw-r--r--spec/ruby/library/net-http/http/Proxy_spec.rb35
-rw-r--r--spec/ruby/library/net-http/http/active_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/address_spec.rb9
-rw-r--r--spec/ruby/library/net-http/http/close_on_empty_response_spec.rb10
-rw-r--r--spec/ruby/library/net-http/http/copy_spec.rb21
-rw-r--r--spec/ruby/library/net-http/http/default_port_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/delete_spec.rb21
-rw-r--r--spec/ruby/library/net-http/http/finish_spec.rb29
-rw-r--r--spec/ruby/library/net-http/http/fixtures/http_server.rb (renamed from spec/ruby/library/net/http/http/fixtures/http_server.rb)0
-rw-r--r--spec/ruby/library/net-http/http/get2_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/get_print_spec.rb30
-rw-r--r--spec/ruby/library/net-http/http/get_response_spec.rb30
-rw-r--r--spec/ruby/library/net-http/http/get_spec.rb94
-rw-r--r--spec/ruby/library/net-http/http/head2_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/head_spec.rb25
-rw-r--r--spec/ruby/library/net-http/http/http_default_port_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/https_default_port_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/initialize_spec.rb46
-rw-r--r--spec/ruby/library/net-http/http/inspect_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/is_version_1_1_spec.rb7
-rw-r--r--spec/ruby/library/net-http/http/is_version_1_2_spec.rb7
-rw-r--r--spec/ruby/library/net-http/http/lock_spec.rb21
-rw-r--r--spec/ruby/library/net-http/http/mkcol_spec.rb21
-rw-r--r--spec/ruby/library/net-http/http/move_spec.rb25
-rw-r--r--spec/ruby/library/net-http/http/new_spec.rb86
-rw-r--r--spec/ruby/library/net-http/http/newobj_spec.rb48
-rw-r--r--spec/ruby/library/net-http/http/open_timeout_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/options_spec.rb25
-rw-r--r--spec/ruby/library/net-http/http/port_spec.rb9
-rw-r--r--spec/ruby/library/net-http/http/post2_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/post_form_spec.rb22
-rw-r--r--spec/ruby/library/net-http/http/post_spec.rb76
-rw-r--r--spec/ruby/library/net-http/http/propfind_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/proppatch_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/proxy_address_spec.rb31
-rw-r--r--spec/ruby/library/net-http/http/proxy_class_spec.rb9
-rw-r--r--spec/ruby/library/net-http/http/proxy_pass_spec.rb39
-rw-r--r--spec/ruby/library/net-http/http/proxy_port_spec.rb39
-rw-r--r--spec/ruby/library/net-http/http/proxy_user_spec.rb39
-rw-r--r--spec/ruby/library/net-http/http/put2_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/put_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/read_timeout_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/request_get_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/request_head_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/request_post_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/request_put_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/request_spec.rb109
-rw-r--r--spec/ruby/library/net-http/http/request_types_spec.rb254
-rw-r--r--spec/ruby/library/net-http/http/send_request_spec.rb61
-rw-r--r--spec/ruby/library/net-http/http/set_debug_output_spec.rb33
-rw-r--r--spec/ruby/library/net-http/http/shared/request_get.rb41
-rw-r--r--spec/ruby/library/net-http/http/shared/request_head.rb41
-rw-r--r--spec/ruby/library/net-http/http/shared/request_post.rb41
-rw-r--r--spec/ruby/library/net-http/http/shared/request_put.rb41
-rw-r--r--spec/ruby/library/net-http/http/shared/started.rb26
-rw-r--r--spec/ruby/library/net-http/http/shared/version_1_1.rb6
-rw-r--r--spec/ruby/library/net-http/http/shared/version_1_2.rb6
-rw-r--r--spec/ruby/library/net-http/http/socket_type_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/start_spec.rb111
-rw-r--r--spec/ruby/library/net-http/http/started_spec.rb8
-rw-r--r--spec/ruby/library/net-http/http/trace_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/unlock_spec.rb24
-rw-r--r--spec/ruby/library/net-http/http/use_ssl_spec.rb9
-rw-r--r--spec/ruby/library/net-http/http/version_1_1_spec.rb7
-rw-r--r--spec/ruby/library/net-http/http/version_1_2_spec.rb20
-rw-r--r--spec/ruby/library/net-http/httpexceptions/fixtures/classes.rb (renamed from spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb)0
-rw-r--r--spec/ruby/library/net-http/httpexceptions/initialize_spec.rb17
-rw-r--r--spec/ruby/library/net-http/httpexceptions/response_spec.rb10
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb21
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_spec.rb30
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb32
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb135
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/inspect_spec.rb25
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/method_spec.rb15
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/path_spec.rb12
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb12
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb12
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb21
-rw-r--r--spec/ruby/library/net-http/httpheader/add_field_spec.rb31
-rw-r--r--spec/ruby/library/net-http/httpheader/basic_auth_spec.rb14
-rw-r--r--spec/ruby/library/net-http/httpheader/canonical_each_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/chunked_spec.rb22
-rw-r--r--spec/ruby/library/net-http/httpheader/content_length_spec.rb54
-rw-r--r--spec/ruby/library/net-http/httpheader/content_range_spec.rb32
-rw-r--r--spec/ruby/library/net-http/httpheader/content_type_spec.rb26
-rw-r--r--spec/ruby/library/net-http/httpheader/delete_spec.rb30
-rw-r--r--spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb35
-rw-r--r--spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/each_header_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/each_key_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/each_name_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/each_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/each_value_spec.rb35
-rw-r--r--spec/ruby/library/net-http/httpheader/element_reference_spec.rb39
-rw-r--r--spec/ruby/library/net-http/httpheader/element_set_spec.rb41
-rw-r--r--spec/ruby/library/net-http/httpheader/fetch_spec.rb68
-rw-r--r--spec/ruby/library/net-http/httpheader/fixtures/classes.rb (renamed from spec/ruby/library/net/http/httpheader/fixtures/classes.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/form_data_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/get_fields_spec.rb39
-rw-r--r--spec/ruby/library/net-http/httpheader/initialize_http_header_spec.rb21
-rw-r--r--spec/ruby/library/net-http/httpheader/key_spec.rb21
-rw-r--r--spec/ruby/library/net-http/httpheader/length_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/main_type_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httpheader/proxy_basic_auth_spec.rb14
-rw-r--r--spec/ruby/library/net-http/httpheader/range_length_spec.rb32
-rw-r--r--spec/ruby/library/net-http/httpheader/range_spec.rb48
-rw-r--r--spec/ruby/library/net-http/httpheader/set_content_type_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/set_form_data_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/set_range_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb31
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_header.rb31
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_name.rb31
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_content_type.rb (renamed from spec/ruby/library/net/http/httpheader/shared/set_content_type.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_form_data.rb (renamed from spec/ruby/library/net/http/httpheader/shared/set_form_data.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_range.rb89
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/size.rb18
-rw-r--r--spec/ruby/library/net-http/httpheader/size_spec.rb8
-rw-r--r--spec/ruby/library/net-http/httpheader/sub_type_spec.rb32
-rw-r--r--spec/ruby/library/net-http/httpheader/to_hash_spec.rb25
-rw-r--r--spec/ruby/library/net-http/httpheader/type_params_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httprequest/initialize_spec.rb45
-rw-r--r--spec/ruby/library/net-http/httpresponse/body_permitted_spec.rb13
-rw-r--r--spec/ruby/library/net-http/httpresponse/body_spec.rb7
-rw-r--r--spec/ruby/library/net-http/httpresponse/code_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httpresponse/code_type_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httpresponse/entity_spec.rb7
-rw-r--r--spec/ruby/library/net-http/httpresponse/error_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httpresponse/error_type_spec.rb24
-rw-r--r--spec/ruby/library/net-http/httpresponse/exception_type_spec.rb13
-rw-r--r--spec/ruby/library/net-http/httpresponse/header_spec.rb9
-rw-r--r--spec/ruby/library/net-http/httpresponse/http_version_spec.rb12
-rw-r--r--spec/ruby/library/net-http/httpresponse/initialize_spec.rb11
-rw-r--r--spec/ruby/library/net-http/httpresponse/inspect_spec.rb15
-rw-r--r--spec/ruby/library/net-http/httpresponse/message_spec.rb9
-rw-r--r--spec/ruby/library/net-http/httpresponse/msg_spec.rb9
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_body_spec.rb86
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_header_spec.rb9
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_new_spec.rb23
-rw-r--r--spec/ruby/library/net-http/httpresponse/reading_body_spec.rb58
-rw-r--r--spec/ruby/library/net-http/httpresponse/response_spec.rb9
-rw-r--r--spec/ruby/library/net-http/httpresponse/shared/body.rb20
-rw-r--r--spec/ruby/library/net-http/httpresponse/value_spec.rb24
-rw-r--r--spec/ruby/library/net/FTPError_spec.rb11
-rw-r--r--spec/ruby/library/net/FTPPermError_spec.rb15
-rw-r--r--spec/ruby/library/net/FTPProtoError_spec.rb15
-rw-r--r--spec/ruby/library/net/FTPReplyError_spec.rb15
-rw-r--r--spec/ruby/library/net/FTPTempError_spec.rb15
-rw-r--r--spec/ruby/library/net/ftp/abort_spec.rb65
-rw-r--r--spec/ruby/library/net/ftp/acct_spec.rb61
-rw-r--r--spec/ruby/library/net/ftp/binary_spec.rb27
-rw-r--r--spec/ruby/library/net/ftp/chdir_spec.rb102
-rw-r--r--spec/ruby/library/net/ftp/close_spec.rb33
-rw-r--r--spec/ruby/library/net/ftp/closed_spec.rb24
-rw-r--r--spec/ruby/library/net/ftp/connect_spec.rb52
-rw-r--r--spec/ruby/library/net/ftp/debug_mode_spec.rb26
-rw-r--r--spec/ruby/library/net/ftp/default_passive_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/delete_spec.rb62
-rw-r--r--spec/ruby/library/net/ftp/dir_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/fixtures/server.rb277
-rw-r--r--spec/ruby/library/net/ftp/get_spec.rb24
-rw-r--r--spec/ruby/library/net/ftp/getbinaryfile_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/getdir_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/gettextfile_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/help_spec.rb69
-rw-r--r--spec/ruby/library/net/ftp/initialize_spec.rb408
-rw-r--r--spec/ruby/library/net/ftp/last_response_code_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/last_response_spec.rb28
-rw-r--r--spec/ruby/library/net/ftp/lastresp_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/list_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/login_spec.rb198
-rw-r--r--spec/ruby/library/net/ftp/ls_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/mdtm_spec.rb41
-rw-r--r--spec/ruby/library/net/ftp/mkdir_spec.rb64
-rw-r--r--spec/ruby/library/net/ftp/mtime_spec.rb53
-rw-r--r--spec/ruby/library/net/ftp/nlst_spec.rb95
-rw-r--r--spec/ruby/library/net/ftp/noop_spec.rb41
-rw-r--r--spec/ruby/library/net/ftp/open_spec.rb58
-rw-r--r--spec/ruby/library/net/ftp/passive_spec.rb31
-rw-r--r--spec/ruby/library/net/ftp/put_spec.rb24
-rw-r--r--spec/ruby/library/net/ftp/putbinaryfile_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/puttextfile_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/pwd_spec.rb56
-rw-r--r--spec/ruby/library/net/ftp/quit_spec.rb36
-rw-r--r--spec/ruby/library/net/ftp/rename_spec.rb97
-rw-r--r--spec/ruby/library/net/ftp/resume_spec.rb26
-rw-r--r--spec/ruby/library/net/ftp/retrbinary_spec.rb33
-rw-r--r--spec/ruby/library/net/ftp/retrlines_spec.rb37
-rw-r--r--spec/ruby/library/net/ftp/return_code_spec.rb27
-rw-r--r--spec/ruby/library/net/ftp/rmdir_spec.rb61
-rw-r--r--spec/ruby/library/net/ftp/sendcmd_spec.rb57
-rw-r--r--spec/ruby/library/net/ftp/set_socket_spec.rb11
-rw-r--r--spec/ruby/library/net/ftp/shared/getbinaryfile.rb150
-rw-r--r--spec/ruby/library/net/ftp/shared/gettextfile.rb100
-rw-r--r--spec/ruby/library/net/ftp/shared/last_response_code.rb25
-rw-r--r--spec/ruby/library/net/ftp/shared/list.rb104
-rw-r--r--spec/ruby/library/net/ftp/shared/putbinaryfile.rb167
-rw-r--r--spec/ruby/library/net/ftp/shared/puttextfile.rb120
-rw-r--r--spec/ruby/library/net/ftp/shared/pwd.rb3
-rw-r--r--spec/ruby/library/net/ftp/site_spec.rb56
-rw-r--r--spec/ruby/library/net/ftp/size_spec.rb51
-rw-r--r--spec/ruby/library/net/ftp/spec_helper.rb5
-rw-r--r--spec/ruby/library/net/ftp/status_spec.rb70
-rw-r--r--spec/ruby/library/net/ftp/storbinary_spec.rb51
-rw-r--r--spec/ruby/library/net/ftp/storlines_spec.rb46
-rw-r--r--spec/ruby/library/net/ftp/system_spec.rb51
-rw-r--r--spec/ruby/library/net/ftp/voidcmd_spec.rb57
-rw-r--r--spec/ruby/library/net/ftp/welcome_spec.rb28
-rw-r--r--spec/ruby/library/net/http/HTTPBadResponse_spec.rb8
-rw-r--r--spec/ruby/library/net/http/HTTPClientExcepton_spec.rb12
-rw-r--r--spec/ruby/library/net/http/HTTPError_spec.rb12
-rw-r--r--spec/ruby/library/net/http/HTTPFatalError_spec.rb12
-rw-r--r--spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb8
-rw-r--r--spec/ruby/library/net/http/HTTPRetriableError_spec.rb12
-rw-r--r--spec/ruby/library/net/http/HTTPServerException_spec.rb12
-rw-r--r--spec/ruby/library/net/http/http/Proxy_spec.rb35
-rw-r--r--spec/ruby/library/net/http/http/active_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/address_spec.rb9
-rw-r--r--spec/ruby/library/net/http/http/close_on_empty_response_spec.rb10
-rw-r--r--spec/ruby/library/net/http/http/copy_spec.rb21
-rw-r--r--spec/ruby/library/net/http/http/default_port_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/delete_spec.rb21
-rw-r--r--spec/ruby/library/net/http/http/finish_spec.rb29
-rw-r--r--spec/ruby/library/net/http/http/get2_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/get_print_spec.rb30
-rw-r--r--spec/ruby/library/net/http/http/get_response_spec.rb30
-rw-r--r--spec/ruby/library/net/http/http/get_spec.rb96
-rw-r--r--spec/ruby/library/net/http/http/head2_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/head_spec.rb25
-rw-r--r--spec/ruby/library/net/http/http/http_default_port_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/https_default_port_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/initialize_spec.rb46
-rw-r--r--spec/ruby/library/net/http/http/inspect_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/is_version_1_1_spec.rb7
-rw-r--r--spec/ruby/library/net/http/http/is_version_1_2_spec.rb7
-rw-r--r--spec/ruby/library/net/http/http/lock_spec.rb21
-rw-r--r--spec/ruby/library/net/http/http/mkcol_spec.rb21
-rw-r--r--spec/ruby/library/net/http/http/move_spec.rb25
-rw-r--r--spec/ruby/library/net/http/http/new_spec.rb86
-rw-r--r--spec/ruby/library/net/http/http/newobj_spec.rb48
-rw-r--r--spec/ruby/library/net/http/http/open_timeout_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/options_spec.rb25
-rw-r--r--spec/ruby/library/net/http/http/port_spec.rb9
-rw-r--r--spec/ruby/library/net/http/http/post2_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/post_form_spec.rb22
-rw-r--r--spec/ruby/library/net/http/http/post_spec.rb74
-rw-r--r--spec/ruby/library/net/http/http/propfind_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/proppatch_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/proxy_address_spec.rb31
-rw-r--r--spec/ruby/library/net/http/http/proxy_class_spec.rb9
-rw-r--r--spec/ruby/library/net/http/http/proxy_pass_spec.rb39
-rw-r--r--spec/ruby/library/net/http/http/proxy_port_spec.rb39
-rw-r--r--spec/ruby/library/net/http/http/proxy_user_spec.rb39
-rw-r--r--spec/ruby/library/net/http/http/put2_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/put_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/read_timeout_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/request_get_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/request_head_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/request_post_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/request_put_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/request_spec.rb109
-rw-r--r--spec/ruby/library/net/http/http/request_types_spec.rb254
-rw-r--r--spec/ruby/library/net/http/http/send_request_spec.rb61
-rw-r--r--spec/ruby/library/net/http/http/set_debug_output_spec.rb33
-rw-r--r--spec/ruby/library/net/http/http/shared/request_get.rb41
-rw-r--r--spec/ruby/library/net/http/http/shared/request_head.rb41
-rw-r--r--spec/ruby/library/net/http/http/shared/request_post.rb41
-rw-r--r--spec/ruby/library/net/http/http/shared/request_put.rb41
-rw-r--r--spec/ruby/library/net/http/http/shared/started.rb26
-rw-r--r--spec/ruby/library/net/http/http/shared/version_1_1.rb6
-rw-r--r--spec/ruby/library/net/http/http/shared/version_1_2.rb6
-rw-r--r--spec/ruby/library/net/http/http/socket_type_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/start_spec.rb111
-rw-r--r--spec/ruby/library/net/http/http/started_spec.rb8
-rw-r--r--spec/ruby/library/net/http/http/trace_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/unlock_spec.rb24
-rw-r--r--spec/ruby/library/net/http/http/use_ssl_spec.rb9
-rw-r--r--spec/ruby/library/net/http/http/version_1_1_spec.rb7
-rw-r--r--spec/ruby/library/net/http/http/version_1_2_spec.rb20
-rw-r--r--spec/ruby/library/net/http/httpexceptions/initialize_spec.rb17
-rw-r--r--spec/ruby/library/net/http/httpexceptions/response_spec.rb10
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb21
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_spec.rb30
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb32
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb131
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb25
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/method_spec.rb15
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/path_spec.rb12
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb12
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb12
-rw-r--r--spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb21
-rw-r--r--spec/ruby/library/net/http/httpheader/add_field_spec.rb31
-rw-r--r--spec/ruby/library/net/http/httpheader/basic_auth_spec.rb14
-rw-r--r--spec/ruby/library/net/http/httpheader/canonical_each_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/chunked_spec.rb22
-rw-r--r--spec/ruby/library/net/http/httpheader/content_length_spec.rb54
-rw-r--r--spec/ruby/library/net/http/httpheader/content_range_spec.rb32
-rw-r--r--spec/ruby/library/net/http/httpheader/content_type_spec.rb26
-rw-r--r--spec/ruby/library/net/http/httpheader/delete_spec.rb30
-rw-r--r--spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb35
-rw-r--r--spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/each_header_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/each_key_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/each_name_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/each_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/each_value_spec.rb35
-rw-r--r--spec/ruby/library/net/http/httpheader/element_reference_spec.rb39
-rw-r--r--spec/ruby/library/net/http/httpheader/element_set_spec.rb41
-rw-r--r--spec/ruby/library/net/http/httpheader/fetch_spec.rb68
-rw-r--r--spec/ruby/library/net/http/httpheader/form_data_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/get_fields_spec.rb39
-rw-r--r--spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb21
-rw-r--r--spec/ruby/library/net/http/httpheader/key_spec.rb21
-rw-r--r--spec/ruby/library/net/http/httpheader/length_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/main_type_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb14
-rw-r--r--spec/ruby/library/net/http/httpheader/range_length_spec.rb32
-rw-r--r--spec/ruby/library/net/http/httpheader/range_spec.rb48
-rw-r--r--spec/ruby/library/net/http/httpheader/set_content_type_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/set_form_data_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/set_range_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb31
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/each_header.rb31
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/each_name.rb31
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/set_range.rb89
-rw-r--r--spec/ruby/library/net/http/httpheader/shared/size.rb18
-rw-r--r--spec/ruby/library/net/http/httpheader/size_spec.rb8
-rw-r--r--spec/ruby/library/net/http/httpheader/sub_type_spec.rb32
-rw-r--r--spec/ruby/library/net/http/httpheader/to_hash_spec.rb25
-rw-r--r--spec/ruby/library/net/http/httpheader/type_params_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httprequest/initialize_spec.rb45
-rw-r--r--spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb13
-rw-r--r--spec/ruby/library/net/http/httpresponse/body_spec.rb7
-rw-r--r--spec/ruby/library/net/http/httpresponse/code_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httpresponse/code_type_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httpresponse/entity_spec.rb7
-rw-r--r--spec/ruby/library/net/http/httpresponse/error_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httpresponse/error_type_spec.rb24
-rw-r--r--spec/ruby/library/net/http/httpresponse/exception_type_spec.rb13
-rw-r--r--spec/ruby/library/net/http/httpresponse/header_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/http_version_spec.rb12
-rw-r--r--spec/ruby/library/net/http/httpresponse/initialize_spec.rb11
-rw-r--r--spec/ruby/library/net/http/httpresponse/inspect_spec.rb15
-rw-r--r--spec/ruby/library/net/http/httpresponse/message_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/msg_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_body_spec.rb86
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_header_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/read_new_spec.rb23
-rw-r--r--spec/ruby/library/net/http/httpresponse/reading_body_spec.rb58
-rw-r--r--spec/ruby/library/net/http/httpresponse/response_spec.rb9
-rw-r--r--spec/ruby/library/net/http/httpresponse/shared/body.rb20
-rw-r--r--spec/ruby/library/net/http/httpresponse/value_spec.rb24
-rw-r--r--spec/ruby/library/objectspace/dump_all_spec.rb112
-rw-r--r--spec/ruby/library/objectspace/dump_spec.rb70
-rw-r--r--spec/ruby/library/objectspace/fixtures/trace.rb1
-rw-r--r--spec/ruby/library/objectspace/memsize_of_all_spec.rb4
-rw-r--r--spec/ruby/library/objectspace/memsize_of_spec.rb4
-rw-r--r--spec/ruby/library/objectspace/reachable_objects_from_spec.rb14
-rw-r--r--spec/ruby/library/objectspace/trace_object_allocations_spec.rb34
-rw-r--r--spec/ruby/library/objectspace/trace_spec.rb20
-rw-r--r--spec/ruby/library/observer/notify_observers_spec.rb2
-rw-r--r--spec/ruby/library/open3/popen3_spec.rb8
-rw-r--r--spec/ruby/library/openssl/cipher_spec.rb2
-rw-r--r--spec/ruby/library/openssl/config/freeze_spec.rb22
-rw-r--r--spec/ruby/library/openssl/digest/append_spec.rb6
-rw-r--r--spec/ruby/library/openssl/digest/block_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_spec.rb62
-rw-r--r--spec/ruby/library/openssl/digest/initialize_spec.rb137
-rw-r--r--spec/ruby/library/openssl/digest/name_spec.rb16
-rw-r--r--spec/ruby/library/openssl/digest/reset_spec.rb36
-rw-r--r--spec/ruby/library/openssl/digest/shared/update.rb123
-rw-r--r--spec/ruby/library/openssl/digest/update_spec.rb6
-rw-r--r--spec/ruby/library/openssl/digest_spec.rb63
-rw-r--r--spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb42
-rw-r--r--spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb162
-rw-r--r--spec/ruby/library/openssl/kdf/scrypt_spec.rb210
-rw-r--r--spec/ruby/library/openssl/random/shared/random_bytes.rb6
-rw-r--r--spec/ruby/library/openssl/secure_compare_spec.rb38
-rw-r--r--spec/ruby/library/openssl/shared/constants.rb2
-rw-r--r--spec/ruby/library/openssl/x509/name/parse_spec.rb4
-rw-r--r--spec/ruby/library/openssl/x509/name/verify_spec.rb78
-rw-r--r--spec/ruby/library/openssl/x509/store/verify_spec.rb78
-rw-r--r--spec/ruby/library/openstruct/delete_field_spec.rb6
-rw-r--r--spec/ruby/library/openstruct/equal_value_spec.rb22
-rw-r--r--spec/ruby/library/openstruct/frozen_spec.rb12
-rw-r--r--spec/ruby/library/openstruct/initialize_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/marshal_load_spec.rb2
-rw-r--r--spec/ruby/library/openstruct/method_missing_spec.rb6
-rw-r--r--spec/ruby/library/openstruct/new_spec.rb4
-rw-r--r--spec/ruby/library/openstruct/shared/inspect.rb2
-rw-r--r--spec/ruby/library/openstruct/to_h_spec.rb10
-rw-r--r--spec/ruby/library/pathname/birthtime_spec.rb4
-rw-r--r--spec/ruby/library/pathname/empty_spec.rb8
-rw-r--r--spec/ruby/library/pathname/glob_spec.rb12
-rw-r--r--spec/ruby/library/pathname/inspect_spec.rb2
-rw-r--r--spec/ruby/library/pathname/new_spec.rb12
-rw-r--r--spec/ruby/library/pathname/pathname_spec.rb4
-rw-r--r--spec/ruby/library/pathname/realdirpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/realpath_spec.rb2
-rw-r--r--spec/ruby/library/pathname/relative_path_from_spec.rb8
-rw-r--r--spec/ruby/library/pp/pp_spec.rb2
-rw-r--r--spec/ruby/library/prime/each_spec.rb247
-rw-r--r--spec/ruby/library/prime/instance_spec.rb31
-rw-r--r--spec/ruby/library/prime/int_from_prime_division_spec.rb19
-rw-r--r--spec/ruby/library/prime/integer/each_prime_spec.rb19
-rw-r--r--spec/ruby/library/prime/integer/from_prime_division_spec.rb19
-rw-r--r--spec/ruby/library/prime/integer/prime_division_spec.rb31
-rw-r--r--spec/ruby/library/prime/integer/prime_spec.rb27
-rw-r--r--spec/ruby/library/prime/next_spec.rb11
-rw-r--r--spec/ruby/library/prime/prime_division_spec.rb37
-rw-r--r--spec/ruby/library/prime/prime_spec.rb27
-rw-r--r--spec/ruby/library/prime/succ_spec.rb11
-rw-r--r--spec/ruby/library/random/formatter/alphanumeric_spec.rb54
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb70
-rw-r--r--spec/ruby/library/rbconfig/sizeof/limits_spec.rb6
-rw-r--r--spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb6
-rw-r--r--spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb18
-rw-r--r--spec/ruby/library/rbconfig/unicode_version_spec.rb18
-rw-r--r--spec/ruby/library/readline/basic_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/basic_word_break_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completer_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completer_word_break_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_append_character_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_case_fold_spec.rb2
-rw-r--r--spec/ruby/library/readline/completion_proc_spec.rb4
-rw-r--r--spec/ruby/library/readline/constants_spec.rb4
-rw-r--r--spec/ruby/library/readline/emacs_editing_mode_spec.rb2
-rw-r--r--spec/ruby/library/readline/filename_quote_characters_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/append_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/delete_at_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/element_reference_spec.rb12
-rw-r--r--spec/ruby/library/readline/history/element_set_spec.rb4
-rw-r--r--spec/ruby/library/readline/history/empty_spec.rb6
-rw-r--r--spec/ruby/library/readline/history/history_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/pop_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/push_spec.rb2
-rw-r--r--spec/ruby/library/readline/history/shift_spec.rb2
-rw-r--r--spec/ruby/library/readline/vi_editing_mode_spec.rb2
-rw-r--r--spec/ruby/library/resolv/get_address_spec.rb2
-rw-r--r--spec/ruby/library/resolv/get_name_spec.rb2
-rw-r--r--spec/ruby/library/rexml/attribute/clone_spec.rb14
-rw-r--r--spec/ruby/library/rexml/attribute/element_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/equal_value_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/hash_spec.rb16
-rw-r--r--spec/ruby/library/rexml/attribute/initialize_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attribute/inspect_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attribute/namespace_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attribute/node_type_spec.rb13
-rw-r--r--spec/ruby/library/rexml/attribute/prefix_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/remove_spec.rb23
-rw-r--r--spec/ruby/library/rexml/attribute/to_s_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/to_string_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/value_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/write_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/xpath_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attributes/add_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/append_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/delete_all_spec.rb34
-rw-r--r--spec/ruby/library/rexml/attributes/delete_spec.rb30
-rw-r--r--spec/ruby/library/rexml/attributes/each_attribute_spec.rb25
-rw-r--r--spec/ruby/library/rexml/attributes/each_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attributes/element_reference_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/element_set_spec.rb28
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attributes/initialize_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/length_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/namespaces_spec.rb9
-rw-r--r--spec/ruby/library/rexml/attributes/prefixes_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attributes/shared/add.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/shared/length.rb13
-rw-r--r--spec/ruby/library/rexml/attributes/size_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/to_a_spec.rb22
-rw-r--r--spec/ruby/library/rexml/cdata/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/cdata/initialize_spec.rb27
-rw-r--r--spec/ruby/library/rexml/cdata/shared/to_s.rb11
-rw-r--r--spec/ruby/library/rexml/cdata/to_s_spec.rb10
-rw-r--r--spec/ruby/library/rexml/cdata/value_spec.rb10
-rw-r--r--spec/ruby/library/rexml/document/add_element_spec.rb34
-rw-r--r--spec/ruby/library/rexml/document/add_spec.rb60
-rw-r--r--spec/ruby/library/rexml/document/clone_spec.rb23
-rw-r--r--spec/ruby/library/rexml/document/doctype_spec.rb18
-rw-r--r--spec/ruby/library/rexml/document/encoding_spec.rb25
-rw-r--r--spec/ruby/library/rexml/document/expanded_name_spec.rb19
-rw-r--r--spec/ruby/library/rexml/document/new_spec.rb39
-rw-r--r--spec/ruby/library/rexml/document/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/document/root_spec.rb15
-rw-r--r--spec/ruby/library/rexml/document/stand_alone_spec.rb22
-rw-r--r--spec/ruby/library/rexml/document/version_spec.rb17
-rw-r--r--spec/ruby/library/rexml/document/write_spec.rb38
-rw-r--r--spec/ruby/library/rexml/document/xml_decl_spec.rb18
-rw-r--r--spec/ruby/library/rexml/element/add_attribute_spec.rb44
-rw-r--r--spec/ruby/library/rexml/element/add_attributes_spec.rb25
-rw-r--r--spec/ruby/library/rexml/element/add_element_spec.rb41
-rw-r--r--spec/ruby/library/rexml/element/add_namespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/add_text_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/attribute_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/attributes_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/cdatas_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/clone_spec.rb32
-rw-r--r--spec/ruby/library/rexml/element/comments_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/delete_attribute_spec.rb42
-rw-r--r--spec/ruby/library/rexml/element/delete_element_spec.rb52
-rw-r--r--spec/ruby/library/rexml/element/delete_namespace_spec.rb28
-rw-r--r--spec/ruby/library/rexml/element/document_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_text_spec.rb34
-rw-r--r--spec/ruby/library/rexml/element/element_reference_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/get_text_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_attributes_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/has_elements_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_text_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/inspect_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/instructions_spec.rb24
-rw-r--r--spec/ruby/library/rexml/element/namespace_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/namespaces_spec.rb35
-rw-r--r--spec/ruby/library/rexml/element/new_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/next_element_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/element/prefixes_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/previous_element_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/raw_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/root_spec.rb31
-rw-r--r--spec/ruby/library/rexml/element/text_spec.rb49
-rw-r--r--spec/ruby/library/rexml/element/texts_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/whitespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/node/each_recursive_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/find_first_recursive_spec.rb28
-rw-r--r--spec/ruby/library/rexml/node/index_in_parent_spec.rb18
-rw-r--r--spec/ruby/library/rexml/node/next_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/parent_spec.rb23
-rw-r--r--spec/ruby/library/rexml/node/previous_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/shared/each_element.rb36
-rw-r--r--spec/ruby/library/rexml/shared/elements_to_a.rb34
-rw-r--r--spec/ruby/library/rexml/text/append_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/comparison_spec.rb28
-rw-r--r--spec/ruby/library/rexml/text/empty_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/indent_text_spec.rb26
-rw-r--r--spec/ruby/library/rexml/text/inspect_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/new_spec.rb51
-rw-r--r--spec/ruby/library/rexml/text/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/normalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/read_with_substitution_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/to_s_spec.rb20
-rw-r--r--spec/ruby/library/rexml/text/unnormalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/value_spec.rb40
-rw-r--r--spec/ruby/library/rexml/text/wrap_spec.rb23
-rw-r--r--spec/ruby/library/rexml/text/write_with_substitution_spec.rb36
-rw-r--r--spec/ruby/library/ripper/lex_spec.rb6
-rw-r--r--spec/ruby/library/rubygems/gem/bin_path_spec.rb1
-rw-r--r--spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb2
-rw-r--r--spec/ruby/library/securerandom/base64_spec.rb10
-rw-r--r--spec/ruby/library/securerandom/hex_spec.rb14
-rw-r--r--spec/ruby/library/securerandom/random_bytes_spec.rb12
-rw-r--r--spec/ruby/library/securerandom/random_number_spec.rb52
-rw-r--r--spec/ruby/library/set/add_spec.rb27
-rw-r--r--spec/ruby/library/set/append_spec.rb7
-rw-r--r--spec/ruby/library/set/case_compare_spec.rb12
-rw-r--r--spec/ruby/library/set/case_equality_spec.rb7
-rw-r--r--spec/ruby/library/set/classify_spec.rb27
-rw-r--r--spec/ruby/library/set/clear_spec.rb17
-rw-r--r--spec/ruby/library/set/collect_spec.rb7
-rw-r--r--spec/ruby/library/set/compare_by_identity_spec.rb143
-rw-r--r--spec/ruby/library/set/comparison_spec.rb29
-rw-r--r--spec/ruby/library/set/constructor_spec.rb15
-rw-r--r--spec/ruby/library/set/delete_if_spec.rb38
-rw-r--r--spec/ruby/library/set/delete_spec.rb37
-rw-r--r--spec/ruby/library/set/difference_spec.rb7
-rw-r--r--spec/ruby/library/set/disjoint_spec.rb23
-rw-r--r--spec/ruby/library/set/divide_spec.rb34
-rw-r--r--spec/ruby/library/set/each_spec.rb27
-rw-r--r--spec/ruby/library/set/empty_spec.rb10
-rw-r--r--spec/ruby/library/set/enumerable/to_set_spec.rb21
-rw-r--r--spec/ruby/library/set/eql_spec.rb15
-rw-r--r--spec/ruby/library/set/equal_value_spec.rb33
-rw-r--r--spec/ruby/library/set/exclusion_spec.rb18
-rw-r--r--spec/ruby/library/set/fixtures/set_like.rb31
-rw-r--r--spec/ruby/library/set/flatten_merge_spec.rb23
-rw-r--r--spec/ruby/library/set/flatten_spec.rb53
-rw-r--r--spec/ruby/library/set/hash_spec.rb13
-rw-r--r--spec/ruby/library/set/include_spec.rb7
-rw-r--r--spec/ruby/library/set/initialize_clone_spec.rb18
-rw-r--r--spec/ruby/library/set/initialize_spec.rb73
-rw-r--r--spec/ruby/library/set/inspect_spec.rb7
-rw-r--r--spec/ruby/library/set/intersect_spec.rb23
-rw-r--r--spec/ruby/library/set/intersection_spec.rb11
-rw-r--r--spec/ruby/library/set/join_spec.rb31
-rw-r--r--spec/ruby/library/set/keep_if_spec.rb38
-rw-r--r--spec/ruby/library/set/length_spec.rb7
-rw-r--r--spec/ruby/library/set/map_spec.rb7
-rw-r--r--spec/ruby/library/set/member_spec.rb7
-rw-r--r--spec/ruby/library/set/merge_spec.rb19
-rw-r--r--spec/ruby/library/set/minus_spec.rb7
-rw-r--r--spec/ruby/library/set/plus_spec.rb7
-rw-r--r--spec/ruby/library/set/pretty_print_cycle_spec.rb10
-rw-r--r--spec/ruby/library/set/pretty_print_spec.rb19
-rw-r--r--spec/ruby/library/set/proper_subset_spec.rb41
-rw-r--r--spec/ruby/library/set/proper_superset_spec.rb41
-rw-r--r--spec/ruby/library/set/reject_spec.rb42
-rw-r--r--spec/ruby/library/set/replace_spec.rb17
-rw-r--r--spec/ruby/library/set/shared/add.rb14
-rw-r--r--spec/ruby/library/set/shared/collect.rb20
-rw-r--r--spec/ruby/library/set/shared/difference.rb15
-rw-r--r--spec/ruby/library/set/shared/include.rb29
-rw-r--r--spec/ruby/library/set/shared/inspect.rb15
-rw-r--r--spec/ruby/library/set/shared/intersection.rb15
-rw-r--r--spec/ruby/library/set/shared/select.rb42
-rw-r--r--spec/ruby/library/set/shared/union.rb15
-rw-r--r--spec/ruby/library/set/size_spec.rb7
-rw-r--r--spec/ruby/library/set/sortedset/add_spec.rb42
-rw-r--r--spec/ruby/library/set/sortedset/append_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/case_equality_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/classify_spec.rb30
-rw-r--r--spec/ruby/library/set/sortedset/clear_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/collect_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/constructor_spec.rb18
-rw-r--r--spec/ruby/library/set/sortedset/delete_if_spec.rb41
-rw-r--r--spec/ruby/library/set/sortedset/delete_spec.rb40
-rw-r--r--spec/ruby/library/set/sortedset/difference_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/divide_spec.rb37
-rw-r--r--spec/ruby/library/set/sortedset/each_spec.rb29
-rw-r--r--spec/ruby/library/set/sortedset/empty_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/eql_spec.rb19
-rw-r--r--spec/ruby/library/set/sortedset/equal_value_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/exclusion_spec.rb21
-rw-r--r--spec/ruby/library/set/sortedset/filter_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/flatten_merge_spec.rb11
-rw-r--r--spec/ruby/library/set/sortedset/flatten_spec.rb47
-rw-r--r--spec/ruby/library/set/sortedset/hash_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/include_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/initialize_spec.rb33
-rw-r--r--spec/ruby/library/set/sortedset/inspect_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/intersection_spec.rb14
-rw-r--r--spec/ruby/library/set/sortedset/keep_if_spec.rb34
-rw-r--r--spec/ruby/library/set/sortedset/length_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/map_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/member_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/merge_spec.rb22
-rw-r--r--spec/ruby/library/set/sortedset/minus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/plus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/proper_subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/proper_superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/reject_spec.rb45
-rw-r--r--spec/ruby/library/set/sortedset/replace_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/select_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/shared/add.rb14
-rw-r--r--spec/ruby/library/set/sortedset/shared/collect.rb20
-rw-r--r--spec/ruby/library/set/sortedset/shared/difference.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/include.rb7
-rw-r--r--spec/ruby/library/set/sortedset/shared/intersection.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/length.rb6
-rw-r--r--spec/ruby/library/set/sortedset/shared/select.rb35
-rw-r--r--spec/ruby/library/set/sortedset/shared/union.rb15
-rw-r--r--spec/ruby/library/set/sortedset/size_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/sortedset_spec.rb22
-rw-r--r--spec/ruby/library/set/sortedset/subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/subtract_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/to_a_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/union_spec.rb14
-rw-r--r--spec/ruby/library/set/subset_spec.rb41
-rw-r--r--spec/ruby/library/set/subtract_spec.rb17
-rw-r--r--spec/ruby/library/set/superset_spec.rb41
-rw-r--r--spec/ruby/library/set/to_a_spec.rb8
-rw-r--r--spec/ruby/library/set/to_s_spec.rb12
-rw-r--r--spec/ruby/library/set/union_spec.rb11
-rw-r--r--spec/ruby/library/shellwords/shellwords_spec.rb15
-rw-r--r--spec/ruby/library/singleton/allocate_spec.rb2
-rw-r--r--spec/ruby/library/singleton/clone_spec.rb2
-rw-r--r--spec/ruby/library/singleton/dup_spec.rb2
-rw-r--r--spec/ruby/library/singleton/instance_spec.rb12
-rw-r--r--spec/ruby/library/singleton/load_spec.rb13
-rw-r--r--spec/ruby/library/singleton/new_spec.rb2
-rw-r--r--spec/ruby/library/socket/addrinfo/afamily_spec.rb16
-rw-r--r--spec/ruby/library/socket/addrinfo/bind_spec.rb8
-rw-r--r--spec/ruby/library/socket/addrinfo/canonname_spec.rb4
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_from_spec.rb12
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_spec.rb6
-rw-r--r--spec/ruby/library/socket/addrinfo/connect_to_spec.rb12
-rw-r--r--spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb62
-rw-r--r--spec/ruby/library/socket/addrinfo/foreach_spec.rb2
-rw-r--r--spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb24
-rw-r--r--spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/initialize_spec.rb90
-rw-r--r--spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/inspect_spec.rb26
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_address_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_port_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv4_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb22
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_spec.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/listen_spec.rb4
-rw-r--r--spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb58
-rw-r--r--spec/ruby/library/socket/addrinfo/marshal_load_spec.rb20
-rw-r--r--spec/ruby/library/socket/addrinfo/pfamily_spec.rb16
-rw-r--r--spec/ruby/library/socket/addrinfo/protocol_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb18
-rw-r--r--spec/ruby/library/socket/addrinfo/socktype_spec.rb14
-rw-r--r--spec/ruby/library/socket/addrinfo/tcp_spec.rb2
-rw-r--r--spec/ruby/library/socket/addrinfo/udp_spec.rb8
-rw-r--r--spec/ruby/library/socket/addrinfo/unix_path_spec.rb46
-rw-r--r--spec/ruby/library/socket/addrinfo/unix_spec.rb52
-rw-r--r--spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb2
-rw-r--r--spec/ruby/library/socket/ancillarydata/initialize_spec.rb36
-rw-r--r--spec/ruby/library/socket/ancillarydata/int_spec.rb4
-rw-r--r--spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb16
-rw-r--r--spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb2
-rw-r--r--spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb10
-rw-r--r--spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb10
-rw-r--r--spec/ruby/library/socket/basicsocket/close_read_spec.rb12
-rw-r--r--spec/ruby/library/socket/basicsocket/close_write_spec.rb12
-rw-r--r--spec/ruby/library/socket/basicsocket/connect_address_spec.rb86
-rw-r--r--spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb2
-rw-r--r--spec/ruby/library/socket/basicsocket/for_fd_spec.rb6
-rw-r--r--spec/ruby/library/socket/basicsocket/getpeereid_spec.rb4
-rw-r--r--spec/ruby/library/socket/basicsocket/getpeername_spec.rb2
-rw-r--r--spec/ruby/library/socket/basicsocket/getsockname_spec.rb4
-rw-r--r--spec/ruby/library/socket/basicsocket/getsockopt_spec.rb12
-rw-r--r--spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb32
-rw-r--r--spec/ruby/library/socket/basicsocket/read_spec.rb47
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb71
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_spec.rb120
-rw-r--r--spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb69
-rw-r--r--spec/ruby/library/socket/basicsocket/recvmsg_spec.rb76
-rw-r--r--spec/ruby/library/socket/basicsocket/send_spec.rb94
-rw-r--r--spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb6
-rw-r--r--spec/ruby/library/socket/basicsocket/sendmsg_spec.rb2
-rw-r--r--spec/ruby/library/socket/basicsocket/setsockopt_spec.rb58
-rw-r--r--spec/ruby/library/socket/basicsocket/shutdown_spec.rb44
-rw-r--r--spec/ruby/library/socket/constants/constants_spec.rb28
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb6
-rw-r--r--spec/ruby/library/socket/ipsocket/addr_spec.rb8
-rw-r--r--spec/ruby/library/socket/ipsocket/getaddress_spec.rb9
-rw-r--r--spec/ruby/library/socket/ipsocket/inspect_spec.rb24
-rw-r--r--spec/ruby/library/socket/ipsocket/peeraddr_spec.rb4
-rw-r--r--spec/ruby/library/socket/ipsocket/recvfrom_spec.rb60
-rw-r--r--spec/ruby/library/socket/option/bool_spec.rb4
-rw-r--r--spec/ruby/library/socket/option/initialize_spec.rb18
-rw-r--r--spec/ruby/library/socket/option/int_spec.rb6
-rw-r--r--spec/ruby/library/socket/option/linger_spec.rb18
-rw-r--r--spec/ruby/library/socket/option/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/shared/address.rb92
-rw-r--r--spec/ruby/library/socket/shared/pack_sockaddr.rb72
-rw-r--r--spec/ruby/library/socket/shared/partially_closable_sockets.rb2
-rw-r--r--spec/ruby/library/socket/shared/socketpair.rb38
-rw-r--r--spec/ruby/library/socket/socket/accept_loop_spec.rb8
-rw-r--r--spec/ruby/library/socket/socket/accept_nonblock_spec.rb24
-rw-r--r--spec/ruby/library/socket/socket/accept_spec.rb12
-rw-r--r--spec/ruby/library/socket/socket/bind_spec.rb30
-rw-r--r--spec/ruby/library/socket/socket/connect_nonblock_spec.rb68
-rw-r--r--spec/ruby/library/socket/socket/connect_spec.rb24
-rw-r--r--spec/ruby/library/socket/socket/getaddrinfo_spec.rb70
-rw-r--r--spec/ruby/library/socket/socket/gethostbyaddr_spec.rb37
-rw-r--r--spec/ruby/library/socket/socket/gethostbyname_spec.rb12
-rw-r--r--spec/ruby/library/socket/socket/gethostname_spec.rb12
-rw-r--r--spec/ruby/library/socket/socket/getifaddrs_spec.rb42
-rw-r--r--spec/ruby/library/socket/socket/getnameinfo_spec.rb18
-rw-r--r--spec/ruby/library/socket/socket/getservbyname_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/getservbyport_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/initialize_spec.rb16
-rw-r--r--spec/ruby/library/socket/socket/ip_address_list_spec.rb10
-rw-r--r--spec/ruby/library/socket/socket/listen_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/local_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/new_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/pair_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb78
-rw-r--r--spec/ruby/library/socket/socket/recvfrom_spec.rb69
-rw-r--r--spec/ruby/library/socket/socket/remote_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/socketpair_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/sysaccept_spec.rb10
-rw-r--r--spec/ruby/library/socket/socket/tcp_server_loop_spec.rb4
-rw-r--r--spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb8
-rw-r--r--spec/ruby/library/socket/socket/tcp_spec.rb30
-rw-r--r--spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/udp_server_loop_spec.rb6
-rw-r--r--spec/ruby/library/socket/socket/udp_server_recv_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/udp_server_sockets_spec.rb8
-rw-r--r--spec/ruby/library/socket/socket/unix_server_loop_spec.rb76
-rw-r--r--spec/ruby/library/socket/socket/unix_server_socket_spec.rb56
-rw-r--r--spec/ruby/library/socket/socket/unix_spec.rb56
-rw-r--r--spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb16
-rw-r--r--spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb34
-rw-r--r--spec/ruby/library/socket/spec_helper.rb21
-rw-r--r--spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb12
-rw-r--r--spec/ruby/library/socket/tcpserver/accept_spec.rb23
-rw-r--r--spec/ruby/library/socket/tcpserver/gets_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpserver/initialize_spec.rb12
-rw-r--r--spec/ruby/library/socket/tcpserver/listen_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpserver/new_spec.rb34
-rw-r--r--spec/ruby/library/socket/tcpserver/sysaccept_spec.rb4
-rw-r--r--spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb18
-rw-r--r--spec/ruby/library/socket/tcpsocket/initialize_spec.rb44
-rw-r--r--spec/ruby/library/socket/tcpsocket/local_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/remote_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/shared/new.rb74
-rw-r--r--spec/ruby/library/socket/udpsocket/bind_spec.rb4
-rw-r--r--spec/ruby/library/socket/udpsocket/initialize_spec.rb27
-rw-r--r--spec/ruby/library/socket/udpsocket/inspect_spec.rb17
-rw-r--r--spec/ruby/library/socket/udpsocket/local_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/udpsocket/new_spec.rb18
-rw-r--r--spec/ruby/library/socket/udpsocket/open_spec.rb2
-rw-r--r--spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb17
-rw-r--r--spec/ruby/library/socket/udpsocket/remote_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/udpsocket/send_spec.rb14
-rw-r--r--spec/ruby/library/socket/udpsocket/write_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb113
-rw-r--r--spec/ruby/library/socket/unixserver/accept_spec.rb161
-rw-r--r--spec/ruby/library/socket/unixserver/for_fd_spec.rb28
-rw-r--r--spec/ruby/library/socket/unixserver/initialize_spec.rb36
-rw-r--r--spec/ruby/library/socket/unixserver/listen_spec.rb24
-rw-r--r--spec/ruby/library/socket/unixserver/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixserver/open_spec.rb26
-rw-r--r--spec/ruby/library/socket/unixserver/shared/new.rb26
-rw-r--r--spec/ruby/library/socket/unixserver/sysaccept_spec.rb64
-rw-r--r--spec/ruby/library/socket/unixsocket/addr_spec.rb47
-rw-r--r--spec/ruby/library/socket/unixsocket/initialize_spec.rb62
-rw-r--r--spec/ruby/library/socket/unixsocket/inspect_spec.rb18
-rw-r--r--spec/ruby/library/socket/unixsocket/local_address_spec.rb132
-rw-r--r--spec/ruby/library/socket/unixsocket/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/open_spec.rb26
-rw-r--r--spec/ruby/library/socket/unixsocket/pair_spec.rb41
-rw-r--r--spec/ruby/library/socket/unixsocket/partially_closable_spec.rb32
-rw-r--r--spec/ruby/library/socket/unixsocket/path_spec.rb34
-rw-r--r--spec/ruby/library/socket/unixsocket/peeraddr_spec.rb38
-rw-r--r--spec/ruby/library/socket/unixsocket/recv_io_spec.rb15
-rw-r--r--spec/ruby/library/socket/unixsocket/recvfrom_spec.rb138
-rw-r--r--spec/ruby/library/socket/unixsocket/remote_address_spec.rb60
-rw-r--r--spec/ruby/library/socket/unixsocket/send_io_spec.rb9
-rw-r--r--spec/ruby/library/socket/unixsocket/shared/new.rb28
-rw-r--r--spec/ruby/library/socket/unixsocket/shared/pair.rb47
-rw-r--r--spec/ruby/library/socket/unixsocket/socketpair_spec.rb46
-rw-r--r--spec/ruby/library/stringio/append_spec.rb25
-rw-r--r--spec/ruby/library/stringio/binmode_spec.rb4
-rw-r--r--spec/ruby/library/stringio/bytes_spec.rb29
-rw-r--r--spec/ruby/library/stringio/chars_spec.rb29
-rw-r--r--spec/ruby/library/stringio/close_read_spec.rb10
-rw-r--r--spec/ruby/library/stringio/close_spec.rb8
-rw-r--r--spec/ruby/library/stringio/close_write_spec.rb12
-rw-r--r--spec/ruby/library/stringio/closed_read_spec.rb6
-rw-r--r--spec/ruby/library/stringio/closed_spec.rb10
-rw-r--r--spec/ruby/library/stringio/closed_write_spec.rb6
-rw-r--r--spec/ruby/library/stringio/codepoints_spec.rb19
-rw-r--r--spec/ruby/library/stringio/each_line_spec.rb4
-rw-r--r--spec/ruby/library/stringio/each_spec.rb4
-rw-r--r--spec/ruby/library/stringio/fcntl_spec.rb2
-rw-r--r--spec/ruby/library/stringio/fileno_spec.rb5
-rw-r--r--spec/ruby/library/stringio/fixtures/classes.rb4
-rw-r--r--spec/ruby/library/stringio/flush_spec.rb4
-rw-r--r--spec/ruby/library/stringio/fsync_spec.rb4
-rw-r--r--spec/ruby/library/stringio/gets_spec.rb263
-rw-r--r--spec/ruby/library/stringio/initialize_spec.rb259
-rw-r--r--spec/ruby/library/stringio/inspect_spec.rb2
-rw-r--r--spec/ruby/library/stringio/lineno_spec.rb8
-rw-r--r--spec/ruby/library/stringio/lines_spec.rb53
-rw-r--r--spec/ruby/library/stringio/new_spec.rb6
-rw-r--r--spec/ruby/library/stringio/open_spec.rb180
-rw-r--r--spec/ruby/library/stringio/path_spec.rb2
-rw-r--r--spec/ruby/library/stringio/pid_spec.rb2
-rw-r--r--spec/ruby/library/stringio/pos_spec.rb2
-rw-r--r--spec/ruby/library/stringio/print_spec.rb22
-rw-r--r--spec/ruby/library/stringio/printf_spec.rb22
-rw-r--r--spec/ruby/library/stringio/putc_spec.rb18
-rw-r--r--spec/ruby/library/stringio/puts_spec.rb16
-rw-r--r--spec/ruby/library/stringio/read_nonblock_spec.rb6
-rw-r--r--spec/ruby/library/stringio/read_spec.rb6
-rw-r--r--spec/ruby/library/stringio/readline_spec.rb160
-rw-r--r--spec/ruby/library/stringio/readlines_spec.rb16
-rw-r--r--spec/ruby/library/stringio/readpartial_spec.rb50
-rw-r--r--spec/ruby/library/stringio/reopen_spec.rb142
-rw-r--r--spec/ruby/library/stringio/rewind_spec.rb2
-rw-r--r--spec/ruby/library/stringio/seek_spec.rb24
-rw-r--r--spec/ruby/library/stringio/set_encoding_by_bom_spec.rb237
-rw-r--r--spec/ruby/library/stringio/set_encoding_spec.rb8
-rw-r--r--spec/ruby/library/stringio/shared/codepoints.rb12
-rw-r--r--spec/ruby/library/stringio/shared/each.rb92
-rw-r--r--spec/ruby/library/stringio/shared/each_byte.rb12
-rw-r--r--spec/ruby/library/stringio/shared/each_char.rb10
-rw-r--r--spec/ruby/library/stringio/shared/eof.rb10
-rw-r--r--spec/ruby/library/stringio/shared/getc.rb22
-rw-r--r--spec/ruby/library/stringio/shared/gets.rb249
-rw-r--r--spec/ruby/library/stringio/shared/isatty.rb2
-rw-r--r--spec/ruby/library/stringio/shared/read.rb54
-rw-r--r--spec/ruby/library/stringio/shared/readchar.rb8
-rw-r--r--spec/ruby/library/stringio/shared/sysread.rb4
-rw-r--r--spec/ruby/library/stringio/shared/write.rb46
-rw-r--r--spec/ruby/library/stringio/string_spec.rb12
-rw-r--r--spec/ruby/library/stringio/stringio_spec.rb2
-rw-r--r--spec/ruby/library/stringio/sync_spec.rb4
-rw-r--r--spec/ruby/library/stringio/sysread_spec.rb7
-rw-r--r--spec/ruby/library/stringio/truncate_spec.rb24
-rw-r--r--spec/ruby/library/stringio/ungetc_spec.rb24
-rw-r--r--spec/ruby/library/stringio/write_nonblock_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/captures_spec.rb36
-rw-r--r--spec/ruby/library/stringscanner/charpos_spec.rb18
-rw-r--r--spec/ruby/library/stringscanner/check_spec.rb68
-rw-r--r--spec/ruby/library/stringscanner/check_until_spec.rb122
-rw-r--r--spec/ruby/library/stringscanner/clear_spec.rb18
-rw-r--r--spec/ruby/library/stringscanner/dup_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/element_reference_spec.rb19
-rw-r--r--spec/ruby/library/stringscanner/empty_spec.rb18
-rw-r--r--spec/ruby/library/stringscanner/eos_spec.rb17
-rw-r--r--spec/ruby/library/stringscanner/exist_spec.rb101
-rw-r--r--spec/ruby/library/stringscanner/fixed_anchor_spec.rb17
-rw-r--r--spec/ruby/library/stringscanner/get_byte_spec.rb81
-rw-r--r--spec/ruby/library/stringscanner/getbyte_spec.rb21
-rw-r--r--spec/ruby/library/stringscanner/getch_spec.rb65
-rw-r--r--spec/ruby/library/stringscanner/initialize_spec.rb11
-rw-r--r--spec/ruby/library/stringscanner/inspect_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/match_spec.rb23
-rw-r--r--spec/ruby/library/stringscanner/matched_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/must_C_version_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/named_captures_spec.rb28
-rw-r--r--spec/ruby/library/stringscanner/peek_byte_spec.rb35
-rw-r--r--spec/ruby/library/stringscanner/peek_spec.rb39
-rw-r--r--spec/ruby/library/stringscanner/peep_spec.rb18
-rw-r--r--spec/ruby/library/stringscanner/rest_size_spec.rb27
-rw-r--r--spec/ruby/library/stringscanner/rest_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/restsize_spec.rb18
-rw-r--r--spec/ruby/library/stringscanner/scan_byte_spec.rb98
-rw-r--r--spec/ruby/library/stringscanner/scan_full_spec.rb14
-rw-r--r--spec/ruby/library/stringscanner/scan_integer_spec.rb157
-rw-r--r--spec/ruby/library/stringscanner/scan_spec.rb34
-rw-r--r--spec/ruby/library/stringscanner/scan_until_spec.rb122
-rw-r--r--spec/ruby/library/stringscanner/search_full_spec.rb107
-rw-r--r--spec/ruby/library/stringscanner/shared/bol.rb16
-rw-r--r--spec/ruby/library/stringscanner/shared/concat.rb16
-rw-r--r--spec/ruby/library/stringscanner/shared/eos.rb17
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range.rb4
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range_matched.rb4
-rw-r--r--spec/ruby/library/stringscanner/shared/get_byte.rb29
-rw-r--r--spec/ruby/library/stringscanner/shared/peek.rb39
-rw-r--r--spec/ruby/library/stringscanner/shared/pos.rb11
-rw-r--r--spec/ruby/library/stringscanner/shared/rest_size.rb18
-rw-r--r--spec/ruby/library/stringscanner/shared/terminate.rb8
-rw-r--r--spec/ruby/library/stringscanner/skip_spec.rb14
-rw-r--r--spec/ruby/library/stringscanner/skip_until_spec.rb118
-rw-r--r--spec/ruby/library/stringscanner/string_spec.rb4
-rw-r--r--spec/ruby/library/stringscanner/terminate_spec.rb8
-rw-r--r--spec/ruby/library/stringscanner/unscan_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/values_at_spec.rb68
-rw-r--r--spec/ruby/library/syslog/close_spec.rb16
-rw-r--r--spec/ruby/library/syslog/constants_spec.rb4
-rw-r--r--spec/ruby/library/syslog/facility_spec.rb6
-rw-r--r--spec/ruby/library/syslog/ident_spec.rb4
-rw-r--r--spec/ruby/library/syslog/inspect_spec.rb4
-rw-r--r--spec/ruby/library/syslog/log_spec.rb10
-rw-r--r--spec/ruby/library/syslog/mask_spec.rb14
-rw-r--r--spec/ruby/library/syslog/open_spec.rb10
-rw-r--r--spec/ruby/library/syslog/opened_spec.rb16
-rw-r--r--spec/ruby/library/syslog/options_spec.rb6
-rw-r--r--spec/ruby/library/syslog/shared/log.rb6
-rw-r--r--spec/ruby/library/syslog/shared/reopen.rb14
-rw-r--r--spec/ruby/library/tempfile/_close_spec.rb4
-rw-r--r--spec/ruby/library/tempfile/callback_spec.rb6
-rw-r--r--spec/ruby/library/tempfile/close_spec.rb6
-rw-r--r--spec/ruby/library/tempfile/create_spec.rb176
-rw-r--r--spec/ruby/library/tempfile/initialize_spec.rb2
-rw-r--r--spec/ruby/library/tempfile/open_spec.rb18
-rw-r--r--spec/ruby/library/tempfile/path_spec.rb2
-rw-r--r--spec/ruby/library/tempfile/shared/length.rb6
-rw-r--r--spec/ruby/library/thread/queue_spec.rb4
-rw-r--r--spec/ruby/library/thread/sizedqueue_spec.rb4
-rw-r--r--spec/ruby/library/time/iso8601_spec.rb4
-rw-r--r--spec/ruby/library/time/shared/rfc2822.rb26
-rw-r--r--spec/ruby/library/time/shared/xmlschema.rb52
-rw-r--r--spec/ruby/library/time/to_date_spec.rb42
-rw-r--r--spec/ruby/library/time/to_datetime_spec.rb41
-rw-r--r--spec/ruby/library/time/to_time_spec.rb4
-rw-r--r--spec/ruby/library/time/xmlschema_spec.rb2
-rw-r--r--spec/ruby/library/timeout/error_spec.rb2
-rw-r--r--spec/ruby/library/timeout/timeout_spec.rb16
-rw-r--r--spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb18
-rw-r--r--spec/ruby/library/tmpdir/dir/tmpdir_spec.rb4
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb5
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb5
-rw-r--r--spec/ruby/library/uri/join_spec.rb2
-rw-r--r--spec/ruby/library/uri/mailto/build_spec.rb2
-rw-r--r--spec/ruby/library/uri/parse_spec.rb24
-rw-r--r--spec/ruby/library/uri/plus_spec.rb170
-rw-r--r--spec/ruby/library/uri/select_spec.rb6
-rw-r--r--spec/ruby/library/uri/set_component_spec.rb60
-rw-r--r--spec/ruby/library/uri/shared/eql.rb6
-rw-r--r--spec/ruby/library/uri/shared/join.rb2
-rw-r--r--spec/ruby/library/uri/shared/parse.rb37
-rw-r--r--spec/ruby/library/uri/uri_spec.rb4
-rw-r--r--spec/ruby/library/weakref/__getobj___spec.rb4
-rw-r--r--spec/ruby/library/weakref/allocate_spec.rb2
-rw-r--r--spec/ruby/library/weakref/send_spec.rb4
-rw-r--r--spec/ruby/library/weakref/weakref_alive_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/fixtures/classes.rb17
-rw-r--r--spec/ruby/library/win32ole/win32ole/_invoke_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/connect_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/const_load_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole/locale_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/new_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole/shared/ole_method.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole/shared/setproperty.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/new_spec.rb14
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb12
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb14
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb12
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/new_spec.rb22
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/params_spec.rb20
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/shared/name.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/visible_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/default_spec.rb16
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/input_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/optional_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/retval_spec.rb10
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/shared/name.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/guid_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/name_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/new_spec.rb34
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progid_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progids_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/shared/name.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb2
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/variables_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/visible_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb6
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/shared/name.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/value_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb4
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb4
-rw-r--r--spec/ruby/library/yaml/dump_spec.rb20
-rw-r--r--spec/ruby/library/yaml/dump_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/fixtures/common.rb4
-rw-r--r--spec/ruby/library/yaml/fixtures/strings.rb56
-rw-r--r--spec/ruby/library/yaml/load_file_spec.rb13
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb8
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb9
-rw-r--r--spec/ruby/library/yaml/shared/each_document.rb5
-rw-r--r--spec/ruby/library/yaml/shared/load.rb24
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb40
-rw-r--r--spec/ruby/library/zlib/adler32_spec.rb2
-rw-r--r--spec/ruby/library/zlib/crc32_spec.rb2
-rw-r--r--spec/ruby/library/zlib/deflate/deflate_spec.rb4
-rw-r--r--spec/ruby/library/zlib/deflate/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate/params_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipfile/close_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipfile/comment_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipfile/orig_name_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_char_spec.rb51
-rw-r--r--spec/ruby/library/zlib/gzipreader/eof_spec.rb22
-rw-r--r--spec/ruby/library/zlib/gzipreader/getc_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/gets_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/mtime_spec.rb11
-rw-r--r--spec/ruby/library/zlib/gzipreader/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/read_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetc_spec.rb12
-rw-r--r--spec/ruby/library/zlib/gzipwriter/append_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipwriter/mtime_spec.rb3
-rw-r--r--spec/ruby/library/zlib/inflate/append_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/finish_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/inflate_spec.rb12
-rw-r--r--spec/ruby/library/zlib/inflate/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/set_dictionary_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zlib_version_spec.rb2
-rw-r--r--spec/ruby/optional/capi/array_spec.rb74
-rw-r--r--spec/ruby/optional/capi/bignum_spec.rb42
-rw-r--r--spec/ruby/optional/capi/binding_spec.rb18
-rw-r--r--spec/ruby/optional/capi/class_spec.rb158
-rw-r--r--spec/ruby/optional/capi/constants_spec.rb2
-rw-r--r--spec/ruby/optional/capi/data_spec.rb73
-rw-r--r--spec/ruby/optional/capi/debug_spec.rb24
-rw-r--r--spec/ruby/optional/capi/digest_spec.rb103
-rw-r--r--spec/ruby/optional/capi/encoding_spec.rb183
-rw-r--r--spec/ruby/optional/capi/exception_spec.rb72
-rw-r--r--spec/ruby/optional/capi/ext/array_spec.c36
-rw-r--r--spec/ruby/optional/capi/ext/class_spec.c17
-rw-r--r--spec/ruby/optional/capi/ext/constants_spec.c6
-rw-r--r--spec/ruby/optional/capi/ext/data_spec.c4
-rw-r--r--spec/ruby/optional/capi/ext/debug_spec.c2
-rw-r--r--spec/ruby/optional/capi/ext/digest_spec.c168
-rw-r--r--spec/ruby/optional/capi/ext/encoding_spec.c39
-rw-r--r--spec/ruby/optional/capi/ext/exception_spec.c27
-rw-r--r--spec/ruby/optional/capi/ext/fiber_spec.c5
-rw-r--r--spec/ruby/optional/capi/ext/finalizer_spec.c25
-rw-r--r--spec/ruby/optional/capi/ext/gc_spec.c101
-rw-r--r--spec/ruby/optional/capi/ext/hash_spec.c20
-rw-r--r--spec/ruby/optional/capi/ext/integer_spec.c5
-rw-r--r--spec/ruby/optional/capi/ext/io_spec.c138
-rw-r--r--spec/ruby/optional/capi/ext/kernel_spec.c102
-rw-r--r--spec/ruby/optional/capi/ext/mutex_spec.c23
-rw-r--r--spec/ruby/optional/capi/ext/object_spec.c137
-rw-r--r--spec/ruby/optional/capi/ext/proc_spec.c15
-rw-r--r--spec/ruby/optional/capi/ext/range_spec.c50
-rw-r--r--spec/ruby/optional/capi/ext/rbasic_spec.c64
-rw-r--r--spec/ruby/optional/capi/ext/rubyspec.h54
-rw-r--r--spec/ruby/optional/capi/ext/set_spec.c65
-rw-r--r--spec/ruby/optional/capi/ext/string_spec.c130
-rw-r--r--spec/ruby/optional/capi/ext/struct_spec.c42
-rw-r--r--spec/ruby/optional/capi/ext/thread_spec.c23
-rw-r--r--spec/ruby/optional/capi/ext/tracepoint_spec.c2
-rw-r--r--spec/ruby/optional/capi/ext/typed_data_spec.c23
-rw-r--r--spec/ruby/optional/capi/ext/util_spec.c21
-rw-r--r--spec/ruby/optional/capi/fiber_spec.rb61
-rw-r--r--spec/ruby/optional/capi/file_spec.rb10
-rw-r--r--spec/ruby/optional/capi/finalizer_spec.rb40
-rw-r--r--spec/ruby/optional/capi/fixnum_spec.rb24
-rw-r--r--spec/ruby/optional/capi/fixtures/kernel.rb19
-rw-r--r--spec/ruby/optional/capi/float_spec.rb4
-rw-r--r--spec/ruby/optional/capi/gc_spec.rb75
-rw-r--r--spec/ruby/optional/capi/globals_spec.rb31
-rw-r--r--spec/ruby/optional/capi/hash_spec.rb107
-rw-r--r--spec/ruby/optional/capi/integer_spec.rb19
-rw-r--r--spec/ruby/optional/capi/io_spec.rb438
-rw-r--r--spec/ruby/optional/capi/kernel_spec.rb461
-rw-r--r--spec/ruby/optional/capi/module_spec.rb62
-rw-r--r--spec/ruby/optional/capi/mutex_spec.rb47
-rw-r--r--spec/ruby/optional/capi/numeric_spec.rb64
-rw-r--r--spec/ruby/optional/capi/object_spec.rb176
-rw-r--r--spec/ruby/optional/capi/proc_spec.rb73
-rw-r--r--spec/ruby/optional/capi/range_spec.rb158
-rw-r--r--spec/ruby/optional/capi/rbasic_spec.rb56
-rw-r--r--spec/ruby/optional/capi/regexp_spec.rb6
-rw-r--r--spec/ruby/optional/capi/set_spec.rb96
-rw-r--r--spec/ruby/optional/capi/shared/rbasic.rb2
-rw-r--r--spec/ruby/optional/capi/spec_helper.rb49
-rw-r--r--spec/ruby/optional/capi/string_spec.rb544
-rw-r--r--spec/ruby/optional/capi/struct_spec.rb133
-rw-r--r--spec/ruby/optional/capi/thread_spec.rb52
-rw-r--r--spec/ruby/optional/capi/time_spec.rb111
-rw-r--r--spec/ruby/optional/capi/tracepoint_spec.rb2
-rw-r--r--spec/ruby/optional/capi/typed_data_spec.rb20
-rw-r--r--spec/ruby/optional/capi/util_spec.rb112
-rw-r--r--spec/ruby/optional/thread_safety/fixtures/classes.rb39
-rw-r--r--spec/ruby/optional/thread_safety/hash_spec.rb210
-rw-r--r--spec/ruby/security/cve_2010_1330_spec.rb4
-rw-r--r--spec/ruby/security/cve_2014_8080_spec.rb34
-rw-r--r--spec/ruby/security/cve_2017_17742_spec.rb37
-rw-r--r--spec/ruby/security/cve_2018_8778_spec.rb2
-rw-r--r--spec/ruby/security/cve_2018_8779_spec.rb4
-rw-r--r--spec/ruby/security/cve_2018_8780_spec.rb12
-rw-r--r--spec/ruby/security/cve_2019_8322_spec.rb33
-rw-r--r--spec/ruby/security/cve_2019_8323_spec.rb14
-rw-r--r--spec/ruby/security/cve_2020_10663_spec.rb64
-rw-r--r--spec/ruby/security/cve_2024_49761_spec.rb7
-rw-r--r--spec/ruby/shared/basicobject/method_missing.rb18
-rw-r--r--spec/ruby/shared/basicobject/send.rb18
-rw-r--r--spec/ruby/shared/enumerable/minmax.rb6
-rw-r--r--spec/ruby/shared/enumerator/enum_for.rb57
-rw-r--r--spec/ruby/shared/enumerator/with_index.rb33
-rw-r--r--spec/ruby/shared/enumerator/with_object.rb42
-rw-r--r--spec/ruby/shared/fiber/resume.rb58
-rw-r--r--spec/ruby/shared/file/directory.rb18
-rw-r--r--spec/ruby/shared/file/executable.rb8
-rw-r--r--spec/ruby/shared/file/executable_real.rb8
-rw-r--r--spec/ruby/shared/file/exist.rb11
-rw-r--r--spec/ruby/shared/file/file.rb8
-rw-r--r--spec/ruby/shared/file/grpowned.rb6
-rw-r--r--spec/ruby/shared/file/identical.rb18
-rw-r--r--spec/ruby/shared/file/size.rb4
-rw-r--r--spec/ruby/shared/file/socket.rb32
-rw-r--r--spec/ruby/shared/file/sticky.rb2
-rw-r--r--spec/ruby/shared/file/world_readable.rb10
-rw-r--r--spec/ruby/shared/file/world_writable.rb10
-rw-r--r--spec/ruby/shared/file/writable_real.rb8
-rw-r--r--spec/ruby/shared/file/zero.rb10
-rw-r--r--spec/ruby/shared/hash/key_error.rb8
-rw-r--r--spec/ruby/shared/io/putc.rb10
-rw-r--r--spec/ruby/shared/kernel/at_exit.rb8
-rw-r--r--spec/ruby/shared/kernel/complex.rb2
-rw-r--r--spec/ruby/shared/kernel/equal.rb4
-rw-r--r--spec/ruby/shared/kernel/object_id.rb30
-rw-r--r--spec/ruby/shared/kernel/raise.rb363
-rw-r--r--spec/ruby/shared/math/atanh.rb44
-rw-r--r--spec/ruby/shared/process/abort.rb12
-rw-r--r--spec/ruby/shared/process/exit.rb22
-rw-r--r--spec/ruby/shared/process/fork.rb39
-rw-r--r--spec/ruby/shared/queue/clear.rb4
-rw-r--r--spec/ruby/shared/queue/close.rb4
-rw-r--r--spec/ruby/shared/queue/closed.rb4
-rw-r--r--spec/ruby/shared/queue/deque.rb137
-rw-r--r--spec/ruby/shared/queue/empty.rb4
-rw-r--r--spec/ruby/shared/queue/enque.rb2
-rw-r--r--spec/ruby/shared/queue/freeze.rb8
-rw-r--r--spec/ruby/shared/rational/Rational.rb146
-rw-r--r--spec/ruby/shared/rational/abs.rb11
-rw-r--r--spec/ruby/shared/rational/arithmetic_exception_in_coerce.rb11
-rw-r--r--spec/ruby/shared/rational/ceil.rb45
-rw-r--r--spec/ruby/shared/rational/coerce.rb34
-rw-r--r--spec/ruby/shared/rational/comparison.rb95
-rw-r--r--spec/ruby/shared/rational/denominator.rb14
-rw-r--r--spec/ruby/shared/rational/div.rb54
-rw-r--r--spec/ruby/shared/rational/divide.rb71
-rw-r--r--spec/ruby/shared/rational/divmod.rb42
-rw-r--r--spec/ruby/shared/rational/equal_value.rb39
-rw-r--r--spec/ruby/shared/rational/exponent.rb196
-rw-r--r--spec/ruby/shared/rational/fdiv.rb5
-rw-r--r--spec/ruby/shared/rational/floor.rb45
-rw-r--r--spec/ruby/shared/rational/hash.rb9
-rw-r--r--spec/ruby/shared/rational/inspect.rb14
-rw-r--r--spec/ruby/shared/rational/marshal_dump.rb5
-rw-r--r--spec/ruby/shared/rational/marshal_load.rb5
-rw-r--r--spec/ruby/shared/rational/modulo.rb43
-rw-r--r--spec/ruby/shared/rational/multiply.rb62
-rw-r--r--spec/ruby/shared/rational/numerator.rb10
-rw-r--r--spec/ruby/shared/rational/plus.rb48
-rw-r--r--spec/ruby/shared/rational/quo.rb5
-rw-r--r--spec/ruby/shared/rational/remainder.rb5
-rw-r--r--spec/ruby/shared/rational/round.rb106
-rw-r--r--spec/ruby/shared/rational/to_f.rb16
-rw-r--r--spec/ruby/shared/rational/to_i.rb12
-rw-r--r--spec/ruby/shared/rational/to_r.rb11
-rw-r--r--spec/ruby/shared/rational/to_s.rb14
-rw-r--r--spec/ruby/shared/rational/truncate.rb71
-rw-r--r--spec/ruby/shared/sizedqueue/enque.rb138
-rw-r--r--spec/ruby/shared/sizedqueue/max.rb10
-rw-r--r--spec/ruby/shared/sizedqueue/new.rb10
-rw-r--r--spec/ruby/shared/string/end_with.rb12
-rw-r--r--spec/ruby/shared/string/start_with.rb20
-rw-r--r--spec/ruby/shared/string/times.rb40
-rw-r--r--spec/ruby/shared/time/yday.rb18
-rw-r--r--spec/ruby/shared/types/rb_num2dbl_fails.rb17
-rw-r--r--spec/ruby/spec_helper.rb2
-rw-r--r--spec/syntax_suggest/integration/ruby_command_line_spec.rb30
-rw-r--r--spec/syntax_suggest/integration/syntax_suggest_spec.rb81
-rw-r--r--spec/syntax_suggest/spec_helper.rb17
-rw-r--r--spec/syntax_suggest/unit/api_spec.rb4
-rw-r--r--spec/syntax_suggest/unit/around_block_scan_spec.rb14
-rw-r--r--spec/syntax_suggest/unit/block_expand_spec.rb34
-rw-r--r--spec/syntax_suggest/unit/capture/before_after_keyword_ends_spec.rb47
-rw-r--r--spec/syntax_suggest/unit/capture/falling_indent_lines_spec.rb44
-rw-r--r--spec/syntax_suggest/unit/capture_code_context_spec.rb59
-rw-r--r--spec/syntax_suggest/unit/clean_document_spec.rb55
-rw-r--r--spec/syntax_suggest/unit/code_block_spec.rb2
-rw-r--r--spec/syntax_suggest/unit/code_line_spec.rb28
-rw-r--r--spec/syntax_suggest/unit/code_search_spec.rb82
-rw-r--r--spec/syntax_suggest/unit/core_ext_spec.rb32
-rw-r--r--spec/syntax_suggest/unit/display_invalid_blocks_spec.rb2
-rw-r--r--spec/syntax_suggest/unit/explain_syntax_spec.rb36
-rw-r--r--spec/syntax_suggest/unit/lex_all_spec.rb29
-rw-r--r--spec/syntax_suggest/unit/mini_stringio_spec.rb25
-rw-r--r--spec/syntax_suggest/unit/pathname_from_message_spec.rb9
-rw-r--r--spec/syntax_suggest/unit/scan_history_spec.rb114
-rw-r--r--spec/syntax_suggest/unit/visitor_spec.rb119
-rw-r--r--sprintf.c28
-rw-r--r--st.c1297
-rw-r--r--strftime.c10
-rw-r--r--string.c4434
-rw-r--r--string.rb552
-rw-r--r--struct.c398
-rw-r--r--symbol.c1033
-rw-r--r--symbol.h21
-rw-r--r--symbol.rb29
-rw-r--r--template/Doxyfile.tmpl359
-rw-r--r--template/GNUmakefile.in15
-rw-r--r--template/Makefile.in217
-rw-r--r--template/builtin_binary.inc.tmpl30
-rw-r--r--template/builtin_binary.rbbin.tmpl35
-rw-r--r--template/configure-ext.mk.tmpl41
-rw-r--r--template/encdb.h.tmpl36
-rw-r--r--template/extinit.c.tmpl2
-rw-r--r--template/exts.mk.tmpl58
-rw-r--r--template/fake.rb.in33
-rw-r--r--template/id.c.tmpl5
-rw-r--r--template/id.h.tmpl17
-rw-r--r--template/known_errors.inc.tmpl8
-rw-r--r--template/limits.c.tmpl19
-rw-r--r--template/prelude.c.tmpl95
-rw-r--r--template/ruby-runner.h.in2
-rw-r--r--template/ruby.pc.in2
-rw-r--r--template/sizes.c.tmpl21
-rw-r--r--template/transdb.h.tmpl39
-rw-r--r--template/unicode_norm_gen.tmpl37
-rwxr-xr-xtemplate/unicode_properties.rdoc.tmpl59
-rw-r--r--test/-ext-/box/test_load_ext.rb97
-rw-r--r--test/-ext-/bug_reporter/test_bug_reporter.rb17
-rw-r--r--test/-ext-/debug/test_debug.rb67
-rw-r--r--test/-ext-/debug/test_profile_frames.rb70
-rw-r--r--test/-ext-/gvl/test_last_thread.rb3
-rw-r--r--test/-ext-/integer/test_my_integer.rb34
-rw-r--r--test/-ext-/load/test_resolve_symbol.rb27
-rw-r--r--test/-ext-/load/test_stringify_symbols.rb35
-rw-r--r--test/-ext-/marshal/test_internal_ivar.rb10
-rw-r--r--test/-ext-/postponed_job/test_postponed_job.rb49
-rw-r--r--test/-ext-/required.rb10
-rw-r--r--test/-ext-/scheduler/test_interrupt_with_scheduler.rb54
-rw-r--r--test/-ext-/stack/test_stack_overflow.rb55
-rw-r--r--test/-ext-/string/test_capacity.rb19
-rw-r--r--test/-ext-/string/test_fstring.rb20
-rw-r--r--test/-ext-/string/test_interned_str.rb5
-rw-r--r--test/-ext-/string/test_set_len.rb49
-rw-r--r--test/-ext-/string/test_too_many_dummy_encodings.rb2
-rw-r--r--test/-ext-/struct/test_data.rb18
-rw-r--r--test/-ext-/symbol/test_type.rb21
-rw-r--r--test/-ext-/test_abi.rb12
-rw-r--r--test/-ext-/test_bug-3571.rb4
-rw-r--r--test/-ext-/test_ensure_and_callcc.rb40
-rw-r--r--test/-ext-/thread/helper.rb51
-rw-r--r--test/-ext-/thread/test_instrumentation_api.rb276
-rw-r--r--test/-ext-/thread/test_lock_native_thread.rb54
-rw-r--r--test/-ext-/thread_fd/test_thread_fd_close.rb24
-rw-r--r--test/-ext-/tracepoint/test_tracepoint.rb21
-rw-r--r--test/.excludes-mmtk/TestArgf.rb1
-rw-r--r--test/.excludes-mmtk/TestEtc.rb1
-rw-r--r--test/.excludes-mmtk/TestGc.rb26
-rw-r--r--test/.excludes-mmtk/TestObjSpace.rb4
-rw-r--r--test/.excludes-mmtk/TestObjectSpace.rb1
-rw-r--r--test/.excludes-mmtk/TestProcess.rb4
-rw-r--r--test/.excludes-mmtk/TestTracepointObj.rb1
-rw-r--r--test/.excludes-zjit/TestResolvDNS.rb1
-rw-r--r--test/.excludes/JSONGenericObjectTest.rb4
-rw-r--r--test/.excludes/TestArray.rb (renamed from test/excludes/TestArray.rb)0
-rw-r--r--test/.excludes/TestArraySubclass.rb (renamed from test/excludes/TestArraySubclass.rb)0
-rw-r--r--test/.excludes/TestException.rb (renamed from test/excludes/TestException.rb)0
-rw-r--r--test/.excludes/TestGem.rb (renamed from test/excludes/TestGem.rb)0
-rw-r--r--test/.excludes/TestIO_Console.rb (renamed from test/excludes/TestIO_Console.rb)0
-rw-r--r--test/.excludes/TestISeq.rb (renamed from test/excludes/TestISeq.rb)0
-rw-r--r--test/.excludes/TestPatternMatching.rb1
-rw-r--r--test/.excludes/TestThread.rb20
-rw-r--r--test/.excludes/TestThreadQueue.rb (renamed from test/excludes/TestThreadQueue.rb)0
-rw-r--r--test/.excludes/URI/TestMailTo.rb1
-rw-r--r--test/base64/test_base64.rb115
-rw-r--r--test/benchmark/test_benchmark.rb167
-rw-r--r--test/bigdecimal/helper.rb39
-rw-r--r--test/bigdecimal/test_bigdecimal.rb2300
-rw-r--r--test/bigdecimal/test_bigdecimal_util.rb141
-rw-r--r--test/bigdecimal/test_bigmath.rb81
-rw-r--r--test/bigdecimal/test_ractor.rb23
-rw-r--r--test/cgi/test_cgi_cookie.rb211
-rw-r--r--test/cgi/test_cgi_core.rb307
-rw-r--r--test/cgi/test_cgi_escape.rb325
-rw-r--r--test/cgi/test_cgi_header.rb192
-rw-r--r--test/cgi/test_cgi_modruby.rb149
-rw-r--r--test/cgi/test_cgi_multipart.rb385
-rw-r--r--test/cgi/test_cgi_session.rb169
-rw-r--r--test/cgi/test_cgi_tag_helper.rb355
-rw-r--r--test/cgi/test_cgi_util.rb285
-rw-r--r--test/cgi/testdata/file1.html10
-rw-r--r--test/cgi/testdata/large.pngbin156414 -> 0 bytes-rw-r--r--test/cgi/testdata/small.pngbin82 -> 0 bytes-rw-r--r--test/coverage/test_coverage.rb221
-rw-r--r--test/csv/helper.rb42
-rw-r--r--test/csv/interface/test_delegation.rb47
-rw-r--r--test/csv/interface/test_read.rb381
-rw-r--r--test/csv/interface/test_read_write.rb124
-rw-r--r--test/csv/interface/test_write.rb217
-rw-r--r--test/csv/line_endings.gzbin59 -> 0 bytes-rw-r--r--test/csv/parse/test_column_separator.rb40
-rw-r--r--test/csv/parse/test_convert.rb165
-rw-r--r--test/csv/parse/test_each.rb23
-rw-r--r--test/csv/parse/test_general.rb341
-rw-r--r--test/csv/parse/test_header.rb342
-rw-r--r--test/csv/parse/test_inputs_scanner.rb63
-rw-r--r--test/csv/parse/test_invalid.rb52
-rw-r--r--test/csv/parse/test_liberal_parsing.rb171
-rw-r--r--test/csv/parse/test_quote_char_nil.rb93
-rw-r--r--test/csv/parse/test_read.rb27
-rw-r--r--test/csv/parse/test_rewind.rb40
-rw-r--r--test/csv/parse/test_row_separator.rb16
-rw-r--r--test/csv/parse/test_skip_lines.rb118
-rw-r--r--test/csv/parse/test_strip.rb112
-rw-r--r--test/csv/parse/test_unconverted_fields.rb117
-rw-r--r--test/csv/test_data_converters.rb190
-rw-r--r--test/csv/test_encodings.rb403
-rw-r--r--test/csv/test_features.rb359
-rw-r--r--test/csv/test_patterns.rb27
-rw-r--r--test/csv/test_row.rb435
-rw-r--r--test/csv/test_table.rb691
-rw-r--r--test/csv/write/test_converters.rb53
-rw-r--r--test/csv/write/test_force_quotes.rb78
-rw-r--r--test/csv/write/test_general.rb246
-rw-r--r--test/csv/write/test_quote_empty.rb70
-rw-r--r--test/date/test_date.rb4
-rw-r--r--test/date/test_date_conv.rb15
-rw-r--r--test/date/test_date_parse.rb47
-rw-r--r--test/date/test_date_ractor.rb2
-rw-r--r--test/date/test_date_strftime.rb9
-rw-r--r--test/date/test_date_strptime.rb15
-rw-r--r--test/date/test_switch_hitter.rb5
-rw-r--r--test/did_you_mean/core_ext/test_name_error_extension.rb2
-rw-r--r--test/did_you_mean/spell_checking/test_method_name_check.rb4
-rw-r--r--test/did_you_mean/spell_checking/test_require_path_check.rb6
-rw-r--r--test/did_you_mean/test_ractor_compatibility.rb12
-rw-r--r--test/digest/test_ractor.rb6
-rw-r--r--test/drb/drbtest.rb396
-rw-r--r--test/drb/ignore_test_drb.rb14
-rw-r--r--test/drb/test_acl.rb207
-rw-r--r--test/drb/test_drb.rb371
-rw-r--r--test/drb/test_drbobject.rb69
-rw-r--r--test/drb/test_drbssl.rb80
-rw-r--r--test/drb/test_drbunix.rb60
-rw-r--r--test/drb/ut_array.rb17
-rw-r--r--test/drb/ut_array_drbssl.rb39
-rw-r--r--test/drb/ut_array_drbunix.rb17
-rw-r--r--test/drb/ut_drb.rb189
-rw-r--r--test/drb/ut_drb_drbssl.rb40
-rw-r--r--test/drb/ut_drb_drbunix.rb18
-rw-r--r--test/drb/ut_eq.rb37
-rw-r--r--test/drb/ut_large.rb62
-rw-r--r--test/drb/ut_port.rb16
-rw-r--r--test/drb/ut_safe1.rb17
-rw-r--r--test/drb/ut_timerholder.rb74
-rw-r--r--test/dtrace/helper.rb6
-rw-r--r--test/erb/test_erb.rb111
-rw-r--r--test/error_highlight/test_error_highlight.rb484
-rw-r--r--test/etc/test_etc.rb79
-rw-r--r--test/excludes/TestThread.rb14
-rw-r--r--test/excludes/_appveyor/TestArray.rb7
-rw-r--r--test/fiber/scheduler.rb244
-rw-r--r--test/fiber/test_address_resolve.rb2
-rw-r--r--test/fiber/test_enumerator.rb8
-rw-r--r--test/fiber/test_io.rb94
-rw-r--r--test/fiber/test_io_buffer.rb77
-rw-r--r--test/fiber/test_io_close.rb107
-rw-r--r--test/fiber/test_mutex.rb2
-rw-r--r--test/fiber/test_process.rb31
-rw-r--r--test/fiber/test_queue.rb20
-rw-r--r--test/fiber/test_ractor.rb2
-rw-r--r--test/fiber/test_scheduler.rb203
-rw-r--r--test/fiber/test_sleep.rb4
-rw-r--r--test/fiber/test_thread.rb69
-rw-r--r--test/fiddle/helper.rb184
-rw-r--r--test/fiddle/test_c_struct_builder.rb69
-rw-r--r--test/fiddle/test_c_struct_entry.rb165
-rw-r--r--test/fiddle/test_c_union_entity.rb36
-rw-r--r--test/fiddle/test_closure.rb141
-rw-r--r--test/fiddle/test_cparser.rb374
-rw-r--r--test/fiddle/test_fiddle.rb58
-rw-r--r--test/fiddle/test_func.rb149
-rw-r--r--test/fiddle/test_function.rb239
-rw-r--r--test/fiddle/test_handle.rb215
-rw-r--r--test/fiddle/test_import.rb490
-rw-r--r--test/fiddle/test_memory_view.rb143
-rw-r--r--test/fiddle/test_pack.rb37
-rw-r--r--test/fiddle/test_pinned.rb28
-rw-r--r--test/fiddle/test_pointer.rb290
-rw-r--r--test/fileutils/test_fileutils.rb111
-rw-r--r--test/fixtures/fake_sorted_set_gem/sorted_set.rb9
-rw-r--r--test/io/console/test_io_console.rb83
-rw-r--r--test/io/console/test_ractor.rb42
-rw-r--r--test/io/wait/test_io_wait.rb37
-rw-r--r--test/io/wait/test_io_wait_uncommon.rb15
-rw-r--r--test/io/wait/test_ractor.rb6
-rw-r--r--test/irb/helper.rb76
-rw-r--r--test/irb/test_cmd.rb892
-rw-r--r--test/irb/test_color.rb306
-rw-r--r--test/irb/test_color_printer.rb77
-rw-r--r--test/irb/test_completion.rb349
-rw-r--r--test/irb/test_context.rb722
-rw-r--r--test/irb/test_debug_cmd.rb303
-rw-r--r--test/irb/test_history.rb209
-rw-r--r--test/irb/test_init.rb177
-rw-r--r--test/irb/test_input_method.rb79
-rw-r--r--test/irb/test_option.rb13
-rw-r--r--test/irb/test_raise_no_backtrace_exception.rb56
-rw-r--r--test/irb/test_ruby_lex.rb856
-rw-r--r--test/irb/test_workspace.rb129
-rw-r--r--test/irb/yamatanooroti/test_rendering.rb249
-rw-r--r--test/json/fixtures/fail15.json (renamed from test/json/fixtures/pass15.json)0
-rw-r--r--test/json/fixtures/fail16.json (renamed from test/json/fixtures/pass16.json)0
-rw-r--r--test/json/fixtures/fail17.json (renamed from test/json/fixtures/pass17.json)0
-rw-r--r--test/json/fixtures/fail26.json (renamed from test/json/fixtures/pass26.json)0
-rw-r--r--test/json/fixtures/fail4.json1
-rw-r--r--test/json/fixtures/fail9.json1
-rw-r--r--test/json/fixtures/pass1.json2
-rw-r--r--test/json/json_addition_test.rb31
-rwxr-xr-xtest/json/json_coder_test.rb154
-rw-r--r--test/json/json_common_interface_test.rb248
-rw-r--r--test/json/json_encoding_test.rb256
-rw-r--r--test/json/json_ext_parser_test.rb76
-rw-r--r--test/json/json_fixtures_test.rb42
-rwxr-xr-x[-rw-r--r--]test/json/json_generator_test.rb1004
-rw-r--r--test/json/json_generic_object_test.rb35
-rw-r--r--test/json/json_parser_test.rb622
-rw-r--r--test/json/json_ryu_fallback_test.rb191
-rw-r--r--test/json/json_string_matching_test.rb4
-rw-r--r--test/json/ractor_test.rb108
-rw-r--r--test/json/test_helper.rb62
-rw-r--r--test/lib/!Nothing_to_test.rb5
-rw-r--r--test/lib/jit_support.rb14
-rw-r--r--test/lib/parser_support.rb20
-rw-r--r--test/logger/test_formatter.rb35
-rw-r--r--test/logger/test_logdevice.rb859
-rw-r--r--test/logger/test_logger.rb393
-rw-r--r--test/logger/test_logperiod.rb80
-rw-r--r--test/logger/test_severity.rb58
-rw-r--r--test/mkmf/base.rb7
-rw-r--r--test/mkmf/test_config.rb56
-rw-r--r--test/mkmf/test_configuration.rb39
-rw-r--r--test/mkmf/test_egrep_cpp.rb14
-rw-r--r--test/mkmf/test_flags.rb6
-rw-r--r--test/mkmf/test_pkg_config.rb17
-rw-r--r--test/mmtk/helper.rb32
-rw-r--r--test/mmtk/test_configuration.rb93
-rw-r--r--test/monitor/test_monitor.rb4
-rw-r--r--test/net/fixtures/Makefile6
-rw-r--r--test/net/fixtures/cacert.pem44
-rw-r--r--test/net/fixtures/server.crt99
-rw-r--r--test/net/fixtures/server.key55
-rw-r--r--test/net/http/test_http.rb107
-rw-r--r--test/net/http/test_http_request.rb34
-rw-r--r--test/net/http/test_httpresponse.rb35
-rw-r--r--test/net/http/test_https.rb139
-rw-r--r--test/net/http/test_https_proxy.rb51
-rw-r--r--test/net/http/utils.rb364
-rw-r--r--test/nkf/test_kconv.rb82
-rw-r--r--test/nkf/test_nkf.rb23
-rw-r--r--test/objspace/test_objspace.rb310
-rw-r--r--test/objspace/test_ractor.rb92
-rw-r--r--test/open-uri/test_ftp.rb216
-rw-r--r--test/open-uri/test_open-uri.rb618
-rw-r--r--test/open-uri/test_proxy.rb174
-rw-r--r--test/open-uri/test_ssl.rb435
-rw-r--r--test/open-uri/utils.rb738
-rw-r--r--test/openssl/fixtures/pkey/certificate.derbin1325 -> 0 bytes-rw-r--r--test/openssl/fixtures/pkey/dh1024.pem5
-rw-r--r--test/openssl/fixtures/pkey/dh2048_ffdhe2048.pem8
-rw-r--r--test/openssl/fixtures/pkey/dsa1024.pem12
-rw-r--r--test/openssl/fixtures/pkey/dsa2048.pem15
-rw-r--r--test/openssl/fixtures/pkey/dsa256.pem8
-rw-r--r--test/openssl/fixtures/pkey/dsa512.pem8
-rw-r--r--test/openssl/fixtures/pkey/empty.der0
-rw-r--r--test/openssl/fixtures/pkey/empty.pem0
-rw-r--r--test/openssl/fixtures/pkey/fullchain.pem56
-rw-r--r--test/openssl/fixtures/pkey/garbage.txt1
-rw-r--r--test/openssl/fixtures/pkey/mldsa65-1.pem88
-rw-r--r--test/openssl/fixtures/pkey/mldsa65-2.pem88
-rw-r--r--test/openssl/fixtures/pkey/p256_too_large.pem5
-rw-r--r--test/openssl/fixtures/pkey/p384_invalid.pem6
-rw-r--r--test/openssl/fixtures/pkey/rsa1024.pem15
-rw-r--r--test/openssl/test_asn1.rb131
-rw-r--r--test/openssl/test_bn.rb58
-rw-r--r--test/openssl/test_buffering.rb2
-rw-r--r--test/openssl/test_cipher.rb131
-rw-r--r--test/openssl/test_config.rb38
-rw-r--r--test/openssl/test_digest.rb109
-rw-r--r--test/openssl/test_engine.rb2
-rw-r--r--test/openssl/test_fips.rb45
-rw-r--r--test/openssl/test_hmac.rb37
-rw-r--r--test/openssl/test_kdf.rb138
-rw-r--r--test/openssl/test_ns_spki.rb10
-rw-r--r--test/openssl/test_ocsp.rb45
-rw-r--r--test/openssl/test_ossl.rb86
-rw-r--r--test/openssl/test_pair.rb41
-rw-r--r--test/openssl/test_pkcs12.rb117
-rw-r--r--test/openssl/test_pkcs7.rb404
-rw-r--r--test/openssl/test_pkey.rb223
-rw-r--r--test/openssl/test_pkey_dh.rb157
-rw-r--r--test/openssl/test_pkey_dsa.rb178
-rw-r--r--test/openssl/test_pkey_ec.rb148
-rw-r--r--test/openssl/test_pkey_rsa.rb475
-rw-r--r--test/openssl/test_provider.rb84
-rw-r--r--test/openssl/test_ssl.rb974
-rw-r--r--test/openssl/test_ssl_session.rb98
-rw-r--r--test/openssl/test_ts.rb86
-rw-r--r--test/openssl/test_x509attr.rb4
-rw-r--r--test/openssl/test_x509cert.rb301
-rw-r--r--test/openssl/test_x509crl.rb85
-rw-r--r--test/openssl/test_x509ext.rb37
-rw-r--r--test/openssl/test_x509name.rb16
-rw-r--r--test/openssl/test_x509req.rb102
-rw-r--r--test/openssl/test_x509store.rb19
-rw-r--r--test/openssl/ut_eof.rb4
-rw-r--r--test/openssl/utils.rb131
-rw-r--r--test/optparse/test_acceptable.rb7
-rw-r--r--test/optparse/test_load.rb61
-rw-r--r--test/optparse/test_optarg.rb16
-rw-r--r--test/optparse/test_optparse.rb112
-rw-r--r--test/optparse/test_placearg.rb45
-rw-r--r--test/optparse/test_reqarg.rb6
-rw-r--r--test/optparse/test_switch.rb50
-rw-r--r--test/ostruct/test_ostruct.rb415
-rw-r--r--test/pathname/test_pathname.rb83
-rw-r--r--test/pathname/test_ractor.rb12
-rw-r--r--test/prism/api/command_line_test.rb114
-rw-r--r--test/prism/api/dump_test.rb56
-rw-r--r--test/prism/api/freeze_test.rb65
-rw-r--r--test/prism/api/lex_test.rb23
-rw-r--r--test/prism/api/parse_comments_test.rb33
-rw-r--r--test/prism/api/parse_stream_test.rb118
-rw-r--r--test/prism/api/parse_success_test.rb16
-rw-r--r--test/prism/api/parse_test.rb189
-rw-r--r--test/prism/bom_test.rb60
-rw-r--r--test/prism/encoding/encodings_test.rb91
-rw-r--r--test/prism/encoding/regular_expression_encoding_test.rb115
-rw-r--r--test/prism/encoding/string_encoding_test.rb136
-rw-r--r--test/prism/encoding/symbol_encoding_test.rb108
-rw-r--r--test/prism/errors/1_2_3.txt11
-rw-r--r--test/prism/errors/3.3-3.3/circular_parameters.txt12
-rw-r--r--test/prism/errors/3.3-3.4/leading_logical.txt34
-rw-r--r--test/prism/errors/3.3-3.4/private_endless_method.txt3
-rw-r--r--test/prism/errors/3.3-4.0/do_not_allow_trailing_commas_in_method_parameters.txt3
-rw-r--r--test/prism/errors/3.3-4.0/noblock.txt6
-rw-r--r--test/prism/errors/3.3-4.0/singleton_method_with_void_value.txt3
-rw-r--r--test/prism/errors/3.4-4.0/void_value.txt18
-rw-r--r--test/prism/errors/3.4/block_args_in_array_assignment.txt3
-rw-r--r--test/prism/errors/3.4/dont_allow_return_inside_sclass_body.txt3
-rw-r--r--test/prism/errors/3.4/it_with_ordinary_parameter.txt3
-rw-r--r--test/prism/errors/3.4/keyword_args_in_array_assignment.txt3
-rw-r--r--test/prism/errors/4.1/do_not_allow_trailing_commas_after_terminating_arguments.txt6
-rw-r--r--test/prism/errors/4.1/end_block_exit.txt10
-rw-r--r--test/prism/errors/4.1/multiple_blocks.txt12
-rw-r--r--test/prism/errors/4.1/singleton_method_with_void_value.txt4
-rw-r--r--test/prism/errors/4.1/void_value.txt44
-rw-r--r--test/prism/errors/aliasing_global_variable_with_global_number_variable.txt3
-rw-r--r--test/prism/errors/aliasing_global_variable_with_non_global_variable.txt3
-rw-r--r--test/prism/errors/aliasing_non_global_variable_with_global_variable.txt3
-rw-r--r--test/prism/errors/alnum_delimiters.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_2.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_3.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_4.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_5.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_6.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_7.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_8.txt3
-rw-r--r--test/prism/errors/alnum_delimiters_9.txt3
-rw-r--r--test/prism/errors/amperand_dot_after_endless_range.txt3
-rw-r--r--test/prism/errors/argument_after_ellipsis.txt3
-rw-r--r--test/prism/errors/argument_forwarding_only_effects_its_own_internals.txt3
-rw-r--r--test/prism/errors/argument_forwarding_when_parent_is_not_forwarding.txt3
-rw-r--r--test/prism/errors/arguments_after_block.txt17
-rw-r--r--test/prism/errors/arguments_binding_power_for_and.txt5
-rw-r--r--test/prism/errors/arguments_invalid_comma.txt4
-rw-r--r--test/prism/errors/arguments_splat_after_star_star.txt3
-rw-r--r--test/prism/errors/array_invalid_comma.txt4
-rw-r--r--test/prism/errors/array_with_double_commas.txt3
-rw-r--r--test/prism/errors/assign_to_numbered_parameter.txt11
-rw-r--r--test/prism/errors/bad_arguments.txt6
-rw-r--r--test/prism/errors/begin_at_toplevel.txt3
-rw-r--r--test/prism/errors/binary_range_with_left_unary_range.txt8
-rw-r--r--test/prism/errors/block_arg_and_block.txt3
-rw-r--r--test/prism/errors/block_args_with_endless_def.txt5
-rw-r--r--test/prism/errors/block_beginning_with_brace_and_ending_with_end.txt5
-rw-r--r--test/prism/errors/block_pass_return_value.txt33
-rw-r--r--test/prism/errors/break_1.txt4
-rw-r--r--test/prism/errors/break_1_2_3.txt8
-rw-r--r--test/prism/errors/call_with_block_and_write.txt4
-rw-r--r--test/prism/errors/call_with_block_operator_write.txt4
-rw-r--r--test/prism/errors/call_with_block_or_write.txt4
-rw-r--r--test/prism/errors/cannot_assign_to_a_reserved_numbered_parameter.txt14
-rw-r--r--test/prism/errors/case_without_clauses.txt4
-rw-r--r--test/prism/errors/case_without_when_clauses_errors_on_else_clause.txt5
-rw-r--r--test/prism/errors/check_value_expression.txt20
-rw-r--r--test/prism/errors/class_definition_in_method_body.txt3
-rw-r--r--test/prism/errors/class_definition_in_method_defs.txt7
-rw-r--r--test/prism/errors/class_name.txt3
-rw-r--r--test/prism/errors/command_call_in.txt6
-rw-r--r--test/prism/errors/command_call_in_2.txt4
-rw-r--r--test/prism/errors/command_call_in_3.txt4
-rw-r--r--test/prism/errors/command_call_in_4.txt4
-rw-r--r--test/prism/errors/command_call_in_5.txt4
-rw-r--r--test/prism/errors/command_call_in_6.txt4
-rw-r--r--test/prism/errors/command_call_in_7.txt4
-rw-r--r--test/prism/errors/command_call_value_and.txt3
-rw-r--r--test/prism/errors/command_call_value_or.txt3
-rw-r--r--test/prism/errors/command_calls.txt10
-rw-r--r--test/prism/errors/command_calls_10.txt3
-rw-r--r--test/prism/errors/command_calls_11.txt3
-rw-r--r--test/prism/errors/command_calls_12.txt3
-rw-r--r--test/prism/errors/command_calls_13.txt3
-rw-r--r--test/prism/errors/command_calls_14.txt3
-rw-r--r--test/prism/errors/command_calls_15.txt3
-rw-r--r--test/prism/errors/command_calls_16.txt3
-rw-r--r--test/prism/errors/command_calls_17.txt5
-rw-r--r--test/prism/errors/command_calls_18.txt3
-rw-r--r--test/prism/errors/command_calls_19.txt3
-rw-r--r--test/prism/errors/command_calls_2.txt6
-rw-r--r--test/prism/errors/command_calls_20.txt3
-rw-r--r--test/prism/errors/command_calls_21.txt5
-rw-r--r--test/prism/errors/command_calls_22.txt3
-rw-r--r--test/prism/errors/command_calls_23.txt3
-rw-r--r--test/prism/errors/command_calls_24.txt5
-rw-r--r--test/prism/errors/command_calls_25.txt8
-rw-r--r--test/prism/errors/command_calls_26.txt3
-rw-r--r--test/prism/errors/command_calls_27.txt3
-rw-r--r--test/prism/errors/command_calls_28.txt3
-rw-r--r--test/prism/errors/command_calls_29.txt3
-rw-r--r--test/prism/errors/command_calls_3.txt3
-rw-r--r--test/prism/errors/command_calls_30.txt3
-rw-r--r--test/prism/errors/command_calls_31.txt17
-rw-r--r--test/prism/errors/command_calls_32.txt19
-rw-r--r--test/prism/errors/command_calls_33.txt6
-rw-r--r--test/prism/errors/command_calls_34.txt31
-rw-r--r--test/prism/errors/command_calls_35.txt50
-rw-r--r--test/prism/errors/command_calls_4.txt3
-rw-r--r--test/prism/errors/command_calls_5.txt3
-rw-r--r--test/prism/errors/command_calls_6.txt6
-rw-r--r--test/prism/errors/command_calls_7.txt6
-rw-r--r--test/prism/errors/command_calls_8.txt6
-rw-r--r--test/prism/errors/command_calls_9.txt6
-rw-r--r--test/prism/errors/conditional_predicate_closed.txt6
-rw-r--r--test/prism/errors/constant_assignment_in_method.txt3
-rw-r--r--test/prism/errors/constant_path_with_invalid_token_after.txt4
-rw-r--r--test/prism/errors/content_after_unterminated_heredoc.txt4
-rw-r--r--test/prism/errors/cr_without_lf_in_percent_expression.txt3
-rw-r--r--test/prism/errors/def_endless_do.txt6
-rw-r--r--test/prism/errors/def_ivar.txt3
-rw-r--r--test/prism/errors/def_with_empty_expression_receiver.txt3
-rw-r--r--test/prism/errors/def_with_expression_receiver_and_no_identifier.txt4
-rw-r--r--test/prism/errors/def_with_multiple_statements_receiver.txt10
-rw-r--r--test/prism/errors/def_with_optional_splat.txt6
-rw-r--r--test/prism/errors/defined_empty.txt3
-rw-r--r--test/prism/errors/defining_numbered_parameter.txt3
-rw-r--r--test/prism/errors/defining_numbered_parameter_2.txt3
-rw-r--r--test/prism/errors/defs_endless_method.txt12
-rw-r--r--test/prism/errors/destroy_call_operator_write_arguments.txt11
-rw-r--r--test/prism/errors/do_not_allow_characters_other_than_0_9_a_f_and_A_F_in_u_Unicode_character_notation.txt4
-rw-r--r--test/prism/errors/do_not_allow_forward_arguments_in_blocks.txt13
-rw-r--r--test/prism/errors/do_not_allow_forward_arguments_in_lambda_literals.txt13
-rw-r--r--test/prism/errors/do_not_allow_more_than_6_hexadecimal_digits_in_u_Unicode_character_notation.txt3
-rw-r--r--test/prism/errors/do_not_allow_multiple_codepoints_in_a_single_character_literal.txt3
-rw-r--r--test/prism/errors/do_not_allow_trailing_commas_in_lambda_parameters.txt3
-rw-r--r--test/prism/errors/dont_allow_return_inside_class_body.txt3
-rw-r--r--test/prism/errors/dont_allow_return_inside_module_body.txt3
-rw-r--r--test/prism/errors/dont_allow_setting_to_back_and_nth_reference.txt7
-rw-r--r--test/prism/errors/double_arguments_forwarding.txt4
-rw-r--r--test/prism/errors/double_scope_numbered_parameters.txt3
-rw-r--r--test/prism/errors/double_scope_repeated_numbered_parameters.txt3
-rw-r--r--test/prism/errors/double_splat_followed_by_splat_argument.txt3
-rw-r--r--test/prism/errors/double_splat_with_double_commas.txt3
-rw-r--r--test/prism/errors/duplicate_pattern_capture.txt17
-rw-r--r--test/prism/errors/duplicate_pattern_hash_key.txt4
-rw-r--r--test/prism/errors/duplicate_pattern_hash_key_2.txt3
-rw-r--r--test/prism/errors/duplicated_parameter_names.txt3
-rw-r--r--test/prism/errors/duplicated_parameter_names_2.txt3
-rw-r--r--test/prism/errors/duplicated_parameter_names_3.txt3
-rw-r--r--test/prism/errors/duplicated_parameter_names_4.txt3
-rw-r--r--test/prism/errors/duplicated_parameter_names_5.txt3
-rw-r--r--test/prism/errors/dynamic_label_pattern.txt3
-rw-r--r--test/prism/errors/ellipsis_in_no_paren_call.txt3
-rw-r--r--test/prism/errors/endless_method_command_call.txt3
-rw-r--r--test/prism/errors/endless_method_command_call_parameters.txt27
-rw-r--r--test/prism/errors/escape_unicode_curly_whitespace.txt5
-rw-r--r--test/prism/errors/for_loop_delimiter.txt3
-rw-r--r--test/prism/errors/for_loops_index_missing.txt5
-rw-r--r--test/prism/errors/for_loops_only_end.txt6
-rw-r--r--test/prism/errors/forwarding_arg_after_keyword_rest.txt3
-rw-r--r--test/prism/errors/forwarding_arg_and_block.txt3
-rw-r--r--test/prism/errors/heredoc_percent_q_newline_delimiter.txt11
-rw-r--r--test/prism/errors/heredoc_unterminated.txt9
-rw-r--r--test/prism/errors/incomplete_instance_var_string.txt4
-rw-r--r--test/prism/errors/index_call_with_block_and_write.txt5
-rw-r--r--test/prism/errors/index_call_with_block_operator_write.txt5
-rw-r--r--test/prism/errors/index_call_with_block_or_write.txt5
-rw-r--r--test/prism/errors/infix_after_label.txt6
-rw-r--r--test/prism/errors/interpolated_regular_expression_with_unknown_regexp_options.txt3
-rw-r--r--test/prism/errors/interpolated_symbol_pattern_hash_key.txt3
-rw-r--r--test/prism/errors/invalid_global_variable_write.txt4
-rw-r--r--test/prism/errors/invalid_hex_escape.txt3
-rw-r--r--test/prism/errors/invalid_multi_target.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_10.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_11.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_12.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_13.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_14.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_15.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_16.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_17.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_18.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_19.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_2.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_20.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_3.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_4.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_5.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_6.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_7.txt3
-rw-r--r--test/prism/errors/invalid_multi_target_8.txt4
-rw-r--r--test/prism/errors/invalid_multi_target_9.txt4
-rw-r--r--test/prism/errors/invalid_number_underscores.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_10.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_11.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_12.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_2.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_3.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_4.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_5.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_6.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_7.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_8.txt3
-rw-r--r--test/prism/errors/invalid_number_underscores_9.txt3
-rw-r--r--test/prism/errors/invalid_operator_write_dot.txt3
-rw-r--r--test/prism/errors/invalid_operator_write_fcall.txt3
-rw-r--r--test/prism/errors/invalid_splat.txt4
-rw-r--r--test/prism/errors/keywords_parameters_before_required_parameters.txt4
-rw-r--r--test/prism/errors/label_in_interpolated_string.txt14
-rw-r--r--test/prism/errors/label_in_parentheses.txt3
-rw-r--r--test/prism/errors/loop_conditional_is_closed.txt4
-rw-r--r--test/prism/errors/match_plus.txt7
-rw-r--r--test/prism/errors/match_predicate_after_and_with_dot_method_call.txt3
-rw-r--r--test/prism/errors/match_predicate_after_and_with_opreator.txt3
-rw-r--r--test/prism/errors/match_predicate_after_or_with_dot_method_call.txt3
-rw-r--r--test/prism/errors/match_predicate_after_or_with_opreator.txt3
-rw-r--r--test/prism/errors/match_predicate_after_rescue_with_dot_method_call.txt4
-rw-r--r--test/prism/errors/match_predicate_after_rescue_with_opreator.txt4
-rw-r--r--test/prism/errors/match_required_after_and_with_dot_method_call.txt3
-rw-r--r--test/prism/errors/match_required_after_and_with_opreator.txt3
-rw-r--r--test/prism/errors/match_required_after_or_with_dot_method_call.txt3
-rw-r--r--test/prism/errors/match_required_after_or_with_opreator.txt3
-rw-r--r--test/prism/errors/match_required_after_rescue_with_dot_method_call.txt4
-rw-r--r--test/prism/errors/match_required_after_rescue_with_opreator.txt4
-rw-r--r--test/prism/errors/method_parameters_after_arguments_forwarding.txt4
-rw-r--r--test/prism/errors/method_parameters_after_block.txt4
-rw-r--r--test/prism/errors/method_with_arguments_after_anonymous_block.txt4
-rw-r--r--test/prism/errors/missing_terminator_in_parentheses.txt3
-rw-r--r--test/prism/errors/modifier_conditional_in_predicate.txt12
-rw-r--r--test/prism/errors/module_definition_in_method_body.txt3
-rw-r--r--test/prism/errors/module_definition_in_method_body_within_block.txt7
-rw-r--r--test/prism/errors/module_definition_in_method_defs.txt7
-rw-r--r--test/prism/errors/module_name_recoverable.txt4
-rw-r--r--test/prism/errors/multi_target_parens.txt19
-rw-r--r--test/prism/errors/multi_target_star.txt17
-rw-r--r--test/prism/errors/multiple_error_in_parameters_order.txt5
-rw-r--r--test/prism/errors/next_1.txt4
-rw-r--r--test/prism/errors/next_1_2_3.txt8
-rw-r--r--test/prism/errors/non_assoc_equality.txt25
-rw-r--r--test/prism/errors/non_assoc_range.txt5
-rw-r--r--test/prism/errors/not_without_parens_assignment.txt4
-rw-r--r--test/prism/errors/not_without_parens_call.txt7
-rw-r--r--test/prism/errors/not_without_parens_command.txt4
-rw-r--r--test/prism/errors/not_without_parens_command_call.txt4
-rw-r--r--test/prism/errors/not_without_parens_return.txt4
-rw-r--r--test/prism/errors/numbered_and_write.txt3
-rw-r--r--test/prism/errors/numbered_operator_write.txt3
-rw-r--r--test/prism/errors/numbered_or_write.txt3
-rw-r--r--test/prism/errors/numbered_parameters_in_block_arguments.txt3
-rw-r--r--test/prism/errors/optional_block_parameters_with_unary_operator.txt3
-rw-r--r--test/prism/errors/optional_block_parameters_with_unary_operator_2.txt3
-rw-r--r--test/prism/errors/optional_block_parameters_with_unary_operator_3.txt3
-rw-r--r--test/prism/errors/optional_block_parameters_with_unary_operator_4.txt3
-rw-r--r--test/prism/errors/parameter_name_ending_with_bang_or_question_mark.txt4
-rw-r--r--test/prism/errors/parameters_invalid_comma.txt4
-rw-r--r--test/prism/errors/pattern-capture-in-alt-array.txt4
-rw-r--r--test/prism/errors/pattern-capture-in-alt-hash.txt3
-rw-r--r--test/prism/errors/pattern-capture-in-alt-name.txt3
-rw-r--r--test/prism/errors/pattern-capture-in-alt-top.txt4
-rw-r--r--test/prism/errors/pattern_arithmetic_expressions.txt3
-rw-r--r--test/prism/errors/pattern_match_implicit_rest.txt3
-rw-r--r--test/prism/errors/pattern_string_key.txt8
-rw-r--r--test/prism/errors/pre_execution_context.txt4
-rw-r--r--test/prism/errors/pre_execution_missing_brace.txt3
-rw-r--r--test/prism/errors/range_and_bin_op.txt5
-rw-r--r--test/prism/errors/range_and_bin_op_2.txt5
-rw-r--r--test/prism/errors/range_and_bin_op_3.txt3
-rw-r--r--test/prism/errors/range_and_bin_op_4.txt5
-rw-r--r--test/prism/errors/range_and_bin_op_5.txt6
-rw-r--r--test/prism/errors/range_and_bin_op_6.txt3
-rw-r--r--test/prism/errors/range_and_bin_op_7.txt3
-rw-r--r--test/prism/errors/range_and_bin_op_8.txt4
-rw-r--r--test/prism/errors/range_doubled.txt3
-rw-r--r--test/prism/errors/rational_number_with_exponential_portion.txt4
-rw-r--r--test/prism/errors/regexp_unicode_too_short.txt4
-rw-r--r--test/prism/errors/regular_expression_with_unknown_regexp_options.txt3
-rw-r--r--test/prism/errors/repeated_parameter_name_in_destructured_params.txt3
-rw-r--r--test/prism/errors/rescue_pattern.txt4
-rw-r--r--test/prism/errors/rest_keywords_parameters_before_required_parameters.txt4
-rw-r--r--test/prism/errors/return_1.txt3
-rw-r--r--test/prism/errors/return_1_2_3.txt7
-rw-r--r--test/prism/errors/returning_to_optional_parameters_multiple_times.txt4
-rw-r--r--test/prism/errors/semicolon_after_inheritance_operator.txt3
-rw-r--r--test/prism/errors/setter_method_cannot_be_defined_in_an_endless_method_definition.txt6
-rw-r--r--test/prism/errors/shadow_args_in_block.txt3
-rw-r--r--test/prism/errors/shadow_args_in_lambda.txt5
-rw-r--r--test/prism/errors/singleton_class_delimiter.txt3
-rw-r--r--test/prism/errors/singleton_method_for_literals.txt37
-rw-r--r--test/prism/errors/splat_argument_after_keyword_argument.txt3
-rw-r--r--test/prism/errors/statement_at_non_statement.txt9
-rw-r--r--test/prism/errors/statement_operators.txt25
-rw-r--r--test/prism/errors/switching_to_named_arguments_twice.txt5
-rw-r--r--test/prism/errors/switching_to_optional_arguments_twice.txt5
-rw-r--r--test/prism/errors/symbol_in_hash.txt3
-rw-r--r--test/prism/errors/symbol_in_keyword_parameter.txt3
-rw-r--r--test/prism/errors/targeting_numbered_parameter.txt3
-rw-r--r--test/prism/errors/top_level_constant_starting_with_downcased_identifier.txt4
-rw-r--r--test/prism/errors/top_level_constant_with_downcased_identifier.txt4
-rw-r--r--test/prism/errors/trailing_comma_after_block.txt3
-rw-r--r--test/prism/errors/trailing_comma_in_calls.txt3
-rw-r--r--test/prism/errors/unexpected_block.txt3
-rw-r--r--test/prism/errors/unterminated_W_list.txt3
-rw-r--r--test/prism/errors/unterminated_argument_expression.txt5
-rw-r--r--test/prism/errors/unterminated_begin.txt4
-rw-r--r--test/prism/errors/unterminated_begin_upcase.txt4
-rw-r--r--test/prism/errors/unterminated_block.txt4
-rw-r--r--test/prism/errors/unterminated_block_do_end.txt4
-rw-r--r--test/prism/errors/unterminated_class.txt4
-rw-r--r--test/prism/errors/unterminated_def.txt5
-rw-r--r--test/prism/errors/unterminated_embdoc.txt3
-rw-r--r--test/prism/errors/unterminated_embdoc_2.txt3
-rw-r--r--test/prism/errors/unterminated_empty_string.txt3
-rw-r--r--test/prism/errors/unterminated_end_upcase.txt4
-rw-r--r--test/prism/errors/unterminated_for.txt5
-rw-r--r--test/prism/errors/unterminated_global_variable.txt3
-rw-r--r--test/prism/errors/unterminated_global_variable_2.txt3
-rw-r--r--test/prism/errors/unterminated_heredoc_and_embexpr.txt11
-rw-r--r--test/prism/errors/unterminated_heredoc_and_embexpr_2.txt9
-rw-r--r--test/prism/errors/unterminated_i_list.txt3
-rw-r--r--test/prism/errors/unterminated_if.txt5
-rw-r--r--test/prism/errors/unterminated_if_else.txt5
-rw-r--r--test/prism/errors/unterminated_interpolated_string.txt3
-rw-r--r--test/prism/errors/unterminated_interpolated_symbol.txt3
-rw-r--r--test/prism/errors/unterminated_lambda_brace.txt4
-rw-r--r--test/prism/errors/unterminated_method_parameters.txt3
-rw-r--r--test/prism/errors/unterminated_module.txt4
-rw-r--r--test/prism/errors/unterminated_parenthesized_expression.txt4
-rw-r--r--test/prism/errors/unterminated_pattern_bracket.txt7
-rw-r--r--test/prism/errors/unterminated_pattern_paren.txt7
-rw-r--r--test/prism/errors/unterminated_regular_expression.txt3
-rw-r--r--test/prism/errors/unterminated_regular_expression_with_heredoc.txt4
-rw-r--r--test/prism/errors/unterminated_s_symbol.txt3
-rw-r--r--test/prism/errors/unterminated_string.txt3
-rw-r--r--test/prism/errors/unterminated_unicode_brackets_should_be_a_syntax_error.txt3
-rw-r--r--test/prism/errors/unterminated_until.txt5
-rw-r--r--test/prism/errors/unterminated_xstring.txt3
-rw-r--r--test/prism/errors/void_value_expression_in_arguments.txt17
-rw-r--r--test/prism/errors/void_value_expression_in_array.txt15
-rw-r--r--test/prism/errors/void_value_expression_in_assignment.txt9
-rw-r--r--test/prism/errors/void_value_expression_in_begin_statement.txt19
-rw-r--r--test/prism/errors/void_value_expression_in_binary_call.txt11
-rw-r--r--test/prism/errors/void_value_expression_in_call.txt11
-rw-r--r--test/prism/errors/void_value_expression_in_constant_path.txt5
-rw-r--r--test/prism/errors/void_value_expression_in_def.txt10
-rw-r--r--test/prism/errors/void_value_expression_in_expression.txt19
-rw-r--r--test/prism/errors/void_value_expression_in_hash.txt9
-rw-r--r--test/prism/errors/void_value_expression_in_modifier.txt13
-rw-r--r--test/prism/errors/void_value_expression_in_statement.txt26
-rw-r--r--test/prism/errors/void_value_expression_in_unary_call.txt5
-rw-r--r--test/prism/errors/while_endless_method.txt5
-rw-r--r--test/prism/errors/writing_numbered_parameter.txt3
-rw-r--r--test/prism/errors/xstring_concat.txt5
-rw-r--r--test/prism/errors_test.rb135
-rw-r--r--test/prism/fixtures/3.3-3.3/block_args_in_array_assignment.txt1
-rw-r--r--test/prism/fixtures/3.3-3.3/it.txt5
-rw-r--r--test/prism/fixtures/3.3-3.3/it_indirect_writes.txt23
-rw-r--r--test/prism/fixtures/3.3-3.3/it_read_and_assignment.txt1
-rw-r--r--test/prism/fixtures/3.3-3.3/it_with_ordinary_parameter.txt1
-rw-r--r--test/prism/fixtures/3.3-3.3/keyword_args_in_array_assignment.txt1
-rw-r--r--test/prism/fixtures/3.3-3.3/return_in_sclass.txt1
-rw-r--r--test/prism/fixtures/3.3-4.0/end_block_exit.txt11
-rw-r--r--test/prism/fixtures/3.3-4.0/void_value.txt29
-rw-r--r--test/prism/fixtures/3.4/circular_parameters.txt4
-rw-r--r--test/prism/fixtures/3.4/it.txt5
-rw-r--r--test/prism/fixtures/3.4/it_indirect_writes.txt23
-rw-r--r--test/prism/fixtures/3.4/it_read_and_assignment.txt1
-rw-r--r--test/prism/fixtures/4.0/endless_methods_command_call.txt11
-rw-r--r--test/prism/fixtures/4.0/leading_logical.txt16
-rw-r--r--test/prism/fixtures/4.1/noblock.txt4
-rw-r--r--test/prism/fixtures/4.1/trailing_comma_after_method_arguments.txt15
-rw-r--r--test/prism/fixtures/4.1/void_value.txt7
-rw-r--r--test/prism/fixtures/__END__.txt3
-rw-r--r--test/prism/fixtures/alias.txt23
-rw-r--r--test/prism/fixtures/and_or_with_suffix.txt17
-rw-r--r--test/prism/fixtures/arithmetic.txt13
-rw-r--r--test/prism/fixtures/arrays.txt122
-rw-r--r--test/prism/fixtures/begin_ensure.txt21
-rw-r--r--test/prism/fixtures/begin_rescue.txt85
-rw-r--r--test/prism/fixtures/blocks.txt62
-rw-r--r--test/prism/fixtures/bom_leading_space.txt1
-rw-r--r--test/prism/fixtures/bom_spaces.txt1
-rw-r--r--test/prism/fixtures/boolean_operators.txt5
-rw-r--r--test/prism/fixtures/booleans.txt3
-rw-r--r--test/prism/fixtures/break.txt33
-rw-r--r--test/prism/fixtures/case.txt55
-rw-r--r--test/prism/fixtures/case_in_hash_key.txt6
-rw-r--r--test/prism/fixtures/case_in_in.txt4
-rw-r--r--test/prism/fixtures/character_literal.txt2
-rw-r--r--test/prism/fixtures/classes.txt35
-rw-r--r--test/prism/fixtures/command_method_call.txt41
-rw-r--r--test/prism/fixtures/command_method_call_2.txt1
-rw-r--r--test/prism/fixtures/command_method_call_3.txt19
-rw-r--r--test/prism/fixtures/comment_single.txt1
-rw-r--r--test/prism/fixtures/comments.txt24
-rw-r--r--test/prism/fixtures/constants.txt184
-rw-r--r--test/prism/fixtures/dash_heredocs.txt63
-rw-r--r--test/prism/fixtures/defined.txt19
-rw-r--r--test/prism/fixtures/dos_endings.txt20
-rw-r--r--test/prism/fixtures/dstring.txt42
-rw-r--r--test/prism/fixtures/dsym_str.txt5
-rw-r--r--test/prism/fixtures/embdoc_no_newline_at_end.txt2
-rw-r--r--test/prism/fixtures/emoji_method_calls.txt1
-rw-r--r--test/prism/fixtures/encoding_binary.txt9
-rw-r--r--test/prism/fixtures/encoding_euc_jp.txt6
-rw-r--r--test/prism/fixtures/endless_method_as_default_arg.txt11
-rw-r--r--test/prism/fixtures/endless_methods.txt11
-rw-r--r--test/prism/fixtures/endless_range_in_conditional.txt3
-rw-r--r--test/prism/fixtures/escaped_newline_with_trailing_content.txt2
-rw-r--r--test/prism/fixtures/for.txt19
-rw-r--r--test/prism/fixtures/global_variables.txt93
-rw-r--r--test/prism/fixtures/hashes.txt28
-rw-r--r--test/prism/fixtures/heredoc.txt2
-rw-r--r--test/prism/fixtures/heredoc_dedent_line_continuation.txt5
-rw-r--r--test/prism/fixtures/heredoc_percent_q_newline_delimiter.txt22
-rw-r--r--test/prism/fixtures/heredoc_with_carriage_returns.txt2
-rw-r--r--test/prism/fixtures/heredoc_with_comment.txt3
-rw-r--r--test/prism/fixtures/heredoc_with_escaped_newline_at_start.txt7
-rw-r--r--test/prism/fixtures/heredoc_with_trailing_newline.txt2
-rw-r--r--test/prism/fixtures/heredocs_leading_whitespace.txt29
-rw-r--r--test/prism/fixtures/heredocs_nested.txt22
-rw-r--r--test/prism/fixtures/heredocs_with_fake_newlines.txt55
-rw-r--r--test/prism/fixtures/heredocs_with_ignored_newlines.txt14
-rw-r--r--test/prism/fixtures/heredocs_with_ignored_newlines_and_non_empty.txt4
-rw-r--r--test/prism/fixtures/if.txt42
-rw-r--r--test/prism/fixtures/indented_file_end.txt4
-rw-r--r--test/prism/fixtures/integer_operations.txt63
-rw-r--r--test/prism/fixtures/it_assignment.txt1
-rw-r--r--test/prism/fixtures/keyword_method_names.txt20
-rw-r--r--test/prism/fixtures/keywords.txt11
-rw-r--r--test/prism/fixtures/lambda.txt27
-rw-r--r--test/prism/fixtures/method_calls.txt156
-rw-r--r--test/prism/fixtures/methods.txt190
-rw-r--r--test/prism/fixtures/modules.txt18
-rw-r--r--test/prism/fixtures/multi_write.txt4
-rw-r--r--test/prism/fixtures/newline_terminated.txtbin0 -> 212 bytes-rw-r--r--test/prism/fixtures/next.txt28
-rw-r--r--test/prism/fixtures/nils.txt13
-rw-r--r--test/prism/fixtures/non_alphanumeric_methods.txt105
-rw-r--r--test/prism/fixtures/non_void_value.txt31
-rw-r--r--test/prism/fixtures/not.txt37
-rw-r--r--test/prism/fixtures/numbers.txt67
-rw-r--r--test/prism/fixtures/patterns.txt224
-rw-r--r--test/prism/fixtures/procs.txt27
-rw-r--r--test/prism/fixtures/range_begin_open_exclusive.txt1
-rw-r--r--test/prism/fixtures/range_begin_open_inclusive.txt1
-rw-r--r--test/prism/fixtures/range_beginless.txt5
-rw-r--r--test/prism/fixtures/range_end_open_exclusive.txt1
-rw-r--r--test/prism/fixtures/range_end_open_inclusive.txt1
-rw-r--r--test/prism/fixtures/ranges.txt51
-rw-r--r--test/prism/fixtures/regex.txt58
-rw-r--r--test/prism/fixtures/regex_char_width.txt3
-rw-r--r--test/prism/fixtures/regex_escape_encoding.txt3
-rw-r--r--test/prism/fixtures/regex_with_fake_newlines.txt41
-rw-r--r--test/prism/fixtures/repeat_parameters.txt38
-rw-r--r--test/prism/fixtures/rescue.txt39
-rw-r--r--test/prism/fixtures/rescue_modifier.txt7
-rw-r--r--test/prism/fixtures/return.txt27
-rw-r--r--test/prism/fixtures/seattlerb/BEGIN.txt1
-rw-r--r--test/prism/fixtures/seattlerb/README.rdoc113
-rw-r--r--test/prism/fixtures/seattlerb/TestRubyParserShared.txt92
-rw-r--r--test/prism/fixtures/seattlerb/__ENCODING__.txt1
-rw-r--r--test/prism/fixtures/seattlerb/alias_gvar_backref.txt1
-rw-r--r--test/prism/fixtures/seattlerb/alias_resword.txt1
-rw-r--r--test/prism/fixtures/seattlerb/and_multi.txt3
-rw-r--r--test/prism/fixtures/seattlerb/aref_args_assocs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/aref_args_lit_assocs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/args_kw_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/array_line_breaks.txt4
-rw-r--r--test/prism/fixtures/seattlerb/array_lits_trailing_calls.txt3
-rw-r--r--test/prism/fixtures/seattlerb/assoc__bare.txt1
-rw-r--r--test/prism/fixtures/seattlerb/assoc_label.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attr_asgn_colon_id.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_array_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_array_lhs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_primary_dot_constant.txt1
-rw-r--r--test/prism/fixtures/seattlerb/backticks_interpolation_line.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bang_eq.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bdot2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bdot3.txt3
-rw-r--r--test/prism/fixtures/seattlerb/begin_ensure_no_bodies.txt3
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_else_ensure_bodies.txt9
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_else_ensure_no_bodies.txt9
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_ensure_no_bodies.txt4
-rw-r--r--test/prism/fixtures/seattlerb/block_arg__bare.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_arg_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_optional.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_scope2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_no_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt2_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_defn_call_block_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/block_call_dot_op2_brace_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_dot_op2_cmd_args_do_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_operation_colon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_operation_dot.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_paren_call_block_call.txt2
-rw-r--r--test/prism/fixtures/seattlerb/block_command_operation_colon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_command_operation_dot.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_anon_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_arg_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kwarg_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kwarg_lvar_multiple.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_optarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_paren_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_reg_optarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_return.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_splat_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug169.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug179.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug190.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug191.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug202.txt2
-rw-r--r--test/prism/fixtures/seattlerb/bug236.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug290.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug_187.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug_215.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_249.txt4
-rw-r--r--test/prism/fixtures/seattlerb/bug_and.txt4
-rw-r--r--test/prism/fixtures/seattlerb/bug_args__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn_outer_parens__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_call_arglist_parens.txt11
-rw-r--r--test/prism/fixtures/seattlerb/bug_case_when_regexp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_cond_pct.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_args_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_interp_array.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_masgn_right.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_not_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_op_asgn_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_and.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_assoc.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_assoc_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_args_assoc_quoted.txt5
-rw-r--r--test/prism/fixtures/seattlerb/call_args_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_args_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_block_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_lambda_block_call.txt2
-rw-r--r--test/prism/fixtures/seattlerb/call_array_lit_inline_hash.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_new.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_new_if_multiline.txt5
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_bang_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_bang_squiggle.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_begin_call_block_call.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_block_arg_named.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_carat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_colon2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_colon_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_div.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_dot_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_eq3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_gt.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_leading_dots.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_leading_dots_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/call_lt.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_lte.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_not.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_pipe.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_rshift.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_self_brackets.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_spaceship.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_stabby_do_end_with_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_stabby_with_braces_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_star.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_star2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_trailing_dots.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_unary_bang.txt1
-rw-r--r--test/prism/fixtures/seattlerb/case_in.txt111
-rw-r--r--test/prism/fixtures/seattlerb/case_in_31.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_37.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_42.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_42_2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_47.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_67.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_86.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_86_2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_const.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_const2.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_paren_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_const.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_else.txt7
-rw-r--r--test/prism/fixtures/seattlerb/case_in_find.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_find_array.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat.txt5
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_paren_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_paren_true.txt5
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_rest.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_rest_solo.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_if_unless_post_mod.txt6
-rw-r--r--test/prism/fixtures/seattlerb/case_in_multiple.txt6
-rw-r--r--test/prism/fixtures/seattlerb/case_in_or.txt5
-rw-r--r--test/prism/fixtures/seattlerb/class_comments.txt9
-rw-r--r--test/prism/fixtures/seattlerb/cond_unary_minus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_2_op_asgn_or2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_3_op_asgn_or.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_and1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_and2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_or.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defined_eh_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_arg_asplat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_arg_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_args_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_comments.txt5
-rw-r--r--test/prism/fixtures/seattlerb/defn_endless_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_endless_command_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_forward_args__no_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwsplat_anon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_no_parens.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_val.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_no_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_eq2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_noargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_noargs_parentheses.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_rescue.txt13
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_last_arg.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_powarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_reg_opt_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_unary_not.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defns_reserved.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_as_arg_with_do_block_inside.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_comments.txt5
-rw-r--r--test/prism/fixtures/seattlerb/defs_endless_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_endless_command_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_kwarg.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner_eq2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner_rescue.txt13
-rw-r--r--test/prism/fixtures/seattlerb/difficult0_.txt4
-rw-r--r--test/prism/fixtures/seattlerb/difficult1_line_numbers.txt13
-rw-r--r--test/prism/fixtures/seattlerb/difficult1_line_numbers2.txt8
-rw-r--r--test/prism/fixtures/seattlerb/difficult2_.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_5.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__10.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__11.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__12.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__6.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__7.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__8.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__9.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult4__leading_dots.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult4__leading_dots2.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult6_.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult6__7.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult6__8.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult7_.txt5
-rw-r--r--test/prism/fixtures/seattlerb/do_bug.txt4
-rw-r--r--test/prism/fixtures/seattlerb/do_lambda.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dot2_nil__26.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dot3_nil__26.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_evstr_empty_end.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_lex_state.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dsym_esc_to_sym.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dsym_to_sym.txt3
-rw-r--r--test/prism/fixtures/seattlerb/eq_begin_line_numbers.txt6
-rw-r--r--test/prism/fixtures/seattlerb/eq_begin_why_wont_people_use_their_spacebar.txt3
-rw-r--r--test/prism/fixtures/seattlerb/evstr_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/evstr_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/expr_not_bang.txt1
-rw-r--r--test/prism/fixtures/seattlerb/f_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/f_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/flip2_env_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/float_with_if_modifier.txt1
-rw-r--r--test/prism/fixtures/seattlerb/heredoc__backslash_dos_format.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_backslash_nl.txt8
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_bad_hex_escape.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_bad_oct_escape.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_comma_arg.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_lineno.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_nested.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_blank_lines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_empty.txt2
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_interp.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_no_indent.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_tabs.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_tabs_extra.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_visually_blank_lines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_trailing_slash_continued_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_unicode.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_carriage_return_escapes.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_carriage_return_escapes_windows.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_horrible_mix.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_returns.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_returns_windows.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_not_global_interpolation.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_only_carriage_returns.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_only_carriage_returns_windows.txt6
-rw-r--r--test/prism/fixtures/seattlerb/if_elsif.txt1
-rw-r--r--test/prism/fixtures/seattlerb/if_symbol.txt1
-rw-r--r--test/prism/fixtures/seattlerb/in_expr_no_case.txt1
-rw-r--r--test/prism/fixtures/seattlerb/index_0.txt1
-rw-r--r--test/prism/fixtures/seattlerb/index_0_opasgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/integer_with_if_modifier.txt1
-rw-r--r--test/prism/fixtures/seattlerb/interpolated_symbol_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/interpolated_word_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_10_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_10_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_11_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_11_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_2__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_5.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_6.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_7_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_7_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_8_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_8_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_9_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_9_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_kwarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_kwarg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/label_vs_string.txt2
-rw-r--r--test/prism/fixtures/seattlerb/lambda_do_vs_brace.txt7
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_arg_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_call_bracket_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_call_nobracket_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_ivar_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_lasgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_middle_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/magic_encoding_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/masgn_anon_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_colon_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_ident.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_colon2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_colon3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_double_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_lhs_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_splat_arg_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_star.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_var_star_var.txt1
-rw-r--r--test/prism/fixtures/seattlerb/messy_op_asgn_lineno.txt1
-rw-r--r--test/prism/fixtures/seattlerb/method_call_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/method_call_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_back_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_back_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_front_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_front_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_keyword.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_mid_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_mid_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/module_comments.txt10
-rw-r--r--test/prism/fixtures/seattlerb/multiline_hash_declaration.txt8
-rw-r--r--test/prism/fixtures/seattlerb/non_interpolated_symbol_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/non_interpolated_word_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_dot_ident_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_index_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_const_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_identifier1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_identifier_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_val_dot_ident_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_def_special_name.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_if_not_canonical.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_if_not_noncanonical.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_comment.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_comment_leading_newlines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_multiline_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_ivar_line_break_paren.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_no_args.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_complex.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_no_parens.txt6
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_no_parens_args.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot2.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot2_open.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot3.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot3_open.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dstr_escaped_newline.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dstr_soft_newline.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_evstr_after_break.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_hash_lit.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_evstr.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_hardnewline.txt7
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_regexp_chars.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_iter_call_no_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_iter_call_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_multiline_str.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_multiline_str_literal_n.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_newlines.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_op_asgn.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_postexe.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_preexe.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_rescue.txt8
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_return.txt6
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_str_with_newline_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_to_ary.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_trailing_newlines.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_opt_call_args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_opt_call_args_lit_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_019.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_044.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_051.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_058.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_058_2.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_069.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_076.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_until_not_canonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_until_not_noncanonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_while_not_canonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_while_not_noncanonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/pctW_lineno.txt5
-rw-r--r--test/prism/fixtures/seattlerb/pct_Q_backslash_nl.txt2
-rw-r--r--test/prism/fixtures/seattlerb/pct_nl.txt3
-rw-r--r--test/prism/fixtures/seattlerb/pct_w_heredoc_interp_nested.txt4
-rw-r--r--test/prism/fixtures/seattlerb/pipe_semicolon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/pipe_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qWords_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_empty_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_interp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/quoted_symbol_hash_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/quoted_symbol_keys.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qw_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qw_escape_term.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qwords_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/read_escape_unicode_curlies.txt1
-rw-r--r--test/prism/fixtures/seattlerb/read_escape_unicode_h4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp.txt9
-rw-r--r--test/prism/fixtures/seattlerb/regexp_esc_C_slash.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_esc_u.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_escape_extended.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_unicode_curlies.txt3
-rw-r--r--test/prism/fixtures/seattlerb/required_kwarg_no_value.txt2
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_ensure_result.txt5
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_no_raise.txt9
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_raised.txt5
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_rescued.txt9
-rw-r--r--test/prism/fixtures/seattlerb/rescue_in_block.txt4
-rw-r--r--test/prism/fixtures/seattlerb/rescue_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/return_call_assocs.txt11
-rw-r--r--test/prism/fixtures/seattlerb/rhs_asgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/ruby21_numbers.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_attrasgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_attrasgn_constant.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_after_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_dot_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_operator.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_rhs_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_calls.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_op_asgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_op_asgn2.txt2
-rw-r--r--test/prism/fixtures/seattlerb/slashy_newlines_within_string.txt7
-rw-r--r--test/prism/fixtures/seattlerb/stabby_arg_no_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_arg_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_iter_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_iter_call_no_target_with_arg.txt4
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_proc_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_backslashes.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_evstr_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_heredoc_interp.txt5
-rw-r--r--test/prism/fixtures/seattlerb/str_interp_ternary_or_label.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_lit_concat_bad_encodings.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_newline_hash_line_number.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_Q_nested.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_nested_nested.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_q.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_str_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/super_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbol_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbol_list.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_empty_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_interp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/thingy.txt3
-rw-r--r--test/prism/fixtures/seattlerb/uminus_float.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_minus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_plus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_plus_on_literal.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_tilde.txt1
-rw-r--r--test/prism/fixtures/seattlerb/utf8_bom.txt3
-rw-r--r--test/prism/fixtures/seattlerb/when_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/words_interp.txt1
-rw-r--r--test/prism/fixtures/single_method_call_with_bang.txt1
-rw-r--r--test/prism/fixtures/single_quote_heredocs.txt3
-rw-r--r--test/prism/fixtures/spanning_heredoc.txt63
-rw-r--r--test/prism/fixtures/spanning_heredoc_newlines.txt23
-rw-r--r--test/prism/fixtures/string_concatination_frozen_false.txt5
-rw-r--r--test/prism/fixtures/string_concatination_frozen_true.txt5
-rw-r--r--test/prism/fixtures/strings.txt185
-rw-r--r--test/prism/fixtures/super.txt17
-rw-r--r--test/prism/fixtures/symbols.txt104
-rw-r--r--test/prism/fixtures/ternary_operator.txt15
-rw-r--r--test/prism/fixtures/tilde_heredocs.txt97
-rw-r--r--test/prism/fixtures/unary_method_calls.txt8
-rw-r--r--test/prism/fixtures/undef.txt17
-rw-r--r--test/prism/fixtures/unescaping.txt9
-rw-r--r--test/prism/fixtures/unless.txt14
-rw-r--r--test/prism/fixtures/unparser/LICENSE20
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/alias.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/assignment.txt53
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/block.txt96
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/case.txt37
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/class.txt35
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/def.txt134
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/defined.txt3
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/defs.txt40
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/dstr.txt37
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/empty.txt (renamed from lib/rdoc/generator/template/darkfish/.document)0
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/empty_begin.txt1
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/flipflop.txt10
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/for.txt12
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/hookexe.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/if.txt36
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/kwbegin.txt80
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/lambda.txt13
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/literal.txt91
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/module.txt16
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/opasgn.txt24
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/pattern.txt41
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/pragma.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/range.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/rescue.txt3
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/send.txt84
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/27.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/30.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/31.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/32.txt11
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/singletons.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/super.txt21
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/unary.txt9
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/undef.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/variables.txt10
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/while.txt73
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/and.txt8
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/block.txt26
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/def.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/dstr.txt127
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/kwbegin.txt42
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/literal.txt14
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/opasgn.txt1
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/send.txt6
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/undef.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/while.txt25
-rw-r--r--test/prism/fixtures/until.txt13
-rw-r--r--test/prism/fixtures/variables.txt49
-rw-r--r--test/prism/fixtures/while.txt23
-rw-r--r--test/prism/fixtures/whitequark/LICENSE26
-rw-r--r--test/prism/fixtures/whitequark/__ENCODING__.txt1
-rw-r--r--test/prism/fixtures/whitequark/__ENCODING___legacy_.txt1
-rw-r--r--test/prism/fixtures/whitequark/alias.txt1
-rw-r--r--test/prism/fixtures/whitequark/alias_gvar.txt3
-rw-r--r--test/prism/fixtures/whitequark/ambiuous_quoted_label_in_ternary_operator.txt1
-rw-r--r--test/prism/fixtures/whitequark/and.txt3
-rw-r--r--test/prism/fixtures/whitequark/and_asgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/and_or_masgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/anonymous_blockarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/arg.txt3
-rw-r--r--test/prism/fixtures/whitequark/arg_combinations.txt29
-rw-r--r--test/prism/fixtures/whitequark/arg_duplicate_ignored.txt3
-rw-r--r--test/prism/fixtures/whitequark/arg_label.txt6
-rw-r--r--test/prism/fixtures/whitequark/arg_scope.txt1
-rw-r--r--test/prism/fixtures/whitequark/args.txt63
-rw-r--r--test/prism/fixtures/whitequark/args_args_assocs.txt3
-rw-r--r--test/prism/fixtures/whitequark/args_args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_args_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_args_star.txt3
-rw-r--r--test/prism/fixtures/whitequark/args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_block_pass.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_star.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_assocs.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_splat.txt5
-rw-r--r--test/prism/fixtures/whitequark/array_symbols.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_symbols_empty.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_symbols_interp.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_words.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_words_empty.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_words_interp.txt3
-rw-r--r--test/prism/fixtures/whitequark/asgn_cmd.txt3
-rw-r--r--test/prism/fixtures/whitequark/asgn_mrhs.txt5
-rw-r--r--test/prism/fixtures/whitequark/back_ref.txt1
-rw-r--r--test/prism/fixtures/whitequark/bang.txt1
-rw-r--r--test/prism/fixtures/whitequark/bang_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/begin_cmdarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/beginless_erange_after_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/beginless_irange_after_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/beginless_range.txt3
-rw-r--r--test/prism/fixtures/whitequark/block_arg_combinations.txt57
-rw-r--r--test/prism/fixtures/whitequark/block_kwarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/block_kwarg_combinations.txt5
-rw-r--r--test/prism/fixtures/whitequark/blockarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/blockargs.txt71
-rw-r--r--test/prism/fixtures/whitequark/bug_435.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_447.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_452.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_466.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_473.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_480.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_481.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_ascii_8bit_in_literal.txt2
-rw-r--r--test/prism/fixtures/whitequark/bug_cmd_string_lookahead.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_cmdarg.txt5
-rw-r--r--test/prism/fixtures/whitequark/bug_def_no_paren_eql_begin.txt4
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_call_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_cmdarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_hash_brace.txt9
-rw-r--r--test/prism/fixtures/whitequark/bug_heredoc_do.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_interp_single.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_lambda_leakage.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_regex_verification.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_rescue_empty_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_while_not_parens_do.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_cond.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_cond_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_expr.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_expr_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_scoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_toplevel.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_unscoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/character.txt1
-rw-r--r--test/prism/fixtures/whitequark/class.txt3
-rw-r--r--test/prism/fixtures/whitequark/class_super.txt1
-rw-r--r--test/prism/fixtures/whitequark/class_super_label.txt1
-rw-r--r--test/prism/fixtures/whitequark/comments_before_leading_dot__27.txt19
-rw-r--r--test/prism/fixtures/whitequark/complex.txt7
-rw-r--r--test/prism/fixtures/whitequark/cond_begin.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_begin_masgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_eflipflop.txt3
-rw-r--r--test/prism/fixtures/whitequark/cond_eflipflop_with_beginless_range.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_eflipflop_with_endless_range.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_iflipflop.txt3
-rw-r--r--test/prism/fixtures/whitequark/cond_iflipflop_with_beginless_range.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_iflipflop_with_endless_range.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_match_current_line.txt3
-rw-r--r--test/prism/fixtures/whitequark/const_op_asgn.txt9
-rw-r--r--test/prism/fixtures/whitequark/const_scoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/const_toplevel.txt1
-rw-r--r--test/prism/fixtures/whitequark/const_unscoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/cpath.txt3
-rw-r--r--test/prism/fixtures/whitequark/cvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/cvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/dedenting_heredoc.txt75
-rw-r--r--test/prism/fixtures/whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt4
-rw-r--r--test/prism/fixtures/whitequark/dedenting_non_interpolating_heredoc_line_continuation.txt4
-rw-r--r--test/prism/fixtures/whitequark/def.txt11
-rw-r--r--test/prism/fixtures/whitequark/defined.txt5
-rw-r--r--test/prism/fixtures/whitequark/defs.txt9
-rw-r--r--test/prism/fixtures/whitequark/emit_arg_inside_procarg0_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/empty_stmt.txt1
-rw-r--r--test/prism/fixtures/whitequark/endless_comparison_method.txt11
-rw-r--r--test/prism/fixtures/whitequark/endless_method.txt7
-rw-r--r--test/prism/fixtures/whitequark/endless_method_command_syntax.txt15
-rw-r--r--test/prism/fixtures/whitequark/endless_method_forwarded_args_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/endless_method_with_rescue_mod.txt3
-rw-r--r--test/prism/fixtures/whitequark/endless_method_without_args.txt7
-rw-r--r--test/prism/fixtures/whitequark/ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/ensure_empty.txt1
-rw-r--r--test/prism/fixtures/whitequark/false.txt1
-rw-r--r--test/prism/fixtures/whitequark/find_pattern.txt7
-rw-r--r--test/prism/fixtures/whitequark/float.txt3
-rw-r--r--test/prism/fixtures/whitequark/for.txt3
-rw-r--r--test/prism/fixtures/whitequark/for_mlhs.txt1
-rw-r--r--test/prism/fixtures/whitequark/forward_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forward_arg_with_open_args.txt27
-rw-r--r--test/prism/fixtures/whitequark/forward_args_legacy.txt5
-rw-r--r--test/prism/fixtures/whitequark/forwarded_argument_with_kwrestarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_argument_with_restarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_kwrestarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_kwrestarg_with_additional_kwarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_restarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/gvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/gvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_empty.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_hashrocket.txt3
-rw-r--r--test/prism/fixtures/whitequark/hash_kwsplat.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_label.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_label_end.txt5
-rw-r--r--test/prism/fixtures/whitequark/hash_pair_value_omission.txt5
-rw-r--r--test/prism/fixtures/whitequark/heredoc.txt14
-rw-r--r--test/prism/fixtures/whitequark/if.txt3
-rw-r--r--test/prism/fixtures/whitequark/if_else.txt3
-rw-r--r--test/prism/fixtures/whitequark/if_elsif.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_masgn__24.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_nl_then.txt2
-rw-r--r--test/prism/fixtures/whitequark/int.txt5
-rw-r--r--test/prism/fixtures/whitequark/int___LINE__.txt1
-rw-r--r--test/prism/fixtures/whitequark/interp_digit_var.txt87
-rw-r--r--test/prism/fixtures/whitequark/ivar.txt1
-rw-r--r--test/prism/fixtures/whitequark/ivasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/keyword_argument_omission.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwarg_combinations.txt7
-rw-r--r--test/prism/fixtures/whitequark/kwarg_no_paren.txt5
-rw-r--r--test/prism/fixtures/whitequark/kwbegin_compstmt.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwnilarg.txt5
-rw-r--r--test/prism/fixtures/whitequark/kwoptarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwoptarg_with_kwrestarg_and_forwarded_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwrestarg_named.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwrestarg_unnamed.txt1
-rw-r--r--test/prism/fixtures/whitequark/lbrace_arg_after_command_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/lparenarg_after_lvar__since_25.txt3
-rw-r--r--test/prism/fixtures/whitequark/lvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/lvar_injecting_match.txt3
-rw-r--r--test/prism/fixtures/whitequark/lvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/marg_combinations.txt19
-rw-r--r--test/prism/fixtures/whitequark/masgn.txt5
-rw-r--r--test/prism/fixtures/whitequark/masgn_attr.txt5
-rw-r--r--test/prism/fixtures/whitequark/masgn_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/masgn_const.txt3
-rw-r--r--test/prism/fixtures/whitequark/masgn_nested.txt3
-rw-r--r--test/prism/fixtures/whitequark/masgn_splat.txt19
-rw-r--r--test/prism/fixtures/whitequark/method_definition_in_while_cond.txt7
-rw-r--r--test/prism/fixtures/whitequark/module.txt1
-rw-r--r--test/prism/fixtures/whitequark/multiple_args_with_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/multiple_pattern_matches.txt5
-rw-r--r--test/prism/fixtures/whitequark/newline_in_hash_argument.txt14
-rw-r--r--test/prism/fixtures/whitequark/nil.txt1
-rw-r--r--test/prism/fixtures/whitequark/nil_expression.txt3
-rw-r--r--test/prism/fixtures/whitequark/non_lvar_injecting_match.txt1
-rw-r--r--test/prism/fixtures/whitequark/not.txt5
-rw-r--r--test/prism/fixtures/whitequark/not_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/not_masgn__24.txt1
-rw-r--r--test/prism/fixtures/whitequark/nth_ref.txt1
-rw-r--r--test/prism/fixtures/whitequark/numbered_args_after_27.txt7
-rw-r--r--test/prism/fixtures/whitequark/numparam_outside_block.txt9
-rw-r--r--test/prism/fixtures/whitequark/numparam_ruby_bug_19025.txt1
-rw-r--r--test/prism/fixtures/whitequark/op_asgn.txt5
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_cmd.txt7
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_index.txt1
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_index_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/optarg.txt3
-rw-r--r--test/prism/fixtures/whitequark/or.txt3
-rw-r--r--test/prism/fixtures/whitequark/or_asgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_272.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_490.txt5
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_507.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_518.txt2
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_525.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_604.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_640.txt4
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_645.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_830.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_989.txt3
-rw-r--r--test/prism/fixtures/whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt3
-rw-r--r--test/prism/fixtures/whitequark/parser_slash_slash_n_escaping_in_literals.txt62
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching__FILE__LINE_literals.txt4
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_blank_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_const_pattern.txt11
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_constants.txt5
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_explicit_array_match.txt19
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_expr_in_paren.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_hash.txt48
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_if_unless_modifiers.txt3
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_implicit_array_match.txt15
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_keyword_variable.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_lambda.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_match_alt.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_match_as.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_nil_pattern.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_no_body.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_ranges.txt11
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_single_line.txt3
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_single_line_allowed_omission_of_parentheses.txt11
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_single_match.txt1
-rw-r--r--test/prism/fixtures/whitequark/pin_expr.txt14
-rw-r--r--test/prism/fixtures/whitequark/postexe.txt1
-rw-r--r--test/prism/fixtures/whitequark/preexe.txt1
-rw-r--r--test/prism/fixtures/whitequark/procarg0.txt3
-rw-r--r--test/prism/fixtures/whitequark/procarg0_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/range_exclusive.txt1
-rw-r--r--test/prism/fixtures/whitequark/range_inclusive.txt1
-rw-r--r--test/prism/fixtures/whitequark/rational.txt3
-rw-r--r--test/prism/fixtures/whitequark/regex_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/regex_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list_mrhs.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list_var.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_var.txt3
-rw-r--r--test/prism/fixtures/whitequark/rescue.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_else_ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_in_lambda_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_masgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_op_assign.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_without_begin_end.txt1
-rw-r--r--test/prism/fixtures/whitequark/restarg_named.txt1
-rw-r--r--test/prism/fixtures/whitequark/restarg_unnamed.txt1
-rw-r--r--test/prism/fixtures/whitequark/return.txt7
-rw-r--r--test/prism/fixtures/whitequark/return_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_10279.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_10653.txt5
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11107.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11380.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873.txt23
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873_a.txt39
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873_b.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11989.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11990.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12073.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12402.txt27
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12669.txt7
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12686.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_13547.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_14690.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_15789.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_18878.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_19281.txt7
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_19539.txt9
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_9669.txt8
-rw-r--r--test/prism/fixtures/whitequark/sclass.txt1
-rw-r--r--test/prism/fixtures/whitequark/self.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_attr_asgn.txt7
-rw-r--r--test/prism/fixtures/whitequark/send_attr_asgn_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_binary_op.txt41
-rw-r--r--test/prism/fixtures/whitequark/send_block_chain_cmd.txt13
-rw-r--r--test/prism/fixtures/whitequark/send_block_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_call.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_asgn_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_lambda.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args_noparen.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args_shadow.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_op_asgn_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_plain.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_plain_cmd.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_self.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_self_block.txt7
-rw-r--r--test/prism/fixtures/whitequark/send_unary_op.txt5
-rw-r--r--test/prism/fixtures/whitequark/slash_newline_in_heredocs.txt13
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_block.txt5
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_call.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/space_args_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/string___FILE__.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_concat.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_dvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_plain.txt3
-rw-r--r--test/prism/fixtures/whitequark/super.txt5
-rw-r--r--test/prism/fixtures/whitequark/super_block.txt3
-rw-r--r--test/prism/fixtures/whitequark/symbol_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/symbol_plain.txt3
-rw-r--r--test/prism/fixtures/whitequark/ternary.txt1
-rw-r--r--test/prism/fixtures/whitequark/ternary_ambiguous_symbol.txt1
-rw-r--r--test/prism/fixtures/whitequark/trailing_forward_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/true.txt1
-rw-r--r--test/prism/fixtures/whitequark/unary_num_pow_precedence.txt5
-rw-r--r--test/prism/fixtures/whitequark/undef.txt1
-rw-r--r--test/prism/fixtures/whitequark/unless.txt3
-rw-r--r--test/prism/fixtures/whitequark/unless_else.txt3
-rw-r--r--test/prism/fixtures/whitequark/unless_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/until.txt3
-rw-r--r--test/prism/fixtures/whitequark/until_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/until_post.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_and_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_op_asgn.txt7
-rw-r--r--test/prism/fixtures/whitequark/var_op_asgn_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_or_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_multi.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_splat.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_then.txt1
-rw-r--r--test/prism/fixtures/whitequark/while.txt3
-rw-r--r--test/prism/fixtures/whitequark/while_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/while_post.txt1
-rw-r--r--test/prism/fixtures/whitequark/xstring_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/xstring_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/zsuper.txt1
-rw-r--r--test/prism/fixtures/write_command_operator.txt3
-rw-r--r--test/prism/fixtures/xstring.txt21
-rw-r--r--test/prism/fixtures/xstring_with_backslash.txt1
-rw-r--r--test/prism/fixtures/yield.txt7
-rw-r--r--test/prism/fixtures_test.rb38
-rw-r--r--test/prism/fuzzer_test.rb67
-rw-r--r--test/prism/heredoc_dedent_test.rb134
-rw-r--r--test/prism/lex_test.rb123
-rw-r--r--test/prism/library_symbols_test.rb104
-rw-r--r--test/prism/locals_test.rb245
-rw-r--r--test/prism/magic_comment_test.rb122
-rw-r--r--test/prism/newline_offsets_test.rb45
-rw-r--r--test/prism/newline_test.rb101
-rw-r--r--test/prism/onigmo_test.rb66
-rw-r--r--test/prism/percent_delimiter_string_test.rb82
-rw-r--r--test/prism/ractor_test.rb74
-rw-r--r--test/prism/regexp_test.rb265
-rw-r--r--test/prism/result/attribute_write_test.rb56
-rw-r--r--test/prism/result/breadth_first_search_test.rb29
-rw-r--r--test/prism/result/comments_test.rb138
-rw-r--r--test/prism/result/constant_path_node_test.rb91
-rw-r--r--test/prism/result/continuable_test.rb124
-rw-r--r--test/prism/result/equality_test.rb22
-rw-r--r--test/prism/result/error_recovery_test.rb237
-rw-r--r--test/prism/result/heredoc_test.rb19
-rw-r--r--test/prism/result/implicit_array_test.rb59
-rw-r--r--test/prism/result/index_write_test.rb89
-rw-r--r--test/prism/result/integer_base_flags_test.rb33
-rw-r--r--test/prism/result/integer_parse_test.rb41
-rw-r--r--test/prism/result/named_capture_test.rb29
-rw-r--r--test/prism/result/node_id_test.rb27
-rw-r--r--test/prism/result/numeric_value_test.rb32
-rw-r--r--test/prism/result/overlap_test.rb48
-rw-r--r--test/prism/result/regular_expression_options_test.rb25
-rw-r--r--test/prism/result/source_location_test.rb954
-rw-r--r--test/prism/result/static_inspect_test.rb89
-rw-r--r--test/prism/result/static_literals_test.rb92
-rw-r--r--test/prism/result/string_test.rb32
-rw-r--r--test/prism/result/warnings_test.rb451
-rw-r--r--test/prism/ruby/compiler_test.rb31
-rw-r--r--test/prism/ruby/desugar_compiler_test.rb80
-rw-r--r--test/prism/ruby/dispatcher_test.rb55
-rw-r--r--test/prism/ruby/find_fixtures.rb69
-rw-r--r--test/prism/ruby/find_test.rb242
-rw-r--r--test/prism/ruby/location_test.rb254
-rw-r--r--test/prism/ruby/parameters_signature_test.rb105
-rw-r--r--test/prism/ruby/parser_test.rb323
-rw-r--r--test/prism/ruby/pattern_test.rb132
-rw-r--r--test/prism/ruby/reflection_test.rb22
-rw-r--r--test/prism/ruby/relocation_test.rb192
-rw-r--r--test/prism/ruby/ripper_test.rb309
-rw-r--r--test/prism/ruby/ruby_parser_test.rb140
-rw-r--r--test/prism/ruby/source_test.rb51
-rw-r--r--test/prism/ruby/string_query_test.rb60
-rw-r--r--test/prism/ruby/tunnel_test.rb26
-rw-r--r--test/prism/snippets_test.rb43
-rw-r--r--test/prism/test_helper.rb386
-rw-r--r--test/prism/unescape_test.rb245
-rw-r--r--test/prism/version_test.rb11
-rw-r--r--test/psych/helper.rb1
-rw-r--r--test/psych/test_data.rb93
-rw-r--r--test/psych/test_date_time.rb16
-rw-r--r--test/psych/test_exception.rb13
-rw-r--r--test/psych/test_numeric.rb9
-rw-r--r--test/psych/test_object_references.rb13
-rw-r--r--test/psych/test_parser.rb61
-rw-r--r--test/psych/test_psych.rb37
-rw-r--r--test/psych/test_psych_set.rb57
-rw-r--r--test/psych/test_ractor.rb6
-rw-r--r--test/psych/test_safe_load.rb32
-rw-r--r--test/psych/test_scalar_scanner.rb21
-rw-r--r--test/psych/test_serialize_subclasses.rb18
-rw-r--r--test/psych/test_set.rb54
-rw-r--r--test/psych/test_stream.rb8
-rw-r--r--test/psych/test_string.rb22
-rw-r--r--test/psych/test_stringio.rb14
-rw-r--r--test/psych/test_yaml.rb928
-rw-r--r--test/psych/test_yaml_special_cases.rb12
-rw-r--r--test/psych/test_yamlstore.rb16
-rw-r--r--test/psych/visitors/test_emitter.rb16
-rw-r--r--test/psych/visitors/test_to_ruby.rb8
-rw-r--r--test/psych/visitors/test_yaml_tree.rb29
-rw-r--r--test/racc/assets/cadenza.y170
-rw-r--r--test/racc/assets/cast.y926
-rw-r--r--test/racc/assets/chk.y126
-rw-r--r--test/racc/assets/conf.y16
-rw-r--r--test/racc/assets/csspool.y729
-rw-r--r--test/racc/assets/digraph.y29
-rw-r--r--test/racc/assets/echk.y118
-rw-r--r--test/racc/assets/edtf.y583
-rw-r--r--test/racc/assets/err.y60
-rw-r--r--test/racc/assets/error_recovery.y35
-rw-r--r--test/racc/assets/expect.y7
-rw-r--r--test/racc/assets/firstline.y4
-rw-r--r--test/racc/assets/huia.y318
-rw-r--r--test/racc/assets/ichk.y102
-rw-r--r--test/racc/assets/ifelse.y14
-rw-r--r--test/racc/assets/intp.y546
-rw-r--r--test/racc/assets/journey.y47
-rw-r--r--test/racc/assets/liquor.y313
-rw-r--r--test/racc/assets/machete.y423
-rw-r--r--test/racc/assets/macruby.y2197
-rw-r--r--test/racc/assets/mailp.y437
-rw-r--r--test/racc/assets/mediacloth.y599
-rw-r--r--test/racc/assets/mof.y649
-rw-r--r--test/racc/assets/namae.y302
-rw-r--r--test/racc/assets/nasl.y626
-rw-r--r--test/racc/assets/newsyn.y25
-rw-r--r--test/racc/assets/noend.y4
-rw-r--r--test/racc/assets/nokogiri-css.y255
-rw-r--r--test/racc/assets/nonass.y41
-rw-r--r--test/racc/assets/normal.y27
-rw-r--r--test/racc/assets/norule.y4
-rw-r--r--test/racc/assets/nullbug1.y25
-rw-r--r--test/racc/assets/nullbug2.y15
-rw-r--r--test/racc/assets/opal.y1807
-rw-r--r--test/racc/assets/opt.y123
-rw-r--r--test/racc/assets/percent.y35
-rw-r--r--test/racc/assets/php_serialization.y98
-rw-r--r--test/racc/assets/recv.y97
-rw-r--r--test/racc/assets/riml.y665
-rw-r--r--test/racc/assets/rrconf.y14
-rw-r--r--test/racc/assets/ruby18.y1943
-rw-r--r--test/racc/assets/ruby19.y2174
-rw-r--r--test/racc/assets/ruby20.y2350
-rw-r--r--test/racc/assets/ruby21.y2359
-rw-r--r--test/racc/assets/ruby22.y2381
-rw-r--r--test/racc/assets/scan.y72
-rw-r--r--test/racc/assets/syntax.y50
-rw-r--r--test/racc/assets/tp_plus.y622
-rw-r--r--test/racc/assets/twowaysql.y278
-rw-r--r--test/racc/assets/unterm.y5
-rw-r--r--test/racc/assets/useless.y12
-rw-r--r--test/racc/assets/yyerr.y46
-rw-r--r--test/racc/bench.y36
-rw-r--r--test/racc/case.rb111
-rw-r--r--test/racc/infini.y8
-rw-r--r--test/racc/regress/README.txt7
-rw-r--r--test/racc/regress/cadenza798
-rw-r--r--test/racc/regress/cast3947
-rw-r--r--test/racc/regress/csspool2316
-rw-r--r--test/racc/regress/edtf1796
-rw-r--r--test/racc/regress/huia1683
-rw-r--r--test/racc/regress/journey224
-rw-r--r--test/racc/regress/liquor887
-rw-r--r--test/racc/regress/machete835
-rw-r--r--test/racc/regress/mediacloth1465
-rw-r--r--test/racc/regress/mof1370
-rw-r--r--test/racc/regress/namae636
-rw-r--r--test/racc/regress/nasl2550
-rw-r--r--test/racc/regress/nokogiri-css838
-rw-r--r--test/racc/regress/opal10109
-rw-r--r--test/racc/regress/php_serialization338
-rw-r--r--test/racc/regress/riml4039
-rw-r--r--test/racc/regress/ruby189947
-rw-r--r--test/racc/regress/ruby2211182
-rw-r--r--test/racc/regress/tp_plus1935
-rw-r--r--test/racc/regress/twowaysql558
-rw-r--r--test/racc/scandata/brace7
-rw-r--r--test/racc/scandata/gvar1
-rw-r--r--test/racc/scandata/normal4
-rw-r--r--test/racc/scandata/percent18
-rw-r--r--test/racc/scandata/slash10
-rw-r--r--test/racc/src.intp34
-rw-r--r--test/racc/start.y20
-rw-r--r--test/racc/test_chk_y.rb52
-rw-r--r--test/racc/test_grammar_file_parser.rb15
-rw-r--r--test/racc/test_racc_command.rb339
-rw-r--r--test/racc/test_scan_y.rb52
-rw-r--r--test/racc/testscanner.rb51
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Amps and angle encoding.text21
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Auto links.text13
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Backslash escapes.text120
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Blockquotes with code blocks.text11
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Code Blocks.text14
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Code Spans.text6
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text8
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Horizontal rules.text67
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Inline HTML (Advanced).text15
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Inline HTML (Simple).text69
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Inline HTML comments.text13
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Links, inline style.text12
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Links, reference style.text71
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Links, shortcut references.text20
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Literal quotes in titles.text7
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Basics.text306
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text888
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Nested blockquotes.text5
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Ordered and unordered lists.text131
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Strong and em together.text7
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Tabs.text21
-rw-r--r--test/rdoc/MarkdownTest_1.0.3/Tidyness.text5
-rw-r--r--test/rdoc/README1
-rw-r--r--test/rdoc/binary.datbin1024 -> 0 bytes-rw-r--r--test/rdoc/helper.rb5
-rw-r--r--test/rdoc/hidden.zip.txt1
-rw-r--r--test/rdoc/support/formatter_test_case.rb764
-rw-r--r--test/rdoc/support/test_case.rb217
-rw-r--r--test/rdoc/support/text_formatter_test_case.rb115
-rw-r--r--test/rdoc/test.ja.largedoc3
-rw-r--r--test/rdoc/test.ja.rdoc10
-rw-r--r--test/rdoc/test.ja.txt8
-rw-r--r--test/rdoc/test.txt1
-rw-r--r--test/rdoc/test_rdoc_alias.rb13
-rw-r--r--test/rdoc/test_rdoc_any_method.rb571
-rw-r--r--test/rdoc/test_rdoc_attr.rb190
-rw-r--r--test/rdoc/test_rdoc_class_module.rb1503
-rw-r--r--test/rdoc/test_rdoc_code_object.rb440
-rw-r--r--test/rdoc/test_rdoc_comment.rb497
-rw-r--r--test/rdoc/test_rdoc_constant.rb182
-rw-r--r--test/rdoc/test_rdoc_context.rb965
-rw-r--r--test/rdoc/test_rdoc_context_section.rb147
-rw-r--r--test/rdoc/test_rdoc_cross_reference.rb219
-rw-r--r--test/rdoc/test_rdoc_encoding.rb184
-rw-r--r--test/rdoc/test_rdoc_extend.rb94
-rw-r--r--test/rdoc/test_rdoc_generator_darkfish.rb344
-rw-r--r--test/rdoc/test_rdoc_generator_json_index.rb349
-rw-r--r--test/rdoc/test_rdoc_generator_markup.rb60
-rw-r--r--test/rdoc/test_rdoc_generator_pot.rb92
-rw-r--r--test/rdoc/test_rdoc_generator_pot_po.rb52
-rw-r--r--test/rdoc/test_rdoc_generator_pot_po_entry.rb140
-rw-r--r--test/rdoc/test_rdoc_generator_ri.rb76
-rw-r--r--test/rdoc/test_rdoc_i18n_locale.rb74
-rw-r--r--test/rdoc/test_rdoc_i18n_text.rb124
-rw-r--r--test/rdoc/test_rdoc_include.rb109
-rw-r--r--test/rdoc/test_rdoc_markdown.rb1090
-rw-r--r--test/rdoc/test_rdoc_markdown_test.rb1883
-rw-r--r--test/rdoc/test_rdoc_markup.rb96
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb396
-rw-r--r--test/rdoc/test_rdoc_markup_attributes.rb40
-rw-r--r--test/rdoc/test_rdoc_markup_document.rb208
-rw-r--r--test/rdoc/test_rdoc_markup_formatter.rb175
-rw-r--r--test/rdoc/test_rdoc_markup_hard_break.rb32
-rw-r--r--test/rdoc/test_rdoc_markup_heading.rb30
-rw-r--r--test/rdoc/test_rdoc_markup_include.rb20
-rw-r--r--test/rdoc/test_rdoc_markup_indented_paragraph.rb54
-rw-r--r--test/rdoc/test_rdoc_markup_paragraph.rb33
-rw-r--r--test/rdoc/test_rdoc_markup_parser.rb1684
-rw-r--r--test/rdoc/test_rdoc_markup_pre_process.rb467
-rw-r--r--test/rdoc/test_rdoc_markup_raw.rb23
-rw-r--r--test/rdoc/test_rdoc_markup_to_ansi.rb370
-rw-r--r--test/rdoc/test_rdoc_markup_to_bs.rb352
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb960
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_crossref.rb268
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_snippet.rb709
-rw-r--r--test/rdoc/test_rdoc_markup_to_joined_paragraph.rb33
-rw-r--r--test/rdoc/test_rdoc_markup_to_label.rb113
-rw-r--r--test/rdoc/test_rdoc_markup_to_markdown.rb390
-rw-r--r--test/rdoc/test_rdoc_markup_to_rdoc.rb378
-rw-r--r--test/rdoc/test_rdoc_markup_to_table_of_contents.rb127
-rw-r--r--test/rdoc/test_rdoc_markup_to_tt_only.rb247
-rw-r--r--test/rdoc/test_rdoc_markup_verbatim.rb30
-rw-r--r--test/rdoc/test_rdoc_method_attr.rb193
-rw-r--r--test/rdoc/test_rdoc_normal_class.rb47
-rw-r--r--test/rdoc/test_rdoc_normal_module.rb42
-rw-r--r--test/rdoc/test_rdoc_options.rb910
-rw-r--r--test/rdoc/test_rdoc_parser.rb323
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb2071
-rw-r--r--test/rdoc/test_rdoc_parser_changelog.rb485
-rw-r--r--test/rdoc/test_rdoc_parser_markdown.rb62
-rw-r--r--test/rdoc/test_rdoc_parser_rd.rb56
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb4361
-rw-r--r--test/rdoc/test_rdoc_parser_simple.rb116
-rw-r--r--test/rdoc/test_rdoc_rd.rb31
-rw-r--r--test/rdoc/test_rdoc_rd_block_parser.rb557
-rw-r--r--test/rdoc/test_rdoc_rd_inline.rb64
-rw-r--r--test/rdoc/test_rdoc_rd_inline_parser.rb178
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb593
-rw-r--r--test/rdoc/test_rdoc_require.rb25
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb1561
-rw-r--r--test/rdoc/test_rdoc_ri_paths.rb158
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb287
-rw-r--r--test/rdoc/test_rdoc_servlet.rb555
-rw-r--r--test/rdoc/test_rdoc_single_class.rb21
-rw-r--r--test/rdoc/test_rdoc_stats.rb723
-rw-r--r--test/rdoc/test_rdoc_store.rb1012
-rw-r--r--test/rdoc/test_rdoc_task.rb182
-rw-r--r--test/rdoc/test_rdoc_text.rb585
-rw-r--r--test/rdoc/test_rdoc_token_stream.rb58
-rw-r--r--test/rdoc/test_rdoc_tom_doc.rb579
-rw-r--r--test/rdoc/test_rdoc_top_level.rb290
-rw-r--r--test/rdoc/xref_data.rb152
-rw-r--r--test/rdoc/xref_test_case.rb94
-rw-r--r--test/readline/helper.rb35
-rw-r--r--test/readline/test_readline.rb955
-rw-r--r--test/readline/test_readline_history.rb292
-rw-r--r--test/reline/helper.rb169
-rw-r--r--test/reline/test_ansi_with_terminfo.rb82
-rw-r--r--test/reline/test_ansi_without_terminfo.rb75
-rw-r--r--test/reline/test_config.rb412
-rw-r--r--test/reline/test_history.rb308
-rw-r--r--test/reline/test_key_actor_emacs.rb2354
-rw-r--r--test/reline/test_key_actor_vi.rb1465
-rw-r--r--test/reline/test_key_stroke.rb79
-rw-r--r--test/reline/test_kill_ring.rb268
-rw-r--r--test/reline/test_macro.rb41
-rw-r--r--test/reline/test_reline.rb386
-rw-r--r--test/reline/test_reline_key.rb53
-rw-r--r--test/reline/test_string_processing.rb81
-rw-r--r--test/reline/test_terminfo.rb61
-rw-r--r--test/reline/test_unicode.rb25
-rw-r--r--test/reline/test_within_pipe.rb78
-rw-r--r--test/reline/windows/test_key_event_record.rb41
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl236
-rw-r--r--test/reline/yamatanooroti/termination_checker.rb26
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb1471
-rw-r--r--test/resolv/test_dns.rb490
-rw-r--r--test/resolv/test_resource.rb144
-rw-r--r--test/resolv/test_svcb_https.rb231
-rw-r--r--test/resolv/test_win32_config.rb26
-rw-r--r--test/rinda/test_rinda.rb912
-rw-r--r--test/rinda/test_tuplebag.rb173
-rw-r--r--test/ripper/assert_parse_files.rb26
-rw-r--r--test/ripper/dummyparser.rb53
-rw-r--r--test/ripper/test_lexer.rb395
-rw-r--r--test/ripper/test_parser_events.rb156
-rw-r--r--test/ripper/test_ripper.rb68
-rw-r--r--test/ripper/test_scanner_events.rb27
-rw-r--r--test/ripper/test_sexp.rb54
-rw-r--r--test/ruby/box/a.1_1_0.rb17
-rw-r--r--test/ruby/box/a.1_2_0.rb17
-rw-r--r--test/ruby/box/a.rb15
-rw-r--r--test/ruby/box/autoloading.rb8
-rw-r--r--test/ruby/box/blank.rb2
-rw-r--r--test/ruby/box/blank1.rb2
-rw-r--r--test/ruby/box/blank2.rb2
-rw-r--r--test/ruby/box/box.rb10
-rw-r--r--test/ruby/box/call_proc.rb5
-rw-r--r--test/ruby/box/call_toplevel.rb8
-rw-r--r--test/ruby/box/consts.rb148
-rw-r--r--test/ruby/box/define_toplevel.rb5
-rw-r--r--test/ruby/box/global_vars.rb37
-rw-r--r--test/ruby/box/instance_variables.rb21
-rw-r--r--test/ruby/box/line_splitter.rb9
-rw-r--r--test/ruby/box/load_path.rb26
-rw-r--r--test/ruby/box/open_class_with_include.rb31
-rw-r--r--test/ruby/box/proc_callee.rb14
-rw-r--r--test/ruby/box/proc_caller.rb5
-rw-r--r--test/ruby/box/procs.rb64
-rw-r--r--test/ruby/box/raise.rb3
-rw-r--r--test/ruby/box/returns_proc.rb12
-rw-r--r--test/ruby/box/singleton_methods.rb65
-rw-r--r--test/ruby/box/string_ext.rb13
-rw-r--r--test/ruby/box/string_ext_caller.rb5
-rw-r--r--test/ruby/box/string_ext_calling.rb1
-rw-r--r--test/ruby/box/string_ext_eval_caller.rb12
-rw-r--r--test/ruby/box/top_level.rb33
-rw-r--r--test/ruby/enc/test_case_comprehensive.rb61
-rw-r--r--test/ruby/enc/test_case_mapping.rb10
-rw-r--r--test/ruby/enc/test_case_options.rb12
-rw-r--r--test/ruby/enc/test_cesu8.rb4
-rw-r--r--test/ruby/enc/test_emoji_breaks.rb2
-rw-r--r--test/ruby/rjit/test_assembler.rb350
-rw-r--r--test/ruby/sentence.rb2
-rw-r--r--test/ruby/test_alias.rb49
-rw-r--r--test/ruby/test_allocation.rb957
-rw-r--r--test/ruby/test_argf.rb110
-rw-r--r--test/ruby/test_arity.rb1
-rw-r--r--test/ruby/test_array.rb243
-rw-r--r--test/ruby/test_assignment.rb10
-rw-r--r--test/ruby/test_ast.rb733
-rw-r--r--test/ruby/test_autoload.rb123
-rw-r--r--test/ruby/test_backtrace.rb82
-rw-r--r--test/ruby/test_beginendblock.rb12
-rw-r--r--test/ruby/test_bignum.rb58
-rw-r--r--test/ruby/test_box.rb1219
-rw-r--r--test/ruby/test_call.rb1295
-rw-r--r--test/ruby/test_case.rb9
-rw-r--r--test/ruby/test_class.rb197
-rw-r--r--test/ruby/test_clone.rb7
-rw-r--r--test/ruby/test_comparable.rb6
-rw-r--r--test/ruby/test_compile_prism.rb2761
-rw-r--r--test/ruby/test_complex.rb139
-rw-r--r--test/ruby/test_continuation.rb4
-rw-r--r--test/ruby/test_data.rb53
-rw-r--r--test/ruby/test_default_gems.rb22
-rw-r--r--test/ruby/test_defined.rb109
-rw-r--r--test/ruby/test_dir.rb150
-rw-r--r--test/ruby/test_dir_m17n.rb46
-rw-r--r--test/ruby/test_econv.rb2
-rw-r--r--test/ruby/test_encoding.rb54
-rw-r--r--test/ruby/test_enum.rb20
-rw-r--r--test/ruby/test_enumerator.rb116
-rw-r--r--test/ruby/test_env.rb604
-rw-r--r--test/ruby/test_eval.rb50
-rw-r--r--test/ruby/test_exception.rb178
-rw-r--r--test/ruby/test_fiber.rb74
-rw-r--r--test/ruby/test_file.rb328
-rw-r--r--test/ruby/test_file_exhaustive.rb78
-rw-r--r--test/ruby/test_float.rb87
-rw-r--r--test/ruby/test_frozen.rb16
-rw-r--r--test/ruby/test_gc.rb534
-rw-r--r--test/ruby/test_gc_compact.rb241
-rw-r--r--test/ruby/test_hash.rb865
-rw-r--r--test/ruby/test_integer.rb110
-rw-r--r--test/ruby/test_io.rb412
-rw-r--r--test/ruby/test_io_buffer.rb660
-rw-r--r--test/ruby/test_io_m17n.rb37
-rw-r--r--test/ruby/test_iseq.rb373
-rw-r--r--test/ruby/test_iterator.rb16
-rw-r--r--test/ruby/test_keyword.rb191
-rw-r--r--test/ruby/test_lambda.rb28
-rw-r--r--test/ruby/test_lazy_enumerator.rb30
-rw-r--r--test/ruby/test_literal.rb66
-rw-r--r--test/ruby/test_m17n.rb223
-rw-r--r--test/ruby/test_marshal.rb135
-rw-r--r--test/ruby/test_math.rb42
-rw-r--r--test/ruby/test_memory_view.rb2
-rw-r--r--test/ruby/test_metaclass.rb2
-rw-r--r--test/ruby/test_method.rb379
-rw-r--r--test/ruby/test_mixed_unicode_escapes.rb2
-rw-r--r--test/ruby/test_module.rb248
-rw-r--r--test/ruby/test_nomethod_error.rb32
-rw-r--r--test/ruby/test_numeric.rb42
-rw-r--r--test/ruby/test_object.rb222
-rw-r--r--test/ruby/test_object_id.rb303
-rw-r--r--test/ruby/test_objectspace.rb111
-rw-r--r--test/ruby/test_optimization.rb360
-rw-r--r--test/ruby/test_pack.rb248
-rw-r--r--test/ruby/test_parse.rb614
-rw-r--r--test/ruby/test_pattern_matching.rb80
-rw-r--r--test/ruby/test_proc.rb458
-rw-r--r--test/ruby/test_process.rb435
-rw-r--r--test/ruby/test_ractor.rb377
-rw-r--r--test/ruby/test_rand.rb5
-rw-r--r--test/ruby/test_random_formatter.rb60
-rw-r--r--test/ruby/test_range.rb721
-rw-r--r--test/ruby/test_rational.rb57
-rw-r--r--test/ruby/test_refinement.rb1046
-rw-r--r--test/ruby/test_regexp.rb665
-rw-r--r--test/ruby/test_require.rb124
-rw-r--r--test/ruby/test_require_lib.rb31
-rw-r--r--test/ruby/test_rubyoptions.rb487
-rw-r--r--test/ruby/test_rubyvm.rb2
-rw-r--r--test/ruby/test_set.rb1072
-rw-r--r--test/ruby/test_settracefunc.rb526
-rw-r--r--test/ruby/test_shapes.rb987
-rw-r--r--test/ruby/test_signal.rb46
-rw-r--r--test/ruby/test_sleep.rb35
-rw-r--r--test/ruby/test_sprintf.rb25
-rw-r--r--test/ruby/test_stack.rb1
-rw-r--r--test/ruby/test_string.rb1092
-rw-r--r--test/ruby/test_string_memory.rb65
-rw-r--r--test/ruby/test_struct.rb36
-rw-r--r--test/ruby/test_super.rb91
-rw-r--r--test/ruby/test_symbol.rb16
-rw-r--r--test/ruby/test_syntax.rb828
-rw-r--r--test/ruby/test_system.rb13
-rw-r--r--test/ruby/test_thread.rb186
-rw-r--r--test/ruby/test_thread_cv.rb4
-rw-r--r--test/ruby/test_thread_queue.rb44
-rw-r--r--test/ruby/test_time.rb104
-rw-r--r--test/ruby/test_time_tz.rb11
-rw-r--r--test/ruby/test_transcode.rb608
-rw-r--r--test/ruby/test_variable.rb182
-rw-r--r--test/ruby/test_vm_dump.rb14
-rw-r--r--test/ruby/test_warning.rb32
-rw-r--r--test/ruby/test_weakkeymap.rb159
-rw-r--r--test/ruby/test_weakmap.rb107
-rw-r--r--test/ruby/test_whileuntil.rb18
-rw-r--r--test/ruby/test_yield.rb2
-rw-r--r--test/ruby/test_yjit.rb801
-rw-r--r--test/ruby/test_yjit_exit_locations.rb18
-rw-r--r--test/ruby/test_zjit.rb556
-rw-r--r--test/ruby/weakkeymap.rb112
-rw-r--r--test/rubygems/bad_rake.rb1
-rw-r--r--test/rubygems/bundler_test_gem.rb40
-rw-r--r--test/rubygems/coverage_setup.rb9
-rw-r--r--test/rubygems/fake_certlib/openssl.rb1
-rw-r--r--test/rubygems/good_rake.rb1
-rw-r--r--test/rubygems/helper.rb488
-rw-r--r--test/rubygems/installer_test_case.rb51
-rw-r--r--test/rubygems/mock_gem_ui.rb86
-rw-r--r--test/rubygems/multifactor_auth_utilities.rb111
-rw-r--r--test/rubygems/package/tar_test_case.rb47
-rw-r--r--test/rubygems/plugin/exception/rubygems_plugin.rb3
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb1
-rw-r--r--test/rubygems/plugin/scripterror/rubygems_plugin.rb4
-rw-r--r--test/rubygems/plugin/standarderror/rubygems_plugin.rb1
-rw-r--r--test/rubygems/rubygems/commands/crash_command.rb1
-rw-r--r--test/rubygems/rubygems/commands/ins_command.rb7
-rw-r--r--test/rubygems/rubygems/commands/interrupt_command.rb11
-rw-r--r--test/rubygems/rubygems_plugin.rb20
-rw-r--r--test/rubygems/simple_gem.rb1
-rw-r--r--test/rubygems/specifications/bar-0.0.2.gemspec2
-rw-r--r--test/rubygems/specifications/rubyforge-0.0.1.gemspec23
-rw-r--r--test/rubygems/test_bundled_ca.rb11
-rw-r--r--test/rubygems/test_config.rb14
-rw-r--r--test/rubygems/test_deprecate.rb3
-rw-r--r--test/rubygems/test_exit.rb2
-rw-r--r--test/rubygems/test_gem.rb310
-rw-r--r--test/rubygems/test_gem_available_set.rb7
-rw-r--r--test/rubygems/test_gem_bundler_version_finder.rb164
-rw-r--r--test/rubygems/test_gem_ci_detector.rb32
-rw-r--r--test/rubygems/test_gem_command.rb23
-rw-r--r--test/rubygems/test_gem_command_manager.rb75
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb26
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb64
-rw-r--r--test/rubygems/test_gem_commands_check_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb19
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb21
-rw-r--r--test/rubygems/test_gem_commands_dependency_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb49
-rw-r--r--test/rubygems/test_gem_commands_exec_command.rb76
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb99
-rw-r--r--test/rubygems/test_gem_commands_generate_index_command.rb80
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb7
-rw-r--r--test/rubygems/test_gem_commands_info_command.rb62
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb281
-rw-r--r--test/rubygems/test_gem_commands_list_command.rb30
-rw-r--r--test/rubygems/test_gem_commands_lock_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_mirror.rb3
-rw-r--r--test/rubygems/test_gem_commands_open_command.rb16
-rw-r--r--test/rubygems/test_gem_commands_outdated_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb244
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb109
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb302
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb857
-rw-r--r--test/rubygems/test_gem_commands_rebuild_command.rb154
-rw-r--r--test/rubygems/test_gem_commands_search_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb3
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb90
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb94
-rw-r--r--test/rubygems/test_gem_commands_signout_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb686
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb31
-rw-r--r--test/rubygems/test_gem_commands_stale_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb92
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb7
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb97
-rw-r--r--test/rubygems/test_gem_commands_which_command.rb15
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb136
-rw-r--r--test/rubygems/test_gem_config_file.rb227
-rw-r--r--test/rubygems/test_gem_console_ui.rb19
-rw-r--r--test/rubygems/test_gem_dependency.rb13
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb453
-rw-r--r--test/rubygems/test_gem_dependency_list.rb13
-rw-r--r--test/rubygems/test_gem_dependency_resolution_error.rb26
-rw-r--r--test/rubygems/test_gem_doctor.rb1
-rw-r--r--test/rubygems/test_gem_ext_builder.rb289
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb77
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock81
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock71
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb3
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_unit.rb2
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb104
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb3
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb43
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb23
-rw-r--r--test/rubygems/test_gem_gem_runner.rb28
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb225
-rw-r--r--test/rubygems/test_gem_impossible_dependencies_error.rb59
-rw-r--r--test/rubygems/test_gem_indexer.rb380
-rw-r--r--test/rubygems/test_gem_install_update_options.rb38
-rw-r--r--test/rubygems/test_gem_installer.rb722
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb13
-rw-r--r--test/rubygems/test_gem_name_tuple.rb67
-rw-r--r--test/rubygems/test_gem_package.rb411
-rw-r--r--test/rubygems/test_gem_package_old.rb7
-rw-r--r--test/rubygems/test_gem_package_tar_header.rb80
-rw-r--r--test/rubygems/test_gem_package_tar_header_ractor.rb61
-rw-r--r--test/rubygems/test_gem_package_tar_reader.rb24
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb63
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb70
-rw-r--r--test/rubygems/test_gem_package_task.rb5
-rw-r--r--test/rubygems/test_gem_path_support.rb9
-rw-r--r--test/rubygems/test_gem_platform.rb380
-rw-r--r--test/rubygems/test_gem_rdoc.rb15
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb897
-rw-r--r--test/rubygems/test_gem_remote_fetcher_local_server.rb220
-rw-r--r--test/rubygems/test_gem_remote_fetcher_local_ssl_server.rb195
-rw-r--r--test/rubygems/test_gem_remote_fetcher_s3.rb437
-rw-r--r--test/rubygems/test_gem_request.rb136
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb33
-rw-r--r--test/rubygems/test_gem_request_set.rb187
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb139
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb1
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_parser.rb543
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_tokenizer.rb306
-rw-r--r--test/rubygems/test_gem_requirement.rb41
-rw-r--r--test/rubygems/test_gem_resolver.rb569
-rw-r--r--test/rubygems/test_gem_resolver_activation_request.rb15
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb131
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb69
-rw-r--r--test/rubygems/test_gem_resolver_best_set.rb115
-rw-r--r--test/rubygems/test_gem_resolver_composed_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_conflict.rb81
-rw-r--r--test/rubygems/test_gem_resolver_dependency_request.rb25
-rw-r--r--test/rubygems/test_gem_resolver_git_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb41
-rw-r--r--test/rubygems/test_gem_resolver_index_set.rb29
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_installed_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb23
-rw-r--r--test/rubygems/test_gem_resolver_local_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_lock_set.rb7
-rw-r--r--test/rubygems/test_gem_resolver_lock_specification.rb15
-rw-r--r--test/rubygems/test_gem_resolver_requirement_list.rb1
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb3
-rw-r--r--test/rubygems/test_gem_resolver_strategy.rb163
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_vendor_specification.rb1
-rw-r--r--test/rubygems/test_gem_safe_marshal.rb518
-rw-r--r--test/rubygems/test_gem_safe_yaml.rb1326
-rw-r--r--test/rubygems/test_gem_security.rb59
-rw-r--r--test/rubygems/test_gem_security_policy.rb48
-rw-r--r--test/rubygems/test_gem_security_signer.rb19
-rw-r--r--test/rubygems/test_gem_security_trust_dir.rb19
-rw-r--r--test/rubygems/test_gem_silent_ui.rb2
-rw-r--r--test/rubygems/test_gem_source.rb40
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb1
-rw-r--r--test/rubygems/test_gem_source_git.rb13
-rw-r--r--test/rubygems/test_gem_source_installed.rb8
-rw-r--r--test/rubygems/test_gem_source_list.rb132
-rw-r--r--test/rubygems/test_gem_source_local.rb34
-rw-r--r--test/rubygems/test_gem_source_lock.rb5
-rw-r--r--test/rubygems/test_gem_source_specific_file.rb9
-rw-r--r--test/rubygems/test_gem_source_subpath_problem.rb9
-rw-r--r--test/rubygems/test_gem_source_vendor.rb3
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb59
-rw-r--r--test/rubygems/test_gem_specification.rb819
-rw-r--r--test/rubygems/test_gem_stream_ui.rb49
-rw-r--r--test/rubygems/test_gem_stub_specification.rb122
-rw-r--r--test/rubygems/test_gem_text.rb1
-rw-r--r--test/rubygems/test_gem_uninstaller.rb200
-rw-r--r--test/rubygems/test_gem_unsatisfiable_dependency_error.rb1
-rw-r--r--test/rubygems/test_gem_update_suggestion.rb145
-rw-r--r--test/rubygems/test_gem_uri.rb4
-rw-r--r--test/rubygems/test_gem_uri_formatter.rb1
-rw-r--r--test/rubygems/test_gem_util.rb18
-rw-r--r--test/rubygems/test_gem_util_atomic_file_writer.rb12
-rw-r--r--test/rubygems/test_gem_version.rb93
-rw-r--r--test/rubygems/test_gem_version_option.rb49
-rw-r--r--test/rubygems/test_kernel.rb19
-rw-r--r--test/rubygems/test_project_sanity.rb16
-rw-r--r--test/rubygems/test_remote_fetch_error.rb5
-rw-r--r--test/rubygems/test_require.rb160
-rw-r--r--test/rubygems/test_rubygems.rb11
-rw-r--r--test/rubygems/test_webauthn_listener.rb143
-rw-r--r--test/rubygems/test_webauthn_listener_response.rb93
-rw-r--r--test/rubygems/test_webauthn_poller.rb134
-rw-r--r--test/rubygems/utilities.rb92
-rw-r--r--test/runner.rb13
-rw-r--r--test/socket/test_addrinfo.rb10
-rw-r--r--test/socket/test_nonblock.rb4
-rw-r--r--test/socket/test_socket.rb441
-rw-r--r--test/socket/test_tcp.rb294
-rw-r--r--test/socket/test_unix.rb89
-rw-r--r--test/stringio/test_ractor.rb8
-rw-r--r--test/stringio/test_stringio.rb301
-rw-r--r--test/strscan/test_ractor.rb8
-rw-r--r--test/strscan/test_stringscanner.rb988
-rw-r--r--test/syslog/test_syslog_logger.rb588
-rw-r--r--test/test_abbrev.rb55
-rw-r--r--test/test_bundled_gems.rb73
-rw-r--r--test/test_delegate.rb66
-rw-r--r--test/test_extlibs.rb11
-rw-r--r--test/test_forwardable.rb2
-rw-r--r--test/test_getoptlong.rb163
-rw-r--r--test/test_ipaddr.rb209
-rw-r--r--test/test_mutex_m.rb79
-rw-r--r--test/test_observer.rb66
-rw-r--r--test/test_pp.rb168
-rw-r--r--test/test_prettyprint.rb71
-rw-r--r--test/test_pstore.rb182
-rw-r--r--test/test_pty.rb8
-rw-r--r--test/test_rbconfig.rb15
-rw-r--r--test/test_securerandom.rb20
-rw-r--r--test/test_set.rb892
-rw-r--r--test/test_shellwords.rb9
-rw-r--r--test/test_singleton.rb21
-rw-r--r--test/test_sorted_set.rb45
-rw-r--r--test/test_syslog.rb193
-rw-r--r--test/test_tempfile.rb118
-rw-r--r--test/test_time.rb11
-rw-r--r--test/test_timeout.rb365
-rw-r--r--test/test_tmpdir.rb47
-rw-r--r--test/test_trick.rb65
-rw-r--r--test/test_tsort.rb115
-rw-r--r--test/test_unicode_normalize.rb28
-rw-r--r--test/uri/test_common.rb86
-rw-r--r--test/uri/test_ftp.rb20
-rw-r--r--test/uri/test_generic.rb107
-rw-r--r--test/uri/test_http.rb28
-rw-r--r--test/uri/test_ldap.rb8
-rw-r--r--test/uri/test_mailto.rb72
-rw-r--r--test/uri/test_parser.rb70
-rw-r--r--test/uri/test_ws.rb24
-rw-r--r--test/uri/test_wss.rb24
-rw-r--r--test/win32ole/available_ole.rb41
-rw-r--r--test/win32ole/err_in_callback.rb10
-rw-r--r--test/win32ole/orig_data.csv5
-rw-r--r--test/win32ole/test_err_in_callback.rb56
-rw-r--r--test/win32ole/test_folderitem2_invokeverb.rb66
-rw-r--r--test/win32ole/test_nil2vtempty.rb37
-rw-r--r--test/win32ole/test_ole_methods.rb35
-rw-r--r--test/win32ole/test_propertyputref.rb31
-rw-r--r--test/win32ole/test_thread.rb34
-rw-r--r--test/win32ole/test_win32ole.rb534
-rw-r--r--test/win32ole/test_win32ole_event.rb407
-rw-r--r--test/win32ole/test_win32ole_method.rb134
-rw-r--r--test/win32ole/test_win32ole_method_event.rb36
-rw-r--r--test/win32ole/test_win32ole_param.rb98
-rw-r--r--test/win32ole/test_win32ole_param_event.rb30
-rw-r--r--test/win32ole/test_win32ole_record.rb209
-rw-r--r--test/win32ole/test_win32ole_type.rb200
-rw-r--r--test/win32ole/test_win32ole_type_event.rb44
-rw-r--r--test/win32ole/test_win32ole_typelib.rb117
-rw-r--r--test/win32ole/test_win32ole_variable.rb66
-rw-r--r--test/win32ole/test_win32ole_variant.rb722
-rw-r--r--test/win32ole/test_win32ole_variant_m.rb36
-rw-r--r--test/win32ole/test_win32ole_variant_outarg.rb69
-rw-r--r--test/win32ole/test_word.rb73
-rw-r--r--test/yaml/test_dbm.rb46
-rw-r--r--test/yaml/test_store.rb10
-rw-r--r--test/zlib/test_zlib.rb162
-rw-r--r--thread.c1664
-rw-r--r--thread_none.c88
-rw-r--r--thread_none.h1
-rw-r--r--thread_pthread.c3607
-rw-r--r--thread_pthread.h143
-rw-r--r--thread_pthread_mn.c1125
-rw-r--r--thread_sync.c1503
-rw-r--r--thread_sync.rb649
-rw-r--r--thread_win32.c255
-rw-r--r--thread_win32.h7
-rw-r--r--time.c554
-rw-r--r--timev.h7
-rw-r--r--timev.rb114
-rw-r--r--tool/annocheck/Dockerfile2
-rw-r--r--tool/annocheck/Dockerfile-copy7
-rwxr-xr-xtool/auto-style.rb284
-rwxr-xr-xtool/auto_review_pr.rb172
-rw-r--r--tool/bundler/dev_gems.rb14
-rw-r--r--tool/bundler/dev_gems.rb.lock157
-rw-r--r--tool/bundler/rubocop_gems.rb7
-rw-r--r--tool/bundler/rubocop_gems.rb.lock183
-rw-r--r--tool/bundler/standard_gems.rb5
-rw-r--r--tool/bundler/standard_gems.rb.lock205
-rw-r--r--tool/bundler/test_gems.rb19
-rw-r--r--tool/bundler/test_gems.rb.lock117
-rw-r--r--tool/bundler/vendor_gems.rb17
-rw-r--r--tool/bundler/vendor_gems.rb.lock75
-rw-r--r--tool/ci_functions.sh29
-rwxr-xr-xtool/commit-email.rb372
-rwxr-xr-xtool/darwin-ar1
-rwxr-xr-xtool/darwin-cc3
-rw-r--r--tool/downloader.rb189
-rw-r--r--tool/dummy-rake-compiler/rake/extensiontask.rb9
-rw-r--r--tool/dump_ast.c77
-rwxr-xr-xtool/dump_ast.mkmf.rb37
-rwxr-xr-xtool/enc-unicode.rb123
-rwxr-xr-xtool/extlibs.rb2
-rw-r--r--tool/fake.rb11
-rwxr-xr-xtool/fetch-bundled_gems.rb52
-rwxr-xr-xtool/file2lastrev.rb1
-rwxr-xr-xtool/format-release65
-rwxr-xr-xtool/gen-github-release.rb19
-rw-r--r--tool/generic_erb.rb8
-rw-r--r--tool/gperf.sed19
-rwxr-xr-xtool/ifchange10
-rwxr-xr-xtool/leaked-globals65
-rw-r--r--tool/lib/_tmpdir.rb105
-rw-r--r--tool/lib/bundle_env.rb4
-rw-r--r--tool/lib/bundled_gem.rb81
-rw-r--r--tool/lib/colorize.rb89
-rw-r--r--tool/lib/core_assertions.rb345
-rw-r--r--tool/lib/dump.gdb17
-rw-r--r--tool/lib/dump.lldb13
-rw-r--r--tool/lib/envutil.rb181
-rw-r--r--tool/lib/gem_env.rb1
-rw-r--r--tool/lib/iseq_loader_checker.rb9
-rw-r--r--tool/lib/launchable.rb91
-rw-r--r--tool/lib/leakchecker.rb49
-rw-r--r--tool/lib/memory_status.rb100
-rw-r--r--tool/lib/output.rb34
-rw-r--r--tool/lib/path.rb101
-rw-r--r--tool/lib/test/jobserver.rb47
-rw-r--r--tool/lib/test/unit.rb312
-rw-r--r--tool/lib/test/unit/assertions.rb53
-rw-r--r--tool/lib/test/unit/parallel.rb23
-rw-r--r--tool/lib/test/unit/testcase.rb22
-rw-r--r--tool/lib/vcs.rb426
-rw-r--r--tool/lib/webrick.rb232
-rw-r--r--tool/lib/webrick/.document6
-rw-r--r--tool/lib/webrick/accesslog.rb157
-rw-r--r--tool/lib/webrick/cgi.rb313
-rw-r--r--tool/lib/webrick/compat.rb36
-rw-r--r--tool/lib/webrick/config.rb158
-rw-r--r--tool/lib/webrick/cookie.rb172
-rw-r--r--tool/lib/webrick/htmlutils.rb30
-rw-r--r--tool/lib/webrick/httpauth.rb96
-rw-r--r--tool/lib/webrick/httpauth/authenticator.rb117
-rw-r--r--tool/lib/webrick/httpauth/basicauth.rb116
-rw-r--r--tool/lib/webrick/httpauth/digestauth.rb395
-rw-r--r--tool/lib/webrick/httpauth/htdigest.rb132
-rw-r--r--tool/lib/webrick/httpauth/htgroup.rb97
-rw-r--r--tool/lib/webrick/httpauth/htpasswd.rb158
-rw-r--r--tool/lib/webrick/httpauth/userdb.rb53
-rw-r--r--tool/lib/webrick/httpproxy.rb354
-rw-r--r--tool/lib/webrick/httprequest.rb636
-rw-r--r--tool/lib/webrick/httpresponse.rb564
-rw-r--r--tool/lib/webrick/https.rb152
-rw-r--r--tool/lib/webrick/httpserver.rb293
-rw-r--r--tool/lib/webrick/httpservlet.rb23
-rw-r--r--tool/lib/webrick/httpservlet/abstract.rb152
-rw-r--r--tool/lib/webrick/httpservlet/cgi_runner.rb47
-rw-r--r--tool/lib/webrick/httpservlet/cgihandler.rb126
-rw-r--r--tool/lib/webrick/httpservlet/erbhandler.rb88
-rw-r--r--tool/lib/webrick/httpservlet/filehandler.rb552
-rw-r--r--tool/lib/webrick/httpservlet/prochandler.rb47
-rw-r--r--tool/lib/webrick/httpstatus.rb194
-rw-r--r--tool/lib/webrick/httputils.rb512
-rw-r--r--tool/lib/webrick/httpversion.rb76
-rw-r--r--tool/lib/webrick/log.rb156
-rw-r--r--tool/lib/webrick/server.rb381
-rw-r--r--tool/lib/webrick/ssl.rb215
-rw-r--r--tool/lib/webrick/utils.rb265
-rw-r--r--tool/lib/webrick/version.rb18
-rwxr-xr-xtool/ln_sr.rb2
-rw-r--r--tool/lrama/LEGAL.md12
-rw-r--r--tool/lrama/MIT21
-rw-r--r--tool/lrama/NEWS.md1072
-rwxr-xr-xtool/lrama/exe/lrama7
-rw-r--r--tool/lrama/lib/lrama.rb22
-rw-r--r--tool/lrama/lib/lrama/bitmap.rb47
-rw-r--r--tool/lrama/lib/lrama/command.rb120
-rw-r--r--tool/lrama/lib/lrama/context.rb497
-rw-r--r--tool/lrama/lib/lrama/counterexamples.rb426
-rw-r--r--tool/lrama/lib/lrama/counterexamples/derivation.rb76
-rw-r--r--tool/lrama/lib/lrama/counterexamples/example.rb154
-rw-r--r--tool/lrama/lib/lrama/counterexamples/node.rb30
-rw-r--r--tool/lrama/lib/lrama/counterexamples/path.rb27
-rw-r--r--tool/lrama/lib/lrama/counterexamples/state_item.rb31
-rw-r--r--tool/lrama/lib/lrama/counterexamples/triple.rb41
-rw-r--r--tool/lrama/lib/lrama/diagram.rb77
-rw-r--r--tool/lrama/lib/lrama/digraph.rb104
-rw-r--r--tool/lrama/lib/lrama/erb.rb29
-rw-r--r--tool/lrama/lib/lrama/grammar.rb603
-rw-r--r--tool/lrama/lib/lrama/grammar/auxiliary.rb14
-rw-r--r--tool/lrama/lib/lrama/grammar/binding.rb80
-rw-r--r--tool/lrama/lib/lrama/grammar/code.rb68
-rw-r--r--tool/lrama/lib/lrama/grammar/code/destructor_code.rb53
-rw-r--r--tool/lrama/lib/lrama/grammar/code/initial_action_code.rb39
-rw-r--r--tool/lrama/lib/lrama/grammar/code/no_reference_code.rb33
-rw-r--r--tool/lrama/lib/lrama/grammar/code/printer_code.rb53
-rw-r--r--tool/lrama/lib/lrama/grammar/code/rule_action.rb128
-rw-r--r--tool/lrama/lib/lrama/grammar/counter.rb27
-rw-r--r--tool/lrama/lib/lrama/grammar/destructor.rb24
-rw-r--r--tool/lrama/lib/lrama/grammar/error_token.rb24
-rw-r--r--tool/lrama/lib/lrama/grammar/inline.rb3
-rw-r--r--tool/lrama/lib/lrama/grammar/inline/resolver.rb80
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterized.rb5
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterized/resolver.rb73
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterized/rhs.rb45
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterized/rule.rb36
-rw-r--r--tool/lrama/lib/lrama/grammar/percent_code.rb25
-rw-r--r--tool/lrama/lib/lrama/grammar/precedence.rb55
-rw-r--r--tool/lrama/lib/lrama/grammar/printer.rb20
-rw-r--r--tool/lrama/lib/lrama/grammar/reference.rb29
-rw-r--r--tool/lrama/lib/lrama/grammar/rule.rb135
-rw-r--r--tool/lrama/lib/lrama/grammar/rule_builder.rb270
-rw-r--r--tool/lrama/lib/lrama/grammar/stdlib.y142
-rw-r--r--tool/lrama/lib/lrama/grammar/symbol.rb149
-rw-r--r--tool/lrama/lib/lrama/grammar/symbols.rb3
-rw-r--r--tool/lrama/lib/lrama/grammar/symbols/resolver.rb362
-rw-r--r--tool/lrama/lib/lrama/grammar/type.rb32
-rw-r--r--tool/lrama/lib/lrama/grammar/union.rb23
-rw-r--r--tool/lrama/lib/lrama/lexer.rb219
-rw-r--r--tool/lrama/lib/lrama/lexer/grammar_file.rb40
-rw-r--r--tool/lrama/lib/lrama/lexer/location.rb132
-rw-r--r--tool/lrama/lib/lrama/lexer/token.rb20
-rw-r--r--tool/lrama/lib/lrama/lexer/token/base.rb73
-rw-r--r--tool/lrama/lib/lrama/lexer/token/char.rb24
-rw-r--r--tool/lrama/lib/lrama/lexer/token/empty.rb14
-rw-r--r--tool/lrama/lib/lrama/lexer/token/ident.rb11
-rw-r--r--tool/lrama/lib/lrama/lexer/token/instantiate_rule.rb30
-rw-r--r--tool/lrama/lib/lrama/lexer/token/int.rb14
-rw-r--r--tool/lrama/lib/lrama/lexer/token/str.rb11
-rw-r--r--tool/lrama/lib/lrama/lexer/token/tag.rb16
-rw-r--r--tool/lrama/lib/lrama/lexer/token/token.rb11
-rw-r--r--tool/lrama/lib/lrama/lexer/token/user_code.rb109
-rw-r--r--tool/lrama/lib/lrama/logger.rb31
-rw-r--r--tool/lrama/lib/lrama/option_parser.rb223
-rw-r--r--tool/lrama/lib/lrama/options.rb46
-rw-r--r--tool/lrama/lib/lrama/output.rb452
-rw-r--r--tool/lrama/lib/lrama/parser.rb2285
-rw-r--r--tool/lrama/lib/lrama/reporter.rb39
-rw-r--r--tool/lrama/lib/lrama/reporter/conflicts.rb44
-rw-r--r--tool/lrama/lib/lrama/reporter/grammar.rb39
-rw-r--r--tool/lrama/lib/lrama/reporter/precedences.rb54
-rw-r--r--tool/lrama/lib/lrama/reporter/profile.rb4
-rw-r--r--tool/lrama/lib/lrama/reporter/profile/call_stack.rb45
-rw-r--r--tool/lrama/lib/lrama/reporter/profile/memory.rb44
-rw-r--r--tool/lrama/lib/lrama/reporter/rules.rb43
-rw-r--r--tool/lrama/lib/lrama/reporter/states.rb387
-rw-r--r--tool/lrama/lib/lrama/reporter/terms.rb44
-rw-r--r--tool/lrama/lib/lrama/state.rb534
-rw-r--r--tool/lrama/lib/lrama/state/action.rb5
-rw-r--r--tool/lrama/lib/lrama/state/action/goto.rb33
-rw-r--r--tool/lrama/lib/lrama/state/action/reduce.rb71
-rw-r--r--tool/lrama/lib/lrama/state/action/shift.rb39
-rw-r--r--tool/lrama/lib/lrama/state/inadequacy_annotation.rb140
-rw-r--r--tool/lrama/lib/lrama/state/item.rb120
-rw-r--r--tool/lrama/lib/lrama/state/reduce_reduce_conflict.rb24
-rw-r--r--tool/lrama/lib/lrama/state/resolved_conflict.rb65
-rw-r--r--tool/lrama/lib/lrama/state/shift_reduce_conflict.rb24
-rw-r--r--tool/lrama/lib/lrama/states.rb867
-rw-r--r--tool/lrama/lib/lrama/tracer.rb51
-rw-r--r--tool/lrama/lib/lrama/tracer/actions.rb22
-rw-r--r--tool/lrama/lib/lrama/tracer/closure.rb30
-rw-r--r--tool/lrama/lib/lrama/tracer/duration.rb38
-rw-r--r--tool/lrama/lib/lrama/tracer/only_explicit_rules.rb24
-rw-r--r--tool/lrama/lib/lrama/tracer/rules.rb23
-rw-r--r--tool/lrama/lib/lrama/tracer/state.rb33
-rw-r--r--tool/lrama/lib/lrama/version.rb6
-rw-r--r--tool/lrama/lib/lrama/warnings.rb33
-rw-r--r--tool/lrama/lib/lrama/warnings/conflicts.rb27
-rw-r--r--tool/lrama/lib/lrama/warnings/implicit_empty.rb29
-rw-r--r--tool/lrama/lib/lrama/warnings/name_conflicts.rb63
-rw-r--r--tool/lrama/lib/lrama/warnings/redefined_rules.rb23
-rw-r--r--tool/lrama/lib/lrama/warnings/required.rb23
-rw-r--r--tool/lrama/lib/lrama/warnings/useless_precedence.rb25
-rw-r--r--tool/lrama/template/bison/_yacc.h79
-rw-r--r--tool/lrama/template/bison/yacc.c2068
-rw-r--r--tool/lrama/template/bison/yacc.h40
-rw-r--r--tool/lrama/template/diagram/diagram.html102
-rw-r--r--tool/m4/ruby_append_option.m44
-rw-r--r--tool/m4/ruby_check_builtin_overflow.m428
-rw-r--r--tool/m4/ruby_check_builtin_setjmp.m42
-rw-r--r--tool/m4/ruby_check_header.m48
-rw-r--r--tool/m4/ruby_default_arch.m425
-rw-r--r--tool/m4/ruby_defint.m43
-rw-r--r--tool/m4/ruby_modular_gc.m441
-rw-r--r--tool/m4/ruby_setjmp_type.m419
-rw-r--r--tool/m4/ruby_try_cflags.m430
-rw-r--r--tool/m4/ruby_universal_arch.m46
-rw-r--r--tool/m4/ruby_wasm_tools.m43
-rwxr-xr-xtool/make-snapshot136
-rwxr-xr-xtool/merger.rb208
-rwxr-xr-xtool/missing-baseruby.bat30
-rw-r--r--tool/mk_builtin_loader.rb439
-rwxr-xr-xtool/mk_rbbin.rb48
-rwxr-xr-xtool/mkconfig.rb12
-rwxr-xr-xtool/mkrunnable.rb102
-rw-r--r--tool/notes-github-pr.rb138
-rw-r--r--tool/notify-slack-commits.rb87
-rwxr-xr-xtool/outdate-bundled-gems.rb124
-rw-r--r--tool/prereq.status11
-rwxr-xr-xtool/rbinstall.rb825
-rw-r--r--tool/rbs_skip_tests44
-rw-r--r--tool/rbs_skip_tests_windows111
-rwxr-xr-xtool/rbuninstall.rb36
-rwxr-xr-xtool/rdoc-srcdir27
-rwxr-xr-xtool/redmine-backporter.rb156
-rwxr-xr-xtool/release.sh12
-rwxr-xr-xtool/releng/gen-mail.rb2
-rwxr-xr-xtool/releng/update-www-meta.rb25
-rwxr-xr-xtool/rjit/bindgen.rb601
-rwxr-xr-xtool/ruby-version.rb52
-rw-r--r--tool/ruby_vm/controllers/application_controller.rb1
-rw-r--r--tool/ruby_vm/helpers/c_escape.rb6
-rw-r--r--tool/ruby_vm/helpers/dumper.rb7
-rw-r--r--tool/ruby_vm/helpers/scanner.rb1
-rw-r--r--tool/ruby_vm/loaders/insns_def.rb1
-rw-r--r--tool/ruby_vm/loaders/opt_insn_unif_def.rb1
-rw-r--r--tool/ruby_vm/loaders/opt_operand_def.rb1
-rw-r--r--tool/ruby_vm/loaders/vm_opts_h.rb1
-rw-r--r--tool/ruby_vm/models/attribute.rb1
-rw-r--r--tool/ruby_vm/models/bare_instruction.rb236
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb240
-rw-r--r--tool/ruby_vm/models/c_expr.rb1
-rw-r--r--tool/ruby_vm/models/instructions.rb19
-rw-r--r--tool/ruby_vm/models/instructions_unification.rb42
-rw-r--r--tool/ruby_vm/models/instructions_unifications.rb43
-rw-r--r--tool/ruby_vm/models/operands_unification.rb141
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb142
-rw-r--r--tool/ruby_vm/models/trace_instruction.rb70
-rw-r--r--tool/ruby_vm/models/trace_instructions.rb71
-rw-r--r--tool/ruby_vm/models/typemap.rb1
-rw-r--r--tool/ruby_vm/models/zjit_instruction.rb56
-rw-r--r--tool/ruby_vm/scripts/insns2vm.rb1
-rw-r--r--tool/ruby_vm/tests/.gitkeep0
-rw-r--r--tool/ruby_vm/views/_comptime_insn_stack_increase.erb25
-rw-r--r--tool/ruby_vm/views/_insn_entry.erb5
-rw-r--r--tool/ruby_vm/views/_insn_leaf_info.erb18
-rw-r--r--tool/ruby_vm/views/_insn_len_info.erb12
-rw-r--r--tool/ruby_vm/views/_insn_name_info.erb33
-rw-r--r--tool/ruby_vm/views/_insn_operand_info.erb32
-rw-r--r--tool/ruby_vm/views/_insn_sp_pc_dependency.erb27
-rw-r--r--tool/ruby_vm/views/_leaf_helpers.erb31
-rw-r--r--tool/ruby_vm/views/_sp_inc_helpers.erb2
-rw-r--r--tool/ruby_vm/views/_zjit_helpers.erb31
-rw-r--r--tool/ruby_vm/views/_zjit_instruction.erb12
-rw-r--r--tool/ruby_vm/views/insns.inc.erb17
-rw-r--r--tool/ruby_vm/views/insns_info.inc.erb6
-rw-r--r--tool/ruby_vm/views/lib/ruby_vm/rjit/instruction.rb.erb2
-rw-r--r--tool/ruby_vm/views/opt_sc.inc.erb40
-rw-r--r--tool/ruby_vm/views/optinsn.inc.erb4
-rw-r--r--tool/ruby_vm/views/optunifs.inc.erb5
-rw-r--r--tool/ruby_vm/views/vm.inc.erb12
-rw-r--r--tool/ruby_vm/views/vmtc.inc.erb10
-rw-r--r--tool/run-gcov.rb3
-rw-r--r--tool/run-lcov.rb14
-rwxr-xr-xtool/runruby.rb9
-rwxr-xr-xtool/sync_default_gems.rb1228
-rwxr-xr-xtool/test-annocheck.sh11
-rw-r--r--tool/test-bundled-gems.rb252
-rw-r--r--tool/test-coverage.rb4
-rw-r--r--tool/test/init.rb26
-rw-r--r--tool/test/runner.rb11
-rw-r--r--tool/test/test_commit_email.rb102
-rwxr-xr-xtool/test/test_sync_default_gems.rb319
-rw-r--r--tool/test/testunit/test4test_load_failure.rb1
-rw-r--r--tool/test/testunit/test4test_timeout.rb15
-rw-r--r--tool/test/testunit/test_assertion.rb175
-rw-r--r--tool/test/testunit/test_hideskip.rb3
-rw-r--r--tool/test/testunit/test_launchable.rb70
-rw-r--r--tool/test/testunit/test_load_failure.rb23
-rw-r--r--tool/test/testunit/test_minitest_unit.rb9
-rw-r--r--tool/test/testunit/test_parallel.rb92
-rw-r--r--tool/test/testunit/test_sorting.rb2
-rw-r--r--tool/test/testunit/test_timeout.rb10
-rw-r--r--tool/test/testunit/tests_for_parallel/ptest_forth.rb8
-rw-r--r--tool/test/testunit/tests_for_parallel/slow_helper.rb8
-rw-r--r--tool/test/testunit/tests_for_parallel/test4test_hungup.rb2
-rw-r--r--tool/test/webrick/.htaccess1
-rw-r--r--tool/test/webrick/test_cgi.rb170
-rw-r--r--tool/test/webrick/test_config.rb17
-rw-r--r--tool/test/webrick/test_cookie.rb141
-rw-r--r--tool/test/webrick/test_do_not_reverse_lookup.rb71
-rw-r--r--tool/test/webrick/test_filehandler.rb403
-rw-r--r--tool/test/webrick/test_htgroup.rb19
-rw-r--r--tool/test/webrick/test_htmlutils.rb21
-rw-r--r--tool/test/webrick/test_httpauth.rb366
-rw-r--r--tool/test/webrick/test_httpproxy.rb467
-rw-r--r--tool/test/webrick/test_httprequest.rb488
-rw-r--r--tool/test/webrick/test_httpresponse.rb282
-rw-r--r--tool/test/webrick/test_https.rb112
-rw-r--r--tool/test/webrick/test_httpserver.rb543
-rw-r--r--tool/test/webrick/test_httpstatus.rb35
-rw-r--r--tool/test/webrick/test_httputils.rb101
-rw-r--r--tool/test/webrick/test_httpversion.rb41
-rw-r--r--tool/test/webrick/test_server.rb191
-rw-r--r--tool/test/webrick/test_ssl_server.rb67
-rw-r--r--tool/test/webrick/test_utils.rb110
-rw-r--r--tool/test/webrick/utils.rb84
-rw-r--r--tool/test/webrick/webrick.cgi38
-rw-r--r--tool/test/webrick/webrick.rhtml4
-rw-r--r--tool/test/webrick/webrick_long_filename.cgi36
-rw-r--r--tool/transcode-tblgen.rb6
-rwxr-xr-xtool/update-NEWS-gemlist.rb55
-rwxr-xr-xtool/update-NEWS-github-release.rb395
-rw-r--r--tool/update-NEWS-refs.rb7
-rwxr-xr-xtool/update-bundled_gems.rb60
-rwxr-xr-xtool/update-deps36
-rwxr-xr-xtool/ytab.sed82
-rwxr-xr-xtool/zjit_bisect.rb165
-rwxr-xr-xtool/zjit_diff.rb272
-rw-r--r--tool/zjit_iongraph.html551
-rwxr-xr-xtool/zjit_iongraph.rb38
-rw-r--r--trace_point.rb363
-rw-r--r--transcode.c451
-rw-r--r--transient_heap.c990
-rw-r--r--transient_heap.h65
-rw-r--r--universal_parser.c211
-rw-r--r--util.c104
-rw-r--r--variable.c2652
-rw-r--r--variable.h22
-rw-r--r--vcpkg.json11
-rw-r--r--version.c201
-rw-r--r--version.h10
-rw-r--r--vm.c1730
-rw-r--r--vm_args.c496
-rw-r--r--vm_backtrace.c752
-rw-r--r--vm_callinfo.h328
-rw-r--r--vm_core.h734
-rw-r--r--vm_debug.h10
-rw-r--r--vm_dump.c779
-rw-r--r--vm_eval.c866
-rw-r--r--vm_exec.c59
-rw-r--r--vm_exec.h48
-rw-r--r--vm_insnhelper.c2879
-rw-r--r--vm_insnhelper.h68
-rw-r--r--vm_method.c1329
-rw-r--r--vm_opts.h7
-rw-r--r--vm_sync.c190
-rw-r--r--vm_sync.h31
-rw-r--r--vm_trace.c823
-rw-r--r--vsnprintf.c4
-rw-r--r--warning.rb10
-rw-r--r--wasm/README.md60
-rw-r--r--wasm/missing.c7
-rw-r--r--wasm/runtime.c7
-rw-r--r--wasm/setjmp.c77
-rw-r--r--wasm/setjmp.h5
-rw-r--r--weakmap.c1010
-rw-r--r--win32/.document1
-rw-r--r--win32/Makefile.sub422
-rw-r--r--[-rwxr-xr-x]win32/configure.bat494
-rw-r--r--win32/dir.h2
-rw-r--r--win32/enc-setup.mak4
-rw-r--r--win32/file.c41
-rw-r--r--win32/file.h3
-rwxr-xr-xwin32/ifchange.bat136
-rwxr-xr-xwin32/install-buildtools.cmd14
-rwxr-xr-xwin32/install-msys-packages.cmd29
-rwxr-xr-xwin32/lastrev.bat30
-rwxr-xr-xwin32/makedirs.bat2
-rwxr-xr-xwin32/mkexports.rb21
-rwxr-xr-xwin32/rm.bat72
-rwxr-xr-xwin32/rmdirs.bat8
-rwxr-xr-xwin32/rtname.cmd71
-rw-r--r--win32/setup.mak194
-rw-r--r--win32/shellsplit.cmd114
-rw-r--r--win32/test_shellsplit.cmd28
-rwxr-xr-xwin32/vssetup.cmd56
-rw-r--r--win32/win32.c963
-rw-r--r--win32/winmain.c4
-rw-r--r--yjit.c966
-rw-r--r--yjit.h47
-rw-r--r--yjit.rb505
-rw-r--r--yjit/Cargo.lock25
-rw-r--r--yjit/Cargo.toml45
-rw-r--r--yjit/bindgen/Cargo.lock299
-rw-r--r--yjit/bindgen/Cargo.toml6
-rw-r--r--yjit/bindgen/src/main.rs210
-rw-r--r--yjit/not_gmake.mk2
-rw-r--r--yjit/src/asm/arm64/arg/bitmask_imm.rs4
-rw-r--r--yjit/src/asm/arm64/arg/condition.rs2
-rw-r--r--yjit/src/asm/arm64/arg/sys_reg.rs4
-rw-r--r--yjit/src/asm/arm64/inst/atomic.rs4
-rw-r--r--yjit/src/asm/arm64/inst/branch.rs8
-rw-r--r--yjit/src/asm/arm64/inst/branch_cond.rs4
-rw-r--r--yjit/src/asm/arm64/inst/breakpoint.rs4
-rw-r--r--yjit/src/asm/arm64/inst/call.rs6
-rw-r--r--yjit/src/asm/arm64/inst/conditional.rs4
-rw-r--r--yjit/src/asm/arm64/inst/data_imm.rs12
-rw-r--r--yjit/src/asm/arm64/inst/data_reg.rs12
-rw-r--r--yjit/src/asm/arm64/inst/halfword_imm.rs14
-rw-r--r--yjit/src/asm/arm64/inst/load_literal.rs4
-rw-r--r--yjit/src/asm/arm64/inst/load_register.rs4
-rw-r--r--yjit/src/asm/arm64/inst/load_store.rs22
-rw-r--r--yjit/src/asm/arm64/inst/load_store_exclusive.rs6
-rw-r--r--yjit/src/asm/arm64/inst/logical_imm.rs14
-rw-r--r--yjit/src/asm/arm64/inst/logical_reg.rs18
-rw-r--r--yjit/src/asm/arm64/inst/madd.rs73
-rw-r--r--yjit/src/asm/arm64/inst/mod.rs4
-rw-r--r--yjit/src/asm/arm64/inst/mov.rs6
-rw-r--r--yjit/src/asm/arm64/inst/nop.rs2
-rw-r--r--yjit/src/asm/arm64/inst/pc_rel.rs6
-rw-r--r--yjit/src/asm/arm64/inst/reg_pair.rs26
-rw-r--r--yjit/src/asm/arm64/inst/sbfm.rs6
-rw-r--r--yjit/src/asm/arm64/inst/shift_imm.rs6
-rw-r--r--yjit/src/asm/arm64/inst/smulh.rs60
-rw-r--r--yjit/src/asm/arm64/inst/sys_reg.rs6
-rw-r--r--yjit/src/asm/arm64/inst/test_bit.rs6
-rw-r--r--yjit/src/asm/arm64/mod.rs106
-rw-r--r--yjit/src/asm/mod.rs241
-rw-r--r--yjit/src/asm/x86_64/mod.rs87
-rw-r--r--yjit/src/asm/x86_64/tests.rs19
-rw-r--r--yjit/src/backend/arm64/mod.rs718
-rw-r--r--yjit/src/backend/ir.rs839
-rw-r--r--yjit/src/backend/mod.rs6
-rw-r--r--yjit/src/backend/tests.rs64
-rw-r--r--yjit/src/backend/x86_64/mod.rs498
-rw-r--r--yjit/src/codegen.rs9763
-rw-r--r--yjit/src/core.rs3812
-rw-r--r--yjit/src/cruby.rs231
-rw-r--r--yjit/src/cruby_bindings.inc.rs1114
-rw-r--r--yjit/src/disasm.rs216
-rw-r--r--yjit/src/invariants.rs371
-rw-r--r--yjit/src/lib.rs15
-rw-r--r--yjit/src/log.rs179
-rw-r--r--yjit/src/options.rs336
-rw-r--r--yjit/src/stats.rs733
-rw-r--r--yjit/src/utils.rs50
-rw-r--r--yjit/src/virtualmem.rs207
-rw-r--r--yjit/src/yjit.rs191
-rw-r--r--yjit/yjit.mk98
-rw-r--r--zjit.c255
-rw-r--r--zjit.h125
-rw-r--r--zjit.rb284
-rw-r--r--zjit/.gitignore2
-rw-r--r--zjit/Cargo.lock594
-rw-r--r--zjit/Cargo.toml25
-rw-r--r--zjit/bindgen/Cargo.lock392
-rw-r--r--zjit/bindgen/Cargo.toml12
-rw-r--r--zjit/bindgen/src/main.rs471
-rw-r--r--zjit/build.rs29
-rw-r--r--zjit/src/asm/arm64/README.md16
-rw-r--r--zjit/src/asm/arm64/arg/bitmask_imm.rs255
-rw-r--r--zjit/src/asm/arm64/arg/condition.rs52
-rw-r--r--zjit/src/asm/arm64/arg/inst_offset.rs47
-rw-r--r--zjit/src/asm/arm64/arg/mod.rs18
-rw-r--r--zjit/src/asm/arm64/arg/sf.rs19
-rw-r--r--zjit/src/asm/arm64/arg/shifted_imm.rs80
-rw-r--r--zjit/src/asm/arm64/arg/sys_reg.rs6
-rw-r--r--zjit/src/asm/arm64/arg/truncate.rs66
-rw-r--r--zjit/src/asm/arm64/inst/atomic.rs86
-rw-r--r--zjit/src/asm/arm64/inst/branch.rs100
-rw-r--r--zjit/src/asm/arm64/inst/branch_cond.rs78
-rw-r--r--zjit/src/asm/arm64/inst/breakpoint.rs55
-rw-r--r--zjit/src/asm/arm64/inst/call.rs104
-rw-r--r--zjit/src/asm/arm64/inst/conditional.rs73
-rw-r--r--zjit/src/asm/arm64/inst/data_imm.rs143
-rw-r--r--zjit/src/asm/arm64/inst/data_reg.rs192
-rw-r--r--zjit/src/asm/arm64/inst/halfword_imm.rs179
-rw-r--r--zjit/src/asm/arm64/inst/load_literal.rs91
-rw-r--r--zjit/src/asm/arm64/inst/load_register.rs108
-rw-r--r--zjit/src/asm/arm64/inst/load_store.rs255
-rw-r--r--zjit/src/asm/arm64/inst/load_store_exclusive.rs109
-rw-r--r--zjit/src/asm/arm64/inst/logical_imm.rs154
-rw-r--r--zjit/src/asm/arm64/inst/logical_reg.rs207
-rw-r--r--zjit/src/asm/arm64/inst/madd.rs73
-rw-r--r--zjit/src/asm/arm64/inst/mod.rs56
-rw-r--r--zjit/src/asm/arm64/inst/mov.rs192
-rw-r--r--zjit/src/asm/arm64/inst/nop.rs44
-rw-r--r--zjit/src/asm/arm64/inst/pc_rel.rs107
-rw-r--r--zjit/src/asm/arm64/inst/reg_pair.rs212
-rw-r--r--zjit/src/asm/arm64/inst/sbfm.rs103
-rw-r--r--zjit/src/asm/arm64/inst/shift_imm.rs147
-rw-r--r--zjit/src/asm/arm64/inst/smulh.rs60
-rw-r--r--zjit/src/asm/arm64/inst/sys_reg.rs86
-rw-r--r--zjit/src/asm/arm64/inst/test_bit.rs133
-rw-r--r--zjit/src/asm/arm64/inst/udf.rs52
-rw-r--r--zjit/src/asm/arm64/mod.rs1987
-rw-r--r--zjit/src/asm/arm64/opnd.rs270
-rw-r--r--zjit/src/asm/mod.rs463
-rw-r--r--zjit/src/asm/x86_64/mod.rs1439
-rw-r--r--zjit/src/asm/x86_64/tests.rs966
-rw-r--r--zjit/src/backend/arm64/mod.rs2929
-rw-r--r--zjit/src/backend/lir.rs4471
-rw-r--r--zjit/src/backend/mod.rs19
-rw-r--r--zjit/src/backend/parcopy.rs368
-rw-r--r--zjit/src/backend/tests.rs261
-rw-r--r--zjit/src/backend/x86_64/mod.rs2461
-rw-r--r--zjit/src/bitset.rs225
-rw-r--r--zjit/src/cast.rs64
-rw-r--r--zjit/src/codegen.rs3633
-rw-r--r--zjit/src/codegen_tests.rs5777
-rw-r--r--zjit/src/cruby.rs1659
-rw-r--r--zjit/src/cruby_bindings.inc.rs2327
-rw-r--r--zjit/src/cruby_methods.rs1040
-rw-r--r--zjit/src/disasm.rs72
-rw-r--r--zjit/src/distribution.rs282
-rw-r--r--zjit/src/gc.rs244
-rw-r--r--zjit/src/hir.rs9432
-rw-r--r--zjit/src/hir/opt_tests.rs17028
-rw-r--r--zjit/src/hir/tests.rs6433
-rw-r--r--zjit/src/hir_effect/gen_hir_effect.rb126
-rw-r--r--zjit/src/hir_effect/hir_effect.inc.rs63
-rw-r--r--zjit/src/hir_effect/mod.rs420
-rw-r--r--zjit/src/hir_type/gen_hir_type.rb251
-rw-r--r--zjit/src/hir_type/hir_type.inc.rs300
-rw-r--r--zjit/src/hir_type/mod.rs1107
-rw-r--r--zjit/src/invariants.rs543
-rw-r--r--zjit/src/jit_frame.rs313
-rw-r--r--zjit/src/json.rs700
-rw-r--r--zjit/src/lib.rs46
-rw-r--r--zjit/src/options.rs631
-rw-r--r--zjit/src/payload.rs135
-rw-r--r--zjit/src/profile.rs582
-rw-r--r--zjit/src/state.rs541
-rw-r--r--zjit/src/stats.rs1280
-rw-r--r--zjit/src/ttycolors.rs31
-rw-r--r--zjit/src/virtualmem.rs504
-rw-r--r--zjit/zjit.mk141
9516 files changed, 676569 insertions, 618065 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
deleted file mode 100644
index 2762a5759c..0000000000
--- a/.appveyor.yml
+++ /dev/null
@@ -1,132 +0,0 @@
----
-version: '{build}'
-init:
- - git config --global user.name git
- - git config --global user.email svn-admin@ruby-lang.org
- - git config --global core.autocrlf false
- - git config --global core.eol lf
- - git config --global advice.detachedHead 0
-shallow_clone: true
-clone_depth: 10
-platform:
- - x64
-skip_commits:
- message: /\[DOC\]/
- files:
- - doc/*
- - '**/*.md'
- - '**/*.rdoc'
- - '**/.document'
- - '**/*.[1-8]'
- - '**/*.ronn'
-environment:
- ruby_version: "25-%Platform%"
- matrix:
- # Test only the oldest supported version because AppVeyor is unstable, its concurrency
- # is limited, and compatibility issues that happen only in newer versions are rare.
- # You may test some other stuff on GitHub Actions instead.
- - build: vs
- vs: 120
- ssl: OpenSSL-v111
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- GEMS_FOR_TEST: ""
- RELINE_TEST_ENCODING: "UTF-8"
-cache:
- - c:\Tools\vcpkg\installed\
-for:
--
- matrix:
- only:
- - build: vs
- install:
- - ver
- - chcp
- - SET BITS=%Platform:x86=32%
- - SET BITS=%BITS:x=%
- - SET OPENSSL_DIR=C:\%ssl%-Win%BITS%
- - cd C:\Tools\vcpkg
- - git pull -q
- - .\bootstrap-vcpkg.bat
- - cd %APPVEYOR_BUILD_FOLDER%
- - vcpkg --triplet %Platform%-windows install --x-use-aria2 libffi libyaml readline zlib
- - CALL SET vcvars=%%^VS%VS%COMNTOOLS^%%..\..\VC\vcvarsall.bat
- - SET vcvars
- - '"%vcvars%" %Platform:x64=amd64%'
- - SET ruby_path=C:\Ruby%ruby_version:-x86=%
- - SET PATH=\usr\local\bin;%ruby_path%\bin;%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin
- - ruby --version
- - 'cl'
- - echo> Makefile srcdir=.
- - echo>> Makefile MSC_VER=0
- - echo>> Makefile RT=none
- - echo>> Makefile RT_VER=0
- - echo>> Makefile BUILTIN_ENCOBJS=nul
- - type win32\Makefile.sub >> Makefile
- - nmake %mflags% up VCSUP="echo Update OK"
- - nmake %mflags% extract-extlibs
- - del Makefile
- - mkdir \usr\local\bin
- - mkdir \usr\local\include
- - mkdir \usr\local\lib
- - for %%I in (%OPENSSL_DIR%\*.dll) do mklink /h \usr\local\bin\%%~nxI %%I
- - for %%I in (c:\Tools\vcpkg\installed\%Platform%-windows\bin\*.dll) do (
- if not %%~nI == readline mklink \usr\local\bin\%%~nxI %%I
- )
- - attrib +r /s /d
- - mkdir %Platform%-mswin_%vs%
- build_script:
- - set HAVE_GIT=no
- - cd %APPVEYOR_BUILD_FOLDER%
- - cd %Platform%-mswin_%vs%
- - >-
- ..\win32\configure.bat
- --with-opt-dir="/usr/local;c:/Tools/vcpkg/installed/%Platform%-windows"
- --with-openssl-dir=%OPENSSL_DIR:\=/%
- - nmake -l
- - nmake install-nodoc
- - \usr\bin\ruby -v -e "p :locale => Encoding.find('locale'), :filesystem => Encoding.find('filesystem')"
- - if not "%GEMS_FOR_TEST%" == "" \usr\bin\gem install --no-document %GEMS_FOR_TEST%
- - \usr\bin\ruby -ropenssl -e "puts 'Build ' + OpenSSL::OPENSSL_VERSION, 'Runtime ' + OpenSSL::OPENSSL_LIBRARY_VERSION"
- test_script:
- - set /a JOBS=%NUMBER_OF_PROCESSORS%
- - nmake -l "TESTOPTS=-v -q" btest
- - nmake -l "TESTOPTS=-v -q" test-basic
- - >-
- nmake -l "TESTOPTS=-v --timeout-scale=3.0
- --excludes=../test/excludes/_appveyor -j%JOBS%
- --exclude win32ole
- --exclude test_bignum
- --exclude test_syntax
- --exclude test_open-uri
- --exclude test_bundled_ca
- " test-all
- # separately execute tests without -j which may crash worker with -j.
- - >-
- nmake -l
- "TESTOPTS=-v --timeout-scale=3.0 --excludes=../test/excludes/_appveyor"
- TESTS="
- ../test/win32ole
- ../test/ruby/test_bignum.rb
- ../test/ruby/test_syntax.rb
- ../test/open-uri/test_open-uri.rb
- ../test/rubygems/test_bundled_ca.rb
- " test-all
- - nmake -l test-spec MSPECOPT=-fs # not using `-j` because sometimes `mspec -j` silently dies on Windows
-notifications:
- - provider: Webhook
- method: POST
- url:
- secure: CcFlJNDJ/a6to7u3Z4Fnz6dScEPNx7hTha2GkSRlV+1U6dqmxY/7uBcLXYb9gR3jfQk6w+2o/HrjNAyXMNGU/JOka3s2WRI4VKitzM+lQ08owvJIh0R7LxrGH0J2e81U # ruby-lang slack: ruby/simpler-alerts-bot
- body: >-
- {{^isPullRequest}}
- {
- "ci": "AppVeyor CI",
- "env": "Visual Studio 2013",
- "url": "{{buildUrl}}",
- "commit": "{{commitId}}",
- "branch": "{{branch}}"
- }
- {{/isPullRequest}}
- on_build_success: false
- on_build_failure: true
- on_build_status_changed: false
diff --git a/.cirrus.yml b/.cirrus.yml
deleted file mode 100644
index 20c14f375c..0000000000
--- a/.cirrus.yml
+++ /dev/null
@@ -1,134 +0,0 @@
-# This CI is used to test Arm cases. We can set the maximum 16 tasks.
-# The entire testing design is inspired from .github/workflows/compilers.yml.
-
-# By default, Cirrus mounts an empty volume to `/tmp`
-# which triggers all sorts of warnings like "system temporary path is world-writable: /tmp".
-# Lets workaround it by specifying a custom volume mount point.
-env:
- CIRRUS_VOLUME: /cirrus-ci-volume
- LANG: C.UTF-8
-
-task:
- name: Arm64 Graviton2 / $CC
- skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
- arm_container:
- # We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
- image: ghcr.io/ruby/ruby-ci-image:$CC
- # Define the used cpu core in each matrix task. We can use total 16 cpu
- # cores in entire matrix. [cpu] = [total cpu: 16] / [number of tasks]
- cpu: 8
- # We can request maximum 4 GB per cpu.
- # [memory per task] = [memory per cpu: 4 GB] * [cpu]
- memory: 32G
- env:
- CIRRUS_CLONE_DEPTH: 50
- optflags: '-O1'
- debugflags: '-ggdb3'
- RUBY_PREFIX: /tmp/ruby-prefix
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
- matrix:
- CC: clang-12
- CC: gcc-11
- id_script: id
- set_env_script:
- # Set `GNUMAKEFLAGS`, because the flags are GNU make specific. Note using
- # the `make` environment variable used in compilers.yml causes some rubygems
- # tests to fail.
- # https://github.com/rubygems/rubygems/issues/4921
- - echo "GNUMAKEFLAGS=-s -j$((1 + $CIRRUS_CPU))" >> "$CIRRUS_ENV"
- - cat "$CIRRUS_ENV"
- # Arm containers are executed in AWS's EKS, and it's not yet supporting IPv6
- # See https://github.com/aws/containers-roadmap/issues/835
- disable_ipv6_script: sudo ./tool/disable_ipv6.sh
- autogen_script: ./autogen.sh
- configure_script: >-
- ./configure -C
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- --prefix="$RUBY_PREFIX"
- make_extract-extlibs_script: make extract-extlibs
- make_incs_script: make incs
- make_script: make
- make_leaked-globals_script: make leaked-globals
- make_test_script: make test
- make_install_script: make install
- install_gems_for_test_script: $RUBY_PREFIX/bin/gem install --no-doc timezone tzinfo
- make_test-tool_script: make test-tool
- make_test-all_script: make test-all
- make_test-spec_script: make test-spec
-
-# The following is to test YJIT on ARM64 CPUs available on Cirrus CI
-yjit_task:
- name: Arm64 Graviton2 / $CC YJIT
- auto_cancellation: $CIRRUS_BRANCH != 'master'
- skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
- arm_container:
- # We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
- image: ghcr.io/ruby/ruby-ci-image:$CC
- # Define the used cpu core in each matrix task. We can use total 16 cpu
- # cores in entire matrix. [cpu] = [total cpu: 16] / [number of tasks]
- cpu: 8
- # We can request maximum 4 GB per cpu.
- # [memory per task] = [memory per cpu: 4 GB] * [cpu]
- memory: 32G
- env:
- CIRRUS_CLONE_DEPTH: 50
- optflags: '-O1'
- debugflags: '-ggdb3'
- RUBY_PREFIX: /tmp/ruby-prefix
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
- matrix:
- - CC: clang-12
- configure: --enable-yjit=dev
- rustup_init: --default-toolchain=1.58.0
- - CC: gcc-11
- configure: --enable-yjit
- id_script: id
- set_env_script:
- # Set `GNUMAKEFLAGS`, because the flags are GNU make specific. Note using
- # the `make` environment variable used in compilers.yml causes some rubygems
- # tests to fail.
- # https://github.com/rubygems/rubygems/issues/4921
- - echo "GNUMAKEFLAGS=-s -j$((1 + $CIRRUS_CPU))" >> "$CIRRUS_ENV"
- - echo RUST_BACKTRACE=1 >> "$CIRRUS_ENV"
- - cat "$CIRRUS_ENV"
- # Arm containers are executed in AWS's EKS, and it's not yet supporting IPv6
- # See https://github.com/aws/containers-roadmap/issues/835
- disable_ipv6_script: sudo ./tool/disable_ipv6.sh
- install_rust_script:
- - sudo apt-get update -y
- - sudo apt-get install -y curl
- - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y $rustup_init"
- autogen_script: ./autogen.sh
- configure_script: >-
- source $HOME/.cargo/env && ./configure -C
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- --prefix="$RUBY_PREFIX"
- $configure
- make_miniruby_script: source $HOME/.cargo/env && make miniruby
- make_bindgen_script: |
- if [[ "$CC" = "clang-12" ]]; then
- source $HOME/.cargo/env && make yjit-bindgen
- else
- echo "only running bindgen on clang image"
- fi
- boot_miniruby_script: ./miniruby --yjit-call-threshold=1 -e0
- test_dump_insns_script: ./miniruby --yjit-call-threshold=1 --yjit-dump-insns -e0
- output_stats_script: ./miniruby --yjit-call-threshold=1 --yjit-stats -e0
- full_build_script: source $HOME/.cargo/env && make
- cargo_test_script: source $HOME/.cargo/env && cd yjit && cargo test
- make_test_script: source $HOME/.cargo/env && make test RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx"
- make_test_all_script: source $HOME/.cargo/env && make test-all RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx" TESTOPTS="$RUBY_TESTOPTS"
- make_test_spec_script: source $HOME/.cargo/env && make test-spec RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx"
- clippy_script: source $HOME/.cargo/env && cd yjit && cargo clippy --all-targets --all-features
diff --git a/.document b/.document
index 70c62324a4..753d6f9892 100644
--- a/.document
+++ b/.document
@@ -15,13 +15,14 @@ array.rb
ast.rb
dir.rb
gc.rb
+hash.rb
io.rb
kernel.rb
marshal.rb
-rjit.rb
numeric.rb
nilclass.rb
pack.rb
+pathname_builtin.rb
ractor.rb
string.rb
symbol.rb
@@ -30,6 +31,10 @@ thread_sync.rb
trace_point.rb
warning.rb
yjit.rb
+zjit.rb
+
+# Errno::*
+known_errors.inc
# the lib/ directory (which has its own .document file)
lib
@@ -37,6 +42,9 @@ lib
# and some of the ext/ directory (which has its own .document file)
ext
+# For `prism`, ruby code is in lib and c in the prism folder
+prism
+
# rdoc files
NEWS.md
@@ -48,7 +56,4 @@ COPYING.ja
LEGAL
-# win32/README.win32 linked from README.md
-win32
-
doc
diff --git a/.gdbinit b/.gdbinit
index 7657d240c5..4457f6f12b 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -1,23 +1,7 @@
-set startup-with-shell off
-
-define hook-run
- set $color_type = 0
- set $color_highlite = 0
- set $color_end = 0
-end
-
define ruby_gdb_init
- if !$color_type
- set $color_type = "\033[31m"
- end
- if !$color_highlite
- set $color_highlite = "\033[36m"
- end
- if !$color_end
- set $color_end = "\033[m"
- end
- if ruby_dummy_gdb_enums.special_consts
- end
+ init-if-undefined $color_type = "\033[31m"
+ init-if-undefined $color_highlite = "\033[36m"
+ init-if-undefined $color_end = "\033[m"
end
# set prompt \033[36m(gdb)\033[m\040
@@ -67,7 +51,7 @@ define rp
printf "%sT_OBJECT%s: ", $color_type, $color_end
print ((struct RObject *)($arg0))->basic
if ($flags & ROBJECT_EMBED)
- print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
+ print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (RSHAPE_CAPACITY(rb_obj_shape_id($arg0)))
else
print (((struct RObject *)($arg0))->as.heap)
if (((struct RObject*)($arg0))->as.heap.numiv) > 0
@@ -99,13 +83,11 @@ define rp
set $regsrc = ((struct RRegexp*)($arg0))->src
set $rsflags = ((struct RBasic*)$regsrc)->flags
printf "%sT_REGEXP%s: ", $color_type, $color_end
- set $len = ($rsflags & RUBY_FL_USER1) ? \
- ((struct RString*)$regsrc)->as.heap.len : \
- (($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
+ set $len = ((struct RString*)($arg0))->len
set print address off
output *(char *)(($rsflags & RUBY_FL_USER1) ? \
- ((struct RString*)$regsrc)->as.heap.ptr : \
- ((struct RString*)$regsrc)->as.ary) @ $len
+ ((struct RString*)$regsrc)->as.heap.ptr : \
+ ((struct RString*)$regsrc)->as.embed.ary) @ $len
set print address on
printf " len:%ld ", $len
if $flags & RUBY_FL_USER6
@@ -126,26 +108,26 @@ define rp
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
printf "(embed) "
if ($len == 0)
- printf "{(empty)} "
+ printf "{(empty)} "
else
- print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
- printf " "
+ print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
+ printf " "
end
else
set $len = ((struct RArray*)($arg0))->as.heap.len
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
if ($flags & RUBY_FL_USER2)
- printf "(shared) shared="
- output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
- printf " "
+ printf "(shared) shared="
+ output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
+ printf " "
else
- printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
+ printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
end
if ($len == 0)
- printf "{(empty)} "
+ printf "{(empty)} "
else
- print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
- printf " "
+ print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
+ printf " "
end
end
print (struct RArray *)($arg0)
@@ -157,13 +139,15 @@ define rp
if ($flags & RUBY_T_MASK) == RUBY_T_HASH
printf "%sT_HASH%s: ", $color_type, $color_end,
if (((struct RHash *)($arg0))->basic.flags & RHASH_ST_TABLE_FLAG)
- printf "st len=%ld ", ((struct RHash *)($arg0))->as.st->num_entries
+ set $st = (struct st_table *)((uintptr_t)($arg0) + sizeof(struct RHash))
+ printf "st len=%ld ", $st->num_entries
+ print $st
else
printf "li len=%ld bound=%ld ", \
((((struct RHash *)($arg0))->basic.flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT), \
((((struct RHash *)($arg0))->basic.flags & RHASH_AR_TABLE_BOUND_MASK) >> RHASH_AR_TABLE_BOUND_SHIFT)
+ print (struct ar_table_struct *)((uintptr_t)($arg0) + sizeof(struct RHash))
end
- print (struct RHash *)($arg0)
else
if ($flags & RUBY_T_MASK) == RUBY_T_STRUCT
set $len = (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
@@ -201,12 +185,14 @@ define rp
print (struct RBasic *)($arg0)
else
if ($flags & RUBY_T_MASK) == RUBY_T_DATA
- if ((struct RTypedData *)($arg0))->typed_flag == 1
- printf "%sT_DATA%s(%s): ", $color_type, $color_end, ((struct RTypedData *)($arg0))->type->wrap_struct_name
- print (struct RTypedData *)($arg0)
+ set $data = (struct RTypedData *)($arg0)
+ set $type = (const rb_data_type_t *)($data->type & ~1)
+ printf "%sT_DATA%s(%s): ", $color_type, $color_end, $type->wrap_struct_name
+ print *$type
+ if ($data->type & 1)
+ print (void *)&$data->data
else
- printf "%sT_DATA%s: ", $color_type, $color_end
- print (struct RData *)($arg0)
+ print $data
end
else
if ($flags & RUBY_T_MASK) == RUBY_T_MATCH
@@ -440,13 +426,11 @@ end
define output_string
set $flags = ((struct RBasic*)($arg0))->flags
- set $len = ($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)
+ set $len = ((struct RString*)($arg0))->len
if $len > 0
output *(char *)(($flags & RUBY_FL_USER1) ? \
- ((struct RString*)($arg0))->as.heap.ptr : \
- ((struct RString*)($arg0))->as.ary) @ $len
+ ((struct RString*)($arg0))->as.heap.ptr : \
+ ((struct RString*)($arg0))->as.embed.ary) @ $len
else
output ""
end
@@ -454,13 +438,11 @@ end
define print_string
set $flags = ((struct RBasic*)($arg0))->flags
- set $len = ($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)
+ set $len = ((struct RString*)($arg0))->len
if $len > 0
printf "%s", *(char *)(($flags & RUBY_FL_USER1) ? \
- ((struct RString*)($arg0))->as.heap.ptr : \
- ((struct RString*)($arg0))->as.ary) @ $len
+ ((struct RString*)($arg0))->as.heap.ptr : \
+ ((struct RString*)($arg0))->as.embed.ary) @ $len
end
end
@@ -543,14 +525,14 @@ document rp_bignum
end
define rp_class
+ set $class_and_classext = (struct RClass_and_rb_classext_t *)($arg0)
printf "(struct RClass *) %p", (void*)$arg0
- if RCLASS_ORIGIN((struct RClass *)($arg0)) != $arg0
- printf " -> %p", RCLASS_ORIGIN((struct RClass *)($arg0))
+ if $class_and_classext->classext->origin_ != (VALUE)$arg0
+ printf " -> %p", $class_and_classext->classext->origin_
end
printf "\n"
rb_classname $arg0
- print/x *(struct RClass *)($arg0)
- print *RCLASS_EXT((struct RClass *)($arg0))
+ print/x *$class_and_classext
end
document rp_class
Print the content of a Class/Module.
@@ -689,11 +671,6 @@ define nd_stts
end
-define nd_entry
- printf "%su3.entry%s: ", $color_highlite, $color_end
- p ($arg0).u3.entry
-end
-
define nd_vid
printf "%su1.id%s: ", $color_highlite, $color_end
p ($arg0).u1.id
@@ -868,22 +845,22 @@ define rb_numtable_entry
set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
if $rb_numtable_p.k == $rb_numtable_id
- set $rb_numtable_key = $rb_numtable_p.k
- set $rb_numtable_rec = $rb_numtable_p.v
- set $rb_numtable_p = 0
+ set $rb_numtable_key = $rb_numtable_p.k
+ set $rb_numtable_rec = $rb_numtable_p.v
+ set $rb_numtable_p = 0
else
- set $rb_numtable_p = $rb_numtable_p + 1
+ set $rb_numtable_p = $rb_numtable_p + 1
end
end
else
set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
while $rb_numtable_p
if $rb_numtable_p->key == $rb_numtable_id
- set $rb_numtable_key = $rb_numtable_p->key
- set $rb_numtable_rec = $rb_numtable_p->record
- set $rb_numtable_p = 0
+ set $rb_numtable_key = $rb_numtable_p->key
+ set $rb_numtable_rec = $rb_numtable_p->record
+ set $rb_numtable_p = 0
else
- set $rb_numtable_p = $rb_numtable_p->next
+ set $rb_numtable_p = $rb_numtable_p->next
end
end
end
@@ -921,10 +898,10 @@ document rb_method_entry
end
define rb_classname
- # up to 128bit int
- set $rb_classname = rb_mod_name($arg0)
- if $rb_classname != RUBY_Qnil
- rp $rb_classname
+ set $rb_classname = ((struct RClass_and_rb_classext_t*)$arg0)->classext->classpath
+ if $rb_classname != RUBY_Qfalse
+ print_string $rb_classname
+ printf "\n"
else
echo anonymous class/module\n
end
@@ -961,7 +938,7 @@ define iseq
set $operand_size = ((INSN*)($arg0))->operand_size
set $operands = ((INSN*)($arg0))->operands
while $i < $operand_size
- rp $operands[$i++]
+ rp $operands[$i++]
end
end
end
@@ -997,7 +974,7 @@ end
define print_lineno
set $cfp = $arg0
- set $iseq = $cfp->iseq
+ set $iseq = rb_get_cfp_iseq($cfp)
set $pos = $cfp->pc - $iseq->body->iseq_encoded
if $pos != 0
set $pos = $pos - 1
@@ -1078,7 +1055,7 @@ define print_id
else
set $serial = (rb_id_serial_t)$id
end
- if $serial && $serial <= ruby_global_symbols.last_id
+ if $serial && $serial < ruby_global_symbols.next_id
set $idx = $serial / ID_ENTRY_UNIT
set $ids = (struct RArray *)ruby_global_symbols.ids
set $flags = $ids->basic.flags
@@ -1101,7 +1078,7 @@ define print_id
set $aryptr = $ary->as.heap.ptr
set $arylen = $ary->as.heap.len
end
- set $result = $aryptr[($serial % ID_ENTRY_UNIT) * ID_ENTRY_SIZE + $t]
+ set $result = $aryptr[($serial % ID_ENTRY_UNIT) + $t]
if $result != RUBY_Qnil
print_string $result
else
@@ -1131,20 +1108,21 @@ define rb_ps_thread
set $ps_thread = (struct RTypedData*)$arg0
set $ps_thread_th = (rb_thread_t*)$ps_thread->data
printf "* #<Thread:%p rb_thread_t:%p native_thread:%p>\n", \
- $ps_thread, $ps_thread_th, $ps_thread_th->thread_id
+ $ps_thread, $ps_thread_th, $ps_thread_th->nt
set $cfp = $ps_thread_th->ec->cfp
set $cfpend = (rb_control_frame_t *)($ps_thread_th->ec->vm_stack + $ps_thread_th->ec->vm_stack_size)-1
while $cfp < $cfpend
- if $cfp->iseq
- if !((VALUE)$cfp->iseq & RUBY_IMMEDIATE_MASK) && (((imemo_ifunc << RUBY_FL_USHIFT) | RUBY_T_IMEMO)==$cfp->iseq->flags & ((RUBY_IMEMO_MASK << RUBY_FL_USHIFT) | RUBY_T_MASK))
+ if $cfp->_iseq
+ set $iseq = rb_get_cfp_iseq($cfp)
+ if !((VALUE)$iseq & RUBY_IMMEDIATE_MASK) && (((imemo_ifunc << RUBY_FL_USHIFT) | RUBY_T_IMEMO)==$iseq->flags & ((RUBY_IMEMO_MASK << RUBY_FL_USHIFT) | RUBY_T_MASK))
printf "%d:ifunc ", $cfpend-$cfp
set print symbol-filename on
- output/a $cfp->iseq.body
+ output/a $iseq.body
set print symbol-filename off
printf "\n"
else
if $cfp->pc
- set $location = $cfp->iseq->body->location
+ set $location = $iseq->body->location
printf "%d:", $cfpend-$cfp
print_pathobj $location.pathobj
printf ":"
@@ -1279,7 +1257,7 @@ document rb_count_objects
Counts all objects grouped by type.
end
-# Details: https://bugs.ruby-lang.org/projects/ruby-master/wiki/MachineInstructionsTraceWithGDB
+# Details: https://github.com/ruby/ruby/wiki/Machine-Instructions-Trace-with-GDB
define trace_machine_instructions
set logging enabled
set height 0
@@ -1316,13 +1294,12 @@ define dump_node
set $flags = ((struct RBasic*)($str))->flags
printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
((struct RString*)$str)->as.heap.ptr : \
- ((struct RString*)$str)->as.ary)
+ ((struct RString*)$str)->as.embed.ary)
end
define print_flags
printf "RUBY_FL_WB_PROTECTED: %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_WB_PROTECTED ? "1" : "0"
- printf "RUBY_FL_PROMOTED0 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED0 ? "1" : "0"
- printf "RUBY_FL_PROMOTED1 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED1 ? "1" : "0"
+ printf "RUBY_FL_PROMOTED : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED ? "1" : "0"
printf "RUBY_FL_FINALIZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FINALIZE ? "1" : "0"
printf "RUBY_FL_SHAREABLE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_SHAREABLE ? "1" : "0"
printf "RUBY_FL_EXIVAR : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_EXIVAR ? "1" : "0"
@@ -1348,3 +1325,8 @@ define print_flags
printf "RUBY_FL_USER17 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER17 ? "1" : "0"
printf "RUBY_FL_USER18 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER18 ? "1" : "0"
end
+
+source -s misc/gdb.py
+
+# Moved from beginning, since it fails on older gdbs
+set startup-with-shell off
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 6c35dbcf83..d752612085 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -6,6 +6,15 @@
# Expand tabs
5b21e94bebed90180d8ff63dad03b8b948361089
c5e9af9c9d890578182a21e7b71b50334cd5579e
+e63a2115f64433b21cb5dd67c5bf8b30f87ef293
+712ac99e4d0384a941c80a9f48f62943ba7d97c0
+d1474affa8e105bece209cc9d594bb0a989859e1
+2da92388b948821269b18d6b178a680f17e41750
+5062c0c621d887367af8a054e5e5d83d7ec57dd3
+
+# Indentation
+0e4bad888e605d424b9222ae0ca43f85c1634e5e
+61aa46c41648c6d1e9b0daa1a292de551fde78df
# Enable Style/StringLiterals cop for RubyGems/Bundler
d7ffd3fea402239b16833cc434404a7af82d44f3
@@ -22,3 +31,24 @@ f28287d34c03f472ffe90ea262bdde9affd4b965
# Make benchmark indentation consistent
fc4acf8cae82e5196186d3278d831f2438479d91
+
+# Make prism_compile.c indentation consistent
+40b2c8e5e7e6e5f83cee9276dc9c1922a69292d6
+d2c5867357ed88eccc28c2b3bd4a46e206e7ff85
+
+# Miss-and-revived commits
+a0f7de814ae5c299d6ce99bed5fb308a05d50ba0
+d4e24021d39e1f80f0055b55d91f8d5f22e15084
+7a56c316418980b8a41fcbdc94067b2bda2ad112
+e90282be7ba1bc8e3119f6e1a2c80356ceb3f80a
+26a9e0b4e31f7b5a9cbd755e0a15823a8fa51bae
+2f53985da9ee593fe524d408256835667938c7d7
+bf01f6ae89a95d8f5572e050facfe311c8c28aaf
+7480cd8d37fd71a41ce12b759090051c7e14fb5a
+
+# Win32: EOL code of batch files
+23f9a0d655c4d405bb2397a147a1523436205486
+b839989fd22fef85e2af19de1bc83aa72a5b22bd
+
+# ZJIT cargo-insta snapshot raw string literals
+b78e0a6ddf7df8a7568ea71284f593423c739551
diff --git a/.gitattributes b/.gitattributes
index d0c2d266b4..f98c091e3f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,8 +1,14 @@
*.gemspec diff=ruby
*.rb diff=ruby
+*.inc.rs linguist-generated=true
bin svn-properties=svn:ignore=ruby
bin/* diff=ruby
tool/update-deps diff=ruby
tool/make-snapshot diff=ruby
tool/format-release diff=ruby
tool/leaked-globals diff=ruby
+
+# To strip CR from the batch files, set the `diff.dos.textconv` filter
+# like as `git config diff.dos.textconv $'sed \'s/\r$//\''`.
+*.bat diff=dos
+*.cmd diff=dos
diff --git a/.github/actions/capiext/action.yml b/.github/actions/capiext/action.yml
new file mode 100644
index 0000000000..ed69c8ac5e
--- /dev/null
+++ b/.github/actions/capiext/action.yml
@@ -0,0 +1,86 @@
+name: rubyspec C-API extensions
+
+inputs:
+ builddir:
+ required: false
+ default: '.'
+ make:
+ required: false
+ default: 'make -s'
+
+outputs:
+ key:
+ value: >-
+ ${{
+ !steps.restore.outputs.cache-hit &&
+ github.ref == 'refs/heads/master' &&
+ steps.config.outputs.key
+ }}
+
+runs:
+ using: composite
+
+ steps:
+ - id: config
+ shell: bash
+ run: |
+ eval $(grep -e '^arch *=' -e '^ruby_version *=' -e '^DLEXT *=' Makefile |
+ sed 's/ *= */=/')
+ case "${ruby_version}" in
+ *+*) key=capiexts-${arch}-${ruby_version}-${{ hashFiles('src/spec/ruby/optional/capi/ext/*.[ch]') }};;
+ *) key=;;
+ esac
+ echo version=$ruby_version >> $GITHUB_OUTPUT
+ echo key="$key" >> $GITHUB_OUTPUT
+ echo DLEXT=$DLEXT >> $GITHUB_OUTPUT
+ working-directory: ${{ inputs.builddir }}
+
+ - name: Restore previous CAPI extensions
+ uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
+ id: cache
+ with:
+ path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/
+ key: ${{ steps.config.outputs.key }}
+ if: ${{ steps.config.outputs.key }}
+
+ - name: Run test-spec with previous CAPI extension binaries
+ id: check
+ shell: bash
+ run: | # zizmor: ignore[template-injection]
+ touch spec/ruby/optional/capi/ext/*.$DLEXT
+ [ ! -f spec/ruby/optional/capi/ext/\*.$DLEXT ]
+ ${{ inputs.make }} SPECOPTS=optional/capi test-spec
+ env:
+ DLEXT: ${{ steps.config.outputs.DLEXT }}
+ working-directory: ${{ inputs.builddir }}
+ if: ${{ steps.cache.outputs.cache-hit }}
+
+ - name: Strip CAPI extensions
+ id: strip
+ shell: bash
+ run: |
+ rm -f spec/ruby/optional/capi/ext/*.c
+ [ "$DLEXT" = bundle ] || # separated to .dSYM directories
+ strip spec/ruby/optional/capi/ext/*.$DLEXT
+ env:
+ DLEXT: ${{ steps.config.outputs.DLEXT }}
+ working-directory: ${{ inputs.builddir }}
+ if: >-
+ ${{true
+ && ! steps.cache.outputs.cache-hit
+ && github.ref_name == 'master'
+ }}
+
+ - name: Save CAPI extensions
+ uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
+ with:
+ path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/
+ key: ${{ steps.config.outputs.key }}
+ if: ${{ steps.strip.outcome == 'success' }}
+
+ - shell: bash
+ run: |
+ echo "::error::Change from ${prev} detected; bump up ABI version"
+ env:
+ prev: ${{ steps.config.outputs.version }}
+ if: ${{ always() && steps.check.outcome == 'failure' }}
diff --git a/.github/actions/compilers/action.yml b/.github/actions/compilers/action.yml
new file mode 100644
index 0000000000..c700bbfe9e
--- /dev/null
+++ b/.github/actions/compilers/action.yml
@@ -0,0 +1,164 @@
+name: Compiles ruby in a container
+description: >-
+ Makes ruby using a dedicated container
+
+inputs:
+ tag:
+ required: false
+ default: clang-20
+ description: >-
+ container image tag to use in this run.
+
+ with_gcc:
+ required: false
+ description: >-
+ override compiler path & flags.
+
+ CFLAGS:
+ required: false
+ description: >-
+ C compiler flags to override.
+
+ CXXFLAGS:
+ required: false
+ description: >-
+ C++ compiler flags to override.
+
+ optflags:
+ required: false
+ # -O1 is faster than -O3 in our tests... Majority of time are consumed trying
+ # to optimize binaries. Also GitHub Actions run on relatively modern CPUs
+ # compared to, say, GCC 4 or Clang 3. We don't specify `-march=native`
+ # because compilers tend not understand what the CPU is.
+ default: '-O1'
+ description: >-
+ Compiler flags for optimisations.
+
+ cppflags:
+ required: false
+ description: >-
+ Additional preprocessor flags.
+
+ append_configure:
+ required: false
+ default: >-
+ --without-valgrind
+ --without-jemalloc
+ --without-gmp
+ description: >-
+ flags to append to configure.
+
+ enable_shared:
+ required: false
+ default: true
+ description: >-
+ Whether to build libruby.so.
+
+ check:
+ required: false
+ default: ''
+ description: >-
+ Whether to run `make check`
+
+ test_all:
+ required: false
+ default: ''
+ description: >-
+ Whether to run `make test-all` with options for test-all.
+
+ test_spec:
+ required: false
+ default: ''
+ description: >-
+ Whether to run `make test-spec` with options for mspec.
+
+ static_exts:
+ required: false
+ description: >-
+ whitespace separated list of extensions that need be linked statically.
+
+runs:
+ using: composite
+ steps:
+ - shell: bash
+ run: docker pull --quiet "ghcr.io/ruby/ruby-ci-image:${INPUT_TAG}"
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
+
+ - name: Enable Launchable conditionally
+ id: enable-launchable
+ run: echo "enable-launchable=true" >> $GITHUB_OUTPUT
+ shell: bash
+ if: >-
+ ${{
+ github.repository == 'ruby/ruby' ||
+ (github.repository != 'ruby/ruby' && env.LAUNCHABLE_TOKEN)
+ }}
+
+ - name: compile
+ shell: bash
+ run: >-
+ docker run
+ --rm
+ --user=root
+ --volume "${GITHUB_WORKSPACE}:/github/workspace:ro"
+ --workdir=/github/workspace
+ --entrypoint=/github/workspace/.github/actions/compilers/entrypoint.sh
+ --env CI
+ --env GITHUB_ACTION
+ --env INPUT_WITH_GCC
+ --env INPUT_CFLAGS
+ --env INPUT_CXXFLAGS
+ --env INPUT_OPTFLAGS
+ --env INPUT_CPPFLAGS
+ --env INPUT_APPEND_CONFIGURE
+ --env INPUT_CHECK
+ --env INPUT_TEST_ALL
+ --env INPUT_TEST_SPEC
+ --env INPUT_ENABLE_SHARED
+ --env INPUT_STATIC_EXTS
+ --env LAUNCHABLE_ORGANIZATION
+ --env LAUNCHABLE_WORKSPACE
+ --env LAUNCHABLE_ENABLED
+ --env GITHUB_PR_HEAD_SHA
+ --env GITHUB_PULL_REQUEST_URL
+ --env GITHUB_REF
+ --env GITHUB_ACTIONS
+ --env GITHUB_RUN_ID
+ --env GITHUB_REPOSITORY
+ --env GITHUB_WORKFLOW
+ --env GITHUB_RUN_NUMBER
+ --env GITHUB_EVENT_NAME
+ --env GITHUB_SHA
+ --env GITHUB_HEAD_REF
+ --env GITHUB_SERVER_URL
+ "ghcr.io/ruby/ruby-ci-image:${INPUT_TAG}"
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
+ INPUT_WITH_GCC: ${{ inputs.with_gcc || inputs.tag }}
+ INPUT_CFLAGS: ${{ inputs.CFLAGS }}
+ INPUT_CXXFLAGS: ${{ inputs.CXXFLAGS }}
+ INPUT_OPTFLAGS: ${{ inputs.OPTFLAGS }}
+ INPUT_CPPFLAGS: ${{ inputs.cppflags }}
+ INPUT_APPEND_CONFIGURE: ${{ inputs.append_configure }}
+ INPUT_CHECK: ${{ inputs.check }}
+ INPUT_TEST_ALL: ${{ inputs.test_all }}
+ INPUT_TEST_SPEC: ${{ inputs.test_spec }}
+ INPUT_ENABLE_SHARED: ${{ inputs.enable_shared }}
+ INPUT_STATIC_EXTS: ${{ inputs.static_exts }}
+ LAUNCHABLE_ORGANIZATION: ${{ github.repository_owner }}
+ LAUNCHABLE_WORKSPACE: ${{ github.event.repository.name }}
+ LAUNCHABLE_ENABLED: ${{ steps.enable-launchable.outputs.enable-launchable || false }}
+ GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
+ GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }}
+ GITHUB_REF: ${{ github.ref }}
+
+ # Clean up non-default docker images to save disk space.
+ # The default image (clang-20) is reused across multiple steps
+ # within the same job, so we keep it to avoid redundant pulls.
+ - name: clean up docker image
+ shell: bash
+ run: docker rmi "ghcr.io/ruby/ruby-ci-image:${INPUT_TAG}" || true
+ if: ${{ always() && inputs.tag != 'clang-20' }}
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
diff --git a/.github/actions/compilers/entrypoint.sh b/.github/actions/compilers/entrypoint.sh
new file mode 100755
index 0000000000..b554151091
--- /dev/null
+++ b/.github/actions/compilers/entrypoint.sh
@@ -0,0 +1,90 @@
+#! /bin/bash
+
+# Copyright (c) 2024 Ruby developers. All rights reserved.
+#
+# This file is a part of the programming language Ruby. Permission is hereby
+# granted, to either redistribute and/or modify this file, provided that the
+# conditions mentioned in the file COPYING are met. Consult the file for
+# details.
+
+grouped()
+{
+ echo "::group::${@}"
+ "${@}"
+ echo "::endgroup::"
+}
+
+set -e
+set -u
+set -o pipefail
+
+srcdir="/github/workspace/src"
+builddir="$(mktemp -dt)"
+
+export GITHUB_WORKFLOW='Compilations'
+export CONFIGURE_TTY='never'
+export RUBY_DEBUG='ci rgengc'
+export RUBY_TESTOPTS='-q --color=always --tty=no'
+export RUBY_DEBUG_COUNTER_DISABLE='1'
+export GNUMAKEFLAGS="-j$((1 + $(nproc)))"
+
+case "x${INPUT_ENABLE_SHARED}" in
+x | xno | xfalse )
+ enable_shared='--disable-shared'
+ ;;
+*)
+ enable_shared='--enable-shared'
+ ;;
+esac
+
+pushd ${builddir}
+
+grouped git config --global --add safe.directory ${srcdir}
+
+grouped ${srcdir}/configure \
+ -C \
+ --with-gcc="${INPUT_WITH_GCC}" \
+ --enable-debug-env \
+ --disable-install-doc \
+ --with-ext=-test-/cxxanyargs,+ \
+ --without-git \
+ ${enable_shared} \
+ ${INPUT_APPEND_CONFIGURE} \
+ CFLAGS="${INPUT_CFLAGS}" \
+ CXXFLAGS="${INPUT_CXXFLAGS}" \
+ optflags="${INPUT_OPTFLAGS}" \
+ cppflags="${INPUT_CPPFLAGS}" \
+ debugflags='-ggdb3' # -g0 disables backtraces when SEGV. Do not set that.
+
+popd
+
+if [[ -n "${INPUT_STATIC_EXTS}" ]]; then
+ echo "::group::ext/Setup"
+ set -x
+ mkdir ${builddir}/ext
+ (
+ for ext in ${INPUT_STATIC_EXTS}; do
+ echo "${ext}"
+ done
+ ) >> ${builddir}/ext/Setup
+ set +x
+ echo "::endgroup::"
+fi
+
+if [ -n "$INPUT_TEST_ALL" ]; then
+ tests=" -- $INPUT_TEST_ALL"
+else
+ tests=" -- ruby -ext-"
+fi
+
+pushd ${builddir}
+
+grouped make showflags
+grouped make all
+# grouped make install
+
+# Run only `make test` by default. Run other tests if specified.
+grouped make test
+if [[ -n "$INPUT_CHECK" ]]; then grouped make test-tool; fi
+if [[ -n "$INPUT_CHECK" || -n "$INPUT_TEST_ALL" ]]; then grouped make test-all TESTS="$tests"; fi
+if [[ -n "$INPUT_CHECK" || -n "$INPUT_TEST_SPEC" ]]; then grouped env CHECK_LEAKS=true make test-spec MSPECOPT="$INPUT_TEST_SPEC"; fi
diff --git a/.github/actions/launchable/setup/action.yml b/.github/actions/launchable/setup/action.yml
new file mode 100644
index 0000000000..305878492c
--- /dev/null
+++ b/.github/actions/launchable/setup/action.yml
@@ -0,0 +1,337 @@
+name: Set up Launchable
+description: >-
+ Install the required dependencies and execute the necessary Launchable commands for test recording
+
+inputs:
+ os:
+ required: true
+ description: The operating system that CI runs on. This value is used in Launchable flavor.
+
+ test-opts:
+ default: none
+ required: false
+ description: >-
+ Test options that determine how tests are run.
+ This value is used in the Launchable flavor.
+
+ launchable-token:
+ required: false
+ description: >-
+ Launchable token is needed if you want to run Launchable on your forked repository.
+ See https://github.com/ruby/ruby/wiki/CI-Servers#launchable-ci for details.
+
+ builddir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Directory to create Launchable report file.
+
+ srcdir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Directory to (re-)checkout source codes. Launchable retrieves the commit information
+ from the directory.
+
+ test-task:
+ required: false
+ default: ${{ matrix.test_task }}
+ description: >-
+ Specifies a single test task to be executed.
+ This value is used in the Launchable flavor.
+ Either 'test-task' or 'multi-test-tasks' must be configured.
+
+ test-tasks:
+ required: false
+ default: '[]'
+ description: >-
+ Specifies an array of multiple test tasks to be executed.
+ For example: '["test", "test-all"]'.
+ If you want to run a single test task, use the 'test-task' input instead.
+
+ is-yjit:
+ required: false
+ default: 'false'
+ description: >-
+ Whether this workflow is executed on YJIT.
+
+ is-zjit:
+ required: false
+ default: 'false'
+ description: >-
+ Whether this workflow is executed on ZJIT.
+
+outputs:
+ stdout_report_path:
+ value: ${{ steps.global.outputs.stdout_report_path }}
+ description: >-
+ Report file path for standard output.
+
+ stderr_report_path:
+ value: ${{ steps.global.outputs.stderr_report_path }}
+ description: >-
+ Report file path for standard error.
+
+runs:
+ using: composite
+
+ steps:
+ - name: Enable Launchable conditionally
+ id: enable-launchable
+ run: echo "enable-launchable=true" >> $GITHUB_OUTPUT
+ shell: bash
+ if: >-
+ ${{
+ (github.repository == 'ruby/ruby'
+ || (github.repository != 'ruby/ruby'
+ && env.LAUNCHABLE_TOKEN))
+ && (inputs.test-task == 'check'
+ || inputs.test-task == 'test-all'
+ || inputs.test-task == 'test'
+ || contains(fromJSON(inputs.test-tasks), 'test-all')
+ || contains(fromJSON(inputs.test-tasks), 'test'))
+ }}
+
+ # Launchable CLI requires Python and Java.
+ # https://www.launchableinc.com/docs/resources/cli-reference/
+ - name: Set up Python
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
+ with:
+ python-version: "3.x"
+ if: >-
+ ${{ steps.enable-launchable.outputs.enable-launchable
+ && !endsWith(inputs.os, 'ppc64le') && !endsWith(inputs.os, 's390x') }}
+
+ - name: Set up Java
+ uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+ if: >-
+ ${{ steps.enable-launchable.outputs.enable-launchable
+ && !endsWith(inputs.os, 'ppc64le') && !endsWith(inputs.os, 's390x') }}
+
+ - name: Set up Java ppc64le
+ uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
+ with:
+ distribution: 'semeru'
+ architecture: 'ppc64le'
+ java-version: '17'
+ if: >-
+ ${{ steps.enable-launchable.outputs.enable-launchable
+ && endsWith(inputs.os, 'ppc64le') }}
+
+ - name: Set up Java s390x
+ uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
+ with:
+ distribution: 'semeru'
+ architecture: 's390x'
+ java-version: '17'
+ if: >-
+ ${{ steps.enable-launchable.outputs.enable-launchable
+ && endsWith(inputs.os, 's390x') }}
+
+ - name: Set global vars
+ id: global
+ shell: bash
+ run: |
+ test_all_enabled="${{ inputs.test-task == 'check' || inputs.test-task == 'test-all' || contains(fromJSON(inputs.test-tasks), 'test-all') }}"
+ btest_enabled="${{ inputs.test-task == 'check' || inputs.test-task == 'test' || contains(fromJSON(inputs.test-tasks), 'test') }}"
+ test_spec_enabled="${{ inputs.test-task == 'check' || inputs.test-task == 'test-spec' || contains(fromJSON(inputs.test-tasks), 'test-spec') }}"
+ echo test_all_enabled="${test_all_enabled}" >> $GITHUB_OUTPUT
+ echo btest_enabled="${btest_enabled}" >> $GITHUB_OUTPUT
+ echo test_spec_enabled="${test_spec_enabled}" >> $GITHUB_OUTPUT
+ echo test_all_report_file='launchable_test_all_report.json' >> $GITHUB_OUTPUT
+ echo btest_report_file='launchable_btest_report.json' >> $GITHUB_OUTPUT
+ echo test_spec_report_dir='launchable_test_spec_report' >> $GITHUB_OUTPUT
+ echo stdout_report_path="launchable_stdout.log" >> $GITHUB_OUTPUT
+ echo stderr_report_path="launchable_stderr.log" >> $GITHUB_OUTPUT
+ if: steps.enable-launchable.outputs.enable-launchable
+
+ - name: Set environment variables for Launchable
+ shell: bash
+ run: | # zizmor: ignore[github-env]
+ : # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App.
+ : # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42
+ echo "GITHUB_PULL_REQUEST_URL=${INPUT_PR_HTML_URL}" >> $GITHUB_ENV
+ : # The following envs are necessary in Launchable tokenless authentication.
+ : # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20
+ echo "LAUNCHABLE_ORGANIZATION=${INPUT_REPOSITORY_OWNER}" >> $GITHUB_ENV
+ echo "LAUNCHABLE_WORKSPACE=${INPUT_REPOSITORY_NAME}" >> $GITHUB_ENV
+ : # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71
+ echo "GITHUB_PR_HEAD_SHA=${INPUT_PR_HEAD_SHA}" >> $GITHUB_ENV
+ echo "LAUNCHABLE_TOKEN=${INPUT_LAUNCHABLE_TOKEN}" >> $GITHUB_ENV
+ : # To prevent a slowdown in CI, disable request retries when the Launchable server is unstable.
+ echo "LAUNCHABLE_SKIP_TIMEOUT_RETRY=1" >> $GITHUB_ENV
+ echo "LAUNCHABLE_COMMIT_TIMEOUT=1" >> $GITHUB_ENV
+ env:
+ INPUT_PR_HTML_URL: ${{ github.event.pull_request.html_url }}
+ INPUT_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ INPUT_REPOSITORY_NAME: ${{ github.event.repository.name }}
+ INPUT_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
+ INPUT_LAUNCHABLE_TOKEN: ${{ inputs.launchable-token }}
+ if: steps.enable-launchable.outputs.enable-launchable
+
+ - name: Set up path
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ # Since updated PATH variable will be available in only subsequent actions, we need to add the path beforehand.
+ # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
+ run: echo "$(python -msite --user-base)/bin" >> $GITHUB_PATH # zizmor: ignore[github-env]
+ if: >-
+ ${{
+ steps.enable-launchable.outputs.enable-launchable
+ && (startsWith(inputs.os, 'macos')
+ || endsWith(inputs.os, 'ppc64le')
+ || endsWith(inputs.os, 's390x'))
+ }}
+
+ - name: Set up Launchable
+ id: setup-launchable
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: | # zizmor: ignore[github-env]
+ set -x
+ pip install --user launchable
+ : # The build name cannot include a slash, so we replace the string here.
+ github_ref="${INPUT_GITHUB_REF}"
+ github_ref="${github_ref//\//_}"
+ : # With the --name option, we need to configure a unique identifier for this build.
+ : # To avoid setting the same build name as the CI which runs on other branches, we use the branch name here.
+ build_name="${github_ref}_${GITHUB_PR_HEAD_SHA}"
+ test_opts="${INPUT_TEST_OPTS}"
+ test_opts="${test_opts// /}"
+ test_opts="${test_opts//=/:}"
+ test_all_test_suite='test-all'
+ btest_test_suite='btest'
+ test_spec_test_suite='test-spec'
+ if [ "${INPUT_IS_YJIT}" = "true" ]; then
+ test_all_test_suite="yjit-${test_all_test_suite}"
+ btest_test_suite="yjit-${btest_test_suite}"
+ test_spec_test_suite="yjit-${test_spec_test_suite}"
+ fi
+ if [ "${INPUT_IS_ZJIT}" = "true" ]; then
+ test_all_test_suite="zjit-${test_all_test_suite}"
+ btest_test_suite="zjit-${btest_test_suite}"
+ test_spec_test_suite="zjit-${test_spec_test_suite}"
+ fi
+ # launchable_setup target var -- refers ${target} prefixed variables
+ launchable_setup() {
+ local target=$1 session
+ eval [ "\${${target}_enabled}" = "true" ] || return
+ eval local suite=\${${target}_test_suite}
+ session=$(launchable record session \
+ --build "${build_name}" \
+ --observation \
+ --flavor os="${INPUT_OS}" \
+ --flavor test_task="${INPUT_TEST_TASK}" \
+ --flavor test_opts="${test_opts}" \
+ --flavor workflow="${INPUT_WORKFLOW}" \
+ --test-suite ${suite} \
+ )
+ echo "${target}_session=${session}" >> $GITHUB_OUTPUT
+ }
+
+ launchable record build --name "${build_name}"
+ if launchable_setup test_all; then
+ echo "TESTS=${TESTS:+$TESTS }--launchable-test-reports=${test_all_report_file}" >> $GITHUB_ENV
+ fi
+ if launchable_setup btest; then
+ echo "BTESTS=${BTESTS:+$BTESTS }--launchable-test-reports=${btest_report_file}" >> $GITHUB_ENV
+ fi
+ if launchable_setup test_spec; then
+ echo "SPECOPTS=${SPECOPTS:$SPECOPTS }--launchable-test-reports=${test_spec_report_dir}" >> $GITHUB_ENV
+ echo test_spec_enabled=true >> $GITHUB_OUTPUT
+ fi
+
+ echo launchable_setup_dir=$(pwd) >> $GITHUB_OUTPUT
+ if: steps.enable-launchable.outputs.enable-launchable
+ env:
+ INPUT_GITHUB_REF: ${{ github.ref }}
+ INPUT_TEST_OPTS: ${{ inputs.test-opts }}
+ INPUT_IS_YJIT: ${{ inputs.is-yjit }}
+ INPUT_IS_ZJIT: ${{ inputs.is-zjit }}
+ INPUT_OS: ${{ inputs.os }}
+ INPUT_TEST_TASK: ${{ inputs.test-task }}
+ INPUT_WORKFLOW: ${{ github.workflow }}
+ test_all_enabled: ${{ steps.global.outputs.test_all_enabled }}
+ btest_enabled: ${{ steps.global.outputs.btest_enabled }}
+ test_spec_enabled: ${{ steps.global.outputs.test_spec_enabled }}
+ test_all_report_file: ${{ steps.global.outputs.test_all_report_file }}
+ btest_report_file: ${{ steps.global.outputs.btest_report_file }}
+ test_spec_report_dir: ${{ steps.global.outputs.test_spec_report_dir }}
+
+ - name: make test-spec report directory in build directory
+ shell: bash
+ working-directory: ${{ inputs.builddir }}
+ run: mkdir "${test_spec_report_dir}"
+ if: ${{ steps.setup-launchable.outputs.test_spec_enabled == 'true' }}
+ env:
+ test_spec_report_dir: ${{ steps.global.outputs.test_spec_report_dir }}
+
+ - name: Clean up test results in Launchable
+ uses: gacts/run-and-post-run@81b6ce503cde93862cec047c54652e45c5dca991 # v1.4.3
+ with:
+ shell: bash
+ working-directory: ${{ inputs.builddir }}
+ post: |
+ rm -f "${test_all_report_file}"
+ rm -f "${btest_report_file}"
+ rm -fr "${test_spec_report_dir}"
+ rm -f launchable_stdout.log
+ rm -f launchable_stderr.log
+ if: always() && steps.setup-launchable.outcome == 'success'
+ env:
+ test_all_report_file: ${{ steps.global.outputs.test_all_report_file }}
+ btest_report_file: ${{ steps.global.outputs.btest_report_file }}
+ test_spec_report_dir: ${{ steps.global.outputs.test_spec_report_dir }}
+
+ - name: Record test results in Launchable
+ uses: gacts/run-and-post-run@81b6ce503cde93862cec047c54652e45c5dca991 # v1.4.3
+ with:
+ shell: bash
+ working-directory: ${{ inputs.builddir }}
+ post: |
+ if [[ "${test_all_enabled}" = "true" ]]; then \
+ launchable record attachment \
+ --session "${test_all_session}" \
+ "${stdout_report_path}" \
+ "${stderr_report_path}"; \
+ launchable record tests \
+ --session "${test_all_session}" \
+ raw "${test_all_report_file}" || true; \
+ fi
+
+ if [[ "${btest_enabled}" = "true" ]]; then \
+ launchable record attachment \
+ --session "${btest_session}" \
+ "${stdout_report_path}" \
+ "${stderr_report_path}"; \
+ launchable record tests \
+ --session "${btest_session}" \
+ raw "${btest_report_file}" || true; \
+ fi
+
+ if [[ "${test_spec_enabled}" = "true" ]]; then \
+ launchable record attachment \
+ --session "${test_spec_session}" \
+ "${stdout_report_path}" \
+ "${stderr_report_path}"; \
+ launchable record tests \
+ --session "${test_spec_session}" \
+ raw ${test_spec_report_dir}/* || true; \
+ fi
+ if: ${{ always() && steps.setup-launchable.outcome == 'success' }}
+ env:
+ test_all_report_file: ${{ steps.global.outputs.test_all_report_file }}
+ btest_report_file: ${{ steps.global.outputs.btest_report_file }}
+ test_spec_report_dir: ${{ steps.global.outputs.test_spec_report_dir }}
+ test_all_enabled: ${{ steps.global.outputs.test_all_enabled }}
+ btest_enabled: ${{ steps.global.outputs.btest_enabled }}
+ test_spec_enabled: ${{ steps.global.outputs.test_spec_enabled }}
+ test_all_session: ${{ steps.setup-launchable.outputs.test_all_session }}
+ btest_session: ${{ steps.setup-launchable.outputs.btest_session }}
+ test_spec_session: ${{ steps.setup-launchable.outputs.test_spec_session }}
+ stdout_report_path: ${{ steps.global.outputs.stdout_report_path }}
+ stderr_report_path: ${{ steps.global.outputs.stderr_report_path }}
+ LAUNCHABLE_SETUP_DIR: ${{ steps.setup-launchable.outputs.launchable_setup_dir }}
diff --git a/.github/actions/make-snapshot/action.yml b/.github/actions/make-snapshot/action.yml
new file mode 100644
index 0000000000..4552f0e067
--- /dev/null
+++ b/.github/actions/make-snapshot/action.yml
@@ -0,0 +1,77 @@
+name: 'make-snapshot'
+description: 'Make snapshot tarballs'
+inputs:
+ archname:
+ description: 'archname passed to tool/make-snapshot (e.g. snapshot-master)'
+ required: true
+ version:
+ description: 'Target Version'
+ required: false
+ shallow-since:
+ description: 'git fetch --shallow-since'
+ required: true
+ default: '2018-12-25 00:00:00'
+ fetch-branch:
+ description: 'fetch branch'
+ required: false
+ srcdir:
+ description: 'srcdir for tool/make-snapshot. Empty = clone ruby/ruby into ./ruby.'
+ required: false
+ default: ''
+ upload-artifact:
+ description: 'Upload Packages and Info as workflow artifacts. Pass "false" when callers run in a matrix that would collide on artifact names.'
+ required: false
+ default: 'true'
+
+runs:
+ using: "composite"
+ steps:
+ - name: Install libraries
+ run: |
+ set -x
+ sudo apt-get update -q || :
+ sudo apt-get install --no-install-recommends -q -y build-essential git bison autoconf ruby p7zip-full curl
+ shell: bash
+ - name: Checkout ruby/ruby for tool/make-snapshot
+ if: inputs.srcdir == ''
+ run: git clone --single-branch --depth=1 https://github.com/ruby/ruby ruby
+ shell: bash
+ - name: Fetch branches and notes (clone mode)
+ if: inputs.srcdir == ''
+ env:
+ SHALLOW_SINCE: ${{ inputs.shallow-since }}
+ FETCH_BRANCH: ${{ inputs.fetch-branch }}
+ run: |
+ set -x
+ cd ruby
+ git fetch --shallow-since="$SHALLOW_SINCE"
+ [ -n "$FETCH_BRANCH" ] && git fetch origin "+$FETCH_BRANCH:$FETCH_BRANCH"
+ git fetch origin '+refs/notes/commits:refs/notes/commits'
+ git fetch origin '+refs/notes/log-fix:refs/notes/log-fix'
+ shell: bash
+ - name: Fetch notes (local srcdir mode)
+ if: inputs.srcdir != ''
+ working-directory: ${{ inputs.srcdir }}
+ run: |
+ git fetch origin '+refs/notes/commits:refs/notes/commits' || :
+ git fetch origin '+refs/notes/log-fix:refs/notes/log-fix' || :
+ shell: bash
+ - name: Make snapshot
+ env:
+ ARCHNAME: ${{ inputs.archname }}
+ SRCDIR: ${{ inputs.srcdir }}
+ VERSION: ${{ inputs.version }}
+ run: |
+ [ -z "$SRCDIR" ] && SRCDIR=ruby
+ ruby "$SRCDIR/tool/make-snapshot" "-archname=$ARCHNAME" -srcdir="$SRCDIR" -packages=gzip,xz,zip pkg $VERSION
+ shell: bash
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: Packages
+ path: pkg
+ if: ${{ inputs.upload-artifact == 'true' }}
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: Info
+ path: pkg/info
+ if: ${{ inputs.upload-artifact == 'true' }}
diff --git a/.github/actions/setup/baseruby/action.yml b/.github/actions/setup/baseruby/action.yml
new file mode 100644
index 0000000000..76fe068897
--- /dev/null
+++ b/.github/actions/setup/baseruby/action.yml
@@ -0,0 +1,73 @@
+name: Setup directories etc.
+description: >-
+ Build baseruby for cross-compiling
+
+inputs:
+ srcdir:
+ required: true
+ default: ${{ github.workspace }}
+ description: >-
+ Directory of source codes.
+
+ builddir:
+ required: false
+ default: ${{ github.workspace }}/baseruby
+ description: >-
+ Where baseruby will be built.
+
+ installdir:
+ required: false
+ default: install
+ description: >-
+ The path where the baseruby will be installed to.
+ This is relative from the workspace.
+
+outputs:
+ ruby:
+ value: ${{ steps.build.outputs.installdir }}/bin/ruby
+ description: >-
+ The path of the executable baseruby.
+ dump_ast:
+ value: ${{ steps.build.outputs.installdir }}/bin/dump_ast
+ description: >-
+ The path of the executable dump_ast.
+
+runs:
+ using: composite
+
+ steps:
+ - name: Build baseruby
+ shell: bash
+ id: build
+ run: |
+ case "$installdir" in /*) ;; *) installdir="$PWD/$installdir";; esac
+ mkdir "$builddir"
+ ln -sr "$srcdir" "$builddir/.src"
+ pushd "$builddir"
+ .src/configure "--prefix=${installdir}" --disable-install-doc
+ CONFIGURE_ARGS=--with-out-ext=-test- make install
+ install dump_ast "${installdir}/bin"
+ {
+ echo "${installdir}/bin/dump_ast"
+ echo "${installdir}/.installed.list"
+ echo "${installdir}/"
+ } >> .installed.list
+ cp .installed.list "${installdir}/"
+ make distclean
+ rm .src
+ popd
+ rmdir "$builddir"
+ {
+ echo "installdir=${installdir}"
+ } | tee -a "$GITHUB_OUTPUT"
+ env:
+ srcdir: ${{ inputs.srcdir }}
+ builddir: ${{ inputs.builddir }}
+ installdir: ${{ inputs.installdir }}
+
+ - name: clean
+ uses: gacts/run-and-post-run@598d7a875d5620e0457490555b5e18e46082aa47 # v1.4.4
+ with:
+ working-directory: ${{ inputs.srcdir }}
+ post: |
+ ruby tool/rbuninstall.rb "${{ steps.build.outputs.installdir }}/.installed.list" > /dev/null
diff --git a/.github/actions/setup/directories/action.yml b/.github/actions/setup/directories/action.yml
new file mode 100644
index 0000000000..589049a4b8
--- /dev/null
+++ b/.github/actions/setup/directories/action.yml
@@ -0,0 +1,205 @@
+name: Setup directories etc.
+description: >-
+ Set up the source code and build directories (plus some
+ environmental tweaks)
+
+inputs:
+ srcdir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Directory to (re-)checkout source codes. This will be created
+ if absent. If there is no `configure` file that is also
+ generated inside.
+
+ builddir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Where binaries and other generated contents go. This will be
+ created if absent.
+
+ make-command:
+ required: false
+ type: string
+ default: 'make'
+ description: >-
+ The command of `make`.
+
+ makeup:
+ required: false
+ type: boolean
+ # Note that `default: false` evaluates to a string constant
+ # `'false'`, which is a truthy value :sigh:
+ # https://github.com/actions/runner/issues/2238
+ default: ''
+ description: >-
+ If set to true, additionally runs `make up`.
+
+ checkout:
+ required: false
+ type: boolean
+ default: true
+ description: >-
+ If set to '' (false), skip running actions/checkout. This is useful when
+ you don't want to overwrite a GitHub token that is already set up.
+
+ dummy-files:
+ required: false
+ type: boolean
+ default: ''
+ description: >-
+ If set to true, creates dummy files in build dir.
+
+ fetch-depth:
+ required: false
+ default: '1'
+ description: The depth of commit history fetched from the remote repository
+
+ clean:
+ required: false
+ type: boolean
+ default: ''
+ description: >-
+ If set to true, clean build directory.
+
+outputs: {} # nothing?
+
+runs:
+ using: composite
+
+ steps:
+ # Note that `shell: bash` works on both Windows and Linux, but not
+ # `shell: sh`. This is because GitHub hosted Windows runners have
+ # their bash manually installed.
+ - shell: bash
+ run: |
+ mkdir -p "${INPUT_SRCDIR}"
+ mkdir -p "${INPUT_BUILDDIR}"
+ env:
+ INPUT_SRCDIR: ${{ inputs.srcdir }}
+ INPUT_BUILDDIR: ${{ inputs.builddir }}
+
+ # Did you know that actions/checkout works without git(1)? We are
+ # checking that here.
+ - id: which
+ shell: bash
+ run: |
+ echo "git=`command -v git`" >> "$GITHUB_OUTPUT"
+ echo "sudo=`sudo true && command -v sudo`" >> "$GITHUB_OUTPUT"
+ echo "autoreconf=`command -v autoreconf`" >> "$GITHUB_OUTPUT"
+
+ - if: steps.which.outputs.git
+ shell: bash
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+ git config --global advice.detachedHead 0
+ git config --global init.defaultBranch garbage
+
+ - if: inputs.checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ path: ${{ inputs.srcdir }}
+ fetch-depth: ${{ inputs.fetch-depth }}
+ persist-credentials: false
+
+ - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+ with:
+ path: ${{ inputs.srcdir }}/.downloaded-cache
+ key: ${{ runner.os }}-${{ runner.arch }}-downloaded-cache
+
+ - if: steps.which.outputs.autoreconf
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: ./autogen.sh --install
+
+ # This is for MinGW.
+ - if: runner.os == 'Windows'
+ shell: bash
+ run: echo "GNUMAKEFLAGS=-j$((2 * NUMBER_OF_PROCESSORS))" >> $GITHUB_ENV # zizmor: ignore[github-env]
+
+ - if: runner.os == 'Linux'
+ shell: bash
+ run: echo "GNUMAKEFLAGS=-sj$((1 + $(nproc)))" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
+
+ # macOS' GNU make is so old that they doesn't understand `GNUMAKEFLAGS`.
+ - if: runner.os == 'macOS'
+ shell: bash
+ run: echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
+
+ - if: inputs.makeup
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: |
+ touch config.status .rbconfig.time
+ for mk in Makefile GNUmakefile; do
+ sed -f tool/prereq.status template/$mk.in > $mk
+ done
+ make up
+
+ # Cleanup, runs even on failure
+ - if: always() && inputs.makeup
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: |
+ rm -f config.status .rbconfig.time \
+ Makefile GNUmakefile uncommon.mk enc.mk noarch-fake.rb
+ rm -f prism/.time prism/util/.time
+
+ - if: steps.which.outputs.sudo
+ shell: bash
+ run: |
+ sudo chmod -R go-w /usr/share
+ chmod -v go-w $HOME $HOME/.config || :
+ declare -a dirs # -A is not supported by old bash, e.g. macos
+ SAVE_IFS="$IFS" IFS=:; set $PATH
+ for d do
+ while [ -d "$d" ]; do
+ case "$IFS${dirs[*]}$IFS" in *"$IFS$d$IFS"*) ;; *) dirs+=("$d");; esac
+ d="${d%/*}"
+ done
+ done
+ IFS="$SAVE_IFS"
+ sudo chmod -v go-w "${dirs[@]}" || :
+
+ - if: inputs.dummy-files == 'true'
+ shell: bash
+ id: dummy-files
+ working-directory: ${{ inputs.builddir }}
+ run: |
+ : Create dummy files in build dir
+ set {{a..z},{A..Z},{0..9},foo,bar,test,zzz}.rb
+ for file; do \
+ echo > $file "raise 'do not load $file'"; \
+ done
+ # drop {a..z}.rb if case-insensitive filesystem
+ grep -F A.rb a.rb > /dev/null && set "${@:27}"
+ echo clean="cd ${INPUT_BUILDDIR} && rm $*" >> $GITHUB_OUTPUT
+ env:
+ INPUT_BUILDDIR: ${{ inputs.builddir }}
+
+ - if: inputs.clean == 'true'
+ shell: bash
+ id: clean
+ run: |
+ echo distclean="cd ${INPUT_BUILDDIR} && ${INPUT_MAKE_COMMAND} distclean" >> $GITHUB_OUTPUT
+ echo remained-files="find ${INPUT_BUILDDIR} -ls" >> $GITHUB_OUTPUT
+ [ "${INPUT_BUILDDIR}" = "${INPUT_SRCDIR}" ] ||
+ echo final="rmdir ${INPUT_BUILDDIR}" >> $GITHUB_OUTPUT
+ env:
+ INPUT_BUILDDIR: ${{ inputs.builddir }}
+ INPUT_SRCDIR: ${{ inputs.srcdir }}
+ INPUT_MAKE_COMMAND: ${{ inputs.make-command }}
+
+ - name: clean
+ uses: gacts/run-and-post-run@598d7a875d5620e0457490555b5e18e46082aa47 # v1.4.4
+ with:
+ working-directory:
+ post: |
+ ${{ steps.dummy-files.outputs.clean }}
+ ${{ steps.clean.outputs.distclean }}
+ ${{ steps.clean.outputs.remained-files }}
+ ${{ steps.clean.outputs.final }}
+ # rmdir randomly fails due to launchable files
+ continue-on-error: true
diff --git a/.github/actions/setup/macos/action.yml b/.github/actions/setup/macos/action.yml
new file mode 100644
index 0000000000..9cd37a9b12
--- /dev/null
+++ b/.github/actions/setup/macos/action.yml
@@ -0,0 +1,29 @@
+name: Setup macOS environment
+description: >-
+ Installs necessary packages via Homebrew.
+
+inputs: {} # nothing?
+
+outputs: {} # nothing?
+
+runs:
+ using: composite
+
+ steps:
+ - name: brew
+ shell: bash
+ run: |
+ brew install --quiet jemalloc gmp libffi openssl@3 zlib autoconf automake libtool
+
+ - name: Set ENV
+ shell: bash
+ run: | # zizmor: ignore[github-env]
+ dir_config() {
+ local args=() lib var="$1"; shift
+ for lib in "$@"; do
+ args+=("--with-${lib%@*}-dir=$(brew --prefix $lib)")
+ done
+ echo "$var=${args[*]}" >> $GITHUB_ENV
+ }
+ dir_config ruby_configure_args gmp
+ dir_config CONFIGURE_ARGS openssl@3
diff --git a/.github/actions/setup/ubuntu/action.yml b/.github/actions/setup/ubuntu/action.yml
new file mode 100644
index 0000000000..5209ccc03f
--- /dev/null
+++ b/.github/actions/setup/ubuntu/action.yml
@@ -0,0 +1,72 @@
+name: Setup ubuntu environment
+description: >-
+ At the beginning there was no way but to copy & paste `apt-get`
+ everywhere. But now that we have composite actions, it seems better
+ merge them into one.
+
+inputs:
+ arch:
+ required: false
+ default: ''
+ description: >-
+ Architecture. Because we run this on a GitHub-hosted runner
+ acceptable value for this input is very limited.
+
+outputs:
+ arch:
+ value: ${{ steps.uname.outputs.uname }}
+ description: >-
+ Actual architecture. This could be different from the one
+ passed to the `inputs.arch`. For instance giving `i386` to this
+ action yields `i686`.
+
+runs:
+ using: composite
+
+ steps:
+ - id: uname
+ name: uname
+ shell: bash
+ env:
+ arch: ${{ inputs.arch }}
+ run: |
+ setarch="${arch:+setarch $arch --}"
+ # normalize `uname`
+ if uname=$(${setarch} uname -m 2> /dev/null); then
+ # `setarch` works, `$arch` is a valid architecture name.
+ echo "setarch=${setarch}" >> "$GITHUB_OUTPUT"
+ else
+ # if `setarch` failed, take the given `arch` as-is.
+ uname="${arch}"
+ setarch=""
+ fi
+ echo "uname=$uname" >> "$GITHUB_OUTPUT"
+ echo "dpkg=${uname/686/386}" >> "$GITHUB_OUTPUT"
+
+ - name: set SETARCH
+ shell: bash
+ run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
+ env:
+ setarch: ${{ steps.uname.outputs.setarch }} # validated
+
+ - name: dpkg setup
+ shell: bash
+ run: sudo dpkg --add-architecture "${dpkg}"
+ # `dpkg` is valid, also `uname`.
+ if: ${{ inputs.arch }}
+ env:
+ dpkg: ${{ steps.uname.outputs.dpkg }}
+
+ - name: apt-get
+ shell: bash
+ env:
+ arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
+ run: |
+ set -x
+ sudo apt-get update -qq || :
+ sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
+ ${arch:+cross}build-essential${arch/:/-} \
+ libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
+ zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
+ autoconf ruby
+ sudo apt-get install -qq -y pkg-config${arch} || :
diff --git a/.github/actions/slack/action.yml b/.github/actions/slack/action.yml
new file mode 100644
index 0000000000..6f89bef11a
--- /dev/null
+++ b/.github/actions/slack/action.yml
@@ -0,0 +1,51 @@
+name: Post a message to slack
+description: >-
+ We have our ruby/action-slack webhook. However its arguments are
+ bit verbose to be listed in every workflow files. Better merge them
+ into one.
+
+inputs:
+ SLACK_WEBHOOK_URL:
+ required: true
+ description: >-
+ The URL to post the payload. This is an input because it tends
+ to be stored in a secrets vault and a composite action cannot
+ look into one.
+
+ label:
+ required: false
+ description: >-
+ Human-readable description of the run, something like "DEBUG=1".
+ This need not be unique among runs.
+
+ event_name:
+ required: false
+ default: 'push'
+ description: >-
+ Target event to trigger notification. Notify only push by default.
+
+ extra_channel_id:
+ required: false
+ description: >-
+ Slack channel ID to notify besides #alerts and #alerts-emoji.
+
+outputs: {} # Nothing?
+
+runs:
+ using: composite
+
+ steps:
+ - uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
+ with:
+ payload: |
+ {
+ "ci": "GitHub Actions",
+ "env": "${{ github.workflow }}${{ inputs.label && format(' / {0}', inputs.label) }}",
+ "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
+ "commit": "${{ github.sha }}",
+ "branch": "${{ github.ref_name }}"
+ ${{ inputs.extra_channel_id && format(', "extra_channel_id": "{0}"', inputs.extra_channel_id) }}
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }}
+ if: ${{ github.event_name == inputs.event_name && startsWith(github.repository, 'ruby/') }}
diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml
index f694a1c72f..9e20cb7459 100644
--- a/.github/auto_request_review.yml
+++ b/.github/auto_request_review.yml
@@ -1,14 +1,21 @@
files:
- 'yjit*': [team:yjit]
- 'yjit/**/*': [team:yjit]
+ 'yjit*': [team:jit]
+ 'yjit/**/*': [team:jit]
'yjit/src/cruby_bindings.inc.rs': []
- 'doc/yjit/*': [team:yjit]
- 'bootstraptest/test_yjit*': [team:yjit]
- 'test/ruby/test_yjit*': [team:yjit]
- '.github/workflows/yjit*': [team:yjit]
+ 'bootstraptest/test_yjit*': [team:jit]
+ 'test/ruby/test_yjit*': [team:jit]
+ 'zjit*': [team:jit]
+ 'zjit/**/*': [team:jit]
+ 'zjit/src/cruby_bindings.inc.rs': []
+ 'test/ruby/test_zjit*': [team:jit]
+ 'defs/jit.mk': [team:jit]
+ 'tool/zjit_bisect.rb': [team:jit]
+ 'doc/jit/*': [team:jit]
+ # Skip files updated by dependabot. It's noisy in notifications, and they're auto-merged anyway.
+ 'yjit/Cargo.lock': []
+ 'zjit/Cargo.lock': []
+ '.github/workflows/yjit-*.yml': []
+ '.github/workflows/zjit-*.yml': []
options:
ignore_draft: true
- # This currently doesn't work as intended. We want to skip reviews when only
- # cruby_bingings.inc.rs is modified, but this skips reviews even when other
- # yjit files are modified as well. To be enabled after fixing the behavior.
- #last_files_match_only: true
+ last_files_match_only: true
diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
new file mode 100644
index 0000000000..f5d33545c1
--- /dev/null
+++ b/.github/codeql/codeql-config.yml
@@ -0,0 +1,22 @@
+paths-ignore:
+ - benchmark
+ - sample
+ - spec/ruby/command_line/fixtures
+ - spec/ruby/core/enumerable/shared/inject.rb
+ - spec/ruby/core/exception/fixtures
+ - spec/ruby/core/proc/parameters_spec.rb
+ - spec/ruby/core/proc/ruby2_keywords_spec.rb
+ - spec/ruby/core/range/reverse_each_spec.rb
+ - spec/ruby/language/fixtures
+ - spec/ruby/language/lambda_spec.rb
+ - spec/ruby/language/method_spec.rb
+ - spec/ruby/language/string_spec.rb
+ - test/error_highlight/test_error_highlight.rb
+ - test/prism/result/named_capture_test.rb
+ - test/ruby/test_call.rb
+ - test/ruby/test_signal.rb
+ - test/ruby/test_super.rb
+ - test/ruby/test_syntax.rb
+ - test/ruby/test_unicode_escape.rb
+ - test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec
+ - trace_point.rb
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 6778b0493a..57da742e5c 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,6 +1,29 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
+ directories:
+ - '/'
+ - '/.github/actions/slack'
+ - '/.github/actions/setup/directories'
+ schedule:
+ interval: 'daily'
+ groups:
+ github-actions:
+ patterns:
+ - "*"
+ - package-ecosystem: 'cargo'
+ directories:
+ - '/yjit'
+ - '/zjit'
+ exclude-paths:
+ - 'gc/mmtk/**'
+ schedule:
+ interval: 'monthly'
+ groups:
+ jit:
+ patterns:
+ - "*"
+ - package-ecosystem: 'vcpkg'
directory: '/'
schedule:
interval: 'daily'
diff --git a/.github/labeler.yml b/.github/labeler.yml
new file mode 100644
index 0000000000..f39fcec386
--- /dev/null
+++ b/.github/labeler.yml
@@ -0,0 +1,7 @@
+Documentation:
+- changed-files:
+ - all-globs-to-all-files: doc/**
+
+Backport:
+- base-branch: 'ruby_3_\d'
+- base-branch: 'ruby_4_\d'
diff --git a/.github/workflows/annocheck.yml b/.github/workflows/annocheck.yml
index 69a7f19264..1d23c38fcd 100644
--- a/.github/workflows/annocheck.yml
+++ b/.github/workflows/annocheck.yml
@@ -4,150 +4,107 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
+ - '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-# GitHub actions does not support YAML anchors. This creative use of
-# environment variables (plus the "echo $GITHUB_ENV" hack) is to reroute that
-# restriction.
-env:
- default_cc: clang-15
- append_cc: ''
-
- # -O1 is faster than -O3 in our tests... Majority of time are consumed trying
- # to optimize binaries. Also GitHub Actions run on relatively modern CPUs
- # compared to, say, GCC 4 or Clang 3. We don't specify `-march=native`
- # because compilers tend not understand what the CPU is.
- optflags: '-O1'
-
- # -g0 disables backtraces when SEGV. Do not set that.
- debugflags: '-ggdb3'
-
- default_configure: >-
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- append_configure: >-
- --without-valgrind
- --without-jemalloc
- --without-gmp
-
- CONFIGURE_TTY: never
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
-
permissions:
contents: read
jobs:
compile:
- strategy:
- fail-fast: false
- matrix:
- env:
- - {}
- entry:
- - name: 'gcc-11 annocheck'
- container: gcc-11
- env:
- # Minimal flags to pass the check.
- default_cc: 'gcc-11 -fcf-protection -Wa,--generate-missing-build-notes=yes'
- optflags: '-O2'
- LDFLAGS: '-Wl,-z,now'
- # FIXME: Drop skipping options
- # https://bugs.ruby-lang.org/issues/18061
- # https://sourceware.org/annobin/annobin.html/Test-pie.html
- TEST_ANNOCHECK_OPTS: "--skip-pie --skip-gaps"
- check: true
-
- name: ${{ matrix.entry.name }}
+ name: test-annocheck
+
runs-on: ubuntu-latest
+
container:
- image: ghcr.io/ruby/ruby-ci-image:${{ matrix.entry.container || matrix.entry.env.default_cc || 'clang-15' }}
+ image: ghcr.io/ruby/ruby-ci-image:gcc-11
options: --user root
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- env: ${{ matrix.entry.env || matrix.env }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ env:
+ CONFIGURE_TTY: never
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUBY_DEBUG: ci rgengc
+ RUBY_TESTOPTS: >-
+ -q
+ --color=always
+ --tty=no
+ # FIXME: Drop skipping options
+ # https://bugs.ruby-lang.org/issues/18061
+ # https://sourceware.org/annobin/annobin.html/Test-pie.html
+ TEST_ANNOCHECK_OPTS: '--skip-pie --skip-gaps'
+
steps:
- run: id
working-directory:
- - run: mkdir build
- working-directory:
- - name: setenv
- run: |
- echo "GNUMAKEFLAGS=-sj$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/directories
with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: autogen
- run: |
- if [ ! -f ./autogen.sh ]; then
- ls -la
- fi
- ./autogen.sh
- working-directory: src
+ ruby-version: '3.1'
+ bundler: none
+
+ # Minimal flags to pass the check.
+ # -g0 disables backtraces when SEGV. Do not set that.
- name: Run configure
run: >
- ../src/configure -C ${default_configure} ${append_configure}
- --${{
- matrix.entry.crosshost && 'host' || 'with-gcc'
- }}=${{
- matrix.entry.crosshost || '"${default_cc}${append_cc:+ $append_cc}"'
- }}
- --${{ matrix.entry.shared || 'enable' }}-shared
- - run: make extract-extlibs
- - run: make incs
+ ../src/configure -C
+ --enable-debug-env
+ --disable-install-doc
+ --with-ext=-test-/cxxanyargs,+
+ --without-valgrind
+ --without-jemalloc
+ --without-gmp
+ --with-gcc="gcc-11 -fcf-protection -Wa,--generate-missing-build-notes=yes"
+ --enable-shared
+ debugflags=-ggdb3
+ optflags=-O2
+ LDFLAGS=-Wl,-z,now
+
- run: make showflags
+
- run: make
- - run: make leaked-globals
- - run: make test
- - run: make install
- if: ${{ matrix.entry.check }}
- - run: make test-tool
- if: ${{ matrix.entry.check }}
- ### test-all doesn't work: https://github.com/ruby/ruby/actions/runs/4340112185/jobs/7578344307
- # - run: make test-all TESTS='-- ruby -ext-'
- # if: ${{ matrix.entry.check }}
- ### test-spec doesn't work: https://github.com/ruby/ruby/actions/runs/4340193212/jobs/7578505652
- # - run: make test-spec
- # env:
- # CHECK_LEAKS: true
- # if: ${{ matrix.entry.check }}
+
- run: make test-annocheck
- if: ${{ matrix.entry.check && endsWith(matrix.entry.name, 'annocheck') }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.entry.name }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
diff --git a/.github/workflows/auto_request_review.yml b/.github/workflows/auto_request_review.yml
index 340aae4391..1be2b11b86 100644
--- a/.github/workflows/auto_request_review.yml
+++ b/.github/workflows/auto_request_review.yml
@@ -2,6 +2,7 @@ name: Auto Request Review
on:
pull_request_target:
types: [opened, ready_for_review, reopened]
+ branches: [master]
permissions:
contents: read
@@ -10,10 +11,10 @@ jobs:
auto-request-review:
name: Auto Request Review
runs-on: ubuntu-latest
- if: ${{ github.repository == 'ruby/ruby' }}
+ if: ${{ github.repository == 'ruby/ruby' && github.base_ref == 'master' }}
steps:
- name: Request review based on files changes and/or groups the author belongs to
- uses: necojackarc/auto-request-review@5f91f424cabb3211c669e49e79da8363f7df395b # v0.10.0
+ uses: necojackarc/auto-request-review@5d3060495e58e9cb41f51de50e808d3135d5374e # master
with:
# scope: public_repo
- token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
+ token: ${{ secrets.MATZBOT_AUTO_REQUEST_REVIEW_TOKEN }}
diff --git a/.github/workflows/auto_review_pr.yml b/.github/workflows/auto_review_pr.yml
new file mode 100644
index 0000000000..24859ad0b0
--- /dev/null
+++ b/.github/workflows/auto_review_pr.yml
@@ -0,0 +1,41 @@
+name: Auto Review PR
+on:
+ pull_request_target:
+ types: [opened, ready_for_review, reopened]
+ branches: [master]
+ workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'PR number to review'
+ required: true
+ type: number
+
+permissions:
+ contents: read
+
+jobs:
+ auto-review-pr:
+ name: Auto Review PR
+ runs-on: ubuntu-latest
+ if: ${{ github.repository == 'ruby/ruby' && (github.base_ref == 'master' || github.event_name == 'workflow_dispatch') }}
+
+ permissions:
+ pull-requests: write
+ contents: read
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.4'
+ bundler: none
+
+ - name: Auto Review PR
+ run: ruby tool/auto_review_pr.rb "$GITHUB_PR_NUMBER"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
diff --git a/.github/workflows/baseruby.yml b/.github/workflows/baseruby.yml
index d50cac3a18..1acfbe19ac 100644
--- a/.github/workflows/baseruby.yml
+++ b/.github/workflows/baseruby.yml
@@ -4,17 +4,20 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -26,46 +29,48 @@ permissions:
jobs:
baseruby:
name: BASERUBY
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
strategy:
matrix:
ruby:
- - ruby-2.5
-# - ruby-2.6
-# - ruby-2.7
- - ruby-3.0
- ruby-3.1
- ruby-3.2
+ - ruby-3.3
steps:
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: .downloaded-cache
- key: downloaded-cache
- - uses: ruby/setup-ruby@e6689b4deb1cb2062ea45315001f687c0b52111b # v1.144.1
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
- - run: echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - run: sudo apt-get install build-essential autoconf bison libyaml-dev
- - run: ./autogen.sh
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ makeup: true
+
- run: ./configure --disable-install-doc
- - run: make common-srcs
- - run: make incs
+
- run: make all
+
- run: make test
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / BASERUBY @ ${{ matrix.ruby }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.ruby }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/bundled_gems.yml b/.github/workflows/bundled_gems.yml
index 3cc68693fc..d890ed2495 100644
--- a/.github/workflows/bundled_gems.yml
+++ b/.github/workflows/bundled_gems.yml
@@ -1,131 +1,186 @@
name: bundled_gems
+env:
+ UPDATE_ENABLED: true
+
on:
push:
+ branches: ['master']
paths:
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
pull_request:
+ branches: ['master']
paths:
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
+ merge_group:
schedule:
- cron: '45 6 * * *'
workflow_dispatch:
-permissions: # added using https://github.com/step-security/secure-workflows
+permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
update:
permissions:
- contents: write # for Git to git push
+ contents: write # for Git to git push
+
if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby' }}
+
name: update ${{ github.workflow }}
+
runs-on: ubuntu-latest
+
steps:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
+ with:
+ token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: 4.0
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN
+ checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)
- name: Set ENV
run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
echo "TODAY=$(date +%F)" >> $GITHUB_ENV
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
-
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: .downloaded-cache
- key: downloaded-cache-${{ github.sha }}
- restore-keys: |
- downloaded-cache
-
- name: Download previous gems list
run: |
- data=bundled_gems.json
mkdir -p .downloaded-cache
- ln -s .downloaded-cache/$data .
- curl -O -R -z ./$data https://stdgems.org/$data
+ for data in bundled_gems.json default_gems.json; do
+ ln -s .downloaded-cache/$data .
+ curl --retry 5 --retry-connrefused --retry-delay 2 --retry-max-time 60 -O -R -z ./$data https://stdgems.org/$data
+ done
- name: Update bundled gems list
+ id: bundled_gems
run: |
- ruby -i~ tool/update-bundled_gems.rb gems/bundled_gems
+ ruby -i~ tool/update-bundled_gems.rb gems/bundled_gems >> $GITHUB_OUTPUT
+ if: ${{ env.UPDATE_ENABLED == 'true' }}
- name: Maintain updated gems list in NEWS
run: |
ruby tool/update-NEWS-gemlist.rb bundled
+ ruby tool/update-NEWS-github-release.rb --update
+ if: ${{ env.UPDATE_ENABLED == 'true' }}
- name: Check diffs
id: diff
run: |
- git add -- NEWS.md
- git diff --no-ext-diff --ignore-submodules --quiet -- gems/bundled_gems
- continue-on-error: true
+ news= gems=
+ git diff --color --no-ext-diff --ignore-submodules --exit-code -- NEWS.md ||
+ news=true
+ git diff --color --no-ext-diff --ignore-submodules --exit-code -- gems/bundled_gems ||
+ gems=true
+ git add -- NEWS.md gems/bundled_gems
+ echo news=$news >> $GITHUB_OUTPUT
+ echo gems=$gems >> $GITHUB_OUTPUT
+ echo update=${news:-$gems} >> $GITHUB_OUTPUT
- - name: Install libraries
+ - name: Commit
+ id: commit
run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
- if: ${{ steps.diff.outcome == 'failure' }}
+ git pull --ff-only origin ${GITHUB_REF#refs/heads/}
+ message="Update bundled gems list"
+ if [ -z "${gems}" ]; then
+ git commit --message="[DOC] ${message} at ${GITHUB_SHA:0:30}"
+ else
+ git commit --message="${message} as of ${TODAY}"
+ fi
+ env:
+ TODAY: ${{ steps.bundled_gems.outputs.latest_date || env.TODAY }}
+ EMAIL: svn-admin@ruby-lang.org
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+ gems: ${{ steps.diff.outputs.gems }}
+ if: ${{ steps.diff.outputs.update }}
+
+ - name: Development revision of bundled gems
+ run: |
+ #!ruby
+ file = "gems/bundled_gems"
+
+ SECONDS_IN_DAY = 86400
+ today = Time.new("#{ENV['TODAY']}Z")
+ if !(december = today.month == 12)
+ days = 30
+ elsif (days = 26 - today.day).positive?
+ days += 4
+ else
+ puts "::info:: just after released"
+ exit
+ end
+
+ since = "#{today.year-1}-12-26"
+ ref = ENV['GITHUB_REF']
+ puts "::group::\e[94mfetching \e[1m#{file}\e[22m since \e[1m#{since}\e[22m from \e[1m#{ref}\e[m"
+ system(*%W[git fetch --shallow-since=#{since} --no-tags origin #{ref}], exception: true)
+ puts "::endgroup::"
+
+ puts "\e[94mchecking development version bundled gems older than \e[1m#{days}\e[22m days\e[m"
+ limit = today.to_i - days * SECONDS_IN_DAY
+ old = 0
+ IO.popen(%W"git blame --line-porcelain -- #{file}") do |blame|
+ while head = blame.gets("\n\t") and s = blame.gets
+ next unless (gem = s.split(/\s+|#.*/)).size > 3
+ time = head[/^committer-time \K\d+/].to_i
+ next if (d = limit - time) <= 0
+ d /= SECONDS_IN_DAY
+ line = head[/\A\h+ \d+ \K\d+/].to_i
+ level = if d < days; 'warning'; else old += 1; 'error'; end
+ d += days
+ puts "::#{level} file=#{file},line=#{line},title=Older than #{d} days::#{gem[0]} #{gem[3]}"
+ end
+ end
+ abort "::error title=Too long-standing gems::The release comes soon." if december and old.nonzero?
+ shell: ruby {0}
+ env:
+ file: ${{ steps.logs.outputs.file }}
+ days: ${{ steps.logs.outputs.days }}
+
+ - name: Install libraries
+ uses: ./.github/actions/setup/ubuntu
+ if: ${{ steps.diff.outputs.gems }}
- name: Build
run: |
./autogen.sh
./configure -C --disable-install-doc
make
- if: ${{ steps.diff.outcome == 'failure' }}
+ if: ${{ steps.diff.outputs.gems }}
- name: Prepare bundled gems
run: |
make -s prepare-gems
- if: ${{ steps.diff.outcome == 'failure' }}
+ if: ${{ steps.diff.outputs.gems }}
- name: Test bundled gems
run: |
make -s test-bundled-gems
- git add -- gems/bundled_gems
timeout-minutes: 30
env:
- RUBY_TESTOPTS: "-q --tty=no"
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- if: ${{ steps.diff.outcome == 'failure' }}
-
- - name: Show diffs
- id: show
- run: |
- git diff --cached --color --no-ext-diff --ignore-submodules --exit-code --
- continue-on-error: true
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ if: ${{ steps.diff.outputs.gems }}
- - name: Commit
+ - name: Push
run: |
- git pull --ff-only origin ${GITHUB_REF#refs/heads/}
- message="Update bundled gems list at "
- if [ ${{ steps.diff.outcome }} = success ]; then
- git commit --message="${message}${GITHUB_SHA:0:30} [ci skip]"
- else
- git commit --message="${message}${TODAY}"
- fi
git push origin ${GITHUB_REF#refs/heads/}
- env:
- EMAIL: svn-admin@ruby-lang.org
- GIT_AUTHOR_NAME: git
- GIT_COMMITTER_NAME: git
- if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.show.outcome == 'failure' }}
-
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ if: >-
+ ${{
+ github.repository == 'ruby/ruby' &&
+ !startsWith(github.event_name, 'pull') &&
+ steps.commit.outcome == 'success'
+ }}
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / update",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/check_dependencies.yml b/.github/workflows/check_dependencies.yml
index 8d14f5fa1e..ad399b264f 100644
--- a/.github/workflows/check_dependencies.yml
+++ b/.github/workflows/check_dependencies.yml
@@ -3,17 +3,13 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -24,49 +20,42 @@ permissions:
jobs:
update-deps:
+ name: Dependency checks
+
strategy:
matrix:
- os: [ubuntu-20.04]
+ os: [ubuntu-latest]
fail-fast: true
+
runs-on: ${{ matrix.os }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
steps:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}
- - name: Install libraries
- run: |
- brew upgrade
- brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline
+
+ - uses: ./.github/actions/setup/macos
if: ${{ contains(matrix.os, 'macos') }}
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+
+ - uses: ./.github/actions/setup/directories
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
- path: .downloaded-cache
- key: downloaded-cache
- - run: ./autogen.sh
+ ruby-version: '3.1'
+ bundler: none
+
- name: Run configure
run: ./configure -C --disable-install-doc --disable-rubygems --with-gcc 'optflags=-O0' 'debugflags=-save-temps=obj -g'
- - run: make all golf
- - run: ruby tool/update-deps --fix
- - run: git diff --no-ext-diff --ignore-submodules --exit-code
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - run: make fix-depends
+
+ - run: git diff --color --no-ext-diff --ignore-submodules --exit-code
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ matrix.os }} / Dependencies need to update",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.os }} / Dependencies need to update
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml
index a59313fad5..f194d00779 100644
--- a/.github/workflows/check_misc.yml
+++ b/.github/workflows/check_misc.yml
@@ -1,5 +1,5 @@
-name: Miscellaneous checks
-on: [push, pull_request]
+name: Misc
+on: [push, pull_request, merge_group]
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -10,90 +10,142 @@ permissions:
jobs:
checks:
+ name: Miscellaneous checks
+
permissions:
- contents: write # for Git to git push
+ contents: write # for Git to git push
+
runs-on: ubuntu-latest
+
steps:
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- - name: Check if C-sources are US-ASCII
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
+ persist-credentials: false
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: head
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ makeup: true
+ # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN
+ checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)
+
+ - name: Re-generate Makefiles
run: |
- ! grep -r -n '[^ -~]' -- *.[chy] include internal win32/*.[ch]
- - name: Check for trailing spaces
+ # config.status needs to run as a shell script
+ { echo ':&&exit'; cat tool/prereq.status; } > config.status
+ : # same as actions/setup/directories/action.yml
+ for mk in Makefile GNUmakefile; do
+ sed -f tool/prereq.status template/$mk.in > $mk
+ done
+
+ - name: Check for code styles
run: |
- ! git grep -n '[ ]$' -- '*.rb' '*.[chy]' '*.rs'
- ! git grep -n '^[ ][ ]*$' -- '*.md'
+ set -x
+ ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA"
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }}
+ GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }}
+ # Skip 'push' events because post_push.yml fixes them on push
+ if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }}
+
+ - name: Check if date in man pages is up-to-date
+ run: |
+ git fetch origin --depth=1 "${GITHUB_OLD_SHA}"
+ git diff --exit-code --name-only "${GITHUB_OLD_SHA}" HEAD -- man ||
+ make V=1 GIT=git BASERUBY=ruby update-man-date
+ git diff --color --no-ext-diff --ignore-submodules --exit-code -- man
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }}
+ if: ${{ startsWith(github.event_name, 'pull') }}
+
- name: Check for bash specific substitution in configure.ac
run: |
- ! git grep -n '\${[A-Za-z_0-9]*/' -- configure.ac
+ git grep -n '\${[A-Za-z_0-9]*/' -- configure.ac && exit 1 || :
+
- name: Check for header macros
run: |
- ! for header in ruby/*.h; do \
- git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null || echo $header
- done | grep -F .
+ fail=
+ for header in ruby/*.h; do
+ git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null && continue
+ fail=1
+ echo $header
+ done
+ exit $fail
working-directory: include
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: .downloaded-cache
- key: downloaded-cache-${{ github.sha }}
- restore-keys: |
- downloaded-cache
+ - id: now
+ run: |
+ date +"mon=%-m"%n"day=%-d" >> $GITHUB_OUTPUT
+ env:
+ TZ: Asia/Tokyo
- - name: Download previous gems list
+ - id: deprecation
run: |
- data=default_gems.json
- mkdir -p .downloaded-cache
- ln -s .downloaded-cache/$data .
- curl -O -R -z ./$data https://stdgems.org/$data
+ eval $(sed -n 's/^#define RUBY_API_VERSION_\(MAJOR\|MINOR\) /\1=/p' include/ruby/version.h)
+ if git --no-pager grep --color -o 'rb_warn_deprecated_to_remove_at('$MAJOR'\.'$MINOR',.*' -- '*.c' >&2; then
+ false
+ else
+ true
+ fi
+ continue-on-error: ${{ steps.now.outputs.mon < 12 }}
- - name: Make default gems list
+ - name: Check if to generate documents
+ id: rdoc
run: |
- #!ruby
- require 'rubygems'
- $:.unshift "lib"
- rgver = File.foreach("lib/rubygems.rb") do |line|
- break $1 if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line
- end
- gems = Dir.glob("{ext,lib}/**/*.gemspec").map do |f|
- spec = Gem::Specification.load(f)
- "#{spec.name} #{spec.version}"
- end.sort
- File.open("gems/default_gems", "w") do |f|
- f.puts "RubyGems #{rgver}"
- f.puts gems
- end
- shell: ruby --disable=gems {0}
-
- - name: Maintain updated gems list in NEWS
+ set -- $(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems)
+ { echo version=$2; echo ref=$4; } >> $GITHUB_OUTPUT
+
+ - name: Checkout rdoc
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ repository: ruby/rdoc
+ ref: ${{ steps.rdoc.outputs.ref }}
+ path: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
+ persist-credentials: false
+ if: ${{ steps.rdoc.outputs.ref != '' }}
+
+ - name: Generate rdoc scripts
run: |
- ruby tool/update-NEWS-gemlist.rb default
+ set -x
+ gempath=$(ruby -e 'print Gem.user_dir, "/bin"')
+ PATH=$gempath:$PATH
+ gem install --user bundler
+ bundle config --local path vendor/bundle
+ bundle install --jobs 4
+ bundle exec rake generate
+ working-directory: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
+ if: ${{ steps.rdoc.outputs.ref != '' }}
- - name: Check diffs
- id: diff
+ - name: Core docs coverage
run: |
- git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md
- continue-on-error: true
- - name: Commit
+ make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig rdoc-coverage
+
+ - name: Generate docs
+ id: docs
run: |
- git pull --ff-only origin ${GITHUB_REF#refs/heads/}
- git commit --message="Update default gems list at ${GITHUB_SHA:0:30} [ci skip]" NEWS.md
- git push origin ${GITHUB_REF#refs/heads/}
- env:
- EMAIL: svn-admin@ruby-lang.org
- GIT_AUTHOR_NAME: git
- GIT_COMMITTER_NAME: git
- if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.diff.outcome == 'failure' }}
+ make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig HTMLOUT=html html
+ echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT
+ # Generate only when document commit/PR
+ if: >-
+ ${{false
+ || contains(github.event.head_commit.message, '[ruby/rdoc]')
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ - name: Upload docs
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ path: html
+ name: ${{ steps.docs.outputs.htmlout }}
+ if: ${{ steps.docs.outcome == 'success' }}
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/check_sast.yml b/.github/workflows/check_sast.yml
new file mode 100644
index 0000000000..6fd1be6542
--- /dev/null
+++ b/.github/workflows/check_sast.yml
@@ -0,0 +1,133 @@
+name: 'Check SAST tool'
+
+on:
+ push:
+ branches: ['master']
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ schedule:
+ - cron: '0 12 * * *'
+ workflow_dispatch:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
+ zizmor:
+ name: zizmor
+
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: read
+ security-events: write
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - name: Run zizmor
+ uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
+ continue-on-error: true
+
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read # for github/codeql-action/init to get workflow details
+ contents: read # for actions/checkout to fetch code
+ security-events: write # for github/codeql-action/upload-sarif to send a status report
+ # CodeQL fails to run pull requests from dependabot due to missing write access to upload results.
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - language: cpp
+ - language: ruby
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
+ with:
+ languages: ${{ matrix.language }}
+ build-mode: none
+ config-file: .github/codeql/codeql-config.yml
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
+ with:
+ category: '/language:${{ matrix.language }}'
+ upload: False
+ output: sarif-results
+
+ - name: filter-sarif
+ uses: advanced-security/filter-sarif@2da736ff05ef065cb2894ac6892e47b5eac2c3c0 # v1.1
+ with:
+ patterns: |
+ +**/*.rb
+ -lib/uri/mailto.rb:rb/overly-large-range
+ -lib/uri/rfc3986_parser.rb:rb/overly-large-range
+ -lib/bundler/vendor/uri/lib/uri/mailto.rb:rb/overly-large-range
+ -lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb:rb/overly-large-range
+ -spec/ruby/core/regexp/timeout_spec.rb:rb/redos
+ -test/ruby/test_io.rb:rb/non-constant-kernel-open
+ -test/open-uri/test_open-uri.rb:rb/non-constant-kernel-open
+ -test/open-uri/test_ssl.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/binread_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/readlines_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/foreach_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/write_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/read_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/kernel/open_spec.rb:rb/non-constant-kernel-open
+ input: sarif-results/${{ matrix.language }}.sarif
+ output: sarif-results/${{ matrix.language }}.sarif
+ if: ${{ matrix.language == 'ruby' }}
+ continue-on-error: true
+
+ - name: filter-sarif
+ uses: advanced-security/filter-sarif@2da736ff05ef065cb2894ac6892e47b5eac2c3c0 # v1.1
+ with:
+ patterns: |
+ +**/*.c
+ +**/*.h
+ input: sarif-results/${{ matrix.language }}.sarif
+ output: sarif-results/${{ matrix.language }}.sarif
+ if: ${{ matrix.language == 'cpp' }}
+ continue-on-error: true
+
+ - name: Upload SARIF
+ uses: github/codeql-action/upload-sarif@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
+ with:
+ sarif_file: sarif-results/${{ matrix.language }}.sarif
+ continue-on-error: true
diff --git a/.github/workflows/cirrus-notify.yml b/.github/workflows/cirrus-notify.yml
deleted file mode 100644
index 4829a2e2bd..0000000000
--- a/.github/workflows/cirrus-notify.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-on:
- check_suite:
- type: ['completed']
-name: Cirrus CI failure notification
-
-permissions:
- contents: read
-
-jobs:
- cirrus-notify:
- name: After Cirrus CI Failure
- if: >-
- github.event.check_suite.app.name == 'Cirrus CI'
- && github.event.check_suite.conclusion != 'success'
- && github.event.check_suite.conclusion != 'cancelled'
- && github.event.check_suite.conclusion != 'skipped'
- && github.event.check_suite.head_branch == 'master'
- runs-on: ubuntu-latest
- steps:
- - uses: octokit/request-action@89a1754fe82ca777b044ca8e79e9881a42f15a93 # v2.1.7
- id: get_failed_check_run
- with:
- route: GET /repos/${{ github.repository }}/check-suites/${{ github.event.check_suite.id }}/check-runs?status=completed
- mediaType: '{"previews": ["antiope"]}'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Dump GitHub context
- env:
- GITHUB_CONTEXT: ${{ toJson(github) }}
- run: echo "$GITHUB_CONTEXT"
- - name: Dump check_runs
- env:
- CHECK_RUNS: ${{ steps.get_failed_check_run.outputs.data }}
- run: echo "$CHECK_RUNS"
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
- with:
- payload: |
- {
- "ci": "Cirrus CI",
- "env": "Cirrus CI",
- "url": "${{ fromJson(steps.get_failed_check_run.outputs.data).check_runs[0].html_url }}",
- "commit": "${{ github.event.check_suite.head_commit.id }}",
- "branch": "${{ github.event.check_suite.head_branch }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
deleted file mode 100644
index 3f9dc2f5af..0000000000
--- a/.github/workflows/codeql-analysis.yml
+++ /dev/null
@@ -1,110 +0,0 @@
-name: "CodeQL"
-
-on:
- push:
- branches: [ "master" ]
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- schedule:
- - cron: '0 12 * * *'
- workflow_dispatch:
-
-concurrency:
- group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
- cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-
-permissions: # added using https://github.com/step-security/secure-workflows
- contents: read
-
-jobs:
- analyze:
- name: Analyze
- runs-on: ubuntu-latest
- permissions:
- actions: read # for github/codeql-action/init to get workflow details
- contents: read # for actions/checkout to fetch code
- security-events: write # for github/codeql-action/autobuild to send a status report
- # CodeQL fails to run pull requests from dependabot due to missing write access to upload results.
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') && github.event.head_commit.pusher.name != 'dependabot[bot]' }}
-
- env:
- enable_install_doc: no
-
- strategy:
- fail-fast: false
- matrix:
- language: [ 'cpp', 'ruby' ]
-
- steps:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
-
- - name: Checkout repository
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
-
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: .downloaded-cache
- key: downloaded-cache
-
- - name: Remove an obsolete rubygems vendored file
- run: sudo rm /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb
-
- - name: Initialize CodeQL
- uses: github/codeql-action/init@168b99b3c22180941ae7dbdd5f5c9678ede476ba # v2.2.7
- with:
- languages: ${{ matrix.language }}
-
- - name: Set ENV
- run: echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
-
- - name: Autobuild
- uses: github/codeql-action/autobuild@168b99b3c22180941ae7dbdd5f5c9678ede476ba # v2.2.7
-
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@168b99b3c22180941ae7dbdd5f5c9678ede476ba # v2.2.7
- with:
- category: "/language:${{matrix.language}}"
- upload: False
- output: sarif-results
-
- - name: filter-sarif
- uses: advanced-security/filter-sarif@eac3ea6a5e1270952681bf7287598a6cd1a4d49d # v1.0
- with:
- patterns: |
- +**/*.rb
- -lib/uri/mailto.rb:rb/overly-large-range
- -lib/uri/rfc3986_parser.rb:rb/overly-large-range
- -lib/bundler/vendor/uri/lib/uri/mailto.rb:rb/overly-large-range
- -lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb:rb/overly-large-range
- -test/ruby/test_io.rb:rb/non-constant-kernel-open
- -test/open-uri/test_open-uri.rb:rb/non-constant-kernel-open
- -test/open-uri/test_ssl.rb:rb/non-constant-kernel-open
- -spec/ruby/core/io/binread_spec.rb:rb/non-constant-kernel-open
- -spec/ruby/core/io/readlines_spec.rb:rb/non-constant-kernel-open
- -spec/ruby/core/io/foreach_spec.rb:rb/non-constant-kernel-open
- -spec/ruby/core/io/write_spec.rb:rb/non-constant-kernel-open
- -spec/ruby/core/io/read_spec.rb:rb/non-constant-kernel-open
- -spec/ruby/core/kernel/open_spec.rb:rb/non-constant-kernel-open
- input: sarif-results/${{ matrix.language }}.sarif
- output: sarif-results/${{ matrix.language }}.sarif
- if: ${{ matrix.language == 'ruby' }}
-
- - name: Upload SARIF
- uses: github/codeql-action/upload-sarif@168b99b3c22180941ae7dbdd5f5c9678ede476ba # v2.2.7
- with:
- sarif_file: sarif-results/${{ matrix.language }}.sarif
diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml
index 251bac6b39..147470f38a 100644
--- a/.github/workflows/compilers.yml
+++ b/.github/workflows/compilers.yml
@@ -1,279 +1,332 @@
+# Some tests depending on this name 'Compilations' via $GITHUB_WORKFLOW. Make sure to update such tests when renaming this workflow.
name: Compilations
on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
+ - '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-# GitHub actions does not support YAML anchors. This creative use of
-# environment variables (plus the "echo $GITHUB_ENV" hack) is to reroute that
-# restriction.
-env:
- default_cc: clang-15
- append_cc: ''
+permissions:
+ contents: read
- # -O1 is faster than -O3 in our tests... Majority of time are consumed trying
- # to optimize binaries. Also GitHub Actions run on relatively modern CPUs
- # compared to, say, GCC 4 or Clang 3. We don't specify `-march=native`
- # because compilers tend not understand what the CPU is.
- optflags: '-O1'
+# Each job is split so that they roughly take 30min to run through.
+jobs:
+ compile-if:
+ name: 'omnibus compilations, trigger'
+ runs-on: ubuntu-latest
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+ steps:
+ - run: true
+ working-directory:
+
+ compile1:
+ name: 'omnibus compilations, #1'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - name: 'clang 22 LTO'
+ uses: './.github/actions/compilers'
+ with:
+ tag: clang-22
+ with_gcc: 'clang-22 -flto=auto'
+ optflags: '-O2'
+ enable_shared: false
+ timeout-minutes: 30
+ - { uses: './.github/actions/compilers', name: '-O0', with: { optflags: '-O0 -march=x86-64 -mtune=generic' }, timeout-minutes: 5 }
+ # - { uses: './.github/actions/compilers', name: '-O3', with: { optflags: '-O3 -march=x86-64 -mtune=generic', check: true } }
- # -g0 disables backtraces when SEGV. Do not set that.
- debugflags: '-ggdb3'
+ compile2:
+ name: 'omnibus compilations, #2'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
- default_configure: >-
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- append_configure: >-
- --without-valgrind
- --without-jemalloc
- --without-gmp
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - name: 'GCC 15 LTO'
+ uses: './.github/actions/compilers'
+ with:
+ tag: gcc-15
+ with_gcc: 'gcc-15 -flto=auto -ffat-lto-objects -Werror=lto-type-mismatch'
+ optflags: '-O2'
+ enable_shared: false
+ timeout-minutes: 10
+ - { uses: './.github/actions/compilers', name: 'ext/Setup', with: { static_exts: 'etc json/* */escape' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 15', with: { tag: 'gcc-15' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 14', with: { tag: 'gcc-14' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 13', with: { tag: 'gcc-13' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 12', with: { tag: 'gcc-12' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 11', with: { tag: 'gcc-11' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 10', with: { tag: 'gcc-10' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 9', with: { tag: 'gcc-9' }, timeout-minutes: 5 }
- CONFIGURE_TTY: never
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
+ compile3:
+ name: 'omnibus compilations, #3'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
-permissions:
- contents: read
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'clang 20', with: { tag: 'clang-20' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 19', with: { tag: 'clang-19' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 18', with: { tag: 'clang-18' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 17', with: { tag: 'clang-17' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 16', with: { tag: 'clang-16' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 15', with: { tag: 'clang-15' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 14', with: { tag: 'clang-14' }, timeout-minutes: 5 }
-jobs:
- compile:
- strategy:
- fail-fast: false
- matrix:
- env:
- - {}
- entry:
- - { name: gcc-12, env: { default_cc: gcc-12 } }
- - { name: gcc-11, env: { default_cc: gcc-11 } }
- - { name: gcc-10, env: { default_cc: gcc-10 } }
- - { name: gcc-9, env: { default_cc: gcc-9 } }
- - { name: gcc-8, env: { default_cc: gcc-8 } }
- - { name: gcc-7, env: { default_cc: gcc-7 } }
- - { name: gcc-6, env: { default_cc: gcc-6 } }
- - { name: gcc-5, env: { default_cc: gcc-5 } }
- - { name: gcc-4.8, env: { default_cc: gcc-4.8 } }
- - name: 'gcc-11 LTO'
- container: gcc-11
- env:
- default_cc: 'gcc-11 -flto=auto -ffat-lto-objects'
- optflags: '-O2'
- shared: disable
- # check: true
- - { name: clang-16, env: { default_cc: clang-16 } }
- - { name: clang-15, env: { default_cc: clang-15 } }
- - { name: clang-14, env: { default_cc: clang-14 } }
- - { name: clang-13, env: { default_cc: clang-13 } }
- - { name: clang-12, env: { default_cc: clang-12 } }
- - { name: clang-11, env: { default_cc: clang-11 } }
- - { name: clang-10, env: { default_cc: clang-10 } }
- - { name: clang-9, env: { default_cc: clang-9 } }
- - { name: clang-8, env: { default_cc: clang-8 } }
- - { name: clang-7, env: { default_cc: clang-7 } }
- - { name: clang-6.0, env: { default_cc: clang-6.0 } }
- - { name: clang-5.0, env: { default_cc: clang-5.0 } }
- - { name: clang-4.0, env: { default_cc: clang-4.0 } }
- - { name: clang-3.9, env: { default_cc: clang-3.9 } }
- - name: 'clang-14 LTO'
- container: clang-14
- env:
- default_cc: 'clang-14 -flto=auto'
- optflags: '-O2'
- shared: disable
- # check: true
+ compile4:
+ name: 'omnibus compilations, #4'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
-# - { name: aarch64-linux-gnu, crosshost: aarch64-linux-gnu, container: crossbuild-essential-arm64 }
-# - { name: arm-linux-gnueabi, crosshost: arm-linux-gnueabi }
-# - { name: arm-linux-gnueabihf, crosshost: arm-linux-gnueabihf }
-# - { name: i686-w64-mingw32, crosshost: i686-w64-mingw32 }
-# - { name: powerpc-linux-gnu, crosshost: powerpc-linux-gnu }
-# - { name: powerpc64le-linux-gnu, crosshost: powerpc64le-linux-gnu, container: crossbuild-essential-ppc64el }
-# - { name: s390x-linux-gnu, crosshost: s390x-linux-gnu, container: crossbuild-essential-s390x }
-# - { name: x86_64-w64-mingw32, crosshost: x86_64-w64-mingw32, container: mingw-w64 }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'clang 13', with: { tag: 'clang-13' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 12', with: { tag: 'clang-12' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 11', with: { tag: 'clang-11' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 10', with: { tag: 'clang-10' }, timeout-minutes: 5 }
+ # llvm-objcopy<=9 doesn't have --wildcard. It compiles, but leaves Rust symbols in libyjit.o and fail `make test-leaked-globals`.
+ - { uses: './.github/actions/compilers', name: 'clang 9', with: { tag: 'clang-9', append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 8', with: { tag: 'clang-8', append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 7', with: { tag: 'clang-7', append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 6', with: { tag: 'clang-6.0', append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
- # -Wno-strict-prototypes is necessary with current clang-15 since
- # older autoconf generate functions without prototype and -pedantic
- # now implies strict-prototypes. Disabling the error but leaving the
- # warning generates a lot of noise from use of ANYARGS in
- # rb_define_method() and friends.
- # See: https://github.com/llvm/llvm-project/commit/11da1b53d8cd3507959022cd790d5a7ad4573d94
- - { name: c99, env: { append_cc: '-std=c99 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
-# - { name: c11, env: { append_cc: '-std=c11 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
-# - { name: c17, env: { append_cc: '-std=c17 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- - { name: c2x, env: { append_cc: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- - { name: c++98, env: { CXXFLAGS: '-std=c++98 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
-# - { name: c++11, env: { CXXFLAGS: '-std=c++11 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
-# - { name: c++14, env: { CXXFLAGS: '-std=c++14 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
-# - { name: c++17, env: { CXXFLAGS: '-std=c++17 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
- - { name: c++2a, env: { CXXFLAGS: '-std=c++2a -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
+ compile5:
+ name: 'omnibus compilations, #5'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
- - { name: '-O0', env: { optflags: '-O0 -march=x86-64 -mtune=generic' } }
-# - { name: '-O3', env: { optflags: '-O3 -march=x86-64 -mtune=generic' }, check: true }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ # -Wno-strict-prototypes is necessary with current clang-15 since
+ # older autoconf generate functions without prototype and -pedantic
+ # now implies strict-prototypes. Disabling the error but leaving the
+ # warning generates a lot of noise from use of ANYARGS in
+ # rb_define_method() and friends.
+ # See: https://github.com/llvm/llvm-project/commit/11da1b53d8cd3507959022cd790d5a7ad4573d94
+ - { uses: './.github/actions/compilers', name: 'C99', with: { CFLAGS: '-std=c99 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C11', with: { CFLAGS: '-std=c11 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C17', with: { CFLAGS: '-std=c17 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C23', with: { CFLAGS: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++98', with: { CXXFLAGS: '-std=c++98 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++11', with: { CXXFLAGS: '-std=c++11 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++14', with: { CXXFLAGS: '-std=c++14 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++17', with: { CXXFLAGS: '-std=c++17 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
- - { name: gmp, env: { append_configure: '--with-gmp' } }
- - { name: jemalloc, env: { append_configure: '--with-jemalloc' } }
- - { name: valgrind, env: { append_configure: '--with-valgrind' } }
- - { name: 'coroutine=ucontext', env: { append_configure: '--with-coroutine=ucontext' } }
- - { name: 'coroutine=pthread', env: { append_configure: '--with-coroutine=pthread' } }
- - { name: disable-jit-support, env: { append_configure: '--disable-jit-support' } }
- - { name: disable-dln, env: { append_configure: '--disable-dln' } }
- - { name: enable-mkmf-verbose, env: { append_configure: '--enable-mkmf-verbose' } }
- - { name: disable-rubygems, env: { append_configure: '--disable-rubygems' } }
- - { name: RUBY_DEVEL, env: { append_configure: '--enable-devel' } }
+ compile6:
+ name: 'omnibus compilations, #6'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
- - { name: OPT_THREADED_CODE=1, env: { cppflags: '-DOPT_THREADED_CODE=1' } }
- - { name: OPT_THREADED_CODE=2, env: { cppflags: '-DOPT_THREADED_CODE=2' } }
- - { name: OPT_THREADED_CODE=3, env: { cppflags: '-DOPT_THREADED_CODE=3' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'C++20', with: { CXXFLAGS: '-std=c++20 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++23', with: { CXXFLAGS: '-std=c++23 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'C++26', with: { CXXFLAGS: '-std=c++26 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'gmp', with: { append_configure: '--with-gmp', test_all: 'ruby/test_bignum.rb', test_spec: "/github/workspace/src/spec/ruby/core/integer" }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'jemalloc', with: { append_configure: '--with-jemalloc' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'valgrind', with: { append_configure: '--with-valgrind' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'coroutine=ucontext', with: { append_configure: '--with-coroutine=ucontext' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'coroutine=pthread', with: { append_configure: '--with-coroutine=pthread' }, timeout-minutes: 5 }
- - { name: NDEBUG, env: { cppflags: '-DNDEBUG' } }
- - { name: RUBY_DEBUG, env: { cppflags: '-DRUBY_DEBUG' } }
-# - { name: ARRAY_DEBUG, env: { cppflags: '-DARRAY_DEBUG' } }
-# - { name: BIGNUM_DEBUG, env: { cppflags: '-DBIGNUM_DEBUG' } }
-# - { name: CCAN_LIST_DEBUG, env: { cppflags: '-DCCAN_LIST_DEBUG' } }
-# - { name: CPDEBUG=-1, env: { cppflags: '-DCPDEBUG=-1' } }
-# - { name: ENC_DEBUG, env: { cppflags: '-DENC_DEBUG' } }
-# - { name: GC_DEBUG, env: { cppflags: '-DGC_DEBUG' } }
-# - { name: HASH_DEBUG, env: { cppflags: '-DHASH_DEBUG' } }
-# - { name: ID_TABLE_DEBUG, env: { cppflags: '-DID_TABLE_DEBUG' } }
-# - { name: RGENGC_DEBUG=-1, env: { cppflags: '-DRGENGC_DEBUG=-1' } }
-# - { name: SYMBOL_DEBUG, env: { cppflags: '-DSYMBOL_DEBUG' } }
+ compile7:
+ name: 'omnibus compilations, #7'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
-# - { name: RGENGC_CHECK_MODE, env: { cppflags: '-DRGENGC_CHECK_MODE' } }
-# - { name: TRANSIENT_HEAP_CHECK_MODE, env: { cppflags: '-DTRANSIENT_HEAP_CHECK_MODE' } }
-# - { name: VM_CHECK_MODE, env: { cppflags: '-DVM_CHECK_MODE' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'disable-jit', with: { append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'disable-yjit', with: { append_configure: '--disable-yjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'disable-zjit', with: { append_configure: '--disable-zjit' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'disable-dln', with: { append_configure: '--disable-dln' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'enable-mkmf-verbose', with: { append_configure: '--enable-mkmf-verbose' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'disable-rubygems', with: { append_configure: '--disable-rubygems' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RUBY_DEVEL', with: { append_configure: '--enable-devel' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'OPT_THREADED_CODE=0', with: { cppflags: '-DOPT_THREADED_CODE=0' }, timeout-minutes: 5 }
- - { name: USE_EMBED_CI=0, env: { cppflags: '-DUSE_EMBED_CI=0' } }
- - { name: USE_FLONUM=0, env: { cppflags: '-DUSE_FLONUM=0' } }
-# - { name: USE_GC_MALLOC_OBJ_INFO_DETAILS, env: { cppflags: '-DUSE_GC_MALLOC_OBJ_INFO_DETAILS' } }
- - { name: USE_LAZY_LOAD, env: { cppflags: '-DUSE_LAZY_LOAD' } }
-# - { name: USE_SYMBOL_GC=0, env: { cppflags: '-DUSE_SYMBOL_GC=0' } }
-# - { name: USE_THREAD_CACHE=0, env: { cppflags: '-DUSE_THREAD_CACHE=0' } }
-# - { name: USE_TRANSIENT_HEAP=0, env: { cppflags: '-DUSE_TRANSIENT_HEAP=0' } }
-# - { name: USE_RUBY_DEBUG_LOG=1, env: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' } }
- - { name: USE_RVARGC=0, env: { cppflags: '-DUSE_RVARGC=0' } }
-# - { name: USE_RVARGC=1, env: { cppflags: '-DUSE_RVARGC=1' } }
-# - { name: USE_DEBUG_COUNTER, env: { cppflags: '-DUSE_DEBUG_COUNTER=1', RUBY_DEBUG_COUNTER_DISABLE: '1' } }
+ compile8:
+ name: 'omnibus compilations, #8'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
- - { name: DEBUG_FIND_TIME_NUMGUESS, env: { cppflags: '-DDEBUG_FIND_TIME_NUMGUESS' } }
- - { name: DEBUG_INTEGER_PACK, env: { cppflags: '-DDEBUG_INTEGER_PACK' } }
-# - { name: ENABLE_PATH_CHECK, env: { cppflags: '-DENABLE_PATH_CHECK' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'NDEBUG', with: { cppflags: '-DNDEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RUBY_DEBUG', with: { cppflags: '-DRUBY_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'ARRAY_DEBUG', with: { cppflags: '-DARRAY_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'CCAN_LIST_DEBUG', with: { cppflags: '-DCCAN_LIST_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'CPDEBUG=-1', with: { cppflags: '-DCPDEBUG=-1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'ENC_DEBUG', with: { cppflags: '-DENC_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GC_DEBUG', with: { cppflags: '-DGC_DEBUG' }, timeout-minutes: 5 }
- - { name: GC_DEBUG_STRESS_TO_CLASS, env: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
-# - { name: GC_ENABLE_LAZY_SWEEP=0, env: { cppflags: '-DGC_ENABLE_LAZY_SWEEP=0' } }
-# - { name: GC_PROFILE_DETAIL_MEMOTY, env: { cppflags: '-DGC_PROFILE_DETAIL_MEMOTY' } }
-# - { name: GC_PROFILE_MORE_DETAIL, env: { cppflags: '-DGC_PROFILE_MORE_DETAIL' } }
+ compile9:
+ name: 'omnibus compilations, #9'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
-# - { name: CALC_EXACT_MALLOC_SIZE, env: { cppflags: '-DCALC_EXACT_MALLOC_SIZE' } }
-# - { name: MALLOC_ALLOCATED_SIZE_CHECK, env: { cppflags: '-DMALLOC_ALLOCATED_SIZE_CHECK' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'HASH_DEBUG', with: { cppflags: '-DHASH_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'ID_TABLE_DEBUG', with: { cppflags: '-DID_TABLE_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RGENGC_DEBUG=-1', with: { cppflags: '-DRGENGC_DEBUG=-1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'SYMBOL_DEBUG', with: { cppflags: '-DSYMBOL_DEBUG' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RGENGC_CHECK_MODE', with: { cppflags: '-DRGENGC_CHECK_MODE' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'VM_CHECK_MODE', with: { cppflags: '-DVM_CHECK_MODE' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'USE_EMBED_CI=0', with: { cppflags: '-DUSE_EMBED_CI=0' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'USE_FLONUM=0', with: { cppflags: '-DUSE_FLONUM=0', append_configure: '--disable-yjit --disable-zjit' }, timeout-minutes: 5 }
-# - { name: IBF_ISEQ_ENABLE_LOCAL_BUFFER, env: { cppflags: '-DIBF_ISEQ_ENABLE_LOCAL_BUFFER' } }
+ compileX:
+ name: 'omnibus compilations, #10'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
-# - { name: RGENGC_ESTIMATE_OLDMALLOC, env: { cppflags: '-DRGENGC_ESTIMATE_OLDMALLOC' } }
-# - { name: RGENGC_FORCE_MAJOR_GC, env: { cppflags: '-DRGENGC_FORCE_MAJOR_GC' } }
-# - { name: RGENGC_OBJ_INFO, env: { cppflags: '-DRGENGC_OBJ_INFO' } }
-# - { name: RGENGC_OLD_NEWOBJ_CHECK, env: { cppflags: '-DRGENGC_OLD_NEWOBJ_CHECK' } }
-# - { name: RGENGC_PROFILE, env: { cppflags: '-DRGENGC_PROFILE' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'USE_LAZY_LOAD', with: { cppflags: '-DUSE_LAZY_LOAD' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'USE_RUBY_DEBUG_LOG=1', with: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'USE_DEBUG_COUNTER', with: { cppflags: '-DUSE_DEBUG_COUNTER=1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'SHARABLE_MIDDLE_SUBSTRING', with: { cppflags: '-DSHARABLE_MIDDLE_SUBSTRING=1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'DEBUG_FIND_TIME_NUMGUESS', with: { cppflags: '-DDEBUG_FIND_TIME_NUMGUESS' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'DEBUG_INTEGER_PACK', with: { cppflags: '-DDEBUG_INTEGER_PACK' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'OPT_THREADED_CODE=1', with: { cppflags: '-DOPT_THREADED_CODE=1' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'OPT_THREADED_CODE=2', with: { cppflags: '-DOPT_THREADED_CODE=2' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 21', with: { tag: 'clang-21' }, timeout-minutes: 5 }
-# - { name: VM_DEBUG_BP_CHECK, env: { cppflags: '-DVM_DEBUG_BP_CHECK' } }
-# - { name: VM_DEBUG_VERIFY_METHOD_CACHE, env: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' } }
+ compileB:
+ name: 'omnibus compilations, #11'
+ runs-on: ubuntu-latest
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
- - { name: enable-yjit, env: { append_configure: '--enable-yjit --disable-rjit' }, rust: true }
- - { name: enable-rjit, env: { append_configure: '--enable-rjit --disable-yjit' } }
- - { name: YJIT_FORCE_ENABLE, env: { cppflags: '-DYJIT_FORCE_ENABLE' }, rust: true }
-# - { name: RJIT_FORCE_ENABLE, env: { cppflags: '-DRJIT_FORCE_ENABLE' } }
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'GC_DEBUG_STRESS_TO_CLASS', with: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GC_ENABLE_LAZY_SWEEP=0', with: { cppflags: '-DGC_ENABLE_LAZY_SWEEP=0' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GC_PROFILE_DETAIL_MEMORY', with: { cppflags: '-DGC_PROFILE_DETAIL_MEMORY' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GC_PROFILE_MORE_DETAIL', with: { cppflags: '-DGC_PROFILE_MORE_DETAIL' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'MALLOC_ALLOCATED_SIZE_CHECK', with: { cppflags: '-DMALLOC_ALLOCATED_SIZE_CHECK' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RGENGC_ESTIMATE_OLDMALLOC', with: { cppflags: '-DRGENGC_ESTIMATE_OLDMALLOC' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'RGENGC_PROFILE', with: { cppflags: '-DRGENGC_PROFILE' }, timeout-minutes: 5 }
- name: ${{ matrix.entry.name }}
+ compileC:
+ name: 'omnibus compilations, #12'
runs-on: ubuntu-latest
- container:
- image: ghcr.io/ruby/ruby-ci-image:${{ matrix.entry.container || matrix.entry.env.default_cc || 'clang-15' }}
- options: --user root
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- env: ${{ matrix.entry.env || matrix.env }}
+ needs: compile-if
+ if: ${{ needs.compile-if.result == 'success' }}
+ timeout-minutes: 60
+
steps:
- - run: id
- working-directory:
- - run: mkdir build
- working-directory:
- - name: setenv
- run: |
- echo "GNUMAKEFLAGS=-sj$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Install Rust
- if: ${{ matrix.entry.rust }}
- run: sudo apt-get update && sudo apt install -y rustc
- - name: autogen
- run: |
- if [ ! -f ./autogen.sh ]; then
- ls -la
- fi
- ./autogen.sh
- working-directory: src
- - name: Run configure
- run: >
- ../src/configure -C ${default_configure} ${append_configure}
- --${{
- matrix.entry.crosshost && 'host' || 'with-gcc'
- }}=${{
- matrix.entry.crosshost || '"${default_cc}${append_cc:+ $append_cc}"'
- }}
- --${{ matrix.entry.shared || 'enable' }}-shared
- - run: make extract-extlibs
- - run: make incs
- - run: make showflags
- - run: make
- - run: make leaked-globals
- - run: make test
- - run: make install
- if: ${{ matrix.entry.check }}
- - run: make test-tool
- if: ${{ matrix.entry.check }}
- - run: make test-all TESTS='-- ruby -ext-'
- if: ${{ matrix.entry.check }}
- - run: make test-spec
- env:
- CHECK_LEAKS: true
- if: ${{ matrix.entry.check }}
- - run: make test-annocheck
- if: ${{ matrix.entry.check && endsWith(matrix.entry.name, 'annocheck') }}
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
+ - { uses: './.github/actions/compilers', name: 'VM_DEBUG_BP_CHECK', with: { cppflags: '-DVM_DEBUG_BP_CHECK' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'VM_DEBUG_VERIFY_METHOD_CACHE', with: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'YJIT_FORCE_ENABLE', with: { cppflags: '-DYJIT_FORCE_ENABLE' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'UNIVERSAL_PARSER', with: { cppflags: '-DUNIVERSAL_PARSER' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 23', with: { tag: 'clang-23' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'clang 22', with: { tag: 'clang-22' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 8', with: { tag: 'gcc-8' }, timeout-minutes: 5 }
+ - { uses: './.github/actions/compilers', name: 'GCC 7', with: { tag: 'gcc-7' }, timeout-minutes: 5 }
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ compilemax:
+ name: 'omnibus compilations, result'
+ runs-on: ubuntu-latest
+ if: ${{ always() }}
+ needs:
+ - 'compile1'
+ - 'compile2'
+ - 'compile3'
+ - 'compile4'
+ - 'compile5'
+ - 'compile6'
+ - 'compile7'
+ - 'compile8'
+ - 'compile9'
+ - 'compileX'
+ - 'compileB'
+ - 'compileC'
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github, persist-credentials: false }
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.entry.name }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: 'omnibus'
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
+ - run: false
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/crosscompile.yml b/.github/workflows/crosscompile.yml
new file mode 100644
index 0000000000..4c28516e25
--- /dev/null
+++ b/.github/workflows/crosscompile.yml
@@ -0,0 +1,123 @@
+name: Cross compile
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ name: make (${{ matrix.host }} host on ${{ matrix.build }})
+ strategy:
+ matrix:
+ include:
+ - host: aarch64-linux-gnu
+ arch: arm64
+ build: x86_64-linux-gnu
+ runs-on: ubuntu-24.04
+ file_arch: ARM aarch64
+ - host: x86_64-linux-gnu
+ arch: amd64
+ build: aarch64-linux-gnu
+ runs-on: ubuntu-24.04-arm
+ file_arch: x86-64
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
+ runs-on: ${{ matrix.runs-on }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Setup cross-compilation toolchain sources
+ run: |
+ native_arch=$(dpkg --print-architecture)
+ # Restrict existing sources to native arch
+ sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources
+ sudo sed -i "/^Types:/a Architectures: ${native_arch}" /etc/apt/sources.list.d/ubuntu.sources
+ # Add cross-arch sources
+ if [ "${{ matrix.arch }}" = "arm64" ]; then
+ cross_uri="http://ports.ubuntu.com/"
+ else
+ cross_uri="http://archive.ubuntu.com/ubuntu/"
+ fi
+ printf '%s\n' \
+ "Types: deb" \
+ "URIs: ${cross_uri}" \
+ "Suites: noble noble-updates noble-security" \
+ "Components: main universe" \
+ "Architectures: ${{ matrix.arch }}" \
+ | sudo tee /etc/apt/sources.list.d/cross-${{ matrix.arch }}.sources
+
+ - uses: ./.github/actions/setup/ubuntu
+ with:
+ arch: ${{ matrix.arch }}
+
+ - uses: ./.github/actions/setup/baseruby
+ id: baseruby
+ with:
+ srcdir: src
+
+ - name: Run configure
+ run: >-
+ ../src/configure -C --disable-install-doc
+ --prefix=/usr
+ --build=${{ matrix.build }}
+ --host=${{ matrix.host }}
+ --with-baseruby="$baseruby"
+ env:
+ baseruby: ${{ steps.baseruby.outputs.ruby }}
+
+ - run: make
+
+ - run: make install DESTDIR=$PWD/install
+
+ - name: Verify cross-compiled binary
+ run: |
+ file install/usr/bin/ruby
+ file install/usr/bin/ruby | grep -q '${{ matrix.file_arch }}'
+
+ - uses: ./.github/actions/slack
+ with:
+ label: cross ${{ matrix.host }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml
new file mode 100644
index 0000000000..5ab86c7b19
--- /dev/null
+++ b/.github/workflows/cygwin.yml
@@ -0,0 +1,75 @@
+name: Cygwin
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ runs-on: windows-2022
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - run: git config --global core.autocrlf input
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - name: Setup Cygwin
+ uses: cygwin/cygwin-install-action@711d29f3da23c9f4a1798e369a6f01198c13b11a # v6.1
+ with:
+ packages: ruby gcc-core make autoconf libtool libssl-devel libyaml-devel libffi-devel zlib-devel rubygems
+ site: |
+ https://cygwin.osuosl.org/
+
+ - name: configure
+ run: |
+ ./autogen.sh
+ ./configure --disable-install-doc
+ shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o igncr -o pipefail {0}
+
+ - name: Extract bundled gems
+ run: |
+ make ruby -j5
+ make extract-gems
+ shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o igncr -o pipefail {0}
+
+ - name: make all
+ timeout-minutes: 30
+ run: make -j4 V=1
+ shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o igncr -o pipefail {0}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: Cygwin
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
diff --git a/.github/workflows/default_gems_list.yml b/.github/workflows/default_gems_list.yml
new file mode 100644
index 0000000000..f52b83103c
--- /dev/null
+++ b/.github/workflows/default_gems_list.yml
@@ -0,0 +1,99 @@
+name: Update default gems list
+on: [push, pull_request, merge_group]
+
+env:
+ UPDATE_NEWS_ENABLED: true
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ update_default_gems_list:
+ name: Update default gems list
+
+ permissions:
+ contents: write # for Git to git push
+
+ runs-on: ubuntu-latest
+
+ if: ${{ github.repository == 'ruby/ruby' }}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
+ with:
+ token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
+
+ - id: gems
+ run: true
+ if: ${{ github.ref == 'refs/heads/master' }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ makeup: true
+ # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN
+ checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)
+ if: ${{ steps.gems.outcome == 'success' }}
+
+ - name: Download previous gems list
+ run: |
+ data=default_gems.json
+ mkdir -p .downloaded-cache
+ ln -s .downloaded-cache/$data .
+ curl --retry 5 --retry-connrefused --retry-delay 2 --retry-max-time 60 -O -R -z ./$data https://stdgems.org/$data
+ if: ${{ steps.gems.outcome == 'success' }}
+
+ - name: Make default gems list
+ run: |
+ #!ruby
+ require 'rubygems'
+ $:.unshift "lib"
+ rgver = File.foreach("lib/rubygems.rb") do |line|
+ break $1 if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line
+ end
+ gems = Dir.glob("{ext,lib}/**/*.gemspec").map do |f|
+ spec = Gem::Specification.load(f)
+ "#{spec.name} #{spec.version}"
+ end.sort
+ File.open("gems/default_gems", "w") do |f|
+ f.puts "RubyGems #{rgver}"
+ f.puts gems
+ end
+ shell: ruby --disable=gems {0}
+ if: ${{ steps.gems.outcome == 'success' }}
+
+ - name: Maintain updated gems list in NEWS
+ run: |
+ ruby tool/update-NEWS-gemlist.rb default
+ if: ${{ steps.gems.outcome == 'success' && env.UPDATE_NEWS_ENABLED == 'true' }}
+
+ - name: Check diffs
+ id: diff
+ run: |
+ git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md ||
+ echo update=true >> $GITHUB_OUTPUT
+ if: ${{ steps.gems.outcome == 'success' }}
+
+ - name: Commit
+ run: |
+ git pull --ff-only origin ${GITHUB_REF#refs/heads/}
+ git commit --message="Update default gems list at ${GITHUB_SHA:0:30} [ci skip]" NEWS.md
+ git push origin ${GITHUB_REF#refs/heads/}
+ env:
+ EMAIL: svn-admin@ruby-lang.org
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+ if: >-
+ ${{
+ github.repository == 'ruby/ruby' &&
+ !startsWith(github.event_name, 'pull') &&
+ steps.diff.outputs.update
+ }}
+
+ - uses: ./.github/actions/slack
+ with:
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
diff --git a/.github/workflows/dependabot_automerge.yml b/.github/workflows/dependabot_automerge.yml
index 4754b3c9fe..2e4dc8d7a2 100644
--- a/.github/workflows/dependabot_automerge.yml
+++ b/.github/workflows/dependabot_automerge.yml
@@ -1,26 +1,32 @@
# from https://github.com/gofiber/swagger/blob/main/.github/workflows/dependabot_automerge.yml
name: Dependabot auto-merge
on:
- pull_request_target:
+ pull_request:
+
+permissions:
+ contents: write
+ pull-requests: write
jobs:
automerge:
runs-on: ubuntu-latest
- if: ${{ github.actor == 'dependabot[bot]' }}
+ if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ruby/ruby'
steps:
- name: Dependabot metadata
- uses: dependabot/fetch-metadata@4de7a6c08ce727a42e0adbbdc345f761a01240ce # v1.3.6
+ uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
id: metadata
+
- name: Wait for status checks
- uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 # v1.3.1
+ uses: lewagon/wait-on-check-action@9312864dfbc9fd208e9c0417843430751c042800 # v1.7.0
with:
- repo-token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'make \(check, .*\)'
wait-interval: 30
+
- name: Auto-merge for Dependabot PRs
- if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
+ if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
run: gh pr merge --auto --rebase "$PR_URL"
env:
- PR_URL: ${{github.event.pull_request.html_url}}
- GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
+ PR_URL: ${{ github.event.pull_request.html_url }}
+ GITHUB_TOKEN: ${{ secrets.MATZBOT_DEPENDABOT_MERGE_TOKEN }}
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
new file mode 100644
index 0000000000..d0a8024b05
--- /dev/null
+++ b/.github/workflows/labeler.yml
@@ -0,0 +1,15 @@
+name: "Pull Request Labeler"
+on:
+- pull_request_target
+
+permissions:
+ contents: read
+
+jobs:
+ labeler:
+ permissions:
+ contents: read
+ pull-requests: write
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/labeler@f27b608878404679385c85cfa523b85ccb86e213 # v6.1.0
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index aa162565bd..501d35698b 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -3,17 +3,15 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -26,84 +24,167 @@ jobs:
make:
strategy:
matrix:
- test_task: ["check"] # "test-bundler-parallel", "test-bundled-gems"
- os:
- - macos-11
- - macos-12
+ include:
+ - test_task: check
+ os: macos-26
+ - test_task: check
+ os: macos-15
+ configure_args: '--with-gcc=gcc-14'
+ - test_task: check
+ os: macos-26
+ configure_args: '--with-jemalloc --with-opt-dir=$(brew --prefix jemalloc)'
+ - test_task: check
+ os: macos-26
+ configure_args: '--with-gmp'
+ - test_task: test-all
+ test_opts: --repeat-count=2
+ os: macos-26
+ - test_task: test-bundler-parallel
+ os: macos-26
+ - test_task: test-bundled-gems
+ os: macos-26
+ - test_task: check
+ os: macos-15
+ - test_task: check
+ os: macos-15-intel
+ - test_task: check
+ os: macos-14
fail-fast: false
+
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
runs-on: ${{ matrix.os }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- path: src/.downloaded-cache
- key: downloaded-cache
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
- name: Install libraries
+ uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ clean: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 0 so that Launchable can receive commits information.
+ fetch-depth: 10
+
+ - name: make sure that kern.coredump=1
run: |
- brew upgrade
- brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline bison
- working-directory: src
- - name: Set ENV
+ sysctl -n kern.coredump
+ sudo sysctl -w kern.coredump=1
+ sudo chmod -R +rwx /cores/
+
+ - name: Delete unused SDKs
+ # To free up disk space to not run out during the run
run: |
- echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
- echo "PATH="/usr/local/opt/bison/bin:$PATH"" >> $GITHUB_ENV
- for lib in openssl@1.1 readline; do
- CONFIGURE_ARGS="${CONFIGURE_ARGS:+$CONFIGURE_ARGS }--with-${lib%@*}-dir=$(brew --prefix $lib)"
- done
- echo CONFIGURE_ARGS="${CONFIGURE_ARGS}" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
+ sudo rm -rf ~/.dotnet
+ sudo rm -rf /Library/Android
+ sudo rm -rf /Library/Developer/CoreSimulator
+ continue-on-error: true
+
- name: Run configure
- run: ../src/configure -C --disable-install-doc
- - run: make incs
+ run: ../src/configure -C --disable-install-doc ${ruby_configure_args} ${{ matrix.configure_args }}
+
- run: make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
- run: make
- - run: make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
+
+ - run: make hello
+
+ - name: runirb
+ run: |
+ echo IRB::VERSION | make runirb RUNOPT="-- -f"
+
+ - name: Set test options for skipped tests
+ run: |
+ set -x
+ TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
+ echo "TESTS=${TESTS}" >> $GITHUB_ENV
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: ${{ matrix.os }}
+ test-opts: ${{ matrix.test_opts }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ continue-on-error: true
+ timeout-minutes: 3
+
+ - name: Set extra test options
+ run: |
+ echo "TESTS=$TESTS ${{ matrix.test_opts }}" >> $GITHUB_ENV
+ echo "RUBY_TEST_TIMEOUT_SCALE=10" >> $GITHUB_ENV # With --repeat-count=2, flaky test by timeout occurs frequently for some reason
+ if: matrix.test_opts
+
- name: make ${{ matrix.test_task }}
run: |
- make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
- timeout-minutes: 40
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ ulimit -c unlimited
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
+ timeout-minutes: 90
env:
- RUBY_TESTOPTS: "-q --tty=no"
- TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+
- name: make skipped tests
run: |
- make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
+ make -s test-all TESTS="${TESTS//-n!\//-n/}"
env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
- TESTS: ${{ matrix.skipped_tests }}
- PRECHECK_BUNDLED_GEMS: "no"
- if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ PRECHECK_BUNDLED_GEMS: 'no'
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - name: CAPI extensions
+ uses: ./.github/actions/capiext
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ matrix.os }} / ${{ matrix.test_task }}${{ matrix.configure }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
+ builddir: build
env:
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ contains(matrix.extra_checks, 'capi') }}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.os }} / ${{ matrix.test_task }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml
index 768ea389b7..1efae8be59 100644
--- a/.github/workflows/mingw.yml
+++ b/.github/workflows/mingw.yml
@@ -3,17 +3,20 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -27,148 +30,217 @@ permissions:
#
jobs:
make:
- runs-on: windows-2022
+ runs-on: windows-${{ matrix.os }}
+
name: ${{ github.workflow }} (${{ matrix.msystem }})
+
env:
MSYSTEM: ${{ matrix.msystem }}
- MSYS2_ARCH: x86_64
- CHOST: "x86_64-w64-mingw32"
- CFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe"
- CXXFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe"
- CPPFLAGS: "-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048"
- LDFLAGS: "-pipe"
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ MSYS2_ARCH: >-
+ ${{ case(
+ contains(matrix.msystem, 'arm64'), 'aarch64',
+ contains(matrix.msystem, '64'), 'x86_64',
+ 'i686'
+ ) }}
+ MINGW_PACKAGE_PREFIX: >-
+ mingw-w${{
+ case(endsWith(matrix.msystem, '64'), '64', '32')
+ }}-${{ case(
+ startsWith(matrix.msystem, 'clang'), 'clang',
+ startsWith(matrix.msystem, 'ucrt'), 'ucrt',
+ 'mingw'
+ ) }}-${{ case(
+ contains(matrix.msystem, 'arm64'), 'aarch64',
+ endsWith(matrix.msystem, '64'), 'x86_64',
+ 'i686'
+ ) }}
+ CFLAGS: '-mtune=generic -O3 -pipe'
+ CXXFLAGS: '-mtune=generic -O3 -pipe'
+ CPPFLAGS: '-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048'
+ LDFLAGS: '-pipe'
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
strategy:
matrix:
include:
# To mitigate flakiness of MinGW CI, we test only one runtime that newer MSYS2 uses.
- - msystem: "UCRT64"
- base_ruby: head
- test_task: "check"
- test-all-opts: "--name=!/TestObjSpace#test_reachable_objects_during_iteration/"
+ # Ruby 3.2 is the first Windows Ruby to use OpenSSL 3.x
+ - msystem: 'UCRT64'
+ os: 2022
+ test_task: 'check'
+ test-all-opts: '--name=!/TestObjSpace#test_reachable_objects_during_iteration/'
+ - msystem: 'CLANGARM64'
+ os: 11-arm
+ test_task: 'check'
fail-fast: false
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/vcpkg'))
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ - uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2.31.1
+ id: msys2
with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Set up Ruby & MSYS2
- uses: ruby/setup-ruby@e6689b4deb1cb2062ea45315001f687c0b52111b # v1.144.1
- with:
- ruby-version: ${{ matrix.base_ruby }}
- - name: set env
+ msystem: ${{ matrix.msystem }}
+ update: true
+ install: >-
+ git
+ make
+ ruby
+ autoconf
+ ${{ env.MINGW_PACKAGE_PREFIX }}-gcc
+ ${{ env.MINGW_PACKAGE_PREFIX }}-ragel
+ ${{ env.MINGW_PACKAGE_PREFIX }}-openssl
+ ${{ env.MINGW_PACKAGE_PREFIX }}-libyaml
+ ${{ env.MINGW_PACKAGE_PREFIX }}-libffi
+
+ - name: Set up env
+ id: setup-env
+ working-directory:
run: |
- echo "GNUMAKEFLAGS=-j$((2 * NUMBER_OF_PROCESSORS))" >> $GITHUB_ENV
+ $msys2 = ${env:MSYS2_LOCATION}
+ $msystem = ${env:MSYSTEM}.ToLower()
+ echo $msys2\usr\bin $msys2\$msystem\bin |
+ Tee-Object ${env:GITHUB_PATH} -Append -Encoding utf-8
+
+ # Use the fast device for the temporary directory.
+ # %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
+ # https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
+ $tmp = ${env:RUNNER_TEMP}
+ echo HOME=$home TMP=$tmp TEMP=$tmp TMPDIR=$tmp |
+ Tee-Object ${env:GITHUB_ENV} -Append -Encoding utf-8
+ shell: pwsh # cmd.exe does not strip spaces before `|`.
+ env:
+ MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
+ MSYSTEM: ${{ matrix.msystem }}
- - name: where check
- run: |
- # show where
- mv /c/Windows/System32/libcrypto-1_1-x64.dll /c/Windows/System32/libcrypto-1_1-x64.dll_
- mv /c/Windows/System32/libssl-1_1-x64.dll /c/Windows/System32/libssl-1_1-x64.dll_
- result=true
- for e in gcc.exe ragel.exe make.exe bison.exe libcrypto-1_1-x64.dll libssl-1_1-x64.dll; do
- echo '##['group']'$'\033[93m'$e$'\033[m'
- where $e || result=false
- echo '##['endgroup']'
- done
- $result
-
- - name: version check
+ - name: Remove Strawberry Perl pkg-config
+ working-directory:
+ # `pkg-config.bat` included in Strawberry Perl is written in
+ # Perl and doesn't work when another msys2 `perl` precede its
+ # own `perl`.
+ #
+ # ```
+ # Can't find C:\Strawberry\perl\bin\pkg-config.bat on PATH, '.' not in PATH.
+ # ```
run: |
- # show version
- result=true
- for e in gcc ragel make bison "openssl version"; do
- case "$e" in *" "*) ;; *) e="$e --version";; esac
- echo '##['group']'$'\033[93m'$e$'\033[m'
- $e || result=false
- echo '##['endgroup']'
- done
- $result
-
- - name: autogen
+ Get-Command pkg-config.bat | % { ren $_.path ($_.path + "~") }
+ shell: pwsh
+
+ - name: Misc system & package info
+ working-directory:
run: |
- ./autogen.sh
- working-directory: src
+ group() { echo ::group::$'\e[94;1m'"$*"$'\e[m'; }
+ endgroup() { echo ::endgroup::; }
+
+ group Path
+ cygpath -wa / . $(type -p cygpath bash sh)
+ endgroup
+
+ I() {
+ group $1
+ run Where type -pa $1 && { [ $# -eq 1 ] || run Version "$@"; } ||
+ failed+=($1)
+ endgroup
+ }
+ run() { local w m=$1; shift; w="$("$@")" && show "$m" && indent "$w"; }
+ indent() { [ -z "$1" ] || echo "$1" | /bin/sed '/^$/!s/^/ /'; }
+ show() { echo $'\e[96m'"$*"$'\e[m'; }
+
+ failed=()
+
+ I gcc.exe --version
+ I ragel.exe --version
+ I make.exe --version
+ I openssl.exe version
+ I libcrypto-3-x64.dll
+ I libssl-3-x64.dll
+
+ group Packages
+ pacman -Qs $MINGW_PACKAGE_PREFIX-* | /bin/sed -n "s,local/$MINGW_PACKAGE_PREFIX-,,p"
+ endgroup
+
+ [ ${#failed[@]} -eq 0 ]
+ shell: sh
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
- name: configure
run: >
../src/configure --disable-install-doc --prefix=/.
--build=$CHOST --host=$CHOST --target=$CHOST
-
- - name: update
- run: |
- make incs
-
- - name: download gems
- run: |
- make update-gems
+ shell: sh
+ env:
+ CHOST: ${{ env.MSYS2_ARCH }}-w64-mingw32
- name: make all
timeout-minutes: 30
- run: |
- make
-
- - run: make leaked-globals
+ run: make -j4
- name: make install
- run: |
- make DESTDIR=../install install-nodoc
+ run: make DESTDIR=../install install-nodoc
+
+ - name: Set up Launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: windows-2022
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ test-tasks: '["test", "test-all", "test-spec"]'
+ continue-on-error: true
+ timeout-minutes: 3
- name: test
timeout-minutes: 30
- run: |
- make test
+ run: make test test-tool
env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test'}}
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test' }}
- name: test-all
timeout-minutes: 45
run: |
- # Actions uses UTF8, causes test failures, similar to normal OS setup
- chcp.com 437
make ${{ StartsWith(matrix.test_task, 'test/') && matrix.test_task || 'test-all' }}
env:
RUBY_TESTOPTS: >-
- --retry --job-status=normal --show-skip --timeout-scale=1.5
+ --retry --job-status=normal --show-skip --timeout-scale=1.5 -j4
${{ matrix.test-all-opts }}
+ ${{ env.TESTS }}
BUNDLER_VERSION:
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test-all' || StartsWith(matrix.test_task, 'test/')}}
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-all' || StartsWith(matrix.test_task, 'test/') }}
- name: test-spec
timeout-minutes: 10
run: |
make ${{ StartsWith(matrix.test_task, 'spec/') && matrix.test_task || 'test-spec' }}
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test-spec' || StartsWith(matrix.test_task, 'spec/')}}
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-spec' || StartsWith(matrix.test_task, 'spec/') }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ - uses: ./src/.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} ${{ matrix.msystem }} / ${{ matrix.test_task }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.msystem }} / ${{ matrix.test_task }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
working-directory: build
- shell: sh
+ shell: cmd
diff --git a/.github/workflows/modgc.yml b/.github/workflows/modgc.yml
new file mode 100644
index 0000000000..bd3c6ab575
--- /dev/null
+++ b/.github/workflows/modgc.yml
@@ -0,0 +1,179 @@
+name: ModGC
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ check:
+ strategy:
+ matrix:
+ gc:
+ - name: default
+ - name: mmtk
+ mmtk_build: release
+ os: [macos-26, ubuntu-latest]
+ include:
+ - test_task: check
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUBY_DEBUG: ci
+
+ runs-on: ${{ matrix.os }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - name: Install libraries (macOS)
+ uses: ./.github/actions/setup/macos
+ if: ${{ contains(matrix.os, 'macos') }}
+
+ - name: Install libraries (Ubuntu)
+ uses: ./.github/actions/setup/ubuntu
+ if: ${{ contains(matrix.os, 'ubuntu') }}
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.1'
+ bundler: none
+ if: ${{ contains(matrix.os, 'ubuntu') }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ clean: true
+ dummy-files: false
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
+ - name: make sure that kern.coredump=1
+ run: |
+ sysctl -n kern.coredump
+ sudo sysctl -w kern.coredump=1
+ sudo chmod -R +rwx /cores/
+ if: ${{ contains(matrix.os, 'macos') }}
+
+ - name: Delete unused SDKs
+ # To free up disk space to not run out during the run
+ run: |
+ sudo rm -rf ~/.dotnet
+ sudo rm -rf /Library/Android
+ sudo rm -rf /Library/Developer/CoreSimulator
+ continue-on-error: true
+ if: ${{ contains(matrix.os, 'macos') }}
+
+ - name: Setup Ruby GC Directory
+ run: |
+ echo "MODULAR_GC_DIR=$HOME/ruby_gc" >> $GITHUB_ENV
+
+ - name: Run configure
+ env:
+ arch: ${{ matrix.arch }}
+ run: |
+ ${SETARCH} ../src/configure -C --disable-install-doc --with-modular-gc="${MODULAR_GC_DIR}" \
+ ${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
+
+ - uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
+ with:
+ cache-bin: false
+ - name: Set MMTk environment variables
+ run: |
+ echo 'EXCLUDES=../src/test/.excludes-mmtk' >> $GITHUB_ENV
+ echo 'MSPECOPT=-B../src/spec/mmtk.mspec' >> $GITHUB_ENV
+ if: ${{ matrix.gc.name == 'mmtk' }}
+
+ - run: ${SETARCH} make
+
+ - name: Build Modular GC
+ run: |
+ echo "RUBY_GC_LIBRARY=${{ matrix.gc.name }}" >> $GITHUB_ENV
+ make install-modular-gc MODULAR_GC=${{ matrix.gc.name }} MMTK_BUILD=${{ matrix.gc.mmtk_build }}
+ make distclean-modular-gc MODULAR_GC=${{ matrix.gc.name }}
+
+ - run: ${SETARCH} make hello
+
+ - name: Set test options for skipped tests
+ run: |
+ set -x
+ TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
+ echo "TESTS=${TESTS}" >> $GITHUB_ENV
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: ${{ matrix.os || 'ubuntu-22.04' }}
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ continue-on-error: true
+ timeout-minutes: 3
+
+ - name: make ${{ matrix.test_task }}
+ run: |
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ ${SETARCH} make -s ${{ matrix.test_task }} \
+ ${TESTS:+TESTS="$TESTS"} \
+ ${{ !contains(matrix.test_task, 'bundle') && 'RUBYOPT=-w' || '' }}
+ timeout-minutes: ${{ matrix.gc.timeout || 40 }}
+ env:
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+
+ - name: make skipped tests
+ run: |
+ ${SETARCH} make -s test-all TESTS="${TESTS//-n!\//-n/}"
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+ continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/parse_y.yml b/.github/workflows/parse_y.yml
new file mode 100644
index 0000000000..a0082f71de
--- /dev/null
+++ b/.github/workflows/parse_y.yml
@@ -0,0 +1,101 @@
+name: parse.y
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ strategy:
+ matrix:
+ include:
+ - test_task: check
+ - test_task: test-bundler-parallel
+ - test_task: test-bundled-gems
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUBY_DEBUG: ci
+ SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.1'
+ bundler: none
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ clean: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc cppflags=-DRUBY_DEBUG --with-parser=parse.y
+
+ - run: make
+
+ - run: make TESTRUN_SCRIPT='-renvutil -v -e "exit EnvUtil.current_parser == %[parse.y]"' run
+ env:
+ RUNOPT0: -I$(tooldir)/lib
+
+ - name: make ${{ matrix.test_task }}
+ run: make -s ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS"
+ env:
+ RUBY_TESTOPTS: ${{ matrix.testopts }}
+ EXCLUDES: '../src/test/.excludes-parsey'
+ RUN_OPTS: ${{ matrix.run_opts || '--parser=parse.y' }}
+ SPECOPTS: ${{ matrix.specopts || '-T --parser=parse.y' }}
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.run_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/post_push.yml b/.github/workflows/post_push.yml
new file mode 100644
index 0000000000..237679ebb1
--- /dev/null
+++ b/.github/workflows/post_push.yml
@@ -0,0 +1,97 @@
+name: Post-push
+on:
+ push:
+ branches:
+ - master
+ - 'ruby_*_*'
+
+permissions:
+ contents: read
+
+jobs:
+ hooks:
+ name: Post-push hooks
+ runs-on: ubuntu-latest
+ if: ${{ github.repository == 'ruby/ruby' }}
+ steps:
+ - name: Sync git.ruby-lang.org
+ id: sync-git
+ continue-on-error: true
+ run: |
+ mkdir -p ~/.ssh
+ (umask 066; printenv RUBY_GIT_SYNC_PRIVATE_KEY > ~/.ssh/id_ed25519)
+ ssh-keyscan -t ed25519 git.ruby-lang.org >> ~/.ssh/known_hosts
+ ssh -i ~/.ssh/id_ed25519 git-sync@git.ruby-lang.org "sudo -u git /home/git/git.ruby-lang.org/bin/update-ruby.sh $GITHUB_REF"
+ env:
+ GITHUB_REF: ${{ github.ref }}
+ RUBY_GIT_SYNC_PRIVATE_KEY: ${{ secrets.RUBY_GIT_SYNC_PRIVATE_KEY }}
+ if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_') }}
+
+ - name: Fetch changesets on bugs.ruby-lang.org
+ run: |
+ curl "https://bugs.ruby-lang.org/sys/fetch_changesets?key=${REDMINE_SYS_API_KEY}" -s --fail-with-body -w '* status: %{http_code}\n'
+ env:
+ REDMINE_SYS_API_KEY: ${{ secrets.REDMINE_SYS_API_KEY }}
+ if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_') }}
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
+ with:
+ fetch-depth: 500 # for notify-slack-commits
+ token: ${{ secrets.MATZBOT_AUTO_UPDATE_TOKEN }}
+
+ - name: Notify commit to Slack
+ run: ruby tool/notify-slack-commits.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.before }}
+ GITHUB_NEW_SHA: ${{ github.event.after }}
+ SLACK_WEBHOOK_URL_ALERTS: ${{ secrets.SLACK_WEBHOOK_URL_ALERTS }}
+ SLACK_WEBHOOK_URL_COMMITS: ${{ secrets.SLACK_WEBHOOK_URL_COMMITS }}
+ SLACK_WEBHOOK_URL_RUBY_JP: ${{ secrets.SLACK_WEBHOOK_URL_RUBY_JP }}
+ if: ${{ github.ref == 'refs/heads/master' }}
+
+ - name: Notify commit to ruby-cvs
+ run: |
+ SENDMAIL="ssh -i ${HOME}/.ssh/id_ed25519 git-sync@git.ruby-lang.org /usr/sbin/sendmail" \
+ ruby tool/commit-email.rb . ruby-cvs@g.ruby-lang.org \
+ "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" "$GITHUB_REF" \
+ --viewer-uri "https://github.com/ruby/ruby/commit/" \
+ --error-to cvs-admin@ruby-lang.org
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.before }}
+ GITHUB_NEW_SHA: ${{ github.event.after }}
+ GITHUB_REF: ${{ github.ref }}
+ if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/ruby_') }}
+
+ - name: Auto-correct code styles
+ run: |
+ set -x
+ ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.before }}
+ GITHUB_NEW_SHA: ${{ github.event.after }}
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+ EMAIL: svn-admin@ruby-lang.org
+ if: ${{ github.ref == 'refs/heads/master' }}
+
+ - name: Push PR notes to GitHub
+ id: pr-notes
+ continue-on-error: true
+ run: ruby tool/notes-github-pr.rb "$(pwd)/.git" "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master
+ env:
+ GITHUB_OLD_SHA: ${{ github.event.before }}
+ GITHUB_NEW_SHA: ${{ github.event.after }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+ EMAIL: svn-admin@ruby-lang.org
+ if: ${{ github.ref == 'refs/heads/master' }}
+
+ - name: Check for failures
+ run: exit 1
+ if: ${{ steps.sync-git.outcome == 'failure' || steps.pr-notes.outcome == 'failure' }}
+
+ - uses: ./.github/actions/slack
+ with:
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
diff --git a/.github/workflows/pr-playground.yml b/.github/workflows/pr-playground.yml
new file mode 100644
index 0000000000..dc4f075a38
--- /dev/null
+++ b/.github/workflows/pr-playground.yml
@@ -0,0 +1,131 @@
+name: Post Playground link to PR
+on:
+ pull_request_target:
+ types: [labeled]
+ workflow_run:
+ workflows: ["WebAssembly"]
+ types: [completed]
+
+permissions:
+ contents: read
+ actions: read
+
+jobs:
+ post-summary:
+ name: Post Playground link
+ runs-on: ubuntu-latest
+ permissions:
+ pull-requests: write
+ # Post a comment only if the PR status check is passed and the PR is labeled with `Playground`.
+ # Triggered twice: when the PR is labeled and when PR build is passed.
+ if: >-
+ ${{ false
+ || (true
+ && github.event_name == 'pull_request_target'
+ && contains(github.event.pull_request.labels.*.name, 'Playground'))
+ || (true
+ && github.event_name == 'workflow_run'
+ && github.event.workflow_run.conclusion == 'success'
+ && github.event.workflow_run.event == 'pull_request')
+ }}
+ steps:
+ - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ const fs = require('fs/promises');
+
+ const buildWorkflowPath = '.github/workflows/wasm.yml';
+ const findSuccessfuBuildRun = async (pr) => {
+ const opts = github.rest.actions.listWorkflowRunsForRepo.endpoint.merge({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ status: 'success',
+ branch: pr.head.ref,
+ });
+ const runs = await github.paginate(opts);
+ const buildRun = runs.find(run => run.path == buildWorkflowPath);
+ return buildRun;
+ }
+
+ const postComment = async (body, pr) => {
+ const { data: comments } = await github.rest.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: pr.number,
+ });
+
+ const commentOpts = { owner: context.repo.owner, repo: context.repo.repo, body: comment };
+
+ const existingComment = comments.find(comment => comment.body.startsWith(magicComment));
+ if (existingComment) {
+ core.info(`Updating existing comment: ${existingComment.html_url}`);
+ await github.rest.issues.updateComment({
+ ...commentOpts, comment_id: existingComment.id
+ });
+ } else {
+ await github.rest.issues.createComment({
+ ...commentOpts, issue_number: pr.number
+ });
+ }
+ }
+
+ const derivePRNumber = async () => {
+ if (context.payload.pull_request) {
+ return context.payload.pull_request.number;
+ }
+ // Workaround for https://github.com/orgs/community/discussions/25220
+
+ const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ run_id: context.payload.workflow_run.id,
+ });
+ const artifact = artifacts.find(artifact => artifact.name == 'github-pr-info');
+ if (!artifact) {
+ throw new Error('Cannot find github-pr-info.txt artifact');
+ }
+
+ const { data } = await github.rest.actions.downloadArtifact({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ artifact_id: artifact.id,
+ archive_format: 'zip',
+ });
+
+ await fs.writeFile('pr-info.zip', Buffer.from(data));
+ await exec.exec('unzip', ['pr-info.zip']);
+ return await fs.readFile('github-pr-info.txt', 'utf8');
+ }
+
+ const prNumber = await derivePRNumber();
+
+ const { data: pr } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: prNumber,
+ });
+
+ core.info(`Checking if the PR ${prNumber} is labeled with Playground...`);
+ if (!pr.labels.some(label => label.name == 'Playground')) {
+ core.info(`The PR is not labeled with Playground.`);
+ return;
+ }
+
+ core.info(`Checking if the build is successful for ${pr.head.ref} in ${pr.head.repo.owner.login}/${pr.head.repo.name}...`);
+ const buildRun = await findSuccessfuBuildRun(pr);
+ if (!buildRun) {
+ core.info(`No successful build run found for ${buildWorkflowPath} on ${pr.head.ref} yet.`);
+ return;
+ }
+ core.info(`Found a successful build run: ${buildRun.html_url}`);
+
+ const runLink = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
+ const magicComment = `<!-- AUTO-GENERATED-COMMENT-PR-PLAYGROUND -->`;
+ const comment = `${magicComment}
+ **Try on Playground**: https://ruby.github.io/play-ruby?run=${buildRun.id}
+ This is an automated comment by [\`pr-playground.yml\`](${runLink}) workflow.
+ `;
+ core.info(`Comment: ${comment}`);
+ await postComment(comment, pr);
+
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000000..5d16915e10
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,114 @@
+name: Publish Ruby packages
+
+on:
+ repository_dispatch:
+ types:
+ - release
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version of the Ruby package to release'
+ required: true
+ default: '4.0.0'
+
+permissions:
+ contents: read
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: 3.3.4
+
+ - name: Store Ruby version
+ env:
+ RUBY_VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
+ run: |
+ echo "RUBY_VERSION=${RUBY_VERSION}" >> $GITHUB_ENV
+
+ - name: Store ABI version
+ run: echo "ABI_VERSION=$(echo ${RUBY_VERSION} | cut -d '.' -f 1-2)" >> $GITHUB_ENV
+
+ - name: Copy draft package `/tmp` to `/pub` directory
+ run: tool/release.sh ${RUBY_VERSION}
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.FTP_R_L_O_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.FTP_R_L_O_AWS_SECRET_ACCESS_KEY }}
+ AWS_DEFAULT_REGION: us-west-2
+
+ - name: Purge URLs of release package
+ run: |
+ curl -X POST \
+ -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
+ https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.tar.gz
+ curl -X POST \
+ -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
+ https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.tar.xz
+ curl -X POST \
+ -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
+ https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.zip
+
+ - name: Create a release on GitHub
+ run: |
+ RELEASE_TAG=$(ruby tool/ruby-version.rb tag "${RUBY_VERSION}")
+ echo $RELEASE_TAG
+ PREVIOUS_RELEASE_TAG=$(ruby tool/ruby-version.rb previous-tag "${RUBY_VERSION}")
+ echo $PREVIOUS_RELEASE_TAG
+ tool/gen-github-release.rb $PREVIOUS_RELEASE_TAG $RELEASE_TAG --no-dry-run
+ env:
+ GITHUB_TOKEN: ${{ secrets.MATZBOT_AUTO_UPDATE_TOKEN }}
+
+ - name: Update versions index
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/ruby/actions/dispatches \
+ -d '{"event_type": "update_index"}'
+
+ - name: Build and push Docker images
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/ruby/docker-images/dispatches \
+ -d "{\"event_type\": \"build\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\"}}"
+
+ - name: Build snapcraft packages
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/ruby/snap.ruby/dispatches \
+ -d "{\"event_type\": \"build\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\"}}"
+
+ - name: Store the latest LTS version of OpenSSL
+ run: |
+ echo "OPENSSL_VERSION=`curl -s https://api.github.com/repos/openssl/openssl/releases | jq -r '.[].tag_name | select(startswith("openssl-3.0"))' | sort -Vr | head -n1 | cut -d'-' -f2`" >> $GITHUB_ENV
+
+ - name: Update ruby-build definition
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.RUBY_BUILD_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/rbenv/ruby-build/dispatches \
+ -d "{\"event_type\": \"update-ruby\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\", \"openssl_version\": \"${OPENSSL_VERSION}\"}}"
+
+ - name: Update all-ruby definition
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/ruby/all-ruby/dispatches \
+ -d '{"event_type": "update"}'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000000..a35bcff99a
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,21 @@
+name: Start release workflow
+on:
+ push:
+ tags:
+ - '*'
+
+permissions:
+ contents: read
+
+jobs:
+ notify:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Build release package
+ run: |
+ curl -L -X POST \
+ -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/ruby/actions/dispatches \
+ -d "{\"event_type\": \"$GITHUB_REF\"}"
diff --git a/.github/workflows/rjit-bindgen.yml b/.github/workflows/rjit-bindgen.yml
deleted file mode 100644
index b7df58a814..0000000000
--- a/.github/workflows/rjit-bindgen.yml
+++ /dev/null
@@ -1,97 +0,0 @@
-name: RJIT bindgen
-on:
- push:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
-
-concurrency:
- group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
- cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-
-permissions:
- contents: read
-
-jobs:
- make:
- strategy:
- matrix:
- include:
- - task: rjit-bindgen
- fail-fast: false
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- steps:
- - run: mkdir build
- working-directory:
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y \
- build-essential \
- libssl-dev libyaml-dev libreadline6-dev \
- zlib1g-dev libncurses5-dev libffi-dev \
- libclang1-10 \
- bison autoconf
- sudo apt-get install -q -y pkg-config || :
- - name: Set up Ruby
- uses: ruby/setup-ruby@e6689b4deb1cb2062ea45315001f687c0b52111b # v1.144.1
- with:
- ruby-version: '3.1'
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - run: ./autogen.sh
- working-directory: src
- - name: Run configure
- run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install --enable-yjit=dev_nodebug
- - run: make incs
- - run: make
- - run: make install
- - run: make ${{ matrix.task }}
- - run: git diff --exit-code
- working-directory: src
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
- with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "RJIT / bindgen",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
-
-defaults:
- run:
- working-directory: build
diff --git a/.github/workflows/rjit.yml b/.github/workflows/rjit.yml
deleted file mode 100644
index 75d1d7355f..0000000000
--- a/.github/workflows/rjit.yml
+++ /dev/null
@@ -1,126 +0,0 @@
-name: RJIT
-on:
- push:
- paths-ignore:
- - 'doc/**'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- - '**.[1-8]'
- - '**.ronn'
- pull_request:
- paths-ignore:
- - 'doc/**'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- - '**.[1-8]'
- - '**.ronn'
-
-concurrency:
- group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
- cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-
-permissions:
- contents: read
-
-jobs:
- make:
- strategy:
- matrix:
- # main variables included in the job name
- test_task: [check]
- run_opts: ['--rjit-call-threshold=1']
- arch: ['']
- fail-fast: false
- env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- RUBY_DEBUG: ci
- SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- steps:
- - run: mkdir build
- working-directory:
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Install libraries
- env:
- arch: ${{matrix.arch}}
- run: |
- set -x
- arch=${arch:+:${arch/i[3-6]86/i386}}
- ${arch:+sudo dpkg --add-architecture ${arch#:}}
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y \
- ${arch:+cross}build-essential${arch/:/-} \
- libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
- zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
- bison autoconf ruby
- sudo apt-get install -q -y pkg-config${arch} || :
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.1.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.0.11
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - run: ./autogen.sh
- working-directory: src
- - name: Run configure
- env:
- arch: ${{matrix.arch}}
- run: >-
- $SETARCH ../src/configure -C --disable-install-doc cppflags=-DRUBY_DEBUG
- ${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
- - run: $SETARCH make
- - name: make test
- run: |
- $SETARCH make -s test RUN_OPTS="$RUN_OPTS"
- timeout-minutes: 30
- env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
- RUN_OPTS: ${{ matrix.run_opts }}
- - name: make test-all
- run: |
- $SETARCH make -s test-all RUN_OPTS="$RUN_OPTS"
- timeout-minutes: 40
- env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
- RUN_OPTS: ${{ matrix.run_opts }}
- - name: make test-spec
- run: |
- $SETARCH make -s test-spec RUN_OPTS="$RUN_OPTS"
- timeout-minutes: 10
- env:
- GNUMAKEFLAGS: ""
- RUN_OPTS: ${{ matrix.run_opts }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
- with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "RJIT / ${{ matrix.run_opts }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
-
-defaults:
- run:
- working-directory: build
diff --git a/.github/workflows/rust-warnings.yml b/.github/workflows/rust-warnings.yml
new file mode 100644
index 0000000000..23ed164405
--- /dev/null
+++ b/.github/workflows/rust-warnings.yml
@@ -0,0 +1,62 @@
+# Surface Rust warnings on PRs that touch any Rust code.
+# Not a required check so we never block people over new warnings
+# that might come from a new Rust version being released.
+name: Rust warnings
+on:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ paths:
+ - '**.rs'
+ - '!**.inc.rs'
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ rust-warnings:
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
+ runs-on: ubuntu-24.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - name: Install Rust
+ run: rustup default beta
+
+ - name: Rust warnings
+ shell: bash
+ run: |
+ set -eu
+ cargo check --quiet --all-features --message-format=json \
+ | jq -r 'select(.message.level | IN("warning", "error")) | .message.rendered' \
+ | tee messages.txt
+ (exit "${PIPESTATUS[0]}") && ! grep --quiet '[^[:space:]]' messages.txt
+
+ - name: "📜 `rustdoc` warnings"
+ shell: bash
+ run: |
+ set -eu
+ cargo doc --document-private-items --all --no-deps --message-format=json \
+ | jq -r 'select(.message.level | IN("warning", "error")) | .message.rendered' \
+ | tee messages.txt
+ (exit "${PIPESTATUS[0]}") && ! grep --quiet '[^[:space:]]' messages.txt
diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml
index 5a5afe829f..74c13f98fa 100644
--- a/.github/workflows/scorecards.yml
+++ b/.github/workflows/scorecards.yml
@@ -2,7 +2,7 @@
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
-name: Scorecards supply-chain security
+name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
@@ -10,7 +10,7 @@ on:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- - cron: '22 4 * * 2'
+ - cron: '39 3 * * 5'
# push:
# branches: [ "master" ]
@@ -19,8 +19,10 @@ permissions: read-all
jobs:
analysis:
- name: Scorecards analysis
+ name: Scorecard analysis
runs-on: ubuntu-latest
+ # `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
+ if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
@@ -32,20 +34,20 @@ jobs:
steps:
- name: "Checkout code"
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: "Run analysis"
- uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
+ uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
with:
results_file: results.sarif
results_format: sarif
- # (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
+ # (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
- # - you are installing Scorecards on a *private* repository
- # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
- repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
+ # - you are installing Scorecard on a *private* repository
+ # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
+ # repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
@@ -56,17 +58,21 @@ jobs:
# of the value entered here.
publish_results: true
+ # (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
+ # file_mode: git
+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- # - name: "Upload artifact"
- # uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
- # with:
- # name: SARIF file
- # path: results.sarif
- # retention-days: 5
+ - name: "Upload artifact"
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: SARIF file
+ path: results.sarif
+ retention-days: 5
- # Upload the results to GitHub's code scanning dashboard.
+ # Upload the results to GitHub's code scanning dashboard (optional).
+ # Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@168b99b3c22180941ae7dbdd5f5c9678ede476ba # v2.1.27
+ uses: github/codeql-action/upload-sarif@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
with:
sarif_file: results.sarif
diff --git a/.github/workflows/spec_guards.yml b/.github/workflows/spec_guards.yml
index 4bbc0b52ce..856b6e434e 100644
--- a/.github/workflows/spec_guards.yml
+++ b/.github/workflows/spec_guards.yml
@@ -3,12 +3,15 @@ name: Rubyspec Version Guards Check
on:
push:
paths:
+ - '.github/workflows/spec_guards.yml'
- 'spec/**'
- '!spec/*.md'
pull_request:
- paths-ignore:
+ paths:
+ - '.github/workflows/spec_guards.yml'
- 'spec/**'
- '!spec/*.md'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -20,38 +23,46 @@ permissions:
jobs:
rubyspec:
name: Rubyspec
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
strategy:
matrix:
# Specs from ruby/spec should still run on all supported Ruby versions.
# This also ensures the needed ruby_version_is guards are there, see spec/README.md.
ruby:
- - ruby-2.7
- - ruby-3.1
- - ruby-3.2
+ - ruby-3.3
+ - ruby-3.4
+ - ruby-4.0
+ fail-fast: false
steps:
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- - uses: ruby/setup-ruby@e6689b4deb1cb2062ea45315001f687c0b52111b # v1.144.1
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
+
- run: gem install webrick
+
- run: ruby ../mspec/bin/mspec
working-directory: spec/ruby
env:
CHECK_LEAKS: true
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / rubyspec @ ${{ matrix.ruby }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.ruby }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/sync_default_gems.yml b/.github/workflows/sync_default_gems.yml
new file mode 100644
index 0000000000..9fd1945449
--- /dev/null
+++ b/.github/workflows/sync_default_gems.yml
@@ -0,0 +1,80 @@
+name: Sync default gems
+
+env:
+ DEFAULT_GEM_SYNC_ENABLED: true
+
+on:
+ workflow_dispatch:
+ inputs:
+ gem:
+ required: true
+ description: 'Name of the gem to be synchronized'
+ type: string
+ before:
+ required: true
+ description: 'Gem commit SHA before sync'
+ type: string
+ after:
+ required: true
+ description: 'Gem commit SHA after sync'
+ type: string
+
+permissions:
+ contents: read
+
+jobs:
+ sync_default_gems:
+ name: Sync default gem ${{ github.event.inputs.gem }}
+
+ permissions:
+ contents: write # for Git to git push
+
+ runs-on: ubuntu-latest
+
+ if: ${{ github.repository == 'ruby/ruby' }}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked]
+ name: Check out ruby/ruby
+ with:
+ token: ${{ github.repository == 'ruby/ruby' && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.4'
+ bundler: none
+
+ - name: Run tool/sync_default_gems.rb
+ id: sync
+ run: |
+ ruby_before=$(git rev-parse HEAD)
+ set -x
+ ruby tool/sync_default_gems.rb "${gem_name}" "${gem_before}..${gem_after}"
+ if [[ "$(git rev-parse HEAD)" != "$ruby_before" ]]; then
+ echo update=true >> $GITHUB_OUTPUT
+ fi
+ env:
+ gem_name: ${{ github.event.inputs.gem }}
+ gem_before: ${{ github.event.inputs.before }}
+ gem_after: ${{ github.event.inputs.after }}
+ EMAIL: svn-admin@ruby-lang.org
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+
+ - name: Push
+ run: |
+ git pull --rebase origin ${GITHUB_REF#refs/heads/}
+ git push origin ${GITHUB_REF#refs/heads/}
+ if: ${{ steps.sync.outputs.update && env.DEFAULT_GEM_SYNC_ENABLED == 'true' }}
+ env:
+ EMAIL: svn-admin@ruby-lang.org
+ GIT_AUTHOR_NAME: git
+ GIT_COMMITTER_NAME: git
+
+ - uses: ./.github/actions/slack
+ with:
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ label: "${{ github.event.inputs.gem }} (<https://github.com/${{ github.event.inputs.gem == 'rubygems' && 'rubygems' || 'ruby' }}/${{ github.event.inputs.gem }}/compare/${{ github.event.inputs.before }}...${{ github.event.inputs.after }}|diff>)"
+ event_name: workflow_dispatch
+ extra_channel_id: C05FPKAU743 # alerts-sync
+ if: ${{ failure() }}
diff --git a/.github/workflows/tarball-macos.yml b/.github/workflows/tarball-macos.yml
new file mode 100644
index 0000000000..9bec94d528
--- /dev/null
+++ b/.github/workflows/tarball-macos.yml
@@ -0,0 +1,101 @@
+name: tarball-macos (reusable)
+
+on:
+ workflow_call:
+ inputs:
+ archname:
+ description: 'archname (e.g. snapshot-master, snapshot-ruby_3_3)'
+ required: true
+ type: string
+ notify-release-channel:
+ description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (schedule/release builds).'
+ required: false
+ type: boolean
+ default: false
+ secrets:
+ SIMPLER_ALERTS_URL:
+ required: false
+ SNAPSHOT_SLACK_WEBHOOK_URL:
+ required: false
+
+permissions:
+ contents: read
+
+jobs:
+ macos:
+ strategy:
+ matrix:
+ test_task: [check, test-bundled-gems, test-bundler-parallel]
+ os: [macos-26, macos-15, macos-14]
+ include:
+ - os: macos-15-intel
+ test_task: check
+ fail-fast: false
+ runs-on: ${{ matrix.os }}
+ env:
+ ARCHNAME: ${{ inputs.archname }}
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: Packages
+ path: pkg
+ - name: Extract
+ run: tar xf pkg/*.tar.xz
+ - name: Install libraries
+ run: |
+ with_retry () {
+ "$@" || { sleep 5 && "$@"; } || { sleep 60 && "$@"; }
+ }
+ set -x
+ with_retry brew install gmp libffi openssl zlib autoconf automake libtool libyaml
+ - name: Set ENV
+ run: |
+ echo "JOBS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
+ - name: configure
+ run: cd "$ARCHNAME/" && ./configure --with-openssl-dir=$(brew --prefix openssl) --with-libyaml-dir=$(brew --prefix libyaml)
+ - name: make
+ run: cd "$ARCHNAME/" && make $JOBS
+ - name: Tests
+ run: cd "$ARCHNAME/" && make $JOBS -s ${{ matrix.test_task }}
+ env:
+ RUBY_TESTOPTS: "-q --tty=no"
+ RUBY_DEBUG_TEST_NO_REMOTE: "1"
+ # leaked-globals since 2.7
+ - name: Leaked Globals
+ run: cd "$ARCHNAME/" && make -s leaked-globals
+ if: matrix.test_task == 'check'
+ - name: make install without root privilege
+ run: cd "$ARCHNAME/" && make $JOBS install DESTDIR="/tmp/destdir"
+ if: matrix.test_task == 'check'
+ - name: make install
+ run: cd "$ARCHNAME/" && sudo make $JOBS install
+ if: matrix.test_task == 'check'
+ - name: Verify installed binaries
+ run: |
+ /usr/local/bin/ruby -v
+ /usr/local/bin/gem -v
+ /usr/local/bin/bundle -v
+ if: matrix.test_task == 'check'
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github/actions/slack
+ sparse-checkout-cone-mode: false
+ persist-credentials: false
+ if: ${{ failure() }}
+ - uses: ./.github/actions/slack
+ with:
+ label: "${{ matrix.os }} / ${{ matrix.test_task }}"
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+ - uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
+ with:
+ payload: |
+ {
+ "attachments": [{
+ "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>",
+ "color": "danger"
+ }]
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+ if: failure() && inputs.notify-release-channel
diff --git a/.github/workflows/tarball-non-development.yml b/.github/workflows/tarball-non-development.yml
new file mode 100644
index 0000000000..db6230b301
--- /dev/null
+++ b/.github/workflows/tarball-non-development.yml
@@ -0,0 +1,87 @@
+name: tarball-non-development (reusable)
+
+on:
+ workflow_call: {}
+
+permissions:
+ contents: read
+
+jobs:
+ non_development:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { variant: default, remove_ruby: false, configure_extra: '' }
+ - { variant: no-ruby, remove_ruby: true, configure_extra: '' }
+ - { variant: baseruby-no, remove_ruby: false, configure_extra: '--with-baseruby=no' }
+ runs-on: ubuntu-24.04
+ env:
+ ruby_prefix: /tmp/ruby-snapshot
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: Packages
+ path: pkg
+ - name: Extract
+ run: tar xf pkg/*.tar.xz
+ - name: Substitute patchlevel
+ run: |
+ set -x
+ cd snapshot-*/
+ sed -i.orig 's/^\( *# *define *RUBY_PATCHLEVEL\) *-.*/\1 0/' version.h
+ diff -u version.h.orig version.h || :
+ rm -f version.h.orig
+ - name: Install libraries
+ run: |
+ set -x
+ sudo apt-get update -q || :
+ sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev bison- autoconf-
+ - name: Remove host ruby
+ if: matrix.remove_ruby
+ run: |
+ set -x
+ sudo apt-get purge -y -q 'ruby*' || :
+ sudo rm -rf /opt/hostedtoolcache/Ruby
+ ! command -v ruby
+ - name: Set ENV
+ run: |
+ echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
+ - name: configure
+ run: cd snapshot-*/ && ./configure --prefix="${ruby_prefix}" ${{ matrix.configure_extra }}
+ - name: make
+ run: cd snapshot-*/ && make $JOBS
+ - name: Leaked Globals
+ run: cd snapshot-*/ && make -s leaked-globals
+ - name: make install
+ run: cd snapshot-*/ && make $JOBS install
+ - name: Set PATH
+ run: echo "PATH=${ruby_prefix}/bin:$PATH" >> $GITHUB_ENV
+ - name: Check patchlevel
+ id: check-patchlevel
+ run: |
+ exec "${ruby_prefix}/bin/ruby" -vx "$0"
+ #!ruby
+ puts "RUBY_PATCHLEVEL=#{RUBY_PATCHLEVEL.inspect}"
+ abort unless RUBY_PATCHLEVEL >= 0
+ working-directory: ${{ env.ruby_prefix }}
+ continue-on-error: true
+ - name: Check LOADPATH
+ id: check-loadpath
+ run: |
+ exec ${ruby_prefix}/bin/ruby -vx "$0"
+ #!ruby
+ paths = $:.grep(/\+/)
+ pp paths
+ abort unless paths.empty?
+ working-directory: ${{ env.ruby_prefix }}
+ continue-on-error: true
+ - name: Check pathnames
+ id: check-pathnames
+ run: |
+ ! find -name '*+*' | grep +
+ working-directory: ${{ env.ruby_prefix }}
+ continue-on-error: true
+ - name: result
+ run: false
+ if: ${{ contains(steps.*.outcome, 'failure') }}
diff --git a/.github/workflows/tarball-test-schedule.yml b/.github/workflows/tarball-test-schedule.yml
new file mode 100644
index 0000000000..6684b09edb
--- /dev/null
+++ b/.github/workflows/tarball-test-schedule.yml
@@ -0,0 +1,26 @@
+name: tarball-test-schedule
+on:
+ schedule:
+ - cron: '30 18 * * *' # Daily at 18:30 UTC
+ workflow_dispatch:
+
+permissions: {}
+
+jobs:
+ dispatch:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby' }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ branch:
+ - master
+ - ruby_4_0
+ - ruby_3_4
+ - ruby_3_3
+ steps:
+ - name: Trigger tarball-test on ${{ matrix.branch }}
+ run: gh workflow run tarball-test.yml --ref "$BRANCH" --repo "$GITHUB_REPOSITORY" -f notify-release-channel=true
+ env:
+ BRANCH: ${{ matrix.branch }}
+ GH_TOKEN: ${{ secrets.MATZBOT_GITHUB_ACTION_TOKEN }}
diff --git a/.github/workflows/tarball-test.yml b/.github/workflows/tarball-test.yml
new file mode 100644
index 0000000000..c862ab76cc
--- /dev/null
+++ b/.github/workflows/tarball-test.yml
@@ -0,0 +1,104 @@
+name: tarball-test
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+ workflow_dispatch:
+ inputs:
+ notify-release-channel:
+ description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (set by tarball-test-schedule).'
+ type: boolean
+ default: false
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ tarball:
+ runs-on: ubuntu-latest
+ # Cherry-pick to maintenance branches by changing only env.BRANCH below;
+ # archname / branch-label / Materialize all derive from it.
+ env:
+ BRANCH: master
+ outputs:
+ branch: ${{ env.BRANCH }}
+ skip: ${{ steps.skipping.outputs.skip }}
+ steps:
+ - id: skipping
+ run: echo 'skip=true' >> $GITHUB_OUTPUT
+ if: >-
+ ${{(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 1 # actions/checkout fetches all heads/tags unless > 0
+ persist-credentials: false
+ # tool/make-snapshot derives the branch name from HEAD and looks up
+ # the upstream during ChangeLog generation. Detached checkouts
+ # (pull_request, merge_group) lack a local branch with tracking, so
+ # pin one to HEAD and connect it to the matching origin ref.
+ - name: Materialize local branch
+ run: |
+ git fetch --no-tags --depth=1 origin "+refs/heads/$BASE:refs/remotes/origin/$BASE"
+ git checkout -B "$BRANCH" HEAD
+ git branch --set-upstream-to="origin/$BASE" "$BRANCH"
+ env:
+ BASE: ${{ github.base_ref || env.BRANCH }}
+ - uses: ./.github/actions/make-snapshot
+ with:
+ archname: snapshot-${{ env.BRANCH }}
+ srcdir: '.'
+
+ ubuntu:
+ needs: tarball
+ if: ${{ ! needs.tarball.outputs.skip }}
+ uses: ./.github/workflows/tarball-ubuntu.yml
+ with:
+ archname: snapshot-${{ needs.tarball.outputs.branch }}
+ notify-release-channel: ${{ github.event_name == 'workflow_dispatch' && inputs.notify-release-channel || false }}
+ secrets:
+ SIMPLER_ALERTS_URL: ${{ secrets.SIMPLER_ALERTS_URL }}
+ SNAPSHOT_SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+
+ macos:
+ needs: tarball
+ if: ${{ ! needs.tarball.outputs.skip }}
+ uses: ./.github/workflows/tarball-macos.yml
+ with:
+ archname: snapshot-${{ needs.tarball.outputs.branch }}
+ notify-release-channel: ${{ github.event_name == 'workflow_dispatch' && inputs.notify-release-channel || false }}
+ secrets:
+ SIMPLER_ALERTS_URL: ${{ secrets.SIMPLER_ALERTS_URL }}
+ SNAPSHOT_SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+
+ windows:
+ needs: tarball
+ if: ${{ ! needs.tarball.outputs.skip }}
+ uses: ./.github/workflows/tarball-windows.yml
+ with:
+ archname: snapshot-${{ needs.tarball.outputs.branch }}
+ notify-release-channel: ${{ github.event_name == 'workflow_dispatch' && inputs.notify-release-channel || false }}
+ secrets:
+ SIMPLER_ALERTS_URL: ${{ secrets.SIMPLER_ALERTS_URL }}
+ SNAPSHOT_SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+
+ non_development:
+ needs: tarball
+ uses: ./.github/workflows/tarball-non-development.yml
diff --git a/.github/workflows/tarball-ubuntu.yml b/.github/workflows/tarball-ubuntu.yml
new file mode 100644
index 0000000000..e227dc29aa
--- /dev/null
+++ b/.github/workflows/tarball-ubuntu.yml
@@ -0,0 +1,151 @@
+name: tarball-ubuntu (reusable)
+
+on:
+ workflow_call:
+ inputs:
+ archname:
+ description: 'archname (e.g. snapshot-master, snapshot-ruby_3_3)'
+ required: true
+ type: string
+ notify-release-channel:
+ description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (schedule/release builds).'
+ required: false
+ type: boolean
+ default: false
+ secrets:
+ SIMPLER_ALERTS_URL:
+ required: false
+ SNAPSHOT_SLACK_WEBHOOK_URL:
+ required: false
+
+permissions:
+ contents: read
+
+jobs:
+ ubuntu:
+ strategy:
+ matrix:
+ test_task: [check, test-bundler-parallel, test-bundled-gems]
+ os: [ubuntu-24.04, ubuntu-22.04]
+ fail-fast: false
+ runs-on: ${{ matrix.os }}
+ env:
+ ARCHNAME: ${{ inputs.archname }}
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: Packages
+ path: pkg
+ - name: Extract
+ run: tar xf pkg/*.tar.xz
+ - name: Install libraries
+ run: |
+ set -x
+ sudo apt-get update -q
+ sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev bison- autoconf-
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.2'
+ # test-bundled-gems requires executable host ruby
+ if: matrix.test_task == 'test-bundled-gems'
+ - name: Fixed world writable dirs
+ run: |
+ mkdir -p $HOME/.local/share
+ mkdir -p $HOME/.cache/gem/specs
+ mkdir -p $HOME/.bundle/cache
+ mkdir -p $HOME/.ssh
+ chmod a-w $HOME/.bundle
+ # chmod a-w $HOME
+ # allow to write $HOME and check stats of HOME around tests (see below)
+ chmod -v a-w $HOME/.config
+ sudo chmod -R a-w /usr/share
+ sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v a-w $d; done' || :
+ - name: Set ENV
+ run: |
+ echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
+ - name: configure
+ run: cd "$ARCHNAME/" && ./configure
+ - name: make
+ run: cd "$ARCHNAME/" && make $JOBS
+ - name: Save stats of HOME
+ run: |
+ set -euxo pipefail
+ cat >"$ARCHNAME/save-stats.rb" <<'EOF'
+ require 'pathname'
+ require 'digest'
+ out = []
+ [
+ Dir.home,
+ ].each do |dir|
+ Dir.each_child(dir) do |name|
+ pn = File.join(dir, name)
+ st = File.stat(pn)
+ if st.file?
+ content = Digest::SHA1.file(pn).hexdigest
+ elsif st.directory? && st.nlink <= 10
+ content = Dir.children(pn).sort
+ end
+ out << [pn, "%o"%st.mode, st.nlink, st.uid, st.gid, st.size, content].to_s
+ rescue
+ out << [pn, $!.inspect].to_s
+ end
+ end
+ File.open(ARGV.shift, "w") do |io|
+ io.puts out.sort
+ end
+ EOF
+ make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-before-tests.txt runruby
+ - name: Tests
+ run: cd "$ARCHNAME/" && make $JOBS -s ${{ matrix.test_task }}
+ env:
+ RUBY_TESTOPTS: "-q --tty=no"
+ # test_sync_default_gems triggers gpg, whose agent processes leave
+ # $HOME/.gnupg around even when GNUPGHOME points elsewhere.
+ - name: Forcibly remove ~/.gnupg
+ run: rm -rf $HOME/.gnupg
+ - name: Diff stats of HOME
+ run: |
+ make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-after-tests.txt runruby
+ rm -f "$ARCHNAME/save-stats.rb"
+ diff -u /tmp/stat-before-tests.txt /tmp/stat-after-tests.txt
+ # leaked-globals since 2.7
+ - name: Leaked Globals
+ run: cd "$ARCHNAME/" && make -s leaked-globals
+ if: matrix.test_task == 'check'
+ - name: make install without root privilege
+ run: cd "$ARCHNAME/" && make $JOBS install DESTDIR="/tmp/destdir"
+ if: matrix.test_task == 'check'
+ - name: make install
+ run: cd "$ARCHNAME/" && sudo make $JOBS install
+ if: matrix.test_task == 'check'
+ - name: Verify installed binaries
+ run: |
+ /usr/local/bin/ruby -v
+ /usr/local/bin/gem -v
+ /usr/local/bin/bundle -v
+ if: matrix.test_task == 'check'
+ - name: Show .local
+ run: find $HOME/.local -ls
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github/actions/slack
+ sparse-checkout-cone-mode: false
+ persist-credentials: false
+ if: ${{ failure() }}
+ - uses: ./.github/actions/slack
+ with:
+ label: "${{ matrix.os }} / ${{ matrix.test_task }}"
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+ - uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
+ with:
+ payload: |
+ {
+ "attachments": [{
+ "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>",
+ "color": "danger"
+ }]
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+ if: failure() && inputs.notify-release-channel
diff --git a/.github/workflows/tarball-windows.yml b/.github/workflows/tarball-windows.yml
new file mode 100644
index 0000000000..1ce95de6fc
--- /dev/null
+++ b/.github/workflows/tarball-windows.yml
@@ -0,0 +1,163 @@
+name: tarball-windows (reusable)
+
+on:
+ workflow_call:
+ inputs:
+ archname:
+ description: 'archname (e.g. snapshot-master)'
+ required: true
+ type: string
+ notify-release-channel:
+ description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (schedule/release builds).'
+ required: false
+ type: boolean
+ default: false
+ secrets:
+ SIMPLER_ALERTS_URL:
+ required: false
+ SNAPSHOT_SLACK_WEBHOOK_URL:
+ required: false
+
+permissions:
+ contents: read
+
+jobs:
+ windows:
+ strategy:
+ matrix:
+ include:
+ - os: '2022'
+ test_task: check
+ - os: '2025-vs2026'
+ test_task: check
+ fail-fast: false
+ runs-on: windows-${{ matrix.os }}
+ defaults:
+ run:
+ shell: cmd
+ working-directory: build
+ name: Windows ${{ matrix.os }} (${{ matrix.test_task }})
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ PATCH: C:\msys64\usr\bin\patch.exe
+ OS_VER: windows-${{ matrix.os }}
+ # see https://github.com/ruby/ruby/commit/9ff4399decef0036897d3cfb9ac2c710dea913ca
+ OPENSSL_MODULES: C:\vcpkg\installed\x64-windows\bin
+ steps:
+ - run: md build
+ working-directory:
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.2'
+ bundler: none
+ windows-toolchain: none
+
+ - uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2.31.1
+ id: setup-msys2
+ with:
+ update: true
+ install: >-
+ patch
+ - name: patch path
+ shell: msys2 {0}
+ run: echo PATCH=$(cygpath -wa $(command -v patch)) >> $GITHUB_ENV
+ if: ${{ steps.setup-msys2.outcome == 'success' }}
+ - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+ with:
+ path: C:\vcpkg\installed
+ key: ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-${{ github.sha }}
+ restore-keys: |
+ ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-
+ ${{ runner.os }}-vcpkg-installed-
+ - name: Install libraries with vcpkg
+ run: |
+ vcpkg --triplet x64-windows install gmp libffi libyaml openssl zlib
+
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: Packages
+ path: pkg
+ - name: Extract
+ run: 7z x pkg/*.zip
+ working-directory:
+
+ - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+ with:
+ path: snapshot-*/.downloaded-cache
+ key: downloaded-cache
+
+ - name: setup env
+ # %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
+ # https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
+ env:
+ ARCHNAME: ${{ inputs.archname }}
+ run: |
+ set > old.env
+ call ..\%ARCHNAME%\win32\vssetup.cmd
+ set TMP=%USERPROFILE%\AppData\Local\Temp
+ set TEMP=%USERPROFILE%\AppData\Local\Temp
+ set /a TEST_JOBS=(15 * %NUMBER_OF_PROCESSORS% / 10) > nul
+ set > new.env
+
+ - name: update env
+ shell: pwsh
+ run: |
+ $old = (Get-Content old.env); $new = (Get-Content new.env)
+ del *.env
+ Compare-Object $old $new |
+ Where-Object { $_.SideIndicator -eq '=>' } |
+ Select-Object -ExpandProperty InputObject |
+ Add-Content -Path $env:GITHUB_ENV
+ - name: link libraries
+ run: |
+ for %%I in (C:\vcpkg\installed\x64-windows\bin\*.dll) do (
+ mklink %%~nxI %%I
+ )
+ - name: Configure
+ env:
+ ARCHNAME: ${{ inputs.archname }}
+ run: >-
+ ../%ARCHNAME%/win32/configure.bat --disable-install-doc
+ --with-opt-dir=C:/vcpkg/installed/x64-windows
+ - run: nmake incs
+ - run: nmake extract-extlibs
+ - run: nmake
+ env:
+ YACC: win_bison
+
+ - name: ruby -v
+ run: .\ruby -v
+
+ - run: nmake test
+ timeout-minutes: 5
+
+ - run: nmake ${{ matrix.test_task }}
+ env:
+ RUBY_TESTOPTS: -j${{env.TEST_JOBS}}
+ timeout-minutes: 70
+ continue-on-error: ${{ matrix.continue-on-error || false }}
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github/actions/slack
+ sparse-checkout-cone-mode: false
+ persist-credentials: false
+ if: ${{ failure() }}
+ - uses: ./.github/actions/slack
+ with:
+ label: "${{ env.OS_VER }} / ${{ matrix.test_task }}"
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+ - uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
+ with:
+ payload: |
+ {
+ "attachments": [{
+ "text": "${{ job.status }}: ${{ env.OS_VER }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>",
+ "color": "danger"
+ }]
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
+ if: failure() && inputs.notify-release-channel
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index 6998c6f340..09e96f764c 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -3,17 +3,15 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -26,111 +24,251 @@ jobs:
make:
strategy:
matrix:
- test_task: [check]
- arch: ['']
- configure: ['cppflags=-DVM_CHECK_MODE']
- # specifying everything else with `include` to avoid redundant tests
+ # We enumerate every job in matrix.include to save build time
include:
- test_task: check
+ configure: 'cppflags=-DVM_CHECK_MODE'
+ - test_task: check
arch: i686
- test_task: check
+ configure: '--disable-yjit'
+ - test_task: check
configure: '--enable-shared --enable-load-relative'
- - test_task: test-all TESTS=--repeat-count=2
- test_task: test-bundler-parallel
+ timeout: 50
- test_task: test-bundled-gems
+ - test_task: check
+ os: ubuntu-24.04
+ extra_checks: [capi]
+ # ubuntu-24.04-arm jobs don't start on ruby/ruby as of 2025-10-29
+ #- test_task: check
+ # os: ubuntu-24.04-arm
fail-fast: false
- env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+
+ env: &make-env
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUBY_DEBUG: ci
- SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- steps:
- - run: mkdir build
- working-directory:
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Install libraries
- env:
- arch: ${{matrix.arch}}
- run: |
- set -x
- arch=${arch:+:${arch/i[3-6]86/i386}}
- ${arch:+sudo dpkg --add-architecture ${arch#:}}
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y \
- ${arch:+cross}build-essential${arch/:/-} \
- libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
- zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
- bison autoconf ruby
- sudo apt-get install -q -y pkg-config${arch} || :
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+
+ runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps: &make-steps
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ arch: ${{ matrix.arch }}
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - run: ./autogen.sh
- working-directory: src
+ ruby-version: '3.1'
+ bundler: none
+ if: >-
+ ${{ !endsWith(matrix.os, 'arm')
+ && !endsWith(matrix.os, 'ppc64le') && !endsWith(matrix.os, 's390x') }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ clean: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
- name: Run configure
env:
- arch: ${{matrix.arch}}
- configure: ${{matrix.configure}}
+ arch: ${{ matrix.arch }}
+ configure: ${{ matrix.configure }}
run: >-
- $SETARCH ../src/configure -C --disable-install-doc ${configure:-cppflags=-DRUBY_DEBUG}
+ $SETARCH ../src/configure -C --disable-install-doc ${configure:- --enable-debug-env cppflags=-DRUBY_DEBUG}
${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
- - run: $SETARCH make incs
+
- run: $SETARCH make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
- run: $SETARCH make
- - run: $SETARCH make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
- - name: Create dummy files in build dir
+
+ - run: $SETARCH make hello
+
+ - name: runirb
run: |
- $SETARCH ./miniruby -e '(("a".."z").to_a+("A".."Z").to_a+("0".."9").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}'
- if: ${{ matrix.test_task == 'check' }}
+ echo IRB::VERSION | $SETARCH make runirb RUNOPT="-- -f"
+
+ - name: Set test options for skipped tests
+ run: |
+ set -x
+ TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
+ echo "TESTS=${TESTS}" >> $GITHUB_ENV
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: ${{ matrix.os || 'ubuntu-22.04' }}
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ continue-on-error: true
+ timeout-minutes: 3
+
+ # Avoid possible test failures with the zlib applying the following patch
+ # on s390x CPU architecture.
+ # https://github.com/madler/zlib/pull/410
+ - name: Disable DFLTCC
+ run: echo "DFLTCC=0" >> $GITHUB_ENV
+ if: ${{ endsWith(matrix.os, 's390x') }}
+
- name: make ${{ matrix.test_task }}
run: |
- $SETARCH make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
- timeout-minutes: 40
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ $SETARCH make -s ${{ matrix.test_task }} \
+ ${TESTS:+TESTS="$TESTS"} \
+ ${{ !contains(matrix.test_task, 'bundle') && 'RUBYOPT=-w' || '' }}
+ timeout-minutes: ${{ matrix.timeout || 40 }}
env:
- RUBY_TESTOPTS: "-q --tty=no"
- TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+
- name: make skipped tests
run: |
- $SETARCH make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
+ $SETARCH make -s test-all TESTS="${TESTS//-n!\//-n/}"
env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
- TESTS: ${{ matrix.skipped_tests }}
- if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - name: test-pc
+ run: |
+ DESTDIR=${RUNNER_TEMP-${TMPDIR-/tmp}}/installed
+ $SETARCH make test-pc "DESTDIR=$DESTDIR"
+
+ - name: CAPI extensions
+ uses: ./.github/actions/capiext
+ with:
+ builddir: build
+ make: '$SETARCH make'
+ env:
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ contains(matrix.extra_checks, 'capi') }}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}${{ matrix.os }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+ make-ibm:
+ strategy:
+ matrix:
+ include:
+ - test_task: check
+ os: ubuntu-24.04-ppc64le
+ - test_task: check
+ os: ubuntu-24.04-s390x
+ fail-fast: false
+
+ env: *make-env
+
+ runs-on: ${{ matrix.os }}
+
+ if: >-
+ ${{github.repository == 'ruby/ruby'
+ && !(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps: *make-steps
+
+ # Separated from `make` job to avoid making it a required status check
+ ruby-bench:
+ strategy:
+ matrix:
+ include:
+ # Using the same setup as ZJIT jobs
+ - bench_opts: '--warmup=1 --bench=1 --excludes=shipit'
+
+ runs-on: ubuntu-24.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc --prefix="$(pwd)/install"
+
+ - run: make install
+
+ - name: Checkout ruby-bench
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
+ repository: ruby/ruby-bench
+ persist-credentials: false
+ path: ruby-bench
+
+ # If you want to skip failing benchmark, consider using `--excludes`.
+ # e.g. `bench_opts: '--warmup=1 --bench=1 --excludes=railsbench,lobsters'`
+ - name: Run ruby-bench
+ run: ruby run_benchmarks.rb -e "ruby::../build/install/bin/ruby" ${{ matrix.bench_opts }}
+ working-directory: ruby-bench
env:
+ BUNDLER_VERSION: 0
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ruby-bench ${{ matrix.bench_opts }} ${{ matrix.ruby_opts }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml
index a57926a8b5..edb2c76c48 100644
--- a/.github/workflows/wasm.yml
+++ b/.github/workflows/wasm.yml
@@ -3,23 +3,26 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-permissions: # added using https://github.com/step-security/secure-workflows
+permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
@@ -28,40 +31,58 @@ jobs:
matrix:
entry:
# # wasmtime can't compile non-optimized Asyncified binary due to locals explosion
-# - { name: O0-debuginfo, optflags: "-O0", debugflags: "-g", wasmoptflags: "-O1" }
-# - { name: O1, optflags: "-O1", debugflags: "" , wasmoptflags: "-O1" }
- - { name: O2, optflags: "-O2", debugflags: "" , wasmoptflags: "-O2" }
-# - { name: O3, optflags: "-O3", debugflags: "" , wasmoptflags: "-O3" }
+# - { name: O0-debuginfo, optflags: '-O0', debugflags: '-g', wasmoptflags: '-O1' }
+# - { name: O1, optflags: '-O1', debugflags: '' , wasmoptflags: '-O1' }
+ - { name: O2, optflags: '-O2', debugflags: '', wasmoptflags: '-O2' }
+# - { name: O3, optflags: '-O3', debugflags: '' , wasmoptflags: '-O3' }
# # -O4 is equivalent to -O3 in clang, but it's different in wasm-opt
-# - { name: O4, optflags: "-O3", debugflags: "" , wasmoptflags: "-O4" }
-# - { name: Oz, optflags: "-Oz", debugflags: "" , wasmoptflags: "-Oz" }
+# - { name: O4, optflags: '-O3', debugflags: '' , wasmoptflags: '-O4' }
+# - { name: Oz, optflags: '-Oz', debugflags: '' , wasmoptflags: '-Oz' }
fail-fast: false
+
env:
RUBY_TESTOPTS: '-q --tty=no'
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- WASI_SDK_VERSION_MAJOR: 14
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ WASI_SDK_VERSION_MAJOR: 25
WASI_SDK_VERSION_MINOR: 0
- BINARYEN_VERSION: 109
- WASMTIME_VERSION: v0.33.0
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+ BINARYEN_VERSION: 113
+ WASMTIME_VERSION: v15.0.0
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
- path: src
+ ruby-version: '3.1'
+ bundler: none
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
- name: Install libraries
run: |
set -ex
sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y ruby bison make autoconf git wget
+ sudo apt-get install --no-install-recommends -q -y ruby make autoconf git wget
- wasi_sdk_deb="wasi-sdk_${WASI_SDK_VERSION_MAJOR}.${WASI_SDK_VERSION_MINOR}_amd64.deb"
+ wasi_sdk_deb="wasi-sdk-${WASI_SDK_VERSION_MAJOR}.${WASI_SDK_VERSION_MINOR}-x86_64-linux.deb"
wget "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION_MAJOR}/${wasi_sdk_deb}"
sudo dpkg -i "$wasi_sdk_deb"
rm -f "$wasi_sdk_deb"
@@ -78,49 +99,96 @@ jobs:
wget -O - "$binaryen_url" | tar xfz -
sudo ln -fs "$PWD/binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt" /usr/local/bin/wasm-opt
working-directory: src
+
- name: Set ENV
run: |
- echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
- - run: ./autogen.sh
+
+ - uses: ./.github/actions/setup/baseruby
+ id: baseruby
+ with:
+ srcdir: src
+
+ - name: Download config.guess with wasi version
+ run: |
+ rm tool/config.guess tool/config.sub
+ ruby tool/downloader.rb -d tool -e gnu config.guess config.sub
working-directory: src
+
- name: Run configure
- run: |
- ../src/configure \
- --host wasm32-unknown-wasi \
- --with-static-linked-ext \
- LDFLAGS=" \
- -Xlinker --stack-first \
- -Xlinker -z -Xlinker stack-size=16777216 \
- " \
- optflags="${{ matrix.entry.optflags }}" \
- debugflags="${{ matrix.entry.debugflags }}" \
- wasmoptflags="${{ matrix.entry.wasmoptflags }} ${{ matrix.entry.debugflags }}"
+ run: >-
+ ../src/configure
+ --host wasm32-unknown-wasi
+ --with-baseruby="${{ steps.baseruby.outputs.ruby }}"
+ --with-dump-ast="${{ steps.baseruby.outputs.dump_ast }}"
+ --with-static-linked-ext
+ --with-ext=${EXTS// /,}
+ LDFLAGS="
+ -Xlinker --stack-first
+ -Xlinker -z -Xlinker stack-size=16777216
+ "
+ optflags="${{ matrix.entry.optflags }}"
+ debugflags="${{ matrix.entry.debugflags }}"
+ wasmoptflags="${{ matrix.entry.wasmoptflags }} ${{ matrix.entry.debugflags }}"
+ env:
+ EXTS:
+ cgi/escape
+ continuation
+ coverage
+ date
+ digest
+ digest/*
+ erb/escape
+ etc
+ fcntl
+ json
+ json/*
+ objspace
+ rbconfig/sizeof
+ ripper
+ stringio
+ strscan
# miniruby may not be built when cross-compling
- run: make mini ruby
+
+ - run: make install DESTDIR=$PWD/../install
+ - run: tar cfz ../install.tar.gz -C ../install .
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: ruby-wasm-install
+ path: ${{ github.workspace }}/install.tar.gz
+ - name: Show Playground URL to try the build
+ run: |
+ echo "Try on Playground: https://ruby.github.io/play-ruby?run=$GITHUB_RUN_ID" >> $GITHUB_STEP_SUMMARY
+
- name: Run basictest
run: wasmtime run ./../build/miniruby --mapdir /::./ -- basictest/test.rb
working-directory: src
+
- name: Run bootstraptest (no thread)
run: |
NO_THREAD_TESTS="$(grep -L Thread -R ./bootstraptest | awk -F/ '{ print $NF }' | uniq | sed -n 's/test_\(.*\).rb/\1/p' | paste -s -d, -)"
ruby ./bootstraptest/runner.rb --ruby="$(which wasmtime) run $PWD/../build/ruby --mapdir /::./ -- " --verbose "--sets=$NO_THREAD_TESTS"
working-directory: src
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.name }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.entry.name }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ # Workaround for https://github.com/orgs/community/discussions/25220
+ - name: Save Pull Request number
+ if: ${{ github.event_name == 'pull_request' }}
+ run: echo "${{ github.event.pull_request.number }}" >> ${{ github.workspace }}/github-pr-info.txt
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ if: ${{ github.event_name == 'pull_request' }}
+ with:
+ name: github-pr-info
+ path: ${{ github.workspace }}/github-pr-info.txt
defaults:
run:
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 3011bfb0f3..13551427bb 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -3,17 +3,15 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -27,131 +25,183 @@ jobs:
strategy:
matrix:
include:
- - vs: 2019
- - vs: 2022
+ - os: 2022
+ test_task: check
+ - os: 2022
+ test_task: test-bundled-gems
+ - os: 2025-vs2026
+ test_task: check
+ - os: 2025-vs2026
+ test_task: test-bundled-gems
+ - os: 11-arm
+ test_task: 'btest test-basic test-tool' # check and test-spec are broken yet.
+ target: arm64
fail-fast: false
- runs-on: windows-${{ matrix.vs < 2022 && '2019' || matrix.vs }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- name: VisualStudio ${{ matrix.vs }}
+
+ runs-on: windows-${{ matrix.os }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/vcpkg'))
+ )}}
+
+ name: Windows ${{ matrix.os }} (${{ matrix.test_task }})
+
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- PATCH: C:\msys64\usr\bin\patch.exe
- OS_VER: windows-${{ matrix.vs < 2022 && '2019' || matrix.vs }}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ VCPKG_DEFAULT_TRIPLET: ${{ matrix.target || 'x64' }}-windows
+
steps:
- run: md build
working-directory:
- - uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # v2
- id: setup-msys2
- with:
- update: true
- install: >-
- patch
- if: ${{ env.OS_VER != 'windows-2019' }}
- - name: patch path
- shell: msys2 {0}
- run: echo PATCH=$(cygpath -wa $(command -v patch)) >> $GITHUB_ENV
- if: ${{ steps.setup-msys2.outcome == 'success' }}
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
- path: C:\vcpkg\downloads
- key: ${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-
- ${{ runner.os }}-vcpkg-download-
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ # windows-11-arm has only 3.4.1, 3.4.2, 3.4.3, head
+ ruby-version: ${{ !endsWith(matrix.os, 'arm') && '3.1' || '3.4' }}
+ bundler: none
+ windows-toolchain: none
+
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- path: C:\vcpkg\installed
- key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-
- ${{ runner.os }}-vcpkg-installed-
- - name: Install libraries with vcpkg
- run: |
- vcpkg --triplet x64-windows install libffi libyaml openssl readline zlib
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ persist-credentials: false
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
with:
- path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
- key: ${{ runner.os }}-chocolatey-${{ env.OS_VER }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-chocolatey-${{ env.OS_VER }}-
- ${{ runner.os }}-chocolatey-
- - name: Install libraries with chocolatey
+ srcdir: src
+ builddir: build
+ make-command: nmake
+ clean: true
+
+ - name: Install tools with scoop
run: |
- # Using Choco-Install for retries, but it doesn't detect failures properly
- # if you pass multiple package names in a single command.
- Choco-Install -PackageName winflexbison3
+ if ((vcpkg.exe help install) -match "manifest") { exit }
+ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
+ iwr -useb get.scoop.sh | iex
+ Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
+ scoop install vcpkg
shell: pwsh
- - name: git config
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+
+ - name: Restore vcpkg artifact
+ id: restore-vcpkg
+ uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ path: src\vcpkg_installed
+ key: windows-${{ matrix.os }}-vcpkg-${{ hashFiles('src/vcpkg.json') }}
+
+ - name: Install libraries with vcpkg
+ run: |
+ vcpkg install
+ working-directory: src
+ if: ${{ ! steps.restore-vcpkg.outputs.cache-hit }}
+
+ - name: Save vcpkg artifact
+ uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
- path: src/.downloaded-cache
- key: downloaded-cache
+ path: src\vcpkg_installed
+ key: windows-${{ matrix.os }}-vcpkg-${{ hashFiles('src/vcpkg.json') }}
+ if: ${{ ! steps.restore-vcpkg.outputs.cache-hit && (github.ref_name == 'master' || startsWith(github.ref_name, 'ruby_')) }}
+
- name: setup env
+ # Available Ruby versions: https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md#ruby
# %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
# https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
run: |
- set VS=${{ matrix.vs }}
- set VCVARS=${{ matrix.vcvars }}
- if not "%VCVARS%" == "" goto :vcset
- set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- :vcset
- set | C:\msys64\usr\bin\sort > old.env
- call %VCVARS%
- set TMP=%USERPROFILE%\AppData\Local\Temp
- set TEMP=%USERPROFILE%\AppData\Local\Temp
+ set > old.env
+ call ..\src\win32\vssetup.cmd ^
+ -arch=${{ matrix.target || 'amd64' }} ^
+ ${{ matrix.vcvars && '-vcvars_ver=' || '' }}${{ matrix.vcvars }}
+ nmake -f nul
+ set TMP=%RUNNER_TEMP%
+ set TEMP=%RUNNER_TEMP%
+ set MAKEFLAGS=l
set /a TEST_JOBS=(15 * %NUMBER_OF_PROCESSORS% / 10) > nul
- set | C:\msys64\usr\bin\sort > new.env
- C:\msys64\usr\bin\comm -13 old.env new.env >> %GITHUB_ENV%
+ set RUBY_OPT_DIR=%GITHUB_WORKSPACE:\=/%/src/vcpkg_installed/%VCPKG_DEFAULT_TRIPLET%
+ set > new.env
+
+ - name: update env
+ shell: pwsh
+ run: |
+ $old = (Get-Content old.env); $new = (Get-Content new.env)
del *.env
+ Compare-Object $old $new |
+ Where-Object { $_.SideIndicator -eq '=>' } |
+ Select-Object -ExpandProperty InputObject |
+ Add-Content -Path $env:GITHUB_ENV
+
+ - name: baseruby version
+ run: ruby -v
+
- name: compiler version
run: cl
- - name: link libraries
- run: |
- for %%I in (C:\vcpkg\installed\x64-windows\bin\*.dll) do (
- if not %%~nI == readline mklink %%~nxI %%I
- )
- for %%I in (libcrypto-1_1-x64 libssl-1_1-x64) do (
- ren c:\Windows\System32\%%I.dll %%I.dll_
- )
+
+ - name: volume info
+ run: Get-Volume
+ shell: pwsh
+
+ # TODO: We should use `../src` instead of `D:/a/ruby/ruby/src`
- name: Configure
run: >-
../src/win32/configure.bat --disable-install-doc
- --with-opt-dir=C:/vcpkg/installed/x64-windows
+ --with-opt-dir=%RUBY_OPT_DIR%
+ --with-gmp
+
+ - run: nmake prepare-vcpkg
+
- run: nmake incs
+
- run: nmake extract-extlibs
+
+ # On all other platforms, test-spec depending on extract-gems (in common.mk) is enough.
+ # But not for this Visual Studio workflow. So here we extract gems before building.
+ - run: nmake extract-gems
+
+ # windows-11-arm runner cannot run `ruby tool/file2lastrev.rb --revision.h --output=revision.h`
+ - name: make revision.h
+ run: |
+ win32\lastrev.bat | win32\ifchange.bat --timestamp=.revision.time revision.h -
+ type revision.h
+ working-directory: src
+
- run: nmake
- env:
- YACC: win_bison
- - run: nmake test
- timeout-minutes: 5
- - run: nmake test-spec
- timeout-minutes: 10
- - run: nmake test-all
- env:
- RUBY_TESTOPTS: -j${{env.TEST_JOBS}} --job-status=normal
- timeout-minutes: 60
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+
+ - name: Set up Launchable
+ uses: ./.github/actions/launchable/setup
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "VS${{ matrix.vs }} / ${{ matrix.test_task || 'check' }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
+ os: windows-${{ matrix.os }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ test-task: ${{ matrix.test_task || 'check' }}
+ continue-on-error: true
+ if: ${{ matrix.test_task != 'test-bundled-gems' }}
+ timeout-minutes: 3
+
+ - run: nmake ${{ matrix.test_task || 'check' }}
env:
+ RUBY_TESTOPTS: -j${{ env.TEST_JOBS || 4 }}
+ timeout-minutes: 70
+
+ - uses: ./.github/actions/slack
+ with:
+ label: Windows ${{ matrix.os }} / ${{ matrix.test_task || 'check' }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: windows-2025-vs2026
+ needs: [make]
+ steps:
+ - run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/wsl.yml b/.github/workflows/wsl.yml
new file mode 100644
index 0000000000..470b68fe66
--- /dev/null
+++ b/.github/workflows/wsl.yml
@@ -0,0 +1,73 @@
+name: Ubuntu on WSL
+
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+
+permissions:
+ contents: read
+
+jobs:
+ wsl:
+ runs-on: windows-2025-vs2026
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - name: Install or update WSL
+ uses: Ubuntu/WSL/.github/actions/wsl-install@main
+ with:
+ distro: Ubuntu-24.04
+
+ - name: Install dependencies
+ uses: Ubuntu/WSL/.github/actions/wsl-bash@main
+ with:
+ distro: Ubuntu-24.04
+ working-dir: /tmp/github/
+ exec: |
+ DEBIAN_FRONTEND=noninteractive sudo apt update
+ DEBIAN_FRONTEND=noninteractive sudo apt install -y ruby build-essential autoconf libssl-dev libyaml-dev zlib1g-dev libgmp-dev libffi-dev
+
+ - name: Check out the repository
+ uses: Ubuntu/WSL/.github/actions/wsl-checkout@main
+ with:
+ distro: Ubuntu-24.04
+ working-dir: /tmp/github/
+ submodules: true
+
+ - name: Build
+ uses: Ubuntu/WSL/.github/actions/wsl-bash@main
+ with:
+ distro: Ubuntu-24.04
+ working-dir: /tmp/github/
+ exec: |
+ ./autogen.sh
+ ./configure --disable-install-doc
+ make ruby -j4
+ make extract-gems
+ make -j4
+
+ - name: Test
+ uses: Ubuntu/WSL/.github/actions/wsl-bash@main
+ with:
+ distro: Ubuntu-24.04
+ working-dir: /tmp/github/
+ exec: |
+ ./ruby -v
+ # make check TESTS="-j4" MSPECOPT="-j"
diff --git a/.github/workflows/yjit-macos.yml b/.github/workflows/yjit-macos.yml
new file mode 100644
index 0000000000..b52c6355ad
--- /dev/null
+++ b/.github/workflows/yjit-macos.yml
@@ -0,0 +1,201 @@
+name: YJIT macOS
+on:
+ push:
+ branches:
+ - master
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ cargo:
+ name: cargo test
+
+ runs-on: macos-26
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - run: RUST_BACKTRACE=1 cargo test
+ working-directory: yjit
+
+ # Also compile and test with all features enabled
+ - run: RUST_BACKTRACE=1 cargo test --all-features
+ working-directory: yjit
+
+ # Check that we can build in release mode too
+ - run: cargo build --release
+ working-directory: yjit
+
+ make:
+ strategy:
+ matrix:
+ include:
+ - test_task: 'check'
+ configure: '--enable-yjit'
+ yjit_opts: '--yjit'
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
+ yjit_opts: '--yjit-call-threshold=1 --yjit-verify-ctx --yjit-code-gc'
+ specopts: '-T --yjit-call-threshold=1 -T --yjit-verify-ctx -T --yjit-code-gc'
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUN_OPTS: ${{ matrix.yjit_opts }}
+ SPECOPTS: ${{ matrix.specopts }}
+
+ runs-on: macos-26
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - name: Install libraries
+ uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc ${{ matrix.configure }}
+
+ - run: make prepare-gems
+ if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
+ - run: make
+
+ - name: Verify that --yjit-dump-disasm works
+ run: |
+ ./miniruby --yjit-call-threshold=1 --yjit-dump-disasm -e0 | \
+ wc -l | \
+ ruby -ne 'raise "Disassembly seems broken in dev build (output has too few lines)" unless $_.to_i > 10'
+ if: ${{ contains(matrix.configure, 'jit=dev') }}
+
+ - name: Set ENV for YJIT
+ run: |
+ echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
+ echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV
+
+ - name: Set test options for skipped tests
+ run: |
+ set -x
+ TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
+ echo "TESTS=${TESTS}" >> $GITHUB_ENV
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: macos-26
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ is-yjit: true
+ continue-on-error: true
+ timeout-minutes: 3
+
+ - name: make ${{ matrix.test_task }}
+ run: |
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ set -x
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
+ RUN_OPTS="$RUN_OPTS" \
+ SPECOPTS="$SPECOPTS"
+ timeout-minutes: 60
+ env:
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ SYNTAX_SUGGEST_TIMEOUT: '5'
+ PRECHECK_BUNDLED_GEMS: 'no'
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+ continue-on-error: ${{ matrix.continue-on-test_task || false }}
+
+ - name: make skipped tests
+ run: |
+ make -s test-all TESTS="${TESTS//-n!\//-n/}"
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ PRECHECK_BUNDLED_GEMS: 'no'
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
+ continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
+
+ - name: Dump crash logs
+ if: ${{ failure() }}
+ continue-on-error: true
+ run: |
+ tail --verbose --lines=+1 rb_crash_*.txt
+ exit 1
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }} ${{ matrix.yjit_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - name: ${{ github.workflow }} jobs have failed
+ run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/yjit-ubuntu.yml b/.github/workflows/yjit-ubuntu.yml
index 13ebb491bf..934c3f56d4 100644
--- a/.github/workflows/yjit-ubuntu.yml
+++ b/.github/workflows/yjit-ubuntu.yml
@@ -3,17 +3,15 @@ on:
push:
paths-ignore:
- 'doc/**'
- - '**/man'
+ - '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -24,147 +22,223 @@ permissions:
jobs:
cargo:
- name: Rust cargo test
+ name: cargo test
+
# GitHub Action's image seems to already contain a Rust 1.58.0.
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
steps:
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
# For now we can't run cargo test --offline because it complains about the
# capstone dependency, even though the dependency is optional
#- run: cargo test --offline
+
- run: RUST_BACKTRACE=1 cargo test
working-directory: yjit
+
# Also compile and test with all features enabled
- run: RUST_BACKTRACE=1 cargo test --all-features
working-directory: yjit
+
# Check that we can build in release mode too
- run: cargo build --release
working-directory: yjit
+
lint:
- name: Rust lint
+ name: cargo clippy
+
# GitHub Action's image seems to already contain a Rust 1.58.0.
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
steps:
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
# Check that we don't have linting errors in release mode, too
- run: cargo clippy --all-targets --all-features
working-directory: yjit
+
make:
strategy:
fail-fast: false
matrix:
include:
- - test_task: "yjit-bindgen"
- hint: "To fix: use patch in logs"
- configure: "--with-gcc=clang-12 --enable-yjit=dev"
+ - test_task: 'yjit-bindgen'
+ hint: 'To fix: use patch in logs'
+ # Build with YJIT+ZJIT for output that works in the most number of configurations
+ configure: '--with-gcc=clang-14 --enable-yjit=dev --enable-zjit'
+ libclang_path: '/usr/lib/llvm-14/lib/libclang.so.1'
- - test_task: "check"
+ - test_task: 'check'
# YJIT should be automatically built in release mode on x86-64 Linux with rustc present
#configure: "--enable-yjit RUSTC='rustc +1.58.0'"
configure: "RUSTC='rustc +1.58.0'"
- rust_version: "1.58.0"
+ rust_version: '1.58.0'
- - test_task: "check"
- configure: "--enable-yjit=dev"
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
- - test_task: "check"
- configure: "--enable-yjit=dev"
- yjit_opts: "--yjit-call-threshold=1 --yjit-verify-ctx"
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
+ yjit_opts: '--yjit-call-threshold=1 --yjit-verify-ctx --yjit-code-gc'
+ specopts: '-T --yjit-call-threshold=1 -T --yjit-verify-ctx -T --yjit-code-gc'
- - test_task: "test-all TESTS=--repeat-count=2"
- configure: "--enable-yjit=dev"
+ - test_task: 'test-bundled-gems'
+ configure: '--enable-yjit=dev'
- - test_task: "test-bundled-gems"
- configure: "--enable-yjit=dev"
-
- - test_task: "yjit-bench"
- configure: "--enable-yjit=dev"
- yjit_bench_opts: "--yjit-stats"
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUN_OPTS: ${{ matrix.yjit_opts }}
YJIT_BENCH_OPTS: ${{ matrix.yjit_bench_opts }}
+ SPECOPTS: ${{ matrix.specopts }}
RUBY_DEBUG: ci
- BUNDLE_JOBS: 8 # for yjit-bench
RUST_BACKTRACE: 1
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.1'
+ bundler: none
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
- name: Install Rust
if: ${{ matrix.rust_version }}
run: rustup install ${{ matrix.rust_version }} --profile minimal
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- with:
- path: src
- - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
+
+ - name: Remove cargo
+ # Since this tests a `rustc` build for release, remove `cargo` to ensure
+ # that only `rustc` is used.
+ if: ${{ contains(matrix.configure, 'rustc') }}
+ run: sudo rm $(which -a cargo | uniq)
+
- name: Run configure
run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install ${{ matrix.configure }}
+
- run: make incs
+
- run: make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
- - run: make -j
- - run: make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
- - name: Create dummy files in build dir
+
+ - run: make
+
+ - name: Verify that --yjit-dump-disasm works
+ run: |
+ ./miniruby --yjit-call-threshold=1 --yjit-dump-disasm -e0 | \
+ wc -l | \
+ ruby -ne 'raise "Disassembly seems broken in dev build (output has too few lines)" unless $_.to_i > 10'
+ if: ${{ contains(matrix.configure, 'jit=dev') }}
+
+ - name: Set ENV for YJIT
run: |
- ./miniruby -e '(("a".."z").to_a+("A".."Z").to_a+("0".."9").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}'
- if: ${{ matrix.test_task == 'check' }}
- - name: Enable YJIT through ENV
- run: echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
+ echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
+ echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV
+
# Check that the binary was built with YJIT
- name: Check YJIT enabled
run: ./miniruby --yjit -v | grep "+YJIT"
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: ubuntu-22.04
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ is-yjit: true
+ continue-on-error: true
+ timeout-minutes: 3
+
- name: make ${{ matrix.test_task }}
- run: make -s -j ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" YJIT_BENCH_OPTS="$YJIT_BENCH_OPTS"
- timeout-minutes: 60
- env:
- RUBY_TESTOPTS: "-q --tty=no"
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
- continue-on-error: ${{ matrix.test_task == 'yjit-bench' }}
- - name: Show ${{ github.event.pull_request.base.ref }} GitHub URL for yjit-bench comparison
- run: echo "https://github.com/${BASE_REPO}/commit/${BASE_SHA}"
+ run: |
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ set -x
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
+ RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug SPECOPTS="$SPECOPTS" \
+ YJIT_BENCH_OPTS="$YJIT_BENCH_OPTS" YJIT_BINDGEN_DIFF_OPTS="$YJIT_BINDGEN_DIFF_OPTS"
+ timeout-minutes: 90
env:
- BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
- BASE_SHA: ${{ github.event.pull_request.base.sha }}
- if: ${{ matrix.test_task == 'yjit-bench' && startsWith(github.event_name, 'pull') }}
- - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+ SYNTAX_SUGGEST_TIMEOUT: '5'
+ YJIT_BINDGEN_DIFF_OPTS: '--exit-code'
+ LIBCLANG_PATH: ${{ matrix.libclang_path }}
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+ continue-on-error: ${{ matrix.continue-on-test_task || false }}
+
+ - name: Dump crash logs
+ if: ${{ failure() }}
+ continue-on-error: true
+ run: |
+ tail --verbose --lines=+1 rb_crash_*.txt
+ exit 1
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.configure }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/zjit-macos.yml b/.github/workflows/zjit-macos.yml
new file mode 100644
index 0000000000..e68bd897fd
--- /dev/null
+++ b/.github/workflows/zjit-macos.yml
@@ -0,0 +1,239 @@
+name: ZJIT macOS
+on:
+ push:
+ branches:
+ - master
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - test_task: 'check'
+ run_opts: '--zjit-call-threshold=1'
+ specopts: '-T --zjit-call-threshold=1'
+ configure: '--enable-zjit=dev'
+
+ - test_task: 'check'
+ run_opts: '--zjit-disable-hir-opt --zjit-call-threshold=1'
+ specopts: '-T --zjit-disable-hir-opt -T --zjit-call-threshold=1'
+ configure: '--enable-zjit=dev'
+
+ - test_task: 'zjit-check' # zjit-test + quick feedback of test_zjit.rb
+ configure: '--enable-yjit=dev --enable-zjit'
+ rust_version: "1.85.0"
+
+ - test_task: 'ruby'
+ hint: 'combo build test'
+ configure: '--enable-yjit --enable-zjit'
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUN_OPTS: ${{ matrix.run_opts }}
+ SPECOPTS: ${{ matrix.specopts }}
+ TESTOPTS: ${{ matrix.testopts }}
+ RUST_BACKTRACE: 1
+ ZJIT_RB_BUG: 1
+
+ runs-on: macos-26
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - name: Install libraries
+ uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
+ - name: Install Rust
+ if: ${{ matrix.rust_version }}
+ run: |
+ rustup install ${{ matrix.rust_version }} --profile minimal
+ rustup default ${{ matrix.rust_version }}
+
+ - uses: taiki-e/install-action@e49978b799e49ff429d162b7a30601a569ab6538 # v2.81.1
+ with:
+ tool: nextest@0.9
+ if: ${{ matrix.test_task == 'zjit-check' }}
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc ${{ matrix.configure }}
+
+ - run: make
+
+ - name: Verify that --zjit-dump-disasm works
+ run: |
+ ./miniruby --zjit-call-threshold=1 --zjit-dump-disasm -e0 | \
+ wc -l | \
+ ruby -ne 'raise "Disassembly seems broken in dev build (output has too few lines)" unless $_.to_i > 10'
+ if: ${{ contains(matrix.configure, 'jit=dev') }}
+
+ - name: Set ENV for ZJIT
+ run: |
+ echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: macos-26
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ is-zjit: true
+ continue-on-error: true
+ timeout-minutes: 3
+
+ - name: make ${{ matrix.test_task }}
+ run: |
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ set -x
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
+ RUN_OPTS="$RUN_OPTS" \
+ SPECOPTS="$SPECOPTS" \
+ TESTOPTS="$TESTOPTS"
+ timeout-minutes: 60
+ env:
+ RUBY_TESTOPTS: '-q --tty=no'
+ EXCLUDES: '../src/test/.excludes-zjit'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ SYNTAX_SUGGEST_TIMEOUT: '30'
+ PRECHECK_BUNDLED_GEMS: 'no'
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+ continue-on-error: ${{ matrix.continue-on-test_task || false }}
+
+ - name: Dump crash logs
+ if: ${{ failure() }}
+ continue-on-error: true
+ run: |
+ tail --verbose --lines=+1 rb_crash_*.txt
+ exit 1
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
+
+ # Separated from `make` job to avoid making it a required status check for now
+ ruby-bench:
+ strategy:
+ matrix:
+ include:
+ # Test --call-threshold=2 with 2 iterations in total
+ - ruby_opts: '--zjit-call-threshold=2'
+ bench_opts: '--warmup=1 --bench=1 --excludes=shipit'
+ configure: '--enable-zjit=dev_nodebug' # --enable-zjit=dev is too slow
+
+ runs-on: macos-26
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc --prefix="$(pwd)/install" ${{ matrix.configure }}
+
+ - run: make install
+
+ # setup/directories set MAKEFLAGS=-j4 for macOS, which randomly fails sqlite3.gem builds
+ - name: Unset MAKEFLAGS
+ run: echo "MAKEFLAGS=" >> "$GITHUB_ENV"
+
+ - name: Checkout ruby-bench
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+ repository: ruby/ruby-bench
+ path: ruby-bench
+
+ # If you want to skip failing benchmark, consider using `--excludes`.
+ # e.g. `bench_opts: '--warmup=1 --bench=1 --excludes=railsbench,lobsters'`
+ - name: Run ruby-bench
+ run: ruby run_benchmarks.rb -e "zjit::../build/install/bin/ruby ${{ matrix.ruby_opts }}" ${{ matrix.bench_opts }}
+ working-directory: ruby-bench
+ env:
+ BUNDLER_VERSION: 0
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ruby-bench ${{ matrix.bench_opts }} ${{ matrix.ruby_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/zjit-ubuntu.yml b/.github/workflows/zjit-ubuntu.yml
new file mode 100644
index 0000000000..8d146b7bdc
--- /dev/null
+++ b/.github/workflows/zjit-ubuntu.yml
@@ -0,0 +1,293 @@
+name: ZJIT Ubuntu
+on:
+ push:
+ branches:
+ - master
+ paths-ignore:
+ - 'doc/**'
+ - '**/man/*'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ name: cargo clippy
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - run: cargo clippy --all-targets --all-features
+ working-directory: zjit
+
+ make:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - test_task: 'check'
+ run_opts: '--zjit-call-threshold=1'
+ specopts: '-T --zjit-call-threshold=1'
+ configure: '--enable-zjit=dev'
+
+ - test_task: 'check'
+ run_opts: '--zjit-disable-hir-opt --zjit-call-threshold=1'
+ specopts: '-T --zjit-disable-hir-opt -T --zjit-call-threshold=1'
+ configure: '--enable-zjit=dev'
+
+ # The optimizer benefits from at least 1 iteration of profiling. Also, many
+ # regression tests in bootstraptest/test_yjit.rb assume call-threshold=2.
+ - test_task: 'btest'
+ run_opts: '--zjit-call-threshold=2'
+ configure: '--enable-zjit=dev'
+
+ - test_task: 'zjit-check' # zjit-test + quick feedback of test_zjit.rb
+ configure: '--enable-yjit --enable-zjit=dev'
+ rust_version: '1.85.0'
+
+ - test_task: 'zjit-bindgen'
+ hint: 'To fix: use patch in logs'
+ # Build with YJIT+ZJIT for output that works in the most number of configurations
+ configure: '--enable-zjit=dev --enable-yjit --with-gcc=clang-16'
+ clang_path: '/usr/bin/clang-16'
+ runs-on: 'ubuntu-24.04' # for clang-16
+
+ - test_task: 'test-bundled-gems'
+ configure: '--enable-zjit=dev'
+ run_opts: '--zjit-call-threshold=1'
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUN_OPTS: ${{ matrix.run_opts }}
+ YJIT_BENCH_OPTS: ${{ matrix.yjit_bench_opts }}
+ SPECOPTS: ${{ matrix.specopts }}
+ TESTOPTS: ${{ matrix.testopts }}
+ RUBY_DEBUG: ci
+ BUNDLE_JOBS: 8 # for yjit-bench
+ RUST_BACKTRACE: 1
+ ZJIT_RB_BUG: 1
+
+ runs-on: ${{ matrix.runs-on || 'ubuntu-22.04' }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
+ with:
+ ruby-version: '3.1'
+ bundler: none
+
+ - uses: taiki-e/install-action@e49978b799e49ff429d162b7a30601a569ab6538 # v2.81.1
+ with:
+ tool: nextest@0.9
+ if: ${{ matrix.test_task == 'zjit-check' }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+ # Set fetch-depth: 10 so that Launchable can receive commits information.
+ fetch-depth: 10
+
+ - name: Install Rust
+ if: ${{ matrix.rust_version }}
+ run: |
+ rustup install ${{ matrix.rust_version }} --profile minimal
+ rustup default ${{ matrix.rust_version }}
+
+ - name: Install rustfmt
+ if: ${{ matrix.test_task == 'zjit-bindgen' }}
+ run: rustup component add rustfmt
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install ${{ matrix.configure }}
+
+ - run: make incs
+
+ - run: make prepare-gems
+ if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
+ - run: make
+
+ - name: Verify that --zjit-dump-disasm works
+ run: |
+ ./miniruby --zjit-call-threshold=1 --zjit-dump-disasm -e0 | \
+ wc -l | \
+ ruby -ne 'raise "Disassembly seems broken in dev build (output has too few lines)" unless $_.to_i > 10'
+ if: ${{ contains(matrix.configure, 'jit=dev') }}
+
+ # Check that the binary was built with ZJIT
+ - name: Check ZJIT enabled
+ run: ./miniruby --zjit -v | grep "+ZJIT"
+ if: ${{ matrix.configure != '--disable-zjit' }}
+
+ - name: Set ENV for ZJIT
+ run: |
+ echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV
+
+ - name: Set up Launchable
+ id: launchable
+ uses: ./.github/actions/launchable/setup
+ with:
+ os: ${{ matrix.runs-on || 'ubuntu-22.04' }}
+ test-opts: ${{ matrix.configure }}
+ launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
+ builddir: build
+ srcdir: src
+ is-zjit: true
+ continue-on-error: true
+ timeout-minutes: 3
+
+ - name: make ${{ matrix.test_task }}
+ run: |
+ test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
+ test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")
+
+ set -x
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
+ RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug SPECOPTS="$SPECOPTS" \
+ TESTOPTS="$TESTOPTS" \
+ ZJIT_BINDGEN_DIFF_OPTS="$ZJIT_BINDGEN_DIFF_OPTS"
+ timeout-minutes: 90
+ env:
+ RUBY_TESTOPTS: '-q --tty=no'
+ EXCLUDES: '../src/test/.excludes-zjit'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+ SYNTAX_SUGGEST_TIMEOUT: '30'
+ ZJIT_BINDGEN_DIFF_OPTS: '--exit-code'
+ CLANG_PATH: ${{ matrix.clang_path }}
+ LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
+ LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
+ continue-on-error: ${{ matrix.continue-on-test_task || false }}
+
+ - name: Dump crash logs
+ if: ${{ failure() }}
+ continue-on-error: true
+ run: |
+ tail --verbose --lines=+1 rb_crash_*.txt
+ exit 1
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-22.04
+ needs: [make]
+ steps:
+ - name: ${{ github.workflow }} jobs have failed
+ run: exit 1
+ working-directory:
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
+
+ # Separated from `make` job to avoid making it a required status check for now
+ ruby-bench:
+ strategy:
+ matrix:
+ include:
+ # Test --call-threshold=2 with 2 iterations in total
+ - ruby_opts: '--zjit-call-threshold=2'
+ bench_opts: '--warmup=1 --bench=1 --excludes=shipit'
+ configure: '--enable-zjit=dev_nodebug' # --enable-zjit=dev is too slow
+
+ runs-on: ubuntu-24.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event.pull_request.user.login == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/cargo'))
+ )}}
+
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc --prefix="$(pwd)/install" ${{ matrix.configure }}
+
+ - run: make install
+
+ - name: Checkout ruby-bench
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ repository: ruby/ruby-bench
+ persist-credentials: false
+ path: ruby-bench
+
+ # If you want to skip failing benchmark, consider using `--excludes`.
+ # e.g. `bench_opts: '--warmup=1 --bench=1 --excludes=railsbench,lobsters'`
+ - name: Run ruby-bench
+ run: ruby run_benchmarks.rb -e "zjit::../build/install/bin/ruby ${{ matrix.ruby_opts }}" ${{ matrix.bench_opts }}
+ working-directory: ruby-bench
+ env:
+ BUNDLER_VERSION: 0
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ruby-bench ${{ matrix.bench_opts }} ${{ matrix.ruby_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/zizmor.yml b/.github/zizmor.yml
new file mode 100644
index 0000000000..65b67fb6c8
--- /dev/null
+++ b/.github/zizmor.yml
@@ -0,0 +1,26 @@
+# Ignore existing findings (baseline)
+# Composite action findings are suppressed inline with # zizmor: ignore
+rules:
+ dangerous-triggers:
+ ignore:
+ - auto_request_review.yml
+ - auto_review_pr.yml
+ - labeler.yml
+ - pr-playground.yml
+ dependabot-cooldown:
+ ignore:
+ - dependabot.yml
+ misfeature:
+ ignore:
+ - mingw.yml
+ - tarball-windows.yml
+ - windows.yml
+ unpinned-images:
+ ignore:
+ - compilers.yml
+ secrets-outside-env:
+ # All committers with write access are trusted; no need for environment-scoped secrets.
+ disable: true
+ unpinned-uses:
+ ignore:
+ - wsl.yml
diff --git a/.gitignore b/.gitignore
index ca1783479d..7ead3a81f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@
*.pch
*.pdb
*.rbinc
+*.rbbin
*.rej
*.s
*.sav
@@ -96,6 +97,7 @@ lcov*.info
/enc.mk
/encdb.h
/exts.mk
+/gc/*/exts.mk
/goruby
/id.[ch]
/largefile.h
@@ -138,12 +140,12 @@ lcov*.info
/test.rb
/test-coverage.dat
/tmp
+/vcpkg_installed
/transdb.h
/uncommon.mk
/verconf.h
/verconf.mk
/web
-/yasmdata.rb
# /bin/
@@ -166,6 +168,7 @@ lcov*.info
# /coroutine/
!/coroutine/**/*.s
+!/coroutine/**/*.S
# /enc/trans/
/enc/trans/*.c
@@ -205,8 +208,10 @@ lcov*.info
# /ext/ripper/
/ext/ripper/eventids1.c
+/ext/ripper/eventids1.h
/ext/ripper/.eventids2-check
/ext/ripper/eventids2table.c
+/ext/ripper/ripper_init.c
/ext/ripper/ripper.*
/ext/ripper/ids1
/ext/ripper/ids2
@@ -228,7 +233,7 @@ lcov*.info
# /misc/
/misc/**/__pycache__
-# /spec/bundler
+# for `make test-bundler`
/.rspec_status
# /tool/
@@ -238,16 +243,49 @@ lcov*.info
# /win32/
/win32/*.ico
-# RJIT
-/include/ruby-*/*/rb_rjit_min_header-*.h
-/lib/ruby_vm/rjit/instruction.rb
-/lib/ruby_vm/rjit/instruction.rb
-/rjit_config.h
-/rb_rjit_header.h*
# YJIT
/yjit-bench
/yjit_exit_locations.dump
+# Rust
+/target
+
# /wasm/
/wasm/tests/*.wasm
+
+# prism
+/lib/prism/compiler.rb
+/lib/prism/dispatcher.rb
+/lib/prism/dot_visitor.rb
+/lib/prism/dsl.rb
+/lib/prism/inspect_visitor.rb
+/lib/prism/mutation_compiler.rb
+/lib/prism/node.rb
+/lib/prism/reflection.rb
+/lib/prism/serialize.rb
+/lib/prism/visitor.rb
+/prism/internal/diagnostic.h
+/prism/api_node.c
+/prism/ast.h
+/prism/diagnostic.c
+/prism/json.c
+/prism/node.c
+/prism/prettyprint.c
+/prism/serialize.c
+/prism/tokens.c
+/prism/srcs.mk
+/dump_ast
+
+# prism (old file)
+/prism/token_type.c
+
+# tool/update-NEWS-gemlist.rb
+/bundled_gems.json
+/default_gems.json
+/gems/default_gems
+
+# AI agents
+/.claude
+/AGENTS.md
+/CLAUDE.md
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000000..213a0f4916
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,431 @@
+git[bot] <svn-admin@ruby-lang.org>
+git[bot] <svn-admin@ruby-lang.org> git <svn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+svn[bot] <svn-admin@ruby-lang.org> svn <svn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# a_matsuda
+Akira Matsuda <ronnie@dio.jp>
+Akira Matsuda <ronnie@dio.jp> <a_matsuda@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# aamine
+Minero Aoki <aamine@loveruby.net>
+Minero Aoki <aamine@loveruby.net> <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# akira
+akira yamada <akira@ruby-lang.org>
+## akira yamada <akira@ruby-lang.org> <akira@rice.p.arika.org>
+akira yamada <akira@ruby-lang.org> <akira@arika.org>
+akira yamada <akira@ruby-lang.org> <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# akiyoshi
+AKIYOSHI, Masamichi <masamichi.akiyoshi@hp.com>
+AKIYOSHI, Masamichi <masamichi.akiyoshi@hp.com> <akiyoshi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# akr
+Tanaka Akira <akr@fsij.org>
+Tanaka Akira <akr@fsij.org> <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# arai
+Koji Arai <jca02266@nifty.ne.jp>
+Koji Arai <jca02266@nifty.ne.jp> <arai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# arton
+Akio Tajima <artonx@yahoo.co.jp>
+Akio Tajima <artonx@yahoo.co.jp> <arton@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# aycabta
+aycabta <aycabta@gmail.com>
+aycabta <aycabta@gmail.com> <aycabta@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ayumin
+Ayumu AIZAWA <ayumu.aizawa@gmail.com>
+Ayumu AIZAWA <ayumu.aizawa@gmail.com> <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# azav
+Alexander Zavorine <alexandre.zavorine@nokia.com>
+Alexander Zavorine <alexandre.zavorine@nokia.com> <azav@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# charliesome
+Charlie Somerville <charliesome@ruby-lang.org>
+Charlie Somerville <charliesome@ruby-lang.org> <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# dave
+Dave Thomas <dave@pragprog.com>
+Dave Thomas <dave@pragprog.com> <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# davidflanagan
+David Flanagan <davidflanagan@ruby-lang.org>
+David Flanagan <davidflanagan@ruby-lang.org> <david@think32>
+David Flanagan <davidflanagan@ruby-lang.org> <david@davidflanagan.com>
+David Flanagan <davidflanagan@ruby-lang.org> <davidflanagan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# dblack
+David A. Black <dblack@rubypal.com>
+David A. Black <dblack@rubypal.com> <dblack@wobblini.net>
+David A. Black <dblack@rubypal.com> <dblack@superlink.net>
+David A. Black <dblack@rubypal.com> <dblack@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# drbrain
+Eric Hodel <drbrain@segment7.net>
+Eric Hodel <drbrain@segment7.net> <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# duerst
+Martin Dürst <duerst@it.aoyama.ac.jp>
+Martin Dürst <duerst@it.aoyama.ac.jp> <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# eban
+WATANABE Hirofumi <eban@ruby-lang.org>
+WATANABE Hirofumi <eban@ruby-lang.org> <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# emboss
+Martin Bosslet <Martin.Bosslet@gmail.com>
+Martin Bosslet <Martin.Bosslet@gmail.com> <Martin.Bosslet@googlemail.com>
+Martin Bosslet <Martin.Bosslet@gmail.com> <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# eregon
+Benoit Daloze <eregontp@gmail.com>
+Benoit Daloze <eregontp@gmail.com> <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# evan
+Evan Phoenix <evan@ruby-lang.org>
+Evan Phoenix <evan@ruby-lang.org> <evan@fallingsnow.net>
+Evan Phoenix <evan@ruby-lang.org> <evan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# glass
+Masaki Matsushita <glass.saga@gmail.com>
+Masaki Matsushita <glass.saga@gmail.com> <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# gogotanaka
+Kazuki Tanaka <gogotanaka@ruby-lang.org>
+Kazuki Tanaka <gogotanaka@ruby-lang.org> <gogotanaka@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# gotoken
+Kentaro Goto <gotoken@gmail.com>
+Kentaro Goto <gotoken@gmail.com> <gotoken@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# gotoyuzo
+GOTOU Yuuzou <gotoyuzo@notwork.org>
+GOTOU Yuuzou <gotoyuzo@notwork.org> <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# gsinclair
+Gavin Sinclair <gsinclair@soyabean.com.au>
+Gavin Sinclair <gsinclair@soyabean.com.au> <gsinclair@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# H_Konishi
+KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+KONISHI Hiromasa <konishih@fd6.so-net.ne.jp> <H_Konishi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# headius
+Charles Oliver Nutter <headius@headius.com>
+Charles Oliver Nutter <headius@headius.com> <headius@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# hone
+Terence Lee <hone@heroku.com>
+Terence Lee <hone@heroku.com> <hone@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# hsbt
+Hiroshi SHIBATA <hsbt@ruby-lang.org>
+Hiroshi SHIBATA <hsbt@ruby-lang.org> <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# iwamatsu
+Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+Nobuhiro Iwamatsu <iwamatsu@nigauri.org> <iwamatsu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# jeg2
+James Edward Gray II <james@graysoftinc.com>
+James Edward Gray II <james@graysoftinc.com> <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# jim
+Jim Weirich <jim@tardis.local>
+Jim Weirich <jim@tardis.local> <jim@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# k0kubun
+Takashi Kokubun <takashikkbn@gmail.com>
+Takashi Kokubun <takashikkbn@gmail.com> <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kanemoto
+Yutaka Kanemoto <kanemoto@ruby-lang.org>
+Yutaka Kanemoto <kanemoto@ruby-lang.org> <kanemoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# katsu
+UENO Katsuhiro <katsu@blue.sky.or.jp>
+UENO Katsuhiro <katsu@blue.sky.or.jp> <katsu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kazu
+Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+Kazuhiro NISHIYAMA <zn@mbf.nifty.com> <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# keiju
+Keiju Ishitsuka <keiju@ishitsuka.com>
+Keiju Ishitsuka <keiju@ishitsuka.com> <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# knu
+Akinori MUSHA <knu@iDaemons.org>
+Akinori MUSHA <knu@iDaemons.org> <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ko1
+Koichi Sasada <ko1@atdot.net>
+Koichi Sasada <ko1@atdot.net> <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kosaki
+KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+KOSAKI Motohiro <kosaki.motohiro@gmail.com> <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kosako
+K.Kosako <sndgk393@ybb.ne.jp>
+K.Kosako <sndgk393@ybb.ne.jp> <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kou
+Sutou Kouhei <kou@clear-code.com>
+Sutou Kouhei <kou@clear-code.com> <kou@cozmixng.org>
+Sutou Kouhei <kou@clear-code.com> <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# kouji
+Kouji Takao <kouji.takao@gmail.com>
+Kouji Takao <kouji.takao@gmail.com> <kouji@takao7.net>
+Kouji Takao <kouji.takao@gmail.com> <kouji@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ksaito
+Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Kazuo Saito <ksaito@uranus.dti.ne.jp> <ksaito@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ktsj
+Kazuki Tsujimoto <kazuki@callcc.net>
+Kazuki Tsujimoto <kazuki@callcc.net> <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# luislavena
+Luis Lavena <luislavena@gmail.com>
+Luis Lavena <luislavena@gmail.com> <luislavena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# mame
+Yusuke Endoh <mame@ruby-lang.org>
+## Yusuke Endoh <mame@ruby-lang.org> <mame@tsg.ne.jp>
+Yusuke Endoh <mame@ruby-lang.org> <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# marcandre
+Marc-Andre Lafortune <github@marc-andre.ca>
+Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+Marc-Andre Lafortune <ruby-core@marc-andre.ca> <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# matz
+Yukihiro "Matz" Matsumoto <matz@ruby.or.jp>
+Yukihiro "Matz" Matsumoto <matz@ruby.or.jp> <matz@ruby-lang.org>
+Yukihiro "Matz" Matsumoto <matz@ruby.or.jp> <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# michal
+Michal Rokos <michal@ruby-lang.org>
+Michal Rokos <michal@ruby-lang.org> <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# mneumann
+Michael Neumann <mneumann@ruby-lang.org>
+Michael Neumann <mneumann@ruby-lang.org> <mneumann@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# mrkn
+Kenta Murata <mrkn@mrkn.jp>
+Kenta Murata <mrkn@mrkn.jp> <muraken@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+Kenta Murata <mrkn@mrkn.jp> <3959+mrkn@users.noreply.github.com>
+Kenta Murata <mrkn@mrkn.jp> <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# nagachika
+nagachika <nagachika@ruby-lang.org>
+nagachika <nagachika@ruby-lang.org> <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# nagai
+Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# nahi
+Hiroshi Nakamura <nahi@ruby-lang.org>
+Hiroshi Nakamura <nahi@ruby-lang.org> <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# nari
+Narihiro Nakamura <authornari@gmail.com>
+Narihiro Nakamura <authornari@gmail.com> <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# naruse
+NARUSE, Yui <naruse@airemix.jp>
+NARUSE, Yui <naruse@airemix.jp> <naruse@ruby-lang.org>
+NARUSE, Yui <naruse@airemix.jp> <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ngoto
+Naohisa Goto <ngotogenome@gmail.com>
+Naohisa Goto <ngotogenome@gmail.com> <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# nobu
+Nobuyoshi Nakada <nobu@ruby-lang.org>
+Nobuyoshi Nakada <nobu@ruby-lang.org> <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# normal
+Eric Wong <normal@ruby-lang.org>
+Eric Wong <normal@ruby-lang.org> <e@80x24.org>
+Eric Wong <normal@ruby-lang.org> <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ntalbott
+Nathaniel Talbott <ntalbott@ruby-lang.org>
+Nathaniel Talbott <ntalbott@ruby-lang.org> <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ocean
+Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# odaira
+Rei Odaira <rodaira@us.ibm.com>
+Rei Odaira <rodaira@us.ibm.com> <Rei.Odaira@gmail.com>
+Rei Odaira <rodaira@us.ibm.com> <odaira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# okkez
+okkez <okkez000@gmail.com>
+okkez <okkez000@gmail.com> <okkez@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# rhe
+Kazuki Yamaguchi <k@rhe.jp>
+Kazuki Yamaguchi <k@rhe.jp> <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ryan
+Ryan Davis <ryand-github@zenspider.com>
+Ryan Davis <ryand-github@zenspider.com> <ryand-ruby@zenspider.com>
+Ryan Davis <ryand-github@zenspider.com> <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# samuel
+Samuel Williams <samuel.williams@oriontransfer.co.nz>
+Samuel Williams <samuel.williams@oriontransfer.co.nz> <samuel@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# seki
+Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ser
+Sean Russell <ser@germane-software.com>
+Sean Russell <ser@germane-software.com> <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# shigek
+Shigeo Kobayashi <shigek@ruby-lang.org>
+Shigeo Kobayashi <shigek@ruby-lang.org> <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# shirosaki
+Hiroshi Shirosaki <h.shirosaki@gmail.com>
+Hiroshi Shirosaki <h.shirosaki@gmail.com> <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# sho-h
+Sho Hashimoto <sho-h@ruby-lang.org>
+Sho Hashimoto <sho-h@ruby-lang.org> <sho-h@netlab.jp>
+Sho Hashimoto <sho-h@ruby-lang.org> <sho.hsmt@gmail.com>
+Sho Hashimoto <sho-h@ruby-lang.org> <sho-h@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# shugo
+Shugo Maeda <shugo@ruby-lang.org>
+Shugo Maeda <shugo@ruby-lang.org> <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# shyouhei
+åœéƒ¨æ˜Œå¹³ <shyouhei@ruby-lang.org>
+åœéƒ¨æ˜Œå¹³ <shyouhei@ruby-lang.org> <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# siena
+Siena. <siena@faculty.chiba-u.jp>
+Siena. <siena@faculty.chiba-u.jp> <siena@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# sonots
+sonots <sonots@gmail.com>
+sonots <sonots@gmail.com> <sonots@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# sorah
+Sorah Fukumori <her@sorah.jp>
+Sorah Fukumori <her@sorah.jp> <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# stomar
+Marcus Stollsteimer <sto.mar@web.de>
+Marcus Stollsteimer <sto.mar@web.de> <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# suke
+Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Masaki Suketa <masaki.suketa@nifty.ne.jp> <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# tadd
+Tadashi Saito <tad.a.digger@gmail.com>
+Tadashi Saito <tad.a.digger@gmail.com> <tadd@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# tadf
+Tadayoshi Funaba <tadf@dotrb.org>
+Tadayoshi Funaba <tadf@dotrb.org> <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# takano32
+TAKANO Mitsuhiro <takano32@gmail.com>
+TAKANO Mitsuhiro <takano32@gmail.com> <takano32@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# tarui
+Masaya Tarui <tarui@ruby-lang.org>
+Masaya Tarui <tarui@ruby-lang.org> <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# technorama
+Technorama Ltd. <oss-ruby@technorama.net>
+Technorama Ltd. <oss-ruby@technorama.net> <technorama@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# tenderlove
+Aaron Patterson <tenderlove@ruby-lang.org>
+Aaron Patterson <tenderlove@ruby-lang.org> <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# tmm1
+Aman Gupta <ruby@tmm1.net>
+Aman Gupta <ruby@tmm1.net> <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ts
+Guy Decoux <ts@moulon.inra.fr>
+Guy Decoux <ts@moulon.inra.fr> <ts@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# ttate
+Takaaki Tateishi <ttate@ttsky.net>
+## Takaaki Tateishi <ttate@ttsky.net> <ttate@kt.jaist.ac.jp>
+Takaaki Tateishi <ttate@ttsky.net> <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# uema2
+Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+Takaaki Uematsu <uema2x@jcom.home.ne.jp> <uema2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# usa
+U.Nakamura <usa@ruby-lang.org>
+U.Nakamura <usa@ruby-lang.org> <usa@garbagecollect.jp>
+U.Nakamura <usa@ruby-lang.org> <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# wakou
+Wakou Aoyama <wakou@ruby-lang.org>
+Wakou Aoyama <wakou@ruby-lang.org> <wakou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# wanabe
+wanabe <s.wanabe@gmail.com>
+wanabe <s.wanabe@gmail.com> <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# watson1978
+Watson <watson1978@gmail.com>
+Watson <watson1978@gmail.com> <watson1978@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# wew
+William Webber <william@williamwebber.com>
+William Webber <william@williamwebber.com> <wew@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# why
+why the lucky stiff <why@ruby-lang.org>
+why the lucky stiff <why@ruby-lang.org> <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# xibbar
+Takeyuki FUJIOKA <xibbar@ruby-lang.org>
+Takeyuki FUJIOKA <xibbar@ruby-lang.org> <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# yugui
+Yuki Yugui Sonoda <yugui@yugui.jp>
+Yuki Yugui Sonoda <yugui@yugui.jp> <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# yui-knk
+yui-knk <spiketeika@gmail.com>
+yui-knk <spiketeika@gmail.com> <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# yuki
+Yuki Nishijima <yuki24@hey.com>
+Yuki Nishijima <yuki24@hey.com> <mail@yukinishijima.net>
+Yuki Nishijima <yuki24@hey.com> <yuki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# zsombor
+Dee Zsombor <zsombor@ruby-lang.org>
+Dee Zsombor <zsombor@ruby-lang.org> <zsombor@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
+
+# zzak
+zzak <zzakscott@gmail.com>
+zzak <zzakscott@gmail.com> <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
diff --git a/.rdoc_options b/.rdoc_options
index 760507c7a2..5172911e16 100644
--- a/.rdoc_options
+++ b/.rdoc_options
@@ -1,4 +1,37 @@
---
page_dir: doc
-main_page: README.md
+main_page: index.md
title: Documentation for Ruby development version
+visibility: :private
+rdoc_include:
+- doc
+
+exclude:
+- \.gemspec\z
+- lib/set/subclass_compatible.rb
+
+autolink_excluded_words:
+- Box
+- Class
+- Method
+- Module
+- Process
+- RDoc
+- Ruby
+- Set
+- ZJIT
+- YJIT
+
+canonical_root: https://docs.ruby-lang.org/en/master
+
+footer_content:
+ Ruby:
+ Documentation: index.html
+ Official Website: https://www.ruby-lang.org/
+ Playground: https://ruby.github.io/play-ruby/
+ Resources:
+ GitHub: https://github.com/ruby/ruby
+ Issue Tracker: https://bugs.ruby-lang.org/projects/ruby-master/issues
+ RubyGems: https://rubygems.org/
+ Community:
+ X: https://x.com/rubylangorg
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 665feba914..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,235 +0,0 @@
-# -*- YAML -*-
-# Copyright (C) 2011 Urabe, Shyouhei. All rights reserved.
-#
-# This file is a part of the programming language Ruby. Permission is hereby
-# granted, to either redistribute or modify this file, provided that the
-# conditions mentioned in the file COPYING are met. Consult the file for
-# details.
-
-# We only manage non-amd64 free pipelines.
-# https://docs.travis-ci.com/user/billing-overview/
-
-language: c
-
-os: linux
-
-if: commit_message !~ /\[DOC\]/
-
-dist: focal
-
-git:
- quiet: true
-
-cache:
- ccache: true
- directories:
- - $HOME/config_2nd
- - $HOME/.downloaded-cache
-
-env:
- global:
- # The tests skipped in `make test-all`.
- - TEST_ALL_SKIPPED_TESTS=
- # The tests executed separately by `make test-all`.
- - TEST_ALL_SEPARATED_TESTS=
- # Reset timestamps early
- - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +)
- - CONFIGURE_TTY=no
- - CCACHE_COMPILERCHECK=none
- - CCACHE_NOCOMPRESS=1
- - CCACHE_MAXSIZE=512Mi
- - NPROC="`nproc`"
- # JOBS and SETARCH are overridden when necessary; see below.
- - JOBS=-j$((1+${NPROC}))
- - SETARCH=
- - RUBY_PREFIX=/tmp/ruby-prefix
- - GEMS_FOR_TEST='timezone tzinfo'
- # https://github.com/travis-ci/travis-build/blob/e411371dda21430a60f61b8f3f57943d2fe4d344/lib/travis/build/bash/travis_apt_get_options.bash#L7
- - travis_apt_get_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages'
- - travis_apt_get_options="-yq --no-install-suggests --no-install-recommends $travis_apt_get_options"
- # -O1 is faster than -O3 in our tests.
- - optflags=-O1
- # -g0 disables backtraces when SEGV. Do not set that.
- - debugflags=-ggdb3
-
-.org.ruby-lang.ci.matrix-definitions:
-
- - &gcc-10
- compiler: gcc-10
- before_install:
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - >-
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install
- ccache
- gcc-10
- g++-10
- libffi-dev
- libncurses-dev
- libncursesw5-dev
- libreadline-dev
- libssl-dev
- libyaml-dev
- openssl
- zlib1g-dev
-
- # --------
-
- - &arm64-linux
- name: arm64-linux
- arch: arm64
- <<: *gcc-10
-
- - &ppc64le-linux
- name: ppc64le-linux
- arch: ppc64le
- <<: *gcc-10
-
- - &s390x-linux
- name: s390x-linux
- arch: s390x
- <<: *gcc-10
-
- - &arm32-linux
- name: arm32-linux
- arch: arm64
- # https://packages.ubuntu.com/focal/crossbuild-essential-armhf
- compiler: arm-linux-gnueabihf-gcc
- env:
- - SETARCH='setarch linux32 --verbose --32bit'
- # The "TestReadline#test_interrupt_in_other_thread" started failing on arm32
- # from https://www.travis-ci.com/github/ruby/ruby/jobs/529005145
- - TEST_ALL_SKIPPED_TESTS=test_interrupt_in_other_thread
- before_install:
- - sudo dpkg --add-architecture armhf
- - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- - >-
- tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install
- ccache
- crossbuild-essential-armhf
- libc6:armhf
- libstdc++-10-dev:armhf
- libffi-dev:armhf
- libncurses-dev:armhf
- libncursesw5-dev:armhf
- libreadline-dev:armhf
- libssl-dev:armhf
- libyaml-dev:armhf
- linux-libc-dev:armhf
- zlib1g-dev:armhf
-
-matrix:
- include:
- # Build every commit (Allowed Failures):
- - <<: *arm32-linux
- # Comment out as the 2nd arm64 pipeline is unstable.
- # - <<: *arm64-linux
- - <<: *ppc64le-linux
- - <<: *s390x-linux
- allow_failures:
- # We see multiple errors indicating errors on the Travis environment itself in a short while:
- # https://app.travis-ci.com/github/ruby/ruby/jobs/544382885
- # https://app.travis-ci.com/github/ruby/ruby/jobs/544361370
- # It's not a fault of Ruby's arm32 support but just Travis arm32 seems unsable.
- - name: arm32-linux
- # - name: arm64-linux
- # We see "Some worker was crashed." in about 40% of recent ppc64le-linux jobs
- # e.g. https://app.travis-ci.com/github/ruby/ruby/jobs/530959548
- - name: ppc64le-linux
- # Tentatively disable, because often hungs up **after** all tests
- # have finished successfully and saving caches.
- - name: s390x-linux
- fast_finish: true
-
-before_script:
- - . tool/ci_functions.sh
- - |-
- if [ -n "${TEST_ALL_SKIPPED_TESTS}" ]; then
- TEST_ALL_OPTS="${TEST_ALL_OPTS} $(ci_to_excluded_test_opts "${TEST_ALL_SKIPPED_TESTS}")"
- if [ -z "${TEST_ALL_SEPARATED_TESTS}" ]; then
- TEST_ALL_SEPARATED_TESTS="${TEST_ALL_SKIPPED_TESTS}"
- fi
- fi
- - |-
- if [ -n "${TEST_ALL_SEPARATED_TESTS}" ]; then
- TEST_ALL_OPTS_SEPARATED="$(ci_to_included_test_opts "${TEST_ALL_SEPARATED_TESTS}")"
- fi
- - echo TEST_ALL_OPTS="${TEST_ALL_OPTS}" TEST_ALL_OPTS_SEPARATED="${TEST_ALL_OPTS_SEPARATED}"
- - rm -fr .ext autom4te.cache
- - |-
- [ -d ~/.downloaded-cache ] ||
- mkdir ~/.downloaded-cache
- - ln -s ~/.downloaded-cache
- - "> config.status"
- - "> .rbconfig.time"
- - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile
- - make -s $JOBS up
- - make -s $JOBS srcs
- - rm -f config.status Makefile rbconfig.rb .rbconfig.time
- - |-
- if [ -d ~/config_2nd ]; then
- cp -pr ~/config_2nd build
- else
- mkdir build
- fi
- - mkdir config_1st config_2nd gems/src
- - chmod -R a-w .
- - chmod -R u+w build config_1st config_2nd gems/src
- - cd build
- - |-
- case "$CC" in
- gcc*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-diagnostics-color";;
- clang*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-color-diagnostics";;
- esac
- - |-
- [ ! -f config.cache ] ||
- [ "$CC" = "`sed -n s/^ac_cv_prog_CC=//p config.cache`" ] ||
- (set -x; exec rm config.cache)
- - $SETARCH ../configure -C --disable-install-doc --prefix=$RUBY_PREFIX $CONFIG_FLAG
- - cp -pr config.cache config.status .ext/include ../config_1st
- - $SETARCH make reconfig
- - cp -pr config.cache config.status .ext/include ../config_2nd
- - (cd .. && exec diff -ru config_1st config_2nd)
- - chmod u+w ..
- - rm -rf ~/config_2nd
- - mv ../config_2nd ~
- - chmod u-w ..
- - $SETARCH make -s $JOBS
- - make -s install
- - |-
- [ -z "${GEMS_FOR_TEST}" ] ||
- $RUBY_PREFIX/bin/gem install --no-document $GEMS_FOR_TEST
- - echo "raise 'do not load ~/.irbrc in test'" > ~/.irbrc
-
-script:
- - $SETARCH make -s test -o showflags TESTOPTS="${TESTOPTS=$JOBS -q --tty=no}"
- - ../tool/travis_wait.sh $SETARCH make -s test-all -o exts TESTOPTS="$JOBS -q --tty=no ${TEST_ALL_OPTS}" RUBYOPT="-w"
- # Run the failing tests separately returning ok status to check if it works,
- # visualize them.
- - |
- if [ -n "${TEST_ALL_OPTS_SEPARATED}" ]; then
- $SETARCH make -s test-all -o exts TESTOPTS="$JOBS -v --tty=no ${TEST_ALL_OPTS_SEPARATED}" RUBYOPT="-w" || :
- fi
- - $SETARCH make -s test-spec MSPECOPT=-ff # not using `-j` because sometimes `mspec -j` silently dies
- - $SETARCH make -s -o showflags leaked-globals
-
-# We enable Travis on the specific branches or forked repositories here.
-if: (repo = ruby/ruby AND (branch = master OR branch =~ /^ruby_\d_\d$/)) OR repo != ruby/ruby
-
-# We want to be notified when something happens.
-notifications:
- irc:
- channels:
- - "chat.freenode.net#ruby-core"
- on_success: change # [always|never|change] # default: always
- on_failure: always # [always|never|change] # default: always
- template:
- - "%{message} by @%{author}: See %{build_url}"
-
- webhooks:
- urls:
- - secure: mRsoS/UbqDkKkW5p3AEqM27d4SZnV6Gsylo3bm8T/deltQzTsGzZwrm7OIBXZv0UFZdE68XmPlyHfZFLSP2V9QZ7apXMf9/vw0GtcSe1gchtnjpAPF6lYBn7nMCbVPPx9cS0dwL927fjdRM1vj7IKZ2bk4F0lAJ25R25S6teqdk= # ruby-lang slack: ruby/simpler-alerts-bot (travis)
- on_success: never
- on_failure: always
-
- email:
- - jaruga@ruby-lang.org
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 13df6087ca..35e79dd3b9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1 +1 @@
-See ["Contributing to Ruby"](https://docs.ruby-lang.org/en/master/contributing_md.html), which includes setup and build instructions.
+See ["Contributing to Ruby"](https://docs.ruby-lang.org/en/master/contributing/contributing_md.html), which includes setup and build instructions.
diff --git a/COPYING b/COPYING
index 48e5a96de7..428ce03ed7 100644
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,5 @@
+{日本語}[rdoc-ref:COPYING.ja]
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
You can redistribute it and/or modify it under either the terms of the
2-clause BSDL (see the file BSDL), or the conditions below:
diff --git a/COPYING.ja b/COPYING.ja
index 230376bc60..5de2dbcc8f 100644
--- a/COPYING.ja
+++ b/COPYING.ja
@@ -1,3 +1,5 @@
+{English}[rdoc-ref:COPYING]
+
本プログラムã¯ãƒ•リーソフトウェアã§ã™ï¼Ž2-clause BSDL
ã¾ãŸã¯ä»¥ä¸‹ã«ç¤ºã™æ¡ä»¶ã§æœ¬ãƒ—ログラムをå†é…布ã§ãã¾ã™
2-clause BSDLã«ã¤ã„ã¦ã¯BSDLファイルをå‚ç…§ã—ã¦ä¸‹ã•ã„.
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000000..2108276e72
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,766 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "anyhow"
+version = "1.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
+
+[[package]]
+name = "autocfg"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
+
+[[package]]
+name = "capstone"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f442ae0f2f3f1b923334b4a5386c95c69c1cfa072bafa23d6fae6d9682eb1dd4"
+dependencies = [
+ "capstone-sys",
+ "static_assertions",
+]
+
+[[package]]
+name = "capstone-sys"
+version = "0.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4e8087cab6731295f5a2a2bd82989ba4f41d3a428aab2e7c98d8f4db38aac05"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "cc"
+version = "1.0.94"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "chacha20"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "rand_core",
+]
+
+[[package]]
+name = "console"
+version = "0.16.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87"
+dependencies = [
+ "encode_unicode",
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "cpufeatures"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "encode_unicode"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "errno"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "fastrand"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
+
+[[package]]
+name = "foldhash"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
+
+[[package]]
+name = "getrandom"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+ "rand_core",
+ "wasip2",
+ "wasip3",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hermit-abi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+
+[[package]]
+name = "id-arena"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
+
+[[package]]
+name = "indexmap"
+version = "2.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.16.1",
+ "serde",
+ "serde_core",
+]
+
+[[package]]
+name = "insta"
+version = "1.47.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b4a6248eb93a4401ed2f37dfe8ea592d3cf05b7cf4f8efa867b6895af7e094e"
+dependencies = [
+ "console",
+ "once_cell",
+ "similar",
+ "tempfile",
+]
+
+[[package]]
+name = "instant"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "io-lifetimes"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
+
+[[package]]
+name = "jit"
+version = "0.1.0"
+
+[[package]]
+name = "leb128fmt"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
+
+[[package]]
+name = "libc"
+version = "0.2.163"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fdaeca4cf44ed4ac623e86ef41f056e848dbeab7ec043ecb7326ba300b36fd0"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
+
+[[package]]
+name = "log"
+version = "0.4.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
+
+[[package]]
+name = "memchr"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c"
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "prettyplease"
+version = "0.2.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
+dependencies = [
+ "proc-macro2",
+ "syn",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.101"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "rand"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207"
+dependencies = [
+ "chacha20",
+ "getrandom",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
+
+[[package]]
+name = "redox_syscall"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
+[[package]]
+name = "ruby"
+version = "0.0.0"
+dependencies = [
+ "yjit",
+ "zjit",
+]
+
+[[package]]
+name = "rustix"
+version = "0.37.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "519165d378b97752ca44bbe15047d5d3409e875f39327546b42ac81d7e18c1b6"
+dependencies = [
+ "bitflags 1.3.2",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "ryu"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
+
+[[package]]
+name = "semver"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
+
+[[package]]
+name = "serde"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.143"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "similar"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21"
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "syn"
+version = "2.0.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6"
+dependencies = [
+ "autocfg",
+ "cfg-if",
+ "fastrand",
+ "redox_syscall",
+ "rustix",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
+
+[[package]]
+name = "wasip2"
+version = "1.0.1+wasi-0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
+dependencies = [
+ "wit-bindgen 0.46.0",
+]
+
+[[package]]
+name = "wasip3"
+version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
+dependencies = [
+ "wit-bindgen 0.51.0",
+]
+
+[[package]]
+name = "wasm-encoder"
+version = "0.244.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
+dependencies = [
+ "leb128fmt",
+ "wasmparser",
+]
+
+[[package]]
+name = "wasm-metadata"
+version = "0.244.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
+dependencies = [
+ "anyhow",
+ "indexmap",
+ "wasm-encoder",
+ "wasmparser",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.244.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
+dependencies = [
+ "bitflags 2.11.0",
+ "hashbrown 0.15.5",
+ "indexmap",
+ "semver",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.6",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm 0.52.6",
+ "windows_aarch64_msvc 0.52.6",
+ "windows_i686_gnu 0.52.6",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc 0.52.6",
+ "windows_x86_64_gnu 0.52.6",
+ "windows_x86_64_gnullvm 0.52.6",
+ "windows_x86_64_msvc 0.52.6",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "wit-bindgen"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
+
+[[package]]
+name = "wit-bindgen"
+version = "0.51.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
+dependencies = [
+ "wit-bindgen-rust-macro",
+]
+
+[[package]]
+name = "wit-bindgen-core"
+version = "0.51.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
+dependencies = [
+ "anyhow",
+ "heck",
+ "wit-parser",
+]
+
+[[package]]
+name = "wit-bindgen-rust"
+version = "0.51.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
+dependencies = [
+ "anyhow",
+ "heck",
+ "indexmap",
+ "prettyplease",
+ "syn",
+ "wasm-metadata",
+ "wit-bindgen-core",
+ "wit-component",
+]
+
+[[package]]
+name = "wit-bindgen-rust-macro"
+version = "0.51.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
+dependencies = [
+ "anyhow",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wit-bindgen-core",
+ "wit-bindgen-rust",
+]
+
+[[package]]
+name = "wit-component"
+version = "0.244.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
+dependencies = [
+ "anyhow",
+ "bitflags 2.11.0",
+ "indexmap",
+ "log",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "wasm-encoder",
+ "wasm-metadata",
+ "wasmparser",
+ "wit-parser",
+]
+
+[[package]]
+name = "wit-parser"
+version = "0.244.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
+dependencies = [
+ "anyhow",
+ "id-arena",
+ "indexmap",
+ "log",
+ "semver",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "unicode-xid",
+ "wasmparser",
+]
+
+[[package]]
+name = "yjit"
+version = "0.1.0"
+dependencies = [
+ "capstone",
+ "jit",
+]
+
+[[package]]
+name = "zjit"
+version = "0.0.1"
+dependencies = [
+ "capstone",
+ "insta",
+ "jit",
+ "rand",
+ "yjit",
+]
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000000..33010e65fb
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,64 @@
+# This is the root Cargo [workspace](https://doc.rust-lang.org/cargo/reference/workspaces.html)
+# and the root package for all the rust code that are statically linked into ruby. Rust tooling
+# limitations means all Rust code need to share a single archive library (staticlib) at the
+# integration point with non-rust code. (See rustlang/rust#44322 and #104707 for a taste of
+# the linking challenges.)
+#
+# Do not add required dependencies. This is a policy that helps downstream consumers and give
+# us tight control over what we ship. All of the optional dependencies are used exclusively
+# during development.
+#
+# Release builds avoid Cargo entirely because offline builds can fail even when none of the
+# optional dependencies are built (rust-lang/cargo#10352).
+
+[workspace]
+members = ["zjit", "yjit", "jit"]
+
+[package]
+name = "ruby"
+version = "0.0.0"
+edition = "2024"
+rust-version = "1.85.0"
+publish = false # Don't publish to crates.io
+
+[dependencies]
+yjit = { path = "yjit", optional = true }
+zjit = { path = "zjit", optional = true }
+
+[lib]
+crate-type = ["staticlib"]
+path = "ruby.rs"
+
+[features]
+disasm = ["yjit?/disasm", "zjit?/disasm"]
+runtime_checks = ["yjit?/runtime_checks", "zjit?/runtime_checks"]
+yjit = [ "dep:yjit" ]
+zjit = [ "dep:zjit" ]
+
+[profile.dev]
+opt-level = 1 # On 0, functions use so much stack space that we get stray `SystemStackError`s
+debug = true
+debug-assertions = true
+overflow-checks = true
+
+[profile.test]
+inherits = "dev"
+opt-level = 0
+
+[profile.dev_nodebug]
+inherits = "dev"
+
+[profile.stats]
+inherits = "release"
+
+[profile.release]
+# NOTE: --enable-yjit and zjit builds use `rustc` without going through Cargo. You
+# might want to update the `rustc` invocation if you change this profile.
+opt-level = 3
+# The extra robustness that comes from checking for arithmetic overflow is
+# worth the performance cost for the compiler.
+overflow-checks = true
+# Generate debug info
+debug = true
+# Use ThinLTO. Much smaller output for a small amount of build time increase.
+lto = "thin"
diff --git a/LEGAL b/LEGAL
index e352c55ee5..2777aa2c14 100644
--- a/LEGAL
+++ b/LEGAL
@@ -58,12 +58,12 @@ mentioned below.
[ccan/list/list.h]
- This file is licensed under the {MIT License}[rdoc-label:label-MIT+License].
+ This file is licensed under the {MIT License}[rdoc-ref:@MIT+License].
[coroutine]
Unless otherwise specified, these files are licensed under the
- {MIT License}[rdoc-label:label-MIT+License].
+ {MIT License}[rdoc-ref:@MIT+License].
[include/ruby/onigmo.h]
[include/ruby/oniguruma.h]
@@ -546,7 +546,7 @@ mentioned below.
[vsnprintf.c]
- This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license].
+ This file is under the {old-style BSD license}[rdoc-ref:@Old-style+BSD+license].
>>>
Copyright (c) 1990, 1993::
@@ -577,7 +577,7 @@ mentioned below.
[missing/crypt.c]
- This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license].
+ This file is under the {old-style BSD license}[rdoc-ref:@Old-style+BSD+license].
>>>
Copyright (c) 1989, 1993::
@@ -588,7 +588,7 @@ mentioned below.
[missing/setproctitle.c]
- This file is under the {old-style BSD license}[rdoc-label:label-Old-style+BSD+license].
+ This file is under the {old-style BSD license}[rdoc-ref:@Old-style+BSD+license].
>>>
Copyright 2003:: Damien Miller
@@ -702,48 +702,22 @@ mentioned below.
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-[ext/json/generator/generator.c]
+[ext/json/vendor/fpconv.c]
- The file contains the following copyright notice.
+ This file is under the {Boost Software License}[rdoc-ref:@Boost+Software+License+1.0].
- >>>
- 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.
-
-[ext/nkf/nkf-utf8/config.h]
-[ext/nkf/nkf-utf8/nkf.c]
-[ext/nkf/nkf-utf8/utf8tbl.c]
-
- These files are under the following license. So to speak, it is
- copyrighted semi-public-domain software.
+[ext/json/vendor/jeaiii-ltoa.h]
>>>
- Copyright (C) 1987:: Fujitsu LTD. (Itaru ICHIKAWA)
+ Copyright (c) 2024,2025 Enrico Thierbach - https://github.com/radiospiel
+ Copyright (c) 2022 James Edward Anhalt III - https://github.com/jeaiii/itoa
- Everyone is permitted to do anything on this program
- including copying, modifying, improving,
- as long as you don't try to pretend that you wrote it.
- i.e., the above copyright notice has to appear in all copies.
- Binary distribution requires original version messages.
- You don't have to ask before copying, redistribution or publishing.
- THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ {MIT License}[rdoc-ref:@MIT+License]
+
+[ext/json/vendor/ryu.h]
+ This file is adapted from the Ryu algorithm by Ulf Adams https://github.com/ulfjack/ryu.
+ It is dual-licensed under {Apache License 2.0}[rdoc-ref:@Apache+License+2.0] OR
+ {Boost Software License 1.0}[rdoc-ref:@Boost+Software+License+1.0].
[ext/psych]
[test/psych]
@@ -879,7 +853,7 @@ mentioned below.
>>>
RubyGems is copyrighted free software by Chad Fowler, Rich Kilmer, Jim
Weirich and others. You can redistribute it and/or modify it under
- either the terms of the {MIT license}[rdoc-label:label-MIT+License], or the conditions
+ either the terms of the {MIT license}[rdoc-ref:@MIT+License], or the conditions
below:
1. You may make and give away verbatim copies of the source form of the
@@ -941,7 +915,7 @@ mentioned below.
Portions copyright (c) 2010:: Andre Arko
Portions copyright (c) 2009:: Engine Yard
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/bundler/vendor/thor]
@@ -950,16 +924,16 @@ mentioned below.
>>>
Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
-[lib/rubygems/resolver/molinillo]
+[lib/rubygems/vendor/molinillo]
molinillo is under the following license.
>>>
Copyright (c) 2014 Samuel E. Giddins segiddins@segiddins.me
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/bundler/vendor/pub_grub]
@@ -968,7 +942,7 @@ mentioned below.
>>>
Copyright (c) 2018 John Hawthorn
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/bundler/vendor/connection_pool]
@@ -977,7 +951,7 @@ mentioned below.
>>>
Copyright (c) 2011 Mike Perham
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/bundler/vendor/net-http-persistent]
@@ -986,7 +960,7 @@ mentioned below.
>>>
Copyright (c) Eric Hodel, Aaron Patterson
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/did_you_mean]
[lib/did_you_mean.rb]
@@ -997,7 +971,7 @@ mentioned below.
>>>
Copyright (c) 2014-2016 Yuki Nishijima
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[lib/error_highlight]
[lib/error_highlight.rb]
@@ -1008,7 +982,7 @@ mentioned below.
>>>
Copyright (c) 2021 Yusuke Endoh
- {MIT License}[rdoc-label:label-MIT+License]
+ {MIT License}[rdoc-ref:@MIT+License]
[benchmark/so_ackermann.rb]
[benchmark/so_array.rb]
@@ -1091,3 +1065,236 @@ mentioned below.
From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
paragraph 3 above is now null and void.
+
+== Boost Software License 1.0
+
+>>>
+ Boost Software License - Version 1.0 - August 17th, 2003
+
+ Permission is hereby granted, free of charge, to any person or organization
+ obtaining a copy of the software and accompanying documentation covered by
+ this license (the "Software") to use, reproduce, display, distribute,
+ execute, and transmit the Software, and to prepare derivative works of the
+ Software, and to permit third-parties to whom the Software is furnished to
+ do so, all subject to the following:
+
+ The copyright notices in the Software and this entire statement, including
+ the above license grant, this restriction and the following disclaimer,
+ must be included in all copies of the Software, in whole or in part, and
+ all derivative works of the Software, unless such copies or derivative
+ works are solely in the form of machine-executable object code generated by
+ a source language processor.
+
+ 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+== Apache License 2.0
+
+>>>
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ a. You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ b. You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ c. You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ d. If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ >>>
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/NEWS.md b/NEWS.md
index 53a7f2e723..8699bc0bff 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,55 +1,138 @@
-# NEWS for Ruby 3.3.0
+# NEWS for Ruby 4.1.0
This document is a list of user-visible feature changes
-since the **3.2.0** release, except for bug fixes.
+since the **4.0.0** release, except for bug fixes.
Note that each entry is kept to a minimum, see links for details.
## Language changes
+* `Module#clone` and `Module#dup` no longer rewrite the lexical scope of
+ copied methods. Constants and class variables resolve through the
+ original class, consistent with inheritance and mixins.
+ [[Feature #21981]]
+
## Core classes updates
Note: We're only listing outstanding class updates.
* Array
- * `Array#pack` now raises ArgumentError for unknown directives. [[Bug #19150]]
+ * `Array#pack` accepts a new format `R` and `r` for unpacking unsigned
+ and signed LEB128 encoded integers. [[Feature #21785]]
+ * `Array#pack` accepts a new format `^` that returns the current offset.
+ Useful when combined with variable width formats like LEB128. [[Feature #21796]]
+
+* ENV
+
+ * `ENV.fetch_values` is added. It returns an array of values for the
+ given names, raising `KeyError` for missing names unless a block is
+ given. [[Feature #21781]]
+
+* Kernel
+
+ * `Kernel#autoload_relative` and `Module#autoload_relative` are added.
+ These methods work like `autoload`, but resolve the file path relative
+ to the file where the method is called, similar to `require_relative`.
+ This makes it easier to autoload constants from files in the same
+ directory without hardcoding absolute paths or manipulating `$LOAD_PATH`.
+ [[Feature #15330]]
+
+* MatchData
+
+ * `MatchData#integer_at` is added. It converts the matched substring to
+ integer and return the result. [[Feature #21932]]
-* String
+* Regexp
- * `String#unpack` now raises ArgumentError for unknown directives. [[Bug #19150]]
- * `String#bytesplice` now accepts new arguments index/length or range of the source string to be copied. [[Feature #19314]]
+ * All instances of `Regexp` are now frozen, not just literals.
+ Subclasses of `Regexp` are not frozen for compatibility.
+ [[Feature #8948]]
-* ObjectSpace::WeakKeyMap
+* Set
- * New core class to build collections with weak references.
- The class use equality semantic to lookup keys like a regular hash,
- but it doesn't hold strong references on the keys. [[Feature #18498]]
+ * A deprecated behavior, `Set#to_set`, `Range#to_set`, and
+ `Enumerable#to_set` accepting arguments, was removed. [[Feature #21390]]
## Stdlib updates
-The following default gems are updated.
+### The following bundled gems are added.
+
+
+We only list stdlib changes that are notable feature changes.
+
+Other changes are listed in the following sections. We also listed release
+history from the previous bundled version that is Ruby 3.4.0 if it has GitHub
+releases.
+
+### The following bundled gems are promoted from default gems.
+
+* tsort 0.2.0
+* win32-registry 0.1.2
+
+### The following default gem is added.
-* RubyGems 3.5.0.dev
-* bigdecimal 3.1.4
-* bundler 2.5.0.dev
-* csv 3.2.7
-* fiddle 1.1.2
-* irb 1.6.3
-* optparse 0.4.0.pre.1
-* psych 5.1.0
-* stringio 3.0.6
-* strscan 3.0.7
-* timeout 0.3.2
+### The following default gems are updated.
-The following bundled gems are updated.
+* RubyGems 4.1.0.dev
+ * 4.0.3 to [v4.0.4][RubyGems-v4.0.4], [v4.0.5][RubyGems-v4.0.5], [v4.0.6][RubyGems-v4.0.6], [v4.0.7][RubyGems-v4.0.7], [v4.0.8][RubyGems-v4.0.8], [v4.0.9][RubyGems-v4.0.9], [v4.0.10][RubyGems-v4.0.10], [v4.0.11][RubyGems-v4.0.11], [v4.0.12][RubyGems-v4.0.12]
+* bundler 4.1.0.dev
+ * 4.0.3 to [v4.0.4][bundler-v4.0.4], [v4.0.5][bundler-v4.0.5], [v4.0.6][bundler-v4.0.6], [v4.0.7][bundler-v4.0.7], [v4.0.8][bundler-v4.0.8], [v4.0.9][bundler-v4.0.9], [v4.0.10][bundler-v4.0.10], [v4.0.11][bundler-v4.0.11], [v4.0.12][bundler-v4.0.12]
+* erb 6.0.4
+ * 6.0.1 to [v6.0.1.1][erb-v6.0.1.1], [v6.0.2][erb-v6.0.2], [v6.0.3][erb-v6.0.3], [v6.0.4][erb-v6.0.4]
+* ipaddr 1.2.9
+ * 1.2.8 to [v1.2.9][ipaddr-v1.2.9]
+* json 2.19.7
+ * 2.18.0 to [v2.18.1][json-v2.18.1], [v2.19.0][json-v2.19.0], [v2.19.1][json-v2.19.1], [v2.19.2][json-v2.19.2], [v2.19.3][json-v2.19.3], [v2.19.4][json-v2.19.4], [v2.19.5][json-v2.19.5], [v2.19.6][json-v2.19.6], [v2.19.7][json-v2.19.7]
+* openssl 4.0.2
+ * 4.0.0 to [v4.0.1][openssl-v4.0.1], [v4.0.2][openssl-v4.0.2]
+* prism 1.9.0
+ * 1.7.0 to [v1.8.0][prism-v1.8.0], [v1.8.1][prism-v1.8.1], [v1.9.0][prism-v1.9.0]
+* psych 5.4.0
+* resolv 0.7.1
+ * 0.7.0 to [v0.7.1][resolv-v0.7.1]
+* stringio 3.2.1.dev
+* strscan 3.1.9.dev
+ * 3.1.6 to [v3.1.7][strscan-v3.1.7], [v3.1.8][strscan-v3.1.8]
+* syntax_suggest 3.0.0
+* timeout 0.6.1
+ * 0.6.0 to [v0.6.1][timeout-v0.6.1]
+* zlib 3.2.3
+ * 3.2.2 to [v3.2.3][zlib-v3.2.3]
-* minitest 5.18.0
-* rbs 3.0.4
-* typeprof 0.21.7
+### The following bundled gems are updated.
-See GitHub releases like [Logger](https://github.com/ruby/logger/releases) or
-changelog for details of the default gems or bundled gems.
+* minitest 6.0.6
+* rake 13.4.2
+ * 13.3.1 to [v13.4.0][rake-v13.4.0], [v13.4.1][rake-v13.4.1], [v13.4.2][rake-v13.4.2]
+* test-unit 3.7.7
+ * 3.7.5 to [3.7.6][test-unit-3.7.6], [3.7.7][test-unit-3.7.7]
+* net-imap 0.6.4
+ * 0.6.2 to [v0.6.3][net-imap-v0.6.3], [v0.6.4][net-imap-v0.6.4]
+* rbs 4.0.2
+ * 3.10.0 to [v3.10.1][rbs-v3.10.1], [v3.10.2][rbs-v3.10.2], [v3.10.3][rbs-v3.10.3], [v3.10.4][rbs-v3.10.4], [v4.0.0.dev.5][rbs-v4.0.0.dev.5], [v4.0.0][rbs-v4.0.0], [v4.0.2][rbs-v4.0.2]
+* typeprof 0.32.0
+* mutex_m 0.3.0
+* bigdecimal 4.1.2
+ * 4.0.1 to [v4.1.0][bigdecimal-v4.1.0], [v4.1.1][bigdecimal-v4.1.1], [v4.1.2][bigdecimal-v4.1.2]
+* resolv-replace 0.2.0
+ * 0.1.1 to [v0.2.0][resolv-replace-v0.2.0]
+* syslog 0.4.0
+ * 0.3.0 to [v0.4.0][syslog-v0.4.0]
+* repl_type_completor 0.1.15
+ * 0.1.12 to [v0.1.13][repl_type_completor-v0.1.13], [v0.1.14][repl_type_completor-v0.1.14], [v0.1.15][repl_type_completor-v0.1.15]
+* pstore 0.2.1
+ * 0.2.0 to [v0.2.1][pstore-v0.2.1]
+* rdoc 7.2.0
+ * 7.0.3 to [v7.0.4][rdoc-v7.0.4], [v7.1.0][rdoc-v7.1.0], [v7.2.0][rdoc-v7.2.0]
+* win32ole 1.9.3
+ * 1.9.2 to [v1.9.3][win32ole-v1.9.3]
+* irb 1.18.0
+ * 1.16.0 to [v1.17.0][irb-v1.17.0], [v1.18.0][irb-v1.18.0]
+
+### RubyGems and Bundler
+
+Ruby 4.0 bundled RubyGems and Bundler version 4. see the following links for details.
## Supported platforms
@@ -59,9 +142,125 @@ changelog for details of the default gems or bundled gems.
## C API updates
+### Embedded TypedData
+
+* The `RUBY_TYPED_EMBEDDABLE` flag is now public and documented and can be used by C extensions.
+ It allows allocating C structs directly into Ruby object slots, which reduces pointer chasing,
+ and in some case memory usage.
+ See the C extension documentation for details. [[Feature #21853]]
+
+* Added new C23 inspired allocator functions, that takes the previous memory size.
+ This allow the Ruby GC to better keep track of memory usage, improving its heuristics.
+ It also improves the performance of system allocators that support C23 `free_sized`.
+
+ However, it is important to note that passing an incorrect size to these function is undefined
+ behavior and may result in crashes or memory leaks.
+
+ - `ruby_xfree_sized(void *ptr, size_t size)`
+ - `ruby_xrealloc_sized(void *ptr, size_t newsiz, size_t oldsiz)`
+ - `ruby_xrealloc2_sized(void *ptr, size_t newelems, size_t newsiz, size_t oldelems)`
+
+ [[Feature #21861]]
+
+### Removed APIs
+
+The following APIs, which have been deprecated for many years, are removed.
+[[Feature #21768]]
+
+* old postponed job functions,
+* untyped data object type/functions,
+* old APIs to allocate a data object,
+* taintedness/trustedness enums/macros,
+* `rb_gc_force_recycle` function,
+* `rb_iterate` function,
+* and some functions and constants for internal use.
+
## Implementation improvements
+### Ractor
+
+A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractor implementation closer to leaving experimental status.
+
## JIT
-[Bug #19150]: https://bugs.ruby-lang.org/issues/19150
-[Feature #19314]: https://bugs.ruby-lang.org/issues/19314
+[Feature #8948]: https://bugs.ruby-lang.org/issues/8948
+[Feature #15330]: https://bugs.ruby-lang.org/issues/15330
+[Feature #21390]: https://bugs.ruby-lang.org/issues/21390
+[Feature #21768]: https://bugs.ruby-lang.org/issues/21768
+[Feature #21785]: https://bugs.ruby-lang.org/issues/21785
+[Feature #21796]: https://bugs.ruby-lang.org/issues/21796
+[Feature #21853]: https://bugs.ruby-lang.org/issues/21853
+[Feature #21861]: https://bugs.ruby-lang.org/issues/21861
+[Feature #21932]: https://bugs.ruby-lang.org/issues/21932
+[Feature #21981]: https://bugs.ruby-lang.org/issues/21981
+[RubyGems-v4.0.4]: https://github.com/rubygems/rubygems/releases/tag/v4.0.4
+[RubyGems-v4.0.5]: https://github.com/rubygems/rubygems/releases/tag/v4.0.5
+[RubyGems-v4.0.6]: https://github.com/rubygems/rubygems/releases/tag/v4.0.6
+[RubyGems-v4.0.7]: https://github.com/rubygems/rubygems/releases/tag/v4.0.7
+[RubyGems-v4.0.8]: https://github.com/rubygems/rubygems/releases/tag/v4.0.8
+[RubyGems-v4.0.9]: https://github.com/rubygems/rubygems/releases/tag/v4.0.9
+[RubyGems-v4.0.10]: https://github.com/rubygems/rubygems/releases/tag/v4.0.10
+[RubyGems-v4.0.11]: https://github.com/rubygems/rubygems/releases/tag/v4.0.11
+[RubyGems-v4.0.12]: https://github.com/rubygems/rubygems/releases/tag/v4.0.12
+[bundler-v4.0.4]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.4
+[bundler-v4.0.5]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.5
+[bundler-v4.0.6]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.6
+[bundler-v4.0.7]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.7
+[bundler-v4.0.8]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.8
+[bundler-v4.0.9]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.9
+[bundler-v4.0.10]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.10
+[bundler-v4.0.11]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.11
+[bundler-v4.0.12]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.12
+[erb-v6.0.1.1]: https://github.com/ruby/erb/releases/tag/v6.0.1.1
+[erb-v6.0.2]: https://github.com/ruby/erb/releases/tag/v6.0.2
+[erb-v6.0.3]: https://github.com/ruby/erb/releases/tag/v6.0.3
+[erb-v6.0.4]: https://github.com/ruby/erb/releases/tag/v6.0.4
+[ipaddr-v1.2.9]: https://github.com/ruby/ipaddr/releases/tag/v1.2.9
+[json-v2.18.1]: https://github.com/ruby/json/releases/tag/v2.18.1
+[json-v2.19.0]: https://github.com/ruby/json/releases/tag/v2.19.0
+[json-v2.19.1]: https://github.com/ruby/json/releases/tag/v2.19.1
+[json-v2.19.2]: https://github.com/ruby/json/releases/tag/v2.19.2
+[json-v2.19.3]: https://github.com/ruby/json/releases/tag/v2.19.3
+[json-v2.19.4]: https://github.com/ruby/json/releases/tag/v2.19.4
+[json-v2.19.5]: https://github.com/ruby/json/releases/tag/v2.19.5
+[json-v2.19.6]: https://github.com/ruby/json/releases/tag/v2.19.6
+[json-v2.19.7]: https://github.com/ruby/json/releases/tag/v2.19.7
+[openssl-v4.0.1]: https://github.com/ruby/openssl/releases/tag/v4.0.1
+[openssl-v4.0.2]: https://github.com/ruby/openssl/releases/tag/v4.0.2
+[prism-v1.8.0]: https://github.com/ruby/prism/releases/tag/v1.8.0
+[prism-v1.8.1]: https://github.com/ruby/prism/releases/tag/v1.8.1
+[prism-v1.9.0]: https://github.com/ruby/prism/releases/tag/v1.9.0
+[resolv-v0.7.1]: https://github.com/ruby/resolv/releases/tag/v0.7.1
+[strscan-v3.1.7]: https://github.com/ruby/strscan/releases/tag/v3.1.7
+[strscan-v3.1.8]: https://github.com/ruby/strscan/releases/tag/v3.1.8
+[timeout-v0.6.1]: https://github.com/ruby/timeout/releases/tag/v0.6.1
+[zlib-v3.2.3]: https://github.com/ruby/zlib/releases/tag/v3.2.3
+[rake-v13.4.0]: https://github.com/ruby/rake/releases/tag/v13.4.0
+[rake-v13.4.1]: https://github.com/ruby/rake/releases/tag/v13.4.1
+[rake-v13.4.2]: https://github.com/ruby/rake/releases/tag/v13.4.2
+[test-unit-3.7.6]: https://github.com/test-unit/test-unit/releases/tag/3.7.6
+[test-unit-3.7.7]: https://github.com/test-unit/test-unit/releases/tag/3.7.7
+[net-imap-v0.6.3]: https://github.com/ruby/net-imap/releases/tag/v0.6.3
+[net-imap-v0.6.4]: https://github.com/ruby/net-imap/releases/tag/v0.6.4
+[rbs-v3.10.1]: https://github.com/ruby/rbs/releases/tag/v3.10.1
+[rbs-v3.10.2]: https://github.com/ruby/rbs/releases/tag/v3.10.2
+[rbs-v3.10.3]: https://github.com/ruby/rbs/releases/tag/v3.10.3
+[rbs-v3.10.4]: https://github.com/ruby/rbs/releases/tag/v3.10.4
+[rbs-v4.0.0.dev.5]: https://github.com/ruby/rbs/releases/tag/v4.0.0.dev.5
+[rbs-v4.0.0]: https://github.com/ruby/rbs/releases/tag/v4.0.0
+[rbs-v4.0.2]: https://github.com/ruby/rbs/releases/tag/v4.0.2
+[bigdecimal-v4.1.0]: https://github.com/ruby/bigdecimal/releases/tag/v4.1.0
+[bigdecimal-v4.1.1]: https://github.com/ruby/bigdecimal/releases/tag/v4.1.1
+[bigdecimal-v4.1.2]: https://github.com/ruby/bigdecimal/releases/tag/v4.1.2
+[resolv-replace-v0.2.0]: https://github.com/ruby/resolv-replace/releases/tag/v0.2.0
+[syslog-v0.4.0]: https://github.com/ruby/syslog/releases/tag/v0.4.0
+[repl_type_completor-v0.1.13]: https://github.com/ruby/repl_type_completor/releases/tag/v0.1.13
+[repl_type_completor-v0.1.14]: https://github.com/ruby/repl_type_completor/releases/tag/v0.1.14
+[repl_type_completor-v0.1.15]: https://github.com/ruby/repl_type_completor/releases/tag/v0.1.15
+[pstore-v0.2.1]: https://github.com/ruby/pstore/releases/tag/v0.2.1
+[rdoc-v7.0.4]: https://github.com/ruby/rdoc/releases/tag/v7.0.4
+[rdoc-v7.1.0]: https://github.com/ruby/rdoc/releases/tag/v7.1.0
+[rdoc-v7.2.0]: https://github.com/ruby/rdoc/releases/tag/v7.2.0
+[win32ole-v1.9.3]: https://github.com/ruby/win32ole/releases/tag/v1.9.3
+[irb-v1.17.0]: https://github.com/ruby/irb/releases/tag/v1.17.0
+[irb-v1.18.0]: https://github.com/ruby/irb/releases/tag/v1.18.0
diff --git a/README.EXT b/README.EXT
deleted file mode 100644
index 48b8d964c4..0000000000
--- a/README.EXT
+++ /dev/null
@@ -1 +0,0 @@
-Moved to doc/extension.rdoc
diff --git a/README.EXT.ja b/README.EXT.ja
deleted file mode 100644
index f884ecbb0e..0000000000
--- a/README.EXT.ja
+++ /dev/null
@@ -1 +0,0 @@
-doc/extension.ja.rdocã«ç§»å‹•ã—ã¾ã—ãŸ
diff --git a/README.ja.md b/README.ja.md
index 67bbc9530d..9bbc3a83a5 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -1,10 +1,10 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
-[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
[![Travis Status](https://app.travis-ci.com/ruby/ruby.svg?branch=master)](https://app.travis-ci.com/ruby/ruby)
-[![Cirrus Status](https://api.cirrus-ci.com/github/ruby/ruby.svg)](https://cirrus-ci.com/github/ruby/ruby/master)
+
+[English](rdoc-ref:README.md)
# Rubyã¨ã¯
@@ -26,7 +26,7 @@ Rubyã¯ãƒ†ã‚­ã‚¹ãƒˆå‡¦ç†é–¢ä¿‚ã®èƒ½åŠ›ãªã©ã«å„ªã‚Œï¼ŒPerlã¨åŒã˜ãらã„
* ダイナミックローディング (アーキテクãƒãƒ£ã«ã‚ˆã‚‹)
* ç§»æ¤æ€§ãŒé«˜ã„.多ãã®Unix-like/POSIX互æ›ãƒ—ラットフォーム上ã§å‹•ãã ã‘ã§ãªã,Windows, macOS,
Haikuãªã©ã®ä¸Šã§ã‚‚å‹•ã cf.
- https://github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers
+ https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers
## 入手法
@@ -41,11 +41,15 @@ https://www.ruby-lang.org/ja/downloads/
ミラーをGitHubã«å…¬é–‹ã—ã¦ã„ã¾ã™ï¼Ž 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã§ãƒªãƒã‚¸ãƒˆãƒªã‚’å–å¾—ã§ãã¾ã™ï¼Ž
- $ git clone https://github.com/ruby/ruby.git
+```console
+$ git clone https://github.com/ruby/ruby.git
+```
ä»–ã®ãƒ–ランãƒã®ä¸€è¦§ã¯æ¬¡ã®ã‚³ãƒžãƒ³ãƒ‰ã§è¦‹ã‚‰ã‚Œã¾ã™ï¼Ž
- $ git ls-remote https://github.com/ruby/ruby.git
+```console
+$ git ls-remote https://github.com/ruby/ruby.git
+```
Rubyリãƒã‚¸ãƒˆãƒªã®æœ¬æ¥ã®master㯠https://git.ruby-lang.org/ruby.git ã«ã‚りã¾ã™ï¼Ž
コミッタã¯ã“ã¡ã‚‰ã‚’使ã„ã¾ã™ï¼Ž
@@ -60,20 +64,20 @@ https://www.ruby-lang.org/
## メーリングリスト
-Rubyã®ãƒ¡ãƒ¼ãƒªãƒ³ã‚°ãƒªã‚¹ãƒˆãŒã‚りã¾ã™ï¼Žå‚åŠ å¸Œæœ›ã®æ–¹ã¯ [ruby-list-request@ruby-lang.org] ã¾ã§æœ¬æ–‡ã«
+Rubyã®ãƒ¡ãƒ¼ãƒªãƒ³ã‚°ãƒªã‚¹ãƒˆãŒã‚りã¾ã™ï¼Žå‚åŠ å¸Œæœ›ã®æ–¹ã¯ [ruby-list-request@ml.ruby-lang.org] ã¾ã§ä»¶åã«
- subscribe
+ join
ã¨æ›¸ã„ã¦é€ã£ã¦ä¸‹ã•ã„.
Ruby開発者å‘ã‘メーリングリストもã‚りã¾ã™ï¼Žã“ã¡ã‚‰ã§ã¯rubyã®ãƒã‚°ï¼Œå°†æ¥ã®ä»•様拡張ãªã©å®Ÿè£…上ã®å•題ã«ã¤ã„ã¦è­°è«–ã•れã¦ã„ã¾ã™ï¼Ž
-å‚åŠ å¸Œæœ›ã®æ–¹ã¯ [ruby-dev-request@ruby-lang.org] ã¾ã§ruby-listã¨åŒæ§˜ã®æ–¹æ³•ã§ãƒ¡ãƒ¼ãƒ«ã—ã¦ãã ã•ã„.
+å‚åŠ å¸Œæœ›ã®æ–¹ã¯ [ruby-dev-request@ml.ruby-lang.org] ã¾ã§ruby-listã¨åŒæ§˜ã®æ–¹æ³•ã§ãƒ¡ãƒ¼ãƒ«ã—ã¦ãã ã•ã„.
Ruby拡張モジュールã«ã¤ã„ã¦è©±ã—åˆã†ruby-extãƒ¡ãƒ¼ãƒªãƒ³ã‚°ãƒªã‚¹ãƒˆã¨æ•°å­¦é–¢ä¿‚ã®è©±é¡Œã«ã¤ã„ã¦è©±ã—åˆã†ruby-mathメーリングリストã¨
英語ã§rubyã«ã¤ã„ã¦è©±ã—åˆã†ruby-talkメーリングリストもã‚りã¾ã™ï¼Žå‚加方法ã¯ã©ã‚Œã‚‚åŒã˜ã§ã™ï¼Ž
-[ruby-list-request@ruby-lang.org]: mailto:ruby-list-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
-[ruby-dev-request@ruby-lang.org]: mailto:ruby-dev-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
+[ruby-list-request@ml.ruby-lang.org]: mailto:ruby-list-request@ml.ruby-lang.org?subject=join
+[ruby-dev-request@ml.ruby-lang.org]: mailto:ruby-dev-request@ml.ruby-lang.org?subject=join
## コンパイル・インストール
@@ -152,7 +156,7 @@ UNIXã§ã‚れ㰠`configure` ãŒã»ã¨ã‚“ã©ã®å·®ç•°ã‚’å¸åŽã—ã¦ãれるã¯
## é…布æ¡ä»¶
-[COPYING.ja](COPYING.ja) ファイルをå‚ç…§ã—ã¦ãã ã•ã„.
+[COPYING.ja](https://docs.ruby-lang.org/en/master/COPYING_ja.html) ファイルをå‚ç…§ã—ã¦ãã ã•ã„.
## フィードãƒãƒƒã‚¯
diff --git a/README.md b/README.md
index 4bbcff3f76..02435b419e 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
-[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
-[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
[![Travis Status](https://app.travis-ci.com/ruby/ruby.svg?branch=master)](https://app.travis-ci.com/ruby/ruby)
-[![Cirrus Status](https://api.cirrus-ci.com/github/ruby/ruby.svg)](https://cirrus-ci.com/github/ruby/ruby/master)
+
+[日本語](rdoc-ref:README.ja.md)
# What is Ruby?
@@ -25,7 +24,7 @@ It is simple, straightforward, and extensible.
* Dynamic Loading of Object Files (on some architectures)
* Highly Portable (works on many Unix-like/POSIX compatible platforms as
well as Windows, macOS, etc.) cf.
- https://github.com/ruby/ruby/blob/master/doc/maintainers.md#platform-maintainers
+ https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers
## How to get Ruby
@@ -53,7 +52,7 @@ if you are a committer.
## How to build
-see [Building Ruby](doc/contributing/building_ruby.md)
+See [Building Ruby](https://docs.ruby-lang.org/en/master/contributing/building_ruby_md.html)
## Ruby home page
@@ -69,11 +68,11 @@ https://www.ruby-lang.org/
There is a mailing list to discuss Ruby. To subscribe to this list, please
send the following phrase:
- subscribe
+ join
-in the mail body (not subject) to the address [ruby-talk-request@ruby-lang.org].
+in the mail subject (not body) to the address [ruby-talk-request@ml.ruby-lang.org].
-[ruby-talk-request@ruby-lang.org]: mailto:ruby-talk-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
+[ruby-talk-request@ml.ruby-lang.org]: mailto:ruby-talk-request@ml.ruby-lang.org?subject=join
## Copying
@@ -88,7 +87,7 @@ Bugs should be reported at https://bugs.ruby-lang.org. Read ["Reporting Issues"]
## Contributing
-See ["Contributing to Ruby"](https://docs.ruby-lang.org/en/master/contributing_md.html), which includes setup and build instructions.
+See ["Contributing to Ruby"](https://docs.ruby-lang.org/en/master/contributing/contributing_md.html), which includes setup and build instructions.
## The Author
diff --git a/addr2line.c b/addr2line.c
index 1c8de350d9..19a6a425c1 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -8,10 +8,14 @@
**********************************************************************/
-#if defined(__clang__)
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wgnu-empty-initializer")
#pragma clang diagnostic ignored "-Wgnu-empty-initializer"
+#endif
+#if __has_warning("-Wgcc-compat")
#pragma clang diagnostic ignored "-Wgcc-compat"
#endif
+#endif
#include "ruby/internal/config.h"
#include "ruby/defines.h"
@@ -52,13 +56,26 @@
# ifdef _AIX
#pragma alloca
# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
+# ifndef alloca /* predefined by HP cc +Olibcalls */
void *alloca();
# endif
# endif /* AIX */
-# endif /* HAVE_ALLOCA_H */
+# endif /* HAVE_ALLOCA_H */
+# ifndef UNREACHABLE
+# define UNREACHABLE __builtin_unreachable()
+# endif
+# ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(_) __builtin_unreachable()
+# endif
#endif /* __GNUC__ */
+#ifndef UNREACHABLE
+# define UNREACHABLE abort()
+#endif
+#ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(_) return (abort(), (_))
+#endif
+
#ifdef HAVE_DLADDR
# include <dlfcn.h>
#endif
@@ -127,7 +144,7 @@ void *alloca();
#define DW_LNE_define_file 0x03
#define DW_LNE_set_discriminator 0x04 /* DWARF4 */
-PRINTF_ARGS(static int kprintf(const char *fmt, ...), 1, 2);
+#define kprintf(...) fprintf(errout, "" __VA_ARGS__)
typedef struct line_info {
const char *dirname;
@@ -184,7 +201,7 @@ obj_dwarf_section_at(obj_info_t *obj, int n)
&obj->debug_line_str
};
if (n < 0 || DWARF_SECTION_COUNT <= n) {
- abort();
+ UNREACHABLE_RETURN(0);
}
return ary[n];
}
@@ -203,13 +220,13 @@ uleb128(const char **p)
unsigned long r = 0;
int s = 0;
for (;;) {
- unsigned char b = (unsigned char)*(*p)++;
- if (b < 0x80) {
- r += (unsigned long)b << s;
- break;
- }
- r += (b & 0x7f) << s;
- s += 7;
+ unsigned char b = (unsigned char)*(*p)++;
+ if (b < 0x80) {
+ r += (unsigned long)b << s;
+ break;
+ }
+ r += (b & 0x7f) << s;
+ s += 7;
}
return r;
}
@@ -220,44 +237,48 @@ sleb128(const char **p)
long r = 0;
int s = 0;
for (;;) {
- unsigned char b = (unsigned char)*(*p)++;
- if (b < 0x80) {
- if (b & 0x40) {
- r -= (0x80 - b) << s;
- }
- else {
- r += (b & 0x3f) << s;
- }
- break;
- }
- r += (b & 0x7f) << s;
- s += 7;
+ unsigned char b = (unsigned char)*(*p)++;
+ if (b < 0x80) {
+ if (b & 0x40) {
+ r -= (0x80 - b) << s;
+ }
+ else {
+ r += (b & 0x3f) << s;
+ }
+ break;
+ }
+ r += (b & 0x7f) << s;
+ s += 7;
}
return r;
}
static const char *
-get_nth_dirname(unsigned long dir, const char *p)
+get_nth_dirname(unsigned long dir, const char *p, FILE *errout)
{
if (!dir--) {
- return "";
+ return "";
}
while (dir--) {
- while (*p) p++;
- p++;
- if (!*p) {
- kprintf("Unexpected directory number %lu in %s\n",
- dir, binary_filename);
- return "";
- }
+ while (*p) p++;
+ p++;
+ if (!*p) {
+ kprintf("Unexpected directory number %lu in %s\n",
+ dir, binary_filename);
+ return "";
+ }
}
return p;
}
-static const char *parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t *obj, const char **out_path, uint64_t *out_directory_index);
+static const char *parse_ver5_debug_line_header(
+ const char *p, int idx, uint8_t format,
+ obj_info_t *obj, const char **out_path,
+ uint64_t *out_directory_index, FILE *errout);
static void
-fill_filename(int file, uint8_t format, uint16_t version, const char *include_directories, const char *filenames, line_info_t *line, obj_info_t *obj)
+fill_filename(int file, uint8_t format, uint16_t version, const char *include_directories,
+ const char *filenames, line_info_t *line, obj_info_t *obj, FILE *errout)
{
int i;
const char *p = filenames;
@@ -266,18 +287,20 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
if (version >= 5) {
const char *path;
uint64_t directory_index = -1;
- parse_ver5_debug_line_header(filenames, file, format, obj, &path, &directory_index);
+ parse_ver5_debug_line_header(filenames, file, format, obj, &path, &directory_index, errout);
line->filename = path;
- parse_ver5_debug_line_header(include_directories, (int)directory_index, format, obj, &path, NULL);
+ parse_ver5_debug_line_header(include_directories, (int)directory_index, format, obj, &path, NULL, errout);
line->dirname = path;
}
else {
for (i = 1; i <= file; i++) {
filename = p;
if (!*p) {
+#ifndef __APPLE__
/* Need to output binary file name? */
kprintf("Unexpected file number %d in %s at %tx\n",
file, binary_filename, filenames - obj->mapped);
+#endif
return;
}
while (*p) p++;
@@ -290,7 +313,7 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
if (i == file) {
line->filename = filename;
- line->dirname = get_nth_dirname(dir, include_directories);
+ line->dirname = get_nth_dirname(dir, include_directories, errout);
}
}
}
@@ -298,19 +321,19 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
static void
fill_line(int num_traces, void **traces, uintptr_t addr, int file, int line,
- uint8_t format, uint16_t version, const char *include_directories, const char *filenames,
- obj_info_t *obj, line_info_t *lines, int offset)
+ uint8_t format, uint16_t version, const char *include_directories, const char *filenames,
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
int i;
addr += obj->base_addr - obj->vmaddr;
for (i = offset; i < num_traces; i++) {
- uintptr_t a = (uintptr_t)traces[i];
- /* We assume one line code doesn't result >100 bytes of native code.
+ uintptr_t a = (uintptr_t)traces[i];
+ /* We assume one line code doesn't result >100 bytes of native code.
We may want more reliable way eventually... */
- if (addr < a && a < addr + 100) {
- fill_filename(file, format, version, include_directories, filenames, &lines[i], obj);
- lines[i].line = line;
- }
+ if (addr < a && a < addr + 100) {
+ fill_filename(file, format, version, include_directories, filenames, &lines[i], obj, errout);
+ lines[i].line = line;
+ }
}
}
@@ -333,7 +356,7 @@ struct LineNumberProgramHeader {
};
static int
-parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgramHeader *header)
+parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgramHeader *header, FILE *errout)
{
const char *p = *pp;
header->unit_length = *(uint32_t *)p;
@@ -341,8 +364,8 @@ parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgr
header->format = 4;
if (header->unit_length == 0xffffffff) {
- header->unit_length = *(uint64_t *)p;
- p += sizeof(uint64_t);
+ header->unit_length = *(uint64_t *)p;
+ p += sizeof(uint64_t);
header->format = 8;
}
@@ -379,7 +402,7 @@ parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgr
if (header->version >= 5) {
header->include_directories = p;
- p = parse_ver5_debug_line_header(p, -1, header->format, obj, NULL, NULL);
+ p = parse_ver5_debug_line_header(p, -1, header->format, obj, NULL, NULL, errout);
header->filenames = p;
}
else {
@@ -406,7 +429,7 @@ parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgr
static int
parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
- obj_info_t *obj, line_info_t *lines, int offset)
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
const char *p = (const char *)*debug_line;
struct LineNumberProgramHeader header;
@@ -423,109 +446,109 @@ parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
/* int epilogue_begin = 0; */
/* unsigned int isa = 0; */
- if (parse_debug_line_header(obj, &p, &header))
+ if (parse_debug_line_header(obj, &p, &header, errout))
return -1;
is_stmt = header.default_is_stmt;
-#define FILL_LINE() \
- do { \
- fill_line(num_traces, traces, addr, file, line, \
+#define FILL_LINE() \
+ do { \
+ fill_line(num_traces, traces, addr, file, line, \
header.format, \
header.version, \
header.include_directories, \
header.filenames, \
- obj, lines, offset); \
- /*basic_block = prologue_end = epilogue_begin = 0;*/ \
+ obj, lines, offset, errout); \
+ /*basic_block = prologue_end = epilogue_begin = 0;*/ \
} while (0)
while (p < header.cu_end) {
- unsigned long a;
- unsigned char op = *p++;
- switch (op) {
- case DW_LNS_copy:
- FILL_LINE();
- break;
- case DW_LNS_advance_pc:
- a = uleb128(&p) * header.minimum_instruction_length;
- addr += a;
- break;
- case DW_LNS_advance_line: {
- long a = sleb128(&p);
- line += a;
- break;
- }
- case DW_LNS_set_file:
- file = (unsigned int)uleb128(&p);
- break;
- case DW_LNS_set_column:
- /*column = (unsigned int)*/(void)uleb128(&p);
- break;
- case DW_LNS_negate_stmt:
- is_stmt = !is_stmt;
- break;
- case DW_LNS_set_basic_block:
- /*basic_block = 1; */
- break;
- case DW_LNS_const_add_pc:
- a = ((255UL - header.opcode_base) / header.line_range) *
- header.minimum_instruction_length;
- addr += a;
- break;
- case DW_LNS_fixed_advance_pc:
- a = *(uint16_t *)p;
- p += sizeof(uint16_t);
- addr += a;
- break;
- case DW_LNS_set_prologue_end:
- /* prologue_end = 1; */
- break;
- case DW_LNS_set_epilogue_begin:
- /* epilogue_begin = 1; */
- break;
- case DW_LNS_set_isa:
- /* isa = (unsigned int)*/(void)uleb128(&p);
- break;
- case 0:
- a = uleb128(&p);
- op = *p++;
- switch (op) {
- case DW_LNE_end_sequence:
- /* end_sequence = 1; */
- FILL_LINE();
- addr = 0;
- file = 1;
- line = 1;
- /* column = 0; */
- is_stmt = header.default_is_stmt;
- /* end_sequence = 0; */
- /* isa = 0; */
- break;
- case DW_LNE_set_address:
- addr = *(unsigned long *)p;
- p += sizeof(unsigned long);
- break;
- case DW_LNE_define_file:
- kprintf("Unsupported operation in %s\n",
- binary_filename);
- break;
- case DW_LNE_set_discriminator:
- /* TODO:currently ignore */
- uleb128(&p);
- break;
- default:
- kprintf("Unknown extended opcode: %d in %s\n",
- op, binary_filename);
- }
- break;
- default: {
+ unsigned long a;
+ unsigned char op = *p++;
+ switch (op) {
+ case DW_LNS_copy:
+ FILL_LINE();
+ break;
+ case DW_LNS_advance_pc:
+ a = uleb128(&p) * header.minimum_instruction_length;
+ addr += a;
+ break;
+ case DW_LNS_advance_line: {
+ long a = sleb128(&p);
+ line += a;
+ break;
+ }
+ case DW_LNS_set_file:
+ file = (unsigned int)uleb128(&p);
+ break;
+ case DW_LNS_set_column:
+ /*column = (unsigned int)*/(void)uleb128(&p);
+ break;
+ case DW_LNS_negate_stmt:
+ is_stmt = !is_stmt;
+ break;
+ case DW_LNS_set_basic_block:
+ /*basic_block = 1; */
+ break;
+ case DW_LNS_const_add_pc:
+ a = ((255UL - header.opcode_base) / header.line_range) *
+ header.minimum_instruction_length;
+ addr += a;
+ break;
+ case DW_LNS_fixed_advance_pc:
+ a = *(uint16_t *)p;
+ p += sizeof(uint16_t);
+ addr += a;
+ break;
+ case DW_LNS_set_prologue_end:
+ /* prologue_end = 1; */
+ break;
+ case DW_LNS_set_epilogue_begin:
+ /* epilogue_begin = 1; */
+ break;
+ case DW_LNS_set_isa:
+ /* isa = (unsigned int)*/(void)uleb128(&p);
+ break;
+ case 0:
+ a = uleb128(&p);
+ op = *p++;
+ switch (op) {
+ case DW_LNE_end_sequence:
+ /* end_sequence = 1; */
+ FILL_LINE();
+ addr = 0;
+ file = 1;
+ line = 1;
+ /* column = 0; */
+ is_stmt = header.default_is_stmt;
+ /* end_sequence = 0; */
+ /* isa = 0; */
+ break;
+ case DW_LNE_set_address:
+ addr = *(unsigned long *)p;
+ p += sizeof(unsigned long);
+ break;
+ case DW_LNE_define_file:
+ kprintf("Unsupported operation in %s\n",
+ binary_filename);
+ break;
+ case DW_LNE_set_discriminator:
+ /* TODO:currently ignore */
+ uleb128(&p);
+ break;
+ default:
+ kprintf("Unknown extended opcode: %d in %s\n",
+ op, binary_filename);
+ }
+ break;
+ default: {
uint8_t adjusted_opcode = op - header.opcode_base;
uint8_t operation_advance = adjusted_opcode / header.line_range;
/* NOTE: this code doesn't support VLIW */
addr += operation_advance * header.minimum_instruction_length;
line += header.line_base + (adjusted_opcode % header.line_range);
- FILL_LINE();
- }
- }
+ FILL_LINE();
+ }
+ }
}
*debug_line = (char *)p;
return 0;
@@ -533,17 +556,17 @@ parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
static int
parse_debug_line(int num_traces, void **traces,
- const char *debug_line, unsigned long size,
- obj_info_t *obj, line_info_t *lines, int offset)
+ const char *debug_line, unsigned long size,
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
const char *debug_line_end = debug_line + size;
while (debug_line < debug_line_end) {
- if (parse_debug_line_cu(num_traces, traces, &debug_line, obj, lines, offset))
- return -1;
+ if (parse_debug_line_cu(num_traces, traces, &debug_line, obj, lines, offset, errout))
+ return -1;
}
if (debug_line != debug_line_end) {
- kprintf("Unexpected size of .debug_line in %s\n",
- binary_filename);
+ kprintf("Unexpected size of .debug_line in %s\n",
+ binary_filename);
}
return 0;
}
@@ -551,7 +574,7 @@ parse_debug_line(int num_traces, void **traces,
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset);
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout);
static void
append_obj(obj_info_t **objp)
@@ -579,7 +602,7 @@ append_obj(obj_info_t **objp)
// check the path pattern of "/usr/lib/debug/usr/bin/ruby.debug"
static void
follow_debuglink(const char *debuglink, int num_traces, void **traces,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
static const char global_debug_dir[] = "/usr/lib/debug";
const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1;
@@ -589,13 +612,13 @@ follow_debuglink(const char *debuglink, int num_traces, void **traces,
p = strrchr(binary_filename, '/');
if (!p) {
- return;
+ return;
}
p[1] = '\0';
len = strlen(binary_filename);
if (len >= PATH_MAX - global_debug_dir_len)
- len = PATH_MAX - global_debug_dir_len - 1;
+ len = PATH_MAX - global_debug_dir_len - 1;
memmove(binary_filename + global_debug_dir_len, binary_filename, len);
memcpy(binary_filename, global_debug_dir, global_debug_dir_len);
len += global_debug_dir_len;
@@ -605,21 +628,22 @@ follow_debuglink(const char *debuglink, int num_traces, void **traces,
o2 = *objp;
o2->base_addr = o1->base_addr;
o2->path = o1->path;
- fill_lines(num_traces, traces, 0, objp, lines, offset);
+ fill_lines(num_traces, traces, 0, objp, lines, offset, errout);
}
// check the path pattern of "/usr/lib/debug/.build-id/ab/cdef1234.debug"
static void
follow_debuglink_build_id(const char *build_id, size_t build_id_size, int num_traces, void **traces,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
static const char global_debug_dir[] = "/usr/lib/debug/.build-id/";
+ static const char debug_suffix[] = ".debug";
const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1;
char *p;
obj_info_t *o1 = *objp, *o2;
size_t i;
- if (PATH_MAX < global_debug_dir_len + 1 + build_id_size * 2 + 6) return;
+ if (PATH_MAX < global_debug_dir_len + build_id_size * 2 + sizeof(debug_suffix)) return;
memcpy(binary_filename, global_debug_dir, global_debug_dir_len);
p = binary_filename + global_debug_dir_len;
@@ -630,13 +654,13 @@ follow_debuglink_build_id(const char *build_id, size_t build_id_size, int num_tr
*p++ = tbl[n % 16];
if (i == 0) *p++ = '/';
}
- strcpy(p, ".debug");
+ memcpy(p, debug_suffix, sizeof(debug_suffix));
append_obj(objp);
o2 = *objp;
o2->base_addr = o1->base_addr;
o2->path = o1->path;
- fill_lines(num_traces, traces, 0, objp, lines, offset);
+ fill_lines(num_traces, traces, 0, objp, lines, offset, errout);
}
#endif
@@ -840,7 +864,11 @@ enum
DW_FORM_addrx1 = 0x29,
DW_FORM_addrx2 = 0x2a,
DW_FORM_addrx3 = 0x2b,
- DW_FORM_addrx4 = 0x2c
+ DW_FORM_addrx4 = 0x2c,
+
+ /* GNU extensions for referring to .gnu_debugaltlink dwz-compressed info */
+ DW_FORM_GNU_ref_alt = 0x1f20,
+ DW_FORM_GNU_strp_alt = 0x1f21
};
/* Range list entry encodings */
@@ -1058,13 +1086,13 @@ di_read_debug_abbrev_cu(DebugInfoReader *reader)
}
static int
-di_read_debug_line_cu(DebugInfoReader *reader)
+di_read_debug_line_cu(DebugInfoReader *reader, FILE *errout)
{
const char *p;
struct LineNumberProgramHeader header;
p = (const char *)reader->debug_line_cu_end;
- if (parse_debug_line_header(reader->obj, &p, &header))
+ if (parse_debug_line_header(reader->obj, &p, &header, errout))
return -1;
reader->debug_line_cu_end = (char *)header.cu_end;
@@ -1144,19 +1172,32 @@ resolve_strx(DebugInfoReader *reader, uint64_t idx)
return reader->obj->debug_str.ptr + off;
}
-static void
-debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoValue *v)
+static bool
+debug_info_reader_read_addr_value_member(DebugInfoReader *reader, DebugInfoValue *v, int size)
+{
+ if (size == 4) {
+ set_uint_value(v, read_uint32(&reader->p));
+ } else if (size == 8) {
+ set_uint_value(v, read_uint64(&reader->p));
+ } else {
+ return false;
+ }
+ return true;
+}
+
+#define debug_info_reader_read_addr_value(reader, v, mem) \
+ if (!debug_info_reader_read_addr_value_member((reader), (v), (reader)->mem)) { \
+ kprintf("unknown " #mem ":%d", (reader)->mem); \
+ return false; \
+ }
+
+
+static bool
+debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoValue *v, FILE *errout)
{
switch (form) {
case DW_FORM_addr:
- if (reader->address_size == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->address_size == 8) {
- set_uint_value(v, read_uint64(&reader->p));
- } else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
- }
+ debug_info_reader_read_addr_value(reader, v, address_size);
break;
case DW_FORM_block2:
v->size = read_uint16(&reader->p);
@@ -1208,13 +1249,12 @@ debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoVa
set_uint_value(v, read_uleb128(reader));
break;
case DW_FORM_ref_addr:
- if (reader->format == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->format == 8) {
- set_uint_value(v, read_uint64(&reader->p));
+ if (reader->current_version <= 2) {
+ // DWARF Version 2 specifies that references have
+ // the same size as an address on the target system
+ debug_info_reader_read_addr_value(reader, v, address_size);
} else {
- fprintf(stderr,"unknown format:%d", reader->format);
- abort();
+ debug_info_reader_read_addr_value(reader, v, format);
}
break;
case DW_FORM_ref1:
@@ -1315,20 +1355,28 @@ debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoVa
case DW_FORM_addrx4:
set_addr_idx_value(v, read_uint32(&reader->p));
break;
+ /* we have no support for actually reading the real values of these refs out
+ * of the .gnu_debugaltlink dwz-compressed debuginfo at the moment, but "read"
+ * them anyway so that we advance the reader by the right amount. */
+ case DW_FORM_GNU_ref_alt:
+ case DW_FORM_GNU_strp_alt:
+ read_uint(reader);
+ set_uint_value(v, 0);
+ break;
case 0:
goto fail;
break;
}
- return;
+ return true;
fail:
- fprintf(stderr, "%d: unsupported form: %#"PRIx64"\n", __LINE__, form);
- exit(1);
+ kprintf("%d: unsupported form: %#"PRIx64"\n", __LINE__, form);
+ return false;
}
/* find abbrev in current compilation unit */
static const char *
-di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
+di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number, FILE *errout)
{
const char *p;
if (abbrev_number < ABBREV_TABLE_SIZE) {
@@ -1341,8 +1389,8 @@ di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
di_skip_die_attributes(&p);
for (uint64_t n = uleb128(&p); abbrev_number != n; n = uleb128(&p)) {
if (n == 0) {
- fprintf(stderr,"%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
- exit(1);
+ kprintf("%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
+ return NULL;
}
uleb128(&p); /* tag */
p++; /* has_children */
@@ -1353,52 +1401,52 @@ di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
#if 0
static void
-hexdump0(const unsigned char *p, size_t n)
+hexdump0(const unsigned char *p, size_t n, FILE *errout)
{
size_t i;
- fprintf(stderr, " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
+ kprintf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
for (i=0; i < n; i++){
switch (i & 15) {
case 0:
- fprintf(stderr, "%02" PRIdSIZE ": %02X ", i/16, p[i]);
+ kprintf("%02" PRIdSIZE ": %02X ", i/16, p[i]);
break;
case 15:
- fprintf(stderr, "%02X\n", p[i]);
+ kprintf("%02X\n", p[i]);
break;
default:
- fprintf(stderr, "%02X ", p[i]);
+ kprintf("%02X ", p[i]);
break;
}
}
if ((i & 15) != 15) {
- fprintf(stderr, "\n");
+ kprintf("\n");
}
}
-#define hexdump(p,n) hexdump0((const unsigned char *)p, n)
+#define hexdump(p,n,e) hexdump0((const unsigned char *)p, n, e)
static void
-div_inspect(DebugInfoValue *v)
+div_inspect(DebugInfoValue *v, FILE *errout)
{
switch (v->type) {
case VAL_uint:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
break;
case VAL_int:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
break;
case VAL_cstr:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
break;
case VAL_data:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:\n",__LINE__,v->type,v->size);
- hexdump(v->as.ptr, 16);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:\n",__LINE__,v->type,v->size);
+ hexdump(v->as.ptr, 16, errout);
break;
}
}
#endif
static DIE *
-di_read_die(DebugInfoReader *reader, DIE *die)
+di_read_die(DebugInfoReader *reader, DIE *die, FILE *errout)
{
uint64_t abbrev_number = uleb128(&reader->p);
if (abbrev_number == 0) {
@@ -1406,7 +1454,7 @@ di_read_die(DebugInfoReader *reader, DIE *die)
return NULL;
}
- reader->q = di_find_abbrev(reader, abbrev_number);
+ if (!(reader->q = di_find_abbrev(reader, abbrev_number, errout))) return NULL;
die->pos = reader->p - reader->obj->debug_info.ptr - 1;
die->tag = (int)uleb128(&reader->q); /* tag */
@@ -1418,26 +1466,26 @@ di_read_die(DebugInfoReader *reader, DIE *die)
}
static DebugInfoValue *
-di_read_record(DebugInfoReader *reader, DebugInfoValue *vp)
+di_read_record(DebugInfoReader *reader, DebugInfoValue *vp, FILE *errout)
{
uint64_t at = uleb128(&reader->q);
uint64_t form = uleb128(&reader->q);
if (!at || !form) return NULL;
vp->at = at;
vp->form = form;
- debug_info_reader_read_value(reader, form, vp);
+ if (!debug_info_reader_read_value(reader, form, vp, errout)) return NULL;
return vp;
}
-static void
-di_skip_records(DebugInfoReader *reader)
+static bool
+di_skip_records(DebugInfoReader *reader, FILE *errout)
{
for (;;) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
uint64_t at = uleb128(&reader->q);
uint64_t form = uleb128(&reader->q);
- if (!at || !form) return;
- debug_info_reader_read_value(reader, form, &v);
+ if (!at || !form) return true;
+ if (!debug_info_reader_read_value(reader, form, &v, errout)) return false;
}
}
@@ -1449,13 +1497,14 @@ typedef struct addr_header {
/* uint8_t segment_selector_size; */
} addr_header_t;
-static void
-addr_header_init(obj_info_t *obj, addr_header_t *header) {
+static bool
+addr_header_init(obj_info_t *obj, addr_header_t *header, FILE *errout)
+{
const char *p = obj->debug_addr.ptr;
header->ptr = p;
- if (!p) return;
+ if (!p) return true;
header->unit_length = *(uint32_t *)p;
p += sizeof(uint32_t);
@@ -1469,7 +1518,12 @@ addr_header_init(obj_info_t *obj, addr_header_t *header) {
p += 2; /* version */
header->address_size = *p++;
+ if (header->address_size != 4 && header->address_size != 8) {
+ kprintf("unknown address_size:%d", header->address_size);
+ return false;
+ }
p++; /* segment_selector_size */
+ return true;
}
static uint64_t
@@ -1489,11 +1543,12 @@ typedef struct rnglists_header {
uint32_t offset_entry_count;
} rnglists_header_t;
-static void
-rnglists_header_init(obj_info_t *obj, rnglists_header_t *header) {
+static bool
+rnglists_header_init(obj_info_t *obj, rnglists_header_t *header, FILE *errout)
+{
const char *p = obj->debug_rnglists.ptr;
- if (!p) return;
+ if (!p) return true;
header->unit_length = *(uint32_t *)p;
p += sizeof(uint32_t);
@@ -1507,8 +1562,13 @@ rnglists_header_init(obj_info_t *obj, rnglists_header_t *header) {
p += 2; /* version */
header->address_size = *p++;
+ if (header->address_size != 4 && header->address_size != 8) {
+ kprintf("unknown address_size:%d", header->address_size);
+ return false;
+ }
p++; /* segment_selector_size */
header->offset_entry_count = *(uint32_t *)p;
+ return true;
}
typedef struct {
@@ -1552,26 +1612,23 @@ ranges_set(ranges_t *ptr, DebugInfoValue *v, addr_header_t *addr_header, uint64_
}
static uint64_t
-read_dw_form_addr(DebugInfoReader *reader, const char **ptr)
+read_dw_form_addr(DebugInfoReader *reader, const char **ptr, FILE *errout)
{
const char *p = *ptr;
*ptr = p + reader->address_size;
if (reader->address_size == 4) {
return read_uint32(&p);
- } else if (reader->address_size == 8) {
- return read_uint64(&p);
} else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
+ return read_uint64(&p);
}
}
static uintptr_t
-ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_header_t *rnglists_header)
+ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_header_t *rnglists_header, FILE *errout)
{
if (ptr->high_pc_set) {
if (ptr->ranges_set || !ptr->low_pc_set) {
- exit(1);
+ return UINTPTR_MAX;
}
if (ptr->low_pc <= addr && addr <= ptr->high_pc) {
return (uintptr_t)ptr->low_pc;
@@ -1620,15 +1677,15 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
to = (uintptr_t)base + uleb128(&p);
break;
case DW_RLE_base_address:
- base = read_dw_form_addr(reader, &p);
+ base = read_dw_form_addr(reader, &p, errout);
base_valid = true;
break;
case DW_RLE_start_end:
- from = (uintptr_t)read_dw_form_addr(reader, &p);
- to = (uintptr_t)read_dw_form_addr(reader, &p);
+ from = (uintptr_t)read_dw_form_addr(reader, &p, errout);
+ to = (uintptr_t)read_dw_form_addr(reader, &p, errout);
break;
case DW_RLE_start_length:
- from = (uintptr_t)read_dw_form_addr(reader, &p);
+ from = (uintptr_t)read_dw_form_addr(reader, &p, errout);
to = from + uleb128(&p);
break;
}
@@ -1636,7 +1693,7 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
return from;
}
}
- return false;
+ return 0;
}
p = reader->obj->debug_ranges.ptr + ptr->ranges;
for (;;) {
@@ -1657,42 +1714,42 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
return (uintptr_t)ptr->low_pc;
}
}
- return false;
+ return 0;
}
#if 0
static void
-ranges_inspect(DebugInfoReader *reader, ranges_t *ptr)
+ranges_inspect(DebugInfoReader *reader, ranges_t *ptr, FILE *errout)
{
if (ptr->high_pc_set) {
if (ptr->ranges_set || !ptr->low_pc_set) {
- fprintf(stderr,"low_pc_set:%d high_pc_set:%d ranges_set:%d\n",ptr->low_pc_set,ptr->high_pc_set,ptr->ranges_set);
- exit(1);
+ kprintf("low_pc_set:%d high_pc_set:%d ranges_set:%d\n",ptr->low_pc_set,ptr->high_pc_set,ptr->ranges_set);
+ return;
}
- fprintf(stderr,"low_pc:%"PRIx64" high_pc:%"PRIx64"\n",ptr->low_pc,ptr->high_pc);
+ kprintf("low_pc:%"PRIx64" high_pc:%"PRIx64"\n",ptr->low_pc,ptr->high_pc);
}
else if (ptr->ranges_set) {
char *p = reader->obj->debug_ranges.ptr + ptr->ranges;
- fprintf(stderr,"low_pc:%"PRIx64" ranges:%"PRIx64" %lx ",ptr->low_pc,ptr->ranges, p-reader->obj->mapped);
+ kprintf("low_pc:%"PRIx64" ranges:%"PRIx64" %lx ",ptr->low_pc,ptr->ranges, p-reader->obj->mapped);
for (;;) {
uintptr_t from = read_uintptr(&p);
uintptr_t to = read_uintptr(&p);
if (!from && !to) break;
- fprintf(stderr,"%"PRIx64"-%"PRIx64" ",ptr->low_pc+from,ptr->low_pc+to);
+ kprintf("%"PRIx64"-%"PRIx64" ",ptr->low_pc+from,ptr->low_pc+to);
}
- fprintf(stderr,"\n");
+ kprintf("\n");
}
else if (ptr->low_pc_set) {
- fprintf(stderr,"low_pc:%"PRIx64"\n",ptr->low_pc);
+ kprintf("low_pc:%"PRIx64"\n",ptr->low_pc);
}
else {
- fprintf(stderr,"empty\n");
+ kprintf("empty\n");
}
}
#endif
static int
-di_read_cu(DebugInfoReader *reader)
+di_read_cu(DebugInfoReader *reader, FILE *errout)
{
uint64_t unit_length;
uint16_t version;
@@ -1719,19 +1776,23 @@ di_read_cu(DebugInfoReader *reader)
debug_abbrev_offset = read_uint(reader);
reader->address_size = read_uint8(&reader->p);
}
+ if (reader->address_size != 4 && reader->address_size != 8) {
+ kprintf("unknown address_size:%d", reader->address_size);
+ return -1;
+ }
reader->q0 = reader->obj->debug_abbrev.ptr + debug_abbrev_offset;
reader->level = 0;
di_read_debug_abbrev_cu(reader);
- if (di_read_debug_line_cu(reader)) return -1;
+ if (di_read_debug_line_cu(reader, errout)) return -1;
do {
DIE die;
- if (!di_read_die(reader, &die)) continue;
+ if (!di_read_die(reader, &die, errout)) continue;
if (die.tag != DW_TAG_compile_unit) {
- di_skip_records(reader);
+ if (!di_skip_records(reader, errout)) return -1;
break;
}
@@ -1739,11 +1800,11 @@ di_read_cu(DebugInfoReader *reader)
reader->current_addr_base = 0;
reader->current_rnglists_base = 0;
- DebugInfoValue low_pc = {{}};
+ DebugInfoValue low_pc = {{0}};
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
+ DebugInfoValue v = {{0}};
+ if (!di_read_record(reader, &v, errout)) break;
switch (v.at) {
case DW_AT_low_pc:
// clang may output DW_AT_addr_base after DW_AT_low_pc.
@@ -1768,8 +1829,8 @@ di_read_cu(DebugInfoReader *reader)
break;
case VAL_addr:
{
- addr_header_t header = {};
- addr_header_init(reader->obj, &header);
+ addr_header_t header = {0};
+ if (!addr_header_init(reader->obj, &header, errout)) return -1;
reader->current_low_pc = read_addr(&header, reader->current_addr_base, low_pc.as.addr_idx);
}
break;
@@ -1780,7 +1841,7 @@ di_read_cu(DebugInfoReader *reader)
}
static void
-read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_origin, line_info_t *line)
+read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_origin, line_info_t *line, FILE *errout)
{
const char *p = reader->p;
const char *q = reader->q;
@@ -1805,12 +1866,12 @@ read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_o
default:
goto finish;
}
- if (!di_read_die(reader, &die)) goto finish;
+ if (!di_read_die(reader, &die, errout)) goto finish;
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
+ DebugInfoValue v = {{0}};
+ if (!di_read_record(reader, &v, errout)) break;
switch (v.at) {
case DW_AT_name:
line->sname = get_cstr_value(&v);
@@ -1824,43 +1885,44 @@ read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_o
reader->level = level;
}
-static void
+static bool
debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
- line_info_t *lines, int offset) {
+ line_info_t *lines, int offset, FILE *errout)
+{
- addr_header_t addr_header = {};
- addr_header_init(reader->obj, &addr_header);
+ addr_header_t addr_header = {0};
+ if (!addr_header_init(reader->obj, &addr_header, errout)) return false;
- rnglists_header_t rnglists_header = {};
- rnglists_header_init(reader->obj, &rnglists_header);
+ rnglists_header_t rnglists_header = {0};
+ if (!rnglists_header_init(reader->obj, &rnglists_header, errout)) return false;
while (reader->p < reader->cu_end) {
DIE die;
- ranges_t ranges = {};
- line_info_t line = {};
+ ranges_t ranges = {0};
+ line_info_t line = {0};
- if (!di_read_die(reader, &die)) continue;
- /* fprintf(stderr,"%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
+ if (!di_read_die(reader, &die, errout)) continue;
+ /* kprintf("%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
if (die.tag != DW_TAG_subprogram && die.tag != DW_TAG_inlined_subroutine) {
skip_die:
- di_skip_records(reader);
+ if (!di_skip_records(reader, errout)) return false;
continue;
}
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
/* ptrdiff_t pos = reader->p - reader->p0; */
- if (!di_read_record(reader, &v)) break;
- /* fprintf(stderr,"\n%d:%tx: AT:%lx FORM:%lx\n",__LINE__,pos,v.at,v.form); */
- /* div_inspect(&v); */
+ if (!di_read_record(reader, &v, errout)) break;
+ /* kprintf("\n%d:%tx: AT:%lx FORM:%lx\n",__LINE__,pos,v.at,v.form); */
+ /* div_inspect(&v, errout); */
switch (v.at) {
case DW_AT_name:
line.sname = get_cstr_value(&v);
break;
case DW_AT_call_file:
- fill_filename((int)v.as.uint64, reader->debug_line_format, reader->debug_line_version, reader->debug_line_directories, reader->debug_line_files, &line, reader->obj);
+ fill_filename((int)v.as.uint64, reader->debug_line_format, reader->debug_line_version, reader->debug_line_directories, reader->debug_line_files, &line, reader->obj, errout);
break;
case DW_AT_call_line:
line.line = (int)v.as.uint64;
@@ -1876,18 +1938,19 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
/* 1 or 3 */
break; /* goto skip_die; */
case DW_AT_abstract_origin:
- read_abstract_origin(reader, v.form, v.as.uint64, &line);
+ read_abstract_origin(reader, v.form, v.as.uint64, &line, errout);
break; /* goto skip_die; */
}
}
- /* ranges_inspect(reader, &ranges); */
- /* fprintf(stderr,"%d:%tx: %x ",__LINE__,diepos,die.tag); */
+ /* ranges_inspect(reader, &ranges, errout); */
+ /* kprintf("%d:%tx: %x ",__LINE__,diepos,die.tag); */
for (int i=offset; i < num_traces; i++) {
uintptr_t addr = (uintptr_t)traces[i];
uintptr_t offset = addr - reader->obj->base_addr + reader->obj->vmaddr;
- uintptr_t saddr = ranges_include(reader, &ranges, offset, &rnglists_header);
+ uintptr_t saddr = ranges_include(reader, &ranges, offset, &rnglists_header, errout);
+ if (saddr == UINTPTR_MAX) return false;
if (saddr) {
- /* fprintf(stdout, "%d:%tx: %d %lx->%lx %x %s: %s/%s %d %s %s %s\n",__LINE__,die.pos, i,addr,offset, die.tag,line.sname,line.dirname,line.filename,line.line,reader->obj->path,line.sname,lines[i].sname); */
+ /* kprintf("%d:%tx: %d %lx->%lx %x %s: %s/%s %d %s %s %s\n",__LINE__,die.pos, i,addr,offset, die.tag,line.sname,line.dirname,line.filename,line.line,reader->obj->path,line.sname,lines[i].sname); */
if (lines[i].sname) {
line_info_t *lp = malloc(sizeof(line_info_t));
memcpy(lp, &lines[i], sizeof(line_info_t));
@@ -1904,6 +1967,7 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
}
}
}
+ return true;
}
// This function parses the following attributes of Line Number Program Header in DWARF 5:
@@ -1922,7 +1986,10 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
//
// It records DW_LNCT_path and DW_LNCT_directory_index at the index "idx".
static const char *
-parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t *obj, const char **out_path, uint64_t *out_directory_index) {
+parse_ver5_debug_line_header(const char *p, int idx, uint8_t format,
+ obj_info_t *obj, const char **out_path,
+ uint64_t *out_directory_index, FILE *errout)
+{
int i, j;
int entry_format_count = *(uint8_t *)p++;
const char *entry_format = p;
@@ -1932,17 +1999,17 @@ parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t
int entry_count = (int)uleb128(&p);
- DebugInfoReader reader;
+ DebugInfoReader reader = {0};
debug_info_reader_init(&reader, obj);
reader.format = format;
reader.p = p;
for (j = 0; j < entry_count; j++) {
const char *format = entry_format;
for (i = 0; i < entry_format_count; i++) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
unsigned long dw_lnct = uleb128(&format);
unsigned long dw_form = uleb128(&format);
- debug_info_reader_read_value(&reader, dw_form, &v);
+ if (!debug_info_reader_read_value(&reader, dw_form, &v, errout)) return 0;
if (dw_lnct == 1 /* DW_LNCT_path */ && v.type == VAL_cstr && out_path)
*out_path = v.as.ptr + v.off;
if (dw_lnct == 2 /* DW_LNCT_directory_index */ && v.type == VAL_uint && out_directory_index)
@@ -1965,14 +2032,14 @@ uncompress_debug_section(ElfW(Shdr) *shdr, char *file, char **ptr)
int ret = 0;
if (chdr->ch_type != ELFCOMPRESS_ZLIB) {
- /* unsupported compression type */
- return 0;
+ /* unsupported compression type */
+ return 0;
}
*ptr = malloc(destsize);
if (!*ptr) return 0;
ret = uncompress((Bytef *)*ptr, &destsize,
- (const Bytef*)chdr + sizeof(ElfW(Chdr)),
+ (const Bytef*)chdr + sizeof(ElfW(Chdr)),
shdr->sh_size - sizeof(ElfW(Chdr)));
if (ret != Z_OK) goto fail;
return destsize;
@@ -1987,7 +2054,7 @@ fail:
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
int i, j;
char *shstr;
@@ -2005,40 +2072,40 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
fd = open(binary_filename, O_RDONLY);
if (fd < 0) {
- goto fail;
+ goto fail;
}
filesize = lseek(fd, 0, SEEK_END);
if (filesize < 0) {
- int e = errno;
- close(fd);
- kprintf("lseek: %s\n", strerror(e));
- goto fail;
+ int e = errno;
+ close(fd);
+ kprintf("lseek: %s\n", strerror(e));
+ goto fail;
}
#if SIZEOF_OFF_T > SIZEOF_SIZE_T
if (filesize > (off_t)SIZE_MAX) {
- close(fd);
- kprintf("Too large file %s\n", binary_filename);
- goto fail;
+ close(fd);
+ kprintf("Too large file %s\n", binary_filename);
+ goto fail;
}
#endif
lseek(fd, 0, SEEK_SET);
/* async-signal unsafe */
file = (char *)mmap(NULL, (size_t)filesize, PROT_READ, MAP_SHARED, fd, 0);
if (file == MAP_FAILED) {
- int e = errno;
- close(fd);
- kprintf("mmap: %s\n", strerror(e));
- goto fail;
+ int e = errno;
+ close(fd);
+ kprintf("mmap: %s\n", strerror(e));
+ goto fail;
}
close(fd);
ehdr = (ElfW(Ehdr) *)file;
if (memcmp(ehdr->e_ident, "\177ELF", 4) != 0) {
- /*
- * Huh? Maybe filename was overridden by setproctitle() and
- * it match non-elf file.
- */
- goto fail;
+ /*
+ * Huh? Maybe filename was overridden by setproctitle() and
+ * it match non-elf file.
+ */
+ goto fail;
}
obj->mapped = file;
obj->mapped_size = (size_t)filesize;
@@ -2050,32 +2117,32 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
for (i = 0; i < ehdr->e_shnum; i++) {
char *section_name = shstr + shdr[i].sh_name;
- switch (shdr[i].sh_type) {
- case SHT_STRTAB:
- if (!strcmp(section_name, ".strtab")) {
- strtab_shdr = shdr + i;
- }
- else if (!strcmp(section_name, ".dynstr")) {
- dynstr_shdr = shdr + i;
- }
- break;
- case SHT_SYMTAB:
- /* if (!strcmp(section_name, ".symtab")) */
- symtab_shdr = shdr + i;
- break;
- case SHT_DYNSYM:
- /* if (!strcmp(section_name, ".dynsym")) */
- dynsym_shdr = shdr + i;
- break;
+ switch (shdr[i].sh_type) {
+ case SHT_STRTAB:
+ if (!strcmp(section_name, ".strtab")) {
+ strtab_shdr = shdr + i;
+ }
+ else if (!strcmp(section_name, ".dynstr")) {
+ dynstr_shdr = shdr + i;
+ }
+ break;
+ case SHT_SYMTAB:
+ /* if (!strcmp(section_name, ".symtab")) */
+ symtab_shdr = shdr + i;
+ break;
+ case SHT_DYNSYM:
+ /* if (!strcmp(section_name, ".dynsym")) */
+ dynsym_shdr = shdr + i;
+ break;
case SHT_NOTE:
if (!strcmp(section_name, ".note.gnu.build-id")) {
note_gnu_build_id = shdr + i;
}
break;
- case SHT_PROGBITS:
- if (!strcmp(section_name, ".gnu_debuglink")) {
- gnu_debuglink_shdr = shdr + i;
- }
+ case SHT_PROGBITS:
+ if (!strcmp(section_name, ".gnu_debuglink")) {
+ gnu_debuglink_shdr = shdr + i;
+ }
else {
const char *debug_section_names[] = {
".debug_abbrev",
@@ -2105,17 +2172,16 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
break;
}
}
- break;
- }
+ break;
+ }
}
- if (offset == -1) {
- /* main executable */
- offset = 0;
- if (dynsym_shdr && dynstr_shdr) {
- char *strtab = file + dynstr_shdr->sh_offset;
- ElfW(Sym) *symtab = (ElfW(Sym) *)(file + dynsym_shdr->sh_offset);
- int symtab_count = (int)(dynsym_shdr->sh_size / sizeof(ElfW(Sym)));
+ if (offset == 0) {
+ /* main executable */
+ if (dynsym_shdr && dynstr_shdr) {
+ char *strtab = file + dynstr_shdr->sh_offset;
+ ElfW(Sym) *symtab = (ElfW(Sym) *)(file + dynsym_shdr->sh_offset);
+ int symtab_count = (int)(dynsym_shdr->sh_size / sizeof(ElfW(Sym)));
void *handle = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
if (handle) {
for (j = 0; j < symtab_count; j++) {
@@ -2132,14 +2198,14 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
}
dlclose(handle);
}
- if (ehdr->e_type == ET_EXEC) {
- obj->base_addr = 0;
- }
- else {
- /* PIE (position-independent executable) */
- obj->base_addr = dladdr_fbase;
- }
- }
+ if (ehdr->e_type == ET_EXEC) {
+ obj->base_addr = 0;
+ }
+ else {
+ /* PIE (position-independent executable) */
+ obj->base_addr = dladdr_fbase;
+ }
+ }
}
if (obj->debug_info.ptr && obj->debug_abbrev.ptr) {
@@ -2147,9 +2213,10 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
debug_info_reader_init(&reader, obj);
i = 0;
while (reader.p < reader.pend) {
- /* fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
- if (di_read_cu(&reader)) goto use_symtab;
- debug_info_read(&reader, num_traces, traces, lines, offset);
+ /* kprintf("%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
+ if (di_read_cu(&reader, errout)) goto use_symtab;
+ if (!debug_info_read(&reader, num_traces, traces, lines, offset, errout))
+ goto use_symtab;
}
}
else {
@@ -2184,27 +2251,27 @@ use_symtab:
}
if (!obj->debug_line.ptr) {
- /* This file doesn't have .debug_line section,
- let's check .gnu_debuglink section instead. */
- if (gnu_debuglink_shdr && check_debuglink) {
- follow_debuglink(file + gnu_debuglink_shdr->sh_offset,
- num_traces, traces,
- objp, lines, offset);
- }
+ /* This file doesn't have .debug_line section,
+ let's check .gnu_debuglink section instead. */
+ if (gnu_debuglink_shdr && check_debuglink) {
+ follow_debuglink(file + gnu_debuglink_shdr->sh_offset,
+ num_traces, traces,
+ objp, lines, offset, errout);
+ }
if (note_gnu_build_id && check_debuglink) {
ElfW(Nhdr) *nhdr = (ElfW(Nhdr)*) (file + note_gnu_build_id->sh_offset);
const char *build_id = (char *)(nhdr + 1) + nhdr->n_namesz;
follow_debuglink_build_id(build_id, nhdr->n_descsz,
- num_traces, traces,
- objp, lines, offset);
+ num_traces, traces,
+ objp, lines, offset, errout);
}
- goto finish;
+ goto finish;
}
if (parse_debug_line(num_traces, traces,
obj->debug_line.ptr,
obj->debug_line.size,
- obj, lines, offset) == -1)
+ obj, lines, offset, errout) == -1)
goto fail;
finish:
@@ -2216,7 +2283,7 @@ fail:
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
# ifdef __LP64__
# define LP(x) x##_64
@@ -2295,13 +2362,13 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
struct fat_header *fat = (struct fat_header *)file;
char *q = file + sizeof(*fat);
uint32_t nfat_arch = __builtin_bswap32(fat->nfat_arch);
- /* fprintf(stderr,"%d: fat:%s %d\n",__LINE__, binary_filename,nfat_arch); */
+ /* kprintf("%d: fat:%s %d\n",__LINE__, binary_filename,nfat_arch); */
for (uint32_t i = 0; i < nfat_arch; i++) {
struct fat_arch *arch = (struct fat_arch *)q;
cpu_type_t cputype = __builtin_bswap32(arch->cputype);
cpu_subtype_t cpusubtype = __builtin_bswap32(arch->cpusubtype);
uint32_t offset = __builtin_bswap32(arch->offset);
- /* fprintf(stderr,"%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */
+ /* kprintf("%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */
if (mhp->cputype == cputype &&
(cpu_subtype_t)(mhp->cpusubtype & ~CPU_SUBTYPE_MASK) == cpusubtype) {
p = file + offset;
@@ -2319,13 +2386,14 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
goto fail;
}
else {
- kprintf("'%s' is not a "
# ifdef __LP64__
- "64"
+# define bitsize "64"
# else
- "32"
+# define bitsize "32"
# endif
+ kprintf("'%s' is not a " bitsize
"-bit Mach-O file!\n",binary_filename);
+# undef bitsize
close(fd);
goto fail;
}
@@ -2360,7 +2428,17 @@ found_mach_header:
for (int j=0; j < DWARF_SECTION_COUNT; j++) {
struct dwarf_section *s = obj_dwarf_section_at(obj, j);
- if (strcmp(sect->sectname, debug_section_names[j]) != 0)
+ if (strcmp(sect->sectname, debug_section_names[j]) != 0
+#ifdef __APPLE__
+ /* macOS clang 16 generates DWARF5, which have Mach-O
+ * section names that are limited to 16 characters,
+ * which causes sections with long names to be truncated
+ * and not match above.
+ * See: https://wiki.dwarfstd.org/Best_Practices.md#Mach-2d-O
+ */
+ && strncmp(sect->sectname, debug_section_names[j], 16) != 0
+#endif
+ )
continue;
s->ptr = file + sect->offset;
@@ -2417,15 +2495,16 @@ found_mach_header:
DebugInfoReader reader;
debug_info_reader_init(&reader, obj);
while (reader.p < reader.pend) {
- if (di_read_cu(&reader)) goto fail;
- debug_info_read(&reader, num_traces, traces, lines, offset);
+ if (di_read_cu(&reader, errout)) goto fail;
+ if (!debug_info_read(&reader, num_traces, traces, lines, offset, errout))
+ goto fail;
}
}
if (parse_debug_line(num_traces, traces,
obj->debug_line.ptr,
obj->debug_line.size,
- obj, lines, offset) == -1)
+ obj, lines, offset, errout) == -1)
goto fail;
return dladdr_fbase;
@@ -2438,7 +2517,7 @@ fail:
#if defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/sysctl.h>
#endif
-/* ssize_t main_exe_path(void)
+/* ssize_t main_exe_path(FILE *errout)
*
* store the path of the main executable to `binary_filename`,
* and returns strlen(binary_filename).
@@ -2446,7 +2525,7 @@ fail:
*/
#if defined(__linux__) || defined(__NetBSD__)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
# if defined(__linux__)
# define PROC_SELF_EXE "/proc/self/exe"
@@ -2460,21 +2539,21 @@ main_exe_path(void)
}
#elif defined(__FreeBSD__) || defined(__DragonFly__)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
size_t len = PATH_MAX;
int err = sysctl(mib, 4, binary_filename, &len, NULL, 0);
if (err) {
- kprintf("Can't get the path of ruby");
- return -1;
+ kprintf("Can't get the path of ruby");
+ return -1;
}
len--; /* sysctl sets strlen+1 */
return len;
}
#elif defined(HAVE_LIBPROC_H)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
int len = proc_pidpath(getpid(), binary_filename, PATH_MAX);
if (len == 0) return 0;
@@ -2486,7 +2565,7 @@ main_exe_path(void)
#endif
static void
-print_line0(line_info_t *line, void *address)
+print_line0(line_info_t *line, void *address, FILE *errout)
{
uintptr_t addr = (uintptr_t)address;
uintptr_t d = addr - line->saddr;
@@ -2527,16 +2606,16 @@ print_line0(line_info_t *line, void *address)
}
static void
-print_line(line_info_t *line, void *address)
+print_line(line_info_t *line, void *address, FILE *errout)
{
- print_line0(line, address);
+ print_line0(line, address, errout);
if (line->next) {
- print_line(line->next, NULL);
+ print_line(line->next, NULL, errout);
}
}
void
-rb_dump_backtrace_with_lines(int num_traces, void **traces)
+rb_dump_backtrace_with_lines(int num_traces, void **traces, FILE *errout)
{
int i;
/* async-signal unsafe */
@@ -2548,80 +2627,80 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
#ifdef HAVE_MAIN_EXE_PATH
char *main_path = NULL; /* used on printing backtrace */
ssize_t len;
- if ((len = main_exe_path()) > 0) {
- main_path = (char *)alloca(len + 1);
- if (main_path) {
- uintptr_t addr;
- memcpy(main_path, binary_filename, len+1);
- append_obj(&obj);
- obj->path = main_path;
- addr = fill_lines(num_traces, traces, 1, &obj, lines, -1);
- if (addr != (uintptr_t)-1) {
- dladdr_fbases[0] = (void *)addr;
- }
- }
+ if ((len = main_exe_path(errout)) > 0) {
+ main_path = (char *)alloca(len + 1);
+ if (main_path) {
+ uintptr_t addr;
+ memcpy(main_path, binary_filename, len+1);
+ append_obj(&obj);
+ obj->path = main_path;
+ addr = fill_lines(num_traces, traces, 1, &obj, lines, 0, errout);
+ if (addr != (uintptr_t)-1) {
+ dladdr_fbases[0] = (void *)addr;
+ }
+ }
}
#endif
/* fill source lines by reading dwarf */
for (i = 0; i < num_traces; i++) {
- Dl_info info;
- if (lines[i].line) continue;
- if (dladdr(traces[i], &info)) {
- const char *path;
- void **p;
-
- /* skip symbols which is in already checked objects */
- /* if the binary is strip-ed, this may effect */
- for (p=dladdr_fbases; *p; p++) {
- if (*p == info.dli_fbase) {
- if (info.dli_fname) lines[i].path = info.dli_fname;
- if (info.dli_sname) lines[i].sname = info.dli_sname;
- goto next_line;
- }
- }
- *p = info.dli_fbase;
-
- append_obj(&obj);
- obj->base_addr = (uintptr_t)info.dli_fbase;
- path = info.dli_fname;
- obj->path = path;
- if (path) lines[i].path = path;
+ Dl_info info;
+ if (lines[i].line) continue;
+ if (dladdr(traces[i], &info)) {
+ const char *path;
+ void **p;
+
+ /* skip symbols which is in already checked objects */
+ /* if the binary is strip-ed, this may effect */
+ for (p=dladdr_fbases; *p; p++) {
+ if (*p == info.dli_fbase) {
+ if (info.dli_fname) lines[i].path = info.dli_fname;
+ if (info.dli_sname) lines[i].sname = info.dli_sname;
+ goto next_line;
+ }
+ }
+ *p = info.dli_fbase;
+
+ append_obj(&obj);
+ obj->base_addr = (uintptr_t)info.dli_fbase;
+ path = info.dli_fname;
+ obj->path = path;
+ if (path) lines[i].path = path;
if (info.dli_sname) {
lines[i].sname = info.dli_sname;
lines[i].saddr = (uintptr_t)info.dli_saddr;
}
- strlcpy(binary_filename, path, PATH_MAX);
- if (fill_lines(num_traces, traces, 1, &obj, lines, i) == (uintptr_t)-1)
- break;
- }
+ strlcpy(binary_filename, path, PATH_MAX);
+ if (fill_lines(num_traces, traces, 1, &obj, lines, i, errout) == (uintptr_t)-1)
+ break;
+ }
next_line:
- continue;
+ continue;
}
/* output */
for (i = 0; i < num_traces; i++) {
- print_line(&lines[i], traces[i]);
+ print_line(&lines[i], traces[i], errout);
- /* FreeBSD's backtrace may show _start and so on */
- if (lines[i].sname && strcmp("main", lines[i].sname) == 0)
- break;
+ /* FreeBSD's backtrace may show _start and so on */
+ if (lines[i].sname && strcmp("main", lines[i].sname) == 0)
+ break;
}
/* free */
while (obj) {
- obj_info_t *o = obj;
+ obj_info_t *o = obj;
for (i=0; i < DWARF_SECTION_COUNT; i++) {
struct dwarf_section *s = obj_dwarf_section_at(obj, i);
if (s->flags & SHF_COMPRESSED) {
free(s->ptr);
}
}
- if (obj->mapped_size) {
- munmap(obj->mapped, obj->mapped_size);
- }
- obj = o->next;
- free(o);
+ if (obj->mapped_size) {
+ munmap(obj->mapped, obj->mapped_size);
+ }
+ obj = o->next;
+ free(o);
}
for (i = 0; i < num_traces; i++) {
line_info_t *line = lines[i].next;
@@ -2635,435 +2714,8 @@ next_line:
free(dladdr_fbases);
}
-/* From FreeBSD's lib/libstand/printf.c */
-/*-
- * Copyright (c) 1986, 1988, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- */
-
-#include <stdarg.h>
-#define MAXNBUF (sizeof(intmax_t) * CHAR_BIT + 1)
-static inline int toupper(int c) { return ('A' <= c && c <= 'Z') ? (c&0x5f) : c; }
-#define hex2ascii(hex) (hex2ascii_data[hex])
-static const char hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-static inline int imax(int a, int b) { return (a > b ? a : b); }
-static int kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap);
-
-static void putce(int c)
-{
- char s[1];
- ssize_t ret;
-
- s[0] = (char)c;
- ret = write(2, s, 1);
- (void)ret;
-}
-
-static int
-kprintf(const char *fmt, ...)
-{
- va_list ap;
- int retval;
+#undef kprintf
- va_start(ap, fmt);
- retval = kvprintf(fmt, putce, NULL, 10, ap);
- va_end(ap);
- return retval;
-}
-
-/*
- * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
- * order; return an optional length and a pointer to the last character
- * written in the buffer (i.e., the first character of the string).
- * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
- */
-static char *
-ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
-{
- char *p, c;
-
- p = nbuf;
- *p = '\0';
- do {
- c = hex2ascii(num % base);
- *++p = upper ? toupper(c) : c;
- } while (num /= base);
- if (lenp)
- *lenp = (int)(p - nbuf);
- return (p);
-}
-
-/*
- * Scaled down version of printf(3).
- *
- * Two additional formats:
- *
- * The format %b is supported to decode error registers.
- * Its usage is:
- *
- * printf("reg=%b\n", regval, "<base><arg>*");
- *
- * where <base> is the output base expressed as a control character, e.g.
- * \10 gives octal; \20 gives hex. Each arg is a sequence of characters,
- * the first of which gives the bit number to be inspected (origin 1), and
- * the next characters (up to a control character, i.e. a character <= 32),
- * give the name of the register. Thus:
- *
- * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
- *
- * would produce output:
- *
- * reg=3<BITTWO,BITONE>
- *
- * XXX: %D -- Hexdump, takes pointer and separator string:
- * ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX
- * ("%*D", len, ptr, " " -> XX XX XX XX ...
- */
-static int
-kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap)
-{
-#define PCHAR(c) {int cc=(c); if (func) (*func)(cc); else *d++ = cc; retval++; }
- char nbuf[MAXNBUF];
- char *d;
- const char *p, *percent, *q;
- unsigned char *up;
- int ch, n;
- uintmax_t num;
- int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
- int cflag, hflag, jflag, tflag, zflag;
- int dwidth, upper;
- char padc;
- int stop = 0, retval = 0;
-
- num = 0;
- if (!func)
- d = (char *) arg;
- else
- d = NULL;
-
- if (fmt == NULL)
- fmt = "(fmt null)\n";
-
- if (radix < 2 || radix > 36)
- radix = 10;
-
- for (;;) {
- padc = ' ';
- width = 0;
- while ((ch = (unsigned char)*fmt++) != '%' || stop) {
- if (ch == '\0')
- return (retval);
- PCHAR(ch);
- }
- percent = fmt - 1;
- qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
- sign = 0; dot = 0; dwidth = 0; upper = 0;
- cflag = 0; hflag = 0; jflag = 0; tflag = 0; zflag = 0;
-reswitch: switch (ch = (unsigned char)*fmt++) {
- case '.':
- dot = 1;
- goto reswitch;
- case '#':
- sharpflag = 1;
- goto reswitch;
- case '+':
- sign = 1;
- goto reswitch;
- case '-':
- ladjust = 1;
- goto reswitch;
- case '%':
- PCHAR(ch);
- break;
- case '*':
- if (!dot) {
- width = va_arg(ap, int);
- if (width < 0) {
- ladjust = !ladjust;
- width = -width;
- }
- } else {
- dwidth = va_arg(ap, int);
- }
- goto reswitch;
- case '0':
- if (!dot) {
- padc = '0';
- goto reswitch;
- }
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- for (n = 0;; ++fmt) {
- n = n * 10 + ch - '0';
- ch = *fmt;
- if (ch < '0' || ch > '9')
- break;
- }
- if (dot)
- dwidth = n;
- else
- width = n;
- goto reswitch;
- case 'b':
- num = (unsigned int)va_arg(ap, int);
- p = va_arg(ap, char *);
- for (q = ksprintn(nbuf, num, *p++, NULL, 0); *q;)
- PCHAR(*q--);
-
- if (num == 0)
- break;
-
- for (tmp = 0; *p;) {
- n = *p++;
- if (num & (1 << (n - 1))) {
- PCHAR(tmp ? ',' : '<');
- for (; (n = *p) > ' '; ++p)
- PCHAR(n);
- tmp = 1;
- } else
- for (; *p > ' '; ++p)
- continue;
- }
- if (tmp)
- PCHAR('>');
- break;
- case 'c':
- PCHAR(va_arg(ap, int));
- break;
- case 'D':
- up = va_arg(ap, unsigned char *);
- p = va_arg(ap, char *);
- if (!width)
- width = 16;
- while(width--) {
- PCHAR(hex2ascii(*up >> 4));
- PCHAR(hex2ascii(*up & 0x0f));
- up++;
- if (width)
- for (q=p;*q;q++)
- PCHAR(*q);
- }
- break;
- case 'd':
- case 'i':
- base = 10;
- sign = 1;
- goto handle_sign;
- case 'h':
- if (hflag) {
- hflag = 0;
- cflag = 1;
- } else
- hflag = 1;
- goto reswitch;
- case 'j':
- jflag = 1;
- goto reswitch;
- case 'l':
- if (lflag) {
- lflag = 0;
- qflag = 1;
- } else
- lflag = 1;
- goto reswitch;
- case 'n':
- if (jflag)
- *(va_arg(ap, intmax_t *)) = retval;
- else if (qflag)
- *(va_arg(ap, int64_t *)) = retval;
- else if (lflag)
- *(va_arg(ap, long *)) = retval;
- else if (zflag)
- *(va_arg(ap, size_t *)) = retval;
- else if (hflag)
- *(va_arg(ap, short *)) = retval;
- else if (cflag)
- *(va_arg(ap, char *)) = retval;
- else
- *(va_arg(ap, int *)) = retval;
- break;
- case 'o':
- base = 8;
- goto handle_nosign;
- case 'p':
- base = 16;
- sharpflag = (width == 0);
- sign = 0;
- num = (uintptr_t)va_arg(ap, void *);
- goto number;
- case 'q':
- qflag = 1;
- goto reswitch;
- case 'r':
- base = radix;
- if (sign)
- goto handle_sign;
- goto handle_nosign;
- case 's':
- p = va_arg(ap, char *);
- if (p == NULL)
- p = "(null)";
- if (!dot)
- n = (int)strlen (p);
- else
- for (n = 0; n < dwidth && p[n]; n++)
- continue;
-
- width -= n;
-
- if (!ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- while (n--)
- PCHAR(*p++);
- if (ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- break;
- case 't':
- tflag = 1;
- goto reswitch;
- case 'u':
- base = 10;
- goto handle_nosign;
- case 'X':
- upper = 1;
- case 'x':
- base = 16;
- goto handle_nosign;
- case 'y':
- base = 16;
- sign = 1;
- goto handle_sign;
- case 'z':
- zflag = 1;
- goto reswitch;
-handle_nosign:
- sign = 0;
- if (jflag)
- num = va_arg(ap, uintmax_t);
- else if (qflag)
- num = va_arg(ap, uint64_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, unsigned long);
- else if (zflag)
- num = va_arg(ap, size_t);
- else if (hflag)
- num = (unsigned short)va_arg(ap, int);
- else if (cflag)
- num = (unsigned char)va_arg(ap, int);
- else
- num = va_arg(ap, unsigned int);
- goto number;
-handle_sign:
- if (jflag)
- num = va_arg(ap, intmax_t);
- else if (qflag)
- num = va_arg(ap, int64_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, long);
- else if (zflag)
- num = va_arg(ap, ssize_t);
- else if (hflag)
- num = (short)va_arg(ap, int);
- else if (cflag)
- num = (char)va_arg(ap, int);
- else
- num = va_arg(ap, int);
-number:
- if (sign && (intmax_t)num < 0) {
- neg = 1;
- num = -(intmax_t)num;
- }
- p = ksprintn(nbuf, num, base, &n, upper);
- tmp = 0;
- if (sharpflag && num != 0) {
- if (base == 8)
- tmp++;
- else if (base == 16)
- tmp += 2;
- }
- if (neg)
- tmp++;
-
- if (!ladjust && padc == '0')
- dwidth = width - tmp;
- width -= tmp + imax(dwidth, n);
- dwidth -= n;
- if (!ladjust)
- while (width-- > 0)
- PCHAR(' ');
- if (neg)
- PCHAR('-');
- if (sharpflag && num != 0) {
- if (base == 8) {
- PCHAR('0');
- } else if (base == 16) {
- PCHAR('0');
- PCHAR('x');
- }
- }
- while (dwidth-- > 0)
- PCHAR('0');
-
- while (*p)
- PCHAR(*p--);
-
- if (ladjust)
- while (width-- > 0)
- PCHAR(' ');
-
- break;
- default:
- while (percent < fmt)
- PCHAR(*percent++);
- /*
- * Since we ignore an formatting argument it is no
- * longer safe to obey the remaining formatting
- * arguments as the arguments will no longer match
- * the format specs.
- */
- stop = 1;
- break;
- }
- }
-#undef PCHAR
-}
#else /* defined(USE_ELF) */
#error not supported
#endif
diff --git a/addr2line.h b/addr2line.h
index f09b665800..ff8e476b92 100644
--- a/addr2line.h
+++ b/addr2line.h
@@ -12,8 +12,10 @@
#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H))
+#include <stdio.h>
+
void
-rb_dump_backtrace_with_lines(int num_traces, void **traces);
+rb_dump_backtrace_with_lines(int num_traces, void **traces, FILE *errout);
#endif /* USE_ELF */
diff --git a/array.c b/array.c
index 83d1c9ced6..6720406d89 100644
--- a/array.c
+++ b/array.c
@@ -27,8 +27,11 @@
#include "probes.h"
#include "ruby/encoding.h"
#include "ruby/st.h"
+#include "ruby/thread.h"
#include "ruby/util.h"
-#include "transient_heap.h"
+#include "ruby/ractor.h"
+#include "shape.h"
+#include "vm_core.h"
#include "builtin.h"
#if !ARRAY_DEBUG
@@ -38,22 +41,18 @@
#include "ruby_assert.h"
VALUE rb_cArray;
+VALUE rb_cArray_empty_frozen;
/* Flags of RArray
*
+ * 0: RARRAY_SHARED_FLAG (equal to ELTS_SHARED)
+ * The array is shared. The buffer this array points to is owned by
+ * another array (the shared root).
* 1: RARRAY_EMBED_FLAG
* The array is embedded (its contents follow the header, rather than
* being on a separately allocated buffer).
- * 2: RARRAY_SHARED_FLAG (equal to ELTS_SHARED)
- * The array is shared. The buffer this array points to is owned by
- * another array (the shared root).
- * if USE_RVARGC
* 3-9: RARRAY_EMBED_LEN
* The length of the array when RARRAY_EMBED_FLAG is set.
- * else
- * 3-4: RARRAY_EMBED_LEN
- * The length of the array when RARRAY_EMBED_FLAG is set.
- * endif
* 12: RARRAY_SHARED_ROOT_FLAG
* The array is a shared root that does reference counting. The buffer
* this array points to is owned by this array but may be pointed to
@@ -63,8 +62,6 @@ VALUE rb_cArray;
* they cannot be modified. Not updating the reference count
* improves copy-on-write performance. Their reference count is
* assumed to be infinity.
- * 13: RARRAY_TRANSIENT_FLAG
- * The buffer of the array is allocated on the transient heap.
* 14: RARRAY_PTR_IN_USE_FLAG
* The buffer of the array is in use. This is only used during
* debugging.
@@ -84,48 +81,49 @@ should_be_T_ARRAY(VALUE ary)
return RB_TYPE_P(ary, T_ARRAY);
}
-#define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)
-#define ARY_HEAP_LEN(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)
-#define ARY_HEAP_CAPA(a) (assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), \
+#define ARY_HEAP_PTR(a) (RUBY_ASSERT(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)
+#define ARY_HEAP_LEN(a) (RUBY_ASSERT(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)
+#define ARY_HEAP_CAPA(a) (RUBY_ASSERT(!ARY_EMBED_P(a)), RUBY_ASSERT(!ARY_SHARED_ROOT_P(a)), \
RARRAY(a)->as.heap.aux.capa)
-#define ARY_EMBED_PTR(a) (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary)
+#define ARY_EMBED_PTR(a) (RUBY_ASSERT(ARY_EMBED_P(a)), RARRAY(a)->as.ary)
#define ARY_EMBED_LEN(a) \
- (assert(ARY_EMBED_P(a)), \
+ (RUBY_ASSERT(ARY_EMBED_P(a)), \
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
(RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)))
-#define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))
+#define ARY_HEAP_SIZE(a) (RUBY_ASSERT(!ARY_EMBED_P(a)), RUBY_ASSERT(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))
-#define ARY_OWNS_HEAP_P(a) (assert(should_be_T_ARRAY((VALUE)(a))), \
+#define ARY_OWNS_HEAP_P(a) (RUBY_ASSERT(should_be_T_ARRAY((VALUE)(a))), \
!FL_TEST_RAW((a), RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG))
#define FL_SET_EMBED(a) do { \
- assert(!ARY_SHARED_P(a)); \
+ RUBY_ASSERT(!ARY_SHARED_P(a)); \
FL_SET((a), RARRAY_EMBED_FLAG); \
- RARY_TRANSIENT_UNSET(a); \
ary_verify(a); \
} while (0)
#define FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)
#define FL_SET_SHARED(ary) do { \
- assert(!ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
FL_SET((ary), RARRAY_SHARED_FLAG); \
} while (0)
#define FL_UNSET_SHARED(ary) FL_UNSET((ary), RARRAY_SHARED_FLAG)
+#define ARY_SET_PTR_FORCE(ary, p) \
+ (RARRAY(ary)->as.heap.ptr = (p))
#define ARY_SET_PTR(ary, p) do { \
- assert(!ARY_EMBED_P(ary)); \
- assert(!OBJ_FROZEN(ary)); \
- RARRAY(ary)->as.heap.ptr = (p); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
+ ARY_SET_PTR_FORCE(ary, p); \
} while (0)
#define ARY_SET_EMBED_LEN(ary, n) do { \
long tmp_n = (n); \
- assert(ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(ARY_EMBED_P(ary)); \
RBASIC(ary)->flags &= ~RARRAY_EMBED_LEN_MASK; \
RBASIC(ary)->flags |= (tmp_n) << RARRAY_EMBED_LEN_SHIFT; \
} while (0)
#define ARY_SET_HEAP_LEN(ary, n) do { \
- assert(!ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
RARRAY(ary)->as.heap.len = (n); \
} while (0)
#define ARY_SET_LEN(ary, n) do { \
@@ -135,15 +133,15 @@ should_be_T_ARRAY(VALUE ary)
else { \
ARY_SET_HEAP_LEN((ary), (n)); \
} \
- assert(RARRAY_LEN(ary) == (n)); \
+ RUBY_ASSERT(RARRAY_LEN(ary) == (n)); \
} while (0)
#define ARY_INCREASE_PTR(ary, n) do { \
- assert(!ARY_EMBED_P(ary)); \
- assert(!OBJ_FROZEN(ary)); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
RARRAY(ary)->as.heap.ptr += (n); \
} while (0)
#define ARY_INCREASE_LEN(ary, n) do { \
- assert(!OBJ_FROZEN(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
if (ARY_EMBED_P(ary)) { \
ARY_SET_EMBED_LEN((ary), RARRAY_LEN(ary)+(n)); \
} \
@@ -154,32 +152,33 @@ should_be_T_ARRAY(VALUE ary)
#define ARY_CAPA(ary) (ARY_EMBED_P(ary) ? ary_embed_capa(ary) : \
ARY_SHARED_ROOT_P(ary) ? RARRAY_LEN(ary) : ARY_HEAP_CAPA(ary))
+#define ARY_SET_CAPA_FORCE(ary, n) \
+ RARRAY(ary)->as.heap.aux.capa = (n);
#define ARY_SET_CAPA(ary, n) do { \
- assert(!ARY_EMBED_P(ary)); \
- assert(!ARY_SHARED_P(ary)); \
- assert(!OBJ_FROZEN(ary)); \
- RARRAY(ary)->as.heap.aux.capa = (n); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
+ RUBY_ASSERT(!ARY_SHARED_P(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
+ ARY_SET_CAPA_FORCE(ary, n); \
} while (0)
#define ARY_SHARED_ROOT_OCCUPIED(ary) (!OBJ_FROZEN(ary) && ARY_SHARED_ROOT_REFCNT(ary) == 1)
#define ARY_SET_SHARED_ROOT_REFCNT(ary, value) do { \
- assert(ARY_SHARED_ROOT_P(ary)); \
- assert(!OBJ_FROZEN(ary)); \
- assert((value) >= 0); \
+ RUBY_ASSERT(ARY_SHARED_ROOT_P(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
+ RUBY_ASSERT((value) >= 0); \
RARRAY(ary)->as.heap.aux.capa = (value); \
} while (0)
#define FL_SET_SHARED_ROOT(ary) do { \
- assert(!OBJ_FROZEN(ary)); \
- assert(!ARY_EMBED_P(ary)); \
- assert(!RARRAY_TRANSIENT_P(ary)); \
+ RUBY_ASSERT(!OBJ_FROZEN(ary)); \
+ RUBY_ASSERT(!ARY_EMBED_P(ary)); \
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
} while (0)
static inline void
ARY_SET(VALUE a, long i, VALUE v)
{
- assert(!ARY_SHARED_P(a));
- assert(!OBJ_FROZEN(a));
+ RUBY_ASSERT(!ARY_SHARED_P(a));
+ RUBY_ASSERT(!OBJ_FROZEN(a));
RARRAY_ASET(a, i, v);
}
@@ -188,29 +187,23 @@ ARY_SET(VALUE a, long i, VALUE v)
static long
ary_embed_capa(VALUE ary)
{
-#if USE_RVARGC
size_t size = rb_gc_obj_slot_size(ary) - offsetof(struct RArray, as.ary);
- assert(size % sizeof(VALUE) == 0);
+ RUBY_ASSERT(size % sizeof(VALUE) == 0);
return size / sizeof(VALUE);
-#else
- return RARRAY_EMBED_LEN_MAX;
-#endif
}
static size_t
ary_embed_size(long capa)
{
- return offsetof(struct RArray, as.ary) + (sizeof(VALUE) * capa);
+ size_t size = offsetof(struct RArray, as.ary) + (sizeof(VALUE) * capa);
+ if (size < sizeof(struct RArray)) size = sizeof(struct RArray);
+ return size;
}
static bool
ary_embeddable_p(long capa)
{
-#if USE_RVARGC
return rb_gc_size_allocatable_p(ary_embed_size(capa));
-#else
- return capa <= RARRAY_EMBED_LEN_MAX;
-#endif
}
bool
@@ -251,25 +244,23 @@ rb_ary_size_as_embedded(VALUE ary)
static VALUE
ary_verify_(VALUE ary, const char *file, int line)
{
- assert(RB_TYPE_P(ary, T_ARRAY));
+ RUBY_ASSERT(RB_TYPE_P(ary, T_ARRAY));
if (ARY_SHARED_P(ary)) {
VALUE root = ARY_SHARED_ROOT(ary);
const VALUE *ptr = ARY_HEAP_PTR(ary);
- const VALUE *root_ptr = RARRAY_CONST_PTR_TRANSIENT(root);
+ const VALUE *root_ptr = RARRAY_CONST_PTR(root);
long len = ARY_HEAP_LEN(ary), root_len = RARRAY_LEN(root);
- assert(ARY_SHARED_ROOT_P(root) || OBJ_FROZEN(root));
- assert(root_ptr <= ptr && ptr + len <= root_ptr + root_len);
+ RUBY_ASSERT(ARY_SHARED_ROOT_P(root) || OBJ_FROZEN(root));
+ RUBY_ASSERT(root_ptr <= ptr && ptr + len <= root_ptr + root_len);
ary_verify(root);
}
else if (ARY_EMBED_P(ary)) {
- assert(!RARRAY_TRANSIENT_P(ary));
- assert(!ARY_SHARED_P(ary));
- assert(RARRAY_LEN(ary) <= ary_embed_capa(ary));
+ RUBY_ASSERT(!ARY_SHARED_P(ary));
+ RUBY_ASSERT(RARRAY_LEN(ary) <= ary_embed_capa(ary));
}
else {
-#if 1
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
long i, len = RARRAY_LEN(ary);
volatile VALUE v;
if (len > 1) len = 1; /* check only HEAD */
@@ -277,25 +268,10 @@ ary_verify_(VALUE ary, const char *file, int line)
v = ptr[i]; /* access check */
}
v = v;
-#endif
}
-#if USE_TRANSIENT_HEAP
- if (RARRAY_TRANSIENT_P(ary)) {
- assert(rb_transient_heap_managed_ptr_p(RARRAY_CONST_PTR_TRANSIENT(ary)));
- }
-#endif
-
- rb_transient_heap_verify();
-
return ary;
}
-
-void
-rb_ary_verify(VALUE ary)
-{
- ary_verify(ary);
-}
#else
#define ary_verify(ary) ((void)0)
#endif
@@ -306,7 +282,7 @@ rb_ary_ptr_use_start(VALUE ary)
#if ARRAY_DEBUG
FL_SET_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
#endif
- return (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary);
+ return (VALUE *)RARRAY_CONST_PTR(ary);
}
void
@@ -328,7 +304,7 @@ rb_mem_clear(VALUE *mem, long size)
static void
ary_mem_clear(VALUE ary, long beg, long size)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
rb_mem_clear(ptr + beg, size);
});
}
@@ -344,7 +320,7 @@ memfill(register VALUE *mem, register long size, register VALUE val)
static void
ary_memfill(VALUE ary, long beg, long size, VALUE val)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
memfill(ptr + beg, size, val);
RB_OBJ_WRITTEN(ary, Qundef, val);
});
@@ -353,17 +329,17 @@ ary_memfill(VALUE ary, long beg, long size, VALUE val)
static void
ary_memcpy0(VALUE ary, long beg, long argc, const VALUE *argv, VALUE buff_owner_ary)
{
- assert(!ARY_SHARED_P(buff_owner_ary));
+ RUBY_ASSERT(!ARY_SHARED_P(buff_owner_ary));
if (argc > (int)(128/sizeof(VALUE)) /* is magic number (cache line size) */) {
rb_gc_writebarrier_remember(buff_owner_ary);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMCPY(ptr+beg, argv, VALUE, argc);
});
}
else {
int i;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
for (i=0; i<argc; i++) {
RB_OBJ_WRITE(buff_owner_ary, &ptr[i+beg], argv[i]);
}
@@ -378,158 +354,63 @@ ary_memcpy(VALUE ary, long beg, long argc, const VALUE *argv)
}
static VALUE *
-ary_heap_alloc(VALUE ary, size_t capa)
+ary_heap_alloc_buffer(size_t capa)
{
- VALUE *ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * capa);
-
- if (ptr != NULL) {
- RARY_TRANSIENT_SET(ary);
- }
- else {
- RARY_TRANSIENT_UNSET(ary);
- ptr = ALLOC_N(VALUE, capa);
- }
-
- return ptr;
+ return ALLOC_N(VALUE, capa);
}
static void
ary_heap_free_ptr(VALUE ary, const VALUE *ptr, long size)
{
- if (RARRAY_TRANSIENT_P(ary)) {
- /* ignore it */
- }
- else {
- ruby_sized_xfree((void *)ptr, size);
- }
+ ruby_xfree_sized((void *)ptr, size);
}
static void
ary_heap_free(VALUE ary)
{
- if (RARRAY_TRANSIENT_P(ary)) {
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- ary_heap_free_ptr(ary, ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
- }
+ ary_heap_free_ptr(ary, ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
static size_t
ary_heap_realloc(VALUE ary, size_t new_capa)
{
- size_t alloc_capa = new_capa;
- size_t old_capa = ARY_HEAP_CAPA(ary);
-
- if (RARRAY_TRANSIENT_P(ary)) {
- if (new_capa <= old_capa) {
- /* do nothing */
- alloc_capa = old_capa;
- }
- else {
- VALUE *new_ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * new_capa);
-
- if (new_ptr == NULL) {
- new_ptr = ALLOC_N(VALUE, new_capa);
- RARY_TRANSIENT_UNSET(ary);
- }
-
- MEMCPY(new_ptr, ARY_HEAP_PTR(ary), VALUE, old_capa);
- ARY_SET_PTR(ary, new_ptr);
- }
- }
- else {
- SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, old_capa);
- }
+ RUBY_ASSERT(!OBJ_FROZEN(ary));
+ SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, ARY_HEAP_CAPA(ary));
ary_verify(ary);
- return alloc_capa;
-}
-
-#if USE_TRANSIENT_HEAP
-static inline void
-rb_ary_transient_heap_evacuate_(VALUE ary, int transient, int promote)
-{
- if (transient) {
- assert(!ARY_SHARED_ROOT_P(ary));
-
- VALUE *new_ptr;
- const VALUE *old_ptr = ARY_HEAP_PTR(ary);
- long capa = ARY_HEAP_CAPA(ary);
-
- assert(ARY_OWNS_HEAP_P(ary));
- assert(RARRAY_TRANSIENT_P(ary));
- assert(!ARY_PTR_USING_P(ary));
-
- if (promote) {
- new_ptr = ALLOC_N(VALUE, capa);
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- new_ptr = ary_heap_alloc(ary, capa);
- }
-
- MEMCPY(new_ptr, old_ptr, VALUE, capa);
- /* do not use ARY_SET_PTR() because they assert !frozen */
- RARRAY(ary)->as.heap.ptr = new_ptr;
- }
-
- ary_verify(ary);
+ return new_capa;
}
void
-rb_ary_transient_heap_evacuate(VALUE ary, int promote)
-{
- rb_ary_transient_heap_evacuate_(ary, RARRAY_TRANSIENT_P(ary), promote);
-}
-
-void
-rb_ary_detransient(VALUE ary)
-{
- assert(RARRAY_TRANSIENT_P(ary));
- rb_ary_transient_heap_evacuate_(ary, TRUE, TRUE);
-}
-#else
-void
-rb_ary_detransient(VALUE ary)
-{
- /* do nothing */
-}
-#endif
-
-void
rb_ary_make_embedded(VALUE ary)
{
- assert(rb_ary_embeddable_p(ary));
+ RUBY_ASSERT(rb_ary_embeddable_p(ary));
if (!ARY_EMBED_P(ary)) {
const VALUE *buf = ARY_HEAP_PTR(ary);
long len = ARY_HEAP_LEN(ary);
- bool was_transient = RARRAY_TRANSIENT_P(ary);
+ long capa = ARY_HEAP_CAPA(ary);
- // FL_SET_EMBED also unsets the transient flag
FL_SET_EMBED(ary);
ARY_SET_EMBED_LEN(ary, len);
MEMCPY((void *)ARY_EMBED_PTR(ary), (void *)buf, VALUE, len);
- if (!was_transient) {
- ary_heap_free_ptr(ary, buf, len * sizeof(VALUE));
- }
+ ary_heap_free_ptr(ary, buf, capa * sizeof(VALUE));
}
}
static void
ary_resize_capa(VALUE ary, long capacity)
{
- assert(RARRAY_LEN(ary) <= capacity);
- assert(!OBJ_FROZEN(ary));
- assert(!ARY_SHARED_P(ary));
+ RUBY_ASSERT(RARRAY_LEN(ary) <= capacity);
+ RUBY_ASSERT(!OBJ_FROZEN(ary));
+ RUBY_ASSERT(!ARY_SHARED_P(ary));
if (capacity > ary_embed_capa(ary)) {
size_t new_capa = capacity;
if (ARY_EMBED_P(ary)) {
long len = ARY_EMBED_LEN(ary);
- VALUE *ptr = ary_heap_alloc(ary, capacity);
+ VALUE *ptr = ary_heap_alloc_buffer(capacity);
MEMCPY(ptr, ARY_EMBED_PTR(ary), VALUE, len);
FL_UNSET_EMBED(ary);
@@ -549,7 +430,7 @@ ary_resize_capa(VALUE ary, long capacity)
if (len > capacity) len = capacity;
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
- ary_heap_free_ptr(ary, ptr, old_capa);
+ ary_heap_free_ptr(ary, ptr, old_capa * sizeof(VALUE));
FL_SET_EMBED(ary);
ARY_SET_LEN(ary, len);
@@ -564,9 +445,12 @@ ary_shrink_capa(VALUE ary)
{
long capacity = ARY_HEAP_LEN(ary);
long old_capa = ARY_HEAP_CAPA(ary);
- assert(!ARY_SHARED_P(ary));
- assert(old_capa >= capacity);
- if (old_capa > capacity) ary_heap_realloc(ary, capacity);
+ RUBY_ASSERT(!ARY_SHARED_P(ary));
+ RUBY_ASSERT(old_capa >= capacity);
+ if (old_capa > capacity) {
+ size_t new_capa = ary_heap_realloc(ary, capacity);
+ ARY_SET_CAPA(ary, new_capa);
+ }
ary_verify(ary);
}
@@ -624,7 +508,7 @@ rb_ary_increment_share(VALUE shared_root)
{
if (!OBJ_FROZEN(shared_root)) {
long num = ARY_SHARED_ROOT_REFCNT(shared_root);
- assert(num >= 0);
+ RUBY_ASSERT(num >= 0);
ARY_SET_SHARED_ROOT_REFCNT(shared_root, num + 1);
}
return shared_root;
@@ -633,9 +517,9 @@ rb_ary_increment_share(VALUE shared_root)
static void
rb_ary_set_shared(VALUE ary, VALUE shared_root)
{
- assert(!ARY_EMBED_P(ary));
- assert(!OBJ_FROZEN(ary));
- assert(ARY_SHARED_ROOT_P(shared_root) || OBJ_FROZEN(shared_root));
+ RUBY_ASSERT(!ARY_EMBED_P(ary));
+ RUBY_ASSERT(!OBJ_FROZEN(ary));
+ RUBY_ASSERT(ARY_SHARED_ROOT_P(shared_root) || OBJ_FROZEN(shared_root));
rb_ary_increment_share(shared_root);
FL_SET_SHARED(ary);
@@ -647,6 +531,8 @@ rb_ary_set_shared(VALUE ary, VALUE shared_root)
static inline void
rb_ary_modify_check(VALUE ary)
{
+ RUBY_ASSERT(ruby_thread_has_gvl_p());
+
rb_check_frozen(ary);
ary_verify(ary);
}
@@ -669,22 +555,22 @@ rb_ary_cancel_sharing(VALUE ary)
ARY_SET_EMBED_LEN(ary, len);
}
else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) {
- long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ long shift = RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared_root);
FL_UNSET_SHARED(ary);
- ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root));
+ ARY_SET_PTR(ary, RARRAY_CONST_PTR(shared_root));
ARY_SET_CAPA(ary, shared_len);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr+shift, VALUE, len);
});
FL_SET_EMBED(shared_root);
rb_ary_decrement_share(shared_root);
}
else {
- VALUE *ptr = ary_heap_alloc(ary, len);
+ VALUE *ptr = ary_heap_alloc_buffer(len);
MEMCPY(ptr, ARY_HEAP_PTR(ary), VALUE, len);
rb_ary_unshare(ary);
- ARY_SET_CAPA(ary, len);
- ARY_SET_PTR(ary, ptr);
+ ARY_SET_CAPA_FORCE(ary, len);
+ ARY_SET_PTR_FORCE(ary, ptr);
}
rb_gc_writebarrier_remember(ary);
@@ -713,7 +599,7 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
if (new_len > ary_embed_capa(ary)) {
VALUE shared_root = ARY_SHARED_ROOT(ary);
if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) {
- if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root) + new_len <= RARRAY_LEN(shared_root)) {
+ if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR(shared_root) + new_len <= RARRAY_LEN(shared_root)) {
rb_ary_modify_check(ary);
ary_verify(ary);
@@ -749,21 +635,32 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
/*
* call-seq:
- * array.freeze -> self
+ * freeze -> self
*
- * Freezes +self+; returns +self+:
+ * Freezes +self+ (if not already frozen); returns +self+:
*
* a = []
* a.frozen? # => false
* a.freeze
* a.frozen? # => true
*
- * An attempt to modify a frozen \Array raises FrozenError.
+ * No further changes may be made to +self+;
+ * raises FrozenError if a change is attempted.
+ *
+ * Related: Kernel#frozen?.
*/
VALUE
rb_ary_freeze(VALUE ary)
{
+ RUBY_ASSERT(RB_TYPE_P(ary, T_ARRAY));
+
+ if (OBJ_FROZEN(ary)) return ary;
+
+ if (!ARY_EMBED_P(ary) && !ARY_SHARED_P(ary) && !ARY_SHARED_ROOT_P(ary)) {
+ ary_shrink_capa(ary);
+ }
+
return rb_obj_freeze(ary);
}
@@ -790,26 +687,23 @@ static VALUE
ary_alloc_embed(VALUE klass, long capa)
{
size_t size = ary_embed_size(capa);
- assert(rb_gc_size_allocatable_p(size));
-#if !USE_RVARGC
- assert(size <= sizeof(struct RArray));
-#endif
- RVARGC_NEWOBJ_OF(ary, struct RArray, klass,
- T_ARRAY | RARRAY_EMBED_FLAG | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- size);
- /* Created array is:
- * FL_SET_EMBED((VALUE)ary);
- * ARY_SET_EMBED_LEN((VALUE)ary, 0);
- */
- return (VALUE)ary;
+ RUBY_ASSERT(rb_gc_size_allocatable_p(size));
+ /* Created array is:
+ * FL_SET_EMBED((VALUE)ary);
+ * ARY_SET_EMBED_LEN((VALUE)ary, 0);
+ */
+ return rb_newobj_of(klass, T_ARRAY | RARRAY_EMBED_FLAG, size);
}
static VALUE
ary_alloc_heap(VALUE klass)
{
- RVARGC_NEWOBJ_OF(ary, struct RArray, klass,
- T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- sizeof(struct RArray));
+ NEWOBJ_OF(ary, struct RArray, klass, T_ARRAY, sizeof(struct RArray));
+
+ ary->as.heap.len = 0;
+ ary->as.heap.aux.capa = 0;
+ ary->as.heap.ptr = NULL;
+
return (VALUE)ary;
}
@@ -823,7 +717,9 @@ empty_ary_alloc(VALUE klass)
static VALUE
ary_new(VALUE klass, long capa)
{
- VALUE ary,*ptr;
+ RUBY_ASSERT(ruby_thread_has_gvl_p());
+
+ VALUE ary;
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
@@ -840,10 +736,9 @@ ary_new(VALUE klass, long capa)
else {
ary = ary_alloc_heap(klass);
ARY_SET_CAPA(ary, capa);
- assert(!ARY_EMBED_P(ary));
+ RUBY_ASSERT(!ARY_EMBED_P(ary));
- ptr = ary_heap_alloc(ary, capa);
- ARY_SET_PTR(ary, ptr);
+ ARY_SET_PTR(ary, ary_heap_alloc_buffer(capa));
ARY_SET_HEAP_LEN(ary, 0);
}
@@ -905,33 +800,28 @@ static VALUE
ec_ary_alloc_embed(rb_execution_context_t *ec, VALUE klass, long capa)
{
size_t size = ary_embed_size(capa);
- assert(rb_gc_size_allocatable_p(size));
-#if !USE_RVARGC
- assert(size <= sizeof(struct RArray));
-#endif
- RB_RVARGC_EC_NEWOBJ_OF(ec, ary, struct RArray, klass,
- T_ARRAY | RARRAY_EMBED_FLAG | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- size);
- /* Created array is:
- * FL_SET_EMBED((VALUE)ary);
- * ARY_SET_EMBED_LEN((VALUE)ary, 0);
- */
- return (VALUE)ary;
+ RUBY_ASSERT(rb_gc_size_allocatable_p(size));
+ /* Created array is:
+ * FL_SET_EMBED((VALUE)ary);
+ * ARY_SET_EMBED_LEN((VALUE)ary, 0);
+ */
+ return rb_ec_newobj_of(ec, klass, T_ARRAY | RARRAY_EMBED_FLAG, size);
}
static VALUE
ec_ary_alloc_heap(rb_execution_context_t *ec, VALUE klass)
{
- RB_RVARGC_EC_NEWOBJ_OF(ec, ary, struct RArray, klass,
- T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- sizeof(struct RArray));
- return (VALUE)ary;
+ VALUE ary = rb_ec_newobj_of(ec, klass, T_ARRAY, sizeof(struct RArray));
+ RARRAY(ary)->as.heap.len = 0;
+ RARRAY(ary)->as.heap.aux.capa = 0;
+ RARRAY(ary)->as.heap.ptr = NULL;
+ return ary;
}
static VALUE
ec_ary_new(rb_execution_context_t *ec, VALUE klass, long capa)
{
- VALUE ary,*ptr;
+ VALUE ary;
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
@@ -948,10 +838,9 @@ ec_ary_new(rb_execution_context_t *ec, VALUE klass, long capa)
else {
ary = ec_ary_alloc_heap(ec, klass);
ARY_SET_CAPA(ary, capa);
- assert(!ARY_EMBED_P(ary));
+ RUBY_ASSERT(!ARY_EMBED_P(ary));
- ptr = ary_heap_alloc(ary, capa);
- ARY_SET_PTR(ary, ptr);
+ ARY_SET_PTR(ary, ary_heap_alloc_buffer(capa));
ARY_SET_HEAP_LEN(ary, 0);
}
@@ -976,7 +865,6 @@ VALUE
rb_ary_hidden_new(long capa)
{
VALUE ary = ary_new(0, capa);
- rb_ary_transient_heap_evacuate(ary, TRUE);
return ary;
}
@@ -999,13 +887,8 @@ rb_ary_free(VALUE ary)
RB_DEBUG_COUNTER_INC(obj_ary_extracapa);
}
- if (RARRAY_TRANSIENT_P(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_transient);
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_ary_ptr);
- ary_heap_free(ary);
- }
+ RB_DEBUG_COUNTER_INC(obj_ary_ptr);
+ ary_heap_free(ary);
}
else {
RB_DEBUG_COUNTER_INC(obj_ary_embed);
@@ -1019,7 +902,33 @@ rb_ary_free(VALUE ary)
}
}
-RUBY_FUNC_EXPORTED size_t
+static VALUE fake_ary_flags;
+
+static VALUE
+init_fake_ary_flags(void)
+{
+ struct RArray fake_ary = {0};
+ fake_ary.basic.flags = T_ARRAY;
+ VALUE ary = (VALUE)&fake_ary;
+ RBASIC_SET_SHAPE_ID(ary, ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER);
+ rb_ary_freeze(ary);
+ return fake_ary.basic.flags;
+}
+
+VALUE
+rb_setup_fake_ary(struct RArray *fake_ary, const VALUE *list, long len)
+{
+ fake_ary->basic.flags = fake_ary_flags;
+ RBASIC_CLEAR_CLASS((VALUE)fake_ary);
+
+ // bypass frozen checks
+ fake_ary->as.heap.ptr = list;
+ fake_ary->as.heap.len = len;
+ fake_ary->as.heap.aux.capa = len;
+ return (VALUE)fake_ary;
+}
+
+size_t
rb_ary_memsize(VALUE ary)
{
if (ARY_OWNS_HEAP_P(ary)) {
@@ -1033,7 +942,6 @@ rb_ary_memsize(VALUE ary)
static VALUE
ary_make_shared(VALUE ary)
{
- assert(USE_RVARGC || !ARY_EMBED_P(ary));
ary_verify(ary);
if (ARY_SHARED_P(ary)) {
@@ -1043,15 +951,9 @@ ary_make_shared(VALUE ary)
return ary;
}
else if (OBJ_FROZEN(ary)) {
- if (!ARY_EMBED_P(ary)) {
- rb_ary_transient_heap_evacuate(ary, TRUE);
- ary_shrink_capa(ary);
- }
return ary;
}
else {
- rb_ary_transient_heap_evacuate(ary, TRUE);
-
long capa = ARY_CAPA(ary);
long len = RARRAY_LEN(ary);
@@ -1061,9 +963,7 @@ ary_make_shared(VALUE ary)
FL_SET_SHARED_ROOT(shared);
if (ARY_EMBED_P(ary)) {
- /* Cannot use ary_heap_alloc because we don't want to allocate
- * on the transient heap. */
- VALUE *ptr = ALLOC_N(VALUE, capa);
+ VALUE *ptr = ary_heap_alloc_buffer(capa);
ARY_SET_PTR(shared, ptr);
ary_memcpy(shared, 0, len, RARRAY_CONST_PTR(ary));
@@ -1093,9 +993,9 @@ ary_make_substitution(VALUE ary)
if (ary_embeddable_p(len)) {
VALUE subst = rb_ary_new_capa(len);
- assert(ARY_EMBED_P(subst));
+ RUBY_ASSERT(ARY_EMBED_P(subst));
- ary_memcpy(subst, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(subst, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_EMBED_LEN(subst, len);
return subst;
}
@@ -1139,14 +1039,18 @@ rb_to_array(VALUE ary)
* call-seq:
* Array.try_convert(object) -> object, new_array, or nil
*
- * If +object+ is an \Array object, returns +object+.
+ * Attempts to return an array, based on the given +object+.
*
- * Otherwise if +object+ responds to <tt>:to_ary</tt>,
- * calls <tt>object.to_ary</tt> and returns the result.
+ * If +object+ is an array, returns +object+.
*
- * Returns +nil+ if +object+ does not respond to <tt>:to_ary</tt>
+ * Otherwise if +object+ responds to <tt>:to_ary</tt>.
+ * calls <tt>object.to_ary</tt>:
+ * if the return value is an array or +nil+, returns that value;
+ * if not, raises TypeError.
*
- * Raises an exception unless <tt>object.to_ary</tt> returns an \Array object.
+ * Otherwise returns +nil+.
+ *
+ * Related: see {Methods for Creating an Array}[rdoc-ref:Array@Methods+for+Creating+an+Array].
*/
static VALUE
@@ -1183,48 +1087,51 @@ rb_ary_s_new(int argc, VALUE *argv, VALUE klass)
* call-seq:
* Array.new -> new_empty_array
* Array.new(array) -> new_array
- * Array.new(size) -> new_array
- * Array.new(size, default_value) -> new_array
- * Array.new(size) {|index| ... } -> new_array
+ * Array.new(size, default_value = nil) -> new_array
+ * Array.new(size = 0) {|index| ... } -> new_array
*
- * Returns a new \Array.
+ * Returns a new array.
*
- * With no block and no arguments, returns a new empty \Array object.
+ * With no block and no argument given, returns a new empty array:
*
- * With no block and a single \Array argument +array+,
- * returns a new \Array formed from +array+:
+ * Array.new # => []
*
- * a = Array.new([:foo, 'bar', 2])
- * a.class # => Array
- * a # => [:foo, "bar", 2]
+ * With no block and array argument given, returns a new array with the same elements:
+ *
+ * Array.new([:foo, 'bar', 2]) # => [:foo, "bar", 2]
*
- * With no block and a single \Integer argument +size+,
- * returns a new \Array of the given size
- * whose elements are all +nil+:
+ * With no block and integer argument given, returns a new array containing
+ * that many instances of the given +default_value+:
*
- * a = Array.new(3)
- * a # => [nil, nil, nil]
+ * Array.new(0) # => []
+ * Array.new(3) # => [nil, nil, nil]
+ * Array.new(2, 3) # => [3, 3]
*
- * With no block and arguments +size+ and +default_value+,
- * returns an \Array of the given size;
- * each element is that same +default_value+:
+ * With a block given, returns an array of the given +size+;
+ * calls the block with each +index+ in the range <tt>(0...size)</tt>;
+ * the element at that +index+ in the returned array is the blocks return value:
*
- * a = Array.new(3, 'x')
- * a # => ['x', 'x', 'x']
+ * Array.new(3) {|index| "Element #{index}" } # => ["Element 0", "Element 1", "Element 2"]
*
- * With a block and argument +size+,
- * returns an \Array of the given size;
- * the block is called with each successive integer +index+;
- * the element for that +index+ is the return value from the block:
+ * A common pitfall for new Rubyists is providing an expression as +default_value+:
*
- * a = Array.new(3) {|index| "Element #{index}" }
- * a # => ["Element 0", "Element 1", "Element 2"]
+ * array = Array.new(2, {})
+ * array # => [{}, {}]
+ * array[0][:a] = 1
+ * array # => [{a: 1}, {a: 1}], as array[0] and array[1] are same object
*
- * Raises ArgumentError if +size+ is negative.
+ * If you want the elements of the array to be distinct, you should pass a block:
*
- * With a block and no argument,
- * or a single argument +0+,
- * ignores the block and returns a new empty \Array.
+ * array = Array.new(2) { {} }
+ * array # => [{}, {}]
+ * array[0][:a] = 1
+ * array # => [{a: 1}, {}], as array[0] and array[1] are different objects
+ *
+ * Raises TypeError if the first argument is not either an array
+ * or an {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]).
+ * Raises ArgumentError if the first argument is a negative integer.
+ *
+ * Related: see {Methods for Creating an Array}[rdoc-ref:Array@Methods+for+Creating+an+Array].
*/
static VALUE
@@ -1236,8 +1143,8 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
rb_ary_modify(ary);
if (argc == 0) {
rb_ary_reset(ary);
- assert(ARY_EMBED_P(ary));
- assert(ARY_EMBED_LEN(ary) == 0);
+ RUBY_ASSERT(ARY_EMBED_P(ary));
+ RUBY_ASSERT(ARY_EMBED_LEN(ary) == 0);
if (rb_block_given_p()) {
rb_warning("given block not used");
}
@@ -1282,11 +1189,13 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
}
/*
- * Returns a new array populated with the given objects.
+ * Returns a new array, populated with the given objects:
+ *
+ * Array[1, 'a', /^A/] # => [1, "a", /^A/]
+ * Array[] # => []
+ * Array.[](1, 'a', /^A/) # => [1, "a", /^A/]
*
- * Array.[]( 1, 'a', /^A/) # => [1, "a", /^A/]
- * Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/]
- * [ 1, 'a', /^A/ ] # => [1, "a", /^A/]
+ * Related: see {Methods for Creating an Array}[rdoc-ref:Array@Methods+for+Creating+an+Array].
*/
static VALUE
@@ -1334,25 +1243,26 @@ rb_ary_store(VALUE ary, long idx, VALUE val)
static VALUE
ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
{
- assert(offset >= 0);
- assert(len >= 0);
- assert(offset+len <= RARRAY_LEN(ary));
+ RUBY_ASSERT(offset >= 0);
+ RUBY_ASSERT(len >= 0);
+ RUBY_ASSERT(offset+len <= RARRAY_LEN(ary));
- const size_t rarray_embed_capa_max = (sizeof(struct RArray) - offsetof(struct RArray, as.ary)) / sizeof(VALUE);
-
- if ((size_t)len <= rarray_embed_capa_max && ary_embeddable_p(len)) {
- VALUE result = ary_alloc_embed(klass, len);
- ary_memcpy(result, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary) + offset);
+ VALUE result = ary_alloc_heap(klass);
+ size_t embed_capa = ary_embed_capa(result);
+ if ((size_t)len <= embed_capa) {
+ FL_SET_EMBED(result);
+ ary_memcpy(result, 0, len, RARRAY_CONST_PTR(ary) + offset);
ARY_SET_EMBED_LEN(result, len);
- return result;
}
else {
VALUE shared = ary_make_shared(ary);
- VALUE result = ary_alloc_heap(klass);
- assert(!ARY_EMBED_P(result));
+ /* The ary_make_shared call may allocate, which can trigger a GC
+ * compaction. This can cause the array to be embedded because it has
+ * a length of 0. */
+ FL_UNSET_EMBED(result);
- ARY_SET_PTR(result, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ARY_SET_PTR(result, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, RARRAY_LEN(ary));
rb_ary_set_shared(result, shared);
@@ -1360,25 +1270,27 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
ARY_SET_LEN(result, len);
ary_verify(shared);
- ary_verify(result);
- return result;
}
+
+ ary_verify(result);
+ return result;
}
static VALUE
ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
{
- assert(offset >= 0);
- assert(len >= 0);
- assert(offset+len <= RARRAY_LEN(ary));
- assert(step != 0);
+ RUBY_ASSERT(offset >= 0);
+ RUBY_ASSERT(len >= 0);
+ RUBY_ASSERT(offset+len <= RARRAY_LEN(ary));
+ RUBY_ASSERT(step != 0);
- const VALUE *values = RARRAY_CONST_PTR_TRANSIENT(ary);
const long orig_len = len;
if (step > 0 && step >= len) {
VALUE result = ary_new(klass, 1);
VALUE *ptr = (VALUE *)ARY_EMBED_PTR(result);
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
RB_OBJ_WRITE(result, ptr, values[offset]);
ARY_SET_EMBED_LEN(result, 1);
return result;
@@ -1396,6 +1308,8 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
VALUE result = ary_new(klass, len);
if (ARY_EMBED_P(result)) {
VALUE *ptr = (VALUE *)ARY_EMBED_PTR(result);
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
for (i = 0; i < len; ++i) {
RB_OBJ_WRITE(result, ptr+i, values[j]);
j += step;
@@ -1403,7 +1317,9 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
ARY_SET_EMBED_LEN(result, len);
}
else {
- RARRAY_PTR_USE_TRANSIENT(result, ptr, {
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
+ RARRAY_PTR_USE(result, ptr, {
for (i = 0; i < len; ++i) {
RB_OBJ_WRITE(result, ptr+i, values[j]);
j += step;
@@ -1428,20 +1344,11 @@ enum ary_take_pos_flags
};
static VALUE
-ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
+ary_take_first_or_last_n(VALUE ary, long n, enum ary_take_pos_flags last)
{
- long n;
- long len;
+ long len = RARRAY_LEN(ary);
long offset = 0;
- argc = rb_check_arity(argc, 0, 1);
- /* the case optional argument is omitted should be handled in
- * callers of this function. if another arity case is added,
- * this arity check needs to rewrite. */
- RUBY_ASSERT_ALWAYS(argc == 1);
-
- n = NUM2LONG(argv[0]);
- len = RARRAY_LEN(ary);
if (n > len) {
n = len;
}
@@ -1454,21 +1361,30 @@ ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos
return ary_make_partial(ary, rb_cArray, offset, n);
}
+static VALUE
+ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
+{
+ argc = rb_check_arity(argc, 0, 1);
+ /* the case optional argument is omitted should be handled in
+ * callers of this function. if another arity case is added,
+ * this arity check needs to rewrite. */
+ RUBY_ASSERT_ALWAYS(argc == 1);
+ return ary_take_first_or_last_n(ary, NUM2LONG(argv[0]), last);
+}
+
/*
* call-seq:
- * array << object -> self
+ * self << object -> self
*
- * Appends +object+ to +self+; returns +self+:
+ * Appends +object+ as the last element in +self+; returns +self+:
*
- * a = [:foo, 'bar', 2]
- * a << :baz # => [:foo, "bar", 2, :baz]
+ * [:foo, 'bar', 2] << :baz # => [:foo, "bar", 2, :baz]
*
- * Appends +object+ as one element, even if it is another \Array:
+ * Appends +object+ as a single element, even if it is another array:
*
- * a = [:foo, 'bar', 2]
- * a1 = a << [3, 4]
- * a1 # => [:foo, "bar", 2, [3, 4]]
+ * [:foo, 'bar', 2] << [3, 4] # => [:foo, "bar", 2, [3, 4]]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
VALUE
@@ -1476,7 +1392,7 @@ rb_ary_push(VALUE ary, VALUE item)
{
long idx = RARRAY_LEN((ary_verify(ary), ary));
VALUE target_ary = ary_ensure_room_for_push(ary, 1);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
RB_OBJ_WRITE(target_ary, &ptr[idx], item);
});
ARY_SET_LEN(ary, idx + 1);
@@ -1496,22 +1412,20 @@ rb_ary_cat(VALUE ary, const VALUE *argv, long len)
/*
* call-seq:
- * array.push(*objects) -> self
- *
- * Appends trailing elements.
+ * push(*objects) -> self
+ * append(*objects) -> self
*
- * Appends each argument in +objects+ to +self+; returns +self+:
+ * Appends each argument in +objects+ to +self+; returns +self+:
*
- * a = [:foo, 'bar', 2]
- * a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat]
+ * a = [:foo, 'bar', 2] # => [:foo, "bar", 2]
+ * a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat]
*
- * Appends each argument as one element, even if it is another \Array:
+ * Appends each argument as a single element, even if it is another array:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.push([:baz, :bat], [:bam, :bad])
- * a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
+ * a = [:foo, 'bar', 2] # => [:foo, "bar", 2]
+ a.push([:baz, :bat], [:bam, :bad]) # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
*
- * Related: #pop, #shift, #unshift.
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -1533,41 +1447,42 @@ rb_ary_pop(VALUE ary)
{
ary_resize_capa(ary, n * 2);
}
- --n;
- ARY_SET_LEN(ary, n);
+
+ VALUE obj = RARRAY_AREF(ary, n - 1);
+
+ ARY_SET_LEN(ary, n - 1);
ary_verify(ary);
- return RARRAY_AREF(ary, n);
+ return obj;
}
/*
* call-seq:
- * array.pop -> object or nil
- * array.pop(n) -> new_array
+ * pop -> object or nil
+ * pop(count) -> new_array
*
- * Removes and returns trailing elements.
+ * Removes and returns trailing elements of +self+.
*
- * When no argument is given and +self+ is not empty,
- * removes and returns the last element:
+ * With no argument given, removes and returns the last element, if available;
+ * otherwise returns +nil+:
*
* a = [:foo, 'bar', 2]
- * a.pop # => 2
- * a # => [:foo, "bar"]
+ * a.pop # => 2
+ * a # => [:foo, "bar"]
+ * [].pop # => nil
*
- * Returns +nil+ if the array is empty.
+ * With non-negative integer argument +count+ given,
+ * returns a new array containing the trailing +count+ elements of +self+, as available:
*
- * When a non-negative \Integer argument +n+ is given and is in range,
- *
- * removes and returns the last +n+ elements in a new \Array:
* a = [:foo, 'bar', 2]
* a.pop(2) # => ["bar", 2]
- *
- * If +n+ is positive and out of range,
- * removes and returns all elements:
+ * a # => [:foo]
*
* a = [:foo, 'bar', 2]
* a.pop(50) # => [:foo, "bar", 2]
+ * a # => []
*
- * Related: #push, #shift, #unshift.
+ * Related: Array#push;
+ * see also {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -1606,35 +1521,40 @@ rb_ary_shift(VALUE ary)
/*
* call-seq:
- * array.shift -> object or nil
- * array.shift(n) -> new_array
+ * shift -> object or nil
+ * shift(count) -> new_array or nil
*
- * Removes and returns leading elements.
- *
- * When no argument is given, removes and returns the first element:
- *
- * a = [:foo, 'bar', 2]
- * a.shift # => :foo
- * a # => ['bar', 2]
+ * Removes and returns leading elements from +self+.
*
- * Returns +nil+ if +self+ is empty.
+ * With no argument, removes and returns one element, if available,
+ * or +nil+ otherwise:
*
- * When positive \Integer argument +n+ is given, removes the first +n+ elements;
- * returns those elements in a new \Array:
+ * a = [0, 1, 2, 3]
+ * a.shift # => 0
+ * a # => [1, 2, 3]
+ * [].shift # => nil
*
- * a = [:foo, 'bar', 2]
- * a.shift(2) # => [:foo, 'bar']
- * a # => [2]
+ * With non-negative numeric argument +count+ given,
+ * removes and returns the first +count+ elements:
*
- * If +n+ is as large as or larger than <tt>self.length</tt>,
- * removes all elements; returns those elements in a new \Array:
+ * a = [0, 1, 2, 3]
+ * a.shift(2) # => [0, 1]
+ * a # => [2, 3]
+ * a.shift(1.1) # => [2]
+ * a # => [3]
+ * a.shift(0) # => []
+ * a # => [3]
+ *
+ * If +count+ is large,
+ * removes and returns all elements:
*
- * a = [:foo, 'bar', 2]
- * a.shift(3) # => [:foo, 'bar', 2]
+ * a = [0, 1, 2, 3]
+ * a.shift(50) # => [0, 1, 2, 3]
+ * a # => []
*
- * If +n+ is zero, returns a new empty \Array; +self+ is unmodified.
+ * If +self+ is empty, returns a new empty array.
*
- * Related: #push, #pop, #unshift.
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -1666,7 +1586,7 @@ rb_ary_behead(VALUE ary, long n)
if (!ARY_SHARED_P(ary)) {
if (ARY_EMBED_P(ary) || RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr + n, VALUE, RARRAY_LEN(ary) - n);
}); /* WB: no new reference */
ARY_INCREASE_LEN(ary, -n);
@@ -1699,7 +1619,7 @@ make_room_for_unshift(VALUE ary, const VALUE *head, VALUE *sharedp, int argc, lo
head = sharedp + argc + room;
}
ARY_SET_PTR(ary, head - argc);
- assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary)));
+ RUBY_ASSERT(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary)));
ary_verify(ary);
return ARY_SHARED_ROOT(ary);
@@ -1727,12 +1647,12 @@ ary_modify_for_unshift(VALUE ary, int argc)
capa = ARY_CAPA(ary);
ary_make_shared(ary);
- head = sharedp = RARRAY_CONST_PTR_TRANSIENT(ary);
+ head = sharedp = RARRAY_CONST_PTR(ary);
return make_room_for_unshift(ary, head, (void *)sharedp, argc, capa, len);
}
else {
/* sliding items */
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + argc, ptr, VALUE, len);
});
@@ -1764,8 +1684,8 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
return ary_modify_for_unshift(ary, argc);
}
else {
- const VALUE * head = RARRAY_CONST_PTR_TRANSIENT(ary);
- void *sharedp = (void *)RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ const VALUE * head = RARRAY_CONST_PTR(ary);
+ void *sharedp = (void *)RARRAY_CONST_PTR(shared_root);
rb_ary_modify_check(ary);
return make_room_for_unshift(ary, head, sharedp, argc, capa, len);
@@ -1775,17 +1695,19 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
/*
* call-seq:
- * array.unshift(*objects) -> self
+ * unshift(*objects) -> self
+ * prepend(*objects) -> self
*
* Prepends the given +objects+ to +self+:
*
* a = [:foo, 'bar', 2]
* a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
*
- * Related: #push, #pop, #shift.
+ * Related: Array#shift;
+ * see also {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
-static VALUE
+VALUE
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
long len = RARRAY_LEN(ary);
@@ -1802,17 +1724,10 @@ rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
return ary;
}
-/* non-static for yjit */
-VALUE
-rb_yjit_rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
-{
- return rb_ary_unshift_m(argc, argv, ary);
-}
-
VALUE
rb_ary_unshift(VALUE ary, VALUE item)
{
- return rb_ary_unshift_m(1,&item,ary);
+ return rb_ary_unshift_m(1, &item, ary);
}
/* faster version - use this if you don't need to treat negative offset */
@@ -1865,25 +1780,38 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
/*
* call-seq:
- * array[index] -> object or nil
- * array[start, length] -> object or nil
- * array[range] -> object or nil
- * array[aseq] -> object or nil
- * array.slice(index) -> object or nil
- * array.slice(start, length) -> object or nil
- * array.slice(range) -> object or nil
- * array.slice(aseq) -> object or nil
+ * self[offset] -> object or nil
+ * self[offset, size] -> object or nil
+ * self[range] -> object or nil
+ * self[aseq] -> object or nil
*
* Returns elements from +self+; does not modify +self+.
*
- * When a single \Integer argument +index+ is given, returns the element at offset +index+:
+ * In brief:
+ *
+ * a = [:foo, 'bar', 2]
+ *
+ * # Single argument offset: returns one element.
+ * a[0] # => :foo # Zero-based index.
+ * a[-1] # => 2 # Negative index counts backwards from end.
+ *
+ * # Arguments offset and size: returns an array.
+ * a[1, 2] # => ["bar", 2]
+ * a[-2, 2] # => ["bar", 2] # Negative offset counts backwards from end.
+ *
+ * # Single argument range: returns an array.
+ * a[0..1] # => [:foo, "bar"]
+ * a[0..-2] # => [:foo, "bar"] # Negative range-begin counts backwards from end.
+ * a[-2..2] # => ["bar", 2] # Negative range-end counts backwards from end.
+ *
+ * When a single integer argument +offset+ is given, returns the element at offset +offset+:
*
* a = [:foo, 'bar', 2]
* a[0] # => :foo
* a[2] # => 2
* a # => [:foo, "bar", 2]
*
- * If +index+ is negative, counts relative to the end of +self+:
+ * If +offset+ is negative, counts backwards from the end of +self+:
*
* a = [:foo, 'bar', 2]
* a[-1] # => 2
@@ -1891,35 +1819,35 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
*
* If +index+ is out of range, returns +nil+.
*
- * When two \Integer arguments +start+ and +length+ are given,
- * returns a new \Array of size +length+ containing successive elements beginning at offset +start+:
+ * When two Integer arguments +offset+ and +size+ are given,
+ * returns a new array of size +size+ containing successive elements beginning at offset +offset+:
*
* a = [:foo, 'bar', 2]
* a[0, 2] # => [:foo, "bar"]
* a[1, 2] # => ["bar", 2]
*
- * If <tt>start + length</tt> is greater than <tt>self.length</tt>,
- * returns all elements from offset +start+ to the end:
+ * If <tt>offset + size</tt> is greater than <tt>self.size</tt>,
+ * returns all elements from offset +offset+ to the end:
*
* a = [:foo, 'bar', 2]
* a[0, 4] # => [:foo, "bar", 2]
* a[1, 3] # => ["bar", 2]
* a[2, 2] # => [2]
*
- * If <tt>start == self.size</tt> and <tt>length >= 0</tt>,
- * returns a new empty \Array.
+ * If <tt>offset == self.size</tt> and <tt>size >= 0</tt>,
+ * returns a new empty array.
*
- * If +length+ is negative, returns +nil+.
+ * If +size+ is negative, returns +nil+.
*
- * When a single \Range argument +range+ is given,
- * treats <tt>range.min</tt> as +start+ above
- * and <tt>range.size</tt> as +length+ above:
+ * When a single Range argument +range+ is given,
+ * treats <tt>range.min</tt> as +offset+ above
+ * and <tt>range.size</tt> as +size+ above:
*
* a = [:foo, 'bar', 2]
* a[0..1] # => [:foo, "bar"]
* a[1..2] # => ["bar", 2]
*
- * Special case: If <tt>range.start == a.size</tt>, returns a new empty \Array.
+ * Special case: If <tt>range.start == a.size</tt>, returns a new empty array.
*
* If <tt>range.end</tt> is negative, calculates the end index from the end:
*
@@ -1943,7 +1871,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
* a[4..-1] # => nil
*
* When a single Enumerator::ArithmeticSequence argument +aseq+ is given,
- * returns an \Array of elements corresponding to the indexes produced by
+ * returns an array of elements corresponding to the indexes produced by
* the sequence.
*
* a = ['--', 'data1', '--', 'data2', '--', 'data3']
@@ -1965,6 +1893,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
* # Raises TypeError (no implicit conversion of Symbol into Integer):
* a[:foo]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
VALUE
@@ -2012,13 +1941,26 @@ rb_ary_aref1(VALUE ary, VALUE arg)
/*
* call-seq:
- * array.at(index) -> object
+ * at(index) -> object or nil
+ *
+ * Returns the element of +self+ specified by the given +index+
+ * or +nil+ if there is no such element;
+ * +index+ must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
+ *
+ * For non-negative +index+, returns the element of +self+ at offset +index+:
*
- * Returns the element at \Integer offset +index+; does not modify +self+.
* a = [:foo, 'bar', 2]
- * a.at(0) # => :foo
- * a.at(2) # => 2
+ * a.at(0) # => :foo
+ * a.at(2) # => 2
+ * a.at(2.0) # => 2
*
+ * For negative +index+, counts backwards from the end of +self+:
+ *
+ * a.at(-2) # => "bar"
+ *
+ * Related: Array#[];
+ * see also {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
VALUE
@@ -2027,39 +1969,7 @@ rb_ary_at(VALUE ary, VALUE pos)
return rb_ary_entry(ary, NUM2LONG(pos));
}
-/*
- * call-seq:
- * array.first -> object or nil
- * array.first(n) -> new_array
- *
- * Returns elements from +self+; does not modify +self+.
- *
- * When no argument is given, returns the first element:
- *
- * a = [:foo, 'bar', 2]
- * a.first # => :foo
- * a # => [:foo, "bar", 2]
- *
- * If +self+ is empty, returns +nil+.
- *
- * When non-negative \Integer argument +n+ is given,
- * returns the first +n+ elements in a new \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.first(2) # => [:foo, "bar"]
- *
- * If <tt>n >= array.size</tt>, returns all elements:
- *
- * a = [:foo, 'bar', 2]
- * a.first(50) # => [:foo, "bar", 2]
- *
- * If <tt>n == 0</tt> returns an new empty \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.first(0) # []
- *
- * Related: #last.
- */
+#if 0
static VALUE
rb_ary_first(int argc, VALUE *argv, VALUE ary)
{
@@ -2071,48 +1981,26 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary)
return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST);
}
}
+#endif
-/*
- * call-seq:
- * array.last -> object or nil
- * array.last(n) -> new_array
- *
- * Returns elements from +self+; +self+ is not modified.
- *
- * When no argument is given, returns the last element:
- *
- * a = [:foo, 'bar', 2]
- * a.last # => 2
- * a # => [:foo, "bar", 2]
- *
- * If +self+ is empty, returns +nil+.
- *
- * When non-negative \Integer argument +n+ is given,
- * returns the last +n+ elements in a new \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.last(2) # => ["bar", 2]
- *
- * If <tt>n >= array.size</tt>, returns all elements:
- *
- * a = [:foo, 'bar', 2]
- * a.last(50) # => [:foo, "bar", 2]
- *
- * If <tt>n == 0</tt>, returns an new empty \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.last(0) # []
- *
- * Related: #first.
- */
+static VALUE
+ary_first(VALUE self)
+{
+ return (RARRAY_LEN(self) == 0) ? Qnil : RARRAY_AREF(self, 0);
+}
+
+static VALUE
+ary_last(VALUE self)
+{
+ long len = RARRAY_LEN(self);
+ return (len == 0) ? Qnil : RARRAY_AREF(self, len-1);
+}
VALUE
-rb_ary_last(int argc, const VALUE *argv, VALUE ary)
+rb_ary_last(int argc, const VALUE *argv, VALUE ary) // used by parse.y
{
if (argc == 0) {
- long len = RARRAY_LEN(ary);
- if (len == 0) return Qnil;
- return RARRAY_AREF(ary, len-1);
+ return ary_last(ary);
}
else {
return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST);
@@ -2121,17 +2009,19 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.fetch(index) -> element
- * array.fetch(index, default_value) -> element
- * array.fetch(index) {|index| ... } -> element
+ * fetch(index) -> element
+ * fetch(index, default_value) -> element or default_value
+ * fetch(index) {|index| ... } -> element or block_return_value
*
- * Returns the element at offset +index+.
+ * Returns the element of +self+ at offset +index+ if +index+ is in range; +index+ must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
*
- * With the single \Integer argument +index+,
+ * With the single argument +index+ and no block,
* returns the element at offset +index+:
*
* a = [:foo, 'bar', 2]
- * a.fetch(1) # => "bar"
+ * a.fetch(1) # => "bar"
+ * a.fetch(1.1) # => "bar"
*
* If +index+ is negative, counts from the end of the array:
*
@@ -2139,12 +2029,12 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
* a.fetch(-1) # => 2
* a.fetch(-2) # => "bar"
*
- * With arguments +index+ and +default_value+,
- * returns the element at offset +index+ if index is in range,
- * otherwise returns +default_value+:
+ * With arguments +index+ and +default_value+ (which may be any object) and no block,
+ * returns +default_value+ if +index+ is out-of-range:
*
* a = [:foo, 'bar', 2]
- * a.fetch(1, nil) # => "bar"
+ * a.fetch(1, nil) # => "bar"
+ * a.fetch(3, :foo) # => :foo
*
* With argument +index+ and a block,
* returns the element at offset +index+ if index is in range
@@ -2154,6 +2044,7 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
* a.fetch(1) {|index| raise 'Cannot happen' } # => "bar"
* a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50"
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -2185,14 +2076,106 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
}
/*
+ * call-seq:
+ * find(if_none_proc = nil) {|element| ... } -> object or nil
+ * find(if_none_proc = nil) -> enumerator
+ *
+ * Returns the first element for which the block returns a truthy value.
+ *
+ * With a block given, calls the block with successive elements of the array;
+ * returns the first element for which the block returns a truthy value:
+ *
+ * [1, 3, 5].find {|element| element > 2} # => 3
+ *
+ * If no such element is found, calls +if_none_proc+ and returns its return value.
+ *
+ * [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
+ *
+ * With no block given, returns an Enumerator.
+ *
+ */
+
+static VALUE
+rb_ary_find(int argc, VALUE *argv, VALUE ary)
+{
+ VALUE if_none;
+ long idx;
+
+ RETURN_ENUMERATOR(ary, argc, argv);
+ if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
+
+ for (idx = 0; idx < RARRAY_LEN(ary); idx++) {
+ VALUE elem = RARRAY_AREF(ary, idx);
+ if (RTEST(rb_yield(elem))) {
+ return elem;
+ }
+ }
+
+ if (!NIL_P(if_none)) {
+ return rb_funcallv(if_none, idCall, 0, 0);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * rfind(if_none_proc = nil) {|element| ... } -> object or nil
+ * rfind(if_none_proc = nil) -> enumerator
+ *
+ * Returns the last element for which the block returns a truthy value.
+ *
+ * With a block given, calls the block with successive elements of the array in
+ * reverse order; returns the first element for which the block returns a truthy
+ * value:
+ *
+ * [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
+ *
+ * If no such element is found, calls +if_none_proc+ and returns its return value.
+ *
+ * [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
+ *
+ * With no block given, returns an Enumerator.
+ *
+ */
+
+static VALUE
+rb_ary_rfind(int argc, VALUE *argv, VALUE ary)
+{
+ VALUE if_none;
+ long len, idx;
+
+ RETURN_ENUMERATOR(ary, argc, argv);
+ if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
+
+ idx = RARRAY_LEN(ary);
+ while (idx--) {
+ VALUE elem = RARRAY_AREF(ary, idx);
+ if (RTEST(rb_yield(elem))) {
+ return elem;
+ }
+
+ len = RARRAY_LEN(ary);
+ idx = (idx >= len) ? len : idx;
+ }
+
+ if (!NIL_P(if_none)) {
+ return rb_funcallv(if_none, idCall, 0, 0);
+ }
+ return Qnil;
+}
+
+/*
* call-seq:
- * array.index(object) -> integer or nil
- * array.index {|element| ... } -> integer or nil
- * array.index -> new_enumerator
+ * find_index(object) -> integer or nil
+ * find_index {|element| ... } -> integer or nil
+ * find_index -> new_enumerator
+ * index(object) -> integer or nil
+ * index {|element| ... } -> integer or nil
+ * index -> new_enumerator
*
- * Returns the index of a specified element.
+ * Returns the zero-based integer index of a specified element, or +nil+.
*
- * When argument +object+ is given but no block,
+ * With only argument +object+ given,
* returns the index of the first element +element+
* for which <tt>object == element</tt>:
*
@@ -2201,7 +2184,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
*
* Returns +nil+ if no such element found.
*
- * When both argument +object+ and a block are given,
+ * With only a block given,
* calls the block with each successive element;
* returns the index of the first element for which the block returns a truthy value:
*
@@ -2210,14 +2193,9 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
*
* Returns +nil+ if the block never returns a truthy value.
*
- * When neither an argument nor a block is given, returns a new Enumerator:
- *
- * a = [:foo, 'bar', 2]
- * e = a.index
- * e # => #<Enumerator: [:foo, "bar", 2]:index>
- * e.each {|element| element == 'bar' } # => 1
+ * With neither an argument nor a block given, returns a new Enumerator.
*
- * Related: #rindex.
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -2250,20 +2228,20 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.rindex(object) -> integer or nil
- * array.rindex {|element| ... } -> integer or nil
- * array.rindex -> new_enumerator
+ * rindex(object) -> integer or nil
+ * rindex {|element| ... } -> integer or nil
+ * rindex -> new_enumerator
*
* Returns the index of the last element for which <tt>object == element</tt>.
*
- * When argument +object+ is given but no block, returns the index of the last such element found:
+ * With argument +object+ given, returns the index of the last such element found:
*
* a = [:foo, 'bar', 2, 'bar']
* a.rindex('bar') # => 3
*
* Returns +nil+ if no such object found.
*
- * When a block is given but no argument, calls the block with each successive element;
+ * With a block given, calls the block with each successive element;
* returns the index of the last element for which the block returns a truthy value:
*
* a = [:foo, 'bar', 2, 'bar']
@@ -2271,14 +2249,9 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
*
* Returns +nil+ if the block never returns a truthy value.
*
- * When neither an argument nor a block is given, returns a new \Enumerator:
+ * When neither an argument nor a block is given, returns a new Enumerator.
*
- * a = [:foo, 'bar', 2, 'bar']
- * e = a.rindex
- * e # => #<Enumerator: [:foo, "bar", 2, "bar"]:rindex>
- * e.each {|element| element == 'bar' } # => 3
- *
- * Related: #index.
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -2343,7 +2316,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
{
- const VALUE *optr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *optr = RARRAY_CONST_PTR(ary);
rofs = (rptr >= optr && rptr < optr + olen) ? rptr - optr : -1;
}
@@ -2356,7 +2329,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
len = beg + rlen;
ary_mem_clear(ary, olen, beg - olen);
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
+ if (rofs != -1) rptr = RARRAY_CONST_PTR(ary) + rofs;
ary_memcpy0(ary, beg, rlen, rptr, target_ary);
}
ARY_SET_LEN(ary, len);
@@ -2374,20 +2347,25 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
if (len != rlen) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
MEMMOVE(ptr + beg + rlen, ptr + beg + len,
VALUE, olen - (beg + len)));
ARY_SET_LEN(ary, alen);
}
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
- /* give up wb-protected ary */
- RB_OBJ_WB_UNPROTECT_FOR(ARRAY, ary);
+ if (rofs == -1) {
+ rb_gc_writebarrier_remember(ary);
+ }
+ else {
+ /* In this case, we're copying from a region in this array, so
+ * we don't need to fire the write barrier. */
+ rptr = RARRAY_CONST_PTR(ary) + rofs;
+ }
/* do not use RARRAY_PTR() because it can causes GC.
* ary can contain T_NONE object because it is not cleared.
*/
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
MEMMOVE(ptr + beg, rptr, VALUE, rlen));
}
}
@@ -2420,7 +2398,7 @@ rb_ary_resize(VALUE ary, long len)
rb_raise(rb_eIndexError, "index %ld too big", len);
}
if (len > olen) {
- if (len >= ARY_CAPA(ary)) {
+ if (len > ARY_CAPA(ary)) {
ary_double_capa(ary, len);
}
ary_mem_clear(ary, olen, len - olen);
@@ -2432,15 +2410,14 @@ rb_ary_resize(VALUE ary, long len)
else if (len <= ary_embed_capa(ary)) {
const VALUE *ptr = ARY_HEAP_PTR(ary);
long ptr_capa = ARY_HEAP_SIZE(ary);
- bool is_malloc_ptr = !ARY_SHARED_P(ary) && !RARRAY_TRANSIENT_P(ary);
+ bool is_malloc_ptr = !ARY_SHARED_P(ary);
- FL_UNSET(ary, RARRAY_TRANSIENT_FLAG);
FL_SET_EMBED(ary);
MEMCPY((VALUE *)ARY_EMBED_PTR(ary), ptr, VALUE, len); /* WB: no new reference */
ARY_SET_EMBED_LEN(ary, len);
- if (is_malloc_ptr) ruby_sized_xfree((void *)ptr, ptr_capa);
+ if (is_malloc_ptr) ruby_xfree_sized((void *)ptr, ptr_capa);
}
else {
if (olen > len + ARY_DEFAULT_SIZE) {
@@ -2464,20 +2441,48 @@ static VALUE
ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
{
VALUE rpl = rb_ary_to_ary(val);
- rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR_TRANSIENT(rpl), RARRAY_LEN(rpl));
+ rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR(rpl), RARRAY_LEN(rpl));
RB_GC_GUARD(rpl);
return val;
}
/*
* call-seq:
- * array[index] = object -> object
- * array[start, length] = object -> object
- * array[range] = object -> object
- *
- * Assigns elements in +self+; returns the given +object+.
- *
- * When \Integer argument +index+ is given, assigns +object+ to an element in +self+.
+ * self[index] = object -> object
+ * self[start, length] = object -> object
+ * self[range] = object -> object
+ *
+ * Assigns elements in +self+, based on the given +object+; returns +object+.
+ *
+ * In brief:
+ *
+ * a_orig = [:foo, 'bar', 2]
+ *
+ * # With argument index.
+ * a = a_orig.dup
+ * a[0] = 'foo' # => "foo"
+ * a # => ["foo", "bar", 2]
+ * a = a_orig.dup
+ * a[7] = 'foo' # => "foo"
+ * a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"]
+ *
+ * # With arguments start and length.
+ * a = a_orig.dup
+ * a[0, 2] = 'foo' # => "foo"
+ * a # => ["foo", 2]
+ * a = a_orig.dup
+ * a[6, 50] = 'foo' # => "foo"
+ * a # => [:foo, "bar", 2, nil, nil, nil, "foo"]
+ *
+ * # With argument range.
+ * a = a_orig.dup
+ * a[0..1] = 'foo' # => "foo"
+ * a # => ["foo", 2]
+ * a = a_orig.dup
+ * a[6..50] = 'foo' # => "foo"
+ * a # => [:foo, "bar", 2, nil, nil, nil, "foo"]
+ *
+ * When Integer argument +index+ is given, assigns +object+ to an element in +self+.
*
* If +index+ is non-negative, assigns +object+ the element at offset +index+:
*
@@ -2497,7 +2502,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a[-1] = 'two' # => "two"
* a # => [:foo, "bar", "two"]
*
- * When \Integer arguments +start+ and +length+ are given and +object+ is not an \Array,
+ * When Integer arguments +start+ and +length+ are given and +object+ is not an array,
* removes <tt>length - 1</tt> elements beginning at offset +start+,
* and assigns +object+ at offset +start+:
*
@@ -2532,7 +2537,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a[1, 5] = 'foo' # => "foo"
* a # => [:foo, "foo"]
*
- * When \Range argument +range+ is given and +object+ is an \Array,
+ * When Range argument +range+ is given and +object+ is not an array,
* removes <tt>length - 1</tt> elements beginning at offset +start+,
* and assigns +object+ at offset +start+:
*
@@ -2547,7 +2552,8 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a # => [:foo, "foo"]
*
* If the array length is less than <tt>range.begin</tt>,
- * assigns +object+ at offset <tt>range.begin</tt>, and ignores +length+:
+ * extends the array with +nil+, assigns +object+ at offset <tt>range.begin</tt>,
+ * and ignores +length+:
*
* a = [:foo, 'bar', 2]
* a[6..50] = 'foo' # => "foo"
@@ -2581,6 +2587,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a[1..5] = 'foo' # => "foo"
* a # => [:foo, "foo"]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -2610,38 +2617,38 @@ rb_ary_aset(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.insert(index, *objects) -> self
+ * insert(index, *objects) -> self
*
- * Inserts given +objects+ before or after the element at \Integer index +offset+;
+ * Inserts the given +objects+ as elements of +self+;
* returns +self+.
*
- * When +index+ is non-negative, inserts all given +objects+
- * before the element at offset +index+:
+ * When +index+ is non-negative, inserts +objects+
+ * _before_ the element at offset +index+:
*
- * a = [:foo, 'bar', 2]
- * a.insert(1, :bat, :bam) # => [:foo, :bat, :bam, "bar", 2]
+ * a = ['a', 'b', 'c'] # => ["a", "b", "c"]
+ * a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"]
*
* Extends the array if +index+ is beyond the array (<tt>index >= self.size</tt>):
*
- * a = [:foo, 'bar', 2]
- * a.insert(5, :bat, :bam)
- * a # => [:foo, "bar", 2, nil, nil, :bat, :bam]
+ * a = ['a', 'b', 'c'] # => ["a", "b", "c"]
+ * a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z]
*
- * Does nothing if no objects given:
+ * When +index+ is negative, inserts +objects+
+ * _after_ the element at offset <tt>index + self.size</tt>:
*
- * a = [:foo, 'bar', 2]
- * a.insert(1)
- * a.insert(50)
- * a.insert(-50)
- * a # => [:foo, "bar", 2]
+ * a = ['a', 'b', 'c'] # => ["a", "b", "c"]
+ * a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"]
*
- * When +index+ is negative, inserts all given +objects+
- * _after_ the element at offset <tt>index+self.size</tt>:
+ * With no +objects+ given, does nothing:
*
- * a = [:foo, 'bar', 2]
- * a.insert(-2, :bat, :bam)
- * a # => [:foo, "bar", :bat, :bam, 2]
+ * a = ['a', 'b', 'c'] # => ["a", "b", "c"]
+ * a.insert(1) # => ["a", "b", "c"]
+ * a.insert(50) # => ["a", "b", "c"]
+ * a.insert(-50) # => ["a", "b", "c"]
+ *
+ * Raises IndexError if +objects+ are given and +index+ is negative and out of range.
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -2677,14 +2684,48 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj)
return rb_ary_length(ary);
}
+// These array primitives enable tight compatibility with the C implementation
+// in terms of what method calls happen. They can use unchecked utilities such as
+// FIX2LONG since unlike userland Ruby code, these methods cannot be traced with
+// TracePoint (or ruby/debug.h APIs) and have their local variables changed from
+// underneath them.
+
+// Return true if the index is at or past the end of the array.
+VALUE
+rb_jit_ary_at_end(rb_execution_context_t *ec, VALUE self, VALUE index)
+{
+ return FIX2LONG(index) >= RARRAY_LEN(self) ? Qtrue : Qfalse;
+}
+
+// Return the element at the given fixnum index.
+VALUE
+rb_jit_ary_at(rb_execution_context_t *ec, VALUE self, VALUE index)
+{
+ return RARRAY_AREF(self, FIX2LONG(index));
+}
+
+// Increment a fixnum by 1.
+VALUE
+rb_jit_fixnum_inc(rb_execution_context_t *ec, VALUE self, VALUE num)
+{
+ return LONG2FIX(FIX2LONG(num) + 1);
+}
+
+// Push a value onto an array and return the value.
+VALUE
+rb_jit_ary_push(rb_execution_context_t *ec, VALUE self, VALUE ary, VALUE val)
+{
+ rb_ary_push(ary, val);
+ return val;
+}
+
/*
* call-seq:
- * array.each {|element| ... } -> self
- * array.each -> Enumerator
- *
- * Iterates over array elements.
+ * each {|element| ... } -> self
+ * each -> new_enumerator
*
- * When a block given, passes each successive array element to the block;
+ * With a block given, iterates over the elements of +self+,
+ * passing each element to the block;
* returns +self+:
*
* a = [:foo, 'bar', 2]
@@ -2706,20 +2747,9 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj)
* foo
* bar
*
- * When no block given, returns a new \Enumerator:
- * a = [:foo, 'bar', 2]
- *
- * e = a.each
- * e # => #<Enumerator: [:foo, "bar", 2]:each>
- * a1 = e.each {|element| puts "#{element.class} #{element}" }
- *
- * Output:
+ * With no block given, returns a new Enumerator.
*
- * Symbol foo
- * String bar
- * Integer 2
- *
- * Related: #each_index, #reverse_each.
+ * Related: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
VALUE
@@ -2736,12 +2766,11 @@ rb_ary_each(VALUE ary)
/*
* call-seq:
- * array.each_index {|index| ... } -> self
- * array.each_index -> Enumerator
- *
- * Iterates over array indexes.
+ * each_index {|index| ... } -> self
+ * each_index -> new_enumerator
*
- * When a block given, passes each successive array index to the block;
+ * With a block given, iterates over the elements of +self+,
+ * passing each <i>array index</i> to the block;
* returns +self+:
*
* a = [:foo, 'bar', 2]
@@ -2757,26 +2786,16 @@ rb_ary_each(VALUE ary)
*
* a = [:foo, 'bar', 2]
* a.each_index {|index| puts index; a.clear if index > 0 }
+ * a # => []
*
* Output:
*
* 0
* 1
*
- * When no block given, returns a new \Enumerator:
- *
- * a = [:foo, 'bar', 2]
- * e = a.each_index
- * e # => #<Enumerator: [:foo, "bar", 2]:each_index>
- * a1 = e.each {|index| puts "#{index} #{a[index]}"}
- *
- * Output:
- *
- * 0 foo
- * 1 bar
- * 2 2
+ * With no block given, returns a new Enumerator.
*
- * Related: #each, #reverse_each.
+ * Related: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
static VALUE
@@ -2793,47 +2812,26 @@ rb_ary_each_index(VALUE ary)
/*
* call-seq:
- * array.reverse_each {|element| ... } -> self
- * array.reverse_each -> Enumerator
- *
- * Iterates backwards over array elements.
+ * reverse_each {|element| ... } -> self
+ * reverse_each -> Enumerator
*
- * When a block given, passes, in reverse order, each element to the block;
+ * When a block given, iterates backwards over the elements of +self+,
+ * passing, in reverse order, each element to the block;
* returns +self+:
*
- * a = [:foo, 'bar', 2]
- * a.reverse_each {|element| puts "#{element.class} #{element}" }
- *
- * Output:
- *
- * Integer 2
- * String bar
- * Symbol foo
+ * a = []
+ * [0, 1, 2].reverse_each {|element| a.push(element) }
+ * a # => [2, 1, 0]
*
* Allows the array to be modified during iteration:
*
- * a = [:foo, 'bar', 2]
- * a.reverse_each {|element| puts element; a.clear if element.to_s.start_with?('b') }
- *
- * Output:
- *
- * 2
- * bar
- *
- * When no block given, returns a new \Enumerator:
- *
- * a = [:foo, 'bar', 2]
- * e = a.reverse_each
- * e # => #<Enumerator: [:foo, "bar", 2]:reverse_each>
- * a1 = e.each {|element| puts "#{element.class} #{element}" }
+ * a = ['a', 'b', 'c']
+ * a.reverse_each {|element| a.clear if element.start_with?('b') }
+ * a # => []
*
- * Output:
+ * When no block given, returns a new Enumerator.
*
- * Integer 2
- * String bar
- * Symbol foo
- *
- * Related: #each, #each_index.
+ * Related: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
static VALUE
@@ -2856,9 +2854,15 @@ rb_ary_reverse_each(VALUE ary)
/*
* call-seq:
- * array.length -> an_integer
+ * length -> integer
+ * size -> integer
+ *
+ * Returns the count of elements in +self+:
+ *
+ * [0, 1, 2].length # => 3
+ * [].length # => 0
*
- * Returns the count of elements in +self+.
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -2870,10 +2874,12 @@ rb_ary_length(VALUE ary)
/*
* call-seq:
- * array.empty? -> true or false
+ * empty? -> true or false
*
* Returns +true+ if the count of elements in +self+ is zero,
* +false+ otherwise.
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -2887,7 +2893,7 @@ rb_ary_dup(VALUE ary)
{
long len = RARRAY_LEN(ary);
VALUE dup = rb_ary_new2(len);
- ary_memcpy(dup, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(dup, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(dup, len);
ary_verify(ary);
@@ -3008,23 +3014,28 @@ rb_ary_join(VALUE ary, VALUE sep)
StringValue(sep);
len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
}
- for (i=0; i<RARRAY_LEN(ary); i++) {
+ long len_memo = RARRAY_LEN(ary);
+ for (i=0; i < len_memo; i++) {
val = RARRAY_AREF(ary, i);
- tmp = rb_check_string_type(val);
-
- if (NIL_P(tmp) || tmp != val) {
- int first;
- long n = RARRAY_LEN(ary);
- if (i > n) i = n;
- result = rb_str_buf_new(len + (n-i)*10);
- rb_enc_associate(result, rb_usascii_encoding());
- i = ary_join_0(ary, sep, i, result);
- first = i == 0;
- ary_join_1(ary, ary, sep, i, result, &first);
- return result;
+ if (RB_UNLIKELY(!RB_TYPE_P(val, T_STRING))) {
+ tmp = rb_check_string_type(val);
+ if (NIL_P(tmp) || tmp != val) {
+ int first;
+ long n = RARRAY_LEN(ary);
+ if (i > n) i = n;
+ result = rb_str_buf_new(len + (n-i)*10);
+ rb_enc_associate(result, rb_usascii_encoding());
+ i = ary_join_0(ary, sep, i, result);
+ first = i == 0;
+ ary_join_1(ary, ary, sep, i, result, &first);
+ return result;
+ }
+ len += RSTRING_LEN(tmp);
+ len_memo = RARRAY_LEN(ary);
+ }
+ else {
+ len += RSTRING_LEN(val);
}
-
- len += RSTRING_LEN(tmp);
}
result = rb_str_new(0, len);
@@ -3037,31 +3048,32 @@ rb_ary_join(VALUE ary, VALUE sep)
/*
* call-seq:
- * array.join ->new_string
- * array.join(separator = $,) -> new_string
+ * join(separator = $,) -> new_string
*
- * Returns the new \String formed by joining the array elements after conversion.
- * For each element +element+:
+ * Returns the new string formed by joining the converted elements of +self+;
+ * for each element +element+:
*
- * - Uses <tt>element.to_s</tt> if +element+ is not a <tt>kind_of?(Array)</tt>.
- * - Uses recursive <tt>element.join(separator)</tt> if +element+ is a <tt>kind_of?(Array)</tt>.
+ * - Converts recursively using <tt>element.join(separator)</tt>
+ * if +element+ is a <tt>kind_of?(Array)</tt>.
+ * - Otherwise, converts using <tt>element.to_s</tt>.
*
- * With no argument, joins using the output field separator, <tt>$,</tt>:
+ * With no argument given, joins using the output field separator, <tt>$,</tt>:
*
* a = [:foo, 'bar', 2]
* $, # => nil
* a.join # => "foobar2"
*
- * With \string argument +separator+, joins using that separator:
+ * With string argument +separator+ given, joins using that separator:
*
* a = [:foo, 'bar', 2]
* a.join("\n") # => "foo\nbar\n2"
*
- * Joins recursively for nested Arrays:
+ * Joins recursively for nested arrays:
*
* a = [:foo, [:bar, [:baz, :bat]]]
* a.join # => "foobarbazbat"
*
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
@@ -3098,14 +3110,16 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
/*
* call-seq:
- * array.inspect -> new_string
+ * inspect -> new_string
+ * to_s -> new_string
*
- * Returns the new \String formed by calling method <tt>#inspect</tt>
+ * Returns the new string formed by calling method <tt>#inspect</tt>
* on each array element:
*
* a = [:foo, 'bar', 2]
* a.inspect # => "[:foo, \"bar\", 2]"
*
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -3125,21 +3139,17 @@ rb_ary_to_s(VALUE ary)
* call-seq:
* to_a -> self or new_array
*
- * When +self+ is an instance of \Array, returns +self+:
- *
- * a = [:foo, 'bar', 2]
- * a.to_a # => [:foo, "bar", 2]
+ * When +self+ is an instance of \Array, returns +self+.
*
- * Otherwise, returns a new \Array containing the elements of +self+:
+ * Otherwise, returns a new array containing the elements of +self+:
*
* class MyArray < Array; end
- * a = MyArray.new(['foo', 'bar', 'two'])
- * a.instance_of?(Array) # => false
- * a.kind_of?(Array) # => true
- * a1 = a.to_a
- * a1 # => ["foo", "bar", "two"]
- * a1.class # => Array # Not MyArray
+ * my_a = MyArray.new(['foo', 'bar', 'two'])
+ * a = my_a.to_a
+ * a # => ["foo", "bar", "two"]
+ * a.class # => Array # Not MyArray.
*
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -3155,27 +3165,27 @@ rb_ary_to_a(VALUE ary)
/*
* call-seq:
- * array.to_h -> new_hash
- * array.to_h {|item| ... } -> new_hash
+ * to_h -> new_hash
+ * to_h {|element| ... } -> new_hash
*
- * Returns a new \Hash formed from +self+.
+ * Returns a new hash formed from +self+.
*
- * When a block is given, calls the block with each array element;
- * the block must return a 2-element \Array whose two elements
- * form a key-value pair in the returned \Hash:
+ * With no block given, each element of +self+ must be a 2-element sub-array;
+ * forms each sub-array into a key-value pair in the new hash:
*
- * a = ['foo', :bar, 1, [2, 3], {baz: 4}]
- * h = a.to_h {|item| [item, item] }
- * h # => {"foo"=>"foo", :bar=>:bar, 1=>1, [2, 3]=>[2, 3], {:baz=>4}=>{:baz=>4}}
+ * a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']]
+ * a.to_h # => {"foo" => "zero", "bar" => "one", "baz" => "two"}
+ * [].to_h # => {}
*
- * When no block is given, +self+ must be an \Array of 2-element sub-arrays,
- * each sub-array is formed into a key-value pair in the new \Hash:
+ * With a block given, the block must return a 2-element array;
+ * calls the block with each element of +self+;
+ * forms each returned array into a key-value pair in the returned hash:
*
- * [].to_h # => {}
- * a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']]
- * h = a.to_h
- * h # => {"foo"=>"zero", "bar"=>"one", "baz"=>"two"}
+ * a = ['foo', :bar, 1, [2, 3], {baz: 4}]
+ * a.to_h {|element| [element, element.class] }
+ * # => {"foo" => String, bar: Symbol, 1 => Integer, [2, 3] => Array, {baz: 4} => Hash}
*
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -3204,7 +3214,7 @@ rb_ary_to_h(VALUE ary)
/*
* call-seq:
- * array.to_ary -> self
+ * to_ary -> self
*
* Returns +self+.
*/
@@ -3233,7 +3243,7 @@ rb_ary_reverse(VALUE ary)
rb_ary_modify(ary);
if (len > 1) {
- RARRAY_PTR_USE_TRANSIENT(ary, p1, {
+ RARRAY_PTR_USE(ary, p1, {
p2 = p1 + len - 1; /* points last item */
ary_reverse(p1, p2);
}); /* WB: no new reference */
@@ -3243,13 +3253,16 @@ rb_ary_reverse(VALUE ary)
/*
* call-seq:
- * array.reverse! -> self
+ * reverse! -> self
*
- * Reverses +self+ in place:
+ * Reverses the order of the elements of +self+;
+ * returns +self+:
*
- * a = ['foo', 'bar', 'two']
- * a.reverse! # => ["two", "bar", "foo"]
+ * a = [0, 1, 2]
+ * a.reverse! # => [2, 1, 0]
+ * a # => [2, 1, 0]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -3260,14 +3273,13 @@ rb_ary_reverse_bang(VALUE ary)
/*
* call-seq:
- * array.reverse -> new_array
+ * reverse -> new_array
*
- * Returns a new \Array with the elements of +self+ in reverse order:
+ * Returns a new array containing the elements of +self+ in reverse order:
*
- * a = ['foo', 'bar', 'two']
- * a1 = a.reverse
- * a1 # => ["two", "bar", "foo"]
+ * [0, 1, 2].reverse # => [2, 1, 0]
*
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -3277,8 +3289,8 @@ rb_ary_reverse_m(VALUE ary)
VALUE dup = rb_ary_new2(len);
if (len > 0) {
- const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);
- VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;
+ const VALUE *p1 = RARRAY_CONST_PTR(ary);
+ VALUE *p2 = (VALUE *)RARRAY_CONST_PTR(dup) + len - 1;
do *p2-- = *p1++; while (--len > 0);
}
ARY_SET_LEN(dup, RARRAY_LEN(ary));
@@ -3320,7 +3332,7 @@ rb_ary_rotate(VALUE ary, long cnt)
if (cnt != 0) {
long len = RARRAY_LEN(ary);
if (len > 1 && (cnt = rotate_count(cnt, len)) > 0) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
+ RARRAY_PTR_USE(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
return ary;
}
}
@@ -3329,48 +3341,34 @@ rb_ary_rotate(VALUE ary, long cnt)
/*
* call-seq:
- * array.rotate! -> self
- * array.rotate!(count) -> self
+ * rotate!(count = 1) -> self
*
* Rotates +self+ in place by moving elements from one end to the other; returns +self+.
*
- * When no argument given, rotates the first element to the last position:
- *
- * a = [:foo, 'bar', 2, 'bar']
- * a.rotate! # => ["bar", 2, "bar", :foo]
- *
- * When given a non-negative \Integer +count+,
+ * With non-negative numeric +count+,
* rotates +count+ elements from the beginning to the end:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(2)
- * a # => [2, :foo, "bar"]
+ * [0, 1, 2, 3].rotate!(2) # => [2, 3, 0, 1]
+ [0, 1, 2, 3].rotate!(2.1) # => [2, 3, 0, 1]
*
* If +count+ is large, uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(20)
- * a # => [2, :foo, "bar"]
+ * [0, 1, 2, 3].rotate!(21) # => [1, 2, 3, 0]
*
- * If +count+ is zero, returns +self+ unmodified:
+ * If +count+ is zero, rotates no elements:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(0)
- * a # => [:foo, "bar", 2]
+ * [0, 1, 2, 3].rotate!(0) # => [0, 1, 2, 3]
*
- * When given a negative Integer +count+, rotates in the opposite direction,
+ * With a negative numeric +count+, rotates in the opposite direction,
* from end to beginning:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(-2)
- * a # => ["bar", 2, :foo]
+ * [0, 1, 2, 3].rotate!(-1) # => [3, 0, 1, 2]
*
* If +count+ is small (far from zero), uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(-5)
- * a # => ["bar", 2, :foo]
+ * [0, 1, 2, 3].rotate!(-21) # => [3, 0, 1, 2]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -3383,51 +3381,35 @@ rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.rotate -> new_array
- * array.rotate(count) -> new_array
+ * rotate(count = 1) -> new_array
*
- * Returns a new \Array formed from +self+ with elements
+ * Returns a new array formed from +self+ with elements
* rotated from one end to the other.
*
- * When no argument given, returns a new \Array that is like +self+,
- * except that the first element has been rotated to the last position:
- *
- * a = [:foo, 'bar', 2, 'bar']
- * a1 = a.rotate
- * a1 # => ["bar", 2, "bar", :foo]
- *
- * When given a non-negative \Integer +count+,
- * returns a new \Array with +count+ elements rotated from the beginning to the end:
+ * With non-negative numeric +count+,
+ * rotates elements from the beginning to the end:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.rotate(2)
- * a1 # => [2, :foo, "bar"]
+ * [0, 1, 2, 3].rotate(2) # => [2, 3, 0, 1]
+ * [0, 1, 2, 3].rotate(2.1) # => [2, 3, 0, 1]
*
* If +count+ is large, uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.rotate(20)
- * a1 # => [2, :foo, "bar"]
+ * [0, 1, 2, 3].rotate(22) # => [2, 3, 0, 1]
*
- * If +count+ is zero, returns a copy of +self+, unmodified:
+ * With a +count+ of zero, rotates no elements:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.rotate(0)
- * a1 # => [:foo, "bar", 2]
+ * [0, 1, 2, 3].rotate(0) # => [0, 1, 2, 3]
*
- * When given a negative \Integer +count+, rotates in the opposite direction,
- * from end to beginning:
+ * With negative numeric +count+, rotates in the opposite direction,
+ * from the end to the beginning:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.rotate(-2)
- * a1 # => ["bar", 2, :foo]
+ * [0, 1, 2, 3].rotate(-1) # => [3, 0, 1, 2]
*
* If +count+ is small (far from zero), uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a1 = a.rotate(-5)
- * a1 # => ["bar", 2, :foo]
+ * [0, 1, 2, 3].rotate(-21) # => [3, 0, 1, 2]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -3442,7 +3424,7 @@ rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary)
rotated = rb_ary_new2(len);
if (len > 0) {
cnt = rotate_count(cnt, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
len -= cnt;
ary_memcpy(rotated, 0, len, ptr + cnt);
ary_memcpy(rotated, len, cnt, ptr);
@@ -3520,50 +3502,19 @@ sort_2(const void *ap, const void *bp, void *dummy)
/*
* call-seq:
- * array.sort! -> self
- * array.sort! {|a, b| ... } -> self
- *
- * Returns +self+ with its elements sorted in place.
- *
- * With no block, compares elements using operator <tt><=></tt>
- * (see Comparable):
- *
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a.sort!
- * a # => ["a", "b", "c", "d", "e"]
- *
- * With a block, calls the block with each element pair;
- * for each element pair +a+ and +b+, the block should return an integer:
+ * sort! -> self
+ * sort! {|a, b| ... } -> self
*
- * - Negative when +b+ is to follow +a+.
- * - Zero when +a+ and +b+ are equivalent.
- * - Positive when +a+ is to follow +b+.
- *
- * Example:
- *
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a.sort! {|a, b| a <=> b }
- * a # => ["a", "b", "c", "d", "e"]
- * a.sort! {|a, b| b <=> a }
- * a # => ["e", "d", "c", "b", "a"]
- *
- * When the block returns zero, the order for +a+ and +b+ is indeterminate,
- * and may be unstable:
- *
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a.sort! {|a, b| 0 }
- * a # => ["d", "e", "c", "a", "b"]
+ * Like Array#sort, but returns +self+ with its elements sorted in place.
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
VALUE
rb_ary_sort_bang(VALUE ary)
{
rb_ary_modify(ary);
- assert(!ARY_SHARED_P(ary));
+ RUBY_ASSERT(!ARY_SHARED_P(ary));
if (RARRAY_LEN(ary) > 1) {
VALUE tmp = ary_make_substitution(ary); /* only ary refers tmp */
struct ary_sort_data data;
@@ -3581,6 +3532,9 @@ rb_ary_sort_bang(VALUE ary)
rb_ary_unshare(ary);
FL_SET_EMBED(ary);
}
+ if (ARY_EMBED_LEN(tmp) > ARY_CAPA(ary)) {
+ ary_resize_capa(ary, ARY_EMBED_LEN(tmp));
+ }
ary_memcpy(ary, 0, ARY_EMBED_LEN(tmp), ARY_EMBED_PTR(tmp));
ARY_SET_LEN(ary, ARY_EMBED_LEN(tmp));
}
@@ -3590,7 +3544,7 @@ rb_ary_sort_bang(VALUE ary)
ARY_SET_CAPA(ary, RARRAY_LEN(tmp));
}
else {
- assert(!ARY_SHARED_P(tmp));
+ RUBY_ASSERT(!ARY_SHARED_P(tmp));
if (ARY_EMBED_P(ary)) {
FL_UNSET_EMBED(ary);
}
@@ -3606,10 +3560,9 @@ rb_ary_sort_bang(VALUE ary)
ARY_SET_CAPA(ary, ARY_HEAP_LEN(tmp));
}
/* tmp was lost ownership for the ptr */
- FL_UNSET(tmp, FL_FREEZE);
FL_SET_EMBED(tmp);
ARY_SET_EMBED_LEN(tmp, 0);
- FL_SET(tmp, FL_FREEZE);
+ OBJ_FREEZE(tmp);
}
/* tmp will be GC'ed. */
RBASIC_SET_CLASS_RAW(tmp, rb_cArray); /* rb_cArray must be marked */
@@ -3620,21 +3573,18 @@ rb_ary_sort_bang(VALUE ary)
/*
* call-seq:
- * array.sort -> new_array
- * array.sort {|a, b| ... } -> new_array
+ * sort -> new_array
+ * sort {|a, b| ... } -> new_array
*
- * Returns a new \Array whose elements are those from +self+, sorted.
+ * Returns a new array containing the elements of +self+, sorted.
*
- * With no block, compares elements using operator <tt><=></tt>
- * (see Comparable):
+ * With no block given, compares elements using operator <tt>#<=></tt>
+ * (see Object#<=>):
*
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a1 = a.sort
- * a1 # => ["a", "b", "c", "d", "e"]
+ * [0, 2, 3, 1].sort # => [0, 1, 2, 3]
*
- * With a block, calls the block with each element pair;
- * for each element pair +a+ and +b+, the block should return an integer:
+ * With a block given, calls the block with each combination of pairs of elements from +self+;
+ * for each pair +a+ and +b+, the block should return a numeric:
*
* - Negative when +b+ is to follow +a+.
* - Zero when +a+ and +b+ are equivalent.
@@ -3642,22 +3592,17 @@ rb_ary_sort_bang(VALUE ary)
*
* Example:
*
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a1 = a.sort {|a, b| a <=> b }
- * a1 # => ["a", "b", "c", "d", "e"]
- * a2 = a.sort {|a, b| b <=> a }
- * a2 # => ["e", "d", "c", "b", "a"]
+ * a = [3, 2, 0, 1]
+ * a.sort {|a, b| a <=> b } # => [0, 1, 2, 3]
+ * a.sort {|a, b| b <=> a } # => [3, 2, 1, 0]
*
* When the block returns zero, the order for +a+ and +b+ is indeterminate,
- * and may be unstable:
+ * and may be unstable.
*
- * a = 'abcde'.split('').shuffle
- * a # => ["e", "b", "d", "a", "c"]
- * a1 = a.sort {|a, b| 0 }
- * a1 # => ["c", "e", "b", "d", "a"]
+ * See an example in Numeric#nonzero? for the idiom to sort more
+ * complex structure.
*
- * Related: Enumerable#sort_by.
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
VALUE
@@ -3672,12 +3617,15 @@ static VALUE rb_ary_bsearch_index(VALUE ary);
/*
* call-seq:
- * array.bsearch {|element| ... } -> object
- * array.bsearch -> new_enumerator
+ * bsearch {|element| ... } -> found_element or nil
+ * bsearch -> new_enumerator
*
- * Returns an element from +self+ selected by a binary search.
+ * Returns the element from +self+ found by a binary search,
+ * or +nil+ if the search found no suitable element.
*
- * See {Binary Searching}[rdoc-ref:bsearch.rdoc].
+ * See {Binary Searching}[rdoc-ref:language/bsearch.rdoc].
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -3693,11 +3641,15 @@ rb_ary_bsearch(VALUE ary)
/*
* call-seq:
- * array.bsearch_index {|element| ... } -> integer or nil
- * array.bsearch_index -> new_enumerator
+ * bsearch_index {|element| ... } -> integer or nil
+ * bsearch_index -> new_enumerator
+ *
+ * Returns the integer index of the element from +self+ found by a binary search,
+ * or +nil+ if the search found no suitable element.
+ *
+ * See {Binary Searching}[rdoc-ref:language/bsearch.rdoc].
*
- * Searches +self+ as described at method #bsearch,
- * but returns the _index_ of the found element instead of the element itself.
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -3727,8 +3679,8 @@ rb_ary_bsearch_index(VALUE ary)
const VALUE zero = INT2FIX(0);
switch (rb_cmpint(rb_funcallv(v, id_cmp, 1, &zero), v, zero)) {
case 0: return INT2FIX(mid);
- case 1: smaller = 1; break;
- case -1: smaller = 0;
+ case 1: smaller = 0; break;
+ case -1: smaller = 1;
}
}
else {
@@ -3756,28 +3708,24 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, dummy))
/*
* call-seq:
- * array.sort_by! {|element| ... } -> self
- * array.sort_by! -> new_enumerator
+ * sort_by! {|element| ... } -> self
+ * sort_by! -> new_enumerator
*
- * Sorts the elements of +self+ in place,
- * using an ordering determined by the block; returns self.
+ * With a block given, sorts the elements of +self+ in place;
+ * returns self.
*
* Calls the block with each successive element;
- * sorts elements based on the values returned from the block.
- *
- * For duplicates returned by the block, the ordering is indeterminate, and may be unstable.
- *
- * This example sorts strings based on their sizes:
+ * sorts elements based on the values returned from the block:
*
* a = ['aaaa', 'bbb', 'cc', 'd']
* a.sort_by! {|element| element.size }
* a # => ["d", "cc", "bbb", "aaaa"]
*
- * Returns a new \Enumerator if no block given:
+ * For duplicate values returned by the block, the ordering is indeterminate, and may be unstable.
*
- * a = ['aaaa', 'bbb', 'cc', 'd']
- * a.sort_by! # => #<Enumerator: ["aaaa", "bbb", "cc", "d"]:sort_by!>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -3787,29 +3735,32 @@ rb_ary_sort_by_bang(VALUE ary)
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
rb_ary_modify(ary);
- sorted = rb_block_call(ary, rb_intern("sort_by"), 0, 0, sort_by_i, 0);
- rb_ary_replace(ary, sorted);
+ if (RARRAY_LEN(ary) > 1) {
+ sorted = rb_block_call(ary, rb_intern("sort_by"), 0, 0, sort_by_i, 0);
+ rb_ary_replace(ary, sorted);
+ }
return ary;
}
/*
* call-seq:
- * array.map {|element| ... } -> new_array
- * array.map -> new_enumerator
+ * collect {|element| ... } -> new_array
+ * collect -> new_enumerator
+ * map {|element| ... } -> new_array
+ * map -> new_enumerator
*
- * Calls the block, if given, with each element of +self+;
- * returns a new \Array whose elements are the return values from the block:
+ * With a block given, calls the block with each element of +self+;
+ * returns a new array whose elements are the return values from the block:
*
* a = [:foo, 'bar', 2]
* a1 = a.map {|element| element.class }
* a1 # => [Symbol, String, Integer]
*
- * Returns a new \Enumerator if no block given:
- * a = [:foo, 'bar', 2]
- * a1 = a.map
- * a1 # => #<Enumerator: [:foo, "bar", 2]:map>
+ * With no block given, returns a new Enumerator.
*
+ * Related: #collect!;
+ * see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -3829,21 +3780,22 @@ rb_ary_collect(VALUE ary)
/*
* call-seq:
- * array.map! {|element| ... } -> self
- * array.map! -> new_enumerator
+ * collect! {|element| ... } -> self
+ * collect! -> new_enumerator
+ * map! {|element| ... } -> self
+ * map! -> new_enumerator
*
- * Calls the block, if given, with each element;
- * replaces the element with the block's return value:
+ * With a block given, calls the block with each element of +self+
+ * and replaces the element with the block's return value;
+ * returns +self+:
*
* a = [:foo, 'bar', 2]
* a.map! { |element| element.class } # => [Symbol, String, Integer]
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2]
- * a1 = a.map!
- * a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
+ * With no block given, returns a new Enumerator.
*
+ * Related: #collect;
+ * see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -3895,7 +3847,7 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
/* check if idx is Range */
else if (rb_range_beg_len(idx, &beg, &len, olen, 1)) {
if (len > 0) {
- const VALUE *const src = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *const src = RARRAY_CONST_PTR(ary);
const long end = beg + len;
const long prevlen = RARRAY_LEN(result);
if (beg < olen) {
@@ -3915,45 +3867,108 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
/*
* call-seq:
- * array.values_at(*indexes) -> new_array
+ * values_at(*specifiers) -> new_array
*
- * Returns a new \Array whose elements are the elements
- * of +self+ at the given \Integer or \Range +indexes+.
+ * Returns elements from +self+ in a new array; does not modify +self+.
*
- * For each positive +index+, returns the element at offset +index+:
+ * The objects included in the returned array are the elements of +self+
+ * selected by the given +specifiers+,
+ * each of which must be a numeric index or a Range.
*
- * a = [:foo, 'bar', 2]
- * a.values_at(0, 2) # => [:foo, 2]
- * a.values_at(0..1) # => [:foo, "bar"]
+ * In brief:
*
- * The given +indexes+ may be in any order, and may repeat:
+ * a = ['a', 'b', 'c', 'd']
*
- * a = [:foo, 'bar', 2]
- * a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2]
- * a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2]
+ * # Index specifiers.
+ * a.values_at(2, 0, 2, 0) # => ["c", "a", "c", "a"] # May repeat.
+ * a.values_at(-4, -3, -2, -1) # => ["a", "b", "c", "d"] # Counts backwards if negative.
+ * a.values_at(-50, 50) # => [nil, nil] # Outside of self.
*
- * Assigns +nil+ for an +index+ that is too large:
+ * # Range specifiers.
+ * a.values_at(1..3) # => ["b", "c", "d"] # From range.begin to range.end.
+ * a.values_at(1...3) # => ["b", "c"] # End excluded.
+ * a.values_at(3..1) # => [] # No such elements.
*
- * a = [:foo, 'bar', 2]
- * a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil]
+ * a.values_at(-3..3) # => ["b", "c", "d"] # Negative range.begin counts backwards.
+ * a.values_at(-50..3) # Raises RangeError.
*
- * Returns a new empty \Array if no arguments given.
+ * a.values_at(1..-2) # => ["b", "c"] # Negative range.end counts backwards.
+ * a.values_at(1..-50) # => [] # No such elements.
*
- * For each negative +index+, counts backward from the end of the array:
+ * # Mixture of specifiers.
+ * a.values_at(2..3, 3, 0..1, 0) # => ["c", "d", "d", "a", "b", "a"]
*
- * a = [:foo, 'bar', 2]
- * a.values_at(-1, -3) # => [2, :foo]
+ * With no +specifiers+ given, returns a new empty array:
*
- * Assigns +nil+ for an +index+ that is too small:
+ * a = ['a', 'b', 'c', 'd']
+ * a.values_at # => []
*
- * a = [:foo, 'bar', 2]
- * a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2]
+ * For each numeric specifier +index+, includes an element:
*
- * The given +indexes+ may have a mixture of signs:
+ * - For each non-negative numeric specifier +index+ that is in-range (less than <tt>self.size</tt>),
+ * includes the element at offset +index+:
*
- * a = [:foo, 'bar', 2]
- * a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2]
+ * a.values_at(0, 2) # => ["a", "c"]
+ * a.values_at(0.1, 2.9) # => ["a", "c"]
+ *
+ * - For each negative numeric +index+ that is in-range (greater than or equal to <tt>- self.size</tt>),
+ * counts backwards from the end of +self+:
+ *
+ * a.values_at(-1, -4) # => ["d", "a"]
+ *
+ * The given indexes may be in any order, and may repeat:
+ *
+ * a.values_at(2, 0, 1, 0, 2) # => ["c", "a", "b", "a", "c"]
+ *
+ * For each +index+ that is out-of-range, includes +nil+:
+ *
+ * a.values_at(4, -5) # => [nil, nil]
+ *
+ * For each Range specifier +range+, includes elements
+ * according to <tt>range.begin</tt> and <tt>range.end</tt>:
+ *
+ * - If both <tt>range.begin</tt> and <tt>range.end</tt>
+ * are non-negative and in-range (less than <tt>self.size</tt>),
+ * includes elements from index <tt>range.begin</tt>
+ * through <tt>range.end - 1</tt> (if <tt>range.exclude_end?</tt>),
+ * or through <tt>range.end</tt> (otherwise):
+ *
+ * a.values_at(1..2) # => ["b", "c"]
+ * a.values_at(1...2) # => ["b"]
+ *
+ * - If <tt>range.begin</tt> is negative and in-range (greater than or equal to <tt>- self.size</tt>),
+ * counts backwards from the end of +self+:
+ *
+ * a.values_at(-2..3) # => ["c", "d"]
+ *
+ * - If <tt>range.begin</tt> is negative and out-of-range, raises an exception:
+ *
+ * a.values_at(-5..3) # Raises RangeError.
+ *
+ * - If <tt>range.end</tt> is positive and out-of-range,
+ * extends the returned array with +nil+ elements:
+ *
+ * a.values_at(1..5) # => ["b", "c", "d", nil, nil]
+ *
+ * - If <tt>range.end</tt> is negative and in-range,
+ * counts backwards from the end of +self+:
+ *
+ * a.values_at(1..-2) # => ["b", "c"]
+ *
+ * - If <tt>range.end</tt> is negative and out-of-range,
+ * returns an empty array:
+ *
+ * a.values_at(1..-5) # => []
+ *
+ * The given ranges may be in any order and may repeat:
*
+ * a.values_at(2..3, 0..1, 2..3) # => ["c", "d", "a", "b", "c", "d"]
+ *
+ * The given specifiers may be any mixture of indexes and ranges:
+ *
+ * a.values_at(3, 1..2, 0, 2..3) # => ["d", "b", "c", "a", "c", "d"]
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -3971,22 +3986,22 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.select {|element| ... } -> new_array
- * array.select -> new_enumerator
+ * select {|element| ... } -> new_array
+ * select -> new_enumerator
+ * filter {|element| ... } -> new_array
+ * filter -> new_enumerator
*
- * Calls the block, if given, with each element of +self+;
- * returns a new \Array containing those elements of +self+
+ * With a block given, calls the block with each element of +self+;
+ * returns a new array containing those elements of +self+
* for which the block returns a truthy value:
*
* a = [:foo, 'bar', 2, :bam]
- * a1 = a.select {|element| element.to_s.start_with?('b') }
- * a1 # => ["bar", :bam]
+ * a.select {|element| element.to_s.start_with?('b') }
+ * # => ["bar", :bam]
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2, :bam]
- * a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -4041,7 +4056,7 @@ select_bang_ensure(VALUE a)
rb_ary_modify(ary);
if (i1 < len) {
tail = len - i1;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + i2, ptr + i1, VALUE, tail);
});
}
@@ -4052,10 +4067,12 @@ select_bang_ensure(VALUE a)
/*
* call-seq:
- * array.select! {|element| ... } -> self or nil
- * array.select! -> new_enumerator
+ * select! {|element| ... } -> self or nil
+ * select! -> new_enumerator
+ * filter! {|element| ... } -> self or nil
+ * filter! -> new_enumerator
*
- * Calls the block, if given with each element of +self+;
+ * With a block given, calls the block with each element of +self+;
* removes from +self+ those elements for which the block returns +false+ or +nil+.
*
* Returns +self+ if any elements were removed:
@@ -4065,11 +4082,9 @@ select_bang_ensure(VALUE a)
*
* Returns +nil+ if no elements were removed.
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2, :bam]
- * a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -4087,20 +4102,18 @@ rb_ary_select_bang(VALUE ary)
/*
* call-seq:
- * array.keep_if {|element| ... } -> self
- * array.keep_if -> new_enumeration
+ * keep_if {|element| ... } -> self
+ * keep_if -> new_enumerator
*
- * Retains those elements for which the block returns a truthy value;
- * deletes all other elements; returns +self+:
+ * With a block given, calls the block with each element of +self+;
+ * removes the element from +self+ if the block does not return a truthy value:
*
* a = [:foo, 'bar', 2, :bam]
* a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam]
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2, :bam]
- * a.keep_if # => #<Enumerator: [:foo, "bar", 2, :bam]:keep_if>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -4126,38 +4139,39 @@ ary_resize_smaller(VALUE ary, long len)
/*
* call-seq:
- * array.delete(obj) -> deleted_object
- * array.delete(obj) {|nosuch| ... } -> deleted_object or block_return
+ * delete(object) -> last_removed_object
+ * delete(object) {|element| ... } -> last_removed_object or block_return
*
* Removes zero or more elements from +self+.
*
- * When no block is given,
- * removes from +self+ each element +ele+ such that <tt>ele == obj</tt>;
- * returns the last deleted element:
+ * With no block given,
+ * removes from +self+ each element +ele+ such that <tt>ele == object</tt>;
+ * returns the last removed element:
*
- * s1 = 'bar'; s2 = 'bar'
- * a = [:foo, s1, 2, s2]
- * a.delete('bar') # => "bar"
- * a # => [:foo, 2]
+ * a = [0, 1, 2, 2.0]
+ * a.delete(2) # => 2.0
+ * a # => [0, 1]
*
- * Returns +nil+ if no elements removed.
+ * Returns +nil+ if no elements removed:
+ *
+ * a.delete(2) # => nil
*
- * When a block is given,
- * removes from +self+ each element +ele+ such that <tt>ele == obj</tt>.
+ * With a block given,
+ * removes from +self+ each element +ele+ such that <tt>ele == object</tt>.
*
* If any such elements are found, ignores the block
- * and returns the last deleted element:
+ * and returns the last removed element:
*
- * s1 = 'bar'; s2 = 'bar'
- * a = [:foo, s1, 2, s2]
- * deleted_obj = a.delete('bar') {|obj| fail 'Cannot happen' }
- * a # => [:foo, 2]
+ * a = [0, 1, 2, 2.0]
+ * a.delete(2) {|element| fail 'Cannot happen' } # => 2.0
+ * a # => [0, 1]
*
- * If no such elements are found, returns the block's return value:
+ * If no such element is found, returns the block's return value:
*
- * a = [:foo, 'bar', 2]
- * a.delete(:nosuch) {|obj| "#{obj} not found" } # => "nosuch not found"
+ * a.delete(2) {|element| "Element #{element} not found." }
+ * # => "Element 2 not found."
*
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
VALUE
@@ -4228,7 +4242,7 @@ rb_ary_delete_at(VALUE ary, long pos)
rb_ary_modify(ary);
del = RARRAY_AREF(ary, pos);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr+pos, ptr+pos+1, VALUE, len-pos-1);
});
ARY_INCREASE_LEN(ary, -1);
@@ -4238,9 +4252,10 @@ rb_ary_delete_at(VALUE ary, long pos)
/*
* call-seq:
- * array.delete_at(index) -> deleted_object or nil
+ * delete_at(index) -> removed_object or nil
*
- * Deletes an element from +self+, per the given \Integer +index+.
+ * Removes the element of +self+ at the given +index+, which must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
*
* When +index+ is non-negative, deletes the element at offset +index+:
*
@@ -4248,15 +4263,19 @@ rb_ary_delete_at(VALUE ary, long pos)
* a.delete_at(1) # => "bar"
* a # => [:foo, 2]
*
- * If index is too large, returns +nil+.
- *
* When +index+ is negative, counts backward from the end of the array:
*
* a = [:foo, 'bar', 2]
* a.delete_at(-2) # => "bar"
* a # => [:foo, 2]
*
- * If +index+ is too small (far from zero), returns nil.
+ * When +index+ is out of range, returns +nil+.
+ *
+ * a = [:foo, 'bar', 2]
+ * a.delete_at(3) # => nil
+ * a.delete_at(-4) # => nil
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -4289,7 +4308,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len)
return rb_ary_new2(0);
}
else {
- VALUE arg2 = rb_ary_new4(len, RARRAY_CONST_PTR_TRANSIENT(ary)+pos);
+ VALUE arg2 = rb_ary_new4(len, RARRAY_CONST_PTR(ary)+pos);
rb_ary_splice(ary, pos, len, 0, 0);
return arg2;
}
@@ -4297,71 +4316,94 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len)
/*
* call-seq:
- * array.slice!(n) -> object or nil
- * array.slice!(start, length) -> new_array or nil
- * array.slice!(range) -> new_array or nil
+ * slice!(index) -> object or nil
+ * slice!(start, length) -> new_array or nil
+ * slice!(range) -> new_array or nil
*
* Removes and returns elements from +self+.
*
- * When the only argument is an \Integer +n+,
- * removes and returns the _nth_ element in +self+:
+ * With numeric argument +index+ given,
+ * removes and returns the element at offset +index+:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(1) # => "bar"
- * a # => [:foo, 2]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(2) # => "c"
+ * a # => ["a", "b", "d"]
+ * a.slice!(2.1) # => "d"
+ * a # => ["a", "b"]
*
- * If +n+ is negative, counts backwards from the end of +self+:
+ * If +index+ is negative, counts backwards from the end of +self+:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(-1) # => 2
- * a # => [:foo, "bar"]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(-2) # => "c"
+ * a # => ["a", "b", "d"]
*
- * If +n+ is out of range, returns +nil+.
+ * If +index+ is out of range, returns +nil+.
*
- * When the only arguments are Integers +start+ and +length+,
- * removes +length+ elements from +self+ beginning at offset +start+;
- * returns the deleted objects in a new \Array:
+ * With numeric arguments +start+ and +length+ given,
+ * removes +length+ elements from +self+ beginning at zero-based offset +start+;
+ * returns the removed objects in a new array:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(0, 2) # => [:foo, "bar"]
- * a # => [2]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(1, 2) # => ["b", "c"]
+ * a # => ["a", "d"]
+ * a.slice!(0.1, 1.1) # => ["a"]
+ * a # => ["d"]
+ *
+ * If +start+ is negative, counts backwards from the end of +self+:
+ *
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(-2, 1) # => ["c"]
+ * a # => ["a", "b", "d"]
+ *
+ * If +start+ is out-of-range, returns +nil+:
+ *
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(5, 1) # => nil
+ * a.slice!(-5, 1) # => nil
*
* If <tt>start + length</tt> exceeds the array size,
* removes and returns all elements from offset +start+ to the end:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(1, 50) # => ["bar", 2]
- * a # => [:foo]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(2, 50) # => ["c", "d"]
+ * a # => ["a", "b"]
*
* If <tt>start == a.size</tt> and +length+ is non-negative,
- * returns a new empty \Array.
+ * returns a new empty array.
*
* If +length+ is negative, returns +nil+.
*
- * When the only argument is a \Range object +range+,
- * treats <tt>range.min</tt> as +start+ above and <tt>range.size</tt> as +length+ above:
+ * With Range argument +range+ given,
+ * treats <tt>range.min</tt> as +start+ (as above)
+ * and <tt>range.size</tt> as +length+ (as above):
*
- * a = [:foo, 'bar', 2]
- * a.slice!(1..2) # => ["bar", 2]
- * a # => [:foo]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(1..2) # => ["b", "c"]
+ * a # => ["a", "d"]
*
- * If <tt>range.start == a.size</tt>, returns a new empty \Array.
+ * If <tt>range.start == a.size</tt>, returns a new empty array:
*
- * If <tt>range.start</tt> is larger than the array size, returns +nil+.
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(4..5) # => []
*
- * If <tt>range.end</tt> is negative, counts backwards from the end of the array:
+ * If <tt>range.start</tt> is larger than the array size, returns +nil+:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(0..-2) # => [:foo, "bar"]
- * a # => [2]
+ * a = ['a', 'b', 'c', 'd']
+ a.slice!(5..6) # => nil
*
* If <tt>range.start</tt> is negative,
- * calculates the start index backwards from the end of the array:
+ * calculates the start index by counting backwards from the end of +self+:
*
- * a = [:foo, 'bar', 2]
- * a.slice!(-2..2) # => ["bar", 2]
- * a # => [:foo]
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(-2..2) # => ["c"]
*
+ * If <tt>range.end</tt> is negative,
+ * calculates the end index by counting backwards from the end of +self+:
+ *
+ * a = ['a', 'b', 'c', 'd']
+ * a.slice!(0..-2) # => ["a", "b", "c"]
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -4442,10 +4484,11 @@ ary_reject_bang(VALUE ary)
/*
* call-seq:
- * array.reject! {|element| ... } -> self or nil
- * array.reject! -> new_enumerator
+ * reject! {|element| ... } -> self or nil
+ * reject! -> new_enumerator
*
- * Removes each element for which the block returns a truthy value.
+ * With a block given, calls the block with each element of +self+;
+ * removes each element for which the block returns a truthy value.
*
* Returns +self+ if any elements removed:
*
@@ -4454,11 +4497,9 @@ ary_reject_bang(VALUE ary)
*
* Returns +nil+ if no elements removed.
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2]
- * a.reject! # => #<Enumerator: [:foo, "bar", 2]:reject!>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -4471,21 +4512,19 @@ rb_ary_reject_bang(VALUE ary)
/*
* call-seq:
- * array.reject {|element| ... } -> new_array
- * array.reject -> new_enumerator
+ * reject {|element| ... } -> new_array
+ * reject -> new_enumerator
*
- * Returns a new \Array whose elements are all those from +self+
+ * With a block given, returns a new array whose elements are all those from +self+
* for which the block returns +false+ or +nil+:
*
* a = [:foo, 'bar', 2, 'bat']
* a1 = a.reject {|element| element.to_s.start_with?('b') }
* a1 # => [:foo, 2]
*
- * Returns a new \Enumerator if no block given:
- *
- * a = [:foo, 'bar', 2]
- * a.reject # => #<Enumerator: [:foo, "bar", 2]:reject>
+ * With no block given, returns a new Enumerator.
*
+ * Related: {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -4501,21 +4540,20 @@ rb_ary_reject(VALUE ary)
/*
* call-seq:
- * array.delete_if {|element| ... } -> self
- * array.delete_if -> Enumerator
+ * delete_if {|element| ... } -> self
+ * delete_if -> new_numerator
*
- * Removes each element in +self+ for which the block returns a truthy value;
+ * With a block given, calls the block with each element of +self+;
+ * removes the element if the block returns a truthy value;
* returns +self+:
*
* a = [:foo, 'bar', 2, 'bat']
* a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
*
- * Returns a new \Enumerator if no block given:
+ * With no block given, returns a new Enumerator.
*
- * a = [:foo, 'bar', 2]
- * a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
- *
-3 */
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
+ */
static VALUE
rb_ary_delete_if(VALUE ary)
@@ -4555,58 +4593,95 @@ take_items(VALUE obj, long n)
/*
* call-seq:
- * array.zip(*other_arrays) -> new_array
- * array.zip(*other_arrays) {|other_array| ... } -> nil
+ * zip(*other_arrays) -> new_array
+ * zip(*other_arrays) {|sub_array| ... } -> nil
+ *
+ * With no block given, combines +self+ with the collection of +other_arrays+;
+ * returns a new array of sub-arrays:
*
- * When no block given, returns a new \Array +new_array+ of size <tt>self.size</tt>
- * whose elements are Arrays.
+ * [0, 1].zip(['zero', 'one'], [:zero, :one])
+ * # => [[0, "zero", :zero], [1, "one", :one]]
*
- * Each nested array <tt>new_array[n]</tt> is of size <tt>other_arrays.size+1</tt>,
- * and contains:
+ * Returned:
*
- * - The _nth_ element of +self+.
- * - The _nth_ element of each of the +other_arrays+.
+ * - The outer array is of size <tt>self.size</tt>.
+ * - Each sub-array is of size <tt>other_arrays.size + 1</tt>.
+ * - The _nth_ sub-array contains (in order):
*
- * If all +other_arrays+ and +self+ are the same size:
+ * - The _nth_ element of +self+.
+ * - The _nth_ element of each of the other arrays, as available.
+ *
+ * Example:
+ *
+ * a = [0, 1]
+ * zipped = a.zip(['zero', 'one'], [:zero, :one])
+ * # => [[0, "zero", :zero], [1, "one", :one]]
+ * zipped.size # => 2 # Same size as a.
+ * zipped.first.size # => 3 # Size of other arrays plus 1.
+ *
+ * When the other arrays are all the same size as +self+,
+ * the returned sub-arrays are a rearrangement containing exactly elements of all the arrays
+ * (including +self+), with no omissions or additions:
*
* a = [:a0, :a1, :a2, :a3]
* b = [:b0, :b1, :b2, :b3]
* c = [:c0, :c1, :c2, :c3]
* d = a.zip(b, c)
- * d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]]
+ * pp d
+ * # =>
+ * [[:a0, :b0, :c0],
+ * [:a1, :b1, :c1],
+ * [:a2, :b2, :c2],
+ * [:a3, :b3, :c3]]
*
- * If any array in +other_arrays+ is smaller than +self+,
- * fills to <tt>self.size</tt> with +nil+:
+ * When one of the other arrays is smaller than +self+,
+ * pads the corresponding sub-array with +nil+ elements:
*
* a = [:a0, :a1, :a2, :a3]
* b = [:b0, :b1, :b2]
* c = [:c0, :c1]
* d = a.zip(b, c)
- * d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]]
+ * pp d
+ * # =>
+ * [[:a0, :b0, :c0],
+ * [:a1, :b1, :c1],
+ * [:a2, :b2, nil],
+ * [:a3, nil, nil]]
*
- * If any array in +other_arrays+ is larger than +self+,
- * its trailing elements are ignored:
+ * When one of the other arrays is larger than +self+,
+ * _ignores_ its trailing elements:
*
* a = [:a0, :a1, :a2, :a3]
* b = [:b0, :b1, :b2, :b3, :b4]
* c = [:c0, :c1, :c2, :c3, :c4, :c5]
* d = a.zip(b, c)
- * d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]]
+ * pp d
+ * # =>
+ * [[:a0, :b0, :c0],
+ * [:a1, :b1, :c1],
+ * [:a2, :b2, :c2],
+ * [:a3, :b3, :c3]]
*
- * When a block is given, calls the block with each of the sub-arrays (formed as above); returns +nil+:
+ * With a block given, calls the block with each of the other arrays;
+ * returns +nil+:
*
+ * d = []
* a = [:a0, :a1, :a2, :a3]
* b = [:b0, :b1, :b2, :b3]
* c = [:c0, :c1, :c2, :c3]
- * a.zip(b, c) {|sub_array| p sub_array} # => nil
- *
- * Output:
- *
- * [:a0, :b0, :c0]
- * [:a1, :b1, :c1]
- * [:a2, :b2, :c2]
- * [:a3, :b3, :c3]
- *
+ * a.zip(b, c) {|sub_array| d.push(sub_array.reverse) } # => nil
+ * pp d
+ * # =>
+ * [[:c0, :b0, :a0],
+ * [:c1, :b1, :a1],
+ * [:c2, :b2, :a2],
+ * [:c3, :b3, :a3]]
+ *
+ * For an *object* in *other_arrays* that is not actually an array,
+ * forms the "other array" as <tt>object.to_ary</tt>, if defined,
+ * or as <tt>object.each.to_a</tt> otherwise.
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -4669,14 +4744,17 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.transpose -> new_array
+ * transpose -> new_array
*
- * Transposes the rows and columns in an \Array of Arrays;
- * the nested Arrays must all be the same size:
+ * Returns a new array that is +self+
+ * as a {transposed matrix}[https://en.wikipedia.org/wiki/Transpose]:
*
* a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]]
* a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]]
*
+ * The elements of +self+ must all be the same size.
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -4709,13 +4787,17 @@ rb_ary_transpose(VALUE ary)
/*
* call-seq:
- * array.replace(other_array) -> self
+ * initialize_copy(other_array) -> self
+ * replace(other_array) -> self
*
- * Replaces the content of +self+ with the content of +other_array+; returns +self+:
+ * Replaces the elements of +self+ with the elements of +other_array+, which must be an
+ * {array-convertible object}[rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects];
+ * returns +self+:
*
- * a = [:foo, 'bar', 2]
- * a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3]
+ * a = ['a', 'b', 'c'] # => ["a", "b", "c"]
+ * a.replace(['d', 'e']) # => ["d", "e"]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
VALUE
@@ -4729,16 +4811,15 @@ rb_ary_replace(VALUE copy, VALUE orig)
/* orig has enough space to embed the contents of orig. */
if (RARRAY_LEN(orig) <= ary_embed_capa(copy)) {
- assert(ARY_EMBED_P(copy));
- ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig));
+ RUBY_ASSERT(ARY_EMBED_P(copy));
+ ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR(orig));
ARY_SET_EMBED_LEN(copy, RARRAY_LEN(orig));
}
-#if USE_RVARGC
/* orig is embedded but copy does not have enough space to embed the
* contents of orig. */
else if (ARY_EMBED_P(orig)) {
long len = ARY_EMBED_LEN(orig);
- VALUE *ptr = ary_heap_alloc(copy, len);
+ VALUE *ptr = ary_heap_alloc_buffer(len);
FL_UNSET_EMBED(copy);
ARY_SET_PTR(copy, ptr);
@@ -4747,9 +4828,8 @@ rb_ary_replace(VALUE copy, VALUE orig)
// No allocation and exception expected that could leave `copy` in a
// bad state from the edits above.
- ary_memcpy(copy, 0, len, RARRAY_CONST_PTR_TRANSIENT(orig));
+ ary_memcpy(copy, 0, len, RARRAY_CONST_PTR(orig));
}
-#endif
/* Otherwise, orig is on heap and copy does not have enough space to embed
* the contents of orig. */
else {
@@ -4758,6 +4838,8 @@ rb_ary_replace(VALUE copy, VALUE orig)
ARY_SET_PTR(copy, ARY_HEAP_PTR(orig));
ARY_SET_LEN(copy, ARY_HEAP_LEN(orig));
rb_ary_set_shared(copy, shared_root);
+
+ RUBY_ASSERT(RB_OBJ_SHAREABLE_P(copy) ? RB_OBJ_SHAREABLE_P(shared_root) : 1);
}
ary_verify(copy);
return copy;
@@ -4765,13 +4847,14 @@ rb_ary_replace(VALUE copy, VALUE orig)
/*
* call-seq:
- * array.clear -> self
+ * clear -> self
*
- * Removes all elements from +self+:
+ * Removes all elements from +self+; returns +self+:
*
* a = [:foo, 'bar', 2]
* a.clear # => []
*
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
VALUE
@@ -4779,11 +4862,9 @@ rb_ary_clear(VALUE ary)
{
rb_ary_modify_check(ary);
if (ARY_SHARED_P(ary)) {
- if (!ARY_EMBED_P(ary)) {
- rb_ary_unshare(ary);
- FL_SET_EMBED(ary);
- ARY_SET_EMBED_LEN(ary, 0);
- }
+ rb_ary_unshare(ary);
+ FL_SET_EMBED(ary);
+ ARY_SET_EMBED_LEN(ary, 0);
}
else {
ARY_SET_LEN(ary, 0);
@@ -4797,198 +4878,182 @@ rb_ary_clear(VALUE ary)
/*
* call-seq:
- * array.fill(obj) -> self
- * array.fill(obj, start) -> self
- * array.fill(obj, start, length) -> self
- * array.fill(obj, range) -> self
- * array.fill {|index| ... } -> self
- * array.fill(start) {|index| ... } -> self
- * array.fill(start, length) {|index| ... } -> self
- * array.fill(range) {|index| ... } -> self
+ * fill(object, start = nil, count = nil) -> self
+ * fill(object, range) -> self
+ * fill(start = nil, count = nil) {|element| ... } -> self
+ * fill(range) {|element| ... } -> self
*
- * Replaces specified elements in +self+ with specified objects; returns +self+.
+ * Replaces selected elements in +self+;
+ * may add elements to +self+;
+ * always returns +self+ (never a new array).
*
- * With argument +obj+ and no block given, replaces all elements with that one object:
+ * In brief:
*
- * a = ['a', 'b', 'c', 'd']
- * a # => ["a", "b", "c", "d"]
- * a.fill(:X) # => [:X, :X, :X, :X]
+ * # Non-negative start.
+ * ['a', 'b', 'c', 'd'].fill('-', 1, 2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1, 2) {|e| e.to_s } # => ["a", "1", "2", "d"]
*
- * With arguments +obj+ and \Integer +start+, and no block given,
- * replaces elements based on the given start.
+ * # Extends with specified values if necessary.
+ * ['a', 'b', 'c', 'd'].fill('-', 3, 2) # => ["a", "b", "c", "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill(3, 2) {|e| e.to_s } # => ["a", "b", "c", "3", "4"]
*
- * If +start+ is in range (<tt>0 <= start < array.size</tt>),
- * replaces all elements from offset +start+ through the end:
+ * # Fills with nils if necessary.
+ * ['a', 'b', 'c', 'd'].fill('-', 6, 2) # => ["a", "b", "c", "d", nil, nil, "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill(6, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, nil, "6", "7"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 2) # => ["a", "b", :X, :X]
+ * # For negative start, counts backwards from the end.
+ * ['a', 'b', 'c', 'd'].fill('-', -3, 3) # => ["a", "-", "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill(-3, 3) {|e| e.to_s } # => ["a", "1", "2", "3"]
*
- * If +start+ is too large (<tt>start >= array.size</tt>), does nothing:
+ * # Range.
+ * ['a', 'b', 'c', 'd'].fill('-', 1..2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1..2) {|e| e.to_s } # => ["a", "1", "2", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 4) # => ["a", "b", "c", "d"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 5) # => ["a", "b", "c", "d"]
+ * When arguments +start+ and +count+ are given,
+ * they select the elements of +self+ to be replaced;
+ * each must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]
+ * (or +nil+):
*
- * If +start+ is negative, counts from the end (starting index is <tt>start + array.size</tt>):
+ * - +start+ specifies the zero-based offset of the first element to be replaced;
+ * +nil+ means zero.
+ * - +count+ is the number of consecutive elements to be replaced;
+ * +nil+ means "all the rest."
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, -2) # => ["a", "b", :X, :X]
+ * With argument +object+ given,
+ * that one object is used for all replacements:
*
- * If +start+ is too small (less than and far from zero), replaces all elements:
+ * o = Object.new # => #<Object:0x0000014e7bff7600>
+ * a = ['a', 'b', 'c', 'd'] # => ["a", "b", "c", "d"]
+ * a.fill(o, 1, 2)
+ * # => ["a", #<Object:0x0000014e7bff7600>, #<Object:0x0000014e7bff7600>, "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, -6) # => [:X, :X, :X, :X]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, -50) # => [:X, :X, :X, :X]
+ * With a block given, the block is called once for each element to be replaced;
+ * the value passed to the block is the _index_ of the element to be replaced
+ * (not the element itself);
+ * the block's return value replaces the element:
*
- * With arguments +obj+, \Integer +start+, and \Integer +length+, and no block given,
- * replaces elements based on the given +start+ and +length+.
+ * a = ['a', 'b', 'c', 'd'] # => ["a", "b", "c", "d"]
+ * a.fill(1, 2) {|element| element.to_s } # => ["a", "1", "2", "d"]
*
- * If +start+ is in range, replaces +length+ elements beginning at offset +start+:
+ * For arguments +start+ and +count+:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 1, 1) # => ["a", :X, "c", "d"]
+ * - If +start+ is non-negative,
+ * replaces +count+ elements beginning at offset +start+:
*
- * If +start+ is negative, counts from the end:
+ * ['a', 'b', 'c', 'd'].fill('-', 0, 2) # => ["-", "-", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1, 2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 2, 2) # => ["a", "b", "-", "-"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, -2, 1) # => ["a", "b", :X, "d"]
+ * ['a', 'b', 'c', 'd'].fill(0, 2) {|e| e.to_s } # => ["0", "1", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1, 2) {|e| e.to_s } # => ["a", "1", "2", "d"]
+ * ['a', 'b', 'c', 'd'].fill(2, 2) {|e| e.to_s } # => ["a", "b", "2", "3"]
*
- * If +start+ is large (<tt>start >= array.size</tt>), extends +self+ with +nil+:
+ * Extends +self+ if necessary:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 5, 2) # => ["a", "b", "c", "d", nil, :X, :X]
+ * ['a', 'b', 'c', 'd'].fill('-', 3, 2) # => ["a", "b", "c", "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill('-', 4, 2) # => ["a", "b", "c", "d", "-", "-"]
*
- * If +length+ is zero or negative, replaces no elements:
+ * ['a', 'b', 'c', 'd'].fill(3, 2) {|e| e.to_s } # => ["a", "b", "c", "3", "4"]
+ * ['a', 'b', 'c', 'd'].fill(4, 2) {|e| e.to_s } # => ["a", "b", "c", "d", "4", "5"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, 1, 0) # => ["a", "b", "c", "d"]
- * a.fill(:X, 1, -1) # => ["a", "b", "c", "d"]
+ * Fills with +nil+ if necessary:
*
- * With arguments +obj+ and \Range +range+, and no block given,
- * replaces elements based on the given range.
+ * ['a', 'b', 'c', 'd'].fill('-', 5, 2) # => ["a", "b", "c", "d", nil, "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill('-', 6, 2) # => ["a", "b", "c", "d", nil, nil, "-", "-"]
*
- * If the range is positive and ascending (<tt>0 < range.begin <= range.end</tt>),
- * replaces elements from <tt>range.begin</tt> to <tt>range.end</tt>:
+ * ['a', 'b', 'c', 'd'].fill(5, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, "5", "6"]
+ * ['a', 'b', 'c', 'd'].fill(6, 2) {|e| e.to_s } # => ["a", "b", "c", "d", nil, nil, "6", "7"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (1..1)) # => ["a", :X, "c", "d"]
+ * Does nothing if +count+ is non-positive:
*
- * If <tt>range.first</tt> is negative, replaces no elements:
+ * ['a', 'b', 'c', 'd'].fill('-', 2, 0) # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 2, -100) # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 6, -100) # => ["a", "b", "c", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (-1..1)) # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(2, 0) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(2, -100) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(6, -100) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
*
- * If <tt>range.last</tt> is negative, counts from the end:
+ * - If +start+ is negative, counts backwards from the end of +self+:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (0..-2)) # => [:X, :X, :X, "d"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (1..-2)) # => ["a", :X, :X, "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -4, 3) # => ["-", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -3, 3) # => ["a", "-", "-", "-"]
*
- * If <tt>range.last</tt> and <tt>range.last</tt> are both negative,
- * both count from the end of the array:
+ * ['a', 'b', 'c', 'd'].fill(-4, 3) {|e| e.to_s } # => ["0", "1", "2", "d"]
+ * ['a', 'b', 'c', 'd'].fill(-3, 3) {|e| e.to_s } # => ["a", "1", "2", "3"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (-1..-1)) # => ["a", "b", "c", :X]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(:X, (-2..-2)) # => ["a", "b", :X, "d"]
+ * Extends +self+ if necessary:
*
- * With no arguments and a block given, calls the block with each index;
- * replaces the corresponding element with the block's return value:
+ * ['a', 'b', 'c', 'd'].fill('-', -2, 3) # => ["a", "b", "-", "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill('-', -1, 3) # => ["a", "b", "c", "-", "-", "-"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"]
+ * ['a', 'b', 'c', 'd'].fill(-2, 3) {|e| e.to_s } # => ["a", "b", "2", "3", "4"]
+ * ['a', 'b', 'c', 'd'].fill(-1, 3) {|e| e.to_s } # => ["a", "b", "c", "3", "4", "5"]
*
- * With argument +start+ and a block given, calls the block with each index
- * from offset +start+ to the end; replaces the corresponding element
- * with the block's return value.
+ * Starts at the beginning of +self+ if +start+ is negative and out-of-range:
*
- * If start is in range (<tt>0 <= start < array.size</tt>),
- * replaces from offset +start+ to the end:
+ * ['a', 'b', 'c', 'd'].fill('-', -5, 2) # => ["-", "-", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -6, 2) # => ["-", "-", "c", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"]
+ * ['a', 'b', 'c', 'd'].fill(-5, 2) {|e| e.to_s } # => ["0", "1", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(-6, 2) {|e| e.to_s } # => ["0", "1", "c", "d"]
*
- * If +start+ is too large(<tt>start >= array.size</tt>), does nothing:
+ * Does nothing if +count+ is non-positive:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -2, 0) # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -2, -1) # => ["a", "b", "c", "d"]
*
- * If +start+ is negative, counts from the end:
+ * ['a', 'b', 'c', 'd'].fill(-2, 0) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(-2, -1) {|e| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"]
+ * When argument +range+ is given,
+ * it must be a Range object whose members are numeric;
+ * its +begin+ and +end+ values determine the elements of +self+
+ * to be replaced:
*
- * If start is too small (<tt>start <= -array.size</tt>, replaces all elements:
+ * - If both +begin+ and +end+ are positive, they specify the first and last elements
+ * to be replaced:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-50) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1..2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1..2) {|e| e.to_s } # => ["a", "1", "2", "d"]
*
- * With arguments +start+ and +length+, and a block given,
- * calls the block for each index specified by start length;
- * replaces the corresponding element with the block's return value.
+ * If +end+ is smaller than +begin+, replaces no elements:
*
- * If +start+ is in range, replaces +length+ elements beginning at offset +start+:
+ * ['a', 'b', 'c', 'd'].fill('-', 2..1) # => ["a", "b", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(2..1) {|e| e.to_s } # => ["a", "b", "c", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(1, 1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"]
+ * - If either is negative (or both are negative), counts backwards from the end of +self+:
*
- * If start is negative, counts from the end:
+ * ['a', 'b', 'c', 'd'].fill('-', -3..2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1..-2) # => ["a", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', -3..-2) # => ["a", "-", "-", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"]
+ * ['a', 'b', 'c', 'd'].fill(-3..2) {|e| e.to_s } # => ["a", "1", "2", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1..-2) {|e| e.to_s } # => ["a", "1", "2", "d"]
+ * ['a', 'b', 'c', 'd'].fill(-3..-2) {|e| e.to_s } # => ["a", "1", "2", "d"]
*
- * If +start+ is large (<tt>start >= array.size</tt>), extends +self+ with +nil+:
+ * - If the +end+ value is excluded (see Range#exclude_end?), omits the last replacement:
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(5, 2) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil, "new_5", "new_6"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1...2) # => ["a", "-", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1...-2) # => ["a", "-", "c", "d"]
*
- * If +length+ is zero or less, replaces no elements:
+ * ['a', 'b', 'c', 'd'].fill(1...2) {|e| e.to_s } # => ["a", "1", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill(1...-2) {|e| e.to_s } # => ["a", "1", "c", "d"]
*
- * a = ['a', 'b', 'c', 'd']
- * a.fill(1, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d"]
- * a.fill(1, -1) { |index| "new_#{index}" } # => ["a", "b", "c", "d"]
+ * - If the range is endless (see {Endless Ranges}[rdoc-ref:Range@Endless+Ranges]),
+ * replaces elements to the end of +self+:
*
- * With arguments +obj+ and +range+, and a block given,
- * calls the block with each index in the given range;
- * replaces the corresponding element with the block's return value.
- *
- * If the range is positive and ascending (<tt>range 0 < range.begin <= range.end</tt>,
- * replaces elements from <tt>range.begin</tt> to <tt>range.end</tt>:
- *
- * a = ['a', 'b', 'c', 'd']
- * a.fill(1..1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', 1..) # => ["a", "-", "-", "-"]
+ * ['a', 'b', 'c', 'd'].fill(1..) {|e| e.to_s } # => ["a", "1", "2", "3"]
*
- * If +range.first+ is negative, does nothing:
- *
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-1..1) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"]
- *
- * If <tt>range.last</tt> is negative, counts from the end:
- *
- * a = ['a', 'b', 'c', 'd']
- * a.fill(0..-2) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "d"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(1..-2) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "d"]
+ * - If the range is beginless (see {Beginless Ranges}[rdoc-ref:Range@Beginless+Ranges]),
+ * replaces elements from the beginning of +self+:
*
- * If <tt>range.first</tt> and <tt>range.last</tt> are both negative,
- * both count from the end:
- *
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-1..-1) { |index| "new_#{index}" } # => ["a", "b", "c", "new_3"]
- * a = ['a', 'b', 'c', 'd']
- * a.fill(-2..-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"]
+ * ['a', 'b', 'c', 'd'].fill('-', ..2) # => ["-", "-", "-", "d"]
+ * ['a', 'b', 'c', 'd'].fill(..2) {|e| e.to_s } # => ["0", "1", "2", "d"]
*
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -5057,15 +5122,15 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array + other_array -> new_array
+ * self + other_array -> new_array
*
- * Returns a new \Array containing all elements of +array+
+ * Returns a new array containing all elements of +self+
* followed by all elements of +other_array+:
*
* a = [0, 1] + [2, 3]
* a # => [0, 1, 2, 3]
*
- * Related: #concat.
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
VALUE
@@ -5080,8 +5145,8 @@ rb_ary_plus(VALUE x, VALUE y)
len = xlen + ylen;
z = rb_ary_new2(len);
- ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR_TRANSIENT(x));
- ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR_TRANSIENT(y));
+ ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR(x));
+ ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR(y));
ARY_SET_LEN(z, len);
return z;
}
@@ -5091,7 +5156,7 @@ ary_append(VALUE x, VALUE y)
{
long n = RARRAY_LEN(y);
if (n > 0) {
- rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR_TRANSIENT(y), n);
+ rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR(y), n);
}
RB_GC_GUARD(y);
return x;
@@ -5099,12 +5164,15 @@ ary_append(VALUE x, VALUE y)
/*
* call-seq:
- * array.concat(*other_arrays) -> self
+ * concat(*other_arrays) -> self
*
- * Adds to +array+ all elements from each \Array in +other_arrays+; returns +self+:
+ * Adds to +self+ all elements from each array in +other_arrays+; returns +self+:
*
* a = [0, 1]
- * a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5]
+ * a.concat(['two', 'three'], [:four, :five], a)
+ * # => [0, 1, "two", "three", :four, :five, 0, 1]
+ *
+ * Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -5136,19 +5204,19 @@ rb_ary_concat(VALUE x, VALUE y)
/*
* call-seq:
- * array * n -> new_array
- * array * string_separator -> new_string
+ * self * n -> new_array
+ * self * string_separator -> new_string
*
- * When non-negative argument \Integer +n+ is given,
- * returns a new \Array built by concatenating the +n+ copies of +self+:
+ * When non-negative integer argument +n+ is given,
+ * returns a new array built by concatenating +n+ copies of +self+:
*
* a = ['x', 'y']
* a * 3 # => ["x", "y", "x", "y", "x", "y"]
*
- * When \String argument +string_separator+ is given,
- * equivalent to <tt>array.join(string_separator)</tt>:
+ * When string argument +string_separator+ is given,
+ * equivalent to <tt>self.join(string_separator)</tt>:
*
- * [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {:foo=>0}"
+ * [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {foo: 0}"
*
*/
@@ -5180,16 +5248,16 @@ rb_ary_times(VALUE ary, VALUE times)
ary2 = ary_new(rb_cArray, len);
ARY_SET_LEN(ary2, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
t = RARRAY_LEN(ary);
if (0 < t) {
ary_memcpy(ary2, 0, t, ptr);
while (t <= len/2) {
- ary_memcpy(ary2, t, t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, t, RARRAY_CONST_PTR(ary2));
t *= 2;
}
if (t < len) {
- ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR(ary2));
}
}
out:
@@ -5198,17 +5266,18 @@ rb_ary_times(VALUE ary, VALUE times)
/*
* call-seq:
- * array.assoc(obj) -> found_array or nil
+ * assoc(object) -> found_array or nil
*
- * Returns the first element in +self+ that is an \Array
- * whose first element <tt>==</tt> +obj+:
+ * Returns the first element +ele+ in +self+ such that +ele+ is an array
+ * and <tt>ele[0] == object</tt>:
*
* a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
* a.assoc(4) # => [4, 5, 6]
*
* Returns +nil+ if no such element is found.
*
- * Related: #rassoc.
+ * Related: Array#rassoc;
+ * see also {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
VALUE
@@ -5228,17 +5297,19 @@ rb_ary_assoc(VALUE ary, VALUE key)
/*
* call-seq:
- * array.rassoc(obj) -> found_array or nil
+ * rassoc(object) -> found_array or nil
*
- * Returns the first element in +self+ that is an \Array
- * whose second element <tt>==</tt> +obj+:
+ * Returns the first element +ele+ in +self+ such that +ele+ is an array
+ * and <tt>ele[1] == object</tt>:
*
* a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
* a.rassoc(4) # => [2, 4]
+ * a.rassoc(5) # => [4, 5, 6]
*
* Returns +nil+ if no such element is found.
*
- * Related: #assoc.
+ * Related: Array#assoc;
+ * see also {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
VALUE
@@ -5248,7 +5319,7 @@ rb_ary_rassoc(VALUE ary, VALUE value)
VALUE v;
for (i = 0; i < RARRAY_LEN(ary); ++i) {
- v = RARRAY_AREF(ary, i);
+ v = rb_check_array_type(RARRAY_AREF(ary, i));
if (RB_TYPE_P(v, T_ARRAY) &&
RARRAY_LEN(v) > 1 &&
rb_equal(RARRAY_AREF(v, 1), value))
@@ -5293,20 +5364,26 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
/*
* call-seq:
- * array == other_array -> true or false
+ * self == other_array -> true or false
*
- * Returns +true+ if both <tt>array.size == other_array.size</tt>
- * and for each index +i+ in +array+, <tt>array[i] == other_array[i]</tt>:
+ * Returns whether both:
*
- * a0 = [:foo, 'bar', 2]
- * a1 = [:foo, 'bar', 2.0]
- * a1 == a0 # => true
- * [] == [] # => true
+ * - +self+ and +other_array+ are the same size.
+ * - Their corresponding elements are the same;
+ * that is, for each index +i+ in <tt>(0...self.size)</tt>,
+ * <tt>self[i] == other_array[i]</tt>.
*
- * Otherwise, returns +false+.
+ * Examples:
+ *
+ * [:foo, 'bar', 2] == [:foo, 'bar', 2] # => true
+ * [:foo, 'bar', 2] == [:foo, 'bar', 2.0] # => true
+ * [:foo, 'bar', 2] == [:foo, 'bar'] # => false # Different sizes.
+ * [:foo, 'bar', 2] == [:foo, 'bar', 3] # => false # Different elements.
*
* This method is different from method Array#eql?,
* which compares elements using <tt>Object#eql?</tt>.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Array@Methods+for+Comparing].
*/
static VALUE
@@ -5320,7 +5397,7 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);
}
@@ -5339,10 +5416,10 @@ recursive_eql(VALUE ary1, VALUE ary2, int recur)
/*
* call-seq:
- * array.eql? other_array -> true or false
+ * eql?(other_array) -> true or false
*
* Returns +true+ if +self+ and +other_array+ are the same size,
- * and if, for each index +i+ in +self+, <tt>self[i].eql? other_array[i]</tt>:
+ * and if, for each index +i+ in +self+, <tt>self[i].eql?(other_array[i])</tt>:
*
* a0 = [:foo, 'bar', 2]
* a1 = [:foo, 'bar', 2]
@@ -5352,6 +5429,8 @@ recursive_eql(VALUE ary1, VALUE ary2, int recur)
*
* This method is different from method Array#==,
* which compares using method <tt>Object#==</tt>.
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -5360,49 +5439,71 @@ rb_ary_eql(VALUE ary1, VALUE ary2)
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
+static VALUE
+ary_hash_values(long len, const VALUE *elements, const VALUE ary)
+{
+ long i;
+ st_index_t h;
+ VALUE n;
+
+ h = rb_hash_start(len);
+ h = rb_hash_uint(h, (st_index_t)rb_ary_hash_values);
+ for (i=0; i<len; i++) {
+ n = rb_hash(elements[i]);
+ h = rb_hash_uint(h, NUM2LONG(n));
+ if (ary) {
+ len = RARRAY_LEN(ary);
+ elements = RARRAY_CONST_PTR(ary);
+ }
+ }
+ h = rb_hash_end(h);
+ return ST2FIX(h);
+}
+
+VALUE
+rb_ary_hash_values(long len, const VALUE *elements)
+{
+ return ary_hash_values(len, elements, 0);
+}
+
/*
* call-seq:
- * array.hash -> integer
+ * hash -> integer
*
* Returns the integer hash value for +self+.
*
- * Two arrays with the same content will have the same hash code (and will compare using eql?):
+ * Two arrays with the same content will have the same hash value
+ * (and will compare using eql?):
*
- * [0, 1, 2].hash == [0, 1, 2].hash # => true
- * [0, 1, 2].hash == [0, 1, 3].hash # => false
+ * ['a', 'b'].hash == ['a', 'b'].hash # => true
+ * ['a', 'b'].hash == ['a', 'c'].hash # => false
+ * ['a', 'b'].hash == ['a'].hash # => false
*
*/
static VALUE
rb_ary_hash(VALUE ary)
{
- long i;
- st_index_t h;
- VALUE n;
-
- h = rb_hash_start(RARRAY_LEN(ary));
- h = rb_hash_uint(h, (st_index_t)rb_ary_hash);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- n = rb_hash(RARRAY_AREF(ary, i));
- h = rb_hash_uint(h, NUM2LONG(n));
- }
- h = rb_hash_end(h);
- return ST2FIX(h);
+ RBIMPL_ASSERT_OR_ASSUME(ary);
+ return ary_hash_values(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary), ary);
}
/*
* call-seq:
- * array.include?(obj) -> true or false
+ * include?(object) -> true or false
*
- * Returns +true+ if for some index +i+ in +self+, <tt>obj == self[i]</tt>;
- * otherwise +false+:
+ * Returns whether for some element +element+ in +self+,
+ * <tt>object == element</tt>:
*
- * [0, 1, 2].include?(2) # => true
- * [0, 1, 2].include?(3) # => false
+ * [0, 1, 2].include?(2) # => true
+ * [0, 1, 2].include?(2.0) # => true
+ * [0, 1, 2].include?(2.1) # => false
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
VALUE
@@ -5457,33 +5558,40 @@ recursive_cmp(VALUE ary1, VALUE ary2, int recur)
/*
* call-seq:
- * array <=> other_array -> -1, 0, or 1
- *
- * Returns -1, 0, or 1 as +self+ is less than, equal to, or greater than +other_array+.
- * For each index +i+ in +self+, evaluates <tt>result = self[i] <=> other_array[i]</tt>.
+ * self <=> other_array -> -1, 0, or 1
*
- * Returns -1 if any result is -1:
+ * Returns -1, 0, or 1 as +self+ is determined
+ * to be less than, equal to, or greater than +other_array+.
*
- * [0, 1, 2] <=> [0, 1, 3] # => -1
+ * Iterates over each index +i+ in <tt>(0...self.size)</tt>:
*
- * Returns 1 if any result is 1:
+ * - Computes <tt>result[i]</tt> as <tt>self[i] <=> other_array[i]</tt>.
+ * - Immediately returns 1 if <tt>result[i]</tt> is 1:
*
- * [0, 1, 2] <=> [0, 1, 1] # => 1
+ * [0, 1, 2] <=> [0, 0, 2] # => 1
*
- * When all results are zero:
+ * - Immediately returns -1 if <tt>result[i]</tt> is -1:
*
- * - Returns -1 if +array+ is smaller than +other_array+:
+ * [0, 1, 2] <=> [0, 2, 2] # => -1
*
- * [0, 1, 2] <=> [0, 1, 2, 3] # => -1
+ * - Continues if <tt>result[i]</tt> is 0.
*
- * - Returns 1 if +array+ is larger than +other_array+:
+ * When every +result+ is 0,
+ * returns <tt>self.size <=> other_array.size</tt>
+ * (see Integer#<=>):
*
- * [0, 1, 2] <=> [0, 1] # => 1
+ * [0, 1, 2] <=> [0, 1] # => 1
+ * [0, 1, 2] <=> [0, 1, 2] # => 0
+ * [0, 1, 2] <=> [0, 1, 2, 3] # => -1
*
- * - Returns 0 if +array+ and +other_array+ are the same size:
+ * Note that when +other_array+ is larger than +self+,
+ * its trailing elements do not affect the result:
*
- * [0, 1, 2] <=> [0, 1, 2] # => 0
+ * [0, 1, 2] <=> [0, 1, 2, -3] # => -1
+ * [0, 1, 2] <=> [0, 1, 2, 0] # => -1
+ * [0, 1, 2] <=> [0, 1, 2, 3] # => -1
*
+ * Related: see {Methods for Comparing}[rdoc-ref:Array@Methods+for+Comparing].
*/
VALUE
@@ -5553,18 +5661,20 @@ ary_make_hash_by(VALUE ary)
/*
* call-seq:
- * array - other_array -> new_array
+ * self - other_array -> new_array
+ *
+ * Returns a new array containing only those elements of +self+
+ * that are not found in +other_array+;
+ * the order from +self+ is preserved:
*
- * Returns a new \Array containing only those elements from +array+
- * that are not found in \Array +other_array+;
- * items are compared using <tt>eql?</tt>;
- * the order from +array+ is preserved:
+ * [0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3]
+ * [0, 1, 1, 2, 1, 1, 3, 1, 1] - [3, 2, 0, :foo] # => [1, 1, 1, 1, 1, 1]
+ * [0, 1, 2] - [:foo] # => [0, 1, 2]
*
- * [0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3]
- * [0, 1, 2, 3] - [3, 0] # => [1, 2]
- * [0, 1, 2] - [4] # => [0, 1, 2]
+ * Element are compared using method <tt>#eql?</tt>
+ * (as defined in each element of +self+).
*
- * Related: Array#difference.
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
VALUE
@@ -5598,19 +5708,21 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
/*
* call-seq:
- * array.difference(*other_arrays) -> new_array
+ * difference(*other_arrays = []) -> new_array
*
- * Returns a new \Array containing only those elements from +self+
- * that are not found in any of the Arrays +other_arrays+;
+ * Returns a new array containing only those elements from +self+
+ * that are not found in any of the given +other_arrays+;
* items are compared using <tt>eql?</tt>; order from +self+ is preserved:
*
* [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3]
- * [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
- * [0, 1, 2].difference([4]) # => [0, 1, 2]
+ * [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
+ * [0, 1, 2].difference([4]) # => [0, 1, 2]
+ * [0, 1, 2].difference # => [0, 1, 2]
*
- * Returns a copy of +self+ if no arguments given.
+ * Returns a copy of +self+ if no arguments are given.
*
- * Related: Array#-.
+ * Related: Array#-;
+ * see also {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -5634,7 +5746,7 @@ rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
VALUE elt = rb_ary_elt(ary, i);
for (j = 0; j < argc; j++) {
if (is_hash[j]) {
- if (rb_hash_stlike_lookup(argv[j], RARRAY_AREF(ary, i), NULL))
+ if (rb_hash_stlike_lookup(argv[j], elt, NULL))
break;
}
else {
@@ -5652,19 +5764,25 @@ rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array & other_array -> new_array
+ * self & other_array -> new_array
*
- * Returns a new \Array containing each element found in both +array+ and \Array +other_array+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * Returns a new array containing the _intersection_ of +self+ and +other_array+;
+ * that is, containing those elements found in both +self+ and +other_array+:
*
* [0, 1, 2, 3] & [1, 2] # => [1, 2]
- * [0, 1, 0, 1] & [0, 1] # => [0, 1]
*
- * Preserves order from +array+:
+ * Omits duplicates:
+ *
+ * [0, 1, 1, 0] & [0, 1] # => [0, 1]
+ *
+ * Preserves order from +self+:
*
* [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2]
*
- * Related: Array#intersection.
+ * Identifies common elements using method <tt>#eql?</tt>
+ * (as defined in each element of +self+).
+ *
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
@@ -5704,22 +5822,23 @@ rb_ary_and(VALUE ary1, VALUE ary2)
/*
* call-seq:
- * array.intersection(*other_arrays) -> new_array
+ * intersection(*other_arrays) -> new_array
*
- * Returns a new \Array containing each element found both in +self+
- * and in all of the given Arrays +other_arrays+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * Returns a new array containing each element in +self+ that is +#eql?+
+ * to at least one element in each of the given +other_arrays+;
+ * duplicates are omitted:
*
- * [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
* [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
*
- * Preserves order from +self+:
+ * Each element must correctly implement method <tt>#hash</tt>.
+ *
+ * Order from +self+ is preserved:
*
* [0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2]
*
- * Returns a copy of +self+ if no arguments given.
+ * Returns a copy of +self+ if no arguments are given.
*
- * Related: Array#&.
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -5768,17 +5887,17 @@ rb_ary_union_hash(VALUE hash, VALUE ary2)
/*
* call-seq:
- * array | other_array -> new_array
+ * self | other_array -> new_array
*
- * Returns the union of +array+ and \Array +other_array+;
+ * Returns the union of +self+ and +other_array+;
* duplicates are removed; order is preserved;
- * items are compared using <tt>eql?</tt>:
+ * items are compared using <tt>eql?</tt> and <tt>hash</tt>:
*
* [0, 1] | [2, 3] # => [0, 1, 2, 3]
* [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3]
* [0, 1, 2] | [3, 2, 1, 0] # => [0, 1, 2, 3]
*
- * Related: Array#union.
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -5802,18 +5921,25 @@ rb_ary_or(VALUE ary1, VALUE ary2)
/*
* call-seq:
- * array.union(*other_arrays) -> new_array
+ * union(*other_arrays) -> new_array
*
- * Returns a new \Array that is the union of +self+ and all given Arrays +other_arrays+;
- * duplicates are removed; order is preserved; items are compared using <tt>eql?</tt>:
+ * Returns a new array that is the union of the elements of +self+
+ * and all given arrays +other_arrays+;
+ * items are compared using <tt>eql?</tt> and <tt>hash</tt>:
*
* [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7]
+ *
+ * Removes duplicates (preserving the first found):
+ *
* [0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3]
- * [0, 1, 2, 3].union([3, 2], [1, 0]) # => [0, 1, 2, 3]
*
- * Returns a copy of +self+ if no arguments given.
+ * Preserves order (preserving the position of the first found):
+ *
+ * [3, 2, 1, 0].union([5, 3], [4, 2]) # => [3, 2, 1, 0, 5, 4]
*
- * Related: Array#|.
+ * With no arguments given, returns a copy of +self+.
+ *
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -5846,17 +5972,16 @@ rb_ary_union_multi(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * ary.intersect?(other_ary) -> true or false
+ * intersect?(other_array) -> true or false
+ *
+ * Returns whether +other_array+ has at least one element that is +#eql?+ to some element of +self+:
*
- * Returns +true+ if the array and +other_ary+ have at least one element in
- * common, otherwise returns +false+:
+ * [1, 2, 3].intersect?([3, 4, 5]) # => true
+ * [1, 2, 3].intersect?([4, 5, 6]) # => false
*
- * a = [ 1, 2, 3 ]
- * b = [ 3, 4, 5 ]
- * c = [ 5, 6, 7 ]
- * a.intersect?(b) #=> true
- * a.intersect?(c) #=> false
+ * Each element must correctly implement method <tt>#hash</tt>.
*
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -5990,42 +6115,51 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
/*
* call-seq:
- * array.max -> element
- * array.max {|a, b| ... } -> element
- * array.max(n) -> new_array
- * array.max(n) {|a, b| ... } -> new_array
+ * max -> element
+ * max(count) -> new_array
+ * max {|a, b| ... } -> element
+ * max(count) {|a, b| ... } -> new_array
*
* Returns one of the following:
*
* - The maximum-valued element from +self+.
- * - A new \Array of maximum-valued elements selected from +self+.
+ * - A new array of maximum-valued elements from +self+.
+ *
+ * Does not modify +self+.
*
- * When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer.
+ * With no block given, each element in +self+ must respond to method <tt>#<=></tt>
+ * with a numeric.
*
* With no argument and no block, returns the element in +self+
- * having the maximum value per method <tt><=></tt>:
+ * having the maximum value per method <tt>#<=></tt>:
*
- * [0, 1, 2].max # => 2
+ * [1, 0, 3, 2].max # => 3
*
- * With an argument \Integer +n+ and no block, returns a new \Array with at most +n+ elements,
- * in descending order per method <tt><=></tt>:
+ * With non-negative numeric argument +count+ and no block,
+ * returns a new array with at most +count+ elements,
+ * in descending order, per method <tt>#<=></tt>:
*
- * [0, 1, 2, 3].max(3) # => [3, 2, 1]
- * [0, 1, 2, 3].max(6) # => [3, 2, 1, 0]
+ * [1, 0, 3, 2].max(3) # => [3, 2, 1]
+ * [1, 0, 3, 2].max(3.0) # => [3, 2, 1]
+ * [1, 0, 3, 2].max(9) # => [3, 2, 1, 0]
+ * [1, 0, 3, 2].max(0) # => []
*
- * When a block is given, the block must return an \Integer.
+ * With a block given, the block must return a numeric.
*
- * With a block and no argument, calls the block <tt>self.size-1</tt> times to compare elements;
+ * With a block and no argument, calls the block <tt>self.size - 1</tt> times to compare elements;
* returns the element having the maximum value per the block:
*
- * ['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000"
+ * ['0', '', '000', '00'].max {|a, b| a.size <=> b.size }
+ * # => "000"
*
- * With an argument +n+ and a block, returns a new \Array with at most +n+ elements,
- * in descending order per the block:
+ * With non-negative numeric argument +count+ and a block,
+ * returns a new array with at most +count+ elements,
+ * in descending order, per the block:
*
- * ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
+ * ['0', '', '000', '00'].max(2) {|a, b| a.size <=> b.size }
+ * # => ["000", "00"]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
rb_ary_max(int argc, VALUE *argv, VALUE ary)
@@ -6158,42 +6292,51 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
/*
* call-seq:
- * array.min -> element
- * array.min { |a, b| ... } -> element
- * array.min(n) -> new_array
- * array.min(n) { |a, b| ... } -> new_array
+ * min -> element
+ * min(count) -> new_array
+ * min {|a, b| ... } -> element
+ * min(count) {|a, b| ... } -> new_array
*
* Returns one of the following:
*
* - The minimum-valued element from +self+.
- * - A new \Array of minimum-valued elements selected from +self+.
+ * - A new array of minimum-valued elements from +self+.
*
- * When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer.
+ * Does not modify +self+.
+ *
+ * With no block given, each element in +self+ must respond to method <tt>#<=></tt>
+ * with a numeric.
*
* With no argument and no block, returns the element in +self+
- * having the minimum value per method <tt><=></tt>:
+ * having the minimum value per method <tt>#<=></tt>:
*
- * [0, 1, 2].min # => 0
+ * [1, 0, 3, 2].min # => 0
*
- * With \Integer argument +n+ and no block, returns a new \Array with at most +n+ elements,
- * in ascending order per method <tt><=></tt>:
+ * With non-negative numeric argument +count+ and no block,
+ * returns a new array with at most +count+ elements,
+ * in ascending order, per method <tt>#<=></tt>:
*
- * [0, 1, 2, 3].min(3) # => [0, 1, 2]
- * [0, 1, 2, 3].min(6) # => [0, 1, 2, 3]
+ * [1, 0, 3, 2].min(3) # => [0, 1, 2]
+ * [1, 0, 3, 2].min(3.0) # => [0, 1, 2]
+ * [1, 0, 3, 2].min(9) # => [0, 1, 2, 3]
+ * [1, 0, 3, 2].min(0) # => []
*
- * When a block is given, the block must return an Integer.
+ * With a block given, the block must return a numeric.
*
- * With a block and no argument, calls the block <tt>self.size-1</tt> times to compare elements;
+ * With a block and no argument, calls the block <tt>self.size - 1</tt> times to compare elements;
* returns the element having the minimum value per the block:
*
- * ['0', '00', '000'].min { |a, b| a.size <=> b.size } # => "0"
+ * ['0', '', '000', '00'].min {|a, b| a.size <=> b.size }
+ * # => ""
*
- * With an argument +n+ and a block, returns a new \Array with at most +n+ elements,
- * in ascending order per the block:
+ * With non-negative numeric argument +count+ and a block,
+ * returns a new array with at most +count+ elements,
+ * in ascending order, per the block:
*
- * ['0', '00', '000'].min(2) {|a, b| a.size <=> b.size } # => ["0", "00"]
+ * ['0', '', '000', '00'].min(2) {|a, b| a.size <=> b.size }
+ * # => ["", "0"]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
rb_ary_min(int argc, VALUE *argv, VALUE ary)
@@ -6237,26 +6380,25 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.minmax -> [min_val, max_val]
- * array.minmax {|a, b| ... } -> [min_val, max_val]
+ * minmax -> array
+ * minmax {|a, b| ... } -> array
*
- * Returns a new 2-element \Array containing the minimum and maximum values
- * from +self+, either per method <tt><=></tt> or per a given block:.
+ * Returns a 2-element array containing the minimum-valued and maximum-valued
+ * elements from +self+;
+ * does not modify +self+.
*
- * When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer;
- * returns a new 2-element \Array containing the minimum and maximum values
- * from +self+, per method <tt><=></tt>:
+ * With no block given, the minimum and maximum values are determined using method <tt>#<=></tt>:
*
- * [0, 1, 2].minmax # => [0, 2]
+ * [1, 0, 3, 2].minmax # => [0, 3]
*
- * When a block is given, the block must return an \Integer;
- * the block is called <tt>self.size-1</tt> times to compare elements;
- * returns a new 2-element \Array containing the minimum and maximum values
- * from +self+, per the block:
+ * With a block given, the block must return a numeric;
+ * the block is called <tt>self.size - 1</tt> times to compare elements;
+ * returns the elements having the minimum and maximum values per the block:
*
- * ['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"]
+ * ['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size }
+ * # => ["", "000"]
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
rb_ary_minmax(VALUE ary)
@@ -6276,32 +6418,30 @@ push_value(st_data_t key, st_data_t val, st_data_t ary)
/*
* call-seq:
- * array.uniq! -> self or nil
- * array.uniq! {|element| ... } -> self or nil
+ * uniq! -> self or nil
+ * uniq! {|element| ... } -> self or nil
*
* Removes duplicate elements from +self+, the first occurrence always being retained;
* returns +self+ if any elements removed, +nil+ otherwise.
*
* With no block given, identifies and removes elements using method <tt>eql?</tt>
- * to compare.
- *
- * Returns +self+ if any elements removed:
+ * and <tt>hash</tt> to compare elements:
*
* a = [0, 0, 1, 1, 2, 2]
* a.uniq! # => [0, 1, 2]
- *
- * Returns +nil+ if no elements removed.
+ * a.uniq! # => nil
*
* With a block given, calls the block for each element;
- * identifies (using method <tt>eql?</tt>) and removes
- * elements for which the block returns duplicate values.
- *
- * Returns +self+ if any elements removed:
+ * identifies and omits "duplicate" elements using method <tt>eql?</tt>
+ * and <tt>hash</tt> to compare <i>block return values</i>;
+ * that is, an element is a duplicate if its block return value
+ * is the same as that of a previous element:
*
* a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
- * a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa']
+ * a.uniq! {|element| element.size } # => ["a", "aa", "aaa"]
+ * a.uniq! {|element| element.size } # => nil
*
- * Returns +nil+ if no elements removed.
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
rb_ary_uniq_bang(VALUE ary)
@@ -6323,7 +6463,7 @@ rb_ary_uniq_bang(VALUE ary)
}
rb_ary_modify_check(ary);
ARY_SET_LEN(ary, 0);
- if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) {
+ if (ARY_SHARED_P(ary)) {
rb_ary_unshare(ary);
FL_SET_EMBED(ary);
}
@@ -6335,25 +6475,28 @@ rb_ary_uniq_bang(VALUE ary)
/*
* call-seq:
- * array.uniq -> new_array
- * array.uniq {|element| ... } -> new_array
+ * uniq -> new_array
+ * uniq {|element| ... } -> new_array
*
- * Returns a new \Array containing those elements from +self+ that are not duplicates,
+ * Returns a new array containing those elements from +self+ that are not duplicates,
* the first occurrence always being retained.
*
- * With no block given, identifies and omits duplicates using method <tt>eql?</tt>
- * to compare:
+ * With no block given, identifies and omits duplicate elements using method <tt>eql?</tt>
+ * and <tt>hash</tt> to compare elements:
*
* a = [0, 0, 1, 1, 2, 2]
* a.uniq # => [0, 1, 2]
*
* With a block given, calls the block for each element;
- * identifies (using method <tt>eql?</tt>) and omits duplicate values,
- * that is, those elements for which the block returns the same value:
+ * identifies and omits "duplicate" elements using method <tt>eql?</tt>
+ * and <tt>hash</tt> to compare <i>block return values</i>;
+ * that is, an element is a duplicate if its block return value
+ * is the same as that of a previous element:
*
* a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
* a.uniq {|element| element.size } # => ["a", "aa", "aaa"]
*
+ * Related: {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -6379,28 +6522,35 @@ rb_ary_uniq(VALUE ary)
/*
* call-seq:
- * array.compact! -> self or nil
+ * compact! -> self or nil
*
- * Removes all +nil+ elements from +self+.
+ * Removes all +nil+ elements from +self+;
+ * Returns +self+ if any elements are removed, +nil+ otherwise:
*
- * Returns +self+ if any elements removed, otherwise +nil+.
+ * a = [nil, 0, nil, false, nil, '', nil, [], nil, {}]
+ * a.compact! # => [0, false, "", [], {}]
+ * a # => [0, false, "", [], {}]
+ * a.compact! # => nil
+ *
+ * Related: Array#compact;
+ * see also {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
-static VALUE
+VALUE
rb_ary_compact_bang(VALUE ary)
{
VALUE *p, *t, *end;
long n;
rb_ary_modify(ary);
- p = t = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary); /* WB: no new reference */
+ p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
end = p + RARRAY_LEN(ary);
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
- n = p - RARRAY_CONST_PTR_TRANSIENT(ary);
+ n = p - RARRAY_CONST_PTR(ary);
if (RARRAY_LEN(ary) == n) {
return Qnil;
}
@@ -6411,12 +6561,16 @@ rb_ary_compact_bang(VALUE ary)
/*
* call-seq:
- * array.compact -> new_array
+ * compact -> new_array
*
- * Returns a new \Array containing all non-+nil+ elements from +self+:
+ * Returns a new array containing only the non-+nil+ elements from +self+;
+ * element order is preserved:
*
- * a = [nil, 0, nil, 1, nil, 2, nil]
- * a.compact # => [0, 1, 2]
+ * a = [nil, 0, nil, false, nil, '', nil, [], nil, {}]
+ * a.compact # => [0, false, "", [], {}]
+ *
+ * Related: Array#compact!;
+ * see also {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
@@ -6429,29 +6583,29 @@ rb_ary_compact(VALUE ary)
/*
* call-seq:
- * array.count -> an_integer
- * array.count(obj) -> an_integer
- * array.count {|element| ... } -> an_integer
+ * count -> integer
+ * count(object) -> integer
+ * count {|element| ... } -> integer
*
* Returns a count of specified elements.
*
* With no argument and no block, returns the count of all elements:
*
- * [0, 1, 2].count # => 3
- * [].count # => 0
+ * [0, :one, 'two', 3, 3.0].count # => 5
*
- * With argument +obj+, returns the count of elements <tt>==</tt> to +obj+:
+ * With argument +object+ given, returns the count of elements <tt>==</tt> to +object+:
*
- * [0, 1, 2, 0.0].count(0) # => 2
- * [0, 1, 2].count(3) # => 0
+ * [0, :one, 'two', 3, 3.0].count(3) # => 2
*
* With no argument and a block given, calls the block with each element;
* returns the count of elements for which the block returns a truthy value:
*
- * [0, 1, 2, 3].count {|element| element > 1} # => 2
+ * [0, 1, 2, 3].count {|element| element > 1 } # => 2
+ *
+ * With argument +object+ and a block given, issues a warning, ignores the block,
+ * and returns the count of elements <tt>==</tt> to +object+.
*
- * With argument +obj+ and a block given, issues a warning, ignores the block,
- * and returns the count of elements <tt>==</tt> to +obj+.
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -6488,9 +6642,8 @@ static VALUE
flatten(VALUE ary, int level)
{
long i;
- VALUE stack, result, tmp = 0, elt, vmemo;
- st_table *memo = 0;
- st_data_t id;
+ VALUE stack, result, tmp = 0, elt;
+ VALUE memo = Qfalse;
for (i = 0; i < RARRAY_LEN(ary); i++) {
elt = RARRAY_AREF(ary, i);
@@ -6504,7 +6657,7 @@ flatten(VALUE ary, int level)
}
result = ary_new(0, RARRAY_LEN(ary));
- ary_memcpy(result, 0, i, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(result, 0, i, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, i);
stack = ary_new(0, ARY_DEFAULT_SIZE);
@@ -6512,12 +6665,9 @@ flatten(VALUE ary, int level)
rb_ary_push(stack, LONG2NUM(i + 1));
if (level < 0) {
- vmemo = rb_hash_new();
- RBASIC_CLEAR_CLASS(vmemo);
- memo = st_init_numtable();
- rb_hash_st_table_set(vmemo, memo);
- st_insert(memo, (st_data_t)ary, (st_data_t)Qtrue);
- st_insert(memo, (st_data_t)tmp, (st_data_t)Qtrue);
+ memo = rb_obj_hide(rb_ident_hash_new());
+ rb_hash_aset(memo, ary, Qtrue);
+ rb_hash_aset(memo, tmp, Qtrue);
}
ary = tmp;
@@ -6532,9 +6682,8 @@ flatten(VALUE ary, int level)
}
tmp = rb_check_array_type(elt);
if (RBASIC(result)->klass) {
- if (memo) {
- RB_GC_GUARD(vmemo);
- st_clear(memo);
+ if (RTEST(memo)) {
+ rb_hash_clear(memo);
}
rb_raise(rb_eRuntimeError, "flatten reentered");
}
@@ -6543,12 +6692,11 @@ flatten(VALUE ary, int level)
}
else {
if (memo) {
- id = (st_data_t)tmp;
- if (st_is_member(memo, id)) {
- st_clear(memo);
+ if (rb_hash_aref(memo, tmp) == Qtrue) {
+ rb_hash_clear(memo);
rb_raise(rb_eArgError, "tried to flatten recursive array");
}
- st_insert(memo, id, (st_data_t)Qtrue);
+ rb_hash_aset(memo, tmp, Qtrue);
}
rb_ary_push(stack, ary);
rb_ary_push(stack, LONG2NUM(i));
@@ -6560,8 +6708,7 @@ flatten(VALUE ary, int level)
break;
}
if (memo) {
- id = (st_data_t)ary;
- st_delete(memo, &id, 0);
+ rb_hash_delete(memo, ary);
}
tmp = rb_ary_pop(stack);
i = NUM2LONG(tmp);
@@ -6569,7 +6716,7 @@ flatten(VALUE ary, int level)
}
if (memo) {
- st_clear(memo);
+ rb_hash_clear(memo);
}
RBASIC_SET_CLASS(result, rb_cArray);
@@ -6578,33 +6725,37 @@ flatten(VALUE ary, int level)
/*
* call-seq:
- * array.flatten! -> self or nil
- * array.flatten!(level) -> self or nil
+ * flatten!(depth = nil) -> self or nil
*
- * Replaces each nested \Array in +self+ with the elements from that \Array;
- * returns +self+ if any changes, +nil+ otherwise.
+ * Returns +self+ as a recursively flattening of +self+ to +depth+ levels of recursion;
+ * +depth+ must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects],
+ * or +nil+.
+ * At each level of recursion:
*
- * With non-negative \Integer argument +level+, flattens recursively through +level+ levels:
+ * - Each element that is an array is "flattened"
+ * (that is, replaced by its individual array elements).
+ * - Each element that is not an array is unchanged
+ * (even if the element is an object that has instance method +flatten+).
*
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten!(1) # => [0, 1, [2, 3], 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten!(2) # => [0, 1, 2, 3, 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten!(3) # => [0, 1, 2, 3, 4, 5]
- * [0, 1, 2].flatten!(1) # => nil
+ * Returns +nil+ if no elements were flattened.
*
- * With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels:
+ * With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
*
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten! # => [0, 1, 2, 3, 4, 5]
- * [0, 1, 2].flatten! # => nil
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten!(-1) # => [0, 1, 2, 3, 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten!(-2) # => [0, 1, 2, 3, 4, 5]
- * [0, 1, 2].flatten!(-1) # => nil
+ * a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
+ * a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
*
+ * With +nil+ or negative argument +depth+, flattens all levels:
+ *
+ * a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ *
+ * Related: Array#flatten;
+ * see also {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
*/
static VALUE
@@ -6622,7 +6773,7 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
if (result == ary) {
return Qnil;
}
- if (!(mod = ARY_EMBED_P(result))) rb_obj_freeze(result);
+ if (!(mod = ARY_EMBED_P(result))) rb_ary_freeze(result);
rb_ary_replace(ary, result);
if (mod) ARY_SET_EMBED_LEN(result, 0);
@@ -6631,35 +6782,37 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.flatten -> new_array
- * array.flatten(level) -> new_array
- *
- * Returns a new \Array that is a recursive flattening of +self+:
- * - Each non-Array element is unchanged.
- * - Each \Array is replaced by its individual elements.
- *
- * With non-negative \Integer argument +level+, flattens recursively through +level+ levels:
- *
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(0) # => [0, [1, [2, 3], 4], 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(1) # => [0, 1, [2, 3], 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(2) # => [0, 1, 2, 3, 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(3) # => [0, 1, 2, 3, 4, 5]
- *
- * With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels:
- *
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten # => [0, 1, 2, 3, 4, 5]
- * [0, 1, 2].flatten # => [0, 1, 2]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(-1) # => [0, 1, 2, 3, 4, 5]
- * a = [ 0, [ 1, [2, 3], 4 ], 5 ]
- * a.flatten(-2) # => [0, 1, 2, 3, 4, 5]
- * [0, 1, 2].flatten(-1) # => [0, 1, 2]
+ * flatten(depth = nil) -> new_array
+ *
+ * Returns a new array that is a recursive flattening of +self+
+ * to +depth+ levels of recursion;
+ * +depth+ must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]
+ * or +nil+.
+ * At each level of recursion:
*
+ * - Each element that is an array is "flattened"
+ * (that is, replaced by its individual array elements).
+ * - Each element that is not an array is unchanged
+ * (even if the element is an object that has instance method +flatten+).
+ *
+ * With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
+ *
+ * a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
+ * a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ *
+ * With +nil+ or negative +depth+, flattens all levels.
+ *
+ * a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ * a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
+ *
+ * Related: Array#flatten!;
+ * see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/
static VALUE
@@ -6691,10 +6844,10 @@ rb_ary_shuffle_bang(rb_execution_context_t *ec, VALUE ary, VALUE randgen)
rb_ary_modify(ary);
i = len = RARRAY_LEN(ary);
RARRAY_PTR_USE(ary, ptr, {
- while (i) {
+ while (i > 1) {
long j = RAND_UPTO(i);
VALUE tmp;
- if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR_TRANSIENT(ary)) {
+ if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR(ary)) {
rb_raise(rb_eRuntimeError, "modified during shuffle");
}
tmp = ptr[--i];
@@ -6713,6 +6866,14 @@ rb_ary_shuffle(rb_execution_context_t *ec, VALUE ary, VALUE randgen)
return ary;
}
+static const rb_data_type_t ary_sample_memo_type = {
+ .wrap_struct_name = "ary_sample_memo",
+ .function = {
+ .dfree = (RUBY_DATA_FUNC)st_free_table,
+ },
+ .flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+};
+
static VALUE
ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE to_array)
{
@@ -6786,7 +6947,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
sorted[j] = idx[i] = k;
}
result = rb_ary_new_capa(n);
- RARRAY_PTR_USE_TRANSIENT(result, ptr_result, {
+ RARRAY_PTR_USE(result, ptr_result, {
for (i=0; i<n; i++) {
ptr_result[i] = RARRAY_AREF(ary, idx[i]);
}
@@ -6794,11 +6955,9 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
}
else if (n <= memo_threshold / 2) {
long max_idx = 0;
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
- VALUE vmemo = Data_Wrap_Struct(0, 0, st_free_table, 0);
+ VALUE vmemo = TypedData_Wrap_Struct(0, &ary_sample_memo_type, 0);
st_table *memo = st_init_numtable_with_size(n);
- DATA_PTR(vmemo) = memo;
+ RTYPEDDATA_DATA(vmemo) = memo;
result = rb_ary_new_capa(n);
RARRAY_PTR_USE(result, ptr_result, {
for (i=0; i<n; i++) {
@@ -6809,7 +6968,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
len = RARRAY_LEN(ary);
if (len <= max_idx) n = 0;
else if (n > len) n = len;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr_ary, {
+ RARRAY_PTR_USE(ary, ptr_ary, {
for (i=0; i<n; i++) {
long j2 = j = ptr_result[i];
long i2 = i;
@@ -6821,8 +6980,9 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
}
});
});
- DATA_PTR(vmemo) = 0;
+ RTYPEDDATA_DATA(vmemo) = 0;
st_free_table(memo);
+ RB_GC_GUARD(vmemo);
}
else {
result = rb_ary_dup(ary);
@@ -6844,6 +7004,12 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
}
static VALUE
+ary_sized_alloc(rb_execution_context_t *ec, VALUE self)
+{
+ return rb_ary_new2(RARRAY_LEN(self));
+}
+
+static VALUE
ary_sample0(rb_execution_context_t *ec, VALUE ary)
{
return ary_sample(ec, ary, rb_cRandom, Qfalse, Qfalse);
@@ -6867,36 +7033,36 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
/*
* call-seq:
- * array.cycle {|element| ... } -> nil
- * array.cycle(count) {|element| ... } -> nil
- * array.cycle -> new_enumerator
- * array.cycle(count) -> new_enumerator
+ * cycle(count = nil) {|element| ... } -> nil
+ * cycle(count = nil) -> new_enumerator
*
- * When called with positive \Integer argument +count+ and a block,
- * calls the block with each element, then does so again,
+ * With a block given, may call the block, depending on the value of argument +count+;
+ * +count+ must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects],
+ * or +nil+.
+ *
+ * When +count+ is positive,
+ * calls the block with each element, then does so repeatedly,
* until it has done so +count+ times; returns +nil+:
*
* output = []
* [0, 1].cycle(2) {|element| output.push(element) } # => nil
* output # => [0, 1, 0, 1]
*
- * If +count+ is zero or negative, does not call the block:
+ * When +count+ is zero or negative, does not call the block:
*
- * [0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil
+ * [0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil
* [0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil
*
- * When a block is given, and argument is omitted or +nil+, cycles forever:
+ * When +count+ is +nil+, cycles forever:
*
* # Prints 0 and 1 forever.
* [0, 1].cycle {|element| puts element }
* [0, 1].cycle(nil) {|element| puts element }
*
- * When no block is given, returns a new \Enumerator:
- *
- * [0, 1].cycle(2) # => #<Enumerator: [0, 1]:cycle(2)>
- * [0, 1].cycle # => # => #<Enumerator: [0, 1]:cycle>
- * [0, 1].cycle.first(5) # => [0, 1, 0, 1, 0]
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
static VALUE
rb_ary_cycle(int argc, VALUE *argv, VALUE ary)
@@ -7040,82 +7206,44 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * array.permutation {|element| ... } -> self
- * array.permutation(n) {|element| ... } -> self
- * array.permutation -> new_enumerator
- * array.permutation(n) -> new_enumerator
- *
- * When invoked with a block, yield all permutations of elements of +self+; returns +self+.
- * The order of permutations is indeterminate.
- *
- * When a block and an in-range positive \Integer argument +n+ (<tt>0 < n <= self.size</tt>)
- * are given, calls the block with all +n+-tuple permutations of +self+.
+ * permutation(count = self.size) {|permutation| ... } -> self
+ * permutation(count = self.size) -> new_enumerator
*
- * Example:
- *
- * a = [0, 1, 2]
- * a.permutation(2) {|permutation| p permutation }
+ * Iterates over permutations of the elements of +self+;
+ * the order of permutations is indeterminate.
*
- * Output:
- *
- * [0, 1]
- * [0, 2]
- * [1, 0]
- * [1, 2]
- * [2, 0]
- * [2, 1]
- *
- * Another example:
+ * With a block and an in-range positive integer argument +count+ (<tt>0 < count <= self.size</tt>) given,
+ * calls the block with each permutation of +self+ of size +count+;
+ * returns +self+:
*
* a = [0, 1, 2]
- * a.permutation(3) {|permutation| p permutation }
+ * perms = []
+ * a.permutation(1) {|perm| perms.push(perm) }
+ * perms # => [[0], [1], [2]]
*
- * Output:
+ * perms = []
+ * a.permutation(2) {|perm| perms.push(perm) }
+ * perms # => [[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]]
*
- * [0, 1, 2]
- * [0, 2, 1]
- * [1, 0, 2]
- * [1, 2, 0]
- * [2, 0, 1]
- * [2, 1, 0]
+ * perms = []
+ * a.permutation(3) {|perm| perms.push(perm) }
+ * perms # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
*
- * When +n+ is zero, calls the block once with a new empty \Array:
+ * When +count+ is zero, calls the block once with a new empty array:
*
- * a = [0, 1, 2]
- * a.permutation(0) {|permutation| p permutation }
+ * perms = []
+ * a.permutation(0) {|perm| perms.push(perm) }
+ * perms # => [[]]
*
- * Output:
- *
- * []
- *
- * When +n+ is out of range (negative or larger than <tt>self.size</tt>),
+ * When +count+ is out of range (negative or larger than <tt>self.size</tt>),
* does not call the block:
*
- * a = [0, 1, 2]
* a.permutation(-1) {|permutation| fail 'Cannot happen' }
* a.permutation(4) {|permutation| fail 'Cannot happen' }
*
- * When a block given but no argument,
- * behaves the same as <tt>a.permutation(a.size)</tt>:
- *
- * a = [0, 1, 2]
- * a.permutation {|permutation| p permutation }
- *
- * Output:
- *
- * [0, 1, 2]
- * [0, 2, 1]
- * [1, 0, 2]
- * [1, 2, 0]
- * [2, 0, 1]
- * [2, 1, 0]
- *
- * Returns a new \Enumerator if no block given:
- *
- * a = [0, 1, 2]
- * a.permutation # => #<Enumerator: [0, 1, 2]:permutation>
- * a.permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>
+ * With no block given, returns a new Enumerator.
*
+ * Related: {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
static VALUE
@@ -7188,56 +7316,46 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * array.combination(n) {|element| ... } -> self
- * array.combination(n) -> new_enumerator
- *
- * Calls the block, if given, with combinations of elements of +self+;
- * returns +self+. The order of combinations is indeterminate.
- *
- * When a block and an in-range positive \Integer argument +n+ (<tt>0 < n <= self.size</tt>)
- * are given, calls the block with all +n+-tuple combinations of +self+.
+ * combination(count) {|element| ... } -> self
+ * combination(count) -> new_enumerator
*
- * Example:
+ * When a block and a positive
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]
+ * argument +count+ (<tt>0 < count <= self.size</tt>)
+ * are given, calls the block with each combination of +self+ of size +count+;
+ * returns +self+:
*
- * a = [0, 1, 2]
- * a.combination(2) {|combination| p combination }
+ * a = %w[a b c] # => ["a", "b", "c"]
+ * a.combination(2) {|combination| p combination } # => ["a", "b", "c"]
*
* Output:
*
- * [0, 1]
- * [0, 2]
- * [1, 2]
+ * ["a", "b"]
+ * ["a", "c"]
+ * ["b", "c"]
*
- * Another example:
+ * The order of the yielded combinations is not guaranteed.
*
- * a = [0, 1, 2]
- * a.combination(3) {|combination| p combination }
- *
- * Output:
+ * When +count+ is zero, calls the block once with a new empty array:
*
- * [0, 1, 2]
- *
- * When +n+ is zero, calls the block once with a new empty \Array:
- *
- * a = [0, 1, 2]
- * a1 = a.combination(0) {|combination| p combination }
+ * a.combination(0) {|combination| p combination }
+ * [].combination(0) {|combination| p combination }
*
* Output:
*
* []
+ * []
*
- * When +n+ is out of range (negative or larger than <tt>self.size</tt>),
+ * When +count+ is negative or larger than +self.size+ and +self+ is non-empty,
* does not call the block:
*
- * a = [0, 1, 2]
- * a.combination(-1) {|combination| fail 'Cannot happen' }
- * a.combination(4) {|combination| fail 'Cannot happen' }
- *
- * Returns a new \Enumerator if no block given:
+ * a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
+ * a.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
*
- * a = [0, 1, 2]
- * a.combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
+ * With no block given, returns a new Enumerator.
*
+ * Related: Array#permutation;
+ * see also {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].
*/
static VALUE
@@ -7324,68 +7442,41 @@ rb_ary_repeated_permutation_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * array.repeated_permutation(n) {|permutation| ... } -> self
- * array.repeated_permutation(n) -> new_enumerator
+ * repeated_permutation(size) {|permutation| ... } -> self
+ * repeated_permutation(size) -> new_enumerator
*
- * Calls the block with each repeated permutation of length +n+ of the elements of +self+;
- * each permutation is an \Array;
+ * With a block given, calls the block with each repeated permutation of length +size+
+ * of the elements of +self+;
+ * each permutation is an array;
* returns +self+. The order of the permutations is indeterminate.
*
- * When a block and a positive \Integer argument +n+ are given, calls the block with each
- * +n+-tuple repeated permutation of the elements of +self+.
- * The number of permutations is <tt>self.size**n</tt>.
- *
- * +n+ = 1:
- *
- * a = [0, 1, 2]
- * a.repeated_permutation(1) {|permutation| p permutation }
- *
- * Output:
- *
- * [0]
- * [1]
- * [2]
- *
- * +n+ = 2:
- *
- * a.repeated_permutation(2) {|permutation| p permutation }
+ * If a positive integer argument +size+ is given,
+ * calls the block with each +size+-tuple repeated permutation of the elements of +self+.
+ * The number of permutations is <tt>self.size**size</tt>.
*
- * Output:
+ * Examples:
*
- * [0, 0]
- * [0, 1]
- * [0, 2]
- * [1, 0]
- * [1, 1]
- * [1, 2]
- * [2, 0]
- * [2, 1]
- * [2, 2]
+ * - +size+ is 1:
*
- * If +n+ is zero, calls the block once with an empty \Array.
+ * p = []
+ * [0, 1, 2].repeated_permutation(1) {|permutation| p.push(permutation) }
+ * p # => [[0], [1], [2]]
*
- * If +n+ is negative, does not call the block:
+ * - +size+ is 2:
*
- * a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' }
+ * p = []
+ * [0, 1, 2].repeated_permutation(2) {|permutation| p.push(permutation) }
+ * p # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]
*
- * Returns a new \Enumerator if no block given:
+ * If +size+ is zero, calls the block once with an empty array.
*
- * a = [0, 1, 2]
- * a.repeated_permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>
+ * If +size+ is negative, does not call the block:
*
- * Using Enumerators, it's convenient to show the permutations and counts
- * for some values of +n+:
+ * [0, 1, 2].repeated_permutation(-1) {|permutation| fail 'Cannot happen' }
*
- * e = a.repeated_permutation(0)
- * e.size # => 1
- * e.to_a # => [[]]
- * e = a.repeated_permutation(1)
- * e.size # => 3
- * e.to_a # => [[0], [1], [2]]
- * e = a.repeated_permutation(2)
- * e.size # => 9
- * e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
rb_ary_repeated_permutation(VALUE ary, VALUE num)
@@ -7456,65 +7547,41 @@ rb_ary_repeated_combination_size(VALUE ary, VALUE args, VALUE eobj)
/*
* call-seq:
- * array.repeated_combination(n) {|combination| ... } -> self
- * array.repeated_combination(n) -> new_enumerator
+ * repeated_combination(size) {|combination| ... } -> self
+ * repeated_combination(size) -> new_enumerator
*
- * Calls the block with each repeated combination of length +n+ of the elements of +self+;
- * each combination is an \Array;
+ * With a block given, calls the block with each repeated combination of length +size+
+ * of the elements of +self+;
+ * each combination is an array;
* returns +self+. The order of the combinations is indeterminate.
*
- * When a block and a positive \Integer argument +n+ are given, calls the block with each
- * +n+-tuple repeated combination of the elements of +self+.
- * The number of combinations is <tt>(n+1)(n+2)/2</tt>.
- *
- * +n+ = 1:
+ * If a positive integer argument +size+ is given,
+ * calls the block with each +size+-tuple repeated combination of the elements of +self+.
+ * The number of combinations is <tt>(size+1)(size+2)/2</tt>.
*
- * a = [0, 1, 2]
- * a.repeated_combination(1) {|combination| p combination }
- *
- * Output:
- *
- * [0]
- * [1]
- * [2]
- *
- * +n+ = 2:
- *
- * a.repeated_combination(2) {|combination| p combination }
+ * Examples:
*
- * Output:
+ * - +size+ is 1:
*
- * [0, 0]
- * [0, 1]
- * [0, 2]
- * [1, 1]
- * [1, 2]
- * [2, 2]
+ * c = []
+ * [0, 1, 2].repeated_combination(1) {|combination| c.push(combination) }
+ * c # => [[0], [1], [2]]
*
- * If +n+ is zero, calls the block once with an empty \Array.
+ * - +size+ is 2:
*
- * If +n+ is negative, does not call the block:
+ * c = []
+ * [0, 1, 2].repeated_combination(2) {|combination| c.push(combination) }
+ * c # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]]
*
- * a.repeated_combination(-1) {|combination| fail 'Cannot happen' }
+ * If +size+ is zero, calls the block once with an empty array.
*
- * Returns a new \Enumerator if no block given:
+ * If +size+ is negative, does not call the block:
*
- * a = [0, 1, 2]
- * a.repeated_combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
+ * [0, 1, 2].repeated_combination(-1) {|combination| fail 'Cannot happen' }
*
- * Using Enumerators, it's convenient to show the combinations and counts
- * for some values of +n+:
- *
- * e = a.repeated_combination(0)
- * e.size # => 1
- * e.to_a # => [[]]
- * e = a.repeated_combination(1)
- * e.size # => 3
- * e.to_a # => [[0], [1], [2]]
- * e = a.repeated_combination(2)
- * e.size # => 6
- * e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]]
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -7554,62 +7621,55 @@ rb_ary_repeated_combination(VALUE ary, VALUE num)
/*
* call-seq:
- * array.product(*other_arrays) -> new_array
- * array.product(*other_arrays) {|combination| ... } -> self
+ * product(*other_arrays) -> new_array
+ * product(*other_arrays) {|combination| ... } -> self
*
- * Computes and returns or yields all combinations of elements from all the Arrays,
+ * Computes all combinations of elements from all the arrays,
* including both +self+ and +other_arrays+:
*
* - The number of combinations is the product of the sizes of all the arrays,
* including both +self+ and +other_arrays+.
* - The order of the returned combinations is indeterminate.
*
- * When no block is given, returns the combinations as an \Array of Arrays:
- *
- * a = [0, 1, 2]
- * a1 = [3, 4]
- * a2 = [5, 6]
- * p = a.product(a1)
- * p.size # => 6 # a.size * a1.size
- * p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]]
- * p = a.product(a1, a2)
- * p.size # => 12 # a.size * a1.size * a2.size
- * p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
- *
- * If any argument is an empty \Array, returns an empty \Array.
- *
- * If no argument is given, returns an \Array of 1-element Arrays,
- * each containing an element of +self+:
+ * With no block given, returns the combinations as an array of arrays:
*
- * a.product # => [[0], [1], [2]]
+ * p = [0, 1].product([2, 3])
+ * # => [[0, 2], [0, 3], [1, 2], [1, 3]]
+ * p.size # => 4
+ * p = [0, 1].product([2, 3], [4, 5])
+ * # => [[0, 2, 4], [0, 2, 5], [0, 3, 4], [0, 3, 5], [1, 2, 4], [1, 2, 5], [1, 3, 4], [1, 3,...
+ * p.size # => 8
*
- * When a block is given, yields each combination as an \Array; returns +self+:
+ * If +self+ or any argument is empty, returns an empty array:
*
- * a.product(a1) {|combination| p combination }
+ * [].product([2, 3], [4, 5]) # => []
+ * [0, 1].product([2, 3], []) # => []
*
- * Output:
+ * If no argument is given, returns an array of 1-element arrays,
+ * each containing an element of +self+:
*
- * [0, 3]
- * [0, 4]
- * [1, 3]
- * [1, 4]
- * [2, 3]
- * [2, 4]
+ * a.product # => [[0], [1], [2]]
*
- * If any argument is an empty \Array, does not call the block:
+ * With a block given, calls the block with each combination; returns +self+:
*
- * a.product(a1, a2, []) {|combination| fail 'Cannot happen' }
+ * p = []
+ * [0, 1].product([2, 3]) {|combination| p.push(combination) }
+ * p # => [[0, 2], [0, 3], [1, 2], [1, 3]]
*
- * If no argument is given, yields each element of +self+ as a 1-element \Array:
+ * If +self+ or any argument is empty, does not call the block:
*
- * a.product {|combination| p combination }
+ * [].product([2, 3], [4, 5]) {|combination| fail 'Cannot happen' }
+ * # => []
+ * [0, 1].product([2, 3], []) {|combination| fail 'Cannot happen' }
+ * # => [0, 1]
*
- * Output:
+ * If no argument is given, calls the block with each element of +self+ as a 1-element array:
*
- * [0]
- * [1]
- * [2]
+ * p = []
+ * [0, 1].product {|combination| p.push(combination) }
+ * p # => [[0], [1]]
*
+ * Related: see {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/
static VALUE
@@ -7702,20 +7762,20 @@ done:
/*
* call-seq:
- * array.take(n) -> new_array
+ * take(count) -> new_array
*
- * Returns a new \Array containing the first +n+ element of +self+,
- * where +n+ is a non-negative \Integer;
- * does not modify +self+.
- *
- * Examples:
+ * Returns a new array containing the first +count+ element of +self+
+ * (as available);
+ * +count+ must be a non-negative numeric;
+ * does not modify +self+:
*
- * a = [0, 1, 2, 3, 4, 5]
- * a.take(1) # => [0]
- * a.take(2) # => [0, 1]
- * a.take(50) # => [0, 1, 2, 3, 4, 5]
- * a # => [0, 1, 2, 3, 4, 5]
+ * a = ['a', 'b', 'c', 'd']
+ * a.take(2) # => ["a", "b"]
+ * a.take(2.1) # => ["a", "b"]
+ * a.take(50) # => ["a", "b", "c", "d"]
+ * a.take(0) # => []
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -7730,25 +7790,23 @@ rb_ary_take(VALUE obj, VALUE n)
/*
* call-seq:
- * array.take_while {|element| ... } -> new_array
- * array.take_while -> new_enumerator
- *
- * Returns a new \Array containing zero or more leading elements of +self+;
- * does not modify +self+.
+ * take_while {|element| ... } -> new_array
+ * take_while -> new_enumerator
*
* With a block given, calls the block with each successive element of +self+;
- * stops if the block returns +false+ or +nil+;
- * returns a new \Array containing those elements for which the block returned a truthy value:
+ * stops iterating if the block returns +false+ or +nil+;
+ * returns a new array containing those elements for which the block returned a truthy value:
*
* a = [0, 1, 2, 3, 4, 5]
* a.take_while {|element| element < 3 } # => [0, 1, 2]
- * a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
- * a # => [0, 1, 2, 3, 4, 5]
+ * a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
+ * a.take_while {|element| false } # => []
*
- * With no block given, returns a new \Enumerator:
+ * With no block given, returns a new Enumerator.
*
- * [0, 1].take_while # => #<Enumerator: [0, 1]:take_while>
+ * Does not modify +self+.
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -7765,10 +7823,10 @@ rb_ary_take_while(VALUE ary)
/*
* call-seq:
- * array.drop(n) -> new_array
+ * drop(count) -> new_array
*
- * Returns a new \Array containing all but the first +n+ element of +self+,
- * where +n+ is a non-negative \Integer;
+ * Returns a new array containing all but the first +count+ element of +self+,
+ * where +count+ is a non-negative integer;
* does not modify +self+.
*
* Examples:
@@ -7777,7 +7835,9 @@ rb_ary_take_while(VALUE ary)
* a.drop(0) # => [0, 1, 2, 3, 4, 5]
* a.drop(1) # => [1, 2, 3, 4, 5]
* a.drop(2) # => [2, 3, 4, 5]
+ * a.drop(9) # => []
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -7796,23 +7856,20 @@ rb_ary_drop(VALUE ary, VALUE n)
/*
* call-seq:
- * array.drop_while {|element| ... } -> new_array
- * array.drop_while -> new_enumerator
-
- * Returns a new \Array containing zero or more trailing elements of +self+;
- * does not modify +self+.
+ * drop_while {|element| ... } -> new_array
+ * drop_while -> new_enumerator
*
* With a block given, calls the block with each successive element of +self+;
* stops if the block returns +false+ or +nil+;
- * returns a new \Array _omitting_ those elements for which the block returned a truthy value:
+ * returns a new array _omitting_ those elements for which the block returned a truthy value;
+ * does not modify +self+:
*
* a = [0, 1, 2, 3, 4, 5]
* a.drop_while {|element| element < 3 } # => [3, 4, 5]
*
- * With no block given, returns a new \Enumerator:
- *
- * [0, 1].drop_while # => # => #<Enumerator: [0, 1]:drop_while>
+ * With no block given, returns a new Enumerator.
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -7829,35 +7886,41 @@ rb_ary_drop_while(VALUE ary)
/*
* call-seq:
- * array.any? -> true or false
- * array.any? {|element| ... } -> true or false
- * array.any?(obj) -> true or false
+ * any? -> true or false
+ * any?(object) -> true or false
+ * any? {|element| ... } -> true or false
*
- * Returns +true+ if any element of +self+ meets a given criterion.
+ * Returns whether for any element of +self+, a given criterion is satisfied.
*
- * With no block given and no argument, returns +true+ if +self+ has any truthy element,
- * +false+ otherwise:
+ * With no block and no argument, returns whether any element of +self+ is truthy:
*
- * [nil, 0, false].any? # => true
- * [nil, false].any? # => false
- * [].any? # => false
+ * [nil, false, []].any? # => true # Array object is truthy.
+ * [nil, false, {}].any? # => true # Hash object is truthy.
+ * [nil, false, ''].any? # => true # String object is truthy.
+ * [nil, false].any? # => false # Nil and false are not truthy.
*
- * With a block given and no argument, calls the block with each element in +self+;
- * returns +true+ if the block returns any truthy value, +false+ otherwise:
+ * With argument +object+ given,
+ * returns whether <tt>object === ele</tt> for any element +ele+ in +self+:
*
- * [0, 1, 2].any? {|element| element > 1 } # => true
- * [0, 1, 2].any? {|element| element > 2 } # => false
+ * [nil, false, 0].any?(0) # => true
+ * [nil, false, 1].any?(0) # => false
+ * [nil, false, 'food'].any?(/foo/) # => true
+ * [nil, false, 'food'].any?(/bar/) # => false
*
- * If argument +obj+ is given, returns +true+ if +obj+.<tt>===</tt> any element,
- * +false+ otherwise:
+ * With a block given,
+ * calls the block with each element in +self+;
+ * returns whether the block returns any truthy value:
+ *
+ * [0, 1, 2].any? {|ele| ele < 1 } # => true
+ * [0, 1, 2].any? {|ele| ele < 0 } # => false
+ *
+ * With both a block and argument +object+ given,
+ * ignores the block and uses +object+ as above.
*
- * ['food', 'drink'].any?(/foo/) # => true
- * ['food', 'drink'].any?(/bar/) # => false
- * [].any?(/foo/) # => false
- * [0, 1, 2].any?(1) # => true
- * [0, 1, 2].any?(3) # => false
+ * <b>Special case</b>: returns +false+ if +self+ is empty
+ * (regardless of any given argument or block).
*
- * Related: Enumerable#any?
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -7890,34 +7953,41 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.all? -> true or false
- * array.all? {|element| ... } -> true or false
- * array.all?(obj) -> true or false
+ * all? -> true or false
+ * all?(object) -> true or false
+ * all? {|element| ... } -> true or false
*
- * Returns +true+ if all elements of +self+ meet a given criterion.
+ * Returns whether for every element of +self+,
+ * a given criterion is satisfied.
*
- * With no block given and no argument, returns +true+ if +self+ contains only truthy elements,
- * +false+ otherwise:
+ * With no block and no argument,
+ * returns whether every element of +self+ is truthy:
*
- * [0, 1, :foo].all? # => true
- * [0, nil, 2].all? # => false
- * [].all? # => true
+ * [[], {}, '', 0, 0.0, Object.new].all? # => true # All truthy objects.
+ * [[], {}, '', 0, 0.0, nil].all? # => false # nil is not truthy.
+ * [[], {}, '', 0, 0.0, false].all? # => false # false is not truthy.
*
- * With a block given and no argument, calls the block with each element in +self+;
- * returns +true+ if the block returns only truthy values, +false+ otherwise:
+ * With argument +object+ given, returns whether <tt>object === ele</tt>
+ * for every element +ele+ in +self+:
*
- * [0, 1, 2].all? { |element| element < 3 } # => true
- * [0, 1, 2].all? { |element| element < 2 } # => false
+ * [0, 0, 0].all?(0) # => true
+ * [0, 1, 2].all?(1) # => false
+ * ['food', 'fool', 'foot'].all?(/foo/) # => true
+ * ['food', 'drink'].all?(/foo/) # => false
*
- * If argument +obj+ is given, returns +true+ if <tt>obj.===</tt> every element, +false+ otherwise:
+ * With a block given, calls the block with each element in +self+;
+ * returns whether the block returns only truthy values:
*
- * ['food', 'fool', 'foot'].all?(/foo/) # => true
- * ['food', 'drink'].all?(/bar/) # => false
- * [].all?(/foo/) # => true
- * [0, 0, 0].all?(0) # => true
- * [0, 1, 2].all?(1) # => false
+ * [0, 1, 2].all? { |ele| ele < 3 } # => true
+ * [0, 1, 2].all? { |ele| ele < 2 } # => false
*
- * Related: Enumerable#all?
+ * With both a block and argument +object+ given,
+ * ignores the block and uses +object+ as above.
+ *
+ * <b>Special case</b>: returns +true+ if +self+ is empty
+ * (regardless of any given argument or block).
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -7950,34 +8020,35 @@ rb_ary_all_p(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.none? -> true or false
- * array.none? {|element| ... } -> true or false
- * array.none?(obj) -> true or false
+ * none? -> true or false
+ * none?(object) -> true or false
+ * none? {|element| ... } -> true or false
*
- * Returns +true+ if no element of +self+ meet a given criterion.
+ * Returns +true+ if no element of +self+ meets a given criterion, +false+ otherwise.
*
* With no block given and no argument, returns +true+ if +self+ has no truthy elements,
* +false+ otherwise:
*
- * [nil, false].none? # => true
+ * [nil, false].none? # => true
* [nil, 0, false].none? # => false
- * [].none? # => true
+ * [].none? # => true
+ *
+ * With argument +object+ given, returns +false+ if for any element +element+,
+ * <tt>object === element</tt>; +true+ otherwise:
*
- * With a block given and no argument, calls the block with each element in +self+;
+ * ['food', 'drink'].none?(/bar/) # => true
+ * ['food', 'drink'].none?(/foo/) # => false
+ * [].none?(/foo/) # => true
+ * [0, 1, 2].none?(3) # => true
+ * [0, 1, 2].none?(1) # => false
+ *
+ * With a block given, calls the block with each element in +self+;
* returns +true+ if the block returns no truthy value, +false+ otherwise:
*
* [0, 1, 2].none? {|element| element > 3 } # => true
* [0, 1, 2].none? {|element| element > 1 } # => false
*
- * If argument +obj+ is given, returns +true+ if <tt>obj.===</tt> no element, +false+ otherwise:
- *
- * ['food', 'drink'].none?(/bar/) # => true
- * ['food', 'drink'].none?(/foo/) # => false
- * [].none?(/foo/) # => true
- * [0, 1, 2].none?(3) # => true
- * [0, 1, 2].none?(1) # => false
- *
- * Related: Enumerable#none?
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -8010,9 +8081,9 @@ rb_ary_none_p(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.one? -> true or false
- * array.one? {|element| ... } -> true or false
- * array.one?(obj) -> true or false
+ * one? -> true or false
+ * one? {|element| ... } -> true or false
+ * one?(object) -> true or false
*
* Returns +true+ if exactly one element of +self+ meets a given criterion.
*
@@ -8024,14 +8095,14 @@ rb_ary_none_p(int argc, VALUE *argv, VALUE ary)
* [nil, nil].one? # => false
* [].one? # => false
*
- * With a block given and no argument, calls the block with each element in +self+;
+ * With a block given, calls the block with each element in +self+;
* returns +true+ if the block a truthy value for exactly one element, +false+ otherwise:
*
* [0, 1, 2].one? {|element| element > 0 } # => false
* [0, 1, 2].one? {|element| element > 1 } # => true
* [0, 1, 2].one? {|element| element > 2 } # => false
*
- * If argument +obj+ is given, returns +true+ if <tt>obj.===</tt> exactly one element,
+ * With argument +object+ given, returns +true+ if for exactly one element +element+, <tt>object === element</tt>;
* +false+ otherwise:
*
* [0, 1, 2].one?(0) # => true
@@ -8041,7 +8112,7 @@ rb_ary_none_p(int argc, VALUE *argv, VALUE ary)
* ['food', 'drink'].one?(/foo/) # => true
* [].one?(/foo/) # => false
*
- * Related: Enumerable#one?
+ * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/
static VALUE
@@ -8084,11 +8155,11 @@ rb_ary_one_p(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
- * array.dig(index, *identifiers) -> object
+ * dig(index, *identifiers) -> object
*
- * Finds and returns the object in nested objects
- * that is specified by +index+ and +identifiers+.
- * The nested objects may be instances of various classes.
+ * Finds and returns the object in nested object
+ * specified by +index+ and +identifiers+;
+ * the nested objects may be instances of various classes.
* See {Dig Methods}[rdoc-ref:dig_methods.rdoc].
*
* Examples:
@@ -8099,6 +8170,7 @@ rb_ary_one_p(int argc, VALUE *argv, VALUE ary)
* a.dig(1, 2, 0) # => :bat
* a.dig(1, 2, 3) # => nil
*
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE
@@ -8127,40 +8199,41 @@ finish_exact_sum(long n, VALUE r, VALUE v, int z)
/*
* call-seq:
- * array.sum(init = 0) -> object
- * array.sum(init = 0) {|element| ... } -> object
+ * sum(init = 0) -> object
+ * sum(init = 0) {|element| ... } -> object
*
- * When no block is given, returns the object equivalent to:
+ * With no block given, returns the sum of +init+ and all elements of +self+;
+ * for array +array+ and value +init+, equivalent to:
*
* sum = init
* array.each {|element| sum += element }
* sum
*
- * For example, <tt>[e1, e2, e3].sum</tt> returns <tt>init + e1 + e2 + e3</tt>.
+ * For example, <tt>[e0, e1, e2].sum</tt> returns <tt>init + e0 + e1 + e2</tt>.
*
* Examples:
*
- * a = [0, 1, 2, 3]
- * a.sum # => 6
- * a.sum(100) # => 106
+ * [0, 1, 2, 3].sum # => 6
+ * [0, 1, 2, 3].sum(100) # => 106
+ * ['abc', 'def', 'ghi'].sum('jkl') # => "jklabcdefghi"
+ * [[:foo, :bar], ['foo', 'bar']].sum([2, 3])
+ * # => [2, 3, :foo, :bar, "foo", "bar"]
*
- * The elements need not be numeric, but must be <tt>+</tt>-compatible
- * with each other and with +init+:
+ * The +init+ value and elements need not be numeric, but must all be <tt>+</tt>-compatible:
*
- * a = ['abc', 'def', 'ghi']
- * a.sum('jkl') # => "jklabcdefghi"
+ * # Raises TypeError: Array can't be coerced into Integer.
+ * [[:foo, :bar], ['foo', 'bar']].sum(2)
*
- * When a block is given, it is called with each element
- * and the block's return value (instead of the element itself) is used as the addend:
+ * With a block given, calls the block with each element of +self+;
+ * the block's return value (instead of the element itself) is used as the addend:
*
- * a = ['zero', 1, :two]
- * s = a.sum('Coerced and concatenated: ') {|element| element.to_s }
- * s # => "Coerced and concatenated: zero1two"
+ * ['zero', 1, :two].sum('Coerced and concatenated: ') {|element| element.to_s }
+ * # => "Coerced and concatenated: zero1two"
*
* Notes:
*
* - Array#join and Array#flatten may be faster than Array#sum
- * for an \Array of Strings or an \Array of Arrays.
+ * for an array of strings or an array of arrays.
* - Array#sum method may not respect method redefinition of "+" methods such as Integer#+.
*
*/
@@ -8282,6 +8355,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
return v;
}
+/* :nodoc: */
static VALUE
rb_ary_deconstruct(VALUE ary)
{
@@ -8289,15 +8363,37 @@ rb_ary_deconstruct(VALUE ary)
}
/*
- * An \Array is an ordered, integer-indexed collection of objects, called _elements_.
- * Any object (even another array) may be an array element,
- * and an array can contain objects of different types.
+ * An \Array object is an ordered, integer-indexed collection of objects,
+ * called _elements_;
+ * the object represents
+ * an {array data structure}[https://en.wikipedia.org/wiki/Array_(data_structure)].
+ *
+ * An element may be any object (even another array);
+ * elements may be any mixture of objects of different types.
+ *
+ * Important data structures that use arrays include:
+ *
+ * - {Coordinate vector}[https://en.wikipedia.org/wiki/Coordinate_vector].
+ * - {Matrix}[https://en.wikipedia.org/wiki/Matrix_(mathematics)].
+ * - {Heap}[https://en.wikipedia.org/wiki/Heap_(data_structure)].
+ * - {Hash table}[https://en.wikipedia.org/wiki/Hash_table].
+ * - {Deque (double-ended queue)}[https://en.wikipedia.org/wiki/Double-ended_queue].
+ * - {Queue}[https://en.wikipedia.org/wiki/Queue_(abstract_data_type)].
+ * - {Stack}[https://en.wikipedia.org/wiki/Stack_(abstract_data_type)].
+ *
+ * There are also array-like data structures:
+ *
+ * - {Associative array}[https://en.wikipedia.org/wiki/Associative_array] (see Hash).
+ * - {Directory}[https://en.wikipedia.org/wiki/Directory_(computing)] (see Dir).
+ * - {Environment}[https://en.wikipedia.org/wiki/Environment_variable] (see ENV).
+ * - {Set}[https://en.wikipedia.org/wiki/Set_(abstract_data_type)] (see Set).
+ * - {String}[https://en.wikipedia.org/wiki/String_(computer_science)] (see String).
*
* == \Array Indexes
*
* \Array indexing starts at 0, as in C or Java.
*
- * A positive index is an offset from the first element:
+ * A non-negative index is an offset from the first element:
*
* - Index 0 indicates the first element.
* - Index 1 indicates the second element.
@@ -8309,6 +8405,9 @@ rb_ary_deconstruct(VALUE ary)
* - Index -2 indicates the next-to-last element.
* - ...
*
+ *
+ * === In-Range and Out-of-Range Indexes
+ *
* A non-negative index is <i>in range</i> if and only if it is smaller than
* the size of the array. For a 3-element array:
*
@@ -8321,31 +8420,32 @@ rb_ary_deconstruct(VALUE ary)
* - Indexes -1 through -3 are in range.
* - Index -4 is out of range.
*
+ * === Effective Index
+ *
* Although the effective index into an array is always an integer,
- * some methods (both within and outside of class \Array)
+ * some methods (both within class \Array and elsewhere)
* accept one or more non-integer arguments that are
* {integer-convertible objects}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
*
- *
* == Creating Arrays
*
* You can create an \Array object explicitly with:
*
- * - An {array literal}[rdoc-ref:literals.rdoc@Array+Literals]:
+ * - An {array literal}[rdoc-ref:syntax/literals.rdoc@Array+Literals]:
*
* [1, 'one', :one, [2, 'two', :two]]
*
- * - A {%w or %W: string-array Literal}[rdoc-ref:literals.rdoc@25w+and+-25W-3A+String-Array+Literals]:
+ * - A {%w or %W string-array Literal}[rdoc-ref:syntax/literals.rdoc@w-and-w-String-Array-Literals]:
*
* %w[foo bar baz] # => ["foo", "bar", "baz"]
* %w[1 % *] # => ["1", "%", "*"]
*
- * - A {%i pr %I: symbol-array Literal}[rdoc-ref:literals.rdoc@25i+and+-25I-3A+Symbol-Array+Literals]:
+ * - A {%i or %I symbol-array Literal}[rdoc-ref:syntax/literals.rdoc@i+and-I-Symbol-Array+Literals]:
*
* %i[foo bar baz] # => [:foo, :bar, :baz]
* %i[1 % *] # => [:"1", :%, :*]
*
- * - \Method Kernel#Array:
+ * - Method Kernel#Array:
*
* Array(["a", "b"]) # => ["a", "b"]
* Array(1..5) # => [1, 2, 3, 4, 5]
@@ -8354,7 +8454,7 @@ rb_ary_deconstruct(VALUE ary)
* Array(1) # => [1]
* Array({:a => "a", :b => "b"}) # => [[:a, "a"], [:b, "b"]]
*
- * - \Method Array.new:
+ * - Method Array.new:
*
* Array.new # => []
* Array.new(3) # => [nil, nil, nil]
@@ -8409,8 +8509,8 @@ rb_ary_deconstruct(VALUE ary)
*
* == Example Usage
*
- * In addition to the methods it mixes in through the Enumerable module, the
- * \Array class has proprietary methods for accessing, searching and otherwise
+ * In addition to the methods it mixes in through the Enumerable module,
+ * class \Array has proprietary methods for accessing, searching and otherwise
* manipulating arrays.
*
* Some of the more common ones are illustrated below.
@@ -8460,7 +8560,7 @@ rb_ary_deconstruct(VALUE ary)
*
* == Obtaining Information about an \Array
*
- * Arrays keep track of their own length at all times. To query an array
+ * An array keeps track of its own length at all times. To query an array
* about the number of elements it contains, use #length, #count or #size.
*
* browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
@@ -8475,7 +8575,7 @@ rb_ary_deconstruct(VALUE ary)
*
* browsers.include?('Konqueror') #=> false
*
- * == Adding Items to Arrays
+ * == Adding Items to an \Array
*
* Items can be added to the end of an array by using either #push or #<<
*
@@ -8536,11 +8636,11 @@ rb_ary_deconstruct(VALUE ary)
* arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
* arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
*
- * == Iterating over Arrays
+ * == Iterating over an \Array
*
- * Like all classes that include the Enumerable module, \Array has an each
+ * Like all classes that include the Enumerable module, class \Array has an each
* method, which defines what elements should be iterated over and how. In
- * case of Array's #each, all elements in the \Array instance are yielded to
+ * case of Array#each, all elements in +self+ are yielded to
* the supplied block in sequence.
*
* Note that this operation leaves the array unchanged.
@@ -8600,10 +8700,10 @@ rb_ary_deconstruct(VALUE ary)
*
* == What's Here
*
- * First, what's elsewhere. \Class \Array:
+ * First, what's elsewhere. Class \Array:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats-Here].
+ * - Includes {module Enumerable}[rdoc-ref:Enumerable@Whats-Here],
* which provides dozens of additional methods.
*
* Here, class \Array provides methods that are useful for:
@@ -8625,148 +8725,132 @@ rb_ary_deconstruct(VALUE ary)
* - ::new: Returns a new array.
* - ::try_convert: Returns a new array created from a given object.
*
+ * See also {Creating Arrays}[rdoc-ref:Array@Creating+Arrays].
+ *
* === Methods for Querying
*
- * - #length, #size: Returns the count of elements.
- * - #include?: Returns whether any element <tt>==</tt> a given object.
- * - #empty?: Returns whether there are no elements.
* - #all?: Returns whether all elements meet a given criterion.
* - #any?: Returns whether any element meets a given criterion.
+ * - #count: Returns the count of elements that meet a given criterion.
+ * - #empty?: Returns whether there are no elements.
+ * - #find_index (aliased as #index): Returns the index of the first element that meets a given criterion.
+ * - #hash: Returns the integer hash code.
+ * - #include?: Returns whether any element <tt>==</tt> a given object.
+ * - #length (aliased as #size): Returns the count of elements.
* - #none?: Returns whether no element <tt>==</tt> a given object.
* - #one?: Returns whether exactly one element <tt>==</tt> a given object.
- * - #count: Returns the count of elements that meet a given criterion.
- * - #find_index, #index: Returns the index of the first element that meets a given criterion.
* - #rindex: Returns the index of the last element that meets a given criterion.
- * - #hash: Returns the integer hash code.
*
* === Methods for Comparing
*
- * - #<=>: Returns -1, 0, or 1 * as +self+ is less than, equal to, or
- * greater than a given object.
- * - #==: Returns whether each element in +self+ is <tt>==</tt> to the corresponding element
- * in a given object.
- * - #eql?: Returns whether each element in +self+ is <tt>eql?</tt> to the corresponding
- * element in a given object.
+ * - #<=>: Returns -1, 0, or 1, as +self+ is less than, equal to, or greater than a given object.
+ * - #==: Returns whether each element in +self+ is <tt>==</tt> to the corresponding element in a given object.
+ * - #eql?: Returns whether each element in +self+ is <tt>eql?</tt> to the corresponding element in a given object.
* === Methods for Fetching
*
* These methods do not modify +self+.
*
- * - #[]: Returns one or more elements.
- * - #fetch: Returns the element at a given offset.
- * - #first: Returns one or more leading elements.
- * - #last: Returns one or more trailing elements.
- * - #max: Returns one or more maximum-valued elements,
- * as determined by <tt><=></tt> or a given block.
- * - #min: Returns one or more minimum-valued elements,
- * as determined by <tt><=></tt> or a given block.
- * - #minmax: Returns the minimum-valued and maximum-valued elements,
- * as determined by <tt><=></tt> or a given block.
- * - #assoc: Returns the first element that is an array
- * whose first element <tt>==</tt> a given object.
- * - #rassoc: Returns the first element that is an array
- * whose second element <tt>==</tt> a given object.
+ * - #[] (aliased as #slice): Returns consecutive elements as determined by a given argument.
+ * - #assoc: Returns the first element that is an array whose first element <tt>==</tt> a given object.
* - #at: Returns the element at a given offset.
- * - #values_at: Returns the elements at given offsets.
- * - #dig: Returns the object in nested objects
- * that is specified by a given index and additional arguments.
+ * - #bsearch: Returns an element selected via a binary search as determined by a given block.
+ * - #bsearch_index: Returns the index of an element selected via a binary search as determined by a given block.
+ * - #compact: Returns an array containing all non-+nil+ elements.
+ * - #dig: Returns the object in nested objects that is specified by a given index and additional arguments.
* - #drop: Returns trailing elements as determined by a given index.
- * - #take: Returns leading elements as determined by a given index.
* - #drop_while: Returns trailing elements as determined by a given block.
- * - #take_while: Returns leading elements as determined by a given block.
- * - #slice: Returns consecutive elements as determined by a given argument.
- * - #sort: Returns all elements in an order determined by <tt><=></tt> or a given block.
+ * - #fetch: Returns the element at a given offset.
+ * - #fetch_values: Returns elements at given offsets.
+ * - #first: Returns one or more leading elements.
+ * - #last: Returns one or more trailing elements.
+ * - #max: Returns one or more maximum-valued elements, as determined by <tt>#<=></tt> or a given block.
+ * - #min: Returns one or more minimum-valued elements, as determined by <tt>#<=></tt> or a given block.
+ * - #minmax: Returns the minimum-valued and maximum-valued elements, as determined by <tt>#<=></tt> or a given block.
+ * - #rassoc: Returns the first element that is an array whose second element <tt>==</tt> a given object.
+ * - #reject: Returns an array containing elements not rejected by a given block.
* - #reverse: Returns all elements in reverse order.
- * - #compact: Returns an array containing all non-+nil+ elements.
- * - #select, #filter: Returns an array containing elements selected by a given block.
- * - #uniq: Returns an array containing non-duplicate elements.
* - #rotate: Returns all elements with some rotated from one end to the other.
- * - #bsearch: Returns an element selected via a binary search
- * as determined by a given block.
- * - #bsearch_index: Returns the index of an element selected via a binary search
- * as determined by a given block.
* - #sample: Returns one or more random elements.
+ * - #select (aliased as #filter): Returns an array containing elements selected by a given block.
* - #shuffle: Returns elements in a random order.
+ * - #sort: Returns all elements in an order determined by <tt>#<=></tt> or a given block.
+ * - #take: Returns leading elements as determined by a given index.
+ * - #take_while: Returns leading elements as determined by a given block.
+ * - #uniq: Returns an array containing non-duplicate elements.
+ * - #values_at: Returns the elements at given offsets.
*
* === Methods for Assigning
*
* These methods add, replace, or reorder elements in +self+.
*
+ * - #<<: Appends an element.
* - #[]=: Assigns specified elements with a given object.
- * - #push, #append, #<<: Appends trailing elements.
- * - #unshift, #prepend: Prepends leading elements.
- * - #insert: Inserts given objects at a given offset; does not replace elements.
* - #concat: Appends all elements from given arrays.
* - #fill: Replaces specified elements with specified objects.
- * - #replace: Replaces the content of +self+ with the content of a given array.
+ * - #flatten!: Replaces each nested array in +self+ with the elements from that array.
+ * - #initialize_copy (aliased as #replace): Replaces the content of +self+ with the content of a given array.
+ * - #insert: Inserts given objects at a given offset; does not replace elements.
+ * - #push (aliased as #append): Appends elements.
* - #reverse!: Replaces +self+ with its elements reversed.
* - #rotate!: Replaces +self+ with its elements rotated.
* - #shuffle!: Replaces +self+ with its elements in random order.
- * - #sort!: Replaces +self+ with its elements sorted,
- * as determined by <tt><=></tt> or a given block.
+ * - #sort!: Replaces +self+ with its elements sorted, as determined by <tt>#<=></tt> or a given block.
* - #sort_by!: Replaces +self+ with its elements sorted, as determined by a given block.
+ * - #unshift (aliased as #prepend): Prepends leading elements.
*
* === Methods for Deleting
*
* Each of these methods removes elements from +self+:
*
- * - #pop: Removes and returns the last element.
- * - #shift: Removes and returns the first element.
+ * - #clear: Removes all elements.
* - #compact!: Removes all +nil+ elements.
* - #delete: Removes elements equal to a given object.
* - #delete_at: Removes the element at a given offset.
* - #delete_if: Removes elements specified by a given block.
* - #keep_if: Removes elements not specified by a given block.
+ * - #pop: Removes and returns the last element.
* - #reject!: Removes elements specified by a given block.
- * - #select!, #filter!: Removes elements not specified by a given block.
+ * - #select! (aliased as #filter!): Removes elements not specified by a given block.
+ * - #shift: Removes and returns the first element.
* - #slice!: Removes and returns a sequence of elements.
* - #uniq!: Removes duplicates.
*
* === Methods for Combining
*
* - #&: Returns an array containing elements found both in +self+ and a given array.
- * - #intersection: Returns an array containing elements found both in +self+
- * and in each given array.
* - #+: Returns an array containing all elements of +self+ followed by all elements of a given array.
* - #-: Returns an array containing all elements of +self+ that are not found in a given array.
- * - #|: Returns an array containing all elements of +self+ and all elements of a given array,
- * duplicates removed.
- * - #union: Returns an array containing all elements of +self+ and all elements of given arrays,
- * duplicates removed.
- * - #difference: Returns an array containing all elements of +self+ that are not found
- * in any of the given arrays..
+ * - #|: Returns an array containing all element of +self+ and all elements of a given array, duplicates removed.
+ * - #difference: Returns an array containing all elements of +self+ that are not found in any of the given arrays..
+ * - #intersection: Returns an array containing elements found both in +self+ and in each given array.
* - #product: Returns or yields all combinations of elements from +self+ and given arrays.
+ * - #reverse: Returns an array containing all elements of +self+ in reverse order.
+ * - #union: Returns an array containing all elements of +self+ and all elements of given arrays, duplicates removed.
*
* === Methods for Iterating
*
+ * - #combination: Calls a given block with combinations of elements of +self+; a combination does not use the same element more than once.
+ * - #cycle: Calls a given block with each element, then does so again, for a specified number of times, or forever.
* - #each: Passes each element to a given block.
- * - #reverse_each: Passes each element, in reverse order, to a given block.
* - #each_index: Passes each element index to a given block.
- * - #cycle: Calls a given block with each element, then does so again,
- * for a specified number of times, or forever.
- * - #combination: Calls a given block with combinations of elements of +self+;
- * a combination does not use the same element more than once.
- * - #permutation: Calls a given block with permutations of elements of +self+;
- * a permutation does not use the same element more than once.
- * - #repeated_combination: Calls a given block with combinations of elements of +self+;
- * a combination may use the same element more than once.
- * - #repeated_permutation: Calls a given block with permutations of elements of +self+;
- * a permutation may use the same element more than once.
+ * - #permutation: Calls a given block with permutations of elements of +self+; a permutation does not use the same element more than once.
+ * - #repeated_combination: Calls a given block with combinations of elements of +self+; a combination may use the same element more than once.
+ * - #repeated_permutation: Calls a given block with permutations of elements of +self+; a permutation may use the same element more than once.
+ * - #reverse_each: Passes each element, in reverse order, to a given block.
*
* === Methods for Converting
*
- * - #map, #collect: Returns an array containing the block return-value for each element.
- * - #map!, #collect!: Replaces each element with a block return-value.
+ * - #collect (aliased as #map): Returns an array containing the block return-value for each element.
+ * - #collect! (aliased as #map!): Replaces each element with a block return-value.
* - #flatten: Returns an array that is a recursive flattening of +self+.
- * - #flatten!: Replaces each nested array in +self+ with the elements from that array.
- * - #inspect, #to_s: Returns a new String containing the elements.
- * - #join: Returns a newsString containing the elements joined by the field separator.
+ * - #inspect (aliased as #to_s): Returns a new String containing the elements.
+ * - #join: Returns a new String containing the elements joined by the field separator.
* - #to_a: Returns +self+ or a new array containing all elements.
* - #to_ary: Returns +self+.
* - #to_h: Returns a new hash formed from the elements.
* - #transpose: Transposes +self+, which must be an array of arrays.
- * - #zip: Returns a new array of arrays containing +self+ and given arrays;
- * follow the link for details.
+ * - #zip: Returns a new array of arrays containing +self+ and given arrays.
*
* === Other Methods
*
@@ -8777,7 +8861,6 @@ rb_ary_deconstruct(VALUE ary)
* - With string argument +field_separator+, a new string that is equivalent to
* <tt>join(field_separator)</tt>.
*
- * - #abbrev: Returns a hash of unambiguous abbreviations for elements.
* - #pack: Packs the elements into a binary sequence.
* - #sum: Returns a sum of elements according to either <tt>+</tt> or a given block.
*/
@@ -8785,6 +8868,8 @@ rb_ary_deconstruct(VALUE ary)
void
Init_Array(void)
{
+ fake_ary_flags = init_fake_ary_flags();
+
rb_cArray = rb_define_class("Array", rb_cObject);
rb_include_module(rb_cArray, rb_mEnumerable);
@@ -8809,8 +8894,6 @@ Init_Array(void)
rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
rb_define_method(rb_cArray, "at", rb_ary_at, 1);
rb_define_method(rb_cArray, "fetch", rb_ary_fetch, -1);
- rb_define_method(rb_cArray, "first", rb_ary_first, -1);
- rb_define_method(rb_cArray, "last", rb_ary_last, -1);
rb_define_method(rb_cArray, "concat", rb_ary_concat_multi, -1);
rb_define_method(rb_cArray, "union", rb_ary_union_multi, -1);
rb_define_method(rb_cArray, "difference", rb_ary_difference_multi, -1);
@@ -8830,6 +8913,9 @@ Init_Array(void)
rb_define_method(rb_cArray, "length", rb_ary_length, 0);
rb_define_method(rb_cArray, "size", rb_ary_length, 0);
rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0);
+ rb_define_method(rb_cArray, "find", rb_ary_find, -1);
+ rb_define_method(rb_cArray, "detect", rb_ary_find, -1);
+ rb_define_method(rb_cArray, "rfind", rb_ary_rfind, -1);
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);
@@ -8907,8 +8993,12 @@ Init_Array(void)
rb_define_method(rb_cArray, "one?", rb_ary_one_p, -1);
rb_define_method(rb_cArray, "dig", rb_ary_dig, -1);
rb_define_method(rb_cArray, "sum", rb_ary_sum, -1);
+ rb_define_method(rb_cArray, "freeze", rb_ary_freeze, 0);
rb_define_method(rb_cArray, "deconstruct", rb_ary_deconstruct, 0);
+
+ rb_cArray_empty_frozen = RB_OBJ_SET_SHAREABLE(rb_ary_freeze(rb_ary_new()));
+ rb_vm_register_global_object(rb_cArray_empty_frozen);
}
#include "array.rbinc"
diff --git a/array.rb b/array.rb
index b9fa9844e6..7ee4e09a4c 100644
--- a/array.rb
+++ b/array.rb
@@ -1,62 +1,97 @@
class Array
# call-seq:
- # array.shuffle!(random: Random) -> array
+ # shuffle!(random: Random) -> self
#
- # Shuffles the elements of +self+ in place.
- # a = [1, 2, 3] #=> [1, 2, 3]
- # a.shuffle! #=> [2, 3, 1]
- # a #=> [2, 3, 1]
+ # Shuffles all elements in +self+ into a random order,
+ # as selected by the object given by the keyword argument +random+.
+ # Returns +self+:
#
- # The optional +random+ argument will be used as the random number generator:
- # a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ # a.shuffle! # => [5, 3, 8, 7, 6, 1, 9, 4, 2, 0]
+ # a.shuffle! # => [9, 4, 0, 6, 2, 8, 1, 5, 3, 7]
+ #
+ # Duplicate elements are included:
+ #
+ # a = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
+ # a.shuffle! # => [1, 0, 0, 1, 1, 0, 1, 0, 0, 1]
+ # a.shuffle! # => [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]
+ #
+ # The object given with the keyword argument +random+ is used as the random number generator.
+ #
+ # Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
def shuffle!(random: Random)
Primitive.rb_ary_shuffle_bang(random)
end
# call-seq:
- # array.shuffle(random: Random) -> new_ary
+ # shuffle(random: Random) -> new_array
+ #
+ # Returns a new array containing all elements from +self+ in a random order,
+ # as selected by the object given by the keyword argument +random+:
+ #
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ # a.shuffle # => [0, 8, 1, 9, 6, 3, 4, 7, 2, 5]
+ # a.shuffle # => [8, 9, 0, 5, 1, 2, 6, 4, 7, 3]
#
- # Returns a new array with elements of +self+ shuffled.
- # a = [1, 2, 3] #=> [1, 2, 3]
- # a.shuffle #=> [2, 3, 1]
- # a #=> [1, 2, 3]
+ # Duplicate elements are included:
#
- # The optional +random+ argument will be used as the random number generator:
- # a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
+ # a = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
+ # a.shuffle # => [1, 0, 1, 1, 0, 0, 1, 0, 0, 1]
+ # a.shuffle # => [1, 1, 0, 0, 0, 1, 1, 0, 0, 1]
+ #
+ # The object given with the keyword argument +random+ is used as the random number generator.
+ #
+ # Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
def shuffle(random: Random)
Primitive.rb_ary_shuffle(random)
end
# call-seq:
- # array.sample(random: Random) -> object
- # array.sample(n, random: Random) -> new_ary
+ # sample(random: Random) -> object
+ # sample(count, random: Random) -> new_ary
#
- # Returns random elements from +self+.
+ # Returns random elements from +self+,
+ # as selected by the object given by the keyword argument +random+.
#
- # When no arguments are given, returns a random element from +self+:
- # a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- # a.sample # => 3
- # a.sample # => 8
- # If +self+ is empty, returns +nil+.
+ # With no argument +count+ given, returns one random element from +self+:
+ #
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ # a.sample # => 3
+ # a.sample # => 8
+ #
+ # Returns +nil+ if +self+ is empty:
+ #
+ # [].sample # => nil
+ #
+ # With a non-negative numeric argument +count+ given,
+ # returns a new array containing +count+ random elements from +self+:
+ #
+ # a.sample(3) # => [8, 9, 2]
+ # a.sample(6) # => [9, 6, 0, 3, 1, 4]
+ #
+ # The order of the result array is unrelated to the order of +self+.
+ #
+ # Returns a new empty array if +self+ is empty:
+ #
+ # [].sample(4) # => []
+ #
+ # May return duplicates in +self+:
+ #
+ # a = [1, 1, 1, 2, 2, 3]
+ # a.sample(a.size) # => [1, 1, 3, 2, 1, 2]
#
- # When argument +n+ is given, returns a new \Array containing +n+ random
- # elements from +self+:
- # a.sample(3) # => [8, 9, 2]
- # a.sample(6) # => [9, 6, 10, 3, 1, 4]
# Returns no more than <tt>a.size</tt> elements
# (because no new duplicates are introduced):
- # a.sample(a.size * 2) # => [6, 4, 1, 8, 5, 9, 10, 2, 3, 7]
- # But +self+ may contain duplicates:
- # a = [1, 1, 1, 2, 2, 3]
- # a.sample(a.size * 2) # => [1, 1, 3, 2, 1, 2]
- # The argument +n+ must be a non-negative numeric value.
- # The order of the result array is unrelated to the order of +self+.
- # Returns a new empty \Array if +self+ is empty.
#
- # The optional +random+ argument will be used as the random number generator:
- # a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- # a.sample(random: Random.new(1)) #=> 6
- # a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
+ # a.sample(50) # => [6, 4, 1, 8, 5, 9, 0, 2, 3, 7]
+ #
+ # The object given with the keyword argument +random+ is used as the random number generator:
+ #
+ # a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ # a.sample(random: Random.new(1)) # => 6
+ # a.sample(4, random: Random.new(1)) # => [6, 10, 9, 2]
+ #
+ # Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
def sample(n = (ary = false), random: Random)
if Primitive.mandatory_only?
# Primitive.cexpr! %{ rb_ary_sample(self, rb_cRandom, Qfalse, Qfalse) }
@@ -66,4 +101,207 @@ class Array
Primitive.ary_sample(random, n, ary)
end
end
+
+ # call-seq:
+ # first -> object or nil
+ # first(count) -> new_array
+ #
+ # Returns elements from +self+, or +nil+; does not modify +self+.
+ #
+ # With no argument given, returns the first element (if available):
+ #
+ # a = [:foo, 'bar', 2]
+ # a.first # => :foo
+ # a # => [:foo, "bar", 2]
+ #
+ # If +self+ is empty, returns +nil+.
+ #
+ # [].first # => nil
+ #
+ # With a non-negative integer argument +count+ given,
+ # returns the first +count+ elements (as available) in a new array:
+ #
+ # a.first(0) # => []
+ # a.first(2) # => [:foo, "bar"]
+ # a.first(50) # => [:foo, "bar", 2]
+ #
+ # Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
+ def first n = unspecified = true
+ if Primitive.mandatory_only?
+ Primitive.attr! :leaf
+ Primitive.cexpr! %q{ ary_first(self) }
+ else
+ if unspecified
+ Primitive.cexpr! %q{ ary_first(self) }
+ else
+ Primitive.cexpr! %q{ ary_take_first_or_last_n(self, NUM2LONG(n), ARY_TAKE_FIRST) }
+ end
+ end
+ end
+
+ # call-seq:
+ # last -> last_object or nil
+ # last(count) -> new_array
+ #
+ # Returns elements from +self+, or +nil+; +self+ is not modified.
+ #
+ # With no argument given, returns the last element, or +nil+ if +self+ is empty:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last # => 2
+ # a # => [:foo, "bar", 2]
+ # [].last # => nil
+ #
+ #
+ # With non-negative integer argument +count+ given,
+ # returns a new array containing the trailing +count+ elements of +self+, as available:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last(2) # => ["bar", 2]
+ # a.last(50) # => [:foo, "bar", 2]
+ # a.last(0) # => []
+ # [].last(3) # => []
+ #
+ # Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
+ def last n = unspecified = true
+ if Primitive.mandatory_only?
+ Primitive.attr! :leaf
+ Primitive.cexpr! %q{ ary_last(self) }
+ else
+ if unspecified
+ Primitive.cexpr! %q{ ary_last(self) }
+ else
+ Primitive.cexpr! %q{ ary_take_first_or_last_n(self, NUM2LONG(n), ARY_TAKE_LAST) }
+ end
+ end
+ end
+
+ # call-seq:
+ # fetch_values(*indexes) -> new_array
+ # fetch_values(*indexes) { |index| ... } -> new_array
+ #
+ # With no block given, returns a new array containing the elements of +self+
+ # at the offsets specified by +indexes+. Each of the +indexes+ must be an
+ # {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]:
+ #
+ # a = [:foo, :bar, :baz]
+ # a.fetch_values(2, 0) # => [:baz, :foo]
+ # a.fetch_values(2.1, 0) # => [:baz, :foo]
+ # a.fetch_values # => []
+ #
+ # For a negative index, counts backwards from the end of the array:
+ #
+ # a.fetch_values(-2, -1) # [:bar, :baz]
+ #
+ # When no block is given, raises an exception if any index is out of range.
+ #
+ # With a block given, for each index:
+ #
+ # - If the index is in range, uses an element of +self+ (as above).
+ # - Otherwise, calls the block with the index and uses the block's return value.
+ #
+ # Example:
+ #
+ # a = [:foo, :bar, :baz]
+ # a.fetch_values(1, 0, 42, 777) { |index| index.to_s }
+ # # => [:bar, :foo, "42", "777"]
+ #
+ # Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
+ def fetch_values(*indexes, &block)
+ indexes.map! { |i| fetch(i, &block) }
+ indexes
+ end
+
+ with_jit do
+ if Primitive.rb_builtin_basic_definition_p(:each)
+ undef :each
+
+ def each # :nodoc:
+ Primitive.attr! :inline_block, :c_trace, :without_interrupts
+
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)'
+ end
+ i = 0
+ until Primitive.rb_jit_ary_at_end(i)
+ yield Primitive.rb_jit_ary_at(i)
+ i = Primitive.rb_jit_fixnum_inc(i)
+ end
+ self
+ end
+ end
+
+ if Primitive.rb_builtin_basic_definition_p(:map)
+ undef :map
+
+ def map # :nodoc:
+ Primitive.attr! :inline_block, :c_trace, :without_interrupts
+
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)'
+ end
+
+ i = 0
+ result = Primitive.ary_sized_alloc
+ until Primitive.rb_jit_ary_at_end(i)
+ value = yield(Primitive.rb_jit_ary_at(i))
+ Primitive.rb_jit_ary_push(result, value)
+ i = Primitive.rb_jit_fixnum_inc(i)
+ end
+ result
+ end
+
+ if Primitive.rb_builtin_basic_definition_p(:collect)
+ undef :collect
+ alias collect map
+ end
+ end
+
+ if Primitive.rb_builtin_basic_definition_p(:select)
+ undef :select
+
+ def select # :nodoc:
+ Primitive.attr! :inline_block, :c_trace, :without_interrupts
+
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)'
+ end
+
+ i = 0
+ result = Primitive.ary_sized_alloc
+ until Primitive.rb_jit_ary_at_end(i)
+ value = Primitive.rb_jit_ary_at(i)
+ if yield value
+ Primitive.rb_jit_ary_push(result, value)
+ end
+ i = Primitive.rb_jit_fixnum_inc(i)
+ end
+ result
+ end
+
+ if Primitive.rb_builtin_basic_definition_p(:filter)
+ undef :filter
+ alias filter select
+ end
+ end
+
+ if Primitive.rb_builtin_basic_definition_p(:find)
+ undef :find
+
+ def find(if_none_proc = nil) # :nodoc:
+ Primitive.attr! :inline_block, :c_trace, :without_interrupts
+
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)'
+ end
+ i = 0
+ until Primitive.rb_jit_ary_at_end(i)
+ value = Primitive.rb_jit_ary_at(i)
+ return value if yield(value)
+ i = Primitive.rb_jit_fixnum_inc(i)
+ end
+ if_none_proc&.call
+ end
+ end
+ end
end
diff --git a/ast.c b/ast.c
index d60e5d3fcf..1ddc2b5791 100644
--- a/ast.c
+++ b/ast.c
@@ -1,6 +1,6 @@
/* indent-tabs-mode: nil */
#include "internal.h"
-#include "internal/parse.h"
+#include "internal/ruby_parser.h"
#include "internal/symbol.h"
#include "internal/warnings.h"
#include "iseq.h"
@@ -14,9 +14,10 @@
static VALUE rb_mAST;
static VALUE rb_cNode;
+static VALUE rb_cLocation;
struct ASTNodeData {
- rb_ast_t *ast;
+ VALUE ast_value;
const NODE *node;
};
@@ -24,14 +25,20 @@ static void
node_gc_mark(void *ptr)
{
struct ASTNodeData *data = (struct ASTNodeData *)ptr;
- rb_gc_mark((VALUE)data->ast);
+ rb_gc_mark(data->ast_value);
}
static size_t
node_memsize(const void *ptr)
{
struct ASTNodeData *data = (struct ASTNodeData *)ptr;
- return rb_ast_memsize(data->ast);
+ size_t size = sizeof(struct ASTNodeData);
+ if (data->ast_value) {
+ rb_ast_t *ast = rb_ruby_ast_data_get(data->ast_value);
+ size += rb_ast_memsize(ast);
+ }
+
+ return size;
}
static const rb_data_type_t rb_node_type = {
@@ -41,25 +48,51 @@ static const rb_data_type_t rb_node_type = {
RUBY_TYPED_FREE_IMMEDIATELY,
};
+struct ASTLocationData {
+ int first_lineno;
+ int first_column;
+ int last_lineno;
+ int last_column;
+};
+
+static void
+location_gc_mark(void *ptr)
+{
+}
+
+static size_t
+location_memsize(const void *ptr)
+{
+ return sizeof(struct ASTLocationData);
+}
+
+static const rb_data_type_t rb_location_type = {
+ "AST/location",
+ {location_gc_mark, RUBY_TYPED_DEFAULT_FREE, location_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+
static VALUE rb_ast_node_alloc(VALUE klass);
static void
-setup_node(VALUE obj, rb_ast_t *ast, const NODE *node)
+setup_node(VALUE obj, VALUE ast_value, const NODE *node)
{
struct ASTNodeData *data;
TypedData_Get_Struct(obj, struct ASTNodeData, &rb_node_type, data);
- data->ast = ast;
+ data->ast_value = ast_value;
data->node = node;
}
static VALUE
-ast_new_internal(rb_ast_t *ast, const NODE *node)
+ast_new_internal(VALUE ast_value, const NODE *node)
{
VALUE obj;
obj = rb_ast_node_alloc(rb_cNode);
- setup_node(obj, ast, node);
+ setup_node(obj, ast_value, node);
return obj;
}
@@ -74,14 +107,26 @@ ast_parse_new(void)
}
static VALUE
-ast_parse_done(rb_ast_t *ast)
+ast_parse_done(VALUE ast_value)
{
+ rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
+
if (!ast->body.root) {
rb_ast_dispose(ast);
rb_exc_raise(GET_EC()->errinfo);
}
- return ast_new_internal(ast, (NODE *)ast->body.root);
+ return ast_new_internal(ast_value, (NODE *)ast->body.root);
+}
+
+static VALUE
+setup_vparser(VALUE keep_script_lines, VALUE error_tolerant, VALUE keep_tokens)
+{
+ VALUE vparser = ast_parse_new();
+ if (RTEST(keep_script_lines)) rb_parser_set_script_lines(vparser);
+ if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
+ if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
+ return vparser;
}
static VALUE
@@ -93,15 +138,11 @@ ast_s_parse(rb_execution_context_t *ec, VALUE module, VALUE str, VALUE keep_scri
static VALUE
rb_ast_parse_str(VALUE str, VALUE keep_script_lines, VALUE error_tolerant, VALUE keep_tokens)
{
- rb_ast_t *ast = 0;
-
+ VALUE ast_value = Qnil;
StringValue(str);
- VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
- if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
- if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
- ast = rb_parser_compile_string_path(vparser, Qnil, str, 1);
- return ast_parse_done(ast);
+ VALUE vparser = setup_vparser(keep_script_lines, error_tolerant, keep_tokens);
+ ast_value = rb_parser_compile_string_path(vparser, Qnil, str, 1);
+ return ast_parse_done(ast_value);
}
static VALUE
@@ -114,49 +155,29 @@ static VALUE
rb_ast_parse_file(VALUE path, VALUE keep_script_lines, VALUE error_tolerant, VALUE keep_tokens)
{
VALUE f;
- rb_ast_t *ast = 0;
+ VALUE ast_value = Qnil;
rb_encoding *enc = rb_utf8_encoding();
- FilePathValue(path);
f = rb_file_open_str(path, "r");
rb_funcall(f, rb_intern("set_encoding"), 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
- VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
- if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
- if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
- ast = rb_parser_compile_file_path(vparser, Qnil, f, 1);
+ VALUE vparser = setup_vparser(keep_script_lines, error_tolerant, keep_tokens);
+ ast_value = rb_parser_compile_file_path(vparser, Qnil, f, 1);
rb_io_close(f);
- return ast_parse_done(ast);
-}
-
-static VALUE
-lex_array(VALUE array, int index)
-{
- VALUE str = rb_ary_entry(array, index);
- if (!NIL_P(str)) {
- StringValue(str);
- if (!rb_enc_asciicompat(rb_enc_get(str))) {
- rb_raise(rb_eArgError, "invalid source encoding");
- }
- }
- return str;
+ return ast_parse_done(ast_value);
}
static VALUE
rb_ast_parse_array(VALUE array, VALUE keep_script_lines, VALUE error_tolerant, VALUE keep_tokens)
{
- rb_ast_t *ast = 0;
+ VALUE ast_value = Qnil;
array = rb_check_array_type(array);
- VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
- if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
- if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
- ast = rb_parser_compile_generic(vparser, lex_array, Qnil, array, 1);
- return ast_parse_done(ast);
+ VALUE vparser = setup_vparser(keep_script_lines, error_tolerant, keep_tokens);
+ ast_value = rb_parser_compile_array(vparser, Qnil, array, 1);
+ return ast_parse_done(ast_value);
}
-static VALUE node_children(rb_ast_t*, const NODE*);
+static VALUE node_children(VALUE, const NODE*);
static VALUE
node_find(VALUE self, const int node_id)
@@ -168,7 +189,7 @@ node_find(VALUE self, const int node_id)
if (nd_node_id(data->node) == node_id) return self;
- ary = node_children(data->ast, data->node);
+ ary = node_children(data->ast_value, data->node);
for (i = 0; i < RARRAY_LEN(ary); i++) {
VALUE child = RARRAY_AREF(ary, i);
@@ -185,20 +206,6 @@ node_find(VALUE self, const int node_id)
extern VALUE rb_e_script;
static VALUE
-script_lines(VALUE path)
-{
- VALUE hash, lines;
- ID script_lines;
- CONST_ID(script_lines, "SCRIPT_LINES__");
- if (!rb_const_defined_at(rb_cObject, script_lines)) return Qnil;
- hash = rb_const_get_at(rb_cObject, script_lines);
- if (!RB_TYPE_P(hash, T_HASH)) return Qnil;
- lines = rb_hash_lookup(hash, path);
- if (!RB_TYPE_P(lines, T_ARRAY)) return Qnil;
- return lines;
-}
-
-static VALUE
node_id_for_backtrace_location(rb_execution_context_t *ec, VALUE module, VALUE location)
{
int node_id;
@@ -245,6 +252,11 @@ ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body, VALUE keep_script
if (!iseq) {
return Qnil;
}
+
+ if (ISEQ_BODY(iseq)->prism) {
+ rb_raise(rb_eRuntimeError, "cannot get AST for ISEQ compiled by prism");
+ }
+
lines = ISEQ_BODY(iseq)->variable.script_lines;
VALUE path = rb_iseq_path(iseq);
@@ -254,7 +266,7 @@ ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body, VALUE keep_script
rb_raise(rb_eArgError, "cannot get AST for method defined in eval");
}
- if (!NIL_P(lines) || !NIL_P(lines = script_lines(path))) {
+ if (!NIL_P(lines)) {
node = rb_ast_parse_array(lines, keep_script_lines, error_tolerant, keep_tokens);
}
else if (e_option) {
@@ -300,10 +312,10 @@ ast_node_node_id(rb_execution_context_t *ec, VALUE self)
return INT2FIX(nd_node_id(data->node));
}
-#define NEW_CHILD(ast, node) node ? ast_new_internal(ast, node) : Qnil
+#define NEW_CHILD(ast_value, node) (node ? ast_new_internal(ast_value, node) : Qnil)
static VALUE
-rb_ary_new_from_node_args(rb_ast_t *ast, long n, ...)
+rb_ary_new_from_node_args(VALUE ast_value, long n, ...)
{
va_list ar;
VALUE ary;
@@ -315,39 +327,57 @@ rb_ary_new_from_node_args(rb_ast_t *ast, long n, ...)
for (i=0; i<n; i++) {
NODE *node;
node = va_arg(ar, NODE *);
- rb_ary_push(ary, NEW_CHILD(ast, node));
+ rb_ary_push(ary, NEW_CHILD(ast_value, node));
}
va_end(ar);
return ary;
}
static VALUE
-dump_block(rb_ast_t *ast, const NODE *node)
+dump_block(VALUE ast_value, const struct RNode_BLOCK *node)
{
VALUE ary = rb_ary_new();
do {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
+ rb_ary_push(ary, NEW_CHILD(ast_value, node->nd_head));
} while (node->nd_next &&
nd_type_p(node->nd_next, NODE_BLOCK) &&
- (node = node->nd_next, 1));
+ (node = RNODE_BLOCK(node->nd_next), 1));
if (node->nd_next) {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
+ rb_ary_push(ary, NEW_CHILD(ast_value, node->nd_next));
}
return ary;
}
static VALUE
-dump_array(rb_ast_t *ast, const NODE *node)
+dump_array(VALUE ast_value, const struct RNode_LIST *node)
{
VALUE ary = rb_ary_new();
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
+ rb_ary_push(ary, NEW_CHILD(ast_value, node->nd_head));
while (node->nd_next && nd_type_p(node->nd_next, NODE_LIST)) {
- node = node->nd_next;
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
+ node = RNODE_LIST(node->nd_next);
+ rb_ary_push(ary, NEW_CHILD(ast_value, node->nd_head));
+ }
+ rb_ary_push(ary, NEW_CHILD(ast_value, node->nd_next));
+
+ return ary;
+}
+
+static VALUE
+dump_parser_array(VALUE ast_value, rb_parser_ary_t *p_ary)
+{
+ VALUE ary;
+
+ if (p_ary->data_type != PARSER_ARY_DATA_NODE) {
+ rb_bug("unexpected rb_parser_ary_data_type: %d", p_ary->data_type);
+ }
+
+ ary = rb_ary_new();
+
+ for (long i = 0; i < p_ary->len; i++) {
+ rb_ary_push(ary, NEW_CHILD(ast_value, p_ary->data[i]));
}
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
return ary;
}
@@ -369,307 +399,354 @@ no_name_rest(void)
}
static VALUE
-rest_arg(rb_ast_t *ast, const NODE *rest_arg)
+rest_arg(VALUE ast_value, const NODE *rest_arg)
{
- return NODE_NAMED_REST_P(rest_arg) ? NEW_CHILD(ast, rest_arg) : no_name_rest();
+ return NODE_NAMED_REST_P(rest_arg) ? NEW_CHILD(ast_value, rest_arg) : no_name_rest();
+}
+
+static ID
+node_colon_name(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_COLON2:
+ return RNODE_COLON2(node)->nd_mid;
+ case NODE_COLON3:
+ return RNODE_COLON3(node)->nd_mid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
}
static VALUE
-node_children(rb_ast_t *ast, const NODE *node)
+node_children(VALUE ast_value, const NODE *node)
{
char name[sizeof("$") + DECIMAL_SIZE_OF(long)];
enum node_type type = nd_type(node);
switch (type) {
case NODE_BLOCK:
- return dump_block(ast, node);
+ return dump_block(ast_value, RNODE_BLOCK(node));
case NODE_IF:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_IF(node)->nd_cond, RNODE_IF(node)->nd_body, RNODE_IF(node)->nd_else);
case NODE_UNLESS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_UNLESS(node)->nd_cond, RNODE_UNLESS(node)->nd_body, RNODE_UNLESS(node)->nd_else);
case NODE_CASE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_CASE(node)->nd_head, RNODE_CASE(node)->nd_body);
case NODE_CASE2:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_CASE2(node)->nd_head, RNODE_CASE2(node)->nd_body);
case NODE_CASE3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_CASE3(node)->nd_head, RNODE_CASE3(node)->nd_body);
case NODE_WHEN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_WHEN(node)->nd_head, RNODE_WHEN(node)->nd_body, RNODE_WHEN(node)->nd_next);
case NODE_IN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_IN(node)->nd_head, RNODE_IN(node)->nd_body, RNODE_IN(node)->nd_next);
case NODE_WHILE:
case NODE_UNTIL:
- return rb_ary_push(rb_ary_new_from_node_args(ast, 2, node->nd_cond, node->nd_body),
- RBOOL(node->nd_state));
+ return rb_ary_push(rb_ary_new_from_node_args(ast_value, 2, RNODE_WHILE(node)->nd_cond, RNODE_WHILE(node)->nd_body),
+ RBOOL(RNODE_WHILE(node)->nd_state));
case NODE_ITER:
case NODE_FOR:
- return rb_ary_new_from_node_args(ast, 2, node->nd_iter, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_ITER(node)->nd_iter, RNODE_ITER(node)->nd_body);
case NODE_FOR_MASGN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_var);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_FOR_MASGN(node)->nd_var);
case NODE_BREAK:
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_BREAK(node)->nd_stts);
case NODE_NEXT:
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_NEXT(node)->nd_stts);
case NODE_RETURN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_stts);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_RETURN(node)->nd_stts);
case NODE_REDO:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_RETRY:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_BEGIN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_BEGIN(node)->nd_body);
case NODE_RESCUE:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_resq, node->nd_else);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_RESCUE(node)->nd_head, RNODE_RESCUE(node)->nd_resq, RNODE_RESCUE(node)->nd_else);
case NODE_RESBODY:
- return rb_ary_new_from_node_args(ast, 3, node->nd_args, node->nd_body, node->nd_head);
+ return rb_ary_new_from_node_args(ast_value, 4, RNODE_RESBODY(node)->nd_args, RNODE_RESBODY(node)->nd_exc_var, RNODE_RESBODY(node)->nd_body, RNODE_RESBODY(node)->nd_next);
case NODE_ENSURE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_ensr);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_ENSURE(node)->nd_head, RNODE_ENSURE(node)->nd_ensr);
case NODE_AND:
case NODE_OR:
{
VALUE ary = rb_ary_new();
while (1) {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_1st));
- if (!node->nd_2nd || !nd_type_p(node->nd_2nd, type))
+ rb_ary_push(ary, NEW_CHILD(ast_value, RNODE_AND(node)->nd_1st));
+ if (!RNODE_AND(node)->nd_2nd || !nd_type_p(RNODE_AND(node)->nd_2nd, type))
break;
- node = node->nd_2nd;
+ node = RNODE_AND(node)->nd_2nd;
}
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_2nd));
+ rb_ary_push(ary, NEW_CHILD(ast_value, RNODE_AND(node)->nd_2nd));
return ary;
}
case NODE_MASGN:
- if (NODE_NAMED_REST_P(node->nd_args)) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_value, node->nd_head, node->nd_args);
+ if (NODE_NAMED_REST_P(RNODE_MASGN(node)->nd_args)) {
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_MASGN(node)->nd_value, RNODE_MASGN(node)->nd_head, RNODE_MASGN(node)->nd_args);
}
else {
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_value),
- NEW_CHILD(ast, node->nd_head),
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_MASGN(node)->nd_value),
+ NEW_CHILD(ast_value, RNODE_MASGN(node)->nd_head),
no_name_rest());
}
case NODE_LASGN:
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_LASGN(node)->nd_value)) {
+ return rb_ary_new_from_args(2, var_name(RNODE_LASGN(node)->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
+ }
+ return rb_ary_new_from_args(2, var_name(RNODE_LASGN(node)->nd_vid), NEW_CHILD(ast_value, RNODE_LASGN(node)->nd_value));
case NODE_DASGN:
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_DASGN(node)->nd_value)) {
+ return rb_ary_new_from_args(2, var_name(RNODE_DASGN(node)->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
+ }
+ return rb_ary_new_from_args(2, var_name(RNODE_DASGN(node)->nd_vid), NEW_CHILD(ast_value, RNODE_DASGN(node)->nd_value));
case NODE_IASGN:
+ return rb_ary_new_from_args(2, var_name(RNODE_IASGN(node)->nd_vid), NEW_CHILD(ast_value, RNODE_IASGN(node)->nd_value));
case NODE_CVASGN:
+ return rb_ary_new_from_args(2, var_name(RNODE_CVASGN(node)->nd_vid), NEW_CHILD(ast_value, RNODE_CVASGN(node)->nd_value));
case NODE_GASGN:
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- return rb_ary_new_from_args(2, var_name(node->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
- }
- return rb_ary_new_from_args(2, var_name(node->nd_vid), NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(2, var_name(RNODE_GASGN(node)->nd_vid), NEW_CHILD(ast_value, RNODE_GASGN(node)->nd_value));
case NODE_CDECL:
- if (node->nd_vid) {
- return rb_ary_new_from_args(2, ID2SYM(node->nd_vid), NEW_CHILD(ast, node->nd_value));
+ if (RNODE_CDECL(node)->nd_vid) {
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_CDECL(node)->nd_vid), NEW_CHILD(ast_value, RNODE_CDECL(node)->nd_value));
}
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_else), ID2SYM(node->nd_else->nd_mid), NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_CDECL(node)->nd_else), ID2SYM(node_colon_name(RNODE_CDECL(node)->nd_else)), NEW_CHILD(ast_value, RNODE_CDECL(node)->nd_value));
case NODE_OP_ASGN1:
- return rb_ary_new_from_args(4, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args->nd_head),
- NEW_CHILD(ast, node->nd_args->nd_body));
+ return rb_ary_new_from_args(4, NEW_CHILD(ast_value, RNODE_OP_ASGN1(node)->nd_recv),
+ ID2SYM(RNODE_OP_ASGN1(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_OP_ASGN1(node)->nd_index),
+ NEW_CHILD(ast_value, RNODE_OP_ASGN1(node)->nd_rvalue));
case NODE_OP_ASGN2:
- return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv),
- RBOOL(node->nd_next->nd_aid),
- ID2SYM(node->nd_next->nd_vid),
- ID2SYM(node->nd_next->nd_mid),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(5, NEW_CHILD(ast_value, RNODE_OP_ASGN2(node)->nd_recv),
+ RBOOL(RNODE_OP_ASGN2(node)->nd_aid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_vid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_OP_ASGN2(node)->nd_value));
case NODE_OP_ASGN_AND:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idANDOP),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_OP_ASGN_AND(node)->nd_head), ID2SYM(idANDOP),
+ NEW_CHILD(ast_value, RNODE_OP_ASGN_AND(node)->nd_value));
case NODE_OP_ASGN_OR:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idOROP),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_OP_ASGN_OR(node)->nd_head), ID2SYM(idOROP),
+ NEW_CHILD(ast_value, RNODE_OP_ASGN_OR(node)->nd_value));
case NODE_OP_CDECL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head),
- ID2SYM(node->nd_aid),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_OP_CDECL(node)->nd_head),
+ ID2SYM(RNODE_OP_CDECL(node)->nd_aid),
+ NEW_CHILD(ast_value, RNODE_OP_CDECL(node)->nd_value));
case NODE_CALL:
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_CALL(node)->nd_recv),
+ ID2SYM(RNODE_CALL(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_CALL(node)->nd_args));
case NODE_OPCALL:
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_OPCALL(node)->nd_recv),
+ ID2SYM(RNODE_OPCALL(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_OPCALL(node)->nd_args));
case NODE_QCALL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_QCALL(node)->nd_recv),
+ ID2SYM(RNODE_QCALL(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_QCALL(node)->nd_args));
case NODE_FCALL:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_FCALL(node)->nd_mid),
+ NEW_CHILD(ast_value, RNODE_FCALL(node)->nd_args));
case NODE_VCALL:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_VCALL(node)->nd_mid));
case NODE_SUPER:
- return rb_ary_new_from_node_args(ast, 1, node->nd_args);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_SUPER(node)->nd_args);
case NODE_ZSUPER:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_LIST:
- case NODE_VALUES:
- return dump_array(ast, node);
+ return dump_array(ast_value, RNODE_LIST(node));
case NODE_ZLIST:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_HASH:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_HASH(node)->nd_head);
case NODE_YIELD:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_YIELD(node)->nd_head);
case NODE_LVAR:
+ return rb_ary_new_from_args(1, var_name(RNODE_LVAR(node)->nd_vid));
case NODE_DVAR:
- return rb_ary_new_from_args(1, var_name(node->nd_vid));
+ return rb_ary_new_from_args(1, var_name(RNODE_DVAR(node)->nd_vid));
case NODE_IVAR:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_IVAR(node)->nd_vid));
case NODE_CONST:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_CONST(node)->nd_vid));
case NODE_CVAR:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_CVAR(node)->nd_vid));
case NODE_GVAR:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_vid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_GVAR(node)->nd_vid));
case NODE_NTH_REF:
- snprintf(name, sizeof(name), "$%ld", node->nd_nth);
+ snprintf(name, sizeof(name), "$%ld", RNODE_NTH_REF(node)->nd_nth);
return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
case NODE_BACK_REF:
name[0] = '$';
- name[1] = (char)node->nd_nth;
+ name[1] = (char)RNODE_BACK_REF(node)->nd_nth;
name[2] = '\0';
return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
+ case NODE_MATCH:
+ return rb_ary_new_from_args(1, rb_node_regx_string_val(node));
case NODE_MATCH2:
- if (node->nd_args) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_recv, node->nd_value, node->nd_args);
+ if (RNODE_MATCH2(node)->nd_args) {
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_MATCH2(node)->nd_recv, RNODE_MATCH2(node)->nd_value, RNODE_MATCH2(node)->nd_args);
}
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_MATCH2(node)->nd_recv, RNODE_MATCH2(node)->nd_value);
case NODE_MATCH3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
- case NODE_MATCH:
- case NODE_LIT:
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_MATCH3(node)->nd_recv, RNODE_MATCH3(node)->nd_value);
case NODE_STR:
case NODE_XSTR:
- return rb_ary_new_from_args(1, node->nd_lit);
+ return rb_ary_new_from_args(1, rb_node_str_string_val(node));
+ case NODE_INTEGER:
+ return rb_ary_new_from_args(1, rb_node_integer_literal_val(node));
+ case NODE_FLOAT:
+ return rb_ary_new_from_args(1, rb_node_float_literal_val(node));
+ case NODE_RATIONAL:
+ return rb_ary_new_from_args(1, rb_node_rational_literal_val(node));
+ case NODE_IMAGINARY:
+ return rb_ary_new_from_args(1, rb_node_imaginary_literal_val(node));
+ case NODE_REGX:
+ return rb_ary_new_from_args(1, rb_node_regx_string_val(node));
case NODE_ONCE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_ONCE(node)->nd_body);
case NODE_DSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_DSYM:
{
- NODE *n = node->nd_next;
+ struct RNode_LIST *n = RNODE_DSTR(node)->nd_next;
VALUE head = Qnil, next = Qnil;
if (n) {
- head = NEW_CHILD(ast, n->nd_head);
- next = NEW_CHILD(ast, n->nd_next);
+ head = NEW_CHILD(ast_value, n->nd_head);
+ next = NEW_CHILD(ast_value, n->nd_next);
}
- return rb_ary_new_from_args(3, node->nd_lit, head, next);
+ return rb_ary_new_from_args(3, rb_node_dstr_string_val(node), head, next);
}
+ case NODE_SYM:
+ return rb_ary_new_from_args(1, rb_node_sym_string_val(node));
case NODE_EVSTR:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_EVSTR(node)->nd_body);
case NODE_ARGSCAT:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_ARGSCAT(node)->nd_head, RNODE_ARGSCAT(node)->nd_body);
case NODE_ARGSPUSH:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_ARGSPUSH(node)->nd_head, RNODE_ARGSPUSH(node)->nd_body);
case NODE_SPLAT:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_SPLAT(node)->nd_head);
case NODE_BLOCK_PASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_BLOCK_PASS(node)->nd_head, RNODE_BLOCK_PASS(node)->nd_body);
case NODE_DEFN:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_DEFN(node)->nd_mid), NEW_CHILD(ast_value, RNODE_DEFN(node)->nd_defn));
case NODE_DEFS:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_DEFS(node)->nd_recv), ID2SYM(RNODE_DEFS(node)->nd_mid), NEW_CHILD(ast_value, RNODE_DEFS(node)->nd_defn));
case NODE_ALIAS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_ALIAS(node)->nd_1st, RNODE_ALIAS(node)->nd_2nd);
case NODE_VALIAS:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_alias), ID2SYM(node->nd_orig));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_VALIAS(node)->nd_alias), ID2SYM(RNODE_VALIAS(node)->nd_orig));
case NODE_UNDEF:
- return rb_ary_new_from_node_args(ast, 1, node->nd_undef);
+ return rb_ary_new_from_args(1, dump_parser_array(ast_value, RNODE_UNDEF(node)->nd_undefs));
case NODE_CLASS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cpath, node->nd_super, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 3, RNODE_CLASS(node)->nd_cpath, RNODE_CLASS(node)->nd_super, RNODE_CLASS(node)->nd_body);
case NODE_MODULE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_cpath, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_MODULE(node)->nd_cpath, RNODE_MODULE(node)->nd_body);
case NODE_SCLASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_SCLASS(node)->nd_recv, RNODE_SCLASS(node)->nd_body);
case NODE_COLON2:
- return rb_ary_new_from_args(2, NEW_CHILD(ast, node->nd_head), ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(2, NEW_CHILD(ast_value, RNODE_COLON2(node)->nd_head), ID2SYM(RNODE_COLON2(node)->nd_mid));
case NODE_COLON3:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_COLON3(node)->nd_mid));
case NODE_DOT2:
case NODE_DOT3:
case NODE_FLIP2:
case NODE_FLIP3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_beg, node->nd_end);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_DOT2(node)->nd_beg, RNODE_DOT2(node)->nd_end);
case NODE_SELF:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_NIL:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_TRUE:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_FALSE:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_ERRINFO:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_DEFINED:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_DEFINED(node)->nd_head);
case NODE_POSTEXE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_POSTEXE(node)->nd_body);
case NODE_ATTRASGN:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast_value, RNODE_ATTRASGN(node)->nd_recv), ID2SYM(RNODE_ATTRASGN(node)->nd_mid), NEW_CHILD(ast_value, RNODE_ATTRASGN(node)->nd_args));
case NODE_LAMBDA:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast_value, 1, RNODE_LAMBDA(node)->nd_body);
case NODE_OPT_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_OPT_ARG(node)->nd_body, RNODE_OPT_ARG(node)->nd_next);
case NODE_KW_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_KW_ARG(node)->nd_body, RNODE_KW_ARG(node)->nd_next);
case NODE_POSTARG:
- if (NODE_NAMED_REST_P(node->nd_1st)) {
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
+ if (NODE_NAMED_REST_P(RNODE_POSTARG(node)->nd_1st)) {
+ return rb_ary_new_from_node_args(ast_value, 2, RNODE_POSTARG(node)->nd_1st, RNODE_POSTARG(node)->nd_2nd);
}
return rb_ary_new_from_args(2, no_name_rest(),
- NEW_CHILD(ast, node->nd_2nd));
+ NEW_CHILD(ast_value, RNODE_POSTARG(node)->nd_2nd));
case NODE_ARGS:
{
- struct rb_args_info *ainfo = node->nd_ainfo;
+ struct rb_args_info *ainfo = &RNODE_ARGS(node)->nd_ainfo;
return rb_ary_new_from_args(10,
INT2NUM(ainfo->pre_args_num),
- NEW_CHILD(ast, ainfo->pre_init),
- NEW_CHILD(ast, ainfo->opt_args),
+ NEW_CHILD(ast_value, ainfo->pre_init),
+ NEW_CHILD(ast_value, (NODE *)ainfo->opt_args),
var_name(ainfo->first_post_arg),
INT2NUM(ainfo->post_args_num),
- NEW_CHILD(ast, ainfo->post_init),
+ NEW_CHILD(ast_value, ainfo->post_init),
(ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA
? ID2SYM(rb_intern("NODE_SPECIAL_EXCESSIVE_COMMA"))
: var_name(ainfo->rest_arg)),
- (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_args)),
- (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_rest_arg)),
- var_name(ainfo->block_arg));
+ (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast_value, (NODE *)ainfo->kw_args)),
+ (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast_value, ainfo->kw_rest_arg)),
+ (ainfo->no_blockarg ? Qfalse : var_name(ainfo->block_arg)));
}
case NODE_SCOPE:
{
- rb_ast_id_table_t *tbl = node->nd_tbl;
+ rb_ast_id_table_t *tbl = RNODE_SCOPE(node)->nd_tbl;
int i, size = tbl ? tbl->size : 0;
VALUE locals = rb_ary_new_capa(size);
for (i = 0; i < size; i++) {
rb_ary_push(locals, var_name(tbl->ids[i]));
}
- return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, node->nd_args), NEW_CHILD(ast, node->nd_body));
+ return rb_ary_new_from_args(3, locals, NEW_CHILD(ast_value, (NODE *)RNODE_SCOPE(node)->nd_args), NEW_CHILD(ast_value, RNODE_SCOPE(node)->nd_body));
}
case NODE_ARYPTN:
{
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- VALUE rest = rest_arg(ast, apinfo->rest_arg);
+ VALUE rest = rest_arg(ast_value, RNODE_ARYPTN(node)->rest_arg);
return rb_ary_new_from_args(4,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, apinfo->pre_args),
+ NEW_CHILD(ast_value, RNODE_ARYPTN(node)->nd_pconst),
+ NEW_CHILD(ast_value, RNODE_ARYPTN(node)->pre_args),
rest,
- NEW_CHILD(ast, apinfo->post_args));
+ NEW_CHILD(ast_value, RNODE_ARYPTN(node)->post_args));
}
case NODE_FNDPTN:
{
- struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
- VALUE pre_rest = rest_arg(ast, fpinfo->pre_rest_arg);
- VALUE post_rest = rest_arg(ast, fpinfo->post_rest_arg);
+ VALUE pre_rest = rest_arg(ast_value, RNODE_FNDPTN(node)->pre_rest_arg);
+ VALUE post_rest = rest_arg(ast_value, RNODE_FNDPTN(node)->post_rest_arg);
return rb_ary_new_from_args(4,
- NEW_CHILD(ast, node->nd_pconst),
+ NEW_CHILD(ast_value, RNODE_FNDPTN(node)->nd_pconst),
pre_rest,
- NEW_CHILD(ast, fpinfo->args),
+ NEW_CHILD(ast_value, RNODE_FNDPTN(node)->args),
post_rest);
}
case NODE_HSHPTN:
{
- VALUE kwrest = node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD ? ID2SYM(rb_intern("NODE_SPECIAL_NO_REST_KEYWORD")) :
- NEW_CHILD(ast, node->nd_pkwrestarg);
+ VALUE kwrest = RNODE_HSHPTN(node)->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD ? ID2SYM(rb_intern("NODE_SPECIAL_NO_REST_KEYWORD")) :
+ NEW_CHILD(ast_value, RNODE_HSHPTN(node)->nd_pkwrestarg);
return rb_ary_new_from_args(3,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, node->nd_pkwargs),
+ NEW_CHILD(ast_value, RNODE_HSHPTN(node)->nd_pconst),
+ NEW_CHILD(ast_value, RNODE_HSHPTN(node)->nd_pkwargs),
kwrest);
}
+ case NODE_LINE:
+ return rb_ary_new_from_args(1, rb_node_line_lineno_val(node));
+ case NODE_FILE:
+ return rb_ary_new_from_args(1, rb_node_file_path_val(node));
+ case NODE_ENCODING:
+ return rb_ary_new_from_args(1, rb_node_encoding_val(node));
case NODE_ERROR:
- return rb_ary_new_from_node_args(ast, 0);
+ return rb_ary_new_from_node_args(ast_value, 0);
case NODE_ARGS_AUX:
case NODE_LAST:
break;
@@ -684,7 +761,250 @@ ast_node_children(rb_execution_context_t *ec, VALUE self)
struct ASTNodeData *data;
TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
- return node_children(data->ast, data->node);
+ return node_children(data->ast_value, data->node);
+}
+
+static int
+null_loc_p(rb_code_location_t *loc)
+{
+ return (loc->beg_pos.lineno == 0 && loc->beg_pos.column == -1 && loc->end_pos.lineno == 0 && loc->end_pos.column == -1);
+}
+
+static VALUE
+location_new(rb_code_location_t *loc)
+{
+ VALUE obj;
+ struct ASTLocationData *data;
+
+ if (null_loc_p(loc)) return Qnil;
+
+ obj = TypedData_Make_Struct(rb_cLocation, struct ASTLocationData, &rb_location_type, data);
+ data->first_lineno = loc->beg_pos.lineno;
+ data->first_column = loc->beg_pos.column;
+ data->last_lineno = loc->end_pos.lineno;
+ data->last_column = loc->end_pos.column;
+
+ return obj;
+}
+
+static VALUE
+node_locations(VALUE ast_value, const NODE *node)
+{
+ enum node_type type = nd_type(node);
+ switch (type) {
+ case NODE_ALIAS:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_ALIAS(node)->keyword_loc));
+ case NODE_AND:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_AND(node)->operator_loc));
+ case NODE_BLOCK_PASS:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_BLOCK_PASS(node)->operator_loc));
+ case NODE_BREAK:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_BREAK(node)->keyword_loc));
+ case NODE_CASE:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_CASE(node)->case_keyword_loc),
+ location_new(&RNODE_CASE(node)->end_keyword_loc));
+ case NODE_CASE2:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_CASE2(node)->case_keyword_loc),
+ location_new(&RNODE_CASE2(node)->end_keyword_loc));
+ case NODE_CASE3:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_CASE3(node)->case_keyword_loc),
+ location_new(&RNODE_CASE3(node)->end_keyword_loc));
+ case NODE_CLASS:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_CLASS(node)->class_keyword_loc),
+ location_new(&RNODE_CLASS(node)->inheritance_operator_loc),
+ location_new(&RNODE_CLASS(node)->end_keyword_loc));
+ case NODE_COLON2:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_COLON2(node)->delimiter_loc),
+ location_new(&RNODE_COLON2(node)->name_loc));
+ case NODE_COLON3:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_COLON3(node)->delimiter_loc),
+ location_new(&RNODE_COLON3(node)->name_loc));
+ case NODE_DEFINED:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_DEFINED(node)->keyword_loc));
+ case NODE_DOT2:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_DOT2(node)->operator_loc));
+ case NODE_DOT3:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_DOT3(node)->operator_loc));
+ case NODE_EVSTR:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_EVSTR(node)->opening_loc),
+ location_new(&RNODE_EVSTR(node)->closing_loc));
+ case NODE_FLIP2:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_FLIP2(node)->operator_loc));
+ case NODE_FLIP3:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_FLIP3(node)->operator_loc));
+ case NODE_FOR:
+ return rb_ary_new_from_args(5,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_FOR(node)->for_keyword_loc),
+ location_new(&RNODE_FOR(node)->in_keyword_loc),
+ location_new(&RNODE_FOR(node)->do_keyword_loc),
+ location_new(&RNODE_FOR(node)->end_keyword_loc));
+ case NODE_LAMBDA:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_LAMBDA(node)->operator_loc),
+ location_new(&RNODE_LAMBDA(node)->opening_loc),
+ location_new(&RNODE_LAMBDA(node)->closing_loc));
+ case NODE_IF:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_IF(node)->if_keyword_loc),
+ location_new(&RNODE_IF(node)->then_keyword_loc),
+ location_new(&RNODE_IF(node)->end_keyword_loc));
+ case NODE_IN:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_IN(node)->in_keyword_loc),
+ location_new(&RNODE_IN(node)->then_keyword_loc),
+ location_new(&RNODE_IN(node)->operator_loc));
+ case NODE_MODULE:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_MODULE(node)->module_keyword_loc),
+ location_new(&RNODE_MODULE(node)->end_keyword_loc));
+ case NODE_NEXT:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_NEXT(node)->keyword_loc));
+ case NODE_OR:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_OR(node)->operator_loc));
+ case NODE_OP_ASGN1:
+ return rb_ary_new_from_args(5,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_OP_ASGN1(node)->call_operator_loc),
+ location_new(&RNODE_OP_ASGN1(node)->opening_loc),
+ location_new(&RNODE_OP_ASGN1(node)->closing_loc),
+ location_new(&RNODE_OP_ASGN1(node)->binary_operator_loc));
+ case NODE_OP_ASGN2:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_OP_ASGN2(node)->call_operator_loc),
+ location_new(&RNODE_OP_ASGN2(node)->message_loc),
+ location_new(&RNODE_OP_ASGN2(node)->binary_operator_loc));
+ case NODE_POSTEXE:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_POSTEXE(node)->keyword_loc),
+ location_new(&RNODE_POSTEXE(node)->opening_loc),
+ location_new(&RNODE_POSTEXE(node)->closing_loc));
+ case NODE_REDO:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_REDO(node)->keyword_loc));
+ case NODE_REGX:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_REGX(node)->opening_loc),
+ location_new(&RNODE_REGX(node)->content_loc),
+ location_new(&RNODE_REGX(node)->closing_loc));
+ case NODE_RETURN:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_RETURN(node)->keyword_loc));
+
+ case NODE_SCLASS:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_SCLASS(node)->class_keyword_loc),
+ location_new(&RNODE_SCLASS(node)->operator_loc),
+ location_new(&RNODE_SCLASS(node)->end_keyword_loc));
+
+ case NODE_SPLAT:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_SPLAT(node)->operator_loc));
+ case NODE_SUPER:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_SUPER(node)->keyword_loc),
+ location_new(&RNODE_SUPER(node)->lparen_loc),
+ location_new(&RNODE_SUPER(node)->rparen_loc));
+ case NODE_UNDEF:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_UNDEF(node)->keyword_loc));
+ case NODE_UNLESS:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_UNLESS(node)->keyword_loc),
+ location_new(&RNODE_UNLESS(node)->then_keyword_loc),
+ location_new(&RNODE_UNLESS(node)->end_keyword_loc));
+ case NODE_VALIAS:
+ return rb_ary_new_from_args(2,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_VALIAS(node)->keyword_loc));
+ case NODE_WHEN:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_WHEN(node)->keyword_loc),
+ location_new(&RNODE_WHEN(node)->then_keyword_loc));
+ case NODE_WHILE:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_WHILE(node)->keyword_loc),
+ location_new(&RNODE_WHILE(node)->closing_loc));
+ case NODE_UNTIL:
+ return rb_ary_new_from_args(3,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_UNTIL(node)->keyword_loc),
+ location_new(&RNODE_UNTIL(node)->closing_loc));
+ case NODE_YIELD:
+ return rb_ary_new_from_args(4,
+ location_new(nd_code_loc(node)),
+ location_new(&RNODE_YIELD(node)->keyword_loc),
+ location_new(&RNODE_YIELD(node)->lparen_loc),
+ location_new(&RNODE_YIELD(node)->rparen_loc));
+ case NODE_ARGS_AUX:
+ case NODE_LAST:
+ break;
+ default:
+ return rb_ary_new_from_args(1, location_new(nd_code_loc(node)));
+ }
+
+ rb_bug("node_locations: unknown node: %s", ruby_node_name(type));
+}
+
+static VALUE
+ast_node_locations(rb_execution_context_t *ec, VALUE self)
+{
+ struct ASTNodeData *data;
+ TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
+
+ return node_locations(data->ast_value, data->node);
}
static VALUE
@@ -726,10 +1046,37 @@ ast_node_last_column(rb_execution_context_t *ec, VALUE self)
static VALUE
ast_node_all_tokens(rb_execution_context_t *ec, VALUE self)
{
+ long i;
struct ASTNodeData *data;
+ rb_ast_t *ast;
+ rb_parser_ary_t *parser_tokens;
+ rb_parser_ast_token_t *parser_token;
+ VALUE str, loc, token, all_tokens;
+
TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
+ ast = rb_ruby_ast_data_get(data->ast_value);
- return rb_ast_tokens(data->ast);
+ parser_tokens = ast->node_buffer->tokens;
+ if (parser_tokens == NULL) {
+ return Qnil;
+ }
+
+ all_tokens = rb_ary_new2(parser_tokens->len);
+ for (i = 0; i < parser_tokens->len; i++) {
+ parser_token = parser_tokens->data[i];
+ str = rb_str_new(parser_token->str->ptr, parser_token->str->len);
+ loc = rb_ary_new_from_args(4,
+ INT2FIX(parser_token->loc.beg_pos.lineno),
+ INT2FIX(parser_token->loc.beg_pos.column),
+ INT2FIX(parser_token->loc.end_pos.lineno),
+ INT2FIX(parser_token->loc.end_pos.column)
+ );
+ token = rb_ary_new_from_args(4, INT2FIX(parser_token->id), ID2SYM(rb_intern(parser_token->type_name)), str, loc);
+ rb_ary_push(all_tokens, token);
+ }
+ rb_ary_freeze(all_tokens);
+
+ return all_tokens;
}
static VALUE
@@ -756,10 +1103,66 @@ static VALUE
ast_node_script_lines(rb_execution_context_t *ec, VALUE self)
{
struct ASTNodeData *data;
+ rb_ast_t *ast;
TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data);
- VALUE ret = data->ast->body.script_lines;
- if (!RB_TYPE_P(ret, T_ARRAY)) return Qnil;
- return ret;
+ ast = rb_ruby_ast_data_get(data->ast_value);
+ rb_parser_ary_t *ret = ast->body.script_lines;
+ return rb_parser_build_script_lines_from(ret);
+}
+
+static VALUE
+ast_location_first_lineno(rb_execution_context_t *ec, VALUE self)
+{
+ struct ASTLocationData *data;
+ TypedData_Get_Struct(self, struct ASTLocationData, &rb_location_type, data);
+
+ return INT2NUM(data->first_lineno);
+}
+
+static VALUE
+ast_location_first_column(rb_execution_context_t *ec, VALUE self)
+{
+ struct ASTLocationData *data;
+ TypedData_Get_Struct(self, struct ASTLocationData, &rb_location_type, data);
+
+ return INT2NUM(data->first_column);
+}
+
+static VALUE
+ast_location_last_lineno(rb_execution_context_t *ec, VALUE self)
+{
+ struct ASTLocationData *data;
+ TypedData_Get_Struct(self, struct ASTLocationData, &rb_location_type, data);
+
+ return INT2NUM(data->last_lineno);
+}
+
+static VALUE
+ast_location_last_column(rb_execution_context_t *ec, VALUE self)
+{
+ struct ASTLocationData *data;
+ TypedData_Get_Struct(self, struct ASTLocationData, &rb_location_type, data);
+
+ return INT2NUM(data->last_column);
+}
+
+static VALUE
+ast_location_inspect(rb_execution_context_t *ec, VALUE self)
+{
+ VALUE str;
+ VALUE cname;
+ struct ASTLocationData *data;
+ TypedData_Get_Struct(self, struct ASTLocationData, &rb_location_type, data);
+
+ cname = rb_class_path(rb_obj_class(self));
+ str = rb_str_new2("#<");
+
+ rb_str_append(str, cname);
+ rb_str_catf(str, ":@%d:%d-%d:%d>",
+ data->first_lineno, data->first_column,
+ data->last_lineno, data->last_column);
+
+ return str;
}
#include "ast.rbinc"
@@ -769,5 +1172,7 @@ Init_ast(void)
{
rb_mAST = rb_define_module_under(rb_cRubyVM, "AbstractSyntaxTree");
rb_cNode = rb_define_class_under(rb_mAST, "Node", rb_cObject);
+ rb_cLocation = rb_define_class_under(rb_mAST, "Location", rb_cObject);
rb_undef_alloc_func(rb_cNode);
+ rb_undef_alloc_func(rb_cLocation);
}
diff --git a/ast.rb b/ast.rb
index ec870d8c7a..6380621780 100644
--- a/ast.rb
+++ b/ast.rb
@@ -13,14 +13,13 @@
# access children nodes by name, etc.
#
# If you are looking for a stable API or an API working under multiple Ruby
-# implementations, consider using the _parser_ gem or Ripper. If you would
-# like to make RubyVM::AbstractSyntaxTree stable, please join the discussion
-# at https://bugs.ruby-lang.org/issues/14844.
+# implementations, consider using the _prism_ gem, which is the official
+# Ruby API to parse Ruby code.
#
module RubyVM::AbstractSyntaxTree
# call-seq:
- # RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Parses the given _string_ into an abstract syntax tree,
# returning the root node of that tree.
@@ -55,12 +54,12 @@ module RubyVM::AbstractSyntaxTree
#
# Note that parsing continues even after the errored expression.
#
- def self.parse string, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.parse string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_parse string, keep_script_lines, error_tolerant, keep_tokens
end
# call-seq:
- # RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Reads the file from _pathname_, then parses it like ::parse,
# returning the root node of the abstract syntax tree.
@@ -72,13 +71,13 @@ module RubyVM::AbstractSyntaxTree
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
#
# See ::parse for explanation of keyword argument meaning and usage.
- def self.parse_file pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.parse_file pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_parse_file pathname, keep_script_lines, error_tolerant, keep_tokens
end
# call-seq:
- # RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
- # RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Returns AST nodes of the given _proc_ or _method_.
#
@@ -93,7 +92,7 @@ module RubyVM::AbstractSyntaxTree
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
#
# See ::parse for explanation of keyword argument meaning and usage.
- def self.of body, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.of body, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_of body, keep_script_lines, error_tolerant, keep_tokens
end
@@ -265,12 +264,69 @@ module RubyVM::AbstractSyntaxTree
lines = script_lines
if lines
lines = lines[first_lineno - 1 .. last_lineno - 1]
- lines[-1] = lines[-1][0...last_column]
- lines[0] = lines[0][first_column..-1]
+ lines[-1] = lines[-1].byteslice(0...last_column)
+ lines[0] = lines[0].byteslice(first_column..-1)
lines.join
else
nil
end
end
+
+ # call-seq:
+ # node.locations -> array
+ #
+ # Returns location objects associated with the AST node.
+ # The returned array contains RubyVM::AbstractSyntaxTree::Location.
+ def locations
+ Primitive.ast_node_locations
+ end
+ end
+
+ # RubyVM::AbstractSyntaxTree::Location instances are created by
+ # RubyVM::AbstractSyntaxTree::Node#locations.
+ #
+ # This class is MRI specific.
+ #
+ class Location
+
+ # call-seq:
+ # location.first_lineno -> integer
+ #
+ # The line number in the source code where this AST's text began.
+ def first_lineno
+ Primitive.ast_location_first_lineno
+ end
+
+ # call-seq:
+ # location.first_column -> integer
+ #
+ # The column number in the source code where this AST's text began.
+ def first_column
+ Primitive.ast_location_first_column
+ end
+
+ # call-seq:
+ # location.last_lineno -> integer
+ #
+ # The line number in the source code where this AST's text ended.
+ def last_lineno
+ Primitive.ast_location_last_lineno
+ end
+
+ # call-seq:
+ # location.last_column -> integer
+ #
+ # The column number in the source code where this AST's text ended.
+ def last_column
+ Primitive.ast_location_last_column
+ end
+
+ # call-seq:
+ # location.inspect -> string
+ #
+ # Returns debugging information about this location as a string.
+ def inspect
+ Primitive.ast_location_inspect
+ end
end
end
diff --git a/autogen.sh b/autogen.sh
index f8cdf3c0c1..6cbc5dddab 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,17 +1,22 @@
#!/bin/sh
+# Clear PWD to force commands to recompute working directory
PWD=
+
+# Figure out the source directory for this script
+# configure.ac should be in the same place
case "$0" in
-*/*) srcdir=`dirname $0`;;
-*) srcdir="";;
+ */* ) srcdir=`dirname "$0"` ;; # Called with path
+ * ) srcdir="";; # Otherwise
esac
-symlink='--install --symlink'
+# If install-only is explicitly requested, disable symlink flags
case " $* " in
- *" -i "*|*" --install "*)
- # reset to copy missing standard auxiliary files, instead of symlinks
- symlink=
- ;;
+ *" -i "* | *" --install"* ) symlink_flags="" ;;
+ * ) symlink_flags="--install --symlink" ;;
esac
-exec ${AUTORECONF:-autoreconf} ${symlink} "$@" ${srcdir:+"$srcdir"}
+exec ${AUTORECONF:-autoreconf} \
+ $symlink_flags \
+ "$@" \
+ $srcdir
diff --git a/basictest/test.rb b/basictest/test.rb
index 95875b52a6..711e4f4ab3 100755
--- a/basictest/test.rb
+++ b/basictest/test.rb
@@ -879,7 +879,7 @@ $x.sort!{|a,b| b-a} # reverse sort
test_ok($x == [7,5,3,2,1])
# split test
-$x = "The Book of Mormon"
+$x = +"The Book of Mormon"
test_ok($x.split(//).reverse!.join == $x.reverse)
test_ok($x.reverse == $x.reverse!)
test_ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1")
@@ -1643,7 +1643,7 @@ test_ok(/^(?:ab+)+/ =~ "ababb" && $& == "ababb")
test_ok(/(\s+\d+){2}/ =~ " 1 2" && $& == " 1 2")
test_ok(/(?:\s+\d+){2}/ =~ " 1 2" && $& == " 1 2")
-$x = <<END;
+$x = +<<END;
ABCD
ABCD
END
@@ -1682,12 +1682,12 @@ test_ok(?a == ?a)
test_ok(?\C-a == "\1")
test_ok(?\M-a == "\341")
test_ok(?\M-\C-a == "\201")
-test_ok("a".upcase![0] == ?A)
-test_ok("A".downcase![0] == ?a)
-test_ok("abc".tr!("a-z", "A-Z") == "ABC")
-test_ok("aabbcccc".tr_s!("a-z", "A-Z") == "ABC")
-test_ok("abcc".squeeze!("a-z") == "abc")
-test_ok("abcd".delete!("bc") == "ad")
+test_ok("a".dup.upcase![0] == ?A)
+test_ok("A".dup.downcase![0] == ?a)
+test_ok("abc".dup.tr!("a-z", "A-Z") == "ABC")
+test_ok("aabbcccc".dup.tr_s!("a-z", "A-Z") == "ABC")
+test_ok("abcc".dup.squeeze!("a-z") == "abc")
+test_ok("abcd".dup.delete!("bc") == "ad")
$x = "abcdef"
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
@@ -1700,7 +1700,7 @@ $x.each_byte {|i|
}
test_ok(!$bad)
-s = "a string"
+s = +"a string"
s[0..s.size]="another string"
test_ok(s == "another string")
diff --git a/benchmark/README.md b/benchmark/README.md
index e11381cad9..9f9192685e 100644
--- a/benchmark/README.md
+++ b/benchmark/README.md
@@ -27,6 +27,7 @@ benchmark-driver benchmark/*.yml
See also:
```console
+benchmark-driver --help
Usage: benchmark-driver [options] RUBY|YAML...
-r, --runner TYPE Specify runner type: ips, time, memory, once, block (default: ips)
-o, --output TYPE Specify output type: compare, simple, markdown, record, all (default: compare)
@@ -39,7 +40,7 @@ Usage: benchmark-driver [options] RUBY|YAML...
--filter REGEXP Filter out benchmarks with given regexp
--run-duration SECONDS Warmup estimates loop_count to run for this duration (default: 3)
--timeout SECONDS Timeout ruby command execution with timeout(1)
- -v, --verbose Verbose mode. Multiple -v options increase visilibity (max: 2)
+ -v, --verbose Verbose mode. Multiple -v options increase visibility (max: 2)
```
## make benchmark
diff --git a/benchmark/app_aobench.rb b/benchmark/app_aobench.rb
index 16296af12b..c1546e08ab 100644
--- a/benchmark/app_aobench.rb
+++ b/benchmark/app_aobench.rb
@@ -151,7 +151,7 @@ def clamp(f)
i.to_i
end
-def otherBasis(basis, n)
+def orthoBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
@@ -183,7 +183,7 @@ class Scene
def ambient_occlusion(isect)
basis = Array.new
- otherBasis(basis, isect.n)
+ orthoBasis(basis, isect.n)
ntheta = NAO_SAMPLES
nphi = NAO_SAMPLES
diff --git a/benchmark/app_fib.rb b/benchmark/app_fib.rb
index 34a7b2e725..e61bc8aa32 100644
--- a/benchmark/app_fib.rb
+++ b/benchmark/app_fib.rb
@@ -1,4 +1,4 @@
-def fib n
+def fib(n)
if n < 3
1
else
diff --git a/benchmark/array_large_literal.yml b/benchmark/array_large_literal.yml
new file mode 100644
index 0000000000..423d68391f
--- /dev/null
+++ b/benchmark/array_large_literal.yml
@@ -0,0 +1,19 @@
+prelude: |
+ def def_array(size)
+ Object.class_eval(<<-END)
+ def array_#{size}
+ x = 1
+ [#{(['x'] * size).join(',')}]
+ end
+ END
+ end
+ def_array(100)
+ def_array(1000)
+ def_array(10000)
+ def_array(100000)
+benchmark:
+ array_100: array_100
+ array_1000: array_1000
+ array_10000: array_10000
+ array_100000: array_100000
+
diff --git a/benchmark/class_superclass.yml b/benchmark/class_superclass.yml
new file mode 100644
index 0000000000..847ff811f1
--- /dev/null
+++ b/benchmark/class_superclass.yml
@@ -0,0 +1,23 @@
+prelude: |
+ class SimpleClass; end
+ class OneModuleClass
+ 1.times { include Module.new }
+ end
+ class MediumClass
+ 10.times { include Module.new }
+ end
+ class LargeClass
+ 100.times { include Module.new }
+ end
+benchmark:
+ object_class_superclass: |
+ Object.superclass
+ simple_class_superclass: |
+ SimpleClass.superclass
+ one_module_class: |
+ OneModuleClass.superclass
+ medium_class_superclass: |
+ MediumClass.superclass
+ large_class_superclass: |
+ LargeClass.superclass
+loop_count: 20000000
diff --git a/benchmark/dir_pwd.yml b/benchmark/dir_pwd.yml
new file mode 100644
index 0000000000..c435d3ac5e
--- /dev/null
+++ b/benchmark/dir_pwd.yml
@@ -0,0 +1,2 @@
+benchmark:
+ pwd: Dir.pwd
diff --git a/benchmark/enum_sort_by.yml b/benchmark/enum_sort_by.yml
new file mode 100644
index 0000000000..d386353888
--- /dev/null
+++ b/benchmark/enum_sort_by.yml
@@ -0,0 +1,53 @@
+prelude: |
+ array_length = 2
+ fixnum_array2 = array_length.times.to_a.map {rand(10000)}
+ float_array2 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array2 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array2 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array2 =array_length.times.to_a.map {0}
+
+ array_length = 10
+ fixnum_array10 = array_length.times.to_a.map {rand(10000)}
+ float_array10 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array10 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array10 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array10 =array_length.times.to_a.map {0}
+
+ array_length = 1000
+ fixnum_array1000 = array_length.times.to_a.map {rand(10000)}
+ float_array1000 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array1000 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array1000 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array1000 =array_length.times.to_a.map {0}
+
+ array_length = 100000
+ fixnum_array100000 = array_length.times.to_a.map {rand(10000)}
+ float_array100000 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array100000 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array100000 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array100000 =array_length.times.to_a.map {0}
+
+benchmark:
+ fixnum_array2.sort_by: fixnum_array2.sort_by {|a| a}
+ float_array2.sort_by: float_array2.sort_by {|a| a}
+ string_length2.sort_by: string_array2.sort_by {|a| a.length}
+ mix_array2.sort_by: mix_array2.sort_by {|a| a}
+ all_zero2.sort_by: all_zero_array2.sort_by{|a| a}
+
+ fixnum_array10.sort_by: fixnum_array10.sort_by {|a| a}
+ float_array10.sort_by: float_array10.sort_by {|a| a}
+ string_length10.sort_by: string_array10.sort_by {|a| a.length}
+ mix_array10.sort_by: mix_array10.sort_by {|a| a}
+ all_zero10.sort_by: all_zero_array10.sort_by{|a| a}
+
+ fixnum_array1000.sort_by: fixnum_array1000.sort_by {|a| a}
+ float_array1000.sort_by: float_array1000.sort_by {|a| a}
+ string_length1000.sort_by: string_array1000.sort_by {|a| a.length}
+ mix_array1000.sort_by: mix_array1000.sort_by {|a| a}
+ all_zero1000.sort_by: all_zero_array1000.sort_by{|a| a}
+
+ fixnum_array100000.sort_by: fixnum_array100000.sort_by {|a| a}
+ float_array100000.sort_by: float_array100000.sort_by {|a| a}
+ string_length100000.sort_by: string_array100000.sort_by {|a| a.length}
+ mix_array100000.sort_by: mix_array100000.sort_by {|a| a}
+ all_zero100000.sort_by: all_zero_array100000.sort_by{|a| a}
diff --git a/benchmark/file_basename.yml b/benchmark/file_basename.yml
new file mode 100644
index 0000000000..fbd78785aa
--- /dev/null
+++ b/benchmark/file_basename.yml
@@ -0,0 +1,6 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ long: File.basename("/Users/george/src/github.com/ruby/ruby/benchmark/file_dirname.yml")
+ long_name: File.basename("Users_george_src_github.com_ruby_ruby_benchmark_file_dirname.yml")
+ withext: File.basename("/Users/george/src/github.com/ruby/ruby/benchmark/file_dirname.yml", ".yml")
diff --git a/benchmark/file_dirname.yml b/benchmark/file_dirname.yml
new file mode 100644
index 0000000000..43a81c9371
--- /dev/null
+++ b/benchmark/file_dirname.yml
@@ -0,0 +1,6 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ long: File.dirname("/Users/george/src/github.com/ruby/ruby/benchmark/file_dirname.yml")
+ short: File.dirname("foo/bar")
+ n_4: File.dirname("/Users/george/src/github.com/ruby/ruby/benchmark/file_dirname.yml", 4)
diff --git a/benchmark/file_expand_path.yml b/benchmark/file_expand_path.yml
new file mode 100644
index 0000000000..9e503ab003
--- /dev/null
+++ b/benchmark/file_expand_path.yml
@@ -0,0 +1,4 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ expand_path: File.expand_path("../../foo.txt", __FILE__)
diff --git a/benchmark/file_extname.yml b/benchmark/file_extname.yml
new file mode 100644
index 0000000000..fb16e55840
--- /dev/null
+++ b/benchmark/file_extname.yml
@@ -0,0 +1,6 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ long: File.extname("/Users/george/src/github.com/ruby/ruby/benchmark/file_dirname.yml")
+ long_name: File.extname("Users_george_src_github.com_ruby_ruby_benchmark_file_dirname.yml")
+ short: File.extname("foo/bar")
diff --git a/benchmark/file_join.yml b/benchmark/file_join.yml
new file mode 100644
index 0000000000..845257cf1e
--- /dev/null
+++ b/benchmark/file_join.yml
@@ -0,0 +1,7 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ two_strings: File.join(__FILE__, "path")
+ many_strings: File.join(__FILE__, "path", "a", "b", "c", "d")
+ array: File.join([__FILE__, "path", "a", "b", "c", "d"])
+ mixed: File.join(__FILE__, "path", "a", "b", ["c", "d"])
diff --git a/benchmark/float_predicate.yml b/benchmark/float_predicate.yml
new file mode 100644
index 0000000000..b946937666
--- /dev/null
+++ b/benchmark/float_predicate.yml
@@ -0,0 +1,12 @@
+prelude: |
+ floats = [1.0, -1.0, 0.0, Float::NAN, Float::INFINITY, -Float::INFINITY]
+
+benchmark:
+ float_nan?: floats.each { |f| f.nan? }
+ float_finite?: floats.each { |f| f.finite? }
+ float_infinite?: floats.each { |f| f.infinite? }
+ float_zero?: floats.each { |f| f.zero? }
+ float_positive?: floats.each { |f| f.positive? }
+ float_negative?: floats.each { |f| f.negative? }
+
+loop_count: 1000000
diff --git a/benchmark/hash_aref_str_lit.yml b/benchmark/hash_aref_str_lit.yml
new file mode 100644
index 0000000000..ed8142bcf1
--- /dev/null
+++ b/benchmark/hash_aref_str_lit.yml
@@ -0,0 +1,20 @@
+prelude: |
+ # frozen_string_literal: true
+ hash = 10.times.to_h do |i|
+ [i, i]
+ end
+ dyn_sym = "dynamic_symbol".to_sym
+ binary = RubyVM::InstructionSequence.compile("# frozen_string_literal: true\n'iseq_load'").to_binary
+ iseq_literal_string = RubyVM::InstructionSequence.load_from_binary(binary).eval
+
+ hash[:some_symbol] = 1
+ hash[dyn_sym] = 2
+ hash["small"] = 3
+ hash["frozen_string_literal"] = 4
+ hash[iseq_literal_string] = 5
+benchmark:
+ symbol: hash[:some_symbol]
+ dyn_symbol: hash[dyn_sym]
+ small_lit: hash["small"]
+ frozen_lit: hash["frozen_string_literal"]
+ iseq_lit: hash[iseq_literal_string]
diff --git a/benchmark/hash_key.yml b/benchmark/hash_key.yml
new file mode 100644
index 0000000000..cab4cf9ca4
--- /dev/null
+++ b/benchmark/hash_key.yml
@@ -0,0 +1,5 @@
+prelude: |
+ obj = Object.new
+ hash = { obj => true }
+benchmark: hash.key?(obj)
+loop_count: 30000000
diff --git a/benchmark/hash_new.yml b/benchmark/hash_new.yml
new file mode 100644
index 0000000000..9d8e34187f
--- /dev/null
+++ b/benchmark/hash_new.yml
@@ -0,0 +1,16 @@
+prelude: |
+ has_hash_with_capa = Hash.instance_method(:initialize).parameters.include?([:key, :capacity])
+ strings_1k = 1_000.times.map { |i| -i.to_s.freeze }
+ strings_100k = 100_000.times.map { |i| -i.to_s.freeze }
+benchmark:
+ new: Hash.new
+ new_with_capa_1k: |
+ h = has_hash_with_capa ? Hash.new(capacity: strings_1k.size) : {}
+ strings_1k.each do |x|
+ h[x] = true
+ end
+ new_with_capa_100k: |
+ h = has_hash_with_capa ? Hash.new(capacity: strings_100k.size) : {}
+ strings_100k.each do |x|
+ h[x] = true
+ end
diff --git a/benchmark/int_to_s.yml b/benchmark/int_to_s.yml
new file mode 100644
index 0000000000..000dae9612
--- /dev/null
+++ b/benchmark/int_to_s.yml
@@ -0,0 +1,25 @@
+prelude: |
+ # frozen_string_literal: true
+ N1 = 5
+ N2 = 42
+ N3 = 400
+ N5 = 12345
+ N10 = 1_234_567_890
+ N19 = 4_611_686_018_427_387_903
+ NEG = -1_234_567_890
+ BIG20 = 10 ** 19 + 12_345_678_901_234_567
+ BIG40 = 10 ** 39 + 123_456_789_012_345
+ BIG100 = 10 ** 99 + 42
+benchmark:
+ fix_1digit: "N1.to_s"
+ fix_2digit: "N2.to_s"
+ fix_3digit: "N3.to_s"
+ fix_5digit: "N5.to_s"
+ fix_10digit: "N10.to_s"
+ fix_19digit: "N19.to_s"
+ fix_negative: "NEG.to_s"
+ big_20digit: "BIG20.to_s"
+ big_40digit: "BIG40.to_s"
+ big_100digit: "BIG100.to_s"
+ interp_id: '"id=#{N10}"'
+ interp_mixed: '"a=#{N2},b=#{N5},c=#{N10}"'
diff --git a/benchmark/integer_predicate.yml b/benchmark/integer_predicate.yml
new file mode 100644
index 0000000000..7c05ff2587
--- /dev/null
+++ b/benchmark/integer_predicate.yml
@@ -0,0 +1,9 @@
+prelude: |
+ nums = (0..9).to_a
+
+benchmark:
+ integer_zero?: nums.each { |n| n.zero? }
+ integer_even?: nums.each { |n| n.even? }
+ integer_odd?: nums.each { |n| n.odd? }
+
+loop_count: 1000000
diff --git a/benchmark/io_close.yml b/benchmark/io_close.yml
new file mode 100644
index 0000000000..a552872884
--- /dev/null
+++ b/benchmark/io_close.yml
@@ -0,0 +1,13 @@
+prelude: |
+ ios = 1000.times.map do
+ 100.times.map{IO.pipe}
+ end
+benchmark:
+ # Close IO
+ io_close: |
+ # Process each batch of ios per iteration of the benchmark.
+ ios.pop.each do |r, w|
+ r.close
+ w.close
+ end
+loop_count: 100
diff --git a/benchmark/io_close_contended.yml b/benchmark/io_close_contended.yml
new file mode 100644
index 0000000000..1d9e4e0d0f
--- /dev/null
+++ b/benchmark/io_close_contended.yml
@@ -0,0 +1,21 @@
+prelude: |
+ ios = 100.times.map do
+ 10.times.map do
+ pipe = IO.pipe.tap do |r, w|
+ Thread.new do
+ r.read
+ rescue IOError
+ # Ignore
+ end
+ end
+ end
+ end
+benchmark:
+ # Close IO
+ io_close_contended: |
+ # Process each batch of ios per iteration of the benchmark.
+ ios.pop.each do |r, w|
+ r.close
+ w.close
+ end
+loop_count: 10
diff --git a/benchmark/lib/benchmark_driver/runner/ractor.rb b/benchmark/lib/benchmark_driver/runner/ractor.rb
index c730b8e4a5..fd9c2dd4db 100644
--- a/benchmark/lib/benchmark_driver/runner/ractor.rb
+++ b/benchmark/lib/benchmark_driver/runner/ractor.rb
@@ -87,7 +87,7 @@ __bmdv_ractors << Ractor.new(__bmdv_loop_after - __bmdv_loop_before) { |__bmdv_l
<% end %>
# Wait for all Ractors before executing code to write results
-__bmdv_ractors.map!(&:take)
+__bmdv_ractors.map!(&:value)
<% results.each do |result| %>
File.write(<%= result.dump %>, __bmdv_ractors.shift)
diff --git a/benchmark/loop_each.yml b/benchmark/loop_each.yml
new file mode 100644
index 0000000000..1c757185a8
--- /dev/null
+++ b/benchmark/loop_each.yml
@@ -0,0 +1,4 @@
+prelude: |
+ arr = [nil] * 30_000_000
+benchmark:
+ loop_each: arr.each{|e|}
diff --git a/benchmark/loop_times_megamorphic.yml b/benchmark/loop_times_megamorphic.yml
new file mode 100644
index 0000000000..f9343ba897
--- /dev/null
+++ b/benchmark/loop_times_megamorphic.yml
@@ -0,0 +1,7 @@
+prelude: |
+ eval(<<~EOS)
+ def loop_times_megamorphic
+ #{"1.times {|i|};" * 1000}
+ end
+ EOS
+benchmark: loop_times_megamorphic
diff --git a/benchmark/module_eqq.yml b/benchmark/module_eqq.yml
index a561fb86dc..2f9c490d92 100644
--- a/benchmark/module_eqq.yml
+++ b/benchmark/module_eqq.yml
@@ -1,4 +1,5 @@
prelude: |
+ module SomeModule; end
class SimpleClass; end
class MediumClass
10.times { include Module.new }
@@ -24,4 +25,8 @@ benchmark:
SimpleClass === LargeObj
simple_class_eqq_huge_obj: |
SimpleClass === HugeObj
-loop_count: 20000000
+ simple_class_eqq_module: |
+ SimpleClass === HugeObj
+ module_eqq_module: |
+ SomeModule === HugeObj
+loop_count: 10000000
diff --git a/benchmark/nilclass.yml b/benchmark/nilclass.yml
index fba67a5f6a..66234c4cdf 100644
--- a/benchmark/nilclass.yml
+++ b/benchmark/nilclass.yml
@@ -1,6 +1,16 @@
+prelude: |
+ def a = nil
benchmark:
+ rationalize:
+ nil.rationalize
+ to_c: |
+ nil.to_c
to_i: |
nil.to_i
to_f: |
nil.to_f
+ to_r: |
+ nil.to_r
+ splat: |
+ a(*nil)
loop_count: 100000
diff --git a/benchmark/object_allocate.yml b/benchmark/object_allocate.yml
index 93ff463e41..c6269923f0 100644
--- a/benchmark/object_allocate.yml
+++ b/benchmark/object_allocate.yml
@@ -11,6 +11,26 @@ prelude: |
class OneTwentyEight
128.times { include(Module.new) }
end
+ class OnePositional
+ def initialize a; end
+ end
+ class TwoPositional
+ def initialize a, b; end
+ end
+ class ThreePositional
+ def initialize a, b, c; end
+ end
+ class FourPositional
+ def initialize a, b, c, d; end
+ end
+ class KWArg
+ def initialize a:, b:, c:, d:
+ end
+ end
+ class Mixed
+ def initialize a, b, c:, d:
+ end
+ end
# Disable GC to see raw throughput:
GC.disable
benchmark:
@@ -18,4 +38,12 @@ benchmark:
allocate_32_deep: ThirtyTwo.new
allocate_64_deep: SixtyFour.new
allocate_128_deep: OneTwentyEight.new
+ allocate_1_positional_params: OnePositional.new(1)
+ allocate_2_positional_params: TwoPositional.new(1, 2)
+ allocate_3_positional_params: ThreePositional.new(1, 2, 3)
+ allocate_4_positional_params: FourPositional.new(1, 2, 3, 4)
+ allocate_kwarg_params: "KWArg.new(a: 1, b: 2, c: 3, d: 4)"
+ allocate_mixed_params: "Mixed.new(1, 2, c: 3, d: 4)"
+ allocate_no_params: "Object.new"
+ allocate_allocate: "Object.allocate"
loop_count: 100000
diff --git a/benchmark/object_class.yml b/benchmark/object_class.yml
new file mode 100644
index 0000000000..1e5409d1e2
--- /dev/null
+++ b/benchmark/object_class.yml
@@ -0,0 +1,40 @@
+prelude: |
+ def get_class(obj)
+ i = 10_000
+ while i > 0
+ i -= 1
+ # 100 times per loop
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class; obj.class;
+ end
+ end
+
+ class Obj
+ end
+ obj = Obj.new
+
+ singleton = Obj.new
+ def singleton.bar
+ end
+
+ extended = Obj.new
+ 2.times do
+ extended.extend Module.new
+ end
+
+ immediate = 1.4
+benchmark:
+ obj: get_class(obj)
+ extended: get_class(extended)
+ singleton: get_class(singleton)
+ immediate: get_class(immediate)
+loop_count: 1000
diff --git a/benchmark/object_id.yml b/benchmark/object_id.yml
new file mode 100644
index 0000000000..2bd52b923f
--- /dev/null
+++ b/benchmark/object_id.yml
@@ -0,0 +1,4 @@
+benchmark:
+ baseline: "Object.new"
+ object_id: "Object.new.object_id"
+# loop_count: 100000
diff --git a/benchmark/pathname.yml b/benchmark/pathname.yml
new file mode 100644
index 0000000000..bcf3011eab
--- /dev/null
+++ b/benchmark/pathname.yml
@@ -0,0 +1,15 @@
+prelude: |
+ abs = Pathname("/a")
+ rel = Pathname("a")
+ p1 = Pathname.new('foo/././././bar')
+ p2 = Pathname.new('foo/bar/./../..')
+ p3 = Pathname.new('foo/bar/zot')
+benchmark:
+ p1+p2: p1+p2
+ abs.root?: abs.root?
+ rel.root?: rel.root?
+ abs.absolute?: abs.absolute?
+ rel.absolute?: rel.absolute?
+ p1.cleanpath: p1.cleanpath
+ p2.cleanpath: p2.cleanpath
+ relative_path_from: p3.relative_path_from('foo/bar/qux/quax')
diff --git a/benchmark/ractor_string_fstring.yml b/benchmark/ractor_string_fstring.yml
new file mode 100644
index 0000000000..14b92d8fd8
--- /dev/null
+++ b/benchmark/ractor_string_fstring.yml
@@ -0,0 +1,18 @@
+type: lib/benchmark_driver/runner/ractor
+benchmark:
+ ractor_fstring_random: |
+ i = 0
+ str = "same".dup
+ while i < 2000000
+ -(i.to_s.freeze)
+ i += 1
+ end
+ ractor_fstring_same: |
+ i = 0
+ str = "same".dup
+ while i < 2000000
+ -str
+ i += 1
+ end
+loop_count: 1
+ractor: 4
diff --git a/benchmark/range_bsearch_bignum.yml b/benchmark/range_bsearch_bignum.yml
new file mode 100644
index 0000000000..5730c93fcf
--- /dev/null
+++ b/benchmark/range_bsearch_bignum.yml
@@ -0,0 +1,10 @@
+prelude: |
+ first = 2**100
+ last = 2**1000
+ mid = (first + last) / 2
+ r = first..last
+
+benchmark:
+ first: r.bsearch { |x| x >= first }
+ mid: r.bsearch { |x| x >= mid }
+ last: r.bsearch { |x| x >= last }
diff --git a/benchmark/range_bsearch_endpointless.yml b/benchmark/range_bsearch_endpointless.yml
new file mode 100644
index 0000000000..8d7bedb662
--- /dev/null
+++ b/benchmark/range_bsearch_endpointless.yml
@@ -0,0 +1,21 @@
+prelude: |
+ re = (1..)
+ rb = (..0)
+
+benchmark:
+ 'endless 10**0': re.bsearch { |x| x >= 1 }
+ 'endless 10**1': re.bsearch { |x| x >= 10 }
+ 'endless 10**2': re.bsearch { |x| x >= 100 }
+ 'endless 10**3': re.bsearch { |x| x >= 1000 }
+ 'endless 10**4': re.bsearch { |x| x >= 10000 }
+ 'endless 10**5': re.bsearch { |x| x >= 100000 }
+ 'endless 10**10': re.bsearch { |x| x >= 10000000000 }
+ 'endless 10**100': re.bsearch { |x| x >= 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }
+ 'beginless -10**0': rb.bsearch { |x| x >= -1 }
+ 'beginless -10**1': rb.bsearch { |x| x >= -10 }
+ 'beginless -10**2': rb.bsearch { |x| x >= -100 }
+ 'beginless -10**3': rb.bsearch { |x| x >= -1000 }
+ 'beginless -10**4': rb.bsearch { |x| x >= -10000 }
+ 'beginless -10**5': rb.bsearch { |x| x >= -100000 }
+ 'beginless -10**10': rb.bsearch { |x| x >= -10000000000 }
+ 'beginless -10**100': rb.bsearch { |x| x >= -10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }
diff --git a/benchmark/range_bsearch_fixnum.yml b/benchmark/range_bsearch_fixnum.yml
new file mode 100644
index 0000000000..59416531b9
--- /dev/null
+++ b/benchmark/range_bsearch_fixnum.yml
@@ -0,0 +1,10 @@
+prelude: |
+ first = 1
+ last = 10000
+ mid = (first + last) / 2
+ r = first..last
+
+benchmark:
+ first: r.bsearch { |x| x >= first }
+ mid: r.bsearch { |x| x >= mid }
+ last: r.bsearch { |x| x >= last }
diff --git a/benchmark/range_count.yml b/benchmark/range_count.yml
new file mode 100644
index 0000000000..58f53a0236
--- /dev/null
+++ b/benchmark/range_count.yml
@@ -0,0 +1,11 @@
+prelude: |
+ r_1 = 1..1
+ r_1k = 1..1000
+ r_1m = 1..1000000
+ r_str = 'a'..'z'
+
+benchmark:
+ 'int 1': r_1.count
+ 'int 1K': r_1k.count
+ 'int 1M': r_1m.count
+ string: r_str.count
diff --git a/benchmark/range_overlap.yml b/benchmark/range_overlap.yml
new file mode 100644
index 0000000000..700a00053c
--- /dev/null
+++ b/benchmark/range_overlap.yml
@@ -0,0 +1,19 @@
+prelude: |
+ class Range
+ unless method_defined?(:overlap?)
+ def overlap?(other)
+ other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin)
+ end
+ end
+ end
+
+benchmark:
+ - (2..3).overlap?(1..1)
+ - (2..3).overlap?(2..4)
+ - (2..3).overlap?(4..5)
+ - (2..3).overlap?(2..1)
+ - (2..3).overlap?(0..1)
+ - (2..3).overlap?(...1)
+ - (2...3).overlap?(..2)
+ - (2...3).overlap?(3...)
+ - (2..3).overlap?('a'..'d')
diff --git a/benchmark/range_reverse_each.yml b/benchmark/range_reverse_each.yml
new file mode 100644
index 0000000000..a32efeccc6
--- /dev/null
+++ b/benchmark/range_reverse_each.yml
@@ -0,0 +1,16 @@
+prelude: |
+ rf_1 = 0..1
+ rf_1k = 0..1000
+ rf_1m = 0..1000000
+ big = 2**1000
+ rb_1 = big..big+1
+ rb_1k = big..big+1000
+ rb_1m = big..big+1000000
+
+benchmark:
+ "Fixnum 1": rf_1.reverse_each { _1 }
+ "Fixnum 1K": rf_1k.reverse_each { _1 }
+ "Fixnum 1M": rf_1m.reverse_each { _1 }
+ "Bignum 1": rb_1.reverse_each { _1 }
+ "Bignum 1K": rb_1k.reverse_each { _1 }
+ "Bignum 1M": rb_1m.reverse_each { _1 }
diff --git a/benchmark/realpath.yml b/benchmark/realpath.yml
index 90a029d5b9..6b6a4836b0 100644
--- a/benchmark/realpath.yml
+++ b/benchmark/realpath.yml
@@ -12,6 +12,9 @@ prelude: |
relative_dir = 'b/c'
absolute_dir = File.join(pwd, relative_dir)
file_dir = 'c'
+teardown: |
+ require 'fileutils'
+ FileUtils.rm_rf('b')
benchmark:
relative_nil: "f.realpath(relative, nil)"
absolute_nil: "f.realpath(absolute, nil)"
diff --git a/benchmark/regexp_dup.yml b/benchmark/regexp_dup.yml
new file mode 100644
index 0000000000..52f89991cd
--- /dev/null
+++ b/benchmark/regexp_dup.yml
@@ -0,0 +1,6 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ dup: re.dup
diff --git a/benchmark/regexp_new.yml b/benchmark/regexp_new.yml
new file mode 100644
index 0000000000..bc9ab3ca21
--- /dev/null
+++ b/benchmark/regexp_new.yml
@@ -0,0 +1,7 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ string: Regexp.new(str)
+ regexp: Regexp.new(re)
diff --git a/benchmark/scan.yaml b/benchmark/scan.yaml
new file mode 100644
index 0000000000..62ad1d6862
--- /dev/null
+++ b/benchmark/scan.yaml
@@ -0,0 +1,16 @@
+prelude: |
+ $LOAD_PATH.unshift(File.expand_path("lib"))
+ require "strscan"
+ str = "test string"
+ scanner = StringScanner.new(str)
+ str = "test"
+ reg = /test/
+benchmark:
+ check(reg): |
+ scanner.check(reg)
+ check(str): |
+ scanner.check(str)
+ match?(reg): |
+ scanner.match?(reg)
+ match?(str): |
+ scanner.match?(str)
diff --git a/benchmark/search.yaml b/benchmark/search.yaml
new file mode 100644
index 0000000000..42a50c90e6
--- /dev/null
+++ b/benchmark/search.yaml
@@ -0,0 +1,16 @@
+prelude: |
+ $LOAD_PATH.unshift(File.expand_path("lib"))
+ require "strscan"
+ str = "test string"
+ scanner = StringScanner.new(str)
+ str = "string"
+ reg = /string/
+benchmark:
+ check_until(reg): |
+ scanner.check_until(reg)
+ check_until(str): |
+ scanner.check_until(str)
+ exist?(reg): |
+ scanner.exist?(reg)
+ exist?(str): |
+ scanner.exist?(str)
diff --git a/benchmark/set.yml b/benchmark/set.yml
new file mode 100644
index 0000000000..061509cb1f
--- /dev/null
+++ b/benchmark/set.yml
@@ -0,0 +1,261 @@
+prelude: |
+ # First 1000 digits of pi
+ pi = <<~END.gsub(/\D/, '')
+ 31415926535897932384626433832795028841971693993751058209749445923078164062862089
+ 98628034825342117067982148086513282306647093844609550582231725359408128481117450
+ 28410270193852110555964462294895493038196442881097566593344612847564823378678316
+ 52712019091456485669234603486104543266482133936072602491412737245870066063155881
+ 74881520920962829254091715364367892590360011330530548820466521384146951941511609
+ 43305727036575959195309218611738193261179310511854807446237996274956735188575272
+ 48912279381830119491298336733624406566430860213949463952247371907021798609437027
+ 70539217176293176752384674818467669405132000568127145263560827785771342757789609
+ 17363717872146844090122495343014654958537105079227968925892354201995611212902196
+ 08640344181598136297747713099605187072113499999983729780499510597317328160963185
+ 95024459455346908302642522308253344685035261931188171010003137838752886587533208
+ 38142061717766914730359825349042875546873115956286388235378759375195778185778053
+ 21712268066130019278766111959092164201989380952572010654505906988788448549
+ END
+ array1 = 10.times.flat_map do |i|
+ pi[i...].chars.each_slice(10).map(&:join)
+ end
+ array2 = array1.map(&:reverse)
+ array1.map!(&:to_i)
+ array2.map!(&:to_i)
+ a1 = array1[...10]
+ a2 = array1[...100]
+ a3 = array1
+ oa1 = array2[...10]
+ oa2 = array2[...100]
+ oa3 = array2
+ s0 = Set.new
+ s0 = Set.new
+ s1 = Set.new(a1)
+ s2 = Set.new(a2)
+ s3 = Set.new(a3)
+ o0 = Set.new
+ o1 = Set.new(array2[...10])
+ o2 = Set.new(array2[...100])
+ o3 = Set.new(array2)
+ d0 = s0.dup
+ d1 = s1.dup
+ d2 = s2.dup
+ d3 = s3.dup
+ ss1 = s1 - a1[-1..-1]
+ ss2 = s2 - a2[-1..-1]
+ ss3 = s3 - a3[-1..-1]
+ os1 = o1 - oa1[-1..-1]
+ os2 = o2 - oa2[-1..-1]
+ os3 = o3 - oa3[-1..-1]
+ member = a1.first
+ cbi = s0.dup.compare_by_identity
+ ns = Set[s3, o3, d3]
+ set_subclass = Class.new(Set)
+
+benchmark:
+ new_0: Set.new
+ new_10: Set.new(a1)
+ new_100: Set.new(a2)
+ new_1000: Set.new(a3)
+ aref_0: Set[]
+ aref_10: Set[*a1]
+ aref_100: Set[*a2]
+ aref_1000: Set[*a3]
+ amp_0: s0 & o0
+ amp_10: s1 & o1
+ amp_100: s2 & o2
+ amp_1000: s3 & o3
+ amp_same_0: s0 & d0
+ amp_same_10: s1 & d1
+ amp_same_100: s2 & d2
+ amp_same_1000: s3 & d3
+ minus_0: s0 - o0
+ minus_10: s1 - o1
+ minus_100: s2 - o2
+ minus_1000: s3 - o3
+ minus_same_0: s0 - d0
+ minus_same_10: s1 - d1
+ minus_same_100: s2 - d2
+ minus_same_1000: s3 - d3
+ spaceship_0: s0 <=> o0
+ spaceship_diff_10: s1 <=> o1
+ spaceship_diff_100: s2 <=> o2
+ spaceship_diff_1000: s2 <=> o3
+ spaceship_sub_10: s1 <=> ss1
+ spaceship_sub_100: s2 <=> ss2
+ spaceship_sub_1000: s2 <=> ss3
+ spaceship_sup_10: ss1 <=> s1
+ spaceship_sup_100: ss2 <=> s2
+ spaceship_sup_1000: ss2 <=> s3
+ eq_0: s0 == o0
+ eq_10: s1 == o1
+ eq_100: s2 == o2
+ eq_1000: s3 == o3
+ eq_same_0: s0 == d0
+ eq_same_10: s1 == d1
+ eq_same_100: s2 == d2
+ eq_same_1000: s3 == d3
+ xor_0: s0 ^ o0
+ xor_10: s1 ^ o1
+ xor_100: s2 ^ o2
+ xor_1000: s3 ^ o3
+ xor_same_0: s0 ^ d0
+ xor_same_10: s1 ^ d1
+ xor_same_100: s2 ^ d2
+ xor_same_1000: s3 ^ d3
+ pipe_0: s0 | o0
+ pipe_10: s1 | o1
+ pipe_100: s2 | o2
+ pipe_1000: s3 | o3
+ pipe_same_0: s0 | d0
+ pipe_same_10: s1 | d1
+ pipe_same_100: s2 | d2
+ pipe_same_1000: s3 | d3
+ add: a3.each { s0.add(it) }
+ add_exist: a3.each { s3.add(it) }
+ addq: a3.each { s0.add?(it) }
+ addq_exist: a3.each { s3.add?(it) }
+ classify_0: s0.classify { it }
+ classify_10: s1.classify { it & 2 }
+ classify_100: s2.classify { it & 8 }
+ classify_1000: s3.classify { it & 32 }
+ clear: s0.clear
+ collect_0: s0.collect! { it }
+ collect_10: s1.collect! { it }
+ collect_100: s2.collect! { it }
+ collect_1000: s3.collect! { it }
+ compare_by_identity_0: s0.dup.compare_by_identity
+ compare_by_identity_10: s1.dup.compare_by_identity
+ compare_by_identity_100: s2.dup.compare_by_identity
+ compare_by_identity_1000: s3.dup.compare_by_identity
+ compare_by_identityq_false: s0.compare_by_identity?
+ compare_by_identityq_true: cbi.compare_by_identity?
+ clone_0: s0.clone
+ clone_10: s1.clone
+ clone_100: s2.clone
+ clone_1000: s3.clone
+ delete: a3.each { s3.delete(it) }
+ delete_not_exist: a3.each { o3.delete(it) }
+ deleteq: a3.each { s3.delete?(it) }
+ deleteq_not_exist: a3.each { o3.delete?(it) }
+ delete_if_0: s0.delete_if { it }
+ delete_if_10: s1.delete_if { it & 2 == 0 }
+ delete_if_100: s2.delete_if { it & 2 == 0 }
+ delete_if_1000: s3.delete_if { it & 2 == 0 }
+ disjoint_0: s0.disjoint? o0
+ disjoint_10: s1.disjoint? o1
+ disjoint_100: s2.disjoint? o2
+ disjoint_1000: s3.disjoint? o3
+ disjoint_same_0: s0.disjoint? d0
+ disjoint_same_10: s1.disjoint? d1
+ disjoint_same_100: s2.disjoint? d2
+ disjoint_same_1000: s3.disjoint? d3
+ divide_1arity_0: s0.divide { true }
+ divide_1arity_10: s1.divide { it & 2 }
+ divide_1arity_100: s2.divide { it & 8 }
+ divide_1arity_1000: s3.divide { it & 32 }
+ divide_2arity_0: s0.divide { true }
+ divide_2arity_10: s1.divide { (_1 & 2) == (_2 & 2) }
+ divide_2arity_100: s2.divide { (_1 & 8) == (_2 & 8) }
+ divide_2arity_1000: s3.divide { (_1 & 32) == (_2 & 32) }
+ dup_0: s0.dup
+ dup_10: s1.dup
+ dup_100: s2.dup
+ dup_1000: s3.dup
+ each_0: s0.each { it }
+ each_10: s1.each { it }
+ each_100: s2.each { it }
+ each_1000: s3.each { it }
+ empty_true: s0.empty?
+ empty_false: s3.empty?
+ flatten: ns.flatten
+ flattenb: ns.flatten!
+ include_true_0: s0.include? member
+ include_true_10: s1.include? member
+ include_true_100: s2.include? member
+ include_true_1000: s3.include? member
+ include_false_0: s0.include?(-1)
+ include_false_10: s1.include?(-1)
+ include_false_100: s2.include?(-1)
+ include_false_1000: s3.include?(-1)
+ intersect_0: s0.intersect? o0
+ intersect_10: s1.intersect? o1
+ intersect_100: s2.intersect? o2
+ intersect_1000: s3.intersect? o3
+ intersect_same_0: s0.intersect? d0
+ intersect_same_10: s1.intersect? d1
+ intersect_same_100: s2.intersect? d2
+ intersect_same_1000: s3.intersect? d3
+ join_0: s0.join
+ join_10: s1.join
+ join_100: s2.join
+ join_1000: s3.join
+ join_arg_0: s0.join ""
+ join_arg_10: s1.join ""
+ join_arg_100: s2.join ""
+ join_arg_1000: s3.join ""
+ keep_if_0: s0.keep_if { it }
+ keep_if_10: s1.keep_if { it & 2 == 0 }
+ keep_if_100: s2.keep_if { it & 2 == 0 }
+ keep_if_1000: s3.keep_if { it & 2 == 0 }
+ merge_set: s0.dup.merge(s3, o3)
+ merge_enum: s0.dup.merge(array1, array2)
+ proper_subset_0: s0.proper_subset? s0
+ proper_subset_10: s1.proper_subset? ss1
+ proper_subset_100: s2.proper_subset? ss2
+ proper_subset_1000: s3.proper_subset? ss3
+ proper_subset_false_10: s1.proper_subset? os1
+ proper_subset_false_100: s2.proper_subset? os2
+ proper_subset_false_1000: s3.proper_subset? os3
+ proper_superset_0: s0.proper_superset? s0
+ proper_superset_10: ss1.proper_superset? s1
+ proper_superset_100: ss2.proper_superset? s2
+ proper_superset_1000: ss3.proper_superset? s3
+ proper_superset_false_10: os1.proper_superset? s1
+ proper_superset_false_100: os2.proper_superset? s2
+ proper_superset_false_1000: os3.proper_superset? s3
+ reject_0: s0.reject! { it }
+ reject_10: s1.reject! { it & 2 == 0 }
+ reject_100: s2.reject! { it & 2 == 0 }
+ reject_1000: s3.reject! { it & 2 == 0 }
+ replace_0: s = Set.new; array1.each { s.replace(s0) }
+ replace_10: s = Set.new; array1.each { s.replace(s1) }
+ replace_100: s = Set.new; array1.each { s.replace(s2) }
+ replace_1000: s = Set.new; array1.each { s.replace(s3) }
+ reset_0: s0.reset
+ reset_10: s1.reset
+ reset_100: s2.reset
+ reset_1000: s3.reset
+ select_0: s0.select! { it }
+ select_10: s1.select! { it & 2 == 0 }
+ select_100: s2.select! { it & 2 == 0 }
+ select_1000: s3.select! { it & 2 == 0 }
+ size_0: s0.size
+ size_10: s1.size
+ size_100: s2.size
+ size_1000: s3.size
+ subtract_set: s3.dup.subtract(os3)
+ subtract_enum: s3.dup.subtract(oa3)
+ subtract_same_set: s3.dup.subtract(s3)
+ subtract_same_enum: s3.dup.subtract(a3)
+ subset_0: s0.subset? s0
+ subset_10: s1.subset? ss1
+ subset_100: s2.subset? ss2
+ subset_1000: s3.subset? ss3
+ subset_false_10: s1.subset? os1
+ subset_false_100: s2.subset? os2
+ subset_false_1000: s3.subset? os3
+ superset_0: s0.superset? s0
+ superset_10: ss1.superset? s1
+ superset_100: ss2.superset? s2
+ superset_1000: ss3.superset? s3
+ superset_false_10: os1.superset? s1
+ superset_false_100: os2.superset? s2
+ superset_false_1000: os3.superset? s3
+ to_a_0: s0.to_a
+ to_a_10: s1.to_a
+ to_a_100: s2.to_a
+ to_a_1000: s3.to_a
+ to_set_0: s0.to_set
+ to_set_10: s1.to_set
+ to_set_100: s2.to_set
+ to_set_1000: s3.to_set
diff --git a/benchmark/so_count_words.yml b/benchmark/so_count_words.yml
index 99683505f9..f7322a8541 100644
--- a/benchmark/so_count_words.yml
+++ b/benchmark/so_count_words.yml
@@ -15,13 +15,13 @@ prelude: |
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 :-).
+ 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:
@@ -38,8 +38,9 @@ prelude: |
13.times{
data << data
}
- open(wcinput, 'w'){|f| f.write data}
+ File.write(wcinput, data)
end
+ at_exit {File.unlink(wcinput) rescue nil}
end
prepare_wc_input(wc_input_base)
@@ -49,16 +50,16 @@ benchmark:
# $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
+ File.open(File.join(File.dirname($0), 'wc.input'), 'rb') do |input|
+ while tmp = input.read(4096)
+ data = tmp << (input.gets || "")
+ nc += data.length
+ nl += data.count("\n")
+ ((data.strip! || data).tr!("\n", " ") || data).squeeze!
+ nw += data.count(" ") + 1
+ end
end
# STDERR.puts "#{nl} #{nw} #{nc}"
diff --git a/benchmark/string_casecmp.yml b/benchmark/string_casecmp.yml
index 2354040a04..88a3555c8a 100644
--- a/benchmark/string_casecmp.yml
+++ b/benchmark/string_casecmp.yml
@@ -20,7 +20,9 @@ benchmark:
casecmp-10: lstr10.casecmp(ustr10)
casecmp-100: lstr100.casecmp(ustr100)
casecmp-1000: lstr1000.casecmp(ustr1000)
+ casecmp-1000vs10: lstr1000.casecmp(ustr10)
casecmp-nonascii1: lnonascii1.casecmp(unonascii1)
casecmp-nonascii10: lnonascii10.casecmp(unonascii10)
casecmp-nonascii100: lnonascii100.casecmp(unonascii100)
casecmp-nonascii1000: lnonascii1000.casecmp(unonascii1000)
+ casecmp-nonascii1000vs10: lnonascii1000.casecmp(unonascii10)
diff --git a/benchmark/string_codepoints.yml b/benchmark/string_codepoints.yml
new file mode 100644
index 0000000000..6a07db7ce1
--- /dev/null
+++ b/benchmark/string_codepoints.yml
@@ -0,0 +1,9 @@
+prelude: |
+ mixed_ascii64 = ("a" * 63 + "\u{100}") * 2048
+ mixed_ascii256 = ("a" * 255 + "\u{100}") * 512
+ utf8_2byte = "\u{100}" * 65536
+
+benchmark:
+ codepoints_mixed_ascii64: mixed_ascii64.codepoints
+ codepoints_mixed_ascii256: mixed_ascii256.codepoints
+ codepoints_utf8_2byte: utf8_2byte.codepoints
diff --git a/benchmark/string_coderange_scan.yml b/benchmark/string_coderange_scan.yml
new file mode 100644
index 0000000000..d47bbd2b30
--- /dev/null
+++ b/benchmark/string_coderange_scan.yml
@@ -0,0 +1,10 @@
+prelude: |
+ def unknown(s) = s.b.force_encoding("UTF-8")
+ multibyte = unknown("\u{00e9}" * 16384) # best case: every byte non-ASCII
+ alternating = unknown("\u{00e9}a" * 10922) # worst case: non-ASCII then ASCII
+ ascii = unknown("a" * 32768) # baseline
+
+benchmark:
+ coderange_multibyte: multibyte.dup.valid_encoding?
+ coderange_alternating: alternating.dup.valid_encoding?
+ coderange_ascii: ascii.dup.valid_encoding?
diff --git a/benchmark/string_concat.yml b/benchmark/string_concat.yml
index da14692f5e..c07fd21013 100644
--- a/benchmark/string_concat.yml
+++ b/benchmark/string_concat.yml
@@ -1,8 +1,8 @@
prelude: |
CHUNK = "a" * 64
UCHUNK = "é" * 32
- SHORT = "a" * (GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] / 2)
- LONG = "a" * (GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] * 2)
+ SHORT = "a" * (GC.stat_heap(0, :slot_size) / 2)
+ LONG = "a" * (GC.stat_heap(0, :slot_size) * 2)
GC.disable # GC causes a lot of variance
benchmark:
binary_concat_7bit: |
@@ -45,7 +45,7 @@ benchmark:
"#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}" \
"#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}" \
"#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}#{CHUNK}"
- interpolation_same_size_pool: |
+ interpolation_same_heap: |
buffer = "#{SHORT}#{SHORT}"
- interpolation_switching_size_pools: |
+ interpolation_switching_heaps: |
buffer = "#{SHORT}#{LONG}"
diff --git a/benchmark/string_dup.yml b/benchmark/string_dup.yml
new file mode 100644
index 0000000000..90793f9f2a
--- /dev/null
+++ b/benchmark/string_dup.yml
@@ -0,0 +1,7 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ uplus: |
+ +"A"
+ dup: |
+ "A".dup
diff --git a/benchmark/string_fstring.yml b/benchmark/string_fstring.yml
new file mode 100644
index 0000000000..cafef1f3fe
--- /dev/null
+++ b/benchmark/string_fstring.yml
@@ -0,0 +1,16 @@
+benchmark:
+ fstring_random: |
+ i = 0
+ str = "same".dup
+ while i < 5_000_000
+ -(i.to_s.freeze)
+ i += 1
+ end
+ fstring_same: |
+ i = 0
+ str = "same".dup
+ while i < 10_000_000
+ -str
+ i += 1
+ end
+loop_count: 1
diff --git a/benchmark/string_gsub.yml b/benchmark/string_gsub.yml
new file mode 100644
index 0000000000..c26e1a6498
--- /dev/null
+++ b/benchmark/string_gsub.yml
@@ -0,0 +1,54 @@
+prelude: |
+ # frozen_string_literal: true
+ STR = ((("a" * 31) + "<") * 1000).freeze
+ STR_UNICODE = ((("a" * 30) + "\u2028") * 1000).freeze
+ ESCAPED_CHARS_BINARY = {
+ "\u2028".b => '\u2028'.b,
+ "\u2029".b => '\u2029'.b,
+ ">".b => '\u003e'.b.freeze,
+ "<".b => '\u003c'.b.freeze,
+ "&".b => '\u0026'.b.freeze,
+ }
+ BINARY_PATTERN = Regexp.union(ESCAPED_CHARS_BINARY.keys)
+
+ ESCAPED_CHARS = {
+ "\u2028" => '\u2028',
+ "\u2029" => '\u2029',
+ ">" => '\u003e',
+ "<" => '\u003c',
+ "&" => '\u0026',
+ }
+ ESCAPE_PATTERN = Regexp.union(ESCAPED_CHARS.keys)
+
+ NO_MATCH_SHARED_STRING = ("a" * 100_000).freeze
+
+benchmark:
+ gsub_no_match_shared: |
+ str = NO_MATCH_SHARED_STRING.dup
+ str.gsub!("z", "x")
+ str
+
+ sub_no_match_shared: |
+ str = NO_MATCH_SHARED_STRING.dup
+ str.sub!("z", "x")
+ str
+
+ escape: |
+ str = STR.dup
+ str.gsub!(ESCAPE_PATTERN, ESCAPED_CHARS)
+ str
+
+ escape_bin: |
+ str = STR.b
+ str.gsub!(BINARY_PATTERN, ESCAPED_CHARS_BINARY)
+ str.force_encoding(Encoding::UTF_8)
+
+ escape_utf8: |
+ str = STR_UNICODE.dup
+ str.gsub!(ESCAPE_PATTERN, ESCAPED_CHARS)
+ str
+
+ escape_utf8_bin: |
+ str = STR_UNICODE.b
+ str.gsub!(BINARY_PATTERN, ESCAPED_CHARS_BINARY)
+ str.force_encoding(Encoding::UTF_8)
diff --git a/benchmark/string_memsearch.yml b/benchmark/string_memsearch.yml
new file mode 100644
index 0000000000..cde363289a
--- /dev/null
+++ b/benchmark/string_memsearch.yml
@@ -0,0 +1,75 @@
+prelude: |
+ # Haystacks of various sizes
+ small_hay = "a" * 256
+ medium_hay = "a" * 4096
+ large_hay = "a" * 65536
+
+ # Short needles (2-8 bytes) that exercise rb_memsearch_ss
+ needle_2 = "xy"
+ needle_4 = "xyzw"
+ needle_8 = "xyzwabcd"
+
+ # Needle whose first byte is absent from the haystack (memchr fast-path)
+ # vs needle whose first byte is common (rolling hash comparison)
+ first_byte_absent = "x" + "a" * 3
+ first_byte_common = "a" + "x" * 3
+
+ # Haystack with match at the end
+ hay_match_end = "a" * 4095 + "xy"
+
+ # Haystack with match at the start
+ hay_match_start = "xy" + "a" * 4094
+
+ # Mixed content haystack (more realistic)
+ mixed_hay = (("abcdefghij" * 100) + "z") * 10
+
+benchmark:
+ # === First byte absent from haystack (biggest win for rolling hash) ===
+ index_first_byte_absent_small: |
+ small_hay.index(first_byte_absent)
+ index_first_byte_absent_medium: |
+ medium_hay.index(first_byte_absent)
+ index_first_byte_absent_large: |
+ large_hay.index(first_byte_absent)
+
+ # === First byte common in haystack (stresses comparison loop) ===
+ index_first_byte_common_small: |
+ small_hay.index(first_byte_common)
+ index_first_byte_common_medium: |
+ medium_hay.index(first_byte_common)
+ index_first_byte_common_large: |
+ large_hay.index(first_byte_common)
+
+ # === Needle length variations (all absent) ===
+ index_needle_2_absent: |
+ medium_hay.index(needle_2)
+ index_needle_4_absent: |
+ medium_hay.index(needle_4)
+ index_needle_8_absent: |
+ medium_hay.index(needle_8)
+
+ # === Match at end of haystack ===
+ index_match_at_end: |
+ hay_match_end.index(needle_2)
+
+ # === Match at start of haystack ===
+ index_match_at_start: |
+ hay_match_start.index(needle_2)
+
+ # === include? (same code path) ===
+ include_first_byte_absent: |
+ medium_hay.include?(first_byte_absent)
+ include_first_byte_common: |
+ medium_hay.include?(first_byte_common)
+
+ # === byteindex ===
+ byteindex_first_byte_absent: |
+ medium_hay.byteindex(first_byte_absent)
+ byteindex_first_byte_common: |
+ medium_hay.byteindex(first_byte_common)
+
+ # === Mixed/realistic haystack ===
+ index_mixed_absent: |
+ mixed_hay.index(needle_4)
+ index_mixed_present: |
+ mixed_hay.index("ijab")
diff --git a/benchmark/string_rpartition.yml b/benchmark/string_rpartition.yml
new file mode 100644
index 0000000000..37e9d1b071
--- /dev/null
+++ b/benchmark/string_rpartition.yml
@@ -0,0 +1,18 @@
+prelude: |
+ str1 = [*"a".."z",*"0".."9"].join("")
+ str10 = str1 * 10 + ":"
+ str100 = str1 * 100 + ":"
+ str1000 = str1 * 1000 + ":"
+ nonascii1 = [*"\u{e0}".."\u{ff}"].join("")
+ nonascii10 = nonascii1 * 10 + ":"
+ nonascii100 = nonascii1 * 100 + ":"
+ nonascii1000 = nonascii1 * 1000 + ":"
+benchmark:
+ rpartition-1: str1.rpartition(":")
+ rpartition-10: str10.rpartition(":")
+ rpartition-100: str100.rpartition(":")
+ rpartition-1000: str1000.rpartition(":")
+ rpartition-nonascii1: nonascii1.rpartition(":")
+ rpartition-nonascii10: nonascii10.rpartition(":")
+ rpartition-nonascii100: nonascii100.rpartition(":")
+ rpartition-nonascii1000: nonascii1000.rpartition(":")
diff --git a/benchmark/string_scrub.yml b/benchmark/string_scrub.yml
new file mode 100644
index 0000000000..4b5faaad8e
--- /dev/null
+++ b/benchmark/string_scrub.yml
@@ -0,0 +1,48 @@
+prelude: |
+
+ STRING_SIZE = 1024
+ def duplicate_to_length(str, target_length)
+ return "" if target_length <= 0
+ return str[0, target_length] if str.length >= target_length
+
+ (str * ((target_length / str.length) + 1))[0, target_length]
+ end
+ base = "Hello \u{1f600} world! \u{00e9}\u{00f1}"
+ padding = duplicate_to_length(base, STRING_SIZE)
+
+ valid_utf8 = (padding.b + "OK".b).force_encoding("UTF-8")
+ valid_utf8.valid_encoding?
+ unknown_but_valid_utf8 = valid_utf8.dup.b.force_encoding("UTF-8")
+ invalid_utf8 = (padding.b + "\x80\xFF".b).force_encoding("UTF-8")
+ invalid_utf8.valid_encoding?
+ unknown_but_invalid_utf8 = (padding.b + "\x80\xFF".b).force_encoding("UTF-8")
+
+ worst_case_utf8 = duplicate_to_length("\u{1f600}\u{00e9}\u{00f1}", STRING_SIZE).b.force_encoding("UTF-8")
+
+ unknown_but_valid_utf8_worst_case = worst_case_utf8.dup.b.force_encoding("UTF-8")
+ unknown_but_invalid_utf8_worst_case = (worst_case_utf8.b + "\x80\xFF".b).force_encoding("UTF-8")
+
+benchmark:
+ scrub_known_valid: |
+ string = valid_utf8.dup
+ string.scrub!
+
+ scrub_known_invalid: |
+ string = invalid_utf8.dup
+ string.scrub!
+
+ scrub_unknown_but_valid_coderange: |
+ string = unknown_but_valid_utf8.dup
+ string.scrub!
+
+ scrub_unknown_and_invalid_coderange: |
+ string = unknown_but_invalid_utf8.dup
+ string.scrub!
+
+ scrub_unknown_but_valid_coderange_worst_case: |
+ string = unknown_but_valid_utf8_worst_case.dup
+ string.scrub!
+
+ scrub_unknown_and_invalid_coderange_worst_case: |
+ string = unknown_but_invalid_utf8_worst_case.dup
+ string.scrub! \ No newline at end of file
diff --git a/benchmark/struct_accessor.yml b/benchmark/struct_accessor.yml
new file mode 100644
index 0000000000..d95240e2dd
--- /dev/null
+++ b/benchmark/struct_accessor.yml
@@ -0,0 +1,37 @@
+prelude: |
+ C = Struct.new(:x) do
+ def initialize(...)
+ super
+ @ivar = 42
+ end
+
+ attr_accessor :ivar
+
+ class_eval <<-END
+ def r
+ #{'x;'*256}
+ end
+ def w
+ #{'self.x = nil;'*256}
+ end
+ def rm
+ m = method(:x)
+ #{'m.call;'*256}
+ end
+ def wm
+ m = method(:x=)
+ #{'m.call(nil);'*256}
+ end
+ def r_ivar
+ #{'ivar;'*256}
+ end
+ END
+ end
+ C.new(nil) # ensure common shape is known
+ obj = C.new(nil)
+benchmark:
+ member_reader: "obj.r"
+ member_writer: "obj.w"
+ member_reader_method: "obj.rm"
+ member_writer_method: "obj.wm"
+ ivar_reader: "obj.r_ivar"
diff --git a/benchmark/time_now.yml b/benchmark/time_now.yml
index f6d6a31489..9336877cd4 100644
--- a/benchmark/time_now.yml
+++ b/benchmark/time_now.yml
@@ -1,3 +1,4 @@
benchmark:
- 'Time.now'
- 'Time.now(in: "+09:00")'
+ - 'Time.now.year'
diff --git a/benchmark/time_strftime.yml b/benchmark/time_strftime.yml
new file mode 100644
index 0000000000..28f62aec87
--- /dev/null
+++ b/benchmark/time_strftime.yml
@@ -0,0 +1,7 @@
+prelude: |
+ # frozen_string_literal: true
+ time = Time.now
+benchmark:
+ - time.strftime("%FT%T") # 19B
+ - time.strftime("%FT%T.%3N") # 23B
+ - time.strftime("%FT%T.%6N") # 26B
diff --git a/benchmark/time_xmlschema.yml b/benchmark/time_xmlschema.yml
new file mode 100644
index 0000000000..654e5cfcbc
--- /dev/null
+++ b/benchmark/time_xmlschema.yml
@@ -0,0 +1,27 @@
+prelude: |
+ # frozen_string_literal
+ unless Time.method_defined?(:xmlschema)
+ class Time
+ def xmlschema(fraction_digits=0)
+ fraction_digits = fraction_digits.to_i
+ s = strftime("%FT%T")
+ if fraction_digits > 0
+ s << strftime(".%#{fraction_digits}N")
+ end
+ s << (utc? ? 'Z' : strftime("%:z"))
+ end
+ end
+ end
+ time = Time.now
+ utc_time = Time.now.utc
+ fraction_sec = Time.at(123456789.quo(9999999999)).getlocal("+09:00")
+ future_time = Time.utc(10000)
+benchmark:
+ - time.xmlschema
+ - utc_time.xmlschema
+ - time.xmlschema(6)
+ - utc_time.xmlschema(6)
+ - time.xmlschema(9)
+ - utc_time.xmlschema(9)
+ - fraction_sec.xmlschema(10)
+ - future_time.xmlschema
diff --git a/benchmark/vm_call_bmethod.yml b/benchmark/vm_call_bmethod.yml
new file mode 100644
index 0000000000..40136e5aa4
--- /dev/null
+++ b/benchmark/vm_call_bmethod.yml
@@ -0,0 +1,37 @@
+prelude: |
+ define_method(:a0){}
+ define_method(:a1){|a| a}
+ define_method(:s){|*a| a}
+ define_method(:b){|kw: 1| kw}
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t100 = 100.times.to_a
+ kw = {kw: 2}
+benchmark:
+ bmethod_simple_0: |
+ a0
+ bmethod_simple_1: |
+ a1(1)
+ bmethod_simple_0_splat: |
+ a0(*t0)
+ bmethod_simple_1_splat: |
+ a1(*t1)
+ bmethod_no_splat: |
+ s
+ bmethod_0_splat: |
+ s(*t0)
+ bmethod_1_splat: |
+ s(*t1)
+ bmethod_10_splat: |
+ s(*t10)
+ bmethod_100_splat: |
+ s(*t100)
+ bmethod_kw: |
+ b(kw: 1)
+ bmethod_no_kw: |
+ b
+ bmethod_kw_splat: |
+ b(**kw)
+loop_count: 6000000
diff --git a/benchmark/vm_call_kw_and_kw_splat.yml b/benchmark/vm_call_kw_and_kw_splat.yml
new file mode 100644
index 0000000000..aa6e549e0c
--- /dev/null
+++ b/benchmark/vm_call_kw_and_kw_splat.yml
@@ -0,0 +1,25 @@
+prelude: |
+ h1, h10, h100, h1000 = [1, 10, 100, 1000].map do |n|
+ h = {kw: 1}
+ n.times{|i| h[i.to_s.to_sym] = i}
+ h
+ end
+ eh = {}
+ def kw(kw: nil, **kws) end
+benchmark:
+ 1: |
+ kw(**h1)
+ 1_mutable: |
+ kw(**eh, **h1)
+ 10: |
+ kw(**h10)
+ 10_mutable: |
+ kw(**eh, **h10)
+ 100: |
+ kw(**h100)
+ 100_mutable: |
+ kw(**eh, **h100)
+ 1000: |
+ kw(**h1000)
+ 1000_mutable: |
+ kw(**eh, **h1000)
diff --git a/benchmark/vm_call_method_missing.yml b/benchmark/vm_call_method_missing.yml
new file mode 100644
index 0000000000..f890796f11
--- /dev/null
+++ b/benchmark/vm_call_method_missing.yml
@@ -0,0 +1,62 @@
+prelude: |
+ class A0
+ def method_missing(m); m end
+ end
+ class A1
+ def method_missing(m, a) a; end
+ end
+ class S
+ def method_missing(m, *a) a; end
+ end
+ class B
+ def method_missing(m, kw: 1) kw end
+ end
+ class SB
+ def method_missing(m, *a, kw: 1) kw end
+ end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+ kw = {kw: 2}
+
+ a0 = A0.new
+ a1 = A1.new
+ s = S.new
+ b = B.new
+ sb = SB.new
+benchmark:
+ method_missing_simple_0: |
+ a0.()
+ method_missing_simple_1: |
+ a1.x(1)
+ method_missing_simple_0_splat: |
+ a0.(*t0)
+ method_missing_simple_1_splat: |
+ a1.(*t1)
+ method_missing_no_splat: |
+ s.()
+ method_missing_0_splat: |
+ s.(*t0)
+ method_missing_1_splat: |
+ s.(*t1)
+ method_missing_10_splat: |
+ s.(*t10)
+ method_missing_200_splat: |
+ s.(*t200)
+ method_missing_kw: |
+ b.(kw: 1)
+ method_missing_no_kw: |
+ b.()
+ method_missing_kw_splat: |
+ b.(**kw)
+ method_missing_0_splat_kw: |
+ sb.(*t0, **kw)
+ method_missing_1_splat_kw: |
+ sb.(*t1, **kw)
+ method_missing_10_splat_kw: |
+ sb.(*t10, **kw)
+ method_missing_200_splat_kw: |
+ sb.(*t200, **kw)
+loop_count: 1000000
diff --git a/benchmark/vm_call_send_iseq.yml b/benchmark/vm_call_send_iseq.yml
new file mode 100644
index 0000000000..60ff23c475
--- /dev/null
+++ b/benchmark/vm_call_send_iseq.yml
@@ -0,0 +1,77 @@
+prelude: |
+ def a0; end
+ def a1(a) a; end
+ def s(*a) a; end
+ def b(kw: 1) kw end
+ def sb(*a, kw: 1) kw end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+
+ a0_t0 = [:a0, *t0]
+ a1_t1 = [:a1, *t1]
+ s_t0 = [:s, *t0]
+ s_t1 = [:s, *t1]
+ s_t10 = [:s, *t10]
+ s_t200 = [:s, *t200]
+ sb_t0 = [:sb, *t0]
+ sb_t1 = [:sb, *t1]
+ sb_t10 = [:sb, *t10]
+ sb_t200 = [:sb, *t200]
+ kw = {kw: 2}
+benchmark:
+ send_simple_0: |
+ send(:a0)
+ send_simple_1: |
+ send(:a1, 1)
+ send_simple_0_splat: |
+ send(:a0, *t0)
+ send_simple_1_splat: |
+ send(:a1, *t1)
+ send_simple_0_splat_comb: |
+ send(*a0_t0)
+ send_simple_1_splat_comb: |
+ send(*a1_t1)
+ send_no_splat: |
+ send(:s)
+ send_0_splat: |
+ send(:s, *t0)
+ send_1_splat: |
+ send(:s, *t1)
+ send_10_splat: |
+ send(:s, *t10)
+ send_200_splat: |
+ send(:s, *t200)
+ send_0_splat_comb: |
+ send(*s_t0)
+ send_1_splat_comb: |
+ send(*s_t1)
+ send_10_splat_comb: |
+ send(*s_t10)
+ send_200_splat_comb: |
+ send(*s_t200)
+ send_kw: |
+ send(:b, kw: 1)
+ send_no_kw: |
+ send(:b)
+ send_kw_splat: |
+ send(:b, **kw)
+ send_0_splat_kw: |
+ send(:sb, *t0, **kw)
+ send_1_splat_kw: |
+ send(:sb, *t1, **kw)
+ send_10_splat_kw: |
+ send(:sb, *t10, **kw)
+ send_200_splat_kw: |
+ send(:sb, *t200, **kw)
+ send_0_splat_comb_kw: |
+ send(*sb_t0, **kw)
+ send_1_splat_comb_kw: |
+ send(*sb_t1, **kw)
+ send_10_splat_comb_kw: |
+ send(*sb_t10, **kw)
+ send_200_splat_comb_kw: |
+ send(*sb_t200, **kw)
+loop_count: 3000000
diff --git a/benchmark/vm_call_symproc.yml b/benchmark/vm_call_symproc.yml
new file mode 100644
index 0000000000..16e0ac579e
--- /dev/null
+++ b/benchmark/vm_call_symproc.yml
@@ -0,0 +1,83 @@
+prelude: |
+ def self.a0; end
+ def self.a1(a) a; end
+ def self.s(*a) a; end
+ def self.b(kw: 1) kw end
+ def self.sb(*a, kw: 1) kw end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+
+ a0_t0 = [self, *t0]
+ a1_t1 = [self, *t1]
+ s_t0 = [self, *t0]
+ s_t1 = [self, *t1]
+ s_t10 = [self, *t10]
+ s_t200 = [self, *t200]
+ sb_t0 = [self, *t0]
+ sb_t1 = [self, *t1]
+ sb_t10 = [self, *t10]
+ sb_t200 = [self, *t200]
+ kw = {kw: 2}
+
+ a0 = :a0.to_proc
+ a1 = :a1.to_proc
+ s = :s.to_proc
+ b = :b.to_proc
+ sb = :sb.to_proc
+benchmark:
+ symproc_simple_0: |
+ a0.(self)
+ symproc_simple_1: |
+ a1.(self, 1)
+ symproc_simple_0_splat: |
+ a0.(self, *t0)
+ symproc_simple_1_splat: |
+ a1.(self, *t1)
+ symproc_simple_0_splat_comb: |
+ a0.(*a0_t0)
+ symproc_simple_1_splat_comb: |
+ a1.(*a1_t1)
+ symproc_no_splat: |
+ s.(self)
+ symproc_0_splat: |
+ s.(self, *t0)
+ symproc_1_splat: |
+ s.(self, *t1)
+ symproc_10_splat: |
+ s.(self, *t10)
+ symproc_200_splat: |
+ s.(self, *t200)
+ symproc_0_splat_comb: |
+ s.(*s_t0)
+ symproc_1_splat_comb: |
+ s.(*s_t1)
+ symproc_10_splat_comb: |
+ s.(*s_t10)
+ symproc_200_splat_comb: |
+ s.(*s_t200)
+ symproc_kw: |
+ b.(self, kw: 1)
+ symproc_no_kw: |
+ b.(self)
+ symproc_kw_splat: |
+ b.(self, **kw)
+ symproc_0_splat_kw: |
+ sb.(self, *t0, **kw)
+ symproc_1_splat_kw: |
+ sb.(self, *t1, **kw)
+ symproc_10_splat_kw: |
+ sb.(self, *t10, **kw)
+ symproc_200_splat_kw: |
+ sb.(self, *t200, **kw)
+ symproc_0_splat_comb_kw: |
+ sb.(*sb_t0, **kw)
+ symproc_1_splat_comb_kw: |
+ sb.(*sb_t1, **kw)
+ symproc_10_splat_comb_kw: |
+ sb.(*sb_t10, **kw)
+ symproc_200_splat_comb_kw: |
+ sb.(*sb_t200, **kw)
+loop_count: 1000000
diff --git a/benchmark/vm_ivar_get.yml b/benchmark/vm_ivar_get.yml
index 9174af6965..1e0dad665f 100644
--- a/benchmark/vm_ivar_get.yml
+++ b/benchmark/vm_ivar_get.yml
@@ -1,17 +1,75 @@
prelude: |
class Example
def initialize
+ @levar = 1
@v0 = 1
@v1 = 2
@v3 = 3
+ end
+
+ def get_value_loop
+ sum = 0
+
+ i = 0
+ while i < 100_000
+ # 10 times to de-emphasize loop overhead
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ i += 1
+ end
+
+ return sum
+ end
+
+ @levar = 1
+ @v0 = 1
+ @v1 = 2
+ @v3 = 3
+
+ def self.get_value_loop
+ sum = 0
+
+ i = 0
+ while i < 100_000
+ # 10 times to de-emphasize loop overhead
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ sum += @levar
+ i += 1
+ end
+
+ return sum
+ end
+ end
+
+ class GenExample < Time
+ def initialize
@levar = 1
+ @v0 = 1
+ @v1 = 2
+ @v3 = 3
end
def get_value_loop
sum = 0
i = 0
- while i < 1000000
+ while i < 100_000
# 10 times to de-emphasize loop overhead
sum += @levar
sum += @levar
@@ -31,7 +89,12 @@ prelude: |
end
obj = Example.new
+ gen = GenExample.new
benchmark:
- vm_ivar_get: |
+ vm_ivar_get_on_obj: |
obj.get_value_loop
+ vm_ivar_get_on_class: |
+ Example.get_value_loop
+ vm_ivar_get_on_generic: |
+ gen.get_value_loop
loop_count: 100
diff --git a/benchmark/vm_ivar_ic_miss.yml b/benchmark/vm_ivar_ic_miss.yml
new file mode 100644
index 0000000000..944fb1a9e6
--- /dev/null
+++ b/benchmark/vm_ivar_ic_miss.yml
@@ -0,0 +1,20 @@
+prelude: |
+ class Foo
+ def initialize diverge
+ if diverge
+ @a = 1
+ end
+
+ @a0 = @a1 = @a2 = @a3 = @a4 = @a5 = @a6 = @a7 = @a8 = @a9 = @a10 = @a11 = @a12 = @a13 = @a14 = @a15 = @a16 = @a17 = @a18 = @a19 = @a20 = @a21 = @a22 = @a23 = @a24 = @a25 = @a26 = @a27 = @a28 = @a29 = @a30 = @a31 = @a32 = @a33 = @a34 = @a35 = @a36 = @a37 = @a38 = @a39 = @a40 = @a41 = @a42 = @a43 = @a44 = @a45 = @a46 = @a47 = @a48 = @a49 = @a50 = @a51 = @a52 = @a53 = @a54 = @a55 = @a56 = @a57 = @a58 = @a59 = @a60 = @a61 = @a62 = @a63 = @a64 = @a65 = @a66 = @a67 = @a68 = @a69 = @a70 = @a71 = @a72 = @a73 = @a74 = @b = 1
+ end
+
+ def b; @b; end
+ end
+
+ a = Foo.new false
+ b = Foo.new true
+benchmark:
+ vm_ivar_ic_miss: |
+ a.b
+ b.b
+loop_count: 30000000
diff --git a/benchmark/vm_ivar_memoize.yml b/benchmark/vm_ivar_memoize.yml
new file mode 100644
index 0000000000..90f6b07f05
--- /dev/null
+++ b/benchmark/vm_ivar_memoize.yml
@@ -0,0 +1,85 @@
+prelude: |
+ IVARS = 60
+ class Record
+ def initialize(offset = false)
+ @offset = 1 if offset
+ @first = 0
+ IVARS.times do |i|
+ instance_variable_set("@ivar_#{i}", i)
+ end
+ end
+
+ def first
+ @first
+ end
+
+ def lazy_set
+ @lazy_set ||= 123
+ end
+
+ def undef
+ @undef
+ end
+ end
+
+ Record.new # Need one alloc to right size
+
+ BASE = Record.new
+ LAZY = Record.new
+ LAZY.lazy_set
+
+ class Miss < Record
+ @first = 0
+ IVARS.times do |i|
+ instance_variable_set("@i_#{i}", i)
+ end
+ end
+
+ Miss.new # Need one alloc to right size
+ MISS = Miss.new
+
+ DIVERGENT = Record.new(true)
+
+benchmark:
+ vm_ivar_stable_shape: |
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ vm_ivar_memoize_unstable_shape: |
+ BASE.first
+ LAZY.first
+ BASE.first
+ LAZY.first
+ BASE.first
+ LAZY.first
+ vm_ivar_memoize_unstable_shape_miss: |
+ BASE.first
+ MISS.first
+ BASE.first
+ MISS.first
+ BASE.first
+ MISS.first
+ vm_ivar_unstable_undef: |
+ BASE.undef
+ LAZY.undef
+ BASE.undef
+ LAZY.undef
+ BASE.undef
+ LAZY.undef
+ vm_ivar_divergent_shape: |
+ BASE.first
+ DIVERGENT.first
+ BASE.first
+ DIVERGENT.first
+ BASE.first
+ DIVERGENT.first
+ vm_ivar_divergent_shape_imbalanced: |
+ BASE.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
diff --git a/benchmark/vm_ivar_set_on_instance.yml b/benchmark/vm_ivar_set_on_instance.yml
index 91857b7742..6ce53a86ec 100644
--- a/benchmark/vm_ivar_set_on_instance.yml
+++ b/benchmark/vm_ivar_set_on_instance.yml
@@ -1,16 +1,44 @@
prelude: |
class TheClass
def initialize
+ @levar = 1
@v0 = 1
@v1 = 2
@v3 = 3
+ end
+
+ def set_value_loop
+ # 100k
+ i = 0
+ while i < 100_000
+ # 10 times to de-emphasize loop overhead
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ i += 1
+ end
+ end
+ end
+
+ class Generic < Time
+ def initialize
@levar = 1
+ @v0 = 1
+ @v1 = 2
+ @v3 = 3
end
def set_value_loop
- # 1M
+ # 100k
i = 0
- while i < 1000000
+ while i < 100_000
# 10 times to de-emphasize loop overhead
@levar = i
@levar = i
@@ -28,8 +56,39 @@ prelude: |
end
obj = TheClass.new
+ gen_obj = Generic.new
+
+ class SomeClass
+ @levar = 1
+ @v0 = 1
+ @v1 = 2
+ @v3 = 3
+
+ def self.set_value_loop
+ # 100k
+ i = 0
+ while i < 100_000
+ # 10 times to de-emphasize loop overhead
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ @levar = i
+ i += 1
+ end
+ end
+ end
benchmark:
vm_ivar_set_on_instance: |
obj.set_value_loop
+ vm_ivar_set_on_generic: |
+ gen_obj.set_value_loop
+ vm_ivar_set_on_class: |
+ SomeClass.set_value_loop
loop_count: 100
diff --git a/benchmark/vm_method_splat_calls.yml b/benchmark/vm_method_splat_calls.yml
new file mode 100644
index 0000000000..f2f366e99c
--- /dev/null
+++ b/benchmark/vm_method_splat_calls.yml
@@ -0,0 +1,13 @@
+prelude: |
+ def f(x=0, y: 0) end
+ a = [1]
+ ea = []
+ kw = {y: 1}
+ b = lambda{}
+benchmark:
+ arg_splat: "f(1, *ea)"
+ arg_splat_block: "f(1, *ea, &b)"
+ splat_kw_splat: "f(*a, **kw)"
+ splat_kw_splat_block: "f(*a, **kw, &b)"
+ splat_kw: "f(*a, y: 1)"
+ splat_kw_block: "f(*a, y: 1, &b)"
diff --git a/benchmark/vm_method_splat_calls2.yml b/benchmark/vm_method_splat_calls2.yml
new file mode 100644
index 0000000000..d33dcd7e8b
--- /dev/null
+++ b/benchmark/vm_method_splat_calls2.yml
@@ -0,0 +1,27 @@
+prelude: |
+ def named_arg_splat(*a) end
+ def named_arg_kw_splat(*a, **kw) end
+ def anon_arg_splat(*) end
+ def anon_kw_splat(**) end
+ def anon_arg_kw_splat(*, **) end
+ def anon_fw_to_named(*, **) named_arg_kw_splat(*, **) end
+ def fw_to_named(...) named_arg_kw_splat(...) end
+ def fw_to_anon_to_named(...) anon_fw_to_named(...) end
+ def fw_no_kw(...) named_arg_splat(...) end
+ a = [1]
+ kw = {y: 1}
+benchmark:
+ named_multi_arg_splat: "named_arg_splat(*a, *a)"
+ named_post_splat: "named_arg_splat(*a, a)"
+ anon_arg_splat: "anon_arg_splat(*a)"
+ anon_arg_kw_splat: "anon_arg_kw_splat(*a, **kw)"
+ anon_multi_arg_splat: "anon_arg_splat(*a, *a)"
+ anon_post_splat: "anon_arg_splat(*a, a)"
+ anon_kw_splat: "anon_kw_splat(**kw)"
+ anon_fw_to_named_splat: "anon_fw_to_named(*a, **kw)"
+ anon_fw_to_named_no_splat: "anon_fw_to_named(1, y: 1)"
+ fw_to_named_splat: "fw_to_named(*a, **kw)"
+ fw_to_named_no_splat: "fw_to_named(1, y: 1)"
+ fw_to_anon_to_named_splat: "fw_to_anon_to_named(*a, **kw)"
+ fw_to_anon_to_named_no_splat: "fw_to_anon_to_named(1, y: 1)"
+ fw_no_kw: "fw_no_kw(1, 2)"
diff --git a/benchmark/vm_regexp.yml b/benchmark/vm_regexp.yml
index 2aa3d94dbd..80541332b1 100644
--- a/benchmark/vm_regexp.yml
+++ b/benchmark/vm_regexp.yml
@@ -3,6 +3,12 @@ prelude: |
benchmark:
vm_regexp: |
/hoge/ =~ str
+ vm_regexp_alternating: |
+ /hoge/ =~ str
+ /huge/ =~ str
vm_regexp_invert: |
str =~ /hoge/
+ vm_regexp_invert_alternating: |
+ str =~ /hoge/
+ str =~ /huge/
loop_count: 6000000
diff --git a/benchmark/vm_send_cfunc.yml b/benchmark/vm_send_cfunc.yml
index b114ac317d..6f12b65176 100644
--- a/benchmark/vm_send_cfunc.yml
+++ b/benchmark/vm_send_cfunc.yml
@@ -1,3 +1,14 @@
+prelude: |
+ ary = []
+ kw = {a: 1}
+ empty_kw = {}
+ kw_ary = [Hash.ruby2_keywords_hash(a: 1)]
+ empty_kw_ary = [Hash.ruby2_keywords_hash({})]
benchmark:
- vm_send_cfunc: self.class
-loop_count: 100000000
+ vm_send_cfunc: itself
+ vm_send_cfunc_splat: itself(*ary)
+ vm_send_cfunc_splat_kw_hash: equal?(*kw_ary)
+ vm_send_cfunc_splat_empty_kw_hash: itself(*empty_kw_ary)
+ vm_send_cfunc_splat_kw: equal?(*ary, **kw)
+ vm_send_cfunc_splat_empty_kw: itself(*ary, **empty_kw)
+loop_count: 20000000
diff --git a/benchmark/vm_super_splat_calls.yml b/benchmark/vm_super_splat_calls.yml
new file mode 100644
index 0000000000..795e44e4da
--- /dev/null
+++ b/benchmark/vm_super_splat_calls.yml
@@ -0,0 +1,25 @@
+prelude: |
+ @a = [1].freeze
+ @ea = [].freeze
+ @kw = {y: 1}.freeze
+ @b = lambda{}
+ extend(Module.new{def arg_splat(x=0, y: 0) end})
+ extend(Module.new{def arg_splat_block(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_splat(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_splat_block(x=0, y: 0) end})
+ extend(Module.new{def splat_kw(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_block(x=0, y: 0) end})
+
+ extend(Module.new{def arg_splat; super(1, *@ea) end})
+ extend(Module.new{def arg_splat_block; super(1, *@ea, &@b) end})
+ extend(Module.new{def splat_kw_splat; super(*@a, **@kw) end})
+ extend(Module.new{def splat_kw_splat_block; super(*@a, **@kw, &@b) end})
+ extend(Module.new{def splat_kw; super(*@a, y: 1) end})
+ extend(Module.new{def splat_kw_block; super(*@a, y: 1, &@b) end})
+benchmark:
+ arg_splat: "arg_splat"
+ arg_splat_block: "arg_splat_block"
+ splat_kw_splat: "splat_kw_splat"
+ splat_kw_splat_block: "splat_kw_splat_block"
+ splat_kw: "splat_kw"
+ splat_kw_block: "splat_kw_block"
diff --git a/benchmark/vm_zsuper_splat_calls.yml b/benchmark/vm_zsuper_splat_calls.yml
new file mode 100644
index 0000000000..82dc22349d
--- /dev/null
+++ b/benchmark/vm_zsuper_splat_calls.yml
@@ -0,0 +1,28 @@
+prelude: |
+ a = [1].freeze
+ ea = [].freeze
+ kw = {y: 1}.freeze
+ b = lambda{}
+ extend(Module.new{def arg_splat(x=0, y: 0) end})
+ extend(Module.new{def arg_splat_block(x=0, y: 0) end})
+ extend(Module.new{def arg_splat_post(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_splat(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_splat_block(x=0, y: 0) end})
+ extend(Module.new{def splat_kw(x=0, y: 0) end})
+ extend(Module.new{def splat_kw_block(x=0, y: 0) end})
+
+ extend(Module.new{def arg_splat(x, *a) super end})
+ extend(Module.new{def arg_splat_block(x, *a, &b) super end})
+ extend(Module.new{def arg_splat_post(*a, x) super end})
+ extend(Module.new{def splat_kw_splat(*a, **kw) super end})
+ extend(Module.new{def splat_kw_splat_block(*a, **kw, &b) super end})
+ extend(Module.new{def splat_kw(*a, y: 1) super end})
+ extend(Module.new{def splat_kw_block(*a, y: 1, &b) super end})
+benchmark:
+ arg_splat: "arg_splat(1, *ea)"
+ arg_splat_block: "arg_splat_block(1, *ea, &b)"
+ arg_splat_post: "arg_splat_post(1, *ea, &b)"
+ splat_kw_splat: "splat_kw_splat(*a, **kw)"
+ splat_kw_splat_block: "splat_kw_splat_block(*a, **kw, &b)"
+ splat_kw: "splat_kw(*a, y: 1)"
+ splat_kw_block: "splat_kw_block(*a, y: 1, &b)"
diff --git a/bignum.c b/bignum.c
index 466b21abc0..28924b4eb9 100644
--- a/bignum.c
+++ b/bignum.c
@@ -30,9 +30,6 @@
# define USE_GMP 0
#endif
#endif
-#if USE_GMP
-# include <gmp.h>
-#endif
#include "id.h"
#include "internal.h"
@@ -48,8 +45,40 @@
#include "ruby/util.h"
#include "ruby_assert.h"
+#if USE_GMP
+RBIMPL_WARNING_PUSH()
+# ifdef _MSC_VER
+RBIMPL_WARNING_IGNORED(4146) /* for mpn_neg() */
+# endif
+# include <gmp.h>
+RBIMPL_WARNING_POP()
+#endif
+
+static const bool debug_integer_pack = (
+#ifdef DEBUG_INTEGER_PACK
+ DEBUG_INTEGER_PACK+0
+#else
+ RUBY_DEBUG
+#endif
+ ) != 0;
+
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+/* Two-digit decimal lookup table. Offset 2*n holds the ASCII pair for
+ * n in the range 0..99. Used by both rb_fix2str in numeric.c and
+ * big2str_2bdigits below to emit two base-10 digits per iteration. */
+const char ruby_decimal_digit_pairs[201] =
+ "00010203040506070809"
+ "10111213141516171819"
+ "20212223242526272829"
+ "30313233343536373839"
+ "40414243444546474849"
+ "50515253545556575859"
+ "60616263646566676869"
+ "70717273747576777879"
+ "80818283848586878889"
+ "90919293949596979899";
+
#ifndef SIZEOF_BDIGIT_DBL
# if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
# define SIZEOF_BDIGIT_DBL SIZEOF_LONG_LONG
@@ -65,7 +94,6 @@ STATIC_ASSERT(sizeof_bdigit_and_dbl, SIZEOF_BDIGIT*2 <= SIZEOF_BDIGIT_DBL);
STATIC_ASSERT(bdigit_signedness, 0 < (BDIGIT)-1);
STATIC_ASSERT(bdigit_dbl_signedness, 0 < (BDIGIT_DBL)-1);
STATIC_ASSERT(bdigit_dbl_signed_signedness, 0 > (BDIGIT_DBL_SIGNED)-1);
-STATIC_ASSERT(rbignum_embed_len_max, BIGNUM_EMBED_LEN_MAX <= (BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT));
#if SIZEOF_BDIGIT < SIZEOF_LONG
STATIC_ASSERT(sizeof_long_and_sizeof_bdigit, SIZEOF_LONG % SIZEOF_BDIGIT == 0);
@@ -341,7 +369,7 @@ maxpow_in_bdigit_dbl(int base, int *exp_ret)
BDIGIT_DBL maxpow;
int exponent;
- assert(2 <= base && base <= 36);
+ RUBY_ASSERT(2 <= base && base <= 36);
{
#if SIZEOF_BDIGIT_DBL == 2
@@ -373,7 +401,7 @@ maxpow_in_bdigit_dbl(int base, int *exp_ret)
static inline BDIGIT_DBL
bary2bdigitdbl(const BDIGIT *ds, size_t n)
{
- assert(n <= 2);
+ RUBY_ASSERT(n <= 2);
if (n == 2)
return ds[0] | BIGUP(ds[1]);
@@ -385,7 +413,7 @@ bary2bdigitdbl(const BDIGIT *ds, size_t n)
static inline void
bdigitdbl2bary(BDIGIT *ds, size_t n, BDIGIT_DBL num)
{
- assert(n == 2);
+ RUBY_ASSERT(n == 2);
ds[0] = BIGLO(num);
ds[1] = (BDIGIT)BIGDN(num);
@@ -416,7 +444,7 @@ bary_small_lshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift)
{
size_t i;
BDIGIT_DBL num = 0;
- assert(0 <= shift && shift < BITSPERDIG);
+ RUBY_ASSERT(0 <= shift && shift < BITSPERDIG);
for (i=0; i<n; i++) {
num = num | (BDIGIT_DBL)*xds++ << shift;
@@ -432,7 +460,7 @@ bary_small_rshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift, BDIGIT hi
size_t i;
BDIGIT_DBL num = 0;
- assert(0 <= shift && shift < BITSPERDIG);
+ RUBY_ASSERT(0 <= shift && shift < BITSPERDIG);
num = BIGUP(higher_bdigit);
for (i = 0; i < n; i++) {
@@ -1049,15 +1077,13 @@ integer_unpack_num_bdigits(size_t numwords, size_t wordsize, size_t nails, int *
if (numwords <= (SIZE_MAX - (BITSPERDIG-1)) / CHAR_BIT / wordsize) {
num_bdigits = integer_unpack_num_bdigits_small(numwords, wordsize, nails, nlp_bits_ret);
-#ifdef DEBUG_INTEGER_PACK
- {
+ if (debug_integer_pack) {
int nlp_bits1;
size_t num_bdigits1 = integer_unpack_num_bdigits_generic(numwords, wordsize, nails, &nlp_bits1);
- assert(num_bdigits == num_bdigits1);
- assert(*nlp_bits_ret == nlp_bits1);
+ RUBY_ASSERT(num_bdigits == num_bdigits1);
+ RUBY_ASSERT(*nlp_bits_ret == nlp_bits1);
(void)num_bdigits1;
}
-#endif
}
else {
num_bdigits = integer_unpack_num_bdigits_generic(numwords, wordsize, nails, nlp_bits_ret);
@@ -1265,7 +1291,7 @@ bary_unpack_internal(BDIGIT *bdigits, size_t num_bdigits, const void *words, siz
}
if (dd)
*dp++ = (BDIGIT)dd;
- assert(dp <= de);
+ RUBY_ASSERT(dp <= de);
while (dp < de)
*dp++ = 0;
#undef PUSH_BITS
@@ -1324,7 +1350,7 @@ bary_unpack(BDIGIT *bdigits, size_t num_bdigits, const void *words, size_t numwo
num_bdigits0 = integer_unpack_num_bdigits(numwords, wordsize, nails, &nlp_bits);
- assert(num_bdigits0 <= num_bdigits);
+ RUBY_ASSERT(num_bdigits0 <= num_bdigits);
sign = bary_unpack_internal(bdigits, num_bdigits0, words, numwords, wordsize, nails, flags, nlp_bits);
@@ -1343,8 +1369,8 @@ bary_subb(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yd
size_t i;
size_t sn;
- assert(xn <= zn);
- assert(yn <= zn);
+ RUBY_ASSERT(xn <= zn);
+ RUBY_ASSERT(yn <= zn);
sn = xn < yn ? xn : yn;
@@ -1405,8 +1431,8 @@ bary_addc(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yd
BDIGIT_DBL num;
size_t i;
- assert(xn <= zn);
- assert(yn <= zn);
+ RUBY_ASSERT(xn <= zn);
+ RUBY_ASSERT(yn <= zn);
if (xn > yn) {
const BDIGIT *tds;
@@ -1470,7 +1496,7 @@ bary_mul_single(BDIGIT *zds, size_t zn, BDIGIT x, BDIGIT y)
{
BDIGIT_DBL n;
- assert(2 <= zn);
+ RUBY_ASSERT(2 <= zn);
n = (BDIGIT_DBL)x * y;
bdigitdbl2bary(zds, 2, n);
@@ -1484,7 +1510,7 @@ bary_muladd_1xN(BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
BDIGIT_DBL dd;
size_t j;
- assert(zn > yn);
+ RUBY_ASSERT(zn > yn);
if (x == 0)
return 0;
@@ -1519,7 +1545,7 @@ bigdivrem_mulsub(BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
BDIGIT_DBL t2;
BDIGIT_DBL_SIGNED num;
- assert(zn == yn + 1);
+ RUBY_ASSERT(zn == yn + 1);
num = 0;
t2 = 0;
@@ -1544,7 +1570,7 @@ bary_mulsub_1xN(BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
{
BDIGIT_DBL_SIGNED num;
- assert(zn == yn + 1);
+ RUBY_ASSERT(zn == yn + 1);
num = bigdivrem_mulsub(zds, zn, x, yds, yn);
zds[yn] = BIGLO(num);
@@ -1558,7 +1584,7 @@ bary_mul_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIG
{
size_t i;
- assert(xn + yn <= zn);
+ RUBY_ASSERT(xn + yn <= zn);
BDIGITS_ZERO(zds, zn);
for (i = 0; i < xn; i++) {
@@ -1589,7 +1615,7 @@ bary_sq_fast(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn)
BDIGIT vl;
int vh;
- assert(xn * 2 <= zn);
+ RUBY_ASSERT(xn * 2 <= zn);
BDIGITS_ZERO(zds, zn);
@@ -1661,9 +1687,9 @@ bary_mul_balance_with_mulfunc(BDIGIT *const zds, const size_t zn,
VALUE work = 0;
size_t n;
- assert(xn + yn <= zn);
- assert(xn <= yn);
- assert(!KARATSUBA_BALANCED(xn, yn) || !TOOM3_BALANCED(xn, yn));
+ RUBY_ASSERT(xn + yn <= zn);
+ RUBY_ASSERT(xn <= yn);
+ RUBY_ASSERT(!KARATSUBA_BALANCED(xn, yn) || !TOOM3_BALANCED(xn, yn));
BDIGITS_ZERO(zds, xn);
@@ -1745,9 +1771,9 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const B
const BDIGIT *xds0, *xds1, *yds0, *yds1;
BDIGIT *zds0, *zds1, *zds2, *zds3;
- assert(xn + yn <= zn);
- assert(xn <= yn);
- assert(yn < 2 * xn);
+ RUBY_ASSERT(xn + yn <= zn);
+ RUBY_ASSERT(xn <= yn);
+ RUBY_ASSERT(yn < 2 * xn);
sq = xds == yds && xn == yn;
@@ -1762,7 +1788,7 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const B
n = yn / 2;
- assert(n < xn);
+ RUBY_ASSERT(n < xn);
if (wn < n) {
/* This function itself needs only n BDIGITs for work area.
@@ -1883,7 +1909,7 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const B
for (x = 0, i = xn-1; 0 <= i; i--) { x <<= SIZEOF_BDIGIT*CHAR_BIT; x |= xds[i]; }
for (y = 0, i = yn-1; 0 <= i; i--) { y <<= SIZEOF_BDIGIT*CHAR_BIT; y |= yds[i]; }
for (z = 0, i = zn-1; 0 <= i; i--) { z <<= SIZEOF_BDIGIT*CHAR_BIT; z |= zds[i]; }
- assert(z == x * y);
+ RUBY_ASSERT(z == x * y);
}
*/
@@ -1951,11 +1977,11 @@ bary_mul_toom3(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGI
int sq = xds == yds && xn == yn;
- assert(xn <= yn); /* assume y >= x */
- assert(xn + yn <= zn);
+ RUBY_ASSERT(xn <= yn); /* assume y >= x */
+ RUBY_ASSERT(xn + yn <= zn);
n = (yn + 2) / 3;
- assert(2*n < xn);
+ RUBY_ASSERT(2*n < xn);
wnc = 0;
@@ -2142,19 +2168,19 @@ bary_mul_toom3(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGI
/* z(1) : t1 <- u1 * v1 */
bary_mul_toom3_start(t1ds, t1n, u1ds, u1n, v1ds, v1n, wds, wn);
t1p = u1p == v1p;
- assert(t1ds[t1n-1] == 0);
+ RUBY_ASSERT(t1ds[t1n-1] == 0);
t1n--;
/* z(-1) : t2 <- u2 * v2 */
bary_mul_toom3_start(t2ds, t2n, u2ds, u2n, v2ds, v2n, wds, wn);
t2p = u2p == v2p;
- assert(t2ds[t2n-1] == 0);
+ RUBY_ASSERT(t2ds[t2n-1] == 0);
t2n--;
/* z(-2) : t3 <- u3 * v3 */
bary_mul_toom3_start(t3ds, t3n, u3ds, u3n, v3ds, v3n, wds, wn);
t3p = u3p == v3p;
- assert(t3ds[t3n-1] == 0);
+ RUBY_ASSERT(t3ds[t3n-1] == 0);
t3n--;
/* z(inf) : t4 <- x2 * y2 */
@@ -2330,7 +2356,7 @@ bary_mul_gmp(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT
mpz_t x, y, z;
size_t count;
- assert(xn + yn <= zn);
+ RUBY_ASSERT(xn + yn <= zn);
mpz_init(x);
mpz_init(y);
@@ -2365,7 +2391,7 @@ rb_big_mul_gmp(VALUE x, VALUE y)
static void
bary_short_mul(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
{
- assert(xn + yn <= zn);
+ RUBY_ASSERT(xn + yn <= zn);
if (xn == 1 && yn == 1) {
bary_mul_single(zds, zn, xds[0], yds[0]);
@@ -2401,7 +2427,7 @@ bary_mul_precheck(BDIGIT **zdsp, size_t *znp, const BDIGIT **xdsp, size_t *xnp,
const BDIGIT *yds = *ydsp;
size_t yn = *ynp;
- assert(xn + yn <= zn);
+ RUBY_ASSERT(xn + yn <= zn);
nlsz = 0;
@@ -2450,7 +2476,7 @@ bary_mul_precheck(BDIGIT **zdsp, size_t *znp, const BDIGIT **xdsp, size_t *xnp,
tds = xds; xds = yds; yds = tds;
tn = xn; xn = yn; yn = tn;
}
- assert(xn <= yn);
+ RUBY_ASSERT(xn <= yn);
if (xn <= 1) {
if (xn == 0) {
@@ -2633,8 +2659,8 @@ rb_big_stop(void *ptr)
static BDIGIT
bigdivrem_single1(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdigit, BDIGIT y)
{
- assert(0 < xn);
- assert(x_higher_bdigit < y);
+ RUBY_ASSERT(0 < xn);
+ RUBY_ASSERT(x_higher_bdigit < y);
if (POW2_P(y)) {
BDIGIT r;
r = xds[0] & (y-1);
@@ -2666,9 +2692,9 @@ bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
struct big_div_struct bds;
size_t ynzero;
- assert(yn < zn);
- assert(BDIGIT_MSB(yds[yn-1]));
- assert(zds[zn-1] < yds[yn-1]);
+ RUBY_ASSERT(yn < zn);
+ RUBY_ASSERT(BDIGIT_MSB(yds[yn-1]));
+ RUBY_ASSERT(zds[zn-1] < yds[yn-1]);
for (ynzero = 0; !yds[ynzero]; ynzero++);
@@ -2687,7 +2713,7 @@ bigdivrem_restoring(BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
if (bds.zn > 10000 || bds.yn > 10000) {
retry:
bds.stop = Qfalse;
- rb_nogvl(bigdivrem1, &bds, rb_big_stop, &bds, RB_NOGVL_UBF_ASYNC_SAFE);
+ rb_nogvl(bigdivrem1, &bds, rb_big_stop, &bds, RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_OFFLOAD_SAFE);
if (bds.stop == Qtrue) {
/* execute trap handler, but exception was not raised. */
@@ -2707,9 +2733,9 @@ bary_divmod_normal(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT
size_t zn;
VALUE tmpyz = 0;
- assert(yn < xn || (xn == yn && yds[yn - 1] <= xds[xn - 1]));
- assert(qds ? (xn - yn + 1) <= qn : 1);
- assert(rds ? yn <= rn : 1);
+ RUBY_ASSERT(yn < xn || (xn == yn && yds[yn - 1] <= xds[xn - 1]));
+ RUBY_ASSERT(qds ? (xn - yn + 1) <= qn : 1);
+ RUBY_ASSERT(rds ? yn <= rn : 1);
zn = xn + BIGDIVREM_EXTRA_WORDS;
@@ -2801,10 +2827,10 @@ bary_divmod_gmp(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xd
mpz_t x, y, q, r;
size_t count;
- assert(yn < xn || (xn == yn && yds[yn - 1] <= xds[xn - 1]));
- assert(qds ? (xn - yn + 1) <= qn : 1);
- assert(rds ? yn <= rn : 1);
- assert(qds || rds);
+ RUBY_ASSERT(yn < xn || (xn == yn && yds[yn - 1] <= xds[xn - 1]));
+ RUBY_ASSERT(qds ? (xn - yn + 1) <= qn : 1);
+ RUBY_ASSERT(rds ? yn <= rn : 1);
+ RUBY_ASSERT(qds || rds);
mpz_init(x);
mpz_init(y);
@@ -2890,8 +2916,8 @@ bary_divmod_branch(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT
static void
bary_divmod(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
{
- assert(xn <= qn);
- assert(yn <= rn);
+ RUBY_ASSERT(xn <= qn);
+ RUBY_ASSERT(yn <= rn);
BARY_TRUNC(yds, yn);
if (yn == 0)
@@ -2932,11 +2958,6 @@ bary_divmod(BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, s
}
}
-
-#ifndef BIGNUM_DEBUG
-# define BIGNUM_DEBUG (0+RUBY_DEBUG)
-#endif
-
static int
bigzero_p(VALUE x)
{
@@ -2953,7 +2974,7 @@ int
rb_cmpint(VALUE val, VALUE a, VALUE b)
{
if (NIL_P(val)) {
- rb_cmperr(a, b);
+ rb_cmperr_reason(a, b, "comparator returned nil");
}
if (FIXNUM_P(val)) {
long l = FIX2LONG(val);
@@ -2978,36 +2999,68 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
((l) << BIGNUM_EMBED_LEN_SHIFT)) : \
(void)(RBIGNUM(b)->as.heap.len = (l)))
+static size_t
+big_embed_capa(VALUE big)
+{
+ size_t size = rb_gc_obj_slot_size(big) - offsetof(struct RBignum, as.ary);
+ RUBY_ASSERT(size % sizeof(BDIGIT) == 0);
+ size_t capa = size / sizeof(BDIGIT);
+ RUBY_ASSERT(capa <= BIGNUM_EMBED_LEN_MAX);
+ return capa;
+}
+
+static size_t
+big_embed_size(size_t capa)
+{
+ size_t size = offsetof(struct RBignum, as.ary) + (sizeof(BDIGIT) * capa);
+ if (size < sizeof(struct RBignum)) {
+ size = sizeof(struct RBignum);
+ }
+ return size;
+}
+
+static bool
+big_embeddable_p(size_t capa)
+{
+ if (capa > BIGNUM_EMBED_LEN_MAX) {
+ return false;
+ }
+ return rb_gc_size_allocatable_p(big_embed_size(capa));
+}
+
static void
rb_big_realloc(VALUE big, size_t len)
{
BDIGIT *ds;
+ size_t embed_capa = big_embed_capa(big);
+
if (BIGNUM_EMBED_P(big)) {
- if (BIGNUM_EMBED_LEN_MAX < len) {
+ if (embed_capa < len) {
ds = ALLOC_N(BDIGIT, len);
- MEMCPY(ds, RBIGNUM(big)->as.ary, BDIGIT, BIGNUM_EMBED_LEN_MAX);
+ MEMCPY(ds, RBIGNUM(big)->as.ary, BDIGIT, embed_capa);
RBIGNUM(big)->as.heap.len = BIGNUM_LEN(big);
RBIGNUM(big)->as.heap.digits = ds;
FL_UNSET_RAW(big, BIGNUM_EMBED_FLAG);
}
}
else {
- if (len <= BIGNUM_EMBED_LEN_MAX) {
+ if (len <= embed_capa) {
ds = RBIGNUM(big)->as.heap.digits;
+ size_t old_len = RBIGNUM(big)->as.heap.len;
FL_SET_RAW(big, BIGNUM_EMBED_FLAG);
BIGNUM_SET_LEN(big, len);
- (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, sizeof(RBIGNUM(big)->as.ary));
+ (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, embed_capa * sizeof(BDIGIT));
if (ds) {
MEMCPY(RBIGNUM(big)->as.ary, ds, BDIGIT, len);
- xfree(ds);
+ SIZED_FREE_N(ds, old_len);
}
}
else {
if (BIGNUM_LEN(big) == 0) {
RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len);
}
- else {
- REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len);
+ else if (BIGNUM_LEN(big) != len) {
+ SIZED_REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len, BIGNUM_LEN(big));
}
}
}
@@ -3023,15 +3076,21 @@ rb_big_resize(VALUE big, size_t len)
static VALUE
bignew_1(VALUE klass, size_t len, int sign)
{
- NEWOBJ_OF(big, struct RBignum, klass, T_BIGNUM | (RGENGC_WB_PROTECTED_BIGNUM ? FL_WB_PROTECTED : 0));
- VALUE bigv = (VALUE)big;
- BIGNUM_SET_SIGN(bigv, sign);
- if (len <= BIGNUM_EMBED_LEN_MAX) {
- FL_SET_RAW(bigv, BIGNUM_EMBED_FLAG);
+ VALUE bigv;
+
+ if (big_embeddable_p(len)) {
+ size_t size = big_embed_size(len);
+ RUBY_ASSERT(rb_gc_size_allocatable_p(size));
+ NEWOBJ_OF(big, struct RBignum, klass, T_BIGNUM | BIGNUM_EMBED_FLAG, size);
+ bigv = (VALUE)big;
+ BIGNUM_SET_SIGN(bigv, sign);
BIGNUM_SET_LEN(bigv, len);
- (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)big->as.ary, sizeof(big->as.ary));
+ (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)big->as.ary, len * sizeof(BDIGIT));
}
else {
+ NEWOBJ_OF(big, struct RBignum, klass, T_BIGNUM, sizeof(struct RBignum));
+ bigv = (VALUE)big;
+ BIGNUM_SET_SIGN(bigv, sign);
big->as.heap.digits = ALLOC_N(BDIGIT, len);
big->as.heap.len = len;
}
@@ -3042,7 +3101,9 @@ bignew_1(VALUE klass, size_t len, int sign)
VALUE
rb_big_new(size_t len, int sign)
{
- return bignew(len, sign != 0);
+ VALUE obj = bignew(len, sign != 0);
+ memset(BIGNUM_DIGITS(obj), 0, len * sizeof(BDIGIT));
+ return obj;
}
VALUE
@@ -3422,15 +3483,13 @@ rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
if (numbytes <= SIZE_MAX / CHAR_BIT) {
numwords = absint_numwords_small(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits);
-#ifdef DEBUG_INTEGER_PACK
- {
+ if (debug_integer_pack) {
size_t numwords0, nlz_bits0;
numwords0 = absint_numwords_generic(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits0);
- assert(numwords0 == numwords);
- assert(nlz_bits0 == nlz_bits);
+ RUBY_ASSERT(numwords0 == numwords);
+ RUBY_ASSERT(nlz_bits0 == nlz_bits);
(void)numwords0;
}
-#endif
}
else {
numwords = absint_numwords_generic(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits);
@@ -3843,7 +3902,7 @@ str2big_poweroftwo(
if (numbits) {
*dp++ = BIGLO(dd);
}
- assert((size_t)(dp - BDIGITS(z)) == num_bdigits);
+ RUBY_ASSERT((size_t)(dp - BDIGITS(z)) == num_bdigits);
return z;
}
@@ -3886,7 +3945,7 @@ str2big_normal(
}
break;
}
- assert(blen <= num_bdigits);
+ RUBY_ASSERT(blen <= num_bdigits);
}
return z;
@@ -3944,7 +4003,7 @@ str2big_karatsuba(
current_base = 1;
}
}
- assert(i == num_bdigits);
+ RUBY_ASSERT(i == num_bdigits);
for (unit = 2; unit < num_bdigits; unit *= 2) {
for (i = 0; i < num_bdigits; i += unit*2) {
if (2*unit <= num_bdigits - i) {
@@ -4089,8 +4148,8 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
len -= (n); \
} while (0)
#define ASSERT_LEN() do {\
- assert(len != 0); \
- if (len0 >= 0) assert(s + len0 == str + len); \
+ RUBY_ASSERT(len != 0); \
+ if (len0 >= 0) RUBY_ASSERT(s + len0 == str + len); \
} while (0)
if (!str) {
@@ -4464,7 +4523,7 @@ rb_str2big_gmp(VALUE arg, int base, int badcheck)
#if HAVE_LONG_LONG
-static VALUE
+VALUE
rb_ull2big(unsigned LONG_LONG n)
{
long i;
@@ -4486,7 +4545,7 @@ rb_ull2big(unsigned LONG_LONG n)
return big;
}
-static VALUE
+VALUE
rb_ll2big(LONG_LONG n)
{
long neg = 0;
@@ -4524,7 +4583,7 @@ rb_ll2inum(LONG_LONG n)
#endif /* HAVE_LONG_LONG */
#ifdef HAVE_INT128_T
-static VALUE
+VALUE
rb_uint128t2big(uint128_t n)
{
long i;
@@ -4635,8 +4694,8 @@ big_shift2(VALUE x, int lshift_p, VALUE y)
size_t shift_numdigits;
int shift_numbits;
- assert(POW2_P(CHAR_BIT));
- assert(POW2_P(BITSPERDIG));
+ RUBY_ASSERT(POW2_P(CHAR_BIT));
+ RUBY_ASSERT(POW2_P(BITSPERDIG));
if (BIGZEROP(x))
return INT2FIX(0);
@@ -4723,7 +4782,7 @@ power_cache_get_power(int base, int power_level, size_t *numdigits_ret)
rb_obj_hide(power);
base36_power_cache[base - 2][power_level] = power;
base36_numdigits_cache[base - 2][power_level] = numdigits;
- rb_gc_register_mark_object(power);
+ rb_vm_register_global_object(power);
}
if (numdigits_ret)
*numdigits_ret = base36_numdigits_cache[base - 2][power_level];
@@ -4759,7 +4818,7 @@ big2str_2bdigits(struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t tail
int beginning = !b2s->ptr;
size_t len = 0;
- assert(xn <= 2);
+ RUBY_ASSERT(xn <= 2);
num = bary2bdigitdbl(xds, xn);
if (beginning) {
@@ -4767,11 +4826,34 @@ big2str_2bdigits(struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t tail
return;
p = buf;
j = sizeof(buf);
- do {
- BDIGIT_DBL idx = num % b2s->base;
- num /= b2s->base;
- p[--j] = ruby_digitmap[idx];
- } while (num);
+ if (b2s->base == 10) {
+ /* Emit two decimal digits per iteration from ruby_decimal_digit_pairs.
+ * See the comment on the table in bignum.c near ruby_digitmap. */
+ while (num >= 100) {
+ BDIGIT_DBL idx = (num % 100) * 2;
+ num /= 100;
+ j -= 2;
+ p[j] = ruby_decimal_digit_pairs[idx];
+ p[j + 1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ if (num >= 10) {
+ BDIGIT_DBL idx = num * 2;
+ j -= 2;
+ p[j] = ruby_decimal_digit_pairs[idx];
+ p[j + 1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ else {
+ /* num is 1..9 here (0 was handled above) */
+ p[--j] = (char)('0' + num);
+ }
+ }
+ else {
+ do {
+ BDIGIT_DBL idx = num % b2s->base;
+ num /= b2s->base;
+ p[--j] = ruby_digitmap[idx];
+ } while (num);
+ }
len = sizeof(buf) - j;
big2str_alloc(b2s, len + taillen);
MEMCPY(b2s->ptr, buf + j, char, len);
@@ -4779,11 +4861,39 @@ big2str_2bdigits(struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t tail
else {
p = b2s->ptr;
j = b2s->hbase2_numdigits;
- do {
- BDIGIT_DBL idx = num % b2s->base;
- num /= b2s->base;
- p[--j] = ruby_digitmap[idx];
- } while (j);
+ if (b2s->base == 10) {
+ /* Non-beginning chunks must emit EXACTLY hbase2_numdigits,
+ * zero-padded on the left. Consume num in 2-digit groups,
+ * handle the odd trailing digit, then memset remaining
+ * positions with '0'. */
+ while (num >= 100) {
+ BDIGIT_DBL idx = (num % 100) * 2;
+ num /= 100;
+ j -= 2;
+ p[j] = ruby_decimal_digit_pairs[idx];
+ p[j + 1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ if (num >= 10) {
+ BDIGIT_DBL idx = num * 2;
+ j -= 2;
+ p[j] = ruby_decimal_digit_pairs[idx];
+ p[j + 1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ else if (num > 0) {
+ p[--j] = (char)('0' + num);
+ }
+ if (j > 0) {
+ memset(p, '0', j);
+ j = 0;
+ }
+ }
+ else {
+ do {
+ BDIGIT_DBL idx = num % b2s->base;
+ num /= b2s->base;
+ p[--j] = ruby_digitmap[idx];
+ } while (j);
+ }
len = b2s->hbase2_numdigits;
}
b2s->ptr += len;
@@ -4887,7 +4997,7 @@ big2str_karatsuba(struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t wn,
/* bigdivrem_restoring will modify y.
* So use temporary buffer. */
tds = xds + qn;
- assert(qn + bn <= xn + wn);
+ RUBY_ASSERT(qn + bn <= xn + wn);
bary_small_lshift(tds, bds, bn, shift);
xds[xn] = bary_small_lshift(xds, xds, xn, shift);
}
@@ -4905,7 +5015,7 @@ big2str_karatsuba(struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t wn,
}
BARY_TRUNC(qds, qn);
- assert(qn <= bn);
+ RUBY_ASSERT(qn <= bn);
big2str_karatsuba(b2s, qds, qn, xn+wn - (rn+qn), lower_power_level, lower_numdigits+taillen);
BARY_TRUNC(rds, rn);
big2str_karatsuba(b2s, rds, rn, xn+wn - rn, lower_power_level, taillen);
@@ -4970,7 +5080,7 @@ big2str_generic(VALUE x, int base)
invalid_radix(base);
if (xn >= LONG_MAX/BITSPERDIG) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'string'");
}
power_level = 0;
@@ -4980,7 +5090,7 @@ big2str_generic(VALUE x, int base)
power_level++;
power = power_cache_get_power(base, power_level, NULL);
}
- assert(power_level != MAX_BASE36_POWER_TABLE_ENTRIES);
+ RUBY_ASSERT(power_level != MAX_BASE36_POWER_TABLE_ENTRIES);
if ((size_t)BIGNUM_LEN(power) <= xn) {
/*
@@ -5095,7 +5205,7 @@ rb_big2str1(VALUE x, int base)
invalid_radix(base);
if (xn >= LONG_MAX/BITSPERDIG) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'string'");
}
if (POW2_P(base)) {
@@ -5131,7 +5241,7 @@ big2ulong(VALUE x, const char *type)
if (len == 0)
return 0;
if (BIGSIZE(x) > sizeof(long)) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
+ rb_raise(rb_eRangeError, "bignum too big to convert into '%s'", type);
}
ds = BDIGITS(x);
#if SIZEOF_LONG <= SIZEOF_BDIGIT
@@ -5174,7 +5284,7 @@ rb_big2long(VALUE x)
if (num <= 1+(unsigned long)(-(LONG_MIN+1)))
return -(long)(num-1)-1;
}
- rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'long'");
}
#if HAVE_LONG_LONG
@@ -5192,7 +5302,7 @@ big2ull(VALUE x, const char *type)
if (len == 0)
return 0;
if (BIGSIZE(x) > SIZEOF_LONG_LONG)
- rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
+ rb_raise(rb_eRangeError, "bignum too big to convert into '%s'", type);
#if SIZEOF_LONG_LONG <= SIZEOF_BDIGIT
num = (unsigned LONG_LONG)ds[0];
#else
@@ -5233,7 +5343,7 @@ rb_big2ll(VALUE x)
if (num <= 1+(unsigned LONG_LONG)(-(LLONG_MIN+1)))
return -(LONG_LONG)(num-1)-1;
}
- rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'long long'");
}
#endif /* HAVE_LONG_LONG */
@@ -5496,10 +5606,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op)
n = FIX2INT(rel);
switch (op) {
- case big_op_gt: return RBOOL(n > 0);
- case big_op_ge: return RBOOL(n >= 0);
- case big_op_lt: return RBOOL(n < 0);
- case big_op_le: return RBOOL(n <= 0);
+ case big_op_gt: return RBOOL(n > 0);
+ case big_op_ge: return RBOOL(n >= 0);
+ case big_op_lt: return RBOOL(n < 0);
+ case big_op_le: return RBOOL(n <= 0);
}
return Qundef;
}
@@ -5655,7 +5765,7 @@ bigsub_int(VALUE x, long y0)
zds = BDIGITS(z);
#if SIZEOF_BDIGIT >= SIZEOF_LONG
- assert(xn == zn);
+ RUBY_ASSERT(xn == zn);
num = (BDIGIT_DBL_SIGNED)xds[0] - y;
if (xn == 1 && num < 0) {
BIGNUM_NEGATE(z);
@@ -5718,7 +5828,7 @@ bigsub_int(VALUE x, long y0)
goto finish;
finish:
- assert(num == 0 || num == -1);
+ RUBY_ASSERT(num == 0 || num == -1);
if (num < 0) {
get2comp(z);
BIGNUM_NEGATE(z);
@@ -5903,6 +6013,8 @@ bigsq(VALUE x)
BDIGIT *xds, *zds;
xn = BIGNUM_LEN(x);
+ if (MUL_OVERFLOW_LONG_P(2, xn))
+ rb_raise(rb_eArgError, "square overflow");
zn = 2 * xn;
z = bignew(zn, 1);
@@ -5931,6 +6043,8 @@ bigmul0(VALUE x, VALUE y)
xn = BIGNUM_LEN(x);
yn = BIGNUM_LEN(y);
+ if (ADD_OVERFLOW_LONG_P(xn, yn))
+ rb_raise(rb_eArgError, "multiplication overflow");
zn = xn + yn;
z = bignew(zn, BIGNUM_SIGN(x)==BIGNUM_SIGN(y));
@@ -6276,8 +6390,7 @@ rb_big_pow(VALUE x, VALUE y)
y = bignorm(y);
if (FIXNUM_P(y))
goto again;
- rb_warn("in a**b, b may be too big");
- d = rb_big2dbl(y);
+ rb_raise(rb_eArgError, "exponent is too large");
}
else if (FIXNUM_P(y)) {
yy = FIX2LONG(y);
@@ -6293,13 +6406,17 @@ rb_big_pow(VALUE x, VALUE y)
VALUE z = 0;
SIGNED_VALUE mask;
const size_t xbits = rb_absint_numwords(x, 1, NULL);
- const size_t BIGLEN_LIMIT = 32*1024*1024;
+#if SIZEOF_SIZE_T == 4
+ const size_t BIGLEN_LIMIT = 1ULL << 31; // 2 GB
+#else // SIZEOF_SIZE_T == 8
+ const size_t BIGLEN_LIMIT = 1ULL << 34; // 16 GB
+#endif
if (xbits == (size_t)-1 ||
(xbits > BIGLEN_LIMIT) ||
+ MUL_OVERFLOW_LONG_P(yy, xbits) ||
(xbits * yy > BIGLEN_LIMIT)) {
- rb_warn("in a**b, b may be too big");
- d = (double)yy;
+ rb_raise(rb_eArgError, "exponent is too large");
}
else {
for (mask = FIXNUM_MAX + 1; mask; mask >>= 1) {
@@ -6328,7 +6445,7 @@ bigand_int(VALUE x, long xn, BDIGIT hibitsx, long y)
BDIGIT hibitsy;
if (y == 0) return INT2FIX(0);
- if (xn == 0) return hibitsx ? LONG2NUM(y) : 0;
+ if (xn == 0) return hibitsx ? LONG2NUM(y) : INT2FIX(0);
hibitsy = 0 <= y ? 0 : BDIGMAX;
xds = BDIGITS(x);
#if SIZEOF_BDIGIT >= SIZEOF_LONG
@@ -6740,6 +6857,73 @@ rb_big_aref(VALUE x, VALUE y)
}
VALUE
+rb_big_aref2(VALUE x, VALUE beg, VALUE len)
+{
+ BDIGIT *xds, *vds;
+ VALUE v;
+ size_t copy_begin, xn, shift;
+ ssize_t begin, length, end;
+ bool negative_add_one;
+
+ beg = rb_to_int(beg);
+ len = rb_to_int(len);
+ length = NUM2SSIZET(len);
+ begin = NUM2SSIZET(beg);
+ end = NUM2SSIZET(rb_int_plus(beg, len));
+ shift = begin < 0 ? -begin : 0;
+ xn = BIGNUM_LEN(x);
+ xds = BDIGITS(x);
+
+ if (length < 0) return rb_big_rshift(x, beg);
+ if (length == 0 || end <= 0) return INT2FIX(0);
+ if (begin < 0) begin = 0;
+
+ if ((size_t)(end - 1) / BITSPERDIG >= xn) {
+ /* end > xn * BITSPERDIG */
+ end = xn * BITSPERDIG;
+ }
+
+ if ((size_t)begin / BITSPERDIG < xn) {
+ /* begin < xn * BITSPERDIG */
+ size_t shift_bits, copy_end;
+ copy_begin = begin / BITSPERDIG;
+ shift_bits = begin % BITSPERDIG;
+ copy_end = (end - 1) / BITSPERDIG + 1;
+ v = bignew(copy_end - copy_begin, 1);
+ vds = BDIGITS(v);
+ MEMCPY(vds, xds + copy_begin, BDIGIT, copy_end - copy_begin);
+ negative_add_one = (vds[0] & ((1 << shift_bits) - 1)) == 0;
+ v = bignorm(v);
+ if (shift_bits) v = rb_int_rshift(v, SIZET2NUM(shift_bits));
+ }
+ else {
+ /* Out of range */
+ v = INT2FIX(0);
+ negative_add_one = false;
+ copy_begin = begin = end = 0;
+ }
+
+ if (BIGNUM_NEGATIVE_P(x)) {
+ size_t mask_size = length - shift;
+ VALUE mask = rb_int_minus(rb_int_lshift(INT2FIX(1), SIZET2NUM(mask_size)), INT2FIX(1));
+ v = rb_int_xor(v, mask);
+ for (size_t i = 0; negative_add_one && i < copy_begin; i++) {
+ if (xds[i]) negative_add_one = false;
+ }
+ if (negative_add_one) v = rb_int_plus(v, INT2FIX(1));
+ v = rb_int_and(v, mask);
+ }
+ else {
+ size_t mask_size = (size_t)end - begin;
+ VALUE mask = rb_int_minus(rb_int_lshift(INT2FIX(1), SIZET2NUM(mask_size)), INT2FIX(1));
+ v = rb_int_and(v, mask);
+ }
+ RB_GC_GUARD(x);
+ if (shift) v = rb_int_lshift(v, SSIZET2NUM(shift));
+ return v;
+}
+
+VALUE
rb_big_hash(VALUE x)
{
st_index_t hash;
@@ -6873,63 +7057,11 @@ BDIGIT rb_bdigit_dbl_isqrt(BDIGIT_DBL);
# define BDIGIT_DBL_TO_DOUBLE(n) (double)(n)
#endif
-static BDIGIT *
-estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
-{
- enum {dbl_per_bdig = roomof(DBL_MANT_DIG,BITSPERDIG)};
- const int zbits = nlz(nds[len-1]);
- VALUE x = *xp = bignew_1(0, xn, 1); /* division may release the GVL */
- BDIGIT *xds = BDIGITS(x);
- BDIGIT_DBL d = bary2bdigitdbl(nds+len-dbl_per_bdig, dbl_per_bdig);
- BDIGIT lowbits = 1;
- int rshift = (int)((BITSPERDIG*2-zbits+(len&BITSPERDIG&1) - DBL_MANT_DIG + 1) & ~1);
- double f;
-
- if (rshift > 0) {
- lowbits = (BDIGIT)d & ~(~(BDIGIT)1U << rshift);
- d >>= rshift;
- }
- else if (rshift < 0) {
- d <<= -rshift;
- d |= nds[len-dbl_per_bdig-1] >> (BITSPERDIG+rshift);
- }
- f = sqrt(BDIGIT_DBL_TO_DOUBLE(d));
- d = (BDIGIT_DBL)ceil(f);
- if (BDIGIT_DBL_TO_DOUBLE(d) == f) {
- if (lowbits || (lowbits = !bary_zero_p(nds, len-dbl_per_bdig)))
- ++d;
- }
- else {
- lowbits = 1;
- }
- rshift /= 2;
- rshift += (2-(len&1))*BITSPERDIG/2;
- if (rshift >= 0) {
- if (nlz((BDIGIT)d) + rshift >= BITSPERDIG) {
- /* (d << rshift) does cause overflow.
- * example: Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)
- */
- d = ~(BDIGIT_DBL)0;
- }
- else {
- d <<= rshift;
- }
- }
- BDIGITS_ZERO(xds, xn-2);
- bdigitdbl2bary(&xds[xn-2], 2, d);
-
- if (!lowbits) return NULL; /* special case, exact result */
- return xds;
-}
-
VALUE
rb_big_isqrt(VALUE n)
{
BDIGIT *nds = BDIGITS(n);
size_t len = BIGNUM_LEN(n);
- size_t xn = (len+1) / 2;
- VALUE x;
- BDIGIT *xds;
if (len <= 2) {
BDIGIT sq = rb_bdigit_dbl_isqrt(bary2bdigitdbl(nds, len));
@@ -6939,25 +7071,19 @@ rb_big_isqrt(VALUE n)
return ULONG2NUM(sq);
#endif
}
- else if ((xds = estimate_initial_sqrt(&x, xn, nds, len)) != 0) {
- size_t tn = xn + BIGDIVREM_EXTRA_WORDS;
- VALUE t = bignew_1(0, tn, 1);
- BDIGIT *tds = BDIGITS(t);
- tn = BIGNUM_LEN(t);
-
- /* t = n/x */
- while (bary_divmod_branch(tds, tn, NULL, 0, nds, len, xds, xn),
- bary_cmp(tds, tn, xds, xn) < 0) {
- int carry;
- BARY_TRUNC(tds, tn);
- /* x = (x+t)/2 */
- carry = bary_add(xds, xn, xds, xn, tds, tn);
- bary_small_rshift(xds, xds, xn, 1, carry);
- tn = BIGNUM_LEN(t);
+ else {
+ size_t shift = FIX2LONG(rb_big_bit_length(n)) / 4;
+ VALUE n2 = rb_int_rshift(n, SIZET2NUM(2 * shift));
+ VALUE x = FIXNUM_P(n2) ? LONG2FIX(rb_ulong_isqrt(FIX2ULONG(n2))) : rb_big_isqrt(n2);
+ /* x = (x+n/x)/2 */
+ x = rb_int_plus(rb_int_lshift(x, SIZET2NUM(shift - 1)), rb_int_idiv(rb_int_rshift(n, SIZET2NUM(shift + 1)), x));
+ VALUE xx = rb_int_mul(x, x);
+ while (rb_int_gt(xx, n)) {
+ xx = rb_int_minus(xx, rb_int_minus(rb_int_plus(x, x), INT2FIX(1)));
+ x = rb_int_minus(x, INT2FIX(1));
}
+ return x;
}
- RBASIC_SET_CLASS_RAW(x, rb_cInteger);
- return x;
}
#if USE_GMP
@@ -6996,14 +7122,14 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, int nega_flg)
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
- assert(RB_BIGNUM_TYPE_P(m));
+ RUBY_ASSERT(RB_BIGNUM_TYPE_P(m));
xn = BIGNUM_LEN(x);
yn = BIGNUM_LEN(y);
mn = BIGNUM_LEN(m);
zn = mn;
z = bignew(zn, 1);
bary_powm_gmp(BDIGITS(z), zn, BDIGITS(x), xn, BDIGITS(y), yn, BDIGITS(m), mn);
- if (nega_flg & BIGNUM_POSITIVE_P(z)) {
+ if (nega_flg && BIGNUM_POSITIVE_P(z) && !BIGZEROP(z)) {
z = rb_big_minus(z, m);
}
RB_GC_GUARD(x);
@@ -7031,7 +7157,7 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, int nega_flg)
x = rb_int_modulo(x, m);
}
- if (nega_flg && rb_int_positive_p(tmp)) {
+ if (nega_flg && rb_int_positive_p(tmp) && !rb_int_zero_p(tmp)) {
tmp = rb_int_minus(tmp, m);
}
return tmp;
@@ -7143,6 +7269,11 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless all arguments are integers");
}
+ if (rb_int_zero_p(a) && !rb_int_zero_p(b)) {
+ /* shortcut; 0**x => 0 except for x == 0 */
+ return INT2FIX(0);
+ }
+
if (rb_int_negative_p(m)) {
m = rb_int_uminus(m);
nega_flg = 1;
diff --git a/bin/gem b/bin/gem
index 1c16ea7ddd..3ac1d9e623 100755
--- a/bin/gem
+++ b/bin/gem
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index fc4998b523..04de0c93b9 100755
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -6,7 +6,6 @@
# Never use optparse in this file.
# Never use test/unit in this file.
# Never use Ruby extensions in this file.
-# Maintain Ruby 1.8 compatibility for now
$start_time = Time.now
@@ -17,6 +16,7 @@ rescue LoadError
$:.unshift File.join(File.dirname(__FILE__), '../lib')
retry
end
+require_relative '../tool/lib/test/jobserver'
if !Dir.respond_to?(:mktmpdir)
# copied from lib/tmpdir.rb
@@ -77,6 +77,9 @@ bt = Struct.new(:ruby,
:width,
:indent,
:platform,
+ :timeout,
+ :timeout_scale,
+ :launchable_test_reports
)
BT = Class.new(bt) do
def indent=(n)
@@ -108,35 +111,7 @@ BT = Class.new(bt) do
def wn=(wn)
unless wn == 1
- if /(?:\A|\s)--jobserver-(?:auth|fds)=(?:(\d+),(\d+)|fifo:((?:\\.|\S)+))/ =~ ENV.delete("MAKEFLAGS")
- begin
- if fifo = $3
- fifo.gsub!(/\\(?=.)/, '')
- r = File.open(fifo, IO::RDONLY|IO::NONBLOCK|IO::BINARY)
- w = File.open(fifo, IO::WRONLY|IO::NONBLOCK|IO::BINARY)
- else
- r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
- w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
- end
- rescue => e
- r.close if r
- else
- r.close_on_exec = true
- w.close_on_exec = true
- tokens = r.read_nonblock(wn > 0 ? wn : 1024, exception: false)
- r.close
- if String === tokens
- tokens.freeze
- auth = w
- w = nil
- at_exit {auth << tokens; auth.close}
- wn = tokens.size + 1
- else
- w.close
- wn = 1
- end
- end
- end
+ wn = Test::JobServer.max_jobs(wn > 0 ? wn : 1024, ENV.delete("MAKEFLAGS")) || wn
if wn <= 0
require 'etc'
wn = [Etc.nprocessors / 2, 1].max
@@ -144,6 +119,10 @@ BT = Class.new(bt) do
end
super wn
end
+
+ def apply_timeout_scale(timeout)
+ timeout&.*(timeout_scale)
+ end
end.new
BT_STATE = Struct.new(:count, :error).new
@@ -156,6 +135,12 @@ def main
BT.color = nil
BT.tty = nil
BT.quiet = false
+ BT.timeout = 180
+ BT.timeout_scale = 1
+ if (ts = (ENV["RUBY_TEST_TIMEOUT_SCALE"] || ENV["RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE"]).to_i) > 1
+ BT.timeout_scale *= ts
+ end
+
# BT.wn = 1
dir = nil
quiet = false
@@ -186,14 +171,18 @@ def main
warn "unknown --tty argument: #$3" if $3
BT.tty = !$1 || !$2
true
- when /\A(-q|--q(uiet))\z/
+ when /\A(-q|--q(uiet)?)\z/
quiet = true
BT.quiet = true
true
when /\A-j(\d+)?/
BT.wn = $1.to_i
true
- when /\A(-v|--v(erbose))\z/
+ when /\A--timeout=(\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)(?::(\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?))?/
+ BT.timeout = $1.to_f
+ BT.timeout_scale = $2.to_f if defined?($2)
+ true
+ when /\A(-v|--v(erbose)?)\z/
BT.verbose = true
BT.quiet = false
true
@@ -205,6 +194,7 @@ Usage: #{File.basename($0, '.*')} --ruby=PATH [--sets=NAME,NAME,...]
default: /tmp/bootstraptestXXXXX.tmpwd
--color[=WHEN] Colorize the output. WHEN defaults to 'always'
or can be 'never' or 'auto'.
+ --timeout=TIMEOUT Default timeout in seconds.
-s, --stress stress test.
-v, --verbose Output test name before exec.
-q, --quiet Don\'t print header message.
@@ -213,6 +203,31 @@ End
exit true
when /\A-j/
true
+ when /--launchable-test-reports=(.*)/
+ if File.exist?($1)
+ # To protect files from overwritten, do nothing when the file exists.
+ return true
+ end
+
+ begin
+ require_relative '../tool/lib/launchable'
+ rescue LoadError
+ # The following error sometimes happens, so we're going to skip writing Launchable report files in this case.
+ #
+ # ```
+ # /tmp/tmp.bISss9CtXZ/.ext/common/json/ext.rb:15:in 'Kernel#require':
+ # /tmp/tmp.bISss9CtXZ/.ext/x86_64-linux/json/ext/parser.so:
+ # undefined symbol: ruby_abi_version - ruby_abi_version (LoadError)
+ # ```
+ #
+ return true
+ end
+ BT.launchable_test_reports = writer = Launchable::JsonStreamWriter.new($1)
+ writer.write_array('testCases')
+ at_exit {
+ writer.close
+ }
+ true
else
false
end
@@ -222,7 +237,7 @@ End
end
tests ||= ARGV
tests = Dir.glob("#{File.dirname($0)}/test_*.rb").sort if tests.empty?
- pathes = tests.map {|path| File.expand_path(path) }
+ paths = tests.map {|path| File.expand_path(path) }
BT.progress = %w[- \\ | /]
BT.progress_bs = "\b" * BT.progress[0].size
@@ -256,7 +271,7 @@ End
if defined?(RUBY_DESCRIPTION)
puts "Driver is #{RUBY_DESCRIPTION}"
elsif defined?(RUBY_PATCHLEVEL)
- puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{RUBY_PLATFORM}) [#{RUBY_PLATFORM}]"
+ puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]"
else
puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end
@@ -266,7 +281,7 @@ End
end
in_temporary_working_directory(dir) do
- exec_test pathes
+ exec_test paths
end
end
@@ -278,8 +293,8 @@ def erase(e = true)
end
end
-def load_test pathes
- pathes.each do |path|
+def load_test paths
+ paths.each do |path|
load File.expand_path(path)
end
end
@@ -312,6 +327,7 @@ def concurrent_exec_test
begin
while BT.wn != term_wn
if r = rq.pop
+ BT_STATE.count += 1
case
when BT.quiet
when BT.tty
@@ -329,13 +345,66 @@ def concurrent_exec_test
end
end
-def exec_test(pathes)
+##
+# Module for writing a test file for uploading test results into Launchable.
+# In bootstraptest, we aggregate the test results based on file level.
+module Launchable
+ @@last_test_name = nil
+ @@failure_log = ''
+ @@duration = 0
+
+ def show_progress(message = '')
+ faildesc, t = super
+
+ if writer = BT.launchable_test_reports
+ if faildesc
+ @@failure_log += faildesc
+ end
+ repo_path = File.expand_path("#{__dir__}/../")
+ relative_path = File.join(__dir__, self.path).delete_prefix("#{repo_path}/")
+ if @@last_test_name != nil && @@last_test_name != relative_path
+ # The test path is a URL-encoded representation.
+ # https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18
+ test_path = "#{encode_test_path_component("file")}=#{encode_test_path_component(@@last_test_name)}"
+ if @@failure_log.size > 0
+ status = 'TEST_FAILED'
+ else
+ status = 'TEST_PASSED'
+ end
+ writer.write_object(
+ {
+ testPath: test_path,
+ status: status,
+ duration: t,
+ createdAt: Time.now.to_s,
+ stderr: @@failure_log,
+ stdout: nil,
+ data: {
+ lineNumber: self.lineno
+ }
+ }
+ )
+ @@duration = 0
+ @@failure_log = ''
+ end
+ @@last_test_name = relative_path
+ @@duration += t
+ end
+ end
+
+ private
+ def encode_test_path_component component
+ component.to_s.gsub('%', '%25').gsub('=', '%3D').gsub('#', '%23').gsub('&', '%26')
+ end
+end
+
+def exec_test(paths)
# setup
- load_test pathes
+ load_test paths
BT_STATE.count = 0
BT_STATE.error = 0
BT.columns = 0
- BT.width = pathes.map {|path| File.basename(path).size}.max + 2
+ BT.width = paths.map {|path| File.basename(path).size}.max + 2
# execute tests
if BT.wn > 1
@@ -405,6 +474,7 @@ def target_platform
end
class Assertion < Struct.new(:src, :path, :lineno, :proc)
+ prepend Launchable
@count = 0
@all = Hash.new{|h, k| h[k] = []}
@errbuf = []
@@ -428,7 +498,7 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
def initialize(*args)
super
self.class.add self
- @category = self.path.match(/test_(.+)\.rb/)[1]
+ @category = self.path[/\Atest_(.+)\.rb\z/, 1]
end
def call
@@ -479,9 +549,9 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
$stderr.print "#{BT.progress_bs}#{BT.progress[BT_STATE.count % BT.progress.size]}"
end
- t = Time.now if BT.verbose
+ t = Time.now if BT.verbose || BT.launchable_test_reports
faildesc, errout = with_stderr {yield}
- t = Time.now - t if BT.verbose
+ t = Time.now - t if BT.verbose || BT.launchable_test_reports
if !faildesc
# success
@@ -508,6 +578,8 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
$stderr.printf("%-*s%s", BT.width, path, BT.progress[BT_STATE.count % BT.progress.size])
end
end
+
+ [faildesc, t]
rescue Interrupt
$stderr.puts "\##{@id} #{path}:#{lineno}"
raise
@@ -526,14 +598,22 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
end
end
- def get_result_string(opt = '', **argh)
+ class Timeout < StandardError; end
+
+ def get_result_string(opt = '', timeout: BT.timeout, **argh)
if BT.ruby
+ timeout = BT.apply_timeout_scale(timeout)
filename = make_srcfile(**argh)
begin
kw = self.err ? {err: self.err} : {}
out = IO.popen("#{BT.ruby} -W0 #{opt} #{filename}", **kw)
pid = out.pid
- out.read.tap{ Process.waitpid(pid); out.close }
+ th = Thread.new {out.read.tap {Process.waitpid(pid); out.close}}
+ if th.join(timeout)
+ th.value
+ else
+ Timeout.new("timed out after #{timeout} seconds")
+ end
ensure
raise Interrupt if $? and $?.signaled? && $?.termsig == Signal.list["INT"]
@@ -551,9 +631,14 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
def make_srcfile(frozen_string_literal: nil)
filename = "bootstraptest.#{self.path}_#{self.lineno}_#{self.id}.rb"
File.open(filename, 'w') {|f|
- f.puts "#frozen_string_literal:true" if frozen_string_literal
- f.puts "GC.stress = true" if $stress
- f.puts "print(begin; #{self.src}; end)"
+ f.puts "#frozen_string_literal:#{frozen_string_literal}" unless frozen_string_literal.nil?
+ if $stress
+ f.puts "GC.stress = true" if $stress
+ else
+ f.puts ""
+ end
+ f.puts "class BT_Skip < Exception; end; def skip(msg) = raise(BT_Skip, msg.to_s)"
+ f.puts "print(begin; #{self.src}; rescue BT_Skip; $!.message; end)"
}
filename
end
@@ -567,9 +652,9 @@ def add_assertion src, pr
Assertion.new(src, path, lineno, pr)
end
-def assert_equal(expected, testsrc, message = '', opt = '', **argh)
+def assert_equal(expected, testsrc, message = '', opt = '', **kwargs)
add_assertion testsrc, -> as do
- as.assert_check(message, opt, **argh) {|result|
+ as.assert_check(message, opt, **kwargs) {|result|
if expected == result
nil
else
@@ -580,9 +665,9 @@ def assert_equal(expected, testsrc, message = '', opt = '', **argh)
end
end
-def assert_match(expected_pattern, testsrc, message = '')
+def assert_match(expected_pattern, testsrc, message = '', **argh)
add_assertion testsrc, -> as do
- as.assert_check(message) {|result|
+ as.assert_check(message, **argh) {|result|
if expected_pattern =~ result
nil
else
@@ -614,8 +699,9 @@ def assert_valid_syntax(testsrc, message = '')
end
end
-def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)
+def assert_normal_exit(testsrc, *rest, timeout: BT.timeout, **opt)
add_assertion testsrc, -> as do
+ timeout = BT.apply_timeout_scale(timeout)
message, ignore_signals = rest
message ||= ''
as.show_progress(message) {
@@ -624,23 +710,19 @@ def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)
timeout_signaled = false
logfile = "assert_normal_exit.#{as.path}.#{as.lineno}.log"
- begin
- err = open(logfile, "w")
- io = IO.popen("#{BT.ruby} -W0 #{filename}", err: err)
- pid = io.pid
- th = Thread.new {
- io.read
- io.close
- $?
- }
- if !th.join(timeout)
- Process.kill :KILL, pid
- timeout_signaled = true
- end
- status = th.value
- ensure
- err.close
+ io = IO.popen("#{BT.ruby} -W0 #{filename}", err: logfile)
+ pid = io.pid
+ th = Thread.new {
+ io.read
+ io.close
+ $?
+ }
+ if !th.join(timeout)
+ Process.kill :KILL, pid
+ timeout_signaled = true
end
+ status = th.value
+
if status && status.signaled?
signo = status.termsig
signame = Signal.list.invert[signo]
@@ -669,9 +751,7 @@ end
def assert_finish(timeout_seconds, testsrc, message = '')
add_assertion testsrc, -> as do
- if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait
- timeout_seconds *= 3
- end
+ timeout_seconds = BT.apply_timeout_scale(timeout_seconds)
as.show_progress(message) {
faildesc = nil
@@ -727,6 +807,8 @@ end
def pretty(src, desc, result)
src = src.sub(/\A\s*\n/, '')
+ lines = src.lines
+ src = lines[0..20].join + "(...snip)\n" if lines.size > 20
(/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) + " #=> #{desc}"
end
@@ -784,4 +866,12 @@ def check_coredump
end
end
+def yjit_enabled?
+ ENV.key?('RUBY_YJIT_ENABLE') || ENV.fetch('RUN_OPTS', '').include?('yjit') || BT.ruby.include?('yjit')
+end
+
+def zjit_enabled?
+ ENV.key?('RUBY_ZJIT_ENABLE') || ENV.fetch('RUN_OPTS', '').include?('zjit') || BT.ruby.include?('zjit')
+end
+
exit main
diff --git a/bootstraptest/test_autoload.rb b/bootstraptest/test_autoload.rb
index 9e0850bc52..de66f1f3ee 100644
--- a/bootstraptest/test_autoload.rb
+++ b/bootstraptest/test_autoload.rb
@@ -11,7 +11,7 @@ assert_equal 'ok', %q{
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
- open('zzz2.rb', 'w') {|f| f.puts '' }
+ File.write('zzz2.rb', '')
instance_eval do
autoload :ZZZ, './zzz2.rb'
begin
@@ -23,7 +23,7 @@ assert_equal 'ok', %q{
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
- open('zzz3.rb', 'w') {|f| f.puts 'class ZZZ; def self.ok;:ok;end;end'}
+ File.write('zzz3.rb', "class ZZZ; def self.ok;:ok;end;end\n")
instance_eval do
autoload :ZZZ, './zzz3.rb'
ZZZ.ok
@@ -31,20 +31,20 @@ assert_equal 'ok', %q{
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
- open("zzz4.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
+ File.write("zzz4.rb", "class ZZZ; def self.ok;:ok;end;end\n")
autoload :ZZZ, "./zzz4.rb"
ZZZ.ok
}
assert_equal 'ok', %q{
- open("zzz5.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
+ File.write("zzz5.rb", "class ZZZ; def self.ok;:ok;end;end\n")
autoload :ZZZ, "./zzz5.rb"
require "./zzz5.rb"
ZZZ.ok
}
assert_equal 'okok', %q{
- open("zzz6.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
+ File.write("zzz6.rb", "class ZZZ; def self.ok;:ok;end;end\n")
autoload :ZZZ, "./zzz6.rb"
t1 = Thread.new {ZZZ.ok}
t2 = Thread.new {ZZZ.ok}
@@ -60,7 +60,7 @@ assert_finish 5, %q{
}, '[ruby-core:21696]'
assert_equal 'A::C', %q{
- open("zzz7.rb", "w") {}
+ File.write("zzz7.rb", "")
class A
autoload :C, "./zzz7"
class C
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
index a9f389c673..20bd9615f4 100644
--- a/bootstraptest/test_eval.rb
+++ b/bootstraptest/test_eval.rb
@@ -217,7 +217,7 @@ assert_equal %q{[10, main]}, %q{
}
%w[break next redo].each do |keyword|
- assert_match %r"Can't escape from eval with #{keyword}\b", %{
+ assert_match %r"Invalid #{keyword}\b", %{
$stderr = STDOUT
begin
eval "0 rescue #{keyword}"
@@ -227,6 +227,16 @@ assert_equal %q{[10, main]}, %q{
}, '[ruby-dev:31372]'
end
+assert_normal_exit %{
+ $stderr = STDOUT
+ 5000.times do
+ begin
+ eval "0 rescue break"
+ rescue SyntaxError
+ end
+ end
+}
+
assert_normal_exit %q{
$stderr = STDOUT
class Foo
@@ -354,3 +364,34 @@ assert_normal_exit %q{
end
}, 'check escaping the internal value th->base_block'
+assert_equal "false", <<~RUBY, "literal strings are mutable", "--disable-frozen-string-literal"
+ eval("'test'").frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "literal strings are mutable", "--disable-frozen-string-literal", frozen_string_literal: true
+ eval("'test'").frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "literal strings are frozen", "--enable-frozen-string-literal"
+ eval("'test'").frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "literal strings are frozen", "--enable-frozen-string-literal", frozen_string_literal: false
+ eval("'test'").frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "__FILE__ is mutable", "--disable-frozen-string-literal"
+ eval("__FILE__").frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "__FILE__ is mutable", "--disable-frozen-string-literal", frozen_string_literal: true
+ eval("__FILE__").frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "__FILE__ is frozen", "--enable-frozen-string-literal"
+ eval("__FILE__").frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "__FILE__ is frozen", "--enable-frozen-string-literal", frozen_string_literal: false
+ eval("__FILE__").frozen?
+RUBY
diff --git a/bootstraptest/test_exception.rb b/bootstraptest/test_exception.rb
index 0fb6f552b8..decfdc08a3 100644
--- a/bootstraptest/test_exception.rb
+++ b/bootstraptest/test_exception.rb
@@ -370,7 +370,7 @@ assert_equal %q{}, %q{
}
##
-assert_match /undefined method `foo\'/, %q{#`
+assert_match /undefined method 'foo\'/, %q{#`
STDERR.reopen(STDOUT)
class C
def inspect
diff --git a/bootstraptest/test_fiber.rb b/bootstraptest/test_fiber.rb
index 2614dd13bf..ae809a5936 100644
--- a/bootstraptest/test_fiber.rb
+++ b/bootstraptest/test_fiber.rb
@@ -37,3 +37,8 @@ assert_normal_exit %q{
assert_normal_exit %q{
Fiber.new(&Object.method(:class_eval)).resume("foo")
}, '[ruby-dev:34128]'
+
+# [Bug #21400]
+assert_normal_exit %q{
+ Thread.new { Fiber.current.kill }.join
+}
diff --git a/bootstraptest/test_finalizer.rb b/bootstraptest/test_finalizer.rb
index 22a16b1220..ccfa0b55d6 100644
--- a/bootstraptest/test_finalizer.rb
+++ b/bootstraptest/test_finalizer.rb
@@ -6,3 +6,11 @@ ObjectSpace.define_finalizer(b1,proc{b1.inspect})
ObjectSpace.define_finalizer(a2,proc{a1.inspect})
ObjectSpace.define_finalizer(a1,proc{})
}, '[ruby-dev:35778]'
+
+assert_equal 'true', %q{
+ obj = Object.new
+ id = obj.object_id
+
+ ObjectSpace.define_finalizer(obj, proc { |i| print(id == i) })
+ nil
+}
diff --git a/bootstraptest/test_flow.rb b/bootstraptest/test_flow.rb
index 35f19db588..7a95def1e6 100644
--- a/bootstraptest/test_flow.rb
+++ b/bootstraptest/test_flow.rb
@@ -363,7 +363,7 @@ assert_equal %q{[1, 2, 3, 5, 2, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1
; $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
+ o = "test".dup; $a << 2
def o.test(a); $a << 3
return a; $a << 4
ensure; $a << 5
@@ -376,7 +376,7 @@ assert_equal %q{[1, 4, 7, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
; $a << 3
end; $a << 4
def m2; $a << 5
- m1(:a, :b, (return 1; :c)); $a << 6
+ m1(:a, :b, (return 1 if true; :c)); $a << 6
end; $a << 7
m2; $a << 8
; $a << 9
@@ -399,7 +399,7 @@ assert_equal %q{[1, 3, 11, 4, 5, 6, 7, 12, 13]}, %q{$a = []; begin; ; $a << 1
m2(begin; $a << 5
2; $a << 6
ensure; $a << 7
- return 3; $a << 8
+ return 3 if true; $a << 8
end); $a << 9
4; $a << 10
end; $a << 11
diff --git a/bootstraptest/test_fork.rb b/bootstraptest/test_fork.rb
index 83923dad97..860ef285d0 100644
--- a/bootstraptest/test_fork.rb
+++ b/bootstraptest/test_fork.rb
@@ -75,3 +75,30 @@ assert_equal '[1, 2]', %q{
end
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
+assert_equal 'ok', %q{
+ def now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+
+ Thread.new do
+ loop { sleep 0.0001 }
+ end
+
+ 10.times do
+ pid = fork{ exit!(0) }
+ deadline = now + 10
+ while true
+ _, status = Process.waitpid2(pid, Process::WNOHANG)
+ break if status
+ if now > deadline
+ Process.kill(:KILL, pid)
+ raise "failed"
+ end
+ sleep 0.001
+ end
+ unless status.success?
+ raise "child exited with status #{status}"
+ end
+ rescue NotImplementedError
+ end
+ :ok
+}, '[Bug #20670]'
+
diff --git a/bootstraptest/test_gc.rb b/bootstraptest/test_gc.rb
index 9f17e14814..eb68c9845e 100644
--- a/bootstraptest/test_gc.rb
+++ b/bootstraptest/test_gc.rb
@@ -14,7 +14,7 @@ ms = "a".."k"
o.send(meth)
end
end
-}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('rjit') # speed up RJIT CI
+}, '[ruby-dev:39453]'
assert_normal_exit %q{
a = []
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 91fba9b011..1f70c8075c 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -86,13 +86,13 @@ tests = [
[ 'putobject', %q{ /(?<x>x)/ =~ "x"; x == "x" }, ],
[ 'putspecialobject', %q{ {//=>true}[//] }, ],
- [ 'putstring', %q{ "true" }, ],
+ [ 'dupstring', %q{ "true" }, ],
[ 'tostring / concatstrings', %q{ "#{true}" }, ],
[ 'toregexp', %q{ /#{true}/ =~ "true" && $~ }, ],
[ 'intern', %q{ :"#{true}" }, ],
[ 'newarray', %q{ ["true"][0] }, ],
- [ 'newarraykwsplat', %q{ [**{x:'true'}][0][:x] }, ],
+ [ 'pushtoarraykwsplat', %q{ [**{x:'true'}][0][:x] }, ],
[ 'duparray', %q{ [ true ][0] }, ],
[ 'expandarray', %q{ y = [ true, false, nil ]; x, = y; x }, ],
[ 'expandarray', %q{ y = [ true, false, nil ]; x, *z = y; x }, ],
@@ -214,9 +214,24 @@ tests = [
'true'.freeze
},
- [ 'opt_newarray_max', %q{ [ ].max.nil? }, ],
- [ 'opt_newarray_max', %q{ [1, x = 2, 3].max == 3 }, ],
- [ 'opt_newarray_max', <<-'},', ], # {
+ [ 'opt_duparray_send', %q{ x = :a; [:a, :b].include?(x) }, ],
+ [ 'opt_duparray_send', <<-'},', ], # {
+ class Array
+ def include?(i)
+ i == 1
+ end
+ end
+ x = 1
+ [:a, :b].include?(x)
+ },
+
+ [ 'opt_newarray_send', %q{ ![ ].hash.nil? }, ],
+
+ [ 'opt_newarray_send', %q{ v=2; [1, Object.new, 2].include?(v) }, ],
+
+ [ 'opt_newarray_send', %q{ [ ].max.nil? }, ],
+ [ 'opt_newarray_send', %q{ [1, x = 2, 3].max == 3 }, ],
+ [ 'opt_newarray_send', <<-'},', ], # {
class Array
def max
true
@@ -224,9 +239,9 @@ tests = [
end
[1, x = 2, 3].max
},
- [ 'opt_newarray_min', %q{ [ ].min.nil? }, ],
- [ 'opt_newarray_min', %q{ [3, x = 2, 1].min == 1 }, ],
- [ 'opt_newarray_min', <<-'},', ], # {
+ [ 'opt_newarray_send', %q{ [ ].min.nil? }, ],
+ [ 'opt_newarray_send', %q{ [3, x = 2, 1].min == 1 }, ],
+ [ 'opt_newarray_send', <<-'},', ], # {
class Array
def min
true
@@ -234,6 +249,48 @@ tests = [
end
[3, x = 2, 1].min
},
+ [ 'opt_newarray_send', %q{ v = 1.23; [v, v*2].pack("E*").unpack("E*") == [v, v*2] }, ],
+ [ 'opt_newarray_send', %q{ v = 4.56; b = +"x"; [v, v*2].pack("E*", buffer: b); b[1..].unpack("E*") == [v, v*2] }, ],
+ [ 'opt_newarray_send', <<-'},', ], # {
+ v = 7.89;
+ b = +"x";
+ class Array
+ alias _pack pack
+ def pack(s, buffer: nil, prefix: "y")
+ buffer ||= +"b"
+ buffer << prefix
+ _pack(s, buffer: buffer)
+ end
+ end
+ tests = []
+
+ ret = [v].pack("E*", prefix: "z")
+ tests << (ret[0..1] == "bz")
+ tests << (ret[2..].unpack("E*") == [v])
+
+ ret = [v].pack("E*")
+ tests << (ret[0..1] == "by")
+ tests << (ret[2..].unpack("E*") == [v])
+
+ [v, v*2, v*3].pack("E*", buffer: b)
+ tests << (b[0..1] == "xy")
+ tests << (b[2..].unpack("E*") == [v, v*2, v*3])
+
+ class Array
+ def pack(_fmt, buffer:) = buffer
+ end
+
+ b = nil
+ tests << [v].pack("E*", buffer: b).nil?
+
+ class Array
+ def pack(_fmt, **kw) = kw.empty?
+ end
+
+ tests << [v].pack("E*") == true
+
+ tests.all? or puts tests
+ },
[ 'throw', %q{ false.tap { break true } }, ],
[ 'branchif', %q{ x = nil; x ||= true }, ],
@@ -352,7 +409,7 @@ tests = [
[ 'opt_ge', %q{ +0.0.next_float >= 0.0 }, ],
[ 'opt_ge', %q{ ?z >= ?a }, ],
- [ 'opt_ltlt', %q{ '' << 'true' }, ],
+ [ 'opt_ltlt', %q{ +'' << 'true' }, ],
[ 'opt_ltlt', %q{ ([] << 'true').join }, ],
[ 'opt_ltlt', %q{ (1 << 31) == 2147483648 }, ],
@@ -361,7 +418,7 @@ tests = [
[ 'opt_aref', %q{ 'true'[0] == ?t }, ],
[ 'opt_aset', %q{ [][0] = true }, ],
[ 'opt_aset', %q{ {}[0] = true }, ],
- [ 'opt_aset', %q{ x = 'frue'; x[0] = 't'; x }, ],
+ [ 'opt_aset', %q{ x = +'frue'; x[0] = 't'; x }, ],
[ 'opt_aset', <<-'},', ], # {
# opt_aref / opt_aset mixup situation
class X; def x; {}; end; end
@@ -369,11 +426,6 @@ tests = [
x&.x[true] ||= true # here
},
- [ 'opt_aref_with', %q{ { 'true' => true }['true'] }, ],
- [ 'opt_aref_with', %q{ Struct.new(:nil).new['nil'].nil? }, ],
- [ 'opt_aset_with', %q{ {}['true'] = true }, ],
- [ 'opt_aset_with', %q{ Struct.new(:true).new['true'] = true }, ],
-
[ 'opt_length', %q{ 'true' .length == 4 }, ],
[ 'opt_length', %q{ :true .length == 4 }, ],
[ 'opt_length', %q{ [ 'true' ] .length == 1 }, ],
diff --git a/bootstraptest/test_io.rb b/bootstraptest/test_io.rb
index 666e5a011b..4081769a8c 100644
--- a/bootstraptest/test_io.rb
+++ b/bootstraptest/test_io.rb
@@ -85,13 +85,13 @@ assert_normal_exit %q{
ARGF.set_encoding "foo"
}
-/freebsd/ =~ RUBY_PLATFORM or
+/(freebsd|mswin)/ =~ RUBY_PLATFORM or
10.times do
assert_normal_exit %q{
at_exit { p :foo }
megacontent = "abc" * 12345678
- #File.open("megasrc", "w") {|f| f << megacontent }
+ #File.write("megasrc", megacontent)
t0 = Thread.main
Thread.new { sleep 0.001 until t0.stop?; Process.kill(:INT, $$) }
diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb
index d07c47a56d..8751343b1f 100644
--- a/bootstraptest/test_jump.rb
+++ b/bootstraptest/test_jump.rb
@@ -292,7 +292,7 @@ assert_equal "true", %q{
end
end
end
- s = "foo"
+ s = +"foo"
s.return_eigenclass == class << s; self; end
}, '[ruby-core:21379]'
diff --git a/bootstraptest/test_literal.rb b/bootstraptest/test_literal.rb
index a0d4ee08c6..39e6527027 100644
--- a/bootstraptest/test_literal.rb
+++ b/bootstraptest/test_literal.rb
@@ -70,6 +70,7 @@ if /wasi/ !~ target_platform
assert_equal "foo\n", %q(`echo foo`)
assert_equal "foo\n", %q(s = "foo"; `echo #{s}`)
end
+assert_equal "ECHO FOO", %q(def `(s) s.upcase; end; `echo foo`)
# regexp
assert_equal '', '//.source'
@@ -116,16 +117,16 @@ 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]"
+assert_equal '[]', 'def nil.to_a; [1, 2]; end; [*nil]'
+assert_equal '[1]', 'def nil.to_a; [2]; end; [1, *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 '{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]'
diff --git a/bootstraptest/test_literal_suffix.rb b/bootstraptest/test_literal_suffix.rb
index c36fa7078f..7a4d67d0fa 100644
--- a/bootstraptest/test_literal_suffix.rb
+++ b/bootstraptest/test_literal_suffix.rb
@@ -46,9 +46,9 @@ assert_equal '1', '1rescue nil'
assert_equal '10000000000000000001/10000000000000000000',
'1.0000000000000000001r'
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
- %q{begin eval('1ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
- %q{begin eval('1.2ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
-assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input',
- %q{begin eval('1e1r', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end}
+assert_equal 'unexpected local variable or method, expecting end-of-input',
+ %q{begin eval('1ir', nil, '', 0); rescue SyntaxError => e; e.message[/(?:\^~*|\A:(?:\d+:)? syntax error,) (.*)/, 1]; end}
+assert_equal 'unexpected local variable or method, expecting end-of-input',
+ %q{begin eval('1.2ir', nil, '', 0); rescue SyntaxError => e; e.message[/(?:\^~*|\A:(?:\d+:)? syntax error,) (.*)/, 1]; end}
+assert_equal 'unexpected local variable or method, expecting end-of-input',
+ %q{begin eval('1e1r', nil, '', 0); rescue SyntaxError => e; e.message[/(?:\^~*|\A:(?:\d+:)? syntax error,) (.*)/, 1]; end}
diff --git a/bootstraptest/test_load.rb b/bootstraptest/test_load.rb
index e63c93a8f4..fa8d31c098 100644
--- a/bootstraptest/test_load.rb
+++ b/bootstraptest/test_load.rb
@@ -1,9 +1,9 @@
assert_equal 'ok', %q{
- open("require-lock-test.rb", "w") {|f|
- f.puts "sleep 0.1"
- f.puts "module M"
- f.puts "end"
- }
+ File.write("require-lock-test.rb", <<-END)
+ sleep 0.1
+ module M
+ end
+ END
$:.unshift Dir.pwd
vs = (1..2).map {|i|
Thread.start {
@@ -16,7 +16,7 @@ assert_equal 'ok', %q{
assert_equal 'ok', %q{
%w[a a/foo b].each {|d| Dir.mkdir(d)}
- open("b/foo", "w") {|f| f.puts "$ok = :ok"}
+ File.write("b/foo", "$ok = :ok\n")
$:.replace(%w[a b])
begin
load "foo"
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
index 04c9eb2d11..e894f6f601 100644
--- a/bootstraptest/test_method.rb
+++ b/bootstraptest/test_method.rb
@@ -340,24 +340,6 @@ assert_equal '1', %q( class C; def m() 7 end; private :m 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
@@ -404,7 +386,6 @@ $result
# aset and splat
assert_equal '4', %q{class Foo;def []=(a,b,c,d);end;end;Foo.new[1,*a=[2,3]]=4}
-assert_equal '4', %q{class Foo;def []=(a,b,c,d);end;end;def m(&blk)Foo.new[1,*a=[2,3],&blk]=4;end;m{}}
# post test
assert_equal %q{[1, 2, :o1, :o2, [], 3, 4, NilClass, nil, nil]}, %q{
@@ -1107,10 +1088,6 @@ assert_equal 'ok', %q{
'ok'
end
}
-assert_equal 'ok', %q{
- [0][0, &proc{}] += 21
- 'ok'
-}, '[ruby-core:30534]'
# should not cache when splat
assert_equal 'ok', %q{
@@ -1190,3 +1167,276 @@ assert_equal 'DC', %q{
test2 o1, [], block
$result.join
}
+
+assert_equal 'ok', %q{
+ def foo
+ binding
+ ["ok"].first
+ end
+ foo
+ foo
+}, '[Bug #20178]'
+
+assert_equal 'ok', %q{
+ def bar(x); x; end
+ def foo(...); bar(...); end
+ foo('ok')
+}
+
+assert_equal 'ok', %q{
+ def bar(x); x; end
+ def foo(z, ...); bar(...); end
+ foo(1, 'ok')
+}
+
+assert_equal 'ok', %q{
+ def bar(x, y); x; end
+ def foo(...); bar("ok", ...); end
+ foo(1)
+}
+
+assert_equal 'ok', %q{
+ def bar(x); x; end
+ def foo(...); 1.times { return bar(...) }; end
+ foo("ok")
+}
+
+assert_equal 'ok', %q{
+ def bar(x); x; end
+ def foo(...); x = nil; 1.times { x = bar(...) }; x; end
+ foo("ok")
+}
+
+assert_equal 'ok', %q{
+ def bar(x); yield; end
+ def foo(...); bar(...); end
+ foo(1) { "ok" }
+}
+
+assert_equal 'ok', %q{
+ def baz(x); x; end
+ def bar(...); baz(...); end
+ def foo(...); bar(...); end
+ foo("ok")
+}
+
+assert_equal '[1, 2, 3, 4]', %q{
+ def baz(a, b, c, d); [a, b, c, d]; end
+ def bar(...); baz(1, ...); end
+ def foo(...); bar(2, ...); end
+ foo(3, 4)
+}
+
+assert_equal 'ok', %q{
+ class Foo; def self.foo(x); x; end; end
+ class Bar < Foo; def self.foo(...); super; end; end
+ Bar.foo('ok')
+}
+
+assert_equal 'ok', %q{
+ class Foo; def self.foo(x); x; end; end
+ class Bar < Foo; def self.foo(...); super(...); end; end
+ Bar.foo('ok')
+}
+
+assert_equal 'ok', %q{
+ class Foo; def self.foo(x, y); x + y; end; end
+ class Bar < Foo; def self.foo(...); super("o", ...); end; end
+ Bar.foo('k')
+}
+
+assert_equal 'ok', %q{
+ def bar(a); a; end
+ def foo(...); lambda { bar(...) }; end
+ foo("ok").call
+}
+
+assert_equal 'ok', %q{
+ class Foo; def self.foo(x, y); x + y; end; end
+ class Bar < Foo; def self.y(&b); b; end; def self.foo(...); y { super("o", ...) }; end; end
+ Bar.foo('k').call
+}
+
+assert_equal 'ok', %q{
+ def baz(n); n; end
+ def foo(...); bar = baz(...); lambda { lambda { bar } }; end
+ foo("ok").call.call
+}
+
+assert_equal 'ok', %q{
+ class A; def self.foo(...); new(...); end; attr_reader :b; def initialize(a, b:"ng"); @a = a; @b = b; end end
+ A.foo(1).b
+ A.foo(1, b: "ok").b
+}
+
+assert_equal 'ok', %q{
+ class A; def initialize; @a = ["ok"]; end; def first(...); @a.first(...); end; end
+ def call x; x.first; end
+ def call1 x; x.first(1); end
+ call(A.new)
+ call1(A.new).first
+}
+
+assert_equal 'ok', %q{
+ class A; def foo; yield("o"); end; end
+ class B < A; def foo(...); super { |x| yield(x + "k") }; end; end
+ B.new.foo { |x| x }
+}
+
+assert_equal "[1, 2, 3, 4]", %q{
+ def foo(*b) = b
+
+ def forward(...)
+ splat = [1,2,3]
+ foo(*splat, ...)
+ end
+
+ forward(4)
+}
+
+assert_equal "[1, 2, 3, 4]", %q{
+class A
+ def foo(*b) = b
+end
+
+class B < A
+ def foo(...)
+ splat = [1,2,3]
+ super(*splat, ...)
+ end
+end
+
+B.new.foo(4)
+}
+
+assert_equal 'ok', %q{
+ class A; attr_reader :iv; def initialize(...) = @iv = "ok"; end
+ A.new("foo", bar: []).iv
+}
+
+assert_equal 'ok', %q{
+ def foo(a, b) = a + b
+ def bar(...) = foo(...)
+ bar(1, 2)
+ bar(1, 2)
+ begin
+ bar(1, 2, 3)
+ "ng"
+ rescue ArgumentError
+ "ok"
+ end
+}
+
+assert_equal 'ok', %q{
+ class C
+ def foo(...) = :ok
+ def bar(...) = __send__(:foo, ...)
+ end
+
+ C.new.bar
+}
+
+assert_equal 'ok', %q{
+ class C
+ def method_missing(...) = :ok
+ def foo(...) = xyzzy(...)
+ end
+
+ C.new.foo
+}
+
+assert_equal 'ok', %q{
+ class C
+ def initialize(a)
+ end
+ end
+
+ def foo(...)
+ C.new(...)
+ :ok
+ end
+
+ foo(*["bar"])
+ foo("baz")
+}
+
+assert_equal 'ok', %q{
+ class C
+ def foo(b:)
+ b
+ end
+ end
+
+ def foo(...)
+ C.new.send(...)
+ end
+
+ foo(:foo, b: :ok)
+ foo(*["foo"], b: :ok)
+}
+
+assert_equal 'ok', %q{
+ Thing = Struct.new(:value)
+
+ Obj = Thing.new("ok")
+
+ def delegate(...)
+ Obj.value(...)
+ end
+
+ def no_args
+ delegate
+ end
+
+ def splat_args(*args)
+ delegate(*args)
+ end
+
+ no_args
+ splat_args
+}
+
+assert_equal 'ok', %q{
+ class A
+ private
+ def foo = "ng"
+ end
+
+ class B
+ def initialize(o)
+ @o = o
+ end
+
+ def foo(...) = @o.foo(...)
+ def internal_foo = foo
+ end
+
+ b = B.new(A.new)
+
+ begin
+ b.internal_foo
+ rescue NoMethodError
+ "ok"
+ end
+}
+
+assert_equal 'ok', <<~RUBY
+ def test(*, kw: false)
+ "ok"
+ end
+
+ test
+RUBY
+
+assert_equal '[1, 2, 3]', %q{
+ def target(*args) = args
+ def x = [1]
+ def forwarder(...) = target(*x, 2, ...)
+ forwarder(3).inspect
+}, '[Bug #21832] post-splat args before forwarding'
+
+assert_equal '[nil, nil]', %q{
+ def self_reading(a = a, kw:) = a
+ def through_binding(a = binding.local_variable_get(:a), kw:) = a
+ [self_reading(kw: 1), through_binding(kw: 1)]
+}, 'nil initialization of optional parameters'
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index f92b604d2a..4fe90703fc 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -67,7 +67,7 @@ assert_equal "#<Ractor:#1 running>", %q{
# Return id, loc, and status for no-name ractor
assert_match /^#<Ractor:#([^ ]*?) .+:[0-9]+ terminated>$/, %q{
r = Ractor.new { '' }
- r.take
+ r.join
sleep 0.1 until r.inspect =~ /terminated/
r.inspect
}
@@ -75,7 +75,7 @@ assert_match /^#<Ractor:#([^ ]*?) .+:[0-9]+ terminated>$/, %q{
# Return id, name, loc, and status for named ractor
assert_match /^#<Ractor:#([^ ]*?) Test Ractor .+:[0-9]+ terminated>$/, %q{
r = Ractor.new(name: 'Test Ractor') { '' }
- r.take
+ r.join
sleep 0.1 until r.inspect =~ /terminated/
r.inspect
}
@@ -86,7 +86,7 @@ assert_equal 'ok', %q{
r = Ractor.new do
'ok'
end
- r.take
+ r.value
}
# Passed arguments to Ractor.new will be a block parameter
@@ -96,7 +96,7 @@ assert_equal 'ok', %q{
r = Ractor.new 'ok' do |msg|
msg
end
- r.take
+ r.value
}
# Pass multiple arguments to Ractor.new
@@ -105,7 +105,7 @@ assert_equal 'ok', %q{
r = Ractor.new 'ping', 'pong' do |msg, msg2|
[msg, msg2]
end
- 'ok' if r.take == ['ping', 'pong']
+ 'ok' if r.value == ['ping', 'pong']
}
# Ractor#send passes an object with copy to a Ractor
@@ -115,65 +115,23 @@ assert_equal 'ok', %q{
msg = Ractor.receive
end
r.send 'ok'
- r.take
+ r.value
}
# Ractor#receive_if can filter the message
-assert_equal '[2, 3, 1]', %q{
- r = Ractor.new Ractor.current do |main|
- main << 1
- main << 2
- main << 3
- end
- a = []
- a << Ractor.receive_if{|msg| msg == 2}
- a << Ractor.receive_if{|msg| msg == 3}
- a << Ractor.receive
-}
+assert_equal '[1, 2, 3]', %q{
+ ports = 3.times.map{Ractor::Port.new}
-# Ractor#receive_if with break
-assert_equal '[2, [1, :break], 3]', %q{
- r = Ractor.new Ractor.current do |main|
- main << 1
- main << 2
- main << 3
+ r = Ractor.new ports do |ports|
+ ports[0] << 3
+ ports[1] << 1
+ ports[2] << 2
end
-
a = []
- a << Ractor.receive_if{|msg| msg == 2}
- a << Ractor.receive_if{|msg| break [msg, :break]}
- a << Ractor.receive
-}
-
-# Ractor#receive_if can't be called recursively
-assert_equal '[[:e1, 1], [:e2, 2]]', %q{
- r = Ractor.new Ractor.current do |main|
- main << 1
- main << 2
- main << 3
- end
-
- a = []
-
- Ractor.receive_if do |msg|
- begin
- Ractor.receive
- rescue Ractor::Error
- a << [:e1, msg]
- end
- true # delete 1 from queue
- end
-
- Ractor.receive_if do |msg|
- begin
- Ractor.receive_if{}
- rescue Ractor::Error
- a << [:e2, msg]
- end
- true # delete 2 from queue
- end
-
- a #
+ a << ports[1].receive # 1
+ a << ports[2].receive # 2
+ a << ports[0].receive # 3
+ a
}
# dtoa race condition
@@ -184,73 +142,145 @@ assert_equal '[:ok, :ok, :ok]', %q{
10_000.times{ rand.to_s }
:ok
}
- }.map(&:take)
+ }.map(&:value)
}
-# Ractor.make_shareable issue for locals in proc [Bug #18023]
+assert_equal "42", %q{
+ a = 42
+ Ractor.shareable_lambda{ a }.call
+}
+
+# Ractor.shareable_proc issue for locals in proc [Bug #18023]
assert_equal '[:a, :b, :c, :d, :e]', %q{
v1, v2, v3, v4, v5 = :a, :b, :c, :d, :e
- closure = Ractor.current.instance_eval{ Proc.new { [v1, v2, v3, v4, v5] } }
+ closure = Proc.new { [v1, v2, v3, v4, v5] }
+ Ractor.shareable_proc(&closure).call
+}
+
+# Ractor.shareable_proc makes a copy of given Proc
+assert_equal '[true, true]', %q{
+ pr1 = Proc.new do
+ self
+ end
+ pr2 = Ractor.shareable_proc(&pr1)
- Ractor.make_shareable(closure).call
+ [pr1.call == self, pr2.call == nil]
}
-# Ractor.make_shareable issue for locals in proc [Bug #18023]
-assert_equal '[:a, :b, :c, :d, :e, :f, :g]', %q{
- a = :a
- closure = Ractor.current.instance_eval do
- -> {
- b, c, d = :b, :c, :d
- -> {
- e, f, g = :e, :f, :g
- -> { [a, b, c, d, e, f, g] }
- }.call
- }.call
+# Ractor.shareable_proc keeps the original Proc intact
+assert_equal '[SyntaxError, [Object, 43, 43], Binding]', %q{
+ a = 42
+ pr1 = Proc.new do
+ [self.class, eval("a"), binding.local_variable_get(:a)]
end
+ a += 1
+ pr2 = Ractor.shareable_proc(&pr1)
- Ractor.make_shareable(closure).call
+ r = []
+ begin
+ pr2.call
+ rescue SyntaxError
+ r << SyntaxError
+ end
+
+ r << pr1.call << pr1.binding.class
}
-# Now autoload in non-main Ractor is not supported
-assert_equal 'ok', %q{
- autoload :Foo, 'foo.rb'
- r = Ractor.new do
- p Foo
- rescue Ractor::UnsafeError
- :ok
+# Ractor.make_shareable mutates the original Proc
+# This is the current behavior, it's currently considered safe enough
+# because in most cases it would raise anyway due to not-shared self or not-shared captured variable value
+assert_equal '[[42, 42], Binding, true, SyntaxError, "Can\'t create Binding from isolated Proc"]', %q{
+ a = 42
+ pr1 = nil.instance_exec do
+ Proc.new do
+ [eval("a"), binding.local_variable_get(:a)]
+ end
+ end
+
+ r = [pr1.call, pr1.binding.class]
+
+ pr2 = Ractor.make_shareable(pr1)
+ r << pr1.equal?(pr2)
+
+ begin
+ pr1.call
+ rescue SyntaxError
+ r << SyntaxError
+ end
+
+ begin
+ r << pr1.binding
+ rescue ArgumentError
+ r << $!.message
+ end
+
+ r
+}
+
+# Ractor::IsolationError cases
+assert_equal '3', %q{
+ ok = 0
+
+ begin
+ a = 1
+ Ractor.shareable_proc{a}
+ a = 2
+ rescue Ractor::IsolationError => e
+ ok += 1
+ end
+
+ begin
+ cond = false
+ b = 1
+ b = 2 if cond
+ Ractor.shareable_proc{b}
+ rescue Ractor::IsolationError => e
+ ok += 1
+ end
+
+ begin
+ 1.times{|i|
+ i = 2
+ Ractor.shareable_proc{i}
+ }
+ rescue Ractor::IsolationError => e
+ ok += 1
end
- r.take
}
###
###
# Ractor still has several memory corruption so skip huge number of tests
-if ENV['GITHUB_WORKFLOW'] &&
- ENV['GITHUB_WORKFLOW'] == 'Compilations'
+if ENV['GITHUB_WORKFLOW'] == 'Compilations'
# ignore the follow
else
-# Ractor.select(*ractors) receives a values from a ractors.
-# It is similar to select(2) and Go's select syntax.
-# The return value is [ch, received_value]
+# Ractor.select with a Ractor argument
assert_equal 'ok', %q{
# select 1
r1 = Ractor.new{'r1'}
- r, obj = Ractor.select(r1)
- 'ok' if r == r1 and obj == 'r1'
+ port, obj = Ractor.select(r1)
+ if port == r1 and obj == 'r1'
+ 'ok'
+ else
+ # failed
+ [port, obj].inspect
+ end
}
# Ractor.select from two ractors.
assert_equal '["r1", "r2"]', %q{
# select 2
- r1 = Ractor.new{'r1'}
- r2 = Ractor.new{'r2'}
- rs = [r1, r2]
+ p1 = Ractor::Port.new
+ p2 = Ractor::Port.new
+ r1 = Ractor.new(p1){|p1| p1 << 'r1'}
+ r2 = Ractor.new(p2){|p2| p2 << 'r2'}
+ ps = [p1, p2]
as = []
- r, obj = Ractor.select(*rs)
- rs.delete(r)
+ port, obj = Ractor.select(*ps)
+ ps.delete(port)
as << obj
- r, obj = Ractor.select(*rs)
+ port, obj = Ractor.select(*ps)
as << obj
as.sort #=> ["r1", "r2"]
}
@@ -286,7 +316,7 @@ assert_equal 30.times.map { 'ok' }.to_s, %q{
} unless (ENV.key?('TRAVIS') && ENV['TRAVIS_CPU_ARCH'] == 'arm64') # https://bugs.ruby-lang.org/issues/17878
# Exception for empty select
-assert_match /specify at least one ractor/, %q{
+assert_match /specify at least one Ractor::Port or Ractor/, %q{
begin
Ractor.select
rescue ArgumentError => e
@@ -294,30 +324,12 @@ assert_match /specify at least one ractor/, %q{
end
}
-# Outgoing port of a ractor will be closed when the Ractor is terminated.
-assert_equal 'ok', %q{
- r = Ractor.new do
- 'finish'
- end
-
- r.take
- sleep 0.1 until r.inspect =~ /terminated/
-
- begin
- o = r.take
- rescue Ractor::ClosedError
- 'ok'
- else
- "ng: #{o}"
- end
-}
-
# Raise Ractor::ClosedError when try to send into a terminated ractor
assert_equal 'ok', %q{
r = Ractor.new do
end
- r.take # closed
+ r.join # closed
sleep 0.1 until r.inspect =~ /terminated/
begin
@@ -329,47 +341,16 @@ assert_equal 'ok', %q{
end
}
-# Raise Ractor::ClosedError when try to send into a closed actor
-assert_equal 'ok', %q{
- r = Ractor.new { Ractor.receive }
- r.close_incoming
-
- begin
- r.send(1)
- rescue Ractor::ClosedError
- 'ok'
- else
- 'ng'
- end
-}
-
-# Raise Ractor::ClosedError when try to take from closed actor
-assert_equal 'ok', %q{
- r = Ractor.new do
- Ractor.yield 1
- Ractor.receive
- end
-
- r.close_outgoing
- begin
- r.take
- rescue Ractor::ClosedError
- 'ok'
- else
- 'ng'
- end
-}
-
-# Can mix with Thread#interrupt and Ractor#take [Bug #17366]
+# Can mix with Thread#interrupt and Ractor#join [Bug #17366]
assert_equal 'err', %q{
- Ractor.new{
+ Ractor.new do
t = Thread.current
begin
Thread.new{ t.raise "err" }.join
rescue => e
e.message
end
- }.take
+ end.value
}
# Killed Ractor's thread yields nil
@@ -377,34 +358,18 @@ assert_equal 'nil', %q{
Ractor.new{
t = Thread.current
Thread.new{ t.kill }.join
- }.take.inspect #=> nil
+ }.value.inspect #=> nil
}
-# Ractor.yield raises Ractor::ClosedError when outgoing port is closed.
+# Raise Ractor::ClosedError when try to send into a ractor with closed default port
assert_equal 'ok', %q{
- r = Ractor.new Ractor.current do |main|
+ r = Ractor.new {
+ Ractor.current.close
+ Ractor.main << :ok
Ractor.receive
- main << true
- Ractor.yield 1
- end
-
- r.close_outgoing
- r << true
- Ractor.receive
-
- begin
- r.take
- rescue Ractor::ClosedError
- 'ok'
- else
- 'ng'
- end
-}
+ }
-# Raise Ractor::ClosedError when try to send into a ractor with closed incoming port
-assert_equal 'ok', %q{
- r = Ractor.new { Ractor.receive }
- r.close_incoming
+ Ractor.receive # wait for ok
begin
r.send(1)
@@ -415,154 +380,82 @@ assert_equal 'ok', %q{
end
}
-# A ractor with closed incoming port still can send messages out
-assert_equal '[1, 2]', %q{
- r = Ractor.new do
- Ractor.yield 1
- 2
- end
- r.close_incoming
-
- [r.take, r.take]
-}
-
-# Raise Ractor::ClosedError when try to take from a ractor with closed outgoing port
-assert_equal 'ok', %q{
- r = Ractor.new do
- Ractor.yield 1
- Ractor.receive
- end
-
- sleep 0.01 # wait for Ractor.yield in r
- r.close_outgoing
- begin
- r.take
- rescue Ractor::ClosedError
- 'ok'
- else
- 'ng'
- end
-}
-
-# A ractor with closed outgoing port still can receive messages from incoming port
-assert_equal 'ok', %q{
- r = Ractor.new do
- Ractor.receive
- end
-
- r.close_outgoing
- begin
- r.send(1)
- rescue Ractor::ClosedError
- 'ng'
- else
- 'ok'
- end
-}
-
# Ractor.main returns main ractor
assert_equal 'true', %q{
Ractor.new{
Ractor.main
- }.take == Ractor.current
+ }.value == Ractor.current
}
# a ractor with closed outgoing port should terminate
assert_equal 'ok', %q{
Ractor.new do
- close_outgoing
+ Ractor.current.close
end
true until Ractor.count == 1
:ok
}
-# multiple Ractors can receive (wait) from one Ractor
-assert_equal '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', %q{
- pipe = Ractor.new do
- loop do
- Ractor.yield Ractor.receive
- end
+# an exception in a Ractor main thread will be re-raised at Ractor#receive
+assert_equal '[RuntimeError, "ok", true]', %q{
+ r = Ractor.new do
+ raise 'ok' # exception will be transferred receiver
end
-
- RN = 10
- rs = RN.times.map{|i|
- Ractor.new pipe, i do |pipe, i|
- msg = pipe.take
- msg # ping-pong
- end
- }
- RN.times{|i|
- pipe << i
- }
- RN.times.map{
- r, n = Ractor.select(*rs)
- rs.delete r
- n
- }.sort
-} unless /mswin/ =~ RUBY_PLATFORM # randomly hangs on mswin https://github.com/ruby/ruby/actions/runs/3753871445/jobs/6377551069#step:20:131
-
-# Ractor.select also support multiple take, receive and yield
-assert_equal '[true, true, true]', %q{
- RN = 10
- CR = Ractor.current
-
- rs = (1..RN).map{
- Ractor.new do
- CR.send 'send' + CR.take #=> 'sendyield'
- 'take'
- end
- }
- received = []
- taken = []
- yielded = []
- until received.size == RN && taken.size == RN && yielded.size == RN
- r, v = Ractor.select(CR, *rs, yield_value: 'yield')
- case r
- when :receive
- received << v
- when :yield
- yielded << v
- else
- taken << v
- rs.delete r
- end
+ begin
+ r.join
+ rescue Ractor::RemoteError => e
+ [e.cause.class, #=> RuntimeError
+ e.cause.message, #=> 'ok'
+ e.ractor == r] #=> true
end
- r = [received == ['sendyield'] * RN,
- yielded == [nil] * RN,
- taken == ['take'] * RN,
- ]
-
- STDERR.puts [received, yielded, taken].inspect
- r
}
-# multiple Ractors can send to one Ractor
-assert_equal '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', %q{
- pipe = Ractor.new do
- loop do
- Ractor.yield Ractor.receive
- end
+# an exception in a Ractor will be re-raised at Ractor#value
+assert_equal '[RuntimeError, "ok", true]', %q{
+ r = Ractor.new do
+ raise 'ok' # exception will be transferred receiver
end
+ begin
+ r.value
+ rescue Ractor::RemoteError => e
+ [e.cause.class, #=> RuntimeError
+ e.cause.message, #=> 'ok'
+ e.ractor == r] #=> true
+ end
+}
- RN = 10
- RN.times.map{|i|
- Ractor.new pipe, i do |pipe, i|
- pipe << i
+# an exception in a Ractor non-main thread will not be re-raised at Ractor#receive
+assert_equal 'ok', %q{
+ r = Ractor.new do
+ Thread.new do
+ raise 'ng'
end
- }
- RN.times.map{
- pipe.take
- }.sort
+ sleep 0.1
+ 'ok'
+ end
+ r.value
}
-# an exception in a Ractor will be re-raised at Ractor#receive
-assert_equal '[RuntimeError, "ok", true]', %q{
- r = Ractor.new do
- raise 'ok' # exception will be transferred receiver
+# SystemExit from a Ractor is re-raised
+# [Bug #21505]
+assert_equal '[SystemExit, "exit", true]', %q{
+ r = Ractor.new { exit }
+ begin
+ r.value
+ rescue Ractor::RemoteError => e
+ [e.cause.class, #=> RuntimeError
+ e.cause.message, #=> 'ok'
+ e.ractor == r] #=> true
end
+}
+
+# SystemExit from a Thread inside a Ractor is re-raised
+# [Bug #21505]
+assert_equal '[SystemExit, "exit", true]', %q{
+ r = Ractor.new { Thread.new { exit }.join }
begin
- r.take
+ r.value
rescue Ractor::RemoteError => e
[e.cause.class, #=> RuntimeError
e.cause.message, #=> 'ok'
@@ -571,7 +464,7 @@ assert_equal '[RuntimeError, "ok", true]', %q{
}
# threads in a ractor will killed
-assert_equal '{:ok=>3}', %q{
+assert_equal '{ok: 3}', %q{
Ractor.new Ractor.current do |main|
q = Thread::Queue.new
Thread.new do
@@ -601,7 +494,7 @@ assert_equal '{:ok=>3}', %q{
end
3.times.map{Ractor.receive}.tally
-}
+} unless yjit_enabled? # YJIT: `[BUG] Bus Error at 0x000000010b7002d0` in jit_exec()
# unshareable object are copied
assert_equal 'false', %q{
@@ -610,29 +503,30 @@ assert_equal 'false', %q{
msg.object_id
end
- obj.object_id == r.take
+ obj.object_id == r.value
}
# To copy the object, now Marshal#dump is used
-assert_equal "allocator undefined for Thread", %q{
+assert_match /can't clone unshareable instance of Thread/, %q{
obj = Thread.new{}
begin
r = Ractor.new obj do |msg|
msg
end
- rescue TypeError => e
- e.message #=> no _dump_data is defined for class Thread
+ rescue Ractor::Error => e
+ e.message
else
'ng'
end
}
# send shareable and unshareable objects
-assert_equal "ok", %q{
- echo_ractor = Ractor.new do
+assert_equal "ok", <<~'RUBY', frozen_string_literal: false
+ port = Ractor::Port.new
+ echo_ractor = Ractor.new port do |port|
loop do
v = Ractor.receive
- Ractor.yield v
+ port << v
end
end
@@ -680,13 +574,13 @@ assert_equal "ok", %q{
shareable_objects.map{|o|
echo_ractor << o
- o2 = echo_ractor.take
+ o2 = port.receive
results << "#{o} is copied" unless o.object_id == o2.object_id
}
unshareable_objects.map{|o|
echo_ractor << o
- o2 = echo_ractor.take
+ o2 = port.receive
results << "#{o.inspect} is not copied" if o.object_id == o2.object_id
}
@@ -695,10 +589,10 @@ assert_equal "ok", %q{
else
results.inspect
end
-}
+RUBY
# frozen Objects are shareable
-assert_equal [false, true, false].inspect, %q{
+assert_equal [false, true, false].inspect, <<~'RUBY', frozen_string_literal: false
class C
def initialize freeze
@a = 1
@@ -712,7 +606,7 @@ assert_equal [false, true, false].inspect, %q{
def check obj1
obj2 = Ractor.new obj1 do |obj|
obj
- end.take
+ end.value
obj1.object_id == obj2.object_id
end
@@ -721,11 +615,11 @@ assert_equal [false, true, false].inspect, %q{
results << check(C.new(true)) # false
results << check(C.new(true).freeze) # true
results << check(C.new(false).freeze) # false
-}
+RUBY
# move example2: String
# touching moved object causes an error
-assert_equal 'hello world', %q{
+assert_equal 'hello world', <<~'RUBY', frozen_string_literal: false
# move
r = Ractor.new do
obj = Ractor.receive
@@ -734,7 +628,7 @@ assert_equal 'hello world', %q{
str = 'hello'
r.send str, move: true
- modified = r.take
+ modified = r.value
begin
str << ' exception' # raise Ractor::MovedError
@@ -743,7 +637,7 @@ assert_equal 'hello world', %q{
else
raise 'unreachable'
end
-}
+RUBY
# move example2: Array
assert_equal '[0, 1]', %q{
@@ -754,7 +648,7 @@ assert_equal '[0, 1]', %q{
a1 = [0]
r.send a1, move: true
- a2 = r.take
+ a2 = r.value
begin
a1 << 2 # raise Ractor::MovedError
rescue Ractor::MovedError
@@ -762,70 +656,39 @@ assert_equal '[0, 1]', %q{
end
}
-# move with yield
-assert_equal 'hello', %q{
- r = Ractor.new do
- Thread.current.report_on_exception = false
- obj = 'hello'
- Ractor.yield obj, move: true
- obj << 'world'
- end
-
- str = r.take
- begin
- r.take
- rescue Ractor::RemoteError
- str #=> "hello"
- end
-}
-
-# yield/move should not make moved object when the yield is not succeeded
-assert_equal '"str"', %q{
- R = Ractor.new{}
- M = Ractor.current
- r = Ractor.new do
- s = 'str'
- selected_r, v = Ractor.select R, yield_value: s, move: true
- raise if selected_r != R # taken from R
- M.send s.inspect # s should not be a moved object
- end
-
- Ractor.receive
-}
-
-# yield/move can fail
-assert_equal "allocator undefined for Thread", %q{
+# unshareable frozen objects should still be frozen in new ractor after move
+assert_equal 'true', %q{
r = Ractor.new do
- obj = Thread.new{}
- Ractor.yield obj
- rescue => e
- e.message
+ obj = receive
+ { frozen: obj.frozen? }
end
- r.take
+ obj = [Object.new].freeze
+ r.send(obj, move: true)
+ r.value[:frozen]
}
-# Access to global-variables are prohibited
-assert_equal 'can not access global variables $gv from non-main Ractors', %q{
+# Access to global-variables are prohibited (read)
+assert_equal 'can not access global variable $gv from non-main Ractor', %q{
$gv = 1
r = Ractor.new do
$gv
end
begin
- r.take
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
}
-# Access to global-variables are prohibited
-assert_equal 'can not access global variables $gv from non-main Ractors', %q{
+# Access to global-variables are prohibited (write)
+assert_equal 'can not access global variable $gv from non-main Ractor', %q{
r = Ractor.new do
$gv = 1
end
begin
- r.take
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
@@ -839,7 +702,7 @@ assert_equal 'ok', %q{
}
end
- [$stdin, $stdout, $stderr].zip(r.take){|io, (oid, fno)|
+ [$stdin, $stdout, $stderr].zip(r.value){|io, (oid, fno)|
raise "should not be different object" if io.object_id == oid
raise "fd should be same" unless io.fileno == fno
}
@@ -855,7 +718,7 @@ assert_equal 'ok', %q{
'ok'
end
- r.take
+ r.value
}
# $DEBUG, $VERBOSE are Ractor local
@@ -913,7 +776,7 @@ assert_equal 'true', %q{
h = Ractor.new do
ractor_local_globals
- end.take
+ end.value
ractor_local_globals == h #=> true
}
@@ -922,7 +785,8 @@ assert_equal 'false', %q{
r = Ractor.new do
self.object_id
end
- r.take == self.object_id #=> false
+ ret = r.value
+ ret == self.object_id
}
# self is a Ractor instance
@@ -930,11 +794,16 @@ assert_equal 'true', %q{
r = Ractor.new do
self.object_id
end
- r.object_id == r.take #=> true
+ ret = r.value
+ if r.object_id == ret #=> true
+ true
+ else
+ raise [ret, r.object_id].inspect
+ end
}
# given block Proc will be isolated, so can not access outer variables.
-assert_equal 'ArgumentError', %q{
+assert_equal 'Ractor::IsolationError', %q{
begin
a = true
r = Ractor.new do
@@ -945,8 +814,39 @@ assert_equal 'ArgumentError', %q{
end
}
+# eval with outer locals in a Ractor raises SyntaxError
+# [Bug #21522]
+assert_equal 'SyntaxError', %q{
+ outer = 42
+ r = Ractor.new do
+ eval("outer")
+ end
+ begin
+ r.value
+ rescue Ractor::RemoteError => e
+ e.cause.class
+ end
+}
+
+# eval of an undefined name in a Ractor raises NameError
+assert_equal 'NameError', %q{
+ r = Ractor.new do
+ eval("totally_undefined_name")
+ end
+ begin
+ r.value
+ rescue Ractor::RemoteError => e
+ e.cause.class
+ end
+}
+
+# eval of a local defined inside the Ractor works
+assert_equal '99', %q{
+ Ractor.new { inner = 99; eval("inner").to_s }.value
+}
+
# ivar in shareable-objects are not allowed to access from non-main Ractor
-assert_equal "can not get unshareable values from instance variables of classes/modules from non-main Ractors", %q{
+assert_equal "can not get unshareable values from instance variables of classes/modules from non-main Ractors (@iv from C)", <<~'RUBY', frozen_string_literal: false
class C
@iv = 'str'
end
@@ -957,13 +857,12 @@ assert_equal "can not get unshareable values from instance variables of classes/
end
end
-
begin
- r.take
+ r.value
rescue Ractor::RemoteError => e
e.cause.message
end
-}
+RUBY
# ivar in shareable-objects are not allowed to access from non-main Ractor
assert_equal 'can not access instance variables of shareable objects from non-main Ractors', %q{
@@ -975,7 +874,7 @@ assert_equal 'can not access instance variables of shareable objects from non-ma
end
begin
- r.take
+ r.value
rescue Ractor::RemoteError => e
e.cause.message
end
@@ -1001,7 +900,7 @@ assert_equal 'can not access instance variables of shareable objects from non-ma
end
begin
- r.take
+ r.value
rescue Ractor::RemoteError => e
e.cause.message
end
@@ -1022,7 +921,7 @@ assert_equal 'can not access instance variables of shareable objects from non-ma
end
begin
- r.take
+ r.value
rescue Ractor::RemoteError => e
e.cause.message
end
@@ -1036,7 +935,7 @@ assert_equal '11', %q{
Ractor.new obj do |obj|
obj.instance_variable_get('@a')
- end.take.to_s
+ end.value.to_s
}.join
}
@@ -1062,33 +961,68 @@ assert_equal '333', %q{
def self.fstr = @fstr
end
- a = Ractor.new{ C.int }.take
+ a = Ractor.new{ C.int }.value
b = Ractor.new do
C.str.to_i
rescue Ractor::IsolationError
10
- end.take
+ end.value
c = Ractor.new do
C.fstr.to_i
- end.take
+ end.value
- d = Ractor.new{ M.int }.take
+ d = Ractor.new{ M.int }.value
e = Ractor.new do
M.str.to_i
rescue Ractor::IsolationError
20
- end.take
+ end.value
f = Ractor.new do
M.fstr.to_i
- end.take
+ end.value
# 1 + 10 + 100 + 2 + 20 + 200
a + b + c + d + e + f
}
-# cvar in shareable-objects are not allowed to access from non-main Ractor
-assert_equal 'can not access class variables from non-main Ractors', %q{
+assert_equal '["instance-variable", "instance-variable", nil]', %q{
+ class C
+ @iv1 = ""
+ @iv2 = 42
+ def self.iv1 = defined?(@iv1) # "instance-variable"
+ def self.iv2 = defined?(@iv2) # "instance-variable"
+ def self.iv3 = defined?(@iv3) # nil
+ end
+
+ Ractor.new{
+ [C.iv1, C.iv2, C.iv3]
+ }.value
+}
+
+# moved objects have their shape properly set to original object's shape
+assert_equal '1234', %q{
+ class Obj
+ attr_accessor :a, :b, :c, :d
+ def initialize
+ @a = 1
+ @b = 2
+ @c = 3
+ end
+ end
+ r = Ractor.new do
+ obj = receive
+ obj.d = 4
+ [obj.a, obj.b, obj.c, obj.d]
+ end
+ obj = Obj.new
+ r.send(obj, move: true)
+ values = r.value
+ values.join
+}
+
+# Reading non-shareable cvar from non-main Ractor is not allowed
+assert_equal 'can not read non-shareable class variable @@cv from non-main Ractors (C)', %q{
class C
@@cv = 'str'
end
@@ -1100,14 +1034,14 @@ assert_equal 'can not access class variables from non-main Ractors', %q{
end
begin
- r.take
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
}
-# also cached cvar in shareable-objects are not allowed to access from non-main Ractor
-assert_equal 'can not access class variables from non-main Ractors', %q{
+# also cached non-shareable cvar read from non-main Ractor is not allowed
+assert_equal 'can not read non-shareable class variable @@cv from non-main Ractors (C)', %q{
class C
@@cv = 'str'
def self.cv
@@ -1122,14 +1056,103 @@ assert_equal 'can not access class variables from non-main Ractors', %q{
end
begin
- r.take
+ r.join
+ rescue Ractor::RemoteError => e
+ e.cause.message
+ end
+}
+
+# Reading shareable cvar from non-main Ractor is allowed
+assert_equal 'shareable', %q{
+ class C
+ @@cv = 'shareable'.freeze
+ def self.cv
+ @@cv
+ end
+ end
+
+ Ractor.new { C.cv }.value
+}
+
+# Reading shareable cvar (integer) from non-main Ractor is allowed
+assert_equal '42', %q{
+ class C
+ @@cv = 42
+ def self.cv
+ @@cv
+ end
+ end
+
+ Ractor.new { C.cv }.value.to_s
+}
+
+# Reading shareable cvar via module include from non-main Ractor is allowed
+assert_equal 'hello', %q{
+ module M
+ @@cv = 'hello'.freeze
+ def self.cv
+ @@cv
+ end
+ end
+
+ class C
+ include M
+ def self.cv
+ @@cv
+ end
+ end
+
+ Ractor.new { C.cv }.value
+}
+
+# Writing cvar from non-main Ractor is not allowed
+assert_equal 'can not set class variables from non-main Ractors (@@cv from C)', %q{
+ class C
+ @@cv = 'str'
+ def self.cv=(v)
+ @@cv = v
+ end
+ end
+
+ r = Ractor.new do
+ C.cv = 'new'
+ end
+
+ begin
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
}
+# Reading cvar that was made shareable after initial assignment
+assert_equal 'made shareable', %q{
+ class C
+ @@cv = +'made shareable'
+ Ractor.make_shareable(@@cv)
+ def self.cv
+ @@cv
+ end
+ end
+
+ Ractor.new { C.cv }.value
+}
+
+# cvar_defined? works from non-main Ractor
+assert_equal 'true', %q{
+ class C
+ @@cv = 42
+ def self.cv?
+ defined?(@@cv)
+ end
+ end
+
+ r = Ractor.new { C.cv? ? 'true' : 'false' }
+ r.value
+}
+
# Getting non-shareable objects via constants by other Ractors is not allowed
-assert_equal 'can not access non-shareable objects in constant C::CONST by non-main Ractor.', %q{
+assert_equal 'can not access non-shareable objects in constant C::CONST by non-main Ractor.', <<~'RUBY', frozen_string_literal: false
class C
CONST = 'str'
end
@@ -1137,44 +1160,58 @@ assert_equal 'can not access non-shareable objects in constant C::CONST by non-m
C::CONST
end
begin
- r.take
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
-}
+ RUBY
-# Constant cache should care about non-sharable constants
-assert_equal "can not access non-shareable objects in constant Object::STR by non-main Ractor.", %q{
+# Constant cache should care about non-shareable constants
+assert_equal "can not access non-shareable objects in constant Object::STR by non-main Ractor.", <<~'RUBY', frozen_string_literal: false
STR = "hello"
def str; STR; end
s = str() # fill const cache
begin
- Ractor.new{ str() }.take
+ Ractor.new{ str() }.join
rescue Ractor::RemoteError => e
e.cause.message
end
-}
+RUBY
+
+# The correct constant path shall be reported
+assert_equal "can not access non-shareable objects in constant Object::STR by non-main Ractor.", <<~'RUBY', frozen_string_literal: false
+ STR = "hello"
+ module M
+ def self.str; STR; end
+ end
+
+ begin
+ Ractor.new{ M.str }.join
+ rescue Ractor::RemoteError => e
+ e.cause.message
+ end
+RUBY
# Setting non-shareable objects into constants by other Ractors is not allowed
-assert_equal 'can not set constants with non-shareable objects by non-main Ractors', %q{
+assert_equal 'can not set constants with non-shareable objects by non-main Ractors', <<~'RUBY', frozen_string_literal: false
class C
end
r = Ractor.new do
C::CONST = 'str'
end
begin
- r.take
+ r.join
rescue Ractor::RemoteError => e
e.cause.message
end
-}
+RUBY
# define_method is not allowed
assert_equal "defined with an un-shareable Proc in a different Ractor", %q{
str = "foo"
define_method(:buggy){|i| str << "#{i}"}
begin
- Ractor.new{buggy(10)}.take
+ Ractor.new{buggy(10)}.join
rescue => e
e.cause.message
end
@@ -1185,7 +1222,7 @@ assert_equal '[1000, 3]', %q{
A = Array.new(1000).freeze # [nil, ...]
H = {a: 1, b: 2, c: 3}.freeze
- Ractor.new{ [A.size, H.size] }.take
+ Ractor.new{ [A.size, H.size] }.value
}
# Ractor.count
@@ -1195,15 +1232,15 @@ assert_equal '[1, 4, 3, 2, 1]', %q{
ractors = (1..3).map { Ractor.new { Ractor.receive } }
counts << Ractor.count
- ractors[0].send('End 0').take
+ ractors[0].send('End 0').join
sleep 0.1 until ractors[0].inspect =~ /terminated/
counts << Ractor.count
- ractors[1].send('End 1').take
+ ractors[1].send('End 1').join
sleep 0.1 until ractors[1].inspect =~ /terminated/
counts << Ractor.count
- ractors[2].send('End 2').take
+ ractors[2].send('End 2').join
sleep 0.1 until ractors[2].inspect =~ /terminated/
counts << Ractor.count
@@ -1216,11 +1253,11 @@ assert_equal '0', %q{
n = 0
ObjectSpace.each_object{|o| n += 1 unless Ractor.shareable?(o)}
n
- }.take
+ }.value
}
# ObjectSpace._id2ref can not handle unshareable objects with Ractors
-assert_equal 'ok', %q{
+assert_equal 'ok', <<~'RUBY', frozen_string_literal: false
s = 'hello'
Ractor.new s.object_id do |id ;s|
@@ -1229,11 +1266,29 @@ assert_equal 'ok', %q{
rescue => e
:ok
end
- end.take
-}
+ end.value
+RUBY
+
+# Inserting into the id2ref table should be Ractor-safe
+assert_equal 'ok', <<~'RUBY'
+ # Force all calls to Kernel#object_id to insert into the id2ref table
+ obj = Object.new
+ ObjectSpace._id2ref(obj.object_id) rescue nil
+
+ 10.times.map do
+ Ractor.new do
+ 10_000.times do
+ a = Object.new
+ a.object_id
+ end
+ end
+ end.map(&:value)
+
+ :ok
+RUBY
# Ractor.make_shareable(obj)
-assert_equal 'true', %q{
+assert_equal 'true', <<~'RUBY', frozen_string_literal: false
class C
def initialize
@a = 'foo'
@@ -1304,7 +1359,7 @@ assert_equal 'true', %q{
}
Ractor.shareable?(a)
-}
+RUBY
# Ractor.make_shareable(obj) doesn't freeze shareable objects
assert_equal 'true', %q{
@@ -1313,19 +1368,42 @@ assert_equal 'true', %q{
[a.frozen?, a[0].frozen?] == [true, false]
}
-# Ractor.make_shareable(a_proc) makes a proc shareable.
-assert_equal 'true', %q{
- a = [1, [2, 3], {a: "4"}]
+# Ractor.make_shareable(a_proc) requires a shareable receiver
+assert_equal '[:ok, "Proc\'s self is not shareable:"]', %q{
+ pr1 = nil.instance_exec { Proc.new{} }
+ pr2 = Proc.new{}
- pr = Ractor.current.instance_eval do
- Proc.new do
- a
+ [pr1, pr2].map do |pr|
+ begin
+ Ractor.make_shareable(pr)
+ rescue Ractor::Error => e
+ e.message[/^.+?:/]
+ else
+ :ok
end
end
+}
- Ractor.make_shareable(a) # referred value should be shareable
- Ractor.make_shareable(pr)
- Ractor.shareable?(pr)
+# Ractor.make_shareable(Method/UnboundMethod)
+assert_equal 'true', %q{
+ # raise because receiver is unshareable
+ begin
+ _m0 = Ractor.make_shareable(self.method(:__id__))
+ rescue => e
+ raise e unless e.message =~ /can not make shareable object/
+ else
+ raise "no error"
+ end
+
+ # Method with shareable receiver
+ M1 = Ractor.make_shareable(Object.method(:__id__))
+
+ # UnboundMethod
+ M2 = Ractor.make_shareable(Object.instance_method(:__id__))
+
+ Ractor.new do
+ Object.__id__ == M1.call && M1.call == M2.bind_call(Object)
+ end.value
}
# Ractor.shareable?(recursive_objects)
@@ -1360,29 +1438,10 @@ assert_equal '[C, M]', %q{
assert_equal '1', %q{
class C
a = 1
- define_method "foo", Ractor.make_shareable(Proc.new{ a })
- a = 2
+ define_method "foo", Ractor.shareable_proc{ a }
end
- Ractor.new{ C.new.foo }.take
-}
-
-# Ractor.make_shareable(a_proc) makes a proc shareable.
-assert_equal 'can not make a Proc shareable because it accesses outer variables (a).', %q{
- a = b = nil
- pr = Ractor.current.instance_eval do
- Proc.new do
- c = b # assign to a is okay because c is block local variable
- # reading b is okay
- a = b # assign to a is not allowed #=> Ractor::Error
- end
- end
-
- begin
- Ractor.make_shareable(pr)
- rescue => e
- e.message
- end
+ Ractor.new{ C.new.foo }.value
}
# Ractor.make_shareable(obj, copy: true) makes copied shareable object.
@@ -1401,14 +1460,14 @@ assert_equal '[false, false, true, true]', %q{
}
# TracePoint with normal Proc should be Ractor local
-assert_equal '[4, 8]', %q{
+assert_equal '[6, 10]', %q{
rs = []
TracePoint.new(:line){|tp| rs << tp.lineno if tp.path == __FILE__}.enable do
- Ractor.new{ # line 4
+ Ractor.new{ # line 5
a = 1
b = 2
- }.take
- c = 3 # line 8
+ }.value
+ c = 3 # line 9
end
rs
}
@@ -1417,7 +1476,7 @@ assert_equal '[4, 8]', %q{
assert_equal '[true, false]', %q{
Ractor.new([[]].freeze) { |ary|
[ary.frozen?, ary.first.frozen? ]
- }.take
+ }.value
}
# Ractor deep copies frozen objects (str)
@@ -1425,7 +1484,7 @@ assert_equal '[true, false]', %q{
s = String.new.instance_eval { @x = []; freeze}
Ractor.new(s) { |s|
[s.frozen?, s.instance_variable_get(:@x).frozen?]
- }.take
+ }.value
}
# Can not trap with not isolated Proc on non-main ractor
@@ -1433,33 +1492,85 @@ assert_equal '[:ok, :ok]', %q{
a = []
Ractor.new{
trap(:INT){p :ok}
- }.take
+ }.join
a << :ok
begin
Ractor.new{
s = 'str'
trap(:INT){p s}
- }.take
- rescue => Ractor::RemoteError
+ }.join
+ rescue Ractor::RemoteError
a << :ok
end
}
+# Ractor.select is interruptible
+assert_normal_exit %q{
+ trap(:INT) do
+ exit
+ end
+
+ r = Ractor.new do
+ loop do
+ sleep 1
+ end
+ end
+
+ Thread.new do
+ sleep 0.5
+ Process.kill(:INT, Process.pid)
+ end
+ Ractor.select(r)
+}
+
# Ractor-local storage
assert_equal '[nil, "b", "a"]', %q{
ans = []
Ractor.current[:key] = 'a'
r = Ractor.new{
- Ractor.yield self[:key]
+ Ractor.main << self[:key]
self[:key] = 'b'
self[:key]
}
- ans << r.take
- ans << r.take
+ ans << Ractor.receive
+ ans << r.value
ans << Ractor.current[:key]
}
+assert_equal '1', %q{
+ N = 1_000
+ Ractor.new{
+ a = []
+ 1_000.times.map{|i|
+ Thread.new(i){|i|
+ Thread.pass if i < N
+ a << Ractor.store_if_absent(:i){ i }
+ a << Ractor.current[:i]
+ }
+ }.each(&:join)
+ a.uniq.size
+ }.value
+}
+
+# Ractor-local storage
+assert_equal '2', %q{
+ Ractor.new {
+ fails = 0
+ begin
+ Ractor.main[:key] # cannot get ractor local storage from non-main ractor
+ rescue => e
+ fails += 1 if e.message =~ /Cannot get ractor local/
+ end
+ begin
+ Ractor.main[:key] = 'val'
+ rescue => e
+ fails += 1 if e.message =~ /Cannot set ractor local/
+ end
+ fails
+ }.value
+}
+
###
### Synchronization tests
###
@@ -1473,37 +1584,54 @@ assert_equal "#{N}#{N}", %Q{
Ractor.new{
N.times{|i| -(i.to_s)}
}
- }.map{|r| r.take}.join
+ }.map{|r| r.value}.join
+}
+
+assert_equal "ok", %Q{
+ N = #{N}
+ a, b = 2.times.map{
+ Ractor.new{
+ N.times.map{|i| -(i.to_s)}
+ }
+ }.map{|r| r.value}
+ N.times do |i|
+ unless a[i].equal?(b[i])
+ raise [a[i], b[i]].inspect
+ end
+ unless a[i] == i.to_s
+ raise [i, a[i], b[i]].inspect
+ end
+ end
+ :ok
}
-# Generic ivtbl
+# Generic fields_tbl
n = N/2
assert_equal "#{n}#{n}", %Q{
2.times.map{
Ractor.new do
#{n}.times do
- obj = ''
+ obj = +''
obj.instance_variable_set("@a", 1)
obj.instance_variable_set("@b", 1)
obj.instance_variable_set("@c", 1)
obj.instance_variable_defined?("@a")
end
end
- }.map{|r| r.take}.join
+ }.map{|r| r.value}.join
}
-# NameError
-assert_equal "ok", %q{
+# Now NoMethodError is copyable
+assert_equal "NoMethodError", %q{
obj = "".freeze # NameError refers the receiver indirectly
begin
obj.bar
rescue => err
end
- begin
- Ractor.new{} << err
- rescue TypeError
- 'ok'
- end
+
+ r = Ractor.new{ Ractor.receive }
+ r << err
+ r.value.class
}
assert_equal "ok", %q{
@@ -1521,54 +1649,27 @@ assert_equal "ok", %q{
# Can yield back values while GC is sweeping [Bug #18117]
assert_equal "ok", %q{
+ port = Ractor::Port.new
workers = (0...8).map do
- Ractor.new do
+ Ractor.new port do |port|
loop do
10_000.times.map { Object.new }
- Ractor.yield Time.now
+ port << Time.now
+ Ractor.receive
end
end
end
- 1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) }
+ 100.times {
+ workers.each do
+ port.receive
+ end
+ workers.each do |w|
+ w.send(nil)
+ end
+ }
"ok"
-} unless ENV['RUN_OPTS'] =~ /rjit/ # flaky
-
-assert_equal "ok", %q{
- def foo(*); ->{ super }; end
- begin
- Ractor.make_shareable(foo)
- rescue Ractor::IsolationError
- "ok"
- end
-}
-
-assert_equal "ok", %q{
- def foo(**); ->{ super }; end
- begin
- Ractor.make_shareable(foo)
- rescue Ractor::IsolationError
- "ok"
- end
-}
-
-assert_equal "ok", %q{
- def foo(...); ->{ super }; end
- begin
- Ractor.make_shareable(foo)
- rescue Ractor::IsolationError
- "ok"
- end
-}
-
-assert_equal "ok", %q{
- def foo((x), (y)); ->{ super }; end
- begin
- Ractor.make_shareable(foo([], []))
- rescue Ractor::IsolationError
- "ok"
- end
-}
+} if !yjit_enabled? && ENV['GITHUB_WORKFLOW'] != 'ModGC' # flaky
# check method cache invalidation
assert_equal "ok", %q{
@@ -1633,26 +1734,75 @@ assert_equal 'true', %q{
}
n = CS.inject(1){|r, c| r * c.foo} * LN
- rs.map{|r| r.take} == Array.new(RN){n}
+ rs.map{|r| r.value} == Array.new(RN){n}
+}
+
+# check method cache invalidation
+assert_equal 'true', %q{
+ class Foo
+ def hello = nil
+ end
+
+ r1 = Ractor.new do
+ 1000.times do
+ class Foo
+ def hello = nil
+ end
+ end
+ end
+
+ r2 = Ractor.new do
+ 1000.times do
+ o = Foo.new
+ o.hello
+ end
+ end
+
+ r1.value
+ r2.value
+
+ true
}
# check experimental warning
-assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor is experimental/, %q{
+assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor API is experimental/, %q{
Warning[:experimental] = $VERBOSE = true
STDERR.reopen(STDOUT)
- eval("Ractor.new{}.take", nil, "test_ractor.rb", 1)
+ eval("Ractor.new{}.value", nil, "test_ractor.rb", 1)
+}, frozen_string_literal: false
+
+# check moved object
+assert_equal 'ok', %q{
+ r = Ractor.new do
+ Ractor.receive
+ GC.start
+ :ok
+ end
+
+ obj = begin
+ raise
+ rescue => e
+ e = Marshal.load(Marshal.dump(e))
+ end
+
+ r.send obj, move: true
+ r.value
}
## Ractor::Selector
# Selector#empty? returns true
assert_equal 'true', %q{
+ skip true unless defined? Ractor::Selector
+
s = Ractor::Selector.new
s.empty?
}
# Selector#empty? returns false if there is target ractors
assert_equal 'false', %q{
+ skip false unless defined? Ractor::Selector
+
s = Ractor::Selector.new
s.add Ractor.new{}
s.empty?
@@ -1660,6 +1810,8 @@ assert_equal 'false', %q{
# Selector#clear removes all ractors from the waiting list
assert_equal 'true', %q{
+ skip true unless defined? Ractor::Selector
+
s = Ractor::Selector.new
s.add Ractor.new{10}
s.add Ractor.new{20}
@@ -1669,6 +1821,8 @@ assert_equal 'true', %q{
# Selector#wait can wait multiple ractors
assert_equal '[10, 20, true]', %q{
+ skip [10, 20, true] unless defined? Ractor::Selector
+
s = Ractor::Selector.new
s.add Ractor.new{10}
s.add Ractor.new{20}
@@ -1678,10 +1832,12 @@ assert_equal '[10, 20, true]', %q{
r, v = s.wait
vs << v
[*vs.sort, s.empty?]
-}
+} if defined? Ractor::Selector
# Selector#wait can wait multiple ractors with receiving.
assert_equal '30', %q{
+ skip 30 unless defined? Ractor::Selector
+
RN = 30
rs = RN.times.map{
Ractor.new{ :v }
@@ -1698,17 +1854,19 @@ assert_equal '30', %q{
end
results.size
-}
+} if defined? Ractor::Selector
# Selector#wait can support dynamic addition
-yjit_enabled = ENV.key?('RUBY_YJIT_ENABLE') || ENV.fetch('RUN_OPTS', '').include?('yjit') || BT.ruby.include?('yjit')
assert_equal '600', %q{
+ skip 600 unless defined? Ractor::Selector
+
RN = 100
s = Ractor::Selector.new
+ port = Ractor::Port.new
rs = RN.times.map{
Ractor.new{
- Ractor.main << Ractor.new{ Ractor.yield :v3; :v4 }
- Ractor.main << Ractor.new{ Ractor.yield :v5; :v6 }
+ Ractor.main << Ractor.new(port){|port| port << :v3; :v4 }
+ Ractor.main << Ractor.new(port){|port| port << :v5; :v6 }
Ractor.yield :v1
:v2
}
@@ -1728,10 +1886,12 @@ assert_equal '600', %q{
end
h.sum{|k, v| v}
-} unless yjit_enabled # http://ci.rvm.jp/results/trunk-yjit@ruby-sp2-docker/4466770
+} unless yjit_enabled? # http://ci.rvm.jp/results/trunk-yjit@ruby-sp2-docker/4466770
-# Selector should be GCed (free'ed) withtou trouble
+# Selector should be GCed (free'ed) without trouble
assert_equal 'ok', %q{
+ skip :ok unless defined? Ractor::Selector
+
RN = 30
rs = RN.times.map{
Ractor.new{ :v }
@@ -1741,3 +1901,766 @@ assert_equal 'ok', %q{
}
end # if !ENV['GITHUB_WORKFLOW']
+
+# Chilled strings are not shareable
+assert_equal 'false', %q{
+ Ractor.shareable?("chilled")
+}
+
+# Chilled strings can be made shareable
+assert_equal 'true', %q{
+ shareable = Ractor.make_shareable("chilled")
+ shareable == "chilled" && Ractor.shareable?(shareable)
+}
+
+# require in Ractor
+assert_equal 'true', %q{
+ Module.new do
+ def require feature
+ return Ractor._require(feature) unless Ractor.main?
+ super
+ end
+ Object.prepend self
+ set_temporary_name 'Ractor#require'
+ end
+
+ Ractor.new{
+ begin
+ require 'tempfile'
+ Tempfile.new
+ rescue SystemStackError
+ # prism parser with -O0 build consumes a lot of machine stack
+ Data.define(:fileno).new(1)
+ end
+ }.value.fileno > 0
+}
+
+# require_relative in Ractor
+assert_equal 'true', %q{
+ dummyfile = File.join(__dir__, "dummy#{rand}.rb")
+ return true if File.exist?(dummyfile)
+
+ begin
+ File.write dummyfile, ''
+ rescue Exception
+ # skip on any errors
+ return true
+ end
+
+ begin
+ Ractor.new dummyfile do |f|
+ require_relative File.basename(f)
+ end.value
+ ensure
+ File.unlink dummyfile
+ end
+}
+
+# require_relative in Ractor
+assert_equal 'LoadError', %q{
+ dummyfile = File.join(__dir__, "not_existed_dummy#{rand}.rb")
+ return true if File.exist?(dummyfile)
+
+ Ractor.new dummyfile do |f|
+ begin
+ require_relative File.basename(f)
+ rescue LoadError => e
+ e.class
+ end
+ end.value
+}
+
+# autolaod in Ractor
+assert_equal 'true', %q{
+ autoload :Tempfile, 'tempfile'
+
+ r = Ractor.new do
+ begin
+ Tempfile.new
+ rescue SystemStackError
+ # prism parser with -O0 build consumes a lot of machine stack
+ Data.define(:fileno).new(1)
+ end
+ end
+ r.value.fileno > 0
+}
+
+# failed in autolaod in Ractor
+assert_equal 'LoadError', %q{
+ dummyfile = File.join(__dir__, "not_existed_dummy#{rand}.rb")
+ autoload :Tempfile, dummyfile
+
+ r = Ractor.new do
+ begin
+ Tempfile.new
+ rescue LoadError => e
+ e.class
+ end
+ end
+ r.value
+}
+
+# bind_call in Ractor [Bug #20934]
+assert_equal 'ok', %q{
+ 2.times.map do
+ Ractor.new do
+ 1000.times do
+ Object.instance_method(:itself).bind_call(self)
+ end
+ end
+ end.each(&:join)
+ GC.start
+ :ok.itself
+}
+
+# moved objects being corrupted if embeded (String)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = "foobarbazfoobarbazfoobarbazfoobarbaz"
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved objects being corrupted if embeded (Array)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved objects being corrupted if embeded (Hash)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = { foo: 1, bar: 2 }
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved objects being corrupted if embeded (MatchData)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = "foo".match(/o/)
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved objects being corrupted if embeded (Struct)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Struct.new(:a, :b, :c, :d, :e, :f).new(1, 2, 3, 4, 5, 6)
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved objects being corrupted if embeded (Object)
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ class SomeObject
+ attr_reader :a, :b, :c, :d, :e, :f
+ def initialize
+ @a = @b = @c = @d = @e = @f = 1
+ end
+
+ def ==(o)
+ @a == o.a &&
+ @b == o.b &&
+ @c == o.c &&
+ @d == o.d &&
+ @e == o.e &&
+ @f == o.f
+ end
+ end
+
+ SomeObject.new # initial non-embeded
+
+ obj = SomeObject.new
+ ractor.send(obj.dup, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj == obj ? :ok : roundtripped_obj
+}
+
+# moved arrays can't be used
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = [1]
+ ractor.send(obj, move: true)
+ begin
+ [].concat(obj)
+ rescue TypeError
+ :ok
+ else
+ :fail
+ end
+}
+
+# moved strings can't be used
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = "hello"
+ ractor.send(obj, move: true)
+ begin
+ "".replace(obj)
+ rescue TypeError
+ :ok
+ else
+ :fail
+ end
+}
+
+# moved hashes can't be used
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = { a: 1 }
+ ractor.send(obj, move: true)
+ begin
+ {}.merge(obj)
+ rescue TypeError
+ :ok
+ else
+ :fail
+ end
+}
+
+# move objects inside frozen containers
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ original = obj.dup
+ ractor.send([obj].freeze, move: true)
+ roundtripped_obj = ractor.value[0]
+ roundtripped_obj == original ? :ok : roundtripped_obj
+}
+
+# move object with generic ivar
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ obj.instance_variable_set(:@array, [1])
+
+ ractor.send(obj, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj.instance_variable_get(:@array) == [1] ? :ok : roundtripped_obj
+}
+
+# move object with many generic ivars
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ 0.upto(300) do |i|
+ obj.instance_variable_set(:"@array#{i}", [i])
+ end
+
+ ractor.send(obj, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj.instance_variable_get(:@array1) == [1] ? :ok : roundtripped_obj
+}
+
+# move object with complex generic ivars
+assert_equal 'ok', %q{
+ # Make Array complex
+ 30.times { |i| [].instance_variable_set(:"@complex#{i}", 1) }
+
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ obj.instance_variable_set(:@array1, [1])
+
+ ractor.send(obj, move: true)
+ roundtripped_obj = ractor.value
+ roundtripped_obj.instance_variable_get(:@array1) == [1] ? :ok : roundtripped_obj
+}
+
+# move object with generic ivars and existing id2ref table
+# [Bug #21664]
+assert_equal 'ok', %q{
+ obj = [1]
+ obj.instance_variable_set("@field", :ok)
+ ObjectSpace._id2ref(obj.object_id) # build id2ref table
+
+ ractor = Ractor.new { Ractor.receive }
+ ractor.send(obj, move: true)
+ obj = ractor.value
+ obj.instance_variable_get("@field")
+}
+
+# copy object with complex generic ivars
+assert_equal 'ok', %q{
+ # Make Array complex
+ 30.times { |i| [].instance_variable_set(:"@complex#{i}", 1) }
+
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ obj.instance_variable_set(:@array1, [1])
+
+ ractor.send(obj)
+ roundtripped_obj = ractor.value
+ roundtripped_obj.instance_variable_get(:@array1) == [1] ? :ok : roundtripped_obj
+}
+
+# copy object with many generic ivars
+assert_equal 'ok', %q{
+ ractor = Ractor.new { Ractor.receive }
+ obj = Array.new(10, 42)
+ 0.upto(300) do |i|
+ obj.instance_variable_set(:"@array#{i}", [i])
+ end
+
+ ractor.send(obj)
+ roundtripped_obj = ractor.value
+ roundtripped_obj.instance_variable_get(:@array1) == [1] ? :ok : roundtripped_obj
+}
+
+# moved composite types move their non-shareable parts properly
+assert_equal 'ok', %q{
+ k, v = String.new("key"), String.new("value")
+ h = { k => v }
+ h.instance_variable_set("@b", String.new("b"))
+ a = [k,v]
+ o_singleton = Object.new
+ def o_singleton.a
+ @a
+ end
+ o_singleton.instance_variable_set("@a", String.new("a"))
+ class MyObject
+ attr_reader :a
+ def initialize(a)
+ @a = a
+ end
+ end
+ struct_class = Struct.new(:a)
+ struct = struct_class.new(String.new('a'))
+ o = MyObject.new(String.new('a'))
+ port = Ractor::Port.new
+
+ r = Ractor.new port do |port|
+ loop do
+ obj = Ractor.receive
+ val = case obj
+ when Hash
+ obj['key'] == 'value' && obj.instance_variable_get("@b") == 'b'
+ when Array
+ obj[0] == 'key'
+ when Struct
+ obj.a == 'a'
+ when Object
+ obj.a == 'a'
+ end
+ port << val
+ end
+ end
+
+ objs = [h, a, o_singleton, o, struct]
+ objs.each_with_index do |obj, i|
+ klass = obj.class
+ parts_moved = {}
+ case obj
+ when Hash
+ parts_moved[klass] = [obj['key'], obj.instance_variable_get("@b")]
+ when Array
+ parts_moved[klass] = obj.dup # the contents
+ when Struct, Object
+ parts_moved[klass] = [obj.a]
+ end
+ r.send(obj, move: true)
+ val = port.receive
+ if val != true
+ raise "bad val in ractor for obj at i:#{i}"
+ end
+ begin
+ p obj
+ rescue
+ else
+ raise "should be moved"
+ end
+ parts_moved.each do |klass, parts|
+ parts.each_with_index do |part, j|
+ case part
+ when Ractor::MovedObject
+ else
+ raise "part for class #{klass} at i:#{j} should be moved"
+ end
+ end
+ end
+ end
+ 'ok'
+}
+
+# fork after creating Ractor
+assert_equal 'ok', %q{
+begin
+ Ractor.new { Ractor.receive }
+ _, status = Process.waitpid2 fork { }
+ status.success? ? "ok" : status
+rescue NotImplementedError
+ :ok
+end
+}
+
+# Ractors should be terminated after fork
+assert_equal 'ok', %q{
+begin
+ r = Ractor.new { Ractor.receive }
+ _, status = Process.waitpid2 fork {
+ begin
+ raise if r.value != nil
+ end
+ }
+ r.send(123)
+ raise unless r.value == 123
+ status.success? ? "ok" : status
+rescue NotImplementedError
+ :ok
+end
+}
+
+# Ractors should be terminated after fork
+assert_equal 'ok', %q{
+begin
+ r = Ractor.new { Ractor.receive }
+ _, status = Process.waitpid2 fork {
+ begin
+ r.send(123)
+ rescue Ractor::ClosedError
+ end
+ }
+ r.send(123)
+ raise unless r.value == 123
+ status.success? ? "ok" : status
+rescue NotImplementedError
+ :ok
+end
+}
+
+# Creating classes inside of Ractors
+# [Bug #18119]
+assert_equal 'ok', %q{
+ port = Ractor::Port.new
+ workers = (0...8).map do
+ Ractor.new port do |port|
+ loop do
+ 100.times.map { Class.new }
+ port << nil
+ end
+ end
+ end
+
+ 100.times { port.receive }
+
+ 'ok'
+}
+
+# Using Symbol#to_proc inside ractors
+# [Bug #21354]
+assert_equal 'ok', %q{
+ :inspect.to_proc
+ Ractor.new do
+ # It should not use this cached proc, it should create a new one. If it used
+ # the cached proc, we would get a ractor_confirm_belonging error here.
+ :inspect.to_proc
+ end.join
+ 'ok'
+}
+
+# take vm lock when deleting generic ivars from the global table
+assert_equal 'ok', %q{
+ Ractor.new do
+ a = [1, 2, 3]
+ a.object_id
+ a.dup # this deletes generic ivar on dupped object
+ 'ok'
+ end.value
+}
+
+## Ractor#monitor
+
+# monitor port returns `:exited` when the monitering Ractor terminated.
+assert_equal 'true', %q{
+ r = Ractor.new do
+ Ractor.main << :ok1
+ :ok2
+ end
+
+ r.monitor port = Ractor::Port.new
+ Ractor.receive # :ok1
+ port.receive == :exited
+}
+
+# monitor port returns `:exited` even if the monitoring Ractor was terminated.
+assert_equal 'true', %q{
+ r = Ractor.new do
+ :ok
+ end
+
+ r.join # wait for r's terminateion
+
+ r.monitor port = Ractor::Port.new
+ port.receive == :exited
+}
+
+# monitor returns false if the monitoring Ractor was terminated.
+assert_equal 'false', %q{
+ r = Ractor.new do
+ :ok
+ end
+
+ r.join # wait for r's terminateion
+
+ r.monitor Ractor::Port.new
+}
+
+# monitor port returns `:aborted` when the monitering Ractor is aborted.
+assert_equal 'true', %q{
+ r = Ractor.new do
+ Ractor.main << :ok1
+ raise 'ok'
+ end
+
+ r.monitor port = Ractor::Port.new
+ Ractor.receive # :ok1
+ port.receive == :aborted
+}
+
+# monitor port returns `:aborted` even if the monitoring Ractor was aborted.
+assert_equal 'true', %q{
+ r = Ractor.new do
+ raise 'ok'
+ end
+
+ begin
+ r.join # wait for r's terminateion
+ rescue Ractor::RemoteError
+ # ignore
+ end
+
+ r.monitor port = Ractor::Port.new
+ port.receive == :aborted
+}
+
+## Ractor#join
+
+# Ractor#join returns self when the Ractor is terminated.
+assert_equal 'true', %q{
+ r = Ractor.new do
+ Ractor.receive
+ end
+
+ r << :ok
+ r.join
+ r.inspect in /terminated/
+} if false # TODO
+
+# Ractor#join raises RemoteError when the remote Ractor aborted with an exception
+assert_equal 'err', %q{
+ r = Ractor.new do
+ raise 'err'
+ end
+
+ begin
+ r.join
+ rescue Ractor::RemoteError => e
+ e.cause.message
+ end
+}
+
+## Ractor#value
+
+# Ractor#value returns the last expression even if it is unshareable
+assert_equal 'true', %q{
+ r = Ractor.new do
+ obj = [1, 2]
+ obj << obj.object_id
+ end
+
+ ret = r.value
+ ret == [1, 2, ret.object_id]
+}
+
+# Only one Ractor can call Ractor#value
+assert_equal '[["Only the successor ractor can take a value", 9], ["ok", 2]]', %q{
+ r = Ractor.new do
+ 'ok'
+ end
+
+ RN = 10
+
+ rs = RN.times.map do
+ Ractor.new r do |r|
+ begin
+ Ractor.main << r.value
+ Ractor.main << r.value # this ractor can get same result
+ rescue Ractor::Error => e
+ Ractor.main << e.message
+ end
+ end
+ end
+
+ (RN+1).times.map{
+ Ractor.receive
+ }.tally.sort
+}
+
+# Cause lots of inline CC misses.
+assert_equal 'ok', <<~'RUBY'
+ class A; def test; 1 + 1; end; end
+ class B; def test; 1 + 1; end; end
+ class C; def test; 1 + 1; end; end
+ class D; def test; 1 + 1; end; end
+ class E; def test; 1 + 1; end; end
+ class F; def test; 1 + 1; end; end
+ class G; def test; 1 + 1; end; end
+
+ objs = [A.new, B.new, C.new, D.new, E.new, F.new, G.new].freeze
+
+ def call_test(obj)
+ obj.test
+ end
+
+ ractors = 7.times.map do
+ Ractor.new(objs) do |objs|
+ objs = objs.shuffle
+ 100_000.times do
+ objs.each do |o|
+ call_test(o)
+ end
+ end
+ end
+ end
+ ractors.each(&:join)
+ :ok
+RUBY
+
+# This test checks that we do not trigger a GC when we have malloc with Ractor
+# locks. We cannot trigger a GC with Ractor locks because GC requires VM lock
+# and Ractor barrier. If another Ractor is waiting on this Ractor lock, then it
+# will deadlock because the other Ractor will never join the barrier.
+#
+# Creating Ractor::Port requires locking the Ractor and inserting into an
+# st_table, which can call malloc.
+assert_equal 'ok', <<~'RUBY'
+ r = Ractor.new do
+ loop do
+ Ractor::Port.new
+ end
+ end
+
+ 10.times do
+ 10_000.times do
+ r.send(nil)
+ end
+ sleep(0.01)
+ end
+ :ok
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+ begin
+ 100.times do |i|
+ Ractor.new(i) do |j|
+ 1000.times do |i|
+ "#{j}-#{i}"
+ end
+ Ractor.receive
+ end
+ pid = fork { }
+ _, status = Process.waitpid2 pid
+ raise unless status.success?
+ end
+
+ :ok
+ rescue NotImplementedError
+ :ok
+ end
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+ begin
+ 100.times do |i|
+ Ractor.new(i) do |j|
+ 1000.times do |i|
+ "#{j}-#{i}"
+ end
+ end
+ pid = fork do
+ GC.verify_internal_consistency
+ end
+ _, status = Process.waitpid2 pid
+ raise unless status.success?
+ end
+
+ :ok
+ rescue NotImplementedError
+ :ok
+ end
+RUBY
+
+# When creating bmethods in Ractors, they should only be usable from their
+# defining ractor, even if it is GC'd
+assert_equal 'ok', <<~'RUBY'
+
+begin
+ CLASSES = 1000.times.map { Class.new }.freeze
+
+ # This would be better to run in parallel, but there's a bug with lambda
+ # creation and YJIT causing crashes in dev mode
+ ractors = CLASSES.map do |klass|
+ Ractor.new(klass) do |klass|
+ Ractor.receive
+ klass.define_method(:foo) {}
+ end
+ end
+
+ ractors.each do |ractor|
+ ractor << nil
+ ractor.join
+ end
+
+ ractors.clear
+ GC.start
+
+ any = 1000.times.map do
+ Ractor.new do
+ CLASSES.any? do |klass|
+ begin
+ klass.new.foo
+ true
+ rescue RuntimeError
+ false
+ end
+ end
+ end
+ end.map(&:value).none? && :ok
+rescue ThreadError => e
+ # ignore limited memory machine
+ if /can\'t create Thread/ =~ e.message
+ :ok
+ else
+ raise
+ end
+end
+RUBY
+
+# Concurrent super calls with keyword arguments must not race on the
+# callinfo kwarg reference count. [Bug #22075]
+assert_equal 'ok', %q{
+ class Base
+ def foo(a:, b:, c:) = a
+ end
+
+ class Sub < Base
+ def foo(a:, b:, c:) = super(a: a, b: b, c: c)
+ end
+
+ 4.times.map do
+ Ractor.new do
+ obj = Sub.new
+ 100_000.times { obj.foo(a: 1, b: 2, c: 3) }
+ end
+ end.each(&:join)
+
+ :ok
+}
diff --git a/bootstraptest/test_rjit.rb b/bootstraptest/test_rjit.rb
deleted file mode 100644
index c00c742318..0000000000
--- a/bootstraptest/test_rjit.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-assert_equal 'true', %q{
- def nil_nil = nil == nil
- nil_nil
-}
-
-assert_equal 'true', %q{
- def lt(a, b) = a < b
- lt(1, 2)
- lt('a', 'b')
-}
-
-assert_equal '3', %q{
- def foo = 2
- def bar = 1 + foo + nil.to_i
- bar
-}
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index 948e2d7809..29bf93cb8f 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -528,24 +528,24 @@ assert_equal %q{1}, %q{
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
+ assert_match /^#{Regexp.escape(expected)}/,
+ "begin eval(%q{#{code}}, nil, '', 0)"'; rescue SyntaxError => e; e.message[/(?:\^~*|\A:(?:\d+:)?(?! syntax errors? found)(?: syntax error,)?) (.*)/, 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 *, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
-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_syntax_error "unexpected *, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
+assert_syntax_error "'@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
+assert_syntax_error "'$00' is not allowed as a global variable name", %q{$00..0}, '[ruby-dev:31100]'
+assert_syntax_error "'$00' is not allowed as a global variable name", %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_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_valid_syntax %q{1.times{1+(1&&next)}}, '[ruby-dev:31119]'
assert_valid_syntax %q{x=-1;loop{x+=1&&redo if (x+=1).zero?}}, '[ruby-dev:31119]'
-assert_syntax_error %q{syntax error, unexpected end-of-input}, %q{!}, '[ruby-dev:31243]'
+assert_syntax_error %q{unexpected end-of-input}, %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]'
@@ -571,7 +571,7 @@ assert_equal 'ok', %q{
assert_equal 'ok', %q{
1.times{
- p(1, (next; 2))
+ p(1, (next if true; 2))
}; :ok
}
assert_equal '3', %q{
@@ -585,7 +585,7 @@ assert_equal '3', %q{
i = 0
1 + (while true
break 2 if (i+=1) > 1
- p(1, (next; 2))
+ p(1, (next if true; 2))
end)
}
# redo
@@ -594,7 +594,7 @@ assert_equal 'ok', %q{
1.times{
break if i>1
i+=1
- p(1, (redo; 2))
+ p(1, (redo if true; 2))
}; :ok
}
assert_equal '3', %q{
@@ -608,7 +608,7 @@ assert_equal '3', %q{
i = 0
1 + (while true
break 2 if (i+=1) > 1
- p(1, (redo; 2))
+ p(1, (redo if true; 2))
end)
}
assert_equal '1', %q{
@@ -629,7 +629,7 @@ assert_equal '2', %q{
assert_match /invalid multibyte char/, %q{
$stderr = STDOUT
- eval("\"\xf0".force_encoding("utf-8"))
+ eval("\"\xf0".dup.force_encoding("utf-8"))
}, '[ruby-dev:32429]'
# method ! and !=
@@ -904,3 +904,35 @@ assert_normal_exit %q{
Class
end
}, '[ruby-core:30293]'
+
+assert_equal "false", <<~RUBY, "literal strings are mutable", "--disable-frozen-string-literal"
+ 'test'.frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "literal strings are frozen", "--disable-frozen-string-literal", frozen_string_literal: true
+ 'test'.frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "literal strings are frozen", "--enable-frozen-string-literal"
+ 'test'.frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "literal strings are mutable", "--enable-frozen-string-literal", frozen_string_literal: false
+ 'test'.frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "__FILE__ is mutable", "--disable-frozen-string-literal"
+ __FILE__.frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "__FILE__ is frozen", "--disable-frozen-string-literal", frozen_string_literal: true
+ __FILE__.frozen?
+RUBY
+
+assert_equal "true", <<~RUBY, "__FILE__ is frozen", "--enable-frozen-string-literal"
+ __FILE__.frozen?
+RUBY
+
+assert_equal "false", <<~RUBY, "__FILE__ is mutable", "--enable-frozen-string-literal", frozen_string_literal: false
+ __FILE__.frozen?
+RUBY
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
index d7d19e97c9..7ff5bb4a38 100644
--- a/bootstraptest/test_thread.rb
+++ b/bootstraptest/test_thread.rb
@@ -242,9 +242,22 @@ assert_equal 'true', %{
end
}
+assert_equal 'true', %{
+ Thread.new{}.join
+ begin
+ Process.waitpid2 fork{
+ Thread.new{
+ sleep 0.1
+ }.join
+ }
+ true
+ rescue NotImplementedError
+ true
+ end
+}
+
assert_equal 'ok', %{
- open("zzz_t1.rb", "w") do |f|
- f.puts <<-END
+ File.write("zzz_t1.rb", <<-END)
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
@@ -253,7 +266,6 @@ assert_equal 'ok', %{
$result = :ok
end
END
- end
require "./zzz_t1.rb"
$result
}
@@ -408,8 +420,7 @@ assert_equal 'ok', %q{
}
assert_equal 'ok', %{
- open("zzz_t2.rb", "w") do |f|
- f.puts <<-'end;' # do
+ File.write("zzz_t2.rb", <<-'end;') # do
begin
m = Thread::Mutex.new
parent = Thread.current
@@ -431,7 +442,6 @@ assert_equal 'ok', %{
$result = :ok
end
end;
- end
require "./zzz_t2.rb"
$result
}
@@ -483,7 +493,8 @@ assert_equal 'foo', %q{
[th1, th2].each {|t| t.join }
GC.start
f.call.source
-} unless ENV['RUN_OPTS'] =~ /rjit/ # flaky
+}
+
assert_normal_exit %q{
class C
def inspect
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 8902cd6cde..e9ce905e2c 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1,3 +1,318 @@
+# To run the tests in this file only, with YJIT enabled:
+# make btest BTESTS=bootstraptest/test_yjit.rb RUN_OPTS="--yjit-call-threshold=1"
+
+# regression test for popping before side exit
+assert_equal "ok", %q{
+ def foo(a, *) = a
+
+ def call(args, &)
+ foo(1) # spill at where the block arg will be
+ foo(*args, &)
+ end
+
+ call([1, 2])
+
+ begin
+ call([])
+ rescue ArgumentError
+ :ok
+ end
+}
+
+# regression test for send processing before side exit
+assert_equal "ok", %q{
+ def foo(a, *) = :foo
+
+ def call(args)
+ send(:foo, *args)
+ end
+
+ call([1, 2])
+
+ begin
+ call([])
+ rescue ArgumentError
+ :ok
+ end
+}
+
+# test discarding extra yield arguments
+assert_equal "22131300500015901015", %q{
+ def splat_kw(ary) = yield *ary, a: 1
+
+ def splat(ary) = yield *ary
+
+ def kw = yield 1, 2, a: 3
+
+ def kw_only = yield a: 0
+
+ def simple = yield 0, 1
+
+ def none = yield
+
+ def calls
+ [
+ splat([1, 1, 2]) { |x, y| x + y },
+ splat([1, 1, 2]) { |y, opt = raise| opt + y},
+ splat_kw([0, 1]) { |a:| a },
+ kw { |a:| a },
+ kw { |one| one },
+ kw { |one, a:| a },
+ kw_only { |a:| a },
+ kw_only { |a: 1| a },
+ simple { 5.itself },
+ simple { |a| a },
+ simple { |opt = raise| opt },
+ simple { |*rest| rest },
+ simple { |opt_kw: 5| opt_kw },
+ none { |a: 9| a },
+ # autosplat ineractions
+ [0, 1, 2].yield_self { |a, b| [a, b] },
+ [0, 1, 2].yield_self { |a, opt = raise| [a, opt] },
+ [1].yield_self { |a, opt = 4| a + opt },
+ ]
+ end
+
+ calls.join
+}
+
+# test autosplat with empty splat
+assert_equal "ok", %q{
+ def m(pos, splat) = yield pos, *splat
+
+ m([:ok], []) {|v0,| v0 }
+}
+
+# regression test for send stack shifting
+assert_normal_exit %q{
+ def foo(a, b)
+ a.singleton_methods(b)
+ end
+
+ def call_foo
+ [1, 1, 1, 1, 1, 1, send(:foo, 1, 1)]
+ end
+
+ call_foo
+}
+
+# regression test for keyword splat with yield
+assert_equal 'nil', %q{
+ def splat_kw(kwargs) = yield(**kwargs)
+
+ splat_kw({}) { _1 }.inspect
+}
+
+# regression test for arity check with splat
+assert_equal '[:ae, :ae]', %q{
+ def req_one(a_, b_ = 1) = raise
+
+ def test(args)
+ req_one *args
+ rescue ArgumentError
+ :ae
+ end
+
+ [test(Array.new 5), test([])]
+}
+
+# regression test for arity check with splat and send
+assert_equal '[:ae, :ae]', %q{
+ def two_reqs(a, b_, _ = 1) = a.gsub(a, a)
+
+ def test(name, args)
+ send(name, *args)
+ rescue ArgumentError
+ :ae
+ end
+
+ [test(:two_reqs, ["g", nil, nil, nil]), test(:two_reqs, ["g"])]
+}
+
+# regression test for GC marking stubs in invalidated code
+assert_normal_exit %q{
+ skip true unless GC.respond_to?(:compact)
+ garbage = Array.new(10_000) { [] } # create garbage to cause iseq movement
+ eval(<<~RUBY)
+ def foo(n, garbage)
+ if n == 2
+ # 1.times.each to create a cfunc frame to preserve the JIT frame
+ # which will return to a stub housed in an invalidated block
+ return 1.times.each do
+ Object.define_method(:foo) {}
+ garbage.clear
+ GC.verify_compaction_references(toward: :empty, expand_heap: true)
+ end
+ end
+
+ foo(n + 1, garbage)
+ end
+ RUBY
+
+ foo(1, garbage)
+}
+
+# regression test for callee block handler overlapping with arguments
+assert_equal '3', %q{
+ def foo(_req, *args) = args.last
+
+ def call_foo = foo(0, 1, 2, 3, &->{})
+
+ call_foo
+}
+
+# call leaf builtin with a block argument
+assert_equal '0', "0.abs(&nil)"
+
+# regression test for invokeblock iseq guard
+assert_equal 'ok', %q{
+ skip :ok unless GC.respond_to?(:compact)
+ def foo = yield
+ 10.times do |i|
+ ret = eval("foo { #{i} }")
+ raise "failed at #{i}" unless ret == i
+ GC.compact
+ end
+ :ok
+}
+
+# regression test for overly generous guard elision
+assert_equal '[0, :sum, 0, :sum]', %q{
+ # In faulty versions, the following happens:
+ # 1. YJIT puts object on the temp stack with type knowledge
+ # (CArray or CString) about RBASIC_CLASS(object).
+ # 2. In iter=0, due to the type knowledge, YJIT generates
+ # a call to sum() without any guard on RBASIC_CLASS(object).
+ # 3. In iter=1, a singleton class is added to the object,
+ # changing RBASIC_CLASS(object), falsifying the type knowledge.
+ # 4. Because the code from (1) has no class guard, it is incorrectly
+ # reused and the wrong method is invoked.
+ # Putting a literal is important for gaining type knowledge.
+ def carray(iter)
+ array = []
+ array.sum(iter.times { def array.sum(_) = :sum })
+ end
+
+ def cstring(iter)
+ string = "".dup
+ string.sum(iter.times { def string.sum(_) = :sum })
+ end
+
+ [carray(0), carray(1), cstring(0), cstring(1)]
+}
+
+# regression test for return type of Integer#/
+# It can return a T_BIGNUM when inputs are T_FIXNUM.
+assert_equal 0x3fffffffffffffff.to_s, %q{
+ def call(fixnum_min)
+ (fixnum_min / -1) - 1
+ end
+
+ call(-(2**62))
+}
+
+# regression test for return type of String#<<
+assert_equal 'Sub', %q{
+ def call(sub) = (sub << sub).itself
+
+ class Sub < String; end
+
+ call(Sub.new('o')).class
+}
+
+# String#dup with generic ivars
+assert_equal '["str", "ivar"]', %q{
+ def str_dup(str) = str.dup
+ str = "str"
+ str.instance_variable_set(:@ivar, "ivar")
+ str = str_dup(str)
+ [str, str.instance_variable_get(:@ivar)]
+}
+
+# test splat filling required and feeding rest
+assert_equal '[0, 1, 2, [3, 4]]', %q{
+ public def lead_rest(a, b, *rest)
+ [self, a, b, rest]
+ end
+
+ def call(args) = 0.lead_rest(*args)
+
+ call([1, 2, 3, 4])
+}
+
+# test missing opts are nil initialized
+assert_equal '[[0, 1, nil, 3], [0, 1, nil, 3], [0, 1, nil, 3, []], [0, 1, nil, 3, []]]', %q{
+ public def lead_opts(a, b=binding.local_variable_get(:c), c=3)
+ [self, a, b, c]
+ end
+
+ public def opts_rest(a=raise, b=binding.local_variable_get(:c), c=3, *rest)
+ [self, a, b, c, rest]
+ end
+
+ def call(args)
+ [
+ 0.lead_opts(1),
+ 0.lead_opts(*args),
+
+ 0.opts_rest(1),
+ 0.opts_rest(*args),
+ ]
+ end
+
+ call([1])
+}
+
+# test filled optionals with unspecified keyword param
+assert_equal 'ok', %q{
+ def opt_rest_opt_kw(_=1, *, k: :ok) = k
+
+ def call = opt_rest_opt_kw(0)
+
+ call
+}
+
+# test splat empty array with rest param
+assert_equal '[0, 1, 2, []]', %q{
+ public def foo(a=1, b=2, *rest)
+ [self, a, b, rest]
+ end
+
+ def call(args) = 0.foo(*args)
+
+ call([])
+}
+
+# Regression test for yielding with autosplat to block with
+# optional parameters. https://github.com/Shopify/yjit/issues/313
+assert_equal '[:a, :b, :a, :b]', %q{
+ def yielder(arg) = yield(arg) + yield(arg)
+
+ yielder([:a, :b]) do |c = :c, d = :d|
+ [c, d]
+ end
+}
+
+# Regression test for GC mishap while doing shape transition
+assert_equal '[:ok]', %q{
+ # [Bug #19601]
+ class RegressionTest
+ def initialize
+ @a = @b = @fourth_ivar_does_shape_transition = nil
+ end
+
+ def extender
+ @first_extended_ivar = [:ok]
+ end
+ end
+
+ GC.stress = true
+
+ # Used to crash due to GC run in rb_ensure_iv_list_size()
+ # not marking the newly allocated [:ok].
+ RegressionTest.new.extender.itself
+}
+
assert_equal 'true', %q{
# regression test for tracking type of locals for too long
def local_setting_cmp(five)
@@ -46,7 +361,7 @@ assert_normal_exit %q{
}
assert_normal_exit %q{
- # Test to ensure send on overriden c functions
+ # Test to ensure send on overridden c functions
# doesn't corrupt the stack
class Bar
def bar(x)
@@ -79,88 +394,77 @@ assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
end
}
-assert_equal '0', %q{
- # This is a regression test for incomplete invalidation from
- # opt_setinlinecache. This test might be brittle, so
- # feel free to remove it in the future if it's too annoying.
- # This test assumes --yjit-call-threshold=2.
- module M
- Foo = 1
- def foo
- Foo
- end
-
- def pin_self_type_then_foo
- _ = @foo
- foo
- end
-
- def only_ints
- 1 + self
- foo
- end
- end
-
- class Integer
- include M
+assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
+ # Tests defined? on non-heap objects
+ [NilClass, TrueClass, FalseClass, Integer, Float, Symbol].each do |klass|
+ klass.class_eval("def foo = defined?(@foo)")
end
- class Sub
- include M
+ [nil, true, false, 0xFABCAFE, 0.42, :cake].map do |instance|
+ instance.foo
+ instance.foo
end
+}
- foo_method = M.instance_method(:foo)
+assert_equal '[nil, "instance-variable", nil, "instance-variable"]', %q{
+ # defined? on object that changes shape between calls
+ class Foo
+ def foo
+ defined?(@foo)
+ end
- dbg = ->(message) do
- return # comment this out to get printouts
+ def add
+ @foo = 1
+ end
- $stderr.puts RubyVM::YJIT.disasm(foo_method)
- $stderr.puts message
+ def remove
+ self.remove_instance_variable(:@foo)
+ end
end
- 2.times { 42.only_ints }
-
- dbg["There should be two versions of getinlineache"]
-
- module M
- remove_const(:Foo)
- end
+ obj = Foo.new
+ [obj.foo, (obj.add; obj.foo), (obj.remove; obj.foo), (obj.add; obj.foo)]
+}
- dbg["There should be no getinlinecaches"]
+assert_equal '["instance-variable", 5]', %q{
+ # defined? on object too complex for shape information
+ class Foo
+ def initialize
+ 100.times { |i| instance_variable_set("@foo#{i}", i) }
+ end
- 2.times do
- 42.only_ints
- rescue NameError => err
- _ = "caught name error #{err}"
+ def foo
+ [defined?(@foo5), @foo5]
+ end
end
- dbg["There should be one version of getinlineache"]
-
- 2.times do
- Sub.new.pin_self_type_then_foo
- rescue NameError
- _ = 'second specialization'
- end
+ Foo.new.foo
+}
- dbg["There should be two versions of getinlineache"]
+# getinstancevariable with shape too complex
+assert_normal_exit %q{
+ class Foo
+ def initialize
+ @a = 1
+ end
- module M
- Foo = 1
+ def getter
+ @foobar
+ end
end
- dbg["There should still be two versions of getinlineache"]
-
- 42.only_ints
-
- dbg["There should be no getinlinecaches"]
+ # Initialize ivars in changing order, making the Foo
+ # class have shape too complex
+ 100.times do |x|
+ foo = Foo.new
+ foo.instance_variable_set(:"@a#{x}", 1)
+ foo.instance_variable_set(:"@foobar", 777)
- # Find name of the first VM instruction in M#foo.
- insns = RubyVM::InstructionSequence.of(foo_method).to_a
- if defined?(RubyVM::YJIT.blocks_for) && (insns.last.find { Array === _1 }&.first == :opt_getinlinecache)
- RubyVM::YJIT.blocks_for(RubyVM::InstructionSequence.of(foo_method))
- .filter { _1.iseq_start_index == 0 }.count
- else
- 0 # skip the test
+ # The getter method eventually sees shape too complex
+ r = foo.getter
+ if r != 777
+ raise "error"
+ end
end
}
@@ -221,6 +525,8 @@ assert_equal 'string', %q{
# Check that exceptions work when getting global variable
assert_equal 'rescued', %q{
+ Warning[:deprecated] = true
+
module Warning
def warn(message)
raise
@@ -856,6 +1162,7 @@ assert_equal 'special', %q{
# Test that object references in generated code get marked and moved
assert_equal "good", %q{
+ skip :good unless GC.respond_to?(:compact)
def bar
"good"
end
@@ -879,7 +1186,7 @@ assert_equal "good", %q{
# Test polymorphic getinstancevariable. T_OBJECT -> T_STRING
assert_equal 'ok', %q{
@hello = @h1 = @h2 = @h3 = @h4 = 'ok'
- str = ""
+ str = +""
str.instance_variable_set(:@hello, 'ok')
public def get
@@ -1023,6 +1330,18 @@ assert_equal '[42, :default]', %q{
]
}
+# Test default value block for Hash
+assert_equal "false", <<~RUBY, frozen_string_literal: false
+ def index_with_string(h)
+ h["foo"]
+ end
+
+ h = Hash.new { |h, k| k.frozen? }
+
+ index_with_string(h)
+ index_with_string(h)
+RUBY
+
# A regression test for making sure cfp->sp is proper when
# hitting stubs. See :stub-sp-flush:
assert_equal 'ok', %q{
@@ -1180,6 +1499,38 @@ assert_equal '42', %q{
run
}
+# splatting an empty array on a specialized method
+assert_equal 'ok', %q{
+ def run
+ "ok".to_s(*[])
+ end
+
+ run
+ run
+}
+
+# splatting an single element array on a specialized method
+assert_equal '[1]', %q{
+ def run
+ [].<<(*[1])
+ end
+
+ run
+ run
+}
+
+# specialized method with wrong args
+assert_equal 'ok', %q{
+ def run(x)
+ "bad".to_s(123) if x
+ rescue
+ :ok
+ end
+
+ run(false)
+ run(true)
+}
+
# getinstancevariable on Symbol
assert_equal '[nil, nil]', %q{
# @foo to exercise the getinstancevariable instruction
@@ -1379,7 +1730,7 @@ assert_equal '{}', %q{
}
# test building hash with values
-assert_equal '{:foo=>:bar}', %q{
+assert_equal '{foo: :bar}', %q{
def build_hash(val)
{ foo: val }
end
@@ -1489,7 +1840,7 @@ assert_equal 'foo', %q{
}
# Test that String unary plus returns the same object ID for an unfrozen string.
-assert_equal 'true', %q{
+assert_equal 'true', <<~RUBY, frozen_string_literal: false
def jittable_method
str = "bar"
@@ -1499,7 +1850,7 @@ assert_equal 'true', %q{
uplus_str.object_id == old_obj_id
end
jittable_method
-}
+RUBY
# Test that String unary plus returns a different unfrozen string when given a frozen string
assert_equal 'false', %q{
@@ -1613,6 +1964,85 @@ assert_equal 'true', %q{
jittable_method
}
+# test getbyte on string class
+assert_equal '[97, :nil, 97, :nil, :raised]', %q{
+ def getbyte(s, i)
+ byte = begin
+ s.getbyte(i)
+ rescue TypeError
+ :raised
+ end
+
+ byte || :nil
+ end
+
+ getbyte("a", 0)
+ getbyte("a", 0)
+
+ [getbyte("a", 0), getbyte("a", 1), getbyte("a", -1), getbyte("a", -2), getbyte("a", "a")]
+}
+
+# Basic test for String#setbyte
+assert_equal 'AoZ', %q{
+ s = +"foo"
+ s.setbyte(0, 65)
+ s.setbyte(-1, 90)
+ s
+}
+
+# String#setbyte IndexError
+assert_equal 'String#setbyte', %q{
+ def ccall = "".setbyte(1, 0)
+ begin
+ ccall
+ rescue => e
+ e.backtrace.first.split("'").last
+ end
+}
+
+# String#setbyte TypeError
+assert_equal 'String#setbyte', %q{
+ def ccall = "".setbyte(nil, 0)
+ begin
+ ccall
+ rescue => e
+ e.backtrace.first.split("'").last
+ end
+}
+
+# String#setbyte FrozenError
+assert_equal 'String#setbyte', %q{
+ def ccall = "a".freeze.setbyte(0, 0)
+ begin
+ ccall
+ rescue => e
+ e.backtrace.first.split("'").last
+ end
+}
+
+# non-leaf String#setbyte
+assert_equal 'String#setbyte', %q{
+ def to_int
+ @caller = caller
+ 0
+ end
+
+ def ccall = "a".dup.setbyte(self, 98)
+ ccall
+
+ @caller.first.split("'").last
+}
+
+# non-leaf String#byteslice
+assert_equal 'TypeError', %q{
+ def ccall = "".byteslice(nil, nil)
+ begin
+ ccall
+ rescue => e
+ e.class
+ end
+}
+
# Test << operator on string subclass
assert_equal 'abab', %q{
class MyString < String; end
@@ -1758,6 +2188,34 @@ assert_equal '7', %q{
foo(5,2)
}
+# regression test for argument registers with invalidation
+assert_equal '[0, 1, 2]', %q{
+ def test(n)
+ ret = n
+ binding
+ ret
+ end
+
+ [0, 1, 2].map do |n|
+ test(n)
+ end
+}
+
+# regression test for argument registers
+assert_equal 'true', %q{
+ class Foo
+ def ==(other)
+ other == nil
+ end
+ end
+
+ def test
+ [Foo.new].include?(Foo.new)
+ end
+
+ test
+}
+
# test pattern matching
assert_equal '[:ok, :ok]', %q{
class C
@@ -1823,6 +2281,20 @@ assert_equal '123', %q{
foo(Foo)
}
+# Test EP == BP invalidation with moving ISEQs
+assert_equal 'ok', %q{
+ skip :ok unless GC.respond_to?(:compact)
+ def entry
+ ok = proc { :ok } # set #entry as an EP-escaping ISEQ
+ [nil].reverse_each do # avoid exiting the JIT frame on the constant
+ GC.compact # move #entry ISEQ
+ end
+ ok # should be read off of escaped EP
+ end
+
+ entry.call
+}
+
# invokesuper edge case
assert_equal '[:A, [:A, :B]]', %q{
class B
@@ -2011,6 +2483,44 @@ assert_equal '[0, 2]', %q{
B.new.foo
}
+# invokesuper in a weird block
+assert_equal '["block->A#itself", "block->singleton#itself"]', %q{
+ # This test runs the same block as first as a block and then as a method,
+ # testing the routine that finds the currently running method, which is
+ # relevant for `super`.
+ class BlockIseqDuality
+ prepend(Module.new do
+ def itself
+ nested = -> { "block->" + super() }
+ @singleton_itself.define_singleton_method(:itself, &nested)
+ nested
+ end
+ end)
+
+ attr_reader :singleton_itself
+ def initialize = (@singleton_itself = "singleton#itself")
+
+ def itself = "A#itself"
+ end
+
+ tester = BlockIseqDuality.new
+ super_lambda = tester.itself
+ super_lambda.call # warmup
+ [super_lambda.call, tester.singleton_itself.itself]
+}
+
+# invokesuper zsuper in a bmethod
+assert_equal 'ok', %q{
+ class Foo
+ define_method(:itself) { super }
+ end
+ begin
+ Foo.new.itself
+ rescue RuntimeError
+ :ok
+ end
+}
+
# Call to fixnum
assert_equal '[true, false]', %q{
def is_odd(obj)
@@ -2051,6 +2561,16 @@ assert_equal '[true, false, true, false]', %q{
[is_odd(123), is_odd(456), is_odd(bignum), is_odd(bignum+1)]
}
+# Flonum and Flonum
+assert_equal '[2.0, 0.0, 1.0, 4.0]', %q{
+ [1.0 + 1.0, 1.0 - 1.0, 1.0 * 1.0, 8.0 / 2.0]
+}
+
+# Flonum and Fixnum
+assert_equal '[2.0, 0.0, 1.0, 4.0]', %q{
+ [1.0 + 1, 1.0 - 1, 1.0 * 1, 8.0 / 2]
+}
+
# Call to static and dynamic symbol
assert_equal 'bar', %q{
def to_string(obj)
@@ -2091,6 +2611,30 @@ assert_equal '[1, 2, 3, 4, 5]', %q{
splatarray
}
+# splatkw
+assert_equal '[1, 2]', %q{
+ def foo(a:) = [a, yield]
+
+ def entry(&block)
+ a = { a: 1 }
+ foo(**a, &block)
+ end
+
+ entry { 2 }
+}
+assert_equal '[1, 2]', %q{
+ def foo(a:) = [a, yield]
+
+ def entry(obj, &block)
+ foo(**obj, &block)
+ end
+
+ entry({ a: 3 }) { 2 }
+ obj = Object.new
+ def obj.to_hash = { a: 1 }
+ entry(obj) { 2 }
+}
+
assert_equal '[1, 1, 2, 1, 2, 3]', %q{
def expandarray
arr = [1, 2, 3]
@@ -2145,6 +2689,39 @@ assert_equal '[:not_array, nil, nil]', %q{
expandarray_not_array(obj)
}
+assert_equal '[1, 2]', %q{
+ class NilClass
+ private
+ def to_ary
+ [1, 2]
+ end
+ end
+
+ def expandarray_redefined_nilclass
+ a, b = nil
+ [a, b]
+ end
+
+ expandarray_redefined_nilclass
+ expandarray_redefined_nilclass
+}
+
+assert_equal 'not_array', %q{
+ def expandarray_not_array(obj)
+ a, = obj
+ a
+ end
+
+ obj = Object.new
+ def obj.method_missing(m, *args, &block)
+ return [:not_array] if m == :to_ary
+ super
+ end
+
+ expandarray_not_array(obj)
+ expandarray_not_array(obj)
+}
+
assert_equal '[1, 2, nil]', %q{
def expandarray_rhs_too_small
a, b, c = [1, 2]
@@ -2155,6 +2732,17 @@ assert_equal '[1, 2, nil]', %q{
expandarray_rhs_too_small
}
+assert_equal '[nil, 2, nil]', %q{
+ def foo(arr)
+ a, b, c = arr
+ end
+
+ a, b, c1 = foo([0, 1])
+ a, b, c2 = foo([0, 1, 2])
+ a, b, c3 = foo([0, 1])
+ [c1, c2, c3]
+}
+
assert_equal '[1, [2]]', %q{
def expandarray_splat
a, *b = [1, 2]
@@ -2244,7 +2832,7 @@ assert_equal '[[:c_return, :String, :string_alias, "events_to_str"]]', %q{
events.compiled(events)
events
-} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
+}
# test enabling a TracePoint that targets a particular line in a C method call
assert_equal '[true]', %q{
@@ -2326,7 +2914,7 @@ assert_equal '[[:c_call, :itself]]', %q{
tp.enable { shouldnt_compile }
events
-} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
+}
# test enabling c_return tracing before compiling
assert_equal '[[:c_return, :itself, main]]', %q{
@@ -2341,7 +2929,7 @@ assert_equal '[[:c_return, :itself, main]]', %q{
tp.enable { shouldnt_compile }
events
-} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
+}
# test c_call invalidation
assert_equal '[[:c_call, :itself]]', %q{
@@ -2387,15 +2975,16 @@ assert_equal '[:itself]', %q{
itself
end
- tracing_ractor = Ractor.new do
+ port = Ractor::Port.new
+ tracing_ractor = Ractor.new port do |port|
# 1: start tracing
events = []
tp = TracePoint.new(:c_call) { events << _1.method_id }
tp.enable
- Ractor.yield(nil)
+ port << nil
# 3: run compiled method on tracing ractor
- Ractor.yield(nil)
+ port << nil
traced_method
events
@@ -2403,13 +2992,13 @@ assert_equal '[:itself]', %q{
tp&.disable
end
- tracing_ractor.take
+ port.receive
# 2: compile on non tracing ractor
traced_method
- tracing_ractor.take
- tracing_ractor.take
+ port.receive
+ tracing_ractor.value
}
# Try to hit a lazy branch stub while another ractor enables tracing
@@ -2423,17 +3012,18 @@ assert_equal '42', %q{
end
end
- ractor = Ractor.new do
+ port = Ractor::Port.new
+ ractor = Ractor.new port do |port|
compiled(false)
- Ractor.yield(nil)
+ port << nil
compiled(41)
end
tp = TracePoint.new(:line) { itself }
- ractor.take
+ port.receive
tp.enable
- ractor.take
+ ractor.value
}
# Test equality with changing types
@@ -2509,7 +3099,7 @@ assert_equal '42', %q{
A.foo
A.foo
- Ractor.new { A.foo }.take
+ Ractor.new { A.foo }.value
}
assert_equal '["plain", "special", "sub", "plain"]', %q{
@@ -2761,7 +3351,7 @@ assert_equal '[[1, 2, 3, 4]]', %q{
}
# cfunc kwargs
-assert_equal '{:foo=>123}', %q{
+assert_equal '{foo: 123}', %q{
def foo(bar)
bar.store(:value, foo: 123)
bar[:value]
@@ -2772,7 +3362,7 @@ assert_equal '{:foo=>123}', %q{
}
# cfunc kwargs
-assert_equal '{:foo=>123}', %q{
+assert_equal '{foo: 123}', %q{
def foo(bar)
bar.replace(foo: 123)
end
@@ -2782,7 +3372,7 @@ assert_equal '{:foo=>123}', %q{
}
# cfunc kwargs
-assert_equal '{:foo=>123, :bar=>456}', %q{
+assert_equal '{foo: 123, bar: 456}', %q{
def foo(bar)
bar.replace(foo: 123, bar: 456)
end
@@ -2792,7 +3382,7 @@ assert_equal '{:foo=>123, :bar=>456}', %q{
}
# variadic cfunc kwargs
-assert_equal '{:foo=>123}', %q{
+assert_equal '{foo: 123}', %q{
def foo(bar)
bar.merge(foo: 123)
end
@@ -2916,7 +3506,7 @@ assert_equal "true", %q{
}
# duphash
-assert_equal '{:foo=>123}', %q{
+assert_equal '{foo: 123}', %q{
def foo
{foo: 123}
end
@@ -2926,7 +3516,7 @@ assert_equal '{:foo=>123}', %q{
}
# newhash
-assert_equal '{:foo=>2}', %q{
+assert_equal '{foo: 2}', %q{
def foo
{foo: 1+1}
end
@@ -3036,6 +3626,74 @@ assert_equal 'new', %q{
test
}
+# Bug #21257 (infinite jmp)
+assert_equal 'ok', %q{
+ Good = :ok
+
+ def first
+ second
+ end
+
+ def second
+ ::Good
+ end
+
+ # Make `second` side exit on its first instruction
+ trace = TracePoint.new(:line) { }
+ trace.enable(target: method(:second))
+
+ first
+ # Recompile now that the constant cache is populated, so we get a fallthrough from `first` to `second`
+ # (this is need to reproduce with --yjit-call-threshold=1)
+ RubyVM::YJIT.code_gc if defined?(RubyVM::YJIT)
+ first
+
+ # Trigger a constant cache miss in rb_vm_opt_getconstant_path (in `second`) next time it's called
+ module InvalidateConstantCache
+ Good = nil
+ end
+
+ RubyVM::YJIT.simulate_oom! if defined?(RubyVM::YJIT)
+
+ first
+ first
+}
+
+assert_equal 'ok', %q{
+ # Multiple incoming branches into second
+ Good = :ok
+
+ def incoming_one
+ second
+ end
+
+ def incoming_two
+ second
+ end
+
+ def second
+ ::Good
+ end
+
+ # Make `second` side exit on its first instruction
+ trace = TracePoint.new(:line) { }
+ trace.enable(target: method(:second))
+
+ incoming_one
+ # Recompile now that the constant cache is populated, so we get a fallthrough from `incoming_one` to `second`
+ # (this is need to reproduce with --yjit-call-threshold=1)
+ RubyVM::YJIT.code_gc if defined?(RubyVM::YJIT)
+ incoming_one
+ incoming_two
+
+ # Trigger a constant cache miss in rb_vm_opt_getconstant_path (in `second`) next time it's called
+ module InvalidateConstantCache
+ Good = nil
+ end
+
+ incoming_one
+}
+
assert_equal 'ok', %q{
# Try to compile new method while OOM
def foo
@@ -3160,36 +3818,6 @@ assert_equal '3,12', %q{
pt_inspect(p)
}
-# Regression test for deadlock between branch_stub_hit and ractor_receive_if
-assert_equal '10', %q{
- r = Ractor.new Ractor.current do |main|
- main << 1
- main << 2
- main << 3
- main << 4
- main << 5
- main << 6
- main << 7
- main << 8
- main << 9
- main << 10
- end
-
- a = []
- a << Ractor.receive_if{|msg| msg == 10}
- a << Ractor.receive_if{|msg| msg == 9}
- a << Ractor.receive_if{|msg| msg == 8}
- a << Ractor.receive_if{|msg| msg == 7}
- a << Ractor.receive_if{|msg| msg == 6}
- a << Ractor.receive_if{|msg| msg == 5}
- a << Ractor.receive_if{|msg| msg == 4}
- a << Ractor.receive_if{|msg| msg == 3}
- a << Ractor.receive_if{|msg| msg == 2}
- a << Ractor.receive_if{|msg| msg == 1}
-
- a.length
-}
-
# checktype
assert_equal 'false', %q{
def function()
@@ -3495,6 +4123,26 @@ assert_equal '1', %q{
bar { }
}
+# unshareable bmethod call through Method#to_proc#call
+assert_equal '1000', %q{
+ define_method(:bmethod) do
+ self
+ end
+
+ Ractor.new do
+ errors = 0
+ 1000.times do
+ p = method(:bmethod).to_proc
+ begin
+ p.call
+ rescue RuntimeError
+ errors += 1
+ end
+ end
+ errors
+ end.value
+}
+
# test for return stub lifetime issue
assert_equal '1', %q{
def foo(n)
@@ -3599,7 +4247,7 @@ assert_equal '2', %q{
assert_equal 'Hello World', %q{
def bar
args = ["Hello "]
- greeting = "World"
+ greeting = +"World"
greeting.insert(0, *args)
greeting
end
@@ -3662,3 +4310,1248 @@ assert_equal '[1, 2, 3]', %q{
end
send(:bar, 1, 2, 3)
}
+
+# Fix splat block arg bad compilation
+assert_equal "foo", %q{
+ def literal(*args, &block)
+ s = ''.dup
+ literal_append(s, *args, &block)
+ s
+ end
+
+ def literal_append(sql, v)
+ sql << v
+ end
+
+ literal("foo")
+}
+
+# regression test for accidentally having a parameter truncated
+# due to Rust/C signature mismatch. Used to crash with
+# > [BUG] rb_vm_insn_addr2insn: invalid insn address ...
+# or
+# > ... `Err` value: TryFromIntError(())'
+assert_normal_exit %q{
+ n = 16384
+ eval(
+ "def foo(arg); " + "_=arg;" * n + '_=1;' + "Object; end"
+ )
+ foo 1
+}
+
+# Regression test for CantCompile not using starting_ctx
+assert_normal_exit %q{
+ class Integer
+ def ===(other)
+ false
+ end
+ end
+
+ def my_func(x)
+ case x
+ when 1
+ 1
+ when 2
+ 2
+ else
+ 3
+ end
+ end
+
+ my_func(1)
+}
+
+# Regression test for CantCompile not using starting_ctx
+assert_equal "ArgumentError", %q{
+ def literal(*args, &block)
+ s = ''.dup
+ args = [1, 2, 3]
+ literal_append(s, *args, &block)
+ s
+ end
+
+ def literal_append(sql, v)
+ [sql.inspect, v.inspect]
+ end
+
+ begin
+ literal("foo")
+ rescue ArgumentError
+ "ArgumentError"
+ end
+}
+
+# Rest with block
+# Simplified code from railsbench
+assert_equal '[{"/a" => "b", as: :c, via: :post}, [], nil]', %q{
+ def match(path, *rest, &block)
+ [path, rest, block]
+ end
+
+ def map_method(method, args, &block)
+ options = args.last
+ args.pop
+ options[:via] = method
+ match(*args, options, &block)
+ end
+
+ def post(*args, &block)
+ map_method(:post, args, &block)
+ end
+
+ post "/a" => "b", as: :c
+}
+
+# Test rest and kw_args
+assert_equal '[true, true, true, true]', %q{
+ def my_func(*args, base: nil, sort: true)
+ [args, base, sort]
+ end
+
+ def calling_my_func
+ results = []
+ results << (my_func("test") == [["test"], nil, true])
+ results << (my_func("test", base: :base) == [["test"], :base, true])
+ results << (my_func("test", sort: false) == [["test"], nil, false])
+ results << (my_func("test", "other", base: :base) == [["test", "other"], :base, true])
+ results
+ end
+ calling_my_func
+}
+
+# Test Integer#[] with 2 args
+assert_equal '0', %q{
+ 3[0, 0]
+}
+
+# unspecified_bits + checkkeyword
+assert_equal '2', %q{
+ def callee = 1
+
+ # checkkeyword should see unspecified_bits=0 (use bar), not Integer 1 (set bar = foo).
+ def foo(foo, bar: foo) = bar
+
+ def entry(&block)
+ # write 1 at stack[3]. Calling #callee spills stack[3].
+ 1 + (1 + (1 + (1 + callee)))
+ # &block is written to a register instead of stack[3]. When &block is popped and
+ # unspecified_bits is pushed, it must be written to stack[3], not to a register.
+ foo(1, bar: 2, &block)
+ end
+
+ entry # call branch_stub_hit (spill temps)
+ entry # doesn't call branch_stub_hit (not spill temps)
+}
+
+# Test rest and optional_params
+assert_equal '[true, true, true, true]', %q{
+ def my_func(stuff, base=nil, sort=true, *args)
+ [stuff, base, sort, args]
+ end
+
+ def calling_my_func
+ results = []
+ results << (my_func("test") == ["test", nil, true, []])
+ results << (my_func("test", :base) == ["test", :base, true, []])
+ results << (my_func("test", :base, false) == ["test", :base, false, []])
+ results << (my_func("test", :base, false, "other", "other") == ["test", :base, false, ["other", "other"]])
+ results
+ end
+ calling_my_func
+}
+
+# Test rest and optional_params and splat
+assert_equal '[true, true, true, true, true]', %q{
+ def my_func(stuff, base=nil, sort=true, *args)
+ [stuff, base, sort, args]
+ end
+
+ def calling_my_func
+ results = []
+ splat = ["test"]
+ results << (my_func(*splat) == ["test", nil, true, []])
+ splat = [:base]
+ results << (my_func("test", *splat) == ["test", :base, true, []])
+ splat = [:base, false]
+ results << (my_func("test", *splat) == ["test", :base, false, []])
+ splat = [:base, false, "other", "other"]
+ results << (my_func("test", *splat) == ["test", :base, false, ["other", "other"]])
+ splat = ["test", :base, false, "other", "other"]
+ results << (my_func(*splat) == ["test", :base, false, ["other", "other"]])
+ results
+ end
+ calling_my_func
+}
+
+# Regression test: rest and optional and splat
+assert_equal 'true', %q{
+ def my_func(base=nil, *args)
+ [base, args]
+ end
+
+ def calling_my_func
+ array = []
+ my_func(:base, :rest1, *array) == [:base, [:rest1]]
+ end
+
+ calling_my_func
+}
+
+# Fix failed case for large splat
+assert_equal 'true', %q{
+ def d(a, b=:b)
+ end
+
+ def calling_func
+ ary = 1380888.times;
+ d(*ary)
+ end
+ begin
+ calling_func
+ rescue ArgumentError
+ true
+ end
+}
+
+# Regression test: register allocator on expandarray
+assert_equal '[]', %q{
+ func = proc { [] }
+ proc do
+ _x, _y = func.call
+ end.call
+}
+
+# Catch TAG_BREAK in a non-FINISH frame with JIT code
+assert_equal '1', %q{
+ def entry
+ catch_break
+ end
+
+ def catch_break
+ while_true do
+ break
+ end
+ 1
+ end
+
+ def while_true
+ while true
+ yield
+ end
+ end
+
+ entry
+}
+
+assert_equal '6', %q{
+ class Base
+ def number = 1 + yield
+ end
+
+ class Sub < Base
+ def number = super + 2
+ end
+
+ Sub.new.number { 3 }
+}
+
+# Integer multiplication and overflow
+assert_equal '[6, -6, 9671406556917033397649408, -9671406556917033397649408, 21267647932558653966460912964485513216]', %q{
+ def foo(a, b)
+ a * b
+ end
+
+ r1 = foo(2, 3)
+ r2 = foo(2, -3)
+ r3 = foo(2 << 40, 2 << 41)
+ r4 = foo(2 << 40, -2 << 41)
+ r5 = foo(1 << 62, 1 << 62)
+
+ [r1, r2, r3, r4, r5]
+}
+
+# Integer multiplication and overflow (minimized regression test from test-basic)
+assert_equal '8515157028618240000', %q{2128789257154560000 * 4}
+
+# Inlined method calls
+assert_equal 'nil', %q{
+ def putnil = nil
+ def entry = putnil
+ entry.inspect
+}
+assert_equal '1', %q{
+ def putobject_1 = 1
+ def entry = putobject_1
+ entry
+}
+assert_equal 'false', %q{
+ def putobject(_unused_arg1) = false
+ def entry = putobject(nil)
+ entry
+}
+assert_equal 'true', %q{
+ def entry = yield
+ entry { true }
+}
+assert_equal 'sym', %q{
+ def entry = :sym.to_sym
+ entry
+}
+
+assert_normal_exit %q{
+ ivars = 1024.times.map { |i| "@iv_#{i} = #{i}\n" }.join
+ Foo = Class.new
+ Foo.class_eval "def initialize() #{ivars} end"
+ Foo.new
+}
+
+assert_equal '0', %q{
+ def spill
+ 1.to_i # not inlined
+ end
+
+ def inline(_stack1, _stack2, _stack3, _stack4, _stack5)
+ 0 # inlined
+ end
+
+ def entry
+ # RegTemps is 00111110 prior to the #inline call.
+ # Its return value goes to stack_idx=0, which conflicts with stack_idx=5.
+ inline(spill, 2, 3, 4, 5)
+ end
+
+ entry
+}
+
+# Integer succ and overflow
+assert_equal '[2, 4611686018427387904]', %q{
+ [1.succ, 4611686018427387903.succ]
+}
+
+# Integer pred and overflow
+assert_equal '[0, -4611686018427387905]', %q{
+ [1.pred, -4611686018427387904.pred]
+}
+
+# Integer right shift
+assert_equal '[0, 1, -4]', %q{
+ [0 >> 1, 2 >> 1, -7 >> 1]
+}
+
+# Integer XOR
+assert_equal '[0, 0, 4]', %q{
+ [0 ^ 0, 1 ^ 1, 7 ^ 3]
+}
+
+assert_equal '[nil, "yield"]', %q{
+ def defined_yield = defined?(yield)
+ [defined_yield, defined_yield {}]
+}
+
+# splat with ruby2_keywords into rest parameter
+assert_equal '[[{a: 1}], {}]', %q{
+ ruby2_keywords def foo(*args) = args
+
+ def bar(*args, **kw) = [args, kw]
+
+ def pass_bar(*args) = bar(*args)
+
+ def body
+ args = foo(a: 1)
+ pass_bar(*args)
+ end
+
+ body
+}
+
+# concatarray
+assert_equal '[1, 2]', %q{
+ def foo(a, b) = [a, b]
+ arr = [2]
+ foo(*[1], *arr)
+}
+
+# pushtoarray
+assert_equal '[1, 2]', %q{
+ def foo(a, b) = [a, b]
+ arr = [1]
+ foo(*arr, 2)
+}
+
+# pop before fallback
+assert_normal_exit %q{
+ class Foo
+ attr_reader :foo
+
+ def try = foo(0, &nil)
+ end
+
+ Foo.new.try
+}
+
+# a kwrest case
+assert_equal '[1, 2, {complete: false}]', %q{
+ def rest(foo: 1, bar: 2, **kwrest)
+ [foo, bar, kwrest]
+ end
+
+ def callsite = rest(complete: false)
+
+ callsite
+}
+
+# splat+kw_splat+opt+rest
+assert_equal '[1, []]', %q{
+ def opt_rest(a = 0, *rest) = [a, rest]
+
+ def call_site(args) = opt_rest(*args, **nil)
+
+ call_site([1])
+}
+
+# splat and nil kw_splat
+assert_equal 'ok', %q{
+ def identity(x) = x
+
+ def splat_nil_kw_splat(args) = identity(*args, **nil)
+
+ splat_nil_kw_splat([:ok])
+}
+
+# empty splat and kwsplat into leaf builtins
+assert_equal '[1, 1, 1]', %q{
+ empty = []
+ [1.abs(*empty), 1.abs(**nil), 1.bit_length(*empty, **nil)]
+}
+
+# splat into C methods with -1 arity
+assert_equal '[[1, 2, 3], [0, 2, 3], [1, 2, 3], [2, 2, 3], [], [], [{}]]', %q{
+ class Foo < Array
+ def push(args) = super(1, *args)
+ end
+
+ def test_cfunc_vargs_splat(sub_instance, array_class, empty_kw_hash)
+ splat = [2, 3]
+ kw_splat = [empty_kw_hash]
+ [
+ sub_instance.push(splat),
+ array_class[0, *splat, **nil],
+ array_class[1, *splat, &nil],
+ array_class[2, *splat, **nil, &nil],
+ array_class.send(:[], *kw_splat),
+ # kw_splat disables keywords hash handling
+ array_class[*kw_splat],
+ array_class[*kw_splat, **nil],
+ ]
+ end
+
+ test_cfunc_vargs_splat(Foo.new, Array, Hash.ruby2_keywords_hash({}))
+}
+
+# Class#new (arity=-1), splat, and ruby2_keywords
+assert_equal '[0, {1 => 1}]', %q{
+ class KwInit
+ attr_reader :init_args
+ def initialize(x = 0, **kw)
+ @init_args = [x, kw]
+ end
+ end
+
+ def test(klass, args)
+ klass.new(*args).init_args
+ end
+
+ test(KwInit, [Hash.ruby2_keywords_hash({1 => 1})])
+}
+
+# Chilled string setivar trigger warning
+assert_match(/literal string will be frozen in the future/, %q{
+ Warning[:deprecated] = true
+ $VERBOSE = true
+ $warning = "no-warning"
+ module ::Warning
+ def self.warn(message)
+ $warning = message.split("warning: ").last.strip
+ end
+ end
+
+ class String
+ def setivar!
+ @ivar = 42
+ end
+ end
+
+ def setivar!(str)
+ str.setivar!
+ end
+
+ 10.times { setivar!("mutable".dup) }
+ 10.times do
+ setivar!("frozen".freeze)
+ rescue FrozenError
+ end
+
+ setivar!("chilled") # Emit warning
+ $warning
+})
+
+# arity=-2 cfuncs
+assert_equal '["", "1/2", [0, [:ok, 1]]]', %q{
+ def test_cases(file, chain)
+ new_chain = chain.allocate # to call initialize directly
+ new_chain.send(:initialize, [0], ok: 1)
+
+ [
+ file.join,
+ file.join("1", "2"),
+ new_chain.to_a,
+ ]
+ end
+
+ test_cases(File, Enumerator::Chain)
+}
+
+# singleton class should invalidate Type::CString assumption
+assert_equal 'foo', %q{
+ def define_singleton(str, define)
+ if define
+ # Wrap a C method frame to avoid exiting JIT code on defineclass
+ [nil].reverse_each do
+ class << str
+ def +(_)
+ "foo"
+ end
+ end
+ end
+ end
+ "bar"
+ end
+
+ def entry(define)
+ str = ""
+ # When `define` is false, #+ compiles to rb_str_plus() without a class guard.
+ # When the code is reused with `define` is true, the class of `str` is changed
+ # to a singleton class, so the block should be invalidated.
+ str + define_singleton(str, define)
+ end
+
+ entry(false)
+ entry(true)
+}
+
+assert_equal 'ok', %q{
+ def ok
+ :ok
+ end
+
+ def delegator(...)
+ ok(...)
+ end
+
+ def caller
+ send(:delegator)
+ end
+
+ caller
+}
+
+# test inlining of simple iseqs
+assert_equal '[:ok, :ok, :ok]', %q{
+ def identity(x) = x
+ def foo(x, _) = x
+ def bar(_, _, _, _, x) = x
+
+ def tests
+ [
+ identity(:ok),
+ foo(:ok, 2),
+ bar(1, 2, 3, 4, :ok),
+ ]
+ end
+
+ tests
+}
+
+# test inlining of simple iseqs with kwargs
+assert_equal '[:ok, :ok, :ok, :ok, :ok]', %q{
+ def optional_unused(x, opt: :not_ok) = x
+ def optional_used(x, opt: :ok) = opt
+ def required_unused(x, req:) = x
+ def required_used(x, req:) = req
+ def unknown(x) = x
+
+ def tests
+ [
+ optional_unused(:ok),
+ optional_used(:not_ok),
+ required_unused(:ok, req: :not_ok),
+ required_used(:not_ok, req: :ok),
+ begin unknown(:not_ok, unknown_kwarg: :not_ok) rescue ArgumentError; :ok end,
+ ]
+ end
+
+ tests
+}
+
+# test simple iseqs not eligible for inlining
+assert_equal '[:ok, :ok, :ok, :ok, :ok]', %q{
+ def identity(x) = x
+ def arg_splat(x, *args) = x
+ def kwarg_splat(x, **kwargs) = x
+ def block_arg(x, &blk) = x
+ def block_iseq(x) = x
+ def call_forwarding(...) = identity(...)
+
+ def tests
+ [
+ arg_splat(:ok),
+ kwarg_splat(:ok),
+ block_arg(:ok, &proc { :not_ok }),
+ block_iseq(:ok) { :not_ok },
+ call_forwarding(:ok),
+ ]
+ end
+
+ tests
+}
+
+# regression test for splat with &proc{} when the target has rest (Bug #21266)
+assert_equal '[]', %q{
+ def foo(args) = bar(*args, &proc { _1 })
+ def bar(_, _, _, _, *rest) = yield rest
+
+ GC.stress = true
+ foo([1,2,3,4])
+ foo([1,2,3,4])
+}
+
+# regression test for invalidating an empty block
+assert_equal '0', %q{
+ def foo = (* = 1).pred
+
+ foo # compile it
+
+ class Integer
+ def to_ary = [] # invalidate
+ end
+
+ foo # try again
+}
+
+# test integer left shift with constant rhs
+assert_equal [0x80000000000, 'a+', :ok].inspect, %q{
+ def shift(val) = val << 43
+
+ def tests
+ int = shift(1)
+ str = shift("a")
+
+ Integer.define_method(:<<) { |_| :ok }
+ redef = shift(1)
+
+ [int, str, redef]
+ end
+
+ tests
+}
+
+# test integer left shift fusion followed by opt_getconstant_path
+assert_equal '33', %q{
+ def test(a)
+ (a << 5) | (Object; a)
+ end
+
+ test(1)
+}
+
+# test String#stebyte with arguments that need conversion
+assert_equal "abc", %q{
+ str = +"a00"
+ def change_bytes(str, one, two)
+ str.setbyte(one, "b".ord)
+ str.setbyte(2, two)
+ end
+
+ to_int_1 = Object.new
+ to_int_99 = Object.new
+ def to_int_1.to_int = 1
+ def to_int_99.to_int = 99
+
+ change_bytes(str, to_int_1, to_int_99)
+ str
+}
+
+# test --yjit-verify-ctx for arrays with a singleton class
+assert_equal "ok", %q{
+ class Array
+ def foo
+ self.singleton_class.define_method(:first) { :ok }
+ first
+ end
+ end
+
+ def test = [].foo
+
+ test
+}
+
+assert_equal '["raised", "Module", "Object"]', %q{
+ def foo(obj)
+ obj.superclass.name
+ end
+
+ ret = []
+
+ begin
+ foo(Class.allocate)
+ rescue TypeError
+ ret << 'raised'
+ end
+
+ ret += [foo(Class), foo(Class.new)]
+}
+
+# test TrueClass#=== before and after redefining TrueClass#==
+assert_equal '[[true, false, false], [true, true, false], [true, :error, :error]]', %q{
+ def true_eqq(x)
+ true === x
+ rescue NoMethodError
+ :error
+ end
+
+ def test
+ [
+ # first one is always true because rb_equal does object comparison before calling #==
+ true_eqq(true),
+ # these will use TrueClass#==
+ true_eqq(false),
+ true_eqq(:truthy),
+ ]
+ end
+
+ results = [test]
+
+ class TrueClass
+ def ==(x)
+ !x
+ end
+ end
+
+ results << test
+
+ class TrueClass
+ undef_method :==
+ end
+
+ results << test
+}
+
+# test FalseClass#=== before and after redefining FalseClass#==
+assert_equal '[[true, false, false], [true, false, true], [true, :error, :error]]', %q{
+ def case_equal(x, y)
+ x === y
+ rescue NoMethodError
+ :error
+ end
+
+ def test
+ [
+ # first one is always true because rb_equal does object comparison before calling #==
+ case_equal(false, false),
+ # these will use #==
+ case_equal(false, true),
+ case_equal(false, nil),
+ ]
+ end
+
+ results = [test]
+
+ class FalseClass
+ def ==(x)
+ !x
+ end
+ end
+
+ results << test
+
+ class FalseClass
+ undef_method :==
+ end
+
+ results << test
+}
+
+# test NilClass#=== before and after redefining NilClass#==
+assert_equal '[[true, false, false], [true, false, true], [true, :error, :error]]', %q{
+ def case_equal(x, y)
+ x === y
+ rescue NoMethodError
+ :error
+ end
+
+ def test
+ [
+ # first one is always true because rb_equal does object comparison before calling #==
+ case_equal(nil, nil),
+ # these will use #==
+ case_equal(nil, true),
+ case_equal(nil, false),
+ ]
+ end
+
+ results = [test]
+
+ class NilClass
+ def ==(x)
+ !x
+ end
+ end
+
+ results << test
+
+ class NilClass
+ undef_method :==
+ end
+
+ results << test
+}
+
+# test struct accessors fire c_call events
+assert_equal '[[:c_call, :x=], [:c_call, :x]]', %q{
+ c = Struct.new(:x)
+ obj = c.new
+
+ events = []
+ TracePoint.new(:c_call) do
+ events << [_1.event, _1.method_id]
+ end.enable do
+ obj.x = 100
+ obj.x
+ end
+
+ events
+}
+
+# regression test for splatting empty array
+assert_equal '1', %q{
+ def callee(foo) = foo
+
+ def test_body(args) = callee(1, *args)
+
+ test_body([])
+ array = Array.new(100)
+ array.clear
+ test_body(array)
+}
+
+# regression test for splatting empty array to cfunc
+assert_normal_exit %q{
+ def test_body(args) = Array(1, *args)
+
+ test_body([])
+ 0x100.times do
+ array = Array.new(100)
+ array.clear
+ test_body(array)
+ end
+}
+
+# compiling code shouldn't emit warnings as it may call into more Ruby code
+assert_equal 'ok', <<~'RUBY'
+ # [Bug #20522]
+ $VERBOSE = true
+ Warning[:performance] = true
+
+ module StrictWarnings
+ def warn(msg, **)
+ raise msg
+ end
+ end
+ Warning.singleton_class.prepend(StrictWarnings)
+
+ class A
+ def compiled_method(is_private)
+ @some_ivar = is_private
+ end
+ end
+
+ shape_max_variations = 8
+ if defined?(RubyVM::Shape::SHAPE_MAX_VARIATIONS) && RubyVM::Shape::SHAPE_MAX_VARIATIONS != shape_max_variations
+ raise "Expected SHAPE_MAX_VARIATIONS to be #{shape_max_variations}, got: #{RubyVM::Shape::SHAPE_MAX_VARIATIONS}"
+ end
+
+ 100.times do |i|
+ klass = Class.new(A)
+ (shape_max_variations - 1).times do |j|
+ obj = klass.new
+ obj.instance_variable_set("@base_#{i}", 42)
+ obj.instance_variable_set("@ivar_#{j}", 42)
+ end
+ obj = klass.new
+ obj.instance_variable_set("@base_#{i}", 42)
+ begin
+ obj.compiled_method(true)
+ rescue
+ # expected
+ end
+ end
+
+ :ok
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+ class MyRelation
+ def callee(...)
+ :ok
+ end
+
+ def uncached(...)
+ callee(...)
+ end
+
+ def takes_block(&block)
+ # push blockhandler
+ uncached(&block) # CI1
+ end
+ end
+
+ relation = MyRelation.new
+ relation.takes_block { }
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+ def _exec_scope(...)
+ instance_exec(...)
+ end
+
+ def ok args, body
+ _exec_scope(*args, &body)
+ end
+
+ ok([], -> { "ok" })
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+ def _exec_scope(...)
+ instance_exec(...)
+ end
+
+ def ok args, body
+ _exec_scope(*args, &body)
+ end
+
+ ok(["ok"], ->(x) { x })
+RUBY
+
+assert_equal 'ok', <<~'RUBY'
+def baz(a, b)
+ a + b
+end
+
+def bar(...)
+ baz(...)
+end
+
+def foo(a, ...)
+ bar(a, ...)
+end
+
+def test
+ foo("o", "k")
+end
+
+test
+RUBY
+
+# opt_newarray_send pack/buffer
+assert_equal '[true, true]', <<~'RUBY'
+ def pack
+ v = 1.23
+ [v, v*2, v*3].pack("E*").unpack("E*") == [v, v*2, v*3]
+ end
+
+ def with_buffer
+ v = 4.56
+ b = +"x"
+ [v, v*2, v*3].pack("E*", buffer: b)
+ b[1..].unpack("E*") == [v, v*2, v*3]
+ end
+
+ [pack, with_buffer]
+RUBY
+
+# String#[] / String#slice
+assert_equal 'ok', <<~'RUBY'
+ def error(klass)
+ yield
+ rescue klass
+ true
+ end
+
+ def test
+ str = "ã“ã‚“ã«ã¡ã¯"
+ substr = "ã«ã¡"
+ failures = []
+
+ # Use many small statements to keep context for each slice call smaller than MAX_CTX_TEMPS
+
+ str[1] == "ã‚“" && str.slice(4) == "ã¯" || failures << :index
+ str[5].nil? && str.slice(5).nil? || failures << :index_end
+
+ str[1, 2] == "ã‚“ã«" && str.slice(2, 1) == "ã«" || failures << :beg_len
+ str[5, 1] == "" && str.slice(5, 1) == "" || failures << :beg_len_end
+
+ str[1..2] == "ã‚“ã«" && str.slice(2..2) == "ã«" || failures << :range
+
+ str[/ã«./] == "ã«ã¡" && str.slice(/ã«./) == "ã«ã¡" || failures << :regexp
+
+ str[/ã«./, 0] == "ã«ã¡" && str.slice(/ã«./, 0) == "ã«ã¡" || failures << :regexp_cap0
+
+ str[/ã«(.)/, 1] == "ã¡" && str.slice(/ã«(.)/, 1) == "ã¡" || failures << :regexp_cap1
+
+ str[substr] == substr && str.slice(substr) == substr || failures << :substr
+
+ error(TypeError) { str[Object.new] } && error(TypeError) { str.slice(Object.new, 1) } || failures << :type_error
+ error(RangeError) { str[Float::INFINITY] } && error(RangeError) { str.slice(Float::INFINITY) } || failures << :range_error
+
+ return "ok" if failures.empty?
+ {failures: failures}
+ end
+
+ test
+RUBY
+
+# opt_duparray_send :include?
+assert_equal '[true, false]', <<~'RUBY'
+ def test(x)
+ [:a, :b].include?(x)
+ end
+
+ [
+ test(:b),
+ test(:c),
+ ]
+RUBY
+
+# opt_newarray_send :include?
+assert_equal '[true, false]', <<~'RUBY'
+ def test(x)
+ [Object.new, :a, :b].include?(x.to_sym)
+ end
+
+ [
+ test("b"),
+ test("c"),
+ ]
+RUBY
+
+# YARV: swap and opt_reverse
+assert_equal '["x", "Y", "c", "A", "t", "A", "b", "C", "d"]', <<~'RUBY'
+ class Swap
+ def initialize(s)
+ @a, @b, @c, @d = s.split("")
+ end
+
+ def swap
+ a, b = @a, @b
+ b = b.upcase
+ @a, @b = a, b
+ end
+
+ def reverse_odd
+ a, b, c = @a, @b, @c
+ b = b.upcase
+ @a, @b, @c = a, b, c
+ end
+
+ def reverse_even
+ a, b, c, d = @a, @b, @c, @d
+ a = a.upcase
+ c = c.upcase
+ @a, @b, @c, @d = a, b, c, d
+ end
+ end
+
+ Swap.new("xy").swap + Swap.new("cat").reverse_odd + Swap.new("abcd").reverse_even
+RUBY
+
+assert_normal_exit %{
+ class Bug20997
+ def foo(&) = self.class.name(&)
+
+ new.foo
+ end
+}
+
+# This used to trigger a "try to mark T_NONE"
+# due to an uninitialized local in foo.
+assert_normal_exit %{
+ def foo(...)
+ _local_that_should_nil_on_call = GC.start
+ end
+
+ def test_bug21021
+ puts [], [], [], [], [], []
+ foo []
+ end
+
+ GC.stress = true
+ test_bug21021
+}
+
+assert_equal 'nil', %{
+ def foo(...)
+ _a = _b = _c = binding.local_variable_get(:_c)
+
+ _c
+ end
+
+ # [Bug #21021]
+ def test_local_fill_in_forwardable
+ puts [], [], [], [], []
+ foo []
+ end
+
+ test_local_fill_in_forwardable.inspect
+}
+
+# Test defined?(yield) and block_given? in non-method context.
+# It's good that the body of this runs at true top level and isn't wrapped in a block.
+assert_equal 'false', %{
+ RESULT = []
+ RESULT << defined?(yield)
+ RESULT << block_given?
+
+ 1.times do
+ RESULT << defined?(yield)
+ RESULT << block_given?
+ end
+
+ module ModuleContext
+ 1.times do
+ RESULT << defined?(yield)
+ RESULT << block_given?
+ end
+ end
+
+ class << self
+ RESULT << defined?(yield)
+ RESULT << block_given?
+ end
+
+ RESULT.any?
+}
+
+# throw and String#dup with GC stress
+assert_equal 'foo', %{
+ GC.stress = true
+
+ def foo
+ 1.times { return "foo".dup }
+ end
+
+ 10.times.map { foo.dup }.last
+}
+
+# regression test for [Bug #21772]
+# local variable type tracking desync
+assert_normal_exit %q{
+ def some_method = 0
+
+ def test_body(key)
+ some_method
+ key = key.to_s # setting of local relevant
+
+ key == "symbol"
+ end
+
+ def jit_caller = test_body("session_id")
+
+ jit_caller # first iteration, non-escaped environment
+ alias some_method binding # induce environment escape
+ test_body(:symbol)
+}
+
+# regression test for missing check in identity method inlining
+assert_normal_exit %q{
+ # Use dead code (if false) to create a local
+ # without initialization instructions.
+ def foo(a)
+ if false
+ x = nil
+ end
+ x
+ end
+ def test = foo(1)
+ test
+ test
+}
+
+# regression test for tracing invalidation with on-stack compiled methods
+# Exercises the on_stack_iseqs path in rb_yjit_tracing_invalidate_all
+# where delayed deallocation must not create aliasing &mut references
+# to IseqPayload (use-after-free of version_map backing storage).
+assert_normal_exit %q{
+ def deep = 42
+ def mid = deep
+ def outer = mid
+
+ # Compile all three methods with YJIT
+ 10.times { outer }
+
+ # Enable tracing from within a call chain so that outer/mid/deep
+ # are on the stack when rb_yjit_tracing_invalidate_all runs.
+ # This triggers the on_stack_iseqs (delayed deallocation) path.
+ def deep
+ TracePoint.new(:line) {}.enable
+ 42
+ end
+
+ outer
+
+ # After invalidation, verify YJIT can recompile and run correctly
+ def deep = 42
+ 10.times { outer }
+}
+
+# regression test for tracing invalidation with on-stack fibers
+# Suspended fibers have iseqs on their stack that must survive invalidation.
+assert_equal '42', %q{
+ def compiled_method
+ Fiber.yield
+ 42
+ end
+
+ # Compile the method
+ 10.times { compiled_method rescue nil }
+
+ fiber = Fiber.new { compiled_method }
+ fiber.resume # suspends inside compiled_method — it's now on the fiber's stack
+
+ # Enable tracing while compiled_method is on the fiber's stack.
+ # This triggers rb_yjit_tracing_invalidate_all with on-stack iseqs.
+ TracePoint.new(:call) {}.enable
+
+ # Resume the fiber — compiled_method's iseq must still be valid
+ fiber.resume.to_s
+}
+
+# regression test for register mapping of methods with over 256 locals
+# [Bug #22074]
+assert_equal "ok", %q{
+ source = +"def many_locals\n"
+ source << " total = 0\n"
+
+ 128.times do |i|
+ source << " y#{i} = 1\n"
+ source << " x#{i} = Object.new\n"
+ end
+
+ source << " total += 1\n"
+ source << " raise total.inspect unless total == 1\n"
+ source << "end\n"
+
+ eval(source)
+ many_locals
+ "ok"
+}
diff --git a/bootstraptest/test_yjit_rust_port.rb b/bootstraptest/test_yjit_rust_port.rb
index e399e0e49e..2dbcebc03a 100644
--- a/bootstraptest/test_yjit_rust_port.rb
+++ b/bootstraptest/test_yjit_rust_port.rb
@@ -374,7 +374,7 @@ assert_equal 'ok', %q{
r = Ractor.new do
'ok'
end
- r.take
+ r.value
}
# Passed arguments to Ractor.new will be a block parameter
@@ -384,7 +384,7 @@ assert_equal 'ok', %q{
r = Ractor.new 'ok' do |msg|
msg
end
- r.take
+ r.value
}
# Pass multiple arguments to Ractor.new
@@ -393,7 +393,7 @@ assert_equal 'ok', %q{
r = Ractor.new 'ping', 'pong' do |msg, msg2|
[msg, msg2]
end
- 'ok' if r.take == ['ping', 'pong']
+ 'ok' if r.value == ['ping', 'pong']
}
# Ractor#send passes an object with copy to a Ractor
@@ -403,7 +403,7 @@ assert_equal 'ok', %q{
msg = Ractor.receive
end
r.send 'ok'
- r.take
+ r.value
}
assert_equal '[1, 2, 3]', %q{
diff --git a/box.c b/box.c
new file mode 100644
index 0000000000..0ca7838be9
--- /dev/null
+++ b/box.c
@@ -0,0 +1,1299 @@
+/* indent-tabs-mode: nil */
+
+#include "eval_intern.h"
+#include "internal.h"
+#include "internal/box.h"
+#include "internal/class.h"
+#include "internal/eval.h"
+#include "internal/error.h"
+#include "internal/file.h"
+#include "internal/gc.h"
+#include "internal/hash.h"
+#include "internal/io.h"
+#include "internal/load.h"
+#include "internal/st.h"
+#include "internal/variable.h"
+#include "iseq.h"
+#include "ruby/internal/globals.h"
+#include "ruby/util.h"
+#include "vm_core.h"
+#include "darray.h"
+#include "zjit.h"
+
+#include "builtin.h"
+
+#include <stdio.h>
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_SENDFILE_H
+# include <sys/sendfile.h>
+#endif
+#ifdef HAVE_COPYFILE_H
+#include <copyfile.h>
+#endif
+
+VALUE rb_cBox = 0;
+VALUE rb_cBoxEntry = 0;
+VALUE rb_mBoxLoader = 0;
+
+static rb_box_t master_box[1]; /* Initialize in initialize_master_box() */
+static rb_box_t *root_box;
+static rb_box_t *main_box;
+
+static rb_box_gem_flags_t box_gem_flags[1];
+
+static char *tmp_dir;
+static bool tmp_dir_has_dirsep;
+
+#define BOX_TMP_PREFIX "_ruby_box_"
+
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+#endif
+
+#if defined(_WIN32)
+# define DIRSEP "\\"
+#else
+# define DIRSEP "/"
+#endif
+
+bool ruby_box_enabled = false; // extern
+bool ruby_box_init_done = false; // extern
+bool ruby_box_crashed = false; // extern, changed only in vm.c
+
+VALUE rb_resolve_feature_path(VALUE klass, VALUE fname);
+static VALUE rb_box_inspect(VALUE obj);
+static void cleanup_all_local_extensions(VALUE libmap);
+
+void
+rb_box_set_gem_flags(rb_box_gem_flags_t *flags)
+{
+
+ box_gem_flags->gem = flags->gem;
+ box_gem_flags->error_highlight = flags->error_highlight;
+ box_gem_flags->did_you_mean = flags->did_you_mean;
+ box_gem_flags->syntax_suggest = flags->syntax_suggest;
+}
+
+void
+rb_box_init_done(void)
+{
+ ruby_box_init_done = true;
+}
+
+const rb_box_t *
+rb_master_box(void)
+{
+ return master_box;
+}
+
+const rb_box_t *
+rb_root_box(void)
+{
+ if (!root_box) // The root box isn't initialized yet - The Ruby runtime is in setup.
+ return master_box;
+ return root_box;
+}
+
+const rb_box_t *
+rb_main_box(void)
+{
+ return main_box;
+}
+
+const rb_box_t *
+rb_current_box(void)
+{
+ /*
+ * If RUBY_BOX is not set, the master box is the only available one.
+ *
+ * While the root/main boxes are not initialized, the master box is
+ * the only valid box.
+ * This early return is to avoid accessing EC before its setup.
+ */
+ if (!root_box)
+ return master_box;
+ if (!main_box)
+ return root_box;
+
+ return rb_vm_current_box(GET_EC());
+}
+
+const rb_box_t *
+rb_loading_box(void)
+{
+ if (!root_box)
+ return master_box;
+ if (!main_box)
+ return root_box;
+
+ return rb_vm_loading_box(GET_EC());
+}
+
+const rb_box_t *
+rb_current_box_in_crash_report(void)
+{
+ if (ruby_box_crashed)
+ return NULL;
+ return rb_current_box();
+}
+
+static long box_id_counter = 0;
+
+static long
+box_generate_id(void)
+{
+ long id;
+ RB_VM_LOCKING() {
+ id = ++box_id_counter;
+ }
+ return id;
+}
+
+static VALUE
+box_main_to_s(VALUE obj)
+{
+ return rb_str_new2("main");
+}
+
+static void
+box_entry_initialize(rb_box_t *box)
+{
+ const rb_box_t *master = rb_master_box();
+
+ // These will be updated immediately
+ box->box_object = 0;
+ box->box_id = 0;
+
+ box->top_self = rb_obj_alloc(rb_cObject);
+ rb_define_singleton_method(box->top_self, "to_s", box_main_to_s, 0);
+ rb_define_alias(rb_singleton_class(box->top_self), "inspect", "to_s");
+ box->load_path = rb_ary_dup(master->load_path);
+ box->expanded_load_path = rb_ary_dup(master->expanded_load_path);
+ box->load_path_snapshot = rb_ary_new();
+ box->load_path_check_cache = 0;
+ box->loaded_features = rb_ary_dup(master->loaded_features);
+ box->loaded_features_snapshot = rb_ary_new();
+ box->loaded_features_index = st_init_numtable();
+ box->loaded_features_realpaths = rb_hash_dup(master->loaded_features_realpaths);
+ box->loaded_features_realpath_map = rb_hash_dup(master->loaded_features_realpath_map);
+ box->loading_table = st_init_strtable();
+ box->ruby_dln_libmap = rb_hash_new_with_size(0);
+ box->gvar_tbl = rb_hash_new_with_size(0);
+ box->classext_cow_classes = st_init_numtable();
+
+ box->is_user = true;
+ box->is_optional = true;
+}
+
+void
+rb_box_gc_update_references(void *ptr)
+{
+ rb_box_t *box = (rb_box_t *)ptr;
+ if (!box) return;
+
+ if (box->box_object)
+ box->box_object = rb_gc_location(box->box_object);
+ if (box->top_self)
+ box->top_self = rb_gc_location(box->top_self);
+ box->load_path = rb_gc_location(box->load_path);
+ box->expanded_load_path = rb_gc_location(box->expanded_load_path);
+ box->load_path_snapshot = rb_gc_location(box->load_path_snapshot);
+ if (box->load_path_check_cache) {
+ box->load_path_check_cache = rb_gc_location(box->load_path_check_cache);
+ }
+ box->loaded_features = rb_gc_location(box->loaded_features);
+ box->loaded_features_snapshot = rb_gc_location(box->loaded_features_snapshot);
+ box->loaded_features_realpaths = rb_gc_location(box->loaded_features_realpaths);
+ box->loaded_features_realpath_map = rb_gc_location(box->loaded_features_realpath_map);
+ box->ruby_dln_libmap = rb_gc_location(box->ruby_dln_libmap);
+ box->gvar_tbl = rb_gc_location(box->gvar_tbl);
+}
+
+void
+rb_box_entry_mark(void *ptr)
+{
+ const rb_box_t *box = (rb_box_t *)ptr;
+ if (!box) return;
+
+ rb_gc_mark(box->box_object);
+ rb_gc_mark(box->top_self);
+ rb_gc_mark(box->load_path);
+ rb_gc_mark(box->expanded_load_path);
+ rb_gc_mark(box->load_path_snapshot);
+ rb_gc_mark(box->load_path_check_cache);
+ rb_gc_mark(box->loaded_features);
+ rb_gc_mark(box->loaded_features_snapshot);
+ rb_gc_mark(box->loaded_features_realpaths);
+ rb_gc_mark(box->loaded_features_realpath_map);
+ if (box->loading_table) {
+ rb_mark_tbl(box->loading_table);
+ }
+ rb_gc_mark(box->ruby_dln_libmap);
+ rb_gc_mark(box->gvar_tbl);
+ if (box->classext_cow_classes) {
+ rb_mark_set(box->classext_cow_classes);
+ }
+}
+
+static int
+free_loading_table_entry(st_data_t key, st_data_t value, st_data_t arg)
+{
+ xfree((char *)key);
+ return ST_DELETE;
+}
+
+static int
+free_loaded_feature_index_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ if (!FIXNUM_P(value)) {
+ rb_darray_free_sized((void *)value, long);
+ }
+ return ST_CONTINUE;
+}
+
+static void
+free_box_st_tables(void *ptr)
+{
+ rb_box_t *box = (rb_box_t *)ptr;
+ if (box->loading_table) {
+ st_foreach(box->loading_table, free_loading_table_entry, 0);
+ st_free_table(box->loading_table);
+ box->loading_table = 0;
+ }
+
+ if (box->loaded_features_index) {
+ st_foreach(box->loaded_features_index, free_loaded_feature_index_i, 0);
+ st_free_table(box->loaded_features_index);
+ }
+}
+
+static int
+free_classext_for_box(st_data_t key, st_data_t _value, st_data_t box_arg)
+{
+ rb_classext_t *ext;
+ VALUE obj = (VALUE)key;
+ const rb_box_t *box = (const rb_box_t *)box_arg;
+
+ if (RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE)) {
+ ext = rb_class_unlink_classext(obj, box);
+ rb_class_classext_free(obj, ext, false);
+ }
+ else if (RB_TYPE_P(obj, T_ICLASS)) {
+ ext = rb_class_unlink_classext(obj, box);
+ rb_iclass_classext_free(obj, ext, false);
+ }
+ else {
+ rb_bug("Invalid type of object in classext_cow_classes: %s", rb_type_str(BUILTIN_TYPE(obj)));
+ }
+ return ST_CONTINUE;
+}
+
+static void
+box_entry_free(void *ptr)
+{
+ const rb_box_t *box = (const rb_box_t *)ptr;
+
+ if (box->classext_cow_classes) {
+ st_foreach(box->classext_cow_classes, free_classext_for_box, (st_data_t)box);
+ }
+
+ cleanup_all_local_extensions(box->ruby_dln_libmap);
+
+ free_box_st_tables(ptr);
+ SIZED_FREE(box);
+}
+
+static size_t
+box_entry_memsize(const void *ptr)
+{
+ size_t size = sizeof(rb_box_t);
+ const rb_box_t *box = (const rb_box_t *)ptr;
+ if (box->loaded_features_index) {
+ size += rb_st_memsize(box->loaded_features_index);
+ }
+ if (box->loading_table) {
+ size += rb_st_memsize(box->loading_table);
+ }
+ return size;
+}
+
+static const rb_data_type_t rb_box_data_type = {
+ "Ruby::Box::Entry",
+ {
+ rb_box_entry_mark,
+ box_entry_free,
+ box_entry_memsize,
+ rb_box_gc_update_references,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY // TODO: enable RUBY_TYPED_WB_PROTECTED when inserting write barriers
+};
+
+static const rb_data_type_t rb_master_box_data_type = {
+ "Ruby::Box::Master",
+ {
+ rb_box_entry_mark,
+ free_box_st_tables,
+ box_entry_memsize,
+ rb_box_gc_update_references,
+ },
+ &rb_box_data_type, 0, RUBY_TYPED_FREE_IMMEDIATELY // TODO: enable RUBY_TYPED_WB_PROTECTED when inserting write barriers
+};
+
+VALUE
+rb_box_entry_alloc(VALUE klass)
+{
+ rb_box_t *entry;
+ VALUE obj = TypedData_Make_Struct(klass, rb_box_t, &rb_box_data_type, entry);
+ box_entry_initialize(entry);
+ return obj;
+}
+
+static rb_box_t *
+get_box_struct_internal(VALUE entry)
+{
+ rb_box_t *sval;
+ TypedData_Get_Struct(entry, rb_box_t, &rb_box_data_type, sval);
+ return sval;
+}
+
+rb_box_t *
+rb_get_box_t(VALUE box)
+{
+ VALUE entry;
+ ID id_box_entry;
+
+ VM_ASSERT(box);
+
+ if (NIL_P(box))
+ return (rb_box_t *)rb_root_box();
+
+ VM_ASSERT(BOX_OBJ_P(box));
+
+ CONST_ID(id_box_entry, "__box_entry__");
+ entry = rb_attr_get(box, id_box_entry);
+ return get_box_struct_internal(entry);
+}
+
+VALUE
+rb_get_box_object(rb_box_t *box)
+{
+ VM_ASSERT(box && box->box_object);
+ return box->box_object;
+}
+
+/*
+ * call-seq:
+ * Ruby::Box.new -> new_box
+ *
+ * Returns a new Ruby::Box object.
+ */
+static VALUE
+box_initialize(VALUE box_value)
+{
+ rb_box_t *box;
+ rb_classext_t *object_classext;
+ VALUE entry;
+ ID id_box_entry;
+ CONST_ID(id_box_entry, "__box_entry__");
+
+ if (!rb_box_available()) {
+ rb_raise(rb_eRuntimeError, "Ruby Box is disabled. Set RUBY_BOX=1 environment variable to use Ruby::Box.");
+ }
+
+ entry = rb_class_new_instance_pass_kw(0, NULL, rb_cBoxEntry);
+ box = get_box_struct_internal(entry);
+
+ box->box_object = box_value;
+ box->box_id = box_generate_id();
+ rb_define_singleton_method(box->load_path, "resolve_feature_path", rb_resolve_feature_path, 1);
+
+ // Set the Ruby::Box object unique/consistent from any boxes to have just single
+ // constant table from any view of every (including main) box.
+ // If a code in the box adds a constant, the constant will be visible even from root/main.
+ RCLASS_SET_PRIME_CLASSEXT_WRITABLE(box_value, true);
+
+ // Get a clean constant table of Object even by writable one
+ // because ns was just created, so it has not touched any constants yet.
+ object_classext = RCLASS_EXT_WRITABLE_IN_BOX(rb_cObject, box);
+ RCLASS_SET_CONST_TBL(box_value, RCLASSEXT_CONST_TBL(object_classext), true);
+
+ rb_ivar_set(box_value, id_box_entry, entry);
+
+ if (ruby_box_init_done) {
+ if (box_gem_flags->gem) {
+ rb_vm_call_cfunc_in_box(Qnil, rb_define_gem_modules, (VALUE)box_gem_flags, Qnil,
+ rb_str_new_cstr("before_prelude.user.dummy"), (const rb_box_t *)box);
+ rb_load_gem_prelude((VALUE)box);
+ }
+ }
+
+ // Invalidate ZJIT code that assumes only the root box is active
+ rb_zjit_invalidate_root_box();
+
+ return box_value;
+}
+
+/*
+ * call-seq:
+ * Ruby::Box.enabled? -> true or false
+ *
+ * Returns +true+ if Ruby::Box is enabled.
+ */
+static VALUE
+rb_box_s_getenabled(VALUE recv)
+{
+ return RBOOL(rb_box_available());
+}
+
+/*
+ * call-seq:
+ * Ruby::Box.current -> box, nil or false
+ *
+ * Returns the current box.
+ * Returns +nil+ if Ruby Box is not enabled.
+ */
+static VALUE
+rb_box_s_current(VALUE recv)
+{
+ const rb_box_t *box;
+
+ if (!rb_box_available())
+ return Qnil;
+
+ box = rb_vm_current_box(GET_EC());
+ VM_ASSERT(box && box->box_object);
+ return box->box_object;
+}
+
+/*
+ * call-seq:
+ * load_path -> array
+ *
+ * Returns box local load path.
+ */
+static VALUE
+rb_box_load_path(VALUE box)
+{
+ VM_ASSERT(BOX_OBJ_P(box));
+ return rb_get_box_t(box)->load_path;
+}
+
+#ifdef _WIN32
+UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
+#endif
+
+/* Copied from mjit.c Ruby 3.0.3 */
+static char *
+system_default_tmpdir(void)
+{
+ // c.f. ext/etc/etc.c:etc_systmpdir()
+#ifdef _WIN32
+ WCHAR tmppath[_MAX_PATH];
+ UINT len = rb_w32_system_tmpdir(tmppath, numberof(tmppath));
+ if (len) {
+ int blen = WideCharToMultiByte(CP_UTF8, 0, tmppath, len, NULL, 0, NULL, NULL);
+ char *tmpdir = xmalloc(blen + 1);
+ WideCharToMultiByte(CP_UTF8, 0, tmppath, len, tmpdir, blen, NULL, NULL);
+ tmpdir[blen] = '\0';
+ return tmpdir;
+ }
+#elif defined _CS_DARWIN_USER_TEMP_DIR
+ char path[MAXPATHLEN];
+ size_t len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
+ if (len > 0) {
+ char *tmpdir = xmalloc(len);
+ if (len > sizeof(path)) {
+ confstr(_CS_DARWIN_USER_TEMP_DIR, tmpdir, len);
+ }
+ else {
+ memcpy(tmpdir, path, len);
+ }
+ return tmpdir;
+ }
+#endif
+ return 0;
+}
+
+static int
+check_tmpdir(const char *dir)
+{
+ struct stat st;
+
+ if (!dir) return FALSE;
+ if (stat(dir, &st)) return FALSE;
+#ifndef S_ISDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+ if (!S_ISDIR(st.st_mode)) return FALSE;
+#ifndef _WIN32
+# ifndef S_IWOTH
+# define S_IWOTH 002
+# endif
+ if (st.st_mode & S_IWOTH) {
+# ifdef S_ISVTX
+ if (!(st.st_mode & S_ISVTX)) return FALSE;
+# else
+ return FALSE;
+# endif
+ }
+ if (access(dir, W_OK)) return FALSE;
+#endif
+ return TRUE;
+}
+
+static char *
+system_tmpdir(void)
+{
+ char *tmpdir;
+# define RETURN_ENV(name) \
+ if (check_tmpdir(tmpdir = getenv(name))) return ruby_strdup(tmpdir)
+ RETURN_ENV("TMPDIR");
+ RETURN_ENV("TMP");
+ tmpdir = system_default_tmpdir();
+ if (check_tmpdir(tmpdir)) return tmpdir;
+ return ruby_strdup("/tmp");
+# undef RETURN_ENV
+}
+
+/* end of copy */
+
+static int
+sprint_ext_filename(char *str, size_t size, long box_id, const char *prefix, const char *basename)
+{
+ if (tmp_dir_has_dirsep) {
+ return snprintf(str, size, "%s%sp%"PRI_PIDT_PREFIX"u_%ld_%s", tmp_dir, prefix, getpid(), box_id, basename);
+ }
+ return snprintf(str, size, "%s%s%sp%"PRI_PIDT_PREFIX"u_%ld_%s", tmp_dir, DIRSEP, prefix, getpid(), box_id, basename);
+}
+
+enum copy_error_type {
+ COPY_ERROR_NONE,
+ COPY_ERROR_SRC_OPEN,
+ COPY_ERROR_DST_OPEN,
+ COPY_ERROR_SRC_READ,
+ COPY_ERROR_DST_WRITE,
+ COPY_ERROR_SRC_STAT,
+ COPY_ERROR_DST_CHMOD,
+ COPY_ERROR_SYSERR
+};
+
+static const char *
+copy_ext_file_error(char *message, size_t size, int copy_retvalue)
+{
+#ifdef _WIN32
+ int error = GetLastError();
+ char *p = message;
+ size_t len = snprintf(message, size, "%d: ", error);
+
+#define format_message(sublang) FormatMessage(\
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \
+ NULL, error, MAKELANGID(LANG_NEUTRAL, (sublang)), \
+ message + len, size - len, NULL)
+ if (format_message(SUBLANG_ENGLISH_US) == 0)
+ format_message(SUBLANG_DEFAULT);
+ for (p = message + len; *p; p++) {
+ if (*p == '\n' || *p == '\r')
+ *p = ' ';
+ }
+#else
+ switch (copy_retvalue) {
+ case COPY_ERROR_SRC_OPEN:
+ strlcpy(message, "can't open the extension path", size);
+ break;
+ case COPY_ERROR_DST_OPEN:
+ strlcpy(message, "can't open the file to write", size);
+ break;
+ case COPY_ERROR_SRC_READ:
+ strlcpy(message, "failed to read the extension path", size);
+ break;
+ case COPY_ERROR_DST_WRITE:
+ strlcpy(message, "failed to write the extension path", size);
+ break;
+ case COPY_ERROR_SRC_STAT:
+ strlcpy(message, "failed to stat the extension path to copy permissions", size);
+ break;
+ case COPY_ERROR_DST_CHMOD:
+ strlcpy(message, "failed to set permissions to the copied extension path", size);
+ break;
+ case COPY_ERROR_SYSERR:
+ strlcpy(message, strerror(errno), size);
+ break;
+ case COPY_ERROR_NONE: /* shouldn't be called */
+ default:
+ rb_bug("unknown return value of copy_ext_file: %d", copy_retvalue);
+ }
+#endif
+ return message;
+}
+
+#ifndef _WIN32
+static enum copy_error_type
+copy_stream(int src_fd, int dst_fd)
+{
+ char buffer[1024];
+ ssize_t rsize;
+
+ while ((rsize = read(src_fd, buffer, sizeof(buffer))) != 0) {
+ if (rsize < 0) return COPY_ERROR_SRC_READ;
+ for (size_t written = 0; written < (size_t)rsize;) {
+ ssize_t wsize = write(dst_fd, buffer+written, rsize-written);
+ if (wsize < 0) return COPY_ERROR_DST_WRITE;
+ written += (size_t)wsize;
+ }
+ }
+ return COPY_ERROR_NONE;
+}
+#endif
+
+static enum copy_error_type
+copy_ext_file(const char *src_path, const char *dst_path)
+{
+#if defined(_WIN32)
+ WCHAR *w_src = rb_w32_mbstr_to_wstr(CP_UTF8, src_path, -1, NULL);
+ WCHAR *w_dst = rb_w32_mbstr_to_wstr(CP_UTF8, dst_path, -1, NULL);
+ if (!w_src || !w_dst) {
+ free(w_src);
+ free(w_dst);
+ rb_memerror();
+ }
+
+ enum copy_error_type rvalue = CopyFileW(w_src, w_dst, TRUE) ?
+ COPY_ERROR_NONE : COPY_ERROR_SYSERR;
+ free(w_src);
+ free(w_dst);
+ return rvalue;
+#else
+# ifdef O_BINARY
+ const int bin = O_BINARY;
+# else
+ const int bin = 0;
+# endif
+# ifdef O_CLOEXEC
+ const int cloexec = O_CLOEXEC;
+# else
+ const int cloexec = 0;
+# endif
+ const int src_fd = open(src_path, O_RDONLY|cloexec|bin);
+ if (src_fd < 0) return COPY_ERROR_SRC_OPEN;
+ if (!cloexec) rb_maygvl_fd_fix_cloexec(src_fd);
+
+ struct stat src_st;
+ if (fstat(src_fd, &src_st)) {
+ close(src_fd);
+ return COPY_ERROR_SRC_STAT;
+ }
+
+ const int dst_fd = open(dst_path, O_WRONLY|O_CREAT|O_EXCL|cloexec|bin, S_IRWXU);
+ if (dst_fd < 0) {
+ close(src_fd);
+ return COPY_ERROR_DST_OPEN;
+ }
+ if (!cloexec) rb_maygvl_fd_fix_cloexec(dst_fd);
+
+ enum copy_error_type ret = COPY_ERROR_NONE;
+
+ if (fchmod(dst_fd, src_st.st_mode & 0777)) {
+ ret = COPY_ERROR_DST_CHMOD;
+ goto done;
+ }
+
+ const size_t count_max = (SIZE_MAX >> 1) + 1;
+ (void)count_max;
+
+# ifdef HAVE_COPY_FILE_RANGE
+ for (;;) {
+ ssize_t written = copy_file_range(src_fd, NULL, dst_fd, NULL, count_max, 0);
+ if (written == 0) goto done;
+ if (written < 0) break;
+ }
+# endif
+# ifdef HAVE_FCOPYFILE
+ if (fcopyfile(src_fd, dst_fd, NULL, COPYFILE_DATA) == 0) {
+ goto done;
+ }
+# endif
+# ifdef USE_SENDFILE
+ for (;;) {
+ ssize_t written = sendfile(src_fd, dst_fd, NULL count_max);
+ if (written == 0) goto done;
+ if (written < 0) break;
+ }
+# endif
+ ret = copy_stream(src_fd, dst_fd);
+
+ done:
+ close(src_fd);
+ if (dst_fd >= 0) close(dst_fd);
+ if (ret != COPY_ERROR_NONE) unlink(dst_path);
+ return ret;
+#endif
+}
+
+#if defined __CYGWIN__ || defined DOSISH
+#define isdirsep(x) ((x) == '/' || (x) == '\\')
+#else
+#define isdirsep(x) ((x) == '/')
+#endif
+
+#define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
+#define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
+
+static void
+fname_without_suffix(const char *fname, char *rvalue, size_t rsize)
+{
+ size_t len = strlen(fname);
+ const char *pos;
+ for (pos = fname + len; pos > fname; pos--) {
+ if (IS_SOEXT(pos) || IS_DLEXT(pos)) {
+ len = pos - fname;
+ break;
+ }
+ if (fname + len - pos > DLEXT_MAXLEN) break;
+ }
+ if (len > rsize - 1) len = rsize - 1;
+ memcpy(rvalue, fname, len);
+ rvalue[len] = '\0';
+}
+
+static void
+escaped_basename(const char *path, const char *fname, char *rvalue, size_t rsize)
+{
+ char *pos;
+ const char *leaf = path, *found;
+ // `leaf + 1` looks uncomfortable (when leaf == path), but fname must not be the top-dir itself
+ while ((found = strstr(leaf + 1, fname)) != NULL) {
+ leaf = found; // find the last occurrence for the path like /etc/my-crazy-lib-dir/etc.so
+ }
+ strlcpy(rvalue, leaf, rsize);
+ for (pos = rvalue; *pos; pos++) {
+ if (isdirsep(*pos)) {
+ *pos = '+';
+ }
+ }
+}
+
+static void
+box_ext_cleanup_mark(void *p)
+{
+ rb_gc_mark((VALUE)p);
+}
+
+static void
+box_ext_cleanup_free(void *p)
+{
+ VALUE path = (VALUE)p;
+ unlink(RSTRING_PTR(path));
+}
+
+static const rb_data_type_t box_ext_cleanup_type = {
+ "box_ext_cleanup",
+ {box_ext_cleanup_mark, box_ext_cleanup_free},
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+void
+rb_box_cleanup_local_extension(VALUE cleanup)
+{
+ void *p = DATA_PTR(cleanup);
+ DATA_PTR(cleanup) = NULL;
+#ifndef _WIN32
+ if (p) box_ext_cleanup_free(p);
+#endif
+ (void)p;
+}
+
+static int
+cleanup_local_extension_i(VALUE key, VALUE value, VALUE arg)
+{
+#if defined(_WIN32)
+ HMODULE h = (HMODULE)NUM2PTR(value);
+ WCHAR module_path[MAXPATHLEN];
+ DWORD len = GetModuleFileNameW(h, module_path, numberof(module_path));
+
+ FreeLibrary(h);
+ if (len > 0 && len < numberof(module_path)) DeleteFileW(module_path);
+#endif
+ return ST_DELETE;
+}
+
+static void
+cleanup_all_local_extensions(VALUE libmap)
+{
+ rb_hash_foreach(libmap, cleanup_local_extension_i, 0);
+}
+
+VALUE
+rb_box_local_extension(VALUE box_value, VALUE fname, VALUE path, VALUE *cleanup)
+{
+ char ext_path[MAXPATHLEN], fname2[MAXPATHLEN], basename[MAXPATHLEN];
+ int wrote;
+ const char *src_path = RSTRING_PTR(path), *fname_ptr = RSTRING_PTR(fname);
+ rb_box_t *box = rb_get_box_t(box_value);
+
+ fname_without_suffix(fname_ptr, fname2, sizeof(fname2));
+ escaped_basename(src_path, fname2, basename, sizeof(basename));
+
+ wrote = sprint_ext_filename(ext_path, sizeof(ext_path), box->box_id, BOX_TMP_PREFIX, basename);
+ if (wrote >= (int)sizeof(ext_path)) {
+ rb_bug("Extension file path in the box was too long");
+ }
+ VALUE new_path = rb_str_new_cstr(ext_path);
+ *cleanup = TypedData_Wrap_Struct(0, &box_ext_cleanup_type, NULL);
+ enum copy_error_type copy_error = copy_ext_file(src_path, ext_path);
+ if (copy_error) {
+ char message[1024];
+ copy_ext_file_error(message, sizeof(message), copy_error);
+ rb_raise(rb_eLoadError, "can't prepare the extension file for Ruby Box (%s from %"PRIsVALUE"): %s", ext_path, path, message);
+ }
+ DATA_PTR(*cleanup) = (void *)new_path;
+ return new_path;
+}
+
+static VALUE
+rb_box_load(int argc, VALUE *argv, VALUE box)
+{
+ VALUE fname, wrap;
+ rb_scan_args(argc, argv, "11", &fname, &wrap);
+
+ rb_vm_frame_flag_set_box_require(GET_EC());
+
+ return rb_load_entrypoint(fname, wrap);
+}
+
+static VALUE
+rb_box_require(VALUE box, VALUE fname)
+{
+ rb_vm_frame_flag_set_box_require(GET_EC());
+
+ return rb_require_string(fname);
+}
+
+static VALUE
+rb_box_require_relative(VALUE box, VALUE fname)
+{
+ rb_vm_frame_flag_set_box_require(GET_EC());
+
+ return rb_require_relative_entrypoint(fname);
+}
+
+static void
+initialize_master_box(void)
+{
+ rb_vm_t *vm = GET_VM();
+ rb_box_t *master = (rb_box_t *)rb_master_box();
+
+ master->load_path = rb_ary_new();
+ master->expanded_load_path = rb_ary_hidden_new(0);
+ master->load_path_snapshot = rb_ary_hidden_new(0);
+ master->load_path_check_cache = 0;
+ rb_define_singleton_method(master->load_path, "resolve_feature_path", rb_resolve_feature_path, 1);
+
+ master->loaded_features = rb_ary_new();
+ master->loaded_features_snapshot = rb_ary_hidden_new(0);
+ master->loaded_features_index = st_init_numtable();
+ master->loaded_features_realpaths = rb_hash_new();
+ rb_obj_hide(master->loaded_features_realpaths);
+ master->loaded_features_realpath_map = rb_hash_new();
+ rb_obj_hide(master->loaded_features_realpath_map);
+
+ master->ruby_dln_libmap = rb_hash_new_with_size(0);
+ master->gvar_tbl = rb_hash_new_with_size(0);
+ master->classext_cow_classes = NULL; // classext CoW never happen on the master box
+
+ vm->master_box = master;
+
+ if (rb_box_available()) {
+ VALUE master_box, entry;
+ ID id_box_entry;
+ CONST_ID(id_box_entry, "__box_entry__");
+
+ master_box = rb_obj_alloc(rb_cBox);
+ RCLASS_SET_PRIME_CLASSEXT_WRITABLE(master_box, true);
+ RCLASS_SET_CONST_TBL(master_box, RCLASSEXT_CONST_TBL(RCLASS_EXT_PRIME(rb_cObject)), true);
+
+ master->box_id = box_generate_id();
+ master->box_object = master_box;
+
+ entry = TypedData_Wrap_Struct(rb_cBoxEntry, &rb_master_box_data_type, master);
+ rb_ivar_set(master_box, id_box_entry, entry);
+
+ rb_gc_register_mark_object(master_box);
+ rb_gc_register_mark_object(entry);
+ }
+ else {
+ master->box_id = 1;
+ master->box_object = Qnil;
+ }
+}
+
+static VALUE
+rb_box_eval(VALUE box_value, VALUE str)
+{
+ const rb_iseq_t *iseq;
+ const rb_box_t *box;
+
+ StringValue(str);
+
+ iseq = rb_iseq_compile_iseq(str, rb_str_new_cstr("eval"));
+ VM_ASSERT(iseq);
+
+ box = (const rb_box_t *)rb_get_box_t(box_value);
+
+ return rb_iseq_eval(iseq, box);
+}
+
+static int box_experimental_warned = 0;
+
+RUBY_EXTERN const char ruby_api_version_name[];
+
+static VALUE
+box_value_initialize(bool root, bool user, bool optional)
+{
+ rb_box_t *box;
+ VALUE box_value = rb_class_new_instance(0, NULL, rb_cBox);
+
+ VM_ASSERT(BOX_OBJ_P(box_value));
+
+ box = rb_get_box_t(box_value);
+ box->box_object = box_value;
+ box->is_root = root;
+ box->is_user = user;
+ box->is_optional = optional;
+ return box_value;
+}
+
+void
+rb_initialize_mandatory_boxes(void)
+{
+ VALUE root_box_value, main_box_value;
+ rb_vm_t *vm = GET_VM();
+
+ VM_ASSERT(rb_box_available());
+
+ if (!box_experimental_warned) {
+ rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL,
+ "Ruby::Box is experimental, and the behavior may change in the future!\n"
+ "See https://docs.ruby-lang.org/en/%s/Ruby/Box.html for known issues, etc.",
+ ruby_api_version_name);
+ box_experimental_warned = 1;
+ }
+
+ root_box_value = box_value_initialize(true, false, false);
+ main_box_value = box_value_initialize(false, true, false);
+
+ rb_const_set(rb_cBox, rb_intern("ROOT"), root_box_value);
+ rb_const_set(rb_cBox, rb_intern("MAIN"), main_box_value);
+
+ vm->root_box = root_box = rb_get_box_t(root_box_value);
+ vm->main_box = main_box = rb_get_box_t(main_box_value);
+
+ // create the writable classext of ::Object explicitly to finalize the set of visible top-level constants
+ RCLASS_EXT_WRITABLE_IN_BOX(rb_cObject, root_box);
+ RCLASS_EXT_WRITABLE_IN_BOX(rb_cObject, main_box);
+}
+
+static VALUE
+rb_box_inspect(VALUE obj)
+{
+ rb_box_t *box;
+ VALUE r;
+ if (obj == Qfalse) {
+ r = rb_str_new_cstr("#<Ruby::Box:master>");
+ return r;
+ }
+ box = rb_get_box_t(obj);
+ r = rb_str_new_cstr("#<Ruby::Box:");
+ rb_str_concat(r, rb_funcall(LONG2NUM(box->box_id), rb_intern("to_s"), 0));
+ if (BOX_MASTER_P(box)) {
+ rb_str_cat_cstr(r, ",master");
+ }
+ if (BOX_ROOT_P(box)) {
+ rb_str_cat_cstr(r, ",root");
+ }
+ if (BOX_USER_P(box)) {
+ rb_str_cat_cstr(r, ",user");
+ }
+ if (BOX_MAIN_P(box)) {
+ rb_str_cat_cstr(r, ",main");
+ }
+ else if (BOX_OPTIONAL_P(box)) {
+ rb_str_cat_cstr(r, ",optional");
+ }
+ rb_str_cat_cstr(r, ">");
+ return r;
+}
+
+static VALUE
+rb_box_loading_func(int argc, VALUE *argv, VALUE _self)
+{
+ rb_vm_frame_flag_set_box_require(GET_EC());
+ return rb_call_super(argc, argv);
+}
+
+static void
+box_define_loader_method(const char *name)
+{
+ rb_define_private_method(rb_mBoxLoader, name, rb_box_loading_func, -1);
+ rb_define_singleton_method(rb_mBoxLoader, name, rb_box_loading_func, -1);
+}
+
+void
+Init_master_box(void)
+{
+ master_box->loading_table = st_init_strtable();
+}
+
+void
+Init_enable_box(void)
+{
+ const char *env = getenv("RUBY_BOX");
+ if (env && strlen(env) == 1 && env[0] == '1') {
+ ruby_box_enabled = true;
+ }
+ else {
+ ruby_box_init_done = true;
+ }
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_s_master(VALUE recv)
+{
+ return master_box->box_object;
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_s_root(VALUE recv)
+{
+ return root_box->box_object;
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_s_main(VALUE recv)
+{
+ return main_box->box_object;
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_master_p(VALUE box_value)
+{
+ const rb_box_t *box = (const rb_box_t *)rb_get_box_t(box_value);
+ return RBOOL(BOX_MASTER_P(box));
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_root_p(VALUE box_value)
+{
+ const rb_box_t *box = (const rb_box_t *)rb_get_box_t(box_value);
+ return RBOOL(BOX_ROOT_P(box));
+}
+
+/* :nodoc: */
+static VALUE
+rb_box_main_p(VALUE box_value)
+{
+ const rb_box_t *box = (const rb_box_t *)rb_get_box_t(box_value);
+ return RBOOL(BOX_MAIN_P(box));
+}
+
+#if RUBY_DEBUG
+
+static const char *
+classname(VALUE klass)
+{
+ VALUE p;
+ if (!klass) {
+ return "Qfalse";
+ }
+ p = RCLASSEXT_CLASSPATH(RCLASS_EXT_PRIME(klass));
+ if (RTEST(p))
+ return RSTRING_PTR(p);
+ if (RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS))
+ return "AnyClassValue";
+ return "NonClassValue";
+}
+
+static enum rb_id_table_iterator_result
+dump_classext_methods_i(ID mid, VALUE _val, void *data)
+{
+ VALUE ary = (VALUE)data;
+ rb_ary_push(ary, rb_id2str(mid));
+ return ID_TABLE_CONTINUE;
+}
+
+static enum rb_id_table_iterator_result
+dump_classext_constants_i(ID mid, VALUE _val, void *data)
+{
+ VALUE ary = (VALUE)data;
+ rb_ary_push(ary, rb_id2str(mid));
+ return ID_TABLE_CONTINUE;
+}
+
+static void
+dump_classext_i(rb_classext_t *ext, bool is_prime, VALUE _recv, void *data)
+{
+ char buf[4096];
+ struct rb_id_table *tbl;
+ VALUE ary, res = (VALUE)data;
+
+ snprintf(buf, 4096, "Ruby::Box %ld:%s classext %p\n",
+ RCLASSEXT_BOX(ext)->box_id, is_prime ? " prime" : "", (void *)ext);
+ rb_str_cat_cstr(res, buf);
+
+ snprintf(buf, 2048, " Super: %s\n", classname(RCLASSEXT_SUPER(ext)));
+ rb_str_cat_cstr(res, buf);
+
+ tbl = RCLASSEXT_M_TBL(ext);
+ if (tbl) {
+ ary = rb_ary_new_capa((long)rb_id_table_size(tbl));
+ rb_id_table_foreach(RCLASSEXT_M_TBL(ext), dump_classext_methods_i, (void *)ary);
+ rb_ary_sort_bang(ary);
+ snprintf(buf, 4096, " Methods(%ld): ", RARRAY_LEN(ary));
+ rb_str_cat_cstr(res, buf);
+ rb_str_concat(res, rb_ary_join(ary, rb_str_new_cstr(",")));
+ rb_str_cat_cstr(res, "\n");
+ }
+ else {
+ rb_str_cat_cstr(res, " Methods(0): .\n");
+ }
+
+ tbl = RCLASSEXT_CONST_TBL(ext);
+ if (tbl) {
+ ary = rb_ary_new_capa((long)rb_id_table_size(tbl));
+ rb_id_table_foreach(tbl, dump_classext_constants_i, (void *)ary);
+ rb_ary_sort_bang(ary);
+ snprintf(buf, 4096, " Constants(%ld): ", RARRAY_LEN(ary));
+ rb_str_cat_cstr(res, buf);
+ rb_str_concat(res, rb_ary_join(ary, rb_str_new_cstr(",")));
+ rb_str_cat_cstr(res, "\n");
+ }
+ else {
+ rb_str_cat_cstr(res, " Constants(0): .\n");
+ }
+}
+
+/* :nodoc: */
+static VALUE
+rb_f_dump_classext(VALUE recv, VALUE klass)
+{
+ /*
+ * The desired output String value is:
+ * Class: 0x88800932 (String) [singleton]
+ * Prime classext box(2,main), readable(t), writable(f)
+ * Non-prime classexts: 3
+ * Box 2: prime classext 0x88800933
+ * Super: Object
+ * Methods(43): aaaaa, bbbb, cccc, dddd, eeeee, ffff, gggg, hhhhh, ...
+ * Constants(12): FOO, Bar, ...
+ * Box 5: classext 0x88800934
+ * Super: Object
+ * Methods(43): aaaaa, bbbb, cccc, dddd, eeeee, ffff, gggg, hhhhh, ...
+ * Constants(12): FOO, Bar, ...
+ */
+ char buf[2048];
+ VALUE res;
+ const rb_classext_t *ext;
+ const rb_box_t *box;
+ st_table *classext_tbl;
+
+ if (!(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE))) {
+ snprintf(buf, 2048, "Non-class/module value: %p (%s)\n", (void *)klass, rb_type_str(BUILTIN_TYPE(klass)));
+ return rb_str_new_cstr(buf);
+ }
+
+ if (RB_TYPE_P(klass, T_CLASS)) {
+ snprintf(buf, 2048, "Class: %p (%s)%s\n",
+ (void *)klass, classname(klass), RCLASS_SINGLETON_P(klass) ? " [singleton]" : "");
+ }
+ else {
+ snprintf(buf, 2048, "Module: %p (%s)\n", (void *)klass, classname(klass));
+ }
+ res = rb_str_new_cstr(buf);
+
+ ext = RCLASS_EXT_PRIME(klass);
+ box = RCLASSEXT_BOX(ext);
+ snprintf(buf, 2048, "Prime classext box(%ld,%s), readable(%s), writable(%s)\n",
+ box->box_id,
+ BOX_MASTER_P(box) ? "master" : (BOX_ROOT_P(box) ? "root" : (BOX_MAIN_P(box) ? "main" : "optional")),
+ RCLASS_PRIME_CLASSEXT_READABLE_P(klass) ? "t" : "f",
+ RCLASS_PRIME_CLASSEXT_WRITABLE_P(klass) ? "t" : "f");
+ rb_str_cat_cstr(res, buf);
+
+ classext_tbl = RCLASS_CLASSEXT_TBL(klass);
+ if (!classext_tbl) {
+ rb_str_cat_cstr(res, "Non-prime classexts: 0\n");
+ }
+ else {
+ snprintf(buf, 2048, "Non-prime classexts: %zu\n", st_table_size(classext_tbl));
+ rb_str_cat_cstr(res, buf);
+ }
+
+ rb_class_classext_foreach(klass, dump_classext_i, (void *)res);
+
+ return res;
+}
+
+#endif /* RUBY_DEBUG */
+
+/*
+ * Document-class: Ruby::Box
+ *
+ * :markup: markdown
+ * :include: doc/language/box.md
+ */
+void
+Init_Box(void)
+{
+ tmp_dir = system_tmpdir();
+ tmp_dir_has_dirsep = (strcmp(tmp_dir + (strlen(tmp_dir) - strlen(DIRSEP)), DIRSEP) == 0);
+
+ VALUE mRuby = rb_define_module("Ruby");
+
+ rb_cBox = rb_define_class_under(mRuby, "Box", rb_cModule);
+ rb_define_method(rb_cBox, "initialize", box_initialize, 0);
+
+ /* :nodoc: */
+ rb_cBoxEntry = rb_define_class_under(rb_cBox, "Entry", rb_cObject);
+ rb_define_alloc_func(rb_cBoxEntry, rb_box_entry_alloc);
+
+ initialize_master_box();
+
+ /* :nodoc: */
+ rb_mBoxLoader = rb_define_module_under(rb_cBox, "Loader");
+ box_define_loader_method("require");
+ box_define_loader_method("require_relative");
+ box_define_loader_method("load");
+
+ if (rb_box_available()) {
+ rb_include_module(rb_cObject, rb_mBoxLoader);
+
+ rb_define_singleton_method(rb_cBox, "master", rb_box_s_master, 0);
+ rb_define_singleton_method(rb_cBox, "root", rb_box_s_root, 0);
+ rb_define_singleton_method(rb_cBox, "main", rb_box_s_main, 0);
+ rb_define_method(rb_cBox, "master?", rb_box_master_p, 0);
+ rb_define_method(rb_cBox, "root?", rb_box_root_p, 0);
+ rb_define_method(rb_cBox, "main?", rb_box_main_p, 0);
+
+#if RUBY_DEBUG
+ rb_define_global_function("dump_classext", rb_f_dump_classext, 1);
+#endif
+ }
+
+ rb_define_singleton_method(rb_cBox, "enabled?", rb_box_s_getenabled, 0);
+ rb_define_singleton_method(rb_cBox, "current", rb_box_s_current, 0);
+
+ rb_define_method(rb_cBox, "load_path", rb_box_load_path, 0);
+ rb_define_method(rb_cBox, "load", rb_box_load, -1);
+ rb_define_method(rb_cBox, "require", rb_box_require, 1);
+ rb_define_method(rb_cBox, "require_relative", rb_box_require_relative, 1);
+ rb_define_method(rb_cBox, "eval", rb_box_eval, 1);
+
+ rb_define_method(rb_cBox, "inspect", rb_box_inspect, 0);
+}
diff --git a/builtin.c b/builtin.c
index 1709922fec..03c9d03bc3 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1,17 +1,18 @@
#include "internal.h"
+#include "internal/box.h"
#include "vm_core.h"
#include "iseq.h"
#include "builtin.h"
-#ifdef CROSS_COMPILING
+#include "builtin_binary.rbbin"
-#define INCLUDED_BY_BUILTIN_C 1
+#ifndef BUILTIN_BINARY_SIZE
+
+#define BUILTIN_LOADED(feature_name, iseq) ((void)0)
#include "mini_builtin.c"
#else
-#include "builtin_binary.inc"
-
static const unsigned char *
bin4feature(const struct builtin_binary *bb, const char *feature, size_t *psize)
{
@@ -22,42 +23,103 @@ bin4feature(const struct builtin_binary *bb, const char *feature, size_t *psize)
static const unsigned char*
builtin_lookup(const char *feature, size_t *psize)
{
- static int index = 0;
- const unsigned char *bin = bin4feature(&builtin_binary[index++], feature, psize);
+ static size_t index = 0;
+ const unsigned char *bin = NULL;
+
+ /*
+ * Fast path:
+ * builtin_binary is usually arranged in the same order
+ * as features are looked up in miniruby, so try the next entry first.
+ */
+ if (builtin_binary[index].feature) {
+ bin = bin4feature(&builtin_binary[index], feature, psize);
+ index++;
+ }
+ if (bin) {
+ return bin;
+ }
- // usually, `builtin_binary` order is loading order at miniruby.
- for (const struct builtin_binary *bb = &builtin_binary[0]; bb->feature &&! bin; bb++) {
- bin = bin4feature(bb++, feature, psize);
+ /*
+ * Fallback:
+ * In case the lookup order does not match the array order,
+ * scan the entire table to find the feature.
+ */
+ for (const struct builtin_binary *bb = &builtin_binary[0];
+ bb->feature;
+ bb++) {
+ bin = bin4feature(bb, feature, psize);
+ if (bin) {
+ break;
+ }
}
+
return bin;
}
-void
-rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
+static void
+load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table, const rb_box_t *target_box)
{
// search binary
size_t size;
const unsigned char *bin = builtin_lookup(feature_name, &size);
if (! bin) {
- rb_bug("builtin_lookup: can not find %s\n", feature_name);
+ rb_bug("builtin_lookup: can not find %s", feature_name);
}
// load binary
rb_vm_t *vm = GET_VM();
if (vm->builtin_function_table != NULL) rb_bug("vm->builtin_function_table should be NULL.");
vm->builtin_function_table = table;
- vm->builtin_inline_index = 0;
const rb_iseq_t *iseq = rb_iseq_ibf_load_bytes((const char *)bin, size);
ASSUME(iseq); // otherwise an exception should have raised
vm->builtin_function_table = NULL;
// exec
- rb_iseq_eval(rb_iseq_check(iseq));
+ rb_iseq_eval(rb_iseq_check(iseq), target_box);
+}
+
+void
+rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
+{
+ load_with_builtin_functions(feature_name, table, rb_root_box());
+}
+
+VALUE
+rb_define_gem_modules(VALUE flags_value, VALUE _)
+{
+ rb_box_gem_flags_t *flags = (rb_box_gem_flags_t *)flags_value;
+
+ if (flags->gem) {
+ rb_define_module("Gem");
+ if (flags->error_highlight) {
+ rb_define_module("ErrorHighlight");
+ }
+ if (flags->did_you_mean) {
+ rb_define_module("DidYouMean");
+ }
+ if (flags->syntax_suggest) {
+ rb_define_module("SyntaxSuggest");
+ }
+ }
+
+ return Qnil;
+}
+
+void
+rb_load_gem_prelude(VALUE box)
+{
+ load_with_builtin_functions("gem_prelude", NULL, (const rb_box_t *)box);
}
#endif
void
+rb_free_loaded_builtin_table(void)
+{
+ // do nothing
+}
+
+void
Init_builtin(void)
{
// nothing
@@ -66,5 +128,13 @@ Init_builtin(void)
void
Init_builtin_features(void)
{
- rb_load_with_builtin_functions("gem_prelude", NULL);
+
+#ifdef BUILTIN_BINARY_SIZE
+
+ rb_load_gem_prelude((VALUE)rb_root_box());
+
+ rb_load_gem_prelude((VALUE)rb_main_box());
+
+#endif
+
}
diff --git a/builtin.h b/builtin.h
index 85fd1a009a..ffd2aad88e 100644
--- a/builtin.h
+++ b/builtin.h
@@ -15,12 +15,14 @@ struct rb_builtin_function {
#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) {\
.name = _i < 0 ? NULL : #_name, \
- .func_ptr = (void *)_fname, \
+ .func_ptr = (void *)(uintptr_t)_fname, \
.argc = _arity, \
.index = _i, \
}
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
+VALUE rb_define_gem_modules(VALUE, VALUE);
+void rb_load_gem_prelude(VALUE box);
#ifndef rb_execution_context_t
typedef struct rb_execution_context_struct rb_execution_context_t;
@@ -106,6 +108,14 @@ rb_vm_lvar(rb_execution_context_t *ec, int index)
#endif
}
+static inline VALUE
+rb_builtin_basic_definition_p(rb_execution_context_t *ec, VALUE klass, VALUE id_sym)
+{
+ return rb_method_basic_definition_p(klass, rb_sym2id(id_sym)) ? Qtrue : Qfalse;
+}
+
+#define LOCAL_PTR(local) local ## __ptr
+
// dump/load
struct builtin_binary {
diff --git a/ccan/list/list.h b/ccan/list/list.h
index 30b2af04e9..bf692a6937 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -635,14 +635,16 @@ static inline void ccan_list_prepend_list_(struct ccan_list_head *to,
/* internal macros, do not use directly */
#define ccan_list_for_each_off_dir_(h, i, off, dir) \
- for (i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
+ for (i = 0, \
+ i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
(off)); \
ccan_list_node_from_off_((void *)i, (off)) != &(h)->n; \
i = ccan_list_node_to_off_(ccan_list_node_from_off_((void *)i, (off))->dir, \
(off)))
#define ccan_list_for_each_safe_off_dir_(h, i, nxt, off, dir) \
- for (i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
+ for (i = 0, \
+ i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
(off)), \
nxt = ccan_list_node_to_off_(ccan_list_node_from_off_(i, (off))->dir, \
(off)); \
diff --git a/class.c b/class.c
index e4c1905ae0..02078cc9bc 100644
--- a/class.c
+++ b/class.c
@@ -21,6 +21,7 @@
#include "debug_counter.h"
#include "id_table.h"
#include "internal.h"
+#include "internal/box.h"
#include "internal/class.h"
#include "internal/eval.h"
#include "internal/hash.h"
@@ -29,233 +30,689 @@
#include "internal/variable.h"
#include "ruby/st.h"
#include "vm_core.h"
+#include "ruby/ractor.h"
+#include "yjit.h"
+#include "zjit.h"
+
+/* Flags of T_CLASS
+ *
+ * 0: RCLASS_IS_ROOT
+ * The class has been added to the VM roots. Will always be marked and pinned.
+ * This is done for classes defined from C to allow storing them in global variables.
+ * 1: RUBY_FL_SINGLETON
+ * This class is a singleton class.
+ * 2: RCLASS_PRIME_CLASSEXT_WRITABLE
+ * This class's prime classext is the only classext and writable from any boxes.
+ * If unset, the prime classext is writable only from the root box.
+ * 3: RCLASS_IS_INITIALIZED
+ * Class has been initialized.
+ * 4: RCLASS_BOXABLE
+ * Is a builtin class that may be boxed. It larger than a normal class.
+ */
+
+/* Flags of T_ICLASS
+ *
+ * 2: RCLASS_PRIME_CLASSEXT_WRITABLE
+ * This module's prime classext is the only classext and writable from any boxes.
+ * If unset, the prime classext is writable only from the root box.
+ * 4: RCLASS_BOXABLE
+ * Is a builtin class that may be boxed. It larger than a normal class.
+ */
+
+/* Flags of T_MODULE
+ *
+ * 0: RCLASS_IS_ROOT
+ * The class has been added to the VM roots. Will always be marked and pinned.
+ * This is done for classes defined from C to allow storing them in global variables.
+ * 1: <reserved>
+ * Ensures that RUBY_FL_SINGLETON is never set on a T_MODULE. See `rb_class_real`.
+ * 2: RCLASS_PRIME_CLASSEXT_WRITABLE
+ * This module's prime classext is the only classext and writable from any boxes.
+ * If unset, the prime classext is writable only from the root box.
+ * 3: RCLASS_IS_INITIALIZED
+ * Module has been initialized.
+ * 4: RCLASS_BOXABLE
+ * Is a builtin class that may be boxed. It larger than a normal class.
+ * 5: RMODULE_IS_REFINEMENT
+ * Module is used for refinements.
+ */
#define METACLASS_OF(k) RBASIC(k)->klass
#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
-RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
+rb_classext_t *
+rb_class_unlink_classext(VALUE klass, const rb_box_t *box)
+{
+ st_data_t ext;
+ st_data_t key = (st_data_t)box->box_object;
+ st_delete(box->classext_cow_classes, &klass, 0);
+ st_delete(RCLASS_CLASSEXT_TBL(klass), &key, &ext);
+ return (rb_classext_t *)ext;
+}
-static rb_subclass_entry_t *
-push_subclass_entry_to_list(VALUE super, VALUE klass)
+void
+rb_class_classext_free(VALUE klass, rb_classext_t *ext, bool is_prime)
{
- rb_subclass_entry_t *entry, *head;
+ struct rb_id_table *tbl;
- entry = ZALLOC(rb_subclass_entry_t);
- entry->klass = klass;
+ rb_id_table_free(RCLASSEXT_M_TBL(ext));
- head = RCLASS_SUBCLASSES(super);
- if (!head) {
- head = ZALLOC(rb_subclass_entry_t);
- RCLASS_SUBCLASSES(super) = head;
+ if (!RCLASSEXT_SHARED_CONST_TBL(ext) && (tbl = RCLASSEXT_CONST_TBL(ext)) != NULL) {
+ rb_free_const_table(tbl);
}
- entry->next = head->next;
- entry->prev = head;
- if (head->next) {
- head->next->prev = entry;
+ if (RCLASSEXT_SUPERCLASSES_WITH_SELF(ext)) {
+ RUBY_ASSERT(is_prime); // superclasses should only be used on prime
+ size_t depth = RCLASSEXT_SUPERCLASS_DEPTH(ext);
+ if (depth != RCLASS_MAX_SUPERCLASS_DEPTH) {
+ depth++;
+ }
+ SIZED_FREE_N(RCLASSEXT_SUPERCLASSES(ext), depth);
}
- head->next = entry;
- return entry;
+ if (!is_prime) { // the prime classext will be freed with RClass
+ SIZED_FREE(ext);
+ }
}
void
-rb_class_subclass_add(VALUE super, VALUE klass)
+rb_iclass_classext_free(VALUE klass, rb_classext_t *ext, bool is_prime)
{
- if (super && !UNDEF_P(super)) {
- rb_subclass_entry_t *entry = push_subclass_entry_to_list(super, klass);
- RCLASS_SUBCLASS_ENTRY(klass) = entry;
+ if (RCLASSEXT_ICLASS_IS_ORIGIN(ext) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext)) {
+ /* Method table is not shared for origin iclasses of classes */
+ rb_id_table_free(RCLASSEXT_M_TBL(ext));
+ }
+
+ if (RCLASSEXT_CALLABLE_M_TBL(ext) != NULL) {
+ rb_id_table_free(RCLASSEXT_CALLABLE_M_TBL(ext));
+ }
+
+ if (!is_prime) { // the prime classext will be freed with RClass
+ SIZED_FREE(ext);
}
}
static void
-rb_module_add_to_subclasses_list(VALUE module, VALUE iclass)
+iclass_free_orphan_classext(VALUE klass, rb_classext_t *ext)
{
- rb_subclass_entry_t *entry = push_subclass_entry_to_list(module, iclass);
- RCLASS_MODULE_SUBCLASS_ENTRY(iclass) = entry;
+ if (RCLASSEXT_ICLASS_IS_ORIGIN(ext) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext)) {
+ /* Method table is not shared for origin iclasses of classes */
+ rb_id_table_free(RCLASSEXT_M_TBL(ext));
+ }
+
+ if (RCLASSEXT_CALLABLE_M_TBL(ext) != NULL) {
+ rb_id_table_free(RCLASSEXT_CALLABLE_M_TBL(ext));
+ }
+
+ SIZED_FREE(ext);
}
-void
-rb_class_remove_subclass_head(VALUE klass)
+struct rb_class_set_box_classext_args {
+ VALUE obj;
+ rb_classext_t *ext;
+};
+
+static int
+set_box_classext_update(st_data_t *key_ptr, st_data_t *val_ptr, st_data_t a, int existing)
{
- rb_subclass_entry_t *head = RCLASS_SUBCLASSES(klass);
+ struct rb_class_set_box_classext_args *args = (struct rb_class_set_box_classext_args *)a;
- if (head) {
- if (head->next) {
- head->next->prev = NULL;
+ if (existing) {
+ if (LIKELY(BUILTIN_TYPE(args->obj) == T_ICLASS)) {
+ iclass_free_orphan_classext(args->obj, (rb_classext_t *)*val_ptr);
+ }
+ else {
+ rb_bug("Updating existing classext for non-iclass never happen");
}
- RCLASS_SUBCLASSES(klass) = NULL;
- xfree(head);
}
+
+ *val_ptr = (st_data_t)args->ext;
+
+ return ST_CONTINUE;
}
void
-rb_class_remove_from_super_subclasses(VALUE klass)
+rb_class_set_box_classext(VALUE obj, const rb_box_t *box, rb_classext_t *ext)
{
- rb_subclass_entry_t *entry = RCLASS_SUBCLASS_ENTRY(klass);
+ struct rb_class_set_box_classext_args args = {
+ .obj = obj,
+ .ext = ext,
+ };
- if (entry) {
- rb_subclass_entry_t *prev = entry->prev, *next = entry->next;
+ VM_ASSERT(BOX_MUTABLE_P(box));
- if (prev) {
- prev->next = next;
- }
- if (next) {
- next->prev = prev;
- }
+ st_update(RCLASS_CLASSEXT_TBL(obj), (st_data_t)box->box_object, set_box_classext_update, (st_data_t)&args);
- xfree(entry);
+ // The classext references are now visible via the classext table,
+ // so we must issue the write barrier before any further allocations
+ // (e.g. st_insert below) that could trigger GC.
+ rb_gc_writebarrier_remember(obj);
+
+ st_insert(box->classext_cow_classes, (st_data_t)obj, 0);
+}
+
+RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
+
+struct duplicate_id_tbl_data {
+ struct rb_id_table *tbl;
+ VALUE klass;
+};
+
+static enum rb_id_table_iterator_result
+duplicate_classext_m_tbl_i(ID key, VALUE value, void *data)
+{
+ struct duplicate_id_tbl_data *arg = (struct duplicate_id_tbl_data *)data;
+ rb_method_entry_t *me = (rb_method_entry_t *)value;
+ rb_method_table_insert0(arg->klass, arg->tbl, key, me, false);
+ return ID_TABLE_CONTINUE;
+}
+
+static struct rb_id_table *
+duplicate_classext_m_tbl(struct rb_id_table *orig, VALUE klass, bool init_missing)
+{
+ struct rb_id_table *tbl;
+ if (!orig) {
+ if (init_missing)
+ return rb_id_table_create(0);
+ else
+ return NULL;
}
+ tbl = rb_id_table_create(rb_id_table_size(orig));
+ struct duplicate_id_tbl_data data = {
+ .tbl = tbl,
+ .klass = klass,
+ };
+ rb_id_table_foreach(orig, duplicate_classext_m_tbl_i, &data);
+ return tbl;
+}
+
+static rb_const_entry_t *
+duplicate_classext_const_entry(rb_const_entry_t *src, VALUE klass)
+{
+ // See also: setup_const_entry (variable.c)
+ rb_const_entry_t *dst = ZALLOC(rb_const_entry_t);
+
+ dst->flag = src->flag;
+ dst->line = src->line;
+ RB_OBJ_WRITE(klass, &dst->value, src->value);
+ RB_OBJ_WRITE(klass, &dst->file, src->file);
- RCLASS_SUBCLASS_ENTRY(klass) = NULL;
+ return dst;
}
-void
-rb_class_remove_from_module_subclasses(VALUE klass)
+static enum rb_id_table_iterator_result
+duplicate_classext_const_tbl_i(ID key, VALUE value, void *data)
{
- rb_subclass_entry_t *entry = RCLASS_MODULE_SUBCLASS_ENTRY(klass);
+ struct duplicate_id_tbl_data *arg = (struct duplicate_id_tbl_data *)data;
+ rb_const_entry_t *entry = duplicate_classext_const_entry((rb_const_entry_t *)value, arg->klass);
- if (entry) {
- rb_subclass_entry_t *prev = entry->prev, *next = entry->next;
+ rb_id_table_insert(arg->tbl, key, (VALUE)entry);
- if (prev) {
- prev->next = next;
- }
- if (next) {
- next->prev = prev;
- }
+ return ID_TABLE_CONTINUE;
+}
+
+static struct rb_id_table *
+duplicate_classext_const_tbl(struct rb_id_table *src, VALUE klass)
+{
+ struct rb_id_table *dst;
+
+ if (!src)
+ return NULL;
- xfree(entry);
+ dst = rb_id_table_create(rb_id_table_size(src));
+
+ struct duplicate_id_tbl_data data = {
+ .tbl = dst,
+ .klass = klass,
+ };
+ rb_id_table_foreach(src, duplicate_classext_const_tbl_i, (void *)&data);
+
+ return dst;
+}
+
+static void
+class_duplicate_iclass_classext(VALUE iclass, rb_classext_t *mod_ext, const rb_box_t *box)
+{
+ RUBY_ASSERT(RB_TYPE_P(iclass, T_ICLASS));
+
+ rb_classext_t *src = RCLASS_EXT_PRIME(iclass);
+ rb_classext_t *ext = RCLASS_EXT_TABLE_LOOKUP_INTERNAL(iclass, box);
+ int first_set = 0;
+
+ if (ext) {
+ // iclass classext for the ns is only for cc/callable_m_tbl if it's created earlier than module's one
+ rb_invalidate_method_caches(RCLASSEXT_CALLABLE_M_TBL(ext), RCLASSEXT_CC_TBL(ext));
}
- RCLASS_MODULE_SUBCLASS_ENTRY(klass) = NULL;
+ ext = ZALLOC(rb_classext_t);
+
+ RCLASSEXT_BOX(ext) = box;
+
+ RCLASSEXT_SUPER(ext) = RCLASSEXT_SUPER(src);
+
+ // See also: rb_include_class_new()
+ if (RCLASSEXT_ICLASS_IS_ORIGIN(src) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(src)) {
+ RCLASSEXT_M_TBL(ext) = duplicate_classext_m_tbl(RCLASSEXT_M_TBL(src), iclass, true);
+ }
+ else {
+ RCLASSEXT_M_TBL(ext) = RCLASSEXT_M_TBL(mod_ext);
+ }
+
+ RCLASSEXT_CONST_TBL(ext) = RCLASSEXT_CONST_TBL(mod_ext);
+ RCLASSEXT_CVC_TBL(ext) = RCLASSEXT_CVC_TBL(mod_ext);
+
+ // Those are cache and should be recreated when methods are called
+ // RCLASSEXT_CALLABLE_M_TBL(ext) = NULL;
+ // RCLASSEXT_CC_TBL(ext) = NULL;
+
+ // Subclasses/back-pointers are only in the prime classext.
+
+ RCLASSEXT_SET_ORIGIN(ext, iclass, RCLASSEXT_ORIGIN(src));
+ RCLASSEXT_ICLASS_IS_ORIGIN(ext) = RCLASSEXT_ICLASS_IS_ORIGIN(src);
+ RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext) = RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(src);
+
+ RCLASSEXT_SET_INCLUDER(ext, iclass, RCLASSEXT_INCLUDER(src));
+
+ VM_ASSERT(FL_TEST_RAW(iclass, RCLASS_BOXABLE));
+
+ first_set = RCLASS_SET_BOX_CLASSEXT(iclass, box, ext);
+ if (first_set) {
+ RCLASS_SET_PRIME_CLASSEXT_WRITABLE(iclass, false);
+ }
}
-void
-rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE arg)
+rb_classext_t *
+rb_class_duplicate_classext(rb_classext_t *orig, VALUE klass, const rb_box_t *box)
{
- // RCLASS_SUBCLASSES should always point to our head element which has NULL klass
- rb_subclass_entry_t *cur = RCLASS_SUBCLASSES(klass);
- // if we have a subclasses list, then the head is a placeholder with no valid
- // class. So ignore it and use the next element in the list (if one exists)
- if (cur) {
- RUBY_ASSERT(!cur->klass);
- cur = cur->next;
+ VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS));
+
+ rb_classext_t *ext = ZALLOC(rb_classext_t);
+ bool dup_iclass = RB_TYPE_P(klass, T_MODULE) ? true : false;
+
+ RCLASSEXT_BOX(ext) = box;
+
+ RCLASSEXT_SUPER(ext) = RCLASSEXT_SUPER(orig);
+
+ RCLASSEXT_M_TBL(ext) = duplicate_classext_m_tbl(RCLASSEXT_M_TBL(orig), klass, dup_iclass);
+ RCLASSEXT_ICLASS_IS_ORIGIN(ext) = true;
+ RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext) = false;
+
+ if (orig->fields_obj) {
+ RB_OBJ_WRITE(klass, &ext->fields_obj, rb_imemo_fields_clone(orig->fields_obj));
+ }
+
+ if (RCLASSEXT_SHARED_CONST_TBL(orig)) {
+ RCLASSEXT_CONST_TBL(ext) = RCLASSEXT_CONST_TBL(orig);
+ RCLASSEXT_SHARED_CONST_TBL(ext) = true;
+ }
+ else {
+ RCLASSEXT_CONST_TBL(ext) = duplicate_classext_const_tbl(RCLASSEXT_CONST_TBL(orig), klass);
+ RCLASSEXT_SHARED_CONST_TBL(ext) = false;
+ }
+ /*
+ * callable_m_tbl is for `super` chain, and entries will be created when the super chain is called.
+ * so initially, it can be NULL and let it be created lazily.
+ * RCLASSEXT_CALLABLE_M_TBL(ext) = NULL;
+ *
+ * cc_tbl is for method inline cache, and method calls from different boxes never occur on
+ * the same code, so the copied classext should have a different cc_tbl from the prime one.
+ * RCLASSEXT_CC_TBL(copy) = NULL
+ */
+
+ VALUE cvc_table = RCLASSEXT_CVC_TBL(orig);
+ if (cvc_table) {
+ cvc_table = rb_marked_id_table_dup(cvc_table);
+ }
+ else if (dup_iclass) {
+ cvc_table = rb_marked_id_table_new(2);
+ }
+ RB_OBJ_WRITE(klass, &RCLASSEXT_CVC_TBL(ext), cvc_table);
+
+ // Subclasses/back-pointers are only in the prime classext.
+
+ RCLASSEXT_SET_ORIGIN(ext, klass, RCLASSEXT_ORIGIN(orig));
+ /*
+ * Members not copied to box's classext values
+ * * refined_class
+ * * as.class.allocator / as.singleton_class.attached_object
+ * * includer
+ * * max IV count
+ * * variation count
+ */
+ RCLASSEXT_PERMANENT_CLASSPATH(ext) = RCLASSEXT_PERMANENT_CLASSPATH(orig);
+ RCLASSEXT_CLASSPATH(ext) = RCLASSEXT_CLASSPATH(orig);
+
+ /* For the usual T_CLASS/T_MODULE, iclass flags are always false */
+
+ if (dup_iclass) {
+ /*
+ * ICLASS has the same m_tbl/const_tbl/cvc_tbl with the included module.
+ * So the module's classext is copied, its tables should be also referred
+ * by the ICLASS's classext for the box.
+ *
+ * Subclasses are only in the prime classext, so read from orig.
+ */
+ VALUE subs_v = RCLASSEXT_SUBCLASSES(orig);
+ if (subs_v) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)subs_v;
+ VALUE *entries = rb_imemo_subclasses_entries(subs_v);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ VALUE iclass = entries[i];
+ if (!iclass) continue;
+
+ /* every node in the subclass list should be an ICLASS built from this module */
+ VM_ASSERT(RB_TYPE_P(iclass, T_ICLASS));
+ VM_ASSERT(RBASIC_CLASS(iclass) == klass);
+
+ if (FL_TEST_RAW(iclass, RCLASS_BOXABLE)) {
+ // Non-boxable ICLASSes (included by classes in main/user boxes) can't
+ // hold per-box classexts, and their includer classes also can't, so
+ // method lookup through them always uses the prime classext.
+ class_duplicate_iclass_classext(iclass, ext, box);
+ }
+ }
+ }
}
- /* do not be tempted to simplify this loop into a for loop, the order of
- operations is important here if `f` modifies the linked list */
- while (cur) {
- VALUE curklass = cur->klass;
- cur = cur->next;
- // do not trigger GC during f, otherwise the cur will become
- // a dangling pointer if the subclass is collected
- f(curklass, arg);
+ return ext;
+}
+
+void
+rb_class_ensure_writable(VALUE klass)
+{
+ VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS));
+ RCLASS_EXT_WRITABLE(klass);
+}
+
+struct class_classext_foreach_arg {
+ rb_class_classext_foreach_callback_func *func;
+ void * callback_arg;
+};
+
+static int
+class_classext_foreach_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ struct class_classext_foreach_arg *foreach_arg = (struct class_classext_foreach_arg *)arg;
+ rb_class_classext_foreach_callback_func *func = foreach_arg->func;
+ func((rb_classext_t *)value, false, (VALUE)key, foreach_arg->callback_arg);
+ return ST_CONTINUE;
+}
+
+void
+rb_class_classext_foreach(VALUE klass, rb_class_classext_foreach_callback_func *func, void *arg)
+{
+ st_table *tbl = RCLASS_CLASSEXT_TBL(klass);
+ struct class_classext_foreach_arg foreach_arg;
+ if (tbl) {
+ foreach_arg.func = func;
+ foreach_arg.callback_arg = arg;
+ rb_st_foreach(tbl, class_classext_foreach_i, (st_data_t)&foreach_arg);
}
+ func(RCLASS_EXT_PRIME(klass), true, (VALUE)NULL, arg);
+}
+
+VALUE
+rb_class_super_of(VALUE klass)
+{
+ return RCLASS_SUPER(klass);
+}
+
+VALUE
+rb_class_singleton_p(VALUE klass)
+{
+ return RCLASS_SINGLETON_P(klass);
+}
+
+unsigned char
+rb_class_variation_count(VALUE klass)
+{
+ return RCLASS_VARIATION_COUNT(klass);
}
static void
-class_detach_subclasses(VALUE klass, VALUE arg)
+push_subclass_entry_to_list(VALUE super, VALUE klass)
{
- rb_class_remove_from_super_subclasses(klass);
+ RUBY_ASSERT(
+ (RB_TYPE_P(super, T_MODULE) && RB_TYPE_P(klass, T_ICLASS)) ||
+ (RB_TYPE_P(super, T_CLASS) && RB_TYPE_P(klass, T_CLASS)) ||
+ (RB_TYPE_P(klass, T_ICLASS) && !NIL_P(RCLASS_REFINED_CLASS(klass)))
+ );
+
+ RB_VM_LOCKING() {
+ VALUE subs_v = RCLASS_SUBCLASSES(super);
+ struct rb_subclasses *subs = (struct rb_subclasses *)subs_v;
+
+ if (!subs || subs->count == subs->capacity) {
+ VALUE *old_entries = subs ? rb_imemo_subclasses_entries(subs_v) : NULL;
+ uint32_t live = 0;
+ for (uint32_t i = 0; subs && i < subs->count; i++) {
+ if (old_entries[i]) live++;
+ }
+
+ uint32_t cap = subs ? subs->capacity : 2;
+ if (live * 2 >= cap) cap *= 2;
+
+ VALUE new_v = rb_imemo_subclasses_new(cap);
+ struct rb_subclasses *new_subs = (struct rb_subclasses *)new_v;
+ VALUE *new_entries = rb_imemo_subclasses_entries(new_v);
+ for (uint32_t i = 0; subs && i < subs->count; i++) {
+ VALUE entry = old_entries[i];
+ if (entry) {
+ new_entries[new_subs->count++] = entry;
+ RB_OBJ_WRITTEN(new_v, Qundef, entry);
+ }
+ }
+ RCLASS_SET_SUBCLASSES(super, new_v);
+ subs_v = new_v;
+ subs = new_subs;
+ }
+
+ rb_imemo_subclasses_entries(subs_v)[subs->count++] = klass;
+ RB_OBJ_WRITTEN(subs_v, Qundef, klass);
+ }
}
void
-rb_class_detach_subclasses(VALUE klass)
+rb_class_subclass_add(VALUE super, VALUE klass)
{
- rb_class_foreach_subclass(klass, class_detach_subclasses, Qnil);
+ if (super && !UNDEF_P(super)) {
+ RUBY_ASSERT(RB_TYPE_P(super, T_CLASS) || RB_TYPE_P(super, T_MODULE));
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_ICLASS));
+ push_subclass_entry_to_list(super, klass);
+ }
}
static void
-class_detach_module_subclasses(VALUE klass, VALUE arg)
+rb_module_add_to_subclasses_list(VALUE module, VALUE iclass)
{
- rb_class_remove_from_module_subclasses(klass);
+ if (module && !UNDEF_P(module)) {
+ RUBY_ASSERT(RB_TYPE_P(module, T_MODULE));
+ RUBY_ASSERT(RB_TYPE_P(iclass, T_ICLASS));
+ push_subclass_entry_to_list(module, iclass);
+ }
}
void
-rb_class_detach_module_subclasses(VALUE klass)
+rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE arg)
{
- rb_class_foreach_subclass(klass, class_detach_module_subclasses, Qnil);
+ VALUE subs_v = RCLASS_SUBCLASSES(klass);
+ if (!subs_v) return;
+
+ struct rb_subclasses *subs = (struct rb_subclasses *)subs_v;
+ VALUE *entries = rb_imemo_subclasses_entries(subs_v);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ VALUE curklass = entries[i];
+ if (curklass) {
+ f(curklass, arg);
+ }
+ }
+}
+
+static void
+class_switch_superclass(VALUE super, VALUE klass)
+{
+ // No need to remove from old super's subclasses list — the GC
+ // will nullify the weak reference when appropriate.
+ rb_class_subclass_add(super, klass);
}
/**
- * Allocates a struct RClass for a new class.
+ * Allocates a struct RClass for a new class, iclass, or module.
*
- * \param flags initial value for basic.flags of the returned class.
- * \param klass the class of the returned class.
- * \return an uninitialized Class object.
- * \pre \p klass must refer \c Class class or an ancestor of Class.
- * \pre \code (flags | T_CLASS) != 0 \endcode
- * \post the returned class can safely be \c #initialize 'd.
+ * @param type The type of the RClass (T_CLASS, T_ICLASS, or T_MODULE)
+ * @param klass value for basic.klass of the returned object.
+ * @return an uninitialized Class/IClass/Module object.
+ * @pre `klass` must refer to a class or module
*
- * \note this function is not Class#allocate.
+ * @note this function is not Class#allocate.
*/
static VALUE
-class_alloc(VALUE flags, VALUE klass)
+class_alloc0(enum ruby_value_type type, VALUE klass, bool boxable)
{
- size_t alloc_size = sizeof(struct RClass);
+ const rb_box_t *box = rb_current_box();
-#if RCLASS_EXT_EMBEDDED
- alloc_size += sizeof(rb_classext_t);
-#endif
+ if (!ruby_box_init_done) {
+ boxable = true;
+ }
- flags &= T_MASK;
- flags |= FL_PROMOTED1 /* start from age == 2 */;
- if (RGENGC_WB_PROTECTED_CLASS) flags |= FL_WB_PROTECTED;
- RVARGC_NEWOBJ_OF(obj, struct RClass, klass, flags, alloc_size);
+ size_t alloc_size = sizeof(struct RClass_and_rb_classext_t);
+ if (boxable) {
+ alloc_size = sizeof(struct RClass_boxable);
+ }
-#if RCLASS_EXT_EMBEDDED
- memset(RCLASS_EXT(obj), 0, sizeof(rb_classext_t));
-#else
- obj->ptr = ZALLOC(rb_classext_t);
-#endif
+ RUBY_ASSERT(type == T_CLASS || type == T_ICLASS || type == T_MODULE);
+
+ VALUE flags = type | FL_SHAREABLE;
+ if (boxable) flags |= RCLASS_BOXABLE;
+
+ shape_id_t shape_id = ROOT_SHAPE_ID;
+ if (boxable) {
+ shape_id |= SHAPE_ID_LAYOUT_OTHER;
+ }
+ else {
+ shape_id |= SHAPE_ID_LAYOUT_RCLASS;
+ }
+
+ struct RClass *obj = (struct RClass *)rb_newobj(GET_EC(), klass, flags, shape_id, true, alloc_size);
+
+ obj->object_id = 0;
+
+ memset(RCLASS_EXT_PRIME(obj), 0, sizeof(rb_classext_t));
/* ZALLOC
RCLASS_CONST_TBL(obj) = 0;
RCLASS_M_TBL(obj) = 0;
- RCLASS_IV_INDEX_TBL(obj) = 0;
+ RCLASS_FIELDS(obj) = 0;
RCLASS_SET_SUPER((VALUE)obj, 0);
- RCLASS_SUBCLASSES(obj) = NULL;
- RCLASS_PARENT_SUBCLASSES(obj) = NULL;
- RCLASS_MODULE_SUBCLASSES(obj) = NULL;
*/
+
+ if (boxable) {
+ ((struct RClass_boxable *)obj)->box_classext_tbl = NULL;
+ }
+
+ RCLASS_PRIME_BOX((VALUE)obj) = box;
+ // Classes/Modules defined in user boxes are
+ // writable directly because it exists only in a box.
+ RCLASS_SET_PRIME_CLASSEXT_WRITABLE((VALUE)obj, !boxable || BOX_USER_P(box));
+
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
- RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil);
- RCLASS_SET_ALLOCATOR((VALUE)obj, NULL);
+ RCLASS_SET_REFINED_CLASS((VALUE)obj, Qnil);
return (VALUE)obj;
}
+static VALUE
+class_alloc(enum ruby_value_type type, VALUE klass)
+{
+ bool boxable = rb_box_available() && BOX_MASTER_P(rb_current_box());
+ return class_alloc0(type, klass, boxable);
+}
+
+static VALUE
+class_associate_super(VALUE klass, VALUE super, bool init)
+{
+ if (super && !UNDEF_P(super)) {
+ // Only maintain subclass lists for T_CLASS→T_CLASS relationships.
+ // Include/prepend inserts ICLASSes into the super chain, but T_CLASS
+ // subclass lists should track only the immutable T_CLASS→T_CLASS link.
+ if (RB_TYPE_P(klass, T_CLASS) && RB_TYPE_P(super, T_CLASS)) {
+ if (RCLASS_SINGLETON_P(klass)) {
+ // Instead of adding singleton classes to the subclass list,
+ // just set a flag so that method cache invalidation takes the
+ // tree path.
+ FL_SET_RAW(super, RCLASS_HAS_SUBCLASSES);
+ }
+ else {
+ class_switch_superclass(super, klass);
+ }
+ }
+ }
+ if (init) {
+ RCLASS_SET_SUPER(klass, super);
+ }
+ else {
+ RCLASS_WRITE_SUPER(klass, super);
+ }
+ rb_class_update_superclasses(klass);
+ return super;
+}
+
+VALUE
+rb_class_set_super(VALUE klass, VALUE super)
+{
+ return class_associate_super(klass, super, false);
+}
+
static void
-RCLASS_M_TBL_INIT(VALUE c)
+class_initialize_method_table(VALUE c)
{
- RCLASS_M_TBL(c) = rb_id_table_create(0);
+ // initialize the prime classext m_tbl
+ RCLASS_SET_M_TBL(c, rb_id_table_create(0));
}
-/*!
+static void
+class_clear_method_table(VALUE c)
+{
+ RCLASS_WRITE_M_TBL(c, rb_id_table_create(0));
+}
+
+static VALUE
+class_boot_boxable(VALUE super, bool boxable)
+{
+ VALUE klass = class_alloc0(T_CLASS, rb_cClass, boxable);
+
+ // initialize method table prior to class_associate_super()
+ // because class_associate_super() may cause GC and promote klass
+ class_initialize_method_table(klass);
+
+ class_associate_super(klass, super, true);
+ if (super && !UNDEF_P(super)) {
+ RCLASS_SET_ALLOCATOR(klass, RCLASS_ALLOCATOR(super));
+ rb_class_set_initialized(klass);
+ }
+
+ return (VALUE)klass;
+}
+
+/**
* A utility function that wraps class_alloc.
*
* allocates a class and initializes safely.
- * \param super a class from which the new class derives.
- * \return a class object.
- * \pre \a super must be a class.
- * \post the metaclass of the new class is Class.
+ * @param super a class from which the new class derives.
+ * @return a class object.
+ * @pre `super` must be a class.
+ * @post the metaclass of the new class is Class.
*/
VALUE
rb_class_boot(VALUE super)
{
- VALUE klass = class_alloc(T_CLASS, rb_cClass);
-
- RCLASS_SET_SUPER(klass, super);
- RCLASS_M_TBL_INIT(klass);
-
- return (VALUE)klass;
+ return class_boot_boxable(super, false);
}
static VALUE *
class_superclasses_including_self(VALUE klass)
{
- if (FL_TEST_RAW(klass, RCLASS_SUPERCLASSES_INCLUDE_SELF))
+ if (RCLASS_SUPERCLASSES_WITH_SELF_P(klass))
return RCLASS_SUPERCLASSES(klass);
size_t depth = RCLASS_SUPERCLASS_DEPTH(klass);
@@ -264,14 +721,14 @@ class_superclasses_including_self(VALUE klass)
memcpy(superclasses, RCLASS_SUPERCLASSES(klass), sizeof(VALUE) * depth);
superclasses[depth] = klass;
- RCLASS_SUPERCLASSES(klass) = superclasses;
- FL_SET_RAW(klass, RCLASS_SUPERCLASSES_INCLUDE_SELF);
return superclasses;
}
void
rb_class_update_superclasses(VALUE klass)
{
+ VALUE *superclasses;
+ size_t super_depth;
VALUE super = RCLASS_SUPER(klass);
if (!RB_TYPE_P(klass, T_CLASS)) return;
@@ -300,8 +757,17 @@ rb_class_update_superclasses(VALUE klass)
return;
}
- RCLASS_SUPERCLASSES(klass) = class_superclasses_including_self(super);
- RCLASS_SUPERCLASS_DEPTH(klass) = RCLASS_SUPERCLASS_DEPTH(super) + 1;
+ super_depth = RCLASS_SUPERCLASS_DEPTH(super);
+ if (RCLASS_SUPERCLASSES_WITH_SELF_P(super)) {
+ superclasses = RCLASS_SUPERCLASSES(super);
+ }
+ else {
+ superclasses = class_superclasses_including_self(super);
+ RCLASS_WRITE_SUPERCLASSES(super, super_depth, superclasses, true);
+ }
+
+ size_t depth = super_depth == RCLASS_MAX_SUPERCLASS_DEPTH ? super_depth : super_depth + 1;
+ RCLASS_WRITE_SUPERCLASSES(klass, depth, superclasses, false);
}
void
@@ -311,7 +777,7 @@ rb_check_inheritable(VALUE super)
rb_raise(rb_eTypeError, "superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
rb_obj_class(super));
}
- if (RBASIC(super)->flags & FL_SINGLETON) {
+ if (RCLASS_SINGLETON_P(super)) {
rb_raise(rb_eTypeError, "can't make subclass of singleton class");
}
if (super == rb_cClass) {
@@ -326,9 +792,8 @@ rb_class_new(VALUE super)
rb_check_inheritable(super);
VALUE klass = rb_class_boot(super);
- if (super != rb_cObject && super != rb_cBasicObject) {
- RCLASS_EXT(klass)->max_iv_count = RCLASS_EXT(super)->max_iv_count;
- }
+ RCLASS_SET_MAX_IV_COUNT(klass, RCLASS_MAX_IV_COUNT(super));
+ RUBY_ASSERT(getenv("RUBY_BOX") || RCLASS_PRIME_CLASSEXT_WRITABLE_P(klass));
return klass;
}
@@ -340,28 +805,20 @@ rb_class_s_alloc(VALUE klass)
}
static void
-clone_method(VALUE old_klass, VALUE new_klass, ID mid, const rb_method_entry_t *me)
+clone_method(VALUE new_klass, ID mid, const rb_method_entry_t *me)
{
- if (me->def->type == VM_METHOD_TYPE_ISEQ) {
- rb_cref_t *new_cref;
- rb_vm_rewrite_cref(me->def->body.iseq.cref, old_klass, new_klass, &new_cref);
- rb_add_method_iseq(new_klass, mid, me->def->body.iseq.iseqptr, new_cref, METHOD_ENTRY_VISI(me));
- }
- else {
- rb_method_entry_set(new_klass, mid, me, METHOD_ENTRY_VISI(me));
- }
+ rb_method_entry_set(new_klass, mid, me, METHOD_ENTRY_VISI(me));
}
struct clone_method_arg {
VALUE new_klass;
- VALUE old_klass;
};
static enum rb_id_table_iterator_result
clone_method_i(ID key, VALUE value, void *data)
{
const struct clone_method_arg *arg = (struct clone_method_arg *)data;
- clone_method(arg->old_klass, arg->new_klass, key, (const rb_method_entry_t *)value);
+ clone_method(arg->new_klass, key, (const rb_method_entry_t *)value);
return ID_TABLE_CONTINUE;
}
@@ -394,19 +851,25 @@ class_init_copy_check(VALUE clone, VALUE orig)
if (orig == rb_cBasicObject) {
rb_raise(rb_eTypeError, "can't copy the root class");
}
- if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) {
+ if (RCLASS_INITIALIZED_P(clone)) {
rb_raise(rb_eTypeError, "already initialized class");
}
- if (FL_TEST(orig, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(orig)) {
rb_raise(rb_eTypeError, "can't copy singleton class");
}
}
struct cvc_table_copy_ctx {
VALUE clone;
- struct rb_id_table * new_table;
+ VALUE new_table;
};
+static struct rb_cvar_class_tbl_entry *
+cvc_table_entry_alloc(void)
+{
+ return (struct rb_cvar_class_tbl_entry *)SHAREABLE_IMEMO_NEW(struct rb_cvar_class_tbl_entry, imemo_cvar_entry, 0);
+}
+
static enum rb_id_table_iterator_result
cvc_table_copy(ID id, VALUE val, void *data)
{
@@ -416,10 +879,11 @@ cvc_table_copy(ID id, VALUE val, void *data)
struct rb_cvar_class_tbl_entry *ent;
- ent = ALLOC(struct rb_cvar_class_tbl_entry);
- ent->class_value = ctx->clone;
+ ent = cvc_table_entry_alloc();
+ RB_OBJ_WRITE((VALUE)ent, &ent->class_value, ctx->clone);
+ RB_OBJ_WRITE(ctx->clone, &ent->cref, orig_entry->cref);
ent->global_cvar_state = orig_entry->global_cvar_state;
- rb_id_table_insert(ctx->new_table, id, (VALUE)ent);
+ rb_marked_id_table_insert(ctx->new_table, id, (VALUE)ent);
return ID_TABLE_CONTINUE;
}
@@ -429,61 +893,49 @@ copy_tables(VALUE clone, VALUE orig)
{
if (RCLASS_CONST_TBL(clone)) {
rb_free_const_table(RCLASS_CONST_TBL(clone));
- RCLASS_CONST_TBL(clone) = 0;
+ RCLASS_WRITE_CONST_TBL(clone, 0, false);
}
if (RCLASS_CVC_TBL(orig)) {
- struct rb_id_table *rb_cvc_tbl = RCLASS_CVC_TBL(orig);
- struct rb_id_table *rb_cvc_tbl_dup = rb_id_table_create(rb_id_table_size(rb_cvc_tbl));
+ VALUE rb_cvc_tbl = RCLASS_CVC_TBL(orig);
+ VALUE rb_cvc_tbl_dup = rb_marked_id_table_new(rb_marked_id_table_size(rb_cvc_tbl));
struct cvc_table_copy_ctx ctx;
ctx.clone = clone;
ctx.new_table = rb_cvc_tbl_dup;
- rb_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
- RCLASS_CVC_TBL(clone) = rb_cvc_tbl_dup;
+ rb_marked_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
+ RCLASS_WRITE_CVC_TBL(clone, rb_cvc_tbl_dup);
}
- RCLASS_M_TBL(clone) = 0;
+ rb_id_table_free(RCLASS_M_TBL(clone));
+ RCLASS_WRITE_M_TBL(clone, 0);
if (!RB_TYPE_P(clone, T_ICLASS)) {
- st_data_t id;
-
- rb_iv_tbl_copy(clone, orig);
- CONST_ID(id, "__tmp_classpath__");
- rb_attr_delete(clone, id);
- CONST_ID(id, "__classpath__");
- rb_attr_delete(clone, id);
+ rb_fields_tbl_copy(clone, orig);
}
if (RCLASS_CONST_TBL(orig)) {
struct clone_const_arg arg;
-
- arg.tbl = RCLASS_CONST_TBL(clone) = rb_id_table_create(0);
+ struct rb_id_table *const_tbl;
+ struct rb_id_table *orig_tbl = RCLASS_CONST_TBL(orig);
+ arg.tbl = const_tbl = rb_id_table_create(rb_id_table_size(orig_tbl));
arg.klass = clone;
- rb_id_table_foreach(RCLASS_CONST_TBL(orig), clone_const_i, &arg);
+ rb_id_table_foreach(orig_tbl, clone_const_i, &arg);
+ RCLASS_WRITE_CONST_TBL(clone, const_tbl, false);
+ rb_gc_writebarrier_remember(clone);
}
}
static bool ensure_origin(VALUE klass);
-/**
- * If this flag is set, that module is allocated but not initialized yet.
- */
-enum {RMODULE_ALLOCATED_BUT_NOT_INITIALIZED = RUBY_FL_USER5};
-
-static inline bool
-RMODULE_UNINITIALIZED(VALUE module)
-{
- return FL_TEST_RAW(module, RMODULE_ALLOCATED_BUT_NOT_INITIALIZED);
-}
-
void
-rb_module_set_initialized(VALUE mod)
+rb_class_set_initialized(VALUE klass)
{
- FL_UNSET_RAW(mod, RMODULE_ALLOCATED_BUT_NOT_INITIALIZED);
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE));
+ FL_SET_RAW(klass, RCLASS_IS_INITIALIZED);
/* no more re-initialization */
}
void
rb_module_check_initializable(VALUE mod)
{
- if (!RMODULE_UNINITIALIZED(mod)) {
+ if (RCLASS_INITIALIZED_P(mod)) {
rb_raise(rb_eTypeError, "already initialized module");
}
}
@@ -492,9 +944,11 @@ rb_module_check_initializable(VALUE mod)
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
+ /* Only class or module is valid here, but other classes may enter here and
+ * only hit an exception on the OBJ_INIT_COPY checks
+ */
switch (BUILTIN_TYPE(clone)) {
case T_CLASS:
- case T_ICLASS:
class_init_copy_check(clone, orig);
break;
case T_MODULE:
@@ -505,28 +959,28 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
}
if (!OBJ_INIT_COPY(clone, orig)) return clone;
- /* cloned flag is refer at constant inline cache
- * see vm_get_const_key_cref() in vm_insnhelper.c
- */
- FL_SET(clone, RCLASS_CLONED);
- FL_SET(orig , RCLASS_CLONED);
+ RUBY_ASSERT(RB_TYPE_P(orig, T_CLASS) || RB_TYPE_P(orig, T_MODULE));
+ RUBY_ASSERT(BUILTIN_TYPE(clone) == BUILTIN_TYPE(orig));
- if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
+ rb_class_set_initialized(clone);
+
+ if (!RCLASS_SINGLETON_P(CLASS_OF(clone))) {
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig));
rb_singleton_class_attached(METACLASS_OF(clone), (VALUE)clone);
}
- RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig));
+ if (BUILTIN_TYPE(clone) == T_CLASS) {
+ RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig));
+ }
copy_tables(clone, orig);
if (RCLASS_M_TBL(orig)) {
struct clone_method_arg arg;
- arg.old_klass = orig;
arg.new_klass = clone;
- RCLASS_M_TBL_INIT(clone);
+ class_initialize_method_table(clone);
rb_id_table_foreach(RCLASS_M_TBL(orig), clone_method_i, &arg);
}
if (RCLASS_ORIGIN(orig) == orig) {
- RCLASS_SET_SUPER(clone, RCLASS_SUPER(orig));
+ rb_class_set_super(clone, RCLASS_SUPER(orig));
}
else {
VALUE p = RCLASS_SUPER(orig);
@@ -546,12 +1000,11 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
if (BUILTIN_TYPE(p) != T_ICLASS) {
rb_bug("non iclass between module/class and origin");
}
- clone_p = class_alloc(RBASIC(p)->flags, METACLASS_OF(p));
- RCLASS_SET_SUPER(prev_clone_p, clone_p);
+ clone_p = class_alloc(T_ICLASS, METACLASS_OF(p));
+ RCLASS_SET_M_TBL(clone_p, RCLASS_M_TBL(p));
+ rb_class_set_super(prev_clone_p, clone_p);
prev_clone_p = clone_p;
- RCLASS_M_TBL(clone_p) = RCLASS_M_TBL(p);
- RCLASS_CONST_TBL(clone_p) = RCLASS_CONST_TBL(p);
- RCLASS_SET_ALLOCATOR(clone_p, RCLASS_ALLOCATOR(p));
+ RCLASS_SET_CONST_TBL(clone_p, RCLASS_CONST_TBL(p), false);
if (RB_TYPE_P(clone, T_CLASS)) {
RCLASS_SET_INCLUDER(clone_p, clone);
}
@@ -563,8 +1016,8 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
}
else if ((origin_len = RARRAY_LEN(origin_stack)) > 1 &&
RARRAY_AREF(origin_stack, origin_len - 1) == p) {
- RCLASS_SET_ORIGIN(RARRAY_AREF(origin_stack, (origin_len -= 2)), clone_p);
- RICLASS_SET_ORIGIN_SHARED_MTBL(clone_p);
+ RCLASS_WRITE_ORIGIN(RARRAY_AREF(origin_stack, (origin_len -= 2)), clone_p);
+ RICLASS_WRITE_ORIGIN_SHARED_MTBL(clone_p);
rb_ary_resize(origin_stack, origin_len);
add_subclass = FALSE;
}
@@ -576,15 +1029,14 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
if (p == orig_origin) {
if (clone_p) {
- RCLASS_SET_SUPER(clone_p, clone_origin);
- RCLASS_SET_SUPER(clone_origin, RCLASS_SUPER(orig_origin));
+ rb_class_set_super(clone_p, clone_origin);
+ rb_class_set_super(clone_origin, RCLASS_SUPER(orig_origin));
}
copy_tables(clone_origin, orig_origin);
if (RCLASS_M_TBL(orig_origin)) {
struct clone_method_arg arg;
- arg.old_klass = orig;
arg.new_klass = clone;
- RCLASS_M_TBL_INIT(clone_origin);
+ class_initialize_method_table(clone_origin);
rb_id_table_foreach(RCLASS_M_TBL(orig_origin), clone_method_i, &arg);
}
}
@@ -614,14 +1066,15 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
// attached to an object other than `obj`. In which case `obj` does not have
// a material singleton class attached yet and there is no singleton class
// to clone.
- if (!(FL_TEST(klass, FL_SINGLETON) && RCLASS_ATTACHED_OBJECT(klass) == obj)) {
+ if (!(RCLASS_SINGLETON_P(klass) && RCLASS_ATTACHED_OBJECT(klass) == obj)) {
// nothing to clone
return klass;
}
else {
/* copy singleton(unnamed) class */
bool klass_of_clone_is_new;
- VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
+ VALUE clone = class_alloc(T_CLASS, 0);
if (BUILTIN_TYPE(obj) == T_CLASS) {
klass_of_clone_is_new = true;
@@ -635,21 +1088,24 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
RBASIC_SET_CLASS(clone, klass_metaclass_clone);
}
- RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass));
- rb_iv_tbl_copy(clone, klass);
+ // initialize method table before any GC chance
+ class_initialize_method_table(clone);
+
+ rb_class_set_super(clone, RCLASS_SUPER(klass));
+ rb_fields_tbl_copy(clone, klass);
if (RCLASS_CONST_TBL(klass)) {
struct clone_const_arg arg;
- arg.tbl = RCLASS_CONST_TBL(clone) = rb_id_table_create(0);
+ struct rb_id_table *table;
+ arg.tbl = table = rb_id_table_create(rb_id_table_size(RCLASS_CONST_TBL(klass)));
arg.klass = clone;
rb_id_table_foreach(RCLASS_CONST_TBL(klass), clone_const_i, &arg);
+ RCLASS_SET_CONST_TBL(clone, table, false);
}
if (!UNDEF_P(attach)) {
rb_singleton_class_attached(clone, attach);
}
- RCLASS_M_TBL_INIT(clone);
{
struct clone_method_arg arg;
- arg.old_klass = klass;
arg.new_klass = clone;
rb_id_table_foreach(RCLASS_M_TBL(klass), clone_method_i, &arg);
}
@@ -665,7 +1121,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
void
rb_singleton_class_attached(VALUE klass, VALUE obj)
{
- if (FL_TEST(klass, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(klass)) {
RCLASS_SET_ATTACHED_OBJECT(klass, obj);
}
}
@@ -690,7 +1146,7 @@ rb_singleton_class_internal_p(VALUE sklass)
!rb_singleton_class_has_metaclass_p(sklass));
}
-/*!
+/**
* whether k has a metaclass
* @retval 1 if \a k has a metaclass
* @retval 0 otherwise
@@ -699,31 +1155,31 @@ rb_singleton_class_internal_p(VALUE sklass)
(FL_TEST(METACLASS_OF(k), FL_SINGLETON) && \
rb_singleton_class_has_metaclass_p(k))
-/*!
- * ensures \a klass belongs to its own eigenclass.
- * @return the eigenclass of \a klass
- * @post \a klass belongs to the returned eigenclass.
- * i.e. the attached object of the eigenclass is \a klass.
+/**
+ * ensures `klass` belongs to its own eigenclass.
+ * @return the eigenclass of `klass`
+ * @post `klass` belongs to the returned eigenclass.
+ * i.e. the attached object of the eigenclass is `klass`.
* @note this macro creates a new eigenclass if necessary.
*/
#define ENSURE_EIGENCLASS(klass) \
(HAVE_METACLASS_P(klass) ? METACLASS_OF(klass) : make_metaclass(klass))
-/*!
- * Creates a metaclass of \a klass
- * \param klass a class
- * \return created metaclass for the class
- * \pre \a klass is a Class object
- * \pre \a klass has no singleton class.
- * \post the class of \a klass is the returned class.
- * \post the returned class is meta^(n+1)-class when \a klass is a meta^(n)-klass for n >= 0
+/**
+ * Creates a metaclass of `klass`
+ * @param klass a class
+ * @return created metaclass for the class
+ * @pre `klass` is a Class object
+ * @pre `klass` has no singleton class.
+ * @post the class of `klass` is the returned class.
+ * @post the returned class is meta^(n+1)-class when `klass` is a meta^(n)-klass for n >= 0
*/
static inline VALUE
make_metaclass(VALUE klass)
{
VALUE super;
- VALUE metaclass = rb_class_boot(Qundef);
+ VALUE metaclass = class_boot_boxable(Qundef, FL_TEST_RAW(klass, RCLASS_BOXABLE));
FL_SET(metaclass, FL_SINGLETON);
rb_singleton_class_attached(metaclass, klass);
@@ -740,7 +1196,8 @@ make_metaclass(VALUE klass)
super = RCLASS_SUPER(klass);
while (RB_TYPE_P(super, T_ICLASS)) super = RCLASS_SUPER(super);
- RCLASS_SET_SUPER(metaclass, super ? ENSURE_EIGENCLASS(super) : rb_cClass);
+ class_associate_super(metaclass, super ? ENSURE_EIGENCLASS(super) : rb_cClass, true);
+ rb_class_set_initialized(klass);
// Full class ancestry may not have been filled until we reach here.
rb_class_update_superclasses(METACLASS_OF(metaclass));
@@ -748,21 +1205,28 @@ make_metaclass(VALUE klass)
return metaclass;
}
-/*!
- * Creates a singleton class for \a obj.
- * \pre \a obj must not a immediate nor a special const.
- * \pre \a obj must not a Class object.
- * \pre \a obj has no singleton class.
+/**
+ * Creates a singleton class for `obj`.
+ * @pre `obj` must not be an immediate nor a special const.
+ * @pre `obj` must not be a Class object.
+ * @pre `obj` has no singleton class.
*/
static inline VALUE
make_singleton_class(VALUE obj)
{
VALUE orig_class = METACLASS_OF(obj);
- VALUE klass = rb_class_boot(orig_class);
-
+ VALUE klass = class_alloc0(T_CLASS, rb_cClass, FL_TEST_RAW(orig_class, RCLASS_BOXABLE));
FL_SET(klass, FL_SINGLETON);
+ class_initialize_method_table(klass);
+ class_associate_super(klass, orig_class, true);
+ if (orig_class && !UNDEF_P(orig_class)) {
+ rb_class_set_initialized(klass);
+ }
+
RBASIC_SET_CLASS(obj, klass);
rb_singleton_class_attached(klass, obj);
+ rb_yjit_invalidate_no_singleton_class(orig_class);
+ rb_zjit_invalidate_no_singleton_class(orig_class);
SET_METACLASS_OF(klass, METACLASS_OF(rb_class_real(orig_class)));
return klass;
@@ -776,7 +1240,7 @@ boot_defclass(const char *name, VALUE super)
ID id = rb_intern(name);
rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
- rb_vm_add_root_module(obj);
+ rb_vm_register_global_object(obj);
return obj;
}
@@ -857,8 +1321,12 @@ void
Init_class_hierarchy(void)
{
rb_cBasicObject = boot_defclass("BasicObject", 0);
+ RCLASS_SET_ALLOCATOR(rb_cBasicObject, rb_class_allocate_instance);
+ FL_SET_RAW(rb_cBasicObject, RCLASS_ALLOCATOR_DEFINED);
+ RCLASS_SET_EXPECT_NO_IVAR(rb_cBasicObject);
+
rb_cObject = boot_defclass("Object", rb_cBasicObject);
- rb_gc_register_mark_object(rb_cObject);
+ RCLASS_SET_EXPECT_NO_IVAR(rb_cObject);
/* resolve class name ASAP for order-independence */
rb_set_class_path_string(rb_cObject, rb_cObject, rb_fstring_lit("Object"));
@@ -883,15 +1351,15 @@ Init_class_hierarchy(void)
}
-/*!
- * \internal
+/**
+ * @internal
* Creates a new *singleton class* for an object.
*
- * \pre \a obj has no singleton class.
- * \note DO NOT USE the function in an extension libraries. Use \ref rb_singleton_class.
- * \param obj An object.
- * \param unused ignored.
- * \return The singleton class of the object.
+ * @pre `obj` has no singleton class.
+ * @note DO NOT USE the function in an extension libraries. Use @ref rb_singleton_class.
+ * @param obj An object.
+ * @param unused ignored.
+ * @return The singleton class of the object.
*/
VALUE
rb_make_metaclass(VALUE obj, VALUE unused)
@@ -917,13 +1385,13 @@ rb_define_class_id(ID id, VALUE super)
}
-/*!
+/**
* Calls Class#inherited.
- * \param super A class which will be called #inherited.
+ * @param super A class which will be called #inherited.
* NULL means Object class.
- * \param klass A Class object which derived from \a super
- * \return the value \c Class#inherited's returns
- * \pre Each of \a super and \a klass must be a \c Class object.
+ * @param klass A Class object which derived from `super`
+ * @return the value `Class#inherited` returns
+ * @pre Each of `super` and `klass` must be a `Class` object.
*/
VALUE
rb_class_inherited(VALUE super, VALUE klass)
@@ -938,9 +1406,8 @@ VALUE
rb_define_class(const char *name, VALUE super)
{
VALUE klass;
- ID id;
+ ID id = rb_intern(name);
- id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) {
klass = rb_const_get(rb_cObject, id);
if (!RB_TYPE_P(klass, T_CLASS)) {
@@ -952,14 +1419,14 @@ rb_define_class(const char *name, VALUE super)
}
/* Class may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(klass);
+ rb_vm_register_global_object(klass);
return klass;
}
if (!super) {
- rb_raise(rb_eArgError, "no super class for `%s'", name);
+ rb_raise(rb_eArgError, "no super class for '%s'", name);
}
klass = rb_define_class_id(id, super);
- rb_vm_add_root_module(klass);
+ rb_vm_register_global_object(klass);
rb_const_set(rb_cObject, id, klass);
rb_class_inherited(super, klass);
@@ -973,7 +1440,7 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super)
}
VALUE
-rb_define_class_id_under(VALUE outer, ID id, VALUE super)
+rb_define_class_id_under_no_pin(VALUE outer, ID id, VALUE super)
{
VALUE klass;
@@ -990,30 +1457,34 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
" (%"PRIsVALUE" is given but was %"PRIsVALUE")",
outer, rb_id2str(id), RCLASS_SUPER(klass), super);
}
- /* Class may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(klass);
return klass;
}
if (!super) {
- rb_raise(rb_eArgError, "no super class for `%"PRIsVALUE"::%"PRIsVALUE"'",
+ rb_raise(rb_eArgError, "no super class for '%"PRIsVALUE"::%"PRIsVALUE"'",
rb_class_path(outer), rb_id2str(id));
}
klass = rb_define_class_id(id, super);
rb_set_class_path_string(klass, outer, rb_id2str(id));
rb_const_set(outer, id, klass);
rb_class_inherited(super, klass);
- rb_vm_add_root_module(klass);
return klass;
}
VALUE
+rb_define_class_id_under(VALUE outer, ID id, VALUE super)
+{
+ VALUE klass = rb_define_class_id_under_no_pin(outer, id, super);
+ rb_vm_register_global_object(klass);
+ return klass;
+}
+
+VALUE
rb_module_s_alloc(VALUE klass)
{
VALUE mod = class_alloc(T_MODULE, klass);
- RCLASS_M_TBL_INIT(mod);
- FL_SET(mod, RMODULE_ALLOCATED_BUT_NOT_INITIALIZED);
+ class_initialize_method_table(mod);
return mod;
}
@@ -1021,7 +1492,7 @@ static inline VALUE
module_new(VALUE klass)
{
VALUE mdl = class_alloc(T_MODULE, klass);
- RCLASS_M_TBL_INIT(mdl);
+ class_initialize_method_table(mdl);
return (VALUE)mdl;
}
@@ -1048,9 +1519,8 @@ VALUE
rb_define_module(const char *name)
{
VALUE module;
- ID id;
+ ID id = rb_intern(name);
- id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) {
module = rb_const_get(rb_cObject, id);
if (!RB_TYPE_P(module, T_MODULE)) {
@@ -1058,11 +1528,11 @@ rb_define_module(const char *name)
name, rb_obj_class(module));
}
/* Module may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(module);
+ rb_vm_register_global_object(module);
return module;
}
module = rb_module_new();
- rb_vm_add_root_module(module);
+ rb_vm_register_global_object(module);
rb_const_set(rb_cObject, id, module);
return module;
@@ -1087,13 +1557,13 @@ rb_define_module_id_under(VALUE outer, ID id)
outer, rb_id2str(id), rb_obj_class(module));
}
/* Module may have been defined in Ruby and not pin-rooted */
- rb_gc_register_mark_object(module);
+ rb_vm_register_global_object(module);
return module;
}
module = rb_module_new();
rb_const_set(outer, id, module);
rb_set_class_path_string(module, outer, rb_id2str(id));
- rb_gc_register_mark_object(module);
+ rb_vm_register_global_object(module);
return module;
}
@@ -1103,21 +1573,24 @@ rb_include_class_new(VALUE module, VALUE super)
{
VALUE klass = class_alloc(T_ICLASS, rb_cClass);
- RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
+ RCLASS_SET_M_TBL(klass, RCLASS_WRITABLE_M_TBL(module));
RCLASS_SET_ORIGIN(klass, klass);
if (BUILTIN_TYPE(module) == T_ICLASS) {
module = METACLASS_OF(module);
}
RUBY_ASSERT(!RB_TYPE_P(module, T_ICLASS));
- if (!RCLASS_CONST_TBL(module)) {
- RCLASS_CONST_TBL(module) = rb_id_table_create(0);
+ if (RCLASS_WRITABLE_CONST_TBL(module)) {
+ RCLASS_SET_CONST_TBL(klass, RCLASS_WRITABLE_CONST_TBL(module), true);
+ }
+ else {
+ RCLASS_WRITE_CONST_TBL(module, rb_id_table_create(0), false);
+ RCLASS_SET_CONST_TBL(klass, RCLASS_WRITABLE_CONST_TBL(module), true);
}
- RCLASS_CVC_TBL(klass) = RCLASS_CVC_TBL(module);
- RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
+ RCLASS_SET_CVC_TBL(klass, RCLASS_WRITABLE_CVC_TBL(module));
- RCLASS_SET_SUPER(klass, super);
+ class_associate_super(klass, super, true);
RBASIC_SET_CLASS(klass, module);
return (VALUE)klass;
@@ -1130,7 +1603,7 @@ ensure_includable(VALUE klass, VALUE module)
{
rb_class_modify_check(klass);
Check_Type(module, T_MODULE);
- rb_module_set_initialized(module);
+ rb_class_set_initialized(module);
if (!NIL_P(rb_refinement_module_get_refined_class(module))) {
rb_raise(rb_eArgError, "refinement module is not allowed");
}
@@ -1148,35 +1621,34 @@ rb_include_module(VALUE klass, VALUE module)
rb_raise(rb_eArgError, "cyclic include detected");
if (RB_TYPE_P(klass, T_MODULE)) {
- rb_subclass_entry_t *iclass = RCLASS_SUBCLASSES(klass);
- // skip the placeholder subclass entry at the head of the list
- if (iclass) {
- RUBY_ASSERT(!iclass->klass);
- iclass = iclass->next;
- }
-
- int do_include = 1;
- while (iclass) {
- VALUE check_class = iclass->klass;
- /* During lazy sweeping, iclass->klass could be a dead object that
- * has not yet been swept. */
- if (!rb_objspace_garbage_object_p(check_class)) {
- while (check_class) {
- RUBY_ASSERT(!rb_objspace_garbage_object_p(check_class));
-
- if (RB_TYPE_P(check_class, T_ICLASS) &&
- (METACLASS_OF(check_class) == module)) {
- do_include = 0;
+ VALUE subs_v = RCLASS_SUBCLASSES(klass);
+ if (subs_v) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)subs_v;
+ VALUE *entries = rb_imemo_subclasses_entries(subs_v);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ VALUE check_class = entries[i];
+ if (!check_class) continue;
+
+ int do_include = 1;
+ /* During lazy sweeping, the entry could be a dead object that
+ * has not yet been swept. */
+ if (!rb_objspace_garbage_object_p(check_class)) {
+ VALUE walk = check_class;
+ while (walk) {
+ RUBY_ASSERT(!rb_objspace_garbage_object_p(walk));
+
+ if (RB_TYPE_P(walk, T_ICLASS) &&
+ (METACLASS_OF(walk) == module)) {
+ do_include = 0;
+ }
+ walk = RCLASS_SUPER(walk);
}
- check_class = RCLASS_SUPER(check_class);
- }
- if (do_include) {
- include_modules_at(iclass->klass, RCLASS_ORIGIN(iclass->klass), module, TRUE);
+ if (do_include) {
+ include_modules_at(check_class, RCLASS_ORIGIN(check_class), module, TRUE);
+ }
}
}
-
- iclass = iclass->next;
}
}
}
@@ -1223,7 +1695,7 @@ static int
do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super, bool check_cyclic)
{
VALUE p, iclass, origin_stack = 0;
- int method_changed = 0, add_subclass;
+ int method_changed = 0;
long origin_len;
VALUE klass_origin = RCLASS_ORIGIN(klass);
VALUE original_klass = klass;
@@ -1285,9 +1757,8 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super
// setup T_ICLASS for the include/prepend module
iclass = rb_include_class_new(module, super_class);
- c = RCLASS_SET_SUPER(c, iclass);
+ c = rb_class_set_super(c, iclass);
RCLASS_SET_INCLUDER(iclass, klass);
- add_subclass = TRUE;
if (module != RCLASS_ORIGIN(module)) {
if (!origin_stack) origin_stack = rb_ary_hidden_new(2);
VALUE origin[2] = {iclass, RCLASS_ORIGIN(module)};
@@ -1295,17 +1766,14 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super
}
else if (origin_stack && (origin_len = RARRAY_LEN(origin_stack)) > 1 &&
RARRAY_AREF(origin_stack, origin_len - 1) == module) {
- RCLASS_SET_ORIGIN(RARRAY_AREF(origin_stack, (origin_len -= 2)), iclass);
- RICLASS_SET_ORIGIN_SHARED_MTBL(iclass);
+ RCLASS_WRITE_ORIGIN(RARRAY_AREF(origin_stack, (origin_len -= 2)), iclass);
+ RICLASS_WRITE_ORIGIN_SHARED_MTBL(iclass);
rb_ary_resize(origin_stack, origin_len);
- add_subclass = FALSE;
}
- if (add_subclass) {
- VALUE m = module;
- if (BUILTIN_TYPE(m) == T_ICLASS) m = METACLASS_OF(m);
- rb_module_add_to_subclasses_list(m, iclass);
- }
+ VALUE m = module;
+ if (BUILTIN_TYPE(m) == T_ICLASS) m = METACLASS_OF(m);
+ rb_module_add_to_subclasses_list(m, iclass);
if (BUILTIN_TYPE(klass) == T_MODULE && FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
VALUE refined_class =
@@ -1338,7 +1806,7 @@ move_refined_method(ID key, VALUE value, void *data)
if (me->def->type == VM_METHOD_TYPE_REFINED) {
VALUE klass = (VALUE)data;
- struct rb_id_table *tbl = RCLASS_M_TBL(klass);
+ struct rb_id_table *tbl = RCLASS_WRITABLE_M_TBL(klass);
if (me->def->body.refined.orig_me) {
const rb_method_entry_t *orig_me = me->def->body.refined.orig_me, *new_me;
@@ -1379,11 +1847,16 @@ ensure_origin(VALUE klass)
VALUE origin = RCLASS_ORIGIN(klass);
if (origin == klass) {
origin = class_alloc(T_ICLASS, klass);
- RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass));
- RCLASS_SET_SUPER(klass, origin);
- RCLASS_SET_ORIGIN(klass, origin);
- RCLASS_M_TBL(origin) = RCLASS_M_TBL(klass);
- RCLASS_M_TBL_INIT(klass);
+ RCLASS_SET_M_TBL(origin, RCLASS_M_TBL(klass));
+ rb_class_set_super(origin, RCLASS_SUPER(klass));
+ rb_class_set_super(klass, origin); // writes origin into RCLASS_SUPER(klass)
+ RCLASS_WRITE_ORIGIN(klass, origin);
+
+ // RCLASS_WRITE_ORIGIN marks origin as an origin, so this is the first
+ // point that it sees M_TBL and may mark it
+ rb_gc_writebarrier_remember(origin);
+
+ class_clear_method_table(klass);
rb_id_table_foreach(RCLASS_M_TBL(origin), cache_clear_refined_method, (void *)klass);
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
return true;
@@ -1408,35 +1881,32 @@ rb_prepend_module(VALUE klass, VALUE module)
rb_vm_check_redefinition_by_prepend(klass);
}
if (RB_TYPE_P(klass, T_MODULE)) {
- rb_subclass_entry_t *iclass = RCLASS_SUBCLASSES(klass);
- // skip the placeholder subclass entry at the head of the list if it exists
- if (iclass) {
- RUBY_ASSERT(!iclass->klass);
- iclass = iclass->next;
- }
-
+ VALUE subs_v = RCLASS_SUBCLASSES(klass);
VALUE klass_origin = RCLASS_ORIGIN(klass);
struct rb_id_table *klass_m_tbl = RCLASS_M_TBL(klass);
struct rb_id_table *klass_origin_m_tbl = RCLASS_M_TBL(klass_origin);
- while (iclass) {
- /* During lazy sweeping, iclass->klass could be a dead object that
- * has not yet been swept. */
- if (!rb_objspace_garbage_object_p(iclass->klass)) {
- const VALUE subclass = iclass->klass;
- if (klass_had_no_origin && klass_origin_m_tbl == RCLASS_M_TBL(subclass)) {
- // backfill an origin iclass to handle refinements and future prepends
- rb_id_table_foreach(RCLASS_M_TBL(subclass), clear_module_cache_i, (void *)subclass);
- RCLASS_M_TBL(subclass) = klass_m_tbl;
- VALUE origin = rb_include_class_new(klass_origin, RCLASS_SUPER(subclass));
- RCLASS_SET_SUPER(subclass, origin);
- RCLASS_SET_INCLUDER(origin, RCLASS_INCLUDER(subclass));
- RCLASS_SET_ORIGIN(subclass, origin);
- RICLASS_SET_ORIGIN_SHARED_MTBL(origin);
+ if (subs_v) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)subs_v;
+ VALUE *entries = rb_imemo_subclasses_entries(subs_v);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ const VALUE subclass = entries[i];
+ if (!subclass) continue;
+ /* During lazy sweeping, the entry could be a dead object that
+ * has not yet been swept. */
+ if (!rb_objspace_garbage_object_p(subclass)) {
+ if (klass_had_no_origin && klass_origin_m_tbl == RCLASS_M_TBL(subclass)) {
+ // backfill an origin iclass to handle refinements and future prepends
+ rb_id_table_foreach(RCLASS_M_TBL(subclass), clear_module_cache_i, (void *)subclass);
+ RCLASS_WRITE_M_TBL(subclass, klass_m_tbl);
+ VALUE origin = rb_include_class_new(klass_origin, RCLASS_SUPER(subclass));
+ rb_class_set_super(subclass, origin);
+ RCLASS_SET_INCLUDER(origin, RCLASS_INCLUDER(subclass));
+ RCLASS_WRITE_ORIGIN(subclass, origin);
+ RICLASS_SET_ORIGIN_SHARED_MTBL(origin);
+ }
+ include_modules_at(subclass, subclass, module, FALSE);
}
- include_modules_at(subclass, subclass, module, FALSE);
}
-
- iclass = iclass->next;
}
}
}
@@ -1506,7 +1976,7 @@ rb_mod_include_p(VALUE mod, VALUE mod2)
Check_Type(mod2, T_MODULE);
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
- if (BUILTIN_TYPE(p) == T_ICLASS && !FL_TEST(p, RICLASS_IS_ORIGIN)) {
+ if (BUILTIN_TYPE(p) == T_ICLASS && !RICLASS_IS_ORIGIN_P(p)) {
if (METACLASS_OF(p) == mod2) return Qtrue;
}
}
@@ -1566,19 +2036,17 @@ class_descendants_recursive(VALUE klass, VALUE v)
{
struct subclass_traverse_data *data = (struct subclass_traverse_data *) v;
- if (BUILTIN_TYPE(klass) == T_CLASS && !FL_TEST(klass, FL_SINGLETON)) {
+ if (RB_TYPE_P(klass, T_ICLASS)) return; // skip refinement ICLASSes
+
+ if (!RCLASS_SINGLETON_P(klass)) {
if (data->buffer && data->count < data->maxcount && !rb_objspace_garbage_object_p(klass)) {
// assumes that this does not cause GC as long as the length does not exceed the capacity
rb_ary_push(data->buffer, klass);
}
data->count++;
- if (!data->immediate_only) {
- rb_class_foreach_subclass(klass, class_descendants_recursive, v);
- }
- }
- else {
- rb_class_foreach_subclass(klass, class_descendants_recursive, v);
+ if (data->immediate_only) return;
}
+ rb_class_foreach_subclass(klass, class_descendants_recursive, v);
}
static VALUE
@@ -1671,8 +2139,8 @@ rb_class_subclasses(VALUE klass)
VALUE
rb_class_attached_object(VALUE klass)
{
- if (!FL_TEST(klass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "`%"PRIsVALUE"' is not a singleton class", klass);
+ if (!RCLASS_SINGLETON_P(klass)) {
+ rb_raise(rb_eTypeError, "'%"PRIsVALUE"' is not a singleton class", klass);
}
return RCLASS_ATTACHED_OBJECT(klass);
@@ -1774,7 +2242,7 @@ static bool
particular_class_p(VALUE mod)
{
if (!mod) return false;
- if (FL_TEST(mod, FL_SINGLETON)) return true;
+ if (RCLASS_SINGLETON_P(mod)) return true;
if (BUILTIN_TYPE(mod) == T_ICLASS) return true;
return false;
}
@@ -2051,19 +2519,19 @@ rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj)
int recur = TRUE;
if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]);
- if (RB_TYPE_P(obj, T_CLASS) && FL_TEST(obj, FL_SINGLETON)) {
+ if (RB_TYPE_P(obj, T_CLASS) && RCLASS_SINGLETON_P(obj)) {
rb_singleton_class(obj);
}
klass = CLASS_OF(obj);
origin = RCLASS_ORIGIN(klass);
me_arg.list = st_init_numtable();
me_arg.recur = recur;
- if (klass && FL_TEST(klass, FL_SINGLETON)) {
+ if (klass && RCLASS_SINGLETON_P(klass)) {
if ((mtbl = RCLASS_M_TBL(origin)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
if (recur) {
- while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
+ while (klass && (RCLASS_SINGLETON_P(klass) || RB_TYPE_P(klass, T_ICLASS))) {
if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
@@ -2167,17 +2635,17 @@ rb_special_singleton_class(VALUE obj)
return special_singleton_class_of(obj);
}
-/*!
- * \internal
- * Returns the singleton class of \a obj. Creates it if necessary.
+/**
+ * @internal
+ * Returns the singleton class of `obj`. Creates it if necessary.
*
- * \note DO NOT expose the returned singleton class to
+ * @note DO NOT expose the returned singleton class to
* outside of class.c.
- * Use \ref rb_singleton_class instead for
+ * Use @ref rb_singleton_class instead for
* consistency of the metaclass hierarchy.
*/
static VALUE
-singleton_class_of(VALUE obj)
+singleton_class_of(VALUE obj, bool ensure_eigenclass)
{
VALUE klass;
@@ -2197,41 +2665,60 @@ singleton_class_of(VALUE obj)
return klass;
case T_STRING:
- if (FL_TEST_RAW(obj, RSTRING_FSTR)) {
+ if (CHILLED_STRING_P(obj)) {
+ CHILLED_STRING_MUTATED(obj);
+ }
+ else if (FL_TEST_RAW(obj, RSTRING_FSTR)) {
rb_raise(rb_eTypeError, "can't define singleton");
}
}
- klass = METACLASS_OF(obj);
- if (!(FL_TEST(klass, FL_SINGLETON) &&
- RCLASS_ATTACHED_OBJECT(klass) == obj)) {
- klass = rb_make_metaclass(obj, klass);
+ bool needs_lock = rb_multi_ractor_p() && rb_ractor_shareable_p(obj);
+ unsigned int lev;
+ if (needs_lock) {
+ RB_VM_LOCK_ENTER_LEV(&lev);
+ }
+ {
+ klass = METACLASS_OF(obj);
+ if (!(RCLASS_SINGLETON_P(klass) &&
+ RCLASS_ATTACHED_OBJECT(klass) == obj)) {
+ klass = rb_make_metaclass(obj, klass);
+ }
+ RB_FL_SET_RAW(klass, RB_OBJ_FROZEN_RAW(obj));
+ if (ensure_eigenclass && RB_TYPE_P(obj, T_CLASS)) {
+ /* ensures an exposed class belongs to its own eigenclass */
+ (void)ENSURE_EIGENCLASS(klass);
+ }
+ }
+ if (needs_lock) {
+ RB_VM_LOCK_LEAVE_LEV(&lev);
}
-
- RB_FL_SET_RAW(klass, RB_OBJ_FROZEN_RAW(obj));
return klass;
}
void
-rb_freeze_singleton_class(VALUE x)
-{
- /* should not propagate to meta-meta-class, and so on */
- if (!(RBASIC(x)->flags & FL_SINGLETON)) {
- VALUE klass = RBASIC_CLASS(x);
- if (klass && // no class when hidden from ObjectSpace
- FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) {
- OBJ_FREEZE_RAW(klass);
- }
+rb_freeze_singleton_class(VALUE attached_object)
+{
+ VALUE klass;
+
+ /* Freeze singleton classes of singleton class, as singleton class is frozen, and so on */
+ /* In each iteration, check the current object's class pointer is the singleton class of the object. */
+ while ((klass = RBASIC_CLASS(attached_object)) &&
+ FL_TEST_RAW(klass, FL_SINGLETON) &&
+ !OBJ_FROZEN_RAW(klass) &&
+ (RCLASS_ATTACHED_OBJECT(klass) == attached_object)) {
+ attached_object = klass;
+ OBJ_FREEZE(attached_object);
}
}
-/*!
- * Returns the singleton class of \a obj, or nil if obj is not a
+/**
+ * Returns the singleton class of `obj`, or nil if obj is not a
* singleton object.
*
- * \param obj an arbitrary object.
- * \return the singleton class or nil.
+ * @param obj an arbitrary object.
+ * @return the singleton class or nil.
*/
VALUE
rb_singleton_class_get(VALUE obj)
@@ -2242,7 +2729,7 @@ rb_singleton_class_get(VALUE obj)
return rb_special_singleton_class(obj);
}
klass = METACLASS_OF(obj);
- if (!FL_TEST(klass, FL_SINGLETON)) return Qnil;
+ if (!RCLASS_SINGLETON_P(klass)) return Qnil;
if (RCLASS_ATTACHED_OBJECT(klass) != obj) return Qnil;
return klass;
}
@@ -2250,12 +2737,7 @@ rb_singleton_class_get(VALUE obj)
VALUE
rb_singleton_class(VALUE obj)
{
- VALUE klass = singleton_class_of(obj);
-
- /* ensures an exposed class belongs to its own eigenclass */
- if (RB_TYPE_P(obj, T_CLASS)) (void)ENSURE_EIGENCLASS(klass);
-
- return klass;
+ return singleton_class_of(obj, true);
}
/*!
@@ -2273,7 +2755,7 @@ rb_singleton_class(VALUE obj)
void
rb_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc)
{
- rb_define_method(singleton_class_of(obj), name, func, argc);
+ rb_define_method(singleton_class_of(obj, false), name, func, argc);
}
#ifdef rb_define_module_function
diff --git a/common.mk b/common.mk
index 7f3fcff4b6..916484a6fe 100644
--- a/common.mk
+++ b/common.mk
@@ -1,10 +1,12 @@
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
+# This fragment can be used with nmake.exe and with bsdmake.
+# Avoid features specific to GNU Make.
bin: $(PROGRAM) $(WPROGRAM)
lib: $(LIBRUBY)
dll: $(LIBRUBY_SO)
-.SUFFIXES: .rbinc .rb .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
+.SUFFIXES: .rbinc .rbbin .rb .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
@@ -16,9 +18,10 @@ ECHO = @$(ECHO0)
mflags = $(MFLAGS)
gnumake_recursive =
+sequential = $(gnumake:yes=-sequential)
enable_shared = $(ENABLE_SHARED:no=)
-UNICODE_VERSION = 15.0.0
+UNICODE_VERSION = 17.0.0
UNICODE_EMOJI_VERSION_0 = $(UNICODE_VERSION)///
UNICODE_EMOJI_VERSION_1 = $(UNICODE_EMOJI_VERSION_0:.0///=)
UNICODE_EMOJI_VERSION = $(UNICODE_EMOJI_VERSION_1:///=)
@@ -41,9 +44,14 @@ RUBYLIB = $(PATH_SEPARATOR)
RUBYOPT = -
RUN_OPTS = --disable-gems
+GIT_IN_SRC = $(GIT) -C $(srcdir)
+GIT_LOG = $(GIT_IN_SRC) log --no-show-signature
+GIT_LOG_FORMAT = $(GIT_LOG) "--pretty=format:"
+
# GITPULLOPTIONS = --no-tags
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(UNICODE_HDR_DIR)
+PRISM_SRCDIR = $(srcdir)/prism
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(ext_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(PRISM_SRCDIR) -I$(UNICODE_HDR_DIR) $(incflags)
GEM_HOME =
GEM_PATH =
@@ -61,32 +69,79 @@ LIBRUBY_EXTS = ./.libruby-with-ext.time
REVISION_H = ./.revision.time
PLATFORM_D = $(TIMESTAMPDIR)/.$(PLATFORM_DIR).time
ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-trans.time
-RDOC = $(XRUBY) "$(srcdir)/libexec/rdoc" --root "$(srcdir)" --encoding=UTF-8 --all
+yes_cross_compiling = $(CROSS_COMPILING:no=)
+X_$(CROSS_COMPILING:yes=)BASERUBY = $(BASERUBY)
+X_$(CROSS_COMPILING:no=)BASERUBY = $(XRUBY)
+RDOC = $(X_BASERUBY) --enable-gems "$(tooldir)/rdoc-srcdir"
RDOCOUT = $(EXTOUT)/rdoc
HTMLOUT = $(EXTOUT)/html
CAPIOUT = doc/capi
INSTALL_DOC_OPTS = --rdoc-output="$(RDOCOUT)" --html-output="$(HTMLOUT)"
-RDOC_GEN_OPTS = --page-dir "$(srcdir)/doc" --no-force-update \
- --title "Documentation for Ruby $(RUBY_API_VERSION)" \
- --main README.md
+RDOC_GEN_OPTS = --no-force-update \
+ --exclude '^lib/rubygems/core_ext/kernel_require\.rb$$' \
+ $(empty)
+RDOC_SERVER_PORT = 4000
INITOBJS = dmyext.$(OBJEXT) dmyenc.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT)
MAINOBJ = $(NORMALMAINOBJ)
DLDOBJS = $(INITOBJS)
EXTSOLIBS =
-MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT) dmyext.$(OBJEXT)
+MINIOBJS = $(ARCHMINIOBJS) miniinit.$(OBJEXT)
ENC_MK = enc.mk
MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
RUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BOOTSTRAPRUBY)" $(mflags)
-COMMONOBJS = array.$(OBJEXT) \
+PRISM_BUILD_DIR = prism
+
+LIBPRISM_OBJS = \
+ prism/arena.$(OBJEXT) \
+ prism/buffer.$(OBJEXT) \
+ prism/char.$(OBJEXT) \
+ prism/constant_pool.$(OBJEXT) \
+ prism/diagnostic.$(OBJEXT) \
+ prism/encoding.$(OBJEXT) \
+ prism/integer.$(OBJEXT) \
+ prism/json.$(OBJEXT) \
+ prism/line_offset_list.$(OBJEXT) \
+ prism/list.$(OBJEXT) \
+ prism/memchr.$(OBJEXT) \
+ prism/node.$(OBJEXT) \
+ prism/options.$(OBJEXT) \
+ prism/parser.$(OBJEXT) \
+ prism/prettyprint.$(OBJEXT) \
+ prism/prism.$(OBJEXT) \
+ prism/regexp.$(OBJEXT) \
+ prism/serialize.$(OBJEXT) \
+ prism/source.$(OBJEXT) \
+ prism/static_literals.$(OBJEXT) \
+ prism/string_query.$(OBJEXT) \
+ prism/stringy.$(OBJEXT) \
+ prism/strncasecmp.$(OBJEXT) \
+ prism/strpbrk.$(OBJEXT) \
+ prism/tokens.$(OBJEXT)
+
+EXTPRISM_OBJS = prism/api_node.$(OBJEXT) \
+ prism/extension.$(OBJEXT) \
+ prism_init.$(OBJEXT)
+
+PRISM_OBJS = $(LIBPRISM_OBJS) $(EXTPRISM_OBJS)
+
+# Prism objects depend on generated headers that are created from templates.
+# This must be declared here to ensure parallel builds don't compile prism
+# sources before the generated headers exist.
+$(LIBPRISM_OBJS): $(srcdir)/prism/ast.h $(srcdir)/prism/internal/diagnostic.h
+
+COMMONOBJS = \
+ array.$(OBJEXT) \
ast.$(OBJEXT) \
bignum.$(OBJEXT) \
+ box.$(OBJEXT) \
class.$(OBJEXT) \
compar.$(OBJEXT) \
compile.$(OBJEXT) \
complex.$(OBJEXT) \
+ concurrent_set.$(OBJEXT) \
cont.$(OBJEXT) \
debug.$(OBJEXT) \
debug_counter.$(OBJEXT) \
@@ -100,6 +155,7 @@ COMMONOBJS = array.$(OBJEXT) \
file.$(OBJEXT) \
gc.$(OBJEXT) \
hash.$(OBJEXT) \
+ imemo.$(OBJEXT) \
inits.$(OBJEXT) \
io.$(OBJEXT) \
io_buffer.$(OBJEXT) \
@@ -108,13 +164,14 @@ COMMONOBJS = array.$(OBJEXT) \
marshal.$(OBJEXT) \
math.$(OBJEXT) \
memory_view.$(OBJEXT) \
- rjit.$(OBJEXT) \
- rjit_c.$(OBJEXT) \
node.$(OBJEXT) \
+ node_dump.$(OBJEXT) \
numeric.$(OBJEXT) \
object.$(OBJEXT) \
pack.$(OBJEXT) \
+ pathname.$(OBJEXT) \
parse.$(OBJEXT) \
+ parser_st.$(OBJEXT) \
proc.$(OBJEXT) \
process.$(OBJEXT) \
ractor.$(OBJEXT) \
@@ -129,7 +186,9 @@ COMMONOBJS = array.$(OBJEXT) \
regparse.$(OBJEXT) \
regsyntax.$(OBJEXT) \
ruby.$(OBJEXT) \
+ ruby_parser.$(OBJEXT) \
scheduler.$(OBJEXT) \
+ set.$(OBJEXT) \
shape.$(OBJEXT) \
signal.$(OBJEXT) \
sprintf.$(OBJEXT) \
@@ -141,7 +200,6 @@ COMMONOBJS = array.$(OBJEXT) \
thread.$(OBJEXT) \
time.$(OBJEXT) \
transcode.$(OBJEXT) \
- transient_heap.$(OBJEXT) \
util.$(OBJEXT) \
variable.$(OBJEXT) \
version.$(OBJEXT) \
@@ -151,21 +209,30 @@ COMMONOBJS = array.$(OBJEXT) \
vm_sync.$(OBJEXT) \
vm_trace.$(OBJEXT) \
weakmap.$(OBJEXT) \
+ $(PRISM_OBJS) \
$(YJIT_OBJ) \
- $(YJIT_LIBOBJ) \
+ $(ZJIT_OBJ) \
+ $(JIT_OBJ) \
+ $(RUST_LIBOBJ) \
$(COROUTINE_OBJ) \
$(DTRACE_OBJ) \
$(BUILTIN_ENCOBJS) \
$(BUILTIN_TRANSOBJS) \
$(MISSING)
+$(PRISM_OBJS): $(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/util/.time
+
+$(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/util/.time:
+ $(Q) $(MAKEDIRS) $(@D)
+ @$(NULLCMD) > $@
+
EXPORTOBJS = $(DLNOBJ) \
localeinit.$(OBJEXT) \
loadpath.$(OBJEXT) \
$(COMMONOBJS)
OBJS = $(EXPORTOBJS) builtin.$(OBJEXT)
-ALLOBJS = $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(INITOBJS)
+ALLOBJS = $(OBJS) $(MINIOBJS) $(INITOBJS) $(MAINOBJ)
GOLFOBJS = goruby.$(OBJEXT)
@@ -173,7 +240,7 @@ DEFAULT_PRELUDES = $(GEM_PRELUDE)
PRELUDE_SCRIPTS = $(DEFAULT_PRELUDES)
GEM_PRELUDE =
PRELUDES = {$(srcdir)}miniprelude.c
-GOLFPRELUDES = {$(srcdir)}golf_prelude.c
+GOLFPRELUDES = golf_prelude.rbbin
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--extout="$(EXTOUT)" \
@@ -197,7 +264,7 @@ INSTALL_DATA_MODE = 0644
BOOTSTRAPRUBY_COMMAND = $(BOOTSTRAPRUBY) $(BOOTSTRAPRUBY_OPT)
TESTSDIR = $(srcdir)/test
TOOL_TESTSDIR = $(tooldir)/test
-TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/
+TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/.excludes --name=!/memory_leak/
TESTWORKDIR = testwork
TESTOPTS = $(RUBY_TESTOPTS)
@@ -218,30 +285,24 @@ MAKE_LINK = $(MINIRUBY) -rfileutils -e "include FileUtils::Verbose" \
# For release builds
YJIT_RUSTC_ARGS = --crate-name=yjit \
- --crate-type=staticlib \
+ $(JIT_RUST_FLAGS) \
+ $(RUSTC_FLAGS) \
--edition=2021 \
- -g \
- -C lto=thin \
- -C opt-level=3 \
- -C overflow-checks=on \
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
- $(top_srcdir)/yjit/src/lib.rs
+ '$(top_srcdir)/yjit/src/lib.rs'
-all: $(SHOWFLAGS) main docs
+ZJIT_RUSTC_ARGS = --crate-name=zjit \
+ $(JIT_RUST_FLAGS) \
+ $(RUSTC_FLAGS) \
+ --edition=2024 \
+ '--out-dir=$(CARGO_TARGET_DIR)/release/' \
+ '$(top_srcdir)/zjit/src/lib.rs'
+
+all: $(SHOWFLAGS) main
main: $(SHOWFLAGS) exts $(ENCSTATIC:static=lib)encs
@$(NULLCMD)
-main: $(srcdir)/lib/ruby_vm/rjit/instruction.rb
-srcs: $(srcdir)/lib/ruby_vm/rjit/instruction.rb
-$(srcdir)/lib/ruby_vm/rjit/instruction.rb: $(tooldir)/insns2vm.rb $(tooldir)/ruby_vm/views/lib/ruby_vm/rjit/instruction.rb.erb $(srcdir)/insns.def
- $(ECHO) generating $@
- $(Q) $(BASERUBY) -Ku $(tooldir)/insns2vm.rb --basedir="$(srcdir)" $(INSNS2VMOPT) $@
-
-.PHONY: rjit-bindgen
-rjit-bindgen:
- $(Q) $(BASERUBY) -rrubygems -C $(srcdir)/tool/rjit bindgen.rb $(CURDIR)
-
.PHONY: showflags
exts enc trans: $(SHOWFLAGS)
showflags:
@@ -261,6 +322,7 @@ showflags:
" MFLAGS = $(MFLAGS)" \
" RUSTC = $(RUSTC)" \
" YJIT_RUSTC_ARGS = $(YJIT_RUSTC_ARGS)" \
+ " ZJIT_RUSTC_ARGS = $(ZJIT_RUSTC_ARGS)" \
$(MESSAGE_END)
-@$(CC_VERSION)
@@ -285,18 +347,21 @@ $(EXTS_MK): ext/configure-ext.mk $(srcdir)/template/exts.mk.tmpl \
$(srcdir)/template/exts.mk.tmpl --gnumake=$(gnumake) --configure-exts=ext/configure-ext.mk
ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY) \
- $(srcdir)/template/configure-ext.mk.tmpl
+ $(srcdir)/template/configure-ext.mk.tmpl update-default-gemspecs \
+ $(HAVE_BASERUBY:yes=extract-gems)
$(ECHO) generating makefiles $@
$(Q)$(MAKEDIRS) $(@D)
$(Q)$(MINIRUBY) $(tooldir)/generic_erb.rb -o $@ -c \
$(srcdir)/template/$(@F).tmpl --srcdir="$(srcdir)" \
- --miniruby="$(MINIRUBY)" --script-args='$(SCRIPT_ARGS)'
+ --miniruby="$(MINIRUBY)" --script-args='$(SCRIPT_ARGS)' \
+ $(yes_cross_compiling:yes=--without-ext=-test-)
configure-ext: $(EXTS_MK)
build-ext: $(EXTS_MK)
$(Q)$(MAKE) -f $(EXTS_MK) $(mflags) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
- EXTENCS="$(ENCOBJS)" MINIRUBY="$(MINIRUBY)" UPDATE_LIBRARIES=no $(EXTSTATIC)
+ EXTENCS="$(ENCOBJS)" BASERUBY="$(BASERUBY)" MINIRUBY="$(MINIRUBY)" \
+ $(EXTSTATIC)
$(Q)$(MAKE) $(EXTS_NOTE)
exts-note: $(EXTS_MK)
@@ -312,7 +377,7 @@ programs: $(PROGRAM) $(WPROGRAM) $(arch)-fake.rb
$(PREP): $(MKFILES)
-miniruby$(EXEEXT): config.status $(ALLOBJS) $(ARCHFILE)
+miniruby$(EXEEXT): config.status $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(ARCHFILE)
objs: $(ALLOBJS)
@@ -339,8 +404,8 @@ Doxyfile: $(srcdir)/template/Doxyfile.tmpl $(PREP) $(tooldir)/generic_erb.rb $(R
$(Q) $(MINIRUBY) $(tooldir)/generic_erb.rb -o $@ $(srcdir)/template/Doxyfile.tmpl \
--srcdir="$(srcdir)" --miniruby="$(MINIRUBY)"
-program: $(SHOWFLAGS) $(PROGRAM)
-wprogram: $(SHOWFLAGS) $(WPROGRAM)
+program: $(SHOWFLAGS) $(DOT_WAIT) $(PROGRAM)
+wprogram: $(SHOWFLAGS) $(DOT_WAIT) $(WPROGRAM)
mini: PHONY miniruby$(EXEEXT)
$(PROGRAM) $(WPROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
@@ -360,27 +425,27 @@ ruby.imp: $(COMMONOBJS)
$(Q){ \
$(NM) -Pgp $(COMMONOBJS) | \
awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
- ($(CHDIR) $(srcdir) && \
- exec sed -n '/^RJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
} | \
sort -u -o $@
install: install-$(INSTALLDOC)
-docs: $(DOCTARGETS)
+docs: srcs-doc $(DOCTARGETS)
pkgconfig-data: $(ruby_pc)
$(ruby_pc): $(srcdir)/template/ruby.pc.in config.status
-install-all: docs pre-install-all do-install-all post-install-all
+INSTALL_ALL = all
+
+install-all: pre-install-all do-install-all post-install-all
pre-install-all:: all pre-install-local pre-install-ext pre-install-gem pre-install-doc
-do-install-all: pre-install-all
- $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all $(INSTALL_DOC_OPTS)
+do-install-all: pre-install-all $(DOT_WAIT) docs
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) $(INSTALL_DOC_OPTS)
post-install-all:: post-install-local post-install-ext post-install-gem post-install-doc
@$(NULLCMD)
install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
pre-install-nodoc:: pre-install-local pre-install-ext pre-install-gem
do-install-nodoc: main pre-install-nodoc
- $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all --exclude=doc
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) --exclude=doc
post-install-nodoc:: post-install-local post-install-ext post-install-gem
install-local: pre-install-local do-install-local post-install-local
@@ -455,7 +520,7 @@ what-where-all: no-install-all
no-install-all: pre-no-install-all dont-install-all post-no-install-all
pre-no-install-all:: pre-no-install-local pre-no-install-ext pre-no-install-doc
dont-install-all: $(PROGRAM)
- $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all $(INSTALL_DOC_OPTS)
+ $(INSTRUBY) -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) $(INSTALL_DOC_OPTS)
post-no-install-all:: post-no-install-local post-no-install-ext post-no-install-doc
@$(NULLCMD)
@@ -560,17 +625,35 @@ do-install-dbg: $(PROGRAM) pre-install-dbg
post-install-dbg::
@$(NULLCMD)
-rdoc: PHONY main
+srcs-doc: prepare-gems
+
+RDOC_DEPENDS = main srcs-doc
+rdoc: PHONY $(RDOC_DEPENDS) $(RBCONFIG) update-default-gemspecs
@echo Generating RDoc documentation
- $(Q) $(RDOC) --ri --op "$(RDOCOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(RDOC) --ri --op "$(RDOCOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) .
-html: PHONY main
+html: PHONY $(RDOC_DEPENDS) $(RBCONFIG) update-default-gemspecs
@echo Generating RDoc HTML files
- $(Q) $(RDOC) --op "$(HTMLOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(RDOC) --op "$(HTMLOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) .
+
+html-server: PHONY $(RDOC_DEPENDS) $(RBCONFIG)
+ @echo Starting RDoc server with live reload
+ $(Q) $(RDOC) --server=$(RDOC_SERVER_PORT) $(RDOC_GEN_OPTS) $(RDOCFLAGS) .
+
+RDOC_COVERAGE_EXCLUDES = -x ^ext/json -x ^ext/openssl -x ^ext/psych \
+ -x ^lib/bundler -x ^lib/rubygems \
+ -x ^lib/did_you_mean -x ^lib/error_highlight -x ^lib/syntax_suggest
-rdoc-coverage: PHONY main
+rdoc-coverage: PHONY $(RDOC_DEPENDS) $(RBCONFIG)
@echo Generating RDoc coverage report
- $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)"
+ $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) $(RDOC_COVERAGE_EXCLUDES) .
+
+undocumented: PHONY $(RDOC_DEPENDS) $(RBCONFIG)
+ $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) $(RDOC_COVERAGE_EXCLUDES) . | \
+ sed -n \
+ -e '/^ *# in file /{' -e 's///;N;s/\n/: /p' -e '}' \
+ -e 's/^ *\(.*[^ ]\) *# in file \(.*\)/\2: \1/p' | \
+ sort -t: -k1,1 -k2n,2
RDOCBENCHOUT=/tmp/rdocbench
@@ -599,22 +682,31 @@ install-prereq: $(CLEAR_INSTALLED_LIST) yes-fake sudo-precheck PHONY
clear-installed-list: PHONY
@> $(INSTALLED_LIST) set MAKE="$(MAKE)"
-clean: clean-ext clean-enc clean-golf clean-docs clean-extout clean-local clean-platform clean-spec
+noarch_config_h = tmp/include/noarch/ruby/config.h
+
+clean: clean-ext clean-enc clean-golf clean-docs clean-extout clean-modular-gc clean-local clean-platform clean-spec
clean-local:: clean-runnable
- $(Q)$(RM) $(OBJS) $(MINIOBJS) $(INITOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
+ $(Q)$(RM) $(ALLOBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
$(Q)$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) dmyenc.$(OBJEXT) $(ARCHFILE) .*.time
$(Q)$(RM) y.tab.c y.output encdb.h transdb.h config.log rbconfig.rb $(ruby_pc) $(COROUTINE_H:/Context.h=/.time)
$(Q)$(RM) probes.h probes.$(OBJEXT) probes.stamp ruby-glommed.$(OBJEXT) ruby.imp ChangeLog $(STATIC_RUBY)$(EXEEXT)
- $(Q)$(RM) GNUmakefile.old Makefile.old $(arch)-fake.rb bisect.sh $(ENC_TRANS_D) builtin_binary.inc
- -$(Q)$(RMALL) yjit/target
- -$(Q) $(RMDIR) enc/jis enc/trans enc $(COROUTINE_H:/Context.h=) coroutine yjit 2> $(NULL) || $(NULLCMD)
+ $(Q)$(RM) GNUmakefile.old Makefile.old $(arch)-fake.rb bisect.sh $(ENC_TRANS_D) builtin_binary.rbbin
+ $(Q)$(RM) $(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/*/.time yjit_exit_locations.dump
+ $(Q)$(RM) $(noarch_config_h)
+ -$(Q)$(RMALL) dump_ast$(BUILD_EXEEXT)*
+ -$(Q)$(RMALL) target
+ -$(Q) $(RMDIR) enc/jis enc/trans enc $(COROUTINE_H:/Context.h=) coroutine target \
+ $(PRISM_BUILD_DIR)/*/ $(PRISM_BUILD_DIR) tmp \
+ 2> $(NULL) || $(NULLCMD)
bin/clean-runnable:: PHONY
$(Q)$(CHDIR) bin 2>$(NULL) && $(RM) $(PROGRAM) $(WPROGRAM) $(GORUBY)$(EXEEXT) bin/*.$(DLEXT) 2>$(NULL) || $(NULLCMD)
lib/clean-runnable:: PHONY
- $(Q)$(CHDIR) lib 2>$(NULL) && $(RM) $(LIBRUBY_A) $(LIBRUBY) $(LIBRUBY_ALIASES) $(RUBY_BASE_NAME)/$(RUBY_PROGRAM_VERSION) $(RUBY_BASE_NAME)/vendor_ruby 2>$(NULL) || $(NULLCMD)
+ $(Q)$(CHDIR) lib 2>$(NULL) && $(RM) $(LIBRUBY_A) $(LIBRUBY) $(LIBRUBY_ALIASES) $(RUBY_BASE_NAME)/$(ruby_version) $(RUBY_BASE_NAME)/vendor_ruby 2>$(NULL) || $(NULLCMD)
clean-runnable:: bin/clean-runnable lib/clean-runnable PHONY
$(Q)$(RMDIR) lib/$(RUBY_BASE_NAME) lib bin 2>$(NULL) || $(NULLCMD)
+ -$(Q)$(RM) $(EXTOUT)/$(arch)/rbconfig.rb $(EXTOUT)/common/$(arch)
+ -$(Q)$(RMALL) exe/
clean-ext:: PHONY
clean-golf: PHONY
$(Q)$(RM) $(GORUBY)$(EXEEXT) $(GOLFOBJS)
@@ -628,13 +720,14 @@ clean-docs: clean-rdoc clean-html clean-capi
clean-spec: PHONY
clean-rubyspec: clean-spec
-distclean: distclean-ext distclean-enc distclean-golf distclean-docs distclean-extout distclean-local distclean-platform distclean-spec
+distclean: distclean-ext distclean-enc distclean-golf distclean-docs distclean-extout distclean-modular-gc distclean-local distclean-platform distclean-spec
distclean-local:: clean-local
- $(Q)$(RM) $(MKFILES) yasmdata.rb *.inc $(PRELUDES) *.rbinc
+ $(Q)$(RM) $(MKFILES) *.inc $(PRELUDES) *.rbinc *.rbbin
$(Q)$(RM) config.cache config.status config.status.lineno
$(Q)$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
-$(Q)$(RMALL) $(srcdir)/autom4te.cache
-distclean-ext:: PHONY
+distclean-local:: distclean-srcs-local
+distclean-ext:: distclean-srcs-ext
distclean-golf: clean-golf
distclean-rdoc: clean-rdoc
distclean-html: clean-html
@@ -649,6 +742,7 @@ realclean:: realclean-ext realclean-local realclean-enc realclean-golf realclean
realclean-local:: distclean-local realclean-srcs-local
clean-srcs:: clean-srcs-local clean-srcs-ext
+distclean-srcs:: distclean-srcs-local distclean-srcs-ext
realclean-srcs:: realclean-srcs-local realclean-srcs-ext
clean-srcs-local::
@@ -656,14 +750,18 @@ clean-srcs-local::
$(Q)$(RM) id.c id.h probes.dmyh probes.h
$(Q)$(RM) encdb.h transdb.h verconf.h ruby-runner.h
-realclean-srcs-local:: clean-srcs-local
+distclean-srcs-local:: clean-srcs-local
+
+realclean-srcs-local:: distclean-srcs-local
$(Q)$(CHDIR) $(srcdir) && $(RM) \
parse.c parse.h lex.c enc/trans/newline.c $(PRELUDES) revision.h \
- id.c id.h probes.dmyh configure aclocal.m4 tool/config.guess tool/config.sub gems/*.gem \
+ id.c id.h probes.dmyh configure aclocal.m4 tool/config.guess tool/config.sub \
+ $(PRISM_SRCDIR)/srcs.mk gems/*.gem \
|| $(NULLCMD)
clean-srcs-ext::
-realclean-srcs-ext:: clean-srcs-ext
+distclean-srcs-ext:: clean-srcs-ext
+realclean-srcs-ext:: distclean-srcs-ext
realclean-ext:: PHONY
realclean-golf: distclean-golf
@@ -691,7 +789,7 @@ timestamp/distclean:: ext/distclean .bundle/distclean
timestamp/realclean:: ext/realclean .bundle/realclean
timestamp/clean timestamp/distclean timestamp/realclean::
- $(Q)$(RM) $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time
+ $(Q)$(RM) $(TIMESTAMPDIR)/*.time $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time
$(Q)$(RMDIRS) $(TIMESTAMPDIR)/$(arch) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
clean-ext::
@@ -723,9 +821,19 @@ clean-capi distclean-capi realclean-capi:
clean-platform distclean-platform realclean-platform:
$(Q) $(RM) $(PLATFORM_D)
- -$(Q) $(RMDIR) $(PLATFORM_DIR) 2> $(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIR) $(PLATFORM_DIR) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
RUBYSPEC_CAPIEXT = spec/ruby/optional/capi/ext
+RUBYSPEC_CAPIEXT_SRCDIR = $(srcdir)/$(RUBYSPEC_CAPIEXT)
+RUBYSPEC_CAPIEXT_DEPS = $(RUBYSPEC_CAPIEXT_SRCDIR)/rubyspec.h $(RUBY_H_INCLUDES) {$(VPATH)}internal/abi.h $(LIBRUBY)
+RUBYSPEC_CAPIEXT_BUILD = $(enable_shared:yes=rubyspec-capiext)
+
+yes-rubyspec-capiext: build-ext
+ $(ACTIONS_GROUP)
+rubyspec-capiext: build-ext $(DOT_WAIT) yes-rubyspec-capiext $(DOT_WAIT)
+ $(ACTIONS_ENDGROUP)
+# make-dependent rules should be included after this and built after build-ext.
+
clean-spec: PHONY
-$(Q) $(RM) $(RUBYSPEC_CAPIEXT)/*.$(OBJEXT) $(RUBYSPEC_CAPIEXT)/*.$(DLEXT)
-$(Q) $(RMDIRS) $(RUBYSPEC_CAPIEXT) 2> $(NULL) || $(NULLCMD)
@@ -749,13 +857,20 @@ $(HAVE_BASERUBY:no=)$(arch)-fake.rb: miniruby$(EXEEXT)
# actually depending on other headers more.
$(arch:noarch=ignore)-fake.rb: $(top_srcdir)/revision.h $(top_srcdir)/version.h $(srcdir)/version.c
-$(arch:noarch=ignore)-fake.rb: {$(VPATH)}id.h {$(VPATH)}vm_opts.h
+$(arch:noarch=ignore)-fake.rb: {$(VPATH)}id.h {$(VPATH)}vm_opts.h $(REVISION_H)
$(arch:noarch=ignore)-fake.rb: $(srcdir)/template/fake.rb.in $(tooldir)/generic_erb.rb
$(ECHO) generating $@
$(Q) $(CPP) -DRUBY_EXPORT $(INCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \
$(BOOTSTRAPRUBY) "$(tooldir)/generic_erb.rb" -o $@ "$(srcdir)/template/fake.rb.in" \
- i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)"
+ i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)" \
+ LIBPATHENV="$(LIBPATHENV)" PRELOADENV="$(PRELOADENV)" LIBRUBY_SO="$(LIBRUBY_SO)"
+
+# dummy file for generating sources; $(arch_hdrdir)/ruby/config.h with prereq.status.
+$(noarch_config_h):
+ $(ECHO) generating dummy config.h
+ $(Q) $(MAKEDIRS) $(@D)
+ $(Q) $(TOUCH) $@
noarch-fake.rb: # prerequisite of yes-fake
$(Q) exit > $@
@@ -812,7 +927,7 @@ no-test-testframework: PHONY
test-tool: $(TEST_RUNNABLE)-test-tool
yes-test-tool: prog PHONY
$(ACTIONS_GROUP)
- $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS)
+ $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) $(TESTS)
$(ACTIONS_ENDGROUP)
no-test-tool: PHONY
@@ -820,16 +935,28 @@ test-sample: test-basic # backward compatibility for mswin-build
test-short: btest-ruby $(DOT_WAIT) test-knownbug $(DOT_WAIT) test-basic
test: test-short
+# Separate to skip updating encs and exts by `make -o test-precheck`
+# for GNU make.
+test-precheck: $(ENCSTATIC:static=lib)encs exts PHONY $(DOT_WAIT)
+yes-test-all-precheck: programs $(DOT_WAIT) test-precheck yes-fake
+
+PRECHECK_TEST_ALL = yes-test-all-precheck
+
# $ make test-all TESTOPTS="--help" displays more detail
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
test-all: $(TEST_RUNNABLE)-test-all
-yes-test-all: programs PHONY
+yes-test-all: $(PRECHECK_TEST_ALL)
$(ACTIONS_GROUP)
- $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
+ $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) -r$(tooldir)/lib/_tmpdir \
+ "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" \
+ $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
$(ACTIONS_ENDGROUP)
TESTS_BUILD = mkmf
no-test-all: PHONY
- $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TESTSDIR)/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
+ $(ACTIONS_GROUP)
+ $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" -r$(tooldir)/lib/_tmpdir \
+ "$(TESTSDIR)/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
+ $(ACTIONS_ENDGROUP)
test-almost: test-all
yes-test-almost: yes-test-all
@@ -848,40 +975,45 @@ rbconfig.rb: $(RBCONFIG)
$(HAVE_BASERUBY:no=)$(RBCONFIG)$(HAVE_BASERUBY:no=): $(PREP)
$(RBCONFIG): $(tooldir)/mkconfig.rb config.status $(srcdir)/version.h $(srcdir)/common.mk
- $(Q)$(BOOTSTRAPRUBY) -n \
- -e 'BEGIN{version=ARGV.shift;mis=ARGV.dup}' \
- -e 'END{abort "UNICODE version mismatch: #{mis}" unless mis.empty?}' \
- -e '(mis.delete(ARGF.path); ARGF.close) if /ONIG_UNICODE_VERSION_STRING +"#{Regexp.quote(version)}"/o' \
- $(UNICODE_VERSION) $(UNICODE_DATA_HEADERS)
+
+$(RBCONFIG):
$(Q)$(BOOTSTRAPRUBY) $(tooldir)/mkconfig.rb \
-arch=$(arch) -version=$(RUBY_PROGRAM_VERSION) \
-install_name=$(RUBY_INSTALL_NAME) \
-so_name=$(RUBY_SO_NAME) \
-unicode_version=$(UNICODE_VERSION) \
-unicode_emoji_version=$(UNICODE_EMOJI_VERSION) \
- > rbconfig.tmp
- $(IFCHANGE) "--timestamp=$@" rbconfig.rb rbconfig.tmp
+ | $(IFCHANGE) "--timestamp=$@" rbconfig.rb -
test-rubyspec: test-spec
yes-test-rubyspec: yes-test-spec
-test-spec-precheck: programs yes-fake
+yes-test-spec-precheck: yes-test-all-precheck $(RUBYSPEC_CAPIEXT_BUILD)
test-spec: $(TEST_RUNNABLE)-test-spec
-yes-test-spec: test-spec-precheck
+yes-test-spec: yes-test-spec-precheck
$(ACTIONS_GROUP)
$(gnumake_recursive)$(Q) \
- $(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS)
+ $(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/lib/_tmpdir \
+ $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS)
$(ACTIONS_ENDGROUP)
no-test-spec:
check: $(DOT_WAIT) test-spec
RUNNABLE = $(LIBRUBY_RELATIVE:no=un)-runnable
-runnable: $(RUNNABLE) prog $(tooldir)/mkrunnable.rb PHONY
+runnable: $(RUNNABLE)
+runnable-golf: golf
+runnable $(enable_shared:yes=runnable-golf): prog $(tooldir)/mkrunnable.rb PHONY
$(Q) $(MINIRUBY) $(tooldir)/mkrunnable.rb -v $(EXTOUT)
yes-runnable: PHONY
+hello: $(TEST_RUNNABLE)-hello
+yes-hello: runnable-golf
+ ./$(enable_shared:yes=bin/)$(GORUBY) -veh
+no-hello: runnable-golf
+ $(ECHO) Run ./$(enable_shared:yes=bin/)$(GORUBY) -veh
+
encs: enc trans
libencs: libenc libtrans
encs enc trans libencs libenc libtrans: $(SHOWFLAGS) $(ENC_MK) $(LIBRUBY) $(PREP) PHONY
@@ -906,8 +1038,11 @@ $(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc
.PHONY: test install install-nodoc install-doc dist
.PHONY: loadpath golf capi rdoc install-prereq clear-installed-list
.PHONY: clean clean-ext clean-local clean-enc clean-golf clean-rdoc clean-html clean-extout
+.PHONY: clean-srcs clean-srcs-local clean-srcs-ext
.PHONY: distclean distclean-ext distclean-local distclean-enc distclean-golf distclean-extout
+.PHONY: distclean-srcs distclean-srcs-local distclean-srcs-ext
.PHONY: realclean realclean-ext realclean-local realclean-enc realclean-golf realclean-extout
+.PHONY: realclean-srcs realclean-srcs-local realclean-srcs-ext
.PHONY: exam check test test-short test-all btest btest-ruby test-basic test-knownbug
.PHONY: run runruby parse benchmark gdb gdb-ruby
.PHONY: update-mspec update-rubyspec test-rubyspec test-spec
@@ -915,23 +1050,19 @@ $(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc
PHONY:
-{$(VPATH)}parse.c: {$(VPATH)}parse.y $(tooldir)/ytab.sed {$(VPATH)}id.h
+{$(VPATH)}parse.c: {$(VPATH)}parse.y {$(VPATH)}id.h
{$(VPATH)}parse.h: {$(VPATH)}parse.c
{$(srcdir)}.y.c:
$(ECHO) generating $@
- $(Q)$(BASERUBY) $(tooldir)/id2token.rb $(SRC_FILE) > parse.tmp.y
- $(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y
- $(Q)$(RM) parse.tmp.y
- $(Q)sed -f $(tooldir)/ytab.sed -e "/^#/s|parse\.tmp\.[iy]|$(SRC_FILE)|" -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
- $(Q)$(MV) $@.new $@
- $(Q)sed -e "/^#line.*y\.tab\.h/d;/^#line.*parse.*\.y/d" y.tab.h > $(@:.c=.h)
- $(Q)$(RM) y.tab.c y.tab.h
+ $(Q)$(BASERUBY) $(tooldir)/id2token.rb $(SRC_FILE) | \
+ $(LRAMA) $(YFLAGS) -o$@ -H$*.h - parse.y
$(PLATFORM_D):
$(Q) $(MAKEDIRS) $(PLATFORM_DIR) $(@D)
@$(NULLCMD) > $@
+exe/$(PROGRAM): $(TIMESTAMPDIR)/$(arch)/.time
exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time $(PREP) {$(VPATH)}config.h
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) $(CPPFLAGS) -DRUBY_INSTALL_NAME=$(@F) $(COUTFLAG)ruby-runner.$(OBJEXT) -c $(CSRCFLAG)$(srcdir)/ruby-runner.c
$(Q) $(PURIFY) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTFLAG)$@ ruby-runner.$(OBJEXT) $(LIBS)
@@ -944,6 +1075,8 @@ exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time $(PREP) {$(VPATH)}config.h
-e ' File.symlink(prog, dest)' \
-e 'end' \
$(@F) $(@D) $(RUBY_INSTALL_NAME)$(EXEEXT)
+ $(Q) $(BOOTSTRAPRUBY) -r$(srcdir)/lib/fileutils \
+ -e 'FileUtils::Verbose.ln_sr(*ARGV, force: true)' rbconfig.rb $(EXTOUT)/$(arch)
exe/.time:
$(Q) $(MAKEDIRS) $(@D)
@@ -1011,7 +1144,7 @@ parse.$(OBJEXT): {$(VPATH)}parse.c
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c
# dependencies for optional sources.
-compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
+compile.$(OBJEXT): {$(VPATH)}optunifs.inc
win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c {$(VPATH)}win32/file.h \
{$(VPATH)}dln.h {$(VPATH)}dln_find.c {$(VPATH)}encindex.h \
@@ -1025,7 +1158,7 @@ $(NEWLINE_C): $(srcdir)/enc/trans/newline.trans $(tooldir)/transcode-tblgen.rb
$(Q) $(BASERUBY) "$(tooldir)/transcode-tblgen.rb" -vo $@ $(srcdir)/enc/trans/newline.trans
enc/trans/newline.$(OBJEXT): $(NEWLINE_C)
-verconf.h: $(srcdir)/template/verconf.h.tmpl $(tooldir)/generic_erb.rb $(RBCONFIG)
+verconf.h: $(srcdir)/template/verconf.h.tmpl $(tooldir)/generic_erb.rb rbconfig.rb
$(ECHO) creating $@
$(Q) $(BOOTSTRAPRUBY) "$(tooldir)/generic_erb.rb" -o $@ $(srcdir)/template/verconf.h.tmpl
@@ -1038,7 +1171,6 @@ INSNS2VMOPT = --srcdir="$(srcdir)"
srcs_vpath = {$(VPATH)}
inc_common_headers = $(tooldir)/ruby_vm/views/_copyright.erb $(tooldir)/ruby_vm/views/_notice.erb
-$(srcs_vpath)opt_sc.inc: $(tooldir)/ruby_vm/views/opt_sc.inc.erb $(inc_common_headers)
$(srcs_vpath)optinsn.inc: $(tooldir)/ruby_vm/views/optinsn.inc.erb $(inc_common_headers)
$(srcs_vpath)optunifs.inc: $(tooldir)/ruby_vm/views/optunifs.inc.erb $(inc_common_headers)
$(srcs_vpath)insns.inc: $(tooldir)/ruby_vm/views/insns.inc.erb $(inc_common_headers)
@@ -1046,10 +1178,11 @@ $(srcs_vpath)insns_info.inc: $(tooldir)/ruby_vm/views/insns_info.inc.erb $(inc_c
$(tooldir)/ruby_vm/views/_insn_type_chars.erb $(tooldir)/ruby_vm/views/_insn_name_info.erb \
$(tooldir)/ruby_vm/views/_insn_len_info.erb $(tooldir)/ruby_vm/views/_insn_operand_info.erb \
$(tooldir)/ruby_vm/views/_attributes.erb $(tooldir)/ruby_vm/views/_comptime_insn_stack_increase.erb \
- $(tooldir)/ruby_vm/views/_insn_sp_pc_dependency.erb
+ $(tooldir)/ruby_vm/views/_zjit_helpers.erb $(tooldir)/ruby_vm/views/_insn_leaf_info.erb
$(srcs_vpath)vmtc.inc: $(tooldir)/ruby_vm/views/vmtc.inc.erb $(inc_common_headers)
$(srcs_vpath)vm.inc: $(tooldir)/ruby_vm/views/vm.inc.erb $(inc_common_headers) \
- $(tooldir)/ruby_vm/views/_insn_entry.erb $(tooldir)/ruby_vm/views/_trace_instruction.erb
+ $(tooldir)/ruby_vm/views/_insn_entry.erb $(tooldir)/ruby_vm/views/_trace_instruction.erb \
+ $(tooldir)/ruby_vm/views/_zjit_instruction.erb
BUILTIN_RB_SRCS = \
$(srcdir)/ast.rb \
@@ -1058,13 +1191,13 @@ BUILTIN_RB_SRCS = \
$(srcdir)/numeric.rb \
$(srcdir)/io.rb \
$(srcdir)/marshal.rb \
- $(srcdir)/rjit.rb \
- $(srcdir)/rjit_c.rb \
$(srcdir)/pack.rb \
$(srcdir)/trace_point.rb \
$(srcdir)/warning.rb \
$(srcdir)/array.rb \
+ $(srcdir)/hash.rb \
$(srcdir)/kernel.rb \
+ $(srcdir)/pathname_builtin.rb \
$(srcdir)/ractor.rb \
$(srcdir)/symbol.rb \
$(srcdir)/timev.rb \
@@ -1072,7 +1205,10 @@ BUILTIN_RB_SRCS = \
$(srcdir)/nilclass.rb \
$(srcdir)/prelude.rb \
$(srcdir)/gem_prelude.rb \
+ $(srcdir)/jit_hook.rb \
+ $(srcdir)/jit_undef.rb \
$(srcdir)/yjit.rb \
+ $(srcdir)/zjit.rb \
$(empty)
BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)
@@ -1082,9 +1218,16 @@ common-srcs: $(srcs_vpath)parse.c $(srcs_vpath)lex.c $(srcs_vpath)enc/trans/newl
missing-srcs: $(srcdir)/missing/des_tables.c
-srcs: common-srcs missing-srcs srcs-enc
+srcs: common-srcs missing-srcs srcs-enc srcs-doc
-EXT_SRCS = $(srcdir)/ext/ripper/ripper.c \
+RIPPER_SRCS = $(srcdir)/ext/ripper/ripper.c \
+ $(srcdir)/ext/ripper/ripper_init.c \
+ $(srcdir)/ext/ripper/eventids1.h \
+ $(srcdir)/ext/ripper/eventids1.c \
+ $(srcdir)/ext/ripper/eventids2table.c \
+ # RIPPER_SRCS
+
+EXT_SRCS = ripper_srcs \
$(srcdir)/ext/rbconfig/sizeof/sizes.c \
$(srcdir)/ext/rbconfig/sizeof/limits.c \
$(srcdir)/ext/socket/constdefs.c \
@@ -1095,7 +1238,7 @@ srcs-ext: $(EXT_SRCS)
realclean-srcs-ext::
$(Q)$(RM) $(EXT_SRCS)
-EXTRA_SRCS = $(srcdir)/ext/json/parser/parser.c \
+EXTRA_SRCS = \
$(srcdir)/ext/date/zonetab.h \
$(empty)
@@ -1111,7 +1254,7 @@ srcs-enc: $(ENC_MK)
$(ECHO) making srcs under enc
$(Q) $(MAKE) $(MAKE_ENC) srcs
-all-incs: incs {$(VPATH)}encdb.h {$(VPATH)}transdb.h
+all-incs: incs {$(VPATH)}encdb.h {$(VPATH)}transdb.h {$(VPATH)}probes.h
incs: $(INSNS) {$(VPATH)}node_name.inc {$(VPATH)}known_errors.inc \
{$(VPATH)}vm_call_iseq_optimized.inc $(srcdir)/revision.h \
$(REVISION_H) \
@@ -1130,9 +1273,9 @@ id.c: $(tooldir)/generic_erb.rb $(srcdir)/template/id.c.tmpl $(srcdir)/defs/id.d
$(Q) $(BASERUBY) $(tooldir)/generic_erb.rb --output=$@ \
$(srcdir)/template/id.c.tmpl
-node_name.inc: $(tooldir)/node_name.rb $(srcdir)/node.h
+node_name.inc: $(tooldir)/node_name.rb $(srcdir)/rubyparser.h
$(ECHO) generating $@
- $(Q) $(BASERUBY) -n $(tooldir)/node_name.rb < $(srcdir)/node.h > $@
+ $(Q) $(BASERUBY) -n $(tooldir)/node_name.rb < $(srcdir)/rubyparser.h > $@
encdb.h: $(RBCONFIG) $(tooldir)/generic_erb.rb $(srcdir)/template/encdb.h.tmpl
$(ECHO) generating $@
@@ -1157,10 +1300,7 @@ $(MINIPRELUDE_C): $(COMPILE_PRELUDE) $(BUILTIN_RB_SRCS)
$(Q) $(BASERUBY) $(tooldir)/generic_erb.rb -I$(srcdir) -o $@ \
$(srcdir)/template/prelude.c.tmpl $(BUILTIN_RB_SRCS)
-$(GOLF_PRELUDE_C): $(COMPILE_PRELUDE) {$(srcdir)}golf_prelude.rb
- $(ECHO) generating $@
- $(Q) $(BASERUBY) $(tooldir)/generic_erb.rb -I$(srcdir) -c -o $@ \
- $(srcdir)/template/prelude.c.tmpl golf_prelude.rb
+golf_prelude.rbbin: {$(srcdir)}golf_prelude.rb $(tooldir)/mk_rbbin.rb $(PREP)
MAINCPPFLAGS = $(ENABLE_DEBUG_ENV:yes=-DRUBY_DEBUG_ENV=1)
@@ -1178,17 +1318,39 @@ probes.h: {$(VPATH)}probes.$(DTRACE_EXT)
prereq: incs srcs preludes PHONY
preludes: {$(VPATH)}miniprelude.c
-preludes: {$(srcdir)}golf_prelude.c
-{$(srcdir)}.rb.rbinc:
+{$(srcdir)}.rb.rbbin:
+ $(ECHO) making $@
+ $(Q) $(MINIRUBY) $(tooldir)/mk_rbbin.rb $(SRC_FILE) > $(OS_DEST_FILE)
+
+{$(srcdir)}.rb.$(HAVE_BASERUBY:yes=)rbinc:
$(ECHO) making $@
- $(Q) $(BASERUBY) $(tooldir)/mk_builtin_loader.rb $<
+ $(Q) $(BASERUBY) $(tooldir)/mk_builtin_loader.rb $(DUMP_AST) $(SRC_FILE)
-builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/template/builtin_binary.inc.tmpl
+$(BUILTIN_BINARY:yes=built)in_binary.rbbin: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/template/builtin_binary.rbbin.tmpl
$(Q) $(MINIRUBY) $(tooldir)/generic_erb.rb -o $@ \
- $(srcdir)/template/builtin_binary.inc.tmpl -- --cross=$(CROSS_COMPILING)
+ $(srcdir)/template/builtin_binary.rbbin.tmpl
+ -$(Q) sha256sum $@ 2> $(NULL) || $(NULLCMD)
+
+$(BUILTIN_BINARY:no=builtin)_binary.rbbin:
+ $(Q) echo> $@ // empty $(@F)
+
+$(BUILTIN_RB_INCS): $(tooldir)/mk_builtin_loader.rb $(DUMP_AST_TARGET)
-$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
+dump_ast$(BUILD_EXEEXT): $(tooldir)/dump_ast.c $(LIBPRISM_OBJS)
+ $(ECHO) compiling $@
+ $(Q) $(CC) $(CFLAGS) $(OUTFLAG)$@ $(INCFLAGS) $(tooldir)/dump_ast.c $(LIBPRISM_OBJS)
+
+build-tool/Makefile: $(tooldir)/dump_ast.mkmf.rb prism-srcs prism-incs
+ +$(BASERUBY) -s $(tooldir)/dump_ast.mkmf.rb "-INCFLAGS=$(INCFLAGS)" "-make=$(MAKE)" build-tool $(tooldir)/dump_ast.c dump_ast.$(OBJEXT) $(LIBPRISM_OBJS)
+
+build-tool/dump_ast$(BUILD_EXEEXT): build-tool/Makefile
+ cd build-tool && MAKEFLAGS= MFLAGS= && unset MAKEFLAGS MFLAGS && $(MAKE)
+
+clean-local:: clean-build-tool
+clean-build-tool:
+ - cd build-tool && $(MAKE) clean 2> $(NULL) || $(NULLCMD)
+ - $(RMDIR) build-tool
$(srcdir)/revision.h$(no_baseruby:no=~disabled~): $(REVISION_H)
@@ -1200,18 +1362,23 @@ $(REVISION_H)$(yes_baseruby:yes=~disabled~):
# uncommon.mk: $(REVISION_H)
# $(MKFILES): $(REVISION_H)
-$(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/parse.y $(srcdir)/defs/id.def $(srcdir)/ext/ripper/depend
+# $(common_mk_includes) is set by config.status or GNUmakefile
+common_mk__$(gnumake:yes=artifact)_ = uncommon.mk
+common_mk_$(gnumake)_artifact_ = $(MKFILES)
+$(common_mk__artifact_): $(srcdir)/common.mk $(common_mk_includes)
+
+ripper_srcs: $(RIPPER_SRCS)
+
+$(RIPPER_SRCS): $(srcdir)/parse.y $(srcdir)/defs/id.def
+$(RIPPER_SRCS): $(srcdir)/ext/ripper/depend $(srcdir)/ext/ripper/extconf.rb
+$(RIPPER_SRCS): $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/ext/ripper/tools/dsl.rb
+$(RIPPER_SRCS): $(srcdir)/ext/ripper/ripper_init.c.tmpl $(srcdir)/ext/ripper/eventids2.c
$(ECHO) generating $@
$(Q) $(CHDIR) $(@D) && \
$(CAT_DEPEND) depend | \
$(exec) $(MAKE) -f - $(mflags) \
- Q=$(Q) ECHO=$(ECHO) RM="$(RM1)" BISON="$(YACC)" top_srcdir=../.. srcdir=. VPATH=../.. \
- RUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)" LANG=C
-
-$(srcdir)/ext/json/parser/parser.c: $(srcdir)/ext/json/parser/parser.rl $(srcdir)/ext/json/parser/prereq.mk
- $(ECHO) generating $@
- $(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(mflags) \
- Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. BASERUBY="$(BASERUBY)"
+ Q=$(Q) ECHO=$(ECHO) RM="$(RM1)" top_srcdir=../.. srcdir=. VPATH=../.. \
+ RUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)" LANG=C
$(srcdir)/ext/date/zonetab.h: $(srcdir)/ext/date/zonetab.list $(srcdir)/ext/date/prereq.mk
$(ECHO) generating $@
@@ -1234,7 +1401,7 @@ $(srcdir)/ext/rbconfig/sizeof/limits.c: $(srcdir)/ext/rbconfig/sizeof/depend \
$(exec) $(MAKE) -f - $(mflags) \
Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. RUBY="$(BASERUBY)" $(@F)
-$(srcdir)/ext/socket/constdefs.c: $(srcdir)/ext/socket/depend
+$(srcdir)/ext/socket/constdefs.c: $(srcdir)/ext/socket/depend $(srcdir)/ext/socket/mkconstants.rb
$(Q) $(CHDIR) $(@D) && \
$(CAT_DEPEND) depend | \
$(exec) $(MAKE) -f - $(mflags) \
@@ -1254,8 +1421,8 @@ run: yes-fake miniruby$(EXEEXT) PHONY
runruby: $(PROGRAM) PHONY
RUBY_ON_BUG='gdb -x $(srcdir)/.gdbinit -p' $(RUNRUBY) $(RUNOPT0) $(TESTRUN_SCRIPT) $(RUNOPT)
-runirb: $(PROGRAM) PHONY
- RUBY_ON_BUG='gdb -x $(srcdir)/.gdbinit -p' $(RUNRUBY) $(RUNOPT0) -r irb -e 'IRB.start("make runirb")' $(RUNOPT)
+runirb: $(PROGRAM) update-default-gemspecs
+ RUBY_ON_BUG='gdb -x $(srcdir)/.gdbinit -p' $(RUNRUBY) $(RUNOPT0) -rrubygems -r irb -e 'IRB.start("make runirb")' $(RUNOPT)
parse: yes-fake miniruby$(EXEEXT) PHONY
$(BTESTRUBY) --dump=parsetree_with_comment,insns $(TESTRUN_SCRIPT)
@@ -1323,7 +1490,7 @@ dist:
up:: update-remote
up$(DOT_WAIT)::
- -$(Q)$(MAKE) $(mflags) Q=$(Q) REVISION_FORCE=PHONY ALWAYS_UPDATE_UNICODE= after-update
+ -$(Q)$(MAKE) $(mflags) Q=$(Q) REVISION_FORCE=PHONY ALWAYS_UPDATE_UNICODE= MINIRUBY=$(BASERUBY) after-update
yes::
no::
@@ -1332,6 +1499,7 @@ after-update:: common-srcs
after-update:: $(REVISION_H)
after-update:: extract-extlibs
after-update:: extract-gems
+after-update:: update-default-gemspecs
update-src::
$(Q) $(RM) $(REVISION_H) revision.h "$(srcdir)/$(REVISION_H)" "$(srcdir)/revision.h"
@@ -1354,15 +1522,21 @@ update-coverage: main PHONY
--install-dir .bundle --conservative "simplecov"
refresh-gems: update-bundled_gems prepare-gems
+# can't recall exactly, but `make` somewhere (not GNU or nmake)
+# couldn't handle spaces in replacement strings; i.e.,
+# `$(HAVE_BASERUBY:yes=word word ...)` didn't work.
prepare-gems: $(HAVE_BASERUBY:yes=update-gems) $(HAVE_BASERUBY:yes=extract-gems)
-extract-gems: $(HAVE_BASERUBY:yes=update-gems)
+extract-gems: $(HAVE_BASERUBY:yes=update-gems) $(HAVE_BASERUBY:yes=outdate-bundled-gems)
+update-gems: $(HAVE_BASERUBY:yes=outdate-bundled-gems)
+
+split_option = -F"\s+|$(HASH_SIGN).*"
-update-gems$(gnumake:yes=-sequential): PHONY
+update-gems$(sequential): PHONY
$(ECHO) Downloading bundled gem files...
$(Q) $(BASERUBY) -C "$(srcdir)" \
- -I./tool -rdownloader -answ \
+ -I./tool -rdownloader $(split_option) -answ \
-e 'gem, ver = *$$F' \
- -e 'next if !ver or /^#/=~gem' \
+ -e 'next if !ver' \
-e 'old = Dir.glob("gems/#{gem}-*.gem")' \
-e 'gem = "#{gem}-#{ver}.gem"' \
-e 'Downloader::RubyGems.download(gem, "gems", nil) and' \
@@ -1371,13 +1545,13 @@ update-gems$(gnumake:yes=-sequential): PHONY
-e 'FileUtils.rm_rf(old.map{'"|n|"'n.chomp(".gem")})' \
gems/bundled_gems
-extract-gems$(gnumake:yes=-sequential): PHONY
+extract-gems$(sequential): PHONY
$(ECHO) Extracting bundled gem files...
$(Q) $(BASERUBY) -C "$(srcdir)" \
- -Itool/lib -rfileutils -rbundled_gem -answ \
+ -Itool/lib -rfileutils -rbundled_gem $(split_option) -answ \
-e 'BEGIN {d = ".bundle/gems"}' \
-e 'gem, ver, _, rev = *$$F' \
- -e 'next if !ver or /^#/=~gem' \
+ -e 'next if !ver' \
-e 'g = "#{gem}-#{ver}"' \
-e 'unless File.directory?("#{d}/#{g}")' \
-e 'if rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
@@ -1387,113 +1561,127 @@ extract-gems$(gnumake:yes=-sequential): PHONY
-e 'end' \
gems/bundled_gems
-extract-gems$(gnumake:yes=-sequential): $(HAVE_GIT:yes=clone-bundled-gems-src)
-
-clone-bundled-gems-src: PHONY
- $(Q) $(BASERUBY) -C "$(srcdir)" \
- -Itool/lib -rbundled_gem -answ \
- -e 'BEGIN {git = $$git}' \
- -e 'gem, _, repo, rev = *$$F' \
- -e 'next if !rev or /^#/=~gem' \
- -e 'gemdir = "gems/src/#{gem}"' \
- -e 'BundledGem.checkout(gemdir, repo, rev, git: git)' \
- -e 'BundledGem.dummy_gemspec("#{gemdir}/#{gem}.gemspec")' \
- -- -git="$(GIT)" \
- gems/bundled_gems
+extract-gems$(sequential): $(HAVE_GIT:yes=clone-bundled-gems-src)
+flush-gems: outdate-bundled-gems
outdate-bundled-gems: PHONY
- $(Q) $(BASERUBY) $(tooldir)/$@.rb --make="$(MAKE)" --mflags="$(MFLAGS)" "$(srcdir)"
+ $(Q) $(BASERUBY) $(tooldir)/$@.rb --make="$(MAKE)" --mflags="$(MFLAGS)" \
+ --ruby-platform=$(arch) --ruby-version=$(ruby_version) \
+ "$(srcdir)"
update-bundled_gems: PHONY
$(Q) $(RUNRUBY) -rrubygems \
$(tooldir)/update-bundled_gems.rb \
"$(srcdir)/gems/bundled_gems" | \
$(IFCHANGE) "$(srcdir)/gems/bundled_gems" -
- $(GIT) -C "$(srcdir)" diff --no-ext-diff --ignore-submodules --exit-code || \
- $(GIT) -C "$(srcdir)" commit -m "Update bundled_gems" gems/bundled_gems
+ $(GIT_IN_SRC) diff --no-ext-diff --ignore-submodules --exit-code || \
+ $(GIT_IN_SRC) commit -m "Update bundled_gems" gems/bundled_gems
-PRECHECK_BUNDLED_GEMS = test-bundled-gems-precheck
+PRECHECK_BUNDLED_GEMS = yes
test-bundled-gems-precheck: $(TEST_RUNNABLE)-test-bundled-gems-precheck
-yes-test-bundled-gems-precheck: main
+yes-test-bundled-gems-precheck: $(PRECHECK_BUNDLED_GEMS:yes=main)
no-test-bundled-gems-precheck:
+yes-update-default-gemspecs no-update-default-gemspecs: update-default-gemspecs
+update-default-gemspecs: $(PREP) $(RBCONFIG)
+ @$(MAKEDIRS) $(srcdir)/.bundle/specifications
+ $(Q)$(MINIRUBY) -W0 -C "$(srcdir)" -I tool/lib -roptparse -routput -rbundled_gem \
+ -e "(out = Output.new).def_options(ARGV.options)" \
+ -e "BundledGem.update_default_gemspecs(ARGV.parse!, out, quiet: $(V).zero?)" \
+ -- -c -o .bundle/specifications lib ext
+
+install-for-test-bundled-gems: $(TEST_RUNNABLE)-install-for-test-bundled-gems
+no-install-for-test-bundled-gems: no-update-default-gemspecs
+yes-install-for-test-bundled-gems: yes-update-default-gemspecs
+ $(XRUBY) -C "$(srcdir)" -r./tool/lib/gem_env.rb bin/gem \
+ install --no-document --conservative \
+ "hoe" "json-schema:5.1.0" "test-unit-rr" "simplecov" "simplecov-html" "simplecov-json" "rspec" "zeitwerk" \
+ "sinatra" "rack" "tilt" "mustermann" "base64" "compact_index" "rack-test" "logger" "kpeg" "tracer" "minitest-mock"
+
test-bundled-gems-fetch: yes-test-bundled-gems-fetch
-yes-test-bundled-gems-fetch:
- $(ACTIONS_GROUP)
- $(Q) $(BASERUBY) -C $(srcdir)/gems ../tool/fetch-bundled_gems.rb src bundled_gems
- $(ACTIONS_ENDGROUP)
+yes-test-bundled-gems-fetch: clone-bundled-gems-src
+clone-bundled-gems-src: PHONY $(TIMESTAMPDIR)/bundled-gems-src.time
+$(TIMESTAMPDIR)/bundled-gems-src.time: $(srcdir)/gems/bundled_gems
+ $(Q) $(MAKEDIRS) $(@D)
+ $(Q) $(BASERUBY) -C $(srcdir) tool/fetch-bundled_gems.rb BUNDLED_GEMS="$(BUNDLED_GEMS)" gems/src gems/bundled_gems
+ $(Q) $(TOUCH) $@
no-test-bundled-gems-fetch:
-test-bundled-gems-prepare: $(PRECHECK_BUNDLED_GEMS) test-bundled-gems-fetch
test-bundled-gems-prepare: $(TEST_RUNNABLE)-test-bundled-gems-prepare
-no-test-bundled-gems-prepare: no-test-bundled-gems-precheck
-yes-test-bundled-gems-prepare: yes-test-bundled-gems-precheck
+no-test-bundled-gems-prepare: no-test-bundled-gems-precheck no-test-bundled-gems-fetch
+Preparing-test-bundled-gems:
$(ACTIONS_GROUP)
- $(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
- --install-dir .bundle --conservative "bundler" "minitest:~> 5" "test-unit" "rake" "hoe" "yard" "pry" "packnga" "rexml" "json-schema" "test-unit-rr"
+yes-test-bundled-gems-prepare: Preparing-test-bundled-gems $(DOT_WAIT)
$(ACTIONS_ENDGROUP)
+yes-test-bundled-gems-prepare: yes-test-bundled-gems-precheck $(DOT_WAIT)
+yes-test-bundled-gems-prepare: yes-install-for-test-bundled-gems $(DOT_WAIT)
+yes-test-bundled-gems-prepare: yes-test-bundled-gems-fetch $(DOT_WAIT)
+yes-test-bundled-gems-precheck: Preparing-test-bundled-gems
+yes-install-for-test-bundled-gems: Preparing-test-bundled-gems
+yes-test-bundled-gems-fetch: Preparing-test-bundled-gems
PREPARE_BUNDLED_GEMS = test-bundled-gems-prepare
-test-bundled-gems: $(TEST_RUNNABLE)-test-bundled-gems
+test-bundled-gems: $(TEST_RUNNABLE)-test-bundled-gems $(DOT_WAIT) $(TEST_RUNNABLE)-test-bundled-gems-spec
yes-test-bundled-gems: test-bundled-gems-run
no-test-bundled-gems:
+bundled_gems_spec-run: install-for-test-bundled-gems
+ $(XRUBY) -C $(srcdir) .bundle/bin/rspec spec/bundled_gems_spec.rb
+
# Override this to allow failure of specific gems on CI
# TEST_BUNDLED_GEMS_ALLOW_FAILURES =
BUNDLED_GEMS =
-test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)
+test-bundled-gems-run: $(TEST_RUNNABLE)-test-bundled-gems-run
+yes-test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)
$(gnumake_recursive)$(Q) $(XRUBY) $(tooldir)/test-bundled-gems.rb $(BUNDLED_GEMS)
+no-test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)
-test-syntax-suggest-precheck: $(TEST_RUNNABLE)-test-syntax-suggest-precheck
-no-test-syntax-suggest-precheck:
-yes-test-syntax-suggest-precheck: main
-
-test-syntax-suggest-prepare: $(TEST_RUNNABLE)-test-syntax-suggest-prepare
-no-test-syntax-suggest-prepare: no-test-syntax-suggest-precheck
-yes-test-syntax-suggest-prepare: yes-test-syntax-suggest-precheck
+test-bundled-gems-spec: $(TEST_RUNNABLE)-test-bundled-gems-spec
+yes-test-bundled-gems-spec: yes-test-all-precheck $(PREPARE_BUNDLED_GEMS)
$(ACTIONS_GROUP)
- $(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
- --install-dir .bundle --conservative "bundler" "rake" "rspec:~> 3" #"ruby-prof"
+ $(gnumake_recursive)$(Q) \
+ $(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/lib/_tmpdir \
+ $(srcdir)/spec/mspec/bin/mspec run --env BUNDLED_GEMS=$(BUNDLED_GEMS) -B $(srcdir)/spec/bundled_gems.mspec \
+ $(MSPECOPT) $(SPECOPTS)
$(ACTIONS_ENDGROUP)
+no-test-bundled-gems-spec:
-RSPECOPTS =
-SYNTAX_SUGGEST_SPECS =
-PREPARE_SYNTAX_SUGGEST = test-syntax-suggest-prepare
-test-syntax-suggest: $(TEST_RUNNABLE)-test-syntax-suggest
-yes-test-syntax-suggest: yes-$(PREPARE_SYNTAX_SUGGEST)
- $(XRUBY) -C $(srcdir) -Ispec/syntax_suggest:spec/lib .bundle/bin/rspec \
- --require spec_helper --require formatter_overrides --require spec_coverage \
- $(RSPECOPTS) spec/syntax_suggest/$(SYNTAX_SUGGEST_SPECS)
-no-test-syntax-suggest:
-check: $(DOT_WAIT) $(TEST_RUNNABLE)-$(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest
+test-syntax-suggest:
+
+check: $(DOT_WAIT) $(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest
+
+RAKER = $(XRUBY) -I$(srcdir)/gems/lib$(PATH_SEPARATOR)$(srcdir)/.bundle/lib \
+ -rrubygems $(srcdir)/.bundle/bin/rake
+rake:
+ $(RAKER) $(RAKE_OPTS) $(RAKE)
test-bundler-precheck: $(TEST_RUNNABLE)-test-bundler-precheck
no-test-bundler-precheck:
yes-test-bundler-precheck: main $(arch)-fake.rb
+yes-test-bundler-parallel-precheck: yes-test-bundler-precheck
+test-bundler-prepare: $(TEST_RUNNABLE)-test-bundler-prepare
no-test-bundler-prepare: no-test-bundler-precheck
yes-test-bundler-prepare: yes-test-bundler-precheck
$(ACTIONS_GROUP)
- $(XRUBY) -C $(srcdir) -Ilib \
- -e 'ENV["GEM_HOME"] = File.expand_path(".bundle")' \
- -e 'ENV["BUNDLE_APP_CONFIG"] = File.expand_path(".bundle")' \
- -e 'ENV["BUNDLE_PATH__SYSTEM"] = "true"' \
- -e 'ENV["BUNDLE_WITHOUT"] = "lint doc"' \
- -e 'load "spec/bundler/support/bundle.rb"' -- install --quiet --gemfile=tool/bundler/dev_gems.rb
+ $(XRUBY) -C $(srcdir) -Ilib -r./tool/lib/bundle_env.rb \
+ spec/bin/bundle install --quiet --gemfile=tool/bundler/dev_gems.rb
$(ACTIONS_ENDGROUP)
-RSPECOPTS =
+RSPECOPTS = -r formatter_overrides
BUNDLER_SPECS =
-PREPARE_BUNDLER = yes-test-bundler-prepare
+PREPARE_BUNDLER = $(TEST_RUNNABLE)-test-bundler-prepare
test-bundler: $(TEST_RUNNABLE)-test-bundler
yes-test-bundler: $(PREPARE_BUNDLER)
- $(gnumake_recursive)$(XRUBY) \
+ $(gnumake_recursive)$(XRUBY) --enable-gems \
-r./$(arch)-fake \
- -e "exec(*ARGV)" -- \
- $(XRUBY) -C $(srcdir) -Ispec/bundler:spec/lib .bundle/bin/rspec \
- --require spec_helper --require formatter_overrides $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
+ -r$(tooldir)/lib/_tmpdir \
+ -I$(srcdir)/spec/bundler -I$(srcdir)/spec/lib \
+ -e "Dir.chdir(ARGV.shift); load('spec/bin/rspec')" \
+ -s -- -no-report-tmpdir -- "$(srcdir)" \
+ -r spec_helper $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
no-test-bundler:
PARALLELRSPECOPTS = --runtime-log $(srcdir)/tmp/parallel_runtime_rspec.log
@@ -1501,22 +1689,23 @@ test-bundler-parallel: $(TEST_RUNNABLE)-test-bundler-parallel
yes-test-bundler-parallel: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
-r./$(arch)-fake \
+ -r$(tooldir)/lib/_tmpdir \
+ -I$(srcdir)/spec/bundler \
+ -e "ruby = ENV['RUBY']" \
-e "ARGV[-1] = File.expand_path(ARGV[-1])" \
- -e "exec(*ARGV)" -- \
- $(XRUBY) -I$(srcdir)/spec/bundler \
- -e "ENV['PARALLEL_TESTS_EXECUTABLE'] = ARGV.shift" \
+ -e "ENV['RSPEC_EXECUTABLE'] = ruby + ARGV.shift" \
-e "load ARGV.shift" \
- "$(XRUBY) -C $(srcdir) -Ispec/bundler:spec/lib .bundle/bin/rspec" \
- $(srcdir)/.bundle/bin/parallel_rspec \
- -o "--require spec_helper --require formatter_overrides" \
+ -s -- -no-report-tmpdir -- \
+ " -C $(srcdir) -Ispec/bundler -Ispec/lib .bundle/bin/rspec -r spec_helper" \
+ $(srcdir)/spec/bin/parallel_rspec $(RSPECOPTS) \
$(PARALLELRSPECOPTS) $(srcdir)/spec/bundler/$(BUNDLER_SPECS)
no-test-bundler-parallel:
# The annocheck supports ELF format binaries compiled for any OS and for any
# architecture. It is designed to be independent of the host OS and the
# architecture. The test-annocheck.sh requires docker or podman.
-test-annocheck: $(PROGRAM)
- $(tooldir)/test-annocheck.sh $(PROGRAM)
+test-annocheck: $(PROGRAM) $(LIBRUBY_SO)
+ $(tooldir)/test-annocheck.sh $(PROGRAM) $(LIBRUBY_SO)
GEM = up
sync-default-gems:
@@ -1529,7 +1718,7 @@ UNICODE_FILES = $(UNICODE_SRC_DATA_DIR)/UnicodeData.txt \
$(UNICODE_SRC_DATA_DIR)/SpecialCasing.txt \
$(empty)
-UNICODE_PROPERTY_FILES = \
+UNICODE_PROPERTY_FILES = \
$(UNICODE_SRC_DATA_DIR)/Blocks.txt \
$(UNICODE_SRC_DATA_DIR)/DerivedAge.txt \
$(UNICODE_SRC_DATA_DIR)/DerivedCoreProperties.txt \
@@ -1539,7 +1728,7 @@ UNICODE_PROPERTY_FILES = \
$(UNICODE_SRC_DATA_DIR)/Scripts.txt \
$(empty)
-UNICODE_AUXILIARY_FILES = \
+UNICODE_AUXILIARY_FILES = \
$(UNICODE_SRC_DATA_DIR)/auxiliary/GraphemeBreakProperty.txt \
$(UNICODE_SRC_DATA_DIR)/auxiliary/GraphemeBreakTest.txt \
$(empty)
@@ -1580,34 +1769,50 @@ UNICODE_UCD_EMOJI_DOWNLOAD = \
UNICODE_EMOJI_DOWNLOAD = \
$(UNICODE_DOWNLOADER) \
-d $(UNICODE_SRC_EMOJI_DATA_DIR) \
- -p emoji/$(UNICODE_EMOJI_VERSION)
+ -p $(UNICODE_VERSION)/emoji
-update-unicode-files: $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
-$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES):
+update-unicode-files:
$(ECHO) Downloading Unicode $(UNICODE_VERSION) data and property files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)"
$(Q) $(UNICODE_DOWNLOAD) $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
-update-unicode-auxiliary-files: $(UNICODE_AUXILIARY_FILES)
-$(UNICODE_AUXILIARY_FILES):
+update-unicode-auxiliary-files:
$(ECHO) Downloading Unicode $(UNICODE_VERSION) auxiliary files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)/auxiliary"
$(Q) $(UNICODE_AUXILIARY_DOWNLOAD) $(UNICODE_AUXILIARY_FILES)
-update-unicode-ucd-emoji-files: $(UNICODE_UCD_EMOJI_FILES)
-$(UNICODE_UCD_EMOJI_FILES):
+update-unicode-ucd-emoji-files:
$(ECHO) Downloading Unicode UCD emoji $(UNICODE_EMOJI_VERSION) files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)/emoji"
$(Q) $(UNICODE_UCD_EMOJI_DOWNLOAD) $(UNICODE_UCD_EMOJI_FILES)
-update-unicode-emoji-files: $(UNICODE_EMOJI_FILES)
-$(UNICODE_EMOJI_FILES):
+update-unicode-emoji-files:
$(ECHO) Downloading Unicode emoji $(UNICODE_EMOJI_VERSION) files...
$(Q) $(MAKEDIRS) "$(UNICODE_SRC_EMOJI_DATA_DIR)"
$(Q) $(UNICODE_EMOJI_DOWNLOAD) $(UNICODE_EMOJI_FILES)
-$(srcdir)/lib/unicode_normalize/tables.rb: \
- $(UNICODE_SRC_DATA_DIR)/$(HAVE_BASERUBY:yes=.unicode-tables.time)
+$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES):
+ $(ECHO) Downloading Unicode $(UNICODE_VERSION) data and property files...
+ $(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)"
+ $(Q) $(UNICODE_DOWNLOAD) $@
+
+$(UNICODE_AUXILIARY_FILES):
+ $(ECHO) Downloading Unicode $(UNICODE_VERSION) auxiliary files...
+ $(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)/auxiliary"
+ $(Q) $(UNICODE_AUXILIARY_DOWNLOAD) $@
+
+$(UNICODE_UCD_EMOJI_FILES):
+ $(ECHO) Downloading Unicode UCD emoji $(UNICODE_EMOJI_VERSION) files...
+ $(Q) $(MAKEDIRS) "$(UNICODE_SRC_DATA_DIR)/emoji"
+ $(Q) $(UNICODE_UCD_EMOJI_DOWNLOAD) $@
+
+$(UNICODE_EMOJI_FILES):
+ $(ECHO) Downloading Unicode emoji $(UNICODE_EMOJI_VERSION) files...
+ $(Q) $(MAKEDIRS) "$(UNICODE_SRC_EMOJI_DATA_DIR)"
+ $(Q) $(UNICODE_EMOJI_DOWNLOAD) $@
+
+$(srcdir)/lib/unicode_normalize/$(HAVE_BASERUBY:yes=tables.rb): \
+ $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time
$(UNICODE_SRC_DATA_DIR)/$(ALWAYS_UPDATE_UNICODE:yes=.unicode-tables.time): \
$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES) \
@@ -1658,6 +1863,16 @@ $(UNICODE_HDR_DIR)/name2ctype.h:
$(UNICODE_SRC_DATA_DIR) $(UNICODE_SRC_EMOJI_DATA_DIR) > $@.new
$(MV) $@.new $@
+srcs-doc: $(srcdir)/doc/language/regexp/unicode_properties.rdoc
+$(srcdir)/doc/language/regexp/$(ALWAYS_UPDATE_UNICODE:yes=unicode_properties.rdoc): \
+ $(UNICODE_HDR_DIR)/name2ctype.h $(UNICODE_PROPERTY_FILES)
+
+$(srcdir)/doc/language/regexp/unicode_properties.rdoc:
+ $(Q) $(BOOTSTRAPRUBY) $(tooldir)/generic_erb.rb -c -o $@ \
+ $(srcdir)/template/unicode_properties.rdoc.tmpl \
+ $(UNICODE_SRC_DATA_DIR) $(UNICODE_HDR_DIR)/name2ctype.h || \
+ $(TOUCH) $@
+
# the next non-comment line was:
# $(UNICODE_HDR_DIR)/casefold.h: $(tooldir)/enc-case-folding.rb \
# but was changed to make sure CI works on systems that don't have gperf
@@ -1689,6 +1904,9 @@ clean-gems:
CLEAN_CACHE = clean-extlibs
+prepare-package: prereq after-update
+clean-cache: $(CLEAN_CACHE)
+
info: info-program info-libruby_a info-libruby_so info-arch
info-program: PHONY
@echo PROGRAM=$(PROGRAM)
@@ -1701,6 +1919,7 @@ info-arch: PHONY
exam: check
exam: $(DOT_WAIT) test-bundler-parallel
+exam: $(DOT_WAIT) bundled_gems_spec-run
exam: $(DOT_WAIT) test-bundled-gems
love: sudo-precheck up all test exam install
@@ -1714,20 +1933,65 @@ sudo-precheck: PHONY
@$(SUDO) echo > $(NULL)
update-man-date: PHONY
- -$(Q) $(BASERUBY) -I"$(tooldir)/lib" -rvcs -i -p \
+ $(Q) $(BASERUBY) -I"$(tooldir)/lib" -rvcs -i -p \
-e 'BEGIN{@vcs=VCS.detect(ARGV.shift)}' \
- -e '$$_.sub!(/^(\.Dd ).*/){$$1+@vcs.modified(ARGF.path).strftime("%B %d, %Y")}' \
+ -e '$$_.sub!(/^(\.Dd ).*/){$$1+@vcs.author_date(@vcs.relative_to(ARGF.path)).strftime("%B %d, %Y")}' \
"$(srcdir)" "$(srcdir)"/man/*.1
.PHONY: ChangeLog
ChangeLog:
$(ECHO) Generating $@
-$(Q) $(BASERUBY) -I"$(tooldir)/lib" -rvcs \
- -e 'VCS.detect(ARGV[0]).export_changelog("@", nil, nil, ARGV[1])' \
+ -e 'VCS.detect(ARGV[0]).export_changelog(path: ARGV[1])' \
"$(srcdir)" $@
+# CAUTION: If using GNU make 3 which does not support `.WAIT`, this
+# recipe with multiple jobs makes build and `git reset` run
+# simultaneously, and will cause inconsistent results. Run with `-j1`
+# or update GNU make.
+nightly: yesterday $(DOT_WAIT) install
+ $(NULLCMD)
+
+# Rewind to the last commit "yesterday". "Yesterday" means here the
+# period where `RUBY_RELEASE_DATE` is the day before the date to be
+# generated now. In short, the yesterday in JST-9 time zone.
+yesterday: rewindable
+
+rewindable:
+ $(GIT_IN_SRC) status --porcelain
+ $(GIT_IN_SRC) diff --quiet
+
HELP_EXTRA_TASKS = ""
+gc/Makefile:
+ $(MAKEDIRS) $(@D)
+ $(MESSAGE_BEGIN) \
+ "all:" \
+ " @echo You must specify MODULAR_GC with the GC to build" \
+ " @exit 1" \
+ $(MESSAGE_END) > $@
+gc/distclean gc/realclean::
+ -$(Q) $(RM) gc/Makefile
+
+modular-gc-precheck:
+modular-gc: probes.h gc/Makefile
+ $(Q) $(RUNRUBY) $(srcdir)/ext/extmk.rb \
+ $(SCRIPT_ARGS) \
+ --make='$(MAKE)' --make-flags="V=$(V) MINIRUBY='$(MINIRUBY)'" \
+ --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
+ --ext-build-dir=gc --command-output=gc/$(MODULAR_GC)/exts.mk -- \
+ configure gc/$(MODULAR_GC)
+ $(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./
+install-modular-gc: modular-gc modular-gc-precheck
+ $(Q) $(MAKEDIRS) $(modular_gc_dir)
+ $(CP) gc/$(MODULAR_GC)/librubygc.$(MODULAR_GC).$(DLEXT) $(modular_gc_dir)
+
+clean-modular-gc: gc/clean
+distclean-modular-gc: gc/distclean
+realclean-modular-gc: gc/realclean
+distclean-modular-gc realclean-modular-gc:
+ -$(Q) $(RMDIR) gc
+
help: PHONY
$(MESSAGE_BEGIN) \
" Makefile of Ruby" \
@@ -1769,16629 +2033,11 @@ help: PHONY
" golf: build goruby for golfers" \
$(HELP_EXTRA_TASKS) \
"see DeveloperHowto for more detail: " \
- " https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto" \
+ " https://github.com/ruby/ruby/wiki/Developer-How-To" \
$(MESSAGE_END)
$(CROSS_COMPILING:yes=)builtin.$(OBJEXT): {$(VPATH)}mini_builtin.c
$(CROSS_COMPILING:yes=)builtin.$(OBJEXT): {$(VPATH)}miniprelude.c
-# AUTOGENERATED DEPENDENCIES START
-addr2line.$(OBJEXT): {$(VPATH)}addr2line.c
-addr2line.$(OBJEXT): {$(VPATH)}addr2line.h
-addr2line.$(OBJEXT): {$(VPATH)}assert.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-addr2line.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-addr2line.$(OBJEXT): {$(VPATH)}config.h
-addr2line.$(OBJEXT): {$(VPATH)}defines.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/assume.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/cast.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/config.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/dosish.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-addr2line.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-addr2line.$(OBJEXT): {$(VPATH)}missing.h
-array.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-array.$(OBJEXT): $(top_srcdir)/internal/array.h
-array.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-array.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-array.$(OBJEXT): $(top_srcdir)/internal/bits.h
-array.$(OBJEXT): $(top_srcdir)/internal/class.h
-array.$(OBJEXT): $(top_srcdir)/internal/compar.h
-array.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-array.$(OBJEXT): $(top_srcdir)/internal/enum.h
-array.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-array.$(OBJEXT): $(top_srcdir)/internal/gc.h
-array.$(OBJEXT): $(top_srcdir)/internal/hash.h
-array.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-array.$(OBJEXT): $(top_srcdir)/internal/object.h
-array.$(OBJEXT): $(top_srcdir)/internal/proc.h
-array.$(OBJEXT): $(top_srcdir)/internal/rational.h
-array.$(OBJEXT): $(top_srcdir)/internal/serial.h
-array.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-array.$(OBJEXT): $(top_srcdir)/internal/variable.h
-array.$(OBJEXT): $(top_srcdir)/internal/vm.h
-array.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-array.$(OBJEXT): {$(VPATH)}array.c
-array.$(OBJEXT): {$(VPATH)}array.rbinc
-array.$(OBJEXT): {$(VPATH)}assert.h
-array.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-array.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-array.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-array.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-array.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-array.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-array.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-array.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-array.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-array.$(OBJEXT): {$(VPATH)}builtin.h
-array.$(OBJEXT): {$(VPATH)}config.h
-array.$(OBJEXT): {$(VPATH)}constant.h
-array.$(OBJEXT): {$(VPATH)}debug_counter.h
-array.$(OBJEXT): {$(VPATH)}defines.h
-array.$(OBJEXT): {$(VPATH)}encoding.h
-array.$(OBJEXT): {$(VPATH)}id.h
-array.$(OBJEXT): {$(VPATH)}id_table.h
-array.$(OBJEXT): {$(VPATH)}intern.h
-array.$(OBJEXT): {$(VPATH)}internal.h
-array.$(OBJEXT): {$(VPATH)}internal/abi.h
-array.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-array.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-array.$(OBJEXT): {$(VPATH)}internal/assume.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-array.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-array.$(OBJEXT): {$(VPATH)}internal/cast.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-array.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-array.$(OBJEXT): {$(VPATH)}internal/config.h
-array.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-array.$(OBJEXT): {$(VPATH)}internal/core.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-array.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-array.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-array.$(OBJEXT): {$(VPATH)}internal/ctype.h
-array.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-array.$(OBJEXT): {$(VPATH)}internal/dosish.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-array.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-array.$(OBJEXT): {$(VPATH)}internal/error.h
-array.$(OBJEXT): {$(VPATH)}internal/eval.h
-array.$(OBJEXT): {$(VPATH)}internal/event.h
-array.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-array.$(OBJEXT): {$(VPATH)}internal/gc.h
-array.$(OBJEXT): {$(VPATH)}internal/glob.h
-array.$(OBJEXT): {$(VPATH)}internal/globals.h
-array.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-array.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-array.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-array.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-array.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-array.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-array.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-array.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-array.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-array.$(OBJEXT): {$(VPATH)}internal/iterator.h
-array.$(OBJEXT): {$(VPATH)}internal/memory.h
-array.$(OBJEXT): {$(VPATH)}internal/method.h
-array.$(OBJEXT): {$(VPATH)}internal/module.h
-array.$(OBJEXT): {$(VPATH)}internal/newobj.h
-array.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-array.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-array.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-array.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-array.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-array.$(OBJEXT): {$(VPATH)}internal/symbol.h
-array.$(OBJEXT): {$(VPATH)}internal/value.h
-array.$(OBJEXT): {$(VPATH)}internal/value_type.h
-array.$(OBJEXT): {$(VPATH)}internal/variable.h
-array.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-array.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-array.$(OBJEXT): {$(VPATH)}missing.h
-array.$(OBJEXT): {$(VPATH)}onigmo.h
-array.$(OBJEXT): {$(VPATH)}oniguruma.h
-array.$(OBJEXT): {$(VPATH)}probes.dmyh
-array.$(OBJEXT): {$(VPATH)}probes.h
-array.$(OBJEXT): {$(VPATH)}ruby_assert.h
-array.$(OBJEXT): {$(VPATH)}shape.h
-array.$(OBJEXT): {$(VPATH)}st.h
-array.$(OBJEXT): {$(VPATH)}subst.h
-array.$(OBJEXT): {$(VPATH)}transient_heap.h
-array.$(OBJEXT): {$(VPATH)}util.h
-ast.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-ast.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-ast.$(OBJEXT): $(CCAN_DIR)/list/list.h
-ast.$(OBJEXT): $(CCAN_DIR)/str/str.h
-ast.$(OBJEXT): $(hdrdir)/ruby.h
-ast.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-ast.$(OBJEXT): $(top_srcdir)/internal/array.h
-ast.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-ast.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-ast.$(OBJEXT): $(top_srcdir)/internal/gc.h
-ast.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-ast.$(OBJEXT): $(top_srcdir)/internal/parse.h
-ast.$(OBJEXT): $(top_srcdir)/internal/serial.h
-ast.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-ast.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-ast.$(OBJEXT): $(top_srcdir)/internal/variable.h
-ast.$(OBJEXT): $(top_srcdir)/internal/vm.h
-ast.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-ast.$(OBJEXT): {$(VPATH)}assert.h
-ast.$(OBJEXT): {$(VPATH)}ast.c
-ast.$(OBJEXT): {$(VPATH)}ast.rbinc
-ast.$(OBJEXT): {$(VPATH)}atomic.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-ast.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-ast.$(OBJEXT): {$(VPATH)}builtin.h
-ast.$(OBJEXT): {$(VPATH)}config.h
-ast.$(OBJEXT): {$(VPATH)}constant.h
-ast.$(OBJEXT): {$(VPATH)}defines.h
-ast.$(OBJEXT): {$(VPATH)}encoding.h
-ast.$(OBJEXT): {$(VPATH)}id.h
-ast.$(OBJEXT): {$(VPATH)}id_table.h
-ast.$(OBJEXT): {$(VPATH)}intern.h
-ast.$(OBJEXT): {$(VPATH)}internal.h
-ast.$(OBJEXT): {$(VPATH)}internal/abi.h
-ast.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-ast.$(OBJEXT): {$(VPATH)}internal/assume.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-ast.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-ast.$(OBJEXT): {$(VPATH)}internal/cast.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-ast.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-ast.$(OBJEXT): {$(VPATH)}internal/config.h
-ast.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-ast.$(OBJEXT): {$(VPATH)}internal/core.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-ast.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-ast.$(OBJEXT): {$(VPATH)}internal/ctype.h
-ast.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-ast.$(OBJEXT): {$(VPATH)}internal/dosish.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-ast.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-ast.$(OBJEXT): {$(VPATH)}internal/error.h
-ast.$(OBJEXT): {$(VPATH)}internal/eval.h
-ast.$(OBJEXT): {$(VPATH)}internal/event.h
-ast.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-ast.$(OBJEXT): {$(VPATH)}internal/gc.h
-ast.$(OBJEXT): {$(VPATH)}internal/glob.h
-ast.$(OBJEXT): {$(VPATH)}internal/globals.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-ast.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-ast.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-ast.$(OBJEXT): {$(VPATH)}internal/iterator.h
-ast.$(OBJEXT): {$(VPATH)}internal/memory.h
-ast.$(OBJEXT): {$(VPATH)}internal/method.h
-ast.$(OBJEXT): {$(VPATH)}internal/module.h
-ast.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ast.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-ast.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-ast.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-ast.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-ast.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-ast.$(OBJEXT): {$(VPATH)}internal/symbol.h
-ast.$(OBJEXT): {$(VPATH)}internal/value.h
-ast.$(OBJEXT): {$(VPATH)}internal/value_type.h
-ast.$(OBJEXT): {$(VPATH)}internal/variable.h
-ast.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-ast.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-ast.$(OBJEXT): {$(VPATH)}iseq.h
-ast.$(OBJEXT): {$(VPATH)}method.h
-ast.$(OBJEXT): {$(VPATH)}missing.h
-ast.$(OBJEXT): {$(VPATH)}node.h
-ast.$(OBJEXT): {$(VPATH)}onigmo.h
-ast.$(OBJEXT): {$(VPATH)}oniguruma.h
-ast.$(OBJEXT): {$(VPATH)}ruby_assert.h
-ast.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-ast.$(OBJEXT): {$(VPATH)}shape.h
-ast.$(OBJEXT): {$(VPATH)}st.h
-ast.$(OBJEXT): {$(VPATH)}subst.h
-ast.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-ast.$(OBJEXT): {$(VPATH)}thread_native.h
-ast.$(OBJEXT): {$(VPATH)}util.h
-ast.$(OBJEXT): {$(VPATH)}vm_core.h
-ast.$(OBJEXT): {$(VPATH)}vm_opts.h
-bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/bits.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/class.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/complex.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/gc.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/object.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/serial.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/variable.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/vm.h
-bignum.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-bignum.$(OBJEXT): {$(VPATH)}assert.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-bignum.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-bignum.$(OBJEXT): {$(VPATH)}bignum.c
-bignum.$(OBJEXT): {$(VPATH)}config.h
-bignum.$(OBJEXT): {$(VPATH)}constant.h
-bignum.$(OBJEXT): {$(VPATH)}defines.h
-bignum.$(OBJEXT): {$(VPATH)}id.h
-bignum.$(OBJEXT): {$(VPATH)}id_table.h
-bignum.$(OBJEXT): {$(VPATH)}intern.h
-bignum.$(OBJEXT): {$(VPATH)}internal.h
-bignum.$(OBJEXT): {$(VPATH)}internal/abi.h
-bignum.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-bignum.$(OBJEXT): {$(VPATH)}internal/assume.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-bignum.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-bignum.$(OBJEXT): {$(VPATH)}internal/cast.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-bignum.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-bignum.$(OBJEXT): {$(VPATH)}internal/config.h
-bignum.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-bignum.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-bignum.$(OBJEXT): {$(VPATH)}internal/ctype.h
-bignum.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-bignum.$(OBJEXT): {$(VPATH)}internal/dosish.h
-bignum.$(OBJEXT): {$(VPATH)}internal/error.h
-bignum.$(OBJEXT): {$(VPATH)}internal/eval.h
-bignum.$(OBJEXT): {$(VPATH)}internal/event.h
-bignum.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-bignum.$(OBJEXT): {$(VPATH)}internal/gc.h
-bignum.$(OBJEXT): {$(VPATH)}internal/glob.h
-bignum.$(OBJEXT): {$(VPATH)}internal/globals.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-bignum.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-bignum.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-bignum.$(OBJEXT): {$(VPATH)}internal/iterator.h
-bignum.$(OBJEXT): {$(VPATH)}internal/memory.h
-bignum.$(OBJEXT): {$(VPATH)}internal/method.h
-bignum.$(OBJEXT): {$(VPATH)}internal/module.h
-bignum.$(OBJEXT): {$(VPATH)}internal/newobj.h
-bignum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-bignum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-bignum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-bignum.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-bignum.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-bignum.$(OBJEXT): {$(VPATH)}internal/symbol.h
-bignum.$(OBJEXT): {$(VPATH)}internal/value.h
-bignum.$(OBJEXT): {$(VPATH)}internal/value_type.h
-bignum.$(OBJEXT): {$(VPATH)}internal/variable.h
-bignum.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-bignum.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-bignum.$(OBJEXT): {$(VPATH)}missing.h
-bignum.$(OBJEXT): {$(VPATH)}ruby_assert.h
-bignum.$(OBJEXT): {$(VPATH)}shape.h
-bignum.$(OBJEXT): {$(VPATH)}st.h
-bignum.$(OBJEXT): {$(VPATH)}subst.h
-bignum.$(OBJEXT): {$(VPATH)}thread.h
-bignum.$(OBJEXT): {$(VPATH)}util.h
-builtin.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-builtin.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-builtin.$(OBJEXT): $(CCAN_DIR)/list/list.h
-builtin.$(OBJEXT): $(CCAN_DIR)/str/str.h
-builtin.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/array.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/gc.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/serial.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/variable.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/vm.h
-builtin.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-builtin.$(OBJEXT): {$(VPATH)}assert.h
-builtin.$(OBJEXT): {$(VPATH)}atomic.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-builtin.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-builtin.$(OBJEXT): {$(VPATH)}builtin.c
-builtin.$(OBJEXT): {$(VPATH)}builtin.h
-builtin.$(OBJEXT): {$(VPATH)}builtin_binary.inc
-builtin.$(OBJEXT): {$(VPATH)}config.h
-builtin.$(OBJEXT): {$(VPATH)}constant.h
-builtin.$(OBJEXT): {$(VPATH)}defines.h
-builtin.$(OBJEXT): {$(VPATH)}id.h
-builtin.$(OBJEXT): {$(VPATH)}id_table.h
-builtin.$(OBJEXT): {$(VPATH)}intern.h
-builtin.$(OBJEXT): {$(VPATH)}internal.h
-builtin.$(OBJEXT): {$(VPATH)}internal/abi.h
-builtin.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-builtin.$(OBJEXT): {$(VPATH)}internal/assume.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-builtin.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-builtin.$(OBJEXT): {$(VPATH)}internal/cast.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-builtin.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-builtin.$(OBJEXT): {$(VPATH)}internal/config.h
-builtin.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-builtin.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-builtin.$(OBJEXT): {$(VPATH)}internal/ctype.h
-builtin.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-builtin.$(OBJEXT): {$(VPATH)}internal/dosish.h
-builtin.$(OBJEXT): {$(VPATH)}internal/error.h
-builtin.$(OBJEXT): {$(VPATH)}internal/eval.h
-builtin.$(OBJEXT): {$(VPATH)}internal/event.h
-builtin.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-builtin.$(OBJEXT): {$(VPATH)}internal/gc.h
-builtin.$(OBJEXT): {$(VPATH)}internal/glob.h
-builtin.$(OBJEXT): {$(VPATH)}internal/globals.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-builtin.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-builtin.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-builtin.$(OBJEXT): {$(VPATH)}internal/iterator.h
-builtin.$(OBJEXT): {$(VPATH)}internal/memory.h
-builtin.$(OBJEXT): {$(VPATH)}internal/method.h
-builtin.$(OBJEXT): {$(VPATH)}internal/module.h
-builtin.$(OBJEXT): {$(VPATH)}internal/newobj.h
-builtin.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-builtin.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-builtin.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-builtin.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-builtin.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-builtin.$(OBJEXT): {$(VPATH)}internal/symbol.h
-builtin.$(OBJEXT): {$(VPATH)}internal/value.h
-builtin.$(OBJEXT): {$(VPATH)}internal/value_type.h
-builtin.$(OBJEXT): {$(VPATH)}internal/variable.h
-builtin.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-builtin.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-builtin.$(OBJEXT): {$(VPATH)}iseq.h
-builtin.$(OBJEXT): {$(VPATH)}method.h
-builtin.$(OBJEXT): {$(VPATH)}missing.h
-builtin.$(OBJEXT): {$(VPATH)}node.h
-builtin.$(OBJEXT): {$(VPATH)}ruby_assert.h
-builtin.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-builtin.$(OBJEXT): {$(VPATH)}shape.h
-builtin.$(OBJEXT): {$(VPATH)}st.h
-builtin.$(OBJEXT): {$(VPATH)}subst.h
-builtin.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-builtin.$(OBJEXT): {$(VPATH)}thread_native.h
-builtin.$(OBJEXT): {$(VPATH)}vm_core.h
-builtin.$(OBJEXT): {$(VPATH)}vm_opts.h
-class.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-class.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-class.$(OBJEXT): $(CCAN_DIR)/list/list.h
-class.$(OBJEXT): $(CCAN_DIR)/str/str.h
-class.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-class.$(OBJEXT): $(top_srcdir)/internal/array.h
-class.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-class.$(OBJEXT): $(top_srcdir)/internal/class.h
-class.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-class.$(OBJEXT): $(top_srcdir)/internal/eval.h
-class.$(OBJEXT): $(top_srcdir)/internal/gc.h
-class.$(OBJEXT): $(top_srcdir)/internal/hash.h
-class.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-class.$(OBJEXT): $(top_srcdir)/internal/object.h
-class.$(OBJEXT): $(top_srcdir)/internal/serial.h
-class.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-class.$(OBJEXT): $(top_srcdir)/internal/string.h
-class.$(OBJEXT): $(top_srcdir)/internal/variable.h
-class.$(OBJEXT): $(top_srcdir)/internal/vm.h
-class.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-class.$(OBJEXT): {$(VPATH)}assert.h
-class.$(OBJEXT): {$(VPATH)}atomic.h
-class.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-class.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-class.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-class.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-class.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-class.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-class.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-class.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-class.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-class.$(OBJEXT): {$(VPATH)}class.c
-class.$(OBJEXT): {$(VPATH)}config.h
-class.$(OBJEXT): {$(VPATH)}constant.h
-class.$(OBJEXT): {$(VPATH)}debug_counter.h
-class.$(OBJEXT): {$(VPATH)}defines.h
-class.$(OBJEXT): {$(VPATH)}encoding.h
-class.$(OBJEXT): {$(VPATH)}id.h
-class.$(OBJEXT): {$(VPATH)}id_table.h
-class.$(OBJEXT): {$(VPATH)}intern.h
-class.$(OBJEXT): {$(VPATH)}internal.h
-class.$(OBJEXT): {$(VPATH)}internal/abi.h
-class.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-class.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-class.$(OBJEXT): {$(VPATH)}internal/assume.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-class.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-class.$(OBJEXT): {$(VPATH)}internal/cast.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-class.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-class.$(OBJEXT): {$(VPATH)}internal/config.h
-class.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-class.$(OBJEXT): {$(VPATH)}internal/core.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-class.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-class.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-class.$(OBJEXT): {$(VPATH)}internal/ctype.h
-class.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-class.$(OBJEXT): {$(VPATH)}internal/dosish.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-class.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-class.$(OBJEXT): {$(VPATH)}internal/error.h
-class.$(OBJEXT): {$(VPATH)}internal/eval.h
-class.$(OBJEXT): {$(VPATH)}internal/event.h
-class.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-class.$(OBJEXT): {$(VPATH)}internal/gc.h
-class.$(OBJEXT): {$(VPATH)}internal/glob.h
-class.$(OBJEXT): {$(VPATH)}internal/globals.h
-class.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-class.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-class.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-class.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-class.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-class.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-class.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-class.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-class.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-class.$(OBJEXT): {$(VPATH)}internal/iterator.h
-class.$(OBJEXT): {$(VPATH)}internal/memory.h
-class.$(OBJEXT): {$(VPATH)}internal/method.h
-class.$(OBJEXT): {$(VPATH)}internal/module.h
-class.$(OBJEXT): {$(VPATH)}internal/newobj.h
-class.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-class.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-class.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-class.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-class.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-class.$(OBJEXT): {$(VPATH)}internal/symbol.h
-class.$(OBJEXT): {$(VPATH)}internal/value.h
-class.$(OBJEXT): {$(VPATH)}internal/value_type.h
-class.$(OBJEXT): {$(VPATH)}internal/variable.h
-class.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-class.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-class.$(OBJEXT): {$(VPATH)}method.h
-class.$(OBJEXT): {$(VPATH)}missing.h
-class.$(OBJEXT): {$(VPATH)}node.h
-class.$(OBJEXT): {$(VPATH)}onigmo.h
-class.$(OBJEXT): {$(VPATH)}oniguruma.h
-class.$(OBJEXT): {$(VPATH)}ruby_assert.h
-class.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-class.$(OBJEXT): {$(VPATH)}shape.h
-class.$(OBJEXT): {$(VPATH)}st.h
-class.$(OBJEXT): {$(VPATH)}subst.h
-class.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-class.$(OBJEXT): {$(VPATH)}thread_native.h
-class.$(OBJEXT): {$(VPATH)}vm_core.h
-class.$(OBJEXT): {$(VPATH)}vm_opts.h
-compar.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-compar.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-compar.$(OBJEXT): $(top_srcdir)/internal/compar.h
-compar.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-compar.$(OBJEXT): $(top_srcdir)/internal/error.h
-compar.$(OBJEXT): $(top_srcdir)/internal/serial.h
-compar.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-compar.$(OBJEXT): $(top_srcdir)/internal/string.h
-compar.$(OBJEXT): $(top_srcdir)/internal/vm.h
-compar.$(OBJEXT): {$(VPATH)}assert.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-compar.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-compar.$(OBJEXT): {$(VPATH)}compar.c
-compar.$(OBJEXT): {$(VPATH)}config.h
-compar.$(OBJEXT): {$(VPATH)}defines.h
-compar.$(OBJEXT): {$(VPATH)}encoding.h
-compar.$(OBJEXT): {$(VPATH)}id.h
-compar.$(OBJEXT): {$(VPATH)}intern.h
-compar.$(OBJEXT): {$(VPATH)}internal.h
-compar.$(OBJEXT): {$(VPATH)}internal/abi.h
-compar.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-compar.$(OBJEXT): {$(VPATH)}internal/assume.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-compar.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-compar.$(OBJEXT): {$(VPATH)}internal/cast.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-compar.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-compar.$(OBJEXT): {$(VPATH)}internal/config.h
-compar.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-compar.$(OBJEXT): {$(VPATH)}internal/core.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-compar.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-compar.$(OBJEXT): {$(VPATH)}internal/ctype.h
-compar.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-compar.$(OBJEXT): {$(VPATH)}internal/dosish.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-compar.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-compar.$(OBJEXT): {$(VPATH)}internal/error.h
-compar.$(OBJEXT): {$(VPATH)}internal/eval.h
-compar.$(OBJEXT): {$(VPATH)}internal/event.h
-compar.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-compar.$(OBJEXT): {$(VPATH)}internal/gc.h
-compar.$(OBJEXT): {$(VPATH)}internal/glob.h
-compar.$(OBJEXT): {$(VPATH)}internal/globals.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-compar.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-compar.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-compar.$(OBJEXT): {$(VPATH)}internal/iterator.h
-compar.$(OBJEXT): {$(VPATH)}internal/memory.h
-compar.$(OBJEXT): {$(VPATH)}internal/method.h
-compar.$(OBJEXT): {$(VPATH)}internal/module.h
-compar.$(OBJEXT): {$(VPATH)}internal/newobj.h
-compar.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-compar.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-compar.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-compar.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-compar.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-compar.$(OBJEXT): {$(VPATH)}internal/symbol.h
-compar.$(OBJEXT): {$(VPATH)}internal/value.h
-compar.$(OBJEXT): {$(VPATH)}internal/value_type.h
-compar.$(OBJEXT): {$(VPATH)}internal/variable.h
-compar.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-compar.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-compar.$(OBJEXT): {$(VPATH)}missing.h
-compar.$(OBJEXT): {$(VPATH)}onigmo.h
-compar.$(OBJEXT): {$(VPATH)}oniguruma.h
-compar.$(OBJEXT): {$(VPATH)}st.h
-compar.$(OBJEXT): {$(VPATH)}subst.h
-compile.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-compile.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-compile.$(OBJEXT): $(CCAN_DIR)/list/list.h
-compile.$(OBJEXT): $(CCAN_DIR)/str/str.h
-compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-compile.$(OBJEXT): $(top_srcdir)/internal/array.h
-compile.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-compile.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-compile.$(OBJEXT): $(top_srcdir)/internal/bits.h
-compile.$(OBJEXT): $(top_srcdir)/internal/class.h
-compile.$(OBJEXT): $(top_srcdir)/internal/compile.h
-compile.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-compile.$(OBJEXT): $(top_srcdir)/internal/complex.h
-compile.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-compile.$(OBJEXT): $(top_srcdir)/internal/error.h
-compile.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-compile.$(OBJEXT): $(top_srcdir)/internal/gc.h
-compile.$(OBJEXT): $(top_srcdir)/internal/hash.h
-compile.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-compile.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-compile.$(OBJEXT): $(top_srcdir)/internal/object.h
-compile.$(OBJEXT): $(top_srcdir)/internal/rational.h
-compile.$(OBJEXT): $(top_srcdir)/internal/re.h
-compile.$(OBJEXT): $(top_srcdir)/internal/serial.h
-compile.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-compile.$(OBJEXT): $(top_srcdir)/internal/string.h
-compile.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-compile.$(OBJEXT): $(top_srcdir)/internal/thread.h
-compile.$(OBJEXT): $(top_srcdir)/internal/variable.h
-compile.$(OBJEXT): $(top_srcdir)/internal/vm.h
-compile.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-compile.$(OBJEXT): {$(VPATH)}assert.h
-compile.$(OBJEXT): {$(VPATH)}atomic.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-compile.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-compile.$(OBJEXT): {$(VPATH)}builtin.h
-compile.$(OBJEXT): {$(VPATH)}compile.c
-compile.$(OBJEXT): {$(VPATH)}config.h
-compile.$(OBJEXT): {$(VPATH)}constant.h
-compile.$(OBJEXT): {$(VPATH)}debug_counter.h
-compile.$(OBJEXT): {$(VPATH)}defines.h
-compile.$(OBJEXT): {$(VPATH)}encindex.h
-compile.$(OBJEXT): {$(VPATH)}encoding.h
-compile.$(OBJEXT): {$(VPATH)}id.h
-compile.$(OBJEXT): {$(VPATH)}id_table.h
-compile.$(OBJEXT): {$(VPATH)}insns.def
-compile.$(OBJEXT): {$(VPATH)}insns.inc
-compile.$(OBJEXT): {$(VPATH)}insns_info.inc
-compile.$(OBJEXT): {$(VPATH)}intern.h
-compile.$(OBJEXT): {$(VPATH)}internal.h
-compile.$(OBJEXT): {$(VPATH)}internal/abi.h
-compile.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-compile.$(OBJEXT): {$(VPATH)}internal/assume.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-compile.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-compile.$(OBJEXT): {$(VPATH)}internal/cast.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-compile.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-compile.$(OBJEXT): {$(VPATH)}internal/config.h
-compile.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-compile.$(OBJEXT): {$(VPATH)}internal/core.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-compile.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-compile.$(OBJEXT): {$(VPATH)}internal/ctype.h
-compile.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-compile.$(OBJEXT): {$(VPATH)}internal/dosish.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-compile.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-compile.$(OBJEXT): {$(VPATH)}internal/error.h
-compile.$(OBJEXT): {$(VPATH)}internal/eval.h
-compile.$(OBJEXT): {$(VPATH)}internal/event.h
-compile.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-compile.$(OBJEXT): {$(VPATH)}internal/gc.h
-compile.$(OBJEXT): {$(VPATH)}internal/glob.h
-compile.$(OBJEXT): {$(VPATH)}internal/globals.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-compile.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-compile.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-compile.$(OBJEXT): {$(VPATH)}internal/iterator.h
-compile.$(OBJEXT): {$(VPATH)}internal/memory.h
-compile.$(OBJEXT): {$(VPATH)}internal/method.h
-compile.$(OBJEXT): {$(VPATH)}internal/module.h
-compile.$(OBJEXT): {$(VPATH)}internal/newobj.h
-compile.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-compile.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-compile.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-compile.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-compile.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-compile.$(OBJEXT): {$(VPATH)}internal/symbol.h
-compile.$(OBJEXT): {$(VPATH)}internal/value.h
-compile.$(OBJEXT): {$(VPATH)}internal/value_type.h
-compile.$(OBJEXT): {$(VPATH)}internal/variable.h
-compile.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-compile.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-compile.$(OBJEXT): {$(VPATH)}iseq.h
-compile.$(OBJEXT): {$(VPATH)}method.h
-compile.$(OBJEXT): {$(VPATH)}missing.h
-compile.$(OBJEXT): {$(VPATH)}node.h
-compile.$(OBJEXT): {$(VPATH)}onigmo.h
-compile.$(OBJEXT): {$(VPATH)}oniguruma.h
-compile.$(OBJEXT): {$(VPATH)}optinsn.inc
-compile.$(OBJEXT): {$(VPATH)}re.h
-compile.$(OBJEXT): {$(VPATH)}regex.h
-compile.$(OBJEXT): {$(VPATH)}ruby_assert.h
-compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-compile.$(OBJEXT): {$(VPATH)}shape.h
-compile.$(OBJEXT): {$(VPATH)}st.h
-compile.$(OBJEXT): {$(VPATH)}subst.h
-compile.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-compile.$(OBJEXT): {$(VPATH)}thread_native.h
-compile.$(OBJEXT): {$(VPATH)}util.h
-compile.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-compile.$(OBJEXT): {$(VPATH)}vm_core.h
-compile.$(OBJEXT): {$(VPATH)}vm_debug.h
-compile.$(OBJEXT): {$(VPATH)}vm_opts.h
-complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-complex.$(OBJEXT): $(top_srcdir)/internal/array.h
-complex.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-complex.$(OBJEXT): $(top_srcdir)/internal/bits.h
-complex.$(OBJEXT): $(top_srcdir)/internal/class.h
-complex.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-complex.$(OBJEXT): $(top_srcdir)/internal/complex.h
-complex.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-complex.$(OBJEXT): $(top_srcdir)/internal/gc.h
-complex.$(OBJEXT): $(top_srcdir)/internal/math.h
-complex.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-complex.$(OBJEXT): $(top_srcdir)/internal/object.h
-complex.$(OBJEXT): $(top_srcdir)/internal/rational.h
-complex.$(OBJEXT): $(top_srcdir)/internal/serial.h
-complex.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-complex.$(OBJEXT): $(top_srcdir)/internal/variable.h
-complex.$(OBJEXT): $(top_srcdir)/internal/vm.h
-complex.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-complex.$(OBJEXT): {$(VPATH)}assert.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-complex.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-complex.$(OBJEXT): {$(VPATH)}complex.c
-complex.$(OBJEXT): {$(VPATH)}config.h
-complex.$(OBJEXT): {$(VPATH)}constant.h
-complex.$(OBJEXT): {$(VPATH)}defines.h
-complex.$(OBJEXT): {$(VPATH)}id.h
-complex.$(OBJEXT): {$(VPATH)}id_table.h
-complex.$(OBJEXT): {$(VPATH)}intern.h
-complex.$(OBJEXT): {$(VPATH)}internal.h
-complex.$(OBJEXT): {$(VPATH)}internal/abi.h
-complex.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-complex.$(OBJEXT): {$(VPATH)}internal/assume.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-complex.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-complex.$(OBJEXT): {$(VPATH)}internal/cast.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-complex.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-complex.$(OBJEXT): {$(VPATH)}internal/config.h
-complex.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-complex.$(OBJEXT): {$(VPATH)}internal/core.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-complex.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-complex.$(OBJEXT): {$(VPATH)}internal/ctype.h
-complex.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-complex.$(OBJEXT): {$(VPATH)}internal/dosish.h
-complex.$(OBJEXT): {$(VPATH)}internal/error.h
-complex.$(OBJEXT): {$(VPATH)}internal/eval.h
-complex.$(OBJEXT): {$(VPATH)}internal/event.h
-complex.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-complex.$(OBJEXT): {$(VPATH)}internal/gc.h
-complex.$(OBJEXT): {$(VPATH)}internal/glob.h
-complex.$(OBJEXT): {$(VPATH)}internal/globals.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-complex.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-complex.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-complex.$(OBJEXT): {$(VPATH)}internal/iterator.h
-complex.$(OBJEXT): {$(VPATH)}internal/memory.h
-complex.$(OBJEXT): {$(VPATH)}internal/method.h
-complex.$(OBJEXT): {$(VPATH)}internal/module.h
-complex.$(OBJEXT): {$(VPATH)}internal/newobj.h
-complex.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-complex.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-complex.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-complex.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-complex.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-complex.$(OBJEXT): {$(VPATH)}internal/symbol.h
-complex.$(OBJEXT): {$(VPATH)}internal/value.h
-complex.$(OBJEXT): {$(VPATH)}internal/value_type.h
-complex.$(OBJEXT): {$(VPATH)}internal/variable.h
-complex.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-complex.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-complex.$(OBJEXT): {$(VPATH)}missing.h
-complex.$(OBJEXT): {$(VPATH)}ruby_assert.h
-complex.$(OBJEXT): {$(VPATH)}shape.h
-complex.$(OBJEXT): {$(VPATH)}st.h
-complex.$(OBJEXT): {$(VPATH)}subst.h
-cont.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-cont.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-cont.$(OBJEXT): $(CCAN_DIR)/list/list.h
-cont.$(OBJEXT): $(CCAN_DIR)/str/str.h
-cont.$(OBJEXT): $(hdrdir)/ruby.h
-cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-cont.$(OBJEXT): $(top_srcdir)/internal/array.h
-cont.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-cont.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-cont.$(OBJEXT): $(top_srcdir)/internal/cont.h
-cont.$(OBJEXT): $(top_srcdir)/internal/error.h
-cont.$(OBJEXT): $(top_srcdir)/internal/gc.h
-cont.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-cont.$(OBJEXT): $(top_srcdir)/internal/proc.h
-cont.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-cont.$(OBJEXT): $(top_srcdir)/internal/serial.h
-cont.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-cont.$(OBJEXT): $(top_srcdir)/internal/string.h
-cont.$(OBJEXT): $(top_srcdir)/internal/variable.h
-cont.$(OBJEXT): $(top_srcdir)/internal/vm.h
-cont.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
-cont.$(OBJEXT): {$(VPATH)}assert.h
-cont.$(OBJEXT): {$(VPATH)}atomic.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-cont.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-cont.$(OBJEXT): {$(VPATH)}config.h
-cont.$(OBJEXT): {$(VPATH)}constant.h
-cont.$(OBJEXT): {$(VPATH)}cont.c
-cont.$(OBJEXT): {$(VPATH)}debug_counter.h
-cont.$(OBJEXT): {$(VPATH)}defines.h
-cont.$(OBJEXT): {$(VPATH)}encoding.h
-cont.$(OBJEXT): {$(VPATH)}eval_intern.h
-cont.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-cont.$(OBJEXT): {$(VPATH)}id.h
-cont.$(OBJEXT): {$(VPATH)}id_table.h
-cont.$(OBJEXT): {$(VPATH)}intern.h
-cont.$(OBJEXT): {$(VPATH)}internal.h
-cont.$(OBJEXT): {$(VPATH)}internal/abi.h
-cont.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-cont.$(OBJEXT): {$(VPATH)}internal/assume.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-cont.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-cont.$(OBJEXT): {$(VPATH)}internal/cast.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-cont.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-cont.$(OBJEXT): {$(VPATH)}internal/config.h
-cont.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-cont.$(OBJEXT): {$(VPATH)}internal/core.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-cont.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-cont.$(OBJEXT): {$(VPATH)}internal/ctype.h
-cont.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-cont.$(OBJEXT): {$(VPATH)}internal/dosish.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-cont.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-cont.$(OBJEXT): {$(VPATH)}internal/error.h
-cont.$(OBJEXT): {$(VPATH)}internal/eval.h
-cont.$(OBJEXT): {$(VPATH)}internal/event.h
-cont.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-cont.$(OBJEXT): {$(VPATH)}internal/gc.h
-cont.$(OBJEXT): {$(VPATH)}internal/glob.h
-cont.$(OBJEXT): {$(VPATH)}internal/globals.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-cont.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-cont.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-cont.$(OBJEXT): {$(VPATH)}internal/iterator.h
-cont.$(OBJEXT): {$(VPATH)}internal/memory.h
-cont.$(OBJEXT): {$(VPATH)}internal/method.h
-cont.$(OBJEXT): {$(VPATH)}internal/module.h
-cont.$(OBJEXT): {$(VPATH)}internal/newobj.h
-cont.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-cont.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-cont.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-cont.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-cont.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-cont.$(OBJEXT): {$(VPATH)}internal/symbol.h
-cont.$(OBJEXT): {$(VPATH)}internal/value.h
-cont.$(OBJEXT): {$(VPATH)}internal/value_type.h
-cont.$(OBJEXT): {$(VPATH)}internal/variable.h
-cont.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-cont.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-cont.$(OBJEXT): {$(VPATH)}iseq.h
-cont.$(OBJEXT): {$(VPATH)}method.h
-cont.$(OBJEXT): {$(VPATH)}missing.h
-cont.$(OBJEXT): {$(VPATH)}node.h
-cont.$(OBJEXT): {$(VPATH)}onigmo.h
-cont.$(OBJEXT): {$(VPATH)}oniguruma.h
-cont.$(OBJEXT): {$(VPATH)}ractor.h
-cont.$(OBJEXT): {$(VPATH)}ractor_core.h
-cont.$(OBJEXT): {$(VPATH)}rjit.h
-cont.$(OBJEXT): {$(VPATH)}ruby_assert.h
-cont.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-cont.$(OBJEXT): {$(VPATH)}shape.h
-cont.$(OBJEXT): {$(VPATH)}st.h
-cont.$(OBJEXT): {$(VPATH)}subst.h
-cont.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-cont.$(OBJEXT): {$(VPATH)}thread_native.h
-cont.$(OBJEXT): {$(VPATH)}vm_core.h
-cont.$(OBJEXT): {$(VPATH)}vm_debug.h
-cont.$(OBJEXT): {$(VPATH)}vm_opts.h
-cont.$(OBJEXT): {$(VPATH)}vm_sync.h
-cont.$(OBJEXT): {$(VPATH)}yjit.h
-debug.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-debug.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-debug.$(OBJEXT): $(CCAN_DIR)/list/list.h
-debug.$(OBJEXT): $(CCAN_DIR)/str/str.h
-debug.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-debug.$(OBJEXT): $(top_srcdir)/internal/array.h
-debug.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-debug.$(OBJEXT): $(top_srcdir)/internal/class.h
-debug.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-debug.$(OBJEXT): $(top_srcdir)/internal/gc.h
-debug.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-debug.$(OBJEXT): $(top_srcdir)/internal/serial.h
-debug.$(OBJEXT): $(top_srcdir)/internal/signal.h
-debug.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-debug.$(OBJEXT): $(top_srcdir)/internal/variable.h
-debug.$(OBJEXT): $(top_srcdir)/internal/vm.h
-debug.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-debug.$(OBJEXT): {$(VPATH)}assert.h
-debug.$(OBJEXT): {$(VPATH)}atomic.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-debug.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-debug.$(OBJEXT): {$(VPATH)}config.h
-debug.$(OBJEXT): {$(VPATH)}constant.h
-debug.$(OBJEXT): {$(VPATH)}debug.c
-debug.$(OBJEXT): {$(VPATH)}debug_counter.h
-debug.$(OBJEXT): {$(VPATH)}defines.h
-debug.$(OBJEXT): {$(VPATH)}encindex.h
-debug.$(OBJEXT): {$(VPATH)}encoding.h
-debug.$(OBJEXT): {$(VPATH)}eval_intern.h
-debug.$(OBJEXT): {$(VPATH)}id.h
-debug.$(OBJEXT): {$(VPATH)}id_table.h
-debug.$(OBJEXT): {$(VPATH)}intern.h
-debug.$(OBJEXT): {$(VPATH)}internal.h
-debug.$(OBJEXT): {$(VPATH)}internal/abi.h
-debug.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-debug.$(OBJEXT): {$(VPATH)}internal/assume.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-debug.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-debug.$(OBJEXT): {$(VPATH)}internal/cast.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-debug.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-debug.$(OBJEXT): {$(VPATH)}internal/config.h
-debug.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-debug.$(OBJEXT): {$(VPATH)}internal/core.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-debug.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-debug.$(OBJEXT): {$(VPATH)}internal/ctype.h
-debug.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-debug.$(OBJEXT): {$(VPATH)}internal/dosish.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-debug.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-debug.$(OBJEXT): {$(VPATH)}internal/error.h
-debug.$(OBJEXT): {$(VPATH)}internal/eval.h
-debug.$(OBJEXT): {$(VPATH)}internal/event.h
-debug.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-debug.$(OBJEXT): {$(VPATH)}internal/gc.h
-debug.$(OBJEXT): {$(VPATH)}internal/glob.h
-debug.$(OBJEXT): {$(VPATH)}internal/globals.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-debug.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-debug.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-debug.$(OBJEXT): {$(VPATH)}internal/iterator.h
-debug.$(OBJEXT): {$(VPATH)}internal/memory.h
-debug.$(OBJEXT): {$(VPATH)}internal/method.h
-debug.$(OBJEXT): {$(VPATH)}internal/module.h
-debug.$(OBJEXT): {$(VPATH)}internal/newobj.h
-debug.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-debug.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-debug.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-debug.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-debug.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-debug.$(OBJEXT): {$(VPATH)}internal/symbol.h
-debug.$(OBJEXT): {$(VPATH)}internal/value.h
-debug.$(OBJEXT): {$(VPATH)}internal/value_type.h
-debug.$(OBJEXT): {$(VPATH)}internal/variable.h
-debug.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-debug.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-debug.$(OBJEXT): {$(VPATH)}io.h
-debug.$(OBJEXT): {$(VPATH)}method.h
-debug.$(OBJEXT): {$(VPATH)}missing.h
-debug.$(OBJEXT): {$(VPATH)}node.h
-debug.$(OBJEXT): {$(VPATH)}onigmo.h
-debug.$(OBJEXT): {$(VPATH)}oniguruma.h
-debug.$(OBJEXT): {$(VPATH)}ractor.h
-debug.$(OBJEXT): {$(VPATH)}ractor_core.h
-debug.$(OBJEXT): {$(VPATH)}ruby_assert.h
-debug.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-debug.$(OBJEXT): {$(VPATH)}shape.h
-debug.$(OBJEXT): {$(VPATH)}st.h
-debug.$(OBJEXT): {$(VPATH)}subst.h
-debug.$(OBJEXT): {$(VPATH)}symbol.h
-debug.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-debug.$(OBJEXT): {$(VPATH)}thread_native.h
-debug.$(OBJEXT): {$(VPATH)}util.h
-debug.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-debug.$(OBJEXT): {$(VPATH)}vm_core.h
-debug.$(OBJEXT): {$(VPATH)}vm_debug.h
-debug.$(OBJEXT): {$(VPATH)}vm_opts.h
-debug_counter.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-debug_counter.$(OBJEXT): {$(VPATH)}assert.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-debug_counter.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-debug_counter.$(OBJEXT): {$(VPATH)}config.h
-debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.c
-debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.h
-debug_counter.$(OBJEXT): {$(VPATH)}defines.h
-debug_counter.$(OBJEXT): {$(VPATH)}intern.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/abi.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/assume.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/cast.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/config.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/ctype.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/dosish.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/error.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/eval.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/event.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/gc.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/glob.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/globals.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/iterator.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/memory.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/method.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/module.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/newobj.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/symbol.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/value.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/value_type.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/variable.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-debug_counter.$(OBJEXT): {$(VPATH)}missing.h
-debug_counter.$(OBJEXT): {$(VPATH)}st.h
-debug_counter.$(OBJEXT): {$(VPATH)}subst.h
-debug_counter.$(OBJEXT): {$(VPATH)}thread_native.h
-dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dir.$(OBJEXT): $(top_srcdir)/internal/array.h
-dir.$(OBJEXT): $(top_srcdir)/internal/class.h
-dir.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-dir.$(OBJEXT): $(top_srcdir)/internal/dir.h
-dir.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-dir.$(OBJEXT): $(top_srcdir)/internal/error.h
-dir.$(OBJEXT): $(top_srcdir)/internal/file.h
-dir.$(OBJEXT): $(top_srcdir)/internal/gc.h
-dir.$(OBJEXT): $(top_srcdir)/internal/io.h
-dir.$(OBJEXT): $(top_srcdir)/internal/object.h
-dir.$(OBJEXT): $(top_srcdir)/internal/serial.h
-dir.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-dir.$(OBJEXT): $(top_srcdir)/internal/string.h
-dir.$(OBJEXT): $(top_srcdir)/internal/variable.h
-dir.$(OBJEXT): $(top_srcdir)/internal/vm.h
-dir.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-dir.$(OBJEXT): {$(VPATH)}assert.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-dir.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-dir.$(OBJEXT): {$(VPATH)}builtin.h
-dir.$(OBJEXT): {$(VPATH)}config.h
-dir.$(OBJEXT): {$(VPATH)}constant.h
-dir.$(OBJEXT): {$(VPATH)}defines.h
-dir.$(OBJEXT): {$(VPATH)}dir.c
-dir.$(OBJEXT): {$(VPATH)}dir.rbinc
-dir.$(OBJEXT): {$(VPATH)}encindex.h
-dir.$(OBJEXT): {$(VPATH)}encoding.h
-dir.$(OBJEXT): {$(VPATH)}id.h
-dir.$(OBJEXT): {$(VPATH)}id_table.h
-dir.$(OBJEXT): {$(VPATH)}intern.h
-dir.$(OBJEXT): {$(VPATH)}internal.h
-dir.$(OBJEXT): {$(VPATH)}internal/abi.h
-dir.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-dir.$(OBJEXT): {$(VPATH)}internal/assume.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-dir.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-dir.$(OBJEXT): {$(VPATH)}internal/cast.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-dir.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-dir.$(OBJEXT): {$(VPATH)}internal/config.h
-dir.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-dir.$(OBJEXT): {$(VPATH)}internal/core.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-dir.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-dir.$(OBJEXT): {$(VPATH)}internal/ctype.h
-dir.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-dir.$(OBJEXT): {$(VPATH)}internal/dosish.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-dir.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-dir.$(OBJEXT): {$(VPATH)}internal/error.h
-dir.$(OBJEXT): {$(VPATH)}internal/eval.h
-dir.$(OBJEXT): {$(VPATH)}internal/event.h
-dir.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-dir.$(OBJEXT): {$(VPATH)}internal/gc.h
-dir.$(OBJEXT): {$(VPATH)}internal/glob.h
-dir.$(OBJEXT): {$(VPATH)}internal/globals.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-dir.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-dir.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-dir.$(OBJEXT): {$(VPATH)}internal/iterator.h
-dir.$(OBJEXT): {$(VPATH)}internal/memory.h
-dir.$(OBJEXT): {$(VPATH)}internal/method.h
-dir.$(OBJEXT): {$(VPATH)}internal/module.h
-dir.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dir.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-dir.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-dir.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-dir.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-dir.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-dir.$(OBJEXT): {$(VPATH)}internal/symbol.h
-dir.$(OBJEXT): {$(VPATH)}internal/value.h
-dir.$(OBJEXT): {$(VPATH)}internal/value_type.h
-dir.$(OBJEXT): {$(VPATH)}internal/variable.h
-dir.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-dir.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-dir.$(OBJEXT): {$(VPATH)}io.h
-dir.$(OBJEXT): {$(VPATH)}missing.h
-dir.$(OBJEXT): {$(VPATH)}onigmo.h
-dir.$(OBJEXT): {$(VPATH)}oniguruma.h
-dir.$(OBJEXT): {$(VPATH)}shape.h
-dir.$(OBJEXT): {$(VPATH)}st.h
-dir.$(OBJEXT): {$(VPATH)}subst.h
-dir.$(OBJEXT): {$(VPATH)}thread.h
-dir.$(OBJEXT): {$(VPATH)}util.h
-dln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dln.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-dln.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-dln.$(OBJEXT): {$(VPATH)}assert.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-dln.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-dln.$(OBJEXT): {$(VPATH)}config.h
-dln.$(OBJEXT): {$(VPATH)}defines.h
-dln.$(OBJEXT): {$(VPATH)}dln.c
-dln.$(OBJEXT): {$(VPATH)}dln.h
-dln.$(OBJEXT): {$(VPATH)}intern.h
-dln.$(OBJEXT): {$(VPATH)}internal.h
-dln.$(OBJEXT): {$(VPATH)}internal/abi.h
-dln.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-dln.$(OBJEXT): {$(VPATH)}internal/assume.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-dln.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-dln.$(OBJEXT): {$(VPATH)}internal/cast.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-dln.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-dln.$(OBJEXT): {$(VPATH)}internal/config.h
-dln.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-dln.$(OBJEXT): {$(VPATH)}internal/core.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-dln.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-dln.$(OBJEXT): {$(VPATH)}internal/ctype.h
-dln.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-dln.$(OBJEXT): {$(VPATH)}internal/dosish.h
-dln.$(OBJEXT): {$(VPATH)}internal/error.h
-dln.$(OBJEXT): {$(VPATH)}internal/eval.h
-dln.$(OBJEXT): {$(VPATH)}internal/event.h
-dln.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-dln.$(OBJEXT): {$(VPATH)}internal/gc.h
-dln.$(OBJEXT): {$(VPATH)}internal/glob.h
-dln.$(OBJEXT): {$(VPATH)}internal/globals.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-dln.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-dln.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-dln.$(OBJEXT): {$(VPATH)}internal/iterator.h
-dln.$(OBJEXT): {$(VPATH)}internal/memory.h
-dln.$(OBJEXT): {$(VPATH)}internal/method.h
-dln.$(OBJEXT): {$(VPATH)}internal/module.h
-dln.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-dln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-dln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-dln.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-dln.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-dln.$(OBJEXT): {$(VPATH)}internal/symbol.h
-dln.$(OBJEXT): {$(VPATH)}internal/value.h
-dln.$(OBJEXT): {$(VPATH)}internal/value_type.h
-dln.$(OBJEXT): {$(VPATH)}internal/variable.h
-dln.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-dln.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-dln.$(OBJEXT): {$(VPATH)}missing.h
-dln.$(OBJEXT): {$(VPATH)}st.h
-dln.$(OBJEXT): {$(VPATH)}subst.h
-dln_find.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dln_find.$(OBJEXT): {$(VPATH)}assert.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-dln_find.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-dln_find.$(OBJEXT): {$(VPATH)}config.h
-dln_find.$(OBJEXT): {$(VPATH)}defines.h
-dln_find.$(OBJEXT): {$(VPATH)}dln.h
-dln_find.$(OBJEXT): {$(VPATH)}dln_find.c
-dln_find.$(OBJEXT): {$(VPATH)}intern.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/abi.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/assume.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/cast.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/config.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/ctype.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/dosish.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/error.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/eval.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/event.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/gc.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/glob.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/globals.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/iterator.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/memory.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/method.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/module.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/symbol.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/value.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/value_type.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/variable.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-dln_find.$(OBJEXT): {$(VPATH)}missing.h
-dln_find.$(OBJEXT): {$(VPATH)}st.h
-dln_find.$(OBJEXT): {$(VPATH)}subst.h
-dmydln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-dmydln.$(OBJEXT): {$(VPATH)}assert.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-dmydln.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-dmydln.$(OBJEXT): {$(VPATH)}config.h
-dmydln.$(OBJEXT): {$(VPATH)}defines.h
-dmydln.$(OBJEXT): {$(VPATH)}dmydln.c
-dmydln.$(OBJEXT): {$(VPATH)}intern.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/abi.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/assume.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/cast.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/config.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/ctype.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/dosish.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/error.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/eval.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/event.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/gc.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/glob.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/globals.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/iterator.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/memory.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/method.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/module.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/symbol.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/value.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/value_type.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/variable.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-dmydln.$(OBJEXT): {$(VPATH)}missing.h
-dmydln.$(OBJEXT): {$(VPATH)}st.h
-dmydln.$(OBJEXT): {$(VPATH)}subst.h
-dmyenc.$(OBJEXT): {$(VPATH)}dmyenc.c
-dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
-enc/ascii.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/ascii.$(OBJEXT): {$(VPATH)}assert.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enc/ascii.$(OBJEXT): {$(VPATH)}config.h
-enc/ascii.$(OBJEXT): {$(VPATH)}defines.h
-enc/ascii.$(OBJEXT): {$(VPATH)}enc/ascii.c
-enc/ascii.$(OBJEXT): {$(VPATH)}encindex.h
-enc/ascii.$(OBJEXT): {$(VPATH)}encoding.h
-enc/ascii.$(OBJEXT): {$(VPATH)}intern.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/assume.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/cast.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/config.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/error.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/eval.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/event.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/gc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/glob.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/globals.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/method.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/module.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/value.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/variable.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}missing.h
-enc/ascii.$(OBJEXT): {$(VPATH)}onigmo.h
-enc/ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
-enc/ascii.$(OBJEXT): {$(VPATH)}regenc.h
-enc/ascii.$(OBJEXT): {$(VPATH)}st.h
-enc/ascii.$(OBJEXT): {$(VPATH)}subst.h
-enc/trans/newline.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}assert.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}config.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}defines.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}enc/trans/newline.c
-enc/trans/newline.$(OBJEXT): {$(VPATH)}intern.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/assume.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/cast.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/config.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/error.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/eval.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/event.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/gc.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/glob.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/globals.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/memory.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/method.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/module.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/value.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/variable.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}missing.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}st.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}subst.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}transcode_data.h
-enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/casefold.h
-enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/name2ctype.h
-enc/unicode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/unicode.$(OBJEXT): {$(VPATH)}assert.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enc/unicode.$(OBJEXT): {$(VPATH)}config.h
-enc/unicode.$(OBJEXT): {$(VPATH)}defines.h
-enc/unicode.$(OBJEXT): {$(VPATH)}enc/unicode.c
-enc/unicode.$(OBJEXT): {$(VPATH)}intern.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/assume.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/cast.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/config.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/error.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/eval.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/event.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/gc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/glob.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/globals.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/memory.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/method.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/module.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/value.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/variable.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}missing.h
-enc/unicode.$(OBJEXT): {$(VPATH)}onigmo.h
-enc/unicode.$(OBJEXT): {$(VPATH)}regenc.h
-enc/unicode.$(OBJEXT): {$(VPATH)}regint.h
-enc/unicode.$(OBJEXT): {$(VPATH)}st.h
-enc/unicode.$(OBJEXT): {$(VPATH)}subst.h
-enc/us_ascii.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}assert.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}config.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}defines.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}enc/us_ascii.c
-enc/us_ascii.$(OBJEXT): {$(VPATH)}encindex.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}encoding.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}intern.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/assume.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/cast.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/config.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/error.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/eval.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/event.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/gc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/glob.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/globals.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/method.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/module.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/value.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/variable.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}missing.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}onigmo.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}regenc.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}st.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}subst.h
-enc/utf_8.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}assert.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}config.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}defines.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}enc/utf_8.c
-enc/utf_8.$(OBJEXT): {$(VPATH)}encindex.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}encoding.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}intern.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/assume.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/cast.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/config.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/error.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/eval.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/event.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/gc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/glob.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/globals.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/memory.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/method.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/module.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/value.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/variable.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}missing.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}onigmo.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}st.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}subst.h
-encoding.$(OBJEXT): $(hdrdir)/ruby.h
-encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/class.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/enc.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/error.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/gc.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/inits.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/load.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/object.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/serial.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/string.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/variable.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/vm.h
-encoding.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-encoding.$(OBJEXT): {$(VPATH)}assert.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-encoding.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-encoding.$(OBJEXT): {$(VPATH)}config.h
-encoding.$(OBJEXT): {$(VPATH)}constant.h
-encoding.$(OBJEXT): {$(VPATH)}debug_counter.h
-encoding.$(OBJEXT): {$(VPATH)}defines.h
-encoding.$(OBJEXT): {$(VPATH)}encindex.h
-encoding.$(OBJEXT): {$(VPATH)}encoding.c
-encoding.$(OBJEXT): {$(VPATH)}encoding.h
-encoding.$(OBJEXT): {$(VPATH)}id_table.h
-encoding.$(OBJEXT): {$(VPATH)}intern.h
-encoding.$(OBJEXT): {$(VPATH)}internal.h
-encoding.$(OBJEXT): {$(VPATH)}internal/abi.h
-encoding.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-encoding.$(OBJEXT): {$(VPATH)}internal/assume.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-encoding.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-encoding.$(OBJEXT): {$(VPATH)}internal/cast.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-encoding.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-encoding.$(OBJEXT): {$(VPATH)}internal/config.h
-encoding.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-encoding.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-encoding.$(OBJEXT): {$(VPATH)}internal/ctype.h
-encoding.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-encoding.$(OBJEXT): {$(VPATH)}internal/dosish.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-encoding.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-encoding.$(OBJEXT): {$(VPATH)}internal/error.h
-encoding.$(OBJEXT): {$(VPATH)}internal/eval.h
-encoding.$(OBJEXT): {$(VPATH)}internal/event.h
-encoding.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-encoding.$(OBJEXT): {$(VPATH)}internal/gc.h
-encoding.$(OBJEXT): {$(VPATH)}internal/glob.h
-encoding.$(OBJEXT): {$(VPATH)}internal/globals.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-encoding.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-encoding.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-encoding.$(OBJEXT): {$(VPATH)}internal/iterator.h
-encoding.$(OBJEXT): {$(VPATH)}internal/memory.h
-encoding.$(OBJEXT): {$(VPATH)}internal/method.h
-encoding.$(OBJEXT): {$(VPATH)}internal/module.h
-encoding.$(OBJEXT): {$(VPATH)}internal/newobj.h
-encoding.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-encoding.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-encoding.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-encoding.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-encoding.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-encoding.$(OBJEXT): {$(VPATH)}internal/symbol.h
-encoding.$(OBJEXT): {$(VPATH)}internal/value.h
-encoding.$(OBJEXT): {$(VPATH)}internal/value_type.h
-encoding.$(OBJEXT): {$(VPATH)}internal/variable.h
-encoding.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-encoding.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-encoding.$(OBJEXT): {$(VPATH)}missing.h
-encoding.$(OBJEXT): {$(VPATH)}onigmo.h
-encoding.$(OBJEXT): {$(VPATH)}oniguruma.h
-encoding.$(OBJEXT): {$(VPATH)}regenc.h
-encoding.$(OBJEXT): {$(VPATH)}ruby_assert.h
-encoding.$(OBJEXT): {$(VPATH)}shape.h
-encoding.$(OBJEXT): {$(VPATH)}st.h
-encoding.$(OBJEXT): {$(VPATH)}subst.h
-encoding.$(OBJEXT): {$(VPATH)}util.h
-encoding.$(OBJEXT): {$(VPATH)}vm_debug.h
-encoding.$(OBJEXT): {$(VPATH)}vm_sync.h
-enum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enum.$(OBJEXT): $(top_srcdir)/internal/array.h
-enum.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-enum.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-enum.$(OBJEXT): $(top_srcdir)/internal/bits.h
-enum.$(OBJEXT): $(top_srcdir)/internal/class.h
-enum.$(OBJEXT): $(top_srcdir)/internal/compar.h
-enum.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-enum.$(OBJEXT): $(top_srcdir)/internal/enum.h
-enum.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-enum.$(OBJEXT): $(top_srcdir)/internal/gc.h
-enum.$(OBJEXT): $(top_srcdir)/internal/hash.h
-enum.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-enum.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-enum.$(OBJEXT): $(top_srcdir)/internal/object.h
-enum.$(OBJEXT): $(top_srcdir)/internal/proc.h
-enum.$(OBJEXT): $(top_srcdir)/internal/rational.h
-enum.$(OBJEXT): $(top_srcdir)/internal/re.h
-enum.$(OBJEXT): $(top_srcdir)/internal/serial.h
-enum.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-enum.$(OBJEXT): $(top_srcdir)/internal/variable.h
-enum.$(OBJEXT): $(top_srcdir)/internal/vm.h
-enum.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-enum.$(OBJEXT): {$(VPATH)}assert.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enum.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enum.$(OBJEXT): {$(VPATH)}config.h
-enum.$(OBJEXT): {$(VPATH)}constant.h
-enum.$(OBJEXT): {$(VPATH)}defines.h
-enum.$(OBJEXT): {$(VPATH)}encoding.h
-enum.$(OBJEXT): {$(VPATH)}enum.c
-enum.$(OBJEXT): {$(VPATH)}id.h
-enum.$(OBJEXT): {$(VPATH)}id_table.h
-enum.$(OBJEXT): {$(VPATH)}intern.h
-enum.$(OBJEXT): {$(VPATH)}internal.h
-enum.$(OBJEXT): {$(VPATH)}internal/abi.h
-enum.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enum.$(OBJEXT): {$(VPATH)}internal/assume.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enum.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enum.$(OBJEXT): {$(VPATH)}internal/cast.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enum.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enum.$(OBJEXT): {$(VPATH)}internal/config.h
-enum.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enum.$(OBJEXT): {$(VPATH)}internal/core.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enum.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enum.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enum.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enum.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-enum.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-enum.$(OBJEXT): {$(VPATH)}internal/error.h
-enum.$(OBJEXT): {$(VPATH)}internal/eval.h
-enum.$(OBJEXT): {$(VPATH)}internal/event.h
-enum.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enum.$(OBJEXT): {$(VPATH)}internal/gc.h
-enum.$(OBJEXT): {$(VPATH)}internal/glob.h
-enum.$(OBJEXT): {$(VPATH)}internal/globals.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enum.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enum.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enum.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enum.$(OBJEXT): {$(VPATH)}internal/memory.h
-enum.$(OBJEXT): {$(VPATH)}internal/method.h
-enum.$(OBJEXT): {$(VPATH)}internal/module.h
-enum.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enum.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enum.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enum.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enum.$(OBJEXT): {$(VPATH)}internal/value.h
-enum.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enum.$(OBJEXT): {$(VPATH)}internal/variable.h
-enum.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enum.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enum.$(OBJEXT): {$(VPATH)}missing.h
-enum.$(OBJEXT): {$(VPATH)}onigmo.h
-enum.$(OBJEXT): {$(VPATH)}oniguruma.h
-enum.$(OBJEXT): {$(VPATH)}ruby_assert.h
-enum.$(OBJEXT): {$(VPATH)}shape.h
-enum.$(OBJEXT): {$(VPATH)}st.h
-enum.$(OBJEXT): {$(VPATH)}subst.h
-enum.$(OBJEXT): {$(VPATH)}symbol.h
-enum.$(OBJEXT): {$(VPATH)}util.h
-enumerator.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/array.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/bits.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/class.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/error.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/gc.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/hash.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/range.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/rational.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/serial.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/string.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/struct.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/variable.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/vm.h
-enumerator.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-enumerator.$(OBJEXT): {$(VPATH)}assert.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-enumerator.$(OBJEXT): {$(VPATH)}config.h
-enumerator.$(OBJEXT): {$(VPATH)}constant.h
-enumerator.$(OBJEXT): {$(VPATH)}defines.h
-enumerator.$(OBJEXT): {$(VPATH)}encoding.h
-enumerator.$(OBJEXT): {$(VPATH)}enumerator.c
-enumerator.$(OBJEXT): {$(VPATH)}id.h
-enumerator.$(OBJEXT): {$(VPATH)}id_table.h
-enumerator.$(OBJEXT): {$(VPATH)}intern.h
-enumerator.$(OBJEXT): {$(VPATH)}internal.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/abi.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/assume.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/cast.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/config.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/ctype.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/dosish.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/error.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/eval.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/event.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/gc.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/glob.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/globals.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/iterator.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/memory.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/method.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/module.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/symbol.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/value.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/value_type.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/variable.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-enumerator.$(OBJEXT): {$(VPATH)}missing.h
-enumerator.$(OBJEXT): {$(VPATH)}onigmo.h
-enumerator.$(OBJEXT): {$(VPATH)}oniguruma.h
-enumerator.$(OBJEXT): {$(VPATH)}ruby_assert.h
-enumerator.$(OBJEXT): {$(VPATH)}shape.h
-enumerator.$(OBJEXT): {$(VPATH)}st.h
-enumerator.$(OBJEXT): {$(VPATH)}subst.h
-error.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-error.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-error.$(OBJEXT): $(CCAN_DIR)/list/list.h
-error.$(OBJEXT): $(CCAN_DIR)/str/str.h
-error.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-error.$(OBJEXT): $(top_srcdir)/internal/array.h
-error.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-error.$(OBJEXT): $(top_srcdir)/internal/class.h
-error.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-error.$(OBJEXT): $(top_srcdir)/internal/error.h
-error.$(OBJEXT): $(top_srcdir)/internal/eval.h
-error.$(OBJEXT): $(top_srcdir)/internal/gc.h
-error.$(OBJEXT): $(top_srcdir)/internal/hash.h
-error.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-error.$(OBJEXT): $(top_srcdir)/internal/io.h
-error.$(OBJEXT): $(top_srcdir)/internal/load.h
-error.$(OBJEXT): $(top_srcdir)/internal/object.h
-error.$(OBJEXT): $(top_srcdir)/internal/serial.h
-error.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-error.$(OBJEXT): $(top_srcdir)/internal/string.h
-error.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-error.$(OBJEXT): $(top_srcdir)/internal/thread.h
-error.$(OBJEXT): $(top_srcdir)/internal/variable.h
-error.$(OBJEXT): $(top_srcdir)/internal/vm.h
-error.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-error.$(OBJEXT): {$(VPATH)}assert.h
-error.$(OBJEXT): {$(VPATH)}atomic.h
-error.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-error.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-error.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-error.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-error.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-error.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-error.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-error.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-error.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-error.$(OBJEXT): {$(VPATH)}builtin.h
-error.$(OBJEXT): {$(VPATH)}config.h
-error.$(OBJEXT): {$(VPATH)}constant.h
-error.$(OBJEXT): {$(VPATH)}defines.h
-error.$(OBJEXT): {$(VPATH)}encoding.h
-error.$(OBJEXT): {$(VPATH)}error.c
-error.$(OBJEXT): {$(VPATH)}id.h
-error.$(OBJEXT): {$(VPATH)}id_table.h
-error.$(OBJEXT): {$(VPATH)}intern.h
-error.$(OBJEXT): {$(VPATH)}internal.h
-error.$(OBJEXT): {$(VPATH)}internal/abi.h
-error.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-error.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-error.$(OBJEXT): {$(VPATH)}internal/assume.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-error.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-error.$(OBJEXT): {$(VPATH)}internal/cast.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-error.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-error.$(OBJEXT): {$(VPATH)}internal/config.h
-error.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-error.$(OBJEXT): {$(VPATH)}internal/core.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-error.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-error.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-error.$(OBJEXT): {$(VPATH)}internal/ctype.h
-error.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-error.$(OBJEXT): {$(VPATH)}internal/dosish.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-error.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-error.$(OBJEXT): {$(VPATH)}internal/error.h
-error.$(OBJEXT): {$(VPATH)}internal/eval.h
-error.$(OBJEXT): {$(VPATH)}internal/event.h
-error.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-error.$(OBJEXT): {$(VPATH)}internal/gc.h
-error.$(OBJEXT): {$(VPATH)}internal/glob.h
-error.$(OBJEXT): {$(VPATH)}internal/globals.h
-error.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-error.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-error.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-error.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-error.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-error.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-error.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-error.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-error.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-error.$(OBJEXT): {$(VPATH)}internal/iterator.h
-error.$(OBJEXT): {$(VPATH)}internal/memory.h
-error.$(OBJEXT): {$(VPATH)}internal/method.h
-error.$(OBJEXT): {$(VPATH)}internal/module.h
-error.$(OBJEXT): {$(VPATH)}internal/newobj.h
-error.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-error.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-error.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-error.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-error.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-error.$(OBJEXT): {$(VPATH)}internal/symbol.h
-error.$(OBJEXT): {$(VPATH)}internal/value.h
-error.$(OBJEXT): {$(VPATH)}internal/value_type.h
-error.$(OBJEXT): {$(VPATH)}internal/variable.h
-error.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-error.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-error.$(OBJEXT): {$(VPATH)}io.h
-error.$(OBJEXT): {$(VPATH)}known_errors.inc
-error.$(OBJEXT): {$(VPATH)}method.h
-error.$(OBJEXT): {$(VPATH)}missing.h
-error.$(OBJEXT): {$(VPATH)}node.h
-error.$(OBJEXT): {$(VPATH)}onigmo.h
-error.$(OBJEXT): {$(VPATH)}oniguruma.h
-error.$(OBJEXT): {$(VPATH)}ruby_assert.h
-error.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-error.$(OBJEXT): {$(VPATH)}shape.h
-error.$(OBJEXT): {$(VPATH)}st.h
-error.$(OBJEXT): {$(VPATH)}subst.h
-error.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-error.$(OBJEXT): {$(VPATH)}thread_native.h
-error.$(OBJEXT): {$(VPATH)}vm_core.h
-error.$(OBJEXT): {$(VPATH)}vm_opts.h
-error.$(OBJEXT): {$(VPATH)}warning.rbinc
-eval.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-eval.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-eval.$(OBJEXT): $(CCAN_DIR)/list/list.h
-eval.$(OBJEXT): $(CCAN_DIR)/str/str.h
-eval.$(OBJEXT): $(hdrdir)/ruby.h
-eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-eval.$(OBJEXT): $(top_srcdir)/internal/array.h
-eval.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-eval.$(OBJEXT): $(top_srcdir)/internal/class.h
-eval.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-eval.$(OBJEXT): $(top_srcdir)/internal/cont.h
-eval.$(OBJEXT): $(top_srcdir)/internal/error.h
-eval.$(OBJEXT): $(top_srcdir)/internal/eval.h
-eval.$(OBJEXT): $(top_srcdir)/internal/gc.h
-eval.$(OBJEXT): $(top_srcdir)/internal/hash.h
-eval.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-eval.$(OBJEXT): $(top_srcdir)/internal/inits.h
-eval.$(OBJEXT): $(top_srcdir)/internal/io.h
-eval.$(OBJEXT): $(top_srcdir)/internal/object.h
-eval.$(OBJEXT): $(top_srcdir)/internal/serial.h
-eval.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-eval.$(OBJEXT): $(top_srcdir)/internal/string.h
-eval.$(OBJEXT): $(top_srcdir)/internal/thread.h
-eval.$(OBJEXT): $(top_srcdir)/internal/variable.h
-eval.$(OBJEXT): $(top_srcdir)/internal/vm.h
-eval.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-eval.$(OBJEXT): {$(VPATH)}assert.h
-eval.$(OBJEXT): {$(VPATH)}atomic.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-eval.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-eval.$(OBJEXT): {$(VPATH)}config.h
-eval.$(OBJEXT): {$(VPATH)}constant.h
-eval.$(OBJEXT): {$(VPATH)}debug_counter.h
-eval.$(OBJEXT): {$(VPATH)}defines.h
-eval.$(OBJEXT): {$(VPATH)}encoding.h
-eval.$(OBJEXT): {$(VPATH)}eval.c
-eval.$(OBJEXT): {$(VPATH)}eval_error.c
-eval.$(OBJEXT): {$(VPATH)}eval_intern.h
-eval.$(OBJEXT): {$(VPATH)}eval_jump.c
-eval.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-eval.$(OBJEXT): {$(VPATH)}id.h
-eval.$(OBJEXT): {$(VPATH)}id_table.h
-eval.$(OBJEXT): {$(VPATH)}intern.h
-eval.$(OBJEXT): {$(VPATH)}internal.h
-eval.$(OBJEXT): {$(VPATH)}internal/abi.h
-eval.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-eval.$(OBJEXT): {$(VPATH)}internal/assume.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-eval.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-eval.$(OBJEXT): {$(VPATH)}internal/cast.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-eval.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-eval.$(OBJEXT): {$(VPATH)}internal/config.h
-eval.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-eval.$(OBJEXT): {$(VPATH)}internal/core.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-eval.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-eval.$(OBJEXT): {$(VPATH)}internal/ctype.h
-eval.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-eval.$(OBJEXT): {$(VPATH)}internal/dosish.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-eval.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-eval.$(OBJEXT): {$(VPATH)}internal/error.h
-eval.$(OBJEXT): {$(VPATH)}internal/eval.h
-eval.$(OBJEXT): {$(VPATH)}internal/event.h
-eval.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-eval.$(OBJEXT): {$(VPATH)}internal/gc.h
-eval.$(OBJEXT): {$(VPATH)}internal/glob.h
-eval.$(OBJEXT): {$(VPATH)}internal/globals.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-eval.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-eval.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-eval.$(OBJEXT): {$(VPATH)}internal/iterator.h
-eval.$(OBJEXT): {$(VPATH)}internal/memory.h
-eval.$(OBJEXT): {$(VPATH)}internal/method.h
-eval.$(OBJEXT): {$(VPATH)}internal/module.h
-eval.$(OBJEXT): {$(VPATH)}internal/newobj.h
-eval.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-eval.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-eval.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-eval.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-eval.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-eval.$(OBJEXT): {$(VPATH)}internal/symbol.h
-eval.$(OBJEXT): {$(VPATH)}internal/value.h
-eval.$(OBJEXT): {$(VPATH)}internal/value_type.h
-eval.$(OBJEXT): {$(VPATH)}internal/variable.h
-eval.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-eval.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-eval.$(OBJEXT): {$(VPATH)}io.h
-eval.$(OBJEXT): {$(VPATH)}iseq.h
-eval.$(OBJEXT): {$(VPATH)}method.h
-eval.$(OBJEXT): {$(VPATH)}missing.h
-eval.$(OBJEXT): {$(VPATH)}node.h
-eval.$(OBJEXT): {$(VPATH)}onigmo.h
-eval.$(OBJEXT): {$(VPATH)}oniguruma.h
-eval.$(OBJEXT): {$(VPATH)}probes.dmyh
-eval.$(OBJEXT): {$(VPATH)}probes.h
-eval.$(OBJEXT): {$(VPATH)}probes_helper.h
-eval.$(OBJEXT): {$(VPATH)}ractor.h
-eval.$(OBJEXT): {$(VPATH)}ractor_core.h
-eval.$(OBJEXT): {$(VPATH)}rjit.h
-eval.$(OBJEXT): {$(VPATH)}ruby_assert.h
-eval.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-eval.$(OBJEXT): {$(VPATH)}shape.h
-eval.$(OBJEXT): {$(VPATH)}st.h
-eval.$(OBJEXT): {$(VPATH)}subst.h
-eval.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-eval.$(OBJEXT): {$(VPATH)}thread_native.h
-eval.$(OBJEXT): {$(VPATH)}vm.h
-eval.$(OBJEXT): {$(VPATH)}vm_core.h
-eval.$(OBJEXT): {$(VPATH)}vm_debug.h
-eval.$(OBJEXT): {$(VPATH)}vm_opts.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}config.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/config.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h
-file.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-file.$(OBJEXT): $(top_srcdir)/internal/array.h
-file.$(OBJEXT): $(top_srcdir)/internal/class.h
-file.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-file.$(OBJEXT): $(top_srcdir)/internal/dir.h
-file.$(OBJEXT): $(top_srcdir)/internal/error.h
-file.$(OBJEXT): $(top_srcdir)/internal/file.h
-file.$(OBJEXT): $(top_srcdir)/internal/gc.h
-file.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-file.$(OBJEXT): $(top_srcdir)/internal/io.h
-file.$(OBJEXT): $(top_srcdir)/internal/load.h
-file.$(OBJEXT): $(top_srcdir)/internal/object.h
-file.$(OBJEXT): $(top_srcdir)/internal/process.h
-file.$(OBJEXT): $(top_srcdir)/internal/serial.h
-file.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-file.$(OBJEXT): $(top_srcdir)/internal/string.h
-file.$(OBJEXT): $(top_srcdir)/internal/thread.h
-file.$(OBJEXT): $(top_srcdir)/internal/variable.h
-file.$(OBJEXT): $(top_srcdir)/internal/vm.h
-file.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-file.$(OBJEXT): {$(VPATH)}assert.h
-file.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-file.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-file.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-file.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-file.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-file.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-file.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-file.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-file.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-file.$(OBJEXT): {$(VPATH)}config.h
-file.$(OBJEXT): {$(VPATH)}constant.h
-file.$(OBJEXT): {$(VPATH)}defines.h
-file.$(OBJEXT): {$(VPATH)}dln.h
-file.$(OBJEXT): {$(VPATH)}encindex.h
-file.$(OBJEXT): {$(VPATH)}encoding.h
-file.$(OBJEXT): {$(VPATH)}file.c
-file.$(OBJEXT): {$(VPATH)}id.h
-file.$(OBJEXT): {$(VPATH)}id_table.h
-file.$(OBJEXT): {$(VPATH)}intern.h
-file.$(OBJEXT): {$(VPATH)}internal.h
-file.$(OBJEXT): {$(VPATH)}internal/abi.h
-file.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-file.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-file.$(OBJEXT): {$(VPATH)}internal/assume.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-file.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-file.$(OBJEXT): {$(VPATH)}internal/cast.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-file.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-file.$(OBJEXT): {$(VPATH)}internal/config.h
-file.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-file.$(OBJEXT): {$(VPATH)}internal/core.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-file.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-file.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-file.$(OBJEXT): {$(VPATH)}internal/ctype.h
-file.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-file.$(OBJEXT): {$(VPATH)}internal/dosish.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-file.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-file.$(OBJEXT): {$(VPATH)}internal/error.h
-file.$(OBJEXT): {$(VPATH)}internal/eval.h
-file.$(OBJEXT): {$(VPATH)}internal/event.h
-file.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-file.$(OBJEXT): {$(VPATH)}internal/gc.h
-file.$(OBJEXT): {$(VPATH)}internal/glob.h
-file.$(OBJEXT): {$(VPATH)}internal/globals.h
-file.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-file.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-file.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-file.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-file.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-file.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-file.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-file.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-file.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-file.$(OBJEXT): {$(VPATH)}internal/iterator.h
-file.$(OBJEXT): {$(VPATH)}internal/memory.h
-file.$(OBJEXT): {$(VPATH)}internal/method.h
-file.$(OBJEXT): {$(VPATH)}internal/module.h
-file.$(OBJEXT): {$(VPATH)}internal/newobj.h
-file.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-file.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-file.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-file.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-file.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-file.$(OBJEXT): {$(VPATH)}internal/symbol.h
-file.$(OBJEXT): {$(VPATH)}internal/value.h
-file.$(OBJEXT): {$(VPATH)}internal/value_type.h
-file.$(OBJEXT): {$(VPATH)}internal/variable.h
-file.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-file.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-file.$(OBJEXT): {$(VPATH)}io.h
-file.$(OBJEXT): {$(VPATH)}missing.h
-file.$(OBJEXT): {$(VPATH)}onigmo.h
-file.$(OBJEXT): {$(VPATH)}oniguruma.h
-file.$(OBJEXT): {$(VPATH)}shape.h
-file.$(OBJEXT): {$(VPATH)}st.h
-file.$(OBJEXT): {$(VPATH)}subst.h
-file.$(OBJEXT): {$(VPATH)}thread.h
-file.$(OBJEXT): {$(VPATH)}util.h
-gc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-gc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-gc.$(OBJEXT): $(CCAN_DIR)/list/list.h
-gc.$(OBJEXT): $(CCAN_DIR)/str/str.h
-gc.$(OBJEXT): $(hdrdir)/ruby.h
-gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-gc.$(OBJEXT): $(top_srcdir)/internal/array.h
-gc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-gc.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-gc.$(OBJEXT): $(top_srcdir)/internal/bits.h
-gc.$(OBJEXT): $(top_srcdir)/internal/class.h
-gc.$(OBJEXT): $(top_srcdir)/internal/compile.h
-gc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-gc.$(OBJEXT): $(top_srcdir)/internal/complex.h
-gc.$(OBJEXT): $(top_srcdir)/internal/cont.h
-gc.$(OBJEXT): $(top_srcdir)/internal/error.h
-gc.$(OBJEXT): $(top_srcdir)/internal/eval.h
-gc.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-gc.$(OBJEXT): $(top_srcdir)/internal/gc.h
-gc.$(OBJEXT): $(top_srcdir)/internal/hash.h
-gc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-gc.$(OBJEXT): $(top_srcdir)/internal/io.h
-gc.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-gc.$(OBJEXT): $(top_srcdir)/internal/object.h
-gc.$(OBJEXT): $(top_srcdir)/internal/proc.h
-gc.$(OBJEXT): $(top_srcdir)/internal/rational.h
-gc.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-gc.$(OBJEXT): $(top_srcdir)/internal/serial.h
-gc.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-gc.$(OBJEXT): $(top_srcdir)/internal/string.h
-gc.$(OBJEXT): $(top_srcdir)/internal/struct.h
-gc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-gc.$(OBJEXT): $(top_srcdir)/internal/thread.h
-gc.$(OBJEXT): $(top_srcdir)/internal/variable.h
-gc.$(OBJEXT): $(top_srcdir)/internal/vm.h
-gc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-gc.$(OBJEXT): {$(VPATH)}assert.h
-gc.$(OBJEXT): {$(VPATH)}atomic.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-gc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-gc.$(OBJEXT): {$(VPATH)}builtin.h
-gc.$(OBJEXT): {$(VPATH)}config.h
-gc.$(OBJEXT): {$(VPATH)}constant.h
-gc.$(OBJEXT): {$(VPATH)}debug.h
-gc.$(OBJEXT): {$(VPATH)}debug_counter.h
-gc.$(OBJEXT): {$(VPATH)}defines.h
-gc.$(OBJEXT): {$(VPATH)}encoding.h
-gc.$(OBJEXT): {$(VPATH)}eval_intern.h
-gc.$(OBJEXT): {$(VPATH)}gc.c
-gc.$(OBJEXT): {$(VPATH)}gc.rbinc
-gc.$(OBJEXT): {$(VPATH)}id.h
-gc.$(OBJEXT): {$(VPATH)}id_table.h
-gc.$(OBJEXT): {$(VPATH)}intern.h
-gc.$(OBJEXT): {$(VPATH)}internal.h
-gc.$(OBJEXT): {$(VPATH)}internal/abi.h
-gc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-gc.$(OBJEXT): {$(VPATH)}internal/assume.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-gc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-gc.$(OBJEXT): {$(VPATH)}internal/cast.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-gc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-gc.$(OBJEXT): {$(VPATH)}internal/config.h
-gc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-gc.$(OBJEXT): {$(VPATH)}internal/core.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-gc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-gc.$(OBJEXT): {$(VPATH)}internal/ctype.h
-gc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-gc.$(OBJEXT): {$(VPATH)}internal/dosish.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-gc.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-gc.$(OBJEXT): {$(VPATH)}internal/error.h
-gc.$(OBJEXT): {$(VPATH)}internal/eval.h
-gc.$(OBJEXT): {$(VPATH)}internal/event.h
-gc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-gc.$(OBJEXT): {$(VPATH)}internal/gc.h
-gc.$(OBJEXT): {$(VPATH)}internal/glob.h
-gc.$(OBJEXT): {$(VPATH)}internal/globals.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-gc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-gc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-gc.$(OBJEXT): {$(VPATH)}internal/iterator.h
-gc.$(OBJEXT): {$(VPATH)}internal/memory.h
-gc.$(OBJEXT): {$(VPATH)}internal/method.h
-gc.$(OBJEXT): {$(VPATH)}internal/module.h
-gc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-gc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-gc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-gc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-gc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-gc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-gc.$(OBJEXT): {$(VPATH)}internal/symbol.h
-gc.$(OBJEXT): {$(VPATH)}internal/value.h
-gc.$(OBJEXT): {$(VPATH)}internal/value_type.h
-gc.$(OBJEXT): {$(VPATH)}internal/variable.h
-gc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-gc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-gc.$(OBJEXT): {$(VPATH)}io.h
-gc.$(OBJEXT): {$(VPATH)}iseq.h
-gc.$(OBJEXT): {$(VPATH)}method.h
-gc.$(OBJEXT): {$(VPATH)}missing.h
-gc.$(OBJEXT): {$(VPATH)}node.h
-gc.$(OBJEXT): {$(VPATH)}onigmo.h
-gc.$(OBJEXT): {$(VPATH)}oniguruma.h
-gc.$(OBJEXT): {$(VPATH)}probes.dmyh
-gc.$(OBJEXT): {$(VPATH)}probes.h
-gc.$(OBJEXT): {$(VPATH)}ractor.h
-gc.$(OBJEXT): {$(VPATH)}ractor_core.h
-gc.$(OBJEXT): {$(VPATH)}re.h
-gc.$(OBJEXT): {$(VPATH)}regenc.h
-gc.$(OBJEXT): {$(VPATH)}regex.h
-gc.$(OBJEXT): {$(VPATH)}regint.h
-gc.$(OBJEXT): {$(VPATH)}rjit.h
-gc.$(OBJEXT): {$(VPATH)}ruby_assert.h
-gc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-gc.$(OBJEXT): {$(VPATH)}shape.h
-gc.$(OBJEXT): {$(VPATH)}st.h
-gc.$(OBJEXT): {$(VPATH)}subst.h
-gc.$(OBJEXT): {$(VPATH)}symbol.h
-gc.$(OBJEXT): {$(VPATH)}thread.h
-gc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-gc.$(OBJEXT): {$(VPATH)}thread_native.h
-gc.$(OBJEXT): {$(VPATH)}transient_heap.h
-gc.$(OBJEXT): {$(VPATH)}util.h
-gc.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-gc.$(OBJEXT): {$(VPATH)}vm_core.h
-gc.$(OBJEXT): {$(VPATH)}vm_debug.h
-gc.$(OBJEXT): {$(VPATH)}vm_opts.h
-gc.$(OBJEXT): {$(VPATH)}vm_sync.h
-goruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-goruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-goruby.$(OBJEXT): $(CCAN_DIR)/list/list.h
-goruby.$(OBJEXT): $(CCAN_DIR)/str/str.h
-goruby.$(OBJEXT): $(hdrdir)/ruby.h
-goruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/array.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/gc.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
-goruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-goruby.$(OBJEXT): {$(VPATH)}assert.h
-goruby.$(OBJEXT): {$(VPATH)}atomic.h
-goruby.$(OBJEXT): {$(VPATH)}backward.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-goruby.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-goruby.$(OBJEXT): {$(VPATH)}config.h
-goruby.$(OBJEXT): {$(VPATH)}constant.h
-goruby.$(OBJEXT): {$(VPATH)}defines.h
-goruby.$(OBJEXT): {$(VPATH)}golf_prelude.c
-goruby.$(OBJEXT): {$(VPATH)}goruby.c
-goruby.$(OBJEXT): {$(VPATH)}id.h
-goruby.$(OBJEXT): {$(VPATH)}id_table.h
-goruby.$(OBJEXT): {$(VPATH)}intern.h
-goruby.$(OBJEXT): {$(VPATH)}internal.h
-goruby.$(OBJEXT): {$(VPATH)}internal/abi.h
-goruby.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-goruby.$(OBJEXT): {$(VPATH)}internal/assume.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-goruby.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-goruby.$(OBJEXT): {$(VPATH)}internal/cast.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-goruby.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-goruby.$(OBJEXT): {$(VPATH)}internal/config.h
-goruby.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-goruby.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-goruby.$(OBJEXT): {$(VPATH)}internal/ctype.h
-goruby.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-goruby.$(OBJEXT): {$(VPATH)}internal/dosish.h
-goruby.$(OBJEXT): {$(VPATH)}internal/error.h
-goruby.$(OBJEXT): {$(VPATH)}internal/eval.h
-goruby.$(OBJEXT): {$(VPATH)}internal/event.h
-goruby.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-goruby.$(OBJEXT): {$(VPATH)}internal/gc.h
-goruby.$(OBJEXT): {$(VPATH)}internal/glob.h
-goruby.$(OBJEXT): {$(VPATH)}internal/globals.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-goruby.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-goruby.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-goruby.$(OBJEXT): {$(VPATH)}internal/iterator.h
-goruby.$(OBJEXT): {$(VPATH)}internal/memory.h
-goruby.$(OBJEXT): {$(VPATH)}internal/method.h
-goruby.$(OBJEXT): {$(VPATH)}internal/module.h
-goruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
-goruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-goruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-goruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-goruby.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-goruby.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-goruby.$(OBJEXT): {$(VPATH)}internal/symbol.h
-goruby.$(OBJEXT): {$(VPATH)}internal/value.h
-goruby.$(OBJEXT): {$(VPATH)}internal/value_type.h
-goruby.$(OBJEXT): {$(VPATH)}internal/variable.h
-goruby.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-goruby.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-goruby.$(OBJEXT): {$(VPATH)}iseq.h
-goruby.$(OBJEXT): {$(VPATH)}main.c
-goruby.$(OBJEXT): {$(VPATH)}method.h
-goruby.$(OBJEXT): {$(VPATH)}missing.h
-goruby.$(OBJEXT): {$(VPATH)}node.h
-goruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
-goruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-goruby.$(OBJEXT): {$(VPATH)}shape.h
-goruby.$(OBJEXT): {$(VPATH)}st.h
-goruby.$(OBJEXT): {$(VPATH)}subst.h
-goruby.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-goruby.$(OBJEXT): {$(VPATH)}thread_native.h
-goruby.$(OBJEXT): {$(VPATH)}vm_core.h
-goruby.$(OBJEXT): {$(VPATH)}vm_debug.h
-goruby.$(OBJEXT): {$(VPATH)}vm_opts.h
-hash.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-hash.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-hash.$(OBJEXT): $(CCAN_DIR)/list/list.h
-hash.$(OBJEXT): $(CCAN_DIR)/str/str.h
-hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-hash.$(OBJEXT): $(top_srcdir)/internal/array.h
-hash.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-hash.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-hash.$(OBJEXT): $(top_srcdir)/internal/bits.h
-hash.$(OBJEXT): $(top_srcdir)/internal/class.h
-hash.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-hash.$(OBJEXT): $(top_srcdir)/internal/cont.h
-hash.$(OBJEXT): $(top_srcdir)/internal/error.h
-hash.$(OBJEXT): $(top_srcdir)/internal/gc.h
-hash.$(OBJEXT): $(top_srcdir)/internal/hash.h
-hash.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-hash.$(OBJEXT): $(top_srcdir)/internal/object.h
-hash.$(OBJEXT): $(top_srcdir)/internal/proc.h
-hash.$(OBJEXT): $(top_srcdir)/internal/serial.h
-hash.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-hash.$(OBJEXT): $(top_srcdir)/internal/string.h
-hash.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-hash.$(OBJEXT): $(top_srcdir)/internal/thread.h
-hash.$(OBJEXT): $(top_srcdir)/internal/time.h
-hash.$(OBJEXT): $(top_srcdir)/internal/variable.h
-hash.$(OBJEXT): $(top_srcdir)/internal/vm.h
-hash.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-hash.$(OBJEXT): {$(VPATH)}assert.h
-hash.$(OBJEXT): {$(VPATH)}atomic.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-hash.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-hash.$(OBJEXT): {$(VPATH)}config.h
-hash.$(OBJEXT): {$(VPATH)}constant.h
-hash.$(OBJEXT): {$(VPATH)}debug_counter.h
-hash.$(OBJEXT): {$(VPATH)}defines.h
-hash.$(OBJEXT): {$(VPATH)}encoding.h
-hash.$(OBJEXT): {$(VPATH)}hash.c
-hash.$(OBJEXT): {$(VPATH)}id.h
-hash.$(OBJEXT): {$(VPATH)}id_table.h
-hash.$(OBJEXT): {$(VPATH)}intern.h
-hash.$(OBJEXT): {$(VPATH)}internal.h
-hash.$(OBJEXT): {$(VPATH)}internal/abi.h
-hash.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-hash.$(OBJEXT): {$(VPATH)}internal/assume.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-hash.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-hash.$(OBJEXT): {$(VPATH)}internal/cast.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-hash.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-hash.$(OBJEXT): {$(VPATH)}internal/config.h
-hash.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-hash.$(OBJEXT): {$(VPATH)}internal/core.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-hash.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-hash.$(OBJEXT): {$(VPATH)}internal/ctype.h
-hash.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-hash.$(OBJEXT): {$(VPATH)}internal/dosish.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-hash.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-hash.$(OBJEXT): {$(VPATH)}internal/error.h
-hash.$(OBJEXT): {$(VPATH)}internal/eval.h
-hash.$(OBJEXT): {$(VPATH)}internal/event.h
-hash.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-hash.$(OBJEXT): {$(VPATH)}internal/gc.h
-hash.$(OBJEXT): {$(VPATH)}internal/glob.h
-hash.$(OBJEXT): {$(VPATH)}internal/globals.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-hash.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-hash.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-hash.$(OBJEXT): {$(VPATH)}internal/iterator.h
-hash.$(OBJEXT): {$(VPATH)}internal/memory.h
-hash.$(OBJEXT): {$(VPATH)}internal/method.h
-hash.$(OBJEXT): {$(VPATH)}internal/module.h
-hash.$(OBJEXT): {$(VPATH)}internal/newobj.h
-hash.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-hash.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-hash.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-hash.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-hash.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-hash.$(OBJEXT): {$(VPATH)}internal/symbol.h
-hash.$(OBJEXT): {$(VPATH)}internal/value.h
-hash.$(OBJEXT): {$(VPATH)}internal/value_type.h
-hash.$(OBJEXT): {$(VPATH)}internal/variable.h
-hash.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-hash.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-hash.$(OBJEXT): {$(VPATH)}iseq.h
-hash.$(OBJEXT): {$(VPATH)}method.h
-hash.$(OBJEXT): {$(VPATH)}missing.h
-hash.$(OBJEXT): {$(VPATH)}node.h
-hash.$(OBJEXT): {$(VPATH)}onigmo.h
-hash.$(OBJEXT): {$(VPATH)}oniguruma.h
-hash.$(OBJEXT): {$(VPATH)}probes.dmyh
-hash.$(OBJEXT): {$(VPATH)}probes.h
-hash.$(OBJEXT): {$(VPATH)}ractor.h
-hash.$(OBJEXT): {$(VPATH)}ruby_assert.h
-hash.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-hash.$(OBJEXT): {$(VPATH)}shape.h
-hash.$(OBJEXT): {$(VPATH)}st.h
-hash.$(OBJEXT): {$(VPATH)}subst.h
-hash.$(OBJEXT): {$(VPATH)}symbol.h
-hash.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-hash.$(OBJEXT): {$(VPATH)}thread_native.h
-hash.$(OBJEXT): {$(VPATH)}transient_heap.h
-hash.$(OBJEXT): {$(VPATH)}util.h
-hash.$(OBJEXT): {$(VPATH)}vm_core.h
-hash.$(OBJEXT): {$(VPATH)}vm_debug.h
-hash.$(OBJEXT): {$(VPATH)}vm_opts.h
-hash.$(OBJEXT): {$(VPATH)}vm_sync.h
-inits.$(OBJEXT): $(hdrdir)/ruby.h
-inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-inits.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-inits.$(OBJEXT): $(top_srcdir)/internal/inits.h
-inits.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-inits.$(OBJEXT): {$(VPATH)}assert.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-inits.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-inits.$(OBJEXT): {$(VPATH)}builtin.h
-inits.$(OBJEXT): {$(VPATH)}config.h
-inits.$(OBJEXT): {$(VPATH)}defines.h
-inits.$(OBJEXT): {$(VPATH)}inits.c
-inits.$(OBJEXT): {$(VPATH)}intern.h
-inits.$(OBJEXT): {$(VPATH)}internal/abi.h
-inits.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-inits.$(OBJEXT): {$(VPATH)}internal/assume.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-inits.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-inits.$(OBJEXT): {$(VPATH)}internal/cast.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-inits.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-inits.$(OBJEXT): {$(VPATH)}internal/config.h
-inits.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-inits.$(OBJEXT): {$(VPATH)}internal/core.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-inits.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-inits.$(OBJEXT): {$(VPATH)}internal/ctype.h
-inits.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-inits.$(OBJEXT): {$(VPATH)}internal/dosish.h
-inits.$(OBJEXT): {$(VPATH)}internal/error.h
-inits.$(OBJEXT): {$(VPATH)}internal/eval.h
-inits.$(OBJEXT): {$(VPATH)}internal/event.h
-inits.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-inits.$(OBJEXT): {$(VPATH)}internal/gc.h
-inits.$(OBJEXT): {$(VPATH)}internal/glob.h
-inits.$(OBJEXT): {$(VPATH)}internal/globals.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-inits.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-inits.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-inits.$(OBJEXT): {$(VPATH)}internal/iterator.h
-inits.$(OBJEXT): {$(VPATH)}internal/memory.h
-inits.$(OBJEXT): {$(VPATH)}internal/method.h
-inits.$(OBJEXT): {$(VPATH)}internal/module.h
-inits.$(OBJEXT): {$(VPATH)}internal/newobj.h
-inits.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-inits.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-inits.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-inits.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-inits.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-inits.$(OBJEXT): {$(VPATH)}internal/symbol.h
-inits.$(OBJEXT): {$(VPATH)}internal/value.h
-inits.$(OBJEXT): {$(VPATH)}internal/value_type.h
-inits.$(OBJEXT): {$(VPATH)}internal/variable.h
-inits.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-inits.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-inits.$(OBJEXT): {$(VPATH)}missing.h
-inits.$(OBJEXT): {$(VPATH)}prelude.rbinc
-inits.$(OBJEXT): {$(VPATH)}st.h
-inits.$(OBJEXT): {$(VPATH)}subst.h
-io.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-io.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-io.$(OBJEXT): $(CCAN_DIR)/list/list.h
-io.$(OBJEXT): $(CCAN_DIR)/str/str.h
-io.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-io.$(OBJEXT): $(top_srcdir)/internal/array.h
-io.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-io.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-io.$(OBJEXT): $(top_srcdir)/internal/bits.h
-io.$(OBJEXT): $(top_srcdir)/internal/class.h
-io.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-io.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-io.$(OBJEXT): $(top_srcdir)/internal/error.h
-io.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-io.$(OBJEXT): $(top_srcdir)/internal/gc.h
-io.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-io.$(OBJEXT): $(top_srcdir)/internal/inits.h
-io.$(OBJEXT): $(top_srcdir)/internal/io.h
-io.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-io.$(OBJEXT): $(top_srcdir)/internal/object.h
-io.$(OBJEXT): $(top_srcdir)/internal/process.h
-io.$(OBJEXT): $(top_srcdir)/internal/serial.h
-io.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-io.$(OBJEXT): $(top_srcdir)/internal/string.h
-io.$(OBJEXT): $(top_srcdir)/internal/thread.h
-io.$(OBJEXT): $(top_srcdir)/internal/transcode.h
-io.$(OBJEXT): $(top_srcdir)/internal/variable.h
-io.$(OBJEXT): $(top_srcdir)/internal/vm.h
-io.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-io.$(OBJEXT): {$(VPATH)}assert.h
-io.$(OBJEXT): {$(VPATH)}atomic.h
-io.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-io.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-io.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-io.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-io.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-io.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-io.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-io.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-io.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-io.$(OBJEXT): {$(VPATH)}builtin.h
-io.$(OBJEXT): {$(VPATH)}config.h
-io.$(OBJEXT): {$(VPATH)}constant.h
-io.$(OBJEXT): {$(VPATH)}defines.h
-io.$(OBJEXT): {$(VPATH)}dln.h
-io.$(OBJEXT): {$(VPATH)}encindex.h
-io.$(OBJEXT): {$(VPATH)}encoding.h
-io.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-io.$(OBJEXT): {$(VPATH)}id.h
-io.$(OBJEXT): {$(VPATH)}id_table.h
-io.$(OBJEXT): {$(VPATH)}intern.h
-io.$(OBJEXT): {$(VPATH)}internal.h
-io.$(OBJEXT): {$(VPATH)}internal/abi.h
-io.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-io.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-io.$(OBJEXT): {$(VPATH)}internal/assume.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-io.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-io.$(OBJEXT): {$(VPATH)}internal/cast.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-io.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-io.$(OBJEXT): {$(VPATH)}internal/config.h
-io.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-io.$(OBJEXT): {$(VPATH)}internal/core.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-io.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-io.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-io.$(OBJEXT): {$(VPATH)}internal/ctype.h
-io.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-io.$(OBJEXT): {$(VPATH)}internal/dosish.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-io.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-io.$(OBJEXT): {$(VPATH)}internal/error.h
-io.$(OBJEXT): {$(VPATH)}internal/eval.h
-io.$(OBJEXT): {$(VPATH)}internal/event.h
-io.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-io.$(OBJEXT): {$(VPATH)}internal/gc.h
-io.$(OBJEXT): {$(VPATH)}internal/glob.h
-io.$(OBJEXT): {$(VPATH)}internal/globals.h
-io.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-io.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-io.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-io.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-io.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-io.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-io.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-io.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-io.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-io.$(OBJEXT): {$(VPATH)}internal/iterator.h
-io.$(OBJEXT): {$(VPATH)}internal/memory.h
-io.$(OBJEXT): {$(VPATH)}internal/method.h
-io.$(OBJEXT): {$(VPATH)}internal/module.h
-io.$(OBJEXT): {$(VPATH)}internal/newobj.h
-io.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-io.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-io.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-io.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-io.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-io.$(OBJEXT): {$(VPATH)}internal/symbol.h
-io.$(OBJEXT): {$(VPATH)}internal/value.h
-io.$(OBJEXT): {$(VPATH)}internal/value_type.h
-io.$(OBJEXT): {$(VPATH)}internal/variable.h
-io.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-io.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-io.$(OBJEXT): {$(VPATH)}io.c
-io.$(OBJEXT): {$(VPATH)}io.h
-io.$(OBJEXT): {$(VPATH)}io.rbinc
-io.$(OBJEXT): {$(VPATH)}io/buffer.h
-io.$(OBJEXT): {$(VPATH)}method.h
-io.$(OBJEXT): {$(VPATH)}missing.h
-io.$(OBJEXT): {$(VPATH)}node.h
-io.$(OBJEXT): {$(VPATH)}onigmo.h
-io.$(OBJEXT): {$(VPATH)}oniguruma.h
-io.$(OBJEXT): {$(VPATH)}ractor.h
-io.$(OBJEXT): {$(VPATH)}ruby_assert.h
-io.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-io.$(OBJEXT): {$(VPATH)}shape.h
-io.$(OBJEXT): {$(VPATH)}st.h
-io.$(OBJEXT): {$(VPATH)}subst.h
-io.$(OBJEXT): {$(VPATH)}thread.h
-io.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-io.$(OBJEXT): {$(VPATH)}thread_native.h
-io.$(OBJEXT): {$(VPATH)}util.h
-io.$(OBJEXT): {$(VPATH)}vm_core.h
-io.$(OBJEXT): {$(VPATH)}vm_opts.h
-io_buffer.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/array.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/bits.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/error.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/serial.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/string.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/thread.h
-io_buffer.$(OBJEXT): $(top_srcdir)/internal/vm.h
-io_buffer.$(OBJEXT): {$(VPATH)}assert.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-io_buffer.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-io_buffer.$(OBJEXT): {$(VPATH)}config.h
-io_buffer.$(OBJEXT): {$(VPATH)}defines.h
-io_buffer.$(OBJEXT): {$(VPATH)}encoding.h
-io_buffer.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-io_buffer.$(OBJEXT): {$(VPATH)}intern.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/abi.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/assume.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/cast.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/config.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/ctype.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/dosish.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/error.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/eval.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/event.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/gc.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/glob.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/globals.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/iterator.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/memory.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/method.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/module.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/newobj.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/symbol.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/value.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/value_type.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/variable.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-io_buffer.$(OBJEXT): {$(VPATH)}io.h
-io_buffer.$(OBJEXT): {$(VPATH)}io/buffer.h
-io_buffer.$(OBJEXT): {$(VPATH)}io_buffer.c
-io_buffer.$(OBJEXT): {$(VPATH)}missing.h
-io_buffer.$(OBJEXT): {$(VPATH)}onigmo.h
-io_buffer.$(OBJEXT): {$(VPATH)}oniguruma.h
-io_buffer.$(OBJEXT): {$(VPATH)}st.h
-io_buffer.$(OBJEXT): {$(VPATH)}subst.h
-iseq.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-iseq.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h
-iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h
-iseq.$(OBJEXT): $(hdrdir)/ruby.h
-iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/array.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/bits.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/class.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/compile.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/error.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/file.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/gc.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/hash.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/parse.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/serial.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/string.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/thread.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/variable.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/vm.h
-iseq.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-iseq.$(OBJEXT): {$(VPATH)}assert.h
-iseq.$(OBJEXT): {$(VPATH)}atomic.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-iseq.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-iseq.$(OBJEXT): {$(VPATH)}builtin.h
-iseq.$(OBJEXT): {$(VPATH)}config.h
-iseq.$(OBJEXT): {$(VPATH)}constant.h
-iseq.$(OBJEXT): {$(VPATH)}debug_counter.h
-iseq.$(OBJEXT): {$(VPATH)}defines.h
-iseq.$(OBJEXT): {$(VPATH)}encoding.h
-iseq.$(OBJEXT): {$(VPATH)}eval_intern.h
-iseq.$(OBJEXT): {$(VPATH)}id.h
-iseq.$(OBJEXT): {$(VPATH)}id_table.h
-iseq.$(OBJEXT): {$(VPATH)}insns.def
-iseq.$(OBJEXT): {$(VPATH)}insns.inc
-iseq.$(OBJEXT): {$(VPATH)}insns_info.inc
-iseq.$(OBJEXT): {$(VPATH)}intern.h
-iseq.$(OBJEXT): {$(VPATH)}internal.h
-iseq.$(OBJEXT): {$(VPATH)}internal/abi.h
-iseq.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-iseq.$(OBJEXT): {$(VPATH)}internal/assume.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-iseq.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-iseq.$(OBJEXT): {$(VPATH)}internal/cast.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-iseq.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-iseq.$(OBJEXT): {$(VPATH)}internal/config.h
-iseq.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-iseq.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-iseq.$(OBJEXT): {$(VPATH)}internal/ctype.h
-iseq.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-iseq.$(OBJEXT): {$(VPATH)}internal/dosish.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-iseq.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-iseq.$(OBJEXT): {$(VPATH)}internal/error.h
-iseq.$(OBJEXT): {$(VPATH)}internal/eval.h
-iseq.$(OBJEXT): {$(VPATH)}internal/event.h
-iseq.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-iseq.$(OBJEXT): {$(VPATH)}internal/gc.h
-iseq.$(OBJEXT): {$(VPATH)}internal/glob.h
-iseq.$(OBJEXT): {$(VPATH)}internal/globals.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-iseq.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-iseq.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-iseq.$(OBJEXT): {$(VPATH)}internal/iterator.h
-iseq.$(OBJEXT): {$(VPATH)}internal/memory.h
-iseq.$(OBJEXT): {$(VPATH)}internal/method.h
-iseq.$(OBJEXT): {$(VPATH)}internal/module.h
-iseq.$(OBJEXT): {$(VPATH)}internal/newobj.h
-iseq.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-iseq.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-iseq.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-iseq.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-iseq.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-iseq.$(OBJEXT): {$(VPATH)}internal/symbol.h
-iseq.$(OBJEXT): {$(VPATH)}internal/value.h
-iseq.$(OBJEXT): {$(VPATH)}internal/value_type.h
-iseq.$(OBJEXT): {$(VPATH)}internal/variable.h
-iseq.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-iseq.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-iseq.$(OBJEXT): {$(VPATH)}iseq.c
-iseq.$(OBJEXT): {$(VPATH)}iseq.h
-iseq.$(OBJEXT): {$(VPATH)}method.h
-iseq.$(OBJEXT): {$(VPATH)}missing.h
-iseq.$(OBJEXT): {$(VPATH)}node.h
-iseq.$(OBJEXT): {$(VPATH)}node_name.inc
-iseq.$(OBJEXT): {$(VPATH)}onigmo.h
-iseq.$(OBJEXT): {$(VPATH)}oniguruma.h
-iseq.$(OBJEXT): {$(VPATH)}ractor.h
-iseq.$(OBJEXT): {$(VPATH)}rjit.h
-iseq.$(OBJEXT): {$(VPATH)}ruby_assert.h
-iseq.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-iseq.$(OBJEXT): {$(VPATH)}shape.h
-iseq.$(OBJEXT): {$(VPATH)}st.h
-iseq.$(OBJEXT): {$(VPATH)}subst.h
-iseq.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-iseq.$(OBJEXT): {$(VPATH)}thread_native.h
-iseq.$(OBJEXT): {$(VPATH)}util.h
-iseq.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-iseq.$(OBJEXT): {$(VPATH)}vm_core.h
-iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
-iseq.$(OBJEXT): {$(VPATH)}yjit.h
-load.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-load.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-load.$(OBJEXT): $(CCAN_DIR)/list/list.h
-load.$(OBJEXT): $(CCAN_DIR)/str/str.h
-load.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-load.$(OBJEXT): $(top_srcdir)/internal/array.h
-load.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-load.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-load.$(OBJEXT): $(top_srcdir)/internal/dir.h
-load.$(OBJEXT): $(top_srcdir)/internal/error.h
-load.$(OBJEXT): $(top_srcdir)/internal/file.h
-load.$(OBJEXT): $(top_srcdir)/internal/gc.h
-load.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-load.$(OBJEXT): $(top_srcdir)/internal/load.h
-load.$(OBJEXT): $(top_srcdir)/internal/parse.h
-load.$(OBJEXT): $(top_srcdir)/internal/serial.h
-load.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-load.$(OBJEXT): $(top_srcdir)/internal/string.h
-load.$(OBJEXT): $(top_srcdir)/internal/thread.h
-load.$(OBJEXT): $(top_srcdir)/internal/variable.h
-load.$(OBJEXT): $(top_srcdir)/internal/vm.h
-load.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-load.$(OBJEXT): {$(VPATH)}assert.h
-load.$(OBJEXT): {$(VPATH)}atomic.h
-load.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-load.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-load.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-load.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-load.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-load.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-load.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-load.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-load.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-load.$(OBJEXT): {$(VPATH)}config.h
-load.$(OBJEXT): {$(VPATH)}constant.h
-load.$(OBJEXT): {$(VPATH)}darray.h
-load.$(OBJEXT): {$(VPATH)}defines.h
-load.$(OBJEXT): {$(VPATH)}dln.h
-load.$(OBJEXT): {$(VPATH)}encoding.h
-load.$(OBJEXT): {$(VPATH)}eval_intern.h
-load.$(OBJEXT): {$(VPATH)}id.h
-load.$(OBJEXT): {$(VPATH)}id_table.h
-load.$(OBJEXT): {$(VPATH)}intern.h
-load.$(OBJEXT): {$(VPATH)}internal.h
-load.$(OBJEXT): {$(VPATH)}internal/abi.h
-load.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-load.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-load.$(OBJEXT): {$(VPATH)}internal/assume.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-load.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-load.$(OBJEXT): {$(VPATH)}internal/cast.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-load.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-load.$(OBJEXT): {$(VPATH)}internal/config.h
-load.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-load.$(OBJEXT): {$(VPATH)}internal/core.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-load.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-load.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-load.$(OBJEXT): {$(VPATH)}internal/ctype.h
-load.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-load.$(OBJEXT): {$(VPATH)}internal/dosish.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-load.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-load.$(OBJEXT): {$(VPATH)}internal/error.h
-load.$(OBJEXT): {$(VPATH)}internal/eval.h
-load.$(OBJEXT): {$(VPATH)}internal/event.h
-load.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-load.$(OBJEXT): {$(VPATH)}internal/gc.h
-load.$(OBJEXT): {$(VPATH)}internal/glob.h
-load.$(OBJEXT): {$(VPATH)}internal/globals.h
-load.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-load.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-load.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-load.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-load.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-load.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-load.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-load.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-load.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-load.$(OBJEXT): {$(VPATH)}internal/iterator.h
-load.$(OBJEXT): {$(VPATH)}internal/memory.h
-load.$(OBJEXT): {$(VPATH)}internal/method.h
-load.$(OBJEXT): {$(VPATH)}internal/module.h
-load.$(OBJEXT): {$(VPATH)}internal/newobj.h
-load.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-load.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-load.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-load.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-load.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-load.$(OBJEXT): {$(VPATH)}internal/symbol.h
-load.$(OBJEXT): {$(VPATH)}internal/value.h
-load.$(OBJEXT): {$(VPATH)}internal/value_type.h
-load.$(OBJEXT): {$(VPATH)}internal/variable.h
-load.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-load.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-load.$(OBJEXT): {$(VPATH)}iseq.h
-load.$(OBJEXT): {$(VPATH)}load.c
-load.$(OBJEXT): {$(VPATH)}method.h
-load.$(OBJEXT): {$(VPATH)}missing.h
-load.$(OBJEXT): {$(VPATH)}node.h
-load.$(OBJEXT): {$(VPATH)}onigmo.h
-load.$(OBJEXT): {$(VPATH)}oniguruma.h
-load.$(OBJEXT): {$(VPATH)}probes.dmyh
-load.$(OBJEXT): {$(VPATH)}probes.h
-load.$(OBJEXT): {$(VPATH)}ruby_assert.h
-load.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-load.$(OBJEXT): {$(VPATH)}shape.h
-load.$(OBJEXT): {$(VPATH)}st.h
-load.$(OBJEXT): {$(VPATH)}subst.h
-load.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-load.$(OBJEXT): {$(VPATH)}thread_native.h
-load.$(OBJEXT): {$(VPATH)}util.h
-load.$(OBJEXT): {$(VPATH)}vm_core.h
-load.$(OBJEXT): {$(VPATH)}vm_opts.h
-loadpath.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-loadpath.$(OBJEXT): $(hdrdir)/ruby/version.h
-loadpath.$(OBJEXT): $(top_srcdir)/version.h
-loadpath.$(OBJEXT): {$(VPATH)}assert.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-loadpath.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-loadpath.$(OBJEXT): {$(VPATH)}config.h
-loadpath.$(OBJEXT): {$(VPATH)}defines.h
-loadpath.$(OBJEXT): {$(VPATH)}intern.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/abi.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/assume.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/cast.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/config.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/ctype.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/dosish.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/error.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/eval.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/event.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/gc.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/glob.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/globals.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/iterator.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/memory.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/method.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/module.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/newobj.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/symbol.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/value.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/value_type.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/variable.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-loadpath.$(OBJEXT): {$(VPATH)}loadpath.c
-loadpath.$(OBJEXT): {$(VPATH)}missing.h
-loadpath.$(OBJEXT): {$(VPATH)}st.h
-loadpath.$(OBJEXT): {$(VPATH)}subst.h
-loadpath.$(OBJEXT): {$(VPATH)}verconf.h
-localeinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-localeinit.$(OBJEXT): {$(VPATH)}assert.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-localeinit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-localeinit.$(OBJEXT): {$(VPATH)}config.h
-localeinit.$(OBJEXT): {$(VPATH)}defines.h
-localeinit.$(OBJEXT): {$(VPATH)}encindex.h
-localeinit.$(OBJEXT): {$(VPATH)}encoding.h
-localeinit.$(OBJEXT): {$(VPATH)}intern.h
-localeinit.$(OBJEXT): {$(VPATH)}internal.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/abi.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/assume.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/cast.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/config.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/ctype.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/dosish.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/error.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/eval.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/event.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/gc.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/glob.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/globals.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/iterator.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/memory.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/method.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/module.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/symbol.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/value.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/value_type.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/variable.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-localeinit.$(OBJEXT): {$(VPATH)}localeinit.c
-localeinit.$(OBJEXT): {$(VPATH)}missing.h
-localeinit.$(OBJEXT): {$(VPATH)}onigmo.h
-localeinit.$(OBJEXT): {$(VPATH)}oniguruma.h
-localeinit.$(OBJEXT): {$(VPATH)}st.h
-localeinit.$(OBJEXT): {$(VPATH)}subst.h
-main.$(OBJEXT): $(hdrdir)/ruby.h
-main.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-main.$(OBJEXT): {$(VPATH)}assert.h
-main.$(OBJEXT): {$(VPATH)}backward.h
-main.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-main.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-main.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-main.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-main.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-main.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-main.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-main.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-main.$(OBJEXT): {$(VPATH)}config.h
-main.$(OBJEXT): {$(VPATH)}defines.h
-main.$(OBJEXT): {$(VPATH)}intern.h
-main.$(OBJEXT): {$(VPATH)}internal/abi.h
-main.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-main.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-main.$(OBJEXT): {$(VPATH)}internal/assume.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-main.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-main.$(OBJEXT): {$(VPATH)}internal/cast.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-main.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-main.$(OBJEXT): {$(VPATH)}internal/config.h
-main.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-main.$(OBJEXT): {$(VPATH)}internal/core.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-main.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-main.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-main.$(OBJEXT): {$(VPATH)}internal/ctype.h
-main.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-main.$(OBJEXT): {$(VPATH)}internal/dosish.h
-main.$(OBJEXT): {$(VPATH)}internal/error.h
-main.$(OBJEXT): {$(VPATH)}internal/eval.h
-main.$(OBJEXT): {$(VPATH)}internal/event.h
-main.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-main.$(OBJEXT): {$(VPATH)}internal/gc.h
-main.$(OBJEXT): {$(VPATH)}internal/glob.h
-main.$(OBJEXT): {$(VPATH)}internal/globals.h
-main.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-main.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-main.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-main.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-main.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-main.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-main.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-main.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-main.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-main.$(OBJEXT): {$(VPATH)}internal/iterator.h
-main.$(OBJEXT): {$(VPATH)}internal/memory.h
-main.$(OBJEXT): {$(VPATH)}internal/method.h
-main.$(OBJEXT): {$(VPATH)}internal/module.h
-main.$(OBJEXT): {$(VPATH)}internal/newobj.h
-main.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-main.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-main.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-main.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-main.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-main.$(OBJEXT): {$(VPATH)}internal/symbol.h
-main.$(OBJEXT): {$(VPATH)}internal/value.h
-main.$(OBJEXT): {$(VPATH)}internal/value_type.h
-main.$(OBJEXT): {$(VPATH)}internal/variable.h
-main.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-main.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-main.$(OBJEXT): {$(VPATH)}main.c
-main.$(OBJEXT): {$(VPATH)}missing.h
-main.$(OBJEXT): {$(VPATH)}st.h
-main.$(OBJEXT): {$(VPATH)}subst.h
-main.$(OBJEXT): {$(VPATH)}vm_debug.h
-marshal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/array.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/bits.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/class.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/error.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/gc.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/hash.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/object.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/serial.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/string.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/struct.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/util.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/variable.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/vm.h
-marshal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-marshal.$(OBJEXT): {$(VPATH)}assert.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-marshal.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-marshal.$(OBJEXT): {$(VPATH)}builtin.h
-marshal.$(OBJEXT): {$(VPATH)}config.h
-marshal.$(OBJEXT): {$(VPATH)}constant.h
-marshal.$(OBJEXT): {$(VPATH)}defines.h
-marshal.$(OBJEXT): {$(VPATH)}encindex.h
-marshal.$(OBJEXT): {$(VPATH)}encoding.h
-marshal.$(OBJEXT): {$(VPATH)}id.h
-marshal.$(OBJEXT): {$(VPATH)}id_table.h
-marshal.$(OBJEXT): {$(VPATH)}intern.h
-marshal.$(OBJEXT): {$(VPATH)}internal.h
-marshal.$(OBJEXT): {$(VPATH)}internal/abi.h
-marshal.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-marshal.$(OBJEXT): {$(VPATH)}internal/assume.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-marshal.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-marshal.$(OBJEXT): {$(VPATH)}internal/cast.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-marshal.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-marshal.$(OBJEXT): {$(VPATH)}internal/config.h
-marshal.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-marshal.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-marshal.$(OBJEXT): {$(VPATH)}internal/ctype.h
-marshal.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-marshal.$(OBJEXT): {$(VPATH)}internal/dosish.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-marshal.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-marshal.$(OBJEXT): {$(VPATH)}internal/error.h
-marshal.$(OBJEXT): {$(VPATH)}internal/eval.h
-marshal.$(OBJEXT): {$(VPATH)}internal/event.h
-marshal.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-marshal.$(OBJEXT): {$(VPATH)}internal/gc.h
-marshal.$(OBJEXT): {$(VPATH)}internal/glob.h
-marshal.$(OBJEXT): {$(VPATH)}internal/globals.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-marshal.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-marshal.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-marshal.$(OBJEXT): {$(VPATH)}internal/iterator.h
-marshal.$(OBJEXT): {$(VPATH)}internal/memory.h
-marshal.$(OBJEXT): {$(VPATH)}internal/method.h
-marshal.$(OBJEXT): {$(VPATH)}internal/module.h
-marshal.$(OBJEXT): {$(VPATH)}internal/newobj.h
-marshal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-marshal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-marshal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-marshal.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-marshal.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-marshal.$(OBJEXT): {$(VPATH)}internal/symbol.h
-marshal.$(OBJEXT): {$(VPATH)}internal/value.h
-marshal.$(OBJEXT): {$(VPATH)}internal/value_type.h
-marshal.$(OBJEXT): {$(VPATH)}internal/variable.h
-marshal.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-marshal.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-marshal.$(OBJEXT): {$(VPATH)}io.h
-marshal.$(OBJEXT): {$(VPATH)}marshal.c
-marshal.$(OBJEXT): {$(VPATH)}marshal.rbinc
-marshal.$(OBJEXT): {$(VPATH)}missing.h
-marshal.$(OBJEXT): {$(VPATH)}onigmo.h
-marshal.$(OBJEXT): {$(VPATH)}oniguruma.h
-marshal.$(OBJEXT): {$(VPATH)}shape.h
-marshal.$(OBJEXT): {$(VPATH)}st.h
-marshal.$(OBJEXT): {$(VPATH)}subst.h
-marshal.$(OBJEXT): {$(VPATH)}util.h
-math.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-math.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-math.$(OBJEXT): $(top_srcdir)/internal/class.h
-math.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-math.$(OBJEXT): $(top_srcdir)/internal/complex.h
-math.$(OBJEXT): $(top_srcdir)/internal/gc.h
-math.$(OBJEXT): $(top_srcdir)/internal/math.h
-math.$(OBJEXT): $(top_srcdir)/internal/object.h
-math.$(OBJEXT): $(top_srcdir)/internal/serial.h
-math.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-math.$(OBJEXT): $(top_srcdir)/internal/variable.h
-math.$(OBJEXT): $(top_srcdir)/internal/vm.h
-math.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-math.$(OBJEXT): {$(VPATH)}assert.h
-math.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-math.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-math.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-math.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-math.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-math.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-math.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-math.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-math.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-math.$(OBJEXT): {$(VPATH)}config.h
-math.$(OBJEXT): {$(VPATH)}constant.h
-math.$(OBJEXT): {$(VPATH)}defines.h
-math.$(OBJEXT): {$(VPATH)}id_table.h
-math.$(OBJEXT): {$(VPATH)}intern.h
-math.$(OBJEXT): {$(VPATH)}internal.h
-math.$(OBJEXT): {$(VPATH)}internal/abi.h
-math.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-math.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-math.$(OBJEXT): {$(VPATH)}internal/assume.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-math.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-math.$(OBJEXT): {$(VPATH)}internal/cast.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-math.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-math.$(OBJEXT): {$(VPATH)}internal/config.h
-math.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-math.$(OBJEXT): {$(VPATH)}internal/core.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-math.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-math.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-math.$(OBJEXT): {$(VPATH)}internal/ctype.h
-math.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-math.$(OBJEXT): {$(VPATH)}internal/dosish.h
-math.$(OBJEXT): {$(VPATH)}internal/error.h
-math.$(OBJEXT): {$(VPATH)}internal/eval.h
-math.$(OBJEXT): {$(VPATH)}internal/event.h
-math.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-math.$(OBJEXT): {$(VPATH)}internal/gc.h
-math.$(OBJEXT): {$(VPATH)}internal/glob.h
-math.$(OBJEXT): {$(VPATH)}internal/globals.h
-math.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-math.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-math.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-math.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-math.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-math.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-math.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-math.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-math.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-math.$(OBJEXT): {$(VPATH)}internal/iterator.h
-math.$(OBJEXT): {$(VPATH)}internal/memory.h
-math.$(OBJEXT): {$(VPATH)}internal/method.h
-math.$(OBJEXT): {$(VPATH)}internal/module.h
-math.$(OBJEXT): {$(VPATH)}internal/newobj.h
-math.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-math.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-math.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-math.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-math.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-math.$(OBJEXT): {$(VPATH)}internal/symbol.h
-math.$(OBJEXT): {$(VPATH)}internal/value.h
-math.$(OBJEXT): {$(VPATH)}internal/value_type.h
-math.$(OBJEXT): {$(VPATH)}internal/variable.h
-math.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-math.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-math.$(OBJEXT): {$(VPATH)}math.c
-math.$(OBJEXT): {$(VPATH)}missing.h
-math.$(OBJEXT): {$(VPATH)}shape.h
-math.$(OBJEXT): {$(VPATH)}st.h
-math.$(OBJEXT): {$(VPATH)}subst.h
-memory_view.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-memory_view.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-memory_view.$(OBJEXT): $(top_srcdir)/internal/gc.h
-memory_view.$(OBJEXT): $(top_srcdir)/internal/hash.h
-memory_view.$(OBJEXT): $(top_srcdir)/internal/variable.h
-memory_view.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-memory_view.$(OBJEXT): {$(VPATH)}assert.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-memory_view.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-memory_view.$(OBJEXT): {$(VPATH)}config.h
-memory_view.$(OBJEXT): {$(VPATH)}constant.h
-memory_view.$(OBJEXT): {$(VPATH)}debug_counter.h
-memory_view.$(OBJEXT): {$(VPATH)}defines.h
-memory_view.$(OBJEXT): {$(VPATH)}id_table.h
-memory_view.$(OBJEXT): {$(VPATH)}intern.h
-memory_view.$(OBJEXT): {$(VPATH)}internal.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/abi.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/assume.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/cast.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/config.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/ctype.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/dosish.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/error.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/eval.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/event.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/gc.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/glob.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/globals.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/iterator.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/memory.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/method.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/module.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/newobj.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/symbol.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/value.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/value_type.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/variable.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-memory_view.$(OBJEXT): {$(VPATH)}memory_view.c
-memory_view.$(OBJEXT): {$(VPATH)}memory_view.h
-memory_view.$(OBJEXT): {$(VPATH)}missing.h
-memory_view.$(OBJEXT): {$(VPATH)}shape.h
-memory_view.$(OBJEXT): {$(VPATH)}st.h
-memory_view.$(OBJEXT): {$(VPATH)}subst.h
-memory_view.$(OBJEXT): {$(VPATH)}util.h
-memory_view.$(OBJEXT): {$(VPATH)}vm_debug.h
-memory_view.$(OBJEXT): {$(VPATH)}vm_sync.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-miniinit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-miniinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-miniinit.$(OBJEXT): $(srcdir)/rjit_c.rb
-miniinit.$(OBJEXT): $(top_srcdir)/internal/array.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/gc.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/serial.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/variable.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/vm.h
-miniinit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-miniinit.$(OBJEXT): {$(VPATH)}array.rb
-miniinit.$(OBJEXT): {$(VPATH)}assert.h
-miniinit.$(OBJEXT): {$(VPATH)}ast.rb
-miniinit.$(OBJEXT): {$(VPATH)}atomic.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-miniinit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-miniinit.$(OBJEXT): {$(VPATH)}builtin.h
-miniinit.$(OBJEXT): {$(VPATH)}config.h
-miniinit.$(OBJEXT): {$(VPATH)}constant.h
-miniinit.$(OBJEXT): {$(VPATH)}defines.h
-miniinit.$(OBJEXT): {$(VPATH)}dir.rb
-miniinit.$(OBJEXT): {$(VPATH)}encoding.h
-miniinit.$(OBJEXT): {$(VPATH)}gc.rb
-miniinit.$(OBJEXT): {$(VPATH)}gem_prelude.rb
-miniinit.$(OBJEXT): {$(VPATH)}id.h
-miniinit.$(OBJEXT): {$(VPATH)}id_table.h
-miniinit.$(OBJEXT): {$(VPATH)}intern.h
-miniinit.$(OBJEXT): {$(VPATH)}internal.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/abi.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/assume.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/cast.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/config.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/ctype.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/dosish.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/error.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/eval.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/event.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/gc.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/glob.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/globals.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/iterator.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/memory.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/method.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/module.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/symbol.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/value.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/value_type.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/variable.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-miniinit.$(OBJEXT): {$(VPATH)}io.rb
-miniinit.$(OBJEXT): {$(VPATH)}iseq.h
-miniinit.$(OBJEXT): {$(VPATH)}kernel.rb
-miniinit.$(OBJEXT): {$(VPATH)}marshal.rb
-miniinit.$(OBJEXT): {$(VPATH)}method.h
-miniinit.$(OBJEXT): {$(VPATH)}mini_builtin.c
-miniinit.$(OBJEXT): {$(VPATH)}miniinit.c
-miniinit.$(OBJEXT): {$(VPATH)}miniprelude.c
-miniinit.$(OBJEXT): {$(VPATH)}missing.h
-miniinit.$(OBJEXT): {$(VPATH)}nilclass.rb
-miniinit.$(OBJEXT): {$(VPATH)}node.h
-miniinit.$(OBJEXT): {$(VPATH)}numeric.rb
-miniinit.$(OBJEXT): {$(VPATH)}onigmo.h
-miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h
-miniinit.$(OBJEXT): {$(VPATH)}pack.rb
-miniinit.$(OBJEXT): {$(VPATH)}prelude.rb
-miniinit.$(OBJEXT): {$(VPATH)}ractor.rb
-miniinit.$(OBJEXT): {$(VPATH)}rjit.rb
-miniinit.$(OBJEXT): {$(VPATH)}rjit_c.rb
-miniinit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-miniinit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-miniinit.$(OBJEXT): {$(VPATH)}shape.h
-miniinit.$(OBJEXT): {$(VPATH)}st.h
-miniinit.$(OBJEXT): {$(VPATH)}subst.h
-miniinit.$(OBJEXT): {$(VPATH)}symbol.rb
-miniinit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-miniinit.$(OBJEXT): {$(VPATH)}thread_native.h
-miniinit.$(OBJEXT): {$(VPATH)}thread_sync.rb
-miniinit.$(OBJEXT): {$(VPATH)}timev.rb
-miniinit.$(OBJEXT): {$(VPATH)}trace_point.rb
-miniinit.$(OBJEXT): {$(VPATH)}vm_core.h
-miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
-miniinit.$(OBJEXT): {$(VPATH)}warning.rb
-miniinit.$(OBJEXT): {$(VPATH)}yjit.rb
-node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-node.$(OBJEXT): $(CCAN_DIR)/list/list.h
-node.$(OBJEXT): $(CCAN_DIR)/str/str.h
-node.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-node.$(OBJEXT): $(top_srcdir)/internal/array.h
-node.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-node.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-node.$(OBJEXT): $(top_srcdir)/internal/gc.h
-node.$(OBJEXT): $(top_srcdir)/internal/hash.h
-node.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-node.$(OBJEXT): $(top_srcdir)/internal/serial.h
-node.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-node.$(OBJEXT): $(top_srcdir)/internal/variable.h
-node.$(OBJEXT): $(top_srcdir)/internal/vm.h
-node.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-node.$(OBJEXT): {$(VPATH)}assert.h
-node.$(OBJEXT): {$(VPATH)}atomic.h
-node.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-node.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-node.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-node.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-node.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-node.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-node.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-node.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-node.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-node.$(OBJEXT): {$(VPATH)}config.h
-node.$(OBJEXT): {$(VPATH)}constant.h
-node.$(OBJEXT): {$(VPATH)}defines.h
-node.$(OBJEXT): {$(VPATH)}id.h
-node.$(OBJEXT): {$(VPATH)}id_table.h
-node.$(OBJEXT): {$(VPATH)}intern.h
-node.$(OBJEXT): {$(VPATH)}internal.h
-node.$(OBJEXT): {$(VPATH)}internal/abi.h
-node.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-node.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-node.$(OBJEXT): {$(VPATH)}internal/assume.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-node.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-node.$(OBJEXT): {$(VPATH)}internal/cast.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-node.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-node.$(OBJEXT): {$(VPATH)}internal/config.h
-node.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-node.$(OBJEXT): {$(VPATH)}internal/core.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-node.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-node.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-node.$(OBJEXT): {$(VPATH)}internal/ctype.h
-node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-node.$(OBJEXT): {$(VPATH)}internal/dosish.h
-node.$(OBJEXT): {$(VPATH)}internal/error.h
-node.$(OBJEXT): {$(VPATH)}internal/eval.h
-node.$(OBJEXT): {$(VPATH)}internal/event.h
-node.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-node.$(OBJEXT): {$(VPATH)}internal/gc.h
-node.$(OBJEXT): {$(VPATH)}internal/glob.h
-node.$(OBJEXT): {$(VPATH)}internal/globals.h
-node.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-node.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-node.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-node.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-node.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-node.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-node.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-node.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-node.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-node.$(OBJEXT): {$(VPATH)}internal/iterator.h
-node.$(OBJEXT): {$(VPATH)}internal/memory.h
-node.$(OBJEXT): {$(VPATH)}internal/method.h
-node.$(OBJEXT): {$(VPATH)}internal/module.h
-node.$(OBJEXT): {$(VPATH)}internal/newobj.h
-node.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-node.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-node.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-node.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-node.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-node.$(OBJEXT): {$(VPATH)}internal/symbol.h
-node.$(OBJEXT): {$(VPATH)}internal/value.h
-node.$(OBJEXT): {$(VPATH)}internal/value_type.h
-node.$(OBJEXT): {$(VPATH)}internal/variable.h
-node.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-node.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-node.$(OBJEXT): {$(VPATH)}method.h
-node.$(OBJEXT): {$(VPATH)}missing.h
-node.$(OBJEXT): {$(VPATH)}node.c
-node.$(OBJEXT): {$(VPATH)}node.h
-node.$(OBJEXT): {$(VPATH)}ruby_assert.h
-node.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-node.$(OBJEXT): {$(VPATH)}shape.h
-node.$(OBJEXT): {$(VPATH)}st.h
-node.$(OBJEXT): {$(VPATH)}subst.h
-node.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-node.$(OBJEXT): {$(VPATH)}thread_native.h
-node.$(OBJEXT): {$(VPATH)}vm_core.h
-node.$(OBJEXT): {$(VPATH)}vm_opts.h
-numeric.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/array.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/bits.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/class.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/complex.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/gc.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/hash.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/object.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/rational.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/serial.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/string.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/util.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/variable.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/vm.h
-numeric.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-numeric.$(OBJEXT): {$(VPATH)}assert.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-numeric.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-numeric.$(OBJEXT): {$(VPATH)}builtin.h
-numeric.$(OBJEXT): {$(VPATH)}config.h
-numeric.$(OBJEXT): {$(VPATH)}constant.h
-numeric.$(OBJEXT): {$(VPATH)}defines.h
-numeric.$(OBJEXT): {$(VPATH)}encoding.h
-numeric.$(OBJEXT): {$(VPATH)}id.h
-numeric.$(OBJEXT): {$(VPATH)}id_table.h
-numeric.$(OBJEXT): {$(VPATH)}intern.h
-numeric.$(OBJEXT): {$(VPATH)}internal.h
-numeric.$(OBJEXT): {$(VPATH)}internal/abi.h
-numeric.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-numeric.$(OBJEXT): {$(VPATH)}internal/assume.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-numeric.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-numeric.$(OBJEXT): {$(VPATH)}internal/cast.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-numeric.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-numeric.$(OBJEXT): {$(VPATH)}internal/config.h
-numeric.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-numeric.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-numeric.$(OBJEXT): {$(VPATH)}internal/ctype.h
-numeric.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-numeric.$(OBJEXT): {$(VPATH)}internal/dosish.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-numeric.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-numeric.$(OBJEXT): {$(VPATH)}internal/error.h
-numeric.$(OBJEXT): {$(VPATH)}internal/eval.h
-numeric.$(OBJEXT): {$(VPATH)}internal/event.h
-numeric.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-numeric.$(OBJEXT): {$(VPATH)}internal/gc.h
-numeric.$(OBJEXT): {$(VPATH)}internal/glob.h
-numeric.$(OBJEXT): {$(VPATH)}internal/globals.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-numeric.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-numeric.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-numeric.$(OBJEXT): {$(VPATH)}internal/iterator.h
-numeric.$(OBJEXT): {$(VPATH)}internal/memory.h
-numeric.$(OBJEXT): {$(VPATH)}internal/method.h
-numeric.$(OBJEXT): {$(VPATH)}internal/module.h
-numeric.$(OBJEXT): {$(VPATH)}internal/newobj.h
-numeric.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-numeric.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-numeric.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-numeric.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-numeric.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-numeric.$(OBJEXT): {$(VPATH)}internal/symbol.h
-numeric.$(OBJEXT): {$(VPATH)}internal/value.h
-numeric.$(OBJEXT): {$(VPATH)}internal/value_type.h
-numeric.$(OBJEXT): {$(VPATH)}internal/variable.h
-numeric.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-numeric.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-numeric.$(OBJEXT): {$(VPATH)}missing.h
-numeric.$(OBJEXT): {$(VPATH)}numeric.c
-numeric.$(OBJEXT): {$(VPATH)}numeric.rbinc
-numeric.$(OBJEXT): {$(VPATH)}onigmo.h
-numeric.$(OBJEXT): {$(VPATH)}oniguruma.h
-numeric.$(OBJEXT): {$(VPATH)}ruby_assert.h
-numeric.$(OBJEXT): {$(VPATH)}shape.h
-numeric.$(OBJEXT): {$(VPATH)}st.h
-numeric.$(OBJEXT): {$(VPATH)}subst.h
-numeric.$(OBJEXT): {$(VPATH)}util.h
-object.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-object.$(OBJEXT): $(top_srcdir)/internal/array.h
-object.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-object.$(OBJEXT): $(top_srcdir)/internal/bits.h
-object.$(OBJEXT): $(top_srcdir)/internal/class.h
-object.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-object.$(OBJEXT): $(top_srcdir)/internal/error.h
-object.$(OBJEXT): $(top_srcdir)/internal/eval.h
-object.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-object.$(OBJEXT): $(top_srcdir)/internal/gc.h
-object.$(OBJEXT): $(top_srcdir)/internal/inits.h
-object.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-object.$(OBJEXT): $(top_srcdir)/internal/object.h
-object.$(OBJEXT): $(top_srcdir)/internal/serial.h
-object.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-object.$(OBJEXT): $(top_srcdir)/internal/string.h
-object.$(OBJEXT): $(top_srcdir)/internal/struct.h
-object.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-object.$(OBJEXT): $(top_srcdir)/internal/variable.h
-object.$(OBJEXT): $(top_srcdir)/internal/vm.h
-object.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-object.$(OBJEXT): {$(VPATH)}assert.h
-object.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-object.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-object.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-object.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-object.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-object.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-object.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-object.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-object.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-object.$(OBJEXT): {$(VPATH)}builtin.h
-object.$(OBJEXT): {$(VPATH)}config.h
-object.$(OBJEXT): {$(VPATH)}constant.h
-object.$(OBJEXT): {$(VPATH)}defines.h
-object.$(OBJEXT): {$(VPATH)}encoding.h
-object.$(OBJEXT): {$(VPATH)}id.h
-object.$(OBJEXT): {$(VPATH)}id_table.h
-object.$(OBJEXT): {$(VPATH)}intern.h
-object.$(OBJEXT): {$(VPATH)}internal.h
-object.$(OBJEXT): {$(VPATH)}internal/abi.h
-object.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-object.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-object.$(OBJEXT): {$(VPATH)}internal/assume.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-object.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-object.$(OBJEXT): {$(VPATH)}internal/cast.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-object.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-object.$(OBJEXT): {$(VPATH)}internal/config.h
-object.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-object.$(OBJEXT): {$(VPATH)}internal/core.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-object.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-object.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-object.$(OBJEXT): {$(VPATH)}internal/ctype.h
-object.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-object.$(OBJEXT): {$(VPATH)}internal/dosish.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-object.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-object.$(OBJEXT): {$(VPATH)}internal/error.h
-object.$(OBJEXT): {$(VPATH)}internal/eval.h
-object.$(OBJEXT): {$(VPATH)}internal/event.h
-object.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-object.$(OBJEXT): {$(VPATH)}internal/gc.h
-object.$(OBJEXT): {$(VPATH)}internal/glob.h
-object.$(OBJEXT): {$(VPATH)}internal/globals.h
-object.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-object.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-object.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-object.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-object.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-object.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-object.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-object.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-object.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-object.$(OBJEXT): {$(VPATH)}internal/iterator.h
-object.$(OBJEXT): {$(VPATH)}internal/memory.h
-object.$(OBJEXT): {$(VPATH)}internal/method.h
-object.$(OBJEXT): {$(VPATH)}internal/module.h
-object.$(OBJEXT): {$(VPATH)}internal/newobj.h
-object.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-object.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-object.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-object.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-object.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-object.$(OBJEXT): {$(VPATH)}internal/symbol.h
-object.$(OBJEXT): {$(VPATH)}internal/value.h
-object.$(OBJEXT): {$(VPATH)}internal/value_type.h
-object.$(OBJEXT): {$(VPATH)}internal/variable.h
-object.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-object.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-object.$(OBJEXT): {$(VPATH)}kernel.rbinc
-object.$(OBJEXT): {$(VPATH)}missing.h
-object.$(OBJEXT): {$(VPATH)}nilclass.rbinc
-object.$(OBJEXT): {$(VPATH)}object.c
-object.$(OBJEXT): {$(VPATH)}onigmo.h
-object.$(OBJEXT): {$(VPATH)}oniguruma.h
-object.$(OBJEXT): {$(VPATH)}probes.dmyh
-object.$(OBJEXT): {$(VPATH)}probes.h
-object.$(OBJEXT): {$(VPATH)}shape.h
-object.$(OBJEXT): {$(VPATH)}st.h
-object.$(OBJEXT): {$(VPATH)}subst.h
-object.$(OBJEXT): {$(VPATH)}util.h
-object.$(OBJEXT): {$(VPATH)}variable.h
-pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-pack.$(OBJEXT): $(top_srcdir)/internal/array.h
-pack.$(OBJEXT): $(top_srcdir)/internal/bits.h
-pack.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-pack.$(OBJEXT): $(top_srcdir)/internal/gc.h
-pack.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-pack.$(OBJEXT): $(top_srcdir)/internal/string.h
-pack.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-pack.$(OBJEXT): $(top_srcdir)/internal/variable.h
-pack.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-pack.$(OBJEXT): {$(VPATH)}assert.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-pack.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-pack.$(OBJEXT): {$(VPATH)}builtin.h
-pack.$(OBJEXT): {$(VPATH)}config.h
-pack.$(OBJEXT): {$(VPATH)}constant.h
-pack.$(OBJEXT): {$(VPATH)}defines.h
-pack.$(OBJEXT): {$(VPATH)}encoding.h
-pack.$(OBJEXT): {$(VPATH)}id_table.h
-pack.$(OBJEXT): {$(VPATH)}intern.h
-pack.$(OBJEXT): {$(VPATH)}internal.h
-pack.$(OBJEXT): {$(VPATH)}internal/abi.h
-pack.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-pack.$(OBJEXT): {$(VPATH)}internal/assume.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-pack.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-pack.$(OBJEXT): {$(VPATH)}internal/cast.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-pack.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-pack.$(OBJEXT): {$(VPATH)}internal/config.h
-pack.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-pack.$(OBJEXT): {$(VPATH)}internal/core.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-pack.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-pack.$(OBJEXT): {$(VPATH)}internal/ctype.h
-pack.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-pack.$(OBJEXT): {$(VPATH)}internal/dosish.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-pack.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-pack.$(OBJEXT): {$(VPATH)}internal/error.h
-pack.$(OBJEXT): {$(VPATH)}internal/eval.h
-pack.$(OBJEXT): {$(VPATH)}internal/event.h
-pack.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-pack.$(OBJEXT): {$(VPATH)}internal/gc.h
-pack.$(OBJEXT): {$(VPATH)}internal/glob.h
-pack.$(OBJEXT): {$(VPATH)}internal/globals.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-pack.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-pack.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-pack.$(OBJEXT): {$(VPATH)}internal/iterator.h
-pack.$(OBJEXT): {$(VPATH)}internal/memory.h
-pack.$(OBJEXT): {$(VPATH)}internal/method.h
-pack.$(OBJEXT): {$(VPATH)}internal/module.h
-pack.$(OBJEXT): {$(VPATH)}internal/newobj.h
-pack.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-pack.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-pack.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-pack.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-pack.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-pack.$(OBJEXT): {$(VPATH)}internal/symbol.h
-pack.$(OBJEXT): {$(VPATH)}internal/value.h
-pack.$(OBJEXT): {$(VPATH)}internal/value_type.h
-pack.$(OBJEXT): {$(VPATH)}internal/variable.h
-pack.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-pack.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-pack.$(OBJEXT): {$(VPATH)}missing.h
-pack.$(OBJEXT): {$(VPATH)}onigmo.h
-pack.$(OBJEXT): {$(VPATH)}oniguruma.h
-pack.$(OBJEXT): {$(VPATH)}pack.c
-pack.$(OBJEXT): {$(VPATH)}pack.rbinc
-pack.$(OBJEXT): {$(VPATH)}shape.h
-pack.$(OBJEXT): {$(VPATH)}st.h
-pack.$(OBJEXT): {$(VPATH)}subst.h
-pack.$(OBJEXT): {$(VPATH)}util.h
-parse.$(OBJEXT): $(hdrdir)/ruby.h
-parse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-parse.$(OBJEXT): $(top_srcdir)/internal/array.h
-parse.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-parse.$(OBJEXT): $(top_srcdir)/internal/bits.h
-parse.$(OBJEXT): $(top_srcdir)/internal/compile.h
-parse.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-parse.$(OBJEXT): $(top_srcdir)/internal/complex.h
-parse.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-parse.$(OBJEXT): $(top_srcdir)/internal/error.h
-parse.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-parse.$(OBJEXT): $(top_srcdir)/internal/gc.h
-parse.$(OBJEXT): $(top_srcdir)/internal/hash.h
-parse.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-parse.$(OBJEXT): $(top_srcdir)/internal/io.h
-parse.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-parse.$(OBJEXT): $(top_srcdir)/internal/parse.h
-parse.$(OBJEXT): $(top_srcdir)/internal/rational.h
-parse.$(OBJEXT): $(top_srcdir)/internal/re.h
-parse.$(OBJEXT): $(top_srcdir)/internal/serial.h
-parse.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-parse.$(OBJEXT): $(top_srcdir)/internal/string.h
-parse.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-parse.$(OBJEXT): $(top_srcdir)/internal/thread.h
-parse.$(OBJEXT): $(top_srcdir)/internal/variable.h
-parse.$(OBJEXT): $(top_srcdir)/internal/vm.h
-parse.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-parse.$(OBJEXT): {$(VPATH)}assert.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-parse.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-parse.$(OBJEXT): {$(VPATH)}config.h
-parse.$(OBJEXT): {$(VPATH)}constant.h
-parse.$(OBJEXT): {$(VPATH)}defines.h
-parse.$(OBJEXT): {$(VPATH)}defs/keywords
-parse.$(OBJEXT): {$(VPATH)}encoding.h
-parse.$(OBJEXT): {$(VPATH)}id.h
-parse.$(OBJEXT): {$(VPATH)}id_table.h
-parse.$(OBJEXT): {$(VPATH)}intern.h
-parse.$(OBJEXT): {$(VPATH)}internal.h
-parse.$(OBJEXT): {$(VPATH)}internal/abi.h
-parse.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-parse.$(OBJEXT): {$(VPATH)}internal/assume.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-parse.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-parse.$(OBJEXT): {$(VPATH)}internal/cast.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-parse.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-parse.$(OBJEXT): {$(VPATH)}internal/config.h
-parse.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-parse.$(OBJEXT): {$(VPATH)}internal/core.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-parse.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-parse.$(OBJEXT): {$(VPATH)}internal/ctype.h
-parse.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-parse.$(OBJEXT): {$(VPATH)}internal/dosish.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-parse.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-parse.$(OBJEXT): {$(VPATH)}internal/error.h
-parse.$(OBJEXT): {$(VPATH)}internal/eval.h
-parse.$(OBJEXT): {$(VPATH)}internal/event.h
-parse.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-parse.$(OBJEXT): {$(VPATH)}internal/gc.h
-parse.$(OBJEXT): {$(VPATH)}internal/glob.h
-parse.$(OBJEXT): {$(VPATH)}internal/globals.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-parse.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-parse.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-parse.$(OBJEXT): {$(VPATH)}internal/iterator.h
-parse.$(OBJEXT): {$(VPATH)}internal/memory.h
-parse.$(OBJEXT): {$(VPATH)}internal/method.h
-parse.$(OBJEXT): {$(VPATH)}internal/module.h
-parse.$(OBJEXT): {$(VPATH)}internal/newobj.h
-parse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-parse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-parse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-parse.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-parse.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-parse.$(OBJEXT): {$(VPATH)}internal/symbol.h
-parse.$(OBJEXT): {$(VPATH)}internal/value.h
-parse.$(OBJEXT): {$(VPATH)}internal/value_type.h
-parse.$(OBJEXT): {$(VPATH)}internal/variable.h
-parse.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-parse.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-parse.$(OBJEXT): {$(VPATH)}io.h
-parse.$(OBJEXT): {$(VPATH)}lex.c
-parse.$(OBJEXT): {$(VPATH)}missing.h
-parse.$(OBJEXT): {$(VPATH)}node.h
-parse.$(OBJEXT): {$(VPATH)}onigmo.h
-parse.$(OBJEXT): {$(VPATH)}oniguruma.h
-parse.$(OBJEXT): {$(VPATH)}parse.c
-parse.$(OBJEXT): {$(VPATH)}parse.h
-parse.$(OBJEXT): {$(VPATH)}parse.y
-parse.$(OBJEXT): {$(VPATH)}probes.dmyh
-parse.$(OBJEXT): {$(VPATH)}probes.h
-parse.$(OBJEXT): {$(VPATH)}ractor.h
-parse.$(OBJEXT): {$(VPATH)}regenc.h
-parse.$(OBJEXT): {$(VPATH)}regex.h
-parse.$(OBJEXT): {$(VPATH)}ruby_assert.h
-parse.$(OBJEXT): {$(VPATH)}shape.h
-parse.$(OBJEXT): {$(VPATH)}st.h
-parse.$(OBJEXT): {$(VPATH)}subst.h
-parse.$(OBJEXT): {$(VPATH)}symbol.h
-parse.$(OBJEXT): {$(VPATH)}util.h
-proc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-proc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-proc.$(OBJEXT): $(CCAN_DIR)/list/list.h
-proc.$(OBJEXT): $(CCAN_DIR)/str/str.h
-proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-proc.$(OBJEXT): $(top_srcdir)/internal/array.h
-proc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-proc.$(OBJEXT): $(top_srcdir)/internal/class.h
-proc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-proc.$(OBJEXT): $(top_srcdir)/internal/error.h
-proc.$(OBJEXT): $(top_srcdir)/internal/eval.h
-proc.$(OBJEXT): $(top_srcdir)/internal/gc.h
-proc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-proc.$(OBJEXT): $(top_srcdir)/internal/object.h
-proc.$(OBJEXT): $(top_srcdir)/internal/proc.h
-proc.$(OBJEXT): $(top_srcdir)/internal/serial.h
-proc.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-proc.$(OBJEXT): $(top_srcdir)/internal/string.h
-proc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-proc.$(OBJEXT): $(top_srcdir)/internal/variable.h
-proc.$(OBJEXT): $(top_srcdir)/internal/vm.h
-proc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-proc.$(OBJEXT): {$(VPATH)}assert.h
-proc.$(OBJEXT): {$(VPATH)}atomic.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-proc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-proc.$(OBJEXT): {$(VPATH)}config.h
-proc.$(OBJEXT): {$(VPATH)}constant.h
-proc.$(OBJEXT): {$(VPATH)}defines.h
-proc.$(OBJEXT): {$(VPATH)}encoding.h
-proc.$(OBJEXT): {$(VPATH)}eval_intern.h
-proc.$(OBJEXT): {$(VPATH)}id.h
-proc.$(OBJEXT): {$(VPATH)}id_table.h
-proc.$(OBJEXT): {$(VPATH)}intern.h
-proc.$(OBJEXT): {$(VPATH)}internal.h
-proc.$(OBJEXT): {$(VPATH)}internal/abi.h
-proc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-proc.$(OBJEXT): {$(VPATH)}internal/assume.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-proc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-proc.$(OBJEXT): {$(VPATH)}internal/cast.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-proc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-proc.$(OBJEXT): {$(VPATH)}internal/config.h
-proc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-proc.$(OBJEXT): {$(VPATH)}internal/core.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-proc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-proc.$(OBJEXT): {$(VPATH)}internal/ctype.h
-proc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-proc.$(OBJEXT): {$(VPATH)}internal/dosish.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-proc.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-proc.$(OBJEXT): {$(VPATH)}internal/error.h
-proc.$(OBJEXT): {$(VPATH)}internal/eval.h
-proc.$(OBJEXT): {$(VPATH)}internal/event.h
-proc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-proc.$(OBJEXT): {$(VPATH)}internal/gc.h
-proc.$(OBJEXT): {$(VPATH)}internal/glob.h
-proc.$(OBJEXT): {$(VPATH)}internal/globals.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-proc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-proc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-proc.$(OBJEXT): {$(VPATH)}internal/iterator.h
-proc.$(OBJEXT): {$(VPATH)}internal/memory.h
-proc.$(OBJEXT): {$(VPATH)}internal/method.h
-proc.$(OBJEXT): {$(VPATH)}internal/module.h
-proc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-proc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-proc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-proc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-proc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-proc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-proc.$(OBJEXT): {$(VPATH)}internal/symbol.h
-proc.$(OBJEXT): {$(VPATH)}internal/value.h
-proc.$(OBJEXT): {$(VPATH)}internal/value_type.h
-proc.$(OBJEXT): {$(VPATH)}internal/variable.h
-proc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-proc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-proc.$(OBJEXT): {$(VPATH)}iseq.h
-proc.$(OBJEXT): {$(VPATH)}method.h
-proc.$(OBJEXT): {$(VPATH)}missing.h
-proc.$(OBJEXT): {$(VPATH)}node.h
-proc.$(OBJEXT): {$(VPATH)}onigmo.h
-proc.$(OBJEXT): {$(VPATH)}oniguruma.h
-proc.$(OBJEXT): {$(VPATH)}proc.c
-proc.$(OBJEXT): {$(VPATH)}ruby_assert.h
-proc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-proc.$(OBJEXT): {$(VPATH)}shape.h
-proc.$(OBJEXT): {$(VPATH)}st.h
-proc.$(OBJEXT): {$(VPATH)}subst.h
-proc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-proc.$(OBJEXT): {$(VPATH)}thread_native.h
-proc.$(OBJEXT): {$(VPATH)}vm_core.h
-proc.$(OBJEXT): {$(VPATH)}vm_opts.h
-proc.$(OBJEXT): {$(VPATH)}yjit.h
-process.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-process.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-process.$(OBJEXT): $(CCAN_DIR)/list/list.h
-process.$(OBJEXT): $(CCAN_DIR)/str/str.h
-process.$(OBJEXT): $(hdrdir)/ruby.h
-process.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-process.$(OBJEXT): $(top_srcdir)/internal/array.h
-process.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-process.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-process.$(OBJEXT): $(top_srcdir)/internal/bits.h
-process.$(OBJEXT): $(top_srcdir)/internal/class.h
-process.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-process.$(OBJEXT): $(top_srcdir)/internal/dir.h
-process.$(OBJEXT): $(top_srcdir)/internal/error.h
-process.$(OBJEXT): $(top_srcdir)/internal/eval.h
-process.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-process.$(OBJEXT): $(top_srcdir)/internal/gc.h
-process.$(OBJEXT): $(top_srcdir)/internal/hash.h
-process.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-process.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-process.$(OBJEXT): $(top_srcdir)/internal/object.h
-process.$(OBJEXT): $(top_srcdir)/internal/process.h
-process.$(OBJEXT): $(top_srcdir)/internal/serial.h
-process.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-process.$(OBJEXT): $(top_srcdir)/internal/string.h
-process.$(OBJEXT): $(top_srcdir)/internal/thread.h
-process.$(OBJEXT): $(top_srcdir)/internal/time.h
-process.$(OBJEXT): $(top_srcdir)/internal/variable.h
-process.$(OBJEXT): $(top_srcdir)/internal/vm.h
-process.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-process.$(OBJEXT): {$(VPATH)}assert.h
-process.$(OBJEXT): {$(VPATH)}atomic.h
-process.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-process.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-process.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-process.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-process.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-process.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-process.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-process.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-process.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-process.$(OBJEXT): {$(VPATH)}config.h
-process.$(OBJEXT): {$(VPATH)}constant.h
-process.$(OBJEXT): {$(VPATH)}debug_counter.h
-process.$(OBJEXT): {$(VPATH)}defines.h
-process.$(OBJEXT): {$(VPATH)}dln.h
-process.$(OBJEXT): {$(VPATH)}encoding.h
-process.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-process.$(OBJEXT): {$(VPATH)}hrtime.h
-process.$(OBJEXT): {$(VPATH)}id.h
-process.$(OBJEXT): {$(VPATH)}id_table.h
-process.$(OBJEXT): {$(VPATH)}intern.h
-process.$(OBJEXT): {$(VPATH)}internal.h
-process.$(OBJEXT): {$(VPATH)}internal/abi.h
-process.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-process.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-process.$(OBJEXT): {$(VPATH)}internal/assume.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-process.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-process.$(OBJEXT): {$(VPATH)}internal/cast.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-process.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-process.$(OBJEXT): {$(VPATH)}internal/config.h
-process.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-process.$(OBJEXT): {$(VPATH)}internal/core.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-process.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-process.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-process.$(OBJEXT): {$(VPATH)}internal/ctype.h
-process.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-process.$(OBJEXT): {$(VPATH)}internal/dosish.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-process.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-process.$(OBJEXT): {$(VPATH)}internal/error.h
-process.$(OBJEXT): {$(VPATH)}internal/eval.h
-process.$(OBJEXT): {$(VPATH)}internal/event.h
-process.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-process.$(OBJEXT): {$(VPATH)}internal/gc.h
-process.$(OBJEXT): {$(VPATH)}internal/glob.h
-process.$(OBJEXT): {$(VPATH)}internal/globals.h
-process.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-process.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-process.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-process.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-process.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-process.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-process.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-process.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-process.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-process.$(OBJEXT): {$(VPATH)}internal/iterator.h
-process.$(OBJEXT): {$(VPATH)}internal/memory.h
-process.$(OBJEXT): {$(VPATH)}internal/method.h
-process.$(OBJEXT): {$(VPATH)}internal/module.h
-process.$(OBJEXT): {$(VPATH)}internal/newobj.h
-process.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-process.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-process.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-process.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-process.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-process.$(OBJEXT): {$(VPATH)}internal/symbol.h
-process.$(OBJEXT): {$(VPATH)}internal/value.h
-process.$(OBJEXT): {$(VPATH)}internal/value_type.h
-process.$(OBJEXT): {$(VPATH)}internal/variable.h
-process.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-process.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-process.$(OBJEXT): {$(VPATH)}io.h
-process.$(OBJEXT): {$(VPATH)}method.h
-process.$(OBJEXT): {$(VPATH)}missing.h
-process.$(OBJEXT): {$(VPATH)}node.h
-process.$(OBJEXT): {$(VPATH)}onigmo.h
-process.$(OBJEXT): {$(VPATH)}oniguruma.h
-process.$(OBJEXT): {$(VPATH)}process.c
-process.$(OBJEXT): {$(VPATH)}ractor.h
-process.$(OBJEXT): {$(VPATH)}rjit.h
-process.$(OBJEXT): {$(VPATH)}ruby_assert.h
-process.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-process.$(OBJEXT): {$(VPATH)}shape.h
-process.$(OBJEXT): {$(VPATH)}st.h
-process.$(OBJEXT): {$(VPATH)}subst.h
-process.$(OBJEXT): {$(VPATH)}thread.h
-process.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-process.$(OBJEXT): {$(VPATH)}thread_native.h
-process.$(OBJEXT): {$(VPATH)}util.h
-process.$(OBJEXT): {$(VPATH)}vm_core.h
-process.$(OBJEXT): {$(VPATH)}vm_opts.h
-ractor.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-ractor.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-ractor.$(OBJEXT): $(CCAN_DIR)/list/list.h
-ractor.$(OBJEXT): $(CCAN_DIR)/str/str.h
-ractor.$(OBJEXT): $(hdrdir)/ruby.h
-ractor.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/array.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/bits.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/complex.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/error.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/gc.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/hash.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/rational.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/serial.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/string.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/struct.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/thread.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/variable.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/vm.h
-ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-ractor.$(OBJEXT): {$(VPATH)}assert.h
-ractor.$(OBJEXT): {$(VPATH)}atomic.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-ractor.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-ractor.$(OBJEXT): {$(VPATH)}builtin.h
-ractor.$(OBJEXT): {$(VPATH)}config.h
-ractor.$(OBJEXT): {$(VPATH)}constant.h
-ractor.$(OBJEXT): {$(VPATH)}debug_counter.h
-ractor.$(OBJEXT): {$(VPATH)}defines.h
-ractor.$(OBJEXT): {$(VPATH)}encoding.h
-ractor.$(OBJEXT): {$(VPATH)}eval_intern.h
-ractor.$(OBJEXT): {$(VPATH)}id.h
-ractor.$(OBJEXT): {$(VPATH)}id_table.h
-ractor.$(OBJEXT): {$(VPATH)}intern.h
-ractor.$(OBJEXT): {$(VPATH)}internal.h
-ractor.$(OBJEXT): {$(VPATH)}internal/abi.h
-ractor.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-ractor.$(OBJEXT): {$(VPATH)}internal/assume.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-ractor.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-ractor.$(OBJEXT): {$(VPATH)}internal/cast.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-ractor.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-ractor.$(OBJEXT): {$(VPATH)}internal/config.h
-ractor.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-ractor.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-ractor.$(OBJEXT): {$(VPATH)}internal/ctype.h
-ractor.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-ractor.$(OBJEXT): {$(VPATH)}internal/dosish.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-ractor.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-ractor.$(OBJEXT): {$(VPATH)}internal/error.h
-ractor.$(OBJEXT): {$(VPATH)}internal/eval.h
-ractor.$(OBJEXT): {$(VPATH)}internal/event.h
-ractor.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-ractor.$(OBJEXT): {$(VPATH)}internal/gc.h
-ractor.$(OBJEXT): {$(VPATH)}internal/glob.h
-ractor.$(OBJEXT): {$(VPATH)}internal/globals.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-ractor.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-ractor.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-ractor.$(OBJEXT): {$(VPATH)}internal/iterator.h
-ractor.$(OBJEXT): {$(VPATH)}internal/memory.h
-ractor.$(OBJEXT): {$(VPATH)}internal/method.h
-ractor.$(OBJEXT): {$(VPATH)}internal/module.h
-ractor.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ractor.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-ractor.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-ractor.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-ractor.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-ractor.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-ractor.$(OBJEXT): {$(VPATH)}internal/symbol.h
-ractor.$(OBJEXT): {$(VPATH)}internal/value.h
-ractor.$(OBJEXT): {$(VPATH)}internal/value_type.h
-ractor.$(OBJEXT): {$(VPATH)}internal/variable.h
-ractor.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-ractor.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-ractor.$(OBJEXT): {$(VPATH)}method.h
-ractor.$(OBJEXT): {$(VPATH)}missing.h
-ractor.$(OBJEXT): {$(VPATH)}node.h
-ractor.$(OBJEXT): {$(VPATH)}onigmo.h
-ractor.$(OBJEXT): {$(VPATH)}oniguruma.h
-ractor.$(OBJEXT): {$(VPATH)}ractor.c
-ractor.$(OBJEXT): {$(VPATH)}ractor.h
-ractor.$(OBJEXT): {$(VPATH)}ractor.rbinc
-ractor.$(OBJEXT): {$(VPATH)}ractor_core.h
-ractor.$(OBJEXT): {$(VPATH)}rjit.h
-ractor.$(OBJEXT): {$(VPATH)}ruby_assert.h
-ractor.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-ractor.$(OBJEXT): {$(VPATH)}shape.h
-ractor.$(OBJEXT): {$(VPATH)}st.h
-ractor.$(OBJEXT): {$(VPATH)}subst.h
-ractor.$(OBJEXT): {$(VPATH)}thread.h
-ractor.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-ractor.$(OBJEXT): {$(VPATH)}thread_native.h
-ractor.$(OBJEXT): {$(VPATH)}transient_heap.h
-ractor.$(OBJEXT): {$(VPATH)}variable.h
-ractor.$(OBJEXT): {$(VPATH)}vm_core.h
-ractor.$(OBJEXT): {$(VPATH)}vm_debug.h
-ractor.$(OBJEXT): {$(VPATH)}vm_opts.h
-ractor.$(OBJEXT): {$(VPATH)}vm_sync.h
-ractor.$(OBJEXT): {$(VPATH)}yjit.h
-random.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-random.$(OBJEXT): $(top_srcdir)/internal/array.h
-random.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-random.$(OBJEXT): $(top_srcdir)/internal/bits.h
-random.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-random.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-random.$(OBJEXT): $(top_srcdir)/internal/gc.h
-random.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-random.$(OBJEXT): $(top_srcdir)/internal/random.h
-random.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-random.$(OBJEXT): $(top_srcdir)/internal/serial.h
-random.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-random.$(OBJEXT): $(top_srcdir)/internal/variable.h
-random.$(OBJEXT): $(top_srcdir)/internal/vm.h
-random.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-random.$(OBJEXT): {$(VPATH)}assert.h
-random.$(OBJEXT): {$(VPATH)}atomic.h
-random.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-random.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-random.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-random.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-random.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-random.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-random.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-random.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-random.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-random.$(OBJEXT): {$(VPATH)}config.h
-random.$(OBJEXT): {$(VPATH)}constant.h
-random.$(OBJEXT): {$(VPATH)}defines.h
-random.$(OBJEXT): {$(VPATH)}id_table.h
-random.$(OBJEXT): {$(VPATH)}intern.h
-random.$(OBJEXT): {$(VPATH)}internal.h
-random.$(OBJEXT): {$(VPATH)}internal/abi.h
-random.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-random.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-random.$(OBJEXT): {$(VPATH)}internal/assume.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-random.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-random.$(OBJEXT): {$(VPATH)}internal/cast.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-random.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-random.$(OBJEXT): {$(VPATH)}internal/config.h
-random.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-random.$(OBJEXT): {$(VPATH)}internal/core.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-random.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-random.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-random.$(OBJEXT): {$(VPATH)}internal/ctype.h
-random.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-random.$(OBJEXT): {$(VPATH)}internal/dosish.h
-random.$(OBJEXT): {$(VPATH)}internal/error.h
-random.$(OBJEXT): {$(VPATH)}internal/eval.h
-random.$(OBJEXT): {$(VPATH)}internal/event.h
-random.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-random.$(OBJEXT): {$(VPATH)}internal/gc.h
-random.$(OBJEXT): {$(VPATH)}internal/glob.h
-random.$(OBJEXT): {$(VPATH)}internal/globals.h
-random.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-random.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-random.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-random.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-random.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-random.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-random.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-random.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-random.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-random.$(OBJEXT): {$(VPATH)}internal/iterator.h
-random.$(OBJEXT): {$(VPATH)}internal/memory.h
-random.$(OBJEXT): {$(VPATH)}internal/method.h
-random.$(OBJEXT): {$(VPATH)}internal/module.h
-random.$(OBJEXT): {$(VPATH)}internal/newobj.h
-random.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-random.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-random.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-random.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-random.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-random.$(OBJEXT): {$(VPATH)}internal/symbol.h
-random.$(OBJEXT): {$(VPATH)}internal/value.h
-random.$(OBJEXT): {$(VPATH)}internal/value_type.h
-random.$(OBJEXT): {$(VPATH)}internal/variable.h
-random.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-random.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-random.$(OBJEXT): {$(VPATH)}missing.h
-random.$(OBJEXT): {$(VPATH)}mt19937.c
-random.$(OBJEXT): {$(VPATH)}ractor.h
-random.$(OBJEXT): {$(VPATH)}random.c
-random.$(OBJEXT): {$(VPATH)}random.h
-random.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-random.$(OBJEXT): {$(VPATH)}shape.h
-random.$(OBJEXT): {$(VPATH)}siphash.c
-random.$(OBJEXT): {$(VPATH)}siphash.h
-random.$(OBJEXT): {$(VPATH)}st.h
-random.$(OBJEXT): {$(VPATH)}subst.h
-range.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-range.$(OBJEXT): $(top_srcdir)/internal/array.h
-range.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-range.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-range.$(OBJEXT): $(top_srcdir)/internal/bits.h
-range.$(OBJEXT): $(top_srcdir)/internal/compar.h
-range.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-range.$(OBJEXT): $(top_srcdir)/internal/enum.h
-range.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
-range.$(OBJEXT): $(top_srcdir)/internal/error.h
-range.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-range.$(OBJEXT): $(top_srcdir)/internal/gc.h
-range.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-range.$(OBJEXT): $(top_srcdir)/internal/range.h
-range.$(OBJEXT): $(top_srcdir)/internal/serial.h
-range.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-range.$(OBJEXT): $(top_srcdir)/internal/string.h
-range.$(OBJEXT): $(top_srcdir)/internal/struct.h
-range.$(OBJEXT): $(top_srcdir)/internal/vm.h
-range.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-range.$(OBJEXT): {$(VPATH)}assert.h
-range.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-range.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-range.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-range.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-range.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-range.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-range.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-range.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-range.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-range.$(OBJEXT): {$(VPATH)}config.h
-range.$(OBJEXT): {$(VPATH)}defines.h
-range.$(OBJEXT): {$(VPATH)}encoding.h
-range.$(OBJEXT): {$(VPATH)}id.h
-range.$(OBJEXT): {$(VPATH)}intern.h
-range.$(OBJEXT): {$(VPATH)}internal.h
-range.$(OBJEXT): {$(VPATH)}internal/abi.h
-range.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-range.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-range.$(OBJEXT): {$(VPATH)}internal/assume.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-range.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-range.$(OBJEXT): {$(VPATH)}internal/cast.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-range.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-range.$(OBJEXT): {$(VPATH)}internal/config.h
-range.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-range.$(OBJEXT): {$(VPATH)}internal/core.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-range.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-range.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-range.$(OBJEXT): {$(VPATH)}internal/ctype.h
-range.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-range.$(OBJEXT): {$(VPATH)}internal/dosish.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-range.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-range.$(OBJEXT): {$(VPATH)}internal/error.h
-range.$(OBJEXT): {$(VPATH)}internal/eval.h
-range.$(OBJEXT): {$(VPATH)}internal/event.h
-range.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-range.$(OBJEXT): {$(VPATH)}internal/gc.h
-range.$(OBJEXT): {$(VPATH)}internal/glob.h
-range.$(OBJEXT): {$(VPATH)}internal/globals.h
-range.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-range.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-range.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-range.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-range.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-range.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-range.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-range.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-range.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-range.$(OBJEXT): {$(VPATH)}internal/iterator.h
-range.$(OBJEXT): {$(VPATH)}internal/memory.h
-range.$(OBJEXT): {$(VPATH)}internal/method.h
-range.$(OBJEXT): {$(VPATH)}internal/module.h
-range.$(OBJEXT): {$(VPATH)}internal/newobj.h
-range.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-range.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-range.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-range.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-range.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-range.$(OBJEXT): {$(VPATH)}internal/symbol.h
-range.$(OBJEXT): {$(VPATH)}internal/value.h
-range.$(OBJEXT): {$(VPATH)}internal/value_type.h
-range.$(OBJEXT): {$(VPATH)}internal/variable.h
-range.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-range.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-range.$(OBJEXT): {$(VPATH)}missing.h
-range.$(OBJEXT): {$(VPATH)}onigmo.h
-range.$(OBJEXT): {$(VPATH)}oniguruma.h
-range.$(OBJEXT): {$(VPATH)}range.c
-range.$(OBJEXT): {$(VPATH)}shape.h
-range.$(OBJEXT): {$(VPATH)}st.h
-range.$(OBJEXT): {$(VPATH)}subst.h
-rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-rational.$(OBJEXT): $(top_srcdir)/internal/array.h
-rational.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-rational.$(OBJEXT): $(top_srcdir)/internal/bits.h
-rational.$(OBJEXT): $(top_srcdir)/internal/class.h
-rational.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-rational.$(OBJEXT): $(top_srcdir)/internal/complex.h
-rational.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-rational.$(OBJEXT): $(top_srcdir)/internal/gc.h
-rational.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-rational.$(OBJEXT): $(top_srcdir)/internal/object.h
-rational.$(OBJEXT): $(top_srcdir)/internal/rational.h
-rational.$(OBJEXT): $(top_srcdir)/internal/serial.h
-rational.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-rational.$(OBJEXT): $(top_srcdir)/internal/variable.h
-rational.$(OBJEXT): $(top_srcdir)/internal/vm.h
-rational.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-rational.$(OBJEXT): {$(VPATH)}assert.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-rational.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-rational.$(OBJEXT): {$(VPATH)}config.h
-rational.$(OBJEXT): {$(VPATH)}constant.h
-rational.$(OBJEXT): {$(VPATH)}defines.h
-rational.$(OBJEXT): {$(VPATH)}id.h
-rational.$(OBJEXT): {$(VPATH)}id_table.h
-rational.$(OBJEXT): {$(VPATH)}intern.h
-rational.$(OBJEXT): {$(VPATH)}internal.h
-rational.$(OBJEXT): {$(VPATH)}internal/abi.h
-rational.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-rational.$(OBJEXT): {$(VPATH)}internal/assume.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-rational.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-rational.$(OBJEXT): {$(VPATH)}internal/cast.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-rational.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-rational.$(OBJEXT): {$(VPATH)}internal/config.h
-rational.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-rational.$(OBJEXT): {$(VPATH)}internal/core.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-rational.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-rational.$(OBJEXT): {$(VPATH)}internal/ctype.h
-rational.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-rational.$(OBJEXT): {$(VPATH)}internal/dosish.h
-rational.$(OBJEXT): {$(VPATH)}internal/error.h
-rational.$(OBJEXT): {$(VPATH)}internal/eval.h
-rational.$(OBJEXT): {$(VPATH)}internal/event.h
-rational.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-rational.$(OBJEXT): {$(VPATH)}internal/gc.h
-rational.$(OBJEXT): {$(VPATH)}internal/glob.h
-rational.$(OBJEXT): {$(VPATH)}internal/globals.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-rational.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-rational.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-rational.$(OBJEXT): {$(VPATH)}internal/iterator.h
-rational.$(OBJEXT): {$(VPATH)}internal/memory.h
-rational.$(OBJEXT): {$(VPATH)}internal/method.h
-rational.$(OBJEXT): {$(VPATH)}internal/module.h
-rational.$(OBJEXT): {$(VPATH)}internal/newobj.h
-rational.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-rational.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-rational.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-rational.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-rational.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-rational.$(OBJEXT): {$(VPATH)}internal/symbol.h
-rational.$(OBJEXT): {$(VPATH)}internal/value.h
-rational.$(OBJEXT): {$(VPATH)}internal/value_type.h
-rational.$(OBJEXT): {$(VPATH)}internal/variable.h
-rational.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-rational.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-rational.$(OBJEXT): {$(VPATH)}missing.h
-rational.$(OBJEXT): {$(VPATH)}rational.c
-rational.$(OBJEXT): {$(VPATH)}ruby_assert.h
-rational.$(OBJEXT): {$(VPATH)}shape.h
-rational.$(OBJEXT): {$(VPATH)}st.h
-rational.$(OBJEXT): {$(VPATH)}subst.h
-re.$(OBJEXT): $(hdrdir)/ruby.h
-re.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-re.$(OBJEXT): $(top_srcdir)/internal/array.h
-re.$(OBJEXT): $(top_srcdir)/internal/bits.h
-re.$(OBJEXT): $(top_srcdir)/internal/class.h
-re.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-re.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-re.$(OBJEXT): $(top_srcdir)/internal/gc.h
-re.$(OBJEXT): $(top_srcdir)/internal/hash.h
-re.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-re.$(OBJEXT): $(top_srcdir)/internal/object.h
-re.$(OBJEXT): $(top_srcdir)/internal/ractor.h
-re.$(OBJEXT): $(top_srcdir)/internal/re.h
-re.$(OBJEXT): $(top_srcdir)/internal/serial.h
-re.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-re.$(OBJEXT): $(top_srcdir)/internal/string.h
-re.$(OBJEXT): $(top_srcdir)/internal/time.h
-re.$(OBJEXT): $(top_srcdir)/internal/variable.h
-re.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-re.$(OBJEXT): {$(VPATH)}assert.h
-re.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-re.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-re.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-re.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-re.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-re.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-re.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-re.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-re.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-re.$(OBJEXT): {$(VPATH)}config.h
-re.$(OBJEXT): {$(VPATH)}constant.h
-re.$(OBJEXT): {$(VPATH)}defines.h
-re.$(OBJEXT): {$(VPATH)}encindex.h
-re.$(OBJEXT): {$(VPATH)}encoding.h
-re.$(OBJEXT): {$(VPATH)}hrtime.h
-re.$(OBJEXT): {$(VPATH)}id_table.h
-re.$(OBJEXT): {$(VPATH)}intern.h
-re.$(OBJEXT): {$(VPATH)}internal.h
-re.$(OBJEXT): {$(VPATH)}internal/abi.h
-re.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-re.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-re.$(OBJEXT): {$(VPATH)}internal/assume.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-re.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-re.$(OBJEXT): {$(VPATH)}internal/cast.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-re.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-re.$(OBJEXT): {$(VPATH)}internal/config.h
-re.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-re.$(OBJEXT): {$(VPATH)}internal/core.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
-re.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-re.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-re.$(OBJEXT): {$(VPATH)}internal/ctype.h
-re.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-re.$(OBJEXT): {$(VPATH)}internal/dosish.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-re.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-re.$(OBJEXT): {$(VPATH)}internal/error.h
-re.$(OBJEXT): {$(VPATH)}internal/eval.h
-re.$(OBJEXT): {$(VPATH)}internal/event.h
-re.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-re.$(OBJEXT): {$(VPATH)}internal/gc.h
-re.$(OBJEXT): {$(VPATH)}internal/glob.h
-re.$(OBJEXT): {$(VPATH)}internal/globals.h
-re.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-re.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-re.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-re.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-re.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-re.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-re.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-re.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-re.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-re.$(OBJEXT): {$(VPATH)}internal/iterator.h
-re.$(OBJEXT): {$(VPATH)}internal/memory.h
-re.$(OBJEXT): {$(VPATH)}internal/method.h
-re.$(OBJEXT): {$(VPATH)}internal/module.h
-re.$(OBJEXT): {$(VPATH)}internal/newobj.h
-re.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-re.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-re.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-re.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-re.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-re.$(OBJEXT): {$(VPATH)}internal/symbol.h
-re.$(OBJEXT): {$(VPATH)}internal/value.h
-re.$(OBJEXT): {$(VPATH)}internal/value_type.h
-re.$(OBJEXT): {$(VPATH)}internal/variable.h
-re.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-re.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-re.$(OBJEXT): {$(VPATH)}missing.h
-re.$(OBJEXT): {$(VPATH)}onigmo.h
-re.$(OBJEXT): {$(VPATH)}oniguruma.h
-re.$(OBJEXT): {$(VPATH)}re.c
-re.$(OBJEXT): {$(VPATH)}re.h
-re.$(OBJEXT): {$(VPATH)}regenc.h
-re.$(OBJEXT): {$(VPATH)}regex.h
-re.$(OBJEXT): {$(VPATH)}regint.h
-re.$(OBJEXT): {$(VPATH)}shape.h
-re.$(OBJEXT): {$(VPATH)}st.h
-re.$(OBJEXT): {$(VPATH)}subst.h
-re.$(OBJEXT): {$(VPATH)}util.h
-regcomp.$(OBJEXT): $(hdrdir)/ruby.h
-regcomp.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regcomp.$(OBJEXT): {$(VPATH)}assert.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regcomp.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regcomp.$(OBJEXT): {$(VPATH)}config.h
-regcomp.$(OBJEXT): {$(VPATH)}defines.h
-regcomp.$(OBJEXT): {$(VPATH)}intern.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/abi.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/assume.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/cast.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/config.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/error.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/eval.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/event.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/gc.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/glob.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/globals.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/memory.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/method.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/module.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/value.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/variable.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regcomp.$(OBJEXT): {$(VPATH)}missing.h
-regcomp.$(OBJEXT): {$(VPATH)}onigmo.h
-regcomp.$(OBJEXT): {$(VPATH)}regcomp.c
-regcomp.$(OBJEXT): {$(VPATH)}regenc.h
-regcomp.$(OBJEXT): {$(VPATH)}regint.h
-regcomp.$(OBJEXT): {$(VPATH)}regparse.h
-regcomp.$(OBJEXT): {$(VPATH)}st.h
-regcomp.$(OBJEXT): {$(VPATH)}subst.h
-regenc.$(OBJEXT): $(hdrdir)/ruby.h
-regenc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regenc.$(OBJEXT): {$(VPATH)}assert.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regenc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regenc.$(OBJEXT): {$(VPATH)}config.h
-regenc.$(OBJEXT): {$(VPATH)}defines.h
-regenc.$(OBJEXT): {$(VPATH)}intern.h
-regenc.$(OBJEXT): {$(VPATH)}internal/abi.h
-regenc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regenc.$(OBJEXT): {$(VPATH)}internal/assume.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regenc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regenc.$(OBJEXT): {$(VPATH)}internal/cast.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regenc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regenc.$(OBJEXT): {$(VPATH)}internal/config.h
-regenc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regenc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regenc.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regenc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regenc.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regenc.$(OBJEXT): {$(VPATH)}internal/error.h
-regenc.$(OBJEXT): {$(VPATH)}internal/eval.h
-regenc.$(OBJEXT): {$(VPATH)}internal/event.h
-regenc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regenc.$(OBJEXT): {$(VPATH)}internal/gc.h
-regenc.$(OBJEXT): {$(VPATH)}internal/glob.h
-regenc.$(OBJEXT): {$(VPATH)}internal/globals.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regenc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regenc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regenc.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regenc.$(OBJEXT): {$(VPATH)}internal/memory.h
-regenc.$(OBJEXT): {$(VPATH)}internal/method.h
-regenc.$(OBJEXT): {$(VPATH)}internal/module.h
-regenc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regenc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regenc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regenc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regenc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regenc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regenc.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regenc.$(OBJEXT): {$(VPATH)}internal/value.h
-regenc.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regenc.$(OBJEXT): {$(VPATH)}internal/variable.h
-regenc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regenc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regenc.$(OBJEXT): {$(VPATH)}missing.h
-regenc.$(OBJEXT): {$(VPATH)}onigmo.h
-regenc.$(OBJEXT): {$(VPATH)}regenc.c
-regenc.$(OBJEXT): {$(VPATH)}regenc.h
-regenc.$(OBJEXT): {$(VPATH)}regint.h
-regenc.$(OBJEXT): {$(VPATH)}st.h
-regenc.$(OBJEXT): {$(VPATH)}subst.h
-regerror.$(OBJEXT): $(hdrdir)/ruby.h
-regerror.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regerror.$(OBJEXT): {$(VPATH)}assert.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regerror.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regerror.$(OBJEXT): {$(VPATH)}config.h
-regerror.$(OBJEXT): {$(VPATH)}defines.h
-regerror.$(OBJEXT): {$(VPATH)}intern.h
-regerror.$(OBJEXT): {$(VPATH)}internal/abi.h
-regerror.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regerror.$(OBJEXT): {$(VPATH)}internal/assume.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regerror.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regerror.$(OBJEXT): {$(VPATH)}internal/cast.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regerror.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regerror.$(OBJEXT): {$(VPATH)}internal/config.h
-regerror.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regerror.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regerror.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regerror.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regerror.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regerror.$(OBJEXT): {$(VPATH)}internal/error.h
-regerror.$(OBJEXT): {$(VPATH)}internal/eval.h
-regerror.$(OBJEXT): {$(VPATH)}internal/event.h
-regerror.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regerror.$(OBJEXT): {$(VPATH)}internal/gc.h
-regerror.$(OBJEXT): {$(VPATH)}internal/glob.h
-regerror.$(OBJEXT): {$(VPATH)}internal/globals.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regerror.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regerror.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regerror.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regerror.$(OBJEXT): {$(VPATH)}internal/memory.h
-regerror.$(OBJEXT): {$(VPATH)}internal/method.h
-regerror.$(OBJEXT): {$(VPATH)}internal/module.h
-regerror.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regerror.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regerror.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regerror.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regerror.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regerror.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regerror.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regerror.$(OBJEXT): {$(VPATH)}internal/value.h
-regerror.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regerror.$(OBJEXT): {$(VPATH)}internal/variable.h
-regerror.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regerror.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regerror.$(OBJEXT): {$(VPATH)}missing.h
-regerror.$(OBJEXT): {$(VPATH)}onigmo.h
-regerror.$(OBJEXT): {$(VPATH)}regenc.h
-regerror.$(OBJEXT): {$(VPATH)}regerror.c
-regerror.$(OBJEXT): {$(VPATH)}regint.h
-regerror.$(OBJEXT): {$(VPATH)}st.h
-regerror.$(OBJEXT): {$(VPATH)}subst.h
-regexec.$(OBJEXT): $(hdrdir)/ruby.h
-regexec.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regexec.$(OBJEXT): {$(VPATH)}assert.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regexec.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regexec.$(OBJEXT): {$(VPATH)}config.h
-regexec.$(OBJEXT): {$(VPATH)}defines.h
-regexec.$(OBJEXT): {$(VPATH)}intern.h
-regexec.$(OBJEXT): {$(VPATH)}internal/abi.h
-regexec.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regexec.$(OBJEXT): {$(VPATH)}internal/assume.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regexec.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regexec.$(OBJEXT): {$(VPATH)}internal/cast.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regexec.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regexec.$(OBJEXT): {$(VPATH)}internal/config.h
-regexec.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regexec.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regexec.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regexec.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regexec.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regexec.$(OBJEXT): {$(VPATH)}internal/error.h
-regexec.$(OBJEXT): {$(VPATH)}internal/eval.h
-regexec.$(OBJEXT): {$(VPATH)}internal/event.h
-regexec.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regexec.$(OBJEXT): {$(VPATH)}internal/gc.h
-regexec.$(OBJEXT): {$(VPATH)}internal/glob.h
-regexec.$(OBJEXT): {$(VPATH)}internal/globals.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regexec.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regexec.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regexec.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regexec.$(OBJEXT): {$(VPATH)}internal/memory.h
-regexec.$(OBJEXT): {$(VPATH)}internal/method.h
-regexec.$(OBJEXT): {$(VPATH)}internal/module.h
-regexec.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regexec.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regexec.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regexec.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regexec.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regexec.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regexec.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regexec.$(OBJEXT): {$(VPATH)}internal/value.h
-regexec.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regexec.$(OBJEXT): {$(VPATH)}internal/variable.h
-regexec.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regexec.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regexec.$(OBJEXT): {$(VPATH)}missing.h
-regexec.$(OBJEXT): {$(VPATH)}onigmo.h
-regexec.$(OBJEXT): {$(VPATH)}regenc.h
-regexec.$(OBJEXT): {$(VPATH)}regexec.c
-regexec.$(OBJEXT): {$(VPATH)}regint.h
-regexec.$(OBJEXT): {$(VPATH)}st.h
-regexec.$(OBJEXT): {$(VPATH)}subst.h
-regparse.$(OBJEXT): $(hdrdir)/ruby.h
-regparse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regparse.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-regparse.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-regparse.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-regparse.$(OBJEXT): {$(VPATH)}assert.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regparse.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regparse.$(OBJEXT): {$(VPATH)}config.h
-regparse.$(OBJEXT): {$(VPATH)}defines.h
-regparse.$(OBJEXT): {$(VPATH)}intern.h
-regparse.$(OBJEXT): {$(VPATH)}internal/abi.h
-regparse.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regparse.$(OBJEXT): {$(VPATH)}internal/assume.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regparse.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regparse.$(OBJEXT): {$(VPATH)}internal/cast.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regparse.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regparse.$(OBJEXT): {$(VPATH)}internal/config.h
-regparse.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regparse.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regparse.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regparse.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regparse.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regparse.$(OBJEXT): {$(VPATH)}internal/error.h
-regparse.$(OBJEXT): {$(VPATH)}internal/eval.h
-regparse.$(OBJEXT): {$(VPATH)}internal/event.h
-regparse.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regparse.$(OBJEXT): {$(VPATH)}internal/gc.h
-regparse.$(OBJEXT): {$(VPATH)}internal/glob.h
-regparse.$(OBJEXT): {$(VPATH)}internal/globals.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regparse.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regparse.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regparse.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regparse.$(OBJEXT): {$(VPATH)}internal/memory.h
-regparse.$(OBJEXT): {$(VPATH)}internal/method.h
-regparse.$(OBJEXT): {$(VPATH)}internal/module.h
-regparse.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regparse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regparse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regparse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regparse.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regparse.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regparse.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regparse.$(OBJEXT): {$(VPATH)}internal/value.h
-regparse.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regparse.$(OBJEXT): {$(VPATH)}internal/variable.h
-regparse.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regparse.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regparse.$(OBJEXT): {$(VPATH)}missing.h
-regparse.$(OBJEXT): {$(VPATH)}onigmo.h
-regparse.$(OBJEXT): {$(VPATH)}regenc.h
-regparse.$(OBJEXT): {$(VPATH)}regint.h
-regparse.$(OBJEXT): {$(VPATH)}regparse.c
-regparse.$(OBJEXT): {$(VPATH)}regparse.h
-regparse.$(OBJEXT): {$(VPATH)}st.h
-regparse.$(OBJEXT): {$(VPATH)}subst.h
-regsyntax.$(OBJEXT): $(hdrdir)/ruby.h
-regsyntax.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-regsyntax.$(OBJEXT): {$(VPATH)}assert.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-regsyntax.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-regsyntax.$(OBJEXT): {$(VPATH)}config.h
-regsyntax.$(OBJEXT): {$(VPATH)}defines.h
-regsyntax.$(OBJEXT): {$(VPATH)}intern.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/abi.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/assume.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/cast.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/config.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/ctype.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/dosish.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/error.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/eval.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/event.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/gc.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/glob.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/globals.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/iterator.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/memory.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/method.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/module.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/symbol.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/value.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/value_type.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/variable.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-regsyntax.$(OBJEXT): {$(VPATH)}missing.h
-regsyntax.$(OBJEXT): {$(VPATH)}onigmo.h
-regsyntax.$(OBJEXT): {$(VPATH)}regenc.h
-regsyntax.$(OBJEXT): {$(VPATH)}regint.h
-regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c
-regsyntax.$(OBJEXT): {$(VPATH)}st.h
-regsyntax.$(OBJEXT): {$(VPATH)}subst.h
-rjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-rjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-rjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-rjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-rjit.$(OBJEXT): $(hdrdir)/ruby.h
-rjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-rjit.$(OBJEXT): $(hdrdir)/ruby/version.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/array.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/class.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/file.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/process.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/string.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/struct.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
-rjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-rjit.$(OBJEXT): {$(VPATH)}assert.h
-rjit.$(OBJEXT): {$(VPATH)}atomic.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-rjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-rjit.$(OBJEXT): {$(VPATH)}builtin.h
-rjit.$(OBJEXT): {$(VPATH)}config.h
-rjit.$(OBJEXT): {$(VPATH)}constant.h
-rjit.$(OBJEXT): {$(VPATH)}debug.h
-rjit.$(OBJEXT): {$(VPATH)}debug_counter.h
-rjit.$(OBJEXT): {$(VPATH)}defines.h
-rjit.$(OBJEXT): {$(VPATH)}dln.h
-rjit.$(OBJEXT): {$(VPATH)}encoding.h
-rjit.$(OBJEXT): {$(VPATH)}id.h
-rjit.$(OBJEXT): {$(VPATH)}id_table.h
-rjit.$(OBJEXT): {$(VPATH)}insns.def
-rjit.$(OBJEXT): {$(VPATH)}insns.inc
-rjit.$(OBJEXT): {$(VPATH)}insns_info.inc
-rjit.$(OBJEXT): {$(VPATH)}intern.h
-rjit.$(OBJEXT): {$(VPATH)}internal.h
-rjit.$(OBJEXT): {$(VPATH)}internal/abi.h
-rjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-rjit.$(OBJEXT): {$(VPATH)}internal/assume.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-rjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-rjit.$(OBJEXT): {$(VPATH)}internal/cast.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-rjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-rjit.$(OBJEXT): {$(VPATH)}internal/config.h
-rjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-rjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-rjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
-rjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-rjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-rjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-rjit.$(OBJEXT): {$(VPATH)}internal/error.h
-rjit.$(OBJEXT): {$(VPATH)}internal/eval.h
-rjit.$(OBJEXT): {$(VPATH)}internal/event.h
-rjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-rjit.$(OBJEXT): {$(VPATH)}internal/gc.h
-rjit.$(OBJEXT): {$(VPATH)}internal/glob.h
-rjit.$(OBJEXT): {$(VPATH)}internal/globals.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-rjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-rjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-rjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-rjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
-rjit.$(OBJEXT): {$(VPATH)}internal/memory.h
-rjit.$(OBJEXT): {$(VPATH)}internal/method.h
-rjit.$(OBJEXT): {$(VPATH)}internal/module.h
-rjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-rjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-rjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-rjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-rjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-rjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-rjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
-rjit.$(OBJEXT): {$(VPATH)}internal/value.h
-rjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
-rjit.$(OBJEXT): {$(VPATH)}internal/variable.h
-rjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-rjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-rjit.$(OBJEXT): {$(VPATH)}iseq.h
-rjit.$(OBJEXT): {$(VPATH)}method.h
-rjit.$(OBJEXT): {$(VPATH)}missing.h
-rjit.$(OBJEXT): {$(VPATH)}node.h
-rjit.$(OBJEXT): {$(VPATH)}onigmo.h
-rjit.$(OBJEXT): {$(VPATH)}oniguruma.h
-rjit.$(OBJEXT): {$(VPATH)}ractor.h
-rjit.$(OBJEXT): {$(VPATH)}ractor_core.h
-rjit.$(OBJEXT): {$(VPATH)}rjit.c
-rjit.$(OBJEXT): {$(VPATH)}rjit.h
-rjit.$(OBJEXT): {$(VPATH)}rjit.rbinc
-rjit.$(OBJEXT): {$(VPATH)}rjit_c.h
-rjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-rjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-rjit.$(OBJEXT): {$(VPATH)}shape.h
-rjit.$(OBJEXT): {$(VPATH)}st.h
-rjit.$(OBJEXT): {$(VPATH)}subst.h
-rjit.$(OBJEXT): {$(VPATH)}thread.h
-rjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-rjit.$(OBJEXT): {$(VPATH)}thread_native.h
-rjit.$(OBJEXT): {$(VPATH)}util.h
-rjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-rjit.$(OBJEXT): {$(VPATH)}vm_core.h
-rjit.$(OBJEXT): {$(VPATH)}vm_debug.h
-rjit.$(OBJEXT): {$(VPATH)}vm_opts.h
-rjit.$(OBJEXT): {$(VPATH)}vm_sync.h
-rjit.$(OBJEXT): {$(VPATH)}yjit.h
-rjit_c.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-rjit_c.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-rjit_c.$(OBJEXT): $(CCAN_DIR)/list/list.h
-rjit_c.$(OBJEXT): $(CCAN_DIR)/str/str.h
-rjit_c.$(OBJEXT): $(hdrdir)/ruby.h
-rjit_c.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-rjit_c.$(OBJEXT): $(srcdir)/rjit_c.rb
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/array.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/class.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/compile.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/gc.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/hash.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/object.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/serial.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/string.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/struct.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/variable.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/vm.h
-rjit_c.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-rjit_c.$(OBJEXT): {$(VPATH)}assert.h
-rjit_c.$(OBJEXT): {$(VPATH)}atomic.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-rjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-rjit_c.$(OBJEXT): {$(VPATH)}builtin.h
-rjit_c.$(OBJEXT): {$(VPATH)}config.h
-rjit_c.$(OBJEXT): {$(VPATH)}constant.h
-rjit_c.$(OBJEXT): {$(VPATH)}debug.h
-rjit_c.$(OBJEXT): {$(VPATH)}debug_counter.h
-rjit_c.$(OBJEXT): {$(VPATH)}defines.h
-rjit_c.$(OBJEXT): {$(VPATH)}encoding.h
-rjit_c.$(OBJEXT): {$(VPATH)}id.h
-rjit_c.$(OBJEXT): {$(VPATH)}id_table.h
-rjit_c.$(OBJEXT): {$(VPATH)}insns.def
-rjit_c.$(OBJEXT): {$(VPATH)}insns.inc
-rjit_c.$(OBJEXT): {$(VPATH)}insns_info.inc
-rjit_c.$(OBJEXT): {$(VPATH)}intern.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/abi.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/assume.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/cast.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/config.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/ctype.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/dosish.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/error.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/eval.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/event.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/gc.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/glob.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/globals.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/iterator.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/memory.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/method.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/module.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/newobj.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/symbol.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/value.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/value_type.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/variable.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-rjit_c.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-rjit_c.$(OBJEXT): {$(VPATH)}iseq.h
-rjit_c.$(OBJEXT): {$(VPATH)}method.h
-rjit_c.$(OBJEXT): {$(VPATH)}missing.h
-rjit_c.$(OBJEXT): {$(VPATH)}node.h
-rjit_c.$(OBJEXT): {$(VPATH)}onigmo.h
-rjit_c.$(OBJEXT): {$(VPATH)}oniguruma.h
-rjit_c.$(OBJEXT): {$(VPATH)}probes.dmyh
-rjit_c.$(OBJEXT): {$(VPATH)}probes.h
-rjit_c.$(OBJEXT): {$(VPATH)}probes_helper.h
-rjit_c.$(OBJEXT): {$(VPATH)}rjit.h
-rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.c
-rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.h
-rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.rb
-rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.rbinc
-rjit_c.$(OBJEXT): {$(VPATH)}ruby_assert.h
-rjit_c.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-rjit_c.$(OBJEXT): {$(VPATH)}shape.h
-rjit_c.$(OBJEXT): {$(VPATH)}st.h
-rjit_c.$(OBJEXT): {$(VPATH)}subst.h
-rjit_c.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-rjit_c.$(OBJEXT): {$(VPATH)}thread_native.h
-rjit_c.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-rjit_c.$(OBJEXT): {$(VPATH)}vm_core.h
-rjit_c.$(OBJEXT): {$(VPATH)}vm_exec.h
-rjit_c.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
-rjit_c.$(OBJEXT): {$(VPATH)}vm_opts.h
-rjit_c.$(OBJEXT): {$(VPATH)}yjit.h
-ruby-runner.$(OBJEXT): {$(VPATH)}config.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-ruby-runner.$(OBJEXT): {$(VPATH)}internal/config.h
-ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.c
-ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.h
-ruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-ruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-ruby.$(OBJEXT): $(CCAN_DIR)/list/list.h
-ruby.$(OBJEXT): $(CCAN_DIR)/str/str.h
-ruby.$(OBJEXT): $(hdrdir)/ruby.h
-ruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-ruby.$(OBJEXT): $(hdrdir)/ruby/version.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/array.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/class.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/cont.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/error.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/file.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/gc.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/inits.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/io.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/load.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/loadpath.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/missing.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/object.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/parse.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/process.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/string.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-ruby.$(OBJEXT): {$(VPATH)}assert.h
-ruby.$(OBJEXT): {$(VPATH)}atomic.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-ruby.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-ruby.$(OBJEXT): {$(VPATH)}config.h
-ruby.$(OBJEXT): {$(VPATH)}constant.h
-ruby.$(OBJEXT): {$(VPATH)}debug_counter.h
-ruby.$(OBJEXT): {$(VPATH)}defines.h
-ruby.$(OBJEXT): {$(VPATH)}dln.h
-ruby.$(OBJEXT): {$(VPATH)}encoding.h
-ruby.$(OBJEXT): {$(VPATH)}eval_intern.h
-ruby.$(OBJEXT): {$(VPATH)}id.h
-ruby.$(OBJEXT): {$(VPATH)}id_table.h
-ruby.$(OBJEXT): {$(VPATH)}intern.h
-ruby.$(OBJEXT): {$(VPATH)}internal.h
-ruby.$(OBJEXT): {$(VPATH)}internal/abi.h
-ruby.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-ruby.$(OBJEXT): {$(VPATH)}internal/assume.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-ruby.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-ruby.$(OBJEXT): {$(VPATH)}internal/cast.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-ruby.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-ruby.$(OBJEXT): {$(VPATH)}internal/config.h
-ruby.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-ruby.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-ruby.$(OBJEXT): {$(VPATH)}internal/ctype.h
-ruby.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-ruby.$(OBJEXT): {$(VPATH)}internal/dosish.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-ruby.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-ruby.$(OBJEXT): {$(VPATH)}internal/error.h
-ruby.$(OBJEXT): {$(VPATH)}internal/eval.h
-ruby.$(OBJEXT): {$(VPATH)}internal/event.h
-ruby.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-ruby.$(OBJEXT): {$(VPATH)}internal/gc.h
-ruby.$(OBJEXT): {$(VPATH)}internal/glob.h
-ruby.$(OBJEXT): {$(VPATH)}internal/globals.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-ruby.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-ruby.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-ruby.$(OBJEXT): {$(VPATH)}internal/iterator.h
-ruby.$(OBJEXT): {$(VPATH)}internal/memory.h
-ruby.$(OBJEXT): {$(VPATH)}internal/method.h
-ruby.$(OBJEXT): {$(VPATH)}internal/module.h
-ruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-ruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-ruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-ruby.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-ruby.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-ruby.$(OBJEXT): {$(VPATH)}internal/symbol.h
-ruby.$(OBJEXT): {$(VPATH)}internal/value.h
-ruby.$(OBJEXT): {$(VPATH)}internal/value_type.h
-ruby.$(OBJEXT): {$(VPATH)}internal/variable.h
-ruby.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-ruby.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-ruby.$(OBJEXT): {$(VPATH)}io.h
-ruby.$(OBJEXT): {$(VPATH)}iseq.h
-ruby.$(OBJEXT): {$(VPATH)}method.h
-ruby.$(OBJEXT): {$(VPATH)}missing.h
-ruby.$(OBJEXT): {$(VPATH)}node.h
-ruby.$(OBJEXT): {$(VPATH)}onigmo.h
-ruby.$(OBJEXT): {$(VPATH)}oniguruma.h
-ruby.$(OBJEXT): {$(VPATH)}rjit.h
-ruby.$(OBJEXT): {$(VPATH)}ruby.c
-ruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
-ruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-ruby.$(OBJEXT): {$(VPATH)}shape.h
-ruby.$(OBJEXT): {$(VPATH)}st.h
-ruby.$(OBJEXT): {$(VPATH)}subst.h
-ruby.$(OBJEXT): {$(VPATH)}thread.h
-ruby.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-ruby.$(OBJEXT): {$(VPATH)}thread_native.h
-ruby.$(OBJEXT): {$(VPATH)}util.h
-ruby.$(OBJEXT): {$(VPATH)}vm_core.h
-ruby.$(OBJEXT): {$(VPATH)}vm_opts.h
-ruby.$(OBJEXT): {$(VPATH)}yjit.h
-scheduler.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-scheduler.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-scheduler.$(OBJEXT): $(CCAN_DIR)/list/list.h
-scheduler.$(OBJEXT): $(CCAN_DIR)/str/str.h
-scheduler.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/array.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/gc.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/serial.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/thread.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/variable.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/vm.h
-scheduler.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-scheduler.$(OBJEXT): {$(VPATH)}assert.h
-scheduler.$(OBJEXT): {$(VPATH)}atomic.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-scheduler.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-scheduler.$(OBJEXT): {$(VPATH)}config.h
-scheduler.$(OBJEXT): {$(VPATH)}constant.h
-scheduler.$(OBJEXT): {$(VPATH)}defines.h
-scheduler.$(OBJEXT): {$(VPATH)}encoding.h
-scheduler.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-scheduler.$(OBJEXT): {$(VPATH)}id.h
-scheduler.$(OBJEXT): {$(VPATH)}id_table.h
-scheduler.$(OBJEXT): {$(VPATH)}intern.h
-scheduler.$(OBJEXT): {$(VPATH)}internal.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/abi.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/assume.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/cast.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/config.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/ctype.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/dosish.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/error.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/eval.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/event.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/gc.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/glob.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/globals.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/iterator.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/memory.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/method.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/module.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/newobj.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/symbol.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/value.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/value_type.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/variable.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-scheduler.$(OBJEXT): {$(VPATH)}io.h
-scheduler.$(OBJEXT): {$(VPATH)}io/buffer.h
-scheduler.$(OBJEXT): {$(VPATH)}method.h
-scheduler.$(OBJEXT): {$(VPATH)}missing.h
-scheduler.$(OBJEXT): {$(VPATH)}node.h
-scheduler.$(OBJEXT): {$(VPATH)}onigmo.h
-scheduler.$(OBJEXT): {$(VPATH)}oniguruma.h
-scheduler.$(OBJEXT): {$(VPATH)}ruby_assert.h
-scheduler.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-scheduler.$(OBJEXT): {$(VPATH)}scheduler.c
-scheduler.$(OBJEXT): {$(VPATH)}shape.h
-scheduler.$(OBJEXT): {$(VPATH)}st.h
-scheduler.$(OBJEXT): {$(VPATH)}subst.h
-scheduler.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-scheduler.$(OBJEXT): {$(VPATH)}thread_native.h
-scheduler.$(OBJEXT): {$(VPATH)}vm_core.h
-scheduler.$(OBJEXT): {$(VPATH)}vm_opts.h
-setproctitle.$(OBJEXT): $(hdrdir)/ruby.h
-setproctitle.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-setproctitle.$(OBJEXT): {$(VPATH)}assert.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-setproctitle.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-setproctitle.$(OBJEXT): {$(VPATH)}config.h
-setproctitle.$(OBJEXT): {$(VPATH)}defines.h
-setproctitle.$(OBJEXT): {$(VPATH)}intern.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/abi.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/assume.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/cast.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/config.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/ctype.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/dosish.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/error.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/eval.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/event.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/gc.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/glob.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/globals.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/iterator.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/memory.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/method.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/module.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/newobj.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/symbol.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/value.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/value_type.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/variable.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-setproctitle.$(OBJEXT): {$(VPATH)}missing.h
-setproctitle.$(OBJEXT): {$(VPATH)}setproctitle.c
-setproctitle.$(OBJEXT): {$(VPATH)}st.h
-setproctitle.$(OBJEXT): {$(VPATH)}subst.h
-setproctitle.$(OBJEXT): {$(VPATH)}util.h
-shape.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-shape.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-shape.$(OBJEXT): $(CCAN_DIR)/list/list.h
-shape.$(OBJEXT): $(CCAN_DIR)/str/str.h
-shape.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-shape.$(OBJEXT): $(top_srcdir)/internal/array.h
-shape.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-shape.$(OBJEXT): $(top_srcdir)/internal/class.h
-shape.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-shape.$(OBJEXT): $(top_srcdir)/internal/gc.h
-shape.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-shape.$(OBJEXT): $(top_srcdir)/internal/serial.h
-shape.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-shape.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-shape.$(OBJEXT): $(top_srcdir)/internal/variable.h
-shape.$(OBJEXT): $(top_srcdir)/internal/vm.h
-shape.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-shape.$(OBJEXT): {$(VPATH)}assert.h
-shape.$(OBJEXT): {$(VPATH)}atomic.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-shape.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-shape.$(OBJEXT): {$(VPATH)}config.h
-shape.$(OBJEXT): {$(VPATH)}constant.h
-shape.$(OBJEXT): {$(VPATH)}debug_counter.h
-shape.$(OBJEXT): {$(VPATH)}defines.h
-shape.$(OBJEXT): {$(VPATH)}encoding.h
-shape.$(OBJEXT): {$(VPATH)}id.h
-shape.$(OBJEXT): {$(VPATH)}id_table.h
-shape.$(OBJEXT): {$(VPATH)}intern.h
-shape.$(OBJEXT): {$(VPATH)}internal.h
-shape.$(OBJEXT): {$(VPATH)}internal/abi.h
-shape.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-shape.$(OBJEXT): {$(VPATH)}internal/assume.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-shape.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-shape.$(OBJEXT): {$(VPATH)}internal/cast.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-shape.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-shape.$(OBJEXT): {$(VPATH)}internal/config.h
-shape.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-shape.$(OBJEXT): {$(VPATH)}internal/core.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-shape.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-shape.$(OBJEXT): {$(VPATH)}internal/ctype.h
-shape.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-shape.$(OBJEXT): {$(VPATH)}internal/dosish.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-shape.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-shape.$(OBJEXT): {$(VPATH)}internal/error.h
-shape.$(OBJEXT): {$(VPATH)}internal/eval.h
-shape.$(OBJEXT): {$(VPATH)}internal/event.h
-shape.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-shape.$(OBJEXT): {$(VPATH)}internal/gc.h
-shape.$(OBJEXT): {$(VPATH)}internal/glob.h
-shape.$(OBJEXT): {$(VPATH)}internal/globals.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-shape.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-shape.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-shape.$(OBJEXT): {$(VPATH)}internal/iterator.h
-shape.$(OBJEXT): {$(VPATH)}internal/memory.h
-shape.$(OBJEXT): {$(VPATH)}internal/method.h
-shape.$(OBJEXT): {$(VPATH)}internal/module.h
-shape.$(OBJEXT): {$(VPATH)}internal/newobj.h
-shape.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-shape.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-shape.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-shape.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-shape.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-shape.$(OBJEXT): {$(VPATH)}internal/symbol.h
-shape.$(OBJEXT): {$(VPATH)}internal/value.h
-shape.$(OBJEXT): {$(VPATH)}internal/value_type.h
-shape.$(OBJEXT): {$(VPATH)}internal/variable.h
-shape.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-shape.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-shape.$(OBJEXT): {$(VPATH)}method.h
-shape.$(OBJEXT): {$(VPATH)}missing.h
-shape.$(OBJEXT): {$(VPATH)}node.h
-shape.$(OBJEXT): {$(VPATH)}onigmo.h
-shape.$(OBJEXT): {$(VPATH)}oniguruma.h
-shape.$(OBJEXT): {$(VPATH)}ruby_assert.h
-shape.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-shape.$(OBJEXT): {$(VPATH)}shape.c
-shape.$(OBJEXT): {$(VPATH)}shape.h
-shape.$(OBJEXT): {$(VPATH)}st.h
-shape.$(OBJEXT): {$(VPATH)}subst.h
-shape.$(OBJEXT): {$(VPATH)}symbol.h
-shape.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-shape.$(OBJEXT): {$(VPATH)}thread_native.h
-shape.$(OBJEXT): {$(VPATH)}variable.h
-shape.$(OBJEXT): {$(VPATH)}vm_core.h
-shape.$(OBJEXT): {$(VPATH)}vm_debug.h
-shape.$(OBJEXT): {$(VPATH)}vm_opts.h
-shape.$(OBJEXT): {$(VPATH)}vm_sync.h
-signal.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-signal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-signal.$(OBJEXT): $(CCAN_DIR)/list/list.h
-signal.$(OBJEXT): $(CCAN_DIR)/str/str.h
-signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-signal.$(OBJEXT): $(top_srcdir)/internal/array.h
-signal.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-signal.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-signal.$(OBJEXT): $(top_srcdir)/internal/eval.h
-signal.$(OBJEXT): $(top_srcdir)/internal/gc.h
-signal.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-signal.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-signal.$(OBJEXT): $(top_srcdir)/internal/serial.h
-signal.$(OBJEXT): $(top_srcdir)/internal/signal.h
-signal.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-signal.$(OBJEXT): $(top_srcdir)/internal/string.h
-signal.$(OBJEXT): $(top_srcdir)/internal/thread.h
-signal.$(OBJEXT): $(top_srcdir)/internal/variable.h
-signal.$(OBJEXT): $(top_srcdir)/internal/vm.h
-signal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-signal.$(OBJEXT): {$(VPATH)}assert.h
-signal.$(OBJEXT): {$(VPATH)}atomic.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-signal.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-signal.$(OBJEXT): {$(VPATH)}config.h
-signal.$(OBJEXT): {$(VPATH)}constant.h
-signal.$(OBJEXT): {$(VPATH)}debug_counter.h
-signal.$(OBJEXT): {$(VPATH)}defines.h
-signal.$(OBJEXT): {$(VPATH)}encoding.h
-signal.$(OBJEXT): {$(VPATH)}eval_intern.h
-signal.$(OBJEXT): {$(VPATH)}id.h
-signal.$(OBJEXT): {$(VPATH)}id_table.h
-signal.$(OBJEXT): {$(VPATH)}intern.h
-signal.$(OBJEXT): {$(VPATH)}internal.h
-signal.$(OBJEXT): {$(VPATH)}internal/abi.h
-signal.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-signal.$(OBJEXT): {$(VPATH)}internal/assume.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-signal.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-signal.$(OBJEXT): {$(VPATH)}internal/cast.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-signal.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-signal.$(OBJEXT): {$(VPATH)}internal/config.h
-signal.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-signal.$(OBJEXT): {$(VPATH)}internal/core.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-signal.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-signal.$(OBJEXT): {$(VPATH)}internal/ctype.h
-signal.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-signal.$(OBJEXT): {$(VPATH)}internal/dosish.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-signal.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-signal.$(OBJEXT): {$(VPATH)}internal/error.h
-signal.$(OBJEXT): {$(VPATH)}internal/eval.h
-signal.$(OBJEXT): {$(VPATH)}internal/event.h
-signal.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-signal.$(OBJEXT): {$(VPATH)}internal/gc.h
-signal.$(OBJEXT): {$(VPATH)}internal/glob.h
-signal.$(OBJEXT): {$(VPATH)}internal/globals.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-signal.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-signal.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-signal.$(OBJEXT): {$(VPATH)}internal/iterator.h
-signal.$(OBJEXT): {$(VPATH)}internal/memory.h
-signal.$(OBJEXT): {$(VPATH)}internal/method.h
-signal.$(OBJEXT): {$(VPATH)}internal/module.h
-signal.$(OBJEXT): {$(VPATH)}internal/newobj.h
-signal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-signal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-signal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-signal.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-signal.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-signal.$(OBJEXT): {$(VPATH)}internal/symbol.h
-signal.$(OBJEXT): {$(VPATH)}internal/value.h
-signal.$(OBJEXT): {$(VPATH)}internal/value_type.h
-signal.$(OBJEXT): {$(VPATH)}internal/variable.h
-signal.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-signal.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-signal.$(OBJEXT): {$(VPATH)}method.h
-signal.$(OBJEXT): {$(VPATH)}missing.h
-signal.$(OBJEXT): {$(VPATH)}node.h
-signal.$(OBJEXT): {$(VPATH)}onigmo.h
-signal.$(OBJEXT): {$(VPATH)}oniguruma.h
-signal.$(OBJEXT): {$(VPATH)}ractor.h
-signal.$(OBJEXT): {$(VPATH)}ractor_core.h
-signal.$(OBJEXT): {$(VPATH)}ruby_assert.h
-signal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-signal.$(OBJEXT): {$(VPATH)}shape.h
-signal.$(OBJEXT): {$(VPATH)}signal.c
-signal.$(OBJEXT): {$(VPATH)}st.h
-signal.$(OBJEXT): {$(VPATH)}subst.h
-signal.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-signal.$(OBJEXT): {$(VPATH)}thread_native.h
-signal.$(OBJEXT): {$(VPATH)}vm_core.h
-signal.$(OBJEXT): {$(VPATH)}vm_debug.h
-signal.$(OBJEXT): {$(VPATH)}vm_opts.h
-sprintf.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/bits.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/class.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/error.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/gc.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/hash.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/object.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/serial.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/string.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/variable.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/vm.h
-sprintf.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-sprintf.$(OBJEXT): {$(VPATH)}assert.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-sprintf.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-sprintf.$(OBJEXT): {$(VPATH)}config.h
-sprintf.$(OBJEXT): {$(VPATH)}constant.h
-sprintf.$(OBJEXT): {$(VPATH)}defines.h
-sprintf.$(OBJEXT): {$(VPATH)}encoding.h
-sprintf.$(OBJEXT): {$(VPATH)}id.h
-sprintf.$(OBJEXT): {$(VPATH)}id_table.h
-sprintf.$(OBJEXT): {$(VPATH)}intern.h
-sprintf.$(OBJEXT): {$(VPATH)}internal.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/abi.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/assume.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/cast.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/config.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/ctype.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/dosish.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/error.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/eval.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/event.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/gc.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/glob.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/globals.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/iterator.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/memory.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/method.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/module.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/newobj.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/symbol.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/value.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/value_type.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/variable.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-sprintf.$(OBJEXT): {$(VPATH)}missing.h
-sprintf.$(OBJEXT): {$(VPATH)}onigmo.h
-sprintf.$(OBJEXT): {$(VPATH)}oniguruma.h
-sprintf.$(OBJEXT): {$(VPATH)}re.h
-sprintf.$(OBJEXT): {$(VPATH)}regex.h
-sprintf.$(OBJEXT): {$(VPATH)}shape.h
-sprintf.$(OBJEXT): {$(VPATH)}sprintf.c
-sprintf.$(OBJEXT): {$(VPATH)}st.h
-sprintf.$(OBJEXT): {$(VPATH)}subst.h
-sprintf.$(OBJEXT): {$(VPATH)}util.h
-sprintf.$(OBJEXT): {$(VPATH)}vsnprintf.c
-st.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-st.$(OBJEXT): $(top_srcdir)/internal/bits.h
-st.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-st.$(OBJEXT): $(top_srcdir)/internal/hash.h
-st.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-st.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-st.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-st.$(OBJEXT): {$(VPATH)}assert.h
-st.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-st.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-st.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-st.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-st.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-st.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-st.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-st.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-st.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-st.$(OBJEXT): {$(VPATH)}config.h
-st.$(OBJEXT): {$(VPATH)}defines.h
-st.$(OBJEXT): {$(VPATH)}intern.h
-st.$(OBJEXT): {$(VPATH)}internal.h
-st.$(OBJEXT): {$(VPATH)}internal/abi.h
-st.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-st.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-st.$(OBJEXT): {$(VPATH)}internal/assume.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-st.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-st.$(OBJEXT): {$(VPATH)}internal/cast.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-st.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-st.$(OBJEXT): {$(VPATH)}internal/config.h
-st.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-st.$(OBJEXT): {$(VPATH)}internal/core.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-st.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-st.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-st.$(OBJEXT): {$(VPATH)}internal/ctype.h
-st.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-st.$(OBJEXT): {$(VPATH)}internal/dosish.h
-st.$(OBJEXT): {$(VPATH)}internal/error.h
-st.$(OBJEXT): {$(VPATH)}internal/eval.h
-st.$(OBJEXT): {$(VPATH)}internal/event.h
-st.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-st.$(OBJEXT): {$(VPATH)}internal/gc.h
-st.$(OBJEXT): {$(VPATH)}internal/glob.h
-st.$(OBJEXT): {$(VPATH)}internal/globals.h
-st.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-st.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-st.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-st.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-st.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-st.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-st.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-st.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-st.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-st.$(OBJEXT): {$(VPATH)}internal/iterator.h
-st.$(OBJEXT): {$(VPATH)}internal/memory.h
-st.$(OBJEXT): {$(VPATH)}internal/method.h
-st.$(OBJEXT): {$(VPATH)}internal/module.h
-st.$(OBJEXT): {$(VPATH)}internal/newobj.h
-st.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-st.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-st.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-st.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-st.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-st.$(OBJEXT): {$(VPATH)}internal/symbol.h
-st.$(OBJEXT): {$(VPATH)}internal/value.h
-st.$(OBJEXT): {$(VPATH)}internal/value_type.h
-st.$(OBJEXT): {$(VPATH)}internal/variable.h
-st.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-st.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-st.$(OBJEXT): {$(VPATH)}missing.h
-st.$(OBJEXT): {$(VPATH)}st.c
-st.$(OBJEXT): {$(VPATH)}st.h
-st.$(OBJEXT): {$(VPATH)}subst.h
-strftime.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/serial.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/string.h
-strftime.$(OBJEXT): $(top_srcdir)/internal/vm.h
-strftime.$(OBJEXT): {$(VPATH)}assert.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-strftime.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-strftime.$(OBJEXT): {$(VPATH)}config.h
-strftime.$(OBJEXT): {$(VPATH)}defines.h
-strftime.$(OBJEXT): {$(VPATH)}encoding.h
-strftime.$(OBJEXT): {$(VPATH)}intern.h
-strftime.$(OBJEXT): {$(VPATH)}internal.h
-strftime.$(OBJEXT): {$(VPATH)}internal/abi.h
-strftime.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-strftime.$(OBJEXT): {$(VPATH)}internal/assume.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-strftime.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-strftime.$(OBJEXT): {$(VPATH)}internal/cast.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-strftime.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-strftime.$(OBJEXT): {$(VPATH)}internal/config.h
-strftime.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-strftime.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-strftime.$(OBJEXT): {$(VPATH)}internal/ctype.h
-strftime.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-strftime.$(OBJEXT): {$(VPATH)}internal/dosish.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-strftime.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-strftime.$(OBJEXT): {$(VPATH)}internal/error.h
-strftime.$(OBJEXT): {$(VPATH)}internal/eval.h
-strftime.$(OBJEXT): {$(VPATH)}internal/event.h
-strftime.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-strftime.$(OBJEXT): {$(VPATH)}internal/gc.h
-strftime.$(OBJEXT): {$(VPATH)}internal/glob.h
-strftime.$(OBJEXT): {$(VPATH)}internal/globals.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-strftime.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-strftime.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-strftime.$(OBJEXT): {$(VPATH)}internal/iterator.h
-strftime.$(OBJEXT): {$(VPATH)}internal/memory.h
-strftime.$(OBJEXT): {$(VPATH)}internal/method.h
-strftime.$(OBJEXT): {$(VPATH)}internal/module.h
-strftime.$(OBJEXT): {$(VPATH)}internal/newobj.h
-strftime.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-strftime.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-strftime.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-strftime.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-strftime.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-strftime.$(OBJEXT): {$(VPATH)}internal/symbol.h
-strftime.$(OBJEXT): {$(VPATH)}internal/value.h
-strftime.$(OBJEXT): {$(VPATH)}internal/value_type.h
-strftime.$(OBJEXT): {$(VPATH)}internal/variable.h
-strftime.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-strftime.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-strftime.$(OBJEXT): {$(VPATH)}missing.h
-strftime.$(OBJEXT): {$(VPATH)}onigmo.h
-strftime.$(OBJEXT): {$(VPATH)}oniguruma.h
-strftime.$(OBJEXT): {$(VPATH)}st.h
-strftime.$(OBJEXT): {$(VPATH)}strftime.c
-strftime.$(OBJEXT): {$(VPATH)}subst.h
-strftime.$(OBJEXT): {$(VPATH)}timev.h
-strftime.$(OBJEXT): {$(VPATH)}util.h
-string.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-string.$(OBJEXT): $(top_srcdir)/internal/array.h
-string.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-string.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-string.$(OBJEXT): $(top_srcdir)/internal/bits.h
-string.$(OBJEXT): $(top_srcdir)/internal/class.h
-string.$(OBJEXT): $(top_srcdir)/internal/compar.h
-string.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-string.$(OBJEXT): $(top_srcdir)/internal/encoding.h
-string.$(OBJEXT): $(top_srcdir)/internal/error.h
-string.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-string.$(OBJEXT): $(top_srcdir)/internal/gc.h
-string.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-string.$(OBJEXT): $(top_srcdir)/internal/object.h
-string.$(OBJEXT): $(top_srcdir)/internal/proc.h
-string.$(OBJEXT): $(top_srcdir)/internal/re.h
-string.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-string.$(OBJEXT): $(top_srcdir)/internal/serial.h
-string.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-string.$(OBJEXT): $(top_srcdir)/internal/string.h
-string.$(OBJEXT): $(top_srcdir)/internal/transcode.h
-string.$(OBJEXT): $(top_srcdir)/internal/variable.h
-string.$(OBJEXT): $(top_srcdir)/internal/vm.h
-string.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-string.$(OBJEXT): {$(VPATH)}assert.h
-string.$(OBJEXT): {$(VPATH)}atomic.h
-string.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-string.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-string.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-string.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-string.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-string.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-string.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-string.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-string.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-string.$(OBJEXT): {$(VPATH)}config.h
-string.$(OBJEXT): {$(VPATH)}constant.h
-string.$(OBJEXT): {$(VPATH)}debug_counter.h
-string.$(OBJEXT): {$(VPATH)}defines.h
-string.$(OBJEXT): {$(VPATH)}encindex.h
-string.$(OBJEXT): {$(VPATH)}encoding.h
-string.$(OBJEXT): {$(VPATH)}id.h
-string.$(OBJEXT): {$(VPATH)}id_table.h
-string.$(OBJEXT): {$(VPATH)}intern.h
-string.$(OBJEXT): {$(VPATH)}internal.h
-string.$(OBJEXT): {$(VPATH)}internal/abi.h
-string.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-string.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-string.$(OBJEXT): {$(VPATH)}internal/assume.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-string.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-string.$(OBJEXT): {$(VPATH)}internal/cast.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-string.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-string.$(OBJEXT): {$(VPATH)}internal/config.h
-string.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-string.$(OBJEXT): {$(VPATH)}internal/core.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
-string.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-string.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-string.$(OBJEXT): {$(VPATH)}internal/ctype.h
-string.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-string.$(OBJEXT): {$(VPATH)}internal/dosish.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-string.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-string.$(OBJEXT): {$(VPATH)}internal/error.h
-string.$(OBJEXT): {$(VPATH)}internal/eval.h
-string.$(OBJEXT): {$(VPATH)}internal/event.h
-string.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-string.$(OBJEXT): {$(VPATH)}internal/gc.h
-string.$(OBJEXT): {$(VPATH)}internal/glob.h
-string.$(OBJEXT): {$(VPATH)}internal/globals.h
-string.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-string.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-string.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-string.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-string.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-string.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-string.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-string.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-string.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-string.$(OBJEXT): {$(VPATH)}internal/iterator.h
-string.$(OBJEXT): {$(VPATH)}internal/memory.h
-string.$(OBJEXT): {$(VPATH)}internal/method.h
-string.$(OBJEXT): {$(VPATH)}internal/module.h
-string.$(OBJEXT): {$(VPATH)}internal/newobj.h
-string.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-string.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-string.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-string.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-string.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-string.$(OBJEXT): {$(VPATH)}internal/symbol.h
-string.$(OBJEXT): {$(VPATH)}internal/value.h
-string.$(OBJEXT): {$(VPATH)}internal/value_type.h
-string.$(OBJEXT): {$(VPATH)}internal/variable.h
-string.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-string.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-string.$(OBJEXT): {$(VPATH)}missing.h
-string.$(OBJEXT): {$(VPATH)}onigmo.h
-string.$(OBJEXT): {$(VPATH)}oniguruma.h
-string.$(OBJEXT): {$(VPATH)}probes.dmyh
-string.$(OBJEXT): {$(VPATH)}probes.h
-string.$(OBJEXT): {$(VPATH)}re.h
-string.$(OBJEXT): {$(VPATH)}regex.h
-string.$(OBJEXT): {$(VPATH)}ruby_assert.h
-string.$(OBJEXT): {$(VPATH)}shape.h
-string.$(OBJEXT): {$(VPATH)}st.h
-string.$(OBJEXT): {$(VPATH)}string.c
-string.$(OBJEXT): {$(VPATH)}subst.h
-string.$(OBJEXT): {$(VPATH)}thread_native.h
-string.$(OBJEXT): {$(VPATH)}util.h
-string.$(OBJEXT): {$(VPATH)}vm_debug.h
-string.$(OBJEXT): {$(VPATH)}vm_sync.h
-strlcat.$(OBJEXT): {$(VPATH)}config.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/config.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-strlcat.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-strlcat.$(OBJEXT): {$(VPATH)}missing.h
-strlcat.$(OBJEXT): {$(VPATH)}strlcat.c
-strlcpy.$(OBJEXT): {$(VPATH)}config.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/config.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-strlcpy.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-strlcpy.$(OBJEXT): {$(VPATH)}missing.h
-strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c
-struct.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-struct.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-struct.$(OBJEXT): $(CCAN_DIR)/list/list.h
-struct.$(OBJEXT): $(CCAN_DIR)/str/str.h
-struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-struct.$(OBJEXT): $(top_srcdir)/internal/array.h
-struct.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-struct.$(OBJEXT): $(top_srcdir)/internal/class.h
-struct.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-struct.$(OBJEXT): $(top_srcdir)/internal/error.h
-struct.$(OBJEXT): $(top_srcdir)/internal/gc.h
-struct.$(OBJEXT): $(top_srcdir)/internal/hash.h
-struct.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-struct.$(OBJEXT): $(top_srcdir)/internal/object.h
-struct.$(OBJEXT): $(top_srcdir)/internal/proc.h
-struct.$(OBJEXT): $(top_srcdir)/internal/serial.h
-struct.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-struct.$(OBJEXT): $(top_srcdir)/internal/string.h
-struct.$(OBJEXT): $(top_srcdir)/internal/struct.h
-struct.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-struct.$(OBJEXT): $(top_srcdir)/internal/variable.h
-struct.$(OBJEXT): $(top_srcdir)/internal/vm.h
-struct.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-struct.$(OBJEXT): {$(VPATH)}assert.h
-struct.$(OBJEXT): {$(VPATH)}atomic.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-struct.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-struct.$(OBJEXT): {$(VPATH)}builtin.h
-struct.$(OBJEXT): {$(VPATH)}config.h
-struct.$(OBJEXT): {$(VPATH)}constant.h
-struct.$(OBJEXT): {$(VPATH)}defines.h
-struct.$(OBJEXT): {$(VPATH)}encoding.h
-struct.$(OBJEXT): {$(VPATH)}id.h
-struct.$(OBJEXT): {$(VPATH)}id_table.h
-struct.$(OBJEXT): {$(VPATH)}intern.h
-struct.$(OBJEXT): {$(VPATH)}internal.h
-struct.$(OBJEXT): {$(VPATH)}internal/abi.h
-struct.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-struct.$(OBJEXT): {$(VPATH)}internal/assume.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-struct.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-struct.$(OBJEXT): {$(VPATH)}internal/cast.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-struct.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-struct.$(OBJEXT): {$(VPATH)}internal/config.h
-struct.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-struct.$(OBJEXT): {$(VPATH)}internal/core.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-struct.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-struct.$(OBJEXT): {$(VPATH)}internal/ctype.h
-struct.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-struct.$(OBJEXT): {$(VPATH)}internal/dosish.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-struct.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-struct.$(OBJEXT): {$(VPATH)}internal/error.h
-struct.$(OBJEXT): {$(VPATH)}internal/eval.h
-struct.$(OBJEXT): {$(VPATH)}internal/event.h
-struct.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-struct.$(OBJEXT): {$(VPATH)}internal/gc.h
-struct.$(OBJEXT): {$(VPATH)}internal/glob.h
-struct.$(OBJEXT): {$(VPATH)}internal/globals.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-struct.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-struct.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-struct.$(OBJEXT): {$(VPATH)}internal/iterator.h
-struct.$(OBJEXT): {$(VPATH)}internal/memory.h
-struct.$(OBJEXT): {$(VPATH)}internal/method.h
-struct.$(OBJEXT): {$(VPATH)}internal/module.h
-struct.$(OBJEXT): {$(VPATH)}internal/newobj.h
-struct.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-struct.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-struct.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-struct.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-struct.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-struct.$(OBJEXT): {$(VPATH)}internal/symbol.h
-struct.$(OBJEXT): {$(VPATH)}internal/value.h
-struct.$(OBJEXT): {$(VPATH)}internal/value_type.h
-struct.$(OBJEXT): {$(VPATH)}internal/variable.h
-struct.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-struct.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-struct.$(OBJEXT): {$(VPATH)}method.h
-struct.$(OBJEXT): {$(VPATH)}missing.h
-struct.$(OBJEXT): {$(VPATH)}node.h
-struct.$(OBJEXT): {$(VPATH)}onigmo.h
-struct.$(OBJEXT): {$(VPATH)}oniguruma.h
-struct.$(OBJEXT): {$(VPATH)}ruby_assert.h
-struct.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-struct.$(OBJEXT): {$(VPATH)}shape.h
-struct.$(OBJEXT): {$(VPATH)}st.h
-struct.$(OBJEXT): {$(VPATH)}struct.c
-struct.$(OBJEXT): {$(VPATH)}subst.h
-struct.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-struct.$(OBJEXT): {$(VPATH)}thread_native.h
-struct.$(OBJEXT): {$(VPATH)}transient_heap.h
-struct.$(OBJEXT): {$(VPATH)}vm_core.h
-struct.$(OBJEXT): {$(VPATH)}vm_opts.h
-symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/class.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/error.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/gc.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/hash.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/object.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/serial.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/string.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/variable.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/vm.h
-symbol.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-symbol.$(OBJEXT): {$(VPATH)}assert.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-symbol.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-symbol.$(OBJEXT): {$(VPATH)}builtin.h
-symbol.$(OBJEXT): {$(VPATH)}config.h
-symbol.$(OBJEXT): {$(VPATH)}constant.h
-symbol.$(OBJEXT): {$(VPATH)}debug_counter.h
-symbol.$(OBJEXT): {$(VPATH)}defines.h
-symbol.$(OBJEXT): {$(VPATH)}encoding.h
-symbol.$(OBJEXT): {$(VPATH)}id.c
-symbol.$(OBJEXT): {$(VPATH)}id.h
-symbol.$(OBJEXT): {$(VPATH)}id_table.c
-symbol.$(OBJEXT): {$(VPATH)}id_table.h
-symbol.$(OBJEXT): {$(VPATH)}intern.h
-symbol.$(OBJEXT): {$(VPATH)}internal.h
-symbol.$(OBJEXT): {$(VPATH)}internal/abi.h
-symbol.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-symbol.$(OBJEXT): {$(VPATH)}internal/assume.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-symbol.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-symbol.$(OBJEXT): {$(VPATH)}internal/cast.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-symbol.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-symbol.$(OBJEXT): {$(VPATH)}internal/config.h
-symbol.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-symbol.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-symbol.$(OBJEXT): {$(VPATH)}internal/ctype.h
-symbol.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-symbol.$(OBJEXT): {$(VPATH)}internal/dosish.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-symbol.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-symbol.$(OBJEXT): {$(VPATH)}internal/error.h
-symbol.$(OBJEXT): {$(VPATH)}internal/eval.h
-symbol.$(OBJEXT): {$(VPATH)}internal/event.h
-symbol.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-symbol.$(OBJEXT): {$(VPATH)}internal/gc.h
-symbol.$(OBJEXT): {$(VPATH)}internal/glob.h
-symbol.$(OBJEXT): {$(VPATH)}internal/globals.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-symbol.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-symbol.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-symbol.$(OBJEXT): {$(VPATH)}internal/iterator.h
-symbol.$(OBJEXT): {$(VPATH)}internal/memory.h
-symbol.$(OBJEXT): {$(VPATH)}internal/method.h
-symbol.$(OBJEXT): {$(VPATH)}internal/module.h
-symbol.$(OBJEXT): {$(VPATH)}internal/newobj.h
-symbol.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-symbol.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-symbol.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-symbol.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-symbol.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-symbol.$(OBJEXT): {$(VPATH)}internal/symbol.h
-symbol.$(OBJEXT): {$(VPATH)}internal/value.h
-symbol.$(OBJEXT): {$(VPATH)}internal/value_type.h
-symbol.$(OBJEXT): {$(VPATH)}internal/variable.h
-symbol.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-symbol.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-symbol.$(OBJEXT): {$(VPATH)}missing.h
-symbol.$(OBJEXT): {$(VPATH)}onigmo.h
-symbol.$(OBJEXT): {$(VPATH)}oniguruma.h
-symbol.$(OBJEXT): {$(VPATH)}probes.dmyh
-symbol.$(OBJEXT): {$(VPATH)}probes.h
-symbol.$(OBJEXT): {$(VPATH)}ruby_assert.h
-symbol.$(OBJEXT): {$(VPATH)}shape.h
-symbol.$(OBJEXT): {$(VPATH)}st.h
-symbol.$(OBJEXT): {$(VPATH)}subst.h
-symbol.$(OBJEXT): {$(VPATH)}symbol.c
-symbol.$(OBJEXT): {$(VPATH)}symbol.h
-symbol.$(OBJEXT): {$(VPATH)}symbol.rb
-symbol.$(OBJEXT): {$(VPATH)}symbol.rbinc
-symbol.$(OBJEXT): {$(VPATH)}vm_debug.h
-symbol.$(OBJEXT): {$(VPATH)}vm_sync.h
-thread.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-thread.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-thread.$(OBJEXT): $(CCAN_DIR)/list/list.h
-thread.$(OBJEXT): $(CCAN_DIR)/str/str.h
-thread.$(OBJEXT): $(hdrdir)/ruby.h
-thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-thread.$(OBJEXT): $(top_srcdir)/internal/array.h
-thread.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-thread.$(OBJEXT): $(top_srcdir)/internal/bits.h
-thread.$(OBJEXT): $(top_srcdir)/internal/class.h
-thread.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-thread.$(OBJEXT): $(top_srcdir)/internal/cont.h
-thread.$(OBJEXT): $(top_srcdir)/internal/error.h
-thread.$(OBJEXT): $(top_srcdir)/internal/gc.h
-thread.$(OBJEXT): $(top_srcdir)/internal/hash.h
-thread.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-thread.$(OBJEXT): $(top_srcdir)/internal/io.h
-thread.$(OBJEXT): $(top_srcdir)/internal/object.h
-thread.$(OBJEXT): $(top_srcdir)/internal/proc.h
-thread.$(OBJEXT): $(top_srcdir)/internal/serial.h
-thread.$(OBJEXT): $(top_srcdir)/internal/signal.h
-thread.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-thread.$(OBJEXT): $(top_srcdir)/internal/string.h
-thread.$(OBJEXT): $(top_srcdir)/internal/thread.h
-thread.$(OBJEXT): $(top_srcdir)/internal/time.h
-thread.$(OBJEXT): $(top_srcdir)/internal/variable.h
-thread.$(OBJEXT): $(top_srcdir)/internal/vm.h
-thread.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-thread.$(OBJEXT): {$(VPATH)}assert.h
-thread.$(OBJEXT): {$(VPATH)}atomic.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-thread.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-thread.$(OBJEXT): {$(VPATH)}builtin.h
-thread.$(OBJEXT): {$(VPATH)}config.h
-thread.$(OBJEXT): {$(VPATH)}constant.h
-thread.$(OBJEXT): {$(VPATH)}debug.h
-thread.$(OBJEXT): {$(VPATH)}debug_counter.h
-thread.$(OBJEXT): {$(VPATH)}defines.h
-thread.$(OBJEXT): {$(VPATH)}encoding.h
-thread.$(OBJEXT): {$(VPATH)}eval_intern.h
-thread.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-thread.$(OBJEXT): {$(VPATH)}hrtime.h
-thread.$(OBJEXT): {$(VPATH)}id.h
-thread.$(OBJEXT): {$(VPATH)}id_table.h
-thread.$(OBJEXT): {$(VPATH)}intern.h
-thread.$(OBJEXT): {$(VPATH)}internal.h
-thread.$(OBJEXT): {$(VPATH)}internal/abi.h
-thread.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-thread.$(OBJEXT): {$(VPATH)}internal/assume.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-thread.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-thread.$(OBJEXT): {$(VPATH)}internal/cast.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-thread.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-thread.$(OBJEXT): {$(VPATH)}internal/config.h
-thread.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-thread.$(OBJEXT): {$(VPATH)}internal/core.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-thread.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-thread.$(OBJEXT): {$(VPATH)}internal/ctype.h
-thread.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-thread.$(OBJEXT): {$(VPATH)}internal/dosish.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-thread.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-thread.$(OBJEXT): {$(VPATH)}internal/error.h
-thread.$(OBJEXT): {$(VPATH)}internal/eval.h
-thread.$(OBJEXT): {$(VPATH)}internal/event.h
-thread.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-thread.$(OBJEXT): {$(VPATH)}internal/gc.h
-thread.$(OBJEXT): {$(VPATH)}internal/glob.h
-thread.$(OBJEXT): {$(VPATH)}internal/globals.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-thread.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-thread.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-thread.$(OBJEXT): {$(VPATH)}internal/iterator.h
-thread.$(OBJEXT): {$(VPATH)}internal/memory.h
-thread.$(OBJEXT): {$(VPATH)}internal/method.h
-thread.$(OBJEXT): {$(VPATH)}internal/module.h
-thread.$(OBJEXT): {$(VPATH)}internal/newobj.h
-thread.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-thread.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-thread.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-thread.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-thread.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-thread.$(OBJEXT): {$(VPATH)}internal/symbol.h
-thread.$(OBJEXT): {$(VPATH)}internal/value.h
-thread.$(OBJEXT): {$(VPATH)}internal/value_type.h
-thread.$(OBJEXT): {$(VPATH)}internal/variable.h
-thread.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-thread.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-thread.$(OBJEXT): {$(VPATH)}io.h
-thread.$(OBJEXT): {$(VPATH)}iseq.h
-thread.$(OBJEXT): {$(VPATH)}method.h
-thread.$(OBJEXT): {$(VPATH)}missing.h
-thread.$(OBJEXT): {$(VPATH)}node.h
-thread.$(OBJEXT): {$(VPATH)}onigmo.h
-thread.$(OBJEXT): {$(VPATH)}oniguruma.h
-thread.$(OBJEXT): {$(VPATH)}ractor.h
-thread.$(OBJEXT): {$(VPATH)}ractor_core.h
-thread.$(OBJEXT): {$(VPATH)}rjit.h
-thread.$(OBJEXT): {$(VPATH)}ruby_assert.h
-thread.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-thread.$(OBJEXT): {$(VPATH)}shape.h
-thread.$(OBJEXT): {$(VPATH)}st.h
-thread.$(OBJEXT): {$(VPATH)}subst.h
-thread.$(OBJEXT): {$(VPATH)}thread.c
-thread.$(OBJEXT): {$(VPATH)}thread.h
-thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).c
-thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-thread.$(OBJEXT): {$(VPATH)}thread_native.h
-thread.$(OBJEXT): {$(VPATH)}thread_sync.c
-thread.$(OBJEXT): {$(VPATH)}thread_sync.rbinc
-thread.$(OBJEXT): {$(VPATH)}timev.h
-thread.$(OBJEXT): {$(VPATH)}vm_core.h
-thread.$(OBJEXT): {$(VPATH)}vm_debug.h
-thread.$(OBJEXT): {$(VPATH)}vm_opts.h
-thread.$(OBJEXT): {$(VPATH)}vm_sync.h
-time.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-time.$(OBJEXT): $(top_srcdir)/internal/array.h
-time.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-time.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-time.$(OBJEXT): $(top_srcdir)/internal/bits.h
-time.$(OBJEXT): $(top_srcdir)/internal/compar.h
-time.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-time.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-time.$(OBJEXT): $(top_srcdir)/internal/gc.h
-time.$(OBJEXT): $(top_srcdir)/internal/hash.h
-time.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-time.$(OBJEXT): $(top_srcdir)/internal/rational.h
-time.$(OBJEXT): $(top_srcdir)/internal/serial.h
-time.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-time.$(OBJEXT): $(top_srcdir)/internal/string.h
-time.$(OBJEXT): $(top_srcdir)/internal/time.h
-time.$(OBJEXT): $(top_srcdir)/internal/variable.h
-time.$(OBJEXT): $(top_srcdir)/internal/vm.h
-time.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-time.$(OBJEXT): {$(VPATH)}assert.h
-time.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-time.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-time.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-time.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-time.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-time.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-time.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-time.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-time.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-time.$(OBJEXT): {$(VPATH)}builtin.h
-time.$(OBJEXT): {$(VPATH)}config.h
-time.$(OBJEXT): {$(VPATH)}constant.h
-time.$(OBJEXT): {$(VPATH)}defines.h
-time.$(OBJEXT): {$(VPATH)}encoding.h
-time.$(OBJEXT): {$(VPATH)}id.h
-time.$(OBJEXT): {$(VPATH)}id_table.h
-time.$(OBJEXT): {$(VPATH)}intern.h
-time.$(OBJEXT): {$(VPATH)}internal.h
-time.$(OBJEXT): {$(VPATH)}internal/abi.h
-time.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-time.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-time.$(OBJEXT): {$(VPATH)}internal/assume.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-time.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-time.$(OBJEXT): {$(VPATH)}internal/cast.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-time.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-time.$(OBJEXT): {$(VPATH)}internal/config.h
-time.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-time.$(OBJEXT): {$(VPATH)}internal/core.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-time.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-time.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-time.$(OBJEXT): {$(VPATH)}internal/ctype.h
-time.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-time.$(OBJEXT): {$(VPATH)}internal/dosish.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-time.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-time.$(OBJEXT): {$(VPATH)}internal/error.h
-time.$(OBJEXT): {$(VPATH)}internal/eval.h
-time.$(OBJEXT): {$(VPATH)}internal/event.h
-time.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-time.$(OBJEXT): {$(VPATH)}internal/gc.h
-time.$(OBJEXT): {$(VPATH)}internal/glob.h
-time.$(OBJEXT): {$(VPATH)}internal/globals.h
-time.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-time.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-time.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-time.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-time.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-time.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-time.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-time.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-time.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-time.$(OBJEXT): {$(VPATH)}internal/iterator.h
-time.$(OBJEXT): {$(VPATH)}internal/memory.h
-time.$(OBJEXT): {$(VPATH)}internal/method.h
-time.$(OBJEXT): {$(VPATH)}internal/module.h
-time.$(OBJEXT): {$(VPATH)}internal/newobj.h
-time.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-time.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-time.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-time.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-time.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-time.$(OBJEXT): {$(VPATH)}internal/symbol.h
-time.$(OBJEXT): {$(VPATH)}internal/value.h
-time.$(OBJEXT): {$(VPATH)}internal/value_type.h
-time.$(OBJEXT): {$(VPATH)}internal/variable.h
-time.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-time.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-time.$(OBJEXT): {$(VPATH)}missing.h
-time.$(OBJEXT): {$(VPATH)}onigmo.h
-time.$(OBJEXT): {$(VPATH)}oniguruma.h
-time.$(OBJEXT): {$(VPATH)}ruby_assert.h
-time.$(OBJEXT): {$(VPATH)}shape.h
-time.$(OBJEXT): {$(VPATH)}st.h
-time.$(OBJEXT): {$(VPATH)}subst.h
-time.$(OBJEXT): {$(VPATH)}time.c
-time.$(OBJEXT): {$(VPATH)}timev.h
-time.$(OBJEXT): {$(VPATH)}timev.rbinc
-transcode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/array.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/class.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/gc.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/inits.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/object.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/serial.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/string.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/transcode.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/variable.h
-transcode.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-transcode.$(OBJEXT): {$(VPATH)}assert.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-transcode.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-transcode.$(OBJEXT): {$(VPATH)}config.h
-transcode.$(OBJEXT): {$(VPATH)}constant.h
-transcode.$(OBJEXT): {$(VPATH)}defines.h
-transcode.$(OBJEXT): {$(VPATH)}encoding.h
-transcode.$(OBJEXT): {$(VPATH)}id.h
-transcode.$(OBJEXT): {$(VPATH)}id_table.h
-transcode.$(OBJEXT): {$(VPATH)}intern.h
-transcode.$(OBJEXT): {$(VPATH)}internal.h
-transcode.$(OBJEXT): {$(VPATH)}internal/abi.h
-transcode.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-transcode.$(OBJEXT): {$(VPATH)}internal/assume.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-transcode.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-transcode.$(OBJEXT): {$(VPATH)}internal/cast.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-transcode.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-transcode.$(OBJEXT): {$(VPATH)}internal/config.h
-transcode.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-transcode.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-transcode.$(OBJEXT): {$(VPATH)}internal/ctype.h
-transcode.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-transcode.$(OBJEXT): {$(VPATH)}internal/dosish.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-transcode.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-transcode.$(OBJEXT): {$(VPATH)}internal/error.h
-transcode.$(OBJEXT): {$(VPATH)}internal/eval.h
-transcode.$(OBJEXT): {$(VPATH)}internal/event.h
-transcode.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-transcode.$(OBJEXT): {$(VPATH)}internal/gc.h
-transcode.$(OBJEXT): {$(VPATH)}internal/glob.h
-transcode.$(OBJEXT): {$(VPATH)}internal/globals.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-transcode.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-transcode.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-transcode.$(OBJEXT): {$(VPATH)}internal/iterator.h
-transcode.$(OBJEXT): {$(VPATH)}internal/memory.h
-transcode.$(OBJEXT): {$(VPATH)}internal/method.h
-transcode.$(OBJEXT): {$(VPATH)}internal/module.h
-transcode.$(OBJEXT): {$(VPATH)}internal/newobj.h
-transcode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-transcode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-transcode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-transcode.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-transcode.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-transcode.$(OBJEXT): {$(VPATH)}internal/symbol.h
-transcode.$(OBJEXT): {$(VPATH)}internal/value.h
-transcode.$(OBJEXT): {$(VPATH)}internal/value_type.h
-transcode.$(OBJEXT): {$(VPATH)}internal/variable.h
-transcode.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-transcode.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-transcode.$(OBJEXT): {$(VPATH)}missing.h
-transcode.$(OBJEXT): {$(VPATH)}onigmo.h
-transcode.$(OBJEXT): {$(VPATH)}oniguruma.h
-transcode.$(OBJEXT): {$(VPATH)}shape.h
-transcode.$(OBJEXT): {$(VPATH)}st.h
-transcode.$(OBJEXT): {$(VPATH)}subst.h
-transcode.$(OBJEXT): {$(VPATH)}transcode.c
-transcode.$(OBJEXT): {$(VPATH)}transcode_data.h
-transient_heap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/array.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/gc.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/hash.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/struct.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/variable.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-transient_heap.$(OBJEXT): {$(VPATH)}assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-transient_heap.$(OBJEXT): {$(VPATH)}config.h
-transient_heap.$(OBJEXT): {$(VPATH)}constant.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug_counter.h
-transient_heap.$(OBJEXT): {$(VPATH)}defines.h
-transient_heap.$(OBJEXT): {$(VPATH)}id_table.h
-transient_heap.$(OBJEXT): {$(VPATH)}intern.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/abi.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/assume.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/cast.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/config.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/ctype.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/dosish.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/eval.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/event.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/gc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/glob.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/globals.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/iterator.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/memory.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/method.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/module.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/newobj.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/symbol.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/value.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/value_type.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/variable.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-transient_heap.$(OBJEXT): {$(VPATH)}missing.h
-transient_heap.$(OBJEXT): {$(VPATH)}ruby_assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}shape.h
-transient_heap.$(OBJEXT): {$(VPATH)}st.h
-transient_heap.$(OBJEXT): {$(VPATH)}subst.h
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.c
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.h
-transient_heap.$(OBJEXT): {$(VPATH)}vm_debug.h
-transient_heap.$(OBJEXT): {$(VPATH)}vm_sync.h
-util.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-util.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-util.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-util.$(OBJEXT): $(top_srcdir)/internal/util.h
-util.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-util.$(OBJEXT): {$(VPATH)}assert.h
-util.$(OBJEXT): {$(VPATH)}atomic.h
-util.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-util.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-util.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-util.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-util.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-util.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-util.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-util.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-util.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-util.$(OBJEXT): {$(VPATH)}config.h
-util.$(OBJEXT): {$(VPATH)}defines.h
-util.$(OBJEXT): {$(VPATH)}dtoa.c
-util.$(OBJEXT): {$(VPATH)}intern.h
-util.$(OBJEXT): {$(VPATH)}internal.h
-util.$(OBJEXT): {$(VPATH)}internal/abi.h
-util.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-util.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-util.$(OBJEXT): {$(VPATH)}internal/assume.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-util.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-util.$(OBJEXT): {$(VPATH)}internal/cast.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-util.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-util.$(OBJEXT): {$(VPATH)}internal/config.h
-util.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-util.$(OBJEXT): {$(VPATH)}internal/core.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-util.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-util.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-util.$(OBJEXT): {$(VPATH)}internal/ctype.h
-util.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-util.$(OBJEXT): {$(VPATH)}internal/dosish.h
-util.$(OBJEXT): {$(VPATH)}internal/error.h
-util.$(OBJEXT): {$(VPATH)}internal/eval.h
-util.$(OBJEXT): {$(VPATH)}internal/event.h
-util.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-util.$(OBJEXT): {$(VPATH)}internal/gc.h
-util.$(OBJEXT): {$(VPATH)}internal/glob.h
-util.$(OBJEXT): {$(VPATH)}internal/globals.h
-util.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-util.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-util.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-util.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-util.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-util.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-util.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-util.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-util.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-util.$(OBJEXT): {$(VPATH)}internal/iterator.h
-util.$(OBJEXT): {$(VPATH)}internal/memory.h
-util.$(OBJEXT): {$(VPATH)}internal/method.h
-util.$(OBJEXT): {$(VPATH)}internal/module.h
-util.$(OBJEXT): {$(VPATH)}internal/newobj.h
-util.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-util.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-util.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-util.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-util.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-util.$(OBJEXT): {$(VPATH)}internal/symbol.h
-util.$(OBJEXT): {$(VPATH)}internal/value.h
-util.$(OBJEXT): {$(VPATH)}internal/value_type.h
-util.$(OBJEXT): {$(VPATH)}internal/variable.h
-util.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-util.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-util.$(OBJEXT): {$(VPATH)}missing.h
-util.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-util.$(OBJEXT): {$(VPATH)}st.h
-util.$(OBJEXT): {$(VPATH)}subst.h
-util.$(OBJEXT): {$(VPATH)}util.c
-util.$(OBJEXT): {$(VPATH)}util.h
-variable.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-variable.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-variable.$(OBJEXT): $(CCAN_DIR)/list/list.h
-variable.$(OBJEXT): $(CCAN_DIR)/str/str.h
-variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-variable.$(OBJEXT): $(top_srcdir)/internal/array.h
-variable.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-variable.$(OBJEXT): $(top_srcdir)/internal/class.h
-variable.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-variable.$(OBJEXT): $(top_srcdir)/internal/error.h
-variable.$(OBJEXT): $(top_srcdir)/internal/eval.h
-variable.$(OBJEXT): $(top_srcdir)/internal/gc.h
-variable.$(OBJEXT): $(top_srcdir)/internal/hash.h
-variable.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-variable.$(OBJEXT): $(top_srcdir)/internal/object.h
-variable.$(OBJEXT): $(top_srcdir)/internal/re.h
-variable.$(OBJEXT): $(top_srcdir)/internal/serial.h
-variable.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-variable.$(OBJEXT): $(top_srcdir)/internal/string.h
-variable.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-variable.$(OBJEXT): $(top_srcdir)/internal/thread.h
-variable.$(OBJEXT): $(top_srcdir)/internal/variable.h
-variable.$(OBJEXT): $(top_srcdir)/internal/vm.h
-variable.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-variable.$(OBJEXT): {$(VPATH)}assert.h
-variable.$(OBJEXT): {$(VPATH)}atomic.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-variable.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-variable.$(OBJEXT): {$(VPATH)}config.h
-variable.$(OBJEXT): {$(VPATH)}constant.h
-variable.$(OBJEXT): {$(VPATH)}debug_counter.h
-variable.$(OBJEXT): {$(VPATH)}defines.h
-variable.$(OBJEXT): {$(VPATH)}encoding.h
-variable.$(OBJEXT): {$(VPATH)}id.h
-variable.$(OBJEXT): {$(VPATH)}id_table.h
-variable.$(OBJEXT): {$(VPATH)}intern.h
-variable.$(OBJEXT): {$(VPATH)}internal.h
-variable.$(OBJEXT): {$(VPATH)}internal/abi.h
-variable.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-variable.$(OBJEXT): {$(VPATH)}internal/assume.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-variable.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-variable.$(OBJEXT): {$(VPATH)}internal/cast.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-variable.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-variable.$(OBJEXT): {$(VPATH)}internal/config.h
-variable.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-variable.$(OBJEXT): {$(VPATH)}internal/core.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-variable.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-variable.$(OBJEXT): {$(VPATH)}internal/ctype.h
-variable.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-variable.$(OBJEXT): {$(VPATH)}internal/dosish.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-variable.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-variable.$(OBJEXT): {$(VPATH)}internal/error.h
-variable.$(OBJEXT): {$(VPATH)}internal/eval.h
-variable.$(OBJEXT): {$(VPATH)}internal/event.h
-variable.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-variable.$(OBJEXT): {$(VPATH)}internal/gc.h
-variable.$(OBJEXT): {$(VPATH)}internal/glob.h
-variable.$(OBJEXT): {$(VPATH)}internal/globals.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-variable.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-variable.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-variable.$(OBJEXT): {$(VPATH)}internal/iterator.h
-variable.$(OBJEXT): {$(VPATH)}internal/memory.h
-variable.$(OBJEXT): {$(VPATH)}internal/method.h
-variable.$(OBJEXT): {$(VPATH)}internal/module.h
-variable.$(OBJEXT): {$(VPATH)}internal/newobj.h
-variable.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-variable.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-variable.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-variable.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-variable.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-variable.$(OBJEXT): {$(VPATH)}internal/symbol.h
-variable.$(OBJEXT): {$(VPATH)}internal/value.h
-variable.$(OBJEXT): {$(VPATH)}internal/value_type.h
-variable.$(OBJEXT): {$(VPATH)}internal/variable.h
-variable.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-variable.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-variable.$(OBJEXT): {$(VPATH)}method.h
-variable.$(OBJEXT): {$(VPATH)}missing.h
-variable.$(OBJEXT): {$(VPATH)}node.h
-variable.$(OBJEXT): {$(VPATH)}onigmo.h
-variable.$(OBJEXT): {$(VPATH)}oniguruma.h
-variable.$(OBJEXT): {$(VPATH)}ractor.h
-variable.$(OBJEXT): {$(VPATH)}ractor_core.h
-variable.$(OBJEXT): {$(VPATH)}ruby_assert.h
-variable.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-variable.$(OBJEXT): {$(VPATH)}shape.h
-variable.$(OBJEXT): {$(VPATH)}st.h
-variable.$(OBJEXT): {$(VPATH)}subst.h
-variable.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-variable.$(OBJEXT): {$(VPATH)}thread_native.h
-variable.$(OBJEXT): {$(VPATH)}transient_heap.h
-variable.$(OBJEXT): {$(VPATH)}util.h
-variable.$(OBJEXT): {$(VPATH)}variable.c
-variable.$(OBJEXT): {$(VPATH)}variable.h
-variable.$(OBJEXT): {$(VPATH)}vm_core.h
-variable.$(OBJEXT): {$(VPATH)}vm_debug.h
-variable.$(OBJEXT): {$(VPATH)}vm_opts.h
-variable.$(OBJEXT): {$(VPATH)}vm_sync.h
-version.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-version.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-version.$(OBJEXT): $(CCAN_DIR)/list/list.h
-version.$(OBJEXT): $(CCAN_DIR)/str/str.h
-version.$(OBJEXT): $(hdrdir)/ruby.h
-version.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-version.$(OBJEXT): $(hdrdir)/ruby/version.h
-version.$(OBJEXT): $(top_srcdir)/internal/array.h
-version.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-version.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
-version.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-version.$(OBJEXT): $(top_srcdir)/internal/gc.h
-version.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-version.$(OBJEXT): $(top_srcdir)/internal/serial.h
-version.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-version.$(OBJEXT): $(top_srcdir)/internal/variable.h
-version.$(OBJEXT): $(top_srcdir)/internal/vm.h
-version.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-version.$(OBJEXT): $(top_srcdir)/version.h
-version.$(OBJEXT): {$(VPATH)}assert.h
-version.$(OBJEXT): {$(VPATH)}atomic.h
-version.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-version.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-version.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-version.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-version.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-version.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-version.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-version.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-version.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-version.$(OBJEXT): {$(VPATH)}config.h
-version.$(OBJEXT): {$(VPATH)}constant.h
-version.$(OBJEXT): {$(VPATH)}debug_counter.h
-version.$(OBJEXT): {$(VPATH)}defines.h
-version.$(OBJEXT): {$(VPATH)}id.h
-version.$(OBJEXT): {$(VPATH)}id_table.h
-version.$(OBJEXT): {$(VPATH)}intern.h
-version.$(OBJEXT): {$(VPATH)}internal.h
-version.$(OBJEXT): {$(VPATH)}internal/abi.h
-version.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-version.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-version.$(OBJEXT): {$(VPATH)}internal/assume.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-version.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-version.$(OBJEXT): {$(VPATH)}internal/cast.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-version.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-version.$(OBJEXT): {$(VPATH)}internal/config.h
-version.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-version.$(OBJEXT): {$(VPATH)}internal/core.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-version.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-version.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-version.$(OBJEXT): {$(VPATH)}internal/ctype.h
-version.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-version.$(OBJEXT): {$(VPATH)}internal/dosish.h
-version.$(OBJEXT): {$(VPATH)}internal/error.h
-version.$(OBJEXT): {$(VPATH)}internal/eval.h
-version.$(OBJEXT): {$(VPATH)}internal/event.h
-version.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-version.$(OBJEXT): {$(VPATH)}internal/gc.h
-version.$(OBJEXT): {$(VPATH)}internal/glob.h
-version.$(OBJEXT): {$(VPATH)}internal/globals.h
-version.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-version.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-version.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-version.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-version.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-version.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-version.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-version.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-version.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-version.$(OBJEXT): {$(VPATH)}internal/iterator.h
-version.$(OBJEXT): {$(VPATH)}internal/memory.h
-version.$(OBJEXT): {$(VPATH)}internal/method.h
-version.$(OBJEXT): {$(VPATH)}internal/module.h
-version.$(OBJEXT): {$(VPATH)}internal/newobj.h
-version.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-version.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-version.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-version.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-version.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-version.$(OBJEXT): {$(VPATH)}internal/symbol.h
-version.$(OBJEXT): {$(VPATH)}internal/value.h
-version.$(OBJEXT): {$(VPATH)}internal/value_type.h
-version.$(OBJEXT): {$(VPATH)}internal/variable.h
-version.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-version.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-version.$(OBJEXT): {$(VPATH)}method.h
-version.$(OBJEXT): {$(VPATH)}missing.h
-version.$(OBJEXT): {$(VPATH)}node.h
-version.$(OBJEXT): {$(VPATH)}revision.h
-version.$(OBJEXT): {$(VPATH)}rjit.h
-version.$(OBJEXT): {$(VPATH)}ruby_assert.h
-version.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-version.$(OBJEXT): {$(VPATH)}shape.h
-version.$(OBJEXT): {$(VPATH)}st.h
-version.$(OBJEXT): {$(VPATH)}subst.h
-version.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-version.$(OBJEXT): {$(VPATH)}thread_native.h
-version.$(OBJEXT): {$(VPATH)}version.c
-version.$(OBJEXT): {$(VPATH)}vm_core.h
-version.$(OBJEXT): {$(VPATH)}vm_opts.h
-version.$(OBJEXT): {$(VPATH)}yjit.h
-vm.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-vm.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-vm.$(OBJEXT): $(CCAN_DIR)/list/list.h
-vm.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm.$(OBJEXT): $(hdrdir)/ruby.h
-vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm.$(OBJEXT): $(top_srcdir)/internal/array.h
-vm.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-vm.$(OBJEXT): $(top_srcdir)/internal/bignum.h
-vm.$(OBJEXT): $(top_srcdir)/internal/bits.h
-vm.$(OBJEXT): $(top_srcdir)/internal/class.h
-vm.$(OBJEXT): $(top_srcdir)/internal/compar.h
-vm.$(OBJEXT): $(top_srcdir)/internal/compile.h
-vm.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-vm.$(OBJEXT): $(top_srcdir)/internal/cont.h
-vm.$(OBJEXT): $(top_srcdir)/internal/error.h
-vm.$(OBJEXT): $(top_srcdir)/internal/eval.h
-vm.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-vm.$(OBJEXT): $(top_srcdir)/internal/gc.h
-vm.$(OBJEXT): $(top_srcdir)/internal/hash.h
-vm.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-vm.$(OBJEXT): $(top_srcdir)/internal/inits.h
-vm.$(OBJEXT): $(top_srcdir)/internal/numeric.h
-vm.$(OBJEXT): $(top_srcdir)/internal/object.h
-vm.$(OBJEXT): $(top_srcdir)/internal/parse.h
-vm.$(OBJEXT): $(top_srcdir)/internal/proc.h
-vm.$(OBJEXT): $(top_srcdir)/internal/random.h
-vm.$(OBJEXT): $(top_srcdir)/internal/re.h
-vm.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-vm.$(OBJEXT): $(top_srcdir)/internal/serial.h
-vm.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-vm.$(OBJEXT): $(top_srcdir)/internal/string.h
-vm.$(OBJEXT): $(top_srcdir)/internal/struct.h
-vm.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-vm.$(OBJEXT): $(top_srcdir)/internal/thread.h
-vm.$(OBJEXT): $(top_srcdir)/internal/variable.h
-vm.$(OBJEXT): $(top_srcdir)/internal/vm.h
-vm.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-vm.$(OBJEXT): {$(VPATH)}assert.h
-vm.$(OBJEXT): {$(VPATH)}atomic.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-vm.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-vm.$(OBJEXT): {$(VPATH)}builtin.h
-vm.$(OBJEXT): {$(VPATH)}config.h
-vm.$(OBJEXT): {$(VPATH)}constant.h
-vm.$(OBJEXT): {$(VPATH)}debug_counter.h
-vm.$(OBJEXT): {$(VPATH)}defines.h
-vm.$(OBJEXT): {$(VPATH)}defs/opt_operand.def
-vm.$(OBJEXT): {$(VPATH)}encoding.h
-vm.$(OBJEXT): {$(VPATH)}eval_intern.h
-vm.$(OBJEXT): {$(VPATH)}id.h
-vm.$(OBJEXT): {$(VPATH)}id_table.h
-vm.$(OBJEXT): {$(VPATH)}insns.def
-vm.$(OBJEXT): {$(VPATH)}insns.inc
-vm.$(OBJEXT): {$(VPATH)}insns_info.inc
-vm.$(OBJEXT): {$(VPATH)}intern.h
-vm.$(OBJEXT): {$(VPATH)}internal.h
-vm.$(OBJEXT): {$(VPATH)}internal/abi.h
-vm.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-vm.$(OBJEXT): {$(VPATH)}internal/assume.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-vm.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-vm.$(OBJEXT): {$(VPATH)}internal/cast.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-vm.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-vm.$(OBJEXT): {$(VPATH)}internal/config.h
-vm.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-vm.$(OBJEXT): {$(VPATH)}internal/core.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-vm.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-vm.$(OBJEXT): {$(VPATH)}internal/ctype.h
-vm.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-vm.$(OBJEXT): {$(VPATH)}internal/dosish.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-vm.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-vm.$(OBJEXT): {$(VPATH)}internal/error.h
-vm.$(OBJEXT): {$(VPATH)}internal/eval.h
-vm.$(OBJEXT): {$(VPATH)}internal/event.h
-vm.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-vm.$(OBJEXT): {$(VPATH)}internal/gc.h
-vm.$(OBJEXT): {$(VPATH)}internal/glob.h
-vm.$(OBJEXT): {$(VPATH)}internal/globals.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-vm.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-vm.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-vm.$(OBJEXT): {$(VPATH)}internal/iterator.h
-vm.$(OBJEXT): {$(VPATH)}internal/memory.h
-vm.$(OBJEXT): {$(VPATH)}internal/method.h
-vm.$(OBJEXT): {$(VPATH)}internal/module.h
-vm.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-vm.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-vm.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-vm.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-vm.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-vm.$(OBJEXT): {$(VPATH)}internal/symbol.h
-vm.$(OBJEXT): {$(VPATH)}internal/value.h
-vm.$(OBJEXT): {$(VPATH)}internal/value_type.h
-vm.$(OBJEXT): {$(VPATH)}internal/variable.h
-vm.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-vm.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-vm.$(OBJEXT): {$(VPATH)}iseq.h
-vm.$(OBJEXT): {$(VPATH)}method.h
-vm.$(OBJEXT): {$(VPATH)}missing.h
-vm.$(OBJEXT): {$(VPATH)}node.h
-vm.$(OBJEXT): {$(VPATH)}onigmo.h
-vm.$(OBJEXT): {$(VPATH)}oniguruma.h
-vm.$(OBJEXT): {$(VPATH)}probes.dmyh
-vm.$(OBJEXT): {$(VPATH)}probes.h
-vm.$(OBJEXT): {$(VPATH)}probes_helper.h
-vm.$(OBJEXT): {$(VPATH)}ractor.h
-vm.$(OBJEXT): {$(VPATH)}ractor_core.h
-vm.$(OBJEXT): {$(VPATH)}rjit.h
-vm.$(OBJEXT): {$(VPATH)}ruby_assert.h
-vm.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-vm.$(OBJEXT): {$(VPATH)}shape.h
-vm.$(OBJEXT): {$(VPATH)}st.h
-vm.$(OBJEXT): {$(VPATH)}subst.h
-vm.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-vm.$(OBJEXT): {$(VPATH)}thread_native.h
-vm.$(OBJEXT): {$(VPATH)}variable.h
-vm.$(OBJEXT): {$(VPATH)}vm.c
-vm.$(OBJEXT): {$(VPATH)}vm.h
-vm.$(OBJEXT): {$(VPATH)}vm.inc
-vm.$(OBJEXT): {$(VPATH)}vm_args.c
-vm.$(OBJEXT): {$(VPATH)}vm_call_iseq_optimized.inc
-vm.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-vm.$(OBJEXT): {$(VPATH)}vm_core.h
-vm.$(OBJEXT): {$(VPATH)}vm_debug.h
-vm.$(OBJEXT): {$(VPATH)}vm_eval.c
-vm.$(OBJEXT): {$(VPATH)}vm_exec.c
-vm.$(OBJEXT): {$(VPATH)}vm_exec.h
-vm.$(OBJEXT): {$(VPATH)}vm_insnhelper.c
-vm.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
-vm.$(OBJEXT): {$(VPATH)}vm_method.c
-vm.$(OBJEXT): {$(VPATH)}vm_opts.h
-vm.$(OBJEXT): {$(VPATH)}vm_sync.h
-vm.$(OBJEXT): {$(VPATH)}vmtc.inc
-vm.$(OBJEXT): {$(VPATH)}yjit.h
-vm_backtrace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-vm_backtrace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h
-vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/array.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/class.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/error.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/gc.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/serial.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/string.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/variable.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/vm.h
-vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}atomic.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}config.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}constant.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}encoding.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}eval_intern.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}id.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}id_table.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}intern.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/abi.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/assume.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/cast.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/config.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/ctype.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/dosish.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/error.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/eval.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/event.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/gc.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/glob.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/globals.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/iterator.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/memory.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/method.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/module.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/symbol.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/value.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/value_type.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/variable.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}iseq.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}method.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}missing.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}node.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}onigmo.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}oniguruma.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_assert.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}shape.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}st.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}subst.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-vm_backtrace.$(OBJEXT): {$(VPATH)}thread_native.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}vm_backtrace.c
-vm_backtrace.$(OBJEXT): {$(VPATH)}vm_core.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}vm_opts.h
-vm_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-vm_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-vm_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
-vm_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/array.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/gc.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/serial.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/variable.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
-vm_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h
-vm_dump.$(OBJEXT): {$(VPATH)}assert.h
-vm_dump.$(OBJEXT): {$(VPATH)}atomic.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-vm_dump.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-vm_dump.$(OBJEXT): {$(VPATH)}config.h
-vm_dump.$(OBJEXT): {$(VPATH)}constant.h
-vm_dump.$(OBJEXT): {$(VPATH)}defines.h
-vm_dump.$(OBJEXT): {$(VPATH)}id.h
-vm_dump.$(OBJEXT): {$(VPATH)}id_table.h
-vm_dump.$(OBJEXT): {$(VPATH)}intern.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/abi.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/assume.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/cast.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/config.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/ctype.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/dosish.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/error.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/eval.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/event.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/gc.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/glob.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/globals.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/iterator.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/memory.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/method.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/module.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/symbol.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/value.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/value_type.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/variable.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-vm_dump.$(OBJEXT): {$(VPATH)}iseq.h
-vm_dump.$(OBJEXT): {$(VPATH)}method.h
-vm_dump.$(OBJEXT): {$(VPATH)}missing.h
-vm_dump.$(OBJEXT): {$(VPATH)}node.h
-vm_dump.$(OBJEXT): {$(VPATH)}procstat_vm.c
-vm_dump.$(OBJEXT): {$(VPATH)}ractor.h
-vm_dump.$(OBJEXT): {$(VPATH)}ractor_core.h
-vm_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
-vm_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-vm_dump.$(OBJEXT): {$(VPATH)}shape.h
-vm_dump.$(OBJEXT): {$(VPATH)}st.h
-vm_dump.$(OBJEXT): {$(VPATH)}subst.h
-vm_dump.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-vm_dump.$(OBJEXT): {$(VPATH)}thread_native.h
-vm_dump.$(OBJEXT): {$(VPATH)}vm_core.h
-vm_dump.$(OBJEXT): {$(VPATH)}vm_debug.h
-vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c
-vm_dump.$(OBJEXT): {$(VPATH)}vm_opts.h
-vm_sync.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-vm_sync.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-vm_sync.$(OBJEXT): $(CCAN_DIR)/list/list.h
-vm_sync.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_sync.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/array.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/gc.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/serial.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/thread.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/variable.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/vm.h
-vm_sync.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-vm_sync.$(OBJEXT): {$(VPATH)}assert.h
-vm_sync.$(OBJEXT): {$(VPATH)}atomic.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-vm_sync.$(OBJEXT): {$(VPATH)}config.h
-vm_sync.$(OBJEXT): {$(VPATH)}constant.h
-vm_sync.$(OBJEXT): {$(VPATH)}debug_counter.h
-vm_sync.$(OBJEXT): {$(VPATH)}defines.h
-vm_sync.$(OBJEXT): {$(VPATH)}id.h
-vm_sync.$(OBJEXT): {$(VPATH)}id_table.h
-vm_sync.$(OBJEXT): {$(VPATH)}intern.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/abi.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/assume.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/cast.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/config.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/ctype.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/dosish.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/error.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/eval.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/event.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/gc.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/glob.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/globals.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/iterator.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/memory.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/method.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/module.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/symbol.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/value.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/value_type.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/variable.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-vm_sync.$(OBJEXT): {$(VPATH)}method.h
-vm_sync.$(OBJEXT): {$(VPATH)}missing.h
-vm_sync.$(OBJEXT): {$(VPATH)}node.h
-vm_sync.$(OBJEXT): {$(VPATH)}ractor.h
-vm_sync.$(OBJEXT): {$(VPATH)}ractor_core.h
-vm_sync.$(OBJEXT): {$(VPATH)}ruby_assert.h
-vm_sync.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-vm_sync.$(OBJEXT): {$(VPATH)}shape.h
-vm_sync.$(OBJEXT): {$(VPATH)}st.h
-vm_sync.$(OBJEXT): {$(VPATH)}subst.h
-vm_sync.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-vm_sync.$(OBJEXT): {$(VPATH)}thread_native.h
-vm_sync.$(OBJEXT): {$(VPATH)}vm_core.h
-vm_sync.$(OBJEXT): {$(VPATH)}vm_debug.h
-vm_sync.$(OBJEXT): {$(VPATH)}vm_opts.h
-vm_sync.$(OBJEXT): {$(VPATH)}vm_sync.c
-vm_sync.$(OBJEXT): {$(VPATH)}vm_sync.h
-vm_trace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-vm_trace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-vm_trace.$(OBJEXT): $(CCAN_DIR)/list/list.h
-vm_trace.$(OBJEXT): $(CCAN_DIR)/str/str.h
-vm_trace.$(OBJEXT): $(hdrdir)/ruby.h
-vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/array.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/class.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/gc.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/hash.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/serial.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/symbol.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/variable.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/vm.h
-vm_trace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-vm_trace.$(OBJEXT): {$(VPATH)}assert.h
-vm_trace.$(OBJEXT): {$(VPATH)}atomic.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-vm_trace.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-vm_trace.$(OBJEXT): {$(VPATH)}builtin.h
-vm_trace.$(OBJEXT): {$(VPATH)}config.h
-vm_trace.$(OBJEXT): {$(VPATH)}constant.h
-vm_trace.$(OBJEXT): {$(VPATH)}debug.h
-vm_trace.$(OBJEXT): {$(VPATH)}debug_counter.h
-vm_trace.$(OBJEXT): {$(VPATH)}defines.h
-vm_trace.$(OBJEXT): {$(VPATH)}encoding.h
-vm_trace.$(OBJEXT): {$(VPATH)}eval_intern.h
-vm_trace.$(OBJEXT): {$(VPATH)}id.h
-vm_trace.$(OBJEXT): {$(VPATH)}id_table.h
-vm_trace.$(OBJEXT): {$(VPATH)}intern.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/abi.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/assume.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/cast.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/config.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/ctype.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/dosish.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/error.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/eval.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/event.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/gc.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/glob.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/globals.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/iterator.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/memory.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/method.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/module.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/symbol.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/value.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/value_type.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/variable.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-vm_trace.$(OBJEXT): {$(VPATH)}iseq.h
-vm_trace.$(OBJEXT): {$(VPATH)}method.h
-vm_trace.$(OBJEXT): {$(VPATH)}missing.h
-vm_trace.$(OBJEXT): {$(VPATH)}node.h
-vm_trace.$(OBJEXT): {$(VPATH)}onigmo.h
-vm_trace.$(OBJEXT): {$(VPATH)}oniguruma.h
-vm_trace.$(OBJEXT): {$(VPATH)}ractor.h
-vm_trace.$(OBJEXT): {$(VPATH)}rjit.h
-vm_trace.$(OBJEXT): {$(VPATH)}ruby_assert.h
-vm_trace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-vm_trace.$(OBJEXT): {$(VPATH)}shape.h
-vm_trace.$(OBJEXT): {$(VPATH)}st.h
-vm_trace.$(OBJEXT): {$(VPATH)}subst.h
-vm_trace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-vm_trace.$(OBJEXT): {$(VPATH)}thread_native.h
-vm_trace.$(OBJEXT): {$(VPATH)}trace_point.rbinc
-vm_trace.$(OBJEXT): {$(VPATH)}vm_core.h
-vm_trace.$(OBJEXT): {$(VPATH)}vm_opts.h
-vm_trace.$(OBJEXT): {$(VPATH)}vm_trace.c
-vm_trace.$(OBJEXT): {$(VPATH)}yjit.h
-weakmap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/gc.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/hash.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/proc.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-weakmap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-weakmap.$(OBJEXT): {$(VPATH)}assert.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-weakmap.$(OBJEXT): {$(VPATH)}config.h
-weakmap.$(OBJEXT): {$(VPATH)}defines.h
-weakmap.$(OBJEXT): {$(VPATH)}intern.h
-weakmap.$(OBJEXT): {$(VPATH)}internal.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/abi.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/assume.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/cast.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/config.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/ctype.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/dosish.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/error.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/eval.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/event.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/gc.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/glob.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/globals.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/iterator.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/memory.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/method.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/module.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/newobj.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/symbol.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/value.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/value_type.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/variable.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-weakmap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-weakmap.$(OBJEXT): {$(VPATH)}missing.h
-weakmap.$(OBJEXT): {$(VPATH)}st.h
-weakmap.$(OBJEXT): {$(VPATH)}subst.h
-weakmap.$(OBJEXT): {$(VPATH)}weakmap.c
-yjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-yjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-yjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-yjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-yjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/array.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/class.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/string.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
-yjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-yjit.$(OBJEXT): {$(VPATH)}assert.h
-yjit.$(OBJEXT): {$(VPATH)}atomic.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-yjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-yjit.$(OBJEXT): {$(VPATH)}builtin.h
-yjit.$(OBJEXT): {$(VPATH)}config.h
-yjit.$(OBJEXT): {$(VPATH)}constant.h
-yjit.$(OBJEXT): {$(VPATH)}debug.h
-yjit.$(OBJEXT): {$(VPATH)}debug_counter.h
-yjit.$(OBJEXT): {$(VPATH)}defines.h
-yjit.$(OBJEXT): {$(VPATH)}encoding.h
-yjit.$(OBJEXT): {$(VPATH)}id.h
-yjit.$(OBJEXT): {$(VPATH)}id_table.h
-yjit.$(OBJEXT): {$(VPATH)}insns.def
-yjit.$(OBJEXT): {$(VPATH)}insns.inc
-yjit.$(OBJEXT): {$(VPATH)}insns_info.inc
-yjit.$(OBJEXT): {$(VPATH)}intern.h
-yjit.$(OBJEXT): {$(VPATH)}internal.h
-yjit.$(OBJEXT): {$(VPATH)}internal/abi.h
-yjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-yjit.$(OBJEXT): {$(VPATH)}internal/assume.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-yjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-yjit.$(OBJEXT): {$(VPATH)}internal/cast.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-yjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-yjit.$(OBJEXT): {$(VPATH)}internal/config.h
-yjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-yjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-yjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
-yjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-yjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-yjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-yjit.$(OBJEXT): {$(VPATH)}internal/error.h
-yjit.$(OBJEXT): {$(VPATH)}internal/eval.h
-yjit.$(OBJEXT): {$(VPATH)}internal/event.h
-yjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-yjit.$(OBJEXT): {$(VPATH)}internal/gc.h
-yjit.$(OBJEXT): {$(VPATH)}internal/glob.h
-yjit.$(OBJEXT): {$(VPATH)}internal/globals.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-yjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-yjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-yjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
-yjit.$(OBJEXT): {$(VPATH)}internal/memory.h
-yjit.$(OBJEXT): {$(VPATH)}internal/method.h
-yjit.$(OBJEXT): {$(VPATH)}internal/module.h
-yjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-yjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-yjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-yjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-yjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-yjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-yjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
-yjit.$(OBJEXT): {$(VPATH)}internal/value.h
-yjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
-yjit.$(OBJEXT): {$(VPATH)}internal/variable.h
-yjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-yjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-yjit.$(OBJEXT): {$(VPATH)}iseq.h
-yjit.$(OBJEXT): {$(VPATH)}method.h
-yjit.$(OBJEXT): {$(VPATH)}missing.h
-yjit.$(OBJEXT): {$(VPATH)}node.h
-yjit.$(OBJEXT): {$(VPATH)}onigmo.h
-yjit.$(OBJEXT): {$(VPATH)}oniguruma.h
-yjit.$(OBJEXT): {$(VPATH)}probes.dmyh
-yjit.$(OBJEXT): {$(VPATH)}probes.h
-yjit.$(OBJEXT): {$(VPATH)}probes_helper.h
-yjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-yjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-yjit.$(OBJEXT): {$(VPATH)}shape.h
-yjit.$(OBJEXT): {$(VPATH)}st.h
-yjit.$(OBJEXT): {$(VPATH)}subst.h
-yjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-yjit.$(OBJEXT): {$(VPATH)}thread_native.h
-yjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-yjit.$(OBJEXT): {$(VPATH)}vm_core.h
-yjit.$(OBJEXT): {$(VPATH)}vm_debug.h
-yjit.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
-yjit.$(OBJEXT): {$(VPATH)}vm_opts.h
-yjit.$(OBJEXT): {$(VPATH)}vm_sync.h
-yjit.$(OBJEXT): {$(VPATH)}yjit.c
-yjit.$(OBJEXT): {$(VPATH)}yjit.h
-yjit.$(OBJEXT): {$(VPATH)}yjit.rbinc
-# AUTOGENERATED DEPENDENCIES END
+!include $(srcdir)/prism/srcs.mk
+!include $(srcdir)/depend
diff --git a/compar.c b/compar.c
index dc157fd241..1ab2520f1e 100644
--- a/compar.c
+++ b/compar.c
@@ -24,8 +24,8 @@ rb_cmp(VALUE x, VALUE y)
return rb_funcallv(x, idCmp, 1, &y);
}
-void
-rb_cmperr(VALUE x, VALUE y)
+static VALUE
+cmperr_subject(VALUE y)
{
VALUE classname;
@@ -35,10 +35,25 @@ rb_cmperr(VALUE x, VALUE y)
else {
classname = rb_obj_class(y);
}
+ return classname;
+}
+
+void
+rb_cmperr(VALUE x, VALUE y)
+{
+ VALUE classname = cmperr_subject(y);
rb_raise(rb_eArgError, "comparison of %"PRIsVALUE" with %"PRIsVALUE" failed",
rb_obj_class(x), classname);
}
+void
+rb_cmperr_reason(VALUE x, VALUE y, const char *reason)
+{
+ VALUE classname = cmperr_subject(y);
+ rb_raise(rb_eArgError, "comparison of %"PRIsVALUE" with %"PRIsVALUE" failed: %s",
+ rb_obj_class(x), classname, reason);
+}
+
static VALUE
invcmp_recursive(VALUE x, VALUE y, int recursive)
{
@@ -95,10 +110,13 @@ cmpint(VALUE x, VALUE y)
/*
* call-seq:
- * obj > other -> true or false
+ * self > other -> true or false
*
- * Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value greater than 0.
+ * Returns whether +self+ is "greater than" +other+;
+ * equivalent to <tt>(self <=> other) > 0</tt>:
+ *
+ * 'foo' > 'foo' # => false
+ * 'food' > 'foo' # => true
*/
static VALUE
@@ -109,10 +127,15 @@ cmp_gt(VALUE x, VALUE y)
/*
* call-seq:
- * obj >= other -> true or false
+ * self >= other -> true or false
+ *
+ * Returns whether +self+ is "greater than or equal to" +other+;
+ * equivalent to <tt>(self <=> other) >= 0</tt>:
+ *
+ * 'food' >= 'foo' # => true
+ * 'foo' >= 'foo' # => true
+ * 'foo' >= 'food' # => false
*
- * Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value greater than or equal to 0.
*/
static VALUE
@@ -123,10 +146,14 @@ cmp_ge(VALUE x, VALUE y)
/*
* call-seq:
- * obj < other -> true or false
+ * self < other -> true or false
+ *
+ * Returns whether +self+ is "less than" +other+;
+ * equivalent to <tt>(self <=> other) < 0</tt>:
+ *
+ * 'foo' < 'foo' # => false
+ * 'foo' < 'food' # => true
*
- * Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value less than 0.
*/
static VALUE
@@ -137,10 +164,15 @@ cmp_lt(VALUE x, VALUE y)
/*
* call-seq:
- * obj <= other -> true or false
+ * self <= other -> true or false
+ *
+ * Returns whether +self+ is "less than or equal to" +other+;
+ * equivalent to <tt>(self <=> other) <= 0</tt>:
+ *
+ * 'foo' <= 'foo' # => true
+ * 'foo' <= 'food' # => true
+ * 'food' <= 'foo' # => false
*
- * Compares two objects based on the receiver's <code><=></code>
- * method, returning true if it returns a value less than or equal to 0.
*/
static VALUE
@@ -187,6 +219,12 @@ cmp_between(VALUE x, VALUE min, VALUE max)
* 'd'.clamp('a', 'f') #=> 'd'
* 'z'.clamp('a', 'f') #=> 'f'
*
+ * If _min_ is +nil+, it is considered smaller than _obj_,
+ * and if _max_ is +nil+, it is considered greater than _obj_.
+ *
+ * -20.clamp(0, nil) #=> 0
+ * 523.clamp(nil, 100) #=> 100
+ *
* In <code>(range)</code> form, returns _range.begin_ if _obj_
* <code><=></code> _range.begin_ is less than zero, _range.end_
* if _obj_ <code><=></code> _range.end_ is greater than zero, and
@@ -257,25 +295,28 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
* <code>==</code>, <code>>=</code>, and <code>></code>) and the
* method <code>between?</code>.
*
- * class SizeMatters
+ * class StringSorter
* include Comparable
+ *
* attr :str
* def <=>(other)
* str.size <=> other.str.size
* end
+ *
* def initialize(str)
* @str = str
* end
+ *
* def inspect
* @str
* end
* end
*
- * s1 = SizeMatters.new("Z")
- * s2 = SizeMatters.new("YY")
- * s3 = SizeMatters.new("XXX")
- * s4 = SizeMatters.new("WWWW")
- * s5 = SizeMatters.new("VVVVV")
+ * s1 = StringSorter.new("Z")
+ * s2 = StringSorter.new("YY")
+ * s3 = StringSorter.new("XXX")
+ * s4 = StringSorter.new("WWWW")
+ * s5 = StringSorter.new("VVVVV")
*
* s1 < s2 #=> true
* s4.between?(s1, s3) #=> false
@@ -284,13 +325,13 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
*
* == What's Here
*
- * \Module \Comparable provides these methods, all of which use method <tt><=></tt>:
+ * Module \Comparable provides these methods, all of which use method <tt>#<=></tt>:
*
* - #<: Returns whether +self+ is less than the given object.
* - #<=: Returns whether +self+ is less than or equal to the given object.
* - #==: Returns whether +self+ is equal to the given object.
- * - #>: Returns whether +self+ is greater than or equal to the given object.
- * - #>=: Returns whether +self+ is greater than the given object.
+ * - #>: Returns whether +self+ is greater than the given object.
+ * - #>=: Returns whether +self+ is greater than or equal to the given object.
* - #between?: Returns +true+ if +self+ is between two given objects.
* - #clamp: For given objects +min+ and +max+, or range <tt>(min..max)</tt>, returns:
*
diff --git a/compile.c b/compile.c
index decac40936..65ced44f9c 100644
--- a/compile.c
+++ b/compile.c
@@ -26,29 +26,29 @@
#include "internal/error.h"
#include "internal/gc.h"
#include "internal/hash.h"
+#include "internal/io.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
#include "internal/re.h"
+#include "internal/ruby_parser.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
+#include "ruby/ractor.h"
#include "ruby/re.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "vm_callinfo.h"
#include "vm_debug.h"
+#include "yjit.h"
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
-
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
-#define FIXNUM_OR(n, i) ((n)|INT2FIX(i))
typedef struct iseq_link_element {
enum {
@@ -118,7 +118,7 @@ struct ensure_range {
};
struct iseq_compile_data_ensure_node_stack {
- const NODE *ensure_node;
+ const void *ensure_node;
struct iseq_compile_data_ensure_node_stack *prev;
struct ensure_range *erange;
};
@@ -213,36 +213,43 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
#define NEW_CHILD_ISEQ(node, name, type, line_no) \
new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))
+#define NEW_CHILD_ISEQ_WITH_CALLBACK(callback_func, name, type, line_no) \
+ new_child_iseq_with_callback(iseq, (callback_func), (name), iseq, (type), (line_no))
+
/* add instructions */
#define ADD_SEQ(seq1, seq2) \
APPEND_LIST((seq1), (seq2))
/* add an instruction */
#define ADD_INSN(seq, line_node, insn) \
- ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line_node), BIN(insn), 0))
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, nd_line(line_node), nd_node_id(line_node), BIN(insn), 0))
+
+/* add an instruction with the given line number and node id */
+#define ADD_SYNTHETIC_INSN(seq, line_no, node_id, insn) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line_no), (node_id), BIN(insn), 0))
/* insert an instruction before next */
-#define INSERT_BEFORE_INSN(next, line_node, insn) \
- ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line_node), BIN(insn), 0))
+#define INSERT_BEFORE_INSN(next, line_no, node_id, insn) \
+ ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) new_insn_body(iseq, line_no, node_id, BIN(insn), 0))
/* insert an instruction after prev */
-#define INSERT_AFTER_INSN(prev, line_node, insn) \
- ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line_node), BIN(insn), 0))
+#define INSERT_AFTER_INSN(prev, line_no, node_id, insn) \
+ ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, line_no, node_id, BIN(insn), 0))
/* add an instruction with some operands (1, 2, 3, 5) */
#define ADD_INSN1(seq, line_node, insn, op1) \
ADD_ELEM((seq), (LINK_ELEMENT *) \
- new_insn_body(iseq, (line_node), BIN(insn), 1, (VALUE)(op1)))
+ new_insn_body(iseq, nd_line(line_node), nd_node_id(line_node), BIN(insn), 1, (VALUE)(op1)))
/* insert an instruction with some operands (1, 2, 3, 5) before next */
-#define INSERT_BEFORE_INSN1(next, line_node, insn, op1) \
+#define INSERT_BEFORE_INSN1(next, line_no, node_id, insn, op1) \
ELEM_INSERT_PREV(&(next)->link, (LINK_ELEMENT *) \
- new_insn_body(iseq, (line_node), BIN(insn), 1, (VALUE)(op1)))
+ new_insn_body(iseq, line_no, node_id, BIN(insn), 1, (VALUE)(op1)))
/* insert an instruction with some operands (1, 2, 3, 5) after prev */
-#define INSERT_AFTER_INSN1(prev, line_node, insn, op1) \
+#define INSERT_AFTER_INSN1(prev, line_no, node_id, insn, op1) \
ELEM_INSERT_NEXT(&(prev)->link, (LINK_ELEMENT *) \
- new_insn_body(iseq, (line_node), BIN(insn), 1, (VALUE)(op1)))
+ new_insn_body(iseq, line_no, node_id, BIN(insn), 1, (VALUE)(op1)))
#define LABEL_REF(label) ((label)->refcnt++)
@@ -251,11 +258,11 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
#define ADD_INSN2(seq, line_node, insn, op1, op2) \
ADD_ELEM((seq), (LINK_ELEMENT *) \
- new_insn_body(iseq, (line_node), BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))
+ new_insn_body(iseq, nd_line(line_node), nd_node_id(line_node), BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))
#define ADD_INSN3(seq, line_node, insn, op1, op2, op3) \
ADD_ELEM((seq), (LINK_ELEMENT *) \
- new_insn_body(iseq, (line_node), BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))
+ new_insn_body(iseq, nd_line(line_node), nd_node_id(line_node), BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))
/* Specific Insn factory */
#define ADD_SEND(seq, line_node, id, argc) \
@@ -277,7 +284,7 @@ const ID rb_iseq_shared_exc_local_tbl[] = {idERROR_INFO};
ADD_SEND_R((seq), (line_node), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
#define ADD_SEND_R(seq, line_node, id, argc, block, flag, keywords) \
- ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line_node), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, nd_line(line_node), nd_node_id(line_node), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
#define ADD_TRACE(seq, event) \
ADD_ELEM((seq), (LINK_ELEMENT *)new_trace_body(iseq, (event), 0))
@@ -332,10 +339,10 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NOD
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), (popped))))
-#define COMPILE_RECV(anchor, desc, node) \
+#define COMPILE_RECV(anchor, desc, node, recv) \
(private_recv_p(node) ? \
(ADD_INSN(anchor, node, putself), VM_CALL_FCALL) : \
- COMPILE(anchor, desc, node->nd_recv) ? 0 : -1)
+ COMPILE(anchor, desc, recv) ? 0 : -1)
#define OPERAND_AT(insn, idx) \
(((INSN*)(insn))->operands[(idx)])
@@ -431,12 +438,10 @@ do { \
#define NO_CHECK(sub) (void)(sub)
#define BEFORE_RETURN
-/* leave name uninitialized so that compiler warn if INIT_ANCHOR is
- * missing */
#define DECL_ANCHOR(name) \
- LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},}}
+ LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},&name[0].anchor}}
#define INIT_ANCHOR(name) \
- (name->last = &name->anchor)
+ ((name->last = &name->anchor)->next = NULL) /* re-initialize */
static inline VALUE
freeze_hide_obj(VALUE obj)
@@ -470,7 +475,7 @@ static void dump_disasm_list(const LINK_ELEMENT *elem);
static int insn_data_length(INSN *iobj);
static int calc_sp_depth(int depth, INSN *iobj);
-static INSN *new_insn_body(rb_iseq_t *iseq, const NODE *const line_node, enum ruby_vminsn_type insn_id, int argc, ...);
+static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int node_id, enum ruby_vminsn_type insn_id, int argc, ...);
static LABEL *new_label_body(rb_iseq_t *iseq, long line);
static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line);
static TRACE *new_trace_body(rb_iseq_t *iseq, rb_event_flag_t event, long data);
@@ -482,16 +487,16 @@ static int iseq_setup_insn(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
-static int iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl);
+static int iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl, const NODE *const node_args);
static int iseq_set_exception_local_table(rb_iseq_t *iseq);
static int iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, const NODE *const node);
-static int iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_set_exception_table(rb_iseq_t *iseq);
static int iseq_set_optargs_table(rb_iseq_t *iseq);
+static int iseq_set_parameters_lvar_state(const rb_iseq_t *iseq);
-static int compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, VALUE needstr);
+static int compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, VALUE needstr, bool ignore);
static int compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int method_call_keywords, int popped);
/*
@@ -606,12 +611,25 @@ branch_coverage_valid_p(rb_iseq_t *iseq, int first_line)
}
static VALUE
-decl_branch_base(rb_iseq_t *iseq, const NODE *node, const char *type)
+setup_branch(const rb_code_location_t *loc, const char *type, VALUE structure, VALUE key)
{
- const int first_lineno = nd_first_lineno(node), first_column = nd_first_column(node);
- const int last_lineno = nd_last_lineno(node), last_column = nd_last_column(node);
+ const int first_lineno = loc->beg_pos.lineno, first_column = loc->beg_pos.column;
+ const int last_lineno = loc->end_pos.lineno, last_column = loc->end_pos.column;
+ VALUE branch = rb_ary_hidden_new(6);
+
+ rb_hash_aset(structure, key, branch);
+ rb_ary_push(branch, ID2SYM(rb_intern(type)));
+ rb_ary_push(branch, INT2FIX(first_lineno));
+ rb_ary_push(branch, INT2FIX(first_column));
+ rb_ary_push(branch, INT2FIX(last_lineno));
+ rb_ary_push(branch, INT2FIX(last_column));
+ return branch;
+}
- if (!branch_coverage_valid_p(iseq, first_lineno)) return Qundef;
+static VALUE
+decl_branch_base(rb_iseq_t *iseq, VALUE key, const rb_code_location_t *loc, const char *type)
+{
+ if (!branch_coverage_valid_p(iseq, loc->beg_pos.lineno)) return Qundef;
/*
* if !structure[node]
@@ -622,18 +640,11 @@ decl_branch_base(rb_iseq_t *iseq, const NODE *node, const char *type)
*/
VALUE structure = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 0);
- VALUE key = (VALUE)node | 1; // FIXNUM for hash key
VALUE branch_base = rb_hash_aref(structure, key);
VALUE branches;
if (NIL_P(branch_base)) {
- branch_base = rb_ary_hidden_new(6);
- rb_hash_aset(structure, key, branch_base);
- rb_ary_push(branch_base, ID2SYM(rb_intern(type)));
- rb_ary_push(branch_base, INT2FIX(first_lineno));
- rb_ary_push(branch_base, INT2FIX(first_column));
- rb_ary_push(branch_base, INT2FIX(last_lineno));
- rb_ary_push(branch_base, INT2FIX(last_column));
+ branch_base = setup_branch(loc, type, structure, key);
branches = rb_hash_new();
rb_obj_hide(branches);
rb_ary_push(branch_base, branches);
@@ -655,12 +666,9 @@ generate_dummy_line_node(int lineno, int node_id)
}
static void
-add_trace_branch_coverage(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *node, int branch_id, const char *type, VALUE branches)
+add_trace_branch_coverage(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const rb_code_location_t *loc, int node_id, int branch_id, const char *type, VALUE branches)
{
- const int first_lineno = nd_first_lineno(node), first_column = nd_first_column(node);
- const int last_lineno = nd_last_lineno(node), last_column = nd_last_column(node);
-
- if (!branch_coverage_valid_p(iseq, first_lineno)) return;
+ if (!branch_coverage_valid_p(iseq, loc->beg_pos.lineno)) return;
/*
* if !branches[branch_id]
@@ -675,13 +683,7 @@ add_trace_branch_coverage(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *n
long counter_idx;
if (NIL_P(branch)) {
- branch = rb_ary_hidden_new(6);
- rb_hash_aset(branches, key, branch);
- rb_ary_push(branch, ID2SYM(rb_intern(type)));
- rb_ary_push(branch, INT2FIX(first_lineno));
- rb_ary_push(branch, INT2FIX(first_column));
- rb_ary_push(branch, INT2FIX(last_lineno));
- rb_ary_push(branch, INT2FIX(last_column));
+ branch = setup_branch(loc, type, branches, key);
VALUE counters = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 1);
counter_idx = RARRAY_LEN(counters);
rb_ary_push(branch, LONG2FIX(counter_idx));
@@ -692,9 +694,7 @@ add_trace_branch_coverage(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *n
}
ADD_TRACE_WITH_DATA(seq, RUBY_EVENT_COVERAGE_BRANCH, counter_idx);
-
- NODE dummy_line_node = generate_dummy_line_node(last_lineno, nd_node_id(node));
- ADD_INSN(seq, &dummy_line_node, nop);
+ ADD_SYNTHETIC_INSN(seq, loc->end_pos.lineno, node_id, nop);
}
#define ISEQ_LAST_LINE(iseq) (ISEQ_COMPILE_DATA(iseq)->last_line)
@@ -721,6 +721,129 @@ validate_labels(rb_iseq_t *iseq, st_table *labels_table)
st_free_table(labels_table);
}
+static NODE *
+get_nd_recv(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_recv;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_recv;
+ case NODE_FCALL:
+ return 0;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_recv;
+ case NODE_VCALL:
+ return 0;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_recv;
+ case NODE_OP_ASGN1:
+ return RNODE_OP_ASGN1(node)->nd_recv;
+ case NODE_OP_ASGN2:
+ return RNODE_OP_ASGN2(node)->nd_recv;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_node_call_nd_mid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_mid;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_mid;
+ case NODE_FCALL:
+ return RNODE_FCALL(node)->nd_mid;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_mid;
+ case NODE_VCALL:
+ return RNODE_VCALL(node)->nd_mid;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_mid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static NODE *
+get_nd_args(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_args;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_args;
+ case NODE_FCALL:
+ return RNODE_FCALL(node)->nd_args;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_args;
+ case NODE_VCALL:
+ return 0;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_args;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_node_colon_nd_mid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_COLON2:
+ return RNODE_COLON2(node)->nd_mid;
+ case NODE_COLON3:
+ return RNODE_COLON3(node)->nd_mid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_nd_vid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_vid;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_vid;
+ case NODE_IASGN:
+ return RNODE_IASGN(node)->nd_vid;
+ case NODE_CVASGN:
+ return RNODE_CVASGN(node)->nd_vid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static NODE *
+get_nd_value(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_value;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_value;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static VALUE
+get_string_value(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_STR:
+ return RB_OBJ_SET_SHAREABLE(rb_node_str_string_val(node));
+ case NODE_FILE:
+ return RB_OBJ_SET_SHAREABLE(rb_node_file_path_val(node));
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
VALUE
rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func * ifunc)
{
@@ -729,32 +852,30 @@ rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback
(*ifunc->func)(iseq, ret, ifunc->data);
- NODE dummy_line_node = generate_dummy_line_node(ISEQ_COMPILE_DATA(iseq)->last_line, -1);
- ADD_INSN(ret, &dummy_line_node, leave);
+ ADD_SYNTHETIC_INSN(ret, ISEQ_COMPILE_DATA(iseq)->last_line, -1, leave);
CHECK(iseq_setup_insn(iseq, ret));
return iseq_setup(iseq, ret);
}
+static bool drop_unreachable_return(LINK_ANCHOR *ret);
+
VALUE
rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
{
DECL_ANCHOR(ret);
INIT_ANCHOR(ret);
- if (IMEMO_TYPE_P(node, imemo_ifunc)) {
- rb_raise(rb_eArgError, "unexpected imemo_ifunc");
- }
-
if (node == 0) {
NO_CHECK(COMPILE(ret, "nil", node));
- iseq_set_local_table(iseq, 0);
+ iseq_set_local_table(iseq, 0, 0);
}
/* assume node is T_NODE */
else if (nd_type_p(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);
+ iseq_set_local_table(iseq, RNODE_SCOPE(node)->nd_tbl, (NODE *)RNODE_SCOPE(node)->nd_args);
+ iseq_set_arguments(iseq, ret, (NODE *)RNODE_SCOPE(node)->nd_args);
+ iseq_set_parameters_lvar_state(iseq);
switch (ISEQ_BODY(iseq)->type) {
case ISEQ_TYPE_BLOCK:
@@ -766,10 +887,9 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
end->rescued = LABEL_RESCUE_END;
ADD_TRACE(ret, RUBY_EVENT_B_CALL);
- NODE dummy_line_node = generate_dummy_line_node(ISEQ_BODY(iseq)->location.first_lineno, -1);
- ADD_INSN (ret, &dummy_line_node, nop);
+ ADD_SYNTHETIC_INSN(ret, ISEQ_BODY(iseq)->location.first_lineno, -1, nop);
ADD_LABEL(ret, start);
- CHECK(COMPILE(ret, "block body", node->nd_body));
+ CHECK(COMPILE(ret, "block body", RNODE_SCOPE(node)->nd_body));
ADD_LABEL(ret, end);
ADD_TRACE(ret, RUBY_EVENT_B_RETURN);
ISEQ_COMPILE_DATA(iseq)->last_line = ISEQ_BODY(iseq)->location.code_location.end_pos.lineno;
@@ -782,23 +902,23 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
case ISEQ_TYPE_CLASS:
{
ADD_TRACE(ret, RUBY_EVENT_CLASS);
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
ADD_TRACE(ret, RUBY_EVENT_END);
ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node);
break;
}
case ISEQ_TYPE_METHOD:
{
- ISEQ_COMPILE_DATA(iseq)->root_node = node->nd_body;
+ ISEQ_COMPILE_DATA(iseq)->root_node = RNODE_SCOPE(node)->nd_body;
ADD_TRACE(ret, RUBY_EVENT_CALL);
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
- ISEQ_COMPILE_DATA(iseq)->root_node = node->nd_body;
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
+ ISEQ_COMPILE_DATA(iseq)->root_node = RNODE_SCOPE(node)->nd_body;
ADD_TRACE(ret, RUBY_EVENT_RETURN);
ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node);
break;
}
default: {
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
break;
}
}
@@ -840,9 +960,8 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
ADD_GETLOCAL(ret, &dummy_line_node, LVAR_ERRINFO, 0);
ADD_INSN1(ret, &dummy_line_node, throw, INT2FIX(0) /* continue throw */ );
}
- else {
- NODE dummy_line_node = generate_dummy_line_node(ISEQ_COMPILE_DATA(iseq)->last_line, -1);
- ADD_INSN(ret, &dummy_line_node, leave);
+ else if (!drop_unreachable_return(ret)) {
+ ADD_SYNTHETIC_INSN(ret, ISEQ_COMPILE_DATA(iseq)->last_line, -1, leave);
}
#if OPT_SUPPORT_JOKE
@@ -872,6 +991,12 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
}
FL_SET((VALUE)iseq, ISEQ_TRANSLATED);
#endif
+
+#if USE_YJIT
+ rb_yjit_live_iseq_count++;
+ rb_yjit_iseq_alloc_count++;
+#endif
+
return COMPILE_OK;
}
@@ -904,75 +1029,44 @@ rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
/* definition of data structure for compiler */
/*********************************************/
-/*
- * On 32-bit SPARC, GCC by default generates SPARC V7 code that may require
- * 8-byte word alignment. On the other hand, Oracle Solaris Studio seems to
- * generate SPARCV8PLUS code with unaligned memory access instructions.
- * That is why the STRICT_ALIGNMENT is defined only with GCC.
- */
-#if defined(__sparc) && SIZEOF_VOIDP == 4 && defined(__GNUC__)
- #define STRICT_ALIGNMENT
+#if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE
+# define ALIGNMENT_SIZE SIZEOF_LONG_LONG
+#else
+# define ALIGNMENT_SIZE SIZEOF_VALUE
#endif
+#define PADDING_SIZE_MAX ((size_t)((ALIGNMENT_SIZE) - 1))
-/*
- * Some OpenBSD platforms (including sparc64) require strict alignment.
- */
-#if defined(__OpenBSD__)
- #include <sys/endian.h>
- #ifdef __STRICT_ALIGNMENT
- #define STRICT_ALIGNMENT
- #endif
-#endif
+#define ALIGNMENT_SIZE_OF(type) alignment_size_assert(RUBY_ALIGNOF(type), #type)
-#ifdef STRICT_ALIGNMENT
- #if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE
- #define ALIGNMENT_SIZE SIZEOF_LONG_LONG
- #else
- #define ALIGNMENT_SIZE SIZEOF_VALUE
- #endif
- #define PADDING_SIZE_MAX ((size_t)((ALIGNMENT_SIZE) - 1))
- #define ALIGNMENT_SIZE_MASK PADDING_SIZE_MAX
- /* Note: ALIGNMENT_SIZE == (2 ** N) is expected. */
-#else
- #define PADDING_SIZE_MAX 0
-#endif /* STRICT_ALIGNMENT */
+static inline size_t
+alignment_size_assert(size_t align, const char *type)
+{
+ RUBY_ASSERT((align & (align - 1)) == 0,
+ "ALIGNMENT_SIZE_OF(%s):%zd == (2 ** N) is expected", type, align);
+ return align;
+}
-#ifdef STRICT_ALIGNMENT
/* calculate padding size for aligned memory access */
-static size_t
-calc_padding(void *ptr, size_t size)
+static inline size_t
+calc_padding(void *ptr, size_t align)
{
size_t mis;
size_t padding = 0;
- mis = (size_t)ptr & ALIGNMENT_SIZE_MASK;
+ mis = (size_t)ptr & (align - 1);
if (mis > 0) {
- padding = ALIGNMENT_SIZE - mis;
- }
-/*
- * On 32-bit sparc or equivalents, when a single VALUE is requested
- * and padding == sizeof(VALUE), it is clear that no padding is needed.
- */
-#if ALIGNMENT_SIZE > SIZEOF_VALUE
- if (size == sizeof(VALUE) && padding == sizeof(VALUE)) {
- padding = 0;
+ padding = align - mis;
}
-#endif
return padding;
}
-#endif /* STRICT_ALIGNMENT */
static void *
-compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t size)
+compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t size, size_t align)
{
void *ptr = 0;
struct iseq_compile_data_storage *storage = *arena;
-#ifdef STRICT_ALIGNMENT
- size_t padding = calc_padding((void *)&storage->buff[storage->pos], size);
-#else
- const size_t padding = 0; /* expected to be optimized by compiler */
-#endif /* STRICT_ALIGNMENT */
+ size_t padding = calc_padding((void *)&storage->buff[storage->pos], align);
if (size >= INT_MAX - padding) rb_memerror();
if (storage->pos + size + padding > storage->size) {
@@ -988,14 +1082,10 @@ compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t s
storage->next = 0;
storage->pos = 0;
storage->size = alloc_size;
-#ifdef STRICT_ALIGNMENT
- padding = calc_padding((void *)&storage->buff[storage->pos], size);
-#endif /* STRICT_ALIGNMENT */
+ padding = calc_padding((void *)&storage->buff[storage->pos], align);
}
-#ifdef STRICT_ALIGNMENT
storage->pos += (int)padding;
-#endif /* STRICT_ALIGNMENT */
ptr = (void *)&storage->buff[storage->pos];
storage->pos += (int)size;
@@ -1003,51 +1093,60 @@ compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t s
}
static void *
-compile_data_alloc(rb_iseq_t *iseq, size_t size)
+compile_data_alloc(rb_iseq_t *iseq, size_t size, size_t align)
{
struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->node.storage_current;
- return compile_data_alloc_with_arena(arena, size);
+ return compile_data_alloc_with_arena(arena, size, align);
}
+#define compile_data_alloc_type(iseq, type) \
+ (type *)compile_data_alloc(iseq, sizeof(type), ALIGNMENT_SIZE_OF(type))
+
static inline void *
-compile_data_alloc2(rb_iseq_t *iseq, size_t x, size_t y)
+compile_data_alloc2(rb_iseq_t *iseq, size_t elsize, size_t num, size_t align)
{
- size_t size = rb_size_mul_or_raise(x, y, rb_eRuntimeError);
- return compile_data_alloc(iseq, size);
+ size_t size = rb_size_mul_or_raise(elsize, num, rb_eRuntimeError);
+ return compile_data_alloc(iseq, size, align);
}
+#define compile_data_alloc2_type(iseq, type, num) \
+ (type *)compile_data_alloc2(iseq, sizeof(type), num, ALIGNMENT_SIZE_OF(type))
+
static inline void *
-compile_data_calloc2(rb_iseq_t *iseq, size_t x, size_t y)
+compile_data_calloc2(rb_iseq_t *iseq, size_t elsize, size_t num, size_t align)
{
- size_t size = rb_size_mul_or_raise(x, y, rb_eRuntimeError);
- void *p = compile_data_alloc(iseq, size);
+ size_t size = rb_size_mul_or_raise(elsize, num, rb_eRuntimeError);
+ void *p = compile_data_alloc(iseq, size, align);
memset(p, 0, size);
return p;
}
+#define compile_data_calloc2_type(iseq, type, num) \
+ (type *)compile_data_calloc2(iseq, sizeof(type), num, ALIGNMENT_SIZE_OF(type))
+
static INSN *
compile_data_alloc_insn(rb_iseq_t *iseq)
{
struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->insn.storage_current;
- return (INSN *)compile_data_alloc_with_arena(arena, sizeof(INSN));
+ return (INSN *)compile_data_alloc_with_arena(arena, sizeof(INSN), ALIGNMENT_SIZE_OF(INSN));
}
static LABEL *
compile_data_alloc_label(rb_iseq_t *iseq)
{
- return (LABEL *)compile_data_alloc(iseq, sizeof(LABEL));
+ return compile_data_alloc_type(iseq, LABEL);
}
static ADJUST *
compile_data_alloc_adjust(rb_iseq_t *iseq)
{
- return (ADJUST *)compile_data_alloc(iseq, sizeof(ADJUST));
+ return compile_data_alloc_type(iseq, ADJUST);
}
static TRACE *
compile_data_alloc_trace(rb_iseq_t *iseq)
{
- return (TRACE *)compile_data_alloc(iseq, sizeof(TRACE));
+ return compile_data_alloc_type(iseq, TRACE);
}
/*
@@ -1165,10 +1264,15 @@ static void
APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2)
{
if (anc2->anchor.next) {
+ /* LINK_ANCHOR must not loop */
+ RUBY_ASSERT(anc2->last != &anc2->anchor);
anc1->last->next = anc2->anchor.next;
anc2->anchor.next->prev = anc1->last;
anc1->last = anc2->last;
}
+ else {
+ RUBY_ASSERT(anc2->last == &anc2->anchor);
+ }
verify_list("append", anc1);
}
#if CPDEBUG < 0
@@ -1228,6 +1332,7 @@ new_label_body(rb_iseq_t *iseq, long line)
labelobj->set = 0;
labelobj->rescued = LABEL_RESCUE_NONE;
labelobj->unremovable = 0;
+ labelobj->position = -1;
return labelobj;
}
@@ -1243,9 +1348,37 @@ new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line)
return adjust;
}
+static void
+iseq_insn_each_markable_object(INSN *insn, void (*func)(VALUE *, VALUE), VALUE data)
+{
+ const char *types = insn_op_types(insn->insn_id);
+ for (int j = 0; types[j]; j++) {
+ char type = types[j];
+ switch (type) {
+ case TS_CDHASH:
+ case TS_ISEQ:
+ case TS_VALUE:
+ case TS_IC: // constant path array
+ case TS_CALLDATA: // ci is stored.
+ func(&OPERAND_AT(insn, j), data);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static void
+iseq_insn_each_object_write_barrier(VALUE * obj, VALUE iseq)
+{
+ RB_OBJ_WRITTEN(iseq, Qundef, *obj);
+ RUBY_ASSERT(SPECIAL_CONST_P(*obj) ||
+ RBASIC_CLASS(*obj) == 0 || // hidden
+ RB_OBJ_SHAREABLE_P(*obj));
+}
+
static INSN *
-new_insn_core(rb_iseq_t *iseq, const NODE *line_node,
- int insn_id, int argc, VALUE *argv)
+new_insn_core(rb_iseq_t *iseq, int line_no, int node_id, int insn_id, int argc, VALUE *argv)
{
INSN *iobj = compile_data_alloc_insn(iseq);
@@ -1254,31 +1387,58 @@ new_insn_core(rb_iseq_t *iseq, const NODE *line_node,
iobj->link.type = ISEQ_ELEMENT_INSN;
iobj->link.next = 0;
iobj->insn_id = insn_id;
- iobj->insn_info.line_no = nd_line(line_node);
- iobj->insn_info.node_id = nd_node_id(line_node);
+ iobj->insn_info.line_no = line_no;
+ iobj->insn_info.node_id = node_id;
iobj->insn_info.events = 0;
iobj->operands = argv;
iobj->operand_size = argc;
iobj->sc_state = 0;
+
+ iseq_insn_each_markable_object(iobj, iseq_insn_each_object_write_barrier, (VALUE)iseq);
+
return iobj;
}
static INSN *
-new_insn_body(rb_iseq_t *iseq, const NODE *const line_node, enum ruby_vminsn_type insn_id, int argc, ...)
+new_insn_body(rb_iseq_t *iseq, int line_no, int node_id, enum ruby_vminsn_type insn_id, int argc, ...)
{
VALUE *operands = 0;
va_list argv;
if (argc > 0) {
int i;
va_start(argv, argc);
- operands = compile_data_alloc2(iseq, sizeof(VALUE), argc);
+ operands = compile_data_alloc2_type(iseq, 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_node, insn_id, argc, operands);
+ return new_insn_core(iseq, line_no, node_id, insn_id, argc, operands);
+}
+
+static INSN *
+insn_replace_with_operands(rb_iseq_t *iseq, INSN *iobj, enum ruby_vminsn_type insn_id, int argc, ...)
+{
+ VALUE *operands = 0;
+ va_list argv;
+ if (argc > 0) {
+ int i;
+ va_start(argv, argc);
+ operands = compile_data_alloc2_type(iseq, VALUE, argc);
+ for (i = 0; i < argc; i++) {
+ VALUE v = va_arg(argv, VALUE);
+ operands[i] = v;
+ }
+ va_end(argv);
+ }
+
+ iobj->insn_id = insn_id;
+ iobj->operand_size = argc;
+ iobj->operands = operands;
+ iseq_insn_each_markable_object(iobj, iseq_insn_each_object_write_barrier, (VALUE)iseq);
+
+ return iobj;
}
static const struct rb_callinfo *
@@ -1286,16 +1446,16 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, unsigned int flag, struct rb_cal
{
VM_ASSERT(argc >= 0);
- if (!(flag & (VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG | VM_CALL_KW_SPLAT)) &&
- kw_arg == NULL && !has_blockiseq) {
- flag |= VM_CALL_ARGS_SIMPLE;
- }
-
if (kw_arg) {
flag |= VM_CALL_KWARG;
argc += kw_arg->keyword_len;
}
+ if (!(flag & (VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG | VM_CALL_KWARG | VM_CALL_KW_SPLAT | VM_CALL_FORWARDING))
+ && !has_blockiseq) {
+ flag |= VM_CALL_ARGS_SIMPLE;
+ }
+
ISEQ_BODY(iseq)->ci_size++;
const struct rb_callinfo *ci = vm_ci_new(mid, flag, argc, kw_arg);
RB_OBJ_WRITTEN(iseq, Qundef, ci);
@@ -1303,16 +1463,25 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, unsigned int flag, struct rb_cal
}
static INSN *
-new_insn_send(rb_iseq_t *iseq, const NODE *const line_node, ID id, VALUE argc, const rb_iseq_t *blockiseq, VALUE flag, struct rb_callinfo_kwarg *keywords)
+new_insn_send(rb_iseq_t *iseq, int line_no, int node_id, ID id, VALUE argc, const rb_iseq_t *blockiseq, VALUE flag, struct rb_callinfo_kwarg *keywords)
{
- VALUE *operands = compile_data_calloc2(iseq, sizeof(VALUE), 2);
+ VALUE *operands = compile_data_calloc2_type(iseq, VALUE, 2);
VALUE ci = (VALUE)new_callinfo(iseq, id, FIX2INT(argc), FIX2INT(flag), keywords, blockiseq != NULL);
operands[0] = ci;
operands[1] = (VALUE)blockiseq;
if (blockiseq) {
RB_OBJ_WRITTEN(iseq, Qundef, blockiseq);
}
- INSN *insn = new_insn_core(iseq, line_node, BIN(send), 2, operands);
+
+ INSN *insn;
+
+ if (vm_ci_flag((struct rb_callinfo *)ci) & VM_CALL_FORWARDING) {
+ insn = new_insn_core(iseq, line_no, node_id, BIN(sendforward), 2, operands);
+ }
+ else {
+ insn = new_insn_core(iseq, line_no, node_id, BIN(send), 2, operands);
+ }
+
RB_OBJ_WRITTEN(iseq, Qundef, ci);
RB_GC_GUARD(ci);
return insn;
@@ -1323,19 +1492,16 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
VALUE name, const rb_iseq_t *parent, enum rb_iseq_type type, int line_no)
{
rb_iseq_t *ret_iseq;
- rb_ast_body_t ast;
-
- ast.root = node;
- ast.compile_option = 0;
- ast.script_lines = ISEQ_BODY(iseq)->variable.script_lines;
+ VALUE ast_value = rb_ruby_ast_new(node);
debugs("[new_child_iseq]> ---------------------------------------\n");
int isolated_depth = ISEQ_COMPILE_DATA(iseq)->isolated_depth;
- ret_iseq = rb_iseq_new_with_opt(&ast, name,
+ ret_iseq = rb_iseq_new_with_opt(ast_value, name,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
line_no, parent,
isolated_depth ? isolated_depth + 1 : 0,
- type, ISEQ_COMPILE_DATA(iseq)->option);
+ type, ISEQ_COMPILE_DATA(iseq)->option,
+ ISEQ_BODY(iseq)->variable.script_lines);
debugs("[new_child_iseq]< ---------------------------------------\n");
return ret_iseq;
}
@@ -1355,11 +1521,14 @@ new_child_iseq_with_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_call
}
static void
-set_catch_except_p(struct rb_iseq_constant_body *body)
+set_catch_except_p(rb_iseq_t *iseq)
{
- body->catch_except_p = true;
- if (body->parent_iseq != NULL) {
- set_catch_except_p(ISEQ_BODY(body->parent_iseq));
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ ISEQ_COMPILE_DATA(iseq)->catch_except_p = true;
+ if (ISEQ_BODY(iseq)->parent_iseq != NULL) {
+ if (ISEQ_COMPILE_DATA(ISEQ_BODY(iseq)->parent_iseq)) {
+ set_catch_except_p((rb_iseq_t *) ISEQ_BODY(iseq)->parent_iseq);
+ }
}
}
@@ -1371,7 +1540,7 @@ set_catch_except_p(struct rb_iseq_constant_body *body)
So this function sets true for limited ISeqs with break/next/redo catch table entries
whose child ISeq would really raise an exception. */
static void
-update_catch_except_flags(struct rb_iseq_constant_body *body)
+update_catch_except_flags(rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
{
unsigned int pos;
size_t i;
@@ -1384,7 +1553,7 @@ update_catch_except_flags(struct rb_iseq_constant_body *body)
while (pos < body->iseq_size) {
insn = rb_vm_insn_decode(body->iseq_encoded[pos]);
if (insn == BIN(throw)) {
- set_catch_except_p(body);
+ set_catch_except_p(iseq);
break;
}
pos += insn_len(insn);
@@ -1399,7 +1568,8 @@ update_catch_except_flags(struct rb_iseq_constant_body *body)
if (entry->type != CATCH_TYPE_BREAK
&& entry->type != CATCH_TYPE_NEXT
&& entry->type != CATCH_TYPE_REDO) {
- body->catch_except_p = true;
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ ISEQ_COMPILE_DATA(iseq)->catch_except_p = true;
break;
}
}
@@ -1411,9 +1581,9 @@ iseq_insert_nop_between_end_and_cont(rb_iseq_t *iseq)
VALUE catch_table_ary = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
if (NIL_P(catch_table_ary)) return;
unsigned int i, tlen = (unsigned int)RARRAY_LEN(catch_table_ary);
- const VALUE *tptr = RARRAY_CONST_PTR_TRANSIENT(catch_table_ary);
+ const VALUE *tptr = RARRAY_CONST_PTR(catch_table_ary);
for (i = 0; i < tlen; i++) {
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
+ const VALUE *ptr = RARRAY_CONST_PTR(tptr[i]);
LINK_ELEMENT *end = (LINK_ELEMENT *)(ptr[2] & ~1);
LINK_ELEMENT *cont = (LINK_ELEMENT *)(ptr[4] & ~1);
LINK_ELEMENT *e;
@@ -1426,14 +1596,15 @@ iseq_insert_nop_between_end_and_cont(rb_iseq_t *iseq)
for (e = end; e && (IS_LABEL(e) || IS_TRACE(e)); e = e->next) {
if (e == cont) {
- NODE dummy_line_node = generate_dummy_line_node(0, -1);
- INSN *nop = new_insn_core(iseq, &dummy_line_node, BIN(nop), 0, 0);
+ INSN *nop = new_insn_core(iseq, 0, -1, BIN(nop), 0, 0);
ELEM_INSERT_NEXT(end, &nop->link);
break;
}
}
}
}
+
+ RB_GC_GUARD(catch_table_ary);
}
static int
@@ -1460,13 +1631,6 @@ iseq_setup_insn(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
dump_disasm_list(FIRST_ELEMENT(anchor));
}
- if (ISEQ_COMPILE_DATA(iseq)->option->stack_caching) {
- debugs("[compile step 3.3 (iseq_set_sequence_stackcaching)]\n");
- iseq_set_sequence_stackcaching(iseq, anchor);
- if (compile_debug > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
- }
-
debugs("[compile step 3.4 (iseq_insert_nop_between_end_and_cont)]\n");
iseq_insert_nop_between_end_and_cont(iseq);
if (compile_debug > 5)
@@ -1496,11 +1660,13 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (!rb_iseq_translate_threaded_code(iseq)) return COMPILE_NG;
debugs("[compile step 6 (update_catch_except_flags)] \n");
- update_catch_except_flags(ISEQ_BODY(iseq));
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ update_catch_except_flags(iseq, ISEQ_BODY(iseq));
debugs("[compile step 6.1 (remove unused catch tables)] \n");
- if (!ISEQ_BODY(iseq)->catch_except_p && ISEQ_BODY(iseq)->catch_table) {
- xfree(ISEQ_BODY(iseq)->catch_table);
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ if (!ISEQ_COMPILE_DATA(iseq)->catch_except_p && ISEQ_BODY(iseq)->catch_table) {
+ ruby_xfree_sized(ISEQ_BODY(iseq)->catch_table, iseq_catch_table_bytes(ISEQ_BODY(iseq)->catch_table->size));
ISEQ_BODY(iseq)->catch_table = NULL;
}
@@ -1526,6 +1692,7 @@ iseq_set_exception_local_table(rb_iseq_t *iseq)
{
ISEQ_BODY(iseq)->local_table_size = numberof(rb_iseq_shared_exc_local_tbl);
ISEQ_BODY(iseq)->local_table = rb_iseq_shared_exc_local_tbl;
+ ISEQ_BODY(iseq)->lvar_states = NULL; // $! is read-only, so don't need lvar_states
return COMPILE_OK;
}
@@ -1635,7 +1802,7 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write)
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not yield from isolated Proc");
}
else {
- COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not access variable `%s' from isolated Proc", rb_id2name(id));
+ COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq), "can not access variable '%s' from isolated Proc", rb_id2name(id));
}
}
@@ -1673,6 +1840,46 @@ iseq_lvar_id(const rb_iseq_t *iseq, int idx, int level)
}
static void
+update_lvar_state(const rb_iseq_t *iseq, int level, int idx)
+{
+ for (int i=0; i<level; i++) {
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
+ }
+
+ enum lvar_state *states = ISEQ_BODY(iseq)->lvar_states;
+ int table_idx = ISEQ_BODY(iseq)->local_table_size - idx;
+ switch (states[table_idx]) {
+ case lvar_uninitialized:
+ states[table_idx] = lvar_initialized;
+ break;
+ case lvar_initialized:
+ states[table_idx] = lvar_reassigned;
+ break;
+ case lvar_reassigned:
+ /* nothing */
+ break;
+ default:
+ rb_bug("unreachable");
+ }
+}
+
+static int
+iseq_set_parameters_lvar_state(const rb_iseq_t *iseq)
+{
+ for (unsigned int i=0; i<ISEQ_BODY(iseq)->param.size; i++) {
+ ISEQ_BODY(iseq)->lvar_states[i] = lvar_initialized;
+ }
+
+ int lead_num = ISEQ_BODY(iseq)->param.lead_num;
+ int opt_num = ISEQ_BODY(iseq)->param.opt_num;
+ for (int i=0; i<opt_num; i++) {
+ ISEQ_BODY(iseq)->lvar_states[lead_num + i] = lvar_uninitialized;
+ }
+
+ return COMPILE_OK;
+}
+
+static void
iseq_add_getlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *const line_node, int idx, int level)
{
if (iseq_local_block_param_p(iseq, idx, level)) {
@@ -1693,6 +1900,7 @@ iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *const lin
else {
ADD_INSN2(seq, line_node, setlocal, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
}
+ update_lvar_state(iseq, level, idx);
if (level > 0) access_outer_variables(iseq, level, iseq_lvar_id(iseq, idx, level), Qtrue);
}
@@ -1740,7 +1948,7 @@ static int
iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
const struct rb_args_info *args, int arg_size)
{
- const NODE *node = args->kw_args;
+ const rb_node_kw_arg_t *node = args->kw_args;
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
struct rb_iseq_param_keyword *keyword;
const VALUE default_values = rb_ary_hidden_new(1);
@@ -1759,7 +1967,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
node = args->kw_args;
while (node) {
- const NODE *val_node = node->nd_body->nd_value;
+ const NODE *val_node = get_nd_value(node->nd_body);
VALUE dv;
if (val_node == NODE_SPECIAL_REQUIRED_KEYWORD) {
@@ -1767,8 +1975,29 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
}
else {
switch (nd_type(val_node)) {
- case NODE_LIT:
- dv = val_node->nd_lit;
+ case NODE_SYM:
+ dv = rb_node_sym_string_val(val_node);
+ break;
+ case NODE_REGX:
+ dv = rb_node_regx_string_val(val_node);
+ break;
+ case NODE_LINE:
+ dv = rb_node_line_lineno_val(val_node);
+ break;
+ case NODE_INTEGER:
+ dv = rb_node_integer_literal_val(val_node);
+ break;
+ case NODE_FLOAT:
+ dv = rb_node_float_literal_val(val_node);
+ break;
+ case NODE_RATIONAL:
+ dv = rb_node_rational_literal_val(val_node);
+ break;
+ case NODE_IMAGINARY:
+ dv = rb_node_imaginary_literal_val(val_node);
+ break;
+ case NODE_ENCODING:
+ dv = rb_node_encoding_val(val_node);
break;
case NODE_NIL:
dv = Qnil;
@@ -1780,7 +2009,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
dv = Qfalse;
break;
default:
- NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type_p(node, NODE_KW_ARG) */
+ NO_CHECK(COMPILE_POPPED(optargs, "kwarg", RNODE(node))); /* nd_type_p(node, NODE_KW_ARG) */
dv = complex_mark;
}
@@ -1793,23 +2022,24 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
keyword->num = kw;
- if (args->kw_rest_arg->nd_vid != 0) {
+ if (RNODE_DVAR(args->kw_rest_arg)->nd_vid != 0) {
+ ID kw_id = ISEQ_BODY(iseq)->local_table[arg_size];
keyword->rest_start = arg_size++;
body->param.flags.has_kwrest = TRUE;
+
+ if (kw_id == idPow) body->param.flags.anon_kwrest = TRUE;
}
keyword->required_num = rkw;
keyword->table = &body->local_table[keyword->bits_start - keyword->num];
- {
+ if (RARRAY_LEN(default_values)) {
VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values));
for (i = 0; i < RARRAY_LEN(default_values); i++) {
VALUE dv = RARRAY_AREF(default_values, i);
if (dv == complex_mark) dv = Qundef;
- if (!SPECIAL_CONST_P(dv)) {
- RB_OBJ_WRITTEN(iseq, Qundef, dv);
- }
- dvs[i] = dv;
+ if (!SPECIAL_CONST_P(dv)) rb_ractor_make_shareable(dv);
+ RB_OBJ_WRITE(iseq, &dvs[i], dv);
}
keyword->default_values = dvs;
@@ -1817,6 +2047,22 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
return arg_size;
}
+static void
+iseq_set_use_block(rb_iseq_t *iseq)
+{
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
+ if (!body->param.flags.use_block) {
+ body->param.flags.use_block = 1;
+
+ rb_vm_t *vm = GET_VM();
+
+ if (!rb_warning_category_enabled_p(RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK)) {
+ st_data_t key = (st_data_t)rb_intern_str(body->location.label); // String -> ID
+ set_insert(&vm->unused_block_warning_table, key);
+ }
+ }
+}
+
static int
iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *const node_args)
{
@@ -1824,7 +2070,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
if (node_args) {
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- struct rb_args_info *args = node_args->nd_ainfo;
+ const struct rb_args_info *const args = &RNODE_ARGS(node_args)->nd_ainfo;
ID rest_id = 0;
int last_comma = 0;
ID block_id = 0;
@@ -1832,7 +2078,6 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
EXPECT_NODE("iseq_set_arguments", node_args, NODE_ARGS, COMPILE_NG);
- body->param.flags.ruby2_keywords = args->ruby2_keywords;
body->param.lead_num = arg_size = (int)args->pre_args_num;
if (body->param.lead_num > 0) body->param.flags.has_lead = TRUE;
debugs(" - argc: %d\n", body->param.lead_num);
@@ -1844,15 +2089,22 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
}
block_id = args->block_arg;
+ bool optimized_forward = (args->forwarding && args->pre_args_num == 0 && !args->opt_args);
+
+ if (optimized_forward) {
+ rest_id = 0;
+ block_id = 0;
+ }
+
if (args->opt_args) {
- const NODE *node = args->opt_args;
+ const rb_node_opt_arg_t *node = args->opt_args;
LABEL *label;
VALUE labels = rb_ary_hidden_new(1);
VALUE *opt_table;
int i = 0, j;
while (node) {
- label = NEW_LABEL(nd_line(node));
+ label = NEW_LABEL(nd_line(RNODE(node)));
rb_ary_push(labels, (VALUE)label | 1);
ADD_LABEL(optargs, label);
NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body));
@@ -1867,7 +2119,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
opt_table = ALLOC_N(VALUE, i+1);
- MEMCPY(opt_table, RARRAY_CONST_PTR_TRANSIENT(labels), VALUE, i+1);
+ MEMCPY(opt_table, RARRAY_CONST_PTR(labels), VALUE, i+1);
for (j = 0; j < i+1; j++) {
opt_table[j] &= ~1;
}
@@ -1882,7 +2134,8 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
if (rest_id) {
body->param.rest_start = arg_size++;
body->param.flags.has_rest = TRUE;
- assert(body->param.rest_start != -1);
+ if (rest_id == '*') body->param.flags.anon_rest = TRUE;
+ RUBY_ASSERT(body->param.rest_start != -1);
}
if (args->first_post_arg) {
@@ -1899,19 +2152,35 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
if (args->kw_args) {
arg_size = iseq_set_arguments_keywords(iseq, optargs, args, arg_size);
}
- else if (args->kw_rest_arg) {
+ else if (args->kw_rest_arg && !optimized_forward) {
+ ID kw_id = ISEQ_BODY(iseq)->local_table[arg_size];
struct rb_iseq_param_keyword *keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
keyword->rest_start = arg_size++;
body->param.keyword = keyword;
body->param.flags.has_kwrest = TRUE;
+
+ static ID anon_kwrest = 0;
+ if (!anon_kwrest) anon_kwrest = rb_intern("**");
+ if (kw_id == anon_kwrest) body->param.flags.anon_kwrest = TRUE;
}
else if (args->no_kwarg) {
body->param.flags.accepts_no_kwarg = TRUE;
}
- if (block_id) {
+ if (args->no_blockarg) {
+ body->param.flags.accepts_no_block = TRUE;
+ }
+ else if (block_id) {
body->param.block_start = arg_size++;
body->param.flags.has_block = TRUE;
+ iseq_set_use_block(iseq);
+ }
+
+ // Only optimize specifically methods like this: `foo(...)`
+ if (optimized_forward) {
+ body->param.flags.use_block = 1;
+ body->param.flags.forwardable = TRUE;
+ arg_size = 1;
}
iseq_calc_param_size(iseq);
@@ -1943,14 +2212,36 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
}
static int
-iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl)
+iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl, const NODE *const node_args)
{
unsigned int size = tbl ? tbl->size : 0;
+ unsigned int offset = 0;
+
+ if (node_args) {
+ struct rb_args_info *args = &RNODE_ARGS(node_args)->nd_ainfo;
+
+ // If we have a function that only has `...` as the parameter,
+ // then its local table should only be `...`
+ // FIXME: I think this should be fixed in the AST rather than special case here.
+ if (args->forwarding && args->pre_args_num == 0 && !args->opt_args) {
+ CHECK(size >= 3);
+ size -= 3;
+ offset += 3;
+ }
+ }
if (size > 0) {
- ID *ids = (ID *)ALLOC_N(ID, size);
- MEMCPY(ids, tbl->ids, ID, size);
+ ID *ids = ALLOC_N(ID, size);
+ MEMCPY(ids, tbl->ids + offset, ID, size);
ISEQ_BODY(iseq)->local_table = ids;
+
+ enum lvar_state *states = ALLOC_N(enum lvar_state, size);
+ // fprintf(stderr, "iseq:%p states:%p size:%d\n", iseq, states, (int)size);
+ for (unsigned int i=0; i<size; i++) {
+ states[i] = lvar_uninitialized;
+ // fprintf(stderr, "id:%s\n", rb_id2name(ISEQ_BODY(iseq)->local_table[i]));
+ }
+ ISEQ_BODY(iseq)->lvar_states = states;
}
ISEQ_BODY(iseq)->local_table_size = size;
@@ -2039,6 +2330,33 @@ static const struct st_hash_type cdhash_type = {
rb_iseq_cdhash_hash,
};
+static VALUE
+cdhash_new(size_t size)
+{
+ VALUE cdhash = rb_imemo_cdhash_new(size, &cdhash_type);
+ RB_OBJ_SET_SHAREABLE(cdhash);
+ return cdhash;
+}
+
+static void
+cdhash_aset(VALUE cdhash, VALUE key, VALUE val)
+{
+ st_table *tbl = rb_imemo_cdhash_tbl(cdhash);
+ st_insert(tbl, key, val);
+ RB_OBJ_WRITTEN(cdhash, Qundef, key);
+}
+
+static void
+cdhash_aset_if_missing(VALUE cdhash, VALUE key, VALUE val)
+{
+ st_table *tbl = rb_imemo_cdhash_tbl(cdhash);
+ VALUE dontcare;
+ if (!st_lookup(tbl, key, &dontcare)) {
+ st_insert(tbl, key, val);
+ RB_OBJ_WRITTEN(cdhash, Qundef, key);
+ }
+}
+
struct cdhash_set_label_struct {
VALUE hash;
int pos;
@@ -2046,15 +2364,20 @@ struct cdhash_set_label_struct {
};
static int
-cdhash_set_label_i(VALUE key, VALUE val, VALUE ptr)
+cdhash_set_label_check_i(st_data_t key, st_data_t value, st_data_t argp, int error)
+{
+ return ST_REPLACE;
+}
+
+static int
+cdhash_set_label_replace_i(st_data_t *key, st_data_t *value, st_data_t ptr, int existing)
{
struct cdhash_set_label_struct *data = (struct cdhash_set_label_struct *)ptr;
- LABEL *lobj = (LABEL *)(val & ~1);
- rb_hash_aset(data->hash, key, INT2FIX(lobj->position - (data->pos+data->len)));
+ LABEL *lobj = (LABEL *)(*value & ~1);
+ *value = lobj->position - (data->pos+data->len);
return ST_CONTINUE;
}
-
static inline VALUE
get_ivar_ic_value(rb_iseq_t *iseq,ID id)
{
@@ -2084,8 +2407,8 @@ get_cvar_ic_value(rb_iseq_t *iseq,ID id)
dump_disasm_list_with_cursor(FIRST_ELEMENT(anchor), list, dest)
#define BADINSN_ERROR \
- (xfree(generated_iseq), \
- xfree(insns_info), \
+ (SIZED_FREE_N(generated_iseq, generated_iseq_size), \
+ SIZED_FREE_N(insns_info, insns_info_size), \
BADINSN_DUMP(anchor, list, NULL), \
COMPILE_ERROR)
@@ -2233,6 +2556,7 @@ add_adjust_info(struct iseq_insn_info_entry *insns_info, unsigned int *positions
int insns_info_index, int code_index, const ADJUST *adjust)
{
insns_info[insns_info_index].line_no = adjust->line_no;
+ insns_info[insns_info_index].node_id = -1;
insns_info[insns_info_index].events = 0;
positions[insns_info_index] = code_index;
return TRUE;
@@ -2244,7 +2568,7 @@ array_to_idlist(VALUE arr)
RUBY_ASSERT(RB_TYPE_P(arr, T_ARRAY));
long size = RARRAY_LEN(arr);
ID *ids = (ID *)ALLOC_N(ID, size + 1);
- for (int i = 0; i < size; i++) {
+ for (long i = 0; i < size; i++) {
VALUE sym = RARRAY_AREF(arr, i);
ids[i] = SYM2ID(sym);
}
@@ -2350,11 +2674,27 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
}
/* make instruction sequence */
+ const int generated_iseq_size = code_index;
generated_iseq = ALLOC_N(VALUE, code_index);
+
+ const int insns_info_size = insn_num;
insns_info = ALLOC_N(struct iseq_insn_info_entry, insn_num);
+
+ const int positions_size = insn_num;
positions = ALLOC_N(unsigned int, insn_num);
- body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(body));
- body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size);
+ if (ISEQ_IS_SIZE(body)) {
+ body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(body));
+ }
+ else {
+ body->is_entries = NULL;
+ }
+
+ if (body->ci_size) {
+ body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size);
+ }
+ else {
+ body->call_data = NULL;
+ }
ISEQ_COMPILE_DATA(iseq)->ci_index = 0;
// Calculate the bitmask buffer size.
@@ -2365,16 +2705,22 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
iseq_bits_t * mark_offset_bits;
int code_size = code_index;
- iseq_bits_t tmp[1] = {0};
bool needs_bitmap = false;
- if (ISEQ_MBITS_BUFLEN(code_index) == 1) {
- mark_offset_bits = tmp;
+ const size_t mark_offset_bits_size = ISEQ_MBITS_BUFLEN(code_index);
+ if (mark_offset_bits_size == 1) {
+ mark_offset_bits = &ISEQ_COMPILE_DATA(iseq)->mark_bits.single;
+ ISEQ_COMPILE_DATA(iseq)->is_single_mark_bit = true;
}
else {
- mark_offset_bits = ZALLOC_N(iseq_bits_t, ISEQ_MBITS_BUFLEN(code_index));
+ mark_offset_bits = ZALLOC_N(iseq_bits_t, mark_offset_bits_size);
+ ISEQ_COMPILE_DATA(iseq)->mark_bits.list = mark_offset_bits;
+ ISEQ_COMPILE_DATA(iseq)->is_single_mark_bit = false;
}
+ ISEQ_COMPILE_DATA(iseq)->iseq_encoded = (void *)generated_iseq;
+ ISEQ_COMPILE_DATA(iseq)->iseq_size = code_index;
+
list = FIRST_ELEMENT(anchor);
insns_info_index = code_index = sp = 0;
@@ -2415,10 +2761,8 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
data.hash = map;
data.pos = code_index;
data.len = len;
- rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data);
+ st_foreach_with_replace(rb_imemo_cdhash_tbl(map), cdhash_set_label_check_i, cdhash_set_label_replace_i, (VALUE)&data);
- rb_hash_rehash(map);
- freeze_hide_obj(map);
generated_iseq[code_index + 1 + j] = map;
ISEQ_MBITS_SET(mark_offset_bits, code_index + 1 + j);
RB_OBJ_WRITTEN(iseq, Qundef, map);
@@ -2467,12 +2811,12 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (insn == BIN(setinstancevariable)) {
cache->iv_set_name = SYM2ID(operands[j - 1]);
+ cache->value = IVAR_CACHE_INIT;
}
else {
cache->iv_set_name = 0;
+ cache->value = rb_getivar_cache_pack(ROOT_SHAPE_ID, ATTR_INDEX_NOT_SET);
}
-
- vm_ic_attr_index_initialize(cache, INVALID_SHAPE_ID);
}
case TS_ISE: /* inline storage entry: `once` insn */
case TS_ICVARC: /* inline cvar cache */
@@ -2489,11 +2833,11 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
break;
}
- case TS_CALLDATA:
+ case TS_CALLDATA:
{
const struct rb_callinfo *source_ci = (const struct rb_callinfo *)operands[j];
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size);
struct rb_call_data *cd = &body->call_data[ISEQ_COMPILE_DATA(iseq)->ci_index++];
- assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size);
cd->ci = source_ci;
cd->cc = vm_cc_empty();
generated_iseq[code_index + 1 + j] = (VALUE)cd;
@@ -2559,11 +2903,11 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
}
else if (diff < 0) {
int label_no = adjust->label ? adjust->label->label_no : -1;
- xfree(generated_iseq);
- xfree(insns_info);
- xfree(positions);
+ SIZED_FREE_N(generated_iseq, generated_iseq_size);
+ SIZED_FREE_N(insns_info, insns_info_size);
+ SIZED_FREE_N(positions, positions_size);
if (ISEQ_MBITS_BUFLEN(code_size) > 1) {
- xfree(mark_offset_bits);
+ SIZED_FREE_N(mark_offset_bits, ISEQ_MBITS_BUFLEN(code_index));
}
debug_list(anchor, list);
COMPILE_ERROR(iseq, adjust->line_no,
@@ -2585,16 +2929,17 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
body->iseq_size = code_index;
body->stack_max = stack_max;
- if (ISEQ_MBITS_BUFLEN(body->iseq_size) == 1) {
- body->mark_bits.single = mark_offset_bits[0];
+ if (ISEQ_COMPILE_DATA(iseq)->is_single_mark_bit) {
+ body->mark_bits.single = ISEQ_COMPILE_DATA(iseq)->mark_bits.single;
}
else {
if (needs_bitmap) {
body->mark_bits.list = mark_offset_bits;
}
else {
- body->mark_bits.list = 0;
- ruby_xfree(mark_offset_bits);
+ body->mark_bits.list = NULL;
+ ISEQ_COMPILE_DATA(iseq)->mark_bits.list = NULL;
+ SIZED_FREE_N(mark_offset_bits, mark_offset_bits_size);
}
}
@@ -2602,9 +2947,9 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
body->insns_info.body = insns_info;
body->insns_info.positions = positions;
- REALLOC_N(insns_info, struct iseq_insn_info_entry, insns_info_index);
+ SIZED_REALLOC_N(insns_info, struct iseq_insn_info_entry, insns_info_index, insns_info_size);
body->insns_info.body = insns_info;
- REALLOC_N(positions, unsigned int, insns_info_index);
+ SIZED_REALLOC_N(positions, unsigned int, insns_info_index, positions_size);
body->insns_info.positions = positions;
body->insns_info.size = insns_info_index;
@@ -2631,20 +2976,27 @@ iseq_set_exception_table(rb_iseq_t *iseq)
struct iseq_catch_table_entry *entry;
ISEQ_BODY(iseq)->catch_table = NULL;
- if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) return COMPILE_OK;
- tlen = (int)RARRAY_LEN(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
- tptr = RARRAY_CONST_PTR_TRANSIENT(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
+
+ VALUE catch_table_ary = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
+ if (NIL_P(catch_table_ary)) return COMPILE_OK;
+ tlen = (int)RARRAY_LEN(catch_table_ary);
+ tptr = RARRAY_CONST_PTR(catch_table_ary);
if (tlen > 0) {
struct iseq_catch_table *table = xmalloc(iseq_catch_table_bytes(tlen));
table->size = tlen;
for (i = 0; i < table->size; i++) {
- ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
+ int pos;
+ ptr = RARRAY_CONST_PTR(tptr[i]);
entry = UNALIGNED_MEMBER_PTR(table, entries[i]);
entry->type = (enum rb_catch_type)(ptr[0] & 0xffff);
- entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
- entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
+ pos = label_get_position((LABEL *)(ptr[1] & ~1));
+ RUBY_ASSERT(pos >= 0);
+ entry->start = (unsigned int)pos;
+ pos = label_get_position((LABEL *)(ptr[2] & ~1));
+ RUBY_ASSERT(pos >= 0);
+ entry->end = (unsigned int)pos;
entry->iseq = (rb_iseq_t *)ptr[3];
RB_OBJ_WRITTEN(iseq, Qundef, entry->iseq);
@@ -2658,6 +3010,7 @@ iseq_set_exception_table(rb_iseq_t *iseq)
if (entry->type == CATCH_TYPE_RESCUE ||
entry->type == CATCH_TYPE_BREAK ||
entry->type == CATCH_TYPE_NEXT) {
+ RUBY_ASSERT(entry->sp > 0);
entry->sp--;
}
}
@@ -2669,6 +3022,8 @@ iseq_set_exception_table(rb_iseq_t *iseq)
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, 0); /* free */
}
+ RB_GC_GUARD(catch_table_ary);
+
return COMPILE_OK;
}
@@ -2765,16 +3120,18 @@ unref_destination(INSN *iobj, int pos)
if (!lobj->refcnt) ELEM_REMOVE(&lobj->link);
}
-static void
+static bool
replace_destination(INSN *dobj, INSN *nobj)
{
VALUE n = OPERAND_AT(nobj, 0);
LABEL *dl = (LABEL *)OPERAND_AT(dobj, 0);
LABEL *nl = (LABEL *)n;
+ if (dl == nl) return false;
--dl->refcnt;
++nl->refcnt;
OPERAND_AT(dobj, 0) = n;
if (!dl->refcnt) ELEM_REMOVE(&dl->link);
+ return true;
}
static LABEL*
@@ -2807,7 +3164,6 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
break;
}
else if ((lab = find_destination((INSN *)i)) != 0) {
- if (lab->unremovable) break;
unref_counts[lab->label_no]++;
}
}
@@ -2824,8 +3180,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
/* do nothing */
}
else if (IS_ADJUST(i)) {
- LABEL *dest = ((ADJUST *)i)->label;
- if (dest && dest->unremovable) return 0;
+ return 0;
}
end = i;
} while ((i = i->next) != 0);
@@ -2870,7 +3225,7 @@ iseq_pop_newarray(rb_iseq_t *iseq, INSN *iobj)
static int
is_frozen_putstring(INSN *insn, VALUE *op)
{
- if (IS_INSN_ID(insn, putstring)) {
+ if (IS_INSN_ID(insn, dupstring) || IS_INSN_ID(insn, dupchilledstring)) {
*op = OPERAND_AT(insn, 0);
return 1;
}
@@ -2882,6 +3237,25 @@ is_frozen_putstring(INSN *insn, VALUE *op)
}
static int
+insn_has_label_before(LINK_ELEMENT *elem)
+{
+ LINK_ELEMENT *prev = elem->prev;
+ while (prev) {
+ if (prev->type == ISEQ_ELEMENT_LABEL) {
+ LABEL *label = (LABEL *)prev;
+ if (label->refcnt > 0) {
+ return 1;
+ }
+ }
+ else if (prev->type == ISEQ_ELEMENT_INSN) {
+ break;
+ }
+ prev = prev->prev;
+ }
+ return 0;
+}
+
+static int
optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
{
/*
@@ -2911,7 +3285,8 @@ optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
VALUE type;
switch (INSN_OF(iobj)) {
- case BIN(putstring):
+ case BIN(dupstring):
+ case BIN(dupchilledstring):
type = INT2FIX(T_STRING);
break;
case BIN(putnil):
@@ -2952,7 +3327,6 @@ optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
}
line = ciobj->insn_info.line_no;
node_id = ciobj->insn_info.node_id;
- NODE dummy_line_node = generate_dummy_line_node(line, node_id);
if (!dest) {
if (niobj->link.next && IS_LABEL(niobj->link.next)) {
dest = (LABEL *)niobj->link.next; /* reuse label */
@@ -2962,9 +3336,9 @@ optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
ELEM_INSERT_NEXT(&niobj->link, &dest->link);
}
}
- INSERT_AFTER_INSN1(iobj, &dummy_line_node, jump, dest);
+ INSERT_AFTER_INSN1(iobj, line, node_id, jump, dest);
LABEL_REF(dest);
- if (!dup) INSERT_AFTER_INSN(iobj, &dummy_line_node, pop);
+ if (!dup) INSERT_AFTER_INSN(iobj, line, node_id, pop);
return TRUE;
}
@@ -2990,6 +3364,8 @@ ci_argc_set(const rb_iseq_t *iseq, const struct rb_callinfo *ci, int argc)
return nci;
}
+#define vm_ci_simple(ci) (vm_ci_flag(ci) & VM_CALL_ARGS_SIMPLE)
+
static int
iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
{
@@ -3028,9 +3404,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* => in this case, first jump instruction should jump to
* LABEL2 directly
*/
- replace_destination(iobj, diobj);
- remove_unreachable_chunk(iseq, iobj->link.next);
- goto again;
+ if (replace_destination(iobj, diobj)) {
+ remove_unreachable_chunk(iseq, iobj->link.next);
+ goto again;
+ }
}
else if (IS_INSN_ID(diobj, leave)) {
/*
@@ -3075,8 +3452,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
*/
piobj->insn_id = (IS_INSN_ID(piobj, branchif))
? BIN(branchunless) : BIN(branchif);
- replace_destination(piobj, iobj);
- if (refcnt <= 1) {
+ if (replace_destination(piobj, iobj) && refcnt <= 1) {
ELEM_REMOVE(&iobj->link);
}
else {
@@ -3098,8 +3474,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* pop
* jump L1
*/
- NODE dummy_line_node = generate_dummy_line_node(iobj->insn_info.line_no, iobj->insn_info.node_id);
- INSN *popiobj = new_insn_core(iseq, &dummy_line_node, BIN(pop), 0, 0);
+ INSN *popiobj = new_insn_core(iseq, iobj->insn_info.line_no, iobj->insn_info.node_id, BIN(pop), 0, 0);
ELEM_REPLACE(&piobj->link, &popiobj->link);
}
}
@@ -3109,8 +3484,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
/*
- * putstring "beg"
- * putstring "end"
+ * dupstring "beg"
+ * dupstring "end"
* newrange excl
*
* ==>
@@ -3125,9 +3500,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if ((end = (INSN *)get_prev_insn(range)) != 0 &&
is_frozen_putstring(end, &str_end) &&
(beg = (INSN *)get_prev_insn(end)) != 0 &&
- is_frozen_putstring(beg, &str_beg)) {
+ is_frozen_putstring(beg, &str_beg) &&
+ !(insn_has_label_before(&beg->link) || insn_has_label_before(&end->link))) {
int excl = FIX2INT(OPERAND_AT(range, 0));
- VALUE lit_range = rb_range_new(str_beg, str_end, excl);
+ VALUE lit_range = RB_OBJ_SET_SHAREABLE(rb_range_new(str_beg, str_end, excl));
ELEM_REMOVE(&beg->link);
ELEM_REMOVE(&end->link);
@@ -3144,19 +3520,102 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
/*
* ...
* duparray [...]
- * concatarray
+ * concatarray | concattoarray
* =>
* ...
* putobject [...]
- * concatarray
+ * concatarray | concattoarray
*/
if (IS_INSN_ID(iobj, duparray)) {
LINK_ELEMENT *next = iobj->link.next;
- if (IS_INSN(next) && IS_INSN_ID(next, concatarray)) {
+ if (IS_INSN(next) && (IS_INSN_ID(next, concatarray) || IS_INSN_ID(next, concattoarray))) {
iobj->insn_id = BIN(putobject);
}
}
+ /*
+ * duparray [...]
+ * send <calldata!mid:freeze, argc:0, ARGS_SIMPLE>, nil
+ * =>
+ * opt_ary_freeze [...], <calldata!mid:freeze, argc:0, ARGS_SIMPLE>
+ */
+ if (IS_INSN_ID(iobj, duparray)) {
+ LINK_ELEMENT *next = iobj->link.next;
+ if (IS_INSN(next) && (IS_INSN_ID(next, send))) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(next, 0);
+ const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(next, 1);
+
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && blockiseq == NULL && vm_ci_mid(ci) == idFreeze) {
+ VALUE ary = iobj->operands[0];
+ rb_obj_reveal(ary, rb_cArray);
+
+ insn_replace_with_operands(iseq, iobj, BIN(opt_ary_freeze), 2, ary, (VALUE)ci);
+ ELEM_REMOVE(next);
+ }
+ }
+ }
+
+ /*
+ * duphash {...}
+ * send <calldata!mid:freeze, argc:0, ARGS_SIMPLE>, nil
+ * =>
+ * opt_hash_freeze {...}, <calldata!mid:freeze, argc:0, ARGS_SIMPLE>
+ */
+ if (IS_INSN_ID(iobj, duphash)) {
+ LINK_ELEMENT *next = iobj->link.next;
+ if (IS_INSN(next) && (IS_INSN_ID(next, send))) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(next, 0);
+ const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(next, 1);
+
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && blockiseq == NULL && vm_ci_mid(ci) == idFreeze) {
+ VALUE hash = iobj->operands[0];
+ rb_obj_reveal(hash, rb_cHash);
+ RB_OBJ_SET_SHAREABLE(hash);
+
+ insn_replace_with_operands(iseq, iobj, BIN(opt_hash_freeze), 2, hash, (VALUE)ci);
+ ELEM_REMOVE(next);
+ }
+ }
+ }
+
+ /*
+ * newarray 0
+ * send <calldata!mid:freeze, argc:0, ARGS_SIMPLE>, nil
+ * =>
+ * opt_ary_freeze [], <calldata!mid:freeze, argc:0, ARGS_SIMPLE>
+ */
+ if (IS_INSN_ID(iobj, newarray) && iobj->operands[0] == INT2FIX(0)) {
+ LINK_ELEMENT *next = iobj->link.next;
+ if (IS_INSN(next) && (IS_INSN_ID(next, send))) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(next, 0);
+ const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(next, 1);
+
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && blockiseq == NULL && vm_ci_mid(ci) == idFreeze) {
+ insn_replace_with_operands(iseq, iobj, BIN(opt_ary_freeze), 2, rb_cArray_empty_frozen, (VALUE)ci);
+ ELEM_REMOVE(next);
+ }
+ }
+ }
+
+ /*
+ * newhash 0
+ * send <calldata!mid:freeze, argc:0, ARGS_SIMPLE>, nil
+ * =>
+ * opt_hash_freeze {}, <calldata!mid:freeze, argc:0, ARGS_SIMPLE>
+ */
+ if (IS_INSN_ID(iobj, newhash) && iobj->operands[0] == INT2FIX(0)) {
+ LINK_ELEMENT *next = iobj->link.next;
+ if (IS_INSN(next) && (IS_INSN_ID(next, send))) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(next, 0);
+ const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(next, 1);
+
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && blockiseq == NULL && vm_ci_mid(ci) == idFreeze) {
+ insn_replace_with_operands(iseq, iobj, BIN(opt_hash_freeze), 2, rb_cHash_empty_frozen, (VALUE)ci);
+ ELEM_REMOVE(next);
+ }
+ }
+ }
+
if (IS_INSN_ID(iobj, branchif) ||
IS_INSN_ID(iobj, branchnil) ||
IS_INSN_ID(iobj, branchunless)) {
@@ -3206,7 +3665,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
for (;;) {
if (IS_INSN(&nobj->link) && IS_INSN_ID(nobj, jump)) {
- replace_destination(iobj, nobj);
+ if (!replace_destination(iobj, nobj)) break;
}
else if (prev_dup && IS_INSN_ID(nobj, dup) &&
!!(nobj = (INSN *)nobj->link.next) &&
@@ -3227,7 +3686,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* dup
* if L2
*/
- replace_destination(iobj, nobj);
+ if (!replace_destination(iobj, nobj)) break;
}
else if (pobj) {
/*
@@ -3241,16 +3700,16 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* =>
* jump L1
*
- * putstring ".."
+ * dupstring ".."
* if L1
* =>
* jump L1
*
- * putstring ".."
+ * dupstring ".."
* dup
* if L1
* =>
- * putstring ".."
+ * dupstring ".."
* jump L1
*
*/
@@ -3265,7 +3724,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
OPERAND_AT(pobj, 0) == Qfalse :
FALSE);
}
- else if (IS_INSN_ID(pobj, putstring) ||
+ else if (IS_INSN_ID(pobj, dupstring) ||
IS_INSN_ID(pobj, duparray) ||
IS_INSN_ID(pobj, newarray)) {
cond = IS_INSN_ID(iobj, branchif);
@@ -3278,14 +3737,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
ELEM_REMOVE(iobj->link.prev);
}
else if (!iseq_pop_newarray(iseq, pobj)) {
- NODE dummy_line_node = generate_dummy_line_node(pobj->insn_info.line_no, pobj->insn_info.node_id);
- pobj = new_insn_core(iseq, &dummy_line_node, BIN(pop), 0, NULL);
+ pobj = new_insn_core(iseq, pobj->insn_info.line_no, pobj->insn_info.node_id, BIN(pop), 0, NULL);
ELEM_INSERT_PREV(&iobj->link, &pobj->link);
}
if (cond) {
if (prev_dup) {
- NODE dummy_line_node = generate_dummy_line_node(pobj->insn_info.line_no, pobj->insn_info.node_id);
- pobj = new_insn_core(iseq, &dummy_line_node, BIN(putnil), 0, NULL);
+ pobj = new_insn_core(iseq, pobj->insn_info.line_no, pobj->insn_info.node_id, BIN(putnil), 0, NULL);
ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
}
iobj->insn_id = BIN(jump);
@@ -3305,7 +3762,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (IS_INSN_ID(iobj, pop)) {
/*
- * putself / putnil / putobject obj / putstring "..."
+ * putself / putnil / putobject obj / dupstring "..."
* pop
* =>
* # do nothing
@@ -3314,7 +3771,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (IS_INSN(prev)) {
enum ruby_vminsn_type previ = ((INSN *)prev)->insn_id;
if (previ == BIN(putobject) || previ == BIN(putnil) ||
- previ == BIN(putself) || previ == BIN(putstring) ||
+ previ == BIN(putself) || previ == BIN(dupstring) ||
+ previ == BIN(dupchilledstring) ||
previ == BIN(dup) ||
previ == BIN(getlocal) ||
previ == BIN(getblockparam) ||
@@ -3331,8 +3789,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
else if (previ == BIN(concatarray)) {
INSN *piobj = (INSN *)prev;
- NODE dummy_line_node = generate_dummy_line_node(piobj->insn_info.line_no, piobj->insn_info.node_id);
- INSERT_BEFORE_INSN1(piobj, &dummy_line_node, splatarray, Qfalse);
+ INSERT_BEFORE_INSN1(piobj, piobj->insn_info.line_no, piobj->insn_info.node_id, splatarray, Qfalse);
INSN_OF(piobj) = BIN(pop);
}
else if (previ == BIN(concatstrings)) {
@@ -3349,7 +3806,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (IS_INSN_ID(iobj, newarray) ||
IS_INSN_ID(iobj, duparray) ||
- IS_INSN_ID(iobj, expandarray) ||
IS_INSN_ID(iobj, concatarray) ||
IS_INSN_ID(iobj, splatarray) ||
0) {
@@ -3398,7 +3854,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
else {
- NODE dummy_line_node = generate_dummy_line_node(iobj->insn_info.line_no, iobj->insn_info.node_id);
long diff = FIX2LONG(op1) - FIX2LONG(op2);
INSN_OF(iobj) = BIN(opt_reverse);
OPERAND_AT(iobj, 0) = OPERAND_AT(next, 0);
@@ -3412,7 +3867,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* opt_reverse Y
*/
for (; diff > 0; diff--) {
- INSERT_BEFORE_INSN(iobj, &dummy_line_node, pop);
+ INSERT_BEFORE_INSN(iobj, iobj->insn_info.line_no, iobj->insn_info.node_id, pop);
}
}
else { /* (op1 < op2) */
@@ -3424,7 +3879,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* opt_reverse Y
*/
for (; diff < 0; diff++) {
- INSERT_BEFORE_INSN(iobj, &dummy_line_node, putnil);
+ INSERT_BEFORE_INSN(iobj, iobj->insn_info.line_no, iobj->insn_info.node_id, putnil);
}
}
}
@@ -3459,10 +3914,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
- if (IS_INSN_ID(iobj, putstring) ||
+ if (IS_INSN_ID(iobj, dupstring) || IS_INSN_ID(iobj, dupchilledstring) ||
(IS_INSN_ID(iobj, putobject) && RB_TYPE_P(OPERAND_AT(iobj, 0), T_STRING))) {
/*
- * putstring ""
+ * dupstring ""
* concatstrings N
* =>
* concatstrings N-1
@@ -3475,6 +3930,27 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
ELEM_REMOVE(&iobj->link);
}
+ if (IS_NEXT_INSN_ID(&iobj->link, toregexp)) {
+ INSN *next = (INSN *)iobj->link.next;
+ if (OPERAND_AT(next, 1) == INT2FIX(1)) {
+ VALUE src = OPERAND_AT(iobj, 0);
+ int opt = (int)FIX2LONG(OPERAND_AT(next, 0));
+ VALUE path = rb_iseq_path(iseq);
+ int line = iobj->insn_info.line_no;
+ VALUE errinfo = rb_errinfo();
+ VALUE re = rb_reg_compile(src, opt, RSTRING_PTR(path), line);
+ if (NIL_P(re)) {
+ VALUE message = rb_attr_get(rb_errinfo(), idMesg);
+ rb_set_errinfo(errinfo);
+ COMPILE_ERROR(iseq, line, "%" PRIsVALUE, message);
+ }
+ else {
+ RB_OBJ_SET_SHAREABLE(re);
+ }
+ RB_OBJ_WRITE(iseq, &OPERAND_AT(iobj, 0), re);
+ ELEM_REMOVE(iobj->link.next);
+ }
+ }
}
if (IS_INSN_ID(iobj, concatstrings)) {
@@ -3512,8 +3988,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (do_tailcallopt &&
(IS_INSN_ID(iobj, send) ||
- IS_INSN_ID(iobj, opt_aref_with) ||
- IS_INSN_ID(iobj, opt_aset_with) ||
IS_INSN_ID(iobj, invokesuper))) {
/*
* send ...
@@ -3646,6 +4120,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (IS_TRACE(iobj->link.next)) {
if (IS_NEXT_INSN_ID(iobj->link.next, leave)) {
iobj->insn_id = BIN(opt_invokebuiltin_delegate_leave);
+ const struct rb_builtin_function *bf = (const struct rb_builtin_function *)iobj->operands[0];
+ if (iobj == (INSN *)list && bf->argc == 0 && (ISEQ_BODY(iseq)->builtin_attrs & BUILTIN_ATTR_LEAF)) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_SINGLE_NOARG_LEAF;
+ }
}
}
}
@@ -3663,23 +4141,80 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
+ if (IS_INSN_ID(iobj, splatarray) && OPERAND_AT(iobj, 0) == false) {
+ LINK_ELEMENT *niobj = &iobj->link;
+ if (IS_NEXT_INSN_ID(niobj, duphash)) {
+ niobj = niobj->next;
+ LINK_ELEMENT *siobj;
+ unsigned int set_flags = 0, unset_flags = 0;
+
+ /*
+ * Eliminate hash allocation for f(*a, kw: 1)
+ *
+ * splatarray false
+ * duphash
+ * send ARGS_SPLAT|KW_SPLAT|KW_SPLAT_MUT and not ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * putobject
+ * send ARGS_SPLAT|KW_SPLAT
+ */
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ siobj = niobj->next;
+ set_flags = VM_CALL_ARGS_SPLAT|VM_CALL_KW_SPLAT|VM_CALL_KW_SPLAT_MUT;
+ unset_flags = VM_CALL_ARGS_BLOCKARG;
+ }
+ /*
+ * Eliminate hash allocation for f(*a, kw: 1, &{arg,lvar,@iv})
+ *
+ * splatarray false
+ * duphash
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send ARGS_SPLAT|KW_SPLAT|KW_SPLAT_MUT|ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * putobject
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send ARGS_SPLAT|KW_SPLAT|ARGS_BLOCKARG
+ */
+ else if ((IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable) ||
+ IS_NEXT_INSN_ID(niobj, getblockparamproxy)) && (IS_NEXT_INSN_ID(niobj->next, send))) {
+ siobj = niobj->next->next;
+ set_flags = VM_CALL_ARGS_SPLAT|VM_CALL_KW_SPLAT|VM_CALL_KW_SPLAT_MUT|VM_CALL_ARGS_BLOCKARG;
+ }
+
+ if (set_flags) {
+ const struct rb_callinfo *ci = (const struct rb_callinfo *)OPERAND_AT(siobj, 0);
+ unsigned int flags = vm_ci_flag(ci);
+ if ((flags & set_flags) == set_flags && !(flags & unset_flags)) {
+ ((INSN*)niobj)->insn_id = BIN(putobject);
+ RB_OBJ_WRITE(iseq, &OPERAND_AT(niobj, 0), RB_OBJ_SET_SHAREABLE(rb_hash_freeze(rb_hash_resurrect(OPERAND_AT(niobj, 0)))));
+
+ const struct rb_callinfo *nci = vm_ci_new(vm_ci_mid(ci),
+ flags & ~VM_CALL_KW_SPLAT_MUT, vm_ci_argc(ci), vm_ci_kwarg(ci));
+ RB_OBJ_WRITTEN(iseq, ci, nci);
+ OPERAND_AT(siobj, 0) = (VALUE)nci;
+ }
+ }
+ }
+ }
+
return COMPILE_OK;
}
static int
insn_set_specialized_instruction(rb_iseq_t *iseq, INSN *iobj, int insn_id)
{
- iobj->insn_id = insn_id;
- iobj->operand_size = insn_len(insn_id) - 1;
- iobj->insn_info.events |= RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN;
-
if (insn_id == BIN(opt_neq)) {
VALUE original_ci = iobj->operands[0];
- iobj->operand_size = 2;
- iobj->operands = compile_data_calloc2(iseq, iobj->operand_size, sizeof(VALUE));
- iobj->operands[0] = (VALUE)new_callinfo(iseq, idEq, 1, 0, NULL, FALSE);
- iobj->operands[1] = original_ci;
+ VALUE new_ci = (VALUE)new_callinfo(iseq, idEq, 1, 0, NULL, FALSE);
+ insn_replace_with_operands(iseq, iobj, insn_id, 2, new_ci, original_ci);
+ }
+ else {
+ iobj->insn_id = insn_id;
+ iobj->operand_size = insn_len(insn_id) - 1;
}
+ iobj->insn_info.events |= RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN;
return COMPILE_OK;
}
@@ -3690,32 +4225,145 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
if (IS_INSN_ID(iobj, newarray) && iobj->link.next &&
IS_INSN(iobj->link.next)) {
/*
- * [a, b, ...].max/min -> a, b, c, opt_newarray_max/min
+ * [a, b, ...].max/min -> a, b, c, opt_newarray_send max/min
*/
INSN *niobj = (INSN *)iobj->link.next;
if (IS_INSN_ID(niobj, send)) {
const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(niobj, 0);
- if ((vm_ci_flag(ci) & VM_CALL_ARGS_SIMPLE) && vm_ci_argc(ci) == 0) {
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 0) {
+ VALUE method = INT2FIX(0);
switch (vm_ci_mid(ci)) {
case idMax:
- iobj->insn_id = BIN(opt_newarray_max);
- ELEM_REMOVE(&niobj->link);
- return COMPILE_OK;
+ method = INT2FIX(VM_OPT_NEWARRAY_SEND_MAX);
+ break;
case idMin:
- iobj->insn_id = BIN(opt_newarray_min);
+ method = INT2FIX(VM_OPT_NEWARRAY_SEND_MIN);
+ break;
+ case idHash:
+ method = INT2FIX(VM_OPT_NEWARRAY_SEND_HASH);
+ break;
+ }
+
+ if (method != INT2FIX(0)) {
+ VALUE num = iobj->operands[0];
+ insn_replace_with_operands(iseq, iobj, BIN(opt_newarray_send), 2, num, method);
ELEM_REMOVE(&niobj->link);
return COMPILE_OK;
}
}
}
+ else if ((IS_INSN_ID(niobj, dupstring) || IS_INSN_ID(niobj, dupchilledstring) ||
+ (IS_INSN_ID(niobj, putobject) && RB_TYPE_P(OPERAND_AT(niobj, 0), T_STRING))) &&
+ IS_NEXT_INSN_ID(&niobj->link, send)) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT((INSN *)niobj->link.next, 0);
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 1 && vm_ci_mid(ci) == idPack) {
+ VALUE num = iobj->operands[0];
+ insn_replace_with_operands(iseq, iobj, BIN(opt_newarray_send), 2, FIXNUM_INC(num, 1), INT2FIX(VM_OPT_NEWARRAY_SEND_PACK));
+ ELEM_REMOVE(&iobj->link);
+ ELEM_REMOVE(niobj->link.next);
+ ELEM_INSERT_NEXT(&niobj->link, &iobj->link);
+ return COMPILE_OK;
+ }
+ }
+ // newarray n, dupchilledstring "E", getlocal b, send :pack with {buffer: b}
+ // -> dupchilledstring "E", getlocal b, opt_newarray_send n+2, :pack, :buffer
+ else if ((IS_INSN_ID(niobj, dupstring) || IS_INSN_ID(niobj, dupchilledstring) ||
+ (IS_INSN_ID(niobj, putobject) && RB_TYPE_P(OPERAND_AT(niobj, 0), T_STRING))) &&
+ IS_NEXT_INSN_ID(&niobj->link, getlocal) &&
+ (niobj->link.next && IS_NEXT_INSN_ID(niobj->link.next, send))) {
+ const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT((INSN *)(niobj->link.next)->next, 0);
+ const struct rb_callinfo_kwarg *kwarg = vm_ci_kwarg(ci);
+ if (vm_ci_mid(ci) == idPack && vm_ci_argc(ci) == 2 &&
+ (kwarg && kwarg->keyword_len == 1 && kwarg->keywords[0] == rb_id2sym(idBuffer))) {
+ VALUE num = iobj->operands[0];
+ insn_replace_with_operands(iseq, iobj, BIN(opt_newarray_send), 2, FIXNUM_INC(num, 2), INT2FIX(VM_OPT_NEWARRAY_SEND_PACK_BUFFER));
+ // Remove the "send" insn.
+ ELEM_REMOVE((niobj->link.next)->next);
+ // Remove the modified insn from its original "newarray" position...
+ ELEM_REMOVE(&iobj->link);
+ // and insert it after the buffer insn.
+ ELEM_INSERT_NEXT(niobj->link.next, &iobj->link);
+ return COMPILE_OK;
+ }
+ }
+
+ // Break the "else if" chain since some prior checks abort after sub-ifs.
+ // We already found "newarray". To match `[...].include?(arg)` we look for
+ // the instruction(s) representing the argument followed by a "send".
+ if ((IS_INSN_ID(niobj, dupstring) || IS_INSN_ID(niobj, dupchilledstring) ||
+ IS_INSN_ID(niobj, putobject) ||
+ IS_INSN_ID(niobj, putself) ||
+ IS_INSN_ID(niobj, getlocal) ||
+ IS_INSN_ID(niobj, getinstancevariable)) &&
+ IS_NEXT_INSN_ID(&niobj->link, send)) {
+
+ LINK_ELEMENT *sendobj = &(niobj->link); // Below we call ->next;
+ const struct rb_callinfo *ci;
+ // Allow any number (0 or more) of simple method calls on the argument
+ // (as in `[...].include?(arg.method1.method2)`.
+ do {
+ sendobj = sendobj->next;
+ ci = (struct rb_callinfo *)OPERAND_AT(sendobj, 0);
+ } while (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && IS_NEXT_INSN_ID(sendobj, send));
+
+ // If this send is for .include? with one arg we can do our opt.
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 1 && vm_ci_mid(ci) == idIncludeP) {
+ VALUE num = iobj->operands[0];
+ INSN *sendins = (INSN *)sendobj;
+ insn_replace_with_operands(iseq, sendins, BIN(opt_newarray_send), 2, FIXNUM_INC(num, 1), INT2FIX(VM_OPT_NEWARRAY_SEND_INCLUDE_P));
+ // Remove the original "newarray" insn.
+ ELEM_REMOVE(&iobj->link);
+ return COMPILE_OK;
+ }
+ }
+ }
+
+ /*
+ * duparray [...]
+ * some insn for the arg...
+ * send <calldata!mid:include?, argc:1, ARGS_SIMPLE>, nil
+ * =>
+ * arg insn...
+ * opt_duparray_send [...], :include?, 1
+ */
+ if (IS_INSN_ID(iobj, duparray) && iobj->link.next && IS_INSN(iobj->link.next)) {
+ INSN *niobj = (INSN *)iobj->link.next;
+ if ((IS_INSN_ID(niobj, getlocal) ||
+ IS_INSN_ID(niobj, getinstancevariable) ||
+ IS_INSN_ID(niobj, putself)) &&
+ IS_NEXT_INSN_ID(&niobj->link, send)) {
+
+ LINK_ELEMENT *sendobj = &(niobj->link); // Below we call ->next;
+ const struct rb_callinfo *ci;
+ // Allow any number (0 or more) of simple method calls on the argument
+ // (as in `[...].include?(arg.method1.method2)`.
+ do {
+ sendobj = sendobj->next;
+ ci = (struct rb_callinfo *)OPERAND_AT(sendobj, 0);
+ } while (vm_ci_simple(ci) && vm_ci_argc(ci) == 0 && IS_NEXT_INSN_ID(sendobj, send));
+
+ if (vm_ci_simple(ci) && vm_ci_argc(ci) == 1 && vm_ci_mid(ci) == idIncludeP) {
+ // Move the array arg from duparray to opt_duparray_send.
+ VALUE ary = iobj->operands[0];
+ rb_obj_reveal(ary, rb_cArray);
+
+ INSN *sendins = (INSN *)sendobj;
+ insn_replace_with_operands(iseq, sendins, BIN(opt_duparray_send), 3, ary, rb_id2sym(idIncludeP), INT2FIX(1));
+
+ // Remove the duparray insn.
+ ELEM_REMOVE(&iobj->link);
+ return COMPILE_OK;
+ }
+ }
}
+
if (IS_INSN_ID(iobj, send)) {
const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(iobj, 0);
const rb_iseq_t *blockiseq = (rb_iseq_t *)OPERAND_AT(iobj, 1);
#define SP_INSN(opt) insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))
- if (vm_ci_flag(ci) & VM_CALL_ARGS_SIMPLE) {
+ if (vm_ci_simple(ci)) {
switch (vm_ci_argc(ci)) {
case 0:
switch (vm_ci_mid(ci)) {
@@ -3755,7 +4403,7 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
}
}
- if ((vm_ci_flag(ci) & VM_CALL_ARGS_BLOCKARG) == 0 && blockiseq == NULL) {
+ if ((vm_ci_flag(ci) & (VM_CALL_ARGS_BLOCKARG | VM_CALL_FORWARDING)) == 0 && blockiseq == NULL) {
iobj->insn_id = BIN(opt_send_without_block);
iobj->operand_size = insn_len(iobj->insn_id) - 1;
}
@@ -3791,15 +4439,25 @@ iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
ISEQ_COMPILE_DATA(iseq)->option->tailcall_optimization;
const int do_si = ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction;
const int do_ou = ISEQ_COMPILE_DATA(iseq)->option->operands_unification;
+ const int do_without_ints = ISEQ_BODY(iseq)->builtin_attrs & BUILTIN_ATTR_WITHOUT_INTERRUPTS;
int rescue_level = 0;
int tailcallopt = do_tailcallopt;
list = FIRST_ELEMENT(anchor);
int do_block_optimization = 0;
+ LABEL * block_loop_label = NULL;
- if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK && !ISEQ_BODY(iseq)->catch_except_p) {
+ // If we're optimizing a block
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK) {
do_block_optimization = 1;
+
+ // If the block starts with a nop and a label,
+ // record the label so we can detect if it's a jump target
+ LINK_ELEMENT * le = FIRST_ELEMENT(anchor)->next;
+ if (IS_INSN(le) && IS_INSN_ID((INSN *)le, nop) && IS_LABEL(le->next)) {
+ block_loop_label = (LABEL *)le->next;
+ }
}
while (list) {
@@ -3814,11 +4472,45 @@ iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
insn_operands_unification((INSN *)list);
}
+ if (do_without_ints) {
+ INSN *item = (INSN *)list;
+ if (IS_INSN_ID(item, jump)) {
+ item->insn_id = BIN(jump_without_ints);
+ }
+ else if (IS_INSN_ID(item, branchif)) {
+ item->insn_id = BIN(branchif_without_ints);
+ }
+ else if (IS_INSN_ID(item, branchunless)) {
+ item->insn_id = BIN(branchunless_without_ints);
+ }
+ else if (IS_INSN_ID(item, branchnil)) {
+ item->insn_id = BIN(branchnil_without_ints);
+ }
+ }
+
if (do_block_optimization) {
INSN * item = (INSN *)list;
- if (IS_INSN_ID(item, jump)) {
+ // Give up if there is a throw
+ if (IS_INSN_ID(item, throw)) {
do_block_optimization = 0;
}
+ else {
+ // If the instruction has a jump target, check if the
+ // jump target is the block loop label
+ const char *types = insn_op_types(item->insn_id);
+ for (int j = 0; types[j]; j++) {
+ if (types[j] == TS_OFFSET) {
+ // If the jump target is equal to the block loop
+ // label, then we can't do the optimization because
+ // the leading `nop` instruction fires the block
+ // entry tracepoint
+ LABEL * target = (LABEL *)OPERAND_AT(item, j);
+ if (target == block_loop_label) {
+ do_block_optimization = 0;
+ }
+ }
+ }
+ }
}
}
if (IS_LABEL(list)) {
@@ -3863,7 +4555,7 @@ new_unified_insn(rb_iseq_t *iseq,
}
if (argc > 0) {
- ptr = operands = compile_data_alloc2(iseq, sizeof(VALUE), argc);
+ ptr = operands = compile_data_alloc2_type(iseq, VALUE, argc);
}
/* copy operands */
@@ -3875,8 +4567,7 @@ new_unified_insn(rb_iseq_t *iseq,
list = list->next;
}
- NODE dummy_line_node = generate_dummy_line_node(iobj->insn_info.line_no, iobj->insn_info.node_id);
- return new_insn_core(iseq, &dummy_line_node, insn_id, argc, operands);
+ return new_insn_core(iseq, iobj->insn_info.line_no, iobj->insn_info.node_id, insn_id, argc, operands);
}
#endif
@@ -3936,231 +4627,114 @@ iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
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, const LINK_ELEMENT *anchor, INSN *iobj, int state)
+all_string_result_p(const NODE *node)
{
- 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) {
- BADINSN_DUMP(anchor, iobj, lobj);
- COMPILE_ERROR(iseq, iobj->insn_info.line_no,
- "insn_set_sc_state error: %d at "LABEL_FORMAT
- ", %d expected\n",
- lobj->sc_state, lobj->label_no, nstate);
- return COMPILE_NG;
- }
- }
- else {
- lobj->sc_state = nstate;
- }
- if (insn_id == BIN(jump)) {
- nstate = SCS_XX;
- }
- }
- else if (insn_id == BIN(leave)) {
- nstate = SCS_XX;
+ if (!node) return FALSE;
+ switch (nd_type(node)) {
+ case NODE_STR: case NODE_DSTR: case NODE_FILE:
+ return TRUE;
+ case NODE_IF: case NODE_UNLESS:
+ if (!RNODE_IF(node)->nd_body || !RNODE_IF(node)->nd_else) return FALSE;
+ if (all_string_result_p(RNODE_IF(node)->nd_body))
+ return all_string_result_p(RNODE_IF(node)->nd_else);
+ return FALSE;
+ case NODE_AND: case NODE_OR:
+ if (!RNODE_AND(node)->nd_2nd)
+ return all_string_result_p(RNODE_AND(node)->nd_1st);
+ if (!all_string_result_p(RNODE_AND(node)->nd_1st))
+ return FALSE;
+ return all_string_result_p(RNODE_AND(node)->nd_2nd);
+ default:
+ return FALSE;
}
-
- return nstate;
}
+struct dstr_ctxt {
+ rb_iseq_t *const iseq;
+ LINK_ANCHOR *const ret;
+ VALUE lit;
+ const NODE *lit_node;
+ int cnt;
+ int dregx;
+};
+
static int
-label_set_sc_state(LABEL *lobj, int state)
+append_dstr_fragment(struct dstr_ctxt *args, const NODE *const node, rb_parser_string_t *str)
{
- if (lobj->sc_state != 0) {
- if (lobj->sc_state != state) {
- state = lobj->sc_state;
+ VALUE s = rb_str_new_mutable_parser_string(str);
+ if (args->dregx) {
+ VALUE error = rb_reg_check_preprocess(s);
+ if (!NIL_P(error)) {
+ COMPILE_ERROR(args->iseq, nd_line(node), "%" PRIsVALUE, error);
+ return COMPILE_NG;
}
}
- else {
- lobj->sc_state = state;
+ if (NIL_P(args->lit)) {
+ args->lit = s;
+ args->lit_node = node;
}
-
- return state;
-}
-
-
-#endif
-
-static int
-iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const 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) {
- NODE dummy_line_node = generate_dummy_line_node(0, -1);
- INSN *rpobj =
- new_insn_body(iseq, &dummy_line_node, BIN(reput), 0);
-
- /* replace this insn */
- ELEM_REPLACE(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);
-
- ELEM_REMOVE(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:
- COMPILE_ERROR(iseq, iobj->insn_info.line_no,
- "unreachable");
- return COMPILE_NG;
- }
- /* remove useless pop */
- ELEM_REMOVE(list);
- list = list->next;
- goto redo_point;
- }
- default:;
- /* none */
- } /* end of switch */
- normal_insn:
- state = insn_set_sc_state(iseq, anchor, iobj, state);
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- LABEL *lobj;
- lobj = (LABEL *)list;
-
- state = label_set_sc_state(lobj, state);
- }
- default:
- break;
- }
- list = list->next;
+ else {
+ rb_str_buf_append(args->lit, s);
}
-#endif
return COMPILE_OK;
}
-static int
-all_string_result_p(const NODE *node)
+static void
+flush_dstr_fragment(struct dstr_ctxt *args)
{
- if (!node) return FALSE;
- switch (nd_type(node)) {
- case NODE_STR: case NODE_DSTR:
- return TRUE;
- case NODE_IF: case NODE_UNLESS:
- if (!node->nd_body || !node->nd_else) return FALSE;
- if (all_string_result_p(node->nd_body))
- return all_string_result_p(node->nd_else);
- return FALSE;
- case NODE_AND: case NODE_OR:
- if (!node->nd_2nd)
- return all_string_result_p(node->nd_1st);
- if (!all_string_result_p(node->nd_1st))
- return FALSE;
- return all_string_result_p(node->nd_2nd);
- default:
- return FALSE;
+ if (!NIL_P(args->lit)) {
+ rb_iseq_t *iseq = args->iseq;
+ VALUE lit = args->lit;
+ args->lit = Qnil;
+ lit = rb_fstring(lit);
+ ADD_INSN1(args->ret, args->lit_node, putobject, lit);
+ RB_OBJ_WRITTEN(args->iseq, Qundef, lit);
+ args->cnt++;
}
}
static int
-compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int *cntp)
+compile_dstr_fragments_0(struct dstr_ctxt *args, const NODE *const node)
{
- const NODE *list = node->nd_next;
- VALUE lit = node->nd_lit;
- LINK_ELEMENT *first_lit = 0;
- int cnt = 0;
+ const struct RNode_LIST *list = RNODE_DSTR(node)->nd_next;
+ rb_parser_string_t *str = RNODE_DSTR(node)->string;
- debugp_param("nd_lit", lit);
- if (!NIL_P(lit)) {
- cnt++;
- if (!RB_TYPE_P(lit, T_STRING)) {
- COMPILE_ERROR(ERROR_ARGS "dstr: must be string: %s",
- rb_builtin_type_name(TYPE(lit)));
- return COMPILE_NG;
- }
- lit = rb_fstring(lit);
- ADD_INSN1(ret, node, putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
- if (RSTRING_LEN(lit) == 0) first_lit = LAST_ELEMENT(ret);
+ if (str) {
+ CHECK(append_dstr_fragment(args, node, str));
}
while (list) {
const NODE *const head = list->nd_head;
if (nd_type_p(head, NODE_STR)) {
- lit = rb_fstring(head->nd_lit);
- ADD_INSN1(ret, head, putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
- lit = Qnil;
+ CHECK(append_dstr_fragment(args, node, RNODE_STR(head)->string));
+ }
+ else if (nd_type_p(head, NODE_DSTR)) {
+ CHECK(compile_dstr_fragments_0(args, head));
}
else {
- CHECK(COMPILE(ret, "each string", head));
+ flush_dstr_fragment(args);
+ rb_iseq_t *iseq = args->iseq;
+ CHECK(COMPILE(args->ret, "each string", head));
+ args->cnt++;
}
- cnt++;
- list = list->nd_next;
- }
- if (NIL_P(lit) && first_lit) {
- ELEM_REMOVE(first_lit);
- --cnt;
+ list = (struct RNode_LIST *)list->nd_next;
}
- *cntp = cnt;
+ return COMPILE_OK;
+}
+
+static int
+compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int *cntp, int dregx)
+{
+ struct dstr_ctxt args = {
+ .iseq = iseq, .ret = ret,
+ .lit = Qnil, .lit_node = NULL,
+ .cnt = 0, .dregx = dregx,
+ };
+ CHECK(compile_dstr_fragments_0(&args, node));
+ flush_dstr_fragment(&args);
+
+ *cntp = args.cnt;
return COMPILE_OK;
}
@@ -4169,12 +4743,12 @@ static int
compile_block(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
{
while (node && nd_type_p(node, NODE_BLOCK)) {
- CHECK(COMPILE_(ret, "BLOCK body", node->nd_head,
- (node->nd_next ? 1 : popped)));
- node = node->nd_next;
+ CHECK(COMPILE_(ret, "BLOCK body", RNODE_BLOCK(node)->nd_head,
+ (RNODE_BLOCK(node)->nd_next ? 1 : popped)));
+ node = RNODE_BLOCK(node)->nd_next;
}
if (node) {
- CHECK(COMPILE_(ret, "BLOCK next", node->nd_next, popped));
+ CHECK(COMPILE_(ret, "BLOCK next", RNODE_BLOCK(node)->nd_next, popped));
}
return COMPILE_OK;
}
@@ -4183,24 +4757,43 @@ static int
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
{
int cnt;
- if (!node->nd_next) {
- VALUE lit = rb_fstring(node->nd_lit);
- ADD_INSN1(ret, node, putstring, lit);
+ if (!RNODE_DSTR(node)->nd_next) {
+ VALUE lit = rb_node_dstr_string_val(node);
+ ADD_INSN1(ret, node, dupstring, lit);
+ RB_OBJ_SET_SHAREABLE(lit);
RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
else {
- CHECK(compile_dstr_fragments(iseq, ret, node, &cnt));
+ CHECK(compile_dstr_fragments(iseq, ret, node, &cnt, FALSE));
ADD_INSN1(ret, node, concatstrings, INT2FIX(cnt));
}
return COMPILE_OK;
}
static int
-compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
+compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
int cnt;
- CHECK(compile_dstr_fragments(iseq, ret, node, &cnt));
- ADD_INSN2(ret, node, toregexp, INT2FIX(node->nd_cflag), INT2FIX(cnt));
+ int cflag = (int)RNODE_DREGX(node)->as.nd_cflag;
+
+ if (!RNODE_DREGX(node)->nd_next) {
+ if (!popped) {
+ VALUE src = rb_node_dregx_string_val(node);
+ VALUE match = rb_reg_compile(src, cflag, NULL, 0);
+ RB_OBJ_SET_SHAREABLE(match);
+ ADD_INSN1(ret, node, putobject, match);
+ RB_OBJ_WRITTEN(iseq, Qundef, match);
+ }
+ return COMPILE_OK;
+ }
+
+ CHECK(compile_dstr_fragments(iseq, ret, node, &cnt, TRUE));
+ ADD_INSN2(ret, node, toregexp, INT2FIX(cflag), INT2FIX(cnt));
+
+ if (popped) {
+ ADD_INSN(ret, node, pop);
+ }
+
return COMPILE_OK;
}
@@ -4218,7 +4811,7 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
ADD_INSNL(ret, node, branchif, lend);
/* *flip == 0 */
- CHECK(COMPILE(ret, "flip2 beg", node->nd_beg));
+ CHECK(COMPILE(ret, "flip2 beg", RNODE_FLIP2(node)->nd_beg));
ADD_INSNL(ret, node, branchunless, else_label);
ADD_INSN1(ret, node, putobject, Qtrue);
ADD_INSN1(ret, node, setspecial, key);
@@ -4228,7 +4821,7 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
/* *flip == 1 */
ADD_LABEL(ret, lend);
- CHECK(COMPILE(ret, "flip2 end", node->nd_end));
+ CHECK(COMPILE(ret, "flip2 end", RNODE_FLIP2(node)->nd_end));
ADD_INSNL(ret, node, branchunless, then_label);
ADD_INSN1(ret, node, putobject, Qfalse);
ADD_INSN1(ret, node, setspecial, key);
@@ -4238,40 +4831,75 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
}
static int
-compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cond,
+compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
+ LABEL *then_label, LABEL *else_label);
+
+#define COMPILE_SINGLE 2
+static int
+compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cond,
+ LABEL *then_label, LABEL *else_label)
+{
+ DECL_ANCHOR(seq);
+ INIT_ANCHOR(seq);
+ LABEL *label = NEW_LABEL(nd_line(cond));
+ if (!then_label) then_label = label;
+ else if (!else_label) else_label = label;
+
+ CHECK(compile_branch_condition(iseq, seq, cond, then_label, else_label));
+
+ if (LIST_INSN_SIZE_ONE(seq)) {
+ INSN *insn = (INSN *)ELEM_FIRST_INSN(FIRST_ELEMENT(seq));
+ if (insn->insn_id == BIN(jump) && (LABEL *)(insn->operands[0]) == label)
+ return COMPILE_OK;
+ }
+ if (!label->refcnt) {
+ return COMPILE_SINGLE;
+ }
+ ADD_LABEL(seq, label);
+ ADD_SEQ(ret, seq);
+ return COMPILE_OK;
+}
+
+static int
+compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
LABEL *then_label, LABEL *else_label)
{
+ int ok;
+ DECL_ANCHOR(ignore);
+
again:
switch (nd_type(cond)) {
case NODE_AND:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
- else_label));
- if (!label->refcnt) {
- ADD_INSN(ret, cond, putnil);
- break;
- }
- ADD_LABEL(ret, label);
- cond = cond->nd_2nd;
- goto again;
- }
+ CHECK(ok = compile_logical(iseq, ret, RNODE_AND(cond)->nd_1st, NULL, else_label));
+ cond = RNODE_AND(cond)->nd_2nd;
+ if (ok == COMPILE_SINGLE) {
+ ADD_INSNL(ret, cond, jump, else_label);
+ INIT_ANCHOR(ignore);
+ ret = ignore;
+ then_label = NEW_LABEL(nd_line(cond));
+ }
+ goto again;
case NODE_OR:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
- label));
- if (!label->refcnt) {
- ADD_INSN(ret, cond, putnil);
- break;
- }
- ADD_LABEL(ret, label);
- cond = cond->nd_2nd;
- goto again;
- }
- case NODE_LIT: /* NODE_LIT is always true */
+ CHECK(ok = compile_logical(iseq, ret, RNODE_OR(cond)->nd_1st, then_label, NULL));
+ cond = RNODE_OR(cond)->nd_2nd;
+ if (ok == COMPILE_SINGLE) {
+ ADD_INSNL(ret, cond, jump, then_label);
+ INIT_ANCHOR(ignore);
+ ret = ignore;
+ else_label = NEW_LABEL(nd_line(cond));
+ }
+ goto again;
+ case NODE_SYM:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
+ case NODE_INTEGER: /* NODE_INTEGER is always true */
+ case NODE_FLOAT: /* NODE_FLOAT is always true */
+ case NODE_RATIONAL: /* NODE_RATIONAL is always true */
+ case NODE_IMAGINARY: /* NODE_IMAGINARY is always true */
case NODE_TRUE:
case NODE_STR:
+ case NODE_REGX:
case NODE_ZLIST:
case NODE_LAMBDA:
/* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
@@ -4296,7 +4924,7 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
CHECK(compile_flip_flop(iseq, ret, cond, FALSE, then_label, else_label));
return COMPILE_OK;
case NODE_DEFINED:
- CHECK(compile_defined_expr(iseq, ret, cond, Qfalse));
+ CHECK(compile_defined_expr(iseq, ret, cond, Qfalse, ret == ignore));
break;
default:
{
@@ -4334,7 +4962,40 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
static int
keyword_node_p(const NODE *const node)
{
- return nd_type_p(node, NODE_HASH) && (node->nd_brace & HASH_BRACE) != HASH_BRACE;
+ return nd_type_p(node, NODE_HASH) && (RNODE_HASH(node)->nd_brace & HASH_BRACE) != HASH_BRACE;
+}
+
+static VALUE
+get_symbol_value(rb_iseq_t *iseq, const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_SYM:
+ return rb_node_sym_string_val(node);
+ default:
+ UNKNOWN_NODE("get_symbol_value", node, Qnil);
+ }
+}
+
+static VALUE
+node_hash_unique_key_index(rb_iseq_t *iseq, rb_node_hash_t *node_hash, int *count_ptr)
+{
+ NODE *node = node_hash->nd_head;
+ VALUE hash = rb_hash_new();
+ VALUE ary = rb_ary_new();
+
+ for (int i = 0; node != NULL; i++, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
+ VALUE key = get_symbol_value(iseq, RNODE_LIST(node)->nd_head);
+ VALUE idx = rb_hash_aref(hash, key);
+ if (!NIL_P(idx)) {
+ rb_ary_store(ary, FIX2INT(idx), Qfalse);
+ (*count_ptr)--;
+ }
+ rb_hash_aset(hash, key, INT2FIX(i));
+ rb_ary_store(ary, i, Qtrue);
+ (*count_ptr)++;
+ }
+
+ return ary;
}
static int
@@ -4347,22 +5008,22 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
RUBY_ASSERT(kw_arg_ptr != NULL);
RUBY_ASSERT(flag != NULL);
- if (root_node->nd_head && nd_type_p(root_node->nd_head, NODE_LIST)) {
- const NODE *node = root_node->nd_head;
+ if (RNODE_HASH(root_node)->nd_head && nd_type_p(RNODE_HASH(root_node)->nd_head, NODE_LIST)) {
+ const NODE *node = RNODE_HASH(root_node)->nd_head;
int seen_nodes = 0;
while (node) {
- const NODE *key_node = node->nd_head;
+ const NODE *key_node = RNODE_LIST(node)->nd_head;
seen_nodes++;
- assert(nd_type_p(node, NODE_LIST));
- if (key_node && nd_type_p(key_node, NODE_LIT) && SYMBOL_P(key_node->nd_lit)) {
+ RUBY_ASSERT(nd_type_p(node, NODE_LIST));
+ if (key_node && nd_type_p(key_node, NODE_SYM)) {
/* can be keywords */
}
else {
if (flag) {
*flag |= VM_CALL_KW_SPLAT;
- if (seen_nodes > 1 || node->nd_next->nd_next) {
+ if (seen_nodes > 1 || RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
/* A new hash will be created for the keyword arguments
* in this case, so mark the method as passing mutable
* keyword splat.
@@ -4372,29 +5033,37 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
}
return FALSE;
}
- node = node->nd_next; /* skip value node */
- node = node->nd_next;
+ node = RNODE_LIST(node)->nd_next; /* skip value node */
+ node = RNODE_LIST(node)->nd_next;
}
/* may be keywords */
- node = root_node->nd_head;
+ node = RNODE_HASH(root_node)->nd_head;
{
- int len = (int)node->nd_alen / 2;
+ int len = 0;
+ VALUE key_index = node_hash_unique_key_index(iseq, RNODE_HASH(root_node), &len);
struct rb_callinfo_kwarg *kw_arg =
rb_xmalloc_mul_add(len, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
VALUE *keywords = kw_arg->keywords;
int i = 0;
+ int j = 0;
+ kw_arg->references = 0;
kw_arg->keyword_len = len;
*kw_arg_ptr = kw_arg;
- for (i=0; node != NULL; i++, node = node->nd_next->nd_next) {
- const NODE *key_node = node->nd_head;
- const NODE *val_node = node->nd_next->nd_head;
- keywords[i] = key_node->nd_lit;
- NO_CHECK(COMPILE(ret, "keyword values", val_node));
+ for (i=0; node != NULL; i++, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
+ const NODE *key_node = RNODE_LIST(node)->nd_head;
+ const NODE *val_node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head;
+ int popped = TRUE;
+ if (rb_ary_entry(key_index, i)) {
+ keywords[j] = get_symbol_value(iseq, key_node);
+ j++;
+ popped = FALSE;
+ }
+ NO_CHECK(COMPILE_(ret, "keyword values", val_node, popped));
}
- assert(i == len);
+ RUBY_ASSERT(j == len);
return TRUE;
}
}
@@ -4406,34 +5075,48 @@ compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, NODE **k
{
int len = 0;
- for (; node; len++, node = node->nd_next) {
+ for (; node; len++, node = RNODE_LIST(node)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_args", node, NODE_LIST, -1);
}
- if (node->nd_next == NULL && keyword_node_p(node->nd_head)) { /* last node is kwnode */
- *kwnode_ptr = node->nd_head;
+ if (RNODE_LIST(node)->nd_next == NULL && keyword_node_p(RNODE_LIST(node)->nd_head)) { /* last node is kwnode */
+ *kwnode_ptr = RNODE_LIST(node)->nd_head;
}
else {
- RUBY_ASSERT(!keyword_node_p(node->nd_head));
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, FALSE));
+ RUBY_ASSERT(!keyword_node_p(RNODE_LIST(node)->nd_head));
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, FALSE));
}
}
return len;
}
-static inline int
-static_literal_node_p(const NODE *node, const rb_iseq_t *iseq)
+static inline bool
+frozen_string_literal_p(const rb_iseq_t *iseq)
+{
+ return ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal > 0;
+}
+
+static inline bool
+static_literal_node_p(const NODE *node, const rb_iseq_t *iseq, bool hash_key)
{
switch (nd_type(node)) {
- case NODE_LIT:
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_LINE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
return TRUE;
case NODE_STR:
- return ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal;
+ case NODE_FILE:
+ return hash_key || frozen_string_literal_p(iseq);
default:
return FALSE;
}
@@ -4443,30 +5126,54 @@ static inline VALUE
static_literal_value(const NODE *node, rb_iseq_t *iseq)
{
switch (nd_type(node)) {
+ case NODE_INTEGER:
+ {
+ VALUE lit = rb_node_integer_literal_val(node);
+ if (!SPECIAL_CONST_P(lit)) RB_OBJ_SET_SHAREABLE(lit);
+ return lit;
+ }
+ case NODE_FLOAT:
+ {
+ VALUE lit = rb_node_float_literal_val(node);
+ if (!SPECIAL_CONST_P(lit)) RB_OBJ_SET_SHAREABLE(lit);
+ return lit;
+ }
+ case NODE_RATIONAL:
+ return rb_ractor_make_shareable(rb_node_rational_literal_val(node));
+ case NODE_IMAGINARY:
+ return rb_ractor_make_shareable(rb_node_imaginary_literal_val(node));
case NODE_NIL:
return Qnil;
case NODE_TRUE:
return Qtrue;
case NODE_FALSE:
return Qfalse;
+ case NODE_SYM:
+ return rb_node_sym_string_val(node);
+ case NODE_REGX:
+ return RB_OBJ_SET_SHAREABLE(rb_node_regx_string_val(node));
+ case NODE_LINE:
+ return rb_node_line_lineno_val(node);
+ case NODE_ENCODING:
+ return rb_node_encoding_val(node);
+ case NODE_FILE:
case NODE_STR:
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
- VALUE lit;
- VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX((int)nd_line(node)));
- lit = rb_str_dup(node->nd_lit);
- rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
- return rb_str_freeze(lit);
+ VALUE lit = get_string_value(node);
+ VALUE str = rb_str_with_debug_created_info(lit, rb_iseq_path(iseq), (int)nd_line(node));
+ RB_OBJ_SET_SHAREABLE(str);
+ return str;
}
else {
- return rb_fstring(node->nd_lit);
+ return get_string_value(node);
}
default:
- return node->nd_lit;
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
}
}
static int
-compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
+compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped, bool first_chunk)
{
const NODE *line_node = node;
@@ -4480,8 +5187,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
EXPECT_NODE("compile_array", node, NODE_LIST, -1);
if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, popped));
+ for (; node; node = RNODE_LIST(node)->nd_next) {
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, popped));
}
return 1;
}
@@ -4501,8 +5208,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
*
* [x1,x2,...,x10000] =>
* push x1 ; push x2 ; ...; push x256; newarray 256;
- * push x257; push x258; ...; push x512; newarray 256; concatarray;
- * push x513; push x514; ...; push x768; newarray 256; concatarray;
+ * push x257; push x258; ...; push x512; pushtoarray 256;
+ * push x513; push x514; ...; push x768; pushtoarray 256;
* ...
*
* - Long subarray can be optimized by pre-allocating a hidden array.
@@ -4512,38 +5219,38 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
*
* [x, 1,2,3,...,100, z] =>
* push x; newarray 1;
- * putobject [1,2,3,...,100] (<- hidden array); concatarray;
- * push z; newarray 1; concatarray
+ * putobject [1,2,3,...,100] (<- hidden array); concattoarray;
+ * push z; pushtoarray 1;
*
- * - If the last element is a keyword, newarraykwsplat should be emitted
- * to check and remove empty keyword arguments hash from array.
+ * - If the last element is a keyword, pushtoarraykwsplat should be emitted
+ * to only push it onto the array if it is not empty
* (Note: a keyword is NODE_HASH which is not static_literal_node_p.)
*
* [1,2,3,**kw] =>
- * putobject 1; putobject 2; putobject 3; push kw; newarraykwsplat
+ * putobject 1; putobject 2; putobject 3; newarray 3; ...; pushtoarraykwsplat kw
*/
const int max_stack_len = 0x100;
const int min_tmp_ary_len = 0x40;
int stack_len = 0;
- int first_chunk = 1;
- /* Convert pushed elements to an array, and concatarray if needed */
-#define FLUSH_CHUNK(newarrayinsn) \
+ /* Either create a new array, or push to the existing array */
+#define FLUSH_CHUNK \
if (stack_len) { \
- ADD_INSN1(ret, line_node, newarrayinsn, INT2FIX(stack_len)); \
- if (!first_chunk) ADD_INSN(ret, line_node, concatarray); \
- first_chunk = stack_len = 0; \
+ if (first_chunk) ADD_INSN1(ret, line_node, newarray, INT2FIX(stack_len)); \
+ else ADD_INSN1(ret, line_node, pushtoarray, INT2FIX(stack_len)); \
+ first_chunk = FALSE; \
+ stack_len = 0; \
}
while (node) {
int count = 1;
/* pre-allocation check (this branch can be omittable) */
- if (static_literal_node_p(node->nd_head, iseq)) {
+ if (static_literal_node_p(RNODE_LIST(node)->nd_head, iseq, false)) {
/* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next;
- for (; node_tmp && static_literal_node_p(node_tmp->nd_head, iseq); node_tmp = node_tmp->nd_next)
+ const NODE *node_tmp = RNODE_LIST(node)->nd_next;
+ for (; node_tmp && static_literal_node_p(RNODE_LIST(node_tmp)->nd_head, iseq, false); node_tmp = RNODE_LIST(node_tmp)->nd_next)
count++;
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) {
@@ -4551,72 +5258,62 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
VALUE ary = rb_ary_hidden_new(count);
/* Create a hidden array */
- for (; count; count--, node = node->nd_next)
- rb_ary_push(ary, static_literal_value(node->nd_head, iseq));
- OBJ_FREEZE(ary);
+ for (; count; count--, node = RNODE_LIST(node)->nd_next)
+ rb_ary_push(ary, static_literal_value(RNODE_LIST(node)->nd_head, iseq));
+ RB_OBJ_SET_FROZEN_SHAREABLE(ary);
/* Emit optimized code */
- FLUSH_CHUNK(newarray);
+ FLUSH_CHUNK;
if (first_chunk) {
ADD_INSN1(ret, line_node, duparray, ary);
- first_chunk = 0;
+ first_chunk = FALSE;
}
else {
ADD_INSN1(ret, line_node, putobject, ary);
- ADD_INSN(ret, line_node, concatarray);
+ ADD_INSN(ret, line_node, concattoarray);
}
+ RB_OBJ_SET_SHAREABLE(ary);
RB_OBJ_WRITTEN(iseq, Qundef, ary);
}
}
/* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next) {
+ for (; count; count--, node = RNODE_LIST(node)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_array", node, NODE_LIST, -1);
}
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, 0));
- stack_len++;
-
- if (!node->nd_next && keyword_node_p(node->nd_head)) {
- /* Reached the end, and the last element is a keyword */
- FLUSH_CHUNK(newarraykwsplat);
+ if (!RNODE_LIST(node)->nd_next && keyword_node_p(RNODE_LIST(node)->nd_head)) {
+ /* Create array or push existing non-keyword elements onto array */
+ if (stack_len == 0 && first_chunk) {
+ ADD_INSN1(ret, line_node, newarray, INT2FIX(0));
+ }
+ else {
+ FLUSH_CHUNK;
+ }
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, 0));
+ ADD_INSN(ret, line_node, pushtoarraykwsplat);
return 1;
}
+ else {
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, 0));
+ stack_len++;
+ }
/* If there are many pushed elements, flush them to avoid stack overflow */
- if (stack_len >= max_stack_len) FLUSH_CHUNK(newarray);
+ if (stack_len >= max_stack_len) FLUSH_CHUNK;
}
}
- FLUSH_CHUNK(newarray);
+ FLUSH_CHUNK;
#undef FLUSH_CHUNK
return 1;
}
-/* Compile an array containing the single element represented by node */
-static int
-compile_array_1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node)
-{
- if (static_literal_node_p(node, iseq)) {
- VALUE ary = rb_ary_hidden_new(1);
- rb_ary_push(ary, static_literal_value(node, iseq));
- OBJ_FREEZE(ary);
-
- ADD_INSN1(ret, node, duparray, ary);
- }
- else {
- CHECK(COMPILE_(ret, "array element", node, FALSE));
- ADD_INSN1(ret, node, newarray, INT2FIX(1));
- }
-
- return 1;
-}
-
static inline int
static_literal_node_pair_p(const NODE *node, const rb_iseq_t *iseq)
{
- return node->nd_head && static_literal_node_p(node->nd_head, iseq) && static_literal_node_p(node->nd_next->nd_head, iseq);
+ return RNODE_LIST(node)->nd_head && static_literal_node_p(RNODE_LIST(node)->nd_head, iseq, true) && static_literal_node_p(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq, false);
}
static int
@@ -4624,7 +5321,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
{
const NODE *line_node = node;
- node = node->nd_head;
+ node = RNODE_HASH(node)->nd_head;
if (!node || nd_type_p(node, NODE_ZLIST)) {
if (!popped) {
@@ -4636,8 +5333,8 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "hash element", node->nd_head, popped));
+ for (; node; node = RNODE_LIST(node)->nd_next) {
+ NO_CHECK(COMPILE_(ret, "hash element", RNODE_LIST(node)->nd_head, popped));
}
return 1;
}
@@ -4690,8 +5387,8 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
/* pre-allocation check (this branch can be omittable) */
if (static_literal_node_pair_p(node, iseq)) {
/* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next->nd_next;
- for (; node_tmp && static_literal_node_pair_p(node_tmp, iseq); node_tmp = node_tmp->nd_next->nd_next)
+ const NODE *node_tmp = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next;
+ for (; node_tmp && static_literal_node_pair_p(node_tmp, iseq); node_tmp = RNODE_LIST(RNODE_LIST(node_tmp)->nd_next)->nd_next)
count++;
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_hash_len) {
@@ -4699,16 +5396,18 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
VALUE ary = rb_ary_hidden_new(count);
/* Create a hidden hash */
- for (; count; count--, node = node->nd_next->nd_next) {
+ for (; count; count--, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
VALUE elem[2];
- elem[0] = static_literal_value(node->nd_head, iseq);
- elem[1] = static_literal_value(node->nd_next->nd_head, iseq);
+ elem[0] = static_literal_value(RNODE_LIST(node)->nd_head, iseq);
+ if (!RB_SPECIAL_CONST_P(elem[0])) RB_OBJ_SET_FROZEN_SHAREABLE(elem[0]);
+ elem[1] = static_literal_value(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq);
+ if (!RB_SPECIAL_CONST_P(elem[1])) RB_OBJ_SET_FROZEN_SHAREABLE(elem[1]);
rb_ary_cat(ary, elem, 2);
}
- VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary) / 2);
- rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR_TRANSIENT(ary), hash);
- hash = rb_obj_hide(hash);
- OBJ_FREEZE(hash);
+ VALUE hash = rb_hash_alloc_fixed_size(Qfalse, RARRAY_LEN(ary) / 2);
+ rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary), hash);
+ RB_GC_GUARD(ary);
+ hash = RB_OBJ_SET_FROZEN_SHAREABLE(hash);
/* Emit optimized code */
FLUSH_CHUNK();
@@ -4729,16 +5428,16 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
}
/* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next->nd_next) {
+ for (; count; count--, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
}
- if (node->nd_head) {
+ if (RNODE_LIST(node)->nd_head) {
/* Normal key-value pair */
- NO_CHECK(COMPILE_(anchor, "hash key element", node->nd_head, 0));
- NO_CHECK(COMPILE_(anchor, "hash value element", node->nd_next->nd_head, 0));
+ NO_CHECK(COMPILE_(anchor, "hash key element", RNODE_LIST(node)->nd_head, 0));
+ NO_CHECK(COMPILE_(anchor, "hash value element", RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, 0));
stack_len += 2;
/* If there are many pushed elements, flush them to avoid stack overflow */
@@ -4748,12 +5447,13 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
/* kwsplat case: foo(..., **kw, ...) */
FLUSH_CHUNK();
- const NODE *kw = node->nd_next->nd_head;
- int empty_kw = nd_type_p(kw, NODE_LIT) && RB_TYPE_P(kw->nd_lit, T_HASH); /* foo( ..., **{}, ...) */
+ const NODE *kw = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head;
+ int empty_kw = nd_type_p(kw, NODE_HASH) && (!RNODE_HASH(kw)->nd_head); /* foo( ..., **{}, ...) */
int first_kw = first_chunk && stack_len == 0; /* foo(1,2,3, **kw, ...) */
- int last_kw = !node->nd_next->nd_next; /* foo( ..., **kw) */
+ int last_kw = !RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next; /* foo( ..., **kw) */
int only_kw = last_kw && first_kw; /* foo(1,2,3, **kw) */
+ empty_kw = empty_kw || nd_type_p(kw, NODE_NIL); /* foo( ..., **nil, ...) */
if (empty_kw) {
if (only_kw && method_call_keywords) {
/* **{} appears at the only keyword argument in method call,
@@ -4813,29 +5513,34 @@ VALUE
rb_node_case_when_optimizable_literal(const NODE *const node)
{
switch (nd_type(node)) {
- case NODE_LIT: {
- VALUE v = node->nd_lit;
+ case NODE_INTEGER:
+ return rb_node_integer_literal_val(node);
+ case NODE_FLOAT: {
+ VALUE v = rb_node_float_literal_val(node);
double ival;
- if (RB_FLOAT_TYPE_P(v) &&
- modf(RFLOAT_VALUE(v), &ival) == 0.0) {
+
+ if (modf(RFLOAT_VALUE(v), &ival) == 0.0) {
return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
}
- if (RB_TYPE_P(v, T_RATIONAL) || RB_TYPE_P(v, T_COMPLEX)) {
- return Qundef;
- }
- if (SYMBOL_P(v) || rb_obj_is_kind_of(v, rb_cNumeric)) {
- return v;
- }
- break;
+ return v;
}
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ return Qundef;
case NODE_NIL:
return Qnil;
case NODE_TRUE:
return Qtrue;
case NODE_FALSE:
return Qfalse;
+ case NODE_SYM:
+ return rb_node_sym_string_val(node);
+ case NODE_LINE:
+ return rb_node_line_lineno_val(node);
case NODE_STR:
- return rb_fstring(node->nd_lit);
+ return rb_node_str_string_val(node);
+ case NODE_FILE:
+ return rb_node_file_path_val(node);
}
return Qundef;
}
@@ -4845,19 +5550,19 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
LABEL *l1, int only_special_literals, VALUE literals)
{
while (vals) {
- const NODE *val = vals->nd_head;
+ const NODE *val = RNODE_LIST(vals)->nd_head;
VALUE lit = rb_node_case_when_optimizable_literal(val);
if (UNDEF_P(lit)) {
only_special_literals = 0;
}
- else if (NIL_P(rb_hash_lookup(literals, lit))) {
- rb_hash_aset(literals, lit, (VALUE)(l1) | 1);
+ else {
+ cdhash_aset_if_missing(literals, lit, (VALUE)(l1));
}
- if (nd_type_p(val, NODE_STR)) {
- debugp_param("nd_lit", val->nd_lit);
- lit = rb_fstring(val->nd_lit);
+ if (nd_type_p(val, NODE_STR) || nd_type_p(val, NODE_FILE)) {
+ debugp_param("nd_lit", get_string_value(val));
+ lit = get_string_value(val);
ADD_INSN1(cond_seq, val, putobject, lit);
RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
@@ -4869,7 +5574,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
ADD_INSN1(cond_seq, vals, topn, INT2FIX(1));
ADD_CALL(cond_seq, vals, idEqq, INT2FIX(1));
ADD_INSNL(cond_seq, val, branchif, l1);
- vals = vals->nd_next;
+ vals = RNODE_LIST(vals)->nd_next;
}
return only_special_literals;
}
@@ -4887,19 +5592,19 @@ when_splat_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
break;
case NODE_SPLAT:
ADD_INSN (cond_seq, line_node, dup);
- CHECK(COMPILE(cond_seq, "when splat", vals->nd_head));
+ CHECK(COMPILE(cond_seq, "when splat", RNODE_SPLAT(vals)->nd_head));
ADD_INSN1(cond_seq, line_node, splatarray, Qfalse);
ADD_INSN1(cond_seq, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
ADD_INSNL(cond_seq, line_node, branchif, l1);
break;
case NODE_ARGSCAT:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_body, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSCAT(vals)->nd_head, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSCAT(vals)->nd_body, l1, only_special_literals, literals));
break;
case NODE_ARGSPUSH:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSPUSH(vals)->nd_head, l1, only_special_literals, literals));
ADD_INSN (cond_seq, line_node, dup);
- CHECK(COMPILE(cond_seq, "when argspush body", vals->nd_body));
+ CHECK(COMPILE(cond_seq, "when argspush body", RNODE_ARGSPUSH(vals)->nd_body));
ADD_INSN1(cond_seq, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
ADD_INSNL(cond_seq, line_node, branchif, l1);
break;
@@ -5058,12 +5763,17 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const
CHECK(COMPILE_POPPED(pre, "masgn lhs (NODE_ATTRASGN)", node));
+ bool safenav_call = false;
LINK_ELEMENT *insn_element = LAST_ELEMENT(pre);
iobj = (INSN *)get_prev_insn((INSN *)insn_element); /* send insn */
ASSUME(iobj);
- ELEM_REMOVE(LAST_ELEMENT(pre));
- ELEM_REMOVE((LINK_ELEMENT *)iobj);
- pre->last = iobj->link.prev;
+ ELEM_REMOVE(insn_element);
+ if (!IS_INSN_ID(iobj, send)) {
+ safenav_call = true;
+ iobj = (INSN *)get_prev_insn(iobj);
+ ELEM_INSERT_NEXT(&iobj->link, insn_element);
+ }
+ (pre->last = iobj->link.prev)->next = 0;
const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(iobj, 0);
int argc = vm_ci_argc(ci) + 1;
@@ -5082,18 +5792,46 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const
return COMPILE_NG;
}
- ADD_ELEM(lhs, (LINK_ELEMENT *)iobj);
+ iobj->link.prev = lhs->last;
+ lhs->last->next = &iobj->link;
+ for (lhs->last = &iobj->link; lhs->last->next; lhs->last = lhs->last->next);
if (vm_ci_flag(ci) & VM_CALL_ARGS_SPLAT) {
int argc = vm_ci_argc(ci);
+ bool dupsplat = false;
ci = ci_argc_set(iseq, ci, argc - 1);
+ if (!(vm_ci_flag(ci) & VM_CALL_ARGS_SPLAT_MUT)) {
+ /* Given h[*a], _ = ary
+ * setup_args sets VM_CALL_ARGS_SPLAT and not VM_CALL_ARGS_SPLAT_MUT
+ * `a` must be dupped, because it will be appended with ary[0]
+ * Since you are dupping `a`, you can set VM_CALL_ARGS_SPLAT_MUT
+ */
+ dupsplat = true;
+ ci = ci_flag_set(iseq, ci, VM_CALL_ARGS_SPLAT_MUT);
+ }
OPERAND_AT(iobj, 0) = (VALUE)ci;
RB_OBJ_WRITTEN(iseq, Qundef, iobj);
- INSERT_BEFORE_INSN1(iobj, line_node, newarray, INT2FIX(1));
- INSERT_BEFORE_INSN(iobj, line_node, concatarray);
+
+ /* Given: h[*a], h[*b, 1] = ary
+ * h[*a] uses splatarray false and does not set VM_CALL_ARGS_SPLAT_MUT,
+ * so this uses splatarray true on a to dup it before using pushtoarray
+ * h[*b, 1] uses splatarray true and sets VM_CALL_ARGS_SPLAT_MUT,
+ * so you can use pushtoarray directly
+ */
+ int line_no = nd_line(line_node);
+ int node_id = nd_node_id(line_node);
+
+ if (dupsplat) {
+ INSERT_BEFORE_INSN(iobj, line_no, node_id, swap);
+ INSERT_BEFORE_INSN1(iobj, line_no, node_id, splatarray, Qtrue);
+ INSERT_BEFORE_INSN(iobj, line_no, node_id, swap);
+ }
+ INSERT_BEFORE_INSN1(iobj, line_no, node_id, pushtoarray, INT2FIX(1));
}
- ADD_INSN(lhs, line_node, pop);
- if (argc != 1) {
+ if (!safenav_call) {
ADD_INSN(lhs, line_node, pop);
+ if (argc != 1) {
+ ADD_INSN(lhs, line_node, pop);
+ }
}
for (int i=0; i < argc; i++) {
ADD_INSN(post, line_node, pop);
@@ -5119,7 +5857,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const
break;
}
case NODE_CDECL:
- if (!node->nd_vid) {
+ if (!RNODE_CDECL(node)->nd_vid) {
/* Special handling only needed for expr::C, not for C */
INSN *iobj;
@@ -5157,8 +5895,8 @@ static int
compile_massign_opt_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *lhsn)
{
if (lhsn) {
- CHECK(compile_massign_opt_lhs(iseq, ret, lhsn->nd_next));
- CHECK(compile_massign_lhs(iseq, ret, ret, ret, ret, lhsn->nd_head, NULL, 0));
+ CHECK(compile_massign_opt_lhs(iseq, ret, RNODE_LIST(lhsn)->nd_next));
+ CHECK(compile_massign_lhs(iseq, ret, ret, ret, ret, RNODE_LIST(lhsn)->nd_head, NULL, 0));
}
return COMPILE_OK;
}
@@ -5188,31 +5926,29 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
}
while (lhsn) {
- const NODE *ln = lhsn->nd_head;
+ const NODE *ln = RNODE_LIST(lhsn)->nd_head;
switch (nd_type(ln)) {
case NODE_LASGN:
- MEMORY(ln->nd_vid);
- break;
case NODE_DASGN:
case NODE_IASGN:
case NODE_CVASGN:
- MEMORY(ln->nd_vid);
+ MEMORY(get_nd_vid(ln));
break;
default:
return 0;
}
- lhsn = lhsn->nd_next;
+ lhsn = RNODE_LIST(lhsn)->nd_next;
llen++;
}
while (rhsn) {
if (llen <= rlen) {
- NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", RNODE_LIST(rhsn)->nd_head));
}
else {
- NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head));
+ NO_CHECK(COMPILE(ret, "masgn val", RNODE_LIST(rhsn)->nd_head));
}
- rhsn = rhsn->nd_next;
+ rhsn = RNODE_LIST(rhsn)->nd_next;
rlen++;
}
@@ -5229,32 +5965,31 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
static int
compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs, LINK_ANCHOR *const lhs, LINK_ANCHOR *const post, const NODE *const node, struct masgn_state *state, int popped)
{
- const NODE *rhsn = node->nd_value;
- const NODE *splatn = node->nd_args;
- const NODE *lhsn = node->nd_head;
+ const NODE *rhsn = RNODE_MASGN(node)->nd_value;
+ const NODE *splatn = RNODE_MASGN(node)->nd_args;
+ const NODE *lhsn = RNODE_MASGN(node)->nd_head;
const NODE *lhsn_count = lhsn;
int lhs_splat = (splatn && NODE_NAMED_REST_P(splatn)) ? 1 : 0;
int llen = 0;
int lpos = 0;
- int expand = 1;
while (lhsn_count) {
llen++;
- lhsn_count = lhsn_count->nd_next;
+ lhsn_count = RNODE_LIST(lhsn_count)->nd_next;
}
while (lhsn) {
- CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, lhsn->nd_head, state, (llen - lpos) + lhs_splat + state->lhs_level));
+ CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, RNODE_LIST(lhsn)->nd_head, state, (llen - lpos) + lhs_splat + state->lhs_level));
lpos++;
- lhsn = lhsn->nd_next;
+ lhsn = RNODE_LIST(lhsn)->nd_next;
}
if (lhs_splat) {
if (nd_type_p(splatn, NODE_POSTARG)) {
/*a, b, *r, p1, p2 */
- const NODE *postn = splatn->nd_2nd;
- const NODE *restn = splatn->nd_1st;
- int plen = (int)postn->nd_alen;
+ const NODE *postn = RNODE_POSTARG(splatn)->nd_2nd;
+ const NODE *restn = RNODE_POSTARG(splatn)->nd_1st;
+ int plen = (int)RNODE_LIST(postn)->as.nd_alen;
int ppos = 0;
int flag = 0x02 | (NODE_NAMED_REST_P(restn) ? 0x01 : 0x00);
@@ -5264,9 +5999,9 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, restn, state, 1 + plen + state->lhs_level));
}
while (postn) {
- CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, postn->nd_head, state, (plen - ppos) + state->lhs_level));
+ CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, RNODE_LIST(postn)->nd_head, state, (plen - ppos) + state->lhs_level));
ppos++;
- postn = postn->nd_next;
+ postn = RNODE_LIST(postn)->nd_next;
}
}
else {
@@ -5275,7 +6010,6 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
}
}
-
if (!state->nested) {
NO_CHECK(COMPILE(rhs, "normal masgn rhs", rhsn));
}
@@ -5283,16 +6017,14 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
if (!popped) {
ADD_INSN(rhs, node, dup);
}
- if (expand) {
- ADD_INSN2(rhs, node, expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
- }
+ ADD_INSN2(rhs, node, expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
return COMPILE_OK;
}
static int
compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- if (!popped || node->nd_args || !compile_massign_opt(iseq, ret, node->nd_value, node->nd_head)) {
+ if (!popped || RNODE_MASGN(node)->nd_args || !compile_massign_opt(iseq, ret, RNODE_MASGN(node)->nd_value, RNODE_MASGN(node)->nd_head)) {
struct masgn_state state;
state.lhs_level = popped ? 0 : 1;
state.nested = 0;
@@ -5314,7 +6046,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
while (memo) {
VALUE topn_arg = INT2FIX((state.num_args - memo->argn) + memo->lhs_pos);
for (int i = 0; i < memo->num_args; i++) {
- INSERT_BEFORE_INSN1(memo->before_insn, memo->line_node, topn, topn_arg);
+ INSERT_BEFORE_INSN1(memo->before_insn, nd_line(memo->line_node), nd_node_id(memo->line_node), topn, topn_arg);
}
tmp_memo = memo->next;
free(memo);
@@ -5341,15 +6073,17 @@ collect_const_segments(rb_iseq_t *iseq, const NODE *node)
for (;;) {
switch (nd_type(node)) {
case NODE_CONST:
- rb_ary_unshift(arr, ID2SYM(node->nd_vid));
+ rb_ary_unshift(arr, ID2SYM(RNODE_CONST(node)->nd_vid));
+ RB_OBJ_SET_SHAREABLE(arr);
return arr;
case NODE_COLON3:
- rb_ary_unshift(arr, ID2SYM(node->nd_mid));
+ rb_ary_unshift(arr, ID2SYM(RNODE_COLON3(node)->nd_mid));
rb_ary_unshift(arr, ID2SYM(idNULL));
+ RB_OBJ_SET_SHAREABLE(arr);
return arr;
case NODE_COLON2:
- rb_ary_unshift(arr, ID2SYM(node->nd_mid));
- node = node->nd_head;
+ rb_ary_unshift(arr, ID2SYM(RNODE_COLON2(node)->nd_mid));
+ node = RNODE_COLON2(node)->nd_head;
break;
default:
return Qfalse;
@@ -5363,22 +6097,22 @@ compile_const_prefix(rb_iseq_t *iseq, const NODE *const node,
{
switch (nd_type(node)) {
case NODE_CONST:
- debugi("compile_const_prefix - colon", node->nd_vid);
+ debugi("compile_const_prefix - colon", RNODE_CONST(node)->nd_vid);
ADD_INSN1(body, node, putobject, Qtrue);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_CONST(node)->nd_vid));
break;
case NODE_COLON3:
- debugi("compile_const_prefix - colon3", node->nd_mid);
+ debugi("compile_const_prefix - colon3", RNODE_COLON3(node)->nd_mid);
ADD_INSN(body, node, pop);
ADD_INSN1(body, node, putobject, rb_cObject);
ADD_INSN1(body, node, putobject, Qtrue);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_COLON3(node)->nd_mid));
break;
case NODE_COLON2:
- CHECK(compile_const_prefix(iseq, node->nd_head, pref, body));
- debugi("compile_const_prefix - colon2", node->nd_mid);
+ CHECK(compile_const_prefix(iseq, RNODE_COLON2(node)->nd_head, pref, body));
+ debugi("compile_const_prefix - colon2", RNODE_COLON2(node)->nd_mid);
ADD_INSN1(body, node, putobject, Qfalse);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_COLON2(node)->nd_mid));
break;
default:
CHECK(COMPILE(pref, "const colon2 prefix", node));
@@ -5388,6 +6122,23 @@ compile_const_prefix(rb_iseq_t *iseq, const NODE *const node,
}
static int
+cpath_const_p(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CONST:
+ case NODE_COLON3:
+ return TRUE;
+ case NODE_COLON2:
+ if (RNODE_COLON2(node)->nd_head) {
+ return cpath_const_p(RNODE_COLON2(node)->nd_head);
+ }
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+static int
compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
{
if (nd_type_p(cpath, NODE_COLON3)) {
@@ -5395,10 +6146,14 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
ADD_INSN1(ret, cpath, putobject, rb_cObject);
return VM_DEFINECLASS_FLAG_SCOPED;
}
- else if (cpath->nd_head) {
- /* Bar::Foo */
- NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head));
- return VM_DEFINECLASS_FLAG_SCOPED;
+ else if (nd_type_p(cpath, NODE_COLON2) && RNODE_COLON2(cpath)->nd_head) {
+ /* Bar::Foo or expr::Foo */
+ NO_CHECK(COMPILE(ret, "nd_else->nd_head", RNODE_COLON2(cpath)->nd_head));
+ int flags = VM_DEFINECLASS_FLAG_SCOPED;
+ if (!cpath_const_p(RNODE_COLON2(cpath)->nd_head)) {
+ flags |= VM_DEFINECLASS_FLAG_DYNAMIC_CREF;
+ }
+ return flags;
}
else {
/* class at cbase Foo */
@@ -5411,16 +6166,16 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
static inline int
private_recv_p(const NODE *node)
{
- if (nd_type_p(node->nd_recv, NODE_SELF)) {
- NODE *self = node->nd_recv;
- return self->nd_state != 0;
+ NODE *recv = get_nd_recv(node);
+ if (recv && nd_type_p(recv, NODE_SELF)) {
+ return RNODE_SELF(recv)->nd_state != 0;
}
return 0;
}
static void
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
- const NODE *const node, LABEL **lfinish, VALUE needstr);
+ const NODE *const node, LABEL **lfinish, VALUE needstr, bool ignore);
static int
compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, const enum node_type type, const NODE *const line_node, int popped, bool assume_receiver);
@@ -5451,21 +6206,34 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
expr_type = DEFINED_FALSE;
break;
+ case NODE_HASH:
case NODE_LIST:{
- const NODE *vals = node;
+ const NODE *vals = (nd_type(node) == NODE_HASH) ? RNODE_HASH(node)->nd_head : node;
- do {
- defined_expr0(iseq, ret, vals->nd_head, lfinish, Qfalse, false);
+ if (vals) {
+ do {
+ if (RNODE_LIST(vals)->nd_head) {
+ defined_expr0(iseq, ret, RNODE_LIST(vals)->nd_head, lfinish, Qfalse, false);
- if (!lfinish[1]) {
- lfinish[1] = NEW_LABEL(line);
- }
- ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- } while ((vals = vals->nd_next) != NULL);
+ if (!lfinish[1]) {
+ lfinish[1] = NEW_LABEL(line);
+ }
+ ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
+ }
+ } while ((vals = RNODE_LIST(vals)->nd_next) != NULL);
+ }
}
/* fall through */
case NODE_STR:
- case NODE_LIT:
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
case NODE_ZLIST:
case NODE_AND:
case NODE_OR:
@@ -5473,6 +6241,15 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
expr_type = DEFINED_EXPR;
break;
+ case NODE_SPLAT:
+ defined_expr0(iseq, ret, RNODE_LIST(node)->nd_head, lfinish, Qfalse, false);
+ if (!lfinish[1]) {
+ lfinish[1] = NEW_LABEL(line);
+ }
+ ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
+ expr_type = DEFINED_EXPR;
+ break;
+
/* variables */
case NODE_LVAR:
case NODE_DVAR:
@@ -5482,47 +6259,47 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
#define PUSH_VAL(type) (needstr == Qfalse ? Qtrue : rb_iseq_defined_string(type))
case NODE_IVAR:
ADD_INSN3(ret, line_node, definedivar,
- ID2SYM(node->nd_vid), get_ivar_ic_value(iseq,node->nd_vid), PUSH_VAL(DEFINED_IVAR));
+ ID2SYM(RNODE_IVAR(node)->nd_vid), get_ivar_ic_value(iseq,RNODE_IVAR(node)->nd_vid), PUSH_VAL(DEFINED_IVAR));
return;
case NODE_GVAR:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_GVAR),
- ID2SYM(node->nd_entry), PUSH_VAL(DEFINED_GVAR));
+ ID2SYM(RNODE_GVAR(node)->nd_vid), PUSH_VAL(DEFINED_GVAR));
return;
case NODE_CVAR:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CVAR),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_CVAR));
+ ID2SYM(RNODE_CVAR(node)->nd_vid), PUSH_VAL(DEFINED_CVAR));
return;
case NODE_CONST:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CONST),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_CONST));
+ ID2SYM(RNODE_CONST(node)->nd_vid), PUSH_VAL(DEFINED_CONST));
return;
case NODE_COLON2:
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(line);
}
- defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse, false);
+ defined_expr0(iseq, ret, RNODE_COLON2(node)->nd_head, lfinish, Qfalse, false);
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head));
+ NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", RNODE_COLON2(node)->nd_head));
- if (rb_is_const_id(node->nd_mid)) {
+ if (rb_is_const_id(RNODE_COLON2(node)->nd_mid)) {
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CONST_FROM),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_CONST));
+ ID2SYM(RNODE_COLON2(node)->nd_mid), PUSH_VAL(DEFINED_CONST));
}
else {
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(RNODE_COLON2(node)->nd_mid), PUSH_VAL(DEFINED_METHOD));
}
return;
case NODE_COLON3:
ADD_INSN1(ret, line_node, putobject, rb_cObject);
ADD_INSN3(ret, line_node, defined,
- INT2FIX(DEFINED_CONST_FROM), ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_CONST));
+ INT2FIX(DEFINED_CONST_FROM), ID2SYM(RNODE_COLON3(node)->nd_mid), PUSH_VAL(DEFINED_CONST));
return;
/* method dispatch */
@@ -5535,7 +6312,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
(type == NODE_CALL || type == NODE_OPCALL ||
(type == NODE_ATTRASGN && !private_recv_p(node)));
- if (node->nd_args || explicit_receiver) {
+ if (get_nd_args(node) || explicit_receiver) {
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(line);
}
@@ -5543,31 +6320,31 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
lfinish[2] = NEW_LABEL(line);
}
}
- if (node->nd_args) {
- defined_expr0(iseq, ret, node->nd_args, lfinish, Qfalse, false);
+ if (get_nd_args(node)) {
+ defined_expr0(iseq, ret, get_nd_args(node), lfinish, Qfalse, false);
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
}
if (explicit_receiver) {
- defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse, true);
- switch (nd_type(node->nd_recv)) {
+ defined_expr0(iseq, ret, get_nd_recv(node), lfinish, Qfalse, true);
+ switch (nd_type(get_nd_recv(node))) {
case NODE_CALL:
case NODE_OPCALL:
case NODE_VCALL:
case NODE_FCALL:
case NODE_ATTRASGN:
ADD_INSNL(ret, line_node, branchunless, lfinish[2]);
- compile_call(iseq, ret, node->nd_recv, nd_type(node->nd_recv), line_node, 0, true);
+ compile_call(iseq, ret, get_nd_recv(node), nd_type(get_nd_recv(node)), line_node, 0, true);
break;
default:
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv));
+ NO_CHECK(COMPILE(ret, "defined/recv", get_nd_recv(node)));
break;
}
if (keep_result) {
ADD_INSN(ret, line_node, dup);
}
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(get_node_call_nd_mid(node)), PUSH_VAL(DEFINED_METHOD));
}
else {
ADD_INSN(ret, line_node, putself);
@@ -5575,7 +6352,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
ADD_INSN(ret, line_node, dup);
}
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_FUNC),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(get_node_call_nd_mid(node)), PUSH_VAL(DEFINED_METHOD));
}
return;
}
@@ -5584,13 +6361,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_YIELD), 0,
PUSH_VAL(DEFINED_YIELD));
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
return;
case NODE_BACK_REF:
case NODE_NTH_REF:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_REF),
- INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)),
+ INT2FIX((RNODE_BACK_REF(node)->nd_nth << 1) | (type == NODE_BACK_REF)),
PUSH_VAL(DEFINED_GVAR));
return;
@@ -5613,11 +6391,12 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_IASGN:
case NODE_CDECL:
case NODE_CVASGN:
+ case NODE_OP_CDECL:
expr_type = DEFINED_ASGN;
break;
}
- assert(expr_type != DEFINED_NOT_DEFINED);
+ RUBY_ASSERT(expr_type != DEFINED_NOT_DEFINED);
if (needstr != Qfalse) {
VALUE str = rb_iseq_defined_string(expr_type);
@@ -5631,14 +6410,13 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
static void
build_defined_rescue_iseq(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const void *unused)
{
- NODE dummy_line_node = generate_dummy_line_node(0, -1);
- ADD_INSN(ret, &dummy_line_node, putnil);
+ ADD_SYNTHETIC_INSN(ret, 0, -1, putnil);
iseq_set_exception_local_table(iseq);
}
static void
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
- const NODE *const node, LABEL **lfinish, VALUE needstr)
+ const NODE *const node, LABEL **lfinish, VALUE needstr, bool ignore)
{
LINK_ELEMENT *lcur = ret->last;
defined_expr0(iseq, ret, node, lfinish, needstr, false);
@@ -5649,24 +6427,26 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const rb_iseq_t *rescue;
struct rb_iseq_new_with_callback_callback_func *ifunc =
rb_iseq_new_with_callback_new_callback(build_defined_rescue_iseq, NULL);
- rescue = new_child_iseq_with_callback(iseq, ifunc,
+ rescue = NEW_CHILD_ISEQ_WITH_CALLBACK(ifunc,
rb_str_concat(rb_str_new2("defined guard in "),
ISEQ_BODY(iseq)->location.label),
- iseq, ISEQ_TYPE_RESCUE, 0);
+ ISEQ_TYPE_RESCUE, 0);
lstart->rescued = LABEL_RESCUE_BEG;
lend->rescued = LABEL_RESCUE_END;
APPEND_LABEL(ret, lcur, lstart);
ADD_LABEL(ret, lend);
- ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
+ if (!ignore) {
+ ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
+ }
}
}
static int
-compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, VALUE needstr)
+compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, VALUE needstr, bool ignore)
{
const int line = nd_line(node);
const NODE *line_node = node;
- if (!node->nd_head) {
+ if (!RNODE_DEFINED(node)->nd_head) {
VALUE str = rb_iseq_defined_string(DEFINED_NIL);
ADD_INSN1(ret, line_node, putobject, str);
}
@@ -5676,9 +6456,9 @@ compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const
lfinish[0] = NEW_LABEL(line);
lfinish[1] = 0;
lfinish[2] = 0;
- defined_expr(iseq, ret, node->nd_head, lfinish, needstr);
+ defined_expr(iseq, ret, RNODE_DEFINED(node)->nd_head, lfinish, needstr, ignore);
if (lfinish[1]) {
- ELEM_INSERT_NEXT(last, &new_insn_body(iseq, line_node, BIN(putnil), 0)->link);
+ ELEM_INSERT_NEXT(last, &new_insn_body(iseq, nd_line(line_node), nd_node_id(line_node), BIN(putnil), 0)->link);
ADD_INSN(ret, line_node, swap);
if (lfinish[2]) {
ADD_LABEL(ret, lfinish[2]);
@@ -5717,7 +6497,7 @@ make_name_for_block(const rb_iseq_t *orig_iseq)
static void
push_ensure_entry(rb_iseq_t *iseq,
struct iseq_compile_data_ensure_node_stack *enl,
- struct ensure_range *er, const NODE *const node)
+ struct ensure_range *er, const void *const node)
{
enl->ensure_node = node;
enl->prev = ISEQ_COMPILE_DATA(iseq)->ensure_node_stack; /* prev */
@@ -5730,7 +6510,7 @@ 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));
+ compile_data_alloc_type(iseq, struct ensure_range);
while (erange->next != 0) {
erange = erange->next;
@@ -5759,7 +6539,7 @@ can_add_ensure_iseq(const rb_iseq_t *iseq)
static void
add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return)
{
- assert(can_add_ensure_iseq(iseq));
+ RUBY_ASSERT(can_add_ensure_iseq(iseq));
struct iseq_compile_data_ensure_node_stack *enlp =
ISEQ_COMPILE_DATA(iseq)->ensure_node_stack;
@@ -5800,10 +6580,10 @@ check_keyword(const NODE *node)
/* This check is essentially a code clone of compile_keyword_arg. */
if (nd_type_p(node, NODE_LIST)) {
- while (node->nd_next) {
- node = node->nd_next;
+ while (RNODE_LIST(node)->nd_next) {
+ node = RNODE_LIST(node)->nd_next;
}
- node = node->nd_head;
+ node = RNODE_LIST(node)->nd_head;
}
return keyword_node_p(node);
@@ -5815,14 +6595,29 @@ keyword_node_single_splat_p(NODE *kwnode)
{
RUBY_ASSERT(keyword_node_p(kwnode));
- NODE *node = kwnode->nd_head;
- return node->nd_head == NULL &&
- node->nd_next->nd_next == NULL;
+ NODE *node = RNODE_HASH(kwnode)->nd_head;
+ return RNODE_LIST(node)->nd_head == NULL &&
+ RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next == NULL;
}
+static void
+compile_single_keyword_splat_mutable(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
+ NODE *kwnode, unsigned int *flag_ptr)
+{
+ *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
+ ADD_INSN1(args, argn, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN1(args, argn, newhash, INT2FIX(0));
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ ADD_SEND(args, argn, id_core_hash_merge_kwd, INT2FIX(2));
+}
+
+#define SPLATARRAY_FALSE 0
+#define SPLATARRAY_TRUE 1
+#define DUP_SINGLE_KW_SPLAT 2
+
static int
setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
- int dup_rest, unsigned int *flag_ptr, struct rb_callinfo_kwarg **kwarg_ptr)
+ unsigned int *dup_rest, unsigned int *flag_ptr, struct rb_callinfo_kwarg **kwarg_ptr)
{
if (!argn) return 0;
@@ -5830,115 +6625,256 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
switch (nd_type(argn)) {
case NODE_LIST: {
- // f(x, y, z)
- int len = compile_args(iseq, args, argn, &kwnode);
- RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_ARGS_SPLAT) == 0);
+ // f(x, y, z)
+ int len = compile_args(iseq, args, argn, &kwnode);
+ RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_ARGS_SPLAT) == 0);
- if (kwnode) {
- if (compile_keyword_arg(iseq, args, kwnode, kwarg_ptr, flag_ptr)) {
- len -= 1;
- }
- else {
- compile_hash(iseq, args, kwnode, TRUE, FALSE);
- }
- }
+ if (kwnode) {
+ if (compile_keyword_arg(iseq, args, kwnode, kwarg_ptr, flag_ptr)) {
+ len -= 1;
+ }
+ else {
+ if (keyword_node_single_splat_p(kwnode) && (*dup_rest & DUP_SINGLE_KW_SPLAT)) {
+ compile_single_keyword_splat_mutable(iseq, args, argn, kwnode, flag_ptr);
+ }
+ else {
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ }
+ }
+ }
- return len;
+ return len;
}
case NODE_SPLAT: {
- // f(*a)
- NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head));
- ADD_INSN1(args, argn, splatarray, RBOOL(dup_rest));
- if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
- RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_KW_SPLAT) == 0);
- return 1;
+ // f(*a)
+ NO_CHECK(COMPILE(args, "args (splat)", RNODE_SPLAT(argn)->nd_head));
+ ADD_INSN1(args, argn, splatarray, RBOOL(*dup_rest & SPLATARRAY_TRUE));
+ if (*dup_rest & SPLATARRAY_TRUE) *dup_rest &= ~SPLATARRAY_TRUE;
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_KW_SPLAT) == 0);
+ return 1;
}
case NODE_ARGSCAT: {
- if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
- int argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL);
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ int argc = setup_args_core(iseq, args, RNODE_ARGSCAT(argn)->nd_head, dup_rest, NULL, NULL);
+ bool args_pushed = false;
- if (nd_type_p(argn->nd_body, NODE_LIST)) {
- int rest_len = compile_args(iseq, args, argn->nd_body, &kwnode);
- if (kwnode) rest_len--;
- ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
- }
- else {
- RUBY_ASSERT(!check_keyword(argn->nd_body));
- NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body));
- }
+ if (nd_type_p(RNODE_ARGSCAT(argn)->nd_body, NODE_LIST)) {
+ int rest_len = compile_args(iseq, args, RNODE_ARGSCAT(argn)->nd_body, &kwnode);
+ if (kwnode) rest_len--;
+ ADD_INSN1(args, argn, pushtoarray, INT2FIX(rest_len));
+ args_pushed = true;
+ }
+ else {
+ RUBY_ASSERT(!check_keyword(RNODE_ARGSCAT(argn)->nd_body));
+ NO_CHECK(COMPILE(args, "args (cat: splat)", RNODE_ARGSCAT(argn)->nd_body));
+ }
- if (nd_type_p(argn->nd_head, NODE_LIST)) {
- ADD_INSN1(args, argn, splatarray, Qtrue);
- argc += 1;
- }
- else {
- ADD_INSN1(args, argn, splatarray, Qfalse);
- ADD_INSN(args, argn, concatarray);
- }
+ if (nd_type_p(RNODE_ARGSCAT(argn)->nd_head, NODE_LIST)) {
+ ADD_INSN1(args, argn, splatarray, RBOOL(*dup_rest & SPLATARRAY_TRUE));
+ if (*dup_rest & SPLATARRAY_TRUE) *dup_rest &= ~SPLATARRAY_TRUE;
+ argc += 1;
+ }
+ else if (!args_pushed) {
+ ADD_INSN(args, argn, concattoarray);
+ }
- // f(..., *a, ..., k1:1, ...) #=> f(..., *[*a, ...], **{k1:1, ...})
- if (kwnode) {
- // kwsplat
- *flag_ptr |= VM_CALL_KW_SPLAT;
- *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
- compile_hash(iseq, args, kwnode, TRUE, FALSE);
- argc += 1;
- }
+ // f(..., *a, ..., k1:1, ...) #=> f(..., *[*a, ...], **{k1:1, ...})
+ if (kwnode) {
+ // kwsplat
+ *flag_ptr |= VM_CALL_KW_SPLAT;
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ argc += 1;
+ }
- return argc;
+ return argc;
}
case NODE_ARGSPUSH: {
- if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
- int argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL);
-
- if (nd_type_p(argn->nd_body, NODE_LIST)) {
- int rest_len = compile_args(iseq, args, argn->nd_body, &kwnode);
- if (kwnode) rest_len--;
- ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
- ADD_INSN1(args, argn, newarray, INT2FIX(1));
- ADD_INSN(args, argn, concatarray);
- }
- else {
- if (keyword_node_p(argn->nd_body)) {
- kwnode = argn->nd_body;
- }
- else {
- NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body));
- ADD_INSN1(args, argn, newarray, INT2FIX(1));
- ADD_INSN(args, argn, concatarray);
- }
- }
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ int argc = setup_args_core(iseq, args, RNODE_ARGSPUSH(argn)->nd_head, dup_rest, NULL, NULL);
- if (kwnode) {
- // f(*a, k:1)
- *flag_ptr |= VM_CALL_KW_SPLAT;
- if (!keyword_node_single_splat_p(kwnode)) {
- *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
- }
- compile_hash(iseq, args, kwnode, TRUE, FALSE);
- argc += 1;
- }
+ if (nd_type_p(RNODE_ARGSPUSH(argn)->nd_body, NODE_LIST)) {
+ int rest_len = compile_args(iseq, args, RNODE_ARGSPUSH(argn)->nd_body, &kwnode);
+ if (kwnode) rest_len--;
+ ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
+ ADD_INSN1(args, argn, pushtoarray, INT2FIX(1));
+ }
+ else {
+ if (keyword_node_p(RNODE_ARGSPUSH(argn)->nd_body)) {
+ kwnode = RNODE_ARGSPUSH(argn)->nd_body;
+ }
+ else {
+ NO_CHECK(COMPILE(args, "args (cat: splat)", RNODE_ARGSPUSH(argn)->nd_body));
+ ADD_INSN1(args, argn, pushtoarray, INT2FIX(1));
+ }
+ }
+
+ if (kwnode) {
+ // f(*a, k:1)
+ *flag_ptr |= VM_CALL_KW_SPLAT;
+ if (!keyword_node_single_splat_p(kwnode)) {
+ *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ }
+ else if (*dup_rest & DUP_SINGLE_KW_SPLAT) {
+ compile_single_keyword_splat_mutable(iseq, args, argn, kwnode, flag_ptr);
+ }
+ else {
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ }
+ argc += 1;
+ }
- return argc;
+ return argc;
}
default: {
- UNKNOWN_NODE("setup_arg", argn, Qnil);
+ UNKNOWN_NODE("setup_arg", argn, Qnil);
}
}
}
+static void
+setup_args_splat_mut(unsigned int *flag, int dup_rest, int initial_dup_rest)
+{
+ if ((*flag & VM_CALL_ARGS_SPLAT) && dup_rest != initial_dup_rest) {
+ *flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+}
+
+static bool
+setup_args_dup_rest_p(const NODE *argn)
+{
+ switch(nd_type(argn)) {
+ case NODE_LVAR:
+ case NODE_DVAR:
+ case NODE_GVAR:
+ case NODE_IVAR:
+ case NODE_CVAR:
+ case NODE_CONST:
+ case NODE_COLON3:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ case NODE_STR:
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_SELF:
+ case NODE_NIL:
+ case NODE_TRUE:
+ case NODE_FALSE:
+ case NODE_LAMBDA:
+ case NODE_NTH_REF:
+ case NODE_BACK_REF:
+ return false;
+ case NODE_COLON2:
+ return setup_args_dup_rest_p(RNODE_COLON2(argn)->nd_head);
+ case NODE_LIST:
+ while (argn) {
+ if (setup_args_dup_rest_p(RNODE_LIST(argn)->nd_head)) {
+ return true;
+ }
+ argn = RNODE_LIST(argn)->nd_next;
+ }
+ return false;
+ default:
+ return true;
+ }
+}
+
static VALUE
setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
unsigned int *flag, struct rb_callinfo_kwarg **keywords)
{
VALUE ret;
+ unsigned int dup_rest = SPLATARRAY_TRUE, initial_dup_rest;
+
+ if (argn) {
+ const NODE *check_arg = nd_type_p(argn, NODE_BLOCK_PASS) ?
+ RNODE_BLOCK_PASS(argn)->nd_head : argn;
+
+ if (check_arg) {
+ switch(nd_type(check_arg)) {
+ case(NODE_SPLAT):
+ // avoid caller side array allocation for f(*arg)
+ dup_rest = SPLATARRAY_FALSE;
+ break;
+ case(NODE_ARGSCAT):
+ // avoid caller side array allocation for f(1, *arg)
+ dup_rest = !nd_type_p(RNODE_ARGSCAT(check_arg)->nd_head, NODE_LIST);
+ break;
+ case(NODE_ARGSPUSH):
+ // avoid caller side array allocation for f(*arg, **hash) and f(1, *arg, **hash)
+ dup_rest = !((nd_type_p(RNODE_ARGSPUSH(check_arg)->nd_head, NODE_SPLAT) ||
+ (nd_type_p(RNODE_ARGSPUSH(check_arg)->nd_head, NODE_ARGSCAT) &&
+ nd_type_p(RNODE_ARGSCAT(RNODE_ARGSPUSH(check_arg)->nd_head)->nd_head, NODE_LIST))) &&
+ nd_type_p(RNODE_ARGSPUSH(check_arg)->nd_body, NODE_HASH) &&
+ !RNODE_HASH(RNODE_ARGSPUSH(check_arg)->nd_body)->nd_brace);
+
+ if (dup_rest == SPLATARRAY_FALSE) {
+ // require allocation for keyword key/value/splat that may modify splatted argument
+ NODE *node = RNODE_HASH(RNODE_ARGSPUSH(check_arg)->nd_body)->nd_head;
+ while (node) {
+ NODE *key_node = RNODE_LIST(node)->nd_head;
+ if (key_node && setup_args_dup_rest_p(key_node)) {
+ dup_rest = SPLATARRAY_TRUE;
+ break;
+ }
+
+ node = RNODE_LIST(node)->nd_next;
+ NODE *value_node = RNODE_LIST(node)->nd_head;
+ if (setup_args_dup_rest_p(value_node)) {
+ dup_rest = SPLATARRAY_TRUE;
+ break;
+ }
+
+ node = RNODE_LIST(node)->nd_next;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (check_arg != argn && setup_args_dup_rest_p(RNODE_BLOCK_PASS(argn)->nd_body)) {
+ // for block pass that may modify splatted argument, dup rest and kwrest if given
+ dup_rest = SPLATARRAY_TRUE | DUP_SINGLE_KW_SPLAT;
+ }
+ }
+ initial_dup_rest = dup_rest;
+
if (argn && nd_type_p(argn, NODE_BLOCK_PASS)) {
- unsigned int dup_rest = 1;
DECL_ANCHOR(arg_block);
INIT_ANCHOR(arg_block);
- NO_CHECK(COMPILE(arg_block, "block", argn->nd_body));
- *flag |= VM_CALL_ARGS_BLOCKARG;
+ if (RNODE_BLOCK_PASS(argn)->forwarding && ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->param.flags.forwardable) {
+ int idx = ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->local_table_size;// - get_local_var_idx(iseq, idDot3);
+
+ RUBY_ASSERT(nd_type_p(RNODE_BLOCK_PASS(argn)->nd_head, NODE_ARGSPUSH));
+ const NODE * arg_node =
+ RNODE_ARGSPUSH(RNODE_BLOCK_PASS(argn)->nd_head)->nd_head;
+
+ int argc = 0;
+
+ // Only compile leading args:
+ // foo(x, y, ...)
+ // ^^^^
+ if (nd_type_p(arg_node, NODE_ARGSCAT)) {
+ argc += setup_args_core(iseq, args, RNODE_ARGSCAT(arg_node)->nd_head, &dup_rest, flag, keywords);
+ }
+
+ *flag |= VM_CALL_FORWARDING;
+
+ ADD_GETLOCAL(args, argn, idx, get_lvar_level(iseq));
+ setup_args_splat_mut(flag, dup_rest, initial_dup_rest);
+ return INT2FIX(argc);
+ }
+ else {
+ *flag |= VM_CALL_ARGS_BLOCKARG;
+
+ NO_CHECK(COMPILE(arg_block, "block", RNODE_BLOCK_PASS(argn)->nd_body));
+ }
if (LIST_INSN_SIZE_ONE(arg_block)) {
LINK_ELEMENT *elem = FIRST_ELEMENT(arg_block);
@@ -5947,15 +6883,15 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
if (iobj->insn_id == BIN(getblockparam)) {
iobj->insn_id = BIN(getblockparamproxy);
}
- dup_rest = 0;
}
}
- ret = INT2FIX(setup_args_core(iseq, args, argn->nd_head, dup_rest, flag, keywords));
+ ret = INT2FIX(setup_args_core(iseq, args, RNODE_BLOCK_PASS(argn)->nd_head, &dup_rest, flag, keywords));
ADD_SEQ(args, arg_block);
}
else {
- ret = INT2FIX(setup_args_core(iseq, args, argn, 0, flag, keywords));
+ ret = INT2FIX(setup_args_core(iseq, args, argn, &dup_rest, flag, keywords));
}
+ setup_args_splat_mut(flag, dup_rest, initial_dup_rest);
return ret;
}
@@ -5970,7 +6906,7 @@ build_postexe_iseq(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *ptr)
ADD_INSN1(ret, body, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_CALL_WITH_BLOCK(ret, body, id_core_set_postexe, argc, block);
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block);
- iseq_set_local_table(iseq, 0);
+ iseq_set_local_table(iseq, 0, 0);
}
static void
@@ -5990,19 +6926,19 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSN(ret, line_node, dup);
ADD_INSNL(ret, line_node, branchunless, fail_label);
- for (vars = node; vars; vars = vars->nd_next) {
+ for (vars = node; vars; vars = RNODE_BLOCK(vars)->nd_next) {
INSN *cap;
- if (vars->nd_next) {
+ if (RNODE_BLOCK(vars)->nd_next) {
ADD_INSN(ret, line_node, dup);
}
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "capture", RNODE_BLOCK(vars)->nd_head));
last = last->next; /* putobject :var */
- cap = new_insn_send(iseq, line_node, idAREF, INT2FIX(1),
+ cap = new_insn_send(iseq, nd_line(line_node), nd_node_id(line_node), idAREF, INT2FIX(1),
NULL, INT2FIX(0), NULL);
ELEM_INSERT_PREV(last->next, (LINK_ELEMENT *)cap);
#if !defined(NAMED_CAPTURE_SINGLE_OPT) || NAMED_CAPTURE_SINGLE_OPT-0
- if (!vars->nd_next && vars == node) {
+ if (!RNODE_BLOCK(vars)->nd_next && vars == node) {
/* only one name */
DECL_ANCHOR(nom);
@@ -6023,9 +6959,9 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSNL(ret, line_node, jump, end_label);
ADD_LABEL(ret, fail_label);
ADD_INSN(ret, line_node, pop);
- for (vars = node; vars; vars = vars->nd_next) {
+ for (vars = node; vars; vars = RNODE_BLOCK(vars)->nd_next) {
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "capture", RNODE_BLOCK(vars)->nd_head));
last = last->next; /* putobject :var */
((INSN*)last)->insn_id = BIN(putnil);
((INSN*)last)->operand_size = 0;
@@ -6038,8 +6974,10 @@ optimizable_range_item_p(const NODE *n)
{
if (!n) return FALSE;
switch (nd_type(n)) {
- case NODE_LIT:
- return RB_INTEGER_TYPE_P(n->nd_lit);
+ case NODE_LINE:
+ return TRUE;
+ case NODE_INTEGER:
+ return TRUE;
case NODE_NIL:
return TRUE;
default:
@@ -6047,11 +6985,32 @@ optimizable_range_item_p(const NODE *n)
}
}
+static VALUE
+optimized_range_item(const NODE *n)
+{
+ switch (nd_type(n)) {
+ case NODE_LINE:
+ return rb_node_line_lineno_val(n);
+ case NODE_INTEGER:
+ return rb_node_integer_literal_val(n);
+ case NODE_FLOAT:
+ return rb_node_float_literal_val(n);
+ case NODE_RATIONAL:
+ return rb_node_rational_literal_val(n);
+ case NODE_IMAGINARY:
+ return rb_node_imaginary_literal_val(n);
+ case NODE_NIL:
+ return Qnil;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(n)));
+ }
+}
+
static int
compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
- const NODE *const node_body = type == NODE_IF ? node->nd_body : node->nd_else;
- const NODE *const node_else = type == NODE_IF ? node->nd_else : node->nd_body;
+ const NODE *const node_body = type == NODE_IF ? RNODE_IF(node)->nd_body : RNODE_UNLESS(node)->nd_else;
+ const NODE *const node_else = type == NODE_IF ? RNODE_IF(node)->nd_else : RNODE_UNLESS(node)->nd_body;
const int line = nd_line(node);
const NODE *line_node = node;
@@ -6064,11 +7023,16 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
else_label = NEW_LABEL(line);
end_label = 0;
- compile_branch_condition(iseq, cond_seq, node->nd_cond, then_label, else_label);
+ NODE *cond = RNODE_IF(node)->nd_cond;
+ if (nd_type(cond) == NODE_BLOCK) {
+ cond = RNODE_BLOCK(cond)->nd_head;
+ }
+
+ CHECK(compile_branch_condition(iseq, cond_seq, cond, then_label, else_label));
ADD_SEQ(ret, cond_seq);
if (then_label->refcnt && else_label->refcnt) {
- branches = decl_branch_base(iseq, node, type == NODE_IF ? "if" : "unless");
+ branches = decl_branch_base(iseq, PTR2NUM(node), nd_code_loc(node), type == NODE_IF ? "if" : "unless");
}
if (then_label->refcnt) {
@@ -6079,10 +7043,12 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
CHECK(COMPILE_(then_seq, "then", node_body, popped));
if (else_label->refcnt) {
+ const NODE *const coverage_node = node_body ? node_body : node;
add_trace_branch_coverage(
iseq,
ret,
- node_body ? node_body : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
0,
type == NODE_IF ? "then" : "else",
branches);
@@ -6103,10 +7069,12 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
CHECK(COMPILE_(else_seq, "else", node_else, popped));
if (then_label->refcnt) {
+ const NODE *const coverage_node = node_else ? node_else : node;
add_trace_branch_coverage(
iseq,
ret,
- node_else ? node_else : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
1,
type == NODE_IF ? "else" : "then",
branches);
@@ -6131,7 +7099,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
DECL_ANCHOR(body_seq);
DECL_ANCHOR(cond_seq);
int only_special_literals = 1;
- VALUE literals = rb_hash_new();
+ VALUE literals = cdhash_new(0);
int line;
enum node_type type;
const NODE *line_node;
@@ -6142,13 +7110,11 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
INIT_ANCHOR(body_seq);
INIT_ANCHOR(cond_seq);
- RHASH_TBL_RAW(literals)->type = &cdhash_type;
+ CHECK(COMPILE(head, "case base", RNODE_CASE(node)->nd_head));
- CHECK(COMPILE(head, "case base", node->nd_head));
+ branches = decl_branch_base(iseq, PTR2NUM(node), nd_code_loc(node), "case");
- branches = decl_branch_base(iseq, node, "case");
-
- node = node->nd_body;
+ node = RNODE_CASE(node)->nd_body;
EXPECT_NODE("NODE_CASE", node, NODE_WHEN, COMPILE_NG);
type = nd_type(node);
line = nd_line(node);
@@ -6165,17 +7131,21 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
l1 = NEW_LABEL(line);
ADD_LABEL(body_seq, l1);
ADD_INSN(body_seq, line_node, pop);
+
+ const NODE *const coverage_node = RNODE_WHEN(node)->nd_body ? RNODE_WHEN(node)->nd_body : node;
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
branch_id++,
"when",
branches);
- CHECK(COMPILE_(body_seq, "when body", node->nd_body, popped));
+
+ CHECK(COMPILE_(body_seq, "when body", RNODE_WHEN(node)->nd_body, popped));
ADD_INSNL(body_seq, line_node, jump, endlabel);
- vals = node->nd_head;
+ vals = RNODE_WHEN(node)->nd_head;
if (vals) {
switch (nd_type(vals)) {
case NODE_LIST:
@@ -6196,7 +7166,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
EXPECT_NODE_NONULL("NODE_CASE", node, NODE_LIST, COMPILE_NG);
}
- node = node->nd_next;
+ node = RNODE_WHEN(node)->nd_next;
if (!node) {
break;
}
@@ -6208,7 +7178,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
if (node) {
ADD_LABEL(cond_seq, elselabel);
ADD_INSN(cond_seq, line_node, pop);
- add_trace_branch_coverage(iseq, cond_seq, node, branch_id, "else", branches);
+ add_trace_branch_coverage(iseq, cond_seq, nd_code_loc(node), nd_node_id(node), branch_id, "else", branches);
CHECK(COMPILE_(cond_seq, "else", node, popped));
ADD_INSNL(cond_seq, line_node, jump, endlabel);
}
@@ -6216,7 +7186,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
debugs("== else (implicit)\n");
ADD_LABEL(cond_seq, elselabel);
ADD_INSN(cond_seq, orig_node, pop);
- add_trace_branch_coverage(iseq, cond_seq, orig_node, branch_id, "else", branches);
+ add_trace_branch_coverage(iseq, cond_seq, nd_code_loc(orig_node), nd_node_id(orig_node), branch_id, "else", branches);
if (!popped) {
ADD_INSN(cond_seq, orig_node, putnil);
}
@@ -6241,13 +7211,13 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
{
const NODE *vals;
const NODE *val;
- const NODE *node = orig_node->nd_body;
+ const NODE *node = RNODE_CASE2(orig_node)->nd_body;
LABEL *endlabel;
DECL_ANCHOR(body_seq);
VALUE branches = Qfalse;
int branch_id = 0;
- branches = decl_branch_base(iseq, orig_node, "case");
+ branches = decl_branch_base(iseq, PTR2NUM(orig_node), nd_code_loc(orig_node), "case");
INIT_ANCHOR(body_seq);
endlabel = NEW_LABEL(nd_line(node));
@@ -6256,17 +7226,21 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
const int line = nd_line(node);
LABEL *l1 = NEW_LABEL(line);
ADD_LABEL(body_seq, l1);
+
+ const NODE *const coverage_node = RNODE_WHEN(node)->nd_body ? RNODE_WHEN(node)->nd_body : node;
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
branch_id++,
"when",
branches);
- CHECK(COMPILE_(body_seq, "when", node->nd_body, popped));
+
+ CHECK(COMPILE_(body_seq, "when", RNODE_WHEN(node)->nd_body, popped));
ADD_INSNL(body_seq, node, jump, endlabel);
- vals = node->nd_head;
+ vals = RNODE_WHEN(node)->nd_head;
if (!vals) {
EXPECT_NODE_NONULL("NODE_WHEN", node, NODE_LIST, COMPILE_NG);
}
@@ -6274,12 +7248,12 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
case NODE_LIST:
while (vals) {
LABEL *lnext;
- val = vals->nd_head;
+ val = RNODE_LIST(vals)->nd_head;
lnext = NEW_LABEL(nd_line(val));
debug_compile("== when2\n", (void)0);
CHECK(compile_branch_condition(iseq, ret, val, l1, lnext));
ADD_LABEL(ret, lnext);
- vals = vals->nd_next;
+ vals = RNODE_LIST(vals)->nd_next;
}
break;
case NODE_SPLAT:
@@ -6293,13 +7267,15 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
default:
UNKNOWN_NODE("NODE_WHEN", vals, COMPILE_NG);
}
- node = node->nd_next;
+ node = RNODE_WHEN(node)->nd_next;
}
/* else */
+ const NODE *const coverage_node = node ? node : orig_node;
add_trace_branch_coverage(
iseq,
ret,
- node ? node : orig_node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
branch_id,
"else",
branches);
@@ -6385,14 +7361,13 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
* match_failed:
* goto unmatched
*/
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- const NODE *args = apinfo->pre_args;
- const int pre_args_num = apinfo->pre_args ? rb_long2int(apinfo->pre_args->nd_alen) : 0;
- const int post_args_num = apinfo->post_args ? rb_long2int(apinfo->post_args->nd_alen) : 0;
+ const NODE *args = RNODE_ARYPTN(node)->pre_args;
+ const int pre_args_num = RNODE_ARYPTN(node)->pre_args ? rb_long2int(RNODE_LIST(RNODE_ARYPTN(node)->pre_args)->as.nd_alen) : 0;
+ const int post_args_num = RNODE_ARYPTN(node)->post_args ? rb_long2int(RNODE_LIST(RNODE_ARYPTN(node)->post_args)->as.nd_alen) : 0;
const int min_argc = pre_args_num + post_args_num;
- const int use_rest_num = apinfo->rest_arg && (NODE_NAMED_REST_P(apinfo->rest_arg) ||
- (!NODE_NAMED_REST_P(apinfo->rest_arg) && post_args_num > 0));
+ const int use_rest_num = RNODE_ARYPTN(node)->rest_arg && (NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg) ||
+ (!NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg) && post_args_num > 0));
LABEL *match_failed, *type_error, *deconstruct, *deconstructed;
int i;
@@ -6416,10 +7391,10 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, dup);
ADD_SEND(ret, line_node, idLength, INT2FIX(0));
ADD_INSN1(ret, line_node, putobject, INT2FIX(min_argc));
- ADD_SEND(ret, line_node, apinfo->rest_arg ? idGE : idEq, INT2FIX(1)); // (1)
+ ADD_SEND(ret, line_node, RNODE_ARYPTN(node)->rest_arg ? idGE : idEq, INT2FIX(1)); // (1)
if (in_single_pattern) {
CHECK(iseq_compile_pattern_set_length_errmsg(iseq, ret, node,
- apinfo->rest_arg ? rb_fstring_lit("%p length mismatch (given %p, expected %p+)") :
+ RNODE_ARYPTN(node)->rest_arg ? rb_fstring_lit("%p length mismatch (given %p, expected %p+)") :
rb_fstring_lit("%p length mismatch (given %p, expected %p)"),
INT2FIX(min_argc), base_index + 1 /* (1) */));
}
@@ -6429,12 +7404,12 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, INT2FIX(i));
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (2)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (2) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (2) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
- if (apinfo->rest_arg) {
- if (NODE_NAMED_REST_P(apinfo->rest_arg)) {
+ if (RNODE_ARYPTN(node)->rest_arg) {
+ if (NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg)) {
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, INT2FIX(pre_args_num));
ADD_INSN1(ret, line_node, topn, INT2FIX(1));
@@ -6444,7 +7419,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN1(ret, line_node, setn, INT2FIX(4));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (3)
- CHECK(iseq_compile_pattern_match(iseq, ret, apinfo->rest_arg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (3) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_ARYPTN(node)->rest_arg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (3) */, false));
}
else {
if (post_args_num > 0) {
@@ -6458,7 +7433,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
}
- args = apinfo->post_args;
+ args = RNODE_ARYPTN(node)->post_args;
for (i = 0; i < post_args_num; i++) {
ADD_INSN(ret, line_node, dup);
@@ -6467,8 +7442,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_SEND(ret, line_node, idPLUS, INT2FIX(1));
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (4)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (4) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (4) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
ADD_INSN(ret, line_node, pop);
@@ -6546,9 +7521,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
* match_failed:
* goto unmatched
*/
- struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
- const NODE *args = fpinfo->args;
- const int args_num = fpinfo->args ? rb_long2int(fpinfo->args->nd_alen) : 0;
+ const NODE *args = RNODE_FNDPTN(node)->args;
+ const int args_num = RNODE_FNDPTN(node)->args ? rb_long2int(RNODE_LIST(RNODE_FNDPTN(node)->args)->as.nd_alen) : 0;
LABEL *match_failed, *type_error, *deconstruct, *deconstructed;
match_failed = NEW_LABEL(line);
@@ -6601,25 +7575,25 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (5)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, next_loop, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (5) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, next_loop, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (5) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
- if (NODE_NAMED_REST_P(fpinfo->pre_rest_arg)) {
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->pre_rest_arg)) {
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_INSN1(ret, line_node, putobject, INT2FIX(0));
ADD_INSN1(ret, line_node, topn, INT2FIX(2));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (6)
- CHECK(iseq_compile_pattern_match(iseq, ret, fpinfo->pre_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (6) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_FNDPTN(node)->pre_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (6) */, false));
}
- if (NODE_NAMED_REST_P(fpinfo->post_rest_arg)) {
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->post_rest_arg)) {
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_INSN1(ret, line_node, topn, INT2FIX(1));
ADD_INSN1(ret, line_node, putobject, INT2FIX(args_num));
ADD_SEND(ret, line_node, idPLUS, INT2FIX(1));
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (7)
- CHECK(iseq_compile_pattern_match(iseq, ret, fpinfo->post_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3),(4), (7) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_FNDPTN(node)->post_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3),(4), (7) */, false));
}
ADD_INSNL(ret, line_node, jump, find_succeeded);
@@ -6733,12 +7707,12 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
match_failed = NEW_LABEL(line);
type_error = NEW_LABEL(line);
- if (node->nd_pkwargs && !node->nd_pkwrestarg) {
- const NODE *kw_args = node->nd_pkwargs->nd_head;
- keys = rb_ary_new_capa(kw_args ? kw_args->nd_alen/2 : 0);
+ if (RNODE_HSHPTN(node)->nd_pkwargs && !RNODE_HSHPTN(node)->nd_pkwrestarg) {
+ const NODE *kw_args = RNODE_HASH(RNODE_HSHPTN(node)->nd_pkwargs)->nd_head;
+ keys = rb_ary_new_capa(kw_args ? RNODE_LIST(kw_args)->as.nd_alen/2 : 0);
while (kw_args) {
- rb_ary_push(keys, kw_args->nd_head->nd_lit);
- kw_args = kw_args->nd_next->nd_next;
+ rb_ary_push(keys, get_symbol_value(iseq, RNODE_LIST(kw_args)->nd_head));
+ kw_args = RNODE_LIST(RNODE_LIST(kw_args)->nd_next)->nd_next;
}
}
@@ -6756,6 +7730,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, putnil);
}
else {
+ RB_OBJ_SET_FROZEN_SHAREABLE(keys);
ADD_INSN1(ret, line_node, duparray, keys);
RB_OBJ_WRITTEN(iseq, Qundef, rb_obj_hide(keys));
}
@@ -6765,28 +7740,23 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN1(ret, line_node, checktype, INT2FIX(T_HASH));
ADD_INSNL(ret, line_node, branchunless, type_error);
- if (node->nd_pkwrestarg) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg) {
ADD_SEND(ret, line_node, rb_intern("dup"), INT2FIX(0));
}
- if (node->nd_pkwargs) {
+ if (RNODE_HSHPTN(node)->nd_pkwargs) {
int i;
int keys_num;
const NODE *args;
- args = node->nd_pkwargs->nd_head;
+ args = RNODE_HASH(RNODE_HSHPTN(node)->nd_pkwargs)->nd_head;
if (args) {
DECL_ANCHOR(match_values);
INIT_ANCHOR(match_values);
- keys_num = rb_long2int(args->nd_alen) / 2;
+ keys_num = rb_long2int(RNODE_LIST(args)->as.nd_alen) / 2;
for (i = 0; i < keys_num; i++) {
- NODE *key_node = args->nd_head;
- NODE *value_node = args->nd_next->nd_head;
- VALUE key;
-
- if (!nd_type_p(key_node, NODE_LIT)) {
- UNKNOWN_NODE("NODE_IN", key_node, COMPILE_NG);
- }
- key = key_node->nd_lit;
+ NODE *key_node = RNODE_LIST(args)->nd_head;
+ NODE *value_node = RNODE_LIST(RNODE_LIST(args)->nd_next)->nd_head;
+ VALUE key = get_symbol_value(iseq, key_node);
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, key);
@@ -6798,7 +7768,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, dup);
ADD_INSNL(ret, line_node, branchif, match_succeeded);
- ADD_INSN1(ret, line_node, putobject, rb_str_freeze(rb_sprintf("key not found: %+"PRIsVALUE, key))); // (4)
+ VALUE str = rb_str_freeze(rb_sprintf("key not found: %+"PRIsVALUE, key));
+ ADD_INSN1(ret, line_node, putobject, RB_OBJ_SET_SHAREABLE(str)); // (4)
ADD_INSN1(ret, line_node, setn, INT2FIX(base_index + CASE3_BI_OFFSET_ERROR_STRING + 2 /* (3), (4) */));
ADD_INSN1(ret, line_node, putobject, Qtrue); // (5)
ADD_INSN1(ret, line_node, setn, INT2FIX(base_index + CASE3_BI_OFFSET_KEY_ERROR_P + 3 /* (3), (4), (5) */));
@@ -6815,9 +7786,9 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(match_values, line_node, dup);
ADD_INSN1(match_values, line_node, putobject, key);
- ADD_SEND(match_values, line_node, node->nd_pkwrestarg ? rb_intern("delete") : idAREF, INT2FIX(1)); // (8)
+ ADD_SEND(match_values, line_node, RNODE_HSHPTN(node)->nd_pkwrestarg ? rb_intern("delete") : idAREF, INT2FIX(1)); // (8)
CHECK(iseq_compile_pattern_match(iseq, match_values, value_node, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (8) */, false));
- args = args->nd_next->nd_next;
+ args = RNODE_LIST(RNODE_LIST(args)->nd_next)->nd_next;
}
ADD_SEQ(ret, match_values);
}
@@ -6831,8 +7802,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSNL(ret, line_node, branchunless, match_failed);
}
- if (node->nd_pkwrestarg) {
- if (node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
ADD_INSN(ret, line_node, dup);
ADD_SEND(ret, line_node, idEmptyP, INT2FIX(0)); // (10)
if (in_single_pattern) {
@@ -6842,7 +7813,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
else {
ADD_INSN(ret, line_node, dup); // (11)
- CHECK(iseq_compile_pattern_match(iseq, ret, node->nd_pkwrestarg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (11) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_HSHPTN(node)->nd_pkwrestarg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (11) */, false));
}
}
@@ -6862,7 +7833,15 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSNL(ret, line_node, jump, unmatched);
break;
}
- case NODE_LIT:
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_LINE:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ case NODE_FILE:
+ case NODE_ENCODING:
case NODE_STR:
case NODE_XSTR:
case NODE_DSTR:
@@ -6886,6 +7865,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
case NODE_COLON2:
case NODE_COLON3:
case NODE_BEGIN:
+ case NODE_BLOCK:
+ case NODE_ONCE:
CHECK(COMPILE(ret, "case in literal", node)); // (1)
if (in_single_pattern) {
ADD_INSN1(ret, line_node, dupn, INT2FIX(2));
@@ -6899,7 +7880,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
break;
case NODE_LASGN: {
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- ID id = node->nd_vid;
+ ID id = RNODE_LASGN(node)->nd_vid;
int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
if (in_alt_pattern) {
@@ -6917,7 +7898,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
case NODE_DASGN: {
int idx, lv, ls;
- ID id = node->nd_vid;
+ ID id = RNODE_DASGN(node)->nd_vid;
idx = get_dyna_var_idx(iseq, id, &lv, &ls);
@@ -6943,8 +7924,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
case NODE_UNLESS: {
LABEL *match_failed;
match_failed = unmatched;
- CHECK(iseq_compile_pattern_match(iseq, ret, node->nd_body, unmatched, in_single_pattern, in_alt_pattern, base_index, use_deconstructed_cache));
- CHECK(COMPILE(ret, "case in if", node->nd_cond));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_IF(node)->nd_body, unmatched, in_single_pattern, in_alt_pattern, base_index, use_deconstructed_cache));
+ CHECK(COMPILE(ret, "case in if", RNODE_IF(node)->nd_cond));
if (in_single_pattern) {
LABEL *match_succeeded;
match_succeeded = NEW_LABEL(line);
@@ -6981,15 +7962,15 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
LABEL *match_failed;
match_failed = NEW_LABEL(line);
- n = node->nd_head;
- if (! (nd_type_p(n, NODE_LIST) && n->nd_alen == 2)) {
+ n = RNODE_HASH(node)->nd_head;
+ if (! (nd_type_p(n, NODE_LIST) && RNODE_LIST(n)->as.nd_alen == 2)) {
COMPILE_ERROR(ERROR_ARGS "unexpected node");
return COMPILE_NG;
}
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(iseq_compile_pattern_match(iseq, ret, n->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (1) */, use_deconstructed_cache));
- CHECK(iseq_compile_pattern_each(iseq, ret, n->nd_next->nd_head, matched, match_failed, in_single_pattern, in_alt_pattern, base_index, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(n)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (1) */, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_LIST(RNODE_LIST(n)->nd_next)->nd_head, matched, match_failed, in_single_pattern, in_alt_pattern, base_index, false));
ADD_INSN(ret, line_node, putnil);
ADD_LABEL(ret, match_failed);
@@ -7003,13 +7984,13 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
fin = NEW_LABEL(line);
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(iseq_compile_pattern_each(iseq, ret, node->nd_1st, match_succeeded, fin, in_single_pattern, true, base_index + 1 /* (1) */, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_OR(node)->nd_1st, match_succeeded, fin, in_single_pattern, true, base_index + 1 /* (1) */, use_deconstructed_cache));
ADD_LABEL(ret, match_succeeded);
ADD_INSN(ret, line_node, pop);
ADD_INSNL(ret, line_node, jump, matched);
ADD_INSN(ret, line_node, putnil);
ADD_LABEL(ret, fin);
- CHECK(iseq_compile_pattern_each(iseq, ret, node->nd_2nd, matched, unmatched, in_single_pattern, true, base_index, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_OR(node)->nd_2nd, matched, unmatched, in_single_pattern, true, base_index, use_deconstructed_cache));
break;
}
default:
@@ -7032,9 +8013,9 @@ iseq_compile_pattern_constant(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
{
const NODE *line_node = node;
- if (node->nd_pconst) {
+ if (RNODE_ARYPTN(node)->nd_pconst) {
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(COMPILE(ret, "constant", node->nd_pconst)); // (2)
+ CHECK(COMPILE(ret, "constant", RNODE_ARYPTN(node)->nd_pconst)); // (2)
if (in_single_pattern) {
ADD_INSN1(ret, line_node, dupn, INT2FIX(2));
}
@@ -7235,14 +8216,14 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
INIT_ANCHOR(body_seq);
INIT_ANCHOR(cond_seq);
- branches = decl_branch_base(iseq, node, "case");
+ branches = decl_branch_base(iseq, PTR2NUM(node), nd_code_loc(node), "case");
- node = node->nd_body;
+ node = RNODE_CASE3(node)->nd_body;
EXPECT_NODE("NODE_CASE3", node, NODE_IN, COMPILE_NG);
type = nd_type(node);
line = nd_line(node);
line_node = node;
- single_pattern = !node->nd_next;
+ single_pattern = !RNODE_IN(node)->nd_next;
endlabel = NEW_LABEL(line);
elselabel = NEW_LABEL(line);
@@ -7256,7 +8237,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
}
ADD_INSN(head, line_node, putnil); /* allocate stack for cached #deconstruct value */
- CHECK(COMPILE(head, "case base", orig_node->nd_head));
+ CHECK(COMPILE(head, "case base", RNODE_CASE3(orig_node)->nd_head));
ADD_SEQ(ret, head); /* case VAL */
@@ -7269,17 +8250,21 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
l1 = NEW_LABEL(line);
ADD_LABEL(body_seq, l1);
ADD_INSN1(body_seq, line_node, adjuststack, INT2FIX(single_pattern ? 6 : 2));
+
+ const NODE *const coverage_node = RNODE_IN(node)->nd_body ? RNODE_IN(node)->nd_body : node;
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
branch_id++,
"in",
branches);
- CHECK(COMPILE_(body_seq, "in body", node->nd_body, popped));
+
+ CHECK(COMPILE_(body_seq, "in body", RNODE_IN(node)->nd_body, popped));
ADD_INSNL(body_seq, line_node, jump, endlabel);
- pattern = node->nd_head;
+ pattern = RNODE_IN(node)->nd_head;
if (pattern) {
int pat_line = nd_line(pattern);
LABEL *next_pat = NEW_LABEL(pat_line);
@@ -7294,7 +8279,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
return COMPILE_NG;
}
- node = node->nd_next;
+ node = RNODE_IN(node)->nd_next;
if (!node) {
break;
}
@@ -7307,7 +8292,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
ADD_LABEL(cond_seq, elselabel);
ADD_INSN(cond_seq, line_node, pop);
ADD_INSN(cond_seq, line_node, pop); /* discard cached #deconstruct value */
- add_trace_branch_coverage(iseq, cond_seq, node, branch_id, "else", branches);
+ add_trace_branch_coverage(iseq, cond_seq, nd_code_loc(node), nd_node_id(node), branch_id, "else", branches);
CHECK(COMPILE_(cond_seq, "else", node, popped));
ADD_INSNL(cond_seq, line_node, jump, endlabel);
ADD_INSN(cond_seq, line_node, putnil);
@@ -7318,7 +8303,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
else {
debugs("== else (implicit)\n");
ADD_LABEL(cond_seq, elselabel);
- add_trace_branch_coverage(iseq, cond_seq, orig_node, branch_id, "else", branches);
+ add_trace_branch_coverage(iseq, cond_seq, nd_code_loc(orig_node), nd_node_id(orig_node), branch_id, "else", branches);
ADD_INSN1(cond_seq, orig_node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
if (single_pattern) {
@@ -7336,6 +8321,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
fin = NEW_LABEL(line);
kw_arg = rb_xmalloc_mul_add(2, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ kw_arg->references = 0;
kw_arg->keyword_len = 2;
kw_arg->keywords[0] = ID2SYM(rb_intern("matchee"));
kw_arg->keywords[1] = ID2SYM(rb_intern("key"));
@@ -7419,7 +8405,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ISEQ_COMPILE_DATA(iseq)->loopval_popped = 0;
push_ensure_entry(iseq, &enl, NULL, NULL);
- if (node->nd_state == 1) {
+ if (RNODE_WHILE(node)->nd_state == 1) {
ADD_INSNL(ret, line_node, jump, next_label);
}
else {
@@ -7434,31 +8420,35 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
if (tmp_label) ADD_LABEL(ret, tmp_label);
ADD_LABEL(ret, redo_label);
- branches = decl_branch_base(iseq, node, type == NODE_WHILE ? "while" : "until");
+ branches = decl_branch_base(iseq, PTR2NUM(node), nd_code_loc(node), type == NODE_WHILE ? "while" : "until");
+
+ const NODE *const coverage_node = RNODE_WHILE(node)->nd_body ? RNODE_WHILE(node)->nd_body : node;
add_trace_branch_coverage(
iseq,
ret,
- node->nd_body ? node->nd_body : node,
+ nd_code_loc(coverage_node),
+ nd_node_id(coverage_node),
0,
"body",
branches);
- CHECK(COMPILE_POPPED(ret, "while body", node->nd_body));
+
+ CHECK(COMPILE_POPPED(ret, "while body", RNODE_WHILE(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);
+ CHECK(compile_branch_condition(iseq, ret, RNODE_WHILE(node)->nd_cond,
+ redo_label, end_label));
}
else {
/* until */
- compile_branch_condition(iseq, ret, node->nd_cond,
- end_label, redo_label);
+ CHECK(compile_branch_condition(iseq, ret, RNODE_WHILE(node)->nd_cond,
+ end_label, redo_label));
}
ADD_LABEL(ret, end_label);
ADD_ADJUST_RESTORE(ret, adjust_label);
- if (UNDEF_P(node->nd_state)) {
+ if (UNDEF_P(RNODE_WHILE(node)->nd_state)) {
/* ADD_INSN(ret, line_node, putundef); */
COMPILE_ERROR(ERROR_ARGS "unsupported: putundef");
return COMPILE_NG;
@@ -7500,18 +8490,18 @@ compile_iter(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ADD_LABEL(ret, retry_label);
if (nd_type_p(node, NODE_FOR)) {
- CHECK(COMPILE(ret, "iter caller (for)", node->nd_iter));
+ CHECK(COMPILE(ret, "iter caller (for)", RNODE_FOR(node)->nd_iter));
ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq =
- NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq),
+ NEW_CHILD_ISEQ(RNODE_FOR(node)->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK, line);
ADD_SEND_WITH_BLOCK(ret, line_node, idEach, INT2FIX(0), child_iseq);
}
else {
ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq =
- NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq),
+ NEW_CHILD_ISEQ(RNODE_ITER(node)->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK, line);
- CHECK(COMPILE(ret, "iter caller", node->nd_iter));
+ CHECK(COMPILE(ret, "iter caller", RNODE_ITER(node)->nd_iter));
}
{
@@ -7522,11 +8512,11 @@ compile_iter(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
// Normally, "send" instruction is at the last.
// However, qcall under branch coverage measurement adds some instructions after the "send".
//
- // Note that "invokesuper" appears instead of "send".
+ // Note that "invokesuper", "invokesuperforward" appears instead of "send".
INSN *iobj;
LINK_ELEMENT *last_elem = LAST_ELEMENT(ret);
iobj = IS_INSN(last_elem) ? (INSN*) last_elem : (INSN*) get_prev_insn((INSN*) last_elem);
- while (INSN_OF(iobj) != BIN(send) && INSN_OF(iobj) != BIN(invokesuper)) {
+ while (!IS_INSN_ID(iobj, send) && !IS_INSN_ID(iobj, invokesuper) && !IS_INSN_ID(iobj, sendforward) && !IS_INSN_ID(iobj, invokesuperforward)) {
iobj = (INSN*) get_prev_insn(iobj);
}
ELEM_INSERT_NEXT(&iobj->link, (LINK_ELEMENT*) retry_end_l);
@@ -7555,7 +8545,7 @@ compile_for_masgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
* (args.length == 1 && Array.try_convert(args[0])) || args
*/
const NODE *line_node = node;
- const NODE *var = node->nd_var;
+ const NODE *var = RNODE_FOR_MASGN(node)->nd_var;
LABEL *not_single = NEW_LABEL(nd_line(var));
LABEL *not_ary = NEW_LABEL(nd_line(var));
CHECK(COMPILE(ret, "for var", var));
@@ -7590,7 +8580,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
LABEL *splabel = NEW_LABEL(0);
ADD_LABEL(ret, splabel);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->redo_label);
- CHECK(COMPILE_(ret, "break val (while/until)", node->nd_stts,
+ CHECK(COMPILE_(ret, "break val (while/until)", RNODE_BREAK(node)->nd_stts,
ISEQ_COMPILE_DATA(iseq)->loopval_popped));
add_ensure_iseq(ret, iseq, 0);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
@@ -7625,7 +8615,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
}
/* escape from block */
- CHECK(COMPILE(ret, "break val (block)", node->nd_stts));
+ CHECK(COMPILE(ret, "break val (block)", RNODE_BREAK(node)->nd_stts));
ADD_INSN1(ret, line_node, throw, INT2FIX(throw_flag | TAG_BREAK));
if (popped) {
ADD_INSN(ret, line_node, pop);
@@ -7648,7 +8638,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
LABEL *splabel = NEW_LABEL(0);
debugs("next in while loop\n");
ADD_LABEL(ret, splabel);
- CHECK(COMPILE(ret, "next val/valid syntax?", node->nd_stts));
+ CHECK(COMPILE(ret, "next val/valid syntax?", RNODE_NEXT(node)->nd_stts));
add_ensure_iseq(ret, iseq, 0);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->redo_label);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->start_label);
@@ -7662,11 +8652,10 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
debugs("next in block\n");
ADD_LABEL(ret, splabel);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->start_label);
- CHECK(COMPILE(ret, "next val", node->nd_stts));
+ CHECK(COMPILE(ret, "next val", RNODE_NEXT(node)->nd_stts));
add_ensure_iseq(ret, iseq, 0);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
ADD_ADJUST_RESTORE(ret, splabel);
- splabel->unremovable = FALSE;
if (!popped) {
ADD_INSN(ret, line_node, putnil);
@@ -7697,7 +8686,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ip = ISEQ_BODY(ip)->parent_iseq;
}
if (ip != 0) {
- CHECK(COMPILE(ret, "next val", node->nd_stts));
+ CHECK(COMPILE(ret, "next val", RNODE_NEXT(node)->nd_stts));
ADD_INSN1(ret, line_node, throw, INT2FIX(throw_flag | TAG_NEXT));
if (popped) {
@@ -7809,7 +8798,7 @@ compile_rescue(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
LABEL *lstart = NEW_LABEL(line);
LABEL *lend = NEW_LABEL(line);
LABEL *lcont = NEW_LABEL(line);
- const rb_iseq_t *rescue = NEW_CHILD_ISEQ(node->nd_resq,
+ const rb_iseq_t *rescue = NEW_CHILD_ISEQ(RNODE_RESCUE(node)->nd_resq,
rb_str_concat(rb_str_new2("rescue in "),
ISEQ_BODY(iseq)->location.label),
ISEQ_TYPE_RESCUE, line);
@@ -7821,14 +8810,14 @@ compile_rescue(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
bool prev_in_rescue = ISEQ_COMPILE_DATA(iseq)->in_rescue;
ISEQ_COMPILE_DATA(iseq)->in_rescue = true;
{
- CHECK(COMPILE(ret, "rescue head", node->nd_head));
+ CHECK(COMPILE(ret, "rescue head", RNODE_RESCUE(node)->nd_head));
}
ISEQ_COMPILE_DATA(iseq)->in_rescue = prev_in_rescue;
ADD_LABEL(ret, lend);
- if (node->nd_else) {
+ if (RNODE_RESCUE(node)->nd_else) {
ADD_INSN(ret, line_node, pop);
- CHECK(COMPILE(ret, "rescue else", node->nd_else));
+ CHECK(COMPILE(ret, "rescue else", RNODE_RESCUE(node)->nd_else));
}
ADD_INSN(ret, line_node, nop);
ADD_LABEL(ret, lcont);
@@ -7856,16 +8845,16 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
label_miss = NEW_LABEL(line);
label_hit = NEW_LABEL(line);
- narg = resq->nd_args;
+ narg = RNODE_RESBODY(resq)->nd_args;
if (narg) {
switch (nd_type(narg)) {
case NODE_LIST:
while (narg) {
ADD_GETLOCAL(ret, line_node, LVAR_ERRINFO, 0);
- CHECK(COMPILE(ret, "rescue arg", narg->nd_head));
+ CHECK(COMPILE(ret, "rescue arg", RNODE_LIST(narg)->nd_head));
ADD_INSN1(ret, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
ADD_INSNL(ret, line_node, branchif, label_hit);
- narg = narg->nd_next;
+ narg = RNODE_LIST(narg)->nd_next;
}
break;
case NODE_SPLAT:
@@ -7888,13 +8877,26 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
}
ADD_INSNL(ret, line_node, jump, label_miss);
ADD_LABEL(ret, label_hit);
- CHECK(COMPILE(ret, "resbody body", resq->nd_body));
+ ADD_TRACE(ret, RUBY_EVENT_RESCUE);
+
+ if (RNODE_RESBODY(resq)->nd_exc_var) {
+ CHECK(COMPILE_POPPED(ret, "resbody exc_var", RNODE_RESBODY(resq)->nd_exc_var));
+ }
+
+ if (nd_type(RNODE_RESBODY(resq)->nd_body) == NODE_BEGIN && RNODE_BEGIN(RNODE_RESBODY(resq)->nd_body)->nd_body == NULL && !RNODE_RESBODY(resq)->nd_exc_var) {
+ // empty body
+ ADD_SYNTHETIC_INSN(ret, nd_line(RNODE_RESBODY(resq)->nd_body), -1, putnil);
+ }
+ else {
+ CHECK(COMPILE(ret, "resbody body", RNODE_RESBODY(resq)->nd_body));
+ }
+
if (ISEQ_COMPILE_DATA(iseq)->option->tailcall_optimization) {
ADD_INSN(ret, line_node, nop);
}
ADD_INSN(ret, line_node, leave);
ADD_LABEL(ret, label_miss);
- resq = resq->nd_head;
+ resq = RNODE_RESBODY(resq)->nd_next;
}
return COMPILE_OK;
}
@@ -7902,10 +8904,10 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- const int line = nd_line(node);
+ const int line = nd_line(RNODE_ENSURE(node)->nd_ensr);
const NODE *line_node = node;
DECL_ANCHOR(ensr);
- const rb_iseq_t *ensure = NEW_CHILD_ISEQ(node->nd_ensr,
+ const rb_iseq_t *ensure = NEW_CHILD_ISEQ(RNODE_ENSURE(node)->nd_ensr,
rb_str_concat(rb_str_new2 ("ensure in "), ISEQ_BODY(iseq)->location.label),
ISEQ_TYPE_ENSURE, line);
LABEL *lstart = NEW_LABEL(line);
@@ -7918,17 +8920,17 @@ compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
struct ensure_range *erange;
INIT_ANCHOR(ensr);
- CHECK(COMPILE_POPPED(ensr, "ensure ensr", node->nd_ensr));
+ CHECK(COMPILE_POPPED(ensr, "ensure ensr", RNODE_ENSURE(node)->nd_ensr));
last = ensr->last;
last_leave = last && IS_INSN(last) && IS_INSN_ID(last, leave);
er.begin = lstart;
er.end = lend;
er.next = 0;
- push_ensure_entry(iseq, &enl, &er, node->nd_ensr);
+ push_ensure_entry(iseq, &enl, &er, RNODE_ENSURE(node)->nd_ensr);
ADD_LABEL(ret, lstart);
- CHECK(COMPILE_(ret, "ensure head", node->nd_head, (popped | last_leave)));
+ CHECK(COMPILE_(ret, "ensure head", RNODE_ENSURE(node)->nd_head, (popped | last_leave)));
ADD_LABEL(ret, lend);
ADD_SEQ(ret, ensr);
if (!popped && last_leave) ADD_INSN(ret, line_node, putnil);
@@ -7957,7 +8959,7 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
enum rb_iseq_type type = ISEQ_BODY(iseq)->type;
const rb_iseq_t *is = iseq;
enum rb_iseq_type t = type;
- const NODE *retval = node->nd_stts;
+ const NODE *retval = RNODE_RETURN(node)->nd_stts;
LABEL *splabel = 0;
while (t == ISEQ_TYPE_RESCUE || t == ISEQ_TYPE_ENSURE) {
@@ -8007,6 +9009,27 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
return COMPILE_OK;
}
+static bool
+drop_unreachable_return(LINK_ANCHOR *ret)
+{
+ LINK_ELEMENT *i = ret->last, *last;
+ if (!i) return false;
+ if (IS_TRACE(i)) i = i->prev;
+ if (!IS_INSN(i) || !IS_INSN_ID(i, putnil)) return false;
+ last = i = i->prev;
+ if (IS_ADJUST(i)) i = i->prev;
+ if (!IS_INSN(i)) return false;
+ switch (INSN_OF(i)) {
+ case BIN(leave):
+ case BIN(jump):
+ break;
+ default:
+ return false;
+ }
+ (ret->last = last->prev)->next = NULL;
+ return true;
+}
+
static int
compile_evstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
@@ -8040,11 +9063,11 @@ qcall_branch_start(rb_iseq_t *iseq, LINK_ANCHOR *const recv, VALUE *branches, co
LABEL *else_label = NEW_LABEL(nd_line(line_node));
VALUE br = 0;
- br = decl_branch_base(iseq, node, "&.");
+ br = decl_branch_base(iseq, PTR2NUM(node), nd_code_loc(node), "&.");
*branches = br;
ADD_INSN(recv, line_node, dup);
ADD_INSNL(recv, line_node, branchnil, else_label);
- add_trace_branch_coverage(iseq, recv, node, 0, "then", br);
+ add_trace_branch_coverage(iseq, recv, nd_code_loc(node), nd_node_id(node), 0, "then", br);
return else_label;
}
@@ -8056,7 +9079,7 @@ qcall_branch_end(rb_iseq_t *iseq, LINK_ANCHOR *const ret, LABEL *else_label, VAL
end_label = NEW_LABEL(nd_line(line_node));
ADD_INSNL(ret, line_node, jump, end_label);
ADD_LABEL(ret, else_label);
- add_trace_branch_coverage(iseq, ret, node, 1, "else", branches);
+ add_trace_branch_coverage(iseq, ret, nd_code_loc(node), nd_node_id(node), 1, "else", branches);
ADD_LABEL(ret, end_label);
}
@@ -8066,13 +9089,14 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
/* optimization shortcut
* "literal".freeze -> opt_str_freeze("literal")
*/
- if (node->nd_recv && nd_type_p(node->nd_recv, NODE_STR) &&
- (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
- node->nd_args == NULL &&
+ if (get_nd_recv(node) &&
+ (nd_type_p(get_nd_recv(node), NODE_STR) || nd_type_p(get_nd_recv(node), NODE_FILE)) &&
+ (get_node_call_nd_mid(node) == idFreeze || get_node_call_nd_mid(node) == idUMinus) &&
+ get_nd_args(node) == NULL &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_recv->nd_lit);
- if (node->nd_mid == idUMinus) {
+ VALUE str = get_string_value(get_nd_recv(node));
+ if (get_node_call_nd_mid(node) == idUMinus) {
ADD_INSN2(ret, line_node, opt_str_uminus, str,
new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE));
}
@@ -8086,25 +9110,6 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
}
return TRUE;
}
- /* optimization shortcut
- * obj["literal"] -> opt_aref_with(obj, "literal")
- */
- if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
- nd_type_p(node->nd_args, NODE_LIST) && node->nd_args->nd_alen == 1 &&
- nd_type_p(node->nd_args->nd_head, NODE_STR) &&
- ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
- !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
- ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
- CHECK(COMPILE(ret, "recv", node->nd_recv));
- ADD_INSN2(ret, line_node, opt_aref_with, str,
- new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE));
- RB_OBJ_WRITTEN(iseq, Qundef, str);
- if (popped) {
- ADD_INSN(ret, line_node, pop);
- }
- return TRUE;
- }
return FALSE;
}
@@ -8139,12 +9144,12 @@ iseq_builtin_function_name(const enum node_type type, const NODE *recv, ID mid)
if (recv) {
switch (nd_type(recv)) {
case NODE_VCALL:
- if (recv->nd_mid == rb_intern("__builtin")) {
+ if (RNODE_VCALL(recv)->nd_mid == rb_intern("__builtin")) {
return name;
}
break;
case NODE_CONST:
- if (recv->nd_vid == rb_intern("Primitive")) {
+ if (RNODE_CONST(recv)->nd_vid == rb_intern("Primitive")) {
return name;
}
break;
@@ -8234,21 +9239,36 @@ compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
if (!node) goto no_arg;
while (node) {
if (!nd_type_p(node, NODE_LIST)) goto bad_arg;
- const NODE *next = node->nd_next;
+ const NODE *next = RNODE_LIST(node)->nd_next;
- node = node->nd_head;
+ node = RNODE_LIST(node)->nd_head;
if (!node) goto no_arg;
- if (!nd_type_p(node, NODE_LIT)) goto bad_arg;
+ switch (nd_type(node)) {
+ case NODE_SYM:
+ symbol = rb_node_sym_string_val(node);
+ break;
+ default:
+ goto bad_arg;
+ }
- symbol = node->nd_lit;
if (!SYMBOL_P(symbol)) goto non_symbol_arg;
- string = rb_sym_to_s(symbol);
+ string = rb_sym2str(symbol);
if (strcmp(RSTRING_PTR(string), "leaf") == 0) {
ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_LEAF;
}
- else if (strcmp(RSTRING_PTR(string), "no_gc") == 0) {
- ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_NO_GC;
+ else if (strcmp(RSTRING_PTR(string), "inline_block") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_INLINE_BLOCK;
+ }
+ else if (strcmp(RSTRING_PTR(string), "use_block") == 0) {
+ iseq_set_use_block(iseq);
+ }
+ else if (strcmp(RSTRING_PTR(string), "c_trace") == 0) {
+ // Let the iseq act like a C method in backtraces
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_C_TRACE;
+ }
+ else if (strcmp(RSTRING_PTR(string), "without_interrupts") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_WITHOUT_INTERRUPTS;
}
else {
goto unknown_arg;
@@ -8272,13 +9292,20 @@ compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
static int
compile_builtin_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, const NODE *line_node, int popped)
{
+ VALUE name;
+
if (!node) goto no_arg;
if (!nd_type_p(node, NODE_LIST)) goto bad_arg;
- if (node->nd_next) goto too_many_arg;
- node = node->nd_head;
+ if (RNODE_LIST(node)->nd_next) goto too_many_arg;
+ node = RNODE_LIST(node)->nd_head;
if (!node) goto no_arg;
- if (!nd_type_p(node, NODE_LIT)) goto bad_arg;
- VALUE name = node->nd_lit;
+ switch (nd_type(node)) {
+ case NODE_SYM:
+ name = rb_node_sym_string_val(node);
+ break;
+ default:
+ goto bad_arg;
+ }
if (!SYMBOL_P(name)) goto non_symbol_arg;
if (!popped) {
compile_lvar(iseq, ret, line_node, SYM2ID(name));
@@ -8302,8 +9329,8 @@ static NODE *
mandatory_node(const rb_iseq_t *iseq, const NODE *cond_node)
{
const NODE *node = ISEQ_COMPILE_DATA(iseq)->root_node;
- if (nd_type(node) == NODE_IF && node->nd_cond == cond_node) {
- return node->nd_body;
+ if (nd_type(node) == NODE_IF && RNODE_IF(node)->nd_cond == cond_node) {
+ return RNODE_IF(node)->nd_body;
}
else {
rb_bug("mandatory_node: can't find mandatory node");
@@ -8317,8 +9344,9 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
struct rb_args_info args = {
.pre_args_num = ISEQ_BODY(iseq)->param.lead_num,
};
- NODE args_node;
- rb_node_init(&args_node, NODE_ARGS, 0, 0, (VALUE)&args);
+ rb_node_args_t args_node;
+ rb_node_init(RNODE(&args_node), NODE_ARGS);
+ args_node.nd_ainfo = args;
// local table without non-mandatory parameters
const int skip_local_size = ISEQ_BODY(iseq)->param.size - ISEQ_BODY(iseq)->param.lead_num;
@@ -8339,24 +9367,23 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
tbl->ids[i] = ISEQ_BODY(iseq)->local_table[i + skip_local_size];
}
- NODE scope_node;
- rb_node_init(&scope_node, NODE_SCOPE, (VALUE)tbl, (VALUE)mandatory_node(iseq, node), (VALUE)&args_node);
-
- rb_ast_body_t ast = {
- .root = &scope_node,
- .compile_option = 0,
- .script_lines = ISEQ_BODY(iseq)->variable.script_lines,
- };
+ rb_node_scope_t scope_node;
+ rb_node_init(RNODE(&scope_node), NODE_SCOPE);
+ scope_node.nd_tbl = tbl;
+ scope_node.nd_body = mandatory_node(iseq, node);
+ scope_node.nd_parent = NULL;
+ scope_node.nd_args = &args_node;
- int prev_inline_index = GET_VM()->builtin_inline_index;
+ VALUE ast_value = rb_ruby_ast_new(RNODE(&scope_node));
- ISEQ_BODY(iseq)->mandatory_only_iseq =
- rb_iseq_new_with_opt(&ast, rb_iseq_base_label(iseq),
+ const rb_iseq_t *mandatory_only_iseq =
+ rb_iseq_new_with_opt(ast_value, rb_iseq_base_label(iseq),
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
nd_line(line_node), NULL, 0,
- ISEQ_TYPE_METHOD, ISEQ_COMPILE_DATA(iseq)->option);
+ ISEQ_TYPE_METHOD, ISEQ_COMPILE_DATA(iseq)->option,
+ ISEQ_BODY(iseq)->variable.script_lines);
+ RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->mandatory_only_iseq, (VALUE)mandatory_only_iseq);
- GET_VM()->builtin_inline_index = prev_inline_index;
ALLOCV_END(idtmp);
return COMPILE_OK;
}
@@ -8365,7 +9392,7 @@ static int
compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, const NODE *line_node, int popped,
const rb_iseq_t *parent_block, LINK_ANCHOR *args, const char *builtin_func)
{
- NODE *args_node = node->nd_args;
+ NODE *args_node = get_nd_args(node);
if (parent_block != NULL) {
COMPILE_ERROR(ERROR_ARGS_AT(line_node) "should not call builtins here.");
@@ -8388,7 +9415,6 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
}
else if (strcmp("cinit!", builtin_func) == 0) {
// ignore
- GET_VM()->builtin_inline_index++;
return COMPILE_OK;
}
else if (strcmp("attr!", builtin_func) == 0) {
@@ -8416,10 +9442,7 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
return COMPILE_NG;
}
- if (GET_VM()->builtin_inline_index == INT_MAX) {
- rb_bug("builtin inline function index overflow:%s", builtin_func);
- }
- int inline_index = GET_VM()->builtin_inline_index++;
+ int inline_index = nd_line(node);
snprintf(inline_func, sizeof(inline_func), BUILTIN_INLINE_PREFIX "%d", inline_index);
builtin_func = inline_func;
args_node = NULL;
@@ -8428,7 +9451,7 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
if (cconst) {
typedef VALUE(*builtin_func0)(void *, VALUE);
- VALUE const_val = (*(builtin_func0)bf->func_ptr)(NULL, Qnil);
+ VALUE const_val = (*(builtin_func0)(uintptr_t)bf->func_ptr)(NULL, Qnil);
ADD_INSN1(ret, line_node, putobject, const_val);
return COMPILE_OK;
}
@@ -8468,7 +9491,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
*/
DECL_ANCHOR(recv);
DECL_ANCHOR(args);
- ID mid = node->nd_mid;
+ ID mid = get_node_call_nd_mid(node);
VALUE argc;
unsigned int flag = 0;
struct rb_callinfo_kwarg *keywords = NULL;
@@ -8480,6 +9503,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
INIT_ANCHOR(recv);
INIT_ANCHOR(args);
+
#if OPT_SUPPORT_JOKE
if (nd_type_p(node, NODE_VCALL)) {
ID id_bitblt;
@@ -8516,20 +9540,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
labels_table = st_init_numtable();
ISEQ_COMPILE_DATA(iseq)->labels_table = labels_table;
}
- if (nd_type_p(node->nd_args->nd_head, NODE_LIT) &&
- SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
-
- label_name = node->nd_args->nd_head->nd_lit;
- if (!st_lookup(labels_table, (st_data_t)label_name, &data)) {
- label = NEW_LABEL(nd_line(line_node));
- label->position = nd_line(line_node);
- st_insert(labels_table, (st_data_t)label_name, (st_data_t)label);
- }
- else {
- label = (LABEL *)data;
- }
- }
- else {
+ {
COMPILE_ERROR(ERROR_ARGS "invalid goto/label format");
return COMPILE_NG;
}
@@ -8547,7 +9558,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
const char *builtin_func;
if (UNLIKELY(iseq_has_builtin_function_table(iseq)) &&
- (builtin_func = iseq_builtin_function_name(type, node->nd_recv, mid)) != NULL) {
+ (builtin_func = iseq_builtin_function_name(type, get_nd_recv(node), mid)) != NULL) {
return compile_builtin_function_call(iseq, ret, node, line_node, popped, parent_block, args, builtin_func);
}
@@ -8557,16 +9568,16 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
int idx, level;
if (mid == idCall &&
- nd_type_p(node->nd_recv, NODE_LVAR) &&
- iseq_block_param_id_p(iseq, node->nd_recv->nd_vid, &idx, &level)) {
- ADD_INSN2(recv, node->nd_recv, getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
+ nd_type_p(get_nd_recv(node), NODE_LVAR) &&
+ iseq_block_param_id_p(iseq, RNODE_LVAR(get_nd_recv(node))->nd_vid, &idx, &level)) {
+ ADD_INSN2(recv, get_nd_recv(node), getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
}
else if (private_recv_p(node)) {
ADD_INSN(recv, node, putself);
flag |= VM_CALL_FCALL;
}
else {
- CHECK(COMPILE(recv, "recv", node->nd_recv));
+ CHECK(COMPILE(recv, "recv", get_nd_recv(node)));
}
if (type == NODE_QCALL) {
@@ -8580,7 +9591,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
/* args */
if (type != NODE_VCALL) {
- argc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
+ argc = setup_args(iseq, args, get_nd_args(node), &flag, &keywords);
CHECK(!NIL_P(argc));
}
else {
@@ -8588,6 +9599,17 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
}
ADD_SEQ(ret, recv);
+
+ bool inline_new = ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction &&
+ mid == rb_intern("new") &&
+ parent_block == NULL &&
+ !(flag & VM_CALL_ARGS_BLOCKARG);
+
+ if (inline_new) {
+ ADD_INSN(ret, node, putnil);
+ ADD_INSN(ret, node, swap);
+ }
+
ADD_SEQ(ret, args);
debugp_param("call args argc", argc);
@@ -8601,7 +9623,40 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
flag |= VM_CALL_FCALL;
}
- ADD_SEND_R(ret, line_node, mid, argc, parent_block, INT2FIX(flag), keywords);
+ if ((flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT) && !(flag & VM_CALL_KW_SPLAT_MUT)) {
+ ADD_INSN(ret, line_node, splatkw);
+ }
+
+ LABEL *not_basic_new = NEW_LABEL(nd_line(node));
+ LABEL *not_basic_new_finish = NEW_LABEL(nd_line(node));
+
+ if (inline_new) {
+ // Jump unless the receiver uses the "basic" implementation of "new"
+ VALUE ci;
+ if (flag & VM_CALL_FORWARDING) {
+ ci = (VALUE)new_callinfo(iseq, mid, NUM2INT(argc) + 1, flag, keywords, 0);
+ }
+ else {
+ ci = (VALUE)new_callinfo(iseq, mid, NUM2INT(argc), flag, keywords, 0);
+ }
+ ADD_INSN2(ret, node, opt_new, ci, not_basic_new);
+ LABEL_REF(not_basic_new);
+
+ // optimized path
+ ADD_SEND_R(ret, line_node, rb_intern("initialize"), argc, parent_block, INT2FIX(flag | VM_CALL_FCALL), keywords);
+ ADD_INSNL(ret, line_node, jump, not_basic_new_finish);
+
+ ADD_LABEL(ret, not_basic_new);
+ // Fall back to normal send
+ ADD_SEND_R(ret, line_node, mid, argc, parent_block, INT2FIX(flag), keywords);
+ ADD_INSN(ret, line_node, swap);
+
+ ADD_LABEL(ret, not_basic_new_finish);
+ ADD_INSN(ret, line_node, pop);
+ }
+ else {
+ ADD_SEND_R(ret, line_node, mid, argc, parent_block, INT2FIX(flag), keywords);
+ }
qcall_branch_end(iseq, ret, else_label, branches, node, line_node);
if (popped) {
@@ -8617,8 +9672,7 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
VALUE argc;
unsigned int flag = 0;
int asgnflag = 0;
- ID id = node->nd_mid;
- int boff = 0;
+ ID id = RNODE_OP_ASGN1(node)->nd_mid;
/*
* a[x] (op)= y
@@ -8646,22 +9700,20 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
if (!popped) {
ADD_INSN(ret, node, putnil);
}
- asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node);
+ asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node, RNODE_OP_ASGN1(node)->nd_recv);
CHECK(asgnflag != -1);
- switch (nd_type(node->nd_args->nd_head)) {
+ switch (nd_type(RNODE_OP_ASGN1(node)->nd_index)) {
case NODE_ZLIST:
argc = INT2FIX(0);
break;
- case NODE_BLOCK_PASS:
- boff = 1;
- /* fall through */
default:
- argc = setup_args(iseq, ret, node->nd_args->nd_head, &flag, NULL);
+ argc = setup_args(iseq, ret, RNODE_OP_ASGN1(node)->nd_index, &flag, NULL);
CHECK(!NIL_P(argc));
}
- ADD_INSN1(ret, node, dupn, FIXNUM_INC(argc, 1 + boff));
+ int dup_argn = FIX2INT(argc) + 1;
+ ADD_INSN1(ret, node, dupn, INT2FIX(dup_argn));
flag |= asgnflag;
- ADD_SEND_WITH_FLAG(ret, node, idAREF, argc, INT2FIX(flag));
+ ADD_SEND_R(ret, node, idAREF, argc, NULL, INT2FIX(flag & ~VM_CALL_ARGS_SPLAT_MUT), NULL);
if (id == idOROP || id == idANDOP) {
/* a[x] ||= y or a[x] &&= y
@@ -8684,64 +9736,63 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
}
ADD_INSN(ret, node, pop);
- CHECK(COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN1 nd_rvalue: ", RNODE_OP_ASGN1(node)->nd_rvalue));
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
if (flag & VM_CALL_ARGS_SPLAT) {
- ADD_INSN1(ret, node, newarray, INT2FIX(1));
- if (boff > 0) {
- ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
ADD_INSN(ret, node, swap);
- ADD_INSN(ret, node, pop);
- }
- ADD_INSN(ret, node, concatarray);
- if (boff > 0) {
- ADD_INSN1(ret, node, setn, INT2FIX(3));
- ADD_INSN(ret, node, pop);
- ADD_INSN(ret, node, pop);
+ ADD_INSN1(ret, node, splatarray, Qtrue);
+ ADD_INSN(ret, node, swap);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
}
- ADD_SEND_WITH_FLAG(ret, node, idASET, argc, INT2FIX(flag));
+ ADD_INSN1(ret, node, pushtoarray, INT2FIX(1));
+ ADD_SEND_R(ret, node, idASET, argc, NULL, INT2FIX(flag), NULL);
}
else {
- if (boff > 0)
- ADD_INSN(ret, node, swap);
- ADD_SEND_WITH_FLAG(ret, node, idASET, FIXNUM_INC(argc, 1), INT2FIX(flag));
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), NULL);
}
ADD_INSN(ret, node, pop);
ADD_INSNL(ret, node, jump, lfin);
ADD_LABEL(ret, label);
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
- ADD_INSN1(ret, node, adjuststack, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, adjuststack, INT2FIX(dup_argn+1));
ADD_LABEL(ret, lfin);
}
else {
- CHECK(COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN1 nd_rvalue: ", RNODE_OP_ASGN1(node)->nd_rvalue));
ADD_SEND(ret, node, id, INT2FIX(1));
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
if (flag & VM_CALL_ARGS_SPLAT) {
- ADD_INSN1(ret, node, newarray, INT2FIX(1));
- if (boff > 0) {
- ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ if (flag & VM_CALL_KW_SPLAT) {
+ ADD_INSN1(ret, node, topn, INT2FIX(2));
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ ADD_INSN1(ret, node, splatarray, Qtrue);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
ADD_INSN(ret, node, swap);
+ ADD_INSN1(ret, node, pushtoarray, INT2FIX(1));
+ ADD_INSN1(ret, node, setn, INT2FIX(2));
ADD_INSN(ret, node, pop);
}
- ADD_INSN(ret, node, concatarray);
- if (boff > 0) {
- ADD_INSN1(ret, node, setn, INT2FIX(3));
- ADD_INSN(ret, node, pop);
- ADD_INSN(ret, node, pop);
+ else {
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ ADD_INSN(ret, node, swap);
+ ADD_INSN1(ret, node, splatarray, Qtrue);
+ ADD_INSN(ret, node, swap);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+ ADD_INSN1(ret, node, pushtoarray, INT2FIX(1));
}
- ADD_SEND_WITH_FLAG(ret, node, idASET, argc, INT2FIX(flag));
+ ADD_SEND_R(ret, node, idASET, argc, NULL, INT2FIX(flag), NULL);
}
else {
- if (boff > 0)
- ADD_INSN(ret, node, swap);
- ADD_SEND_WITH_FLAG(ret, node, idASET, FIXNUM_INC(argc, 1), INT2FIX(flag));
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), NULL);
}
ADD_INSN(ret, node, pop);
}
@@ -8752,8 +9803,8 @@ static int
compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
const int line = nd_line(node);
- ID atype = node->nd_next->nd_mid;
- ID vid = node->nd_next->nd_vid, aid = rb_id_attrset(vid);
+ ID atype = RNODE_OP_ASGN2(node)->nd_mid;
+ ID vid = RNODE_OP_ASGN2(node)->nd_vid, aid = rb_id_attrset(vid);
int asgnflag;
LABEL *lfin = NEW_LABEL(line);
LABEL *lcfin = NEW_LABEL(line);
@@ -8811,9 +9862,9 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
*/
- asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
+ asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node, RNODE_OP_ASGN2(node)->nd_recv);
CHECK(asgnflag != -1);
- if (node->nd_next->nd_aid) {
+ if (RNODE_OP_ASGN2(node)->nd_aid) {
lskip = NEW_LABEL(line);
ADD_INSN(ret, node, dup);
ADD_INSNL(ret, node, branchnil, lskip);
@@ -8834,7 +9885,7 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
if (!popped) {
ADD_INSN(ret, node, pop);
}
- CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", RNODE_OP_ASGN2(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, swap);
ADD_INSN1(ret, node, topn, INT2FIX(1));
@@ -8850,7 +9901,7 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_LABEL(ret, lfin);
}
else {
- CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", RNODE_OP_ASGN2(node)->nd_value));
ADD_SEND(ret, node, atype, INT2FIX(1));
if (!popped) {
ADD_INSN(ret, node, swap);
@@ -8868,6 +9919,8 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
return COMPILE_OK;
}
+static int compile_shareable_constant_value(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_parser_shareability shareable, const NODE *lhs, const NODE *value);
+
static int
compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
@@ -8876,21 +9929,21 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
LABEL *lassign = 0;
ID mid;
- switch (nd_type(node->nd_head)) {
+ switch (nd_type(RNODE_OP_CDECL(node)->nd_head)) {
case NODE_COLON3:
ADD_INSN1(ret, node, putobject, rb_cObject);
break;
case NODE_COLON2:
- CHECK(COMPILE(ret, "NODE_OP_CDECL/colon2#nd_head", node->nd_head->nd_head));
+ CHECK(COMPILE(ret, "NODE_OP_CDECL/colon2#nd_head", RNODE_COLON2(RNODE_OP_CDECL(node)->nd_head)->nd_head));
break;
default:
COMPILE_ERROR(ERROR_ARGS "%s: invalid node in NODE_OP_CDECL",
- ruby_node_name(nd_type(node->nd_head)));
+ ruby_node_name(nd_type(RNODE_OP_CDECL(node)->nd_head)));
return COMPILE_NG;
}
- mid = node->nd_head->nd_mid;
+ mid = get_node_colon_nd_mid(RNODE_OP_CDECL(node)->nd_head);
/* cref */
- if (node->nd_aid == idOROP) {
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP) {
lassign = NEW_LABEL(line);
ADD_INSN(ret, node, dup); /* cref cref */
ADD_INSN3(ret, node, defined, INT2FIX(DEFINED_CONST_FROM),
@@ -8901,17 +9954,17 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_INSN1(ret, node, putobject, Qtrue);
ADD_INSN1(ret, node, getconstant, ID2SYM(mid)); /* cref obj */
- if (node->nd_aid == idOROP || node->nd_aid == idANDOP) {
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP || RNODE_OP_CDECL(node)->nd_aid == idANDOP) {
lfin = NEW_LABEL(line);
if (!popped) ADD_INSN(ret, node, dup); /* cref [obj] obj */
- if (node->nd_aid == idOROP)
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP)
ADD_INSNL(ret, node, branchif, lfin);
else /* idANDOP */
ADD_INSNL(ret, node, branchunless, lfin);
/* cref [obj] */
if (!popped) ADD_INSN(ret, node, pop); /* cref */
if (lassign) ADD_LABEL(ret, lassign);
- CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value));
+ CHECK(compile_shareable_constant_value(iseq, ret, RNODE_OP_CDECL(node)->shareability, RNODE_OP_CDECL(node)->nd_head, RNODE_OP_CDECL(node)->nd_value));
/* cref value */
if (popped)
ADD_INSN1(ret, node, topn, INT2FIX(1)); /* cref value cref */
@@ -8925,9 +9978,9 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_INSN(ret, node, pop); /* [value] */
}
else {
- CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value));
+ CHECK(compile_shareable_constant_value(iseq, ret, RNODE_OP_CDECL(node)->shareability, RNODE_OP_CDECL(node)->nd_head, RNODE_OP_CDECL(node)->nd_value));
/* cref obj value */
- ADD_CALL(ret, node, node->nd_aid, INT2FIX(1));
+ ADD_CALL(ret, node, RNODE_OP_CDECL(node)->nd_aid, INT2FIX(1));
/* cref value */
ADD_INSN(ret, node, swap); /* value cref */
if (!popped) {
@@ -8946,11 +9999,11 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
LABEL *lfin = NEW_LABEL(line);
LABEL *lassign;
- if (type == NODE_OP_ASGN_OR && !nd_type_p(node->nd_head, NODE_IVAR)) {
+ if (type == NODE_OP_ASGN_OR && !nd_type_p(RNODE_OP_ASGN_OR(node)->nd_head, NODE_IVAR)) {
LABEL *lfinish[2];
lfinish[0] = lfin;
lfinish[1] = 0;
- defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
+ defined_expr(iseq, ret, RNODE_OP_ASGN_OR(node)->nd_head, lfinish, Qfalse, false);
lassign = lfinish[1];
if (!lassign) {
lassign = NEW_LABEL(line);
@@ -8961,7 +10014,7 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
lassign = NEW_LABEL(line);
}
- CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", node->nd_head));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", RNODE_OP_ASGN_OR(node)->nd_head));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -8979,7 +10032,7 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
}
ADD_LABEL(ret, lassign);
- CHECK(COMPILE_(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value, popped));
+ CHECK(COMPILE_(ret, "NODE_OP_ASGN_AND/OR#nd_value", RNODE_OP_ASGN_OR(node)->nd_value, popped));
ADD_LABEL(ret, lfin);
return COMPILE_OK;
}
@@ -8993,13 +10046,22 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
unsigned int flag = 0;
struct rb_callinfo_kwarg *keywords = NULL;
const rb_iseq_t *parent_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ int use_block = 1;
INIT_ANCHOR(args);
ISEQ_COMPILE_DATA(iseq)->current_block = NULL;
+
if (type == NODE_SUPER) {
- VALUE vargc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
+ VALUE vargc = setup_args(iseq, args, RNODE_SUPER(node)->nd_args, &flag, &keywords);
CHECK(!NIL_P(vargc));
argc = FIX2INT(vargc);
+ if ((flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT) && !(flag & VM_CALL_KW_SPLAT_MUT)) {
+ ADD_INSN(args, node, splatkw);
+ }
+
+ if (flag & VM_CALL_ARGS_BLOCKARG) {
+ use_block = 0;
+ }
}
else {
/* NODE_ZSUPER */
@@ -9017,6 +10079,13 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_GETLOCAL(args, node, idx, lvar_level);
}
+ /* forward ... */
+ if (local_body->param.flags.forwardable) {
+ flag |= VM_CALL_FORWARDING;
+ int idx = local_body->local_table_size - get_local_var_idx(liseq, idDot3);
+ ADD_GETLOCAL(args, node, idx, lvar_level);
+ }
+
if (local_body->param.flags.has_opt) {
/* optional arguments */
int j;
@@ -9031,7 +10100,7 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
/* rest argument */
int idx = local_body->local_table_size - local_body->param.rest_start;
ADD_GETLOCAL(args, node, idx, lvar_level);
- ADD_INSN1(args, node, splatarray, Qfalse);
+ ADD_INSN1(args, node, splatarray, RBOOL(local_body->param.flags.has_post));
argc = local_body->param.rest_start + 1;
flag |= VM_CALL_ARGS_SPLAT;
@@ -9047,8 +10116,8 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
int idx = local_body->local_table_size - (post_start + j);
ADD_GETLOCAL(args, node, idx, lvar_level);
}
- ADD_INSN1(args, node, newarray, INT2FIX(j));
- ADD_INSN (args, node, concatarray);
+ ADD_INSN1(args, node, pushtoarray, INT2FIX(j));
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
/* argc is settled at above */
}
else {
@@ -9070,14 +10139,11 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
if (local_body->param.flags.has_kwrest) {
int idx = local_body->local_table_size - local_kwd->rest_start;
ADD_GETLOCAL(args, node, idx, lvar_level);
- if (local_kwd->num > 0) {
- ADD_SEND (args, node, rb_intern("dup"), INT2FIX(0));
- flag |= VM_CALL_KW_SPLAT_MUT;
- }
+ RUBY_ASSERT(local_kwd->num > 0);
+ ADD_SEND (args, node, rb_intern("dup"), INT2FIX(0));
}
else {
ADD_INSN1(args, node, newhash, INT2FIX(0));
- flag |= VM_CALL_KW_SPLAT_MUT;
}
for (i = 0; i < local_kwd->num; ++i) {
ID id = local_kwd->table[i];
@@ -9086,23 +10152,33 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_GETLOCAL(args, node, idx, lvar_level);
}
ADD_SEND(args, node, id_core_hash_merge_ptr, INT2FIX(i * 2 + 1));
- flag |= VM_CALL_KW_SPLAT;
+ flag |= VM_CALL_KW_SPLAT| VM_CALL_KW_SPLAT_MUT;
}
else if (local_body->param.flags.has_kwrest) {
int idx = local_body->local_table_size - local_kwd->rest_start;
ADD_GETLOCAL(args, node, idx, lvar_level);
argc++;
- flag |= VM_CALL_KW_SPLAT | VM_CALL_KW_SPLAT_MUT;
+ flag |= VM_CALL_KW_SPLAT;
}
}
+ if (use_block && parent_block == NULL) {
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+ }
+
flag |= VM_CALL_SUPER | VM_CALL_FCALL;
if (type == NODE_ZSUPER) flag |= VM_CALL_ZSUPER;
ADD_INSN(ret, node, putself);
ADD_SEQ(ret, args);
- ADD_INSN2(ret, node, invokesuper,
- new_callinfo(iseq, 0, argc, flag, keywords, parent_block != NULL),
- parent_block);
+
+ const struct rb_callinfo * ci = new_callinfo(iseq, 0, argc, flag, keywords, parent_block != NULL);
+
+ if (vm_ci_flag(ci) & VM_CALL_FORWARDING) {
+ ADD_INSN2(ret, node, invokesuperforward, ci, parent_block);
+ }
+ else {
+ ADD_INSN2(ret, node, invokesuper, ci, parent_block);
+ }
if (popped) {
ADD_INSN(ret, node, pop);
@@ -9129,8 +10205,8 @@ compile_yield(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
default: /* valid */;
}
- if (node->nd_head) {
- argc = setup_args(iseq, args, node->nd_head, &flag, &keywords);
+ if (RNODE_YIELD(node)->nd_head) {
+ argc = setup_args(iseq, args, RNODE_YIELD(node)->nd_head, &flag, &keywords);
CHECK(!NIL_P(argc));
}
else {
@@ -9139,6 +10215,7 @@ compile_yield(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_SEQ(ret, args);
ADD_INSN1(ret, node, invokeblock, new_callinfo(iseq, 0, FIX2INT(argc), flag, keywords, FALSE));
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
if (popped) {
ADD_INSN(ret, node, pop);
@@ -9164,17 +10241,21 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
INIT_ANCHOR(val);
switch ((int)type) {
case NODE_MATCH:
- ADD_INSN1(recv, node, putobject, node->nd_lit);
- ADD_INSN2(val, node, getspecial, INT2FIX(0),
- INT2FIX(0));
+ {
+ VALUE re = rb_node_regx_string_val(node);
+ RB_OBJ_SET_FROZEN_SHAREABLE(re);
+ ADD_INSN1(recv, node, putobject, re);
+ ADD_INSN2(val, node, getspecial, INT2FIX(0),
+ INT2FIX(0));
+ }
break;
case NODE_MATCH2:
- CHECK(COMPILE(recv, "receiver", node->nd_recv));
- CHECK(COMPILE(val, "value", node->nd_value));
+ CHECK(COMPILE(recv, "receiver", RNODE_MATCH2(node)->nd_recv));
+ CHECK(COMPILE(val, "value", RNODE_MATCH2(node)->nd_value));
break;
case NODE_MATCH3:
- CHECK(COMPILE(recv, "receiver", node->nd_value));
- CHECK(COMPILE(val, "value", node->nd_recv));
+ CHECK(COMPILE(recv, "receiver", RNODE_MATCH3(node)->nd_value));
+ CHECK(COMPILE(val, "value", RNODE_MATCH3(node)->nd_recv));
break;
}
@@ -9182,8 +10263,8 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_SEQ(ret, val);
ADD_SEND(ret, node, idEqTilde, INT2FIX(1));
- if (node->nd_args) {
- compile_named_capture_assign(iseq, ret, node->nd_args);
+ if (nd_type_p(node, NODE_MATCH2) && RNODE_MATCH2(node)->nd_args) {
+ compile_named_capture_assign(iseq, ret, RNODE_MATCH2(node)->nd_args);
}
if (popped) {
@@ -9195,7 +10276,7 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
static int
compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- if (rb_is_const_id(node->nd_mid)) {
+ if (rb_is_const_id(RNODE_COLON2(node)->nd_mid)) {
/* constant */
VALUE segments;
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache &&
@@ -9225,8 +10306,8 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
else {
/* function call */
ADD_CALL_RECEIVER(ret, node);
- CHECK(COMPILE(ret, "colon2#nd_head", node->nd_head));
- ADD_CALL(ret, node, node->nd_mid, INT2FIX(1));
+ CHECK(COMPILE(ret, "colon2#nd_head", RNODE_COLON2(node)->nd_head));
+ ADD_CALL(ret, node, RNODE_COLON2(node)->nd_mid, INT2FIX(1));
}
if (popped) {
ADD_INSN(ret, node, pop);
@@ -9237,19 +10318,20 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_colon3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- debugi("colon3#nd_mid", node->nd_mid);
+ debugi("colon3#nd_mid", RNODE_COLON3(node)->nd_mid);
/* add cache insn */
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
ISEQ_BODY(iseq)->ic_size++;
- VALUE segments = rb_ary_new_from_args(2, ID2SYM(idNULL), ID2SYM(node->nd_mid));
+ VALUE segments = rb_ary_new_from_args(2, ID2SYM(idNULL), ID2SYM(RNODE_COLON3(node)->nd_mid));
+ RB_OBJ_SET_FROZEN_SHAREABLE(segments);
ADD_INSN1(ret, node, opt_getconstant_path, segments);
RB_OBJ_WRITTEN(iseq, Qundef, segments);
}
else {
ADD_INSN1(ret, node, putobject, rb_cObject);
ADD_INSN1(ret, node, putobject, Qtrue);
- ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(ret, node, getconstant, ID2SYM(RNODE_COLON3(node)->nd_mid));
}
if (popped) {
@@ -9262,14 +10344,15 @@ static int
compile_dots(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const int excl)
{
VALUE flag = INT2FIX(excl);
- const NODE *b = node->nd_beg;
- const NODE *e = node->nd_end;
+ const NODE *b = RNODE_DOT2(node)->nd_beg;
+ const NODE *e = RNODE_DOT2(node)->nd_end;
if (optimizable_range_item_p(b) && optimizable_range_item_p(e)) {
if (!popped) {
- VALUE bv = nd_type_p(b, NODE_LIT) ? b->nd_lit : Qnil;
- VALUE ev = nd_type_p(e, NODE_LIT) ? e->nd_lit : Qnil;
+ VALUE bv = optimized_range_item(b);
+ VALUE ev = optimized_range_item(e);
VALUE val = rb_range_new(bv, ev, excl);
+ rb_ractor_make_shareable(rb_obj_freeze(val));
ADD_INSN1(ret, node, putobject, val);
RB_OBJ_WRITTEN(iseq, Qundef, val);
}
@@ -9317,14 +10400,20 @@ compile_kw_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
{
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
LABEL *end_label = NEW_LABEL(nd_line(node));
- const NODE *default_value = node->nd_body->nd_value;
+ const NODE *default_value = get_nd_value(RNODE_KW_ARG(node)->nd_body);
if (default_value == NODE_SPECIAL_REQUIRED_KEYWORD) {
/* required argument. do nothing */
COMPILE_ERROR(ERROR_ARGS "unreachable");
return COMPILE_NG;
}
- else if (nd_type_p(default_value, NODE_LIT) ||
+ else if (nd_type_p(default_value, NODE_SYM) ||
+ nd_type_p(default_value, NODE_REGX) ||
+ nd_type_p(default_value, NODE_LINE) ||
+ nd_type_p(default_value, NODE_INTEGER) ||
+ nd_type_p(default_value, NODE_FLOAT) ||
+ nd_type_p(default_value, NODE_RATIONAL) ||
+ nd_type_p(default_value, NODE_IMAGINARY) ||
nd_type_p(default_value, NODE_NIL) ||
nd_type_p(default_value, NODE_TRUE) ||
nd_type_p(default_value, NODE_FALSE)) {
@@ -9341,7 +10430,7 @@ compile_kw_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
ADD_INSN2(ret, node, checkkeyword, INT2FIX(kw_bits_idx + VM_ENV_DATA_SIZE - 1), INT2FIX(keyword_idx));
ADD_INSNL(ret, node, branchif, end_label);
- CHECK(COMPILE_POPPED(ret, "keyword default argument", node->nd_body));
+ CHECK(COMPILE_POPPED(ret, "keyword default argument", RNODE_KW_ARG(node)->nd_body));
ADD_LABEL(ret, end_label);
}
return COMPILE_OK;
@@ -9353,41 +10442,17 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
DECL_ANCHOR(recv);
DECL_ANCHOR(args);
unsigned int flag = 0;
- ID mid = node->nd_mid;
+ ID mid = RNODE_ATTRASGN(node)->nd_mid;
VALUE argc;
LABEL *else_label = NULL;
VALUE branches = Qfalse;
- /* optimization shortcut
- * obj["literal"] = value -> opt_aset_with(obj, "literal", value)
- */
- if (mid == idASET && !private_recv_p(node) && node->nd_args &&
- nd_type_p(node->nd_args, NODE_LIST) && node->nd_args->nd_alen == 2 &&
- nd_type_p(node->nd_args->nd_head, NODE_STR) &&
- ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
- !ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
- ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction)
- {
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
- CHECK(COMPILE(ret, "recv", node->nd_recv));
- CHECK(COMPILE(ret, "value", node->nd_args->nd_next->nd_head));
- if (!popped) {
- ADD_INSN(ret, node, swap);
- ADD_INSN1(ret, node, topn, INT2FIX(1));
- }
- ADD_INSN2(ret, node, opt_aset_with, str,
- new_callinfo(iseq, idASET, 2, 0, NULL, FALSE));
- RB_OBJ_WRITTEN(iseq, Qundef, str);
- ADD_INSN(ret, node, pop);
- return COMPILE_OK;
- }
-
INIT_ANCHOR(recv);
INIT_ANCHOR(args);
- argc = setup_args(iseq, args, node->nd_args, &flag, NULL);
+ argc = setup_args(iseq, args, RNODE_ATTRASGN(node)->nd_args, &flag, NULL);
CHECK(!NIL_P(argc));
- int asgnflag = COMPILE_RECV(recv, "recv", node);
+ int asgnflag = COMPILE_RECV(recv, "recv", node, RNODE_ATTRASGN(node)->nd_recv);
CHECK(asgnflag != -1);
flag |= (unsigned int)asgnflag;
@@ -9404,16 +10469,7 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_SEQ(ret, recv);
ADD_SEQ(ret, args);
- if (flag & VM_CALL_ARGS_BLOCKARG) {
- ADD_INSN1(ret, node, topn, INT2FIX(1));
- if (flag & VM_CALL_ARGS_SPLAT) {
- ADD_INSN1(ret, node, putobject, INT2FIX(-1));
- ADD_SEND_WITH_FLAG(ret, node, idAREF, INT2FIX(1), INT2FIX(asgnflag));
- }
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 3));
- ADD_INSN (ret, node, pop);
- }
- else if (flag & VM_CALL_ARGS_SPLAT) {
+ if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN(ret, node, dup);
ADD_INSN1(ret, node, putobject, INT2FIX(-1));
ADD_SEND_WITH_FLAG(ret, node, idAREF, INT2FIX(1), INT2FIX(asgnflag));
@@ -9434,6 +10490,375 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
return COMPILE_OK;
}
+static int
+compile_make_shareable_node(rb_iseq_t *iseq, LINK_ANCHOR *ret, LINK_ANCHOR *sub, const NODE *value, bool copy)
+{
+ ADD_INSN1(ret, value, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_SEQ(ret, sub);
+
+ if (copy) {
+ /*
+ * NEW_CALL(fcore, rb_intern("make_shareable_copy"),
+ * NEW_LIST(value, loc), loc);
+ */
+ ADD_SEND_WITH_FLAG(ret, value, rb_intern("make_shareable_copy"), INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+ else {
+ /*
+ * NEW_CALL(fcore, rb_intern("make_shareable"),
+ * NEW_LIST(value, loc), loc);
+ */
+ ADD_SEND_WITH_FLAG(ret, value, rb_intern("make_shareable"), INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+
+ return COMPILE_OK;
+}
+
+static VALUE
+node_const_decl_val(const NODE *node)
+{
+ VALUE path;
+ switch (nd_type(node)) {
+ case NODE_CDECL:
+ if (RNODE_CDECL(node)->nd_vid) {
+ path = rb_id2str(RNODE_CDECL(node)->nd_vid);
+ goto end;
+ }
+ else {
+ node = RNODE_CDECL(node)->nd_else;
+ }
+ break;
+ case NODE_COLON2:
+ break;
+ case NODE_COLON3:
+ // ::Const
+ path = rb_str_new_cstr("::");
+ rb_str_append(path, rb_id2str(RNODE_COLON3(node)->nd_mid));
+ goto end;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ UNREACHABLE_RETURN(0);
+ }
+
+ path = rb_ary_new();
+ if (node) {
+ for (; node && nd_type_p(node, NODE_COLON2); node = RNODE_COLON2(node)->nd_head) {
+ rb_ary_push(path, rb_id2str(RNODE_COLON2(node)->nd_mid));
+ }
+ if (node && nd_type_p(node, NODE_CONST)) {
+ // Const::Name
+ rb_ary_push(path, rb_id2str(RNODE_CONST(node)->nd_vid));
+ }
+ else if (node && nd_type_p(node, NODE_COLON3)) {
+ // ::Const::Name
+ rb_ary_push(path, rb_id2str(RNODE_COLON3(node)->nd_mid));
+ rb_ary_push(path, rb_str_new(0, 0));
+ }
+ else {
+ // expression::Name
+ rb_ary_push(path, rb_str_new_cstr("..."));
+ }
+ path = rb_ary_join(rb_ary_reverse(path), rb_str_new_cstr("::"));
+ }
+ end:
+ path = rb_fstring(path);
+ return path;
+}
+
+static VALUE
+const_decl_path(NODE *dest)
+{
+ VALUE path = Qnil;
+ if (!nd_type_p(dest, NODE_CALL)) {
+ path = node_const_decl_val(dest);
+ }
+ return path;
+}
+
+static int
+compile_ensure_shareable_node(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *dest, const NODE *value)
+{
+ /*
+ *. RubyVM::FrozenCore.ensure_shareable(value, const_decl_path(dest))
+ */
+ VALUE path = const_decl_path(dest);
+ ADD_INSN1(ret, value, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ CHECK(COMPILE(ret, "compile_ensure_shareable_node", value));
+ ADD_INSN1(ret, value, putobject, path);
+ RB_OBJ_WRITTEN(iseq, Qundef, path);
+ ADD_SEND_WITH_FLAG(ret, value, rb_intern("ensure_shareable"), INT2FIX(2), INT2FIX(VM_CALL_ARGS_SIMPLE));
+
+ return COMPILE_OK;
+}
+
+#ifndef SHAREABLE_BARE_EXPRESSION
+#define SHAREABLE_BARE_EXPRESSION 1
+#endif
+
+static int
+compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_parser_shareability shareable, NODE *dest, const NODE *node, size_t level, VALUE *value_p, int *shareable_literal_p)
+{
+# define compile_shareable_literal_constant_next(node, anchor, value_p, shareable_literal_p) \
+ compile_shareable_literal_constant(iseq, anchor, shareable, dest, node, level+1, value_p, shareable_literal_p)
+ VALUE lit = Qnil;
+ DECL_ANCHOR(anchor);
+
+ enum node_type type = node ? nd_type(node) : NODE_NIL;
+ switch (type) {
+ case NODE_TRUE:
+ *value_p = Qtrue;
+ goto compile;
+ case NODE_FALSE:
+ *value_p = Qfalse;
+ goto compile;
+ case NODE_NIL:
+ *value_p = Qnil;
+ goto compile;
+ case NODE_SYM:
+ *value_p = rb_node_sym_string_val(node);
+ goto compile;
+ case NODE_REGX:
+ *value_p = rb_node_regx_string_val(node);
+ goto compile;
+ case NODE_LINE:
+ *value_p = rb_node_line_lineno_val(node);
+ goto compile;
+ case NODE_INTEGER:
+ *value_p = rb_node_integer_literal_val(node);
+ goto compile;
+ case NODE_FLOAT:
+ *value_p = rb_node_float_literal_val(node);
+ goto compile;
+ case NODE_RATIONAL:
+ *value_p = rb_node_rational_literal_val(node);
+ goto compile;
+ case NODE_IMAGINARY:
+ *value_p = rb_node_imaginary_literal_val(node);
+ goto compile;
+ case NODE_ENCODING:
+ *value_p = rb_node_encoding_val(node);
+
+ compile:
+ CHECK(COMPILE(ret, "shareable_literal_constant", node));
+ *shareable_literal_p = 1;
+ return COMPILE_OK;
+
+ case NODE_DSTR:
+ CHECK(COMPILE(ret, "shareable_literal_constant", node));
+ if (shareable == rb_parser_shareable_literal) {
+ /*
+ * NEW_CALL(node, idUMinus, 0, loc);
+ *
+ * -"#{var}"
+ */
+ ADD_SEND_WITH_FLAG(ret, node, idUMinus, INT2FIX(0), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+ *value_p = Qundef;
+ *shareable_literal_p = 1;
+ return COMPILE_OK;
+
+ case NODE_STR:{
+ VALUE lit = rb_node_str_string_val(node);
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ *value_p = lit;
+ *shareable_literal_p = 1;
+
+ return COMPILE_OK;
+ }
+
+ case NODE_FILE:{
+ VALUE lit = rb_node_file_path_val(node);
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ *value_p = lit;
+ *shareable_literal_p = 1;
+
+ return COMPILE_OK;
+ }
+
+ case NODE_ZLIST:{
+ VALUE lit = rb_ary_new();
+ OBJ_FREEZE(lit);
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ *value_p = lit;
+ *shareable_literal_p = 1;
+
+ return COMPILE_OK;
+ }
+
+ case NODE_LIST:{
+ INIT_ANCHOR(anchor);
+ lit = rb_ary_new();
+ for (NODE *n = (NODE *)node; n; n = RNODE_LIST(n)->nd_next) {
+ VALUE val;
+ int shareable_literal_p2;
+ NODE *elt = RNODE_LIST(n)->nd_head;
+ if (elt) {
+ CHECK(compile_shareable_literal_constant_next(elt, anchor, &val, &shareable_literal_p2));
+ if (shareable_literal_p2) {
+ /* noop */
+ }
+ else if (RTEST(lit)) {
+ rb_ary_clear(lit);
+ lit = Qfalse;
+ }
+ }
+ if (RTEST(lit)) {
+ if (!UNDEF_P(val)) {
+ rb_ary_push(lit, val);
+ }
+ else {
+ rb_ary_clear(lit);
+ lit = Qnil; /* make shareable at runtime */
+ }
+ }
+ }
+ break;
+ }
+ case NODE_HASH:{
+ if (!RNODE_HASH(node)->nd_brace) {
+ *value_p = Qundef;
+ *shareable_literal_p = 0;
+ return COMPILE_OK;
+ }
+ for (NODE *n = RNODE_HASH(node)->nd_head; n; n = RNODE_LIST(RNODE_LIST(n)->nd_next)->nd_next) {
+ if (!RNODE_LIST(n)->nd_head) {
+ // If the hash node have a keyword splat, fall back to the default case.
+ goto compile_shareable;
+ }
+ }
+
+ INIT_ANCHOR(anchor);
+ lit = rb_hash_new();
+ for (NODE *n = RNODE_HASH(node)->nd_head; n; n = RNODE_LIST(RNODE_LIST(n)->nd_next)->nd_next) {
+ VALUE key_val = 0;
+ VALUE value_val = 0;
+ int shareable_literal_p2;
+ NODE *key = RNODE_LIST(n)->nd_head;
+ NODE *val = RNODE_LIST(RNODE_LIST(n)->nd_next)->nd_head;
+ CHECK(compile_shareable_literal_constant_next(key, anchor, &key_val, &shareable_literal_p2));
+ if (shareable_literal_p2) {
+ /* noop */
+ }
+ else if (RTEST(lit)) {
+ rb_hash_clear(lit);
+ lit = Qfalse;
+ }
+ CHECK(compile_shareable_literal_constant_next(val, anchor, &value_val, &shareable_literal_p2));
+ if (shareable_literal_p2) {
+ /* noop */
+ }
+ else if (RTEST(lit)) {
+ rb_hash_clear(lit);
+ lit = Qfalse;
+ }
+ if (RTEST(lit)) {
+ if (!UNDEF_P(key_val) && !UNDEF_P(value_val)) {
+ rb_hash_aset(lit, key_val, value_val);
+ }
+ else {
+ rb_hash_clear(lit);
+ lit = Qnil; /* make shareable at runtime */
+ }
+ }
+ }
+ break;
+ }
+
+ default:
+
+ compile_shareable:
+ if (shareable == rb_parser_shareable_literal &&
+ (SHAREABLE_BARE_EXPRESSION || level > 0)) {
+ CHECK(compile_ensure_shareable_node(iseq, ret, dest, node));
+ *value_p = Qundef;
+ *shareable_literal_p = 1;
+ return COMPILE_OK;
+ }
+ CHECK(COMPILE(ret, "shareable_literal_constant", node));
+ *value_p = Qundef;
+ *shareable_literal_p = 0;
+ return COMPILE_OK;
+ }
+
+ /* Array or Hash that does not have keyword splat */
+ if (!lit) {
+ if (nd_type(node) == NODE_LIST) {
+ ADD_INSN1(anchor, node, newarray, INT2FIX(RNODE_LIST(node)->as.nd_alen));
+ }
+ else if (nd_type(node) == NODE_HASH) {
+ long len = RNODE_LIST(RNODE_HASH(node)->nd_head)->as.nd_alen;
+ RBIMPL_ASSERT_OR_ASSUME(len >= 0);
+ RBIMPL_ASSERT_OR_ASSUME(RB_POSFIXABLE(len));
+ ADD_INSN1(anchor, node, newhash, LONG2FIX(len));
+ }
+ *value_p = Qundef;
+ *shareable_literal_p = 0;
+ ADD_SEQ(ret, anchor);
+ return COMPILE_OK;
+ }
+ if (NIL_P(lit)) {
+ // if shareable_literal, all elements should have been ensured
+ // as shareable
+ if (nd_type(node) == NODE_LIST) {
+ ADD_INSN1(anchor, node, newarray, INT2FIX(RNODE_LIST(node)->as.nd_alen));
+ }
+ else if (nd_type(node) == NODE_HASH) {
+ long len = RNODE_LIST(RNODE_HASH(node)->nd_head)->as.nd_alen;
+ RBIMPL_ASSERT_OR_ASSUME(len >= 0);
+ RBIMPL_ASSERT_OR_ASSUME(RB_POSFIXABLE(len));
+ ADD_INSN1(anchor, node, newhash, LONG2FIX(len));
+ }
+ CHECK(compile_make_shareable_node(iseq, ret, anchor, node, false));
+ *value_p = Qundef;
+ *shareable_literal_p = 1;
+ }
+ else {
+ VALUE val = rb_ractor_make_shareable(lit);
+ ADD_INSN1(ret, node, putobject, val);
+ RB_OBJ_WRITTEN(iseq, Qundef, val);
+ *value_p = val;
+ *shareable_literal_p = 1;
+ }
+
+ return COMPILE_OK;
+}
+
+static int
+compile_shareable_constant_value(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_parser_shareability shareable, const NODE *lhs, const NODE *value)
+{
+ int literal_p = 0;
+ VALUE val;
+ DECL_ANCHOR(anchor);
+ INIT_ANCHOR(anchor);
+
+ switch (shareable) {
+ case rb_parser_shareable_none:
+ CHECK(COMPILE(ret, "compile_shareable_constant_value", value));
+ return COMPILE_OK;
+
+ case rb_parser_shareable_literal:
+ CHECK(compile_shareable_literal_constant(iseq, anchor, shareable, (NODE *)lhs, value, 0, &val, &literal_p));
+ ADD_SEQ(ret, anchor);
+ return COMPILE_OK;
+
+ case rb_parser_shareable_copy:
+ case rb_parser_shareable_everything:
+ CHECK(compile_shareable_literal_constant(iseq, anchor, shareable, (NODE *)lhs, value, 0, &val, &literal_p));
+ if (!literal_p) {
+ CHECK(compile_make_shareable_node(iseq, ret, anchor, value, shareable == rb_parser_shareable_copy));
+ }
+ else {
+ ADD_SEQ(ret, anchor);
+ }
+ return COMPILE_OK;
+ default:
+ rb_bug("unexpected rb_parser_shareability: %d", shareable);
+ }
+}
+
static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped);
/**
compile each node
@@ -9450,8 +10875,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *node, int poppe
int lineno = ISEQ_COMPILE_DATA(iseq)->last_line;
if (lineno == 0) lineno = FIX2INT(rb_iseq_first_lineno(iseq));
debugs("node: NODE_NIL(implicit)\n");
- NODE dummy_line_node = generate_dummy_line_node(lineno, -1);
- ADD_INSN(ret, &dummy_line_node, putnil);
+ ADD_SYNTHETIC_INSN(ret, lineno, -1, putnil);
}
return COMPILE_OK;
}
@@ -9469,10 +10893,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
/* ignore */
}
else {
- if (node->flags & NODE_FL_NEWLINE) {
+ if (nd_fl_newline(node)) {
int event = RUBY_EVENT_LINE;
ISEQ_COMPILE_DATA(iseq)->last_line = line;
- if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
+ if (line > 0 && ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
event |= RUBY_EVENT_COVERAGE_LINE;
}
ADD_TRACE(ret, event);
@@ -9524,7 +10948,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
CHECK(compile_retry(iseq, ret, node, popped));
break;
case NODE_BEGIN:{
- CHECK(COMPILE_(ret, "NODE_BEGIN", node->nd_body, popped));
+ CHECK(COMPILE_(ret, "NODE_BEGIN", RNODE_BEGIN(node)->nd_body, popped));
break;
}
case NODE_RESCUE:
@@ -9540,7 +10964,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_AND:
case NODE_OR:{
LABEL *end_label = NEW_LABEL(line);
- CHECK(COMPILE(ret, "nd_1st", node->nd_1st));
+ CHECK(COMPILE(ret, "nd_1st", RNODE_OR(node)->nd_1st));
if (!popped) {
ADD_INSN(ret, node, dup);
}
@@ -9553,7 +10977,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
if (!popped) {
ADD_INSN(ret, node, pop);
}
- CHECK(COMPILE_(ret, "nd_2nd", node->nd_2nd, popped));
+ CHECK(COMPILE_(ret, "nd_2nd", RNODE_OR(node)->nd_2nd, popped));
ADD_LABEL(ret, end_label);
break;
}
@@ -9564,11 +10988,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_LASGN:{
- ID id = node->nd_vid;
+ ID id = RNODE_LASGN(node)->nd_vid;
int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
- CHECK(COMPILE(ret, "rvalue", node->nd_value));
+ CHECK(COMPILE(ret, "rvalue", RNODE_LASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -9578,8 +11002,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_DASGN: {
int idx, lv, ls;
- ID id = node->nd_vid;
- CHECK(COMPILE(ret, "dvalue", node->nd_value));
+ ID id = RNODE_DASGN(node)->nd_vid;
+ CHECK(COMPILE(ret, "dvalue", RNODE_DASGN(node)->nd_value));
debugi("dassn id", rb_id2str(id) ? id : '*');
if (!popped) {
@@ -9597,27 +11021,27 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_GASGN:{
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ CHECK(COMPILE(ret, "lvalue", RNODE_GASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
- ADD_INSN1(ret, node, setglobal, ID2SYM(node->nd_entry));
+ ADD_INSN1(ret, node, setglobal, ID2SYM(RNODE_GASGN(node)->nd_vid));
break;
}
case NODE_IASGN:{
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ CHECK(COMPILE(ret, "lvalue", RNODE_IASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
ADD_INSN2(ret, node, setinstancevariable,
- ID2SYM(node->nd_vid),
- get_ivar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_IASGN(node)->nd_vid),
+ get_ivar_ic_value(iseq,RNODE_IASGN(node)->nd_vid));
break;
}
case NODE_CDECL:{
- if (node->nd_vid) {
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ if (RNODE_CDECL(node)->nd_vid) {
+ CHECK(compile_shareable_constant_value(iseq, ret, RNODE_CDECL(node)->shareability, node, RNODE_CDECL(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -9625,11 +11049,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
ADD_INSN1(ret, node, putspecialobject,
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
- ADD_INSN1(ret, node, setconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, node, setconstant, ID2SYM(RNODE_CDECL(node)->nd_vid));
}
else {
- compile_cpath(ret, iseq, node->nd_else);
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ compile_cpath(ret, iseq, RNODE_CDECL(node)->nd_else);
+ CHECK(compile_shareable_constant_value(iseq, ret, RNODE_CDECL(node)->shareability, node, RNODE_CDECL(node)->nd_value));
ADD_INSN(ret, node, swap);
if (!popped) {
@@ -9637,18 +11061,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
ADD_INSN(ret, node, swap);
}
- ADD_INSN1(ret, node, setconstant, ID2SYM(node->nd_else->nd_mid));
+ ADD_INSN1(ret, node, setconstant, ID2SYM(get_node_colon_nd_mid(RNODE_CDECL(node)->nd_else)));
}
break;
}
case NODE_CVASGN:{
- CHECK(COMPILE(ret, "cvasgn val", node->nd_value));
+ CHECK(COMPILE(ret, "cvasgn val", RNODE_CVASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
ADD_INSN2(ret, node, setclassvariable,
- ID2SYM(node->nd_vid),
- get_cvar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_CVASGN(node)->nd_vid),
+ get_cvar_ic_value(iseq, RNODE_CVASGN(node)->nd_vid));
break;
}
case NODE_OP_ASGN1:
@@ -9681,7 +11105,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
CHECK(compile_super(iseq, ret, node, popped, type));
break;
case NODE_LIST:{
- CHECK(compile_array(iseq, ret, node, popped) >= 0);
+ CHECK(compile_array(iseq, ret, node, popped, TRUE) >= 0);
break;
}
case NODE_ZLIST:{
@@ -9690,18 +11114,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
break;
}
- case NODE_VALUES:{
- const NODE *n = node;
- if (popped) {
- COMPILE_ERROR(ERROR_ARGS "NODE_VALUES: must not be popped");
- }
- while (n) {
- CHECK(COMPILE(ret, "values item", n->nd_head));
- n = n->nd_next;
- }
- ADD_INSN1(ret, node, newarray, INT2FIX(node->nd_alen));
- break;
- }
case NODE_HASH:
CHECK(compile_hash(iseq, ret, node, FALSE, popped) >= 0);
break;
@@ -9713,18 +11125,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
case NODE_LVAR:{
if (!popped) {
- compile_lvar(iseq, ret, node, node->nd_vid);
+ compile_lvar(iseq, ret, node, RNODE_LVAR(node)->nd_vid);
}
break;
}
case NODE_DVAR:{
int lv, idx, ls;
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_DVAR(node)->nd_vid);
if (!popped) {
- idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
+ idx = get_dyna_var_idx(iseq, RNODE_DVAR(node)->nd_vid, &lv, &ls);
if (idx < 0) {
COMPILE_ERROR(ERROR_ARGS "unknown dvar (%"PRIsVALUE")",
- rb_id2str(node->nd_vid));
+ rb_id2str(RNODE_DVAR(node)->nd_vid));
goto ng;
}
ADD_GETLOCAL(ret, node, ls - idx, lv);
@@ -9732,34 +11144,35 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_GVAR:{
- ADD_INSN1(ret, node, getglobal, ID2SYM(node->nd_entry));
+ ADD_INSN1(ret, node, getglobal, ID2SYM(RNODE_GVAR(node)->nd_vid));
if (popped) {
ADD_INSN(ret, node, pop);
}
break;
}
case NODE_IVAR:{
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_IVAR(node)->nd_vid);
if (!popped) {
ADD_INSN2(ret, node, getinstancevariable,
- ID2SYM(node->nd_vid),
- get_ivar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_IVAR(node)->nd_vid),
+ get_ivar_ic_value(iseq, RNODE_IVAR(node)->nd_vid));
}
break;
}
case NODE_CONST:{
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_CONST(node)->nd_vid);
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
body->ic_size++;
- VALUE segments = rb_ary_new_from_args(1, ID2SYM(node->nd_vid));
+ VALUE segments = rb_ary_new_from_args(1, ID2SYM(RNODE_CONST(node)->nd_vid));
+ RB_OBJ_SET_FROZEN_SHAREABLE(segments);
ADD_INSN1(ret, node, opt_getconstant_path, segments);
RB_OBJ_WRITTEN(iseq, Qundef, segments);
}
else {
ADD_INSN(ret, node, putnil);
ADD_INSN1(ret, node, putobject, Qtrue);
- ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, node, getconstant, ID2SYM(RNODE_CONST(node)->nd_vid));
}
if (popped) {
@@ -9770,26 +11183,26 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_CVAR:{
if (!popped) {
ADD_INSN2(ret, node, getclassvariable,
- ID2SYM(node->nd_vid),
- get_cvar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_CVAR(node)->nd_vid),
+ get_cvar_ic_value(iseq, RNODE_CVAR(node)->nd_vid));
}
break;
}
case NODE_NTH_REF:{
if (!popped) {
- if (!node->nd_nth) {
+ if (!RNODE_NTH_REF(node)->nd_nth) {
ADD_INSN(ret, node, putnil);
break;
}
ADD_INSN2(ret, node, getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(node->nd_nth << 1));
+ INT2FIX(RNODE_NTH_REF(node)->nd_nth << 1));
}
break;
}
case NODE_BACK_REF:{
if (!popped) {
ADD_INSN2(ret, node, getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(0x01 | (node->nd_nth << 1)));
+ INT2FIX(0x01 | (RNODE_BACK_REF(node)->nd_nth << 1)));
}
break;
}
@@ -9798,36 +11211,89 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_MATCH3:
CHECK(compile_match(iseq, ret, node, popped, type));
break;
- case NODE_LIT:{
- debugp_param("lit", node->nd_lit);
+ case NODE_SYM:{
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, rb_node_sym_string_val(node));
+ }
+ break;
+ }
+ case NODE_LINE:{
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, rb_node_line_lineno_val(node));
+ }
+ break;
+ }
+ case NODE_ENCODING:{
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, rb_node_encoding_val(node));
+ }
+ break;
+ }
+ case NODE_INTEGER:{
+ VALUE lit = rb_node_integer_literal_val(node);
+ if (!SPECIAL_CONST_P(lit)) RB_OBJ_SET_SHAREABLE(lit);
+ debugp_param("integer", lit);
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ }
+ break;
+ }
+ case NODE_FLOAT:{
+ VALUE lit = rb_node_float_literal_val(node);
+ if (!SPECIAL_CONST_P(lit)) RB_OBJ_SET_SHAREABLE(lit);
+ debugp_param("float", lit);
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ }
+ break;
+ }
+ case NODE_RATIONAL:{
+ VALUE lit = rb_node_rational_literal_val(node);
+ rb_ractor_make_shareable(lit);
+ debugp_param("rational", lit);
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ }
+ break;
+ }
+ case NODE_IMAGINARY:{
+ VALUE lit = rb_node_imaginary_literal_val(node);
+ rb_ractor_make_shareable(lit);
+ debugp_param("imaginary", lit);
if (!popped) {
- ADD_INSN1(ret, node, putobject, node->nd_lit);
- RB_OBJ_WRITTEN(iseq, Qundef, node->nd_lit);
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
break;
}
+ case NODE_FILE:
case NODE_STR:{
- debugp_param("nd_lit", node->nd_lit);
+ debugp_param("nd_lit", get_string_value(node));
if (!popped) {
- VALUE lit = node->nd_lit;
- if (!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
- lit = rb_fstring(lit);
- ADD_INSN1(ret, node, putstring, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
- }
- else {
- if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
- VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX(line));
- lit = rb_str_dup(lit);
- rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
- lit = rb_str_freeze(lit);
- }
- else {
- lit = rb_fstring(lit);
- }
+ VALUE lit = get_string_value(node);
+ const rb_compile_option_t *option = ISEQ_COMPILE_DATA(iseq)->option;
+ if ((option->debug_frozen_string_literal || RTEST(ruby_debug)) &&
+ option->frozen_string_literal != ISEQ_FROZEN_STRING_LITERAL_DISABLED) {
+ lit = rb_str_with_debug_created_info(lit, rb_iseq_path(iseq), line);
+ RB_OBJ_SET_SHAREABLE(lit);
+ }
+ switch (option->frozen_string_literal) {
+ case ISEQ_FROZEN_STRING_LITERAL_UNSET:
+ ADD_INSN1(ret, node, dupchilledstring, lit);
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
+ ADD_INSN1(ret, node, dupstring, lit);
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
ADD_INSN1(ret, node, putobject, lit);
- RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ break;
+ default:
+ rb_bug("invalid frozen_string_literal");
}
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
break;
}
@@ -9841,7 +11307,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_XSTR:{
ADD_CALL_RECEIVER(ret, node);
- VALUE str = rb_fstring(node->nd_lit);
+ VALUE str = rb_node_str_string_val(node);
ADD_INSN1(ret, node, putobject, str);
RB_OBJ_WRITTEN(iseq, Qundef, str);
ADD_CALL(ret, node, idBackquote, INT2FIX(1));
@@ -9862,20 +11328,24 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_EVSTR:
- CHECK(compile_evstr(iseq, ret, node->nd_body, popped));
+ CHECK(compile_evstr(iseq, ret, RNODE_EVSTR(node)->nd_body, popped));
break;
- case NODE_DREGX:{
- compile_dregx(iseq, ret, node);
-
- if (popped) {
- ADD_INSN(ret, node, pop);
+ case NODE_REGX:{
+ if (!popped) {
+ VALUE lit = rb_node_regx_string_val(node);
+ RB_OBJ_SET_SHAREABLE(lit);
+ ADD_INSN1(ret, node, putobject, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
break;
}
+ case NODE_DREGX:
+ compile_dregx(iseq, ret, node, popped);
+ break;
case NODE_ONCE:{
int ic_index = body->ise_size++;
const rb_iseq_t *block_iseq;
- block_iseq = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line);
+ block_iseq = NEW_CHILD_ISEQ(RNODE_ONCE(node)->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line);
ADD_INSN2(ret, node, once, block_iseq, INT2FIX(ic_index));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block_iseq);
@@ -9887,36 +11357,53 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_ARGSCAT:{
if (popped) {
- CHECK(COMPILE(ret, "argscat head", node->nd_head));
+ CHECK(COMPILE(ret, "argscat head", RNODE_ARGSCAT(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
- CHECK(COMPILE(ret, "argscat body", node->nd_body));
+ CHECK(COMPILE(ret, "argscat body", RNODE_ARGSCAT(node)->nd_body));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
}
else {
- CHECK(COMPILE(ret, "argscat head", node->nd_head));
- CHECK(COMPILE(ret, "argscat body", node->nd_body));
- ADD_INSN(ret, node, concatarray);
+ CHECK(COMPILE(ret, "argscat head", RNODE_ARGSCAT(node)->nd_head));
+ const NODE *body_node = RNODE_ARGSCAT(node)->nd_body;
+ if (nd_type_p(body_node, NODE_LIST)) {
+ CHECK(compile_array(iseq, ret, body_node, popped, FALSE) >= 0);
+ }
+ else {
+ CHECK(COMPILE(ret, "argscat body", body_node));
+ ADD_INSN(ret, node, concattoarray);
+ }
}
break;
}
case NODE_ARGSPUSH:{
if (popped) {
- CHECK(COMPILE(ret, "argspush head", node->nd_head));
+ CHECK(COMPILE(ret, "argspush head", RNODE_ARGSPUSH(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
- CHECK(COMPILE_(ret, "argspush body", node->nd_body, popped));
+ CHECK(COMPILE_(ret, "argspush body", RNODE_ARGSPUSH(node)->nd_body, popped));
}
else {
- CHECK(COMPILE(ret, "argspush head", node->nd_head));
- CHECK(compile_array_1(iseq, ret, node->nd_body));
- ADD_INSN(ret, node, concatarray);
+ CHECK(COMPILE(ret, "argspush head", RNODE_ARGSPUSH(node)->nd_head));
+ const NODE *body_node = RNODE_ARGSPUSH(node)->nd_body;
+ if (keyword_node_p(body_node)) {
+ CHECK(COMPILE_(ret, "array element", body_node, FALSE));
+ ADD_INSN(ret, node, pushtoarraykwsplat);
+ }
+ else if (static_literal_node_p(body_node, iseq, false)) {
+ ADD_INSN1(ret, body_node, putobject, static_literal_value(body_node, iseq));
+ ADD_INSN1(ret, node, pushtoarray, INT2FIX(1));
+ }
+ else {
+ CHECK(COMPILE_(ret, "array element", body_node, FALSE));
+ ADD_INSN1(ret, node, pushtoarray, INT2FIX(1));
+ }
}
break;
}
case NODE_SPLAT:{
- CHECK(COMPILE(ret, "splat", node->nd_head));
+ CHECK(COMPILE(ret, "splat", RNODE_SPLAT(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qtrue);
if (popped) {
@@ -9925,8 +11412,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_DEFN:{
- ID mid = node->nd_mid;
- const rb_iseq_t *method_iseq = NEW_ISEQ(node->nd_defn,
+ ID mid = RNODE_DEFN(node)->nd_mid;
+ const rb_iseq_t *method_iseq = NEW_ISEQ(RNODE_DEFN(node)->nd_defn,
rb_id2str(mid),
ISEQ_TYPE_METHOD, line);
@@ -9941,13 +11428,13 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_DEFS:{
- ID mid = node->nd_mid;
- const rb_iseq_t * singleton_method_iseq = NEW_ISEQ(node->nd_defn,
+ ID mid = RNODE_DEFS(node)->nd_mid;
+ const rb_iseq_t * singleton_method_iseq = NEW_ISEQ(RNODE_DEFS(node)->nd_defn,
rb_id2str(mid),
ISEQ_TYPE_METHOD, line);
debugp_param("defs/iseq", rb_iseqw_new(singleton_method_iseq));
- CHECK(COMPILE(ret, "defs: recv", node->nd_recv));
+ CHECK(COMPILE(ret, "defs: recv", RNODE_DEFS(node)->nd_recv));
ADD_INSN2(ret, node, definesmethod, ID2SYM(mid), singleton_method_iseq);
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_method_iseq);
@@ -9959,8 +11446,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_ALIAS:{
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
- CHECK(COMPILE(ret, "alias arg1", node->nd_1st));
- CHECK(COMPILE(ret, "alias arg2", node->nd_2nd));
+ CHECK(COMPILE(ret, "alias arg1", RNODE_ALIAS(node)->nd_1st));
+ CHECK(COMPILE(ret, "alias arg2", RNODE_ALIAS(node)->nd_2nd));
ADD_SEND(ret, node, id_core_set_method_alias, INT2FIX(3));
if (popped) {
@@ -9970,8 +11457,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_VALIAS:{
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(ret, node, putobject, ID2SYM(node->nd_alias));
- ADD_INSN1(ret, node, putobject, ID2SYM(node->nd_orig));
+ ADD_INSN1(ret, node, putobject, ID2SYM(RNODE_VALIAS(node)->nd_alias));
+ ADD_INSN1(ret, node, putobject, ID2SYM(RNODE_VALIAS(node)->nd_orig));
ADD_SEND(ret, node, id_core_set_variable_alias, INT2FIX(2));
if (popped) {
@@ -9980,10 +11467,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_UNDEF:{
- ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
- CHECK(COMPILE(ret, "undef arg", node->nd_undef));
- ADD_SEND(ret, node, id_core_undef_method, INT2FIX(2));
+ const rb_parser_ary_t *ary = RNODE_UNDEF(node)->nd_undefs;
+
+ for (long i = 0; i < ary->len; i++) {
+ ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
+ CHECK(COMPILE(ret, "undef arg", ary->data[i]));
+ ADD_SEND(ret, node, id_core_undef_method, INT2FIX(2));
+
+ if (i < ary->len - 1) {
+ ADD_INSN(ret, node, pop);
+ }
+ }
if (popped) {
ADD_INSN(ret, node, pop);
@@ -9991,15 +11486,15 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_CLASS:{
- const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(node->nd_body,
- rb_str_freeze(rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid))),
+ const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(RNODE_CLASS(node)->nd_body,
+ rb_str_freeze(rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(get_node_colon_nd_mid(RNODE_CLASS(node)->nd_cpath)))),
ISEQ_TYPE_CLASS, line);
const int flags = VM_DEFINECLASS_TYPE_CLASS |
- (node->nd_super ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) |
- compile_cpath(ret, iseq, node->nd_cpath);
+ (RNODE_CLASS(node)->nd_super ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) |
+ compile_cpath(ret, iseq, RNODE_CLASS(node)->nd_cpath);
- CHECK(COMPILE(ret, "super", node->nd_super));
- ADD_INSN3(ret, node, defineclass, ID2SYM(node->nd_cpath->nd_mid), class_iseq, INT2FIX(flags));
+ CHECK(COMPILE(ret, "super", RNODE_CLASS(node)->nd_super));
+ ADD_INSN3(ret, node, defineclass, ID2SYM(get_node_colon_nd_mid(RNODE_CLASS(node)->nd_cpath)), class_iseq, INT2FIX(flags));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)class_iseq);
if (popped) {
@@ -10008,14 +11503,14 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_MODULE:{
- const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(node->nd_body,
- rb_str_freeze(rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid))),
+ const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(RNODE_MODULE(node)->nd_body,
+ rb_str_freeze(rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(get_node_colon_nd_mid(RNODE_MODULE(node)->nd_cpath)))),
ISEQ_TYPE_CLASS, line);
const int flags = VM_DEFINECLASS_TYPE_MODULE |
- compile_cpath(ret, iseq, node->nd_cpath);
+ compile_cpath(ret, iseq, RNODE_MODULE(node)->nd_cpath);
ADD_INSN (ret, node, putnil); /* dummy */
- ADD_INSN3(ret, node, defineclass, ID2SYM(node->nd_cpath->nd_mid), module_iseq, INT2FIX(flags));
+ ADD_INSN3(ret, node, defineclass, ID2SYM(get_node_colon_nd_mid(RNODE_MODULE(node)->nd_cpath)), module_iseq, INT2FIX(flags));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)module_iseq);
if (popped) {
@@ -10025,15 +11520,26 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_SCLASS:{
ID singletonclass;
- const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_fstring_lit("singleton class"),
+ const rb_iseq_t *singleton_class = NEW_ISEQ(RNODE_SCLASS(node)->nd_body, rb_fstring_lit("singleton class"),
ISEQ_TYPE_CLASS, line);
- CHECK(COMPILE(ret, "sclass#recv", node->nd_recv));
+ CHECK(COMPILE(ret, "sclass#recv", RNODE_SCLASS(node)->nd_recv));
ADD_INSN (ret, node, putnil);
CONST_ID(singletonclass, "singletonclass");
+
+ /* `class << self` in a class body and `class << Foo` (constant
+ receiver) are stable. All other forms are potentially dynamic. */
+ int sclass_flags = VM_DEFINECLASS_TYPE_SINGLETON_CLASS;
+ const NODE *recv = RNODE_SCLASS(node)->nd_recv;
+ if (!(nd_type_p(recv, NODE_SELF) &&
+ ISEQ_BODY(iseq)->type == ISEQ_TYPE_CLASS) &&
+ !cpath_const_p(recv)) {
+ sclass_flags |= VM_DEFINECLASS_FLAG_DYNAMIC_CREF;
+ }
+
ADD_INSN3(ret, node, defineclass,
ID2SYM(singletonclass), singleton_class,
- INT2FIX(VM_DEFINECLASS_TYPE_SINGLETON_CLASS));
+ INT2FIX(sclass_flags));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_class);
if (popped) {
@@ -10097,7 +11603,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
case NODE_DEFINED:
if (!popped) {
- CHECK(compile_defined_expr(iseq, ret, node, Qtrue));
+ CHECK(compile_defined_expr(iseq, ret, node, Qtrue, false));
}
break;
case NODE_POSTEXE:{
@@ -10106,10 +11612,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
*/
int is_index = body->ise_size++;
struct rb_iseq_new_with_callback_callback_func *ifunc =
- rb_iseq_new_with_callback_new_callback(build_postexe_iseq, node->nd_body);
+ rb_iseq_new_with_callback_new_callback(build_postexe_iseq, RNODE_POSTEXE(node)->nd_body);
const rb_iseq_t *once_iseq =
- new_child_iseq_with_callback(iseq, ifunc,
- rb_fstring(make_name_for_block(iseq)), iseq, ISEQ_TYPE_BLOCK, line);
+ NEW_CHILD_ISEQ_WITH_CALLBACK(ifunc, rb_fstring(make_name_for_block(iseq)), ISEQ_TYPE_BLOCK, line);
ADD_INSN2(ret, node, once, once_iseq, INT2FIX(is_index));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)once_iseq);
@@ -10137,7 +11642,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
case NODE_LAMBDA:{
/* compile same as lambda{...} */
- const rb_iseq_t *block = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
+ const rb_iseq_t *block = NEW_CHILD_ISEQ(RNODE_LAMBDA(node)->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
VALUE argc = INT2FIX(0);
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
@@ -10257,7 +11762,7 @@ insn_data_to_s_detail(INSN *iobj)
{
const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT(iobj, j);
rb_str_cat2(str, "<calldata:");
- if (vm_ci_mid(ci)) rb_str_catf(str, "%"PRIsVALUE, rb_id2str(vm_ci_mid(ci)));
+ if (vm_ci_mid(ci)) rb_str_append(str, rb_id2str(vm_ci_mid(ci)));
rb_str_catf(str, ", %d>", vm_ci_argc(ci));
break;
}
@@ -10322,7 +11827,7 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
case ISEQ_ELEMENT_LABEL:
{
lobj = (LABEL *)link;
- printf(LABEL_FORMAT" [sp: %d]%s\n", lobj->label_no, lobj->sp,
+ printf(LABEL_FORMAT" [sp: %d, unremovable: %d, refcnt: %d]%s\n", lobj->label_no, lobj->sp, lobj->unremovable, lobj->refcnt,
dest == lobj ? " <---" : "");
break;
}
@@ -10340,7 +11845,7 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
}
default:
/* ignore */
- rb_raise(rb_eSyntaxError, "dump_disasm_list error: %ld\n", FIX2LONG(link->type));
+ rb_raise(rb_eSyntaxError, "dump_disasm_list error: %d\n", (int)link->type);
}
link = link->next;
}
@@ -10348,12 +11853,6 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
fflush(stdout);
}
-bool
-rb_insns_leaf_p(int i)
-{
- return insn_leaf_p(i);
-}
-
int
rb_insn_len(VALUE insn)
{
@@ -10374,7 +11873,7 @@ rb_insns_name_array(void)
for (i = 0; i < VM_INSTRUCTION_SIZE; i++) {
rb_ary_push(ary, rb_fstring_cstr(insn_name(i)));
}
- return rb_obj_freeze(ary);
+ return rb_ary_freeze(ary);
}
static LABEL *
@@ -10523,6 +12022,7 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op)
size_t n = rb_callinfo_kwarg_bytes(len);
kw_arg = xmalloc(n);
+ kw_arg->references = 0;
kw_arg->keyword_len = len;
for (i = 0; i < len; i++) {
VALUE kw = RARRAY_AREF(vkw_arg, i);
@@ -10548,6 +12048,7 @@ event_name_to_flag(VALUE sym)
CHECK_EVENT(RUBY_EVENT_RETURN);
CHECK_EVENT(RUBY_EVENT_B_CALL);
CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_RESCUE);
#undef CHECK_EVENT
return RUBY_EVENT_NONE;
}
@@ -10558,7 +12059,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
{
/* TODO: body should be frozen */
long i, len = RARRAY_LEN(body);
- struct st_table *labels_table = DATA_PTR(labels_wrapper);
+ struct st_table *labels_table = RTYPEDDATA_DATA(labels_wrapper);
int j;
int line_no = 0, node_id = -1, insn_idx = 0;
int ret = COMPILE_OK;
@@ -10615,12 +12116,11 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
if (argc > 0) {
- argv = compile_data_calloc2(iseq, sizeof(VALUE), argc);
+ argv = compile_data_calloc2_type(iseq, VALUE, argc);
// add element before operand setup to make GC root
- NODE dummy_line_node = generate_dummy_line_node(line_no, node_id);
ADD_ELEM(anchor,
- (LINK_ELEMENT*)new_insn_core(iseq, &dummy_line_node,
+ (LINK_ELEMENT*)new_insn_core(iseq, line_no, node_id,
(enum ruby_vminsn_type)insn_id, argc, argv));
for (j=0; j<argc; j++) {
@@ -10696,18 +12196,18 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
case TS_CDHASH:
{
int i;
- VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
+ VALUE map = cdhash_new(RARRAY_LEN(op) / 2);
- RHASH_TBL_RAW(map)->type = &cdhash_type;
op = rb_to_array_type(op);
for (i=0; i<RARRAY_LEN(op); i+=2) {
VALUE key = RARRAY_AREF(op, i);
VALUE sym = RARRAY_AREF(op, i+1);
LABEL *label =
register_label(iseq, labels_table, sym);
- rb_hash_aset(map, key, (VALUE)label | 1);
+ cdhash_aset(map, key, (VALUE)label);
}
RB_GC_GUARD(op);
+ RB_OBJ_SET_SHAREABLE(map); // allow mutation while compiling
argv[j] = map;
RB_OBJ_WRITTEN(iseq, Qundef, map);
}
@@ -10728,9 +12228,8 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
}
else {
- NODE dummy_line_node = generate_dummy_line_node(line_no, node_id);
ADD_ELEM(anchor,
- (LINK_ELEMENT*)new_insn_core(iseq, &dummy_line_node,
+ (LINK_ELEMENT*)new_insn_core(iseq, line_no, node_id,
(enum ruby_vminsn_type)insn_id, argc, NULL));
}
}
@@ -10738,7 +12237,8 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
rb_raise(rb_eTypeError, "unexpected object for instruction");
}
}
- DATA_PTR(labels_wrapper) = 0;
+ RTYPEDDATA_DATA(labels_wrapper) = 0;
+ RB_GC_GUARD(labels_wrapper);
validate_labels(iseq, labels_table);
if (!ret) return ret;
return iseq_setup(iseq, anchor);
@@ -10822,7 +12322,7 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
rb_raise(rb_eTypeError, "keyword default has unsupported len %+"PRIsVALUE, key);
}
ids[i] = SYM2ID(sym);
- dvs[j] = default_val;
+ RB_OBJ_WRITE(iseq, &dvs[j], default_val);
}
keyword->table = ids;
@@ -10831,55 +12331,49 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
return keyword;
}
+static void
+iseq_insn_each_object_mark_and_move(VALUE * obj, VALUE _)
+{
+ rb_gc_mark_and_move(obj);
+}
+
void
rb_iseq_mark_and_move_insn_storage(struct iseq_compile_data_storage *storage)
{
INSN *iobj = 0;
size_t size = sizeof(INSN);
+ size_t align = ALIGNMENT_SIZE_OF(INSN);
unsigned int pos = 0;
while (storage) {
-#ifdef STRICT_ALIGNMENT
- size_t padding = calc_padding((void *)&storage->buff[pos], size);
-#else
- const size_t padding = 0; /* expected to be optimized by compiler */
-#endif /* STRICT_ALIGNMENT */
+ size_t padding = calc_padding((void *)&storage->buff[pos], align);
size_t offset = pos + size + padding;
if (offset > storage->size || offset > storage->pos) {
pos = 0;
storage = storage->next;
}
else {
-#ifdef STRICT_ALIGNMENT
pos += (int)padding;
-#endif /* STRICT_ALIGNMENT */
iobj = (INSN *)&storage->buff[pos];
if (iobj->operands) {
- int j;
- const char *types = insn_op_types(iobj->insn_id);
-
- for (j = 0; types[j]; j++) {
- char type = types[j];
- switch (type) {
- case TS_CDHASH:
- case TS_ISEQ:
- case TS_VALUE:
- case TS_IC: // constant path array
- case TS_CALLDATA: // ci is stored.
- rb_gc_mark_and_move(&OPERAND_AT(iobj, j));
- break;
- default:
- break;
- }
- }
+ iseq_insn_each_markable_object(iobj, iseq_insn_each_object_mark_and_move, (VALUE)0);
}
pos += (int)size;
}
}
}
+static const rb_data_type_t labels_wrapper_type = {
+ .wrap_struct_name = "compiler/labels_wrapper",
+ .function = {
+ .dmark = (RUBY_DATA_FUNC)rb_mark_set,
+ .dfree = (RUBY_DATA_FUNC)st_free_table,
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+
void
rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
VALUE exception, VALUE body)
@@ -10889,7 +12383,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
unsigned int arg_size, local_size, stack_max;
ID *tbl;
struct st_table *labels_table = st_init_numtable();
- VALUE labels_wrapper = Data_Wrap_Struct(0, rb_mark_set, st_free_table, labels_table);
+ VALUE labels_wrapper = TypedData_Wrap_Struct(0, &labels_wrapper_type, labels_table);
VALUE arg_opt_labels = rb_hash_aref(params, SYM(opt));
VALUE keywords = rb_hash_aref(params, SYM(keyword));
VALUE sym_arg_rest = ID2SYM(rb_intern_const("#arg_rest"));
@@ -10971,6 +12465,10 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
ISEQ_BODY(iseq)->param.flags.ambiguous_param0 = TRUE;
}
+ if (Qtrue == rb_hash_aref(params, SYM(use_block))) {
+ ISEQ_BODY(iseq)->param.flags.use_block = TRUE;
+ }
+
if (int_param(&i, params, SYM(kwrest))) {
struct rb_iseq_param_keyword *keyword = (struct rb_iseq_param_keyword *)ISEQ_BODY(iseq)->param.keyword;
if (keyword == NULL) {
@@ -11046,28 +12544,38 @@ rb_local_defined(ID id, const rb_iseq_t *iseq)
#define IBF_ISEQ_ENABLE_LOCAL_BUFFER 0
#endif
-typedef unsigned int ibf_offset_t;
+typedef uint32_t ibf_offset_t;
#define IBF_OFFSET(ptr) ((ibf_offset_t)(VALUE)(ptr))
#define IBF_MAJOR_VERSION ISEQ_MAJOR_VERSION
#ifdef RUBY_DEVEL
-#define IBF_DEVEL_VERSION 4
+#define IBF_DEVEL_VERSION 5
#define IBF_MINOR_VERSION (ISEQ_MINOR_VERSION * 10000 + IBF_DEVEL_VERSION)
#else
#define IBF_MINOR_VERSION ISEQ_MINOR_VERSION
#endif
+static const char IBF_ENDIAN_MARK =
+#ifdef WORDS_BIGENDIAN
+ 'b'
+#else
+ 'l'
+#endif
+ ;
+
struct ibf_header {
char magic[4]; /* YARB */
- unsigned int major_version;
- unsigned int minor_version;
- unsigned int size;
- unsigned int extra_size;
+ uint32_t major_version;
+ uint32_t minor_version;
+ uint32_t size;
+ uint32_t extra_size;
- unsigned int iseq_list_size;
- unsigned int global_object_list_size;
+ uint32_t iseq_list_size;
+ uint32_t global_object_list_size;
ibf_offset_t iseq_list_offset;
ibf_offset_t global_object_list_offset;
+ uint8_t endian;
+ uint8_t wordsize; /* assume no 2048-bit CPU */
};
struct ibf_dump_buffer {
@@ -11102,7 +12610,7 @@ struct ibf_load {
struct pinned_list {
long size;
- VALUE * buffer;
+ VALUE buffer[1];
};
static void
@@ -11117,25 +12625,14 @@ pinned_list_mark(void *ptr)
}
}
-static void
-pinned_list_free(void *ptr)
-{
- struct pinned_list *list = (struct pinned_list *)ptr;
- xfree(list->buffer);
- xfree(ptr);
-}
-
-static size_t
-pinned_list_memsize(const void *ptr)
-{
- struct pinned_list *list = (struct pinned_list *)ptr;
- return sizeof(struct pinned_list) + (list->size * sizeof(VALUE *));
-}
-
static const rb_data_type_t pinned_list_type = {
"pinned_list",
- {pinned_list_mark, pinned_list_free, pinned_list_memsize,},
- 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+ {
+ pinned_list_mark,
+ RUBY_DEFAULT_FREE,
+ NULL, // No external memory to report,
+ },
+ 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
static VALUE
@@ -11169,13 +12666,10 @@ pinned_list_store(VALUE list, long offset, VALUE object)
static VALUE
pinned_list_new(long size)
{
- struct pinned_list * ptr;
- VALUE obj_list =
- TypedData_Make_Struct(0, struct pinned_list, &pinned_list_type, ptr);
-
- ptr->buffer = xcalloc(size, sizeof(VALUE));
+ size_t memsize = offsetof(struct pinned_list, buffer) + size * sizeof(VALUE);
+ VALUE obj_list = rb_data_typed_object_zalloc(0, memsize, &pinned_list_type);
+ struct pinned_list * ptr = RTYPEDDATA_GET_DATA(obj_list);
ptr->size = size;
-
return obj_list;
}
@@ -11214,8 +12708,13 @@ static ibf_offset_t
ibf_dump_write(struct ibf_dump *dump, const void *buff, unsigned long size)
{
ibf_offset_t pos = ibf_dump_pos(dump);
+#if SIZEOF_LONG > SIZEOF_INT
+ /* ensure the resulting dump does not exceed UINT_MAX */
+ if (size >= UINT_MAX || pos + size >= UINT_MAX) {
+ rb_raise(rb_eRuntimeError, "dump size exceeds");
+ }
+#endif
rb_str_cat(dump->current_buffer->str, (const char *)buff, size);
- /* TODO: overflow check */
return pos;
}
@@ -11324,6 +12823,10 @@ ibf_load_id(const struct ibf_load *load, const ID id_index)
return 0;
}
VALUE sym = ibf_load_object(load, id_index);
+ if (rb_integer_type_p(sym)) {
+ /* Load hidden local variables as indexes */
+ return NUM2ULONG(sym);
+ }
return rb_sym2id(sym);
}
@@ -11449,7 +12952,8 @@ ibf_load_builtin(const struct ibf_load *load, ibf_offset_t *offset)
const struct rb_builtin_function *table = GET_VM()->builtin_function_table;
if (table == NULL) rb_raise(rb_eArgError, "builtin function table is not provided");
if (strncmp(table[i].name, name, len) != 0) {
- rb_raise(rb_eArgError, "builtin function index (%d) mismatch (expect %s but %s)", i, name, table[i].name);
+ rb_raise(rb_eArgError, "builtin function index (%d) mismatch (expect %.*s but %s)",
+ i, len, name, table[i].name);
}
// fprintf(stderr, "load-builtin: name:%s(%d)\n", table[i].name, table[i].argc);
@@ -11523,7 +13027,7 @@ ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_dump_write_small_value(dump, wv);
skip_wv:;
}
- assert(insn_len(insn) == op_index+1);
+ RUBY_ASSERT(insn_len(insn) == op_index+1);
}
return offset;
@@ -11535,21 +13039,23 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
VALUE iseqv = (VALUE)iseq;
unsigned int code_index;
ibf_offset_t reading_pos = bytecode_offset;
- VALUE *code = ALLOC_N(VALUE, iseq_size);
+ VALUE *code = ZALLOC_N(VALUE, iseq_size);
struct rb_iseq_constant_body *load_body = ISEQ_BODY(iseq);
struct rb_call_data *cd_entries = load_body->call_data;
int ic_index = 0;
- iseq_bits_t * mark_offset_bits;
-
- iseq_bits_t tmp[1] = {0};
+ load_body->iseq_encoded = code;
+ load_body->iseq_size = iseq_size;
+ iseq_bits_t * mark_offset_bits;
if (ISEQ_MBITS_BUFLEN(iseq_size) == 1) {
- mark_offset_bits = tmp;
+ load_body->mark_bits.single = 0;
+ mark_offset_bits = &load_body->mark_bits.single;
}
else {
- mark_offset_bits = ZALLOC_N(iseq_bits_t, ISEQ_MBITS_BUFLEN(iseq_size));
+ load_body->mark_bits.list = ZALLOC_N(iseq_bits_t, ISEQ_MBITS_BUFLEN(iseq_size));
+ mark_offset_bits = load_body->mark_bits.list;
}
bool needs_bitmap = false;
@@ -11581,10 +13087,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
{
VALUE op = ibf_load_small_value(load, &reading_pos);
VALUE v = ibf_load_object(load, op);
- v = rb_hash_dup(v); // hash dumped as frozen
- RHASH_TBL_RAW(v)->type = &cdhash_type;
- rb_hash_rehash(v); // hash function changed
- freeze_hide_obj(v);
// Overwrite the existing hash in the object list. This
// is to keep the object alive during load time.
@@ -11635,12 +13137,12 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
if (insn == BIN(setinstancevariable)) {
ID iv_name = (ID)code[code_index - 1];
cache->iv_set_name = iv_name;
+ cache->value = IVAR_CACHE_INIT;
}
else {
cache->iv_set_name = 0;
+ cache->value = rb_getivar_cache_pack(ROOT_SHAPE_ID, ATTR_INDEX_NOT_SET);
}
-
- vm_ic_attr_index_initialize(cache, INVALID_SHAPE_ID);
}
}
@@ -11672,24 +13174,13 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
}
}
- load_body->iseq_encoded = code;
- load_body->iseq_size = code_index;
-
- if (ISEQ_MBITS_BUFLEN(load_body->iseq_size) == 1) {
- load_body->mark_bits.single = mark_offset_bits[0];
- }
- else {
- if (needs_bitmap) {
- load_body->mark_bits.list = mark_offset_bits;
- }
- else {
- load_body->mark_bits.list = 0;
- ruby_xfree(mark_offset_bits);
- }
+ if (!needs_bitmap) {
+ SIZED_FREE_N(load_body->mark_bits.list, ISEQ_MBITS_BUFLEN(iseq_size));
+ load_body->mark_bits.list = NULL;
}
- assert(code_index == iseq_size);
- assert(reading_pos == bytecode_offset + bytecode_size);
+ RUBY_ASSERT(code_index == iseq_size);
+ RUBY_ASSERT(reading_pos == bytecode_offset + bytecode_size);
return code;
}
@@ -11750,19 +13241,17 @@ ibf_load_param_keyword(const struct ibf_load *load, ibf_offset_t param_keyword_o
{
if (param_keyword_offset) {
struct rb_iseq_param_keyword *kw = IBF_R(param_keyword_offset, struct rb_iseq_param_keyword, 1);
- ID *ids = IBF_R(kw->table, ID, kw->num);
int dv_num = kw->num - kw->required_num;
- VALUE *dvs = IBF_R(kw->default_values, VALUE, dv_num);
- int i;
+ VALUE *dvs = dv_num ? IBF_R(kw->default_values, VALUE, dv_num) : NULL;
- for (i=0; i<kw->num; i++) {
- ids[i] = ibf_load_id(load, ids[i]);
- }
+ int i;
for (i=0; i<dv_num; i++) {
dvs[i] = ibf_load_object(load, dvs[i]);
}
- kw->table = ids;
+ // Will be set once the local table is loaded.
+ kw->table = NULL;
+
kw->default_values = dvs;
return kw;
}
@@ -11847,14 +13336,19 @@ ibf_dump_local_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
int i;
for (i=0; i<size; i++) {
- table[i] = ibf_dump_id(dump, body->local_table[i]);
+ VALUE v = ibf_dump_id(dump, body->local_table[i]);
+ if (v == 0) {
+ /* Dump hidden local variables as indexes, so load_from_binary will work with them */
+ v = ibf_dump_object(dump, ULONG2NUM(body->local_table[i]));
+ }
+ table[i] = v;
}
IBF_W_ALIGN(ID);
return ibf_dump_write(dump, table, sizeof(ID) * size);
}
-static ID *
+static const ID *
ibf_load_local_table(const struct ibf_load *load, ibf_offset_t local_table_offset, int size)
{
if (size > 0) {
@@ -11864,7 +13358,14 @@ ibf_load_local_table(const struct ibf_load *load, ibf_offset_t local_table_offse
for (i=0; i<size; i++) {
table[i] = ibf_load_id(load, table[i]);
}
- return table;
+
+ if (size == 1 && table[0] == idERROR_INFO) {
+ ruby_xfree_sized(table, sizeof(ID) * size);
+ return rb_iseq_shared_exc_local_tbl;
+ }
+ else {
+ return table;
+ }
}
else {
return NULL;
@@ -11872,6 +13373,28 @@ ibf_load_local_table(const struct ibf_load *load, ibf_offset_t local_table_offse
}
static ibf_offset_t
+ibf_dump_lvar_states(struct ibf_dump *dump, const rb_iseq_t *iseq)
+{
+ const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
+ const int size = body->local_table_size;
+ IBF_W_ALIGN(enum lvar_state);
+ return ibf_dump_write(dump, body->lvar_states, sizeof(enum lvar_state) * (body->lvar_states ? size : 0));
+}
+
+static enum lvar_state *
+ibf_load_lvar_states(const struct ibf_load *load, ibf_offset_t lvar_states_offset, int size, const ID *local_table)
+{
+ if (local_table == rb_iseq_shared_exc_local_tbl ||
+ size <= 0) {
+ return NULL;
+ }
+ else {
+ enum lvar_state *states = IBF_R(lvar_states_offset, enum lvar_state, size);
+ return states;
+ }
+}
+
+static ibf_offset_t
ibf_dump_catch_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
const struct iseq_catch_table *table = ISEQ_BODY(iseq)->catch_table;
@@ -11901,12 +13424,13 @@ ibf_dump_catch_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
}
}
-static struct iseq_catch_table *
-ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offset, unsigned int size)
+static void
+ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offset, unsigned int size, const rb_iseq_t *parent_iseq)
{
if (size) {
- struct iseq_catch_table *table = ruby_xmalloc(iseq_catch_table_bytes(size));
+ struct iseq_catch_table *table = ruby_xcalloc(1, iseq_catch_table_bytes(size));
table->size = size;
+ ISEQ_BODY(parent_iseq)->catch_table = table;
ibf_offset_t reading_pos = catch_table_offset;
@@ -11919,12 +13443,12 @@ ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offse
table->entries[i].cont = (unsigned int)ibf_load_small_value(load, &reading_pos);
table->entries[i].sp = (unsigned int)ibf_load_small_value(load, &reading_pos);
- table->entries[i].iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)iseq_index);
+ rb_iseq_t *catch_iseq = (rb_iseq_t *)ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)iseq_index);
+ RB_OBJ_WRITE(parent_iseq, UNALIGNED_MEMBER_PTR(&table->entries[i], iseq), catch_iseq);
}
- return table;
}
else {
- return NULL;
+ ISEQ_BODY(parent_iseq)->catch_table = NULL;
}
}
@@ -11968,15 +13492,44 @@ ibf_dump_ci_entries(struct ibf_dump *dump, const rb_iseq_t *iseq)
return offset;
}
+struct outer_variable_pair {
+ ID id;
+ VALUE name;
+ VALUE val;
+};
+
+struct outer_variable_list {
+ size_t num;
+ struct outer_variable_pair pairs[1];
+};
+
static enum rb_id_table_iterator_result
-dump_outer_variable(ID id, VALUE val, void *dump)
+store_outer_variable(ID id, VALUE val, void *dump)
{
- ibf_dump_write_small_value(dump, ibf_dump_id(dump, id));
- ibf_dump_write_small_value(dump, val);
-
+ struct outer_variable_list *ovlist = dump;
+ struct outer_variable_pair *pair = &ovlist->pairs[ovlist->num++];
+ pair->id = id;
+ pair->name = rb_id2str(id);
+ pair->val = val;
return ID_TABLE_CONTINUE;
}
+static int
+outer_variable_cmp(const void *a, const void *b, void *arg)
+{
+ const struct outer_variable_pair *ap = (const struct outer_variable_pair *)a;
+ const struct outer_variable_pair *bp = (const struct outer_variable_pair *)b;
+
+ if (!ap->name) {
+ return -1;
+ }
+ else if (!bp->name) {
+ return 1;
+ }
+
+ return rb_str_cmp(ap->name, bp->name);
+}
+
static ibf_offset_t
ibf_dump_outer_variables(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
@@ -11984,12 +13537,24 @@ ibf_dump_outer_variables(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_offset_t offset = ibf_dump_pos(dump);
- if (ovs) {
- ibf_dump_write_small_value(dump, (VALUE)rb_id_table_size(ovs));
- rb_id_table_foreach(ovs, dump_outer_variable, (void *)dump);
- }
- else {
- ibf_dump_write_small_value(dump, (VALUE)0);
+ size_t size = ovs ? rb_id_table_size(ovs) : 0;
+ ibf_dump_write_small_value(dump, (VALUE)size);
+ if (size > 0) {
+ VALUE buff;
+ size_t buffsize =
+ rb_size_mul_add_or_raise(sizeof(struct outer_variable_pair), size,
+ offsetof(struct outer_variable_list, pairs),
+ rb_eArgError);
+ struct outer_variable_list *ovlist = RB_ALLOCV(buff, buffsize);
+ ovlist->num = 0;
+ rb_id_table_foreach(ovs, store_outer_variable, ovlist);
+ ruby_qsort(ovlist->pairs, size, sizeof(struct outer_variable_pair), outer_variable_cmp, NULL);
+ for (size_t i = 0; i < size; ++i) {
+ ID id = ovlist->pairs[i].id;
+ ID val = ovlist->pairs[i].val;
+ ibf_dump_write_small_value(dump, ibf_dump_id(dump, id));
+ ibf_dump_write_small_value(dump, val);
+ }
}
return offset;
@@ -12002,6 +13567,11 @@ ibf_load_ci_entries(const struct ibf_load *load,
unsigned int ci_size,
struct rb_call_data **cd_ptr)
{
+ if (!ci_size) {
+ *cd_ptr = NULL;
+ return;
+ }
+
ibf_offset_t reading_pos = ci_entries_offset;
unsigned int i;
@@ -12020,6 +13590,7 @@ ibf_load_ci_entries(const struct ibf_load *load,
int kwlen = (int)ibf_load_small_value(load, &reading_pos);
if (kwlen > 0) {
kwarg = rb_xmalloc_mul_add(kwlen, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ kwarg->references = 0;
kwarg->keyword_len = kwlen;
for (int j=0; j<kwlen; j++) {
VALUE keyword = ibf_load_small_value(load, &reading_pos);
@@ -12065,7 +13636,7 @@ ibf_load_outer_variables(const struct ibf_load * load, ibf_offset_t outer_variab
static ibf_offset_t
ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- assert(dump->current_buffer == &dump->global_buffer);
+ RUBY_ASSERT(dump->current_buffer == &dump->global_buffer);
unsigned int *positions;
@@ -12093,9 +13664,10 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
positions = rb_iseq_insns_info_decode_positions(ISEQ_BODY(iseq));
const ibf_offset_t insns_info_positions_offset = ibf_dump_insns_info_positions(dump, positions, body->insns_info.size);
- ruby_xfree(positions);
+ SIZED_FREE_N(positions, ISEQ_BODY(iseq)->insns_info.size);
const ibf_offset_t local_table_offset = ibf_dump_local_table(dump, iseq);
+ const ibf_offset_t lvar_states_offset = ibf_dump_lvar_states(dump, iseq);
const unsigned int catch_table_size = body->catch_table ? body->catch_table->size : 0;
const ibf_offset_t catch_table_offset = ibf_dump_catch_table(dump, iseq);
const int parent_iseq_index = ibf_dump_iseq(dump, ISEQ_BODY(iseq)->parent_iseq);
@@ -12124,7 +13696,12 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
(body->param.flags.has_block << 6) |
(body->param.flags.ambiguous_param0 << 7) |
(body->param.flags.accepts_no_kwarg << 8) |
- (body->param.flags.ruby2_keywords << 9);
+ (body->param.flags.ruby2_keywords << 9) |
+ (body->param.flags.anon_rest << 10) |
+ (body->param.flags.anon_kwrest << 11) |
+ (body->param.flags.use_block << 12) |
+ (body->param.flags.forwardable << 13) |
+ (body->param.flags.accepts_no_block << 14);
#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
# define IBF_BODY_OFFSET(x) (x)
@@ -12159,6 +13736,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(insns_info_positions_offset));
ibf_dump_write_small_value(dump, body->insns_info.size);
ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(local_table_offset));
+ ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(lvar_states_offset));
ibf_dump_write_small_value(dump, catch_table_size);
ibf_dump_write_small_value(dump, IBF_BODY_OFFSET(catch_table_offset));
ibf_dump_write_small_value(dump, parent_iseq_index);
@@ -12174,8 +13752,8 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_dump_write_small_value(dump, body->ic_size);
ibf_dump_write_small_value(dump, body->ci_size);
ibf_dump_write_small_value(dump, body->stack_max);
- ibf_dump_write_small_value(dump, body->catch_except_p);
ibf_dump_write_small_value(dump, body->builtin_attrs);
+ ibf_dump_write_small_value(dump, body->prism ? 1 : 0);
#undef IBF_BODY_OFFSET
@@ -12270,6 +13848,7 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
const ibf_offset_t insns_info_positions_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
const unsigned int insns_info_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
const ibf_offset_t local_table_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
+ const ibf_offset_t lvar_states_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
const unsigned int catch_table_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
const ibf_offset_t catch_table_offset = (ibf_offset_t)IBF_BODY_OFFSET(ibf_load_small_value(load, &reading_pos));
const int parent_iseq_index = (int)ibf_load_small_value(load, &reading_pos);
@@ -12287,8 +13866,8 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
const unsigned int ci_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
const unsigned int stack_max = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const char catch_except_p = (char)ibf_load_small_value(load, &reading_pos);
const unsigned int builtin_attrs = (unsigned int)ibf_load_small_value(load, &reading_pos);
+ const bool prism = (bool)ibf_load_small_value(load, &reading_pos);
// setup fname and dummy frame
VALUE path = ibf_load_object(load, location_pathobj_index);
@@ -12338,6 +13917,11 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
load_body->param.flags.ambiguous_param0 = (param_flags >> 7) & 1;
load_body->param.flags.accepts_no_kwarg = (param_flags >> 8) & 1;
load_body->param.flags.ruby2_keywords = (param_flags >> 9) & 1;
+ load_body->param.flags.anon_rest = (param_flags >> 10) & 1;
+ load_body->param.flags.anon_kwrest = (param_flags >> 11) & 1;
+ load_body->param.flags.use_block = (param_flags >> 12) & 1;
+ load_body->param.flags.forwardable = (param_flags >> 13) & 1;
+ load_body->param.flags.accepts_no_block = (param_flags >> 14) & 1;
load_body->param.size = param_size;
load_body->param.lead_num = param_lead_num;
load_body->param.opt_num = param_opt_num;
@@ -12360,14 +13944,20 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
load_body->location.code_location.beg_pos.column = location_code_location_beg_pos_column;
load_body->location.code_location.end_pos.lineno = location_code_location_end_pos_lineno;
load_body->location.code_location.end_pos.column = location_code_location_end_pos_column;
- load_body->catch_except_p = catch_except_p;
load_body->builtin_attrs = builtin_attrs;
+ load_body->prism = prism;
load_body->ivc_size = ivc_size;
load_body->icvarc_size = icvarc_size;
load_body->ise_size = ise_size;
load_body->ic_size = ic_size;
- load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(load_body));
+
+ if (ISEQ_IS_SIZE(load_body)) {
+ load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(load_body));
+ }
+ else {
+ load_body->is_entries = NULL;
+ }
ibf_load_ci_entries(load, ci_entries_offset, ci_size, &load_body->call_data);
load_body->outer_variables = ibf_load_outer_variables(load, outer_variables_offset);
load_body->param.opt_table = ibf_load_param_opt_table(load, param_opt_table_offset, param_opt_num);
@@ -12376,10 +13966,23 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
load_body->insns_info.body = ibf_load_insns_info_body(load, insns_info_body_offset, insns_info_size);
load_body->insns_info.positions = ibf_load_insns_info_positions(load, insns_info_positions_offset, insns_info_size);
load_body->local_table = ibf_load_local_table(load, local_table_offset, local_table_size);
- load_body->catch_table = ibf_load_catch_table(load, catch_table_offset, catch_table_size);
- load_body->parent_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)parent_iseq_index);
- load_body->local_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)local_iseq_index);
- load_body->mandatory_only_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)mandatory_only_iseq_index);
+ load_body->lvar_states = ibf_load_lvar_states(load, lvar_states_offset, local_table_size, load_body->local_table);
+ ibf_load_catch_table(load, catch_table_offset, catch_table_size, iseq);
+
+ const rb_iseq_t *parent_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)parent_iseq_index);
+ const rb_iseq_t *local_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)local_iseq_index);
+ const rb_iseq_t *mandatory_only_iseq = ibf_load_iseq(load, (const rb_iseq_t *)(VALUE)mandatory_only_iseq_index);
+
+ RB_OBJ_WRITE(iseq, &load_body->parent_iseq, parent_iseq);
+ RB_OBJ_WRITE(iseq, &load_body->local_iseq, local_iseq);
+ RB_OBJ_WRITE(iseq, &load_body->mandatory_only_iseq, mandatory_only_iseq);
+
+ // This must be done after the local table is loaded.
+ if (load_body->param.keyword != NULL) {
+ RUBY_ASSERT(load_body->local_table);
+ struct rb_iseq_param_keyword *keyword = (struct rb_iseq_param_keyword *) load_body->param.keyword;
+ keyword->table = &load_body->local_table[keyword->bits_start - keyword->num];
+ }
ibf_load_code(load, iseq, bytecode_offset, bytecode_size, iseq_size);
#if VM_INSN_INFO_TABLE_IMPL == 2
@@ -12446,8 +14049,6 @@ ibf_dump_iseq_list(struct ibf_dump *dump, struct ibf_header *header)
header->iseq_list_size = (unsigned int)size;
}
-#define IBF_OBJECT_INTERNAL FL_PROMOTED0
-
/*
* Binary format
* - ibf_object_header
@@ -12507,7 +14108,11 @@ struct ibf_object_symbol {
#define IBF_ALIGNED_OFFSET(align, offset) /* offset > 0 */ \
((((offset) - 1) / (align) + 1) * (align))
-#define IBF_OBJBODY(type, offset) (const type *)\
+/* No cast, since it's UB to create an unaligned pointer.
+ * Leave as void* for use with memcpy in those cases.
+ * We align the offset, but the buffer pointer is only VALUE aligned,
+ * so the returned pointer may be unaligned for `type` .*/
+#define IBF_OBJBODY(type, offset) \
ibf_load_check_offset(load, IBF_ALIGNED_OFFSET(RUBY_ALIGNOF(type), offset))
static const void *
@@ -12602,8 +14207,12 @@ ibf_dump_object_float(struct ibf_dump *dump, VALUE obj)
static VALUE
ibf_load_object_float(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
- const double *dblp = IBF_OBJBODY(double, offset);
- return DBL2NUM(*dblp);
+ double d;
+ /* Avoid unaligned VFP load on ARMv7; IBF payload may be unaligned (C99 6.3.2.3 p7). */
+ memcpy(&d, IBF_OBJBODY(double, offset), sizeof(d));
+ VALUE f = DBL2NUM(d);
+ if (!FLONUM_P(f)) RB_OBJ_SET_SHAREABLE(f);
+ return f;
}
static void
@@ -12640,7 +14249,7 @@ ibf_load_object_string(const struct ibf_load *load, const struct ibf_object_head
VALUE str;
if (header->frozen && !header->internal) {
- str = rb_enc_interned_str(ptr, len, rb_enc_from_index(encindex));
+ str = rb_enc_literal_str(ptr, len, rb_enc_from_index(encindex));
}
else {
str = rb_enc_str_new(ptr, len, rb_enc_from_index(encindex));
@@ -12674,7 +14283,7 @@ ibf_load_object_regexp(const struct ibf_load *load, const struct ibf_object_head
VALUE reg = rb_reg_compile(srcstr, (int)regexp.option, NULL, 0);
if (header->internal) rb_obj_hide(reg);
- if (header->frozen) rb_obj_freeze(reg);
+ if (header->frozen) RB_OBJ_SET_SHAREABLE(rb_obj_freeze(reg));
return reg;
}
@@ -12705,7 +14314,10 @@ ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_heade
rb_ary_push(ary, ibf_load_object(load, index));
}
- if (header->frozen) rb_obj_freeze(ary);
+ if (header->frozen) {
+ rb_ary_freeze(ary);
+ rb_ractor_make_shareable(ary); // TODO: check elements
+ }
return ary;
}
@@ -12736,7 +14348,7 @@ static VALUE
ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
long len = (long)ibf_load_small_value(load, &offset);
- VALUE obj = rb_hash_new_with_size(len);
+ VALUE obj = header->frozen ? rb_hash_alloc_fixed_size(rb_cHash, len) : rb_hash_new_with_size(len);
int i;
for (i = 0; i < len; i++) {
@@ -12747,10 +14359,59 @@ ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header
VALUE val = ibf_load_object(load, val_index);
rb_hash_aset(obj, key, val);
}
- rb_hash_rehash(obj);
if (header->internal) rb_obj_hide(obj);
- if (header->frozen) rb_obj_freeze(obj);
+ if (header->frozen) {
+ RB_OBJ_SET_FROZEN_SHAREABLE(obj);
+ }
+
+ return obj;
+}
+
+static int
+ibf_dump_cdhash_i(st_data_t key, st_data_t val, st_data_t ptr)
+{
+ struct ibf_dump *dump = (struct ibf_dump *)ptr;
+
+ VALUE key_index = ibf_dump_object(dump, (VALUE)key);
+
+ ibf_dump_write_small_value(dump, key_index);
+ ibf_dump_write_small_value(dump, val);
+ return ST_CONTINUE;
+}
+
+static void
+ibf_dump_object_imemo(struct ibf_dump *dump, VALUE obj)
+{
+ switch (imemo_type(obj)) {
+ case imemo_cdhash: {
+ st_table *tbl = rb_imemo_cdhash_tbl(obj);
+
+ long len = tbl->num_entries;
+ ibf_dump_write_small_value(dump, (VALUE)len);
+ if (len > 0) st_foreach(tbl, ibf_dump_cdhash_i, (VALUE)dump);
+ break;
+ }
+ default:
+ ibf_dump_object_unsupported(dump, obj);
+ break;
+ }
+}
+
+static VALUE
+ibf_load_object_imemo(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
+{
+ long len = (long)ibf_load_small_value(load, &offset);
+ VALUE obj = cdhash_new(len);
+
+ int i;
+ for (i = 0; i < len; i++) {
+ VALUE key_index = ibf_load_small_value(load, &offset);
+ VALUE val = ibf_load_small_value(load, &offset);
+
+ VALUE key = ibf_load_object(load, key_index);
+ cdhash_aset(obj, key, val);
+ }
return obj;
}
@@ -12786,7 +14447,7 @@ ibf_load_object_struct(const struct ibf_load *load, const struct ibf_object_head
VALUE end = ibf_load_object(load, range->end);
VALUE obj = rb_range_new(beg, end, range->excl);
if (header->internal) rb_obj_hide(obj);
- if (header->frozen) rb_obj_freeze(obj);
+ if (header->frozen) RB_OBJ_SET_FROZEN_SHAREABLE(obj);
return obj;
}
@@ -12807,10 +14468,14 @@ ibf_load_object_bignum(const struct ibf_load *load, const struct ibf_object_head
const struct ibf_object_bignum *bignum = IBF_OBJBODY(struct ibf_object_bignum, offset);
int sign = bignum->slen > 0;
ssize_t len = sign > 0 ? bignum->slen : -1 * bignum->slen;
- VALUE obj = rb_integer_unpack(bignum->digits, len * 2, 2, 0,
- INTEGER_PACK_LITTLE_ENDIAN | (sign == 0 ? INTEGER_PACK_NEGATIVE : 0));
+ const int big_unpack_flags = /* c.f. rb_big_unpack() */
+ INTEGER_PACK_LSWORD_FIRST |
+ INTEGER_PACK_NATIVE_BYTE_ORDER;
+ VALUE obj = rb_integer_unpack(bignum->digits, len, sizeof(BDIGIT), 0,
+ big_unpack_flags |
+ (sign == 0 ? INTEGER_PACK_NEGATIVE : 0));
if (header->internal) rb_obj_hide(obj);
- if (header->frozen) rb_obj_freeze(obj);
+ if (header->frozen) RB_OBJ_SET_FROZEN_SHAREABLE(obj);
return obj;
}
@@ -12871,7 +14536,7 @@ ibf_load_object_complex_rational(const struct ibf_load *load, const struct ibf_o
rb_complex_new(a, b) : rb_rational_new(a, b);
if (header->internal) rb_obj_hide(obj);
- if (header->frozen) rb_obj_freeze(obj);
+ if (header->frozen) rb_ractor_make_shareable(rb_obj_freeze(obj));
return obj;
}
@@ -12927,7 +14592,7 @@ static const ibf_dump_object_function dump_object_functions[RUBY_T_MASK+1] = {
ibf_dump_object_unsupported, /* 0x17 */
ibf_dump_object_unsupported, /* 0x18 */
ibf_dump_object_unsupported, /* 0x19 */
- ibf_dump_object_unsupported, /* T_IMEMO 0x1a */
+ ibf_dump_object_imemo, /* T_IMEMO 0x1a */
ibf_dump_object_unsupported, /* T_NODE 0x1b */
ibf_dump_object_unsupported, /* T_ICLASS 0x1c */
ibf_dump_object_unsupported, /* T_ZOMBIE 0x1d */
@@ -12984,7 +14649,7 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj)
else {
obj_header.internal = SPECIAL_CONST_P(obj) ? FALSE : (RBASIC_CLASS(obj) == 0) ? TRUE : FALSE;
obj_header.special_const = FALSE;
- obj_header.frozen = FL_TEST(obj, FL_FREEZE) ? TRUE : FALSE;
+ obj_header.frozen = OBJ_FROZEN(obj) ? TRUE : FALSE;
ibf_dump_object_object_header(dump, obj_header);
(*dump_object_functions[obj_header.type])(dump, obj);
}
@@ -13020,7 +14685,7 @@ static const ibf_load_object_function load_object_functions[RUBY_T_MASK+1] = {
ibf_load_object_unsupported, /* 0x17 */
ibf_load_object_unsupported, /* 0x18 */
ibf_load_object_unsupported, /* 0x19 */
- ibf_load_object_unsupported, /* T_IMEMO 0x1a */
+ ibf_load_object_imemo, /* T_IMEMO 0x1a */
ibf_load_object_unsupported, /* T_NODE 0x1b */
ibf_load_object_unsupported, /* T_ICLASS 0x1c */
ibf_load_object_unsupported, /* T_ZOMBIE 0x1d */
@@ -13136,14 +14801,13 @@ ibf_dump_free(void *ptr)
st_free_table(dump->iseq_table);
dump->iseq_table = 0;
}
- ruby_xfree(dump);
}
static size_t
ibf_dump_memsize(const void *ptr)
{
struct ibf_dump *dump = (struct ibf_dump *)ptr;
- size_t size = sizeof(*dump);
+ size_t size = 0;
if (dump->iseq_table) size += st_memsize(dump->iseq_table);
if (dump->global_buffer.obj_table) size += st_memsize(dump->global_buffer.obj_table);
return size;
@@ -13152,7 +14816,7 @@ ibf_dump_memsize(const void *ptr)
static const rb_data_type_t ibf_dump_type = {
"ibf_dump",
{ibf_dump_mark, ibf_dump_free, ibf_dump_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
static void
@@ -13188,7 +14852,6 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
ibf_dump_setup(dump, dump_obj);
ibf_dump_write(dump, &header, sizeof(header));
- ibf_dump_write(dump, RUBY_PLATFORM, strlen(RUBY_PLATFORM) + 1);
ibf_dump_iseq(dump, iseq);
header.magic[0] = 'Y'; /* YARB */
@@ -13197,6 +14860,8 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
header.magic[3] = 'B';
header.major_version = IBF_MAJOR_VERSION;
header.minor_version = IBF_MINOR_VERSION;
+ header.endian = IBF_ENDIAN_MARK;
+ header.wordsize = (uint8_t)SIZEOF_VALUE;
ibf_dump_iseq_list(dump, &header);
ibf_dump_object_list(dump, &header.global_object_list_offset, &header.global_object_list_size);
header.size = ibf_dump_pos(dump);
@@ -13214,8 +14879,6 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
ibf_dump_overwrite(dump, &header, sizeof(header), 0);
str = dump->global_buffer.str;
- ibf_dump_free(dump);
- DATA_PTR(dump_obj) = NULL;
RB_GC_GUARD(dump_obj);
return str;
}
@@ -13289,16 +14952,12 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
#endif
pinned_list_store(load->iseq_list, iseq_index, (VALUE)iseq);
-#if !USE_LAZY_LOAD
+ if (!USE_LAZY_LOAD || GET_VM()->builtin_function_table) {
#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: loading iseq=%p\n", (void *)iseq);
+ fprintf(stderr, "ibf_load_iseq: loading iseq=%p\n", (void *)iseq);
#endif
- rb_ibf_load_iseq_complete(iseq);
-#else
- if (GET_VM()->builtin_function_table) {
rb_ibf_load_iseq_complete(iseq);
}
-#endif /* !USE_LAZY_LOAD */
#if IBF_ISEQ_DEBUG
fprintf(stderr, "ibf_load_iseq: iseq=%p loaded %p\n",
@@ -13312,35 +14971,39 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
static void
ibf_load_setup_bytes(struct ibf_load *load, VALUE loader_obj, const char *bytes, size_t size)
{
+ struct ibf_header *header = (struct ibf_header *)bytes;
load->loader_obj = loader_obj;
load->global_buffer.buff = bytes;
- load->header = (struct ibf_header *)load->global_buffer.buff;
- load->global_buffer.size = load->header->size;
- load->global_buffer.obj_list_offset = load->header->global_object_list_offset;
- load->global_buffer.obj_list_size = load->header->global_object_list_size;
- RB_OBJ_WRITE(loader_obj, &load->iseq_list, pinned_list_new(load->header->iseq_list_size));
+ load->header = header;
+ load->global_buffer.size = header->size;
+ load->global_buffer.obj_list_offset = header->global_object_list_offset;
+ load->global_buffer.obj_list_size = header->global_object_list_size;
+ RB_OBJ_WRITE(loader_obj, &load->iseq_list, pinned_list_new(header->iseq_list_size));
RB_OBJ_WRITE(loader_obj, &load->global_buffer.obj_list, pinned_list_new(load->global_buffer.obj_list_size));
load->iseq = NULL;
load->current_buffer = &load->global_buffer;
- if (size < load->header->size) {
+ if (size < header->size) {
rb_raise(rb_eRuntimeError, "broken binary format");
}
- if (strncmp(load->header->magic, "YARB", 4) != 0) {
+ if (strncmp(header->magic, "YARB", 4) != 0) {
rb_raise(rb_eRuntimeError, "unknown binary format");
}
- if (load->header->major_version != IBF_MAJOR_VERSION ||
- load->header->minor_version != IBF_MINOR_VERSION) {
+ if (header->major_version != IBF_MAJOR_VERSION ||
+ header->minor_version != IBF_MINOR_VERSION) {
rb_raise(rb_eRuntimeError, "unmatched version file (%u.%u for %u.%u)",
- load->header->major_version, load->header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
+ header->major_version, header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
}
- if (strcmp(load->global_buffer.buff + sizeof(struct ibf_header), RUBY_PLATFORM) != 0) {
- rb_raise(rb_eRuntimeError, "unmatched platform");
+ if (header->endian != IBF_ENDIAN_MARK) {
+ rb_raise(rb_eRuntimeError, "unmatched endian: %c", header->endian);
}
- if (load->header->iseq_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
+ if (header->wordsize != SIZEOF_VALUE) {
+ rb_raise(rb_eRuntimeError, "unmatched word size: %d", header->wordsize);
+ }
+ if (header->iseq_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
rb_raise(rb_eArgError, "unaligned iseq list offset: %u",
- load->header->iseq_list_offset);
+ header->iseq_list_offset);
}
if (load->global_buffer.obj_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
rb_raise(rb_eArgError, "unaligned object list offset: %u",
@@ -13351,15 +15014,17 @@ ibf_load_setup_bytes(struct ibf_load *load, VALUE loader_obj, const char *bytes,
static void
ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
{
+ StringValue(str);
+
if (RSTRING_LENINT(str) < (int)sizeof(struct ibf_header)) {
rb_raise(rb_eRuntimeError, "broken binary format");
}
-#if USE_LAZY_LOAD
- str = rb_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
-#endif
+ if (USE_LAZY_LOAD) {
+ str = rb_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
+ }
- ibf_load_setup_bytes(load, loader_obj, StringValuePtr(str), RSTRING_LEN(str));
+ ibf_load_setup_bytes(load, loader_obj, RSTRING_PTR(str), RSTRING_LEN(str));
RB_OBJ_WRITE(loader_obj, &load->str, str);
}
@@ -13376,7 +15041,7 @@ static void
ibf_loader_free(void *ptr)
{
struct ibf_load *load = (struct ibf_load *)ptr;
- ruby_xfree(load);
+ SIZED_FREE(load);
}
static size_t
@@ -13431,3 +15096,5 @@ rb_iseq_ibf_load_extra_data(VALUE str)
RB_GC_GUARD(loader_obj);
return extra_str;
}
+
+#include "prism_compile.c"
diff --git a/complex.c b/complex.c
index 686114b292..8c661f2019 100644
--- a/complex.c
+++ b/complex.c
@@ -20,10 +20,12 @@
#include "internal/array.h"
#include "internal/class.h"
#include "internal/complex.h"
+#include "internal/error.h"
#include "internal/math.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
+#include "internal/string.h"
#include "ruby_assert.h"
#define ZERO INT2FIX(0)
@@ -50,20 +52,6 @@ static ID id_abs, id_arg,
#define id_quo idQuo
#define id_fdiv idFdiv
-#define fun1(n) \
-inline static VALUE \
-f_##n(VALUE x)\
-{\
- return rb_funcall(x, id_##n, 0);\
-}
-
-#define fun2(n) \
-inline static VALUE \
-f_##n(VALUE x, VALUE y)\
-{\
- return rb_funcall(x, id_##n, 1, y);\
-}
-
#define PRESERVE_SIGNEDZERO
inline static VALUE
@@ -274,8 +262,6 @@ f_to_f(VALUE x)
return rb_funcall(x, id_to_f, 0);
}
-fun1(to_r)
-
inline static int
f_eqeq_p(VALUE x, VALUE y)
{
@@ -286,8 +272,18 @@ f_eqeq_p(VALUE x, VALUE y)
return (int)rb_equal(x, y);
}
-fun2(expt)
-fun2(fdiv)
+static VALUE
+f_fdiv(VALUE x, VALUE y)
+{
+ if (RB_INTEGER_TYPE_P(x))
+ return rb_int_fdiv(x, y);
+ if (RB_FLOAT_TYPE_P(x))
+ return rb_float_div(x, y);
+ if (RB_TYPE_P(x, T_RATIONAL))
+ return rb_rational_fdiv(x, y);
+
+ return rb_funcallv(x, id_fdiv, 1, &y);
+}
static VALUE
f_quo(VALUE x, VALUE y)
@@ -316,24 +312,6 @@ f_negative_p(VALUE x)
#define f_positive_p(x) (!f_negative_p(x))
-inline static bool
-f_zero_p(VALUE x)
-{
- if (RB_FLOAT_TYPE_P(x)) {
- return FLOAT_ZERO_P(x);
- }
- else if (RB_INTEGER_TYPE_P(x)) {
- return FIXNUM_ZERO_P(x);
- }
- else if (RB_TYPE_P(x, T_RATIONAL)) {
- const VALUE num = RRATIONAL(x)->num;
- return FIXNUM_ZERO_P(num);
- }
- return rb_equal(x, ZERO) != 0;
-}
-
-#define f_nonzero_p(x) (!f_zero_p(x))
-
static inline bool
always_finite_type_p(VALUE x)
{
@@ -391,11 +369,11 @@ k_numeric_p(VALUE x)
inline static VALUE
nucomp_s_new_internal(VALUE klass, VALUE real, VALUE imag)
{
- NEWOBJ_OF(obj, struct RComplex, klass, T_COMPLEX | (RGENGC_WB_PROTECTED_COMPLEX ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(obj, struct RComplex, klass, T_COMPLEX, sizeof(struct RComplex));
RCOMPLEX_SET_REAL(obj, real);
RCOMPLEX_SET_IMAG(obj, imag);
- OBJ_FREEZE_RAW((VALUE)obj);
+ OBJ_FREEZE((VALUE)obj);
return (VALUE)obj;
}
@@ -409,15 +387,15 @@ nucomp_s_alloc(VALUE klass)
inline static VALUE
f_complex_new_bang1(VALUE klass, VALUE x)
{
- assert(!RB_TYPE_P(x, T_COMPLEX));
+ RUBY_ASSERT(!RB_TYPE_P(x, T_COMPLEX));
return nucomp_s_new_internal(klass, x, ZERO);
}
inline static VALUE
f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
{
- assert(!RB_TYPE_P(x, T_COMPLEX));
- assert(!RB_TYPE_P(y, T_COMPLEX));
+ RUBY_ASSERT(!RB_TYPE_P(x, T_COMPLEX));
+ RUBY_ASSERT(!RB_TYPE_P(y, T_COMPLEX));
return nucomp_s_new_internal(klass, x, y);
}
@@ -430,7 +408,7 @@ nucomp_real_check(VALUE num)
!RB_TYPE_P(num, T_RATIONAL)) {
if (RB_TYPE_P(num, T_COMPLEX) && nucomp_real_p(num)) {
VALUE real = RCOMPLEX(num)->real;
- assert(!RB_TYPE_P(real, T_COMPLEX));
+ RUBY_ASSERT(!RB_TYPE_P(real, T_COMPLEX));
return real;
}
if (!k_numeric_p(num) || !f_real_p(num))
@@ -473,12 +451,19 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
/*
* call-seq:
- * Complex.rect(real[, imag]) -> complex
- * Complex.rectangular(real[, imag]) -> complex
+ * Complex.rect(real, imag = 0) -> complex
*
- * Returns a complex object which denotes the given rectangular form.
+ * Returns a new \Complex object formed from the arguments,
+ * each of which must be an instance of Numeric,
+ * or an instance of one of its subclasses:
+ * \Complex, Float, Integer, Rational;
+ * see {Rectangular Coordinates}[rdoc-ref:Complex@Rectangular+Coordinates]:
*
- * Complex.rectangular(1, 2) #=> (1+2i)
+ * Complex.rect(3) # => (3+0i)
+ * Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
+ * Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
+ *
+ * \Complex.rectangular is an alias for \Complex.rect.
*/
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
@@ -515,39 +500,54 @@ static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
/*
* call-seq:
- * Complex(x[, y], exception: true) -> numeric or nil
- *
- * Returns x+i*y;
- *
- * Complex(1, 2) #=> (1+2i)
- * Complex('1+2i') #=> (1+2i)
- * Complex(nil) #=> TypeError
- * Complex(1, nil) #=> TypeError
- *
- * Complex(1, nil, exception: false) #=> nil
- * Complex('1+2', exception: false) #=> nil
- *
- * Syntax of string form:
- *
- * string form = extra spaces , complex , extra spaces ;
- * complex = real part | [ sign ] , imaginary part
- * | real part , sign , imaginary part
- * | rational , "@" , rational ;
- * real part = rational ;
- * imaginary part = imaginary unit | unsigned rational , imaginary unit ;
- * rational = [ sign ] , unsigned rational ;
- * unsigned rational = numerator | numerator , "/" , denominator ;
- * numerator = integer part | fractional part | integer part , fractional part ;
- * denominator = digits ;
- * integer part = digits ;
- * fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
- * imaginary unit = "i" | "I" | "j" | "J" ;
- * sign = "-" | "+" ;
- * digits = digit , { digit | "_" , digit };
- * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
- * extra spaces = ? \s* ? ;
- *
- * See String#to_c.
+ * Complex(real, imag = 0, exception: true) -> complex or nil
+ * Complex(s, exception: true) -> complex or nil
+ *
+ * Returns a new \Complex object if the arguments are valid;
+ * otherwise raises an exception if +exception+ is +true+;
+ * otherwise returns +nil+.
+ *
+ * With Numeric arguments +real+ and +imag+,
+ * returns <tt>Complex.rect(real, imag)</tt> if the arguments are valid.
+ *
+ * With string argument +s+, returns a new \Complex object if the argument is valid;
+ * the string may have:
+ *
+ * - One or two numeric substrings,
+ * each of which specifies a Complex, Float, Integer, Numeric, or Rational value,
+ * specifying {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates]:
+ *
+ * - Sign-separated real and imaginary numeric substrings
+ * (with trailing character <tt>'i'</tt>):
+ *
+ * Complex('1+2i') # => (1+2i)
+ * Complex('+1+2i') # => (1+2i)
+ * Complex('+1-2i') # => (1-2i)
+ * Complex('-1+2i') # => (-1+2i)
+ * Complex('-1-2i') # => (-1-2i)
+ *
+ * - Real-only numeric string (without trailing character <tt>'i'</tt>):
+ *
+ * Complex('1') # => (1+0i)
+ * Complex('+1') # => (1+0i)
+ * Complex('-1') # => (-1+0i)
+ *
+ * - Imaginary-only numeric string (with trailing character <tt>'i'</tt>):
+ *
+ * Complex('1i') # => (0+1i)
+ * Complex('+1i') # => (0+1i)
+ * Complex('-1i') # => (0-1i)
+ *
+ * - At-sign separated real and imaginary rational substrings,
+ * each of which specifies a Rational value,
+ * specifying {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
+ *
+ * Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i)
+ * Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i)
+ * Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i)
+ * Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i)
+ * Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i)
+ *
*/
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
@@ -697,14 +697,19 @@ rb_dbl_complex_new_polar_pi(double abs, double ang)
/*
* call-seq:
- * Complex.polar(abs[, arg]) -> complex
+ * Complex.polar(abs, arg = 0) -> complex
+ *
+ * Returns a new \Complex object formed from the arguments,
+ * each of which must be an instance of Numeric,
+ * or an instance of one of its subclasses:
+ * \Complex, Float, Integer, Rational.
+ * Argument +arg+ is given in radians;
+ * see {Polar Coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
*
- * Returns a complex object which denotes the given polar form.
+ * Complex.polar(3) # => (3+0i)
+ * Complex.polar(3, 2.0) # => (-1.2484405096414273+2.727892280477045i)
+ * Complex.polar(-3, -2.0) # => (1.2484405096414273+2.727892280477045i)
*
- * Complex.polar(3, 0) #=> (3.0+0.0i)
- * Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i)
- * Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i)
- * Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i)
*/
static VALUE
nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
@@ -724,12 +729,19 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * cmp.real -> real
+ * real -> numeric
+ *
+ * Returns the real value for +self+:
+ *
+ * Complex.rect(7).real # => 7
+ * Complex.rect(9, -4).real # => 9
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
*
- * Returns the real part.
+ * Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.
*
- * Complex(7).real #=> 7
- * Complex(9, -4).real #=> 9
*/
VALUE
rb_complex_real(VALUE self)
@@ -740,13 +752,19 @@ rb_complex_real(VALUE self)
/*
* call-seq:
- * cmp.imag -> real
- * cmp.imaginary -> real
+ * imag -> numeric
*
- * Returns the imaginary part.
+ * Returns the imaginary value for +self+:
+ *
+ * Complex.rect(7).imag # => 0
+ * Complex.rect(9, -4).imag # => -4
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
*
- * Complex(7).imaginary #=> 0
- * Complex(9, -4).imaginary #=> -4
*/
VALUE
rb_complex_imag(VALUE self)
@@ -757,11 +775,13 @@ rb_complex_imag(VALUE self)
/*
* call-seq:
- * -cmp -> complex
+ * -self -> complex
*
- * Returns negation of the value.
+ * Returns +self+, negated, which is the negation of each of its parts:
+ *
+ * -Complex.rect(1, 2) # => (-1-2i)
+ * -Complex.rect(-1, -2) # => (1+2i)
*
- * -Complex(1, 2) #=> (-1-2i)
*/
VALUE
rb_complex_uminus(VALUE self)
@@ -772,16 +792,26 @@ rb_complex_uminus(VALUE self)
}
/*
- * call-seq:
- * cmp + numeric -> complex
+ * call-seq:
+ * self + other -> numeric
+ *
+ * Returns the sum of +self+ and +other+:
*
- * Performs addition.
+ * Complex(1, 2) + 0 # => (1+2i)
+ * Complex(1, 2) + 1 # => (2+2i)
+ * Complex(1, 2) + -1 # => (0+2i)
*
- * Complex(2, 3) + Complex(2, 3) #=> (4+6i)
- * Complex(900) + Complex(1) #=> (901+0i)
- * Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i)
- * Complex(9, 8) + 4 #=> (13+8i)
- * Complex(20, 9) + 9.8 #=> (29.8+9i)
+ * Complex(1, 2) + 1.0 # => (2.0+2i)
+ *
+ * Complex(1, 2) + Complex(2, 1) # => (3+3i)
+ * Complex(1, 2) + Complex(2.0, 1.0) # => (3.0+3.0i)
+ *
+ * Complex(1, 2) + Rational(1, 1) # => ((2/1)+2i)
+ * Complex(1, 2) + Rational(1, 2) # => ((3/2)+2i)
+ *
+ * For a computation involving Floats, the result may be inexact (see Float#+):
+ *
+ * Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
*/
VALUE
rb_complex_plus(VALUE self, VALUE other)
@@ -807,15 +837,16 @@ rb_complex_plus(VALUE self, VALUE other)
/*
* call-seq:
- * cmp - numeric -> complex
+ * self - other -> complex
*
- * Performs subtraction.
+ * Returns the difference of +self+ and +other+:
+ *
+ * Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
+ * Complex.rect(900) - Complex.rect(1) # => (899+0i)
+ * Complex.rect(-2, 9) - Complex.rect(-9, 2) # => (7+7i)
+ * Complex.rect(9, 8) - 4 # => (5+8i)
+ * Complex.rect(20, 9) - 9.8 # => (10.2+9i)
*
- * Complex(2, 3) - Complex(2, 3) #=> (0+0i)
- * Complex(900) - Complex(1) #=> (899+0i)
- * Complex(-2, 9) - Complex(-9, 2) #=> (7+7i)
- * Complex(9, 8) - 4 #=> (5+8i)
- * Complex(20, 9) - 9.8 #=> (10.2+9i)
*/
VALUE
rb_complex_minus(VALUE self, VALUE other)
@@ -867,15 +898,17 @@ comp_mul(VALUE areal, VALUE aimag, VALUE breal, VALUE bimag, VALUE *real, VALUE
/*
* call-seq:
- * cmp * numeric -> complex
+ * self * other -> numeric
+ *
+ * Returns the numeric product of +self+ and +other+:
*
- * Performs multiplication.
+ * Complex.rect(9, 8) * 4 # => (36+32i)
+ * Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
+ * Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
+ * Complex.rect(900) * Complex.rect(1) # => (900+0i)
+ * Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
+ * Complex.rect(9, 8) * Rational(2, 3) # => ((6/1)+(16/3)*i)
*
- * Complex(2, 3) * Complex(2, 3) #=> (-5+12i)
- * Complex(900) * Complex(1) #=> (900+0i)
- * Complex(-2, 9) * Complex(-9, 2) #=> (0-85i)
- * Complex(9, 8) * 4 #=> (36+32i)
- * Complex(20, 9) * 9.8 #=> (196.0+88.2i)
*/
VALUE
rb_complex_mul(VALUE self, VALUE other)
@@ -942,16 +975,16 @@ f_divide(VALUE self, VALUE other,
/*
* call-seq:
- * cmp / numeric -> complex
- * cmp.quo(numeric) -> complex
+ * self / other -> complex
+ *
+ * Returns the quotient of +self+ and +other+:
*
- * Performs division.
+ * Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
+ * Complex.rect(900) / Complex.rect(1) # => (900+0i)
+ * Complex.rect(-2, 9) / Complex.rect(-9, 2) # => ((36/85)-(77/85)*i)
+ * Complex.rect(9, 8) / 4 # => ((9/4)+2i)
+ * Complex.rect(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
*
- * Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i)
- * Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i)
- * Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i)
- * Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
- * Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
*/
VALUE
rb_complex_div(VALUE self, VALUE other)
@@ -963,11 +996,12 @@ rb_complex_div(VALUE self, VALUE other)
/*
* call-seq:
- * cmp.fdiv(numeric) -> complex
+ * fdiv(numeric) -> new_complex
*
- * Performs division as each part is a float, never returns a float.
+ * Returns <tt>Complex.rect(self.real/numeric, self.imag/numeric)</tt>:
+ *
+ * Complex.rect(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
*
- * Complex(11, 22).fdiv(3) #=> (3.6666666666666665+7.333333333333333i)
*/
static VALUE
nucomp_fdiv(VALUE self, VALUE other)
@@ -981,14 +1015,96 @@ f_reciprocal(VALUE x)
return f_quo(ONE, x);
}
+static VALUE
+zero_for(VALUE x)
+{
+ if (RB_FLOAT_TYPE_P(x))
+ return DBL2NUM(0);
+ if (RB_TYPE_P(x, T_RATIONAL))
+ return rb_rational_new(INT2FIX(0), INT2FIX(1));
+
+ return INT2FIX(0);
+}
+
+static VALUE
+complex_pow_for_special_angle(VALUE self, VALUE other)
+{
+ if (!rb_integer_type_p(other)) {
+ return Qundef;
+ }
+
+ get_dat1(self);
+ VALUE x = Qundef;
+ int dir;
+ if (f_zero_p(dat->imag)) {
+ x = dat->real;
+ dir = 0;
+ }
+ else if (f_zero_p(dat->real)) {
+ x = dat->imag;
+ dir = 2;
+ }
+ else if (f_eqeq_p(dat->real, dat->imag)) {
+ x = dat->real;
+ dir = 1;
+ }
+ else if (f_eqeq_p(dat->real, f_negate(dat->imag))) {
+ x = dat->imag;
+ dir = 3;
+ }
+ else {
+ dir = 0;
+ }
+
+ if (UNDEF_P(x)) return x;
+
+ if (f_negative_p(x)) {
+ x = f_negate(x);
+ dir += 4;
+ }
+
+ VALUE zx;
+ if (dir % 2 == 0) {
+ zx = rb_num_pow(x, other);
+ }
+ else {
+ zx = rb_num_pow(
+ rb_funcall(rb_int_mul(TWO, x), '*', 1, x),
+ rb_int_div(other, TWO)
+ );
+ if (rb_int_odd_p(other)) {
+ zx = rb_funcall(zx, '*', 1, x);
+ }
+ }
+ static const int dirs[][2] = {
+ {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}
+ };
+ int z_dir = FIX2INT(rb_int_modulo(rb_int_mul(INT2FIX(dir), other), INT2FIX(8)));
+
+ VALUE zr = Qfalse, zi = Qfalse;
+ switch (dirs[z_dir][0]) {
+ case 0: zr = zero_for(zx); break;
+ case 1: zr = zx; break;
+ case -1: zr = f_negate(zx); break;
+ }
+ switch (dirs[z_dir][1]) {
+ case 0: zi = zero_for(zx); break;
+ case 1: zi = zx; break;
+ case -1: zi = f_negate(zx); break;
+ }
+ return nucomp_s_new_internal(CLASS_OF(self), zr, zi);
+}
+
+
/*
* call-seq:
- * cmp ** numeric -> complex
+ * self ** exponent -> complex
+ *
+ * Returns +self+ raised to the power +exponent+:
*
- * Performs exponentiation.
+ * Complex.rect(0, 1) ** 2 # => (-1+0i)
+ * Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
*
- * Complex('i') ** 2 #=> (-1+0i)
- * Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i)
*/
VALUE
rb_complex_pow(VALUE self, VALUE other)
@@ -1006,6 +1122,14 @@ rb_complex_pow(VALUE self, VALUE other)
other = dat->real; /* c14n */
}
+ if (other == ONE) {
+ get_dat1(self);
+ return nucomp_s_new_internal(CLASS_OF(self), dat->real, dat->imag);
+ }
+
+ VALUE result = complex_pow_for_special_angle(self, other);
+ if (!UNDEF_P(result)) return result;
+
if (RB_TYPE_P(other, T_COMPLEX)) {
VALUE r, theta, nr, ntheta;
@@ -1067,26 +1191,23 @@ rb_complex_pow(VALUE self, VALUE other)
if (RB_BIGNUM_TYPE_P(other))
rb_warn("in a**b, b may be too big");
- r = f_abs(self);
- theta = f_arg(self);
+ r = rb_num_pow(f_abs(self), other);
+ theta = f_mul(f_arg(self), other);
- return f_complex_polar(CLASS_OF(self), f_expt(r, other),
- f_mul(theta, other));
+ return f_complex_polar(CLASS_OF(self), r, theta);
}
return rb_num_coerce_bin(self, other, id_expt);
}
/*
* call-seq:
- * cmp == object -> true or false
+ * self == other -> true or false
+ *
+ * Returns whether both <tt>self.real == other.real</tt>
+ * and <tt>self.imag == other.imag</tt>:
*
- * Returns true if cmp equals object numerically.
+ * Complex.rect(2, 3) == Complex.rect(2.0, 3.0) # => true
*
- * Complex(2, 3) == Complex(2, 3) #=> true
- * Complex(5) == 5 #=> true
- * Complex(0) == 0.0 #=> true
- * Complex('1/3') == 0.33 #=> false
- * Complex('1/2') == '1/2' #=> false
*/
static VALUE
nucomp_eqeq_p(VALUE self, VALUE other)
@@ -1114,17 +1235,30 @@ nucomp_real_p(VALUE self)
/*
* call-seq:
- * cmp <=> object -> 0, 1, -1, or nil
+ * self <=> other -> -1, 0, 1, or nil
*
- * If +cmp+'s imaginary part is zero, and +object+ is also a
- * real number (or a Complex number where the imaginary part is zero),
- * compare the real part of +cmp+ to object. Otherwise, return nil.
+ * Compares +self+ and +other+.
*
- * Complex(2, 3) <=> Complex(2, 3) #=> nil
- * Complex(2, 3) <=> 1 #=> nil
- * Complex(2) <=> 1 #=> 1
- * Complex(2) <=> 2 #=> 0
- * Complex(2) <=> 3 #=> -1
+ * Returns:
+ *
+ * - <tt>self.real <=> other.real</tt> if both of the following are true:
+ *
+ * - <tt>self.imag == 0</tt>.
+ * - <tt>other.imag == 0</tt> (always true if +other+ is numeric but not complex).
+ *
+ * - +nil+ otherwise.
+ *
+ * Examples:
+ *
+ * Complex.rect(2) <=> 3 # => -1
+ * Complex.rect(2) <=> 2 # => 0
+ * Complex.rect(2) <=> 1 # => 1
+ * Complex.rect(2, 1) <=> 1 # => nil # self.imag not zero.
+ * Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
+ * Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
+ *
+ * \Class \Complex includes module Comparable,
+ * each of whose methods uses Complex#<=> for comparison.
*/
static VALUE
nucomp_cmp(VALUE self, VALUE other)
@@ -1169,13 +1303,19 @@ nucomp_coerce(VALUE self, VALUE other)
/*
* call-seq:
- * cmp.abs -> real
- * cmp.magnitude -> real
+ * abs -> float
+ *
+ * Returns the absolute value (magnitude) for +self+;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
*
- * Returns the absolute part of its polar form.
+ * Complex.polar(-1, 0).abs # => 1.0
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2.
*
- * Complex(-1).abs #=> 1
- * Complex(3.0, -4.0).abs #=> 5.0
*/
VALUE
rb_complex_abs(VALUE self)
@@ -1199,12 +1339,19 @@ rb_complex_abs(VALUE self)
/*
* call-seq:
- * cmp.abs2 -> real
+ * abs2 -> float
+ *
+ * Returns square of the absolute value (magnitude) for +self+;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
*
- * Returns square of the absolute value.
+ * Complex.polar(2, 2).abs2 # => 4.0
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222
*
- * Complex(-1).abs2 #=> 1
- * Complex(3.0, -4.0).abs2 #=> 25.0
*/
static VALUE
nucomp_abs2(VALUE self)
@@ -1216,13 +1363,19 @@ nucomp_abs2(VALUE self)
/*
* call-seq:
- * cmp.arg -> float
- * cmp.angle -> float
- * cmp.phase -> float
+ * arg -> float
+ *
+ * Returns the argument (angle) for +self+ in radians;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
*
- * Returns the angle part of its polar form.
+ * Complex.polar(3, Math::PI/2).arg # => 1.57079632679489660
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
*
- * Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
*/
VALUE
rb_complex_arg(VALUE self)
@@ -1233,12 +1386,22 @@ rb_complex_arg(VALUE self)
/*
* call-seq:
- * cmp.rect -> array
- * cmp.rectangular -> array
+ * rect -> array
+ *
+ * Returns the array <tt>[self.real, self.imag]</tt>:
+ *
+ * Complex.rect(1, 2).rect # => [1, 2]
+ *
+ * See {Rectangular Coordinates}[rdoc-ref:Complex@Rectangular+Coordinates].
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]
*
- * Returns an array; [cmp.real, cmp.imag].
*
- * Complex(1, 2).rectangular #=> [1, 2]
+ * Complex#rectangular is an alias for Complex#rect.
*/
static VALUE
nucomp_rect(VALUE self)
@@ -1249,11 +1412,20 @@ nucomp_rect(VALUE self)
/*
* call-seq:
- * cmp.polar -> array
+ * polar -> array
*
- * Returns an array; [cmp.abs, cmp.arg].
+ * Returns the array <tt>[self.abs, self.arg]</tt>:
+ *
+ * Complex.polar(1, 2).polar # => [1.0, 2.0]
+ *
+ * See {Polar Coordinates}[rdoc-ref:Complex@Polar+Coordinates].
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.rect(1, 1).polar # => [1.4142135623730951, 0.7853981633974483]
*
- * Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904]
*/
static VALUE
nucomp_polar(VALUE self)
@@ -1263,12 +1435,12 @@ nucomp_polar(VALUE self)
/*
* call-seq:
- * cmp.conj -> complex
- * cmp.conjugate -> complex
+ * conj -> complex
+ *
+ * Returns the conjugate of +self+, <tt>Complex.rect(self.imag, self.real)</tt>:
*
- * Returns the complex conjugate.
+ * Complex.rect(1, 2).conj # => (1-2i)
*
- * Complex(1, 2).conjugate #=> (1-2i)
*/
VALUE
rb_complex_conjugate(VALUE self)
@@ -1279,10 +1451,9 @@ rb_complex_conjugate(VALUE self)
/*
* call-seq:
- * Complex(1).real? -> false
- * Complex(1, 2).real? -> false
+ * real? -> false
*
- * Returns false, even if the complex number has no imaginary part.
+ * Returns +false+; for compatibility with Numeric#real?.
*/
static VALUE
nucomp_real_p_m(VALUE self)
@@ -1292,11 +1463,17 @@ nucomp_real_p_m(VALUE self)
/*
* call-seq:
- * cmp.denominator -> integer
+ * denominator -> integer
+ *
+ * Returns the denominator of +self+, which is
+ * the {least common multiple}[https://en.wikipedia.org/wiki/Least_common_multiple]
+ * of <tt>self.real.denominator</tt> and <tt>self.imag.denominator</tt>:
*
- * Returns the denominator (lcm of both denominator - real and imag).
+ * Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
*
- * See numerator.
+ * Note that <tt>n.denominator</tt> of a non-rational numeric is +1+.
+ *
+ * Related: Complex#numerator.
*/
static VALUE
nucomp_denominator(VALUE self)
@@ -1307,21 +1484,23 @@ nucomp_denominator(VALUE self)
/*
* call-seq:
- * cmp.numerator -> numeric
+ * numerator -> new_complex
+ *
+ * Returns the \Complex object created from the numerators
+ * of the real and imaginary parts of +self+,
+ * after converting each part to the
+ * {lowest common denominator}[https://en.wikipedia.org/wiki/Lowest_common_denominator]
+ * of the two:
*
- * Returns the numerator.
+ * c = Complex.rect(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
+ * c.numerator # => (8+9i)
*
- * 1 2 3+4i <- numerator
- * - + -i -> ----
- * 2 3 6 <- denominator
+ * In this example, the lowest common denominator of the two parts is 12;
+ * the two converted parts may be thought of as \Rational(8, 12) and \Rational(9, 12),
+ * whose numerators, respectively, are 8 and 9;
+ * so the returned value of <tt>c.numerator</tt> is <tt>Complex.rect(8, 9)</tt>.
*
- * c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i)
- * n = c.numerator #=> (3+4i)
- * d = c.denominator #=> 6
- * n / d #=> ((1/2)+(2/3)*i)
- * Complex(Rational(n.real, d), Rational(n.imag, d))
- * #=> ((1/2)+(2/3)*i)
- * See denominator.
+ * Related: Complex#denominator.
*/
static VALUE
nucomp_numerator(VALUE self)
@@ -1354,6 +1533,18 @@ rb_complex_hash(VALUE self)
return v;
}
+/*
+ * :call-seq:
+ * hash -> integer
+ *
+ * Returns the integer hash value for +self+.
+ *
+ * Two \Complex objects created from the same values will have the same hash value
+ * (and will compare using #eql?):
+ *
+ * Complex.rect(1, 2).hash == Complex.rect(1, 2).hash # => true
+ *
+ */
static VALUE
nucomp_hash(VALUE self)
{
@@ -1392,16 +1583,15 @@ f_tpositive_p(VALUE x)
}
static VALUE
-f_format(VALUE self, VALUE (*func)(VALUE))
+f_format(VALUE self, VALUE s, VALUE (*func)(VALUE))
{
- VALUE s;
int impos;
get_dat1(self);
impos = f_tpositive_p(dat->imag);
- s = (*func)(dat->real);
+ rb_str_concat(s, (*func)(dat->real));
rb_str_cat2(s, !impos ? "-" : "+");
rb_str_concat(s, (*func)(f_abs(dat->imag)));
@@ -1414,33 +1604,35 @@ f_format(VALUE self, VALUE (*func)(VALUE))
/*
* call-seq:
- * cmp.to_s -> string
+ * to_s -> string
+ *
+ * Returns a string representation of +self+:
*
- * Returns the value as a string.
+ * Complex.rect(2).to_s # => "2+0i"
+ * Complex.rect(-8, 6).to_s # => "-8+6i"
+ * Complex.rect(0, Rational(1, 2)).to_s # => "0+1/2i"
+ * Complex.rect(0, Float::INFINITY).to_s # => "0+Infinity*i"
+ * Complex.rect(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
*
- * Complex(2).to_s #=> "2+0i"
- * Complex('-8/6').to_s #=> "-4/3+0i"
- * Complex('1/2i').to_s #=> "0+1/2i"
- * Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i"
- * Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i"
*/
static VALUE
nucomp_to_s(VALUE self)
{
- return f_format(self, rb_String);
+ return f_format(self, rb_usascii_str_new2(""), rb_String);
}
/*
* call-seq:
- * cmp.inspect -> string
+ * inspect -> string
*
- * Returns the value as a string for inspection.
+ * Returns a string representation of +self+:
+ *
+ * Complex.rect(2).inspect # => "(2+0i)"
+ * Complex.rect(-8, 6).inspect # => "(-8+6i)"
+ * Complex.rect(0, Rational(1, 2)).inspect # => "(0+(1/2)*i)"
+ * Complex.rect(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
+ * Complex.rect(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
*
- * Complex(2).inspect #=> "(2+0i)"
- * Complex('-8/6').inspect #=> "((-4/3)+0i)"
- * Complex('1/2i').inspect #=> "(0+(1/2)*i)"
- * Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)"
- * Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)"
*/
static VALUE
nucomp_inspect(VALUE self)
@@ -1448,7 +1640,7 @@ nucomp_inspect(VALUE self)
VALUE s;
s = rb_usascii_str_new2("(");
- rb_str_concat(s, f_format(self, rb_inspect));
+ f_format(self, s, rb_inspect);
rb_str_cat2(s, ")");
return s;
@@ -1458,10 +1650,15 @@ nucomp_inspect(VALUE self)
/*
* call-seq:
- * cmp.finite? -> true or false
+ * finite? -> true or false
+ *
+ * Returns +true+ if both <tt>self.real.finite?</tt> and <tt>self.imag.finite?</tt>
+ * are true, +false+ otherwise:
+ *
+ * Complex.rect(1, 1).finite? # => true
+ * Complex.rect(Float::INFINITY, 0).finite? # => false
*
- * Returns +true+ if +cmp+'s real and imaginary parts are both finite numbers,
- * otherwise returns +false+.
+ * Related: Numeric#finite?, Float#finite?.
*/
static VALUE
rb_complex_finite_p(VALUE self)
@@ -1473,15 +1670,15 @@ rb_complex_finite_p(VALUE self)
/*
* call-seq:
- * cmp.infinite? -> nil or 1
+ * infinite? -> 1 or nil
*
- * Returns +1+ if +cmp+'s real or imaginary part is an infinite number,
- * otherwise returns +nil+.
+ * Returns +1+ if either <tt>self.real.infinite?</tt> or <tt>self.imag.infinite?</tt>
+ * is true, +nil+ otherwise:
*
- * For example:
+ * Complex.rect(Float::INFINITY, 0).infinite? # => 1
+ * Complex.rect(1, 1).infinite? # => nil
*
- * (1+1i).infinite? #=> nil
- * (Float::INFINITY + 1i).infinite? #=> 1
+ * Related: Numeric#infinite?, Float#infinite?.
*/
static VALUE
rb_complex_infinite_p(VALUE self)
@@ -1509,7 +1706,7 @@ nucomp_loader(VALUE self, VALUE a)
RCOMPLEX_SET_REAL(dat, rb_ivar_get(a, id_i_real));
RCOMPLEX_SET_IMAG(dat, rb_ivar_get(a, id_i_imag));
- OBJ_FREEZE_RAW(self);
+ OBJ_FREEZE(self);
return self;
}
@@ -1557,12 +1754,6 @@ rb_complex_new_polar(VALUE x, VALUE y)
}
VALUE
-rb_complex_polar(VALUE x, VALUE y)
-{
- return rb_complex_new_polar(x, y);
-}
-
-VALUE
rb_Complex(VALUE x, VALUE y)
{
VALUE a[2];
@@ -1579,14 +1770,15 @@ rb_dbl_complex_new(double real, double imag)
/*
* call-seq:
- * cmp.to_i -> integer
+ * to_i -> integer
+ *
+ * Returns the value of <tt>self.real</tt> as an Integer, if possible:
*
- * Returns the value as an integer if possible (the imaginary part
- * should be exactly zero).
+ * Complex.rect(1, 0).to_i # => 1
+ * Complex.rect(1, Rational(0, 1)).to_i # => 1
*
- * Complex(1, 0).to_i #=> 1
- * Complex(1, 0.0).to_i # RangeError
- * Complex(1, 2).to_i # RangeError
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>).
*/
static VALUE
nucomp_to_i(VALUE self)
@@ -1602,14 +1794,15 @@ nucomp_to_i(VALUE self)
/*
* call-seq:
- * cmp.to_f -> float
+ * to_f -> float
*
- * Returns the value as a float if possible (the imaginary part should
- * be exactly zero).
+ * Returns the value of <tt>self.real</tt> as a Float, if possible:
*
- * Complex(1, 0).to_f #=> 1.0
- * Complex(1, 0.0).to_f # RangeError
- * Complex(1, 2).to_f # RangeError
+ * Complex.rect(1, 0).to_f # => 1.0
+ * Complex.rect(1, Rational(0, 1)).to_f # => 1.0
+ *
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>).
*/
static VALUE
nucomp_to_f(VALUE self)
@@ -1625,41 +1818,69 @@ nucomp_to_f(VALUE self)
/*
* call-seq:
- * cmp.to_r -> rational
+ * to_r -> rational
+ *
+ * Returns the value of <tt>self.real</tt> as a Rational, if possible:
*
- * Returns the value as a rational if possible (the imaginary part
- * should be exactly zero).
+ * Complex.rect(1, 0).to_r # => (1/1)
+ * Complex.rect(1, Rational(0, 1)).to_r # => (1/1)
+ * Complex.rect(1, 0.0).to_r # => (1/1)
*
- * Complex(1, 0).to_r #=> (1/1)
- * Complex(1, 0.0).to_r # RangeError
- * Complex(1, 2).to_r # RangeError
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, n)</tt>)
+ * and <tt>self.imag.to_r</tt> is not exactly zero.
*
- * See rationalize.
+ * Related: Complex#rationalize.
*/
static VALUE
nucomp_to_r(VALUE self)
{
get_dat1(self);
- if (!k_exact_zero_p(dat->imag)) {
- rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational",
- self);
+ if (RB_FLOAT_TYPE_P(dat->imag) && FLOAT_ZERO_P(dat->imag)) {
+ /* Do nothing here */
+ }
+ else if (!k_exact_zero_p(dat->imag)) {
+ VALUE imag = rb_check_convert_type_with_id(dat->imag, T_RATIONAL, "Rational", idTo_r);
+ if (NIL_P(imag) || !k_exact_zero_p(imag)) {
+ rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational",
+ self);
+ }
}
- return f_to_r(dat->real);
+ return rb_funcallv(dat->real, id_to_r, 0, 0);
}
/*
* call-seq:
- * cmp.rationalize([eps]) -> rational
- *
- * Returns the value as a rational if possible (the imaginary part
- * should be exactly zero).
- *
- * Complex(1.0/3, 0).rationalize #=> (1/3)
- * Complex(1, 0.0).rationalize # RangeError
- * Complex(1, 2).rationalize # RangeError
- *
- * See to_r.
+ * rationalize(epsilon = nil) -> rational
+ *
+ * Returns a Rational object whose value is exactly or approximately
+ * equivalent to that of <tt>self.real</tt>.
+ *
+ * With no argument +epsilon+ given, returns a \Rational object
+ * whose value is exactly equal to that of <tt>self.real.rationalize</tt>:
+ *
+ * Complex.rect(1, 0).rationalize # => (1/1)
+ * Complex.rect(1, Rational(0, 1)).rationalize # => (1/1)
+ * Complex.rect(3.14159, 0).rationalize # => (314159/100000)
+ *
+ * With argument +epsilon+ given, returns a \Rational object
+ * whose value is exactly or approximately equal to that of <tt>self.real</tt>
+ * to the given precision:
+ *
+ * Complex.rect(3.14159, 0).rationalize(0.1) # => (16/5)
+ * Complex.rect(3.14159, 0).rationalize(0.01) # => (22/7)
+ * Complex.rect(3.14159, 0).rationalize(0.001) # => (201/64)
+ * Complex.rect(3.14159, 0).rationalize(0.0001) # => (333/106)
+ * Complex.rect(3.14159, 0).rationalize(0.00001) # => (355/113)
+ * Complex.rect(3.14159, 0).rationalize(0.000001) # => (7433/2366)
+ * Complex.rect(3.14159, 0).rationalize(0.0000001) # => (9208/2931)
+ * Complex.rect(3.14159, 0).rationalize(0.00000001) # => (47460/15107)
+ * Complex.rect(3.14159, 0).rationalize(0.000000001) # => (76149/24239)
+ * Complex.rect(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
+ * Complex.rect(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624)
+ *
+ * Related: Complex#to_r.
*/
static VALUE
nucomp_rationalize(int argc, VALUE *argv, VALUE self)
@@ -1677,12 +1898,9 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * complex.to_c -> self
- *
- * Returns self.
+ * to_c -> self
*
- * Complex(2).to_c #=> (2+0i)
- * Complex(-8, 6).to_c #=> (-8+6i)
+ * Returns +self+.
*/
static VALUE
nucomp_to_c(VALUE self)
@@ -1692,24 +1910,9 @@ nucomp_to_c(VALUE self)
/*
* call-seq:
- * to_c -> (0+0i)
- *
- * Returns zero as a Complex:
- *
- * nil.to_c # => (0+0i)
+ * to_c -> complex
*
- */
-static VALUE
-nilclass_to_c(VALUE self)
-{
- return rb_complex_new1(INT2FIX(0));
-}
-
-/*
- * call-seq:
- * num.to_c -> complex
- *
- * Returns the value as a complex.
+ * Returns +self+ as a Complex object.
*/
static VALUE
numeric_to_c(VALUE self)
@@ -1989,23 +2192,14 @@ string_to_c_strict(VALUE self, int raise)
rb_must_asciicompat(self);
- s = RSTRING_PTR(self);
-
- if (!s || memchr(s, '\0', RSTRING_LEN(self))) {
- if (!raise) return Qnil;
- rb_raise(rb_eArgError, "string contains null byte");
+ if (raise) {
+ s = StringValueCStr(self);
}
-
- if (s && s[RSTRING_LEN(self)]) {
- rb_str_modify(self);
- s = RSTRING_PTR(self);
- s[RSTRING_LEN(self)] = '\0';
+ else if (!(s = rb_str_to_cstr(self))) {
+ return Qnil;
}
- if (!s)
- s = (char *)"";
-
- if (!parse_comp(s, 1, &num)) {
+ if (!parse_comp(s, TRUE, &num)) {
if (!raise) return Qnil;
rb_raise(rb_eArgError, "invalid value for convert(): %+"PRIsVALUE,
self);
@@ -2016,53 +2210,167 @@ string_to_c_strict(VALUE self, int raise)
/*
* call-seq:
- * str.to_c -> complex
- *
- * Returns a complex which denotes the string form. The parser
- * ignores leading whitespaces and trailing garbage. Any digit
- * sequences can be separated by an underscore. Returns zero for null
- * or garbage string.
- *
- * '9'.to_c #=> (9+0i)
- * '2.5'.to_c #=> (2.5+0i)
- * '2.5/1'.to_c #=> ((5/2)+0i)
- * '-3/2'.to_c #=> ((-3/2)+0i)
- * '-i'.to_c #=> (0-1i)
- * '45i'.to_c #=> (0+45i)
- * '3-4i'.to_c #=> (3-4i)
- * '-4e2-4e-2i'.to_c #=> (-400.0-0.04i)
- * '-0.0-0.0i'.to_c #=> (-0.0-0.0i)
- * '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i)
- * 'ruby'.to_c #=> (0+0i)
- *
- * Polar form:
- * include Math
- * "1.0@0".to_c #=> (1+0.0i)
- * "1.0@#{PI/2}".to_c #=> (0.0+1i)
- * "1.0@#{PI}".to_c #=> (-1+0.0i)
- *
- * See Kernel.Complex.
+ * to_c -> complex
+ *
+ * Returns a Complex object:
+ * parses the leading substring of +self+
+ * to extract two numeric values that become the coordinates of the complex object.
+ *
+ * The substring is interpreted as containing
+ * either rectangular coordinates (real and imaginary parts)
+ * or polar coordinates (magnitude and angle parts),
+ * depending on an included or implied "separator" character:
+ *
+ * - <tt>'+'</tt>, <tt>'-'</tt>, or no separator: rectangular coordinates.
+ * - <tt>'@'</tt>: polar coordinates.
+ *
+ * <b>In Brief</b>
+ *
+ * In these examples, we use method Complex#rect to display rectangular coordinates,
+ * and method Complex#polar to display polar coordinates.
+ *
+ * # Rectangular coordinates.
+ *
+ * # Real-only: no separator; imaginary part is zero.
+ * '9'.to_c.rect # => [9, 0] # Integer.
+ * '-9'.to_c.rect # => [-9, 0] # Integer (negative).
+ * '2.5'.to_c.rect # => [2.5, 0] # Float.
+ * '1.23e-14'.to_c.rect # => [1.23e-14, 0] # Float with exponent.
+ * '2.5/1'.to_c.rect # => [(5/2), 0] # Rational.
+ *
+ * # Some things are ignored.
+ * 'foo1'.to_c.rect # => [0, 0] # Unparsed entire substring.
+ * '1foo'.to_c.rect # => [1, 0] # Unparsed trailing substring.
+ * ' 1 '.to_c.rect # => [1, 0] # Leading and trailing whitespace.
+ * *
+ * # Imaginary only: trailing 'i' required; real part is zero.
+ * '9i'.to_c.rect # => [0, 9]
+ * '-9i'.to_c.rect # => [0, -9]
+ * '2.5i'.to_c.rect # => [0, 2.5]
+ * '1.23e-14i'.to_c.rect # => [0, 1.23e-14]
+ * '2.5/1i'.to_c.rect # => [0, (5/2)]
+ *
+ * # Real and imaginary; '+' or '-' separator; trailing 'i' required.
+ * '2+3i'.to_c.rect # => [2, 3]
+ * '-2-3i'.to_c.rect # => [-2, -3]
+ * '2.5+3i'.to_c.rect # => [2.5, 3]
+ * '2.5+3/2i'.to_c.rect # => [2.5, (3/2)]
+ *
+ * # Polar coordinates; '@' separator; magnitude required.
+ * '1.0@0'.to_c.polar # => [1.0, 0.0]
+ * '1.0@'.to_c.polar # => [1.0, 0.0]
+ * "1.0@#{Math::PI}".to_c.polar # => [1.0, 3.141592653589793]
+ * "1.0@#{Math::PI/2}".to_c.polar # => [1.0, 1.5707963267948966]
+ *
+ * <b>Parsed Values</b>
+ *
+ * The parsing may be thought of as searching for numeric literals
+ * embedded in the substring.
+ *
+ * This section shows how the method parses numeric values from leading substrings.
+ * The examples show real-only or imaginary-only parsing;
+ * the parsing is the same for each part.
+ *
+ * '1foo'.to_c # => (1+0i) # Ignores trailing unparsed characters.
+ * ' 1 '.to_c # => (1+0i) # Ignores leading and trailing whitespace.
+ * 'x1'.to_c # => (0+0i) # Finds no leading numeric.
+ *
+ * # Integer literal embedded in the substring.
+ * '1'.to_c # => (1+0i)
+ * '-1'.to_c # => (-1+0i)
+ * '1i'.to_c # => (0+1i)
+ *
+ * # Integer literals that don't work.
+ * '0b100'.to_c # => (0+0i) # Not parsed as binary.
+ * '0o100'.to_c # => (0+0i) # Not parsed as octal.
+ * '0d100'.to_c # => (0+0i) # Not parsed as decimal.
+ * '0x100'.to_c # => (0+0i) # Not parsed as hexadecimal.
+ * '010'.to_c # => (10+0i) # Not parsed as octal.
+ *
+ * # Float literals:
+ * '3.14'.to_c # => (3.14+0i)
+ * '3.14i'.to_c # => (0+3.14i)
+ * '1.23e4'.to_c # => (12300.0+0i)
+ * '1.23e+4'.to_c # => (12300.0+0i)
+ * '1.23e-4'.to_c # => (0.000123+0i)
+ *
+ * # Rational literals:
+ * '1/2'.to_c # => ((1/2)+0i)
+ * '-1/2'.to_c # => ((-1/2)+0i)
+ * '1/2r'.to_c # => ((1/2)+0i)
+ * '-1/2r'.to_c # => ((-1/2)+0i)
+ *
+ * <b>Rectangular Coordinates</b>
+ *
+ * With separator <tt>'+'</tt> or <tt>'-'</tt>,
+ * or with no separator,
+ * interprets the values as rectangular coordinates: real and imaginary.
+ *
+ * With no separator, assigns a single value to either the real or the imaginary part:
+ *
+ * ''.to_c # => (0+0i) # Defaults to zero.
+ * '1'.to_c # => (1+0i) # Real (no trailing 'i').
+ * '1i'.to_c # => (0+1i) # Imaginary (trailing 'i').
+ * 'i'.to_c # => (0+1i) # Special case (imaginary 1).
+ *
+ * With separator <tt>'+'</tt>, both parts positive (or zero):
+ *
+ * # Without trailing 'i'.
+ * '+'.to_c # => (0+0i) # No values: defaults to zero.
+ * '+1'.to_c # => (1+0i) # Value after '+': real only.
+ * '1+'.to_c # => (1+0i) # Value before '+': real only.
+ * '2+1'.to_c # => (2+0i) # Values before and after '+': real and imaginary.
+ * # With trailing 'i'.
+ * '+1i'.to_c # => (0+1i) # Value after '+': imaginary only.
+ * '2+i'.to_c # => (2+1i) # Value before '+': real and imaginary 1.
+ * '2+1i'.to_c # => (2+1i) # Values before and after '+': real and imaginary.
+ *
+ * With separator <tt>'-'</tt>, negative imaginary part:
+ *
+ * # Without trailing 'i'.
+ * '-'.to_c # => (0+0i) # No values: defaults to zero.
+ * '-1'.to_c # => (-1+0i) # Value after '-': negative real, zero imaginary.
+ * '1-'.to_c # => (1+0i) # Value before '-': positive real, zero imaginary.
+ * '2-1'.to_c # => (2+0i) # Values before and after '-': positive real, zero imaginary.
+ * # With trailing 'i'.
+ * '-1i'.to_c # => (0-1i) # Value after '-': negative real, zero imaginary.
+ * '2-i'.to_c # => (2-1i) # Value before '-': positive real, negative imaginary.
+ * '2-1i'.to_c # => (2-1i) # Values before and after '-': positive real, negative imaginary.
+ *
+ * Note that the suffixed character <tt>'i'</tt>
+ * may instead be one of <tt>'I'</tt>, <tt>'j'</tt>, or <tt>'J'</tt>,
+ * with the same effect.
+ *
+ * <b>Polar Coordinates</b>
+ *
+ * With separator <tt>'@'</tt>)
+ * interprets the values as polar coordinates: magnitude and angle.
+ *
+ * '2@'.to_c.polar # => [2, 0.0] # Value before '@': magnitude only.
+ * # Values before and after '@': magnitude and angle.
+ * '2@1'.to_c.polar # => [2.0, 1.0]
+ * "1.0@#{Math::PI/2}".to_c # => (0.0+1i)
+ * "1.0@#{Math::PI}".to_c # => (-1+0.0i)
+ * # Magnitude not given: defaults to zero.
+ * '@'.to_c.polar # => [0, 0.0]
+ * '@1'.to_c.polar # => [0, 0.0]
+ *
+ * '1.0@0'.to_c # => (1+0.0i)
+ *
+ * Note that in all cases, the suffixed character <tt>'i'</tt>
+ * may instead be one of <tt>'I'</tt>, <tt>'j'</tt>, <tt>'J'</tt>,
+ * with the same effect.
+ *
+ * See {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
*/
static VALUE
string_to_c(VALUE self)
{
- char *s;
VALUE num;
rb_must_asciicompat(self);
- s = RSTRING_PTR(self);
-
- if (s && s[RSTRING_LEN(self)]) {
- rb_str_modify(self);
- s = RSTRING_PTR(self);
- s[RSTRING_LEN(self)] = '\0';
- }
-
- if (!s)
- s = (char *)"";
-
- (void)parse_comp(s, 0, &num);
+ (void)parse_comp(rb_str_fill_terminator(self, 1), FALSE, &num);
return num;
}
@@ -2078,7 +2386,7 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
{
if (NIL_P(a1) || NIL_P(a2)) {
if (!raise) return Qnil;
- rb_raise(rb_eTypeError, "can't convert nil into Complex");
+ rb_cant_convert(Qnil, "Complex");
}
if (RB_TYPE_P(a1, T_STRING)) {
@@ -2119,8 +2427,11 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
return a1;
/* should raise exception for consistency */
if (!k_numeric_p(a1)) {
- if (!raise)
- return rb_protect(to_complex, a1, NULL);
+ if (!raise) {
+ a1 = rb_protect(to_complex, a1, NULL);
+ rb_set_errinfo(Qnil);
+ return a1;
+ }
return to_complex(a1);
}
}
@@ -2164,9 +2475,9 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * num.abs2 -> real
+ * abs2 -> real
*
- * Returns square of self.
+ * Returns the square of +self+.
*/
static VALUE
numeric_abs2(VALUE self)
@@ -2176,11 +2487,9 @@ numeric_abs2(VALUE self)
/*
* call-seq:
- * num.arg -> 0 or float
- * num.angle -> 0 or float
- * num.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns zero if +self+ is positive, Math::PI otherwise.
*/
static VALUE
numeric_arg(VALUE self)
@@ -2192,10 +2501,9 @@ numeric_arg(VALUE self)
/*
* call-seq:
- * num.rect -> array
- * num.rectangular -> array
+ * rect -> array
*
- * Returns an array; [num, 0].
+ * Returns array <tt>[self, 0]</tt>.
*/
static VALUE
numeric_rect(VALUE self)
@@ -2205,9 +2513,9 @@ numeric_rect(VALUE self)
/*
* call-seq:
- * num.polar -> array
+ * polar -> array
*
- * Returns an array; [num.abs, num.arg].
+ * Returns array <tt>[self.abs, self.arg]</tt>.
*/
static VALUE
numeric_polar(VALUE self)
@@ -2235,11 +2543,9 @@ numeric_polar(VALUE self)
/*
* call-seq:
- * flo.arg -> 0 or float
- * flo.angle -> 0 or float
- * flo.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns 0 if +self+ is positive, Math::PI otherwise.
*/
static VALUE
float_arg(VALUE self)
@@ -2252,45 +2558,137 @@ float_arg(VALUE self)
}
/*
- * A complex number can be represented as a paired real number with
- * imaginary unit; a+bi. Where a is real part, b is imaginary part
- * and i is imaginary unit. Real a equals complex a+0i
- * mathematically.
+ * A \Complex object houses a pair of values,
+ * given when the object is created as either <i>rectangular coordinates</i>
+ * or <i>polar coordinates</i>.
*
- * You can create a \Complex object explicitly with:
+ * == Rectangular Coordinates
+ *
+ * The rectangular coordinates of a complex number
+ * are called the _real_ and _imaginary_ parts;
+ * see {Complex number definition}[https://en.wikipedia.org/wiki/Complex_number#Definition_and_basic_operations].
+ *
+ * You can create a \Complex object from rectangular coordinates with:
*
* - A {complex literal}[rdoc-ref:syntax/literals.rdoc@Complex+Literals].
+ * - Method Complex.rect.
+ * - Method Kernel#Complex, either with numeric arguments or with certain string arguments.
+ * - Method String#to_c, for certain strings.
+ *
+ * Note that each of the stored parts may be a an instance one of the classes
+ * Complex, Float, Integer, or Rational;
+ * they may be retrieved:
+ *
+ * - Separately, with methods Complex#real and Complex#imaginary.
+ * - Together, with method Complex#rect.
+ *
+ * The corresponding (computed) polar values may be retrieved:
+ *
+ * - Separately, with methods Complex#abs and Complex#arg.
+ * - Together, with method Complex#polar.
+ *
+ * == Polar Coordinates
+ *
+ * The polar coordinates of a complex number
+ * are called the _absolute_ and _argument_ parts;
+ * see {Complex polar plane}[https://en.wikipedia.org/wiki/Complex_number#Polar_form].
+ *
+ * In this class, the argument part
+ * in expressed {radians}[https://en.wikipedia.org/wiki/Radian]
+ * (not {degrees}[https://en.wikipedia.org/wiki/Degree_(angle)]).
+ *
+ * You can create a \Complex object from polar coordinates with:
+ *
+ * - Method Complex.polar.
+ * - Method Kernel#Complex, with certain string arguments.
+ * - Method String#to_c, for certain strings.
+ *
+ * Note that each of the stored parts may be a an instance one of the classes
+ * Complex, Float, Integer, or Rational;
+ * they may be retrieved:
+ *
+ * - Separately, with methods Complex#abs and Complex#arg.
+ * - Together, with method Complex#polar.
+ *
+ * The corresponding (computed) rectangular values may be retrieved:
+ *
+ * - Separately, with methods Complex#real and Complex#imag.
+ * - Together, with method Complex#rect.
+ *
+ * == What's Here
+ *
+ * First, what's elsewhere:
+ *
+ * - Class \Complex inherits (directly or indirectly)
+ * from classes {Numeric}[rdoc-ref:Numeric@Whats-Here]
+ * and {Object}[rdoc-ref:Object@Whats-Here].
+ * - Includes (indirectly) module {Comparable}[rdoc-ref:Comparable@Whats-Here].
+ *
+ * Here, class \Complex has methods for:
+ *
+ * === Creating \Complex Objects
+ *
+ * - ::polar: Returns a new \Complex object based on given polar coordinates.
+ * - ::rect (and its alias ::rectangular):
+ * Returns a new \Complex object based on given rectangular coordinates.
+ *
+ * === Querying
+ *
+ * - #abs (and its alias #magnitude): Returns the absolute value for +self+.
+ * - #arg (and its aliases #angle and #phase):
+ * Returns the argument (angle) for +self+ in radians.
+ * - #denominator: Returns the denominator of +self+.
+ * - #finite?: Returns whether both +self.real+ and +self.image+ are finite.
+ * - #hash: Returns the integer hash value for +self+.
+ * - #imag (and its alias #imaginary): Returns the imaginary value for +self+.
+ * - #infinite?: Returns whether +self.real+ or +self.image+ is infinite.
+ * - #numerator: Returns the numerator of +self+.
+ * - #polar: Returns the array <tt>[self.abs, self.arg]</tt>.
+ * - #inspect: Returns a string representation of +self+.
+ * - #real: Returns the real value for +self+.
+ * - #real?: Returns +false+; for compatibility with Numeric#real?.
+ * - #rect (and its alias #rectangular):
+ * Returns the array <tt>[self.real, self.imag]</tt>.
+ *
+ * === Comparing
+ *
+ * - #<=>: Returns whether +self+ is less than, equal to, or greater than the given argument.
+ * - #==: Returns whether +self+ is equal to the given argument.
*
- * You can convert certain objects to \Complex objects with:
+ * === Converting
*
- * - \Method #Complex.
+ * - #rationalize: Returns a Rational object whose value is exactly
+ * or approximately equivalent to that of <tt>self.real</tt>.
+ * - #to_c: Returns +self+.
+ * - #to_d: Returns the value as a BigDecimal object.
+ * - #to_f: Returns the value of <tt>self.real</tt> as a Float, if possible.
+ * - #to_i: Returns the value of <tt>self.real</tt> as an Integer, if possible.
+ * - #to_r: Returns the value of <tt>self.real</tt> as a Rational, if possible.
+ * - #to_s: Returns a string representation of +self+.
*
- * Complex object can be created as literal, and also by using
- * Kernel#Complex, Complex::rect, Complex::polar or to_c method.
+ * === Performing Complex Arithmetic
*
- * 2+1i #=> (2+1i)
- * Complex(1) #=> (1+0i)
- * Complex(2, 3) #=> (2+3i)
- * Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i)
- * 3.to_c #=> (3+0i)
+ * - #*: Returns the product of +self+ and the given numeric.
+ * - #**: Returns +self+ raised to power of the given numeric.
+ * - #+: Returns the sum of +self+ and the given numeric.
+ * - #-: Returns the difference of +self+ and the given numeric.
+ * - #-@: Returns the negation of +self+.
+ * - #/: Returns the quotient of +self+ and the given numeric.
+ * - #abs2: Returns square of the absolute value (magnitude) for +self+.
+ * - #conj (and its alias #conjugate): Returns the conjugate of +self+.
+ * - #fdiv: Returns <tt>Complex.rect(self.real/numeric, self.imag/numeric)</tt>.
*
- * You can also create complex object from floating-point numbers or
- * strings.
+ * === Working with JSON
*
- * Complex(0.3) #=> (0.3+0i)
- * Complex('0.3-0.5i') #=> (0.3-0.5i)
- * Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i)
- * Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i)
+ * - ::json_create: Returns a new \Complex object,
+ * deserialized from the given serialized hash.
+ * - #as_json: Returns a serialized hash constructed from +self+.
+ * - #to_json: Returns a JSON string representing +self+.
*
- * 0.3.to_c #=> (0.3+0i)
- * '0.3-0.5i'.to_c #=> (0.3-0.5i)
- * '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i)
- * '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i)
+ * These methods are provided by the {JSON gem}[https://github.com/ruby/json]. To make these methods available:
*
- * A complex object is either an exact or an inexact number.
+ * require 'json/add/complex'
*
- * Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i)
- * Complex(1, 1) / 2.0 #=> (0.5+0.5i)
*/
void
Init_Complex(void)
@@ -2391,7 +2789,6 @@ Init_Complex(void)
rb_define_method(rb_cComplex, "to_r", nucomp_to_r, 0);
rb_define_method(rb_cComplex, "rationalize", nucomp_rationalize, -1);
rb_define_method(rb_cComplex, "to_c", nucomp_to_c, 0);
- rb_define_method(rb_cNilClass, "to_c", nilclass_to_c, 0);
rb_define_method(rb_cNumeric, "to_c", numeric_to_c, 0);
rb_define_method(rb_cString, "to_c", string_to_c, 0);
@@ -2411,13 +2808,17 @@ Init_Complex(void)
rb_define_method(rb_cFloat, "phase", float_arg, 0);
/*
- * The imaginary unit.
+ * Equivalent
+ * to <tt>Complex.rect(0, 1)</tt>:
+ *
+ * Complex::I # => (0+1i)
+ *
*/
rb_define_const(rb_cComplex, "I",
f_complex_new_bang2(rb_cComplex, ZERO, ONE));
#if !USE_FLONUM
- rb_gc_register_mark_object(RFLOAT_0 = DBL2NUM(0.0));
+ rb_vm_register_global_object(RFLOAT_0 = DBL2NUM(0.0));
#endif
rb_provide("complex.so"); /* for backward compatibility */
diff --git a/concurrent_set.c b/concurrent_set.c
new file mode 100644
index 0000000000..42a5bfe8da
--- /dev/null
+++ b/concurrent_set.c
@@ -0,0 +1,518 @@
+#include "internal.h"
+#include "internal/gc.h"
+#include "internal/concurrent_set.h"
+#include "ruby/atomic.h"
+#include "vm_sync.h"
+
+#define CONCURRENT_SET_CONTINUATION_BIT ((VALUE)1 << (sizeof(VALUE) * CHAR_BIT - 1))
+#define CONCURRENT_SET_HASH_MASK (~CONCURRENT_SET_CONTINUATION_BIT)
+
+enum concurrent_set_special_values {
+ CONCURRENT_SET_EMPTY,
+ CONCURRENT_SET_DELETED,
+ CONCURRENT_SET_MOVED,
+ CONCURRENT_SET_SPECIAL_VALUE_COUNT
+};
+
+struct concurrent_set_entry {
+ VALUE hash;
+ VALUE key;
+};
+
+struct concurrent_set {
+ rb_atomic_t size;
+ unsigned int capacity;
+ unsigned int deleted_entries;
+ const struct rb_concurrent_set_funcs *funcs;
+ struct concurrent_set_entry *entries;
+};
+
+static void
+concurrent_set_mark_continuation(struct concurrent_set_entry *entry, VALUE curr_hash_and_flags)
+{
+ if (curr_hash_and_flags & CONCURRENT_SET_CONTINUATION_BIT) return;
+
+ RUBY_ASSERT((curr_hash_and_flags & CONCURRENT_SET_HASH_MASK) != 0);
+
+ VALUE new_hash = curr_hash_and_flags | CONCURRENT_SET_CONTINUATION_BIT;
+ VALUE prev_hash = rbimpl_atomic_value_cas(&entry->hash, curr_hash_and_flags, new_hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
+
+ // At the moment we only expect to be racing concurrently against another
+ // thread also setting the continuation bit.
+ // In the future if deletion is concurrent this will need adjusting
+ RUBY_ASSERT(prev_hash == curr_hash_and_flags || prev_hash == new_hash);
+ (void)prev_hash;
+}
+
+static VALUE
+concurrent_set_hash(const struct concurrent_set *set, VALUE key)
+{
+ VALUE hash = set->funcs->hash(key);
+ hash &= CONCURRENT_SET_HASH_MASK;
+ if (hash == 0) {
+ hash ^= CONCURRENT_SET_HASH_MASK;
+ }
+ RUBY_ASSERT(hash != 0);
+ RUBY_ASSERT(!(hash & CONCURRENT_SET_CONTINUATION_BIT));
+ return hash;
+}
+
+static void
+concurrent_set_free(void *ptr)
+{
+ struct concurrent_set *set = ptr;
+ SIZED_FREE_N(set->entries, set->capacity);
+}
+
+static size_t
+concurrent_set_size(const void *ptr)
+{
+ const struct concurrent_set *set = ptr;
+ return sizeof(struct concurrent_set) +
+ (set->capacity * sizeof(struct concurrent_set_entry));
+}
+
+/* Hack: Though it would be trivial, we're intentionally avoiding WB-protecting
+ * this object. This prevents the object from aging and ensures it can always be
+ * collected in a minor GC.
+ * Longer term this deserves a better way to reclaim memory promptly.
+ */
+static void
+concurrent_set_mark(void *ptr)
+{
+ (void)ptr;
+}
+
+static const rb_data_type_t concurrent_set_type = {
+ .wrap_struct_name = "VM/concurrent_set",
+ .function = {
+ .dmark = concurrent_set_mark,
+ .dfree = concurrent_set_free,
+ .dsize = concurrent_set_size,
+ },
+ /* Hack: NOT WB_PROTECTED on purpose (see above) */
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
+};
+
+VALUE
+rb_concurrent_set_new(const struct rb_concurrent_set_funcs *funcs, int capacity)
+{
+ struct concurrent_set *set;
+ VALUE obj = TypedData_Make_Struct(0, struct concurrent_set, &concurrent_set_type, set);
+ set->funcs = funcs;
+ set->entries = ZALLOC_N(struct concurrent_set_entry, capacity);
+ set->capacity = capacity;
+ return obj;
+}
+
+rb_atomic_t
+rb_concurrent_set_size(VALUE set_obj)
+{
+ struct concurrent_set *set = RTYPEDDATA_GET_DATA(set_obj);
+
+ return RUBY_ATOMIC_LOAD(set->size);
+}
+
+struct concurrent_set_probe {
+ int idx;
+ int d;
+ int mask;
+};
+
+static int
+concurrent_set_probe_start(struct concurrent_set_probe *probe, struct concurrent_set *set, VALUE hash)
+{
+ RUBY_ASSERT((set->capacity & (set->capacity - 1)) == 0);
+ probe->d = 0;
+ probe->mask = set->capacity - 1;
+ probe->idx = hash & probe->mask;
+ return probe->idx;
+}
+
+static int
+concurrent_set_probe_next(struct concurrent_set_probe *probe)
+{
+ probe->d++;
+ probe->idx = (probe->idx + probe->d) & probe->mask;
+ return probe->idx;
+}
+
+static void
+concurrent_set_try_resize_without_locking(VALUE old_set_obj, VALUE *set_obj_ptr)
+{
+ // Check if another thread has already resized.
+ if (rbimpl_atomic_value_load(set_obj_ptr, RBIMPL_ATOMIC_ACQUIRE) != old_set_obj) {
+ return;
+ }
+
+ struct concurrent_set *old_set = RTYPEDDATA_GET_DATA(old_set_obj);
+
+ // This may overcount by up to the number of threads concurrently attempting to insert
+ // GC may also happen between now and the set being rebuilt
+ int expected_size = rbimpl_atomic_load(&old_set->size, RBIMPL_ATOMIC_RELAXED) - old_set->deleted_entries;
+
+ // NOTE: new capacity must make sense with load factor, don't change one without checking the other.
+ struct concurrent_set_entry *old_entries = old_set->entries;
+ int old_capacity = old_set->capacity;
+ int new_capacity = old_capacity * 2;
+ if (new_capacity > expected_size * 8) {
+ new_capacity = old_capacity / 2;
+ }
+ else if (new_capacity > expected_size * 4) {
+ new_capacity = old_capacity;
+ }
+
+ // May cause GC and therefore deletes, so must happen first.
+ VALUE new_set_obj = rb_concurrent_set_new(old_set->funcs, new_capacity);
+ struct concurrent_set *new_set = RTYPEDDATA_GET_DATA(new_set_obj);
+
+ for (int i = 0; i < old_capacity; i++) {
+ struct concurrent_set_entry *old_entry = &old_entries[i];
+ VALUE key = rbimpl_atomic_value_exchange(&old_entry->key, CONCURRENT_SET_MOVED, RBIMPL_ATOMIC_ACQUIRE);
+ RUBY_ASSERT(key != CONCURRENT_SET_MOVED);
+
+ if (key < CONCURRENT_SET_SPECIAL_VALUE_COUNT) continue;
+ if (!RB_SPECIAL_CONST_P(key) && rb_objspace_garbage_object_p(key)) continue;
+
+ VALUE hash = rbimpl_atomic_value_load(&old_entry->hash, RBIMPL_ATOMIC_RELAXED) & CONCURRENT_SET_HASH_MASK;
+ RUBY_ASSERT(hash != 0);
+ RUBY_ASSERT(hash == concurrent_set_hash(old_set, key));
+
+ // Insert key into new_set.
+ struct concurrent_set_probe probe;
+ int idx = concurrent_set_probe_start(&probe, new_set, hash);
+
+ while (true) {
+ struct concurrent_set_entry *entry = &new_set->entries[idx];
+
+ if (entry->hash == CONCURRENT_SET_EMPTY) {
+ RUBY_ASSERT(entry->key == CONCURRENT_SET_EMPTY);
+
+ new_set->size++;
+ RUBY_ASSERT(new_set->size <= new_set->capacity / 2);
+
+ entry->key = key;
+ entry->hash = hash;
+ break;
+ }
+
+ RUBY_ASSERT(entry->key >= CONCURRENT_SET_SPECIAL_VALUE_COUNT);
+ entry->hash |= CONCURRENT_SET_CONTINUATION_BIT;
+ idx = concurrent_set_probe_next(&probe);
+ }
+ }
+
+ rbimpl_atomic_value_store(set_obj_ptr, new_set_obj, RBIMPL_ATOMIC_RELEASE);
+
+ RB_GC_GUARD(old_set_obj);
+}
+
+static void
+concurrent_set_try_resize(VALUE old_set_obj, VALUE *set_obj_ptr)
+{
+ RB_VM_LOCKING() {
+ concurrent_set_try_resize_without_locking(old_set_obj, set_obj_ptr);
+ }
+}
+
+VALUE
+rb_concurrent_set_find(VALUE *set_obj_ptr, VALUE key)
+{
+ RUBY_ASSERT(key >= CONCURRENT_SET_SPECIAL_VALUE_COUNT);
+
+ VALUE set_obj;
+ VALUE hash = 0;
+ struct concurrent_set *set;
+ struct concurrent_set_probe probe;
+ int idx;
+
+ retry:
+ set_obj = rbimpl_atomic_value_load(set_obj_ptr, RBIMPL_ATOMIC_ACQUIRE);
+ RUBY_ASSERT(set_obj);
+ set = RTYPEDDATA_GET_DATA(set_obj);
+
+ if (hash == 0) {
+ // We don't need to recompute the hash on every retry because it should
+ // never change.
+ hash = concurrent_set_hash(set, key);
+ }
+ RUBY_ASSERT(hash == concurrent_set_hash(set, key));
+
+ idx = concurrent_set_probe_start(&probe, set, hash);
+
+ while (true) {
+ struct concurrent_set_entry *entry = &set->entries[idx];
+ VALUE curr_hash_and_flags = rbimpl_atomic_value_load(&entry->hash, RBIMPL_ATOMIC_ACQUIRE);
+ VALUE curr_hash = curr_hash_and_flags & CONCURRENT_SET_HASH_MASK;
+ bool continuation = curr_hash_and_flags & CONCURRENT_SET_CONTINUATION_BIT;
+
+ if (curr_hash_and_flags == CONCURRENT_SET_EMPTY) {
+ return 0;
+ }
+
+ if (curr_hash != hash) {
+ if (!continuation) {
+ return 0;
+ }
+ idx = concurrent_set_probe_next(&probe);
+ continue;
+ }
+
+ VALUE curr_key = rbimpl_atomic_value_load(&entry->key, RBIMPL_ATOMIC_ACQUIRE);
+
+ switch (curr_key) {
+ case CONCURRENT_SET_EMPTY:
+ // In-progress insert: hash written but key not yet
+ break;
+ case CONCURRENT_SET_DELETED:
+ break;
+ case CONCURRENT_SET_MOVED:
+ // Wait
+ RB_VM_LOCKING();
+
+ goto retry;
+ default: {
+ if (UNLIKELY(!RB_SPECIAL_CONST_P(curr_key) && rb_objspace_garbage_object_p(curr_key))) {
+ // This is a weakref set, so after marking but before sweeping is complete we may find a matching garbage object.
+ // Skip it and let the GC pass clean it up
+ break;
+ }
+
+ if (set->funcs->cmp(key, curr_key)) {
+ // We've found a match.
+ RB_GC_GUARD(set_obj);
+ return curr_key;
+ }
+
+ if (!continuation) {
+ return 0;
+ }
+
+ break;
+ }
+ }
+
+ idx = concurrent_set_probe_next(&probe);
+ }
+}
+
+VALUE
+rb_concurrent_set_find_or_insert(VALUE *set_obj_ptr, VALUE key, void *data)
+{
+ RUBY_ASSERT(key >= CONCURRENT_SET_SPECIAL_VALUE_COUNT);
+
+ // First attempt to find
+ {
+ VALUE result = rb_concurrent_set_find(set_obj_ptr, key);
+ if (result) return result;
+ }
+
+ // First time we need to call create, and store the hash
+ VALUE set_obj = rbimpl_atomic_value_load(set_obj_ptr, RBIMPL_ATOMIC_ACQUIRE);
+ RUBY_ASSERT(set_obj);
+
+ struct concurrent_set *set = RTYPEDDATA_GET_DATA(set_obj);
+ key = set->funcs->create(key, data);
+ VALUE hash = concurrent_set_hash(set, key);
+
+ struct concurrent_set_probe probe;
+ int idx;
+
+ goto start_search;
+
+retry:
+ // On retries we only need to load the hash object
+ set_obj = rbimpl_atomic_value_load(set_obj_ptr, RBIMPL_ATOMIC_ACQUIRE);
+ RUBY_ASSERT(set_obj);
+ set = RTYPEDDATA_GET_DATA(set_obj);
+
+ RUBY_ASSERT(hash == concurrent_set_hash(set, key));
+
+start_search:
+ idx = concurrent_set_probe_start(&probe, set, hash);
+
+ while (true) {
+ struct concurrent_set_entry *entry = &set->entries[idx];
+ VALUE curr_hash_and_flags = rbimpl_atomic_value_load(&entry->hash, RBIMPL_ATOMIC_ACQUIRE);
+ VALUE curr_hash = curr_hash_and_flags & CONCURRENT_SET_HASH_MASK;
+ bool continuation = curr_hash_and_flags & CONCURRENT_SET_CONTINUATION_BIT;
+
+ if (curr_hash_and_flags == CONCURRENT_SET_EMPTY) {
+ // Reserve this slot for our hash value
+ curr_hash_and_flags = rbimpl_atomic_value_cas(&entry->hash, CONCURRENT_SET_EMPTY, hash, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
+ if (curr_hash_and_flags != CONCURRENT_SET_EMPTY) {
+ // Lost race, retry same slot to check winner's hash
+ continue;
+ }
+
+ // CAS succeeded, so these are the values stored
+ curr_hash_and_flags = hash;
+ curr_hash = hash;
+
+ // Fall through to try to claim key
+ }
+
+ if (curr_hash != hash) {
+ goto probe_next;
+ }
+
+ VALUE curr_key = rbimpl_atomic_value_load(&entry->key, RBIMPL_ATOMIC_ACQUIRE);
+
+ switch (curr_key) {
+ case CONCURRENT_SET_EMPTY: {
+ rb_atomic_t prev_size = rbimpl_atomic_fetch_add(&set->size, 1, RBIMPL_ATOMIC_RELAXED);
+
+ // Load_factor reached at 75% full. ex: prev_size: 32, capacity: 64, load_factor: 50%.
+ bool load_factor_reached = (uint64_t)(prev_size * 4) >= (uint64_t)(set->capacity * 3);
+
+ if (UNLIKELY(load_factor_reached)) {
+ concurrent_set_try_resize(set_obj, set_obj_ptr);
+ goto retry;
+ }
+
+ VALUE prev_key = rbimpl_atomic_value_cas(&entry->key, CONCURRENT_SET_EMPTY, key, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
+ if (prev_key == CONCURRENT_SET_EMPTY) {
+ RUBY_ASSERT(rb_concurrent_set_find(set_obj_ptr, key) == key);
+ RB_GC_GUARD(set_obj);
+ return key;
+ }
+ else {
+ // Entry was not inserted.
+ rbimpl_atomic_sub(&set->size, 1, RBIMPL_ATOMIC_RELAXED);
+
+ // Another thread won the race, try again at the same location.
+ continue;
+ }
+ }
+ case CONCURRENT_SET_DELETED:
+ break;
+ case CONCURRENT_SET_MOVED:
+ // Wait
+ RB_VM_LOCKING();
+ goto retry;
+ default:
+ // We're never GC during our search
+ // If the continuation bit wasn't set at the start of our search,
+ // any concurrent find with the same hash value would also look at
+ // this location and try to swap curr_key
+ if (UNLIKELY(!RB_SPECIAL_CONST_P(curr_key) && rb_objspace_garbage_object_p(curr_key))) {
+ if (continuation) {
+ goto probe_next;
+ }
+ {
+ VALUE prev = rbimpl_atomic_value_cas(&entry->key, curr_key, CONCURRENT_SET_EMPTY, RBIMPL_ATOMIC_RELEASE, RBIMPL_ATOMIC_RELAXED);
+ if (prev == curr_key) {
+ rbimpl_atomic_sub(&set->size, 1, RBIMPL_ATOMIC_RELAXED);
+ }
+ }
+ continue;
+ }
+
+ if (set->funcs->cmp(key, curr_key)) {
+ // We've found a live match.
+ RB_GC_GUARD(set_obj);
+
+ // We created key using set->funcs->create, but we didn't end
+ // up inserting it into the set. Free it here to prevent memory
+ // leaks.
+ if (set->funcs->free) set->funcs->free(key);
+
+ return curr_key;
+ }
+ break;
+ }
+
+ probe_next:
+ RUBY_ASSERT(curr_hash_and_flags != CONCURRENT_SET_EMPTY);
+ concurrent_set_mark_continuation(entry, curr_hash_and_flags);
+ idx = concurrent_set_probe_next(&probe);
+ }
+}
+
+static void
+concurrent_set_delete_entry_locked(struct concurrent_set *set, struct concurrent_set_entry *entry)
+{
+ ASSERT_vm_locking_with_barrier();
+
+ if (entry->hash & CONCURRENT_SET_CONTINUATION_BIT) {
+ entry->hash = CONCURRENT_SET_CONTINUATION_BIT;
+ entry->key = CONCURRENT_SET_DELETED;
+ set->deleted_entries++;
+ }
+ else {
+ entry->hash = CONCURRENT_SET_EMPTY;
+ entry->key = CONCURRENT_SET_EMPTY;
+ set->size--;
+ }
+}
+
+VALUE
+rb_concurrent_set_delete_by_identity(VALUE set_obj, VALUE key)
+{
+ ASSERT_vm_locking_with_barrier();
+
+ struct concurrent_set *set = RTYPEDDATA_GET_DATA(set_obj);
+
+ VALUE hash = concurrent_set_hash(set, key);
+
+ struct concurrent_set_probe probe;
+ int idx = concurrent_set_probe_start(&probe, set, hash);
+
+ while (true) {
+ struct concurrent_set_entry *entry = &set->entries[idx];
+ VALUE curr_key = entry->key;
+
+ switch (curr_key) {
+ case CONCURRENT_SET_EMPTY:
+ // We didn't find our entry to delete.
+ return 0;
+ case CONCURRENT_SET_DELETED:
+ break;
+ case CONCURRENT_SET_MOVED:
+ rb_bug("rb_concurrent_set_delete_by_identity: moved entry");
+ break;
+ default:
+ if (key == curr_key) {
+ RUBY_ASSERT((entry->hash & CONCURRENT_SET_HASH_MASK) == hash);
+ concurrent_set_delete_entry_locked(set, entry);
+ return curr_key;
+ }
+ break;
+ }
+
+ idx = concurrent_set_probe_next(&probe);
+ }
+}
+
+void
+rb_concurrent_set_foreach_with_replace(VALUE set_obj, int (*callback)(VALUE *key, void *data), void *data)
+{
+ ASSERT_vm_locking_with_barrier();
+
+ struct concurrent_set *set = RTYPEDDATA_GET_DATA(set_obj);
+
+ for (unsigned int i = 0; i < set->capacity; i++) {
+ struct concurrent_set_entry *entry = &set->entries[i];
+ VALUE key = entry->key;
+
+ switch (key) {
+ case CONCURRENT_SET_EMPTY:
+ case CONCURRENT_SET_DELETED:
+ continue;
+ case CONCURRENT_SET_MOVED:
+ rb_bug("rb_concurrent_set_foreach_with_replace: moved entry");
+ break;
+ default: {
+ int ret = callback(&entry->key, data);
+ switch (ret) {
+ case ST_STOP:
+ return;
+ case ST_DELETE:
+ concurrent_set_delete_entry_locked(set, entry);
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/configure.ac b/configure.ac
index 8624d366b5..2de91209d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,49 +9,69 @@ tooldir="$srcdir/tool"
AC_DISABLE_OPTION_CHECKING
-m4_include([tool/m4/_colorize_result_prepare.m4])dnl
-m4_include([tool/m4/ac_msg_result.m4])dnl
-m4_include([tool/m4/colorize_result.m4])dnl
-m4_include([tool/m4/ruby_append_option.m4])dnl
-m4_include([tool/m4/ruby_append_options.m4])dnl
-m4_include([tool/m4/ruby_check_builtin_func.m4])dnl
-m4_include([tool/m4/ruby_check_builtin_setjmp.m4])dnl
-m4_include([tool/m4/ruby_check_printf_prefix.m4])dnl
-m4_include([tool/m4/ruby_check_setjmp.m4])dnl
-m4_include([tool/m4/ruby_check_signedness.m4])dnl
-m4_include([tool/m4/ruby_check_sizeof.m4])dnl
-m4_include([tool/m4/ruby_check_sysconf.m4])dnl
-m4_include([tool/m4/ruby_cppoutfile.m4])dnl
-m4_include([tool/m4/ruby_decl_attribute.m4])dnl
-m4_include([tool/m4/ruby_default_arch.m4])dnl
-m4_include([tool/m4/ruby_define_if.m4])dnl
-m4_include([tool/m4/ruby_defint.m4])dnl
-m4_include([tool/m4/ruby_dtrace_available.m4])dnl
-m4_include([tool/m4/ruby_dtrace_postprocess.m4])dnl
-m4_include([tool/m4/ruby_func_attribute.m4])dnl
-m4_include([tool/m4/ruby_mingw32.m4])dnl
-m4_include([tool/m4/ruby_prepend_option.m4])dnl
-m4_include([tool/m4/ruby_prog_gnu_ld.m4])dnl
-m4_include([tool/m4/ruby_prog_makedirs.m4])dnl
-m4_include([tool/m4/ruby_replace_funcs.m4])dnl
-m4_include([tool/m4/ruby_replace_type.m4])dnl
-m4_include([tool/m4/ruby_require_funcs.m4])dnl
-m4_include([tool/m4/ruby_rm_recursive.m4])dnl
-m4_include([tool/m4/ruby_setjmp_type.m4])dnl
-m4_include([tool/m4/ruby_stack_grow_direction.m4])dnl
-m4_include([tool/m4/ruby_thread.m4])dnl
-m4_include([tool/m4/ruby_try_cflags.m4])dnl
-m4_include([tool/m4/ruby_try_cxxflags.m4])dnl
-m4_include([tool/m4/ruby_try_ldflags.m4])dnl
-m4_include([tool/m4/ruby_universal_arch.m4])dnl
-m4_include([tool/m4/ruby_wasm_tools.m4])dnl
-m4_include([tool/m4/ruby_werror_flag.m4])dnl
+m4_define([RUBY_M4_INCLUDED], [])dnl
+AC_DEFUN([RUBY_M4_INCLUDE], [m4_include([tool/m4/$1])dnl
+ m4_append([RUBY_M4_INCLUDED], [ \
+ $(tooldir)/m4/$1])dnl
+])
+RUBY_M4_INCLUDE([_colorize_result_prepare.m4])dnl
+RUBY_M4_INCLUDE([ac_msg_result.m4])dnl
+RUBY_M4_INCLUDE([colorize_result.m4])dnl
+RUBY_M4_INCLUDE([ruby_append_option.m4])dnl
+RUBY_M4_INCLUDE([ruby_append_options.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_builtin_func.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_builtin_overflow.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_builtin_setjmp.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_header.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_printf_prefix.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_setjmp.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_signedness.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_sizeof.m4])dnl
+RUBY_M4_INCLUDE([ruby_check_sysconf.m4])dnl
+RUBY_M4_INCLUDE([ruby_cppoutfile.m4])dnl
+RUBY_M4_INCLUDE([ruby_decl_attribute.m4])dnl
+RUBY_M4_INCLUDE([ruby_default_arch.m4])dnl
+RUBY_M4_INCLUDE([ruby_define_if.m4])dnl
+RUBY_M4_INCLUDE([ruby_defint.m4])dnl
+RUBY_M4_INCLUDE([ruby_dtrace_available.m4])dnl
+RUBY_M4_INCLUDE([ruby_dtrace_postprocess.m4])dnl
+RUBY_M4_INCLUDE([ruby_func_attribute.m4])dnl
+RUBY_M4_INCLUDE([ruby_mingw32.m4])dnl
+RUBY_M4_INCLUDE([ruby_prepend_option.m4])dnl
+RUBY_M4_INCLUDE([ruby_prog_gnu_ld.m4])dnl
+RUBY_M4_INCLUDE([ruby_prog_makedirs.m4])dnl
+RUBY_M4_INCLUDE([ruby_replace_funcs.m4])dnl
+RUBY_M4_INCLUDE([ruby_replace_type.m4])dnl
+RUBY_M4_INCLUDE([ruby_require_funcs.m4])dnl
+RUBY_M4_INCLUDE([ruby_rm_recursive.m4])dnl
+RUBY_M4_INCLUDE([ruby_setjmp_type.m4])dnl
+RUBY_M4_INCLUDE([ruby_modular_gc.m4])dnl
+RUBY_M4_INCLUDE([ruby_stack_grow_direction.m4])dnl
+RUBY_M4_INCLUDE([ruby_thread.m4])dnl
+RUBY_M4_INCLUDE([ruby_try_cflags.m4])dnl
+RUBY_M4_INCLUDE([ruby_try_cxxflags.m4])dnl
+RUBY_M4_INCLUDE([ruby_try_ldflags.m4])dnl
+RUBY_M4_INCLUDE([ruby_universal_arch.m4])dnl
+RUBY_M4_INCLUDE([ruby_wasm_tools.m4])dnl
+RUBY_M4_INCLUDE([ruby_werror_flag.m4])dnl
+
+AS_IF([test "x${GITHUB_ACTIONS}" = xtrue],
+[AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl
+dnl 93(bright yellow) is copied from .github/workflows/mingw.yml
+ begin_group() { AS_ECHO(["::group::@<:@93m$[]1@<:@m"]);}
+ end_group() { AS_ECHO(["::endgroup::"]);}
+],
+[dnl
+ begin_group() { :;}
+ end_group() { :;}
+])
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
+AC_ARG_VAR([rustc_flags], [additional RUSTC_FLAGS])dnl
-: "environment section" && {
+[begin]_group "environment section" && {
HAVE_BASERUBY=yes
BASERUBY_VERSION=
AC_ARG_WITH(baseruby,
@@ -63,9 +83,19 @@ AC_ARG_WITH(baseruby,
],
[
AC_PATH_PROG([BASERUBY], [ruby], [false])
+ HAVE_BASERUBY=
])
-# BASERUBY must be >= 2.5.0. Note that `"2.5.0" > "2.5"` is true.
-AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42 if RUBY_VERSION > "2.5"' 2>/dev/null`" = 42], [
+AS_IF([test "$HAVE_BASERUBY" = no], [
+ # --without-baseruby
+], [error=`RUBYOPT=- $BASERUBY --disable=gems "${tooldir}/missing-baseruby.bat" --verbose 2>&1`], [
+ HAVE_BASERUBY=yes
+], [test "$HAVE_BASERUBY" = ""], [ # no --with-baseruby option
+ AC_MSG_WARN($error) # just warn and continue
+ HAVE_BASERUBY=no
+], [ # the ruby given by --with-baseruby is too old
+ AC_MSG_ERROR($error) # bail out
+])
+AS_IF([test "${HAVE_BASERUBY:=no}" != no], [
AS_CASE(["$build_os"], [mingw*], [
# Can MSys shell run a command with a drive letter?
RUBYOPT=- `cygpath -ma "$BASERUBY"` --disable=gems -e exit 2>/dev/null || HAVE_BASERUBY=no
@@ -73,25 +103,51 @@ AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'p
RUBY_APPEND_OPTION(BASERUBY, "--disable=gems")
BASERUBY_VERSION=`$BASERUBY -v`
$BASERUBY -C "$srcdir" tool/downloader.rb -d tool -e gnu config.guess config.sub >&AS_MESSAGE_FD
-], [
- HAVE_BASERUBY=no
])
AS_IF([test "$HAVE_BASERUBY" = no], [
AS_IF([test "$cross_compiling" = yes], [AC_MSG_ERROR([executable host ruby is required for cross-compiling])])
- BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
+ BASERUBY=${tooldir}/missing-baseruby.bat
])
AC_SUBST(BASERUBY)
AC_SUBST(HAVE_BASERUBY)
+AS_IF([test "$cross_compiling" = yes],
+ [X_BUILD_EXEEXT=`$BASERUBY -rrbconfig -e ['puts RbConfig::CONFIG["EXEEXT"]']`],
+ [X_BUILD_EXEEXT='$(EXEEXT)']
+)
+AC_SUBST(X_BUILD_EXEEXT)
+
+AC_ARG_WITH(dump-ast,
+ AS_HELP_STRING([--with-dump-ast=DUMP_AST], [use DUMP_AST as dump_ast; for cross-compiling with a host-built dump_ast]),
+ [DUMP_AST=$withval DUMP_AST_TARGET='$(empty)'],
+ [AS_IF([test "$cross_compiling" = yes], [
+ DUMP_AST='build-tool/dump_ast$(BUILD_EXEEXT)'
+ ], [
+ DUMP_AST='./dump_ast$(BUILD_EXEEXT)'
+ ])
+ DUMP_AST_TARGET='$(DUMP_AST)'])
+dnl Without baseruby, .rbinc files cannot be regenerated, so clear the
+dnl dependency on dump_ast to avoid rebuilding pre-generated .rbinc files.
+AS_IF([test "$HAVE_BASERUBY" = no], [DUMP_AST_TARGET='$(empty)'])
+AC_SUBST(X_DUMP_AST, "${DUMP_AST}")
+AC_SUBST(X_DUMP_AST_TARGET, "${DUMP_AST_TARGET}")
: ${GIT=git}
HAVE_GIT=yes
AC_ARG_WITH(git,
AS_HELP_STRING([--without-git], [never use git]),
[AS_CASE([$withval],
- [no], [GIT=never-use HAVE_GIT=no],
+ [no], [HAVE_GIT=no],
[yes], [],
[GIT=$withval])])
-AS_IF([test x"$HAVE_GIT" = xyes], [command -v "$GIT" > /dev/null || HAVE_GIT=no])
+{
+ test x"$HAVE_GIT" = xyes &&
+ command -v "$GIT" > /dev/null &&
+ # `git -C`: 1.8.5
+ # `git log --no-show-signature`: 2.10.0
+ AS_CASE([`$GIT -C . --version 2> /dev/null | sed 's/.* //'`],
+ [0.*|1.*|2.@<:@0-9@:>@.*], [false],
+ [true])
+} || HAVE_GIT=no GIT=never-use
AC_SUBST(GIT)
AC_SUBST(HAVE_GIT)
@@ -130,6 +186,7 @@ dnl checks for alternative programs
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
+AC_SUBST(config_target, $target)
AS_CASE(["$target_cpu-$target_os"],
[aarch64-darwin*], [
target_cpu=arm64
@@ -188,7 +245,7 @@ AC_ARG_VAR([STRIP], [Strip command])
set rb_dummy ${CC}
rb_CC=$2
AC_DEFUN([RUBY_CHECK_PROG_FOR_CC], [
- rb_prog=`echo "${rb_CC}" | sed "$2"`
+ rb_prog=`echo "${rb_CC}" | sed ["s:$2\([^/]*\)$:$3\1:"]`
AC_CHECK_PROG([$1], [$rb_prog], [$rb_prog])
])
AS_CASE(["/${rb_CC} "],
@@ -199,30 +256,43 @@ AS_CASE(["/${rb_CC} "],
[*icc*], [
# Intel C++ has interprocedural optimizations. It tends to come with its
# own linker etc.
- RUBY_CHECK_PROG_FOR_CC([AR], [s/icc/xiar/])
- RUBY_CHECK_PROG_FOR_CC([CXX], [s/icc/icpc/])
- RUBY_CHECK_PROG_FOR_CC([LD], [s/icc/xild/])
+ RUBY_CHECK_PROG_FOR_CC([AR], [icc], [xiar])
+ RUBY_CHECK_PROG_FOR_CC([CXX], [icc], [icpc])
+ RUBY_CHECK_PROG_FOR_CC([LD], [icc], [xild])
],
[*gcc*], [
# Ditto for GCC.
- RUBY_CHECK_PROG_FOR_CC([LD], [s/gcc/ld/])
- RUBY_CHECK_PROG_FOR_CC([AR], [s/gcc/gcc-ar/])
- RUBY_CHECK_PROG_FOR_CC([CXX], [s/gcc/g++/])
- RUBY_CHECK_PROG_FOR_CC([NM], [s/gcc/gcc-nm/])
- RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/gcc/gcc-ranlib/])
+ RUBY_CHECK_PROG_FOR_CC([LD], [gcc], [ld])
+ RUBY_CHECK_PROG_FOR_CC([AR], [gcc], [gcc-ar])
+ RUBY_CHECK_PROG_FOR_CC([CXX], [gcc], [g++])
+ RUBY_CHECK_PROG_FOR_CC([NM], [gcc], [gcc-nm])
+ RUBY_CHECK_PROG_FOR_CC([RANLIB], [gcc], [gcc-ranlib])
],
[*clang*], [
# Ditto for LLVM. Note however that llvm-as is a LLVM-IR to LLVM bitcode
# assembler that does not target your machine native binary.
- RUBY_CHECK_PROG_FOR_CC([LD], [s/clang/ld/]) # ... maybe try lld ?
- RUBY_CHECK_PROG_FOR_CC([AR], [s/clang/llvm-ar/])
-# RUBY_CHECK_PROG_FOR_CC([AS], [s/clang/llvm-as/])
- RUBY_CHECK_PROG_FOR_CC([CXX], [s/clang/clang++/])
- RUBY_CHECK_PROG_FOR_CC([NM], [s/clang/llvm-nm/])
- RUBY_CHECK_PROG_FOR_CC([OBJCOPY], [s/clang/llvm-objcopy/])
- RUBY_CHECK_PROG_FOR_CC([OBJDUMP], [s/clang/llvm-objdump/])
- RUBY_CHECK_PROG_FOR_CC([RANLIB], [s/clang/llvm-ranlib/])
- RUBY_CHECK_PROG_FOR_CC([STRIP], [s/clang/llvm-strip/])
+
+ # Xcode has its own version tools that may be incompatible with
+ # genuine LLVM tools, use the tools in the same directory.
+
+ AS_IF([$rb_CC -E -dM -xc - < /dev/null | grep -F __apple_build_version__ > /dev/null],
+ [llvm_prefix=], [llvm_prefix=llvm-])
+ # AC_PREPROC_IFELSE cannot be used before AC_USE_SYSTEM_EXTENSIONS
+
+ RUBY_CHECK_PROG_FOR_CC([LD], [clang], [ld]) # ... maybe try lld ?
+ RUBY_CHECK_PROG_FOR_CC([AR], [clang], [${llvm_prefix}ar])
+# RUBY_CHECK_PROG_FOR_CC([AS], [clang], [${llvm_prefix}as])
+ RUBY_CHECK_PROG_FOR_CC([CXX], [clang], [clang++])
+ RUBY_CHECK_PROG_FOR_CC([NM], [clang], [${llvm_prefix}nm])
+ RUBY_CHECK_PROG_FOR_CC([OBJCOPY], [clang], [${llvm_prefix}objcopy])
+ RUBY_CHECK_PROG_FOR_CC([OBJDUMP], [clang], [${llvm_prefix}objdump])
+ RUBY_CHECK_PROG_FOR_CC([RANLIB], [clang], [${llvm_prefix}ranlib])
+ RUBY_CHECK_PROG_FOR_CC([STRIP], [clang], [${llvm_prefix}strip])
+
+ # These -Wno-* flags silence clang-specific diagnostics that don't exist
+ # in GCC. GCC silently accepts unknown -Wno-* flags but later emits noisy
+ # "unrecognized command-line option" notes whenever another warning fires.
+ clang_warnflags="-Wno-constant-logical-operand -Wno-parentheses-equality -Wno-self-assign"
])
AS_UNSET(rb_CC)
AS_UNSET(rb_dummy)
@@ -236,6 +306,8 @@ AS_CASE(["${build_os}"],
])
AS_CASE(["${target_os}"],
[cygwin*|msys*|mingw*|darwin*], [
+ ac_ct_OBJCOPY=":"
+ ac_cv_prog_OBJCOPY=":"
ac_cv_prog_ac_ct_OBJCOPY=":"
])
@@ -258,6 +330,12 @@ AC_CHECK_TOOLS([OBJCOPY], [gobjcopy objcopy], [:])
AC_CHECK_TOOLS([OBJDUMP], [gobjdump objdump])
AC_CHECK_TOOLS([STRIP], [gstrip strip], [:])
+FIRSTMAKEFILE=""
+
+# nm errors with Rust's LLVM bitcode when Rust uses a newer LLVM version than nm.
+# In case we're working with llvm-nm, tell it to not worry about the bitcode.
+AS_IF([${NM} --help 2>&1 | grep -q 'llvm-bc'], [NM="$NM --no-llvm-bc"])
+
AS_IF([test ! $rb_test_CFLAGS], [AS_UNSET(CFLAGS)]); AS_UNSET(rb_test_CFLAGS)
AS_IF([test ! $rb_test_CXXFLAGS], [AS_UNSET(CXXFLAGS)]); AS_UNSET(rb_save_CXXFLAGS)
@@ -330,7 +408,7 @@ test -z "$warnflags" ||
AS_IF([test -z "${CFLAGS+set}"], [
cflags=`echo " $cflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
orig_cflags="$cflags"
- cflags="$cflags "'${optflags} ${debugflags} ${warnflags}'
+ cflags='${hardenflags} '"$cflags "'${optflags} ${debugflags} ${warnflags}'
])
dnl AS_IF([test -z "${CXXFLAGS+set}"], [
dnl cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
@@ -385,13 +463,6 @@ AS_IF([test "$GCC" = yes], [
AS_IF([test "$gcc_major" -lt 4], [
AC_MSG_ERROR([too old GCC: $gcc_major.$gcc_minor])
])
-
- AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported],
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])],
- [rb_cv_tls_supported=yes],
- [rb_cv_tls_supported=no])])
- AS_IF([test x"$rb_cv_tls_supported" != xyes],
- [AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)])
], [
linker_flag=
])
@@ -406,33 +477,26 @@ AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG)
-: ${RJIT_CC=$CC}
-AS_IF([test "x$cross_compiling" = xno], [
- AC_PATH_PROG([RJIT_CC], ${RJIT_CC})
-
- # if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
- AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
- echo $RJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
- PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` RJIT_CC=`which $CC`])
-
- AS_CASE([$target_os],
- [*mingw*], [command -v cygpath > /dev/null && RJIT_CC=`cygpath -ma $RJIT_CC`])
- shift 2
- RJIT_CC="$RJIT_CC${1+ }$*"
-])
-
AS_CASE(["$build_os"],
- [darwin1*.*], [
+ [darwin*], [
+ # gcc 13 warns duplicate -l options, which are added by the
+ # default spec.
# Xcode linker warns for deprecated architecture and wrongly
# installed TBD files.
- CC_WRAPPER=""
+ AC_MSG_CHECKING(for $CC linker warning)
+ suppress_ld_waring=no
echo 'int main(void) {return 0;}' > conftest.c
AS_IF([$CC -framework Foundation -o conftest conftest.c 2>&1 |
- grep '^ld: warning: text-based stub file' >/dev/null], [
- CC_WRAPPER=`cd -P "${tooldir}" && pwd`/darwin-cc
- CC="$CC_WRAPPER $CC"
+ grep \
+ -e '^ld: warning: ignoring duplicate libraries:' \
+ -e '^ld: warning: text-based stub file' \
+ -e '^ld: warning: -multiply_defined is obsolete' \
+ >/dev/null], [
+ suppress_ld_waring=yes
])
rm -fr conftest*
+ test $suppress_ld_waring = yes && warnflags="${warnflags:+${warnflags} }-Wl,-w"
+ AC_MSG_RESULT($suppress_ld_waring)
])
AS_CASE(["$target_os"],
[wasi*], [
@@ -442,6 +506,8 @@ AS_CASE(["$target_os"],
# so wrap clang to insert our fake wasm-opt, which does nothing, in PATH.
CC_WRAPPER=`cd -P "${tooldir}" && pwd`/wasm-clangw
CC="$CC_WRAPPER $CC"
+
+ FIRSTMAKEFILE=GNUmakefile:wasm/GNUmakefile.in
])
cc_version=
@@ -459,8 +525,8 @@ AC_SUBST(CC_VERSION_MESSAGE, $cc_version_message)
: ${DLDFLAGS="$LDFLAGS"}
RUBY_UNIVERSAL_ARCH
-AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "${universal_binary:-no}" = no], [
- RUBY_DEFAULT_ARCH("$target_cpu")
+AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "${universal_binary:-no}" = no], [
+ RUBY_DEFAULT_ARCH($target_cpu)
])
host_os=$target_os
host_vendor=$target_vendor
@@ -473,7 +539,6 @@ AC_CACHE_CHECK([for $AR flags], [rb_cv_arflags], [
[rb_cv_arflags=rcD], [rb_cv_arflags=rcu])
])
AC_SUBST(ARFLAGS, ["$rb_cv_arflags "])
-AC_SUBST(ASFLAGS)
AS_CASE(["$target_os"],
[cygwin*|msys*|mingw*], [
@@ -484,6 +549,8 @@ AS_CASE(["$target_os"],
target_cpu=`echo $target_cpu | sed s/i.86/i386/`
AS_CASE(["$target"], [-*], [ target="$target_cpu${target}"])
AS_CASE(["$target_alias"], [-*], [ target_alias="$target_cpu${target_alias}"])
+ # cygwin/GNUmakefile.in is not exclusively for cygwin.
+ FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
AS_CASE(["$target_os"],
[mingw*], [
test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
@@ -507,7 +574,6 @@ AS_CASE(["$target_os"],
],
[hiuxmpp*], [AC_DEFINE(__HIUX_MPP__)]) # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
-
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
@@ -586,9 +652,25 @@ AS_IF([test -f conf$$.dir/src/cdcmd], [
rm -fr conf$$.dir
AC_MSG_RESULT([$CHDIR])
AC_SUBST(CHDIR)
+
+AS_CASE(["$FIRSTMAKEFILE"], [*GNUmakefile:*], [gnumake=yes], [
+ AC_MSG_CHECKING([if ${MAKE-make} is GNU make])
+ mkdir conftest.dir
+ echo "all:; @echo yes" > conftest.dir/GNUmakefile
+ echo "all:; @echo no" > conftest.dir/Makefile
+ gnumake=`(cd conftest.dir; ${MAKE-make})`
+ rm -fr conftest.dir
+ AS_CASE(["$gnumake"],
+ [*yes*], [
+ FIRSTMAKEFILE=GNUmakefile:template/GNUmakefile.in
+ gnumake=yes],
+ [
+ gnumake=no])
+ AC_MSG_RESULT($gnumake)
+])
}
-: "compiler section" && {
+[begin]_group "compiler section" && {
RUBY_WERROR_FLAG([
AC_MSG_CHECKING([whether CFLAGS is valid])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
@@ -647,9 +729,9 @@ RUBY_WERROR_FLAG([
[enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
AS_IF([test "$enable_rpath:${RPATHFLAG}" = yes:], [
- RPATHFLAG="${rpathflag:+ ${rpathflag}%1\$-s}"
+ RPATHFLAG="${rpathflag:+${rpathflag}%1\$-s}"
])
- AS_CASE([${RPATHFLAG}],[*'%1$'*],[: ${LIBPATHFLAG=' -L%1$-s'}],[: ${LIBPATHFLAG=' -L%s'}])
+ AS_CASE([${RPATHFLAG}],[*'%1$'*],[: ${LIBPATHFLAG='-L%1$-s'}],[: ${LIBPATHFLAG='-L%s'}])
}
RUBY_TRY_LDFLAGS(-fdeclspec, [fdeclspec=yes], [fdeclspec=no])
@@ -658,7 +740,7 @@ AS_IF([test "$fdeclspec" = yes], [
RUBY_APPEND_OPTIONS(cflags, -fdeclspec)
RUBY_APPEND_OPTIONS(orig_cflags, -fdeclspec)
])
-RUBY_TRY_CXXFLAGS(-fdeclspec, [fdeclspec=yes], [fdeclspec=no])
+RUBY_TRY_CXXFLAGS(-fdeclspec, [fdeclspec=yes], [fdeclspec=no], [@%:@include <cstdio>])
AS_IF([test "$fdeclspec" = yes], [
RUBY_APPEND_OPTIONS(CXXFLAGS, -fdeclspec)
])
@@ -683,6 +765,16 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
AS_IF([test $gcc_major -le 6], [
extra_warnflags="$extra_warnflags -Wno-maybe-uninitialized"
])
+ AS_CASE([ $CFLAGS ], [*" -save-temps="*|*" -save-temps "*], [], [
+ extra_warnflags="$extra_warnflags -Werror=misleading-indentation"
+ ])
+ AS_CASE([$target_os], [mingw*], [
+ # 64bit Windows is IL32P64; shorten-64-to-32 causes tons of warnigs
+ extra_warnflags="$extra_warnflags -Wno-shorten-64-to-32"
+ ], [
+ extra_warnflags="$extra_warnflags -Werror=shorten-64-to-32"
+ ])
+
# ICC doesn't support -Werror=
AS_IF([test $icc_version -gt 0], [
particular_werror_flags=no
@@ -694,21 +786,16 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
-Werror=duplicated-cond \
-Werror=implicit-function-declaration \
-Werror=implicit-int \
- -Werror=misleading-indentation \
-Werror=pointer-arith \
- -Werror=shorten-64-to-32 \
-Werror=write-strings \
-Werror=old-style-definition \
-Wimplicit-fallthrough=0 \
-Wmissing-noreturn \
-Wno-cast-function-type \
- -Wno-constant-logical-operand \
-Wno-long-long \
-Wno-missing-field-initializers \
-Wno-overlength-strings \
-Wno-packed-bitfield-compat \
- -Wno-parentheses-equality \
- -Wno-self-assign \
-Wno-tautological-compare \
-Wno-unused-parameter \
-Wno-unused-value \
@@ -716,6 +803,7 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
-Wsuggest-attribute=noreturn \
-Wunused-variable \
-diag-disable=175,188,1684,2259,2312 \
+ $clang_warnflags \
$extra_warnflags \
; do
AS_IF([test "$particular_werror_flags" != yes], [
@@ -794,7 +882,7 @@ AS_IF([test "$GCC" = yes], [
[fortify_source=$enableval])
AS_IF([test "x$fortify_source" != xno], [
RUBY_TRY_CFLAGS([$optflags -D_FORTIFY_SOURCE=2],
- [RUBY_APPEND_OPTION(XCFLAGS, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [],
+ [RUBY_PREPEND_OPTION(hardenflags, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [],
[@%:@include <stdio.h>])
])
@@ -815,18 +903,45 @@ AS_IF([test "$GCC" = yes], [
AC_MSG_CHECKING([for -fstack-protector])
AC_MSG_RESULT(["$stack_protector"])
AS_CASE(["$stack_protector"], [-*], [
- RUBY_APPEND_OPTION(XCFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
+ RUBY_PREPEND_OPTION(hardenflags, $stack_protector)
+ RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
+ RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
])
# aarch64 branch protection
- AS_CASE(["$target_cpu"], [aarch64], [
- AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
- RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
- AS_IF([test "x$branch_protection" = xyes], [
- RUBY_APPEND_OPTION(XCFLAGS, option)
- break
+ AS_CASE(["$target_cpu"], [aarch64|arm64], [
+ # LLVM libunwind is not actually capable of unwinding code compiled with pointer
+ # authentication unless it's built without LIBUNWIND_ENABLE_CROSS_UNWINDING (see
+ # https://github.com/llvm/llvm-project/blob/8e35c86977ce5529a9387657321ac9fefcdae5b5/libunwind/src/DwarfInstructions.hpp#L294)
+ # It seems that macOS ships LLVM compiled this way.
+ # Detect this and disable automatic insertion of pac-ret flags in that case, since we assume
+ # that reliable backtraces are more important than hardening flags.
+ AC_MSG_CHECKING([for a broken LLVM libunwind that cannot unwind code with RA signing])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ @%:@include <libunwind.h>
+ int foo = UNW_ECROSSRASIGNING;
+ ]])],
+ # If compilation succeeds, that means we a) had libunwind, and b) it was NOT native only
+ [rb_cv_libunwind_broken_ra_signing=yes],
+ # if compilation fails, that means we either a) do not have libunwind, or b) have it in
+ # native only mode (which is good!)
+ [rb_cv_libunwind_broken_ra_signing=no]
+ )
+ AC_MSG_RESULT(["$rb_cv_libunwind_broken_ra_signing"])
+ AS_IF([test "x$rb_cv_libunwind_broken_ra_signing" = "xno"], [
+ AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
+ # Try these flags in the _prepended_ position - i.e. we want to try building a program
+ # with CFLAGS="-mbranch-protection=pac-ret $CFLAGS". If the builder has provided different
+ # branch protection flags in CFLAGS, we don't want to overwrite those. We just want to
+ # find some branch protection flags which work if none were provided.
+ RUBY_TRY_CFLAGS_PREPEND(option, [branch_protection=yes], [branch_protection=no])
+ AS_IF([test "x$branch_protection" = xyes], [
+ # _prepend_ the options to CFLAGS, so that user-provided flags will overwrite them.
+ # These CFLAGS are used during the configure script to compile further test programs;
+ # however, $harden_flags is prepended separately to CFLAGS at the end of the script.
+ RUBY_PREPEND_OPTION(hardenflags, $opt)
+ break
+ ])
])
])
])
@@ -882,9 +997,9 @@ AS_IF([test "$GCC" = yes], [
# suppress annoying -Wstrict-overflow warnings
RUBY_TRY_CFLAGS(-fno-strict-overflow, [RUBY_APPEND_OPTION(XCFLAGS, -fno-strict-overflow)])
- test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb3, [debugflags=-ggdb3])}
- test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-ggdb, [debugflags=-ggdb])}
- test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-g3, [debugflags=-g3])}
+ test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-ggdb3, [debugflags=-ggdb3])}
+ test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-ggdb, [debugflags=-ggdb])}
+ test "${debugflags+set}" || {RUBY_TRY_LDFLAGS(-g3, [debugflags=-g3])}
])
test $ac_cv_prog_cc_g = yes && : ${debugflags=-g}
@@ -956,22 +1071,31 @@ AC_ARG_WITH(opt-dir,
[OPT_DIR="${OPT_DIR:+$OPT_DIR$PATH_SEPARATOR}$withval"], [])
AS_IF([test "x$OPT_DIR" != x], [
+ save_IFS="$IFS" IFS="$PATH_SEPARATOR" val= PWD=
+ for dir in $OPT_DIR; do
+ test -z "$dir" && continue
+ dir=`eval $CHDIR '"$dir"' 2>/dev/null && pwd` || continue
+ val="${val:+$val$PATH_SEPARATOR}$dir"
+ done
+ IFS="$save_IFS" OPT_DIR="$val"
+ unset PWD
+ unset save_IFS
val=`IFS="$PATH_SEPARATOR"
for dir in $OPT_DIR; do
- test -z "$dir" && continue
echo x ${LIBPATHFLAG} ${RPATHFLAG} |
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${dir}/lib${IFS}g;s${IFS}%s${IFS}${dir}/lib${IFS}g"
done | tr '\012' ' ' | sed 's/ *$//'`
LDFLAGS="${LDFLAGS:+$LDFLAGS }$val"
DLDFLAGS="${DLDFLAGS:+$DLDFLAGS }$val"
LDFLAGS_OPTDIR="$val"
- CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' |
+ INCFLAGS="${INCFLAGS:+$INCFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' |
sed '/^$/d;s|^|-I|;s|$|/include|' | tr '\012' ' ' | sed 's/ *$//'`
])
+AC_SUBST(incflags, "$INCFLAGS")
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
-}
+
AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
rb_cv_have_stmt_and_decl_in_expr,
@@ -981,8 +1105,9 @@ AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
AS_IF([test "$rb_cv_have_stmt_and_decl_in_expr" = yes], [
AC_DEFINE(HAVE_STMT_AND_DECL_IN_EXPR)
])
+}
-: "header and library section" && {
+[begin]_group "header and library section" && {
AC_ARG_WITH(winnt-ver,
AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0600)]),
[with_winnt_ver="$withval"], [with_winnt_ver="0x0600"])
@@ -1037,7 +1162,6 @@ AS_CASE(["$target_os"],
AS_IF([test $gcc_major -eq 4 -a $gcc_minor -lt 3], [
ac_cv_func___builtin_setjmp=no
])
- with_setjmp_type=sigsetjmp # to hijack SIGCHLD handler
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
@@ -1085,21 +1209,23 @@ main()
])
POSTLINK=""
AC_CHECK_PROGS(codesign, codesign)
- AC_CHECK_PROGS(dsymutil, dsymutil)
+ dsymutils=
+ AS_CASE("$CC_NO_WRAPPER", [gcc*-1[[3-9]]], [
+ dsymutils=${CC_NO_WRAPPER@%:@gcc}
+ dsymutils=dsymutil${dsymutils%-1*}
+ dsymutils="$dsymutils-19 $dsymutils-18 $dsymutils-17"
+ ])
+ AC_CHECK_PROGS(dsymutil, $dsymutils dsymutil)
AS_IF([test -n "$codesign"], [
- POSTLINK="{ test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@; }${POSTLINK:+; $POSTLINK}"
+ POSTLINK="{ test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' \$@; }${POSTLINK:+; $POSTLINK}"
])
AS_IF([test -n "$dsymutil"], [
- POSTLINK="$dsymutil \$@${POSTLINK:+; $POSTLINK}"
- ])
- AS_IF([test -n "${POSTLINK}"], [
- LINK_SO="$LINK_SO
-\$(POSTLINK)"
+ POSTLINK="$dsymutil \$@ 2>/dev/null${POSTLINK:+; $POSTLINK}"
])
AC_CHECK_HEADERS(crt_externs.h, [], [], [
#include <crt_externs.h>
])
- cleanlibs='$(TARGET_SO).dSYM'
+ cleanlibs='$(TARGET_SO:=.dSYM)'
],
[solaris*], [ LIBS="-lm $LIBS"
ac_cv_func_vfork=no
@@ -1170,6 +1296,11 @@ main()
ac_cv_header_sys_time_h=no
ac_cv_header_sys_times_h=no
ac_cv_header_sys_socket_h=no
+ ac_cv_func_chown=yes
+ ac_cv_func_getegid=yes
+ ac_cv_func_geteuid=yes
+ ac_cv_func_getgid=yes
+ ac_cv_func_getuid=yes
ac_cv_func_execv=yes
ac_cv_func_lstat=yes
ac_cv_func_times=yes
@@ -1182,6 +1313,8 @@ main()
ac_cv_func_readlink=yes
ac_cv_func_shutdown=yes
ac_cv_func_symlink=yes
+ ac_cv_func_clock_getres=yes
+ ac_cv_func_clock_gettime=yes
ac_cv_lib_crypt_crypt=no
ac_cv_func_getpgrp_void=no
ac_cv_func_memcmp_working=yes
@@ -1192,19 +1325,18 @@ main()
ac_cv_func_gmtime_r=yes
rb_cv_large_fd_select=yes
ac_cv_type_struct_timeval=yes
- ac_cv_func_clock_gettime=yes
- ac_cv_func_clock_getres=yes
ac_cv_func_malloc_usable_size=no
ac_cv_type_off_t=yes
ac_cv_sizeof_off_t=8
AS_IF([test "$target_cpu" = x64], [
ac_cv_func___builtin_setjmp=yes
ac_cv_func_round=no
+ ac_cv_func_tgamma=no
])
- ac_cv_func_tgamma=no
AC_CHECK_TYPE([NET_LUID], [], [],
[@%:@include <winsock2.h>
- @%:@include <iphlpapi.h>])
+ @%:@include <windows.h>
+ @%:@include <iphlpapi.h>])
AS_IF([test x"$ac_cv_type_NET_LUID" = xyes], [
AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
])
@@ -1234,12 +1366,8 @@ main()
# __builtin_longjmp in ppc64* Linux does not restore
# the TOC register (r2), which is problematic
# when a global exit happens from JITted .so code.
- AS_CASE(["$target_cpu"], [powerpc64*], [
- ac_cv_func___builtin_setjmp=no
- ])
- # With gcc-8's -fcf-protection, RJIT's __builtin_longjmp fails.
- AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
- AS_IF([test "$cf_protection" = yes], [
+ # __builtin_setjmp can have issues on arm64 linux (see [Bug #14480]).
+ AS_CASE(["$target_cpu"], [powerpc64*|arm64|aarch64], [
ac_cv_func___builtin_setjmp=no
])
],
@@ -1252,7 +1380,7 @@ main()
[wasi*],[ LIBS="-lm -lwasi-emulated-mman -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks $LIBS"
RUBY_APPEND_OPTIONS(CFLAGS, -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_GETPID -D_WASI_EMULATED_PROCESS_CLOCKS)
RUBY_APPEND_OPTIONS(CPPFLAGS, -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_GETPID -D_WASI_EMULATED_PROCESS_CLOCKS)
- POSTLINK="\$(WASMOPT) --asyncify \$(wasmoptflags) --pass-arg=asyncify-ignore-imports -o \$@ \$@${POSTLINK:+; $POSTLINK}"
+ POSTLINK="\$(WASMOPT) --asyncify \$(wasmoptflags) -o \$@ \$@${POSTLINK:+; $POSTLINK}"
# wasi-libc's sys/socket.h is not compatible with -std=gnu99,
# so re-declare shutdown in include/ruby/missing.h
ac_cv_func_shutdown=no
@@ -1260,6 +1388,13 @@ main()
[ LIBS="-lm $LIBS"])
: ${ORIG_LIBS=$LIBS}
+AS_IF([test -n "${POSTLINK}"], [
+ # NOTE: A (part of) link commands used link shared extension libraries. If
+ # the first line of the value is empty, mkmf prepends default link steps.
+ LINK_SO="$LINK_SO
+\$(POSTLINK)"
+])
+
AS_IF([test -n "${rb_there_is_in_fact_no_gplusplus_but_autoconf_is_cheating_us}"], [
AC_MSG_NOTICE([Test skipped due to lack of a C++ compiler.])
],
@@ -1312,6 +1447,7 @@ AC_CHECK_HEADERS(process.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(sanitizer/asan_interface.h)
AC_CHECK_HEADERS(sanitizer/msan_interface.h)
+AC_CHECK_HEADERS(sanitizer/tsan_interface.h)
AC_CHECK_HEADERS(setjmpex.h)
AC_CHECK_HEADERS(stdalign.h)
AC_CHECK_HEADERS(stdio.h)
@@ -1339,13 +1475,18 @@ AC_CHECK_HEADERS(syscall.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(ucontext.h)
AC_CHECK_HEADERS(utime.h)
-AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [
+AC_CHECK_HEADERS(sys/epoll.h)
+AC_CHECK_HEADERS(sys/event.h)
+AC_CHECK_HEADERS(stdckdint.h)
+AC_CHECK_HEADERS(stdatomic.h)
+
+AS_CASE("$target_cpu", [x64|x86_64|[i[3-6]86*]], [
AC_CHECK_HEADERS(x86intrin.h)
])
RUBY_UNIVERSAL_CHECK_HEADER([x86_64, i386], x86intrin.h)
AS_IF([test "x$with_gmp" != xno],
- [AC_CHECK_HEADERS(gmp.h)
+ [RUBY_CHECK_HEADER(gmp.h)
AS_IF([test "x$ac_cv_header_gmp_h" != xno],
AC_SEARCH_LIBS([__gmpz_init], [gmp],
[AC_DEFINE(HAVE_LIBGMP, 1)]))])
@@ -1355,6 +1496,8 @@ AC_ARG_WITH([jemalloc],
[with_jemalloc=$withval], [with_jemalloc=no])
AS_IF([test "x$with_jemalloc" != xno],[
# find jemalloc header first
+ save_CPPFLAGS="${CPPFLAGS}"
+ CPPFLAGS="${INCFLAGS} ${CPPFLAGS}"
malloc_header=
AC_CHECK_HEADER(jemalloc/jemalloc.h, [malloc_header=jemalloc/jemalloc.h], [
AC_CHECK_HEADER(jemalloc.h, [malloc_header=jemalloc.h])
@@ -1386,6 +1529,8 @@ AS_IF([test "x$with_jemalloc" != xno],[
done
done
])
+ CPPFLAGS="${save_CPPFLAGS}"
+ unset save_CPPFLAGS
with_jemalloc=${rb_cv_jemalloc_library}
AS_CASE(["$with_jemalloc"],
[no],
@@ -1411,7 +1556,7 @@ AC_SYS_LARGEFILE
# which is not added by AC_SYS_LARGEFILE.
AS_IF([test x"$enable_largefile" != xno], [
AS_CASE(["$target_os"], [solaris*], [
- AC_MSG_CHECKING([wheather _LARGEFILE_SOURCE should be defined])
+ AC_MSG_CHECKING([whether _LARGEFILE_SOURCE should be defined])
AS_CASE(["${ac_cv_sys_file_offset_bits}:${ac_cv_sys_large_files}"],
["64:"|"64:no"|"64:unknown"], [
# insert _LARGEFILE_SOURCE before _FILE_OFFSET_BITS line
@@ -1472,6 +1617,25 @@ RUBY_CHECK_SIZEOF(float)
RUBY_CHECK_SIZEOF(double)
RUBY_CHECK_SIZEOF(time_t, [long "long long"], [], [@%:@include <time.h>])
RUBY_CHECK_SIZEOF(clock_t, [], [], [@%:@include <time.h>])
+AC_SUBST(X_BUILTIN_BINARY, yes)
+AS_IF([test "$cross_compiling" = yes],
+[dnl miniruby cannot run if cross compiling
+ X_BUILTIN_BINARY=no
+],
+[
+ AS_CASE([ac_cv_sizeof_voidp],
+ [[1-9]*], [dnl fixed value
+ ],
+ [
+ AC_CACHE_CHECK([word size], [rb_cv_word_size],
+ [for w in 4 8; do
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@if SIZEOF_VOIDP != ${w}
+ @%:@error SIZEOF_VOIDP
+ @%:@endif]])], [rb_cv_word_size=${w}; break])
+ done])
+ AS_IF([test -z $rb_cv_word_size], [X_BUILTIN_BINARY=no])
+ ])
+])
AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct,
[rb_cv_packed_struct=no
@@ -1591,21 +1755,6 @@ AS_IF([test "$rb_cv_func_weak" != x], [
AC_DEFINE(HAVE_FUNC_WEAK)
])
-AC_CACHE_CHECK([for __attribute__((__depreacted__(msg))) in C++],
- rb_cv_CentOS6_CXX_workaround,
- RUBY_WERROR_FLAG([
- AC_LANG_PUSH([C++])
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [],
- [__attribute__((__deprecated__("message"))) int conftest(...);])],
- [rb_cv_CentOS6_CXX_workaround=yes],
- [rb_cv_CentOS6_CXX_workaround=no])
- AC_LANG_POP()]))
-AS_IF([test "$rb_cv_CentOS6_CXX_workaround" != no],[
- AC_DEFINE([RUBY_CXX_DEPRECATED(msg)],
- [__attribute__((__deprecated__(msg)))])])
-
AC_CACHE_CHECK([for std::nullptr_t], rb_cv_CXX_nullptr, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
@@ -1655,6 +1804,26 @@ AS_IF([test "$GCC" = yes], [
[rb_cv_gcc_atomic_builtins=no])])
AS_IF([test "$rb_cv_gcc_atomic_builtins" = yes], [
AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS)
+ for lib in "" atomic; do
+ AS_IF([test "$lib" != ""], [
+ AC_CHECK_LIB([atomic], [__atomic_fetch_add_8])
+ unset rb_cv_gcc_atomic_builtins_64
+ ])
+ AC_CACHE_CHECK([for 64bit __atomic builtins${lib:+ with -l$lib}],
+ [rb_cv_gcc_atomic_builtins_64], [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdint.h>
+ uint64_t atomic_var;]],
+ [[
+ __atomic_load_n(&atomic_var, __ATOMIC_RELAXED);
+ __atomic_store_n(&atomic_var, 0, __ATOMIC_RELAXED);
+ ]])],
+ [rb_cv_gcc_atomic_builtins_64=yes],
+ [rb_cv_gcc_atomic_builtins_64=no])])
+ AS_IF([test "$rb_cv_gcc_atomic_builtins_64" = yes], [
+ AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS_64)
+ break
+ ])
+ done
])
AC_CACHE_CHECK([for __sync builtins], [rb_cv_gcc_sync_builtins], [
@@ -1701,7 +1870,7 @@ AS_IF([test "$GCC" = yes], [
AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [
rb_cv_func_exported=no
RUBY_WERROR_FLAG([
-for mac in '__attribute__ ((__visibility__("default")))' '__declspec(dllexport)'; do
+for mac in '__declspec(dllexport)' '__attribute__ ((__visibility__("default")))'; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@define RUBY_FUNC_EXPORTED $mac extern
RUBY_FUNC_EXPORTED void conftest_attribute_check(void);]], [[]])],
[rb_cv_func_exported="$mac"; break])
@@ -1718,16 +1887,12 @@ RUBY_DECL_ATTRIBUTE([__nonnull__(n)], [RUBY_FUNC_NONNULL(n,x)], [rb_cv_func_nonn
RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_EXPORT)
-AC_ARG_ENABLE(mathn,
- AS_HELP_STRING([--enable-mathn], [enable canonicalization for mathn]),
- [AC_MSG_ERROR([mathn support has been dropped])])
-
AC_CACHE_CHECK(for function name string predefined identifier,
rb_cv_function_name_string,
[AS_CASE(["$target_os"],[openbsd*],[
rb_cv_function_name_string=__func__
],[
- rb_cv_function_name_string=no
+ rb_cv_function_name_string=no
RUBY_WERROR_FLAG([
for func in __func__ __FUNCTION__; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>]],
@@ -1735,7 +1900,8 @@ AC_CACHE_CHECK(for function name string predefined identifier,
[rb_cv_function_name_string=$func
break])
done
- ])])]
+ ])
+ ])]
)
AS_IF([test "$rb_cv_function_name_string" != no], [
AC_DEFINE_UNQUOTED(RUBY_FUNCTION_NAME_STRING, [$rb_cv_function_name_string])
@@ -1995,6 +2161,7 @@ AC_CHECK_FUNCS(_longjmp) # used for AC_ARG_WITH(setjmp-type)
test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
AC_CHECK_FUNCS(arc4random_buf)
AC_CHECK_FUNCS(atan2l atan2f)
+AC_CHECK_DECLS(atomic_signal_fence, [], [], [@%:@include <stdatomic.h>])
AC_CHECK_FUNCS(chmod)
AC_CHECK_FUNCS(chown)
AC_CHECK_FUNCS(chroot)
@@ -2018,6 +2185,7 @@ AC_CHECK_FUNCS(execv)
AC_CHECK_FUNCS(execve)
AC_CHECK_FUNCS(explicit_memset)
AC_CHECK_FUNCS(fcopyfile)
+AC_CHECK_FUNCS(fchdir)
AC_CHECK_FUNCS(fchmod)
AC_CHECK_FUNCS(fchown)
AC_CHECK_FUNCS(fcntl)
@@ -2058,7 +2226,6 @@ AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday
AC_CHECK_FUNCS(getuid)
AC_CHECK_FUNCS(getuidx)
AC_CHECK_FUNCS(gmtime_r)
-AC_CHECK_FUNCS(grantpt)
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS(ioctl)
AC_CHECK_FUNCS(isfinite)
@@ -2075,6 +2242,7 @@ AC_CHECK_FUNCS(lstat)
AC_CHECK_FUNCS(lutimes)
AC_CHECK_FUNCS(malloc_usable_size)
AC_CHECK_FUNCS(malloc_size)
+AC_CHECK_FUNCS(malloc_trim)
AC_CHECK_FUNCS(mblen)
AC_CHECK_FUNCS(memalign)
AC_CHECK_FUNCS(memset_s)
@@ -2128,6 +2296,7 @@ AC_CHECK_FUNCS(sigaction)
AC_CHECK_FUNCS(sigaltstack)
AC_CHECK_FUNCS(sigprocmask)
AC_CHECK_FUNCS(sinh)
+AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(spawnv)
AC_CHECK_FUNCS(symlink)
AC_CHECK_FUNCS(syscall)
@@ -2152,9 +2321,6 @@ AC_CHECK_FUNCS(__sinpi)
AS_IF([test "x$ac_cv_member_struct_statx_stx_btime" = xyes],
[AC_CHECK_FUNCS(statx)])
-AS_CASE(["$ac_cv_func_memset_s:$ac_cv_func_qsort_s"], [*yes*],
- [RUBY_DEFINE_IF([!defined __STDC_WANT_LIB_EXT1__], [__STDC_WANT_LIB_EXT1__], 1)])
-
AS_IF([test "$ac_cv_func_getcwd" = yes], [
AC_CACHE_CHECK(if getcwd allocates buffer if NULL is given, [rb_cv_getcwd_malloc],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -2204,10 +2370,6 @@ RUBY_CHECK_BUILTIN_FUNC(__builtin_clzl, [__builtin_clzl(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_clzll, [__builtin_clzll(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_ctz, [__builtin_ctz(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_ctzll, [__builtin_ctzll(0)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_add_overflow, [int x;__builtin_add_overflow(0,0,&x)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_sub_overflow, [int x;__builtin_sub_overflow(0,0,&x)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_mul_overflow, [int x;__builtin_mul_overflow(0,0,&x)])
-RUBY_CHECK_BUILTIN_FUNC(__builtin_mul_overflow_p, [__builtin_mul_overflow_p(0,0,(int)0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_constant_p, [__builtin_constant_p(0)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_choose_expr, [
[int x[__extension__(__builtin_choose_expr(1, 1, -1))]];
@@ -2223,6 +2385,10 @@ RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatibl
RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
RUBY_CHECK_BUILTIN_FUNC(__builtin_expect, [__builtin_expect(0, 0)])
+RUBY_CHECK_BUILTIN_OVERFLOW(add)
+RUBY_CHECK_BUILTIN_OVERFLOW(sub)
+RUBY_CHECK_BUILTIN_OVERFLOW(mul)
+
AS_IF([test "$ac_cv_func_qsort_r" != no], [
AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -2348,9 +2514,7 @@ AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
#include <time.h>
void
-check(tm, y, m, d, h, s)
- struct tm *tm;
- int y, m, d, h, s;
+check(struct tm *tm, int y, int m, int d, int h, int s)
{
if (!tm ||
tm->tm_year != y ||
@@ -2434,8 +2598,7 @@ AS_IF([test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = ye
#include <signal.h>
void
-sig_handler(dummy)
- int dummy;
+sig_handler(int dummy)
{
}
@@ -2610,6 +2773,9 @@ AS_CASE([$coroutine_type], [yes|''], [
[*86-mingw*], [
coroutine_type=win32
],
+ [aarch64-mingw*], [
+ coroutine_type=arm64
+ ],
[arm*-linux*], [
coroutine_type=arm32
],
@@ -2634,6 +2800,12 @@ AS_CASE([$coroutine_type], [yes|''], [
[aarch64-freebsd*], [
coroutine_type=arm64
],
+ [powerpc64-freebsd*], [
+ coroutine_type=ppc64le
+ ],
+ [powerpc64le-freebsd*], [
+ coroutine_type=ppc64le
+ ],
[x86_64-netbsd*], [
coroutine_type=amd64
],
@@ -2652,6 +2824,9 @@ AS_CASE([$coroutine_type], [yes|''], [
[aarch64-openbsd*], [
coroutine_type=arm64
],
+ [riscv64-openbsd*], [
+ coroutine_type=riscv64
+ ],
[*-openbsd*], [
coroutine_type=pthread
],
@@ -2749,6 +2924,22 @@ AS_IF([test "$THREAD_MODEL" = pthread], [
AC_DEFINE_UNQUOTED(SET_ANOTHER_THREAD_NAME(thid,name), $set_another_thread_name)
])
])
+
+ AC_CACHE_CHECK([for thread-local storage specifier], [rb_cv_tls_specifier],
+ rb_cv_tls_specifier=none
+ RUBY_WERROR_FLAG([
+ for attr in \
+ _Thread_local \
+ __thread \
+ ; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$attr int conftest;]])],
+ [rb_cv_tls_specifier=$attr; break])
+ done
+ ])
+ )
+ AS_IF([test x"${rb_cv_tls_specifier}" != xnone],
+ [AC_DEFINE_UNQUOTED(RB_THREAD_LOCAL_SPECIFIER, ${rb_cv_tls_specifier})]
+ )
])
AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [
@@ -2892,8 +3083,8 @@ AS_IF([test "x$ac_cv_func_ioctl" = xyes], [
}
-: "runtime section" && {
-dnl wheather use dln_a_out or not
+[begin]_group "runtime section" && {
+dnl whether use dln_a_out or not
AC_ARG_WITH(dln-a-out,
AS_HELP_STRING([--with-dln-a-out], [dln_a_out is deprecated]),
[
@@ -2928,14 +3119,6 @@ LIBEXT=a
AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl
-AC_SUBST(RJIT_CC)dnl
-AS_CASE(["$GCC:$target_os"],
- [yes:aix*], [rjit_std_cflag="-std=gnu99"],
- [rjit_std_cflag=])
-AC_SUBST(RJIT_CFLAGS, [${RJIT_CFLAGS-"-w ${rjit_std_cflag} ${orig_cflags}"}])dnl
-AC_SUBST(RJIT_OPTFLAGS, [${RJIT_OPTFLAGS-'$(optflags)'}])dnl
-AC_SUBST(RJIT_DEBUGFLAGS, [${RJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
-AC_SUBST(RJIT_LDSHARED)dnl
AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
@@ -3049,11 +3232,10 @@ AC_SUBST(EXTOBJS)
[darwin*], [ : ${LDSHARED='$(CC) -dynamic -bundle'}
: ${DLDSHARED='$(CC) -dynamiclib'}
: ${LDFLAGS=""}
- : ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH}
+ : ${LIBPATHENV=DYLD_LIBRARY_PATH}
: ${PRELOADENV=DYLD_INSERT_LIBRARIES}
AS_IF([test x"$enable_shared" = xyes], [
- # Resolve symbols from libruby.dylib when --enable-shared
- EXTDLDFLAGS='$(LIBRUBYARG_SHARED)'
+ # Resolve symbols from libruby.dylib in $(LIBS) when --enable-shared
], [test "x$EXTSTATIC" = x], [
# When building exts as bundles, a mach-o bundle needs to know its loader
# program to bind symbols from the ruby executable
@@ -3089,6 +3271,7 @@ AC_SUBST(EXTOBJS)
[hiuxmpp], [ : ${LDSHARED='$(LD) -r'}],
[atheos*], [ : ${LDSHARED='$(CC) -shared'}
rb_cv_dlopen=yes],
+ [wasi*], [ : ${LDSHARED='$(LD) -shared -Xlinker --export-dynamic'}],
[ : ${LDSHARED='$(LD)'}])
AC_MSG_RESULT($rb_cv_dlopen)
}
@@ -3253,7 +3436,6 @@ AS_IF([test x$with_valgrind != xno],
DLEXT=so])
: ${SOEXT="${DLEXT}"}
AC_SUBST(SOEXT)
-}
AS_IF([test "$rb_cv_dlopen:$load_relative" = yes:yes], [
AS_IF([test "$ac_cv_func_dladdr" = yes], [
@@ -3272,6 +3454,9 @@ AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
AC_SUBST(DLEXT)
+AC_DEFINE_UNQUOTED(SOEXT, ".$SOEXT")
+}
+
: "strip" && {
AC_MSG_CHECKING([for $STRIP flags])
AC_LINK_IFELSE([AC_LANG_PROGRAM], [AS_IF(
@@ -3344,7 +3529,7 @@ done
BTESTRUBY='$(MINIRUBY)'
AS_IF([test x"$cross_compiling" = xyes], [
- test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I`$CHDIR .; pwd` "-r'$(arch)-fake'
+ test x"$MINIRUBY" = x && MINIRUBY="${RUBY-$BASERUBY} -I${ac_abs_builddir-.} "-r'$(arch)-fake'
XRUBY_LIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["libdir"]']`
XRUBY_RUBYLIBDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["rubylibdir"]']`
XRUBY_RUBYHDRDIR=`${RUBY-$BASERUBY} -rrbconfig -e ['puts RbConfig::CONFIG["rubyhdrdir"]']`
@@ -3356,7 +3541,7 @@ AS_IF([test x"$cross_compiling" = xyes], [
# darwin target requires miniruby for linking ext bundles
PREP="$PREP"' miniruby$(EXEEXT)'
])
- RUNRUBY_COMMAND='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
+ RUNRUBY_COMMAND='$(MINIRUBY) -I`$(CHDIR) $(srcdir)/lib; pwd`'
RUNRUBY='$(RUNRUBY_COMMAND)'
XRUBY='$(MINIRUBY)'
TEST_RUNNABLE=no
@@ -3382,7 +3567,6 @@ AC_SUBST(RUNRUBY)
AC_SUBST(XRUBY)
AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
-FIRSTMAKEFILE=""
LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
@@ -3399,7 +3583,11 @@ AS_CASE(["$target_os"],
AC_ARG_ENABLE(multiarch,
AS_HELP_STRING([--enable-multiarch], [enable multiarch compatible directories]),
- [multiarch=], [unset multiarch])
+ [AS_CASE([$enableval], [no], [unset multiarch], [multiarch=])],
+ [unset multiarch])
+AS_IF([test ${multiarch+set}], [
+ AC_DEFINE(ENABLE_MULTIARCH)
+])
archlibdir='${libdir}/${arch}'
sitearchlibdir='${libdir}/${sitearch}'
@@ -3419,7 +3607,7 @@ AC_ARG_WITH(soname,
],
[mingw*], [
RUBY_SO_NAME="${rb_cv_msvcrt}"'-$(RUBY_BASE_NAME)$(MAJOR)$(MINOR)0'
- AS_IF([test x"${target_cpu}" != xi386], [
+ AS_IF([test x"${target_cpu}" != xi386 || test x"${rb_cv_msvcrt}" != xmsvcrt], [
RUBY_SO_NAME="${target_cpu}-${RUBY_SO_NAME}"
])
],
@@ -3476,6 +3664,7 @@ AS_CASE("$enable_shared", [yes], [
])
])
+ relative_libprefix="/../${multiarch+../}${libdir_basename}"
AS_CASE(["$target_os"],
[sunos4*], [
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
@@ -3484,7 +3673,7 @@ AS_CASE("$enable_shared", [yes], [
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"])
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
AS_IF([test "$load_relative" = yes], [
- libprefix="'\$\${ORIGIN}/../${libdir_basename}'"
+ libprefix="'\$\${ORIGIN}${relative_libprefix}'"
LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}"
LIBRUBY_RELATIVE=yes
])
@@ -3496,7 +3685,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
LIBRUBY_ALIASES=''
], [test "$load_relative" = yes], [
- libprefix="'\$\$ORIGIN/../${libdir_basename}'"
+ libprefix="'\$\$ORIGIN${relative_libprefix}'"
LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}"
LIBRUBY_RELATIVE=yes
])
@@ -3520,7 +3709,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-h${linker_flag:+,}"'$(@F)'])
AS_IF([test "$load_relative" = yes], [
- libprefix="'\$\$ORIGIN/../${libdir_basename}'"
+ libprefix="'\$\$ORIGIN${relative_libprefix}'"
LIBRUBY_RPATHFLAGS="-R${libprefix}"
LIBRUBY_RELATIVE=yes
], [
@@ -3537,7 +3726,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_SONAME='$(LIBRUBY_SO)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(SOEXT)'
AS_IF([test "$load_relative" = yes], [
- libprefix="@executable_path/../${libdir_basename}"
+ libprefix="@executable_path${relative_libprefix}"
LIBRUBY_RELATIVE=yes
])
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS -install_name ${libprefix}"'/$(LIBRUBY_SONAME)'
@@ -3545,6 +3734,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-current_version $(RUBY_PROGRAM_VERSION)'
AS_IF([test "$visibility_option" = ld], [
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,_Init_*'
+ LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,_InitVM_*'
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,_ruby_static_id_*'
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-Wl,-unexported_symbol,*_threadptr_*'
])
@@ -3585,16 +3775,16 @@ AS_CASE("$enable_shared", [yes], [
])
])
AS_IF([test "$enable_rpath" = yes], [
- test -z "$LIBRUBY_RPATHFLAGS" || LIBRUBY_RPATHFLAGS="$LIBRUBY_RPATHFLAGS "
- rpathflag="${RPATHFLAG}"
- AS_CASE(["${cross_compiling}${load_relative}"], [*yes*], [], [rpathflag="$RPATHFLAG$LIBPATHFLAG"])
+ AS_CASE(["${cross_compiling}${load_relative}"],
+ [*yes*], [rpathflag="${RPATHFLAG}"],
+ [rpathflag="$RPATHFLAG${LIBPATHFLAG:+${RPATHFLAG:+ }$LIBPATHFLAG}"])
rpathflag=`IFS="$PATH_SEPARATOR"
echo x "$rpathflag" |
sed "s/^x *//;s${IFS}"'%1\\$-s'"${IFS}${libprefix}${IFS}g;s${IFS}%s${IFS}${libprefix}${IFS}g"
`
- LIBRUBY_RPATHFLAGS="$LIBRUBY_RPATHFLAGS${rpathflag}"
- LIBRUBYARG_SHARED="$LIBRUBY_RPATHFLAGS $LIBRUBYARG_SHARED"
- LIBRUBYARG_STATIC="$LIBRUBY_RPATHFLAGS $LIBRUBYARG_STATIC"
+ LIBRUBY_RPATHFLAGS="${LIBRUBY_RPATHFLAGS:+$LIBRUBY_RPATHFLAGS }${rpathflag}"
+ LIBRUBYARG_SHARED="${LIBRUBY_RPATHFLAGS:+$LIBRUBY_RPATHFLAGS }$LIBRUBYARG_SHARED"
+ LIBRUBYARG_STATIC="${LIBRUBY_RPATHFLAGS:+$LIBRUBY_RPATHFLAGS }$LIBRUBYARG_STATIC"
])
AC_SUBST(LIBRUBY_RELATIVE)
@@ -3671,14 +3861,15 @@ AC_ARG_ENABLE(gcov,
AS_HELP_STRING([--enable-gcov], [enable coverage measurement by gcov]),
[gcov=yes])
AS_IF([test x"$gcov" = xyes], [
- CFLAGS="$CFLAGS -coverage"
+ CFLAGS="$CFLAGS -coverage -fprofile-update=atomic"
LDFLAGS="$LDFLAGS -coverage"
])
RUBY_SETJMP_TYPE
+RUBY_MODULAR_GC
}
-: "build section" && {
+[begin]_group "installation section" && {
dnl build rdoc index if requested
RDOCTARGET=""
CAPITARGET=""
@@ -3726,42 +3917,55 @@ AC_SUBST(CAPITARGET)
AS_CASE(["$RDOCTARGET:$CAPITARGET"],[nodoc:nodoc],[INSTALLDOC=nodoc],[INSTALLDOC=all])
AC_SUBST(INSTALLDOC)
+AC_ARG_ENABLE(install-static-library,
+ AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]),
+ [INSTALL_STATIC_LIBRARY=$enableval
+ AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno],
+ [AC_MSG_ERROR([must install either static or shared library])],
+ [])],
+ AS_IF([test x"$enable_shared" = xyes],
+ [INSTALL_STATIC_LIBRARY=no],
+ [INSTALL_STATIC_LIBRARY=yes]))
+AC_SUBST(INSTALL_STATIC_LIBRARY)
+}
+
+[begin]_group "JIT section" && {
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix
dnl check if rustc is recent enough to build YJIT (rustc >= 1.58.0)
-YJIT_RUSTC_OK=no
+JIT_RUSTC_OK=no
+JIT_TARGET_ARCH=
AS_IF([test "$RUSTC" != "no"],
AC_MSG_CHECKING([whether ${RUSTC} works for YJIT])
- YJIT_TARGET_ARCH=
AS_CASE(["$target_cpu"],
- [arm64|aarch64], [YJIT_TARGET_ARCH=aarch64],
- [x86_64], [YJIT_TARGET_ARCH=x86_64],
+ [arm64|aarch64], [JIT_TARGET_ARCH=aarch64],
+ [x86_64], [JIT_TARGET_ARCH=x86_64],
)
dnl Fails in case rustc target doesn't match ruby target.
dnl Can happen on Rosetta, for example.
- AS_IF([echo "#[cfg(target_arch = \"$YJIT_TARGET_ARCH\")] fn main() { let x = 1; format!(\"{x}\"); }" |
+ AS_IF([echo "#[cfg(target_arch = \"$JIT_TARGET_ARCH\")] fn main() { let x = 1; format!(\"{x}\"); }" |
$RUSTC - --emit asm=/dev/null 2>/dev/null],
- [YJIT_RUSTC_OK=yes]
+ [JIT_RUSTC_OK=yes]
)
- AC_MSG_RESULT($YJIT_RUSTC_OK)
+ AC_MSG_RESULT($JIT_RUSTC_OK)
)
-dnl check if we can build YJIT on this target platform
+dnl check if we can build YJIT/ZJIT on this target platform
dnl we can't easily cross-compile with rustc so we don't support that
-YJIT_TARGET_OK=no
+JIT_TARGET_OK=no
AS_IF([test "$cross_compiling" = no],
AS_CASE(["$target_cpu-$target_os"],
[*android*], [
- YJIT_TARGET_OK=no
+ JIT_TARGET_OK=no
],
[arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [
- YJIT_TARGET_OK=yes
+ JIT_TARGET_OK=yes
],
[arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [
- YJIT_TARGET_OK=yes
+ JIT_TARGET_OK=yes
],
[arm64-*bsd*|aarch64-*bsd*|x86_64-*bsd*], [
- YJIT_TARGET_OK=yes
+ JIT_TARGET_OK=yes
]
)
)
@@ -3771,7 +3975,7 @@ AC_ARG_ENABLE(yjit,
AS_HELP_STRING([--enable-yjit],
[enable in-process JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.58.0+ is available]),
[YJIT_SUPPORT=$enableval],
- [AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"],
+ [AS_CASE(["$JIT_TARGET_OK:$JIT_RUSTC_OK"],
[yes:yes], [
YJIT_SUPPORT=yes
],
@@ -3779,9 +3983,33 @@ AC_ARG_ENABLE(yjit,
)]
)
-CARGO=
+dnl build ZJIT in release mode if rustc >= 1.85.0 is present and we are on a supported platform
+ZJIT_SUPPORT=no
+AC_ARG_ENABLE(zjit,
+ AS_HELP_STRING([--enable-zjit],
+ [enable experimental JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.85.0+ is available]),
+ [ZJIT_SUPPORT=$enableval],
+ [AS_CASE(["$JIT_TARGET_OK"],
+ [yes], [
+ rb_zjit_build_possible=no
+ AC_MSG_CHECKING([prerequisites for ZJIT])dnl only checked when --enable-zjit is not specified
+ # Fails in case rustc target doesn't match ruby target. Can happen on Rosetta, for example.
+ # 1.85.0 is the first stable version that supports the 2024 edition.
+ AS_IF([test "$RUSTC" != "no" && echo "#[cfg(target_arch = \"$JIT_TARGET_ARCH\")] fn main() {}" |
+ $RUSTC - --edition=2024 --emit asm=/dev/null 2>/dev/null],
+ AS_IF([test "$gnumake" = "yes"], [
+ rb_zjit_build_possible=yes
+ ])
+ )
+ AC_MSG_RESULT($rb_zjit_build_possible)
+ ZJIT_SUPPORT=$rb_zjit_build_possible
+ ]
+ )]
+)
+
CARGO_BUILD_ARGS=
YJIT_LIBS=
+JIT_CARGO_SUPPORT=no
AS_CASE(["${YJIT_SUPPORT}"],
[yes|dev|stats|dev_nodebug], [
AS_IF([test x"$RUSTC" = "xno"],
@@ -3790,35 +4018,26 @@ AS_CASE(["${YJIT_SUPPORT}"],
AS_CASE(["${YJIT_SUPPORT}"],
[yes], [
- rb_rust_target_subdir=release
],
[dev], [
- rb_rust_target_subdir=debug
- CARGO_BUILD_ARGS='--features stats,disasm'
+ rb_cargo_features='disasm,runtime_checks'
+ JIT_CARGO_SUPPORT=dev
AC_DEFINE(RUBY_DEBUG, 1)
],
[dev_nodebug], [
- rb_rust_target_subdir=dev_nodebug
- CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm'
+ rb_cargo_features='disasm'
+ JIT_CARGO_SUPPORT=dev_nodebug
+ AC_DEFINE(YJIT_STATS, 1)
],
[stats], [
- rb_rust_target_subdir=stats
- CARGO_BUILD_ARGS='--profile stats --features stats'
+ JIT_CARGO_SUPPORT=stats
AC_DEFINE(YJIT_STATS, 1)
])
- AS_IF([test -n "${CARGO_BUILD_ARGS}"], [
- AC_CHECK_TOOL(CARGO, [cargo], [no])
- AS_IF([test x"$CARGO" = "xno"],
- AC_MSG_ERROR([cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install])
- ]))
-
- YJIT_LIBS="yjit/target/${rb_rust_target_subdir}/libyjit.a"
- AS_CASE(["$target_os"],[openbsd*],[
- # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
- LDFLAGS="$LDFLAGS -lpthread -lc++abi"
- ])
+ YJIT_LIBS="target/release/libyjit.a"
+ RUST_LIB='$(YJIT_LIBS)'
YJIT_OBJ='yjit.$(OBJEXT)'
+ JIT_OBJ='jit.$(OBJEXT)'
AS_IF([test x"$YJIT_SUPPORT" != "xyes" ], [
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
])
@@ -3827,73 +4046,121 @@ AS_CASE(["${YJIT_SUPPORT}"],
AC_DEFINE(USE_YJIT, 0)
])
-dnl These variables end up in ::RbConfig::CONFIG
-AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes
-AC_SUBST(RUSTC)dnl Rust compiler command
-AC_SUBST(CARGO)dnl Cargo command for Rust builds
-AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
-AC_SUBST(YJIT_LIBS)dnl for optionally building the Rust parts of YJIT
-AC_SUBST(YJIT_OBJ)dnl for optionally building the C parts of YJIT
-
-dnl Currently, RJIT only supports Unix x86_64 platforms.
-RJIT_TARGET_OK=no
-AS_IF([test "$cross_compiling" = no],
- AS_CASE(["$target_cpu-$target_os"],
- [*android*], [
- RJIT_TARGET_OK=no
- ],
- [x86_64-darwin*], [
- RJIT_TARGET_OK=yes
- ],
- [x86_64-*linux*], [
- RJIT_TARGET_OK=yes
- ],
- [x86_64-*bsd*], [
- RJIT_TARGET_OK=yes
- ]
+ZJIT_LIBS=
+AS_CASE(["${ZJIT_SUPPORT}"],
+[yes|dev|dev_nodebug|stats], [
+ AS_IF([test x"$RUSTC" = "xno"],
+ AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install])
)
-)
-dnl Build RJIT on Unix x86_64 platforms or if --enable-rjit is specified.
-AC_ARG_ENABLE(rjit,
- AS_HELP_STRING([--enable-rjit],
- [enable pure-Ruby JIT compiler. enabled by default on Unix x86_64 platforms]),
- [RJIT_SUPPORT=$enableval],
- [AS_CASE(["$YJIT_TARGET_OK"],
- [yes], [RJIT_SUPPORT=yes],
- [RJIT_SUPPORT=no]
- )]
-)
-
-AS_CASE(["$RJIT_SUPPORT"],
-[yes|dev], [
- # Link libcapstone for --rjit-dump-disasm
- AC_CHECK_LIB([capstone], [cs_disasm])
-
- AS_CASE(["$RJIT_SUPPORT"],
+ AS_CASE(["${ZJIT_SUPPORT}"],
+ [yes], [
+ ],
[dev], [
- # Enable RJIT_STATS (vm_insns_count of --rjit-stats)
+ rb_cargo_features="$rb_cargo_features,disasm,runtime_checks"
+ JIT_CARGO_SUPPORT=dev
AC_DEFINE(RUBY_DEBUG, 1)
+ ],
+ [dev_nodebug], [
+ rb_cargo_features="$rb_cargo_features,disasm"
+ JIT_CARGO_SUPPORT=dev_nodebug
+ AC_DEFINE(ZJIT_STATS, 1)
+ ],
+ [stats], [
+ JIT_CARGO_SUPPORT=stats
+ AC_DEFINE(ZJIT_STATS, 1)
])
- AC_DEFINE(USE_RJIT, 1)
+ ZJIT_LIBS="target/release/libzjit.a"
+ RUST_LIB='$(ZJIT_LIBS)'
+ ZJIT_OBJ='zjit.$(OBJEXT)'
+ JIT_OBJ='jit.$(OBJEXT)'
+ AS_IF([test x"$ZJIT_SUPPORT" != "xyes" ], [
+ AC_DEFINE_UNQUOTED(ZJIT_SUPPORT, [$ZJIT_SUPPORT])
+ ])
+ AC_DEFINE(USE_ZJIT, 1)
], [
- AC_DEFINE(USE_RJIT, 0)
+ AC_DEFINE(USE_ZJIT, 0)
])
-AC_SUBST(RJIT_SUPPORT)
+RUSTC_FLAGS='-g -C lto=thin -C opt-level=3 -C overflow-checks=on'
+AS_IF([test -n "${rustc_flags}"], [
+ RUSTC_FLAGS="${RUSTC_FLAGS} ${rustc_flags}"
+])
-AC_ARG_ENABLE(install-static-library,
- AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]),
- [INSTALL_STATIC_LIBRARY=$enableval
- AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno],
- [AC_MSG_ERROR([must install either static or shared library])],
- [])],
- AS_IF([test x"$enable_shared" = xyes],
- [INSTALL_STATIC_LIBRARY=no],
- [INSTALL_STATIC_LIBRARY=yes]))
-AC_SUBST(INSTALL_STATIC_LIBRARY)
+JIT_RUST_FLAGS='--crate-type=staticlib --cfg feature=\"stats_allocator\"'
+RLIB_DIR=
+AS_CASE(["$JIT_CARGO_SUPPORT:$YJIT_SUPPORT:$ZJIT_SUPPORT"],
+[no:yes:yes], [ # release build of YJIT+ZJIT
+ YJIT_LIBS=
+ ZJIT_LIBS=
+ JIT_RUST_FLAGS="--crate-type=rlib"
+ RLIB_DIR="target/release"
+ RUST_LIB="target/release/libruby.a"
+],
+[no:*], [],
+[ # JIT_CARGO_SUPPORT not "no" -- cargo required.
+ AC_CHECK_TOOL(CARGO, [cargo], [no])
+ AS_IF([test x"$CARGO" = "xno"],
+ AC_MSG_ERROR([this build configuration requires cargo. Installation instructions available at https://www.rust-lang.org/tools/install]))
+
+ YJIT_LIBS=
+ ZJIT_LIBS=
+
+ # There's more processing below to get the feature set for the
+ # top-level crate, so capture at this point for feature set of
+ # just the zjit crate.
+ ZJIT_TEST_FEATURES="${rb_cargo_features}"
+
+ AS_IF([test x"${YJIT_SUPPORT}" != x"no"], [
+ rb_cargo_features="$rb_cargo_features,yjit"
+ ])
+ AS_IF([test x"${ZJIT_SUPPORT}" != x"no"], [
+ AC_SUBST(ZJIT_TEST_FEATURES)
+ rb_cargo_features="$rb_cargo_features,zjit"
+ ])
+ # if YJIT and ZJIT release mode
+ AS_IF([test "${YJIT_SUPPORT}:${ZJIT_SUPPORT}" = "yes:yes"], [
+ JIT_CARGO_SUPPORT=release
+ ])
+ CARGO_BUILD_ARGS="--profile ${JIT_CARGO_SUPPORT} --features ${rb_cargo_features}"
+ AS_IF([test "${JIT_CARGO_SUPPORT}" = "dev"], [
+ RUST_LIB="target/debug/libruby.a"
+ ], [
+ RUST_LIB="target/${JIT_CARGO_SUPPORT}/libruby.a"
+ ])
+])
+
+# In case either we're linking rust code
+AS_IF([test -n "$RUST_LIB"], [
+ AS_CASE(["$target_os"],[openbsd*],[
+ # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by rust stdlib
+ LDFLAGS="$LDFLAGS -lpthread -lc++abi"
+ ])
+
+ # absolute path to stop the "target" dir in src dir from interfering through VPATH
+ RUST_LIB="$(pwd)/${RUST_LIB}"
+])
+
+dnl These variables end up in ::RbConfig::CONFIG
+AC_SUBST(RUSTC)dnl Rust compiler command
+AC_SUBST(JIT_RUST_FLAGS)dnl the common rustc flags for JIT crates such as zjit
+AC_SUBST(RUSTC_FLAGS)dnl user-configurable rustc compiler flags
+AC_SUBST(CARGO)dnl Cargo command for Rust builds
+AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
+AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes
+AC_SUBST(YJIT_LIBS)dnl the .a library of YJIT
+AC_SUBST(YJIT_OBJ)dnl for optionally building the C parts of YJIT
+AC_SUBST(ZJIT_SUPPORT)dnl what flavor of ZJIT the Ruby build includes
+AC_SUBST(ZJIT_LIBS)dnl path to the .a library of ZJIT
+AC_SUBST(ZJIT_OBJ)dnl for optionally building the C parts of ZJIT
+AC_SUBST(JIT_OBJ)dnl for optionally building C glue code for Rust FFI
+AC_SUBST(RUST_LIB)dnl path to the rust .a library that contains either or both JITs
+AC_SUBST(RLIB_DIR)dnl subpath of build directory for .rlib files
+AC_SUBST(JIT_CARGO_SUPPORT)dnl "no" or the cargo profile of the rust code
+}
+[begin]_group "build section" && {
AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern void conftest_external(void) {}]], [[]])],[
rb_cv_symbol_prefix=`$NM conftest.$ac_objext |
@@ -3904,6 +4171,25 @@ AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [
])
SYMBOL_PREFIX="$rb_cv_symbol_prefix"
test "x$SYMBOL_PREFIX" = xNONE && SYMBOL_PREFIX=''
+
+AS_IF([test x"$SOEXT" = xdll], [
+ # DLL on Windows is managed by win32/mkexports.rb
+], [test x"$enable_shared" = xyes], [
+ AC_CACHE_CHECK([for default symbols in empty shared library], rb_cv_symbols_in_emptylib, [
+ save_CC="$CC"
+ eval CC=\"`printf "%s" "${DLDSHARED}" | sed ['s/\$(CC)/${CC}/']`\"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
+ rb_cv_symbols_in_emptylib=`$NM -Pgp conftest$ac_exeext |
+ sed ["/ [A-TV-Z] .*/!d;s///;s/^${SYMBOL_PREFIX}//;/^main$/d"]`
+ ])
+ set dummy ${rb_cv_symbols_in_emptylib}
+ shift
+ rb_cv_symbols_in_emptylib="$*"
+ CC="$save_CC"
+ ])
+])
+AC_SUBST(XSYMBOLS_IN_EMPTYLIB, "${rb_cv_symbols_in_emptylib}")
+
DLNOBJ=dln.o
AC_ARG_ENABLE(dln,
AS_HELP_STRING([--disable-dln], [disable dynamic link feature]),
@@ -3918,7 +4204,8 @@ AS_CASE(["$target_os"],
RUBY_APPEND_OPTION(CFLAGS, -pipe)
],
[darwin*], [
- RUBY_APPEND_OPTION(CFLAGS, -pipe)
+ RUBY_TRY_CFLAGS(-pipe, [pipe_opt=yes], [pipe_opt=no])
+ AS_IF([test $pipe_opt = yes], [RUBY_APPEND_OPTION(CFLAGS, -pipe)])
AC_MSG_CHECKING([whether Security framework is needed])
AC_COMPILE_IFELSE([
AC_LANG_BOOL_COMPILE_TRY([
@@ -3971,6 +4258,7 @@ enum {
[mingw*], [
AS_IF([test x"$enable_shared" = xyes], [
LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
+ LIBRUBY_SONAME=''
LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)'
])
EXPORT_PREFIX=' '
@@ -3983,7 +4271,6 @@ enum {
PLATFORM_DIR=win32
])
LIBRUBY_ALIASES=''
- FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
AS_IF([test x"$enable_shared" = xyes], [
LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
], [
@@ -3993,7 +4280,6 @@ enum {
])
],
[wasi*], [
- FIRSTMAKEFILE=GNUmakefile:wasm/GNUmakefile.in
AC_LIBOBJ([wasm/missing])
AC_LIBOBJ([wasm/runtime])
AC_LIBOBJ([wasm/fiber])
@@ -4010,21 +4296,6 @@ AC_ARG_ENABLE(debug-env,
AS_HELP_STRING([--enable-debug-env], [enable RUBY_DEBUG environment variable]),
[AC_SUBST(ENABLE_DEBUG_ENV, yes)])
-AS_CASE(["$FIRSTMAKEFILE"], [*GNUmakefile:*], [gnumake=yes], [
- AC_MSG_CHECKING([if ${MAKE-make} is GNU make])
- mkdir conftest.dir
- echo "all:; @echo yes" > conftest.dir/GNUmakefile
- echo "all:; @echo no" > conftest.dir/Makefile
- gnumake=`(cd conftest.dir; ${MAKE-make})`
- rm -fr conftest.dir
- AS_CASE(["$gnumake"],
- [*yes*], [
- FIRSTMAKEFILE=GNUmakefile:template/GNUmakefile.in
- gnumake=yes],
- [
- gnumake=no])
- AC_MSG_RESULT($gnumake)
-])
AS_IF([test "$gnumake" = yes], [ NULLCMD=: ], [
AC_MSG_CHECKING([for safe null command for ${MAKE-make}])
mkdir conftest.dir
@@ -4081,8 +4352,9 @@ AS_IF([test "${universal_binary-no}" = yes ], [
const char arch[[]] = __ARCHITECTURE__;]], [[puts(arch);]])],
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
])
+}
-: ${RJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(RJIT_CC)|g']`}
+[end]_group
MAINLIBS="$LIBS"
LIBS=$ORIG_LIBS
@@ -4091,8 +4363,7 @@ AS_IF([test -n "${LIBS}"], [
MAINFLAGS=`echo " $MAINLIBS " | sed "s|$libspat"'||;s/^ *//;s/ *$//'`
])
LIBRUBYARG_STATIC="${LIBRUBYARG_STATIC} \$(MAINLIBS)"
-CPPFLAGS="$CPPFLAGS "'$(DEFS)'
-test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
+CPPFLAGS="$CPPFLAGS "'$(DEFS) ${cppflags}'
AS_IF([test -n "${cflags+set}"], [
cflagspat=`eval echo '"'"${cflags}"'"' | sed 's/[[][|.*]]/\\&/g;s/^ */ /;s/^ *$/ /'`
CFLAGS=`echo " $CFLAGS " | sed "s|$cflagspat"'|${cflags}|;s/^ *//;s/ *$//'`
@@ -4107,15 +4378,34 @@ AS_IF([test "${ARCH_FLAG}"], [
CXXFLAGS=`echo "$CXXFLAGS" | sed "s| *$archflagpat"'||'`
LDFLAGS=`echo "$LDFLAGS" | sed "s| *$archflagpat"'||'`
])
+AS_CASE([" $rb_cv_warnflags "], [*" -Wshorten-64-to-32 "*|*" -Werror=shorten-64-to-32 "*], [
+ voidp_ll=
+ AS_CASE([$ac_cv_sizeof_voidp],
+ [SIZEOF_LONG_LONG], [voidp_ll=true],
+ [@<:@0-9@:>@*], [
+ AS_IF([test $ac_cv_sizeof_voidp -gt $ac_cv_sizeof_long], [voidp_ll=true])
+ ])
+ AS_IF([test "$voidp_ll"], [
+ # Disable the shorten-64-to-32 warning for now, because it currently
+ # generates a lot of warnings on platforms where `sizeof(void*)` is
+ # larger than `sizeof(long)`.
+ #
+ # TODO: Replace `long` with `ptrdiff_t` or something in the all sources.
+ rb_cv_warnflags=`echo "$rb_cv_warnflags" |
+ sed -e 's/ -W\(shorten-64-to-32 \)/ -Wno-\1/' \
+ -e 's/ -Werror=\(shorten-64-to-32 \)/ -Wno-\1/'`
+ ])
+])
rb_cv_warnflags=`echo "$rb_cv_warnflags" | sed 's/^ *//;s/ *$//'`
warnflags="$rb_cv_warnflags"
AC_SUBST(cppflags)dnl
-AC_SUBST(cflags, ["${orig_cflags:+$orig_cflags }"'${optflags} ${debugflags} ${warnflags}'])dnl
+AC_SUBST(cflags, ['${hardenflags} '"${orig_cflags:+$orig_cflags }"' ${optflags} ${debugflags} ${warnflags}'])dnl
AC_SUBST(cxxflags)dnl
AC_SUBST(optflags)dnl
AC_SUBST(debugflags)dnl
AC_SUBST(warnflags)dnl
AC_SUBST(strict_warnflags)dnl
+AC_SUBST(hardenflags)dnl
AC_SUBST(XCFLAGS)dnl
AC_SUBST(XLDFLAGS)dnl
AC_SUBST(EXTLDFLAGS)dnl
@@ -4299,6 +4589,10 @@ AS_IF([test "${universal_binary-no}" = yes ], [
arch="${target_cpu}-${target_os}"
])
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch")
+
+ AS_IF([test "$arch" = "s390x-linux"], [
+ AC_DEFINE_UNQUOTED(USE_MN_THREADS, 0)
+ ])
])
unset sitearch
@@ -4396,6 +4690,20 @@ AS_IF([test x"$enable_rubygems" = xno], [
])
AC_SUBST(USE_RUBYGEMS)
+m4_define(available_parsers, [parse.y, prism])
+AC_ARG_WITH(parser,
+ AS_HELP_STRING([--with-parser=PARSER],
+ [specify default parser; PARSER is one of ]m4_join([, ],available_parsers)),
+ [], [with_parser=prism])
+AS_CASE([$with_parser],
+m4_foreach(parser, [available_parsers],
+ parser[,][AC_DEFINE_UNQUOTED(RB_DEFAULT_PARSER, RB_DEFAULT_PARSER_[]AS_TR_CPP(parser)),])
+ [AC_MSG_ERROR([Unknown parser: $with_parser])]
+)
+
+# Use the ruby allocator for prism. See prism/defines.h
+RUBY_APPEND_OPTIONS(XCFLAGS, -DPRISM_XALLOCATOR)
+
arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
AS_MKDIR_P("${arch_hdrdir}")
config_h="${arch_hdrdir}/config.h"
@@ -4403,7 +4711,7 @@ guard=INCLUDE_RUBY_CONFIG_H
{
echo "#ifndef $guard"
echo "#define $guard 1"
- grep -v "^#define PACKAGE_" confdefs.h
+ sed "/^@%:@define PACKAGE_/d;s/ *$//" confdefs.h
echo "#endif /* $guard */"
} | tr -d '\015' |
(
@@ -4482,8 +4790,12 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [
sed '/^MISSING/s/\$U\././g;/^VCS *=/s#@VCS@#'"$VCS"'#;/^VCSUP *=/s#@VCSUP@#'"$VCSUP"'#' Makefile
echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
AS_IF([test "$gnumake" != yes], [
- echo ['$(MKFILES): $(srcdir)/common.mk']
- sed ['s/{\$([^(){}]*)[^{}]*}//g'] ${srcdir}/common.mk
+ # extract NMake-style include list
+ set = `sed -n 's/^!include *//p' ${srcdir}/common.mk`
+ echo common_mk_includes "@S|@*" # generate the macro assignment
+ shift
+ common_mk_includes="`echo \"@S|@*\" | sed 's|\$(srcdir)|.|g'`"
+ (PWD= cd ${srcdir} && sed -f tool/prereq.status common.mk ${common_mk_includes})
AS_IF([test "$YJIT_SUPPORT" = yes], [
cat ${srcdir}/yjit/not_gmake.mk
echo ['$(MKFILES): ${srcdir}/yjit/not_gmake.mk']
@@ -4491,20 +4803,10 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [
], [
echo 'distclean-local::; @$(RM) GNUmakefile uncommon.mk'
])
- } > $tmpmk && AS_IF([! grep '^ruby:' $tmpmk > /dev/null], [
- AS_IF([test "${gnumake}" = yes], [
- tmpgmk=confgmk$$.tmp
- {
- echo "include $tmpmk"
- echo "-include uncommon.mk"
- } > $tmpgmk
- ], [
- tmpgmk=$tmpmk
- ]) &&
- test -z "`${MAKE-make} -f $tmpgmk info-program | grep '^PROGRAM=ruby$'`" &&
- echo 'ruby: $(PROGRAM);' >> $tmpmk
- test "$tmpmk" = "$tmpgmk" || rm -f "$tmpgmk"
- ]) && mv -f $tmpmk Makefile],
+
+ echo; echo '$(srcdir)/$(CONFIGURE):RUBY_M4_INCLUDED \
+ $(empty)'
+ } > $tmpmk && mv -f $tmpmk Makefile],
[EXEEXT='$EXEEXT' MAKE='${MAKE-make}' gnumake='$gnumake' GIT='$GIT' YJIT_SUPPORT='$YJIT_SUPPORT'])
AC_ARG_WITH([ruby-pc],
@@ -4519,9 +4821,13 @@ AC_ARG_WITH(destdir,
[DESTDIR="$withval"])
AC_SUBST(DESTDIR)
+AS_IF([test "x$load_relative:$DESTDIR" = xyes:], [
+ AS_IF([test "x$prefix" = xNONE], [DESTDIR="$ac_default_prefix"], [DESTDIR="$prefix"])
+ prefix=/.
+])
+
AC_OUTPUT
}
-}
AS_IF([test "$silent" = yes], [], [
AS_IF([${FOLD+:} false], [], [
@@ -4558,6 +4864,7 @@ config_summary "target OS" "$target_os"
config_summary "compiler" "$CC"
config_summary "with thread" "$THREAD_MODEL"
config_summary "with coroutine" "$coroutine_type"
+config_summary "with modular GC" "$modular_gc_summary"
config_summary "enable shared libs" "$ENABLE_SHARED"
config_summary "dynamic library ext" "$DLEXT"
config_summary "CFLAGS" "$cflags"
@@ -4567,10 +4874,12 @@ config_summary "DLDFLAGS" "$DLDFLAGS"
config_summary "optflags" "$optflags"
config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
+config_summary "hardenflags" "$hardenflags"
config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS"
config_summary "YJIT support" "$YJIT_SUPPORT"
-config_summary "RJIT support" "$RJIT_SUPPORT"
+config_summary "ZJIT support" "$ZJIT_SUPPORT"
+config_summary "RUSTC_FLAGS" "$RUSTC_FLAGS"
config_summary "man page type" "$MANTYPE"
config_summary "search path" "$search_path"
config_summary "static-linked-ext" ${EXTSTATIC:+"yes"}
diff --git a/cont.c b/cont.c
index 4173e5a6b9..6bb61e5ee8 100644
--- a/cont.c
+++ b/cont.c
@@ -28,26 +28,33 @@ extern int madvise(caddr_t, size_t, int);
#include "eval_intern.h"
#include "internal.h"
#include "internal/cont.h"
+#include "internal/thread.h"
#include "internal/error.h"
+#include "internal/eval.h"
#include "internal/gc.h"
#include "internal/proc.h"
#include "internal/sanitizers.h"
#include "internal/warnings.h"
#include "ruby/fiber/scheduler.h"
-#include "rjit.h"
#include "yjit.h"
#include "vm_core.h"
#include "vm_sync.h"
#include "id_table.h"
#include "ractor_core.h"
+#include "zjit.h"
-static const int DEBUG = 0;
+enum {
+ DEBUG = 0,
+ DEBUG_EXPAND = 0,
+ DEBUG_ACQUIRE = 0,
+};
#define RB_PAGE_SIZE (pagesize)
#define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1))
static long pagesize;
-static const rb_data_type_t cont_data_type, fiber_data_type;
+static const rb_data_type_t rb_cont_data_type;
+static const rb_data_type_t rb_fiber_data_type;
static VALUE rb_cContinuation;
static VALUE rb_cFiber;
static VALUE rb_eFiberError;
@@ -60,18 +67,16 @@ static VALUE rb_cFiberPool;
// Defined in `coroutine/$arch/Context.h`:
#ifdef COROUTINE_LIMITED_ADDRESS_SPACE
#define FIBER_POOL_ALLOCATION_FREE
-#define FIBER_POOL_INITIAL_SIZE 8
-#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 32
+#define FIBER_POOL_MINIMUM_COUNT 8
+#define FIBER_POOL_MAXIMUM_ALLOCATIONS 32
#else
-#define FIBER_POOL_INITIAL_SIZE 32
-#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 1024
+#define FIBER_POOL_MINIMUM_COUNT 32
+#define FIBER_POOL_MAXIMUM_ALLOCATIONS 1024
#endif
#ifdef RB_EXPERIMENTAL_FIBER_POOL
#define FIBER_POOL_ALLOCATION_FREE
#endif
-#define jit_cont_enabled (rb_rjit_enabled || rb_yjit_enabled_p())
-
enum context_type {
CONTINUATION_CONTEXT = 0,
FIBER_CONTEXT = 1
@@ -79,6 +84,7 @@ enum context_type {
struct cont_saved_vm_stack {
VALUE *ptr;
+ size_t size;
#ifdef CAPTURE_JUST_VALID_VM_STACK
size_t slen; /* length of stack (head of ec->vm_stack) */
size_t clen; /* length of control frames (tail of ec->vm_stack) */
@@ -178,7 +184,7 @@ struct fiber_pool {
// A singly-linked list of allocations which contain 1 or more stacks each.
struct fiber_pool_allocation * allocations;
- // Provides O(1) stack "allocation":
+ // Free list that provides O(1) stack "allocation".
struct fiber_pool_vacancy * vacancies;
// The size of the stack allocations (excluding any guard page).
@@ -188,15 +194,21 @@ struct fiber_pool {
size_t count;
// The initial number of stacks to allocate.
- size_t initial_count;
+ size_t minimum_count;
- // Whether to madvise(free) the stack or not:
+ // If positive, total stacks in this pool cannot exceed this (shared pool only:
+ // set via RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT). Expansion fails with errno EAGAIN.
+ size_t maximum_count;
+
+ // Whether to madvise(free) the stack or not.
+ // If this value is set to 1, the stack will be madvise(free)ed
+ // (or equivalent), where possible, when it is returned to the pool.
int free_stacks;
// The number of stacks that have been used in this pool.
size_t used;
- // The amount to allocate for the vm_stack:
+ // The amount to allocate for the vm_stack.
size_t vm_stack_size;
};
@@ -225,22 +237,21 @@ typedef struct rb_context_struct {
} machine;
rb_execution_context_t saved_ec;
rb_jmpbuf_t jmpbuf;
- rb_ensure_entry_t *ensure_array;
struct rb_jit_cont *jit_cont; // Continuation contexts for JITs
} rb_context_t;
-
/*
* Fiber status:
- * [Fiber.new] ------> FIBER_CREATED
- * | [Fiber#resume]
- * v
- * +--> FIBER_RESUMED ----+
- * [Fiber#resume] | | [Fiber.yield] |
- * | v |
- * +-- FIBER_SUSPENDED | [Terminate]
- * |
- * FIBER_TERMINATED <-+
+ * [Fiber.new] ------> FIBER_CREATED ----> [Fiber#kill] --> |
+ * | [Fiber#resume] |
+ * v |
+ * +--> FIBER_RESUMED ----> [return] ------> |
+ * [Fiber#resume] | | [Fiber.yield/transfer] |
+ * [Fiber#transfer] | v |
+ * +--- FIBER_SUSPENDED --> [Fiber#kill] --> |
+ * |
+ * |
+ * FIBER_TERMINATED <-------------------+
*/
enum fiber_status {
FIBER_CREATED,
@@ -266,12 +277,25 @@ struct rb_fiber_struct {
unsigned int yielding : 1;
unsigned int blocking : 1;
+ unsigned int killed : 1;
+
struct coroutine_context context;
struct fiber_pool_stack stack;
};
static struct fiber_pool shared_fiber_pool = {NULL, NULL, 0, 0, 0, 0};
+void
+rb_free_shared_fiber_pool(void)
+{
+ struct fiber_pool_allocation *allocations = shared_fiber_pool.allocations;
+ while (allocations) {
+ struct fiber_pool_allocation *next = allocations->next;
+ SIZED_FREE(allocations);
+ allocations = next;
+ }
+}
+
static ID fiber_initialize_keywords[3] = {0};
/*
@@ -455,11 +479,12 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
// the system would allow (e.g. overcommit * physical memory + swap), we
// divide count by two and try again. This condition should only be
// encountered in edge cases, but we handle it here gracefully.
- while (*count > 1) {
+ while (*count) {
#if defined(_WIN32)
void * base = VirtualAlloc(0, (*count)*stride, MEM_COMMIT, PAGE_READWRITE);
if (!base) {
+ errno = rb_w32_map_errno(GetLastError());
*count = (*count) >> 1;
}
else {
@@ -467,18 +492,20 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
}
#else
errno = 0;
- void * base = mmap(NULL, (*count)*stride, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0);
+ size_t mmap_size = (*count)*stride;
+ void * base = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, FIBER_STACK_FLAGS, -1, 0);
if (base == MAP_FAILED) {
// If the allocation fails, count = count / 2, and try again.
*count = (*count) >> 1;
}
else {
+ ruby_annotate_mmap(base, mmap_size, "Ruby:fiber_pool_allocate_memory");
#if defined(MADV_FREE_REUSE)
// On Mac MADV_FREE_REUSE is necessary for the task_info api
// to keep the accounting accurate as possible when a page is marked as reusable
// it can possibly not occurring at first call thus re-iterating if necessary.
- while (madvise(base, (*count)*stride, MADV_FREE_REUSE) == -1 && errno == EAGAIN);
+ while (madvise(base, mmap_size, MADV_FREE_REUSE) == -1 && errno == EAGAIN);
#endif
return base;
}
@@ -489,26 +516,53 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
}
// Given an existing fiber pool, expand it by the specified number of stacks.
+//
// @param count the maximum number of stacks to allocate.
-// @return the allocated fiber pool.
+// @return the new allocation on success, or NULL on failure with errno set.
+// @raise NoMemoryError if the struct or memory allocation fails.
+//
+// Call from fiber_pool_stack_acquire_expand with VM lock held, or from
+// fiber_pool_initialize before the pool is shared across threads.
// @sa fiber_pool_allocation_free
static struct fiber_pool_allocation *
fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
{
+ if (count == 0) {
+ errno = EAGAIN;
+ return NULL;
+ }
+
STACK_GROW_DIR_DETECTION;
size_t size = fiber_pool->size;
size_t stride = size + RB_PAGE_SIZE;
+ // If the maximum number of stacks is set, and we have reached it, return NULL.
+ if (fiber_pool->maximum_count > 0) {
+ if (fiber_pool->count >= fiber_pool->maximum_count) {
+ errno = EAGAIN;
+ return NULL;
+ }
+ size_t remaining = fiber_pool->maximum_count - fiber_pool->count;
+ if (count > remaining) {
+ count = remaining;
+ }
+ }
+
+ // Allocate metadata before mmap: ruby_xmalloc (RB_ALLOC) raises on failure and
+ // must not run after base is mapped, or the region would leak.
+ struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation);
+
// Allocate the memory required for the stacks:
void * base = fiber_pool_allocate_memory(&count, stride);
if (base == NULL) {
- rb_raise(rb_eFiberError, "can't alloc machine stack to fiber (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", count, size, ERRNOMSG);
+ if (!errno) errno = ENOMEM;
+ ruby_xfree(allocation);
+ return NULL;
}
struct fiber_pool_vacancy * vacancies = fiber_pool->vacancies;
- struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation);
// Initialize fiber pool allocation:
allocation->base = base;
@@ -520,7 +574,7 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
#endif
allocation->pool = fiber_pool;
- if (DEBUG) {
+ if (DEBUG_EXPAND) {
fprintf(stderr, "fiber_pool_expand(%"PRIuSIZE"): %p, %"PRIuSIZE"/%"PRIuSIZE" x [%"PRIuSIZE":%"PRIuSIZE"]\n",
count, (void*)fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size);
}
@@ -529,18 +583,27 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
for (size_t i = 0; i < count; i += 1) {
void * base = (char*)allocation->base + (stride * i);
void * page = (char*)base + STACK_DIR_UPPER(size, 0);
-
#if defined(_WIN32)
DWORD old_protect;
if (!VirtualProtect(page, RB_PAGE_SIZE, PAGE_READWRITE | PAGE_GUARD, &old_protect)) {
+ int error = rb_w32_map_errno(GetLastError());
VirtualFree(allocation->base, 0, MEM_RELEASE);
- rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG);
+ ruby_xfree(allocation);
+ errno = error;
+ return NULL;
}
+#elif defined(__wasi__)
+ // wasi-libc's mprotect emulation doesn't support PROT_NONE.
+ (void)page;
#else
if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) {
+ int error = errno;
+ if (!error) error = ENOMEM;
munmap(allocation->base, count*stride);
- rb_raise(rb_eFiberError, "can't set a guard page: %s", ERRNOMSG);
+ ruby_xfree(allocation);
+ errno = error;
+ return NULL;
}
#endif
@@ -576,7 +639,7 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count)
// Initialize the specified fiber pool with the given number of stacks.
// @param vm_stack_size The size of the vm stack to allocate.
static void
-fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, size_t vm_stack_size)
+fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t minimum_count, size_t maximum_count, size_t vm_stack_size)
{
VM_ASSERT(vm_stack_size < size);
@@ -584,13 +647,17 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count,
fiber_pool->vacancies = NULL;
fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE;
fiber_pool->count = 0;
- fiber_pool->initial_count = count;
+ fiber_pool->minimum_count = minimum_count;
+ fiber_pool->maximum_count = maximum_count;
fiber_pool->free_stacks = 1;
fiber_pool->used = 0;
-
fiber_pool->vm_stack_size = vm_stack_size;
- fiber_pool_expand(fiber_pool, count);
+ if (fiber_pool->minimum_count > 0) {
+ if (RB_UNLIKELY(!fiber_pool_expand(fiber_pool, fiber_pool->minimum_count))) {
+ rb_raise(rb_eFiberError, "can't allocate initial fiber stacks (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", fiber_pool->minimum_count, fiber_pool->size, strerror(errno));
+ }
+ }
}
#ifdef FIBER_POOL_ALLOCATION_FREE
@@ -634,49 +701,120 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation)
allocation->pool->count -= allocation->count;
- ruby_xfree(allocation);
+ SIZED_FREE(allocation);
}
#endif
-// Acquire a stack from the given fiber pool. If none are available, allocate more.
-static struct fiber_pool_stack
-fiber_pool_stack_acquire(struct fiber_pool * fiber_pool)
+// Number of stacks to request when expanding the pool (clamped to min/max).
+static size_t
+fiber_pool_stack_expand_count(const struct fiber_pool *pool)
{
- struct fiber_pool_vacancy * vacancy = fiber_pool_vacancy_pop(fiber_pool);
+ const size_t maximum_allocations = FIBER_POOL_MAXIMUM_ALLOCATIONS;
+ const size_t minimum_count = FIBER_POOL_MINIMUM_COUNT;
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", (void*)fiber_pool->vacancies, fiber_pool->used);
+ // We are going try and double the number of stacks in the pool:
+ size_t count = pool->count;
+ if (count > maximum_allocations) count = maximum_allocations;
+ if (count < minimum_count) count = minimum_count;
- if (!vacancy) {
- const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE;
- const size_t minimum = fiber_pool->initial_count;
+ // If we have a maximum count, we need to clamp the number of stacks to the maximum:
+ if (pool->maximum_count > 0) {
+ if (pool->count >= pool->maximum_count) {
+ // No expansion is possible:
+ return 0;
+ }
- size_t count = fiber_pool->count;
- if (count > maximum) count = maximum;
- if (count < minimum) count = minimum;
+ // Otherwise, compute the number of stacks we can allocate to bring us to the maximum:
+ size_t remaining = pool->maximum_count - pool->count;
+ if (count > remaining) {
+ count = remaining;
+ }
+ }
- fiber_pool_expand(fiber_pool, count);
+ return count;
+}
- // The free list should now contain some stacks:
- VM_ASSERT(fiber_pool->vacancies);
+// When the vacancy list is empty, grow the pool (and run GC only if mmap fails). Caller holds the VM lock.
+// Returns NULL if expansion failed after GC + retry; errno is set. Otherwise returns a vacancy.
+static struct fiber_pool_vacancy *
+fiber_pool_stack_acquire_expand(struct fiber_pool *fiber_pool)
+{
+ size_t count = fiber_pool_stack_expand_count(fiber_pool);
+ if (DEBUG_ACQUIRE) fprintf(stderr, "fiber_pool_stack_acquire: expanding fiber pool by %"PRIuSIZE" stacks\n", count);
+
+ struct fiber_pool_vacancy *vacancy = NULL;
+
+ if (RB_LIKELY(fiber_pool_expand(fiber_pool, count))) {
+ return fiber_pool_vacancy_pop(fiber_pool);
+ }
+ else {
+ if (DEBUG_ACQUIRE) fprintf(stderr, "fiber_pool_stack_acquire: expand failed (%s), collecting garbage\n", strerror(errno));
+
+ rb_gc();
+
+ // After running GC, the vacancy list may have some stacks:
vacancy = fiber_pool_vacancy_pop(fiber_pool);
+ if (RB_LIKELY(vacancy)) {
+ return vacancy;
+ }
+
+ // Recompute count as gc may have freed up some allocations:
+ count = fiber_pool_stack_expand_count(fiber_pool);
+
+ // Try to expand the fiber pool again:
+ if (RB_LIKELY(fiber_pool_expand(fiber_pool, count))) {
+ return fiber_pool_vacancy_pop(fiber_pool);
+ }
+ else {
+ // Okay, we really failed to acquire a stack. Give up and return NULL with errno set:
+ return NULL;
+ }
}
+}
+
+// Acquire a stack from the given fiber pool. If none are available, allocate more.
+static struct fiber_pool_stack
+fiber_pool_stack_acquire(struct fiber_pool * fiber_pool)
+{
+ struct fiber_pool_vacancy * vacancy;
+
+ unsigned int lev;
+ RB_VM_LOCK_ENTER_LEV(&lev);
+ {
+ // Fast path: try to acquire a stack from the vacancy list:
+ vacancy = fiber_pool_vacancy_pop(fiber_pool);
+
+ if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", (void*)fiber_pool->vacancies, fiber_pool->used);
+
+ // Slow path: If the pool has no vacancies, expand first. Only run GC when expansion fails (e.g. mmap), so we can reclaim stacks from dead fibers before retrying:
+ if (RB_UNLIKELY(!vacancy)) {
+ vacancy = fiber_pool_stack_acquire_expand(fiber_pool);
+
+ // If expansion failed, raise an error:
+ if (RB_UNLIKELY(!vacancy)) {
+ RB_VM_LOCK_LEAVE_LEV(&lev);
+ rb_raise(rb_eFiberError, "can't allocate fiber stack: %s", strerror(errno));
+ }
+ }
- VM_ASSERT(vacancy);
- VM_ASSERT(vacancy->stack.base);
+ VM_ASSERT(vacancy);
+ VM_ASSERT(vacancy->stack.base);
#if defined(COROUTINE_SANITIZE_ADDRESS)
- __asan_unpoison_memory_region(fiber_pool_stack_poison_base(&vacancy->stack), fiber_pool_stack_poison_size(&vacancy->stack));
+ __asan_unpoison_memory_region(fiber_pool_stack_poison_base(&vacancy->stack), fiber_pool_stack_poison_size(&vacancy->stack));
#endif
- // Take the top item from the free list:
- fiber_pool->used += 1;
+ // Take the top item from the free list:
+ fiber_pool->used += 1;
#ifdef FIBER_POOL_ALLOCATION_FREE
- vacancy->stack.allocation->used += 1;
+ vacancy->stack.allocation->used += 1;
#endif
- fiber_pool_stack_reset(&vacancy->stack);
+ fiber_pool_stack_reset(&vacancy->stack);
+ }
+ RB_VM_LOCK_LEAVE_LEV(&lev);
return vacancy->stack;
}
@@ -692,7 +830,9 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack)
// If this is not true, the vacancy information will almost certainly be destroyed:
VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE));
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"]\n", base, size, stack->base, stack->size);
+ int advice = stack->pool->free_stacks >> 1;
+
+ if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"] advice=%d\n", base, size, stack->base, stack->size, advice);
// The pages being used by the stack can be returned back to the system.
// That doesn't change the page mapping, but it does allow the system to
@@ -706,24 +846,29 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack)
#ifdef __wasi__
// WebAssembly doesn't support madvise, so we just don't do anything.
#elif VM_CHECK_MODE > 0 && defined(MADV_DONTNEED)
+ if (!advice) advice = MADV_DONTNEED;
// This immediately discards the pages and the memory is reset to zero.
- madvise(base, size, MADV_DONTNEED);
+ madvise(base, size, advice);
#elif defined(MADV_FREE_REUSABLE)
+ if (!advice) advice = MADV_FREE_REUSABLE;
// Darwin / macOS / iOS.
// Acknowledge the kernel down to the task info api we make this
// page reusable for future use.
- // As for MADV_FREE_REUSE below we ensure in the rare occasions the task was not
+ // As for MADV_FREE_REUSABLE below we ensure in the rare occasions the task was not
// completed at the time of the call to re-iterate.
- while (madvise(base, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN);
+ while (madvise(base, size, advice) == -1 && errno == EAGAIN);
#elif defined(MADV_FREE)
+ if (!advice) advice = MADV_FREE;
// Recent Linux.
- madvise(base, size, MADV_FREE);
+ madvise(base, size, advice);
#elif defined(MADV_DONTNEED)
+ if (!advice) advice = MADV_DONTNEED;
// Old Linux.
- madvise(base, size, MADV_DONTNEED);
+ madvise(base, size, advice);
#elif defined(POSIX_MADV_DONTNEED)
+ if (!advice) advice = POSIX_MADV_DONTNEED;
// Solaris?
- posix_madvise(base, size, POSIX_MADV_DONTNEED);
+ posix_madvise(base, size, advice);
#elif defined(_WIN32)
VirtualAlloc(base, size, MEM_RESET, PAGE_READWRITE);
// Not available in all versions of Windows.
@@ -780,6 +925,9 @@ static inline void
ec_switch(rb_thread_t *th, rb_fiber_t *fiber)
{
rb_execution_context_t *ec = &fiber->cont.saved_ec;
+#ifdef RUBY_ASAN_ENABLED
+ ec->machine.asan_fake_stack_handle = asan_get_thread_fake_stack_handle();
+#endif
rb_ractor_set_current_ec(th->ractor, th->ec = ec);
// ruby_current_execution_context_ptr = th->ec = ec;
@@ -802,6 +950,10 @@ fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fiber)
VM_ASSERT(th->ec->fiber_ptr == fiber);
}
+#ifndef COROUTINE_DECL
+# define COROUTINE_DECL COROUTINE
+#endif
+NORETURN(static COROUTINE_DECL fiber_entry(struct coroutine_context * from, struct coroutine_context * to));
static COROUTINE
fiber_entry(struct coroutine_context * from, struct coroutine_context * to)
{
@@ -879,6 +1031,17 @@ fiber_stack_release(rb_fiber_t * fiber)
rb_ec_clear_vm_stack(ec);
}
+static void
+fiber_stack_release_locked(rb_fiber_t *fiber)
+{
+ if (!ruby_vm_during_cleanup) {
+ // We can't try to acquire the VM lock here because MMTK calls free in its own native thread which has no ec.
+ // This assertion will fail on MMTK but we currently don't have CI for debug releases of MMTK, so we can assert for now.
+ ASSERT_vm_locking_with_barrier();
+ }
+ fiber_stack_release(fiber);
+}
+
static const char *
fiber_status_name(enum fiber_status s)
{
@@ -900,7 +1063,9 @@ fiber_verify(const rb_fiber_t *fiber)
switch (fiber->status) {
case FIBER_RESUMED:
- VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL);
+ if (fiber->cont.saved_ec.thread_ptr->self == 0) {
+ VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL);
+ }
break;
case FIBER_SUSPENDED:
VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL);
@@ -930,7 +1095,7 @@ cont_ptr(VALUE obj)
{
rb_context_t *cont;
- TypedData_Get_Struct(obj, rb_context_t, &cont_data_type, cont);
+ TypedData_Get_Struct(obj, rb_context_t, &rb_cont_data_type, cont);
return cont;
}
@@ -940,7 +1105,7 @@ fiber_ptr(VALUE obj)
{
rb_fiber_t *fiber;
- TypedData_Get_Struct(obj, rb_fiber_t, &fiber_data_type, fiber);
+ TypedData_Get_Struct(obj, rb_fiber_t, &rb_fiber_data_type, fiber);
if (!fiber) rb_raise(rb_eFiberError, "uninitialized fiber");
return fiber;
@@ -1007,13 +1172,8 @@ cont_mark(void *ptr)
cont->machine.stack + cont->machine.stack_size);
}
else {
- /* fiber */
- const rb_fiber_t *fiber = (rb_fiber_t*)cont;
-
- if (!FIBER_TERMINATED_P(fiber)) {
- rb_gc_mark_locations(cont->machine.stack,
- cont->machine.stack + cont->machine.stack_size);
- }
+ /* fiber machine context is marked as part of rb_execution_context_mark, no need to
+ * do anything here. */
}
}
@@ -1038,24 +1198,26 @@ cont_free(void *ptr)
RUBY_FREE_ENTER("cont");
if (cont->type == CONTINUATION_CONTEXT) {
- ruby_xfree(cont->saved_ec.vm_stack);
- ruby_xfree(cont->ensure_array);
- RUBY_FREE_UNLESS_NULL(cont->machine.stack);
+ SIZED_FREE_N(cont->saved_ec.vm_stack, cont->saved_ec.vm_stack_size);
+ SIZED_FREE_N(cont->machine.stack, cont->machine.stack_size);
}
else {
rb_fiber_t *fiber = (rb_fiber_t*)cont;
coroutine_destroy(&fiber->context);
- fiber_stack_release(fiber);
+ fiber_stack_release_locked(fiber);
}
- RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
+ SIZED_FREE_N(cont->saved_vm_stack.ptr, cont->saved_vm_stack.size);
- if (jit_cont_enabled) {
- VM_ASSERT(cont->jit_cont != NULL);
- jit_cont_free(cont->jit_cont);
- }
+ VM_ASSERT(cont->jit_cont != NULL);
+ jit_cont_free(cont->jit_cont);
/* free rb_cont_t or rb_fiber_t */
- ruby_xfree(ptr);
+ if (cont->type == CONTINUATION_CONTEXT) {
+ SIZED_FREE(cont);
+ }
+ else {
+ SIZED_FREE((rb_fiber_t *)cont);
+ }
RUBY_FREE_LEAVE("cont");
}
@@ -1096,12 +1258,7 @@ rb_fiber_update_self(rb_fiber_t *fiber)
void
rb_fiber_mark_self(const rb_fiber_t *fiber)
{
- if (fiber->cont.self) {
- rb_gc_mark_movable(fiber->cont.self);
- }
- else {
- rb_execution_context_mark(&fiber->cont.saved_ec);
- }
+ rb_gc_mark_movable(fiber->cont.self);
}
static void
@@ -1167,12 +1324,13 @@ fiber_memsize(const void *ptr)
VALUE
rb_obj_is_fiber(VALUE obj)
{
- return RBOOL(rb_typeddata_is_kind_of(obj, &fiber_data_type));
+ return RBOOL(rb_typeddata_is_kind_of(obj, &rb_fiber_data_type));
}
static void
cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
{
+ const size_t old_stack_size = cont->machine.stack_size;
size_t size;
SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
@@ -1187,10 +1345,10 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
}
if (cont->machine.stack) {
- REALLOC_N(cont->machine.stack, VALUE, size);
+ SIZED_REALLOC_N(cont->machine.stack, VALUE, cont->machine.stack_size, old_stack_size);
}
else {
- cont->machine.stack = ALLOC_N(VALUE, size);
+ cont->machine.stack = ALLOC_N(VALUE, cont->machine.stack_size);
}
FLUSH_REGISTER_WINDOWS;
@@ -1198,9 +1356,23 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
MEMCPY(cont->machine.stack, cont->machine.stack_src, VALUE, size);
}
-static const rb_data_type_t cont_data_type = {
+static void
+cont_handle_weak_references(void *ptr)
+{
+ rb_context_t *cont = ptr;
+
+ if (!cont) return;
+
+ if (!rb_gc_handle_weak_references_alive_p(cont->saved_ec.gen_fields_cache.obj) ||
+ !rb_gc_handle_weak_references_alive_p(cont->saved_ec.gen_fields_cache.fields_obj)) {
+ cont->saved_ec.gen_fields_cache.obj = Qundef;
+ cont->saved_ec.gen_fields_cache.fields_obj = Qundef;
+ }
+}
+
+static const rb_data_type_t rb_cont_data_type = {
"continuation",
- {cont_mark, cont_free, cont_memsize, cont_compact},
+ {cont_mark, cont_free, cont_memsize, cont_compact, cont_handle_weak_references},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
@@ -1231,7 +1403,7 @@ jit_cont_new(rb_execution_context_t *ec)
// We need to use calloc instead of something like ZALLOC to avoid triggering GC here.
// When this function is called from rb_thread_alloc through rb_threadptr_root_fiber_setup,
// the thread is still being prepared and marking it causes SEGV.
- cont = calloc(1, sizeof(struct rb_jit_cont));
+ cont = ruby_mimcalloc(1, sizeof(struct rb_jit_cont));
if (cont == NULL)
rb_memerror();
cont->ec = ec;
@@ -1270,7 +1442,7 @@ jit_cont_free(struct rb_jit_cont *cont)
}
rb_native_mutex_unlock(&jit_cont_lock);
- free(cont);
+ ruby_mimfree(cont);
}
// Call a given callback against all on-stack ISEQs.
@@ -1282,30 +1454,49 @@ rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data)
if (cont->ec->vm_stack == NULL)
continue;
- const rb_control_frame_t *cfp;
- for (cfp = RUBY_VM_END_CONTROL_FRAME(cont->ec) - 1; ; cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
- const rb_iseq_t *iseq;
- if (cfp->pc && (iseq = cfp->iseq) != NULL && imemo_type((VALUE)iseq) == imemo_iseq) {
- callback(iseq, data);
+ const rb_control_frame_t *cfp = cont->ec->cfp;
+ while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(cont->ec, cfp)) {
+ if (CFP_PC(cfp) && CFP_ISEQ(cfp)) {
+ const rb_iseq_t *iseq = CFP_ISEQ(cfp);
+ if (iseq && imemo_type((VALUE)iseq) == imemo_iseq) {
+ callback(iseq, data);
+ }
}
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ }
+ }
+}
+
+#if USE_YJIT
+// Update the jit_return of all CFPs to leave_exit unless it's leave_exception or not set.
+// This prevents jit_exec_exception from jumping to the caller after invalidation.
+void
+rb_yjit_cancel_jit_return(void *leave_exit, void *leave_exception)
+{
+ struct rb_jit_cont *cont;
+ for (cont = first_jit_cont; cont != NULL; cont = cont->next) {
+ if (cont->ec->vm_stack == NULL)
+ continue;
- if (cfp == cont->ec->cfp)
- break; // reached the most recent cfp
+ const rb_control_frame_t *cfp = cont->ec->cfp;
+ while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(cont->ec, cfp)) {
+ if (cfp->jit_return && cfp->jit_return != leave_exception) {
+ ((rb_control_frame_t *)cfp)->jit_return = leave_exit;
+ }
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
}
+#endif
// Finish working with jit_cont.
void
rb_jit_cont_finish(void)
{
- if (!jit_cont_enabled)
- return;
-
struct rb_jit_cont *cont, *next;
for (cont = first_jit_cont; cont != NULL; cont = next) {
next = cont->next;
- free(cont); // Don't use xfree because it's allocated by calloc.
+ ruby_mimfree(cont); // Don't use xfree because it's allocated by mimcalloc.
}
rb_native_mutex_destroy(&jit_cont_lock);
}
@@ -1314,9 +1505,8 @@ static void
cont_init_jit_cont(rb_context_t *cont)
{
VM_ASSERT(cont->jit_cont == NULL);
- if (jit_cont_enabled) {
- cont->jit_cont = jit_cont_new(&(cont->saved_ec));
- }
+ // We always allocate this since YJIT may be enabled later
+ cont->jit_cont = jit_cont_new(&(cont->saved_ec));
}
struct rb_execution_context_struct *
@@ -1345,7 +1535,8 @@ cont_new(VALUE klass)
rb_thread_t *th = GET_THREAD();
THREAD_MUST_BE_RUNNING(th);
- contval = TypedData_Make_Struct(klass, rb_context_t, &cont_data_type, cont);
+ contval = TypedData_Make_Struct(klass, rb_context_t, &rb_cont_data_type, cont);
+ rb_gc_declare_weak_references(contval);
cont->self = contval;
cont_init(cont, th);
return cont;
@@ -1363,15 +1554,11 @@ rb_fiberptr_blocking(struct rb_fiber_struct *fiber)
return fiber->blocking;
}
-// Start working with jit_cont.
+// Initialize the jit_cont_lock
void
rb_jit_cont_init(void)
{
- if (!jit_cont_enabled)
- return;
-
rb_native_mutex_initialize(&jit_cont_lock);
- cont_init_jit_cont(&GET_EC()->fiber_ptr->cont);
}
#if 0
@@ -1393,8 +1580,8 @@ show_vm_pcs(const rb_control_frame_t *cfp,
int i=0;
while (cfp != end_of_cfp) {
int pc = 0;
- if (cfp->iseq) {
- pc = cfp->pc - ISEQ_BODY(cfp->iseq)->iseq_encoded;
+ if (CFP_ISEQ(cfp)) {
+ pc = cfp->pc - ISEQ_BODY(CFP_ISEQ(cfp))->iseq_encoded;
}
fprintf(stderr, "%2d pc: %d\n", i++, pc);
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
@@ -1418,6 +1605,7 @@ cont_capture(volatile int *volatile stat)
#ifdef CAPTURE_JUST_VALID_VM_STACK
cont->saved_vm_stack.slen = ec->cfp->sp - ec->vm_stack;
cont->saved_vm_stack.clen = ec->vm_stack + ec->vm_stack_size - (VALUE*)ec->cfp;
+ cont->saved_vm_stack.size = cont->saved_vm_stack.slen + cont->saved_vm_stack.clen;
cont->saved_vm_stack.ptr = ALLOC_N(VALUE, cont->saved_vm_stack.slen + cont->saved_vm_stack.clen);
MEMCPY(cont->saved_vm_stack.ptr,
ec->vm_stack,
@@ -1427,6 +1615,7 @@ cont_capture(volatile int *volatile stat)
VALUE,
cont->saved_vm_stack.clen);
#else
+ cont->saved_vm_stack.size = ec->vm_stack_size;
cont->saved_vm_stack.ptr = ALLOC_N(VALUE, ec->vm_stack_size);
MEMCPY(cont->saved_vm_stack.ptr, ec->vm_stack, VALUE, ec->vm_stack_size);
#endif
@@ -1435,22 +1624,6 @@ cont_capture(volatile int *volatile stat)
VM_ASSERT(cont->saved_ec.cfp != NULL);
cont_save_machine_stack(th, cont);
- /* backup ensure_list to array for search in another context */
- {
- rb_ensure_list_t *p;
- int size = 0;
- rb_ensure_entry_t *entry;
- for (p=th->ec->ensure_list; p; p=p->next)
- size++;
- entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1);
- for (p=th->ec->ensure_list; p; p=p->next) {
- if (!p->entry.marker)
- p->entry.marker = rb_ary_hidden_new(0); /* dummy object */
- *entry++ = p->entry;
- }
- entry->marker = 0;
- }
-
if (ruby_setjmp(cont->jmpbuf)) {
VALUE value;
@@ -1493,6 +1666,51 @@ cont_restore_thread(rb_context_t *cont)
rb_raise(rb_eRuntimeError, "can't call across trace_func");
}
+#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
+ if (th->ec->tag != sec->tag) {
+ /* find the lowest common ancestor tag of the current EC and the saved EC */
+
+ struct rb_vm_tag *lowest_common_ancestor = NULL;
+ size_t num_tags = 0;
+ size_t num_saved_tags = 0;
+ for (struct rb_vm_tag *tag = th->ec->tag; tag != NULL; tag = tag->prev) {
+ ++num_tags;
+ }
+ for (struct rb_vm_tag *tag = sec->tag; tag != NULL; tag = tag->prev) {
+ ++num_saved_tags;
+ }
+
+ size_t min_tags = num_tags <= num_saved_tags ? num_tags : num_saved_tags;
+
+ struct rb_vm_tag *tag = th->ec->tag;
+ while (num_tags > min_tags) {
+ tag = tag->prev;
+ --num_tags;
+ }
+
+ struct rb_vm_tag *saved_tag = sec->tag;
+ while (num_saved_tags > min_tags) {
+ saved_tag = saved_tag->prev;
+ --num_saved_tags;
+ }
+
+ while (min_tags > 0) {
+ if (tag == saved_tag) {
+ lowest_common_ancestor = tag;
+ break;
+ }
+ tag = tag->prev;
+ saved_tag = saved_tag->prev;
+ --min_tags;
+ }
+
+ /* free all the jump buffers between the current EC's tag and the lowest common ancestor tag */
+ for (struct rb_vm_tag *tag = th->ec->tag; tag != lowest_common_ancestor; tag = tag->prev) {
+ rb_vm_tag_jmpbuf_deinit(&tag->buf);
+ }
+ }
+#endif
+
/* copy vm stack */
#ifdef CAPTURE_JUST_VALID_VM_STACK
MEMCPY(th->ec->vm_stack,
@@ -1511,7 +1729,6 @@ cont_restore_thread(rb_context_t *cont)
th->ec->tag = sec->tag;
th->ec->root_lep = sec->root_lep;
th->ec->root_svar = sec->root_svar;
- th->ec->ensure_list = sec->ensure_list;
th->ec->errinfo = sec->errinfo;
VM_ASSERT(th->ec->vm_stack != NULL);
@@ -1543,11 +1760,10 @@ fiber_setcontext(rb_fiber_t *new_fiber, rb_fiber_t *old_fiber)
}
}
- /* exchange machine_stack_start between old_fiber and new_fiber */
+ /* these values are used in rb_gc_mark_machine_context to mark the fiber's stack. */
old_fiber->cont.saved_ec.machine.stack_start = th->ec->machine.stack_start;
+ old_fiber->cont.saved_ec.machine.stack_end = FIBER_TERMINATED_P(old_fiber) ? NULL : th->ec->machine.stack_end;
- /* old_fiber->machine.stack_end should be NULL */
- old_fiber->cont.saved_ec.machine.stack_end = NULL;
// if (DEBUG) fprintf(stderr, "fiber_setcontext: %p[%p] -> %p[%p]\n", (void*)old_fiber, old_fiber->stack.base, (void*)new_fiber, new_fiber->stack.base);
@@ -1581,9 +1797,9 @@ cont_restore_1(rb_context_t *cont)
cont_restore_thread(cont);
/* restore machine stack */
-#if defined(_M_AMD64) && !defined(__MINGW64__)
+#if (defined(_M_AMD64) && !defined(__MINGW64__)) || defined(_M_ARM64)
{
- /* workaround for x64 SEH */
+ /* workaround for x64 and arm64 SEH on Windows */
jmp_buf buf;
setjmp(buf);
_JUMP_BUFFER *bp = (void*)&cont->jmpbuf;
@@ -1750,6 +1966,13 @@ rb_callcc(VALUE self)
return rb_yield(val);
}
}
+#ifdef RUBY_ASAN_ENABLED
+/* callcc can't possibly work with ASAN; see bug #20273. Also this function
+ * definition below avoids a "defined and not used" warning. */
+MAYBE_UNUSED(static void notusing_callcc(void)) { rb_callcc(Qnil); }
+# define rb_callcc rb_f_notimplement
+#endif
+
static VALUE
make_passing_arg(int argc, const VALUE *argv)
@@ -1768,80 +1991,6 @@ make_passing_arg(int argc, const VALUE *argv)
typedef VALUE e_proc(VALUE);
-/* CAUTION!! : Currently, error in rollback_func is not supported */
-/* same as rb_protect if set rollback_func to NULL */
-void
-ruby_register_rollback_func_for_ensure(e_proc *ensure_func, e_proc *rollback_func)
-{
- st_table **table_p = &GET_VM()->ensure_rollback_table;
- if (UNLIKELY(*table_p == NULL)) {
- *table_p = st_init_numtable();
- }
- st_insert(*table_p, (st_data_t)ensure_func, (st_data_t)rollback_func);
-}
-
-static inline e_proc *
-lookup_rollback_func(e_proc *ensure_func)
-{
- st_table *table = GET_VM()->ensure_rollback_table;
- st_data_t val;
- if (table && st_lookup(table, (st_data_t)ensure_func, &val))
- return (e_proc *) val;
- return (e_proc *) Qundef;
-}
-
-
-static inline void
-rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *target)
-{
- rb_ensure_list_t *p;
- rb_ensure_entry_t *entry;
- size_t i, j;
- size_t cur_size;
- size_t target_size;
- size_t base_point;
- e_proc *func;
-
- cur_size = 0;
- for (p=current; p; p=p->next)
- cur_size++;
- target_size = 0;
- for (entry=target; entry->marker; entry++)
- target_size++;
-
- /* search common stack point */
- p = current;
- base_point = cur_size;
- while (base_point) {
- if (target_size >= base_point &&
- p->entry.marker == target[target_size - base_point].marker)
- break;
- base_point --;
- p = p->next;
- }
-
- /* rollback function check */
- for (i=0; i < target_size - base_point; i++) {
- if (!lookup_rollback_func(target[i].e_proc)) {
- rb_raise(rb_eRuntimeError, "continuation called from out of critical rb_ensure scope");
- }
- }
- /* pop ensure stack */
- while (cur_size > base_point) {
- /* escape from ensure block */
- (*current->entry.e_proc)(current->entry.data2);
- current = current->next;
- cur_size--;
- }
- /* push ensure stack */
- for (j = 0; j < i; j++) {
- func = lookup_rollback_func(target[i - j - 1].e_proc);
- if (!UNDEF_P((VALUE)func)) {
- (*func)(target[i - j - 1].data2);
- }
- }
-}
-
NORETURN(static VALUE rb_cont_call(int argc, VALUE *argv, VALUE contval));
/*
@@ -1873,7 +2022,6 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
rb_raise(rb_eRuntimeError, "continuation called across fiber");
}
}
- rollback_ensure_stack(contval, th->ec->ensure_list, cont->ensure_array);
cont->argc = argc;
cont->value = make_passing_arg(argc, argv);
@@ -1950,7 +2098,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* == Non-blocking Fibers
*
* The concept of <em>non-blocking fiber</em> was introduced in Ruby 3.0.
- * A non-blocking fiber, when reaching a operation that would normally block
+ * A non-blocking fiber, when reaching an operation that would normally block
* the fiber (like <code>sleep</code>, or wait for another process or I/O)
* will yield control to other fibers and allow the <em>scheduler</em> to
* handle blocking and waking up (resuming) this fiber when it can proceed.
@@ -1969,16 +2117,38 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
*
*/
-static const rb_data_type_t fiber_data_type = {
+static void
+fiber_handle_weak_references(void *ptr)
+{
+ rb_fiber_t *fiber = ptr;
+
+ if (!fiber) return;
+
+ if (!rb_gc_handle_weak_references_alive_p(fiber->cont.saved_ec.gen_fields_cache.obj) ||
+ !rb_gc_handle_weak_references_alive_p(fiber->cont.saved_ec.gen_fields_cache.fields_obj)) {
+ fiber->cont.saved_ec.gen_fields_cache.obj = Qundef;
+ fiber->cont.saved_ec.gen_fields_cache.fields_obj = Qundef;
+ }
+}
+
+static const rb_data_type_t rb_fiber_data_type = {
"fiber",
- {fiber_mark, fiber_free, fiber_memsize, fiber_compact,},
+ {fiber_mark, fiber_free, fiber_memsize, fiber_compact, fiber_handle_weak_references},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
static VALUE
fiber_alloc(VALUE klass)
{
- return TypedData_Wrap_Struct(klass, &fiber_data_type, 0);
+ VALUE obj = TypedData_Wrap_Struct(klass, &rb_fiber_data_type, 0);
+ rb_gc_declare_weak_references(obj);
+ return obj;
+}
+
+static rb_serial_t
+next_ec_serial(rb_ractor_t *cr)
+{
+ return cr->next_ec_serial++;
}
static rb_fiber_t*
@@ -1996,9 +2166,11 @@ fiber_t_alloc(VALUE fiber_value, unsigned int blocking)
fiber->cont.self = fiber_value;
fiber->cont.type = FIBER_CONTEXT;
fiber->blocking = blocking;
+ fiber->killed = 0;
cont_init(&fiber->cont, th);
fiber->cont.saved_ec.fiber_ptr = fiber;
+ fiber->cont.saved_ec.serial = next_ec_serial(th->ractor);
rb_ec_clear_vm_stack(&fiber->cont.saved_ec);
fiber->prev = NULL;
@@ -2012,32 +2184,10 @@ fiber_t_alloc(VALUE fiber_value, unsigned int blocking)
return fiber;
}
-static rb_fiber_t *
-root_fiber_alloc(rb_thread_t *th)
-{
- VALUE fiber_value = fiber_alloc(rb_cFiber);
- rb_fiber_t *fiber = th->ec->fiber_ptr;
-
- VM_ASSERT(DATA_PTR(fiber_value) == NULL);
- VM_ASSERT(fiber->cont.type == FIBER_CONTEXT);
- VM_ASSERT(FIBER_RESUMED_P(fiber));
-
- th->root_fiber = fiber;
- DATA_PTR(fiber_value) = fiber;
- fiber->cont.self = fiber_value;
-
- coroutine_initialize_main(&fiber->context);
-
- return fiber;
-}
-
static inline rb_fiber_t*
fiber_current(void)
{
rb_execution_context_t *ec = GET_EC();
- if (ec->fiber_ptr->cont.self == 0) {
- root_fiber_alloc(rb_ec_thread_ptr(ec));
- }
return ec->fiber_ptr;
}
@@ -2105,7 +2255,7 @@ rb_fiber_storage_get(VALUE self)
static int
fiber_storage_validate_each(VALUE key, VALUE value, VALUE _argument)
{
- rb_check_id(&key);
+ Check_Type(key, T_SYMBOL);
return ST_CONTINUE;
}
@@ -2170,15 +2320,14 @@ rb_fiber_storage_set(VALUE self, VALUE value)
* Returns the value of the fiber storage variable identified by +key+.
*
* The +key+ must be a symbol, and the value is set by Fiber#[]= or
- * Fiber#store.
+ * Fiber#storage.
*
* See also Fiber::[]=.
*/
static VALUE
rb_fiber_storage_aref(VALUE class, VALUE key)
{
- ID id = rb_check_id(&key);
- if (!id) return Qnil;
+ key = rb_to_symbol(key);
VALUE storage = fiber_storage_get(fiber_current(), FALSE);
if (storage == Qnil) return Qnil;
@@ -2199,8 +2348,7 @@ rb_fiber_storage_aref(VALUE class, VALUE key)
static VALUE
rb_fiber_storage_aset(VALUE class, VALUE key, VALUE value)
{
- ID id = rb_check_id(&key);
- if (!id) return Qnil;
+ key = rb_to_symbol(key);
VALUE storage = fiber_storage_get(fiber_current(), value != Qnil);
if (storage == Qnil) return Qnil;
@@ -2354,7 +2502,7 @@ rb_fiber_initialize(int argc, VALUE* argv, VALUE self)
VALUE
rb_fiber_new_storage(rb_block_call_func_t func, VALUE obj, VALUE storage)
{
- return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 1, storage);
+ return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), rb_fiber_pool_default(Qnil), 0, storage);
}
VALUE
@@ -2488,7 +2636,6 @@ rb_fiber_start(rb_fiber_t *fiber)
rb_proc_t *proc;
enum ruby_tag_type state;
- int need_interrupt = TRUE;
VM_ASSERT(th->ec == GET_EC());
VM_ASSERT(FIBER_RESUMED_P(fiber));
@@ -2514,6 +2661,7 @@ rb_fiber_start(rb_fiber_t *fiber)
}
EC_POP_TAG();
+ int need_interrupt = TRUE;
VALUE err = Qfalse;
if (state) {
err = th->ec->errinfo;
@@ -2522,13 +2670,16 @@ rb_fiber_start(rb_fiber_t *fiber)
if (state == TAG_RAISE) {
// noop...
}
+ else if (state == TAG_FATAL && err == RUBY_FATAL_FIBER_KILLED) {
+ need_interrupt = FALSE;
+ err = Qfalse;
+ }
else if (state == TAG_FATAL) {
rb_threadptr_pending_interrupt_enque(th, err);
}
else {
err = rb_vm_make_jump_tag_but_local_jump(state, err);
}
- need_interrupt = TRUE;
}
rb_fiber_terminate(fiber, need_interrupt, err);
@@ -2538,37 +2689,48 @@ rb_fiber_start(rb_fiber_t *fiber)
void
rb_threadptr_root_fiber_setup(rb_thread_t *th)
{
- rb_fiber_t *fiber = ruby_mimmalloc(sizeof(rb_fiber_t));
+ rb_fiber_t *fiber = ZALLOC(rb_fiber_t);
if (!fiber) {
rb_bug("%s", strerror(errno)); /* ... is it possible to call rb_bug here? */
}
- MEMZERO(fiber, rb_fiber_t, 1);
+
fiber->cont.type = FIBER_CONTEXT;
fiber->cont.saved_ec.fiber_ptr = fiber;
+ fiber->cont.saved_ec.serial = next_ec_serial(th->ractor);
fiber->cont.saved_ec.thread_ptr = th;
fiber->blocking = 1;
+ fiber->killed = 0;
fiber_status_set(fiber, FIBER_RESUMED); /* skip CREATED */
+
+ coroutine_initialize_main(&fiber->context);
+
th->ec = &fiber->cont.saved_ec;
- // When rb_threadptr_root_fiber_setup is called for the first time, rb_rjit_enabled and
- // rb_yjit_enabled_p() are still false. So this does nothing and rb_jit_cont_init() that is
- // called later will take care of it. However, you still have to call cont_init_jit_cont()
- // here for other Ractors, which are not initialized by rb_jit_cont_init().
+
cont_init_jit_cont(&fiber->cont);
}
void
+rb_root_fiber_obj_setup(rb_thread_t *th)
+{
+ rb_fiber_t *fiber = th->ec->fiber_ptr;
+ VALUE fiber_value = fiber_alloc(rb_cFiber);
+ DATA_PTR(fiber_value) = fiber;
+ fiber->cont.self = fiber_value;
+}
+
+void
rb_threadptr_root_fiber_release(rb_thread_t *th)
{
if (th->root_fiber) {
/* ignore. A root fiber object will free th->ec */
}
else {
- rb_execution_context_t *ec = GET_EC();
+ rb_execution_context_t *ec = rb_current_execution_context(false);
VM_ASSERT(th->ec->fiber_ptr->cont.type == FIBER_CONTEXT);
VM_ASSERT(th->ec->fiber_ptr->cont.self == 0);
- if (th->ec == ec) {
+ if (ec && th->ec == ec) {
rb_ractor_set_current_ec(th->ractor, NULL);
}
fiber_free(th->ec->fiber_ptr);
@@ -2626,15 +2788,7 @@ rb_fiber_current(void)
static inline void
fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th)
{
- rb_fiber_t *fiber;
-
- if (th->ec->fiber_ptr != NULL) {
- fiber = th->ec->fiber_ptr;
- }
- else {
- /* create root fiber */
- fiber = root_fiber_alloc(th);
- }
+ rb_fiber_t *fiber = th->ec->fiber_ptr;
if (FIBER_CREATED_P(next_fiber)) {
fiber_prepare_stack(next_fiber);
@@ -2649,6 +2803,19 @@ fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th)
fiber_setcontext(next_fiber, fiber);
}
+static void
+fiber_check_killed(rb_fiber_t *fiber)
+{
+ VM_ASSERT(fiber == fiber_current());
+
+ if (fiber->killed) {
+ rb_thread_t *thread = fiber->cont.saved_ec.thread_ptr;
+
+ thread->ec->errinfo = RUBY_FATAL_FIBER_KILLED;
+ EC_JUMP_TAG(thread->ec, RUBY_TAG_FATAL);
+ }
+}
+
static inline VALUE
fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fiber_t *resuming_fiber, bool yielding)
{
@@ -2657,7 +2824,9 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fi
rb_thread_t *th = GET_THREAD();
/* make sure the root_fiber object is available */
- if (th->root_fiber == NULL) root_fiber_alloc(th);
+ if (th->root_fiber == NULL) {
+ th->root_fiber = th->ec->fiber_ptr;
+ }
if (th->ec->fiber_ptr == fiber) {
/* ignore fiber context switch
@@ -2722,8 +2891,10 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fi
// We cannot free the stack until the pthread is joined:
#ifndef COROUTINE_PTHREAD_CONTEXT
- if (resuming_fiber && FIBER_TERMINATED_P(fiber)) {
- fiber_stack_release(fiber);
+ if (FIBER_TERMINATED_P(fiber)) {
+ RB_VM_LOCKING() {
+ fiber_stack_release(fiber);
+ }
}
#endif
@@ -2737,7 +2908,14 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fi
current_fiber = th->ec->fiber_ptr;
value = current_fiber->cont.value;
- if (current_fiber->cont.argc == -1) rb_exc_raise(value);
+
+ fiber_check_killed(current_fiber);
+
+ if (current_fiber->cont.argc == -1) {
+ // Fiber#raise will trigger this path.
+ rb_exc_raise(value);
+ }
+
return value;
}
@@ -2773,6 +2951,8 @@ fiber_blocking_yield(VALUE fiber_value)
rb_fiber_t *fiber = fiber_ptr(fiber_value);
rb_thread_t * volatile th = fiber->cont.saved_ec.thread_ptr;
+ VM_ASSERT(fiber->blocking == 0);
+
// fiber->blocking is `unsigned int : 1`, so we use it as a boolean:
fiber->blocking = 1;
@@ -2854,6 +3034,7 @@ void
rb_fiber_close(rb_fiber_t *fiber)
{
fiber_status_set(fiber, FIBER_TERMINATED);
+ rb_ec_close(&fiber->cont.saved_ec);
}
static void
@@ -3175,12 +3356,13 @@ rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-fiber_raise(rb_fiber_t *fiber, int argc, const VALUE *argv)
+fiber_raise(rb_fiber_t *fiber, VALUE exception)
{
- VALUE exception = rb_make_exception(argc, argv);
-
- if (fiber->resuming_fiber) {
- rb_raise(rb_eFiberError, "attempt to raise a resuming fiber");
+ if (fiber == fiber_current()) {
+ rb_exc_raise(exception);
+ }
+ else if (fiber->resuming_fiber) {
+ return fiber_raise(fiber->resuming_fiber, exception);
}
else if (FIBER_SUSPENDED_P(fiber) && !fiber->yielding) {
return fiber_transfer_kw(fiber, -1, &exception, RB_NO_KEYWORDS);
@@ -3191,31 +3373,46 @@ fiber_raise(rb_fiber_t *fiber, int argc, const VALUE *argv)
}
VALUE
-rb_fiber_raise(VALUE fiber, int argc, const VALUE *argv)
+rb_fiber_raise(VALUE fiber, int argc, VALUE *argv)
{
- return fiber_raise(fiber_ptr(fiber), argc, argv);
+ VALUE exception = rb_exception_setup(argc, argv);
+
+ return fiber_raise(fiber_ptr(fiber), exception);
}
/*
* call-seq:
- * fiber.raise -> obj
- * fiber.raise(string) -> obj
- * fiber.raise(exception [, string [, array]]) -> obj
+ * raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
+ * raise(message = nil, cause: $!)
*
* Raises an exception in the fiber at the point at which the last
- * +Fiber.yield+ was called. If the fiber has not been started or has
+ * +Fiber.yield+ was called.
+ *
+ * f = Fiber.new {
+ * puts "Before the yield"
+ * Fiber.yield 1 # -- exception will be raised here
+ * puts "After the yield"
+ * }
+ *
+ * p f.resume
+ * f.raise "Gotcha"
+ *
+ * Output
+ *
+ * Before the first yield
+ * 1
+ * t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError)
+ * from t.rb:8:in 'block in <main>'
+ *
+ * If the fiber has not been started or has
* already run to completion, raises +FiberError+. If the fiber is
* yielding, it is resumed. If it is transferring, it is transferred into.
* But if it is resuming, raises +FiberError+.
*
- * With no arguments, raises a +RuntimeError+. With a single +String+
- * argument, raises a +RuntimeError+ with the string as a message. Otherwise,
- * the first parameter should be the name of an +Exception+ class (or an
- * object that returns an +Exception+ object when sent an +exception+
- * message). The optional second parameter sets the message associated with
- * the exception, and the third parameter is an array of callback information.
- * Exceptions are caught by the +rescue+ clause of <code>begin...end</code>
- * blocks.
+ * Raises +FiberError+ if called on a Fiber belonging to another +Thread+.
+ *
+ * See Kernel#raise for more information on arguments.
+ *
*/
static VALUE
rb_fiber_m_raise(int argc, VALUE *argv, VALUE self)
@@ -3225,6 +3422,46 @@ rb_fiber_m_raise(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
+ * fiber.kill -> nil
+ *
+ * Terminates the fiber by raising an uncatchable exception.
+ * It only terminates the given fiber and no other fiber, returning +nil+ to
+ * another fiber if that fiber was calling #resume or #transfer.
+ *
+ * <tt>Fiber#kill</tt> only interrupts another fiber when it is in Fiber.yield.
+ * If called on the current fiber then it raises that exception at the <tt>Fiber#kill</tt> call site.
+ *
+ * If the fiber has not been started, transition directly to the terminated state.
+ *
+ * If the fiber is already terminated, does nothing.
+ *
+ * Raises FiberError if called on a fiber belonging to another thread.
+ */
+static VALUE
+rb_fiber_m_kill(VALUE self)
+{
+ rb_fiber_t *fiber = fiber_ptr(self);
+
+ if (fiber->killed) return Qfalse;
+ fiber->killed = 1;
+
+ if (fiber->status == FIBER_CREATED) {
+ fiber->status = FIBER_TERMINATED;
+ }
+ else if (fiber->status != FIBER_TERMINATED) {
+ if (fiber_current() == fiber) {
+ fiber_check_killed(fiber);
+ }
+ else {
+ fiber_raise(fiber_ptr(self), Qnil);
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
* Fiber.current -> fiber
*
* Returns the current fiber. If you are not running in the context of
@@ -3270,6 +3507,8 @@ rb_fiber_atfork(rb_thread_t *th)
th->root_fiber = th->ec->fiber_ptr;
}
th->root_fiber->prev = 0;
+ th->root_fiber->blocking = 1;
+ th->blocking = 1;
}
}
#endif
@@ -3282,7 +3521,7 @@ fiber_pool_free(void *ptr)
RUBY_FREE_ENTER("fiber_pool");
fiber_pool_allocation_free(fiber_pool->allocations);
- ruby_xfree(fiber_pool);
+ SIZED_FREE(fiber_pool);
RUBY_FREE_LEAVE("fiber_pool");
}
@@ -3336,7 +3575,7 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool);
- fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size));
+ fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), 0, NUM2SIZET(vm_stack_size));
return self;
}
@@ -3355,6 +3594,46 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
* fiber.resume #=> FiberError: dead fiber called
*/
+static size_t
+shared_fiber_pool_minimum_count(void)
+{
+ size_t minimum_count = FIBER_POOL_MINIMUM_COUNT;
+
+ const char *minimum_count_env = getenv("RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT");
+ if (minimum_count_env && minimum_count_env[0]) {
+ char *end;
+ unsigned long value = strtoul(minimum_count_env, &end, 10);
+ if (end != minimum_count_env && *end == '\0') {
+ minimum_count = (size_t)value;
+ }
+ else {
+ rb_warn("invalid RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT=%s (expected a non-negative integer)", minimum_count_env);
+ }
+ }
+
+ return minimum_count;
+}
+
+static size_t
+shared_fiber_pool_maximum_count(void)
+{
+ size_t maximum_count = 0;
+
+ const char *maximum_count_env = getenv("RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT");
+ if (maximum_count_env && maximum_count_env[0]) {
+ char *end;
+ unsigned long value = strtoul(maximum_count_env, &end, 10);
+ if (end != maximum_count_env && *end == '\0') {
+ maximum_count = (size_t)value;
+ }
+ else {
+ rb_warn("invalid RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT=%s (expected a non-negative integer)", maximum_count_env);
+ }
+ }
+
+ return maximum_count;
+}
+
void
Init_Cont(void)
{
@@ -3372,7 +3651,11 @@ Init_Cont(void)
#endif
SET_MACHINE_STACK_END(&th->ec->machine.stack_end);
- fiber_pool_initialize(&shared_fiber_pool, stack_size, FIBER_POOL_INITIAL_SIZE, vm_stack_size);
+ rb_eFiberError = rb_define_class("FiberError", rb_eStandardError);
+
+ size_t minimum_count = shared_fiber_pool_minimum_count();
+ size_t maximum_count = shared_fiber_pool_maximum_count();
+ fiber_pool_initialize(&shared_fiber_pool, stack_size, minimum_count, maximum_count, vm_stack_size);
fiber_initialize_keywords[0] = rb_intern_const("blocking");
fiber_initialize_keywords[1] = rb_intern_const("pool");
@@ -3381,11 +3664,19 @@ Init_Cont(void)
const char *fiber_shared_fiber_pool_free_stacks = getenv("RUBY_SHARED_FIBER_POOL_FREE_STACKS");
if (fiber_shared_fiber_pool_free_stacks) {
shared_fiber_pool.free_stacks = atoi(fiber_shared_fiber_pool_free_stacks);
+
+ if (shared_fiber_pool.free_stacks < 0) {
+ rb_warn("Setting RUBY_SHARED_FIBER_POOL_FREE_STACKS to a negative value is not allowed.");
+ shared_fiber_pool.free_stacks = 0;
+ }
+
+ if (shared_fiber_pool.free_stacks > 1) {
+ rb_warn("Setting RUBY_SHARED_FIBER_POOL_FREE_STACKS to a value greater than 1 is operating system specific, and may cause crashes.");
+ }
}
rb_cFiber = rb_define_class("Fiber", rb_cObject);
rb_define_alloc_func(rb_cFiber, fiber_alloc);
- rb_eFiberError = rb_define_class("FiberError", rb_eStandardError);
rb_define_singleton_method(rb_cFiber, "yield", rb_fiber_s_yield, -1);
rb_define_singleton_method(rb_cFiber, "current", rb_fiber_s_current, 0);
rb_define_singleton_method(rb_cFiber, "blocking", rb_fiber_blocking, 0);
@@ -3398,6 +3689,7 @@ Init_Cont(void)
rb_define_method(rb_cFiber, "storage=", rb_fiber_storage_set, 1);
rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
rb_define_method(rb_cFiber, "raise", rb_fiber_m_raise, -1);
+ rb_define_method(rb_cFiber, "kill", rb_fiber_m_kill, 0);
rb_define_method(rb_cFiber, "backtrace", rb_fiber_backtrace, -1);
rb_define_method(rb_cFiber, "backtrace_locations", rb_fiber_backtrace_locations, -1);
rb_define_method(rb_cFiber, "to_s", fiber_to_s, 0);
@@ -3412,7 +3704,15 @@ Init_Cont(void)
rb_define_singleton_method(rb_cFiber, "schedule", rb_fiber_s_schedule, -1);
+ rb_thread_t *current_thread = rb_current_thread();
+ RUBY_ASSERT(CLASS_OF(current_thread->ec->fiber_ptr->cont.self) == 0);
+ *(VALUE *)&((struct RBasic *)current_thread->ec->fiber_ptr->cont.self)->klass = rb_cFiber;
+
#ifdef RB_EXPERIMENTAL_FIBER_POOL
+ /*
+ * Document-class: Fiber::Pool
+ * :nodoc: experimental
+ */
rb_cFiberPool = rb_define_class_under(rb_cFiber, "Pool", rb_cObject);
rb_define_alloc_func(rb_cFiberPool, fiber_pool_alloc);
rb_define_method(rb_cFiberPool, "initialize", rb_fiber_pool_initialize, -1);
diff --git a/coroutine/amd64/Context.S b/coroutine/amd64/Context.S
index d50732adbc..4b94d31f30 100644
--- a/coroutine/amd64/Context.S
+++ b/coroutine/amd64/Context.S
@@ -5,37 +5,51 @@
## Copyright, 2018, by Samuel Williams.
##
+/* Important - do _not_ include <cet.h> in this file; doing so will
+ * cause an incorrect .note.gnu.property section to be emitted. We have
+ * one at the bottom of this file */
+
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.globl PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
+
+#if defined(__CET__) && (__CET__ & 0x01) != 0
+ /* IBT landing pad */
+ endbr64
+#endif
+
+ # Make space on the stack for 6 registers:
+ subq $48, %rsp
- # Save caller state
- pushq %rbp
- pushq %rbx
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
+ # Save caller state:
+ movq %rbp, 40(%rsp)
+ movq %rbx, 32(%rsp)
+ movq %r12, 24(%rsp)
+ movq %r13, 16(%rsp)
+ movq %r14, 8(%rsp)
+ movq %r15, (%rsp)
- # Save caller stack pointer
+ # Save caller stack pointer:
movq %rsp, (%rdi)
- # Restore callee stack pointer
+ # Restore callee stack pointer:
movq (%rsi), %rsp
# Restore callee state
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %rbx
- popq %rbp
-
- # Put the first argument into the return value
+ movq 40(%rsp), %rbp
+ movq 32(%rsp), %rbx
+ movq 24(%rsp), %r12
+ movq 16(%rsp), %r13
+ movq 8(%rsp), %r14
+ movq (%rsp), %r15
+
+ # Adjust stack pointer back:
+ addq $48, %rsp
+
+ # Put the first argument into the return value:
movq %rdi, %rax
# We pop the return address and jump to it
@@ -44,3 +58,31 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
+
+#if defined(__ELF__)
+
+#if defined(__CET__) && (__CET__ & 0x01) != 0
+# define IBT_FLAG 0x01
+#else
+# define IBT_FLAG 0x00
+#endif
+
+/* We do _NOT_ support CET shadow-stack. Do _not_ add the property for
+ * this to the Context.o object. If you require CET shadow-stack support,
+ * for now, consider building with --with-coroutine=ucontext */
+#define SHSTK_FLAG 0x00
+
+.pushsection .note.gnu.property, "a"
+.p2align 3
+.long 0x4 /* Name size ("GNU\0") */
+.long 0x10 /* Descriptor size */
+.long 0x5 /* Type: NT_GNU_PROPERTY_TYPE_0 */
+.asciz "GNU" /* Name */
+# Begin descriptor
+.long 0xc0000002 /* Property type: GNU_PROPERTY_X86_FEATURE_1_AND */
+.long 0x4 /* Property size */
+.long (IBT_FLAG | SHSTK_FLAG)
+.long 0x0 /* 8-byte alignment padding */
+/* End descriptor */
+.popsection
+#endif
diff --git a/coroutine/amd64/Context.h b/coroutine/amd64/Context.h
index 44daa4e01a..65aa638304 100644
--- a/coroutine/amd64/Context.h
+++ b/coroutine/amd64/Context.h
@@ -69,7 +69,7 @@ static inline void coroutine_initialize(
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
*--context->stack_pointer = NULL;
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
diff --git a/coroutine/arm32/Context.S b/coroutine/arm32/Context.S
index 1850c4c408..945e4f82d5 100644
--- a/coroutine/arm32/Context.S
+++ b/coroutine/arm32/Context.S
@@ -6,16 +6,15 @@
##
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.file "Context.S"
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
+.globl PREFIXED_SYMBOL(coroutine_transfer)
.align 2
-.type PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer),%function
+.type PREFIXED_SYMBOL(coroutine_transfer),%function
.syntax unified
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+PREFIXED_SYMBOL(coroutine_transfer):
# Save caller state (8 registers + return address)
push {r4-r11,lr}
diff --git a/coroutine/arm32/Context.h b/coroutine/arm32/Context.h
index 09410eb25d..7529dd2efc 100644
--- a/coroutine/arm32/Context.h
+++ b/coroutine/arm32/Context.h
@@ -44,7 +44,7 @@ static inline void coroutine_initialize(
char * top = (char*)stack + size;
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
diff --git a/coroutine/arm64/Context.S b/coroutine/arm64/Context.S
index 07d50d30df..ce219c0c4d 100644
--- a/coroutine/arm64/Context.S
+++ b/coroutine/arm64/Context.S
@@ -6,7 +6,6 @@
##
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
#if defined(__APPLE__)
#define x29 fp
@@ -18,26 +17,63 @@
.align 2
#endif
-.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT & 0x02) != 0
+# error "-mbranch-protection flag specified b-key but Context.S does not support this"
+#endif
+
+#if defined(_WIN32)
+## Add more space for certain TEB values on each stack
+#define TEB_OFFSET 0x20
+#else
+#define TEB_OFFSET 0x00
+#endif
+
+## NOTE(PAC): Use we HINT mnemonics instead of PAC mnemonics to
+## keep compatibility with those assemblers that don't support PAC.
+##
+## See "Providing protection for complex software" for more details about PAC/BTI
+## https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
+
+.global PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+ # paciasp (it also acts as BTI landing pad, so no need to insert BTI also)
+ hint #25
+#elif defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT != 0)
+ # For the case PAC is not enabled but BTI is.
+ # bti c
+ hint #34
+#endif
# Make space on the stack for caller registers
- sub sp, sp, 0xb0
+ sub sp, sp, 0xa0 + TEB_OFFSET
# Save caller registers
- stp d8, d9, [sp, 0x00]
- stp d10, d11, [sp, 0x10]
- stp d12, d13, [sp, 0x20]
- stp d14, d15, [sp, 0x30]
- stp x19, x20, [sp, 0x40]
- stp x21, x22, [sp, 0x50]
- stp x23, x24, [sp, 0x60]
- stp x25, x26, [sp, 0x70]
- stp x27, x28, [sp, 0x80]
- stp x29, x30, [sp, 0x90]
-
- # Save return address
- str x30, [sp, 0xa0]
+ stp d8, d9, [sp, 0x00 + TEB_OFFSET]
+ stp d10, d11, [sp, 0x10 + TEB_OFFSET]
+ stp d12, d13, [sp, 0x20 + TEB_OFFSET]
+ stp d14, d15, [sp, 0x30 + TEB_OFFSET]
+ stp x19, x20, [sp, 0x40 + TEB_OFFSET]
+ stp x21, x22, [sp, 0x50 + TEB_OFFSET]
+ stp x23, x24, [sp, 0x60 + TEB_OFFSET]
+ stp x25, x26, [sp, 0x70 + TEB_OFFSET]
+ stp x27, x28, [sp, 0x80 + TEB_OFFSET]
+ stp x29, x30, [sp, 0x90 + TEB_OFFSET]
+
+#if defined(_WIN32)
+ # Save certain values from Thread Environment Block (TEB)
+ # x18 points to the TEB on Windows
+ # Read TeStackBase and TeStackLimit at ksarm64.h from TEB
+ ldp x5, x6, [x18, #0x08]
+ # Save them
+ stp x5, x6, [sp, #0x00]
+ # Read TeDeallocationStack at ksarm64.h from TEB
+ ldr x5, [x18, #0x1478]
+ # Read TeFiberData at ksarm64.h from TEB
+ ldr x6, [x18, #0x20]
+ # Save current fiber data and deallocation stack
+ stp x5, x6, [sp, #0x10]
+#endif
# Save stack pointer to x0 (first argument)
mov x2, sp
@@ -47,27 +83,78 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
ldr x3, [x1, 0]
mov sp, x3
+#if defined(_WIN32)
+ # Restore stack base and limit
+ ldp x5, x6, [sp, #0x00]
+ # Write TeStackBase and TeStackLimit at ksarm64.h to TEB
+ stp x5, x6, [x18, #0x08]
+ # Restore fiber data and deallocation stack
+ ldp x5, x6, [sp, #0x10]
+ # Write TeDeallocationStack at ksarm64.h to TEB
+ str x5, [x18, #0x1478]
+ # Write TeFiberData at ksarm64.h to TEB
+ str x6, [x18, #0x20]
+#endif
+
# Restore caller registers
- ldp d8, d9, [sp, 0x00]
- ldp d10, d11, [sp, 0x10]
- ldp d12, d13, [sp, 0x20]
- ldp d14, d15, [sp, 0x30]
- ldp x19, x20, [sp, 0x40]
- ldp x21, x22, [sp, 0x50]
- ldp x23, x24, [sp, 0x60]
- ldp x25, x26, [sp, 0x70]
- ldp x27, x28, [sp, 0x80]
- ldp x29, x30, [sp, 0x90]
-
- # Load return address into x4
- ldr x4, [sp, 0xa0]
+ ldp d8, d9, [sp, 0x00 + TEB_OFFSET]
+ ldp d10, d11, [sp, 0x10 + TEB_OFFSET]
+ ldp d12, d13, [sp, 0x20 + TEB_OFFSET]
+ ldp d14, d15, [sp, 0x30 + TEB_OFFSET]
+ ldp x19, x20, [sp, 0x40 + TEB_OFFSET]
+ ldp x21, x22, [sp, 0x50 + TEB_OFFSET]
+ ldp x23, x24, [sp, 0x60 + TEB_OFFSET]
+ ldp x25, x26, [sp, 0x70 + TEB_OFFSET]
+ ldp x27, x28, [sp, 0x80 + TEB_OFFSET]
+ ldp x29, x30, [sp, 0x90 + TEB_OFFSET]
# Pop stack frame
- add sp, sp, 0xb0
+ add sp, sp, 0xa0 + TEB_OFFSET
- # Jump to return address (in x4)
- ret x4
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+ # autiasp: Authenticate x30 (LR) with SP and key A
+ hint #29
+#endif
+
+ # Jump to return address (in x30)
+ ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
+
+#if (defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0) || (defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0)
+#if defined(__ELF__)
+/* See "ELF for the Arm 64-bit Architecture (AArch64)"
+ https://github.com/ARM-software/abi-aa/blob/2023Q3/aaelf64/aaelf64.rst#program-property */
+# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1<<0)
+# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1<<1)
+
+# if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0
+# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+# else
+# define BTI_FLAG 0
+# endif
+# if defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0
+# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
+# else
+# define PAC_FLAG 0
+# endif
+
+ # The note section format is described by Note Section in Chapter 5
+ # of "System V Application Binary Interface, Edition 4.1".
+ .pushsection .note.gnu.property, "a"
+ .p2align 3
+ .long 0x4 /* Name size ("GNU\0") */
+ .long 0x10 /* Descriptor size */
+ .long 0x5 /* Type: NT_GNU_PROPERTY_TYPE_0 */
+ .asciz "GNU" /* Name */
+ # Begin descriptor
+ .long 0xc0000000 /* Property type: GNU_PROPERTY_AARCH64_FEATURE_1_AND */
+ .long 0x4 /* Property size */
+ .long (BTI_FLAG|PAC_FLAG)
+ .long 0x0 /* 8-byte alignment padding */
+ # End descriptor
+ .popsection
+#endif
+#endif
diff --git a/coroutine/arm64/Context.asm b/coroutine/arm64/Context.asm
new file mode 100644
index 0000000000..866fa628e7
--- /dev/null
+++ b/coroutine/arm64/Context.asm
@@ -0,0 +1,81 @@
+ TTL coroutine/arm64/Context.asm
+
+ AREA |.drectve|, DRECTVE
+
+ EXPORT |coroutine_transfer|
+
+ AREA |.text$mn|, CODE, ARM64
+
+;; Add more space for certain TEB values on each stack
+TEB_OFFSET EQU 0x20
+
+;; Incomplete implementation
+coroutine_transfer PROC
+ ; Make space on the stack for caller registers
+ sub sp, sp, 0xa0 + TEB_OFFSET
+
+ ; Save caller registers
+ stp d8, d9, [sp, 0x00 + TEB_OFFSET]
+ stp d10, d11, [sp, 0x10 + TEB_OFFSET]
+ stp d12, d13, [sp, 0x20 + TEB_OFFSET]
+ stp d14, d15, [sp, 0x30 + TEB_OFFSET]
+ stp x19, x20, [sp, 0x40 + TEB_OFFSET]
+ stp x21, x22, [sp, 0x50 + TEB_OFFSET]
+ stp x23, x24, [sp, 0x60 + TEB_OFFSET]
+ stp x25, x26, [sp, 0x70 + TEB_OFFSET]
+ stp x27, x28, [sp, 0x80 + TEB_OFFSET]
+ stp x29, x30, [sp, 0x90 + TEB_OFFSET]
+
+ ;; Save certain values from Thread Environment Block (TEB) x18
+ ;; points to the TEB on Windows
+ ;; Read TeStackBase and TeStackLimit at ksarm64.h from TEB
+ ldp x5, x6, [x18, #0x08]
+ ;; Save them
+ stp x5, x6, [sp, #0x00]
+ ;; Read TeDeallocationStack at ksarm64.h from TEB
+ ldr x5, [x18, #0x1478]
+ ;; Read TeFiberData at ksarm64.h from TEB
+ ldr x6, [x18, #0x20]
+ ;; Save current fiber data and deallocation stack
+ stp x5, x6, [sp, #0x10]
+
+ ; Save stack pointer to x0 (first argument)
+ mov x2, sp
+ str x2, [x0, 0]
+
+ ; Load stack pointer from x1 (second argument)
+ ldr x3, [x1, 0]
+ mov sp, x3
+
+ ;; Restore stack base and limit
+ ldp x5, x6, [sp, #0x00]
+ ;; Write TeStackBase and TeStackLimit at ksarm64.h to TEB
+ stp x5, x6, [x18, #0x08]
+ ;; Restore fiber data and deallocation stack
+ ldp x5, x6, [sp, #0x10]
+ ;; Write TeDeallocationStack at ksarm64.h to TEB
+ str x5, [x18, #0x1478]
+ ;; Write TeFiberData at ksarm64.h to TEB
+ str x6, [x18, #0x20]
+
+ ; Restore caller registers
+ ldp d8, d9, [sp, 0x00 + TEB_OFFSET]
+ ldp d10, d11, [sp, 0x10 + TEB_OFFSET]
+ ldp d12, d13, [sp, 0x20 + TEB_OFFSET]
+ ldp d14, d15, [sp, 0x30 + TEB_OFFSET]
+ ldp x19, x20, [sp, 0x40 + TEB_OFFSET]
+ ldp x21, x22, [sp, 0x50 + TEB_OFFSET]
+ ldp x23, x24, [sp, 0x60 + TEB_OFFSET]
+ ldp x25, x26, [sp, 0x70 + TEB_OFFSET]
+ ldp x27, x28, [sp, 0x80 + TEB_OFFSET]
+ ldp x29, x30, [sp, 0x90 + TEB_OFFSET]
+
+ ; Pop stack frame
+ add sp, sp, 0xa0 + TEB_OFFSET
+
+ ; Jump to return address (in x30)
+ ret
+
+ endp
+
+ end
diff --git a/coroutine/arm64/Context.h b/coroutine/arm64/Context.h
index 1472621f48..468e4155b2 100644
--- a/coroutine/arm64/Context.h
+++ b/coroutine/arm64/Context.h
@@ -15,9 +15,21 @@
#include <stdint.h>
#include <string.h>
+#if defined __GNUC__
#define COROUTINE __attribute__((noreturn)) void
+#define COROUTINE_DECL COROUTINE
+#elif defined _MSC_VER
+#define COROUTINE __declspec(noreturn) void
+#define COROUTINE_DECL void
+#endif
+
+#if defined(_WIN32)
+#define TEB_OFFSET 0x20
+#else
+#define TEB_OFFSET 0x00
+#endif
-enum {COROUTINE_REGISTERS = 0xb0 / 8};
+enum {COROUTINE_REGISTERS = (0xa0 + TEB_OFFSET) / 8};
#if defined(__SANITIZE_ADDRESS__)
#define COROUTINE_SANITIZE_ADDRESS
@@ -44,12 +56,26 @@ struct coroutine_context
#endif
};
-typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
+typedef COROUTINE_DECL(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
static inline void coroutine_initialize_main(struct coroutine_context * context) {
context->stack_pointer = NULL;
}
+static inline void *ptrauth_sign_instruction_addr(void *addr, void *modifier) {
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0
+ // Sign the given instruction address with the given modifier and key A
+ register void *r17 __asm("r17") = addr;
+ register void *r16 __asm("r16") = modifier;
+ // Use HINT mnemonic instead of PACIA1716 for compatibility with older assemblers.
+ __asm ("hint #8;" : "+r"(r17) : "r"(r16));
+ addr = r17;
+#else
+ // No-op if PAC is not enabled
+#endif
+ return addr;
+}
+
static inline void coroutine_initialize(
struct coroutine_context *context,
coroutine_start start,
@@ -66,12 +92,21 @@ static inline void coroutine_initialize(
// Stack grows down. Force 16-byte alignment.
char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
+ top = (char *)((uintptr_t)top & ~0xF);
+ context->stack_pointer = (void**)top;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
- context->stack_pointer[0xa0 / 8] = (void*)start;
+ void *addr = (void*)(uintptr_t)start;
+ context->stack_pointer[(0x98 + TEB_OFFSET) / 8] = ptrauth_sign_instruction_addr(addr, (void*)top);
+#if defined(_WIN32)
+ // save top address of stack as base in TEB
+ context->stack_pointer[0x00 / 8] = (char*)stack + size;
+ // save botton address of stack as limit and deallocation stack in TEB
+ context->stack_pointer[0x08 / 8] = stack;
+ context->stack_pointer[0x10 / 8] = stack;
+#endif
}
struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
diff --git a/coroutine/asyncify/Context.h b/coroutine/asyncify/Context.h
index 7dba829a1d..71791a4004 100644
--- a/coroutine/asyncify/Context.h
+++ b/coroutine/asyncify/Context.h
@@ -13,6 +13,7 @@
#include <stddef.h>
#include <stdio.h>
+#include <stdint.h>
#include "wasm/asyncify.h"
#include "wasm/machine.h"
#include "wasm/fiber.h"
@@ -47,10 +48,13 @@ static inline void coroutine_initialize_main(struct coroutine_context * context)
static inline void coroutine_initialize(struct coroutine_context *context, coroutine_start start, void *stack, size_t size)
{
- if (ASYNCIFY_CORO_DEBUG) fprintf(stderr, "[%s] entry (context = %p, stack = %p ... %p)\n", __func__, context, stack, (char *)stack + size);
+ // Linear stack pointer must be always aligned down to 16 bytes.
+ // https://github.com/WebAssembly/tool-conventions/blob/c74267a5897c1bdc9aa60adeaf41816387d3cd12/BasicCABI.md#the-linear-stack
+ uintptr_t sp = ((uintptr_t)stack + size) & ~0xF;
+ if (ASYNCIFY_CORO_DEBUG) fprintf(stderr, "[%s] entry (context = %p, stack = %p ... %p)\n", __func__, context, stack, (char *)sp);
rb_wasm_init_context(&context->fc, coroutine_trampoline, start, context);
// record the initial stack pointer position to restore it after resumption
- context->current_sp = (char *)stack + size;
+ context->current_sp = (char *)sp;
context->stack_base = stack;
context->size = size;
}
diff --git a/coroutine/loongarch64/Context.S b/coroutine/loongarch64/Context.S
index 662f5dfb6c..6e10cd032b 100644
--- a/coroutine/loongarch64/Context.S
+++ b/coroutine/loongarch64/Context.S
@@ -1,11 +1,10 @@
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.text
.align 2
-.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.global PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
# Make space on the stack for caller registers
addi.d $sp, $sp, -0xa0
diff --git a/coroutine/loongarch64/Context.h b/coroutine/loongarch64/Context.h
index 668c9a965e..82b85b36e9 100644
--- a/coroutine/loongarch64/Context.h
+++ b/coroutine/loongarch64/Context.h
@@ -36,7 +36,7 @@ static inline void coroutine_initialize(
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
- context->stack_pointer[0x90 / 8] = (void*)start;
+ context->stack_pointer[0x90 / 8] = (void*)(uintptr_t)start;
}
struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
diff --git a/coroutine/ppc/Context.S b/coroutine/ppc/Context.S
index cdda93e179..f44b2419b4 100644
--- a/coroutine/ppc/Context.S
+++ b/coroutine/ppc/Context.S
@@ -3,21 +3,20 @@
; Some relevant examples: https://github.com/gcc-mirror/gcc/blob/master/libphobos/libdruntime/config/powerpc/switchcontext.S
; https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/rs6000/darwin-gpsave.S
; https://www.ibm.com/docs/en/aix/7.2?topic=epilogs-saving-gprs-only
-; ppc32 version may be re-written compactly with stmw/lwm, but the code wonʼt be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
+; ppc32 version may be re-written compactly with stmw/lwm, but the code won't be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
; Notice that this code is only for Darwin (macOS). Darwin ABI differs from AIX and ELF.
; To add support for AIX, *BSD or *Linux, please make separate implementations.
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.machine ppc7400 ; = G4, Rosetta
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
+.globl PREFIXED_SYMBOL(coroutine_transfer)
.align 2
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+PREFIXED_SYMBOL(coroutine_transfer):
; Make space on the stack for caller registers
; (Should we rather use red zone? See libphobos example.)
subi r1,r1,80
diff --git a/coroutine/ppc/Context.h b/coroutine/ppc/Context.h
index 1fce112579..8035d08556 100644
--- a/coroutine/ppc/Context.h
+++ b/coroutine/ppc/Context.h
@@ -13,7 +13,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/coroutine/ppc64/Context.S b/coroutine/ppc64/Context.S
index f8561e0e7d..20a47c61c6 100644
--- a/coroutine/ppc64/Context.S
+++ b/coroutine/ppc64/Context.S
@@ -8,15 +8,14 @@
; To add support for AIX, *BSD or *Linux, please make separate implementations.
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.machine ppc64 ; = G5
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
+.globl PREFIXED_SYMBOL(coroutine_transfer)
.align 2
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+PREFIXED_SYMBOL(coroutine_transfer):
; Make space on the stack for caller registers
; (Should we rather use red zone? See libphobos example.)
subi r1,r1,160
diff --git a/coroutine/ppc64/Context.h b/coroutine/ppc64/Context.h
index 3e6f77f55a..085b475ed5 100644
--- a/coroutine/ppc64/Context.h
+++ b/coroutine/ppc64/Context.h
@@ -12,7 +12,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/coroutine/ppc64le/Context.S b/coroutine/ppc64le/Context.S
index 61be9efcf0..819264c245 100644
--- a/coroutine/ppc64le/Context.S
+++ b/coroutine/ppc64le/Context.S
@@ -1,14 +1,20 @@
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
+.abiversion 2
.text
.align 2
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-.type PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer), @function
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.globl PREFIXED_SYMBOL(coroutine_transfer)
+.type PREFIXED_SYMBOL(coroutine_transfer), @function
+PREFIXED_SYMBOL(coroutine_transfer):
+ # Global entry: set up TOC pointer (r2) from r12.
+ # Required by ELFv2 ABI when this function is reached via the PLT.
+ addis 2, 12, .TOC. - PREFIXED_SYMBOL(coroutine_transfer)@ha
+ addi 2, 2, .TOC. - PREFIXED_SYMBOL(coroutine_transfer)@l
+ .localentry PREFIXED_SYMBOL(coroutine_transfer), .-PREFIXED_SYMBOL(coroutine_transfer)
+
# Make space on the stack for caller registers
- addi 1,1,-152
+ addi 1,1,-160
# Save caller registers
std 14,0(1)
@@ -34,6 +40,10 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
mflr 0
std 0,144(1)
+ # Save caller special register
+ mfcr 0
+ std 0, 152(1)
+
# Save stack pointer to first argument
std 1,0(3)
@@ -64,8 +74,14 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
ld 0,144(1)
mtlr 0
+ # Load special registers
+ ld 0,152(1)
+ # Restore cr register cr2, cr3 and cr4 (field index 3,4,5)
+ # (field index is 1-based, field 1 = cr0) using a mask (32|16|8 = 56)
+ mtcrf 56,0
+
# Pop stack frame
- addi 1,1,152
+ addi 1,1,160
# Jump to return address
blr
diff --git a/coroutine/ppc64le/Context.h b/coroutine/ppc64le/Context.h
index fbfaa2ee63..63ea9f19ff 100644
--- a/coroutine/ppc64le/Context.h
+++ b/coroutine/ppc64le/Context.h
@@ -12,7 +12,7 @@
enum {
COROUTINE_REGISTERS =
- 19 /* 18 general purpose registers (r14-r31) and 1 return address */
+ 20 /* 18 general purpose registers (r14-r31), 1 special register (cr) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/coroutine/riscv64/Context.S b/coroutine/riscv64/Context.S
index cc4e872f84..8e7fc74ffc 100644
--- a/coroutine/riscv64/Context.S
+++ b/coroutine/riscv64/Context.S
@@ -1,11 +1,10 @@
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.text
.align 2
-.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.global PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
# Make space on the stack for caller registers
addi sp, sp, -0xd0
diff --git a/coroutine/riscv64/Context.h b/coroutine/riscv64/Context.h
index 9ce1140e0b..3660fb5577 100644
--- a/coroutine/riscv64/Context.h
+++ b/coroutine/riscv64/Context.h
@@ -36,7 +36,7 @@ static inline void coroutine_initialize(
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
- context->stack_pointer[0xc0 / 8] = (void*)start;
+ context->stack_pointer[0xc0 / 8] = (void*)(uintptr_t)start;
}
struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
diff --git a/coroutine/win32/Context.h b/coroutine/win32/Context.h
index 902fd1246f..c1c8fbcd13 100644
--- a/coroutine/win32/Context.h
+++ b/coroutine/win32/Context.h
@@ -16,6 +16,7 @@
#include <string.h>
#define COROUTINE __declspec(noreturn) void __fastcall
+#define COROUTINE_DECL void __fastcall
#define COROUTINE_LIMITED_ADDRESS_SPACE
/* This doesn't include thread information block */
@@ -45,7 +46,7 @@ static inline void coroutine_initialize(
char * top = (char*)stack + size;
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
/* Windows Thread Information Block */
*--context->stack_pointer = (void*)0xFFFFFFFF; /* fs:[0] */
diff --git a/coroutine/win64/Context.h b/coroutine/win64/Context.h
index aaa4caeaf9..23b21b5c1c 100644
--- a/coroutine/win64/Context.h
+++ b/coroutine/win64/Context.h
@@ -16,6 +16,7 @@
#include <string.h>
#define COROUTINE __declspec(noreturn) void
+#define COROUTINE_DECL void
enum {
COROUTINE_REGISTERS = 8,
@@ -30,7 +31,7 @@ struct coroutine_context
typedef void(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
-void coroutine_trampoline();
+void coroutine_trampoline(void);
static inline void coroutine_initialize_main(struct coroutine_context * context) {
context->stack_pointer = NULL;
@@ -53,7 +54,7 @@ static inline void coroutine_initialize(
/* Return address */
*--context->stack_pointer = 0;
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
*--context->stack_pointer = (void*)coroutine_trampoline;
/* Windows Thread Information Block */
diff --git a/coroutine/x86/Context.S b/coroutine/x86/Context.S
index f06a417084..b04e71aa1c 100644
--- a/coroutine/x86/Context.S
+++ b/coroutine/x86/Context.S
@@ -6,12 +6,11 @@
##
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.globl PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
# Save caller registers
pushl %ebp
diff --git a/coroutine/x86/Context.h b/coroutine/x86/Context.h
index d98eaf6486..f33b338eab 100644
--- a/coroutine/x86/Context.h
+++ b/coroutine/x86/Context.h
@@ -45,7 +45,7 @@ static inline void coroutine_initialize(
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
*--context->stack_pointer = NULL;
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in
index 43e92a27f0..109baa747d 100644
--- a/cygwin/GNUmakefile.in
+++ b/cygwin/GNUmakefile.in
@@ -2,6 +2,9 @@ gnumake = yes
include Makefile
+MUNICODE_FLAG := $(if $(filter mingw%,$(target_os)),-municode)
+override EXE_LDFLAGS += $(MUNICODE_FLAG)
+
DLLWRAP = @DLLWRAP@ --target=$(target_os) --driver-name="$(CC)"
windres-cpp := $(CPP) -xc
windres-cpp := --preprocessor=$(firstword $(windres-cpp)) \
@@ -41,6 +44,7 @@ SOLIBS := $(DLL_BASE_NAME).res.$(OBJEXT) $(SOLIBS)
override EXTOBJS += $(if $(filter-out $(RUBYW_INSTALL_NAME),$(@:$(EXEEXT)=)),$(RUBY_INSTALL_NAME),$(@:$(EXEEXT)=)).res.$(OBJEXT)
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
RUBYDEF = $(DLL_BASE_NAME).def
+override LIBRUBY_FOR_LEAKED_GLOBALS := # DLL shows symbols from import library
ruby: $(PROGRAM)
rubyw: $(WPROGRAM)
@@ -63,7 +67,7 @@ $(PROGRAM): $(RUBY_INSTALL_NAME).res.$(OBJEXT)
$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.$(OBJEXT)
@rm -f $@
$(ECHO) linking $@
- $(Q) $(PURIFY) $(CC) -mwindows -e $(SYMBOL_PREFIX)mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
+ $(Q) $(PURIFY) $(CC) $(MUNICODE_FLAG) -mwindows -e $(SYMBOL_PREFIX)mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
$(STUBPROGRAM): $(RUBY_INSTALL_NAME).res.$(OBJEXT)
@@ -90,6 +94,8 @@ yes-test-all: export MSYS2_ARG_CONV_EXCL=$(MSYS2_ARG_CONV_EXCL_PARAM)
yes-test-almost: export MSYS2_ARG_CONV_EXCL=$(MSYS2_ARG_CONV_EXCL_PARAM)
test/% spec/%/ spec/%_spec.rb: export MSYS2_ARG_CONV_EXCL=$(MSYS2_ARG_CONV_EXCL_PARAM)
+distclean-local::
+ $(RMDIR) win32
endif
$(LIBRUBY_SO): $(RUBYDEF)
diff --git a/darray.h b/darray.h
index 7183041f03..d6521be19f 100644
--- a/darray.h
+++ b/darray.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
+#include "ruby/ruby.h"
// Type for a dynamic array. Use to declare a dynamic array.
// It is a pointer so it fits in st_table nicely. Designed
@@ -37,33 +38,40 @@
//
#define rb_darray_ref(ary, idx) (&((ary)->data[(idx)]))
-// Copy a new element into the array. ptr_to_ary is evaluated multiple times.
-//
-// void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
-//
-#define rb_darray_append(ptr_to_ary, element) do { \
- rb_darray_ensure_space((ptr_to_ary), sizeof(**(ptr_to_ary)), \
- sizeof((*(ptr_to_ary))->data[0])); \
+/* Copy a new element into the array. ptr_to_ary is evaluated multiple times.
+ *
+ * void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
+ */
+#define rb_darray_append(ptr_to_ary, element) \
+ rb_darray_append_impl(ptr_to_ary, element, rb_darray_realloc_mul_add)
+
+#define rb_darray_append_without_gc(ptr_to_ary, element) \
+ rb_darray_append_impl(ptr_to_ary, element, rb_darray_realloc_mul_add_without_gc)
+
+#define rb_darray_append_impl(ptr_to_ary, element, realloc_func) do { \
+ rb_darray_ensure_space((ptr_to_ary), \
+ sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), \
+ realloc_func); \
rb_darray_set(*(ptr_to_ary), \
(*(ptr_to_ary))->meta.size, \
(element)); \
(*(ptr_to_ary))->meta.size++; \
} while (0)
-
-// Last element of the array
-//
-#define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
-
-// Remove the last element of the array.
-//
-#define rb_darray_pop_back(ary) ((ary)->meta.size--)
-
-// Remove element at idx and replace it by the last element
-#define rb_darray_remove_unordered(ary, idx) do { \
- rb_darray_set(ary, idx, rb_darray_back(ary)); \
- rb_darray_pop_back(ary); \
-} while (0);
+#define rb_darray_insert_without_gc(ptr_to_ary, idx, element) do { \
+ rb_darray_ensure_space((ptr_to_ary), \
+ sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), \
+ rb_darray_realloc_mul_add_without_gc); \
+ MEMMOVE( \
+ rb_darray_ref(*(ptr_to_ary), idx + 1), \
+ rb_darray_ref(*(ptr_to_ary), idx), \
+ (*(ptr_to_ary))->data[0], \
+ rb_darray_size(*(ptr_to_ary)) - idx); \
+ rb_darray_set(*(ptr_to_ary), idx, element); \
+ (*(ptr_to_ary))->meta.size++; \
+} while (0)
// Iterate over items of the array in a for loop
//
@@ -75,28 +83,48 @@
#define rb_darray_for(ary, idx_name) \
for (size_t idx_name = 0; idx_name < rb_darray_size(ary); ++idx_name)
-// Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
-//
-// Note that NULL is a valid empty dynamic array.
-//
-// void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
-//
+/* Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
+ * Return 1 on success and 0 on failure.
+ *
+ * Note that NULL is a valid empty dynamic array.
+ *
+ * void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
+ */
#define rb_darray_make(ptr_to_ary, size) \
rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
- sizeof((*(ptr_to_ary))->data[0]))
+ sizeof((*(ptr_to_ary))->data[0]), rb_darray_calloc_mul_add)
-#define rb_darray_data_ptr(ary) ((ary)->data)
+#define rb_darray_make_without_gc(ptr_to_ary, size) \
+ rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), rb_darray_calloc_mul_add_without_gc)
-// Set the size of the array to zero without freeing the backing memory.
-// Allows reusing the same array.
-//
-#define rb_darray_clear(ary) (ary->meta.size = 0)
+/* Resize the darray to a new capacity. The new capacity must be greater than
+ * or equal to the size of the darray.
+ *
+ * void rb_darray_resize_capa(rb_darray(T) *ptr_to_ary, size_t capa);
+ */
+#define rb_darray_resize_capa_without_gc(ptr_to_ary, capa) \
+ rb_darray_resize_capa_impl((ptr_to_ary), capa, sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), rb_darray_realloc_mul_add_without_gc)
+
+#define rb_darray_data_ptr(ary) ((ary)->data)
typedef struct rb_darray_meta {
size_t size;
size_t capa;
} rb_darray_meta_t;
+/* Set the size of the array to zero without freeing the backing memory.
+ * Allows reusing the same array. */
+static inline void
+rb_darray_clear(void *ary)
+{
+ rb_darray_meta_t *meta = ary;
+ if (meta) {
+ meta->size = 0;
+ }
+}
+
// Get the size of the dynamic array.
//
static inline size_t
@@ -106,6 +134,17 @@ rb_darray_size(const void *ary)
return meta ? meta->size : 0;
}
+/* Estimate of the amount of memory used by this darray.
+ * Useful for TypedData objects. */
+#define rb_darray_memsize(ary) (sizeof(*(ary)) + (rb_darray_size(ary) * sizeof((ary)->data[0])))
+
+static inline void
+rb_darray_pop(void *ary, size_t count)
+{
+ rb_darray_meta_t *meta = ary;
+ meta->size -= count;
+}
+
// Get the capacity of the dynamic array.
//
static inline size_t
@@ -115,20 +154,112 @@ rb_darray_capa(const void *ary)
return meta ? meta->capa : 0;
}
-// Free the dynamic array.
-//
+/* Free the dynamic array. */
static inline void
rb_darray_free(void *ary)
{
- rb_darray_meta_t *meta = ary;
- ruby_sized_xfree(ary, meta->capa);
+ xfree(ary);
+}
+
+static inline void
+rb_darray_free_sized0(void *ary, size_t element_size)
+{
+ const rb_darray_meta_t *meta = ary;
+ if (meta) {
+ ruby_xfree_sized(ary, sizeof(*meta) + (element_size * meta->capa));
+ }
+}
+#define rb_darray_free_sized(ary, T) rb_darray_free_sized0((ary), sizeof(T))
+
+static inline void
+rb_darray_free_without_gc(void *ary)
+{
+ free(ary);
+}
+
+/* Internal function. Like rb_xcalloc_mul_add. */
+static inline void *
+rb_darray_calloc_mul_add(size_t x, size_t y, size_t z)
+{
+ size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(x, y), z);
+
+ void *ptr = xcalloc(1, size);
+ RUBY_ASSERT(ptr != NULL);
+
+ return ptr;
+}
+
+/* Internal function. Like rb_xcalloc_mul_add but does not trigger GC. */
+static inline void *
+rb_darray_calloc_mul_add_without_gc(size_t x, size_t y, size_t z)
+{
+ size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(x, y), z);
+
+ void *ptr = calloc(1, size);
+ if (ptr == NULL) rb_bug("rb_darray_calloc_mul_add_without_gc: failed");
+
+ return ptr;
+}
+
+void *ruby_xrealloc_sized(void *ptr, size_t new_size, size_t old_size);
+
+/* Internal function. Like rb_xrealloc_mul_add. */
+static inline void *
+rb_darray_realloc_mul_add(void *orig_ptr, size_t capa, size_t element_size, size_t header_size)
+{
+ size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(capa, element_size), header_size);
+ size_t old_size = (rb_darray_capa(orig_ptr) * element_size) + header_size; // We know it won't overflow
+
+ void *ptr = ruby_xrealloc_sized(orig_ptr, size, old_size);
+ RUBY_ASSERT(ptr != NULL);
+
+ return ptr;
+}
+
+/* Internal function. Like rb_xrealloc_mul_add but does not trigger GC. */
+static inline void *
+rb_darray_realloc_mul_add_without_gc(void *orig_ptr, size_t x, size_t y, size_t z)
+{
+ size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(x, y), z);
+
+ void *ptr = realloc(orig_ptr, size);
+ if (ptr == NULL) rb_bug("rb_darray_realloc_mul_add_without_gc: failed");
+
+ return ptr;
+}
+
+/* Internal function. Resizes the capacity of a darray. The new capacity must
+ * be greater than or equal to the size of the darray. */
+static inline void
+rb_darray_resize_capa_impl(void *ptr_to_ary, size_t new_capa, size_t header_size, size_t element_size,
+ void *(*realloc_mul_add_impl)(void *, size_t, size_t, size_t))
+{
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
+ rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
+
+ rb_darray_meta_t *new_ary = realloc_mul_add_impl(meta, new_capa, element_size, header_size);
+
+ if (meta == NULL) {
+ /* First allocation. Initialize size. On subsequence allocations
+ * realloc takes care of carrying over the size. */
+ new_ary->size = 0;
+ }
+
+ RUBY_ASSERT(new_ary->size <= new_capa);
+
+ new_ary->capa = new_capa;
+
+ // We don't have access to the type of the dynamic array in function context.
+ // Write out result with memcpy to avoid strict aliasing issue.
+ memcpy(ptr_to_ary, &new_ary, sizeof(new_ary));
}
// Internal function
// Ensure there is space for one more element.
// Note: header_size can be bigger than sizeof(rb_darray_meta_t) when T is __int128_t, for example.
static inline void
-rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size)
+rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size,
+ void *(*realloc_mul_add_impl)(void *, size_t, size_t, size_t))
{
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
@@ -138,25 +269,12 @@ rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size
// Double the capacity
size_t new_capa = current_capa == 0 ? 1 : current_capa * 2;
- rb_darray_meta_t *doubled_ary = rb_xrealloc_mul_add(meta, new_capa, element_size, header_size);
- // rb_xrealloc functions guarantee that NULL is not returned
- assert(doubled_ary != NULL);
-
- if (meta == NULL) {
- // First allocation. Initialize size. On subsequence allocations
- // realloc takes care of carrying over the size.
- doubled_ary->size = 0;
- }
-
- doubled_ary->capa = new_capa;
-
- // We don't have access to the type of the dynamic array in function context.
- // Write out result with memcpy to avoid strict aliasing issue.
- memcpy(ptr_to_ary, &doubled_ary, sizeof(doubled_ary));
+ rb_darray_resize_capa_impl(ptr_to_ary, new_capa, header_size, element_size, realloc_mul_add_impl);
}
static inline void
-rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size)
+rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size,
+ void *(*calloc_mul_add_impl)(size_t, size_t, size_t))
{
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
if (array_size == 0) {
@@ -164,9 +282,7 @@ rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, siz
return;
}
- rb_darray_meta_t *meta = rb_xcalloc_mul_add(array_size, element_size, header_size);
- // rb_xcalloc functions guarantee that NULL is not returned
- assert(meta != NULL);
+ rb_darray_meta_t *meta = calloc_mul_add_impl(array_size, element_size, header_size);
meta->size = array_size;
meta->capa = array_size;
diff --git a/debug.c b/debug.c
index f1b83714d8..730f860e7a 100644
--- a/debug.c
+++ b/debug.c
@@ -53,16 +53,11 @@ const union {
rb_econv_result_t econv_result;
enum ruby_preserved_encindex encoding_index;
enum ruby_robject_flags robject_flags;
-#if !USE_RVARGC
- enum ruby_robject_consts robject_consts;
-#endif
enum ruby_rmodule_flags rmodule_flags;
enum ruby_rstring_flags rstring_flags;
-#if !USE_RVARGC
- enum ruby_rstring_consts rstring_consts;
-#endif
enum ruby_rarray_flags rarray_flags;
enum ruby_rarray_consts rarray_consts;
+ enum rbimpl_typeddata_flags rtypeddata_consts;
enum {
RUBY_FMODE_READABLE = FMODE_READABLE,
RUBY_FMODE_WRITABLE = FMODE_WRITABLE,
@@ -76,7 +71,7 @@ const union {
RUBY_FMODE_NOREVLOOKUP = 0x00000100,
RUBY_FMODE_TRUNC = FMODE_TRUNC,
RUBY_FMODE_TEXTMODE = FMODE_TEXTMODE,
- RUBY_FMODE_PREP = 0x00010000,
+ RUBY_FMODE_EXTERNAL = 0x00010000,
RUBY_FMODE_SETENC_BY_BOM = FMODE_SETENC_BY_BOM,
RUBY_FMODE_UNIX = 0x00200000,
RUBY_FMODE_INET = 0x00400000,
@@ -153,22 +148,28 @@ 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 (%u)\n", header,
- ruby_node_name(nd_type(node)), nd_line(node));
+ fprintf(stderr, "DBG> %s: %s (id: %d, line: %d, location: (%d,%d)-(%d,%d))\n",
+ header, ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node),
+ nd_first_lineno(node), nd_first_column(node),
+ nd_last_lineno(node), nd_last_column(node));
}
return (NODE *)node;
}
void
+ruby_debug_print_n(const NODE *node)
+{
+ ruby_debug_print_node(0, 1, "", node);
+}
+
+void
ruby_debug_breakpoint(void)
{
/* */
}
#if defined _WIN32
-# if RUBY_MSVCRT_VERSION >= 80
extern int ruby_w32_rtc_error;
-# endif
#endif
#if defined _WIN32 || defined __CYGWIN__
#include <windows.h>
@@ -183,9 +184,9 @@ ruby_env_debug_option(const char *str, int len, void *arg)
int ov;
size_t retlen;
unsigned long n;
+#define NAME_MATCH(name) (len == sizeof(name) - 1 && strncmp(str, (name), len) == 0)
#define SET_WHEN(name, var, val) do { \
- if (len == sizeof(name) - 1 && \
- strncmp(str, (name), len) == 0) { \
+ if (NAME_MATCH(name)) { \
(var) = (val); \
return 1; \
} \
@@ -213,31 +214,29 @@ ruby_env_debug_option(const char *str, int len, void *arg)
--len; \
} \
if (len > 0) { \
- fprintf(stderr, "ignored "name" option: `%.*s'\n", len, str); \
+ fprintf(stderr, "ignored "name" option: '%.*s'\n", len, str); \
} \
} while (0)
#define SET_WHEN_UINT(name, vals, num, req) \
- if (NAME_MATCH_VALUE(name)) SET_UINT_LIST(name, vals, num);
+ if (NAME_MATCH_VALUE(name)) { \
+ if (!len) req; \
+ else SET_UINT_LIST(name, vals, num); \
+ return 1; \
+ }
- SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr, Qtrue);
- SET_WHEN("core", ruby_enable_coredump, 1);
- SET_WHEN("ci", ruby_on_ci, 1);
- if (NAME_MATCH_VALUE("rgengc")) {
- if (!len) ruby_rgengc_debug = 1;
- else SET_UINT_LIST("rgengc", &ruby_rgengc_debug, 1);
+ if (NAME_MATCH("gc_stress")) {
+ rb_gc_initial_stress_set(Qtrue);
return 1;
}
+ SET_WHEN("core", ruby_enable_coredump, 1);
+ SET_WHEN("ci", ruby_on_ci, 1);
+ SET_WHEN_UINT("rgengc", &ruby_rgengc_debug, 1, ruby_rgengc_debug = 1);
#if defined _WIN32
-# if RUBY_MSVCRT_VERSION >= 80
SET_WHEN("rtc_error", ruby_w32_rtc_error, 1);
-# endif
#endif
#if defined _WIN32 || defined __CYGWIN__
- if (NAME_MATCH_VALUE("codepage")) {
- if (!len) fprintf(stderr, "missing codepage argument");
- else SET_UINT_LIST("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage));
- return 1;
- }
+ SET_WHEN_UINT("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage),
+ fprintf(stderr, "missing codepage argument"));
#endif
return 0;
}
@@ -291,12 +290,20 @@ static const char *dlf_type_names[] = {
"func",
};
+#ifdef MAX_PATH
+#define DEBUG_LOG_MAX_PATH (MAX_PATH-1)
+#else
+#define DEBUG_LOG_MAX_PATH 255
+#endif
+
static struct {
char *mem;
unsigned int cnt;
struct debug_log_filter filters[MAX_DEBUG_LOG_FILTER_NUM];
unsigned int filters_num;
+ bool show_pid;
rb_nativethread_lock_t lock;
+ char output_file[DEBUG_LOG_MAX_PATH+1];
FILE *output;
} debug_log;
@@ -361,7 +368,7 @@ setup_debug_log_filter(void)
if (len >= MAX_DEBUG_LOG_FILTER_LEN) {
fprintf(stderr, "too long: %s (max:%d)\n", str, MAX_DEBUG_LOG_FILTER_LEN - 1);
- exit(1);
+ exit(EXIT_FAILURE);
}
// body
@@ -389,7 +396,7 @@ setup_debug_log(void)
debug_log.mem = (char *)malloc(MAX_DEBUG_LOG * MAX_DEBUG_LOG_MESSAGE_LEN);
if (debug_log.mem == NULL) {
fprintf(stderr, "setup_debug_log failed (can't allocate memory)\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
ruby_debug_log_mode |= ruby_debug_log_memory;
}
@@ -398,9 +405,41 @@ setup_debug_log(void)
}
else {
ruby_debug_log_mode |= ruby_debug_log_file;
- if ((debug_log.output = fopen(log_config, "w")) == NULL) {
+
+ // pid extension with %p
+ unsigned long len = strlen(log_config);
+
+ for (unsigned long i=0, j=0; i<len; i++) {
+ const char c = log_config[i];
+
+ if (c == '%') {
+ i++;
+ switch (log_config[i]) {
+ case '%':
+ debug_log.output_file[j++] = '%';
+ break;
+ case 'p':
+ snprintf(debug_log.output_file + j, DEBUG_LOG_MAX_PATH - j, "%d", getpid());
+ j = strlen(debug_log.output_file);
+ break;
+ default:
+ fprintf(stderr, "can not parse RUBY_DEBUG_LOG filename: %s\n", log_config);
+ exit(EXIT_FAILURE);
+ }
+ }
+ else {
+ debug_log.output_file[j++] = c;
+ }
+
+ if (j >= DEBUG_LOG_MAX_PATH) {
+ fprintf(stderr, "RUBY_DEBUG_LOG=%s is too long\n", log_config);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if ((debug_log.output = fopen(debug_log.output_file, "w")) == NULL) {
fprintf(stderr, "can not open %s for RUBY_DEBUG_LOG\n", log_config);
- exit(1);
+ exit(EXIT_FAILURE);
}
setvbuf(debug_log.output, NULL, _IONBF, 0);
}
@@ -409,9 +448,17 @@ setup_debug_log(void)
(ruby_debug_log_mode & ruby_debug_log_memory) ? "[mem]" : "",
(ruby_debug_log_mode & ruby_debug_log_stderr) ? "[stderr]" : "",
(ruby_debug_log_mode & ruby_debug_log_file) ? "[file]" : "");
+ if (debug_log.output_file[0]) {
+ fprintf(stderr, "RUBY_DEBUG_LOG filename=%s\n", debug_log.output_file);
+ }
+
rb_nativethread_lock_initialize(&debug_log.lock);
setup_debug_log_filter();
+
+ if (getenv("RUBY_DEBUG_LOG_PID")) {
+ debug_log.show_pid = true;
+ }
}
}
@@ -507,10 +554,16 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
int len = 0;
int r = 0;
+ if (debug_log.show_pid) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "pid:%d\t", getpid());
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+
// message title
if (func_name && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "%s\t", func_name);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
@@ -529,41 +582,67 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
// C location
if (file && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "\t%s:%d", pretty_filename(file), line);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
- if (rb_current_execution_context(false)) {
- // Ruby location
- int ruby_line;
- const char *ruby_file = rb_source_location_cstr(&ruby_line);
- if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- if (ruby_file) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
- }
- else {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
- }
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
- len += r;
+ rb_execution_context_t *ec = rb_current_execution_context(false);
+
+ // Ruby location
+ int ruby_line;
+ const char *ruby_file = ec ? rb_source_location_cstr(&ruby_line) : NULL;
+
+ if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ if (ruby_file) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
+ }
+ else {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
}
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+
+#ifdef RUBY_NT_SERIAL
+ // native thread information
+ if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tnt:%d", ruby_nt_serial);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+#endif
+
+ if (ec) {
+ rb_thread_t *th = ec ? rb_ec_thread_ptr(ec) : NULL;
// ractor information
if (ruby_single_main_ractor == NULL) {
- rb_ractor_t *cr = GET_RACTOR();
+ rb_ractor_t *cr = th ? th->ractor : NULL;
+ rb_vm_t *vm = GET_VM();
+
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%u/%u",
- (unsigned int)rb_ractor_id(cr), GET_VM()->ractor.cnt);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%d/%u (%u)",
+ cr ? (int)rb_ractor_id(cr) : -1, vm->ractor.cnt, vm->ractor.sched.running_cnt);
+
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}
// thread information
- const rb_thread_t *th = GET_THREAD();
- if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (th && r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ rb_execution_context_t *rec = th->ractor ? th->ractor->threads.running_ec : NULL;
+ const rb_thread_t *rth = rec ? rec->thread_ptr : NULL;
+ const rb_thread_t *sth = th->ractor ? th->ractor->threads.sched.running : NULL;
+
+ if (rth != th || sth != th) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u (rth:%d,sth:%d)",
+ rb_th_serial(th), rth ? (int)rb_th_serial(rth) : -1, sth ? (int)rb_th_serial(sth) : -1);
+ }
+ else {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
+ }
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}
@@ -601,7 +680,7 @@ debug_log_dump(FILE *out, unsigned int n)
int index = current_index - size + i;
if (index < 0) index += MAX_DEBUG_LOG;
VM_ASSERT(index <= MAX_DEBUG_LOG);
- const char *mesg = RUBY_DEBUG_LOG_MEM_ENTRY(index);;
+ const char *mesg = RUBY_DEBUG_LOG_MEM_ENTRY(index);
fprintf(out, "%4u: %s\n", debug_log.cnt - size + i, mesg);
}
}
@@ -630,4 +709,22 @@ ruby_debug_log_dump(const char *fname, unsigned int n)
fclose(fp);
}
}
+
+#else
+
+#undef ruby_debug_log
+void
+ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...)
+{
+ va_list args;
+
+ fprintf(stderr, "[%s:%d] %s: ", file, line, func_name);
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+
+ fprintf(stderr, "\n");
+}
+
#endif // #if USE_RUBY_DEBUG_LOG
diff --git a/debug_counter.h b/debug_counter.h
index f1208d83a8..721ff9d1b8 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -49,7 +49,7 @@ RB_DEBUG_COUNTER(cc_temp) // dummy CC (stack-allocated)
RB_DEBUG_COUNTER(cc_found_in_ccs) // count for CC lookup success in CCS
RB_DEBUG_COUNTER(cc_not_found_in_ccs) // count for CC lookup success in CCS
-RB_DEBUG_COUNTER(cc_ent_invalidate) // count for invalidating cc (cc->klass = 0)
+RB_DEBUG_COUNTER(cc_ent_invalidate) // count for invalidating cc (cc->klass = Qundef)
RB_DEBUG_COUNTER(cc_cme_invalidate) // count for invalidating CME
RB_DEBUG_COUNTER(cc_invalidate_leaf) // count for invalidating klass if klass has no-subclasses
@@ -100,6 +100,13 @@ RB_DEBUG_COUNTER(ccf_opt_block_call)
RB_DEBUG_COUNTER(ccf_opt_struct_aref)
RB_DEBUG_COUNTER(ccf_opt_struct_aset)
RB_DEBUG_COUNTER(ccf_super_method)
+RB_DEBUG_COUNTER(ccf_cfunc_other)
+RB_DEBUG_COUNTER(ccf_cfunc_only_splat)
+RB_DEBUG_COUNTER(ccf_cfunc_only_splat_kw)
+RB_DEBUG_COUNTER(ccf_iseq_bmethod)
+RB_DEBUG_COUNTER(ccf_noniseq_bmethod)
+RB_DEBUG_COUNTER(ccf_opt_send_complex)
+RB_DEBUG_COUNTER(ccf_opt_send_simple)
/*
* control frame push counts.
@@ -207,7 +214,6 @@ RB_DEBUG_COUNTER(gc_isptr_maybe)
* * [attr]
* * _ptr: R?? is not embed.
* * _embed: R?? is embed.
- * * _transient: R?? uses transient heap.
* * type specific attr.
* * str_shared: str is shared.
* * str_nofree: nofree
@@ -233,9 +239,8 @@ RB_DEBUG_COUNTER(obj_promote)
RB_DEBUG_COUNTER(obj_wb_unprotect)
RB_DEBUG_COUNTER(obj_obj_embed)
-RB_DEBUG_COUNTER(obj_obj_transient)
RB_DEBUG_COUNTER(obj_obj_ptr)
-RB_DEBUG_COUNTER(obj_obj_too_complex)
+RB_DEBUG_COUNTER(obj_obj_complex)
RB_DEBUG_COUNTER(obj_str_ptr)
RB_DEBUG_COUNTER(obj_str_embed)
@@ -244,7 +249,6 @@ RB_DEBUG_COUNTER(obj_str_nofree)
RB_DEBUG_COUNTER(obj_str_fstr)
RB_DEBUG_COUNTER(obj_ary_embed)
-RB_DEBUG_COUNTER(obj_ary_transient)
RB_DEBUG_COUNTER(obj_ary_ptr)
RB_DEBUG_COUNTER(obj_ary_extracapa)
/*
@@ -268,11 +272,9 @@ RB_DEBUG_COUNTER(obj_hash_g8)
RB_DEBUG_COUNTER(obj_hash_null)
RB_DEBUG_COUNTER(obj_hash_ar)
RB_DEBUG_COUNTER(obj_hash_st)
-RB_DEBUG_COUNTER(obj_hash_transient)
RB_DEBUG_COUNTER(obj_hash_force_convert)
RB_DEBUG_COUNTER(obj_struct_embed)
-RB_DEBUG_COUNTER(obj_struct_transient)
RB_DEBUG_COUNTER(obj_struct_ptr)
RB_DEBUG_COUNTER(obj_data_empty)
@@ -303,16 +305,21 @@ RB_DEBUG_COUNTER(obj_imemo_ment)
RB_DEBUG_COUNTER(obj_imemo_iseq)
RB_DEBUG_COUNTER(obj_imemo_env)
RB_DEBUG_COUNTER(obj_imemo_tmpbuf)
-RB_DEBUG_COUNTER(obj_imemo_ast)
+RB_DEBUG_COUNTER(obj_imemo_cvar_entry)
RB_DEBUG_COUNTER(obj_imemo_cref)
RB_DEBUG_COUNTER(obj_imemo_svar)
RB_DEBUG_COUNTER(obj_imemo_throw_data)
RB_DEBUG_COUNTER(obj_imemo_ifunc)
RB_DEBUG_COUNTER(obj_imemo_memo)
-RB_DEBUG_COUNTER(obj_imemo_parser_strterm)
RB_DEBUG_COUNTER(obj_imemo_callinfo)
RB_DEBUG_COUNTER(obj_imemo_callcache)
RB_DEBUG_COUNTER(obj_imemo_constcache)
+RB_DEBUG_COUNTER(obj_imemo_fields)
+RB_DEBUG_COUNTER(obj_imemo_subclasses)
+RB_DEBUG_COUNTER(obj_imemo_cdhash)
+
+RB_DEBUG_COUNTER(opt_new_hit)
+RB_DEBUG_COUNTER(opt_new_miss)
/* ar_table */
RB_DEBUG_COUNTER(artable_hint_hit)
@@ -327,11 +334,6 @@ RB_DEBUG_COUNTER(heap_xmalloc)
RB_DEBUG_COUNTER(heap_xrealloc)
RB_DEBUG_COUNTER(heap_xfree)
-/* transient_heap */
-RB_DEBUG_COUNTER(theap_alloc)
-RB_DEBUG_COUNTER(theap_alloc_fail)
-RB_DEBUG_COUNTER(theap_evacuate)
-
// VM sync
RB_DEBUG_COUNTER(vm_sync_lock)
RB_DEBUG_COUNTER(vm_sync_lock_enter)
@@ -359,7 +361,7 @@ RB_DEBUG_COUNTER(load_path_is_not_realpath)
enum rb_debug_counter_type {
#define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
-#include __FILE__
+#include "debug_counter.h"
RB_DEBUG_COUNTER_MAX
#undef RB_DEBUG_COUNTER
};
diff --git a/defs/gmake.mk b/defs/gmake.mk
index c978af38f2..0320f9b7d5 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -1,20 +1,20 @@
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
reconfig config.status: export MAKE:=$(MAKE)
+export BASERUBY:=$(BASERUBY)
+export GIT
override gnumake_recursive := $(if $(findstring n,$(firstword $(MFLAGS))),,+)
override mflags := $(filter-out -j%,$(MFLAGS))
MSPECOPT += $(if $(filter -j%,$(MFLAGS)),-j)
nproc = $(subst -j,,$(filter -j%,$(MFLAGS)))
ifeq ($(GITHUB_ACTIONS),true)
-override ACTIONS_GROUP = @echo "\#\#[group]$(patsubst yes-%,%,$@)"
-override ACTIONS_ENDGROUP = @echo "\#\#[endgroup]"
+# 93(bright yellow) is copied from .github/workflows/mingw.yml
+override ACTIONS_GROUP = @echo "::group::$(@:yes-%=%)"
+override ACTIONS_ENDGROUP = @echo "::endgroup::"
endif
ifneq ($(filter darwin%,$(target_os)),)
-# Remove debug option not to generate thousands of .dSYM
-RJIT_DEBUGFLAGS := $(filter-out -g%,$(RJIT_DEBUGFLAGS))
-
INSTRUBY_ENV += SDKROOT=
endif
INSTRUBY_ARGS += --gnumake
@@ -26,7 +26,7 @@ TEST_TARGETS := $(filter $(CHECK_TARGETS),$(MAKECMDGOALS))
TEST_DEPENDS := $(filter-out commit $(TEST_TARGETS),$(MAKECMDGOALS))
TEST_TARGETS := $(patsubst great,exam,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out great $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst exam,test-bundled-gems yes-test-bundler-parallel check,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst exam,test-bundled-gems test-bundler-parallel check,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst check,test-syntax-suggest test-spec test-all test-tool test-short,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-rubyspec,test-spec,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out exam check test-spec $(TEST_TARGETS),$(TEST_DEPENDS))
@@ -37,13 +37,15 @@ TEST_DEPENDS := $(filter-out test-all $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_TARGETS := $(patsubst test,test-short,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out test $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_TARGETS := $(patsubst test-short,btest-ruby test-knownbug test-basic,$(TEST_TARGETS))
-TEST_TARGETS := $(patsubst test-bundled-gems,test-bundled-gems-run,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst test-basic,test-basic test-leaked-globals,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst test-bundled-gems,test-bundled-gems-spec test-bundled-gems-run,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundled-gems-run,test-bundled-gems-run $(PREPARE_BUNDLED_GEMS),$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundled-gems-prepare,test-bundled-gems-prepare $(PRECHECK_BUNDLED_GEMS) test-bundled-gems-fetch,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundler-parallel,test-bundler-parallel $(PREPARE_BUNDLER),$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-syntax-suggest,test-syntax-suggest $(PREPARE_SYNTAX_SUGGEST),$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out test-short $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_DEPENDS += $(if $(filter great exam love check,$(MAKECMDGOALS)),all exts)
+TEST_TARGETS := $(patsubst yes-%,%,$(filter-out no-%,$(TEST_TARGETS)))
endif
in-srcdir := $(if $(filter-out .,$(srcdir)),$(CHDIR) $(srcdir) &&)
@@ -78,7 +80,7 @@ define archcmd
%.i: %.$(1).i
endef
-$(foreach arch,$(arch_flags),\
+$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
endif
@@ -90,16 +92,32 @@ $(addprefix yes-,$(TEST_TARGETS)): $(TEST_DEPENDS)
endif
ORDERED_TEST_TARGETS := $(filter $(TEST_TARGETS), \
- btest-ruby test-knownbug test-basic \
+ btest-ruby test-knownbug test-leaked-globals test-basic \
test-testframework test-tool test-ruby test-all \
test-spec test-syntax-suggest-prepare test-syntax-suggest \
test-bundler-prepare test-bundler test-bundler-parallel \
test-bundled-gems-precheck test-bundled-gems-fetch \
test-bundled-gems-prepare test-bundled-gems-run \
+ test-bundled-gems-spec \
+ )
+
+# grep ^yes-test-.*-precheck: template/Makefile.in defs/gmake.mk common.mk
+test_prechecks := $(filter $(ORDERED_TEST_TARGETS),\
+ test-leaked-globals \
+ test-all \
+ test-spec \
+ test-syntax-suggest \
+ test-bundler \
+ test-bundler-parallel \
+ test-bundled-gems\
)
-prev_test := $(if $(filter test-spec,$(ORDERED_TEST_TARGETS)),test-spec-precheck)
+prev_test := $(subst test-bundler-parallel,test-bundler,$(test_prechecks))
+prev_test := $(addsuffix -precheck,$(prev_test))
+first_test_prechecks := $(prev_test)
+
$(foreach test,$(ORDERED_TEST_TARGETS), \
- $(eval yes-$(value test) no-$(value test): $(value prev_test)); \
+ $(eval yes-$(value test): $(addprefix yes-,$(value prev_test))); \
+ $(eval no-$(value test): $(addprefix no-,$(value prev_test))); \
$(eval prev_test := $(value test)))
endif
@@ -144,6 +162,10 @@ endif
config.status: $(wildcard config.cache)
+ifneq (ruby,$(PROGRAM))
+ruby: $(PROGRAM);
+endif
+
STUBPROGRAM = rubystub$(EXEEXT)
IGNOREDPATTERNS = %~ .% %.orig %.rej \#%\#
SCRIPTBINDIR := $(if $(EXEEXT),,exec/)
@@ -177,23 +199,30 @@ $(SCRIPTBINDIR):
$(Q) mkdir $@
.PHONY: commit
-commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) up
+COMMIT_PREPARE := $(subst :,\:,$(filter-out commit do-commit,$(MAKECMDGOALS))) up
+
+commit: pre-commit $(DOT_WAIT) do-commit $(DOT_WAIT) post_commit
+pre-commit: $(COMMIT_PREPARE)
+do-commit: $(if $(DOT_WAIT),,pre-commit)
@$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit'
+post-commit: $(if $(DOT_WAIT),,do-commit)
+$(Q) \
{ \
$(in-srcdir) \
- exec sed -f tool/prereq.status defs/gmake.mk template/Makefile.in common.mk; \
+ exec sed -f tool/prereq.status defs/gmake.mk template/Makefile.in common.mk depend; \
} | \
- $(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
- BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" \
+ $(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) \
+ top_srcdir="$(top_srcdir)" srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
+ BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" BOOTSTRAPRUBY_OPT="$(BOOTSTRAPRUBY_OPT)" \
+ MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" HAVE_BASERUBY="$(HAVE_BASERUBY)" \
VCSUP="" ENC_MK=.top-enc.mk REVISION_FORCE=PHONY CONFIGURE="$(CONFIGURE)" -f - \
update-src srcs all-incs
GITHUB_RUBY_URL = https://github.com/ruby/ruby
PR =
-COMMIT_GPG_SIGN = $(shell $(GIT) -C "$(srcdir)" config commit.gpgsign)
-REMOTE_GITHUB_URL = $(shell $(GIT) -C "$(srcdir)" config remote.github.url)
+COMMIT_GPG_SIGN = $(shell $(GIT_IN_SRC) config commit.gpgsign)
+REMOTE_GITHUB_URL = $(shell $(GIT_IN_SRC) config remote.github.url)
COMMITS_NOTES = commits
.PHONY: fetch-github
@@ -208,19 +237,19 @@ define fetch-github
$(eval REMOTE_GITHUB_URL := $(REMOTE_GITHUB_URL))
$(if $(REMOTE_GITHUB_URL),,
echo adding $(GITHUB_RUBY_URL) as remote github
- $(GIT) -C "$(srcdir)" remote add github $(GITHUB_RUBY_URL)
- $(GIT) -C "$(srcdir)" config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
+ $(GIT_IN_SRC) remote add github $(GITHUB_RUBY_URL)
+ $(GIT_IN_SRC) config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
$(eval REMOTE_GITHUB_URL := $(GITHUB_RUBY_URL))
)
- $(if $(shell $(GIT) -C "$(srcdir)" rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
- $(GIT) -C "$(srcdir)" branch -f "gh-$(1)" "github/pull/$(1)/head",
- $(GIT) -C "$(srcdir)" fetch -f github "pull/$(1)/head:gh-$(1)"
+ $(if $(shell $(GIT_IN_SRC) rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
+ $(GIT_IN_SRC) branch -f "gh-$(1)" "github/pull/$(1)/head",
+ $(GIT_IN_SRC) fetch -f github "pull/$(1)/head:gh-$(1)"
)
endef
.PHONY: checkout-github
checkout-github: fetch-github
- $(GIT) -C "$(srcdir)" checkout "gh-$(PR)"
+ $(GIT_IN_SRC) checkout "gh-$(PR)"
.PHONY: update-github
update-github: fetch-github
@@ -233,25 +262,25 @@ update-github: fetch-github
$(eval PR_BRANCH := $(word 2,$(PULL_REQUEST_FORK_BRANCH)))
$(eval GITHUB_UPDATE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(PR)-XXXXXX"))
- $(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
+ $(GIT_IN_SRC) worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" merge master --no-edit
@$(BASERUBY) -e 'print "Are you sure to push this to PR=$(PR)? [Y/n]: "; exit(gets.chomp != "n")'
- $(GIT) -C "$(srcdir)" remote add fork-$(PR) git@github.com:$(FORK_REPO).git
+ $(GIT_IN_SRC) remote add fork-$(PR) git@github.com:$(FORK_REPO).git
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" push fork-$(PR) gh-$(PR):$(PR_BRANCH)
- $(GIT) -C "$(srcdir)" remote rm fork-$(PR)
- $(GIT) -C "$(srcdir)" worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
- $(GIT) -C "$(srcdir)" branch -D gh-$(PR)
+ $(GIT_IN_SRC) remote rm fork-$(PR)
+ $(GIT_IN_SRC) worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
+ $(GIT_IN_SRC) branch -D gh-$(PR)
.PHONY: pull-github
pull-github: fetch-github
$(call pull-github,$(PR))
define pull-github
- $(eval GITHUB_MERGE_BASE := $(shell $(GIT) -C "$(srcdir)" log -1 --format=format:%H))
- $(eval GITHUB_MERGE_BRANCH := $(shell $(GIT) -C "$(srcdir)" symbolic-ref --short HEAD))
+ $(eval GITHUB_MERGE_BASE := $(shell $(GIT_IN_SRC) rev-parse HEAD)
+ $(eval GITHUB_MERGE_BRANCH := $(shell $(GIT_IN_SRC) symbolic-ref --short HEAD))
$(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX"))
- $(GIT) -C "$(srcdir)" worktree prune
- $(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
+ $(GIT_IN_SRC) worktree prune
+ $(GIT_IN_SRC) worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
$(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN))
$(if $(filter true,$(COMMIT_GPG_SIGN)), \
@@ -266,7 +295,7 @@ fetch-github-%:
.PHONY: checkout-github-%
checkout-github-%: fetch-github-%
- $(GIT) -C "$(srcdir)" checkout "gh-$*"
+ $(GIT_IN_SRC) checkout "gh-$*"
.PHONY: pr-% pull-github-%
pr-% pull-github-%: fetch-github-%
@@ -285,7 +314,7 @@ HELP_EXTRA_TASKS = \
# 4. "gem x.y.z URL" -> "gem-x.y.z"
bundled-gems := $(shell sed \
-e 's/[ ][ ]*/ /g' \
- -e 's/^ //;/\#/d;s/ *$$//;/^$$/d' \
+ -e 's/^ //;s/\#.*//;s/ *$$//;/^$$/d' \
$(if $(filter yes,$(HAVE_GIT)), \
-e 's/^\(.*\) \(.*\) \(.*\) \(.*\)/\1|\2|\4|\3/' \
) \
@@ -303,6 +332,7 @@ foreach-bundled-gems-rev-0 = \
bundled-gem-gemfile = $(srcdir)/gems/$(1)-$(2).gem
bundled-gem-gemspec = $(srcdir)/gems/src/$(1)/$(1).gemspec
bundled-gem-extracted = $(srcdir)/.bundle/gems/$(1)-$(2)
+bundled-gem-revision = $(srcdir)/.bundle/.timestamp/$(1).revision
update-gems: | $(patsubst %,$(srcdir)/gems/%.gem,$(bundled-gems))
update-gems: | $(call foreach-bundled-gems-rev,bundled-gem-gemfile)
@@ -340,26 +370,27 @@ $(srcdir)/.bundle/.timestamp:
define build-gem
$(srcdir)/gems/src/$(1)/.git: | $(srcdir)/gems/src
$(ECHO) Cloning $(4)
- $(Q) $(GIT) clone $(4) $$(@D)
+ $(Q) $(GIT) clone --depth=1 --no-tags $(4) $$(@D)
-$(srcdir)/.bundle/.timestamp/$(1).revision: \
+$(bundled-gem-revision): \
$(if $(if $(wildcard $$(@)),$(filter $(3),$(shell cat $$(@)))),,PHONY) \
| $(srcdir)/.bundle/.timestamp $(srcdir)/gems/src/$(1)/.git
$(ECHO) Update $(1) to $(3)
$(Q) $(CHDIR) "$(srcdir)/gems/src/$(1)" && \
- $(GIT) fetch origin $(3) && \
- $(GIT) checkout --detach $(3) && \
- :
+ if [ `$(GIT) rev-parse HEAD` != $(3) ]; then \
+ $(GIT) fetch origin $(3) && \
+ $(GIT) checkout --detach $(3) && \
+ :; \
+ fi
echo $(3) | $(IFCHANGE) $$(@) -
# The repository of minitest does not include minitest.gemspec because it uses hoe.
# This creates a dummy gemspec.
-$(srcdir)/gems/src/$(1)/$(1).gemspec: $(srcdir)/.bundle/.timestamp/$(1).revision \
+$(bundled-gem-gemspec): $(bundled-gem-revision) \
| $(srcdir)/gems/src/$(1)/.git
$(Q) $(BASERUBY) -I$(tooldir)/lib -rbundled_gem -e 'BundledGem.dummy_gemspec(*ARGV)' $$(@)
-$(srcdir)/gems/$(1)-$(2).gem: $(srcdir)/gems/src/$(1)/$(1).gemspec \
- $(srcdir)/.bundle/.timestamp/$(1).revision
+$(bundled-gem-gemfile): $(bundled-gem-gemspec) $(bundled-gem-revision)
$(ECHO) Building $(1)@$(3) to $$(@)
$(Q) $(BASERUBY) -C "$(srcdir)" \
-Itool/lib -rbundled_gem \
@@ -380,6 +411,7 @@ $(srcdir)/.bundle/gems:
ifneq ($(DOT_WAIT),)
up:: $(DOT_WAIT) after-update
+after-update:: MINIRUBY = $(BASERUBY)
endif
ifneq ($(filter update-bundled_gems refresh-gems,$(MAKECMDGOALS)),)
@@ -391,8 +423,19 @@ endif
.SECONDARY: update-unicode-ucd-emoji-files
.SECONDARY: update-unicode-emoji-files
+ifneq ($(DOT_WAIT),)
+.NOTPARALLEL: update-unicode
+.NOTPARALLEL: update-unicode-files
+.NOTPARALLEL: update-unicode-auxiliary-files
+.NOTPARALLEL: update-unicode-ucd-emoji-files
+.NOTPARALLEL: update-unicode-emoji-files
+.NOTPARALLEL: $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
+.NOTPARALLEL: $(UNICODE_AUXILIARY_FILES)
+.NOTPARALLEL: $(UNICODE_UCD_EMOJI_FILES) $(UNICODE_EMOJI_FILES)
+endif
+
ifeq ($(HAVE_GIT),yes)
-REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && $(GIT) log -1 --format=%H 2>/dev/null)
+REVISION_LATEST := $(shell $(GIT_IN_SRC) rev-parse HEAD 2>/dev/null)
else
REVISION_LATEST := update
endif
@@ -405,12 +448,16 @@ $(REVISION_H): PHONY
endif
include $(top_srcdir)/yjit/yjit.mk
+include $(top_srcdir)/zjit/zjit.mk
+include $(top_srcdir)/defs/jit.mk
# Query on the generated rdoc
#
# $ make rdoc:Integer#+
-rdoc\:%: PHONY
- $(Q)$(RUNRUBY) $(srcdir)/libexec/ri --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@)
+rdoc\:%: PHONY programs $(RDOCOUT) update-default-gemspecs
+ $(Q)$(RUNRUBY) $(RUNOPT0) -I$(tooldir)/lib -rbundled_gem \
+ -e "load BundledGem.command('rdoc', 'ri')" -- \
+ --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@)
test_%.rb test/%: programs PHONY
$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@)
@@ -433,6 +480,10 @@ benchmark/%: miniruby$(EXEEXT) update-benchmark-driver PHONY
--executables="built-ruby::$(BENCH_RUBY) --disable-gem" \
$(srcdir)/$@ $(BENCH_OPTS) $(OPTS)
+clean-local:: TARGET_SO = $(PROGRAM) $(WPROGRAM) $(LIBRUBY_SO) $(STATIC_RUBY) miniruby goruby
+clean-local::
+ -$(Q)$(RMALL) $(cleanlibs)
+
clean-srcs-ext::
$(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXT_SRCS))
@@ -448,7 +499,7 @@ endif
update-deps:
$(eval update_deps := $(shell date +update-deps-%Y%m%d))
$(eval deps_dir := $(shell mktemp -d)/$(update_deps))
- $(eval GIT_DIR := $(shell $(GIT) -C $(srcdir) rev-parse --absolute-git-dir))
+ $(eval GIT_DIR := $(shell $(GIT_IN_SRC) rev-parse --absolute-git-dir))
$(GIT) --git-dir=$(GIT_DIR) worktree add $(deps_dir)
cp $(tooldir)/config.guess $(tooldir)/config.sub $(deps_dir)/tool
[ -f config.status ] && cp config.status $(deps_dir)
@@ -462,35 +513,114 @@ update-deps:
$(GIT) --git-dir=$(GIT_DIR) merge --no-edit --ff-only $(update_deps)
$(GIT) --git-dir=$(GIT_DIR) branch --delete $(update_deps)
+fix-depends check-depends: all hello
+ $(BASERUBY) -C $(srcdir) tool/update-deps $(if $(filter fix-%,$@),--fix)
+
# order-only-prerequisites doesn't work for $(RUBYSPEC_CAPIEXT)
# because the same named directory exists in the source tree.
-$(RUBYSPEC_CAPIEXT)/%.$(DLEXT): $(srcdir)/$(RUBYSPEC_CAPIEXT)/%.c $(srcdir)/$(RUBYSPEC_CAPIEXT)/rubyspec.h $(RUBY_H_INCLUDES) $(LIBRUBY)
- $(ECHO) building $@
+$(RUBYSPEC_CAPIEXT)/%.$(DLEXT): $(srcdir)/$(RUBYSPEC_CAPIEXT)/%.c $(RUBYSPEC_CAPIEXT_DEPS) \
+ | build-ext yes-rubyspec-capiext
+ $(no_silence:no=$(ECHO) building $@)
$(Q) $(MAKEDIRS) $(@D)
$(Q) $(DLDSHARED) -L. $(XDLDFLAGS) $(XLDFLAGS) $(LDFLAGS) $(INCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ $< $(LIBRUBYARG)
+ifneq ($(POSTLINK),)
+ $(Q) $(POSTLINK)
+endif
$(Q) $(RMALL) $@.*
-rubyspec-capiext: $(patsubst %.c,$(RUBYSPEC_CAPIEXT)/%.$(DLEXT),$(notdir $(wildcard $(srcdir)/$(RUBYSPEC_CAPIEXT)/*.c)))
- @ $(NULLCMD)
-
-ifeq ($(ENABLE_SHARED),yes)
-exts: rubyspec-capiext
-endif
+RUBYSPEC_CAPIEXT_EXTS := $(patsubst %.c,$(RUBYSPEC_CAPIEXT)/%.$(DLEXT),$(notdir $(wildcard $(srcdir)/$(RUBYSPEC_CAPIEXT)/*.c)))
+rubyspec-capiext: $(RUBYSPEC_CAPIEXT_EXTS)
-spec/%/ spec/%_spec.rb: programs exts PHONY
+spec/%/ spec/%_spec.rb: programs exts $(RUBYSPEC_CAPIEXT_BUILD) PHONY
+$(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec-run -B $(srcdir)/spec/default.mspec $(SPECOPTS) $(patsubst %,$(srcdir)/%,$@)
ruby.pc: $(filter-out ruby.pc,$(ruby_pc))
+# `make matz`: bump up the MINOR;
+# Copying NEWS.md to doc/NEWS/, and empty the details in NEWS.md.
+#
+# `make matz NEW=x.y`: bump up to x.y.0;
+# Just update the version in the title of NEWS.md.
+
matz: up
- $(eval MINOR := $(shell expr $(MINOR) + 1))
- $(eval message := Development of $(MAJOR).$(MINOR).0 started.)
- $(eval files := include/ruby/version.h include/ruby/internal/abi.h)
+matz-commit: OLD := $(MAJOR).$(MINOR).0
+ifdef NEW
+matz-commit: MAJOR := $(word 1,$(subst ., ,$(NEW)))
+matz-commit: MINOR := $(word 2,$(subst ., ,$(NEW)))
+matz-commit: $(DOT_WAIT) bump_news
+bump_news$(DOT_WAIT): up
+bump_headers$(DOT_WAIT): bump_news
+else
+matz-commit: MINOR := $(shell expr $(MINOR) + 1)
+matz-commit: $(DOT_WAIT) reset_news
+flush_news$(DOT_WAIT): up
+bump_headers$(DOT_WAIT): reset_news
+endif
+
+matz: $(DOT_WAIT) matz-commit
+matz-commit: bump_headers
+matz-commit: override NEW := $(MAJOR).$(MINOR).0
+matz-commit: files := include/ruby/version.h include/ruby/internal/abi.h
+matz-commit: message := Development of $(NEW) started.
+
+flush_news:
+ $(GIT_IN_SRC) mv -f NEWS.md doc/NEWS/NEWS-$(OLD).md
+ $(GIT_IN_SRC) commit -m "[DOC] Flush NEWS.md"
+
+.PHONY: flush_news reset_news bump_news bump_headers
+
+bump_headers:
sed -i~ \
+ -e "s/^\(#define RUBY_API_VERSION_MAJOR\) .*/\1 $(MAJOR)/" \
-e "s/^\(#define RUBY_API_VERSION_MINOR\) .*/\1 $(MINOR)/" \
-e "s/^\(#define RUBY_ABI_VERSION\) .*/\1 0/" \
$(files:%=$(srcdir)/%)
- $(GIT) -C $(srcdir) commit -m "$(message)" $(files)
+
+reset_news: flush_news
+ $(BASERUBY) -C $(srcdir) -p -00 \
+ -e 'BEGIN {old, new = ARGV.shift(2); STDOUT.reopen(ARGV.shift)}' \
+ -e 'case $$.' \
+ -e 'when 1; $$_.sub!(/Ruby \K[0-9.]+/, new)' \
+ -e 'when 2; $$_.sub!(/\*\*\K[0-9.]+(?=\*\*)/, old)' \
+ -e 'end' \
+ -e 'next if /^[\[ *]/ =~ $$_' \
+ -e '$$_.sub!(/\n{2,}\z/, "\n\n")' \
+ $(OLD) $(NEW) NEWS.md doc/NEWS/NEWS-$(OLD).md
+
+bump_news:
+ $(BASERUBY) -C $(srcdir) -p -i \
+ -e 'BEGIN {new = ARGV.shift; print gets("").sub(/Ruby \K[0-9.]+/, new)}' \
+ $(NEW) NEWS.md
+
+matz: matz-commit matz-push
+
+matz-commit:
+ $(GIT_IN_SRC) add NEWS.md $(files)
+ $(GIT_IN_SRC) commit -m "$(message)"
+
+GIT_REMOTE_ORIGIN = origin
+
+matz-push: matz-commit
+ $(eval origin_url := $(shell $(GIT_IN_SRC) remote get-url $(GIT_REMOTE_ORIGIN)))
+ $(if $(origin_url),,@false)
+ $(eval last_commit := $(shell $(GIT_IN_SRC) log -n1 --format=%H --author=matz HEAD~..HEAD))
+ $(if $(last_commit),,$(ECHO) No matz commits 1>&2; false)
+ $(if $(filter 12-25 12-26,$(shell date +%m-%d)),,$(ECHO) Not the release date 1>&2; false)
+ $(ECHO) $$'\e[31m'Pushing to $$'\e[7m'$(GIT_REMOTE_ORIGIN)$$'\e[27m'" ($(origin_url))"$$'\e[m'
+ $(GIT_IN_SRC) push $(GIT_REMOTE_ORIGIN)
tags:
$(MAKE) GIT="$(GIT)" -C "$(srcdir)" -f defs/tags.mk
+
+
+# ripper_srcs makes all sources at once. invoking this target multiple
+# times in parallel means all sources will be built for the number of
+# sources times respectively.
+ifneq ($(DOT_WAIT),)
+.NOTPARALLEL: ripper_srcs
+else
+ripper_src =
+$(foreach r,$(RIPPER_SRCS),$(eval $(value r): | $(value ripper_src))\
+ $(eval ripper_src := $(value r)))
+ripper_srcs: $(ripper_src)
+endif
diff --git a/defs/id.def b/defs/id.def
index c8d7b6af3e..344b072e76 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -2,11 +2,13 @@
firstline, predefined = __LINE__+1, %[\
max
min
+ hash
freeze
nil?
inspect
intern
object_id
+ __id__
const_added
const_missing
method_missing MethodMissing
@@ -26,6 +28,7 @@ firstline, predefined = __LINE__+1, %[\
send
__send__
__recursive_key__
+ clone
initialize
initialize_copy
initialize_clone
@@ -58,6 +61,11 @@ firstline, predefined = __LINE__+1, %[\
name
nil
path
+ pack
+ buffer
+ include?
+ aborted
+ exited
_ UScore
@@ -71,6 +79,8 @@ firstline, predefined = __LINE__+1, %[\
_7 NUMPARAM_7
_8 NUMPARAM_8
_9 NUMPARAM_9
+ <it> ItImplicit
+ it It
"/*NULL*/" NULL
empty?
@@ -96,6 +106,8 @@ firstline, predefined = __LINE__+1, %[\
$_ LASTLINE
$~ BACKREF
$! ERROR_INFO
+
+ Ruby
]
# VM ID OP Parser Token
diff --git a/defs/jit.mk b/defs/jit.mk
new file mode 100644
index 0000000000..2c1e819684
--- /dev/null
+++ b/defs/jit.mk
@@ -0,0 +1,107 @@
+# Make recipes that deal with the rust code of YJIT and ZJIT.
+#
+# $(gnumake_recursive) adds the '+' prefix to pass down GNU make's
+# jobserver resources to cargo/rustc as rust-lang.org recommends.
+# Without it, certain make version trigger a warning. It does not
+# add the prefix when `make --dry-run` so dry runs are indeed dry.
+
+ifneq ($(JIT_CARGO_SUPPORT),no)
+
+# Show Cargo progress when doing `make V=1`
+CARGO_VERBOSE_0 = -q
+CARGO_VERBOSE_1 =
+CARGO_VERBOSE = $(CARGO_VERBOSE_$(V))
+
+# Because of Cargo cache, if the actual binary is not changed from the
+# previous build, the mtime is preserved as the cached file.
+# This means the target is not updated actually, and it will need to
+# rebuild at the next build.
+RUST_LIB_TOUCH = touch $@
+
+# NOTE: MACOSX_DEPLOYMENT_TARGET to match `rustc --print deployment-target` to avoid the warning below.
+# ld: warning: object file (target/debug/libjit.a(<libcapstone object>)) was built for
+# newer macOS version (15.2) than being linked (15.0)
+# This limits us to an older set of macOS API in the rust code, but we don't use any.
+$(RUST_LIB): $(srcdir)/ruby.rs target/.rustc-version
+ $(Q)if [ '$(ZJIT_SUPPORT)' != no -a '$(YJIT_SUPPORT)' != no ]; then \
+ echo 'building YJIT and ZJIT ($(JIT_CARGO_SUPPORT:yes=release) mode)'; \
+ elif [ '$(ZJIT_SUPPORT)' != no ]; then \
+ echo 'building ZJIT ($(JIT_CARGO_SUPPORT) mode)'; \
+ elif [ '$(YJIT_SUPPORT)' != no ]; then \
+ echo 'building YJIT ($(JIT_CARGO_SUPPORT) mode)'; \
+ fi
+ $(gnumake_recursive)$(Q)CARGO_TARGET_DIR='$(CARGO_TARGET_DIR)' \
+ CARGO_TERM_PROGRESS_WHEN='never' \
+ MACOSX_DEPLOYMENT_TARGET=11.0 \
+ $(CARGO) $(CARGO_VERBOSE) build --manifest-path '$(top_srcdir)/Cargo.toml' $(CARGO_BUILD_ARGS)
+ $(RUST_LIB_TOUCH)
+else ifneq ($(strip $(RLIB_DIR)),) # combo build
+
+$(RUST_LIB): $(srcdir)/ruby.rs target/.rustc-version
+ $(ECHO) 'building $(@F)'
+ $(gnumake_recursive)$(Q) $(RUSTC) --edition=2024 \
+ $(RUSTC_FLAGS) \
+ '-L$(@D)' \
+ --extern=yjit \
+ --extern=zjit \
+ --crate-type=staticlib \
+ --cfg 'feature="yjit"' \
+ --cfg 'feature="zjit"' \
+ '--out-dir=$(@D)' \
+ '$(top_srcdir)/ruby.rs'
+
+# Absolute path to avoid VPATH ambiguity
+JIT_RLIB = $(TOP_BUILD_DIR)/$(RLIB_DIR)/libjit.rlib
+$(YJIT_RLIB): $(JIT_RLIB)
+$(ZJIT_RLIB): $(JIT_RLIB)
+$(JIT_RLIB): target/.rustc-version
+ $(ECHO) 'building $(@F)'
+ $(gnumake_recursive)$(Q) $(RUSTC) --crate-name=jit \
+ --edition=2024 \
+ $(JIT_RUST_FLAGS) \
+ $(RUSTC_FLAGS) \
+ '--out-dir=$(@D)' \
+ '$(top_srcdir)/jit/src/lib.rs'
+endif # ifneq ($(JIT_CARGO_SUPPORT),no)
+
+RUST_LIB_SYMBOLS = $(RUST_LIB:.a=).symbols
+$(RUST_LIBOBJ): $(RUST_LIB)
+ $(ECHO) 'partial linking $(RUST_LIB) into $@'
+ifneq ($(findstring darwin,$(target_os)),)
+ $(Q) $(CC) -nodefaultlibs -r -o $@ -exported_symbols_list $(RUST_LIB_SYMBOLS) $(RUST_LIB)
+else
+ $(Q) $(LD) -r -o $@ --whole-archive $(RUST_LIB)
+ -$(Q) $(OBJCOPY) --wildcard --keep-global-symbol='$(SYMBOL_PREFIX)rb_*' $(@)
+endif
+
+rust-libobj: $(RUST_LIBOBJ)
+rust-lib: $(RUST_LIB)
+
+rustc-version-check: target/.rustc-version
+
+target/.rustc-version: PHONY
+ $(eval prev_version := $(if $(wildcard $@),$(shell cat $@)))
+ $(eval curr_version := $(shell $(RUSTC) -V | cut -d' ' -f2))
+ $(eval clean := $(filter-out $(prev_version),$(curr_version)))
+ $(if $(clean),$(ECHO) Cleaning $(@D) for rustc $(curr_version))
+ $(if $(clean),$(Q)$(RMALL) $(@D))
+ $(if $(clean),$(Q)$(MAKEDIRS) $(@D))
+ $(if $(clean),$(Q)echo $(curr_version) > $@)
+
+# For Darwin only: a list of symbols that we want the glommed Rust static lib to export.
+# Unfortunately, using wildcard like '_rb_*' with -exported-symbol does not work, at least
+# not on version 820.1. Assume llvm-nm, so XCode 8.0 (from 2016) or newer.
+#
+# The -exported_symbols_list pulls out the right archive members. Symbols not listed
+# in the list are made private extern, which are in turn made local as we're using `ld -r`.
+# Note, section about -keep_private_externs in ld's man page hints at this behavior on which
+# we rely.
+ifneq ($(findstring darwin,$(target_os)),)
+$(RUST_LIB_SYMBOLS): $(RUST_LIB)
+ $(Q) $(tooldir)/darwin-ar $(NM) --defined-only --extern-only $(RUST_LIB) | \
+ sed -n -e 's/.* //' -e '/^$(SYMBOL_PREFIX)rb_/p' \
+ -e '/^$(SYMBOL_PREFIX)rust_eh_personality/p' \
+ > $@
+
+$(RUST_LIBOBJ): $(RUST_LIB_SYMBOLS)
+endif
diff --git a/defs/known_errors.def b/defs/known_errors.def
index e9694cfbda..23e9e53507 100644
--- a/defs/known_errors.def
+++ b/defs/known_errors.def
@@ -1,157 +1,157 @@
-E2BIG
-EACCES
-EADDRINUSE
-EADDRNOTAVAIL
-EADV
-EAFNOSUPPORT
-EAGAIN
-EALREADY
-EAUTH
-EBADARCH
-EBADE
-EBADEXEC
-EBADF
-EBADFD
-EBADMACHO
-EBADMSG
-EBADR
-EBADRPC
-EBADRQC
-EBADSLT
-EBFONT
-EBUSY
-ECANCELED
-ECAPMODE
-ECHILD
-ECHRNG
-ECOMM
-ECONNABORTED
-ECONNREFUSED
-ECONNRESET
-EDEADLK
-EDEADLOCK
-EDESTADDRREQ
-EDEVERR
-EDOM
-EDOOFUS
-EDOTDOT
-EDQUOT
-EEXIST
-EFAULT
-EFBIG
-EFTYPE
-EHOSTDOWN
-EHOSTUNREACH
-EHWPOISON
-EIDRM
-EILSEQ
-EINPROGRESS
-EINTR
-EINVAL
-EIO
-EIPSEC
-EISCONN
-EISDIR
-EISNAM
-EKEYEXPIRED
-EKEYREJECTED
-EKEYREVOKED
-EL2HLT
-EL2NSYNC
-EL3HLT
-EL3RST
-ELAST
-ELIBACC
-ELIBBAD
-ELIBEXEC
-ELIBMAX
-ELIBSCN
-ELNRNG
-ELOOP
-EMEDIUMTYPE
-EMFILE
-EMLINK
-EMSGSIZE
-EMULTIHOP
-ENAMETOOLONG
-ENAVAIL
-ENEEDAUTH
-ENETDOWN
-ENETRESET
-ENETUNREACH
-ENFILE
-ENOANO
-ENOATTR
-ENOBUFS
-ENOCSI
-ENODATA
-ENODEV
-ENOENT
-ENOEXEC
-ENOKEY
-ENOLCK
-ENOLINK
-ENOMEDIUM
-ENOMEM
-ENOMSG
-ENONET
-ENOPKG
-ENOPOLICY
-ENOPROTOOPT
-ENOSPC
-ENOSR
-ENOSTR
-ENOSYS
-ENOTBLK
-ENOTCAPABLE
-ENOTCONN
-ENOTDIR
-ENOTEMPTY
-ENOTNAM
-ENOTRECOVERABLE
-ENOTSOCK
-ENOTSUP
-ENOTTY
-ENOTUNIQ
-ENXIO
-EOPNOTSUPP
-EOVERFLOW
-EOWNERDEAD
-EPERM
-EPFNOSUPPORT
-EPIPE
-EPROCLIM
-EPROCUNAVAIL
-EPROGMISMATCH
-EPROGUNAVAIL
-EPROTO
-EPROTONOSUPPORT
-EPROTOTYPE
-EPWROFF
-EQFULL
-ERANGE
-EREMCHG
-EREMOTE
-EREMOTEIO
-ERESTART
-ERFKILL
-EROFS
-ERPCMISMATCH
-ESHLIBVERS
-ESHUTDOWN
-ESOCKTNOSUPPORT
-ESPIPE
-ESRCH
-ESRMNT
-ESTALE
-ESTRPIPE
-ETIME
-ETIMEDOUT
-ETOOMANYREFS
-ETXTBSY
-EUCLEAN
-EUNATCH
-EUSERS
-EWOULDBLOCK
-EXDEV
-EXFULL
+E2BIG Argument list too long
+EACCES Permission denied
+EADDRINUSE Address already in use
+EADDRNOTAVAIL Address not available
+EADV Advertise error
+EAFNOSUPPORT Address family not supported
+EAGAIN Resource temporarily unavailable, try again (may be the same value as EWOULDBLOCK)
+EALREADY Connection already in progress
+EAUTH Authentication error
+EBADARCH Bad CPU type in executable
+EBADE Bad exchange
+EBADEXEC Bad executable
+EBADF Bad file descriptor
+EBADFD File descriptor in bad state
+EBADMACHO Malformed Macho file
+EBADMSG Bad message
+EBADR Invalid request descriptor
+EBADRPC RPC struct is bad
+EBADRQC Invalid request code
+EBADSLT Invalid slot
+EBFONT Bad font file format
+EBUSY Device or resource busy
+ECANCELED Operation canceled
+ECAPMODE Not permitted in capability mode
+ECHILD No child processes
+ECHRNG Channel number out of range
+ECOMM Communication error on send
+ECONNABORTED Connection aborted
+ECONNREFUSED Connection refused
+ECONNRESET Connection reset
+EDEADLK Resource deadlock avoided
+EDEADLOCK File locking deadlock error
+EDESTADDRREQ Destination address required
+EDEVERR Device error; e.g., printer paper out
+EDOM Mathematics argument out of domain of function
+EDOOFUS Improper function use
+EDOTDOT RFS specific error
+EDQUOT Disk quota exceeded
+EEXIST File exists
+EFAULT Bad address
+EFBIG File too large
+EFTYPE Invalid file type or format
+EHOSTDOWN Host is down
+EHOSTUNREACH Host is unreachable
+EHWPOISON Memory page has hardware error
+EIDRM Identifier removed
+EILSEQ Invalid or incomplete multibyte or wide character
+EINPROGRESS Operation in progress
+EINTR Interrupted function call
+EINVAL Invalid argument
+EIO Input/output error
+EIPSEC IPsec processing failure
+EISCONN Socket is connected
+EISDIR Is a directory
+EISNAM Is a named file type
+EKEYEXPIRED Key has expired
+EKEYREJECTED Key was rejected by service
+EKEYREVOKED Key has been revoked
+EL2HLT Level 2 halted
+EL2NSYNC Level 2 not synchronized
+EL3HLT Level 3 halted
+EL3RST Level 3 reset
+ELIBACC Cannot access a needed shared library
+ELIBBAD Accessing a corrupted shared library
+ELIBEXEC Cannot exec a shared library directly
+ELIBMAX Attempting to link in too many shared libraries
+ELIBSCN .lib section in a.out corrupted
+ELNRNG Link number out of range
+ELOOP Too many levels of symbolic links
+EMEDIUMTYPE Wrong medium type
+EMFILE Too many open files
+EMLINK Too many links
+EMSGSIZE Message too long
+EMULTIHOP Multihop attempted
+ENAMETOOLONG Filename too long
+ENAVAIL No XENIX semaphores available
+ENEEDAUTH Need authenticator
+ENETDOWN Network is down
+ENETRESET Connection aborted by network
+ENETUNREACH Network unreachable
+ENFILE Too many open files in system
+ENOANO No anode
+ENOATTR Attribute not found
+ENOBUFS No buffer space available
+ENOCSI No CSI structure available
+ENODATA No data available
+ENODEV No such device
+ENOENT No such file or directory
+ENOEXEC Exec format error
+ENOKEY Required key not available
+ENOLCK No locks available
+ENOLINK Link has been severed
+ENOMEDIUM No medium found
+ENOMEM Not enough space/cannot allocate memory
+ENOMSG No message of the desired type
+ENONET Machine is not on the network
+ENOPKG Package not installed
+ENOPOLICY No such policy
+ENOPROTOOPT Protocol not available
+ENOSPC No space left on device
+ENOSR No STREAM resources
+ENOSTR Not a STREAM
+ENOSYS Functionality not implemented
+ENOTBLK Block device required
+ENOTCAPABLE Capabilities insufficient
+ENOTCONN The socket is not connected
+ENOTDIR Not a directory
+ENOTEMPTY Directory not empty
+ENOTNAM Not a XENIX named type file
+ENOTRECOVERABLE State not recoverable
+ENOTSOCK Not a socket
+ENOTSUP Operation not supported
+ENOTTY Inappropriate I/O control operation
+ENOTUNIQ Name not unique on network
+ENXIO No such device or address
+EOPNOTSUPP Operation not supported on socket
+EOVERFLOW Value too large to be stored in data type
+EOWNERDEAD Owner died
+EPERM Operation not permitted
+EPFNOSUPPORT Protocol family not supported
+EPIPE Broken pipe
+EPROCLIM Too many processes
+EPROCUNAVAIL Bad procedure for program
+EPROGMISMATCH Program version wrong
+EPROGUNAVAIL RPC program isn't available
+EPROTO Protocol error
+EPROTONOSUPPORT Protocol not supported
+EPROTOTYPE Protocol wrong type for socket
+EPWROFF Device power is off
+EQFULL Interface output queue is full
+ERANGE Result too large
+EREMCHG Remote address changed
+EREMOTE Object is remote
+EREMOTEIO Remote I/O error
+ERESTART Interrupted system call should be restarted
+ERFKILL Operation not possible due to RF-kill
+EROFS Read-only file system
+ERPCMISMATCH RPC version wrong
+ESHLIBVERS Shared library version mismatch
+ESHUTDOWN Cannot send after transport endpoint shutdown
+ESOCKTNOSUPPORT Socket type not supported
+ESPIPE Illegal seek
+ESRCH No such process
+ESRMNT Server mount error
+ESTALE Stale file handle
+ESTRPIPE Streams pipe error
+ETIME Timer expired
+ETIMEDOUT Connection timed out
+ETOOMANYREFS Too many references: cannot splice
+ETXTBSY Text file busy
+EUCLEAN Structure needs cleaning
+EUNATCH Protocol driver not attached
+EUSERS Too many users
+EWOULDBLOCK Operation would block
+EXDEV Invalid cross-device link
+EXFULL Exchange full
+ELAST Largest errno value
diff --git a/defs/opt_insn_unif.def b/defs/opt_insn_unif.def
index 31ae2eb6a1..5ce67538f1 100644
--- a/defs/opt_insn_unif.def
+++ b/defs/opt_insn_unif.def
@@ -6,12 +6,12 @@
__END__
putobject putobject
-putobject putstring
+putobject dupstring
putobject setlocal
-putstring putstring
-putstring putobject
-putstring setlocal
+dupstring dupstring
+dupstring putobject
+dupstring setlocal
# putnil end
diff --git a/depend b/depend
new file mode 100644
index 0000000000..a2e8312298
--- /dev/null
+++ b/depend
@@ -0,0 +1,21719 @@
+# AUTOGENERATED DEPENDENCIES START
+addr2line.$(OBJEXT): {$(VPATH)}addr2line.c
+addr2line.$(OBJEXT): {$(VPATH)}addr2line.h
+addr2line.$(OBJEXT): {$(VPATH)}assert.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+addr2line.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+addr2line.$(OBJEXT): {$(VPATH)}config.h
+addr2line.$(OBJEXT): {$(VPATH)}defines.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/assume.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/cast.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/config.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/dosish.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+addr2line.$(OBJEXT): {$(VPATH)}missing.h
+array.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+array.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+array.$(OBJEXT): $(CCAN_DIR)/list/list.h
+array.$(OBJEXT): $(CCAN_DIR)/str/str.h
+array.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+array.$(OBJEXT): $(top_srcdir)/internal/array.h
+array.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+array.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+array.$(OBJEXT): $(top_srcdir)/internal/bits.h
+array.$(OBJEXT): $(top_srcdir)/internal/box.h
+array.$(OBJEXT): $(top_srcdir)/internal/class.h
+array.$(OBJEXT): $(top_srcdir)/internal/compar.h
+array.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+array.$(OBJEXT): $(top_srcdir)/internal/enum.h
+array.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+array.$(OBJEXT): $(top_srcdir)/internal/gc.h
+array.$(OBJEXT): $(top_srcdir)/internal/hash.h
+array.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+array.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+array.$(OBJEXT): $(top_srcdir)/internal/object.h
+array.$(OBJEXT): $(top_srcdir)/internal/proc.h
+array.$(OBJEXT): $(top_srcdir)/internal/rational.h
+array.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+array.$(OBJEXT): $(top_srcdir)/internal/serial.h
+array.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+array.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+array.$(OBJEXT): $(top_srcdir)/internal/struct.h
+array.$(OBJEXT): $(top_srcdir)/internal/variable.h
+array.$(OBJEXT): $(top_srcdir)/internal/vm.h
+array.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+array.$(OBJEXT): {$(VPATH)}array.c
+array.$(OBJEXT): {$(VPATH)}array.rbinc
+array.$(OBJEXT): {$(VPATH)}assert.h
+array.$(OBJEXT): {$(VPATH)}atomic.h
+array.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+array.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+array.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+array.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+array.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+array.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+array.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+array.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+array.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+array.$(OBJEXT): {$(VPATH)}builtin.h
+array.$(OBJEXT): {$(VPATH)}config.h
+array.$(OBJEXT): {$(VPATH)}constant.h
+array.$(OBJEXT): {$(VPATH)}debug_counter.h
+array.$(OBJEXT): {$(VPATH)}defines.h
+array.$(OBJEXT): {$(VPATH)}encoding.h
+array.$(OBJEXT): {$(VPATH)}id.h
+array.$(OBJEXT): {$(VPATH)}id_table.h
+array.$(OBJEXT): {$(VPATH)}intern.h
+array.$(OBJEXT): {$(VPATH)}internal.h
+array.$(OBJEXT): {$(VPATH)}internal/abi.h
+array.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+array.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+array.$(OBJEXT): {$(VPATH)}internal/assume.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+array.$(OBJEXT): {$(VPATH)}internal/cast.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+array.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+array.$(OBJEXT): {$(VPATH)}internal/config.h
+array.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+array.$(OBJEXT): {$(VPATH)}internal/core.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+array.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+array.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+array.$(OBJEXT): {$(VPATH)}internal/ctype.h
+array.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+array.$(OBJEXT): {$(VPATH)}internal/dosish.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+array.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+array.$(OBJEXT): {$(VPATH)}internal/error.h
+array.$(OBJEXT): {$(VPATH)}internal/eval.h
+array.$(OBJEXT): {$(VPATH)}internal/event.h
+array.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+array.$(OBJEXT): {$(VPATH)}internal/gc.h
+array.$(OBJEXT): {$(VPATH)}internal/glob.h
+array.$(OBJEXT): {$(VPATH)}internal/globals.h
+array.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+array.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+array.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+array.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+array.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+array.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+array.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+array.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+array.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+array.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+array.$(OBJEXT): {$(VPATH)}internal/iterator.h
+array.$(OBJEXT): {$(VPATH)}internal/memory.h
+array.$(OBJEXT): {$(VPATH)}internal/method.h
+array.$(OBJEXT): {$(VPATH)}internal/module.h
+array.$(OBJEXT): {$(VPATH)}internal/newobj.h
+array.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+array.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+array.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+array.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+array.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+array.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+array.$(OBJEXT): {$(VPATH)}internal/symbol.h
+array.$(OBJEXT): {$(VPATH)}internal/value.h
+array.$(OBJEXT): {$(VPATH)}internal/value_type.h
+array.$(OBJEXT): {$(VPATH)}internal/variable.h
+array.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+array.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+array.$(OBJEXT): {$(VPATH)}method.h
+array.$(OBJEXT): {$(VPATH)}missing.h
+array.$(OBJEXT): {$(VPATH)}node.h
+array.$(OBJEXT): {$(VPATH)}onigmo.h
+array.$(OBJEXT): {$(VPATH)}oniguruma.h
+array.$(OBJEXT): {$(VPATH)}probes.dmyh
+array.$(OBJEXT): {$(VPATH)}probes.h
+array.$(OBJEXT): {$(VPATH)}ractor.h
+array.$(OBJEXT): {$(VPATH)}ruby_assert.h
+array.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+array.$(OBJEXT): {$(VPATH)}rubyparser.h
+array.$(OBJEXT): {$(VPATH)}shape.h
+array.$(OBJEXT): {$(VPATH)}st.h
+array.$(OBJEXT): {$(VPATH)}subst.h
+array.$(OBJEXT): {$(VPATH)}thread.h
+array.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+array.$(OBJEXT): {$(VPATH)}thread_native.h
+array.$(OBJEXT): {$(VPATH)}util.h
+array.$(OBJEXT): {$(VPATH)}vm_core.h
+array.$(OBJEXT): {$(VPATH)}vm_opts.h
+ast.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+ast.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+ast.$(OBJEXT): $(CCAN_DIR)/list/list.h
+ast.$(OBJEXT): $(CCAN_DIR)/str/str.h
+ast.$(OBJEXT): $(hdrdir)/ruby.h
+ast.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+ast.$(OBJEXT): $(top_srcdir)/internal/array.h
+ast.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+ast.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+ast.$(OBJEXT): $(top_srcdir)/internal/bits.h
+ast.$(OBJEXT): $(top_srcdir)/internal/box.h
+ast.$(OBJEXT): $(top_srcdir)/internal/compar.h
+ast.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+ast.$(OBJEXT): $(top_srcdir)/internal/complex.h
+ast.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+ast.$(OBJEXT): $(top_srcdir)/internal/gc.h
+ast.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+ast.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+ast.$(OBJEXT): $(top_srcdir)/internal/parse.h
+ast.$(OBJEXT): $(top_srcdir)/internal/rational.h
+ast.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+ast.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+ast.$(OBJEXT): $(top_srcdir)/internal/serial.h
+ast.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+ast.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+ast.$(OBJEXT): $(top_srcdir)/internal/struct.h
+ast.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+ast.$(OBJEXT): $(top_srcdir)/internal/variable.h
+ast.$(OBJEXT): $(top_srcdir)/internal/vm.h
+ast.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+ast.$(OBJEXT): $(top_srcdir)/prism/arena.h
+ast.$(OBJEXT): $(top_srcdir)/prism/ast.h
+ast.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+ast.$(OBJEXT): $(top_srcdir)/prism/comments.h
+ast.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+ast.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+ast.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+ast.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+ast.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+ast.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+ast.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+ast.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+ast.$(OBJEXT): $(top_srcdir)/prism/integer.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+ast.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+ast.$(OBJEXT): $(top_srcdir)/prism/json.h
+ast.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+ast.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+ast.$(OBJEXT): $(top_srcdir)/prism/node.h
+ast.$(OBJEXT): $(top_srcdir)/prism/options.h
+ast.$(OBJEXT): $(top_srcdir)/prism/parser.h
+ast.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+ast.$(OBJEXT): $(top_srcdir)/prism/prism.h
+ast.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+ast.$(OBJEXT): $(top_srcdir)/prism/source.h
+ast.$(OBJEXT): $(top_srcdir)/prism/stream.h
+ast.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+ast.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+ast.$(OBJEXT): $(top_srcdir)/prism/version.h
+ast.$(OBJEXT): {$(VPATH)}assert.h
+ast.$(OBJEXT): {$(VPATH)}ast.c
+ast.$(OBJEXT): {$(VPATH)}ast.rbinc
+ast.$(OBJEXT): {$(VPATH)}atomic.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+ast.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+ast.$(OBJEXT): {$(VPATH)}builtin.h
+ast.$(OBJEXT): {$(VPATH)}config.h
+ast.$(OBJEXT): {$(VPATH)}constant.h
+ast.$(OBJEXT): {$(VPATH)}defines.h
+ast.$(OBJEXT): {$(VPATH)}encoding.h
+ast.$(OBJEXT): {$(VPATH)}id.h
+ast.$(OBJEXT): {$(VPATH)}id_table.h
+ast.$(OBJEXT): {$(VPATH)}intern.h
+ast.$(OBJEXT): {$(VPATH)}internal.h
+ast.$(OBJEXT): {$(VPATH)}internal/abi.h
+ast.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+ast.$(OBJEXT): {$(VPATH)}internal/assume.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+ast.$(OBJEXT): {$(VPATH)}internal/cast.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+ast.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+ast.$(OBJEXT): {$(VPATH)}internal/config.h
+ast.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+ast.$(OBJEXT): {$(VPATH)}internal/core.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+ast.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+ast.$(OBJEXT): {$(VPATH)}internal/ctype.h
+ast.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+ast.$(OBJEXT): {$(VPATH)}internal/dosish.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+ast.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+ast.$(OBJEXT): {$(VPATH)}internal/error.h
+ast.$(OBJEXT): {$(VPATH)}internal/eval.h
+ast.$(OBJEXT): {$(VPATH)}internal/event.h
+ast.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+ast.$(OBJEXT): {$(VPATH)}internal/gc.h
+ast.$(OBJEXT): {$(VPATH)}internal/glob.h
+ast.$(OBJEXT): {$(VPATH)}internal/globals.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+ast.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+ast.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+ast.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+ast.$(OBJEXT): {$(VPATH)}internal/iterator.h
+ast.$(OBJEXT): {$(VPATH)}internal/memory.h
+ast.$(OBJEXT): {$(VPATH)}internal/method.h
+ast.$(OBJEXT): {$(VPATH)}internal/module.h
+ast.$(OBJEXT): {$(VPATH)}internal/newobj.h
+ast.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+ast.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+ast.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+ast.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+ast.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+ast.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+ast.$(OBJEXT): {$(VPATH)}internal/symbol.h
+ast.$(OBJEXT): {$(VPATH)}internal/value.h
+ast.$(OBJEXT): {$(VPATH)}internal/value_type.h
+ast.$(OBJEXT): {$(VPATH)}internal/variable.h
+ast.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+ast.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+ast.$(OBJEXT): {$(VPATH)}iseq.h
+ast.$(OBJEXT): {$(VPATH)}method.h
+ast.$(OBJEXT): {$(VPATH)}missing.h
+ast.$(OBJEXT): {$(VPATH)}node.h
+ast.$(OBJEXT): {$(VPATH)}onigmo.h
+ast.$(OBJEXT): {$(VPATH)}oniguruma.h
+ast.$(OBJEXT): {$(VPATH)}prism_compile.h
+ast.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+ast.$(OBJEXT): {$(VPATH)}ruby_assert.h
+ast.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ast.$(OBJEXT): {$(VPATH)}rubyparser.h
+ast.$(OBJEXT): {$(VPATH)}shape.h
+ast.$(OBJEXT): {$(VPATH)}st.h
+ast.$(OBJEXT): {$(VPATH)}subst.h
+ast.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+ast.$(OBJEXT): {$(VPATH)}thread_native.h
+ast.$(OBJEXT): {$(VPATH)}util.h
+ast.$(OBJEXT): {$(VPATH)}vm_core.h
+ast.$(OBJEXT): {$(VPATH)}vm_opts.h
+bignum.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+bignum.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+bignum.$(OBJEXT): $(CCAN_DIR)/list/list.h
+bignum.$(OBJEXT): $(CCAN_DIR)/str/str.h
+bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/array.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/bits.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/box.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/class.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/compar.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/complex.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/gc.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/object.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/serial.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/struct.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/variable.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/vm.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+bignum.$(OBJEXT): {$(VPATH)}assert.h
+bignum.$(OBJEXT): {$(VPATH)}atomic.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+bignum.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+bignum.$(OBJEXT): {$(VPATH)}bignum.c
+bignum.$(OBJEXT): {$(VPATH)}config.h
+bignum.$(OBJEXT): {$(VPATH)}constant.h
+bignum.$(OBJEXT): {$(VPATH)}defines.h
+bignum.$(OBJEXT): {$(VPATH)}encoding.h
+bignum.$(OBJEXT): {$(VPATH)}id.h
+bignum.$(OBJEXT): {$(VPATH)}id_table.h
+bignum.$(OBJEXT): {$(VPATH)}intern.h
+bignum.$(OBJEXT): {$(VPATH)}internal.h
+bignum.$(OBJEXT): {$(VPATH)}internal/abi.h
+bignum.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+bignum.$(OBJEXT): {$(VPATH)}internal/assume.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+bignum.$(OBJEXT): {$(VPATH)}internal/cast.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+bignum.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+bignum.$(OBJEXT): {$(VPATH)}internal/config.h
+bignum.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+bignum.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+bignum.$(OBJEXT): {$(VPATH)}internal/ctype.h
+bignum.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+bignum.$(OBJEXT): {$(VPATH)}internal/dosish.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+bignum.$(OBJEXT): {$(VPATH)}internal/error.h
+bignum.$(OBJEXT): {$(VPATH)}internal/eval.h
+bignum.$(OBJEXT): {$(VPATH)}internal/event.h
+bignum.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+bignum.$(OBJEXT): {$(VPATH)}internal/gc.h
+bignum.$(OBJEXT): {$(VPATH)}internal/glob.h
+bignum.$(OBJEXT): {$(VPATH)}internal/globals.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+bignum.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+bignum.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+bignum.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+bignum.$(OBJEXT): {$(VPATH)}internal/iterator.h
+bignum.$(OBJEXT): {$(VPATH)}internal/memory.h
+bignum.$(OBJEXT): {$(VPATH)}internal/method.h
+bignum.$(OBJEXT): {$(VPATH)}internal/module.h
+bignum.$(OBJEXT): {$(VPATH)}internal/newobj.h
+bignum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+bignum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+bignum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+bignum.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+bignum.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+bignum.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+bignum.$(OBJEXT): {$(VPATH)}internal/symbol.h
+bignum.$(OBJEXT): {$(VPATH)}internal/value.h
+bignum.$(OBJEXT): {$(VPATH)}internal/value_type.h
+bignum.$(OBJEXT): {$(VPATH)}internal/variable.h
+bignum.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+bignum.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+bignum.$(OBJEXT): {$(VPATH)}method.h
+bignum.$(OBJEXT): {$(VPATH)}missing.h
+bignum.$(OBJEXT): {$(VPATH)}node.h
+bignum.$(OBJEXT): {$(VPATH)}onigmo.h
+bignum.$(OBJEXT): {$(VPATH)}oniguruma.h
+bignum.$(OBJEXT): {$(VPATH)}ruby_assert.h
+bignum.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+bignum.$(OBJEXT): {$(VPATH)}rubyparser.h
+bignum.$(OBJEXT): {$(VPATH)}shape.h
+bignum.$(OBJEXT): {$(VPATH)}st.h
+bignum.$(OBJEXT): {$(VPATH)}subst.h
+bignum.$(OBJEXT): {$(VPATH)}thread.h
+bignum.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+bignum.$(OBJEXT): {$(VPATH)}thread_native.h
+bignum.$(OBJEXT): {$(VPATH)}util.h
+bignum.$(OBJEXT): {$(VPATH)}vm_core.h
+bignum.$(OBJEXT): {$(VPATH)}vm_opts.h
+box.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+box.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+box.$(OBJEXT): $(CCAN_DIR)/list/list.h
+box.$(OBJEXT): $(CCAN_DIR)/str/str.h
+box.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+box.$(OBJEXT): $(top_srcdir)/internal/array.h
+box.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+box.$(OBJEXT): $(top_srcdir)/internal/box.h
+box.$(OBJEXT): $(top_srcdir)/internal/class.h
+box.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+box.$(OBJEXT): $(top_srcdir)/internal/error.h
+box.$(OBJEXT): $(top_srcdir)/internal/eval.h
+box.$(OBJEXT): $(top_srcdir)/internal/file.h
+box.$(OBJEXT): $(top_srcdir)/internal/gc.h
+box.$(OBJEXT): $(top_srcdir)/internal/hash.h
+box.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+box.$(OBJEXT): $(top_srcdir)/internal/io.h
+box.$(OBJEXT): $(top_srcdir)/internal/load.h
+box.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+box.$(OBJEXT): $(top_srcdir)/internal/serial.h
+box.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+box.$(OBJEXT): $(top_srcdir)/internal/st.h
+box.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+box.$(OBJEXT): $(top_srcdir)/internal/string.h
+box.$(OBJEXT): $(top_srcdir)/internal/struct.h
+box.$(OBJEXT): $(top_srcdir)/internal/variable.h
+box.$(OBJEXT): $(top_srcdir)/internal/vm.h
+box.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+box.$(OBJEXT): $(top_srcdir)/prism/arena.h
+box.$(OBJEXT): $(top_srcdir)/prism/ast.h
+box.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+box.$(OBJEXT): $(top_srcdir)/prism/comments.h
+box.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+box.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+box.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+box.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+box.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+box.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+box.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+box.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+box.$(OBJEXT): $(top_srcdir)/prism/integer.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+box.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+box.$(OBJEXT): $(top_srcdir)/prism/json.h
+box.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+box.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+box.$(OBJEXT): $(top_srcdir)/prism/node.h
+box.$(OBJEXT): $(top_srcdir)/prism/options.h
+box.$(OBJEXT): $(top_srcdir)/prism/parser.h
+box.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+box.$(OBJEXT): $(top_srcdir)/prism/prism.h
+box.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+box.$(OBJEXT): $(top_srcdir)/prism/source.h
+box.$(OBJEXT): $(top_srcdir)/prism/stream.h
+box.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+box.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+box.$(OBJEXT): $(top_srcdir)/prism/version.h
+box.$(OBJEXT): {$(VPATH)}assert.h
+box.$(OBJEXT): {$(VPATH)}atomic.h
+box.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+box.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+box.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+box.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+box.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+box.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+box.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+box.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+box.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+box.$(OBJEXT): {$(VPATH)}box.c
+box.$(OBJEXT): {$(VPATH)}builtin.h
+box.$(OBJEXT): {$(VPATH)}config.h
+box.$(OBJEXT): {$(VPATH)}constant.h
+box.$(OBJEXT): {$(VPATH)}darray.h
+box.$(OBJEXT): {$(VPATH)}debug_counter.h
+box.$(OBJEXT): {$(VPATH)}defines.h
+box.$(OBJEXT): {$(VPATH)}encindex.h
+box.$(OBJEXT): {$(VPATH)}encoding.h
+box.$(OBJEXT): {$(VPATH)}eval_intern.h
+box.$(OBJEXT): {$(VPATH)}id.h
+box.$(OBJEXT): {$(VPATH)}id_table.h
+box.$(OBJEXT): {$(VPATH)}intern.h
+box.$(OBJEXT): {$(VPATH)}internal.h
+box.$(OBJEXT): {$(VPATH)}internal/abi.h
+box.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+box.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+box.$(OBJEXT): {$(VPATH)}internal/assume.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+box.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+box.$(OBJEXT): {$(VPATH)}internal/cast.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+box.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+box.$(OBJEXT): {$(VPATH)}internal/config.h
+box.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+box.$(OBJEXT): {$(VPATH)}internal/core.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+box.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+box.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+box.$(OBJEXT): {$(VPATH)}internal/ctype.h
+box.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+box.$(OBJEXT): {$(VPATH)}internal/dosish.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+box.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+box.$(OBJEXT): {$(VPATH)}internal/error.h
+box.$(OBJEXT): {$(VPATH)}internal/eval.h
+box.$(OBJEXT): {$(VPATH)}internal/event.h
+box.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+box.$(OBJEXT): {$(VPATH)}internal/gc.h
+box.$(OBJEXT): {$(VPATH)}internal/glob.h
+box.$(OBJEXT): {$(VPATH)}internal/globals.h
+box.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+box.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+box.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+box.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+box.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+box.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+box.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+box.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+box.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+box.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+box.$(OBJEXT): {$(VPATH)}internal/iterator.h
+box.$(OBJEXT): {$(VPATH)}internal/memory.h
+box.$(OBJEXT): {$(VPATH)}internal/method.h
+box.$(OBJEXT): {$(VPATH)}internal/module.h
+box.$(OBJEXT): {$(VPATH)}internal/newobj.h
+box.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+box.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+box.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+box.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+box.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+box.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+box.$(OBJEXT): {$(VPATH)}internal/symbol.h
+box.$(OBJEXT): {$(VPATH)}internal/value.h
+box.$(OBJEXT): {$(VPATH)}internal/value_type.h
+box.$(OBJEXT): {$(VPATH)}internal/variable.h
+box.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+box.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+box.$(OBJEXT): {$(VPATH)}io.h
+box.$(OBJEXT): {$(VPATH)}iseq.h
+box.$(OBJEXT): {$(VPATH)}method.h
+box.$(OBJEXT): {$(VPATH)}missing.h
+box.$(OBJEXT): {$(VPATH)}node.h
+box.$(OBJEXT): {$(VPATH)}onigmo.h
+box.$(OBJEXT): {$(VPATH)}oniguruma.h
+box.$(OBJEXT): {$(VPATH)}prism/ast.h
+box.$(OBJEXT): {$(VPATH)}prism/diagnostic.h
+box.$(OBJEXT): {$(VPATH)}prism/version.h
+box.$(OBJEXT): {$(VPATH)}prism_compile.h
+box.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+box.$(OBJEXT): {$(VPATH)}ruby_assert.h
+box.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+box.$(OBJEXT): {$(VPATH)}rubyparser.h
+box.$(OBJEXT): {$(VPATH)}shape.h
+box.$(OBJEXT): {$(VPATH)}st.h
+box.$(OBJEXT): {$(VPATH)}subst.h
+box.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+box.$(OBJEXT): {$(VPATH)}thread_native.h
+box.$(OBJEXT): {$(VPATH)}util.h
+box.$(OBJEXT): {$(VPATH)}vm_core.h
+box.$(OBJEXT): {$(VPATH)}vm_debug.h
+box.$(OBJEXT): {$(VPATH)}vm_opts.h
+box.$(OBJEXT): {$(VPATH)}vm_sync.h
+box.$(OBJEXT): {$(VPATH)}zjit.h
+builtin.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+builtin.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+builtin.$(OBJEXT): $(CCAN_DIR)/list/list.h
+builtin.$(OBJEXT): $(CCAN_DIR)/str/str.h
+builtin.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/array.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/box.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/gc.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/serial.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/struct.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/variable.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/vm.h
+builtin.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/arena.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/ast.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/comments.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/integer.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/json.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/node.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/options.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/parser.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/prism.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/source.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/stream.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/version.h
+builtin.$(OBJEXT): {$(VPATH)}assert.h
+builtin.$(OBJEXT): {$(VPATH)}atomic.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+builtin.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+builtin.$(OBJEXT): {$(VPATH)}builtin.c
+builtin.$(OBJEXT): {$(VPATH)}builtin.h
+builtin.$(OBJEXT): {$(VPATH)}builtin_binary.rbbin
+builtin.$(OBJEXT): {$(VPATH)}config.h
+builtin.$(OBJEXT): {$(VPATH)}constant.h
+builtin.$(OBJEXT): {$(VPATH)}defines.h
+builtin.$(OBJEXT): {$(VPATH)}encoding.h
+builtin.$(OBJEXT): {$(VPATH)}id.h
+builtin.$(OBJEXT): {$(VPATH)}id_table.h
+builtin.$(OBJEXT): {$(VPATH)}intern.h
+builtin.$(OBJEXT): {$(VPATH)}internal.h
+builtin.$(OBJEXT): {$(VPATH)}internal/abi.h
+builtin.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+builtin.$(OBJEXT): {$(VPATH)}internal/assume.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+builtin.$(OBJEXT): {$(VPATH)}internal/cast.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+builtin.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+builtin.$(OBJEXT): {$(VPATH)}internal/config.h
+builtin.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+builtin.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+builtin.$(OBJEXT): {$(VPATH)}internal/ctype.h
+builtin.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+builtin.$(OBJEXT): {$(VPATH)}internal/dosish.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+builtin.$(OBJEXT): {$(VPATH)}internal/error.h
+builtin.$(OBJEXT): {$(VPATH)}internal/eval.h
+builtin.$(OBJEXT): {$(VPATH)}internal/event.h
+builtin.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+builtin.$(OBJEXT): {$(VPATH)}internal/gc.h
+builtin.$(OBJEXT): {$(VPATH)}internal/glob.h
+builtin.$(OBJEXT): {$(VPATH)}internal/globals.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+builtin.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+builtin.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+builtin.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+builtin.$(OBJEXT): {$(VPATH)}internal/iterator.h
+builtin.$(OBJEXT): {$(VPATH)}internal/memory.h
+builtin.$(OBJEXT): {$(VPATH)}internal/method.h
+builtin.$(OBJEXT): {$(VPATH)}internal/module.h
+builtin.$(OBJEXT): {$(VPATH)}internal/newobj.h
+builtin.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+builtin.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+builtin.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+builtin.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+builtin.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+builtin.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+builtin.$(OBJEXT): {$(VPATH)}internal/symbol.h
+builtin.$(OBJEXT): {$(VPATH)}internal/value.h
+builtin.$(OBJEXT): {$(VPATH)}internal/value_type.h
+builtin.$(OBJEXT): {$(VPATH)}internal/variable.h
+builtin.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+builtin.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+builtin.$(OBJEXT): {$(VPATH)}iseq.h
+builtin.$(OBJEXT): {$(VPATH)}method.h
+builtin.$(OBJEXT): {$(VPATH)}missing.h
+builtin.$(OBJEXT): {$(VPATH)}node.h
+builtin.$(OBJEXT): {$(VPATH)}onigmo.h
+builtin.$(OBJEXT): {$(VPATH)}oniguruma.h
+builtin.$(OBJEXT): {$(VPATH)}prism_compile.h
+builtin.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+builtin.$(OBJEXT): {$(VPATH)}ruby_assert.h
+builtin.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+builtin.$(OBJEXT): {$(VPATH)}rubyparser.h
+builtin.$(OBJEXT): {$(VPATH)}shape.h
+builtin.$(OBJEXT): {$(VPATH)}st.h
+builtin.$(OBJEXT): {$(VPATH)}subst.h
+builtin.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+builtin.$(OBJEXT): {$(VPATH)}thread_native.h
+builtin.$(OBJEXT): {$(VPATH)}vm_core.h
+builtin.$(OBJEXT): {$(VPATH)}vm_opts.h
+class.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+class.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+class.$(OBJEXT): $(CCAN_DIR)/list/list.h
+class.$(OBJEXT): $(CCAN_DIR)/str/str.h
+class.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+class.$(OBJEXT): $(top_srcdir)/internal/array.h
+class.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+class.$(OBJEXT): $(top_srcdir)/internal/box.h
+class.$(OBJEXT): $(top_srcdir)/internal/class.h
+class.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+class.$(OBJEXT): $(top_srcdir)/internal/eval.h
+class.$(OBJEXT): $(top_srcdir)/internal/gc.h
+class.$(OBJEXT): $(top_srcdir)/internal/hash.h
+class.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+class.$(OBJEXT): $(top_srcdir)/internal/object.h
+class.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+class.$(OBJEXT): $(top_srcdir)/internal/serial.h
+class.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+class.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+class.$(OBJEXT): $(top_srcdir)/internal/string.h
+class.$(OBJEXT): $(top_srcdir)/internal/struct.h
+class.$(OBJEXT): $(top_srcdir)/internal/variable.h
+class.$(OBJEXT): $(top_srcdir)/internal/vm.h
+class.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+class.$(OBJEXT): {$(VPATH)}assert.h
+class.$(OBJEXT): {$(VPATH)}atomic.h
+class.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+class.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+class.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+class.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+class.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+class.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+class.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+class.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+class.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+class.$(OBJEXT): {$(VPATH)}class.c
+class.$(OBJEXT): {$(VPATH)}config.h
+class.$(OBJEXT): {$(VPATH)}constant.h
+class.$(OBJEXT): {$(VPATH)}debug_counter.h
+class.$(OBJEXT): {$(VPATH)}defines.h
+class.$(OBJEXT): {$(VPATH)}encindex.h
+class.$(OBJEXT): {$(VPATH)}encoding.h
+class.$(OBJEXT): {$(VPATH)}id.h
+class.$(OBJEXT): {$(VPATH)}id_table.h
+class.$(OBJEXT): {$(VPATH)}intern.h
+class.$(OBJEXT): {$(VPATH)}internal.h
+class.$(OBJEXT): {$(VPATH)}internal/abi.h
+class.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+class.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+class.$(OBJEXT): {$(VPATH)}internal/assume.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+class.$(OBJEXT): {$(VPATH)}internal/cast.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+class.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+class.$(OBJEXT): {$(VPATH)}internal/config.h
+class.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+class.$(OBJEXT): {$(VPATH)}internal/core.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+class.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+class.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+class.$(OBJEXT): {$(VPATH)}internal/ctype.h
+class.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+class.$(OBJEXT): {$(VPATH)}internal/dosish.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+class.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+class.$(OBJEXT): {$(VPATH)}internal/error.h
+class.$(OBJEXT): {$(VPATH)}internal/eval.h
+class.$(OBJEXT): {$(VPATH)}internal/event.h
+class.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+class.$(OBJEXT): {$(VPATH)}internal/gc.h
+class.$(OBJEXT): {$(VPATH)}internal/glob.h
+class.$(OBJEXT): {$(VPATH)}internal/globals.h
+class.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+class.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+class.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+class.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+class.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+class.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+class.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+class.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+class.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+class.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+class.$(OBJEXT): {$(VPATH)}internal/iterator.h
+class.$(OBJEXT): {$(VPATH)}internal/memory.h
+class.$(OBJEXT): {$(VPATH)}internal/method.h
+class.$(OBJEXT): {$(VPATH)}internal/module.h
+class.$(OBJEXT): {$(VPATH)}internal/newobj.h
+class.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+class.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+class.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+class.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+class.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+class.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+class.$(OBJEXT): {$(VPATH)}internal/symbol.h
+class.$(OBJEXT): {$(VPATH)}internal/value.h
+class.$(OBJEXT): {$(VPATH)}internal/value_type.h
+class.$(OBJEXT): {$(VPATH)}internal/variable.h
+class.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+class.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+class.$(OBJEXT): {$(VPATH)}method.h
+class.$(OBJEXT): {$(VPATH)}missing.h
+class.$(OBJEXT): {$(VPATH)}node.h
+class.$(OBJEXT): {$(VPATH)}onigmo.h
+class.$(OBJEXT): {$(VPATH)}oniguruma.h
+class.$(OBJEXT): {$(VPATH)}ractor.h
+class.$(OBJEXT): {$(VPATH)}ruby_assert.h
+class.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+class.$(OBJEXT): {$(VPATH)}rubyparser.h
+class.$(OBJEXT): {$(VPATH)}shape.h
+class.$(OBJEXT): {$(VPATH)}st.h
+class.$(OBJEXT): {$(VPATH)}subst.h
+class.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+class.$(OBJEXT): {$(VPATH)}thread_native.h
+class.$(OBJEXT): {$(VPATH)}vm_core.h
+class.$(OBJEXT): {$(VPATH)}vm_debug.h
+class.$(OBJEXT): {$(VPATH)}vm_opts.h
+class.$(OBJEXT): {$(VPATH)}vm_sync.h
+class.$(OBJEXT): {$(VPATH)}yjit.h
+class.$(OBJEXT): {$(VPATH)}zjit.h
+compar.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+compar.$(OBJEXT): $(hdrdir)/ruby/version.h
+compar.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+compar.$(OBJEXT): $(top_srcdir)/internal/compar.h
+compar.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+compar.$(OBJEXT): $(top_srcdir)/internal/error.h
+compar.$(OBJEXT): $(top_srcdir)/internal/serial.h
+compar.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+compar.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+compar.$(OBJEXT): $(top_srcdir)/internal/string.h
+compar.$(OBJEXT): $(top_srcdir)/internal/vm.h
+compar.$(OBJEXT): {$(VPATH)}assert.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+compar.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+compar.$(OBJEXT): {$(VPATH)}compar.c
+compar.$(OBJEXT): {$(VPATH)}config.h
+compar.$(OBJEXT): {$(VPATH)}defines.h
+compar.$(OBJEXT): {$(VPATH)}encindex.h
+compar.$(OBJEXT): {$(VPATH)}encoding.h
+compar.$(OBJEXT): {$(VPATH)}id.h
+compar.$(OBJEXT): {$(VPATH)}intern.h
+compar.$(OBJEXT): {$(VPATH)}internal.h
+compar.$(OBJEXT): {$(VPATH)}internal/abi.h
+compar.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+compar.$(OBJEXT): {$(VPATH)}internal/assume.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+compar.$(OBJEXT): {$(VPATH)}internal/cast.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+compar.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+compar.$(OBJEXT): {$(VPATH)}internal/config.h
+compar.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+compar.$(OBJEXT): {$(VPATH)}internal/core.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+compar.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+compar.$(OBJEXT): {$(VPATH)}internal/ctype.h
+compar.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+compar.$(OBJEXT): {$(VPATH)}internal/dosish.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+compar.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+compar.$(OBJEXT): {$(VPATH)}internal/error.h
+compar.$(OBJEXT): {$(VPATH)}internal/eval.h
+compar.$(OBJEXT): {$(VPATH)}internal/event.h
+compar.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+compar.$(OBJEXT): {$(VPATH)}internal/gc.h
+compar.$(OBJEXT): {$(VPATH)}internal/glob.h
+compar.$(OBJEXT): {$(VPATH)}internal/globals.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+compar.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+compar.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+compar.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+compar.$(OBJEXT): {$(VPATH)}internal/iterator.h
+compar.$(OBJEXT): {$(VPATH)}internal/memory.h
+compar.$(OBJEXT): {$(VPATH)}internal/method.h
+compar.$(OBJEXT): {$(VPATH)}internal/module.h
+compar.$(OBJEXT): {$(VPATH)}internal/newobj.h
+compar.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+compar.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+compar.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+compar.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+compar.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+compar.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+compar.$(OBJEXT): {$(VPATH)}internal/symbol.h
+compar.$(OBJEXT): {$(VPATH)}internal/value.h
+compar.$(OBJEXT): {$(VPATH)}internal/value_type.h
+compar.$(OBJEXT): {$(VPATH)}internal/variable.h
+compar.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+compar.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+compar.$(OBJEXT): {$(VPATH)}missing.h
+compar.$(OBJEXT): {$(VPATH)}onigmo.h
+compar.$(OBJEXT): {$(VPATH)}oniguruma.h
+compar.$(OBJEXT): {$(VPATH)}st.h
+compar.$(OBJEXT): {$(VPATH)}subst.h
+compile.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+compile.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+compile.$(OBJEXT): $(CCAN_DIR)/list/list.h
+compile.$(OBJEXT): $(CCAN_DIR)/str/str.h
+compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+compile.$(OBJEXT): $(hdrdir)/ruby/version.h
+compile.$(OBJEXT): $(top_srcdir)/internal/array.h
+compile.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+compile.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+compile.$(OBJEXT): $(top_srcdir)/internal/bits.h
+compile.$(OBJEXT): $(top_srcdir)/internal/box.h
+compile.$(OBJEXT): $(top_srcdir)/internal/class.h
+compile.$(OBJEXT): $(top_srcdir)/internal/compar.h
+compile.$(OBJEXT): $(top_srcdir)/internal/compile.h
+compile.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+compile.$(OBJEXT): $(top_srcdir)/internal/complex.h
+compile.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+compile.$(OBJEXT): $(top_srcdir)/internal/error.h
+compile.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+compile.$(OBJEXT): $(top_srcdir)/internal/gc.h
+compile.$(OBJEXT): $(top_srcdir)/internal/hash.h
+compile.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+compile.$(OBJEXT): $(top_srcdir)/internal/io.h
+compile.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+compile.$(OBJEXT): $(top_srcdir)/internal/object.h
+compile.$(OBJEXT): $(top_srcdir)/internal/parse.h
+compile.$(OBJEXT): $(top_srcdir)/internal/rational.h
+compile.$(OBJEXT): $(top_srcdir)/internal/re.h
+compile.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+compile.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+compile.$(OBJEXT): $(top_srcdir)/internal/serial.h
+compile.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+compile.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+compile.$(OBJEXT): $(top_srcdir)/internal/string.h
+compile.$(OBJEXT): $(top_srcdir)/internal/struct.h
+compile.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+compile.$(OBJEXT): $(top_srcdir)/internal/thread.h
+compile.$(OBJEXT): $(top_srcdir)/internal/variable.h
+compile.$(OBJEXT): $(top_srcdir)/internal/vm.h
+compile.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+compile.$(OBJEXT): $(top_srcdir)/prism/arena.h
+compile.$(OBJEXT): $(top_srcdir)/prism/ast.h
+compile.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+compile.$(OBJEXT): $(top_srcdir)/prism/comments.h
+compile.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+compile.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+compile.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+compile.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+compile.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+compile.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+compile.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+compile.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+compile.$(OBJEXT): $(top_srcdir)/prism/integer.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+compile.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+compile.$(OBJEXT): $(top_srcdir)/prism/json.h
+compile.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+compile.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+compile.$(OBJEXT): $(top_srcdir)/prism/node.h
+compile.$(OBJEXT): $(top_srcdir)/prism/options.h
+compile.$(OBJEXT): $(top_srcdir)/prism/parser.h
+compile.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+compile.$(OBJEXT): $(top_srcdir)/prism/prism.h
+compile.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+compile.$(OBJEXT): $(top_srcdir)/prism/source.h
+compile.$(OBJEXT): $(top_srcdir)/prism/stream.h
+compile.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+compile.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+compile.$(OBJEXT): $(top_srcdir)/prism/version.h
+compile.$(OBJEXT): $(top_srcdir)/prism_compile.c
+compile.$(OBJEXT): {$(VPATH)}assert.h
+compile.$(OBJEXT): {$(VPATH)}atomic.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+compile.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+compile.$(OBJEXT): {$(VPATH)}builtin.h
+compile.$(OBJEXT): {$(VPATH)}compile.c
+compile.$(OBJEXT): {$(VPATH)}config.h
+compile.$(OBJEXT): {$(VPATH)}constant.h
+compile.$(OBJEXT): {$(VPATH)}debug_counter.h
+compile.$(OBJEXT): {$(VPATH)}defines.h
+compile.$(OBJEXT): {$(VPATH)}encindex.h
+compile.$(OBJEXT): {$(VPATH)}encoding.h
+compile.$(OBJEXT): {$(VPATH)}id.h
+compile.$(OBJEXT): {$(VPATH)}id_table.h
+compile.$(OBJEXT): {$(VPATH)}insns.def
+compile.$(OBJEXT): {$(VPATH)}insns.inc
+compile.$(OBJEXT): {$(VPATH)}insns_info.inc
+compile.$(OBJEXT): {$(VPATH)}intern.h
+compile.$(OBJEXT): {$(VPATH)}internal.h
+compile.$(OBJEXT): {$(VPATH)}internal/abi.h
+compile.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+compile.$(OBJEXT): {$(VPATH)}internal/assume.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+compile.$(OBJEXT): {$(VPATH)}internal/cast.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+compile.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+compile.$(OBJEXT): {$(VPATH)}internal/config.h
+compile.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+compile.$(OBJEXT): {$(VPATH)}internal/core.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+compile.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+compile.$(OBJEXT): {$(VPATH)}internal/ctype.h
+compile.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+compile.$(OBJEXT): {$(VPATH)}internal/dosish.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+compile.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+compile.$(OBJEXT): {$(VPATH)}internal/error.h
+compile.$(OBJEXT): {$(VPATH)}internal/eval.h
+compile.$(OBJEXT): {$(VPATH)}internal/event.h
+compile.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+compile.$(OBJEXT): {$(VPATH)}internal/gc.h
+compile.$(OBJEXT): {$(VPATH)}internal/glob.h
+compile.$(OBJEXT): {$(VPATH)}internal/globals.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+compile.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+compile.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+compile.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+compile.$(OBJEXT): {$(VPATH)}internal/iterator.h
+compile.$(OBJEXT): {$(VPATH)}internal/memory.h
+compile.$(OBJEXT): {$(VPATH)}internal/method.h
+compile.$(OBJEXT): {$(VPATH)}internal/module.h
+compile.$(OBJEXT): {$(VPATH)}internal/newobj.h
+compile.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+compile.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+compile.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+compile.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+compile.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+compile.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+compile.$(OBJEXT): {$(VPATH)}internal/symbol.h
+compile.$(OBJEXT): {$(VPATH)}internal/value.h
+compile.$(OBJEXT): {$(VPATH)}internal/value_type.h
+compile.$(OBJEXT): {$(VPATH)}internal/variable.h
+compile.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+compile.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+compile.$(OBJEXT): {$(VPATH)}io.h
+compile.$(OBJEXT): {$(VPATH)}iseq.h
+compile.$(OBJEXT): {$(VPATH)}method.h
+compile.$(OBJEXT): {$(VPATH)}missing.h
+compile.$(OBJEXT): {$(VPATH)}node.h
+compile.$(OBJEXT): {$(VPATH)}onigmo.h
+compile.$(OBJEXT): {$(VPATH)}oniguruma.h
+compile.$(OBJEXT): {$(VPATH)}optinsn.inc
+compile.$(OBJEXT): {$(VPATH)}prism_compile.c
+compile.$(OBJEXT): {$(VPATH)}prism_compile.h
+compile.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+compile.$(OBJEXT): {$(VPATH)}ractor.h
+compile.$(OBJEXT): {$(VPATH)}re.h
+compile.$(OBJEXT): {$(VPATH)}regex.h
+compile.$(OBJEXT): {$(VPATH)}ruby_assert.h
+compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+compile.$(OBJEXT): {$(VPATH)}rubyparser.h
+compile.$(OBJEXT): {$(VPATH)}shape.h
+compile.$(OBJEXT): {$(VPATH)}st.h
+compile.$(OBJEXT): {$(VPATH)}subst.h
+compile.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+compile.$(OBJEXT): {$(VPATH)}thread_native.h
+compile.$(OBJEXT): {$(VPATH)}util.h
+compile.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+compile.$(OBJEXT): {$(VPATH)}vm_core.h
+compile.$(OBJEXT): {$(VPATH)}vm_debug.h
+compile.$(OBJEXT): {$(VPATH)}vm_opts.h
+compile.$(OBJEXT): {$(VPATH)}vm_sync.h
+compile.$(OBJEXT): {$(VPATH)}yjit.h
+complex.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+complex.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+complex.$(OBJEXT): $(CCAN_DIR)/list/list.h
+complex.$(OBJEXT): $(CCAN_DIR)/str/str.h
+complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+complex.$(OBJEXT): $(top_srcdir)/internal/array.h
+complex.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+complex.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+complex.$(OBJEXT): $(top_srcdir)/internal/bits.h
+complex.$(OBJEXT): $(top_srcdir)/internal/box.h
+complex.$(OBJEXT): $(top_srcdir)/internal/class.h
+complex.$(OBJEXT): $(top_srcdir)/internal/compar.h
+complex.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+complex.$(OBJEXT): $(top_srcdir)/internal/complex.h
+complex.$(OBJEXT): $(top_srcdir)/internal/error.h
+complex.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+complex.$(OBJEXT): $(top_srcdir)/internal/gc.h
+complex.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+complex.$(OBJEXT): $(top_srcdir)/internal/math.h
+complex.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+complex.$(OBJEXT): $(top_srcdir)/internal/object.h
+complex.$(OBJEXT): $(top_srcdir)/internal/rational.h
+complex.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+complex.$(OBJEXT): $(top_srcdir)/internal/serial.h
+complex.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+complex.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+complex.$(OBJEXT): $(top_srcdir)/internal/string.h
+complex.$(OBJEXT): $(top_srcdir)/internal/struct.h
+complex.$(OBJEXT): $(top_srcdir)/internal/variable.h
+complex.$(OBJEXT): $(top_srcdir)/internal/vm.h
+complex.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+complex.$(OBJEXT): {$(VPATH)}assert.h
+complex.$(OBJEXT): {$(VPATH)}atomic.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+complex.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+complex.$(OBJEXT): {$(VPATH)}complex.c
+complex.$(OBJEXT): {$(VPATH)}config.h
+complex.$(OBJEXT): {$(VPATH)}constant.h
+complex.$(OBJEXT): {$(VPATH)}debug_counter.h
+complex.$(OBJEXT): {$(VPATH)}defines.h
+complex.$(OBJEXT): {$(VPATH)}encindex.h
+complex.$(OBJEXT): {$(VPATH)}encoding.h
+complex.$(OBJEXT): {$(VPATH)}id.h
+complex.$(OBJEXT): {$(VPATH)}id_table.h
+complex.$(OBJEXT): {$(VPATH)}intern.h
+complex.$(OBJEXT): {$(VPATH)}internal.h
+complex.$(OBJEXT): {$(VPATH)}internal/abi.h
+complex.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+complex.$(OBJEXT): {$(VPATH)}internal/assume.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+complex.$(OBJEXT): {$(VPATH)}internal/cast.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+complex.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+complex.$(OBJEXT): {$(VPATH)}internal/config.h
+complex.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+complex.$(OBJEXT): {$(VPATH)}internal/core.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+complex.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+complex.$(OBJEXT): {$(VPATH)}internal/ctype.h
+complex.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+complex.$(OBJEXT): {$(VPATH)}internal/dosish.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+complex.$(OBJEXT): {$(VPATH)}internal/error.h
+complex.$(OBJEXT): {$(VPATH)}internal/eval.h
+complex.$(OBJEXT): {$(VPATH)}internal/event.h
+complex.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+complex.$(OBJEXT): {$(VPATH)}internal/gc.h
+complex.$(OBJEXT): {$(VPATH)}internal/glob.h
+complex.$(OBJEXT): {$(VPATH)}internal/globals.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+complex.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+complex.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+complex.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+complex.$(OBJEXT): {$(VPATH)}internal/iterator.h
+complex.$(OBJEXT): {$(VPATH)}internal/memory.h
+complex.$(OBJEXT): {$(VPATH)}internal/method.h
+complex.$(OBJEXT): {$(VPATH)}internal/module.h
+complex.$(OBJEXT): {$(VPATH)}internal/newobj.h
+complex.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+complex.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+complex.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+complex.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+complex.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+complex.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+complex.$(OBJEXT): {$(VPATH)}internal/symbol.h
+complex.$(OBJEXT): {$(VPATH)}internal/value.h
+complex.$(OBJEXT): {$(VPATH)}internal/value_type.h
+complex.$(OBJEXT): {$(VPATH)}internal/variable.h
+complex.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+complex.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+complex.$(OBJEXT): {$(VPATH)}method.h
+complex.$(OBJEXT): {$(VPATH)}missing.h
+complex.$(OBJEXT): {$(VPATH)}node.h
+complex.$(OBJEXT): {$(VPATH)}onigmo.h
+complex.$(OBJEXT): {$(VPATH)}oniguruma.h
+complex.$(OBJEXT): {$(VPATH)}ruby_assert.h
+complex.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+complex.$(OBJEXT): {$(VPATH)}rubyparser.h
+complex.$(OBJEXT): {$(VPATH)}shape.h
+complex.$(OBJEXT): {$(VPATH)}st.h
+complex.$(OBJEXT): {$(VPATH)}subst.h
+complex.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+complex.$(OBJEXT): {$(VPATH)}thread_native.h
+complex.$(OBJEXT): {$(VPATH)}vm_core.h
+complex.$(OBJEXT): {$(VPATH)}vm_debug.h
+complex.$(OBJEXT): {$(VPATH)}vm_opts.h
+complex.$(OBJEXT): {$(VPATH)}vm_sync.h
+concurrent_set.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+concurrent_set.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+concurrent_set.$(OBJEXT): $(CCAN_DIR)/list/list.h
+concurrent_set.$(OBJEXT): $(CCAN_DIR)/str/str.h
+concurrent_set.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/array.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/box.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/concurrent_set.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/gc.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/serial.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/vm.h
+concurrent_set.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+concurrent_set.$(OBJEXT): {$(VPATH)}assert.h
+concurrent_set.$(OBJEXT): {$(VPATH)}atomic.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+concurrent_set.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+concurrent_set.$(OBJEXT): {$(VPATH)}concurrent_set.c
+concurrent_set.$(OBJEXT): {$(VPATH)}config.h
+concurrent_set.$(OBJEXT): {$(VPATH)}debug_counter.h
+concurrent_set.$(OBJEXT): {$(VPATH)}defines.h
+concurrent_set.$(OBJEXT): {$(VPATH)}encindex.h
+concurrent_set.$(OBJEXT): {$(VPATH)}encoding.h
+concurrent_set.$(OBJEXT): {$(VPATH)}id.h
+concurrent_set.$(OBJEXT): {$(VPATH)}id_table.h
+concurrent_set.$(OBJEXT): {$(VPATH)}intern.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/abi.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/assume.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/cast.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/config.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/ctype.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/dosish.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/error.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/eval.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/event.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/gc.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/glob.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/globals.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/iterator.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/memory.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/method.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/module.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/newobj.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/symbol.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/value.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/value_type.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/variable.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+concurrent_set.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+concurrent_set.$(OBJEXT): {$(VPATH)}method.h
+concurrent_set.$(OBJEXT): {$(VPATH)}missing.h
+concurrent_set.$(OBJEXT): {$(VPATH)}node.h
+concurrent_set.$(OBJEXT): {$(VPATH)}onigmo.h
+concurrent_set.$(OBJEXT): {$(VPATH)}oniguruma.h
+concurrent_set.$(OBJEXT): {$(VPATH)}ruby_assert.h
+concurrent_set.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+concurrent_set.$(OBJEXT): {$(VPATH)}rubyparser.h
+concurrent_set.$(OBJEXT): {$(VPATH)}st.h
+concurrent_set.$(OBJEXT): {$(VPATH)}subst.h
+concurrent_set.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+concurrent_set.$(OBJEXT): {$(VPATH)}thread_native.h
+concurrent_set.$(OBJEXT): {$(VPATH)}vm_core.h
+concurrent_set.$(OBJEXT): {$(VPATH)}vm_debug.h
+concurrent_set.$(OBJEXT): {$(VPATH)}vm_opts.h
+concurrent_set.$(OBJEXT): {$(VPATH)}vm_sync.h
+cont.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+cont.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+cont.$(OBJEXT): $(CCAN_DIR)/list/list.h
+cont.$(OBJEXT): $(CCAN_DIR)/str/str.h
+cont.$(OBJEXT): $(hdrdir)/ruby.h
+cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+cont.$(OBJEXT): $(hdrdir)/ruby/version.h
+cont.$(OBJEXT): $(top_srcdir)/internal/array.h
+cont.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+cont.$(OBJEXT): $(top_srcdir)/internal/box.h
+cont.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+cont.$(OBJEXT): $(top_srcdir)/internal/cont.h
+cont.$(OBJEXT): $(top_srcdir)/internal/error.h
+cont.$(OBJEXT): $(top_srcdir)/internal/eval.h
+cont.$(OBJEXT): $(top_srcdir)/internal/gc.h
+cont.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+cont.$(OBJEXT): $(top_srcdir)/internal/proc.h
+cont.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+cont.$(OBJEXT): $(top_srcdir)/internal/serial.h
+cont.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+cont.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+cont.$(OBJEXT): $(top_srcdir)/internal/string.h
+cont.$(OBJEXT): $(top_srcdir)/internal/struct.h
+cont.$(OBJEXT): $(top_srcdir)/internal/thread.h
+cont.$(OBJEXT): $(top_srcdir)/internal/variable.h
+cont.$(OBJEXT): $(top_srcdir)/internal/vm.h
+cont.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+cont.$(OBJEXT): $(top_srcdir)/prism/arena.h
+cont.$(OBJEXT): $(top_srcdir)/prism/ast.h
+cont.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+cont.$(OBJEXT): $(top_srcdir)/prism/comments.h
+cont.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+cont.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+cont.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+cont.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+cont.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+cont.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+cont.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+cont.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+cont.$(OBJEXT): $(top_srcdir)/prism/integer.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+cont.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+cont.$(OBJEXT): $(top_srcdir)/prism/json.h
+cont.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+cont.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+cont.$(OBJEXT): $(top_srcdir)/prism/node.h
+cont.$(OBJEXT): $(top_srcdir)/prism/options.h
+cont.$(OBJEXT): $(top_srcdir)/prism/parser.h
+cont.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+cont.$(OBJEXT): $(top_srcdir)/prism/prism.h
+cont.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+cont.$(OBJEXT): $(top_srcdir)/prism/source.h
+cont.$(OBJEXT): $(top_srcdir)/prism/stream.h
+cont.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+cont.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+cont.$(OBJEXT): $(top_srcdir)/prism/version.h
+cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
+cont.$(OBJEXT): {$(VPATH)}assert.h
+cont.$(OBJEXT): {$(VPATH)}atomic.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+cont.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+cont.$(OBJEXT): {$(VPATH)}config.h
+cont.$(OBJEXT): {$(VPATH)}constant.h
+cont.$(OBJEXT): {$(VPATH)}cont.c
+cont.$(OBJEXT): {$(VPATH)}debug_counter.h
+cont.$(OBJEXT): {$(VPATH)}defines.h
+cont.$(OBJEXT): {$(VPATH)}encindex.h
+cont.$(OBJEXT): {$(VPATH)}encoding.h
+cont.$(OBJEXT): {$(VPATH)}eval_intern.h
+cont.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+cont.$(OBJEXT): {$(VPATH)}id.h
+cont.$(OBJEXT): {$(VPATH)}id_table.h
+cont.$(OBJEXT): {$(VPATH)}intern.h
+cont.$(OBJEXT): {$(VPATH)}internal.h
+cont.$(OBJEXT): {$(VPATH)}internal/abi.h
+cont.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+cont.$(OBJEXT): {$(VPATH)}internal/assume.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+cont.$(OBJEXT): {$(VPATH)}internal/cast.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+cont.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+cont.$(OBJEXT): {$(VPATH)}internal/config.h
+cont.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+cont.$(OBJEXT): {$(VPATH)}internal/core.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+cont.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+cont.$(OBJEXT): {$(VPATH)}internal/ctype.h
+cont.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+cont.$(OBJEXT): {$(VPATH)}internal/dosish.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+cont.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+cont.$(OBJEXT): {$(VPATH)}internal/error.h
+cont.$(OBJEXT): {$(VPATH)}internal/eval.h
+cont.$(OBJEXT): {$(VPATH)}internal/event.h
+cont.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+cont.$(OBJEXT): {$(VPATH)}internal/gc.h
+cont.$(OBJEXT): {$(VPATH)}internal/glob.h
+cont.$(OBJEXT): {$(VPATH)}internal/globals.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+cont.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+cont.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+cont.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+cont.$(OBJEXT): {$(VPATH)}internal/iterator.h
+cont.$(OBJEXT): {$(VPATH)}internal/memory.h
+cont.$(OBJEXT): {$(VPATH)}internal/method.h
+cont.$(OBJEXT): {$(VPATH)}internal/module.h
+cont.$(OBJEXT): {$(VPATH)}internal/newobj.h
+cont.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+cont.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+cont.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+cont.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+cont.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+cont.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+cont.$(OBJEXT): {$(VPATH)}internal/symbol.h
+cont.$(OBJEXT): {$(VPATH)}internal/value.h
+cont.$(OBJEXT): {$(VPATH)}internal/value_type.h
+cont.$(OBJEXT): {$(VPATH)}internal/variable.h
+cont.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+cont.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+cont.$(OBJEXT): {$(VPATH)}iseq.h
+cont.$(OBJEXT): {$(VPATH)}method.h
+cont.$(OBJEXT): {$(VPATH)}missing.h
+cont.$(OBJEXT): {$(VPATH)}node.h
+cont.$(OBJEXT): {$(VPATH)}onigmo.h
+cont.$(OBJEXT): {$(VPATH)}oniguruma.h
+cont.$(OBJEXT): {$(VPATH)}prism_compile.h
+cont.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+cont.$(OBJEXT): {$(VPATH)}ractor.h
+cont.$(OBJEXT): {$(VPATH)}ractor_core.h
+cont.$(OBJEXT): {$(VPATH)}ruby_assert.h
+cont.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+cont.$(OBJEXT): {$(VPATH)}rubyparser.h
+cont.$(OBJEXT): {$(VPATH)}shape.h
+cont.$(OBJEXT): {$(VPATH)}st.h
+cont.$(OBJEXT): {$(VPATH)}subst.h
+cont.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+cont.$(OBJEXT): {$(VPATH)}thread_native.h
+cont.$(OBJEXT): {$(VPATH)}vm_core.h
+cont.$(OBJEXT): {$(VPATH)}vm_debug.h
+cont.$(OBJEXT): {$(VPATH)}vm_opts.h
+cont.$(OBJEXT): {$(VPATH)}vm_sync.h
+cont.$(OBJEXT): {$(VPATH)}yjit.h
+cont.$(OBJEXT): {$(VPATH)}zjit.h
+debug.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+debug.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+debug.$(OBJEXT): $(CCAN_DIR)/list/list.h
+debug.$(OBJEXT): $(CCAN_DIR)/str/str.h
+debug.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+debug.$(OBJEXT): $(top_srcdir)/internal/array.h
+debug.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+debug.$(OBJEXT): $(top_srcdir)/internal/box.h
+debug.$(OBJEXT): $(top_srcdir)/internal/class.h
+debug.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+debug.$(OBJEXT): $(top_srcdir)/internal/gc.h
+debug.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+debug.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+debug.$(OBJEXT): $(top_srcdir)/internal/serial.h
+debug.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+debug.$(OBJEXT): $(top_srcdir)/internal/signal.h
+debug.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+debug.$(OBJEXT): $(top_srcdir)/internal/struct.h
+debug.$(OBJEXT): $(top_srcdir)/internal/variable.h
+debug.$(OBJEXT): $(top_srcdir)/internal/vm.h
+debug.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+debug.$(OBJEXT): {$(VPATH)}assert.h
+debug.$(OBJEXT): {$(VPATH)}atomic.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+debug.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+debug.$(OBJEXT): {$(VPATH)}config.h
+debug.$(OBJEXT): {$(VPATH)}constant.h
+debug.$(OBJEXT): {$(VPATH)}debug.c
+debug.$(OBJEXT): {$(VPATH)}debug_counter.h
+debug.$(OBJEXT): {$(VPATH)}defines.h
+debug.$(OBJEXT): {$(VPATH)}encindex.h
+debug.$(OBJEXT): {$(VPATH)}encoding.h
+debug.$(OBJEXT): {$(VPATH)}eval_intern.h
+debug.$(OBJEXT): {$(VPATH)}id.h
+debug.$(OBJEXT): {$(VPATH)}id_table.h
+debug.$(OBJEXT): {$(VPATH)}intern.h
+debug.$(OBJEXT): {$(VPATH)}internal.h
+debug.$(OBJEXT): {$(VPATH)}internal/abi.h
+debug.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+debug.$(OBJEXT): {$(VPATH)}internal/assume.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+debug.$(OBJEXT): {$(VPATH)}internal/cast.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+debug.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+debug.$(OBJEXT): {$(VPATH)}internal/config.h
+debug.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+debug.$(OBJEXT): {$(VPATH)}internal/core.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+debug.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+debug.$(OBJEXT): {$(VPATH)}internal/ctype.h
+debug.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+debug.$(OBJEXT): {$(VPATH)}internal/dosish.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+debug.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+debug.$(OBJEXT): {$(VPATH)}internal/error.h
+debug.$(OBJEXT): {$(VPATH)}internal/eval.h
+debug.$(OBJEXT): {$(VPATH)}internal/event.h
+debug.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+debug.$(OBJEXT): {$(VPATH)}internal/gc.h
+debug.$(OBJEXT): {$(VPATH)}internal/glob.h
+debug.$(OBJEXT): {$(VPATH)}internal/globals.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+debug.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+debug.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+debug.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+debug.$(OBJEXT): {$(VPATH)}internal/iterator.h
+debug.$(OBJEXT): {$(VPATH)}internal/memory.h
+debug.$(OBJEXT): {$(VPATH)}internal/method.h
+debug.$(OBJEXT): {$(VPATH)}internal/module.h
+debug.$(OBJEXT): {$(VPATH)}internal/newobj.h
+debug.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+debug.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+debug.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+debug.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+debug.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+debug.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+debug.$(OBJEXT): {$(VPATH)}internal/symbol.h
+debug.$(OBJEXT): {$(VPATH)}internal/value.h
+debug.$(OBJEXT): {$(VPATH)}internal/value_type.h
+debug.$(OBJEXT): {$(VPATH)}internal/variable.h
+debug.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+debug.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+debug.$(OBJEXT): {$(VPATH)}io.h
+debug.$(OBJEXT): {$(VPATH)}method.h
+debug.$(OBJEXT): {$(VPATH)}missing.h
+debug.$(OBJEXT): {$(VPATH)}node.h
+debug.$(OBJEXT): {$(VPATH)}onigmo.h
+debug.$(OBJEXT): {$(VPATH)}oniguruma.h
+debug.$(OBJEXT): {$(VPATH)}ractor.h
+debug.$(OBJEXT): {$(VPATH)}ractor_core.h
+debug.$(OBJEXT): {$(VPATH)}ruby_assert.h
+debug.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+debug.$(OBJEXT): {$(VPATH)}rubyparser.h
+debug.$(OBJEXT): {$(VPATH)}shape.h
+debug.$(OBJEXT): {$(VPATH)}st.h
+debug.$(OBJEXT): {$(VPATH)}subst.h
+debug.$(OBJEXT): {$(VPATH)}symbol.h
+debug.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+debug.$(OBJEXT): {$(VPATH)}thread_native.h
+debug.$(OBJEXT): {$(VPATH)}util.h
+debug.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+debug.$(OBJEXT): {$(VPATH)}vm_core.h
+debug.$(OBJEXT): {$(VPATH)}vm_debug.h
+debug.$(OBJEXT): {$(VPATH)}vm_opts.h
+debug.$(OBJEXT): {$(VPATH)}vm_sync.h
+debug.$(OBJEXT): {$(VPATH)}zjit.h
+debug_counter.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+debug_counter.$(OBJEXT): {$(VPATH)}assert.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+debug_counter.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+debug_counter.$(OBJEXT): {$(VPATH)}config.h
+debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.c
+debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.h
+debug_counter.$(OBJEXT): {$(VPATH)}defines.h
+debug_counter.$(OBJEXT): {$(VPATH)}intern.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/abi.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/assume.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/cast.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/config.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/ctype.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/dosish.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/error.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/eval.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/event.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/gc.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/glob.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/globals.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/iterator.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/memory.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/method.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/module.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/newobj.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/symbol.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/value.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/value_type.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/variable.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+debug_counter.$(OBJEXT): {$(VPATH)}missing.h
+debug_counter.$(OBJEXT): {$(VPATH)}st.h
+debug_counter.$(OBJEXT): {$(VPATH)}subst.h
+debug_counter.$(OBJEXT): {$(VPATH)}thread_native.h
+dir.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+dir.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+dir.$(OBJEXT): $(CCAN_DIR)/list/list.h
+dir.$(OBJEXT): $(CCAN_DIR)/str/str.h
+dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+dir.$(OBJEXT): $(hdrdir)/ruby/version.h
+dir.$(OBJEXT): $(top_srcdir)/internal/array.h
+dir.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+dir.$(OBJEXT): $(top_srcdir)/internal/box.h
+dir.$(OBJEXT): $(top_srcdir)/internal/class.h
+dir.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+dir.$(OBJEXT): $(top_srcdir)/internal/dir.h
+dir.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+dir.$(OBJEXT): $(top_srcdir)/internal/error.h
+dir.$(OBJEXT): $(top_srcdir)/internal/file.h
+dir.$(OBJEXT): $(top_srcdir)/internal/gc.h
+dir.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+dir.$(OBJEXT): $(top_srcdir)/internal/io.h
+dir.$(OBJEXT): $(top_srcdir)/internal/object.h
+dir.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+dir.$(OBJEXT): $(top_srcdir)/internal/serial.h
+dir.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+dir.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+dir.$(OBJEXT): $(top_srcdir)/internal/string.h
+dir.$(OBJEXT): $(top_srcdir)/internal/variable.h
+dir.$(OBJEXT): $(top_srcdir)/internal/vm.h
+dir.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+dir.$(OBJEXT): {$(VPATH)}assert.h
+dir.$(OBJEXT): {$(VPATH)}atomic.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+dir.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+dir.$(OBJEXT): {$(VPATH)}builtin.h
+dir.$(OBJEXT): {$(VPATH)}config.h
+dir.$(OBJEXT): {$(VPATH)}constant.h
+dir.$(OBJEXT): {$(VPATH)}defines.h
+dir.$(OBJEXT): {$(VPATH)}dir.c
+dir.$(OBJEXT): {$(VPATH)}dir.rbinc
+dir.$(OBJEXT): {$(VPATH)}encindex.h
+dir.$(OBJEXT): {$(VPATH)}encoding.h
+dir.$(OBJEXT): {$(VPATH)}id.h
+dir.$(OBJEXT): {$(VPATH)}id_table.h
+dir.$(OBJEXT): {$(VPATH)}intern.h
+dir.$(OBJEXT): {$(VPATH)}internal.h
+dir.$(OBJEXT): {$(VPATH)}internal/abi.h
+dir.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+dir.$(OBJEXT): {$(VPATH)}internal/assume.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+dir.$(OBJEXT): {$(VPATH)}internal/cast.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+dir.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+dir.$(OBJEXT): {$(VPATH)}internal/config.h
+dir.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+dir.$(OBJEXT): {$(VPATH)}internal/core.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+dir.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+dir.$(OBJEXT): {$(VPATH)}internal/ctype.h
+dir.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+dir.$(OBJEXT): {$(VPATH)}internal/dosish.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+dir.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+dir.$(OBJEXT): {$(VPATH)}internal/error.h
+dir.$(OBJEXT): {$(VPATH)}internal/eval.h
+dir.$(OBJEXT): {$(VPATH)}internal/event.h
+dir.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+dir.$(OBJEXT): {$(VPATH)}internal/gc.h
+dir.$(OBJEXT): {$(VPATH)}internal/glob.h
+dir.$(OBJEXT): {$(VPATH)}internal/globals.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+dir.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+dir.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+dir.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+dir.$(OBJEXT): {$(VPATH)}internal/iterator.h
+dir.$(OBJEXT): {$(VPATH)}internal/memory.h
+dir.$(OBJEXT): {$(VPATH)}internal/method.h
+dir.$(OBJEXT): {$(VPATH)}internal/module.h
+dir.$(OBJEXT): {$(VPATH)}internal/newobj.h
+dir.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+dir.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+dir.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+dir.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+dir.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+dir.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+dir.$(OBJEXT): {$(VPATH)}internal/symbol.h
+dir.$(OBJEXT): {$(VPATH)}internal/value.h
+dir.$(OBJEXT): {$(VPATH)}internal/value_type.h
+dir.$(OBJEXT): {$(VPATH)}internal/variable.h
+dir.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+dir.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+dir.$(OBJEXT): {$(VPATH)}io.h
+dir.$(OBJEXT): {$(VPATH)}method.h
+dir.$(OBJEXT): {$(VPATH)}missing.h
+dir.$(OBJEXT): {$(VPATH)}node.h
+dir.$(OBJEXT): {$(VPATH)}onigmo.h
+dir.$(OBJEXT): {$(VPATH)}oniguruma.h
+dir.$(OBJEXT): {$(VPATH)}ruby_assert.h
+dir.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+dir.$(OBJEXT): {$(VPATH)}rubyparser.h
+dir.$(OBJEXT): {$(VPATH)}shape.h
+dir.$(OBJEXT): {$(VPATH)}st.h
+dir.$(OBJEXT): {$(VPATH)}subst.h
+dir.$(OBJEXT): {$(VPATH)}thread.h
+dir.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+dir.$(OBJEXT): {$(VPATH)}thread_native.h
+dir.$(OBJEXT): {$(VPATH)}util.h
+dir.$(OBJEXT): {$(VPATH)}vm_core.h
+dir.$(OBJEXT): {$(VPATH)}vm_opts.h
+dln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+dln.$(OBJEXT): $(top_srcdir)/internal/box.h
+dln.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+dln.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+dln.$(OBJEXT): {$(VPATH)}assert.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+dln.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+dln.$(OBJEXT): {$(VPATH)}config.h
+dln.$(OBJEXT): {$(VPATH)}defines.h
+dln.$(OBJEXT): {$(VPATH)}dln.c
+dln.$(OBJEXT): {$(VPATH)}dln.h
+dln.$(OBJEXT): {$(VPATH)}intern.h
+dln.$(OBJEXT): {$(VPATH)}internal.h
+dln.$(OBJEXT): {$(VPATH)}internal/abi.h
+dln.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+dln.$(OBJEXT): {$(VPATH)}internal/assume.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+dln.$(OBJEXT): {$(VPATH)}internal/cast.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+dln.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+dln.$(OBJEXT): {$(VPATH)}internal/config.h
+dln.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+dln.$(OBJEXT): {$(VPATH)}internal/core.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+dln.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+dln.$(OBJEXT): {$(VPATH)}internal/ctype.h
+dln.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+dln.$(OBJEXT): {$(VPATH)}internal/dosish.h
+dln.$(OBJEXT): {$(VPATH)}internal/error.h
+dln.$(OBJEXT): {$(VPATH)}internal/eval.h
+dln.$(OBJEXT): {$(VPATH)}internal/event.h
+dln.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+dln.$(OBJEXT): {$(VPATH)}internal/gc.h
+dln.$(OBJEXT): {$(VPATH)}internal/glob.h
+dln.$(OBJEXT): {$(VPATH)}internal/globals.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+dln.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+dln.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+dln.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+dln.$(OBJEXT): {$(VPATH)}internal/iterator.h
+dln.$(OBJEXT): {$(VPATH)}internal/memory.h
+dln.$(OBJEXT): {$(VPATH)}internal/method.h
+dln.$(OBJEXT): {$(VPATH)}internal/module.h
+dln.$(OBJEXT): {$(VPATH)}internal/newobj.h
+dln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+dln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+dln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+dln.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+dln.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+dln.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+dln.$(OBJEXT): {$(VPATH)}internal/symbol.h
+dln.$(OBJEXT): {$(VPATH)}internal/value.h
+dln.$(OBJEXT): {$(VPATH)}internal/value_type.h
+dln.$(OBJEXT): {$(VPATH)}internal/variable.h
+dln.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+dln.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+dln.$(OBJEXT): {$(VPATH)}missing.h
+dln.$(OBJEXT): {$(VPATH)}st.h
+dln.$(OBJEXT): {$(VPATH)}subst.h
+dln_find.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+dln_find.$(OBJEXT): {$(VPATH)}assert.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+dln_find.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+dln_find.$(OBJEXT): {$(VPATH)}config.h
+dln_find.$(OBJEXT): {$(VPATH)}defines.h
+dln_find.$(OBJEXT): {$(VPATH)}dln.h
+dln_find.$(OBJEXT): {$(VPATH)}dln_find.c
+dln_find.$(OBJEXT): {$(VPATH)}intern.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/abi.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/assume.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/cast.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/config.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/ctype.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/dosish.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/error.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/eval.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/event.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/gc.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/glob.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/globals.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/iterator.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/memory.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/method.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/module.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/newobj.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/symbol.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/value.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/value_type.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/variable.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+dln_find.$(OBJEXT): {$(VPATH)}missing.h
+dln_find.$(OBJEXT): {$(VPATH)}st.h
+dln_find.$(OBJEXT): {$(VPATH)}subst.h
+dmydln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+dmydln.$(OBJEXT): {$(VPATH)}assert.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+dmydln.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+dmydln.$(OBJEXT): {$(VPATH)}config.h
+dmydln.$(OBJEXT): {$(VPATH)}defines.h
+dmydln.$(OBJEXT): {$(VPATH)}dmydln.c
+dmydln.$(OBJEXT): {$(VPATH)}intern.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/abi.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/assume.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/cast.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/config.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/ctype.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/dosish.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/error.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/eval.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/event.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/gc.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/glob.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/globals.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/iterator.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/memory.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/method.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/module.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/newobj.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/symbol.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/value.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/value_type.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/variable.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+dmydln.$(OBJEXT): {$(VPATH)}missing.h
+dmydln.$(OBJEXT): {$(VPATH)}st.h
+dmydln.$(OBJEXT): {$(VPATH)}subst.h
+dmyenc.$(OBJEXT): {$(VPATH)}dmyenc.c
+dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/arena.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/ast.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/comments.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/integer.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/json.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/node.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/options.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/parser.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/prism.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/source.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/stream.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/prism/version.h
+dump_ast-dump_ast.$(OBJEXT): $(top_srcdir)/tool/dump_ast.c
+enc/ascii.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/ascii.$(OBJEXT): {$(VPATH)}assert.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enc/ascii.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enc/ascii.$(OBJEXT): {$(VPATH)}config.h
+enc/ascii.$(OBJEXT): {$(VPATH)}defines.h
+enc/ascii.$(OBJEXT): {$(VPATH)}enc/ascii.c
+enc/ascii.$(OBJEXT): {$(VPATH)}encindex.h
+enc/ascii.$(OBJEXT): {$(VPATH)}encoding.h
+enc/ascii.$(OBJEXT): {$(VPATH)}intern.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/assume.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/cast.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/config.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/error.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/eval.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/event.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/gc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/glob.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/globals.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/method.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/module.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/value.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/variable.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enc/ascii.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}missing.h
+enc/ascii.$(OBJEXT): {$(VPATH)}onigmo.h
+enc/ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
+enc/ascii.$(OBJEXT): {$(VPATH)}regenc.h
+enc/ascii.$(OBJEXT): {$(VPATH)}st.h
+enc/ascii.$(OBJEXT): {$(VPATH)}subst.h
+enc/trans/newline.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}assert.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}config.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}defines.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}enc/trans/newline.c
+enc/trans/newline.$(OBJEXT): {$(VPATH)}intern.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/assume.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/cast.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/config.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/error.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/eval.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/event.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/gc.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/glob.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/globals.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/memory.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/method.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/module.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/value.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/variable.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}missing.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}st.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}subst.h
+enc/trans/newline.$(OBJEXT): {$(VPATH)}transcode_data.h
+enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/casefold.h
+enc/unicode.$(OBJEXT): $(UNICODE_HDR_DIR)/name2ctype.h
+enc/unicode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/unicode.$(OBJEXT): {$(VPATH)}assert.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enc/unicode.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enc/unicode.$(OBJEXT): {$(VPATH)}config.h
+enc/unicode.$(OBJEXT): {$(VPATH)}defines.h
+enc/unicode.$(OBJEXT): {$(VPATH)}enc/unicode.c
+enc/unicode.$(OBJEXT): {$(VPATH)}intern.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/assume.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/cast.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/config.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/error.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/eval.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/event.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/gc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/glob.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/globals.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/memory.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/method.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/module.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/value.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/variable.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enc/unicode.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}missing.h
+enc/unicode.$(OBJEXT): {$(VPATH)}onigmo.h
+enc/unicode.$(OBJEXT): {$(VPATH)}regenc.h
+enc/unicode.$(OBJEXT): {$(VPATH)}regint.h
+enc/unicode.$(OBJEXT): {$(VPATH)}st.h
+enc/unicode.$(OBJEXT): {$(VPATH)}subst.h
+enc/us_ascii.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}assert.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}config.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}defines.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}enc/us_ascii.c
+enc/us_ascii.$(OBJEXT): {$(VPATH)}encindex.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}encoding.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}intern.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/assume.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/cast.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/config.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/error.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/eval.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/event.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/gc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/glob.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/globals.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/method.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/module.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/value.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/variable.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}missing.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}onigmo.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}oniguruma.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}regenc.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}st.h
+enc/us_ascii.$(OBJEXT): {$(VPATH)}subst.h
+enc/utf_8.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}assert.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}config.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}defines.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}enc/utf_8.c
+enc/utf_8.$(OBJEXT): {$(VPATH)}encindex.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}encoding.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}intern.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/assume.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/cast.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/config.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/error.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/eval.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/event.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/gc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/glob.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/globals.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/memory.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/method.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/module.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/value.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/variable.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}missing.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}onigmo.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}st.h
+enc/utf_8.$(OBJEXT): {$(VPATH)}subst.h
+encoding.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+encoding.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+encoding.$(OBJEXT): $(CCAN_DIR)/list/list.h
+encoding.$(OBJEXT): $(CCAN_DIR)/str/str.h
+encoding.$(OBJEXT): $(hdrdir)/ruby.h
+encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+encoding.$(OBJEXT): $(hdrdir)/ruby/version.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/array.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/class.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/enc.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/error.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/gc.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/inits.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/load.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/object.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/serial.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/string.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/variable.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/vm.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+encoding.$(OBJEXT): {$(VPATH)}assert.h
+encoding.$(OBJEXT): {$(VPATH)}atomic.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+encoding.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+encoding.$(OBJEXT): {$(VPATH)}config.h
+encoding.$(OBJEXT): {$(VPATH)}constant.h
+encoding.$(OBJEXT): {$(VPATH)}debug_counter.h
+encoding.$(OBJEXT): {$(VPATH)}defines.h
+encoding.$(OBJEXT): {$(VPATH)}encindex.h
+encoding.$(OBJEXT): {$(VPATH)}encoding.c
+encoding.$(OBJEXT): {$(VPATH)}encoding.h
+encoding.$(OBJEXT): {$(VPATH)}id.h
+encoding.$(OBJEXT): {$(VPATH)}id_table.h
+encoding.$(OBJEXT): {$(VPATH)}intern.h
+encoding.$(OBJEXT): {$(VPATH)}internal.h
+encoding.$(OBJEXT): {$(VPATH)}internal/abi.h
+encoding.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+encoding.$(OBJEXT): {$(VPATH)}internal/assume.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+encoding.$(OBJEXT): {$(VPATH)}internal/cast.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+encoding.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+encoding.$(OBJEXT): {$(VPATH)}internal/config.h
+encoding.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+encoding.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+encoding.$(OBJEXT): {$(VPATH)}internal/ctype.h
+encoding.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+encoding.$(OBJEXT): {$(VPATH)}internal/dosish.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+encoding.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+encoding.$(OBJEXT): {$(VPATH)}internal/error.h
+encoding.$(OBJEXT): {$(VPATH)}internal/eval.h
+encoding.$(OBJEXT): {$(VPATH)}internal/event.h
+encoding.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+encoding.$(OBJEXT): {$(VPATH)}internal/gc.h
+encoding.$(OBJEXT): {$(VPATH)}internal/glob.h
+encoding.$(OBJEXT): {$(VPATH)}internal/globals.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+encoding.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+encoding.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+encoding.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+encoding.$(OBJEXT): {$(VPATH)}internal/iterator.h
+encoding.$(OBJEXT): {$(VPATH)}internal/memory.h
+encoding.$(OBJEXT): {$(VPATH)}internal/method.h
+encoding.$(OBJEXT): {$(VPATH)}internal/module.h
+encoding.$(OBJEXT): {$(VPATH)}internal/newobj.h
+encoding.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+encoding.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+encoding.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+encoding.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+encoding.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+encoding.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+encoding.$(OBJEXT): {$(VPATH)}internal/symbol.h
+encoding.$(OBJEXT): {$(VPATH)}internal/value.h
+encoding.$(OBJEXT): {$(VPATH)}internal/value_type.h
+encoding.$(OBJEXT): {$(VPATH)}internal/variable.h
+encoding.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+encoding.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+encoding.$(OBJEXT): {$(VPATH)}method.h
+encoding.$(OBJEXT): {$(VPATH)}missing.h
+encoding.$(OBJEXT): {$(VPATH)}node.h
+encoding.$(OBJEXT): {$(VPATH)}onigmo.h
+encoding.$(OBJEXT): {$(VPATH)}oniguruma.h
+encoding.$(OBJEXT): {$(VPATH)}ractor.h
+encoding.$(OBJEXT): {$(VPATH)}regenc.h
+encoding.$(OBJEXT): {$(VPATH)}ruby_assert.h
+encoding.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+encoding.$(OBJEXT): {$(VPATH)}rubyparser.h
+encoding.$(OBJEXT): {$(VPATH)}shape.h
+encoding.$(OBJEXT): {$(VPATH)}st.h
+encoding.$(OBJEXT): {$(VPATH)}subst.h
+encoding.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+encoding.$(OBJEXT): {$(VPATH)}thread_native.h
+encoding.$(OBJEXT): {$(VPATH)}util.h
+encoding.$(OBJEXT): {$(VPATH)}vm_core.h
+encoding.$(OBJEXT): {$(VPATH)}vm_debug.h
+encoding.$(OBJEXT): {$(VPATH)}vm_opts.h
+encoding.$(OBJEXT): {$(VPATH)}vm_sync.h
+enum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enum.$(OBJEXT): $(top_srcdir)/internal/array.h
+enum.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+enum.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+enum.$(OBJEXT): $(top_srcdir)/internal/bits.h
+enum.$(OBJEXT): $(top_srcdir)/internal/class.h
+enum.$(OBJEXT): $(top_srcdir)/internal/compar.h
+enum.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+enum.$(OBJEXT): $(top_srcdir)/internal/enum.h
+enum.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+enum.$(OBJEXT): $(top_srcdir)/internal/gc.h
+enum.$(OBJEXT): $(top_srcdir)/internal/hash.h
+enum.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+enum.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+enum.$(OBJEXT): $(top_srcdir)/internal/object.h
+enum.$(OBJEXT): $(top_srcdir)/internal/proc.h
+enum.$(OBJEXT): $(top_srcdir)/internal/rational.h
+enum.$(OBJEXT): $(top_srcdir)/internal/re.h
+enum.$(OBJEXT): $(top_srcdir)/internal/serial.h
+enum.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+enum.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+enum.$(OBJEXT): $(top_srcdir)/internal/variable.h
+enum.$(OBJEXT): $(top_srcdir)/internal/vm.h
+enum.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+enum.$(OBJEXT): {$(VPATH)}assert.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enum.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enum.$(OBJEXT): {$(VPATH)}config.h
+enum.$(OBJEXT): {$(VPATH)}constant.h
+enum.$(OBJEXT): {$(VPATH)}defines.h
+enum.$(OBJEXT): {$(VPATH)}encoding.h
+enum.$(OBJEXT): {$(VPATH)}enum.c
+enum.$(OBJEXT): {$(VPATH)}id.h
+enum.$(OBJEXT): {$(VPATH)}id_table.h
+enum.$(OBJEXT): {$(VPATH)}intern.h
+enum.$(OBJEXT): {$(VPATH)}internal.h
+enum.$(OBJEXT): {$(VPATH)}internal/abi.h
+enum.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enum.$(OBJEXT): {$(VPATH)}internal/assume.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enum.$(OBJEXT): {$(VPATH)}internal/cast.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enum.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enum.$(OBJEXT): {$(VPATH)}internal/config.h
+enum.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enum.$(OBJEXT): {$(VPATH)}internal/core.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enum.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enum.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enum.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enum.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+enum.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+enum.$(OBJEXT): {$(VPATH)}internal/error.h
+enum.$(OBJEXT): {$(VPATH)}internal/eval.h
+enum.$(OBJEXT): {$(VPATH)}internal/event.h
+enum.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enum.$(OBJEXT): {$(VPATH)}internal/gc.h
+enum.$(OBJEXT): {$(VPATH)}internal/glob.h
+enum.$(OBJEXT): {$(VPATH)}internal/globals.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enum.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enum.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enum.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enum.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enum.$(OBJEXT): {$(VPATH)}internal/memory.h
+enum.$(OBJEXT): {$(VPATH)}internal/method.h
+enum.$(OBJEXT): {$(VPATH)}internal/module.h
+enum.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enum.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enum.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enum.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+enum.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enum.$(OBJEXT): {$(VPATH)}internal/value.h
+enum.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enum.$(OBJEXT): {$(VPATH)}internal/variable.h
+enum.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enum.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enum.$(OBJEXT): {$(VPATH)}missing.h
+enum.$(OBJEXT): {$(VPATH)}onigmo.h
+enum.$(OBJEXT): {$(VPATH)}oniguruma.h
+enum.$(OBJEXT): {$(VPATH)}re.h
+enum.$(OBJEXT): {$(VPATH)}regex.h
+enum.$(OBJEXT): {$(VPATH)}ruby_assert.h
+enum.$(OBJEXT): {$(VPATH)}shape.h
+enum.$(OBJEXT): {$(VPATH)}st.h
+enum.$(OBJEXT): {$(VPATH)}subst.h
+enum.$(OBJEXT): {$(VPATH)}symbol.h
+enum.$(OBJEXT): {$(VPATH)}util.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/list/list.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/str/str.h
+enumerator.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enumerator.$(OBJEXT): $(hdrdir)/ruby/version.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/array.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/bits.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/box.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/class.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/compar.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/error.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/gc.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/hash.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/range.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/rational.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/serial.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/string.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/struct.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/variable.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/vm.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+enumerator.$(OBJEXT): {$(VPATH)}assert.h
+enumerator.$(OBJEXT): {$(VPATH)}atomic.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+enumerator.$(OBJEXT): {$(VPATH)}config.h
+enumerator.$(OBJEXT): {$(VPATH)}constant.h
+enumerator.$(OBJEXT): {$(VPATH)}debug_counter.h
+enumerator.$(OBJEXT): {$(VPATH)}defines.h
+enumerator.$(OBJEXT): {$(VPATH)}encindex.h
+enumerator.$(OBJEXT): {$(VPATH)}encoding.h
+enumerator.$(OBJEXT): {$(VPATH)}enumerator.c
+enumerator.$(OBJEXT): {$(VPATH)}id.h
+enumerator.$(OBJEXT): {$(VPATH)}id_table.h
+enumerator.$(OBJEXT): {$(VPATH)}intern.h
+enumerator.$(OBJEXT): {$(VPATH)}internal.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/abi.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/assume.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/cast.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/config.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/ctype.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/dosish.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/error.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/eval.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/event.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/gc.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/glob.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/globals.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/iterator.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/memory.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/method.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/module.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/newobj.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/symbol.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/value.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/value_type.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/variable.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enumerator.$(OBJEXT): {$(VPATH)}method.h
+enumerator.$(OBJEXT): {$(VPATH)}missing.h
+enumerator.$(OBJEXT): {$(VPATH)}node.h
+enumerator.$(OBJEXT): {$(VPATH)}onigmo.h
+enumerator.$(OBJEXT): {$(VPATH)}oniguruma.h
+enumerator.$(OBJEXT): {$(VPATH)}ruby_assert.h
+enumerator.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+enumerator.$(OBJEXT): {$(VPATH)}rubyparser.h
+enumerator.$(OBJEXT): {$(VPATH)}shape.h
+enumerator.$(OBJEXT): {$(VPATH)}st.h
+enumerator.$(OBJEXT): {$(VPATH)}subst.h
+enumerator.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+enumerator.$(OBJEXT): {$(VPATH)}thread_native.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_core.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_debug.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_opts.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_sync.h
+error.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+error.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+error.$(OBJEXT): $(CCAN_DIR)/list/list.h
+error.$(OBJEXT): $(CCAN_DIR)/str/str.h
+error.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+error.$(OBJEXT): $(hdrdir)/ruby/version.h
+error.$(OBJEXT): $(top_srcdir)/internal/array.h
+error.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+error.$(OBJEXT): $(top_srcdir)/internal/box.h
+error.$(OBJEXT): $(top_srcdir)/internal/class.h
+error.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+error.$(OBJEXT): $(top_srcdir)/internal/error.h
+error.$(OBJEXT): $(top_srcdir)/internal/eval.h
+error.$(OBJEXT): $(top_srcdir)/internal/gc.h
+error.$(OBJEXT): $(top_srcdir)/internal/hash.h
+error.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+error.$(OBJEXT): $(top_srcdir)/internal/io.h
+error.$(OBJEXT): $(top_srcdir)/internal/load.h
+error.$(OBJEXT): $(top_srcdir)/internal/object.h
+error.$(OBJEXT): $(top_srcdir)/internal/process.h
+error.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+error.$(OBJEXT): $(top_srcdir)/internal/serial.h
+error.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+error.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+error.$(OBJEXT): $(top_srcdir)/internal/string.h
+error.$(OBJEXT): $(top_srcdir)/internal/struct.h
+error.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+error.$(OBJEXT): $(top_srcdir)/internal/thread.h
+error.$(OBJEXT): $(top_srcdir)/internal/variable.h
+error.$(OBJEXT): $(top_srcdir)/internal/vm.h
+error.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+error.$(OBJEXT): {$(VPATH)}assert.h
+error.$(OBJEXT): {$(VPATH)}atomic.h
+error.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+error.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+error.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+error.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+error.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+error.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+error.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+error.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+error.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+error.$(OBJEXT): {$(VPATH)}builtin.h
+error.$(OBJEXT): {$(VPATH)}config.h
+error.$(OBJEXT): {$(VPATH)}constant.h
+error.$(OBJEXT): {$(VPATH)}debug_counter.h
+error.$(OBJEXT): {$(VPATH)}defines.h
+error.$(OBJEXT): {$(VPATH)}encindex.h
+error.$(OBJEXT): {$(VPATH)}encoding.h
+error.$(OBJEXT): {$(VPATH)}error.c
+error.$(OBJEXT): {$(VPATH)}id.h
+error.$(OBJEXT): {$(VPATH)}id_table.h
+error.$(OBJEXT): {$(VPATH)}intern.h
+error.$(OBJEXT): {$(VPATH)}internal.h
+error.$(OBJEXT): {$(VPATH)}internal/abi.h
+error.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+error.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+error.$(OBJEXT): {$(VPATH)}internal/assume.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+error.$(OBJEXT): {$(VPATH)}internal/cast.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+error.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+error.$(OBJEXT): {$(VPATH)}internal/config.h
+error.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+error.$(OBJEXT): {$(VPATH)}internal/core.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+error.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+error.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+error.$(OBJEXT): {$(VPATH)}internal/ctype.h
+error.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+error.$(OBJEXT): {$(VPATH)}internal/dosish.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+error.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+error.$(OBJEXT): {$(VPATH)}internal/error.h
+error.$(OBJEXT): {$(VPATH)}internal/eval.h
+error.$(OBJEXT): {$(VPATH)}internal/event.h
+error.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+error.$(OBJEXT): {$(VPATH)}internal/gc.h
+error.$(OBJEXT): {$(VPATH)}internal/glob.h
+error.$(OBJEXT): {$(VPATH)}internal/globals.h
+error.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+error.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+error.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+error.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+error.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+error.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+error.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+error.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+error.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+error.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+error.$(OBJEXT): {$(VPATH)}internal/iterator.h
+error.$(OBJEXT): {$(VPATH)}internal/memory.h
+error.$(OBJEXT): {$(VPATH)}internal/method.h
+error.$(OBJEXT): {$(VPATH)}internal/module.h
+error.$(OBJEXT): {$(VPATH)}internal/newobj.h
+error.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+error.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+error.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+error.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+error.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+error.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+error.$(OBJEXT): {$(VPATH)}internal/symbol.h
+error.$(OBJEXT): {$(VPATH)}internal/value.h
+error.$(OBJEXT): {$(VPATH)}internal/value_type.h
+error.$(OBJEXT): {$(VPATH)}internal/variable.h
+error.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+error.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+error.$(OBJEXT): {$(VPATH)}io.h
+error.$(OBJEXT): {$(VPATH)}known_errors.inc
+error.$(OBJEXT): {$(VPATH)}method.h
+error.$(OBJEXT): {$(VPATH)}missing.h
+error.$(OBJEXT): {$(VPATH)}node.h
+error.$(OBJEXT): {$(VPATH)}onigmo.h
+error.$(OBJEXT): {$(VPATH)}oniguruma.h
+error.$(OBJEXT): {$(VPATH)}ruby_assert.h
+error.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+error.$(OBJEXT): {$(VPATH)}rubyparser.h
+error.$(OBJEXT): {$(VPATH)}shape.h
+error.$(OBJEXT): {$(VPATH)}st.h
+error.$(OBJEXT): {$(VPATH)}subst.h
+error.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+error.$(OBJEXT): {$(VPATH)}thread_native.h
+error.$(OBJEXT): {$(VPATH)}util.h
+error.$(OBJEXT): {$(VPATH)}vm_core.h
+error.$(OBJEXT): {$(VPATH)}vm_debug.h
+error.$(OBJEXT): {$(VPATH)}vm_opts.h
+error.$(OBJEXT): {$(VPATH)}vm_sync.h
+error.$(OBJEXT): {$(VPATH)}warning.rbinc
+error.$(OBJEXT): {$(VPATH)}yjit.h
+error.$(OBJEXT): {$(VPATH)}zjit.h
+eval.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+eval.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+eval.$(OBJEXT): $(CCAN_DIR)/list/list.h
+eval.$(OBJEXT): $(CCAN_DIR)/str/str.h
+eval.$(OBJEXT): $(hdrdir)/ruby.h
+eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+eval.$(OBJEXT): $(hdrdir)/ruby/version.h
+eval.$(OBJEXT): $(top_srcdir)/internal/array.h
+eval.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+eval.$(OBJEXT): $(top_srcdir)/internal/box.h
+eval.$(OBJEXT): $(top_srcdir)/internal/class.h
+eval.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+eval.$(OBJEXT): $(top_srcdir)/internal/cont.h
+eval.$(OBJEXT): $(top_srcdir)/internal/error.h
+eval.$(OBJEXT): $(top_srcdir)/internal/eval.h
+eval.$(OBJEXT): $(top_srcdir)/internal/gc.h
+eval.$(OBJEXT): $(top_srcdir)/internal/hash.h
+eval.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+eval.$(OBJEXT): $(top_srcdir)/internal/inits.h
+eval.$(OBJEXT): $(top_srcdir)/internal/io.h
+eval.$(OBJEXT): $(top_srcdir)/internal/object.h
+eval.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+eval.$(OBJEXT): $(top_srcdir)/internal/serial.h
+eval.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+eval.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+eval.$(OBJEXT): $(top_srcdir)/internal/string.h
+eval.$(OBJEXT): $(top_srcdir)/internal/struct.h
+eval.$(OBJEXT): $(top_srcdir)/internal/thread.h
+eval.$(OBJEXT): $(top_srcdir)/internal/variable.h
+eval.$(OBJEXT): $(top_srcdir)/internal/vm.h
+eval.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+eval.$(OBJEXT): $(top_srcdir)/prism/arena.h
+eval.$(OBJEXT): $(top_srcdir)/prism/ast.h
+eval.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+eval.$(OBJEXT): $(top_srcdir)/prism/comments.h
+eval.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+eval.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+eval.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+eval.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+eval.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+eval.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+eval.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+eval.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+eval.$(OBJEXT): $(top_srcdir)/prism/integer.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+eval.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+eval.$(OBJEXT): $(top_srcdir)/prism/json.h
+eval.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+eval.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+eval.$(OBJEXT): $(top_srcdir)/prism/node.h
+eval.$(OBJEXT): $(top_srcdir)/prism/options.h
+eval.$(OBJEXT): $(top_srcdir)/prism/parser.h
+eval.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+eval.$(OBJEXT): $(top_srcdir)/prism/prism.h
+eval.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+eval.$(OBJEXT): $(top_srcdir)/prism/source.h
+eval.$(OBJEXT): $(top_srcdir)/prism/stream.h
+eval.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+eval.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+eval.$(OBJEXT): $(top_srcdir)/prism/version.h
+eval.$(OBJEXT): {$(VPATH)}assert.h
+eval.$(OBJEXT): {$(VPATH)}atomic.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+eval.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+eval.$(OBJEXT): {$(VPATH)}config.h
+eval.$(OBJEXT): {$(VPATH)}constant.h
+eval.$(OBJEXT): {$(VPATH)}debug_counter.h
+eval.$(OBJEXT): {$(VPATH)}defines.h
+eval.$(OBJEXT): {$(VPATH)}encindex.h
+eval.$(OBJEXT): {$(VPATH)}encoding.h
+eval.$(OBJEXT): {$(VPATH)}eval.c
+eval.$(OBJEXT): {$(VPATH)}eval_error.c
+eval.$(OBJEXT): {$(VPATH)}eval_intern.h
+eval.$(OBJEXT): {$(VPATH)}eval_jump.c
+eval.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+eval.$(OBJEXT): {$(VPATH)}id.h
+eval.$(OBJEXT): {$(VPATH)}id_table.h
+eval.$(OBJEXT): {$(VPATH)}intern.h
+eval.$(OBJEXT): {$(VPATH)}internal.h
+eval.$(OBJEXT): {$(VPATH)}internal/abi.h
+eval.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+eval.$(OBJEXT): {$(VPATH)}internal/assume.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+eval.$(OBJEXT): {$(VPATH)}internal/cast.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+eval.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+eval.$(OBJEXT): {$(VPATH)}internal/config.h
+eval.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+eval.$(OBJEXT): {$(VPATH)}internal/core.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+eval.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+eval.$(OBJEXT): {$(VPATH)}internal/ctype.h
+eval.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+eval.$(OBJEXT): {$(VPATH)}internal/dosish.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+eval.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+eval.$(OBJEXT): {$(VPATH)}internal/error.h
+eval.$(OBJEXT): {$(VPATH)}internal/eval.h
+eval.$(OBJEXT): {$(VPATH)}internal/event.h
+eval.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+eval.$(OBJEXT): {$(VPATH)}internal/gc.h
+eval.$(OBJEXT): {$(VPATH)}internal/glob.h
+eval.$(OBJEXT): {$(VPATH)}internal/globals.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+eval.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+eval.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+eval.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+eval.$(OBJEXT): {$(VPATH)}internal/iterator.h
+eval.$(OBJEXT): {$(VPATH)}internal/memory.h
+eval.$(OBJEXT): {$(VPATH)}internal/method.h
+eval.$(OBJEXT): {$(VPATH)}internal/module.h
+eval.$(OBJEXT): {$(VPATH)}internal/newobj.h
+eval.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+eval.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+eval.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+eval.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+eval.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+eval.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+eval.$(OBJEXT): {$(VPATH)}internal/symbol.h
+eval.$(OBJEXT): {$(VPATH)}internal/value.h
+eval.$(OBJEXT): {$(VPATH)}internal/value_type.h
+eval.$(OBJEXT): {$(VPATH)}internal/variable.h
+eval.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+eval.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+eval.$(OBJEXT): {$(VPATH)}io.h
+eval.$(OBJEXT): {$(VPATH)}iseq.h
+eval.$(OBJEXT): {$(VPATH)}method.h
+eval.$(OBJEXT): {$(VPATH)}missing.h
+eval.$(OBJEXT): {$(VPATH)}node.h
+eval.$(OBJEXT): {$(VPATH)}onigmo.h
+eval.$(OBJEXT): {$(VPATH)}oniguruma.h
+eval.$(OBJEXT): {$(VPATH)}prism_compile.h
+eval.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+eval.$(OBJEXT): {$(VPATH)}probes.dmyh
+eval.$(OBJEXT): {$(VPATH)}probes.h
+eval.$(OBJEXT): {$(VPATH)}probes_helper.h
+eval.$(OBJEXT): {$(VPATH)}ractor.h
+eval.$(OBJEXT): {$(VPATH)}ractor_core.h
+eval.$(OBJEXT): {$(VPATH)}ruby_assert.h
+eval.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+eval.$(OBJEXT): {$(VPATH)}rubyparser.h
+eval.$(OBJEXT): {$(VPATH)}shape.h
+eval.$(OBJEXT): {$(VPATH)}st.h
+eval.$(OBJEXT): {$(VPATH)}subst.h
+eval.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+eval.$(OBJEXT): {$(VPATH)}thread_native.h
+eval.$(OBJEXT): {$(VPATH)}vm.h
+eval.$(OBJEXT): {$(VPATH)}vm_core.h
+eval.$(OBJEXT): {$(VPATH)}vm_debug.h
+eval.$(OBJEXT): {$(VPATH)}vm_opts.h
+eval.$(OBJEXT): {$(VPATH)}vm_sync.h
+eval.$(OBJEXT): {$(VPATH)}zjit.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}config.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/config.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h
+file.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+file.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+file.$(OBJEXT): $(CCAN_DIR)/list/list.h
+file.$(OBJEXT): $(CCAN_DIR)/str/str.h
+file.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+file.$(OBJEXT): $(hdrdir)/ruby/version.h
+file.$(OBJEXT): $(top_srcdir)/internal/array.h
+file.$(OBJEXT): $(top_srcdir)/internal/class.h
+file.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+file.$(OBJEXT): $(top_srcdir)/internal/dir.h
+file.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+file.$(OBJEXT): $(top_srcdir)/internal/error.h
+file.$(OBJEXT): $(top_srcdir)/internal/file.h
+file.$(OBJEXT): $(top_srcdir)/internal/gc.h
+file.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+file.$(OBJEXT): $(top_srcdir)/internal/io.h
+file.$(OBJEXT): $(top_srcdir)/internal/load.h
+file.$(OBJEXT): $(top_srcdir)/internal/object.h
+file.$(OBJEXT): $(top_srcdir)/internal/process.h
+file.$(OBJEXT): $(top_srcdir)/internal/serial.h
+file.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+file.$(OBJEXT): $(top_srcdir)/internal/string.h
+file.$(OBJEXT): $(top_srcdir)/internal/thread.h
+file.$(OBJEXT): $(top_srcdir)/internal/variable.h
+file.$(OBJEXT): $(top_srcdir)/internal/vm.h
+file.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+file.$(OBJEXT): {$(VPATH)}assert.h
+file.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+file.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+file.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+file.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+file.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+file.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+file.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+file.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+file.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+file.$(OBJEXT): {$(VPATH)}config.h
+file.$(OBJEXT): {$(VPATH)}constant.h
+file.$(OBJEXT): {$(VPATH)}defines.h
+file.$(OBJEXT): {$(VPATH)}dln.h
+file.$(OBJEXT): {$(VPATH)}encindex.h
+file.$(OBJEXT): {$(VPATH)}encoding.h
+file.$(OBJEXT): {$(VPATH)}file.c
+file.$(OBJEXT): {$(VPATH)}id.h
+file.$(OBJEXT): {$(VPATH)}id_table.h
+file.$(OBJEXT): {$(VPATH)}intern.h
+file.$(OBJEXT): {$(VPATH)}internal.h
+file.$(OBJEXT): {$(VPATH)}internal/abi.h
+file.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+file.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+file.$(OBJEXT): {$(VPATH)}internal/assume.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+file.$(OBJEXT): {$(VPATH)}internal/cast.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+file.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+file.$(OBJEXT): {$(VPATH)}internal/config.h
+file.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+file.$(OBJEXT): {$(VPATH)}internal/core.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+file.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+file.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+file.$(OBJEXT): {$(VPATH)}internal/ctype.h
+file.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+file.$(OBJEXT): {$(VPATH)}internal/dosish.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+file.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+file.$(OBJEXT): {$(VPATH)}internal/error.h
+file.$(OBJEXT): {$(VPATH)}internal/eval.h
+file.$(OBJEXT): {$(VPATH)}internal/event.h
+file.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+file.$(OBJEXT): {$(VPATH)}internal/gc.h
+file.$(OBJEXT): {$(VPATH)}internal/glob.h
+file.$(OBJEXT): {$(VPATH)}internal/globals.h
+file.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+file.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+file.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+file.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+file.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+file.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+file.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+file.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+file.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+file.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+file.$(OBJEXT): {$(VPATH)}internal/iterator.h
+file.$(OBJEXT): {$(VPATH)}internal/memory.h
+file.$(OBJEXT): {$(VPATH)}internal/method.h
+file.$(OBJEXT): {$(VPATH)}internal/module.h
+file.$(OBJEXT): {$(VPATH)}internal/newobj.h
+file.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+file.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+file.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+file.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+file.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+file.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+file.$(OBJEXT): {$(VPATH)}internal/symbol.h
+file.$(OBJEXT): {$(VPATH)}internal/value.h
+file.$(OBJEXT): {$(VPATH)}internal/value_type.h
+file.$(OBJEXT): {$(VPATH)}internal/variable.h
+file.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+file.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+file.$(OBJEXT): {$(VPATH)}io.h
+file.$(OBJEXT): {$(VPATH)}missing.h
+file.$(OBJEXT): {$(VPATH)}onigmo.h
+file.$(OBJEXT): {$(VPATH)}oniguruma.h
+file.$(OBJEXT): {$(VPATH)}shape.h
+file.$(OBJEXT): {$(VPATH)}st.h
+file.$(OBJEXT): {$(VPATH)}subst.h
+file.$(OBJEXT): {$(VPATH)}thread.h
+file.$(OBJEXT): {$(VPATH)}thread_native.h
+file.$(OBJEXT): {$(VPATH)}util.h
+gc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+gc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+gc.$(OBJEXT): $(CCAN_DIR)/list/list.h
+gc.$(OBJEXT): $(CCAN_DIR)/str/str.h
+gc.$(OBJEXT): $(hdrdir)/ruby.h
+gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+gc.$(OBJEXT): $(hdrdir)/ruby/version.h
+gc.$(OBJEXT): $(top_srcdir)/gc/default/default.c
+gc.$(OBJEXT): $(top_srcdir)/gc/gc.h
+gc.$(OBJEXT): $(top_srcdir)/gc/gc_impl.h
+gc.$(OBJEXT): $(top_srcdir)/internal/array.h
+gc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+gc.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+gc.$(OBJEXT): $(top_srcdir)/internal/bits.h
+gc.$(OBJEXT): $(top_srcdir)/internal/box.h
+gc.$(OBJEXT): $(top_srcdir)/internal/class.h
+gc.$(OBJEXT): $(top_srcdir)/internal/compar.h
+gc.$(OBJEXT): $(top_srcdir)/internal/compile.h
+gc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+gc.$(OBJEXT): $(top_srcdir)/internal/complex.h
+gc.$(OBJEXT): $(top_srcdir)/internal/concurrent_set.h
+gc.$(OBJEXT): $(top_srcdir)/internal/cont.h
+gc.$(OBJEXT): $(top_srcdir)/internal/error.h
+gc.$(OBJEXT): $(top_srcdir)/internal/eval.h
+gc.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+gc.$(OBJEXT): $(top_srcdir)/internal/gc.h
+gc.$(OBJEXT): $(top_srcdir)/internal/hash.h
+gc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+gc.$(OBJEXT): $(top_srcdir)/internal/io.h
+gc.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+gc.$(OBJEXT): $(top_srcdir)/internal/object.h
+gc.$(OBJEXT): $(top_srcdir)/internal/proc.h
+gc.$(OBJEXT): $(top_srcdir)/internal/rational.h
+gc.$(OBJEXT): $(top_srcdir)/internal/re.h
+gc.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+gc.$(OBJEXT): $(top_srcdir)/internal/serial.h
+gc.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+gc.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+gc.$(OBJEXT): $(top_srcdir)/internal/string.h
+gc.$(OBJEXT): $(top_srcdir)/internal/struct.h
+gc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+gc.$(OBJEXT): $(top_srcdir)/internal/thread.h
+gc.$(OBJEXT): $(top_srcdir)/internal/variable.h
+gc.$(OBJEXT): $(top_srcdir)/internal/vm.h
+gc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+gc.$(OBJEXT): $(top_srcdir)/prism/arena.h
+gc.$(OBJEXT): $(top_srcdir)/prism/ast.h
+gc.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+gc.$(OBJEXT): $(top_srcdir)/prism/comments.h
+gc.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+gc.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+gc.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+gc.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+gc.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+gc.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+gc.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+gc.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+gc.$(OBJEXT): $(top_srcdir)/prism/integer.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+gc.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+gc.$(OBJEXT): $(top_srcdir)/prism/json.h
+gc.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+gc.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+gc.$(OBJEXT): $(top_srcdir)/prism/node.h
+gc.$(OBJEXT): $(top_srcdir)/prism/options.h
+gc.$(OBJEXT): $(top_srcdir)/prism/parser.h
+gc.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+gc.$(OBJEXT): $(top_srcdir)/prism/prism.h
+gc.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+gc.$(OBJEXT): $(top_srcdir)/prism/source.h
+gc.$(OBJEXT): $(top_srcdir)/prism/stream.h
+gc.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+gc.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+gc.$(OBJEXT): $(top_srcdir)/prism/version.h
+gc.$(OBJEXT): {$(VPATH)}assert.h
+gc.$(OBJEXT): {$(VPATH)}atomic.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+gc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+gc.$(OBJEXT): {$(VPATH)}builtin.h
+gc.$(OBJEXT): {$(VPATH)}config.h
+gc.$(OBJEXT): {$(VPATH)}constant.h
+gc.$(OBJEXT): {$(VPATH)}darray.h
+gc.$(OBJEXT): {$(VPATH)}debug.h
+gc.$(OBJEXT): {$(VPATH)}debug_counter.h
+gc.$(OBJEXT): {$(VPATH)}defines.h
+gc.$(OBJEXT): {$(VPATH)}encindex.h
+gc.$(OBJEXT): {$(VPATH)}encoding.h
+gc.$(OBJEXT): {$(VPATH)}eval_intern.h
+gc.$(OBJEXT): {$(VPATH)}gc.c
+gc.$(OBJEXT): {$(VPATH)}gc.rbinc
+gc.$(OBJEXT): {$(VPATH)}id.h
+gc.$(OBJEXT): {$(VPATH)}id_table.h
+gc.$(OBJEXT): {$(VPATH)}intern.h
+gc.$(OBJEXT): {$(VPATH)}internal.h
+gc.$(OBJEXT): {$(VPATH)}internal/abi.h
+gc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+gc.$(OBJEXT): {$(VPATH)}internal/assume.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+gc.$(OBJEXT): {$(VPATH)}internal/cast.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+gc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+gc.$(OBJEXT): {$(VPATH)}internal/config.h
+gc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+gc.$(OBJEXT): {$(VPATH)}internal/core.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+gc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+gc.$(OBJEXT): {$(VPATH)}internal/ctype.h
+gc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+gc.$(OBJEXT): {$(VPATH)}internal/dosish.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+gc.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+gc.$(OBJEXT): {$(VPATH)}internal/error.h
+gc.$(OBJEXT): {$(VPATH)}internal/eval.h
+gc.$(OBJEXT): {$(VPATH)}internal/event.h
+gc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+gc.$(OBJEXT): {$(VPATH)}internal/gc.h
+gc.$(OBJEXT): {$(VPATH)}internal/glob.h
+gc.$(OBJEXT): {$(VPATH)}internal/globals.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+gc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+gc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+gc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+gc.$(OBJEXT): {$(VPATH)}internal/iterator.h
+gc.$(OBJEXT): {$(VPATH)}internal/memory.h
+gc.$(OBJEXT): {$(VPATH)}internal/method.h
+gc.$(OBJEXT): {$(VPATH)}internal/module.h
+gc.$(OBJEXT): {$(VPATH)}internal/newobj.h
+gc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+gc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+gc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+gc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+gc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+gc.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+gc.$(OBJEXT): {$(VPATH)}internal/symbol.h
+gc.$(OBJEXT): {$(VPATH)}internal/value.h
+gc.$(OBJEXT): {$(VPATH)}internal/value_type.h
+gc.$(OBJEXT): {$(VPATH)}internal/variable.h
+gc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+gc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+gc.$(OBJEXT): {$(VPATH)}io.h
+gc.$(OBJEXT): {$(VPATH)}iseq.h
+gc.$(OBJEXT): {$(VPATH)}method.h
+gc.$(OBJEXT): {$(VPATH)}missing.h
+gc.$(OBJEXT): {$(VPATH)}node.h
+gc.$(OBJEXT): {$(VPATH)}onigmo.h
+gc.$(OBJEXT): {$(VPATH)}oniguruma.h
+gc.$(OBJEXT): {$(VPATH)}prism_compile.h
+gc.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+gc.$(OBJEXT): {$(VPATH)}probes.dmyh
+gc.$(OBJEXT): {$(VPATH)}probes.h
+gc.$(OBJEXT): {$(VPATH)}ractor.h
+gc.$(OBJEXT): {$(VPATH)}ractor_core.h
+gc.$(OBJEXT): {$(VPATH)}re.h
+gc.$(OBJEXT): {$(VPATH)}regenc.h
+gc.$(OBJEXT): {$(VPATH)}regex.h
+gc.$(OBJEXT): {$(VPATH)}regint.h
+gc.$(OBJEXT): {$(VPATH)}ruby_assert.h
+gc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+gc.$(OBJEXT): {$(VPATH)}rubyparser.h
+gc.$(OBJEXT): {$(VPATH)}shape.h
+gc.$(OBJEXT): {$(VPATH)}st.h
+gc.$(OBJEXT): {$(VPATH)}subst.h
+gc.$(OBJEXT): {$(VPATH)}symbol.h
+gc.$(OBJEXT): {$(VPATH)}thread.h
+gc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+gc.$(OBJEXT): {$(VPATH)}thread_native.h
+gc.$(OBJEXT): {$(VPATH)}util.h
+gc.$(OBJEXT): {$(VPATH)}variable.h
+gc.$(OBJEXT): {$(VPATH)}vm.h
+gc.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+gc.$(OBJEXT): {$(VPATH)}vm_core.h
+gc.$(OBJEXT): {$(VPATH)}vm_debug.h
+gc.$(OBJEXT): {$(VPATH)}vm_opts.h
+gc.$(OBJEXT): {$(VPATH)}vm_sync.h
+gc.$(OBJEXT): {$(VPATH)}yjit.h
+gc.$(OBJEXT): {$(VPATH)}zjit.h
+goruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+goruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+goruby.$(OBJEXT): $(CCAN_DIR)/list/list.h
+goruby.$(OBJEXT): $(CCAN_DIR)/str/str.h
+goruby.$(OBJEXT): $(hdrdir)/ruby.h
+goruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/array.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/bits.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/box.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/complex.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/gc.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/parse.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/rational.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/arena.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/ast.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/integer.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/node.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/options.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/parser.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/prism.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/version.h
+goruby.$(OBJEXT): {$(VPATH)}assert.h
+goruby.$(OBJEXT): {$(VPATH)}atomic.h
+goruby.$(OBJEXT): {$(VPATH)}backward.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+goruby.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+goruby.$(OBJEXT): {$(VPATH)}config.h
+goruby.$(OBJEXT): {$(VPATH)}constant.h
+goruby.$(OBJEXT): {$(VPATH)}defines.h
+goruby.$(OBJEXT): {$(VPATH)}encoding.h
+goruby.$(OBJEXT): {$(VPATH)}golf_prelude.rbbin
+goruby.$(OBJEXT): {$(VPATH)}goruby.c
+goruby.$(OBJEXT): {$(VPATH)}id.h
+goruby.$(OBJEXT): {$(VPATH)}id_table.h
+goruby.$(OBJEXT): {$(VPATH)}intern.h
+goruby.$(OBJEXT): {$(VPATH)}internal.h
+goruby.$(OBJEXT): {$(VPATH)}internal/abi.h
+goruby.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+goruby.$(OBJEXT): {$(VPATH)}internal/assume.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+goruby.$(OBJEXT): {$(VPATH)}internal/cast.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+goruby.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+goruby.$(OBJEXT): {$(VPATH)}internal/config.h
+goruby.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+goruby.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+goruby.$(OBJEXT): {$(VPATH)}internal/ctype.h
+goruby.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+goruby.$(OBJEXT): {$(VPATH)}internal/dosish.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+goruby.$(OBJEXT): {$(VPATH)}internal/error.h
+goruby.$(OBJEXT): {$(VPATH)}internal/eval.h
+goruby.$(OBJEXT): {$(VPATH)}internal/event.h
+goruby.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+goruby.$(OBJEXT): {$(VPATH)}internal/gc.h
+goruby.$(OBJEXT): {$(VPATH)}internal/glob.h
+goruby.$(OBJEXT): {$(VPATH)}internal/globals.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+goruby.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+goruby.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+goruby.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+goruby.$(OBJEXT): {$(VPATH)}internal/iterator.h
+goruby.$(OBJEXT): {$(VPATH)}internal/memory.h
+goruby.$(OBJEXT): {$(VPATH)}internal/method.h
+goruby.$(OBJEXT): {$(VPATH)}internal/module.h
+goruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
+goruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+goruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+goruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+goruby.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+goruby.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+goruby.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+goruby.$(OBJEXT): {$(VPATH)}internal/symbol.h
+goruby.$(OBJEXT): {$(VPATH)}internal/value.h
+goruby.$(OBJEXT): {$(VPATH)}internal/value_type.h
+goruby.$(OBJEXT): {$(VPATH)}internal/variable.h
+goruby.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+goruby.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+goruby.$(OBJEXT): {$(VPATH)}iseq.h
+goruby.$(OBJEXT): {$(VPATH)}main.c
+goruby.$(OBJEXT): {$(VPATH)}method.h
+goruby.$(OBJEXT): {$(VPATH)}missing.h
+goruby.$(OBJEXT): {$(VPATH)}node.h
+goruby.$(OBJEXT): {$(VPATH)}onigmo.h
+goruby.$(OBJEXT): {$(VPATH)}oniguruma.h
+goruby.$(OBJEXT): {$(VPATH)}prism_compile.h
+goruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
+goruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+goruby.$(OBJEXT): {$(VPATH)}rubyparser.h
+goruby.$(OBJEXT): {$(VPATH)}shape.h
+goruby.$(OBJEXT): {$(VPATH)}st.h
+goruby.$(OBJEXT): {$(VPATH)}subst.h
+goruby.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+goruby.$(OBJEXT): {$(VPATH)}thread_native.h
+goruby.$(OBJEXT): {$(VPATH)}vm_core.h
+goruby.$(OBJEXT): {$(VPATH)}vm_debug.h
+goruby.$(OBJEXT): {$(VPATH)}vm_opts.h
+hash.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+hash.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+hash.$(OBJEXT): $(CCAN_DIR)/list/list.h
+hash.$(OBJEXT): $(CCAN_DIR)/str/str.h
+hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+hash.$(OBJEXT): $(hdrdir)/ruby/version.h
+hash.$(OBJEXT): $(top_srcdir)/internal/array.h
+hash.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+hash.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+hash.$(OBJEXT): $(top_srcdir)/internal/bits.h
+hash.$(OBJEXT): $(top_srcdir)/internal/box.h
+hash.$(OBJEXT): $(top_srcdir)/internal/class.h
+hash.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+hash.$(OBJEXT): $(top_srcdir)/internal/cont.h
+hash.$(OBJEXT): $(top_srcdir)/internal/error.h
+hash.$(OBJEXT): $(top_srcdir)/internal/gc.h
+hash.$(OBJEXT): $(top_srcdir)/internal/hash.h
+hash.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+hash.$(OBJEXT): $(top_srcdir)/internal/object.h
+hash.$(OBJEXT): $(top_srcdir)/internal/proc.h
+hash.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+hash.$(OBJEXT): $(top_srcdir)/internal/serial.h
+hash.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+hash.$(OBJEXT): $(top_srcdir)/internal/st.h
+hash.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+hash.$(OBJEXT): $(top_srcdir)/internal/string.h
+hash.$(OBJEXT): $(top_srcdir)/internal/struct.h
+hash.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+hash.$(OBJEXT): $(top_srcdir)/internal/thread.h
+hash.$(OBJEXT): $(top_srcdir)/internal/time.h
+hash.$(OBJEXT): $(top_srcdir)/internal/variable.h
+hash.$(OBJEXT): $(top_srcdir)/internal/vm.h
+hash.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+hash.$(OBJEXT): $(top_srcdir)/prism/arena.h
+hash.$(OBJEXT): $(top_srcdir)/prism/ast.h
+hash.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+hash.$(OBJEXT): $(top_srcdir)/prism/comments.h
+hash.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+hash.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+hash.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+hash.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+hash.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+hash.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+hash.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+hash.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+hash.$(OBJEXT): $(top_srcdir)/prism/integer.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+hash.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+hash.$(OBJEXT): $(top_srcdir)/prism/json.h
+hash.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+hash.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+hash.$(OBJEXT): $(top_srcdir)/prism/node.h
+hash.$(OBJEXT): $(top_srcdir)/prism/options.h
+hash.$(OBJEXT): $(top_srcdir)/prism/parser.h
+hash.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+hash.$(OBJEXT): $(top_srcdir)/prism/prism.h
+hash.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+hash.$(OBJEXT): $(top_srcdir)/prism/source.h
+hash.$(OBJEXT): $(top_srcdir)/prism/stream.h
+hash.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+hash.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+hash.$(OBJEXT): $(top_srcdir)/prism/version.h
+hash.$(OBJEXT): {$(VPATH)}assert.h
+hash.$(OBJEXT): {$(VPATH)}atomic.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+hash.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+hash.$(OBJEXT): {$(VPATH)}builtin.h
+hash.$(OBJEXT): {$(VPATH)}config.h
+hash.$(OBJEXT): {$(VPATH)}constant.h
+hash.$(OBJEXT): {$(VPATH)}debug_counter.h
+hash.$(OBJEXT): {$(VPATH)}defines.h
+hash.$(OBJEXT): {$(VPATH)}encindex.h
+hash.$(OBJEXT): {$(VPATH)}encoding.h
+hash.$(OBJEXT): {$(VPATH)}hash.c
+hash.$(OBJEXT): {$(VPATH)}hash.rbinc
+hash.$(OBJEXT): {$(VPATH)}id.h
+hash.$(OBJEXT): {$(VPATH)}id_table.h
+hash.$(OBJEXT): {$(VPATH)}intern.h
+hash.$(OBJEXT): {$(VPATH)}internal.h
+hash.$(OBJEXT): {$(VPATH)}internal/abi.h
+hash.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+hash.$(OBJEXT): {$(VPATH)}internal/assume.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+hash.$(OBJEXT): {$(VPATH)}internal/cast.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+hash.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+hash.$(OBJEXT): {$(VPATH)}internal/config.h
+hash.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+hash.$(OBJEXT): {$(VPATH)}internal/core.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+hash.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+hash.$(OBJEXT): {$(VPATH)}internal/ctype.h
+hash.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+hash.$(OBJEXT): {$(VPATH)}internal/dosish.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+hash.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+hash.$(OBJEXT): {$(VPATH)}internal/error.h
+hash.$(OBJEXT): {$(VPATH)}internal/eval.h
+hash.$(OBJEXT): {$(VPATH)}internal/event.h
+hash.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+hash.$(OBJEXT): {$(VPATH)}internal/gc.h
+hash.$(OBJEXT): {$(VPATH)}internal/glob.h
+hash.$(OBJEXT): {$(VPATH)}internal/globals.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+hash.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+hash.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+hash.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+hash.$(OBJEXT): {$(VPATH)}internal/iterator.h
+hash.$(OBJEXT): {$(VPATH)}internal/memory.h
+hash.$(OBJEXT): {$(VPATH)}internal/method.h
+hash.$(OBJEXT): {$(VPATH)}internal/module.h
+hash.$(OBJEXT): {$(VPATH)}internal/newobj.h
+hash.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+hash.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+hash.$(OBJEXT): {$(VPATH)}internal/st.h
+hash.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+hash.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+hash.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+hash.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+hash.$(OBJEXT): {$(VPATH)}internal/symbol.h
+hash.$(OBJEXT): {$(VPATH)}internal/value.h
+hash.$(OBJEXT): {$(VPATH)}internal/value_type.h
+hash.$(OBJEXT): {$(VPATH)}internal/variable.h
+hash.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+hash.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+hash.$(OBJEXT): {$(VPATH)}iseq.h
+hash.$(OBJEXT): {$(VPATH)}method.h
+hash.$(OBJEXT): {$(VPATH)}missing.h
+hash.$(OBJEXT): {$(VPATH)}node.h
+hash.$(OBJEXT): {$(VPATH)}onigmo.h
+hash.$(OBJEXT): {$(VPATH)}oniguruma.h
+hash.$(OBJEXT): {$(VPATH)}prism_compile.h
+hash.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+hash.$(OBJEXT): {$(VPATH)}probes.dmyh
+hash.$(OBJEXT): {$(VPATH)}probes.h
+hash.$(OBJEXT): {$(VPATH)}ractor.h
+hash.$(OBJEXT): {$(VPATH)}ruby_assert.h
+hash.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+hash.$(OBJEXT): {$(VPATH)}rubyparser.h
+hash.$(OBJEXT): {$(VPATH)}shape.h
+hash.$(OBJEXT): {$(VPATH)}st.h
+hash.$(OBJEXT): {$(VPATH)}subst.h
+hash.$(OBJEXT): {$(VPATH)}symbol.h
+hash.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+hash.$(OBJEXT): {$(VPATH)}thread_native.h
+hash.$(OBJEXT): {$(VPATH)}util.h
+hash.$(OBJEXT): {$(VPATH)}variable.h
+hash.$(OBJEXT): {$(VPATH)}vm_core.h
+hash.$(OBJEXT): {$(VPATH)}vm_debug.h
+hash.$(OBJEXT): {$(VPATH)}vm_opts.h
+hash.$(OBJEXT): {$(VPATH)}vm_sync.h
+imemo.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+imemo.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+imemo.$(OBJEXT): $(CCAN_DIR)/list/list.h
+imemo.$(OBJEXT): $(CCAN_DIR)/str/str.h
+imemo.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/array.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/box.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/class.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/gc.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/object.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/serial.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/st.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/struct.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/variable.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/vm.h
+imemo.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+imemo.$(OBJEXT): {$(VPATH)}assert.h
+imemo.$(OBJEXT): {$(VPATH)}atomic.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+imemo.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+imemo.$(OBJEXT): {$(VPATH)}config.h
+imemo.$(OBJEXT): {$(VPATH)}constant.h
+imemo.$(OBJEXT): {$(VPATH)}debug_counter.h
+imemo.$(OBJEXT): {$(VPATH)}defines.h
+imemo.$(OBJEXT): {$(VPATH)}encoding.h
+imemo.$(OBJEXT): {$(VPATH)}id.h
+imemo.$(OBJEXT): {$(VPATH)}id_table.h
+imemo.$(OBJEXT): {$(VPATH)}imemo.c
+imemo.$(OBJEXT): {$(VPATH)}intern.h
+imemo.$(OBJEXT): {$(VPATH)}internal.h
+imemo.$(OBJEXT): {$(VPATH)}internal/abi.h
+imemo.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+imemo.$(OBJEXT): {$(VPATH)}internal/assume.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+imemo.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+imemo.$(OBJEXT): {$(VPATH)}internal/cast.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+imemo.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+imemo.$(OBJEXT): {$(VPATH)}internal/config.h
+imemo.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+imemo.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+imemo.$(OBJEXT): {$(VPATH)}internal/ctype.h
+imemo.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+imemo.$(OBJEXT): {$(VPATH)}internal/dosish.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+imemo.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+imemo.$(OBJEXT): {$(VPATH)}internal/error.h
+imemo.$(OBJEXT): {$(VPATH)}internal/eval.h
+imemo.$(OBJEXT): {$(VPATH)}internal/event.h
+imemo.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+imemo.$(OBJEXT): {$(VPATH)}internal/gc.h
+imemo.$(OBJEXT): {$(VPATH)}internal/glob.h
+imemo.$(OBJEXT): {$(VPATH)}internal/globals.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+imemo.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+imemo.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+imemo.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+imemo.$(OBJEXT): {$(VPATH)}internal/iterator.h
+imemo.$(OBJEXT): {$(VPATH)}internal/memory.h
+imemo.$(OBJEXT): {$(VPATH)}internal/method.h
+imemo.$(OBJEXT): {$(VPATH)}internal/module.h
+imemo.$(OBJEXT): {$(VPATH)}internal/newobj.h
+imemo.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+imemo.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+imemo.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+imemo.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+imemo.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+imemo.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+imemo.$(OBJEXT): {$(VPATH)}internal/symbol.h
+imemo.$(OBJEXT): {$(VPATH)}internal/value.h
+imemo.$(OBJEXT): {$(VPATH)}internal/value_type.h
+imemo.$(OBJEXT): {$(VPATH)}internal/variable.h
+imemo.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+imemo.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+imemo.$(OBJEXT): {$(VPATH)}method.h
+imemo.$(OBJEXT): {$(VPATH)}missing.h
+imemo.$(OBJEXT): {$(VPATH)}node.h
+imemo.$(OBJEXT): {$(VPATH)}onigmo.h
+imemo.$(OBJEXT): {$(VPATH)}oniguruma.h
+imemo.$(OBJEXT): {$(VPATH)}ruby_assert.h
+imemo.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+imemo.$(OBJEXT): {$(VPATH)}rubyparser.h
+imemo.$(OBJEXT): {$(VPATH)}shape.h
+imemo.$(OBJEXT): {$(VPATH)}st.h
+imemo.$(OBJEXT): {$(VPATH)}subst.h
+imemo.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+imemo.$(OBJEXT): {$(VPATH)}thread_native.h
+imemo.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+imemo.$(OBJEXT): {$(VPATH)}vm_core.h
+imemo.$(OBJEXT): {$(VPATH)}vm_debug.h
+imemo.$(OBJEXT): {$(VPATH)}vm_opts.h
+imemo.$(OBJEXT): {$(VPATH)}vm_sync.h
+inits.$(OBJEXT): $(hdrdir)/ruby.h
+inits.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+inits.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+inits.$(OBJEXT): $(top_srcdir)/internal/inits.h
+inits.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+inits.$(OBJEXT): {$(VPATH)}assert.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+inits.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+inits.$(OBJEXT): {$(VPATH)}builtin.h
+inits.$(OBJEXT): {$(VPATH)}config.h
+inits.$(OBJEXT): {$(VPATH)}defines.h
+inits.$(OBJEXT): {$(VPATH)}inits.c
+inits.$(OBJEXT): {$(VPATH)}intern.h
+inits.$(OBJEXT): {$(VPATH)}internal/abi.h
+inits.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+inits.$(OBJEXT): {$(VPATH)}internal/assume.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+inits.$(OBJEXT): {$(VPATH)}internal/cast.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+inits.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+inits.$(OBJEXT): {$(VPATH)}internal/config.h
+inits.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+inits.$(OBJEXT): {$(VPATH)}internal/core.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+inits.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+inits.$(OBJEXT): {$(VPATH)}internal/ctype.h
+inits.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+inits.$(OBJEXT): {$(VPATH)}internal/dosish.h
+inits.$(OBJEXT): {$(VPATH)}internal/error.h
+inits.$(OBJEXT): {$(VPATH)}internal/eval.h
+inits.$(OBJEXT): {$(VPATH)}internal/event.h
+inits.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+inits.$(OBJEXT): {$(VPATH)}internal/gc.h
+inits.$(OBJEXT): {$(VPATH)}internal/glob.h
+inits.$(OBJEXT): {$(VPATH)}internal/globals.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+inits.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+inits.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+inits.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+inits.$(OBJEXT): {$(VPATH)}internal/iterator.h
+inits.$(OBJEXT): {$(VPATH)}internal/memory.h
+inits.$(OBJEXT): {$(VPATH)}internal/method.h
+inits.$(OBJEXT): {$(VPATH)}internal/module.h
+inits.$(OBJEXT): {$(VPATH)}internal/newobj.h
+inits.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+inits.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+inits.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+inits.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+inits.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+inits.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+inits.$(OBJEXT): {$(VPATH)}internal/symbol.h
+inits.$(OBJEXT): {$(VPATH)}internal/value.h
+inits.$(OBJEXT): {$(VPATH)}internal/value_type.h
+inits.$(OBJEXT): {$(VPATH)}internal/variable.h
+inits.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+inits.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+inits.$(OBJEXT): {$(VPATH)}missing.h
+inits.$(OBJEXT): {$(VPATH)}prelude.rbinc
+inits.$(OBJEXT): {$(VPATH)}st.h
+inits.$(OBJEXT): {$(VPATH)}subst.h
+io.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+io.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+io.$(OBJEXT): $(CCAN_DIR)/list/list.h
+io.$(OBJEXT): $(CCAN_DIR)/str/str.h
+io.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+io.$(OBJEXT): $(hdrdir)/ruby/version.h
+io.$(OBJEXT): $(top_srcdir)/internal/array.h
+io.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+io.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+io.$(OBJEXT): $(top_srcdir)/internal/bits.h
+io.$(OBJEXT): $(top_srcdir)/internal/box.h
+io.$(OBJEXT): $(top_srcdir)/internal/class.h
+io.$(OBJEXT): $(top_srcdir)/internal/compar.h
+io.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+io.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+io.$(OBJEXT): $(top_srcdir)/internal/error.h
+io.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+io.$(OBJEXT): $(top_srcdir)/internal/gc.h
+io.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+io.$(OBJEXT): $(top_srcdir)/internal/inits.h
+io.$(OBJEXT): $(top_srcdir)/internal/io.h
+io.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+io.$(OBJEXT): $(top_srcdir)/internal/object.h
+io.$(OBJEXT): $(top_srcdir)/internal/process.h
+io.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+io.$(OBJEXT): $(top_srcdir)/internal/serial.h
+io.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+io.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+io.$(OBJEXT): $(top_srcdir)/internal/string.h
+io.$(OBJEXT): $(top_srcdir)/internal/struct.h
+io.$(OBJEXT): $(top_srcdir)/internal/thread.h
+io.$(OBJEXT): $(top_srcdir)/internal/transcode.h
+io.$(OBJEXT): $(top_srcdir)/internal/variable.h
+io.$(OBJEXT): $(top_srcdir)/internal/vm.h
+io.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+io.$(OBJEXT): {$(VPATH)}assert.h
+io.$(OBJEXT): {$(VPATH)}atomic.h
+io.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+io.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+io.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+io.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+io.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+io.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+io.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+io.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+io.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+io.$(OBJEXT): {$(VPATH)}builtin.h
+io.$(OBJEXT): {$(VPATH)}config.h
+io.$(OBJEXT): {$(VPATH)}constant.h
+io.$(OBJEXT): {$(VPATH)}debug_counter.h
+io.$(OBJEXT): {$(VPATH)}defines.h
+io.$(OBJEXT): {$(VPATH)}dln.h
+io.$(OBJEXT): {$(VPATH)}encindex.h
+io.$(OBJEXT): {$(VPATH)}encoding.h
+io.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+io.$(OBJEXT): {$(VPATH)}id.h
+io.$(OBJEXT): {$(VPATH)}id_table.h
+io.$(OBJEXT): {$(VPATH)}intern.h
+io.$(OBJEXT): {$(VPATH)}internal.h
+io.$(OBJEXT): {$(VPATH)}internal/abi.h
+io.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+io.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+io.$(OBJEXT): {$(VPATH)}internal/assume.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+io.$(OBJEXT): {$(VPATH)}internal/cast.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+io.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+io.$(OBJEXT): {$(VPATH)}internal/config.h
+io.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+io.$(OBJEXT): {$(VPATH)}internal/core.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+io.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+io.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+io.$(OBJEXT): {$(VPATH)}internal/ctype.h
+io.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+io.$(OBJEXT): {$(VPATH)}internal/dosish.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+io.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+io.$(OBJEXT): {$(VPATH)}internal/error.h
+io.$(OBJEXT): {$(VPATH)}internal/eval.h
+io.$(OBJEXT): {$(VPATH)}internal/event.h
+io.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+io.$(OBJEXT): {$(VPATH)}internal/gc.h
+io.$(OBJEXT): {$(VPATH)}internal/glob.h
+io.$(OBJEXT): {$(VPATH)}internal/globals.h
+io.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+io.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+io.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+io.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+io.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+io.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+io.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+io.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+io.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+io.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+io.$(OBJEXT): {$(VPATH)}internal/iterator.h
+io.$(OBJEXT): {$(VPATH)}internal/memory.h
+io.$(OBJEXT): {$(VPATH)}internal/method.h
+io.$(OBJEXT): {$(VPATH)}internal/module.h
+io.$(OBJEXT): {$(VPATH)}internal/newobj.h
+io.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+io.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+io.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+io.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+io.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+io.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+io.$(OBJEXT): {$(VPATH)}internal/symbol.h
+io.$(OBJEXT): {$(VPATH)}internal/value.h
+io.$(OBJEXT): {$(VPATH)}internal/value_type.h
+io.$(OBJEXT): {$(VPATH)}internal/variable.h
+io.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+io.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+io.$(OBJEXT): {$(VPATH)}io.c
+io.$(OBJEXT): {$(VPATH)}io.h
+io.$(OBJEXT): {$(VPATH)}io.rbinc
+io.$(OBJEXT): {$(VPATH)}io/buffer.h
+io.$(OBJEXT): {$(VPATH)}method.h
+io.$(OBJEXT): {$(VPATH)}missing.h
+io.$(OBJEXT): {$(VPATH)}node.h
+io.$(OBJEXT): {$(VPATH)}onigmo.h
+io.$(OBJEXT): {$(VPATH)}oniguruma.h
+io.$(OBJEXT): {$(VPATH)}ractor.h
+io.$(OBJEXT): {$(VPATH)}ruby_assert.h
+io.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+io.$(OBJEXT): {$(VPATH)}rubyparser.h
+io.$(OBJEXT): {$(VPATH)}shape.h
+io.$(OBJEXT): {$(VPATH)}st.h
+io.$(OBJEXT): {$(VPATH)}subst.h
+io.$(OBJEXT): {$(VPATH)}thread.h
+io.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+io.$(OBJEXT): {$(VPATH)}thread_native.h
+io.$(OBJEXT): {$(VPATH)}util.h
+io.$(OBJEXT): {$(VPATH)}vm_core.h
+io.$(OBJEXT): {$(VPATH)}vm_debug.h
+io.$(OBJEXT): {$(VPATH)}vm_opts.h
+io.$(OBJEXT): {$(VPATH)}vm_sync.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/list/list.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/str/str.h
+io_buffer.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+io_buffer.$(OBJEXT): $(hdrdir)/ruby/version.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/array.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/bits.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/box.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/compar.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/error.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/gc.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/io.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/serial.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/string.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/thread.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/vm.h
+io_buffer.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+io_buffer.$(OBJEXT): {$(VPATH)}assert.h
+io_buffer.$(OBJEXT): {$(VPATH)}atomic.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+io_buffer.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+io_buffer.$(OBJEXT): {$(VPATH)}config.h
+io_buffer.$(OBJEXT): {$(VPATH)}defines.h
+io_buffer.$(OBJEXT): {$(VPATH)}encindex.h
+io_buffer.$(OBJEXT): {$(VPATH)}encoding.h
+io_buffer.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+io_buffer.$(OBJEXT): {$(VPATH)}id.h
+io_buffer.$(OBJEXT): {$(VPATH)}id_table.h
+io_buffer.$(OBJEXT): {$(VPATH)}intern.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/abi.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/assume.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/cast.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/config.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/ctype.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/dosish.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/error.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/eval.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/event.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/gc.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/glob.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/globals.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/iterator.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/memory.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/method.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/module.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/newobj.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/symbol.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/value.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/value_type.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/variable.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+io_buffer.$(OBJEXT): {$(VPATH)}io.h
+io_buffer.$(OBJEXT): {$(VPATH)}io/buffer.h
+io_buffer.$(OBJEXT): {$(VPATH)}io_buffer.c
+io_buffer.$(OBJEXT): {$(VPATH)}method.h
+io_buffer.$(OBJEXT): {$(VPATH)}missing.h
+io_buffer.$(OBJEXT): {$(VPATH)}node.h
+io_buffer.$(OBJEXT): {$(VPATH)}onigmo.h
+io_buffer.$(OBJEXT): {$(VPATH)}oniguruma.h
+io_buffer.$(OBJEXT): {$(VPATH)}ruby_assert.h
+io_buffer.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+io_buffer.$(OBJEXT): {$(VPATH)}rubyparser.h
+io_buffer.$(OBJEXT): {$(VPATH)}st.h
+io_buffer.$(OBJEXT): {$(VPATH)}subst.h
+io_buffer.$(OBJEXT): {$(VPATH)}thread.h
+io_buffer.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+io_buffer.$(OBJEXT): {$(VPATH)}thread_native.h
+io_buffer.$(OBJEXT): {$(VPATH)}vm_core.h
+io_buffer.$(OBJEXT): {$(VPATH)}vm_opts.h
+iseq.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+iseq.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h
+iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h
+iseq.$(OBJEXT): $(hdrdir)/ruby.h
+iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+iseq.$(OBJEXT): $(hdrdir)/ruby/version.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/array.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/bits.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/box.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/class.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/compar.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/compile.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/complex.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/error.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/file.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/gc.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/hash.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/io.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/parse.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/rational.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/serial.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/string.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/struct.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/thread.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/variable.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/vm.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/arena.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/ast.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/comments.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/integer.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/json.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/node.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/options.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/parser.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/prism.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/source.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/stream.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/version.h
+iseq.$(OBJEXT): {$(VPATH)}assert.h
+iseq.$(OBJEXT): {$(VPATH)}atomic.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+iseq.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+iseq.$(OBJEXT): {$(VPATH)}builtin.h
+iseq.$(OBJEXT): {$(VPATH)}config.h
+iseq.$(OBJEXT): {$(VPATH)}constant.h
+iseq.$(OBJEXT): {$(VPATH)}debug_counter.h
+iseq.$(OBJEXT): {$(VPATH)}defines.h
+iseq.$(OBJEXT): {$(VPATH)}encindex.h
+iseq.$(OBJEXT): {$(VPATH)}encoding.h
+iseq.$(OBJEXT): {$(VPATH)}eval_intern.h
+iseq.$(OBJEXT): {$(VPATH)}id.h
+iseq.$(OBJEXT): {$(VPATH)}id_table.h
+iseq.$(OBJEXT): {$(VPATH)}insns.def
+iseq.$(OBJEXT): {$(VPATH)}insns.inc
+iseq.$(OBJEXT): {$(VPATH)}insns_info.inc
+iseq.$(OBJEXT): {$(VPATH)}intern.h
+iseq.$(OBJEXT): {$(VPATH)}internal.h
+iseq.$(OBJEXT): {$(VPATH)}internal/abi.h
+iseq.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+iseq.$(OBJEXT): {$(VPATH)}internal/assume.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+iseq.$(OBJEXT): {$(VPATH)}internal/cast.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+iseq.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+iseq.$(OBJEXT): {$(VPATH)}internal/config.h
+iseq.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+iseq.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+iseq.$(OBJEXT): {$(VPATH)}internal/ctype.h
+iseq.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+iseq.$(OBJEXT): {$(VPATH)}internal/dosish.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+iseq.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+iseq.$(OBJEXT): {$(VPATH)}internal/error.h
+iseq.$(OBJEXT): {$(VPATH)}internal/eval.h
+iseq.$(OBJEXT): {$(VPATH)}internal/event.h
+iseq.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+iseq.$(OBJEXT): {$(VPATH)}internal/gc.h
+iseq.$(OBJEXT): {$(VPATH)}internal/glob.h
+iseq.$(OBJEXT): {$(VPATH)}internal/globals.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+iseq.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+iseq.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+iseq.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+iseq.$(OBJEXT): {$(VPATH)}internal/iterator.h
+iseq.$(OBJEXT): {$(VPATH)}internal/memory.h
+iseq.$(OBJEXT): {$(VPATH)}internal/method.h
+iseq.$(OBJEXT): {$(VPATH)}internal/module.h
+iseq.$(OBJEXT): {$(VPATH)}internal/newobj.h
+iseq.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+iseq.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+iseq.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+iseq.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+iseq.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+iseq.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+iseq.$(OBJEXT): {$(VPATH)}internal/symbol.h
+iseq.$(OBJEXT): {$(VPATH)}internal/value.h
+iseq.$(OBJEXT): {$(VPATH)}internal/value_type.h
+iseq.$(OBJEXT): {$(VPATH)}internal/variable.h
+iseq.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+iseq.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+iseq.$(OBJEXT): {$(VPATH)}io.h
+iseq.$(OBJEXT): {$(VPATH)}iseq.c
+iseq.$(OBJEXT): {$(VPATH)}iseq.h
+iseq.$(OBJEXT): {$(VPATH)}method.h
+iseq.$(OBJEXT): {$(VPATH)}missing.h
+iseq.$(OBJEXT): {$(VPATH)}node.h
+iseq.$(OBJEXT): {$(VPATH)}onigmo.h
+iseq.$(OBJEXT): {$(VPATH)}oniguruma.h
+iseq.$(OBJEXT): {$(VPATH)}prism_compile.h
+iseq.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+iseq.$(OBJEXT): {$(VPATH)}ractor.h
+iseq.$(OBJEXT): {$(VPATH)}ractor_core.h
+iseq.$(OBJEXT): {$(VPATH)}ruby_assert.h
+iseq.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+iseq.$(OBJEXT): {$(VPATH)}rubyparser.h
+iseq.$(OBJEXT): {$(VPATH)}shape.h
+iseq.$(OBJEXT): {$(VPATH)}st.h
+iseq.$(OBJEXT): {$(VPATH)}subst.h
+iseq.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+iseq.$(OBJEXT): {$(VPATH)}thread_native.h
+iseq.$(OBJEXT): {$(VPATH)}util.h
+iseq.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+iseq.$(OBJEXT): {$(VPATH)}vm_core.h
+iseq.$(OBJEXT): {$(VPATH)}vm_debug.h
+iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
+iseq.$(OBJEXT): {$(VPATH)}vm_sync.h
+iseq.$(OBJEXT): {$(VPATH)}yjit.h
+iseq.$(OBJEXT): {$(VPATH)}zjit.h
+jit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+jit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+jit.$(OBJEXT): $(CCAN_DIR)/list/list.h
+jit.$(OBJEXT): $(CCAN_DIR)/str/str.h
+jit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+jit.$(OBJEXT): $(top_srcdir)/internal/array.h
+jit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+jit.$(OBJEXT): $(top_srcdir)/internal/bits.h
+jit.$(OBJEXT): $(top_srcdir)/internal/box.h
+jit.$(OBJEXT): $(top_srcdir)/internal/class.h
+jit.$(OBJEXT): $(top_srcdir)/internal/compile.h
+jit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+jit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+jit.$(OBJEXT): $(top_srcdir)/internal/gc.h
+jit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+jit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+jit.$(OBJEXT): $(top_srcdir)/internal/serial.h
+jit.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+jit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+jit.$(OBJEXT): $(top_srcdir)/internal/string.h
+jit.$(OBJEXT): $(top_srcdir)/internal/struct.h
+jit.$(OBJEXT): $(top_srcdir)/internal/variable.h
+jit.$(OBJEXT): $(top_srcdir)/internal/vm.h
+jit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+jit.$(OBJEXT): $(top_srcdir)/prism/arena.h
+jit.$(OBJEXT): $(top_srcdir)/prism/ast.h
+jit.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+jit.$(OBJEXT): $(top_srcdir)/prism/comments.h
+jit.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+jit.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+jit.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+jit.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+jit.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+jit.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+jit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+jit.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+jit.$(OBJEXT): $(top_srcdir)/prism/integer.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+jit.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+jit.$(OBJEXT): $(top_srcdir)/prism/json.h
+jit.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+jit.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+jit.$(OBJEXT): $(top_srcdir)/prism/node.h
+jit.$(OBJEXT): $(top_srcdir)/prism/options.h
+jit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+jit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+jit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+jit.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+jit.$(OBJEXT): $(top_srcdir)/prism/source.h
+jit.$(OBJEXT): $(top_srcdir)/prism/stream.h
+jit.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+jit.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+jit.$(OBJEXT): $(top_srcdir)/prism/version.h
+jit.$(OBJEXT): {$(VPATH)}assert.h
+jit.$(OBJEXT): {$(VPATH)}atomic.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+jit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+jit.$(OBJEXT): {$(VPATH)}builtin.h
+jit.$(OBJEXT): {$(VPATH)}config.h
+jit.$(OBJEXT): {$(VPATH)}constant.h
+jit.$(OBJEXT): {$(VPATH)}debug_counter.h
+jit.$(OBJEXT): {$(VPATH)}defines.h
+jit.$(OBJEXT): {$(VPATH)}encindex.h
+jit.$(OBJEXT): {$(VPATH)}encoding.h
+jit.$(OBJEXT): {$(VPATH)}id.h
+jit.$(OBJEXT): {$(VPATH)}id_table.h
+jit.$(OBJEXT): {$(VPATH)}insns.def
+jit.$(OBJEXT): {$(VPATH)}insns.inc
+jit.$(OBJEXT): {$(VPATH)}insns_info.inc
+jit.$(OBJEXT): {$(VPATH)}intern.h
+jit.$(OBJEXT): {$(VPATH)}internal.h
+jit.$(OBJEXT): {$(VPATH)}internal/abi.h
+jit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+jit.$(OBJEXT): {$(VPATH)}internal/assume.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+jit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+jit.$(OBJEXT): {$(VPATH)}internal/cast.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+jit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+jit.$(OBJEXT): {$(VPATH)}internal/config.h
+jit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+jit.$(OBJEXT): {$(VPATH)}internal/core.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+jit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+jit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+jit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+jit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+jit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+jit.$(OBJEXT): {$(VPATH)}internal/error.h
+jit.$(OBJEXT): {$(VPATH)}internal/eval.h
+jit.$(OBJEXT): {$(VPATH)}internal/event.h
+jit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+jit.$(OBJEXT): {$(VPATH)}internal/gc.h
+jit.$(OBJEXT): {$(VPATH)}internal/glob.h
+jit.$(OBJEXT): {$(VPATH)}internal/globals.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+jit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+jit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+jit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+jit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+jit.$(OBJEXT): {$(VPATH)}internal/memory.h
+jit.$(OBJEXT): {$(VPATH)}internal/method.h
+jit.$(OBJEXT): {$(VPATH)}internal/module.h
+jit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+jit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+jit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+jit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+jit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+jit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+jit.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+jit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+jit.$(OBJEXT): {$(VPATH)}internal/value.h
+jit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+jit.$(OBJEXT): {$(VPATH)}internal/variable.h
+jit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+jit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+jit.$(OBJEXT): {$(VPATH)}iseq.h
+jit.$(OBJEXT): {$(VPATH)}jit.c
+jit.$(OBJEXT): {$(VPATH)}method.h
+jit.$(OBJEXT): {$(VPATH)}missing.h
+jit.$(OBJEXT): {$(VPATH)}node.h
+jit.$(OBJEXT): {$(VPATH)}onigmo.h
+jit.$(OBJEXT): {$(VPATH)}oniguruma.h
+jit.$(OBJEXT): {$(VPATH)}prism_compile.h
+jit.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+jit.$(OBJEXT): {$(VPATH)}ruby_assert.h
+jit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+jit.$(OBJEXT): {$(VPATH)}rubyparser.h
+jit.$(OBJEXT): {$(VPATH)}shape.h
+jit.$(OBJEXT): {$(VPATH)}st.h
+jit.$(OBJEXT): {$(VPATH)}subst.h
+jit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+jit.$(OBJEXT): {$(VPATH)}thread_native.h
+jit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+jit.$(OBJEXT): {$(VPATH)}vm_core.h
+jit.$(OBJEXT): {$(VPATH)}vm_debug.h
+jit.$(OBJEXT): {$(VPATH)}vm_opts.h
+jit.$(OBJEXT): {$(VPATH)}vm_sync.h
+jit.$(OBJEXT): {$(VPATH)}zjit.h
+load.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+load.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+load.$(OBJEXT): $(CCAN_DIR)/list/list.h
+load.$(OBJEXT): $(CCAN_DIR)/str/str.h
+load.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+load.$(OBJEXT): $(hdrdir)/ruby/version.h
+load.$(OBJEXT): $(top_srcdir)/internal/array.h
+load.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+load.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+load.$(OBJEXT): $(top_srcdir)/internal/bits.h
+load.$(OBJEXT): $(top_srcdir)/internal/box.h
+load.$(OBJEXT): $(top_srcdir)/internal/compar.h
+load.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+load.$(OBJEXT): $(top_srcdir)/internal/complex.h
+load.$(OBJEXT): $(top_srcdir)/internal/dir.h
+load.$(OBJEXT): $(top_srcdir)/internal/error.h
+load.$(OBJEXT): $(top_srcdir)/internal/eval.h
+load.$(OBJEXT): $(top_srcdir)/internal/file.h
+load.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+load.$(OBJEXT): $(top_srcdir)/internal/gc.h
+load.$(OBJEXT): $(top_srcdir)/internal/hash.h
+load.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+load.$(OBJEXT): $(top_srcdir)/internal/load.h
+load.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+load.$(OBJEXT): $(top_srcdir)/internal/parse.h
+load.$(OBJEXT): $(top_srcdir)/internal/rational.h
+load.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+load.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+load.$(OBJEXT): $(top_srcdir)/internal/serial.h
+load.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+load.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+load.$(OBJEXT): $(top_srcdir)/internal/string.h
+load.$(OBJEXT): $(top_srcdir)/internal/struct.h
+load.$(OBJEXT): $(top_srcdir)/internal/thread.h
+load.$(OBJEXT): $(top_srcdir)/internal/variable.h
+load.$(OBJEXT): $(top_srcdir)/internal/vm.h
+load.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+load.$(OBJEXT): $(top_srcdir)/prism/arena.h
+load.$(OBJEXT): $(top_srcdir)/prism/ast.h
+load.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+load.$(OBJEXT): $(top_srcdir)/prism/comments.h
+load.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+load.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+load.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+load.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+load.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+load.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+load.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+load.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+load.$(OBJEXT): $(top_srcdir)/prism/integer.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+load.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+load.$(OBJEXT): $(top_srcdir)/prism/json.h
+load.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+load.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+load.$(OBJEXT): $(top_srcdir)/prism/node.h
+load.$(OBJEXT): $(top_srcdir)/prism/options.h
+load.$(OBJEXT): $(top_srcdir)/prism/parser.h
+load.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+load.$(OBJEXT): $(top_srcdir)/prism/prism.h
+load.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+load.$(OBJEXT): $(top_srcdir)/prism/source.h
+load.$(OBJEXT): $(top_srcdir)/prism/stream.h
+load.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+load.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+load.$(OBJEXT): $(top_srcdir)/prism/version.h
+load.$(OBJEXT): {$(VPATH)}assert.h
+load.$(OBJEXT): {$(VPATH)}atomic.h
+load.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+load.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+load.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+load.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+load.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+load.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+load.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+load.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+load.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+load.$(OBJEXT): {$(VPATH)}config.h
+load.$(OBJEXT): {$(VPATH)}constant.h
+load.$(OBJEXT): {$(VPATH)}darray.h
+load.$(OBJEXT): {$(VPATH)}defines.h
+load.$(OBJEXT): {$(VPATH)}dln.h
+load.$(OBJEXT): {$(VPATH)}encindex.h
+load.$(OBJEXT): {$(VPATH)}encoding.h
+load.$(OBJEXT): {$(VPATH)}eval_intern.h
+load.$(OBJEXT): {$(VPATH)}id.h
+load.$(OBJEXT): {$(VPATH)}id_table.h
+load.$(OBJEXT): {$(VPATH)}intern.h
+load.$(OBJEXT): {$(VPATH)}internal.h
+load.$(OBJEXT): {$(VPATH)}internal/abi.h
+load.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+load.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+load.$(OBJEXT): {$(VPATH)}internal/assume.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+load.$(OBJEXT): {$(VPATH)}internal/cast.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+load.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+load.$(OBJEXT): {$(VPATH)}internal/config.h
+load.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+load.$(OBJEXT): {$(VPATH)}internal/core.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+load.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+load.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+load.$(OBJEXT): {$(VPATH)}internal/ctype.h
+load.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+load.$(OBJEXT): {$(VPATH)}internal/dosish.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+load.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+load.$(OBJEXT): {$(VPATH)}internal/error.h
+load.$(OBJEXT): {$(VPATH)}internal/eval.h
+load.$(OBJEXT): {$(VPATH)}internal/event.h
+load.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+load.$(OBJEXT): {$(VPATH)}internal/gc.h
+load.$(OBJEXT): {$(VPATH)}internal/glob.h
+load.$(OBJEXT): {$(VPATH)}internal/globals.h
+load.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+load.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+load.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+load.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+load.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+load.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+load.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+load.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+load.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+load.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+load.$(OBJEXT): {$(VPATH)}internal/iterator.h
+load.$(OBJEXT): {$(VPATH)}internal/memory.h
+load.$(OBJEXT): {$(VPATH)}internal/method.h
+load.$(OBJEXT): {$(VPATH)}internal/module.h
+load.$(OBJEXT): {$(VPATH)}internal/newobj.h
+load.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+load.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+load.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+load.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+load.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+load.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+load.$(OBJEXT): {$(VPATH)}internal/symbol.h
+load.$(OBJEXT): {$(VPATH)}internal/value.h
+load.$(OBJEXT): {$(VPATH)}internal/value_type.h
+load.$(OBJEXT): {$(VPATH)}internal/variable.h
+load.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+load.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+load.$(OBJEXT): {$(VPATH)}iseq.h
+load.$(OBJEXT): {$(VPATH)}load.c
+load.$(OBJEXT): {$(VPATH)}method.h
+load.$(OBJEXT): {$(VPATH)}missing.h
+load.$(OBJEXT): {$(VPATH)}node.h
+load.$(OBJEXT): {$(VPATH)}onigmo.h
+load.$(OBJEXT): {$(VPATH)}oniguruma.h
+load.$(OBJEXT): {$(VPATH)}prism_compile.h
+load.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+load.$(OBJEXT): {$(VPATH)}probes.dmyh
+load.$(OBJEXT): {$(VPATH)}probes.h
+load.$(OBJEXT): {$(VPATH)}ractor.h
+load.$(OBJEXT): {$(VPATH)}ractor_core.h
+load.$(OBJEXT): {$(VPATH)}ruby_assert.h
+load.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+load.$(OBJEXT): {$(VPATH)}rubyparser.h
+load.$(OBJEXT): {$(VPATH)}shape.h
+load.$(OBJEXT): {$(VPATH)}st.h
+load.$(OBJEXT): {$(VPATH)}subst.h
+load.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+load.$(OBJEXT): {$(VPATH)}thread_native.h
+load.$(OBJEXT): {$(VPATH)}util.h
+load.$(OBJEXT): {$(VPATH)}vm_core.h
+load.$(OBJEXT): {$(VPATH)}vm_debug.h
+load.$(OBJEXT): {$(VPATH)}vm_opts.h
+load.$(OBJEXT): {$(VPATH)}zjit.h
+loadpath.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+loadpath.$(OBJEXT): $(hdrdir)/ruby/version.h
+loadpath.$(OBJEXT): $(top_srcdir)/version.h
+loadpath.$(OBJEXT): {$(VPATH)}assert.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+loadpath.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+loadpath.$(OBJEXT): {$(VPATH)}config.h
+loadpath.$(OBJEXT): {$(VPATH)}defines.h
+loadpath.$(OBJEXT): {$(VPATH)}intern.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/abi.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/assume.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/cast.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/config.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/ctype.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/dosish.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/error.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/eval.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/event.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/gc.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/glob.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/globals.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/iterator.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/memory.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/method.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/module.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/newobj.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/symbol.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/value.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/value_type.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/variable.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+loadpath.$(OBJEXT): {$(VPATH)}loadpath.c
+loadpath.$(OBJEXT): {$(VPATH)}missing.h
+loadpath.$(OBJEXT): {$(VPATH)}st.h
+loadpath.$(OBJEXT): {$(VPATH)}subst.h
+loadpath.$(OBJEXT): {$(VPATH)}verconf.h
+localeinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+localeinit.$(OBJEXT): {$(VPATH)}assert.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+localeinit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+localeinit.$(OBJEXT): {$(VPATH)}config.h
+localeinit.$(OBJEXT): {$(VPATH)}defines.h
+localeinit.$(OBJEXT): {$(VPATH)}encindex.h
+localeinit.$(OBJEXT): {$(VPATH)}encoding.h
+localeinit.$(OBJEXT): {$(VPATH)}intern.h
+localeinit.$(OBJEXT): {$(VPATH)}internal.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/abi.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/assume.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/cast.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/config.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/error.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/eval.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/event.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/gc.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/glob.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/globals.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/memory.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/method.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/module.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/value.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/variable.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+localeinit.$(OBJEXT): {$(VPATH)}localeinit.c
+localeinit.$(OBJEXT): {$(VPATH)}missing.h
+localeinit.$(OBJEXT): {$(VPATH)}onigmo.h
+localeinit.$(OBJEXT): {$(VPATH)}oniguruma.h
+localeinit.$(OBJEXT): {$(VPATH)}st.h
+localeinit.$(OBJEXT): {$(VPATH)}subst.h
+main.$(OBJEXT): $(hdrdir)/ruby.h
+main.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+main.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+main.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+main.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+main.$(OBJEXT): {$(VPATH)}assert.h
+main.$(OBJEXT): {$(VPATH)}backward.h
+main.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+main.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+main.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+main.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+main.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+main.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+main.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+main.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+main.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+main.$(OBJEXT): {$(VPATH)}config.h
+main.$(OBJEXT): {$(VPATH)}defines.h
+main.$(OBJEXT): {$(VPATH)}intern.h
+main.$(OBJEXT): {$(VPATH)}internal/abi.h
+main.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+main.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+main.$(OBJEXT): {$(VPATH)}internal/assume.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+main.$(OBJEXT): {$(VPATH)}internal/cast.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+main.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+main.$(OBJEXT): {$(VPATH)}internal/config.h
+main.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+main.$(OBJEXT): {$(VPATH)}internal/core.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+main.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+main.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+main.$(OBJEXT): {$(VPATH)}internal/ctype.h
+main.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+main.$(OBJEXT): {$(VPATH)}internal/dosish.h
+main.$(OBJEXT): {$(VPATH)}internal/error.h
+main.$(OBJEXT): {$(VPATH)}internal/eval.h
+main.$(OBJEXT): {$(VPATH)}internal/event.h
+main.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+main.$(OBJEXT): {$(VPATH)}internal/gc.h
+main.$(OBJEXT): {$(VPATH)}internal/glob.h
+main.$(OBJEXT): {$(VPATH)}internal/globals.h
+main.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+main.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+main.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+main.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+main.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+main.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+main.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+main.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+main.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+main.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+main.$(OBJEXT): {$(VPATH)}internal/iterator.h
+main.$(OBJEXT): {$(VPATH)}internal/memory.h
+main.$(OBJEXT): {$(VPATH)}internal/method.h
+main.$(OBJEXT): {$(VPATH)}internal/module.h
+main.$(OBJEXT): {$(VPATH)}internal/newobj.h
+main.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+main.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+main.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+main.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+main.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+main.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+main.$(OBJEXT): {$(VPATH)}internal/symbol.h
+main.$(OBJEXT): {$(VPATH)}internal/value.h
+main.$(OBJEXT): {$(VPATH)}internal/value_type.h
+main.$(OBJEXT): {$(VPATH)}internal/variable.h
+main.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+main.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+main.$(OBJEXT): {$(VPATH)}main.c
+main.$(OBJEXT): {$(VPATH)}missing.h
+main.$(OBJEXT): {$(VPATH)}st.h
+main.$(OBJEXT): {$(VPATH)}subst.h
+main.$(OBJEXT): {$(VPATH)}vm_debug.h
+marshal.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+marshal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+marshal.$(OBJEXT): $(CCAN_DIR)/list/list.h
+marshal.$(OBJEXT): $(CCAN_DIR)/str/str.h
+marshal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+marshal.$(OBJEXT): $(hdrdir)/ruby/version.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/array.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/bits.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/box.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/class.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/compar.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/error.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/gc.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/hash.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/object.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/re.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/serial.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/string.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/struct.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/util.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/variable.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/vm.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+marshal.$(OBJEXT): {$(VPATH)}assert.h
+marshal.$(OBJEXT): {$(VPATH)}atomic.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+marshal.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+marshal.$(OBJEXT): {$(VPATH)}builtin.h
+marshal.$(OBJEXT): {$(VPATH)}config.h
+marshal.$(OBJEXT): {$(VPATH)}constant.h
+marshal.$(OBJEXT): {$(VPATH)}debug_counter.h
+marshal.$(OBJEXT): {$(VPATH)}defines.h
+marshal.$(OBJEXT): {$(VPATH)}encindex.h
+marshal.$(OBJEXT): {$(VPATH)}encoding.h
+marshal.$(OBJEXT): {$(VPATH)}id.h
+marshal.$(OBJEXT): {$(VPATH)}id_table.h
+marshal.$(OBJEXT): {$(VPATH)}intern.h
+marshal.$(OBJEXT): {$(VPATH)}internal.h
+marshal.$(OBJEXT): {$(VPATH)}internal/abi.h
+marshal.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+marshal.$(OBJEXT): {$(VPATH)}internal/assume.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+marshal.$(OBJEXT): {$(VPATH)}internal/cast.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+marshal.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+marshal.$(OBJEXT): {$(VPATH)}internal/config.h
+marshal.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+marshal.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+marshal.$(OBJEXT): {$(VPATH)}internal/ctype.h
+marshal.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+marshal.$(OBJEXT): {$(VPATH)}internal/dosish.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+marshal.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+marshal.$(OBJEXT): {$(VPATH)}internal/error.h
+marshal.$(OBJEXT): {$(VPATH)}internal/eval.h
+marshal.$(OBJEXT): {$(VPATH)}internal/event.h
+marshal.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+marshal.$(OBJEXT): {$(VPATH)}internal/gc.h
+marshal.$(OBJEXT): {$(VPATH)}internal/glob.h
+marshal.$(OBJEXT): {$(VPATH)}internal/globals.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+marshal.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+marshal.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+marshal.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+marshal.$(OBJEXT): {$(VPATH)}internal/iterator.h
+marshal.$(OBJEXT): {$(VPATH)}internal/memory.h
+marshal.$(OBJEXT): {$(VPATH)}internal/method.h
+marshal.$(OBJEXT): {$(VPATH)}internal/module.h
+marshal.$(OBJEXT): {$(VPATH)}internal/newobj.h
+marshal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+marshal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+marshal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+marshal.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+marshal.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+marshal.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+marshal.$(OBJEXT): {$(VPATH)}internal/symbol.h
+marshal.$(OBJEXT): {$(VPATH)}internal/value.h
+marshal.$(OBJEXT): {$(VPATH)}internal/value_type.h
+marshal.$(OBJEXT): {$(VPATH)}internal/variable.h
+marshal.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+marshal.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+marshal.$(OBJEXT): {$(VPATH)}io.h
+marshal.$(OBJEXT): {$(VPATH)}marshal.c
+marshal.$(OBJEXT): {$(VPATH)}marshal.rbinc
+marshal.$(OBJEXT): {$(VPATH)}method.h
+marshal.$(OBJEXT): {$(VPATH)}missing.h
+marshal.$(OBJEXT): {$(VPATH)}node.h
+marshal.$(OBJEXT): {$(VPATH)}onigmo.h
+marshal.$(OBJEXT): {$(VPATH)}oniguruma.h
+marshal.$(OBJEXT): {$(VPATH)}re.h
+marshal.$(OBJEXT): {$(VPATH)}regex.h
+marshal.$(OBJEXT): {$(VPATH)}ruby_assert.h
+marshal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+marshal.$(OBJEXT): {$(VPATH)}rubyparser.h
+marshal.$(OBJEXT): {$(VPATH)}shape.h
+marshal.$(OBJEXT): {$(VPATH)}st.h
+marshal.$(OBJEXT): {$(VPATH)}subst.h
+marshal.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+marshal.$(OBJEXT): {$(VPATH)}thread_native.h
+marshal.$(OBJEXT): {$(VPATH)}util.h
+marshal.$(OBJEXT): {$(VPATH)}vm_core.h
+marshal.$(OBJEXT): {$(VPATH)}vm_debug.h
+marshal.$(OBJEXT): {$(VPATH)}vm_opts.h
+marshal.$(OBJEXT): {$(VPATH)}vm_sync.h
+math.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+math.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+math.$(OBJEXT): $(top_srcdir)/internal/class.h
+math.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+math.$(OBJEXT): $(top_srcdir)/internal/complex.h
+math.$(OBJEXT): $(top_srcdir)/internal/gc.h
+math.$(OBJEXT): $(top_srcdir)/internal/math.h
+math.$(OBJEXT): $(top_srcdir)/internal/object.h
+math.$(OBJEXT): $(top_srcdir)/internal/serial.h
+math.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+math.$(OBJEXT): $(top_srcdir)/internal/variable.h
+math.$(OBJEXT): $(top_srcdir)/internal/vm.h
+math.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+math.$(OBJEXT): {$(VPATH)}assert.h
+math.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+math.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+math.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+math.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+math.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+math.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+math.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+math.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+math.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+math.$(OBJEXT): {$(VPATH)}config.h
+math.$(OBJEXT): {$(VPATH)}constant.h
+math.$(OBJEXT): {$(VPATH)}defines.h
+math.$(OBJEXT): {$(VPATH)}id_table.h
+math.$(OBJEXT): {$(VPATH)}intern.h
+math.$(OBJEXT): {$(VPATH)}internal.h
+math.$(OBJEXT): {$(VPATH)}internal/abi.h
+math.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+math.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+math.$(OBJEXT): {$(VPATH)}internal/assume.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+math.$(OBJEXT): {$(VPATH)}internal/cast.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+math.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+math.$(OBJEXT): {$(VPATH)}internal/config.h
+math.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+math.$(OBJEXT): {$(VPATH)}internal/core.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+math.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+math.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+math.$(OBJEXT): {$(VPATH)}internal/ctype.h
+math.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+math.$(OBJEXT): {$(VPATH)}internal/dosish.h
+math.$(OBJEXT): {$(VPATH)}internal/error.h
+math.$(OBJEXT): {$(VPATH)}internal/eval.h
+math.$(OBJEXT): {$(VPATH)}internal/event.h
+math.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+math.$(OBJEXT): {$(VPATH)}internal/gc.h
+math.$(OBJEXT): {$(VPATH)}internal/glob.h
+math.$(OBJEXT): {$(VPATH)}internal/globals.h
+math.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+math.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+math.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+math.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+math.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+math.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+math.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+math.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+math.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+math.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+math.$(OBJEXT): {$(VPATH)}internal/iterator.h
+math.$(OBJEXT): {$(VPATH)}internal/memory.h
+math.$(OBJEXT): {$(VPATH)}internal/method.h
+math.$(OBJEXT): {$(VPATH)}internal/module.h
+math.$(OBJEXT): {$(VPATH)}internal/newobj.h
+math.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+math.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+math.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+math.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+math.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+math.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+math.$(OBJEXT): {$(VPATH)}internal/symbol.h
+math.$(OBJEXT): {$(VPATH)}internal/value.h
+math.$(OBJEXT): {$(VPATH)}internal/value_type.h
+math.$(OBJEXT): {$(VPATH)}internal/variable.h
+math.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+math.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+math.$(OBJEXT): {$(VPATH)}math.c
+math.$(OBJEXT): {$(VPATH)}missing.h
+math.$(OBJEXT): {$(VPATH)}shape.h
+math.$(OBJEXT): {$(VPATH)}st.h
+math.$(OBJEXT): {$(VPATH)}subst.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/list/list.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/str/str.h
+memory_view.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/array.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/box.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/gc.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/hash.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/serial.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/struct.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/variable.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/vm.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+memory_view.$(OBJEXT): {$(VPATH)}assert.h
+memory_view.$(OBJEXT): {$(VPATH)}atomic.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+memory_view.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+memory_view.$(OBJEXT): {$(VPATH)}config.h
+memory_view.$(OBJEXT): {$(VPATH)}constant.h
+memory_view.$(OBJEXT): {$(VPATH)}debug_counter.h
+memory_view.$(OBJEXT): {$(VPATH)}defines.h
+memory_view.$(OBJEXT): {$(VPATH)}encoding.h
+memory_view.$(OBJEXT): {$(VPATH)}id.h
+memory_view.$(OBJEXT): {$(VPATH)}id_table.h
+memory_view.$(OBJEXT): {$(VPATH)}intern.h
+memory_view.$(OBJEXT): {$(VPATH)}internal.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/abi.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/assume.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/cast.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/config.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/ctype.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/dosish.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/error.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/eval.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/event.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/gc.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/glob.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/globals.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/iterator.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/memory.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/method.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/module.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/newobj.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/symbol.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/value.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/value_type.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/variable.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+memory_view.$(OBJEXT): {$(VPATH)}memory_view.c
+memory_view.$(OBJEXT): {$(VPATH)}memory_view.h
+memory_view.$(OBJEXT): {$(VPATH)}method.h
+memory_view.$(OBJEXT): {$(VPATH)}missing.h
+memory_view.$(OBJEXT): {$(VPATH)}node.h
+memory_view.$(OBJEXT): {$(VPATH)}onigmo.h
+memory_view.$(OBJEXT): {$(VPATH)}oniguruma.h
+memory_view.$(OBJEXT): {$(VPATH)}ruby_assert.h
+memory_view.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+memory_view.$(OBJEXT): {$(VPATH)}rubyparser.h
+memory_view.$(OBJEXT): {$(VPATH)}shape.h
+memory_view.$(OBJEXT): {$(VPATH)}st.h
+memory_view.$(OBJEXT): {$(VPATH)}subst.h
+memory_view.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+memory_view.$(OBJEXT): {$(VPATH)}thread_native.h
+memory_view.$(OBJEXT): {$(VPATH)}util.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_core.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_debug.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_opts.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_sync.h
+miniinit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+miniinit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+miniinit.$(OBJEXT): $(CCAN_DIR)/list/list.h
+miniinit.$(OBJEXT): $(CCAN_DIR)/str/str.h
+miniinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/array.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/bits.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/box.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/compar.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/complex.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/eval.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/gc.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/parse.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/rational.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/serial.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/struct.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/variable.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/vm.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/arena.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/ast.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/comments.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/integer.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/json.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/node.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/options.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/source.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/stream.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/version.h
+miniinit.$(OBJEXT): {$(VPATH)}array.rb
+miniinit.$(OBJEXT): {$(VPATH)}assert.h
+miniinit.$(OBJEXT): {$(VPATH)}ast.rb
+miniinit.$(OBJEXT): {$(VPATH)}atomic.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+miniinit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+miniinit.$(OBJEXT): {$(VPATH)}builtin.h
+miniinit.$(OBJEXT): {$(VPATH)}config.h
+miniinit.$(OBJEXT): {$(VPATH)}constant.h
+miniinit.$(OBJEXT): {$(VPATH)}defines.h
+miniinit.$(OBJEXT): {$(VPATH)}dir.rb
+miniinit.$(OBJEXT): {$(VPATH)}encoding.h
+miniinit.$(OBJEXT): {$(VPATH)}gc.rb
+miniinit.$(OBJEXT): {$(VPATH)}gem_prelude.rb
+miniinit.$(OBJEXT): {$(VPATH)}id.h
+miniinit.$(OBJEXT): {$(VPATH)}id_table.h
+miniinit.$(OBJEXT): {$(VPATH)}intern.h
+miniinit.$(OBJEXT): {$(VPATH)}internal.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/abi.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/assume.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/cast.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/config.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/error.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/eval.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/event.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/gc.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/glob.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/globals.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/memory.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/method.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/module.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/value.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/variable.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+miniinit.$(OBJEXT): {$(VPATH)}io.rb
+miniinit.$(OBJEXT): {$(VPATH)}iseq.h
+miniinit.$(OBJEXT): {$(VPATH)}jit_hook.rb
+miniinit.$(OBJEXT): {$(VPATH)}jit_undef.rb
+miniinit.$(OBJEXT): {$(VPATH)}kernel.rb
+miniinit.$(OBJEXT): {$(VPATH)}marshal.rb
+miniinit.$(OBJEXT): {$(VPATH)}method.h
+miniinit.$(OBJEXT): {$(VPATH)}mini_builtin.c
+miniinit.$(OBJEXT): {$(VPATH)}miniinit.c
+miniinit.$(OBJEXT): {$(VPATH)}miniprelude.c
+miniinit.$(OBJEXT): {$(VPATH)}missing.h
+miniinit.$(OBJEXT): {$(VPATH)}nilclass.rb
+miniinit.$(OBJEXT): {$(VPATH)}node.h
+miniinit.$(OBJEXT): {$(VPATH)}numeric.rb
+miniinit.$(OBJEXT): {$(VPATH)}onigmo.h
+miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h
+miniinit.$(OBJEXT): {$(VPATH)}pack.rb
+miniinit.$(OBJEXT): {$(VPATH)}pathname_builtin.rb
+miniinit.$(OBJEXT): {$(VPATH)}prelude.rb
+miniinit.$(OBJEXT): {$(VPATH)}prism_compile.h
+miniinit.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+miniinit.$(OBJEXT): {$(VPATH)}ractor.rb
+miniinit.$(OBJEXT): {$(VPATH)}ruby_assert.h
+miniinit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+miniinit.$(OBJEXT): {$(VPATH)}rubyparser.h
+miniinit.$(OBJEXT): {$(VPATH)}shape.h
+miniinit.$(OBJEXT): {$(VPATH)}st.h
+miniinit.$(OBJEXT): {$(VPATH)}subst.h
+miniinit.$(OBJEXT): {$(VPATH)}symbol.rb
+miniinit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+miniinit.$(OBJEXT): {$(VPATH)}thread_native.h
+miniinit.$(OBJEXT): {$(VPATH)}thread_sync.rb
+miniinit.$(OBJEXT): {$(VPATH)}timev.rb
+miniinit.$(OBJEXT): {$(VPATH)}trace_point.rb
+miniinit.$(OBJEXT): {$(VPATH)}vm_core.h
+miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
+miniinit.$(OBJEXT): {$(VPATH)}warning.rb
+miniinit.$(OBJEXT): {$(VPATH)}yjit.rb
+miniinit.$(OBJEXT): {$(VPATH)}zjit.rb
+node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+node.$(OBJEXT): $(CCAN_DIR)/list/list.h
+node.$(OBJEXT): $(CCAN_DIR)/str/str.h
+node.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+node.$(OBJEXT): $(top_srcdir)/internal/array.h
+node.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+node.$(OBJEXT): $(top_srcdir)/internal/box.h
+node.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+node.$(OBJEXT): $(top_srcdir)/internal/gc.h
+node.$(OBJEXT): $(top_srcdir)/internal/hash.h
+node.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+node.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+node.$(OBJEXT): $(top_srcdir)/internal/serial.h
+node.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+node.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+node.$(OBJEXT): $(top_srcdir)/internal/struct.h
+node.$(OBJEXT): $(top_srcdir)/internal/variable.h
+node.$(OBJEXT): $(top_srcdir)/internal/vm.h
+node.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+node.$(OBJEXT): {$(VPATH)}assert.h
+node.$(OBJEXT): {$(VPATH)}atomic.h
+node.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+node.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+node.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+node.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+node.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+node.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+node.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+node.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+node.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+node.$(OBJEXT): {$(VPATH)}config.h
+node.$(OBJEXT): {$(VPATH)}constant.h
+node.$(OBJEXT): {$(VPATH)}defines.h
+node.$(OBJEXT): {$(VPATH)}encoding.h
+node.$(OBJEXT): {$(VPATH)}id.h
+node.$(OBJEXT): {$(VPATH)}id_table.h
+node.$(OBJEXT): {$(VPATH)}intern.h
+node.$(OBJEXT): {$(VPATH)}internal.h
+node.$(OBJEXT): {$(VPATH)}internal/abi.h
+node.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+node.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+node.$(OBJEXT): {$(VPATH)}internal/assume.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+node.$(OBJEXT): {$(VPATH)}internal/cast.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+node.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+node.$(OBJEXT): {$(VPATH)}internal/config.h
+node.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+node.$(OBJEXT): {$(VPATH)}internal/core.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+node.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+node.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+node.$(OBJEXT): {$(VPATH)}internal/ctype.h
+node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+node.$(OBJEXT): {$(VPATH)}internal/dosish.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+node.$(OBJEXT): {$(VPATH)}internal/error.h
+node.$(OBJEXT): {$(VPATH)}internal/eval.h
+node.$(OBJEXT): {$(VPATH)}internal/event.h
+node.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+node.$(OBJEXT): {$(VPATH)}internal/gc.h
+node.$(OBJEXT): {$(VPATH)}internal/glob.h
+node.$(OBJEXT): {$(VPATH)}internal/globals.h
+node.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+node.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+node.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+node.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+node.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+node.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+node.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+node.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+node.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+node.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+node.$(OBJEXT): {$(VPATH)}internal/iterator.h
+node.$(OBJEXT): {$(VPATH)}internal/memory.h
+node.$(OBJEXT): {$(VPATH)}internal/method.h
+node.$(OBJEXT): {$(VPATH)}internal/module.h
+node.$(OBJEXT): {$(VPATH)}internal/newobj.h
+node.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+node.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+node.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+node.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+node.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+node.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+node.$(OBJEXT): {$(VPATH)}internal/symbol.h
+node.$(OBJEXT): {$(VPATH)}internal/value.h
+node.$(OBJEXT): {$(VPATH)}internal/value_type.h
+node.$(OBJEXT): {$(VPATH)}internal/variable.h
+node.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+node.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+node.$(OBJEXT): {$(VPATH)}method.h
+node.$(OBJEXT): {$(VPATH)}missing.h
+node.$(OBJEXT): {$(VPATH)}node.c
+node.$(OBJEXT): {$(VPATH)}node.h
+node.$(OBJEXT): {$(VPATH)}node_name.inc
+node.$(OBJEXT): {$(VPATH)}onigmo.h
+node.$(OBJEXT): {$(VPATH)}oniguruma.h
+node.$(OBJEXT): {$(VPATH)}ruby_assert.h
+node.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+node.$(OBJEXT): {$(VPATH)}rubyparser.h
+node.$(OBJEXT): {$(VPATH)}shape.h
+node.$(OBJEXT): {$(VPATH)}st.h
+node.$(OBJEXT): {$(VPATH)}subst.h
+node.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+node.$(OBJEXT): {$(VPATH)}thread_native.h
+node.$(OBJEXT): {$(VPATH)}vm_core.h
+node.$(OBJEXT): {$(VPATH)}vm_opts.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h
+node_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/array.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/bits.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/box.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/class.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/compar.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/complex.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/gc.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/hash.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/parse.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/rational.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/serial.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/struct.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/variable.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+node_dump.$(OBJEXT): {$(VPATH)}assert.h
+node_dump.$(OBJEXT): {$(VPATH)}atomic.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+node_dump.$(OBJEXT): {$(VPATH)}config.h
+node_dump.$(OBJEXT): {$(VPATH)}constant.h
+node_dump.$(OBJEXT): {$(VPATH)}debug_counter.h
+node_dump.$(OBJEXT): {$(VPATH)}defines.h
+node_dump.$(OBJEXT): {$(VPATH)}encoding.h
+node_dump.$(OBJEXT): {$(VPATH)}id.h
+node_dump.$(OBJEXT): {$(VPATH)}id_table.h
+node_dump.$(OBJEXT): {$(VPATH)}intern.h
+node_dump.$(OBJEXT): {$(VPATH)}internal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/abi.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/assume.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/cast.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/config.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/ctype.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/dosish.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/eval.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/event.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/gc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/glob.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/globals.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/iterator.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/memory.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/method.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/module.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/newobj.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/symbol.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/value.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/value_type.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/variable.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+node_dump.$(OBJEXT): {$(VPATH)}method.h
+node_dump.$(OBJEXT): {$(VPATH)}missing.h
+node_dump.$(OBJEXT): {$(VPATH)}node.h
+node_dump.$(OBJEXT): {$(VPATH)}node_dump.c
+node_dump.$(OBJEXT): {$(VPATH)}onigmo.h
+node_dump.$(OBJEXT): {$(VPATH)}oniguruma.h
+node_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
+node_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+node_dump.$(OBJEXT): {$(VPATH)}rubyparser.h
+node_dump.$(OBJEXT): {$(VPATH)}shape.h
+node_dump.$(OBJEXT): {$(VPATH)}st.h
+node_dump.$(OBJEXT): {$(VPATH)}subst.h
+node_dump.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+node_dump.$(OBJEXT): {$(VPATH)}thread_native.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_core.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_debug.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_opts.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_sync.h
+numeric.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+numeric.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+numeric.$(OBJEXT): $(CCAN_DIR)/list/list.h
+numeric.$(OBJEXT): $(CCAN_DIR)/str/str.h
+numeric.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/array.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/bits.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/box.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/class.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/compar.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/complex.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/error.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/gc.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/hash.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/object.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/rational.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/serial.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/string.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/struct.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/util.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/variable.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/vm.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+numeric.$(OBJEXT): {$(VPATH)}assert.h
+numeric.$(OBJEXT): {$(VPATH)}atomic.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+numeric.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+numeric.$(OBJEXT): {$(VPATH)}builtin.h
+numeric.$(OBJEXT): {$(VPATH)}config.h
+numeric.$(OBJEXT): {$(VPATH)}constant.h
+numeric.$(OBJEXT): {$(VPATH)}defines.h
+numeric.$(OBJEXT): {$(VPATH)}encindex.h
+numeric.$(OBJEXT): {$(VPATH)}encoding.h
+numeric.$(OBJEXT): {$(VPATH)}id.h
+numeric.$(OBJEXT): {$(VPATH)}id_table.h
+numeric.$(OBJEXT): {$(VPATH)}intern.h
+numeric.$(OBJEXT): {$(VPATH)}internal.h
+numeric.$(OBJEXT): {$(VPATH)}internal/abi.h
+numeric.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+numeric.$(OBJEXT): {$(VPATH)}internal/assume.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+numeric.$(OBJEXT): {$(VPATH)}internal/cast.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+numeric.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+numeric.$(OBJEXT): {$(VPATH)}internal/config.h
+numeric.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+numeric.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+numeric.$(OBJEXT): {$(VPATH)}internal/ctype.h
+numeric.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+numeric.$(OBJEXT): {$(VPATH)}internal/dosish.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+numeric.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+numeric.$(OBJEXT): {$(VPATH)}internal/error.h
+numeric.$(OBJEXT): {$(VPATH)}internal/eval.h
+numeric.$(OBJEXT): {$(VPATH)}internal/event.h
+numeric.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+numeric.$(OBJEXT): {$(VPATH)}internal/gc.h
+numeric.$(OBJEXT): {$(VPATH)}internal/glob.h
+numeric.$(OBJEXT): {$(VPATH)}internal/globals.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+numeric.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+numeric.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+numeric.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+numeric.$(OBJEXT): {$(VPATH)}internal/iterator.h
+numeric.$(OBJEXT): {$(VPATH)}internal/memory.h
+numeric.$(OBJEXT): {$(VPATH)}internal/method.h
+numeric.$(OBJEXT): {$(VPATH)}internal/module.h
+numeric.$(OBJEXT): {$(VPATH)}internal/newobj.h
+numeric.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+numeric.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+numeric.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+numeric.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+numeric.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+numeric.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+numeric.$(OBJEXT): {$(VPATH)}internal/symbol.h
+numeric.$(OBJEXT): {$(VPATH)}internal/value.h
+numeric.$(OBJEXT): {$(VPATH)}internal/value_type.h
+numeric.$(OBJEXT): {$(VPATH)}internal/variable.h
+numeric.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+numeric.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+numeric.$(OBJEXT): {$(VPATH)}method.h
+numeric.$(OBJEXT): {$(VPATH)}missing.h
+numeric.$(OBJEXT): {$(VPATH)}node.h
+numeric.$(OBJEXT): {$(VPATH)}numeric.c
+numeric.$(OBJEXT): {$(VPATH)}numeric.rbinc
+numeric.$(OBJEXT): {$(VPATH)}onigmo.h
+numeric.$(OBJEXT): {$(VPATH)}oniguruma.h
+numeric.$(OBJEXT): {$(VPATH)}ruby_assert.h
+numeric.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+numeric.$(OBJEXT): {$(VPATH)}rubyparser.h
+numeric.$(OBJEXT): {$(VPATH)}shape.h
+numeric.$(OBJEXT): {$(VPATH)}st.h
+numeric.$(OBJEXT): {$(VPATH)}subst.h
+numeric.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+numeric.$(OBJEXT): {$(VPATH)}thread_native.h
+numeric.$(OBJEXT): {$(VPATH)}util.h
+numeric.$(OBJEXT): {$(VPATH)}vm_core.h
+numeric.$(OBJEXT): {$(VPATH)}vm_opts.h
+object.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+object.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+object.$(OBJEXT): $(CCAN_DIR)/list/list.h
+object.$(OBJEXT): $(CCAN_DIR)/str/str.h
+object.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+object.$(OBJEXT): $(hdrdir)/ruby/version.h
+object.$(OBJEXT): $(top_srcdir)/internal/array.h
+object.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+object.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+object.$(OBJEXT): $(top_srcdir)/internal/bits.h
+object.$(OBJEXT): $(top_srcdir)/internal/box.h
+object.$(OBJEXT): $(top_srcdir)/internal/class.h
+object.$(OBJEXT): $(top_srcdir)/internal/compar.h
+object.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+object.$(OBJEXT): $(top_srcdir)/internal/error.h
+object.$(OBJEXT): $(top_srcdir)/internal/eval.h
+object.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+object.$(OBJEXT): $(top_srcdir)/internal/gc.h
+object.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+object.$(OBJEXT): $(top_srcdir)/internal/inits.h
+object.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+object.$(OBJEXT): $(top_srcdir)/internal/object.h
+object.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+object.$(OBJEXT): $(top_srcdir)/internal/serial.h
+object.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+object.$(OBJEXT): $(top_srcdir)/internal/st.h
+object.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+object.$(OBJEXT): $(top_srcdir)/internal/string.h
+object.$(OBJEXT): $(top_srcdir)/internal/struct.h
+object.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+object.$(OBJEXT): $(top_srcdir)/internal/variable.h
+object.$(OBJEXT): $(top_srcdir)/internal/vm.h
+object.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+object.$(OBJEXT): {$(VPATH)}assert.h
+object.$(OBJEXT): {$(VPATH)}atomic.h
+object.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+object.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+object.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+object.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+object.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+object.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+object.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+object.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+object.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+object.$(OBJEXT): {$(VPATH)}builtin.h
+object.$(OBJEXT): {$(VPATH)}config.h
+object.$(OBJEXT): {$(VPATH)}constant.h
+object.$(OBJEXT): {$(VPATH)}debug_counter.h
+object.$(OBJEXT): {$(VPATH)}defines.h
+object.$(OBJEXT): {$(VPATH)}encindex.h
+object.$(OBJEXT): {$(VPATH)}encoding.h
+object.$(OBJEXT): {$(VPATH)}id.h
+object.$(OBJEXT): {$(VPATH)}id_table.h
+object.$(OBJEXT): {$(VPATH)}intern.h
+object.$(OBJEXT): {$(VPATH)}internal.h
+object.$(OBJEXT): {$(VPATH)}internal/abi.h
+object.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+object.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+object.$(OBJEXT): {$(VPATH)}internal/assume.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+object.$(OBJEXT): {$(VPATH)}internal/cast.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+object.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+object.$(OBJEXT): {$(VPATH)}internal/config.h
+object.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+object.$(OBJEXT): {$(VPATH)}internal/core.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+object.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+object.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+object.$(OBJEXT): {$(VPATH)}internal/ctype.h
+object.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+object.$(OBJEXT): {$(VPATH)}internal/dosish.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+object.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+object.$(OBJEXT): {$(VPATH)}internal/error.h
+object.$(OBJEXT): {$(VPATH)}internal/eval.h
+object.$(OBJEXT): {$(VPATH)}internal/event.h
+object.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+object.$(OBJEXT): {$(VPATH)}internal/gc.h
+object.$(OBJEXT): {$(VPATH)}internal/glob.h
+object.$(OBJEXT): {$(VPATH)}internal/globals.h
+object.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+object.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+object.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+object.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+object.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+object.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+object.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+object.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+object.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+object.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+object.$(OBJEXT): {$(VPATH)}internal/iterator.h
+object.$(OBJEXT): {$(VPATH)}internal/memory.h
+object.$(OBJEXT): {$(VPATH)}internal/method.h
+object.$(OBJEXT): {$(VPATH)}internal/module.h
+object.$(OBJEXT): {$(VPATH)}internal/newobj.h
+object.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+object.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+object.$(OBJEXT): {$(VPATH)}internal/st.h
+object.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+object.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+object.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+object.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+object.$(OBJEXT): {$(VPATH)}internal/symbol.h
+object.$(OBJEXT): {$(VPATH)}internal/value.h
+object.$(OBJEXT): {$(VPATH)}internal/value_type.h
+object.$(OBJEXT): {$(VPATH)}internal/variable.h
+object.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+object.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+object.$(OBJEXT): {$(VPATH)}kernel.rbinc
+object.$(OBJEXT): {$(VPATH)}method.h
+object.$(OBJEXT): {$(VPATH)}missing.h
+object.$(OBJEXT): {$(VPATH)}nilclass.rbinc
+object.$(OBJEXT): {$(VPATH)}node.h
+object.$(OBJEXT): {$(VPATH)}object.c
+object.$(OBJEXT): {$(VPATH)}onigmo.h
+object.$(OBJEXT): {$(VPATH)}oniguruma.h
+object.$(OBJEXT): {$(VPATH)}probes.dmyh
+object.$(OBJEXT): {$(VPATH)}probes.h
+object.$(OBJEXT): {$(VPATH)}ruby_assert.h
+object.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+object.$(OBJEXT): {$(VPATH)}rubyparser.h
+object.$(OBJEXT): {$(VPATH)}shape.h
+object.$(OBJEXT): {$(VPATH)}st.h
+object.$(OBJEXT): {$(VPATH)}subst.h
+object.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+object.$(OBJEXT): {$(VPATH)}thread_native.h
+object.$(OBJEXT): {$(VPATH)}util.h
+object.$(OBJEXT): {$(VPATH)}variable.h
+object.$(OBJEXT): {$(VPATH)}vm_core.h
+object.$(OBJEXT): {$(VPATH)}vm_debug.h
+object.$(OBJEXT): {$(VPATH)}vm_opts.h
+object.$(OBJEXT): {$(VPATH)}vm_sync.h
+object.$(OBJEXT): {$(VPATH)}yjit.h
+pack.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+pack.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+pack.$(OBJEXT): $(CCAN_DIR)/list/list.h
+pack.$(OBJEXT): $(CCAN_DIR)/str/str.h
+pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+pack.$(OBJEXT): $(top_srcdir)/internal/array.h
+pack.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+pack.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+pack.$(OBJEXT): $(top_srcdir)/internal/bits.h
+pack.$(OBJEXT): $(top_srcdir)/internal/box.h
+pack.$(OBJEXT): $(top_srcdir)/internal/compar.h
+pack.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+pack.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+pack.$(OBJEXT): $(top_srcdir)/internal/gc.h
+pack.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+pack.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+pack.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+pack.$(OBJEXT): $(top_srcdir)/internal/serial.h
+pack.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+pack.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+pack.$(OBJEXT): $(top_srcdir)/internal/string.h
+pack.$(OBJEXT): $(top_srcdir)/internal/struct.h
+pack.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+pack.$(OBJEXT): $(top_srcdir)/internal/variable.h
+pack.$(OBJEXT): $(top_srcdir)/internal/vm.h
+pack.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+pack.$(OBJEXT): {$(VPATH)}assert.h
+pack.$(OBJEXT): {$(VPATH)}atomic.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+pack.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+pack.$(OBJEXT): {$(VPATH)}builtin.h
+pack.$(OBJEXT): {$(VPATH)}config.h
+pack.$(OBJEXT): {$(VPATH)}constant.h
+pack.$(OBJEXT): {$(VPATH)}defines.h
+pack.$(OBJEXT): {$(VPATH)}encindex.h
+pack.$(OBJEXT): {$(VPATH)}encoding.h
+pack.$(OBJEXT): {$(VPATH)}id.h
+pack.$(OBJEXT): {$(VPATH)}id_table.h
+pack.$(OBJEXT): {$(VPATH)}intern.h
+pack.$(OBJEXT): {$(VPATH)}internal.h
+pack.$(OBJEXT): {$(VPATH)}internal/abi.h
+pack.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+pack.$(OBJEXT): {$(VPATH)}internal/assume.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+pack.$(OBJEXT): {$(VPATH)}internal/cast.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+pack.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+pack.$(OBJEXT): {$(VPATH)}internal/config.h
+pack.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+pack.$(OBJEXT): {$(VPATH)}internal/core.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+pack.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+pack.$(OBJEXT): {$(VPATH)}internal/ctype.h
+pack.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+pack.$(OBJEXT): {$(VPATH)}internal/dosish.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+pack.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+pack.$(OBJEXT): {$(VPATH)}internal/error.h
+pack.$(OBJEXT): {$(VPATH)}internal/eval.h
+pack.$(OBJEXT): {$(VPATH)}internal/event.h
+pack.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+pack.$(OBJEXT): {$(VPATH)}internal/gc.h
+pack.$(OBJEXT): {$(VPATH)}internal/glob.h
+pack.$(OBJEXT): {$(VPATH)}internal/globals.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+pack.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+pack.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+pack.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+pack.$(OBJEXT): {$(VPATH)}internal/iterator.h
+pack.$(OBJEXT): {$(VPATH)}internal/memory.h
+pack.$(OBJEXT): {$(VPATH)}internal/method.h
+pack.$(OBJEXT): {$(VPATH)}internal/module.h
+pack.$(OBJEXT): {$(VPATH)}internal/newobj.h
+pack.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+pack.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+pack.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+pack.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+pack.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+pack.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+pack.$(OBJEXT): {$(VPATH)}internal/symbol.h
+pack.$(OBJEXT): {$(VPATH)}internal/value.h
+pack.$(OBJEXT): {$(VPATH)}internal/value_type.h
+pack.$(OBJEXT): {$(VPATH)}internal/variable.h
+pack.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+pack.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+pack.$(OBJEXT): {$(VPATH)}method.h
+pack.$(OBJEXT): {$(VPATH)}missing.h
+pack.$(OBJEXT): {$(VPATH)}node.h
+pack.$(OBJEXT): {$(VPATH)}onigmo.h
+pack.$(OBJEXT): {$(VPATH)}oniguruma.h
+pack.$(OBJEXT): {$(VPATH)}pack.c
+pack.$(OBJEXT): {$(VPATH)}pack.rbinc
+pack.$(OBJEXT): {$(VPATH)}ruby_assert.h
+pack.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+pack.$(OBJEXT): {$(VPATH)}rubyparser.h
+pack.$(OBJEXT): {$(VPATH)}shape.h
+pack.$(OBJEXT): {$(VPATH)}st.h
+pack.$(OBJEXT): {$(VPATH)}subst.h
+pack.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+pack.$(OBJEXT): {$(VPATH)}thread_native.h
+pack.$(OBJEXT): {$(VPATH)}util.h
+pack.$(OBJEXT): {$(VPATH)}vm_core.h
+pack.$(OBJEXT): {$(VPATH)}vm_opts.h
+parse.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+parse.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+parse.$(OBJEXT): $(CCAN_DIR)/list/list.h
+parse.$(OBJEXT): $(CCAN_DIR)/str/str.h
+parse.$(OBJEXT): $(hdrdir)/ruby.h
+parse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+parse.$(OBJEXT): $(hdrdir)/ruby/version.h
+parse.$(OBJEXT): $(top_srcdir)/internal/array.h
+parse.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+parse.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+parse.$(OBJEXT): $(top_srcdir)/internal/bits.h
+parse.$(OBJEXT): $(top_srcdir)/internal/box.h
+parse.$(OBJEXT): $(top_srcdir)/internal/compar.h
+parse.$(OBJEXT): $(top_srcdir)/internal/compile.h
+parse.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+parse.$(OBJEXT): $(top_srcdir)/internal/complex.h
+parse.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+parse.$(OBJEXT): $(top_srcdir)/internal/error.h
+parse.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+parse.$(OBJEXT): $(top_srcdir)/internal/gc.h
+parse.$(OBJEXT): $(top_srcdir)/internal/hash.h
+parse.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+parse.$(OBJEXT): $(top_srcdir)/internal/io.h
+parse.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+parse.$(OBJEXT): $(top_srcdir)/internal/parse.h
+parse.$(OBJEXT): $(top_srcdir)/internal/rational.h
+parse.$(OBJEXT): $(top_srcdir)/internal/re.h
+parse.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+parse.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+parse.$(OBJEXT): $(top_srcdir)/internal/serial.h
+parse.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+parse.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+parse.$(OBJEXT): $(top_srcdir)/internal/string.h
+parse.$(OBJEXT): $(top_srcdir)/internal/struct.h
+parse.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+parse.$(OBJEXT): $(top_srcdir)/internal/thread.h
+parse.$(OBJEXT): $(top_srcdir)/internal/variable.h
+parse.$(OBJEXT): $(top_srcdir)/internal/vm.h
+parse.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+parse.$(OBJEXT): {$(VPATH)}assert.h
+parse.$(OBJEXT): {$(VPATH)}atomic.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+parse.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+parse.$(OBJEXT): {$(VPATH)}config.h
+parse.$(OBJEXT): {$(VPATH)}constant.h
+parse.$(OBJEXT): {$(VPATH)}defines.h
+parse.$(OBJEXT): {$(VPATH)}defs/keywords
+parse.$(OBJEXT): {$(VPATH)}encindex.h
+parse.$(OBJEXT): {$(VPATH)}encoding.h
+parse.$(OBJEXT): {$(VPATH)}id.h
+parse.$(OBJEXT): {$(VPATH)}id_table.h
+parse.$(OBJEXT): {$(VPATH)}intern.h
+parse.$(OBJEXT): {$(VPATH)}internal.h
+parse.$(OBJEXT): {$(VPATH)}internal/abi.h
+parse.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+parse.$(OBJEXT): {$(VPATH)}internal/assume.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+parse.$(OBJEXT): {$(VPATH)}internal/cast.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+parse.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+parse.$(OBJEXT): {$(VPATH)}internal/config.h
+parse.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+parse.$(OBJEXT): {$(VPATH)}internal/core.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+parse.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+parse.$(OBJEXT): {$(VPATH)}internal/ctype.h
+parse.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+parse.$(OBJEXT): {$(VPATH)}internal/dosish.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+parse.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+parse.$(OBJEXT): {$(VPATH)}internal/error.h
+parse.$(OBJEXT): {$(VPATH)}internal/eval.h
+parse.$(OBJEXT): {$(VPATH)}internal/event.h
+parse.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+parse.$(OBJEXT): {$(VPATH)}internal/gc.h
+parse.$(OBJEXT): {$(VPATH)}internal/glob.h
+parse.$(OBJEXT): {$(VPATH)}internal/globals.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+parse.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+parse.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+parse.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+parse.$(OBJEXT): {$(VPATH)}internal/iterator.h
+parse.$(OBJEXT): {$(VPATH)}internal/memory.h
+parse.$(OBJEXT): {$(VPATH)}internal/method.h
+parse.$(OBJEXT): {$(VPATH)}internal/module.h
+parse.$(OBJEXT): {$(VPATH)}internal/newobj.h
+parse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+parse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+parse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+parse.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+parse.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+parse.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+parse.$(OBJEXT): {$(VPATH)}internal/symbol.h
+parse.$(OBJEXT): {$(VPATH)}internal/value.h
+parse.$(OBJEXT): {$(VPATH)}internal/value_type.h
+parse.$(OBJEXT): {$(VPATH)}internal/variable.h
+parse.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+parse.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+parse.$(OBJEXT): {$(VPATH)}io.h
+parse.$(OBJEXT): {$(VPATH)}lex.c
+parse.$(OBJEXT): {$(VPATH)}method.h
+parse.$(OBJEXT): {$(VPATH)}missing.h
+parse.$(OBJEXT): {$(VPATH)}node.h
+parse.$(OBJEXT): {$(VPATH)}onigmo.h
+parse.$(OBJEXT): {$(VPATH)}oniguruma.h
+parse.$(OBJEXT): {$(VPATH)}parse.c
+parse.$(OBJEXT): {$(VPATH)}parse.h
+parse.$(OBJEXT): {$(VPATH)}parse.y
+parse.$(OBJEXT): {$(VPATH)}parser_node.h
+parse.$(OBJEXT): {$(VPATH)}parser_st.h
+parse.$(OBJEXT): {$(VPATH)}probes.dmyh
+parse.$(OBJEXT): {$(VPATH)}probes.h
+parse.$(OBJEXT): {$(VPATH)}ractor.h
+parse.$(OBJEXT): {$(VPATH)}re.h
+parse.$(OBJEXT): {$(VPATH)}regenc.h
+parse.$(OBJEXT): {$(VPATH)}regex.h
+parse.$(OBJEXT): {$(VPATH)}ruby_assert.h
+parse.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+parse.$(OBJEXT): {$(VPATH)}rubyparser.h
+parse.$(OBJEXT): {$(VPATH)}shape.h
+parse.$(OBJEXT): {$(VPATH)}st.h
+parse.$(OBJEXT): {$(VPATH)}subst.h
+parse.$(OBJEXT): {$(VPATH)}symbol.h
+parse.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+parse.$(OBJEXT): {$(VPATH)}thread_native.h
+parse.$(OBJEXT): {$(VPATH)}util.h
+parse.$(OBJEXT): {$(VPATH)}vm_core.h
+parse.$(OBJEXT): {$(VPATH)}vm_opts.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+parser_st.$(OBJEXT): {$(VPATH)}assert.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+parser_st.$(OBJEXT): {$(VPATH)}config.h
+parser_st.$(OBJEXT): {$(VPATH)}defines.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/assume.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/cast.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/config.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/dosish.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+parser_st.$(OBJEXT): {$(VPATH)}missing.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_bits.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_st.c
+parser_st.$(OBJEXT): {$(VPATH)}parser_st.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_value.h
+parser_st.$(OBJEXT): {$(VPATH)}st.c
+pathname.$(OBJEXT): $(hdrdir)/ruby.h
+pathname.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/file.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/serial.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/string.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/vm.h
+pathname.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+pathname.$(OBJEXT): {$(VPATH)}assert.h
+pathname.$(OBJEXT): {$(VPATH)}backward.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+pathname.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+pathname.$(OBJEXT): {$(VPATH)}builtin.h
+pathname.$(OBJEXT): {$(VPATH)}config.h
+pathname.$(OBJEXT): {$(VPATH)}defines.h
+pathname.$(OBJEXT): {$(VPATH)}encindex.h
+pathname.$(OBJEXT): {$(VPATH)}encoding.h
+pathname.$(OBJEXT): {$(VPATH)}intern.h
+pathname.$(OBJEXT): {$(VPATH)}internal.h
+pathname.$(OBJEXT): {$(VPATH)}internal/abi.h
+pathname.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+pathname.$(OBJEXT): {$(VPATH)}internal/assume.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+pathname.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+pathname.$(OBJEXT): {$(VPATH)}internal/cast.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+pathname.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+pathname.$(OBJEXT): {$(VPATH)}internal/config.h
+pathname.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+pathname.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+pathname.$(OBJEXT): {$(VPATH)}internal/ctype.h
+pathname.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+pathname.$(OBJEXT): {$(VPATH)}internal/dosish.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+pathname.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+pathname.$(OBJEXT): {$(VPATH)}internal/error.h
+pathname.$(OBJEXT): {$(VPATH)}internal/eval.h
+pathname.$(OBJEXT): {$(VPATH)}internal/event.h
+pathname.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+pathname.$(OBJEXT): {$(VPATH)}internal/gc.h
+pathname.$(OBJEXT): {$(VPATH)}internal/glob.h
+pathname.$(OBJEXT): {$(VPATH)}internal/globals.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+pathname.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+pathname.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+pathname.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+pathname.$(OBJEXT): {$(VPATH)}internal/iterator.h
+pathname.$(OBJEXT): {$(VPATH)}internal/memory.h
+pathname.$(OBJEXT): {$(VPATH)}internal/method.h
+pathname.$(OBJEXT): {$(VPATH)}internal/module.h
+pathname.$(OBJEXT): {$(VPATH)}internal/newobj.h
+pathname.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+pathname.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+pathname.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+pathname.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+pathname.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+pathname.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+pathname.$(OBJEXT): {$(VPATH)}internal/symbol.h
+pathname.$(OBJEXT): {$(VPATH)}internal/value.h
+pathname.$(OBJEXT): {$(VPATH)}internal/value_type.h
+pathname.$(OBJEXT): {$(VPATH)}internal/variable.h
+pathname.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+pathname.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+pathname.$(OBJEXT): {$(VPATH)}missing.h
+pathname.$(OBJEXT): {$(VPATH)}onigmo.h
+pathname.$(OBJEXT): {$(VPATH)}oniguruma.h
+pathname.$(OBJEXT): {$(VPATH)}pathname.c
+pathname.$(OBJEXT): {$(VPATH)}pathname_builtin.rbinc
+pathname.$(OBJEXT): {$(VPATH)}ruby.h
+pathname.$(OBJEXT): {$(VPATH)}st.h
+pathname.$(OBJEXT): {$(VPATH)}subst.h
+prism/api_node.$(OBJEXT): $(hdrdir)/ruby.h
+prism/api_node.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism/api_node.$(OBJEXT): $(hdrdir)/ruby/version.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/api_node.c
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/json.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/stream.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism/api_node.$(OBJEXT): {$(VPATH)}assert.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism/api_node.$(OBJEXT): {$(VPATH)}config.h
+prism/api_node.$(OBJEXT): {$(VPATH)}defines.h
+prism/api_node.$(OBJEXT): {$(VPATH)}encoding.h
+prism/api_node.$(OBJEXT): {$(VPATH)}intern.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/event.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/method.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/module.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/value.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}missing.h
+prism/api_node.$(OBJEXT): {$(VPATH)}onigmo.h
+prism/api_node.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism/api_node.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/api_node.$(OBJEXT): {$(VPATH)}st.h
+prism/api_node.$(OBJEXT): {$(VPATH)}subst.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/arena.c
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/arena.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/arena.$(OBJEXT): {$(VPATH)}config.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/arena.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/arena.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/buffer.c
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/buffer.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/buffer.$(OBJEXT): {$(VPATH)}config.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/buffer.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/buffer.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/char.c
+prism/char.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/internal/line_offset_list.h
+prism/char.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/char.$(OBJEXT): {$(VPATH)}config.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/char.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/char.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/constant_pool.c
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/constant_pool.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}config.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/constant_pool.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/diagnostic.c
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}config.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/compiler/unused.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/encoding.c
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/encoding.$(OBJEXT): {$(VPATH)}config.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/encoding.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/encoding.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/extension.$(OBJEXT): $(hdrdir)/ruby.h
+prism/extension.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism/extension.$(OBJEXT): $(hdrdir)/ruby/version.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/extension.c
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/json.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/stream.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism/extension.$(OBJEXT): {$(VPATH)}assert.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism/extension.$(OBJEXT): {$(VPATH)}config.h
+prism/extension.$(OBJEXT): {$(VPATH)}defines.h
+prism/extension.$(OBJEXT): {$(VPATH)}encoding.h
+prism/extension.$(OBJEXT): {$(VPATH)}intern.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/event.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/method.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/module.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/value.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/extension.$(OBJEXT): {$(VPATH)}missing.h
+prism/extension.$(OBJEXT): {$(VPATH)}onigmo.h
+prism/extension.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism/extension.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/extension.$(OBJEXT): {$(VPATH)}st.h
+prism/extension.$(OBJEXT): {$(VPATH)}subst.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/integer.c
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/internal/integer.h
+prism/integer.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/integer.$(OBJEXT): {$(VPATH)}config.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/integer.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/integer.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/integer.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/json.c
+prism/json.$(OBJEXT): $(top_srcdir)/prism/json.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/json.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/internal/line_offset_list.h
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.c
+prism/line_offset_list.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}config.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/line_offset_list.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/list.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/list.$(OBJEXT): $(top_srcdir)/prism/list.c
+prism/list.$(OBJEXT): {$(VPATH)}config.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/list.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/list.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/memchr.c
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/memchr.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/memchr.$(OBJEXT): {$(VPATH)}config.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/memchr.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/memchr.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/node.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/node.c
+prism/node.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/node.$(OBJEXT): {$(VPATH)}config.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/node.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/node.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/internal/stringy.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/options.c
+prism/options.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/options.$(OBJEXT): {$(VPATH)}config.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/options.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/options.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/comments.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/magic_comments.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/parser.c
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/parser.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/parser.$(OBJEXT): {$(VPATH)}config.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/parser.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/parser.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/integer.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/prettyprint.c
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}config.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/fallthrough.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/compiler/unused.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/bit.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/comments.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/integer.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/isinf.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/line_offset_list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/magic_comments.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/node.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/serialize.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/source.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/stringy.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/internal/tokens.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prism.c
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/stream.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism/prism.$(OBJEXT): {$(VPATH)}config.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/prism.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/prism.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/fallthrough.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/stringy.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/regexp.c
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/regexp.$(OBJEXT): {$(VPATH)}config.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/regexp.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/regexp.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/comments.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/magic_comments.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/json.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/serialize.c
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/stream.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism/serialize.$(OBJEXT): {$(VPATH)}config.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/serialize.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/serialize.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/internal/source.h
+prism/source.$(OBJEXT): $(top_srcdir)/prism/source.c
+prism/source.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism/source.$(OBJEXT): {$(VPATH)}config.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/source.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/source.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/format.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/compiler/unused.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/buffer.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/integer.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/isinf.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/stringy.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/static_literals.c
+prism/static_literals.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}config.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/static_literals.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/string_query.c
+prism/string_query.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/internal/allocator.h
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/internal/stringy.h
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/stringy.c
+prism/stringy.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/stringy.$(OBJEXT): {$(VPATH)}config.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/stringy.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/stringy.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/strncasecmp.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/strncasecmp.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/strncasecmp.$(OBJEXT): $(top_srcdir)/prism/strncasecmp.c
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}config.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/strncasecmp.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/accel.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/flex_array.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/force_inline.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/inline.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/compiler/unused.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/arena.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/bit.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/constant_pool.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/diagnostic.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/options.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/parser.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/strpbrk.$(OBJEXT): $(top_srcdir)/prism/strpbrk.c
+prism/strpbrk.$(OBJEXT): {$(VPATH)}config.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/strpbrk.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism/tokens.$(OBJEXT): $(top_srcdir)/prism/tokens.c
+prism/tokens.$(OBJEXT): {$(VPATH)}config.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/tokens.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/tokens.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism_init.$(OBJEXT): $(hdrdir)/ruby.h
+prism_init.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism_init.$(OBJEXT): $(hdrdir)/ruby/version.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/arena.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/ast.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/comments.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/integer.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/json.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/source.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/stream.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism_init.c
+prism_init.$(OBJEXT): {$(VPATH)}assert.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism_init.$(OBJEXT): {$(VPATH)}config.h
+prism_init.$(OBJEXT): {$(VPATH)}defines.h
+prism_init.$(OBJEXT): {$(VPATH)}encoding.h
+prism_init.$(OBJEXT): {$(VPATH)}intern.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/config.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/event.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/method.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/module.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/value.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism_init.$(OBJEXT): {$(VPATH)}missing.h
+prism_init.$(OBJEXT): {$(VPATH)}onigmo.h
+prism_init.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism_init.$(OBJEXT): {$(VPATH)}prism_init.c
+prism_init.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+prism_init.$(OBJEXT): {$(VPATH)}st.h
+prism_init.$(OBJEXT): {$(VPATH)}subst.h
+proc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+proc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+proc.$(OBJEXT): $(CCAN_DIR)/list/list.h
+proc.$(OBJEXT): $(CCAN_DIR)/str/str.h
+proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+proc.$(OBJEXT): $(hdrdir)/ruby/version.h
+proc.$(OBJEXT): $(top_srcdir)/internal/array.h
+proc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+proc.$(OBJEXT): $(top_srcdir)/internal/box.h
+proc.$(OBJEXT): $(top_srcdir)/internal/class.h
+proc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+proc.$(OBJEXT): $(top_srcdir)/internal/error.h
+proc.$(OBJEXT): $(top_srcdir)/internal/eval.h
+proc.$(OBJEXT): $(top_srcdir)/internal/gc.h
+proc.$(OBJEXT): $(top_srcdir)/internal/hash.h
+proc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+proc.$(OBJEXT): $(top_srcdir)/internal/object.h
+proc.$(OBJEXT): $(top_srcdir)/internal/proc.h
+proc.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+proc.$(OBJEXT): $(top_srcdir)/internal/serial.h
+proc.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+proc.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+proc.$(OBJEXT): $(top_srcdir)/internal/string.h
+proc.$(OBJEXT): $(top_srcdir)/internal/struct.h
+proc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+proc.$(OBJEXT): $(top_srcdir)/internal/variable.h
+proc.$(OBJEXT): $(top_srcdir)/internal/vm.h
+proc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+proc.$(OBJEXT): $(top_srcdir)/prism/arena.h
+proc.$(OBJEXT): $(top_srcdir)/prism/ast.h
+proc.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+proc.$(OBJEXT): $(top_srcdir)/prism/comments.h
+proc.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+proc.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+proc.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+proc.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+proc.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+proc.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+proc.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+proc.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+proc.$(OBJEXT): $(top_srcdir)/prism/integer.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+proc.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+proc.$(OBJEXT): $(top_srcdir)/prism/json.h
+proc.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+proc.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+proc.$(OBJEXT): $(top_srcdir)/prism/node.h
+proc.$(OBJEXT): $(top_srcdir)/prism/options.h
+proc.$(OBJEXT): $(top_srcdir)/prism/parser.h
+proc.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+proc.$(OBJEXT): $(top_srcdir)/prism/prism.h
+proc.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+proc.$(OBJEXT): $(top_srcdir)/prism/source.h
+proc.$(OBJEXT): $(top_srcdir)/prism/stream.h
+proc.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+proc.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+proc.$(OBJEXT): $(top_srcdir)/prism/version.h
+proc.$(OBJEXT): {$(VPATH)}assert.h
+proc.$(OBJEXT): {$(VPATH)}atomic.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+proc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+proc.$(OBJEXT): {$(VPATH)}config.h
+proc.$(OBJEXT): {$(VPATH)}constant.h
+proc.$(OBJEXT): {$(VPATH)}debug_counter.h
+proc.$(OBJEXT): {$(VPATH)}defines.h
+proc.$(OBJEXT): {$(VPATH)}encindex.h
+proc.$(OBJEXT): {$(VPATH)}encoding.h
+proc.$(OBJEXT): {$(VPATH)}eval_intern.h
+proc.$(OBJEXT): {$(VPATH)}id.h
+proc.$(OBJEXT): {$(VPATH)}id_table.h
+proc.$(OBJEXT): {$(VPATH)}intern.h
+proc.$(OBJEXT): {$(VPATH)}internal.h
+proc.$(OBJEXT): {$(VPATH)}internal/abi.h
+proc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+proc.$(OBJEXT): {$(VPATH)}internal/assume.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+proc.$(OBJEXT): {$(VPATH)}internal/cast.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+proc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+proc.$(OBJEXT): {$(VPATH)}internal/config.h
+proc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+proc.$(OBJEXT): {$(VPATH)}internal/core.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+proc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+proc.$(OBJEXT): {$(VPATH)}internal/ctype.h
+proc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+proc.$(OBJEXT): {$(VPATH)}internal/dosish.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+proc.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+proc.$(OBJEXT): {$(VPATH)}internal/error.h
+proc.$(OBJEXT): {$(VPATH)}internal/eval.h
+proc.$(OBJEXT): {$(VPATH)}internal/event.h
+proc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+proc.$(OBJEXT): {$(VPATH)}internal/gc.h
+proc.$(OBJEXT): {$(VPATH)}internal/glob.h
+proc.$(OBJEXT): {$(VPATH)}internal/globals.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+proc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+proc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+proc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+proc.$(OBJEXT): {$(VPATH)}internal/iterator.h
+proc.$(OBJEXT): {$(VPATH)}internal/memory.h
+proc.$(OBJEXT): {$(VPATH)}internal/method.h
+proc.$(OBJEXT): {$(VPATH)}internal/module.h
+proc.$(OBJEXT): {$(VPATH)}internal/newobj.h
+proc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+proc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+proc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+proc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+proc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+proc.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+proc.$(OBJEXT): {$(VPATH)}internal/symbol.h
+proc.$(OBJEXT): {$(VPATH)}internal/value.h
+proc.$(OBJEXT): {$(VPATH)}internal/value_type.h
+proc.$(OBJEXT): {$(VPATH)}internal/variable.h
+proc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+proc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+proc.$(OBJEXT): {$(VPATH)}iseq.h
+proc.$(OBJEXT): {$(VPATH)}method.h
+proc.$(OBJEXT): {$(VPATH)}missing.h
+proc.$(OBJEXT): {$(VPATH)}node.h
+proc.$(OBJEXT): {$(VPATH)}onigmo.h
+proc.$(OBJEXT): {$(VPATH)}oniguruma.h
+proc.$(OBJEXT): {$(VPATH)}prism_compile.h
+proc.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+proc.$(OBJEXT): {$(VPATH)}proc.c
+proc.$(OBJEXT): {$(VPATH)}ractor.h
+proc.$(OBJEXT): {$(VPATH)}ractor_core.h
+proc.$(OBJEXT): {$(VPATH)}ruby_assert.h
+proc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+proc.$(OBJEXT): {$(VPATH)}rubyparser.h
+proc.$(OBJEXT): {$(VPATH)}shape.h
+proc.$(OBJEXT): {$(VPATH)}st.h
+proc.$(OBJEXT): {$(VPATH)}subst.h
+proc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+proc.$(OBJEXT): {$(VPATH)}thread_native.h
+proc.$(OBJEXT): {$(VPATH)}vm_core.h
+proc.$(OBJEXT): {$(VPATH)}vm_debug.h
+proc.$(OBJEXT): {$(VPATH)}vm_opts.h
+proc.$(OBJEXT): {$(VPATH)}vm_sync.h
+proc.$(OBJEXT): {$(VPATH)}yjit.h
+proc.$(OBJEXT): {$(VPATH)}zjit.h
+process.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+process.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+process.$(OBJEXT): $(CCAN_DIR)/list/list.h
+process.$(OBJEXT): $(CCAN_DIR)/str/str.h
+process.$(OBJEXT): $(hdrdir)/ruby.h
+process.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+process.$(OBJEXT): $(hdrdir)/ruby/version.h
+process.$(OBJEXT): $(top_srcdir)/internal/array.h
+process.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+process.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+process.$(OBJEXT): $(top_srcdir)/internal/bits.h
+process.$(OBJEXT): $(top_srcdir)/internal/box.h
+process.$(OBJEXT): $(top_srcdir)/internal/class.h
+process.$(OBJEXT): $(top_srcdir)/internal/compar.h
+process.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+process.$(OBJEXT): $(top_srcdir)/internal/dir.h
+process.$(OBJEXT): $(top_srcdir)/internal/error.h
+process.$(OBJEXT): $(top_srcdir)/internal/eval.h
+process.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+process.$(OBJEXT): $(top_srcdir)/internal/gc.h
+process.$(OBJEXT): $(top_srcdir)/internal/hash.h
+process.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+process.$(OBJEXT): $(top_srcdir)/internal/io.h
+process.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+process.$(OBJEXT): $(top_srcdir)/internal/object.h
+process.$(OBJEXT): $(top_srcdir)/internal/process.h
+process.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+process.$(OBJEXT): $(top_srcdir)/internal/serial.h
+process.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+process.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+process.$(OBJEXT): $(top_srcdir)/internal/string.h
+process.$(OBJEXT): $(top_srcdir)/internal/struct.h
+process.$(OBJEXT): $(top_srcdir)/internal/thread.h
+process.$(OBJEXT): $(top_srcdir)/internal/time.h
+process.$(OBJEXT): $(top_srcdir)/internal/variable.h
+process.$(OBJEXT): $(top_srcdir)/internal/vm.h
+process.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+process.$(OBJEXT): {$(VPATH)}assert.h
+process.$(OBJEXT): {$(VPATH)}atomic.h
+process.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+process.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+process.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+process.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+process.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+process.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+process.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+process.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+process.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+process.$(OBJEXT): {$(VPATH)}config.h
+process.$(OBJEXT): {$(VPATH)}constant.h
+process.$(OBJEXT): {$(VPATH)}debug_counter.h
+process.$(OBJEXT): {$(VPATH)}defines.h
+process.$(OBJEXT): {$(VPATH)}dln.h
+process.$(OBJEXT): {$(VPATH)}encindex.h
+process.$(OBJEXT): {$(VPATH)}encoding.h
+process.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+process.$(OBJEXT): {$(VPATH)}hrtime.h
+process.$(OBJEXT): {$(VPATH)}id.h
+process.$(OBJEXT): {$(VPATH)}id_table.h
+process.$(OBJEXT): {$(VPATH)}intern.h
+process.$(OBJEXT): {$(VPATH)}internal.h
+process.$(OBJEXT): {$(VPATH)}internal/abi.h
+process.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+process.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+process.$(OBJEXT): {$(VPATH)}internal/assume.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+process.$(OBJEXT): {$(VPATH)}internal/cast.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+process.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+process.$(OBJEXT): {$(VPATH)}internal/config.h
+process.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+process.$(OBJEXT): {$(VPATH)}internal/core.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+process.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+process.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+process.$(OBJEXT): {$(VPATH)}internal/ctype.h
+process.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+process.$(OBJEXT): {$(VPATH)}internal/dosish.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+process.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+process.$(OBJEXT): {$(VPATH)}internal/error.h
+process.$(OBJEXT): {$(VPATH)}internal/eval.h
+process.$(OBJEXT): {$(VPATH)}internal/event.h
+process.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+process.$(OBJEXT): {$(VPATH)}internal/gc.h
+process.$(OBJEXT): {$(VPATH)}internal/glob.h
+process.$(OBJEXT): {$(VPATH)}internal/globals.h
+process.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+process.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+process.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+process.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+process.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+process.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+process.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+process.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+process.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+process.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+process.$(OBJEXT): {$(VPATH)}internal/iterator.h
+process.$(OBJEXT): {$(VPATH)}internal/memory.h
+process.$(OBJEXT): {$(VPATH)}internal/method.h
+process.$(OBJEXT): {$(VPATH)}internal/module.h
+process.$(OBJEXT): {$(VPATH)}internal/newobj.h
+process.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+process.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+process.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+process.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+process.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+process.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+process.$(OBJEXT): {$(VPATH)}internal/symbol.h
+process.$(OBJEXT): {$(VPATH)}internal/value.h
+process.$(OBJEXT): {$(VPATH)}internal/value_type.h
+process.$(OBJEXT): {$(VPATH)}internal/variable.h
+process.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+process.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+process.$(OBJEXT): {$(VPATH)}io.h
+process.$(OBJEXT): {$(VPATH)}method.h
+process.$(OBJEXT): {$(VPATH)}missing.h
+process.$(OBJEXT): {$(VPATH)}node.h
+process.$(OBJEXT): {$(VPATH)}onigmo.h
+process.$(OBJEXT): {$(VPATH)}oniguruma.h
+process.$(OBJEXT): {$(VPATH)}process.c
+process.$(OBJEXT): {$(VPATH)}ractor.h
+process.$(OBJEXT): {$(VPATH)}ractor_core.h
+process.$(OBJEXT): {$(VPATH)}ruby_assert.h
+process.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+process.$(OBJEXT): {$(VPATH)}rubyparser.h
+process.$(OBJEXT): {$(VPATH)}shape.h
+process.$(OBJEXT): {$(VPATH)}st.h
+process.$(OBJEXT): {$(VPATH)}subst.h
+process.$(OBJEXT): {$(VPATH)}thread.h
+process.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+process.$(OBJEXT): {$(VPATH)}thread_native.h
+process.$(OBJEXT): {$(VPATH)}util.h
+process.$(OBJEXT): {$(VPATH)}vm_core.h
+process.$(OBJEXT): {$(VPATH)}vm_debug.h
+process.$(OBJEXT): {$(VPATH)}vm_opts.h
+process.$(OBJEXT): {$(VPATH)}vm_sync.h
+ractor.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+ractor.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+ractor.$(OBJEXT): $(CCAN_DIR)/list/list.h
+ractor.$(OBJEXT): $(CCAN_DIR)/str/str.h
+ractor.$(OBJEXT): $(hdrdir)/ruby.h
+ractor.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+ractor.$(OBJEXT): $(hdrdir)/ruby/version.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/array.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/bits.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/box.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/compar.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/complex.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/error.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/gc.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/hash.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/object.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/ractor.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/rational.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/serial.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/st.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/string.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/struct.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/thread.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/variable.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/vm.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+ractor.$(OBJEXT): {$(VPATH)}assert.h
+ractor.$(OBJEXT): {$(VPATH)}atomic.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+ractor.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+ractor.$(OBJEXT): {$(VPATH)}builtin.h
+ractor.$(OBJEXT): {$(VPATH)}config.h
+ractor.$(OBJEXT): {$(VPATH)}constant.h
+ractor.$(OBJEXT): {$(VPATH)}debug_counter.h
+ractor.$(OBJEXT): {$(VPATH)}defines.h
+ractor.$(OBJEXT): {$(VPATH)}encindex.h
+ractor.$(OBJEXT): {$(VPATH)}encoding.h
+ractor.$(OBJEXT): {$(VPATH)}eval_intern.h
+ractor.$(OBJEXT): {$(VPATH)}id.h
+ractor.$(OBJEXT): {$(VPATH)}id_table.h
+ractor.$(OBJEXT): {$(VPATH)}intern.h
+ractor.$(OBJEXT): {$(VPATH)}internal.h
+ractor.$(OBJEXT): {$(VPATH)}internal/abi.h
+ractor.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+ractor.$(OBJEXT): {$(VPATH)}internal/assume.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+ractor.$(OBJEXT): {$(VPATH)}internal/cast.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+ractor.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+ractor.$(OBJEXT): {$(VPATH)}internal/config.h
+ractor.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+ractor.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+ractor.$(OBJEXT): {$(VPATH)}internal/ctype.h
+ractor.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+ractor.$(OBJEXT): {$(VPATH)}internal/dosish.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+ractor.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+ractor.$(OBJEXT): {$(VPATH)}internal/error.h
+ractor.$(OBJEXT): {$(VPATH)}internal/eval.h
+ractor.$(OBJEXT): {$(VPATH)}internal/event.h
+ractor.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+ractor.$(OBJEXT): {$(VPATH)}internal/gc.h
+ractor.$(OBJEXT): {$(VPATH)}internal/glob.h
+ractor.$(OBJEXT): {$(VPATH)}internal/globals.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+ractor.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+ractor.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+ractor.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+ractor.$(OBJEXT): {$(VPATH)}internal/iterator.h
+ractor.$(OBJEXT): {$(VPATH)}internal/memory.h
+ractor.$(OBJEXT): {$(VPATH)}internal/method.h
+ractor.$(OBJEXT): {$(VPATH)}internal/module.h
+ractor.$(OBJEXT): {$(VPATH)}internal/newobj.h
+ractor.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+ractor.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+ractor.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+ractor.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+ractor.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+ractor.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+ractor.$(OBJEXT): {$(VPATH)}internal/symbol.h
+ractor.$(OBJEXT): {$(VPATH)}internal/value.h
+ractor.$(OBJEXT): {$(VPATH)}internal/value_type.h
+ractor.$(OBJEXT): {$(VPATH)}internal/variable.h
+ractor.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+ractor.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+ractor.$(OBJEXT): {$(VPATH)}method.h
+ractor.$(OBJEXT): {$(VPATH)}missing.h
+ractor.$(OBJEXT): {$(VPATH)}node.h
+ractor.$(OBJEXT): {$(VPATH)}onigmo.h
+ractor.$(OBJEXT): {$(VPATH)}oniguruma.h
+ractor.$(OBJEXT): {$(VPATH)}ractor.c
+ractor.$(OBJEXT): {$(VPATH)}ractor.h
+ractor.$(OBJEXT): {$(VPATH)}ractor.rbinc
+ractor.$(OBJEXT): {$(VPATH)}ractor_core.h
+ractor.$(OBJEXT): {$(VPATH)}ractor_sync.c
+ractor.$(OBJEXT): {$(VPATH)}re.h
+ractor.$(OBJEXT): {$(VPATH)}regex.h
+ractor.$(OBJEXT): {$(VPATH)}ruby_assert.h
+ractor.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ractor.$(OBJEXT): {$(VPATH)}rubyparser.h
+ractor.$(OBJEXT): {$(VPATH)}shape.h
+ractor.$(OBJEXT): {$(VPATH)}st.h
+ractor.$(OBJEXT): {$(VPATH)}subst.h
+ractor.$(OBJEXT): {$(VPATH)}thread.h
+ractor.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+ractor.$(OBJEXT): {$(VPATH)}thread_native.h
+ractor.$(OBJEXT): {$(VPATH)}variable.h
+ractor.$(OBJEXT): {$(VPATH)}vm_core.h
+ractor.$(OBJEXT): {$(VPATH)}vm_debug.h
+ractor.$(OBJEXT): {$(VPATH)}vm_opts.h
+ractor.$(OBJEXT): {$(VPATH)}vm_sync.h
+ractor.$(OBJEXT): {$(VPATH)}yjit.h
+ractor.$(OBJEXT): {$(VPATH)}zjit.h
+random.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+random.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+random.$(OBJEXT): $(CCAN_DIR)/list/list.h
+random.$(OBJEXT): $(CCAN_DIR)/str/str.h
+random.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+random.$(OBJEXT): $(top_srcdir)/internal/array.h
+random.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+random.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+random.$(OBJEXT): $(top_srcdir)/internal/bits.h
+random.$(OBJEXT): $(top_srcdir)/internal/box.h
+random.$(OBJEXT): $(top_srcdir)/internal/compar.h
+random.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+random.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+random.$(OBJEXT): $(top_srcdir)/internal/gc.h
+random.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+random.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+random.$(OBJEXT): $(top_srcdir)/internal/random.h
+random.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+random.$(OBJEXT): $(top_srcdir)/internal/serial.h
+random.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+random.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+random.$(OBJEXT): $(top_srcdir)/internal/struct.h
+random.$(OBJEXT): $(top_srcdir)/internal/variable.h
+random.$(OBJEXT): $(top_srcdir)/internal/vm.h
+random.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+random.$(OBJEXT): {$(VPATH)}assert.h
+random.$(OBJEXT): {$(VPATH)}atomic.h
+random.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+random.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+random.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+random.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+random.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+random.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+random.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+random.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+random.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+random.$(OBJEXT): {$(VPATH)}config.h
+random.$(OBJEXT): {$(VPATH)}constant.h
+random.$(OBJEXT): {$(VPATH)}defines.h
+random.$(OBJEXT): {$(VPATH)}encoding.h
+random.$(OBJEXT): {$(VPATH)}id.h
+random.$(OBJEXT): {$(VPATH)}id_table.h
+random.$(OBJEXT): {$(VPATH)}intern.h
+random.$(OBJEXT): {$(VPATH)}internal.h
+random.$(OBJEXT): {$(VPATH)}internal/abi.h
+random.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+random.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+random.$(OBJEXT): {$(VPATH)}internal/assume.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+random.$(OBJEXT): {$(VPATH)}internal/cast.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+random.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+random.$(OBJEXT): {$(VPATH)}internal/config.h
+random.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+random.$(OBJEXT): {$(VPATH)}internal/core.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+random.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+random.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+random.$(OBJEXT): {$(VPATH)}internal/ctype.h
+random.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+random.$(OBJEXT): {$(VPATH)}internal/dosish.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+random.$(OBJEXT): {$(VPATH)}internal/error.h
+random.$(OBJEXT): {$(VPATH)}internal/eval.h
+random.$(OBJEXT): {$(VPATH)}internal/event.h
+random.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+random.$(OBJEXT): {$(VPATH)}internal/gc.h
+random.$(OBJEXT): {$(VPATH)}internal/glob.h
+random.$(OBJEXT): {$(VPATH)}internal/globals.h
+random.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+random.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+random.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+random.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+random.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+random.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+random.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+random.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+random.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+random.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+random.$(OBJEXT): {$(VPATH)}internal/iterator.h
+random.$(OBJEXT): {$(VPATH)}internal/memory.h
+random.$(OBJEXT): {$(VPATH)}internal/method.h
+random.$(OBJEXT): {$(VPATH)}internal/module.h
+random.$(OBJEXT): {$(VPATH)}internal/newobj.h
+random.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+random.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+random.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+random.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+random.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+random.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+random.$(OBJEXT): {$(VPATH)}internal/symbol.h
+random.$(OBJEXT): {$(VPATH)}internal/value.h
+random.$(OBJEXT): {$(VPATH)}internal/value_type.h
+random.$(OBJEXT): {$(VPATH)}internal/variable.h
+random.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+random.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+random.$(OBJEXT): {$(VPATH)}method.h
+random.$(OBJEXT): {$(VPATH)}missing.h
+random.$(OBJEXT): {$(VPATH)}mt19937.c
+random.$(OBJEXT): {$(VPATH)}node.h
+random.$(OBJEXT): {$(VPATH)}onigmo.h
+random.$(OBJEXT): {$(VPATH)}oniguruma.h
+random.$(OBJEXT): {$(VPATH)}ractor.h
+random.$(OBJEXT): {$(VPATH)}random.c
+random.$(OBJEXT): {$(VPATH)}random.h
+random.$(OBJEXT): {$(VPATH)}ruby_assert.h
+random.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+random.$(OBJEXT): {$(VPATH)}rubyparser.h
+random.$(OBJEXT): {$(VPATH)}shape.h
+random.$(OBJEXT): {$(VPATH)}siphash.c
+random.$(OBJEXT): {$(VPATH)}siphash.h
+random.$(OBJEXT): {$(VPATH)}st.h
+random.$(OBJEXT): {$(VPATH)}subst.h
+random.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+random.$(OBJEXT): {$(VPATH)}thread_native.h
+random.$(OBJEXT): {$(VPATH)}vm_core.h
+random.$(OBJEXT): {$(VPATH)}vm_opts.h
+range.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+range.$(OBJEXT): $(hdrdir)/ruby/version.h
+range.$(OBJEXT): $(top_srcdir)/internal/array.h
+range.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+range.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+range.$(OBJEXT): $(top_srcdir)/internal/bits.h
+range.$(OBJEXT): $(top_srcdir)/internal/compar.h
+range.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+range.$(OBJEXT): $(top_srcdir)/internal/enum.h
+range.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
+range.$(OBJEXT): $(top_srcdir)/internal/error.h
+range.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+range.$(OBJEXT): $(top_srcdir)/internal/gc.h
+range.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+range.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+range.$(OBJEXT): $(top_srcdir)/internal/range.h
+range.$(OBJEXT): $(top_srcdir)/internal/serial.h
+range.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+range.$(OBJEXT): $(top_srcdir)/internal/string.h
+range.$(OBJEXT): $(top_srcdir)/internal/struct.h
+range.$(OBJEXT): $(top_srcdir)/internal/vm.h
+range.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+range.$(OBJEXT): {$(VPATH)}assert.h
+range.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+range.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+range.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+range.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+range.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+range.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+range.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+range.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+range.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+range.$(OBJEXT): {$(VPATH)}config.h
+range.$(OBJEXT): {$(VPATH)}defines.h
+range.$(OBJEXT): {$(VPATH)}encindex.h
+range.$(OBJEXT): {$(VPATH)}encoding.h
+range.$(OBJEXT): {$(VPATH)}id.h
+range.$(OBJEXT): {$(VPATH)}id_table.h
+range.$(OBJEXT): {$(VPATH)}intern.h
+range.$(OBJEXT): {$(VPATH)}internal.h
+range.$(OBJEXT): {$(VPATH)}internal/abi.h
+range.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+range.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+range.$(OBJEXT): {$(VPATH)}internal/assume.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+range.$(OBJEXT): {$(VPATH)}internal/cast.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+range.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+range.$(OBJEXT): {$(VPATH)}internal/config.h
+range.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+range.$(OBJEXT): {$(VPATH)}internal/core.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+range.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+range.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+range.$(OBJEXT): {$(VPATH)}internal/ctype.h
+range.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+range.$(OBJEXT): {$(VPATH)}internal/dosish.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+range.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+range.$(OBJEXT): {$(VPATH)}internal/error.h
+range.$(OBJEXT): {$(VPATH)}internal/eval.h
+range.$(OBJEXT): {$(VPATH)}internal/event.h
+range.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+range.$(OBJEXT): {$(VPATH)}internal/gc.h
+range.$(OBJEXT): {$(VPATH)}internal/glob.h
+range.$(OBJEXT): {$(VPATH)}internal/globals.h
+range.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+range.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+range.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+range.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+range.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+range.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+range.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+range.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+range.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+range.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+range.$(OBJEXT): {$(VPATH)}internal/iterator.h
+range.$(OBJEXT): {$(VPATH)}internal/memory.h
+range.$(OBJEXT): {$(VPATH)}internal/method.h
+range.$(OBJEXT): {$(VPATH)}internal/module.h
+range.$(OBJEXT): {$(VPATH)}internal/newobj.h
+range.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+range.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+range.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+range.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+range.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+range.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+range.$(OBJEXT): {$(VPATH)}internal/symbol.h
+range.$(OBJEXT): {$(VPATH)}internal/value.h
+range.$(OBJEXT): {$(VPATH)}internal/value_type.h
+range.$(OBJEXT): {$(VPATH)}internal/variable.h
+range.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+range.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+range.$(OBJEXT): {$(VPATH)}missing.h
+range.$(OBJEXT): {$(VPATH)}onigmo.h
+range.$(OBJEXT): {$(VPATH)}oniguruma.h
+range.$(OBJEXT): {$(VPATH)}range.c
+range.$(OBJEXT): {$(VPATH)}shape.h
+range.$(OBJEXT): {$(VPATH)}st.h
+range.$(OBJEXT): {$(VPATH)}subst.h
+rational.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+rational.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+rational.$(OBJEXT): $(CCAN_DIR)/list/list.h
+rational.$(OBJEXT): $(CCAN_DIR)/str/str.h
+rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+rational.$(OBJEXT): $(top_srcdir)/internal/array.h
+rational.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+rational.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+rational.$(OBJEXT): $(top_srcdir)/internal/bits.h
+rational.$(OBJEXT): $(top_srcdir)/internal/box.h
+rational.$(OBJEXT): $(top_srcdir)/internal/class.h
+rational.$(OBJEXT): $(top_srcdir)/internal/compar.h
+rational.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+rational.$(OBJEXT): $(top_srcdir)/internal/complex.h
+rational.$(OBJEXT): $(top_srcdir)/internal/error.h
+rational.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+rational.$(OBJEXT): $(top_srcdir)/internal/gc.h
+rational.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+rational.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+rational.$(OBJEXT): $(top_srcdir)/internal/object.h
+rational.$(OBJEXT): $(top_srcdir)/internal/rational.h
+rational.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+rational.$(OBJEXT): $(top_srcdir)/internal/serial.h
+rational.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+rational.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+rational.$(OBJEXT): $(top_srcdir)/internal/string.h
+rational.$(OBJEXT): $(top_srcdir)/internal/variable.h
+rational.$(OBJEXT): $(top_srcdir)/internal/vm.h
+rational.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+rational.$(OBJEXT): {$(VPATH)}assert.h
+rational.$(OBJEXT): {$(VPATH)}atomic.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+rational.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+rational.$(OBJEXT): {$(VPATH)}config.h
+rational.$(OBJEXT): {$(VPATH)}constant.h
+rational.$(OBJEXT): {$(VPATH)}defines.h
+rational.$(OBJEXT): {$(VPATH)}encindex.h
+rational.$(OBJEXT): {$(VPATH)}encoding.h
+rational.$(OBJEXT): {$(VPATH)}id.h
+rational.$(OBJEXT): {$(VPATH)}id_table.h
+rational.$(OBJEXT): {$(VPATH)}intern.h
+rational.$(OBJEXT): {$(VPATH)}internal.h
+rational.$(OBJEXT): {$(VPATH)}internal/abi.h
+rational.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+rational.$(OBJEXT): {$(VPATH)}internal/assume.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+rational.$(OBJEXT): {$(VPATH)}internal/cast.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+rational.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+rational.$(OBJEXT): {$(VPATH)}internal/config.h
+rational.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+rational.$(OBJEXT): {$(VPATH)}internal/core.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+rational.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+rational.$(OBJEXT): {$(VPATH)}internal/ctype.h
+rational.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+rational.$(OBJEXT): {$(VPATH)}internal/dosish.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+rational.$(OBJEXT): {$(VPATH)}internal/error.h
+rational.$(OBJEXT): {$(VPATH)}internal/eval.h
+rational.$(OBJEXT): {$(VPATH)}internal/event.h
+rational.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+rational.$(OBJEXT): {$(VPATH)}internal/gc.h
+rational.$(OBJEXT): {$(VPATH)}internal/glob.h
+rational.$(OBJEXT): {$(VPATH)}internal/globals.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+rational.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+rational.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+rational.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+rational.$(OBJEXT): {$(VPATH)}internal/iterator.h
+rational.$(OBJEXT): {$(VPATH)}internal/memory.h
+rational.$(OBJEXT): {$(VPATH)}internal/method.h
+rational.$(OBJEXT): {$(VPATH)}internal/module.h
+rational.$(OBJEXT): {$(VPATH)}internal/newobj.h
+rational.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+rational.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+rational.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+rational.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+rational.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+rational.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+rational.$(OBJEXT): {$(VPATH)}internal/symbol.h
+rational.$(OBJEXT): {$(VPATH)}internal/value.h
+rational.$(OBJEXT): {$(VPATH)}internal/value_type.h
+rational.$(OBJEXT): {$(VPATH)}internal/variable.h
+rational.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+rational.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+rational.$(OBJEXT): {$(VPATH)}method.h
+rational.$(OBJEXT): {$(VPATH)}missing.h
+rational.$(OBJEXT): {$(VPATH)}node.h
+rational.$(OBJEXT): {$(VPATH)}onigmo.h
+rational.$(OBJEXT): {$(VPATH)}oniguruma.h
+rational.$(OBJEXT): {$(VPATH)}rational.c
+rational.$(OBJEXT): {$(VPATH)}ruby_assert.h
+rational.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+rational.$(OBJEXT): {$(VPATH)}rubyparser.h
+rational.$(OBJEXT): {$(VPATH)}shape.h
+rational.$(OBJEXT): {$(VPATH)}st.h
+rational.$(OBJEXT): {$(VPATH)}subst.h
+rational.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+rational.$(OBJEXT): {$(VPATH)}thread_native.h
+rational.$(OBJEXT): {$(VPATH)}vm_core.h
+rational.$(OBJEXT): {$(VPATH)}vm_opts.h
+re.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+re.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+re.$(OBJEXT): $(CCAN_DIR)/list/list.h
+re.$(OBJEXT): $(CCAN_DIR)/str/str.h
+re.$(OBJEXT): $(hdrdir)/ruby.h
+re.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+re.$(OBJEXT): $(top_srcdir)/internal/array.h
+re.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+re.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+re.$(OBJEXT): $(top_srcdir)/internal/bits.h
+re.$(OBJEXT): $(top_srcdir)/internal/box.h
+re.$(OBJEXT): $(top_srcdir)/internal/class.h
+re.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+re.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+re.$(OBJEXT): $(top_srcdir)/internal/error.h
+re.$(OBJEXT): $(top_srcdir)/internal/gc.h
+re.$(OBJEXT): $(top_srcdir)/internal/hash.h
+re.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+re.$(OBJEXT): $(top_srcdir)/internal/object.h
+re.$(OBJEXT): $(top_srcdir)/internal/ractor.h
+re.$(OBJEXT): $(top_srcdir)/internal/re.h
+re.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+re.$(OBJEXT): $(top_srcdir)/internal/serial.h
+re.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+re.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+re.$(OBJEXT): $(top_srcdir)/internal/string.h
+re.$(OBJEXT): $(top_srcdir)/internal/struct.h
+re.$(OBJEXT): $(top_srcdir)/internal/time.h
+re.$(OBJEXT): $(top_srcdir)/internal/variable.h
+re.$(OBJEXT): $(top_srcdir)/internal/vm.h
+re.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+re.$(OBJEXT): {$(VPATH)}assert.h
+re.$(OBJEXT): {$(VPATH)}atomic.h
+re.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+re.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+re.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+re.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+re.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+re.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+re.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+re.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+re.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+re.$(OBJEXT): {$(VPATH)}config.h
+re.$(OBJEXT): {$(VPATH)}constant.h
+re.$(OBJEXT): {$(VPATH)}defines.h
+re.$(OBJEXT): {$(VPATH)}encindex.h
+re.$(OBJEXT): {$(VPATH)}encoding.h
+re.$(OBJEXT): {$(VPATH)}hrtime.h
+re.$(OBJEXT): {$(VPATH)}id.h
+re.$(OBJEXT): {$(VPATH)}id_table.h
+re.$(OBJEXT): {$(VPATH)}intern.h
+re.$(OBJEXT): {$(VPATH)}internal.h
+re.$(OBJEXT): {$(VPATH)}internal/abi.h
+re.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+re.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+re.$(OBJEXT): {$(VPATH)}internal/assume.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+re.$(OBJEXT): {$(VPATH)}internal/cast.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+re.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+re.$(OBJEXT): {$(VPATH)}internal/config.h
+re.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+re.$(OBJEXT): {$(VPATH)}internal/core.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+re.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+re.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+re.$(OBJEXT): {$(VPATH)}internal/ctype.h
+re.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+re.$(OBJEXT): {$(VPATH)}internal/dosish.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+re.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+re.$(OBJEXT): {$(VPATH)}internal/error.h
+re.$(OBJEXT): {$(VPATH)}internal/eval.h
+re.$(OBJEXT): {$(VPATH)}internal/event.h
+re.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+re.$(OBJEXT): {$(VPATH)}internal/gc.h
+re.$(OBJEXT): {$(VPATH)}internal/glob.h
+re.$(OBJEXT): {$(VPATH)}internal/globals.h
+re.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+re.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+re.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+re.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+re.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+re.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+re.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+re.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+re.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+re.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+re.$(OBJEXT): {$(VPATH)}internal/iterator.h
+re.$(OBJEXT): {$(VPATH)}internal/memory.h
+re.$(OBJEXT): {$(VPATH)}internal/method.h
+re.$(OBJEXT): {$(VPATH)}internal/module.h
+re.$(OBJEXT): {$(VPATH)}internal/newobj.h
+re.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+re.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+re.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+re.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+re.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+re.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+re.$(OBJEXT): {$(VPATH)}internal/symbol.h
+re.$(OBJEXT): {$(VPATH)}internal/value.h
+re.$(OBJEXT): {$(VPATH)}internal/value_type.h
+re.$(OBJEXT): {$(VPATH)}internal/variable.h
+re.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+re.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+re.$(OBJEXT): {$(VPATH)}method.h
+re.$(OBJEXT): {$(VPATH)}missing.h
+re.$(OBJEXT): {$(VPATH)}node.h
+re.$(OBJEXT): {$(VPATH)}onigmo.h
+re.$(OBJEXT): {$(VPATH)}oniguruma.h
+re.$(OBJEXT): {$(VPATH)}ractor.h
+re.$(OBJEXT): {$(VPATH)}ractor_core.h
+re.$(OBJEXT): {$(VPATH)}re.c
+re.$(OBJEXT): {$(VPATH)}re.h
+re.$(OBJEXT): {$(VPATH)}regenc.h
+re.$(OBJEXT): {$(VPATH)}regex.h
+re.$(OBJEXT): {$(VPATH)}regint.h
+re.$(OBJEXT): {$(VPATH)}ruby_assert.h
+re.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+re.$(OBJEXT): {$(VPATH)}rubyparser.h
+re.$(OBJEXT): {$(VPATH)}shape.h
+re.$(OBJEXT): {$(VPATH)}st.h
+re.$(OBJEXT): {$(VPATH)}subst.h
+re.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+re.$(OBJEXT): {$(VPATH)}thread_native.h
+re.$(OBJEXT): {$(VPATH)}util.h
+re.$(OBJEXT): {$(VPATH)}vm_core.h
+re.$(OBJEXT): {$(VPATH)}vm_debug.h
+re.$(OBJEXT): {$(VPATH)}vm_opts.h
+regcomp.$(OBJEXT): $(hdrdir)/ruby.h
+regcomp.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regcomp.$(OBJEXT): {$(VPATH)}assert.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regcomp.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regcomp.$(OBJEXT): {$(VPATH)}config.h
+regcomp.$(OBJEXT): {$(VPATH)}defines.h
+regcomp.$(OBJEXT): {$(VPATH)}intern.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/abi.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/assume.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/cast.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/config.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/error.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/eval.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/event.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/gc.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/glob.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/globals.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/memory.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/method.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/module.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/value.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/variable.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regcomp.$(OBJEXT): {$(VPATH)}missing.h
+regcomp.$(OBJEXT): {$(VPATH)}onigmo.h
+regcomp.$(OBJEXT): {$(VPATH)}regcomp.c
+regcomp.$(OBJEXT): {$(VPATH)}regenc.h
+regcomp.$(OBJEXT): {$(VPATH)}regint.h
+regcomp.$(OBJEXT): {$(VPATH)}regparse.h
+regcomp.$(OBJEXT): {$(VPATH)}st.h
+regcomp.$(OBJEXT): {$(VPATH)}subst.h
+regenc.$(OBJEXT): $(hdrdir)/ruby.h
+regenc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regenc.$(OBJEXT): {$(VPATH)}assert.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regenc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regenc.$(OBJEXT): {$(VPATH)}config.h
+regenc.$(OBJEXT): {$(VPATH)}defines.h
+regenc.$(OBJEXT): {$(VPATH)}intern.h
+regenc.$(OBJEXT): {$(VPATH)}internal/abi.h
+regenc.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regenc.$(OBJEXT): {$(VPATH)}internal/assume.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regenc.$(OBJEXT): {$(VPATH)}internal/cast.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regenc.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regenc.$(OBJEXT): {$(VPATH)}internal/config.h
+regenc.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regenc.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regenc.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regenc.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regenc.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regenc.$(OBJEXT): {$(VPATH)}internal/error.h
+regenc.$(OBJEXT): {$(VPATH)}internal/eval.h
+regenc.$(OBJEXT): {$(VPATH)}internal/event.h
+regenc.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regenc.$(OBJEXT): {$(VPATH)}internal/gc.h
+regenc.$(OBJEXT): {$(VPATH)}internal/glob.h
+regenc.$(OBJEXT): {$(VPATH)}internal/globals.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regenc.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regenc.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regenc.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regenc.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regenc.$(OBJEXT): {$(VPATH)}internal/memory.h
+regenc.$(OBJEXT): {$(VPATH)}internal/method.h
+regenc.$(OBJEXT): {$(VPATH)}internal/module.h
+regenc.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regenc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regenc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regenc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regenc.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regenc.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regenc.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regenc.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regenc.$(OBJEXT): {$(VPATH)}internal/value.h
+regenc.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regenc.$(OBJEXT): {$(VPATH)}internal/variable.h
+regenc.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regenc.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regenc.$(OBJEXT): {$(VPATH)}missing.h
+regenc.$(OBJEXT): {$(VPATH)}onigmo.h
+regenc.$(OBJEXT): {$(VPATH)}regenc.c
+regenc.$(OBJEXT): {$(VPATH)}regenc.h
+regenc.$(OBJEXT): {$(VPATH)}regint.h
+regenc.$(OBJEXT): {$(VPATH)}st.h
+regenc.$(OBJEXT): {$(VPATH)}subst.h
+regerror.$(OBJEXT): $(hdrdir)/ruby.h
+regerror.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regerror.$(OBJEXT): {$(VPATH)}assert.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regerror.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regerror.$(OBJEXT): {$(VPATH)}config.h
+regerror.$(OBJEXT): {$(VPATH)}defines.h
+regerror.$(OBJEXT): {$(VPATH)}intern.h
+regerror.$(OBJEXT): {$(VPATH)}internal/abi.h
+regerror.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regerror.$(OBJEXT): {$(VPATH)}internal/assume.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regerror.$(OBJEXT): {$(VPATH)}internal/cast.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regerror.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regerror.$(OBJEXT): {$(VPATH)}internal/config.h
+regerror.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regerror.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regerror.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regerror.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regerror.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regerror.$(OBJEXT): {$(VPATH)}internal/error.h
+regerror.$(OBJEXT): {$(VPATH)}internal/eval.h
+regerror.$(OBJEXT): {$(VPATH)}internal/event.h
+regerror.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regerror.$(OBJEXT): {$(VPATH)}internal/gc.h
+regerror.$(OBJEXT): {$(VPATH)}internal/glob.h
+regerror.$(OBJEXT): {$(VPATH)}internal/globals.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regerror.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regerror.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regerror.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regerror.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regerror.$(OBJEXT): {$(VPATH)}internal/memory.h
+regerror.$(OBJEXT): {$(VPATH)}internal/method.h
+regerror.$(OBJEXT): {$(VPATH)}internal/module.h
+regerror.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regerror.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regerror.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regerror.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regerror.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regerror.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regerror.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regerror.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regerror.$(OBJEXT): {$(VPATH)}internal/value.h
+regerror.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regerror.$(OBJEXT): {$(VPATH)}internal/variable.h
+regerror.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regerror.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regerror.$(OBJEXT): {$(VPATH)}missing.h
+regerror.$(OBJEXT): {$(VPATH)}onigmo.h
+regerror.$(OBJEXT): {$(VPATH)}regenc.h
+regerror.$(OBJEXT): {$(VPATH)}regerror.c
+regerror.$(OBJEXT): {$(VPATH)}regint.h
+regerror.$(OBJEXT): {$(VPATH)}st.h
+regerror.$(OBJEXT): {$(VPATH)}subst.h
+regexec.$(OBJEXT): $(hdrdir)/ruby.h
+regexec.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regexec.$(OBJEXT): {$(VPATH)}assert.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regexec.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regexec.$(OBJEXT): {$(VPATH)}config.h
+regexec.$(OBJEXT): {$(VPATH)}defines.h
+regexec.$(OBJEXT): {$(VPATH)}intern.h
+regexec.$(OBJEXT): {$(VPATH)}internal/abi.h
+regexec.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regexec.$(OBJEXT): {$(VPATH)}internal/assume.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regexec.$(OBJEXT): {$(VPATH)}internal/cast.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regexec.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regexec.$(OBJEXT): {$(VPATH)}internal/config.h
+regexec.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regexec.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regexec.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regexec.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regexec.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regexec.$(OBJEXT): {$(VPATH)}internal/error.h
+regexec.$(OBJEXT): {$(VPATH)}internal/eval.h
+regexec.$(OBJEXT): {$(VPATH)}internal/event.h
+regexec.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regexec.$(OBJEXT): {$(VPATH)}internal/gc.h
+regexec.$(OBJEXT): {$(VPATH)}internal/glob.h
+regexec.$(OBJEXT): {$(VPATH)}internal/globals.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regexec.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regexec.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regexec.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regexec.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regexec.$(OBJEXT): {$(VPATH)}internal/memory.h
+regexec.$(OBJEXT): {$(VPATH)}internal/method.h
+regexec.$(OBJEXT): {$(VPATH)}internal/module.h
+regexec.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regexec.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regexec.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regexec.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regexec.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regexec.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regexec.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regexec.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regexec.$(OBJEXT): {$(VPATH)}internal/value.h
+regexec.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regexec.$(OBJEXT): {$(VPATH)}internal/variable.h
+regexec.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regexec.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regexec.$(OBJEXT): {$(VPATH)}missing.h
+regexec.$(OBJEXT): {$(VPATH)}onigmo.h
+regexec.$(OBJEXT): {$(VPATH)}regenc.h
+regexec.$(OBJEXT): {$(VPATH)}regexec.c
+regexec.$(OBJEXT): {$(VPATH)}regint.h
+regexec.$(OBJEXT): {$(VPATH)}st.h
+regexec.$(OBJEXT): {$(VPATH)}subst.h
+regparse.$(OBJEXT): $(hdrdir)/ruby.h
+regparse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regparse.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+regparse.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+regparse.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+regparse.$(OBJEXT): {$(VPATH)}assert.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regparse.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regparse.$(OBJEXT): {$(VPATH)}config.h
+regparse.$(OBJEXT): {$(VPATH)}defines.h
+regparse.$(OBJEXT): {$(VPATH)}intern.h
+regparse.$(OBJEXT): {$(VPATH)}internal/abi.h
+regparse.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regparse.$(OBJEXT): {$(VPATH)}internal/assume.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regparse.$(OBJEXT): {$(VPATH)}internal/cast.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regparse.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regparse.$(OBJEXT): {$(VPATH)}internal/config.h
+regparse.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regparse.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regparse.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regparse.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regparse.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regparse.$(OBJEXT): {$(VPATH)}internal/error.h
+regparse.$(OBJEXT): {$(VPATH)}internal/eval.h
+regparse.$(OBJEXT): {$(VPATH)}internal/event.h
+regparse.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regparse.$(OBJEXT): {$(VPATH)}internal/gc.h
+regparse.$(OBJEXT): {$(VPATH)}internal/glob.h
+regparse.$(OBJEXT): {$(VPATH)}internal/globals.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regparse.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regparse.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regparse.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regparse.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regparse.$(OBJEXT): {$(VPATH)}internal/memory.h
+regparse.$(OBJEXT): {$(VPATH)}internal/method.h
+regparse.$(OBJEXT): {$(VPATH)}internal/module.h
+regparse.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regparse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regparse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regparse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regparse.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regparse.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regparse.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regparse.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regparse.$(OBJEXT): {$(VPATH)}internal/value.h
+regparse.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regparse.$(OBJEXT): {$(VPATH)}internal/variable.h
+regparse.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regparse.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regparse.$(OBJEXT): {$(VPATH)}missing.h
+regparse.$(OBJEXT): {$(VPATH)}onigmo.h
+regparse.$(OBJEXT): {$(VPATH)}regenc.h
+regparse.$(OBJEXT): {$(VPATH)}regint.h
+regparse.$(OBJEXT): {$(VPATH)}regparse.c
+regparse.$(OBJEXT): {$(VPATH)}regparse.h
+regparse.$(OBJEXT): {$(VPATH)}st.h
+regparse.$(OBJEXT): {$(VPATH)}subst.h
+regsyntax.$(OBJEXT): $(hdrdir)/ruby.h
+regsyntax.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+regsyntax.$(OBJEXT): {$(VPATH)}assert.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+regsyntax.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+regsyntax.$(OBJEXT): {$(VPATH)}config.h
+regsyntax.$(OBJEXT): {$(VPATH)}defines.h
+regsyntax.$(OBJEXT): {$(VPATH)}intern.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/abi.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/assume.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/cast.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/config.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/ctype.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/dosish.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/error.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/eval.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/event.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/gc.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/glob.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/globals.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/iterator.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/memory.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/method.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/module.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/newobj.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/symbol.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/value.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/value_type.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/variable.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+regsyntax.$(OBJEXT): {$(VPATH)}missing.h
+regsyntax.$(OBJEXT): {$(VPATH)}onigmo.h
+regsyntax.$(OBJEXT): {$(VPATH)}regenc.h
+regsyntax.$(OBJEXT): {$(VPATH)}regint.h
+regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c
+regsyntax.$(OBJEXT): {$(VPATH)}st.h
+regsyntax.$(OBJEXT): {$(VPATH)}subst.h
+ruby-runner.$(OBJEXT): {$(VPATH)}config.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+ruby-runner.$(OBJEXT): {$(VPATH)}internal/config.h
+ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.c
+ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.h
+ruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+ruby.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+ruby.$(OBJEXT): $(CCAN_DIR)/list/list.h
+ruby.$(OBJEXT): $(CCAN_DIR)/str/str.h
+ruby.$(OBJEXT): $(hdrdir)/ruby.h
+ruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+ruby.$(OBJEXT): $(hdrdir)/ruby/version.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/array.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/bits.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/box.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/class.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/compar.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/complex.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/cont.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/error.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/file.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/gc.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/inits.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/io.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/load.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/loadpath.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/missing.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/object.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/parse.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/rational.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/string.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/struct.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/thread.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/arena.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/ast.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/comments.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/integer.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/json.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/node.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/options.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/parser.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/prism.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/source.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/stream.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/version.h
+ruby.$(OBJEXT): {$(VPATH)}assert.h
+ruby.$(OBJEXT): {$(VPATH)}atomic.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+ruby.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+ruby.$(OBJEXT): {$(VPATH)}config.h
+ruby.$(OBJEXT): {$(VPATH)}constant.h
+ruby.$(OBJEXT): {$(VPATH)}debug_counter.h
+ruby.$(OBJEXT): {$(VPATH)}defines.h
+ruby.$(OBJEXT): {$(VPATH)}dln.h
+ruby.$(OBJEXT): {$(VPATH)}encindex.h
+ruby.$(OBJEXT): {$(VPATH)}encoding.h
+ruby.$(OBJEXT): {$(VPATH)}eval_intern.h
+ruby.$(OBJEXT): {$(VPATH)}id.h
+ruby.$(OBJEXT): {$(VPATH)}id_table.h
+ruby.$(OBJEXT): {$(VPATH)}intern.h
+ruby.$(OBJEXT): {$(VPATH)}internal.h
+ruby.$(OBJEXT): {$(VPATH)}internal/abi.h
+ruby.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+ruby.$(OBJEXT): {$(VPATH)}internal/assume.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+ruby.$(OBJEXT): {$(VPATH)}internal/cast.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+ruby.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+ruby.$(OBJEXT): {$(VPATH)}internal/config.h
+ruby.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+ruby.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+ruby.$(OBJEXT): {$(VPATH)}internal/ctype.h
+ruby.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+ruby.$(OBJEXT): {$(VPATH)}internal/dosish.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+ruby.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+ruby.$(OBJEXT): {$(VPATH)}internal/error.h
+ruby.$(OBJEXT): {$(VPATH)}internal/eval.h
+ruby.$(OBJEXT): {$(VPATH)}internal/event.h
+ruby.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+ruby.$(OBJEXT): {$(VPATH)}internal/gc.h
+ruby.$(OBJEXT): {$(VPATH)}internal/glob.h
+ruby.$(OBJEXT): {$(VPATH)}internal/globals.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+ruby.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+ruby.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+ruby.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+ruby.$(OBJEXT): {$(VPATH)}internal/iterator.h
+ruby.$(OBJEXT): {$(VPATH)}internal/memory.h
+ruby.$(OBJEXT): {$(VPATH)}internal/method.h
+ruby.$(OBJEXT): {$(VPATH)}internal/module.h
+ruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
+ruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+ruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+ruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+ruby.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+ruby.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+ruby.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+ruby.$(OBJEXT): {$(VPATH)}internal/symbol.h
+ruby.$(OBJEXT): {$(VPATH)}internal/value.h
+ruby.$(OBJEXT): {$(VPATH)}internal/value_type.h
+ruby.$(OBJEXT): {$(VPATH)}internal/variable.h
+ruby.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+ruby.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+ruby.$(OBJEXT): {$(VPATH)}io.h
+ruby.$(OBJEXT): {$(VPATH)}iseq.h
+ruby.$(OBJEXT): {$(VPATH)}method.h
+ruby.$(OBJEXT): {$(VPATH)}missing.h
+ruby.$(OBJEXT): {$(VPATH)}node.h
+ruby.$(OBJEXT): {$(VPATH)}onigmo.h
+ruby.$(OBJEXT): {$(VPATH)}oniguruma.h
+ruby.$(OBJEXT): {$(VPATH)}prism_compile.h
+ruby.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+ruby.$(OBJEXT): {$(VPATH)}ruby.c
+ruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
+ruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ruby.$(OBJEXT): {$(VPATH)}rubyparser.h
+ruby.$(OBJEXT): {$(VPATH)}shape.h
+ruby.$(OBJEXT): {$(VPATH)}st.h
+ruby.$(OBJEXT): {$(VPATH)}subst.h
+ruby.$(OBJEXT): {$(VPATH)}thread.h
+ruby.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+ruby.$(OBJEXT): {$(VPATH)}thread_native.h
+ruby.$(OBJEXT): {$(VPATH)}util.h
+ruby.$(OBJEXT): {$(VPATH)}vm_core.h
+ruby.$(OBJEXT): {$(VPATH)}vm_opts.h
+ruby.$(OBJEXT): {$(VPATH)}yjit.h
+ruby.$(OBJEXT): {$(VPATH)}zjit.h
+ruby_parser.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/array.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/bits.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/compar.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/complex.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/error.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/parse.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/rational.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/re.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/serial.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/string.h
+ruby_parser.$(OBJEXT): $(top_srcdir)/internal/vm.h
+ruby_parser.$(OBJEXT): {$(VPATH)}assert.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+ruby_parser.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+ruby_parser.$(OBJEXT): {$(VPATH)}config.h
+ruby_parser.$(OBJEXT): {$(VPATH)}defines.h
+ruby_parser.$(OBJEXT): {$(VPATH)}encindex.h
+ruby_parser.$(OBJEXT): {$(VPATH)}encoding.h
+ruby_parser.$(OBJEXT): {$(VPATH)}intern.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/abi.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/assume.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/cast.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/config.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/ctype.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/dosish.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/error.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/eval.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/event.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/gc.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/glob.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/globals.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/iterator.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/memory.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/method.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/module.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/newobj.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/symbol.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/value.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/value_type.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/variable.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+ruby_parser.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+ruby_parser.$(OBJEXT): {$(VPATH)}missing.h
+ruby_parser.$(OBJEXT): {$(VPATH)}node.h
+ruby_parser.$(OBJEXT): {$(VPATH)}onigmo.h
+ruby_parser.$(OBJEXT): {$(VPATH)}oniguruma.h
+ruby_parser.$(OBJEXT): {$(VPATH)}re.h
+ruby_parser.$(OBJEXT): {$(VPATH)}regex.h
+ruby_parser.$(OBJEXT): {$(VPATH)}ruby_assert.h
+ruby_parser.$(OBJEXT): {$(VPATH)}ruby_parser.c
+ruby_parser.$(OBJEXT): {$(VPATH)}rubyparser.h
+ruby_parser.$(OBJEXT): {$(VPATH)}st.h
+ruby_parser.$(OBJEXT): {$(VPATH)}subst.h
+scheduler.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+scheduler.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+scheduler.$(OBJEXT): $(CCAN_DIR)/list/list.h
+scheduler.$(OBJEXT): $(CCAN_DIR)/str/str.h
+scheduler.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/array.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/box.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/gc.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/serial.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/thread.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/variable.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/vm.h
+scheduler.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+scheduler.$(OBJEXT): {$(VPATH)}assert.h
+scheduler.$(OBJEXT): {$(VPATH)}atomic.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+scheduler.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+scheduler.$(OBJEXT): {$(VPATH)}config.h
+scheduler.$(OBJEXT): {$(VPATH)}constant.h
+scheduler.$(OBJEXT): {$(VPATH)}defines.h
+scheduler.$(OBJEXT): {$(VPATH)}encoding.h
+scheduler.$(OBJEXT): {$(VPATH)}eval_intern.h
+scheduler.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+scheduler.$(OBJEXT): {$(VPATH)}id.h
+scheduler.$(OBJEXT): {$(VPATH)}id_table.h
+scheduler.$(OBJEXT): {$(VPATH)}intern.h
+scheduler.$(OBJEXT): {$(VPATH)}internal.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/abi.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/assume.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/cast.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/config.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/ctype.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/dosish.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/error.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/eval.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/event.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/gc.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/glob.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/globals.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/iterator.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/memory.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/method.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/module.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/newobj.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/symbol.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/value.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/value_type.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/variable.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+scheduler.$(OBJEXT): {$(VPATH)}io.h
+scheduler.$(OBJEXT): {$(VPATH)}io/buffer.h
+scheduler.$(OBJEXT): {$(VPATH)}method.h
+scheduler.$(OBJEXT): {$(VPATH)}missing.h
+scheduler.$(OBJEXT): {$(VPATH)}node.h
+scheduler.$(OBJEXT): {$(VPATH)}onigmo.h
+scheduler.$(OBJEXT): {$(VPATH)}oniguruma.h
+scheduler.$(OBJEXT): {$(VPATH)}ruby_assert.h
+scheduler.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+scheduler.$(OBJEXT): {$(VPATH)}rubyparser.h
+scheduler.$(OBJEXT): {$(VPATH)}scheduler.c
+scheduler.$(OBJEXT): {$(VPATH)}shape.h
+scheduler.$(OBJEXT): {$(VPATH)}st.h
+scheduler.$(OBJEXT): {$(VPATH)}subst.h
+scheduler.$(OBJEXT): {$(VPATH)}thread.h
+scheduler.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+scheduler.$(OBJEXT): {$(VPATH)}thread_native.h
+scheduler.$(OBJEXT): {$(VPATH)}vm_core.h
+scheduler.$(OBJEXT): {$(VPATH)}vm_opts.h
+scheduler.$(OBJEXT): {$(VPATH)}zjit.h
+set.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+set.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+set.$(OBJEXT): $(CCAN_DIR)/list/list.h
+set.$(OBJEXT): $(CCAN_DIR)/str/str.h
+set.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+set.$(OBJEXT): $(top_srcdir)/internal/array.h
+set.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+set.$(OBJEXT): $(top_srcdir)/internal/bits.h
+set.$(OBJEXT): $(top_srcdir)/internal/box.h
+set.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+set.$(OBJEXT): $(top_srcdir)/internal/error.h
+set.$(OBJEXT): $(top_srcdir)/internal/gc.h
+set.$(OBJEXT): $(top_srcdir)/internal/hash.h
+set.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+set.$(OBJEXT): $(top_srcdir)/internal/proc.h
+set.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+set.$(OBJEXT): $(top_srcdir)/internal/serial.h
+set.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+set.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+set.$(OBJEXT): $(top_srcdir)/internal/string.h
+set.$(OBJEXT): $(top_srcdir)/internal/struct.h
+set.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+set.$(OBJEXT): $(top_srcdir)/internal/variable.h
+set.$(OBJEXT): $(top_srcdir)/internal/vm.h
+set.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+set.$(OBJEXT): {$(VPATH)}assert.h
+set.$(OBJEXT): {$(VPATH)}atomic.h
+set.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+set.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+set.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+set.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+set.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+set.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+set.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+set.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+set.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+set.$(OBJEXT): {$(VPATH)}config.h
+set.$(OBJEXT): {$(VPATH)}constant.h
+set.$(OBJEXT): {$(VPATH)}defines.h
+set.$(OBJEXT): {$(VPATH)}encindex.h
+set.$(OBJEXT): {$(VPATH)}encoding.h
+set.$(OBJEXT): {$(VPATH)}id.h
+set.$(OBJEXT): {$(VPATH)}id_table.h
+set.$(OBJEXT): {$(VPATH)}intern.h
+set.$(OBJEXT): {$(VPATH)}internal.h
+set.$(OBJEXT): {$(VPATH)}internal/abi.h
+set.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+set.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+set.$(OBJEXT): {$(VPATH)}internal/assume.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+set.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+set.$(OBJEXT): {$(VPATH)}internal/cast.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+set.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+set.$(OBJEXT): {$(VPATH)}internal/config.h
+set.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+set.$(OBJEXT): {$(VPATH)}internal/core.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+set.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+set.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+set.$(OBJEXT): {$(VPATH)}internal/ctype.h
+set.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+set.$(OBJEXT): {$(VPATH)}internal/dosish.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+set.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+set.$(OBJEXT): {$(VPATH)}internal/error.h
+set.$(OBJEXT): {$(VPATH)}internal/eval.h
+set.$(OBJEXT): {$(VPATH)}internal/event.h
+set.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+set.$(OBJEXT): {$(VPATH)}internal/gc.h
+set.$(OBJEXT): {$(VPATH)}internal/glob.h
+set.$(OBJEXT): {$(VPATH)}internal/globals.h
+set.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+set.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+set.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+set.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+set.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+set.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+set.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+set.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+set.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+set.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+set.$(OBJEXT): {$(VPATH)}internal/iterator.h
+set.$(OBJEXT): {$(VPATH)}internal/memory.h
+set.$(OBJEXT): {$(VPATH)}internal/method.h
+set.$(OBJEXT): {$(VPATH)}internal/module.h
+set.$(OBJEXT): {$(VPATH)}internal/newobj.h
+set.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+set.$(OBJEXT): {$(VPATH)}internal/set_table.h
+set.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+set.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+set.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+set.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+set.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+set.$(OBJEXT): {$(VPATH)}internal/symbol.h
+set.$(OBJEXT): {$(VPATH)}internal/value.h
+set.$(OBJEXT): {$(VPATH)}internal/value_type.h
+set.$(OBJEXT): {$(VPATH)}internal/variable.h
+set.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+set.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+set.$(OBJEXT): {$(VPATH)}method.h
+set.$(OBJEXT): {$(VPATH)}missing.h
+set.$(OBJEXT): {$(VPATH)}node.h
+set.$(OBJEXT): {$(VPATH)}onigmo.h
+set.$(OBJEXT): {$(VPATH)}oniguruma.h
+set.$(OBJEXT): {$(VPATH)}ruby_assert.h
+set.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+set.$(OBJEXT): {$(VPATH)}rubyparser.h
+set.$(OBJEXT): {$(VPATH)}set.c
+set.$(OBJEXT): {$(VPATH)}shape.h
+set.$(OBJEXT): {$(VPATH)}st.h
+set.$(OBJEXT): {$(VPATH)}subst.h
+set.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+set.$(OBJEXT): {$(VPATH)}thread_native.h
+set.$(OBJEXT): {$(VPATH)}vm_core.h
+set.$(OBJEXT): {$(VPATH)}vm_opts.h
+setproctitle.$(OBJEXT): $(hdrdir)/ruby.h
+setproctitle.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+setproctitle.$(OBJEXT): {$(VPATH)}assert.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+setproctitle.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+setproctitle.$(OBJEXT): {$(VPATH)}config.h
+setproctitle.$(OBJEXT): {$(VPATH)}defines.h
+setproctitle.$(OBJEXT): {$(VPATH)}intern.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/abi.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/assume.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/cast.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/config.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/ctype.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/dosish.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/error.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/eval.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/event.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/gc.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/glob.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/globals.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/iterator.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/memory.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/method.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/module.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/newobj.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/symbol.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/value.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/value_type.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/variable.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+setproctitle.$(OBJEXT): {$(VPATH)}missing.h
+setproctitle.$(OBJEXT): {$(VPATH)}setproctitle.c
+setproctitle.$(OBJEXT): {$(VPATH)}st.h
+setproctitle.$(OBJEXT): {$(VPATH)}subst.h
+setproctitle.$(OBJEXT): {$(VPATH)}util.h
+shape.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+shape.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+shape.$(OBJEXT): $(CCAN_DIR)/list/list.h
+shape.$(OBJEXT): $(CCAN_DIR)/str/str.h
+shape.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+shape.$(OBJEXT): $(hdrdir)/ruby/version.h
+shape.$(OBJEXT): $(top_srcdir)/internal/array.h
+shape.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+shape.$(OBJEXT): $(top_srcdir)/internal/box.h
+shape.$(OBJEXT): $(top_srcdir)/internal/class.h
+shape.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+shape.$(OBJEXT): $(top_srcdir)/internal/error.h
+shape.$(OBJEXT): $(top_srcdir)/internal/gc.h
+shape.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+shape.$(OBJEXT): $(top_srcdir)/internal/object.h
+shape.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+shape.$(OBJEXT): $(top_srcdir)/internal/serial.h
+shape.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+shape.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+shape.$(OBJEXT): $(top_srcdir)/internal/string.h
+shape.$(OBJEXT): $(top_srcdir)/internal/struct.h
+shape.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+shape.$(OBJEXT): $(top_srcdir)/internal/variable.h
+shape.$(OBJEXT): $(top_srcdir)/internal/vm.h
+shape.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+shape.$(OBJEXT): {$(VPATH)}assert.h
+shape.$(OBJEXT): {$(VPATH)}atomic.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+shape.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+shape.$(OBJEXT): {$(VPATH)}config.h
+shape.$(OBJEXT): {$(VPATH)}constant.h
+shape.$(OBJEXT): {$(VPATH)}debug_counter.h
+shape.$(OBJEXT): {$(VPATH)}defines.h
+shape.$(OBJEXT): {$(VPATH)}encindex.h
+shape.$(OBJEXT): {$(VPATH)}encoding.h
+shape.$(OBJEXT): {$(VPATH)}id.h
+shape.$(OBJEXT): {$(VPATH)}id_table.h
+shape.$(OBJEXT): {$(VPATH)}intern.h
+shape.$(OBJEXT): {$(VPATH)}internal.h
+shape.$(OBJEXT): {$(VPATH)}internal/abi.h
+shape.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+shape.$(OBJEXT): {$(VPATH)}internal/assume.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+shape.$(OBJEXT): {$(VPATH)}internal/cast.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+shape.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+shape.$(OBJEXT): {$(VPATH)}internal/config.h
+shape.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+shape.$(OBJEXT): {$(VPATH)}internal/core.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+shape.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+shape.$(OBJEXT): {$(VPATH)}internal/ctype.h
+shape.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+shape.$(OBJEXT): {$(VPATH)}internal/dosish.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+shape.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+shape.$(OBJEXT): {$(VPATH)}internal/error.h
+shape.$(OBJEXT): {$(VPATH)}internal/eval.h
+shape.$(OBJEXT): {$(VPATH)}internal/event.h
+shape.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+shape.$(OBJEXT): {$(VPATH)}internal/gc.h
+shape.$(OBJEXT): {$(VPATH)}internal/glob.h
+shape.$(OBJEXT): {$(VPATH)}internal/globals.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+shape.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+shape.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+shape.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+shape.$(OBJEXT): {$(VPATH)}internal/iterator.h
+shape.$(OBJEXT): {$(VPATH)}internal/memory.h
+shape.$(OBJEXT): {$(VPATH)}internal/method.h
+shape.$(OBJEXT): {$(VPATH)}internal/module.h
+shape.$(OBJEXT): {$(VPATH)}internal/newobj.h
+shape.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+shape.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+shape.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+shape.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+shape.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+shape.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+shape.$(OBJEXT): {$(VPATH)}internal/symbol.h
+shape.$(OBJEXT): {$(VPATH)}internal/value.h
+shape.$(OBJEXT): {$(VPATH)}internal/value_type.h
+shape.$(OBJEXT): {$(VPATH)}internal/variable.h
+shape.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+shape.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+shape.$(OBJEXT): {$(VPATH)}method.h
+shape.$(OBJEXT): {$(VPATH)}missing.h
+shape.$(OBJEXT): {$(VPATH)}node.h
+shape.$(OBJEXT): {$(VPATH)}onigmo.h
+shape.$(OBJEXT): {$(VPATH)}oniguruma.h
+shape.$(OBJEXT): {$(VPATH)}ruby_assert.h
+shape.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+shape.$(OBJEXT): {$(VPATH)}rubyparser.h
+shape.$(OBJEXT): {$(VPATH)}shape.c
+shape.$(OBJEXT): {$(VPATH)}shape.h
+shape.$(OBJEXT): {$(VPATH)}st.h
+shape.$(OBJEXT): {$(VPATH)}subst.h
+shape.$(OBJEXT): {$(VPATH)}symbol.h
+shape.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+shape.$(OBJEXT): {$(VPATH)}thread_native.h
+shape.$(OBJEXT): {$(VPATH)}variable.h
+shape.$(OBJEXT): {$(VPATH)}vm_core.h
+shape.$(OBJEXT): {$(VPATH)}vm_debug.h
+shape.$(OBJEXT): {$(VPATH)}vm_opts.h
+shape.$(OBJEXT): {$(VPATH)}vm_sync.h
+signal.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+signal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+signal.$(OBJEXT): $(CCAN_DIR)/list/list.h
+signal.$(OBJEXT): $(CCAN_DIR)/str/str.h
+signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+signal.$(OBJEXT): $(hdrdir)/ruby/version.h
+signal.$(OBJEXT): $(top_srcdir)/internal/array.h
+signal.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+signal.$(OBJEXT): $(top_srcdir)/internal/box.h
+signal.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+signal.$(OBJEXT): $(top_srcdir)/internal/error.h
+signal.$(OBJEXT): $(top_srcdir)/internal/eval.h
+signal.$(OBJEXT): $(top_srcdir)/internal/gc.h
+signal.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+signal.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+signal.$(OBJEXT): $(top_srcdir)/internal/serial.h
+signal.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+signal.$(OBJEXT): $(top_srcdir)/internal/signal.h
+signal.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+signal.$(OBJEXT): $(top_srcdir)/internal/string.h
+signal.$(OBJEXT): $(top_srcdir)/internal/thread.h
+signal.$(OBJEXT): $(top_srcdir)/internal/variable.h
+signal.$(OBJEXT): $(top_srcdir)/internal/vm.h
+signal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+signal.$(OBJEXT): {$(VPATH)}assert.h
+signal.$(OBJEXT): {$(VPATH)}atomic.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+signal.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+signal.$(OBJEXT): {$(VPATH)}config.h
+signal.$(OBJEXT): {$(VPATH)}constant.h
+signal.$(OBJEXT): {$(VPATH)}debug_counter.h
+signal.$(OBJEXT): {$(VPATH)}defines.h
+signal.$(OBJEXT): {$(VPATH)}encindex.h
+signal.$(OBJEXT): {$(VPATH)}encoding.h
+signal.$(OBJEXT): {$(VPATH)}eval_intern.h
+signal.$(OBJEXT): {$(VPATH)}id.h
+signal.$(OBJEXT): {$(VPATH)}id_table.h
+signal.$(OBJEXT): {$(VPATH)}intern.h
+signal.$(OBJEXT): {$(VPATH)}internal.h
+signal.$(OBJEXT): {$(VPATH)}internal/abi.h
+signal.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+signal.$(OBJEXT): {$(VPATH)}internal/assume.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+signal.$(OBJEXT): {$(VPATH)}internal/cast.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+signal.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+signal.$(OBJEXT): {$(VPATH)}internal/config.h
+signal.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+signal.$(OBJEXT): {$(VPATH)}internal/core.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+signal.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+signal.$(OBJEXT): {$(VPATH)}internal/ctype.h
+signal.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+signal.$(OBJEXT): {$(VPATH)}internal/dosish.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+signal.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+signal.$(OBJEXT): {$(VPATH)}internal/error.h
+signal.$(OBJEXT): {$(VPATH)}internal/eval.h
+signal.$(OBJEXT): {$(VPATH)}internal/event.h
+signal.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+signal.$(OBJEXT): {$(VPATH)}internal/gc.h
+signal.$(OBJEXT): {$(VPATH)}internal/glob.h
+signal.$(OBJEXT): {$(VPATH)}internal/globals.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+signal.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+signal.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+signal.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+signal.$(OBJEXT): {$(VPATH)}internal/iterator.h
+signal.$(OBJEXT): {$(VPATH)}internal/memory.h
+signal.$(OBJEXT): {$(VPATH)}internal/method.h
+signal.$(OBJEXT): {$(VPATH)}internal/module.h
+signal.$(OBJEXT): {$(VPATH)}internal/newobj.h
+signal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+signal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+signal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+signal.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+signal.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+signal.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+signal.$(OBJEXT): {$(VPATH)}internal/symbol.h
+signal.$(OBJEXT): {$(VPATH)}internal/value.h
+signal.$(OBJEXT): {$(VPATH)}internal/value_type.h
+signal.$(OBJEXT): {$(VPATH)}internal/variable.h
+signal.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+signal.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+signal.$(OBJEXT): {$(VPATH)}method.h
+signal.$(OBJEXT): {$(VPATH)}missing.h
+signal.$(OBJEXT): {$(VPATH)}node.h
+signal.$(OBJEXT): {$(VPATH)}onigmo.h
+signal.$(OBJEXT): {$(VPATH)}oniguruma.h
+signal.$(OBJEXT): {$(VPATH)}ractor.h
+signal.$(OBJEXT): {$(VPATH)}ractor_core.h
+signal.$(OBJEXT): {$(VPATH)}ruby_assert.h
+signal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+signal.$(OBJEXT): {$(VPATH)}rubyparser.h
+signal.$(OBJEXT): {$(VPATH)}shape.h
+signal.$(OBJEXT): {$(VPATH)}signal.c
+signal.$(OBJEXT): {$(VPATH)}st.h
+signal.$(OBJEXT): {$(VPATH)}subst.h
+signal.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+signal.$(OBJEXT): {$(VPATH)}thread_native.h
+signal.$(OBJEXT): {$(VPATH)}vm_core.h
+signal.$(OBJEXT): {$(VPATH)}vm_debug.h
+signal.$(OBJEXT): {$(VPATH)}vm_opts.h
+signal.$(OBJEXT): {$(VPATH)}zjit.h
+sprintf.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+sprintf.$(OBJEXT): $(hdrdir)/ruby/version.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/bits.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/class.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/compar.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/error.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/gc.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/hash.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/object.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/serial.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/string.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/variable.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/vm.h
+sprintf.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+sprintf.$(OBJEXT): {$(VPATH)}assert.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+sprintf.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+sprintf.$(OBJEXT): {$(VPATH)}config.h
+sprintf.$(OBJEXT): {$(VPATH)}constant.h
+sprintf.$(OBJEXT): {$(VPATH)}defines.h
+sprintf.$(OBJEXT): {$(VPATH)}encindex.h
+sprintf.$(OBJEXT): {$(VPATH)}encoding.h
+sprintf.$(OBJEXT): {$(VPATH)}id.h
+sprintf.$(OBJEXT): {$(VPATH)}id_table.h
+sprintf.$(OBJEXT): {$(VPATH)}intern.h
+sprintf.$(OBJEXT): {$(VPATH)}internal.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/abi.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/assume.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/cast.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/config.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/ctype.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/dosish.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/error.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/eval.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/event.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/gc.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/glob.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/globals.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/iterator.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/memory.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/method.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/module.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/newobj.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/symbol.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/value.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/value_type.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/variable.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+sprintf.$(OBJEXT): {$(VPATH)}missing.h
+sprintf.$(OBJEXT): {$(VPATH)}onigmo.h
+sprintf.$(OBJEXT): {$(VPATH)}oniguruma.h
+sprintf.$(OBJEXT): {$(VPATH)}re.h
+sprintf.$(OBJEXT): {$(VPATH)}regex.h
+sprintf.$(OBJEXT): {$(VPATH)}shape.h
+sprintf.$(OBJEXT): {$(VPATH)}sprintf.c
+sprintf.$(OBJEXT): {$(VPATH)}st.h
+sprintf.$(OBJEXT): {$(VPATH)}subst.h
+sprintf.$(OBJEXT): {$(VPATH)}util.h
+sprintf.$(OBJEXT): {$(VPATH)}vsnprintf.c
+st.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+st.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+st.$(OBJEXT): $(CCAN_DIR)/list/list.h
+st.$(OBJEXT): $(CCAN_DIR)/str/str.h
+st.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+st.$(OBJEXT): $(top_srcdir)/internal/array.h
+st.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+st.$(OBJEXT): $(top_srcdir)/internal/bits.h
+st.$(OBJEXT): $(top_srcdir)/internal/box.h
+st.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+st.$(OBJEXT): $(top_srcdir)/internal/gc.h
+st.$(OBJEXT): $(top_srcdir)/internal/hash.h
+st.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+st.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+st.$(OBJEXT): $(top_srcdir)/internal/serial.h
+st.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+st.$(OBJEXT): $(top_srcdir)/internal/st.h
+st.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+st.$(OBJEXT): $(top_srcdir)/internal/vm.h
+st.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+st.$(OBJEXT): {$(VPATH)}assert.h
+st.$(OBJEXT): {$(VPATH)}atomic.h
+st.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+st.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+st.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+st.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+st.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+st.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+st.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+st.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+st.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+st.$(OBJEXT): {$(VPATH)}config.h
+st.$(OBJEXT): {$(VPATH)}defines.h
+st.$(OBJEXT): {$(VPATH)}encoding.h
+st.$(OBJEXT): {$(VPATH)}id.h
+st.$(OBJEXT): {$(VPATH)}id_table.h
+st.$(OBJEXT): {$(VPATH)}intern.h
+st.$(OBJEXT): {$(VPATH)}internal.h
+st.$(OBJEXT): {$(VPATH)}internal/abi.h
+st.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+st.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+st.$(OBJEXT): {$(VPATH)}internal/assume.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+st.$(OBJEXT): {$(VPATH)}internal/cast.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+st.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+st.$(OBJEXT): {$(VPATH)}internal/config.h
+st.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+st.$(OBJEXT): {$(VPATH)}internal/core.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+st.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+st.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+st.$(OBJEXT): {$(VPATH)}internal/ctype.h
+st.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+st.$(OBJEXT): {$(VPATH)}internal/dosish.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+st.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+st.$(OBJEXT): {$(VPATH)}internal/error.h
+st.$(OBJEXT): {$(VPATH)}internal/eval.h
+st.$(OBJEXT): {$(VPATH)}internal/event.h
+st.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+st.$(OBJEXT): {$(VPATH)}internal/gc.h
+st.$(OBJEXT): {$(VPATH)}internal/glob.h
+st.$(OBJEXT): {$(VPATH)}internal/globals.h
+st.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+st.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+st.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+st.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+st.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+st.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+st.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+st.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+st.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+st.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+st.$(OBJEXT): {$(VPATH)}internal/iterator.h
+st.$(OBJEXT): {$(VPATH)}internal/memory.h
+st.$(OBJEXT): {$(VPATH)}internal/method.h
+st.$(OBJEXT): {$(VPATH)}internal/module.h
+st.$(OBJEXT): {$(VPATH)}internal/newobj.h
+st.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+st.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+st.$(OBJEXT): {$(VPATH)}internal/st.h
+st.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+st.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+st.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+st.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+st.$(OBJEXT): {$(VPATH)}internal/symbol.h
+st.$(OBJEXT): {$(VPATH)}internal/value.h
+st.$(OBJEXT): {$(VPATH)}internal/value_type.h
+st.$(OBJEXT): {$(VPATH)}internal/variable.h
+st.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+st.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+st.$(OBJEXT): {$(VPATH)}method.h
+st.$(OBJEXT): {$(VPATH)}missing.h
+st.$(OBJEXT): {$(VPATH)}node.h
+st.$(OBJEXT): {$(VPATH)}onigmo.h
+st.$(OBJEXT): {$(VPATH)}oniguruma.h
+st.$(OBJEXT): {$(VPATH)}ruby_assert.h
+st.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+st.$(OBJEXT): {$(VPATH)}rubyparser.h
+st.$(OBJEXT): {$(VPATH)}st.c
+st.$(OBJEXT): {$(VPATH)}st.h
+st.$(OBJEXT): {$(VPATH)}subst.h
+st.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+st.$(OBJEXT): {$(VPATH)}thread_native.h
+st.$(OBJEXT): {$(VPATH)}vm_core.h
+st.$(OBJEXT): {$(VPATH)}vm_opts.h
+strftime.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/serial.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/string.h
+strftime.$(OBJEXT): $(top_srcdir)/internal/vm.h
+strftime.$(OBJEXT): {$(VPATH)}assert.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+strftime.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+strftime.$(OBJEXT): {$(VPATH)}config.h
+strftime.$(OBJEXT): {$(VPATH)}defines.h
+strftime.$(OBJEXT): {$(VPATH)}encindex.h
+strftime.$(OBJEXT): {$(VPATH)}encoding.h
+strftime.$(OBJEXT): {$(VPATH)}intern.h
+strftime.$(OBJEXT): {$(VPATH)}internal.h
+strftime.$(OBJEXT): {$(VPATH)}internal/abi.h
+strftime.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+strftime.$(OBJEXT): {$(VPATH)}internal/assume.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+strftime.$(OBJEXT): {$(VPATH)}internal/cast.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+strftime.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+strftime.$(OBJEXT): {$(VPATH)}internal/config.h
+strftime.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+strftime.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+strftime.$(OBJEXT): {$(VPATH)}internal/ctype.h
+strftime.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+strftime.$(OBJEXT): {$(VPATH)}internal/dosish.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+strftime.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+strftime.$(OBJEXT): {$(VPATH)}internal/error.h
+strftime.$(OBJEXT): {$(VPATH)}internal/eval.h
+strftime.$(OBJEXT): {$(VPATH)}internal/event.h
+strftime.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+strftime.$(OBJEXT): {$(VPATH)}internal/gc.h
+strftime.$(OBJEXT): {$(VPATH)}internal/glob.h
+strftime.$(OBJEXT): {$(VPATH)}internal/globals.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+strftime.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+strftime.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+strftime.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+strftime.$(OBJEXT): {$(VPATH)}internal/iterator.h
+strftime.$(OBJEXT): {$(VPATH)}internal/memory.h
+strftime.$(OBJEXT): {$(VPATH)}internal/method.h
+strftime.$(OBJEXT): {$(VPATH)}internal/module.h
+strftime.$(OBJEXT): {$(VPATH)}internal/newobj.h
+strftime.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+strftime.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+strftime.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+strftime.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+strftime.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+strftime.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+strftime.$(OBJEXT): {$(VPATH)}internal/symbol.h
+strftime.$(OBJEXT): {$(VPATH)}internal/value.h
+strftime.$(OBJEXT): {$(VPATH)}internal/value_type.h
+strftime.$(OBJEXT): {$(VPATH)}internal/variable.h
+strftime.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+strftime.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+strftime.$(OBJEXT): {$(VPATH)}missing.h
+strftime.$(OBJEXT): {$(VPATH)}onigmo.h
+strftime.$(OBJEXT): {$(VPATH)}oniguruma.h
+strftime.$(OBJEXT): {$(VPATH)}st.h
+strftime.$(OBJEXT): {$(VPATH)}strftime.c
+strftime.$(OBJEXT): {$(VPATH)}subst.h
+strftime.$(OBJEXT): {$(VPATH)}timev.h
+strftime.$(OBJEXT): {$(VPATH)}util.h
+string.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+string.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+string.$(OBJEXT): $(CCAN_DIR)/list/list.h
+string.$(OBJEXT): $(CCAN_DIR)/str/str.h
+string.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+string.$(OBJEXT): $(hdrdir)/ruby/version.h
+string.$(OBJEXT): $(top_srcdir)/internal/array.h
+string.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+string.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+string.$(OBJEXT): $(top_srcdir)/internal/bits.h
+string.$(OBJEXT): $(top_srcdir)/internal/box.h
+string.$(OBJEXT): $(top_srcdir)/internal/class.h
+string.$(OBJEXT): $(top_srcdir)/internal/compar.h
+string.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+string.$(OBJEXT): $(top_srcdir)/internal/concurrent_set.h
+string.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+string.$(OBJEXT): $(top_srcdir)/internal/error.h
+string.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+string.$(OBJEXT): $(top_srcdir)/internal/gc.h
+string.$(OBJEXT): $(top_srcdir)/internal/hash.h
+string.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+string.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+string.$(OBJEXT): $(top_srcdir)/internal/object.h
+string.$(OBJEXT): $(top_srcdir)/internal/proc.h
+string.$(OBJEXT): $(top_srcdir)/internal/re.h
+string.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+string.$(OBJEXT): $(top_srcdir)/internal/serial.h
+string.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+string.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+string.$(OBJEXT): $(top_srcdir)/internal/string.h
+string.$(OBJEXT): $(top_srcdir)/internal/struct.h
+string.$(OBJEXT): $(top_srcdir)/internal/transcode.h
+string.$(OBJEXT): $(top_srcdir)/internal/variable.h
+string.$(OBJEXT): $(top_srcdir)/internal/vm.h
+string.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+string.$(OBJEXT): {$(VPATH)}assert.h
+string.$(OBJEXT): {$(VPATH)}atomic.h
+string.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+string.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+string.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+string.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+string.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+string.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+string.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+string.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+string.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+string.$(OBJEXT): {$(VPATH)}config.h
+string.$(OBJEXT): {$(VPATH)}constant.h
+string.$(OBJEXT): {$(VPATH)}debug_counter.h
+string.$(OBJEXT): {$(VPATH)}defines.h
+string.$(OBJEXT): {$(VPATH)}encindex.h
+string.$(OBJEXT): {$(VPATH)}encoding.h
+string.$(OBJEXT): {$(VPATH)}id.h
+string.$(OBJEXT): {$(VPATH)}id_table.h
+string.$(OBJEXT): {$(VPATH)}intern.h
+string.$(OBJEXT): {$(VPATH)}internal.h
+string.$(OBJEXT): {$(VPATH)}internal/abi.h
+string.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+string.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+string.$(OBJEXT): {$(VPATH)}internal/assume.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+string.$(OBJEXT): {$(VPATH)}internal/cast.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+string.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+string.$(OBJEXT): {$(VPATH)}internal/config.h
+string.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+string.$(OBJEXT): {$(VPATH)}internal/core.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+string.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+string.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+string.$(OBJEXT): {$(VPATH)}internal/ctype.h
+string.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+string.$(OBJEXT): {$(VPATH)}internal/dosish.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+string.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+string.$(OBJEXT): {$(VPATH)}internal/error.h
+string.$(OBJEXT): {$(VPATH)}internal/eval.h
+string.$(OBJEXT): {$(VPATH)}internal/event.h
+string.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+string.$(OBJEXT): {$(VPATH)}internal/gc.h
+string.$(OBJEXT): {$(VPATH)}internal/glob.h
+string.$(OBJEXT): {$(VPATH)}internal/globals.h
+string.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+string.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+string.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+string.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+string.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+string.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+string.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+string.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+string.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+string.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+string.$(OBJEXT): {$(VPATH)}internal/iterator.h
+string.$(OBJEXT): {$(VPATH)}internal/memory.h
+string.$(OBJEXT): {$(VPATH)}internal/method.h
+string.$(OBJEXT): {$(VPATH)}internal/module.h
+string.$(OBJEXT): {$(VPATH)}internal/newobj.h
+string.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+string.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+string.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+string.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+string.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+string.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+string.$(OBJEXT): {$(VPATH)}internal/symbol.h
+string.$(OBJEXT): {$(VPATH)}internal/value.h
+string.$(OBJEXT): {$(VPATH)}internal/value_type.h
+string.$(OBJEXT): {$(VPATH)}internal/variable.h
+string.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+string.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+string.$(OBJEXT): {$(VPATH)}method.h
+string.$(OBJEXT): {$(VPATH)}missing.h
+string.$(OBJEXT): {$(VPATH)}node.h
+string.$(OBJEXT): {$(VPATH)}onigmo.h
+string.$(OBJEXT): {$(VPATH)}oniguruma.h
+string.$(OBJEXT): {$(VPATH)}probes.dmyh
+string.$(OBJEXT): {$(VPATH)}probes.h
+string.$(OBJEXT): {$(VPATH)}ractor.h
+string.$(OBJEXT): {$(VPATH)}re.h
+string.$(OBJEXT): {$(VPATH)}regex.h
+string.$(OBJEXT): {$(VPATH)}ruby_assert.h
+string.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+string.$(OBJEXT): {$(VPATH)}rubyparser.h
+string.$(OBJEXT): {$(VPATH)}shape.h
+string.$(OBJEXT): {$(VPATH)}st.h
+string.$(OBJEXT): {$(VPATH)}string.c
+string.$(OBJEXT): {$(VPATH)}subst.h
+string.$(OBJEXT): {$(VPATH)}thread.h
+string.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+string.$(OBJEXT): {$(VPATH)}thread_native.h
+string.$(OBJEXT): {$(VPATH)}util.h
+string.$(OBJEXT): {$(VPATH)}variable.h
+string.$(OBJEXT): {$(VPATH)}vm_core.h
+string.$(OBJEXT): {$(VPATH)}vm_debug.h
+string.$(OBJEXT): {$(VPATH)}vm_opts.h
+string.$(OBJEXT): {$(VPATH)}vm_sync.h
+strlcat.$(OBJEXT): {$(VPATH)}config.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/config.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+strlcat.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+strlcat.$(OBJEXT): {$(VPATH)}missing.h
+strlcat.$(OBJEXT): {$(VPATH)}strlcat.c
+strlcpy.$(OBJEXT): {$(VPATH)}config.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/config.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+strlcpy.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+strlcpy.$(OBJEXT): {$(VPATH)}missing.h
+strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c
+struct.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+struct.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+struct.$(OBJEXT): $(CCAN_DIR)/list/list.h
+struct.$(OBJEXT): $(CCAN_DIR)/str/str.h
+struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+struct.$(OBJEXT): $(hdrdir)/ruby/version.h
+struct.$(OBJEXT): $(top_srcdir)/internal/array.h
+struct.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+struct.$(OBJEXT): $(top_srcdir)/internal/box.h
+struct.$(OBJEXT): $(top_srcdir)/internal/class.h
+struct.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+struct.$(OBJEXT): $(top_srcdir)/internal/error.h
+struct.$(OBJEXT): $(top_srcdir)/internal/gc.h
+struct.$(OBJEXT): $(top_srcdir)/internal/hash.h
+struct.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+struct.$(OBJEXT): $(top_srcdir)/internal/object.h
+struct.$(OBJEXT): $(top_srcdir)/internal/proc.h
+struct.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+struct.$(OBJEXT): $(top_srcdir)/internal/serial.h
+struct.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+struct.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+struct.$(OBJEXT): $(top_srcdir)/internal/string.h
+struct.$(OBJEXT): $(top_srcdir)/internal/struct.h
+struct.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+struct.$(OBJEXT): $(top_srcdir)/internal/variable.h
+struct.$(OBJEXT): $(top_srcdir)/internal/vm.h
+struct.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+struct.$(OBJEXT): {$(VPATH)}assert.h
+struct.$(OBJEXT): {$(VPATH)}atomic.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+struct.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+struct.$(OBJEXT): {$(VPATH)}builtin.h
+struct.$(OBJEXT): {$(VPATH)}config.h
+struct.$(OBJEXT): {$(VPATH)}constant.h
+struct.$(OBJEXT): {$(VPATH)}debug_counter.h
+struct.$(OBJEXT): {$(VPATH)}defines.h
+struct.$(OBJEXT): {$(VPATH)}encindex.h
+struct.$(OBJEXT): {$(VPATH)}encoding.h
+struct.$(OBJEXT): {$(VPATH)}id.h
+struct.$(OBJEXT): {$(VPATH)}id_table.h
+struct.$(OBJEXT): {$(VPATH)}intern.h
+struct.$(OBJEXT): {$(VPATH)}internal.h
+struct.$(OBJEXT): {$(VPATH)}internal/abi.h
+struct.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+struct.$(OBJEXT): {$(VPATH)}internal/assume.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+struct.$(OBJEXT): {$(VPATH)}internal/cast.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+struct.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+struct.$(OBJEXT): {$(VPATH)}internal/config.h
+struct.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+struct.$(OBJEXT): {$(VPATH)}internal/core.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+struct.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+struct.$(OBJEXT): {$(VPATH)}internal/ctype.h
+struct.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+struct.$(OBJEXT): {$(VPATH)}internal/dosish.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+struct.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+struct.$(OBJEXT): {$(VPATH)}internal/error.h
+struct.$(OBJEXT): {$(VPATH)}internal/eval.h
+struct.$(OBJEXT): {$(VPATH)}internal/event.h
+struct.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+struct.$(OBJEXT): {$(VPATH)}internal/gc.h
+struct.$(OBJEXT): {$(VPATH)}internal/glob.h
+struct.$(OBJEXT): {$(VPATH)}internal/globals.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+struct.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+struct.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+struct.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+struct.$(OBJEXT): {$(VPATH)}internal/iterator.h
+struct.$(OBJEXT): {$(VPATH)}internal/memory.h
+struct.$(OBJEXT): {$(VPATH)}internal/method.h
+struct.$(OBJEXT): {$(VPATH)}internal/module.h
+struct.$(OBJEXT): {$(VPATH)}internal/newobj.h
+struct.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+struct.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+struct.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+struct.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+struct.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+struct.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+struct.$(OBJEXT): {$(VPATH)}internal/symbol.h
+struct.$(OBJEXT): {$(VPATH)}internal/value.h
+struct.$(OBJEXT): {$(VPATH)}internal/value_type.h
+struct.$(OBJEXT): {$(VPATH)}internal/variable.h
+struct.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+struct.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+struct.$(OBJEXT): {$(VPATH)}method.h
+struct.$(OBJEXT): {$(VPATH)}missing.h
+struct.$(OBJEXT): {$(VPATH)}node.h
+struct.$(OBJEXT): {$(VPATH)}onigmo.h
+struct.$(OBJEXT): {$(VPATH)}oniguruma.h
+struct.$(OBJEXT): {$(VPATH)}ruby_assert.h
+struct.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+struct.$(OBJEXT): {$(VPATH)}rubyparser.h
+struct.$(OBJEXT): {$(VPATH)}shape.h
+struct.$(OBJEXT): {$(VPATH)}st.h
+struct.$(OBJEXT): {$(VPATH)}struct.c
+struct.$(OBJEXT): {$(VPATH)}subst.h
+struct.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+struct.$(OBJEXT): {$(VPATH)}thread_native.h
+struct.$(OBJEXT): {$(VPATH)}vm_core.h
+struct.$(OBJEXT): {$(VPATH)}vm_debug.h
+struct.$(OBJEXT): {$(VPATH)}vm_opts.h
+struct.$(OBJEXT): {$(VPATH)}vm_sync.h
+symbol.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+symbol.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+symbol.$(OBJEXT): $(CCAN_DIR)/list/list.h
+symbol.$(OBJEXT): $(CCAN_DIR)/str/str.h
+symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+symbol.$(OBJEXT): $(hdrdir)/ruby/version.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/array.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/box.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/class.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/concurrent_set.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/error.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/gc.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/hash.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/object.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/serial.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/string.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/variable.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/vm.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+symbol.$(OBJEXT): {$(VPATH)}assert.h
+symbol.$(OBJEXT): {$(VPATH)}atomic.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+symbol.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+symbol.$(OBJEXT): {$(VPATH)}builtin.h
+symbol.$(OBJEXT): {$(VPATH)}config.h
+symbol.$(OBJEXT): {$(VPATH)}constant.h
+symbol.$(OBJEXT): {$(VPATH)}darray.h
+symbol.$(OBJEXT): {$(VPATH)}debug_counter.h
+symbol.$(OBJEXT): {$(VPATH)}defines.h
+symbol.$(OBJEXT): {$(VPATH)}encindex.h
+symbol.$(OBJEXT): {$(VPATH)}encoding.h
+symbol.$(OBJEXT): {$(VPATH)}id.c
+symbol.$(OBJEXT): {$(VPATH)}id.h
+symbol.$(OBJEXT): {$(VPATH)}id_table.c
+symbol.$(OBJEXT): {$(VPATH)}id_table.h
+symbol.$(OBJEXT): {$(VPATH)}intern.h
+symbol.$(OBJEXT): {$(VPATH)}internal.h
+symbol.$(OBJEXT): {$(VPATH)}internal/abi.h
+symbol.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+symbol.$(OBJEXT): {$(VPATH)}internal/assume.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+symbol.$(OBJEXT): {$(VPATH)}internal/cast.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+symbol.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+symbol.$(OBJEXT): {$(VPATH)}internal/config.h
+symbol.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+symbol.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+symbol.$(OBJEXT): {$(VPATH)}internal/ctype.h
+symbol.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+symbol.$(OBJEXT): {$(VPATH)}internal/dosish.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+symbol.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+symbol.$(OBJEXT): {$(VPATH)}internal/error.h
+symbol.$(OBJEXT): {$(VPATH)}internal/eval.h
+symbol.$(OBJEXT): {$(VPATH)}internal/event.h
+symbol.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+symbol.$(OBJEXT): {$(VPATH)}internal/gc.h
+symbol.$(OBJEXT): {$(VPATH)}internal/glob.h
+symbol.$(OBJEXT): {$(VPATH)}internal/globals.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+symbol.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+symbol.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+symbol.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+symbol.$(OBJEXT): {$(VPATH)}internal/iterator.h
+symbol.$(OBJEXT): {$(VPATH)}internal/memory.h
+symbol.$(OBJEXT): {$(VPATH)}internal/method.h
+symbol.$(OBJEXT): {$(VPATH)}internal/module.h
+symbol.$(OBJEXT): {$(VPATH)}internal/newobj.h
+symbol.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+symbol.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+symbol.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+symbol.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+symbol.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+symbol.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+symbol.$(OBJEXT): {$(VPATH)}internal/symbol.h
+symbol.$(OBJEXT): {$(VPATH)}internal/value.h
+symbol.$(OBJEXT): {$(VPATH)}internal/value_type.h
+symbol.$(OBJEXT): {$(VPATH)}internal/variable.h
+symbol.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+symbol.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+symbol.$(OBJEXT): {$(VPATH)}method.h
+symbol.$(OBJEXT): {$(VPATH)}missing.h
+symbol.$(OBJEXT): {$(VPATH)}node.h
+symbol.$(OBJEXT): {$(VPATH)}onigmo.h
+symbol.$(OBJEXT): {$(VPATH)}oniguruma.h
+symbol.$(OBJEXT): {$(VPATH)}probes.dmyh
+symbol.$(OBJEXT): {$(VPATH)}probes.h
+symbol.$(OBJEXT): {$(VPATH)}ractor.h
+symbol.$(OBJEXT): {$(VPATH)}ruby_assert.h
+symbol.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+symbol.$(OBJEXT): {$(VPATH)}rubyparser.h
+symbol.$(OBJEXT): {$(VPATH)}shape.h
+symbol.$(OBJEXT): {$(VPATH)}st.h
+symbol.$(OBJEXT): {$(VPATH)}subst.h
+symbol.$(OBJEXT): {$(VPATH)}symbol.c
+symbol.$(OBJEXT): {$(VPATH)}symbol.h
+symbol.$(OBJEXT): {$(VPATH)}symbol.rb
+symbol.$(OBJEXT): {$(VPATH)}symbol.rbinc
+symbol.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+symbol.$(OBJEXT): {$(VPATH)}thread_native.h
+symbol.$(OBJEXT): {$(VPATH)}vm_core.h
+symbol.$(OBJEXT): {$(VPATH)}vm_debug.h
+symbol.$(OBJEXT): {$(VPATH)}vm_opts.h
+symbol.$(OBJEXT): {$(VPATH)}vm_sync.h
+thread.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+thread.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+thread.$(OBJEXT): $(CCAN_DIR)/list/list.h
+thread.$(OBJEXT): $(CCAN_DIR)/str/str.h
+thread.$(OBJEXT): $(hdrdir)/ruby.h
+thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+thread.$(OBJEXT): $(hdrdir)/ruby/version.h
+thread.$(OBJEXT): $(top_srcdir)/internal/array.h
+thread.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+thread.$(OBJEXT): $(top_srcdir)/internal/bits.h
+thread.$(OBJEXT): $(top_srcdir)/internal/box.h
+thread.$(OBJEXT): $(top_srcdir)/internal/class.h
+thread.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+thread.$(OBJEXT): $(top_srcdir)/internal/cont.h
+thread.$(OBJEXT): $(top_srcdir)/internal/error.h
+thread.$(OBJEXT): $(top_srcdir)/internal/eval.h
+thread.$(OBJEXT): $(top_srcdir)/internal/gc.h
+thread.$(OBJEXT): $(top_srcdir)/internal/hash.h
+thread.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+thread.$(OBJEXT): $(top_srcdir)/internal/io.h
+thread.$(OBJEXT): $(top_srcdir)/internal/object.h
+thread.$(OBJEXT): $(top_srcdir)/internal/proc.h
+thread.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+thread.$(OBJEXT): $(top_srcdir)/internal/serial.h
+thread.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+thread.$(OBJEXT): $(top_srcdir)/internal/signal.h
+thread.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+thread.$(OBJEXT): $(top_srcdir)/internal/string.h
+thread.$(OBJEXT): $(top_srcdir)/internal/struct.h
+thread.$(OBJEXT): $(top_srcdir)/internal/thread.h
+thread.$(OBJEXT): $(top_srcdir)/internal/time.h
+thread.$(OBJEXT): $(top_srcdir)/internal/variable.h
+thread.$(OBJEXT): $(top_srcdir)/internal/vm.h
+thread.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+thread.$(OBJEXT): $(top_srcdir)/prism/arena.h
+thread.$(OBJEXT): $(top_srcdir)/prism/ast.h
+thread.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+thread.$(OBJEXT): $(top_srcdir)/prism/comments.h
+thread.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+thread.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+thread.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+thread.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+thread.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+thread.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+thread.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+thread.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+thread.$(OBJEXT): $(top_srcdir)/prism/integer.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+thread.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+thread.$(OBJEXT): $(top_srcdir)/prism/json.h
+thread.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+thread.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+thread.$(OBJEXT): $(top_srcdir)/prism/node.h
+thread.$(OBJEXT): $(top_srcdir)/prism/options.h
+thread.$(OBJEXT): $(top_srcdir)/prism/parser.h
+thread.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+thread.$(OBJEXT): $(top_srcdir)/prism/prism.h
+thread.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+thread.$(OBJEXT): $(top_srcdir)/prism/source.h
+thread.$(OBJEXT): $(top_srcdir)/prism/stream.h
+thread.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+thread.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+thread.$(OBJEXT): $(top_srcdir)/prism/version.h
+thread.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
+thread.$(OBJEXT): {$(VPATH)}assert.h
+thread.$(OBJEXT): {$(VPATH)}atomic.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+thread.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+thread.$(OBJEXT): {$(VPATH)}builtin.h
+thread.$(OBJEXT): {$(VPATH)}config.h
+thread.$(OBJEXT): {$(VPATH)}constant.h
+thread.$(OBJEXT): {$(VPATH)}debug.h
+thread.$(OBJEXT): {$(VPATH)}debug_counter.h
+thread.$(OBJEXT): {$(VPATH)}defines.h
+thread.$(OBJEXT): {$(VPATH)}encindex.h
+thread.$(OBJEXT): {$(VPATH)}encoding.h
+thread.$(OBJEXT): {$(VPATH)}eval_intern.h
+thread.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+thread.$(OBJEXT): {$(VPATH)}hrtime.h
+thread.$(OBJEXT): {$(VPATH)}id.h
+thread.$(OBJEXT): {$(VPATH)}id_table.h
+thread.$(OBJEXT): {$(VPATH)}intern.h
+thread.$(OBJEXT): {$(VPATH)}internal.h
+thread.$(OBJEXT): {$(VPATH)}internal/abi.h
+thread.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+thread.$(OBJEXT): {$(VPATH)}internal/assume.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+thread.$(OBJEXT): {$(VPATH)}internal/cast.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+thread.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+thread.$(OBJEXT): {$(VPATH)}internal/config.h
+thread.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+thread.$(OBJEXT): {$(VPATH)}internal/core.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+thread.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+thread.$(OBJEXT): {$(VPATH)}internal/ctype.h
+thread.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+thread.$(OBJEXT): {$(VPATH)}internal/dosish.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+thread.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+thread.$(OBJEXT): {$(VPATH)}internal/error.h
+thread.$(OBJEXT): {$(VPATH)}internal/eval.h
+thread.$(OBJEXT): {$(VPATH)}internal/event.h
+thread.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+thread.$(OBJEXT): {$(VPATH)}internal/gc.h
+thread.$(OBJEXT): {$(VPATH)}internal/glob.h
+thread.$(OBJEXT): {$(VPATH)}internal/globals.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+thread.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+thread.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+thread.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+thread.$(OBJEXT): {$(VPATH)}internal/iterator.h
+thread.$(OBJEXT): {$(VPATH)}internal/memory.h
+thread.$(OBJEXT): {$(VPATH)}internal/method.h
+thread.$(OBJEXT): {$(VPATH)}internal/module.h
+thread.$(OBJEXT): {$(VPATH)}internal/newobj.h
+thread.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+thread.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+thread.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+thread.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+thread.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+thread.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+thread.$(OBJEXT): {$(VPATH)}internal/symbol.h
+thread.$(OBJEXT): {$(VPATH)}internal/value.h
+thread.$(OBJEXT): {$(VPATH)}internal/value_type.h
+thread.$(OBJEXT): {$(VPATH)}internal/variable.h
+thread.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+thread.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+thread.$(OBJEXT): {$(VPATH)}io.h
+thread.$(OBJEXT): {$(VPATH)}iseq.h
+thread.$(OBJEXT): {$(VPATH)}method.h
+thread.$(OBJEXT): {$(VPATH)}missing.h
+thread.$(OBJEXT): {$(VPATH)}node.h
+thread.$(OBJEXT): {$(VPATH)}onigmo.h
+thread.$(OBJEXT): {$(VPATH)}oniguruma.h
+thread.$(OBJEXT): {$(VPATH)}prism_compile.h
+thread.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+thread.$(OBJEXT): {$(VPATH)}ractor.h
+thread.$(OBJEXT): {$(VPATH)}ractor_core.h
+thread.$(OBJEXT): {$(VPATH)}ruby_assert.h
+thread.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+thread.$(OBJEXT): {$(VPATH)}rubyparser.h
+thread.$(OBJEXT): {$(VPATH)}shape.h
+thread.$(OBJEXT): {$(VPATH)}st.h
+thread.$(OBJEXT): {$(VPATH)}subst.h
+thread.$(OBJEXT): {$(VPATH)}thread.c
+thread.$(OBJEXT): {$(VPATH)}thread.h
+thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).c
+thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+thread.$(OBJEXT): {$(VPATH)}thread_native.h
+thread.$(OBJEXT): {$(VPATH)}thread_pthread_mn.c
+thread.$(OBJEXT): {$(VPATH)}thread_sync.c
+thread.$(OBJEXT): {$(VPATH)}thread_sync.rbinc
+thread.$(OBJEXT): {$(VPATH)}timev.h
+thread.$(OBJEXT): {$(VPATH)}vm_core.h
+thread.$(OBJEXT): {$(VPATH)}vm_debug.h
+thread.$(OBJEXT): {$(VPATH)}vm_opts.h
+thread.$(OBJEXT): {$(VPATH)}vm_sync.h
+thread.$(OBJEXT): {$(VPATH)}zjit.h
+time.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+time.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+time.$(OBJEXT): $(CCAN_DIR)/list/list.h
+time.$(OBJEXT): $(CCAN_DIR)/str/str.h
+time.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+time.$(OBJEXT): $(top_srcdir)/internal/array.h
+time.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+time.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+time.$(OBJEXT): $(top_srcdir)/internal/bits.h
+time.$(OBJEXT): $(top_srcdir)/internal/box.h
+time.$(OBJEXT): $(top_srcdir)/internal/compar.h
+time.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+time.$(OBJEXT): $(top_srcdir)/internal/error.h
+time.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+time.$(OBJEXT): $(top_srcdir)/internal/gc.h
+time.$(OBJEXT): $(top_srcdir)/internal/hash.h
+time.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+time.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+time.$(OBJEXT): $(top_srcdir)/internal/rational.h
+time.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+time.$(OBJEXT): $(top_srcdir)/internal/serial.h
+time.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+time.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+time.$(OBJEXT): $(top_srcdir)/internal/string.h
+time.$(OBJEXT): $(top_srcdir)/internal/struct.h
+time.$(OBJEXT): $(top_srcdir)/internal/time.h
+time.$(OBJEXT): $(top_srcdir)/internal/variable.h
+time.$(OBJEXT): $(top_srcdir)/internal/vm.h
+time.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+time.$(OBJEXT): {$(VPATH)}assert.h
+time.$(OBJEXT): {$(VPATH)}atomic.h
+time.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+time.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+time.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+time.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+time.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+time.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+time.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+time.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+time.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+time.$(OBJEXT): {$(VPATH)}builtin.h
+time.$(OBJEXT): {$(VPATH)}config.h
+time.$(OBJEXT): {$(VPATH)}constant.h
+time.$(OBJEXT): {$(VPATH)}defines.h
+time.$(OBJEXT): {$(VPATH)}encindex.h
+time.$(OBJEXT): {$(VPATH)}encoding.h
+time.$(OBJEXT): {$(VPATH)}id.h
+time.$(OBJEXT): {$(VPATH)}id_table.h
+time.$(OBJEXT): {$(VPATH)}intern.h
+time.$(OBJEXT): {$(VPATH)}internal.h
+time.$(OBJEXT): {$(VPATH)}internal/abi.h
+time.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+time.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+time.$(OBJEXT): {$(VPATH)}internal/assume.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+time.$(OBJEXT): {$(VPATH)}internal/cast.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+time.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+time.$(OBJEXT): {$(VPATH)}internal/config.h
+time.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+time.$(OBJEXT): {$(VPATH)}internal/core.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+time.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+time.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+time.$(OBJEXT): {$(VPATH)}internal/ctype.h
+time.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+time.$(OBJEXT): {$(VPATH)}internal/dosish.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+time.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+time.$(OBJEXT): {$(VPATH)}internal/error.h
+time.$(OBJEXT): {$(VPATH)}internal/eval.h
+time.$(OBJEXT): {$(VPATH)}internal/event.h
+time.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+time.$(OBJEXT): {$(VPATH)}internal/gc.h
+time.$(OBJEXT): {$(VPATH)}internal/glob.h
+time.$(OBJEXT): {$(VPATH)}internal/globals.h
+time.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+time.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+time.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+time.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+time.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+time.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+time.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+time.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+time.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+time.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+time.$(OBJEXT): {$(VPATH)}internal/iterator.h
+time.$(OBJEXT): {$(VPATH)}internal/memory.h
+time.$(OBJEXT): {$(VPATH)}internal/method.h
+time.$(OBJEXT): {$(VPATH)}internal/module.h
+time.$(OBJEXT): {$(VPATH)}internal/newobj.h
+time.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+time.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+time.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+time.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+time.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+time.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+time.$(OBJEXT): {$(VPATH)}internal/symbol.h
+time.$(OBJEXT): {$(VPATH)}internal/value.h
+time.$(OBJEXT): {$(VPATH)}internal/value_type.h
+time.$(OBJEXT): {$(VPATH)}internal/variable.h
+time.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+time.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+time.$(OBJEXT): {$(VPATH)}method.h
+time.$(OBJEXT): {$(VPATH)}missing.h
+time.$(OBJEXT): {$(VPATH)}node.h
+time.$(OBJEXT): {$(VPATH)}onigmo.h
+time.$(OBJEXT): {$(VPATH)}oniguruma.h
+time.$(OBJEXT): {$(VPATH)}ruby_assert.h
+time.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+time.$(OBJEXT): {$(VPATH)}rubyparser.h
+time.$(OBJEXT): {$(VPATH)}shape.h
+time.$(OBJEXT): {$(VPATH)}st.h
+time.$(OBJEXT): {$(VPATH)}subst.h
+time.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+time.$(OBJEXT): {$(VPATH)}thread_native.h
+time.$(OBJEXT): {$(VPATH)}time.c
+time.$(OBJEXT): {$(VPATH)}timev.h
+time.$(OBJEXT): {$(VPATH)}timev.rbinc
+time.$(OBJEXT): {$(VPATH)}util.h
+time.$(OBJEXT): {$(VPATH)}vm_core.h
+time.$(OBJEXT): {$(VPATH)}vm_opts.h
+transcode.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+transcode.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+transcode.$(OBJEXT): $(CCAN_DIR)/list/list.h
+transcode.$(OBJEXT): $(CCAN_DIR)/str/str.h
+transcode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/array.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/box.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/class.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/gc.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/inits.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/object.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/serial.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/string.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/transcode.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/variable.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/vm.h
+transcode.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+transcode.$(OBJEXT): {$(VPATH)}assert.h
+transcode.$(OBJEXT): {$(VPATH)}atomic.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+transcode.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+transcode.$(OBJEXT): {$(VPATH)}config.h
+transcode.$(OBJEXT): {$(VPATH)}constant.h
+transcode.$(OBJEXT): {$(VPATH)}debug_counter.h
+transcode.$(OBJEXT): {$(VPATH)}defines.h
+transcode.$(OBJEXT): {$(VPATH)}encindex.h
+transcode.$(OBJEXT): {$(VPATH)}encoding.h
+transcode.$(OBJEXT): {$(VPATH)}id.h
+transcode.$(OBJEXT): {$(VPATH)}id_table.h
+transcode.$(OBJEXT): {$(VPATH)}intern.h
+transcode.$(OBJEXT): {$(VPATH)}internal.h
+transcode.$(OBJEXT): {$(VPATH)}internal/abi.h
+transcode.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+transcode.$(OBJEXT): {$(VPATH)}internal/assume.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+transcode.$(OBJEXT): {$(VPATH)}internal/cast.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+transcode.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+transcode.$(OBJEXT): {$(VPATH)}internal/config.h
+transcode.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+transcode.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+transcode.$(OBJEXT): {$(VPATH)}internal/ctype.h
+transcode.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+transcode.$(OBJEXT): {$(VPATH)}internal/dosish.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+transcode.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+transcode.$(OBJEXT): {$(VPATH)}internal/error.h
+transcode.$(OBJEXT): {$(VPATH)}internal/eval.h
+transcode.$(OBJEXT): {$(VPATH)}internal/event.h
+transcode.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+transcode.$(OBJEXT): {$(VPATH)}internal/gc.h
+transcode.$(OBJEXT): {$(VPATH)}internal/glob.h
+transcode.$(OBJEXT): {$(VPATH)}internal/globals.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+transcode.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+transcode.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+transcode.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+transcode.$(OBJEXT): {$(VPATH)}internal/iterator.h
+transcode.$(OBJEXT): {$(VPATH)}internal/memory.h
+transcode.$(OBJEXT): {$(VPATH)}internal/method.h
+transcode.$(OBJEXT): {$(VPATH)}internal/module.h
+transcode.$(OBJEXT): {$(VPATH)}internal/newobj.h
+transcode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+transcode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+transcode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+transcode.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+transcode.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+transcode.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+transcode.$(OBJEXT): {$(VPATH)}internal/symbol.h
+transcode.$(OBJEXT): {$(VPATH)}internal/value.h
+transcode.$(OBJEXT): {$(VPATH)}internal/value_type.h
+transcode.$(OBJEXT): {$(VPATH)}internal/variable.h
+transcode.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+transcode.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+transcode.$(OBJEXT): {$(VPATH)}method.h
+transcode.$(OBJEXT): {$(VPATH)}missing.h
+transcode.$(OBJEXT): {$(VPATH)}node.h
+transcode.$(OBJEXT): {$(VPATH)}onigmo.h
+transcode.$(OBJEXT): {$(VPATH)}oniguruma.h
+transcode.$(OBJEXT): {$(VPATH)}ruby_assert.h
+transcode.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+transcode.$(OBJEXT): {$(VPATH)}rubyparser.h
+transcode.$(OBJEXT): {$(VPATH)}shape.h
+transcode.$(OBJEXT): {$(VPATH)}st.h
+transcode.$(OBJEXT): {$(VPATH)}subst.h
+transcode.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+transcode.$(OBJEXT): {$(VPATH)}thread_native.h
+transcode.$(OBJEXT): {$(VPATH)}transcode.c
+transcode.$(OBJEXT): {$(VPATH)}transcode_data.h
+transcode.$(OBJEXT): {$(VPATH)}vm_core.h
+transcode.$(OBJEXT): {$(VPATH)}vm_debug.h
+transcode.$(OBJEXT): {$(VPATH)}vm_opts.h
+transcode.$(OBJEXT): {$(VPATH)}vm_sync.h
+util.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+util.$(OBJEXT): $(top_srcdir)/internal/array.h
+util.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+util.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+util.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+util.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+util.$(OBJEXT): $(top_srcdir)/internal/util.h
+util.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+util.$(OBJEXT): {$(VPATH)}assert.h
+util.$(OBJEXT): {$(VPATH)}atomic.h
+util.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+util.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+util.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+util.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+util.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+util.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+util.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+util.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+util.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+util.$(OBJEXT): {$(VPATH)}config.h
+util.$(OBJEXT): {$(VPATH)}defines.h
+util.$(OBJEXT): {$(VPATH)}dtoa.c
+util.$(OBJEXT): {$(VPATH)}id_table.h
+util.$(OBJEXT): {$(VPATH)}intern.h
+util.$(OBJEXT): {$(VPATH)}internal.h
+util.$(OBJEXT): {$(VPATH)}internal/abi.h
+util.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+util.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+util.$(OBJEXT): {$(VPATH)}internal/assume.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+util.$(OBJEXT): {$(VPATH)}internal/cast.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+util.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+util.$(OBJEXT): {$(VPATH)}internal/config.h
+util.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+util.$(OBJEXT): {$(VPATH)}internal/core.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+util.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+util.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+util.$(OBJEXT): {$(VPATH)}internal/ctype.h
+util.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+util.$(OBJEXT): {$(VPATH)}internal/dosish.h
+util.$(OBJEXT): {$(VPATH)}internal/error.h
+util.$(OBJEXT): {$(VPATH)}internal/eval.h
+util.$(OBJEXT): {$(VPATH)}internal/event.h
+util.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+util.$(OBJEXT): {$(VPATH)}internal/gc.h
+util.$(OBJEXT): {$(VPATH)}internal/glob.h
+util.$(OBJEXT): {$(VPATH)}internal/globals.h
+util.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+util.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+util.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+util.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+util.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+util.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+util.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+util.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+util.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+util.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+util.$(OBJEXT): {$(VPATH)}internal/iterator.h
+util.$(OBJEXT): {$(VPATH)}internal/memory.h
+util.$(OBJEXT): {$(VPATH)}internal/method.h
+util.$(OBJEXT): {$(VPATH)}internal/module.h
+util.$(OBJEXT): {$(VPATH)}internal/newobj.h
+util.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+util.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+util.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+util.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+util.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+util.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+util.$(OBJEXT): {$(VPATH)}internal/symbol.h
+util.$(OBJEXT): {$(VPATH)}internal/value.h
+util.$(OBJEXT): {$(VPATH)}internal/value_type.h
+util.$(OBJEXT): {$(VPATH)}internal/variable.h
+util.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+util.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+util.$(OBJEXT): {$(VPATH)}missing.h
+util.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+util.$(OBJEXT): {$(VPATH)}st.h
+util.$(OBJEXT): {$(VPATH)}subst.h
+util.$(OBJEXT): {$(VPATH)}util.c
+util.$(OBJEXT): {$(VPATH)}util.h
+variable.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+variable.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+variable.$(OBJEXT): $(CCAN_DIR)/list/list.h
+variable.$(OBJEXT): $(CCAN_DIR)/str/str.h
+variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+variable.$(OBJEXT): $(hdrdir)/ruby/version.h
+variable.$(OBJEXT): $(top_srcdir)/internal/array.h
+variable.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+variable.$(OBJEXT): $(top_srcdir)/internal/box.h
+variable.$(OBJEXT): $(top_srcdir)/internal/class.h
+variable.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+variable.$(OBJEXT): $(top_srcdir)/internal/error.h
+variable.$(OBJEXT): $(top_srcdir)/internal/eval.h
+variable.$(OBJEXT): $(top_srcdir)/internal/gc.h
+variable.$(OBJEXT): $(top_srcdir)/internal/hash.h
+variable.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+variable.$(OBJEXT): $(top_srcdir)/internal/object.h
+variable.$(OBJEXT): $(top_srcdir)/internal/re.h
+variable.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+variable.$(OBJEXT): $(top_srcdir)/internal/serial.h
+variable.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+variable.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+variable.$(OBJEXT): $(top_srcdir)/internal/string.h
+variable.$(OBJEXT): $(top_srcdir)/internal/struct.h
+variable.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+variable.$(OBJEXT): $(top_srcdir)/internal/thread.h
+variable.$(OBJEXT): $(top_srcdir)/internal/variable.h
+variable.$(OBJEXT): $(top_srcdir)/internal/vm.h
+variable.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+variable.$(OBJEXT): {$(VPATH)}assert.h
+variable.$(OBJEXT): {$(VPATH)}atomic.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+variable.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+variable.$(OBJEXT): {$(VPATH)}config.h
+variable.$(OBJEXT): {$(VPATH)}constant.h
+variable.$(OBJEXT): {$(VPATH)}debug_counter.h
+variable.$(OBJEXT): {$(VPATH)}defines.h
+variable.$(OBJEXT): {$(VPATH)}encindex.h
+variable.$(OBJEXT): {$(VPATH)}encoding.h
+variable.$(OBJEXT): {$(VPATH)}id.h
+variable.$(OBJEXT): {$(VPATH)}id_table.h
+variable.$(OBJEXT): {$(VPATH)}intern.h
+variable.$(OBJEXT): {$(VPATH)}internal.h
+variable.$(OBJEXT): {$(VPATH)}internal/abi.h
+variable.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+variable.$(OBJEXT): {$(VPATH)}internal/assume.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+variable.$(OBJEXT): {$(VPATH)}internal/cast.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+variable.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+variable.$(OBJEXT): {$(VPATH)}internal/config.h
+variable.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+variable.$(OBJEXT): {$(VPATH)}internal/core.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+variable.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+variable.$(OBJEXT): {$(VPATH)}internal/ctype.h
+variable.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+variable.$(OBJEXT): {$(VPATH)}internal/dosish.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+variable.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+variable.$(OBJEXT): {$(VPATH)}internal/error.h
+variable.$(OBJEXT): {$(VPATH)}internal/eval.h
+variable.$(OBJEXT): {$(VPATH)}internal/event.h
+variable.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+variable.$(OBJEXT): {$(VPATH)}internal/gc.h
+variable.$(OBJEXT): {$(VPATH)}internal/glob.h
+variable.$(OBJEXT): {$(VPATH)}internal/globals.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+variable.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+variable.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+variable.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+variable.$(OBJEXT): {$(VPATH)}internal/iterator.h
+variable.$(OBJEXT): {$(VPATH)}internal/memory.h
+variable.$(OBJEXT): {$(VPATH)}internal/method.h
+variable.$(OBJEXT): {$(VPATH)}internal/module.h
+variable.$(OBJEXT): {$(VPATH)}internal/newobj.h
+variable.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+variable.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+variable.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+variable.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+variable.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+variable.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+variable.$(OBJEXT): {$(VPATH)}internal/symbol.h
+variable.$(OBJEXT): {$(VPATH)}internal/value.h
+variable.$(OBJEXT): {$(VPATH)}internal/value_type.h
+variable.$(OBJEXT): {$(VPATH)}internal/variable.h
+variable.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+variable.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+variable.$(OBJEXT): {$(VPATH)}method.h
+variable.$(OBJEXT): {$(VPATH)}missing.h
+variable.$(OBJEXT): {$(VPATH)}node.h
+variable.$(OBJEXT): {$(VPATH)}onigmo.h
+variable.$(OBJEXT): {$(VPATH)}oniguruma.h
+variable.$(OBJEXT): {$(VPATH)}ractor.h
+variable.$(OBJEXT): {$(VPATH)}ractor_core.h
+variable.$(OBJEXT): {$(VPATH)}re.h
+variable.$(OBJEXT): {$(VPATH)}regex.h
+variable.$(OBJEXT): {$(VPATH)}ruby_assert.h
+variable.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+variable.$(OBJEXT): {$(VPATH)}rubyparser.h
+variable.$(OBJEXT): {$(VPATH)}shape.h
+variable.$(OBJEXT): {$(VPATH)}st.h
+variable.$(OBJEXT): {$(VPATH)}subst.h
+variable.$(OBJEXT): {$(VPATH)}symbol.h
+variable.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+variable.$(OBJEXT): {$(VPATH)}thread_native.h
+variable.$(OBJEXT): {$(VPATH)}util.h
+variable.$(OBJEXT): {$(VPATH)}variable.c
+variable.$(OBJEXT): {$(VPATH)}variable.h
+variable.$(OBJEXT): {$(VPATH)}vm_core.h
+variable.$(OBJEXT): {$(VPATH)}vm_debug.h
+variable.$(OBJEXT): {$(VPATH)}vm_opts.h
+variable.$(OBJEXT): {$(VPATH)}vm_sync.h
+version.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+version.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+version.$(OBJEXT): $(CCAN_DIR)/list/list.h
+version.$(OBJEXT): $(CCAN_DIR)/str/str.h
+version.$(OBJEXT): $(hdrdir)/ruby.h
+version.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+version.$(OBJEXT): $(hdrdir)/ruby/version.h
+version.$(OBJEXT): $(top_srcdir)/internal/array.h
+version.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+version.$(OBJEXT): $(top_srcdir)/internal/box.h
+version.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
+version.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+version.$(OBJEXT): $(top_srcdir)/internal/gc.h
+version.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+version.$(OBJEXT): $(top_srcdir)/internal/parse.h
+version.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+version.$(OBJEXT): $(top_srcdir)/internal/serial.h
+version.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+version.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+version.$(OBJEXT): $(top_srcdir)/internal/variable.h
+version.$(OBJEXT): $(top_srcdir)/internal/vm.h
+version.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+version.$(OBJEXT): $(top_srcdir)/version.h
+version.$(OBJEXT): {$(VPATH)}assert.h
+version.$(OBJEXT): {$(VPATH)}atomic.h
+version.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+version.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+version.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+version.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+version.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+version.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+version.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+version.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+version.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+version.$(OBJEXT): {$(VPATH)}config.h
+version.$(OBJEXT): {$(VPATH)}constant.h
+version.$(OBJEXT): {$(VPATH)}debug_counter.h
+version.$(OBJEXT): {$(VPATH)}defines.h
+version.$(OBJEXT): {$(VPATH)}encoding.h
+version.$(OBJEXT): {$(VPATH)}id.h
+version.$(OBJEXT): {$(VPATH)}id_table.h
+version.$(OBJEXT): {$(VPATH)}intern.h
+version.$(OBJEXT): {$(VPATH)}internal.h
+version.$(OBJEXT): {$(VPATH)}internal/abi.h
+version.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+version.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+version.$(OBJEXT): {$(VPATH)}internal/assume.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+version.$(OBJEXT): {$(VPATH)}internal/cast.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+version.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+version.$(OBJEXT): {$(VPATH)}internal/config.h
+version.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+version.$(OBJEXT): {$(VPATH)}internal/core.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+version.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+version.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+version.$(OBJEXT): {$(VPATH)}internal/ctype.h
+version.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+version.$(OBJEXT): {$(VPATH)}internal/dosish.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+version.$(OBJEXT): {$(VPATH)}internal/error.h
+version.$(OBJEXT): {$(VPATH)}internal/eval.h
+version.$(OBJEXT): {$(VPATH)}internal/event.h
+version.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+version.$(OBJEXT): {$(VPATH)}internal/gc.h
+version.$(OBJEXT): {$(VPATH)}internal/glob.h
+version.$(OBJEXT): {$(VPATH)}internal/globals.h
+version.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+version.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+version.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+version.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+version.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+version.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+version.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+version.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+version.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+version.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+version.$(OBJEXT): {$(VPATH)}internal/iterator.h
+version.$(OBJEXT): {$(VPATH)}internal/memory.h
+version.$(OBJEXT): {$(VPATH)}internal/method.h
+version.$(OBJEXT): {$(VPATH)}internal/module.h
+version.$(OBJEXT): {$(VPATH)}internal/newobj.h
+version.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+version.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+version.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+version.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+version.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+version.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+version.$(OBJEXT): {$(VPATH)}internal/symbol.h
+version.$(OBJEXT): {$(VPATH)}internal/value.h
+version.$(OBJEXT): {$(VPATH)}internal/value_type.h
+version.$(OBJEXT): {$(VPATH)}internal/variable.h
+version.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+version.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+version.$(OBJEXT): {$(VPATH)}method.h
+version.$(OBJEXT): {$(VPATH)}missing.h
+version.$(OBJEXT): {$(VPATH)}node.h
+version.$(OBJEXT): {$(VPATH)}onigmo.h
+version.$(OBJEXT): {$(VPATH)}oniguruma.h
+version.$(OBJEXT): {$(VPATH)}revision.h
+version.$(OBJEXT): {$(VPATH)}ruby_assert.h
+version.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+version.$(OBJEXT): {$(VPATH)}rubyparser.h
+version.$(OBJEXT): {$(VPATH)}shape.h
+version.$(OBJEXT): {$(VPATH)}st.h
+version.$(OBJEXT): {$(VPATH)}subst.h
+version.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+version.$(OBJEXT): {$(VPATH)}thread_native.h
+version.$(OBJEXT): {$(VPATH)}version.c
+version.$(OBJEXT): {$(VPATH)}vm_core.h
+version.$(OBJEXT): {$(VPATH)}vm_opts.h
+version.$(OBJEXT): {$(VPATH)}yjit.h
+vm.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+vm.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+vm.$(OBJEXT): $(CCAN_DIR)/list/list.h
+vm.$(OBJEXT): $(CCAN_DIR)/str/str.h
+vm.$(OBJEXT): $(hdrdir)/ruby.h
+vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm.$(OBJEXT): $(hdrdir)/ruby/version.h
+vm.$(OBJEXT): $(top_srcdir)/internal/array.h
+vm.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+vm.$(OBJEXT): $(top_srcdir)/internal/bits.h
+vm.$(OBJEXT): $(top_srcdir)/internal/box.h
+vm.$(OBJEXT): $(top_srcdir)/internal/class.h
+vm.$(OBJEXT): $(top_srcdir)/internal/compar.h
+vm.$(OBJEXT): $(top_srcdir)/internal/compile.h
+vm.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+vm.$(OBJEXT): $(top_srcdir)/internal/complex.h
+vm.$(OBJEXT): $(top_srcdir)/internal/cont.h
+vm.$(OBJEXT): $(top_srcdir)/internal/encoding.h
+vm.$(OBJEXT): $(top_srcdir)/internal/error.h
+vm.$(OBJEXT): $(top_srcdir)/internal/eval.h
+vm.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+vm.$(OBJEXT): $(top_srcdir)/internal/gc.h
+vm.$(OBJEXT): $(top_srcdir)/internal/hash.h
+vm.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+vm.$(OBJEXT): $(top_srcdir)/internal/inits.h
+vm.$(OBJEXT): $(top_srcdir)/internal/missing.h
+vm.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+vm.$(OBJEXT): $(top_srcdir)/internal/object.h
+vm.$(OBJEXT): $(top_srcdir)/internal/parse.h
+vm.$(OBJEXT): $(top_srcdir)/internal/proc.h
+vm.$(OBJEXT): $(top_srcdir)/internal/random.h
+vm.$(OBJEXT): $(top_srcdir)/internal/rational.h
+vm.$(OBJEXT): $(top_srcdir)/internal/re.h
+vm.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
+vm.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+vm.$(OBJEXT): $(top_srcdir)/internal/serial.h
+vm.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+vm.$(OBJEXT): $(top_srcdir)/internal/st.h
+vm.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm.$(OBJEXT): $(top_srcdir)/internal/string.h
+vm.$(OBJEXT): $(top_srcdir)/internal/struct.h
+vm.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+vm.$(OBJEXT): $(top_srcdir)/internal/thread.h
+vm.$(OBJEXT): $(top_srcdir)/internal/transcode.h
+vm.$(OBJEXT): $(top_srcdir)/internal/variable.h
+vm.$(OBJEXT): $(top_srcdir)/internal/vm.h
+vm.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm.$(OBJEXT): $(top_srcdir)/prism/arena.h
+vm.$(OBJEXT): $(top_srcdir)/prism/ast.h
+vm.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+vm.$(OBJEXT): $(top_srcdir)/prism/comments.h
+vm.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+vm.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+vm.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+vm.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+vm.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+vm.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+vm.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+vm.$(OBJEXT): $(top_srcdir)/prism/integer.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+vm.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+vm.$(OBJEXT): $(top_srcdir)/prism/json.h
+vm.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+vm.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+vm.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+vm.$(OBJEXT): $(top_srcdir)/prism/source.h
+vm.$(OBJEXT): $(top_srcdir)/prism/stream.h
+vm.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+vm.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+vm.$(OBJEXT): $(top_srcdir)/prism/version.h
+vm.$(OBJEXT): {$(VPATH)}assert.h
+vm.$(OBJEXT): {$(VPATH)}atomic.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+vm.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+vm.$(OBJEXT): {$(VPATH)}builtin.h
+vm.$(OBJEXT): {$(VPATH)}config.h
+vm.$(OBJEXT): {$(VPATH)}constant.h
+vm.$(OBJEXT): {$(VPATH)}debug_counter.h
+vm.$(OBJEXT): {$(VPATH)}defines.h
+vm.$(OBJEXT): {$(VPATH)}defs/opt_operand.def
+vm.$(OBJEXT): {$(VPATH)}encindex.h
+vm.$(OBJEXT): {$(VPATH)}encoding.h
+vm.$(OBJEXT): {$(VPATH)}eval_intern.h
+vm.$(OBJEXT): {$(VPATH)}id.h
+vm.$(OBJEXT): {$(VPATH)}id_table.h
+vm.$(OBJEXT): {$(VPATH)}insns.def
+vm.$(OBJEXT): {$(VPATH)}insns.inc
+vm.$(OBJEXT): {$(VPATH)}insns_info.inc
+vm.$(OBJEXT): {$(VPATH)}intern.h
+vm.$(OBJEXT): {$(VPATH)}internal.h
+vm.$(OBJEXT): {$(VPATH)}internal/abi.h
+vm.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+vm.$(OBJEXT): {$(VPATH)}internal/assume.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+vm.$(OBJEXT): {$(VPATH)}internal/cast.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+vm.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+vm.$(OBJEXT): {$(VPATH)}internal/config.h
+vm.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+vm.$(OBJEXT): {$(VPATH)}internal/core.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rmatch.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+vm.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+vm.$(OBJEXT): {$(VPATH)}internal/ctype.h
+vm.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+vm.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+vm.$(OBJEXT): {$(VPATH)}internal/error.h
+vm.$(OBJEXT): {$(VPATH)}internal/eval.h
+vm.$(OBJEXT): {$(VPATH)}internal/event.h
+vm.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+vm.$(OBJEXT): {$(VPATH)}internal/gc.h
+vm.$(OBJEXT): {$(VPATH)}internal/glob.h
+vm.$(OBJEXT): {$(VPATH)}internal/globals.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+vm.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+vm.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+vm.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+vm.$(OBJEXT): {$(VPATH)}internal/iterator.h
+vm.$(OBJEXT): {$(VPATH)}internal/memory.h
+vm.$(OBJEXT): {$(VPATH)}internal/method.h
+vm.$(OBJEXT): {$(VPATH)}internal/module.h
+vm.$(OBJEXT): {$(VPATH)}internal/newobj.h
+vm.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+vm.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+vm.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+vm.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+vm.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+vm.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+vm.$(OBJEXT): {$(VPATH)}internal/symbol.h
+vm.$(OBJEXT): {$(VPATH)}internal/value.h
+vm.$(OBJEXT): {$(VPATH)}internal/value_type.h
+vm.$(OBJEXT): {$(VPATH)}internal/variable.h
+vm.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+vm.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+vm.$(OBJEXT): {$(VPATH)}iseq.h
+vm.$(OBJEXT): {$(VPATH)}jit_hook.rbinc
+vm.$(OBJEXT): {$(VPATH)}jit_undef.rbinc
+vm.$(OBJEXT): {$(VPATH)}method.h
+vm.$(OBJEXT): {$(VPATH)}missing.h
+vm.$(OBJEXT): {$(VPATH)}node.h
+vm.$(OBJEXT): {$(VPATH)}onigmo.h
+vm.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm.$(OBJEXT): {$(VPATH)}prism_compile.h
+vm.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+vm.$(OBJEXT): {$(VPATH)}probes.dmyh
+vm.$(OBJEXT): {$(VPATH)}probes.h
+vm.$(OBJEXT): {$(VPATH)}probes_helper.h
+vm.$(OBJEXT): {$(VPATH)}ractor.h
+vm.$(OBJEXT): {$(VPATH)}ractor_core.h
+vm.$(OBJEXT): {$(VPATH)}re.h
+vm.$(OBJEXT): {$(VPATH)}regex.h
+vm.$(OBJEXT): {$(VPATH)}ruby_assert.h
+vm.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm.$(OBJEXT): {$(VPATH)}rubyparser.h
+vm.$(OBJEXT): {$(VPATH)}shape.h
+vm.$(OBJEXT): {$(VPATH)}st.h
+vm.$(OBJEXT): {$(VPATH)}subst.h
+vm.$(OBJEXT): {$(VPATH)}symbol.h
+vm.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+vm.$(OBJEXT): {$(VPATH)}thread_native.h
+vm.$(OBJEXT): {$(VPATH)}variable.h
+vm.$(OBJEXT): {$(VPATH)}vm.c
+vm.$(OBJEXT): {$(VPATH)}vm.h
+vm.$(OBJEXT): {$(VPATH)}vm.inc
+vm.$(OBJEXT): {$(VPATH)}vm_args.c
+vm.$(OBJEXT): {$(VPATH)}vm_call_iseq_optimized.inc
+vm.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+vm.$(OBJEXT): {$(VPATH)}vm_core.h
+vm.$(OBJEXT): {$(VPATH)}vm_debug.h
+vm.$(OBJEXT): {$(VPATH)}vm_eval.c
+vm.$(OBJEXT): {$(VPATH)}vm_exec.c
+vm.$(OBJEXT): {$(VPATH)}vm_exec.h
+vm.$(OBJEXT): {$(VPATH)}vm_insnhelper.c
+vm.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
+vm.$(OBJEXT): {$(VPATH)}vm_method.c
+vm.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm.$(OBJEXT): {$(VPATH)}vm_sync.h
+vm.$(OBJEXT): {$(VPATH)}vmtc.inc
+vm.$(OBJEXT): {$(VPATH)}yjit.h
+vm.$(OBJEXT): {$(VPATH)}zjit.h
+vm_backtrace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+vm_backtrace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h
+vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h
+vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/version.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/array.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/box.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/class.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/error.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/gc.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/object.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/serial.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/string.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/struct.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/variable.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/vm.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/arena.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/ast.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/comments.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/integer.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/json.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/source.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/stream.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/version.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}atomic.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}config.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}constant.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}debug_counter.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}encindex.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}encoding.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}eval_intern.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}id.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}id_table.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}intern.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/abi.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/assume.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/cast.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/config.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/ctype.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/error.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/eval.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/event.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/gc.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/glob.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/globals.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/iterator.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/memory.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/method.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/module.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/newobj.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/symbol.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/value.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/value_type.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/variable.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}iseq.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}method.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}missing.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}node.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}prism_compile.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_assert.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}rubyparser.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}shape.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}st.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}subst.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+vm_backtrace.$(OBJEXT): {$(VPATH)}thread_native.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_backtrace.c
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_debug.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_sync.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}zjit.h
+vm_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+vm_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+vm_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
+vm_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h
+vm_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/array.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/box.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/gc.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/serial.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/struct.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/variable.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
+vm_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/arena.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/ast.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/comments.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/integer.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/json.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/source.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/stream.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/version.h
+vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h
+vm_dump.$(OBJEXT): {$(VPATH)}assert.h
+vm_dump.$(OBJEXT): {$(VPATH)}atomic.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+vm_dump.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+vm_dump.$(OBJEXT): {$(VPATH)}config.h
+vm_dump.$(OBJEXT): {$(VPATH)}constant.h
+vm_dump.$(OBJEXT): {$(VPATH)}defines.h
+vm_dump.$(OBJEXT): {$(VPATH)}encoding.h
+vm_dump.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
+vm_dump.$(OBJEXT): {$(VPATH)}id.h
+vm_dump.$(OBJEXT): {$(VPATH)}id_table.h
+vm_dump.$(OBJEXT): {$(VPATH)}intern.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/abi.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/assume.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/cast.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/config.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/ctype.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/error.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/eval.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/event.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/gc.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/glob.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/globals.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/iterator.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/memory.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/method.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/module.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/newobj.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/symbol.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/value.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/value_type.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/variable.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+vm_dump.$(OBJEXT): {$(VPATH)}iseq.h
+vm_dump.$(OBJEXT): {$(VPATH)}method.h
+vm_dump.$(OBJEXT): {$(VPATH)}missing.h
+vm_dump.$(OBJEXT): {$(VPATH)}node.h
+vm_dump.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_dump.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_dump.$(OBJEXT): {$(VPATH)}prism_compile.h
+vm_dump.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+vm_dump.$(OBJEXT): {$(VPATH)}procstat_vm.c
+vm_dump.$(OBJEXT): {$(VPATH)}ractor.h
+vm_dump.$(OBJEXT): {$(VPATH)}ractor_core.h
+vm_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
+vm_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_dump.$(OBJEXT): {$(VPATH)}rubyparser.h
+vm_dump.$(OBJEXT): {$(VPATH)}shape.h
+vm_dump.$(OBJEXT): {$(VPATH)}st.h
+vm_dump.$(OBJEXT): {$(VPATH)}subst.h
+vm_dump.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+vm_dump.$(OBJEXT): {$(VPATH)}thread_native.h
+vm_dump.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_dump.$(OBJEXT): {$(VPATH)}vm_debug.h
+vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c
+vm_dump.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_dump.$(OBJEXT): {$(VPATH)}zjit.h
+vm_sync.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+vm_sync.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+vm_sync.$(OBJEXT): $(CCAN_DIR)/list/list.h
+vm_sync.$(OBJEXT): $(CCAN_DIR)/str/str.h
+vm_sync.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/array.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/box.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/gc.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/serial.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/thread.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/variable.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/vm.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_sync.$(OBJEXT): {$(VPATH)}assert.h
+vm_sync.$(OBJEXT): {$(VPATH)}atomic.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+vm_sync.$(OBJEXT): {$(VPATH)}config.h
+vm_sync.$(OBJEXT): {$(VPATH)}constant.h
+vm_sync.$(OBJEXT): {$(VPATH)}debug_counter.h
+vm_sync.$(OBJEXT): {$(VPATH)}defines.h
+vm_sync.$(OBJEXT): {$(VPATH)}encoding.h
+vm_sync.$(OBJEXT): {$(VPATH)}id.h
+vm_sync.$(OBJEXT): {$(VPATH)}id_table.h
+vm_sync.$(OBJEXT): {$(VPATH)}intern.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/abi.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/assume.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/cast.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/config.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/ctype.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/error.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/eval.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/event.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/gc.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/glob.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/globals.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/iterator.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/memory.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/method.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/module.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/newobj.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/symbol.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/value.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/value_type.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/variable.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+vm_sync.$(OBJEXT): {$(VPATH)}method.h
+vm_sync.$(OBJEXT): {$(VPATH)}missing.h
+vm_sync.$(OBJEXT): {$(VPATH)}node.h
+vm_sync.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_sync.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_sync.$(OBJEXT): {$(VPATH)}ractor.h
+vm_sync.$(OBJEXT): {$(VPATH)}ractor_core.h
+vm_sync.$(OBJEXT): {$(VPATH)}ruby_assert.h
+vm_sync.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_sync.$(OBJEXT): {$(VPATH)}rubyparser.h
+vm_sync.$(OBJEXT): {$(VPATH)}shape.h
+vm_sync.$(OBJEXT): {$(VPATH)}st.h
+vm_sync.$(OBJEXT): {$(VPATH)}subst.h
+vm_sync.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+vm_sync.$(OBJEXT): {$(VPATH)}thread_native.h
+vm_sync.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_sync.$(OBJEXT): {$(VPATH)}vm_debug.h
+vm_sync.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_sync.$(OBJEXT): {$(VPATH)}vm_sync.c
+vm_sync.$(OBJEXT): {$(VPATH)}vm_sync.h
+vm_trace.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+vm_trace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+vm_trace.$(OBJEXT): $(CCAN_DIR)/list/list.h
+vm_trace.$(OBJEXT): $(CCAN_DIR)/str/str.h
+vm_trace.$(OBJEXT): $(hdrdir)/ruby.h
+vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/array.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/bits.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/box.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/class.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/gc.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/hash.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/serial.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/struct.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/thread.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/variable.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/vm.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/arena.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/ast.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/comments.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/integer.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/json.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/source.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/stream.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/version.h
+vm_trace.$(OBJEXT): {$(VPATH)}assert.h
+vm_trace.$(OBJEXT): {$(VPATH)}atomic.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+vm_trace.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+vm_trace.$(OBJEXT): {$(VPATH)}builtin.h
+vm_trace.$(OBJEXT): {$(VPATH)}config.h
+vm_trace.$(OBJEXT): {$(VPATH)}constant.h
+vm_trace.$(OBJEXT): {$(VPATH)}debug.h
+vm_trace.$(OBJEXT): {$(VPATH)}debug_counter.h
+vm_trace.$(OBJEXT): {$(VPATH)}defines.h
+vm_trace.$(OBJEXT): {$(VPATH)}encoding.h
+vm_trace.$(OBJEXT): {$(VPATH)}eval_intern.h
+vm_trace.$(OBJEXT): {$(VPATH)}id.h
+vm_trace.$(OBJEXT): {$(VPATH)}id_table.h
+vm_trace.$(OBJEXT): {$(VPATH)}intern.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/abi.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/assume.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/cast.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/config.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/ctype.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/error.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/eval.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/event.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/gc.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/glob.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/globals.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/iterator.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/memory.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/method.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/module.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/newobj.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/symbol.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/value.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/value_type.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/variable.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+vm_trace.$(OBJEXT): {$(VPATH)}iseq.h
+vm_trace.$(OBJEXT): {$(VPATH)}method.h
+vm_trace.$(OBJEXT): {$(VPATH)}missing.h
+vm_trace.$(OBJEXT): {$(VPATH)}node.h
+vm_trace.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_trace.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_trace.$(OBJEXT): {$(VPATH)}prism_compile.h
+vm_trace.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+vm_trace.$(OBJEXT): {$(VPATH)}ractor.h
+vm_trace.$(OBJEXT): {$(VPATH)}ractor_core.h
+vm_trace.$(OBJEXT): {$(VPATH)}ruby_assert.h
+vm_trace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_trace.$(OBJEXT): {$(VPATH)}rubyparser.h
+vm_trace.$(OBJEXT): {$(VPATH)}shape.h
+vm_trace.$(OBJEXT): {$(VPATH)}st.h
+vm_trace.$(OBJEXT): {$(VPATH)}subst.h
+vm_trace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+vm_trace.$(OBJEXT): {$(VPATH)}thread_native.h
+vm_trace.$(OBJEXT): {$(VPATH)}trace_point.rbinc
+vm_trace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_debug.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_sync.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_trace.c
+vm_trace.$(OBJEXT): {$(VPATH)}yjit.h
+vm_trace.$(OBJEXT): {$(VPATH)}zjit.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/list/list.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/str/str.h
+weakmap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/array.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/box.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/gc.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/hash.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/proc.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/serial.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/vm.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+weakmap.$(OBJEXT): {$(VPATH)}assert.h
+weakmap.$(OBJEXT): {$(VPATH)}atomic.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+weakmap.$(OBJEXT): {$(VPATH)}config.h
+weakmap.$(OBJEXT): {$(VPATH)}defines.h
+weakmap.$(OBJEXT): {$(VPATH)}encoding.h
+weakmap.$(OBJEXT): {$(VPATH)}id.h
+weakmap.$(OBJEXT): {$(VPATH)}id_table.h
+weakmap.$(OBJEXT): {$(VPATH)}intern.h
+weakmap.$(OBJEXT): {$(VPATH)}internal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/abi.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/assume.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/cast.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/config.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/ctype.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/dosish.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/eval.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/event.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/gc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/glob.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/globals.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/iterator.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/memory.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/method.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/module.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/newobj.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/symbol.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/value.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/value_type.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/variable.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+weakmap.$(OBJEXT): {$(VPATH)}method.h
+weakmap.$(OBJEXT): {$(VPATH)}missing.h
+weakmap.$(OBJEXT): {$(VPATH)}node.h
+weakmap.$(OBJEXT): {$(VPATH)}onigmo.h
+weakmap.$(OBJEXT): {$(VPATH)}oniguruma.h
+weakmap.$(OBJEXT): {$(VPATH)}ruby_assert.h
+weakmap.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+weakmap.$(OBJEXT): {$(VPATH)}rubyparser.h
+weakmap.$(OBJEXT): {$(VPATH)}st.h
+weakmap.$(OBJEXT): {$(VPATH)}subst.h
+weakmap.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+weakmap.$(OBJEXT): {$(VPATH)}thread_native.h
+weakmap.$(OBJEXT): {$(VPATH)}vm_core.h
+weakmap.$(OBJEXT): {$(VPATH)}vm_opts.h
+weakmap.$(OBJEXT): {$(VPATH)}weakmap.c
+yjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+yjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+yjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
+yjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
+yjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/array.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/bits.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/box.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/class.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/compar.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/string.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/struct.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/arena.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/ast.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/comments.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/integer.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/json.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/node.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/options.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/source.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/stream.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/version.h
+yjit.$(OBJEXT): {$(VPATH)}assert.h
+yjit.$(OBJEXT): {$(VPATH)}atomic.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+yjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+yjit.$(OBJEXT): {$(VPATH)}builtin.h
+yjit.$(OBJEXT): {$(VPATH)}config.h
+yjit.$(OBJEXT): {$(VPATH)}constant.h
+yjit.$(OBJEXT): {$(VPATH)}debug.h
+yjit.$(OBJEXT): {$(VPATH)}debug_counter.h
+yjit.$(OBJEXT): {$(VPATH)}defines.h
+yjit.$(OBJEXT): {$(VPATH)}encindex.h
+yjit.$(OBJEXT): {$(VPATH)}encoding.h
+yjit.$(OBJEXT): {$(VPATH)}id.h
+yjit.$(OBJEXT): {$(VPATH)}id_table.h
+yjit.$(OBJEXT): {$(VPATH)}insns.def
+yjit.$(OBJEXT): {$(VPATH)}insns.inc
+yjit.$(OBJEXT): {$(VPATH)}insns_info.inc
+yjit.$(OBJEXT): {$(VPATH)}intern.h
+yjit.$(OBJEXT): {$(VPATH)}internal.h
+yjit.$(OBJEXT): {$(VPATH)}internal/abi.h
+yjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+yjit.$(OBJEXT): {$(VPATH)}internal/assume.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+yjit.$(OBJEXT): {$(VPATH)}internal/cast.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+yjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+yjit.$(OBJEXT): {$(VPATH)}internal/config.h
+yjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+yjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+yjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+yjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+yjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+yjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+yjit.$(OBJEXT): {$(VPATH)}internal/error.h
+yjit.$(OBJEXT): {$(VPATH)}internal/eval.h
+yjit.$(OBJEXT): {$(VPATH)}internal/event.h
+yjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+yjit.$(OBJEXT): {$(VPATH)}internal/gc.h
+yjit.$(OBJEXT): {$(VPATH)}internal/glob.h
+yjit.$(OBJEXT): {$(VPATH)}internal/globals.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+yjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+yjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+yjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+yjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+yjit.$(OBJEXT): {$(VPATH)}internal/memory.h
+yjit.$(OBJEXT): {$(VPATH)}internal/method.h
+yjit.$(OBJEXT): {$(VPATH)}internal/module.h
+yjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+yjit.$(OBJEXT): {$(VPATH)}internal/numeric.h
+yjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+yjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+yjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+yjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+yjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+yjit.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+yjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+yjit.$(OBJEXT): {$(VPATH)}internal/value.h
+yjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+yjit.$(OBJEXT): {$(VPATH)}internal/variable.h
+yjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+yjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+yjit.$(OBJEXT): {$(VPATH)}iseq.h
+yjit.$(OBJEXT): {$(VPATH)}method.h
+yjit.$(OBJEXT): {$(VPATH)}missing.h
+yjit.$(OBJEXT): {$(VPATH)}node.h
+yjit.$(OBJEXT): {$(VPATH)}onigmo.h
+yjit.$(OBJEXT): {$(VPATH)}oniguruma.h
+yjit.$(OBJEXT): {$(VPATH)}prism_compile.h
+yjit.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+yjit.$(OBJEXT): {$(VPATH)}probes.dmyh
+yjit.$(OBJEXT): {$(VPATH)}probes.h
+yjit.$(OBJEXT): {$(VPATH)}probes_helper.h
+yjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
+yjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+yjit.$(OBJEXT): {$(VPATH)}rubyparser.h
+yjit.$(OBJEXT): {$(VPATH)}shape.h
+yjit.$(OBJEXT): {$(VPATH)}st.h
+yjit.$(OBJEXT): {$(VPATH)}subst.h
+yjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+yjit.$(OBJEXT): {$(VPATH)}thread_native.h
+yjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+yjit.$(OBJEXT): {$(VPATH)}vm_core.h
+yjit.$(OBJEXT): {$(VPATH)}vm_debug.h
+yjit.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
+yjit.$(OBJEXT): {$(VPATH)}vm_opts.h
+yjit.$(OBJEXT): {$(VPATH)}vm_sync.h
+yjit.$(OBJEXT): {$(VPATH)}yjit.c
+yjit.$(OBJEXT): {$(VPATH)}yjit.h
+yjit.$(OBJEXT): {$(VPATH)}yjit.rbinc
+yjit.$(OBJEXT): {$(VPATH)}zjit.h
+zjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+zjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+zjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
+zjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
+zjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/array.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/bits.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/box.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/class.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/compar.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/numeric.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/set_table.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/string.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/struct.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
+zjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/arena.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/ast.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/buffer.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/comments.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/compiler/align.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/compiler/exported.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/compiler/filesystem.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/compiler/nodiscard.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/compiler/nonnull.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/constant_pool.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/excludes.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/integer.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/char.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/encoding.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/list.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/memchr.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/regexp.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/static_literals.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/strncasecmp.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/internal/strpbrk.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/json.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/line_offset_list.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/magic_comments.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/node.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/options.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/serialize.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/source.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/stream.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/string_query.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/stringy.h
+zjit.$(OBJEXT): $(top_srcdir)/prism/version.h
+zjit.$(OBJEXT): {$(VPATH)}assert.h
+zjit.$(OBJEXT): {$(VPATH)}atomic.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+zjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+zjit.$(OBJEXT): {$(VPATH)}builtin.h
+zjit.$(OBJEXT): {$(VPATH)}config.h
+zjit.$(OBJEXT): {$(VPATH)}constant.h
+zjit.$(OBJEXT): {$(VPATH)}debug.h
+zjit.$(OBJEXT): {$(VPATH)}debug_counter.h
+zjit.$(OBJEXT): {$(VPATH)}defines.h
+zjit.$(OBJEXT): {$(VPATH)}encindex.h
+zjit.$(OBJEXT): {$(VPATH)}encoding.h
+zjit.$(OBJEXT): {$(VPATH)}id.h
+zjit.$(OBJEXT): {$(VPATH)}id_table.h
+zjit.$(OBJEXT): {$(VPATH)}insns.def
+zjit.$(OBJEXT): {$(VPATH)}insns.inc
+zjit.$(OBJEXT): {$(VPATH)}insns_info.inc
+zjit.$(OBJEXT): {$(VPATH)}intern.h
+zjit.$(OBJEXT): {$(VPATH)}internal.h
+zjit.$(OBJEXT): {$(VPATH)}internal/abi.h
+zjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+zjit.$(OBJEXT): {$(VPATH)}internal/assume.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+zjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+zjit.$(OBJEXT): {$(VPATH)}internal/cast.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+zjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+zjit.$(OBJEXT): {$(VPATH)}internal/config.h
+zjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+zjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+zjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+zjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+zjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+zjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+zjit.$(OBJEXT): {$(VPATH)}internal/error.h
+zjit.$(OBJEXT): {$(VPATH)}internal/eval.h
+zjit.$(OBJEXT): {$(VPATH)}internal/event.h
+zjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+zjit.$(OBJEXT): {$(VPATH)}internal/gc.h
+zjit.$(OBJEXT): {$(VPATH)}internal/glob.h
+zjit.$(OBJEXT): {$(VPATH)}internal/globals.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+zjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/set.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+zjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+zjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+zjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+zjit.$(OBJEXT): {$(VPATH)}internal/memory.h
+zjit.$(OBJEXT): {$(VPATH)}internal/method.h
+zjit.$(OBJEXT): {$(VPATH)}internal/module.h
+zjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+zjit.$(OBJEXT): {$(VPATH)}internal/numeric.h
+zjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+zjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+zjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+zjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+zjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+zjit.$(OBJEXT): {$(VPATH)}internal/stdckdint.h
+zjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+zjit.$(OBJEXT): {$(VPATH)}internal/value.h
+zjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+zjit.$(OBJEXT): {$(VPATH)}internal/variable.h
+zjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+zjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+zjit.$(OBJEXT): {$(VPATH)}iseq.h
+zjit.$(OBJEXT): {$(VPATH)}method.h
+zjit.$(OBJEXT): {$(VPATH)}missing.h
+zjit.$(OBJEXT): {$(VPATH)}node.h
+zjit.$(OBJEXT): {$(VPATH)}onigmo.h
+zjit.$(OBJEXT): {$(VPATH)}oniguruma.h
+zjit.$(OBJEXT): {$(VPATH)}prism_compile.h
+zjit.$(OBJEXT): {$(VPATH)}prism_xallocator.h
+zjit.$(OBJEXT): {$(VPATH)}probes.dmyh
+zjit.$(OBJEXT): {$(VPATH)}probes.h
+zjit.$(OBJEXT): {$(VPATH)}probes_helper.h
+zjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
+zjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+zjit.$(OBJEXT): {$(VPATH)}rubyparser.h
+zjit.$(OBJEXT): {$(VPATH)}shape.h
+zjit.$(OBJEXT): {$(VPATH)}st.h
+zjit.$(OBJEXT): {$(VPATH)}subst.h
+zjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+zjit.$(OBJEXT): {$(VPATH)}thread_native.h
+zjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+zjit.$(OBJEXT): {$(VPATH)}vm_core.h
+zjit.$(OBJEXT): {$(VPATH)}vm_debug.h
+zjit.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
+zjit.$(OBJEXT): {$(VPATH)}vm_opts.h
+zjit.$(OBJEXT): {$(VPATH)}vm_sync.h
+zjit.$(OBJEXT): {$(VPATH)}yjit.h
+zjit.$(OBJEXT): {$(VPATH)}zjit.c
+zjit.$(OBJEXT): {$(VPATH)}zjit.h
+zjit.$(OBJEXT): {$(VPATH)}zjit.rbinc
+# AUTOGENERATED DEPENDENCIES END
diff --git a/dir.c b/dir.c
index 3f73f83fc5..9f2d36b633 100644
--- a/dir.c
+++ b/dir.c
@@ -22,10 +22,6 @@
#include <unistd.h>
#endif
-#ifndef O_CLOEXEC
-# define O_CLOEXEC 0
-#endif
-
#ifndef USE_OPENDIR_AT
# if defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD) && \
defined(HAVE_OPENAT) && defined(HAVE_FSTATAT)
@@ -35,8 +31,12 @@
# endif
#endif
-#if USE_OPENDIR_AT
-# include <fcntl.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
#endif
#undef HAVE_DIRENT_NAMLEN
@@ -113,6 +113,7 @@ char *strchr(char*,char);
#include "internal/gc.h"
#include "internal/io.h"
#include "internal/object.h"
+#include "internal/imemo.h"
#include "internal/vm.h"
#include "ruby/encoding.h"
#include "ruby/ruby.h"
@@ -142,6 +143,50 @@ char *strchr(char*,char);
# define IS_WIN32 0
#endif
+#ifdef HAVE_GETATTRLIST
+struct getattrlist_args {
+ const char *path;
+ int fd;
+ struct attrlist *list;
+ void *buf;
+ size_t size;
+ unsigned int options;
+};
+
+# define GETATTRLIST_ARGS(list_, buf_, options_) (struct getattrlist_args) \
+ {.list = list_, .buf = buf_, .size = sizeof(buf_), .options = options_}
+
+static void *
+nogvl_getattrlist(void *args)
+{
+ struct getattrlist_args *arg = args;
+ return (void *)(VALUE)getattrlist(arg->path, arg->list, arg->buf, arg->size, arg->options);
+}
+
+static int
+gvl_getattrlist(struct getattrlist_args *args, const char *path)
+{
+ args->path = path;
+ return IO_WITHOUT_GVL_INT(nogvl_getattrlist, args);
+}
+
+# ifdef HAVE_FGETATTRLIST
+static void *
+nogvl_fgetattrlist(void *args)
+{
+ struct getattrlist_args *arg = args;
+ return (void *)(VALUE)fgetattrlist(arg->fd, arg->list, arg->buf, arg->size, arg->options);
+}
+
+static int
+gvl_fgetattrlist(struct getattrlist_args *args, int fd)
+{
+ args->fd = fd;
+ return IO_WITHOUT_GVL_INT(nogvl_fgetattrlist, args);
+}
+# endif
+#endif
+
#if NORMALIZE_UTF8PATH
# if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST
# define need_normalization(dirp, path) need_normalization(dirp)
@@ -154,10 +199,11 @@ need_normalization(DIR *dirp, const char *path)
# if defined HAVE_FGETATTRLIST || defined HAVE_GETATTRLIST
u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
+ struct getattrlist_args args = GETATTRLIST_ARGS(&al, attrbuf, 0);
# if defined HAVE_FGETATTRLIST
- int ret = fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), 0);
+ int ret = gvl_fgetattrlist(&args, dirfd(dirp));
# else
- int ret = getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0);
+ int ret = gvl_getattrlist(&args, path);
# endif
if (!ret) {
const fsobj_tag_t *tag = (void *)(attrbuf+1);
@@ -458,6 +504,20 @@ fnmatch(
}
VALUE rb_cDir;
+static VALUE sym_directory, sym_link, sym_file, sym_unknown;
+
+#if defined(DT_BLK) || defined(S_IFBLK)
+static VALUE sym_block_device;
+#endif
+#if defined(DT_CHR) || defined(S_IFCHR)
+static VALUE sym_character_device;
+#endif
+#if defined(DT_FIFO) || defined(S_IFIFO)
+static VALUE sym_fifo;
+#endif
+#if defined(DT_SOCK) || defined(S_IFSOCK)
+static VALUE sym_socket;
+#endif
struct dir_data {
DIR *dir;
@@ -466,31 +526,26 @@ struct dir_data {
};
static void
-dir_mark(void *ptr)
-{
- struct dir_data *dir = ptr;
- rb_gc_mark(dir->path);
-}
-
-static void
dir_free(void *ptr)
{
struct dir_data *dir = ptr;
if (dir->dir) closedir(dir->dir);
- xfree(dir);
}
-static size_t
-dir_memsize(const void *ptr)
-{
- return sizeof(struct dir_data);
-}
+RUBY_REFERENCES(dir_refs) = {
+ RUBY_REF_EDGE(struct dir_data, path),
+ RUBY_REF_END
+};
static const rb_data_type_t dir_data_type = {
"dir",
- {dir_mark, dir_free, dir_memsize,},
- 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+ {
+ RUBY_REFS_LIST_PTR(dir_refs),
+ dir_free,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ },
+ 0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
};
static VALUE dir_close(VALUE);
@@ -513,7 +568,7 @@ nogvl_opendir(void *ptr)
{
const char *path = ptr;
- return (void *)opendir(path);
+ return opendir(path);
}
static DIR *
@@ -524,12 +579,31 @@ opendir_without_gvl(const char *path)
u.in = path;
- return rb_thread_call_without_gvl(nogvl_opendir, u.out, RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL(nogvl_opendir, u.out);
}
else
return opendir(path);
}
+static void
+close_dir_data(struct dir_data *dp)
+{
+ if (dp->dir) {
+ if (closedir(dp->dir) < 0) {
+ dp->dir = NULL;
+ rb_sys_fail("closedir");
+ }
+ dp->dir = NULL;
+ }
+}
+
+static void
+check_closedir(DIR *dirp)
+{
+ if (closedir(dirp) < 0)
+ rb_sys_fail("closedir");
+}
+
static VALUE
dir_initialize(rb_execution_context_t *ec, VALUE dir, VALUE dirname, VALUE enc)
{
@@ -544,8 +618,7 @@ dir_initialize(rb_execution_context_t *ec, VALUE dir, VALUE dirname, VALUE enc)
dirname = rb_str_dup_frozen(dirname);
TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp);
- if (dp->dir) closedir(dp->dir);
- dp->dir = NULL;
+ close_dir_data(dp);
RB_OBJ_WRITE(dir, &dp->path, Qnil);
dp->enc = fsenc;
path = RSTRING_PTR(dirname);
@@ -559,7 +632,8 @@ dir_initialize(rb_execution_context_t *ec, VALUE dir, VALUE dirname, VALUE enc)
else if (e == EIO) {
u_int32_t attrbuf[1];
struct attrlist al = {ATTR_BIT_MAP_COUNT, 0};
- if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) {
+ struct getattrlist_args args = GETATTRLIST_ARGS(&al, attrbuf, FSOPT_NOFOLLOW);
+ if (gvl_getattrlist(&args, path) == 0) {
dp->dir = opendir_without_gvl(path);
}
}
@@ -591,6 +665,51 @@ dir_s_close(rb_execution_context_t *ec, VALUE klass, VALUE dir)
return dir_close(dir);
}
+# if defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD)
+static void *
+nogvl_fdopendir(void *fd)
+{
+ return fdopendir((int)(VALUE)fd);
+}
+
+/*
+ * call-seq:
+ * Dir.for_fd(fd) -> dir
+ *
+ * Returns a new \Dir object representing the directory specified by the given
+ * integer directory file descriptor +fd+:
+ *
+ * d0 = Dir.new('..')
+ * d1 = Dir.for_fd(d0.fileno)
+ *
+ * Note that the returned +d1+ does not have an associated path:
+ *
+ * d0.path # => '..'
+ * d1.path # => nil
+ *
+ * This method uses the
+ * {fdopendir()}[https://www.man7.org/linux/man-pages/man3/fdopendir.3p.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
+ */
+static VALUE
+dir_s_for_fd(VALUE klass, VALUE fd)
+{
+ struct dir_data *dp;
+ VALUE dir = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dp);
+
+ if (!(dp->dir = IO_WITHOUT_GVL(nogvl_fdopendir, (void *)(VALUE)NUM2INT(fd)))) {
+ rb_sys_fail("fdopendir");
+ UNREACHABLE_RETURN(Qnil);
+ }
+
+ RB_OBJ_WRITE(dir, &dp->path, Qnil);
+ return dir;
+}
+#else
+#define dir_s_for_fd rb_f_notimplement
+#endif
+
NORETURN(static void dir_closed(void));
static void
@@ -618,10 +737,13 @@ dir_check(VALUE dir)
/*
- * call-seq:
- * dir.inspect -> string
+ * call-seq:
+ * inspect -> string
+ *
+ * Returns a string description of +self+:
+ *
+ * Dir.new('example').inspect # => "#<Dir:example>"
*
- * Return a string describing this Dir object.
*/
static VALUE
dir_inspect(VALUE dir)
@@ -655,18 +777,18 @@ dir_inspect(VALUE dir)
#ifdef HAVE_DIRFD
/*
- * call-seq:
- * dir.fileno -> integer
- *
- * Returns the file descriptor used in <em>dir</em>.
+ * call-seq:
+ * fileno -> integer
*
- * d = Dir.new("..")
- * d.fileno #=> 8
+ * Returns the file descriptor used in <em>dir</em>.
*
- * This method uses dirfd() function defined by POSIX 2008.
- * NotImplementedError is raised on other platforms, such as Windows,
- * which doesn't provide the function.
+ * d = Dir.new('..')
+ * d.fileno # => 8
*
+ * This method uses the
+ * {dirfd()}[https://www.man7.org/linux/man-pages/man3/dirfd.3.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
*/
static VALUE
dir_fileno(VALUE dir)
@@ -685,14 +807,14 @@ dir_fileno(VALUE dir)
#endif
/*
- * call-seq:
- * dir.path -> string or nil
- * dir.to_path -> string or nil
+ * call-seq:
+ * path -> string or nil
*
- * Returns the path parameter passed to <em>dir</em>'s constructor.
+ * Returns the +dirpath+ string that was used to create +self+
+ * (or +nil+ if created by method Dir.for_fd):
+ *
+ * Dir.new('example').path # => "example"
*
- * d = Dir.new("..")
- * d.path #=> ".."
*/
static VALUE
dir_path(VALUE dir)
@@ -718,8 +840,28 @@ fundamental_encoding_p(rb_encoding *enc)
}
}
# define READDIR(dir, enc) rb_w32_readdir((dir), (enc))
+# define READDIR_NOGVL READDIR
#else
-# define READDIR(dir, enc) readdir((dir))
+NORETURN(static void *sys_failure(void *function));
+static void *
+sys_failure(void *function)
+{
+ rb_sys_fail(function);
+}
+
+static void *
+nogvl_readdir(void *dir)
+{
+ rb_errno_set(0);
+ if ((dir = readdir(dir)) == NULL) {
+ if (rb_errno())
+ rb_thread_call_with_gvl(sys_failure, (void *)"readdir");
+ }
+ return dir;
+}
+
+# define READDIR(dir, enc) IO_WITHOUT_GVL(nogvl_readdir, (void *)(dir))
+# define READDIR_NOGVL(dir, enc) nogvl_readdir((dir))
#endif
/* safe to use without GVL */
@@ -746,16 +888,18 @@ to_be_skipped(const struct dirent *dp)
}
/*
- * call-seq:
- * dir.read -> string or nil
+ * call-seq:
+ * read -> string or nil
+ *
+ * Reads and returns the next entry name from +self+;
+ * returns +nil+ if at end-of-stream;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
*
- * Reads the next entry from <em>dir</em> and returns it as a string.
- * Returns <code>nil</code> at the end of the stream.
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.read # => ".."
+ * dir.read # => "config.h"
*
- * d = Dir.new("testdir")
- * d.read #=> "."
- * d.read #=> ".."
- * d.read #=> "config.h"
*/
static VALUE
dir_read(VALUE dir)
@@ -764,7 +908,7 @@ dir_read(VALUE dir)
struct dirent *dp;
GetDIR(dir, dirp);
- errno = 0;
+ rb_errno_set(0);
if ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc);
}
@@ -775,33 +919,127 @@ dir_read(VALUE dir)
}
}
-static VALUE dir_each_entry(VALUE, VALUE (*)(VALUE, VALUE), VALUE, int);
+struct dir_entry_args {
+ struct dir_data *dirp;
+ struct dirent *dp;
+};
+
+static VALUE dir_each_entry(VALUE, VALUE (*)(VALUE, VALUE, struct dir_entry_args *), VALUE, int);
static VALUE
-dir_yield(VALUE arg, VALUE path)
+dir_yield(VALUE arg, VALUE path, struct dir_entry_args *_unused)
{
return rb_yield(path);
}
+static int do_lstat(int fd, const char *path, struct stat *pst, int flags, rb_encoding *enc);
+
+static VALUE
+dir_yield_with_type(VALUE arg, VALUE path, struct dir_entry_args *dir_entry)
+{
+ VALUE type;
+ switch (dir_entry->dp->d_type) {
+#ifdef DT_BLK
+ case DT_BLK:
+ type = sym_block_device;
+ break;
+#endif
+#ifdef DT_CHR
+ case DT_CHR:
+ type = sym_character_device;
+ break;
+#endif
+ case DT_DIR:
+ type = sym_directory;
+ break;
+#ifdef DT_FIFO
+ case DT_FIFO:
+ type = sym_fifo;
+ break;
+#endif
+ case DT_LNK:
+ type = sym_link;
+ break;
+ case DT_REG:
+ type = sym_file;
+ break;
+#ifdef DT_SOCK
+ case DT_SOCK:
+ type = sym_socket;
+ break;
+#endif
+ default:
+ type = sym_unknown;
+ break;
+ }
+
+#ifdef HAVE_DIRFD
+ if (RUBY_DEBUG || RB_UNLIKELY(type == sym_unknown)) {
+ struct stat st;
+ if (do_lstat(dirfd(dir_entry->dirp->dir), dir_entry->dp->d_name, &st, 0, rb_filesystem_encoding()) == 0) {
+ switch (st.st_mode & S_IFMT) {
+ case S_IFDIR:
+ type = sym_directory;
+ break;
+ case S_IFLNK:
+ type = sym_link;
+ break;
+ case S_IFREG:
+ type = sym_file;
+ break;
+#ifdef S_IFSOCK
+ case S_IFSOCK:
+ type = sym_socket;
+ break;
+#endif
+#ifdef S_IFIFO
+ case S_IFIFO:
+ type = sym_fifo;
+ break;
+#endif
+#ifdef S_IFBLK
+ case S_IFBLK:
+ type = sym_block_device;
+ break;
+#endif
+#ifdef S_IFCHR
+ case S_IFCHR:
+ type = sym_character_device;
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+ }
+#endif // HAVE_DIRFD
+
+ if (NIL_P(arg)) {
+ return rb_yield_values(2, path, type);
+ }
+ else {
+ return rb_ary_push(arg, rb_assoc_new(path, type));
+ }
+}
+
/*
- * call-seq:
- * dir.each { |filename| block } -> dir
- * dir.each -> an_enumerator
+ * call-seq:
+ * each {|entry_name| ... } -> self
*
- * Calls the block once for each entry in this directory, passing the
- * filename of each entry as a parameter to the block.
+ * Calls the block with each entry name in +self+:
*
- * If no block is given, an enumerator is returned instead.
+ * Dir.new('example').each {|entry_name| p entry_name }
*
- * d = Dir.new("testdir")
- * d.each {|x| puts "Got #{x}" }
+ * Output:
+
+ * "."
+ * ".."
+ * "config.h"
+ * "lib"
+ * "main.rb"
*
- * <em>produces:</em>
+ * With no block given, returns an Enumerator.
*
- * Got .
- * Got ..
- * Got config.h
- * Got main.rb
*/
static VALUE
dir_each(VALUE dir)
@@ -811,7 +1049,7 @@ dir_each(VALUE dir)
}
static VALUE
-dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_only)
+dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE, struct dir_entry_args *), VALUE arg, int children_only)
{
struct dir_data *dirp;
struct dirent *dp;
@@ -837,23 +1075,28 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o
else
#endif
path = rb_external_str_new_with_enc(name, namlen, dirp->enc);
- (*each)(arg, path);
+ struct dir_entry_args each_args = {
+ .dirp = dirp,
+ .dp = dp,
+ };
+ (*each)(arg, path, &each_args);
}
return dir;
}
#ifdef HAVE_TELLDIR
/*
- * call-seq:
- * dir.pos -> integer
- * dir.tell -> integer
+ * call-seq:
+ * tell -> integer
+ *
+ * Returns the current position of +self+;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
*
- * Returns the current position in <em>dir</em>. See also Dir#seek.
+ * dir = Dir.new('example')
+ * dir.tell # => 0
+ * dir.read # => "."
+ * dir.tell # => 1
*
- * d = Dir.new("testdir")
- * d.tell #=> 0
- * d.read #=> "."
- * d.tell #=> 12
*/
static VALUE
dir_tell(VALUE dir)
@@ -862,7 +1105,8 @@ dir_tell(VALUE dir)
long pos;
GetDIR(dir, dirp);
- pos = telldir(dirp->dir);
+ if((pos = telldir(dirp->dir)) < 0)
+ rb_sys_fail("telldir");
return rb_int2inum(pos);
}
#else
@@ -871,18 +1115,24 @@ dir_tell(VALUE dir)
#ifdef HAVE_SEEKDIR
/*
- * call-seq:
- * dir.seek( integer ) -> dir
- *
- * Seeks to a particular location in <em>dir</em>. <i>integer</i>
- * must be a value returned by Dir#tell.
- *
- * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
- * d.read #=> "."
- * i = d.tell #=> 12
- * d.read #=> ".."
- * d.seek(i) #=> #<Dir:0x401b3c40>
- * d.read #=> ".."
+ * call-seq:
+ * seek(position) -> self
+ *
+ * Sets the position in +self+ and returns +self+.
+ * The value of +position+ should have been returned from an earlier call to #tell;
+ * if not, the return values from subsequent calls to #read are unspecified.
+ *
+ * See {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like].
+ *
+ * Examples:
+ *
+ * dir = Dir.new('example')
+ * dir.pos # => 0
+ * dir.seek(3) # => #<Dir:example>
+ * dir.pos # => 3
+ * dir.seek(30) # => #<Dir:example>
+ * dir.pos # => 5
+ *
*/
static VALUE
dir_seek(VALUE dir, VALUE pos)
@@ -900,17 +1150,24 @@ dir_seek(VALUE dir, VALUE pos)
#ifdef HAVE_SEEKDIR
/*
- * call-seq:
- * dir.pos = integer -> integer
+ * call-seq:
+ * pos = position -> integer
*
- * Synonym for Dir#seek, but returns the position parameter.
+ * Sets the position in +self+ and returns +position+.
+ * The value of +position+ should have been returned from an earlier call to #tell;
+ * if not, the return values from subsequent calls to #read are unspecified.
+ *
+ * See {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like].
+ *
+ * Examples:
+ *
+ * dir = Dir.new('example')
+ * dir.pos # => 0
+ * dir.pos = 3 # => 3
+ * dir.pos # => 3
+ * dir.pos = 30 # => 30
+ * dir.pos # => 5
*
- * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
- * d.read #=> "."
- * i = d.pos #=> 12
- * d.read #=> ".."
- * d.pos = i #=> 12
- * d.read #=> ".."
*/
static VALUE
dir_set_pos(VALUE dir, VALUE pos)
@@ -923,15 +1180,19 @@ dir_set_pos(VALUE dir, VALUE pos)
#endif
/*
- * call-seq:
- * dir.rewind -> dir
+ * call-seq:
+ * rewind -> self
*
- * Repositions <em>dir</em> to the first entry.
+ * Sets the position in +self+ to zero;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
+ *
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.read # => ".."
+ * dir.pos # => 2
+ * dir.rewind # => #<Dir:example>
+ * dir.pos # => 0
*
- * d = Dir.new("testdir")
- * d.read #=> "."
- * d.rewind #=> #<Dir:0x401b3fb0>
- * d.read #=> "."
*/
static VALUE
dir_rewind(VALUE dir)
@@ -944,14 +1205,18 @@ dir_rewind(VALUE dir)
}
/*
- * call-seq:
- * dir.close -> nil
+ * call-seq:
+ * close -> nil
+ *
+ * Closes the stream in +self+, if it is open, and returns +nil+;
+ * ignored if +self+ is already closed:
*
- * Closes the directory stream.
- * Calling this method on closed Dir object is ignored since Ruby 2.3.
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.close # => nil
+ * dir.close # => nil
+ * dir.read # Raises IOError.
*
- * d = Dir.new("testdir")
- * d.close #=> nil
*/
static VALUE
dir_close(VALUE dir)
@@ -960,8 +1225,7 @@ dir_close(VALUE dir)
dirp = dir_get(dir);
if (!dirp->dir) return Qnil;
- closedir(dirp->dir);
- dirp->dir = NULL;
+ close_dir_data(dirp);
return Qnil;
}
@@ -975,30 +1239,80 @@ nogvl_chdir(void *ptr)
}
static void
-dir_chdir(VALUE path)
+dir_chdir0(VALUE path)
{
- if (chdir(RSTRING_PTR(path)) < 0)
+ if (IO_WITHOUT_GVL_INT(nogvl_chdir, (void*)RSTRING_PTR(path)) < 0)
rb_sys_fail_path(path);
}
-static int chdir_blocking = 0;
-static VALUE chdir_thread = Qnil;
+static struct {
+ VALUE thread;
+ VALUE path;
+ int line;
+ int blocking;
+} chdir_lock = {
+ .blocking = 0, .thread = Qnil,
+ .path = Qnil, .line = 0,
+};
+
+static void
+chdir_enter(void)
+{
+ if (chdir_lock.blocking == 0) {
+ chdir_lock.path = rb_source_location(&chdir_lock.line);
+ }
+ chdir_lock.blocking++;
+ if (NIL_P(chdir_lock.thread)) {
+ chdir_lock.thread = rb_thread_current();
+ }
+}
+
+static void
+chdir_leave(void)
+{
+ chdir_lock.blocking--;
+ if (chdir_lock.blocking == 0) {
+ chdir_lock.thread = Qnil;
+ chdir_lock.path = Qnil;
+ chdir_lock.line = 0;
+ }
+}
+
+static int
+chdir_alone_block_p(void)
+{
+ int block_given = rb_block_given_p();
+ if (chdir_lock.blocking > 0) {
+ if (rb_thread_current() != chdir_lock.thread)
+ rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block");
+ if (!block_given) {
+ if (!NIL_P(chdir_lock.path)) {
+ rb_warn("conflicting chdir during another chdir block\n"
+ "%" PRIsVALUE ":%d: note: previous chdir was here",
+ chdir_lock.path, chdir_lock.line);
+ }
+ else {
+ rb_warn("conflicting chdir during another chdir block");
+ }
+ }
+ }
+ return block_given;
+}
struct chdir_data {
VALUE old_path, new_path;
int done;
+ bool yield_path;
};
static VALUE
chdir_yield(VALUE v)
{
struct chdir_data *args = (void *)v;
- dir_chdir(args->new_path);
+ dir_chdir0(args->new_path);
args->done = TRUE;
- chdir_blocking++;
- if (NIL_P(chdir_thread))
- chdir_thread = rb_thread_current();
- return rb_yield(args->new_path);
+ chdir_enter();
+ return args->yield_path ? rb_yield(args->new_path) : rb_yield_values2(0, NULL);
}
static VALUE
@@ -1006,53 +1320,96 @@ chdir_restore(VALUE v)
{
struct chdir_data *args = (void *)v;
if (args->done) {
- chdir_blocking--;
- if (chdir_blocking == 0)
- chdir_thread = Qnil;
- dir_chdir(args->old_path);
+ chdir_leave();
+ dir_chdir0(args->old_path);
}
return Qnil;
}
+static VALUE
+chdir_path(VALUE path, bool yield_path)
+{
+ if (chdir_alone_block_p()) {
+ struct chdir_data args;
+
+ args.old_path = rb_str_encode_ospath(rb_dir_getwd());
+ args.new_path = path;
+ args.done = FALSE;
+ args.yield_path = yield_path;
+ return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
+ }
+ else {
+ char *p = RSTRING_PTR(path);
+ int r = IO_WITHOUT_GVL_INT(nogvl_chdir, p);
+ if (r < 0)
+ rb_sys_fail_path(path);
+ }
+
+ return INT2FIX(0);
+}
+
/*
- * call-seq:
- * Dir.chdir( [ string] ) -> 0
- * Dir.chdir( [ string] ) {| path | block } -> anObject
- *
- * Changes the current working directory of the process to the given
- * string. When called without an argument, changes the directory to
- * the value of the environment variable <code>HOME</code>, or
- * <code>LOGDIR</code>. SystemCallError (probably Errno::ENOENT) if
- * the target directory does not exist.
- *
- * If a block is given, it is passed the name of the new current
- * directory, and the block is executed with that as the current
- * directory. The original working directory is restored when the block
- * exits. The return value of <code>chdir</code> is the value of the
- * block. <code>chdir</code> blocks can be nested, but in a
- * multi-threaded program an error will be raised if a thread attempts
- * to open a <code>chdir</code> block while another thread has one
- * open or a call to <code>chdir</code> without a block occurs inside
- * a block passed to <code>chdir</code> (even in the same thread).
- *
- * Dir.chdir("/var/spool/mail")
- * puts Dir.pwd
- * Dir.chdir("/tmp") do
- * puts Dir.pwd
- * Dir.chdir("/usr") do
- * puts Dir.pwd
- * end
- * puts Dir.pwd
+ * call-seq:
+ * Dir.chdir(new_dirpath) -> 0
+ * Dir.chdir -> 0
+ * Dir.chdir(new_dirpath) {|new_dirpath| ... } -> object
+ * Dir.chdir {|cur_dirpath| ... } -> object
+ *
+ * Changes the current working directory.
+ *
+ * With argument +new_dirpath+ and no block,
+ * changes to the given +dirpath+:
+ *
+ * Dir.pwd # => "/example"
+ * Dir.chdir('..') # => 0
+ * Dir.pwd # => "/"
+ *
+ * With no argument and no block:
+ *
+ * - Changes to the value of environment variable +HOME+ if defined.
+ * - Otherwise changes to the value of environment variable +LOGDIR+ if defined.
+ * - Otherwise makes no change.
+ *
+ * With argument +new_dirpath+ and a block, temporarily changes the working directory:
+ *
+ * - Calls the block with the argument.
+ * - Changes to the given directory.
+ * - Executes the block (yielding the new path).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Example:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * Dir.chdir('/tmp') do
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
+ *
+ * With no argument and a block,
+ * calls the block with the current working directory (string)
+ * and returns the block's return value.
+ *
+ * Calls to \Dir.chdir with blocks may be nested:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * Dir.chdir('/tmp') do
+ * Dir.pwd # => "/tmp"
+ * Dir.chdir('/usr') do
+ * Dir.pwd # => "/usr"
* end
- * puts Dir.pwd
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
*
- * <em>produces:</em>
+ * In a multi-threaded program an error is raised if a thread attempts
+ * to open a +chdir+ block while another thread has one open,
+ * or a call to +chdir+ without a block occurs inside
+ * a block passed to +chdir+ (even in the same thread).
*
- * /var/spool/mail
- * /tmp
- * /usr
- * /tmp
- * /var/spool/mail
+ * Raises an exception if the target directory does not exist.
*/
static VALUE
dir_s_chdir(int argc, VALUE *argv, VALUE obj)
@@ -1071,54 +1428,212 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
path = rb_str_new2(dist);
}
- if (chdir_blocking > 0) {
- if (rb_thread_current() != chdir_thread)
- rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block");
- if (!rb_block_given_p())
- rb_warn("conflicting chdir during another chdir block");
+ return chdir_path(path, true);
+}
+
+#if defined(HAVE_FCHDIR) && defined(HAVE_DIRFD) && HAVE_FCHDIR && HAVE_DIRFD
+static void *
+nogvl_fchdir(void *ptr)
+{
+ const int *fd = ptr;
+
+ return (void *)(VALUE)fchdir(*fd);
+}
+
+static void
+dir_fchdir(int fd)
+{
+ if (IO_WITHOUT_GVL_INT(nogvl_fchdir, (void *)&fd) < 0)
+ rb_sys_fail("fchdir");
+}
+
+struct fchdir_data {
+ VALUE old_dir;
+ int fd;
+ int done;
+};
+
+static VALUE
+fchdir_yield(VALUE v)
+{
+ struct fchdir_data *args = (void *)v;
+ dir_fchdir(args->fd);
+ args->done = TRUE;
+ chdir_enter();
+ return rb_yield_values(0);
+}
+
+static VALUE
+fchdir_restore(VALUE v)
+{
+ struct fchdir_data *args = (void *)v;
+ if (args->done) {
+ chdir_leave();
+ dir_fchdir(RB_NUM2INT(dir_fileno(args->old_dir)));
}
+ dir_close(args->old_dir);
+ return Qnil;
+}
- if (rb_block_given_p()) {
- struct chdir_data args;
+/*
+ * call-seq:
+ * Dir.fchdir(fd) -> 0
+ * Dir.fchdir(fd) { ... } -> object
+ *
+ * Changes the current working directory to the directory
+ * specified by the integer file descriptor +fd+.
+ *
+ * When passing a file descriptor over a UNIX socket or to a child process,
+ * using +fchdir+ instead of +chdir+ avoids the
+ * {time-of-check to time-of-use vulnerability}[https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use]
+ *
+ * With no block, changes to the directory given by +fd+:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * dir = Dir.new('/usr')
+ * fd = dir.fileno
+ * Dir.fchdir(fd)
+ * Dir.pwd # => "/usr"
+ *
+ * With a block, temporarily changes the working directory:
+ *
+ * - Calls the block with the argument.
+ * - Changes to the given directory.
+ * - Executes the block (yields no args).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Example:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * dir = Dir.new('/tmp')
+ * fd = dir.fileno
+ * Dir.fchdir(fd) do
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
+ *
+ * This method uses the
+ * {fchdir()}[https://www.man7.org/linux/man-pages/man3/fchdir.3p.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
+ *
+ * Raises an exception if the file descriptor is not valid.
+ *
+ * In a multi-threaded program an error is raised if a thread attempts
+ * to open a +chdir+ block while another thread has one open,
+ * or a call to +chdir+ without a block occurs inside
+ * a block passed to +chdir+ (even in the same thread).
+ */
+static VALUE
+dir_s_fchdir(VALUE klass, VALUE fd_value)
+{
+ int fd = RB_NUM2INT(fd_value);
- args.old_path = rb_str_encode_ospath(rb_dir_getwd());
- args.new_path = path;
+ if (chdir_alone_block_p()) {
+ struct fchdir_data args;
+ args.old_dir = dir_s_alloc(klass);
+ dir_initialize(NULL, args.old_dir, rb_fstring_cstr("."), Qnil);
+ args.fd = fd;
args.done = FALSE;
- return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
+ return rb_ensure(fchdir_yield, (VALUE)&args, fchdir_restore, (VALUE)&args);
}
else {
- char *p = RSTRING_PTR(path);
- int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p,
- RUBY_UBF_IO, 0);
+ int r = IO_WITHOUT_GVL_INT(nogvl_fchdir, &fd);
if (r < 0)
- rb_sys_fail_path(path);
+ rb_sys_fail("fchdir");
}
return INT2FIX(0);
}
+#else
+#define dir_s_fchdir rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * chdir -> 0
+ * chdir { ... } -> object
+ *
+ * Changes the current working directory to +self+:
+ *
+ * Dir.pwd # => "/"
+ * dir = Dir.new('example')
+ * dir.chdir
+ * Dir.pwd # => "/example"
+ *
+ * With a block, temporarily changes the working directory:
+ *
+ * - Calls the block.
+ * - Changes to the given directory.
+ * - Executes the block (yields no args).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Uses Dir.fchdir if available, and Dir.chdir if not, see those
+ * methods for caveats.
+ */
+static VALUE
+dir_chdir(VALUE dir)
+{
+#if defined(HAVE_FCHDIR) && defined(HAVE_DIRFD) && HAVE_FCHDIR && HAVE_DIRFD
+ return dir_s_fchdir(rb_cDir, dir_fileno(dir));
+#else
+ return chdir_path(dir_get(dir)->path, false);
+#endif
+}
+
+static VALUE last_cwd;
#ifndef _WIN32
+static VALUE
+getcwd_to_str(VALUE arg)
+{
+ const char *path = (const char *)arg;
+#ifdef __APPLE__
+ return rb_str_normalize_ospath(path, strlen(path));
+#else
+ return rb_str_new2(path);
+#endif
+}
+
+static VALUE
+getcwd_xfree(VALUE arg)
+{
+ xfree((void *)arg);
+ return Qnil;
+}
+
+static VALUE
+rb_dir_getwd_ospath_slowpath(void)
+{
+ char *path = ruby_getcwd();
+ return rb_ensure(getcwd_to_str, (VALUE)path, getcwd_xfree, (VALUE)path);
+}
+
VALUE
rb_dir_getwd_ospath(void)
{
- char *path;
- VALUE cwd;
- VALUE path_guard;
+ char buf[PATH_MAX];
+ char *path = getcwd(buf, PATH_MAX);
+ if (!path) {
+ return rb_dir_getwd_ospath_slowpath();
+ }
+
+ VALUE cached_cwd = RUBY_ATOMIC_VALUE_LOAD(last_cwd);
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
- path_guard = Data_Wrap_Struct((VALUE)0, NULL, RUBY_DEFAULT_FREE, NULL);
- path = ruby_getcwd();
- DATA_PTR(path_guard) = path;
+ if (!cached_cwd || strcmp(RSTRING_PTR(cached_cwd), path) != 0) {
#ifdef __APPLE__
- cwd = rb_str_normalize_ospath(path, strlen(path));
+ cached_cwd = rb_str_normalize_ospath(path, strlen(path));
#else
- cwd = rb_str_new2(path);
+ cached_cwd = rb_str_new2(path);
#endif
- DATA_PTR(path_guard) = 0;
-
- xfree(path);
- return cwd;
+ rb_str_freeze(cached_cwd);
+ RUBY_ATOMIC_VALUE_SET(last_cwd, cached_cwd);
+ }
+ return cached_cwd;
}
#endif
@@ -1127,7 +1642,7 @@ rb_dir_getwd(void)
{
rb_encoding *fs = rb_filesystem_encoding();
int fsenc = rb_enc_to_index(fs);
- VALUE cwd = rb_dir_getwd_ospath();
+ VALUE cwd = rb_str_new_shared(rb_dir_getwd_ospath());
switch (fsenc) {
case ENCINDEX_US_ASCII:
@@ -1143,16 +1658,14 @@ rb_dir_getwd(void)
}
/*
- * call-seq:
- * Dir.getwd -> string
- * Dir.pwd -> string
+ * call-seq:
+ * Dir.pwd -> string
+ *
+ * Returns the path to the current working directory:
*
- * Returns the path to the current working directory of this process as
- * a string.
+ * Dir.chdir("/tmp") # => 0
+ * Dir.pwd # => "/tmp"
*
- * Dir.chdir("/tmp") #=> 0
- * Dir.getwd #=> "/tmp"
- * Dir.pwd #=> "/tmp"
*/
static VALUE
dir_s_getwd(VALUE dir)
@@ -1181,20 +1694,29 @@ check_dirname(VALUE dir)
}
#if defined(HAVE_CHROOT)
+static void *
+nogvl_chroot(void *dirname)
+{
+ return (void *)(VALUE)chroot((const char *)dirname);
+}
+
/*
- * call-seq:
- * Dir.chroot( string ) -> 0
+ * call-seq:
+ * Dir.chroot(dirpath) -> 0
+ *
+ * Changes the root directory of the calling process to that specified in +dirpath+.
+ * The new root directory is used for pathnames beginning with <tt>'/'</tt>.
+ * The root directory is inherited by all children of the calling process.
+ *
+ * Only a privileged process may call +chroot+.
*
- * Changes this process's idea of the file system root. Only a
- * privileged process may make this call. Not available on all
- * platforms. On Unix systems, see <code>chroot(2)</code> for more
- * information.
+ * See {Linux chroot}[https://man7.org/linux/man-pages/man2/chroot.2.html].
*/
static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
path = check_dirname(path);
- if (chroot(RSTRING_PTR(path)) == -1)
+ if (IO_WITHOUT_GVL_INT(nogvl_chroot, (void *)RSTRING_PTR(path)) == -1)
rb_sys_fail_path(path);
return INT2FIX(0);
@@ -1217,18 +1739,20 @@ nogvl_mkdir(void *ptr)
}
/*
- * call-seq:
- * Dir.mkdir( string [, integer] ) -> 0
+ * call-seq:
+ * Dir.mkdir(dirpath, permissions = 0775) -> 0
*
- * Makes a new directory named by <i>string</i>, with permissions
- * specified by the optional parameter <i>anInteger</i>. The
- * permissions may be modified by the value of File::umask, and are
- * ignored on NT. Raises a SystemCallError if the directory cannot be
- * created. See also the discussion of permissions in the class
- * documentation for File.
+ * Creates a directory in the underlying file system
+ * at +dirpath+ with the given +permissions+;
+ * returns zero:
*
- * Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
+ * Dir.mkdir('foo')
+ * File.stat(Dir.new('foo')).mode.to_s(8)[1..4] # => "0755"
+ * Dir.mkdir('bar', 0644)
+ * File.stat(Dir.new('bar')).mode.to_s(8)[1..4] # => "0644"
*
+ * See {File Permissions}[rdoc-ref:File@File+Permissions].
+ * Note that argument +permissions+ is ignored on Windows.
*/
static VALUE
dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
@@ -1246,7 +1770,7 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
path = check_dirname(path);
m.path = RSTRING_PTR(path);
- r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_mkdir, &m, RUBY_UBF_IO, 0);
+ r = IO_WITHOUT_GVL_INT(nogvl_mkdir, &m);
if (r < 0)
rb_sys_fail_path(path);
@@ -1262,13 +1786,14 @@ nogvl_rmdir(void *ptr)
}
/*
- * call-seq:
- * Dir.delete( string ) -> 0
- * Dir.rmdir( string ) -> 0
- * Dir.unlink( string ) -> 0
+ * call-seq:
+ * Dir.rmdir(dirpath) -> 0
+ *
+ * Removes the directory at +dirpath+ from the underlying file system:
+ *
+ * Dir.rmdir('foo') # => 0
*
- * Deletes the named directory. Raises a subclass of SystemCallError
- * if the directory isn't empty.
+ * Raises an exception if the directory is not empty.
*/
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
@@ -1278,7 +1803,7 @@ dir_s_rmdir(VALUE obj, VALUE dir)
dir = check_dirname(dir);
p = RSTRING_PTR(dir);
- r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0);
+ r = IO_WITHOUT_GVL_INT(nogvl_rmdir, (void *)p);
if (r < 0)
rb_sys_fail_path(dir);
@@ -1368,11 +1893,11 @@ to_be_ignored(int e)
}
#ifdef _WIN32
-#define STAT(p, s) rb_w32_ustati128((p), (s))
-#undef lstat
-#define lstat(p, s) rb_w32_ulstati128((p), (s))
+#define STAT(args) (int)(VALUE)nogvl_stat(&(args))
+#define LSTAT(args) (int)(VALUE)nogvl_lstat(&(args))
#else
-#define STAT(p, s) stat((p), (s))
+#define STAT(args) IO_WITHOUT_GVL_INT(nogvl_stat, (void *)&(args))
+#define LSTAT(args) IO_WITHOUT_GVL_INT(nogvl_lstat, (void *)&(args))
#endif
typedef int ruby_glob_errfunc(const char*, VALUE, const void*, int);
@@ -1393,14 +1918,50 @@ at_subpath(int fd, size_t baselen, const char *path)
return *path ? path : ".";
}
+#if USE_OPENDIR_AT
+struct fstatat_args {
+ int fd;
+ int flag;
+ const char *path;
+ struct stat *pst;
+};
+
+static void *
+nogvl_fstatat(void *args)
+{
+ struct fstatat_args *arg = (struct fstatat_args *)args;
+ return (void *)(VALUE)fstatat(arg->fd, arg->path, arg->pst, arg->flag);
+}
+#else
+struct stat_args {
+ const char *path;
+ struct stat *pst;
+};
+
+static void *
+nogvl_stat(void *args)
+{
+ struct stat_args *arg = (struct stat_args *)args;
+ return (void *)(VALUE)stat(arg->path, arg->pst);
+}
+#endif
+
/* System call with warning */
static int
-do_stat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, rb_encoding *enc)
+do_stat(int fd, const char *path, struct stat *pst, int flags, rb_encoding *enc)
{
#if USE_OPENDIR_AT
- int ret = fstatat(fd, at_subpath(fd, baselen, path), pst, 0);
+ struct fstatat_args args;
+ args.fd = fd;
+ args.path = path;
+ args.pst = pst;
+ args.flag = 0;
+ int ret = IO_WITHOUT_GVL_INT(nogvl_fstatat, (void *)&args);
#else
- int ret = STAT(path, pst);
+ struct stat_args args;
+ args.path = path;
+ args.pst = pst;
+ int ret = STAT(args);
#endif
if (ret < 0 && !to_be_ignored(errno))
sys_warning(path, enc);
@@ -1409,13 +1970,30 @@ do_stat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, r
}
#if defined HAVE_LSTAT || defined lstat || USE_OPENDIR_AT
+#if !USE_OPENDIR_AT
+static void *
+nogvl_lstat(void *args)
+{
+ struct stat_args *arg = (struct stat_args *)args;
+ return (void *)(VALUE)lstat(arg->path, arg->pst);
+}
+#endif
+
static int
-do_lstat(int fd, size_t baselen, const char *path, struct stat *pst, int flags, rb_encoding *enc)
+do_lstat(int fd, const char *path, struct stat *pst, int flags, rb_encoding *enc)
{
#if USE_OPENDIR_AT
- int ret = fstatat(fd, at_subpath(fd, baselen, path), pst, AT_SYMLINK_NOFOLLOW);
+ struct fstatat_args args;
+ args.fd = fd;
+ args.path = path;
+ args.pst = pst;
+ args.flag = AT_SYMLINK_NOFOLLOW;
+ int ret = IO_WITHOUT_GVL_INT(nogvl_fstatat, (void *)&args);
#else
- int ret = lstat(path, pst);
+ struct stat_args args;
+ args.path = path;
+ args.pst = pst;
+ int ret = LSTAT(args);
#endif
if (ret < 0 && !to_be_ignored(errno))
sys_warning(path, enc);
@@ -1476,7 +2054,7 @@ nogvl_opendir_at(void *ptr)
/* fallthrough*/
case 0:
if (fd >= 0) close(fd);
- errno = e;
+ rb_errno_set(e);
}
}
#else /* !USE_OPENDIR_AT */
@@ -1497,7 +2075,7 @@ opendir_at(int basefd, const char *path)
oaa.path = path;
if (vm_initialized)
- return rb_thread_call_without_gvl(nogvl_opendir_at, &oaa, RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL(nogvl_opendir_at, &oaa);
else
return nogvl_opendir_at(&oaa);
}
@@ -1776,14 +2354,15 @@ is_case_sensitive(DIR *dirp, const char *path)
const vol_capabilities_attr_t *const cap = attrbuf[0].cap;
const int idx = VOL_CAPABILITIES_FORMAT;
const uint32_t mask = VOL_CAP_FMT_CASE_SENSITIVE;
-
+ struct getattrlist_args args = GETATTRLIST_ARGS(&al, attrbuf, FSOPT_NOFOLLOW);
# if defined HAVE_FGETATTRLIST
- if (fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW))
- return -1;
+ int ret = gvl_fgetattrlist(&args, dirfd(dirp));
# else
- if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW))
- return -1;
+ int ret = gvl_getattrlist(&args, path);
# endif
+ if (ret)
+ return -1;
+
if (!(cap->valid[idx] & mask))
return -1;
return (cap->capabilities[idx] & mask) != 0;
@@ -1806,7 +2385,8 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p, int f
IF_NORMALIZE_UTF8PATH(VALUE utf8str = Qnil);
*type = path_noent;
- if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW)) {
+ struct getattrlist_args args = GETATTRLIST_ARGS(&al, attrbuf, FSOPT_NOFOLLOW);
+ if (gvl_getattrlist(&args, path)) {
if (!to_be_ignored(errno))
sys_warning(path, enc);
return path;
@@ -2179,7 +2759,7 @@ static void
glob_dir_finish(ruby_glob_entries_t *ent, int flags)
{
if (flags & FNM_GLOB_NOSORT) {
- closedir(ent->nosort.dirp);
+ check_closedir(ent->nosort.dirp);
ent->nosort.dirp = NULL;
}
else if (ent->sort.entries) {
@@ -2210,7 +2790,7 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc)
#ifdef _WIN32
if ((capacity = dirp->nfiles) > 0) {
if (!(newp = GLOB_ALLOC_N(rb_dirent_t, capacity))) {
- closedir(dirp);
+ check_closedir(dirp);
return NULL;
}
ent->sort.entries = newp;
@@ -2223,14 +2803,16 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc)
}
if (count >= capacity) {
capacity += 256;
- if (!(newp = GLOB_REALLOC_N(ent->sort.entries, capacity)))
+ if (!(newp = GLOB_REALLOC_N(ent->sort.entries, capacity))) {
+ GLOB_FREE(rdp);
goto nomem;
+ }
ent->sort.entries = newp;
}
ent->sort.entries[count++] = rdp;
ent->sort.count = count;
}
- closedir(dirp);
+ check_closedir(dirp);
if (count < capacity) {
if (!(newp = GLOB_REALLOC_N(ent->sort.entries, count))) {
glob_dir_finish(ent, 0);
@@ -2245,7 +2827,7 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc)
nomem:
glob_dir_finish(ent, 0);
- closedir(dirp);
+ check_closedir(dirp);
return NULL;
}
@@ -2343,7 +2925,7 @@ glob_helper(
if (*path) {
if (match_all && pathtype == path_unknown) {
- if (do_lstat(fd, baselen, path, &st, flags, enc) == 0) {
+ if (do_lstat(fd, path, &st, flags, enc) == 0) {
pathtype = IFTODT(st.st_mode);
}
else {
@@ -2351,7 +2933,7 @@ glob_helper(
}
}
if (match_dir && (pathtype == path_unknown || pathtype == path_symlink)) {
- if (do_stat(fd, baselen, path, &st, flags, enc) == 0) {
+ if (do_stat(fd, path, &st, flags, enc) == 0) {
pathtype = IFTODT(st.st_mode);
}
else {
@@ -2408,7 +2990,7 @@ glob_helper(
# if NORMALIZE_UTF8PATH
if (!(norm_p || magical || recursive)) {
- closedir(dirp);
+ check_closedir(dirp);
goto literally;
}
# endif
@@ -2479,7 +3061,7 @@ glob_helper(
if (recursive && dotfile < ((flags & FNM_DOTMATCH) ? 2 : 1) &&
new_pathtype == path_unknown) {
/* RECURSIVE never match dot files unless FNM_DOTMATCH is set */
- if (do_lstat(fd, baselen, buf, &st, flags, enc) == 0)
+ if (do_lstat(fd, buf, &st, flags, enc) == 0)
new_pathtype = IFTODT(st.st_mode);
else
new_pathtype = path_noent;
@@ -2869,7 +3451,7 @@ push_glob(VALUE ary, VALUE str, VALUE base, int flags)
fd = AT_FDCWD;
if (!NIL_P(base)) {
if (!RB_TYPE_P(base, T_STRING) || !rb_enc_check(str, base)) {
- struct dir_data *dirp = DATA_PTR(base);
+ struct dir_data *dirp = RTYPEDDATA_GET_DATA(base);
if (!dirp->dir) dir_closed();
#ifdef HAVE_DIRFD
if ((fd = dirfd(dirp->dir)) == -1)
@@ -2993,26 +3575,35 @@ dir_open_dir(int argc, VALUE *argv)
/*
- * call-seq:
- * Dir.foreach( dirname ) {| filename | block } -> nil
- * Dir.foreach( dirname, encoding: enc ) {| filename | block } -> nil
- * Dir.foreach( dirname ) -> an_enumerator
- * Dir.foreach( dirname, encoding: enc ) -> an_enumerator
+ * call-seq:
+ * Dir.foreach(dirpath, encoding: 'UTF-8') {|entry_name| ... } -> nil
+ *
+ * Calls the block with each entry name in the directory at +dirpath+;
+ * sets the given encoding onto each passed +entry_name+:
*
- * Calls the block once for each entry in the named directory, passing
- * the filename of each entry as a parameter to the block.
+ * Dir.foreach('/example') {|entry_name| p entry_name }
*
- * If no block is given, an enumerator is returned instead.
+ * Output:
*
- * Dir.foreach("testdir") {|x| puts "Got #{x}" }
+ * "config.h"
+ * "lib"
+ * "main.rb"
+ * ".."
+ * "."
*
- * <em>produces:</em>
+ * Encoding:
*
- * Got .
- * Got ..
- * Got config.h
- * Got main.rb
+ * Dir.foreach('/example') {|entry_name| p entry_name.encoding; break }
+ * Dir.foreach('/example', encoding: 'US-ASCII') {|entry_name| p entry_name.encoding; break }
*
+ * Output:
+ *
+ * #<Encoding:UTF-8>
+ * #<Encoding:US-ASCII>
+ *
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
+ *
+ * Returns an enumerator if no block is given.
*/
static VALUE
dir_foreach(int argc, VALUE *argv, VALUE io)
@@ -3026,27 +3617,35 @@ dir_foreach(int argc, VALUE *argv, VALUE io)
}
static VALUE
+dir_entry_ary_push(VALUE ary, VALUE entry, struct dir_entry_args *_unused)
+{
+ return rb_ary_push(ary, entry);
+}
+
+static VALUE
dir_collect(VALUE dir)
{
VALUE ary = rb_ary_new();
- dir_each_entry(dir, rb_ary_push, ary, FALSE);
+ dir_each_entry(dir, dir_entry_ary_push, ary, FALSE);
return ary;
}
/*
- * call-seq:
- * Dir.entries( dirname ) -> array
- * Dir.entries( dirname, encoding: enc ) -> array
+ * call-seq:
+ * Dir.entries(dirname, encoding: 'UTF-8') -> array
*
- * Returns an array containing all of the filenames in the given
- * directory. Will raise a SystemCallError if the named directory
- * doesn't exist.
+ * Returns an array of the entry names in the directory at +dirpath+;
+ * sets the given encoding onto each returned entry name:
*
- * The optional <i>encoding</i> keyword argument specifies the encoding of the
- * directory. If not specified, the filesystem encoding is used.
+ * Dir.entries('/example') # => ["config.h", "lib", "main.rb", "..", "."]
+ * Dir.entries('/example').first.encoding
+ * # => #<Encoding:UTF-8>
+ * Dir.entries('/example', encoding: 'US-ASCII').first.encoding
+ * # => #<Encoding:US-ASCII>
*
- * Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
*
+ * Raises an exception if the directory does not exist.
*/
static VALUE
dir_entries(int argc, VALUE *argv, VALUE io)
@@ -3064,25 +3663,12 @@ dir_each_child(VALUE dir)
}
/*
- * call-seq:
- * Dir.each_child( dirname ) {| filename | block } -> nil
- * Dir.each_child( dirname, encoding: enc ) {| filename | block } -> nil
- * Dir.each_child( dirname ) -> an_enumerator
- * Dir.each_child( dirname, encoding: enc ) -> an_enumerator
- *
- * Calls the block once for each entry except for "." and ".." in the
- * named directory, passing the filename of each entry as a parameter
- * to the block.
- *
- * If no block is given, an enumerator is returned instead.
- *
- * Dir.each_child("testdir") {|x| puts "Got #{x}" }
- *
- * <em>produces:</em>
- *
- * Got config.h
- * Got main.rb
+ * call-seq:
+ * Dir.each_child(dirpath) {|entry_name| ... } -> nil
+ * Dir.each_child(dirpath, encoding: 'UTF-8') {|entry_name| ... } -> nil
*
+ * Like Dir.foreach, except that entries <tt>'.'</tt> and <tt>'..'</tt>
+ * are not included.
*/
static VALUE
dir_s_each_child(int argc, VALUE *argv, VALUE io)
@@ -3096,24 +3682,22 @@ dir_s_each_child(int argc, VALUE *argv, VALUE io)
}
/*
- * call-seq:
- * dir.each_child {| filename | block } -> dir
- * dir.each_child -> an_enumerator
- *
- * Calls the block once for each entry except for "." and ".." in
- * this directory, passing the filename of each entry as a parameter
- * to the block.
+ * call-seq:
+ * each_child {|entry_name| ... } -> self
*
- * If no block is given, an enumerator is returned instead.
+ * Calls the block with each entry name in +self+
+ * except <tt>'.'</tt> and <tt>'..'</tt>:
*
- * d = Dir.new("testdir")
- * d.each_child {|x| puts "Got #{x}" }
+ * dir = Dir.new('/example')
+ * dir.each_child {|entry_name| p entry_name }
*
- * <em>produces:</em>
+ * Output:
*
- * Got config.h
- * Got main.rb
+ * "config.h"
+ * "lib"
+ * "main.rb"
*
+ * If no block is given, returns an enumerator.
*/
static VALUE
dir_each_child_m(VALUE dir)
@@ -3123,38 +3707,67 @@ dir_each_child_m(VALUE dir)
}
/*
- * call-seq:
- * dir.children -> array
+ * call-seq:
+ * children -> array
*
- * Returns an array containing all of the filenames except for "."
- * and ".." in this directory.
+ * Returns an array of the entry names in +self+
+ * except for <tt>'.'</tt> and <tt>'..'</tt>:
*
- * d = Dir.new("testdir")
- * d.children #=> ["config.h", "main.rb"]
+ * dir = Dir.new('/example')
+ * dir.children # => ["config.h", "lib", "main.rb"]
*
*/
static VALUE
dir_collect_children(VALUE dir)
{
VALUE ary = rb_ary_new();
- dir_each_entry(dir, rb_ary_push, ary, TRUE);
+ dir_each_entry(dir, dir_entry_ary_push, ary, TRUE);
return ary;
}
/*
- * call-seq:
- * Dir.children( dirname ) -> array
- * Dir.children( dirname, encoding: enc ) -> array
+ * call-seq:
+ * children -> array
+ *
+ * Returns an array of the entry names in +self+ along with their type
+ * except for <tt>'.'</tt> and <tt>'..'</tt>:
+ *
+ * dir = Dir.new('/example')
+ * dir.scan # => [["config.h", :file], ["lib", :directory], ["main.rb", :file]]
+ *
+ */
+static VALUE
+dir_scan_children(VALUE dir)
+{
+ if (rb_block_given_p()) {
+ dir_each_entry(dir, dir_yield_with_type, Qnil, TRUE);
+ return Qnil;
+ }
+ else {
+ VALUE ary = rb_ary_new();
+ dir_each_entry(dir, dir_yield_with_type, ary, TRUE);
+ return ary;
+ }
+}
+
+/*
+ * call-seq:
+ * Dir.children(dirpath) -> array
+ * Dir.children(dirpath, encoding: 'UTF-8') -> array
*
- * Returns an array containing all of the filenames except for "."
- * and ".." in the given directory. Will raise a SystemCallError if
- * the named directory doesn't exist.
+ * Returns an array of the entry names in the directory at +dirpath+
+ * except for <tt>'.'</tt> and <tt>'..'</tt>;
+ * sets the given encoding onto each returned entry name:
*
- * The optional <i>encoding</i> keyword argument specifies the encoding of the
- * directory. If not specified, the filesystem encoding is used.
+ * Dir.children('/example') # => ["config.h", "lib", "main.rb"]
+ * Dir.children('/example').first.encoding
+ * # => #<Encoding:UTF-8>
+ * Dir.children('/example', encoding: 'US-ASCII').first.encoding
+ * # => #<Encoding:US-ASCII>
*
- * Dir.children("testdir") #=> ["config.h", "main.rb"]
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
*
+ * Raises an exception if the directory does not exist.
*/
static VALUE
dir_s_children(int argc, VALUE *argv, VALUE io)
@@ -3165,6 +3778,40 @@ dir_s_children(int argc, VALUE *argv, VALUE io)
return rb_ensure(dir_collect_children, dir, dir_close, dir);
}
+/*
+ * call-seq:
+ * Dir.scan(dirpath) {|entry_name, entry_type| ... } -> nil
+ * Dir.scan(dirpath, encoding: 'UTF-8') {|entry_name, entry_type| ... } -> nil
+ * Dir.scan(dirpath) -> [[entry_name, entry_type], ...]
+ * Dir.scan(dirpath, encoding: 'UTF-8') -> [[entry_name, entry_type], ...]
+ *
+ * Yields or returns an array of the entry names in the directory at +dirpath+
+ * associated with their type, except for <tt>'.'</tt> and <tt>'..'</tt>;
+ * sets the given encoding onto each returned entry name.
+ *
+ * The type symbol is one of:
+ * ``<code>:file</code>'', ``<code>:directory</code>'',
+ * ``<code>:characterSpecial</code>'', ``<code>:blockSpecial</code>'',
+ * ``<code>:fifo</code>'', ``<code>:link</code>'',
+ * or ``<code>:socket</code>'':
+ *
+ * Dir.children('/example') # => [["config.h", :file], ["lib", :directory], ["main.rb", :file]]
+ * Dir.children('/example').first.first.encoding
+ * # => #<Encoding:UTF-8>
+ * Dir.children('/example', encoding: 'US-ASCII').first.encoding
+ * # => #<Encoding:US-ASCII>
+ *
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
+ *
+ * Raises an exception if the directory does not exist.
+ */
+static VALUE
+dir_s_scan(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE dir = dir_open_dir(argc, argv);
+ return rb_ensure(dir_scan_children, dir, dir_close, dir);
+}
+
static int
fnmatch_brace(const char *pattern, VALUE val, void *enc)
{
@@ -3228,12 +3875,16 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
}
/*
- * call-seq:
- * Dir.home() -> "/home/me"
- * Dir.home("root") -> "/root"
+ * call-seq:
+ * Dir.home(user_name = nil) -> dirpath
*
- * Returns the home directory of the current user or the named user
- * if given.
+ * Returns the home directory path of the user specified with +user_name+
+ * if it is not +nil+, or the current login user:
+ *
+ * Dir.home # => "/home/me"
+ * Dir.home('root') # => "/root"
+ *
+ * Raises ArgumentError if +user_name+ is not a user name.
*/
static VALUE
dir_s_home(int argc, VALUE *argv, VALUE obj)
@@ -3244,7 +3895,7 @@ dir_s_home(int argc, VALUE *argv, VALUE obj)
rb_check_arity(argc, 0, 1);
user = (argc > 0) ? argv[0] : Qnil;
if (!NIL_P(user)) {
- SafeStringValue(user);
+ StringValue(user);
rb_must_asciicompat(user);
u = StringValueCStr(user);
if (*u) {
@@ -3258,10 +3909,15 @@ dir_s_home(int argc, VALUE *argv, VALUE obj)
#if 0
/*
* call-seq:
- * Dir.exist?(file_name) -> true or false
+ * Dir.exist?(dirpath) -> true or false
+ *
+ * Returns whether +dirpath+ is a directory in the underlying file system:
*
- * Returns <code>true</code> if the named file is a directory,
- * <code>false</code> otherwise.
+ * Dir.exist?('/example') # => true
+ * Dir.exist?('/nosuch') # => false
+ * Dir.exist?('/example/main.rb') # => false
+ *
+ * Same as File.directory?.
*
*/
VALUE
@@ -3288,26 +3944,33 @@ nogvl_dir_empty_p(void *ptr)
/* fall through */
case 0:
if (e == ENOTDIR) return (void *)Qfalse;
- errno = e; /* for rb_sys_fail_path */
- return (void *)Qundef;
+ return (void *)INT2FIX(e);
}
}
- while ((dp = READDIR(dir, NULL)) != NULL) {
+ while ((dp = READDIR_NOGVL(dir, NULL)) != NULL) {
if (!to_be_skipped(dp)) {
result = Qfalse;
break;
}
}
- closedir(dir);
+ check_closedir(dir);
return (void *)result;
}
/*
* call-seq:
- * Dir.empty?(path_name) -> true or false
+ * Dir.empty?(dirpath) -> true or false
+ *
+ * Returns whether +dirpath+ specifies an empty directory:
+ *
+ * dirpath = '/tmp/foo'
+ * Dir.mkdir(dirpath)
+ * Dir.empty?(dirpath) # => true
+ * Dir.empty?('/example') # => false
+ * Dir.empty?('/example/main.rb') # => false
*
- * Returns <code>true</code> if the named file is an empty directory,
- * <code>false</code> if it is not a directory or non-empty.
+ * Raises an exception if +dirpath+ does not specify a directory or file
+ * in the underlying file system.
*/
static VALUE
rb_dir_s_empty_p(VALUE obj, VALUE dirname)
@@ -3326,12 +3989,13 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
{
u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
- if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0) != 0)
+ struct getattrlist_args args = GETATTRLIST_ARGS(&al, attrbuf, 0);
+ if (gvl_getattrlist(&args, path) != 0)
rb_sys_fail_path(orig);
if (*(const fsobj_tag_t *)(attrbuf+1) == VT_HFS) {
al.commonattr = 0;
al.dirattr = ATTR_DIR_ENTRYCOUNT;
- if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0) == 0) {
+ if (gvl_getattrlist(&args, path) == 0) {
if (attrbuf[0] >= 2 * sizeof(u_int32_t))
return RBOOL(attrbuf[1] == 0);
if (false_on_notdir) return Qfalse;
@@ -3341,10 +4005,9 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
}
#endif
- result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path,
- RUBY_UBF_IO, 0);
- if (UNDEF_P(result)) {
- rb_sys_fail_path(orig);
+ result = (VALUE)IO_WITHOUT_GVL(nogvl_dir_empty_p, (void *)path);
+ if (FIXNUM_P(result)) {
+ rb_syserr_fail_path((int)FIX2LONG(result), orig);
}
return result;
}
@@ -3352,15 +4015,39 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
void
Init_Dir(void)
{
+ sym_directory = ID2SYM(rb_intern("directory"));
+ sym_link = ID2SYM(rb_intern("link"));
+ sym_file = ID2SYM(rb_intern("file"));
+ sym_unknown = ID2SYM(rb_intern("unknown"));
+
+#if defined(DT_BLK) || defined(S_IFBLK)
+ sym_block_device = ID2SYM(rb_intern("blockSpecial"));
+#endif
+#if defined(DT_CHR) || defined(S_IFCHR)
+ sym_character_device = ID2SYM(rb_intern("characterSpecial"));
+#endif
+#if defined(DT_FIFO) || defined(S_IFIFO)
+ sym_fifo = ID2SYM(rb_intern("fifo"));
+#endif
+#if defined(DT_SOCK) || defined(S_IFSOCK)
+ sym_socket = ID2SYM(rb_intern("socket"));
+#endif
+
+ rb_gc_register_address(&chdir_lock.path);
+ rb_gc_register_address(&chdir_lock.thread);
+ rb_gc_register_address(&last_cwd);
+
rb_cDir = rb_define_class("Dir", rb_cObject);
rb_include_module(rb_cDir, rb_mEnumerable);
rb_define_alloc_func(rb_cDir, dir_s_alloc);
+ rb_define_singleton_method(rb_cDir,"for_fd", dir_s_for_fd, 1);
rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, -1);
rb_define_singleton_method(rb_cDir, "entries", dir_entries, -1);
rb_define_singleton_method(rb_cDir, "each_child", dir_s_each_child, -1);
rb_define_singleton_method(rb_cDir, "children", dir_s_children, -1);
+ rb_define_singleton_method(rb_cDir, "scan", dir_s_scan, -1);
rb_define_method(rb_cDir,"fileno", dir_fileno, 0);
rb_define_method(rb_cDir,"path", dir_path, 0);
@@ -3370,13 +4057,16 @@ Init_Dir(void)
rb_define_method(rb_cDir,"each", dir_each, 0);
rb_define_method(rb_cDir,"each_child", dir_each_child_m, 0);
rb_define_method(rb_cDir,"children", dir_collect_children, 0);
+ rb_define_method(rb_cDir,"scan", dir_scan_children, 0);
rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
rb_define_method(rb_cDir,"tell", dir_tell, 0);
rb_define_method(rb_cDir,"seek", dir_seek, 1);
rb_define_method(rb_cDir,"pos", dir_tell, 0);
rb_define_method(rb_cDir,"pos=", dir_set_pos, 1);
rb_define_method(rb_cDir,"close", dir_close, 0);
+ rb_define_method(rb_cDir,"chdir", dir_chdir, 0);
+ rb_define_singleton_method(rb_cDir,"fchdir", dir_s_fchdir, 1);
rb_define_singleton_method(rb_cDir,"chdir", dir_s_chdir, -1);
rb_define_singleton_method(rb_cDir,"getwd", dir_s_getwd, 0);
rb_define_singleton_method(rb_cDir,"pwd", dir_s_getwd, 0);
@@ -3393,51 +4083,19 @@ Init_Dir(void)
rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1);
rb_define_singleton_method(rb_cFile,"fnmatch?", file_s_fnmatch, -1);
- /* Document-const: File::Constants::FNM_NOESCAPE
- *
- * Disables escapes in File.fnmatch and Dir.glob patterns
- */
+ /* {File::FNM_NOESCAPE}[rdoc-ref:File::Constants@File-3A-3AFNM_NOESCAPE] */
rb_file_const("FNM_NOESCAPE", INT2FIX(FNM_NOESCAPE));
-
- /* Document-const: File::Constants::FNM_PATHNAME
- *
- * Wildcards in File.fnmatch and Dir.glob patterns do not match directory
- * separators
- */
+ /* {File::FNM_PATHNAME}[rdoc-ref:File::Constants@File-3A-3AFNM_PATHNAME] */
rb_file_const("FNM_PATHNAME", INT2FIX(FNM_PATHNAME));
-
- /* Document-const: File::Constants::FNM_DOTMATCH
- *
- * The '*' wildcard matches filenames starting with "." in File.fnmatch
- * and Dir.glob patterns
- */
+ /* {File::FNM_DOTMATCH}[rdoc-ref:File::Constants@File-3A-3AFNM_DOTMATCH] */
rb_file_const("FNM_DOTMATCH", INT2FIX(FNM_DOTMATCH));
-
- /* Document-const: File::Constants::FNM_CASEFOLD
- *
- * Makes File.fnmatch patterns case insensitive (but not Dir.glob
- * patterns).
- */
+ /* {File::FNM_CASEFOLD}[rdoc-ref:File::Constants@File-3A-3AFNM_CASEFOLD] */
rb_file_const("FNM_CASEFOLD", INT2FIX(FNM_CASEFOLD));
-
- /* Document-const: File::Constants::FNM_EXTGLOB
- *
- * Allows file globbing through "{a,b}" in File.fnmatch patterns.
- */
+ /* {File::FNM_EXTGLOB}[rdoc-ref:File::Constants@File-3A-3AFNM_EXTGLOB] */
rb_file_const("FNM_EXTGLOB", INT2FIX(FNM_EXTGLOB));
-
- /* Document-const: File::Constants::FNM_SYSCASE
- *
- * System default case insensitiveness, equals to FNM_CASEFOLD or
- * 0.
- */
+ /* {File::FNM_SYSCASE}[rdoc-ref:File::Constants@File-3A-3AFNM_SYSCASE] */
rb_file_const("FNM_SYSCASE", INT2FIX(FNM_SYSCASE));
-
- /* Document-const: File::Constants::FNM_SHORTNAME
- *
- * Makes patterns to match short names if existing. Valid only
- * on Microsoft Windows.
- */
+ /* {File::FNM_SHORTNAME}[rdoc-ref:File::Constants@File-3A-3AFNM_SHORTNAME] */
rb_file_const("FNM_SHORTNAME", INT2FIX(FNM_SHORTNAME));
}
diff --git a/dir.rb b/dir.rb
index 2e426b0881..9b83f68822 100644
--- a/dir.rb
+++ b/dir.rb
@@ -1,18 +1,92 @@
-# Objects of class Dir are directory streams representing
-# directories in the underlying file system. They provide a variety
-# of ways to list directories and their contents. See also File.
+# An object of class \Dir represents a directory in the underlying file system.
#
-# The directory used in these examples contains the two regular files
-# (<code>config.h</code> and <code>main.rb</code>), the parent
-# directory (<code>..</code>), and the directory itself
-# (<code>.</code>).
+# It consists mainly of:
+#
+# - A string _path_, given when the object is created,
+# that specifies a directory in the underlying file system;
+# method #path returns the path.
+# - A collection of string <i>entry names</i>,
+# each of which is the name of a directory or file in the underlying file system;
+# the entry names may be retrieved
+# in an {array-like fashion}[rdoc-ref:Dir@Dir+As+Array-Like]
+# or in a {stream-like fashion}[rdoc-ref:Dir@Dir+As+Stream-Like].
+#
+# == About the Examples
+#
+# Some examples on this page use this simple file tree:
+#
+# example/
+# ├── config.h
+# ├── lib/
+# │ ├── song/
+# │ │ └── karaoke.rb
+# │ └── song.rb
+# └── main.rb
+#
+# Others use the file tree for the
+# {Ruby project itself}[https://github.com/ruby/ruby].
+#
+# == \Dir As \Array-Like
+#
+# A \Dir object is in some ways array-like:
+#
+# - It has instance methods #children, #each, and #each_child.
+# - It includes {module Enumerable}[rdoc-ref:Enumerable@Whats+Here].
+#
+# == \Dir As Stream-Like
+#
+# A \Dir object is in some ways stream-like.
+#
+# The stream is initially open for reading,
+# but may be closed manually (using method #close),
+# and will be closed on block exit if created by Dir.open called with a block.
+# The closed stream may not be further manipulated,
+# and may not be reopened.
+#
+# The stream has a _position_, which is the index of an entry in the directory:
+#
+# - The initial position is zero (before the first entry).
+# - Method #tell (aliased as #pos) returns the position.
+# - Method #pos= sets the position (but ignores a value outside the stream),
+# and returns the position.
+# - Method #seek is like #pos=, but returns +self+ (convenient for chaining).
+# - Method #read, if not at end-of-stream, reads the next entry and increments
+# the position;
+# if at end-of-stream, does not increment the position.
+# - Method #rewind sets the position to zero.
+#
+# Examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+#
+# dir = Dir.new('example') # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.read # => "."
+# dir.read # => ".."
+# dir.read # => "config.h"
+# dir.read # => "lib"
+# dir.read # => "main.rb"
+# dir.pos # => 5
+# dir.read # => nil
+# dir.pos # => 5
+#
+# dir.rewind # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.pos = 3 # => 3
+# dir.pos # => 3
+#
+# dir.seek(4) # => #<Dir:example>
+# dir.pos # => 4
+#
+# dir.close # => nil
+# dir.read # Raises IOError.
#
# == What's Here
#
-# First, what's elsewhere. \Class \Dir:
+# First, what's elsewhere. Class \Dir:
#
-# - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
-# - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+# - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+# - Includes {module Enumerable}[rdoc-ref:Enumerable@Whats+Here],
# which provides dozens of additional methods.
#
# Here, class \Dir provides methods that are useful for:
@@ -80,20 +154,32 @@
# closing it upon block exit.
# - ::unlink (aliased as ::delete and ::rmdir): Removes the given directory.
# - #inspect: Returns a string description of +self+.
+#
class Dir
# call-seq:
- # Dir.open( string ) -> aDir
- # Dir.open( string, encoding: enc ) -> aDir
- # Dir.open( string ) {| aDir | block } -> anObject
- # Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
- #
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
- #
- # With no block, <code>open</code> is a synonym for Dir::new. If a
- # block is present, it is passed <i>aDir</i> as a parameter. The
- # directory is closed at the end of the block, and Dir::open returns
- # the value of the block.
+ # Dir.open(dirpath) -> dir
+ # Dir.open(dirpath, encoding: nil) -> dir
+ # Dir.open(dirpath) {|dir| ... } -> object
+ # Dir.open(dirpath, encoding: nil) {|dir| ... } -> object
+ #
+ # Creates a new \Dir object _dir_ for the directory at +dirpath+.
+ #
+ # With no block, the method equivalent to Dir.new(dirpath, encoding):
+ #
+ # Dir.open('.') # => #<Dir:.>
+ #
+ # With a block given, the block is called with the created _dir_;
+ # on block exit _dir_ is closed and the block's value is returned:
+ #
+ # Dir.open('.') {|dir| dir.inspect } # => "#<Dir:.>"
+ #
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.open('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.open('.', encoding: Encoding::US_ASCII).read.encoding # => #<Encoding:US-ASCII>
+ #
def self.open(name, encoding: nil, &block)
dir = Primitive.dir_s_open(name, encoding)
if block
@@ -108,115 +194,221 @@ class Dir
end
# call-seq:
- # Dir.new( string ) -> aDir
- # Dir.new( string, encoding: enc ) -> aDir
+ # Dir.new(dirpath) -> dir
+ # Dir.new(dirpath, encoding: nil) -> dir
+ #
+ # Returns a new \Dir object for the directory at +dirpath+:
+ #
+ # Dir.new('.') # => #<Dir:.>
#
- # Returns a new directory object for the named directory.
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.new('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.new('.', encoding: Encoding::US_ASCI).read.encoding # => #<Encoding:US-ASCII>
#
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
def initialize(name, encoding: nil)
Primitive.dir_initialize(name, encoding)
end
# call-seq:
- # Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
+ # Dir[*patterns, base: nil, sort: true] -> array
+ #
+ # Calls Dir.glob with argument +patterns+
+ # and the values of keyword arguments +base+ and +sort+;
+ # returns the array of selected entry names.
#
- # Equivalent to calling
- # <code>Dir.glob([</code><i>string,...</i><code>], 0)</code>.
def self.[](*args, base: nil, sort: true)
Primitive.dir_s_aref(args, base, sort)
end
# call-seq:
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) { |filename| block } -> nil
+ # Dir.glob(patterns, flags: 0, base: nil, sort: true) -> array
+ # Dir.glob(patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
#
- # Expands +pattern+, which is a pattern string or an Array of pattern
- # strings, and returns an array containing the matching filenames.
- # If a block is given, calls the block once for each matching filename,
- # passing the filename as a parameter to the block.
+ # Forms an array _entry_names_ of the entry names selected by the arguments.
#
- # The optional +base+ keyword argument specifies the base directory for
- # interpreting relative pathnames instead of the current working directory.
- # As the results are not prefixed with the base directory name in this
- # case, you will need to prepend the base directory name if you want real
- # paths.
+ # Argument +patterns+ is a string pattern or an array of string patterns;
+ # note that these are not regexps; see below.
#
- # The results which matched single wildcard or character set are sorted in
- # binary ascending order, unless +false+ is given as the optional +sort+
- # keyword argument. The order of an Array of pattern strings and braces
- # are preserved.
+ # Notes for the following examples:
#
- # Note that the pattern is not a regexp, it's closer to a shell glob.
- # See File::fnmatch for the meaning of the +flags+ parameter.
- # Case sensitivity depends on your system (+File::FNM_CASEFOLD+ is ignored).
+ # - <tt>'*'</tt> is the pattern that matches any entry name
+ # except those that begin with <tt>'.'</tt>.
+ # - We use method Array#take to shorten returned arrays
+ # that otherwise would be very large.
#
- # <code>*</code>::
- # Matches any file. Can be restricted by other values in the glob.
- # Equivalent to <code>/.*/mx</code> in regexp.
+ # With no block, returns array _entry_names_;
+ # example (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
#
- # <code>*</code>:: Matches all files
- # <code>c*</code>:: Matches all files beginning with <code>c</code>
- # <code>*c</code>:: Matches all files ending with <code>c</code>
- # <code>\*c\*</code>:: Match all files that have <code>c</code> in them
- # (including at the beginning or end).
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
#
- # Note, this will not match Unix-like hidden files (dotfiles). In order
- # to include those in the match results, you must use the
- # File::FNM_DOTMATCH flag or something like <code>"{*,.*}"</code>.
+ # With a block, calls the block with each of the _entry_names_
+ # and returns +nil+:
#
- # <code>**</code>::
- # Matches directories recursively if followed by <code>/</code>. If
- # this path segment contains any other characters, it is the same as the
- # usual <code>*</code>.
+ # Dir.glob('*') {|entry_name| puts entry_name } # => nil
#
- # <code>?</code>::
- # Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
+ # Output:
#
- # <code>[set]</code>::
- # Matches any one character in +set+. Behaves exactly like character sets
- # in Regexp, including set negation (<code>[^a-z]</code>).
+ # config.h
+ # lib
+ # main.rb
#
- # <code>{p,q}</code>::
- # Matches either literal <code>p</code> or literal <code>q</code>.
- # Equivalent to pattern alternation in regexp.
+ # If optional keyword argument +flags+ is given,
+ # the value modifies the matching; see below.
#
- # Matching literals may be more than one character in length. More than
- # two literals may be specified.
+ # If optional keyword argument +base+ is given,
+ # its value specifies the base directory.
+ # Each pattern string specifies entries relative to the base directory;
+ # the default is <tt>'.'</tt>.
+ # The base directory is not prepended to the entry names in the result:
#
- # <code>\\</code>::
- # Escapes the next metacharacter.
+ # Dir.glob(pattern, base: 'lib').take(5)
+ # # => ["abbrev.gemspec", "abbrev.rb", "base64.gemspec", "base64.rb", "benchmark.gemspec"]
+ # Dir.glob(pattern, base: 'lib/irb').take(5)
+ # # => ["cmd", "color.rb", "color_printer.rb", "completion.rb", "context.rb"]
#
- # Note that this means you cannot use backslash on windows as part of a
- # glob, i.e. <code>Dir["c:\\foo*"]</code> will not work, use
- # <code>Dir["c:/foo*"]</code> instead.
+ # If optional keyword +sort+ is given, its value specifies whether
+ # the array is to be sorted; the default is +true+.
+ # Passing value +false+ with that keyword disables sorting
+ # (though the underlying file system may already have sorted the array).
#
- # Examples:
+ # <b>Patterns</b>
+ #
+ # Each pattern string is expanded
+ # according to certain metacharacters;
+ # examples below use the {Ruby file tree}[rdoc-ref:Dir@About+the+Examples]:
+ #
+ # - <tt>'*'</tt>: Matches any substring in an entry name,
+ # similar in meaning to regexp <tt>/.*/mx</tt>;
+ # may be restricted by other values in the pattern strings:
+ #
+ # - <tt>'*'</tt> matches all entry names:
+ #
+ # Dir.glob('*').take(3) # => ["BSDL", "CONTRIBUTING.md", "COPYING"]
+ #
+ # - <tt>'c*'</tt> matches entry names beginning with <tt>'c'</tt>:
+ #
+ # Dir.glob('c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # - <tt>'*c'</tt> matches entry names ending with <tt>'c'</tt>:
+ #
+ # Dir.glob('*c').take(3) # => ["addr2line.c", "array.c", "ast.c"]
+ #
+ # - <tt>'\*c\*'</tt> matches entry names that contain <tt>'c'</tt>,
+ # even at the beginning or end:
+ #
+ # Dir.glob('*c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # Does not match Unix-like hidden entry names ("dot files").
+ # To include those in the matched entry names,
+ # use flag IO::FNM_DOTMATCH or something like <tt>'{*,.*}'</tt>.
+ #
+ # - <tt>'**'</tt>: Matches entry names recursively
+ # if followed by the slash character <tt>'/'</tt>:
+ #
+ # Dir.glob('**/').take(3) # => ["basictest/", "benchmark/", "benchmark/gc/"]
+ #
+ # If the string pattern contains other characters
+ # or is not followed by a slash character,
+ # it is equivalent to <tt>'*'</tt>.
+ #
+ # - <tt>'?'</tt> Matches any single character;
+ # similar in meaning to regexp <tt>/./</tt>:
+ #
+ # Dir.glob('io.?') # => ["io.c"]
+ #
+ # - <tt>'[set]'</tt>: Matches any one character in the string _set_;
+ # behaves like a {Regexp character class}[rdoc-ref:Regexp@Character+Classes],
+ # including set negation (<tt>'[^a-z]'</tt>):
+ #
+ # Dir.glob('*.[a-z][a-z]').take(3)
+ # # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"]
+ #
+ # - <tt>'{abc,xyz}'</tt>:
+ # Matches either string _abc_ or string _xyz_;
+ # behaves like {Regexp alternation}[rdoc-ref:Regexp@Alternation]:
+ #
+ # Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"]
+ #
+ # More than two alternatives may be given.
+ #
+ # - <tt>\\</tt>: Escapes the following metacharacter.
+ #
+ # Note that on Windows, the backslash character may not be used
+ # in a string pattern:
+ # <tt>Dir['c:\\foo*']</tt> will not work, use <tt>Dir['c:/foo*']</tt> instead.
+ #
+ # More examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+ #
+ # # We're in the example directory.
+ # File.basename(Dir.pwd) # => "example"
+ # Dir.glob('config.?') # => ["config.h"]
+ # Dir.glob('*.[a-z][a-z]') # => ["main.rb"]
+ # Dir.glob('*.[^r]*') # => ["config.h"]
+ # Dir.glob('*.{rb,h}') # => ["main.rb", "config.h"]
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
+ # Dir.glob('*', File::FNM_DOTMATCH) # => [".", "config.h", "lib", "main.rb"]
+ # Dir.glob(["*.rb", "*.h"]) # => ["main.rb", "config.h"]
+ #
+ # Dir.glob('**/*.rb')
+ # => ["lib/song/karaoke.rb", "lib/song.rb", "main.rb"]
+ #
+ # Dir.glob('**/*.rb', base: 'lib') # => ["song/karaoke.rb", "song.rb"]
+ #
+ # Dir.glob('**/lib') # => ["lib"]
+ #
+ # Dir.glob('**/lib/**/*.rb') # => ["lib/song/karaoke.rb", "lib/song.rb"]
+ #
+ # Dir.glob('**/lib/*.rb') # => ["lib/song.rb"]
+ #
+ # <b>Flags</b>
+ #
+ # If optional keyword argument +flags+ is given (the default is zero -- no flags),
+ # its value should be the bitwise OR of one or more of the constants
+ # defined in module File::Constants.
+ #
+ # Example:
+ #
+ # flags = File::FNM_EXTGLOB | File::FNM_DOTMATCH
+ #
+ # Specifying flags can extend, restrict, or otherwise modify the matching.
+ #
+ # The flags for this method (other constants in File::Constants do not apply):
+ #
+ # - File::FNM_DOTMATCH:
+ # specifies that entry names beginning with <tt>'.'</tt>
+ # should be considered for matching:
+ #
+ # Dir.glob('*').take(5)
+ # # => ["BSDL", "CONTRIBUTING.md", "COPYING", "COPYING.ja", "GPL"]
+ # Dir.glob('*', flags: File::FNM_DOTMATCH).take(5)
+ # # => [".", ".appveyor.yml", ".cirrus.yml", ".dir-locals.el", ".document"]
#
- # Dir["config.?"] #=> ["config.h"]
- # Dir.glob("config.?") #=> ["config.h"]
- # Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
- # Dir.glob("*.[^r]*") #=> ["config.h"]
- # Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
- # Dir.glob("*") #=> ["config.h", "main.rb"]
- # Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "config.h", "main.rb"]
- # Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
+ # - File::FNM_EXTGLOB:
+ # enables the pattern extension
+ # <tt>'{a,b}'</tt>, which matches pattern _a_ and pattern _b_;
+ # behaves like a
+ # {regexp union}[rdoc-ref:Regexp.union]
+ # (e.g., <tt>'(?:a|b)'</tt>):
#
- # Dir.glob("**/*.rb") #=> ["main.rb",
- # # "lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # pattern = '{LEGAL,BSDL}'
+ # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
#
- # Dir.glob("**/*.rb", base: "lib") #=> ["song.rb",
- # # "song/karaoke.rb"]
+ # - File::FNM_NOESCAPE:
+ # specifies that escaping with the backslash character <tt>'\'</tt>
+ # is disabled; the character is not an escape character.
#
- # Dir.glob("**/lib") #=> ["lib"]
+ # - File::FNM_PATHNAME:
+ # specifies that metacharacters <tt>'*'</tt> and <tt>'?'</tt>
+ # do not match directory separators.
#
- # Dir.glob("**/lib/**/*.rb") #=> ["lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # - File::FNM_SHORTNAME:
+ # specifies that patterns may match short names if they exist; Windows only.
#
- # Dir.glob("**/lib/*.rb") #=> ["lib/song.rb"]
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true)
+ Primitive.attr! :use_block
Primitive.dir_s_glob(pattern, flags, base, sort)
end
end
diff --git a/dln.c b/dln.c
index 0edd709bbe..d3b03e3e87 100644
--- a/dln.c
+++ b/dln.c
@@ -25,6 +25,7 @@ static void dln_loaderror(const char *format, ...);
#endif
#include "dln.h"
#include "internal.h"
+#include "internal/box.h"
#include "internal/compilers.h"
#ifdef HAVE_STDLIB_H
@@ -76,6 +77,10 @@ void *xrealloc();
# include <unistd.h>
#endif
+#ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(x) return (x)
+#endif
+
#ifndef dln_loaderror
static void
dln_loaderror(const char *format, ...)
@@ -107,36 +112,45 @@ dln_loaderror(const char *format, ...)
#endif
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
-static size_t
-init_funcname_len(const char **file)
+struct string_part {
+ const char *ptr;
+ size_t len;
+};
+
+static struct string_part
+init_funcname_len(const char *file)
{
- const char *p = *file, *base, *dot = NULL;
+ const char *p = file, *base, *dot = NULL;
/* Load the file as an object one */
for (base = p; *p; p++) { /* Find position of last '/' */
if (*p == '.' && !dot) dot = p;
if (isdirsep(*p)) base = p+1, dot = NULL;
}
- *file = base;
/* Delete suffix if it exists */
- return (dot ? dot : p) - base;
+ const size_t len = (dot ? dot : p) - base;
+ return (struct string_part){base, len};
+}
+
+static inline char *
+concat_funcname(char *buf, const char *prefix, size_t plen, const struct string_part base)
+{
+ if (!buf) {
+ dln_memerror();
+ }
+ memcpy(buf, prefix, plen);
+ memcpy(buf + plen, base.ptr, base.len);
+ buf[plen + base.len] = '\0';
+ return buf;
}
-static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;
-
-#define init_funcname(buf, file) do {\
- const char *base = (file);\
- const size_t flen = init_funcname_len(&base);\
- const size_t plen = sizeof(funcname_prefix);\
- char *const tmp = ALLOCA_N(char, plen+flen+1);\
- if (!tmp) {\
- dln_memerror();\
- }\
- memcpy(tmp, funcname_prefix, plen);\
- memcpy(tmp+plen, base, flen);\
- tmp[plen+flen] = '\0';\
- *(buf) = tmp;\
+#define build_funcname(prefix, buf, file) do {\
+ const struct string_part f = init_funcname_len(file);\
+ const size_t plen = sizeof(prefix "") - 1;\
+ *(buf) = concat_funcname(ALLOCA_N(char, plen+f.len+1), prefix, plen, f);\
} while (0)
+
+#define init_funcname(buf, file) build_funcname(FUNCNAME_PREFIX, buf, file)
#endif
#ifdef USE_DLN_DLOPEN
@@ -272,13 +286,15 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine)
static bool
dln_incompatible_func(void *handle, const char *funcname, void *const fp, const char **libname)
{
- Dl_info dli;
void *ex = dlsym(handle, funcname);
if (!ex) return false;
if (ex == fp) return false;
+# if defined(HAVE_DLADDR) && !defined(__CYGWIN__)
+ Dl_info dli;
if (dladdr(ex, &dli)) {
*libname = dli.dli_fname;
}
+# endif
return true;
}
@@ -336,6 +352,7 @@ dln_open(const char *file)
void *handle;
#if defined(_WIN32)
+# define DLN_DEFINED
char message[1024];
/* Convert the file path to wide char */
@@ -362,6 +379,7 @@ dln_open(const char *file)
# endif
#elif defined(USE_DLN_DLOPEN)
+# define DLN_DEFINED
# ifndef RTLD_LAZY
# define RTLD_LAZY 1
@@ -372,9 +390,13 @@ dln_open(const char *file)
# ifndef RTLD_GLOBAL
# define RTLD_GLOBAL 0
# endif
+# ifndef RTLD_LOCAL
+# define RTLD_LOCAL 0 /* TODO: 0??? some systems (including libc) use 0x00100 for RTLD_GLOBAL, 0x00000 for RTLD_LOCAL */
+# endif
/* Load file */
- handle = dlopen(file, RTLD_LAZY|RTLD_GLOBAL);
+ int mode = rb_box_available() ? RTLD_LAZY|RTLD_LOCAL : RTLD_LAZY|RTLD_GLOBAL;
+ handle = dlopen(file, mode);
if (handle == NULL) {
error = dln_strerror();
goto failed;
@@ -392,6 +414,12 @@ dln_open(const char *file)
dln_fatalerror("%s - %s", incompatible, file);
}
else {
+ if (libruby_name) {
+ const size_t len = strlen(libruby_name);
+ char *const tmp = ALLOCA_N(char, len + 1);
+ if (tmp) memcpy(tmp, libruby_name, len + 1);
+ libruby_name = tmp;
+ }
dlclose(handle);
if (libruby_name) {
dln_loaderror("linked to incompatible %s - %s", libruby_name, file);
@@ -413,33 +441,63 @@ dln_open(const char *file)
static void *
dln_sym(void *handle, const char *symbol)
{
- void *func;
- const char *error;
-
#if defined(_WIN32)
- char message[1024];
+ return GetProcAddress(handle, symbol);
+#elif defined(USE_DLN_DLOPEN)
+ return dlsym(handle, symbol);
+#endif
+}
+
+static uintptr_t
+dln_sym_func(void *handle, const char *symbol)
+{
+ void *func = dln_sym(handle, symbol);
- func = GetProcAddress(handle, symbol);
if (func == NULL) {
+ const char *error;
+#if defined(_WIN32)
+ char message[1024];
error = dln_strerror();
- goto failed;
- }
-
#elif defined(USE_DLN_DLOPEN)
- func = dlsym(handle, symbol);
- if (func == NULL) {
const size_t errlen = strlen(error = dln_strerror()) + 1;
error = memcpy(ALLOCA_N(char, errlen), error, errlen);
- goto failed;
- }
#endif
+ dln_loaderror("%s - %s", error, symbol);
+ }
+ return (uintptr_t)func;
+}
- return func;
+#define dln_sym_callable(rettype, argtype, handle, symbol) \
+ (*(rettype (*)argtype)dln_sym_func(handle, symbol))
+#endif
- failed:
- dln_loaderror("%s - %s", error, symbol);
-}
+void *
+dln_symbol(void *handle, const char *symbol)
+{
+#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
+ if (EXTERNAL_PREFIX[0]) {
+ const size_t symlen = strlen(symbol);
+ char *const tmp = ALLOCA_N(char, symlen + sizeof(EXTERNAL_PREFIX));
+ if (!tmp) dln_memerror();
+ memcpy(tmp, EXTERNAL_PREFIX, sizeof(EXTERNAL_PREFIX) - 1);
+ memcpy(tmp + sizeof(EXTERNAL_PREFIX) - 1, symbol, symlen + 1);
+ symbol = tmp;
+ }
+ if (handle == NULL) {
+# if defined(USE_DLN_DLOPEN)
+ handle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
+# elif defined(_WIN32)
+ handle = rb_libruby_handle();
+# else
+ return NULL;
+# endif
+ }
+ return dln_sym(handle, symbol);
+#else
+ return NULL;
#endif
+}
+
#if defined(RUBY_DLN_CHECK_ABI) && defined(USE_DLN_DLOPEN)
static bool
@@ -450,33 +508,32 @@ abi_check_enabled_p(void)
}
#endif
-void *
-dln_load(const char *file)
+static void *
+dln_load_and_init(const char *file, const char *init_fct_name)
{
-#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
+#if defined(DLN_DEFINED)
void *handle = dln_open(file);
#ifdef RUBY_DLN_CHECK_ABI
- unsigned long long (*abi_version_fct)(void) = (unsigned long long(*)(void))dln_sym(handle, "ruby_abi_version");
- unsigned long long binary_abi_version = (*abi_version_fct)();
- if (binary_abi_version != ruby_abi_version() && abi_check_enabled_p()) {
+ typedef unsigned long long abi_version_number;
+ abi_version_number binary_abi_version =
+ dln_sym_callable(abi_version_number, (void), handle, EXTERNAL_PREFIX "ruby_abi_version")();
+ if (binary_abi_version != RUBY_ABI_VERSION && abi_check_enabled_p()) {
dln_loaderror("incompatible ABI version of binary - %s", file);
}
#endif
- char *init_fct_name;
- init_funcname(&init_fct_name, file);
- void (*init_fct)(void) = (void(*)(void))dln_sym(handle, init_fct_name);
-
/* Call the init code */
- (*init_fct)();
+ dln_sym_callable(void, (void), handle, init_fct_name)();
return handle;
#elif defined(_AIX)
+# define DLN_DEFINED
{
void (*init_fct)(void);
+ /* TODO: check - AIX's load system call will return the first/last symbol/function? */
init_fct = (void(*)(void))load((char*)file, 1, 0);
if (init_fct == NULL) {
aix_loaderror(file);
@@ -489,7 +546,25 @@ dln_load(const char *file)
}
#else
dln_notimplement();
+ UNREACHABLE_RETURN(0);
#endif
+}
- return 0; /* dummy return */
+void *
+dln_load(const char *file)
+{
+ return dln_load_feature(file, file);
+}
+
+void *
+dln_load_feature(const char *file, const char *fname)
+{
+#if defined(DLN_DEFINED)
+ char *init_fct_name;
+ init_funcname(&init_fct_name, fname);
+ return dln_load_and_init(file, init_fct_name);
+#else
+ dln_notimplement();
+ UNREACHABLE_RETURN(0);
+#endif
}
diff --git a/dln.h b/dln.h
index 902f753450..711abf592c 100644
--- a/dln.h
+++ b/dln.h
@@ -25,6 +25,8 @@ RUBY_SYMBOL_EXPORT_BEGIN
char *dln_find_exe_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
char *dln_find_file_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
void *dln_load(const char*);
+void *dln_load_feature(const char*, const char*);
+void *dln_symbol(void*,const char*);
RUBY_SYMBOL_EXPORT_END
diff --git a/dln_find.c b/dln_find.c
index 5d380f5d39..ae37b9dde4 100644
--- a/dln_find.c
+++ b/dln_find.c
@@ -11,11 +11,9 @@
#ifdef RUBY_EXPORT
#include "ruby/ruby.h"
-#define dln_warning rb_warning
-#define dln_warning_arg
+#define dln_warning(...) rb_warning(__VA_ARGS__)
#else
-#define dln_warning fprintf
-#define dln_warning_arg stderr,
+#define dln_warning(...) fprintf(stderr, __VA_ARGS__)
#endif
#include "dln.h"
@@ -75,7 +73,7 @@ dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size
".";
}
buf = dln_find_1(fname, path, buf, size, 1 DLN_FIND_EXTRA_ARG);
- if (envpath) free(envpath);
+ free(envpath);
return buf;
}
@@ -109,7 +107,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\
\tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n";
-#define PATHNAME_TOO_LONG() dln_warning(dln_warning_arg pathname_too_long, \
+#define PATHNAME_TOO_LONG() dln_warning(pathname_too_long, \
((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \
((bp - fbuf) > 100 ? "..." : ""), \
(fnlen > 100 ? 100 : (int)fnlen), fname, \
@@ -120,8 +118,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
RETURN_IF(!fname);
fnlen = strlen(fname);
if (fnlen >= size) {
- dln_warning(dln_warning_arg
- "openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
+ dln_warning("openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
(fnlen > 100 ? 100 : (int)fnlen), fname,
(fnlen > 100 ? "..." : ""));
return NULL;
diff --git a/dmydln.c b/dmydln.c
index d05cda0b8e..62a89e2da5 100644
--- a/dmydln.c
+++ b/dmydln.c
@@ -1,3 +1,6 @@
+// This file is used by miniruby, not ruby.
+// ruby uses dln.c.
+
#include "ruby/ruby.h"
NORETURN(void *dln_load(const char *));
@@ -8,3 +11,21 @@ dln_load(const char *file)
UNREACHABLE_RETURN(NULL);
}
+
+NORETURN(void *dln_load_feature(const char*,const char*));
+void*
+dln_load_feature(const char *file, const char *fname)
+{
+ rb_loaderror("this executable file can't load extension libraries");
+
+ UNREACHABLE_RETURN(NULL);
+}
+
+NORETURN(void *dln_symbol(void*,const char*));
+void*
+dln_symbol(void *handle, const char *symbol)
+{
+ rb_loaderror("this executable file can't load extension libraries");
+
+ UNREACHABLE_RETURN(NULL);
+}
diff --git a/dmyenc.c b/dmyenc.c
index 75b8a2da43..4771841281 100644
--- a/dmyenc.c
+++ b/dmyenc.c
@@ -1,3 +1,17 @@
+// This file is used by dynamically-linked ruby, which has no
+// statically-linked encodings other than the builtin encodings.
+//
+// - miniruby does not use this Init_enc. Instead, "miniinit.c"
+// provides Init_enc, which defines only the builtin encodings.
+//
+// - Dynamically-linked ruby uses this Init_enc, which requires
+// "enc/encdb.so" to load the builtin encodings and set up the
+// optional encodings.
+//
+// - Statically-linked ruby does not use this Init_enc. Instead,
+// "enc/encinit.c" (which is a generated file) defines Init_enc,
+// which activates the encodings.
+
#define require(name) ruby_require_internal(name, (unsigned int)sizeof(name)-1)
int ruby_require_internal(const char *, int);
diff --git a/dmyext.c b/dmyext.c
index 4d273f7faf..66be95ab4e 100644
--- a/dmyext.c
+++ b/dmyext.c
@@ -1,3 +1,17 @@
+// This file is used by dynamically-linked ruby, which has no
+// statically-linked extension libraries.
+//
+// - miniruby does not use this Init_ext. Instead, "miniinit.c"
+// provides Init_enc, which does nothing too. It does not support
+// require'ing extension libraries.
+//
+// - Dynamically-linked ruby uses this Init_ext, which does
+// nothing. It loads extension libraries by dlopen, etc.
+//
+// - Statically-linked ruby does not use this Init_ext. Instead,
+// "ext/extinit.c" (which is a generated file) defines Init_ext,
+// which activates the (statically-linked) extension libraries.
+
void
Init_ext(void)
{
diff --git a/doc/.document b/doc/.document
index 5ef2d99651..337289a662 100644
--- a/doc/.document
+++ b/doc/.document
@@ -1,8 +1,14 @@
-*.md
-*.rb
-*.rdoc
+[^_]*.md
+[^_]*.rb
+[^_]*.rdoc
contributing
+distribution
NEWS
syntax
optparse
-rdoc
+jit
+security
+language
+strscan
+file
+
diff --git a/doc/ChangeLog/ChangeLog-1.9.3 b/doc/ChangeLog/ChangeLog-1.9.3
index 0f80eed2d5..03a7f3eabf 100644
--- a/doc/ChangeLog/ChangeLog-1.9.3
+++ b/doc/ChangeLog/ChangeLog-1.9.3
@@ -9012,7 +9012,7 @@ Thu Dec 2 01:24:39 2010 NARUSE, Yui <naruse@ruby-lang.org>
Thu Dec 2 01:02:03 2010 NARUSE, Yui <naruse@ruby-lang.org>
- * ext/json: Update github/flori/json from 1.4.2+ to
+ * ext/json: Update github/ruby/json from 1.4.2+ to
e22b2f2bdfe6a9b0. this fixes some bugs.
Thu Dec 2 00:05:44 2010 NARUSE, Yui <naruse@ruby-lang.org>
diff --git a/doc/ChangeLog/ChangeLog-2.0.0 b/doc/ChangeLog/ChangeLog-2.0.0
index 9e654db189..de47b66a69 100644
--- a/doc/ChangeLog/ChangeLog-2.0.0
+++ b/doc/ChangeLog/ChangeLog-2.0.0
@@ -14426,7 +14426,7 @@ Tue May 8 02:34:26 2012 NARUSE, Yui <naruse@ruby-lang.org>
Mon May 7 21:19:17 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: Merge JSON 1.7.1.
- https://github.com/flori/json/commit/e5b9a9465c1159fae533bca320d950b772bcb4ac
+ https://github.com/ruby/json/commit/e5b9a9465c1159fae533bca320d950b772bcb4ac
Mon May 7 22:54:22 2012 Martin Bosslet <Martin.Bosslet@googlemail.com>
diff --git a/doc/ChangeLog/ChangeLog-2.1.0 b/doc/ChangeLog/ChangeLog-2.1.0
index 5b670b31c9..b6977dbccd 100644
--- a/doc/ChangeLog/ChangeLog-2.1.0
+++ b/doc/ChangeLog/ChangeLog-2.1.0
@@ -659,7 +659,7 @@ Mon Dec 9 02:10:32 2013 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/http/responses.rb:
Add `HTTPIMUsed`, as it is also supported by rack/rails.
- RFC - http://tools.ietf.org/html/rfc3229
+ RFC - https://www.rfc-editor.org/rfc/rfc3229
by Vipul A M <vipulnsward@gmail.com>
https://github.com/ruby/ruby/pull/447 fix GH-447
@@ -2167,7 +2167,7 @@ Wed Nov 20 11:46:38 2013 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: merge JSON 1.8.1.
https://github.com/nurse/json/compare/002ac2771ce32776b32ccd2d06e5604de6c36dcd...e09ffc0d7da25d0393873936c118c188c78dbac3
* Remove Rubinius exception since transcoding should be working now.
- * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre
+ * Fix https://github.com/ruby/json/issues/162 reported by Marc-Andre
Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
warning with -Wchar-subscripts and better validate UTF-8 strings.
@@ -17913,7 +17913,7 @@ Tue Feb 12 12:02:35 2013 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: merge JSON 1.7.7.
This includes security fix. [CVE-2013-0269]
- https://github.com/flori/json/commit/d0a62f3ced7560daba2ad546d83f0479a5ae2cf2
+ https://github.com/ruby/json/commit/d0a62f3ced7560daba2ad546d83f0479a5ae2cf2
https://groups.google.com/d/topic/rubyonrails-security/4_YvCpLzL58/discussion
Mon Feb 11 23:08:48 2013 Tanaka Akira <akr@fsij.org>
diff --git a/doc/ChangeLog/ChangeLog-2.2.0 b/doc/ChangeLog/ChangeLog-2.2.0
index 5a7dbf826d..0edcf0122b 100644
--- a/doc/ChangeLog/ChangeLog-2.2.0
+++ b/doc/ChangeLog/ChangeLog-2.2.0
@@ -5648,7 +5648,7 @@ Wed Aug 6 04:16:05 2014 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/http/requests.rb (Net::HTTP::Options::RESPONSE_HAS_BODY):
OPTIONS requests may have response bodies. [Feature #8429]
- http://tools.ietf.org/html/rfc7231#section-4.3.7
+ https://www.rfc-editor.org/rfc/rfc7231#section-4.3.7
Wed Aug 6 03:18:04 2014 NARUSE, Yui <naruse@ruby-lang.org>
diff --git a/doc/ChangeLog/ChangeLog-2.3.0 b/doc/ChangeLog/ChangeLog-2.3.0
index 94996cffd0..e616183895 100644
--- a/doc/ChangeLog/ChangeLog-2.3.0
+++ b/doc/ChangeLog/ChangeLog-2.3.0
@@ -1211,7 +1211,7 @@ Sun Dec 6 08:39:05 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
upstream changes.
https://github.com/ruby/ruby/commit/4d059bf9f5f10f3d3088de49fc87e5555db7770d
- https://github.com/flori/json/commit/d4c99de78905d96c3f301f48b2c789943bb3f098
+ https://github.com/ruby/json/commit/d4c99de78905d96c3f301f48b2c789943bb3f098
* ext/json/lib/json/version.rb: ditto.
@@ -10989,7 +10989,7 @@ Fri Feb 13 21:16:00 2015 Yusuke Endoh <mame@tsg.ne.jp>
Fri Feb 13 14:19:06 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
- * ext/json: merge upstream from flori/json
+ * ext/json: merge upstream from ruby/json
change usage of TypedData. [Feature #10739][ruby-core:67564]
Thu Feb 12 18:34:01 2015 multisnow <infinity.blick.winkel@gmail.com>
@@ -11556,7 +11556,7 @@ Tue Jan 13 21:08:22 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* ext/json, test/json: merge JSON HEAD(259dee6)
separate implementation of Typed_Data macro.
- https://github.com/flori/json/compare/v1.8.1...v1.8.2
+ https://github.com/ruby/json/compare/v1.8.1...v1.8.2
Tue Jan 13 14:16:35 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -12009,7 +12009,7 @@ Mon Dec 29 10:37:27 2014 Thiago Lewin <thiago_lewin@yahoo.com.br>
Mon Dec 29 07:27:23 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* ext/json, test/json: merge JSON HEAD(17fe8e7)
- https://github.com/flori/json/compare/v1.8.1...17fe8e7
+ https://github.com/ruby/json/compare/v1.8.1...17fe8e7
Sun Dec 28 23:49:37 2014 Michal Papis <mpapis@gmail.com>
diff --git a/doc/ChangeLog/ChangeLog-2.4.0 b/doc/ChangeLog/ChangeLog-2.4.0
index a297a579d1..5e126fbd90 100644
--- a/doc/ChangeLog/ChangeLog-2.4.0
+++ b/doc/ChangeLog/ChangeLog-2.4.0
@@ -2668,8 +2668,8 @@ Wed Jul 6 07:11:27 2016 Shugo Maeda <shugo@ruby-lang.org>
Tue Jul 5 20:49:30 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* ext/json/*, test/json/*: Update json-2.0.1.
- Changes of 2.0.0: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2015-09-11-200
- Changes of 2.0.1: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2016-07-01-201
+ Changes of 2.0.0: https://github.com/ruby/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2015-09-11-200
+ Changes of 2.0.1: https://github.com/ruby/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2016-07-01-201
[Feature #12542][ruby-dev:49706][fix GH-1395]
Tue Jul 5 19:39:49 2016 Naohisa Goto <ngotogenome@gmail.com>
@@ -7356,7 +7356,7 @@ Thu Mar 17 11:51:48 2016 NARUSE, Yui <naruse@ruby-lang.org>
Note: CryptGenRandom function is PRNG and doesn't check its entropy,
so it won't block. [Bug #12139]
https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa379942.aspx
- https://tools.ietf.org/html/rfc4086#section-7.1.3
+ https://www.rfc-editor.org/rfc/rfc4086#section-7.1.3
https://eprint.iacr.org/2007/419.pdf
http://www.cs.huji.ac.il/~dolev/pubs/thesis/msc-thesis-leo.pdf
diff --git a/doc/NEWS/NEWS-3.0.0.md b/doc/NEWS/NEWS-3.0.0.md
index bdbd47327b..9fbaf504b4 100644
--- a/doc/NEWS/NEWS-3.0.0.md
+++ b/doc/NEWS/NEWS-3.0.0.md
@@ -367,11 +367,11 @@ Outstanding ones only.
* Fiber.blocking? tells whether the current execution context is
blocking. [[Feature #16786]]
+* Thread
+
* Thread#join invokes the scheduler hooks `block`/`unblock` in a
non-blocking execution context. [[Feature #16786]]
-* Thread
-
* Thread.ignore_deadlock accessor has been added for disabling the
default deadlock detection, allowing the use of signal handlers to
break deadlock. [[Bug #13768]]
@@ -741,7 +741,7 @@ end
foo(42)
```
-```
+```console
$ typeprof test.rb
# Classes
class Object
diff --git a/doc/NEWS/NEWS-3.1.0.md b/doc/NEWS/NEWS-3.1.0.md
index fe292fc414..686003894e 100644
--- a/doc/NEWS/NEWS-3.1.0.md
+++ b/doc/NEWS/NEWS-3.1.0.md
@@ -552,7 +552,7 @@ Example: `title = json[:article][:title]`
If `json` is nil, it shows:
-```
+```console
$ ruby test.rb
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
@@ -562,7 +562,7 @@ title = json[:article][:title]
If `json[:article]` returns nil, it shows:
-```
+```console
$ ruby test.rb
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
diff --git a/doc/NEWS/NEWS-3.2.0.md b/doc/NEWS/NEWS-3.2.0.md
index 33a7b85c47..3a48c1964d 100644
--- a/doc/NEWS/NEWS-3.2.0.md
+++ b/doc/NEWS/NEWS-3.2.0.md
@@ -623,13 +623,13 @@ The following deprecated methods are removed.
Psych and fiddle supported the static build with specific version of libyaml
and libffi sources. You can build psych with libyaml-0.2.5 like this.
- ```bash
+ ```console
$ ./configure --with-libyaml-source-dir=/path/to/libyaml-0.2.5
```
And you can build fiddle with libffi-3.4.4 like this.
- ```bash
+ ```console
$ ./configure --with-libffi-source-dir=/path/to/libffi-3.4.4
```
diff --git a/doc/NEWS/NEWS-3.3.0.md b/doc/NEWS/NEWS-3.3.0.md
new file mode 100644
index 0000000000..364786d754
--- /dev/null
+++ b/doc/NEWS/NEWS-3.3.0.md
@@ -0,0 +1,529 @@
+# NEWS for Ruby 3.3.0
+
+This document is a list of user-visible feature changes
+since the **3.2.0** release, except for bug fixes.
+
+Note that each entry is kept to a minimum, see links for details.
+
+## Command line options
+
+* A new `performance` warning category was introduced.
+ They are not displayed by default even in verbose mode.
+ Turn them on with `-W:performance` or `Warning[:performance] = true`. [[Feature #19538]]
+
+* A new `RUBY_CRASH_REPORT` environment variable was introduced to allow
+ redirecting Ruby crash reports to a file or sub command. See the `BUG REPORT ENVIRONMENT`
+ section of the ruby manpage for further details. [[Feature #19790]]
+
+## Core classes updates
+
+Note: We're only listing outstanding class updates.
+
+* Array
+
+ * Array#pack now raises ArgumentError for unknown directives. [[Bug #19150]]
+
+* Dir
+
+ * Dir.for_fd added for returning a Dir object for the directory specified
+ by the provided directory file descriptor. [[Feature #19347]]
+ * Dir.fchdir added for changing the directory to the directory specified
+ by the provided directory file descriptor. [[Feature #19347]]
+ * Dir#chdir added for changing the directory to the directory specified by
+ the provided `Dir` object. [[Feature #19347]]
+
+* Encoding
+
+ * `Encoding#replicate` has been removed, it was already deprecated. [[Feature #18949]]
+
+* Fiber
+
+ * Introduce Fiber#kill. [[Bug #595]]
+
+ ```ruby
+ fiber = Fiber.new do
+ while true
+ puts "Yielding..."
+ Fiber.yield
+ end
+ ensure
+ puts "Exiting..."
+ end
+
+ fiber.resume
+ # Yielding...
+ fiber.kill
+ # Exiting...
+ ```
+
+* MatchData
+
+ * MatchData#named_captures now accepts optional `symbolize_names`
+ keyword. [[Feature #19591]]
+
+* Module
+
+ * Module#set_temporary_name added for setting a temporary name for a
+ module. [[Feature #19521]]
+
+* ObjectSpace::WeakKeyMap
+
+ * New core class to build collections with weak references.
+ The class use equality semantic to lookup keys like a regular hash,
+ but it doesn't hold strong references on the keys. [[Feature #18498]]
+
+* ObjectSpace::WeakMap
+
+ * ObjectSpace::WeakMap#delete was added to eagerly clear weak map
+ entries. [[Feature #19561]]
+
+* Proc
+ * Now Proc#dup and Proc#clone call `#initialize_dup` and `#initialize_clone`
+ hooks respectively. [[Feature #19362]]
+
+* Process
+
+ * New Process.warmup method that notify the Ruby virtual machine that the boot sequence is finished,
+ and that now is a good time to optimize the application. This is useful
+ for long-running applications. The actual optimizations performed are entirely
+ implementation-specific and may change in the future without notice. [[Feature #18885]]
+
+* Process::Status
+
+ * Process::Status#& and Process::Status#>> are deprecated. [[Bug #19868]]
+
+* Range
+
+ * Range#reverse_each can now process beginless ranges with an Integer endpoint. [[Feature #18515]]
+ * Range#reverse_each now raises TypeError for endless ranges. [[Feature #18551]]
+ * Range#overlap? added for checking if two ranges overlap. [[Feature #19839]]
+
+* Refinement
+
+ * Add Refinement#target as an alternative of Refinement#refined_class.
+ Refinement#refined_class is deprecated and will be removed in Ruby
+ 3.4. [[Feature #19714]]
+
+* Regexp
+
+ * The cache-based optimization now supports lookarounds and atomic groupings. That is, match
+ for Regexp containing these extensions can now also be performed in linear time to the length
+ of the input string. However, these cannot contain captures and cannot be nested. [[Feature #19725]]
+
+* String
+
+ * String#unpack now raises ArgumentError for unknown directives. [[Bug #19150]]
+ * String#bytesplice now accepts new arguments index/length or range of the
+ source string to be copied. [[Feature #19314]]
+
+* Thread::Queue
+
+ * Thread::Queue#freeze now raises TypeError. [[Bug #17146]]
+
+* Thread::SizedQueue
+
+ * Thread::SizedQueue#freeze now raises TypeError. [[Bug #17146]]
+
+* Time
+
+ * Time.new with a string argument became stricter. [[Bug #19293]]
+
+ ```ruby
+ Time.new('2023-12-20')
+ # no time information (ArgumentError)
+ ```
+
+* TracePoint
+
+ * TracePoint supports `rescue` event. When the raised exception was rescued,
+ the TracePoint will fire the hook. `rescue` event only supports Ruby-level
+ `rescue`. [[Feature #19572]]
+
+## Stdlib updates
+
+* RubyGems and Bundler warn if users do `require` the following gems without adding them to Gemfile or gemspec.
+ This is because they will become the bundled gems in the future version of Ruby. This warning is suppressed
+ if you use bootsnap gem. We recommend to run your application with `DISABLE_BOOTSNAP=1` environmental variable
+ at least once. This is limitation of this version.
+ [[Feature #19351]] [[Feature #19776]] [[Feature #19843]]
+ * abbrev
+ * base64
+ * bigdecimal
+ * csv
+ * drb
+ * getoptlong
+ * mutex_m
+ * nkf
+ * observer
+ * racc
+ * resolv-replace
+ * rinda
+ * syslog
+
+* Socket#recv and Socket#recv_nonblock returns `nil` instead of an empty string on closed
+ connections. Socket#recvmsg and Socket#recvmsg_nonblock returns `nil` instead of an empty packet on closed
+ connections. [[Bug #19012]]
+
+* Name resolution such as Socket.getaddrinfo, Socket.getnameinfo, Addrinfo.getaddrinfo, etc.
+ can now be interrupted. [[Feature #19965]]
+
+* Random::Formatter#alphanumeric is extended to accept optional `chars`
+ keyword argument. [[Feature #18183]]
+
+The following default gem is added.
+
+* prism 0.19.0
+
+The following default gems are updated.
+
+* RubyGems 3.5.3
+* abbrev 0.1.2
+* base64 0.2.0
+* benchmark 0.3.0
+* bigdecimal 3.1.5
+* bundler 2.5.3
+* cgi 0.4.1
+* csv 3.2.8
+* date 3.3.4
+* delegate 0.3.1
+* drb 2.2.0
+* english 0.8.0
+* erb 4.0.3
+* error_highlight 0.6.0
+* etc 1.4.3
+* fcntl 1.1.0
+* fiddle 1.1.2
+* fileutils 1.7.2
+* find 0.2.0
+* getoptlong 0.2.1
+* io-console 0.7.1
+* io-nonblock 0.3.0
+* io-wait 0.3.1
+* ipaddr 1.2.6
+* irb 1.11.0
+* json 2.7.1
+* logger 1.6.0
+* mutex_m 0.2.0
+* net-http 0.4.0
+* net-protocol 0.2.2
+* nkf 0.1.3
+* observer 0.1.2
+* open-uri 0.4.1
+* open3 0.2.1
+* openssl 3.2.0
+* optparse 0.4.0
+* ostruct 0.6.0
+* pathname 0.3.0
+* pp 0.5.0
+* prettyprint 0.2.0
+* pstore 0.1.3
+* psych 5.1.2
+* rdoc 6.6.2
+* readline 0.0.4
+* reline 0.4.1
+* resolv 0.3.0
+* rinda 0.2.0
+* securerandom 0.3.1
+* set 1.1.0
+* shellwords 0.2.0
+* singleton 0.2.0
+* stringio 3.1.0
+* strscan 3.0.7
+* syntax_suggest 2.0.0
+* syslog 0.1.2
+* tempfile 0.2.1
+* time 0.3.0
+* timeout 0.4.1
+* tmpdir 0.2.0
+* tsort 0.2.0
+* un 0.3.0
+* uri 0.13.0
+* weakref 0.1.3
+* win32ole 1.8.10
+* yaml 0.3.0
+* zlib 3.1.0
+
+The following bundled gem is promoted from default gems.
+
+* racc 1.7.3
+
+The following bundled gems are updated.
+
+* minitest 5.20.0
+* rake 13.1.0
+* test-unit 3.6.1
+* rexml 3.2.6
+* rss 0.3.0
+* net-ftp 0.3.3
+* net-imap 0.4.9
+* net-smtp 0.4.0
+* rbs 3.4.0
+* typeprof 0.21.9
+* debug 1.9.1
+
+See GitHub releases like [Logger](https://github.com/ruby/logger/releases) or
+changelog for details of the default gems or bundled gems.
+
+### Prism
+
+* Introduced [the Prism parser](https://github.com/ruby/prism) as a default gem
+ * Prism is a portable, error tolerant, and maintainable recursive descent parser for the Ruby language
+* Prism is production ready and actively maintained, you can use it in place of Ripper
+ * There is [extensive documentation](https://ruby.github.io/prism/) on how to use Prism
+ * Prism is both a C library that will be used internally by CRuby and a Ruby gem that can be used by any tooling which needs to parse Ruby code
+ * Notable methods in the Prism API are:
+ * `Prism.parse(source)` which returns the AST as part of a parse result object
+ * `Prism.parse_comments(source)` which returns the comments
+ * `Prism.parse_success?(source)` which returns true if there are no errors
+* You can make pull requests or issues directly on [the Prism repository](https://github.com/ruby/prism) if you are interested in contributing
+* You can now use `ruby --parser=prism` or `RUBYOPT="--parser=prism"` to experiment with the Prism compiler. Please note that this flag is for debugging only.
+
+## Compatibility issues
+
+* Subprocess creation/forking via the following file open methods is deprecated. [[Feature #19630]]
+ * Kernel#open
+ * URI.open
+ * IO.binread
+ * IO.foreach
+ * IO.readlines
+ * IO.read
+ * IO.write
+
+* When given a non-lambda, non-literal block, Kernel#lambda with now raises
+ ArgumentError instead of returning it unmodified. These usages have been
+ issuing warnings under the `Warning[:deprecated]` category since Ruby 3.0.0.
+ [[Feature #19777]]
+
+* The `RUBY_GC_HEAP_INIT_SLOTS` environment variable has been deprecated and
+ removed. Environment variables `RUBY_GC_HEAP_%d_INIT_SLOTS` should be
+ used instead. [[Feature #19785]]
+
+* `it` calls without arguments in a block with no ordinary parameters are
+ deprecated. `it` will be a reference to the first block parameter in Ruby 3.4.
+ [[Feature #18980]]
+
+* Error message for NoMethodError have changed to not use the target object's `#inspect`
+ for efficiency, and says "instance of ClassName" instead. [[Feature #18285]]
+
+ ```ruby
+ ([1] * 100).nonexisting
+ # undefined method `nonexisting' for an instance of Array (NoMethodError)
+ ```
+
+* Now anonymous parameters forwarding is disallowed inside a block
+ that uses anonymous parameters. [[Feature #19370]]
+
+## Stdlib compatibility issues
+
+* `racc` is promoted to bundled gems.
+ * You need to add `racc` to your `Gemfile` if you use `racc` under bundler environment.
+* `ext/readline` is retired
+ * We have `reline` that is pure Ruby implementation compatible with `ext/readline` API.
+ We rely on `reline` in the future. If you need to use `ext/readline`, you can install
+ `ext/readline` via rubygems.org with `gem install readline-ext`.
+ * We no longer need to install libraries like `libreadline` or `libedit`.
+
+## C API updates
+
+* `rb_postponed_job` updates
+ * New APIs and deprecated APIs (see comments for details)
+ * added: `rb_postponed_job_preregister()`
+ * added: `rb_postponed_job_trigger()`
+ * deprecated: `rb_postponed_job_register()` (and semantic change. see below)
+ * deprecated: `rb_postponed_job_register_one()`
+ * The postponed job APIs have been changed to address some rare crashes.
+ To solve the issue, we introduced new two APIs and deprecated current APIs.
+ The semantics of these functions have also changed slightly; `rb_postponed_job_register`
+ now behaves like the `once` variant in that multiple calls with the same
+ `func` might be coalesced into a single execution of the `func`
+ [[Feature #20057]]
+
+* Some updates for internal thread event hook APIs
+ * `rb_internal_thread_event_data_t` with a target Ruby thread (VALUE)
+ and callback functions (`rb_internal_thread_event_callback`) receive it.
+ https://github.com/ruby/ruby/pull/8885
+ * The following functions are introduced to manipulate Ruby thread local data
+ from internal thread event hook APIs (they are introduced since Ruby 3.2).
+ https://github.com/ruby/ruby/pull/8936
+ * `rb_internal_thread_specific_key_create()`
+ * `rb_internal_thread_specific_get()`
+ * `rb_internal_thread_specific_set()`
+
+* `rb_profile_thread_frames()` is introduced to get a frames from
+ a specific thread.
+ [[Feature #10602]]
+
+* `rb_data_define()` is introduced to define `Data`. [[Feature #19757]]
+
+* `rb_ext_resolve_symbol()` is introduced to search a function from
+ extension libraries. [[Feature #20005]]
+
+* IO related updates:
+ * The details of `rb_io_t` will be hidden and deprecated attributes
+ are added for each members. [[Feature #19057]]
+ * `rb_io_path(VALUE io)` is introduced to get a path of `io`.
+ * `rb_io_closed_p(VALUE io)` to get opening or closing of `io`.
+ * `rb_io_mode(VALUE io)` to get the mode of `io`.
+ * `rb_io_open_descriptor()` is introduced to make an IO object from a file
+ descriptor.
+
+## Implementation improvements
+
+### Parser
+
+* Replace Bison with [Lrama LALR parser generator](https://github.com/ruby/lrama).
+ No need to install Bison to build Ruby from source code anymore.
+ We will no longer suffer bison compatibility issues and we can use new features by just implementing it to Lrama. [[Feature #19637]]
+ * See [The future vision of Ruby Parser](https://rubykaigi.org/2023/presentations/spikeolaf.html) for detail.
+ * Lrama internal parser is a LR parser generated by Racc for maintainability.
+ * Parameterizing Rules `(?, *, +)` are supported, it will be used in Ruby parse.y.
+
+### GC / Memory management
+
+* Major performance improvements over Ruby 3.2
+ * Young objects referenced by old objects are no longer immediately
+ promoted to the old generation. This significantly reduces the frequency of
+ major GC collections. [[Feature #19678]]
+ * A new `REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO` tuning variable was
+ introduced to control the number of unprotected objects cause a major GC
+ collection to trigger. The default is set to `0.01` (1%). This significantly
+ reduces the frequency of major GC collection. [[Feature #19571]]
+ * Write Barriers were implemented for many core types that were missing them,
+ notably `Time`, `Enumerator`, `MatchData`, `Method`, `File::Stat`, `BigDecimal`
+ and several others. This significantly reduces minor GC collection time and major
+ GC collection frequency.
+ * Most core classes are now using Variable Width Allocation, notably `Hash`, `Time`,
+ `Thread::Backtrace`, `Thread::Backtrace::Location`, `File::Stat`, `Method`.
+ This makes these classes faster to allocate and free, use less memory and reduce
+ heap fragmentation.
+* `defined?(@ivar)` is optimized with Object Shapes.
+
+### YJIT
+
+* Major performance improvements over Ruby 3.2
+ * Support for splat and rest arguments has been improved.
+ * Registers are allocated for stack operations of the virtual machine.
+ * More calls with optional arguments are compiled. Exception handlers are also compiled.
+ * Unsupported call types and megamorphic call sites no longer exit to the interpreter.
+ * Basic methods like Rails `#blank?` and
+ [specialized `#present?`](https://github.com/rails/rails/pull/49909) are inlined.
+ * `Integer#*`, `Integer#!=`, `String#!=`, `String#getbyte`,
+ `Kernel#block_given?`, `Kernel#is_a?`, `Kernel#instance_of?`, and `Module#===`
+ are specially optimized.
+ * Compilation speed is now slightly faster than Ruby 3.2.
+ * Now more than 3x faster than the interpreter on Optcarrot!
+* Significantly improved memory usage over Ruby 3.2
+ * Metadata for compiled code uses a lot less memory.
+ * `--yjit-call-threshold` is automatically raised from 30 to 120
+ when the application has more than 40,000 ISEQs.
+ * `--yjit-cold-threshold` is added to skip compiling cold ISEQs.
+ * More compact code is generated on Arm64.
+* Code GC is now disabled by default
+ * `--yjit-exec-mem-size` is treated as a hard limit where compilation of new code stops.
+ * No sudden drops in performance due to code GC.
+ Better copy-on-write behavior on servers reforking with
+ [Pitchfork](https://github.com/shopify/pitchfork).
+ * You can still enable code GC if desired with `--yjit-code-gc`
+* Add `RubyVM::YJIT.enable` that can enable YJIT at run-time
+ * You can start YJIT without modifying command-line arguments or environment variables.
+ Rails 7.2 will [enable YJIT by default](https://github.com/rails/rails/pull/49947)
+ using this method.
+ * This can also be used to enable YJIT only once your application is
+ done booting. `--yjit-disable` can be used if you want to use other
+ YJIT options while disabling YJIT at boot.
+* More YJIT stats are available by default
+ * `yjit_alloc_size` and several more metadata-related stats are now available by default.
+ * `ratio_in_yjit` stat produced by `--yjit-stats` is now available in release builds,
+ a special stats or dev build is no longer required to access most stats.
+* Add more profiling capabilities
+ * `--yjit-perf` is added to facilitate profiling with Linux perf.
+ * `--yjit-trace-exits` now supports sampling with `--yjit-trace-exits-sample-rate=N`
+* More thorough testing and multiple bug fixes
+* `--yjit-stats=quiet` is added to avoid printing stats on exit.
+
+### MJIT
+
+* MJIT is removed.
+ * `--disable-jit-support` is removed. Consider using `--disable-yjit --disable-rjit` instead.
+
+### RJIT
+
+* Introduced a pure-Ruby JIT compiler RJIT.
+ * RJIT supports only x86\_64 architecture on Unix platforms.
+ * Unlike MJIT, it doesn't require a C compiler at runtime.
+* RJIT exists only for experimental purposes.
+ * You should keep using YJIT in production.
+
+### M:N Thread scheduler
+
+* M:N Thread scheduler is introduced. [[Feature #19842]]
+ * Background: Ruby 1.8 and before, M:1 thread scheduler (M Ruby threads
+ with 1 native thread. Called as User level threads or Green threads)
+ is used. Ruby 1.9 and later, 1:1 thread scheduler (1 Ruby thread with
+ 1 native thread). M:1 threads takes lower resources compare with 1:1
+ threads because it needs only 1 native threads. However it is difficult
+ to support context switching for all of blocking operation so 1:1
+ threads are employed from Ruby 1.9. M:N thread scheduler uses N native
+ threads for M Ruby threads (N is small number in general). It doesn't
+ need same number of native threads as Ruby threads (similar to the M:1
+ thread scheduler). Also our M:N threads supports blocking operations
+ well same as 1:1 threads. See the ticket for more details.
+ Our M:N thread scheduler refers on the goroutine scheduler in the
+ Go language.
+ * In a ractor, only 1 thread can run in a same time because of
+ implementation. Therefore, applications that use only one Ractor
+ (most applications) M:N thread scheduler works as M:1 thread scheduler
+ with further extension from Ruby 1.8.
+ * M:N thread scheduler can introduce incompatibility for C-extensions,
+ so it is disabled by default on the main Ractors.
+ `RUBY_MN_THREADS=1` environment variable will enable it.
+ On non-main Ractors, M:N thread scheduler is enabled (and can not
+ disable it now).
+ * `N` (the number of native threads) can be specified with `RUBY_MAX_CPU`
+ environment variable. The default is 8.
+ Note that more than `N` native threads are used to support many kind of
+ blocking operations.
+
+[Bug #595]: https://bugs.ruby-lang.org/issues/595
+[Feature #10602]: https://bugs.ruby-lang.org/issues/10602
+[Bug #17146]: https://bugs.ruby-lang.org/issues/17146
+[Feature #18183]: https://bugs.ruby-lang.org/issues/18183
+[Feature #18285]: https://bugs.ruby-lang.org/issues/18285
+[Feature #18498]: https://bugs.ruby-lang.org/issues/18498
+[Feature #18515]: https://bugs.ruby-lang.org/issues/18515
+[Feature #18551]: https://bugs.ruby-lang.org/issues/18551
+[Feature #18885]: https://bugs.ruby-lang.org/issues/18885
+[Feature #18949]: https://bugs.ruby-lang.org/issues/18949
+[Feature #18980]: https://bugs.ruby-lang.org/issues/18980
+[Bug #19012]: https://bugs.ruby-lang.org/issues/19012
+[Feature #19057]: https://bugs.ruby-lang.org/issues/19057
+[Bug #19150]: https://bugs.ruby-lang.org/issues/19150
+[Bug #19293]: https://bugs.ruby-lang.org/issues/19293
+[Feature #19314]: https://bugs.ruby-lang.org/issues/19314
+[Feature #19347]: https://bugs.ruby-lang.org/issues/19347
+[Feature #19351]: https://bugs.ruby-lang.org/issues/19351
+[Feature #19362]: https://bugs.ruby-lang.org/issues/19362
+[Feature #19370]: https://bugs.ruby-lang.org/issues/19370
+[Feature #19521]: https://bugs.ruby-lang.org/issues/19521
+[Feature #19538]: https://bugs.ruby-lang.org/issues/19538
+[Feature #19561]: https://bugs.ruby-lang.org/issues/19561
+[Feature #19571]: https://bugs.ruby-lang.org/issues/19571
+[Feature #19572]: https://bugs.ruby-lang.org/issues/19572
+[Feature #19591]: https://bugs.ruby-lang.org/issues/19591
+[Feature #19630]: https://bugs.ruby-lang.org/issues/19630
+[Feature #19637]: https://bugs.ruby-lang.org/issues/19637
+[Feature #19678]: https://bugs.ruby-lang.org/issues/19678
+[Feature #19714]: https://bugs.ruby-lang.org/issues/19714
+[Feature #19725]: https://bugs.ruby-lang.org/issues/19725
+[Feature #19757]: https://bugs.ruby-lang.org/issues/19757
+[Feature #19776]: https://bugs.ruby-lang.org/issues/19776
+[Feature #19777]: https://bugs.ruby-lang.org/issues/19777
+[Feature #19785]: https://bugs.ruby-lang.org/issues/19785
+[Feature #19790]: https://bugs.ruby-lang.org/issues/19790
+[Feature #19839]: https://bugs.ruby-lang.org/issues/19839
+[Feature #19842]: https://bugs.ruby-lang.org/issues/19842
+[Feature #19843]: https://bugs.ruby-lang.org/issues/19843
+[Bug #19868]: https://bugs.ruby-lang.org/issues/19868
+[Feature #19965]: https://bugs.ruby-lang.org/issues/19965
+[Feature #20005]: https://bugs.ruby-lang.org/issues/20005
+[Feature #20057]: https://bugs.ruby-lang.org/issues/20057
diff --git a/doc/NEWS/NEWS-3.4.0.md b/doc/NEWS/NEWS-3.4.0.md
new file mode 100644
index 0000000000..e9cc3a9569
--- /dev/null
+++ b/doc/NEWS/NEWS-3.4.0.md
@@ -0,0 +1,962 @@
+# NEWS for Ruby 3.4.0
+
+This document is a list of user-visible feature changes
+since the **3.3.0** release, except for bug fixes.
+
+Note that each entry is kept to a minimum, see links for details.
+
+## Language changes
+
+* `it` is added to reference a block parameter. [[Feature #18980]]
+
+* String literals in files without a `frozen_string_literal` comment now emit a deprecation warning
+ when they are mutated.
+ These warnings can be enabled with `-W:deprecated` or by setting `Warning[:deprecated] = true`.
+ To disable this change, you can run Ruby with the `--disable-frozen-string-literal`
+ command line argument. [[Feature #20205]]
+
+ * `String#+@` now duplicates when mutating the string would emit
+ a deprecation warning, offered as a replacement for the
+ `str.dup if str.frozen?` pattern.
+
+* Keyword splatting `nil` when calling methods is now supported.
+ `**nil` is treated similarly to `**{}`, passing no keywords,
+ and not calling any conversion methods. [[Bug #20064]]
+
+* Block passing is no longer allowed in index assignment
+ (e.g. `a[0, &b] = 1`). [[Bug #19918]]
+
+* Keyword arguments are no longer allowed in index assignment
+ (e.g. `a[0, kw: 1] = 2`). [[Bug #20218]]
+
+* The toplevel name `::Ruby` is reserved now, and the definition will be warned
+ when `Warning[:deprecated]`. [[Feature #20884]]
+
+## Core classes updates
+
+Note: We're only listing outstanding class updates.
+
+
+* Array
+
+ * `Array#fetch_values` was added. [[Feature #20702]]
+
+* Exception
+
+ * `Exception#set_backtrace` now accepts arrays of `Thread::Backtrace::Location`.
+ `Kernel#raise`, `Thread#raise` and `Fiber#raise` also accept this new format. [[Feature #13557]]
+
+* Fiber::Scheduler
+
+ * An optional `Fiber::Scheduler#blocking_operation_wait` hook allows blocking operations to be moved out of the
+ event loop in order to reduce latency and improve multi-core processor utilization. [[Feature #20876]]
+
+* GC
+
+ * `GC.config` added to allow setting configuration variables on the Garbage
+ Collector. [[Feature #20443]]
+
+ * GC configuration parameter `rgengc_allow_full_mark` introduced. When `false`
+ GC will only mark young objects. Default is `true`. [[Feature #20443]]
+
+* Hash
+
+ * `Hash.new` now accepts an optional `capacity:` argument, to preallocate the hash with a given capacity.
+ This can improve performance when building large hashes incrementally by saving on reallocation and
+ rehashing of keys. [[Feature #19236]]
+
+* IO::Buffer
+
+ * `IO::Buffer#copy` can release the GVL, allowing other threads to run while copying data. [[Feature #20902]]
+
+* Integer
+
+ * `Integer#**` used to return `Float::INFINITY` when the return value is large, but now returns an `Integer`.
+ If the return value is extremely large, it raises an exception.
+ [[Feature #20811]]
+
+* MatchData
+
+ * `MatchData#bytebegin` and `MatchData#byteend` have been added. [[Feature #20576]]
+
+* Object
+
+ * `Object#singleton_method` now returns methods in modules prepended to or included in the
+ receiver's singleton class. [[Bug #20620]]
+
+ ```rb
+ o = Object.new
+ o.extend(Module.new{def a = 1})
+ o.singleton_method(:a).call #=> 1
+ ```
+
+* Ractor
+
+ * `require` in Ractor is allowed. The requiring process will be run on
+ the main Ractor.
+ `Ractor._require(feature)` is added to run requiring process on the
+ main Ractor.
+ [[Feature #20627]]
+
+ * `Ractor.main?` is added. [[Feature #20627]]
+
+ * `Ractor.[]` and `Ractor.[]=` are added to access the ractor local storage
+ of the current Ractor. [[Feature #20715]]
+
+ * `Ractor.store_if_absent(key){ init }` is added to initialize ractor local
+ variables in thread-safety. [[Feature #20875]]
+
+* Range
+
+ * `Range#size` now raises `TypeError` if the range is not iterable. [[Misc #18984]]
+ * `Range#step` now consistently has a semantics of iterating by using `+` operator
+ for all types, not only numerics. [[Feature #18368]]
+
+ ```ruby
+ (Time.utc(2022, 2, 24)..).step(24*60*60).take(3)
+ #=> [2022-02-24 00:00:00 UTC, 2022-02-25 00:00:00 UTC, 2022-02-26 00:00:00 UTC]
+ ```
+
+* Rational
+
+ * `Rational#**` used to return `Float::INFINITY` or `Float::NAN`
+ when the numerator of the return value is large, but now returns an `Rational`.
+ If it is extremely large, it raises an exception. [[Feature #20811]]
+
+* RubyVM::AbstractSyntaxTree
+
+ * Add `RubyVM::AbstractSyntaxTree::Node#locations` method which returns location objects
+ associated with the AST node. [[Feature #20624]]
+ * Add `RubyVM::AbstractSyntaxTree::Location` class which holds location information. [[Feature #20624]]
+
+
+* String
+
+ * `String#append_as_bytes` was added to more easily and efficiently work with binary buffers and protocols.
+ It directly concatenate the arguments into the string without any encoding validation or conversion.
+ [[Feature #20594]]
+
+* Symbol
+
+ * The string returned by `Symbol#to_s` now emits a deprecation warning when mutated, and will be
+ frozen in a future version of Ruby.
+ These warnings can be enabled with `-W:deprecated` or by setting `Warning[:deprecated] = true`.
+ [[Feature #20350]]
+
+* Time
+
+ * On Windows, now `Time#zone` encodes the system timezone name in UTF-8
+ instead of the active code page, if it contains non-ASCII characters.
+ [[Bug #20929]]
+
+ * `Time#xmlschema`, and its `Time#iso8601` alias have been moved into the core Time
+ class while previously it was an extension provided by the `time` gem. [[Feature #20707]]
+
+* Warning
+
+ * Add `Warning.categories` method which returns a list of possible warning categories.
+ [[Feature #20293]]
+
+## Stdlib updates
+
+We only list stdlib changes that are notable feature changes.
+
+* RubyGems
+
+ * Add `--attestation` option to gem push. It enabled to store signature of build artifact to sigstore.dev.
+
+* Bundler
+
+ * Add a `lockfile_checksums` configuration to include checksums in fresh lockfiles.
+ * Add bundle lock `--add-checksums` to add checksums to an existing lockfile.
+
+* JSON
+
+ * Performance improvements `JSON.parse` about 1.5 times faster than json-2.7.x.
+
+* Tempfile
+
+ * The keyword argument `anonymous: true` is implemented for Tempfile.create.
+ `Tempfile.create(anonymous: true)` removes the created temporary file immediately.
+ So applications don't need to remove the file.
+ [[Feature #20497]]
+
+* win32/sspi.rb
+
+ * This library is now extracted from the Ruby repository to [ruby/net-http-sspi].
+ [[Feature #20775]]
+
+* Socket
+
+ * `Socket::ResolutionError` and `Socket::ResolutionError#error_code` was added.
+ [[Feature #20018]]
+
+* IRB
+
+ * Interactive method completion is now improved with type information by default.
+ [[Feature #20778]]
+
+Other changes are listed in the following sections. we also listed release history from the previous bundled version that is Ruby 3.3.0 if it has GitHub releases.
+
+The following default gem is added.
+
+* win32-registry 0.1.0
+
+The following default gems are updated.
+
+* RubyGems 3.6.2
+* benchmark 0.4.0
+* bundler 2.6.2
+* date 3.4.1
+* delegate 0.4.0
+* did_you_mean 2.0.0
+* digest 3.2.0
+* erb 4.0.4
+* error_highlight 0.7.0
+* etc 1.4.5
+* fcntl 1.2.0
+* fiddle 1.1.6
+* fileutils 1.7.3
+* io-console 0.8.0
+* io-nonblock 0.3.1
+* ipaddr 1.2.7
+* irb 1.14.3
+* json 2.9.1
+* logger 1.6.4
+* net-http 0.6.0
+* open-uri 0.5.0
+* openssl 3.3.0
+* optparse 0.6.0
+* ostruct 0.6.1
+* pathname 0.4.0
+* pp 0.6.2
+* prism 1.2.0
+* pstore 0.1.4
+* psych 5.2.2
+* rdoc 6.10.0
+* reline 0.6.0
+* resolv 0.6.0
+* securerandom 0.4.1
+* set 1.1.1
+* shellwords 0.2.2
+* singleton 0.3.0
+* stringio 3.1.2
+* strscan 3.1.2
+* syntax_suggest 2.0.2
+* tempfile 0.3.1
+* time 0.4.1
+* timeout 0.4.3
+* tmpdir 0.3.1
+* uri 1.0.2
+* win32ole 1.9.1
+* yaml 0.4.0
+* zlib 3.2.1
+
+ * 3.5.3 to [v3.5.4][RubyGems-v3.5.4], [v3.5.5][RubyGems-v3.5.5], [v3.5.6][RubyGems-v3.5.6], [v3.5.7][RubyGems-v3.5.7], [v3.5.8][RubyGems-v3.5.8], [v3.5.9][RubyGems-v3.5.9], [v3.5.10][RubyGems-v3.5.10], [v3.5.11][RubyGems-v3.5.11], [v3.5.12][RubyGems-v3.5.12], [v3.5.13][RubyGems-v3.5.13], [v3.5.14][RubyGems-v3.5.14], [v3.5.15][RubyGems-v3.5.15], [v3.5.16][RubyGems-v3.5.16], [v3.5.17][RubyGems-v3.5.17], [v3.5.18][RubyGems-v3.5.18], [v3.5.19][RubyGems-v3.5.19], [v3.5.20][RubyGems-v3.5.20], [v3.5.21][RubyGems-v3.5.21], [v3.5.22][RubyGems-v3.5.22], [v3.5.23][RubyGems-v3.5.23], [v3.6.0][RubyGems-v3.6.0], [v3.6.1][RubyGems-v3.6.1], [v3.6.2][RubyGems-v3.6.2]
+* [benchmark][benchmark] 0.4.0
+ * 0.3.0 to [v0.4.0][benchmark-v0.4.0]
+* [bundler][bundler] 2.6.2
+ * 2.5.3 to [v2.5.4][bundler-v2.5.4], [v2.5.5][bundler-v2.5.5], [v2.5.6][bundler-v2.5.6], [v2.5.7][bundler-v2.5.7], [v2.5.8][bundler-v2.5.8], [v2.5.9][bundler-v2.5.9], [v2.5.10][bundler-v2.5.10], [v2.5.11][bundler-v2.5.11], [v2.5.12][bundler-v2.5.12], [v2.5.13][bundler-v2.5.13], [v2.5.14][bundler-v2.5.14], [v2.5.15][bundler-v2.5.15], [v2.5.16][bundler-v2.5.16], [v2.5.17][bundler-v2.5.17], [v2.5.18][bundler-v2.5.18], [v2.5.19][bundler-v2.5.19], [v2.5.20][bundler-v2.5.20], [v2.5.21][bundler-v2.5.21], [v2.5.22][bundler-v2.5.22], [v2.5.23][bundler-v2.5.23], [v2.6.0][bundler-v2.6.0], [v2.6.1][bundler-v2.6.1], [v2.6.2][bundler-v2.6.2]
+* [date][date] 3.4.1
+ * 3.3.4 to [v3.4.0][date-v3.4.0], [v3.4.1][date-v3.4.1]
+* [delegate][delegate] 0.4.0
+ * 0.3.1 to [v0.4.0][delegate-v0.4.0]
+* [did_you_mean][did_you_mean] 2.0.0
+ * 1.6.3 to [v2.0.0][did_you_mean-v2.0.0]
+* [digest][digest] 3.2.0
+ * 3.1.1 to [v3.2.0.pre0][digest-v3.2.0.pre0], [v3.2.0][digest-v3.2.0]
+* [erb][erb] 4.0.4
+ * 4.0.3 to [v4.0.4][erb-v4.0.4]
+* [error_highlight][error_highlight] 0.7.0
+ * 0.6.0 to [v0.7.0][error_highlight-v0.7.0]
+* [etc][etc] 1.4.5
+ * 1.4.3 to [v1.4.4][etc-v1.4.4], [v1.4.5][etc-v1.4.5]
+* [fcntl][fcntl] 1.2.0
+ * 1.1.0 to [v1.2.0][fcntl-v1.2.0]
+* [fiddle][fiddle] 1.1.6
+ * 1.1.2 to [v1.1.3][fiddle-v1.1.3], [v1.1.4][fiddle-v1.1.4], [v1.1.5][fiddle-v1.1.5], [v1.1.6][fiddle-v1.1.6]
+* [fileutils][fileutils] 1.7.3
+ * 1.7.2 to [v1.7.3][fileutils-v1.7.3]
+* [io-console][io-console] 0.8.0
+ * 0.7.1 to [v0.7.2][io-console-v0.7.2], [v0.8.0.beta1][io-console-v0.8.0.beta1], [v0.8.0][io-console-v0.8.0]
+* [io-nonblock][io-nonblock] 0.3.1
+ * 0.3.0 to [v0.3.1][io-nonblock-v0.3.1]
+* [ipaddr][ipaddr] 1.2.7
+ * 1.2.6 to [v1.2.7][ipaddr-v1.2.7]
+* [irb][irb] 1.14.3
+ * 1.11.0 to [v1.11.1][irb-v1.11.1], [v1.11.2][irb-v1.11.2], [v1.12.0][irb-v1.12.0], [v1.13.0][irb-v1.13.0], [v1.13.1][irb-v1.13.1], [v1.13.2][irb-v1.13.2], [v1.14.0][irb-v1.14.0], [v1.14.1][irb-v1.14.1], [v1.14.2][irb-v1.14.2], [v1.14.3][irb-v1.14.3]
+* [json][json] 2.9.1
+ * 2.7.1 to [v2.7.2][json-v2.7.2], [v2.7.3.rc1][json-v2.7.3.rc1], [v2.7.3][json-v2.7.3], [v2.7.4][json-v2.7.4], [v2.7.5][json-v2.7.5], [v2.7.6][json-v2.7.6], [v2.8.0][json-v2.8.0], [v2.8.1][json-v2.8.1], [v2.8.2][json-v2.8.2], [v2.9.0][json-v2.9.0], [v2.9.1][json-v2.9.1]
+* [logger][logger] 1.6.4
+ * 1.6.0 to [v1.6.1][logger-v1.6.1], [v1.6.2][logger-v1.6.2], [v1.6.3][logger-v1.6.3], [v1.6.4][logger-v1.6.4]
+* [net-http][net-http] 0.6.0
+ * 0.4.0 to [v0.4.1][net-http-v0.4.1], [v0.5.0][net-http-v0.5.0], [v0.6.0][net-http-v0.6.0]
+* [open-uri][open-uri] 0.5.0
+ * 0.4.1 to [v0.5.0][open-uri-v0.5.0]
+* [optparse][optparse] 0.6.0
+ * 0.4.0 to [v0.5.0][optparse-v0.5.0], [v0.6.0][optparse-v0.6.0]
+* [ostruct][ostruct] 0.6.1
+ * 0.6.0 to [v0.6.1][ostruct-v0.6.1]
+* [pathname][pathname] 0.4.0
+ * 0.3.0 to [v0.4.0][pathname-v0.4.0]
+* [pp][pp] 0.6.2
+ * 0.5.0 to [v0.6.0][pp-v0.6.0], [v0.6.1][pp-v0.6.1], [v0.6.2][pp-v0.6.2]
+* [prism][prism] 1.2.0
+ * 0.19.0 to [v0.20.0][prism-v0.20.0], [v0.21.0][prism-v0.21.0], [v0.22.0][prism-v0.22.0], [v0.23.0][prism-v0.23.0], [v0.24.0][prism-v0.24.0], [v0.25.0][prism-v0.25.0], [v0.26.0][prism-v0.26.0], [v0.27.0][prism-v0.27.0], [v0.28.0][prism-v0.28.0], [v0.29.0][prism-v0.29.0], [v0.30.0][prism-v0.30.0], [v1.0.0][prism-v1.0.0], [v1.1.0][prism-v1.1.0], [v1.2.0][prism-v1.2.0]
+* [pstore][pstore] 0.1.4
+ * 0.1.3 to [v0.1.4][pstore-v0.1.4]
+* [psych][psych] 5.2.2
+ * 5.1.2 to [v5.2.0.beta1][psych-v5.2.0.beta1], [v5.2.0.beta2][psych-v5.2.0.beta2], [v5.2.0.beta3][psych-v5.2.0.beta3], [v5.2.0.beta4][psych-v5.2.0.beta4], [v5.2.0.beta5][psych-v5.2.0.beta5], [v5.2.0.beta6][psych-v5.2.0.beta6], [v5.2.0.beta7][psych-v5.2.0.beta7], [v5.2.0][psych-v5.2.0], [v5.2.1][psych-v5.2.1], [v5.2.2][psych-v5.2.2]
+* [rdoc][rdoc] 6.10.0
+ * 6.6.2 to [v6.7.0][rdoc-v6.7.0], [v6.8.0][rdoc-v6.8.0], [v6.8.1][rdoc-v6.8.1], [v6.9.0][rdoc-v6.9.0], [v6.9.1][rdoc-v6.9.1], [v6.10.0][rdoc-v6.10.0]
+* [reline][reline] 0.6.0
+ * 0.4.1 to [v0.4.2][reline-v0.4.2], [v0.4.3][reline-v0.4.3], [v0.5.0.pre.1][reline-v0.5.0.pre.1], [v0.5.0][reline-v0.5.0], [v0.5.1][reline-v0.5.1], [v0.5.2][reline-v0.5.2], [v0.5.3][reline-v0.5.3], [v0.5.4][reline-v0.5.4], [v0.5.5][reline-v0.5.5], [v0.5.6][reline-v0.5.6], [v0.5.7][reline-v0.5.7], [v0.5.8][reline-v0.5.8], [v0.5.9][reline-v0.5.9], [v0.5.10][reline-v0.5.10], [v0.5.11][reline-v0.5.11], [v0.5.12][reline-v0.5.12], [v0.6.0][reline-v0.6.0]
+* [resolv][resolv] 0.6.0
+ * 0.3.0 to [v0.4.0][resolv-v0.4.0], [v0.5.0][resolv-v0.5.0], [v0.6.0][resolv-v0.6.0]
+* [securerandom][securerandom] 0.4.1
+ * 0.3.1 to [v0.3.2][securerandom-v0.3.2], [v0.4.0][securerandom-v0.4.0], [v0.4.1][securerandom-v0.4.1]
+* [set][set] 1.1.1
+ * 1.1.0 to [v1.1.1][set-v1.1.1]
+* [shellwords][shellwords] 0.2.2
+ * 0.2.0 to [v0.2.1][shellwords-v0.2.1], [v0.2.2][shellwords-v0.2.2]
+* [singleton][singleton] 0.3.0
+ * 0.2.0 to [v0.3.0][singleton-v0.3.0]
+* [stringio][stringio] 3.1.2
+ * 3.1.0 to [v3.1.1][stringio-v3.1.1], [v3.1.2][stringio-v3.1.2]
+* [strscan][strscan] 3.1.2
+ * 3.0.7 to [v3.0.8][strscan-v3.0.8], [v3.0.9][strscan-v3.0.9], [v3.1.0][strscan-v3.1.0], [v3.1.1][strscan-v3.1.1], [v3.1.2][strscan-v3.1.2]
+* [syntax_suggest][syntax_suggest] 2.0.2
+ * 2.0.0 to [v2.0.1][syntax_suggest-v2.0.1], [v2.0.2][syntax_suggest-v2.0.2]
+* [tempfile][tempfile] 0.3.1
+ * 0.2.1 to [v0.3.0][tempfile-v0.3.0], [v0.3.1][tempfile-v0.3.1]
+* [time][time] 0.4.1
+ * 0.3.0 to [v0.4.0][time-v0.4.0], [v0.4.1][time-v0.4.1]
+* [timeout][timeout] 0.4.3
+ * 0.4.1 to [v0.4.2][timeout-v0.4.2], [v0.4.3][timeout-v0.4.3]
+* [tmpdir][tmpdir] 0.3.1
+ * 0.2.0 to [v0.3.0][tmpdir-v0.3.0], [v0.3.1][tmpdir-v0.3.1]
+* [uri][uri] 1.0.2
+ * 0.13.0 to [v0.13.1][uri-v0.13.1], [v1.0.0][uri-v1.0.0], [v1.0.1][uri-v1.0.1], [v1.0.2][uri-v1.0.2]
+* [win32ole][win32ole] 1.9.1
+ * 1.8.10 to [v1.9.0][win32ole-v1.9.0], [v1.9.1][win32ole-v1.9.1]
+* [yaml][yaml] 0.4.0
+ * 0.3.0 to [v0.4.0][yaml-v0.4.0]
+* [zlib][zlib] 3.2.1
+ * 3.1.0 to [v3.1.1][zlib-v3.1.1], [v3.2.0][zlib-v3.2.0], [v3.2.1][zlib-v3.2.1]
+
+The following bundled gem is added.
+
+* [repl_type_completor][repl_type_completor] 0.1.9
+
+The following bundled gems are updated.
+
+* [minitest][minitest] 5.25.4
+ * 5.20.0 to [v5.25.4][minitest-v5.25.4]
+* [power_assert][power_assert] 2.0.5
+ * 2.0.3 to [v2.0.4][power_assert-v2.0.4], [v2.0.5][power_assert-v2.0.5]
+* [rake][rake] 13.2.1
+ * 13.1.0 to [v13.2.0][rake-v13.2.0], [v13.2.1][rake-v13.2.1]
+* [test-unit][test-unit] 3.6.7
+ * 3.6.1 to [3.6.2][test-unit-3.6.2], [3.6.3][test-unit-3.6.3], [3.6.4][test-unit-3.6.4], [3.6.5][test-unit-3.6.5], [3.6.6][test-unit-3.6.6], [3.6.7][test-unit-3.6.7]
+* [rexml][rexml] 3.4.0
+ * 3.2.6 to [v3.2.7][rexml-v3.2.7], [v3.2.8][rexml-v3.2.8], [v3.2.9][rexml-v3.2.9], [v3.3.0][rexml-v3.3.0], [v3.3.1][rexml-v3.3.1], [v3.3.2][rexml-v3.3.2], [v3.3.3][rexml-v3.3.3], [v3.3.4][rexml-v3.3.4], [v3.3.5][rexml-v3.3.5], [v3.3.6][rexml-v3.3.6], [v3.3.7][rexml-v3.3.7], [v3.3.8][rexml-v3.3.8], [v3.3.9][rexml-v3.3.9], [v3.4.0][rexml-v3.4.0]
+* [rss][rss] 0.3.1
+ * 0.3.0 to [0.3.1][rss-0.3.1]
+* [net-ftp][net-ftp] 0.3.8
+ * 0.3.3 to [v0.3.4][net-ftp-v0.3.4], [v0.3.5][net-ftp-v0.3.5], [v0.3.6][net-ftp-v0.3.6], [v0.3.7][net-ftp-v0.3.7], [v0.3.8][net-ftp-v0.3.8]
+* [net-imap][net-imap] 0.5.4
+ * 0.4.9 to [v0.4.9.1][net-imap-v0.4.9.1], [v0.4.10][net-imap-v0.4.10], [v0.4.11][net-imap-v0.4.11], [v0.4.12][net-imap-v0.4.12], [v0.4.13][net-imap-v0.4.13], [v0.4.14][net-imap-v0.4.14], [v0.4.15][net-imap-v0.4.15], [v0.4.16][net-imap-v0.4.16], [v0.4.17][net-imap-v0.4.17], [v0.5.0][net-imap-v0.5.0], [v0.4.18][net-imap-v0.4.18], [v0.5.1][net-imap-v0.5.1], [v0.5.2][net-imap-v0.5.2], [v0.5.3][net-imap-v0.5.3], [v0.5.4][net-imap-v0.5.4]
+* [net-smtp][net-smtp] 0.5.0
+ * 0.4.0 to [v0.4.0.1][net-smtp-v0.4.0.1], [v0.5.0][net-smtp-v0.5.0]
+* [prime][prime] 0.1.3
+ * 0.1.2 to [v0.1.3][prime-v0.1.3]
+* [rbs][rbs] 3.8.0
+ * 3.4.0 to [v3.4.1][rbs-v3.4.1], [v3.4.2][rbs-v3.4.2], [v3.4.3][rbs-v3.4.3], [v3.4.4][rbs-v3.4.4], [v3.5.0.pre.1][rbs-v3.5.0.pre.1], [v3.5.0.pre.2][rbs-v3.5.0.pre.2], [v3.5.0][rbs-v3.5.0], [v3.5.1][rbs-v3.5.1], [v3.5.2][rbs-v3.5.2], [v3.5.3][rbs-v3.5.3], [v3.6.0.dev.1][rbs-v3.6.0.dev.1], [v3.6.0.pre.1][rbs-v3.6.0.pre.1], [v3.6.0.pre.2][rbs-v3.6.0.pre.2], [v3.6.0.pre.3][rbs-v3.6.0.pre.3], [v3.6.0][rbs-v3.6.0], [v3.6.1][rbs-v3.6.1], [v3.7.0.dev.1][rbs-v3.7.0.dev.1], [v3.7.0.pre.1][rbs-v3.7.0.pre.1], [v3.7.0][rbs-v3.7.0], [v3.8.0.pre.1][rbs-v3.8.0.pre.1] [v3.8.0][rbs-v3.8.0]
+* [typeprof][typeprof] 0.30.1
+ * 0.21.9 to [v0.30.1][typeprof-v0.30.1]
+* [debug][debug] 1.10.0
+ * 1.9.1 to [v1.9.2][debug-v1.9.2], [v1.10.0][debug-v1.10.0]
+* [racc][racc] 1.8.1
+ * 1.7.3 to [v1.8.0][racc-v1.8.0], [v1.8.1][racc-v1.8.1]
+
+The following bundled gems are promoted from default gems.
+
+* [mutex_m][mutex_m] 0.3.0
+ * 0.2.0 to [v0.3.0][mutex_m-v0.3.0]
+* [getoptlong][getoptlong] 0.2.1
+* [base64][base64] 0.2.0
+* [bigdecimal][bigdecimal] 3.1.8
+ * 3.1.5 to [v3.1.6][bigdecimal-v3.1.6], [v3.1.7][bigdecimal-v3.1.7], [v3.1.8][bigdecimal-v3.1.8]
+* [observer][observer] 0.1.2
+* [abbrev][abbrev] 0.1.2
+* [resolv-replace][resolv-replace] 0.1.1
+* [rinda][rinda] 0.2.0
+* [drb][drb] 2.2.1
+ * 2.2.0 to [v2.2.1][drb-v2.2.1]
+* [nkf][nkf] 0.2.0
+ * 0.1.3 to [v0.2.0][nkf-v0.2.0]
+* [syslog][syslog] 0.2.0
+ * 0.1.2 to [v0.2.0][syslog-v0.2.0]
+* [csv][csv] 3.3.2
+ * 3.2.8 to [v3.2.9][csv-v3.2.9], [v3.3.0][csv-v3.3.0], [v3.3.1][csv-v3.3.1], [v3.3.2][csv-v3.3.2]
+
+## Supported platforms
+
+## Compatibility issues
+
+* Error messages and backtrace displays have been changed.
+
+ * Use a single quote instead of a backtick as an opening quote. [[Feature #16495]]
+ * Display a class name before a method name (only when the class has a permanent name). [[Feature #19117]]
+ * Extra `rescue`/`ensure` frames are no longer available on the backtrace. [[Feature #20275]]
+ * `Kernel#caller`, `Thread::Backtrace::Location`’s methods, etc. are also changed accordingly.
+
+ Old:
+ ```
+ test.rb:1:in `foo': undefined method `time' for an instance of Integer
+ from test.rb:2:in `<main>'
+ ```
+
+ New:
+ ```
+ test.rb:1:in 'Object#foo': undefined method 'time' for an instance of Integer
+ from test.rb:2:in '<main>'
+ ```
+
+* `Hash#inspect` rendering have been changed. [[Bug #20433]]
+
+ * Symbol keys are displayed using the modern symbol key syntax: `"{user: 1}"`
+ * Other keys now have spaces around `=>`: `'{"user" => 1}'`, while previously they didn't: `'{"user"=>1}'`
+
+* `Kernel#Float()` now accepts a decimal string with decimal part omitted. [[Feature #20705]]
+
+ ```rb
+ Float("1.") #=> 1.0 (previously, an ArgumentError was raised)
+ Float("1.E-1") #=> 0.1 (previously, an ArgumentError was raised)
+ ```
+
+* `String#to_f` now accepts a decimal string with decimal part omitted. [[Feature #20705]]
+ Note that the result changes when an exponent is specified.
+
+ ```rb
+ "1.".to_f #=> 1.0
+ "1.E-1".to_f #=> 0.1 (previously, 1.0 was returned)
+ ```
+
+* `Refinement#refined_class` has been removed. [[Feature #19714]]
+
+## Stdlib compatibility issues
+
+* DidYouMean
+
+ * `DidYouMean::SPELL_CHECKERS[]=` and `DidYouMean::SPELL_CHECKERS.merge!` are removed.
+
+* Net::HTTP
+
+ * Removed the following deprecated constants:
+ * `Net::HTTP::ProxyMod`
+ * `Net::NetPrivate::HTTPRequest`
+ * `Net::HTTPInformationCode`
+ * `Net::HTTPSuccessCode`
+ * `Net::HTTPRedirectionCode`
+ * `Net::HTTPRetriableCode`
+ * `Net::HTTPClientErrorCode`
+ * `Net::HTTPFatalErrorCode`
+ * `Net::HTTPServerErrorCode`
+ * `Net::HTTPResponseReceiver`
+ * `Net::HTTPResponceReceiver`
+
+ These constants were deprecated from 2012.
+
+* Timeout
+
+ * Reject negative values for `Timeout.timeout`. [[Bug #20795]]
+
+* URI
+
+ * Switched default parser to RFC 3986 compliant from RFC 2396 compliant.
+ [[Bug #19266]]
+
+## C API updates
+
+* `rb_newobj` and `rb_newobj_of` (and corresponding macros `RB_NEWOBJ`, `RB_NEWOBJ_OF`, `NEWOBJ`, `NEWOBJ_OF`) have been removed. [[Feature #20265]]
+* Removed deprecated function `rb_gc_force_recycle`. [[Feature #18290]]
+
+## Implementation improvements
+
+* The default parser is now Prism.
+ To use the conventional parser, use the command-line argument `--parser=parse.y`.
+ [[Feature #20564]]
+
+* Happy Eyeballs version 2 (RFC8305), an algorithm that ensures faster and more reliable connections
+ by attempting IPv6 and IPv4 concurrently, is used in `Socket.tcp` and `TCPSocket.new`.
+ To disable it globally, set the environment variable `RUBY_TCP_NO_FAST_FALLBACK=1` or
+ call `Socket.tcp_fast_fallback=false`.
+ Or to disable it on a per-method basis, use the keyword argument `fast_fallback: false`.
+ [[Feature #20108]] [[Feature #20782]]
+
+* Alternative garbage collector (GC) implementations can be loaded dynamically
+ through the modular garbage collector feature. To enable this feature,
+ configure Ruby with `--with-modular-gc` at build time. GC libraries can be
+ loaded at runtime using the environment variable `RUBY_GC_LIBRARY`.
+ [[Feature #20351]]
+
+* Ruby's built-in garbage collector has been split into a separate file at
+ `gc/default/default.c` and interacts with Ruby using an API defined in
+ `gc/gc_impl.h`. The built-in garbage collector can now also be built as a
+ library using `make modular-gc MODULAR_GC=default` and enabled using the
+ environment variable `RUBY_GC_LIBRARY=default`. [[Feature #20470]]
+
+* An experimental GC library is provided based on [MMTk](https://www.mmtk.io/).
+ This GC library can be built using `make modular-gc MODULAR_GC=mmtk` and
+ enabled using the environment variable `RUBY_GC_LIBRARY=mmtk`. This requires
+ the Rust toolchain on the build machine. [[Feature #20860]]
+
+### YJIT
+
+#### New features
+
+* Command-line options
+ * `--yjit-mem-size` introduces a unified memory limit (default 128MiB) to track total YJIT memory usage,
+ providing a more intuitive alternative to the old `--yjit-exec-mem-size` option.
+ * `--yjit-trace-exits=COUNTER` allows tracing of counted exits and fallbacks.
+ * `--yjit-perf=codegen` allows profiling of JIT code based on YJIT's codegen functions.
+ * `--yjit-log` enables a compilation log to track what gets compiled.
+* Ruby API
+ * `RubyVM::YJIT.enable(log: true)` also enables a compilation log.
+ * `RubyVM::YJIT.log` provides access to the tail of the compilation log at run-time.
+* YJIT stats
+ * `RubyVM::YJIT.runtime_stats` now always provides additional statistics on
+ invalidation, inlining, and metadata encoding.
+ * `RubyVM::YJIT.runtime_stats[:iseq_calls]` is added to profile non-inlined Ruby method calls.
+ * `RubyVM::YJIT.runtime_stats[:cfunc_calls]` is truncated to the top 20 entries for better performance.
+
+#### New optimizations
+
+* Compressed context reduces memory needed to store YJIT metadata
+* Allocate registers for local variables and Ruby method arguments
+* When YJIT is enabled, use more Core primitives written in Ruby:
+ * `Array#each`, `Array#select`, `Array#map` rewritten in Ruby for better performance [[Feature #20182]].
+* Ability to inline small/trivial methods such as:
+ * Empty methods
+ * Methods returning a constant
+ * Methods returning `self`
+ * Methods directly returning an argument
+* Specialized codegen for many more runtime methods
+* Optimize `String#getbyte`, `String#setbyte` and other string methods
+* Optimize bitwise operations to speed up low-level bit/byte manipulation
+* Support shareable constants in multi-ractor mode
+* Various other incremental optimizations
+
+## Miscellaneous changes
+
+* Passing a block to a method which doesn't use the passed block will show
+ a warning on verbose mode (`-w`).
+ In connection with this, a new `strict_unused_block` warning category was introduced.
+ Turn them on with `-W:strict_unused_block` or `Warning[:strict_unused_block] = true`.
+ [[Feature #15554]]
+
+* Redefining some core methods that are specially optimized by the interpreter
+ and JIT like `String#freeze` or `Integer#+` now emits a performance class
+ warning (`-W:performance` or `Warning[:performance] = true`).
+ [[Feature #20429]]
+
+[Feature #13557]: https://bugs.ruby-lang.org/issues/13557
+[Feature #15554]: https://bugs.ruby-lang.org/issues/15554
+[Feature #16495]: https://bugs.ruby-lang.org/issues/16495
+[Feature #18290]: https://bugs.ruby-lang.org/issues/18290
+[Feature #18368]: https://bugs.ruby-lang.org/issues/18368
+[Feature #18980]: https://bugs.ruby-lang.org/issues/18980
+[Misc #18984]: https://bugs.ruby-lang.org/issues/18984
+[Feature #19117]: https://bugs.ruby-lang.org/issues/19117
+[Feature #19236]: https://bugs.ruby-lang.org/issues/19236
+[Bug #19266]: https://bugs.ruby-lang.org/issues/19266
+[Feature #19714]: https://bugs.ruby-lang.org/issues/19714
+[Bug #19918]: https://bugs.ruby-lang.org/issues/19918
+[Feature #20018]: https://bugs.ruby-lang.org/issues/20018
+[Bug #20064]: https://bugs.ruby-lang.org/issues/20064
+[Feature #20108]: https://bugs.ruby-lang.org/issues/20108
+[Feature #20182]: https://bugs.ruby-lang.org/issues/20182
+[Feature #20205]: https://bugs.ruby-lang.org/issues/20205
+[Bug #20218]: https://bugs.ruby-lang.org/issues/20218
+[Feature #20265]: https://bugs.ruby-lang.org/issues/20265
+[Feature #20275]: https://bugs.ruby-lang.org/issues/20275
+[Feature #20293]: https://bugs.ruby-lang.org/issues/20293
+[Feature #20350]: https://bugs.ruby-lang.org/issues/20350
+[Feature #20351]: https://bugs.ruby-lang.org/issues/20351
+[Feature #20429]: https://bugs.ruby-lang.org/issues/20429
+[Bug #20433]: https://bugs.ruby-lang.org/issues/20433
+[Feature #20443]: https://bugs.ruby-lang.org/issues/20443
+[Feature #20470]: https://bugs.ruby-lang.org/issues/20470
+[Feature #20497]: https://bugs.ruby-lang.org/issues/20497
+[Feature #20564]: https://bugs.ruby-lang.org/issues/20564
+[Feature #20576]: https://bugs.ruby-lang.org/issues/20576
+[Feature #20594]: https://bugs.ruby-lang.org/issues/20594
+[Bug #20620]: https://bugs.ruby-lang.org/issues/20620
+[Feature #20624]: https://bugs.ruby-lang.org/issues/20624
+[Feature #20627]: https://bugs.ruby-lang.org/issues/20627
+[Feature #20702]: https://bugs.ruby-lang.org/issues/20702
+[Feature #20705]: https://bugs.ruby-lang.org/issues/20705
+[Feature #20707]: https://bugs.ruby-lang.org/issues/20707
+[Feature #20715]: https://bugs.ruby-lang.org/issues/20715
+[Feature #20775]: https://bugs.ruby-lang.org/issues/20775
+[Feature #20778]: https://bugs.ruby-lang.org/issues/20778
+[Feature #20782]: https://bugs.ruby-lang.org/issues/20782
+[Bug #20795]: https://bugs.ruby-lang.org/issues/20795
+[Feature #20811]: https://bugs.ruby-lang.org/issues/20811
+[Feature #20860]: https://bugs.ruby-lang.org/issues/20860
+[Feature #20875]: https://bugs.ruby-lang.org/issues/20875
+[Feature #20876]: https://bugs.ruby-lang.org/issues/20876
+[Feature #20884]: https://bugs.ruby-lang.org/issues/20884
+[Feature #20902]: https://bugs.ruby-lang.org/issues/20902
+[Bug #20929]: https://bugs.ruby-lang.org/issues/20929
+[RubyGems-v3.5.4]: https://github.com/rubygems/rubygems/releases/tag/v3.5.4
+[RubyGems-v3.5.5]: https://github.com/rubygems/rubygems/releases/tag/v3.5.5
+[RubyGems-v3.5.6]: https://github.com/rubygems/rubygems/releases/tag/v3.5.6
+[RubyGems-v3.5.7]: https://github.com/rubygems/rubygems/releases/tag/v3.5.7
+[RubyGems-v3.5.8]: https://github.com/rubygems/rubygems/releases/tag/v3.5.8
+[RubyGems-v3.5.9]: https://github.com/rubygems/rubygems/releases/tag/v3.5.9
+[RubyGems-v3.5.10]: https://github.com/rubygems/rubygems/releases/tag/v3.5.10
+[RubyGems-v3.5.11]: https://github.com/rubygems/rubygems/releases/tag/v3.5.11
+[RubyGems-v3.5.12]: https://github.com/rubygems/rubygems/releases/tag/v3.5.12
+[RubyGems-v3.5.13]: https://github.com/rubygems/rubygems/releases/tag/v3.5.13
+[RubyGems-v3.5.14]: https://github.com/rubygems/rubygems/releases/tag/v3.5.14
+[RubyGems-v3.5.15]: https://github.com/rubygems/rubygems/releases/tag/v3.5.15
+[RubyGems-v3.5.16]: https://github.com/rubygems/rubygems/releases/tag/v3.5.16
+[RubyGems-v3.5.17]: https://github.com/rubygems/rubygems/releases/tag/v3.5.17
+[RubyGems-v3.5.18]: https://github.com/rubygems/rubygems/releases/tag/v3.5.18
+[RubyGems-v3.5.19]: https://github.com/rubygems/rubygems/releases/tag/v3.5.19
+[RubyGems-v3.5.20]: https://github.com/rubygems/rubygems/releases/tag/v3.5.20
+[RubyGems-v3.5.21]: https://github.com/rubygems/rubygems/releases/tag/v3.5.21
+[RubyGems-v3.5.22]: https://github.com/rubygems/rubygems/releases/tag/v3.5.22
+[RubyGems-v3.5.23]: https://github.com/rubygems/rubygems/releases/tag/v3.5.23
+[RubyGems-v3.6.0]: https://github.com/rubygems/rubygems/releases/tag/v3.6.0
+[RubyGems-v3.6.1]: https://github.com/rubygems/rubygems/releases/tag/v3.6.1
+[RubyGems-v3.6.2]: https://github.com/rubygems/rubygems/releases/tag/v3.6.2
+[benchmark-v0.4.0]: https://github.com/ruby/benchmark/releases/tag/v0.4.0
+[bundler-v2.5.4]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.4
+[bundler-v2.5.5]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.5
+[bundler-v2.5.6]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.6
+[bundler-v2.5.7]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.7
+[bundler-v2.5.8]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.8
+[bundler-v2.5.9]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.9
+[bundler-v2.5.10]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.10
+[bundler-v2.5.11]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.11
+[bundler-v2.5.12]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.12
+[bundler-v2.5.13]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.13
+[bundler-v2.5.14]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.14
+[bundler-v2.5.15]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.15
+[bundler-v2.5.16]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.16
+[bundler-v2.5.17]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.17
+[bundler-v2.5.18]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.18
+[bundler-v2.5.19]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.19
+[bundler-v2.5.20]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.20
+[bundler-v2.5.21]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.21
+[bundler-v2.5.22]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.22
+[bundler-v2.5.23]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.23
+[bundler-v2.6.0]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.6.0
+[bundler-v2.6.1]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.6.1
+[bundler-v2.6.2]: https://github.com/rubygems/rubygems/releases/tag/bundler-v2.6.2
+[date-v3.4.0]: https://github.com/ruby/date/releases/tag/v3.4.0
+[date-v3.4.1]: https://github.com/ruby/date/releases/tag/v3.4.1
+[delegate-v0.4.0]: https://github.com/ruby/delegate/releases/tag/v0.4.0
+[did_you_mean-v2.0.0]: https://github.com/ruby/did_you_mean/releases/tag/v2.0.0
+[digest-v3.2.0.pre0]: https://github.com/ruby/digest/releases/tag/v3.2.0.pre0
+[digest-v3.2.0]: https://github.com/ruby/digest/releases/tag/v3.2.0
+[erb-v4.0.4]: https://github.com/ruby/erb/releases/tag/v4.0.4
+[etc-v1.4.4]: https://github.com/ruby/etc/releases/tag/v1.4.4
+[etc-v1.4.5]: https://github.com/ruby/etc/releases/tag/v1.4.5
+[fcntl-v1.2.0]: https://github.com/ruby/fcntl/releases/tag/v1.2.0
+[fiddle-v1.1.3]: https://github.com/ruby/fiddle/releases/tag/v1.1.3
+[fiddle-v1.1.4]: https://github.com/ruby/fiddle/releases/tag/v1.1.4
+[fiddle-v1.1.5]: https://github.com/ruby/fiddle/releases/tag/v1.1.5
+[fiddle-v1.1.6]: https://github.com/ruby/fiddle/releases/tag/v1.1.6
+[fileutils-v1.7.3]: https://github.com/ruby/fileutils/releases/tag/v1.7.3
+[io-console-v0.7.2]: https://github.com/ruby/io-console/releases/tag/v0.7.2
+[io-console-v0.8.0.beta1]: https://github.com/ruby/io-console/releases/tag/v0.8.0.beta1
+[io-console-v0.8.0]: https://github.com/ruby/io-console/releases/tag/v0.8.0
+[io-nonblock-v0.3.1]: https://github.com/ruby/io-nonblock/releases/tag/v0.3.1
+[ipaddr-v1.2.7]: https://github.com/ruby/ipaddr/releases/tag/v1.2.7
+[irb-v1.11.1]: https://github.com/ruby/irb/releases/tag/v1.11.1
+[irb-v1.11.2]: https://github.com/ruby/irb/releases/tag/v1.11.2
+[irb-v1.12.0]: https://github.com/ruby/irb/releases/tag/v1.12.0
+[irb-v1.13.0]: https://github.com/ruby/irb/releases/tag/v1.13.0
+[irb-v1.13.1]: https://github.com/ruby/irb/releases/tag/v1.13.1
+[irb-v1.13.2]: https://github.com/ruby/irb/releases/tag/v1.13.2
+[irb-v1.14.0]: https://github.com/ruby/irb/releases/tag/v1.14.0
+[irb-v1.14.1]: https://github.com/ruby/irb/releases/tag/v1.14.1
+[irb-v1.14.2]: https://github.com/ruby/irb/releases/tag/v1.14.2
+[irb-v1.14.3]: https://github.com/ruby/irb/releases/tag/v1.14.3
+[json-v2.7.2]: https://github.com/ruby/json/releases/tag/v2.7.2
+[json-v2.7.3.rc1]: https://github.com/ruby/json/releases/tag/v2.7.3.rc1
+[json-v2.7.3]: https://github.com/ruby/json/releases/tag/v2.7.3
+[json-v2.7.4]: https://github.com/ruby/json/releases/tag/v2.7.4
+[json-v2.7.5]: https://github.com/ruby/json/releases/tag/v2.7.5
+[json-v2.7.6]: https://github.com/ruby/json/releases/tag/v2.7.6
+[json-v2.8.0]: https://github.com/ruby/json/releases/tag/v2.8.0
+[json-v2.8.1]: https://github.com/ruby/json/releases/tag/v2.8.1
+[json-v2.8.2]: https://github.com/ruby/json/releases/tag/v2.8.2
+[json-v2.9.0]: https://github.com/ruby/json/releases/tag/v2.9.0
+[json-v2.9.1]: https://github.com/ruby/json/releases/tag/v2.9.1
+[logger-v1.6.1]: https://github.com/ruby/logger/releases/tag/v1.6.1
+[logger-v1.6.2]: https://github.com/ruby/logger/releases/tag/v1.6.2
+[logger-v1.6.3]: https://github.com/ruby/logger/releases/tag/v1.6.3
+[logger-v1.6.4]: https://github.com/ruby/logger/releases/tag/v1.6.4
+[net-http-v0.4.1]: https://github.com/ruby/net-http/releases/tag/v0.4.1
+[net-http-v0.5.0]: https://github.com/ruby/net-http/releases/tag/v0.5.0
+[net-http-v0.6.0]: https://github.com/ruby/net-http/releases/tag/v0.6.0
+[open-uri-v0.5.0]: https://github.com/ruby/open-uri/releases/tag/v0.5.0
+[optparse-v0.5.0]: https://github.com/ruby/optparse/releases/tag/v0.5.0
+[optparse-v0.6.0]: https://github.com/ruby/optparse/releases/tag/v0.6.0
+[ostruct-v0.6.1]: https://github.com/ruby/ostruct/releases/tag/v0.6.1
+[pathname-v0.4.0]: https://github.com/ruby/pathname/releases/tag/v0.4.0
+[pp-v0.6.0]: https://github.com/ruby/pp/releases/tag/v0.6.0
+[pp-v0.6.1]: https://github.com/ruby/pp/releases/tag/v0.6.1
+[pp-v0.6.2]: https://github.com/ruby/pp/releases/tag/v0.6.2
+[prism-v0.20.0]: https://github.com/ruby/prism/releases/tag/v0.20.0
+[prism-v0.21.0]: https://github.com/ruby/prism/releases/tag/v0.21.0
+[prism-v0.22.0]: https://github.com/ruby/prism/releases/tag/v0.22.0
+[prism-v0.23.0]: https://github.com/ruby/prism/releases/tag/v0.23.0
+[prism-v0.24.0]: https://github.com/ruby/prism/releases/tag/v0.24.0
+[prism-v0.25.0]: https://github.com/ruby/prism/releases/tag/v0.25.0
+[prism-v0.26.0]: https://github.com/ruby/prism/releases/tag/v0.26.0
+[prism-v0.27.0]: https://github.com/ruby/prism/releases/tag/v0.27.0
+[prism-v0.28.0]: https://github.com/ruby/prism/releases/tag/v0.28.0
+[prism-v0.29.0]: https://github.com/ruby/prism/releases/tag/v0.29.0
+[prism-v0.30.0]: https://github.com/ruby/prism/releases/tag/v0.30.0
+[prism-v1.0.0]: https://github.com/ruby/prism/releases/tag/v1.0.0
+[prism-v1.1.0]: https://github.com/ruby/prism/releases/tag/v1.1.0
+[prism-v1.2.0]: https://github.com/ruby/prism/releases/tag/v1.2.0
+[pstore-v0.1.4]: https://github.com/ruby/pstore/releases/tag/v0.1.4
+[psych-v5.2.0.beta1]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta1
+[psych-v5.2.0]: https://github.com/ruby/psych/releases/tag/v5.2.0
+[psych-v5.2.0.beta2]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta2
+[psych-v5.2.0.beta3]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta3
+[psych-v5.2.0.beta4]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta4
+[psych-v5.2.0.beta5]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta5
+[psych-v5.2.0.beta6]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta6
+[psych-v5.2.0.beta7]: https://github.com/ruby/psych/releases/tag/v5.2.0.beta7
+[psych-v5.2.1]: https://github.com/ruby/psych/releases/tag/v5.2.1
+[psych-v5.2.2]: https://github.com/ruby/psych/releases/tag/v5.2.2
+[rdoc-v6.7.0]: https://github.com/ruby/rdoc/releases/tag/v6.7.0
+[rdoc-v6.8.0]: https://github.com/ruby/rdoc/releases/tag/v6.8.0
+[rdoc-v6.8.1]: https://github.com/ruby/rdoc/releases/tag/v6.8.1
+[rdoc-v6.9.0]: https://github.com/ruby/rdoc/releases/tag/v6.9.0
+[rdoc-v6.9.1]: https://github.com/ruby/rdoc/releases/tag/v6.9.1
+[rdoc-v6.10.0]: https://github.com/ruby/rdoc/releases/tag/v6.10.0
+[reline-v0.5.0.pre.1]: https://github.com/ruby/reline/releases/tag/v0.5.0.pre.1
+[reline-v0.4.2]: https://github.com/ruby/reline/releases/tag/v0.4.2
+[reline-v0.4.3]: https://github.com/ruby/reline/releases/tag/v0.4.3
+[reline-v0.5.0]: https://github.com/ruby/reline/releases/tag/v0.5.0
+[reline-v0.5.1]: https://github.com/ruby/reline/releases/tag/v0.5.1
+[reline-v0.5.2]: https://github.com/ruby/reline/releases/tag/v0.5.2
+[reline-v0.5.3]: https://github.com/ruby/reline/releases/tag/v0.5.3
+[reline-v0.5.4]: https://github.com/ruby/reline/releases/tag/v0.5.4
+[reline-v0.5.5]: https://github.com/ruby/reline/releases/tag/v0.5.5
+[reline-v0.5.6]: https://github.com/ruby/reline/releases/tag/v0.5.6
+[reline-v0.5.7]: https://github.com/ruby/reline/releases/tag/v0.5.7
+[reline-v0.5.8]: https://github.com/ruby/reline/releases/tag/v0.5.8
+[reline-v0.5.9]: https://github.com/ruby/reline/releases/tag/v0.5.9
+[reline-v0.5.10]: https://github.com/ruby/reline/releases/tag/v0.5.10
+[reline-v0.5.11]: https://github.com/ruby/reline/releases/tag/v0.5.11
+[reline-v0.5.12]: https://github.com/ruby/reline/releases/tag/v0.5.12
+[reline-v0.6.0]: https://github.com/ruby/reline/releases/tag/v0.6.0
+[resolv-v0.4.0]: https://github.com/ruby/resolv/releases/tag/v0.4.0
+[resolv-v0.5.0]: https://github.com/ruby/resolv/releases/tag/v0.5.0
+[resolv-v0.6.0]: https://github.com/ruby/resolv/releases/tag/v0.6.0
+[securerandom-v0.3.2]: https://github.com/ruby/securerandom/releases/tag/v0.3.2
+[securerandom-v0.4.0]: https://github.com/ruby/securerandom/releases/tag/v0.4.0
+[securerandom-v0.4.1]: https://github.com/ruby/securerandom/releases/tag/v0.4.1
+[set-v1.1.1]: https://github.com/ruby/set/releases/tag/v1.1.1
+[shellwords-v0.2.1]: https://github.com/ruby/shellwords/releases/tag/v0.2.1
+[shellwords-v0.2.2]: https://github.com/ruby/shellwords/releases/tag/v0.2.2
+[singleton-v0.3.0]: https://github.com/ruby/singleton/releases/tag/v0.3.0
+[stringio-v3.1.1]: https://github.com/ruby/stringio/releases/tag/v3.1.1
+[stringio-v3.1.2]: https://github.com/ruby/stringio/releases/tag/v3.1.2
+[strscan-v3.0.8]: https://github.com/ruby/strscan/releases/tag/v3.0.8
+[strscan-v3.0.9]: https://github.com/ruby/strscan/releases/tag/v3.0.9
+[strscan-v3.1.0]: https://github.com/ruby/strscan/releases/tag/v3.1.0
+[strscan-v3.1.1]: https://github.com/ruby/strscan/releases/tag/v3.1.1
+[strscan-v3.1.2]: https://github.com/ruby/strscan/releases/tag/v3.1.2
+[syntax_suggest-v2.0.1]: https://github.com/ruby/syntax_suggest/releases/tag/v2.0.1
+[syntax_suggest-v2.0.2]: https://github.com/ruby/syntax_suggest/releases/tag/v2.0.2
+[tempfile-v0.3.0]: https://github.com/ruby/tempfile/releases/tag/v0.3.0
+[tempfile-v0.3.1]: https://github.com/ruby/tempfile/releases/tag/v0.3.1
+[time-v0.4.0]: https://github.com/ruby/time/releases/tag/v0.4.0
+[time-v0.4.1]: https://github.com/ruby/time/releases/tag/v0.4.1
+[timeout-v0.4.2]: https://github.com/ruby/timeout/releases/tag/v0.4.2
+[timeout-v0.4.3]: https://github.com/ruby/timeout/releases/tag/v0.4.3
+[tmpdir-v0.3.0]: https://github.com/ruby/tmpdir/releases/tag/v0.3.0
+[tmpdir-v0.3.1]: https://github.com/ruby/tmpdir/releases/tag/v0.3.1
+[uri-v0.13.1]: https://github.com/ruby/uri/releases/tag/v0.13.1
+[uri-v1.0.0]: https://github.com/ruby/uri/releases/tag/v1.0.0
+[uri-v1.0.1]: https://github.com/ruby/uri/releases/tag/v1.0.1
+[uri-v1.0.2]: https://github.com/ruby/uri/releases/tag/v1.0.2
+[win32ole-v1.9.0]: https://github.com/ruby/win32ole/releases/tag/v1.9.0
+[win32ole-v1.9.1]: https://github.com/ruby/win32ole/releases/tag/v1.9.1
+[yaml-v0.4.0]: https://github.com/ruby/yaml/releases/tag/v0.4.0
+[zlib-v3.1.1]: https://github.com/ruby/zlib/releases/tag/v3.1.1
+[zlib-v3.2.0]: https://github.com/ruby/zlib/releases/tag/v3.2.0
+[zlib-v3.2.1]: https://github.com/ruby/zlib/releases/tag/v3.2.1
+[minitest-v5.25.4]: https://github.com/seattlerb/minitest/releases/tag/v5.25.4
+[power_assert-v2.0.4]: https://github.com/ruby/power_assert/releases/tag/v2.0.4
+[power_assert-v2.0.5]: https://github.com/ruby/power_assert/releases/tag/v2.0.5
+[rake-v13.2.0]: https://github.com/ruby/rake/releases/tag/v13.2.0
+[rake-v13.2.1]: https://github.com/ruby/rake/releases/tag/v13.2.1
+[test-unit-3.6.2]: https://github.com/test-unit/test-unit/releases/tag/3.6.2
+[test-unit-3.6.3]: https://github.com/test-unit/test-unit/releases/tag/3.6.3
+[test-unit-3.6.4]: https://github.com/test-unit/test-unit/releases/tag/3.6.4
+[test-unit-3.6.5]: https://github.com/test-unit/test-unit/releases/tag/3.6.5
+[test-unit-3.6.6]: https://github.com/test-unit/test-unit/releases/tag/3.6.6
+[test-unit-3.6.7]: https://github.com/test-unit/test-unit/releases/tag/3.6.7
+[rexml-v3.2.7]: https://github.com/ruby/rexml/releases/tag/v3.2.7
+[rexml-v3.2.8]: https://github.com/ruby/rexml/releases/tag/v3.2.8
+[rexml-v3.2.9]: https://github.com/ruby/rexml/releases/tag/v3.2.9
+[rexml-v3.3.0]: https://github.com/ruby/rexml/releases/tag/v3.3.0
+[rexml-v3.3.1]: https://github.com/ruby/rexml/releases/tag/v3.3.1
+[rexml-v3.3.2]: https://github.com/ruby/rexml/releases/tag/v3.3.2
+[rexml-v3.3.3]: https://github.com/ruby/rexml/releases/tag/v3.3.3
+[rexml-v3.3.4]: https://github.com/ruby/rexml/releases/tag/v3.3.4
+[rexml-v3.3.5]: https://github.com/ruby/rexml/releases/tag/v3.3.5
+[rexml-v3.3.6]: https://github.com/ruby/rexml/releases/tag/v3.3.6
+[rexml-v3.3.7]: https://github.com/ruby/rexml/releases/tag/v3.3.7
+[rexml-v3.3.8]: https://github.com/ruby/rexml/releases/tag/v3.3.8
+[rexml-v3.3.9]: https://github.com/ruby/rexml/releases/tag/v3.3.9
+[rexml-v3.4.0]: https://github.com/ruby/rexml/releases/tag/v3.4.0
+[rss-0.3.1]: https://github.com/ruby/rss/releases/tag/0.3.1
+[net-ftp-v0.3.4]: https://github.com/ruby/net-ftp/releases/tag/v0.3.4
+[net-ftp-v0.3.5]: https://github.com/ruby/net-ftp/releases/tag/v0.3.5
+[net-ftp-v0.3.6]: https://github.com/ruby/net-ftp/releases/tag/v0.3.6
+[net-ftp-v0.3.7]: https://github.com/ruby/net-ftp/releases/tag/v0.3.7
+[net-ftp-v0.3.8]: https://github.com/ruby/net-ftp/releases/tag/v0.3.8
+[net-imap-v0.4.9.1]: https://github.com/ruby/net-imap/releases/tag/v0.4.9.1
+[net-imap-v0.4.10]: https://github.com/ruby/net-imap/releases/tag/v0.4.10
+[net-imap-v0.4.11]: https://github.com/ruby/net-imap/releases/tag/v0.4.11
+[net-imap-v0.4.12]: https://github.com/ruby/net-imap/releases/tag/v0.4.12
+[net-imap-v0.4.13]: https://github.com/ruby/net-imap/releases/tag/v0.4.13
+[net-imap-v0.4.14]: https://github.com/ruby/net-imap/releases/tag/v0.4.14
+[net-imap-v0.4.15]: https://github.com/ruby/net-imap/releases/tag/v0.4.15
+[net-imap-v0.4.16]: https://github.com/ruby/net-imap/releases/tag/v0.4.16
+[net-imap-v0.4.17]: https://github.com/ruby/net-imap/releases/tag/v0.4.17
+[net-imap-v0.5.0]: https://github.com/ruby/net-imap/releases/tag/v0.5.0
+[net-imap-v0.4.18]: https://github.com/ruby/net-imap/releases/tag/v0.4.18
+[net-imap-v0.5.1]: https://github.com/ruby/net-imap/releases/tag/v0.5.1
+[net-imap-v0.5.2]: https://github.com/ruby/net-imap/releases/tag/v0.5.2
+[net-imap-v0.5.3]: https://github.com/ruby/net-imap/releases/tag/v0.5.3
+[net-imap-v0.5.4]: https://github.com/ruby/net-imap/releases/tag/v0.5.4
+[net-smtp-v0.4.0.1]: https://github.com/ruby/net-smtp/releases/tag/v0.4.0.1
+[net-smtp-v0.5.0]: https://github.com/ruby/net-smtp/releases/tag/v0.5.0
+[prime-v0.1.3]: https://github.com/ruby/prime/releases/tag/v0.1.3
+[rbs-v3.4.1]: https://github.com/ruby/rbs/releases/tag/v3.4.1
+[rbs-v3.4.2]: https://github.com/ruby/rbs/releases/tag/v3.4.2
+[rbs-v3.4.3]: https://github.com/ruby/rbs/releases/tag/v3.4.3
+[rbs-v3.4.4]: https://github.com/ruby/rbs/releases/tag/v3.4.4
+[rbs-v3.5.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.5.0.pre.1
+[rbs-v3.5.0.pre.2]: https://github.com/ruby/rbs/releases/tag/v3.5.0.pre.2
+[rbs-v3.5.0]: https://github.com/ruby/rbs/releases/tag/v3.5.0
+[rbs-v3.5.1]: https://github.com/ruby/rbs/releases/tag/v3.5.1
+[rbs-v3.5.2]: https://github.com/ruby/rbs/releases/tag/v3.5.2
+[rbs-v3.5.3]: https://github.com/ruby/rbs/releases/tag/v3.5.3
+[rbs-v3.6.0.dev.1]: https://github.com/ruby/rbs/releases/tag/v3.6.0.dev.1
+[rbs-v3.6.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.6.0.pre.1
+[rbs-v3.6.0.pre.2]: https://github.com/ruby/rbs/releases/tag/v3.6.0.pre.2
+[rbs-v3.6.0.pre.3]: https://github.com/ruby/rbs/releases/tag/v3.6.0.pre.3
+[rbs-v3.6.0]: https://github.com/ruby/rbs/releases/tag/v3.6.0
+[rbs-v3.6.1]: https://github.com/ruby/rbs/releases/tag/v3.6.1
+[rbs-v3.7.0.dev.1]: https://github.com/ruby/rbs/releases/tag/v3.7.0.dev.1
+[rbs-v3.7.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.7.0.pre.1
+[rbs-v3.7.0]: https://github.com/ruby/rbs/releases/tag/v3.7.0
+[rbs-v3.8.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.8.0.pre.1
+[rbs-v3.8.0]: https://github.com/ruby/rbs/releases/tag/v3.8.0
+[debug-v1.9.2]: https://github.com/ruby/debug/releases/tag/v1.9.2
+[debug-v1.10.0]: https://github.com/ruby/debug/releases/tag/v1.10.0
+[racc-v1.8.0]: https://github.com/ruby/racc/releases/tag/v1.8.0
+[racc-v1.8.1]: https://github.com/ruby/racc/releases/tag/v1.8.1
+[mutex_m-v0.3.0]: https://github.com/ruby/mutex_m/releases/tag/v0.3.0
+[bigdecimal-v3.1.6]: https://github.com/ruby/bigdecimal/releases/tag/v3.1.6
+[bigdecimal-v3.1.7]: https://github.com/ruby/bigdecimal/releases/tag/v3.1.7
+[bigdecimal-v3.1.8]: https://github.com/ruby/bigdecimal/releases/tag/v3.1.8
+[drb-v2.2.1]: https://github.com/ruby/drb/releases/tag/v2.2.1
+[nkf-v0.2.0]: https://github.com/ruby/nkf/releases/tag/v0.2.0
+[syslog-v0.2.0]: https://github.com/ruby/syslog/releases/tag/v0.2.0
+[csv-v3.2.9]: https://github.com/ruby/csv/releases/tag/v3.2.9
+[csv-v3.3.0]: https://github.com/ruby/csv/releases/tag/v3.3.0
+[csv-v3.3.1]: https://github.com/ruby/csv/releases/tag/v3.3.1
+[csv-v3.3.2]: https://github.com/ruby/csv/releases/tag/v3.3.2
+[ruby/net-http-sspi]: https://github.com/ruby/net-http-sspi
+[typeprof-v0.30.1]: https://github.com/ruby/typeprof/releases/tag/v0.30.1
+
+[RubyGems]: https://github.com/rubygems/rubygems
+[benchmark]: https://github.com/ruby/benchmark
+[bundler]: https://github.com/rubygems/rubygems
+[date]: https://github.com/ruby/date
+[delegate]: https://github.com/ruby/delegate
+[did_you_mean]: https://github.com/ruby/did_you_mean
+[digest]: https://github.com/ruby/digest
+[erb]: https://github.com/ruby/erb
+[error_highlight]: https://github.com/ruby/error_highlight
+[etc]: https://github.com/ruby/etc
+[fcntl]: https://github.com/ruby/fcntl
+[fiddle]: https://github.com/ruby/fiddle
+[fileutils]: https://github.com/ruby/fileutils
+[io-console]: https://github.com/ruby/io-console
+[io-nonblock]: https://github.com/ruby/io-nonblock
+[ipaddr]: https://github.com/ruby/ipaddr
+[irb]: https://github.com/ruby/irb
+[json]: https://github.com/ruby/json
+[logger]: https://github.com/ruby/logger
+[net-http]: https://github.com/ruby/net-http
+[open-uri]: https://github.com/ruby/open-uri
+[optparse]: https://github.com/ruby/optparse
+[ostruct]: https://github.com/ruby/ostruct
+[pathname]: https://github.com/ruby/pathname
+[pp]: https://github.com/ruby/pp
+[prism]: https://github.com/ruby/prism
+[pstore]: https://github.com/ruby/pstore
+[psych]: https://github.com/ruby/psych
+[rdoc]: https://github.com/ruby/rdoc
+[reline]: https://github.com/ruby/reline
+[resolv]: https://github.com/ruby/resolv
+[securerandom]: https://github.com/ruby/securerandom
+[set]: https://github.com/ruby/set
+[shellwords]: https://github.com/ruby/shellwords
+[singleton]: https://github.com/ruby/singleton
+[stringio]: https://github.com/ruby/stringio
+[strscan]: https://github.com/ruby/strscan
+[syntax_suggest]: https://github.com/ruby/syntax_suggest
+[tempfile]: https://github.com/ruby/tempfile
+[time]: https://github.com/ruby/time
+[timeout]: https://github.com/ruby/timeout
+[tmpdir]: https://github.com/ruby/tmpdir
+[uri]: https://github.com/ruby/uri
+[win32ole]: https://github.com/ruby/win32ole
+[yaml]: https://github.com/ruby/yaml
+[zlib]: https://github.com/ruby/zlib
+
+[repl_type_completor]: https://github.com/ruby/repl_type_completor
+[minitest]: https://github.com/seattlerb/minitest
+[power_assert]: https://github.com/ruby/power_assert
+[rake]: https://github.com/ruby/rake
+[test-unit]: https://github.com/test-unit/test-unit
+[rexml]: https://github.com/ruby/rexml
+[rss]: https://github.com/ruby/rss
+[net-ftp]: https://github.com/ruby/net-ftp
+[net-imap]: https://github.com/ruby/net-imap
+[net-smtp]: https://github.com/ruby/net-smtp
+[prime]: https://github.com/ruby/prime
+[rbs]: https://github.com/ruby/rbs
+[typeprof]: https://github.com/ruby/typeprof
+[debug]: https://github.com/ruby/debug
+[racc]: https://github.com/ruby/racc
+[mutex_m]: https://github.com/ruby/mutex_m
+[getoptlong]: https://github.com/ruby/getoptlong
+[base64]: https://github.com/ruby/base64
+[bigdecimal]: https://github.com/ruby/bigdecimal
+[observer]: https://github.com/ruby/observer
+[abbrev]: https://github.com/ruby/abbrev
+[resolv-replace]: https://github.com/ruby/resolv-replace
+[rinda]: https://github.com/ruby/rinda
+[drb]: https://github.com/ruby/drb
+[nkf]: https://github.com/ruby/nkf
+[syslog]: https://github.com/ruby/syslog
+[csv]: https://github.com/ruby/csv
diff --git a/doc/NEWS/NEWS-4.0.0.md b/doc/NEWS/NEWS-4.0.0.md
new file mode 100644
index 0000000000..5d932fbf5d
--- /dev/null
+++ b/doc/NEWS/NEWS-4.0.0.md
@@ -0,0 +1,802 @@
+# NEWS for Ruby 4.0.0
+
+This document is a list of user-visible feature changes
+since the **3.4.0** release, except for bug fixes.
+
+Note that each entry is kept to a minimum, see links for details.
+
+## Language changes
+
+* `*nil` no longer calls `nil.to_a`, similar to how `**nil` does
+ not call `nil.to_hash`. [[Feature #21047]]
+
+* Logical binary operators (`||`, `&&`, `and` and `or`) at the
+ beginning of a line continue the previous line, like fluent dot.
+ The following code examples are equal:
+
+ ```ruby
+ if condition1
+ && condition2
+ ...
+ end
+ ```
+
+ Previously:
+
+ ```ruby
+ if condition1 && condition2
+ ...
+ end
+ ```
+
+ ```ruby
+ if condition1 &&
+ condition2
+ ...
+ end
+ ```
+
+ [[Feature #20925]]
+
+## Core classes updates
+
+Note: We're only listing outstanding class updates.
+
+* Array
+
+ * `Array#rfind` has been added as a more efficient alternative to `array.reverse_each.find` [[Feature #21678]]
+ * `Array#find` has been added as a more efficient override of `Enumerable#find` [[Feature #21678]]
+* Binding
+
+ * `Binding#local_variables` does no longer include numbered parameters.
+ Also, `Binding#local_variable_get`, `Binding#local_variable_set`, and
+ `Binding#local_variable_defined?` reject to handle numbered parameters.
+ [[Bug #21049]]
+
+ * `Binding#implicit_parameters`, `Binding#implicit_parameter_get`, and
+ `Binding#implicit_parameter_defined?` have been added to access
+ numbered parameters and "it" parameter. [[Bug #21049]]
+
+* Enumerator
+
+ * `Enumerator.produce` now accepts an optional `size` keyword argument
+ to specify the size of the enumerator. It can be an integer,
+ `Float::INFINITY`, a callable object (such as a lambda), or `nil` to
+ indicate unknown size. When not specified, the size defaults to
+ `Float::INFINITY`.
+
+ ```ruby
+ # Infinite enumerator
+ enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
+ enum.size # => Float::INFINITY
+
+ # Finite enumerator with known/computable size
+ abs_dir = File.expand_path("./baz") # => "/foo/bar/baz"
+ traverser = Enumerator.produce(abs_dir, size: -> { abs_dir.count("/") + 1 }) {
+ raise StopIteration if it == "/"
+ File.dirname(it)
+ }
+ traverser.size # => 4
+ ```
+
+ [[Feature #21701]]
+
+* ErrorHighlight
+
+ * When an ArgumentError is raised, it now displays code snippets for
+ both the method call (caller) and the method definition (callee).
+ [[Feature #21543]]
+
+ ```
+ test.rb:1:in 'Object#add': wrong number of arguments (given 1, expected 2) (ArgumentError)
+
+ caller: test.rb:3
+ | add(1)
+ ^^^
+ callee: test.rb:1
+ | def add(x, y) = x + y
+ ^^^
+ from test.rb:3:in '<main>'
+ ```
+
+* Fiber
+
+ * Introduce support for `Fiber#raise(cause:)` argument similar to
+ `Kernel#raise`. [[Feature #21360]]
+
+* Fiber::Scheduler
+
+ * Introduce `Fiber::Scheduler#fiber_interrupt` to interrupt a fiber with a
+ given exception. The initial use case is to interrupt a fiber that is
+ waiting on a blocking IO operation when the IO operation is closed.
+ [[Feature #21166]]
+
+ * Introduce `Fiber::Scheduler#yield` to allow the fiber scheduler to
+ continue processing when signal exceptions are disabled.
+ [[Bug #21633]]
+
+ * Reintroduce the `Fiber::Scheduler#io_close` hook for asynchronous `IO#close`.
+
+ * Invoke `Fiber::Scheduler#io_write` when flushing the IO write buffer.
+ [[Bug #21789]]
+
+* File
+
+ * `File::Stat#birthtime` is now available on Linux via the statx
+ system call when supported by the kernel and filesystem.
+ [[Feature #21205]]
+
+* IO
+
+ * `IO.select` accepts `Float::INFINITY` as a timeout argument.
+ [[Feature #20610]]
+
+ * A deprecated behavior, process creation by `IO` class methods
+ with a leading `|`, was removed. [[Feature #19630]]
+
+* Kernel
+
+ * `Kernel#inspect` now checks for the existence of a `#instance_variables_to_inspect` method,
+ allowing control over which instance variables are displayed in the `#inspect` string:
+
+ ```ruby
+ class DatabaseConfig
+ def initialize(host, user, password)
+ @host = host
+ @user = user
+ @password = password
+ end
+
+ private def instance_variables_to_inspect = [:@host, :@user]
+ end
+
+ conf = DatabaseConfig.new("localhost", "root", "hunter2")
+ conf.inspect #=> #<DatabaseConfig:0x0000000104def350 @host="localhost", @user="root">
+ ```
+
+ [[Feature #21219]]
+
+ * A deprecated behavior, process creation by `Kernel#open` with a
+ leading `|`, was removed. [[Feature #19630]]
+
+* Math
+
+ * `Math.log1p` and `Math.expm1` are added. [[Feature #21527]]
+
+* Pathname
+
+ * Pathname has been promoted from a default gem to a core class of Ruby.
+ [[Feature #17473]]
+
+* Proc
+
+ * `Proc#parameters` now shows anonymous optional parameters as `[:opt]`
+ instead of `[:opt, nil]`, making the output consistent with when the
+ anonymous parameter is required. [[Bug #20974]]
+
+* Ractor
+
+ * `Ractor::Port` class was added for a new synchronization mechanism
+ to communicate between Ractors. [[Feature #21262]]
+
+ ```ruby
+ port1 = Ractor::Port.new
+ port2 = Ractor::Port.new
+ Ractor.new port1, port2 do |port1, port2|
+ port1 << 1
+ port2 << 11
+ port1 << 2
+ port2 << 12
+ end
+ 2.times{ p port1.receive } #=> 1, 2
+ 2.times{ p port2.receive } #=> 11, 12
+ ```
+
+ `Ractor::Port` provides the following methods:
+
+ * `Ractor::Port#receive`
+ * `Ractor::Port#send` (or `Ractor::Port#<<`)
+ * `Ractor::Port#close`
+ * `Ractor::Port#closed?`
+
+ As a result, `Ractor.yield` and `Ractor#take` were removed.
+
+ * `Ractor#join` and `Ractor#value` were added to wait for the
+ termination of a Ractor. These are similar to `Thread#join`
+ and `Thread#value`.
+
+ * `Ractor#monitor` and `Ractor#unmonitor` were added as low-level
+ interfaces used internally to implement `Ractor#join`.
+
+ * `Ractor.select` now only accepts Ractors and Ports. If Ractors are given,
+ it returns when a Ractor terminates.
+
+ * `Ractor#default_port` was added. Each `Ractor` has a default port,
+ which is used by `Ractor.send`, `Ractor.receive`.
+
+ * `Ractor#close_incoming` and `Ractor#close_outgoing` were removed.
+
+ * `Ractor.shareable_proc` and `Ractor.shareable_lambda` are introduced
+ to make shareable Proc or lambda.
+ [[Feature #21550]], [[Feature #21557]]
+
+* Range
+
+ * `Range#to_set` now performs size checks to prevent issues with
+ endless ranges. [[Bug #21654]]
+
+ * `Range#overlap?` now correctly handles infinite (unbounded) ranges.
+ [[Bug #21185]]
+
+ * `Range#max` behavior on beginless integer ranges has been fixed.
+ [[Bug #21174]] [[Bug #21175]]
+
+* Ruby
+
+ * A new toplevel module `Ruby` has been defined, which contains
+ Ruby-related constants. This module was reserved in Ruby 3.4
+ and is now officially defined. [[Feature #20884]]
+
+* Ruby::Box
+
+ * A new (experimental) feature to provide separation about definitions.
+ For the detail of "Ruby Box", see [doc/language/box.md](doc/language/box.md).
+ [[Feature #21311]] [[Misc #21385]]
+
+* Set
+
+ * `Set` is now a core class, instead of an autoloaded stdlib class.
+ [[Feature #21216]]
+
+ * `Set#inspect` now uses a simpler display, similar to literal arrays.
+ (e.g., `Set[1, 2, 3]` instead of `#<Set: {1, 2, 3}>`). [[Feature #21389]]
+
+ * Passing arguments to `Set#to_set` and `Enumerable#to_set` is now deprecated.
+ [[Feature #21390]]
+
+* Socket
+
+ * `Socket.tcp` & `TCPSocket.new` accepts an `open_timeout` keyword argument to specify
+ the timeout for the initial connection. [[Feature #21347]]
+ * When a user-specified timeout occurred in `TCPSocket.new`, either `Errno::ETIMEDOUT`
+ or `IO::TimeoutError` could previously be raised depending on the situation.
+ This behavior has been unified so that `IO::TimeoutError` is now consistently raised.
+ (Please note that, in `Socket.tcp`, there are still cases where `Errno::ETIMEDOUT`
+ may be raised in similar situations, and that in both cases `Errno::ETIMEDOUT` may be
+ raised when the timeout occurs at the OS level.)
+
+* String
+
+ * Update Unicode to Version 17.0.0 and Emoji Version 17.0.
+ [[Feature #19908]][[Feature #20724]][[Feature #21275]] (also applies to Regexp)
+
+ * `String#strip`, `strip!`, `lstrip`, `lstrip!`, `rstrip`, and `rstrip!`
+ are extended to accept `*selectors` arguments. [[Feature #21552]]
+
+* Thread
+
+ * Introduce support for `Thread#raise(cause:)` argument similar to
+ `Kernel#raise`. [[Feature #21360]]
+
+## Stdlib updates
+
+We only list stdlib changes that are notable feature changes.
+
+Other changes are listed in the following sections. We also listed release
+history from the previous bundled version that is Ruby 3.4.0 if it has GitHub
+releases.
+
+The following bundled gems are promoted from default gems.
+
+* ostruct 0.6.3
+ * 0.6.1 to [v0.6.2][ostruct-v0.6.2], [v0.6.3][ostruct-v0.6.3]
+* pstore 0.2.0
+ * 0.1.4 to [v0.2.0][pstore-v0.2.0]
+* benchmark 0.5.0
+ * 0.4.0 to [v0.4.1][benchmark-v0.4.1], [v0.5.0][benchmark-v0.5.0]
+* logger 1.7.0
+ * 1.6.4 to [v1.6.5][logger-v1.6.5], [v1.6.6][logger-v1.6.6], [v1.7.0][logger-v1.7.0]
+* rdoc 7.0.3
+ * 6.14.0 to [v6.14.1][rdoc-v6.14.1], [v6.14.2][rdoc-v6.14.2], [v6.15.0][rdoc-v6.15.0], [v6.15.1][rdoc-v6.15.1], [v6.16.0][rdoc-v6.16.0], [v6.16.1][rdoc-v6.16.1], [v6.17.0][rdoc-v6.17.0], [v7.0.0][rdoc-v7.0.0], [v7.0.1][rdoc-v7.0.1], [v7.0.2][rdoc-v7.0.2], [v7.0.3][rdoc-v7.0.3]
+* win32ole 1.9.2
+ * 1.9.1 to [v1.9.2][win32ole-v1.9.2]
+* irb 1.16.0
+ * 1.14.3 to [v1.15.0][irb-v1.15.0], [v1.15.1][irb-v1.15.1], [v1.15.2][irb-v1.15.2], [v1.15.3][irb-v1.15.3], [v1.16.0][irb-v1.16.0]
+* reline 0.6.3
+ * 0.6.0 to [v0.6.1][reline-v0.6.1], [v0.6.2][reline-v0.6.2], [v0.6.3][reline-v0.6.3]
+* readline 0.0.4
+* fiddle 1.1.8
+ * 1.1.6 to [v1.1.7][fiddle-v1.1.7], [v1.1.8][fiddle-v1.1.8]
+
+The following default gem is added.
+
+* win32-registry 0.1.2
+
+The following default gems are updated.
+
+* RubyGems 4.0.3
+* bundler 4.0.3
+* date 3.5.1
+ * 3.4.1 to [v3.5.0][date-v3.5.0], [v3.5.1][date-v3.5.1]
+* delegate 0.6.1
+ * 0.4.0 to [v0.5.0][delegate-v0.5.0], [v0.6.0][delegate-v0.6.0], [v0.6.1][delegate-v0.6.1]
+* digest 3.2.1
+ * 3.2.0 to [v3.2.1][digest-v3.2.1]
+* english 0.8.1
+ * 0.8.0 to [v0.8.1][english-v0.8.1]
+* erb 6.0.1
+ * 4.0.4 to [v5.1.2][erb-v5.1.2], [v5.1.3][erb-v5.1.3], [v6.0.0][erb-v6.0.0], [v6.0.1][erb-v6.0.1]
+* error_highlight 0.7.1
+* etc 1.4.6
+* fcntl 1.3.0
+ * 1.2.0 to [v1.3.0][fcntl-v1.3.0]
+* fileutils 1.8.0
+ * 1.7.3 to [v1.8.0][fileutils-v1.8.0]
+* forwardable 1.4.0
+ * 1.3.3 to [v1.4.0][forwardable-v1.4.0]
+* io-console 0.8.2
+ * 0.8.1 to [v0.8.2][io-console-v0.8.2]
+* io-nonblock 0.3.2
+* io-wait 0.4.0
+ * 0.3.2 to [v0.3.3][io-wait-v0.3.3], [v0.3.5.test1][io-wait-v0.3.5.test1], [v0.3.5][io-wait-v0.3.5], [v0.3.6][io-wait-v0.3.6], [v0.4.0][io-wait-v0.4.0]
+* ipaddr 1.2.8
+* json 2.18.0
+ * 2.9.1 to [v2.10.0][json-v2.10.0], [v2.10.1][json-v2.10.1], [v2.10.2][json-v2.10.2], [v2.11.0][json-v2.11.0], [v2.11.1][json-v2.11.1], [v2.11.2][json-v2.11.2], [v2.11.3][json-v2.11.3], [v2.12.0][json-v2.12.0], [v2.12.1][json-v2.12.1], [v2.12.2][json-v2.12.2], [v2.13.0][json-v2.13.0], [v2.13.1][json-v2.13.1], [v2.13.2][json-v2.13.2], [v2.14.0][json-v2.14.0], [v2.14.1][json-v2.14.1], [v2.15.0][json-v2.15.0], [v2.15.1][json-v2.15.1], [v2.15.2][json-v2.15.2], [v2.16.0][json-v2.16.0], [v2.17.0][json-v2.17.0], [v2.17.1][json-v2.17.1], [v2.18.0][json-v2.18.0]
+* net-http 0.9.1
+ * 0.6.0 to [v0.7.0][net-http-v0.7.0], [v0.8.0][net-http-v0.8.0], [v0.9.0][net-http-v0.9.0], [v0.9.1][net-http-v0.9.1]
+* openssl 4.0.0
+ * 3.3.1 to [v3.3.2][openssl-v3.3.2], [v4.0.0][openssl-v4.0.0]
+* optparse 0.8.1
+ * 0.6.0 to [v0.7.0][optparse-v0.7.0], [v0.8.0][optparse-v0.8.0], [v0.8.1][optparse-v0.8.1]
+* pp 0.6.3
+ * 0.6.2 to [v0.6.3][pp-v0.6.3]
+* prism 1.7.0
+ * 1.5.2 to [v1.6.0][prism-v1.6.0], [v1.7.0][prism-v1.7.0]
+* psych 5.3.1
+ * 5.2.2 to [v5.2.3][psych-v5.2.3], [v5.2.4][psych-v5.2.4], [v5.2.5][psych-v5.2.5], [v5.2.6][psych-v5.2.6], [v5.3.0][psych-v5.3.0], [v5.3.1][psych-v5.3.1]
+* resolv 0.7.0
+ * 0.6.2 to [v0.6.3][resolv-v0.6.3], [v0.7.0][resolv-v0.7.0]
+* stringio 3.2.0
+ * 3.1.2 to [v3.1.3][stringio-v3.1.3], [v3.1.4][stringio-v3.1.4], [v3.1.5][stringio-v3.1.5], [v3.1.6][stringio-v3.1.6], [v3.1.7][stringio-v3.1.7], [v3.1.8][stringio-v3.1.8], [v3.1.9][stringio-v3.1.9], [v3.2.0][stringio-v3.2.0]
+* strscan 3.1.6
+ * 3.1.2 to [v3.1.3][strscan-v3.1.3], [v3.1.4][strscan-v3.1.4], [v3.1.5][strscan-v3.1.5], [v3.1.6][strscan-v3.1.6]
+* time 0.4.2
+ * 0.4.1 to [v0.4.2][time-v0.4.2]
+* timeout 0.6.0
+ * 0.4.3 to [v0.4.4][timeout-v0.4.4], [v0.5.0][timeout-v0.5.0], [v0.6.0][timeout-v0.6.0]
+* uri 1.1.1
+ * 1.0.4 to [v1.1.0][uri-v1.1.0], [v1.1.1][uri-v1.1.1]
+* weakref 0.1.4
+ * 0.1.3 to [v0.1.4][weakref-v0.1.4]
+* zlib 3.2.2
+ * 3.2.1 to [v3.2.2][zlib-v3.2.2]
+
+The following bundled gems are updated.
+
+* minitest 6.0.0
+* power_assert 3.0.1
+ * 2.0.5 to [v3.0.0][power_assert-v3.0.0], [v3.0.1][power_assert-v3.0.1]
+* rake 13.3.1
+ * 13.2.1 to [v13.3.0][rake-v13.3.0], [v13.3.1][rake-v13.3.1]
+* test-unit 3.7.5
+ * 3.6.7 to [3.6.8][test-unit-3.6.8], [3.6.9][test-unit-3.6.9], [3.7.0][test-unit-3.7.0], [3.7.1][test-unit-3.7.1], [3.7.2][test-unit-3.7.2], [3.7.3][test-unit-3.7.3], [3.7.4][test-unit-3.7.4], [3.7.5][test-unit-3.7.5]
+* rexml 3.4.4
+* rss 0.3.2
+ * 0.3.1 to [0.3.2][rss-0.3.2]
+* net-ftp 0.3.9
+ * 0.3.8 to [v0.3.9][net-ftp-v0.3.9]
+* net-imap 0.6.2
+ * 0.5.8 to [v0.5.9][net-imap-v0.5.9], [v0.5.10][net-imap-v0.5.10], [v0.5.11][net-imap-v0.5.11], [v0.5.12][net-imap-v0.5.12], [v0.5.13][net-imap-v0.5.13], [v0.6.0][net-imap-v0.6.0], [v0.6.1][net-imap-v0.6.1], [v0.6.2][net-imap-v0.6.2]
+* net-smtp 0.5.1
+ * 0.5.0 to [v0.5.1][net-smtp-v0.5.1]
+* matrix 0.4.3
+ * 0.4.2 to [v0.4.3][matrix-v0.4.3]
+* prime 0.1.4
+ * 0.1.3 to [v0.1.4][prime-v0.1.4]
+* rbs 3.10.0
+ * 3.8.0 to [v3.8.1][rbs-v3.8.1], [v3.9.0.dev.1][rbs-v3.9.0.dev.1], [v3.9.0.pre.1][rbs-v3.9.0.pre.1], [v3.9.0.pre.2][rbs-v3.9.0.pre.2], [v3.9.0][rbs-v3.9.0], [v3.9.1][rbs-v3.9.1], [v3.9.2][rbs-v3.9.2], [v3.9.3][rbs-v3.9.3], [v3.9.4][rbs-v3.9.4], [v3.9.5][rbs-v3.9.5], [v3.10.0.pre.1][rbs-v3.10.0.pre.1], [v3.10.0.pre.2][rbs-v3.10.0.pre.2], [v3.10.0][rbs-v3.10.0]
+* typeprof 0.31.1
+* debug 1.11.1
+ * 1.11.0 to [v1.11.1][debug-v1.11.1]
+* base64 0.3.0
+ * 0.2.0 to [v0.3.0][base64-v0.3.0]
+* bigdecimal 4.0.1
+ * 3.1.8 to [v3.2.0][bigdecimal-v3.2.0], [v3.2.1][bigdecimal-v3.2.1], [v3.2.2][bigdecimal-v3.2.2], [v3.2.3][bigdecimal-v3.2.3], [v3.3.0][bigdecimal-v3.3.0], [v3.3.1][bigdecimal-v3.3.1], [v4.0.0][bigdecimal-v4.0.0], [v4.0.1][bigdecimal-v4.0.1]
+* drb 2.2.3
+ * 2.2.1 to [v2.2.3][drb-v2.2.3]
+* syslog 0.3.0
+ * 0.2.0 to [v0.3.0][syslog-v0.3.0]
+* csv 3.3.5
+ * 3.3.2 to [v3.3.3][csv-v3.3.3], [v3.3.4][csv-v3.3.4], [v3.3.5][csv-v3.3.5]
+* repl_type_completor 0.1.12
+
+### RubyGems and Bundler
+
+Ruby 4.0 bundled RubyGems and Bundler version 4. see the following links for details.
+
+* [Upgrading to RubyGems/Bundler 4 - RubyGems Blog](https://blog.rubygems.org/2025/12/03/upgrade-to-rubygems-bundler-4.html)
+* [4.0.0 Released - RubyGems Blog](https://blog.rubygems.org/2025/12/03/4.0.0-released.html)
+* [4.0.1 Released - RubyGems Blog](https://blog.rubygems.org/2025/12/09/4.0.1-released.html)
+* [4.0.2 Released - RubyGems Blog](https://blog.rubygems.org/2025/12/17/4.0.2-released.html)
+* [4.0.3 Released - RubyGems Blog](https://blog.rubygems.org/2025/12/23/4.0.3-released.html)
+
+## Supported platforms
+
+* Windows
+
+ * Dropped support for MSVC versions older than 14.0 (_MSC_VER 1900).
+ This means Visual Studio 2015 or later is now required.
+
+## Compatibility issues
+
+* The following methods were removed from Ractor due to the addition of `Ractor::Port`:
+
+ * `Ractor.yield`
+ * `Ractor#take`
+ * `Ractor#close_incoming`
+ * `Ractor#close_outgoing`
+
+ [[Feature #21262]]
+
+* `ObjectSpace._id2ref` is deprecated. [[Feature #15408]]
+
+* `Process::Status#&` and `Process::Status#>>` have been removed.
+ They were deprecated in Ruby 3.3. [[Bug #19868]]
+
+* `rb_path_check` has been removed. This function was used for
+ `$SAFE` path checking which was removed in Ruby 2.7,
+ and was already deprecated.
+ [[Feature #20971]]
+
+* A backtrace for `ArgumentError` of "wrong number of arguments" now
+ include the receiver's class or module name (e.g., in `Foo#bar`
+ instead of in `bar`). [[Bug #21698]]
+
+* Backtraces no longer display `internal` frames.
+ These methods now appear as if it is in the Ruby source file,
+ consistent with other C-implemented methods. [[Bug #20968]]
+
+ Before:
+ ```
+ ruby -e '[1].fetch_values(42)'
+ <internal:array>:211:in 'Array#fetch': index 42 outside of array bounds: -1...1 (IndexError)
+ from <internal:array>:211:in 'block in Array#fetch_values'
+ from <internal:array>:211:in 'Array#map!'
+ from <internal:array>:211:in 'Array#fetch_values'
+ from -e:1:in '<main>'
+ ```
+
+ After:
+ ```
+ $ ruby -e '[1].fetch_values(42)'
+ -e:1:in 'Array#fetch_values': index 42 outside of array bounds: -1...1 (IndexError)
+ from -e:1:in '<main>'
+ ```
+
+## Stdlib compatibility issues
+
+* CGI library is removed from the default gems. Now we only provide `cgi/escape` for
+ the following methods:
+
+ * `CGI.escape` and `CGI.unescape`
+ * `CGI.escapeHTML` and `CGI.unescapeHTML`
+ * `CGI.escapeURIComponent` and `CGI.unescapeURIComponent`
+ * `CGI.escapeElement` and `CGI.unescapeElement`
+
+ [[Feature #21258]]
+
+* With the move of `Set` from stdlib to core class, `set/sorted_set.rb` has
+ been removed, and `SortedSet` is no longer an autoloaded constant. Please
+ install the `sorted_set` gem and `require 'sorted_set'` to use `SortedSet`.
+ [[Feature #21287]]
+
+* Net::HTTP
+
+ * The default behavior of automatically setting the `Content-Type` header
+ to `application/x-www-form-urlencoded` for requests with a body
+ (e.g., `POST`, `PUT`) when the header was not explicitly set has been
+ removed. If your application relied on this automatic default, your
+ requests will now be sent without a Content-Type header, potentially
+ breaking compatibility with certain servers.
+ [[GH-net-http #205]]
+
+## C API updates
+
+* IO
+
+ * `rb_thread_fd_close` is deprecated and now a no-op. If you need to expose
+ file descriptors from C extensions to Ruby code, create an `IO` instance
+ using `RUBY_IO_MODE_EXTERNAL` and use `rb_io_close(io)` to close it (this
+ also interrupts and waits for all pending operations on the `IO`
+ instance). Directly closing file descriptors does not interrupt pending
+ operations, and may lead to undefined behaviour. In other words, if two
+ `IO` objects share the same file descriptor, closing one does not affect
+ the other. [[Feature #18455]]
+
+* GVL
+
+ * `rb_thread_call_with_gvl` now works with or without the GVL.
+ This allows gems to avoid checking `ruby_thread_has_gvl_p`.
+ Please still be diligent about the GVL. [[Feature #20750]]
+
+* Set
+
+ * A C API for `Set` has been added. The following methods are supported:
+ [[Feature #21459]]
+
+ * `rb_set_foreach`
+ * `rb_set_new`
+ * `rb_set_new_capa`
+ * `rb_set_lookup`
+ * `rb_set_add`
+ * `rb_set_clear`
+ * `rb_set_delete`
+ * `rb_set_size`
+
+## Implementation improvements
+
+* `Class#new` (ex. `Object.new`) is faster in all cases, but especially when passing keyword arguments. This has also been integrated into YJIT and ZJIT. [[Feature #21254]]
+* GC heaps of different size pools now grow independently, reducing memory usage when only some pools contain long-lived objects
+* GC sweeping is faster on pages of large objects
+* "Generic ivar" objects (String, Array, `TypedData`, etc.) now use a new internal "fields" object for faster instance variable access
+* The GC avoids maintaining an internal `id2ref` table until it is first used, making `object_id` allocation and GC sweeping faster
+* `object_id` and `hash` are faster on Class and Module objects
+* Larger bignum Integers can remain embedded using variable width allocation
+* `Random`, `Enumerator::Product`, `Enumerator::Chain`, `Addrinfo`,
+ `StringScanner`, and some internal objects are now write-barrier protected,
+ which reduces GC overhead.
+
+### Ractor
+
+A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractor implementation closer to leaving experimental status.
+
+* Performance improvements
+ * Frozen strings and the symbol table internally use a lock-free hash set [[Feature #21268]]
+ * Method cache lookups avoid locking in most cases
+ * Class (and generic ivar) instance variable access is faster and avoids locking
+ * CPU cache contention is avoided in object allocation by using a per-ractor counter
+ * CPU cache contention is avoided in xmalloc/xfree by using a thread-local counter
+ * `object_id` avoids locking in most cases
+* Bug fixes and stability
+ * Fixed possible deadlocks when combining Ractors and Threads
+ * Fixed issues with require and autoload in a Ractor
+ * Fixed encoding/transcoding issues across Ractors
+ * Fixed race conditions in GC operations and method invalidation
+ * Fixed issues with processes forking after starting a Ractor
+ * GC allocation counts are now accurate under Ractors
+ * Fixed TracePoints not working after GC [[Bug #19112]]
+
+## JIT
+
+* ZJIT
+ * Introduce an [experimental method-based JIT compiler](https://docs.ruby-lang.org/en/master/jit/zjit_md.html).
+ Where available, ZJIT can be enabled at runtime with the `--zjit` option or by calling `RubyVM::ZJIT.enable`.
+ When building Ruby, Rust 1.85.0 or later is required to include ZJIT support.
+ * As of Ruby 4.0.0, ZJIT is faster than the interpreter, but not yet as fast as YJIT.
+ We encourage experimentation with ZJIT, but advise against deploying it in production for now.
+ * Our goal is to make ZJIT faster than YJIT and production-ready in Ruby 4.1.
+* YJIT
+ * `RubyVM::YJIT.runtime_stats`
+ * `ratio_in_yjit` no longer works in the default build.
+ Use `--enable-yjit=stats` on `configure` to enable it on `--yjit-stats`.
+ * Add `invalidate_everything` to default stats, which is
+ incremented when every code is invalidated by TracePoint.
+ * Add `mem_size:` and `call_threshold:` options to `RubyVM::YJIT.enable`.
+* RJIT
+ * `--rjit` is removed. We will move the implementation of the third-party JIT API
+ to the [ruby/rjit](https://github.com/ruby/rjit) repository.
+
+[Feature #15408]: https://bugs.ruby-lang.org/issues/15408
+[Feature #17473]: https://bugs.ruby-lang.org/issues/17473
+[Feature #18455]: https://bugs.ruby-lang.org/issues/18455
+[Bug #19112]: https://bugs.ruby-lang.org/issues/19112
+[Feature #19630]: https://bugs.ruby-lang.org/issues/19630
+[Bug #19868]: https://bugs.ruby-lang.org/issues/19868
+[Feature #19908]: https://bugs.ruby-lang.org/issues/19908
+[Feature #20610]: https://bugs.ruby-lang.org/issues/20610
+[Feature #20724]: https://bugs.ruby-lang.org/issues/20724
+[Feature #20750]: https://bugs.ruby-lang.org/issues/20750
+[Feature #20884]: https://bugs.ruby-lang.org/issues/20884
+[Feature #20925]: https://bugs.ruby-lang.org/issues/20925
+[Bug #20968]: https://bugs.ruby-lang.org/issues/20968
+[Feature #20971]: https://bugs.ruby-lang.org/issues/20971
+[Bug #20974]: https://bugs.ruby-lang.org/issues/20974
+[Feature #21047]: https://bugs.ruby-lang.org/issues/21047
+[Bug #21049]: https://bugs.ruby-lang.org/issues/21049
+[Feature #21166]: https://bugs.ruby-lang.org/issues/21166
+[Bug #21174]: https://bugs.ruby-lang.org/issues/21174
+[Bug #21175]: https://bugs.ruby-lang.org/issues/21175
+[Bug #21185]: https://bugs.ruby-lang.org/issues/21185
+[Feature #21205]: https://bugs.ruby-lang.org/issues/21205
+[Feature #21216]: https://bugs.ruby-lang.org/issues/21216
+[Feature #21219]: https://bugs.ruby-lang.org/issues/21219
+[Feature #21254]: https://bugs.ruby-lang.org/issues/21254
+[Feature #21258]: https://bugs.ruby-lang.org/issues/21258
+[Feature #21268]: https://bugs.ruby-lang.org/issues/21268
+[Feature #21262]: https://bugs.ruby-lang.org/issues/21262
+[Feature #21275]: https://bugs.ruby-lang.org/issues/21275
+[Feature #21287]: https://bugs.ruby-lang.org/issues/21287
+[Feature #21311]: https://bugs.ruby-lang.org/issues/21311
+[Feature #21347]: https://bugs.ruby-lang.org/issues/21347
+[Feature #21360]: https://bugs.ruby-lang.org/issues/21360
+[Misc #21385]: https://bugs.ruby-lang.org/issues/21385
+[Feature #21389]: https://bugs.ruby-lang.org/issues/21389
+[Feature #21390]: https://bugs.ruby-lang.org/issues/21390
+[Feature #21459]: https://bugs.ruby-lang.org/issues/21459
+[Feature #21527]: https://bugs.ruby-lang.org/issues/21527
+[Feature #21543]: https://bugs.ruby-lang.org/issues/21543
+[Feature #21550]: https://bugs.ruby-lang.org/issues/21550
+[Feature #21552]: https://bugs.ruby-lang.org/issues/21552
+[Feature #21557]: https://bugs.ruby-lang.org/issues/21557
+[Bug #21633]: https://bugs.ruby-lang.org/issues/21633
+[Bug #21654]: https://bugs.ruby-lang.org/issues/21654
+[Feature #21678]: https://bugs.ruby-lang.org/issues/21678
+[Bug #21698]: https://bugs.ruby-lang.org/issues/21698
+[Feature #21701]: https://bugs.ruby-lang.org/issues/21701
+[Bug #21789]: https://bugs.ruby-lang.org/issues/21789
+[GH-net-http #205]: https://github.com/ruby/net-http/issues/205
+[ostruct-v0.6.2]: https://github.com/ruby/ostruct/releases/tag/v0.6.2
+[ostruct-v0.6.3]: https://github.com/ruby/ostruct/releases/tag/v0.6.3
+[pstore-v0.2.0]: https://github.com/ruby/pstore/releases/tag/v0.2.0
+[benchmark-v0.4.1]: https://github.com/ruby/benchmark/releases/tag/v0.4.1
+[benchmark-v0.5.0]: https://github.com/ruby/benchmark/releases/tag/v0.5.0
+[logger-v1.6.5]: https://github.com/ruby/logger/releases/tag/v1.6.5
+[logger-v1.6.6]: https://github.com/ruby/logger/releases/tag/v1.6.6
+[logger-v1.7.0]: https://github.com/ruby/logger/releases/tag/v1.7.0
+[rdoc-v6.14.1]: https://github.com/ruby/rdoc/releases/tag/v6.14.1
+[rdoc-v6.14.2]: https://github.com/ruby/rdoc/releases/tag/v6.14.2
+[rdoc-v6.15.0]: https://github.com/ruby/rdoc/releases/tag/v6.15.0
+[rdoc-v6.15.1]: https://github.com/ruby/rdoc/releases/tag/v6.15.1
+[rdoc-v6.16.0]: https://github.com/ruby/rdoc/releases/tag/v6.16.0
+[rdoc-v6.16.1]: https://github.com/ruby/rdoc/releases/tag/v6.16.1
+[rdoc-v6.17.0]: https://github.com/ruby/rdoc/releases/tag/v6.17.0
+[rdoc-v7.0.0]: https://github.com/ruby/rdoc/releases/tag/v7.0.0
+[rdoc-v7.0.1]: https://github.com/ruby/rdoc/releases/tag/v7.0.1
+[rdoc-v7.0.2]: https://github.com/ruby/rdoc/releases/tag/v7.0.2
+[rdoc-v7.0.3]: https://github.com/ruby/rdoc/releases/tag/v7.0.3
+[win32ole-v1.9.2]: https://github.com/ruby/win32ole/releases/tag/v1.9.2
+[irb-v1.15.0]: https://github.com/ruby/irb/releases/tag/v1.15.0
+[irb-v1.15.1]: https://github.com/ruby/irb/releases/tag/v1.15.1
+[irb-v1.15.2]: https://github.com/ruby/irb/releases/tag/v1.15.2
+[irb-v1.15.3]: https://github.com/ruby/irb/releases/tag/v1.15.3
+[irb-v1.16.0]: https://github.com/ruby/irb/releases/tag/v1.16.0
+[reline-v0.6.1]: https://github.com/ruby/reline/releases/tag/v0.6.1
+[reline-v0.6.2]: https://github.com/ruby/reline/releases/tag/v0.6.2
+[reline-v0.6.3]: https://github.com/ruby/reline/releases/tag/v0.6.3
+[fiddle-v1.1.7]: https://github.com/ruby/fiddle/releases/tag/v1.1.7
+[fiddle-v1.1.8]: https://github.com/ruby/fiddle/releases/tag/v1.1.8
+[date-v3.5.0]: https://github.com/ruby/date/releases/tag/v3.5.0
+[date-v3.5.1]: https://github.com/ruby/date/releases/tag/v3.5.1
+[delegate-v0.5.0]: https://github.com/ruby/delegate/releases/tag/v0.5.0
+[delegate-v0.6.0]: https://github.com/ruby/delegate/releases/tag/v0.6.0
+[delegate-v0.6.1]: https://github.com/ruby/delegate/releases/tag/v0.6.1
+[digest-v3.2.1]: https://github.com/ruby/digest/releases/tag/v3.2.1
+[english-v0.8.1]: https://github.com/ruby/english/releases/tag/v0.8.1
+[erb-v5.1.2]: https://github.com/ruby/erb/releases/tag/v5.1.2
+[erb-v5.1.3]: https://github.com/ruby/erb/releases/tag/v5.1.3
+[erb-v6.0.0]: https://github.com/ruby/erb/releases/tag/v6.0.0
+[erb-v6.0.1]: https://github.com/ruby/erb/releases/tag/v6.0.1
+[fcntl-v1.3.0]: https://github.com/ruby/fcntl/releases/tag/v1.3.0
+[fileutils-v1.8.0]: https://github.com/ruby/fileutils/releases/tag/v1.8.0
+[forwardable-v1.4.0]: https://github.com/ruby/forwardable/releases/tag/v1.4.0
+[io-console-v0.8.2]: https://github.com/ruby/io-console/releases/tag/v0.8.2
+[io-wait-v0.3.3]: https://github.com/ruby/io-wait/releases/tag/v0.3.3
+[io-wait-v0.3.5.test1]: https://github.com/ruby/io-wait/releases/tag/v0.3.5.test1
+[io-wait-v0.3.5]: https://github.com/ruby/io-wait/releases/tag/v0.3.5
+[io-wait-v0.3.6]: https://github.com/ruby/io-wait/releases/tag/v0.3.6
+[io-wait-v0.4.0]: https://github.com/ruby/io-wait/releases/tag/v0.4.0
+[json-v2.10.0]: https://github.com/ruby/json/releases/tag/v2.10.0
+[json-v2.10.1]: https://github.com/ruby/json/releases/tag/v2.10.1
+[json-v2.10.2]: https://github.com/ruby/json/releases/tag/v2.10.2
+[json-v2.11.0]: https://github.com/ruby/json/releases/tag/v2.11.0
+[json-v2.11.1]: https://github.com/ruby/json/releases/tag/v2.11.1
+[json-v2.11.2]: https://github.com/ruby/json/releases/tag/v2.11.2
+[json-v2.11.3]: https://github.com/ruby/json/releases/tag/v2.11.3
+[json-v2.12.0]: https://github.com/ruby/json/releases/tag/v2.12.0
+[json-v2.12.1]: https://github.com/ruby/json/releases/tag/v2.12.1
+[json-v2.12.2]: https://github.com/ruby/json/releases/tag/v2.12.2
+[json-v2.13.0]: https://github.com/ruby/json/releases/tag/v2.13.0
+[json-v2.13.1]: https://github.com/ruby/json/releases/tag/v2.13.1
+[json-v2.13.2]: https://github.com/ruby/json/releases/tag/v2.13.2
+[json-v2.14.0]: https://github.com/ruby/json/releases/tag/v2.14.0
+[json-v2.14.1]: https://github.com/ruby/json/releases/tag/v2.14.1
+[json-v2.15.0]: https://github.com/ruby/json/releases/tag/v2.15.0
+[json-v2.15.1]: https://github.com/ruby/json/releases/tag/v2.15.1
+[json-v2.15.2]: https://github.com/ruby/json/releases/tag/v2.15.2
+[json-v2.16.0]: https://github.com/ruby/json/releases/tag/v2.16.0
+[json-v2.17.0]: https://github.com/ruby/json/releases/tag/v2.17.0
+[json-v2.17.1]: https://github.com/ruby/json/releases/tag/v2.17.1
+[json-v2.18.0]: https://github.com/ruby/json/releases/tag/v2.18.0
+[net-http-v0.7.0]: https://github.com/ruby/net-http/releases/tag/v0.7.0
+[net-http-v0.8.0]: https://github.com/ruby/net-http/releases/tag/v0.8.0
+[net-http-v0.9.0]: https://github.com/ruby/net-http/releases/tag/v0.9.0
+[net-http-v0.9.1]: https://github.com/ruby/net-http/releases/tag/v0.9.1
+[openssl-v3.3.2]: https://github.com/ruby/openssl/releases/tag/v3.3.2
+[openssl-v4.0.0]: https://github.com/ruby/openssl/releases/tag/v4.0.0
+[optparse-v0.7.0]: https://github.com/ruby/optparse/releases/tag/v0.7.0
+[optparse-v0.8.0]: https://github.com/ruby/optparse/releases/tag/v0.8.0
+[optparse-v0.8.1]: https://github.com/ruby/optparse/releases/tag/v0.8.1
+[pp-v0.6.3]: https://github.com/ruby/pp/releases/tag/v0.6.3
+[prism-v1.6.0]: https://github.com/ruby/prism/releases/tag/v1.6.0
+[prism-v1.7.0]: https://github.com/ruby/prism/releases/tag/v1.7.0
+[psych-v5.2.3]: https://github.com/ruby/psych/releases/tag/v5.2.3
+[psych-v5.2.4]: https://github.com/ruby/psych/releases/tag/v5.2.4
+[psych-v5.2.5]: https://github.com/ruby/psych/releases/tag/v5.2.5
+[psych-v5.2.6]: https://github.com/ruby/psych/releases/tag/v5.2.6
+[psych-v5.3.0]: https://github.com/ruby/psych/releases/tag/v5.3.0
+[psych-v5.3.1]: https://github.com/ruby/psych/releases/tag/v5.3.1
+[resolv-v0.6.3]: https://github.com/ruby/resolv/releases/tag/v0.6.3
+[resolv-v0.7.0]: https://github.com/ruby/resolv/releases/tag/v0.7.0
+[stringio-v3.1.3]: https://github.com/ruby/stringio/releases/tag/v3.1.3
+[stringio-v3.1.4]: https://github.com/ruby/stringio/releases/tag/v3.1.4
+[stringio-v3.1.5]: https://github.com/ruby/stringio/releases/tag/v3.1.5
+[stringio-v3.1.6]: https://github.com/ruby/stringio/releases/tag/v3.1.6
+[stringio-v3.1.7]: https://github.com/ruby/stringio/releases/tag/v3.1.7
+[stringio-v3.1.8]: https://github.com/ruby/stringio/releases/tag/v3.1.8
+[stringio-v3.1.9]: https://github.com/ruby/stringio/releases/tag/v3.1.9
+[stringio-v3.2.0]: https://github.com/ruby/stringio/releases/tag/v3.2.0
+[strscan-v3.1.3]: https://github.com/ruby/strscan/releases/tag/v3.1.3
+[strscan-v3.1.4]: https://github.com/ruby/strscan/releases/tag/v3.1.4
+[strscan-v3.1.5]: https://github.com/ruby/strscan/releases/tag/v3.1.5
+[strscan-v3.1.6]: https://github.com/ruby/strscan/releases/tag/v3.1.6
+[time-v0.4.2]: https://github.com/ruby/time/releases/tag/v0.4.2
+[timeout-v0.4.4]: https://github.com/ruby/timeout/releases/tag/v0.4.4
+[timeout-v0.5.0]: https://github.com/ruby/timeout/releases/tag/v0.5.0
+[timeout-v0.6.0]: https://github.com/ruby/timeout/releases/tag/v0.6.0
+[uri-v1.1.0]: https://github.com/ruby/uri/releases/tag/v1.1.0
+[uri-v1.1.1]: https://github.com/ruby/uri/releases/tag/v1.1.1
+[weakref-v0.1.4]: https://github.com/ruby/weakref/releases/tag/v0.1.4
+[zlib-v3.2.2]: https://github.com/ruby/zlib/releases/tag/v3.2.2
+[power_assert-v3.0.0]: https://github.com/ruby/power_assert/releases/tag/v3.0.0
+[power_assert-v3.0.1]: https://github.com/ruby/power_assert/releases/tag/v3.0.1
+[rake-v13.3.0]: https://github.com/ruby/rake/releases/tag/v13.3.0
+[rake-v13.3.1]: https://github.com/ruby/rake/releases/tag/v13.3.1
+[test-unit-3.6.8]: https://github.com/test-unit/test-unit/releases/tag/3.6.8
+[test-unit-3.6.9]: https://github.com/test-unit/test-unit/releases/tag/3.6.9
+[test-unit-3.7.0]: https://github.com/test-unit/test-unit/releases/tag/3.7.0
+[test-unit-3.7.1]: https://github.com/test-unit/test-unit/releases/tag/3.7.1
+[test-unit-3.7.2]: https://github.com/test-unit/test-unit/releases/tag/3.7.2
+[test-unit-3.7.3]: https://github.com/test-unit/test-unit/releases/tag/3.7.3
+[test-unit-3.7.4]: https://github.com/test-unit/test-unit/releases/tag/3.7.4
+[test-unit-3.7.5]: https://github.com/test-unit/test-unit/releases/tag/3.7.5
+[rss-0.3.2]: https://github.com/ruby/rss/releases/tag/0.3.2
+[net-ftp-v0.3.9]: https://github.com/ruby/net-ftp/releases/tag/v0.3.9
+[net-imap-v0.5.9]: https://github.com/ruby/net-imap/releases/tag/v0.5.9
+[net-imap-v0.5.10]: https://github.com/ruby/net-imap/releases/tag/v0.5.10
+[net-imap-v0.5.11]: https://github.com/ruby/net-imap/releases/tag/v0.5.11
+[net-imap-v0.5.12]: https://github.com/ruby/net-imap/releases/tag/v0.5.12
+[net-imap-v0.5.13]: https://github.com/ruby/net-imap/releases/tag/v0.5.13
+[net-imap-v0.6.0]: https://github.com/ruby/net-imap/releases/tag/v0.6.0
+[net-imap-v0.6.1]: https://github.com/ruby/net-imap/releases/tag/v0.6.1
+[net-imap-v0.6.2]: https://github.com/ruby/net-imap/releases/tag/v0.6.2
+[net-smtp-v0.5.1]: https://github.com/ruby/net-smtp/releases/tag/v0.5.1
+[matrix-v0.4.3]: https://github.com/ruby/matrix/releases/tag/v0.4.3
+[prime-v0.1.4]: https://github.com/ruby/prime/releases/tag/v0.1.4
+[rbs-v3.8.1]: https://github.com/ruby/rbs/releases/tag/v3.8.1
+[rbs-v3.9.0.dev.1]: https://github.com/ruby/rbs/releases/tag/v3.9.0.dev.1
+[rbs-v3.9.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.9.0.pre.1
+[rbs-v3.9.0.pre.2]: https://github.com/ruby/rbs/releases/tag/v3.9.0.pre.2
+[rbs-v3.9.0]: https://github.com/ruby/rbs/releases/tag/v3.9.0
+[rbs-v3.9.1]: https://github.com/ruby/rbs/releases/tag/v3.9.1
+[rbs-v3.9.2]: https://github.com/ruby/rbs/releases/tag/v3.9.2
+[rbs-v3.9.3]: https://github.com/ruby/rbs/releases/tag/v3.9.3
+[rbs-v3.9.4]: https://github.com/ruby/rbs/releases/tag/v3.9.4
+[rbs-v3.9.5]: https://github.com/ruby/rbs/releases/tag/v3.9.5
+[rbs-v3.10.0.pre.1]: https://github.com/ruby/rbs/releases/tag/v3.10.0.pre.1
+[rbs-v3.10.0.pre.2]: https://github.com/ruby/rbs/releases/tag/v3.10.0.pre.2
+[rbs-v3.10.0]: https://github.com/ruby/rbs/releases/tag/v3.10.0
+[debug-v1.11.1]: https://github.com/ruby/debug/releases/tag/v1.11.1
+[base64-v0.3.0]: https://github.com/ruby/base64/releases/tag/v0.3.0
+[bigdecimal-v3.2.0]: https://github.com/ruby/bigdecimal/releases/tag/v3.2.0
+[bigdecimal-v3.2.1]: https://github.com/ruby/bigdecimal/releases/tag/v3.2.1
+[bigdecimal-v3.2.2]: https://github.com/ruby/bigdecimal/releases/tag/v3.2.2
+[bigdecimal-v3.2.3]: https://github.com/ruby/bigdecimal/releases/tag/v3.2.3
+[bigdecimal-v3.3.0]: https://github.com/ruby/bigdecimal/releases/tag/v3.3.0
+[bigdecimal-v3.3.1]: https://github.com/ruby/bigdecimal/releases/tag/v3.3.1
+[bigdecimal-v4.0.0]: https://github.com/ruby/bigdecimal/releases/tag/v4.0.0
+[bigdecimal-v4.0.1]: https://github.com/ruby/bigdecimal/releases/tag/v4.0.1
+[drb-v2.2.3]: https://github.com/ruby/drb/releases/tag/v2.2.3
+[syslog-v0.3.0]: https://github.com/ruby/syslog/releases/tag/v0.3.0
+[csv-v3.3.3]: https://github.com/ruby/csv/releases/tag/v3.3.3
+[csv-v3.3.4]: https://github.com/ruby/csv/releases/tag/v3.3.4
+[csv-v3.3.5]: https://github.com/ruby/csv/releases/tag/v3.3.5
diff --git a/doc/_regexp.rdoc b/doc/_regexp.rdoc
new file mode 100644
index 0000000000..4ad6118ddd
--- /dev/null
+++ b/doc/_regexp.rdoc
@@ -0,0 +1,1291 @@
+A {regular expression}[https://en.wikipedia.org/wiki/Regular_expression]
+(also called a _regexp_) is a <i>match pattern</i> (also simply called a _pattern_).
+
+A common notation for a regexp uses enclosing slash characters:
+
+ /foo/
+
+A regexp may be applied to a <i>target string</i>;
+The part of the string (if any) that matches the pattern is called a _match_,
+and may be said <i>to match</i>:
+
+ re = /red/
+ re.match?('redirect') # => true # Match at beginning of target.
+ re.match?('bored') # => true # Match at end of target.
+ re.match?('credit') # => true # Match within target.
+ re.match?('foo') # => false # No match.
+
+== \Regexp Uses
+
+A regexp may be used:
+
+- To extract substrings based on a given pattern:
+
+ re = /foo/ # => /foo/
+ re.match('food') # => #<MatchData "foo">
+ re.match('good') # => nil
+
+ See sections {Method match}[rdoc-ref:Regexp@Method+match]
+ and {Operator =~}[rdoc-ref:Regexp@Operator-].
+
+- To determine whether a string matches a given pattern:
+
+ re.match?('food') # => true
+ re.match?('good') # => false
+
+ See section {Method match?}[rdoc-ref:Regexp@Method+match].
+
+- As an argument for calls to certain methods in other classes and modules;
+ most such methods accept an argument that may be either a string
+ or the (much more powerful) regexp.
+
+ See {Regexp Methods}[rdoc-ref:language/regexp/methods.rdoc].
+
+== \Regexp Objects
+
+A regexp object has:
+
+- A source; see {Sources}[rdoc-ref:Regexp@Sources].
+
+- Several modes; see {Modes}[rdoc-ref:Regexp@Modes].
+
+- A timeout; see {Timeouts}[rdoc-ref:Regexp@Timeouts].
+
+- An encoding; see {Encodings}[rdoc-ref:Regexp@Encodings].
+
+== Creating a \Regexp
+
+A regular expression may be created with:
+
+- A regexp literal using slash characters
+ (see {Regexp Literals}[rdoc-ref:syntax/literals.rdoc@Regexp+Literals]):
+
+ # This is a very common usage.
+ /foo/ # => /foo/
+
+- A <tt>%r</tt> regexp literal
+ (see {%r: Regexp Literals}[rdoc-ref:syntax/literals.rdoc@r-regexp+literals]):
+
+ # Same delimiter character at beginning and end;
+ # useful for avoiding escaping characters
+ %r/name\/value pair/ # => /name\/value pair/
+ %r:name/value pair: # => /name\/value pair/
+ %r|name/value pair| # => /name\/value pair/
+
+ # Certain "paired" characters can be delimiters.
+ %r[foo] # => /foo/
+ %r{foo} # => /foo/
+ %r(foo) # => /foo/
+ %r<foo> # => /foo/
+
+- Method Regexp.new.
+
+== Method <tt>match</tt>
+
+Each of the methods Regexp#match, String#match, and Symbol#match
+returns a MatchData object if a match was found, +nil+ otherwise;
+each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ 'food'.match(/foo/) # => #<MatchData "foo">
+ 'food'.match(/bar/) # => nil
+
+== Operator <tt>=~</tt>
+
+Each of the operators Regexp#=~, String#=~, and Symbol#=~
+returns an integer offset if a match was found, +nil+ otherwise;
+each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ /bar/ =~ 'foo bar' # => 4
+ 'foo bar' =~ /bar/ # => 4
+ /baz/ =~ 'foo bar' # => nil
+
+== Method <tt>match?</tt>
+
+Each of the methods Regexp#match?, String#match?, and Symbol#match?
+returns +true+ if a match was found, +false+ otherwise;
+none sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ 'food'.match?(/foo/) # => true
+ 'food'.match?(/bar/) # => false
+
+== Global Variables
+
+Certain regexp-oriented methods assign values to global variables:
+
+- <tt>#match</tt>: see {Method match}[rdoc-ref:Regexp@Method+match].
+- <tt>#=~</tt>: see {Operator =~}[rdoc-ref:Regexp@Operator-].
+
+The affected global variables are:
+
+- <tt>$~</tt>: Returns a MatchData object, or +nil+.
+- <tt>$&</tt>: Returns the matched part of the string, or +nil+.
+- <tt>$`</tt>: Returns the part of the string to the left of the match, or +nil+.
+- <tt>$'</tt>: Returns the part of the string to the right of the match, or +nil+.
+- <tt>$+</tt>: Returns the last group matched, or +nil+.
+- <tt>$1</tt>, <tt>$2</tt>, etc.: Returns the first, second, etc.,
+ matched group, or +nil+.
+ Note that <tt>$0</tt> is quite different;
+ it returns the name of the currently executing program.
+
+These variables, except for <tt>$~</tt>, are shorthands for methods of
+<tt>$~</tt>. See MatchData@Global+variables+equivalence.
+
+Examples:
+
+ # Matched string, but no matched groups.
+ 'foo bar bar baz'.match('bar')
+ $~ # => #<MatchData "bar">
+ $& # => "bar"
+ $` # => "foo "
+ $' # => " bar baz"
+ $+ # => nil
+ $1 # => nil
+
+ # Matched groups.
+ /s(\w{2}).*(c)/.match('haystack')
+ $~ # => #<MatchData "stac" 1:"ta" 2:"c">
+ $& # => "stac"
+ $` # => "hay"
+ $' # => "k"
+ $+ # => "c"
+ $1 # => "ta"
+ $2 # => "c"
+ $3 # => nil
+
+ # No match.
+ 'foo'.match('bar')
+ $~ # => nil
+ $& # => nil
+ $` # => nil
+ $' # => nil
+ $+ # => nil
+ $1 # => nil
+
+Note that Regexp#match?, String#match?, and Symbol#match?
+do not set global variables.
+
+== Sources
+
+As seen above, the simplest regexp uses a literal expression as its source:
+
+ re = /foo/ # => /foo/
+ re.match('food') # => #<MatchData "foo">
+ re.match('good') # => nil
+
+A rich collection of available _subexpressions_
+gives the regexp great power and flexibility:
+
+- {Special characters}[rdoc-ref:Regexp@Special+Characters]
+- {Source literals}[rdoc-ref:Regexp@Source+Literals]
+- {Character classes}[rdoc-ref:Regexp@Character+Classes]
+- {Shorthand character classes}[rdoc-ref:Regexp@Shorthand+Character+Classes]
+- {Anchors}[rdoc-ref:Regexp@Anchors]
+- {Alternation}[rdoc-ref:Regexp@Alternation]
+- {Quantifiers}[rdoc-ref:Regexp@Quantifiers]
+- {Groups and captures}[rdoc-ref:Regexp@Groups+and+Captures]
+- {Unicode}[rdoc-ref:Regexp@Unicode]
+- {POSIX Bracket Expressions}[rdoc-ref:Regexp@POSIX+Bracket+Expressions]
+- {Comments}[rdoc-ref:Regexp@Comments]
+
+=== Special Characters
+
+\Regexp special characters, called _metacharacters_,
+have special meanings in certain contexts;
+depending on the context, these are sometimes metacharacters:
+
+ . ? - + * ^ \ | $ ( ) [ ] { }
+
+To match a metacharacter literally, backslash-escape it:
+
+ # Matches one or more 'o' characters.
+ /o+/.match('foo') # => #<MatchData "oo">
+ # Would match 'o+'.
+ /o\+/.match('foo') # => nil
+
+To match a backslash literally, backslash-escape it:
+
+ /\./.match('\.') # => #<MatchData ".">
+ /\\./.match('\.') # => #<MatchData "\\.">
+
+Method Regexp.escape returns an escaped string:
+
+ Regexp.escape('.?-+*^\|$()[]{}')
+ # => "\\.\\?\\-\\+\\*\\^\\\\\\|\\$\\(\\)\\[\\]\\{\\}"
+
+=== Source Literals
+
+The source literal largely behaves like a double-quoted string;
+see {Double-Quoted String Literals}[rdoc-ref:syntax/literals.rdoc@Double-Quoted+String+Literals].
+
+In particular, a source literal may contain interpolated expressions:
+
+ s = 'foo' # => "foo"
+ /#{s}/ # => /foo/
+ /#{s.capitalize}/ # => /Foo/
+ /#{2 + 2}/ # => /4/
+
+There are differences between an ordinary string literal and a source literal;
+see {Shorthand Character Classes}[rdoc-ref:Regexp@Shorthand+Character+Classes].
+
+- <tt>\s</tt> in an ordinary string literal is equivalent to a space character;
+ in a source literal, it's shorthand for matching a whitespace character.
+- In an ordinary string literal, these are (needlessly) escaped characters;
+ in a source literal, they are shorthands for various matching characters:
+
+ \w \W \d \D \h \H \S \R
+
+=== Character Classes
+
+A <i>character class</i> is delimited by square brackets;
+it specifies that certain characters match at a given point in the target string:
+
+ # This character class will match any vowel.
+ re = /B[aeiou]rd/
+ re.match('Bird') # => #<MatchData "Bird">
+ re.match('Bard') # => #<MatchData "Bard">
+ re.match('Byrd') # => nil
+
+A character class may contain hyphen characters to specify ranges of characters:
+
+ # These regexps have the same effect.
+ /[abcdef]/.match('foo') # => #<MatchData "f">
+ /[a-f]/.match('foo') # => #<MatchData "f">
+ /[a-cd-f]/.match('foo') # => #<MatchData "f">
+
+When the first character of a character class is a caret (<tt>^</tt>),
+the sense of the class is inverted: it matches any character _except_ those specified.
+
+ /[^a-eg-z]/.match('f') # => #<MatchData "f">
+
+A character class may contain another character class.
+By itself this isn't useful because <tt>[a-z[0-9]]</tt>
+describes the same set as <tt>[a-z0-9]</tt>.
+
+However, character classes also support the <tt>&&</tt> operator,
+which performs set intersection on its arguments.
+The two can be combined as follows:
+
+ /[a-w&&[^c-g]z]/ # ([a-w] AND ([^c-g] OR z))
+
+This is equivalent to:
+
+ /[abh-w]/
+
+=== Shorthand Character Classes
+
+Each of the following metacharacters serves as a shorthand
+for a character class:
+
+- <tt>/./</tt>: Matches any character except a newline:
+
+ /./.match('foo') # => #<MatchData "f">
+ /./.match("\n") # => nil
+
+- <tt>/./m</tt>: Matches any character, including a newline;
+ see {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode]:
+
+ /./m.match("\n") # => #<MatchData "\n">
+
+- <tt>/\w/</tt>: Matches a word character: equivalent to <tt>[a-zA-Z0-9_]</tt>:
+
+ /\w/.match(' foo') # => #<MatchData "f">
+ /\w/.match(' _') # => #<MatchData "_">
+ /\w/.match(' ') # => nil
+
+- <tt>/\W/</tt>: Matches a non-word character: equivalent to <tt>[^a-zA-Z0-9_]</tt>:
+
+ /\W/.match(' ') # => #<MatchData " ">
+ /\W/.match('_') # => nil
+
+- <tt>/\d/</tt>: Matches a digit character: equivalent to <tt>[0-9]</tt>:
+
+ /\d/.match('THX1138') # => #<MatchData "1">
+ /\d/.match('foo') # => nil
+
+- <tt>/\D/</tt>: Matches a non-digit character: equivalent to <tt>[^0-9]</tt>:
+
+ /\D/.match('123Jump!') # => #<MatchData "J">
+ /\D/.match('123') # => nil
+
+- <tt>/\h/</tt>: Matches a hexdigit character: equivalent to <tt>[0-9a-fA-F]</tt>:
+
+ /\h/.match('xyz fedcba9876543210') # => #<MatchData "f">
+ /\h/.match('xyz') # => nil
+
+- <tt>/\H/</tt>: Matches a non-hexdigit character: equivalent to <tt>[^0-9a-fA-F]</tt>:
+
+ /\H/.match('fedcba9876543210xyz') # => #<MatchData "x">
+ /\H/.match('fedcba9876543210') # => nil
+
+- <tt>/\s/</tt>: Matches a whitespace character: equivalent to <tt>/[ \t\r\n\f\v]/</tt>:
+
+ /\s/.match('foo bar') # => #<MatchData " ">
+ /\s/.match('foo') # => nil
+
+- <tt>/\S/</tt>: Matches a non-whitespace character: equivalent to <tt>/[^ \t\r\n\f\v]/</tt>:
+
+ /\S/.match(" \t\r\n\f\v foo") # => #<MatchData "f">
+ /\S/.match(" \t\r\n\f\v") # => nil
+
+- <tt>/\R/</tt>: Matches a linebreak, platform-independently:
+
+ /\R/.match("\r") # => #<MatchData "\r"> # Carriage return (CR)
+ /\R/.match("\n") # => #<MatchData "\n"> # Newline (LF)
+ /\R/.match("\f") # => #<MatchData "\f"> # Formfeed (FF)
+ /\R/.match("\v") # => #<MatchData "\v"> # Vertical tab (VT)
+ /\R/.match("\r\n") # => #<MatchData "\r\n"> # CRLF
+ /\R/.match("\u0085") # => #<MatchData "\u0085"> # Next line (NEL)
+ /\R/.match("\u2028") # => #<MatchData "\u2028"> # Line separator (LSEP)
+ /\R/.match("\u2029") # => #<MatchData "\u2029"> # Paragraph separator (PSEP)
+
+=== Anchors
+
+An anchor is a metasequence that matches a zero-width position between
+characters in the target string.
+
+For a subexpression with no anchor,
+matching may begin anywhere in the target string:
+
+ /real/.match('surrealist') # => #<MatchData "real">
+
+For a subexpression with an anchor,
+matching must begin at the matched anchor.
+
+==== Boundary Anchors
+
+Each of these anchors matches a boundary:
+
+- <tt>^</tt>: Matches the beginning of a line:
+
+ /^bar/.match("foo\nbar") # => #<MatchData "bar">
+ /^ar/.match("foo\nbar") # => nil
+
+- <tt>$</tt>: Matches the end of a line:
+
+ /bar$/.match("foo\nbar") # => #<MatchData "bar">
+ /ba$/.match("foo\nbar") # => nil
+
+- <tt>\A</tt>: Matches the beginning of the string:
+
+ /\Afoo/.match('foo bar') # => #<MatchData "foo">
+ /\Afoo/.match(' foo bar') # => nil
+
+- <tt>\Z</tt>: Matches the end of the string;
+ if string ends with a single newline,
+ it matches just before the ending newline:
+
+ /foo\Z/.match('bar foo') # => #<MatchData "foo">
+ /foo\Z/.match('foo bar') # => nil
+ /foo\Z/.match("bar foo\n") # => #<MatchData "foo">
+ /foo\Z/.match("bar foo\n\n") # => nil
+
+- <tt>\z</tt>: Matches the end of the string:
+
+ /foo\z/.match('bar foo') # => #<MatchData "foo">
+ /foo\z/.match('foo bar') # => nil
+ /foo\z/.match("bar foo\n") # => nil
+
+- <tt>\b</tt>: Matches word boundary when not inside brackets;
+ matches backspace (<tt>"0x08"</tt>) when inside brackets:
+
+ /foo\b/.match('foo bar') # => #<MatchData "foo">
+ /foo\b/.match('foobar') # => nil
+
+- <tt>\B</tt>: Matches non-word boundary:
+
+ /foo\B/.match('foobar') # => #<MatchData "foo">
+ /foo\B/.match('foo bar') # => nil
+
+- <tt>\G</tt>: Matches first matching position:
+
+ In methods like String#gsub and String#scan, it changes on each iteration.
+ It initially matches the beginning of subject, and in each following iteration it matches where the last match finished.
+
+ " a b c".gsub(/ /, '_') # => "____a_b_c"
+ " a b c".gsub(/\G /, '_') # => "____a b c"
+
+ In methods like Regexp#match and String#match
+ that take an optional offset, it matches where the search begins.
+
+ "hello, world".match(/,/, 3) # => #<MatchData ",">
+ "hello, world".match(/\G,/, 3) # => nil
+
+==== Lookaround Anchors
+
+Lookahead anchors:
+
+- <tt>(?=pat)</tt>: Positive lookahead assertion:
+ ensures that the following characters match _pat_,
+ but doesn't include those characters in the matched substring.
+
+- <tt>(?!pat)</tt>: Negative lookahead assertion:
+ ensures that the following characters <i>do not</i> match _pat_,
+ but doesn't include those characters in the matched substring.
+
+Lookbehind anchors:
+
+- <tt>(?<=pat)</tt>: Positive lookbehind assertion:
+ ensures that the preceding characters match _pat_, but
+ doesn't include those characters in the matched substring.
+
+- <tt>(?<!pat)</tt>: Negative lookbehind assertion:
+ ensures that the preceding characters do not match
+ _pat_, but doesn't include those characters in the matched substring.
+
+The pattern below uses positive lookahead and positive lookbehind to match
+text appearing in <tt><b></tt>...<tt></b></tt> tags
+without including the tags in the match:
+
+ /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favors the <b>bold</b>.")
+ # => #<MatchData "bold">
+
+The pattern in lookbehind must be fixed-width.
+But top-level alternatives can be of various lengths.
+ex. (?<=a|bc) is OK. (?<=aaa(?:b|cd)) is not allowed.
+
+==== Match-Reset Anchor
+
+- <tt>\K</tt>: Match reset:
+ the matched content preceding <tt>\K</tt> in the regexp is excluded from the result.
+ For example, the following two regexps are almost equivalent:
+
+ /ab\Kc/.match('abc') # => #<MatchData "c">
+ /(?<=ab)c/.match('abc') # => #<MatchData "c">
+
+ These match same string and <tt>$&</tt> equals <tt>'c'</tt>,
+ while the matched position is different.
+
+ As are the following two regexps:
+
+ /(a)\K(b)\Kc/
+ /(?<=(?<=(a))(b))c/
+
+=== Alternation
+
+The vertical bar metacharacter (<tt>|</tt>) may be used within parentheses
+to express alternation:
+two or more subexpressions any of which may match the target string.
+
+Two alternatives:
+
+ re = /(a|b)/
+ re.match('foo') # => nil
+ re.match('bar') # => #<MatchData "b" 1:"b">
+
+Four alternatives:
+
+ re = /(a|b|c|d)/
+ re.match('shazam') # => #<MatchData "a" 1:"a">
+ re.match('cold') # => #<MatchData "c" 1:"c">
+
+Each alternative is a subexpression, and may be composed of other subexpressions:
+
+ re = /([a-c]|[x-z])/
+ re.match('bar') # => #<MatchData "b" 1:"b">
+ re.match('ooz') # => #<MatchData "z" 1:"z">
+
+Method Regexp.union provides a convenient way to construct
+a regexp with alternatives.
+
+=== Quantifiers
+
+A simple regexp matches one character:
+
+ /\w/.match('Hello') # => #<MatchData "H">
+
+An added _quantifier_ specifies how many matches are required or allowed:
+
+- <tt>*</tt> - Matches zero or more times:
+
+ /\w*/.match('')
+ # => #<MatchData "">
+ /\w*/.match('x')
+ # => #<MatchData "x">
+ /\w*/.match('xyz')
+ # => #<MatchData "xyz">
+
+- <tt>+</tt> - Matches one or more times:
+
+ /\w+/.match('') # => nil
+ /\w+/.match('x') # => #<MatchData "x">
+ /\w+/.match('xyz') # => #<MatchData "xyz">
+
+- <tt>?</tt> - Matches zero or one times:
+
+ /\w?/.match('') # => #<MatchData "">
+ /\w?/.match('x') # => #<MatchData "x">
+ /\w?/.match('xyz') # => #<MatchData "x">
+
+- <tt>{</tt>_n_<tt>}</tt> - Matches exactly _n_ times:
+
+ /\w{2}/.match('') # => nil
+ /\w{2}/.match('x') # => nil
+ /\w{2}/.match('xyz') # => #<MatchData "xy">
+
+- <tt>{</tt>_min_<tt>,}</tt> - Matches _min_ or more times:
+
+ /\w{2,}/.match('') # => nil
+ /\w{2,}/.match('x') # => nil
+ /\w{2,}/.match('xy') # => #<MatchData "xy">
+ /\w{2,}/.match('xyz') # => #<MatchData "xyz">
+
+- <tt>{,</tt>_max_<tt>}</tt> - Matches _max_ or fewer times:
+
+ /\w{,2}/.match('') # => #<MatchData "">
+ /\w{,2}/.match('x') # => #<MatchData "x">
+ /\w{,2}/.match('xyz') # => #<MatchData "xy">
+
+- <tt>{</tt>_min_<tt>,</tt>_max_<tt>}</tt> -
+ Matches at least _min_ times and at most _max_ times:
+
+ /\w{1,2}/.match('') # => nil
+ /\w{1,2}/.match('x') # => #<MatchData "x">
+ /\w{1,2}/.match('xyz') # => #<MatchData "xy">
+
+==== Greedy, Lazy, or Possessive Matching
+
+Quantifier matching may be greedy, lazy, or possessive:
+
+- In _greedy_ matching, as many occurrences as possible are matched
+ while still allowing the overall match to succeed.
+ Greedy quantifiers: <tt>*</tt>, <tt>+</tt>, <tt>?</tt>,
+ <tt>{min, max}</tt> and its variants.
+- In _lazy_ matching, the minimum number of occurrences are matched.
+ Lazy quantifiers: <tt>*?</tt>, <tt>+?</tt>, <tt>??</tt>,
+ <tt>{min, max}?</tt> and its variants.
+- In _possessive_ matching, once a match is found, there is no backtracking;
+ that match is retained, even if it jeopardises the overall match.
+ Possessive quantifiers: <tt>*+</tt>, <tt>++</tt>, <tt>?+</tt>.
+ Note that <tt>{min, max}</tt> and its variants do _not_ support possessive matching.
+
+More:
+
+- About greedy and lazy matching, see
+ {Choosing Minimal or Maximal Repetition}[https://www.oreilly.com/library/view/regular-expressions-cookbook/9780596802837/ch02s13.html].
+- About possessive matching, see
+ {Eliminate Needless Backtracking}[https://www.oreilly.com/library/view/regular-expressions-cookbook/9780596802837/ch02s14.html].
+
+=== Groups and Captures
+
+A simple regexp has (at most) one match:
+
+ re = /\d\d\d\d-\d\d-\d\d/
+ re.match('1943-02-04') # => #<MatchData "1943-02-04">
+ re.match('1943-02-04').size # => 1
+ re.match('foo') # => nil
+
+Adding one or more pairs of parentheses, <tt>(subexpression)</tt>,
+defines _groups_, which may result in multiple matched substrings,
+called _captures_:
+
+ re = /(\d\d\d\d)-(\d\d)-(\d\d)/
+ re.match('1943-02-04') # => #<MatchData "1943-02-04" 1:"1943" 2:"02" 3:"04">
+ re.match('1943-02-04').size # => 4
+
+The first capture is the entire matched string;
+the other captures are the matched substrings from the groups.
+
+A group may have a {quantifier}[rdoc-ref:Regexp@Quantifiers]:
+
+ re = /July 4(th)?/
+ re.match('July 4') # => #<MatchData "July 4" 1:nil>
+ re.match('July 4th') # => #<MatchData "July 4th" 1:"th">
+
+ re = /(foo)*/
+ re.match('') # => #<MatchData "" 1:nil>
+ re.match('foo') # => #<MatchData "foo" 1:"foo">
+ re.match('foofoo') # => #<MatchData "foofoo" 1:"foo">
+
+ re = /(foo)+/
+ re.match('') # => nil
+ re.match('foo') # => #<MatchData "foo" 1:"foo">
+ re.match('foofoo') # => #<MatchData "foofoo" 1:"foo">
+
+The returned \MatchData object gives access to the matched substrings:
+
+ re = /(\d\d\d\d)-(\d\d)-(\d\d)/
+ md = re.match('1943-02-04')
+ # => #<MatchData "1943-02-04" 1:"1943" 2:"02" 3:"04">
+ md[0] # => "1943-02-04"
+ md[1] # => "1943"
+ md[2] # => "02"
+ md[3] # => "04"
+
+==== Non-Capturing Groups
+
+A group may be made non-capturing;
+it is still a group (and, for example, can have a quantifier),
+but its matching substring is not included among the captures.
+
+A non-capturing group begins with <tt>?:</tt> (inside the parentheses):
+
+ # Don't capture the year.
+ re = /(?:\d\d\d\d)-(\d\d)-(\d\d)/
+ md = re.match('1943-02-04') # => #<MatchData "1943-02-04" 1:"02" 2:"04">
+
+==== Backreferences
+
+A group match may also be referenced within the regexp itself;
+such a reference is called a +backreference+:
+
+ /[csh](..) [csh]\1 in/.match('The cat sat in the hat')
+ # => #<MatchData "cat sat in" 1:"at">
+
+This table shows how each subexpression in the regexp above
+matches a substring in the target string:
+
+ | Subexpression in Regexp | Matching Substring in Target String |
+ |---------------------------|-------------------------------------|
+ | First '[csh]' | Character 'c' |
+ | '(..)' | First substring 'at' |
+ | First space ' ' | First space character ' ' |
+ | Second '[csh]' | Character 's' |
+ | '\1' (backreference 'at') | Second substring 'at' |
+ | ' in' | Substring ' in' |
+
+A regexp may contain any number of groups:
+
+- For a large number of groups:
+
+ - The ordinary <tt>\\n</tt> notation applies only for _n_ in range (1..9).
+ - The <tt>MatchData[n]</tt> notation applies for any non-negative _n_.
+
+- <tt>\0</tt> is a special backreference, referring to the entire matched string;
+ it may not be used within the regexp itself,
+ but may be used outside it (for example, in a substitution method call):
+
+ 'The cat sat in the hat'.gsub(/[csh]at/, '\0s')
+ # => "The cats sats in the hats"
+
+==== Named Captures
+
+As seen above, a capture can be referred to by its number.
+A capture can also have a name,
+prefixed as <tt>?<name></tt> or <tt>?'name'</tt>,
+and the name (symbolized) may be used as an index in <tt>MatchData[]</tt>:
+
+ md = /\$(?<dollars>\d+)\.(?'cents'\d+)/.match("$3.67")
+ # => #<MatchData "$3.67" dollars:"3" cents:"67">
+ md[:dollars] # => "3"
+ md[:cents] # => "67"
+ # The capture numbers are still valid.
+ md[2] # => "67"
+
+When a regexp contains a named capture, there are no unnamed captures:
+
+ /\$(?<dollars>\d+)\.(\d+)/.match("$3.67")
+ # => #<MatchData "$3.67" dollars:"3">
+
+A named group may be backreferenced as <tt>\k<name></tt>:
+
+ /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
+ # => #<MatchData "ototo" vowel:"o">
+
+When (and only when) a regexp contains named capture groups
+and appears before the <tt>=~</tt> operator,
+the captured substrings are assigned to local variables with corresponding names:
+
+ /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ '$3.67'
+ dollars # => "3"
+ cents # => "67"
+
+Method Regexp#named_captures returns a hash of the capture names and substrings;
+method Regexp#names returns an array of the capture names.
+
+==== Atomic Grouping
+
+A group may be made _atomic_ with <tt>(?></tt>_subexpression_<tt>)</tt>.
+
+This causes the subexpression to be matched
+independently of the rest of the expression,
+so that the matched substring becomes fixed for the remainder of the match,
+unless the entire subexpression must be abandoned and subsequently revisited.
+
+In this way _subexpression_ is treated as a non-divisible whole.
+Atomic grouping is typically used to optimise patterns
+to prevent needless backtracking .
+
+Example (without atomic grouping):
+
+ /".*"/.match('"Quote"') # => #<MatchData "\"Quote\"">
+
+Analysis:
+
+1. The leading subexpression <tt>"</tt> in the pattern matches the first character
+ <tt>"</tt> in the target string.
+2. The next subexpression <tt>.*</tt> matches the next substring <tt>Quote"</tt>
+ (including the trailing double-quote).
+3. Now there is nothing left in the target string to match
+ the trailing subexpression <tt>"</tt> in the pattern;
+ this would cause the overall match to fail.
+4. The matched substring is backtracked by one position: <tt>Quote</tt>.
+5. The final subexpression <tt>"</tt> now matches the final substring <tt>"</tt>,
+ and the overall match succeeds.
+
+If subexpression <tt>.*</tt> is grouped atomically,
+the backtracking is disabled, and the overall match fails:
+
+ /"(?>.*)"/.match('"Quote"') # => nil
+
+Atomic grouping can affect performance;
+see {Atomic Group}[https://www.regular-expressions.info/atomic.html].
+
+==== Subexpression Calls
+
+As seen above, a backreference number (<tt>\\n</tt>) or name (<tt>\k<name></tt>)
+gives access to a captured _substring_;
+the corresponding regexp _subexpression_ may also be accessed,
+via the number n (<tt>\\gn</tt>) or name (<tt>\g<name></tt>):
+
+ /\A(?<paren>\(\g<paren>*\))*\z/.match('(())')
+ # ^1
+ # ^2
+ # ^3
+ # ^4
+ # ^5
+ # ^6
+ # ^7
+ # ^8
+ # ^9
+ # ^10
+
+The pattern:
+
+1. Matches at the beginning of the string, i.e. before the first character.
+2. Enters a named group +paren+.
+3. Matches the first character in the string, <tt>'('</tt>.
+4. Calls the +paren+ group again, i.e. recurses back to the second step.
+5. Re-enters the +paren+ group.
+6. Matches the second character in the string, <tt>'('</tt>.
+7. Attempts to call +paren+ a third time,
+ but fails because doing so would prevent an overall successful match.
+8. Matches the third character in the string, <tt>')'</tt>;
+ marks the end of the second recursive call
+9. Matches the fourth character in the string, <tt>')'</tt>.
+10. Matches the end of the string.
+
+See {Subexpression calls}[https://learnbyexample.github.io/Ruby_Regexp/groupings-and-backreferences.html#subexpression-calls].
+
+==== Conditionals
+
+The conditional construct takes the form <tt>(?(cond)yes|no)</tt>, where:
+
+- _cond_ may be a capture number or name.
+- The match to be applied is _yes_ if _cond_ is captured;
+ otherwise the match to be applied is _no_.
+- If not needed, <tt>|no</tt> may be omitted.
+
+Examples:
+
+ re = /\A(foo)?(?(1)(T)|(F))\z/
+ re.match('fooT') # => #<MatchData "fooT" 1:"foo" 2:"T" 3:nil>
+ re.match('F') # => #<MatchData "F" 1:nil 2:nil 3:"F">
+ re.match('fooF') # => nil
+ re.match('T') # => nil
+
+ re = /\A(?<xyzzy>foo)?(?(<xyzzy>)(T)|(F))\z/
+ re.match('fooT') # => #<MatchData "fooT" xyzzy:"foo">
+ re.match('F') # => #<MatchData "F" xyzzy:nil>
+ re.match('fooF') # => nil
+ re.match('T') # => nil
+
+
+==== Absence Operator
+
+The absence operator is a special group that matches anything which does _not_ match the contained subexpressions.
+
+ /(?~real)/.match('surrealist') # => #<MatchData "surrea">
+ /(?~real)ist/.match('surrealist') # => #<MatchData "ealist">
+ /sur(?~real)ist/.match('surrealist') # => nil
+
+=== Unicode
+
+==== Unicode Properties
+
+The <tt>/\p{property_name}/</tt> construct (with lowercase +p+)
+matches characters using a Unicode property name,
+much like a character class;
+property +Alpha+ specifies alphabetic characters:
+
+ /\p{Alpha}/.match('a') # => #<MatchData "a">
+ /\p{Alpha}/.match('1') # => nil
+
+A property can be inverted
+by prefixing the name with a caret character (<tt>^</tt>):
+
+ /\p{^Alpha}/.match('1') # => #<MatchData "1">
+ /\p{^Alpha}/.match('a') # => nil
+
+Or by using <tt>\P</tt> (uppercase +P+):
+
+ /\P{Alpha}/.match('1') # => #<MatchData "1">
+ /\P{Alpha}/.match('a') # => nil
+
+See {Unicode Properties}[rdoc-ref:language/regexp/unicode_properties.rdoc]
+for regexps based on the numerous properties.
+
+Some commonly-used properties correspond to POSIX bracket expressions:
+
+- <tt>/\p{Alnum}/</tt>: Alphabetic and numeric character
+- <tt>/\p{Alpha}/</tt>: Alphabetic character
+- <tt>/\p{Blank}/</tt>: Space or tab
+- <tt>/\p{Cntrl}/</tt>: Control character
+- <tt>/\p{Digit}/</tt>: Digit
+ characters, and similar)
+- <tt>/\p{Lower}/</tt>: Lowercase alphabetical character
+- <tt>/\p{Print}/</tt>: Like <tt>\p{Graph}</tt>, but includes the space character
+- <tt>/\p{Punct}/</tt>: Punctuation character
+- <tt>/\p{Space}/</tt>: Whitespace character (<tt>[:blank:]</tt>, newline,
+ carriage return, etc.)
+- <tt>/\p{Upper}/</tt>: Uppercase alphabetical
+- <tt>/\p{XDigit}/</tt>: Digit allowed in a hexadecimal number (i.e., 0-9a-fA-F)
+
+These are also commonly used:
+
+- <tt>/\p{Emoji}/</tt>: Unicode emoji.
+- <tt>/\p{Graph}/</tt>: Characters excluding <tt>/\p{Cntrl}/</tt> and <tt>/\p{Space}/</tt>.
+ Note that invisible characters under the Unicode
+ {"Format"}[https://www.compart.com/en/unicode/category/Cf] category are included.
+- <tt>/\p{Word}/</tt>: A member in one of these Unicode character
+ categories (see below) or having one of these Unicode properties:
+
+ - Unicode categories:
+ - +Mark+ (+M+).
+ - <tt>Decimal Number</tt> (+Nd+)
+ - <tt>Connector Punctuation</tt> (+Pc+).
+
+ - Unicode properties:
+ - +Alpha+
+ - <tt>Join_Control</tt>
+
+- <tt>/\p{ASCII}/</tt>: A character in the ASCII character set.
+- <tt>/\p{Any}/</tt>: Any Unicode character (including unassigned characters).
+- <tt>/\p{Assigned}/</tt>: An assigned character.
+
+==== Unicode Character Categories
+
+A Unicode character category name:
+
+- May be either its full name or its abbreviated name.
+- Is case-insensitive.
+- Treats a space, a hyphen, and an underscore as equivalent.
+
+Examples:
+
+ /\p{lu}/ # => /\p{lu}/
+ /\p{LU}/ # => /\p{LU}/
+ /\p{Uppercase Letter}/ # => /\p{Uppercase Letter}/
+ /\p{Uppercase_Letter}/ # => /\p{Uppercase_Letter}/
+ /\p{UPPERCASE-LETTER}/ # => /\p{UPPERCASE-LETTER}/
+
+Below are the Unicode character category abbreviations and names.
+Enumerations of characters in each category are at the links.
+
+Letters:
+
+- +L+, +Letter+: +LC+, +Lm+, or +Lo+.
+- +LC+, +Cased_Letter+: +Ll+, +Lt+, or +Lu+.
+- {Lu, Lowercase_Letter}[https://www.compart.com/en/unicode/category/Ll].
+- {Lu, Modifier_Letter}[https://www.compart.com/en/unicode/category/Lm].
+- {Lu, Other_Letter}[https://www.compart.com/en/unicode/category/Lo].
+- {Lu, Titlecase_Letter}[https://www.compart.com/en/unicode/category/Lt].
+- {Lu, Uppercase_Letter}[https://www.compart.com/en/unicode/category/Lu].
+
+Marks:
+
+- +M+, +Mark+: +Mc+, +Me+, or +Mn+.
+- {Mc, Spacing_Mark}[https://www.compart.com/en/unicode/category/Mc].
+- {Me, Enclosing_Mark}[https://www.compart.com/en/unicode/category/Me].
+- {Mn, Nonapacing_Mark}[https://www.compart.com/en/unicode/category/Mn].
+
+Numbers:
+
+- +N+, +Number+: +Nd+, +Nl+, or +No+.
+- {Nd, Decimal_Number}[https://www.compart.com/en/unicode/category/Nd].
+- {Nl, Letter_Number}[https://www.compart.com/en/unicode/category/Nl].
+- {No, Other_Number}[https://www.compart.com/en/unicode/category/No].
+
+Punctuation:
+
+- +P+, +Punctuation+: +Pc+, +Pd+, +Pe+, +Pf+, +Pi+, +Po+, or +Ps+.
+- {Pc, Connector_Punctuation}[https://www.compart.com/en/unicode/category/Pc].
+- {Pd, Dash_Punctuation}[https://www.compart.com/en/unicode/category/Pd].
+- {Pe, Close_Punctuation}[https://www.compart.com/en/unicode/category/Pe].
+- {Pf, Final_Punctuation}[https://www.compart.com/en/unicode/category/Pf].
+- {Pi, Initial_Punctuation}[https://www.compart.com/en/unicode/category/Pi].
+- {Po, Other_Punctuation}[https://www.compart.com/en/unicode/category/Po].
+- {Ps, Open_Punctuation}[https://www.compart.com/en/unicode/category/Ps].
+
+- +S+, +Symbol+: +Sc+, +Sk+, +Sm+, or +So+.
+- {Sc, Currency_Symbol}[https://www.compart.com/en/unicode/category/Sc].
+- {Sk, Modifier_Symbol}[https://www.compart.com/en/unicode/category/Sk].
+- {Sm, Math_Symbol}[https://www.compart.com/en/unicode/category/Sm].
+- {So, Other_Symbol}[https://www.compart.com/en/unicode/category/So].
+
+- +Z+, +Separator+: +Zl+, +Zp+, or +Zs+.
+- {Zl, Line_Separator}[https://www.compart.com/en/unicode/category/Zl].
+- {Zp, Paragraph_Separator}[https://www.compart.com/en/unicode/category/Zp].
+- {Zs, Space_Separator}[https://www.compart.com/en/unicode/category/Zs].
+
+- +C+, +Other+: +Cc+, +Cf+, +Cn+, +Co+, or +Cs+.
+- {Cc, Control}[https://www.compart.com/en/unicode/category/Cc].
+- {Cf, Format}[https://www.compart.com/en/unicode/category/Cf].
+- {Cn, Unassigned}[http://zuga.net/articles/unicode/category/unassigned/].
+- {Co, Private_Use}[https://www.compart.com/en/unicode/category/Co].
+- {Cs, Surrogate}[https://www.compart.com/en/unicode/category/Cs].
+
+==== Unicode Scripts and Blocks
+
+Among the Unicode properties are:
+
+- {Unicode scripts}[https://en.wikipedia.org/wiki/Script_(Unicode)];
+ see {supported scripts}[https://www.unicode.org/standard/supported.html].
+- {Unicode blocks}[https://en.wikipedia.org/wiki/Unicode_block];
+ see {supported blocks}[http://www.unicode.org/Public/UNIDATA/Blocks.txt].
+
+=== POSIX Bracket Expressions
+
+A POSIX <i>bracket expression</i> is also similar to a character class.
+These expressions provide a portable alternative to the above,
+with the added benefit of encompassing non-ASCII characters:
+
+- <tt>/\d/</tt> matches only ASCII decimal digits +0+ through +9+.
+- <tt>/[[:digit:]]/</tt> matches any character in the Unicode
+ <tt>Decimal Number</tt> (+Nd+) category;
+ see below.
+
+The POSIX bracket expressions:
+
+- <tt>/[[:digit:]]/</tt>: Matches a {Unicode digit}[https://www.compart.com/en/unicode/category/Nd]:
+
+ /[[:digit:]]/.match('9') # => #<MatchData "9">
+ /[[:digit:]]/.match("\u1fbf9") # => #<MatchData "9">
+
+- <tt>/[[:xdigit:]]/</tt>: Matches a digit allowed in a hexadecimal number;
+ equivalent to <tt>[0-9a-fA-F]</tt>.
+
+- <tt>/[[:upper:]]/</tt>: Matches a {Unicode uppercase letter}[https://www.compart.com/en/unicode/category/Lu]:
+
+ /[[:upper:]]/.match('A') # => #<MatchData "A">
+ /[[:upper:]]/.match("\u00c6") # => #<MatchData "Æ">
+
+- <tt>/[[:lower:]]/</tt>: Matches a {Unicode lowercase letter}[https://www.compart.com/en/unicode/category/Ll]:
+
+ /[[:lower:]]/.match('a') # => #<MatchData "a">
+ /[[:lower:]]/.match("\u01fd") # => #<MatchData "ǽ">
+
+- <tt>/[[:alpha:]]/</tt>: Matches <tt>/[[:upper:]]/</tt> or <tt>/[[:lower:]]/</tt>.
+
+- <tt>/[[:alnum:]]/</tt>: Matches <tt>/[[:alpha:]]/</tt> or <tt>/[[:digit:]]/</tt>.
+
+- <tt>/[[:space:]]/</tt>: Matches {Unicode space character}[https://www.compart.com/en/unicode/category/Zs]:
+
+ /[[:space:]]/.match(' ') # => #<MatchData " ">
+ /[[:space:]]/.match("\u2005") # => #<MatchData " ">
+
+- <tt>/[[:blank:]]/</tt>: Matches <tt>/[[:space:]]/</tt> or tab character:
+
+ /[[:blank:]]/.match(' ') # => #<MatchData " ">
+ /[[:blank:]]/.match("\u2005") # => #<MatchData " ">
+ /[[:blank:]]/.match("\t") # => #<MatchData "\t">
+
+- <tt>/[[:cntrl:]]/</tt>: Matches {Unicode control character}[https://www.compart.com/en/unicode/category/Cc]:
+
+ /[[:cntrl:]]/.match("\u0000") # => #<MatchData "\u0000">
+ /[[:cntrl:]]/.match("\u009f") # => #<MatchData "\u009F">
+
+- <tt>/[[:graph:]]/</tt>: Matches any character
+ except <tt>/[[:space:]]/</tt> or <tt>/[[:cntrl:]]/</tt>.
+
+- <tt>/[[:print:]]/</tt>: Matches <tt>/[[:graph:]]/</tt> or space character.
+
+- <tt>/[[:punct:]]/</tt>: Matches any (Unicode punctuation character}[https://www.compart.com/en/unicode/category/Po]:
+
+Ruby also supports these (non-POSIX) bracket expressions:
+
+- <tt>/[[:ascii:]]/</tt>: Matches a character in the ASCII character set.
+- <tt>/[[:word:]]/</tt>: Matches a character in one of these Unicode character
+ categories or having one of these Unicode properties:
+
+ - Unicode categories:
+ - +Mark+ (+M+).
+ - <tt>Decimal Number</tt> (+Nd+)
+ - <tt>Connector Punctuation</tt> (+Pc+).
+
+ - Unicode properties:
+ - +Alpha+
+ - <tt>Join_Control</tt>
+
+=== Comments
+
+A comment may be included in a regexp pattern
+using the <tt>(?#</tt>_comment_<tt>)</tt> construct,
+where _comment_ is a substring that is to be ignored.
+arbitrary text ignored by the regexp engine:
+
+ /foo(?#Ignore me)bar/.match('foobar') # => #<MatchData "foobar">
+
+The comment may not include an unescaped terminator character.
+
+See also {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
+
+== Modes
+
+Each of these modifiers sets a mode for the regexp:
+
+- +i+: <tt>/pattern/i</tt> sets
+ {Case-Insensitive Mode}[rdoc-ref:Regexp@Case-Insensitive+Mode].
+- +m+: <tt>/pattern/m</tt> sets
+ {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode].
+- +x+: <tt>/pattern/x</tt> sets
+ {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
+- +o+: <tt>/pattern/o</tt> sets
+ {Interpolation Mode}[rdoc-ref:Regexp@Interpolation+Mode].
+
+Any, all, or none of these may be applied.
+
+Modifiers +i+, +m+, and +x+ may be applied to subexpressions:
+
+- <tt>(?modifier)</tt> turns the mode "on" for ensuing subexpressions
+- <tt>(?-modifier)</tt> turns the mode "off" for ensuing subexpressions
+- <tt>(?modifier:subexp)</tt> turns the mode "on" for _subexp_ within the group
+- <tt>(?-modifier:subexp)</tt> turns the mode "off" for _subexp_ within the group
+
+Example:
+
+ re = /(?i)te(?-i)st/
+ re.match('test') # => #<MatchData "test">
+ re.match('TEst') # => #<MatchData "TEst">
+ re.match('TEST') # => nil
+ re.match('teST') # => nil
+
+ re = /t(?i:e)st/
+ re.match('test') # => #<MatchData "test">
+ re.match('tEst') # => #<MatchData "tEst">
+ re.match('tEST') # => nil
+
+Method Regexp#options returns an integer whose value showing
+the settings for case-insensitivity mode, multiline mode, and extended mode.
+
+=== Case-Insensitive Mode
+
+By default, a regexp is case-sensitive:
+
+ /foo/.match('FOO') # => nil
+
+Modifier +i+ enables case-insensitive mode:
+
+ /foo/i.match('FOO')
+ # => #<MatchData "FOO">
+
+Method Regexp#casefold? returns whether the mode is case-insensitive.
+
+=== Multiline Mode
+
+The multiline-mode in Ruby is what is commonly called a "dot-all mode":
+
+- Without the +m+ modifier, the subexpression <tt>.</tt> does not match newlines:
+
+ /a.c/.match("a\nc") # => nil
+
+- With the modifier, it does match:
+
+ /a.c/m.match("a\nc") # => #<MatchData "a\nc">
+
+Unlike other languages, the modifier +m+ does not affect the anchors <tt>^</tt> and <tt>$</tt>.
+These anchors always match at line-boundaries in Ruby.
+
+=== Extended Mode
+
+Modifier +x+ enables extended mode, which means that:
+
+- Literal white space in the pattern is to be ignored.
+- Character <tt>#</tt> marks the remainder of its containing line as a comment,
+ which is also to be ignored for matching purposes.
+
+In extended mode, whitespace and comments may be used
+to form a self-documented regexp.
+
+Regexp not in extended mode (matches some Roman numerals):
+
+ pattern = '^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$'
+ re = /#{pattern}/
+ re.match('MCMXLIII') # => #<MatchData "MCMXLIII" 1:"CM" 2:"XL" 3:"III">
+
+Regexp in extended mode:
+
+ pattern = <<-EOT
+ ^ # beginning of string
+ M{0,3} # thousands - 0 to 3 Ms
+ (CM|CD|D?C{0,3}) # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 Cs),
+ # or 500-800 (D, followed by 0 to 3 Cs)
+ (XC|XL|L?X{0,3}) # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 Xs),
+ # or 50-80 (L, followed by 0 to 3 Xs)
+ (IX|IV|V?I{0,3}) # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 Is),
+ # or 5-8 (V, followed by 0 to 3 Is)
+ $ # end of string
+ EOT
+ re = /#{pattern}/x
+ re.match('MCMXLIII') # => #<MatchData "MCMXLIII" 1:"CM" 2:"XL" 3:"III">
+
+Comments in regexp literals cannot include unescaped terminator
+characters:
+
+ /
+ foo # the following slash \/ must be escaped
+ /x
+
+=== Interpolation Mode
+
+Modifier +o+ means that the first time a literal regexp with interpolations
+is encountered,
+the generated Regexp object is saved and used for all future evaluations
+of that literal regexp.
+Without modifier +o+, the generated Regexp is not saved,
+so each evaluation of the literal regexp generates a new Regexp object.
+
+Without modifier +o+:
+
+ def letters; sleep 5; /[A-Z][a-z]/; end
+ words = %w[abc def xyz]
+ start = Time.now
+ words.each {|word| word.match(/\A[#{letters}]+\z/) }
+ Time.now - start # => 15.0174892
+
+With modifier +o+:
+
+ start = Time.now
+ words.each {|word| word.match(/\A[#{letters}]+\z/o) }
+ Time.now - start # => 5.0010866
+
+Note that if the literal regexp does not have interpolations,
+the +o+ behavior is the default.
+
+== Encodings
+
+By default, a regexp with only US-ASCII characters has US-ASCII encoding:
+
+ re = /foo/
+ re.source.encoding # => #<Encoding:US-ASCII>
+ re.encoding # => #<Encoding:US-ASCII>
+
+A regular expression containing non-US-ASCII characters
+is assumed to use the source encoding.
+This can be overridden with one of the following modifiers.
+
+- <tt>/pat/n</tt>: US-ASCII if only containing US-ASCII characters,
+ otherwise ASCII-8BIT:
+
+ /foo/n.encoding # => #<Encoding:US-ASCII>
+ /foo\xff/n.encoding # => #<Encoding:ASCII-8BIT>
+ /foo\x7f/n.encoding # => #<Encoding:US-ASCII>
+
+- <tt>/pat/u</tt>: UTF-8
+
+ /foo/u.encoding # => #<Encoding:UTF-8>
+
+- <tt>/pat/e</tt>: EUC-JP
+
+ /foo/e.encoding # => #<Encoding:EUC-JP>
+
+- <tt>/pat/s</tt>: Windows-31J
+
+ /foo/s.encoding # => #<Encoding:Windows-31J>
+
+A regexp can be matched against a target string when either:
+
+- They have the same encoding.
+- The regexp's encoding is a fixed encoding and the string
+ contains only ASCII characters.
+ Method Regexp#fixed_encoding? returns whether the regexp
+ has a <i>fixed</i> encoding.
+
+If a match between incompatible encodings is attempted an
+<tt>Encoding::CompatibilityError</tt> exception is raised.
+
+Example:
+
+ re = eval("# encoding: ISO-8859-1\n/foo\\xff?/")
+ re.encoding # => #<Encoding:ISO-8859-1>
+ re =~ "foo".encode("UTF-8") # => 0
+ re =~ "foo\u0100" # Raises Encoding::CompatibilityError
+
+The encoding may be explicitly fixed by including Regexp::FIXEDENCODING
+in the second argument for Regexp.new:
+
+ # Regexp with encoding ISO-8859-1.
+ re = Regexp.new("a".force_encoding('iso-8859-1'), Regexp::FIXEDENCODING)
+ re.encoding # => #<Encoding:ISO-8859-1>
+ # Target string with encoding UTF-8.
+ s = "a\u3042"
+ s.encoding # => #<Encoding:UTF-8>
+ re.match(s) # Raises Encoding::CompatibilityError.
+
+== Timeouts
+
+When either a regexp source or a target string comes from untrusted input,
+malicious values could become a denial-of-service attack;
+to prevent such an attack, it is wise to set a timeout.
+
+\Regexp has two timeout values:
+
+- A class default timeout, used for a regexp whose instance timeout is +nil+;
+ this default is initially +nil+, and may be set by method Regexp.timeout=:
+
+ Regexp.timeout # => nil
+ Regexp.timeout = 3.0
+ Regexp.timeout # => 3.0
+
+- An instance timeout, which defaults to +nil+ and may be set in Regexp.new:
+
+ re = Regexp.new('foo', timeout: 5.0)
+ re.timeout # => 5.0
+
+When regexp.timeout is +nil+, the timeout "falls through" to Regexp.timeout;
+when regexp.timeout is non-+nil+, that value controls timing out:
+
+ | regexp.timeout Value | Regexp.timeout Value | Result |
+ |----------------------|----------------------|-----------------------------|
+ | nil | nil | Never times out. |
+ | nil | Float | Times out in Float seconds. |
+ | Float | Any | Times out in Float seconds. |
+
+== Optimization
+
+For certain values of the pattern and target string,
+matching time can grow polynomially or exponentially in relation to the input size;
+the potential vulnerability arising from this is the {regular expression denial-of-service}[https://en.wikipedia.org/wiki/ReDoS] (ReDoS) attack.
+
+\Regexp matching can apply an optimization to prevent ReDoS attacks.
+When the optimization is applied, matching time increases linearly (not polynomially or exponentially)
+in relation to the input size, and a ReDoS attack is not possible.
+
+This optimization is applied if the pattern meets these criteria:
+
+- No backreferences.
+- No subexpression calls.
+- No nested lookaround anchors or atomic groups.
+- No nested quantifiers with counting (i.e. no nested <tt>{n}</tt>,
+ <tt>{min,}</tt>, <tt>{,max}</tt>, or <tt>{min,max}</tt> style quantifiers)
+
+You can use method Regexp.linear_time? to determine whether a pattern meets these criteria:
+
+ Regexp.linear_time?(/a*/) # => true
+ Regexp.linear_time?('a*') # => true
+ Regexp.linear_time?(/(a*)\1/) # => false
+
+However, an untrusted source may not be safe even if the method returns +true+,
+because the optimization uses memoization (which may invoke large memory consumption).
+
+== References
+
+Read:
+
+- <i>Mastering Regular Expressions</i>
+ by Jeffrey E.F. Friedl.
+- <i>Regular Expressions Cookbook</i>
+ by Jan Goyvaerts & Steven Levithan.
+
+Explore, test:
+
+- {Rubular}[https://rubular.com/]: interactive online editor.
diff --git a/doc/_timezones.rdoc b/doc/_timezones.rdoc
new file mode 100644
index 0000000000..945654c163
--- /dev/null
+++ b/doc/_timezones.rdoc
@@ -0,0 +1,163 @@
+== Timezone Specifiers
+
+Certain +Time+ methods accept arguments that specify timezones:
+
+- Time.at: keyword argument +in:+.
+- Time.new: positional argument +zone+ or keyword argument +in:+.
+- Time.now: keyword argument +in:+.
+- Time#getlocal: positional argument +zone+.
+- Time#localtime: positional argument +zone+.
+
+The value given with any of these must be one of the following
+(each detailed below):
+
+- {Hours/minutes offset}[rdoc-ref:Time@HoursMinutes+Offsets].
+- {Single-letter offset}[rdoc-ref:Time@Single-Letter+Offsets].
+- {Integer offset}[rdoc-ref:Time@Integer+Offsets].
+- {Timezone object}[rdoc-ref:Time@Timezone+Objects].
+- {Timezone name}[rdoc-ref:Time@Timezone+Names].
+
+=== Hours/Minutes Offsets
+
+The zone value may be a string offset from UTC
+in the form <tt>'+HH:MM'</tt> or <tt>'-HH:MM'</tt>,
+where:
+
+- +HH+ is the 2-digit hour in the range <tt>0..23</tt>.
+- +MM+ is the 2-digit minute in the range <tt>0..59</tt>.
+
+Examples:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
+ Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
+
+=== Single-Letter Offsets
+
+The zone value may be a letter in the range <tt>'A'..'I'</tt>
+or <tt>'K'..'Z'</tt>;
+see {List of military time zones}[https://en.wikipedia.org/wiki/List_of_military_time_zones]:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
+ Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
+ Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
+ Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
+ Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
+
+=== \Integer Offsets
+
+The zone value may be an integer number of seconds
+in the range <tt>-86399..86399</tt>:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
+ Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
+
+=== Timezone Objects
+
+The zone value may be an object responding to certain timezone methods, an
+instance of {Timezone}[https://github.com/panthomakos/timezone] and
+{TZInfo}[https://tzinfo.github.io] for example.
+
+The timezone methods are:
+
+- +local_to_utc+:
+
+ Called when Time.new is invoked with +tz+ as the value of positional
+ argument +zone+ or keyword argument +in:+.
+
+ Argument:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ Returns:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects] in the UTC timezone.
+
+- +utc_to_local+:
+
+ Called when Time.at or Time.now is invoked with +tz+ as the value for
+ keyword argument +in:+, and when Time#getlocal or Time#localtime is called
+ with +tz+ as the value for positional argument +zone+.
+
+ The UTC offset will be calculated as the difference between the
+ original time and the returned object as an +Integer+.
+ If the object is in fixed offset, its +utc_offset+ is also counted.
+
+ Argument:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ Returns:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects] in the local timezone.
+
+A custom timezone class may have these instance methods,
+which will be called if defined:
+
+- +abbr+:
+
+ Called when Time#strftime is invoked with a format involving <tt>%Z</tt>.
+
+ Argument:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ Returns:: a string abbreviation for the timezone name.
+
+- +dst?+:
+
+ Called when Time.at or Time.now is invoked with +tz+ as the value for
+ keyword argument +in:+, and when Time#getlocal or Time#localtime is
+ called with +tz+ as the value for positional argument +zone+.
+
+ Argument:: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ Returns:: whether the time is daylight saving time.
+
+- +name+:
+
+ Called when <tt>Marshal.dump(t)</tt> is invoked
+
+ Argument:: none.
+ Returns:: the string name of the timezone.
+
+==== +Time+-Like Objects
+
+A +Time+-like object is a container object capable of interfacing with
+timezone libraries for timezone conversion.
+
+The argument to the timezone conversion methods above will have attributes
+similar to Time, except that timezone related attributes are meaningless.
+
+The objects returned by +local_to_utc+ and +utc_to_local+ methods of the
+timezone object may be of the same class as their arguments, of arbitrary
+object classes, or of class Integer.
+
+For a returned class other than +Integer+, the class must have the
+following methods:
+
+- +year+
+- +mon+
+- +mday+
+- +hour+
+- +min+
+- +sec+
+- +isdst+
+- +to_i+
+
+For a returned +Integer+, its components, decomposed in UTC, are
+interpreted as times in the specified timezone.
+
+=== Timezone Names
+
+If the class (the receiver of class methods, or the class of the receiver
+of instance methods) has +find_timezone+ singleton method, this method is
+called to achieve the corresponding timezone object from a timezone name.
+
+For example, using {Timezone}[https://github.com/panthomakos/timezone]:
+ class TimeWithTimezone < Time
+ require 'timezone'
+ def self.find_timezone(z) = Timezone[z]
+ end
+
+ TimeWithTimezone.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
+ TimeWithTimezone.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
+
+Or, using {TZInfo}[https://tzinfo.github.io]:
+ class TimeWithTZInfo < Time
+ require 'tzinfo'
+ def self.find_timezone(z) = TZInfo::Timezone.get(z)
+ end
+
+ TimeWithTZInfo.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
+ TimeWithTZInfo.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
+
+You can define this method per subclasses, or on the toplevel Time class.
diff --git a/doc/bsearch.rdoc b/doc/bsearch.rdoc
deleted file mode 100644
index ca8091fc0d..0000000000
--- a/doc/bsearch.rdoc
+++ /dev/null
@@ -1,120 +0,0 @@
-== Binary Searching
-
-A few Ruby methods support binary searching in a collection:
-
-Array#bsearch:: Returns an element selected via a binary search
- as determined by a given block.
-Array#bsearch_index:: Returns the index of an element selected via a binary search
- as determined by a given block.
-Range#bsearch:: Returns an element selected via a binary search
- as determined by a given block.
-
-Each of these methods returns an enumerator if no block is given.
-
-Given a block, each of these methods returns an element (or element index) from +self+
-as determined by a binary search.
-The search finds an element of +self+ which meets
-the given condition in <tt>O(log n)</tt> operations, where +n+ is the count of elements.
-+self+ should be sorted, but this is not checked.
-
-There are two search modes:
-
-Find-minimum mode:: method +bsearch+ returns the first element for which
- the block returns +true+;
- the block must return +true+ or +false+.
-Find-any mode:: method +bsearch+ some element, if any, for which
- the block returns zero.
- the block must return a numeric value.
-
-The block should not mix the modes by sometimes returning +true+ or +false+
-and other times returning a numeric value, but this is not checked.
-
-<b>Find-Minimum Mode</b>
-
-In find-minimum mode, the block must return +true+ or +false+.
-The further requirement (though not checked) is that
-there are no indexes +i+ and +j+ such that:
-
-- <tt>0 <= i < j <= self.size</tt>.
-- The block returns +true+ for <tt>self[i]</tt> and +false+ for <tt>self[j]</tt>.
-
-Less formally: the block is such that all +false+-evaluating elements
-precede all +true+-evaluating elements.
-
-In find-minimum mode, method +bsearch+ returns the first element
-for which the block returns +true+.
-
-Examples:
-
- a = [0, 4, 7, 10, 12]
- a.bsearch {|x| x >= 4 } # => 4
- a.bsearch {|x| x >= 6 } # => 7
- a.bsearch {|x| x >= -1 } # => 0
- a.bsearch {|x| x >= 100 } # => nil
-
- r = (0...a.size)
- r.bsearch {|i| a[i] >= 4 } #=> 1
- r.bsearch {|i| a[i] >= 6 } #=> 2
- r.bsearch {|i| a[i] >= 8 } #=> 3
- r.bsearch {|i| a[i] >= 100 } #=> nil
- r = (0.0...Float::INFINITY)
- r.bsearch {|x| Math.log(x) >= 0 } #=> 1.0
-
-These blocks make sense in find-minimum mode:
-
- a = [0, 4, 7, 10, 12]
- a.map {|x| x >= 4 } # => [false, true, true, true, true]
- a.map {|x| x >= 6 } # => [false, false, true, true, true]
- a.map {|x| x >= -1 } # => [true, true, true, true, true]
- a.map {|x| x >= 100 } # => [false, false, false, false, false]
-
-This would not make sense:
-
- a.map {|x| x == 7 } # => [false, false, true, false, false]
-
-<b>Find-Any Mode</b>
-
-In find-any mode, the block must return a numeric value.
-The further requirement (though not checked) is that
-there are no indexes +i+ and +j+ such that:
-
-- <tt>0 <= i < j <= self.size</tt>.
-- The block returns a negative value for <tt>self[i]</tt>
- and a positive value for <tt>self[j]</tt>.
-- The block returns a negative value for <tt>self[i]</tt> and zero <tt>self[j]</tt>.
-- The block returns zero for <tt>self[i]</tt> and a positive value for <tt>self[j]</tt>.
-
-Less formally: the block is such that:
-
-- All positive-evaluating elements precede all zero-evaluating elements.
-- All positive-evaluating elements precede all negative-evaluating elements.
-- All zero-evaluating elements precede all negative-evaluating elements.
-
-In find-any mode, method +bsearch+ returns some element
-for which the block returns zero, or +nil+ if no such element is found.
-
-Examples:
-
- a = [0, 4, 7, 10, 12]
- a.bsearch {|element| 7 <=> element } # => 7
- a.bsearch {|element| -1 <=> element } # => nil
- a.bsearch {|element| 5 <=> element } # => nil
- a.bsearch {|element| 15 <=> element } # => nil
-
- a = [0, 100, 100, 100, 200]
- r = (0..4)
- r.bsearch {|i| 100 - a[i] } #=> 1, 2 or 3
- r.bsearch {|i| 300 - a[i] } #=> nil
- r.bsearch {|i| 50 - a[i] } #=> nil
-
-These blocks make sense in find-any mode:
-
- a = [0, 4, 7, 10, 12]
- a.map {|element| 7 <=> element } # => [1, 1, 0, -1, -1]
- a.map {|element| -1 <=> element } # => [-1, -1, -1, -1, -1]
- a.map {|element| 5 <=> element } # => [1, 1, -1, -1, -1]
- a.map {|element| 15 <=> element } # => [1, 1, 1, 1, 1]
-
-This would not make sense:
-
- a.map {|element| element <=> 7 } # => [-1, -1, 0, 1, 1]
diff --git a/doc/case_mapping.rdoc b/doc/case_mapping.rdoc
deleted file mode 100644
index 3c42154973..0000000000
--- a/doc/case_mapping.rdoc
+++ /dev/null
@@ -1,116 +0,0 @@
-== Case Mapping
-
-Some string-oriented methods use case mapping.
-
-In String:
-
-- String#capitalize
-- String#capitalize!
-- String#casecmp
-- String#casecmp?
-- String#downcase
-- String#downcase!
-- String#swapcase
-- String#swapcase!
-- String#upcase
-- String#upcase!
-
-In Symbol:
-
-- Symbol#capitalize
-- Symbol#casecmp
-- Symbol#casecmp?
-- Symbol#downcase
-- Symbol#swapcase
-- Symbol#upcase
-
-=== Default Case Mapping
-
-By default, all of these methods use full Unicode case mapping,
-which is suitable for most languages.
-See {Section 3.13 (Default Case Algorithms) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf].
-
-Non-ASCII case mapping and folding are supported for UTF-8,
-UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols.
-
-Context-dependent case mapping as described in
-{Table 3-17 (Context Specification for Casing) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf]
-is currently not supported.
-
-In most cases, case conversions of a string have the same number of characters.
-There are exceptions (see also +:fold+ below):
-
- s = "\u00DF" # => "ß"
- s.upcase # => "SS"
- s = "\u0149" # => "ʼn"
- s.upcase # => "ʼN"
-
-Case mapping may also depend on locale (see also +:turkic+ below):
-
- s = "\u0049" # => "I"
- s.downcase # => "i" # Dot above.
- s.downcase(:turkic) # => "ı" # No dot above.
-
-Case changes may not be reversible:
-
- s = 'Hello World!' # => "Hello World!"
- s.downcase # => "hello world!"
- s.downcase.upcase # => "HELLO WORLD!" # Different from original s.
-
-Case changing methods may not maintain Unicode normalization.
-See String#unicode_normalize).
-
-=== Options for Case Mapping
-
-Except for +casecmp+ and +casecmp?+,
-each of the case-mapping methods listed above
-accepts optional arguments, <tt>*options</tt>.
-
-The arguments may be:
-
-- +:ascii+ only.
-- +:fold+ only.
-- +:turkic+ or +:lithuanian+ or both.
-
-The options:
-
-- +:ascii+:
- ASCII-only mapping:
- uppercase letters ('A'..'Z') are mapped to lowercase letters ('a'..'z);
- other characters are not changed
-
- s = "Foo \u00D8 \u00F8 Bar" # => "Foo Ø ø Bar"
- s.upcase # => "FOO Ø Ø BAR"
- s.downcase # => "foo ø ø bar"
- s.upcase(:ascii) # => "FOO Ø ø BAR"
- s.downcase(:ascii) # => "foo Ø ø bar"
-
-- +:turkic+:
- Full Unicode case mapping, adapted for the Turkic languages
- that distinguish dotted and dotless I, for example Turkish and Azeri.
-
- s = 'Türkiye' # => "Türkiye"
- s.upcase # => "TÜRKIYE"
- s.upcase(:turkic) # => "TÜRKİYE" # Dot above.
-
- s = 'TÜRKIYE' # => "TÜRKIYE"
- s.downcase # => "türkiye"
- s.downcase(:turkic) # => "türkıye" # No dot above.
-
-- +:lithuanian+:
- Not yet implemented.
-
-- +:fold+ (available only for String#downcase, String#downcase!,
- and Symbol#downcase):
- Unicode case folding,
- which is more far-reaching than Unicode case mapping.
-
- s = "\u00DF" # => "ß"
- s.downcase # => "ß"
- s.downcase(:fold) # => "ss"
- s.upcase # => "SS"
-
- s = "\uFB04" # => "ffl"
- s.downcase # => "ffl"
- s.upcase # => "FFL"
- s.downcase(:fold) # => "ffl"
diff --git a/doc/character_selectors.rdoc b/doc/character_selectors.rdoc
deleted file mode 100644
index e01b0e6a25..0000000000
--- a/doc/character_selectors.rdoc
+++ /dev/null
@@ -1,97 +0,0 @@
-== Character Selectors
-
-=== Character Selector
-
-A _character_ _selector_ is a string argument accepted by certain Ruby methods.
-Each of these instance methods accepts one or more character selectors:
-
-- String#tr(selector, replacements): returns a new string.
-- String#tr!(selector, replacements): returns +self+ or +nil+.
-- String#tr_s(selector, replacements): returns a new string.
-- String#tr_s!(selector, replacements): returns +self+ or +nil+.
-- String#count(*selectors): returns the count of the specified characters.
-- String#delete(*selectors): returns a new string.
-- String#delete!(*selectors): returns +self+ or +nil+.
-- String#squeeze(*selectors): returns a new string.
-- String#squeeze!(*selectors): returns +self+ or +nil+.
-
-A character selector identifies zero or more characters in +self+
-that are to be operands for the method.
-
-In this section, we illustrate using method String#delete(selector),
-which deletes the selected characters.
-
-In the simplest case, the characters selected are exactly those
-contained in the selector itself:
-
- 'abracadabra'.delete('a') # => "brcdbr"
- 'abracadabra'.delete('ab') # => "rcdr"
- 'abracadabra'.delete('abc') # => "rdr"
- '0123456789'.delete('258') # => "0134679"
- '!@#$%&*()_+'.delete('+&#') # => "!@$%*()_"
- 'теÑÑ‚'.delete('Ñ‚') # => "еÑ"
- 'ã“ã‚“ã«ã¡ã¯'.delete('ã«') # => "ã“ã‚“ã¡ã¯"
-
-Note that order and repetitions do not matter:
-
- 'abracadabra'.delete('dcab') # => "rr"
- 'abracadabra'.delete('aaaa') # => "brcdbr"
-
-In a character selector, these three characters get special treatment:
-
-- A leading caret (<tt>'^'</tt>) functions as a "not" operator
- for the characters to its right:
-
- 'abracadabra'.delete('^bc') # => "bcb"
- '0123456789'.delete('^852') # => "258"
-
-- A hyphen (<tt>'-'</tt>) between two other characters
- defines a range of characters instead of a plain string of characters:
-
- 'abracadabra'.delete('a-d') # => "rr"
- '0123456789'.delete('4-7') # => "012389"
- '!@#$%&*()_+'.delete(' -/') # => "@^_"
-
- # May contain more than one range.
- 'abracadabra'.delete('a-cq-t') # => "d"
-
- # Ranges may be mixed with plain characters.
- '0123456789'.delete('67-950-23') # => "4"
-
- # Ranges may be mixed with negations.
- 'abracadabra'.delete('^a-c') # => "abacaaba"
-
-- A backslash (<tt>'\'</tt>) acts as an escape for a caret, a hyphen,
- or another backslash:
-
- 'abracadabra^'.delete('\^bc') # => "araadara"
- 'abracadabra-'.delete('a\-d') # => "brcbr"
- "hello\r\nworld".delete("\r") # => "hello\nworld"
- "hello\r\nworld".delete("\\r") # => "hello\r\nwold"
- "hello\r\nworld".delete("\\\r") # => "hello\nworld"
-
-=== Multiple Character Selectors
-
-These instance methods accept multiple character selectors:
-
-- String#count(*selectors): returns the count of the specified characters.
-- String#delete(*selectors): returns a new string.
-- String#delete!(*selectors): returns +self+ or +nil+.
-- String#squeeze(*selectors): returns a new string.
-- String#squeeze!(*selectors): returns +self+ or +nil+.
-
-In effect, the given selectors are formed into a single selector
-consisting of only those characters common to _all_ of the given selectors.
-
-All forms of selectors may be used, including negations, ranges, and escapes.
-
-Each of these pairs of method calls is equivalent:
-
- s.delete('abcde', 'dcbfg')
- s.delete('bcd')
-
- s.delete('^abc', '^def')
- s.delete('^abcdef')
-
- s.delete('a-e', 'c-g')
- s.delete('cde')
diff --git a/doc/command_injection.rdoc b/doc/command_injection.rdoc
deleted file mode 100644
index af09be23f0..0000000000
--- a/doc/command_injection.rdoc
+++ /dev/null
@@ -1,29 +0,0 @@
-== Command Injection
-
-Some Ruby core methods accept string data
-that includes text to be executed as a system command.
-
-They should not be called with unknown or unsanitized commands.
-
-These methods include:
-
-- Kernel.system
-- {\`command` (backtick method)}[rdoc-ref:Kernel#`]
- (also called by the expression <tt>%x[command]</tt>).
-- IO.popen(command).
-- IO.read(command).
-- IO.write(command).
-- IO.binread(command).
-- IO.binwrite(command).
-- IO.readlines(command).
-- IO.foreach(command).
-
-Note that some of these methods do not execute commands when called
-from subclass \File:
-
-- File.read(path).
-- File.write(path).
-- File.binread(path).
-- File.binwrite(path).
-- File.readlines(path).
-- File.foreach(path).
diff --git a/doc/contributing.md b/doc/contributing.md
deleted file mode 100644
index a6c63de9b2..0000000000
--- a/doc/contributing.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Contributing to Ruby
-
-This guide outlines ways to get started with contributing to Ruby:
-
-* [Reporting issues](contributing/reporting_issues.md): How to report issues, how to request features, and how backporting works
-* [Building Ruby](contributing/building_ruby.md): How to build Ruby on your local machine for development
-* [Testing Ruby](contributing/testing_ruby.md): How to test Ruby on your local machine once you've built it
-* [Making changes to Ruby](contributing/making_changes_to_ruby.md): How to submit pull requests
- to change Ruby's documentation, code, test suite, or standard libraries
-* [Making changes to Ruby standard libraries](contributing/making_changes_to_stdlibs.md): How to build, test, and contribute to Ruby standard libraries
-* [Making changes to Ruby documentation](contributing/documentation_guide.md): How to make changes to Ruby documentation
-* [Benchmarking Ruby](https://github.com/ruby/ruby/tree/master/benchmark#make-benchmark): How to benchmark Ruby
diff --git a/doc/bug_triaging.rdoc b/doc/contributing/bug_triaging.rdoc
index 83fe88cabe..83fe88cabe 100644
--- a/doc/bug_triaging.rdoc
+++ b/doc/contributing/bug_triaging.rdoc
diff --git a/doc/contributing/building_ruby.md b/doc/contributing/building_ruby.md
index 8098b72927..a283a2f3db 100644
--- a/doc/contributing/building_ruby.md
+++ b/doc/contributing/building_ruby.md
@@ -8,98 +8,183 @@
For RubyGems, you will also need:
- * OpenSSL 1.1.x or 3.0.x / LibreSSL
- * libyaml 0.1.7 or later
- * zlib
+ * [OpenSSL] 1.1.x or 3.0.x / [LibreSSL]
+ * [libyaml] 0.1.7 or later
+ * [zlib]
If you want to build from the git repository, you will also need:
- * autoconf - 2.67 or later
- * bison - 3.0 or later
- * gperf - 3.1 or later
+ * [autoconf] - 2.67 or later
+ * [gperf] - 3.1 or later
* Usually unneeded; only if you edit some source files using gperf
- * ruby - 2.5 or later
- * We can upgrade this version to system ruby version of the latest Ubuntu LTS.
+ * ruby - 3.1 or later
+ * We can upgrade this version to system ruby version of the latest
+ Ubuntu LTS.
+ * git - 2.32 or later
+ * Earlier versions may work; 2.32 or later will prevent build
+ errors in case your system `.gitconfig` uses `$HOME` paths.
2. Install optional, recommended dependencies:
- * readline/editline (libedit, to build readline)
- * libffi (to build fiddle)
- * gmp (if you with to accelerate Bignum operations)
- * libexecinfo (FreeBSD)
- * rustc - 1.58.0 or later (if you wish to build [YJIT](/doc/yjit/yjit.md))
+ * [libffi] (to build fiddle)
+ * [gmp] (if you wish to accelerate Bignum operations)
+ * [rustc] - 1.58.0 or later, if you wish to build
+ [YJIT](rdoc-ref:RubyVM::YJIT).
- If you installed the libraries needed for extensions (openssl, readline, libyaml, zlib) into other than the OS default place,
- typically using Homebrew on macOS, add `--with-EXTLIB-dir` options to `CONFIGURE_ARGS` environment variable.
+ If you want to link the libraries (e.g., gmp) installed into other than
+ the OS default place, typically using Homebrew on macOS, pass the
+ `--with-opt-dir` (or `--with-gmp-dir` for gmp) option to `configure`.
- ``` shell
+ ```sh
+ configure --with-opt-dir=$(brew --prefix gmp):$(brew --prefix jemalloc)
+ ```
+
+ As for the libraries needed for particular extensions only and not for
+ Ruby (openssl, readline, libyaml, zlib), you can add `--with-EXTLIB-dir`
+ options to the command line or to `CONFIGURE_ARGS` environment variable.
+ The command line options will be embedded in `rbconfig.rb`, while the
+ latter environment variable is not embedded and is only used when
+ building the extension libraries.
+
+ ```sh
export CONFIGURE_ARGS=""
for ext in openssl readline libyaml zlib; do
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)"
done
```
+[OpenSSL]: https://www.openssl.org
+[LibreSSL]: https://www.libressl.org
+[libyaml]: https://github.com/yaml/libyaml/
+[zlib]: https://www.zlib.net
+[autoconf]: https://www.gnu.org/software/autoconf/
+[gperf]: https://www.gnu.org/software/gperf/
+[libffi]: https://sourceware.org/libffi/
+[gmp]: https://gmplib.org
+[rustc]: https://www.rust-lang.org
+
## Quick start guide
1. Download ruby source code:
+ Select one of the below.
+
1. Build from the tarball:
- Download the latest tarball from [ruby-lang.org](https://www.ruby-lang.org/en/downloads/) and
- extract it. Example for Ruby 3.0.2:
+ Download the latest tarball from [Download Ruby] page and extract
+ it. Example for Ruby 3.0.2:
- ``` shell
- tar -xzf ruby-3.0.2.tar.gz
- cd ruby-3.0.2
- ```
+ ```sh
+ tar -xzf ruby-3.0.2.tar.gz
+ cd ruby-3.0.2
+ ```
2. Build from the git repository:
- Checkout the CRuby source code:
+ Checkout the CRuby source code:
- ``` shell
- git clone https://github.com/ruby/ruby.git
- ```
+ ```sh
+ git clone https://github.com/ruby/ruby.git
+ cd ruby
+ ```
- Generate the configure file:
+ Run the GNU Autoconf script (which generates the `configure` script):
- ``` shell
- ./autogen.sh
- ```
+ ```sh
+ ./autogen.sh
+ ```
-2. Create a `build` directory separate from the source directory:
+2. Create a `build` directory inside the repository directory:
- ``` shell
+ ```sh
mkdir build && cd build
```
- While it's not necessary to build in a separate directory, it's good practice to do so.
+ While it's not necessary to build in a dedicated directory like this, it's good
+ practice to do so.
-3. We'll install Ruby in `~/.rubies/ruby-master`, so create the directory:
+3. We'll eventually install our new Ruby in `~/.rubies/ruby-master`, so we'll create that directory:
- ``` shell
+ ```sh
mkdir ~/.rubies
```
-4. Run configure:
+4. Run the `configure` script (which generates the `Makefile`):
- ``` shell
+ ```sh
../configure --prefix="${HOME}/.rubies/ruby-master"
```
- - If you are frequently building Ruby, add the `--disable-install-doc` flag to not build documentation which will speed up the build process.
+ - Also `-C` (or `--config-cache`) would reduce time to configure from the
+ next time.
5. Build Ruby:
- ``` shell
- make install
+ ```sh
+ make
```
6. [Run tests](testing_ruby.md) to confirm your build succeeded.
+7. Install our newly-compiled Ruby into `~/.rubies/ruby-master`:
+
+ ```sh
+ make install
+ ```
+
+ - If you need to run `make install` with `sudo` and want to avoid document
+ generation with different permissions, you can use `make SUDO=sudo
+ install`.
+
+8. You can then try your new Ruby out, for example:
+
+ ```sh
+ ~/.rubies/ruby-master/bin/ruby -e "puts 'Hello, World!'"
+ ```
+
+By the end, your repo will look like this:
+
+```text
+ruby
+├── autogen.sh # Pre-existing Autoconf script, used in step 1
+├── configure # Generated in step 1, which generates the `Makefile` in step 4
+├── build # Created in step 2 and populated in step 4
+│ ├── GNUmakefile # Generated by `../configure`
+│ ├── Makefile # Generated by `../configure`
+│ ├── object.o # Compiled object file, built by `make`
+│ └── ... other compiled `.o` object files
+│
+│ # Other interesting files:
+├── include
+│ └── ruby.h # The main public header
+├── internal
+│ ├── object.h
+│ └── ... other header files used by the `.c` files in the repo root.
+├── lib
+│ └── # Default gems, like `bundler`, `erb`, `set`, `yaml`, etc.
+├── spec
+│ └── # A mirror of the Ruby specification from github.com/ruby/spec
+├── test
+│ ├── ruby
+│ └── ...
+├── object.c
+└── ... other `.c` files
+```
+
+[Download Ruby]: https://www.ruby-lang.org/en/downloads/
+
### Unexplainable Build Errors
-If you are having unexplainable build errors, after saving all your work, try running `git clean -xfd` in the source root to remove all git ignored local files. If you are working from a source directory that's been updated several times, you may have temporary build artifacts from previous releases which can cause build failures.
+If you are having unexplainable build errors, after saving all your work, try
+running `git clean -xfd` in the source root to remove all git ignored local
+files. If you are working from a source directory that's been updated several
+times, you may have temporary build artifacts from previous releases which can
+cause build failures.
+
+## Building on Windows
+
+The documentation for building on Windows can be found in [the separated
+file](../distribution/windows.md).
## More details
@@ -108,18 +193,21 @@ about Ruby's build to help out.
### Running make scripts in parallel
-In GNU make and BSD make implementations, to run a specific make script in parallel, pass the flag `-j<number of processes>`. For instance,
-to run tests on 8 processes, use:
+In GNU make[^caution-gmake-3] and BSD make implementations, to run a specific make script in
+parallel, pass the flag `-j<number of processes>`. For instance, to run tests
+on 8 processes, use:
-``` shell
+```sh
make test-all -j8
```
We can also set `MAKEFLAGS` to run _all_ `make` commands in parallel.
-Having the right `--jobs` flag will ensure all processors are utilized when building software projects. To do this effectively, you can set `MAKEFLAGS` in your shell configuration/profile:
+Having the right `--jobs` flag will ensure all processors are utilized when
+building software projects. To do this effectively, you can set `MAKEFLAGS` in
+your shell configuration/profile:
-``` shell
+```sh
# On macOS with Fish shell:
export MAKEFLAGS="--jobs "(sysctl -n hw.ncpu)
@@ -133,20 +221,25 @@ export MAKEFLAGS="--jobs "(nproc)
export MAKEFLAGS="--jobs $(nproc)"
```
+[^caution-gmake-3]: **CAUTION**: GNU make 3 is missing some features for parallel execution, we
+recommend to upgrade to GNU make 4 or later.
+
### Miniruby vs Ruby
-Miniruby is a version of Ruby which has no external dependencies and lacks certain features.
-It can be useful in Ruby development because it allows for faster build times. Miniruby is
-built before Ruby. A functional Miniruby is required to build Ruby. To build Miniruby:
+Miniruby is a version of Ruby which has no external dependencies and lacks
+certain features. It can be useful in Ruby development because it allows for
+faster build times. Miniruby is built before Ruby. A functional Miniruby is
+required to build Ruby. To build Miniruby:
-``` shell
+```sh
make miniruby
```
## Debugging
-You can use either lldb or gdb for debugging. Before debugging, you need to create a `test.rb`
-with the Ruby script you'd like to run. You can use the following make targets:
+You can use either lldb or gdb for debugging. Before debugging, you need to
+create a `test.rb` with the Ruby script you'd like to run. You can use the
+following make targets:
* `make run`: Runs `test.rb` using Miniruby
* `make lldb`: Runs `test.rb` using Miniruby in lldb
@@ -155,25 +248,92 @@ with the Ruby script you'd like to run. You can use the following make targets:
* `make lldb-ruby`: Runs `test.rb` using Ruby in lldb
* `make gdb-ruby`: Runs `test.rb` using Ruby in gdb
+For VS Code users, you can set up editor-based debugging experience by running:
+
+```shell
+cp -r misc/.vscode .vscode
+```
+
+This will add launch configurations for debugging Ruby itself by running `test.rb` with `lldb`.
+
+**Note**: if you build Ruby under the `./build` folder, you'll need to update `.vscode/launch.json`'s program entry accordingly to: `"${workspaceFolder}/build/ruby"`
+
+### Compiling for Debugging
+
+You can compile Ruby with the `RUBY_DEBUG` macro to enable debugging on some
+features. One example is debugging object shapes in Ruby with
+`RubyVM::Shape.of(object)`.
+
+Additionally Ruby can be compiled to support the `RUBY_DEBUG` environment
+variable to enable debugging on some features. An example is using
+`RUBY_DEBUG=gc_stress` to debug GC-related issues.
+
+There is also support for the `RUBY_DEBUG_LOG` environment variable to log a
+lot of information about what the VM is doing, via the `USE_RUBY_DEBUG_LOG`
+macro.
+
+You should also configure Ruby without optimization and other flags that may
+interfere with debugging by changing the optimization flags.
+
+Bringing it all together:
+
+```sh
+./configure cppflags="-DRUBY_DEBUG=1 -DUSE_RUBY_DEBUG_LOG=1" --enable-debug-env optflags="-O0 -fno-omit-frame-pointer"
+```
+
### Building with Address Sanitizer
-Using the address sanitizer is a great way to detect memory issues.
+Using the address sanitizer (ASAN) is a great way to detect memory issues. It
+can detect memory safety issues in Ruby itself, and also in any C extensions
+compiled with and loaded into a Ruby compiled with ASAN.
-``` shell
+```sh
./autogen.sh
mkdir build && cd build
-export ASAN_OPTIONS="halt_on_error=0:use_sigaltstack=0:detect_leaks=0"
-../configure cppflags="-fsanitize=address -fno-omit-frame-pointer" optflags=-O0 LDFLAGS="-fsanitize=address -fno-omit-frame-pointer"
+../configure CC=clang-18 cflags="-fsanitize=address -fno-omit-frame-pointer -DUSE_MN_THREADS=0" # and any other options you might like
make
```
-On Linux it is important to specify `-O0` when debugging. This is especially true for ASAN which sometimes works incorrectly at higher optimisation levels.
+The compiled Ruby will now automatically crash with a report and a backtrace
+if ASAN detects a memory safety issue. To run Ruby's test suite under ASAN,
+issue the following command. Note that this will take quite a long time (over
+two hours on my laptop); the `RUBY_TEST_TIMEOUT_SCALE` and
+`SYNTAX_SUGEST_TIMEOUT` variables are required to make sure tests don't
+spuriously fail with timeouts when in fact they're just slow.
+
+```sh
+RUBY_TEST_TIMEOUT_SCALE=5 SYNTAX_SUGGEST_TIMEOUT=600 make check
+```
+
+Please note, however, the following caveats!
+
+* Due to [Bug #20243], Clang generates code for threadlocal variables which
+ doesn't work with M:N threading. Thus, it's necessary to disable M:N
+ threading support at build time for now (with the `-DUSE_MN_THREADS=0`
+ configure argument).
+* ASAN will only work when using Clang version 18 or later - it requires
+ [llvm/llvm-project#75290] related to multithreaded `fork`.
+* ASAN has only been tested so far with Clang on Linux. It may or may not work
+ with other compilers or on other platforms - please file an issue on
+ [Ruby Issue Tracking System] if you run into problems with such configurations
+ (or, to report that they actually work properly!)
+* In particular, although I have not yet tried it, I have reason to believe
+ ASAN will _not_ work properly on macOS yet - the fix for the multithreaded
+ fork issue was actually reverted for macOS (see [llvm/llvm-project#75659]).
+ Please open an issue on [Ruby Issue Tracking System] if this is a problem for
+ you.
+
+[Revision 9d0a5148]: https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/9d0a5148ae062a0481a4a18fbeb9cfd01dc10428
+[Bug #20243]: https://bugs.ruby-lang.org/issues/20243
+[llvm/llvm-project#75290]: https://github.com/llvm/llvm-project/pull/75290
+[llvm/llvm-project#75659]: https://github.com/llvm/llvm-project/pull/75659#issuecomment-1861584777
+[Ruby Issue Tracking System]: https://bugs.ruby-lang.org
## How to measure coverage of C and Ruby code
You need to be able to use gcc (gcov) and lcov visualizer.
-``` shell
+```sh
./autogen.sh
./configure --enable-gcov
make
@@ -184,11 +344,12 @@ make lcov
open lcov-out/index.html
```
-If you need only C code coverage, you can remove `COVERAGE=true` from the above process.
-You can also use `gcov` command directly to get per-file coverage.
+If you need only C code coverage, you can remove `COVERAGE=true` from the
+above process. You can also use `gcov` command directly to get per-file
+coverage.
-If you need only Ruby code coverage, you can remove `--enable-gcov`.
-Note that `test-coverage.dat` accumulates all runs of `make test-all`.
-Make sure that you remove the file if you want to measure one test run.
+If you need only Ruby code coverage, you can remove `--enable-gcov`. Note
+that `test-coverage.dat` accumulates all runs of `make test-all`. Make sure
+that you remove the file if you want to measure one test run.
You can see the coverage result of CI: https://rubyci.org/coverage
diff --git a/doc/contributing/concurrency_guide.md b/doc/contributing/concurrency_guide.md
new file mode 100644
index 0000000000..1fb58f7203
--- /dev/null
+++ b/doc/contributing/concurrency_guide.md
@@ -0,0 +1,154 @@
+# Concurrency Guide
+
+This is a guide to thinking about concurrency in the cruby source code, whether that's contributing to Ruby
+by writing C or by contributing to one of the JITs. This does not touch on native extensions, only the core
+language. It will go over:
+
+* What needs synchronizing?
+* How to use the VM lock, and what you can and can't do when you've acquired this lock.
+* What you can and can't do when you've acquired other native locks.
+* The difference between the VM lock and the GVL.
+* What a VM barrier is and when to use it.
+* The lock ordering of some important locks.
+* How ruby interrupt handling works.
+* The timer thread and what it's responsible for.
+
+## What needs synchronizing?
+
+Before ractors, only one ruby thread could run at once. That didn't mean you could forget about concurrency issues, though. The timer thread
+is a native thread that interacts with other ruby threads and changes some VM internals, so if these changes can be done in parallel by both the timer
+thread and a ruby thread, they need to be synchronized.
+
+When you add ractors to the mix, it gets more complicated. However, ractors allow you to forget about synchronization for non-shareable objects because
+they aren't used across ractors. Only one ruby thread can touch the object at once. For shareable objects, they are deeply frozen so there isn't any
+mutation on the objects themselves. However, something like reading/writing constants across ractors does need to be synchronized. In this case, ruby threads need to
+see a consistent view of the VM. If publishing the update takes 2 steps or even two separate instructions, like in this case, synchronization is required.
+
+Most synchronization is to protect VM internals. These internals include structures for the thread scheduler on each ractor, the global ractor scheduler, the
+coordination between ruby threads and ractors, global tables (for `fstrings`, encodings, symbols and global vars), etc. Anything that can be mutated by a ractor
+that can also be read or mutated by another ractor at the same time requires proper synchronization.
+
+## The VM Lock
+
+There's only one VM lock and it is for critical sections that can only be entered by one ractor at a time.
+Without ractors, the VM lock is useless. It does not stop all ractors from running, as ractors can run
+without trying to acquire this lock. If you're updating global (shared) data between ractors and aren't using
+atomics, you need to use a lock and this is a convenient one to use. Unlike other locks, you can allocate ruby-managed
+memory with it held. When you take the VM lock, there are things you can and can't do during your critical section:
+
+You can (as long as no other locks are also held before the VM lock):
+
+* Create ruby objects, call `ruby_xmalloc`, etc.
+
+You can't:
+
+* Context switch to another ruby thread or ractor. This is important, as many things can cause ruby-level context switches including:
+
+ * Calling any ruby method through, for example, `rb_funcall`. If you execute ruby code, a context switch could happen.
+ This also applies to ruby methods defined in C, as they can be redefined in Ruby. Things that call ruby methods such as
+ `rb_obj_respond_to` are also disallowed.
+
+ * Calling `rb_raise`. This will call `initialize` on the new exception object. With the VM lock
+ held, nothing you call should be able to raise an exception. `NoMemoryError` is allowed, however.
+
+ * Calling `rb_nogvl` or a ruby-level mechanism that can context switch like `rb_mutex_lock`.
+
+ * Enter any blocking operation managed by ruby. This will context switch to another ruby thread using `rb_nogvl` or
+ something equivalent. A blocking operation is one that blocks the thread's progress, such as `sleep` or `IO#read`.
+
+Internally, the VM lock is the `vm->ractor.sync.lock`.
+
+You need to be on a ruby thread to take the VM lock. You also can't take it inside any functions that could be called during sweeping, as MMTK sweeps
+on another thread and you need a valid `ec` to grab the lock. For this same reason (among others), you can't take it from the timer thread either.
+
+## Other Locks
+
+All native locks that aren't the VM lock share a more strict set of rules for what's allowed during the critical section. By native locks, we mean
+anything that uses `rb_native_mutex_lock`. Some important locks include the `interrupt_lock`, the ractor scheduling lock (protects global scheduling data structures),
+the thread scheduling lock (local to each ractor, protects per-ractor scheduling data structures) and the ractor lock (local to each ractor, protects ractor data structures).
+
+When you acquire one of these locks,
+
+You can:
+
+* Allocate memory though non-ruby allocation such as raw `malloc` or the standard library. But be careful, some functions like `strdup` use
+ruby allocation through the use of macros!
+
+* Use `ccan` lists, as they don't allocate.
+
+* Do the usual things like set variables or struct fields, manipulate linked lists, signal condition variables etc.
+
+You can't:
+
+* Allocate ruby-managed memory. This includes creating ruby objects or using `ruby_xmalloc` or `st_insert`. The reason this
+is disallowed is if that allocation causes a GC, then all other ruby threads must join a VM barrier as soon as possible
+(when they next check interrupts or acquire the VM lock). This is so that no other ractors are running during GC. If a ruby thread
+is waiting (blocked) on this same native lock, it can't join the barrier and a deadlock occurs because the barrier will never finish.
+
+* Raise exceptions. You also can't use `EC_JUMP_TAG` if it jumps out of the critical section.
+
+* Context switch. See the `VM Lock` section for more info.
+
+## Difference Between VM Lock and GVL
+
+The VM Lock is a particular lock in the source code. There is only one VM Lock. The GVL, on the other hand, is more of a combination of locks.
+It is "acquired" when a ruby thread is about to run or is running. Since many ruby threads can run at the same time if they're in different ractors,
+there are many GVLs (1 per `SNT` + 1 for the main ractor). It can no longer be thought of as a "Global VM Lock" like it once was before ractors.
+
+## VM Barriers
+
+Sometimes, taking the VM Lock isn't enough and you need a guarantee that all ractors have stopped. This happens when running `GC`, for instance.
+To get a barrier, you take the VM Lock and call `rb_vm_barrier()`. For the duration that the VM lock is held, no other ractors will be running. It's not used
+often as taking a barrier slows ractor performance down considerably, but it's useful to know about and is sometimes the only solution.
+
+## Lock Orderings
+
+It's a good idea to not hold more than 2 locks at once on the same thread. Locking multiple locks can introduce deadlocks, so do it with care. When locking
+multiple locks at once, follow an ordering that is consistent across the program, otherwise you can introduce deadlocks. Here are the orderings of some important locks:
+
+* VM lock before ractor_sched_lock
+* thread_sched_lock before ractor_sched_lock
+* interrupt_lock before timer_th.waiting_lock
+* timer_th.waiting_lock before ractor_sched_lock
+
+These orderings are subject to change, so check the source if you're not sure. On top of this:
+
+* During each `ubf` (unblock) function, the VM lock can be taken around it in some circumstances. This happens during VM shutdown, for example.
+See the "Interrupt Handling" section for more details.
+
+## Ruby Interrupt Handling
+
+When the VM runs ruby code, ruby's threads intermittently check ruby-level interrupts. These software interrupts
+are for various things in ruby and they can be set by other ruby threads or the timer thread.
+
+* Ruby threads check when they should give up their timeslice. The native thread switches to another ruby thread when their time is up.
+* The timer thread sends a "trap" interrupt to the main thread if any ruby-level signal handlers are pending.
+* Ruby threads can have other ruby threads run tasks for them by sending them an interrupt. For instance, ractors send
+the main thread an interrupt when they need to `require` a file so that it's done on the main thread. They wait for the
+main thread's result.
+* During VM shutdown, a "terminate" interrupt is sent to all ractor main threads top stop them asap.
+* When calling `Thread#raise`, the caller sends an interrupt to that thread telling it which exception to raise.
+* Unlocking a mutex sends the next waiter (if any) an interrupt telling it to grab the lock.
+* Signalling or broadcasting on a condition variable tells the waiter(s) to wake up.
+
+This isn't a complete list.
+
+When sending an interrupt to a ruby thread, the ruby thread can be blocked. For example, it could be in the middle of a `TCPSocket#read` call. If so,
+the receiving thread's `ubf` (unblock function) gets called from the thread (ruby thread or timer thread) that sent the interrupt.
+Each ruby thread has a `ubf` that is set when it enters a blocking operation and is unset after returning from it. By default, this `ubf` function sends a
+`SIGVTALRM` to the receiving thread to try to unblock it from the kernel so it can check its interrupts. There are other `ubfs` that
+aren't associated with a syscall, such as when calling `Ractor#join` or `sleep`. All `ubfs` are called with the `interrupt_lock` held,
+so take that into account when using locks inside `ubfs`.
+
+Remember, `ubfs` can be called from the timer thread so you cannot assume an `ec` inside them. The `ec` (execution context) is only set on ruby threads.
+
+## The Timer Thread
+
+The timer thread has a few functions. They are:
+
+* Send interrupts to ruby threads that have run for their whole timeslice.
+* Wake up M:N ruby threads (threads in non-main ractors) blocked on IO or after a specified timeout. This
+uses `kqueue` or `epoll`, depending on the OS, to receive IO events on behalf of the threads.
+* Continue calling the `SIGVTARLM` signal if a thread is still blocked on a syscall after the first `ubf` call.
+* Signal native threads (`SNT`) waiting on a ractor if there are ractors waiting in the global run queue.
+* Create more `SNT`s if some are blocked, like on IO or on `Ractor#join`.
diff --git a/doc/contributing/contributing.md b/doc/contributing/contributing.md
new file mode 100644
index 0000000000..a2ed00ab90
--- /dev/null
+++ b/doc/contributing/contributing.md
@@ -0,0 +1,35 @@
+# Contributing to Ruby
+
+## Ruby Issues
+
+To report an issue in the Ruby core:
+
+* [Report issues](reporting_issues.md).
+
+## Ruby Core
+
+To contribute to the Ruby core functionality,
+you'll need initially to:
+
+* [Build Ruby](building_ruby.md) on your system.
+* [Test Ruby](testing_ruby.md), to make sure the build is correct.
+
+Then:
+
+* [Make changes to Ruby](making_changes_to_ruby.md).
+
+And possibly:
+
+* [Benchmark Ruby](https://github.com/ruby/ruby/tree/master/benchmark#make-benchmark).
+
+## Ruby Documentation
+
+To contribute to the Ruby core documentation, see:
+
+* [Making changes to the Ruby documentation](documentation_guide.md).
+
+## Ruby Standard Library
+
+To contribute to the Ruby Standard Library, see:
+
+* [Making changes to the Ruby Standard Library](making_changes_to_stdlibs.md).
diff --git a/doc/contributing/documentation_guide.md b/doc/contributing/documentation_guide.md
index 907d935de9..7c73ad1c50 100644
--- a/doc/contributing/documentation_guide.md
+++ b/doc/contributing/documentation_guide.md
@@ -6,8 +6,8 @@ in the Ruby core and in the Ruby standard library.
## Generating documentation
-Most Ruby documentation lives in the source files and is written in
-[RDoc format](rdoc-ref:RDoc::Markup).
+Most Ruby documentation lives in the source files, and is written in RDoc format
+(described in the [RDoc Markup Reference]).
Some pages live under the `doc` folder and can be written in either
`.rdoc` or `.md` format, determined by the file extension.
@@ -20,9 +20,18 @@ build directory:
make html
```
-Then you can preview your changes by opening
-`{build folder}/.ext/html/index.html` file in your browser.
+Or, to start a live-reloading server that automatically refreshes
+the browser when you edit source files:
+```sh
+make html-server
+```
+
+Then visit http://localhost:4000 in your browser.
+To use a different port: `make html-server RDOC_SERVER_PORT=8080`.
+
+If you don't have a build directory, follow the [quick start
+guide](building_ruby.md#label-Quick+start+guide) up to step 4.
## Goal
@@ -41,16 +50,14 @@ Use your judgment about what the user needs to know.
- Write short declarative or imperative sentences.
- Group sentences into (ideally short) paragraphs,
each covering a single topic.
-- Organize material with [headers](rdoc-ref:RDoc::Markup@Headers).
-- Refer to authoritative and relevant sources using
- [links](rdoc-ref:RDoc::Markup@Links).
+- Organize material with [headings].
+- Refer to authoritative and relevant sources using [links].
- Use simple verb tenses: simple present, simple past, simple future.
- Use simple sentence structure, not compound or complex structure.
- Avoid:
- - Excessive comma-separated phrases;
- consider a [list](rdoc-ref:RDoc::Markup@Simple+Lists).
+ - Excessive comma-separated phrases; consider a [list][lists].
- Idioms and culture-specific references.
- - Overuse of headers.
+ - Overuse of headings.
- Using US-ASCII-incompatible characters in C source files;
see [Characters](#label-Characters) below.
@@ -59,7 +66,7 @@ Use your judgment about what the user needs to know.
Use only US-ASCII-compatible characters in a C source file.
(If you use other characters, the Ruby CI will gently let you know.)
-If want to put ASCII-incompatible characters into the documentation
+If you want to put ASCII-incompatible characters into the documentation
for a C-coded class, module, or method, there are workarounds
involving new files `doc/*.rdoc`:
@@ -72,7 +79,7 @@ involving new files `doc/*.rdoc`:
class Foo; end
```
-- Similarly, for module `Bar` (defined in file `bar.c`,
+- Similarly, for module `Bar` (defined in file `bar.c`),
create file `doc/bar.rdoc`, declare `module Bar; end`,
and place the module documentation above that declaration:
@@ -92,7 +99,7 @@ involving new files `doc/*.rdoc`:
Example:
- ```
+ ```c
/*
* call-seq:
* each_byte {|byte| ... } -> self
@@ -103,16 +110,16 @@ involving new files `doc/*.rdoc`:
*/
```
-### \RDoc
+### RDoc
Ruby is documented using RDoc.
-For information on \RDoc syntax and features, see the
-[RDoc Markup Reference](rdoc-ref:RDoc::Markup@RDoc+Markup+Reference).
+For information on RDoc syntax and features,
+see the [RDoc Markup Reference].
### Output from `irb`
For code examples, consider using interactive Ruby,
-[irb](https://ruby-doc.org/stdlib/libdoc/irb/rdoc/IRB.html).
+[irb].
For a code example that includes `irb` output,
consider aligning `# => ...` in successive lines.
@@ -124,17 +131,22 @@ a.shuffle! #=> [2, 3, 1]
a #=> [2, 3, 1]
```
-### Headers
+### Headings
+
+Organize a long discussion for a class or module with [headings].
-Organize a long discussion with [headers](rdoc-ref:RDoc::Markup@Headers).
+Do not use formal headings in the documentation for a method or constant.
+
+In the rare case where heading-like structures are needed
+within the documentation for a method or constant,
+use [bold text] as pseudo-headings.
### Blank Lines
A blank line begins a new paragraph.
-A [code block](rdoc-ref:RDoc::Markup@Paragraphs+and+Verbatim)
-or [list](rdoc-ref:RDoc::Markup@Simple+Lists)
-should be preceded by and followed by a blank line.
+A [code block][code blocks]
+or [list][lists] should be preceded by and followed by a blank line.
This is unnecessary for the HTML output, but helps in the `ri` output.
### \Method Names
@@ -150,19 +162,170 @@ For a method name in text:
or a hash mark for an instance method:
<tt>Foo.bar</tt>, <tt>Foo#baz</tt>.
+### Embedded Code and Commands
+
+Code or commands embedded in running text (i.e., not in a code block)
+should marked up as
+[monofont].
+
+Code that is a simple string should include the quote marks.
+
### Auto-Linking
-In general, \RDoc's auto-linking should not be suppressed.
-For example, we should write `Array`, not `\Array`.
+Most often, the name of a class, module, or method
+is auto-linked:
+
+```rdoc
+- Float.
+- Enumerable.
+- File.new
+- File#read.
+```
+
+renders as:
+
+> - Float.
+> - Enumerable.
+> - File.new
+> - File#read.
+
+In general, RDoc's auto-linking should not be suppressed.
+For example, we should write just plain _Float_ (which is auto-linked):
+
+```rdoc
+Returns a Float.
+```
+
+which renders as:
+
+> Returns a Float.
+
+However, _do_ suppress auto-linking when the word in question
+does not refer to a Ruby entity (e.g., some uses of _Class_ or _English_):
+
+```rdoc
+Class variables can be tricky.
+```
+
+renders as:
+
+> Class variables can be tricky.
+
+Also, _do_ suppress auto-linking when the word in question
+refers to the current document
+(e.g., _Float_ in the documentation for class Float).
+
+In this case you may consider forcing the name to
+[monofont],
+which suppresses auto-linking, and also emphasizes that the word is a class name:
+
+```rdoc
+A +Float+ object represents ....
+```
+
+renders as:
+
+> A `Float` object represents ....
+
+For a _very_ few, _very_ often-discussed classes,
+you might consider avoiding the capitalized class name altogether.
+For example, for some mentions of arrays,
+you might write simply the lowercase _array_.
+
+Instead of:
+
+```rdoc
+For an empty Array, ....
+```
+
+which renders as:
+
+> For an empty Array, ....
+
+you might write:
+
+```rdoc
+For an empty array, ....
+```
+
+which renders as:
+
+> For an empty array, ....
+
+This more casual usage avoids both auto-linking and distracting font changes,
+and is unlikely to cause confusion.
+
+This principle may be usefully applied, in particular, for:
+
+- An array.
+- An integer.
+- A hash.
+- A string.
+
+However, it should be applied _only_ when referring to an _instance_ of the class,
+and _never_ when referring to the class itself.
+
+### Explicit Links
-We might consider whether to suppress when:
+When writing an explicit link, follow these guidelines.
-- The word in question does not refer to a Ruby entity
- (e.g., some uses of _Class_ or _English_).
-- The reference is to the current class document
- (e.g., _Array_ in the documentation for class `Array`).
-- The same reference is repeated many times
- (e.g., _RDoc_ on this page).
+#### `rdoc-ref` Scheme
+
+Use the `rdoc-ref` scheme for:
+
+- A link in core documentation to other core documentation.
+- A link in core documentation to documentation in a standard library package.
+- A link in a standard library package to other documentation in that same
+ standard library package.
+
+See section "`rdoc-ref` Scheme" in [links].
+
+#### URL-Based Link
+
+Use a full URL-based link for:
+
+- A link in standard library documentation to documentation in the core.
+- A link in standard library documentation to documentation in a different
+ standard library package.
+
+Doing so ensures that the link will be valid even when the package documentation
+is built independently (separately from the core documentation).
+
+The link should lead to a target in https://docs.ruby-lang.org/en/master/.
+
+Also use a full URL-based link for a link to an off-site document.
+
+#### Fragments
+
+In general, a link that includes a [fragment][fragment]
+must cite the exact identifier on the target page;
+otherwise, the browser finds no suitable identifier,
+and does not scroll to the desired part of the page.
+
+However, certain pages on `github.com` and `github.io`
+support "fuzzy" identifier matching, so that URL
+https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rubys-floats-imprecise,
+(whose fragment is `-why-are-rubys-floats-imprecise`)
+scrolls to heading "Why are ruby’s floats imprecise?"
+even though the identifier there actually is the longer
+`#user-content--why-are-rubys-floats-imprecise`.
+
+Ruby documentation should avoid using these shortened fragments, for two reasons:
+
+- The GitHub pages that do this implement it using Javascript;
+ if the user's browser has Javascript disabled
+ (which some employers actually require),
+ the shortened fragment is ineffective and the desired scrolling does not occur.
+- A program that checks links in Ruby documentation will find no suitable identifier,
+ and therefore will report the fragment as not found.
+
+### Variable Names
+
+The name of a variable (as specified in its call-seq) should be marked up as
+[monofont].
+
+Also, use monofont text for the name of a transient variable
+(i.e., one defined and used only in the discussion, such as `n`).
### HTML Tags
@@ -175,16 +338,30 @@ may not render them properly.
In particular, avoid building tables with HTML tags
(<tt><table></tt>, etc.).
-Alternatives are:
+Alternatives:
+
+- A [verbatim text block][verbatim text blocks],
+ using spaces and punctuation to format the text;
+ note that [text markup][text markup] will not be honored:
-- The GFM (GitHub Flavored Markdown) table extension,
- which is enabled by default. See
- {GFM tables extension}[https://github.github.com/gfm/#tables-extension-].
+ - Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/file.c#L6570-L6596].
+ - Corresponding {output}[rdoc-ref:File@ReadWrite+Mode].
-- A {verbatim text block}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks],
- using spaces and punctuation to format the text.
- Note that {text markup}[rdoc-ref:RDoc::MarkupReference@Text+Markup]
- will not be honored.
+- (Markdown format only): A {Github Flavored Markdown (GFM) table}[https://github.github.com/gfm/#tables-extension-],
+ using special formatting for the text:
+
+ - Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/doc/contributing/glossary.md?plain=1].
+ - Corresponding {output}[https://docs.ruby-lang.org/en/master/contributing/glossary_md.html].
+
+### Languages in Examples
+
+For symbols and strings in documentation examples:
+
+- Prefer \English in \English documentation: <tt>'Hello'</tt>.
+- Prefer Japanese in Japanese documentation: <tt>'ã“ã‚“ã«ã¡ã¯'</tt>.
+- If a second language is needed (as, for example, characters with different byte-sizes),
+ prefer Japanese in \English documentation and \English in Japanese documentation.
+- Use other languages examples only as necessary: see String#capitalize.
## Documenting Classes and Modules
@@ -214,19 +391,21 @@ Guidelines:
- The section title is `What's Here`.
- Consider listing the parent class and any included modules; consider
- [links](rdoc-ref:RDoc::Markup@Links)
- to their "What's Here" sections if those exist.
-- List methods as a bullet list:
+ [links] to their "What's Here" sections if those exist.
+- All methods mentioned in the left-pane table of contents
+ should be listed (including any methods extended from another class).
+- Attributes (which are not included in the TOC) may also be listed.
+- Display methods as items in one or more bullet lists:
- Begin each item with the method name, followed by a colon
and a short description.
- If the method has aliases, mention them in parentheses before the colon
(and do not list the aliases separately).
- - Check the rendered documentation to determine whether \RDoc has recognized
+ - Check the rendered documentation to determine whether RDoc has recognized
the method and linked to it; if not, manually insert a
- [link](rdoc-ref:RDoc::Markup@Links).
+ [link][links].
-- If there are numerous entries, consider grouping them into subsections with headers.
+- If there are numerous entries, consider grouping them into subsections with headings.
- If there are more than a few such subsections,
consider adding a table of contents just below the main section title.
@@ -238,6 +417,7 @@ The general structure of the method documentation should be:
- Calling sequence (for methods written in C).
- Synopsis (short description).
+- In-brief examples (optional)
- Details and examples.
- Argument description (if necessary).
- Corner cases and exceptions.
@@ -245,21 +425,21 @@ The general structure of the method documentation should be:
### Calling Sequence (for methods written in C)
-For methods written in Ruby, \RDoc documents the calling sequence automatically.
+For methods written in Ruby, RDoc documents the calling sequence automatically.
-For methods written in C, \RDoc cannot determine what arguments
-the method accepts, so those need to be documented using \RDoc directive
-[`call-seq:`](rdoc-ref:RDoc::Markup@Method+arguments).
+For methods written in C, RDoc cannot determine what arguments
+the method accepts, so those need to be documented using RDoc directive
+[`call-seq:`][call-seq]
For a singleton method, use the form:
-```
+```rdoc
class_name.method_name(method_args) {|block_args| ... } -> return_type
```
Example:
-```
+```rdoc
* call-seq:
* Hash.new(default_value = nil) -> new_hash
* Hash.new {|hash, key| ... } -> new_hash
@@ -268,23 +448,32 @@ Example:
For an instance method, use the form
(omitting any prefix, just as RDoc does for a Ruby-coded method):
-```
+```rdoc
method_name(method_args) {|block_args| ... } -> return_type
```
+
For example, in Array, use:
-```
+```rdoc
* call-seq:
* count -> integer
* count(obj) -> integer
* count {|element| ... } -> integer
```
-```
-* call-seq:
+```rdoc
+* call-seq:
* <=> other -> -1, 0, 1, or nil
```
+For a binary-operator style method (e.g., Array#&),
+cite `self` in the call-seq (not, e.g., `array` or `receiver`):
+
+```rdoc
+* call-seq:
+* self & other_array -> new_array
+```
+
Arguments:
- If the method does not accept arguments, omit the parentheses.
@@ -296,15 +485,17 @@ Arguments:
or an explicit argument, use a `call-seq` with optional arguments.
For example, use:
- ```
- respond_to?(symbol, include_all = false) -> true or false
+ ```rdoc
+ * call-seq:
+ * respond_to?(symbol, include_all = false) -> true or false
```
- If the behavior is different with an omitted or an explicit argument,
use a `call-seq` with separate lines.
For example, in Enumerable, use:
- ```
+ ```rdoc
+ * call-seq:
* max -> element
* max(n) -> array
```
@@ -314,15 +505,23 @@ Block:
- If the method does not accept a block, omit the block.
- If the method accepts a block, the `call-seq` should have `{|args| ... }`,
not `{|args| block }` or `{|args| code }`.
+- If the method accepts a block, but returns an Enumerator when the block is omitted,
+ the `call-seq` should show both forms:
+
+ ```rdoc
+ * call-seq:
+ * array.select {|element| ... } -> new_array
+ * array.select -> new_enumerator
+ ```
Return types:
- If the method can return multiple different types,
separate the types with "or" and, if necessary, commas.
-- If the method can return multiple types, use +object+.
-- If the method returns the receiver, use +self+.
+- If the method can return multiple types, use `object`.
+- If the method returns the receiver, use `self`.
- If the method returns an object of the same class,
- prefix `new_` if an only if the object is not +self+;
+ prefix `new_` if and only if the object is not `self`;
example: `new_array`.
Aliases:
@@ -342,14 +541,22 @@ an entire paragraph.
For `Array#count`, the synopsis is:
-```
-Returns a count of specified elements.
-```
+> Returns a count of specified elements.
This is great as it is short and descriptive. Avoid documenting
too much in the synopsis, stick to the most important information
for the benefit of the reader.
+### In-Brief Examples
+
+For a method whose documentation is lengthy,
+consider adding an "in-brief" passage,
+showing examples that summarize the method's uses.
+
+The passage may answer some users' questions
+(without their having to read long documentation);
+see Array#[] and Array#[]=.
+
### Details and Examples
Most non-trivial methods benefit from examples, as well as details
@@ -372,6 +579,15 @@ do not add an example if it provides the same information given
in the synopsis or details. The purpose of examples is not to prove
what the details are stating.
+Many methods that can take an optional block call the block if it is given,
+but return a new Enumerator if the block is not given;
+in that case, do not provide an example,
+but do state the fact (with the auto-linking uppercase Enumerator):
+
+```rdoc
+* With no block given, returns a new Enumerator.
+```
+
### Argument Description (if necessary)
For methods that require arguments, if not obvious and not explicitly
@@ -388,7 +604,7 @@ argument passed if it is not obvious, not explicitly mentioned in the
details, and not implicitly shown in the examples.
If there is more than one argument or block argument, use a
-[labeled list](rdoc-ref:RDoc::Markup@Labeled+Lists).
+[labeled list][lists].
### Corner Cases and Exceptions
@@ -409,7 +625,7 @@ mention `Hash#fetch` as a related method, and `Hash#merge` might mention
`Hash#merge!` as a related method.
- Consider which methods may be related
- to the current method, and if you think the reader would benefit it,
+ to the current method, and if you think the reader would benefit from it,
at the end of the method documentation, add a line starting with
"Related: " (e.g. "Related: #fetch.").
- Don't list more than three related methods.
@@ -418,7 +634,7 @@ mention `Hash#fetch` as a related method, and `Hash#merge` might mention
- Consider adding:
- A phrase suggesting how the related method is similar to,
- or different from,the current method.
+ or different from, the current method.
See an example at Time#getutc.
- Example code that illustrates the similarities and differences.
See examples at Time#ctime, Time#inspect, Time#to_s.
@@ -428,3 +644,16 @@ mention `Hash#fetch` as a related method, and `Hash#merge` might mention
For methods that accept multiple argument types, in some cases it can
be useful to document the different argument types separately. It's
best to use a separate paragraph for each case you are discussing.
+
+[bold text]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#bold
+[call-seq]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#directive-for-specifying-rdoc-source-format
+[code blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#code-blocks
+[fragment]: https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment
+[headings]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#headings
+[irb]: https://ruby.github.io/irb/index.html
+[links]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#links
+[lists]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#lists
+[monofont]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#monofont
+[RDoc Markup Reference]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html
+[text markup]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#text-markup
+[verbatim text blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#verbatim-text-blocks
diff --git a/doc/dtrace_probes.rdoc b/doc/contributing/dtrace_probes.rdoc
index 1b20597ab4..1b20597ab4 100644
--- a/doc/dtrace_probes.rdoc
+++ b/doc/contributing/dtrace_probes.rdoc
diff --git a/doc/contributing/glossary.md b/doc/contributing/glossary.md
index 952601f813..3ec9796147 100644
--- a/doc/contributing/glossary.md
+++ b/doc/contributing/glossary.md
@@ -4,13 +4,17 @@ Just a list of acronyms I've run across in the Ruby source code and their meanin
| Term | Definition |
| --- | -----------|
-| `bop` | Basic Operator. Relates to methods like `Integer` plus and minus which can be optimized as long as they haven't been redefined.
+| `bmethod` | Method defined by `define_method() {}` (a Block that runs as a Method). |
+| `BIN` | Basic Instruction Name. Used as a macro to reference the YARV instruction. Converts pop into YARVINSN_pop. |
+| `bop` | Basic Operator. Relates to methods like `Integer` plus and minus which can be optimized as long as they haven't been redefined. |
| `cc` | Call Cache. An inline cache structure for the call site. Stored in the `cd` |
| `cd` | Call Data. A data structure that points at the `ci` and the `cc`. `iseq` objects points at the `cd`, and access call information and call caches via this structure |
+| CFG | Control Flow Graph. Representation of the program where all control-flow and data dependencies have been made explicit by unrolling the stack and local variables. |
| `cfp`| Control Frame Pointer. Represents a Ruby stack frame. Calling a method pushes a new frame (cfp), returning pops a frame. Points at the `pc`, `sp`, `ep`, and the corresponding `iseq`|
-| `ci` | Call Information. Refers to an `rb_callinfo` struct. Contains call information about the call site, including number of parameters to be passed, whether it they are keyword arguments or not, etc. Used in conjunction with the `cc` and `cd`. |
-| `cref` | Class reference. A structure pointing to the class reference where `klass_or_self`, visibility scope, and refinements are stored. It also stores a pointer to the next class in the hierachy referenced by `rb_cref_struct * next`. The Class reference is lexically scoped. |
-| CRuby | Implementation of Ruby written in C |
+| `ci` | Call Information. Refers to an `rb_callinfo` struct. Contains call information about the call site, including number of parameters to be passed, whether they are keyword arguments or not, etc. Used in conjunction with the `cc` and `cd`. |
+| `cme` | Callable Method Entry. Refers to the `rb_callable_method_entry_t` struct, the internal representation of a Ruby method that has `defined_class` and `owner` set and is ready for dispatch. |
+| `cref` | Class reference. A structure pointing to the class reference where `klass_or_self`, visibility scope, and refinements are stored. It also stores a pointer to the next class in the hierarchy referenced by `rb_cref_struct * next`. The Class reference is lexically scoped. |
+| CRuby | Reference implementation of Ruby written in C |
| `cvar` | Class Variable. Refers to a Ruby class variable like `@@foo` |
| `dvar` | Dynamic Variable. Used by the parser to refer to local variables that are defined outside of the current lexical scope. For example `def foo; bar = 1; -> { p bar }; end` the "bar" inside the block is a `dvar` |
| `ec` | Execution Context. The top level VM context, points at the current `cfp` |
@@ -24,16 +28,20 @@ Just a list of acronyms I've run across in the Ruby source code and their meanin
| `insns` | Instructions. Usually an array of YARV instructions. |
| `ivar` | Instance Variable. Refers to a Ruby instance variable like `@foo` |
| `imemo` | Internal Memo. A tagged struct whose memory is managed by Ruby's GC, but contains internal information and isn't meant to be exposed to Ruby programs. Contains various information depending on the type. See the `imemo_type` enum for different types. |
+| `IVC` | Instance Variable Cache. Cache specifically for instance variable access |
| JIT | Just In Time compiler |
| `lep` | Local Environment Pointer. An `ep` which is tagged `VM_ENV_FLAG_LOCAL`. Usually this is the `ep` of a method (rather than a block, whose `ep` isn't "local") |
| `local` | Local. Refers to a local variable. |
-| `me` | Method Entry. Refers to an `rb_method_entry_t` struct, the internal representation of a Ruby method.
+| `me` | Method Entry. Refers to an `rb_method_entry_t` struct, the internal representation of a Ruby method. |
| MRI | Matz's Ruby Implementation |
| `pc` | Program Counter. Usually the instruction that will be executed _next_ by the VM. Pointed to by the `cfp` and incremented by the VM |
+| `snt` | Shared Native Thread. OS thread on which many ruby threads can run. Ruby threads from different ractors can even run on the same SNT. Ruby threads can switch SNTs when they context switch. SNTs are used in the M:N threading model. By default, non-main ractors use this model.
+| `dnt` | Dedicated Native Thread. OS thread on which only one ruby thread can run. The ruby thread always runs on that same OS thread. DNTs are used in the 1:1 threading model. By default, the main ractor uses this model.
| `sp` | Stack Pointer. The top of the stack. The VM executes instructions in the `iseq` and instructions will push and pop values on the stack. The VM updates the `sp` on the `cfp` to point at the top of the stack|
+| ST table | ST table is the main C implementation of a hash (smaller Ruby hashes may be backed by AR tables). |
| `svar` | Special Variable. Refers to special local variables like `$~` and `$_`. See the `getspecial` instruction in `insns.def` |
| `VALUE` | VALUE is a pointer to a ruby object from the Ruby C code. |
-| VM | Virtual Machine. In MRI's case YARV (Yet Another Ruby VM)
+| VM | Virtual Machine. In MRI's case YARV (Yet Another Ruby VM)
| WB | Write Barrier. To do with GC write barriers |
| WC | Wild Card. As seen in instructions like `getlocal_WC_0`. It means this instruction takes a "wild card" for the parameter (in this case an index for a local) |
| YARV | Yet Another Ruby VM. The virtual machine that CRuby uses |
diff --git a/doc/contributing/making_changes_to_stdlibs.md b/doc/contributing/making_changes_to_stdlibs.md
index ef3811ea12..2ceb2e6075 100644
--- a/doc/contributing/making_changes_to_stdlibs.md
+++ b/doc/contributing/making_changes_to_stdlibs.md
@@ -4,17 +4,17 @@ Everything in the [lib](https://github.com/ruby/ruby/tree/master/lib) directory
If you'd like to make contributions to standard libraries, do so in the standalone repositories, and the
changes will be automatically mirrored into the Ruby repository.
-For example, CSV lives in [a separate repository](https://github.com/ruby/csv) and is mirrored into [Ruby](https://github.com/ruby/ruby/tree/master/lib/csv).
+For example, ERB lives in [a separate repository](https://github.com/ruby/erb) and is mirrored into [Ruby](https://github.com/ruby/ruby/tree/master/lib/erb).
## Maintainers
-You can find the list of maintainers [here](https://docs.ruby-lang.org/en/master/maintainers_rdoc.html#label-Maintainers).
+You can find the list of maintainers [here](https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Maintainers).
## Build
First, install its dependencies using:
-```
+```shell
bundle install
```
@@ -22,7 +22,7 @@ bundle install
If the library has a `/ext` directory, it has C files that you need to compile with:
-```
+```shell
bundle exec rake compile
```
@@ -32,18 +32,18 @@ All standard libraries use [test-unit](https://github.com/test-unit/test-unit) a
To run all tests:
-```
+```shell
bundle exec rake test
```
To run a single test file:
-```
+```shell
bundle exec rake test TEST="test/test_foo.rb"
```
To run a single test case:
-```
-bundle exec rake test TEST="test/test_foo.rb" TESTOPS="--name=/test_mytest/"
+```shell
+bundle exec rake test TEST="test/test_foo.rb" TESTOPTS="--name=/test_mytest/"
```
diff --git a/doc/memory_view.md b/doc/contributing/memory_view.md
index 0b1369163d..0b1369163d 100644
--- a/doc/memory_view.md
+++ b/doc/contributing/memory_view.md
diff --git a/doc/contributing/reporting_issues.md b/doc/contributing/reporting_issues.md
index 25516ffc6b..a1a2295712 100644
--- a/doc/contributing/reporting_issues.md
+++ b/doc/contributing/reporting_issues.md
@@ -52,19 +52,30 @@ your feature it could help persuade Ruby core.
Here is a template you can use for a feature proposal:
-```
-[Abstract]
- Briefly summarize your feature
-[Background]
- Describe current behavior
-[Proposal]
- Describe your feature in detail
-[Use cases]
- Give specific example uses of your feature
-[Discussion]
- Describe why this feature is necessary and better than using existing features
-[See also]
- Link to other related resources (such as implementations in other languages)
+```markdown
+# Abstract
+
+Briefly summarize your feature
+
+# Background
+
+Describe current behavior
+
+# Proposal
+
+Describe your feature in detail
+
+# Use cases
+
+Give specific example uses of your feature
+
+# Discussion
+
+Describe why this feature is necessary and better than using existing features
+
+# See also
+
+Link to other related resources (such as implementations in other languages)
```
## Backport requests
diff --git a/doc/contributing/testing_ruby.md b/doc/contributing/testing_ruby.md
index 6247686efc..4c7ce7f6a8 100644
--- a/doc/contributing/testing_ruby.md
+++ b/doc/contributing/testing_ruby.md
@@ -1,5 +1,9 @@
# Testing Ruby
+All the commands below assume that you're running them from the `build/` directory made during [Building Ruby](building_ruby.md).
+
+Most commands below should work with [GNU make](https://www.gnu.org/software/make/) (the default on Linux and macOS), [BSD make](https://man.freebsd.org/cgi/man.cgi?make(1)) and [NMAKE](https://learn.microsoft.com/en-us/cpp/build/reference/nmake-reference), except where indicated otherwise.
+
## Test suites
There are several test suites in the Ruby codebase:
@@ -8,131 +12,144 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
1. [bootstraptest/](https://github.com/ruby/ruby/tree/master/bootstraptest)
- This is a small test suite that runs on Miniruby (see [building Ruby](building_ruby.md#label-Miniruby+vs+Ruby)). We can run it with:
+ This is a small test suite that runs on [Miniruby](building_ruby.md#label-Miniruby+vs+Ruby). We can run it with:
- ```
+ ```sh
make btest
```
- To run it with logs, we can use:
+ To run individual bootstrap tests, we can either specify a list of filenames or use the `--sets` flag in the variable `BTESTS`:
- ```
- make btest OPTS=-v
+ ```sh
+ make btest BTESTS="../bootstraptest/test_string.rb ../bootstraptest/test_class.rb"
+ make btest BTESTS="--sets=string,class"
```
- To run individual bootstrap tests, we can either specify a list of filenames or use the `--sets` flag in the variable `BTESTS`:
+ To run these tests with verbose logging, we can add `-v` to the `OPTS`:
- ```
- make btest BTESTS="bootstraptest/test_fork.rb bootstraptest/tes_gc.rb"
- make btest BTESTS="--sets=fork,gc"
+ ```sh
+ make btest OPTS="--sets=string,class -v"
```
If we want to run the bootstrap test suite on Ruby (not Miniruby), we can use:
- ```
+ ```sh
make test
```
- To run it with logs, we can use:
+ To run these tests with verbose logging, we can add `-v` to the `OPTS`:
- ```
+ ```sh
make test OPTS=-v
```
- To run a file or directory with GNU make, we can use:
+ (GNU make only) To run a specific file, we can use:
+ ```sh
+ make ../test/ruby/test_string.rb
```
- make test/ruby/test_foo.rb
- make test/ruby/test_foo.rb TESTOPTS="-n /test_bar/"
+
+ You can use the `-n` test option to run a specific test with a regex:
+
+ ```sh
+ make ../test/ruby/test_string.rb TESTOPTS="-n /test_.*_to_s/"
```
2. [test/](https://github.com/ruby/ruby/tree/master/test)
This is a more comprehensive test suite that runs on Ruby. We can run it with:
- ```
+ ```sh
make test-all
```
- We can run a specific test directory in this suite using the `TESTS` option, for example:
+ We can run a specific test file or directory in this suite using the `TESTS` option, for example:
- ```
- make test-all TESTS=test/rubygems
- ```
-
- We can run a specific test file in this suite by also using the `TESTS` option, for example:
-
- ```
- make test-all TESTS=test/ruby/test_array.rb
+ ```sh
+ make test-all TESTS="../test/ruby/"
+ make test-all TESTS="../test/ruby/test_string.rb"
```
We can run a specific test in this suite using the `TESTS` option, specifying
first the file name, and then the test name, prefixed with `--name`. For example:
- ```
- make test-all TESTS="../test/ruby/test_alias.rb --name=/test_alias_with_zsuper_method/"
+ ```sh
+ make test-all TESTS="../test/ruby/test_string.rb --name=TestString#test_to_s"
```
- To run these specs with logs, we can use:
+ To run these tests with verbose logging, we can add `-v` to `TESTS`:
- ```
+ ```sh
make test-all TESTS=-v
```
- If we would like to run both the `test/` and `bootstraptest/` test suites, we can run
+ We can display the help of the `TESTS` option:
+ ```sh
+ make test-all TESTS=--help
```
+
+ We can run all the tests in `test/`, `bootstraptest/` and `spec/` (the `spec/` is explained in a later section) all together with:
+
+ ```sh
make check
```
3. [spec/ruby](https://github.com/ruby/ruby/tree/master/spec/ruby)
- This is a test suite that exists in [the Ruby spec repository](https://github.com/ruby/spec) and is mirrored into the `spec/ruby` directory in the Ruby repository. It tests the behavior of the Ruby programming language. We can run this using:
+ This is a test suite defined in [the Ruby spec repository](https://github.com/ruby/spec), and is periodically mirrored into the `spec/ruby` directory of this repository. It tests the behavior of the Ruby programming language. We can run this using:
- ```
+ ```sh
make test-spec
```
- To run a specific directory, we can use `MSPECOPT` to specify the directory:
+ We can run a specific test file or directory in this suite using the `SPECOPTS` option, for example:
- ```
- make test-spec MSPECOPT=spec/ruby/core/array
- ```
-
- To run a specific file, we can also use `MSPECOPT` to specify the file:
-
- ```
- make test-spec MSPECOPT=spec/ruby/core/array/any_spec.rb
+ ```sh
+ make test-spec SPECOPTS="../spec/ruby/core/string/"
+ make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb"
```
To run a specific test, we can use the `--example` flag to match against the test name:
- ```
- make test-spec MSPECOPT="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'"
+ ```sh
+ make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb --example='returns self when self.class == String'"
```
- To run these specs with logs, we can use:
+ To run these specs with verbose logging, we can add `-v` to the `SPECOPTS`:
- ```
- make test-spec MSPECOPT=-Vfs
+ ```sh
+ make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb -Vfs"
```
- To run a ruby-spec file or directory with GNU make, we can use
+ (GNU make only) To run a ruby-spec file or directory, we can use
- ```
- make spec/ruby/core/foo/bar_spec.rb
+ ```sh
+ make ../spec/ruby/core/string/to_s_spec.rb
```
4. [spec/bundler](https://github.com/ruby/ruby/tree/master/spec/bundler)
- The bundler test suite exists in [the RubyGems repository](https://github.com/rubygems/rubygems/tree/master/bundler/spec) and is mirrored into the `spec/bundler` directory in the Ruby repository. We can run this using:
+ The bundler test suite is defined in [the RubyGems repository](https://github.com/rubygems/rubygems/tree/master/bundler/spec), and is periodically mirrored into the `spec/ruby` directory of this repository. We can run this using:
- ```
+ ```sh
make test-bundler
```
To run a specific bundler spec file, we can use `BUNDLER_SPECS` as follows:
+ ```sh
+ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb
```
- $ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb
- ```
+
+## Troubleshooting
+
+### Running test suites on s390x CPU Architecture
+
+If we see failing tests related to the zlib library on s390x CPU architecture, we can run the test suites with `DFLTCC=0` to pass:
+
+```sh
+DFLTCC=0 make check
+```
+
+The failures can happen with the zlib library applying the patch [madler/zlib#410](https://github.com/madler/zlib/pull/410) to enable the deflate algorithm producing a different compressed byte stream. We manage this issue at [[ruby-core:114942][Bug #19909]](https://bugs.ruby-lang.org/issues/19909).
diff --git a/doc/contributing/vm_stack_and_frames.md b/doc/contributing/vm_stack_and_frames.md
new file mode 100644
index 0000000000..c7dc59db16
--- /dev/null
+++ b/doc/contributing/vm_stack_and_frames.md
@@ -0,0 +1,163 @@
+# Ruby VM Stack and Frame Layout
+
+This document explains the Ruby VM stack architecture, including how the value
+stack (SP) and control frames (CFP) share a single contiguous memory region,
+and how individual frames are structured.
+
+## VM Stack Architecture
+
+The Ruby VM uses a single contiguous stack (`ec->vm_stack`) with two different
+regions growing toward each other. Understanding this requires distinguishing
+the overall architecture (how CFPs and values share one stack) from individual
+frame internals (how values are organized for one single frame).
+
+```text
+High addresses (ec->vm_stack + ec->vm_stack_size)
+ ↓
+ [CFP region starts here] ↠RUBY_VM_END_CONTROL_FRAME(ec)
+ [CFP - 1] New frame pushed here (grows downward)
+ [CFP - 2] Another frame
+ ...
+
+ (Unused space - stack overflow when they meet)
+
+ ... Value stack grows UP toward higher addresses
+ [SP + n] Values pushed here
+ [ec->cfp->sp] Current executing frame's stack pointer
+ ↑
+Low addresses (ec->vm_stack)
+```
+
+The "unused space" represents free space available for new frames and values. When this gap closes (CFP meets SP), stack overflow occurs.
+
+### Stack Growth Directions
+
+**Control Frames (CFP):**
+
+- Start at `ec->vm_stack + ec->vm_stack_size` (high addresses)
+- Grow **downward** toward lower addresses as frames are pushed
+- Each new frame is allocated at `cfp - 1` (lower address)
+- The `rb_control_frame_t` structure itself moves downward
+
+**Value Stack (SP):**
+
+- Starts at `ec->vm_stack` (low addresses)
+- Grows **upward** toward higher addresses as values are pushed
+- Each frame's `cfp->sp` points to the top of its value stack
+
+### Stack Overflow
+
+When recursive calls push too many frames, CFP grows downward until it collides
+with SP growing upward. The VM detects this with `CHECK_VM_STACK_OVERFLOW0`,
+which computes `const rb_control_frame_struct *bound = (void *)&sp[margin];`
+and raises if `cfp <= &bound[1]`.
+
+## Understanding Individual Frame Value Stacks
+
+Each frame has its own portion of the overall VM stack, called its "VM value stack"
+or simply "value stack". This space is pre-allocated when the frame is created,
+with size determined by:
+
+- `local_size` - space for local variables
+- `stack_max` - maximum depth for temporary values during execution
+
+The frame's value stack grows upward from its base (where self/arguments/locals
+live) toward `cfp->sp` (the current top of temporary values).
+
+## Visualizing How Frames Fit in the VM Stack
+
+The left side shows the overall VM stack with CFP metadata separated from frame
+values. The right side zooms into one frame's value region, revealing its internal
+structure.
+
+```text
+Overall VM Stack (ec->vm_stack): Zooming into Frame 2's value stack:
+
+High addr (vm_stack + vm_stack_size) High addr (cfp->sp)
+ ↓ ┌
+ [CFP 1 metadata] │ [Temporaries]
+ [CFP 2 metadata] ─────────┠│ [Env: Flags/Block/CME] ↠cfp->ep
+ [CFP 3 metadata] │ │ [Locals]
+ ──────────────── │ ┌─┤ [Arguments]
+ (unused space) │ │ │ [self]
+ ──────────────── │ │ └
+ [Frame 3 values] │ │ Low addr (frame base)
+ [Frame 2 values] <────────┴───────┘
+ [Frame 1 values]
+ ↑
+Low addr (vm_stack)
+```
+
+## Examining a Single Frame's Value Stack
+
+Now let's walk through a concrete Ruby program to see how a single frame's
+value stack is structured internally:
+
+```ruby
+def foo(x, y)
+ z = x.casecmp(y)
+end
+
+foo(:one, :two)
+```
+
+First, after arguments are evaluated and right before the `send` to `foo`:
+
+```text
+ ┌────────────â”
+ putself │ :two │
+ putobject :one 0x2 ├────────────┤
+ putobject :two │ :one │
+► send <:foo, argc:2> 0x1 ├────────────┤
+ leave │ self │
+ 0x0 └────────────┘
+```
+
+The `put*` instructions have pushed 3 items onto the stack. It's now time to
+add a new control frame for `foo`. The following is the shape of the stack
+after one instruction in `foo`:
+
+```text
+ cfp->sp=0x8 at this point.
+ 0x8 ┌────────────â”◄──Stack space for temporaries
+ │ :one │ live above the environment.
+ 0x7 ├────────────┤
+ getlocal x@0 │ < flags > │ foo's rb_control_frame_t
+► getlocal y@1 0x6 ├────────────┤◄──has cfp->ep=0x6
+ send <:casecmp, argc:1> │ <no block> │
+ dup 0x5 ├────────────┤ The flags, block, and CME triple
+ setlocal z@2 │ <CME: foo> │ (VM_ENV_DATA_SIZE) form an
+ leave 0x4 ├────────────┤ environment. They can be used to
+ │ z (nil) │ figure out what local variables
+ 0x3 ├────────────┤ are below them.
+ │ :two │
+ 0x2 ├────────────┤ Notice how the arguments, now
+ │ :one │ locals, never moved. This layout
+ 0x1 ├────────────┤ allows for argument transfer
+ │ self │ without copying.
+ 0x0 └────────────┘
+```
+
+Given that locals have lower address than `cfp->ep`, it makes sense then that
+`getlocal` in `insns.def` has `val = *(vm_get_ep(GET_EP(), level) - idx);`.
+When accessing variables in the immediate scope, where `level=0`, it's
+essentially `val = cfp->ep[-idx];`.
+
+Note that this EP-relative index has a different basis than the index that comes
+after "@" in disassembly listings. The "@" index is relative to the 0th local
+(`x` in this case).
+
+### Q&A
+
+Q: It seems that the receiver is always at an offset relative to EP,
+ like locals. Couldn't we use EP to access it instead of using `cfp->self`?
+
+A: Not all calls put the `self` in the callee on the stack. Two
+ examples are `Proc#call`, where the receiver is the Proc object, but `self`
+ inside the callee is `Proc#receiver`, and `yield`, where the receiver isn't
+ pushed onto the stack before the arguments.
+
+Q: Why have `cfp->ep` when it seems that everything is below `cfp->sp`?
+
+A: In the example, `cfp->ep` points to the stack, but it can also point to the
+ GC heap. Blocks can capture and evacuate their environment to the heap.
diff --git a/doc/csv/arguments/io.rdoc b/doc/csv/arguments/io.rdoc
deleted file mode 100644
index f5fe1d1975..0000000000
--- a/doc/csv/arguments/io.rdoc
+++ /dev/null
@@ -1,5 +0,0 @@
-* Argument +io+ should be an IO object that is:
- * Open for reading; on return, the IO object will be closed.
- * Positioned at the beginning.
- To position at the end, for appending, use method CSV.generate.
- For any other positioning, pass a preset \StringIO object instead.
diff --git a/doc/csv/options/common/col_sep.rdoc b/doc/csv/options/common/col_sep.rdoc
deleted file mode 100644
index 05769b5773..0000000000
--- a/doc/csv/options/common/col_sep.rdoc
+++ /dev/null
@@ -1,63 +0,0 @@
-====== Option +col_sep+
-
-Specifies the \String field separator to be used
-for both parsing and generating.
-The \String will be transcoded into the data's \Encoding before use.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:col_sep) # => "," (comma)
-
-Using the default (comma):
- str = CSV.generate do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0\nbar,1\nbaz,2\n"
- ary = CSV.parse(str)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using +:+ (colon):
- col_sep = ':'
- str = CSV.generate(col_sep: col_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo:0\nbar:1\nbaz:2\n"
- ary = CSV.parse(str, col_sep: col_sep)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using +::+ (two colons):
- col_sep = '::'
- str = CSV.generate(col_sep: col_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo::0\nbar::1\nbaz::2\n"
- ary = CSV.parse(str, col_sep: col_sep)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using <tt>''</tt> (empty string):
- col_sep = ''
- str = CSV.generate(col_sep: col_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo0\nbar1\nbaz2\n"
-
----
-
-Raises an exception if parsing with the empty \String:
- col_sep = ''
- # Raises ArgumentError (:col_sep must be 1 or more characters: "")
- CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep)
-
-Raises an exception if the given value is not String-convertible:
- col_sep = BasicObject.new
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.generate(line, col_sep: col_sep)
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.parse(str, col_sep: col_sep)
diff --git a/doc/csv/options/common/quote_char.rdoc b/doc/csv/options/common/quote_char.rdoc
deleted file mode 100644
index 67fd3af68b..0000000000
--- a/doc/csv/options/common/quote_char.rdoc
+++ /dev/null
@@ -1,42 +0,0 @@
-====== Option +quote_char+
-
-Specifies the character (\String of length 1) used used to quote fields
-in both parsing and generating.
-This String will be transcoded into the data's \Encoding before use.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:quote_char) # => "\"" (double quote)
-
-This is useful for an application that incorrectly uses <tt>'</tt> (single-quote)
-to quote fields, instead of the correct <tt>"</tt> (double-quote).
-
-Using the default (double quote):
- str = CSV.generate do |csv|
- csv << ['foo', 0]
- csv << ["'bar'", 1]
- csv << ['"baz"', 2]
- end
- str # => "foo,0\n'bar',1\n\"\"\"baz\"\"\",2\n"
- ary = CSV.parse(str)
- ary # => [["foo", "0"], ["'bar'", "1"], ["\"baz\"", "2"]]
-
-Using <tt>'</tt> (single-quote):
- quote_char = "'"
- str = CSV.generate(quote_char: quote_char) do |csv|
- csv << ['foo', 0]
- csv << ["'bar'", 1]
- csv << ['"baz"', 2]
- end
- str # => "foo,0\n'''bar''',1\n\"baz\",2\n"
- ary = CSV.parse(str, quote_char: quote_char)
- ary # => [["foo", "0"], ["'bar'", "1"], ["\"baz\"", "2"]]
-
----
-
-Raises an exception if the \String length is greater than 1:
- # Raises ArgumentError (:quote_char has to be nil or a single character String)
- CSV.new('', quote_char: 'xx')
-
-Raises an exception if the value is not a \String:
- # Raises ArgumentError (:quote_char has to be nil or a single character String)
- CSV.new('', quote_char: :foo)
diff --git a/doc/csv/options/common/row_sep.rdoc b/doc/csv/options/common/row_sep.rdoc
deleted file mode 100644
index 872d9d1f3f..0000000000
--- a/doc/csv/options/common/row_sep.rdoc
+++ /dev/null
@@ -1,100 +0,0 @@
-====== Option +row_sep+
-
-Specifies the row separator, a \String or the \Symbol <tt>:auto</tt> (see below),
-to be used for both parsing and generating.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:row_sep) # => :auto
-
----
-
-When +row_sep+ is a \String, that \String becomes the row separator.
-The String will be transcoded into the data's Encoding before use.
-
-Using <tt>"\n"</tt>:
- row_sep = "\n"
- str = CSV.generate(row_sep: row_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0\nbar,1\nbaz,2\n"
- ary = CSV.parse(str)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using <tt>|</tt> (pipe):
- row_sep = '|'
- str = CSV.generate(row_sep: row_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0|bar,1|baz,2|"
- ary = CSV.parse(str, row_sep: row_sep)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using <tt>--</tt> (two hyphens):
- row_sep = '--'
- str = CSV.generate(row_sep: row_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0--bar,1--baz,2--"
- ary = CSV.parse(str, row_sep: row_sep)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using <tt>''</tt> (empty string):
- row_sep = ''
- str = CSV.generate(row_sep: row_sep) do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0bar,1baz,2"
- ary = CSV.parse(str, row_sep: row_sep)
- ary # => [["foo", "0bar", "1baz", "2"]]
-
----
-
-When +row_sep+ is the \Symbol +:auto+ (the default),
-generating uses <tt>"\n"</tt> as the row separator:
- str = CSV.generate do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0\nbar,1\nbaz,2\n"
-
-Parsing, on the other hand, invokes auto-discovery of the row separator.
-
-Auto-discovery reads ahead in the data looking for the next <tt>\r\n</tt>, +\n+, or +\r+ sequence.
-The sequence will be selected even if it occurs in a quoted field,
-assuming that you would have the same line endings there.
-
-Example:
- str = CSV.generate do |csv|
- csv << [:foo, 0]
- csv << [:bar, 1]
- csv << [:baz, 2]
- end
- str # => "foo,0\nbar,1\nbaz,2\n"
- ary = CSV.parse(str)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-The default <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>) is used
-if any of the following is true:
-* None of those sequences is found.
-* Data is +ARGF+, +STDIN+, +STDOUT+, or +STDERR+.
-* The stream is only available for output.
-
-Obviously, discovery takes a little time. Set manually if speed is important. Also note that IO objects should be opened in binary mode on Windows if this feature will be used as the line-ending translation can cause problems with resetting the document position to where it was before the read ahead.
-
----
-
-Raises an exception if the given value is not String-convertible:
- row_sep = BasicObject.new
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.generate(ary, row_sep: row_sep)
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.parse(str, row_sep: row_sep)
diff --git a/doc/csv/options/generating/force_quotes.rdoc b/doc/csv/options/generating/force_quotes.rdoc
deleted file mode 100644
index 11afd1a16c..0000000000
--- a/doc/csv/options/generating/force_quotes.rdoc
+++ /dev/null
@@ -1,17 +0,0 @@
-====== Option +force_quotes+
-
-Specifies the boolean that determines whether each output field is to be double-quoted.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:force_quotes) # => false
-
-For examples in this section:
- ary = ['foo', 0, nil]
-
-Using the default, +false+:
- str = CSV.generate_line(ary)
- str # => "foo,0,\n"
-
-Using +true+:
- str = CSV.generate_line(ary, force_quotes: true)
- str # => "\"foo\",\"0\",\"\"\n"
diff --git a/doc/csv/options/generating/quote_empty.rdoc b/doc/csv/options/generating/quote_empty.rdoc
deleted file mode 100644
index 4c5645c662..0000000000
--- a/doc/csv/options/generating/quote_empty.rdoc
+++ /dev/null
@@ -1,12 +0,0 @@
-====== Option +quote_empty+
-
-Specifies the boolean that determines whether an empty value is to be double-quoted.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:quote_empty) # => true
-
-With the default +true+:
- CSV.generate_line(['"', ""]) # => "\"\"\"\",\"\"\n"
-
-With +false+:
- CSV.generate_line(['"', ""], quote_empty: false) # => "\"\"\"\",\n"
diff --git a/doc/csv/options/generating/write_converters.rdoc b/doc/csv/options/generating/write_converters.rdoc
deleted file mode 100644
index 6e5fae5fda..0000000000
--- a/doc/csv/options/generating/write_converters.rdoc
+++ /dev/null
@@ -1,33 +0,0 @@
-====== Option +write_converters+
-
-Specifies converters to be used in generating fields.
-See {Write Converters}[#class-CSV-label-Write+Converters]
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:write_converters) # => nil
-
-With no write converter:
- str = CSV.generate_line(["\na\n", "\tb\t", " c "])
- str # => "\"\na\n\",\tb\t, c \n"
-
-With a write converter:
- strip_converter = proc {|field| field.strip }
- str = CSV.generate_line(["\na\n", "\tb\t", " c "], write_converters: strip_converter)
- str # => "a,b,c\n"
-
-With two write converters (called in order):
- upcase_converter = proc {|field| field.upcase }
- downcase_converter = proc {|field| field.downcase }
- write_converters = [upcase_converter, downcase_converter]
- str = CSV.generate_line(['a', 'b', 'c'], write_converters: write_converters)
- str # => "a,b,c\n"
-
-See also {Write Converters}[#class-CSV-label-Write+Converters]
-
----
-
-Raises an exception if the converter returns a value that is neither +nil+
-nor \String-convertible:
- bad_converter = proc {|field| BasicObject.new }
- # Raises NoMethodError (undefined method `is_a?' for #<BasicObject:>)
- CSV.generate_line(['a', 'b', 'c'], write_converters: bad_converter) \ No newline at end of file
diff --git a/doc/csv/options/generating/write_empty_value.rdoc b/doc/csv/options/generating/write_empty_value.rdoc
deleted file mode 100644
index 67be5662cb..0000000000
--- a/doc/csv/options/generating/write_empty_value.rdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-====== Option +write_empty_value+
-
-Specifies the object that is to be substituted for each field
-that has an empty \String.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:write_empty_value) # => ""
-
-Without the option:
- str = CSV.generate_line(['a', '', 'c', ''])
- str # => "a,\"\",c,\"\"\n"
-
-With the option:
- str = CSV.generate_line(['a', '', 'c', ''], write_empty_value: "x")
- str # => "a,x,c,x\n"
diff --git a/doc/csv/options/generating/write_headers.rdoc b/doc/csv/options/generating/write_headers.rdoc
deleted file mode 100644
index f9faa9d438..0000000000
--- a/doc/csv/options/generating/write_headers.rdoc
+++ /dev/null
@@ -1,29 +0,0 @@
-====== Option +write_headers+
-
-Specifies the boolean that determines whether a header row is included in the output;
-ignored if there are no headers.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:write_headers) # => nil
-
-Without +write_headers+:
- file_path = 't.csv'
- CSV.open(file_path,'w',
- :headers => ['Name','Value']
- ) do |csv|
- csv << ['foo', '0']
- end
- CSV.open(file_path) do |csv|
- csv.shift
- end # => ["foo", "0"]
-
-With +write_headers+":
- CSV.open(file_path,'w',
- :write_headers=> true,
- :headers => ['Name','Value']
- ) do |csv|
- csv << ['foo', '0']
- end
- CSV.open(file_path) do |csv|
- csv.shift
- end # => ["Name", "Value"]
diff --git a/doc/csv/options/generating/write_nil_value.rdoc b/doc/csv/options/generating/write_nil_value.rdoc
deleted file mode 100644
index 65d33ff54e..0000000000
--- a/doc/csv/options/generating/write_nil_value.rdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-====== Option +write_nil_value+
-
-Specifies the object that is to be substituted for each +nil+-valued field.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:write_nil_value) # => nil
-
-Without the option:
- str = CSV.generate_line(['a', nil, 'c', nil])
- str # => "a,,c,\n"
-
-With the option:
- str = CSV.generate_line(['a', nil, 'c', nil], write_nil_value: "x")
- str # => "a,x,c,x\n"
diff --git a/doc/csv/options/parsing/converters.rdoc b/doc/csv/options/parsing/converters.rdoc
deleted file mode 100644
index 211fa48de6..0000000000
--- a/doc/csv/options/parsing/converters.rdoc
+++ /dev/null
@@ -1,46 +0,0 @@
-====== Option +converters+
-
-Specifies converters to be used in parsing fields.
-See {Field Converters}[#class-CSV-label-Field+Converters]
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:converters) # => nil
-
-The value may be a field converter name
-(see {Stored Converters}[#class-CSV-label-Stored+Converters]):
- str = '1,2,3'
- # Without a converter
- array = CSV.parse_line(str)
- array # => ["1", "2", "3"]
- # With built-in converter :integer
- array = CSV.parse_line(str, converters: :integer)
- array # => [1, 2, 3]
-
-The value may be a converter list
-(see {Converter Lists}[#class-CSV-label-Converter+Lists]):
- str = '1,3.14159'
- # Without converters
- array = CSV.parse_line(str)
- array # => ["1", "3.14159"]
- # With built-in converters
- array = CSV.parse_line(str, converters: [:integer, :float])
- array # => [1, 3.14159]
-
-The value may be a \Proc custom converter:
-(see {Custom Field Converters}[#class-CSV-label-Custom+Field+Converters]):
- str = ' foo , bar , baz '
- # Without a converter
- array = CSV.parse_line(str)
- array # => [" foo ", " bar ", " baz "]
- # With a custom converter
- array = CSV.parse_line(str, converters: proc {|field| field.strip })
- array # => ["foo", "bar", "baz"]
-
-See also {Custom Field Converters}[#class-CSV-label-Custom+Field+Converters]
-
----
-
-Raises an exception if the converter is not a converter name or a \Proc:
- str = 'foo,0'
- # Raises NoMethodError (undefined method `arity' for nil:NilClass)
- CSV.parse(str, converters: :foo)
diff --git a/doc/csv/options/parsing/empty_value.rdoc b/doc/csv/options/parsing/empty_value.rdoc
deleted file mode 100644
index 7d3bcc078c..0000000000
--- a/doc/csv/options/parsing/empty_value.rdoc
+++ /dev/null
@@ -1,13 +0,0 @@
-====== Option +empty_value+
-
-Specifies the object that is to be substituted
-for each field that has an empty \String.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:empty_value) # => "" (empty string)
-
-With the default, <tt>""</tt>:
- CSV.parse_line('a,"",b,"",c') # => ["a", "", "b", "", "c"]
-
-With a different object:
- CSV.parse_line('a,"",b,"",c', empty_value: 'x') # => ["a", "x", "b", "x", "c"]
diff --git a/doc/csv/options/parsing/field_size_limit.rdoc b/doc/csv/options/parsing/field_size_limit.rdoc
deleted file mode 100644
index 797c5776fc..0000000000
--- a/doc/csv/options/parsing/field_size_limit.rdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-====== Option +field_size_limit+
-
-Specifies the \Integer field size limit.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:field_size_limit) # => nil
-
-This is a maximum size CSV will read ahead looking for the closing quote for a field.
-(In truth, it reads to the first line ending beyond this size.)
-If a quote cannot be found within the limit CSV will raise a MalformedCSVError,
-assuming the data is faulty.
-You can use this limit to prevent what are effectively DoS attacks on the parser.
-However, this limit can cause a legitimate parse to fail;
-therefore the default value is +nil+ (no limit).
-
-For the examples in this section:
- str = <<~EOT
- "a","b"
- "
- 2345
- ",""
- EOT
- str # => "\"a\",\"b\"\n\"\n2345\n\",\"\"\n"
-
-Using the default +nil+:
- ary = CSV.parse(str)
- ary # => [["a", "b"], ["\n2345\n", ""]]
-
-Using <tt>50</tt>:
- field_size_limit = 50
- ary = CSV.parse(str, field_size_limit: field_size_limit)
- ary # => [["a", "b"], ["\n2345\n", ""]]
-
----
-
-Raises an exception if a field is too long:
- big_str = "123456789\n" * 1024
- # Raises CSV::MalformedCSVError (Field size exceeded in line 1.)
- CSV.parse('valid,fields,"' + big_str + '"', field_size_limit: 2048)
diff --git a/doc/csv/options/parsing/header_converters.rdoc b/doc/csv/options/parsing/header_converters.rdoc
deleted file mode 100644
index 309180805f..0000000000
--- a/doc/csv/options/parsing/header_converters.rdoc
+++ /dev/null
@@ -1,43 +0,0 @@
-====== Option +header_converters+
-
-Specifies converters to be used in parsing headers.
-See {Header Converters}[#class-CSV-label-Header+Converters]
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:header_converters) # => nil
-
-Identical in functionality to option {converters}[#class-CSV-label-Option+converters]
-except that:
-- The converters apply only to the header row.
-- The built-in header converters are +:downcase+ and +:symbol+.
-
-This section assumes prior execution of:
- str = <<-EOT
- Name,Value
- foo,0
- bar,1
- baz,2
- EOT
- # With no header converter
- table = CSV.parse(str, headers: true)
- table.headers # => ["Name", "Value"]
-
-The value may be a header converter name
-(see {Stored Converters}[#class-CSV-label-Stored+Converters]):
- table = CSV.parse(str, headers: true, header_converters: :downcase)
- table.headers # => ["name", "value"]
-
-The value may be a converter list
-(see {Converter Lists}[#class-CSV-label-Converter+Lists]):
- header_converters = [:downcase, :symbol]
- table = CSV.parse(str, headers: true, header_converters: header_converters)
- table.headers # => [:name, :value]
-
-The value may be a \Proc custom converter
-(see {Custom Header Converters}[#class-CSV-label-Custom+Header+Converters]):
- upcase_converter = proc {|field| field.upcase }
- table = CSV.parse(str, headers: true, header_converters: upcase_converter)
- table.headers # => ["NAME", "VALUE"]
-
-See also {Custom Header Converters}[#class-CSV-label-Custom+Header+Converters]
-
diff --git a/doc/csv/options/parsing/headers.rdoc b/doc/csv/options/parsing/headers.rdoc
deleted file mode 100644
index 0ea151f24b..0000000000
--- a/doc/csv/options/parsing/headers.rdoc
+++ /dev/null
@@ -1,63 +0,0 @@
-====== Option +headers+
-
-Specifies a boolean, \Symbol, \Array, or \String to be used
-to define column headers.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:headers) # => false
-
----
-
-Without +headers+:
- str = <<-EOT
- Name,Count
- foo,0
- bar,1
- bax,2
- EOT
- csv = CSV.new(str)
- csv # => #<CSV io_type:StringIO encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- csv.headers # => nil
- csv.shift # => ["Name", "Count"]
-
----
-
-If set to +true+ or the \Symbol +:first_row+,
-the first row of the data is treated as a row of headers:
- str = <<-EOT
- Name,Count
- foo,0
- bar,1
- bax,2
- EOT
- csv = CSV.new(str, headers: true)
- csv # => #<CSV io_type:StringIO encoding:UTF-8 lineno:2 col_sep:"," row_sep:"\n" quote_char:"\"" headers:["Name", "Count"]>
- csv.headers # => ["Name", "Count"]
- csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
-
----
-
-If set to an \Array, the \Array elements are treated as headers:
- str = <<-EOT
- foo,0
- bar,1
- bax,2
- EOT
- csv = CSV.new(str, headers: ['Name', 'Count'])
- csv
- csv.headers # => ["Name", "Count"]
- csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
-
----
-
-If set to a \String +str+, method <tt>CSV::parse_line(str, options)</tt> is called
-with the current +options+, and the returned \Array is treated as headers:
- str = <<-EOT
- foo,0
- bar,1
- bax,2
- EOT
- csv = CSV.new(str, headers: 'Name,Count')
- csv
- csv.headers # => ["Name", "Count"]
- csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
diff --git a/doc/csv/options/parsing/liberal_parsing.rdoc b/doc/csv/options/parsing/liberal_parsing.rdoc
deleted file mode 100644
index b8b9b00c98..0000000000
--- a/doc/csv/options/parsing/liberal_parsing.rdoc
+++ /dev/null
@@ -1,19 +0,0 @@
-====== Option +liberal_parsing+
-
-Specifies the boolean value that determines whether
-CSV will attempt to parse input not conformant with RFC 4180,
-such as double quotes in unquoted fields.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:liberal_parsing) # => false
-
-For examples in this section:
- str = 'is,this "three, or four",fields'
-
-Without +liberal_parsing+:
- # Raises CSV::MalformedCSVError (Illegal quoting in str 1.)
- CSV.parse_line(str)
-
-With +liberal_parsing+:
- ary = CSV.parse_line(str, liberal_parsing: true)
- ary # => ["is", "this \"three", " or four\"", "fields"]
diff --git a/doc/csv/options/parsing/nil_value.rdoc b/doc/csv/options/parsing/nil_value.rdoc
deleted file mode 100644
index 412e8795e8..0000000000
--- a/doc/csv/options/parsing/nil_value.rdoc
+++ /dev/null
@@ -1,12 +0,0 @@
-====== Option +nil_value+
-
-Specifies the object that is to be substituted for each null (no-text) field.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:nil_value) # => nil
-
-With the default, +nil+:
- CSV.parse_line('a,,b,,c') # => ["a", nil, "b", nil, "c"]
-
-With a different object:
- CSV.parse_line('a,,b,,c', nil_value: 0) # => ["a", 0, "b", 0, "c"]
diff --git a/doc/csv/options/parsing/return_headers.rdoc b/doc/csv/options/parsing/return_headers.rdoc
deleted file mode 100644
index 45d2e3f3de..0000000000
--- a/doc/csv/options/parsing/return_headers.rdoc
+++ /dev/null
@@ -1,22 +0,0 @@
-====== Option +return_headers+
-
-Specifies the boolean that determines whether method #shift
-returns or ignores the header row.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:return_headers) # => false
-
-Examples:
- str = <<-EOT
- Name,Count
- foo,0
- bar,1
- bax,2
- EOT
- # Without return_headers first row is str.
- csv = CSV.new(str, headers: true)
- csv.shift # => #<CSV::Row "Name":"foo" "Count":"0">
- # With return_headers first row is headers.
- csv = CSV.new(str, headers: true, return_headers: true)
- csv.shift # => #<CSV::Row "Name":"Name" "Count":"Count">
-
diff --git a/doc/csv/options/parsing/skip_blanks.rdoc b/doc/csv/options/parsing/skip_blanks.rdoc
deleted file mode 100644
index 2c8f7b7bb8..0000000000
--- a/doc/csv/options/parsing/skip_blanks.rdoc
+++ /dev/null
@@ -1,31 +0,0 @@
-====== Option +skip_blanks+
-
-Specifies a boolean that determines whether blank lines in the input will be ignored;
-a line that contains a column separator is not considered to be blank.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:skip_blanks) # => false
-
-See also option {skiplines}[#class-CSV-label-Option+skip_lines].
-
-For examples in this section:
- str = <<-EOT
- foo,0
-
- bar,1
- baz,2
-
- ,
- EOT
-
-Using the default, +false+:
- ary = CSV.parse(str)
- ary # => [["foo", "0"], [], ["bar", "1"], ["baz", "2"], [], [nil, nil]]
-
-Using +true+:
- ary = CSV.parse(str, skip_blanks: true)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"], [nil, nil]]
-
-Using a truthy value:
- ary = CSV.parse(str, skip_blanks: :foo)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"], [nil, nil]]
diff --git a/doc/csv/options/parsing/skip_lines.rdoc b/doc/csv/options/parsing/skip_lines.rdoc
deleted file mode 100644
index 1481c40a5f..0000000000
--- a/doc/csv/options/parsing/skip_lines.rdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-====== Option +skip_lines+
-
-Specifies an object to use in identifying comment lines in the input that are to be ignored:
-* If a \Regexp, ignores lines that match it.
-* If a \String, converts it to a \Regexp, ignores lines that match it.
-* If +nil+, no lines are considered to be comments.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:skip_lines) # => nil
-
-For examples in this section:
- str = <<-EOT
- # Comment
- foo,0
- bar,1
- baz,2
- # Another comment
- EOT
- str # => "# Comment\nfoo,0\nbar,1\nbaz,2\n# Another comment\n"
-
-Using the default, +nil+:
- ary = CSV.parse(str)
- ary # => [["# Comment"], ["foo", "0"], ["bar", "1"], ["baz", "2"], ["# Another comment"]]
-
-Using a \Regexp:
- ary = CSV.parse(str, skip_lines: /^#/)
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Using a \String:
- ary = CSV.parse(str, skip_lines: '#')
- ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
----
-
-Raises an exception if given an object that is not a \Regexp, a \String, or +nil+:
- # Raises ArgumentError (:skip_lines has to respond to #match: 0)
- CSV.parse(str, skip_lines: 0)
diff --git a/doc/csv/options/parsing/strip.rdoc b/doc/csv/options/parsing/strip.rdoc
deleted file mode 100644
index 56ae4310c3..0000000000
--- a/doc/csv/options/parsing/strip.rdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-====== Option +strip+
-
-Specifies the boolean value that determines whether
-whitespace is stripped from each input field.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:strip) # => false
-
-With default value +false+:
- ary = CSV.parse_line(' a , b ')
- ary # => [" a ", " b "]
-
-With value +true+:
- ary = CSV.parse_line(' a , b ', strip: true)
- ary # => ["a", "b"]
diff --git a/doc/csv/options/parsing/unconverted_fields.rdoc b/doc/csv/options/parsing/unconverted_fields.rdoc
deleted file mode 100644
index 3e7f839d49..0000000000
--- a/doc/csv/options/parsing/unconverted_fields.rdoc
+++ /dev/null
@@ -1,27 +0,0 @@
-====== Option +unconverted_fields+
-
-Specifies the boolean that determines whether unconverted field values are to be available.
-
-Default value:
- CSV::DEFAULT_OPTIONS.fetch(:unconverted_fields) # => nil
-
-The unconverted field values are those found in the source data,
-prior to any conversions performed via option +converters+.
-
-When option +unconverted_fields+ is +true+,
-each returned row (\Array or \CSV::Row) has an added method,
-+unconverted_fields+, that returns the unconverted field values:
- str = <<-EOT
- foo,0
- bar,1
- baz,2
- EOT
- # Without unconverted_fields
- csv = CSV.parse(str, converters: :integer)
- csv # => [["foo", 0], ["bar", 1], ["baz", 2]]
- csv.first.respond_to?(:unconverted_fields) # => false
- # With unconverted_fields
- csv = CSV.parse(str, converters: :integer, unconverted_fields: true)
- csv # => [["foo", 0], ["bar", 1], ["baz", 2]]
- csv.first.respond_to?(:unconverted_fields) # => true
- csv.first.unconverted_fields # => ["foo", "0"]
diff --git a/doc/csv/recipes/filtering.rdoc b/doc/csv/recipes/filtering.rdoc
deleted file mode 100644
index 470649d09a..0000000000
--- a/doc/csv/recipes/filtering.rdoc
+++ /dev/null
@@ -1,156 +0,0 @@
-== Recipes for Filtering \CSV
-
-For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
-
-All code snippets on this page assume that the following has been executed:
- require 'csv'
-
-=== Contents
-
-- {Source and Output Formats}[#label-Source+and+Output+Formats]
- - {Filtering String to String}[#label-Filtering+String+to+String]
- - {Recipe: Filter String to String with Headers}[#label-Recipe-3A+Filter+String+to+String+with+Headers]
- - {Recipe: Filter String to String Without Headers}[#label-Recipe-3A+Filter+String+to+String+Without+Headers]
- - {Filtering String to IO Stream}[#label-Filtering+String+to+IO+Stream]
- - {Recipe: Filter String to IO Stream with Headers}[#label-Recipe-3A+Filter+String+to+IO+Stream+with+Headers]
- - {Recipe: Filter String to IO Stream Without Headers}[#label-Recipe-3A+Filter+String+to+IO+Stream+Without+Headers]
- - {Filtering IO Stream to String}[#label-Filtering+IO+Stream+to+String]
- - {Recipe: Filter IO Stream to String with Headers}[#label-Recipe-3A+Filter+IO+Stream+to+String+with+Headers]
- - {Recipe: Filter IO Stream to String Without Headers}[#label-Recipe-3A+Filter+IO+Stream+to+String+Without+Headers]
- - {Filtering IO Stream to IO Stream}[#label-Filtering+IO+Stream+to+IO+Stream]
- - {Recipe: Filter IO Stream to IO Stream with Headers}[#label-Recipe-3A+Filter+IO+Stream+to+IO+Stream+with+Headers]
- - {Recipe: Filter IO Stream to IO Stream Without Headers}[#label-Recipe-3A+Filter+IO+Stream+to+IO+Stream+Without+Headers]
-
-=== Source and Output Formats
-
-You can use a Unix-style "filter" for \CSV data.
-The filter reads source \CSV data and writes output \CSV data as modified by the filter.
-The input and output \CSV data may be any mixture of \Strings and \IO streams.
-
-==== Filtering \String to \String
-
-You can filter one \String to another, with or without headers.
-
-===== Recipe: Filter \String to \String with Headers
-
-Use class method CSV.filter with option +headers+ to filter a \String to another \String:
- in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- out_string = ''
- CSV.filter(in_string, out_string, headers: true) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- out_string # => "Name,Value\nFOO,0000\nBAR,1111\nBAZ,2222\n"
-
-===== Recipe: Filter \String to \String Without Headers
-
-Use class method CSV.filter without option +headers+ to filter a \String to another \String:
- in_string = "foo,0\nbar,1\nbaz,2\n"
- out_string = ''
- CSV.filter(in_string, out_string) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- out_string # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
-
-==== Filtering \String to \IO Stream
-
-You can filter a \String to an \IO stream, with or without headers.
-
-===== Recipe: Filter \String to \IO Stream with Headers
-
-Use class method CSV.filter with option +headers+ to filter a \String to an \IO stream:
- in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.open(path, 'w') do |out_io|
- CSV.filter(in_string, out_io, headers: true) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- p File.read(path) # => "Name,Value\nFOO,0000\nBAR,1111\nBAZ,2222\n"
-
-===== Recipe: Filter \String to \IO Stream Without Headers
-
-Use class method CSV.filter without option +headers+ to filter a \String to an \IO stream:
- in_string = "foo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.open(path, 'w') do |out_io|
- CSV.filter(in_string, out_io) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- p File.read(path) # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
-
-==== Filtering \IO Stream to \String
-
-You can filter an \IO stream to a \String, with or without headers.
-
-===== Recipe: Filter \IO Stream to \String with Headers
-
-Use class method CSV.filter with option +headers+ to filter an \IO stream to a \String:
- in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, in_string)
- out_string = ''
- File.open(path, headers: true) do |in_io|
- CSV.filter(in_io, out_string, headers: true) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- out_string # => "Name,Value\nFOO,0000\nBAR,1111\nBAZ,2222\n"
-
-===== Recipe: Filter \IO Stream to \String Without Headers
-
-Use class method CSV.filter without option +headers+ to filter an \IO stream to a \String:
- in_string = "foo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, in_string)
- out_string = ''
- File.open(path) do |in_io|
- CSV.filter(in_io, out_string) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- out_string # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
-
-==== Filtering \IO Stream to \IO Stream
-
-You can filter an \IO stream to another \IO stream, with or without headers.
-
-===== Recipe: Filter \IO Stream to \IO Stream with Headers
-
-Use class method CSV.filter with option +headers+ to filter an \IO stream to another \IO stream:
- in_path = 't.csv'
- in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- File.write(in_path, in_string)
- out_path = 'u.csv'
- File.open(in_path) do |in_io|
- File.open(out_path, 'w') do |out_io|
- CSV.filter(in_io, out_io, headers: true) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- end
- p File.read(out_path) # => "Name,Value\nFOO,0000\nBAR,1111\nBAZ,2222\n"
-
-===== Recipe: Filter \IO Stream to \IO Stream Without Headers
-
-Use class method CSV.filter without option +headers+ to filter an \IO stream to another \IO stream:
- in_path = 't.csv'
- in_string = "foo,0\nbar,1\nbaz,2\n"
- File.write(in_path, in_string)
- out_path = 'u.csv'
- File.open(in_path) do |in_io|
- File.open(out_path, 'w') do |out_io|
- CSV.filter(in_io, out_io) do |row|
- row[0] = row[0].upcase
- row[1] *= 4
- end
- end
- end
- p File.read(out_path) # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
diff --git a/doc/csv/recipes/generating.rdoc b/doc/csv/recipes/generating.rdoc
deleted file mode 100644
index 3ef6df99b4..0000000000
--- a/doc/csv/recipes/generating.rdoc
+++ /dev/null
@@ -1,244 +0,0 @@
-== Recipes for Generating \CSV
-
-For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
-
-All code snippets on this page assume that the following has been executed:
- require 'csv'
-
-=== Contents
-
-- {Output Formats}[#label-Output+Formats]
- - {Generating to a String}[#label-Generating+to+a+String]
- - {Recipe: Generate to String with Headers}[#label-Recipe-3A+Generate+to+String+with+Headers]
- - {Recipe: Generate to String Without Headers}[#label-Recipe-3A+Generate+to+String+Without+Headers]
- - {Generating to a File}[#label-Generating+to+a+File]
- - {Recipe: Generate to File with Headers}[#label-Recipe-3A+Generate+to+File+with+Headers]
- - {Recipe: Generate to File Without Headers}[#label-Recipe-3A+Generate+to+File+Without+Headers]
- - {Generating to IO an Stream}[#label-Generating+to+an+IO+Stream]
- - {Recipe: Generate to IO Stream with Headers}[#label-Recipe-3A+Generate+to+IO+Stream+with+Headers]
- - {Recipe: Generate to IO Stream Without Headers}[#label-Recipe-3A+Generate+to+IO+Stream+Without+Headers]
-- {Converting Fields}[#label-Converting+Fields]
- - {Recipe: Filter Generated Field Strings}[#label-Recipe-3A+Filter+Generated+Field+Strings]
- - {Recipe: Specify Multiple Write Converters}[#label-Recipe-3A+Specify+Multiple+Write+Converters]
-- {RFC 4180 Compliance}[#label-RFC+4180+Compliance]
- - {Row Separator}[#label-Row+Separator]
- - {Recipe: Generate Compliant Row Separator}[#label-Recipe-3A+Generate+Compliant+Row+Separator]
- - {Recipe: Generate Non-Compliant Row Separator}[#label-Recipe-3A+Generate+Non-Compliant+Row+Separator]
- - {Column Separator}[#label-Column+Separator]
- - {Recipe: Generate Compliant Column Separator}[#label-Recipe-3A+Generate+Compliant+Column+Separator]
- - {Recipe: Generate Non-Compliant Column Separator}[#label-Recipe-3A+Generate+Non-Compliant+Column+Separator]
- - {Quote Character}[#label-Quote+Character]
- - {Recipe: Generate Compliant Quote Character}[#label-Recipe-3A+Generate+Compliant+Quote+Character]
- - {Recipe: Generate Non-Compliant Quote Character}[#label-Recipe-3A+Generate+Non-Compliant+Quote+Character]
-
-=== Output Formats
-
-You can generate \CSV output to a \String, to a \File (via its path), or to an \IO stream.
-
-==== Generating to a \String
-
-You can generate \CSV output to a \String, with or without headers.
-
-===== Recipe: Generate to \String with Headers
-
-Use class method CSV.generate with option +headers+ to generate to a \String.
-
-This example uses method CSV#<< to append the rows
-that are to be generated:
- output_string = CSV.generate('', headers: ['Name', 'Value'], write_headers: true) do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Name,Value\nFoo,0\nBar,1\nBaz,2\n"
-
-===== Recipe: Generate to \String Without Headers
-
-Use class method CSV.generate without option +headers+ to generate to a \String.
-
-This example uses method CSV#<< to append the rows
-that are to be generated:
- output_string = CSV.generate do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Foo,0\nBar,1\nBaz,2\n"
-
-==== Generating to a \File
-
-You can generate /CSV data to a \File, with or without headers.
-
-===== Recipe: Generate to \File with Headers
-
-Use class method CSV.open with option +headers+ generate to a \File.
-
-This example uses method CSV#<< to append the rows
-that are to be generated:
- path = 't.csv'
- CSV.open(path, 'w', headers: ['Name', 'Value'], write_headers: true) do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- p File.read(path) # => "Name,Value\nFoo,0\nBar,1\nBaz,2\n"
-
-===== Recipe: Generate to \File Without Headers
-
-Use class method CSV.open without option +headers+ to generate to a \File.
-
-This example uses method CSV#<< to append the rows
-that are to be generated:
- path = 't.csv'
- CSV.open(path, 'w') do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- p File.read(path) # => "Foo,0\nBar,1\nBaz,2\n"
-
-==== Generating to an \IO Stream
-
-You can generate \CSV data to an \IO stream, with or without headers.
-
-==== Recipe: Generate to \IO Stream with Headers
-
-Use class method CSV.new with option +headers+ to generate \CSV data to an \IO stream:
- path = 't.csv'
- File.open(path, 'w') do |file|
- csv = CSV.new(file, headers: ['Name', 'Value'], write_headers: true)
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- p File.read(path) # => "Name,Value\nFoo,0\nBar,1\nBaz,2\n"
-
-===== Recipe: Generate to \IO Stream Without Headers
-
-Use class method CSV.new without option +headers+ to generate \CSV data to an \IO stream:
- path = 't.csv'
- File.open(path, 'w') do |file|
- csv = CSV.new(file)
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- p File.read(path) # => "Foo,0\nBar,1\nBaz,2\n"
-
-=== Converting Fields
-
-You can use _write_ _converters_ to convert fields when generating \CSV.
-
-==== Recipe: Filter Generated Field Strings
-
-Use option <tt>:write_converters</tt> and a custom converter to convert field values when generating \CSV.
-
-This example defines and uses a custom write converter to strip whitespace from generated fields:
- strip_converter = proc {|field| field.respond_to?(:strip) ? field.strip : field }
- output_string = CSV.generate(write_converters: strip_converter) do |csv|
- csv << [' foo ', 0]
- csv << [' bar ', 1]
- csv << [' baz ', 2]
- end
- output_string # => "foo,0\nbar,1\nbaz,2\n"
-
-==== Recipe: Specify Multiple Write Converters
-
-Use option <tt>:write_converters</tt> and multiple custom coverters
-to convert field values when generating \CSV.
-
-This example defines and uses two custom write converters to strip and upcase generated fields:
- strip_converter = proc {|field| field.respond_to?(:strip) ? field.strip : field }
- upcase_converter = proc {|field| field.respond_to?(:upcase) ? field.upcase : field }
- converters = [strip_converter, upcase_converter]
- output_string = CSV.generate(write_converters: converters) do |csv|
- csv << [' foo ', 0]
- csv << [' bar ', 1]
- csv << [' baz ', 2]
- end
- output_string # => "FOO,0\nBAR,1\nBAZ,2\n"
-
-=== RFC 4180 Compliance
-
-By default, \CSV generates data that is compliant with
-{RFC 4180}[https://tools.ietf.org/html/rfc4180]
-with respect to:
-- Column separator.
-- Quote character.
-
-==== Row Separator
-
-RFC 4180 specifies the row separator CRLF (Ruby <tt>"\r\n"</tt>).
-
-===== Recipe: Generate Compliant Row Separator
-
-For strict compliance, use option +:row_sep+ to specify row separator <tt>"\r\n"</tt>:
- output_string = CSV.generate('', row_sep: "\r\n") do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Foo,0\r\nBar,1\r\nBaz,2\r\n"
-
-===== Recipe: Generate Non-Compliant Row Separator
-
-For data with non-compliant row separators, use option +:row_sep+ with a different value:
-This example source uses semicolon (<tt>";'</tt>) as its row separator:
- output_string = CSV.generate('', row_sep: ";") do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Foo,0;Bar,1;Baz,2;"
-
-==== Column Separator
-
-RFC 4180 specifies column separator COMMA (Ruby <tt>","</tt>).
-
-===== Recipe: Generate Compliant Column Separator
-
-Because the \CSV default comma separator is <tt>","</tt>,
-you need not specify option +:col_sep+ for compliant data:
- output_string = CSV.generate('') do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Foo,0\nBar,1\nBaz,2\n"
-
-===== Recipe: Generate Non-Compliant Column Separator
-
-For data with non-compliant column separators, use option +:col_sep+.
-This example source uses TAB (<tt>"\t"</tt>) as its column separator:
- output_string = CSV.generate('', col_sep: "\t") do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "Foo\t0\nBar\t1\nBaz\t2\n"
-
-==== Quote Character
-
-RFC 4180 specifies quote character DQUOTE (Ruby <tt>"\""</tt>).
-
-===== Recipe: Generate Compliant Quote Character
-
-Because the \CSV default quote character is <tt>"\""</tt>,
-you need not specify option +:quote_char+ for compliant data:
- output_string = CSV.generate('', force_quotes: true) do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "\"Foo\",\"0\"\n\"Bar\",\"1\"\n\"Baz\",\"2\"\n"
-
-===== Recipe: Generate Non-Compliant Quote Character
-
-For data with non-compliant quote characters, use option +:quote_char+.
-This example source uses SQUOTE (<tt>"'"</tt>) as its quote character:
- output_string = CSV.generate('', quote_char: "'", force_quotes: true) do |csv|
- csv << ['Foo', 0]
- csv << ['Bar', 1]
- csv << ['Baz', 2]
- end
- output_string # => "'Foo','0'\n'Bar','1'\n'Baz','2'\n"
diff --git a/doc/csv/recipes/parsing.rdoc b/doc/csv/recipes/parsing.rdoc
deleted file mode 100644
index 7ac96a934b..0000000000
--- a/doc/csv/recipes/parsing.rdoc
+++ /dev/null
@@ -1,543 +0,0 @@
-== Recipes for Parsing \CSV
-
-For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
-
-All code snippets on this page assume that the following has been executed:
- require 'csv'
-
-=== Contents
-
-- {Source Formats}[#label-Source+Formats]
- - {Parsing from a String}[#label-Parsing+from+a+String]
- - {Recipe: Parse from String with Headers}[#label-Recipe-3A+Parse+from+String+with+Headers]
- - {Recipe: Parse from String Without Headers}[#label-Recipe-3A+Parse+from+String+Without+Headers]
- - {Parsing from a File}[#label-Parsing+from+a+File]
- - {Recipe: Parse from File with Headers}[#label-Recipe-3A+Parse+from+File+with+Headers]
- - {Recipe: Parse from File Without Headers}[#label-Recipe-3A+Parse+from+File+Without+Headers]
- - {Parsing from an IO Stream}[#label-Parsing+from+an+IO+Stream]
- - {Recipe: Parse from IO Stream with Headers}[#label-Recipe-3A+Parse+from+IO+Stream+with+Headers]
- - {Recipe: Parse from IO Stream Without Headers}[#label-Recipe-3A+Parse+from+IO+Stream+Without+Headers]
-- {RFC 4180 Compliance}[#label-RFC+4180+Compliance]
- - {Row Separator}[#label-Row+Separator]
- - {Recipe: Handle Compliant Row Separator}[#label-Recipe-3A+Handle+Compliant+Row+Separator]
- - {Recipe: Handle Non-Compliant Row Separator}[#label-Recipe-3A+Handle+Non-Compliant+Row+Separator]
- - {Column Separator}[#label-Column+Separator]
- - {Recipe: Handle Compliant Column Separator}[#label-Recipe-3A+Handle+Compliant+Column+Separator]
- - {Recipe: Handle Non-Compliant Column Separator}[#label-Recipe-3A+Handle+Non-Compliant+Column+Separator]
- - {Quote Character}[#label-Quote+Character]
- - {Recipe: Handle Compliant Quote Character}[#label-Recipe-3A+Handle+Compliant+Quote+Character]
- - {Recipe: Handle Non-Compliant Quote Character}[#label-Recipe-3A+Handle+Non-Compliant+Quote+Character]
- - {Recipe: Allow Liberal Parsing}[#label-Recipe-3A+Allow+Liberal+Parsing]
-- {Special Handling}[#label-Special+Handling]
- - {Special Line Handling}[#label-Special+Line+Handling]
- - {Recipe: Ignore Blank Lines}[#label-Recipe-3A+Ignore+Blank+Lines]
- - {Recipe: Ignore Selected Lines}[#label-Recipe-3A+Ignore+Selected+Lines]
- - {Special Field Handling}[#label-Special+Field+Handling]
- - {Recipe: Strip Fields}[#label-Recipe-3A+Strip+Fields]
- - {Recipe: Handle Null Fields}[#label-Recipe-3A+Handle+Null+Fields]
- - {Recipe: Handle Empty Fields}[#label-Recipe-3A+Handle+Empty+Fields]
-- {Converting Fields}[#label-Converting+Fields]
- - {Converting Fields to Objects}[#label-Converting+Fields+to+Objects]
- - {Recipe: Convert Fields to Integers}[#label-Recipe-3A+Convert+Fields+to+Integers]
- - {Recipe: Convert Fields to Floats}[#label-Recipe-3A+Convert+Fields+to+Floats]
- - {Recipe: Convert Fields to Numerics}[#label-Recipe-3A+Convert+Fields+to+Numerics]
- - {Recipe: Convert Fields to Dates}[#label-Recipe-3A+Convert+Fields+to+Dates]
- - {Recipe: Convert Fields to DateTimes}[#label-Recipe-3A+Convert+Fields+to+DateTimes]
- - {Recipe: Convert Assorted Fields to Objects}[#label-Recipe-3A+Convert+Assorted+Fields+to+Objects]
- - {Recipe: Convert Fields to Other Objects}[#label-Recipe-3A+Convert+Fields+to+Other+Objects]
- - {Recipe: Filter Field Strings}[#label-Recipe-3A+Filter+Field+Strings]
- - {Recipe: Register Field Converters}[#label-Recipe-3A+Register+Field+Converters]
- - {Using Multiple Field Converters}[#label-Using+Multiple+Field+Converters]
- - {Recipe: Specify Multiple Field Converters in Option :converters}[#label-Recipe-3A+Specify+Multiple+Field+Converters+in+Option+-3Aconverters]
- - {Recipe: Specify Multiple Field Converters in a Custom Converter List}[#label-Recipe-3A+Specify+Multiple+Field+Converters+in+a+Custom+Converter+List]
-- {Converting Headers}[#label-Converting+Headers]
- - {Recipe: Convert Headers to Lowercase}[#label-Recipe-3A+Convert+Headers+to+Lowercase]
- - {Recipe: Convert Headers to Symbols}[#label-Recipe-3A+Convert+Headers+to+Symbols]
- - {Recipe: Filter Header Strings}[#label-Recipe-3A+Filter+Header+Strings]
- - {Recipe: Register Header Converters}[#label-Recipe-3A+Register+Header+Converters]
- - {Using Multiple Header Converters}[#label-Using+Multiple+Header+Converters]
- - {Recipe: Specify Multiple Header Converters in Option :header_converters}[#label-Recipe-3A+Specify+Multiple+Header+Converters+in+Option+-3Aheader_converters]
- - {Recipe: Specify Multiple Header Converters in a Custom Header Converter List}[#label-Recipe-3A+Specify+Multiple+Header+Converters+in+a+Custom+Header+Converter+List]
-- {Diagnostics}[#label-Diagnostics]
- - {Recipe: Capture Unconverted Fields}[#label-Recipe-3A+Capture+Unconverted+Fields]
- - {Recipe: Capture Field Info}[#label-Recipe-3A+Capture+Field+Info]
-
-=== Source Formats
-
-You can parse \CSV data from a \String, from a \File (via its path), or from an \IO stream.
-
-==== Parsing from a \String
-
-You can parse \CSV data from a \String, with or without headers.
-
-===== Recipe: Parse from \String with Headers
-
-Use class method CSV.parse with option +headers+ to read a source \String all at once
-(may have memory resource implications):
- string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- CSV.parse(string, headers: true) # => #<CSV::Table mode:col_or_row row_count:4>
-
-Use instance method CSV#each with option +headers+ to read a source \String one row at a time:
- CSV.new(string, headers: true).each do |row|
- p row
- end
-Output:
- #<CSV::Row "Name":"foo" "Value":"0">
- #<CSV::Row "Name":"bar" "Value":"1">
- #<CSV::Row "Name":"baz" "Value":"2">
-
-===== Recipe: Parse from \String Without Headers
-
-Use class method CSV.parse without option +headers+ to read a source \String all at once
-(may have memory resource implications):
- string = "foo,0\nbar,1\nbaz,2\n"
- CSV.parse(string) # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Use instance method CSV#each without option +headers+ to read a source \String one row at a time:
- CSV.new(string).each do |row|
- p row
- end
-Output:
- ["foo", "0"]
- ["bar", "1"]
- ["baz", "2"]
-
-==== Parsing from a \File
-
-You can parse \CSV data from a \File, with or without headers.
-
-===== Recipe: Parse from \File with Headers
-
-Use instance method CSV#read with option +headers+ to read a file all at once:
- string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, string)
- CSV.read(path, headers: true) # => #<CSV::Table mode:col_or_row row_count:4>
-
-Use class method CSV.foreach with option +headers+ to read one row at a time:
- CSV.foreach(path, headers: true) do |row|
- p row
- end
-Output:
- #<CSV::Row "Name":"foo" "Value":"0">
- #<CSV::Row "Name":"bar" "Value":"1">
- #<CSV::Row "Name":"baz" "Value":"2">
-
-===== Recipe: Parse from \File Without Headers
-
-Use class method CSV.read without option +headers+ to read a file all at once:
- string = "foo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, string)
- CSV.read(path) # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Use class method CSV.foreach without option +headers+ to read one row at a time:
- CSV.foreach(path) do |row|
- p row
- end
-Output:
- ["foo", "0"]
- ["bar", "1"]
- ["baz", "2"]
-
-==== Parsing from an \IO Stream
-
-You can parse \CSV data from an \IO stream, with or without headers.
-
-===== Recipe: Parse from \IO Stream with Headers
-
-Use class method CSV.parse with option +headers+ to read an \IO stream all at once:
- string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, string)
- File.open(path) do |file|
- CSV.parse(file, headers: true)
- end # => #<CSV::Table mode:col_or_row row_count:4>
-
-Use class method CSV.foreach with option +headers+ to read one row at a time:
- File.open(path) do |file|
- CSV.foreach(file, headers: true) do |row|
- p row
- end
- end
-Output:
- #<CSV::Row "Name":"foo" "Value":"0">
- #<CSV::Row "Name":"bar" "Value":"1">
- #<CSV::Row "Name":"baz" "Value":"2">
-
-===== Recipe: Parse from \IO Stream Without Headers
-
-Use class method CSV.parse without option +headers+ to read an \IO stream all at once:
- string = "foo,0\nbar,1\nbaz,2\n"
- path = 't.csv'
- File.write(path, string)
- File.open(path) do |file|
- CSV.parse(file)
- end # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-Use class method CSV.foreach without option +headers+ to read one row at a time:
- File.open(path) do |file|
- CSV.foreach(file) do |row|
- p row
- end
- end
-Output:
- ["foo", "0"]
- ["bar", "1"]
- ["baz", "2"]
-
-=== RFC 4180 Compliance
-
-By default, \CSV parses data that is compliant with
-{RFC 4180}[https://tools.ietf.org/html/rfc4180]
-with respect to:
-- Row separator.
-- Column separator.
-- Quote character.
-
-==== Row Separator
-
-RFC 4180 specifies the row separator CRLF (Ruby <tt>"\r\n"</tt>).
-
-Although the \CSV default row separator is <tt>"\n"</tt>,
-the parser also by default handles row separator <tt>"\r"</tt> and the RFC-compliant <tt>"\r\n"</tt>.
-
-===== Recipe: Handle Compliant Row Separator
-
-For strict compliance, use option +:row_sep+ to specify row separator <tt>"\r\n"</tt>,
-which allows the compliant row separator:
- source = "foo,1\r\nbar,1\r\nbaz,2\r\n"
- CSV.parse(source, row_sep: "\r\n") # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-But rejects other row separators:
- source = "foo,1\nbar,1\nbaz,2\n"
- CSV.parse(source, row_sep: "\r\n") # Raised MalformedCSVError
- source = "foo,1\rbar,1\rbaz,2\r"
- CSV.parse(source, row_sep: "\r\n") # Raised MalformedCSVError
- source = "foo,1\n\rbar,1\n\rbaz,2\n\r"
- CSV.parse(source, row_sep: "\r\n") # Raised MalformedCSVError
-
-===== Recipe: Handle Non-Compliant Row Separator
-
-For data with non-compliant row separators, use option +:row_sep+.
-This example source uses semicolon (<tt>";"</tt>) as its row separator:
- source = "foo,1;bar,1;baz,2;"
- CSV.parse(source, row_sep: ';') # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-
-==== Column Separator
-
-RFC 4180 specifies column separator COMMA (Ruby <tt>","</tt>).
-
-===== Recipe: Handle Compliant Column Separator
-
-Because the \CSV default comma separator is ',',
-you need not specify option +:col_sep+ for compliant data:
- source = "foo,1\nbar,1\nbaz,2\n"
- CSV.parse(source) # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-
-===== Recipe: Handle Non-Compliant Column Separator
-
-For data with non-compliant column separators, use option +:col_sep+.
-This example source uses TAB (<tt>"\t"</tt>) as its column separator:
- source = "foo,1\tbar,1\tbaz,2"
- CSV.parse(source, col_sep: "\t") # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-
-==== Quote Character
-
-RFC 4180 specifies quote character DQUOTE (Ruby <tt>"\""</tt>).
-
-===== Recipe: Handle Compliant Quote Character
-
-Because the \CSV default quote character is <tt>"\""</tt>,
-you need not specify option +:quote_char+ for compliant data:
- source = "\"foo\",\"1\"\n\"bar\",\"1\"\n\"baz\",\"2\"\n"
- CSV.parse(source) # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-
-===== Recipe: Handle Non-Compliant Quote Character
-
-For data with non-compliant quote characters, use option +:quote_char+.
-This example source uses SQUOTE (<tt>"'"</tt>) as its quote character:
- source = "'foo','1'\n'bar','1'\n'baz','2'\n"
- CSV.parse(source, quote_char: "'") # => [["foo", "1"], ["bar", "1"], ["baz", "2"]]
-
-==== Recipe: Allow Liberal Parsing
-
-Use option +:liberal_parsing+ to specify that \CSV should
-attempt to parse input not conformant with RFC 4180, such as double quotes in unquoted fields:
- source = 'is,this "three, or four",fields'
- CSV.parse(source) # Raises MalformedCSVError
- CSV.parse(source, liberal_parsing: true) # => [["is", "this \"three", " or four\"", "fields"]]
-
-=== Special Handling
-
-You can use parsing options to specify special handling for certain lines and fields.
-
-==== Special Line Handling
-
-Use parsing options to specify special handling for blank lines, or for other selected lines.
-
-===== Recipe: Ignore Blank Lines
-
-Use option +:skip_blanks+ to ignore blank lines:
- source = <<-EOT
- foo,0
-
- bar,1
- baz,2
-
- ,
- EOT
- parsed = CSV.parse(source, skip_blanks: true)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"], [nil, nil]]
-
-===== Recipe: Ignore Selected Lines
-
-Use option +:skip_lines+ to ignore selected lines.
- source = <<-EOT
- # Comment
- foo,0
- bar,1
- baz,2
- # Another comment
- EOT
- parsed = CSV.parse(source, skip_lines: /^#/)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-
-==== Special Field Handling
-
-Use parsing options to specify special handling for certain field values.
-
-===== Recipe: Strip Fields
-
-Use option +:strip+ to strip parsed field values:
- CSV.parse_line(' a , b ', strip: true) # => ["a", "b"]
-
-===== Recipe: Handle Null Fields
-
-Use option +:nil_value+ to specify a value that will replace each field
-that is null (no text):
- CSV.parse_line('a,,b,,c', nil_value: 0) # => ["a", 0, "b", 0, "c"]
-
-===== Recipe: Handle Empty Fields
-
-Use option +:empty_value+ to specify a value that will replace each field
-that is empty (\String of length 0);
- CSV.parse_line('a,"",b,"",c', empty_value: 'x') # => ["a", "x", "b", "x", "c"]
-
-=== Converting Fields
-
-You can use field converters to change parsed \String fields into other objects,
-or to otherwise modify the \String fields.
-
-==== Converting Fields to Objects
-
-Use field converters to change parsed \String objects into other, more specific, objects.
-
-There are built-in field converters for converting to objects of certain classes:
-- \Float
-- \Integer
-- \Date
-- \DateTime
-
-Other built-in field converters include:
-- +:numeric+: converts to \Integer and \Float.
-- +:all+: converts to \DateTime, \Integer, \Float.
-
-You can also define field converters to convert to objects of other classes.
-
-===== Recipe: Convert Fields to Integers
-
-Convert fields to \Integer objects using built-in converter +:integer+:
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, converters: :integer)
- parsed.map {|row| row['Value'].class} # => [Integer, Integer, Integer]
-
-===== Recipe: Convert Fields to Floats
-
-Convert fields to \Float objects using built-in converter +:float+:
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, converters: :float)
- parsed.map {|row| row['Value'].class} # => [Float, Float, Float]
-
-===== Recipe: Convert Fields to Numerics
-
-Convert fields to \Integer and \Float objects using built-in converter +:numeric+:
- source = "Name,Value\nfoo,0\nbar,1.1\nbaz,2.2\n"
- parsed = CSV.parse(source, headers: true, converters: :numeric)
- parsed.map {|row| row['Value'].class} # => [Integer, Float, Float]
-
-===== Recipe: Convert Fields to Dates
-
-Convert fields to \Date objects using built-in converter +:date+:
- source = "Name,Date\nfoo,2001-02-03\nbar,2001-02-04\nbaz,2001-02-03\n"
- parsed = CSV.parse(source, headers: true, converters: :date)
- parsed.map {|row| row['Date'].class} # => [Date, Date, Date]
-
-===== Recipe: Convert Fields to DateTimes
-
-Convert fields to \DateTime objects using built-in converter +:date_time+:
- source = "Name,DateTime\nfoo,2001-02-03\nbar,2001-02-04\nbaz,2020-05-07T14:59:00-05:00\n"
- parsed = CSV.parse(source, headers: true, converters: :date_time)
- parsed.map {|row| row['DateTime'].class} # => [DateTime, DateTime, DateTime]
-
-===== Recipe: Convert Assorted Fields to Objects
-
-Convert assorted fields to objects using built-in converter +:all+:
- source = "Type,Value\nInteger,0\nFloat,1.0\nDateTime,2001-02-04\n"
- parsed = CSV.parse(source, headers: true, converters: :all)
- parsed.map {|row| row['Value'].class} # => [Integer, Float, DateTime]
-
-===== Recipe: Convert Fields to Other Objects
-
-Define a custom field converter to convert \String fields into other objects.
-This example defines and uses a custom field converter
-that converts each column-1 value to a \Rational object:
- rational_converter = proc do |field, field_context|
- field_context.index == 1 ? field.to_r : field
- end
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, converters: rational_converter)
- parsed.map {|row| row['Value'].class} # => [Rational, Rational, Rational]
-
-==== Recipe: Filter Field Strings
-
-Define a custom field converter to modify \String fields.
-This example defines and uses a custom field converter
-that strips whitespace from each field value:
- strip_converter = proc {|field| field.strip }
- source = "Name,Value\n foo , 0 \n bar , 1 \n baz , 2 \n"
- parsed = CSV.parse(source, headers: true, converters: strip_converter)
- parsed['Name'] # => ["foo", "bar", "baz"]
- parsed['Value'] # => ["0", "1", "2"]
-
-==== Recipe: Register Field Converters
-
-Register a custom field converter, assigning it a name;
-then refer to the converter by its name:
- rational_converter = proc do |field, field_context|
- field_context.index == 1 ? field.to_r : field
- end
- CSV::Converters[:rational] = rational_converter
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, converters: :rational)
- parsed['Value'] # => [(0/1), (1/1), (2/1)]
-
-==== Using Multiple Field Converters
-
-You can use multiple field converters in either of these ways:
-- Specify converters in option +:converters+.
-- Specify converters in a custom converter list.
-
-===== Recipe: Specify Multiple Field Converters in Option +:converters+
-
-Apply multiple field converters by specifying them in option +:converters+:
- source = "Name,Value\nfoo,0\nbar,1.0\nbaz,2.0\n"
- parsed = CSV.parse(source, headers: true, converters: [:integer, :float])
- parsed['Value'] # => [0, 1.0, 2.0]
-
-===== Recipe: Specify Multiple Field Converters in a Custom Converter List
-
-Apply multiple field converters by defining and registering a custom converter list:
- strip_converter = proc {|field| field.strip }
- CSV::Converters[:strip] = strip_converter
- CSV::Converters[:my_converters] = [:integer, :float, :strip]
- source = "Name,Value\n foo , 0 \n bar , 1.0 \n baz , 2.0 \n"
- parsed = CSV.parse(source, headers: true, converters: :my_converters)
- parsed['Name'] # => ["foo", "bar", "baz"]
- parsed['Value'] # => [0, 1.0, 2.0]
-
-=== Converting Headers
-
-You can use header converters to modify parsed \String headers.
-
-Built-in header converters include:
-- +:symbol+: converts \String header to \Symbol.
-- +:downcase+: converts \String header to lowercase.
-
-You can also define header converters to otherwise modify header \Strings.
-
-==== Recipe: Convert Headers to Lowercase
-
-Convert headers to lowercase using built-in converter +:downcase+:
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, header_converters: :downcase)
- parsed.headers # => ["name", "value"]
-
-==== Recipe: Convert Headers to Symbols
-
-Convert headers to downcased Symbols using built-in converter +:symbol+:
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, header_converters: :symbol)
- parsed.headers # => [:name, :value]
- parsed.headers.map {|header| header.class} # => [Symbol, Symbol]
-
-==== Recipe: Filter Header Strings
-
-Define a custom header converter to modify \String fields.
-This example defines and uses a custom header converter
-that capitalizes each header \String:
- capitalize_converter = proc {|header| header.capitalize }
- source = "NAME,VALUE\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, header_converters: capitalize_converter)
- parsed.headers # => ["Name", "Value"]
-
-==== Recipe: Register Header Converters
-
-Register a custom header converter, assigning it a name;
-then refer to the converter by its name:
- capitalize_converter = proc {|header| header.capitalize }
- CSV::HeaderConverters[:capitalize] = capitalize_converter
- source = "NAME,VALUE\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, headers: true, header_converters: :capitalize)
- parsed.headers # => ["Name", "Value"]
-
-==== Using Multiple Header Converters
-
-You can use multiple header converters in either of these ways:
-- Specify header converters in option +:header_converters+.
-- Specify header converters in a custom header converter list.
-
-===== Recipe: Specify Multiple Header Converters in Option :header_converters
-
-Apply multiple header converters by specifying them in option +:header_converters+:
- source = "Name,Value\nfoo,0\nbar,1.0\nbaz,2.0\n"
- parsed = CSV.parse(source, headers: true, header_converters: [:downcase, :symbol])
- parsed.headers # => [:name, :value]
-
-===== Recipe: Specify Multiple Header Converters in a Custom Header Converter List
-
-Apply multiple header converters by defining and registering a custom header converter list:
- CSV::HeaderConverters[:my_header_converters] = [:symbol, :downcase]
- source = "NAME,VALUE\nfoo,0\nbar,1.0\nbaz,2.0\n"
- parsed = CSV.parse(source, headers: true, header_converters: :my_header_converters)
- parsed.headers # => [:name, :value]
-
-=== Diagnostics
-
-==== Recipe: Capture Unconverted Fields
-
-To capture unconverted field values, use option +:unconverted_fields+:
- source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- parsed = CSV.parse(source, converters: :integer, unconverted_fields: true)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- parsed.each {|row| p row.unconverted_fields }
-Output:
- ["Name", "Value"]
- ["foo", "0"]
- ["bar", "1"]
- ["baz", "2"]
-
-==== Recipe: Capture Field Info
-
-To capture field info in a custom converter, accept two block arguments.
-The first is the field value; the second is a +CSV::FieldInfo+ object:
- strip_converter = proc {|field, field_info| p field_info; field.strip }
- source = " foo , 0 \n bar , 1 \n baz , 2 \n"
- parsed = CSV.parse(source, converters: strip_converter)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-Output:
- #<struct CSV::FieldInfo index=0, line=1, header=nil>
- #<struct CSV::FieldInfo index=1, line=1, header=nil>
- #<struct CSV::FieldInfo index=0, line=2, header=nil>
- #<struct CSV::FieldInfo index=1, line=2, header=nil>
- #<struct CSV::FieldInfo index=0, line=3, header=nil>
- #<struct CSV::FieldInfo index=1, line=3, header=nil>
diff --git a/doc/csv/recipes/recipes.rdoc b/doc/csv/recipes/recipes.rdoc
deleted file mode 100644
index 9e4eaa1da4..0000000000
--- a/doc/csv/recipes/recipes.rdoc
+++ /dev/null
@@ -1,6 +0,0 @@
-== Recipes for \CSV
-
-See:
-- {Recipes for Parsing CSV}[./parsing_rdoc.html]
-- {Recipes for Generating CSV}[./generating_rdoc.html]
-- {Recipes for Filtering CSV}[./filtering_rdoc.html]
diff --git a/doc/date/calendars.rdoc b/doc/date/calendars.rdoc
deleted file mode 100644
index b8690841b1..0000000000
--- a/doc/date/calendars.rdoc
+++ /dev/null
@@ -1,62 +0,0 @@
-== Julian and Gregorian Calendars
-
-The difference between the
-{Julian calendar}[https://en.wikipedia.org/wiki/Julian_calendar]
-and the
-{Gregorian calendar}[https://en.wikipedia.org/wiki/Gregorian_calendar]
-may matter to your program if it uses dates before the switchovers.
-
-- October 15, 1582.
-- September 14, 1752.
-
-A date will be different in the two calendars, in general.
-
-=== Different switchover dates
-
-The reasons for the difference are religious/political histories.
-
-- On October 15, 1582, several countries changed
- from the Julian calendar to the Gregorian calendar;
- these included Italy, Poland, Portugal, and Spain.
- Other contries in the Western world retained the Julian calendar.
-- On September 14, 1752, most of the British empire
- changed from the Julian calendar to the Gregorian calendar.
-
-When your code uses a date before these switchover dates,
-it will matter whether it considers the switchover date
-to be the earlier date or the later date (or neither).
-
-See also {a concrete example here}[rdoc-ref:DateTime@When+should+you+use+DateTime+and+when+should+you+use+Time-3F].
-
-=== Argument +start+
-
-Certain methods in class \Date handle differences in the
-{Julian and Gregorian calendars}[rdoc-ref:calendars.rdoc@Julian+and+Gregorian+Calendars]
-by accepting an optional argument +start+, whose value may be:
-
-- Date::ITALY (the default): the created date is Julian
- if before October 15, 1582, Gregorian otherwise:
-
- d = Date.new(1582, 10, 15)
- d.prev_day.julian? # => true
- d.julian? # => false
- d.gregorian? # => true
-
-- Date::ENGLAND: the created date is Julian if before September 14, 1752,
- Gregorian otherwise:
-
- d = Date.new(1752, 9, 14, Date::ENGLAND)
- d.prev_day.julian? # => true
- d.julian? # => false
- d.gregorian? # => true
-
-- Date::JULIAN: the created date is Julian regardless of its value:
-
- d = Date.new(1582, 10, 15, Date::JULIAN)
- d.julian? # => true
-
-- Date::GREGORIAN: the created date is Gregorian regardless of its value:
-
- d = Date.new(1752, 9, 14, Date::GREGORIAN)
- d.prev_day.gregorian? # => true
-
diff --git a/doc/distribution.md b/doc/distribution.md
deleted file mode 100644
index bc89a7500a..0000000000
--- a/doc/distribution.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Distribution
-
-This document outlines the expected way to distribute Ruby, with a specific focus on building Ruby packages.
-
-## Getting the Ruby Tarball
-
-### Official Releases
-
-The tarball for official releases is created by the release manager. The release manager uploads the tarball to the [Ruby website](https://www.ruby-lang.org/en/downloads/).
-
-Downstream distributors should use the official release tarballs as part of their build process. This ensures that the tarball is created in a consistent way, and that the tarball is crytographically verified.
-
-### Using the nightly tarball for testing
-
-See the Snapshots section of the [Ruby website](https://www.ruby-lang.org/en/downloads/).
-
-### Building a manual snapshot tarball for testing
-
-This can be useful if the nightly tarball does not have all changes yet.
-
-At Ruby source tree cloned using git:
-```sh-session
-$ ./autogen.sh
-$ ./configure -C
-$ make
-$ make dist
-```
-
-This will create several tarball in the `tmp` directory. The tarball will be named e.g. `ruby-<version>.tar.gz` (several different compression formats will be generated).
-
-## Building the Tarball
-
-See [Building Ruby](contributing/building_ruby.md).
-
-## Updating the Ruby Standard Library
-
-The Ruby standard library is a collection of Ruby files that are included with Ruby. These files are used to provide the basic functionality of Ruby. The standard library is located in the `lib` directory and is distributed as part of the Ruby tarball.
-
-Occasionally, the standard library needs to be updated, for example a security issue might be found in a default gem or standard gem. There are two main ways that Ruby would update this code.
-
-### Releasing an Updated Ruby Gem
-
-Normally, the Ruby gem maintainer will release an updated gem. This gem can be installed alongside the default gem. This allows the user to update the gem without having to update Ruby.
-
-### Releasing a New Ruby Version
-
-If the update is critical, then the Ruby maintainers may decide to release a new version of Ruby. This new version will include the updated standard library.
diff --git a/doc/distribution/distribution.md b/doc/distribution/distribution.md
new file mode 100644
index 0000000000..e0e4ad354b
--- /dev/null
+++ b/doc/distribution/distribution.md
@@ -0,0 +1,48 @@
+# Distribution
+
+This document outlines the expected way to distribute Ruby, with a specific focus on building Ruby packages.
+
+## Getting the Ruby Tarball
+
+### Official Releases
+
+The tarball for official releases is created by the release manager. The release manager uploads the tarball to the [Ruby website](https://www.ruby-lang.org/en/downloads/).
+
+Downstream distributors should use the official release tarballs as part of their build process. This ensures that the tarball is created in a consistent way, and that the tarball is cryptographically verified.
+
+### Using the nightly tarball for testing
+
+See the Snapshots section of the [Ruby website](https://www.ruby-lang.org/en/downloads/).
+
+### Building a manual snapshot tarball for testing
+
+This can be useful if the nightly tarball does not have all changes yet.
+
+At Ruby source tree cloned using git:
+
+```console
+$ ./autogen.sh
+$ ./configure -C
+$ make
+$ make dist
+```
+
+This will create several tarball in the `tmp` directory. The tarball will be named e.g. `ruby-<version>.tar.gz` (several different compression formats will be generated).
+
+## Building the Tarball
+
+See [Building Ruby](../contributing/building_ruby.md).
+
+## Updating the Ruby Standard Library
+
+The Ruby standard library is a collection of Ruby files that are included with Ruby. These files are used to provide the basic functionality of Ruby. The standard library is located in the `lib` directory and is distributed as part of the Ruby tarball.
+
+Occasionally, the standard library needs to be updated, for example a security issue might be found in a default gem or standard gem. There are two main ways that Ruby would update this code.
+
+### Releasing an Updated Ruby Gem
+
+Normally, the Ruby gem maintainer will release an updated gem. This gem can be installed alongside the default gem. This allows the user to update the gem without having to update Ruby.
+
+### Releasing a New Ruby Version
+
+If the update is critical, then the Ruby maintainers may decide to release a new version of Ruby. This new version will include the updated standard library.
diff --git a/doc/distribution/windows.md b/doc/distribution/windows.md
new file mode 100644
index 0000000000..26a727d7ad
--- /dev/null
+++ b/doc/distribution/windows.md
@@ -0,0 +1,304 @@
+# Windows
+
+Ruby supports a few native build platforms for Windows.
+
+* mswin: Build using Microsoft Visual C++ compiler with vcruntimeXXX.dll
+* mingw-msvcrt: Build using compiler for Mingw with msvcrtXX.dll
+* mingw-ucrt: Build using compiler for Mingw with Windows Universal CRT
+
+## Building Ruby using Mingw with UCRT
+
+The easiest build environment is just a standard [RubyInstaller-Devkit]
+installation and [git-for-windows]. You might like to use [VSCode] as an
+editor.
+
+### Build examples
+
+Ruby core development can be done either in Windows `cmd` like:
+
+```batch
+ridk install
+ridk enable ucrt64
+
+pacman -S --needed %MINGW_PACKAGE_PREFIX%-openssl %MINGW_PACKAGE_PREFIX%-libyaml %MINGW_PACKAGE_PREFIX%-libffi
+
+mkdir c:\work\ruby
+cd /d c:\work\ruby
+
+git clone https://github.com/ruby/ruby src
+
+sh ./src/autogen.sh
+
+mkdir build
+cd build
+sh ../src/configure -C --disable-install-doc
+make
+```
+
+or in MSYS2 `bash` like:
+
+```bash
+ridk install
+ridk enable ucrt64
+bash
+
+pacman -S --needed $MINGW_PACKAGE_PREFIX-openssl $MINGW_PACKAGE_PREFIX-libyaml $MINGW_PACKAGE_PREFIX-libffi
+
+mkdir /c/work/ruby
+cd /c/work/ruby
+
+git clone https://github.com/ruby/ruby src
+
+./src/autogen.sh
+cd build
+../src/configure -C --disable-install-doc
+make
+```
+
+If you have other MSYS2 environment via other package manager like `scoop`, you need to specify `$MINGW_PACKAGE_PREFIX` is `mingw-w64-ucrt-x86_64`.
+And you need to add `--with-opt-dir` option to `configure` command like:
+
+```batch
+sh ../../ruby/configure -C --disable-install-doc --with-opt-dir=C:\Users\username\scoop\apps\msys2\current\ucrt64
+```
+
+[RubyInstaller-Devkit]: https://rubyinstaller.org/
+[git-for-windows]: https://gitforwindows.org/
+[VSCode]: https://code.visualstudio.com/
+
+## Building Ruby using Visual C++
+
+### Requirement
+
+1. Windows 10/Windows Server 2016 or later.
+
+2. Visual C++ 14.0 (2015) or later.
+
+ **Note** if you want to build x64 version, use native compiler for
+ x64.
+
+ The minimum requirement is here:
+ * VC++/MSVC on VS 2017/2019/2022 version build tools.
+ * Windows 10/11 SDK
+
+ You can install Visual Studio Build Tools with `winget`.
+ `win32\install-buildtools.cmd` is a batch file to install the
+ minimum requirements excluding the IDE etc.
+
+3. Please set environment variable `INCLUDE`, `LIB`, `PATH` to run
+ required commands properly from the command line. These are set
+ properly by `vsdevcmd.bat` or `vcvarall*.bat` usually. You can run
+ the following command to set them in your command line.
+
+ To native build:
+
+ ```
+ cmd /k win32\vssetup.cmd
+ ```
+
+ To cross build arm64 binary:
+
+ ```
+ cmd /k win32\vssetup.cmd -arch=arm64
+ ```
+
+ To cross build x64 binary:
+
+ ```
+ cmd /k win32\vssetup.cmd -arch=x64
+ ```
+
+ This batch file is a wrapper of `vsdevcmd.bat` and options are
+ passed to it as-is. `win32\vssetup.cmd -help` for other command
+ line options.
+
+ **Note** building ruby requires following commands.
+
+ * `nmake`
+ * `cl`
+ * `ml`
+ * `lib`
+ * `dumpbin`
+
+4. If you want to build from GIT source, following commands are required.
+ * `git`
+ * `ruby` 3.1 or later
+
+ You can use [scoop](https://scoop.sh/) to install them like:
+
+ ```batch
+ scoop install git ruby
+ ```
+
+ The windows version of `git` configured with `autocrlf` is `true`. The Ruby
+ test suite may fail with `autocrlf` set to `true`. You can set it to `false`
+ like:
+
+ ```batch
+ git config --global core.autocrlf false
+ ```
+
+5. You need to install required libraries using [vcpkg](https://vcpkg.io/) on
+ directory of ruby repository like:
+
+ ```batch
+ vcpkg --triplet x64-windows install
+ ```
+
+6. Enable Command Extension of your command line. It's the default behavior
+ of `cmd.exe`. If you want to enable it explicitly, run `cmd.exe` with
+ `/E:ON` option.
+
+### How to compile and install
+
+1. Execute `win32\configure.bat` on your build directory.
+ You can specify the target platform as an argument.
+ For example, run `configure --target=i686-mswin32`.
+ You can also specify the install directory.
+ For example, run `configure --prefix=<install_directory>`.
+ Default of the install directory is `/usr` .
+
+2. If you want to append to the executable and DLL file names,
+ specify `--program-prefix` and `--program-suffix`, like
+ `win32\configure.bat --program-suffix=-$(MAJOR)$(MINOR)`.
+
+ Also, the `--install-name` and `--so-name` options specify the
+ exact base names of the executable and DLL files, respectively,
+ like `win32\configure.bat --install-name=$(RUBY_BASE_NAME)-$(MAJOR)$(MINOR)`.
+
+ By default, the name for the executable without a console window
+ is generated from the _RUBY_INSTALL_NAME_ specified as above by
+ replacing `ruby` with `rubyw`. If you want to make it different
+ more, modify _RUBYW_INSTALL_NAME_ directly in the Makefile.
+
+3. You need specify vcpkg directory to use `--with-opt-dir`
+ option like `win32\configure.bat --with-opt-dir=C:/vcpkg_installed/x64-windows`
+
+4. Run `nmake up` if you are building from GIT source.
+
+5. Run `nmake`
+
+6. Run `nmake prepare-vcpkg` with administrator privilege if you need to
+ copy vcpkg installed libraries like `libssl-3-x64.dll` to the build directory.
+
+7. Run `nmake check`
+
+8. Run `nmake install`
+
+### Build examples
+
+* Build on the ruby source directory.
+
+ ```
+ ruby source directory: C:\ruby
+ build directory: C:\ruby
+ install directory: C:\usr\local
+ ```
+
+ ```batch
+ C:
+ cd \ruby
+ win32\configure --prefix=/usr/local
+ nmake
+ nmake check
+ nmake install
+ ```
+
+* Build on the relative directory from the ruby source directory.
+
+ ```
+ ruby source directory: C:\ruby
+ build directory: C:\ruby\mswin32
+ install directory: C:\usr\local
+ ```
+
+ ```batch
+ C:
+ cd \ruby
+ mkdir mswin32
+ cd mswin32
+ ..\win32\configure --prefix=/usr/local
+ nmake
+ nmake check
+ nmake install
+ ```
+
+* Build on the different drive.
+
+ ```
+ ruby source directory: C:\src\ruby
+ build directory: D:\build\ruby
+ install directory: C:\usr\local
+ ```
+
+ ```batch
+ D:
+ cd D:\build\ruby
+ C:\src\ruby\win32\configure --prefix=/usr/local
+ nmake
+ nmake check
+ nmake install DESTDIR=C:
+ ```
+
+* Build x64 version (requires native x64 VC++ compiler)
+
+ ```
+ ruby source directory: C:\ruby
+ build directory: C:\ruby
+ install directory: C:\usr\local
+ ```
+
+ ```batch
+ C:
+ cd \ruby
+ win32\configure --prefix=/usr/local --target=x64-mswin64
+ nmake
+ nmake check
+ nmake install
+ ```
+
+### Bugs
+
+You can **NOT** use a path name that contains any white space characters
+as the ruby source directory, this restriction comes from the behavior
+of `!INCLUDE` directives of `NMAKE`.
+
+You can build ruby in any directory including the source directory,
+except `win32` directory in the source directory.
+This is restriction originating in the path search method of `NMAKE`.
+
+### Dependency management
+
+Ruby uses [vcpkg](https://vcpkg.io/) to manage dependencies on mswin platform.
+
+You can update and install it under the build directory like:
+
+```batch
+nmake update-vcpkg # Update baseline version of vcpkg
+nmake install-vcpkg # Install vcpkg from build directory
+```
+
+
+## Icons
+
+Any icon files(`*.ico`) in the build directory, directories specified with
+_icondirs_ make variable and `win32` directory under the ruby
+source directory will be included in DLL or executable files, according
+to their base names.
+
+ $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
+ $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
+ the others --> $(RUBY_SO_NAME).dll
+
+Although no icons are distributed with the ruby source, you can use
+anything you like. You will be able to find many images by search engines.
+For example, followings are made from [Ruby logo kit]:
+
+* Small [favicon] in the official site
+
+* [vit-ruby.ico] or [icon itself]
+
+[Ruby logo kit]: https://cache.ruby-lang.org/pub/misc/logo/ruby-logo-kit.zip
+[favicon]: https://www.ruby-lang.org/favicon.ico
+[vit-ruby.ico]: http://ruby.morphball.net/vit-ruby-ico_en.html
+[icon itself]: http://ruby.morphball.net/icon/vit-ruby.ico
diff --git a/doc/encodings.rdoc b/doc/encodings.rdoc
deleted file mode 100644
index 1f3c54d740..0000000000
--- a/doc/encodings.rdoc
+++ /dev/null
@@ -1,479 +0,0 @@
-== Encodings
-
-=== The Basics
-
-A {character encoding}[https://en.wikipedia.org/wiki/Character_encoding],
-often shortened to _encoding_, is a mapping between:
-
-- A sequence of 8-bit bytes (each byte in the range <tt>0..255</tt>).
-- Characters in a specific character set.
-
-Some character sets contain only 1-byte characters;
-{US-ASCII}[https://en.wikipedia.org/wiki/ASCII], for example, has 256 1-byte characters.
-This string, encoded in US-ASCII, has six characters that are stored as six bytes:
-
- s = 'Hello!'.encode('US-ASCII') # => "Hello!"
- s.encoding # => #<Encoding:US-ASCII>
- s.bytes # => [72, 101, 108, 108, 111, 33]
-
-Other encodings may involve multi-byte characters.
-{UTF-8}[https://en.wikipedia.org/wiki/UTF-8], for example,
-encodes more than one million characters, encoding each in one to four bytes.
-The lowest-valued of these characters correspond to ASCII characters,
-and so are 1-byte characters:
-
- s = 'Hello!' # => "Hello!"
- s.bytes # => [72, 101, 108, 108, 111, 33]
-
-Other characters, such as the Euro symbol, are multi-byte:
-
- s = "\u20ac" # => "€"
- s.bytes # => [226, 130, 172]
-
-=== The \Encoding \Class
-
-==== \Encoding Objects
-
-Ruby encodings are defined by constants in class \Encoding.
-There can be only one instance of \Encoding for each of these constants.
-\Method Encoding.list returns an array of \Encoding objects (one for each constant):
-
- Encoding.list.size # => 103
- Encoding.list.first.class # => Encoding
- Encoding.list.take(3)
- # => [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>, #<Encoding:US-ASCII>]
-
-==== Names and Aliases
-
-\Method Encoding#name returns the name of an \Encoding:
-
- Encoding::ASCII_8BIT.name # => "ASCII-8BIT"
- Encoding::WINDOWS_31J.name # => "Windows-31J"
-
-An \Encoding object has zero or more aliases;
-method Encoding#names returns an array containing the name and all aliases:
-
- Encoding::ASCII_8BIT.names
- # => ["ASCII-8BIT", "BINARY"]
- Encoding::WINDOWS_31J.names
- #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"]
-
-\Method Encoding.aliases returns a hash of all alias/name pairs:
-
- Encoding.aliases.size # => 71
- Encoding.aliases.take(3)
- # => [["BINARY", "ASCII-8BIT"], ["CP437", "IBM437"], ["CP720", "IBM720"]]
-
-\Method Encoding.name_list returns an array of all the encoding names and aliases:
-
- Encoding.name_list.size # => 175
- Encoding.name_list.take(3)
- # => ["ASCII-8BIT", "UTF-8", "US-ASCII"]
-
-\Method +name_list+ returns more entries than method +list+
-because it includes both the names and their aliases.
-
-\Method Encoding.find returns the \Encoding for a given name or alias, if it exists:
-
- Encoding.find("US-ASCII") # => #<Encoding:US-ASCII>
- Encoding.find("US-ASCII").class # => Encoding
-
-==== Default Encodings
-
-\Method Encoding.find, above, also returns a default \Encoding
-for each of these special names:
-
-- +external+: the default external \Encoding:
-
- Encoding.find("external") # => #<Encoding:UTF-8>
-
-- +internal+: the default internal \Encoding (may be +nil+):
-
- Encoding.find("internal") # => nil
-
-- +locale+: the default \Encoding for a string from the environment:
-
- Encoding.find("locale") # => #<Encoding:UTF-8> # Linux
- Encoding.find("locale") # => #<Encoding:IBM437> # Windows
-
-- +filesystem+: the default \Encoding for a string from the filesystem:
-
- Encoding.find("filesystem") # => #<Encoding:UTF-8>
-
-\Method Encoding.default_external returns the default external \Encoding:
-
- Encoding.default_external # => #<Encoding:UTF-8>
-
-\Method Encoding.default_external= sets that value:
-
- Encoding.default_external = 'US-ASCII' # => "US-ASCII"
- Encoding.default_external # => #<Encoding:US-ASCII>
-
-\Method Encoding.default_internal returns the default internal \Encoding:
-
- Encoding.default_internal # => nil
-
-\Method Encoding.default_internal= sets the default internal \Encoding:
-
- Encoding.default_internal = 'US-ASCII' # => "US-ASCII"
- Encoding.default_internal # => #<Encoding:US-ASCII>
-
-==== Compatible Encodings
-
-\Method Encoding.compatible? returns whether two given objects are encoding-compatible
-(that is, whether they can be concatenated);
-returns the \Encoding of the concatenated string, or +nil+ if incompatible:
-
- rus = "\u{442 435 441 442}"
- eng = 'text'
- Encoding.compatible?(rus, eng) # => #<Encoding:UTF-8>
-
- s0 = "\xa1\xa1".force_encoding('iso-8859-1') # => "\xA1\xA1"
- s1 = "\xa1\xa1".force_encoding('euc-jp') # => "\x{A1A1}"
- Encoding.compatible?(s0, s1) # => nil
-
-=== \String \Encoding
-
-A Ruby String object has an encoding that is an instance of class \Encoding.
-The encoding may be retrieved by method String#encoding.
-
-The default encoding for a string literal is the script encoding
-(see Encoding@Script+encoding):
-
- 's'.encoding # => #<Encoding:UTF-8>
-
-The default encoding for a string created with method String.new is:
-
-- For a \String object argument, the encoding of that string.
-- For a string literal, the script encoding (see Encoding@Script+encoding).
-
-In either case, any encoding may be specified:
-
- s = String.new(encoding: 'UTF-8') # => ""
- s.encoding # => #<Encoding:UTF-8>
- s = String.new('foo', encoding: 'ASCII-8BIT') # => "foo"
- s.encoding # => #<Encoding:ASCII-8BIT>
-
-The encoding for a string may be changed:
-
- s = "R\xC3\xA9sum\xC3\xA9" # => "Résumé"
- s.encoding # => #<Encoding:UTF-8>
- s.force_encoding('ISO-8859-1') # => "R\xC3\xA9sum\xC3\xA9"
- s.encoding # => #<Encoding:ISO-8859-1>
-
-Changing the assigned encoding does not alter the content of the string;
-it changes only the way the content is to be interpreted:
-
- s # => "R\xC3\xA9sum\xC3\xA9"
- s.force_encoding('UTF-8') # => "Résumé"
-
-The actual content of a string may also be altered;
-see {Transcoding a String}[#label-Transcoding+a+String].
-
-Here are a couple of useful query methods:
-
- s = "abc".force_encoding("UTF-8") # => "abc"
- s.ascii_only? # => true
- s = "abc\u{6666}".force_encoding("UTF-8") # => "abc晦"
- s.ascii_only? # => false
-
- s = "\xc2\xa1".force_encoding("UTF-8") # => "¡"
- s.valid_encoding? # => true
- s = "\xc2".force_encoding("UTF-8") # => "\xC2"
- s.valid_encoding? # => false
-
-=== \Symbol and \Regexp Encodings
-
-The string stored in a Symbol or Regexp object also has an encoding;
-the encoding may be retrieved by method Symbol#encoding or Regexp#encoding.
-
-The default encoding for these, however, is:
-
-- US-ASCII, if all characters are US-ASCII.
-- The script encoding, otherwise (see Encoding@Script+encoding).
-
-=== Filesystem \Encoding
-
-The filesystem encoding is the default \Encoding for a string from the filesystem:
-
- Encoding.find("filesystem") # => #<Encoding:UTF-8>
-
-=== Locale \Encoding
-
-The locale encoding is the default encoding for a string from the environment,
-other than from the filesystem:
-
- Encoding.find('locale') # => #<Encoding:IBM437>
-
-=== Stream Encodings
-
-Certain stream objects can have two encodings; these objects include instances of:
-
-- IO.
-- File.
-- ARGF.
-- StringIO.
-
-The two encodings are:
-
-- An _external_ _encoding_, which identifies the encoding of the stream.
-- An _internal_ _encoding_, which (if not +nil+) specifies the encoding
- to be used for the string constructed from the stream.
-
-==== External \Encoding
-
-The external encoding, which is an \Encoding object, specifies how bytes read
-from the stream are to be interpreted as characters.
-
-The default external encoding is:
-
-- UTF-8 for a text stream.
-- ASCII-8BIT for a binary stream.
-
-The default external encoding is returned by method Encoding.default_external,
-and may be set by:
-
-- Ruby command-line options <tt>--external_encoding</tt> or <tt>-E</tt>.
-
-You can also set the default external encoding using method Encoding.default_external=,
-but doing so may cause problems; strings created before and after the change
-may have a different encodings.
-
-For an \IO or \File object, the external encoding may be set by:
-
-- Open options +external_encoding+ or +encoding+, when the object is created;
- see {Open Options}[rdoc-ref:IO@Open+Options].
-
-For an \IO, \File, \ARGF, or \StringIO object, the external encoding may be set by:
-
-- \Methods +set_encoding+ or (except for \ARGF) +set_encoding_by_bom+.
-
-==== Internal \Encoding
-
-The internal encoding, which is an \Encoding object or +nil+,
-specifies how characters read from the stream
-are to be converted to characters in the internal encoding;
-those characters become a string whose encoding is set to the internal encoding.
-
-The default internal encoding is +nil+ (no conversion).
-It is returned by method Encoding.default_internal,
-and may be set by:
-
-- Ruby command-line options <tt>--internal_encoding</tt> or <tt>-E</tt>.
-
-You can also set the default internal encoding using method Encoding.default_internal=,
-but doing so may cause problems; strings created before and after the change
-may have a different encodings.
-
-For an \IO or \File object, the internal encoding may be set by:
-
-- Open options +internal_encoding+ or +encoding+, when the object is created;
- see {Open Options}[rdoc-ref:IO@Open+Options].
-
-For an \IO, \File, \ARGF, or \StringIO object, the internal encoding may be set by:
-
-- \Method +set_encoding+.
-
-=== Script \Encoding
-
-A Ruby script has a script encoding, which may be retrieved by:
-
- __ENCODING__ # => #<Encoding:UTF-8>
-
-The default script encoding is UTF-8;
-a Ruby source file may set its script encoding with a magic comment
-on the first line of the file (or second line, if there is a shebang on the first).
-The comment must contain the word +coding+ or +encoding+,
-followed by a colon, space and the Encoding name or alias:
-
- # encoding: ISO-8859-1
- __ENCODING__ #=> #<Encoding:ISO-8859-1>
-
-=== Transcoding
-
-_Transcoding_ is the process of changing a sequence of characters
-from one encoding to another.
-
-As far as possible, the characters remain the same,
-but the bytes that represent them may change.
-
-The handling for characters that cannot be represented in the destination encoding
-may be specified by @Encoding+Options.
-
-==== Transcoding a \String
-
-Each of these methods transcodes a string:
-
-- String#encode: Transcodes +self+ into a new string
- according to given encodings and options.
-- String#encode!: Like String#encode, but transcodes +self+ in place.
-- String#scrub: Transcodes +self+ into a new string
- by replacing invalid byte sequences with a given or default replacement string.
-- String#scrub!: Like String#scrub, but transcodes +self+ in place.
-- String#unicode_normalize: Transcodes +self+ into a new string
- according to Unicode normalization.
-- String#unicode_normalize!: Like String#unicode_normalize,
- but transcodes +self+ in place.
-
-=== Transcoding a Stream
-
-Each of these methods may transcode a stream;
-whether it does so depends on the external and internal encodings:
-
-- IO.foreach: Yields each line of given stream to the block.
-- IO.new: Creates and returns a new \IO object for the given integer file descriptor.
-- IO.open: Creates a new \IO object.
-- IO.pipe: Creates a connected pair of reader and writer \IO objects.
-- IO.popen: Creates an \IO object to interact with a subprocess.
-- IO.read: Returns a string with all or a subset of bytes from the given stream.
-- IO.readlines: Returns an array of strings, which are the lines from the given stream.
-- IO.write: Writes a given string to the given stream.
-
-This example writes a string to a file, encoding it as ISO-8859-1,
-then reads the file into a new string, encoding it as UTF-8:
-
- s = "R\u00E9sum\u00E9"
- path = 't.tmp'
- ext_enc = 'ISO-8859-1'
- int_enc = 'UTF-8'
-
- File.write(path, s, external_encoding: ext_enc)
- raw_text = File.binread(path)
-
- transcoded_text = File.read(path, external_encoding: ext_enc, internal_encoding: int_enc)
-
- p raw_text
- p transcoded_text
-
-Output:
-
- "R\xE9sum\xE9"
- "Résumé"
-
-=== \Encoding Options
-
-A number of methods in the Ruby core accept keyword arguments as encoding options.
-
-Some of the options specify or utilize a _replacement_ _string_, to be used
-in certain transcoding operations.
-A replacement string may be in any encoding that can be converted
-to the encoding of the destination string.
-
-These keyword-value pairs specify encoding options:
-
-- For an invalid byte sequence:
-
- - <tt>:invalid: nil</tt> (default): Raise exception.
- - <tt>:invalid: :replace</tt>: Replace each invalid byte sequence
- with the replacement string.
-
- Examples:
-
- s = "\x80foo\x80"
- s.encode('ISO-8859-3') # Raises Encoding::InvalidByteSequenceError.
- s.encode('ISO-8859-3', invalid: :replace) # => "?foo?"
-
-- For an undefined character:
-
- - <tt>:undef: nil</tt> (default): Raise exception.
- - <tt>:undef: :replace</tt>: Replace each undefined character
- with the replacement string.
-
- Examples:
-
- s = "\x80foo\x80"
- "\x80".encode('UTF-8', 'ASCII-8BIT') # Raises Encoding::UndefinedConversionError.
- s.encode('UTF-8', 'ASCII-8BIT', undef: :replace) # => "�foo�"
-
-
-- Replacement string:
-
- - <tt>:replace: nil</tt> (default): Set replacement string to default value:
- <tt>"\uFFFD"</tt> ("�") for a Unicode encoding, <tt>'?'</tt> otherwise.
- - <tt>:replace: _some_string_</tt>: Set replacement string to the given +some_string+;
- overrides +:fallback+.
-
- Examples:
-
- s = "\xA5foo\xA5"
- options = {:undef => :replace, :replace => 'xyzzy'}
- s.encode('UTF-8', 'ISO-8859-3', **options) # => "xyzzyfooxyzzy"
-
-- Replacement fallback:
-
- One of these may be specified:
-
- - <tt>:fallback: nil</tt> (default): No replacement fallback.
- - <tt>:fallback: _hash_like_object_</tt>: Set replacement fallback to the given
- +hash_like_object+; the replacement string is <tt>_hash_like_object_[X]</tt>.
- - <tt>:fallback: _method_</tt>: Set replacement fallback to the given
- +method+; the replacement string is <tt>_method_(X)</tt>.
- - <tt>:fallback: _proc_</tt>: Set replacement fallback to the given
- +proc+; the replacement string is <tt>_proc_[X]</tt>.
-
- Examples:
-
- s = "\u3042foo\u3043"
-
- hash = {"\u3042" => 'xyzzy'}
- hash.default = 'XYZZY'
- s.encode('ASCII', fallback: h) # => "xyzzyfooXYZZY"
-
- def (fallback = "U+%.4X").escape(x)
- self % x.unpack("U")
- end
- "\u{3042}".encode("US-ASCII", fallback: fallback.method(:escape)) # => "U+3042"
-
- proc = Proc.new {|x| x == "\u3042" ? 'xyzzy' : 'XYZZY' }
- s.encode('ASCII', fallback: proc) # => "XYZZYfooXYZZY"
-
-- XML entities:
-
- One of these may be specified:
-
- - <tt>:xml: nil</tt> (default): No handling for XML entities.
- - <tt>:xml: :text</tt>: Treat source text as XML;
- replace each undefined character
- with its upper-case hexdecimal numeric character reference,
- except that:
-
- - <tt>&</tt> is replaced with <tt>&amp;</tt>.
- - <tt><</tt> is replaced with <tt>&lt;</tt>.
- - <tt>></tt> is replaced with <tt>&gt;</tt>.
-
- - <tt>:xml: :attr</tt>: Treat source text as XML attribute value;
- replace each undefined character
- with its upper-case hexdecimal numeric character reference,
- except that:
-
- - The replacement string <tt>r</tt> is double-quoted (<tt>"r"</tt>).
- - Each embedded double-quote is replaced with <tt>&quot;</tt>.
- - <tt>&</tt> is replaced with <tt>&amp;</tt>.
- - <tt><</tt> is replaced with <tt>&lt;</tt>.
- - <tt>></tt> is replaced with <tt>&gt;</tt>.
-
- Examples:
-
- s = 'foo"<&>"bar' + "\u3042"
- s.encode('ASCII', xml: :text) # => "foo\"&lt;&amp;&gt;\"bar&#x3042;"
- s.encode('ASCII', xml: :attr) # => "\"foo&quot;&lt;&amp;&gt;&quot;bar&#x3042;\""
-
-
-- Newlines:
-
- One of these may be specified:
-
- - <tt>:cr_newline: true</tt>: Replace each line-feed character (<tt>"\n"</tt>)
- with a carriage-return character (<tt>"\r"</tt>).
- - <tt>:crlf_newline: true</tt>: Replace each line-feed character (<tt>"\n"</tt>)
- with a carriage-return/line-feed string (<tt>"\r\n"</tt>).
- - <tt>:universal_newline: true</tt>: Replace each carriage-return
- character (<tt>"\r"</tt>) and each carriage-return/line-feed string
- (<tt>"\r\n"</tt>) with a line-feed character (<tt>"\n"</tt>).
-
- Examples:
-
- s = "\n \r \r\n" # => "\n \r \r\n"
- s.encode('ASCII', cr_newline: true) # => "\r \r \r\r"
- s.encode('ASCII', crlf_newline: true) # => "\r\n \r \r\r\n"
- s.encode('ASCII', universal_newline: true) # => "\n \n \n"
diff --git a/doc/examples/files.rdoc b/doc/examples/files.rdoc
index f736132770..cb400c81be 100644
--- a/doc/examples/files.rdoc
+++ b/doc/examples/files.rdoc
@@ -7,8 +7,8 @@ text = <<~EOT
Fifth line
EOT
-# Russian text.
-russian = "\u{442 435 441 442}" # => "теÑÑ‚"
+# Japanese text.
+japanese = 'ã“ã‚“ã«ã¡ã¯'
# Binary data.
data = "\u9990\u9991\u9992\u9993\u9994"
@@ -16,8 +16,8 @@ data = "\u9990\u9991\u9992\u9993\u9994"
# Text file.
File.write('t.txt', text)
-# File with Russian text.
-File.write('t.rus', russian)
+# File with Japanese text.
+File.write('t.ja', japanese)
# File with binary data.
f = File.new('t.dat', 'wb:UTF-16')
diff --git a/doc/extension.ja.rdoc b/doc/extension.ja.rdoc
index bde907c916..a943f7a109 100644
--- a/doc/extension.ja.rdoc
+++ b/doc/extension.ja.rdoc
@@ -1,5 +1,7 @@
# extension.ja.rdoc - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995
+{English}[rdoc-ref:extension.rdoc]
+
= Rubyã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã®ä½œã‚Šæ–¹
Rubyã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã®ä½œã‚Šæ–¹ã‚’説明ã—ã¾ã™ï¼Ž
@@ -335,11 +337,11 @@ rb_ary_aref(int argc, const VALUE *argv, VALUE ary) ::
rb_ary_entry(VALUE ary, long offset) ::
- \ary[offset]
+ ary\[offset]
rb_ary_store(VALUE ary, long offset, VALUE obj) ::
- \ary[offset] = obj
+ ary\[offset] = obj
rb_ary_subseq(VALUE ary, long beg, long len) ::
@@ -780,9 +782,14 @@ RUBY_TYPED_WB_PROTECTED ::
メソッドã®å®Ÿè£…ã«é©åˆ‡ã«ãƒ©ã‚¤ãƒˆãƒãƒªã‚¢ã‚’挿入ã™ã‚‹è²¬ä»»ãŒã‚りã¾ã™ï¼Ž
ã•ã‚‚ãªãã°Rubyã¯å®Ÿè¡Œæ™‚ã«ã‚¯ãƒ©ãƒƒã‚·ãƒ¥ã™ã‚‹å¯èƒ½æ€§ãŒã‚りã¾ã™ï¼Ž
- ライトãƒãƒªã‚¢ã«ã¤ã„ã¦ã¯doc/extension.ja.rdocã®Appendix D
- "世代別GC"ã‚‚å‚ç…§ã—ã¦ãã ã•ã„.
+ ライトãƒãƒªã‚¢ã«ã¤ã„ã¦ã¯{世代別
+ GC}[rdoc-ref:@Appendix+D.+-E4-B8-96-E4-BB-A3-E5-88-A5GC]
+ ã‚‚å‚ç…§ã—ã¦ãã ã•ã„.
+ã“ã®ãƒžã‚¯ãƒ­ã¯ä¾‹å¤–を発生ã•ã›ã‚‹å¯èƒ½æ€§ãŒã‚ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•
+ã„. ラップã•れる sval ãŒï¼Œè§£æ”¾ã™ã‚‹å¿…è¦ãŒã‚るリソース (割り
+当ã¦ã‚‰ã‚ŒãŸãƒ¡ãƒ¢ãƒªï¼Œå¤–部ライブラリã‹ã‚‰ã®ãƒãƒ³ãƒ‰ãƒ«ãªã©) ã‚’ä¿æŒã—
+ã¦ã„ã‚‹å ´åˆã¯ï¼Œrb_protect を使用ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ï¼Ž
Cã®æ§‹é€ ä½“ã®å‰²å½“ã¨å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトã®ç”Ÿæˆã‚’åŒæ™‚ã«è¡Œã†ãƒžã‚¯
ロã¨ã—ã¦ä»¥ä¸‹ã®ã‚‚ã®ãŒæä¾›ã•れã¦ã„ã¾ã™ï¼Ž
@@ -1731,7 +1738,7 @@ have_func(func, header) ::
ックã™ã‚‹ï¼ŽfuncãŒæ¨™æº–ã§ã¯ãƒªãƒ³ã‚¯ã•れãªã„ライブラリ内ã®ã‚‚ã®ã§
ã‚る時ã«ã¯å…ˆã«have_libraryã§ãã®ãƒ©ã‚¤ãƒ–ラリをãƒã‚§ãƒƒã‚¯ã—ã¦ãŠ
ã事.ãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ
- `HAVE_{FUNC}` を定義ã—,trueã‚’è¿”ã™ï¼Ž
+ <tt>HAVE_{FUNC}</tt> を定義ã—,trueã‚’è¿”ã™ï¼Ž
have_var(var, header) ::
@@ -1739,44 +1746,44 @@ have_var(var, header) ::
クã™ã‚‹ï¼ŽvarãŒæ¨™æº–ã§ã¯ãƒªãƒ³ã‚¯ã•れãªã„ライブラリ内ã®ã‚‚ã®ã§ã‚
る時ã«ã¯å…ˆã«have_libraryã§ãã®ãƒ©ã‚¤ãƒ–ラリをãƒã‚§ãƒƒã‚¯ã—ã¦ãŠã
事.ãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ
- `HAVE_{VAR}` を定義ã—,trueã‚’è¿”ã™ï¼Ž
+ <tt>HAVE_{VAR}</tt> を定義ã—,trueã‚’è¿”ã™ï¼Ž
have_header(header) ::
ヘッダファイルã®å­˜åœ¨ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹ï¼Žãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œ
- プリプロセッサマクロ `HAVE_{HEADER_H}` を定義ã—,trueã‚’è¿”ã™ï¼Ž
+ プリプロセッサマクロ <tt>HAVE_{HEADER_H}</tt> を定義ã—,trueã‚’è¿”ã™ï¼Ž
(スラッシュやドットã¯ã‚¢ãƒ³ãƒ€ãƒ¼ã‚¹ã‚³ã‚¢ã«ç½®æ›ã•れる)
find_header(header, path...) ::
ヘッダファイルheaderã®å­˜åœ¨ã‚’ -Ipath を追加ã—ãªãŒã‚‰ãƒã‚§ãƒƒã‚¯
ã™ã‚‹ï¼Žãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ
- `HAVE_{HEADER_H}` を定義ã—,trueã‚’è¿”ã™ï¼Ž
+ <tt>HAVE_{HEADER_H}</tt> を定義ã—,trueã‚’è¿”ã™ï¼Ž
(スラッシュやドットã¯ã‚¢ãƒ³ãƒ€ãƒ¼ã‚¹ã‚³ã‚¢ã«ç½®æ›ã•れる)
have_struct_member(type, member[, header[, opt]]) ::
ヘッダファイルheaderをインクルードã—ã¦åž‹typeãŒå®šç¾©ã•れ,
ãªãŠã‹ã¤ãƒ¡ãƒ³ãƒmemberãŒå­˜åœ¨ã™ã‚‹ã‹ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹ï¼Žãƒã‚§ãƒƒã‚¯ã«
- æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ `HAVE_{TYPE}_{MEMBER}` ã‚’
+ æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ <tt>HAVE_{TYPE}_{MEMBER}</tt> ã‚’
定義ã—,trueã‚’è¿”ã™ï¼Ž
have_type(type, header, opt) ::
ヘッダファイルheaderをインクルードã—ã¦åž‹typeãŒå­˜åœ¨ã™ã‚‹ã‹ã‚’
ãƒã‚§ãƒƒã‚¯ã™ã‚‹ï¼Žãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ
- `HAVE_TYPE_{TYPE}` を定義ã—,trueã‚’è¿”ã™ï¼Ž
+ <tt>HAVE_TYPE_{TYPE}</tt> を定義ã—,trueã‚’è¿”ã™ï¼Ž
check_sizeof(type, header) ::
ヘッダファイルheaderをインクルードã—ã¦åž‹typeã®charå˜ä½ã‚µã‚¤
ズを調ã¹ã‚‹ï¼Žãƒã‚§ãƒƒã‚¯ã«æˆåŠŸã™ã‚‹ã¨ï¼Œãƒ—リプロセッサマクロ
- `SIZEOF_{TYPE}` を定義ã—,ãã®ã‚µã‚¤ã‚ºã‚’è¿”ã™ï¼Žå®šç¾©ã•れã¦ã„ãª
+ <tt>SIZEOF_{TYPE}</tt> を定義ã—,ãã®ã‚µã‚¤ã‚ºã‚’è¿”ã™ï¼Žå®šç¾©ã•れã¦ã„ãª
ã„ã¨ãã¯nilã‚’è¿”ã™ï¼Ž
-append_cppflags(array-of-flags[, opt])
-append_cflags(array-of-flags[, opt])
-append_ldflags(array-of-flags[, opt])
+append_cppflags(array-of-flags[, opt]) ::
+append_cflags(array-of-flags[, opt]) ::
+append_ldflags(array-of-flags[, opt]) ::
å„flagãŒä½¿ç”¨å¯èƒ½ã§ã‚れã°ï¼Œãれãžã‚Œ$CPPFLAGS, $CFLAGS,
$LDFLAGSã«è¿½åŠ ã™ã‚‹ï¼Žã‚³ãƒ³ãƒ‘イラã®ãƒ•ラグã«ã¯ç§»æ¤æ€§ãŒãªã„ã®ã§ï¼Œ
@@ -1850,8 +1857,9 @@ RGenGCã¯ï¼ŒéŽåŽ»ã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã«ï¼ˆã»ã¼ï¼‰äº’æ›æ€§ã‚’ä¿ã¤ã‚ˆã
スã™ã‚‹ã‚ˆã†ãªã‚³ãƒ¼ãƒ‰ã¯æ›¸ã‹ãªã„よã†ã«ã—ã¦ä¸‹ã•ã„.代ã‚りã«ï¼Œrb_ary_aref(),
rb_ary_store() ãªã©ã®ï¼Œé©åˆ‡ãª API 関数を利用ã™ã‚‹ã‚ˆã†ã«ã—ã¦ä¸‹ã•ã„.
-ãã®ã»ã‹ï¼Œå¯¾å¿œã«ã¤ã„ã¦ã®è©³ç´°ã¯ extension.rdoc ã®ã€ŒAppendix D. Generational
-GCã€ã‚’å‚ç…§ã—ã¦ä¸‹ã•ã„.
+ãã®ã»ã‹ï¼Œå¯¾å¿œã«ã¤ã„ã¦ã®è©³ç´°ã¯ {Appendix D. Generational
+GC}[rdoc-ref:extension.rdoc@Appendix+D.+Generational+GC]ã‚’å‚
+ç…§ã—ã¦ä¸‹ã•ã„.
== Appendix E. Ractor サãƒãƒ¼ãƒˆ
@@ -1860,10 +1868,12 @@ Ruby 3.0 ã‹ã‚‰ã€Ruby プログラムを並列ã«å®Ÿè¡Œã™ã‚‹ãŸã‚ã®ä»•組ã¿
ãªã‚Šã¾ã™ã€‚サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„ライブラリã¯ã€ãƒ¡ã‚¤ãƒ³ Ractor 以外ã§å®Ÿè¡Œã™ã‚‹ã¨
エラーã«ãªã‚Šã¾ã™ï¼ˆRactor::UnsafeError)。
-Ractor をサãƒãƒ¼ãƒˆã™ã‚‹ãŸã‚ã®è©³ç´°ã¯ã€extension.rdoc ã®ã€ŒAppendix F. Ractor
-supportã€ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
-
+Ractor をサãƒãƒ¼ãƒˆã™ã‚‹ãŸã‚ã®è©³ç´°ã¯ã€{Appendix F. Ractor
+support}[rdoc-ref:extension.rdoc@Appendix+F.+Ractor+support]
+ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
-:enddoc: Local variables:
-:enddoc: fill-column: 60
-:enddoc: end:
+--
+Local variables:
+fill-column: 60
+end:
+++
diff --git a/doc/extension.rdoc b/doc/extension.rdoc
index c0360ae625..9fc507706e 100644
--- a/doc/extension.rdoc
+++ b/doc/extension.rdoc
@@ -1,5 +1,7 @@
# extension.rdoc - -*- RDoc -*- created at: Mon Aug 7 16:45:54 JST 1995
+{日本語}[rdoc-ref:extension.ja.rdoc]
+
= Creating extension libraries for Ruby
This document explains how to make extension libraries for Ruby.
@@ -315,11 +317,11 @@ rb_ary_aref(int argc, const VALUE *argv, VALUE ary) ::
rb_ary_entry(VALUE ary, long offset) ::
- \ary[offset]
+ ary\[offset]
rb_ary_store(VALUE ary, long offset, VALUE obj) ::
- \ary[offset] = obj
+ ary\[offset] = obj
rb_ary_subseq(VALUE ary, long beg, long len) ::
@@ -747,18 +749,68 @@ RUBY_TYPED_WB_PROTECTED ::
barriers in all implementations of methods of that object as
appropriate. Otherwise Ruby might crash while running.
- More about write barriers can be found in "Generational GC" in
- Appendix D.
+ More about write barriers can be found in {Generational
+ GC}[rdoc-ref:@Appendix+D.+Generational+GC].
RUBY_TYPED_FROZEN_SHAREABLE ::
- This flag indicates that the object is shareable object
- if the object is frozen. See Appendix F more details.
+ This flag indicates that the object is shareable object if the object
+ is frozen. See {Ractor support}[rdoc-ref:@Appendix+F.+Ractor+support]
+ more details.
If this flag is not set, the object can not become a shareable
object by Ractor.make_shareable() method.
-You can allocate and wrap the structure in one step.
+RUBY_TYPED_EMBEDDABLE ::
+
+ This flag indicates that Ruby may store the C struct inside the object
+ slot, rather than allocate it separately with +malloc+.
+ However, it is not a guarantee. Ruby may decide not to embed the object.
+ For instance if it's too large to fit into one of the available slot sizes.
+
+ Embedding the C struct inside the object slot reduces pointer chasing,
+ malloc overhead, and improves sweep performance.
+ In some cases, it can also reduce the memory footprint of the object.
+
+ To be embeddable, types must abide by some restrictions:
+
+ * Pointers to the C struct, or into the C struct, MUST NOT be stored,
+ as they become invalid when GC compaction occurs.
+ It is however valid to pass and use such pointers for as long as the Ruby
+ object remains on the stack.
+
+ In a sense, this is similar to the restrictions of a stack allocated struct.
+
+ The +RB_GC_GUARD+ macro must be used to ensure the object is not moved by
+ compaction and not freed, unless the object is passed directly as an
+ argument from Ruby to C, i.e. as a parameter of a function used with
+ +rb_define_method+ and similar.
+
+ * The +DATA_PTR+ and +RTYPEDDATA_DATA+ macro can't be used.
+ Only +RTYPEDDATA_GET_DATA+` or +TypedData_Get_Struct+ macros can be used
+ with embeddable objects.
+ Accessing `RDATA(obj)->data` or `RTYPEDDATA(obj)->data` is invalid too.
+
+ * The +dfree+ function MUST NOT free the C struct itself.
+ Setting +dfree+ to +RUBY_DEFAULT_FREE+ is fine.
+ To support older Ruby versions without this feature, you can
+ conditionally free the C struct if +RUBY_TYPED_EMBEDDABLE+ isn't defined.
+
+ * The type must have the +RUBY_TYPED_FREE_IMMEDIATELY+ flag set.
+
+ If the embedded C struct is of variable size, +rb_data_typed_object_zalloc+
+ can be used instead of +TypedData_Make_Struct+.
+
+ See {Embedded TypedData}[rdoc-ref:@Appendix+G.+Embedded+TypedData] for a
+ commented example of how to use +RUBY_TYPED_EMBEDDABLE+.
+
+
+Note that this macro can raise an exception. If sval to be wrapped
+holds a resource needs to be released (e.g., allocated memory, handle
+from an external library, and etc), you will have to use rb_protect.
+
+You can allocate and wrap the structure in one step, in more
+preferable manner.
TypedData_Make_Struct(klass, type, data_type, sval)
@@ -767,10 +819,71 @@ the structure, which is also allocated. This macro works like:
(sval = ZALLOC(type), TypedData_Wrap_Struct(klass, data_type, sval))
+However, you should use this macro instead of "allocation then wrap"
+like the above code if it is simply allocated, because the latter can
+raise a NoMemoryError and sval will be memory leaked in that case.
+
Arguments klass and data_type work like their counterparts in
TypedData_Wrap_Struct(). A pointer to the allocated structure will
be assigned to sval, which should be a pointer of the type specified.
+==== Declaratively marking/compacting struct references
+
+In the case where your struct refers to Ruby objects that are simple values,
+not wrapped in conditional logic or complex data structures an alternative
+approach to marking and reference updating is provided, by declaring offset
+references to the VALUES in your struct.
+
+Doing this allows the Ruby GC to support marking these references and GC
+compaction without the need to define the +dmark+ and +dcompact+ callbacks.
+
+You must define a static list of VALUE pointers to the offsets within your
+struct where the references are located, and set the "data" member to point to
+this reference list. The reference list must end with +RUBY_END_REFS+.
+
+Some Macros have been provided to make edge referencing easier:
+
+* <code>RUBY_TYPED_DECL_MARKING</code> =A flag that can be set on the +ruby_data_type_t+ to indicate that references are being declared as edges.
+
+* <code>RUBY_REFERENCES(ref_list_name)</code> - Define _ref_list_name_ as a list of references
+
+* <code>RUBY_REF_END</code> - The end mark of the references list.
+
+* <code>RUBY_REF_EDGE(struct, member)</code> - Declare _member_ as a VALUE edge from _struct_. Use this after +RUBY_REFERENCES_START+
+
+* +RUBY_REFS_LIST_PTR+ - Coerce the reference list into a format that can be
+ accepted by the existing +dmark+ interface.
+
+The example below is from Dir (defined in +dir.c+)
+
+ // The struct being wrapped. Notice this contains 3 members of which the second
+ // is a VALUE reference to another ruby object.
+ struct dir_data {
+ DIR *dir;
+ const VALUE path;
+ rb_encoding *enc;
+ }
+
+ // Define a reference list `dir_refs` containing a single entry to `path`.
+ // Needs terminating with RUBY_REF_END
+ RUBY_REFERENCES(dir_refs) = {
+ RUBY_REF_EDGE(dir_data, path),
+ RUBY_REF_END
+ };
+
+ // Override the "dmark" field with the defined reference list now that we
+ // no longer need a marking callback and add RUBY_TYPED_DECL_MARKING to the
+ // flags field
+ static const rb_data_type_t dir_data_type = {
+ "dir",
+ {RUBY_REFS_LIST_PTR(dir_refs), dir_free, dir_memsize,},
+ 0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING
+ };
+
+Declaring simple references declaratively in this manner allows the GC to both
+mark, and move the underlying object, and automatically update the reference to
+it during compaction.
+
==== Ruby object to C struct
To retrieve the C pointer from the T_DATA object, use the macro
@@ -1980,7 +2093,7 @@ the <code>*_kw</code> functions introduced in Ruby 2.7.
#define rb_proc_call_with_block_kw(p, c, v, b, kw) rb_proc_call_with_block(p, c, v, b)
#define rb_method_call_kw(c, v, m, kw) rb_method_call(c, v, m)
#define rb_method_call_with_block_kw(c, v, m, b, kw) rb_method_call_with_block(c, v, m, b)
- #define rb_eval_cmd_kwd(c, a, kw) rb_eval_cmd(c, a, 0)
+ #define rb_eval_cmd_kw(c, a, kw) rb_eval_cmd(c, a, 0)
#endif
== Appendix C. Functions available for use in extconf.rb
@@ -2152,70 +2265,155 @@ Ractor safety around C extensions has the following properties:
To make a "Ractor-safe" C extension, we need to check the following points:
-(1) Do not share unshareable objects between ractors
+1. Do not share unshareable objects between ractors
+
+ For example, C's global variable can lead sharing an unshareable objects
+ between ractors.
-For example, C's global variable can lead sharing an unshareable objects
-between ractors.
+ VALUE g_var;
+ VALUE set(VALUE self, VALUE v){ return g_var = v; }
+ VALUE get(VALUE self){ return g_var; }
- VALUE g_var;
- VALUE set(VALUE self, VALUE v){ return g_var = v; }
- VALUE get(VALUE self){ return g_var; }
+ set() and get() pair can share an unshareable objects using g_var, and
+ it is Ractor-unsafe.
-set() and get() pair can share an unshareable objects using g_var, and
-it is Ractor-unsafe.
+ Not only using global variables directly, some indirect data structure
+ such as global st_table can share the objects, so please take care.
-Not only using global variables directly, some indirect data structure
-such as global st_table can share the objects, so please take care.
+ Note that class and module objects are shareable objects, so you can
+ keep the code "cFoo = rb_define_class(...)" with C's global variables.
-Note that class and module objects are shareable objects, so you can
-keep the code "cFoo = rb_define_class(...)" with C's global variables.
+2. Check the thread-safety of the extension
-(2) Check the thread-safety of the extension
+ An extension should be thread-safe. For example, the following code is
+ not thread-safe:
-An extension should be thread-safe. For example, the following code is
-not thread-safe:
+ bool g_called = false;
+ VALUE call(VALUE self) {
+ if (g_called) rb_raise("recursive call is not allowed.");
+ g_called = true;
+ VALUE ret = do_something();
+ g_called = false;
+ return ret;
+ }
- bool g_called = false;
- VALUE call(VALUE self) {
- if (g_called) rb_raise("recursive call is not allowed.");
- g_called = true;
- VALUE ret = do_something();
- g_called = false;
- return ret;
+ because g_called global variable should be synchronized by other
+ ractor's threads. To avoid such data-race, some synchronization should
+ be used. Check include/ruby/thread_native.h and include/ruby/atomic.h.
+
+ With Ractors, all objects given as method parameters and the receiver (self)
+ are guaranteed to be from the current Ractor or to be shareable. As a
+ consequence, it is easier to make code ractor-safe than to make code generally
+ thread-safe. For example, we don't need to lock an array object to access the
+ element of it.
+
+3. Check the thread-safety of any used library
+
+ If the extension relies on an external library, such as a function foo() from
+ a library libfoo, the function libfoo foo() should be thread safe.
+
+4. Make an object shareable
+
+ This is not required to make an extension Ractor-safe.
+
+ If an extension provides special objects defined by rb_data_type_t,
+ consider these objects can become shareable or not.
+
+ RUBY_TYPED_FROZEN_SHAREABLE flag indicates that these objects can be
+ shareable objects if the object is frozen. This means that if the object
+ is frozen, the mutation of wrapped data is not allowed.
+
+5. Others
+
+ There are possibly other points or requirements which must be considered in the
+ making of a Ractor-safe extension. This document will be extended as they are
+ discovered.
+
+== Appendix G. Embedded TypedData
+
+Here is an example of how to use +RUBY_TYPED_EMBEDDABLE+::
+
+ struct my_data {
+ struct timespec created_at;
+ size_t buffer_capa;
+ char *buffer;
+ };
+
+ static void
+ my_data_free(void *ptr)
+ {
+ struct my_data *data = (struct my_data *)ptr;
+
+ // Deliberately don't free `ptr` if it is embeddable.
+ // Only auxiliary memory need to be freed.
+ ruby_xfree(data->buffer);
}
-because g_called global variable should be synchronized by other
-ractor's threads. To avoid such data-race, some synchronization should
-be used. Check include/ruby/thread_native.h and include/ruby/atomic.h.
+ static size_t
+ my_data_size(const void *ptr)
+ {
+ const struct my_data *data = (const struct my_data *)ptr;
+ // We don't need to account for `sizeof(struct my_struct)` because it is embedded inside the Ruby object.
+ // Only auxiliary memory need to be reported.
+ return data->buffer_capa;
+ }
-With Ractors, all objects given as method parameters and the receiver (self)
-are guaranteed to be from the current Ractor or to be shareable. As a
-consequence, it is easier to make code ractor-safe than to make code generally
-thread-safe. For example, we don't need to lock an array object to access the
-element of it.
+ static const rb_data_type_t my_type = {
+ .wrap_struct_name = "my_type",
+ .function = {
+ .dfree = my_data_free,
+ .dsize = my_data_size,
+ }
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE,
+ };
-(3) Check the thread-safety of any used library
+ static VALUE
+ my_data_alloc(VALUE klass)
+ {
+ struct my_data *data;
+ VALUE obj = TypedData_Make_Struct(klass, struct my_data, &my_type, data);
-If the extension relies on an external library, such as a function foo() from
-a library libfoo, the function libfoo foo() should be thread safe.
+ // Is it fine to pass pointers into the embedded struct, for as long as
+ // the called function won't use it after the Ruby object have left the stack.
+ clock_gettime(CLOCK_REALTIME, &data->created_at);
+ data->buffer_capa = 1024;
+ data->buffer = ZALLOC_N(char, data->buffer_capa);
-(4) Make an object shareable
+ return obj
+ }
-This is not required to make an extension Ractor-safe.
+ static VALUE
+ my_data_m_parse(VALUE klass)
+ {
+ struct my_data *data;
+ VALUE my_data_obj = my_data_alloc(klass);
+ TypedData_Get_Struct(obj, struct my_data, &my_type, data);
-If an extension provides special objects defined by rb_data_type_t,
-consider these objects can become shareable or not.
+ // `my_data_obj` was allocated from C, `RB_GC_GUARD` must be used to
+ // ensure the compiler will keep its reference on the stack.
+ RB_GC_GUARD(my_data_obj)
+ }
-RUBY_TYPED_FROZEN_SHAREABLE flag indicates that these objects can be
-shareable objects if the object is frozen. This means that if the object
-is frozen, the mutation of wrapped data is not allowed.
+ static VALUE
+ my_data_read(VALUE self)
+ {
+ struct my_data *data;
+ TypedData_Get_Struct(obj, struct my_data, &my_type, data);
-(5) Others
+ // `self` is received from `rb_define_method` so `RB_GC_GUARD` isn't necessary.
+ return rb_str_new(data->buffer, data->buffer_capa)
+ }
-There are possibly other points or requirements which must be considered in the
-making of a Ractor-safe extension. This document will be extended as they are
-discovered.
+ void
+ Init_my_data(void)
+ {
+ VALUE cMyData = rb_define_class("MyData");
+ rb_define_method(cMyData, "read", my_data_read, 0);
+ rb_define_singleton_method(cMyData, "parse", my_data_m_parse, 0);
+ }
-:enddoc: Local variables:
-:enddoc: fill-column: 70
-:enddoc: end:
+--
+Local variables:
+fill-column: 70
+end:
+++
diff --git a/doc/fiber.md b/doc/fiber.md
deleted file mode 100644
index a334faf739..0000000000
--- a/doc/fiber.md
+++ /dev/null
@@ -1,232 +0,0 @@
-# Fiber
-
-Fibers provide a mechanism for cooperative concurrency.
-
-## Context Switching
-
-Fibers execute a user-provided block. During the execution, the block may call `Fiber.yield` or `Fiber.transfer` to switch to another fiber. `Fiber#resume` is used to continue execution from the point where `Fiber.yield` was called.
-
-``` ruby
-#!/usr/bin/env ruby
-
-puts "1: Start program."
-
-f = Fiber.new do
- puts "3: Entered fiber."
- Fiber.yield
- puts "5: Resumed fiber."
-end
-
-puts "2: Resume fiber first time."
-f.resume
-
-puts "4: Resume fiber second time."
-f.resume
-
-puts "6: Finished."
-```
-
-This program demonstrates the flow control of fibers.
-
-## Scheduler
-
-The scheduler interface is used to intercept blocking operations. A typical
-implementation would be a wrapper for a gem like `EventMachine` or `Async`. This
-design provides separation of concerns between the event loop implementation
-and application code. It also allows for layered schedulers which can perform
-instrumentation.
-
-To set the scheduler for the current thread:
-
-``` ruby
-Fiber.set_scheduler(MyScheduler.new)
-```
-
-When the thread exits, there is an implicit call to `set_scheduler`:
-
-``` ruby
-Fiber.set_scheduler(nil)
-```
-
-### Design
-
-The scheduler interface is designed to be a un-opinionated light-weight layer
-between user code and blocking operations. The scheduler hooks should avoid
-translating or converting arguments or return values. Ideally, the exact same
-arguments from the user code are provided directly to the scheduler hook with
-no changes.
-
-### Interface
-
-This is the interface you need to implement.
-
-``` ruby
-class Scheduler
- # Wait for the specified process ID to exit.
- # This hook is optional.
- # @parameter pid [Integer] The process ID to wait for.
- # @parameter flags [Integer] A bit-mask of flags suitable for `Process::Status.wait`.
- # @returns [Process::Status] A process status instance.
- def process_wait(pid, flags)
- Thread.new do
- Process::Status.wait(pid, flags)
- end.value
- end
-
- # Wait for the given io readiness to match the specified events within
- # the specified timeout.
- # @parameter event [Integer] A bit mask of `IO::READABLE`,
- # `IO::WRITABLE` and `IO::PRIORITY`.
- # @parameter timeout [Numeric] The amount of time to wait for the event in seconds.
- # @returns [Integer] The subset of events that are ready.
- def io_wait(io, events, timeout)
- end
-
- # Read from the given io into the specified buffer.
- # WARNING: Experimental hook! Do not use in production code!
- # @parameter io [IO] The io to read from.
- # @parameter buffer [IO::Buffer] The buffer to read into.
- # @parameter length [Integer] The minimum amount to read.
- def io_read(io, buffer, length)
- end
-
- # Write from the given buffer into the specified IO.
- # WARNING: Experimental hook! Do not use in production code!
- # @parameter io [IO] The io to write to.
- # @parameter buffer [IO::Buffer] The buffer to write from.
- # @parameter length [Integer] The minimum amount to write.
- def io_write(io, buffer, length)
- end
-
- # Sleep the current task for the specified duration, or forever if not
- # specified.
- # @parameter duration [Numeric] The amount of time to sleep in seconds.
- def kernel_sleep(duration = nil)
- end
-
- # Execute the given block. If the block execution exceeds the given timeout,
- # the specified exception `klass` will be raised. Typically, only non-blocking
- # methods which enter the scheduler will raise such exceptions.
- # @parameter duration [Integer] The amount of time to wait, after which an exception will be raised.
- # @parameter klass [Class] The exception class to raise.
- # @parameter *arguments [Array] The arguments to send to the constructor of the exception.
- # @yields {...} The user code to execute.
- def timeout_after(duration, klass, *arguments, &block)
- end
-
- # Resolve hostname to an array of IP addresses.
- # This hook is optional.
- # @parameter hostname [String] Example: "www.ruby-lang.org".
- # @returns [Array] An array of IPv4 and/or IPv6 address strings that the hostname resolves to.
- def address_resolve(hostname)
- end
-
- # Block the calling fiber.
- # @parameter blocker [Object] What we are waiting on, informational only.
- # @parameter timeout [Numeric | Nil] The amount of time to wait for in seconds.
- # @returns [Boolean] Whether the blocking operation was successful or not.
- def block(blocker, timeout = nil)
- end
-
- # Unblock the specified fiber.
- # @parameter blocker [Object] What we are waiting on, informational only.
- # @parameter fiber [Fiber] The fiber to unblock.
- # @reentrant Thread safe.
- def unblock(blocker, fiber)
- end
-
- # Intercept the creation of a non-blocking fiber.
- # @returns [Fiber]
- def fiber(&block)
- Fiber.new(blocking: false, &block)
- end
-
- # Invoked when the thread exits.
- def close
- self.run
- end
-
- def run
- # Implement event loop here.
- end
-end
-```
-
-Additional hooks may be introduced in the future, we will use feature detection
-in order to enable these hooks.
-
-### Non-blocking Execution
-
-The scheduler hooks will only be used in special non-blocking execution
-contexts. Non-blocking execution contexts introduce non-determinism because the
-execution of scheduler hooks may introduce context switching points into your
-program.
-
-#### Fibers
-
-Fibers can be used to create non-blocking execution contexts.
-
-``` ruby
-Fiber.new do
- puts Fiber.current.blocking? # false
-
- # May invoke `Fiber.scheduler&.io_wait`.
- io.read(...)
-
- # May invoke `Fiber.scheduler&.io_wait`.
- io.write(...)
-
- # Will invoke `Fiber.scheduler&.kernel_sleep`.
- sleep(n)
-end.resume
-```
-
-We also introduce a new method which simplifies the creation of these
-non-blocking fibers:
-
-``` ruby
-Fiber.schedule do
- puts Fiber.current.blocking? # false
-end
-```
-
-The purpose of this method is to allow the scheduler to internally decide the
-policy for when to start the fiber, and whether to use symmetric or asymmetric
-fibers.
-
-You can also create blocking execution contexts:
-
-``` ruby
-Fiber.new(blocking: true) do
- # Won't use the scheduler:
- sleep(n)
-end
-```
-
-However you should generally avoid this unless you are implementing a scheduler.
-
-#### IO
-
-By default, I/O is non-blocking. Not all operating systems support non-blocking
-I/O. Windows is a notable example where socket I/O can be non-blocking but pipe
-I/O is blocking. Provided that there *is* a scheduler and the current thread *is
-non-blocking*, the operation will invoke the scheduler.
-
-#### Mutex
-
-The `Mutex` class can be used in a non-blocking context and is fiber specific.
-
-#### ConditionVariable
-
-The `ConditionVariable` class can be used in a non-blocking context and is
-fiber-specific.
-
-#### Queue / SizedQueue
-
-The `Queue` and `SizedQueue` classes can be used in a non-blocking context and
-are fiber-specific.
-
-#### Thread
-
-The `Thread#join` operation can be used in a non-blocking context and is
-fiber-specific.
diff --git a/doc/file/timestamps.md b/doc/file/timestamps.md
new file mode 100644
index 0000000000..c8ad616567
--- /dev/null
+++ b/doc/file/timestamps.md
@@ -0,0 +1,83 @@
+# \File System Timestamps
+
+A file system entry (the name of a file or directory)
+has several times (called timestamps) associated with it.
+
+The Ruby methods that return these timestamps (each as a Time object)
+are actually returning "whatever the OS says,"
+and so their behaviors may vary among OS platforms.
+If a platform does not support a particular timestamp,
+the corresponding Ruby methods raise NotImplementedError.
+
+These timestamps are:
+
+| Name | Meaning | Changes |
+|:--------------------------------:|----------------------------------------|-----------------------|
+| [`birthtime`](#birth-time) | Create time. | Never. |
+| [`mtime`](#modification-time) | Modification time. | When written. |
+| [`atime`](#access-time) | Access time. | When read or written. |
+| [`ctime`](#metadata-change-time) | Metadata-change time (or create time). | See below. |
+
+## Birth \Time
+
+The birth time for an entry is the time the entry was created.
+The birth time does not change, although if the entry is deleted and re-created,
+the birth time will be different.
+
+Each of these methods returns the birth time for an entry as a Time object:
+
+- File::birthtime.
+- File#birthtime.
+- File::Stat#birthtime.
+- Pathname#birthtime.
+
+On Windows, each of these methods also returns the birth time:
+
+- File::ctime.
+- File#ctime.
+- File::Stat#ctime.
+- Pathname#ctime.
+
+## Modification \Time
+
+The modification time for an entry is the time the entry was last modified.
+The modification time is updated when the entry is written,
+though some file systems may delay the update.
+
+Each of these methods returns the modification time for an entry as a Time object:
+
+- File::mtime.
+- File#mtime.
+- File::Stat#mtime.
+- Pathname#mtime.
+
+## Access \Time
+
+The access time for an entry is the time the entry last read.
+The access time is updated when the entry is read,
+though some file systems may delay the update.
+
+Each of these methods returns the access time for an entry as a Time object:
+
+- File::atime.
+- File#atime.
+- File::Stat#atime.
+- Pathname#atime.
+
+## Metadata-Change \Time
+
+The metadata-change time for an entry is the time the entry last read.
+The metadata-change time is updated when the entry's metadata is changed;
+changing access mode or permissions may update the metadata-change time,
+though some file systems may delay the update.
+
+On non-Windows systems,
+each of these methods returns the metadata-change time for an entry:
+
+- File::ctime.
+- File#ctime.
+- File::Stat#ctime.
+- Pathname#ctime.
+
+On Windows, each `ctime` method returns the birth time,
+not the metadata-change time.
diff --git a/doc/float.rb b/doc/float.rb
new file mode 100644
index 0000000000..93b57ebc4c
--- /dev/null
+++ b/doc/float.rb
@@ -0,0 +1,128 @@
+# A \Float object stores a real number
+# using the native architecture's double-precision floating-point representation.
+#
+# == \Float Imprecisions
+#
+# Some real numbers can be represented precisely as \Float objects:
+#
+# 37.5 # => 37.5
+# 98.75 # => 98.75
+# 12.3125 # => 12.3125
+#
+# Others cannot; among these are the transcendental numbers, including:
+#
+# - Pi, <i>Ï€</i>: in mathematics, a number of infinite precision:
+# 3.1415926535897932384626433... (to 25 places);
+# in Ruby, it is of limited precision (in this case, to 16 decimal places):
+#
+# Math::PI # => 3.141592653589793
+#
+# - Euler's number, <i>e</i>: in mathematics, a number of infinite precision:
+# 2.7182818284590452353602874... (to 25 places);
+# in Ruby, it is of limited precision (in this case, to 15 decimal places):
+#
+# Math::E # => 2.718281828459045
+#
+# Some floating-point computations in Ruby give precise results:
+#
+# 1.0/2 # => 0.5
+# 100.0/8 # => 12.5
+#
+# Others do not:
+#
+# - In mathematics, 2/3 as a decimal number is an infinitely-repeating decimal:
+# 0.666... (forever);
+# in Ruby, +2.0/3+ is of limited precision (in this case, to 16 decimal places):
+#
+# 2.0/3 # => 0.6666666666666666
+#
+# - In mathematics, the square root of 2 is an irrational number of infinite precision:
+# 1.4142135623730950488016887... (to 25 decimal places);
+# in Ruby, it is of limited precision (in this case, to 16 decimal places):
+#
+# Math.sqrt(2.0) # => 1.4142135623730951
+#
+# - Even a simple computation can introduce imprecision:
+#
+# x = 0.1 + 0.2 # => 0.30000000000000004
+# y = 0.3 # => 0.3
+# x == y # => false
+#
+# See:
+#
+# - https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
+# - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#user-content--why-are-rubys-floats-imprecise
+# - https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
+#
+# Note that precise storage and computation of rational numbers
+# is possible using Rational objects.
+#
+# == Creating a \Float
+#
+# You can create a \Float object explicitly with:
+#
+# - A {floating-point literal}[rdoc-ref:syntax/literals.rdoc@Float+Literals].
+#
+# You can convert certain objects to Floats with:
+#
+# - Method #Float.
+#
+# == What's Here
+#
+# First, what's elsewhere. Class \Float:
+#
+# - Inherits from
+# {class Numeric}[rdoc-ref:Numeric@Whats+Here]
+# and {class Object}[rdoc-ref:Object@Whats+Here].
+# - Includes {module Comparable}[rdoc-ref:Comparable@Whats+Here].
+#
+# Here, class \Float provides methods for:
+#
+# - {Querying}[rdoc-ref:Float@Querying]
+# - {Comparing}[rdoc-ref:Float@Comparing]
+# - {Converting}[rdoc-ref:Float@Converting]
+#
+# === Querying
+#
+# - #finite?: Returns whether +self+ is finite.
+# - #hash: Returns the integer hash code for +self+.
+# - #infinite?: Returns whether +self+ is infinite.
+# - #nan?: Returns whether +self+ is a NaN (not-a-number).
+#
+# === Comparing
+#
+# - #<: Returns whether +self+ is less than the given value.
+# - #<=: Returns whether +self+ is less than or equal to the given value.
+# - #<=>: Returns a number indicating whether +self+ is less than, equal
+# to, or greater than the given value.
+# - #== (aliased as #=== and #eql?): Returns whether +self+ is equal to
+# the given value.
+# - #>: Returns whether +self+ is greater than the given value.
+# - #>=: Returns whether +self+ is greater than or equal to the given value.
+#
+# === Converting
+#
+# - #% (aliased as #modulo): Returns +self+ modulo the given value.
+# - #*: Returns the product of +self+ and the given value.
+# - #**: Returns the value of +self+ raised to the power of the given value.
+# - #+: Returns the sum of +self+ and the given value.
+# - #-: Returns the difference of +self+ and the given value.
+# - #/: Returns the quotient of +self+ and the given value.
+# - #ceil: Returns the smallest number greater than or equal to +self+.
+# - #coerce: Returns a 2-element array containing the given value converted to a \Float
+# and +self+
+# - #divmod: Returns a 2-element array containing the quotient and remainder
+# results of dividing +self+ by the given value.
+# - #fdiv: Returns the \Float result of dividing +self+ by the given value.
+# - #floor: Returns the greatest number smaller than or equal to +self+.
+# - #next_float: Returns the next-larger representable \Float.
+# - #prev_float: Returns the next-smaller representable \Float.
+# - #quo: Returns the quotient from dividing +self+ by the given value.
+# - #round: Returns +self+ rounded to the nearest value, to a given precision.
+# - #to_i (aliased as #to_int): Returns +self+ truncated to an Integer.
+# - #to_s (aliased as #inspect): Returns a string containing the place-value
+# representation of +self+ in the given radix.
+# - #truncate: Returns +self+ truncated to a given precision.
+#
+
+ class Float; end
diff --git a/doc/format_specifications.rdoc b/doc/format_specifications.rdoc
deleted file mode 100644
index e589524f27..0000000000
--- a/doc/format_specifications.rdoc
+++ /dev/null
@@ -1,348 +0,0 @@
-== Format Specifications
-
-Several Ruby core classes have instance method +printf+ or +sprintf+:
-
-- ARGF#printf
-- IO#printf
-- Kernel#printf
-- Kernel#sprintf
-
-Each of these methods takes:
-
-- Argument +format_string+, which has zero or more
- embedded _format_ _specifications_ (see below).
-- Arguments <tt>*arguments</tt>, which are zero or more objects to be formatted.
-
-Each of these methods prints or returns the string
-resulting from replacing each
-format specification embedded in +format_string+ with a string form
-of the corresponding argument among +arguments+.
-
-A simple example:
-
- sprintf('Name: %s; value: %d', 'Foo', 0) # => "Name: Foo; value: 0"
-
-A format specification has the form:
-
- %[flags][width][.precision]type
-
-It consists of:
-
-- A leading percent character.
-- Zero or more _flags_ (each is a character).
-- An optional _width_ _specifier_ (an integer).
-- An optional _precision_ _specifier_ (a period followed by a non-negative integer).
-- A _type_ _specifier_ (a character).
-
-Except for the leading percent character,
-the only required part is the type specifier, so we begin with that.
-
-=== Type Specifiers
-
-This section provides a brief explanation of each type specifier.
-The links lead to the details and examples.
-
-==== \Integer Type Specifiers
-
-- +b+ or +B+: Format +argument+ as a binary integer.
- See {Specifiers b and B}[rdoc-ref:format_specifications.rdoc@Specifiers+b+and+B].
-- +d+, +i+, or +u+ (all are identical):
- Format +argument+ as a decimal integer.
- See {Specifier d}[rdoc-ref:format_specifications.rdoc@Specifier+d].
-- +o+: Format +argument+ as an octal integer.
- See {Specifier o}[rdoc-ref:format_specifications.rdoc@Specifier+o].
-- +x+ or +X+: Format +argument+ as a hexadecimal integer.
- See {Specifiers x and X}[rdoc-ref:format_specifications.rdoc@Specifiers+x+and+X].
-
-==== Floating-Point Type Specifiers
-
-- +a+ or +A+: Format +argument+ as hexadecimal floating-point number.
- See {Specifiers a and A}[rdoc-ref:format_specifications.rdoc@Specifiers+a+and+A].
-- +e+ or +E+: Format +argument+ in scientific notation.
- See {Specifiers e and E}[rdoc-ref:format_specifications.rdoc@Specifiers+e+and+E].
-- +f+: Format +argument+ as a decimal floating-point number.
- See {Specifier f}[rdoc-ref:format_specifications.rdoc@Specifier+f].
-- +g+ or +G+: Format +argument+ in a "general" format.
- See {Specifiers g and G}[rdoc-ref:format_specifications.rdoc@Specifiers+g+and+G].
-
-==== Other Type Specifiers
-
-- +c+: Format +argument+ as a character.
- See {Specifier c}[rdoc-ref:format_specifications.rdoc@Specifier+c].
-- +p+: Format +argument+ as a string via <tt>argument.inspect</tt>.
- See {Specifier p}[rdoc-ref:format_specifications.rdoc@Specifier+p].
-- +s+: Format +argument+ as a string via <tt>argument.to_s</tt>.
- See {Specifier s}[rdoc-ref:format_specifications.rdoc@Specifier+s].
-- <tt>%</tt>: Format +argument+ (<tt>'%'</tt>) as a single percent character.
- See {Specifier %}[rdoc-ref:format_specifications.rdoc@Specifier+-25].
-
-=== Flags
-
-The effect of a flag may vary greatly among type specifiers.
-These remarks are general in nature.
-See {type-specific details}[rdoc-ref:format_specifications.rdoc@Type+Specifier+Details+and+Examples].
-
-Multiple flags may be given with single type specifier;
-order does not matter.
-
-==== <tt>' '</tt> Flag
-
-Insert a space before a non-negative number:
-
- sprintf('%d', 10) # => "10"
- sprintf('% d', 10) # => " 10"
-
-Insert a minus sign for negative value:
-
- sprintf('%d', -10) # => "-10"
- sprintf('% d', -10) # => "-10"
-
-==== <tt>'#'</tt> Flag
-
-Use an alternate format; varies among types:
-
- sprintf('%x', 100) # => "64"
- sprintf('%#x', 100) # => "0x64"
-
-==== <tt>'+'</tt> Flag
-
-Add a leading plus sign for a non-negative number:
-
- sprintf('%x', 100) # => "64"
- sprintf('%+x', 100) # => "+64"
-
-==== <tt>'-'</tt> Flag
-
-Left justify the value in its field:
-
- sprintf('%6d', 100) # => " 100"
- sprintf('%-6d', 100) # => "100 "
-
-==== <tt>'0'</tt> Flag
-
-Left-pad with zeros instead of spaces:
-
- sprintf('%6d', 100) # => " 100"
- sprintf('%06d', 100) # => "000100"
-
-==== <tt>'*'</tt> Flag
-
-Use the next argument as the field width:
-
- sprintf('%d', 20, 14) # => "20"
- sprintf('%*d', 20, 14) # => " 14"
-
-==== <tt>'n$'</tt> Flag
-
-Format the (1-based) <tt>n</tt>th argument into this field:
-
- sprintf("%s %s", 'world', 'hello') # => "world hello"
- sprintf("%2$s %1$s", 'world', 'hello') # => "hello world"
-
-=== Width Specifier
-
-In general, a width specifier determines the minimum width (in characters)
-of the formatted field:
-
- sprintf('%10d', 100) # => " 100"
-
- # Left-justify if negative.
- sprintf('%-10d', 100) # => "100 "
-
- # Ignore if too small.
- sprintf('%1d', 100) # => "100"
-
-=== Precision Specifier
-
-A precision specifier is a decimal point followed by zero or more
-decimal digits.
-
-For integer type specifiers, the precision specifies the minimum number of
-digits to be written. If the precision is shorter than the integer, the result is
-padded with leading zeros. There is no modification or truncation of the result
-if the integer is longer than the precision:
-
- sprintf('%.3d', 1) # => "001"
- sprintf('%.3d', 1000) # => "1000"
-
- # If the precision is 0 and the value is 0, nothing is written
- sprintf('%.d', 0) # => ""
- sprintf('%.0d', 0) # => ""
-
-For the +a+/+A+, +e+/+E+, +f+/+F+ specifiers, the precision specifies
-the number of digits after the decimal point to be written:
-
- sprintf('%.2f', 3.14159) # => "3.14"
- sprintf('%.10f', 3.14159) # => "3.1415900000"
-
- # With no precision specifier, defaults to 6-digit precision.
- sprintf('%f', 3.14159) # => "3.141590"
-
-For the +g+/+G+ specifiers, the precision specifies
-the number of significant digits to be written:
-
- sprintf('%.2g', 123.45) # => "1.2e+02"
- sprintf('%.3g', 123.45) # => "123"
- sprintf('%.10g', 123.45) # => "123.45"
-
- # With no precision specifier, defaults to 6 significant digits.
- sprintf('%g', 123.456789) # => "123.457"
-
-For the +s+, +p+ specifiers, the precision specifies
-the number of characters to write:
-
- sprintf('%s', Time.now) # => "2022-05-04 11:59:16 -0400"
- sprintf('%.10s', Time.now) # => "2022-05-04"
-
-=== Type Specifier Details and Examples
-
-==== Specifiers +a+ and +A+
-
-Format +argument+ as hexadecimal floating-point number:
-
- sprintf('%a', 3.14159) # => "0x1.921f9f01b866ep+1"
- sprintf('%a', -3.14159) # => "-0x1.921f9f01b866ep+1"
- sprintf('%a', 4096) # => "0x1p+12"
- sprintf('%a', -4096) # => "-0x1p+12"
-
- # Capital 'A' means that alphabetical characters are printed in upper case.
- sprintf('%A', 4096) # => "0X1P+12"
- sprintf('%A', -4096) # => "-0X1P+12"
-
-==== Specifiers +b+ and +B+
-
-The two specifiers +b+ and +B+ behave identically
-except when flag <tt>'#'</tt>+ is used.
-
-Format +argument+ as a binary integer:
-
- sprintf('%b', 1) # => "1"
- sprintf('%b', 4) # => "100"
-
- # Prefix '..' for negative value.
- sprintf('%b', -4) # => "..100"
-
- # Alternate format.
- sprintf('%#b', 4) # => "0b100"
- sprintf('%#B', 4) # => "0B100"
-
-==== Specifier +c+
-
-Format +argument+ as a single character:
-
- sprintf('%c', 'A') # => "A"
- sprintf('%c', 65) # => "A"
-
-==== Specifier +d+
-
-Format +argument+ as a decimal integer:
-
- sprintf('%d', 100) # => "100"
- sprintf('%d', -100) # => "-100"
-
-Flag <tt>'#'</tt> does not apply.
-
-==== Specifiers +e+ and +E+
-
-Format +argument+ in
-{scientific notation}[https://en.wikipedia.org/wiki/Scientific_notation]:
-
- sprintf('%e', 3.14159) # => "3.141590e+00"
- sprintf('%E', -3.14159) # => "-3.141590E+00"
-
-==== Specifier +f+
-
-Format +argument+ as a floating-point number:
-
- sprintf('%f', 3.14159) # => "3.141590"
- sprintf('%f', -3.14159) # => "-3.141590"
-
-Flag <tt>'#'</tt> does not apply.
-
-==== Specifiers +g+ and +G+
-
-Format +argument+ using exponential form (+e+/+E+ specifier)
-if the exponent is less than -4 or greater than or equal to the precision.
-Otherwise format +argument+ using floating-point form (+f+ specifier):
-
- sprintf('%g', 100) # => "100"
- sprintf('%g', 100.0) # => "100"
- sprintf('%g', 3.14159) # => "3.14159"
- sprintf('%g', 100000000000) # => "1e+11"
- sprintf('%g', 0.000000000001) # => "1e-12"
-
- # Capital 'G' means use capital 'E'.
- sprintf('%G', 100000000000) # => "1E+11"
- sprintf('%G', 0.000000000001) # => "1E-12"
-
- # Alternate format.
- sprintf('%#g', 100000000000) # => "1.00000e+11"
- sprintf('%#g', 0.000000000001) # => "1.00000e-12"
- sprintf('%#G', 100000000000) # => "1.00000E+11"
- sprintf('%#G', 0.000000000001) # => "1.00000E-12"
-
-==== Specifier +o+
-
-Format +argument+ as an octal integer.
-If +argument+ is negative, it will be formatted as a two's complement
-prefixed with +..7+:
-
- sprintf('%o', 16) # => "20"
-
- # Prefix '..7' for negative value.
- sprintf('%o', -16) # => "..760"
-
- # Prefix zero for alternate format if positive.
- sprintf('%#o', 16) # => "020"
- sprintf('%#o', -16) # => "..760"
-
-==== Specifier +p+
-
-Format +argument+ as a string via <tt>argument.inspect</tt>:
-
- t = Time.now
- sprintf('%p', t) # => "2022-05-01 13:42:07.1645683 -0500"
-
-==== Specifier +s+
-
-Format +argument+ as a string via <tt>argument.to_s</tt>:
-
- t = Time.now
- sprintf('%s', t) # => "2022-05-01 13:42:07 -0500"
-
-Flag <tt>'#'</tt> does not apply.
-
-==== Specifiers +x+ and +X+
-
-Format +argument+ as a hexadecimal integer.
-If +argument+ is negative, it will be formatted as a two's complement
-prefixed with +..f+:
-
- sprintf('%x', 100) # => "64"
-
- # Prefix '..f' for negative value.
- sprintf('%x', -100) # => "..f9c"
-
- # Use alternate format.
- sprintf('%#x', 100) # => "0x64"
-
- # Alternate format for negative value.
- sprintf('%#x', -100) # => "0x..f9c"
-
-==== Specifier <tt>%</tt>
-
-Format +argument+ (<tt>'%'</tt>) as a single percent character:
-
- sprintf('%d %%', 100) # => "100 %"
-
-Flags do not apply.
-
-=== Reference by Name
-
-For more complex formatting, Ruby supports a reference by name.
-%<name>s style uses format style, but %{name} style doesn't.
-
-Examples:
-
- sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000
- sprintf("%{foo}f", { :foo => 1 }) # => "1f"
diff --git a/doc/forwardable.rd.ja b/doc/forwardable.rd.ja
deleted file mode 100644
index 171724b2e5..0000000000
--- a/doc/forwardable.rd.ja
+++ /dev/null
@@ -1,80 +0,0 @@
- -- forwatable.rb
- $Release Version: 1.1 $
- $Revision$
-
-=begin
-= Forwardable
-
-クラスã«å¯¾ã—メソッドã®å§”譲機能を定義ã—ã¾ã™.
-
-== ä½¿ã„æ–¹
-
-クラスã«å¯¾ã—ã¦extendã—ã¦ä½¿ã„ã¾ã™.
-
- class Foo
- extend Forwardable
-
- def_delegators("@out", "printf", "print")
- def_delegators(:@in, :gets)
- def_delegator(:@contents, :[], "content_at")
- end
- f = Foo.new
- f.printf ...
- f.gets
- f.content_at(1)
-
-== メソッド
-
---- Forwardable#def_instance_delegators(accessor, *methods)
-
- ((|methods|))ã§æ¸¡ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã®ãƒªã‚¹ãƒˆã‚’((|accessorã«|))委譲ã™ã‚‹
- よã†ã«ã—ã¾ã™.
-
---- Forwardable#def_instance_delegator(accessor, method, ali = method)
-
- ((||method|))ã§æ¸¡ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã‚’((|accessor|))ã«å§”è­²ã™ã‚‹ã‚ˆã†ã«ã—
- ã¾ã™. ((|ali|))ãŒå¼•æ•°ã¨ã—ã¦æ¸¡ã•れãŸã¨ãã¯, メソッド((|ali|))ãŒå‘¼ã°
- れãŸã¨ãã«ã¯, ((|accessor|))ã«å¯¾ã—((|method|))を呼ã³å‡ºã—ã¾ã™.
-
---- Forwardable#def_delegators(accessor, *methods)
-
- ((|Forwardable#def_instance_delegators|))ã®åˆ¥åã§ã™.
-
---- Forwardable#def_delegator(accessor, method, ali = method)
-
- ((|Forwardable#def_instance_delegator|))ã®åˆ¥åã§ã™.
-
-= SingleForwardable
-
-オブジェクトã«å¯¾ã—, メソッドã®å§”譲機能を定義ã—ã¾ã™.
-
-== ä½¿ã„æ–¹
-
-オブジェクトã«å¯¾ã—ã¦((|extend|))ã—ã¦ä½¿ã„ã¾ã™.
-
- g = Goo.new
- g.extend SingleForwardable
- g.def_delegator("@out", :puts)
- g.puts ...
-
-== メソッド
-
---- SingleForwardable#def_singleton_delegators(accessor, *methods)
-
- ((|methods|))ã§æ¸¡ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã®ãƒªã‚¹ãƒˆã‚’((|accessor|))ã«å§”è­²ã™ã‚‹
- よã†ã«ã—ã¾ã™.
-
---- SingleForwardable#def_singleton_delegator(accessor, method, ali = method)
-
- ((|method|))ã§æ¸¡ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã‚’((|accessor|))ã«å§”è­²ã™ã‚‹ã‚ˆã†ã«ã—ã¾
- ã™. ((|ali|))ãŒå¼•æ•°ã¨ã—ã¦æ¸¡ã•れãŸã¨ãã¯, メソッド((|ali|))ãŒå‘¼ã°ã‚Œ
- ãŸã¨ãã«ã¯, ((|accessor|))ã«å¯¾ã—((|method|))を呼ã³å‡ºã—ã¾ã™.
-
---- SingleForwardable#def_delegators(accessor, *methods)
-
- ((|SingleForwardable#def_singleton_delegators|))ã®åˆ¥åã§ã™.
-
---- SingleForwardable#def_delegator(accessor, method, ali = method)
-
- ((|SingleForwardable#def_singleton_delegator|))ã®åˆ¥åã§ã™.
-=end
diff --git a/doc/globals.rdoc b/doc/globals.rdoc
deleted file mode 100644
index 1d7cda69f9..0000000000
--- a/doc/globals.rdoc
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-
-== Pre-defined global variables
-
-$!:: The Exception object set by Kernel#raise.
-$@:: The same as <code>$!.backtrace</code>.
-$~:: The information about the last match in the current scope (thread-local and frame-local).
-$&:: The string matched by the last successful match.
-$`:: The string to the left of the last successful match.
-$':: The string to the right of the last successful match.
-$+:: The highest group matched by the last successful match.
-$1:: The Nth group of the last successful match. May be > 1.
-$=:: This variable is no longer effective. Deprecated.
-$/:: The input record separator, newline by default. Aliased to $-0.
-$\:: The output record separator for Kernel#print and IO#write. Default is +nil+.
-$,:: The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated.
-$;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F.
-$.:: The current input line number of the last file that was read.
-$<:: The same as ARGF.
-$>:: The default output stream for Kernel#print and Kernel#printf. $stdout by default.
-$_:: The last input line of string by gets or readline.
-$0:: Contains the name of the script being executed. May be assignable.
-$*:: The same as ARGV.
-$$:: The process number of the Ruby running this script. Same as Process.pid.
-$?:: The status of the last executed child process (thread-local).
-$LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used
- by Kernel#load and Kernel#require. Aliased to $: and $-I.
- Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
- that returns [+:rb+ or +:so+, path], which resolves the feature to
- the path the original Kernel#require method would load.
-$LOADED_FEATURES:: The array contains the module names loaded by require.
- Aliased to $".
-$DEBUG:: The debug flag, which is set by the <tt>-d</tt> switch. Enabling debug
- output prints each exception raised to $stderr (but not its
- backtrace). Setting this to a true value enables debug output as
- if <tt>-d</tt> were given on the command line. Setting this to a false
- value disables debug output. Aliased to $-d.
-$FILENAME:: Current input filename from ARGF. Same as ARGF.filename.
-$stderr:: The current standard error output.
-$stdin:: The current standard input.
-$stdout:: The current standard output.
-$VERBOSE:: The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
- Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
- on the command line. Setting this to +nil+ disables warnings,
- including from Kernel#warn. Aliased to $-v and $-w.
-$-a:: True if option <tt>-a</tt> is set. Read-only variable.
-$-i:: In in-place-edit mode, this variable holds the extension, otherwise +nil+.
-$-l:: True if option <tt>-l</tt> is set. Read-only variable.
-$-p:: True if option <tt>-p</tt> is set. Read-only variable.
-
-== Pre-defined global constants
-
-STDIN:: The standard input. The default value for $stdin.
-STDOUT:: The standard output. The default value for $stdout.
-STDERR:: The standard error output. The default value for $stderr.
-ENV:: The hash contains current environment variables.
-ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given).
-ARGV:: An Array of command line arguments given for the script.
-DATA:: The file object of the script, pointing just after <code>__END__</code>.
-TOPLEVEL_BINDING:: The Binding of the top level scope.
-RUBY_VERSION:: The Ruby language version.
-RUBY_RELEASE_DATE:: The release date string.
-RUBY_PLATFORM:: The platform identifier.
-RUBY_PATCHLEVEL:: The patchlevel for this Ruby. If this is a development build of Ruby the patchlevel will be -1.
-RUBY_REVISION:: The GIT commit hash for this Ruby.
-RUBY_COPYRIGHT:: The copyright string for Ruby.
-RUBY_ENGINE:: The name of the Ruby implementation.
-RUBY_ENGINE_VERSION:: The version of the Ruby implementation.
-RUBY_DESCRIPTION:: The same as <tt>ruby --version</tt>, a String describing various aspects of the Ruby implementation.
diff --git a/doc/implicit_conversion.rdoc b/doc/implicit_conversion.rdoc
deleted file mode 100644
index ba15fa4bf4..0000000000
--- a/doc/implicit_conversion.rdoc
+++ /dev/null
@@ -1,221 +0,0 @@
-== Implicit Conversions
-
-Some Ruby methods accept one or more objects
-that can be either:
-
-* <i>Of a given class</i>, and so accepted as is.
-* <i>Implicitly convertible to that class</i>, in which case
- the called method converts the object.
-
-For each of the relevant classes, the conversion is done by calling
-a specific conversion method:
-
-* Array: +to_ary+
-* Hash: +to_hash+
-* Integer: +to_int+
-* String: +to_str+
-
-=== Array-Convertible Objects
-
-An <i>Array-convertible object</i> is an object that:
-
-* Has instance method +to_ary+.
-* The method accepts no arguments.
-* The method returns an object +obj+ for which <tt>obj.kind_of?(Array)</tt> returns +true+.
-
-The Ruby core class that satisfies these requirements is:
-
-* Array
-
-The examples in this section use method <tt>Array#replace</tt>,
-which accepts an Array-convertible argument.
-
-This class is Array-convertible:
-
- class ArrayConvertible
- def to_ary
- [:foo, 'bar', 2]
- end
- end
- a = []
- a.replace(ArrayConvertible.new) # => [:foo, "bar", 2]
-
-This class is not Array-convertible (no +to_ary+ method):
-
- class NotArrayConvertible; end
- a = []
- # Raises TypeError (no implicit conversion of NotArrayConvertible into Array)
- a.replace(NotArrayConvertible.new)
-
-This class is not Array-convertible (method +to_ary+ takes arguments):
-
- class NotArrayConvertible
- def to_ary(x)
- [:foo, 'bar', 2]
- end
- end
- a = []
- # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
- a.replace(NotArrayConvertible.new)
-
-This class is not Array-convertible (method +to_ary+ returns non-Array):
-
- class NotArrayConvertible
- def to_ary
- :foo
- end
- end
- a = []
- # Raises TypeError (can't convert NotArrayConvertible to Array (NotArrayConvertible#to_ary gives Symbol))
- a.replace(NotArrayConvertible.new)
-
-=== Hash-Convertible Objects
-
-A <i>Hash-convertible object</i> is an object that:
-
-* Has instance method +to_hash+.
-* The method accepts no arguments.
-* The method returns an object +obj+ for which <tt>obj.kind_of?(Hash)</tt> returns +true+.
-
-The Ruby core class that satisfies these requirements is:
-
-* Hash
-
-The examples in this section use method <tt>Hash#merge</tt>,
-which accepts a Hash-convertible argument.
-
-This class is Hash-convertible:
-
- class HashConvertible
- def to_hash
- {foo: 0, bar: 1, baz: 2}
- end
- end
- h = {}
- h.merge(HashConvertible.new) # => {:foo=>0, :bar=>1, :baz=>2}
-
-This class is not Hash-convertible (no +to_hash+ method):
-
- class NotHashConvertible; end
- h = {}
- # Raises TypeError (no implicit conversion of NotHashConvertible into Hash)
- h.merge(NotHashConvertible.new)
-
-This class is not Hash-convertible (method +to_hash+ takes arguments):
-
- class NotHashConvertible
- def to_hash(x)
- {foo: 0, bar: 1, baz: 2}
- end
- end
- h = {}
- # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
- h.merge(NotHashConvertible.new)
-
-This class is not Hash-convertible (method +to_hash+ returns non-Hash):
-
- class NotHashConvertible
- def to_hash
- :foo
- end
- end
- h = {}
- # Raises TypeError (can't convert NotHashConvertible to Hash (ToHashReturnsNonHash#to_hash gives Symbol))
- h.merge(NotHashConvertible.new)
-
-=== Integer-Convertible Objects
-
-An <i>Integer-convertible object</i> is an object that:
-
-* Has instance method +to_int+.
-* The method accepts no arguments.
-* The method returns an object +obj+ for which <tt>obj.kind_of?(Integer)</tt> returns +true+.
-
-The Ruby core classes that satisfy these requirements are:
-
-* Integer
-* Float
-* Complex
-* Rational
-
-The examples in this section use method <tt>Array.new</tt>,
-which accepts an Integer-convertible argument.
-
-This user-defined class is Integer-convertible:
-
- class IntegerConvertible
- def to_int
- 3
- end
- end
- a = Array.new(IntegerConvertible.new).size
- a # => 3
-
-This class is not Integer-convertible (method +to_int+ takes arguments):
-
- class NotIntegerConvertible
- def to_int(x)
- 3
- end
- end
- # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
- Array.new(NotIntegerConvertible.new)
-
-This class is not Integer-convertible (method +to_int+ returns non-Integer):
-
- class NotIntegerConvertible
- def to_int
- :foo
- end
- end
- # Raises TypeError (can't convert NotIntegerConvertible to Integer (NotIntegerConvertible#to_int gives Symbol))
- Array.new(NotIntegerConvertible.new)
-
-=== String-Convertible Objects
-
-A <i>String-convertible object</i> is an object that:
-* Has instance method +to_str+.
-* The method accepts no arguments.
-* The method returns an object +obj+ for which <tt>obj.kind_of?(String)</tt> returns +true+.
-
-The Ruby core class that satisfies these requirements is:
-
-* String
-
-The examples in this section use method <tt>String::new</tt>,
-which accepts a String-convertible argument.
-
-This class is String-convertible:
-
- class StringConvertible
- def to_str
- 'foo'
- end
- end
- String.new(StringConvertible.new) # => "foo"
-
-This class is not String-convertible (no +to_str+ method):
-
- class NotStringConvertible; end
- # Raises TypeError (no implicit conversion of NotStringConvertible into String)
- String.new(NotStringConvertible.new)
-
-This class is not String-convertible (method +to_str+ takes arguments):
-
- class NotStringConvertible
- def to_str(x)
- 'foo'
- end
- end
- # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
- String.new(NotStringConvertible.new)
-
-This class is not String-convertible (method +to_str+ returns non-String):
-
- class NotStringConvertible
- def to_str
- :foo
- end
- end
- # Raises TypeError (can't convert NotStringConvertible to String (NotStringConvertible#to_str gives Symbol))
- String.new(NotStringConvertible.new)
diff --git a/doc/index.md b/doc/index.md
new file mode 100644
index 0000000000..596825a19c
--- /dev/null
+++ b/doc/index.md
@@ -0,0 +1,65 @@
+# Ruby Documentation
+
+Welcome to the official Ruby programming language documentation.
+
+## Getting Started
+
+New to Ruby? Start with our [Getting Started Guide](https://www.ruby-lang.org/en/documentation/quickstart/).
+
+## Core Classes and Modules
+
+Explore the essential classes and modules:
+
+- [String](String.html) - Text manipulation and string utilities.
+- [Symbol](Symbol.html) - Named identifiers inside the Ruby interpreter.
+- [Array](Array.html) - Ordered collections of objects.
+- [Hash](Hash.html) - Key-value pairs for efficient data retrieval.
+- [Integer](Integer.html) - \Integer number class.
+- [Float](Float.html) - Floating-point number class.
+- [Enumerable](Enumerable.html) - Collection traversal and searching.
+- [File](File.html) - \File operations and handling.
+- [IO](IO.html) - Input/output functionality.
+- [Time](Time.html) - \Time representation.
+- [Regexp](Regexp.html) - Regular expressions for pattern matching.
+- [Range](Range.html) - Representing a range of values.
+- [Exception](Exception.html) - Base class for all exceptions.
+- [Thread](Thread.html) - Multithreading and concurrency.
+
+## Language Reference
+
+Deep dive into Ruby's syntax and features:
+
+- [Ruby Syntax](rdoc-ref:syntax.rdoc)
+- [Exceptions](rdoc-ref:exceptions.md)
+- [Implicit Conversions](rdoc-ref:implicit_conversion.rdoc)
+
+## Standard Libraries
+
+There are some standard libraries included in Ruby that are also commonly used, such as:
+
+- [Date](Date.html) - \Date representation.
+- [JSON](JSON.html) - \JSON encoding and decoding.
+- [ERB](ERB.html) - Embedded Ruby for templating.
+- [Net::HTTP](Net/HTTP.html) - HTTP client library.
+
+Use the following links to access the comprehensive set of libraries included with Ruby:
+
+- [Standard Library Documentation](rdoc-ref:standard_library.md)
+- [Maintainers](rdoc-ref:maintainers.md)
+
+## Contribute to Ruby
+
+Get involved with the Ruby community:
+
+- [Contribution Guide](rdoc-ref:contributing/contributing.md)
+- [Documentation Guide](rdoc-ref:contributing/documentation_guide.md)
+- [Reporting Issues](rdoc-ref:contributing/reporting_issues.md)
+- [Building Ruby](rdoc-ref:contributing/building_ruby.md)
+- [Testing Ruby](rdoc-ref:contributing/testing_ruby.md)
+- [Issue Tracker](https://bugs.ruby-lang.org/projects/ruby-master/issues)
+
+## Additional Resources
+
+- [Ruby Homepage](https://www.ruby-lang.org/)
+- [RubyGems](https://rubygems.org/)
+- [Ruby Community](https://www.ruby-lang.org/en/community/)
diff --git a/doc/irb/irb-tools.rd.ja b/doc/irb/irb-tools.rd.ja
deleted file mode 100644
index b997f0edea..0000000000
--- a/doc/irb/irb-tools.rd.ja
+++ /dev/null
@@ -1,184 +0,0 @@
-irb関連ãŠã¾ã‘コマンドã¨ãƒ©ã‚¤ãƒ–ラリ
- $Release Version: 0.7.1 $
- $Revision$
- by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.)
-
-=begin
-
-:コマンド:
-* rtags -- ruby tags command
-
-:関数ライブラリ:
-* xmp -- irb version of gotoken xmp-function
-
-:クラスライブラリ:
-* frame.rb -- frame tracer
-* completion.rb -- irb completor
-
-= rtags
-
-rtagsã¯emacsåŠã³vi用ã®, TAGファイルをã¤ãるコマンドã§ã™.
-
-== ä½¿ã„æ–¹
-
- rtags [-vi] file....
-
-カレントディレクトリã«emacs用ã®TAGSファイルãŒã§ãã¾ã™. -viオプションを
-ã¤ã‘ãŸæ™‚ã«ã¯vi用ã®tagsファイルを作æˆã—ã¾ã™.
-
-emacsã®å ´åˆ, 通常ã®etags.elãŒãã®ã¾ã¾ä½¿ãˆã¾ã™. 検索å¯èƒ½ãªã®ã¯,
-
-* クラス
-* メソッド
-* 特異メソッド
-* alias
-* attrã§å®£è¨€ã•れãŸã‚¢ã‚¯ã‚»ã‚µ(パラメータãŒã‚·ãƒ³ãƒœãƒ«ã‹æ–‡å­—列リテラルã«é™ã‚‹)
-* attr_XXXã§å®£è¨€ã•れãŸã‚¢ã‚¯ã‚»ã‚µ(パラメータãŒã‚·ãƒ³ãƒœãƒ«ã‹æ–‡å­—列リテラルã«é™ã‚‹)
-
-ã§ã™.
-
-Cãªã©ã§ä½¿ã£ã¦ã„ã‚‹ã®ã¨é•ã†ã®ã¯, コンプリーションã«é–¢ã™ã‚‹éƒ¨åˆ†ã§,
-
-関数åã¯,
-
- 関数å(
-
-クラスã¯,
-
- ::クラスå::....::クラスå
-
-メソッドã¯,
-
- ::クラスå::....::クラスå#メソッドå
-
-特異メソッド(クラスメソッド)ã¯
-
- ::クラスå::....::クラスå.メソッドå
-
-ã§ã‚³ãƒ³ãƒ—リーションを行ãªã†ã¨ã“ã‚ã§ã™.
-
-= xmp.rb
-
-ã”ã¨ã‘ã‚“xmpã®ä¸Šä½äº’æ›ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã™. ãŸã , éžå¸¸ã«é‡ã„ã®ã§ã”ã¨ã‘ã‚“xmpã§
-ã¯å¯¾å¿œã§ããªã„時ã«, 使用ã™ã‚‹ã¨è‰¯ã„ã§ã—ょã†.
-
-== ä½¿ã„æ–¹
-
-=== 関数ã¨ã—ã¦ä½¿ã†.
-
- require "irb/xmp"
- xmp <<END
- foo = 1
- foo
- END
- ---
- foo = 1
- ==>1
- foo
- ==>1
-
-=== XMPインスタンスを用ã„ã‚‹.
-
-ã“ã®å ´åˆã¯, XMPãŒã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆæƒ…報をæŒã¤ã®ã§, 変数ã®å€¤ãªã©ã‚’ä¿æŒã—ã¦ã„
-ã¾ã™.
-
- require "irb/xmp"
- xmp = XMP.new
- xmp.puts <<END
- foo = 1
- foo
- END
- xmp.puts <<END
- foo
- END
- ===
- foo = 1
- ==>1
- foo
- ==>1
- foo
- ==>1
-
-== コンテキストã«é–¢ã—ã¦
-
-XMPメソッド群ã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã¯, 呼ã³å‡ºã™å‰ã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã§è©•価ã•れã¾ã™.
-明示的ã«ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã‚’指定ã™ã‚‹ã¨ãã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã§è©•価ã—ã¾ã™.
-
-例:
-
- xmp "foo", an_binding
-
-:注:
-マルãƒã‚¹ãƒ¬ãƒƒãƒ‰ã«ã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“.
-
-= frame.rb
-ç¾åœ¨å®Ÿè¡Œä¸­ã®ãƒ•レーム情報をå–り扱ã†ãŸã‚ã®ã‚¯ãƒ©ã‚¹ã§ã™.
-
-* IRB::Frame.top(n = 0)
- 上ã‹ã‚‰n番目ã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã‚’å–り出ã—ã¾ã™. nã¯0ãŒæœ€ä¸Šä½ã«ãªã‚Šã¾ã™.
-* IRB::Frame.bottom(n = 0)
- 下ã‹ã‚‰n番目ã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã‚’å–り出ã—ã¾ã™. nã¯0ãŒæœ€ä¸‹ä½ã«ãªã‚Šã¾ã™.
-* IRB::Frame.sender
- センダã«ãªã£ã¦ã„るオブジェクトをå–り出ã—ã¾ã™. センダã¨ã¯, ãã®ãƒ¡ã‚½ãƒƒ
- ドを呼ã³å‡ºã—ãŸå´ã®selfã®ã“ã¨ã§ã™.
-
-:注:
-set_trace_funcを用ã„ã¦Rubyã®å®Ÿè¡Œã‚’トレースã—ã¦ã„ã¾ã™. マルãƒã‚¹ãƒ¬ãƒƒãƒ‰ã«
-ã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“.
-
-= completion.rb
-irbã®completion機能をæä¾›ã™ã‚‹ã‚‚ã®ã§ã™.
-
-== ä½¿ã„æ–¹
-
- % irb -r irb/completion
-
-ã¨ã™ã‚‹ã‹, ~/.irbrc 中ã«
-
- require "irb/completion"
-
-を入れã¦ãã ã•ã„. irb実行中㫠require "irb/completion" ã—ã¦ã‚‚よã„ã§ã™.
-
-irb実行中㫠(TAB) を押ã™ã¨ã‚³ãƒ³ãƒ—レーションã—ã¾ã™.
-
-トップレベルã§(TAB)を押ã™ã¨ã™ã¹ã¦ã®æ§‹æ–‡è¦ç´ , クラス, メソッドã®å€™è£œãŒã§
-ã¾ã™. 候補ãŒå”¯ä¸€ãªã‚‰ã°å®Œå…¨ã«è£œå®Œã—ã¾ã™.
-
- irb(main):001:0> in
- in inspect instance_eval
- include install_alias_method instance_of?
- initialize install_aliases instance_variables
- irb(main):001:0> inspect
- "main"
- irb(main):002:0> foo = Object.new
- #<Object:0x4027146c>
-
- ((|変数å.|))ã®å¾Œã«(TAB)を押ã™ã¨, ãã®ã‚ªãƒ–ジェクトã®ãƒ¡ã‚½ãƒƒãƒ‰ä¸€è¦§ãŒã§ã¾
- ã™.
-
- irb(main):003:0> foo.
- foo.== foo.frozen? foo.protected_methods
- foo.=== foo.hash foo.public_methods
- foo.=~ foo.id foo.respond_to?
- foo.__id__ foo.inspect foo.send
- foo.__send__ foo.instance_eval foo.singleton_methods
- foo.class foo.instance_of? foo.taint
- foo.clone foo.instance_variables foo.tainted?
- foo.display foo.is_a? foo.to_a
- foo.dup foo.kind_of? foo.to_s
- foo.eql? foo.method foo.type
- foo.equal? foo.methods foo.untaint
- foo.extend foo.nil?
- foo.freeze foo.private_methods
-
-=end
-
-% Begin Emacs Environment
-% Local Variables:
-% mode: text
-% comment-column: 0
-% comment-start: "%"
-% comment-end: "\n"
-% End:
-%
-
diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja
deleted file mode 100644
index 633c08cbd4..0000000000
--- a/doc/irb/irb.rd.ja
+++ /dev/null
@@ -1,427 +0,0 @@
-irb -- interactive ruby
- $Release Version: 0.9.5 $
- $Revision$
- by Keiju ISHITSUKA(keiju@ruby-lang.org)
-=begin
-= irbã¨ã¯?
-
-irbã¯interactive rubyã®ç•¥ã§ã™. rubyã®å¼ã‚’標準入力ã‹ã‚‰ç°¡å˜ã«å…¥åŠ›/実行ã™ã‚‹
-ãŸã‚ã®ãƒ„ールã§ã™.
-
-= èµ·å‹•
-
- % irb
-
-ã§è¡Œãªã„ã¾ã™.
-
-= ä½¿ã„æ–¹
-
-irbã®ä½¿ã„æ–¹ã¯, Rubyã•ãˆçŸ¥ã£ã¦ã„れã°ã„ãŸã£ã¦ç°¡å˜ã§ã™. 基本的ã«ã¯ irb ã¨
-ã„ã†ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã™ã‚‹ã ã‘ã§ã™. irbを実行ã™ã‚‹ã¨, 以下ã®ã‚ˆã†ãªãƒ—ロンプ
-トãŒè¡¨ã‚Œã¦ãã¾ã™. 後ã¯, rubyã®å¼ã‚’入れã¦ä¸‹ã•ã„. å¼ãŒå®Œçµã—ãŸæ™‚点ã§å®Ÿè¡Œ
-ã•れã¾ã™.
-
- dim% irb
- irb(main):001:0> 1+2
- 3
- irb(main):002:0> class Foo
- irb(main):003:1> def foo
- irb(main):004:2> print 1
- irb(main):005:2> end
- irb(main):006:1> end
- nil
- irb(main):007:0>
-
-ã¾ãŸ, irbã¯Readlineモジュールã«ã‚‚対応ã—ã¦ã„ã¾ã™. ReadlineモジュールãŒ
-インストールã•れã¦ã„る時ã«ã¯, ãれを使ã†ã®ãŒæ¨™æº–ã®å‹•作ã«ãªã‚Šã¾ã™.
-
-= コマンドオプション
-
- irb.rb [options] file_name opts
- options:
- -f ~/.irbrc を読ã¿è¾¼ã¾ãªã„.
- -d $DEBUG ã‚’trueã«ã™ã‚‹(ruby -d ã¨åŒã˜)
- -r load-module ruby -r ã¨åŒã˜.
- -I path $LOAD_PATH ã« path を追加ã™ã‚‹.
- -U ruby -U ã¨åŒã˜.
- -E enc ruby -E ã¨åŒã˜.
- -w ruby -w ã¨åŒã˜.
- -W[level=2] ruby -W ã¨åŒã˜.
- --context-mode n æ–°ã—ã„ワークスペースを作æˆã—ãŸæ™‚ã«é–¢é€£ã™ã‚‹ Binding
- オブジェクトã®ä½œæˆæ–¹æ³•ã‚’ 0 ã‹ã‚‰ 3 ã®ã„ãšã‚Œã‹ã«è¨­å®šã™ã‚‹.
- --echo å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト).
- --noecho å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„.
- --echo-on-assignment
- 代入時ã«å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹.
- --noecho-on-assignment
- 代入時ã«å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„.
- --truncate-echo-on-assignment
- 代入時ã«çœç•¥ã•れãŸå®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト).
- --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹.
- --noinspect çµæžœå‡ºåŠ›ã«inspectを用ã„ãªã„.
- --singleline シングルラインエディタを利用ã™ã‚‹.
- --nosingleline シングルラインエディタを利用ã—ãªã„. デフォルトã®å‹•
- 作ã¯, inf-ruby-mode以外ã§ã‚·ãƒ³ã‚°ãƒ«ãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利
- 用ã—よã†ã¨ã™ã‚‹.
- --colorize 色付ã‘を利用ã™ã‚‹.
- --nocolorize 色付ã‘を利用ã—ãªã„.
- --autocomplete オートコンプリートを利用ã™ã‚‹.
- --noautocomplete オートコンプリートを利用ã—ãªã„.
- --prompt prompt-mode
- --prompt-mode prompt-mode
- プロンプトモードを切替ãˆã¾ã™. ç¾åœ¨å®šç¾©ã•れã¦ã„るプ
- ロンプトモードã¯, default, simple, xmp, inf-rubyãŒ
- 用æ„ã•れã¦ã„ã¾ã™.
- --inf-ruby-mode emacsã®inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. 特
- ã«æŒ‡å®šãŒãªã„é™ã‚Š, ラインエディタã¯ä½¿ã‚ãªããªã‚‹.
- --simple-prompt
- éžå¸¸ã«ã‚·ãƒ³ãƒ—ルãªãƒ—ロンプトを用ã„るモードã§ã™.
- --noprompt プロンプト表示を行ãªã‚ãªã„.
- --single-irb irb 中㧠self を実行ã—ã¦å¾—られるオブジェクトをサ
- ブ irb ã¨å…±æœ‰ã™ã‚‹.
- --tracer コマンド実行時ã«ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’行ãªã†.
- --back-trace-limit n
- ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰ n, 後ã‚
- ã‹ã‚‰nã ã‘行ãªã†. デフォルトã¯16
-
- --verbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹.
- --noverbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ãªã„(デフォルト).
- -v, --version irbã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’表示ã™ã‚‹.
- -h, --help irb ã®ãƒ˜ãƒ«ãƒ—を表示ã™ã‚‹.
- -- 以é™ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数をオプションã¨ã—ã¦æ‰±ã‚ãªã„.
-
-= コンフィギュレーション
-
-irb起動時ã«``~/.irbrc''を読ã¿è¾¼ã¿ã¾ã™. ã‚‚ã—存在ã—ãªã„å ´åˆã¯,
-``.irbrc'', ``irb.rc'', ``_irbrc'', ``$irbrc''ã®é †ã«loadを試ã¿ã¾ã™.
-
-オプションを設定ã™ã‚‹ä»£ã‚りã«, 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã§ã‚‚デフォルトã®å‹•作を設定
-ã§ãã¾ã™.
-
- IRB.conf[:IRB_NAME]="irb"
- IRB.conf[:USE_TRACER]=false
- IRB.conf[:USE_LOADER]=false
- IRB.conf[:IGNORE_SIGINT]=true
- IRB.conf[:IGNORE_EOF]=false
- IRB.conf[:INSPECT_MODE]=nil
- IRB.conf[:IRB_RC] = nil
- IRB.conf[:BACK_TRACE_LIMIT]=16
- IRB.conf[:USE_LOADER] = false
- IRB.conf[:USE_SINGLELINE] = nil
- IRB.conf[:USE_TRACER] = false
- IRB.conf[:IGNORE_SIGINT] = true
- IRB.conf[:IGNORE_EOF] = false
- IRB.conf[:PROMPT_MODE] = :DEFAULT
- IRB.conf[:PROMPT] = {...}
- IRB.conf[:VERBOSE]=true
-
-== プロンプトã®è¨­å®š
-
-プロンプトをカスタマイズã—ãŸã„時ã«ã¯,
-
- IRB.conf[:PROMPT]
-
-を用ã„ã¾ã™. 例ãˆã°, .irbrcã®ä¸­ã§ä¸‹ã®ã‚ˆã†ãªå¼ã‚’記述ã—ã¾ã™:
-
- IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードã®åå‰
- :PROMPT_I => nil, # 通常ã®ãƒ—ロンプト
- :PROMPT_N => nil, # 継続行ã®ãƒ—ロンプト
- :PROMPT_S => nil, # 文字列ãªã©ã®ç¶™ç¶šè¡Œã®ãƒ—ロンプト
- :PROMPT_C => nil, # å¼ãŒç¶™ç¶šã—ã¦ã„る時ã®ãƒ—ロンプト
- :RETURN => " ==>%s\n" # リターン時ã®ãƒ—ロンプト
- }
-
-プロンプトモードを指定ã—ãŸã„時ã«ã¯,
-
- irb --prompt my-prompt
-
-ã§ãã®ãƒ—ロンプトモードã§èµ·å‹•ã•れã¾ã™. ã¾ãŸã¯, .irbrcã«ä¸‹å¼ã‚’記述ã—ã¦ã‚‚
-OKã§ã™.
-
- IRB.conf[:PROMPT_MODE] = :MY_PROMPT
-
-PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cã¯, フォーマットを指定ã—ã¾ã™.
-
- %N èµ·å‹•ã—ã¦ã„るコマンドåãŒå‡ºåŠ›ã•れる.
- %m mainオブジェクト(self)ãŒto_sã§å‡ºåŠ›ã•れる.
- %M mainオブジェクト(self)ãŒinspectã•れã¦å‡ºåŠ›ã•れる.
- %l 文字列中ã®ã‚¿ã‚¤ãƒ—を表ã™(", ', /, ], `]'ã¯%wã®ä¸­ã®æ™‚)
- %NNi インデントã®ãƒ¬ãƒ™ãƒ«ã‚’表ã™. NNã¯æ•°å­—ãŒå…¥ã‚Šprintfã®%NNdã¨åŒã˜. çœ
- ç•¥å¯èƒ½
- %NNn 行番å·ã‚’表ã—ã¾ã™.
- %% %
-
-例ãˆã°, デフォルトã®ãƒ—ロンプトモードã¯:
-
- IRB.conf[:PROMPT][:DEFAULT] = {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "=> %s\n"
- }
-
-ã¨ãªã£ã¦ã„ã¾ã™.
-
-RETURNã¯, ç¾åœ¨ã®ã¨ã“ã‚printfå½¢å¼ã§ã™. å°†æ¥ä»•様ãŒå¤‰ã‚ã‚‹ã‹ã‚‚知れã¾ã›ã‚“.
-
-== サブirbã®è¨­å®š
-
-コマンドラインオプションãŠã‚ˆã³IRB.confã¯(サブ)irb起動時ã®ãƒ‡ãƒ•ォルトã®
-設定を決ã‚ã‚‹ã‚‚ã®ã§, `5. コマンド'ã«ã‚ã‚‹confã§å€‹åˆ¥ã®(サブ)irbã®è¨­å®šãŒã§
-ãるよã†ã«ãªã£ã¦ã„ã¾ã™.
-
-IRB.conf[:IRB_RC]ã«procãŒè¨­å®šã•れã¦ã„ã‚‹ã¨, サブirbã‚’èµ·å‹•ã™ã‚‹æ™‚ã«ãã®
-procã‚’irbã®ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã‚’引数ã¨ã—ã¦å‘¼ã³å‡ºã—ã¾ã™. ã“れã«ã‚ˆã£ã¦å€‹åˆ¥ã®ã‚µ
-ブirbã”ã¨ã«è¨­å®šã‚’変ãˆã‚‹ã“ã¨ãŒã§ãるよã†ã«ãªã‚Šã¾ã™.
-
-
-= コマンド
-
-irb拡張コマンドã¯, ç°¡å˜ãªåå‰ã¨é ­ã«`irb_'ã‚’ã¤ã‘ãŸåå‰ã¨ä¸¡æ–¹å®šç¾©ã•れã¦
-ã„ã¾ã™. ã“れã¯, ç°¡å˜ãªåå‰ãŒoverrideã•ã‚ŒãŸæ™‚ã®ãŸã‚ã§ã™.
-
---- exit, quit, irb_exit
- 終了ã™ã‚‹.
- サブirbã®å ´åˆ, ãã®ã‚µãƒ–irbを終了ã™ã‚‹.
-
---- conf, irb_context
- irbã®ç¾åœ¨ã®è¨­å®šã‚’表示ã™ã‚‹. 設定ã®å¤‰æ›´ã¯, confã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’é€ã‚‹ã“
- ã¨ã«ã‚ˆã£ã¦è¡Œãªãˆã‚‹.
-
---- conf.eval_history = N
- å®Ÿè¡Œçµæžœã®ãƒ’ストリ機能ã®è¨­å®š.
- nnã¯æ•´æ•°ã‹nilã§ nn>0 ã§ã‚れã°ãã®æ•°ã ã‘ヒストリã«ãŸã‚る。nn==0ã®æ™‚ã¯
- 無制é™ã«è¨˜æ†¶ã™ã‚‹ã€nilã ã¨ãƒ’ストリ機能ã¯ã‚„ã‚ã‚‹(デフォルト).
-
---- Conf.back_trace_limit
- ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰n, 後ã‚ã‹ã‚‰nã ã‘行ãªã†.
- デフォルトã¯16
-
---- conf.ignore_eof = true/false
- ^DãŒå…¥åŠ›ã•ã‚ŒãŸæ™‚ã®å‹•作を設定ã™ã‚‹. trueã®æ™‚ã¯^Dを無視ã™ã‚‹, falseã®
- 時ã¯irbを終了ã™ã‚‹.
-
---- conf.ignore_sigint= true/false
- ^CãŒå…¥åŠ›ã•ã‚ŒãŸæ™‚ã®å‹•作を設定ã™ã‚‹. false時ã¯, irbを終了ã™ã‚‹. trueã®
- 時ã®å‹•作ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ãªã‚‹:
- 入力中: ã“れã¾ã§å…¥åŠ›ã—ãŸã‚‚ã®ã‚’キャンセルã—ãƒˆãƒƒãƒ—ãƒ¬ãƒ™ãƒ«ã«æˆ»ã‚‹.
- 実行中: 実行を中止ã™ã‚‹.
-
---- conf.inf_ruby_mode = true/false
- inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. デフォルトã¯false. ç‰¹ã«æŒ‡å®š
- ãŒãªã„é™ã‚Š, ラインエディタã¯ä½¿ã‚ãªããªã‚‹.
-
---- conf.inspect_mode = true/false/nil
- インスペクトモードを設定ã™ã‚‹.
- true: インスペクトã—ã¦è¡¨ç¤ºã™ã‚‹.
- false: 通常ã®printã§è¡¨ç¤ºã™ã‚‹.
- nil: 通常モードã§ã‚れã°, inspect modeã¨ãªã‚Š, mathãƒ¢ãƒ¼ãƒ‰ã®æ™‚ã¯, non
- inspect modeã¨ãªã‚‹.
-
---- conf.use_loader = true/false
- load/require時ã«irbã®file読ã¿è¾¼ã¿æ©Ÿèƒ½ã‚’用ã„るモードã®ã‚¹ã‚¤ãƒƒãƒ(デフォ
- ルトã¯ç”¨ã„ãªã„). ã“ã®ãƒ¢ãƒ¼ãƒ‰ã¯IRB全体ã«å映ã•れる.
-
---- conf.prompt_c
- ifã®ç›´å¾Œãªã©, 行ãŒç¶™ç¶šã—ã¦ã„る時ã®ãƒ—ロンプト.
-
---- conf.prompt_i
- 通常ã®ãƒ—ロンプト.
-
---- conf.prompt_s
- 文字列中ãªã©ã‚’表ã™ãƒ—ロンプト.
-
---- conf.rc
- ~/.irbrcを読ã¿è¾¼ã‚“ã ã‹ã©ã†ã‹?
-
---- conf.use_prompt = true/false
- プロンプト表示ã™ã‚‹ã‹ã©ã†ã‹? デフォルトã§ã¯ãƒ—ロンプトを表示ã™ã‚‹.
-
---- conf.use_multiline = true/false/nil
- マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã†ã‹ã©ã†ã‹?
- true: マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã†.
- false: マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’使ã‚ãªã„.
- nil: (デフォルト)inf-ruby-mode以外ã§ãƒžãƒ«ãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã—よã†
- ã¨ã™ã‚‹.
-
---- conf.use_singleline = true/false/nil
- シングルラインエディタを使ã†ã‹ã©ã†ã‹?
- true: シングルラインエディタを使ã†.
- false: シングルラインエディタを使ã‚ãªã„.
- nil: (デフォルト)inf-ruby-modeã¨ãƒžãƒ«ãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ä»¥å¤–ã§ã‚·ãƒ³ã‚°ãƒ«ãƒ©
- インエディタを利用ã—よã†ã¨ã™ã‚‹.
-#
-#--- conf.verbose=T/F
-# irbã‹ã‚‰ã„ã‚ã„ã‚ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹ã‹?
-
---- cws, chws, irb_cws, irb_chws, irb_change_workspace [obj]
- objã‚’selfã¨ã™ã‚‹. objãŒçœç•¥ã•れãŸã¨ãã¯, home workspace, ã™ãªã‚ã¡
- irbã‚’èµ·å‹•ã—ãŸã¨ãã®main objectã‚’selfã¨ã™ã‚‹.
-
---- pushws, irb_pushws, irb_push_workspace [obj]
- UNIXシェルコマンドã®pushdã¨åŒæ§˜.
-
---- popws, irb_popws, irb_pop_workspace
- UNIXシェルコマンドã®popdã¨åŒæ§˜.
-
---- irb [obj]
- サブirbã‚’ç«‹ã¡ã‚ã’ã‚‹. objãŒæŒ‡å®šã•ã‚ŒãŸæ™‚ã¯, ãã®objã‚’selfã¨ã™ã‚‹.
-
---- jobs, irb_jobs
- サブirbã®ãƒªã‚¹ãƒˆ
-
---- fg n, irb_fg n
- 指定ã—ãŸã‚µãƒ–irbã«ã‚¹ã‚¤ãƒƒãƒã™ã‚‹. nã¯, 次ã®ã‚‚ã®ã‚’指定ã™ã‚‹.
-
- irb番å·
- スレッド
- irbオブジェクト
- self(irb objã§èµ·å‹•ã—ãŸæ™‚ã®obj)
-
---- kill n, irb_kill n
- サブirbã‚’killã™ã‚‹. nã¯fgã¨åŒã˜.
-
---- source, irb_source path
- UNIXシェルコマンドã®sourceã¨ä¼¼ã¦ã„ã‚‹. ç¾åœ¨ã®ç’°å¢ƒä¸Šã§path内ã®ã‚¹ã‚¯ãƒª
- プトを評価ã™ã‚‹.
-
---- irb_load path, prev
-
- Rubyã®loadã®irb版.
-
-= システム変数
-
---- _
- å‰ã®è¨ˆç®—ã®å®Ÿè¡Œçµæžœã‚’覚ãˆã¦ã„ã‚‹(ローカル変数).
---- __
- å®Ÿè¡Œçµæžœã®å±¥æ­´ã‚’覚ãˆã¦ã„ã‚‹.
- __[line_no]ã§ã€ãã®è¡Œã§å®Ÿè¡Œã—ãŸçµæžœã‚’å¾—ã‚‹ã“ã¨ãŒã§ãã‚‹. line_noãŒè² ã®
- 時ã«ã¯ã€æœ€æ–°ã®çµæžœã‹ã‚‰-line_noå‰ã®çµæžœã‚’å¾—ã‚‹ã“ã¨ãŒã§ãã‚‹.
-
-= 使用例
-
-以下ã®ã‚ˆã†ãªæ„Ÿã˜ã§ã™.
-
- dim% ruby irb.rb
- irb(main):001:0> irb # サブirbã®ç«‹ã¡ã‚ã’
- irb#1(main):001:0> jobs # サブirbã®ãƒªã‚¹ãƒˆ
- #0->irb on main (#<Thread:0x400fb7e4> : stop)
- #1->irb#1 on main (#<Thread:0x40125d64> : running)
- nil
- irb#1(main):002:0> fg 0 # jobã®ã‚¹ã‚¤ãƒƒãƒ
- nil
- irb(main):002:0> class Foo;end
- nil
- irb(main):003:0> irb Foo # Fooをコンテキストã—ã¦irb
- # ç«‹ã¡ã‚ã’
- irb#2(Foo):001:0> def foo # Foo#fooã®å®šç¾©
- irb#2(Foo):002:1> print 1
- irb#2(Foo):003:1> end
- nil
- irb#2(Foo):004:0> fg 0 # jobをスイッãƒ
- nil
- irb(main):004:0> jobs # jobã®ãƒªã‚¹ãƒˆ
- #0->irb on main (#<Thread:0x400fb7e4> : running)
- #1->irb#1 on main (#<Thread:0x40125d64> : stop)
- #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
- nil
- irb(main):005:0> Foo.instance_methods # Foo#fooãŒã¡ã‚ƒã‚“ã¨å®šç¾©ã•
- # れã¦ã„ã‚‹
- ["foo"]
- irb(main):006:0> fg 2 # jobをスイッãƒ
- nil
- irb#2(Foo):005:0> def bar # Foo#barを定義
- irb#2(Foo):006:1> print "bar"
- irb#2(Foo):007:1> end
- nil
- irb#2(Foo):010:0> Foo.instance_methods
- ["bar", "foo"]
- irb#2(Foo):011:0> fg 0
- nil
- irb(main):007:0> f = Foo.new
- #<Foo:0x4010af3c>
- irb(main):008:0> irb f # Fooã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã§irbã‚’
- # ç«‹ã¡ã‚ã’ã‚‹.
- irb#3(#<Foo:0x4010af3c>):001:0> jobs
- #0->irb on main (#<Thread:0x400fb7e4> : stop)
- #1->irb#1 on main (#<Thread:0x40125d64> : stop)
- #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
- #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
- nil
- irb#3(#<Foo:0x4010af3c>):002:0> foo # f.fooã®å®Ÿè¡Œ
- nil
- irb#3(#<Foo:0x4010af3c>):003:0> bar # f.barã®å®Ÿè¡Œ
- barnil
- irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# jobã®kill
- nil
- irb(main):009:0> jobs
- #0->irb on main (#<Thread:0x400fb7e4> : running)
- nil
- irb(main):010:0> exit # 終了
- dim%
-
-= 使用上ã®åˆ¶é™
-
-irbã¯, 評価ã§ãる時点(å¼ãŒé–‰ã˜ãŸæ™‚点)ã§ã®é€æ¬¡å®Ÿè¡Œã‚’行ãªã„ã¾ã™. ã—ãŸãŒã£
-ã¦, rubyを直接使ã£ãŸæ™‚ã¨, 若干異ãªã‚‹å‹•作を行ãªã†å ´åˆãŒã‚りã¾ã™.
-
-ç¾åœ¨æ˜Žã‚‰ã‹ã«ãªã£ã¦ã„ã‚‹å•題点を説明ã—ã¾ã™.
-
-== ローカル変数ã®å®£è¨€
-
-rubyã§ã¯, 以下ã®ãƒ—ログラムã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™.
-
- eval "foo = 0"
- foo
- --
- -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
- ---
- NameError
-
-ã¨ã“ã‚ãŒ, irbを用ã„ã‚‹ã¨
-
- >> eval "foo = 0"
- => 0
- >> foo
- => 0
-
-ã¨ãªã‚Š, エラーを起ã“ã—ã¾ã›ã‚“. ã“れã¯, rubyãŒæœ€åˆã«ã‚¹ã‚¯ãƒªãƒ—ト全体をコン
-パイルã—ã¦ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã‚’決定ã™ã‚‹ã‹ã‚‰ã§ã™. ãれã«å¯¾ã—, irbã¯å®Ÿè¡Œå¯èƒ½ã«
-ãªã‚‹(å¼ãŒé–‰ã˜ã‚‹)ã¨è‡ªå‹•çš„ã«è©•価ã—ã¦ã„ã‚‹ã‹ã‚‰ã§ã™. 上記ã®ä¾‹ã§ã¯,
-
- eval "foo = 0"
-
-を行ãªã£ãŸæ™‚点ã§è©•価を行ãªã„, ãã®æ™‚点ã§å¤‰æ•°ãŒå®šç¾©ã•れるãŸã‚, 次å¼ã§
-変数fooã¯å®šç¾©ã•れã¦ã„ã‚‹ã‹ã‚‰ã§ã™.
-
-ã“ã®ã‚ˆã†ãªrubyã¨irbã®å‹•作ã®é•ã„を解決ã—ãŸã„å ´åˆã¯, begin...endã§æ‹¬ã£ã¦
-ãƒãƒƒãƒçš„ã«å®Ÿè¡Œã—ã¦ä¸‹ã•ã„:
-
- >> begin
- ?> eval "foo = 0"
- >> foo
- >> end
- NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
- (irb):3
- (irb_local_binding):1:in `eval'
-
-== ヒアドキュメント
-
-ç¾åœ¨ã®ã¨ã“ã‚ヒアドキュメントã®å®Ÿè£…ã¯ä¸å®Œå…¨ã§ã™.
-
-== シンボル
-
-シンボルã§ã‚ã‚‹ã‹ã©ã†ã‹ã®åˆ¤æ–­ã‚’é–“é•ãˆã‚‹ã“ã¨ãŒã‚りã¾ã™. 具体的ã«ã¯å¼ãŒå®Œäº†
-ã—ã¦ã„ã‚‹ã®ã«ç¶™ç¶šè¡Œã¨è¦‹ãªã™ã“ã¨ãŒã‚りã¾ã™.
-
-=end
-
-% Begin Emacs Environment
-% Local Variables:
-% mode: text
-% comment-column: 0
-% comment-start: "%"
-% comment-end: "\n"
-% End:
-%
diff --git a/doc/jit/yjit.md b/doc/jit/yjit.md
new file mode 100644
index 0000000000..d91877c30e
--- /dev/null
+++ b/doc/jit/yjit.md
@@ -0,0 +1,547 @@
+<p align="center">
+ <a href="https://yjit.org/" target="_blank" rel="noopener noreferrer">
+ <img src="https://user-images.githubusercontent.com/224488/131155756-aa8fb528-a813-4dfd-99ac-8785c3d5eed7.png" width="400">
+ </a>
+</p>
+
+YJIT - Yet Another Ruby JIT
+===========================
+
+YJIT is a lightweight, minimalistic Ruby JIT built inside CRuby.
+It lazily compiles code using a Basic Block Versioning (BBV) architecture.
+YJIT is currently supported for macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs.
+This project is open source and falls under the same license as CRuby.
+
+<p align="center"><b>
+ If you're using YJIT in production, please
+ <a href="mailto:ruby@shopify.com">share your success stories with us!</a>
+</b></p>
+
+If you wish to learn more about the approach taken, here are some conference talks and publications:
+
+- MPLR 2023 talk: [Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach](https://www.youtube.com/watch?v=pVRmPZcNUhc)
+- RubyKaigi 2023 keynote: [Optimizing YJIT’s Performance, from Inception to Production](https://www.youtube.com/watch?v=X0JRhh8w_4I)
+- RubyKaigi 2023 keynote: [Fitting Rust YJIT into CRuby](https://www.youtube.com/watch?v=GI7vvAgP_Qs)
+- RubyKaigi 2022 keynote: [Stories from developing YJIT](https://www.youtube.com/watch?v=EMchdR9C8XM)
+- RubyKaigi 2022 talk: [Building a Lightweight IR and Backend for YJIT](https://www.youtube.com/watch?v=BbLGqTxTRp0)
+- RubyKaigi 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=PBVLf3yfMs8)
+- Blog post: [YJIT: Building a New JIT Compiler Inside CRuby](https://pointersgonewild.com/2021/06/02/yjit-building-a-new-jit-compiler-inside-cruby/)
+- MPLR 2023 paper: [Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach](https://dl.acm.org/doi/10.1145/3617651.3622982)
+- VMIL 2021 paper: [YJIT: A Basic Block Versioning JIT Compiler for CRuby](https://dl.acm.org/doi/10.1145/3486606.3486781)
+- MoreVMs 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=vucLAqv7qpc)
+- ECOOP 2016 talk: [Interprocedural Type Specialization of JavaScript Programs Without Type Analysis](https://www.youtube.com/watch?v=sRNBY7Ss97A)
+- ECOOP 2016 paper: [Interprocedural Type Specialization of JavaScript Programs Without Type Analysis](https://drops.dagstuhl.de/opus/volltexte/2016/6101/pdf/LIPIcs-ECOOP-2016-7.pdf)
+- ECOOP 2015 talk: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://www.youtube.com/watch?v=S-aHBuoiYE0)
+- ECOOP 2015 paper: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://arxiv.org/pdf/1411.0352.pdf)
+
+To cite YJIT in your publications, please cite the MPLR 2023 paper:
+
+```BibTeX
+@inproceedings{yjit_mplr_2023,
+author = {Chevalier-Boisvert, Maxime and Kokubun, Takashi and Gibbs, Noah and Wu, Si Xing (Alan) and Patterson, Aaron and Issroff, Jemma},
+title = {Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach},
+year = {2023},
+isbn = {9798400703805},
+publisher = {Association for Computing Machinery},
+address = {New York, NY, USA},
+url = {https://doi.org/10.1145/3617651.3622982},
+doi = {10.1145/3617651.3622982},
+booktitle = {Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes},
+pages = {20–33},
+numpages = {14},
+keywords = {dynamically typed, optimization, just-in-time, virtual machine, ruby, compiler, bytecode},
+location = {Cascais, Portugal},
+series = {MPLR 2023}
+}
+```
+
+## Current Limitations
+
+YJIT may not be suitable for certain applications. It currently only supports macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs. YJIT will use more memory than the Ruby interpreter because the JIT compiler needs to generate machine code in memory and maintain additional state information.
+You can change how much executable memory is allocated using [YJIT's command-line options](#command-line-options).
+
+## Installation
+
+### Requirements
+
+You will need to install:
+
+ - All the usual build tools for Ruby. See [Building Ruby](../contributing/building_ruby.md)
+ - The Rust compiler `rustc`
+ - The Rust version must be [>= 1.58.0](../../yjit/Cargo.toml).
+ - Optionally, only if you wish to build in dev/debug mode, Rust's `cargo`
+
+If you don't intend on making code changes to YJIT itself, we recommend
+obtaining `rustc` through your OS's package manager since that
+likely reuses the same vendor which provides the C toolchain.
+
+If you will be changing YJIT's Rust code, we suggest using the
+[first-party installation method][rust-install] for Rust. Rust also provides
+first class [support][editor-tools] for many source code editors.
+
+[rust-install]: https://www.rust-lang.org/tools/install
+[editor-tools]: https://www.rust-lang.org/tools
+
+### Building YJIT
+
+Start by cloning the `ruby/ruby` repository:
+
+```sh
+git clone https://github.com/ruby/ruby yjit
+cd yjit
+```
+
+The YJIT `ruby` binary can be built with either GCC or Clang.
+It can be built either in dev (debug) mode or in release mode.
+For maximum performance, compile YJIT in release mode with GCC.
+See [Building Ruby](rdoc-ref:contributing/building_ruby.md@building-ruby).
+
+```sh
+# Configure in release mode for maximum performance, build and install
+./autogen.sh
+./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
+make -j && make install
+```
+
+or
+
+```sh
+# Configure in lower-performance dev (debug) mode for development, build and install
+./autogen.sh
+./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
+make -j && make install
+```
+
+Dev mode includes extended YJIT statistics, but can be slow. For only statistics you can configure in stats mode:
+
+```sh
+# Configure in extended-stats mode without slow runtime checks, build and install
+./autogen.sh
+./configure --enable-yjit=stats --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
+make -j && make install
+```
+
+On macOS, you may need to specify where to find some libraries:
+
+```sh
+# Install dependencies
+brew install openssl libyaml
+
+# Configure in dev (debug) mode for development, build and install
+./autogen.sh
+./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
+make -j && make install
+```
+
+Typically configure will choose the default C compiler. To specify the C compiler, use
+
+```sh
+# Choosing a specific c compiler
+export CC=/path/to/my/chosen/c/compiler
+```
+
+before running `./configure`.
+
+You can test that YJIT works correctly by running:
+
+```sh
+# Quick tests found in /bootstraptest
+make btest
+
+# Complete set of tests
+make -j test-all
+```
+
+## Usage
+
+### Examples
+
+Once YJIT is built, you can either use `./miniruby` from within your build directory, or switch to the YJIT version of `ruby`
+by using the `chruby` tool:
+
+```sh
+chruby ruby-yjit
+ruby myscript.rb
+```
+
+You can dump statistics about compilation and execution by running YJIT with the `--yjit-stats` command-line option:
+
+```sh
+./miniruby --yjit-stats myscript.rb
+```
+
+You can see what YJIT has compiled by running YJIT with the `--yjit-log` command-line option:
+
+```sh
+./miniruby --yjit-log myscript.rb
+```
+
+The machine code generated for a given method can be printed by adding `puts RubyVM::YJIT.disasm(method(:method_name))` to a Ruby script. Note that no code will be generated if the method is not compiled.
+
+<h3 id="command-line-options">Command-Line Options</h3>
+
+YJIT supports all command-line options supported by upstream CRuby, but also adds a few YJIT-specific options:
+
+- `--yjit`: enable YJIT (disabled by default)
+- `--yjit-mem-size=N`: soft limit on YJIT memory usage in MiB (default: 128). Tries to limit `code_region_size + yjit_alloc_size`
+- `--yjit-exec-mem-size=N`: hard limit on executable memory block in MiB. Limits `code_region_size`
+- `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function.
+ It defaults to 30, and it's then increased to 120 when the number of ISEQs in the process reaches 40,000.
+- `--yjit-cold-threshold=N`: number of global calls after which an ISEQ is considered cold and not
+ compiled, lower values mean less code is compiled (default 200K)
+- `--yjit-stats`: print statistics after the execution of a program (incurs a run-time cost)
+- `--yjit-stats=quiet`: gather statistics while running a program but don't print them. Stats are accessible through `RubyVM::YJIT.runtime_stats`. (incurs a run-time cost)
+- `--yjit-log[=file|dir]`: log all compilation events to the specified file or directory. If no name is supplied, the last 1024 log entries will be printed to stderr when the application exits.
+- `--yjit-log=quiet`: gather a circular buffer of recent YJIT compilations. The compilation log entries are accessible through `RubyVM::YJIT.log` and old entries will be discarded if the buffer is not drained quickly. (incurs a run-time cost)
+- `--yjit-disable`: disable YJIT despite other `--yjit*` flags for lazily enabling it with `RubyVM::YJIT.enable`
+- `--yjit-code-gc`: enable code GC (disabled by default as of Ruby 3.3).
+ It will cause all machine code to be discarded when the executable memory size limit is hit, meaning JIT compilation will then start over.
+ This can allow you to use a lower executable memory size limit, but may cause a slight drop in performance when the limit is hit.
+- `--yjit-perf`: enable frame pointers and profiling with the `perf` tool
+- `--yjit-trace-exits`: produce a Marshal dump of backtraces from all exits. Automatically enables `--yjit-stats`
+- `--yjit-trace-exits=COUNTER`: produce a Marshal dump of backtraces from a counted exit or a fallback. Automatically enables `--yjit-stats`
+- `--yjit-trace-exits-sample-rate=N`: trace exit locations only every Nth occurrence. Automatically enables `--yjit-trace-exits`
+
+Note that there is also an environment variable `RUBY_YJIT_ENABLE` which can be used to enable YJIT.
+This can be useful for some deployment scripts where specifying an extra command-line option to Ruby is not practical.
+
+You can also enable YJIT at run-time using `RubyVM::YJIT.enable`. This can allow you to enable YJIT after your application is done
+booting, which makes it possible to avoid compiling any initialization code.
+
+You can verify that YJIT is enabled using `RubyVM::YJIT.enabled?` or by checking that `ruby --yjit -v` includes the string `+YJIT`:
+
+```sh
+ruby --yjit -v
+ruby 3.3.0dev (2023-01-31T15:11:10Z master 2a0bf269c9) +YJIT dev [x86_64-darwin22]
+
+ruby --yjit -e "p RubyVM::YJIT.enabled?"
+true
+
+ruby -e "RubyVM::YJIT.enable; p RubyVM::YJIT.enabled?"
+true
+```
+
+### Benchmarking
+
+We have collected a set of benchmarks and implemented a simple benchmarking harness in the [yjit-bench](https://github.com/Shopify/yjit-bench) repository. This benchmarking harness is designed to disable CPU frequency scaling, set process affinity and disable address space randomization so that the variance between benchmarking runs will be as small as possible.
+
+## Performance Tips for Production Deployments
+
+While YJIT options default to what we think would work well for most workloads,
+they might not necessarily be the best configuration for your application.
+This section covers tips on improving YJIT performance in case YJIT does not
+speed up your application in production.
+
+### Increasing --yjit-mem-size
+
+The `--yjit-mem-size` value can be used to set the maximum amount of memory that YJIT
+is allowed to use. This corresponds to the total of `RubyVM::YJIT.runtime_stats[:code_region_size]`
+and `RubyVM::YJIT.runtime_stats[:yjit_alloc_size]`
+Increasing the `--yjit-mem-size` value means more code
+can be optimized by YJIT, at the cost of more memory usage.
+
+If you start Ruby with `--yjit-stats`, e.g. using an environment variable `RUBYOPT=--yjit-stats`,
+`RubyVM::YJIT.runtime_stats[:ratio_in_yjit]` shows the percentage of total YARV instructions
+executed by YJIT as opposed to the CRuby interpreter.
+Ideally, `ratio_in_yjit` should be as large as 99%, and increasing `--yjit-mem-size` often
+helps improving `ratio_in_yjit`.
+
+### Running workers as long as possible
+
+It's helpful to call the same code as many times as possible before a process restarts.
+If a process is killed too frequently, the time taken for compiling methods may outweigh
+the speedup obtained by compiling them.
+
+You should monitor the number of requests each process has served.
+If you're periodically killing worker processes, e.g. with `unicorn-worker-killer` or `puma_worker_killer`,
+you may want to reduce the killing frequency or increase the limit.
+
+## Reducing YJIT Memory Usage
+
+YJIT allocates memory for JIT code and metadata. Enabling YJIT generally results in more memory usage.
+This section goes over tips on minimizing YJIT memory usage in case it uses more than your capacity.
+
+### Decreasing --yjit-mem-size
+
+YJIT uses memory for compiled code and metadata. You can change the maximum amount of memory
+that YJIT can use by specifying a different `--yjit-mem-size` command-line option. The default value
+is currently `128`.
+When changing this value, you may want to monitor `RubyVM::YJIT.runtime_stats[:ratio_in_yjit]`
+as explained above.
+
+### Enabling YJIT lazily
+
+If you enable YJIT by `--yjit` options or `RUBY_YJIT_ENABLE=1`, YJIT may compile code that is
+used only during the application boot. `RubyVM::YJIT.enable` allows you to enable YJIT from Ruby code,
+and you can call this after your application is initialized, e.g. on Unicorn's `after_fork` hook.
+If you use any YJIT options (`--yjit-*`), YJIT will start at boot by default, but `--yjit-disable`
+allows you to start Ruby with the YJIT-disabled mode while passing YJIT tuning options.
+
+## Code Optimization Tips
+
+This section contains tips on writing Ruby code that will run as fast as possible on YJIT. Some of this advice is based on current limitations of YJIT, while other advice is broadly applicable. It probably won't be practical to apply these tips everywhere in your codebase. You should ideally start by profiling your application using a tool such as [stackprof](https://github.com/tmm1/stackprof) so that you can determine which methods make up most of the execution time. You can then refactor the specific methods that make up the largest fractions of the execution time. We do not recommend modifying your entire codebase based on the current limitations of YJIT.
+
+- Avoid using `OpenStruct`
+- Avoid redefining basic integer operations (i.e. +, -, <, >, etc.)
+- Avoid redefining the meaning of `nil`, equality, etc.
+- Avoid allocating objects in the hot parts of your code
+- Minimize layers of indirection
+ - Avoid writing wrapper classes if you can (e.g. a class that only wraps a Ruby hash)
+ - Avoid methods that just call another method
+- Ruby method calls are costly. Avoid things such as methods that only return a value from a hash
+- Try to write code so that the same variables and method arguments always have the same type
+- Avoid using `TracePoint` as it can cause YJIT to deoptimize code
+- Avoid using `binding` as it can cause YJIT to deoptimize code
+
+You can also use the `--yjit-stats` command-line option to see which bytecodes cause YJIT to exit, and refactor your code to avoid using these instructions in the hottest methods of your code.
+
+### Other Statistics
+
+If you run `ruby` with `--yjit-stats`, YJIT will track and return performance statistics in `RubyVM::YJIT.runtime_stats`.
+
+```rb
+$ RUBYOPT="--yjit-stats" irb
+irb(main):001:0> RubyVM::YJIT.runtime_stats
+=>
+{:inline_code_size=>340745,
+ :outlined_code_size=>297664,
+ :all_stats=>true,
+ :yjit_insns_count=>1547816,
+ :send_callsite_not_simple=>7267,
+ :send_kw_splat=>7,
+ :send_ivar_set_method=>72,
+...
+```
+
+Some of the counters include:
+
+* `:yjit_insns_count` - how many Ruby bytecode instructions have been executed
+* `:binding_allocations` - number of bindings allocated
+* `:binding_set` - number of variables set via a binding
+* `:code_gc_count` - number of garbage collections of compiled code since process start
+* `:vm_insns_count` - number of instructions executed by the Ruby interpreter
+* `:compiled_iseq_count` - number of bytecode sequences compiled
+* `:inline_code_size` - size in bytes of main-line machine code
+* `:outlined_code_size` - size in bytes of relatively uncommonly executed machine code
+* `:side_exit_count` - number of side exits taken at runtime
+* `:total_exit_count` - number of exits, including side exits, taken at runtime
+* `:avg_len_in_yjit` - avg. number of instructions in compiled blocks before exiting to interpreter
+
+Counters starting with "exit_" show reasons for YJIT code taking a side exit (return to the interpreter.)
+
+Performance counter names are not guaranteed to remain the same between Ruby versions. If you're curious what each counter means,
+it's usually best to search the source code for it &mdash; but it may change in a later Ruby version.
+
+The printed text after a `--yjit-stats` run includes other information that may be named differently than the information in `RubyVM::YJIT.runtime_stats`.
+
+## Contributing
+
+We welcome open source contributions. You should feel free to open new issues to report bugs or just to ask questions.
+Suggestions on how to make this readme file more helpful for new contributors are most welcome.
+
+Bug fixes and bug reports are very valuable to us. If you find a bug in YJIT, it's very possible be that nobody has reported it before,
+or that we don't have a good reproduction for it, so please open an issue and provide as much information as you can about your configuration and a description of how you encountered the problem. List the commands you used to run YJIT so that we can easily reproduce the issue on our end and investigate it. If you are able to produce a small program reproducing the error to help us track it down, that is very much appreciated as well.
+
+If you would like to contribute a large patch to YJIT, we suggest opening an issue or a discussion on the [Shopify/ruby repository](https://github.com/Shopify/ruby/issues) so that
+we can have an active discussion. A common problem is that sometimes people submit large pull requests to open source projects
+without prior communication, and we have to reject them because the work they implemented does not fit within the design of the
+project. We want to save you time and frustration, so please reach out so we can have a productive discussion as to how
+you can contribute patches we will want to merge into YJIT.
+
+### Source Code Organization
+
+The YJIT source code is divided between:
+
+- `yjit.c`: code YJIT uses to interface with the rest of CRuby
+- `yjit.h`: C definitions YJIT exposes to the rest of the CRuby
+- `yjit.rb`: `YJIT` Ruby module that is exposed to Ruby
+- `yjit/src/asm/*`: in-memory assembler we use to generate machine code
+- `yjit/src/codegen.rs`: logic for translating Ruby bytecode to machine code
+- `yjit/src/core.rb`: basic block versioning logic, core structure of YJIT
+- `yjit/src/stats.rs`: gathering of run-time statistics
+- `yjit/src/options.rs`: handling of command-line options
+- `yjit/src/cruby.rs`: C bindings manually exposed to the Rust codebase
+- `yjit/bindgen/src/main.rs`: C bindings exposed to the Rust codebase through bindgen
+
+The core of CRuby's interpreter logic is found in:
+
+- `insns.def`: defines Ruby's bytecode instructions (gets compiled into `vm.inc`)
+- `vm_insnshelper.c`: logic used by Ruby's bytecode instructions
+- `vm_exec.c`: Ruby interpreter loop
+
+### Generating C bindings with bindgen
+
+In order to expose C functions to the Rust codebase, you will need to generate C bindings:
+
+```sh
+CC=clang ./configure --enable-yjit=dev
+make -j yjit-bindgen
+```
+
+This uses the bindgen tools to generate/update `yjit/src/cruby_bindings.inc.rs` based on the
+bindings listed in `yjit/bindgen/src/main.rs`. Avoid manually editing this file
+as it could be automatically regenerated at a later time. If you need to manually add C bindings,
+add them to `yjit/cruby.rs` instead.
+
+### Coding & Debugging Protips
+
+There are multiple test suites:
+
+- `make btest` (see `/bootstraptest`)
+- `make test-all`
+- `make test-spec`
+- `make check` runs all of the above
+- `make yjit-check` runs quick checks to see that YJIT is working correctly
+
+The tests can be run in parallel like this:
+
+```sh
+make -j test-all RUN_OPTS="--yjit-call-threshold=1"
+```
+
+Or single-threaded like this, to more easily identify which specific test is failing:
+
+```sh
+make test-all TESTOPTS=--verbose RUN_OPTS="--yjit-call-threshold=1"
+```
+
+To run a single test file with `test-all`:
+
+```sh
+make test-all TESTS='test/-ext-/marshal/test_usrmarshal.rb' RUNRUBYOPT=--debugger=lldb RUN_OPTS="--yjit-call-threshold=1"
+```
+
+It's also possible to filter tests by name to run a single test:
+
+```sh
+make test-all TESTS='-n /test_float_plus/' RUN_OPTS="--yjit-call-threshold=1"
+```
+
+You can also run one specific test in `btest`:
+
+```sh
+make btest BTESTS=bootstraptest/test_ractor.rb RUN_OPTS="--yjit-call-threshold=1"
+```
+
+There are shortcuts to run/debug your own test/repro in `test.rb`:
+
+```sh
+make run # runs ./miniruby test.rb
+make lldb # launches ./miniruby test.rb in lldb
+```
+
+You can use the Intel syntax for disassembly in LLDB, keeping it consistent with YJIT's disassembly:
+
+```sh
+echo "settings set target.x86-disassembly-flavor intel" >> ~/.lldbinit
+```
+
+## Running x86 YJIT on Apple's Rosetta
+
+For development purposes, it is possible to run x86 YJIT on an Apple M1 via Rosetta. You can find basic
+instructions below, but there are a few caveats listed further down.
+
+First, install Rosetta:
+
+```console
+$ softwareupdate --install-rosetta
+```
+
+Now any command can be run with Rosetta via the `arch` command line tool.
+
+Then you can start your shell in an x86 environment:
+
+```console
+$ arch -x86_64 zsh
+```
+
+You can double check your current architecture via the `arch` command:
+
+```console
+$ arch -x86_64 zsh
+$ arch
+i386
+```
+
+You may need to set the default target for `rustc` to x86-64, e.g.
+
+```console
+$ rustup default stable-x86_64-apple-darwin
+```
+
+While in your i386 shell, install Cargo and Homebrew, then hack away!
+
+### Rosetta Caveats
+
+1. You must install a version of Homebrew for each architecture
+2. Cargo will install in $HOME/.cargo by default, and I don't know a good way to change architectures after install
+
+If you use Fish shell you can [read this link](https://tenderlovemaking.com/2022/01/07/homebrew-rosetta-and-ruby.html) for information on making the dev environment easier.
+
+## Profiling with Linux perf
+
+`--yjit-perf` allows you to profile JIT-ed methods along with other native functions using Linux perf.
+When you run Ruby with `perf record`, perf looks up `/tmp/perf-{pid}.map` to resolve symbols in JIT code,
+and this option lets YJIT write method symbols into that file as well as enabling frame pointers.
+
+### Call graph
+
+Here's an example way to use this option with [Firefox Profiler](https://profiler.firefox.com)
+(See also: [Profiling with Linux perf](https://profiler.firefox.com/docs/#/./guide-perf-profiling)):
+
+```bash
+# Compile the interpreter with frame pointers enabled
+./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc cflags=-fno-omit-frame-pointer
+make -j && make install
+
+# [Optional] Allow running perf without sudo
+echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
+echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
+
+# Profile Ruby with --yjit-perf
+cd ../yjit-bench
+PERF="record --call-graph fp" ruby --yjit-perf -Iharness-perf benchmarks/liquid-render/benchmark.rb
+
+# View results on Firefox Profiler https://profiler.firefox.com.
+# Create /tmp/test.perf as below and upload it using "Load a profile from file".
+perf script --fields +pid > /tmp/test.perf
+```
+
+### YJIT codegen
+
+You can also profile the number of cycles consumed by code generated by each YJIT function.
+
+```bash
+# Install perf
+apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r`
+
+# [Optional] Allow running perf without sudo
+echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
+echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
+
+# Profile Ruby with --yjit-perf=codegen
+cd ../yjit-bench
+PERF=record ruby --yjit-perf=codegen -Iharness-perf benchmarks/lobsters/benchmark.rb
+
+# Aggregate results
+perf script > /tmp/perf.txt
+../ruby/misc/jit_perf.py /tmp/perf.txt
+```
+
+#### Building perf with Python support
+
+The above instructions work fine for most people, but you could also use
+a handy `perf script -s` interface if you build perf from source.
+
+```bash
+# Build perf from source for Python support
+sudo apt-get install libpython3-dev python3-pip flex libtraceevent-dev \
+ libelf-dev libunwind-dev libaudit-dev libslang2-dev libdw-dev
+git clone --depth=1 https://github.com/torvalds/linux
+cd linux/tools/perf
+make
+make install
+
+# Aggregate results
+perf script -s ../ruby/misc/jit_perf.py
+```
diff --git a/doc/jit/zjit.md b/doc/jit/zjit.md
new file mode 100644
index 0000000000..ebe5cc4f9b
--- /dev/null
+++ b/doc/jit/zjit.md
@@ -0,0 +1,461 @@
+<p align="center">
+ <img src="https://github.com/user-attachments/assets/27abfe03-3e96-4220-b6f1-278bb0c87684" width="400">
+</p>
+
+# ZJIT: ADVANCED RUBY JIT PROTOTYPE
+
+ZJIT is a method-based just-in-time (JIT) compiler for Ruby. It uses profile
+information from the interpreter to guide optimization in the compiler.
+
+ZJIT is currently supported for macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs.
+This project is open source and falls under the same license as CRuby.
+
+## Current Limitations
+
+ZJIT may not be suitable for certain applications. It currently only supports macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs. ZJIT will use more memory than the Ruby interpreter because the JIT compiler needs to generate machine code in memory and maintain additional state information.
+You can change how much executable memory is allocated using [ZJIT's command-line options](rdoc-ref:@Command-Line+Options).
+
+## Contributing
+
+We welcome open source contributions. Feel free to open new issues to report
+bugs or just to ask questions. Suggestions on how to make this document more
+helpful for new contributors are most welcome.
+
+Bug fixes and bug reports are very valuable to us. If you find a bug in ZJIT,
+it's very possible that nobody has reported it before, or that we don't have
+a good reproduction for it, so please open a ticket on [the official Ruby bug
+tracker][rubybugs] (or, if you don't want to make an account, [on
+Shopify/ruby][shopifyruby]) and provide as much information as you can about
+your configuration and a description of how you encountered the problem. List
+the commands you used to run ZJIT so that we can easily reproduce the issue on
+our end and investigate it. If you are able to produce a small program
+reproducing the error to help us track it down, that is very much appreciated
+as well.
+
+[rubybugs]: https://bugs.ruby-lang.org/projects/ruby-master
+[shopifyruby]: https://github.com/Shopify/ruby/issues
+
+If you would like to contribute a large patch to ZJIT, we suggest [chatting on
+Zulip][zulip] for a casual chat and then opening an issue on the [Shopify/ruby
+repository][shopifyruby] so that we can have a technical discussion. A common
+problem is that sometimes people submit large pull requests to open source
+projects without prior communication, and we have to reject them because the
+work they implemented does not fit within the design of the project. We want to
+save you time and frustration, so please reach out so we can have a productive
+discussion as to how you can contribute patches we will want to merge into
+ZJIT.
+
+[zulip]: https://zjit.zulipchat.com/
+
+## Build Instructions
+
+Refer to [Building Ruby](rdoc-ref:contributing/building_ruby.md) for general build prerequisites.
+Additionally, ZJIT requires Rust 1.85.0 or later. Release builds need only `rustc`. Development
+builds require `cargo` and may download dependencies. GNU Make is required.
+
+### For normal use
+
+To build ZJIT on macOS:
+
+```bash
+./autogen.sh
+
+./configure \
+ --enable-zjit \
+ --prefix="$HOME"/.rubies/ruby-zjit \
+ --disable-install-doc \
+ --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
+
+make -j miniruby
+```
+
+To build ZJIT on Linux:
+
+```bash
+./autogen.sh
+
+./configure \
+ --enable-zjit \
+ --prefix="$HOME"/.rubies/ruby-zjit \
+ --disable-install-doc
+
+make -j miniruby
+```
+
+### For development
+
+To build ZJIT on macOS:
+
+```bash
+./autogen.sh
+
+./configure \
+ --enable-zjit=dev \
+ --prefix="$HOME"/.rubies/ruby-zjit \
+ --disable-install-doc \
+ --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
+
+make -j miniruby
+```
+
+To build ZJIT on Linux:
+
+```bash
+./autogen.sh
+
+./configure \
+ --enable-zjit=dev \
+ --prefix="$HOME"/.rubies/ruby-zjit \
+ --disable-install-doc
+
+make -j miniruby
+```
+
+Note that `--enable-zjit=dev` does a lot of IR validation, which will help to catch errors early but mean compilation and warmup are significantly slower.
+
+The valid values for `--enable-zjit` are, from fastest to slowest:
+* `--enable-zjit`: enable ZJIT in release mode for maximum performance
+* `--enable-zjit=stats`: enable ZJIT in extended-stats mode
+* `--enable-zjit=dev_nodebug`: enable ZJIT in development mode but without slow runtime checks
+* `--enable-zjit=dev`: enable ZJIT in debug mode for development, also enables `RUBY_DEBUG`
+
+### Regenerate bindings
+
+When modifying `zjit/bindgen/src/main.rs` you need to regenerate bindings in `zjit/src/cruby_bindings.inc.rs` with:
+
+```bash
+make zjit-bindgen
+```
+
+## Documentation
+
+### Command-Line Options
+
+See `ruby --help` for ZJIT-specific command-line options:
+
+```
+$ ruby --help
+...
+ZJIT options:
+ --zjit-mem-size=num
+ Max amount of memory that ZJIT can use in MiB (default: 128).
+ --zjit-call-threshold=num
+ Number of calls to trigger JIT (default: 30).
+ --zjit-num-profiles=num
+ Number of profiled calls before JIT (default: 5).
+ --zjit-stats[=quiet]
+ Enable collecting ZJIT statistics (=quiet to suppress output).
+ --zjit-disable Disable ZJIT for lazily enabling it with RubyVM::ZJIT.enable.
+ --zjit-perf Dump ISEQ symbols into /tmp/perf-{}.map for Linux perf.
+ --zjit-log-compiled-iseqs=path
+ Log compiled ISEQs to the file. The file will be truncated.
+ --zjit-trace-exits[=counter]
+ Record source on side-exit. `Counter` picks specific counter.
+ --zjit-trace-exits-sample-rate=num
+ Frequency at which to record side exits. Must be `usize`.
+$
+```
+
+### Source level documentation
+
+You can generate and open the source level documentation in your browser using:
+
+```bash
+cargo doc --document-private-items -p zjit --open
+```
+
+### Graph of the Type System
+
+You can generate a graph of the ZJIT type hierarchy using:
+
+```bash
+ruby zjit/src/hir_type/gen_hir_type.rb > zjit/src/hir_type/hir_type.inc.rs
+dot -O -Tpdf zjit_types.dot
+open zjit_types.dot.pdf
+```
+
+## Testing
+
+Note that tests link against CRuby, so directly calling `cargo test`, or `cargo nextest` should not build. All tests are instead accessed through `make`.
+
+### Setup
+
+First, ensure you have `cargo` installed. If you do not already have it, you can use [rustup.rs](https://rustup.rs/).
+
+Also install cargo-binstall with:
+
+```bash
+cargo install cargo-binstall
+```
+
+Make sure to add `--enable-zjit=dev` when you run `configure`, then install the following tools:
+
+```bash
+cargo binstall --secure cargo-nextest
+cargo binstall --secure cargo-insta
+```
+
+`cargo-insta` is used for updating snapshots. `cargo-nextest` runs each test in its own process, which is valuable since CRuby only supports booting once per process, and most APIs are not thread safe.
+
+### Running unit tests
+
+For testing functionality within ZJIT, use:
+
+```bash
+make zjit-test
+```
+
+You can also run a single test case by specifying the function name:
+
+```bash
+make zjit-test ZJIT_TESTS=test_putobject
+```
+
+#### Snapshot Testing
+
+ZJIT uses [insta](https://insta.rs/) for snapshot testing within unit tests. When tests fail due to snapshot mismatches, pending snapshots are created. The test command will notify you if there are pending snapshots:
+
+```
+Pending snapshots found. Accept with: make zjit-test-update
+```
+
+To update/accept all the snapshot changes:
+
+```bash
+make zjit-test-update
+```
+
+You can also review snapshot changes interactively one by one:
+
+```bash
+cd zjit && cargo insta review
+```
+
+Test changes will be reviewed alongside code changes.
+
+### Running integration tests
+
+This command runs Ruby execution tests.
+
+```bash
+make test-all TESTS="test/ruby/test_zjit.rb"
+```
+
+You can also run a single test case by matching the method name:
+
+```bash
+make test-all TESTS="test/ruby/test_zjit.rb -n TestZJIT#test_putobject"
+```
+
+### Running all tests
+
+Runs both `make zjit-test` and `test/ruby/test_zjit.rb`:
+
+```bash
+make zjit-check
+```
+
+## Statistics Collection
+
+ZJIT provides detailed statistics about JIT compilation and execution behavior.
+
+### Basic Stats
+
+Run with basic statistics printed on exit:
+
+```bash
+./miniruby --zjit-stats script.rb
+```
+
+Collect stats without printing (access via `RubyVM::ZJIT.stats` in Ruby):
+
+```bash
+./miniruby --zjit-stats=quiet script.rb
+```
+
+### Accessing Stats in Ruby
+
+```ruby
+# Check if stats are enabled
+if RubyVM::ZJIT.stats_enabled?
+ stats = RubyVM::ZJIT.stats
+ puts "Compiled ISEQs: #{stats[:compiled_iseq_count]}"
+ puts "Failed ISEQs: #{stats[:failed_iseq_count]}"
+
+ # You can also reset stats during execution
+ RubyVM::ZJIT.reset_stats!
+end
+```
+
+### Performance Ratio
+
+The `ratio_in_zjit` stat shows the percentage of Ruby instructions executed in JIT code vs interpreter.
+This metric only appears when ZJIT is built with `--enable-zjit=stats` [or more](#build-instructions) (which enables `rb_vm_insn_count` tracking) and represents a key performance indicator for ZJIT effectiveness.
+
+### Tracing side exits
+
+`--zjit-trace-exits` records a backtrace every time compiled code takes a
+side exit. The output is a [Fuchsia Trace Format](https://fuchsia.dev/fuchsia-src/reference/tracing/trace-format)
+(`.fxt`) file written to `/tmp/perfetto-{pid}.fxt`, which can be opened
+directly in [Perfetto UI](https://ui.perfetto.dev/) or queried with the
+[Perfetto trace processor](https://perfetto.dev/docs/quickstart/trace-analysis).
+
+```bash
+$ ./miniruby --zjit-trace-exits -e '
+def poly(x)
+ x.to_s
+end
+
+30.times { poly(1) }
+30.times { poly("hello") }
+30.times { poly(:sym) }
+'
+ZJIT: writing trace exits to /tmp/perfetto-123456.fxt
+```
+
+To find the hottest side-exit locations, open the `.fxt` file in
+[Perfetto UI](https://ui.perfetto.dev/) and run an SQL query via the
+"Query (SQL)" tab in the bottom panel. Alternatively, download
+`trace_processor_shell` to query from the command line:
+
+```bash
+curl -Lo /tmp/trace_processor_shell https://get.perfetto.dev/trace_processor
+chmod +x /tmp/trace_processor_shell
+
+/tmp/trace_processor_shell /tmp/perfetto-123456.fxt -Q "
+SELECT reason, backtrace, count(*) AS exits FROM (
+ SELECT
+ s.id,
+ s.name AS reason,
+ group_concat(a.display_value, ' <- ') AS backtrace
+ FROM slice s
+ JOIN args a USING(arg_set_id)
+ WHERE s.category = 'side_exit'
+ GROUP BY s.id
+)
+GROUP BY reason, backtrace
+ORDER BY exits DESC
+LIMIT 30
+"
+```
+
+Example output:
+
+```
+"reason","backtrace","exits"
+"GuardType(Fixnum)","Object#poly (-e) <- block in <main> (-e) <- Integer#times (<internal:numeric>) <- <main> (-e)",60
+```
+
+You can also trace a specific counter with `--zjit-trace-exits=<counter_name>`
+(e.g. `--zjit-trace-exits=exit_compile_error`), or downsample with
+`--zjit-trace-exits-sample-rate=N` to record every N-th exit.
+Enabling `--zjit-trace-exits-sample-rate=N` will automatically enable
+`--zjit-trace-exits`.
+
+### Viewing HIR as text
+
+The compiled ZJIT HIR can be viewed as text using the `--zjit-dump-hir` option. However, HIR will only be generated if the call threshold is reached (default 30). By setting the threshold to 1 you can easily view the HIR for code snippets such as `1 + 1`:
+
+```bash
+./miniruby --zjit --zjit-dump-hir --zjit-call-threshold=1 -e "1 + 1"
+```
+
+Note that this disables profiling. To inject interpreter profiles into ZJIT, consider running your sample code 30 times:
+
+```bash
+./miniruby --zjit --zjit-dump-hir -e "30.times { 1 + 1 }"
+```
+
+### Viewing HIR in Iongraph
+
+Using `--zjit-dump-hir-iongraph` will dump all compiled functions into a directory named `/tmp/zjit-iongraph-{PROCESS_PID}`. Each file will be named `func_{ZJIT_FUNC_NAME}.json`. In order to use them in the Iongraph viewer, you'll need to use `jq` to collate them to a single file. An example invocation of `jq` is shown below for reference.
+
+`jq --slurp --null-input '.functions=inputs | .version=1' /tmp/zjit-iongraph-{PROCESS_PID}/func*.json > ~/Downloads/ion.json`
+
+From there, you can use https://mozilla-spidermonkey.github.io/iongraph/ to view your trace.
+
+### Printing ZJIT Errors
+
+`--zjit-debug` prints ZJIT compilation errors and other diagnostics:
+
+```bash
+./miniruby --zjit-debug script.rb
+```
+
+As you might guess from the name, this option is intended mostly for ZJIT developers.
+
+## Useful dev commands
+
+To view YARV output for code snippets:
+
+```bash
+./miniruby --dump=insns -e0
+```
+
+To run code snippets with ZJIT:
+
+```bash
+./miniruby --zjit -e0
+```
+
+You can also try https://www.rubyexplorer.xyz/ to view Ruby YARV disasm output with syntax highlighting
+in a way that can be easily shared with other team members.
+
+## Understanding Ruby Stacks
+
+Ruby execution involves three distinct stacks and understanding them will help you understand ZJIT's implementation:
+
+### 1. Native Stack
+
+- **Purpose**: Return addresses and saved registers. ZJIT also uses it for some C functions' argument arrays
+- **Management**: OS-managed, one per native thread
+- **Growth**: Downward from high addresses
+- **Constants**: `NATIVE_STACK_PTR`, `NATIVE_BASE_PTR`
+
+### 2. Ruby VM Stack
+
+The Ruby VM uses a single contiguous memory region (`ec->vm_stack`) containing two sub-stacks that grow toward each other. When they meet, stack overflow occurs.
+
+See [doc/contributing/vm_stack_and_frames.md](rdoc-ref:contributing/vm_stack_and_frames.md) for detailed architecture and frame layout.
+
+**Control Frame Stack:**
+
+- **Stores**: Frame metadata (`rb_control_frame_t` structures)
+- **Growth**: Downward from `vm_stack + size` (high addresses)
+- **Constants**: `CFP`
+
+**Value Stack:**
+
+- **Stores**: YARV bytecode operands (self, arguments, locals, temporaries)
+- **Growth**: Upward from `vm_stack` (low addresses)
+- **Constants**: `SP`
+
+## ZJIT Glossary
+
+This glossary contains terms that are helpful for understanding ZJIT.
+
+Please note that some terms may appear in CRuby internals too but with different meanings.
+
+| Term | Definition |
+| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
+| HIR | High-level Intermediate Representation. High-level (Ruby semantics) graph representation in static single-assignment (SSA) form |
+| LIR | Low-level Intermediate Representation. Low-level IR used in the backend for assembly generation |
+| SSA | Static Single Assignment. A form where each variable is assigned exactly once |
+| `opnd` | Operand. An operand to an IR instruction (can be register, memory, immediate, etc.) |
+| `dst` | Destination. The output operand of an instruction where the result is stored |
+| VReg | Virtual Register. A virtual register that gets lowered to physical register or memory |
+| `insn_id` | Instruction ID. An index of an instruction in a function |
+| `block_id` | The index of a basic block, which effectively acts like a pointer |
+| `branch` | Control flow edge between basic blocks in the compiled code |
+| `cb` | Code Block. Memory region for generated machine code |
+| `entry` | The starting address of compiled code for an ISEQ |
+| Patch Point | Location in generated code that can be modified later in case assumptions get invalidated |
+| Frame State | Captured state of the Ruby stack frame at a specific point for deoptimization |
+| Guard | A run-time check that ensures assumptions are still valid |
+| `invariant` | An assumption that JIT code relies on, requiring invalidation if broken |
+| Deopt | Deoptimization. Process of falling back from JIT code to interpreter |
+| Side Exit | Exit from JIT code back to interpreter |
+| Type Lattice | Hierarchy of types used for type inference and optimization |
+| Constant Folding | Optimization that evaluates constant expressions at compile time |
+| RSP | x86-64 stack pointer register used for native stack operations |
+| Register Spilling | Process of moving register values to memory when running out of physical registers |
diff --git a/doc/keywords.rdoc b/doc/keywords.rdoc
deleted file mode 100644
index cb1cff33f0..0000000000
--- a/doc/keywords.rdoc
+++ /dev/null
@@ -1,162 +0,0 @@
-== Keywords
-
-The following keywords are used by Ruby.
-
-__ENCODING__::
- The script encoding of the current file. See Encoding.
-
-__LINE__::
- The line number of this keyword in the current file.
-
-__FILE__::
- The path to the current file.
-
-BEGIN::
- Runs before any other code in the current file. See {miscellaneous
- syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
-
-END::
- Runs after any other code in the current file. See {miscellaneous
- syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
-
-alias::
- Creates an alias between two methods (and other things). See {modules and
- classes syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
-
-and::
- Short-circuit Boolean and with lower precedence than <code>&&</code>
-
-begin::
- Starts an exception handling block. See {exceptions
- syntax}[rdoc-ref:syntax/exceptions.rdoc]
-
-break::
- Leaves a block early. See {control expressions
- syntax}[rdoc-ref:syntax/control_expressions.rdoc]
-
-case::
- Starts a +case+ expression. See {control expressions
- syntax}[rdoc-ref:syntax/control_expressions.rdoc]
-
-class::
- Creates or opens a class. See {modules and classes
- syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
-
-def::
- Defines a method. See {methods syntax}[rdoc-ref:syntax/methods.rdoc]
-
-defined?::
- Returns a string describing its argument. See {miscellaneous
- syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
-
-do::
- Starts a block.
-
-else::
- The unhandled condition in +case+, +if+ and +unless+ expressions. See
- {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-elsif::
- An alternate condition for an +if+ expression. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-end::
- The end of a syntax block. Used by classes, modules, methods, exception
- handling and control expressions.
-
-ensure::
- Starts a section of code that is always run when an exception is raised.
- See {exception handling}[rdoc-ref:syntax/exceptions.rdoc]
-
-false::
- Boolean false. See {literals}[rdoc-ref:syntax/literals.rdoc]
-
-for::
- A loop that is similar to using the +each+ method. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-if::
- Used for +if+ and modifier +if+ statements. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-in::
- Used to separate the iterable object and iterator variable in a +for+ loop.
- See {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
- It also serves as a pattern in a +case+ expression.
- See {pattern matching}[rdoc-ref:syntax/pattern_matching.rdoc]
-
-module::
- Creates or opens a module. See {modules and classes
- syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
-
-next::
- Skips the rest of the block. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-nil::
- A false value usually indicating "no value" or "unknown". See
- {literals}[rdoc-ref:syntax/literals.rdoc]
-
-not::
- Inverts the following boolean expression. Has a lower precedence than
- <code>!</code>
-
-or::
- Boolean or with lower precedence than <code>||</code>
-
-redo::
- Restarts execution in the current block. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-rescue::
- Starts an exception section of code in a +begin+ block. See {exception
- handling}[rdoc-ref:syntax/exceptions.rdoc]
-
-retry::
- Retries an exception block. See {exception
- handling}[rdoc-ref:syntax/exceptions.rdoc]
-
-return::
- Exits a method. See {methods}[rdoc-ref:syntax/methods.rdoc].
- If met in top-level scope, immediately stops interpretation of
- the current file.
-
-self::
- The object the current method is attached to. See
- {methods}[rdoc-ref:syntax/methods.rdoc]
-
-super::
- Calls the current method in a superclass. See
- {methods}[rdoc-ref:syntax/methods.rdoc]
-
-then::
- Indicates the end of conditional blocks in control structures. See
- {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-true::
- Boolean true. See {literals}[rdoc-ref:syntax/literals.rdoc]
-
-undef::
- Prevents a class or module from responding to a method call.
- See {modules and classes}[rdoc-ref:syntax/modules_and_classes.rdoc]
-
-unless::
- Used for +unless+ and modifier +unless+ statements. See {control
- expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-until::
- Creates a loop that executes until the condition is true. See
- {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-when::
- A condition in a +case+ expression. See
- {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-while::
- Creates a loop that executes while the condition is true. See
- {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
-
-yield::
- Starts execution of the block sent to the current method. See
- {methods}[rdoc-ref:syntax/methods.rdoc]
-
diff --git a/doc/language/box.md b/doc/language/box.md
new file mode 100644
index 0000000000..92514b3ec9
--- /dev/null
+++ b/doc/language/box.md
@@ -0,0 +1,357 @@
+# Ruby Box - Ruby's in-process separation of Classes and Modules
+
+Ruby Box is designed to provide separated spaces in a Ruby process, to isolate application code, libraries and monkey patches.
+
+## Known issues
+
+* Experimental warning is shown when ruby starts with `RUBY_BOX=1` (specify `-W:no-experimental` option to hide it)
+* Installing native extensions may fail under `RUBY_BOX=1` because of stack level too deep in extconf.rb
+* `require 'active_support/core_ext'` may fail under `RUBY_BOX=1`
+* Defined methods in a box may not be referred by built-in methods written in Ruby
+
+## TODOs
+
+* Add the loaded box on iseq to check if another box tries running the iseq (add a field only when VM_CHECK_MODE?)
+* Assign its own TOPLEVEL_BINDING in boxes
+* Fix calling `warn` in boxes to refer `$VERBOSE` and `Warning.warn` in the box
+* Make an internal data container class `Ruby::Box::Entry` invisible
+* More test cases about `$LOAD_PATH` and `$LOADED_FEATURES`
+
+## How to use
+
+### Enabling Ruby Box
+
+First, an environment variable should be set at the ruby process bootup: `RUBY_BOX=1`.
+The only valid value is `1` to enable Ruby Box. Other values (or unset `RUBY_BOX`) means disabling Ruby Box. And setting the value after Ruby program starts doesn't work.
+
+### Using Ruby Box
+
+`Ruby::Box` class is the entrypoint of Ruby Box.
+
+```ruby
+box = Ruby::Box.new
+box.require('something') # or require_relative, load
+```
+
+The required file (either .rb or .so/.dll/.bundle) is loaded in the box (`box` here). The required/loaded files from `something` will be loaded in the box recursively.
+
+```ruby
+# something.rb
+
+X = 1
+
+class Something
+ def self.x = X
+ def x = ::X
+end
+```
+
+Classes/modules, those methods and constants defined in the box can be accessed via `box` object.
+
+```ruby
+X = 2
+p X # 2
+p ::X # 2
+p box::Something.x # 1
+p box::X # 1
+```
+
+Instance methods defined in the box also run with definitions in the box.
+
+```ruby
+s = box::Something.new
+
+p s.x # 1
+```
+
+## Specifications
+
+### Ruby Box types
+
+There are three box types:
+
+* Master box
+* Root box
+* User boxes
+
+Ruby bootstrap runs in the root box, and a
+
+There is the root box, just a single box in a Ruby process. All builtin classes/modules are defined and run in the root box. (See "Builtin classes and modules".)
+
+User boxes are to run user-written programs and libraries loaded from user programs. The user's main program (specified by the `ruby` command line argument) is executed in the "main" box, which is a user box automatically created at the end of Ruby's bootstrap. The files specified with `-r` command line option will be required in the main box.
+
+Calling `Ruby::Box.new` creates an "optional" box (a user, non-main box), technically equal to the main box.
+
+Ruby also has the master box. The master box is the "master copy" of all boxes. Boxes will be created as a copy of the master box. The master box is only for the source of box copies, and no code runs in the master box.
+
+
+```
+[master]
+ |
+ |----[root]
+ |
+ |----[main]
+ |
+ |----[user box 1]
+ |
+ |----[user box 2]
+ ...
+```
+
+### Ruby Box class and instances
+
+`Ruby::Box` is a class, as a subclass of `Module`. `Ruby::Box` instances are a kind of `Module`.
+
+### Classes and modules defined in boxes
+
+The classes and modules, newly defined in a box `box`, are accessible via `box`. For example, if a class `A` is defined in `box`, it is accessible as `box::A` from outside of the box.
+
+In the box `box`, `A` can be referred to as `A` (and `::A`).
+
+### Built-in classes and modules reopened in boxes
+
+In boxes, builtin classes/modules are visible and can be reopened. Those classes/modules can be reopened using `class` or `module` clauses, and class/module definitions can be changed.
+
+The changed definitions are visible only in the box. In other boxes, builtin classes/modules and those instances work without changed definitions.
+
+```ruby
+# in foo.rb
+class String
+ BLANK_PATTERN = /\A\s*\z/
+ def blank?
+ self.match?(BLANK_PATTERN)
+ end
+end
+
+module Foo
+ def self.foo = "foo"
+
+ def self.foo_is_blank?
+ foo.blank?
+ end
+end
+
+Foo.foo.blank? #=> false
+"foo".blank? #=> false
+
+# in main.rb
+box = Ruby::Box.new
+box.require_relative('foo')
+
+box::Foo.foo_is_blank? #=> false (#blank? called in box)
+
+"foo".blank? # NoMethodError
+String::BLANK_PATTERN # NameError
+```
+
+The main box and `box` above are different boxes, so monkey patches in main are also invisible in `box`.
+
+### Builtin classes and modules
+
+In the box context, "builtin" classes and modules are classes and modules:
+
+* Accessible without any `require` calls in user scripts
+* Defined before any user program start running
+
+Hereafter, "builtin classes and modules" will be referred to as just "builtin classes".
+
+Builtin classes and modules are loaded in all boxes, and run in the root box.
+
+### Exceptional non-built-in classes/modules
+
+There are some exceptional classes/modules that are enabled in default, but aren't built-in classes. Those classes/modules are:
+
+* `RubyGems`
+* `ErrorHighlight`
+* `DidYouMean`
+* `SyntaxSuggest`
+
+Those classes/modules (part of default gems) are loaded in each boxes independently. If a user box's code calls RubyGems, it calls the RubyGems inside the box itself, instead of the root box's one.
+
+### Builtin classes referred via box objects
+
+Builtin classes in a box `box` can be referred from other boxes. For example, `box::String` is a valid reference, and `String` and `box::String` are identical (`String == box::String`, `String.object_id == box::String.object_id`).
+
+`box::String`-like reference returns just a `String` in the current box, so its definition is `String` in the box, not in `box`.
+
+```ruby
+# foo.rb
+class String
+ def self.foo = "foo"
+end
+
+# main.rb
+box = Ruby::Box.new
+box.require_relative('foo')
+
+box::String.foo # NoMethodError
+```
+
+### Class instance variables, class variables, constants
+
+Builtin classes can have different sets of class instance variables, class variables and constants between boxes.
+
+```ruby
+# foo.rb
+class Array
+ @v = "foo"
+ @@v = "_foo_"
+ V = "FOO"
+end
+
+Array.instance_variable_get(:@v) #=> "foo"
+Array.class_variable_get(:@@v) #=> "_foo_"
+Array.const_get(:V) #=> "FOO"
+
+# main.rb
+box = Ruby::Box.new
+box.require_relative('foo')
+
+Array.instance_variable_get(:@v) #=> nil
+Array.class_variable_get(:@@v) # NameError
+Array.const_get(:V) # NameError
+```
+
+### Global variables
+
+In boxes, changes on global variables are also isolated in the boxes. Changes on global variables in a box are visible/applied only in the box.
+
+```ruby
+# foo.rb
+$foo = "foo"
+$VERBOSE = nil
+
+puts "This appears: '#{$foo}'"
+
+# main.rb
+p $foo #=> nil
+p $VERBOSE #=> false
+
+box = Ruby::Box.new
+box.require_relative('foo') # "This appears: 'foo'"
+
+p $foo #=> nil
+p $VERBOSE #=> false
+```
+
+### Top level constants
+
+Usually, top level constants are defined as constants of `Object`. In boxes, top level constants are constants of `Object` in the box. And the box object `box`'s constants are strictly equal to constants of `Object`.
+
+```ruby
+# foo.rb
+FOO = 100
+
+FOO #=> 100
+Object::FOO #=> 100
+
+# main.rb
+box = Ruby::Box.new
+box.require_relative('foo')
+
+box::FOO #=> 100
+
+FOO # NameError
+Object::FOO # NameError
+```
+
+### Top level methods
+
+Top level methods are private instance methods of `Object`, in each box.
+
+```ruby
+# foo.rb
+def yay = "foo"
+
+class Foo
+ def self.say = yay
+end
+
+Foo.say #=> "foo"
+yay #=> "foo"
+
+# main.rb
+box = Ruby::Box.new
+box.require_relative('foo')
+
+box::Foo.say #=> "foo"
+
+yay # NoMethodError
+```
+
+There is no way to expose top level methods in boxes to others.
+(See "Expose top level methods as a method of the box object" in "Discussions" section below)
+
+### Ruby Box scopes
+
+Ruby Box works in file scope. One `.rb` file runs in a single box.
+
+Once a file is loaded in a box `box`, all methods/procs defined/created in the file run in `box`.
+
+### Utility methods
+
+Several methods are available for trying/testing Ruby Box.
+
+* `Ruby::Box.current` returns the current box
+* `Ruby::Box.enabled?` returns true/false to represent `RUBY_BOX=1` is specified or not
+* `Ruby::Box.root` returns the root box
+* `Ruby::Box.main` returns the main box
+* `Ruby::Box#eval` evaluates a Ruby code (String) in the receiver box, just like calling `#load` with a file
+
+## Implementation details
+
+#### ISeq inline method/constant cache
+
+As described above in "Ruby Box scopes", an ".rb" file runs in a box. So method/constant resolution will be done in a box consistently.
+
+That means ISeq inline caches work well even with boxes. Otherwise, it's a bug.
+
+#### Method call global cache (gccct)
+
+`rb_funcall()` C function refers to the global cc cache table (gccct), and the cache key is calculated with the current box.
+
+So, `rb_funcall()` calls have a performance penalty when Ruby Box is enabled.
+
+#### Current box and loading box
+
+The current box is the box that the executing code is in. `Ruby::Box.current` returns the current box object.
+
+The loading box is an internally managed box to determine the box to load newly required/loaded files. For example, `box` is the loading box when `box.require("foo")` is called.
+
+## Discussions
+
+#### More builtin methods written in Ruby
+
+If Ruby Box is enabled by default, builtin methods can be written in Ruby because it can't be overridden by users' monkey patches. Builtin Ruby methods can be JIT-ed, and it could bring performance reward.
+
+#### Monkey patching methods called by builtin methods
+
+Builtin methods sometimes call other builtin methods. For example, `Hash#map` calls `Hash#each` to retrieve entries to be mapped. Without Ruby Box, Ruby users can overwrite `Hash#each` and expect the behavior change of `Hash#map` as a result.
+
+But with boxes, `Hash#map` runs in the root box. Ruby users can define `Hash#each` only in user boxes, so users cannot change `Hash#map`'s behavior in this case. To achieve it, users should override both`Hash#map` and `Hash#each` (or only `Hash#map`).
+
+It is a breaking change.
+
+Users can define methods using `Ruby::Box.root.eval(...)`, but it's clearly not ideal API.
+
+#### Assigning values to global variables used by builtin methods
+
+Similar to monkey patching methods, global variables assigned in a box is separated from the root box. Methods defined in the root box referring a global variable can't find the re-assigned one.
+
+#### Context of `$LOAD_PATH` and `$LOADED_FEATURES`
+
+Global variables `$LOAD_PATH` and `$LOADED_FEATURES` control `require` method behaviors. So those variables are determined by the loading box instead of the current box.
+
+This could potentially conflict with the user's expectations. We should find the solution.
+
+#### Expose top level methods as a method of the box object
+
+Currently, top level methods in boxes are not accessible from outside of the box. But there might be a use case to call other box's top level methods.
+
+#### Separate `cc_tbl` and `callable_m_tbl`, `cvc_tbl` for less classext CoW
+
+The fields of `rb_classext_t` contains several cache(-like) data, `cc_tbl`(callcache table), `callable_m_tbl`(table of resolved complemented methods) and `cvc_tbl`(class variable cache table).
+
+The classext CoW is triggered when the contents of `rb_classext_t` are changed, including `cc_tbl`, `callable_m_tbl`, and `cvc_tbl`. But those three tables are changed by just calling methods or referring class variables. So, currently, classext CoW is triggered much more times than the original expectation.
+
+If we can move those three tables outside of `rb_classext_t`, the number of copied `rb_classext_t` will be much less than the current implementation.
diff --git a/doc/language/bsearch.rdoc b/doc/language/bsearch.rdoc
new file mode 100644
index 0000000000..90705853d7
--- /dev/null
+++ b/doc/language/bsearch.rdoc
@@ -0,0 +1,120 @@
+= Binary Searching
+
+A few Ruby methods support binary searching in a collection:
+
+Array#bsearch:: Returns an element selected via a binary search
+ as determined by a given block.
+Array#bsearch_index:: Returns the index of an element selected via a binary search
+ as determined by a given block.
+Range#bsearch:: Returns an element selected via a binary search
+ as determined by a given block.
+
+Each of these methods returns an enumerator if no block is given.
+
+Given a block, each of these methods returns an element (or element index) from +self+
+as determined by a binary search.
+The search finds an element of +self+ which meets
+the given condition in <tt>O(log n)</tt> operations, where +n+ is the count of elements.
++self+ should be sorted, but this is not checked.
+
+There are two search modes:
+
+Find-minimum mode:: method +bsearch+ returns the first element for which
+ the block returns +true+;
+ the block must return +true+ or +false+.
+Find-any mode:: method +bsearch+ some element, if any, for which
+ the block returns zero.
+ the block must return a numeric value.
+
+The block should not mix the modes by sometimes returning +true+ or +false+
+and other times returning a numeric value, but this is not checked.
+
+<b>Find-Minimum Mode</b>
+
+In find-minimum mode, the block must return +true+ or +false+.
+The further requirement (though not checked) is that
+there are no indexes +i+ and +j+ such that:
+
+- <tt>0 <= i < j <= self.size</tt>.
+- The block returns +true+ for <tt>self[i]</tt> and +false+ for <tt>self[j]</tt>.
+
+Less formally: the block is such that all +false+-evaluating elements
+precede all +true+-evaluating elements.
+
+In find-minimum mode, method +bsearch+ returns the first element
+for which the block returns +true+.
+
+Examples:
+
+ a = [0, 4, 7, 10, 12]
+ a.bsearch {|x| x >= 4 } # => 4
+ a.bsearch {|x| x >= 6 } # => 7
+ a.bsearch {|x| x >= -1 } # => 0
+ a.bsearch {|x| x >= 100 } # => nil
+
+ r = (0...a.size)
+ r.bsearch {|i| a[i] >= 4 } #=> 1
+ r.bsearch {|i| a[i] >= 6 } #=> 2
+ r.bsearch {|i| a[i] >= 8 } #=> 3
+ r.bsearch {|i| a[i] >= 100 } #=> nil
+ r = (0.0...Float::INFINITY)
+ r.bsearch {|x| Math.log(x) >= 0 } #=> 1.0
+
+These blocks make sense in find-minimum mode:
+
+ a = [0, 4, 7, 10, 12]
+ a.map {|x| x >= 4 } # => [false, true, true, true, true]
+ a.map {|x| x >= 6 } # => [false, false, true, true, true]
+ a.map {|x| x >= -1 } # => [true, true, true, true, true]
+ a.map {|x| x >= 100 } # => [false, false, false, false, false]
+
+This would not make sense:
+
+ a.map {|x| x == 7 } # => [false, false, true, false, false]
+
+<b>Find-Any Mode</b>
+
+In find-any mode, the block must return a numeric value.
+The further requirement (though not checked) is that
+there are no indexes +i+ and +j+ such that:
+
+- <tt>0 <= i < j <= self.size</tt>.
+- The block returns a negative value for <tt>self[i]</tt>
+ and a positive value for <tt>self[j]</tt>.
+- The block returns a negative value for <tt>self[i]</tt> and zero <tt>self[j]</tt>.
+- The block returns zero for <tt>self[i]</tt> and a positive value for <tt>self[j]</tt>.
+
+Less formally: the block is such that:
+
+- All positive-evaluating elements precede all zero-evaluating elements.
+- All positive-evaluating elements precede all negative-evaluating elements.
+- All zero-evaluating elements precede all negative-evaluating elements.
+
+In find-any mode, method +bsearch+ returns some element
+for which the block returns zero, or +nil+ if no such element is found.
+
+Examples:
+
+ a = [0, 4, 7, 10, 12]
+ a.bsearch {|element| 7 <=> element } # => 7
+ a.bsearch {|element| -1 <=> element } # => nil
+ a.bsearch {|element| 5 <=> element } # => nil
+ a.bsearch {|element| 15 <=> element } # => nil
+
+ a = [0, 100, 100, 100, 200]
+ r = (0..4)
+ r.bsearch {|i| 100 - a[i] } #=> 1, 2 or 3
+ r.bsearch {|i| 300 - a[i] } #=> nil
+ r.bsearch {|i| 50 - a[i] } #=> nil
+
+These blocks make sense in find-any mode:
+
+ a = [0, 4, 7, 10, 12]
+ a.map {|element| 7 <=> element } # => [1, 1, 0, -1, -1]
+ a.map {|element| -1 <=> element } # => [-1, -1, -1, -1, -1]
+ a.map {|element| 5 <=> element } # => [1, 1, -1, -1, -1]
+ a.map {|element| 15 <=> element } # => [1, 1, 1, 1, 1]
+
+This would not make sense:
+
+ a.map {|element| element <=> 7 } # => [-1, -1, 0, 1, 1]
diff --git a/doc/language/calendars.rdoc b/doc/language/calendars.rdoc
new file mode 100644
index 0000000000..a2540f1c43
--- /dev/null
+++ b/doc/language/calendars.rdoc
@@ -0,0 +1,62 @@
+== Julian and Gregorian Calendars
+
+The difference between the
+{Julian calendar}[https://en.wikipedia.org/wiki/Julian_calendar]
+and the
+{Gregorian calendar}[https://en.wikipedia.org/wiki/Gregorian_calendar]
+may matter to your program if it uses dates before the switchovers.
+
+- October 15, 1582.
+- September 14, 1752.
+
+A date will be different in the two calendars, in general.
+
+=== Different switchover dates
+
+The reasons for the difference are religious/political histories.
+
+- On October 15, 1582, several countries changed
+ from the Julian calendar to the Gregorian calendar;
+ these included Italy, Poland, Portugal, and Spain.
+ Other countries in the Western world retained the Julian calendar.
+- On September 14, 1752, most of the British empire
+ changed from the Julian calendar to the Gregorian calendar.
+
+When your code uses a date before these switchover dates,
+it will matter whether it considers the switchover date
+to be the earlier date or the later date (or neither).
+
+See also {a concrete example here}[rdoc-ref:DateTime@When+should+you+use+DateTime+and+when+should+you+use+Time-3F].
+
+=== Argument +start+
+
+Certain methods in class \Date handle differences in the
+{Julian and Gregorian calendars}[rdoc-ref:@Julian+and+Gregorian+Calendars]
+by accepting an optional argument +start+, whose value may be:
+
+- Date::ITALY (the default): the created date is Julian
+ if before October 15, 1582, Gregorian otherwise:
+
+ d = Date.new(1582, 10, 15)
+ d.prev_day.julian? # => true
+ d.julian? # => false
+ d.gregorian? # => true
+
+- Date::ENGLAND: the created date is Julian if before September 14, 1752,
+ Gregorian otherwise:
+
+ d = Date.new(1752, 9, 14, Date::ENGLAND)
+ d.prev_day.julian? # => true
+ d.julian? # => false
+ d.gregorian? # => true
+
+- Date::JULIAN: the created date is Julian regardless of its value:
+
+ d = Date.new(1582, 10, 15, Date::JULIAN)
+ d.julian? # => true
+
+- Date::GREGORIAN: the created date is Gregorian regardless of its value:
+
+ d = Date.new(1752, 9, 14, Date::GREGORIAN)
+ d.prev_day.gregorian? # => true
+
diff --git a/doc/language/case_mapping.rdoc b/doc/language/case_mapping.rdoc
new file mode 100644
index 0000000000..d40155db03
--- /dev/null
+++ b/doc/language/case_mapping.rdoc
@@ -0,0 +1,106 @@
+= Case Mapping
+
+Some string-oriented methods use case mapping.
+
+In String:
+
+- String#capitalize
+- String#capitalize!
+- String#casecmp
+- String#casecmp?
+- String#downcase
+- String#downcase!
+- String#swapcase
+- String#swapcase!
+- String#upcase
+- String#upcase!
+
+In Symbol:
+
+- Symbol#capitalize
+- Symbol#casecmp
+- Symbol#casecmp?
+- Symbol#downcase
+- Symbol#swapcase
+- Symbol#upcase
+
+== Default Case Mapping
+
+By default, all of these methods use full Unicode case mapping,
+which is suitable for most languages.
+See {Section 3.13 (Default Case Algorithms) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf].
+
+Non-ASCII case mapping and folding are supported for UTF-8,
+UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols.
+
+Context-dependent case mapping as described in
+{Table 3-17 (Context Specification for Casing) of the Unicode standard}[https://www.unicode.org/versions/latest/ch03.pdf]
+is currently not supported.
+
+In most cases, the case conversion of a string has the same number of characters as before.
+There are exceptions (see also +:fold+ below):
+
+ s = "\u00DF" # => "ß"
+ s.upcase # => "SS"
+ s = "\u0149" # => "ʼn"
+ s.upcase # => "ʼN"
+
+Case mapping may also depend on locale (see also +:turkic+ below):
+
+ s = "\u0049" # => "I"
+ s.downcase # => "i" # Dot above.
+ s.downcase(:turkic) # => "ı" # No dot above.
+
+Case changes may not be reversible:
+
+ s = 'Hello World!' # => "Hello World!"
+ s.downcase # => "hello world!"
+ s.downcase.upcase # => "HELLO WORLD!" # Different from original s.
+
+Case changing methods may not maintain Unicode normalization.
+See String#unicode_normalize.
+
+== Case Mappings
+
+Except for +casecmp+ and +casecmp?+,
+each of the case-mapping methods listed above
+accepts an optional argument, <tt>mapping</tt>.
+
+The argument is one of:
+
+- +:ascii+: ASCII-only mapping.
+ Uppercase letters ('A'..'Z') are mapped to lowercase letters ('a'..'z);
+ other characters are not changed
+
+ s = "Foo \u00D8 \u00F8 Bar" # => "Foo Ø ø Bar"
+ s.upcase # => "FOO Ø Ø BAR"
+ s.downcase # => "foo ø ø bar"
+ s.upcase(:ascii) # => "FOO Ø ø BAR"
+ s.downcase(:ascii) # => "foo Ø ø bar"
+
+- +:turkic+: Full Unicode case mapping.
+ For the Turkic languages
+ that distinguish dotted and dotless I, for example Turkish and Azeri.
+
+ s = 'Türkiye' # => "Türkiye"
+ s.upcase # => "TÜRKIYE"
+ s.upcase(:turkic) # => "TÜRKİYE" # Dot above.
+
+ s = 'TÜRKIYE' # => "TÜRKIYE"
+ s.downcase # => "türkiye"
+ s.downcase(:turkic) # => "türkıye" # No dot above.
+
+- +:fold+ (available only for String#downcase, String#downcase!,
+ and Symbol#downcase).
+ Unicode case folding,
+ which is more far-reaching than Unicode case mapping.
+
+ s = "\u00DF" # => "ß"
+ s.downcase # => "ß"
+ s.downcase(:fold) # => "ss"
+ s.upcase # => "SS"
+
+ s = "\uFB04" # => "ffl"
+ s.downcase # => "ffl"
+ s.upcase # => "FFL"
+ s.downcase(:fold) # => "ffl"
diff --git a/doc/language/character_selectors.rdoc b/doc/language/character_selectors.rdoc
new file mode 100644
index 0000000000..8bfc9b719b
--- /dev/null
+++ b/doc/language/character_selectors.rdoc
@@ -0,0 +1,100 @@
+= Character Selectors
+
+== Character Selector
+
+A _character_ _selector_ is a string argument accepted by certain Ruby methods.
+Each of these instance methods accepts one or more character selectors:
+
+- String#tr(selector, replacements): returns a new string.
+- String#tr!(selector, replacements): returns +self+ or +nil+.
+- String#tr_s(selector, replacements): returns a new string.
+- String#tr_s!(selector, replacements): returns +self+ or +nil+.
+- String#count(*selectors): returns the count of the specified characters.
+- String#delete(*selectors): returns a new string.
+- String#delete!(*selectors): returns +self+ or +nil+.
+- String#squeeze(*selectors): returns a new string.
+- String#squeeze!(*selectors): returns +self+ or +nil+.
+- String#strip(*selectors): returns a new string.
+- String#strip!(*selectors): returns +self+ or +nil+.
+
+A character selector identifies zero or more characters in +self+
+that are to be operands for the method.
+
+In this section, we illustrate using method String#delete(selector),
+which deletes the selected characters.
+
+In the simplest case, the characters selected are exactly those
+contained in the selector itself:
+
+ 'abracadabra'.delete('a') # => "brcdbr"
+ 'abracadabra'.delete('ab') # => "rcdr"
+ 'abracadabra'.delete('abc') # => "rdr"
+ '0123456789'.delete('258') # => "0134679"
+ '!@#$%&*()_+'.delete('+&#') # => "!@$%*()_"
+ 'ã“ã‚“ã«ã¡ã¯'.delete('ã«') # => "ã“ã‚“ã¡ã¯"
+
+Note that order and repetitions do not matter:
+
+ 'abracadabra'.delete('dcab') # => "rr"
+ 'abracadabra'.delete('aaaa') # => "brcdbr"
+
+In a character selector, these three characters get special treatment:
+
+- A leading caret (<tt>'^'</tt>) functions as a "not" operator
+ for the characters to its right:
+
+ 'abracadabra'.delete('^bc') # => "bcb"
+ '0123456789'.delete('^852') # => "258"
+
+- A hyphen (<tt>'-'</tt>) between two other characters
+ defines a range of characters instead of a plain string of characters:
+
+ 'abracadabra'.delete('a-d') # => "rr"
+ '0123456789'.delete('4-7') # => "012389"
+ '!@#$%&*()_+'.delete(' -/') # => "@^_"
+
+ # May contain more than one range.
+ 'abracadabra'.delete('a-cq-t') # => "d"
+
+ # Ranges may be mixed with plain characters.
+ '0123456789'.delete('67-950-23') # => "4"
+
+ # Ranges may be mixed with negations.
+ 'abracadabra'.delete('^a-c') # => "abacaaba"
+
+- A backslash (<tt>'\'</tt>) acts as an escape for a caret, a hyphen,
+ or another backslash:
+
+ 'abracadabra^'.delete('\^bc') # => "araadara"
+ 'abracadabra-'.delete('a\-d') # => "brcbr"
+ "hello\r\nworld".delete("\r") # => "hello\nworld"
+ "hello\r\nworld".delete("\\r") # => "hello\r\nwold"
+ "hello\r\nworld".delete("\\\r") # => "hello\nworld"
+
+== Multiple Character Selectors
+
+These instance methods accept multiple character selectors:
+
+- String#count(*selectors): returns the count of the specified characters.
+- String#delete(*selectors): returns a new string.
+- String#delete!(*selectors): returns +self+ or +nil+.
+- String#squeeze(*selectors): returns a new string.
+- String#squeeze!(*selectors): returns +self+ or +nil+.
+- String#strip(*selectors): returns a new string.
+- String#strip!(*selectors): returns +self+ or +nil+.
+
+In effect, the given selectors are formed into a single selector
+consisting of only those characters common to _all_ of the given selectors.
+
+All forms of selectors may be used, including negations, ranges, and escapes.
+
+Each of these pairs of method calls is equivalent:
+
+ s.delete('abcde', 'dcbfg')
+ s.delete('bcd')
+
+ s.delete('^abc', '^def')
+ s.delete('^abcdef')
+
+ s.delete('a-e', 'c-g')
+ s.delete('cde')
diff --git a/doc/dig_methods.rdoc b/doc/language/dig_methods.rdoc
index 366275d451..366275d451 100644
--- a/doc/dig_methods.rdoc
+++ b/doc/language/dig_methods.rdoc
diff --git a/doc/language/encodings.rdoc b/doc/language/encodings.rdoc
new file mode 100644
index 0000000000..683842d3fb
--- /dev/null
+++ b/doc/language/encodings.rdoc
@@ -0,0 +1,482 @@
+= Encodings
+
+== The Basics
+
+A {character encoding}[https://en.wikipedia.org/wiki/Character_encoding],
+often shortened to _encoding_, is a mapping between:
+
+- A sequence of 8-bit bytes (each byte in the range <tt>0..255</tt>).
+- Characters in a specific character set.
+
+Some character sets contain only 1-byte characters;
+{US-ASCII}[https://en.wikipedia.org/wiki/ASCII], for example, has 256 1-byte characters.
+This string, encoded in US-ASCII, has six characters that are stored as six bytes:
+
+ s = 'Hello!'.encode(Encoding::US_ASCII) # => "Hello!"
+ s.encoding # => #<Encoding:US-ASCII>
+ s.bytes # => [72, 101, 108, 108, 111, 33]
+
+Other encodings may involve multi-byte characters.
+{UTF-8}[https://en.wikipedia.org/wiki/UTF-8], for example,
+encodes more than one million characters, encoding each in one to four bytes.
+The lowest-valued of these characters correspond to ASCII characters,
+and so are 1-byte characters:
+
+ s = 'Hello!' # => "Hello!"
+ s.bytes # => [72, 101, 108, 108, 111, 33]
+
+Other characters, such as the Euro symbol, are multi-byte:
+
+ s = "\u20ac" # => "€"
+ s.bytes # => [226, 130, 172]
+
+== The \Encoding Class
+
+=== \Encoding Objects
+
+Ruby encodings are defined by constants in class \Encoding.
+There can be only one instance of \Encoding for each of these constants.
+Method Encoding.list returns an array of \Encoding objects (one for each constant):
+
+ Encoding.list.size # => 103
+ Encoding.list.first.class # => Encoding
+ Encoding.list.take(3)
+ # => [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>, #<Encoding:US-ASCII>]
+
+=== Names and Aliases
+
+Method Encoding#name returns the name of an \Encoding:
+
+ Encoding::ASCII_8BIT.name # => "ASCII-8BIT"
+ Encoding::WINDOWS_31J.name # => "Windows-31J"
+
+An \Encoding object has zero or more aliases;
+method Encoding#names returns an array containing the name and all aliases:
+
+ Encoding::ASCII_8BIT.names
+ # => ["ASCII-8BIT", "BINARY"]
+ Encoding::WINDOWS_31J.names
+ #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"]
+
+Method Encoding.aliases returns a hash of all alias/name pairs:
+
+ Encoding.aliases.size # => 71
+ Encoding.aliases.take(3)
+ # => [["BINARY", "ASCII-8BIT"], ["CP437", "IBM437"], ["CP720", "IBM720"]]
+
+Method Encoding.name_list returns an array of all the encoding names and aliases:
+
+ Encoding.name_list.size # => 175
+ Encoding.name_list.take(3)
+ # => ["ASCII-8BIT", "UTF-8", "US-ASCII"]
+
+Method +name_list+ returns more entries than method +list+
+because it includes both the names and their aliases.
+
+Method Encoding.find returns the \Encoding for a given name or alias, if it exists:
+
+ Encoding.find("US-ASCII") # => #<Encoding:US-ASCII>
+ Encoding.find("US-ASCII").class # => Encoding
+
+=== Default Encodings
+
+Method Encoding.find, above, also returns a default \Encoding
+for each of these special names:
+
+- +external+: the default external \Encoding:
+
+ Encoding.find("external") # => #<Encoding:UTF-8>
+
+- +internal+: the default internal \Encoding (may be +nil+):
+
+ Encoding.find("internal") # => nil
+
+- +locale+: the default \Encoding for a string from the environment:
+
+ Encoding.find("locale") # => #<Encoding:UTF-8> # Linux
+ Encoding.find("locale") # => #<Encoding:IBM437> # Windows
+
+- +filesystem+: the default \Encoding for a string from the filesystem:
+
+ Encoding.find("filesystem") # => #<Encoding:UTF-8>
+
+Method Encoding.default_external returns the default external \Encoding:
+
+ Encoding.default_external # => #<Encoding:UTF-8>
+
+Method Encoding.default_external= sets that value:
+
+ Encoding.default_external = Encoding::US_ASCII # => #<Encoding:US-ASCII>
+ Encoding.default_external # => #<Encoding:US-ASCII>
+
+Method Encoding.default_internal returns the default internal \Encoding:
+
+ Encoding.default_internal # => nil
+
+Method Encoding.default_internal= sets the default internal \Encoding:
+
+ Encoding.default_internal = Encoding::US_ASCII # => #<Encoding:US-ASCII>
+ Encoding.default_internal # => #<Encoding:US-ASCII>
+
+=== Compatible Encodings
+
+Method Encoding.compatible? returns whether two given objects are encoding-compatible
+(that is, whether they can be concatenated);
+returns the \Encoding of the concatenated string, or +nil+ if incompatible:
+
+ rus = "\u{442 435 441 442}"
+ eng = 'text'
+ Encoding.compatible?(rus, eng) # => #<Encoding:UTF-8>
+
+ s0 = "\xa1\xa1".force_encoding(Encoding::ISO_8859_1) # => "\xA1\xA1"
+ s1 = "\xa1\xa1".force_encoding(Encoding::EUCJP) # => "\x{A1A1}"
+ Encoding.compatible?(s0, s1) # => nil
+
+== \String \Encoding
+
+A Ruby String object has an encoding that is an instance of class \Encoding.
+The encoding may be retrieved by method String#encoding.
+
+The default encoding for a string literal is the script encoding;
+see {Script Encoding}[rdoc-ref:@Script+Encoding].
+
+ 's'.encoding # => #<Encoding:UTF-8>
+
+The default encoding for a string created with method String.new is:
+
+- For no argument, ASCII-8BIT.
+- For a \String object argument, the encoding of that string.
+- For a string literal, the script encoding;
+ see {Script Encoding}[rdoc-ref:@Script+Encoding].
+
+In either case, any encoding may be specified:
+
+ s = String.new(encoding: Encoding::UTF_8) # => ""
+ s.encoding # => #<Encoding:UTF-8>
+ s = String.new('foo', encoding: Encoding::BINARY) # => "foo"
+ s.encoding # => #<Encoding:BINARY (ASCII-8BIT)>
+
+The encoding for a string may be changed:
+
+ s = "R\xC3\xA9sum\xC3\xA9" # => "Résumé"
+ s.encoding # => #<Encoding:UTF-8>
+ s.force_encoding(Encoding::ISO_8859_1) # => "R\xC3\xA9sum\xC3\xA9"
+ s.encoding # => #<Encoding:ISO-8859-1>
+
+Changing the assigned encoding does not alter the content of the string;
+it changes only the way the content is to be interpreted:
+
+ s # => "R\xC3\xA9sum\xC3\xA9"
+ s.force_encoding(Encoding::UTF_8) # => "Résumé"
+
+The actual content of a string may also be altered;
+see {Transcoding a String}[#label-Transcoding+a+String].
+
+Here are a couple of useful query methods:
+
+ s = "abc".force_encoding(Encoding::UTF_8) # => "abc"
+ s.ascii_only? # => true
+ s = "abc\u{6666}".force_encoding(Encoding::UTF_8) # => "abc晦"
+ s.ascii_only? # => false
+
+ s = "\xc2\xa1".force_encoding(Encoding::UTF_8) # => "¡"
+ s.valid_encoding? # => true
+ s = "\xc2".force_encoding(Encoding::UTF_8) # => "\xC2"
+ s.valid_encoding? # => false
+
+== \Symbol and \Regexp Encodings
+
+The string stored in a Symbol or Regexp object also has an encoding;
+the encoding may be retrieved by method Symbol#encoding or Regexp#encoding.
+
+The default encoding for these, however, is:
+
+- US-ASCII, if all characters are US-ASCII.
+- The script encoding, otherwise;
+ see (Script Encoding)[rdoc-ref:@Script+Encoding].
+
+== Filesystem \Encoding
+
+The filesystem encoding is the default \Encoding for a string from the filesystem:
+
+ Encoding.find("filesystem") # => #<Encoding:UTF-8>
+
+== Locale \Encoding
+
+The locale encoding is the default encoding for a string from the environment,
+other than from the filesystem:
+
+ Encoding.find('locale') # => #<Encoding:IBM437>
+
+== Stream Encodings
+
+Certain stream objects can have two encodings; these objects include instances of:
+
+- IO.
+- File.
+- ARGF.
+- StringIO.
+
+The two encodings are:
+
+- An _external_ _encoding_, which identifies the encoding of the stream.
+- An _internal_ _encoding_, which (if not +nil+) specifies the encoding
+ to be used for the string constructed from the stream.
+
+=== External \Encoding
+
+The external encoding, which is an \Encoding object, specifies how bytes read
+from the stream are to be interpreted as characters.
+
+The default external encoding is:
+
+- UTF-8 for a text stream.
+- ASCII-8BIT for a binary stream.
+
+The default external encoding is returned by method Encoding.default_external,
+and may be set by:
+
+- Ruby command-line options <tt>--external_encoding</tt> or <tt>-E</tt>.
+
+You can also set the default external encoding using method Encoding.default_external=,
+but doing so may cause problems; strings created before and after the change
+may have a different encodings.
+
+For an \IO or \File object, the external encoding may be set by:
+
+- Open options +external_encoding+ or +encoding+, when the object is created;
+ see {Open Options}[rdoc-ref:IO@Open+Options].
+
+For an \IO, \File, \ARGF, or \StringIO object, the external encoding may be set by:
+
+- Methods +set_encoding+ or (except for \ARGF) +set_encoding_by_bom+.
+
+=== Internal \Encoding
+
+The internal encoding, which is an \Encoding object or +nil+,
+specifies how characters read from the stream
+are to be converted to characters in the internal encoding;
+those characters become a string whose encoding is set to the internal encoding.
+
+The default internal encoding is +nil+ (no conversion).
+It is returned by method Encoding.default_internal,
+and may be set by:
+
+- Ruby command-line options <tt>--internal_encoding</tt> or <tt>-E</tt>.
+
+You can also set the default internal encoding using method Encoding.default_internal=,
+but doing so may cause problems; strings created before and after the change
+may have a different encodings.
+
+For an \IO or \File object, the internal encoding may be set by:
+
+- Open options +internal_encoding+ or +encoding+, when the object is created;
+ see {Open Options}[rdoc-ref:IO@Open+Options].
+
+For an \IO, \File, \ARGF, or \StringIO object, the internal encoding may be set by:
+
+- Method +set_encoding+.
+
+== Script \Encoding
+
+A Ruby script has a script encoding, which may be retrieved by:
+
+ __ENCODING__ # => #<Encoding:UTF-8>
+
+The default script encoding is UTF-8;
+a Ruby source file may set its script encoding with a magic comment
+on the first line of the file (or second line, if there is a shebang on the first).
+The comment must contain the word +coding+ or +encoding+,
+followed by a colon, space and the Encoding name or alias:
+
+ # encoding: ISO-8859-1
+ __ENCODING__ #=> #<Encoding:ISO-8859-1>
+
+== Transcoding
+
+_Transcoding_ is the process of changing a sequence of characters
+from one encoding to another.
+
+As far as possible, the characters remain the same,
+but the bytes that represent them may change.
+
+The handling for characters that cannot be represented in the destination encoding
+may be specified by @Encoding+Options.
+
+=== Transcoding a \String
+
+Each of these methods transcodes a string:
+
+- String#encode: Transcodes +self+ into a new string
+ according to given encodings and options.
+- String#encode!: Like String#encode, but transcodes +self+ in place.
+- String#scrub: Transcodes +self+ into a new string
+ by replacing invalid byte sequences with a given or default replacement string.
+- String#scrub!: Like String#scrub, but transcodes +self+ in place.
+- String#unicode_normalize: Transcodes +self+ into a new string
+ according to Unicode normalization.
+- String#unicode_normalize!: Like String#unicode_normalize,
+ but transcodes +self+ in place.
+
+== Transcoding a Stream
+
+Each of these methods may transcode a stream;
+whether it does so depends on the external and internal encodings:
+
+- IO.foreach: Yields each line of given stream to the block.
+- IO.new: Creates and returns a new \IO object for the given integer file descriptor.
+- IO.open: Creates a new \IO object.
+- IO.pipe: Creates a connected pair of reader and writer \IO objects.
+- IO.popen: Creates an \IO object to interact with a subprocess.
+- IO.read: Returns a string with all or a subset of bytes from the given stream.
+- IO.readlines: Returns an array of strings, which are the lines from the given stream.
+- IO.write: Writes a given string to the given stream.
+
+This example writes a string to a file, encoding it as ISO-8859-1,
+then reads the file into a new string, encoding it as UTF-8:
+
+ s = "R\u00E9sum\u00E9"
+ path = 't.tmp'
+ ext_enc = Encoding::ISO_8859_1
+ int_enc = Encoding::UTF_8
+
+ File.write(path, s, external_encoding: ext_enc)
+ raw_text = File.binread(path)
+
+ transcoded_text = File.read(path, external_encoding: ext_enc, internal_encoding: int_enc)
+
+ p raw_text
+ p transcoded_text
+
+Output:
+
+ "R\xE9sum\xE9"
+ "Résumé"
+
+== \Encoding Options
+
+A number of methods in the Ruby core accept keyword arguments as encoding options.
+
+Some of the options specify or utilize a _replacement_ _string_, to be used
+in certain transcoding operations.
+A replacement string may be in any encoding that can be converted
+to the encoding of the destination string.
+
+These keyword-value pairs specify encoding options:
+
+- For an invalid byte sequence:
+
+ - <tt>:invalid: nil</tt> (default): Raise exception.
+ - <tt>:invalid: :replace</tt>: Replace each invalid byte sequence
+ with the replacement string.
+
+ Examples:
+
+ s = "\x80foo\x80"
+ s.encode(Encoding::ISO_8859_3) # Raises Encoding::InvalidByteSequenceError.
+ s.encode(Encoding::ISO_8859_3, invalid: :replace) # => "?foo?"
+
+- For an undefined character:
+
+ - <tt>:undef: nil</tt> (default): Raise exception.
+ - <tt>:undef: :replace</tt>: Replace each undefined character
+ with the replacement string.
+
+ Examples:
+
+ s = "\x80foo\x80"
+ "\x80".encode(Encoding::UTF_8, Encoding::BINARY) # Raises Encoding::UndefinedConversionError.
+ s.encode(Encoding::UTF_8, Encoding::BINARY, undef: :replace) # => "�foo�"
+
+
+- Replacement string:
+
+ - <tt>:replace: nil</tt> (default): Set replacement string to default value:
+ <tt>"\uFFFD"</tt> ("�") for a Unicode encoding, <tt>'?'</tt> otherwise.
+ - <tt>:replace: some_string</tt>: Set replacement string to the given +some_string+;
+ overrides +:fallback+.
+
+ Examples:
+
+ s = "\xA5foo\xA5"
+ options = {:undef => :replace, :replace => 'xyzzy'}
+ s.encode(Encoding::UTF_8, Encoding::ISO_8859_3, **options) # => "xyzzyfooxyzzy"
+
+- Replacement fallback:
+
+ One of these may be specified:
+
+ - <tt>:fallback: nil</tt> (default): No replacement fallback.
+ - <tt>:fallback: hash_like_object</tt>: Set replacement fallback to the given
+ +hash_like_object+; the replacement string is <tt>hash_like_object[X]</tt>.
+ - <tt>:fallback: method</tt>: Set replacement fallback to the given
+ +method+; the replacement string is <tt>method(X)</tt>.
+ - <tt>:fallback: proc</tt>: Set replacement fallback to the given
+ +proc+; the replacement string is <tt>proc[X]</tt>.
+
+ Examples:
+
+ s = "\u3042foo\u3043"
+
+ hash = {"\u3042" => 'xyzzy'}
+ hash.default = 'XYZZY'
+ s.encode(Encoding::US_ASCII, fallback: hash) # => "xyzzyfooXYZZY"
+
+ def (fallback = "U+%.4X").escape(x)
+ self % x.unpack("U")
+ end
+ "\u{3042}".encode(Encoding::US_ASCII, fallback: fallback.method(:escape)) # => "U+3042"
+
+ proc = Proc.new {|x| x == "\u3042" ? 'xyzzy' : 'XYZZY' }
+ s.encode('ASCII', fallback: proc) # => "XYZZYfooXYZZY"
+
+- XML entities:
+
+ One of these may be specified:
+
+ - <tt>:xml: nil</tt> (default): No handling for XML entities.
+ - <tt>:xml: :text</tt>: Treat source text as XML;
+ replace each undefined character
+ with its upper-case hexadecimal numeric character reference,
+ except that:
+
+ - <tt>&</tt> is replaced with <tt>&amp;</tt>.
+ - <tt><</tt> is replaced with <tt>&lt;</tt>.
+ - <tt>></tt> is replaced with <tt>&gt;</tt>.
+
+ - <tt>:xml: :attr</tt>: Treat source text as XML attribute value;
+ replace each undefined character
+ with its upper-case hexadecimal numeric character reference,
+ except that:
+
+ - The replacement string <tt>r</tt> is double-quoted (<tt>"r"</tt>).
+ - Each embedded double-quote is replaced with <tt>&quot;</tt>.
+ - <tt>&</tt> is replaced with <tt>&amp;</tt>.
+ - <tt><</tt> is replaced with <tt>&lt;</tt>.
+ - <tt>></tt> is replaced with <tt>&gt;</tt>.
+
+ Examples:
+
+ s = 'foo"<&>"bar' + "\u3042"
+ s.encode(Encoding::US_ASCII, xml: :text) # => "foo\"&lt;&amp;&gt;\"bar&#x3042;"
+ s.encode(Encoding::US_ASCII, xml: :attr) # => "\"foo&quot;&lt;&amp;&gt;&quot;bar&#x3042;\""
+
+
+- Newlines:
+
+ One of these may be specified:
+
+ - <tt>:cr_newline: true</tt>: Replace each line-feed character (<tt>"\n"</tt>)
+ with a carriage-return character (<tt>"\r"</tt>).
+ - <tt>:crlf_newline: true</tt>: Replace each line-feed character (<tt>"\n"</tt>)
+ with a carriage-return/line-feed string (<tt>"\r\n"</tt>).
+ - <tt>:universal_newline: true</tt>: Replace each carriage-return
+ character (<tt>"\r"</tt>) and each carriage-return/line-feed string
+ (<tt>"\r\n"</tt>) with a line-feed character (<tt>"\n"</tt>).
+
+ Examples:
+
+ s = "\n \r \r\n" # => "\n \r \r\n"
+ s.encode(Encoding::US_ASCII, cr_newline: true) # => "\r \r \r\r"
+ s.encode(Encoding::US_ASCII, crlf_newline: true) # => "\r\n \r \r\r\n"
+ s.encode(Encoding::US_ASCII, universal_newline: true) # => "\n \n \n"
diff --git a/doc/language/exceptions.md b/doc/language/exceptions.md
new file mode 100644
index 0000000000..5f8f0ece69
--- /dev/null
+++ b/doc/language/exceptions.md
@@ -0,0 +1,521 @@
+# Exceptions
+
+Ruby code can raise exceptions.
+
+Most often, a raised exception is meant to alert the running program
+that an unusual (i.e., _exceptional_) situation has arisen,
+and may need to be handled.
+
+Code throughout the Ruby core, Ruby standard library, and Ruby gems generates exceptions
+in certain circumstances:
+
+```rb
+File.open('nope.txt') # Raises Errno::ENOENT: "No such file or directory"
+```
+
+## Raised Exceptions
+
+A raised exception transfers program execution, one way or another.
+
+### Unrescued Exceptions
+
+If an exception not _rescued_
+(see [Rescued Exceptions](#label-Rescued+Exceptions) below),
+execution transfers to code in the Ruby interpreter
+that prints a message and exits the program (or thread):
+
+```console
+$ ruby -e "raise"
+-e:1:in '<main>': unhandled exception
+```
+
+### Rescued Exceptions
+
+An <i>exception handler</i> may determine what is to happen
+when an exception is raised;
+the handler may _rescue_ an exception,
+and may prevent the program from exiting.
+
+A simple example:
+
+```rb
+begin
+ raise 'Boom!' # Raises an exception, transfers control.
+ puts 'Will not get here.'
+rescue
+ puts 'Rescued an exception.' # Control transferred to here; program does not exit.
+end
+puts 'Got here.'
+```
+
+Output:
+
+```
+Rescued an exception.
+Got here.
+```
+
+An exception handler has several elements:
+
+| Element | Use |
+|-----------------------------|------------------------------------------------------------------------------------------|
+| Begin clause. | Begins the handler and contains the code whose raised exception, if any, may be rescued. |
+| One or more rescue clauses. | Each contains "rescuing" code, which is to be executed for certain exceptions. |
+| Else clause (optional). | Contains code to be executed if no exception is raised. |
+| Ensure clause (optional). | Contains code to be executed whether or not an exception is raised, or is rescued. |
+| <tt>end</tt> statement. | Ends the handler. ` |
+
+#### Begin Clause
+
+The begin clause begins the exception handler:
+
+- May start with a `begin` statement;
+ see also [Begin-Less Exception Handlers](#label-Begin-Less+Exception+Handlers).
+- Contains code whose raised exception (if any) is covered
+ by the handler.
+- Ends with the first following `rescue` statement.
+
+#### Rescue Clauses
+
+A rescue clause:
+
+- Starts with a `rescue` statement.
+- Contains code that is to be executed for certain raised exceptions.
+- Ends with the first following `rescue`,
+ `else`, `ensure`, or `end` statement.
+
+##### Rescued Exceptions
+
+A `rescue` statement may include one or more classes
+that are to be rescued;
+if none is given, StandardError is assumed.
+
+The rescue clause rescues both the specified class
+(or StandardError if none given) or any of its subclasses;
+see [Built-In Exception Class Hierarchy](rdoc-ref:Exception@Built-In+Exception+Class+Hierarchy).
+
+```rb
+begin
+ 1 / 0 # Raises ZeroDivisionError, a subclass of StandardError.
+rescue
+ puts "Rescued #{$!.class}"
+end
+```
+
+Output:
+
+```
+Rescued ZeroDivisionError
+```
+
+If the `rescue` statement specifies an exception class,
+only that class (or one of its subclasses) is rescued;
+this example exits with a ZeroDivisionError,
+which was not rescued because it is not ArgumentError or one of its subclasses:
+
+```rb
+begin
+ 1 / 0
+rescue ArgumentError
+ puts "Rescued #{$!.class}"
+end
+```
+
+A `rescue` statement may specify multiple classes,
+which means that its code rescues an exception
+of any of the given classes (or their subclasses):
+
+```rb
+begin
+ 1 / 0
+rescue FloatDomainError, ZeroDivisionError
+ puts "Rescued #{$!.class}"
+end
+```
+
+##### Multiple Rescue Clauses
+
+An exception handler may contain multiple rescue clauses;
+in that case, the first clause that rescues the exception does so,
+and those before and after are ignored:
+
+```rb
+begin
+ Dir.open('nosuch')
+rescue Errno::ENOTDIR
+ puts "Rescued #{$!.class}"
+rescue Errno::ENOENT
+ puts "Rescued #{$!.class}"
+end
+```
+
+Output:
+
+```
+Rescued Errno::ENOENT
+```
+
+##### Capturing the Rescued \Exception
+
+A `rescue` statement may specify a variable
+whose value becomes the rescued exception
+(an instance of Exception or one of its subclasses:
+
+```rb
+begin
+ 1 / 0
+rescue => x
+ puts x.class
+ puts x.message
+end
+```
+
+Output:
+
+```
+ZeroDivisionError
+divided by 0
+```
+
+##### Global Variables
+
+Two read-only global variables always have `nil` value
+except in a rescue clause;
+they're:
+
+- `$!`: contains the rescued exception.
+- `$@`: contains its backtrace.
+
+Example:
+
+```rb
+begin
+ 1 / 0
+rescue
+ p $!
+ p $@
+end
+```
+
+Output:
+
+```
+#<ZeroDivisionError: divided by 0>
+["t.rb:2:in 'Integer#/'", "t.rb:2:in '<main>'"]
+```
+
+##### Cause
+
+In a rescue clause, the method Exception#cause returns the previous value of `$!`,
+which may be `nil`;
+elsewhere, the method returns `nil`.
+
+Example:
+
+```rb
+begin
+ raise('Boom 0')
+rescue => x0
+ puts "Exception: #{x0.inspect}; $!: #{$!.inspect}; cause: #{x0.cause.inspect}."
+ begin
+ raise('Boom 1')
+ rescue => x1
+ puts "Exception: #{x1.inspect}; $!: #{$!.inspect}; cause: #{x1.cause.inspect}."
+ begin
+ raise('Boom 2')
+ rescue => x2
+ puts "Exception: #{x2.inspect}; $!: #{$!.inspect}; cause: #{x2.cause.inspect}."
+ end
+ end
+end
+```
+
+Output:
+
+```
+Exception: #<RuntimeError: Boom 0>; $!: #<RuntimeError: Boom 0>; cause: nil.
+Exception: #<RuntimeError: Boom 1>; $!: #<RuntimeError: Boom 1>; cause: #<RuntimeError: Boom 0>.
+Exception: #<RuntimeError: Boom 2>; $!: #<RuntimeError: Boom 2>; cause: #<RuntimeError: Boom 1>.
+```
+
+#### Else Clause
+
+The `else` clause:
+
+- Starts with an `else` statement.
+- Contains code that is to be executed if no exception is raised in the begin clause.
+- Ends with the first following `ensure` or `end` statement.
+
+```rb
+begin
+ puts 'Begin.'
+rescue
+ puts 'Rescued an exception!'
+else
+ puts 'No exception raised.'
+end
+```
+
+Output:
+
+```
+Begin.
+No exception raised.
+```
+
+#### Ensure Clause
+
+The ensure clause:
+
+- Starts with an `ensure` statement.
+- Contains code that is to be executed
+ regardless of whether an exception is raised,
+ and regardless of whether a raised exception is handled.
+- Ends with the first following `end` statement.
+
+```rb
+def foo(boom: false)
+ puts 'Begin.'
+ raise 'Boom!' if boom
+rescue
+ puts 'Rescued an exception!'
+else
+ puts 'No exception raised.'
+ensure
+ puts 'Always do this.'
+end
+
+foo(boom: true)
+foo(boom: false)
+```
+
+Output:
+
+```
+Begin.
+Rescued an exception!
+Always do this.
+Begin.
+No exception raised.
+Always do this.
+```
+
+#### End Statement
+
+The `end` statement ends the handler.
+
+Code following it is reached only if any raised exception is rescued.
+
+#### Begin-Less \Exception Handlers
+
+As seen above, an exception handler may be implemented with `begin` and `end`.
+
+An exception handler may also be implemented as:
+
+- A method body:
+
+ ```rb
+ def foo(boom: false) # Serves as beginning of exception handler.
+ puts 'Begin.'
+ raise 'Boom!' if boom
+ rescue
+ puts 'Rescued an exception!'
+ else
+ puts 'No exception raised.'
+ end # Serves as end of exception handler.
+ ```
+
+- A block:
+
+ ```rb
+ Dir.chdir('.') do |dir| # Serves as beginning of exception handler.
+ raise 'Boom!'
+ rescue
+ puts 'Rescued an exception!'
+ end # Serves as end of exception handler.
+ ```
+
+#### Re-Raising an \Exception
+
+It can be useful to rescue an exception, but allow its eventual effect;
+for example, a program can rescue an exception, log data about it,
+and then "reinstate" the exception.
+
+This may be done via the `raise` method, but in a special way;
+a rescuing clause:
+
+ - Captures an exception.
+ - Does whatever is needed concerning the exception (such as logging it).
+ - Calls method `raise` with no argument,
+ which raises the rescued exception:
+
+```rb
+begin
+ 1 / 0
+rescue ZeroDivisionError
+ # Do needful things (like logging).
+ raise # Raised exception will be ZeroDivisionError, not RuntimeError.
+end
+```
+
+Output:
+
+```
+ruby t.rb
+t.rb:2:in 'Integer#/': divided by 0 (ZeroDivisionError)
+ from t.rb:2:in '<main>'
+```
+
+#### Retrying
+
+It can be useful to retry a begin clause;
+for example, if it must access a possibly-volatile resource
+(such as a web page),
+it can be useful to try the access more than once
+(in the hope that it may become available):
+
+```rb
+retries = 0
+begin
+ puts "Try ##{retries}."
+ raise 'Boom'
+rescue
+ puts "Rescued retry ##{retries}."
+ if (retries += 1) < 3
+ puts 'Retrying'
+ retry
+ else
+ puts 'Giving up.'
+ raise
+ end
+end
+```
+
+```
+Try #0.
+Rescued retry #0.
+Retrying
+Try #1.
+Rescued retry #1.
+Retrying
+Try #2.
+Rescued retry #2.
+Giving up.
+# RuntimeError ('Boom') raised.
+```
+
+Note that the retry re-executes the entire begin clause,
+not just the part after the point of failure.
+
+## Raising an \Exception
+
+Method Kernel#raise raises an exception.
+
+## Custom Exceptions
+
+To provide additional or alternate information,
+you may create custom exception classes.
+Each should be a subclass of one of the built-in exception classes
+(commonly StandardError or RuntimeError);
+see [Built-In Exception Class Hierarchy](rdoc-ref:Exception@Built-In+Exception+Class+Hierarchy).
+
+```rb
+class MyException < StandardError; end
+```
+
+## Messages
+
+Every `Exception` object has a message,
+which is a string that is set at the time the object is created;
+see Exception.new.
+
+The message cannot be changed, but you can create a similar object with a different message;
+see Exception#exception.
+
+This method returns the message as defined:
+
+- Exception#message.
+
+Two other methods return enhanced versions of the message:
+
+- Exception#detailed_message: adds exception class name, with optional highlighting.
+- Exception#full_message: adds exception class name and backtrace, with optional highlighting.
+
+Each of the two methods above accepts keyword argument `highlight`;
+if the value of keyword `highlight` is `true`,
+the returned string includes bolding and underlining ANSI codes (see below)
+to enhance the appearance of the message.
+
+Any exception class (Ruby or custom) may choose to override either of these methods,
+and may choose to interpret keyword argument <tt>highlight: true</tt>
+to mean that the returned message should contain
+[ANSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
+that specify color, bolding, and underlining.
+
+Because the enhanced message may be written to a non-terminal device
+(e.g., into an HTML page),
+it is best to limit the ANSI codes to these widely-supported codes:
+
+- Begin font color:
+
+ | Color | ANSI Code |
+ |---------|------------------|
+ | Red | <tt>\\e[31m</tt> |
+ | Green | <tt>\\e[32m</tt> |
+ | Yellow | <tt>\\e[33m</tt> |
+ | Blue | <tt>\\e[34m</tt> |
+ | Magenta | <tt>\\e[35m</tt> |
+ | Cyan | <tt>\\e[36m</tt> |
+
+<br>
+
+- Begin font attribute:
+
+ | Attribute | ANSI Code |
+ |-----------|-----------------|
+ | Bold | <tt>\\e[1m</tt> |
+ | Underline | <tt>\\e[4m</tt> |
+
+<br>
+
+- End all of the above:
+
+ | Color | ANSI Code |
+ |-------|-----------------|
+ | Reset | <tt>\\e[0m</tt> |
+
+It's also best to craft a message that is conveniently human-readable,
+even if the ANSI codes are included "as-is"
+(rather than interpreted as font directives).
+
+## Backtraces
+
+A _backtrace_ is a record of the methods currently
+in the [call stack](https://en.wikipedia.org/wiki/Call_stack);
+each such method has been called, but has not yet returned.
+
+These methods return backtrace information:
+
+- Exception#backtrace: returns the backtrace as an array of strings or `nil`.
+- Exception#backtrace_locations: returns the backtrace as an array
+ of Thread::Backtrace::Location objects or `nil`.
+ Each Thread::Backtrace::Location object gives detailed information about a called method.
+
+By default, Ruby sets the backtrace of the exception to the location where it
+was raised.
+
+The developer might adjust this by either providing `backtrace` argument
+to Kernel#raise, or using Exception#set_backtrace.
+
+Note that:
+
+- by default, both `backtrace` and `backtrace_locations` represent the same backtrace;
+- if the developer sets the backtrace by one of the above methods to an array of
+ Thread::Backtrace::Location, they still represent the same backtrace;
+- if the developer sets the backtrace to a string or an array of strings:
+ - by Kernel#raise: `backtrace_locations` become `nil`;
+ - by Exception#set_backtrace: `backtrace_locations` preserve the original
+ value;
+- if the developer sets the backtrace to `nil` by Exception#set_backtrace,
+ `backtrace_locations` preserve the original value; but if the exception is then
+ reraised, both `backtrace` and `backtrace_locations` become the location of reraise.
diff --git a/doc/language/fiber.md b/doc/language/fiber.md
new file mode 100644
index 0000000000..d9011cce2f
--- /dev/null
+++ b/doc/language/fiber.md
@@ -0,0 +1,290 @@
+# Fiber
+
+Fibers provide a mechanism for cooperative concurrency.
+
+## Context Switching
+
+Fibers execute a user-provided block. During the execution, the block may call `Fiber.yield` or `Fiber.transfer` to switch to another fiber. `Fiber#resume` is used to continue execution from the point where `Fiber.yield` was called.
+
+```rb
+#!/usr/bin/env ruby
+
+puts "1: Start program."
+
+f = Fiber.new do
+ puts "3: Entered fiber."
+ Fiber.yield
+ puts "5: Resumed fiber."
+end
+
+puts "2: Resume fiber first time."
+f.resume
+
+puts "4: Resume fiber second time."
+f.resume
+
+puts "6: Finished."
+```
+
+This program demonstrates the flow control of fibers.
+
+## Scheduler
+
+The scheduler interface is used to intercept blocking operations. A typical
+implementation would be a wrapper for a gem like `EventMachine` or `Async`. This
+design provides separation of concerns between the event loop implementation
+and application code. It also allows for layered schedulers which can perform
+instrumentation.
+
+To set the scheduler for the current thread:
+
+```rb
+Fiber.set_scheduler(MyScheduler.new)
+```
+
+When the thread exits, there is an implicit call to `set_scheduler`:
+
+```rb
+Fiber.set_scheduler(nil)
+```
+
+### Design
+
+The scheduler interface is designed to be a un-opinionated light-weight layer
+between user code and blocking operations. The scheduler hooks should avoid
+translating or converting arguments or return values. Ideally, the exact same
+arguments from the user code are provided directly to the scheduler hook with
+no changes.
+
+### Interface
+
+This is the interface you need to implement.
+
+```rb
+class Scheduler
+ # Wait for the specified process ID to exit.
+ # This hook is optional.
+ # @parameter pid [Integer] The process ID to wait for.
+ # @parameter flags [Integer] A bit-mask of flags suitable for `Process::Status.wait`.
+ # @returns [Process::Status] A process status instance.
+ def process_wait(pid, flags)
+ Thread.new do
+ Process::Status.wait(pid, flags)
+ end.value
+ end
+
+ # Wait for the given io readiness to match the specified events within
+ # the specified timeout.
+ # @parameter event [Integer] A bit mask of `IO::READABLE`,
+ # `IO::WRITABLE` and `IO::PRIORITY`.
+ # @parameter timeout [Numeric] The amount of time to wait for the event in seconds.
+ # @returns [Integer] The subset of events that are ready.
+ def io_wait(io, events, timeout)
+ end
+
+ # Read from the given io into the specified buffer.
+ # WARNING: Experimental hook! Do not use in production code!
+ # @parameter io [IO] The io to read from.
+ # @parameter buffer [IO::Buffer] The buffer to read into.
+ # @parameter length [Integer] The minimum amount to read.
+ def io_read(io, buffer, length)
+ end
+
+ # Write from the given buffer into the specified IO.
+ # WARNING: Experimental hook! Do not use in production code!
+ # @parameter io [IO] The io to write to.
+ # @parameter buffer [IO::Buffer] The buffer to write from.
+ # @parameter length [Integer] The minimum amount to write.
+ def io_write(io, buffer, length)
+ end
+
+ # Sleep the current task for the specified duration, or forever if not
+ # specified.
+ # @parameter duration [Numeric] The amount of time to sleep in seconds.
+ def kernel_sleep(duration = nil)
+ end
+
+ # Execute the given block. If the block execution exceeds the given timeout,
+ # the specified exception `klass` will be raised. Typically, only non-blocking
+ # methods which enter the scheduler will raise such exceptions.
+ # @parameter duration [Integer] The amount of time to wait, after which an exception will be raised.
+ # @parameter klass [Class] The exception class to raise.
+ # @parameter *arguments [Array] The arguments to send to the constructor of the exception.
+ # @yields {...} The user code to execute.
+ def timeout_after(duration, klass, *arguments, &block)
+ end
+
+ # Resolve hostname to an array of IP addresses.
+ # This hook is optional.
+ # @parameter hostname [String] Example: "www.ruby-lang.org".
+ # @returns [Array] An array of IPv4 and/or IPv6 address strings that the hostname resolves to.
+ def address_resolve(hostname)
+ end
+
+ # Block the calling fiber.
+ # @parameter blocker [Object] What we are waiting on, informational only.
+ # @parameter timeout [Numeric | Nil] The amount of time to wait for in seconds.
+ # @returns [Boolean] Whether the blocking operation was successful or not.
+ def block(blocker, timeout = nil)
+ end
+
+ # Unblock the specified fiber.
+ # @parameter blocker [Object] What we are waiting on, informational only.
+ # @parameter fiber [Fiber] The fiber to unblock.
+ # @reentrant Thread safe.
+ def unblock(blocker, fiber)
+ end
+
+ # Intercept the creation of a non-blocking fiber.
+ # @returns [Fiber]
+ def fiber(&block)
+ Fiber.new(blocking: false, &block)
+ end
+
+ # Invoked when the thread exits.
+ def close
+ self.run
+ end
+
+ def run
+ # Implement event loop here.
+ end
+end
+```
+
+Additional hooks may be introduced in the future, we will use feature detection
+in order to enable these hooks.
+
+### Non-blocking Execution
+
+The scheduler hooks will only be used in special non-blocking execution
+contexts. Non-blocking execution contexts introduce non-determinism because the
+execution of scheduler hooks may introduce context switching points into your
+program.
+
+#### Fibers
+
+Fibers can be used to create non-blocking execution contexts.
+
+```rb
+Fiber.new do
+ puts Fiber.current.blocking? # false
+
+ # May invoke `Fiber.scheduler&.io_wait`.
+ io.read(...)
+
+ # May invoke `Fiber.scheduler&.io_wait`.
+ io.write(...)
+
+ # Will invoke `Fiber.scheduler&.kernel_sleep`.
+ sleep(n)
+end.resume
+```
+
+We also introduce a new method which simplifies the creation of these
+non-blocking fibers:
+
+```rb
+Fiber.schedule do
+ puts Fiber.current.blocking? # false
+end
+```
+
+The purpose of this method is to allow the scheduler to internally decide the
+policy for when to start the fiber, and whether to use symmetric or asymmetric
+fibers.
+
+You can also create blocking execution contexts:
+
+```rb
+Fiber.new(blocking: true) do
+ # Won't use the scheduler:
+ sleep(n)
+end
+```
+
+However you should generally avoid this unless you are implementing a scheduler.
+
+#### IO
+
+By default, I/O is non-blocking. Not all operating systems support non-blocking
+I/O. Windows is a notable example where socket I/O can be non-blocking but pipe
+I/O is blocking. Provided that there *is* a scheduler and the current thread *is
+non-blocking*, the operation will invoke the scheduler.
+
+##### `IO#close`
+
+Closing an IO interrupts all blocking operations on that IO. When a thread calls `IO#close`, it first attempts to interrupt any threads or fibers that are blocked on that IO. The closing thread waits until all blocked threads and fibers have been properly interrupted and removed from the IO's blocking list. Each interrupted thread or fiber receives an `IOError` and is cleanly removed from the blocking operation. Only after all blocking operations have been interrupted and cleaned up will the actual file descriptor be closed, ensuring proper resource cleanup and preventing potential race conditions.
+
+For fibers managed by a scheduler, the interruption process involves calling `rb_fiber_scheduler_fiber_interrupt` on the scheduler. This allows the scheduler to handle the interruption in a way that's appropriate for its event loop implementation. The scheduler can then notify the fiber, which will receive an `IOError` and be removed from the blocking operation. This mechanism ensures that fiber-based concurrency works correctly with IO operations, even when those operations are interrupted by `IO#close`.
+
+```mermaid
+sequenceDiagram
+ participant ThreadB
+ participant ThreadA
+ participant Scheduler
+ participant IO
+ participant Fiber1
+ participant Fiber2
+
+ Note over ThreadA: Thread A has a fiber scheduler
+ activate Scheduler
+ ThreadA->>Fiber1: Schedule Fiber 1
+ activate Fiber1
+ Fiber1->>IO: IO.read
+ IO->>Scheduler: rb_thread_io_blocking_region
+ deactivate Fiber1
+
+ ThreadA->>Fiber2: Schedule Fiber 2
+ activate Fiber2
+ Fiber2->>IO: IO.read
+ IO->>Scheduler: rb_thread_io_blocking_region
+ deactivate Fiber2
+
+ Note over Fiber1,Fiber2: Both fibers blocked on same IO
+
+ Note over ThreadB: IO.close
+ activate ThreadB
+ ThreadB->>IO: thread_io_close_notify_all
+ Note over ThreadB: rb_mutex_sleep
+
+ IO->>Scheduler: rb_fiber_scheduler_fiber_interrupt(Fiber1)
+ Scheduler->>Fiber1: fiber_interrupt with IOError
+ activate Fiber1
+ Note over IO: fiber_interrupt causes removal from blocking list
+ Fiber1->>IO: rb_io_blocking_operation_exit()
+ IO-->>ThreadB: Wakeup thread
+ deactivate Fiber1
+
+ IO->>Scheduler: rb_fiber_scheduler_fiber_interrupt(Fiber2)
+ Scheduler->>Fiber2: fiber_interrupt with IOError
+ activate Fiber2
+ Note over IO: fiber_interrupt causes removal from blocking list
+ Fiber2->>IO: rb_io_blocking_operation_exit()
+ IO-->>ThreadB: Wakeup thread
+ deactivate Fiber2
+ deactivate Scheduler
+
+ Note over ThreadB: Blocking operations list empty
+ ThreadB->>IO: close(fd)
+ deactivate ThreadB
+```
+
+#### Mutex
+
+The `Mutex` class can be used in a non-blocking context and is fiber specific.
+
+#### ConditionVariable
+
+The `ConditionVariable` class can be used in a non-blocking context and is
+fiber-specific.
+
+#### Queue / SizedQueue
+
+The `Queue` and `SizedQueue` classes can be used in a non-blocking context and
+are fiber-specific.
+
+#### Thread
+
+The `Thread#join` operation can be used in a non-blocking context and is
+fiber-specific.
diff --git a/doc/language/format_specifications.rdoc b/doc/language/format_specifications.rdoc
new file mode 100644
index 0000000000..763470aa02
--- /dev/null
+++ b/doc/language/format_specifications.rdoc
@@ -0,0 +1,354 @@
+= Format Specifications
+
+Several Ruby core classes have instance method +printf+ or +sprintf+:
+
+- ARGF#printf
+- IO#printf
+- Kernel#printf
+- Kernel#sprintf
+
+Each of these methods takes:
+
+- Argument +format_string+, which has zero or more
+ embedded _format_ _specifications_ (see below).
+- Arguments <tt>*arguments</tt>, which are zero or more objects to be formatted.
+
+Each of these methods prints or returns the string
+resulting from replacing each
+format specification embedded in +format_string+ with a string form
+of the corresponding argument among +arguments+.
+
+A simple example:
+
+ sprintf('Name: %s; value: %d', 'Foo', 0) # => "Name: Foo; value: 0"
+
+A format specification has the form:
+
+ %[flags][width][.precision]type
+
+It consists of:
+
+- A leading percent character.
+- Zero or more _flags_ (each is a character).
+- An optional _width_ _specifier_ (an integer, or <tt>*</tt>).
+- An optional _precision_ _specifier_ (a period followed by a non-negative
+ integer, or <tt>*</tt>).
+- A _type_ _specifier_ (a character).
+
+Except for the leading percent character,
+the only required part is the type specifier, so we begin with that.
+
+== Type Specifiers
+
+This section provides a brief explanation of each type specifier.
+The links lead to the details and examples.
+
+=== \Integer Type Specifiers
+
+- +b+ or +B+: Format +argument+ as a binary integer.
+ See {Specifiers b and B}[rdoc-ref:@Specifiers+b+and+B].
+- +d+, +i+, or +u+ (all are identical):
+ Format +argument+ as a decimal integer.
+ See {Specifier d}[rdoc-ref:@Specifier+d].
+- +o+: Format +argument+ as an octal integer.
+ See {Specifier o}[rdoc-ref:@Specifier+o].
+- +x+ or +X+: Format +argument+ as a hexadecimal integer.
+ See {Specifiers x and X}[rdoc-ref:@Specifiers+x+and+X].
+
+=== Floating-Point Type Specifiers
+
+- +a+ or +A+: Format +argument+ as hexadecimal floating-point number.
+ See {Specifiers a and A}[rdoc-ref:@Specifiers+a+and+A].
+- +e+ or +E+: Format +argument+ in scientific notation.
+ See {Specifiers e and E}[rdoc-ref:@Specifiers+e+and+E].
+- +f+: Format +argument+ as a decimal floating-point number.
+ See {Specifier f}[rdoc-ref:@Specifier+f].
+- +g+ or +G+: Format +argument+ in a "general" format.
+ See {Specifiers g and G}[rdoc-ref:@Specifiers+g+and+G].
+
+=== Other Type Specifiers
+
+- +c+: Format +argument+ as a character.
+ See {Specifier c}[rdoc-ref:@Specifier+c].
+- +p+: Format +argument+ as a string via <tt>argument.inspect</tt>.
+ See {Specifier p}[rdoc-ref:@Specifier+p].
+- +s+: Format +argument+ as a string via <tt>argument.to_s</tt>.
+ See {Specifier s}[rdoc-ref:@Specifier+s].
+- <tt>%</tt>: Format +argument+ (<tt>'%'</tt>) as a single percent character.
+ See {Specifier %}[rdoc-ref:@Specifier+-25].
+
+== Flags
+
+The effect of a flag may vary greatly among type specifiers.
+These remarks are general in nature.
+See {type-specific details}[rdoc-ref:@Type+Specifier+Details+and+Examples].
+
+Multiple flags may be given with single type specifier;
+order does not matter.
+
+=== <tt>' '</tt> Flag
+
+Insert a space before a non-negative number:
+
+ sprintf('%d', 10) # => "10"
+ sprintf('% d', 10) # => " 10"
+
+Insert a minus sign for negative value:
+
+ sprintf('%d', -10) # => "-10"
+ sprintf('% d', -10) # => "-10"
+
+=== <tt>'#'</tt> Flag
+
+Use an alternate format; varies among types:
+
+ sprintf('%x', 100) # => "64"
+ sprintf('%#x', 100) # => "0x64"
+
+=== <tt>'+'</tt> Flag
+
+Add a leading plus sign for a non-negative number:
+
+ sprintf('%x', 100) # => "64"
+ sprintf('%+x', 100) # => "+64"
+
+=== <tt>'-'</tt> Flag
+
+Left justify the value in its field:
+
+ sprintf('%6d', 100) # => " 100"
+ sprintf('%-6d', 100) # => "100 "
+
+=== <tt>'0'</tt> Flag
+
+Left-pad with zeros instead of spaces:
+
+ sprintf('%6d', 100) # => " 100"
+ sprintf('%06d', 100) # => "000100"
+
+=== <tt>'n$'</tt> Flag
+
+Format the (1-based) <tt>n</tt>th argument into this field:
+
+ sprintf("%s %s", 'world', 'hello') # => "world hello"
+ sprintf("%2$s %1$s", 'world', 'hello') # => "hello world"
+
+== Width Specifier
+
+In general, a width specifier determines the minimum width (in characters)
+of the formatted field:
+
+ sprintf('%10d', 100) # => " 100"
+
+ # Left-justify if negative.
+ sprintf('%-10d', 100) # => "100 "
+
+ # Ignore if too small.
+ sprintf('%1d', 100) # => "100"
+
+If the width specifier is <tt>'*'</tt> instead of an integer, the actual minimum
+width is taken from the argument list:
+
+ sprintf('%*d', 20, 14) # => " 14"
+
+== Precision Specifier
+
+A precision specifier is a decimal point followed by zero or more
+decimal digits.
+
+For integer type specifiers, the precision specifies the minimum number of
+digits to be written. If the precision is shorter than the integer, the result is
+padded with leading zeros. There is no modification or truncation of the result
+if the integer is longer than the precision:
+
+ sprintf('%.3d', 1) # => "001"
+ sprintf('%.3d', 1000) # => "1000"
+
+ # If the precision is 0 and the value is 0, nothing is written
+ sprintf('%.d', 0) # => ""
+ sprintf('%.0d', 0) # => ""
+
+For the +a+/+A+, +e+/+E+, +f+ specifiers, the precision specifies
+the number of digits after the decimal point to be written:
+
+ sprintf('%.2f', 3.14159) # => "3.14"
+ sprintf('%.10f', 3.14159) # => "3.1415900000"
+
+ # With no precision specifier, defaults to 6-digit precision.
+ sprintf('%f', 3.14159) # => "3.141590"
+
+For the +g+/+G+ specifiers, the precision specifies
+the number of significant digits to be written:
+
+ sprintf('%.2g', 123.45) # => "1.2e+02"
+ sprintf('%.3g', 123.45) # => "123"
+ sprintf('%.10g', 123.45) # => "123.45"
+
+ # With no precision specifier, defaults to 6 significant digits.
+ sprintf('%g', 123.456789) # => "123.457"
+
+For the +s+, +p+ specifiers, the precision specifies
+the number of characters to write:
+
+ sprintf('%s', Time.now) # => "2022-05-04 11:59:16 -0400"
+ sprintf('%.10s', Time.now) # => "2022-05-04"
+
+If the precision specifier is <tt>'*'</tt> instead of a non-negative integer,
+the actual precision is taken from the argument list:
+
+ sprintf('%.*d', 20, 1) # => "00000000000000000001"
+
+== Type Specifier Details and Examples
+
+=== Specifiers +a+ and +A+
+
+Format +argument+ as hexadecimal floating-point number:
+
+ sprintf('%a', 3.14159) # => "0x1.921f9f01b866ep+1"
+ sprintf('%a', -3.14159) # => "-0x1.921f9f01b866ep+1"
+ sprintf('%a', 4096) # => "0x1p+12"
+ sprintf('%a', -4096) # => "-0x1p+12"
+
+ # Capital 'A' means that alphabetical characters are printed in upper case.
+ sprintf('%A', 4096) # => "0X1P+12"
+ sprintf('%A', -4096) # => "-0X1P+12"
+
+=== Specifiers +b+ and +B+
+
+The two specifiers +b+ and +B+ behave identically
+except when flag <tt>'#'</tt>+ is used.
+
+Format +argument+ as a binary integer:
+
+ sprintf('%b', 1) # => "1"
+ sprintf('%b', 4) # => "100"
+
+ # Prefix '..' for negative value.
+ sprintf('%b', -4) # => "..100"
+
+ # Alternate format.
+ sprintf('%#b', 4) # => "0b100"
+ sprintf('%#B', 4) # => "0B100"
+
+=== Specifier +c+
+
+Format +argument+ as a single character:
+
+ sprintf('%c', 'A') # => "A"
+ sprintf('%c', 65) # => "A"
+
+This behaves like String#<<, except for raising ArgumentError instead of RangeError.
+
+=== Specifier +d+
+
+Format +argument+ as a decimal integer:
+
+ sprintf('%d', 100) # => "100"
+ sprintf('%d', -100) # => "-100"
+
+Flag <tt>'#'</tt> does not apply.
+
+=== Specifiers +e+ and +E+
+
+Format +argument+ in
+{scientific notation}[https://en.wikipedia.org/wiki/Scientific_notation]:
+
+ sprintf('%e', 3.14159) # => "3.141590e+00"
+ sprintf('%E', -3.14159) # => "-3.141590E+00"
+
+=== Specifier +f+
+
+Format +argument+ as a floating-point number:
+
+ sprintf('%f', 3.14159) # => "3.141590"
+ sprintf('%f', -3.14159) # => "-3.141590"
+
+Flag <tt>'#'</tt> does not apply.
+
+=== Specifiers +g+ and +G+
+
+Format +argument+ using exponential form (+e+/+E+ specifier)
+if the exponent is less than -4 or greater than or equal to the precision.
+Otherwise format +argument+ using floating-point form (+f+ specifier):
+
+ sprintf('%g', 100) # => "100"
+ sprintf('%g', 100.0) # => "100"
+ sprintf('%g', 3.14159) # => "3.14159"
+ sprintf('%g', 100000000000) # => "1e+11"
+ sprintf('%g', 0.000000000001) # => "1e-12"
+
+ # Capital 'G' means use capital 'E'.
+ sprintf('%G', 100000000000) # => "1E+11"
+ sprintf('%G', 0.000000000001) # => "1E-12"
+
+ # Alternate format.
+ sprintf('%#g', 100000000000) # => "1.00000e+11"
+ sprintf('%#g', 0.000000000001) # => "1.00000e-12"
+ sprintf('%#G', 100000000000) # => "1.00000E+11"
+ sprintf('%#G', 0.000000000001) # => "1.00000E-12"
+
+=== Specifier +o+
+
+Format +argument+ as an octal integer.
+If +argument+ is negative, it will be formatted as a two's complement
+prefixed with +..7+:
+
+ sprintf('%o', 16) # => "20"
+
+ # Prefix '..7' for negative value.
+ sprintf('%o', -16) # => "..760"
+
+ # Prefix zero for alternate format if positive.
+ sprintf('%#o', 16) # => "020"
+ sprintf('%#o', -16) # => "..760"
+
+=== Specifier +p+
+
+Format +argument+ as a string via <tt>argument.inspect</tt>:
+
+ t = Time.now
+ sprintf('%p', t) # => "2022-05-01 13:42:07.1645683 -0500"
+
+=== Specifier +s+
+
+Format +argument+ as a string via <tt>argument.to_s</tt>:
+
+ t = Time.now
+ sprintf('%s', t) # => "2022-05-01 13:42:07 -0500"
+
+Flag <tt>'#'</tt> does not apply.
+
+=== Specifiers +x+ and +X+
+
+Format +argument+ as a hexadecimal integer.
+If +argument+ is negative, it will be formatted as a two's complement
+prefixed with +..f+:
+
+ sprintf('%x', 100) # => "64"
+
+ # Prefix '..f' for negative value.
+ sprintf('%x', -100) # => "..f9c"
+
+ # Use alternate format.
+ sprintf('%#x', 100) # => "0x64"
+
+ # Alternate format for negative value.
+ sprintf('%#x', -100) # => "0x..f9c"
+
+=== Specifier <tt>%</tt>
+
+Format +argument+ (<tt>'%'</tt>) as a single percent character:
+
+ sprintf('%d %%', 100) # => "100 %"
+
+Flags do not apply.
+
+== Reference by Name
+
+For more complex formatting, Ruby supports a reference by name.
+%<name>s style uses format style, but %{name} style doesn't.
+
+Examples:
+
+ sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000
+ sprintf("%{foo}f", { :foo => 1 }) # => "1f"
diff --git a/doc/language/globals.md b/doc/language/globals.md
new file mode 100644
index 0000000000..0f6b632a08
--- /dev/null
+++ b/doc/language/globals.md
@@ -0,0 +1,611 @@
+# Pre-Defined Global Variables
+
+Some of the pre-defined global variables have synonyms
+that are available via module English.
+For each of those, the \English synonym is given.
+
+To use the module:
+
+```ruby
+require 'English'
+```
+
+## In Brief
+
+### Exceptions
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:--------:|:-----------------:|----------------------------------------|:---------:|:---------:|--------------|
+| `$!` | `$ERROR_INFO` | \Exception object or `nil` | `nil` | Yes | Kernel#raise |
+| `$@` | `$ERROR_POSITION` | \Array of backtrace positions or `nil` | `nil` | Yes | Kernel#raise |
+
+### Matched \Data
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:---------:|:-------------------:|-----------------------------------|:---------:|:---------:|-----------------|
+| `$~` | `$LAST_MATCH_INFO` | \MatchData object or `nil` | `nil` | No | Matcher methods |
+| `$&` | `$MATCH` | Matched substring or `nil` | `nil` | No | Matcher methods |
+| `` $` `` | `$PRE_MATCH` | Substring left of match or `nil` | `nil` | No | Matcher methods |
+| `$'` | `$POST_MATCH` | Substring right of match or `nil` | `nil` | No | Matcher methods |
+| `$+` | `$LAST_PAREN_MATCH` | Last group matched or `nil` | `nil` | No | Matcher methods |
+| `$1` | | First group matched or `nil` | `nil` | Yes | Matcher methods |
+| `$2` | | Second group matched or `nil` | `nil` | Yes | Matcher methods |
+| `$n` | | <i>n</i>th group matched or `nil` | `nil` | Yes | Matcher methods |
+
+### Separators
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:-----------:|:---------------------------:|-------------------------|:---------:|:---------:|----------|
+| `$/`, `$-0` | `$INPUT_RECORD_SEPARATOR` | Input record separator | Newline | No | |
+| `$\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator | `nil` | No | |
+
+### Streams
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:---------:|:----------------------------:|---------------------------------------------|:---------:|:---------:|----------------------|
+| `$stdin` | | Standard input stream | `STDIN` | No | |
+| `$stdout` | | Standard output stream | `STDOUT` | No | |
+| `$stderr` | | Standard error stream | `STDERR` | No | |
+| `$<` | `$DEFAULT_INPUT` | Default standard input | `ARGF` | Yes | |
+| `$>` | `$DEFAULT_OUTPUT` | Default standard output | `STDOUT` | No | |
+| `$.` | `$INPUT_LINE_NUMBER`, `$NR` | Input position of most recently read stream | 0 | No | Certain read methods |
+| `$_` | `$LAST_READ_LINE` | String from most recently read stream | `nil` | No | Certain read methods |
+
+### Processes
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:-------------------------:|:----------------------:|---------------------------------|:-------------:|:---------:|----------|
+| `$0`, `$PROGRAM_NAME` | | Program name | Program name | No | |
+| `$*` | `$ARGV` | \ARGV array | `ARGV` | Yes | |
+| `$$` | `$PROCESS_ID`, `$PID` | Process id | Process PID | Yes | |
+| `$?` | `$CHILD_STATUS` | Status of recently exited child | `nil` | Yes | |
+| `$LOAD_PATH`, `$:`, `$-I` | | \Array of search paths | Ruby defaults | Yes | |
+| `$LOADED_FEATURES`, `$"` | | \Array of load paths | Ruby defaults | Yes | |
+
+### Debugging
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:-----------:|:--------:|--------------------------------------------|:----------------------------:|:---------:|----------|
+| `$FILENAME` | | Value returned by method `ARGF.filename` | Command-line argument or '-' | Yes | |
+| `$DEBUG` | | Whether option `-d` or `--debug` was given | Command-line option | No | |
+| `$VERBOSE` | | Whether option `-V` or `-W` was given | Command-line option | No | |
+
+### Other Variables
+
+| Variable | \English | Contains | Initially | Read-Only | Reset By |
+|:-----------:|:--------:|-----------------------------------------------|:---------:|:---------:|----------|
+| `$-F`, `$;` | | Separator given with command-line option `-F` | | | |
+| `$-a` | | Whether option `-a` was given | | Yes | |
+| `$-i` | | Extension given with command-line option `-i` | | No | |
+| `$-l` | | Whether option `-l` was given | | Yes | |
+| `$-p` | | Whether option `-p` was given | | Yes | |
+| `$F` | | \Array of `$_` split by `$-F` | | | |
+
+## Exceptions
+
+### `$!` (\Exception)
+
+Contains the Exception object set by Kernel#raise:
+
+```ruby
+begin
+ raise RuntimeError.new('Boo!')
+rescue RuntimeError
+ p $!
+end
+```
+
+Output:
+
+```
+#<RuntimeError: Boo!>
+```
+
+English - `$ERROR_INFO`
+
+### `$@` (Backtrace)
+
+Same as `$!.backtrace`;
+returns an array of backtrace positions:
+
+```ruby
+begin
+ raise RuntimeError.new('Boo!')
+rescue RuntimeError
+ pp $@.take(4)
+end
+```
+
+Output:
+
+```
+["(irb):338:in `<top (required)>'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/workspace.rb:119:in `eval'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/workspace.rb:119:in `evaluate'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/context.rb:502:in `evaluate'"]
+```
+
+English - `$ERROR_POSITION`.
+
+## Matched \Data
+
+These global variables store information about the most recent
+successful match in the current scope.
+
+For details and examples,
+see [Regexp Global Variables].
+
+### `$~` (\MatchData)
+
+MatchData object created from the match;
+thread-local and frame-local.
+
+English - `$LAST_MATCH_INFO`.
+
+### `$&` (Matched Substring)
+
+The matched string.
+
+English - `$MATCH`.
+
+### `` $` `` (Pre-Match Substring)
+The string to the left of the match.
+
+English - `$PREMATCH`.
+
+### `$'` (Post-Match Substring)
+
+The string to the right of the match.
+
+English - `$POSTMATCH`.
+
+### `$+` (Last Matched Group)
+
+The last group matched.
+
+English - `$LAST_PAREN_MATCH`.
+
+### `$1`, `$2`, \Etc. (Matched Group)
+
+For <tt>$n</tt> the <i>n</i>th group of the match.
+
+No \English.
+
+## Separators
+
+### `$/` (Input Record Separator)
+
+An input record separator, initially newline.
+Set by the [command-line option `-0`].
+
+Setting to non-nil value by other than the command-line option is
+deprecated.
+
+English - `$INPUT_RECORD_SEPARATOR`, `$RS`.
+
+Aliased as `$-0`.
+
+### `$\` (Output Record Separator)
+
+An output record separator, initially `nil`.
+
+Copied from `$/` when the [command-line option `-l`] is
+given.
+
+Setting to non-nil value by other than the command-line option is
+deprecated.
+
+English - `$OUTPUT_RECORD_SEPARATOR`, `$ORS`.
+
+## Streams
+
+### `$stdin` (Standard Input)
+
+The current standard input stream; initially:
+
+```ruby
+$stdin # => #<IO:<STDIN>>
+```
+
+### `$stdout` (Standard Output)
+
+The current standard output stream; initially:
+
+```ruby
+$stdout # => #<IO:<STDOUT>>
+```
+
+### `$stderr` (Standard Error)
+
+The current standard error stream; initially:
+
+```ruby
+$stderr # => #<IO:<STDERR>>
+```
+
+### `$<` (\ARGF or $stdin)
+
+Points to stream ARGF if not empty, else to stream $stdin; read-only.
+
+English - `$DEFAULT_INPUT`.
+
+### `$>` (Default Standard Output)
+
+An output stream, initially `$stdout`.
+
+English - `$DEFAULT_OUTPUT`
+
+### `$.` (Input Position)
+
+The input position (line number) in the most recently read stream.
+
+English - `$INPUT_LINE_NUMBER`, `$NR`
+
+### `$_` (Last Read Line)
+
+The line (string) from the most recently read stream.
+
+English - `$LAST_READ_LINE`.
+
+## Processes
+
+### `$0`
+
+Initially, contains the name of the script being executed;
+may be reassigned.
+
+### `$*` (\ARGV)
+
+Points to ARGV.
+
+English - `$ARGV`.
+
+### `$$` (Process ID)
+
+The process ID of the current process. Same as Process.pid.
+
+English - `$PROCESS_ID`, `$PID`.
+
+### `$?` (Child Status)
+
+Initially `nil`, otherwise the Process::Status object
+created for the most-recently exited child process;
+thread-local.
+
+English - `$CHILD_STATUS`.
+
+### `$LOAD_PATH` (Load Path)
+
+Contains the array of paths to be searched
+by Kernel#load and Kernel#require.
+
+Singleton method `$LOAD_PATH.resolve_feature_path(feature)`
+returns:
+
+- <tt>[:rb, path]</tt>, where `path` is the path to the Ruby file to be
+ loaded for the given `feature`.
+- <tt>[:so, path]</tt>, where `path` is the path to the shared object file
+ to be loaded for the given `feature`.
+- `nil` if there is no such `feature` and `path`.
+
+Examples:
+
+```ruby
+$LOAD_PATH.resolve_feature_path('timeout')
+# => [:rb, "/snap/ruby/317/lib/ruby/3.2.0/timeout.rb"]
+$LOAD_PATH.resolve_feature_path('date_core')
+# => [:so, "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/date_core.so"]
+$LOAD_PATH.resolve_feature_path('foo')
+# => nil
+```
+
+Aliased as `$:` and `$-I`.
+
+### `$LOADED_FEATURES`
+
+Contains an array of the paths to the loaded files:
+
+```ruby
+$LOADED_FEATURES.take(10)
+# =>
+["enumerator.so",
+ "thread.rb",
+ "fiber.so",
+ "rational.so",
+ "complex.so",
+ "ruby2_keywords.rb",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/enc/encdb.so",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/enc/trans/transdb.so",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/rbconfig.rb",
+ "/snap/ruby/317/lib/ruby/3.2.0/rubygems/compatibility.rb"]
+```
+
+Aliased as `$"`.
+
+## Debugging
+
+### `$FILENAME`
+
+The value returned by method ARGF.filename.
+
+### `$DEBUG`
+
+Initially `true` if [command-line option `-d`] or
+[`--debug`][command-line option `-d`] is given, otherwise initially `false`;
+may be set to either value in the running program.
+
+When `true`, prints each raised exception to `$stderr`.
+
+Aliased as `$-d`.
+
+### `$VERBOSE`
+
+Initially `true` if [command-line option `-v`] or
+[command-line option `-w`] is given, otherwise initially `false`;
+may be set to either value, or to `nil`, in the running program.
+
+When `true`, enables Ruby warnings.
+
+When `nil`, disables warnings, including those from Kernel#warn.
+
+Aliased as `$-v` and `$-w`.
+
+## Other Variables
+
+### `$-F`
+
+The default field separator in String#split; must be a String or a
+Regexp, and can be set with [command-line option `-F`].
+
+Setting to non-nil value by other than the command-line option is
+deprecated.
+
+Aliased as `$;`.
+
+### `$-a`
+
+Whether [command-line option `-a`] was given; read-only.
+
+### `$-i`
+
+Contains the extension given with [command-line option `-i`],
+or `nil` if none.
+
+An alias of ARGF.inplace_mode.
+
+### `$-l`
+
+Whether [command-line option `-l`] was set; read-only.
+
+### `$-p`
+
+Whether [command-line option `-p`] was given; read-only.
+
+### `$F`
+
+If the [command-line option `-a`] is given, the array
+obtained by splitting `$_` by `$-F` is assigned at the start of each
+`-l`/`-p` loop.
+
+## Deprecated
+
+### `$=`
+
+### `$,`
+
+# Pre-Defined Global Constants
+
+## Summary
+
+### Streams
+
+| Constant | Contains |
+|:--------:|-------------------------|
+| `STDIN` | Standard input stream. |
+| `STDOUT` | Standard output stream. |
+| `STDERR` | Standard error stream. |
+
+### Environment
+
+| Constant | Contains |
+|-----------------------|-------------------------------------------------------------------------------|
+| `ENV` | Hash of current environment variable names and values. |
+| `ARGF` | String concatenation of files given on the command line, or `$stdin` if none. |
+| `ARGV` | Array of the given command-line arguments. |
+| `TOPLEVEL_BINDING` | Binding of the top level scope. |
+| `RUBY_VERSION` | String Ruby version. |
+| `RUBY_RELEASE_DATE` | String Ruby release date. |
+| `RUBY_PLATFORM` | String Ruby platform. |
+| `RUBY_PATCH_LEVEL` | String Ruby patch level. |
+| `RUBY_REVISION` | String Ruby revision. |
+| `RUBY_COPYRIGHT` | String Ruby copyright. |
+| `RUBY_ENGINE` | String Ruby engine. |
+| `RUBY_ENGINE_VERSION` | String Ruby engine version. |
+| `RUBY_DESCRIPTION` | String Ruby description. |
+
+### Embedded \Data
+
+| Constant | Contains |
+|:---------------------:|-------------------------------------------------------------------------------|
+| `DATA` | File containing embedded data (lines following `__END__`, if any). |
+
+## Streams
+
+### `STDIN`
+
+The standard input stream (the default value for `$stdin`):
+
+```ruby
+STDIN # => #<IO:<STDIN>>
+```
+
+### `STDOUT`
+
+The standard output stream (the default value for `$stdout`):
+
+```ruby
+STDOUT # => #<IO:<STDOUT>>
+```
+
+### `STDERR`
+
+The standard error stream (the default value for `$stderr`):
+
+```ruby
+STDERR # => #<IO:<STDERR>>
+```
+
+## Environment
+
+### `ENV`
+
+A hash of the contains current environment variables names and values:
+
+```ruby
+ENV.take(5)
+# =>
+[["COLORTERM", "truecolor"],
+ ["DBUS_SESSION_BUS_ADDRESS", "unix:path=/run/user/1000/bus"],
+ ["DESKTOP_SESSION", "ubuntu"],
+ ["DISPLAY", ":0"],
+ ["GDMSESSION", "ubuntu"]]
+```
+
+### `ARGF`
+
+The virtual concatenation of the files given on the command line, or from
+`$stdin` if no files were given, `"-"` is given, or after
+all files have been read.
+
+### `ARGV`
+
+An array of the given command-line arguments.
+
+### `TOPLEVEL_BINDING`
+
+The Binding of the top level scope:
+
+```ruby
+TOPLEVEL_BINDING # => #<Binding:0x00007f58da0da7c0>
+```
+
+### `RUBY_VERSION`
+
+The Ruby version:
+
+```ruby
+RUBY_VERSION # => "3.2.2"
+```
+
+### `RUBY_RELEASE_DATE`
+
+The release date string:
+
+```ruby
+RUBY_RELEASE_DATE # => "2023-03-30"
+```
+
+### `RUBY_PLATFORM`
+
+The platform identifier:
+
+```ruby
+RUBY_PLATFORM # => "x86_64-linux"
+```
+
+### `RUBY_PATCHLEVEL`
+
+The integer patch level for this Ruby:
+
+```ruby
+RUBY_PATCHLEVEL # => 53
+```
+
+For a development build the patch level will be -1.
+
+### `RUBY_REVISION`
+
+The git commit hash for this Ruby:
+
+```ruby
+RUBY_REVISION # => "e51014f9c05aa65cbf203442d37fef7c12390015"
+```
+
+### `RUBY_COPYRIGHT`
+
+The copyright string:
+
+```ruby
+RUBY_COPYRIGHT
+# => "ruby - Copyright (C) 1993-2023 Yukihiro Matsumoto"
+```
+
+### `RUBY_ENGINE`
+
+The name of the Ruby implementation:
+
+```ruby
+RUBY_ENGINE # => "ruby"
+```
+
+### `RUBY_ENGINE_VERSION`
+
+The version of the Ruby implementation:
+
+```ruby
+RUBY_ENGINE_VERSION # => "3.2.2"
+```
+
+### `RUBY_DESCRIPTION`
+
+The description of the Ruby implementation:
+
+```ruby
+RUBY_DESCRIPTION
+# => "ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]"
+```
+
+## Embedded \Data
+
+### `DATA`
+
+Defined if and only if the program has this line:
+
+```ruby
+__END__
+```
+
+When defined, `DATA` is a File object
+containing the lines following the `__END__`,
+positioned at the first of those lines:
+
+```ruby
+p DATA
+DATA.each_line { |line| p line }
+__END__
+Foo
+Bar
+Baz
+```
+
+Output:
+
+```
+#<File:t.rb>
+"Foo\n"
+"Bar\n"
+"Baz\n"
+```
+
+[command-line option `-0`]: rdoc-ref:language/options.md@-0-set--input-record-separator
+[command-line option `-F`]: rdoc-ref:language/options.md@-f-set-input-field-separator
+[command-line option `-a`]: rdoc-ref:language/options.md@-a-split-input-lines-into-fields
+[command-line option `-d`]: rdoc-ref:language/options.md@-d-set-debug-to-true
+[command-line option `-i`]: rdoc-ref:language/options.md@-i-set-argf-in-place-mode
+[command-line option `-l`]: rdoc-ref:language/options.md@-l-set-output-record-separator-chop-lines
+[command-line option `-p`]: rdoc-ref:language/options.md@-p--n-with-printing
+[command-line option `-v`]: rdoc-ref:language/options.md@-v-print-version-set-verbose
+[command-line option `-w`]: rdoc-ref:language/options.md@-w-synonym-for--w1
+
+[Regexp Global Variables]: rdoc-ref:Regexp@Global+Variables
+
diff --git a/doc/language/hash_inclusion.rdoc b/doc/language/hash_inclusion.rdoc
new file mode 100644
index 0000000000..05c2b0932a
--- /dev/null
+++ b/doc/language/hash_inclusion.rdoc
@@ -0,0 +1,31 @@
+== \Hash Inclusion
+
+A hash is set-like in that it cannot have duplicate entries
+(or even duplicate keys).
+\Hash inclusion can therefore based on the idea of
+{subset and superset}[https://en.wikipedia.org/wiki/Subset].
+
+Two hashes may be tested for inclusion,
+based on comparisons of their entries.
+
+An entry <tt>h0[k0]</tt> in one hash
+is equal to an entry <tt>h1[k1]</tt> in another hash
+if and only if the two keys are equal (<tt>k0 == k1</tt>)
+and their two values are equal (<tt>h0[k0] == h1[h1]</tt>).
+
+A hash may be a subset or a superset of another hash:
+
+- Subset (included in or equal to another):
+
+ - \Hash +h0+ is a _subset_ of hash +h1+ (see Hash#<=)
+ if each entry in +h0+ is equal to an entry in +h1+.
+ - Further, +h0+ is a <i>proper subset</i> of +h1+ (see Hash#<)
+ if +h1+ is larger than +h0+.
+
+- Superset (including or equal to another):
+
+ - \Hash +h0+ is a _superset_ of hash +h1+ (see Hash#>=)
+ if each entry in +h1+ is equal to an entry in +h0+.
+ - Further, +h0+ is a <i>proper superset</i> of +h1+ (see Hash#>)
+ if +h0+ is larger than +h1+.
+
diff --git a/doc/language/implicit_conversion.rdoc b/doc/language/implicit_conversion.rdoc
new file mode 100644
index 0000000000..e244096125
--- /dev/null
+++ b/doc/language/implicit_conversion.rdoc
@@ -0,0 +1,221 @@
+= Implicit Conversions
+
+Some Ruby methods accept one or more objects
+that can be either:
+
+* <i>Of a given class</i>, and so accepted as is.
+* <i>Implicitly convertible to that class</i>, in which case
+ the called method converts the object.
+
+For each of the relevant classes, the conversion is done by calling
+a specific conversion method:
+
+* Array: +to_ary+
+* Hash: +to_hash+
+* Integer: +to_int+
+* String: +to_str+
+
+== Array-Convertible Objects
+
+An <i>Array-convertible object</i> is an object that:
+
+* Has instance method +to_ary+.
+* The method accepts no arguments.
+* The method returns an object +obj+ for which <tt>obj.kind_of?(Array)</tt> returns +true+.
+
+The Ruby core class that satisfies these requirements is:
+
+* Array
+
+The examples in this section use method <tt>Array#replace</tt>,
+which accepts an Array-convertible argument.
+
+This class is Array-convertible:
+
+ class ArrayConvertible
+ def to_ary
+ [:foo, 'bar', 2]
+ end
+ end
+ a = []
+ a.replace(ArrayConvertible.new) # => [:foo, "bar", 2]
+
+This class is not Array-convertible (no +to_ary+ method):
+
+ class NotArrayConvertible; end
+ a = []
+ # Raises TypeError (no implicit conversion of NotArrayConvertible into Array)
+ a.replace(NotArrayConvertible.new)
+
+This class is not Array-convertible (method +to_ary+ takes arguments):
+
+ class NotArrayConvertible
+ def to_ary(x)
+ [:foo, 'bar', 2]
+ end
+ end
+ a = []
+ # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
+ a.replace(NotArrayConvertible.new)
+
+This class is not Array-convertible (method +to_ary+ returns non-Array):
+
+ class NotArrayConvertible
+ def to_ary
+ :foo
+ end
+ end
+ a = []
+ # Raises TypeError (can't convert NotArrayConvertible to Array (NotArrayConvertible#to_ary gives Symbol))
+ a.replace(NotArrayConvertible.new)
+
+== Hash-Convertible Objects
+
+A <i>Hash-convertible object</i> is an object that:
+
+* Has instance method +to_hash+.
+* The method accepts no arguments.
+* The method returns an object +obj+ for which <tt>obj.kind_of?(Hash)</tt> returns +true+.
+
+The Ruby core class that satisfies these requirements is:
+
+* Hash
+
+The examples in this section use method <tt>Hash#merge</tt>,
+which accepts a Hash-convertible argument.
+
+This class is Hash-convertible:
+
+ class HashConvertible
+ def to_hash
+ {foo: 0, bar: 1, baz: 2}
+ end
+ end
+ h = {}
+ h.merge(HashConvertible.new) # => {:foo=>0, :bar=>1, :baz=>2}
+
+This class is not Hash-convertible (no +to_hash+ method):
+
+ class NotHashConvertible; end
+ h = {}
+ # Raises TypeError (no implicit conversion of NotHashConvertible into Hash)
+ h.merge(NotHashConvertible.new)
+
+This class is not Hash-convertible (method +to_hash+ takes arguments):
+
+ class NotHashConvertible
+ def to_hash(x)
+ {foo: 0, bar: 1, baz: 2}
+ end
+ end
+ h = {}
+ # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
+ h.merge(NotHashConvertible.new)
+
+This class is not Hash-convertible (method +to_hash+ returns non-Hash):
+
+ class NotHashConvertible
+ def to_hash
+ :foo
+ end
+ end
+ h = {}
+ # Raises TypeError (can't convert NotHashConvertible to Hash (ToHashReturnsNonHash#to_hash gives Symbol))
+ h.merge(NotHashConvertible.new)
+
+== Integer-Convertible Objects
+
+An <i>Integer-convertible object</i> is an object that:
+
+* Has instance method +to_int+.
+* The method accepts no arguments.
+* The method returns an object +obj+ for which <tt>obj.kind_of?(Integer)</tt> returns +true+.
+
+The Ruby core classes that satisfy these requirements are:
+
+* Integer
+* Float
+* Complex
+* Rational
+
+The examples in this section use method <tt>Array.new</tt>,
+which accepts an Integer-convertible argument.
+
+This user-defined class is Integer-convertible:
+
+ class IntegerConvertible
+ def to_int
+ 3
+ end
+ end
+ a = Array.new(IntegerConvertible.new).size
+ a # => 3
+
+This class is not Integer-convertible (method +to_int+ takes arguments):
+
+ class NotIntegerConvertible
+ def to_int(x)
+ 3
+ end
+ end
+ # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
+ Array.new(NotIntegerConvertible.new)
+
+This class is not Integer-convertible (method +to_int+ returns non-Integer):
+
+ class NotIntegerConvertible
+ def to_int
+ :foo
+ end
+ end
+ # Raises TypeError (can't convert NotIntegerConvertible to Integer (NotIntegerConvertible#to_int gives Symbol))
+ Array.new(NotIntegerConvertible.new)
+
+== String-Convertible Objects
+
+A <i>String-convertible object</i> is an object that:
+* Has instance method +to_str+.
+* The method accepts no arguments.
+* The method returns an object +obj+ for which <tt>obj.kind_of?(String)</tt> returns +true+.
+
+The Ruby core class that satisfies these requirements is:
+
+* String
+
+The examples in this section use method <tt>String::new</tt>,
+which accepts a String-convertible argument.
+
+This class is String-convertible:
+
+ class StringConvertible
+ def to_str
+ 'foo'
+ end
+ end
+ String.new(StringConvertible.new) # => "foo"
+
+This class is not String-convertible (no +to_str+ method):
+
+ class NotStringConvertible; end
+ # Raises TypeError (no implicit conversion of NotStringConvertible into String)
+ String.new(NotStringConvertible.new)
+
+This class is not String-convertible (method +to_str+ takes arguments):
+
+ class NotStringConvertible
+ def to_str(x)
+ 'foo'
+ end
+ end
+ # Raises ArgumentError (wrong number of arguments (given 0, expected 1))
+ String.new(NotStringConvertible.new)
+
+This class is not String-convertible (method +to_str+ returns non-String):
+
+ class NotStringConvertible
+ def to_str
+ :foo
+ end
+ end
+ # Raises TypeError (can't convert NotStringConvertible to String (NotStringConvertible#to_str gives Symbol))
+ String.new(NotStringConvertible.new)
diff --git a/doc/language/marshal.rdoc b/doc/language/marshal.rdoc
new file mode 100644
index 0000000000..740064ade6
--- /dev/null
+++ b/doc/language/marshal.rdoc
@@ -0,0 +1,318 @@
+= Marshal Format
+
+The Marshal format is used to serialize ruby objects. The format can store
+arbitrary objects through three user-defined extension mechanisms.
+
+For documentation on using Marshal to serialize and deserialize objects, see
+the Marshal module.
+
+This document calls a serialized set of objects a stream. The Ruby
+implementation can load a set of objects from a String, an IO or an object
+that implements a +getc+ method.
+
+== Stream Format
+
+The first two bytes of the stream contain the major and minor version, each as
+a single byte encoding a digit. The version implemented in Ruby is 4.8
+(stored as "\x04\x08") and is supported by ruby 1.8.0 and newer.
+
+Different major versions of the Marshal format are not compatible and cannot
+be understood by other major versions. Lesser minor versions of the format
+can be understood by newer minor versions. Format 4.7 can be loaded by a 4.8
+implementation but format 4.8 cannot be loaded by a 4.7 implementation.
+
+Following the version bytes is a stream describing the serialized object. The
+stream contains nested objects (the same as a Ruby object) but objects in the
+stream do not necessarily have a direct mapping to the Ruby object model.
+
+Each object in the stream is described by a byte indicating its type followed
+by one or more bytes describing the object. When "object" is mentioned below
+it means any of the types below that defines a Ruby object.
+
+=== true, false, nil
+
+These objects are each one byte long. "T" is represents +true+, "F"
+represents +false+ and "0" represents +nil+.
+
+=== Fixnum and long
+
+"i" represents a signed 32 bit value using a packed format. One through five
+bytes follows the type. The value loaded will always be a Fixnum. On
+32 bit platforms (where the precision of a Fixnum is less than 32 bits)
+loading large values will cause overflow on CRuby.
+
+The fixnum type is used to represent both ruby Fixnum objects and the sizes of
+marshaled arrays, hashes, instance variables and other types. In the
+following sections "long" will mean the format described below, which supports
+full 32 bit precision.
+
+The first byte has the following special values:
+
+"\x00"::
+ The value of the integer is 0. No bytes follow.
+
+"\x01"::
+ The total size of the integer is two bytes. The following byte is a
+ positive integer in the range of 0 through 255. Only values between 123
+ and 255 should be represented this way to save bytes.
+
+"\xff"::
+ The total size of the integer is two bytes. The following byte is a
+ negative integer in the range of -1 through -256.
+
+"\x02"::
+ The total size of the integer is three bytes. The following two bytes are a
+ positive little-endian integer.
+
+"\xfe"::
+ The total size of the integer is three bytes. The following two bytes are a
+ negative little-endian integer.
+
+"\x03"::
+ The total size of the integer is four bytes. The following three bytes are
+ a positive little-endian integer.
+
+"\xfd"::
+ The total size of the integer is four bytes. The following three bytes are a
+ negative little-endian integer.
+
+"\x04"::
+ The total size of the integer is five bytes. The following four bytes are a
+ positive little-endian integer. For compatibility with 32 bit ruby,
+ only Fixnums less than 1073741824 should be represented this way. For sizes
+ of stream objects full precision may be used.
+
+"\xfc"::
+ The total size of the integer is five bytes. The following four bytes are a
+ negative little-endian integer. For compatibility with 32 bit ruby,
+ only Fixnums greater than -10737341824 should be represented this way. For
+ sizes of stream objects full precision may be used.
+
+Otherwise the first byte is a sign-extended eight-bit value with an offset.
+If the value is positive the value is determined by subtracting 5 from the
+value. If the value is negative the value is determined by adding 5 to the
+value.
+
+There are multiple representations for many values. CRuby always outputs the
+shortest representation possible.
+
+=== Symbols and Byte Sequence
+
+":" represents a real symbol. A real symbol contains the data needed to
+define the symbol for the rest of the stream as future occurrences in the
+stream will instead be references (a symbol link) to this one. The reference
+is a zero-indexed 32 bit value (so the first occurrence of <code>:hello</code>
+is 0).
+
+Following the type byte is byte sequence which consists of a long indicating
+the number of bytes in the sequence followed by that many bytes of data. Byte
+sequences have no encoding.
+
+For example, the following stream contains the Symbol <code>:hello</code>:
+
+ "\x04\x08:\x0ahello"
+
+";" represents a Symbol link which references a previously defined Symbol.
+Following the type byte is a long containing the index in the lookup table for
+the linked (referenced) Symbol.
+
+For example, the following stream contains <code>[:hello, :hello]</code>:
+
+ "\x04\b[\a:\nhello;\x00"
+
+When a "symbol" is referenced below it may be either a real symbol or a
+symbol link.
+
+=== Object References
+
+Separate from but similar to symbol references, the stream contains only one
+copy of each object (as determined by #object_id) for all objects except
+true, false, nil, Fixnums and Symbols (which are stored separately as
+described above) a one-indexed 32 bit value will be stored and reused when the
+object is encountered again. (The first object has an index of 1).
+
+"@" represents an object link. Following the type byte is a long giving the
+index of the object.
+
+For example, the following stream contains an Array of the same
+<code>"hello"</code> object twice:
+
+ "\004\b[\a\"\nhello@\006"
+
+=== Instance Variables
+
+"I" indicates that instance variables follow the next object. An object
+follows the type byte. Following the object is a length indicating the number
+of instance variables for the object. Following the length is a set of
+name-value pairs. The names are symbols while the values are objects. The
+symbols must be instance variable names (<code>:@name</code>).
+
+An Object ("o" type, described below) uses the same format for its instance
+variables as described here.
+
+For a String and Regexp (described below) a special instance variable
+<code>:E</code> is used to indicate the Encoding.
+
+=== Extended
+
+"e" indicates that the next object is extended by a module. An object follows
+the type byte. Following the object is a symbol that contains the name of the
+module the object is extended by.
+
+=== Array
+
+"[" represents an Array. Following the type byte is a long indicating the
+number of objects in the array. The given number of objects follow the
+length.
+
+=== Bignum
+
+"l" represents a Bignum which is composed of three parts:
+
+sign::
+ A single byte containing "+" for a positive value or "-" for a negative
+ value.
+length::
+ A long indicating the number of bytes of Bignum data follows, divided by
+ two. Multiply the length by two to determine the number of bytes of data
+ that follow.
+data::
+ Bytes of Bignum data representing the number.
+
+The following ruby code will reconstruct the Bignum value from an array of
+bytes:
+
+ result = 0
+
+ bytes.each_with_index do |byte, exp|
+ result += (byte * 2 ** (exp * 8))
+ end
+
+=== +Class+ and +Module+
+
+"c" represents a +Class+ object, "m" represents a +Module+ and "M" represents
+either a class or module (this is an old-style for compatibility). No class
+or module content is included, this type is only a reference. Following the
+type byte is a byte sequence which is used to look up an existing class or
+module, respectively.
+
+Instance variables are not allowed on a class or module.
+
+If no class or module exists an exception should be raised.
+
+For "c" and "m" types, the loaded object must be a class or module,
+respectively.
+
+=== Data
+
+"d" represents a Data object. (Data objects are wrapped pointers from ruby
+extensions.) Following the type byte is a symbol indicating the class for the
+Data object and an object that contains the state of the Data object.
+
+To dump a Data object Ruby calls _dump_data. To load a Data object Ruby calls
+_load_data with the state of the object on a newly allocated instance.
+
+=== Float
+
+"f" represents a Float object. Following the type byte is a byte sequence
+containing the float value. The following values are special:
+
+"inf"::
+ Positive infinity
+
+"-inf"::
+ Negative infinity
+
+"nan"::
+ Not a Number
+
+Otherwise the byte sequence contains a C double (loadable by strtod(3)).
+Older minor versions of Marshal also stored extra mantissa bits to ensure
+portability across platforms but 4.8 does not include these. See
+[ruby-talk:69518] for some explanation.
+
+=== Hash and Hash with Default Value
+
+"{" represents a Hash object while "}" represents a Hash with a default value
+set (<code>Hash.new 0</code>). Following the type byte is a long indicating
+the number of key-value pairs in the Hash, the size. Double the given number
+of objects follow the size.
+
+For a Hash with a default value, the default value follows all the pairs.
+
+=== Module and Old Module
+
+=== Object
+
+"o" represents an object that doesn't have any other special form (such as
+a user-defined or built-in format). Following the type byte is a symbol
+containing the class name of the object. Following the class name is a long
+indicating the number of instance variable names and values for the object.
+Double the given number of pairs of objects follow the size.
+
+The keys in the pairs must be symbols containing instance variable names.
+
+=== Regular Expression
+
+"/" represents a regular expression. Following the type byte is a byte
+sequence containing the regular expression source. Following the type byte is
+a byte containing the regular expression options (case-insensitive, etc.) as a
+signed 8-bit value.
+
+Regular expressions can have an encoding attached through instance variables
+(see above). If no encoding is attached escapes for the following regexp
+specials not present in ruby 1.8 must be removed: g-m, o-q, u, y, E, F, H-L,
+N-V, X, Y.
+
+=== String
+
+'"' represents a String. Following the type byte is a byte sequence
+containing the string content. When dumped from ruby 1.9 an encoding instance
+variable (<code>:E</code> see above) should be included unless the encoding is
+binary.
+
+=== Struct
+
+"S" represents a Struct. Following the type byte is a symbol containing the
+name of the struct. Following the name is a long indicating the number of
+members in the struct. Double the number of objects follow the member count.
+Each member is a pair containing the member's symbol and an object for the
+value of that member.
+
+If the struct name does not match a Struct subclass in the running ruby an
+exception should be raised.
+
+If there is a mismatch between the struct in the currently running ruby and
+the member count in the marshaled struct an exception should be raised.
+
+=== User Class
+
+"C" represents a subclass of a String, Regexp, Array or Hash. Following the
+type byte is a symbol containing the name of the subclass. Following the name
+is the wrapped object.
+
+=== User Defined
+
+"u" represents an object with a user-defined serialization format using the
++_dump+ instance method and +_load+ class method. Following the type byte is
+a symbol containing the class name. Following the class name is a byte
+sequence containing the user-defined representation of the object.
+
+The class method +_load+ is called on the class with a string created from the
+byte-sequence.
+
+This type is not recommended for newly created classes, because of some
+restrictions:
+
+- cannot have recursive reference
+
+=== User Marshal
+
+"U" represents an object with a user-defined serialization format using the
++marshal_dump+ and +marshal_load+ instance methods. Following the type byte
+is a symbol containing the class name. Following the class name is an object
+containing the data.
+
+Upon loading a new instance must be allocated and +marshal_load+ must be
+called on the instance with the data.
+
diff --git a/doc/language/option_dump.md b/doc/language/option_dump.md
new file mode 100644
index 0000000000..328c6b52af
--- /dev/null
+++ b/doc/language/option_dump.md
@@ -0,0 +1,265 @@
+# Option `--dump`
+
+For other argument values,
+see {Option `--dump`}[rdoc-ref:options.md@--dump+Dump+Items].
+
+For the examples here, we use this program:
+
+```console
+$ cat t.rb
+puts 'Foo'
+```
+
+The supported dump items:
+
+- `insns`: Instruction sequences:
+
+ ```sh
+ $ ruby --dump=insns t.rb
+ == disasm: #<ISeq:<main>@t.rb:1 (1,0)-(1,10)> (catch: FALSE)
+ 0000 putself ( 1)[Li]
+ 0001 dupstring "Foo"
+ 0003 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
+ 0005 leave
+ ```
+
+- `parsetree`: {Abstract syntax tree}[https://en.wikipedia.org/wiki/Abstract_syntax_tree]
+ (AST):
+
+ ```console
+ $ ruby --dump=parsetree t.rb
+ ###########################################################
+ ## Do NOT use this node dump for any purpose other than ##
+ ## debug and research. Compatibility is not guaranteed. ##
+ ###########################################################
+
+ # @ NODE_SCOPE (line: 1, location: (1,0)-(1,10))
+ # +- nd_tbl: (empty)
+ # +- nd_args:
+ # | (null node)
+ # +- nd_body:
+ # @ NODE_FCALL (line: 1, location: (1,0)-(1,10))*
+ # +- nd_mid: :puts
+ # +- nd_args:
+ # @ NODE_LIST (line: 1, location: (1,5)-(1,10))
+ # +- nd_alen: 1
+ # +- nd_head:
+ # | @ NODE_STR (line: 1, location: (1,5)-(1,10))
+ # | +- nd_lit: "Foo"
+ # +- nd_next:
+ # (null node)
+ ```
+
+- `yydebug`: Debugging information from yacc parser generator:
+
+ ```
+ $ ruby --dump=yydebug t.rb
+ Starting parse
+ Entering state 0
+ Reducing stack by rule 1 (line 1295):
+ lex_state: NONE -> BEG at line 1296
+ vtable_alloc:12392: 0x0000558453df1a00
+ vtable_alloc:12393: 0x0000558453df1a60
+ cmdarg_stack(push): 0 at line 12406
+ cond_stack(push): 0 at line 12407
+ -> $$ = nterm $@1 (1.0-1.0: )
+ Stack now 0
+ Entering state 2
+ Reading a token:
+ lex_state: BEG -> CMDARG at line 9049
+ Next token is token "local variable or method" (1.0-1.4: puts)
+ Shifting token "local variable or method" (1.0-1.4: puts)
+ Entering state 35
+ Reading a token: Next token is token "string literal" (1.5-1.6: )
+ Reducing stack by rule 742 (line 5567):
+ $1 = token "local variable or method" (1.0-1.4: puts)
+ -> $$ = nterm operation (1.0-1.4: )
+ Stack now 0 2
+ Entering state 126
+ Reducing stack by rule 78 (line 1794):
+ $1 = nterm operation (1.0-1.4: )
+ -> $$ = nterm fcall (1.0-1.4: )
+ Stack now 0 2
+ Entering state 80
+ Next token is token "string literal" (1.5-1.6: )
+ Reducing stack by rule 292 (line 2723):
+ cmdarg_stack(push): 1 at line 2737
+ -> $$ = nterm $@16 (1.4-1.4: )
+ Stack now 0 2 80
+ Entering state 235
+ Next token is token "string literal" (1.5-1.6: )
+ Shifting token "string literal" (1.5-1.6: )
+ Entering state 216
+ Reducing stack by rule 607 (line 4706):
+ -> $$ = nterm string_contents (1.6-1.6: )
+ Stack now 0 2 80 235 216
+ Entering state 437
+ Reading a token: Next token is token "literal content" (1.6-1.9: "Foo")
+ Shifting token "literal content" (1.6-1.9: "Foo")
+ Entering state 503
+ Reducing stack by rule 613 (line 4802):
+ $1 = token "literal content" (1.6-1.9: "Foo")
+ -> $$ = nterm string_content (1.6-1.9: )
+ Stack now 0 2 80 235 216 437
+ Entering state 507
+ Reducing stack by rule 608 (line 4716):
+ $1 = nterm string_contents (1.6-1.6: )
+ $2 = nterm string_content (1.6-1.9: )
+ -> $$ = nterm string_contents (1.6-1.9: )
+ Stack now 0 2 80 235 216
+ Entering state 437
+ Reading a token:
+ lex_state: CMDARG -> END at line 7276
+ Next token is token "terminator" (1.9-1.10: )
+ Shifting token "terminator" (1.9-1.10: )
+ Entering state 508
+ Reducing stack by rule 590 (line 4569):
+ $1 = token "string literal" (1.5-1.6: )
+ $2 = nterm string_contents (1.6-1.9: )
+ $3 = token "terminator" (1.9-1.10: )
+ -> $$ = nterm string1 (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 109
+ Reducing stack by rule 588 (line 4559):
+ $1 = nterm string1 (1.5-1.10: )
+ -> $$ = nterm string (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 108
+ Reading a token:
+ lex_state: END -> BEG at line 9200
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 586 (line 4541):
+ $1 = nterm string (1.5-1.10: )
+ -> $$ = nterm strings (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 107
+ Reducing stack by rule 307 (line 2837):
+ $1 = nterm strings (1.5-1.10: )
+ -> $$ = nterm primary (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 90
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 261 (line 2553):
+ $1 = nterm primary (1.5-1.10: )
+ -> $$ = nterm arg (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 220
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 270 (line 2586):
+ $1 = nterm arg (1.5-1.10: )
+ -> $$ = nterm arg_value (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 221
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 297 (line 2779):
+ $1 = nterm arg_value (1.5-1.10: )
+ -> $$ = nterm args (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 224
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 772 (line 5626):
+ -> $$ = nterm none (1.10-1.10: )
+ Stack now 0 2 80 235 224
+ Entering state 442
+ Reducing stack by rule 296 (line 2773):
+ $1 = nterm none (1.10-1.10: )
+
+ -> $$ = nterm opt_block_arg (1.10-1.10: )
+ Stack now 0 2 80 235 224
+ Entering state 441
+ Reducing stack by rule 288 (line 2696):
+ $1 = nterm args (1.5-1.10: )
+ $2 = nterm opt_block_arg (1.10-1.10: )
+ -> $$ = nterm call_args (1.5-1.10: )
+ Stack now 0 2 80 235
+ Entering state 453
+ Reducing stack by rule 293 (line 2723):
+ $1 = nterm $@16 (1.4-1.4: )
+ $2 = nterm call_args (1.5-1.10: )
+ cmdarg_stack(pop): 0 at line 2754
+ -> $$ = nterm command_args (1.4-1.10: )
+ Stack now 0 2 80
+ Entering state 333
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 79 (line 1804):
+ $1 = nterm fcall (1.0-1.4: )
+ $2 = nterm command_args (1.4-1.10: )
+ -> $$ = nterm command (1.0-1.10: )
+ Stack now 0 2
+ Entering state 81
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 73 (line 1770):
+ $1 = nterm command (1.0-1.10: )
+ -> $$ = nterm command_call (1.0-1.10: )
+ Stack now 0 2
+ Entering state 78
+ Reducing stack by rule 51 (line 1659):
+ $1 = nterm command_call (1.0-1.10: )
+ -> $$ = nterm expr (1.0-1.10: )
+ Stack now 0 2
+ Entering state 75
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 39 (line 1578):
+ $1 = nterm expr (1.0-1.10: )
+ -> $$ = nterm stmt (1.0-1.10: )
+ Stack now 0 2
+ Entering state 73
+ Next token is token '\n' (1.10-1.10: )
+ Reducing stack by rule 8 (line 1354):
+ $1 = nterm stmt (1.0-1.10: )
+ -> $$ = nterm top_stmt (1.0-1.10: )
+ Stack now 0 2
+ Entering state 72
+ Reducing stack by rule 5 (line 1334):
+ $1 = nterm top_stmt (1.0-1.10: )
+ -> $$ = nterm top_stmts (1.0-1.10: )
+ Stack now 0 2
+ Entering state 71
+ Next token is token '\n' (1.10-1.10: )
+ Shifting token '\n' (1.10-1.10: )
+ Entering state 311
+ Reducing stack by rule 769 (line 5618):
+ $1 = token '\n' (1.10-1.10: )
+ -> $$ = nterm term (1.10-1.10: )
+ Stack now 0 2 71
+ Entering state 313
+ Reducing stack by rule 770 (line 5621):
+ $1 = nterm term (1.10-1.10: )
+ -> $$ = nterm terms (1.10-1.10: )
+ Stack now 0 2 71
+ Entering state 314
+ Reading a token: Now at end of input.
+ Reducing stack by rule 759 (line 5596):
+ $1 = nterm terms (1.10-1.10: )
+ -> $$ = nterm opt_terms (1.10-1.10: )
+ Stack now 0 2 71
+ Entering state 312
+ Reducing stack by rule 3 (line 1321):
+ $1 = nterm top_stmts (1.0-1.10: )
+ $2 = nterm opt_terms (1.10-1.10: )
+ -> $$ = nterm top_compstmt (1.0-1.10: )
+ Stack now 0 2
+ Entering state 70
+ Reducing stack by rule 2 (line 1295):
+ $1 = nterm $@1 (1.0-1.0: )
+ $2 = nterm top_compstmt (1.0-1.10: )
+ vtable_free:12426: p->lvtbl->args(0x0000558453df1a00)
+ vtable_free:12427: p->lvtbl->vars(0x0000558453df1a60)
+ cmdarg_stack(pop): 0 at line 12428
+ cond_stack(pop): 0 at line 12429
+ -> $$ = nterm program (1.0-1.10: )
+ Stack now 0
+ Entering state 1
+ Now at end of input.
+ Shifting token "end-of-input" (1.10-1.10: )
+ Entering state 3
+ Stack now 0 1 3
+ Cleanup: popping token "end-of-input" (1.10-1.10: )
+ Cleanup: popping nterm program (1.0-1.10: )
+ ```
+
+Additional flags can follow dump items.
+
+- `+comment`: Add comments to AST.
+- `+error-tolerant`: Parse in error-tolerant mode.
+- `-optimize`: Disable optimizations for instruction sequences.
diff --git a/doc/language/options.md b/doc/language/options.md
new file mode 100644
index 0000000000..1329b7ca63
--- /dev/null
+++ b/doc/language/options.md
@@ -0,0 +1,744 @@
+# Ruby Command-Line Options
+
+## About the Examples
+
+Some examples here use command-line option `-e`,
+which passes the Ruby code to be executed on the command line itself:
+
+```console
+$ ruby -e 'puts "Hello, World."'
+```
+
+Some examples here assume that file `desiderata.txt` exists:
+
+```console
+$ cat desiderata.txt
+Go placidly amid the noise and the haste,
+and remember what peace there may be in silence.
+As far as possible, without surrender,
+be on good terms with all persons.
+```
+
+## Options
+
+### `-0`: Set `$/` (Input Record Separator)
+
+Option `-0` defines the input record separator `$/`
+for the invoked Ruby program.
+
+The optional argument to the option must be octal digits,
+each in the range `0..7`;
+these digits are prefixed with digit `0` to form an octal value.
+
+If no argument is given, the input record separator is `0x00`.
+
+If an argument is given, it must immediately follow the option
+(no intervening whitespace or equal-sign character `'='`);
+argument values:
+
+- `0`: the input record separator is `''`;
+ see {Special Line Separator Values}[rdoc-ref:IO@Special+Line+Separator+Values].
+- In range `(1..0377)`:
+ the input record separator `$/` is set to the character value of the argument.
+- Any other octal value: the input record separator is `nil`.
+
+Examples:
+
+```console
+$ ruby -0 -e 'p $/'
+"\x00"
+ruby -00 -e 'p $/'
+""
+$ ruby -012 -e 'p $/'
+"\n"
+$ ruby -015 -e 'p $/'
+"\r"
+$ ruby -0377 -e 'p $/'
+"\xFF"
+$ ruby -0400 -e 'p $/'
+nil
+```
+
+See also:
+
+- [Option `-a`][-a]:
+ Split input lines into fields.
+- [Option `-F`][-F]:
+ Set input field separator.
+- [Option `-l`][-l]:
+ Set output record separator; chop lines.
+- [Option `-n`][-n]:
+ Run program in `gets` loop.
+- [Option `-p`][-p]:
+ `-n`, with printing.
+
+### `-a`: Split Input Lines into Fields
+
+Option `-a`, when given with either of options `-n` or `-p`,
+splits the string at `$_` into an array of strings at `$F`:
+
+```console
+$ ruby -an -e 'p $F' desiderata.txt
+["Go", "placidly", "amid", "the", "noise", "and", "the", "haste,"]
+["and", "remember", "what", "peace", "there", "may", "be", "in", "silence."]
+["As", "far", "as", "possible,", "without", "surrender,"]
+["be", "on", "good", "terms", "with", "all", "persons."]
+```
+
+For the splitting,
+the default record separator is `$/`,
+and the default field separator is `$;`.
+
+See also:
+
+- [Option `-0`][-0]:
+ Set `$/` (input record separator).
+- [Option `-F`][-F]:
+ Set input field separator.
+- [Option `-l`][-l]:
+ Set output record separator; chop lines.
+- [Option `-n`][-n]:
+ Run program in `gets` loop.
+- [Option `-p`][-p]:
+ `-n`, with printing.
+
+### `-c`: Check Syntax
+
+Option `-c` specifies that the specified Ruby program
+should be checked for syntax, but not actually executed:
+
+```console
+$ ruby -e 'puts "Foo"'
+Foo
+$ ruby -c -e 'puts "Foo"'
+Syntax OK
+```
+
+### `-C`: Set Working Directory
+
+The argument to option `-C` specifies a working directory
+for the invoked Ruby program;
+does not change the working directory for the current process:
+
+```console
+$ basename `pwd`
+ruby
+$ ruby -C lib -e 'puts File.basename(Dir.pwd)'
+lib
+$ basename `pwd`
+ruby
+```
+
+This option is accumulative; relative paths are solved from the
+previous working directory.
+
+```console
+$ ruby -C / -C usr -e 'puts Dir.pwd'
+/usr
+```
+
+If the argument is not an existing directory, a fatal error will
+occur:
+
+```console
+$ ruby -C /nonexistent
+ruby: Can't chdir to /nonexistent (fatal)
+$ ruby -C /dev/null
+ruby: Can't chdir to /dev/null (fatal)
+```
+
+Whitespace between the option and its argument may be omitted.
+
+### `-d`: Set `$DEBUG` to `true`
+
+Some code in (or called by) the Ruby program may include statements or blocks
+conditioned by the global variable `$DEBUG` (e.g., `if $DEBUG`);
+these commonly write to `$stdout` or `$stderr`.
+
+The default value for `$DEBUG` is `false`;
+option `-d` sets it to `true`:
+
+```console
+$ ruby -e 'p $DEBUG'
+false
+$ ruby -d -e 'p $DEBUG'
+true
+```
+
+[Option `--debug`][--debug] is an alias for option `-d`.
+
+### `-e`: Execute Given Ruby Code
+
+Option `-e` requires an argument, which is Ruby code to be executed;
+the option may be given more than once:
+
+```console
+$ ruby -e 'puts "Foo"' -e 'puts "Bar"'
+Foo
+Bar
+```
+
+Whitespace between the option and its argument may be omitted.
+
+The command may include other options,
+but should not include arguments (which, if given, are ignored).
+
+### `-E`: Set Default Encodings
+
+Option `-E` requires an argument, which specifies either the default external encoding,
+or both the default external and internal encodings for the invoked Ruby program:
+
+```console
+# No option -E.
+$ ruby -e 'p [Encoding::default_external, Encoding::default_internal]'
+[#<Encoding:UTF-8>, nil]
+# Option -E with default external encoding.
+$ ruby -E cesu-8 -e 'p [Encoding::default_external, Encoding::default_internal]'
+[#<Encoding:CESU-8>, nil]
+# Option -E with default external and internal encodings.
+$ ruby -E utf-8:cesu-8 -e 'p [Encoding::default_external, Encoding::default_internal]'
+[#<Encoding:UTF-8>, #<Encoding:CESU-8>]
+```
+
+Whitespace between the option and its argument may be omitted.
+
+See also:
+
+- [Option `--external-encoding`][--external-encoding]:
+ Set default external encoding.
+- [Option `--internal-encoding`][--internal-encoding]:
+ Set default internal encoding.
+
+Option `--encoding` is an alias for option `-E`.
+
+### `-F`: Set Input Field Separator
+
+Option `-F`, when given with option `-a`,
+specifies that its argument is to be the input field separator to be used for splitting:
+
+```console
+$ ruby -an -Fs -e 'p $F' desiderata.txt
+["Go placidly amid the noi", "e and the ha", "te,\n"]
+["and remember what peace there may be in ", "ilence.\n"]
+["A", " far a", " po", "", "ible, without ", "urrender,\n"]
+["be on good term", " with all per", "on", ".\n"]
+```
+
+The argument may be a regular expression:
+
+```console
+$ ruby -an -F'[.,]\s*' -e 'p $F' desiderata.txt
+["Go placidly amid the noise and the haste"]
+["and remember what peace there may be in silence"]
+["As far as possible", "without surrender"]
+["be on good terms with all persons"]
+```
+
+The argument must immediately follow the option
+(no intervening whitespace or equal-sign character `'='`).
+
+See also:
+
+- [Option `-0`][-0]:
+ Set `$/` (input record separator).
+- [Option `-a`][-a]:
+ Split input lines into fields.
+- [Option `-l`][-l]:
+ Set output record separator; chop lines.
+- [Option `-n`][-n]:
+ Run program in `gets` loop.
+- [Option `-p`][-p]:
+ `-n`, with printing.
+
+### `-h`: Print Short Help Message
+
+Option `-h` prints a short help message
+that includes single-hyphen options (e.g. `-I`),
+and largely omits double-hyphen options (e.g., `--version`).
+
+Arguments and additional options are ignored.
+
+For a longer help message, use option `--help`.
+
+### `-i`: Set \ARGF In-Place Mode
+
+Option `-i` sets the \ARGF in-place mode for the invoked Ruby program;
+see ARGF#inplace_mode=:
+
+```console
+$ ruby -e 'p ARGF.inplace_mode'
+nil
+$ ruby -i -e 'p ARGF.inplace_mode'
+""
+$ ruby -i.bak -e 'p ARGF.inplace_mode'
+".bak"
+```
+
+### `-I`: Add to `$LOAD_PATH`
+
+The argument to option `-I` specifies a directory
+to be added to the array in global variable `$LOAD_PATH`;
+the option may be given more than once:
+
+```console
+$ pushd /tmp
+$ ruby -e 'p $LOAD_PATH.size'
+8
+$ ruby -I my_lib -I some_lib -e 'p $LOAD_PATH.size'
+10
+$ ruby -I my_lib -I some_lib -e 'p $LOAD_PATH.take(2)'
+["/tmp/my_lib", "/tmp/some_lib"]
+$ popd
+```
+
+This option and [option `-C`][-C] will
+be applied in the order in the command line; expansion of `-I` options
+are affected by preceeding `-C` options.
+
+```console
+$ ruby -C / -Ilib -C usr -Ilib -e 'puts $:[0, 2]'
+/lib
+/usr/lib
+```
+
+Whitespace between the option and its argument may be omitted.
+
+### `-l`: Set Output Record Separator; Chop Lines
+
+Option `-l`, when given with option `-n` or `-p`,
+modifies line-ending processing by:
+
+- Setting global variable output record separator `$\`
+ to the current value of input record separator `$/`;
+ this affects line-oriented output (such a the output from Kernel#puts).
+- Calling String#chop! on each line read.
+
+Without option `-l` (unchopped):
+
+```console
+$ ruby -n -e 'p $_' desiderata.txt
+"Go placidly amid the noise and the haste,\n"
+"and remember what peace there may be in silence.\n"
+"As far as possible, without surrender,\n"
+"be on good terms with all persons.\n"
+```
+
+With option `-l` (chopped):
+
+```console
+$ ruby -ln -e 'p $_' desiderata.txt
+"Go placidly amid the noise and the haste,"
+"and remember what peace there may be in silence."
+"As far as possible, without surrender,"
+"be on good terms with all persons."
+```
+
+See also:
+
+- [Option `-0`][-0]:
+ Set `$/` (input record separator).
+- [Option `-a`][-a]:
+ Split input lines into fields.
+- [Option `-F`][-F]:
+ Set input field separator.
+- [Option `-n`][-n]:
+ Run program in `gets` loop.
+- [Option `-p`][-p]:
+ `-n`, with printing.
+
+### `-n`: Run Program in `gets` Loop
+
+Option `-n` runs your program in a `Kernel#gets` loop:
+
+```ruby
+while gets
+ # Your Ruby code.
+end
+```
+
+Note that `gets` reads the next line and sets global variable `$_`
+to the last read line:
+
+```console
+$ ruby -n -e 'puts $_' desiderata.txt
+Go placidly amid the noise and the haste,
+and remember what peace there may be in silence.
+As far as possible, without surrender,
+be on good terms with all persons.
+```
+
+See also:
+
+- [Option `-0`][-0]:
+ Set `$/` (input record separator).
+- [Option `-a`][-a]:
+ Split input lines into fields.
+- [Option `-F`][-F]:
+ Set input field separator.
+- [Option `-l`][-l]:
+ Set output record separator; chop lines.
+- [Option `-p`][-p]:
+ `-n`, with printing.
+
+### `-p`: `-n`, with Printing
+
+Option `-p` is like option `-n`, but also prints each line:
+
+```console
+$ ruby -p -e 'puts $_.size' desiderata.txt
+42
+Go placidly amid the noise and the haste,
+49
+and remember what peace there may be in silence.
+39
+As far as possible, without surrender,
+35
+be on good terms with all persons.
+```
+
+See also:
+
+- [Option `-0`][-0]:
+ Set `$/` (input record separator).
+- [Option `-a`][-a]:
+ Split input lines into fields.
+- [Option `-F`][-F]:
+ Set input field separator.
+- [Option `-l`][-l]:
+ Set output record separator; chop lines.
+- [Option `-n`][-n]:
+ Run program in `gets` loop.
+
+### `-r`: Require Library
+
+The argument to option `-r` specifies a library to be required
+before executing the Ruby program;
+the option may be given more than once:
+
+```console
+$ ruby -e 'p defined?(JSON); p defined?(CSV)'
+nil
+nil
+$ ruby -r csv -r json -e 'p defined?(JSON); p defined?(CSV)'
+"constant"
+"constant"
+```
+
+The library is loaded with the `Kernel#require` method, after the
+other options such as [`-C`][-C], [`-I`][-I], and "custom options" by
+[`-s`][-s], are applied:
+
+Whitespace between the option and its argument may be omitted.
+
+### `-s`: Define Global Variable
+
+Option `-s` specifies that a "custom option" is to define a global variable
+in the invoked Ruby program:
+
+- The custom option must appear _after_ the program name.
+- If there is no script name in the command line (using {option
+ -e}[rdoc-ref:@-e+Execute+Given+Ruby+Code] or implicit reading from
+ `$stdin`), the custom options must be separated from the other
+ interpreter options with a `--`.
+- The custom option must begin with single hyphen (e.g., `-foo`),
+ not two hyphens (e.g., `--foo`).
+- The name of the global variable is based on the option name:
+ global variable `$foo` for custom option`-foo`.
+- The value of the global variable is the string option argument if given,
+ `true` otherwise.
+
+More than one custom option may be given:
+
+```console
+$ cat t.rb
+p [$foo, $bar]
+$ ruby t.rb
+[nil, nil]
+$ ruby -s t.rb -foo=baz
+["baz", nil]
+$ ruby -s t.rb -foo
+[true, nil]
+$ ruby -s t.rb -foo=baz -bar=bat
+["baz", "bat"]
+```
+
+### `-S`: Search Directories in `ENV['PATH']`
+
+Option `-S` specifies that the Ruby interpreter
+is to search (if necessary) the directories whose paths are in the program's
+`PATH` environment variable;
+the program is executed in the shell's current working directory
+(not necessarily in the directory where the program is found).
+
+This example uses adds path `'tmp/'` to the `PATH` environment variable:
+
+```console
+$ export PATH=/tmp:$PATH
+$ echo "puts File.basename(Dir.pwd)" > /tmp/t.rb
+$ ruby -S t.rb
+ruby
+```
+
+### `-v`: Print Version; Set `$VERBOSE`
+
+Options `-v` prints the Ruby version and sets global variable `$VERBOSE`:
+
+```console
+$ ruby -e 'p $VERBOSE'
+false
+$ ruby -v -e 'p $VERBOSE'
+ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x64-mingw-ucrt]
+true
+```
+
+### `-w`: Synonym for `-W1`
+
+Option `-w` (lowercase letter) is equivalent to option `-W1` (uppercase letter).
+
+### `-W`: Set \Warning Policy
+
+Any Ruby code can create a <i>warning message</i> by calling method Kernel#warn;
+methods in the Ruby core and standard libraries can also create warning messages.
+Such a message may be printed on `$stderr`
+(or not, depending on certain settings).
+
+Option `-W` helps determine whether a particular warning message
+will be written,
+by setting the initial value of global variable `$-W`:
+
+- `-W0`: Sets `$-W` to `0` (silent; no warnings).
+- `-W1`: Sets `$-W` to `1` (moderate verbosity).
+- `-W2`: Sets `$-W` to `2` (high verbosity).
+- `-W`: Same as `-W2` (high verbosity).
+- Option not given: Same as `-W1` (moderate verbosity).
+
+The value of `$-W`, in turn, determines which warning messages (if any)
+are to be printed to `$stdout` (see Kernel#warn):
+
+```console
+$ ruby -W1 -e 'p $foo'
+nil
+$ ruby -W2 -e 'p $foo'
+-e:1: warning: global variable '$foo' not initialized
+nil
+```
+
+Ruby code may also define warnings for certain categories;
+these are the default settings for the defined categories:
+
+```rb
+Warning[:experimental] # => true
+Warning[:deprecated] # => false
+Warning[:performance] # => false
+```
+
+They may also be set:
+
+```rb
+Warning[:experimental] = false
+Warning[:deprecated] = true
+Warning[:performance] = true
+```
+
+You can suppress a category by prefixing `no-` to the category name:
+
+```console
+$ ruby -W:no-experimental -e 'p IO::Buffer.new'
+#<IO::Buffer>
+```
+
+### `-x`: Execute Ruby Code Found in Text
+
+Option `-x` executes a Ruby program whose code is embedded
+in other, non-code, text:
+
+The ruby code:
+
+- Begins after the first line beginning with `'#!` and containing string `'ruby'`.
+- Ends before any one of:
+
+ - End-of-file.
+ - A line consisting of `'__END__'`,
+ - Character `Ctrl-D` or `Ctrl-Z`.
+
+Example:
+
+```console
+$ cat t.txt
+Leading garbage.
+#!ruby
+puts File.basename(Dir.pwd)
+__END__
+Trailing garbage.
+
+$ ruby -x t.txt
+ruby
+```
+
+The optional argument specifies the directory where the text file
+is to be found;
+the Ruby code is executed in that directory:
+
+```console
+$ cp t.txt /tmp/
+$ ruby -x/tmp t.txt
+tmp
+$
+
+```
+
+If an argument is given, it must immediately follow the option
+(no intervening whitespace or equal-sign character `'='`).
+
+### `--backtrace-limit`: Set Backtrace Limit
+
+Option `--backtrace-limit` sets a limit on the number of entries
+to be displayed in a backtrace.
+
+See Thread::Backtrace.limit.
+
+### `--copyright`: Print Ruby Copyright
+
+Option `--copyright` prints a copyright message:
+
+```console
+$ ruby --copyright
+ruby - Copyright (C) 1993-2024 Yukihiro Matsumoto
+```
+
+### `--debug`: Alias for `-d`
+
+Option `--debug` is an alias for
+[option `-d`][-d].
+
+### `--disable`: Disable Features
+
+Option `--disable` specifies features to be disabled;
+the argument is a comma-separated list of the features to be disabled:
+
+```sh
+ruby --disable=gems,rubyopt t.rb
+```
+
+The supported features:
+
+- `gems`: Rubygems (default: enabled).
+- `did_you_mean`: [`did_you_mean`](https://github.com/ruby/did_you_mean) (default: enabled).
+- `rubyopt`: `RUBYOPT` environment variable (default: enabled).
+- `frozen-string-literal`: Freeze all string literals (default: disabled).
+- `jit`: JIT compiler (default: disabled).
+
+See also [option `--enable`][--enable].
+
+### `--dump`: Dump Items
+
+Option `--dump` specifies items to be dumped;
+the argument is a comma-separated list of the items.
+
+Some of the argument values cause the command to behave as if a different
+option was given:
+
+- `--dump=copyright`:
+ Same as [option `--copyright`][--copyright].
+- `--dump=help`:
+ Same as [option `--help`][--help].
+- `--dump=syntax`:
+ Same as [option `-c`][-c].
+- `--dump=usage`:
+ Same as [option `-h`][-h].
+- `--dump=version`:
+ Same as [option `--version`][--version].
+
+For other argument values and examples,
+see {Option `--dump`}[rdoc-ref:option_dump.md].
+
+### `--enable`: Enable Features
+
+Option `--enable` specifies features to be enabled;
+the argument is a comma-separated list of the features to be enabled.
+
+```sh
+ruby --enable=gems,rubyopt t.rb
+```
+
+For the features,
+see [option `--disable`][--disable].
+
+### `--encoding`: Alias for `-E`.
+
+Option `--encoding` is an alias for
+[option `-E`][-E].
+
+### `--external-encoding`: Set Default External \Encoding
+
+Option `--external-encoding`
+sets the default external encoding for the invoked Ruby program;
+for values of `encoding`,
+see [Encoding: Names and Aliases].
+
+```console
+$ ruby -e 'puts Encoding::default_external'
+UTF-8
+$ ruby --external-encoding=cesu-8 -e 'puts Encoding::default_external'
+CESU-8
+```
+
+### `--help`: Print Help Message
+
+Option `--help` prints a long help message.
+
+Arguments and additional options are ignored.
+
+For a shorter help message, use option `-h`.
+
+### `--internal-encoding`: Set Default Internal \Encoding
+
+Option `--internal-encoding`
+sets the default internal encoding for the invoked Ruby program;
+for values of `encoding`,
+see [Encoding: Names and Aliases].
+
+```console
+$ ruby -e 'puts Encoding::default_internal.nil?'
+true
+$ ruby --internal-encoding=cesu-8 -e 'puts Encoding::default_internal'
+CESU-8
+```
+
+### `--jit`
+
+Option `--jit` is an alias for option `--yjit`, which enables YJIT;
+see additional YJIT options in the [YJIT documentation](rdoc-ref:jit/yjit.md).
+
+### `--verbose`: Set `$VERBOSE`
+
+Option `--verbose` sets global variable `$VERBOSE` to `true`
+and disables input from `$stdin`.
+
+### `--version`: Print Ruby Version
+
+Option `--version` prints the version of the Ruby interpreter, then exits.
+
+[-0]: rdoc-ref:@-0+Set++Input+Record+Separator
+[-C]: rdoc-ref:@-C+Set+Working+Directory
+[-E]: rdoc-ref:@-E+Set+Default+Encodings
+[-F]: rdoc-ref:@-F+Set+Input+Field+Separator
+[-I]: rdoc-ref:@-I+Add+to+LOADPATH
+[-a]: rdoc-ref:@-a+Split+Input+Lines+into+Fields
+[-c]: rdoc-ref:@-c+Check+Syntax
+[-d]: rdoc-ref:@-d+Set+DEBUG+to+true
+[-e]: rdoc-ref:@-e+Execute+Given+Ruby+Code
+[-h]: rdoc-ref:@-h+Print+Short+Help+Message
+[-l]: rdoc-ref:@-l+Set+Output+Record+Separator+Chop+Lines
+[-n]: rdoc-ref:@-n+Run+Program+in+gets+Loop
+[-p]: rdoc-ref:@-p+-n+with+Printing
+[-s]: rdoc-ref:@-s+Define+Global+Variable
+[--copyright]: rdoc-ref:@--copyright+Print+Ruby+Copyright
+[--debug]: rdoc-ref:@--debug+Alias+for+-d
+[--disable]: rdoc-ref:@--disable+Disable+Features
+[--enable]: rdoc-ref:@--enable+Enable+Features
+[--external-encoding]: rdoc-ref:@--external+encoding+Set+Default+External+Encoding
+[--internal-encoding]: rdoc-ref:@--internal+encoding+Set+Default+Internal+Encoding
+[--help]: rdoc-ref:@--help+Print+Help+Message
+[--version]: rdoc-ref:@--version+Print+Ruby+Version
+[Encoding: Names and Aliases]: rdoc-ref:encodings.rdoc@Names+and+Aliases
diff --git a/doc/language/packed_data.md b/doc/language/packed_data.md
new file mode 100644
index 0000000000..1b133367d6
--- /dev/null
+++ b/doc/language/packed_data.md
@@ -0,0 +1,886 @@
+# Packed \Data
+
+## Quick Reference
+
+These tables summarize the directives for packing and unpacking.
+
+### For Integers
+
+| Directive | Meaning |
+|-----------------------|-----------------------------------------------------------------------------------------------------|
+| `C` | 8-bit unsigned (`unsigned char`) |
+| `S` | 16-bit unsigned, native endian (`uint16_t`) |
+| `L` | 32-bit unsigned, native endian (`uint32_t`) |
+| `Q` | 64-bit unsigned, native endian (`uint64_t`) |
+| `J` | pointer width unsigned, native endian (`uintptr_t`) |
+| | |
+| `c` | 8-bit signed (`signed char`) |
+| `s` | 16-bit signed, native endian (`int16_t`) |
+| `l` | 32-bit signed, native endian (`int32_t`) |
+| `q` | 64-bit signed, native endian (`int64_t`) |
+| `j` | pointer width signed, native endian (`intptr_t`) |
+| | |
+| `S_` `S!` | `unsigned short`, native endian |
+| `I` `I_` `I!` | `unsigned int`, native endian |
+| `L_` `L!` | `unsigned long`, native endian |
+| `Q_` `Q!` | `unsigned long long`, native endian; (raises ArgumentError if the platform has no `long long` type) |
+| `J!` | `uintptr_t`, native endian (same with `J`) |
+| | |
+| `s_` `s!` | `signed short`, native endian |
+| `i` `i_` `i!` | `signed int`, native endian |
+| `l_` `l!` | `signed long`, native endian |
+| `q_` `q!` | `signed long long`, native endian; (raises ArgumentError if the platform has no `long long` type) |
+| `j!` | `intptr_t`, native endian (same with `j`) |
+| | |
+| `S>` `s>` `S!>` `s!>` | each the same as the directive without `>`, but big endian; `S>` is the same as `n` |
+| `L>` `l>` `L!>` `l!>` | `L>` is the same as `N` |
+| `I!>` `i!>` | |
+| `Q>` `q>` `Q!>` `q!>` | |
+| `J>` `j>` `J!>` `j!>` | |
+| | |
+| `S<` `s<` `S!<` `s!<` | each the same as the directive without `<`, but little endian; `S<` is the same as `v` |
+| `L<` `l<` `L!<` `l!<` | `L<` is the same as `V` |
+| `I!<` `i!<` | |
+| `Q<` `q<` `Q!<` `q!<` | |
+| `J<` `j<` `J!<` `j!<` | |
+| | |
+| `n` | 16-bit unsigned, network (big-endian) byte order |
+| `N` | 32-bit unsigned, network (big-endian) byte order |
+| `v` | 16-bit unsigned, VAX (little-endian) byte order |
+| `V` | 32-bit unsigned, VAX (little-endian) byte order |
+| | |
+| `U` | UTF-8 character |
+| `w` | BER-compressed integer |
+| `R` | LEB128 encoded unsigned integer |
+| `r` | LEB128 encoded signed integer |
+
+### For Floats
+
+| Directive | Meaning |
+|-----------|---------------------------------------------------|
+| `D` `d` | double-precision, native format |
+| `F` `f` | single-precision, native format |
+| `E` | double-precision, little-endian byte order |
+| `e` | single-precision, little-endian byte order |
+| `G` | double-precision, network (big-endian) byte order |
+| `g` | single-precision, network (big-endian) byte order |
+
+### For Strings
+
+| Directive | Meaning |
+|-----------|------------------------------------------------------------------------------------------------|
+| `A` | arbitrary binary string (remove trailing nulls and ASCII spaces) |
+| `a` | arbitrary binary string |
+| `Z` | null-terminated string |
+| `B` | bit string (MSB first) |
+| `b` | bit string (LSB first) |
+| `H` | hex string (high nibble first) |
+| `h` | hex string (low nibble first) |
+| `u` | UU-encoded string |
+| `M` | quoted-printable, MIME encoding (see RFC2045) |
+| `m` | base64 encoded string (RFC 2045) (default) (base64 encoded string (RFC 4648) if followed by 0) |
+| `P` | pointer to a structure (fixed-length string) |
+| `p` | pointer to a null-terminated string |
+
+### Additional Directives for Packing
+
+| Directive | Meaning |
+|-----------|----------------------------|
+| `@` | moves to absolute position |
+| `X` | back up a byte |
+| `x` | null byte |
+
+### Additional Directives for Unpacking
+
+| Directive | Meaning |
+|-----------|-------------------------------------------------|
+| `@` | skip to the offset given by the length argument |
+| `X` | skip backward one byte |
+| `x` | skip forward one byte |
+| `^` | return the current offset |
+
+## Packing and Unpacking
+
+Certain Ruby core methods deal with packing and unpacking data:
+
+- Method Array#pack:
+ Formats each element in array `self` into a binary string;
+ returns that string.
+- Method String#unpack:
+ Extracts data from string `self`,
+ forming objects that become the elements of a new array;
+ returns that array.
+- Method String#unpack1:
+ Does the same, but unpacks and returns only the first extracted object.
+
+Each of these methods accepts a string `template`,
+consisting of zero or more _directive_ characters,
+each followed by zero or more _modifier_ characters.
+
+Examples (directive `'C'` specifies '`unsigned character`'):
+
+```ruby
+[65].pack('C') # => "A" # One element, one directive.
+[65, 66].pack('CC') # => "AB" # Two elements, two directives.
+[65, 66].pack('C') # => "A" # Extra element is ignored.
+[65].pack('') # => "" # No directives.
+[65].pack('CC') # Extra directive raises ArgumentError.
+```
+
+```ruby
+'A'.unpack('C') # => [65] # One character, one directive.
+'AB'.unpack('CC') # => [65, 66] # Two characters, two directives.
+'AB'.unpack('C') # => [65] # Extra character is ignored.
+'A'.unpack('CC') # => [65, nil] # Extra directive generates nil.
+'AB'.unpack('') # => [] # No directives.
+```
+
+The string `template` may contain any mixture of valid directives
+(directive `'c'` specifies 'signed character'):
+
+```ruby
+[65, -1].pack('cC') # => "A\xFF"
+"A\xFF".unpack('cC') # => [65, 255]
+```
+
+The string `template` may contain whitespace (which is ignored)
+and comments, each of which begins with character `'#'`
+and continues up to and including the next following newline:
+
+```ruby
+[0,1].pack(" C #foo \n C ") # => "\x00\x01"
+"\0\1".unpack(" C #foo \n C ") # => [0, 1]
+```
+
+Any directive may be followed by either of these modifiers:
+
+- `'*'` - The directive is to be applied as many times as needed:
+
+ ```ruby
+ [65, 66].pack('C*') # => "AB"
+ 'AB'.unpack('C*') # => [65, 66]
+ ```
+
+- \Integer `count` - The directive is to be applied `count` times:
+
+ ```ruby
+ [65, 66].pack('C2') # => "AB"
+ [65, 66].pack('C3') # Raises ArgumentError.
+ 'AB'.unpack('C2') # => [65, 66]
+ 'AB'.unpack('C3') # => [65, 66, nil]
+ ```
+
+ Note: Directives in `%w[A a Z m]` use `count` differently;
+ see [\String Directives][rdoc-ref:@String+Directives].
+
+If elements don't fit the provided directive, only least significant bits are encoded:
+
+```ruby
+[257].pack("C").unpack("C") # => [1]
+```
+
+## Packing Method
+
+Method Array#pack accepts optional keyword argument
+`buffer` that specifies the target string (instead of a new string):
+
+```ruby
+[65, 66].pack('C*', buffer: 'foo') # => "fooAB"
+```
+
+The method can accept a block:
+
+```ruby
+# Packed string is passed to the block.
+[65, 66].pack('C*') {|s| p s } # => "AB"
+```
+
+## Unpacking Methods
+
+Methods String#unpack and String#unpack1 each accept
+an optional keyword argument `offset` that specifies an offset
+into the string:
+
+```ruby
+'ABC'.unpack('C*', offset: 1) # => [66, 67]
+'ABC'.unpack1('C*', offset: 1) # => 66
+```
+
+Both methods can accept a block:
+
+```ruby
+# Each unpacked object is passed to the block.
+ret = []
+"ABCD".unpack("C*") {|c| ret << c }
+ret # => [65, 66, 67, 68]
+```
+
+```ruby
+# The single unpacked object is passed to the block.
+'AB'.unpack1('C*') {|ele| p ele } # => 65
+```
+
+## \Integer Directives
+
+Each integer directive specifies the packing or unpacking
+for one element in the input or output array.
+
+### 8-Bit \Integer Directives
+
+- `'c'` - 8-bit signed integer
+ (like C `signed char`):
+
+ ```ruby
+ [0, 1, 255].pack('c*') # => "\x00\x01\xFF"
+ s = [0, 1, -1].pack('c*') # => "\x00\x01\xFF"
+ s.unpack('c*') # => [0, 1, -1]
+ ```
+
+- `'C'` - 8-bit unsigned integer
+ (like C `unsigned char`):
+
+ ```ruby
+ [0, 1, 255].pack('C*') # => "\x00\x01\xFF"
+ s = [0, 1, -1].pack('C*') # => "\x00\x01\xFF"
+ s.unpack('C*') # => [0, 1, 255]
+ ```
+
+### 16-Bit \Integer Directives
+
+- `'s'` - 16-bit signed integer, native-endian
+ (like C `int16_t`):
+
+ ```ruby
+ [513, -514].pack('s*') # => "\x01\x02\xFE\xFD"
+ s = [513, 65022].pack('s*') # => "\x01\x02\xFE\xFD"
+ s.unpack('s*') # => [513, -514]
+ ```
+
+- `'S'` - 16-bit unsigned integer, native-endian
+ (like C `uint16_t`):
+
+ ```ruby
+ [513, -514].pack('S*') # => "\x01\x02\xFE\xFD"
+ s = [513, 65022].pack('S*') # => "\x01\x02\xFE\xFD"
+ s.unpack('S*') # => [513, 65022]
+ ```
+
+- `'n'` - 16-bit network integer, big-endian:
+
+ ```ruby
+ s = [0, 1, -1, 32767, -32768, 65535].pack('n*')
+ # => "\x00\x00\x00\x01\xFF\xFF\x7F\xFF\x80\x00\xFF\xFF"
+ s.unpack('n*')
+ # => [0, 1, 65535, 32767, 32768, 65535]
+ ```
+
+- `'v'` - 16-bit VAX integer, little-endian:
+
+ ```ruby
+ s = [0, 1, -1, 32767, -32768, 65535].pack('v*')
+ # => "\x00\x00\x01\x00\xFF\xFF\xFF\x7F\x00\x80\xFF\xFF"
+ s.unpack('v*')
+ # => [0, 1, 65535, 32767, 32768, 65535]
+ ```
+
+### 32-Bit \Integer Directives
+
+- `'l'` - 32-bit signed integer, native-endian
+ (like C `int32_t`):
+
+ ```ruby
+ s = [67305985, -50462977].pack('l*')
+ # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
+ s.unpack('l*')
+ # => [67305985, -50462977]
+ ```
+
+- `'L'` - 32-bit unsigned integer, native-endian
+ (like C `uint32_t`):
+
+ ```ruby
+ s = [67305985, 4244504319].pack('L*')
+ # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
+ s.unpack('L*')
+ # => [67305985, 4244504319]
+ ```
+
+- `'N'` - 32-bit network integer, big-endian:
+
+ ```ruby
+ s = [0,1,-1].pack('N*')
+ # => "\x00\x00\x00\x00\x00\x00\x00\x01\xFF\xFF\xFF\xFF"
+ s.unpack('N*')
+ # => [0, 1, 4294967295]
+ ```
+
+- `'V'` - 32-bit VAX integer, little-endian:
+
+ ```ruby
+ s = [0,1,-1].pack('V*')
+ # => "\x00\x00\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF"
+ s.unpack('v*')
+ # => [0, 0, 1, 0, 65535, 65535]
+ ```
+
+### 64-Bit \Integer Directives
+
+- `'q'` - 64-bit signed integer, native-endian
+ (like C `int64_t`):
+
+ ```ruby
+ s = [578437695752307201, -506097522914230529].pack('q*')
+ # => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8"
+ s.unpack('q*')
+ # => [578437695752307201, -506097522914230529]
+ ```
+
+- `'Q'` - 64-bit unsigned integer, native-endian
+ (like C `uint64_t`):
+
+ ```ruby
+ s = [578437695752307201, 17940646550795321087].pack('Q*')
+ # => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8"
+ s.unpack('Q*')
+ # => [578437695752307201, 17940646550795321087]
+ ```
+
+### Platform-Dependent \Integer Directives
+
+- `'i'` - Platform-dependent width signed integer,
+ native-endian (like C `int`):
+
+ ```ruby
+ s = [67305985, -50462977].pack('i*')
+ # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
+ s.unpack('i*')
+ # => [67305985, -50462977]
+ ```
+
+- `'I'` - Platform-dependent width unsigned integer,
+ native-endian (like C `unsigned int`):
+
+ ```ruby
+ s = [67305985, -50462977].pack('I*')
+ # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
+ s.unpack('I*')
+ # => [67305985, 4244504319]
+ ```
+
+- `'j'` - Pointer-width signed integer, native-endian
+ (like C `intptr_t`):
+
+ ```ruby
+ s = [67305985, -50462977].pack('j*')
+ # => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\xFF\xFF\xFF\xFF"
+ s.unpack('j*')
+ # => [67305985, -50462977]
+ ```
+
+- `'J'` - Pointer-width unsigned integer, native-endian
+ (like C `uintptr_t`):
+
+ ```ruby
+ s = [67305985, 4244504319].pack('J*')
+ # => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\x00\x00\x00\x00"
+ s.unpack('J*')
+ # => [67305985, 4244504319]
+ ```
+
+### Other \Integer Directives
+
+- `'U'` - UTF-8 character:
+
+ ```ruby
+ s = [4194304].pack('U*')
+ # => "\xF8\x90\x80\x80\x80"
+ s.unpack('U*')
+ # => [4194304]
+ ```
+
+- `'r'` - Signed LEB128-encoded integer
+ (see [Signed LEB128](https://en.wikipedia.org/wiki/LEB128#Signed_LEB128))
+
+ ```ruby
+ s = [1, 127, -128, 16383, -16384].pack("r*")
+ # => "\x01\xFF\x00\x80\x7F\xFF\xFF\x00\x80\x80\x7F"
+ s.unpack('r*')
+ # => [1, 127, -128, 16383, -16384]
+ ```
+
+- `'R'` - Unsigned LEB128-encoded integer
+ (see [Unsigned LEB128](https://en.wikipedia.org/wiki/LEB128#Unsigned_LEB128))
+
+ ```ruby
+ s = [1, 127, 128, 16383, 16384].pack("R*")
+ # => "\x01\x7F\x80\x01\xFF\x7F\x80\x80\x01"
+ s.unpack('R*')
+ # => [1, 127, 128, 16383, 16384]
+ ```
+
+- `'w'` - BER-encoded integer
+ (see [BER encoding](https://en.wikipedia.org/wiki/X.690#BER_encoding)):
+
+ ```ruby
+ s = [1073741823].pack('w*')
+ # => "\x83\xFF\xFF\xFF\x7F"
+ s.unpack('w*')
+ # => [1073741823]
+ ```
+
+### Modifiers for \Integer Directives
+
+For the following directives, `'!'` or `'_'` modifiers may be
+suffixed as underlying platform’s native size.
+
+- `'i'`, `'I'` - C `int`, always native size.
+- `'s'`, `'S'` - C `short`.
+- `'l'`, `'L'` - C `long`.
+- `'q'`, `'Q'` - C `long long`, if available.
+- `'j'`, `'J'` - C `intptr_t`, always native size.
+
+Native size modifiers are silently ignored for always native size directives.
+
+The endian modifiers also may be suffixed in the directives above:
+
+- `'>'` - Big-endian.
+- `'<'` - Little-endian.
+
+## \Float Directives
+
+Each float directive specifies the packing or unpacking
+for one element in the input or output array.
+
+### Single-Precision \Float Directives
+
+- `'F'` or `'f'` - Native format:
+
+ ```ruby
+ s = [3.0].pack('F') # => "\x00\x00@@"
+ s.unpack('F') # => [3.0]
+ ```
+
+- `'e'` - Little-endian:
+
+ ```ruby
+ s = [3.0].pack('e') # => "\x00\x00@@"
+ s.unpack('e') # => [3.0]
+ ```
+
+- `'g'` - Big-endian:
+
+ ```ruby
+ s = [3.0].pack('g') # => "@@\x00\x00"
+ s.unpack('g') # => [3.0]
+ ```
+
+### Double-Precision \Float Directives
+
+- `'D'` or `'d'` - Native format:
+
+ ```ruby
+ s = [3.0].pack('D') # => "\x00\x00\x00\x00\x00\x00\b@"
+ s.unpack('D') # => [3.0]
+ ```
+
+- `'E'` - Little-endian:
+
+ ```ruby
+ s = [3.0].pack('E') # => "\x00\x00\x00\x00\x00\x00\b@"
+ s.unpack('E') # => [3.0]
+ ```
+
+- `'G'` - Big-endian:
+
+ ```ruby
+ s = [3.0].pack('G') # => "@\b\x00\x00\x00\x00\x00\x00"
+ s.unpack('G') # => [3.0]
+ ```
+
+A float directive may be infinity or not-a-number:
+
+```ruby
+inf = 1.0/0.0 # => Infinity
+[inf].pack('f') # => "\x00\x00\x80\x7F"
+"\x00\x00\x80\x7F".unpack('f') # => [Infinity]
+
+nan = inf/inf # => NaN
+[nan].pack('f') # => "\x00\x00\xC0\x7F"
+"\x00\x00\xC0\x7F".unpack('f') # => [NaN]
+```
+
+## \String Directives
+
+Each string directive specifies the packing or unpacking
+for one byte in the input or output string.
+
+### Binary \String Directives
+
+- `'A'` - Arbitrary binary string (space padded; count is width);
+ `nil` is treated as the empty string:
+
+ ```ruby
+ ['foo'].pack('A') # => "f"
+ ['foo'].pack('A*') # => "foo"
+ ['foo'].pack('A2') # => "fo"
+ ['foo'].pack('A4') # => "foo "
+ [nil].pack('A') # => " "
+ [nil].pack('A*') # => ""
+ [nil].pack('A2') # => " "
+ [nil].pack('A4') # => " "
+ ```
+
+ ```ruby
+ "foo\0".unpack('A') # => ["f"]
+ "foo\0".unpack('A4') # => ["foo"]
+ "foo\0bar".unpack('A10') # => ["foo\x00bar"] # Reads past "\0".
+ "foo ".unpack('A') # => ["f"]
+ "foo ".unpack('A4') # => ["foo"]
+ "foo".unpack('A4') # => ["foo"]
+ ```
+
+ ```ruby
+ japanese = 'ã“ã‚“ã«ã¡ã¯'
+ japanese.size # => 5
+ japanese.bytesize # => 15
+ [japanese].pack('A') # => "\xE3"
+ [japanese].pack('A*') # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ japanese.unpack('A') # => ["\xE3"]
+ japanese.unpack('A2') # => ["\xE3\x81"]
+ japanese.unpack('A4') # => ["\xE3\x81\x93\xE3"]
+ japanese.unpack('A*') # => ["\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"]
+ ```
+
+- `'a'` - Arbitrary binary string (null padded; count is width):
+
+ ```ruby
+ ["foo"].pack('a') # => "f"
+ ["foo"].pack('a*') # => "foo"
+ ["foo"].pack('a2') # => "fo"
+ ["foo\0"].pack('a4') # => "foo\x00"
+ [nil].pack('a') # => "\x00"
+ [nil].pack('a*') # => ""
+ [nil].pack('a2') # => "\x00\x00"
+ [nil].pack('a4') # => "\x00\x00\x00\x00"
+ ```
+
+ ```ruby
+ "foo\0".unpack('a') # => ["f"]
+ "foo\0".unpack('a4') # => ["foo\x00"]
+ "foo ".unpack('a4') # => ["foo "]
+ "foo".unpack('a4') # => ["foo"]
+ "foo\0bar".unpack('a4') # => ["foo\x00"] # Reads past "\0".
+ ```
+
+- `'Z'` - Same as `'a'`,
+ except that null is added or ignored with `'*'`:
+
+ ```ruby
+ ["foo"].pack('Z*') # => "foo\x00"
+ [nil].pack('Z*') # => "\x00"
+ ```
+
+ ```ruby
+ "foo\0".unpack('Z*') # => ["foo"]
+ "foo".unpack('Z*') # => ["foo"]
+ "foo\0bar".unpack('Z*') # => ["foo"] # Does not read past "\0".
+ ```
+
+### Bit \String Directives
+
+- `'B'` - Bit string (high byte first):
+
+ ```ruby
+ ['11111111' + '00000000'].pack('B*') # => "\xFF\x00"
+ ['10000000' + '01000000'].pack('B*') # => "\x80@"
+ ```
+
+ ```ruby
+ ['1'].pack('B0') # => ""
+ ['1'].pack('B1') # => "\x80"
+ ['1'].pack('B2') # => "\x80\x00"
+ ['1'].pack('B3') # => "\x80\x00"
+ ['1'].pack('B4') # => "\x80\x00\x00"
+ ['1'].pack('B5') # => "\x80\x00\x00"
+ ['1'].pack('B6') # => "\x80\x00\x00\x00"
+ ```
+
+ ```ruby
+ "\xff\x00".unpack("B*") # => ["1111111100000000"]
+ "\x01\x02".unpack("B*") # => ["0000000100000010"]
+ ```
+
+ ```ruby
+ "".unpack("B0") # => [""]
+ "\x80".unpack("B1") # => ["1"]
+ "\x80".unpack("B2") # => ["10"]
+ "\x80".unpack("B3") # => ["100"]
+ ```
+
+- `'b'` - Bit string (low byte first):
+
+ ```ruby
+ ['11111111' + '00000000'].pack('b*') # => "\xFF\x00"
+ ['10000000' + '01000000'].pack('b*') # => "\x01\x02"
+ ```
+
+ ```ruby
+ ['1'].pack('b0') # => ""
+ ['1'].pack('b1') # => "\x01"
+ ['1'].pack('b2') # => "\x01\x00"
+ ['1'].pack('b3') # => "\x01\x00"
+ ['1'].pack('b4') # => "\x01\x00\x00"
+ ['1'].pack('b5') # => "\x01\x00\x00"
+ ['1'].pack('b6') # => "\x01\x00\x00\x00"
+ ```
+
+ ```ruby
+ "\xff\x00".unpack("b*") # => ["1111111100000000"]
+ "\x01\x02".unpack("b*") # => ["1000000001000000"]
+ ```
+
+ ```ruby
+ "".unpack("b0") # => [""]
+ "\x01".unpack("b1") # => ["1"]
+ "\x01".unpack("b2") # => ["10"]
+ "\x01".unpack("b3") # => ["100"]
+ ```
+
+### Hex \String Directives
+
+- `'H'` - Hex string (high nibble first):
+
+ ```ruby
+ ['10ef'].pack('H*') # => "\x10\xEF"
+ ['10ef'].pack('H0') # => ""
+ ['10ef'].pack('H3') # => "\x10\xE0"
+ ['10ef'].pack('H5') # => "\x10\xEF\x00"
+ ```
+
+ ```ruby
+ ['fff'].pack('H3') # => "\xFF\xF0"
+ ['fff'].pack('H4') # => "\xFF\xF0"
+ ['fff'].pack('H5') # => "\xFF\xF0\x00"
+ ['fff'].pack('H6') # => "\xFF\xF0\x00"
+ ['fff'].pack('H7') # => "\xFF\xF0\x00\x00"
+ ['fff'].pack('H8') # => "\xFF\xF0\x00\x00"
+ ```
+
+ ```ruby
+ "\x10\xef".unpack('H*') # => ["10ef"]
+ "\x10\xef".unpack('H0') # => [""]
+ "\x10\xef".unpack('H1') # => ["1"]
+ "\x10\xef".unpack('H2') # => ["10"]
+ "\x10\xef".unpack('H3') # => ["10e"]
+ "\x10\xef".unpack('H4') # => ["10ef"]
+ "\x10\xef".unpack('H5') # => ["10ef"]
+ ```
+
+- `'h'` - Hex string (low nibble first):
+
+ ```ruby
+ ['10ef'].pack('h*') # => "\x01\xFE"
+ ['10ef'].pack('h0') # => ""
+ ['10ef'].pack('h3') # => "\x01\x0E"
+ ['10ef'].pack('h5') # => "\x01\xFE\x00"
+ ```
+
+ ```ruby
+ ['fff'].pack('h3') # => "\xFF\x0F"
+ ['fff'].pack('h4') # => "\xFF\x0F"
+ ['fff'].pack('h5') # => "\xFF\x0F\x00"
+ ['fff'].pack('h6') # => "\xFF\x0F\x00"
+ ['fff'].pack('h7') # => "\xFF\x0F\x00\x00"
+ ['fff'].pack('h8') # => "\xFF\x0F\x00\x00"
+ ```
+
+ ```ruby
+ "\x01\xfe".unpack('h*') # => ["10ef"]
+ "\x01\xfe".unpack('h0') # => [""]
+ "\x01\xfe".unpack('h1') # => ["1"]
+ "\x01\xfe".unpack('h2') # => ["10"]
+ "\x01\xfe".unpack('h3') # => ["10e"]
+ "\x01\xfe".unpack('h4') # => ["10ef"]
+ "\x01\xfe".unpack('h5') # => ["10ef"]
+ ```
+
+### Pointer \String Directives
+
+- `'P'` - Pointer to a structure (fixed-length string):
+
+ ```ruby
+ s = ['abc'].pack('P') # => "\xE0O\x7F\xE5\xA1\x01\x00\x00"
+ s.unpack('P*') # => ["abc"]
+ ".".unpack("P") # => []
+ ("\0" * 8).unpack("P") # => [nil]
+ [nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
+ ```
+
+- `'p'` - Pointer to a null-terminated string:
+
+ ```ruby
+ s = ['abc'].pack('p') # => "(\xE4u\xE5\xA1\x01\x00\x00"
+ s.unpack('p*') # => ["abc"]
+ ".".unpack("p") # => []
+ ("\0" * 8).unpack("p") # => [nil]
+ [nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
+ ```
+
+### Other \String Directives
+
+- `'M'` - Quoted printable, MIME encoding;
+ text mode, but input must use LF and output LF;
+ (see [RFC 2045](https://www.ietf.org/rfc/rfc2045.txt)):
+
+ ```ruby
+ ["a b c\td \ne"].pack('M') # => "a b c\td =\n\ne=\n"
+ ["\0"].pack('M') # => "=00=\n"
+ ```
+
+ ```ruby
+ ["a"*1023].pack('M') == ("a"*73+"=\n")*14+"a=\n" # => true
+ ("a"*73+"=\na=\n").unpack('M') == ["a"*74] # => true
+ (("a"*73+"=\n")*14+"a=\n").unpack('M') == ["a"*1023] # => true
+ ```
+
+ ```ruby
+ "a b c\td =\n\ne=\n".unpack('M') # => ["a b c\td \ne"]
+ "=00=\n".unpack('M') # => ["\x00"]
+ ```
+
+ ```ruby
+ "pre=31=32=33after".unpack('M') # => ["pre123after"]
+ "pre=\nafter".unpack('M') # => ["preafter"]
+ "pre=\r\nafter".unpack('M') # => ["preafter"]
+ "pre=".unpack('M') # => ["pre="]
+ "pre=\r".unpack('M') # => ["pre=\r"]
+ "pre=hoge".unpack('M') # => ["pre=hoge"]
+ "pre==31after".unpack('M') # => ["pre==31after"]
+ "pre===31after".unpack('M') # => ["pre===31after"]
+ ```
+
+- `'m'` - Base64 encoded string;
+ count specifies input bytes between each newline,
+ rounded down to nearest multiple of 3;
+ if count is zero, no newlines are added;
+ (see [RFC 4648](https://www.ietf.org/rfc/rfc4648.txt)):
+
+ ```ruby
+ [""].pack('m') # => ""
+ ["\0"].pack('m') # => "AA==\n"
+ ["\0\0"].pack('m') # => "AAA=\n"
+ ["\0\0\0"].pack('m') # => "AAAA\n"
+ ["\377"].pack('m') # => "/w==\n"
+ ["\377\377"].pack('m') # => "//8=\n"
+ ["\377\377\377"].pack('m') # => "////\n"
+ ```
+
+ ```ruby
+ "".unpack('m') # => [""]
+ "AA==\n".unpack('m') # => ["\x00"]
+ "AAA=\n".unpack('m') # => ["\x00\x00"]
+ "AAAA\n".unpack('m') # => ["\x00\x00\x00"]
+ "/w==\n".unpack('m') # => ["\xFF"]
+ "//8=\n".unpack('m') # => ["\xFF\xFF"]
+ "////\n".unpack('m') # => ["\xFF\xFF\xFF"]
+ "A\n".unpack('m') # => [""]
+ "AA\n".unpack('m') # => ["\x00"]
+ "AA=\n".unpack('m') # => ["\x00"]
+ "AAA\n".unpack('m') # => ["\x00\x00"]
+ ```
+
+ ```ruby
+ [""].pack('m0') # => ""
+ ["\0"].pack('m0') # => "AA=="
+ ["\0\0"].pack('m0') # => "AAA="
+ ["\0\0\0"].pack('m0') # => "AAAA"
+ ["\377"].pack('m0') # => "/w=="
+ ["\377\377"].pack('m0') # => "//8="
+ ["\377\377\377"].pack('m0') # => "////"
+ ```
+
+ ```ruby
+ "".unpack('m0') # => [""]
+ "AA==".unpack('m0') # => ["\x00"]
+ "AAA=".unpack('m0') # => ["\x00\x00"]
+ "AAAA".unpack('m0') # => ["\x00\x00\x00"]
+ "/w==".unpack('m0') # => ["\xFF"]
+ "//8=".unpack('m0') # => ["\xFF\xFF"]
+ "////".unpack('m0') # => ["\xFF\xFF\xFF"]
+ ```
+
+- `'u'` - UU-encoded string:
+
+ ```ruby
+ [""].pack("u") # => ""
+ ["a"].pack("u") # => "!80``\n"
+ ["aaa"].pack("u") # => "#86%A\n"
+ ```
+
+ ```ruby
+ "".unpack("u") # => [""]
+ "#86)C\n".unpack("u") # => ["abc"]
+ ```
+
+## Offset Directives
+
+- `'@'` - Begin packing at the given byte offset;
+ for packing, null fill or shrink if necessary:
+
+ ```ruby
+ [1, 2].pack("C@0C") # => "\x02"
+ [1, 2].pack("C@1C") # => "\x01\x02"
+ [1, 2].pack("C@5C") # => "\x01\x00\x00\x00\x00\x02"
+ [*1..5].pack("CCCC@2C") # => "\x01\x02\x05"
+ ```
+
+ For unpacking, cannot to move to outside the string:
+
+ ```ruby
+ "\x01\x00\x00\x02".unpack("C@3C") # => [1, 2]
+ "\x00".unpack("@1C") # => [nil]
+ "\x00".unpack("@2C") # Raises ArgumentError.
+ ```
+
+- `'X'` - For packing, shrink for the given byte offset:
+
+ ```ruby
+ [0, 1, 2].pack("CCXC") # => "\x00\x02"
+ [0, 1, 2].pack("CCX2C") # => "\x02"
+ ```
+
+ For unpacking; rewind unpacking position for the given byte offset:
+
+ ```ruby
+ "\x00\x02".unpack("CCXC") # => [0, 2, 2]
+ ```
+
+ Cannot to move to outside the string:
+
+ ```ruby
+ [0, 1, 2].pack("CCX3C") # Raises ArgumentError.
+ "\x00\x02".unpack("CX3C") # Raises ArgumentError.
+ ```
+
+- `'x'` - Begin packing at after the given byte offset;
+ for packing, null fill if necessary:
+
+ ```ruby
+ [].pack("x0") # => ""
+ [].pack("x") # => "\x00"
+ [].pack("x8") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
+ ```
+
+ For unpacking, cannot to move to outside the string:
+
+ ```ruby
+ "\x00\x00\x02".unpack("CxC") # => [0, 2]
+ "\x00\x00\x02".unpack("x3C") # => [nil]
+ "\x00\x00\x02".unpack("x4C") # Raises ArgumentError
+ ```
+
+- `'^'` - Only for unpacking; the current position:
+
+ ```ruby
+ "foo\0\0\0".unpack("Z*^") # => ["foo", 4]
+ ```
diff --git a/doc/language/ractor.md b/doc/language/ractor.md
new file mode 100644
index 0000000000..1592656217
--- /dev/null
+++ b/doc/language/ractor.md
@@ -0,0 +1,797 @@
+# Ractor - Ruby's Actor-like concurrency abstraction
+
+Ractors are designed to provide parallel execution of Ruby code without thread-safety concerns.
+
+## Summary
+
+### Multiple Ractors in a ruby process
+
+You can create multiple Ractors which can run ruby code in parallel with each other.
+
+* `Ractor.new{ expr }` creates a new Ractor and `expr` can run in parallel with other ractors on a multi-core computer.
+* Ruby processes start with one ractor (called the *main ractor*).
+* If the main ractor terminates, all other ractors receive termination requests, similar to how threads behave.
+* Each Ractor contains one or more `Thread`s.
+ * Threads within the same ractor share a ractor-wide global lock (GVL in MRI terminology), so they can't run in parallel with each other (without releasing the GVL explicitly in C extensions). Threads in different ractors can run in parallel.
+ * The overhead of creating a ractor is slightly above the overhead of creating a thread.
+
+### Limited sharing between Ractors
+
+Ractors don't share all objects, unlike threads which can access any object other than objects stored in another thread's thread-locals.
+
+* Most objects are *unshareable objects*. Unshareable objects can only be used by the ractor that instantiated them, so you don't need to worry about thread-safety issues resulting from using the object concurrently across ractors.
+* Some objects are *shareable objects*. Here is an incomplete list to give you an idea:
+ * `i = 123`: All `Integer`s are shareable.
+ * `s = "str".freeze`: Frozen strings are shareable if they have no instance variables that refer to unshareable objects.
+ * `a = [1, [2], 3].freeze`: `a` is not a shareable object because `a` refers to the unshareable object `[2]` (this Array is not frozen).
+ * `h = {c: Object}.freeze`: `h` is shareable because `Symbol`s and `Class`es are shareable, and the Hash is frozen.
+ * Class/Module objects are always shareable, even if they refer to unshareable objects.
+ * Special shareable objects
+ * Ractor objects themselves are shareable.
+ * And more...
+
+### Communication between Ractors with `Ractor::Port`
+
+Ractors communicate with each other and synchronize their execution by exchanging messages. The `Ractor::Port` class provides this communication mechanism.
+
+```ruby
+port = Ractor::Port.new
+
+Ractor.new port do |port|
+ # Other ractors can send to the port
+ port << 42
+end
+
+port.receive # get a message from the port. Only the ractor that created the Port can receive from it.
+#=> 42
+```
+
+All Ractors have a default port, which `Ractor#send`, `Ractor.receive` (etc) will use.
+
+### Copy & Move semantics when sending objects
+
+To send unshareable objects to another ractor, objects are either copied or moved.
+
+* Copy: deep-copies the object to the other ractor. All unshareable objects will be `Kernel#clone`ed.
+* Move: moves membership to another ractor.
+ * The sending ractor can not access the moved object after it moves.
+ * There is a guarantee that only one ractor can access an unshareable object at once.
+
+### Thread-safety
+
+Ractors help to write thread-safe, concurrent programs. They allow sharing of data only through explicit message passing for
+unshareable objects. Shareable objects are guaranteed to work correctly across ractors, even if the ractors are running in parallel.
+This guarantee, however, only applies across ractors. You still need to use `Mutex`es and other thread-safety tools within a ractor if
+you're using multiple ruby `Thread`s.
+
+ * Most objects are unshareable. You can't create data-races across ractors due to the inability to use these objects across ractors.
+ * Shareable objects are protected by locks (or otherwise don't need to be) so they can be used by more than one ractor at once.
+
+## Creation and termination
+
+### `Ractor.new`
+
+* `Ractor.new { expr }` creates a Ractor.
+
+```ruby
+# Ractor.new with a block creates a new Ractor
+r = Ractor.new do
+ # This block can run in parallel with other ractors
+end
+
+# You can name a Ractor with a `name:` argument.
+r = Ractor.new name: 'my-first-ractor' do
+end
+
+r.name #=> 'my-first-ractor'
+```
+
+### Block isolation
+
+The Ractor executes `expr` in the given block.
+The given block will be isolated from its outer scope. To prevent sharing objects between ractors, outer variables, `self` and other information is isolated from the block.
+
+This isolation occurs at Ractor creation time (when `Ractor.new` is called). If the given block is not able to be isolated because of outer variables or `self`, an error will be raised.
+
+```ruby
+begin
+ a = true
+ r = Ractor.new do
+ a #=> Ractor::IsolationError because this block accesses outer variable `a`.
+ end
+ r.join # wait for ractor to finish
+rescue Ractor::IsolationError
+end
+```
+
+* The `self` of the given block is the `Ractor` object itself.
+
+```ruby
+r = Ractor.new do
+ p self.class #=> Ractor
+ self.object_id
+end
+r.value == self.object_id #=> false
+```
+
+Arguments passed to `Ractor.new()` become block parameters for the given block. However, Ruby does not pass the objects themselves, but sends them as messages (see below for details).
+
+```ruby
+r = Ractor.new 'ok' do |msg|
+ msg #=> 'ok'
+end
+r.value #=> 'ok'
+```
+
+```ruby
+# similar to the last example
+r = Ractor.new do
+ msg = Ractor.receive
+ msg
+end
+r.send 'ok'
+r.value #=> 'ok'
+```
+
+### The execution result of the given block
+
+The return value of the given block becomes an outgoing message (see below for details).
+
+```ruby
+r = Ractor.new do
+ 'ok'
+end
+r.value #=> `ok`
+```
+
+An error in the given block will be propagated to the consumer of the outgoing message.
+
+```ruby
+r = Ractor.new do
+ raise 'ok' # exception will be transferred to the consumer
+end
+
+begin
+ r.value
+rescue Ractor::RemoteError => e
+ e.cause.class #=> RuntimeError
+ e.cause.message #=> 'ok'
+ e.ractor #=> r
+end
+```
+
+## Communication between Ractors
+
+Communication between ractors is achieved by sending and receiving messages. There are two ways to communicate:
+
+* (1) Sending and receiving messages via `Ractor::Port`
+* (2) Using shareable container objects. For example, the Ractor::TVar gem ([ko1/ractor-tvar](https://github.com/ko1/ractor-tvar))
+
+Users can control program execution timing with (1), but should not control with (2) (only perform critical sections).
+
+For sending and receiving messages, these are the fundamental APIs:
+
+* send/receive via `Ractor::Port`.
+ * `Ractor::Port#send(obj)` (`Ractor::Port#<<(obj)` is an alias) sends a message to the port. Ports are connected to an infinite size incoming queue so sending will never block the caller.
+ * `Ractor::Port#receive` dequeues a message from its own incoming queue. If the incoming queue is empty, `Ractor::Port#receive` will block the execution of the current Thread until a message is sent.
+ * `Ractor#send` and `Ractor.receive` use ports (their default port) internally, so are conceptually similar to the above.
+* You can close a `Ractor::Port` by `Ractor::Port#close`. A port can only be closed by the ractor that created it.
+ * If a port is closed, you can't `send` to it. Doing so raises an exception.
+ * When a ractor is terminated, the ractor's ports are automatically closed.
+* You can wait for a ractor's termination and receive its return value with `Ractor#value`. This is similar to `Thread#value`.
+
+There are 3 ways to send an object as a message:
+
+1) Send a reference: sending a shareable object sends only a reference to the object (fast).
+
+2) Copy an object: sending an unshareable object through copying it deeply (can be slow). Note that you can not send an object this way which does not support deep copy. Some `T_DATA` objects (objects whose class is defined in a C extension, such as `StringIO`) are not supported.
+
+3) Move an object: sending an unshareable object across ractors with a membership change. The sending Ractor can not access the moved object after moving it, otherwise an exception will be raised. Implementation note: `T_DATA` objects are not supported.
+
+You can choose between "Copy" and "Move" by the `move:` keyword, `Ractor#send(obj, move: true/false)`. The default is `false` ("Copy"). However, if the object is shareable it will automatically use `move`.
+
+### Wait for multiple Ractors with `Ractor.select`
+
+You can wait for messages on multiple ports at once.
+The return value of `Ractor.select()` is `[port, msg]` where `port` is a ready port and `msg` is the received message.
+
+To make it convenient, `Ractor.select` can also accept ractors. In this case, it waits for their termination.
+The return value of `Ractor.select()` is `[r, msg]` where `r` is a terminated Ractor and `msg` is the value of the ractor's block.
+
+Wait for a single ractor (same as `Ractor#value`):
+
+```ruby
+r1 = Ractor.new{'r1'}
+
+r, obj = Ractor.select(r1)
+r == r1 and obj == 'r1' #=> true
+```
+
+Wait for two ractors:
+
+```ruby
+r1 = Ractor.new{'r1'}
+r2 = Ractor.new{'r2'}
+rs = [r1, r2]
+values = []
+
+while rs.any?
+ r, obj = Ractor.select(*rs)
+ rs.delete(r)
+ values << obj
+end
+
+values.sort == ['r1', 'r2'] #=> true
+```
+
+NOTE: Using `Ractor.select()` on a very large number of ractors has the same issue as `select(2)` currently.
+
+### Closing ports
+
+* `Ractor::Port#close` closes the port (similar to `Queue#close`).
+ * `port.send(obj)` will raise an exception when the port is closed.
+ * When the queue connected to the port is empty and port is closed, `Ractor::Port#receive` raises an exception. If the queue is not empty, it dequeues an object without exceptions.
+* When a Ractor terminates, the ports are closed automatically.
+
+Example (try to get a result from closed ractor):
+
+```ruby
+r = Ractor.new do
+ 'finish'
+end
+r.join # success (wait for the termination)
+r.value # success (will return 'finish')
+
+# The ractor's termination value has already been given to another ractor
+Ractor.new r do |r|
+ r.value #=> Ractor::Error
+end.join
+```
+
+Example (try to send to closed port):
+
+```ruby
+r = Ractor.new do
+end
+
+r.join # wait for termination, closes default port
+
+begin
+ r.send(1)
+rescue Ractor::ClosedError
+ 'ok'
+end
+```
+
+### Send a message by copying
+
+`Ractor::Port#send(obj)` copies `obj` deeply if `obj` is an unshareable object.
+
+```ruby
+obj = 'str'.dup
+r = Ractor.new obj do |msg|
+ # return received msg's object_id
+ msg.object_id
+end
+
+obj.object_id == r.value #=> false
+```
+
+Some objects do not support copying, and raise an exception.
+
+```ruby
+obj = Thread.new{}
+begin
+ Ractor.new obj do |msg|
+ msg
+ end
+rescue TypeError => e
+ e.message #=> #<TypeError: allocator undefined for Thread>
+end
+```
+
+### Send a message by moving
+
+`Ractor::Port#send(obj, move: true)` moves `obj` to the destination Ractor.
+If the source ractor uses the moved object (for example, calls a method like `obj.foo()`), it will raise an error.
+
+```ruby
+r = Ractor.new do
+ obj = Ractor.receive
+ obj << ' world'
+end
+
+str = 'hello'.dup
+r.send str, move: true
+# str is now moved, and accessing str from this ractor is prohibited
+modified = r.value #=> 'hello world'
+
+
+begin
+ # Error because it uses moved str.
+ str << ' exception' # raise Ractor::MovedError
+rescue Ractor::MovedError
+ modified #=> 'hello world'
+end
+```
+
+Some objects do not support moving, and an exception will be raised.
+
+```ruby
+r = Ractor.new do
+ Ractor.receive
+end
+
+r.send(Thread.new{}, move: true) #=> allocator undefined for Thread (TypeError)
+```
+
+Once an object has been moved, the source object's class is changed to `Ractor::MovedObject`.
+
+### Shareable objects
+
+The following is an inexhaustive list of shareable objects:
+
+* `Integer`, `Float`, `Complex`, `Rational`
+* `Symbol`, frozen `String` objects that don't refer to unshareables, `true`, `false`, `nil`
+* `Regexp` objects, if they have no instance variables or their instance variables refer only to shareables
+* `Class` and `Module` objects
+* `Ractor` and other special objects which deal with synchronization
+
+To make objects shareable, `Ractor.make_shareable(obj)` is provided. It tries to make the object shareable by freezing `obj` and recursively traversing its references to freeze them all. This method accepts the `copy:` keyword (default value is false). `Ractor.make_shareable(obj, copy: true)` tries to make a deep copy of `obj` and make the copied object shareable. `Ractor.make_shareable(copy: false)` has no effect on an already shareable object. If the object cannot be made shareable, a `Ractor::Error` exception will be raised.
+
+## Language changes to limit sharing between Ractors
+
+To isolate unshareable objects across ractors, we introduced additional language semantics for multi-ractor Ruby programs.
+
+Note that when not using ractors, these additional semantics are not needed (100% compatible with Ruby 2).
+
+### Global variables
+
+Only the main Ractor can access global variables.
+
+```ruby
+$gv = 1
+r = Ractor.new do
+ $gv
+end
+
+begin
+ r.join
+rescue Ractor::RemoteError => e
+ e.cause.message #=> 'can not access global variables from non-main Ractors'
+end
+```
+
+Note that some special global variables, such as `$stdin`, `$stdout` and `$stderr` are local to each ractor. See [[Bug #17268]](https://bugs.ruby-lang.org/issues/17268) for more details.
+
+### Instance variables of shareable objects
+
+Instance variables of classes/modules can be accessed from non-main ractors only if their values are shareable objects.
+
+```ruby
+class C
+ @iv = 1
+end
+
+p Ractor.new do
+ class C
+ @iv
+ end
+end.value #=> 1
+```
+
+Otherwise, only the main Ractor can access instance variables of shareable objects.
+
+```ruby
+class C
+ @iv = [] # unshareable object
+end
+
+Ractor.new do
+ class C
+ begin
+ p @iv
+ rescue Ractor::IsolationError
+ p $!.message
+ #=> "can not get unshareable values from instance variables of classes/modules from non-main Ractors"
+ end
+
+ begin
+ @iv = 42
+ rescue Ractor::IsolationError
+ p $!.message
+ #=> "can not set instance variables of classes/modules by non-main Ractors"
+ end
+ end
+end.join
+```
+
+```ruby
+shared = Ractor.new{}
+shared.instance_variable_set(:@iv, 'str')
+
+r = Ractor.new shared do |shared|
+ p shared.instance_variable_get(:@iv)
+end
+
+begin
+ r.join
+rescue Ractor::RemoteError => e
+ e.cause.message #=> can not access instance variables of shareable objects from non-main Ractors (Ractor::IsolationError)
+end
+```
+
+### Class variables
+
+Only the main Ractor can access class variables.
+
+```ruby
+class C
+ @@cv = 'str'
+end
+
+r = Ractor.new do
+ class C
+ p @@cv
+ end
+end
+
+
+begin
+ r.join
+rescue => e
+ e.class #=> Ractor::IsolationError
+end
+```
+
+### Constants
+
+Only the main Ractor can read constants which refer to an unshareable object.
+
+```ruby
+class C
+ CONST = 'str'.dup
+end
+r = Ractor.new do
+ C::CONST
+end
+begin
+ r.join
+rescue => e
+ e.class #=> Ractor::IsolationError
+end
+```
+
+Only the main Ractor can define constants which refer to an unshareable object.
+
+```ruby
+class C
+end
+r = Ractor.new do
+ C::CONST = 'str'.dup
+end
+begin
+ r.join
+rescue => e
+ e.class #=> Ractor::IsolationError
+end
+```
+
+When creating/updating a library to support ractors, constants should only refer to shareable objects if they are to be used by non-main ractors.
+
+```ruby
+TABLE = {a: 'ko1', b: 'ko2', c: 'ko3'}
+```
+
+In this case, `TABLE` refers to an unshareable Hash object. In order for other ractors to use `TABLE`, we need to make it shareable. We can use `Ractor.make_shareable()` like so:
+
+```ruby
+TABLE = Ractor.make_shareable( {a: 'ko1', b: 'ko2', c: 'ko3'} )
+```
+
+To make it easy, Ruby 3.0 introduced a new `shareable_constant_value` file directive.
+
+```ruby
+# shareable_constant_value: literal
+
+TABLE = {a: 'ko1', b: 'ko2', c: 'ko3'}
+#=> Same as: TABLE = Ractor.make_shareable( {a: 'ko1', b: 'ko2', c: 'ko3'} )
+```
+
+The `shareable_constant_value` directive accepts the following modes (descriptions use the example: `CONST = expr`):
+
+* none: Do nothing. Same as: `CONST = expr`
+* literal:
+ * if `expr` consists of literals, replaced to `CONST = Ractor.make_shareable(expr)`.
+ * otherwise: replaced to `CONST = expr.tap{|o| raise unless Ractor.shareable?(o)}`.
+* experimental_everything: replaced to `CONST = Ractor.make_shareable(expr)`.
+* experimental_copy: replaced to `CONST = Ractor.make_shareable(expr, copy: true)`.
+
+Except for the `none` mode (default), it is guaranteed that these constants refer only to shareable objects.
+
+See [syntax/comments.rdoc](../syntax/comments.rdoc) for more details.
+
+### Shareable procs
+
+Procs and lambdas are unshareable objects, even when they are frozen. To create an unshareable Proc, you must use `Ractor.shareable_proc { expr }`. Much like during Ractor creation, the proc's block is isolated from its outer environment, so it cannot access variables from the outside scope. `self` is also changed within the Proc to be `nil` by default, although a `self:` keyword can be provided if you want to customize the value to a different shareable object.
+
+```ruby
+p = Ractor.shareable_proc { p self }
+p.call #=> nil
+```
+
+```ruby
+begin
+ a = 1
+ pr = Ractor.shareable_proc { p a }
+ pr.call # never gets here
+rescue Ractor::IsolationError
+end
+```
+
+In order to dynamically define a method with `Module#define_method` that can be used from different ractors, you must define it with a shareable proc. Alternatively, you can use `Module#class_eval` or `Module#module_eval` with a String. Even though the shareable proc's `self` is initially bound to `nil`, `define_method` will bind `self` to the correct value in the method.
+
+```ruby
+class A
+ define_method :testing, &Ractor.shareable_proc do
+ p self
+ end
+end
+Ractor.new do
+ a = A.new
+ a.testing #=> #<A:0x0000000101acfe10>
+end.join
+```
+
+This isolation must be done to prevent the method from accessing and assigning captured outer variables across ractors.
+
+### Ractor-local storage
+
+You can store any object (even unshareables) in ractor-local storage.
+
+```ruby
+r = Ractor.new do
+ values = []
+ Ractor[:threads] = []
+ 3.times do |i|
+ Ractor[:threads] << Thread.new do
+ values << [Ractor.receive, i+1] # Ractor.receive blocks the current thread in the current ractor until it receives a message
+ end
+ end
+ Ractor[:threads].each(&:join)
+ values
+end
+
+r << 1
+r << 2
+r << 3
+r.value #=> [[1,1],[2,2],[3,3]] (the order can change with each run)
+```
+
+## Examples
+
+### Traditional Ring example in Actor-model
+
+```ruby
+RN = 1_000
+CR = Ractor.current
+
+r = Ractor.new do
+ p Ractor.receive
+ CR << :fin
+end
+
+RN.times{
+ r = Ractor.new r do |next_r|
+ next_r << Ractor.receive
+ end
+}
+
+p :setup_ok
+r << 1
+p Ractor.receive
+```
+
+### Fork-join
+
+```ruby
+def fib n
+ if n < 2
+ 1
+ else
+ fib(n-2) + fib(n-1)
+ end
+end
+
+RN = 10
+rs = (1..RN).map do |i|
+ Ractor.new i do |i|
+ [i, fib(i)]
+ end
+end
+
+until rs.empty?
+ r, v = Ractor.select(*rs)
+ rs.delete r
+ p answer: v
+end
+```
+
+### Worker pool
+
+(1) One ractor has a pool
+
+```ruby
+require 'prime'
+
+N = 1000
+RN = 10
+
+# make RN workers
+workers = (1..RN).map do
+ Ractor.new do |; result_port|
+ loop do
+ n, result_port = Ractor.receive
+ result_port << [n, n.prime?, Ractor.current]
+ end
+ end
+end
+
+result_port = Ractor::Port.new
+results = []
+
+(1..N).each do |i|
+ if workers.empty?
+ # receive a result
+ n, result, w = result_port.receive
+ results << [n, result]
+ else
+ w = workers.pop
+ end
+
+ # send a task to the idle worker ractor
+ w << [i, result_port]
+end
+
+# receive a result
+while results.size != N
+ n, result, _w = result_port.receive
+ results << [n, result]
+end
+
+pp results.sort_by{|n, result| n}
+```
+
+### Pipeline
+
+```ruby
+# pipeline with send/receive
+
+r3 = Ractor.new Ractor.current do |cr|
+ cr.send Ractor.receive + 'r3'
+end
+
+r2 = Ractor.new r3 do |r3|
+ r3.send Ractor.receive + 'r2'
+end
+
+r1 = Ractor.new r2 do |r2|
+ r2.send Ractor.receive + 'r1'
+end
+
+r1 << 'r0'
+p Ractor.receive #=> "r0r1r2r3"
+```
+
+### Supervise
+
+```ruby
+# ring example again
+
+r = Ractor.current
+(1..10).map{|i|
+ r = Ractor.new r, i do |r, i|
+ r.send Ractor.receive + "r#{i}"
+ end
+}
+
+r.send "r0"
+p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
+```
+
+```ruby
+# ring example with an error
+
+r = Ractor.current
+rs = (1..10).map{|i|
+ r = Ractor.new r, i do |r, i|
+ loop do
+ msg = Ractor.receive
+ raise if /e/ =~ msg
+ r.send msg + "r#{i}"
+ end
+ end
+}
+
+r.send "r0"
+p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
+r.send "r0"
+p Ractor.select(*rs, Ractor.current) #=> [:receive, "r0r10r9r8r7r6r5r4r3r2r1"]
+r.send "e0"
+p Ractor.select(*rs, Ractor.current)
+#=>
+# <Thread:0x000056262de28bd8 run> terminated with exception (report_on_exception is true):
+# Traceback (most recent call last):
+# 2: from /home/ko1/src/ruby/trunk/test.rb:7:in `block (2 levels) in <main>'
+# 1: from /home/ko1/src/ruby/trunk/test.rb:7:in `loop'
+# /home/ko1/src/ruby/trunk/test.rb:9:in `block (3 levels) in <main>': unhandled exception
+# Traceback (most recent call last):
+# 2: from /home/ko1/src/ruby/trunk/test.rb:7:in `block (2 levels) in <main>'
+# 1: from /home/ko1/src/ruby/trunk/test.rb:7:in `loop'
+# /home/ko1/src/ruby/trunk/test.rb:9:in `block (3 levels) in <main>': unhandled exception
+# 1: from /home/ko1/src/ruby/trunk/test.rb:21:in `<main>'
+# <internal:ractor>:69:in `select': thrown by remote Ractor. (Ractor::RemoteError)
+```
+
+```ruby
+# resend non-error message
+
+r = Ractor.current
+rs = (1..10).map{|i|
+ r = Ractor.new r, i do |r, i|
+ loop do
+ msg = Ractor.receive
+ raise if /e/ =~ msg
+ r.send msg + "r#{i}"
+ end
+ end
+}
+
+r.send "r0"
+p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
+r.send "r0"
+p Ractor.select(*rs, Ractor.current)
+[:receive, "r0r10r9r8r7r6r5r4r3r2r1"]
+msg = 'e0'
+begin
+ r.send msg
+ p Ractor.select(*rs, Ractor.current)
+rescue Ractor::RemoteError
+ msg = 'r0'
+ retry
+end
+
+#=> <internal:ractor>:100:in `send': The incoming-port is already closed (Ractor::ClosedError)
+# because r == r[-1] is terminated.
+```
+
+```ruby
+# ring example with supervisor and re-start
+
+def make_ractor r, i
+ Ractor.new r, i do |r, i|
+ loop do
+ msg = Ractor.receive
+ raise if /e/ =~ msg
+ r.send msg + "r#{i}"
+ end
+ end
+end
+
+r = Ractor.current
+rs = (1..10).map{|i|
+ r = make_ractor(r, i)
+}
+
+msg = 'e0' # error causing message
+begin
+ r.send msg
+ p Ractor.select(*rs, Ractor.current)
+rescue Ractor::RemoteError
+ r = rs[-1] = make_ractor(rs[-2], rs.size-1)
+ msg = 'x0'
+ retry
+end
+
+#=> [:receive, "x0r9r9r8r7r6r5r4r3r2r1"]
+```
diff --git a/doc/language/regexp/methods.rdoc b/doc/language/regexp/methods.rdoc
new file mode 100644
index 0000000000..356156ac9a
--- /dev/null
+++ b/doc/language/regexp/methods.rdoc
@@ -0,0 +1,41 @@
+== \Regexp Methods
+
+Each of these Ruby core methods can accept a regexp as an argument:
+
+- Enumerable#all?
+- Enumerable#any?
+- Enumerable#grep
+- Enumerable#grep_v
+- Enumerable#none?
+- Enumerable#one?
+- Enumerable#slice_after
+- Enumerable#slice_before
+- Regexp#=~
+- Regexp#match
+- Regexp#match?
+- Regexp.new
+- Regexp.union
+- String#=~
+- String#[]=
+- String#byteindex
+- String#byterindex
+- String#gsub
+- String#gsub!
+- String#index
+- String#match
+- String#match?
+- String#partition
+- String#rindex
+- String#rpartition
+- String#scan
+- String#slice
+- String#slice!
+- String#split
+- String#start_with?
+- String#sub
+- String#sub!
+- Symbol#=~
+- Symbol#match
+- Symbol#match?
+- Symbol#slice
+- Symbol#start_with?
diff --git a/doc/language/regexp/unicode_properties.rdoc b/doc/language/regexp/unicode_properties.rdoc
new file mode 100644
index 0000000000..94080f7199
--- /dev/null
+++ b/doc/language/regexp/unicode_properties.rdoc
@@ -0,0 +1,718 @@
+== \Regexps Based on Unicode Properties
+
+The properties shown here are those currently supported in Ruby.
+Older versions may not support all of these.
+
+=== POSIX brackets
+
+- <tt>\p{ASCII}</tt>
+- <tt>\p{Alnum}</tt>
+- <tt>\p{Alphabetic}</tt>, <tt>\p{Alpha}</tt>
+- <tt>\p{Blank}</tt>
+- <tt>\p{Cntrl}</tt>
+- <tt>\p{Digit}</tt>
+- <tt>\p{Graph}</tt>
+- <tt>\p{Lowercase}</tt>, <tt>\p{Lower}</tt>
+- <tt>\p{Print}</tt>
+- <tt>\p{Punct}</tt>
+- <tt>\p{Space}</tt>
+- <tt>\p{Uppercase}</tt>, <tt>\p{Upper}</tt>
+- <tt>\p{Word}</tt>
+- <tt>\p{XDigit}</tt>
+- <tt>\p{XPosixPunct}</tt>
+
+=== Special
+
+- <tt>\p{Any}</tt>
+- <tt>\p{Assigned}</tt>
+
+=== Major and General Categories
+
+- <tt>\p{Cased_Letter}</tt>, <tt>\p{LC}</tt>
+- <tt>\p{Close_Punctuation}</tt>, <tt>\p{Pe}</tt>
+- <tt>\p{Connector_Punctuation}</tt>, <tt>\p{Pc}</tt>
+- <tt>\p{Control}</tt>, <tt>\p{Cc}</tt>
+- <tt>\p{Currency_Symbol}</tt>, <tt>\p{Sc}</tt>
+- <tt>\p{Dash_Punctuation}</tt>, <tt>\p{Pd}</tt>
+- <tt>\p{Decimal_Number}</tt>, <tt>\p{Nd}</tt>
+- <tt>\p{Enclosing_Mark}</tt>, <tt>\p{Me}</tt>
+- <tt>\p{Final_Punctuation}</tt>, <tt>\p{Pf}</tt>
+- <tt>\p{Format}</tt>, <tt>\p{Cf}</tt>
+- <tt>\p{Initial_Punctuation}</tt>, <tt>\p{Pi}</tt>
+- <tt>\p{Letter}</tt>, <tt>\p{L}</tt>
+- <tt>\p{Letter_Number}</tt>, <tt>\p{Nl}</tt>
+- <tt>\p{Line_Separator}</tt>, <tt>\p{Zl}</tt>
+- <tt>\p{Lowercase_Letter}</tt>, <tt>\p{Ll}</tt>
+- <tt>\p{Mark}</tt>, <tt>\p{M}</tt>
+- <tt>\p{Math_Symbol}</tt>, <tt>\p{Sm}</tt>
+- <tt>\p{Modifier_Letter}</tt>, <tt>\p{Lm}</tt>
+- <tt>\p{Modifier_Symbol}</tt>, <tt>\p{Sk}</tt>
+- <tt>\p{Nonspacing_Mark}</tt>, <tt>\p{Mn}</tt>
+- <tt>\p{Number}</tt>, <tt>\p{N}</tt>
+- <tt>\p{Open_Punctuation}</tt>, <tt>\p{Ps}</tt>
+- <tt>\p{Other}</tt>, <tt>\p{C}</tt>
+- <tt>\p{Other_Letter}</tt>, <tt>\p{Lo}</tt>
+- <tt>\p{Other_Number}</tt>, <tt>\p{No}</tt>
+- <tt>\p{Other_Punctuation}</tt>, <tt>\p{Po}</tt>
+- <tt>\p{Other_Symbol}</tt>, <tt>\p{So}</tt>
+- <tt>\p{Paragraph_Separator}</tt>, <tt>\p{Zp}</tt>
+- <tt>\p{Private_Use}</tt>, <tt>\p{Co}</tt>
+- <tt>\p{Punctuation}</tt>, <tt>\p{P}</tt>
+- <tt>\p{Separator}</tt>, <tt>\p{Z}</tt>
+- <tt>\p{Space_Separator}</tt>, <tt>\p{Zs}</tt>
+- <tt>\p{Spacing_Mark}</tt>, <tt>\p{Mc}</tt>
+- <tt>\p{Surrogate}</tt>, <tt>\p{Cs}</tt>
+- <tt>\p{Symbol}</tt>, <tt>\p{S}</tt>
+- <tt>\p{Titlecase_Letter}</tt>, <tt>\p{Lt}</tt>
+- <tt>\p{Unassigned}</tt>, <tt>\p{Cn}</tt>
+- <tt>\p{Uppercase_Letter}</tt>, <tt>\p{Lu}</tt>
+
+=== Prop List
+
+- <tt>\p{ASCII_Hex_Digit}</tt>, <tt>\p{AHex}</tt>
+- <tt>\p{Bidi_Control}</tt>, <tt>\p{Bidi_C}</tt>
+- <tt>\p{Dash}</tt>
+- <tt>\p{Deprecated}</tt>, <tt>\p{Dep}</tt>
+- <tt>\p{Diacritic}</tt>, <tt>\p{Dia}</tt>
+- <tt>\p{Extender}</tt>, <tt>\p{Ext}</tt>
+- <tt>\p{Hex_Digit}</tt>, <tt>\p{Hex}</tt>
+- <tt>\p{Hyphen}</tt>
+- <tt>\p{IDS_Binary_Operator}</tt>, <tt>\p{IDSB}</tt>
+- <tt>\p{IDS_Trinary_Operator}</tt>, <tt>\p{IDST}</tt>
+- <tt>\p{IDS_Unary_Operator}</tt>, <tt>\p{IDSU}</tt>
+- <tt>\p{ID_Compat_Math_Continue}</tt>
+- <tt>\p{ID_Compat_Math_Start}</tt>
+- <tt>\p{Ideographic}</tt>, <tt>\p{Ideo}</tt>
+- <tt>\p{Join_Control}</tt>, <tt>\p{Join_C}</tt>
+- <tt>\p{Logical_Order_Exception}</tt>, <tt>\p{LOE}</tt>
+- <tt>\p{Modifier_Combining_Mark}</tt>, <tt>\p{MCM}</tt>
+- <tt>\p{Noncharacter_Code_Point}</tt>, <tt>\p{NChar}</tt>
+- <tt>\p{Other_Alphabetic}</tt>, <tt>\p{OAlpha}</tt>
+- <tt>\p{Other_Default_Ignorable_Code_Point}</tt>, <tt>\p{ODI}</tt>
+- <tt>\p{Other_Grapheme_Extend}</tt>, <tt>\p{OGr_Ext}</tt>
+- <tt>\p{Other_ID_Continue}</tt>, <tt>\p{OIDC}</tt>
+- <tt>\p{Other_ID_Start}</tt>, <tt>\p{OIDS}</tt>
+- <tt>\p{Other_Lowercase}</tt>, <tt>\p{OLower}</tt>
+- <tt>\p{Other_Math}</tt>, <tt>\p{OMath}</tt>
+- <tt>\p{Other_Uppercase}</tt>, <tt>\p{OUpper}</tt>
+- <tt>\p{Pattern_Syntax}</tt>, <tt>\p{Pat_Syn}</tt>
+- <tt>\p{Pattern_White_Space}</tt>, <tt>\p{Pat_WS}</tt>
+- <tt>\p{Prepended_Concatenation_Mark}</tt>, <tt>\p{PCM}</tt>
+- <tt>\p{Quotation_Mark}</tt>, <tt>\p{QMark}</tt>
+- <tt>\p{Radical}</tt>
+- <tt>\p{Regional_Indicator}</tt>, <tt>\p{RI}</tt>
+- <tt>\p{Sentence_Terminal}</tt>, <tt>\p{STerm}</tt>
+- <tt>\p{Soft_Dotted}</tt>, <tt>\p{SD}</tt>
+- <tt>\p{Terminal_Punctuation}</tt>, <tt>\p{Term}</tt>
+- <tt>\p{Unified_Ideograph}</tt>, <tt>\p{UIdeo}</tt>
+- <tt>\p{Variation_Selector}</tt>, <tt>\p{VS}</tt>
+- <tt>\p{White_Space}</tt>, <tt>\p{WSpace}</tt>
+
+=== Derived Core Properties
+
+- <tt>\p{Alphabetic}</tt>, <tt>\p{Alpha}</tt>
+- <tt>\p{Case_Ignorable}</tt>, <tt>\p{CI}</tt>
+- <tt>\p{Cased}</tt>
+- <tt>\p{Changes_When_Casefolded}</tt>, <tt>\p{CWCF}</tt>
+- <tt>\p{Changes_When_Casemapped}</tt>, <tt>\p{CWCM}</tt>
+- <tt>\p{Changes_When_Lowercased}</tt>, <tt>\p{CWL}</tt>
+- <tt>\p{Changes_When_Titlecased}</tt>, <tt>\p{CWT}</tt>
+- <tt>\p{Changes_When_Uppercased}</tt>, <tt>\p{CWU}</tt>
+- <tt>\p{Default_Ignorable_Code_Point}</tt>, <tt>\p{DI}</tt>
+- <tt>\p{Grapheme_Base}</tt>, <tt>\p{Gr_Base}</tt>
+- <tt>\p{Grapheme_Extend}</tt>, <tt>\p{Gr_Ext}</tt>
+- <tt>\p{Grapheme_Link}</tt>, <tt>\p{Gr_Link}</tt>
+- <tt>\p{ID_Continue}</tt>, <tt>\p{IDC}</tt>
+- <tt>\p{ID_Start}</tt>, <tt>\p{IDS}</tt>
+- <tt>\p{InCB_Consonant}</tt>
+- <tt>\p{InCB_Extend}</tt>
+- <tt>\p{InCB_Linker}</tt>
+- <tt>\p{Lowercase}</tt>, <tt>\p{Lower}</tt>
+- <tt>\p{Math}</tt>
+- <tt>\p{Uppercase}</tt>, <tt>\p{Upper}</tt>
+- <tt>\p{XID_Continue}</tt>, <tt>\p{XIDC}</tt>
+- <tt>\p{XID_Start}</tt>, <tt>\p{XIDS}</tt>
+
+=== Scripts
+
+- <tt>\p{Adlam}</tt>, <tt>\p{Adlm}</tt>
+- <tt>\p{Ahom}</tt>
+- <tt>\p{Anatolian_Hieroglyphs}</tt>, <tt>\p{Hluw}</tt>
+- <tt>\p{Arabic}</tt>, <tt>\p{Arab}</tt>
+- <tt>\p{Armenian}</tt>, <tt>\p{Armn}</tt>
+- <tt>\p{Avestan}</tt>, <tt>\p{Avst}</tt>
+- <tt>\p{Balinese}</tt>, <tt>\p{Bali}</tt>
+- <tt>\p{Bamum}</tt>, <tt>\p{Bamu}</tt>
+- <tt>\p{Bassa_Vah}</tt>, <tt>\p{Bass}</tt>
+- <tt>\p{Batak}</tt>, <tt>\p{Batk}</tt>
+- <tt>\p{Bengali}</tt>, <tt>\p{Beng}</tt>
+- <tt>\p{Beria_Erfe}</tt>, <tt>\p{Berf}</tt>
+- <tt>\p{Bhaiksuki}</tt>, <tt>\p{Bhks}</tt>
+- <tt>\p{Bopomofo}</tt>, <tt>\p{Bopo}</tt>
+- <tt>\p{Brahmi}</tt>, <tt>\p{Brah}</tt>
+- <tt>\p{Braille}</tt>, <tt>\p{Brai}</tt>
+- <tt>\p{Buginese}</tt>, <tt>\p{Bugi}</tt>
+- <tt>\p{Buhid}</tt>, <tt>\p{Buhd}</tt>
+- <tt>\p{Canadian_Aboriginal}</tt>, <tt>\p{Cans}</tt>
+- <tt>\p{Carian}</tt>, <tt>\p{Cari}</tt>
+- <tt>\p{Caucasian_Albanian}</tt>, <tt>\p{Aghb}</tt>
+- <tt>\p{Chakma}</tt>, <tt>\p{Cakm}</tt>
+- <tt>\p{Cham}</tt>
+- <tt>\p{Cherokee}</tt>, <tt>\p{Cher}</tt>
+- <tt>\p{Chorasmian}</tt>, <tt>\p{Chrs}</tt>
+- <tt>\p{Common}</tt>, <tt>\p{Zyyy}</tt>
+- <tt>\p{Coptic}</tt>, <tt>\p{Copt}</tt>
+- <tt>\p{Cuneiform}</tt>, <tt>\p{Xsux}</tt>
+- <tt>\p{Cypriot}</tt>, <tt>\p{Cprt}</tt>
+- <tt>\p{Cypro_Minoan}</tt>, <tt>\p{Cpmn}</tt>
+- <tt>\p{Cyrillic}</tt>, <tt>\p{Cyrl}</tt>
+- <tt>\p{Deseret}</tt>, <tt>\p{Dsrt}</tt>
+- <tt>\p{Devanagari}</tt>, <tt>\p{Deva}</tt>
+- <tt>\p{Dives_Akuru}</tt>, <tt>\p{Diak}</tt>
+- <tt>\p{Dogra}</tt>, <tt>\p{Dogr}</tt>
+- <tt>\p{Duployan}</tt>, <tt>\p{Dupl}</tt>
+- <tt>\p{Egyptian_Hieroglyphs}</tt>, <tt>\p{Egyp}</tt>
+- <tt>\p{Elbasan}</tt>, <tt>\p{Elba}</tt>
+- <tt>\p{Elymaic}</tt>, <tt>\p{Elym}</tt>
+- <tt>\p{Ethiopic}</tt>, <tt>\p{Ethi}</tt>
+- <tt>\p{Garay}</tt>, <tt>\p{Gara}</tt>
+- <tt>\p{Georgian}</tt>, <tt>\p{Geor}</tt>
+- <tt>\p{Glagolitic}</tt>, <tt>\p{Glag}</tt>
+- <tt>\p{Gothic}</tt>, <tt>\p{Goth}</tt>
+- <tt>\p{Grantha}</tt>, <tt>\p{Gran}</tt>
+- <tt>\p{Greek}</tt>, <tt>\p{Grek}</tt>
+- <tt>\p{Gujarati}</tt>, <tt>\p{Gujr}</tt>
+- <tt>\p{Gunjala_Gondi}</tt>, <tt>\p{Gong}</tt>
+- <tt>\p{Gurmukhi}</tt>, <tt>\p{Guru}</tt>
+- <tt>\p{Gurung_Khema}</tt>, <tt>\p{Gukh}</tt>
+- <tt>\p{Han}</tt>, <tt>\p{Hani}</tt>
+- <tt>\p{Hangul}</tt>, <tt>\p{Hang}</tt>
+- <tt>\p{Hanifi_Rohingya}</tt>, <tt>\p{Rohg}</tt>
+- <tt>\p{Hanunoo}</tt>, <tt>\p{Hano}</tt>
+- <tt>\p{Hatran}</tt>, <tt>\p{Hatr}</tt>
+- <tt>\p{Hebrew}</tt>, <tt>\p{Hebr}</tt>
+- <tt>\p{Hiragana}</tt>, <tt>\p{Hira}</tt>
+- <tt>\p{Imperial_Aramaic}</tt>, <tt>\p{Armi}</tt>
+- <tt>\p{Inherited}</tt>, <tt>\p{Zinh}</tt>
+- <tt>\p{Inscriptional_Pahlavi}</tt>, <tt>\p{Phli}</tt>
+- <tt>\p{Inscriptional_Parthian}</tt>, <tt>\p{Prti}</tt>
+- <tt>\p{Javanese}</tt>, <tt>\p{Java}</tt>
+- <tt>\p{Kaithi}</tt>, <tt>\p{Kthi}</tt>
+- <tt>\p{Kannada}</tt>, <tt>\p{Knda}</tt>
+- <tt>\p{Katakana}</tt>, <tt>\p{Kana}</tt>
+- <tt>\p{Kawi}</tt>
+- <tt>\p{Kayah_Li}</tt>, <tt>\p{Kali}</tt>
+- <tt>\p{Kharoshthi}</tt>, <tt>\p{Khar}</tt>
+- <tt>\p{Khitan_Small_Script}</tt>, <tt>\p{Kits}</tt>
+- <tt>\p{Khmer}</tt>, <tt>\p{Khmr}</tt>
+- <tt>\p{Khojki}</tt>, <tt>\p{Khoj}</tt>
+- <tt>\p{Khudawadi}</tt>, <tt>\p{Sind}</tt>
+- <tt>\p{Kirat_Rai}</tt>, <tt>\p{Krai}</tt>
+- <tt>\p{Lao}</tt>, <tt>\p{Laoo}</tt>
+- <tt>\p{Latin}</tt>, <tt>\p{Latn}</tt>
+- <tt>\p{Lepcha}</tt>, <tt>\p{Lepc}</tt>
+- <tt>\p{Limbu}</tt>, <tt>\p{Limb}</tt>
+- <tt>\p{Linear_A}</tt>, <tt>\p{Lina}</tt>
+- <tt>\p{Linear_B}</tt>, <tt>\p{Linb}</tt>
+- <tt>\p{Lisu}</tt>
+- <tt>\p{Lycian}</tt>, <tt>\p{Lyci}</tt>
+- <tt>\p{Lydian}</tt>, <tt>\p{Lydi}</tt>
+- <tt>\p{Mahajani}</tt>, <tt>\p{Mahj}</tt>
+- <tt>\p{Makasar}</tt>, <tt>\p{Maka}</tt>
+- <tt>\p{Malayalam}</tt>, <tt>\p{Mlym}</tt>
+- <tt>\p{Mandaic}</tt>, <tt>\p{Mand}</tt>
+- <tt>\p{Manichaean}</tt>, <tt>\p{Mani}</tt>
+- <tt>\p{Marchen}</tt>, <tt>\p{Marc}</tt>
+- <tt>\p{Masaram_Gondi}</tt>, <tt>\p{Gonm}</tt>
+- <tt>\p{Medefaidrin}</tt>, <tt>\p{Medf}</tt>
+- <tt>\p{Meetei_Mayek}</tt>, <tt>\p{Mtei}</tt>
+- <tt>\p{Mende_Kikakui}</tt>, <tt>\p{Mend}</tt>
+- <tt>\p{Meroitic_Cursive}</tt>, <tt>\p{Merc}</tt>
+- <tt>\p{Meroitic_Hieroglyphs}</tt>, <tt>\p{Mero}</tt>
+- <tt>\p{Miao}</tt>, <tt>\p{Plrd}</tt>
+- <tt>\p{Modi}</tt>
+- <tt>\p{Mongolian}</tt>, <tt>\p{Mong}</tt>
+- <tt>\p{Mro}</tt>, <tt>\p{Mroo}</tt>
+- <tt>\p{Multani}</tt>, <tt>\p{Mult}</tt>
+- <tt>\p{Myanmar}</tt>, <tt>\p{Mymr}</tt>
+- <tt>\p{Nabataean}</tt>, <tt>\p{Nbat}</tt>
+- <tt>\p{Nag_Mundari}</tt>, <tt>\p{Nagm}</tt>
+- <tt>\p{Nandinagari}</tt>, <tt>\p{Nand}</tt>
+- <tt>\p{New_Tai_Lue}</tt>, <tt>\p{Talu}</tt>
+- <tt>\p{Newa}</tt>
+- <tt>\p{Nko}</tt>, <tt>\p{Nkoo}</tt>
+- <tt>\p{Nushu}</tt>, <tt>\p{Nshu}</tt>
+- <tt>\p{Nyiakeng_Puachue_Hmong}</tt>, <tt>\p{Hmnp}</tt>
+- <tt>\p{Ogham}</tt>, <tt>\p{Ogam}</tt>
+- <tt>\p{Ol_Chiki}</tt>, <tt>\p{Olck}</tt>
+- <tt>\p{Ol_Onal}</tt>, <tt>\p{Onao}</tt>
+- <tt>\p{Old_Hungarian}</tt>, <tt>\p{Hung}</tt>
+- <tt>\p{Old_Italic}</tt>, <tt>\p{Ital}</tt>
+- <tt>\p{Old_North_Arabian}</tt>, <tt>\p{Narb}</tt>
+- <tt>\p{Old_Permic}</tt>, <tt>\p{Perm}</tt>
+- <tt>\p{Old_Persian}</tt>, <tt>\p{Xpeo}</tt>
+- <tt>\p{Old_Sogdian}</tt>, <tt>\p{Sogo}</tt>
+- <tt>\p{Old_South_Arabian}</tt>, <tt>\p{Sarb}</tt>
+- <tt>\p{Old_Turkic}</tt>, <tt>\p{Orkh}</tt>
+- <tt>\p{Old_Uyghur}</tt>, <tt>\p{Ougr}</tt>
+- <tt>\p{Oriya}</tt>, <tt>\p{Orya}</tt>
+- <tt>\p{Osage}</tt>, <tt>\p{Osge}</tt>
+- <tt>\p{Osmanya}</tt>, <tt>\p{Osma}</tt>
+- <tt>\p{Pahawh_Hmong}</tt>, <tt>\p{Hmng}</tt>
+- <tt>\p{Palmyrene}</tt>, <tt>\p{Palm}</tt>
+- <tt>\p{Pau_Cin_Hau}</tt>, <tt>\p{Pauc}</tt>
+- <tt>\p{Phags_Pa}</tt>, <tt>\p{Phag}</tt>
+- <tt>\p{Phoenician}</tt>, <tt>\p{Phnx}</tt>
+- <tt>\p{Psalter_Pahlavi}</tt>, <tt>\p{Phlp}</tt>
+- <tt>\p{Rejang}</tt>, <tt>\p{Rjng}</tt>
+- <tt>\p{Runic}</tt>, <tt>\p{Runr}</tt>
+- <tt>\p{Samaritan}</tt>, <tt>\p{Samr}</tt>
+- <tt>\p{Saurashtra}</tt>, <tt>\p{Saur}</tt>
+- <tt>\p{Sharada}</tt>, <tt>\p{Shrd}</tt>
+- <tt>\p{Shavian}</tt>, <tt>\p{Shaw}</tt>
+- <tt>\p{Siddham}</tt>, <tt>\p{Sidd}</tt>
+- <tt>\p{Sidetic}</tt>, <tt>\p{Sidt}</tt>
+- <tt>\p{SignWriting}</tt>, <tt>\p{Sgnw}</tt>
+- <tt>\p{Sinhala}</tt>, <tt>\p{Sinh}</tt>
+- <tt>\p{Sogdian}</tt>, <tt>\p{Sogd}</tt>
+- <tt>\p{Sora_Sompeng}</tt>, <tt>\p{Sora}</tt>
+- <tt>\p{Soyombo}</tt>, <tt>\p{Soyo}</tt>
+- <tt>\p{Sundanese}</tt>, <tt>\p{Sund}</tt>
+- <tt>\p{Sunuwar}</tt>, <tt>\p{Sunu}</tt>
+- <tt>\p{Syloti_Nagri}</tt>, <tt>\p{Sylo}</tt>
+- <tt>\p{Syriac}</tt>, <tt>\p{Syrc}</tt>
+- <tt>\p{Tagalog}</tt>, <tt>\p{Tglg}</tt>
+- <tt>\p{Tagbanwa}</tt>, <tt>\p{Tagb}</tt>
+- <tt>\p{Tai_Le}</tt>, <tt>\p{Tale}</tt>
+- <tt>\p{Tai_Tham}</tt>, <tt>\p{Lana}</tt>
+- <tt>\p{Tai_Viet}</tt>, <tt>\p{Tavt}</tt>
+- <tt>\p{Tai_Yo}</tt>, <tt>\p{Tayo}</tt>
+- <tt>\p{Takri}</tt>, <tt>\p{Takr}</tt>
+- <tt>\p{Tamil}</tt>, <tt>\p{Taml}</tt>
+- <tt>\p{Tangsa}</tt>, <tt>\p{Tnsa}</tt>
+- <tt>\p{Tangut}</tt>, <tt>\p{Tang}</tt>
+- <tt>\p{Telugu}</tt>, <tt>\p{Telu}</tt>
+- <tt>\p{Thaana}</tt>, <tt>\p{Thaa}</tt>
+- <tt>\p{Thai}</tt>
+- <tt>\p{Tibetan}</tt>, <tt>\p{Tibt}</tt>
+- <tt>\p{Tifinagh}</tt>, <tt>\p{Tfng}</tt>
+- <tt>\p{Tirhuta}</tt>, <tt>\p{Tirh}</tt>
+- <tt>\p{Todhri}</tt>, <tt>\p{Todr}</tt>
+- <tt>\p{Tolong_Siki}</tt>, <tt>\p{Tols}</tt>
+- <tt>\p{Toto}</tt>
+- <tt>\p{Tulu_Tigalari}</tt>, <tt>\p{Tutg}</tt>
+- <tt>\p{Ugaritic}</tt>, <tt>\p{Ugar}</tt>
+- <tt>\p{Unknown}</tt>, <tt>\p{Zzzz}</tt>
+- <tt>\p{Vai}</tt>, <tt>\p{Vaii}</tt>
+- <tt>\p{Vithkuqi}</tt>, <tt>\p{Vith}</tt>
+- <tt>\p{Wancho}</tt>, <tt>\p{Wcho}</tt>
+- <tt>\p{Warang_Citi}</tt>, <tt>\p{Wara}</tt>
+- <tt>\p{Yezidi}</tt>, <tt>\p{Yezi}</tt>
+- <tt>\p{Yi}</tt>, <tt>\p{Yiii}</tt>
+- <tt>\p{Zanabazar_Square}</tt>, <tt>\p{Zanb}</tt>
+
+=== Blocks
+
+- <tt>\p{In_Adlam}</tt>
+- <tt>\p{In_Aegean_Numbers}</tt>
+- <tt>\p{In_Ahom}</tt>
+- <tt>\p{In_Alchemical_Symbols}</tt>
+- <tt>\p{In_Alphabetic_Presentation_Forms}</tt>
+- <tt>\p{In_Anatolian_Hieroglyphs}</tt>
+- <tt>\p{In_Ancient_Greek_Musical_Notation}</tt>
+- <tt>\p{In_Ancient_Greek_Numbers}</tt>
+- <tt>\p{In_Ancient_Symbols}</tt>
+- <tt>\p{In_Arabic}</tt>
+- <tt>\p{In_Arabic_Extended_A}</tt>
+- <tt>\p{In_Arabic_Extended_B}</tt>
+- <tt>\p{In_Arabic_Extended_C}</tt>
+- <tt>\p{In_Arabic_Mathematical_Alphabetic_Symbols}</tt>
+- <tt>\p{In_Arabic_Presentation_Forms_A}</tt>
+- <tt>\p{In_Arabic_Presentation_Forms_B}</tt>
+- <tt>\p{In_Arabic_Supplement}</tt>
+- <tt>\p{In_Armenian}</tt>
+- <tt>\p{In_Arrows}</tt>
+- <tt>\p{In_Avestan}</tt>
+- <tt>\p{In_Balinese}</tt>
+- <tt>\p{In_Bamum}</tt>
+- <tt>\p{In_Bamum_Supplement}</tt>
+- <tt>\p{In_Basic_Latin}</tt>
+- <tt>\p{In_Bassa_Vah}</tt>
+- <tt>\p{In_Batak}</tt>
+- <tt>\p{In_Bengali}</tt>
+- <tt>\p{In_Beria_Erfe}</tt>
+- <tt>\p{In_Bhaiksuki}</tt>
+- <tt>\p{In_Block_Elements}</tt>
+- <tt>\p{In_Bopomofo}</tt>
+- <tt>\p{In_Bopomofo_Extended}</tt>
+- <tt>\p{In_Box_Drawing}</tt>
+- <tt>\p{In_Brahmi}</tt>
+- <tt>\p{In_Braille_Patterns}</tt>
+- <tt>\p{In_Buginese}</tt>
+- <tt>\p{In_Buhid}</tt>
+- <tt>\p{In_Byzantine_Musical_Symbols}</tt>
+- <tt>\p{In_CJK_Compatibility}</tt>
+- <tt>\p{In_CJK_Compatibility_Forms}</tt>
+- <tt>\p{In_CJK_Compatibility_Ideographs}</tt>
+- <tt>\p{In_CJK_Compatibility_Ideographs_Supplement}</tt>
+- <tt>\p{In_CJK_Radicals_Supplement}</tt>
+- <tt>\p{In_CJK_Strokes}</tt>
+- <tt>\p{In_CJK_Symbols_and_Punctuation}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_A}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_B}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_C}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_D}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_E}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_F}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_G}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_H}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_I}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_J}</tt>
+- <tt>\p{In_Carian}</tt>
+- <tt>\p{In_Caucasian_Albanian}</tt>
+- <tt>\p{In_Chakma}</tt>
+- <tt>\p{In_Cham}</tt>
+- <tt>\p{In_Cherokee}</tt>
+- <tt>\p{In_Cherokee_Supplement}</tt>
+- <tt>\p{In_Chess_Symbols}</tt>
+- <tt>\p{In_Chorasmian}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_Extended}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_Supplement}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_for_Symbols}</tt>
+- <tt>\p{In_Combining_Half_Marks}</tt>
+- <tt>\p{In_Common_Indic_Number_Forms}</tt>
+- <tt>\p{In_Control_Pictures}</tt>
+- <tt>\p{In_Coptic}</tt>
+- <tt>\p{In_Coptic_Epact_Numbers}</tt>
+- <tt>\p{In_Counting_Rod_Numerals}</tt>
+- <tt>\p{In_Cuneiform}</tt>
+- <tt>\p{In_Cuneiform_Numbers_and_Punctuation}</tt>
+- <tt>\p{In_Currency_Symbols}</tt>
+- <tt>\p{In_Cypriot_Syllabary}</tt>
+- <tt>\p{In_Cypro_Minoan}</tt>
+- <tt>\p{In_Cyrillic}</tt>
+- <tt>\p{In_Cyrillic_Extended_A}</tt>
+- <tt>\p{In_Cyrillic_Extended_B}</tt>
+- <tt>\p{In_Cyrillic_Extended_C}</tt>
+- <tt>\p{In_Cyrillic_Extended_D}</tt>
+- <tt>\p{In_Cyrillic_Supplement}</tt>
+- <tt>\p{In_Deseret}</tt>
+- <tt>\p{In_Devanagari}</tt>
+- <tt>\p{In_Devanagari_Extended}</tt>
+- <tt>\p{In_Devanagari_Extended_A}</tt>
+- <tt>\p{In_Dingbats}</tt>
+- <tt>\p{In_Dives_Akuru}</tt>
+- <tt>\p{In_Dogra}</tt>
+- <tt>\p{In_Domino_Tiles}</tt>
+- <tt>\p{In_Duployan}</tt>
+- <tt>\p{In_Early_Dynastic_Cuneiform}</tt>
+- <tt>\p{In_Egyptian_Hieroglyph_Format_Controls}</tt>
+- <tt>\p{In_Egyptian_Hieroglyphs}</tt>
+- <tt>\p{In_Egyptian_Hieroglyphs_Extended_A}</tt>
+- <tt>\p{In_Elbasan}</tt>
+- <tt>\p{In_Elymaic}</tt>
+- <tt>\p{In_Emoticons}</tt>
+- <tt>\p{In_Enclosed_Alphanumeric_Supplement}</tt>
+- <tt>\p{In_Enclosed_Alphanumerics}</tt>
+- <tt>\p{In_Enclosed_CJK_Letters_and_Months}</tt>
+- <tt>\p{In_Enclosed_Ideographic_Supplement}</tt>
+- <tt>\p{In_Ethiopic}</tt>
+- <tt>\p{In_Ethiopic_Extended}</tt>
+- <tt>\p{In_Ethiopic_Extended_A}</tt>
+- <tt>\p{In_Ethiopic_Extended_B}</tt>
+- <tt>\p{In_Ethiopic_Supplement}</tt>
+- <tt>\p{In_Garay}</tt>
+- <tt>\p{In_General_Punctuation}</tt>
+- <tt>\p{In_Geometric_Shapes}</tt>
+- <tt>\p{In_Geometric_Shapes_Extended}</tt>
+- <tt>\p{In_Georgian}</tt>
+- <tt>\p{In_Georgian_Extended}</tt>
+- <tt>\p{In_Georgian_Supplement}</tt>
+- <tt>\p{In_Glagolitic}</tt>
+- <tt>\p{In_Glagolitic_Supplement}</tt>
+- <tt>\p{In_Gothic}</tt>
+- <tt>\p{In_Grantha}</tt>
+- <tt>\p{In_Greek_Extended}</tt>
+- <tt>\p{In_Greek_and_Coptic}</tt>
+- <tt>\p{In_Gujarati}</tt>
+- <tt>\p{In_Gunjala_Gondi}</tt>
+- <tt>\p{In_Gurmukhi}</tt>
+- <tt>\p{In_Gurung_Khema}</tt>
+- <tt>\p{In_Halfwidth_and_Fullwidth_Forms}</tt>
+- <tt>\p{In_Hangul_Compatibility_Jamo}</tt>
+- <tt>\p{In_Hangul_Jamo}</tt>
+- <tt>\p{In_Hangul_Jamo_Extended_A}</tt>
+- <tt>\p{In_Hangul_Jamo_Extended_B}</tt>
+- <tt>\p{In_Hangul_Syllables}</tt>
+- <tt>\p{In_Hanifi_Rohingya}</tt>
+- <tt>\p{In_Hanunoo}</tt>
+- <tt>\p{In_Hatran}</tt>
+- <tt>\p{In_Hebrew}</tt>
+- <tt>\p{In_High_Private_Use_Surrogates}</tt>
+- <tt>\p{In_High_Surrogates}</tt>
+- <tt>\p{In_Hiragana}</tt>
+- <tt>\p{In_IPA_Extensions}</tt>
+- <tt>\p{In_Ideographic_Description_Characters}</tt>
+- <tt>\p{In_Ideographic_Symbols_and_Punctuation}</tt>
+- <tt>\p{In_Imperial_Aramaic}</tt>
+- <tt>\p{In_Indic_Siyaq_Numbers}</tt>
+- <tt>\p{In_Inscriptional_Pahlavi}</tt>
+- <tt>\p{In_Inscriptional_Parthian}</tt>
+- <tt>\p{In_Javanese}</tt>
+- <tt>\p{In_Kaithi}</tt>
+- <tt>\p{In_Kaktovik_Numerals}</tt>
+- <tt>\p{In_Kana_Extended_A}</tt>
+- <tt>\p{In_Kana_Extended_B}</tt>
+- <tt>\p{In_Kana_Supplement}</tt>
+- <tt>\p{In_Kanbun}</tt>
+- <tt>\p{In_Kangxi_Radicals}</tt>
+- <tt>\p{In_Kannada}</tt>
+- <tt>\p{In_Katakana}</tt>
+- <tt>\p{In_Katakana_Phonetic_Extensions}</tt>
+- <tt>\p{In_Kawi}</tt>
+- <tt>\p{In_Kayah_Li}</tt>
+- <tt>\p{In_Kharoshthi}</tt>
+- <tt>\p{In_Khitan_Small_Script}</tt>
+- <tt>\p{In_Khmer}</tt>
+- <tt>\p{In_Khmer_Symbols}</tt>
+- <tt>\p{In_Khojki}</tt>
+- <tt>\p{In_Khudawadi}</tt>
+- <tt>\p{In_Kirat_Rai}</tt>
+- <tt>\p{In_Lao}</tt>
+- <tt>\p{In_Latin_1_Supplement}</tt>
+- <tt>\p{In_Latin_Extended_A}</tt>
+- <tt>\p{In_Latin_Extended_Additional}</tt>
+- <tt>\p{In_Latin_Extended_B}</tt>
+- <tt>\p{In_Latin_Extended_C}</tt>
+- <tt>\p{In_Latin_Extended_D}</tt>
+- <tt>\p{In_Latin_Extended_E}</tt>
+- <tt>\p{In_Latin_Extended_F}</tt>
+- <tt>\p{In_Latin_Extended_G}</tt>
+- <tt>\p{In_Lepcha}</tt>
+- <tt>\p{In_Letterlike_Symbols}</tt>
+- <tt>\p{In_Limbu}</tt>
+- <tt>\p{In_Linear_A}</tt>
+- <tt>\p{In_Linear_B_Ideograms}</tt>
+- <tt>\p{In_Linear_B_Syllabary}</tt>
+- <tt>\p{In_Lisu}</tt>
+- <tt>\p{In_Lisu_Supplement}</tt>
+- <tt>\p{In_Low_Surrogates}</tt>
+- <tt>\p{In_Lycian}</tt>
+- <tt>\p{In_Lydian}</tt>
+- <tt>\p{In_Mahajani}</tt>
+- <tt>\p{In_Mahjong_Tiles}</tt>
+- <tt>\p{In_Makasar}</tt>
+- <tt>\p{In_Malayalam}</tt>
+- <tt>\p{In_Mandaic}</tt>
+- <tt>\p{In_Manichaean}</tt>
+- <tt>\p{In_Marchen}</tt>
+- <tt>\p{In_Masaram_Gondi}</tt>
+- <tt>\p{In_Mathematical_Alphanumeric_Symbols}</tt>
+- <tt>\p{In_Mathematical_Operators}</tt>
+- <tt>\p{In_Mayan_Numerals}</tt>
+- <tt>\p{In_Medefaidrin}</tt>
+- <tt>\p{In_Meetei_Mayek}</tt>
+- <tt>\p{In_Meetei_Mayek_Extensions}</tt>
+- <tt>\p{In_Mende_Kikakui}</tt>
+- <tt>\p{In_Meroitic_Cursive}</tt>
+- <tt>\p{In_Meroitic_Hieroglyphs}</tt>
+- <tt>\p{In_Miao}</tt>
+- <tt>\p{In_Miscellaneous_Mathematical_Symbols_A}</tt>
+- <tt>\p{In_Miscellaneous_Mathematical_Symbols_B}</tt>
+- <tt>\p{In_Miscellaneous_Symbols}</tt>
+- <tt>\p{In_Miscellaneous_Symbols_Supplement}</tt>
+- <tt>\p{In_Miscellaneous_Symbols_and_Arrows}</tt>
+- <tt>\p{In_Miscellaneous_Symbols_and_Pictographs}</tt>
+- <tt>\p{In_Miscellaneous_Technical}</tt>
+- <tt>\p{In_Modi}</tt>
+- <tt>\p{In_Modifier_Tone_Letters}</tt>
+- <tt>\p{In_Mongolian}</tt>
+- <tt>\p{In_Mongolian_Supplement}</tt>
+- <tt>\p{In_Mro}</tt>
+- <tt>\p{In_Multani}</tt>
+- <tt>\p{In_Musical_Symbols}</tt>
+- <tt>\p{In_Myanmar}</tt>
+- <tt>\p{In_Myanmar_Extended_A}</tt>
+- <tt>\p{In_Myanmar_Extended_B}</tt>
+- <tt>\p{In_Myanmar_Extended_C}</tt>
+- <tt>\p{In_NKo}</tt>
+- <tt>\p{In_Nabataean}</tt>
+- <tt>\p{In_Nag_Mundari}</tt>
+- <tt>\p{In_Nandinagari}</tt>
+- <tt>\p{In_New_Tai_Lue}</tt>
+- <tt>\p{In_Newa}</tt>
+- <tt>\p{In_No_Block}</tt>
+- <tt>\p{In_Number_Forms}</tt>
+- <tt>\p{In_Nushu}</tt>
+- <tt>\p{In_Nyiakeng_Puachue_Hmong}</tt>
+- <tt>\p{In_Ogham}</tt>
+- <tt>\p{In_Ol_Chiki}</tt>
+- <tt>\p{In_Ol_Onal}</tt>
+- <tt>\p{In_Old_Hungarian}</tt>
+- <tt>\p{In_Old_Italic}</tt>
+- <tt>\p{In_Old_North_Arabian}</tt>
+- <tt>\p{In_Old_Permic}</tt>
+- <tt>\p{In_Old_Persian}</tt>
+- <tt>\p{In_Old_Sogdian}</tt>
+- <tt>\p{In_Old_South_Arabian}</tt>
+- <tt>\p{In_Old_Turkic}</tt>
+- <tt>\p{In_Old_Uyghur}</tt>
+- <tt>\p{In_Optical_Character_Recognition}</tt>
+- <tt>\p{In_Oriya}</tt>
+- <tt>\p{In_Ornamental_Dingbats}</tt>
+- <tt>\p{In_Osage}</tt>
+- <tt>\p{In_Osmanya}</tt>
+- <tt>\p{In_Ottoman_Siyaq_Numbers}</tt>
+- <tt>\p{In_Pahawh_Hmong}</tt>
+- <tt>\p{In_Palmyrene}</tt>
+- <tt>\p{In_Pau_Cin_Hau}</tt>
+- <tt>\p{In_Phags_pa}</tt>
+- <tt>\p{In_Phaistos_Disc}</tt>
+- <tt>\p{In_Phoenician}</tt>
+- <tt>\p{In_Phonetic_Extensions}</tt>
+- <tt>\p{In_Phonetic_Extensions_Supplement}</tt>
+- <tt>\p{In_Playing_Cards}</tt>
+- <tt>\p{In_Private_Use_Area}</tt>
+- <tt>\p{In_Psalter_Pahlavi}</tt>
+- <tt>\p{In_Rejang}</tt>
+- <tt>\p{In_Rumi_Numeral_Symbols}</tt>
+- <tt>\p{In_Runic}</tt>
+- <tt>\p{In_Samaritan}</tt>
+- <tt>\p{In_Saurashtra}</tt>
+- <tt>\p{In_Sharada}</tt>
+- <tt>\p{In_Sharada_Supplement}</tt>
+- <tt>\p{In_Shavian}</tt>
+- <tt>\p{In_Shorthand_Format_Controls}</tt>
+- <tt>\p{In_Siddham}</tt>
+- <tt>\p{In_Sidetic}</tt>
+- <tt>\p{In_Sinhala}</tt>
+- <tt>\p{In_Sinhala_Archaic_Numbers}</tt>
+- <tt>\p{In_Small_Form_Variants}</tt>
+- <tt>\p{In_Small_Kana_Extension}</tt>
+- <tt>\p{In_Sogdian}</tt>
+- <tt>\p{In_Sora_Sompeng}</tt>
+- <tt>\p{In_Soyombo}</tt>
+- <tt>\p{In_Spacing_Modifier_Letters}</tt>
+- <tt>\p{In_Specials}</tt>
+- <tt>\p{In_Sundanese}</tt>
+- <tt>\p{In_Sundanese_Supplement}</tt>
+- <tt>\p{In_Sunuwar}</tt>
+- <tt>\p{In_Superscripts_and_Subscripts}</tt>
+- <tt>\p{In_Supplemental_Arrows_A}</tt>
+- <tt>\p{In_Supplemental_Arrows_B}</tt>
+- <tt>\p{In_Supplemental_Arrows_C}</tt>
+- <tt>\p{In_Supplemental_Mathematical_Operators}</tt>
+- <tt>\p{In_Supplemental_Punctuation}</tt>
+- <tt>\p{In_Supplemental_Symbols_and_Pictographs}</tt>
+- <tt>\p{In_Supplementary_Private_Use_Area_A}</tt>
+- <tt>\p{In_Supplementary_Private_Use_Area_B}</tt>
+- <tt>\p{In_Sutton_SignWriting}</tt>
+- <tt>\p{In_Syloti_Nagri}</tt>
+- <tt>\p{In_Symbols_and_Pictographs_Extended_A}</tt>
+- <tt>\p{In_Symbols_for_Legacy_Computing}</tt>
+- <tt>\p{In_Symbols_for_Legacy_Computing_Supplement}</tt>
+- <tt>\p{In_Syriac}</tt>
+- <tt>\p{In_Syriac_Supplement}</tt>
+- <tt>\p{In_Tagalog}</tt>
+- <tt>\p{In_Tagbanwa}</tt>
+- <tt>\p{In_Tags}</tt>
+- <tt>\p{In_Tai_Le}</tt>
+- <tt>\p{In_Tai_Tham}</tt>
+- <tt>\p{In_Tai_Viet}</tt>
+- <tt>\p{In_Tai_Xuan_Jing_Symbols}</tt>
+- <tt>\p{In_Tai_Yo}</tt>
+- <tt>\p{In_Takri}</tt>
+- <tt>\p{In_Tamil}</tt>
+- <tt>\p{In_Tamil_Supplement}</tt>
+- <tt>\p{In_Tangsa}</tt>
+- <tt>\p{In_Tangut}</tt>
+- <tt>\p{In_Tangut_Components}</tt>
+- <tt>\p{In_Tangut_Components_Supplement}</tt>
+- <tt>\p{In_Tangut_Supplement}</tt>
+- <tt>\p{In_Telugu}</tt>
+- <tt>\p{In_Thaana}</tt>
+- <tt>\p{In_Thai}</tt>
+- <tt>\p{In_Tibetan}</tt>
+- <tt>\p{In_Tifinagh}</tt>
+- <tt>\p{In_Tirhuta}</tt>
+- <tt>\p{In_Todhri}</tt>
+- <tt>\p{In_Tolong_Siki}</tt>
+- <tt>\p{In_Toto}</tt>
+- <tt>\p{In_Transport_and_Map_Symbols}</tt>
+- <tt>\p{In_Tulu_Tigalari}</tt>
+- <tt>\p{In_Ugaritic}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics_Extended}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics_Extended_A}</tt>
+- <tt>\p{In_Vai}</tt>
+- <tt>\p{In_Variation_Selectors}</tt>
+- <tt>\p{In_Variation_Selectors_Supplement}</tt>
+- <tt>\p{In_Vedic_Extensions}</tt>
+- <tt>\p{In_Vertical_Forms}</tt>
+- <tt>\p{In_Vithkuqi}</tt>
+- <tt>\p{In_Wancho}</tt>
+- <tt>\p{In_Warang_Citi}</tt>
+- <tt>\p{In_Yezidi}</tt>
+- <tt>\p{In_Yi_Radicals}</tt>
+- <tt>\p{In_Yi_Syllables}</tt>
+- <tt>\p{In_Yijing_Hexagram_Symbols}</tt>
+- <tt>\p{In_Zanabazar_Square}</tt>
+- <tt>\p{In_Znamenny_Musical_Notation}</tt>
+
+=== Emoji
+
+- <tt>\p{Emoji}</tt>
+- <tt>\p{Emoji_Component}</tt>, <tt>\p{EComp}</tt>
+- <tt>\p{Emoji_Modifier}</tt>, <tt>\p{EMod}</tt>
+- <tt>\p{Emoji_Modifier_Base}</tt>, <tt>\p{EBase}</tt>
+- <tt>\p{Emoji_Presentation}</tt>, <tt>\p{EPres}</tt>
+- <tt>\p{Extended_Pictographic}</tt>, <tt>\p{ExtPict}</tt>
+
+=== Graphemes
+
+- <tt>\p{Grapheme_Cluster_Break_CR}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Control}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Extend}</tt>
+- <tt>\p{Grapheme_Cluster_Break_L}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LF}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LV}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LVT}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Prepend}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Regional_Indicator}</tt>
+- <tt>\p{Grapheme_Cluster_Break_SpacingMark}</tt>
+- <tt>\p{Grapheme_Cluster_Break_T}</tt>
+- <tt>\p{Grapheme_Cluster_Break_V}</tt>
+- <tt>\p{Grapheme_Cluster_Break_ZWJ}</tt>
+
+=== Derived Ages
+
+- <tt>\p{Age_10_0}</tt>
+- <tt>\p{Age_11_0}</tt>
+- <tt>\p{Age_12_0}</tt>
+- <tt>\p{Age_12_1}</tt>
+- <tt>\p{Age_13_0}</tt>
+- <tt>\p{Age_14_0}</tt>
+- <tt>\p{Age_15_0}</tt>
+- <tt>\p{Age_15_1}</tt>
+- <tt>\p{Age_16_0}</tt>
+- <tt>\p{Age_17_0}</tt>
+- <tt>\p{Age_1_1}</tt>
+- <tt>\p{Age_2_0}</tt>
+- <tt>\p{Age_2_1}</tt>
+- <tt>\p{Age_3_0}</tt>
+- <tt>\p{Age_3_1}</tt>
+- <tt>\p{Age_3_2}</tt>
+- <tt>\p{Age_4_0}</tt>
+- <tt>\p{Age_4_1}</tt>
+- <tt>\p{Age_5_0}</tt>
+- <tt>\p{Age_5_1}</tt>
+- <tt>\p{Age_5_2}</tt>
+- <tt>\p{Age_6_0}</tt>
+- <tt>\p{Age_6_1}</tt>
+- <tt>\p{Age_6_2}</tt>
+- <tt>\p{Age_6_3}</tt>
+- <tt>\p{Age_7_0}</tt>
+- <tt>\p{Age_8_0}</tt>
+- <tt>\p{Age_9_0}</tt>
diff --git a/doc/language/signals.rdoc b/doc/language/signals.rdoc
new file mode 100644
index 0000000000..a82dab81c6
--- /dev/null
+++ b/doc/language/signals.rdoc
@@ -0,0 +1,106 @@
+= Caveats for implementing Signal.trap callbacks
+
+As with implementing signal handlers in C or most other languages,
+all code passed to Signal.trap must be reentrant. If you are not
+familiar with reentrancy, you need to read up on it at
+{Wikipedia}[https://en.wikipedia.org/wiki/Reentrancy_(computing)] or
+elsewhere before reading the rest of this document.
+
+Most importantly, "thread-safety" does not guarantee reentrancy;
+and methods such as Mutex#lock and Mutex#synchronize which are
+commonly used for thread-safety even prevent reentrancy.
+
+== An implementation detail of the Ruby VM
+
+The Ruby VM defers Signal.trap callbacks from running until it is safe
+for its internal data structures, but it does not know when it is safe
+for data structures in YOUR code. Ruby implements deferred signal
+handling by registering short C functions with only
+{async-signal-safe functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html] as
+signal handlers. These short C functions only do enough to tell the VM to
+run callbacks registered via Signal.trap later in the main Ruby Thread.
+
+== Unsafe methods to call in Signal.trap blocks
+
+When in doubt, consider anything not listed as safe below as being
+unsafe.
+
+* Mutex#lock, Mutex#synchronize and any code using them are explicitly
+ unsafe. This includes Monitor in the standard library which uses
+ Mutex to provide reentrancy.
+
+* Dir.chdir with block
+
+* any IO write operations when IO#sync is false;
+ including IO#write, IO#write_nonblock, IO#puts.
+ Pipes and sockets default to `IO#sync = true', so it is safe to
+ write to them unless IO#sync was disabled.
+
+* File#flock, as the underlying flock(2) call is not specified by POSIX
+
+== Commonly safe operations inside Signal.trap blocks
+
+* Assignment and retrieval of local, instance, and class variables
+
+* Most object allocations and initializations of common types
+ including Array, Hash, String, Struct, Time.
+
+* Common Array, Hash, String, Struct operations which do not execute a block
+ are generally safe; but beware if iteration is occurring elsewhere.
+
+* Hash#[], Hash#[]= (unless Hash.new was given an unsafe block)
+
+* Thread::Queue#push and Thread::SizedQueue#push (since Ruby 2.1)
+
+* Creating a new Thread via Thread.new/Thread.start can used to get
+ around the unusability of Mutexes inside a signal handler
+
+* Signal.trap is safe to use inside blocks passed to Signal.trap
+
+* arithmetic on Integer and Float (`+', `-', '%', '*', '/')
+
+ Additionally, signal handlers do not run between two successive
+ local variable accesses, so shortcuts such as `+=' and `-=' will
+ not trigger a data race when used on Integer and Float classes in
+ signal handlers.
+
+== System call wrapper methods which are safe inside Signal.trap
+
+Since Ruby has wrappers around many
+{async-signal-safe C functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html]
+the corresponding wrappers for many IO, File, Dir, and Socket methods
+are safe.
+
+(Incomplete list)
+
+* Dir.chdir (without block arg)
+* Dir.mkdir
+* Dir.open
+* File#truncate
+* File.link
+* File.open
+* File.readlink
+* File.rename
+* File.stat
+* File.symlink
+* File.truncate
+* File.unlink
+* File.utime
+* IO#close
+* IO#dup
+* IO#fsync
+* IO#read
+* IO#read_nonblock
+* IO#stat
+* IO#sysread
+* IO#syswrite
+* IO.select
+* IO.pipe
+* Process.clock_gettime
+* Process.exit!
+* Process.fork
+* Process.kill
+* Process.pid
+* Process.ppid
+* Process.waitpid
+...
diff --git a/doc/language/strftime_formatting.rdoc b/doc/language/strftime_formatting.rdoc
new file mode 100644
index 0000000000..2bfa6b975e
--- /dev/null
+++ b/doc/language/strftime_formatting.rdoc
@@ -0,0 +1,525 @@
+= Formats for Dates and Times
+
+Several Ruby time-related classes have instance method +strftime+,
+which returns a formatted string representing all or part of a date or time:
+
+- Date#strftime.
+- DateTime#strftime.
+- Time#strftime.
+
+Each of these methods takes optional argument +format+,
+which has zero or more embedded _format_ _specifications_ (see below).
+
+Each of these methods returns the string resulting from replacing each
+format specification embedded in +format+ with a string form
+of one or more parts of the date or time.
+
+A simple example:
+
+ Time.now.strftime('%H:%M:%S') # => "14:02:07"
+
+A format specification has the form:
+
+ %[flags][width]conversion
+
+It consists of:
+
+- A leading percent character.
+- Zero or more _flags_ (each is a character).
+- An optional _width_ _specifier_ (an integer).
+- A _conversion_ _specifier_ (a character).
+
+Except for the leading percent character,
+the only required part is the conversion specifier, so we begin with that.
+
+== Conversion Specifiers
+
+=== \Date (Year, Month, Day)
+
+- <tt>%Y</tt> - Year including century, zero-padded:
+
+ Time.now.strftime('%Y') # => "2022"
+ Time.new(-1000).strftime('%Y') # => "-1000" # Before common era.
+ Time.new(10000).strftime('%Y') # => "10000" # Far future.
+ Time.new(10).strftime('%Y') # => "0010" # Zero-padded by default.
+
+- <tt>%y</tt> - Year without century, in range (0.99), zero-padded:
+
+ Time.now.strftime('%y') # => "22"
+ Time.new(1).strftime('%y') # => "01" # Zero-padded by default.
+
+- <tt>%C</tt> - Century, zero-padded:
+
+ Time.now.strftime('%C') # => "20"
+ Time.new(-1000).strftime('%C') # => "-10" # Before common era.
+ Time.new(10000).strftime('%C') # => "100" # Far future.
+ Time.new(100).strftime('%C') # => "01" # Zero-padded by default.
+
+- <tt>%m</tt> - Month of the year, in range (1..12), zero-padded:
+
+ Time.new(2022, 1).strftime('%m') # => "01" # Zero-padded by default.
+ Time.new(2022, 12).strftime('%m') # => "12"
+
+- <tt>%B</tt> - Full month name, capitalized:
+
+ Time.new(2022, 1).strftime('%B') # => "January"
+ Time.new(2022, 12).strftime('%B') # => "December"
+
+- <tt>%b</tt> - Abbreviated month name, capitalized:
+
+ Time.new(2022, 1).strftime('%b') # => "Jan"
+ Time.new(2022, 12).strftime('%h') # => "Dec"
+
+- <tt>%h</tt> - Same as <tt>%b</tt>.
+
+- <tt>%d</tt> - Day of the month, in range (1..31), zero-padded:
+
+ Time.new(2002, 1, 1).strftime('%d') # => "01"
+ Time.new(2002, 1, 31).strftime('%d') # => "31"
+
+- <tt>%e</tt> - Day of the month, in range (1..31), blank-padded:
+
+ Time.new(2002, 1, 1).strftime('%e') # => " 1"
+ Time.new(2002, 1, 31).strftime('%e') # => "31"
+
+- <tt>%j</tt> - Day of the year, in range (1..366), zero-padded:
+
+ Time.new(2002, 1, 1).strftime('%j') # => "001"
+ Time.new(2002, 12, 31).strftime('%j') # => "365"
+
+=== \Time (Hour, Minute, Second, Subsecond)
+
+- <tt>%H</tt> - Hour of the day, in range (0..23), zero-padded:
+
+ Time.new(2022, 1, 1, 1).strftime('%H') # => "01"
+ Time.new(2022, 1, 1, 13).strftime('%H') # => "13"
+
+- <tt>%k</tt> - Hour of the day, in range (0..23), blank-padded:
+
+ Time.new(2022, 1, 1, 1).strftime('%k') # => " 1"
+ Time.new(2022, 1, 1, 13).strftime('%k') # => "13"
+
+- <tt>%I</tt> - Hour of the day, in range (1..12), zero-padded:
+
+ Time.new(2022, 1, 1, 1).strftime('%I') # => "01"
+ Time.new(2022, 1, 1, 13).strftime('%I') # => "01"
+
+- <tt>%l</tt> - Hour of the day, in range (1..12), blank-padded:
+
+ Time.new(2022, 1, 1, 1).strftime('%l') # => " 1"
+ Time.new(2022, 1, 1, 13).strftime('%l') # => " 1"
+
+- <tt>%P</tt> - Meridian indicator, lowercase:
+
+ Time.new(2022, 1, 1, 1).strftime('%P') # => "am"
+ Time.new(2022, 1, 1, 13).strftime('%P') # => "pm"
+
+- <tt>%p</tt> - Meridian indicator, uppercase:
+
+ Time.new(2022, 1, 1, 1).strftime('%p') # => "AM"
+ Time.new(2022, 1, 1, 13).strftime('%p') # => "PM"
+
+- <tt>%M</tt> - Minute of the hour, in range (0..59), zero-padded:
+
+ Time.new(2022, 1, 1, 1, 0, 0).strftime('%M') # => "00"
+
+- <tt>%S</tt> - Second of the minute in range (0..59), zero-padded:
+
+ Time.new(2022, 1, 1, 1, 0, 0, 0).strftime('%S') # => "00"
+
+- <tt>%L</tt> - Millisecond of the second, in range (0..999), zero-padded:
+
+ Time.new(2022, 1, 1, 1, 0, 0, 0).strftime('%L') # => "000"
+
+- <tt>%N</tt> - Fractional seconds, default width is 9 digits (nanoseconds):
+
+ t = Time.now # => 2022-06-29 07:10:20.3230914 -0500
+ t.strftime('%N') # => "323091400" # Default.
+
+ Use {width specifiers}[rdoc-ref:@Width+Specifiers]
+ to adjust units:
+
+ t.strftime('%3N') # => "323" # Milliseconds.
+ t.strftime('%6N') # => "323091" # Microseconds.
+ t.strftime('%9N') # => "323091400" # Nanoseconds.
+ t.strftime('%12N') # => "323091400000" # Picoseconds.
+ t.strftime('%15N') # => "323091400000000" # Femptoseconds.
+ t.strftime('%18N') # => "323091400000000000" # Attoseconds.
+ t.strftime('%21N') # => "323091400000000000000" # Zeptoseconds.
+ t.strftime('%24N') # => "323091400000000000000000" # Yoctoseconds.
+
+- <tt>%s</tt> - Number of seconds since the epoch:
+
+ Time.now.strftime('%s') # => "1656505136"
+
+=== Timezone
+
+- <tt>%z</tt> - Timezone as hour and minute offset from UTC:
+
+ Time.now.strftime('%z') # => "-0500"
+
+- <tt>%Z</tt> - Timezone name (platform-dependent):
+
+ Time.now.strftime('%Z') # => "Central Daylight Time"
+
+=== Weekday
+
+- <tt>%A</tt> - Full weekday name:
+
+ Time.now.strftime('%A') # => "Wednesday"
+
+- <tt>%a</tt> - Abbreviated weekday name:
+
+ Time.now.strftime('%a') # => "Wed"
+
+- <tt>%u</tt> - Day of the week, in range (1..7), Monday is 1:
+
+ t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
+ t.strftime('%a') # => "Sun"
+ t.strftime('%u') # => "7"
+
+- <tt>%w</tt> - Day of the week, in range (0..6), Sunday is 0:
+
+ t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
+ t.strftime('%a') # => "Sun"
+ t.strftime('%w') # => "0"
+
+=== Week Number
+
+- <tt>%U</tt> - Week number of the year, in range (0..53), zero-padded,
+ where each week begins on a Sunday:
+
+ t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
+ t.strftime('%a') # => "Sun"
+ t.strftime('%U') # => "26"
+
+- <tt>%W</tt> - Week number of the year, in range (0..53), zero-padded,
+ where each week begins on a Monday:
+
+ t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
+ t.strftime('%a') # => "Sun"
+ t.strftime('%W') # => "25"
+
+=== Week Dates
+
+See {ISO 8601 week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates].
+
+ t0 = Time.new(2023, 1, 1) # => 2023-01-01 00:00:00 -0600
+ t1 = Time.new(2024, 1, 1) # => 2024-01-01 00:00:00 -0600
+
+- <tt>%G</tt> - Week-based year:
+
+ t0.strftime('%G') # => "2022"
+ t1.strftime('%G') # => "2024"
+
+- <tt>%g</tt> - Week-based year without century, in range (0..99), zero-padded:
+
+ t0.strftime('%g') # => "22"
+ t1.strftime('%g') # => "24"
+
+- <tt>%V</tt> - Week number of the week-based year, in range (1..53),
+ zero-padded:
+
+ t0.strftime('%V') # => "52"
+ t1.strftime('%V') # => "01"
+
+=== Literals
+
+- <tt>%n</tt> - Newline character "\n":
+
+ Time.now.strftime('%n') # => "\n"
+
+- <tt>%t</tt> - Tab character "\t":
+
+ Time.now.strftime('%t') # => "\t"
+
+- <tt>%%</tt> - Percent character '%':
+
+ Time.now.strftime('%%') # => "%"
+
+=== Shorthand Conversion Specifiers
+
+Each shorthand specifier here is shown with its corresponding
+longhand specifier.
+
+- <tt>%c</tt> - \Date and time:
+
+ Time.now.strftime('%c') # => "Wed Jun 29 08:01:41 2022"
+ Time.now.strftime('%a %b %e %T %Y') # => "Wed Jun 29 08:02:07 2022"
+
+- <tt>%D</tt> - \Date:
+
+ Time.now.strftime('%D') # => "06/29/22"
+ Time.now.strftime('%m/%d/%y') # => "06/29/22"
+
+- <tt>%F</tt> - ISO 8601 date:
+
+ Time.now.strftime('%F') # => "2022-06-29"
+ Time.now.strftime('%Y-%m-%d') # => "2022-06-29"
+
+- <tt>%v</tt> - VMS date:
+
+ Time.now.strftime('%v') # => "29-JUN-2022"
+ Time.now.strftime('%e-%^b-%4Y') # => "29-JUN-2022"
+
+- <tt>%x</tt> - Same as <tt>%D</tt>.
+
+- <tt>%X</tt> - Same as <tt>%T</tt>.
+
+- <tt>%r</tt> - 12-hour time:
+
+ Time.new(2022, 1, 1, 1).strftime('%r') # => "01:00:00 AM"
+ Time.new(2022, 1, 1, 1).strftime('%I:%M:%S %p') # => "01:00:00 AM"
+ Time.new(2022, 1, 1, 13).strftime('%r') # => "01:00:00 PM"
+ Time.new(2022, 1, 1, 13).strftime('%I:%M:%S %p') # => "01:00:00 PM"
+
+- <tt>%R</tt> - 24-hour time:
+
+ Time.new(2022, 1, 1, 1).strftime('%R') # => "01:00"
+ Time.new(2022, 1, 1, 1).strftime('%H:%M') # => "01:00"
+ Time.new(2022, 1, 1, 13).strftime('%R') # => "13:00"
+ Time.new(2022, 1, 1, 13).strftime('%H:%M') # => "13:00"
+
+- <tt>%T</tt> - 24-hour time:
+
+ Time.new(2022, 1, 1, 1).strftime('%T') # => "01:00:00"
+ Time.new(2022, 1, 1, 1).strftime('%H:%M:%S') # => "01:00:00"
+ Time.new(2022, 1, 1, 13).strftime('%T') # => "13:00:00"
+ Time.new(2022, 1, 1, 13).strftime('%H:%M:%S') # => "13:00:00"
+
+- <tt>%+</tt> (not supported in Time#strftime) - \Date and time:
+
+ DateTime.now.strftime('%+')
+ # => "Wed Jun 29 08:31:53 -05:00 2022"
+ DateTime.now.strftime('%a %b %e %H:%M:%S %Z %Y')
+ # => "Wed Jun 29 08:32:18 -05:00 2022"
+
+== Flags
+
+Flags may affect certain formatting specifications.
+
+Multiple flags may be given with a single conversion specified;
+order does not matter.
+
+=== Padding Flags
+
+- <tt>0</tt> - Pad with zeroes:
+
+ Time.new(10).strftime('%0Y') # => "0010"
+
+- <tt>_</tt> - Pad with blanks:
+
+ Time.new(10).strftime('%_Y') # => " 10"
+
+- <tt>-</tt> - Don't pad:
+
+ Time.new(10).strftime('%-Y') # => "10"
+
+=== Casing Flags
+
+- <tt>^</tt> - Upcase result:
+
+ Time.new(2022, 1).strftime('%B') # => "January" # No casing flag.
+ Time.new(2022, 1).strftime('%^B') # => "JANUARY"
+
+- <tt>#</tt> - Swapcase result:
+
+ Time.now.strftime('%p') # => "AM"
+ Time.now.strftime('%^p') # => "AM"
+ Time.now.strftime('%#p') # => "am"
+
+=== Timezone Flags
+
+- <tt>:</tt> - Put timezone as colon-separated hours and minutes:
+
+ Time.now.strftime('%:z') # => "-05:00"
+
+- <tt>::</tt> - Put timezone as colon-separated hours, minutes, and seconds:
+
+ Time.now.strftime('%::z') # => "-05:00:00"
+
+== Width Specifiers
+
+The integer width specifier gives a minimum width for the returned string:
+
+ Time.new(2002).strftime('%Y') # => "2002" # No width specifier.
+ Time.new(2002).strftime('%10Y') # => "0000002002"
+ Time.new(2002, 12).strftime('%B') # => "December" # No width specifier.
+ Time.new(2002, 12).strftime('%10B') # => " December"
+ Time.new(2002, 12).strftime('%3B') # => "December" # Ignored if too small.
+
+= Specialized Format Strings
+
+Here are a few specialized format strings,
+each based on an external standard.
+
+== HTTP Format
+
+The HTTP date format is based on
+{RFC 2616}[https://www.rfc-editor.org/rfc/rfc2616],
+and treats dates in the format <tt>'%a, %d %b %Y %T GMT'</tt>:
+
+ d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
+ # Return HTTP-formatted string.
+ httpdate = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
+ # Return new date parsed from HTTP-formatted string.
+ Date.httpdate(httpdate) # => #<Date: 2001-02-03>
+ # Return hash parsed from HTTP-formatted string.
+ Date._httpdate(httpdate)
+ # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
+
+== RFC 3339 Format
+
+The RFC 3339 date format is based on
+{RFC 3339}[https://www.rfc-editor.org/rfc/rfc3339]:
+
+ d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
+ # Return 3339-formatted string.
+ rfc3339 = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
+ # Return new date parsed from 3339-formatted string.
+ Date.rfc3339(rfc3339) # => #<Date: 2001-02-03>
+ # Return hash parsed from 3339-formatted string.
+ Date._rfc3339(rfc3339)
+ # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
+
+== RFC 2822 Format
+
+The RFC 2822 date format is based on
+{RFC 2822}[https://www.rfc-editor.org/rfc/rfc2822],
+and treats dates in the format <tt>'%a, %-d %b %Y %T %z'</tt>]:
+
+ d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
+ # Return 2822-formatted string.
+ rfc2822 = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
+ # Return new date parsed from 2822-formatted string.
+ Date.rfc2822(rfc2822) # => #<Date: 2001-02-03>
+ # Return hash parsed from 2822-formatted string.
+ Date._rfc2822(rfc2822)
+ # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
+
+== JIS X 0301 Format
+
+The JIS X 0301 format includes the
+{Japanese era name}[https://en.wikipedia.org/wiki/Japanese_era_name],
+and treats dates in the format <tt>'%Y-%m-%d'</tt>
+with the first letter of the romanized era name prefixed:
+
+ d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
+ # Return 0301-formatted string.
+ jisx0301 = d.jisx0301 # => "H13.02.03"
+ # Return new date parsed from 0301-formatted string.
+ Date.jisx0301(jisx0301) # => #<Date: 2001-02-03>
+ # Return hash parsed from 0301-formatted string.
+ Date._jisx0301(jisx0301) # => {:year=>2001, :mon=>2, :mday=>3}
+
+== ISO 8601 Format Specifications
+
+This section shows format specifications that are compatible with
+{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601].
+Details for various formats may be seen at the links.
+
+Examples in this section assume:
+
+ t = Time.now # => 2022-06-29 16:49:25.465246 -0500
+
+=== Dates
+
+See {ISO 8601 dates}[https://en.wikipedia.org/wiki/ISO_8601#Dates].
+
+- {Years}[https://en.wikipedia.org/wiki/ISO_8601#Years]:
+
+ - Basic year (+YYYY+):
+
+ t.strftime('%Y') # => "2022"
+
+ - Expanded year (<tt>±YYYYY</tt>):
+
+ t.strftime('+%5Y') # => "+02022"
+ t.strftime('-%5Y') # => "-02022"
+
+- {Calendar dates}[https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates]:
+
+ - Basic date (+YYYYMMDD+):
+
+ t.strftime('%Y%m%d') # => "20220629"
+
+ - Extended date (<tt>YYYY-MM-DD</tt>):
+
+ t.strftime('%Y-%m-%d') # => "2022-06-29"
+
+ - Reduced extended date (<tt>YYYY-MM</tt>):
+
+ t.strftime('%Y-%m') # => "2022-06"
+
+- {Week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates]:
+
+ - Basic date (+YYYYWww+ or +YYYYWwwD+):
+
+ t.strftime('%Y%Ww') # => "202226w"
+ t.strftime('%Y%Ww%u') # => "202226w3"
+
+ - Extended date (<tt>YYYY-Www</tt> or <tt>YYYY-Www-D<tt>):
+
+ t.strftime('%Y-%Ww') # => "2022-26w"
+ t.strftime('%Y-%Ww-%u') # => "2022-26w-3"
+
+- {Ordinal dates}[https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates]:
+
+ - Basic date (+YYYYDDD+):
+
+ t.strftime('%Y%j') # => "2022180"
+
+ - Extended date (<tt>YYYY-DDD</tt>):
+
+ t.strftime('%Y-%j') # => "2022-180"
+
+=== Times
+
+See {ISO 8601 times}[https://en.wikipedia.org/wiki/ISO_8601#Times].
+
+- Times:
+
+ - Basic time (+Thhmmss.sss+, +Thhmmss+, +Thhmm+, or +Thh+):
+
+ t.strftime('T%H%M%S.%L') # => "T164925.465"
+ t.strftime('T%H%M%S') # => "T164925"
+ t.strftime('T%H%M') # => "T1649"
+ t.strftime('T%H') # => "T16"
+
+ - Extended time (+Thh:mm:ss.sss+, +Thh:mm:ss+, or +Thh:mm+):
+
+ t.strftime('T%H:%M:%S.%L') # => "T16:49:25.465"
+ t.strftime('T%H:%M:%S') # => "T16:49:25"
+ t.strftime('T%H:%M') # => "T16:49"
+
+- {Time zone designators}[https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators]:
+
+ - Timezone (+time+ represents a valid time,
+ +hh+ represents a valid 2-digit hour,
+ and +mm+ represents a valid 2-digit minute):
+
+ - Basic timezone (<tt>time±hhmm</tt>, <tt>time±hh</tt>, or +timeZ+):
+
+ t.strftime('T%H%M%S%z') # => "T164925-0500"
+ t.strftime('T%H%M%S%z').slice(0..-3) # => "T164925-05"
+ t.strftime('T%H%M%SZ') # => "T164925Z"
+
+ - Extended timezone (<tt>time±hh:mm</tt>):
+
+ t.strftime('T%H:%M:%S%z') # => "T16:49:25-0500"
+
+ - See also:
+
+ - {Local time (unqualified)}[https://en.wikipedia.org/wiki/ISO_8601#Local_time_(unqualified)].
+ - {Coordinated Universal Time (UTC)}[https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_(UTC)].
+ - {Time offsets from UTC}[https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC].
+
+=== Combined \Date and \Time
+
+See {ISO 8601 Combined date and time representations}[https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations].
+
+An ISO 8601 combined date and time representation may be any
+ISO 8601 date and any ISO 8601 time,
+separated by the letter +T+.
+
+For the relevant +strftime+ formats, see {Dates}[rdoc-ref:@Dates] and {Times}[rdoc-ref:@Times] above.
diff --git a/doc/maintainers.md b/doc/maintainers.md
index 970b09dc02..e87ccaca05 100644
--- a/doc/maintainers.md
+++ b/doc/maintainers.md
@@ -1,7 +1,16 @@
# Maintainers
-This page describes the current module, library, and extension maintainers of Ruby.
+
+This page describes the current branch, module, library, and extension maintainers of Ruby.
+
+## Branch Maintainers
+
+A branch maintainer is responsible for backporting commits into stable branches
+and publishing Ruby patch releases.
+
+[The list of current branch maintainers is available in the wiki](https://github.com/ruby/ruby/wiki/Release-Engineering).
## Module Maintainers
+
A module maintainer is responsible for a certain part of Ruby.
* The maintainer fixes bugs of the part. Particularly, they should fix
@@ -19,508 +28,695 @@ not have authority to change/add a feature on his/her part. They need
consensus on ruby-core/ruby-dev before changing/adding. Some of submaintainers
have commit right, others don't.
+No maintainer means that there is no specific maintainer for the part now.
+The member of ruby core team can fix issues at anytime. But major changes need
+consensus on ruby-core/ruby-dev.
+
### Language core features including security
-* Yukihiro Matsumoto (matz)
+
+* Yukihiro Matsumoto ([matz])
### Evaluator
-* Koichi Sasada (ko1)
+
+* Koichi Sasada ([ko1])
### Core classes
-* Yukihiro Matsumoto (matz)
-## Standard Library Maintainers
-### Libraries
+* Yukihiro Matsumoto ([matz])
+
+### Standard Library Maintainers
+
#### lib/mkmf.rb
-* *unmaintained*
+
+* *No maintainer*
+
+#### pathname_builtin.rb, lib/pathname.rb
+
+* Tanaka Akira ([akr])
#### lib/rubygems.rb, lib/rubygems/*
-* Eric Hodel (drbrain)
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/rubygems/rubygems
+
+* Hiroshi SHIBATA ([hsbt])
+* https://github.com/ruby/rubygems
#### lib/unicode_normalize.rb, lib/unicode_normalize/*
-* Martin J. Dürst
-### Extensions
+* Martin J. Dürst ([duerst])
+
+### Standard Library(Extensions) Maintainers
+
+#### set.c
+
+* Akinori MUSHA ([knu])
+
#### ext/continuation
-* Koichi Sasada (ko1)
+
+* Koichi Sasada ([ko1])
#### ext/coverage
-* Yusuke Endoh (mame)
+
+* Yusuke Endoh ([mame])
#### ext/fiber
-* Koichi Sasada (ko1)
+
+* Koichi Sasada ([ko1])
#### ext/monitor
-* Koichi Sasada (ko1)
+
+* Koichi Sasada ([ko1])
#### ext/objspace
-* *unmaintained*
+
+* *No maintainer*
+
+#### ext/pathname
+
+* Tanaka Akira ([akr])
#### ext/pty
-* *unmaintained*
+
+* *No maintainer*
#### ext/ripper
-* *unmaintained*
+
+* *No maintainer*
#### ext/socket
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* API change needs matz's approval
#### ext/win32
-* NAKAMURA Usaku (usa)
-## Default gems Maintainers
-### Libraries
-#### lib/abbrev.rb
-* Akinori MUSHA (knu)
-* https://github.com/ruby/abbrev
-* https://rubygems.org/gems/abbrev
+* NAKAMURA Usaku ([unak])
-#### lib/base64.rb
-* Yusuke Endoh (mame)
-* https://github.com/ruby/base64
-* https://rubygems.org/gems/base64
-
-#### lib/benchmark.rb
-* *unmaintained*
-* https://github.com/ruby/benchmark
-* https://rubygems.org/gems/benchmark
+### Default gems(Libraries) Maintainers
#### lib/bundler.rb, lib/bundler/*
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/rubygems/rubygems
+
+* Hiroshi SHIBATA ([hsbt])
+* https://github.com/ruby/rubygems
* https://rubygems.org/gems/bundler
-#### lib/cgi.rb, lib/cgi/*
-* *unmaintained*
-* https://github.com/ruby/cgi
-* https://rubygems.org/gems/cgi
+#### lib/cgi/escape.rb
-#### lib/csv.rb
-* Kenta Murata (mrkn)
-* Kouhei Sutou (kou)
-* https://github.com/ruby/csv
-* https://rubygems.org/gems/csv
+* *No maintainer*
#### lib/English.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/English
* https://rubygems.org/gems/English
#### lib/delegate.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/delegate
* https://rubygems.org/gems/delegate
#### lib/did_you_mean.rb
-* Yuki Nishijima (yuki24)
+
+* Yuki Nishijima ([yuki24])
* https://github.com/ruby/did_you_mean
* https://rubygems.org/gems/did_you_mean
#### ext/digest, ext/digest/*
-* Akinori MUSHA (knu)
+
+* Akinori MUSHA ([knu])
* https://github.com/ruby/digest
* https://rubygems.org/gems/digest
-#### lib/drb.rb, lib/drb/*
-* Masatoshi SEKI (seki)
-* https://github.com/ruby/drb
-* https://rubygems.org/gems/drb
-
#### lib/erb.rb
-* Masatoshi SEKI (seki)
-* Takashi Kokubun (k0kubun)
+
+* Masatoshi SEKI ([seki])
+* Takashi Kokubun ([k0kubun])
* https://github.com/ruby/erb
* https://rubygems.org/gems/erb
#### lib/error_highlight.rb, lib/error_highlight/*
-* Yusuke Endoh (mame)
+
+* Yusuke Endoh ([mame])
* https://github.com/ruby/error_highlight
* https://rubygems.org/gems/error_highlight
#### lib/fileutils.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/fileutils
* https://rubygems.org/gems/fileutils
#### lib/find.rb
-* Kazuki Tsujimoto (ktsj)
+
+* Kazuki Tsujimoto ([k-tsj])
* https://github.com/ruby/find
* https://rubygems.org/gems/find
#### lib/forwardable.rb
-* Keiju ISHITSUKA (keiju)
+
+* Keiju ISHITSUKA ([keiju])
* https://github.com/ruby/forwardable
* https://rubygems.org/gems/forwardable
-#### lib/getoptlong.rb
-* *unmaintained*
-* https://github.com/ruby/getoptlong
-* https://rubygems.org/gems/getoptlong
-
#### lib/ipaddr.rb
-* Akinori MUSHA (knu)
+
+* Akinori MUSHA ([knu])
* https://github.com/ruby/ipaddr
* https://rubygems.org/gems/ipaddr
-#### lib/irb.rb, lib/irb/*
-* aycabta
-* https://github.com/ruby/irb
-* https://rubygems.org/gems/irb
-
#### lib/optparse.rb, lib/optparse/*
-* Nobuyuki Nakada (nobu)
-* https://github.com/ruby/optparse
-#### lib/logger.rb
-* Naotoshi Seo (sonots)
-* https://github.com/ruby/logger
-* https://rubygems.org/gems/logger
-
-#### lib/mutex_m.rb
-* Keiju ISHITSUKA (keiju)
-* https://github.com/ruby/mutex_m
-* https://rubygems.org/gems/mutex_m
+* Nobuyuki Nakada ([nobu])
+* https://github.com/ruby/optparse
+* https://rubygems.org/gems/optparse
#### lib/net/http.rb, lib/net/https.rb
-* NARUSE, Yui (naruse)
+
+* NARUSE, Yui ([nurse])
* https://github.com/ruby/net-http
* https://rubygems.org/gems/net-http
#### lib/net/protocol.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/net-protocol
* https://rubygems.org/gems/net-protocol
-#### lib/observer.rb
-* *unmaintained*
-* https://github.com/ruby/observer
-* https://rubygems.org/gems/observer
-
#### lib/open3.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/open3
* https://rubygems.org/gems/open3
#### lib/open-uri.rb
-* Tanaka Akira (akr)
-* https://github.com/ruby/open-uri
-#### lib/ostruct.rb
-* Marc-André Lafortune (marcandre)
-* https://github.com/ruby/ostruct
-* https://rubygems.org/gems/ostruct
+* Tanaka Akira ([akr])
+* https://github.com/ruby/open-uri
+* https://rubygems.org/gems/open-uri
#### lib/pp.rb
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* https://github.com/ruby/pp
* https://rubygems.org/gems/pp
#### lib/prettyprint.rb
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* https://github.com/ruby/prettyprint
* https://rubygems.org/gems/prettyprint
-#### lib/pstore.rb
-* *unmaintained*
-* https://github.com/ruby/pstore
-* https://rubygems.org/gems/pstore
-
-#### lib/racc.rb, lib/racc/*
-* Aaron Patterson (tenderlove)
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/ruby/racc
-* https://rubygems.org/gems/racc
+#### lib/prism.rb
-#### lib/readline.rb
-* aycabta
-* https://github.com/ruby/readline
-* https://rubygems.org/gems/readline
+* Kevin Newton ([kddnewton])
+* Eileen Uchitelle ([eileencodes])
+* Aaron Patterson ([tenderlove])
+* Earlopain ([earlopain])
+* https://github.com/ruby/prism
+* https://rubygems.org/gems/prism
#### lib/resolv.rb
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* https://github.com/ruby/resolv
* https://rubygems.org/gems/resolv
-#### lib/resolv-replace.rb
-* Tanaka Akira (akr)
-* https://github.com/ruby/resolv-replace
-* https://rubygems.org/gems/resolv-replace
-
-#### lib/rdoc.rb, lib/rdoc/*
-* Eric Hodel (drbrain)
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/ruby/rdoc
-* https://rubygems.org/gems/rdoc
-
-#### lib/readline.rb
-* aycabta
-* https://github.com/ruby/readline
-* https://rubygems.org/gems/readline
-
-#### lib/reline.rb, lib/reline/*
-* aycabta
-* https://github.com/ruby/reline
-* https://rubygems.org/gems/reline
-
-#### lib/rinda/*
-* Masatoshi SEKI (seki)
-* https://github.com/ruby/rinda
-* https://rubygems.org/gems/rinda
-
#### lib/securerandom.rb
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* https://github.com/ruby/securerandom
* https://rubygems.org/gems/securerandom
-#### lib/set.rb
-* Akinori MUSHA (knu)
-* https://github.com/ruby/set
-* https://rubygems.org/gems/set
-
#### lib/shellwords.rb
-* Akinori MUSHA (knu)
+
+* Akinori MUSHA ([knu])
* https://github.com/ruby/shellwords
* https://rubygems.org/gems/shellwords
#### lib/singleton.rb
-* Yukihiro Matsumoto (matz)
+
+* Yukihiro Matsumoto ([matz])
* https://github.com/ruby/singleton
* https://rubygems.org/gems/singleton
#### lib/tempfile.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/tempfile
* https://rubygems.org/gems/tempfile
#### lib/time.rb
-* Tanaka Akira (akr)
+
+* Tanaka Akira ([akr])
* https://github.com/ruby/time
* https://rubygems.org/gems/time
#### lib/timeout.rb
-* Yukihiro Matsumoto (matz)
+
+* Yukihiro Matsumoto ([matz])
* https://github.com/ruby/timeout
* https://rubygems.org/gems/timeout
-#### lib/thwait.rb
-* Keiju ISHITSUKA (keiju)
-* https://github.com/ruby/thwait
-* https://rubygems.org/gems/thwait
-
#### lib/tmpdir.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/tmpdir
* https://rubygems.org/gems/tmpdir
-#### lib/tsort.rb
-* Tanaka Akira (akr)
-* https://github.com/ruby/tsort
-* https://rubygems.org/gems/tsort
-
#### lib/un.rb
-* WATANABE Hirofumi (eban)
+
+* WATANABE Hirofumi ([eban])
* https://github.com/ruby/un
* https://rubygems.org/gems/un
#### lib/uri.rb, lib/uri/*
-* YAMADA, Akira (akira)
+
+* NARUSE, Yui ([nurse])
* https://github.com/ruby/uri
* https://rubygems.org/gems/uri
#### lib/yaml.rb, lib/yaml/*
-* Aaron Patterson (tenderlove)
-* Hiroshi SHIBATA (hsbt)
+
+* Aaron Patterson ([tenderlove])
+* Hiroshi SHIBATA ([hsbt])
* https://github.com/ruby/yaml
* https://rubygems.org/gems/yaml
#### lib/weakref.rb
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/weakref
* https://rubygems.org/gems/weakref
-### Extensions
-#### ext/bigdecimal
-* Kenta Murata (mrkn) https://github.com/ruby/bigdecimal
-* https://rubygems.org/gems/bigdecimal
+### Default gems(Extensions) Maintainers
#### ext/cgi
-* Nobuyoshi Nakada (nobu)
-* https://github.com/ruby/cgi
-* https://rubygems.org/gems/cgi
+
+* Nobuyoshi Nakada ([nobu])
#### ext/date
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/date
* https://rubygems.org/gems/date
#### ext/etc
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/etc
* https://rubygems.org/gems/etc
#### ext/fcntl
-* *unmaintained*
+
+* *No maintainer*
* https://github.com/ruby/fcntl
* https://rubygems.org/gems/fcntl
-#### ext/fiddle
-* Aaron Patterson (tenderlove)
-* https://github.com/ruby/fiddle
-* https://rubygems.org/gems/fiddle
-
#### ext/io/console
-* Nobuyuki Nakada (nobu)
+
+* Nobuyuki Nakada ([nobu])
* https://github.com/ruby/io-console
* https://rubygems.org/gems/io-console
#### ext/io/nonblock
-* Nobuyuki Nakada (nobu)
+
+* Nobuyuki Nakada ([nobu])
* https://github.com/ruby/io-nonblock
* https://rubygems.org/gems/io-nonblock
#### ext/io/wait
-* Nobuyuki Nakada (nobu)
+
+* Nobuyuki Nakada ([nobu])
* https://github.com/ruby/io-wait
* https://rubygems.org/gems/io-wait
#### ext/json
-* NARUSE, Yui (naruse)
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/flori/json
-* https://rubygems.org/gems/json
-#### ext/nkf
-* NARUSE, Yui (naruse)
-* https://github.com/ruby/nkf
-* https://rubygems.org/gems/nkf
+* NARUSE, Yui ([nurse])
+* Hiroshi SHIBATA ([hsbt])
+* Jean Boussier ([byroot])
+* https://github.com/ruby/json
+* https://rubygems.org/gems/json
#### ext/openssl
-* Kazuki Yamaguchi (rhe)
+
+* Kazuki Yamaguchi ([rhenium])
* https://github.com/ruby/openssl
* https://rubygems.org/gems/openssl
-#### ext/pathname
-* Tanaka Akira (akr)
-* https://github.com/ruby/pathname
-* https://rubygems.org/gems/pathname
-
#### ext/psych
-* Aaron Patterson (tenderlove)
-* Hiroshi SHIBATA (hsbt)
+
+* Aaron Patterson ([tenderlove])
+* Hiroshi SHIBATA ([hsbt])
* https://github.com/ruby/psych
* https://rubygems.org/gems/psych
-#### ext/racc
-* Aaron Patterson (tenderlove)
-* Hiroshi SHIBATA (hsbt)
-* https://github.com/ruby/racc
-* https://rubygems.org/gems/racc
-
-#### ext/readline
-* TAKAO Kouji (kouji)
-* https://github.com/ruby/readline-ext
-* https://rubygems.org/gems/readline-ext
-
#### ext/stringio
-* Nobuyuki Nakada (nobu)
+
+* Nobuyuki Nakada ([nobu])
* https://github.com/ruby/stringio
* https://rubygems.org/gems/stringio
#### ext/strscan
-* Kouhei Sutou (kou)
+
+* Kouhei Sutou ([kou])
* https://github.com/ruby/strscan
* https://rubygems.org/gems/strscan
-#### ext/syslog
-* Akinori MUSHA (knu)
-* https://github.com/ruby/syslog
-* https://rubygems.org/gems/syslog
-
-#### ext/win32ole
-* Masaki Suketa (suke)
-* https://github.com/ruby/win32ole
-* https://rubygems.org/gems/win32ole
-
#### ext/zlib
-* NARUSE, Yui (naruse)
+
+* NARUSE, Yui ([nurse])
* https://github.com/ruby/zlib
* https://rubygems.org/gems/zlib
-## Bundled gems upstream repositories
+## Bundled gems upstream repositories and maintainers
+
+The maintanance policy of bundled gems is different from Module Maintainers above.
+Please check the policies for each repository.
+
+The ruby core team tries to maintain the repositories with no maintainers.
+It may needs to make consensus on ruby-core/ruby-dev before making major changes.
+
### minitest
-* https://github.com/seattlerb/minitest
+
+* Ryan Davis ([zenspider])
+* https://github.com/minitest/minitest
+* https://rubygems.org/gems/minitest
### power_assert
+
+* Tsujimoto Kenta ([k-tsj])
* https://github.com/ruby/power_assert
+* https://rubygems.org/gems/power_assert
### rake
+
+* Hiroshi SHIBATA ([hsbt])
* https://github.com/ruby/rake
+* https://rubygems.org/gems/rake
### test-unit
+
+* Kouhei Sutou ([kou])
* https://github.com/test-unit/test-unit
+* https://rubygems.org/gems/test-unit
### rexml
+
+* Kouhei Sutou ([kou])
* https://github.com/ruby/rexml
+* https://rubygems.org/gems/rexml
### rss
-* https://github.com/ruby/rss
-### net-ftp
-* https://github.com/ruby/net-ftp
+* Kouhei Sutou ([kou])
+* https://github.com/ruby/rss
+* https://rubygems.org/gems/rss
### net-imap
-* https://github.com/ruby/net-imap
-### net-pop
-* https://github.com/ruby/net-pop
+* Nicholas A. Evans ([nevans])
+* https://github.com/ruby/net-imap
+* https://rubygems.org/gems/net-imap
### net-smtp
+
+* TOMITA Masahiro ([tmtm])
* https://github.com/ruby/net-smtp
+* https://rubygems.org/gems/net-smtp
### matrix
+
+* Marc-André Lafortune ([marcandre])
* https://github.com/ruby/matrix
+* https://rubygems.org/gems/matrix
### prime
+
* https://github.com/ruby/prime
+* https://rubygems.org/gems/prime
### rbs
+
+* Soutaro Matsumoto ([soutaro])
* https://github.com/ruby/rbs
+* https://rubygems.org/gems/rbs
### typeprof
+
+* Yusuke Endoh ([mame])
* https://github.com/ruby/typeprof
+* https://rubygems.org/gems/typeprof
### debug
+
+* Koichi Sasada ([ko1])
* https://github.com/ruby/debug
+* https://rubygems.org/gems/debug
+
+### racc
+
+* Yuichi Kaneko ([yui-knk])
+* https://github.com/ruby/racc
+* https://rubygems.org/gems/racc
+
+#### mutex_m
+
+* https://github.com/ruby/mutex_m
+* https://rubygems.org/gems/mutex_m
+
+#### getoptlong
+
+* https://github.com/ruby/getoptlong
+* https://rubygems.org/gems/getoptlong
+
+#### base64
+
+* Yusuke Endoh ([mame])
+* https://github.com/ruby/base64
+* https://rubygems.org/gems/base64
+
+#### bigdecimal
+
+* Kenta Murata ([mrkn])
+* https://github.com/ruby/bigdecimal
+* https://rubygems.org/gems/bigdecimal
+
+#### observer
+
+* https://github.com/ruby/observer
+* https://rubygems.org/gems/observer
+
+#### abbrev
+
+* Akinori MUSHA ([knu])
+* https://github.com/ruby/abbrev
+* https://rubygems.org/gems/abbrev
+
+#### resolv-replace
+
+* Akira TANAKA ([akr])
+* https://github.com/ruby/resolv-replace
+* https://rubygems.org/gems/resolv-replace
+
+#### rinda
+
+* Masatoshi SEKI ([seki])
+* https://github.com/ruby/rinda
+* https://rubygems.org/gems/rinda
+
+#### drb
+
+* Masatoshi SEKI ([seki])
+* https://github.com/ruby/drb
+* https://rubygems.org/gems/drb
+
+#### nkf
+
+* Naruse Yusuke ([nurse])
+* https://github.com/ruby/nkf
+* https://rubygems.org/gems/nkf
+
+#### syslog
+
+* Akinori Musha ([knu])
+* https://github.com/ruby/syslog
+* https://rubygems.org/gems/syslog
+
+#### csv
+
+* Kouhei Sutou ([kou])
+* https://github.com/ruby/csv
+* https://rubygems.org/gems/csv
+
+#### ostruct
+
+* Marc-André Lafortune ([marcandre])
+* https://github.com/ruby/ostruct
+* https://rubygems.org/gems/ostruct
+
+#### pstore
+
+* https://github.com/ruby/pstore
+* https://rubygems.org/gems/pstore
+
+#### benchmark
+
+* Benoit Daloze ([eregon])
+* https://github.com/ruby/benchmark
+* https://rubygems.org/gems/benchmark
+
+#### logger
+
+* Naotoshi Seo ([sonots])
+* https://github.com/ruby/logger
+* https://rubygems.org/gems/logger
+
+#### rdoc
+
+* Stan Lo ([st0012])
+* Nobuyoshi Nakada ([nobu])
+* https://github.com/ruby/rdoc
+* https://rubygems.org/gems/rdoc
+
+#### win32ole
+
+* Masaki Suketa ([suketa])
+* https://github.com/ruby/win32ole
+* https://rubygems.org/gems/win32ole
+
+#### irb
+
+* Tomoya Ishida ([tompng])
+* Stan Lo ([st0012])
+* Mari Imaizumi ([ima1zumi])
+* HASUMI Hitoshi ([hasumikin])
+* https://github.com/ruby/irb
+* https://rubygems.org/gems/irb
+
+#### reline
+
+* Tomoya Ishida ([tompng])
+* Stan Lo ([st0012])
+* Mari Imaizumi ([ima1zumi])
+* HASUMI Hitoshi ([hasumikin])
+* https://github.com/ruby/reline
+* https://rubygems.org/gems/reline
+
+#### readline
+
+* https://github.com/ruby/readline
+* https://rubygems.org/gems/readline
+
+#### fiddle
+
+* Kouhei Sutou ([kou])
+* https://github.com/ruby/fiddle
+* https://rubygems.org/gems/fiddle
+
+#### repl_type_completor
+
+* Tomoya Ishida ([tompng])
+* https://github.com/ruby/repl_type_completor
+* https://rubygems.org/gems/repl_type_completor
+
+#### tsort
+
+* Tanaka Akira ([akr])
+* https://github.com/ruby/tsort
+* https://rubygems.org/gems/tsort
+
+#### win32-registry
+
+* Nakamura Usaku ([unak])
+* https://github.com/ruby/win32-registry
+* https://rubygems.org/gems/win32-registry
## Platform Maintainers
+
### mswin64 (Microsoft Windows)
-* NAKAMURA Usaku (usa)
+
+* NAKAMURA Usaku ([unak])
### mingw32 (Minimalist GNU for Windows)
-* Nobuyoshi Nakada (nobu)
+
+* Nobuyoshi Nakada ([nobu])
### AIX
-* Yutaka Kanemoto (kanemoto)
+
+* Yutaka Kanemoto ([kanemoto])
### FreeBSD
-* Akinori MUSHA (knu)
+
+* Akinori MUSHA ([knu])
### Solaris
-* Naohisa Goto (ngoto)
+
+* Naohisa Goto ([ngoto])
### RHEL, CentOS
-* KOSAKI Motohiro (kosaki)
+
+* KOSAKI Motohiro ([kosaki])
### macOS
-* Kenta Murata (mrkn)
+
+* Kenta Murata ([mrkn])
### OpenBSD
-* Jeremy Evans (jeremyevans0)
+
+* Jeremy Evans ([jeremyevans])
### cygwin, ...
-* none. (Maintainer WANTED)
+
+* **No maintainer**
### WebAssembly/WASI
-* Yuta Saito (katei)
+
+* Yuta Saito ([kateinoigakukun])
+
+[akr]: https://github.com/akr
+[byroot]: https://github.com/byroot
+[colby-swandale]: https://github.com/colby-swandale
+[drbrain]: https://github.com/drbrain
+[duerst]: https://github.com/duerst
+[earlopain]: https://github.com/earlopain
+[eban]: https://github.com/eban
+[eileencodes]: https://github.com/eileencodes
+[eregon]: https://github.com/eregon
+[hasumikin]: https://github.com/hasumikin
+[hsbt]: https://github.com/hsbt
+[ima1zumi]: https://github.com/ima1zumi
+[jeremyevans]: https://github.com/jeremyevans
+[k-tsj]: https://github.com/k-tsj
+[k0kubun]: https://github.com/k0kubun
+[kanemoto]: https://github.com/kanemoto
+[kateinoigakukun]: https://github.com/kateinoigakukun
+[kddnewton]: https://github.com/kddnewton
+[keiju]: https://github.com/keiju
+[knu]: https://github.com/knu
+[ko1]: https://github.com/ko1
+[kosaki]: https://github.com/kosaki
+[kou]: https://github.com/kou
+[mame]: https://github.com/mame
+[marcandre]: https://github.com/marcandre
+[matz]: https://github.com/matz
+[mrkn]: https://github.com/mrkn
+[ngoto]: https://github.com/ngoto
+[nobu]: https://github.com/nobu
+[nurse]: https://github.com/nurse
+[rhenium]: https://github.com/rhenium
+[seki]: https://github.com/seki
+[suketa]: https://github.com/suketa
+[sonots]: https://github.com/sonots
+[st0012]: https://github.com/st0012
+[tenderlove]: https://github.com/tenderlove
+[tompng]: https://github.com/tompng
+[unak]: https://github.com/unak
+[yuki24]: https://github.com/yuki24
+[zenspider]: https://github.com/zenspider
+[k-tsj]: https://github.com/k-tsj
+[nevans]: https://github.com/nevans
+[tmtm]: https://github.com/tmtm
+[soutaro]: https://github.com/soutaro
+[yui-knk]: https://github.com/yui-knk
+[hasumikin]: https://github.com/hasumikin
+[suketa]: https://github.com/suketa
diff --git a/doc/marshal.rdoc b/doc/marshal.rdoc
deleted file mode 100644
index abf9467262..0000000000
--- a/doc/marshal.rdoc
+++ /dev/null
@@ -1,313 +0,0 @@
-= Marshal Format
-
-The Marshal format is used to serialize ruby objects. The format can store
-arbitrary objects through three user-defined extension mechanisms.
-
-For documentation on using Marshal to serialize and deserialize objects, see
-the Marshal module.
-
-This document calls a serialized set of objects a stream. The Ruby
-implementation can load a set of objects from a String, an IO or an object
-that implements a +getc+ method.
-
-== Stream Format
-
-The first two bytes of the stream contain the major and minor version, each as
-a single byte encoding a digit. The version implemented in Ruby is 4.8
-(stored as "\x04\x08") and is supported by ruby 1.8.0 and newer.
-
-Different major versions of the Marshal format are not compatible and cannot
-be understood by other major versions. Lesser minor versions of the format
-can be understood by newer minor versions. Format 4.7 can be loaded by a 4.8
-implementation but format 4.8 cannot be loaded by a 4.7 implementation.
-
-Following the version bytes is a stream describing the serialized object. The
-stream contains nested objects (the same as a Ruby object) but objects in the
-stream do not necessarily have a direct mapping to the Ruby object model.
-
-Each object in the stream is described by a byte indicating its type followed
-by one or more bytes describing the object. When "object" is mentioned below
-it means any of the types below that defines a Ruby object.
-
-=== true, false, nil
-
-These objects are each one byte long. "T" is represents +true+, "F"
-represents +false+ and "0" represents +nil+.
-
-=== Fixnum and long
-
-"i" represents a signed 32 bit value using a packed format. One through five
-bytes follows the type. The value loaded will always be a Fixnum. On
-32 bit platforms (where the precision of a Fixnum is less than 32 bits)
-loading large values will cause overflow on CRuby.
-
-The fixnum type is used to represent both ruby Fixnum objects and the sizes of
-marshaled arrays, hashes, instance variables and other types. In the
-following sections "long" will mean the format described below, which supports
-full 32 bit precision.
-
-The first byte has the following special values:
-
-"\x00"::
- The value of the integer is 0. No bytes follow.
-
-"\x01"::
- The total size of the integer is two bytes. The following byte is a
- positive integer in the range of 0 through 255. Only values between 123
- and 255 should be represented this way to save bytes.
-
-"\xff"::
- The total size of the integer is two bytes. The following byte is a
- negative integer in the range of -1 through -256.
-
-"\x02"::
- The total size of the integer is three bytes. The following two bytes are a
- positive little-endian integer.
-
-"\xfe"::
- The total size of the integer is three bytes. The following two bytes are a
- negative little-endian integer.
-
-"\x03"::
- The total size of the integer is four bytes. The following three bytes are
- a positive little-endian integer.
-
-"\xfd"::
- The total size of the integer is four bytes. The following three bytes are a
- negative little-endian integer.
-
-"\x04"::
- The total size of the integer is five bytes. The following four bytes are a
- positive little-endian integer. For compatibility with 32 bit ruby,
- only Fixnums less than 1073741824 should be represented this way. For sizes
- of stream objects full precision may be used.
-
-"\xfc"::
- The total size of the integer is five bytes. The following four bytes are a
- negative little-endian integer. For compatibility with 32 bit ruby,
- only Fixnums greater than -10737341824 should be represented this way. For
- sizes of stream objects full precision may be used.
-
-Otherwise the first byte is a sign-extended eight-bit value with an offset.
-If the value is positive the value is determined by subtracting 5 from the
-value. If the value is negative the value is determined by adding 5 to the
-value.
-
-There are multiple representations for many values. CRuby always outputs the
-shortest representation possible.
-
-=== Symbols and Byte Sequence
-
-":" represents a real symbol. A real symbol contains the data needed to
-define the symbol for the rest of the stream as future occurrences in the
-stream will instead be references (a symbol link) to this one. The reference
-is a zero-indexed 32 bit value (so the first occurrence of <code>:hello</code>
-is 0).
-
-Following the type byte is byte sequence which consists of a long indicating
-the number of bytes in the sequence followed by that many bytes of data. Byte
-sequences have no encoding.
-
-For example, the following stream contains the Symbol <code>:hello</code>:
-
- "\x04\x08:\x0ahello"
-
-";" represents a Symbol link which references a previously defined Symbol.
-Following the type byte is a long containing the index in the lookup table for
-the linked (referenced) Symbol.
-
-For example, the following stream contains <code>[:hello, :hello]</code>:
-
- "\x04\b[\a:\nhello;\x00"
-
-When a "symbol" is referenced below it may be either a real symbol or a
-symbol link.
-
-=== Object References
-
-Separate from but similar to symbol references, the stream contains only one
-copy of each object (as determined by #object_id) for all objects except
-true, false, nil, Fixnums and Symbols (which are stored separately as
-described above) a one-indexed 32 bit value will be stored and reused when the
-object is encountered again. (The first object has an index of 1).
-
-"@" represents an object link. Following the type byte is a long giving the
-index of the object.
-
-For example, the following stream contains an Array of the same
-<code>"hello"</code> object twice:
-
- "\004\b[\a\"\nhello@\006"
-
-=== Instance Variables
-
-"I" indicates that instance variables follow the next object. An object
-follows the type byte. Following the object is a length indicating the number
-of instance variables for the object. Following the length is a set of
-name-value pairs. The names are symbols while the values are objects. The
-symbols must be instance variable names (<code>:@name</code>).
-
-An Object ("o" type, described below) uses the same format for its instance
-variables as described here.
-
-For a String and Regexp (described below) a special instance variable
-<code>:E</code> is used to indicate the Encoding.
-
-=== Extended
-
-"e" indicates that the next object is extended by a module. An object follows
-the type byte. Following the object is a symbol that contains the name of the
-module the object is extended by.
-
-=== Array
-
-"[" represents an Array. Following the type byte is a long indicating the
-number of objects in the array. The given number of objects follow the
-length.
-
-=== Bignum
-
-"l" represents a Bignum which is composed of three parts:
-
-sign::
- A single byte containing "+" for a positive value or "-" for a negative
- value.
-length::
- A long indicating the number of bytes of Bignum data follows, divided by
- two. Multiply the length by two to determine the number of bytes of data
- that follow.
-data::
- Bytes of Bignum data representing the number.
-
-The following ruby code will reconstruct the Bignum value from an array of
-bytes:
-
- result = 0
-
- bytes.each_with_index do |byte, exp|
- result += (byte * 2 ** (exp * 8))
- end
-
-=== Class and Module
-
-"c" represents a Class object, "m" represents a Module and "M" represents
-either a class or module (this is an old-style for compatibility). No class
-or module content is included, this type is only a reference. Following the
-type byte is a byte sequence which is used to look up an existing class or
-module, respectively.
-
-Instance variables are not allowed on a class or module.
-
-If no class or module exists an exception should be raised.
-
-For "c" and "m" types, the loaded object must be a class or module,
-respectively.
-
-=== Data
-
-"d" represents a Data object. (Data objects are wrapped pointers from ruby
-extensions.) Following the type byte is a symbol indicating the class for the
-Data object and an object that contains the state of the Data object.
-
-To dump a Data object Ruby calls _dump_data. To load a Data object Ruby calls
-_load_data with the state of the object on a newly allocated instance.
-
-=== Float
-
-"f" represents a Float object. Following the type byte is a byte sequence
-containing the float value. The following values are special:
-
-"inf"::
- Positive infinity
-
-"-inf"::
- Negative infinity
-
-"nan"::
- Not a Number
-
-Otherwise the byte sequence contains a C double (loadable by strtod(3)).
-Older minor versions of Marshal also stored extra mantissa bits to ensure
-portability across platforms but 4.8 does not include these. See
-[ruby-talk:69518] for some explanation.
-
-=== Hash and Hash with Default Value
-
-"{" represents a Hash object while "}" represents a Hash with a default value
-set (<code>Hash.new 0</code>). Following the type byte is a long indicating
-the number of key-value pairs in the Hash, the size. Double the given number
-of objects follow the size.
-
-For a Hash with a default value, the default value follows all the pairs.
-
-=== Module and Old Module
-
-=== Object
-
-"o" represents an object that doesn't have any other special form (such as
-a user-defined or built-in format). Following the type byte is a symbol
-containing the class name of the object. Following the class name is a long
-indicating the number of instance variable names and values for the object.
-Double the given number of pairs of objects follow the size.
-
-The keys in the pairs must be symbols containing instance variable names.
-
-=== Regular Expression
-
-"/" represents a regular expression. Following the type byte is a byte
-sequence containing the regular expression source. Following the type byte is
-a byte containing the regular expression options (case-insensitive, etc.) as a
-signed 8-bit value.
-
-Regular expressions can have an encoding attached through instance variables
-(see above). If no encoding is attached escapes for the following regexp
-specials not present in ruby 1.8 must be removed: g-m, o-q, u, y, E, F, H-L,
-N-V, X, Y.
-
-=== String
-
-'"' represents a String. Following the type byte is a byte sequence
-containing the string content. When dumped from ruby 1.9 an encoding instance
-variable (<code>:E</code> see above) should be included unless the encoding is
-binary.
-
-=== Struct
-
-"S" represents a Struct. Following the type byte is a symbol containing the
-name of the struct. Following the name is a long indicating the number of
-members in the struct. Double the number of objects follow the member count.
-Each member is a pair containing the member's symbol and an object for the
-value of that member.
-
-If the struct name does not match a Struct subclass in the running ruby an
-exception should be raised.
-
-If there is a mismatch between the struct in the currently running ruby and
-the member count in the marshaled struct an exception should be raised.
-
-=== User Class
-
-"C" represents a subclass of a String, Regexp, Array or Hash. Following the
-type byte is a symbol containing the name of the subclass. Following the name
-is the wrapped object.
-
-=== User Defined
-
-"u" represents an object with a user-defined serialization format using the
-+_dump+ instance method and +_load+ class method. Following the type byte is
-a symbol containing the class name. Following the class name is a byte
-sequence containing the user-defined representation of the object.
-
-The class method +_load+ is called on the class with a string created from the
-byte-sequence.
-
-=== User Marshal
-
-"U" represents an object with a user-defined serialization format using the
-+marshal_dump+ and +marshal_load+ instance methods. Following the type byte
-is a symbol containing the class name. Following the class name is an object
-containing the data.
-
-Upon loading a new instance must be allocated and +marshal_load+ must be
-called on the instance with the data.
-
diff --git a/doc/matchdata/begin.rdoc b/doc/matchdata/begin.rdoc
index 8046dd9d55..6100617e19 100644
--- a/doc/matchdata/begin.rdoc
+++ b/doc/matchdata/begin.rdoc
@@ -10,12 +10,12 @@ returns the offset of the beginning of the <tt>n</tt>th match:
m[3] # => "113"
m.begin(3) # => 3
- m = /(Ñ‚)(е)(Ñ)/.match('теÑÑ‚')
- # => #<MatchData "теÑ" 1:"Ñ‚" 2:"е" 3:"Ñ">
- m[0] # => "теÑ"
- m.begin(0) # => 0
- m[3] # => "Ñ"
- m.begin(3) # => 2
+ m = /(ã‚“)(ã«)(ã¡)/.match('ã“ã‚“ã«ã¡ã¯')
+ # => #<MatchData "ã‚“ã«ã¡" 1:"ã‚“" 2:"ã«" 3:"ã¡">
+ m[0] # => "ã‚“ã«ã¡"
+ m.begin(0) # => 1
+ m[3] # => "ã¡"
+ m.begin(3) # => 3
When string or symbol argument +name+ is given,
returns the offset of the beginning for the named match:
diff --git a/doc/matchdata/bytebegin.rdoc b/doc/matchdata/bytebegin.rdoc
new file mode 100644
index 0000000000..54e417a7fc
--- /dev/null
+++ b/doc/matchdata/bytebegin.rdoc
@@ -0,0 +1,30 @@
+Returns the offset (in bytes) of the beginning of the specified match.
+
+When non-negative integer argument +n+ is given,
+returns the offset of the beginning of the <tt>n</tt>th match:
+
+ m = /(.)(.)(\d+)(\d)/.match("THX1138.")
+ # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
+ m[0] # => "HX1138"
+ m.bytebegin(0) # => 1
+ m[3] # => "113"
+ m.bytebegin(3) # => 3
+
+ m = /(ã‚“)(ã«)(ã¡)/.match('ã“ã‚“ã«ã¡ã¯')
+ # => #<MatchData "ã‚“ã«ã¡" 1:"ã‚“" 2:"ã«" 3:"ã¡">
+ m[0] # => "ã‚“ã«ã¡"
+ m.bytebegin(0) # => 3
+ m[3] # => "ã¡"
+ m.bytebegin(3) # => 9
+
+When string or symbol argument +name+ is given,
+returns the offset of the beginning for the named match:
+
+ m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
+ # => #<MatchData "hog" foo:"h" bar:"g">
+ m[:foo] # => "h"
+ m.bytebegin('foo') # => 0
+ m[:bar] # => "g"
+ m.bytebegin(:bar) # => 2
+
+Related: MatchData#byteend, MatchData#byteoffset.
diff --git a/doc/matchdata/byteend.rdoc b/doc/matchdata/byteend.rdoc
new file mode 100644
index 0000000000..0a03f76208
--- /dev/null
+++ b/doc/matchdata/byteend.rdoc
@@ -0,0 +1,30 @@
+Returns the offset (in bytes) of the end of the specified match.
+
+When non-negative integer argument +n+ is given,
+returns the offset of the end of the <tt>n</tt>th match:
+
+ m = /(.)(.)(\d+)(\d)/.match("THX1138.")
+ # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
+ m[0] # => "HX1138"
+ m.byteend(0) # => 7
+ m[3] # => "113"
+ m.byteend(3) # => 6
+
+ m = /(ã‚“)(ã«)(ã¡)/.match('ã“ã‚“ã«ã¡ã¯')
+ # => #<MatchData "ã‚“ã«ã¡" 1:"ã‚“" 2:"ã«" 3:"ã¡">
+ m[0] # => "ã‚“ã«ã¡"
+ m.byteend(0) # => 12
+ m[3] # => "ã¡"
+ m.byteend(3) # => 12
+
+When string or symbol argument +name+ is given,
+returns the offset of the end for the named match:
+
+ m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
+ # => #<MatchData "hog" foo:"h" bar:"g">
+ m[:foo] # => "h"
+ m.byteend('foo') # => 1
+ m[:bar] # => "g"
+ m.byteend(:bar) # => 3
+
+Related: MatchData#bytebegin, MatchData#byteoffset.
diff --git a/doc/matchdata/end.rdoc b/doc/matchdata/end.rdoc
index 0209b2d2fc..c43a5428f3 100644
--- a/doc/matchdata/end.rdoc
+++ b/doc/matchdata/end.rdoc
@@ -10,12 +10,12 @@ returns the offset of the end of the <tt>n</tt>th match:
m[3] # => "113"
m.end(3) # => 6
- m = /(Ñ‚)(е)(Ñ)/.match('теÑÑ‚')
- # => #<MatchData "теÑ" 1:"Ñ‚" 2:"е" 3:"Ñ">
- m[0] # => "теÑ"
- m.end(0) # => 3
- m[3] # => "Ñ"
- m.end(3) # => 3
+ m = /(ã‚“)(ã«)(ã¡)/.match('ã“ã‚“ã«ã¡ã¯')
+ # => #<MatchData "ã‚“ã«ã¡" 1:"ã‚“" 2:"ã«" 3:"ã¡">
+ m[0] # => "ã‚“ã«ã¡"
+ m.end(0) # => 4
+ m[3] # => "ã¡"
+ m.end(3) # => 4
When string or symbol argument +name+ is given,
returns the offset of the end for the named match:
diff --git a/doc/matchdata/offset.rdoc b/doc/matchdata/offset.rdoc
index 0985316d76..4194ef7ef9 100644
--- a/doc/matchdata/offset.rdoc
+++ b/doc/matchdata/offset.rdoc
@@ -11,12 +11,12 @@ returns the starting and ending offsets of the <tt>n</tt>th match:
m[3] # => "113"
m.offset(3) # => [3, 6]
- m = /(Ñ‚)(е)(Ñ)/.match('теÑÑ‚')
- # => #<MatchData "теÑ" 1:"Ñ‚" 2:"е" 3:"Ñ">
- m[0] # => "теÑ"
- m.offset(0) # => [0, 3]
- m[3] # => "Ñ"
- m.offset(3) # => [2, 3]
+ m = /(ã‚“)(ã«)(ã¡)/.match('ã“ã‚“ã«ã¡ã¯')
+ # => #<MatchData "ã‚“ã«ã¡" 1:"ã‚“" 2:"ã«" 3:"ã¡">
+ m[0] # => "ã‚“ã«ã¡"
+ m.offset(0) # => [1, 4]
+ m[3] # => "ã¡"
+ m.offset(3) # => [3, 4]
When string or symbol argument +name+ is given,
returns the starting and ending offsets for the named match:
diff --git a/doc/math/math.rdoc b/doc/math/math.rdoc
index 7a89df951c..2978375564 100644
--- a/doc/math/math.rdoc
+++ b/doc/math/math.rdoc
@@ -1,4 +1,4 @@
-\Module \Math provides methods for basic trigonometric,
+Module \Math provides methods for basic trigonometric,
logarithmic, and transcendental functions, and for extracting roots.
You can write its constants and method calls thus:
diff --git a/doc/optparse/argument_converters.rdoc b/doc/optparse/argument_converters.rdoc
index ac659da8c5..532729871c 100644
--- a/doc/optparse/argument_converters.rdoc
+++ b/doc/optparse/argument_converters.rdoc
@@ -1,7 +1,7 @@
== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
=== Contents
@@ -27,13 +27,13 @@ from the default \String to an instance of another class.
=== Built-In Argument Converters
-\OptionParser has a number of built-in argument converters,
++OptionParser+ has a number of built-in argument converters,
which are demonstrated below.
-==== \Date
+==== +Date+
File +date.rb+
-defines an option whose argument is to be converted to a \Date object.
+defines an option whose argument is to be converted to a +Date+ object.
The argument is converted by method Date#parse.
:include: ruby/date.rb
@@ -47,10 +47,10 @@ Executions:
$ ruby date.rb --date "3rd Feb 2001"
[#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
-==== \DateTime
+==== +DateTime+
File +datetime.rb+
-defines an option whose argument is to be converted to a \DateTime object.
+defines an option whose argument is to be converted to a +DateTime+ object.
The argument is converted by method DateTime#parse.
:include: ruby/datetime.rb
@@ -64,10 +64,10 @@ Executions:
$ ruby datetime.rb --datetime "3rd Feb 2001 04:05:06 PM"
[#<DateTime: 2001-02-03T16:05:06+00:00 ((2451944j,57906s,0n),+0s,2299161j)>, DateTime]
-==== \Time
+==== +Time+
File +time.rb+
-defines an option whose argument is to be converted to a \Time object.
+defines an option whose argument is to be converted to a +Time+ object.
The argument is converted by method Time#httpdate or Time#parse.
:include: ruby/time.rb
@@ -79,10 +79,10 @@ Executions:
$ ruby time.rb --time 2010-10-31
[2010-10-31 00:00:00 -0500, Time]
-==== \URI
+==== +URI+
File +uri.rb+
-defines an option whose argument is to be converted to a \URI object.
+defines an option whose argument is to be converted to a +URI+ object.
The argument is converted by method URI#parse.
:include: ruby/uri.rb
@@ -96,10 +96,10 @@ Executions:
$ ruby uri.rb --uri file://~/var
[#<URI::File file://~/var>, URI::File]
-==== \Shellwords
+==== +Shellwords+
File +shellwords.rb+
-defines an option whose argument is to be converted to an \Array object by method
+defines an option whose argument is to be converted to an +Array+ object by method
Shellwords#shellwords.
:include: ruby/shellwords.rb
@@ -111,10 +111,10 @@ Executions:
$ ruby shellwords.rb --shellwords "here are 'two words'"
[["here", "are", "two words"], Array]
-==== \Integer
+==== +Integer+
File +integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/integer.rb
@@ -132,10 +132,10 @@ Executions:
$ ruby integer.rb --integer 0b100
[4, Integer]
-==== \Float
+==== +Float+
File +float.rb+
-defines an option whose argument is to be converted to a \Float object.
+defines an option whose argument is to be converted to a +Float+ object.
The argument is converted by method Kernel#Float.
:include: ruby/float.rb
@@ -151,11 +151,11 @@ Executions:
$ ruby float.rb --float 1.234E-2
[0.01234, Float]
-==== \Numeric
+==== +Numeric+
File +numeric.rb+
defines an option whose argument is to be converted to an instance
-of \Rational, \Float, or \Integer.
+of +Rational+, +Float+, or +Integer+.
The argument is converted by method Kernel#Rational,
Kernel#Float, or Kernel#Integer.
@@ -170,10 +170,10 @@ Executions:
$ ruby numeric.rb --numeric 3
[3, Integer]
-==== \DecimalInteger
+==== +DecimalInteger+
File +decimal_integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/decimal_integer.rb
@@ -192,10 +192,10 @@ Executions:
$ ruby decimal_integer.rb --decimal_integer -0100
[-100, Integer]
-==== \OctalInteger
+==== +OctalInteger+
File +octal_integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/octal_integer.rb
@@ -212,10 +212,10 @@ Executions:
$ ruby octal_integer.rb --octal_integer 0100
[64, Integer]
-==== \DecimalNumeric
+==== +DecimalNumeric+
File +decimal_numeric.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer
:include: ruby/decimal_numeric.rb
@@ -232,7 +232,7 @@ Executions:
$ ruby decimal_numeric.rb --decimal_numeric 0100
[64, Integer]
-==== \TrueClass
+==== +TrueClass+
File +true_class.rb+
defines an option whose argument is to be converted to +true+ or +false+.
@@ -259,7 +259,7 @@ Executions:
$ ruby true_class.rb --true_class nil
[false, FalseClass]
-==== \FalseClass
+==== +FalseClass+
File +false_class.rb+
defines an option whose argument is to be converted to +true+ or +false+.
@@ -286,10 +286,10 @@ Executions:
$ ruby false_class.rb --false_class +
[true, TrueClass]
-==== \Object
+==== +Object+
File +object.rb+
-defines an option whose argument is not to be converted from \String.
+defines an option whose argument is not to be converted from +String+.
:include: ruby/object.rb
@@ -300,10 +300,10 @@ Executions:
$ ruby object.rb --object nil
["nil", String]
-==== \String
+==== +String+
File +string.rb+
-defines an option whose argument is not to be converted from \String.
+defines an option whose argument is not to be converted from +String+.
:include: ruby/string.rb
@@ -314,10 +314,10 @@ Executions:
$ ruby string.rb --string nil
["nil", String]
-==== \Array
+==== +Array+
File +array.rb+
-defines an option whose argument is to be converted from \String
+defines an option whose argument is to be converted from +String+
to an array of strings, based on comma-separated substrings.
:include: ruby/array.rb
@@ -331,10 +331,10 @@ Executions:
$ ruby array.rb --array "foo, bar, baz"
[["foo", " bar", " baz"], Array]
-==== \Regexp
+==== +Regexp+
File +regexp.rb+
-defines an option whose argument is to be converted to a \Regexp object.
+defines an option whose argument is to be converted to a +Regexp+ object.
:include: ruby/regexp.rb
@@ -352,7 +352,7 @@ To create a custom converter, call OptionParser#accept with:
- A block that accepts the argument and returns the converted value.
This custom converter accepts any argument and converts it,
-if possible, to a \Complex object.
+if possible, to a +Complex+ object.
:include: ruby/custom_converter.rb
@@ -377,4 +377,4 @@ Executions:
$ ruby match_converter.rb --capitalize foo
["Foo", String]
$ ruby match_converter.rb --capitalize "foo bar"
- match_converter.rb:9:in `<main>': invalid argument: --capitalize foo bar (OptionParser::InvalidArgument)
+ match_converter.rb:9:in '<main>': invalid argument: --capitalize foo bar (OptionParser::InvalidArgument)
diff --git a/doc/optparse/option_params.rdoc b/doc/optparse/option_params.rdoc
index ace2c4283f..575ee66cdb 100644
--- a/doc/optparse/option_params.rdoc
+++ b/doc/optparse/option_params.rdoc
@@ -1,6 +1,6 @@
== Parameters for New Options
-Option-creating methods in \OptionParser
+Option-creating methods in +OptionParser+
accept arguments that determine the behavior of a new option:
- OptionParser#on
@@ -31,7 +31,7 @@ Contents:
- {Long Names with Optional Arguments}[#label-Long+Names+with+Optional+Arguments]
- {Long Names with Negation}[#label-Long+Names+with+Negation]
- {Mixed Names}[#label-Mixed+Names]
-- {Argument Styles}[#label-Argument+Styles]
+- {Argument Strings}[#label-Argument+Strings]
- {Argument Values}[#label-Argument+Values]
- {Explicit Argument Values}[#label-Explicit+Argument+Values]
- {Explicit Values in Array}[#label-Explicit+Values+in+Array]
@@ -91,7 +91,7 @@ Executions:
Usage: short_required [options]
-xXXX Short name with required argument
$ ruby short_required.rb -x
- short_required.rb:6:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ short_required.rb:6:in '<main>': missing argument: -x (OptionParser::MissingArgument)
$ ruby short_required.rb -x FOO
["-x", "FOO"]
@@ -181,7 +181,7 @@ Executions:
Usage: long_required [options]
--xxx XXX Long name with required argument
$ ruby long_required.rb --xxx
- long_required.rb:6:in `<main>': missing argument: --xxx (OptionParser::MissingArgument)
+ long_required.rb:6:in '<main>': missing argument: --xxx (OptionParser::MissingArgument)
$ ruby long_required.rb --xxx FOO
["--xxx", "FOO"]
@@ -243,11 +243,11 @@ Usage: mixed_names [options]
$ ruby mixed_names.rb --xxx
["--xxx", true]
$ ruby mixed_names.rb -y
- mixed_names.rb:12:in `<main>': missing argument: -y (OptionParser::MissingArgument)
+ mixed_names.rb:12:in '<main>': missing argument: -y (OptionParser::MissingArgument)
$ ruby mixed_names.rb -y FOO
["--yyy", "FOO"]
$ ruby mixed_names.rb --yyy
- mixed_names.rb:12:in `<main>': missing argument: --yyy (OptionParser::MissingArgument)
+ mixed_names.rb:12:in '<main>': missing argument: --yyy (OptionParser::MissingArgument)
$ ruby mixed_names.rb --yyy BAR
["--yyy", "BAR"]
$ ruby mixed_names.rb -z
@@ -279,7 +279,7 @@ Executions:
Usage: argument_keywords [options]
-x, --xxx Required argument
$ ruby argument_styles.rb --xxx
- argument_styles.rb:6:in `<main>': missing argument: --xxx (OptionParser::MissingArgument)
+ argument_styles.rb:6:in '<main>': missing argument: --xxx (OptionParser::MissingArgument)
$ ruby argument_styles.rb --xxx FOO
["--xxx", "FOO"]
@@ -298,7 +298,7 @@ Executions:
Usage: argument_strings [options]
-x, --xxx=XXX Required argument
$ ruby argument_strings.rb --xxx
- argument_strings.rb:9:in `<main>': missing argument: --xxx (OptionParser::MissingArgument)
+ argument_strings.rb:9:in '<main>': missing argument: --xxx (OptionParser::MissingArgument)
$ ruby argument_strings.rb --xxx FOO
["--xxx", "FOO"]
@@ -331,7 +331,7 @@ Executions:
-xXXX Values for required argument
-y [YYY] Values for optional argument
$ ruby explicit_array_values.rb -x
- explicit_array_values.rb:9:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ explicit_array_values.rb:9:in '<main>': missing argument: -x (OptionParser::MissingArgument)
$ ruby explicit_array_values.rb -x foo
["-x", "foo"]
$ ruby explicit_array_values.rb -x f
@@ -339,9 +339,9 @@ Executions:
$ ruby explicit_array_values.rb -x bar
["-x", "bar"]
$ ruby explicit_array_values.rb -y ba
- explicit_array_values.rb:9:in `<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
+ explicit_array_values.rb:9:in '<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
$ ruby explicit_array_values.rb -x baz
- explicit_array_values.rb:9:in `<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
+ explicit_array_values.rb:9:in '<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
===== Explicit Values in Hash
@@ -361,7 +361,7 @@ Executions:
-xXXX Values for required argument
-y [YYY] Values for optional argument
$ ruby explicit_hash_values.rb -x
- explicit_hash_values.rb:9:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ explicit_hash_values.rb:9:in '<main>': missing argument: -x (OptionParser::MissingArgument)
$ ruby explicit_hash_values.rb -x foo
["-x", 0]
$ ruby explicit_hash_values.rb -x f
@@ -369,7 +369,7 @@ Executions:
$ ruby explicit_hash_values.rb -x bar
["-x", 1]
$ ruby explicit_hash_values.rb -x baz
- explicit_hash_values.rb:9:in `<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
+ explicit_hash_values.rb:9:in '<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
$ ruby explicit_hash_values.rb -y
["-y", nil]
$ ruby explicit_hash_values.rb -y baz
@@ -377,14 +377,15 @@ Executions:
$ ruby explicit_hash_values.rb -y bat
["-y", 3]
$ ruby explicit_hash_values.rb -y ba
- explicit_hash_values.rb:9:in `<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
+ explicit_hash_values.rb:9:in '<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
$ ruby explicit_hash_values.rb -y bam
["-y", nil]
==== Argument Value Patterns
You can restrict permissible argument values
-by specifying a Regexp that the given argument must match.
+by specifying a +Regexp+ that the given argument must match,
+or a +Range+ or +Array+ that the converted value must be included in.
File +matched_values.rb+ defines options with matched argument values.
@@ -395,17 +396,27 @@ Executions:
$ ruby matched_values.rb --help
Usage: matched_values [options]
--xxx XXX Matched values
+ --yyy YYY Check by range
+ --zzz ZZZ Check by list
$ ruby matched_values.rb --xxx foo
["--xxx", "foo"]
$ ruby matched_values.rb --xxx FOO
["--xxx", "FOO"]
$ ruby matched_values.rb --xxx bar
- matched_values.rb:6:in `<main>': invalid argument: --xxx bar (OptionParser::InvalidArgument)
+ matched_values.rb:12:in '<main>': invalid argument: --xxx bar (OptionParser::InvalidArgument)
+ $ ruby matched_values.rb --yyy 1
+ ["--yyy", 1]
+ $ ruby matched_values.rb --yyy 4
+ matched_values.rb:12:in '<main>': invalid argument: --yyy 4 (OptionParser::InvalidArgument)
+ $ ruby matched_values.rb --zzz 1
+ ["--zzz", 1]
+ $ ruby matched_values.rb --zzz 2
+ matched_values.rb:12:in '<main>': invalid argument: --zzz 2 (OptionParser::InvalidArgument)
=== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
There are a number of built-in converters.
You can also define custom converters.
diff --git a/doc/optparse/ruby/argument_abbreviation.rb b/doc/optparse/ruby/argument_abbreviation.rb
new file mode 100644
index 0000000000..49007ebe69
--- /dev/null
+++ b/doc/optparse/ruby/argument_abbreviation.rb
@@ -0,0 +1,9 @@
+require 'optparse'
+parser = OptionParser.new
+parser.on('-x', '--xxx=VALUE', %w[ABC def], 'Argument abbreviations') do |value|
+ p ['--xxx', value]
+end
+parser.on('-y', '--yyy=VALUE', {"abc"=>"XYZ", def: "FOO"}, 'Argument abbreviations') do |value|
+ p ['--yyy', value]
+end
+parser.parse!
diff --git a/doc/optparse/ruby/matched_values.rb b/doc/optparse/ruby/matched_values.rb
index f184ca8474..a1aba140e6 100644
--- a/doc/optparse/ruby/matched_values.rb
+++ b/doc/optparse/ruby/matched_values.rb
@@ -3,4 +3,10 @@ parser = OptionParser.new
parser.on('--xxx XXX', /foo/i, 'Matched values') do |value|
p ['--xxx', value]
end
+parser.on('--yyy YYY', Integer, 'Check by range', 1..3) do |value|
+ p ['--yyy', value]
+end
+parser.on('--zzz ZZZ', Integer, 'Check by list', [1, 3, 4]) do |value|
+ p ['--zzz', value]
+end
parser.parse!
diff --git a/doc/optparse/tutorial.rdoc b/doc/optparse/tutorial.rdoc
index b95089826d..1134f94ddf 100644
--- a/doc/optparse/tutorial.rdoc
+++ b/doc/optparse/tutorial.rdoc
@@ -1,10 +1,10 @@
== Tutorial
-=== Why \OptionParser?
+=== Why +OptionParser+?
When a Ruby program executes, it captures its command-line arguments
and options into variable ARGV.
-This simple program just prints its \ARGV:
+This simple program just prints its +ARGV+:
:include: ruby/argv.rb
@@ -18,7 +18,7 @@ the command-line options.
OptionParser offers methods for parsing and handling those options.
-With \OptionParser, you can define options so that for each option:
+With +OptionParser+, you can define options so that for each option:
- The code that defines the option and code that handles that option
are in the same place.
@@ -55,7 +55,7 @@ The class also has method #help, which displays automatically-generated help tex
- {Argument Converters}[#label-Argument+Converters]
- {Help}[#label-Help]
- {Top List and Base List}[#label-Top+List+and+Base+List]
-- {Defining Options}[#label-Defining+Options]
+- {Methods for Defining Options}[#label-Methods+for+Defining+Options]
- {Parsing}[#label-Parsing]
- {Method parse!}[#label-Method+parse-21]
- {Method parse}[#label-Method+parse]
@@ -66,10 +66,10 @@ The class also has method #help, which displays automatically-generated help tex
=== To Begin With
-To use \OptionParser:
+To use +OptionParser+:
-1. Require the \OptionParser code.
-2. Create an \OptionParser object.
+1. Require the +OptionParser+ code.
+2. Create an +OptionParser+ object.
3. Define one or more options.
4. Parse the command line.
@@ -92,9 +92,9 @@ the block defined for the option is called with the argument value.
An invalid option raises an exception.
Method #parse!, which is used most often in this tutorial,
-removes from \ARGV the options and arguments it finds,
+removes from +ARGV+ the options and arguments it finds,
leaving other non-option arguments for the program to handle on its own.
-The method returns the possibly-reduced \ARGV array.
+The method returns the possibly-reduced +ARGV+ array.
Executions:
@@ -111,11 +111,11 @@ Executions:
["x", true]
["input_file.txt", "output_file.txt"]
$ ruby basic.rb -a
- basic.rb:16:in `<main>': invalid option: -a (OptionParser::InvalidOption)
+ basic.rb:16:in '<main>': invalid option: -a (OptionParser::InvalidOption)
=== Defining Options
-A common way to define an option in \OptionParser
+A common way to define an option in +OptionParser+
is with instance method OptionParser#on.
The method may be called with any number of arguments
@@ -232,11 +232,11 @@ Executions:
$ ruby mixed_names.rb --xxx
["--xxx", true]
$ ruby mixed_names.rb -y
- mixed_names.rb:12:in `<main>': missing argument: -y (OptionParser::MissingArgument)
+ mixed_names.rb:12:in '<main>': missing argument: -y (OptionParser::MissingArgument)
$ ruby mixed_names.rb -y FOO
["--yyy", "FOO"]
$ ruby mixed_names.rb --yyy
- mixed_names.rb:12:in `<main>': missing argument: --yyy (OptionParser::MissingArgument)
+ mixed_names.rb:12:in '<main>': missing argument: --yyy (OptionParser::MissingArgument)
$ ruby mixed_names.rb --yyy BAR
["--yyy", "BAR"]
$ ruby mixed_names.rb -z
@@ -270,9 +270,9 @@ Executions:
$ ruby name_abbrev.rb --draft
["--draft", true]
$ ruby name_abbrev.rb --d
- name_abbrev.rb:9:in `<main>': ambiguous option: --d (OptionParser::AmbiguousOption)
+ name_abbrev.rb:9:in '<main>': ambiguous option: --d (OptionParser::AmbiguousOption)
$ ruby name_abbrev.rb --dr
- name_abbrev.rb:9:in `<main>': ambiguous option: --dr (OptionParser::AmbiguousOption)
+ name_abbrev.rb:9:in '<main>': ambiguous option: --dr (OptionParser::AmbiguousOption)
$ ruby name_abbrev.rb --dry
["--dry-run", true]
$ ruby name_abbrev.rb --dra
@@ -285,7 +285,7 @@ You can disable abbreviation using method +require_exact+.
Executions:
$ ruby no_abbreviation.rb --dry-ru
- no_abbreviation.rb:10:in `<main>': invalid option: --dry-ru (OptionParser::InvalidOption)
+ no_abbreviation.rb:10:in '<main>': invalid option: --dry-ru (OptionParser::InvalidOption)
$ ruby no_abbreviation.rb --dry-run
["--dry-run", true]
@@ -323,7 +323,7 @@ Executions:
Omitting a required argument raises an error:
$ ruby required_argument.rb -x
- required_argument.rb:9:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ required_argument.rb:9:in '<main>': missing argument: -x (OptionParser::MissingArgument)
==== Option with Optional Argument
@@ -351,6 +351,29 @@ Executions:
Omitting an optional argument does not raise an error.
+==== Argument Abbreviations
+
+Specify an argument list as an Array or a Hash.
+
+ :include: ruby/argument_abbreviation.rb
+
+When an argument is abbreviated, the expanded argument yielded.
+
+Executions:
+
+ $ ruby argument_abbreviation.rb --help
+ Usage: argument_abbreviation [options]
+ Usage: argument_abbreviation [options]
+ -x, --xxx=VALUE Argument abbreviations
+ -y, --yyy=VALUE Argument abbreviations
+ $ ruby argument_abbreviation.rb --xxx A
+ ["--xxx", "ABC"]
+ $ ruby argument_abbreviation.rb --xxx c
+ argument_abbreviation.rb:9:in '<main>': invalid argument: --xxx c (OptionParser::InvalidArgument)
+ $ ruby argument_abbreviation.rb --yyy a --yyy d
+ ["--yyy", "XYZ"]
+ ["--yyy", "FOO"]
+
=== Argument Values
Permissible argument values may be restricted
@@ -380,7 +403,7 @@ Executions:
-xXXX Values for required argument
-y [YYY] Values for optional argument
$ ruby explicit_array_values.rb -x
- explicit_array_values.rb:9:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ explicit_array_values.rb:9:in '<main>': missing argument: -x (OptionParser::MissingArgument)
$ ruby explicit_array_values.rb -x foo
["-x", "foo"]
$ ruby explicit_array_values.rb -x f
@@ -388,9 +411,9 @@ Executions:
$ ruby explicit_array_values.rb -x bar
["-x", "bar"]
$ ruby explicit_array_values.rb -y ba
- explicit_array_values.rb:9:in `<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
+ explicit_array_values.rb:9:in '<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
$ ruby explicit_array_values.rb -x baz
- explicit_array_values.rb:9:in `<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
+ explicit_array_values.rb:9:in '<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
===== Explicit Values in Hash
@@ -410,7 +433,7 @@ Executions:
-xXXX Values for required argument
-y [YYY] Values for optional argument
$ ruby explicit_hash_values.rb -x
- explicit_hash_values.rb:9:in `<main>': missing argument: -x (OptionParser::MissingArgument)
+ explicit_hash_values.rb:9:in '<main>': missing argument: -x (OptionParser::MissingArgument)
$ ruby explicit_hash_values.rb -x foo
["-x", 0]
$ ruby explicit_hash_values.rb -x f
@@ -418,7 +441,7 @@ Executions:
$ ruby explicit_hash_values.rb -x bar
["-x", 1]
$ ruby explicit_hash_values.rb -x baz
- explicit_hash_values.rb:9:in `<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
+ explicit_hash_values.rb:9:in '<main>': invalid argument: -x baz (OptionParser::InvalidArgument)
$ ruby explicit_hash_values.rb -y
["-y", nil]
$ ruby explicit_hash_values.rb -y baz
@@ -426,7 +449,7 @@ Executions:
$ ruby explicit_hash_values.rb -y bat
["-y", 3]
$ ruby explicit_hash_values.rb -y ba
- explicit_hash_values.rb:9:in `<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
+ explicit_hash_values.rb:9:in '<main>': ambiguous argument: -y ba (OptionParser::AmbiguousArgument)
$ ruby explicit_hash_values.rb -y bam
["-y", nil]
@@ -449,7 +472,7 @@ Executions:
$ ruby matched_values.rb --xxx FOO
["--xxx", "FOO"]
$ ruby matched_values.rb --xxx bar
- matched_values.rb:6:in `<main>': invalid argument: --xxx bar (OptionParser::InvalidArgument)
+ matched_values.rb:6:in '<main>': invalid argument: --xxx bar (OptionParser::InvalidArgument)
=== Keyword Argument +into+
@@ -501,7 +524,7 @@ Executions:
-y, --yyyYYY Short and long, required argument
-z, --zzz [ZZZ] Short and long, optional argument
$ ruby missing_options.rb --yyy FOO
- missing_options.rb:11:in `<main>': Missing required options: [:xxx, :zzz] (RuntimeError)
+ missing_options.rb:11:in '<main>': Missing required options: [:xxx, :zzz] (RuntimeError)
==== Default Values for Options
@@ -522,11 +545,11 @@ Executions:
=== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
There are a number of built-in converters.
Example: File +date.rb+
-defines an option whose argument is to be converted to a \Date object.
+defines an option whose argument is to be converted to a +Date+ object.
The argument is converted by method Date#parse.
:include: ruby/date.rb
@@ -546,7 +569,7 @@ for both built-in and custom converters.
=== Help
-\OptionParser makes automatically generated help text available.
++OptionParser+ makes automatically generated help text available.
The help text consists of:
@@ -614,49 +637,49 @@ Execution:
=== Top List and Base List
-An \OptionParser object maintains a stack of \OptionParser::List objects,
+An +OptionParser+ object maintains a stack of OptionParser::List objects,
each of which has a collection of zero or more options.
It is unlikely that you'll need to add or take away from that stack.
The stack includes:
-- The <em>top list</em>, given by \OptionParser#top.
-- The <em>base list</em>, given by \OptionParser#base.
+- The <em>top list</em>, given by OptionParser#top.
+- The <em>base list</em>, given by OptionParser#base.
-When \OptionParser builds its help text, the options in the top list
+When +OptionParser+ builds its help text, the options in the top list
precede those in the base list.
-=== Defining Options
+=== Methods for Defining Options
Option-defining methods allow you to create an option, and also append/prepend it
to the top list or append it to the base list.
Each of these next three methods accepts a sequence of parameter arguments and a block,
-creates an option object using method \Option#make_switch (see below),
+creates an option object using method OptionParser#make_switch (see below),
and returns the created option:
-- \Method \OptionParser#define appends the created option to the top list.
+- \Method OptionParser#define appends the created option to the top list.
-- \Method \OptionParser#define_head prepends the created option to the top list.
+- \Method OptionParser#define_head prepends the created option to the top list.
-- \Method \OptionParser#define_tail appends the created option to the base list.
+- \Method OptionParser#define_tail appends the created option to the base list.
These next three methods are identical to the three above,
except for their return values:
-- \Method \OptionParser#on is identical to method \OptionParser#define,
+- \Method OptionParser#on is identical to method OptionParser#define,
except that it returns the parser object +self+.
-- \Method \OptionParser#on_head is identical to method \OptionParser#define_head,
+- \Method OptionParser#on_head is identical to method OptionParser#define_head,
except that it returns the parser object +self+.
-- \Method \OptionParser#on_tail is identical to method \OptionParser#define_tail,
+- \Method OptionParser#on_tail is identical to method OptionParser#define_tail,
except that it returns the parser object +self+.
Though you may never need to call it directly,
here's the core method for defining an option:
-- \Method \OptionParser#make_switch accepts an array of parameters and a block.
+- \Method OptionParser#make_switch accepts an array of parameters and a block.
See {Parameters for New Options}[optparse/option_params.rdoc].
This method is unlike others here in that it:
- Accepts an <em>array of parameters</em>;
@@ -668,7 +691,7 @@ here's the core method for defining an option:
=== Parsing
-\OptionParser has six instance methods for parsing.
++OptionParser+ has six instance methods for parsing.
Three have names ending with a "bang" (<tt>!</tt>):
@@ -699,9 +722,9 @@ Each of these methods:
(see {Keyword Argument into}[#label-Keyword+Argument+into]).
- Returns +argv+, possibly with some elements removed.
-==== \Method parse!
+==== \Method +parse!+
-\Method parse!:
+\Method +parse!+:
- Accepts an optional array of string arguments +argv+;
if not given, +argv+ defaults to the value of OptionParser#default_argv,
@@ -756,9 +779,9 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
["--xxx", true]
Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
-==== \Method parse
+==== \Method +parse+
-\Method parse:
+\Method +parse+:
- Accepts an array of string arguments
_or_ zero or more string arguments.
@@ -810,25 +833,25 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
["--xxx", true]
Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
-==== \Method order!
+==== \Method +order!+
Calling method OptionParser#order! gives exactly the same result as
calling method OptionParser#parse! with environment variable
+POSIXLY_CORRECT+ defined.
-==== \Method order
+==== \Method +order+
Calling method OptionParser#order gives exactly the same result as
calling method OptionParser#parse with environment variable
+POSIXLY_CORRECT+ defined.
-==== \Method permute!
+==== \Method +permute!+
Calling method OptionParser#permute! gives exactly the same result as
calling method OptionParser#parse! with environment variable
+POSIXLY_CORRECT+ _not_ defined.
-==== \Method permute
+==== \Method +permute+
Calling method OptionParser#permute gives exactly the same result as
calling method OptionParser#parse with environment variable
diff --git a/doc/packed_data.rdoc b/doc/packed_data.rdoc
deleted file mode 100644
index ec13b24c69..0000000000
--- a/doc/packed_data.rdoc
+++ /dev/null
@@ -1,590 +0,0 @@
-== Packed \Data
-
-Certain Ruby core methods deal with packing and unpacking data:
-
-- \Method Array#pack:
- Formats each element in array +self+ into a binary string;
- returns that string.
-- \Method String#unpack:
- Extracts data from string +self+,
- forming objects that become the elements of a new array;
- returns that array.
-- \Method String#unpack1:
- Does the same, but unpacks and returns only the first extracted object.
-
-Each of these methods accepts a string +template+,
-consisting of zero or more _directive_ characters,
-each followed by zero or more _modifier_ characters.
-
-Examples (directive <tt>'C'</tt> specifies 'unsigned character'):
-
- [65].pack('C') # => "A" # One element, one directive.
- [65, 66].pack('CC') # => "AB" # Two elements, two directives.
- [65, 66].pack('C') # => "A" # Extra element is ignored.
- [65].pack('') # => "" # No directives.
- [65].pack('CC') # Extra directive raises ArgumentError.
-
- 'A'.unpack('C') # => [65] # One character, one directive.
- 'AB'.unpack('CC') # => [65, 66] # Two characters, two directives.
- 'AB'.unpack('C') # => [65] # Extra character is ignored.
- 'A'.unpack('CC') # => [65, nil] # Extra directive generates nil.
- 'AB'.unpack('') # => [] # No directives.
-
-The string +template+ may contain any mixture of valid directives
-(directive <tt>'c'</tt> specifies 'signed character'):
-
- [65, -1].pack('cC') # => "A\xFF"
- "A\xFF".unpack('cC') # => [65, 255]
-
-The string +template+ may contain whitespace (which is ignored)
-and comments, each of which begins with character <tt>'#'</tt>
-and continues up to and including the next following newline:
-
- [0,1].pack(" C #foo \n C ") # => "\x00\x01"
- "\0\1".unpack(" C #foo \n C ") # => [0, 1]
-
-Any directive may be followed by either of these modifiers:
-
-- <tt>'*'</tt> - The directive is to be applied as many times as needed:
-
- [65, 66].pack('C*') # => "AB"
- 'AB'.unpack('C*') # => [65, 66]
-
-- Integer +count+ - The directive is to be applied +count+ times:
-
- [65, 66].pack('C2') # => "AB"
- [65, 66].pack('C3') # Raises ArgumentError.
- 'AB'.unpack('C2') # => [65, 66]
- 'AB'.unpack('C3') # => [65, 66, nil]
-
- Note: Directives in <tt>%w[A a Z m]</tt> use +count+ differently;
- see {String Directives}[rdoc-ref:packed_data.rdoc@String+Directives].
-
-If elements don't fit the provided directive, only least significant bits are encoded:
-
- [257].pack("C").unpack("C") # => [1]
-
-=== Packing \Method
-
-\Method Array#pack accepts optional keyword argument
-+buffer+ that specifies the target string (instead of a new string):
-
- [65, 66].pack('C*', buffer: 'foo') # => "fooAB"
-
-The method can accept a block:
-
- # Packed string is passed to the block.
- [65, 66].pack('C*') {|s| p s } # => "AB"
-
-=== Unpacking Methods
-
-Methods String#unpack and String#unpack1 each accept
-an optional keyword argument +offset+ that specifies an offset
-into the string:
-
- 'ABC'.unpack('C*', offset: 1) # => [66, 67]
- 'ABC'.unpack1('C*', offset: 1) # => 66
-
-Both methods can accept a block:
-
- # Each unpacked object is passed to the block.
- ret = []
- "ABCD".unpack("C*") {|c| ret << c }
- ret # => [65, 66, 67, 68]
-
- # The single unpacked object is passed to the block.
- 'AB'.unpack1('C*') {|ele| p ele } # => 65
-
-=== \Integer Directives
-
-Each integer directive specifies the packing or unpacking
-for one element in the input or output array.
-
-==== 8-Bit \Integer Directives
-
-- <tt>'c'</tt> - 8-bit signed integer
- (like C <tt>signed char</tt>):
-
- [0, 1, 255].pack('c*') # => "\x00\x01\xFF"
- s = [0, 1, -1].pack('c*') # => "\x00\x01\xFF"
- s.unpack('c*') # => [0, 1, -1]
-
-- <tt>'C'</tt> - 8-bit signed integer
- (like C <tt>unsigned char</tt>):
-
- [0, 1, 255].pack('C*') # => "\x00\x01\xFF"
- s = [0, 1, -1].pack('C*') # => "\x00\x01\xFF"
- s.unpack('C*') # => [0, 1, 255]
-
-==== 16-Bit \Integer Directives
-
-- <tt>'s'</tt> - 16-bit signed integer, native-endian
- (like C <tt>int16_t</tt>):
-
- [513, -514].pack('s*') # => "\x01\x02\xFE\xFD"
- s = [513, 65022].pack('s*') # => "\x01\x02\xFE\xFD"
- s.unpack('s*') # => [513, -514]
-
-- <tt>'S'</tt> - 16-bit unsigned integer, native-endian
- (like C <tt>uint16_t</tt>):
-
- [513, -514].pack('S*') # => "\x01\x02\xFE\xFD"
- s = [513, 65022].pack('S*') # => "\x01\x02\xFE\xFD"
- s.unpack('S*') # => [513, 65022]
-
-- <tt>'n'</tt> - 16-bit network integer, big-endian:
-
- s = [0, 1, -1, 32767, -32768, 65535].pack('n*')
- # => "\x00\x00\x00\x01\xFF\xFF\x7F\xFF\x80\x00\xFF\xFF"
- s.unpack('n*')
- # => [0, 1, 65535, 32767, 32768, 65535]
-
-- <tt>'v'</tt> - 16-bit VAX integer, little-endian:
-
- s = [0, 1, -1, 32767, -32768, 65535].pack('v*')
- # => "\x00\x00\x01\x00\xFF\xFF\xFF\x7F\x00\x80\xFF\xFF"
- s.unpack('v*')
- # => [0, 1, 65535, 32767, 32768, 65535]
-
-==== 32-Bit \Integer Directives
-
-- <tt>'l'</tt> - 32-bit signed integer, native-endian
- (like C <tt>int32_t</tt>):
-
- s = [67305985, -50462977].pack('l*')
- # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
- s.unpack('l*')
- # => [67305985, -50462977]
-
-- <tt>'L'</tt> - 32-bit unsigned integer, native-endian
- (like C <tt>uint32_t</tt>):
-
- s = [67305985, 4244504319].pack('L*')
- # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
- s.unpack('L*')
- # => [67305985, 4244504319]
-
-- <tt>'N'</tt> - 32-bit network integer, big-endian:
-
- s = [0,1,-1].pack('N*')
- # => "\x00\x00\x00\x00\x00\x00\x00\x01\xFF\xFF\xFF\xFF"
- s.unpack('N*')
- # => [0, 1, 4294967295]
-
-- <tt>'V'</tt> - 32-bit VAX integer, little-endian:
-
- s = [0,1,-1].pack('V*')
- # => "\x00\x00\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF"
- s.unpack('v*')
- # => [0, 0, 1, 0, 65535, 65535]
-
-==== 64-Bit \Integer Directives
-
-- <tt>'q'</tt> - 64-bit signed integer, native-endian
- (like C <tt>int64_t</tt>):
-
- s = [578437695752307201, -506097522914230529].pack('q*')
- # => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8"
- s.unpack('q*')
- # => [578437695752307201, -506097522914230529]
-
-- <tt>'Q'</tt> - 64-bit unsigned integer, native-endian
- (like C <tt>uint64_t</tt>):
-
- s = [578437695752307201, 17940646550795321087].pack('Q*')
- # => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8"
- s.unpack('Q*')
- # => [578437695752307201, 17940646550795321087]
-
-==== Platform-Dependent \Integer Directives
-
-- <tt>'i'</tt> - Platform-dependent width signed integer,
- native-endian (like C <tt>int</tt>):
-
- s = [67305985, -50462977].pack('i*')
- # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
- s.unpack('i*')
- # => [67305985, -50462977]
-
-- <tt>'I'</tt> - Platform-dependent width unsigned integer,
- native-endian (like C <tt>unsigned int</tt>):
-
- s = [67305985, -50462977].pack('I*')
- # => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC"
- s.unpack('I*')
- # => [67305985, 4244504319]
-
-==== Pointer Directives
-
-- <tt>'j'</tt> - 64-bit pointer-width signed integer,
- native-endian (like C <tt>intptr_t</tt>):
-
- s = [67305985, -50462977].pack('j*')
- # => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\xFF\xFF\xFF\xFF"
- s.unpack('j*')
- # => [67305985, -50462977]
-
-- <tt>'j'</tt> - 64-bit pointer-width unsigned integer,
- native-endian (like C <tt>uintptr_t</tt>):
-
- s = [67305985, 4244504319].pack('J*')
- # => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\x00\x00\x00\x00"
- s.unpack('J*')
- # => [67305985, 4244504319]
-
-==== Other \Integer Directives
-:
-- <tt>'U'</tt> - UTF-8 character:
-
- s = [4194304].pack('U*')
- # => "\xF8\x90\x80\x80\x80"
- s.unpack('U*')
- # => [4194304]
-
-- <tt>'w'</tt> - BER-encoded integer
- (see {BER enocding}[https://en.wikipedia.org/wiki/X.690#BER_encoding]):
-
- s = [1073741823].pack('w*')
- # => "\x83\xFF\xFF\xFF\x7F"
- s.unpack('w*')
- # => [1073741823]
-
-==== Modifiers for \Integer Directives
-
-For directives in
-<tt>'i'</tt>,
-<tt>'I'</tt>,
-<tt>'s'</tt>,
-<tt>'S'</tt>,
-<tt>'l'</tt>,
-<tt>'L'</tt>,
-<tt>'q'</tt>,
-<tt>'Q'</tt>,
-<tt>'j'</tt>, and
-<tt>'J'</tt>,
-these modifiers may be suffixed:
-
-- <tt>'!'</tt> or <tt>'_'</tt> - Underlying platform’s native size.
-- <tt>'>'</tt> - Big-endian.
-- <tt>'<'</tt> - Little-endian.
-
-=== \Float Directives
-
-Each float directive specifies the packing or unpacking
-for one element in the input or output array.
-
-==== Single-Precision \Float Directives
-
-- <tt>'F'</tt> or <tt>'f'</tt> - Native format:
-
- s = [3.0].pack('F') # => "\x00\x00@@"
- s.unpack('F') # => [3.0]
-
-- <tt>'e'</tt> - Little-endian:
-
- s = [3.0].pack('e') # => "\x00\x00@@"
- s.unpack('e') # => [3.0]
-
-- <tt>'g'</tt> - Big-endian:
-
- s = [3.0].pack('g') # => "@@\x00\x00"
- s.unpack('g') # => [3.0]
-
-==== Double-Precision \Float Directives
-
-- <tt>'D'</tt> or <tt>'d'</tt> - Native format:
-
- s = [3.0].pack('D') # => "\x00\x00\x00\x00\x00\x00\b@"
- s.unpack('D') # => [3.0]
-
-- <tt>'E'</tt> - Little-endian:
-
- s = [3.0].pack('E') # => "\x00\x00\x00\x00\x00\x00\b@"
- s.unpack('E') # => [3.0]
-
-- <tt>'G'</tt> - Big-endian:
-
- s = [3.0].pack('G') # => "@\b\x00\x00\x00\x00\x00\x00"
- s.unpack('G') # => [3.0]
-
-A float directive may be infinity or not-a-number:
-
- inf = 1.0/0.0 # => Infinity
- [inf].pack('f') # => "\x00\x00\x80\x7F"
- "\x00\x00\x80\x7F".unpack('f') # => [Infinity]
-
- nan = inf/inf # => NaN
- [nan].pack('f') # => "\x00\x00\xC0\x7F"
- "\x00\x00\xC0\x7F".unpack('f') # => [NaN]
-
-=== \String Directives
-
-Each string directive specifies the packing or unpacking
-for one byte in the input or output string.
-
-==== Binary \String Directives
-
-- <tt>'A'</tt> - Arbitrary binary string (space padded; count is width);
- +nil+ is treated as the empty string:
-
- ['foo'].pack('A') # => "f"
- ['foo'].pack('A*') # => "foo"
- ['foo'].pack('A2') # => "fo"
- ['foo'].pack('A4') # => "foo "
- [nil].pack('A') # => " "
- [nil].pack('A*') # => ""
- [nil].pack('A2') # => " "
- [nil].pack('A4') # => " "
-
- "foo\0".unpack('A') # => ["f"]
- "foo\0".unpack('A4') # => ["foo"]
- "foo\0bar".unpack('A10') # => ["foo\x00bar"] # Reads past "\0".
- "foo ".unpack('A') # => ["f"]
- "foo ".unpack('A4') # => ["foo"]
- "foo".unpack('A4') # => ["foo"]
-
- russian = "\u{442 435 441 442}" # => "теÑÑ‚"
- russian.size # => 4
- russian.bytesize # => 8
- [russian].pack('A') # => "\xD1"
- [russian].pack('A*') # => "\xD1\x82\xD0\xB5\xD1\x81\xD1\x82"
- russian.unpack('A') # => ["\xD1"]
- russian.unpack('A2') # => ["\xD1\x82"]
- russian.unpack('A4') # => ["\xD1\x82\xD0\xB5"]
- russian.unpack('A*') # => ["\xD1\x82\xD0\xB5\xD1\x81\xD1\x82"]
-
-- <tt>'a'</tt> - Arbitrary binary string (null padded; count is width):
-
- ["foo"].pack('a') # => "f"
- ["foo"].pack('a*') # => "foo"
- ["foo"].pack('a2') # => "fo"
- ["foo\0"].pack('a4') # => "foo\x00"
- [nil].pack('a') # => "\x00"
- [nil].pack('a*') # => ""
- [nil].pack('a2') # => "\x00\x00"
- [nil].pack('a4') # => "\x00\x00\x00\x00"
-
- "foo\0".unpack('a') # => ["f"]
- "foo\0".unpack('a4') # => ["foo\x00"]
- "foo ".unpack('a4') # => ["foo "]
- "foo".unpack('a4') # => ["foo"]
- "foo\0bar".unpack('a4') # => ["foo\x00"] # Reads past "\0".
-
-- <tt>'Z'</tt> - Same as <tt>'a'</tt>,
- except that null is added or ignored with <tt>'*'</tt>:
-
- ["foo"].pack('Z*') # => "foo\x00"
- [nil].pack('Z*') # => "\x00"
-
- "foo\0".unpack('Z*') # => ["foo"]
- "foo".unpack('Z*') # => ["foo"]
- "foo\0bar".unpack('Z*') # => ["foo"] # Does not read past "\0".
-
-==== Bit \String Directives
-
-- <tt>'B'</tt> - Bit string (high byte first):
-
- ['11111111' + '00000000'].pack('B*') # => "\xFF\x00"
- ['10000000' + '01000000'].pack('B*') # => "\x80@"
-
- ['1'].pack('B0') # => ""
- ['1'].pack('B1') # => "\x80"
- ['1'].pack('B2') # => "\x80\x00"
- ['1'].pack('B3') # => "\x80\x00"
- ['1'].pack('B4') # => "\x80\x00\x00"
- ['1'].pack('B5') # => "\x80\x00\x00"
- ['1'].pack('B6') # => "\x80\x00\x00\x00"
-
- "\xff\x00".unpack("B*") # => ["1111111100000000"]
- "\x01\x02".unpack("B*") # => ["0000000100000010"]
-
- "".unpack("B0") # => [""]
- "\x80".unpack("B1") # => ["1"]
- "\x80".unpack("B2") # => ["10"]
- "\x80".unpack("B3") # => ["100"]
-
-- <tt>'b'</tt> - Bit string (low byte first):
-
- ['11111111' + '00000000'].pack('b*') # => "\xFF\x00"
- ['10000000' + '01000000'].pack('b*') # => "\x01\x02"
-
- ['1'].pack('b0') # => ""
- ['1'].pack('b1') # => "\x01"
- ['1'].pack('b2') # => "\x01\x00"
- ['1'].pack('b3') # => "\x01\x00"
- ['1'].pack('b4') # => "\x01\x00\x00"
- ['1'].pack('b5') # => "\x01\x00\x00"
- ['1'].pack('b6') # => "\x01\x00\x00\x00"
-
- "\xff\x00".unpack("b*") # => ["1111111100000000"]
- "\x01\x02".unpack("b*") # => ["1000000001000000"]
-
- "".unpack("b0") # => [""]
- "\x01".unpack("b1") # => ["1"]
- "\x01".unpack("b2") # => ["10"]
- "\x01".unpack("b3") # => ["100"]
-
-==== Hex \String Directives
-
-- <tt>'H'</tt> - Hex string (high nibble first):
-
- ['10ef'].pack('H*') # => "\x10\xEF"
- ['10ef'].pack('H0') # => ""
- ['10ef'].pack('H3') # => "\x10\xE0"
- ['10ef'].pack('H5') # => "\x10\xEF\x00"
-
- ['fff'].pack('H3') # => "\xFF\xF0"
- ['fff'].pack('H4') # => "\xFF\xF0"
- ['fff'].pack('H5') # => "\xFF\xF0\x00"
- ['fff'].pack('H6') # => "\xFF\xF0\x00"
- ['fff'].pack('H7') # => "\xFF\xF0\x00\x00"
- ['fff'].pack('H8') # => "\xFF\xF0\x00\x00"
-
- "\x10\xef".unpack('H*') # => ["10ef"]
- "\x10\xef".unpack('H0') # => [""]
- "\x10\xef".unpack('H1') # => ["1"]
- "\x10\xef".unpack('H2') # => ["10"]
- "\x10\xef".unpack('H3') # => ["10e"]
- "\x10\xef".unpack('H4') # => ["10ef"]
- "\x10\xef".unpack('H5') # => ["10ef"]
-
-- <tt>'h'</tt> - Hex string (low nibble first):
-
- ['10ef'].pack('h*') # => "\x01\xFE"
- ['10ef'].pack('h0') # => ""
- ['10ef'].pack('h3') # => "\x01\x0E"
- ['10ef'].pack('h5') # => "\x01\xFE\x00"
-
- ['fff'].pack('h3') # => "\xFF\x0F"
- ['fff'].pack('h4') # => "\xFF\x0F"
- ['fff'].pack('h5') # => "\xFF\x0F\x00"
- ['fff'].pack('h6') # => "\xFF\x0F\x00"
- ['fff'].pack('h7') # => "\xFF\x0F\x00\x00"
- ['fff'].pack('h8') # => "\xFF\x0F\x00\x00"
-
- "\x01\xfe".unpack('h*') # => ["10ef"]
- "\x01\xfe".unpack('h0') # => [""]
- "\x01\xfe".unpack('h1') # => ["1"]
- "\x01\xfe".unpack('h2') # => ["10"]
- "\x01\xfe".unpack('h3') # => ["10e"]
- "\x01\xfe".unpack('h4') # => ["10ef"]
- "\x01\xfe".unpack('h5') # => ["10ef"]
-
-==== Pointer \String Directives
-
-- <tt>'P'</tt> - Pointer to a structure (fixed-length string):
-
- s = ['abc'].pack('P') # => "\xE0O\x7F\xE5\xA1\x01\x00\x00"
- s.unpack('P*') # => ["abc"]
- ".".unpack("P") # => []
- ("\0" * 8).unpack("P") # => [nil]
- [nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
-
-- <tt>'p'</tt> - Pointer to a null-terminated string:
-
- s = ['abc'].pack('p') # => "(\xE4u\xE5\xA1\x01\x00\x00"
- s.unpack('p*') # => ["abc"]
- ".".unpack("p") # => []
- ("\0" * 8).unpack("p") # => [nil]
- [nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
-
-==== Other \String Directives
-
-- <tt>'M'</tt> - Quoted printable, MIME encoding;
- text mode, but input must use LF and output LF;
- (see {RFC 2045}[https://www.ietf.org/rfc/rfc2045.txt]):
-
- ["a b c\td \ne"].pack('M') # => "a b c\td =\n\ne=\n"
- ["\0"].pack('M') # => "=00=\n"
-
- ["a"*1023].pack('M') == ("a"*73+"=\n")*14+"a=\n" # => true
- ("a"*73+"=\na=\n").unpack('M') == ["a"*74] # => true
- (("a"*73+"=\n")*14+"a=\n").unpack('M') == ["a"*1023] # => true
-
- "a b c\td =\n\ne=\n".unpack('M') # => ["a b c\td \ne"]
- "=00=\n".unpack('M') # => ["\x00"]
-
- "pre=31=32=33after".unpack('M') # => ["pre123after"]
- "pre=\nafter".unpack('M') # => ["preafter"]
- "pre=\r\nafter".unpack('M') # => ["preafter"]
- "pre=".unpack('M') # => ["pre="]
- "pre=\r".unpack('M') # => ["pre=\r"]
- "pre=hoge".unpack('M') # => ["pre=hoge"]
- "pre==31after".unpack('M') # => ["pre==31after"]
- "pre===31after".unpack('M') # => ["pre===31after"]
-
-- <tt>'m'</tt> - Base64 encoded string;
- count specifies input bytes between each newline,
- rounded down to nearest multiple of 3;
- if count is zero, no newlines are added;
- (see {RFC 4648}[https://www.ietf.org/rfc/rfc4648.txt]):
-
- [""].pack('m') # => ""
- ["\0"].pack('m') # => "AA==\n"
- ["\0\0"].pack('m') # => "AAA=\n"
- ["\0\0\0"].pack('m') # => "AAAA\n"
- ["\377"].pack('m') # => "/w==\n"
- ["\377\377"].pack('m') # => "//8=\n"
- ["\377\377\377"].pack('m') # => "////\n"
-
- "".unpack('m') # => [""]
- "AA==\n".unpack('m') # => ["\x00"]
- "AAA=\n".unpack('m') # => ["\x00\x00"]
- "AAAA\n".unpack('m') # => ["\x00\x00\x00"]
- "/w==\n".unpack('m') # => ["\xFF"]
- "//8=\n".unpack('m') # => ["\xFF\xFF"]
- "////\n".unpack('m') # => ["\xFF\xFF\xFF"]
- "A\n".unpack('m') # => [""]
- "AA\n".unpack('m') # => ["\x00"]
- "AA=\n".unpack('m') # => ["\x00"]
- "AAA\n".unpack('m') # => ["\x00\x00"]
-
- [""].pack('m0') # => ""
- ["\0"].pack('m0') # => "AA=="
- ["\0\0"].pack('m0') # => "AAA="
- ["\0\0\0"].pack('m0') # => "AAAA"
- ["\377"].pack('m0') # => "/w=="
- ["\377\377"].pack('m0') # => "//8="
- ["\377\377\377"].pack('m0') # => "////"
-
- "".unpack('m0') # => [""]
- "AA==".unpack('m0') # => ["\x00"]
- "AAA=".unpack('m0') # => ["\x00\x00"]
- "AAAA".unpack('m0') # => ["\x00\x00\x00"]
- "/w==".unpack('m0') # => ["\xFF"]
- "//8=".unpack('m0') # => ["\xFF\xFF"]
- "////".unpack('m0') # => ["\xFF\xFF\xFF"]
-
-- <tt>'u'</tt> - UU-encoded string:
-
- [0].pack("U") # => "\u0000"
- [0x3fffffff].pack("U") # => "\xFC\xBF\xBF\xBF\xBF\xBF"
- [0x40000000].pack("U") # => "\xFD\x80\x80\x80\x80\x80"
- [0x7fffffff].pack("U") # => "\xFD\xBF\xBF\xBF\xBF\xBF"
-
-=== Offset Directives
-
-- <tt>'@'</tt> - Begin packing at the given byte offset;
- for packing, null fill if necessary:
-
- [1, 2].pack("C@0C") # => "\x02"
- [1, 2].pack("C@1C") # => "\x01\x02"
- [1, 2].pack("C@5C") # => "\x01\x00\x00\x00\x00\x02"
-
- "\x01\x00\x00\x02".unpack("C@3C") # => [1, 2]
- "\x00".unpack("@1C") # => [nil]
-
-- <tt>'X'</tt> - Back up a byte:
-
- [0, 1, 2].pack("CCXC") # => "\x00\x02"
- [0, 1, 2].pack("CCX2C") # => "\x02"
- "\x00\x02".unpack("CCXC") # => [0, 2, 2]
-
-=== Null Byte Direcive
-
-- <tt>'x'</tt> - Null byte:
-
- [].pack("x0") # => ""
- [].pack("x") # => "\x00"
- [].pack("x8") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x02".unpack("CxC") # => [0, 2]
diff --git a/doc/pty/README.expect.ja b/doc/pty/README.expect.ja
index 7c0456f24f..a4eb6b01df 100644
--- a/doc/pty/README.expect.ja
+++ b/doc/pty/README.expect.ja
@@ -1,21 +1,23 @@
- README for expect
+= README for expect
by A. Ito, 28 October, 1998
- Expectライブラリã¯ï¼Œtcl ã® expect パッケージã¨ä¼¼ãŸã‚ˆã†ãªæ©Ÿèƒ½ã‚’
+Expectライブラリã¯ï¼Œtcl ã® expect パッケージã¨ä¼¼ãŸã‚ˆã†ãªæ©Ÿèƒ½ã‚’
IOクラスã«è¿½åŠ ã—ã¾ã™ï¼Ž
- 追加ã•れるメソッドã®ä½¿ã„æ–¹ã¯æ¬¡ã®é€šã‚Šã§ã™ï¼Ž
+追加ã•れるメソッドã®ä½¿ã„æ–¹ã¯æ¬¡ã®é€šã‚Šã§ã™ï¼Ž
- IO#expect(pattern,timeout=9999999)
+[IO#expect(pattern,timeout=9999999)]
-pattern 㯠String ã‹ Regexp ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ï¼Œtimeout 㯠Fixnum
-ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã§ã™ï¼Žtimeout ã¯çœç•¥ã§ãã¾ã™ï¼Ž
- ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒãƒ–ロックãªã—ã§å‘¼ã°ã‚ŒãŸå ´åˆï¼Œã¾ãšãƒ¬ã‚·ãƒ¼ãƒã§ã‚ã‚‹
-IOオブジェクトã‹ã‚‰ pattern ã«ãƒžãƒƒãƒã™ã‚‹ãƒ‘ターンãŒèª­ã¿ã“ã¾ã‚Œã‚‹
-ã¾ã§å¾…ã¡ã¾ã™ï¼Žãƒ‘ターンãŒå¾—られãŸã‚‰ï¼Œãã®ãƒ‘ターンã«é–¢ã™ã‚‹é…列を
-è¿”ã—ã¾ã™ï¼Žé…åˆ—ã®æœ€åˆã®è¦ç´ ã¯ï¼Œpattern ã«ãƒžãƒƒãƒã™ã‚‹ã¾ã§ã«èª­ã¿ã“
-ã¾ã‚ŒãŸå†…å®¹ã®æ–‡å­—列ã§ã™ï¼Ž2番目以é™ã®è¦ç´ ã¯ï¼Œpattern ã®æ­£è¦è¡¨ç¾
-ã®ä¸­ã«ã‚¢ãƒ³ã‚«ãƒ¼ãŒã‚ã£ãŸå ´åˆã«ï¼Œãã®ã‚¢ãƒ³ã‚«ãƒ¼ã«ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã§ã™ï¼Ž
-ã‚‚ã—タイムアウトãŒèµ·ããŸå ´åˆã¯ï¼Œã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯nilã‚’è¿”ã—ã¾ã™ï¼Ž
- ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒãƒ–ロック付ãã§å‘¼ã°ã‚ŒãŸå ´åˆã«ã¯ï¼Œãƒžãƒƒãƒã—ãŸè¦ç´ ã®
-é…列ãŒãƒ–ロック引数ã¨ã—ã¦æ¸¡ã•れ,ブロックãŒè©•価ã•れã¾ã™ï¼Ž
+ _pattern_ 㯠String ã‹ Regexp ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ï¼Œ_timeout_ 㯠Fixnum
+ ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã§ã™ï¼Ž_timeout_ ã¯çœç•¥ã§ãã¾ã™ï¼Ž
+
+ ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒãƒ–ロックãªã—ã§å‘¼ã°ã‚ŒãŸå ´åˆï¼Œã¾ãšãƒ¬ã‚·ãƒ¼ãƒã§ã‚ã‚‹
+ IOオブジェクトã‹ã‚‰ _pattern_ ã«ãƒžãƒƒãƒã™ã‚‹ãƒ‘ターンãŒèª­ã¿ã“ã¾ã‚Œã‚‹
+ ã¾ã§å¾…ã¡ã¾ã™ï¼Žãƒ‘ターンãŒå¾—られãŸã‚‰ï¼Œãã®ãƒ‘ターンã«é–¢ã™ã‚‹é…列を
+ è¿”ã—ã¾ã™ï¼Žé…åˆ—ã®æœ€åˆã®è¦ç´ ã¯ï¼Œ_pattern_ ã«ãƒžãƒƒãƒã™ã‚‹ã¾ã§ã«èª­ã¿ã“
+ ã¾ã‚ŒãŸå†…å®¹ã®æ–‡å­—列ã§ã™ï¼Ž2番目以é™ã®è¦ç´ ã¯ï¼Œ_pattern_ ã®æ­£è¦è¡¨ç¾
+ ã®ä¸­ã«ã‚¢ãƒ³ã‚«ãƒ¼ãŒã‚ã£ãŸå ´åˆã«ï¼Œãã®ã‚¢ãƒ³ã‚«ãƒ¼ã«ãƒžãƒƒãƒã™ã‚‹éƒ¨åˆ†ã§ã™ï¼Ž
+ ã‚‚ã—タイムアウトãŒèµ·ããŸå ´åˆã¯ï¼Œã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ +nil+ ã‚’è¿”ã—ã¾ã™ï¼Ž
+
+ ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ãŒãƒ–ロック付ãã§å‘¼ã°ã‚ŒãŸå ´åˆã«ã¯ï¼Œãƒžãƒƒãƒã—ãŸè¦ç´ ã®
+ é…列ãŒãƒ–ロック引数ã¨ã—ã¦æ¸¡ã•れ,ブロックãŒè©•価ã•れã¾ã™ï¼Ž
diff --git a/doc/pty/README.ja b/doc/pty/README.ja
index 2d83ffa033..a26b4932ff 100644
--- a/doc/pty/README.ja
+++ b/doc/pty/README.ja
@@ -1,27 +1,26 @@
-pty 拡張モジュール version 0.3 by A.ito
+= pty 拡張モジュール version 0.3 by A.ito
1. ã¯ã˜ã‚ã«
-ã“ã®æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯ï¼Œä»®æƒ³tty (pty) を通ã—ã¦é©å½“ãªã‚³ãƒžãƒ³ãƒ‰ã‚’
-実行ã™ã‚‹æ©Ÿèƒ½ã‚’ ruby ã«æä¾›ã—ã¾ã™ï¼Ž
+ ã“ã®æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯ï¼Œä»®æƒ³tty (pty) を通ã—ã¦é©å½“ãªã‚³ãƒžãƒ³ãƒ‰ã‚’
+ 実行ã™ã‚‹æ©Ÿèƒ½ã‚’ ruby ã«æä¾›ã—ã¾ã™ï¼Ž
2. インストール
-次ã®ã‚ˆã†ã«ã—ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ã¦ãã ã•ã„.
+ 次ã®ã‚ˆã†ã«ã—ã¦ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ã¦ãã ã•ã„.
-(1) ruby extconf.rb
+ 1. <tt>ruby extconf.rb</tt>
+ を実行ã™ã‚‹ã¨ Makefile ãŒç”Ÿæˆã•れã¾ã™ï¼Ž
- を実行ã™ã‚‹ã¨ Makefile ãŒç”Ÿæˆã•れã¾ã™ï¼Ž
-
-(2) make; make install を実行ã—ã¦ãã ã•ã„.
+ 2. <tt>make; make install</tt> を実行ã—ã¦ãã ã•ã„.
3. 何ãŒã§ãã‚‹ã‹
-ã“ã®æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯ï¼ŒPTY ã¨ã„ã†ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’定義ã—ã¾ã™ï¼Žãã®ä¸­
-ã«ã¯ï¼Œæ¬¡ã®ã‚ˆã†ãªãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«é–¢æ•°ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ï¼Ž
+ ã“ã®æ‹¡å¼µãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã¯ï¼ŒPTY ã¨ã„ã†ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã‚’定義ã—ã¾ã™ï¼Žãã®ä¸­
+ ã«ã¯ï¼Œæ¬¡ã®ã‚ˆã†ãªãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«é–¢æ•°ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ï¼Ž
- getpty(command)
- spawn(command)
+ [PTY.getpty(command)]
+ [PTY.spawn(command)]
ã“ã®é–¢æ•°ã¯ï¼Œä»®æƒ³ttyを確ä¿ã—,指定ã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’ãã®ä»®æƒ³tty
ã®å‘ã“ã†ã§å®Ÿè¡Œã—,é…列を返ã—ã¾ã™ï¼Žæˆ»ã‚Šå€¤ã¯3ã¤ã®è¦ç´ ã‹ã‚‰ãªã‚‹
@@ -35,12 +34,7 @@ pty 拡張モジュール version 0.3 by A.ito
ã®ã¿ä¾‹å¤–ãŒç™ºç”Ÿã—ã¾ã™ï¼Žå­ãƒ—ロセスをモニターã—ã¦ã„るスレッドã¯ãƒ–ロッ
クを抜ã‘ã‚‹ã¨ãã«çµ‚了ã—ã¾ã™ï¼Ž
- protect_signal
- reset_signal
-
- 廃止予定ã§ã™ï¼Ž
-
- PTY.open
+ [PTY.open]
仮想ttyを確ä¿ã—,マスターå´ã«å¯¾å¿œã™ã‚‹IOオブジェクトã¨ã‚¹ãƒ¬ãƒ¼ãƒ–å´ã«
対応ã™ã‚‹Fileオブジェクトã®é…列を返ã—ã¾ã™ï¼Žãƒ–ロック付ãã§å‘¼ã³å‡ºã•
@@ -48,7 +42,7 @@ pty 拡張モジュール version 0.3 by A.ito
クã‹ã‚‰è¿”ã•れãŸçµæžœã‚’è¿”ã—ã¾ã™ï¼Žã¾ãŸã€ã“ã®ãƒžã‚¹ã‚¿ãƒ¼IOã¨ã‚¹ãƒ¬ãƒ¼ãƒ–File
ã¯ã€ãƒ–ロックを抜ã‘ã‚‹ã¨ãã«ã‚¯ãƒ­ãƒ¼ã‚ºæ¸ˆã¿ã§ãªã‘れã°ã‚¯ãƒ­ãƒ¼ã‚ºã•れã¾ã™ï¼Ž
- PTY.check(pid[, raise=false])
+ [PTY.check(pid[, raise=false])]
pidã§æŒ‡å®šã•れãŸå­ãƒ—ロセスã®çŠ¶æ…‹ã‚’ãƒã‚§ãƒƒã‚¯ã—,実行中ã§ã‚れã°nilã‚’
è¿”ã—ã¾ã™ï¼Žçµ‚了ã—ã¦ã„ã‚‹ã‹åœæ­¢ã—ã¦ã„ã‚‹å ´åˆã€ç¬¬äºŒå¼•æ•°ãŒå½ã§ã‚れã°ã€
@@ -57,20 +51,20 @@ pty 拡張モジュール version 0.3 by A.ito
4. 利用ã«ã¤ã„ã¦
-伊藤彰則ãŒè‘—ä½œæ¨©ã‚’ä¿æœ‰ã—ã¾ã™ï¼Ž
+ 伊藤彰則ãŒè‘—ä½œæ¨©ã‚’ä¿æœ‰ã—ã¾ã™ï¼Ž
-ソースプログラムã¾ãŸã¯ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã«å…ƒã®è‘—ä½œæ¨©è¡¨ç¤ºãŒæ”¹å¤‰ã•れãšã«
-表示ã•れã¦ã„ã‚‹å ´åˆã«é™ã‚Šï¼Œèª°ã§ã‚‚,ã“ã®ã‚½ãƒ•トウェアを無償ã‹ã¤è‘—作
-権者ã«ç„¡æ–­ã§åˆ©ç”¨ãƒ»é…布・改変ã§ãã¾ã™ï¼Žåˆ©ç”¨ç›®çš„ã¯é™å®šã•れã¦ã„ã¾ã›
-ん.
+ ソースプログラムã¾ãŸã¯ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã«å…ƒã®è‘—ä½œæ¨©è¡¨ç¤ºãŒæ”¹å¤‰ã•れãšã«
+ 表示ã•れã¦ã„ã‚‹å ´åˆã«é™ã‚Šï¼Œèª°ã§ã‚‚,ã“ã®ã‚½ãƒ•トウェアを無償ã‹ã¤è‘—作
+ 権者ã«ç„¡æ–­ã§åˆ©ç”¨ãƒ»é…布・改変ã§ãã¾ã™ï¼Žåˆ©ç”¨ç›®çš„ã¯é™å®šã•れã¦ã„ã¾ã›
+ ん.
-ã“ã®ãƒ—ログラムã®åˆ©ç”¨ãƒ»é…布ãã®ä»–ã“ã®ãƒ—ログラムã«é–¢ä¿‚ã™ã‚‹è¡Œç‚ºã«ã‚ˆ
-ã£ã¦ç”Ÿã˜ãŸã„ã‹ãªã‚‹æå®³ã«å¯¾ã—ã¦ã‚‚,作者ã¯ä¸€åˆ‡è²¬ä»»ã‚’è² ã„ã¾ã›ã‚“.
+ ã“ã®ãƒ—ログラムã®åˆ©ç”¨ãƒ»é…布ãã®ä»–ã“ã®ãƒ—ログラムã«é–¢ä¿‚ã™ã‚‹è¡Œç‚ºã«ã‚ˆ
+ ã£ã¦ç”Ÿã˜ãŸã„ã‹ãªã‚‹æå®³ã«å¯¾ã—ã¦ã‚‚,作者ã¯ä¸€åˆ‡è²¬ä»»ã‚’è² ã„ã¾ã›ã‚“.
5. ãƒã‚°å ±å‘Šç­‰
-ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆã¯æ­“迎ã—ã¾ã™ï¼Ž
+ ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆã¯æ­“迎ã—ã¾ã™ï¼Ž
aito@ei5sun.yz.yamagata-u.ac.jp
-ã¾ã§é›»å­ãƒ¡ãƒ¼ãƒ«ã§ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆã‚’ãŠé€ã‚Šãã ã•ã„.
+ ã¾ã§é›»å­ãƒ¡ãƒ¼ãƒ«ã§ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆã‚’ãŠé€ã‚Šãã ã•ã„.
diff --git a/doc/ractor.md b/doc/ractor.md
deleted file mode 100644
index 3ead510501..0000000000
--- a/doc/ractor.md
+++ /dev/null
@@ -1,952 +0,0 @@
-# Ractor - Ruby's Actor-like concurrent abstraction
-
-Ractor is designed to provide a parallel execution feature of Ruby without thread-safety concerns.
-
-## Summary
-
-### Multiple Ractors in an interpreter process
-
-You can make multiple Ractors and they run in parallel.
-
-* `Ractor.new{ expr }` creates a new Ractor and `expr` is run in parallel on a parallel computer.
-* Interpreter invokes with the first Ractor (called *main Ractor*).
-* If main Ractor terminated, all Ractors receive terminate request like Threads (if main thread (first invoked Thread), Ruby interpreter sends all running threads to terminate execution).
-* Each Ractor has 1 or more Threads.
- * Threads in a Ractor shares a Ractor-wide global lock like GIL (GVL in MRI terminology), so they can't run in parallel (without releasing GVL explicitly in C-level). Threads in different ractors run in parallel.
- * The overhead of creating a Ractor is similar to overhead of one Thread creation.
-
-### Limited sharing between multiple ractors
-
-Ractors don't share everything, unlike threads.
-
-* Most objects are *Unshareable objects*, so you don't need to care about thread-safety problems which are caused by sharing.
-* Some objects are *Shareable objects*.
- * Immutable objects: frozen objects which don't refer to unshareable-objects.
- * `i = 123`: `i` is an immutable object.
- * `s = "str".freeze`: `s` is an immutable object.
- * `a = [1, [2], 3].freeze`: `a` is not an immutable object because `a` refers unshareable-object `[2]` (which is not frozen).
- * `h = {c: Object}.freeze`: `h` is an immutable object because `h` refers Symbol `:c` and shareable `Object` class object which is not frozen.
- * Class/Module objects
- * Special shareable objects
- * Ractor object itself.
- * And more...
-
-### Two-types communication between Ractors
-
-Ractors communicate with each other and synchronize the execution by message exchanging between Ractors. There are two message exchange protocols: push type (message passing) and pull type.
-
-* Push type message passing: `Ractor#send(obj)` and `Ractor.receive()` pair.
- * Sender ractor passes the `obj` to the ractor `r` by `r.send(obj)` and receiver ractor receives the message with `Ractor.receive`.
- * Sender knows the destination Ractor `r` and the receiver does not know the sender (accept all messages from any ractors).
- * Receiver has infinite queue and sender enqueues the message. Sender doesn't block to put message into this queue.
- * This type of message exchanging is employed by many other Actor-based languages.
- * `Ractor.receive_if{ filter_expr }` is a variant of `Ractor.receive` to select a message.
-* Pull type communication: `Ractor.yield(obj)` and `Ractor#take()` pair.
- * Sender ractor declare to yield the `obj` by `Ractor.yield(obj)` and receiver Ractor take it with `r.take`.
- * Sender doesn't know a destination Ractor and receiver knows the sender Ractor `r`.
- * Sender or receiver will block if there is no other side.
-
-### Copy & Move semantics to send messages
-
-To send unshareable objects as messages, objects are copied or moved.
-
-* Copy: use deep-copy.
-* Move: move membership.
- * Sender can not access the moved object after moving the object.
- * Guarantee that at least only 1 Ractor can access the object.
-
-### Thread-safety
-
-Ractor helps to write a thread-safe concurrent program, but we can make thread-unsafe programs with Ractors.
-
-* GOOD: Sharing limitation
- * Most objects are unshareable, so we can't make data-racy and race-conditional programs.
- * Shareable objects are protected by an interpreter or locking mechanism.
-* BAD: Class/Module can violate this assumption
- * To make it compatible with old behavior, classes and modules can introduce data-race and so on.
- * Ruby programmers should take care if they modify class/module objects on multi Ractor programs.
-* BAD: Ractor can't solve all thread-safety problems
- * There are several blocking operations (waiting send, waiting yield and waiting take) so you can make a program which has dead-lock and live-lock issues.
- * Some kind of shareable objects can introduce transactions (STM, for example). However, misusing transactions will generate inconsistent state.
-
-Without Ractor, we need to trace all state-mutations to debug thread-safety issues.
-With Ractor, you can concentrate on suspicious code which are shared with Ractors.
-
-## Creation and termination
-
-### `Ractor.new`
-
-* `Ractor.new{ expr }` generates another Ractor.
-
-```ruby
-# Ractor.new with a block creates new Ractor
-r = Ractor.new do
- # This block will be run in parallel with other ractors
-end
-
-# You can name a Ractor with `name:` argument.
-r = Ractor.new name: 'test-name' do
-end
-
-# and Ractor#name returns its name.
-r.name #=> 'test-name'
-```
-
-### Given block isolation
-
-The Ractor executes given `expr` in a given block.
-Given block will be isolated from outer scope by the `Proc#isolate` method (not exposed yet for Ruby users). To prevent sharing unshareable objects between ractors, block outer-variables, `self` and other information are isolated.
-
-`Proc#isolate` is called at Ractor creation time (when `Ractor.new` is called). If given Proc object is not able to isolate because of outer variables and so on, an error will be raised.
-
-```ruby
-begin
- a = true
- r = Ractor.new do
- a #=> ArgumentError because this block accesses `a`.
- end
- r.take # see later
-rescue ArgumentError
-end
-```
-
-* The `self` of the given block is the `Ractor` object itself.
-
-```ruby
-r = Ractor.new do
- p self.class #=> Ractor
- self.object_id
-end
-r.take == self.object_id #=> false
-```
-
-Passed arguments to `Ractor.new()` becomes block parameters for the given block. However, an interpreter does not pass the parameter object references, but send them as messages (see below for details).
-
-```ruby
-r = Ractor.new 'ok' do |msg|
- msg #=> 'ok'
-end
-r.take #=> 'ok'
-```
-
-```ruby
-# almost similar to the last example
-r = Ractor.new do
- msg = Ractor.receive
- msg
-end
-r.send 'ok'
-r.take #=> 'ok'
-```
-
-### An execution result of given block
-
-Return value of the given block becomes an outgoing message (see below for details).
-
-```ruby
-r = Ractor.new do
- 'ok'
-end
-r.take #=> `ok`
-```
-
-```ruby
-# almost similar to the last example
-r = Ractor.new do
- Ractor.yield 'ok'
-end
-r.take #=> 'ok'
-```
-
-Error in the given block will be propagated to the receiver of an outgoing message.
-
-```ruby
-r = Ractor.new do
- raise 'ok' # exception will be transferred to the receiver
-end
-
-begin
- r.take
-rescue Ractor::RemoteError => e
- e.cause.class #=> RuntimeError
- e.cause.message #=> 'ok'
- e.ractor #=> r
-end
-```
-
-## Communication between Ractors
-
-Communication between Ractors is achieved by sending and receiving messages. There are two ways to communicate with each other.
-
-* (1) Message sending/receiving
- * (1-1) push type send/receive (sender knows receiver). Similar to the Actor model.
- * (1-2) pull type yield/take (receiver knows sender).
-* (2) Using shareable container objects
- * Ractor::TVar gem ([ko1/ractor-tvar](https://github.com/ko1/ractor-tvar))
- * more?
-
-Users can control program execution timing with (1), but should not control with (2) (only manage as critical section).
-
-For message sending and receiving, there are two types of APIs: push type and pull type.
-
-* (1-1) send/receive (push type)
- * `Ractor#send(obj)` (`Ractor#<<(obj)` is an alias) send a message to the Ractor's incoming port. Incoming port is connected to the infinite size incoming queue so `Ractor#send` will never block.
- * `Ractor.receive` dequeue a message from its own incoming queue. If the incoming queue is empty, `Ractor.receive` calling will block.
- * `Ractor.receive_if{|msg| filter_expr }` is variant of `Ractor.receive`. `receive_if` only receives a message which `filter_expr` is true (So `Ractor.receive` is the same as `Ractor.receive_if{ true }`.
-* (1-2) yield/take (pull type)
- * `Ractor.yield(obj)` send an message to a Ractor which are calling `Ractor#take` via outgoing port . If no Ractors are waiting for it, the `Ractor.yield(obj)` will block. If multiple Ractors are waiting for `Ractor.yield(obj)`, only one Ractor can receive the message.
- * `Ractor#take` receives a message which is waiting by `Ractor.yield(obj)` method from the specified Ractor. If the Ractor does not call `Ractor.yield` yet, the `Ractor#take` call will block.
-* `Ractor.select()` can wait for the success of `take`, `yield` and `receive`.
-* You can close the incoming port or outgoing port.
- * You can close then with `Ractor#close_incoming` and `Ractor#close_outgoing`.
- * If the incoming port is closed for a Ractor, you can't `send` to the Ractor. If `Ractor.receive` is blocked for the closed incoming port, then it will raise an exception.
- * If the outgoing port is closed for a Ractor, you can't call `Ractor#take` and `Ractor.yield` on the Ractor. If ractors are blocking by `Ractor#take` or `Ractor.yield`, closing outgoing port will raise an exception on these blocking ractors.
- * When a Ractor is terminated, the Ractor's ports are closed.
-* There are 3 ways to send an object as a message
- * (1) Send a reference: Sending a shareable object, send only a reference to the object (fast)
- * (2) Copy an object: Sending an unshareable object by copying an object deeply (slow). Note that you can not send an object which does not support deep copy. Some `T_DATA` objects are not supported.
- * (3) Move an object: Sending an unshareable object reference with a membership. Sender Ractor can not access moved objects anymore (raise an exception) after moving it. Current implementation makes new object as a moved object for receiver Ractor and copies references of sending object to moved object.
- * You can choose "Copy" and "Move" by the `move:` keyword, `Ractor#send(obj, move: true/false)` and `Ractor.yield(obj, move: true/false)` (default is `false` (COPY)).
-
-### Sending/Receiving ports
-
-Each Ractor has _incoming-port_ and _outgoing-port_. Incoming-port is connected to the infinite sized incoming queue.
-
-```
- Ractor r
- +-------------------------------------------+
- | incoming outgoing |
- | port port |
- r.send(obj) ->*->[incoming queue] Ractor.yield(obj) ->*-> r.take
- | | |
- | v |
- | Ractor.receive |
- +-------------------------------------------+
-
-
-Connection example: r2.send obj on r1ã€Ractor.receive on r2
- +----+ +----+
- * r1 |---->* r2 *
- +----+ +----+
-
-
-Connection example: Ractor.yield(obj) on r1, r1.take on r2
- +----+ +----+
- * r1 *---->- r2 *
- +----+ +----+
-
-Connection example: Ractor.yield(obj) on r1 and r2,
- and waiting for both simultaneously by Ractor.select(r1, r2)
-
- +----+
- * r1 *------+
- +----+ |
- +----> Ractor.select(r1, r2)
- +----+ |
- * r2 *------|
- +----+
-```
-
-```ruby
-r = Ractor.new do
- msg = Ractor.receive # Receive from r's incoming queue
- msg # send back msg as block return value
-end
-r.send 'ok' # Send 'ok' to r's incoming port -> incoming queue
-r.take # Receive from r's outgoing port
-```
-
-The last example shows the following ractor network.
-
-```
-
- +------+ +---+
- * main |------> * r *---+
- +------+ +---+ |
- ^ |
- +-------------------+
-```
-
-And this code can be simplified by using an argument for `Ractor.new`.
-
-```ruby
-# Actual argument 'ok' for `Ractor.new()` will be sent to created Ractor.
-r = Ractor.new 'ok' do |msg|
- # Values for formal parameters will be received from incoming queue.
- # Similar to: msg = Ractor.receive
-
- msg # Return value of the given block will be sent via outgoing port
-end
-
-# receive from the r's outgoing port.
-r.take #=> `ok`
-```
-
-### Return value of a block for `Ractor.new`
-
-As already explained, the return value of `Ractor.new` (an evaluated value of `expr` in `Ractor.new{ expr }`) can be taken by `Ractor#take`.
-
-```ruby
-Ractor.new{ 42 }.take #=> 42
-```
-
-When the block return value is available, the Ractor is dead so that no ractors except taken Ractor can touch the return value, so any values can be sent with this communication path without any modification.
-
-```ruby
-r = Ractor.new do
- a = "hello"
- binding
-end
-
-r.take.eval("p a") #=> "hello" (other communication path can not send a Binding object directly)
-```
-
-### Wait for multiple Ractors with `Ractor.select`
-
-You can wait multiple Ractor's `yield` with `Ractor.select(*ractors)`.
-The return value of `Ractor.select()` is `[r, msg]` where `r` is yielding Ractor and `msg` is yielded message.
-
-Wait for a single ractor (same as `Ractor.take`):
-
-```ruby
-r1 = Ractor.new{'r1'}
-
-r, obj = Ractor.select(r1)
-r == r1 and obj == 'r1' #=> true
-```
-
-Wait for two ractors:
-
-```ruby
-r1 = Ractor.new{'r1'}
-r2 = Ractor.new{'r2'}
-rs = [r1, r2]
-as = []
-
-# Wait for r1 or r2's Ractor.yield
-r, obj = Ractor.select(*rs)
-rs.delete(r)
-as << obj
-
-# Second try (rs only contain not-closed ractors)
-r, obj = Ractor.select(*rs)
-rs.delete(r)
-as << obj
-as.sort == ['r1', 'r2'] #=> true
-```
-
-Complex example:
-
-```ruby
-pipe = Ractor.new do
- loop do
- Ractor.yield Ractor.receive
- end
-end
-
-RN = 10
-rs = RN.times.map{|i|
- Ractor.new pipe, i do |pipe, i|
- msg = pipe.take
- msg # ping-pong
- end
-}
-RN.times{|i|
- pipe << i
-}
-RN.times.map{
- r, n = Ractor.select(*rs)
- rs.delete r
- n
-}.sort #=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-```
-
-Multiple Ractors can send to one Ractor.
-
-```ruby
-# Create 10 ractors and they send objects to pipe ractor.
-# pipe ractor yield received objects
-
-pipe = Ractor.new do
- loop do
- Ractor.yield Ractor.receive
- end
-end
-
-RN = 10
-rs = RN.times.map{|i|
- Ractor.new pipe, i do |pipe, i|
- pipe << i
- end
-}
-
-RN.times.map{
- pipe.take
-}.sort #=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-```
-
-TODO: Current `Ractor.select()` has the same issue of `select(2)`, so this interface should be refined.
-
-TODO: `select` syntax of go-language uses round-robin technique to make fair scheduling. Now `Ractor.select()` doesn't use it.
-
-### Closing Ractor's ports
-
-* `Ractor#close_incoming/outgoing` close incoming/outgoing ports (similar to `Queue#close`).
-* `Ractor#close_incoming`
- * `r.send(obj)` where `r`'s incoming port is closed, will raise an exception.
- * When the incoming queue is empty and incoming port is closed, `Ractor.receive` raises an exception. If the incoming queue is not empty, it dequeues an object without exceptions.
-* `Ractor#close_outgoing`
- * `Ractor.yield` on a Ractor which closed the outgoing port, it will raise an exception.
- * `Ractor#take` for a Ractor which closed the outgoing port, it will raise an exception. If `Ractor#take` is blocking, it will raise an exception.
-* When a Ractor terminates, the ports are closed automatically.
- * Return value of the Ractor's block will be yielded as `Ractor.yield(ret_val)`, even if the implementation terminates the based native thread.
-
-Example (try to take from closed Ractor):
-
-```ruby
-r = Ractor.new do
- 'finish'
-end
-r.take # success (will return 'finish')
-begin
- o = r.take # try to take from closed Ractor
-rescue Ractor::ClosedError
- 'ok'
-else
- "ng: #{o}"
-end
-```
-
-Example (try to send to closed (terminated) Ractor):
-
-```ruby
-r = Ractor.new do
-end
-
-r.take # wait terminate
-
-begin
- r.send(1)
-rescue Ractor::ClosedError
- 'ok'
-else
- 'ng'
-end
-```
-
-When multiple Ractors are waiting for `Ractor.yield()`, `Ractor#close_outgoing` will cancel all blocking by raising an exception (`ClosedError`).
-
-### Send a message by copying
-
-`Ractor#send(obj)` or `Ractor.yield(obj)` copy `obj` deeply if `obj` is an unshareable object.
-
-```ruby
-obj = 'str'.dup
-r = Ractor.new obj do |msg|
- # return received msg's object_id
- msg.object_id
-end
-
-obj.object_id == r.take #=> false
-```
-
-Some objects are not supported to copy the value, and raise an exception.
-
-```ruby
-obj = Thread.new{}
-begin
- Ractor.new obj do |msg|
- msg
- end
-rescue TypeError => e
- e.message #=> #<TypeError: allocator undefined for Thread>
-else
- 'ng' # unreachable here
-end
-```
-
-### Send a message by moving
-
-`Ractor#send(obj, move: true)` or `Ractor.yield(obj, move: true)` move `obj` to the destination Ractor.
-If the source Ractor touches the moved object (for example, call the method like `obj.foo()`), it will be an error.
-
-```ruby
-# move with Ractor#send
-r = Ractor.new do
- obj = Ractor.receive
- obj << ' world'
-end
-
-str = 'hello'
-r.send str, move: true
-modified = r.take #=> 'hello world'
-
-# str is moved, and accessing str from this Ractor is prohibited
-
-begin
- # Error because it touches moved str.
- str << ' exception' # raise Ractor::MovedError
-rescue Ractor::MovedError
- modified #=> 'hello world'
-else
- raise 'unreachable'
-end
-```
-
-```ruby
-# move with Ractor.yield
-r = Ractor.new do
- obj = 'hello'
- Ractor.yield obj, move: true
- obj << 'world' # raise Ractor::MovedError
-end
-
-str = r.take
-begin
- r.take
-rescue Ractor::RemoteError
- p str #=> "hello"
-end
-```
-
-Some objects are not supported to move, and an exception will be raised.
-
-```ruby
-r = Ractor.new do
- Ractor.receive
-end
-
-r.send(Thread.new{}, move: true) #=> allocator undefined for Thread (TypeError)
-```
-
-To achieve the access prohibition for moved objects, _class replacement_ technique is used to implement it.
-
-### Shareable objects
-
-The following objects are shareable.
-
-* Immutable objects
- * Small integers, some symbols, `true`, `false`, `nil` (a.k.a. `SPECIAL_CONST_P()` objects in internal)
- * Frozen native objects
- * Numeric objects: `Float`, `Complex`, `Rational`, big integers (`T_BIGNUM` in internal)
- * All Symbols.
- * Frozen `String` and `Regexp` objects (their instance variables should refer only shareable objects)
-* Class, Module objects (`T_CLASS`, `T_MODULE` and `T_ICLASS` in internal)
-* `Ractor` and other special objects which care about synchronization.
-
-Implementation: Now shareable objects (`RVALUE`) have `FL_SHAREABLE` flag. This flag can be added lazily.
-
-To make shareable objects, `Ractor.make_shareable(obj)` method is provided. In this case, try to make sharaeble by freezing `obj` and recursively traversable objects. This method accepts `copy:` keyword (default value is false).`Ractor.make_shareable(obj, copy: true)` tries to make a deep copy of `obj` and make the copied object shareable.
-
-## Language changes to isolate unshareable objects between Ractors
-
-To isolate unshareable objects between Ractors, we introduced additional language semantics on multi-Ractor Ruby programs.
-
-Note that without using Ractors, these additional semantics is not needed (100% compatible with Ruby 2).
-
-### Global variables
-
-Only the main Ractor (a Ractor created at starting of interpreter) can access global variables.
-
-```ruby
-$gv = 1
-r = Ractor.new do
- $gv
-end
-
-begin
- r.take
-rescue Ractor::RemoteError => e
- e.cause.message #=> 'can not access global variables from non-main Ractors'
-end
-```
-
-Note that some special global variables are ractor-local, like `$stdin`, `$stdout`, `$stderr`. See [[Bug #17268]](https://bugs.ruby-lang.org/issues/17268) for more details.
-
-### Instance variables of shareable objects
-
-Instance variables of classes/modules can be get from non-main Ractors if the referring values are shareable objects.
-
-```ruby
-class C
- @iv = 1
-end
-
-p Ractor.new do
- class C
- @iv
- end
-end.take #=> 1
-```
-
-Otherwise, only the main Ractor can access instance variables of shareable objects.
-
-```ruby
-class C
- @iv = [] # unshareable object
-end
-
-Ractor.new do
- class C
- begin
- p @iv
- rescue Ractor::IsolationError
- p $!.message
- #=> "can not get unshareable values from instance variables of classes/modules from non-main Ractors"
- end
-
- begin
- @iv = 42
- rescue Ractor::IsolationError
- p $!.message
- #=> "can not set instance variables of classes/modules by non-main Ractors"
- end
- end
-end.take
-```
-
-
-
-```ruby
-shared = Ractor.new{}
-shared.instance_variable_set(:@iv, 'str')
-
-r = Ractor.new shared do |shared|
- p shared.instance_variable_get(:@iv)
-end
-
-begin
- r.take
-rescue Ractor::RemoteError => e
- e.cause.message #=> can not access instance variables of shareable objects from non-main Ractors (Ractor::IsolationError)
-end
-```
-
-Note that instance variables for class/module objects are also prohibited on Ractors.
-
-### Class variables
-
-Only the main Ractor can access class variables.
-
-```ruby
-class C
- @@cv = 'str'
-end
-
-r = Ractor.new do
- class C
- p @@cv
- end
-end
-
-
-begin
- r.take
-rescue => e
- e.class #=> Ractor::IsolationError
-end
-```
-
-### Constants
-
-Only the main Ractor can read constants which refer to the unshareable object.
-
-```ruby
-class C
- CONST = 'str'
-end
-r = Ractor.new do
- C::CONST
-end
-begin
- r.take
-rescue => e
- e.class #=> Ractor::IsolationError
-end
-```
-
-Only the main Ractor can define constants which refer to the unshareable object.
-
-```ruby
-class C
-end
-r = Ractor.new do
- C::CONST = 'str'
-end
-begin
- r.take
-rescue => e
- e.class #=> Ractor::IsolationError
-end
-```
-
-To make multi-ractor supported library, the constants should only refer shareable objects.
-
-```ruby
-TABLE = {a: 'ko1', b: 'ko2', c: 'ko3'}
-```
-
-In this case, `TABLE` references an unshareable Hash object. So that other ractors can not refer `TABLE` constant. To make it shareable, we can use `Ractor.make_shareable()` like that.
-
-```ruby
-TABLE = Ractor.make_shareable( {a: 'ko1', b: 'ko2', c: 'ko3'} )
-```
-
-To make it easy, Ruby 3.0 introduced new `shareable_constant_value` Directive.
-
-```ruby
-# shareable_constant_value: literal
-
-TABLE = {a: 'ko1', b: 'ko2', c: 'ko3'}
-#=> Same as: TABLE = Ractor.make_shareable( {a: 'ko1', b: 'ko2', c: 'ko3'} )
-```
-
-`shareable_constant_value` directive accepts the following modes (descriptions use the example: `CONST = expr`):
-
-* none: Do nothing. Same as: `CONST = expr`
-* literal:
- * if `expr` consists of literals, replaced to `CONST = Ractor.make_shareable(expr)`.
- * otherwise: replaced to `CONST = expr.tap{|o| raise unless Ractor.shareable?(o)}`.
-* experimental_everything: replaced to `CONST = Ractor.make_shareable(expr)`.
-* experimental_copy: replaced to `CONST = Ractor.make_shareable(expr, copy: true)`.
-
-Except the `none` mode (default), it is guaranteed that the assigned constants refer to only shareable objects.
-
-See [doc/syntax/comments.rdoc](syntax/comments.rdoc) for more details.
-
-## Implementation note
-
-* Each Ractor has its own thread, it means each Ractor has at least 1 native thread.
-* Each Ractor has its own ID (`rb_ractor_t::pub::id`).
- * On debug mode, all unshareable objects are labeled with current Ractor's id, and it is checked to detect unshareable object leak (access an object from different Ractor) in VM.
-
-## Examples
-
-### Traditional Ring example in Actor-model
-
-```ruby
-RN = 1_000
-CR = Ractor.current
-
-r = Ractor.new do
- p Ractor.receive
- CR << :fin
-end
-
-RN.times{
- r = Ractor.new r do |next_r|
- next_r << Ractor.receive
- end
-}
-
-p :setup_ok
-r << 1
-p Ractor.receive
-```
-
-### Fork-join
-
-```ruby
-def fib n
- if n < 2
- 1
- else
- fib(n-2) + fib(n-1)
- end
-end
-
-RN = 10
-rs = (1..RN).map do |i|
- Ractor.new i do |i|
- [i, fib(i)]
- end
-end
-
-until rs.empty?
- r, v = Ractor.select(*rs)
- rs.delete r
- p answer: v
-end
-```
-
-### Worker pool
-
-```ruby
-require 'prime'
-
-pipe = Ractor.new do
- loop do
- Ractor.yield Ractor.receive
- end
-end
-
-N = 1000
-RN = 10
-workers = (1..RN).map do
- Ractor.new pipe do |pipe|
- while n = pipe.take
- Ractor.yield [n, n.prime?]
- end
- end
-end
-
-(1..N).each{|i|
- pipe << i
-}
-
-pp (1..N).map{
- _r, (n, b) = Ractor.select(*workers)
- [n, b]
-}.sort_by{|(n, b)| n}
-```
-
-### Pipeline
-
-```ruby
-# pipeline with yield/take
-r1 = Ractor.new do
- 'r1'
-end
-
-r2 = Ractor.new r1 do |r1|
- r1.take + 'r2'
-end
-
-r3 = Ractor.new r2 do |r2|
- r2.take + 'r3'
-end
-
-p r3.take #=> 'r1r2r3'
-```
-
-```ruby
-# pipeline with send/receive
-
-r3 = Ractor.new Ractor.current do |cr|
- cr.send Ractor.receive + 'r3'
-end
-
-r2 = Ractor.new r3 do |r3|
- r3.send Ractor.receive + 'r2'
-end
-
-r1 = Ractor.new r2 do |r2|
- r2.send Ractor.receive + 'r1'
-end
-
-r1 << 'r0'
-p Ractor.receive #=> "r0r1r2r3"
-```
-
-### Supervise
-
-```ruby
-# ring example again
-
-r = Ractor.current
-(1..10).map{|i|
- r = Ractor.new r, i do |r, i|
- r.send Ractor.receive + "r#{i}"
- end
-}
-
-r.send "r0"
-p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
-```
-
-```ruby
-# ring example with an error
-
-r = Ractor.current
-rs = (1..10).map{|i|
- r = Ractor.new r, i do |r, i|
- loop do
- msg = Ractor.receive
- raise if /e/ =~ msg
- r.send msg + "r#{i}"
- end
- end
-}
-
-r.send "r0"
-p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
-r.send "r0"
-p Ractor.select(*rs, Ractor.current) #=> [:receive, "r0r10r9r8r7r6r5r4r3r2r1"]
-r.send "e0"
-p Ractor.select(*rs, Ractor.current)
-#=>
-#<Thread:0x000056262de28bd8 run> terminated with exception (report_on_exception is true):
-Traceback (most recent call last):
- 2: from /home/ko1/src/ruby/trunk/test.rb:7:in `block (2 levels) in <main>'
- 1: from /home/ko1/src/ruby/trunk/test.rb:7:in `loop'
-/home/ko1/src/ruby/trunk/test.rb:9:in `block (3 levels) in <main>': unhandled exception
-Traceback (most recent call last):
- 2: from /home/ko1/src/ruby/trunk/test.rb:7:in `block (2 levels) in <main>'
- 1: from /home/ko1/src/ruby/trunk/test.rb:7:in `loop'
-/home/ko1/src/ruby/trunk/test.rb:9:in `block (3 levels) in <main>': unhandled exception
- 1: from /home/ko1/src/ruby/trunk/test.rb:21:in `<main>'
-<internal:ractor>:69:in `select': thrown by remote Ractor. (Ractor::RemoteError)
-```
-
-```ruby
-# resend non-error message
-
-r = Ractor.current
-rs = (1..10).map{|i|
- r = Ractor.new r, i do |r, i|
- loop do
- msg = Ractor.receive
- raise if /e/ =~ msg
- r.send msg + "r#{i}"
- end
- end
-}
-
-r.send "r0"
-p Ractor.receive #=> "r0r10r9r8r7r6r5r4r3r2r1"
-r.send "r0"
-p Ractor.select(*rs, Ractor.current)
-[:receive, "r0r10r9r8r7r6r5r4r3r2r1"]
-msg = 'e0'
-begin
- r.send msg
- p Ractor.select(*rs, Ractor.current)
-rescue Ractor::RemoteError
- msg = 'r0'
- retry
-end
-
-#=> <internal:ractor>:100:in `send': The incoming-port is already closed (Ractor::ClosedError)
-# because r == r[-1] is terminated.
-```
-
-```ruby
-# ring example with supervisor and re-start
-
-def make_ractor r, i
- Ractor.new r, i do |r, i|
- loop do
- msg = Ractor.receive
- raise if /e/ =~ msg
- r.send msg + "r#{i}"
- end
- end
-end
-
-r = Ractor.current
-rs = (1..10).map{|i|
- r = make_ractor(r, i)
-}
-
-msg = 'e0' # error causing message
-begin
- r.send msg
- p Ractor.select(*rs, Ractor.current)
-rescue Ractor::RemoteError
- r = rs[-1] = make_ractor(rs[-2], rs.size-1)
- msg = 'x0'
- retry
-end
-
-#=> [:receive, "x0r9r9r8r7r6r5r4r3r2r1"]
-```
diff --git a/doc/rdoc/markup_reference.rb b/doc/rdoc/markup_reference.rb
deleted file mode 100644
index e63d625b55..0000000000
--- a/doc/rdoc/markup_reference.rb
+++ /dev/null
@@ -1,1257 +0,0 @@
-require 'rdoc'
-
-# \Class \RDoc::MarkupReference exists only to provide a suitable home
-# for a reference document for \RDoc markup.
-#
-# All objects defined in this class -- classes, modules, methods, aliases,
-# attributes, and constants -- are solely for illustrating \RDoc markup,
-# and have no other legitimate use.
-#
-# = \RDoc Markup Reference
-#
-# Notes:
-#
-# - Examples in this reference are Ruby code and comments;
-# certain differences from other sources
-# (such as C code and comments) are noted.
-# - An example that shows rendered HTML output
-# displays that output in a blockquote:
-#
-# Rendered HTML:
-# >>>
-# Some stuff
-#
-# \RDoc-generated documentation is derived from and controlled by:
-#
-# - Single-line or multi-line comments that precede certain definitions;
-# see {Markup in Comments}[rdoc-ref:RDoc::MarkupReference@Markup+in+Comments].
-# - \RDoc directives in trailing comments (on the same line as code);
-# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew</tt>.
-# - \RDoc directives in single-line comments;
-# see other {Directives}[rdoc-ref:RDoc::MarkupReference@Directives].
-# - The Ruby code itself (but not from C code);
-# see {Documentation Derived from Ruby Code}[rdoc-ref:RDoc::MarkupReference@Documentation+Derived+from+Ruby+Code].
-#
-# == Markup in Comments
-#
-# The treatment of markup in comments varies according to the type of file:
-#
-# - <tt>.rb</tt> (Ruby code file): markup is parsed from Ruby comments.
-# - <tt>.c</tt> (C code file): markup is parsed from C comments.
-# - <tt>.rdoc</tt> (RDoc text file): markup is parsed from the entire file.
-#
-# The comment associated with
-# a Ruby class, module, method, alias, constant, or attribute
-# becomes the documentation for that defined object:
-#
-# - In a Ruby file, that comment immediately precedes
-# the definition of the object.
-# - In a C file, that comment immediately precedes
-# the function that implements a method,
-# or otherwise immediately precedes the definition of the object.
-#
-# In either a Ruby or a C file,
-# \RDoc ignores comments that do not precede object definitions.
-#
-# In an \RDoc file, the text is not associated with any code object,
-# but may (depending on how the documentation is built),
-# become a separate page.
-#
-# Almost all examples on this page are all RDoc-like;
-# that is, they have no comment markers like Ruby <tt>#</tt>
-# or C <tt>/* ... */</tt>.
-#
-# === Margins
-#
-# In a multi-line comment,
-# \RDoc looks for the comment's natural left margin,
-# which becomes the <em>base margin</em> for the comment
-# and is the initial <em>current margin</em> for the comment.
-#
-# The current margin can change, and does so, for example in a list.
-#
-# === Blocks
-#
-# It's convenient to think of \RDoc markup input as a sequence of _blocks_
-# of various types (details at the links):
-#
-# - {Paragraph}[rdoc-ref:RDoc::MarkupReference@Paragraphs]:
-# an ordinary paragraph.
-# - {Verbatim text block}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks]:
-# a block of text to be rendered literally.
-# - {Code block}[rdoc-ref:RDoc::MarkupReference@Code+Blocks]:
-# a verbatim text block containing Ruby code,
-# to be rendered with code highlighting.
-# - {Block quote}[rdoc-ref:RDoc::MarkupReference@Block+Quotes]:
-# a longish quoted passage, to be rendered with indentation
-# instead of quote marks.
-# - {List}[rdoc-ref:RDoc::MarkupReference@Lists]: items for
-# a bullet list, numbered list, lettered list, or labeled list.
-# - {Heading}[rdoc-ref:RDoc::MarkupReference@Headings]:
-# a section heading.
-# - {Horizontal rule}[rdoc-ref:RDoc::MarkupReference@Horizontal+Rules]:
-# a line across the rendered page.
-# - {Directive}[rdoc-ref:RDoc::MarkupReference@Directives]:
-# various special directions for the rendering.
-# - {Text Markup}[rdoc-ref:RDoc:MarkupReference@Text+Markup]:
-# text to be rendered in a special way.
-#
-# About the blocks:
-#
-# - Except for a paragraph, a block is distinguished by its indentation,
-# or by unusual initial or embedded characters.
-# - Any block may appear independently
-# (that is, not nested in another block);
-# some blocks may be nested, as detailed below.
-#
-# ==== Paragraphs
-#
-# A paragraph consists of one or more non-empty lines of ordinary text,
-# each beginning at the current margin.
-#
-# Note: Here, <em>ordinary text</em> means text that is <em>not identified</em>
-# by indentation, or by unusual initial or embedded characters.
-# See below.
-#
-# Paragraphs are separated by one or more empty lines.
-#
-# Example input:
-#
-# \RDoc produces HTML and command-line documentation for Ruby projects.
-# \RDoc includes the rdoc and ri tools for generating and displaying
-# documentation from the command-line.
-#
-# You'll love it.
-#
-# Rendered HTML:
-# >>>
-# \RDoc produces HTML and command-line documentation for Ruby projects.
-# \RDoc includes the rdoc and ri tools for generating and displaying
-# documentation from the command-line.
-#
-# You'll love it.
-#
-# A paragraph may contain nested blocks, including:
-#
-# - {Verbatim text blocks}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks].
-# - {Code blocks}[rdoc-ref:RDoc::MarkupReference@Code+Blocks].
-# - {Block quotes}[rdoc-ref:RDoc::MarkupReference@Block+Quotes].
-# - {Lists}[rdoc-ref:RDoc::MarkupReference@Lists].
-# - {Headings}[rdoc-ref:RDoc::MarkupReference@Headings].
-# - {Horizontal rules}[rdoc-ref:RDoc::MarkupReference@Horizontal+Rules].
-# - {Text Markup}[rdoc-ref:RDoc:MarkupReference@Text+Markup].
-#
-# ==== Verbatim Text Blocks
-#
-# Text indented farther than the current margin becomes a <em>verbatim text block</em>
-# (or a code block, described next).
-# In the rendered HTML, such text:
-#
-# - Is indented.
-# - Has a contrasting background color.
-#
-# The verbatim text block ends at the first line beginning at the current margin.
-#
-# Example input:
-#
-# This is not verbatim text.
-#
-# This is verbatim text.
-# Whitespace is honored. # See?
-# Whitespace is honored. # See?
-#
-# This is still the same verbatim text block.
-#
-# This is not verbatim text.
-#
-# Rendered HTML:
-# >>>
-# This is not verbatim text.
-#
-# This is verbatim text.
-# Whitespace is honored. # See?
-# Whitespace is honored. # See?
-#
-# This is still the same verbatim text block.
-#
-# This is not verbatim text.
-#
-# A verbatim text block may not contain nested blocks of any kind
-# -- it's verbatim.
-#
-# ==== Code Blocks
-#
-# A special case of verbatim text is the <em>code block</em>,
-# which is merely verbatim text that \RDoc recognizes as Ruby code:
-#
-# In the rendered HTML, the code block:
-#
-# - Is indented.
-# - Has a contrasting background color.
-# - Has syntax highlighting.
-#
-# Example input:
-#
-# Consider this method:
-#
-# def foo(name = '', value = 0)
-# @name = name # Whitespace is still honored.
-# @value = value
-# end
-#
-#
-# Rendered HTML:
-# >>>
-# Consider this method:
-#
-# def foo(name = '', value = 0)
-# @name = name # Whitespace is still honored.
-# @value = value
-# end
-#
-# Pro tip: If your indented Ruby code does not get highlighted,
-# it may contain a syntax error.
-#
-# A code block may not contain nested blocks of any kind
-# -- it's verbatim.
-#
-# ==== Block Quotes
-#
-# You can use the characters <tt>>>></tt> (unindented),
-# followed by indented text, to treat the text
-# as a {block quote}[https://en.wikipedia.org/wiki/Block_quotation]:
-#
-# Example input:
-#
-# Here's a block quote:
-# >>>
-# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
-# commodo quam iaculis massa posuere, dictum fringilla justo pulvinar.
-# Quisque turpis erat, pharetra eu dui at, sollicitudin accumsan nulla.
-#
-# Aenean congue ligula eu ligula molestie, eu pellentesque purus
-# faucibus. In id leo non ligula condimentum lobortis. Duis vestibulum,
-# diam in pellentesque aliquet, mi tellus placerat sapien, id euismod
-# purus magna ut tortor.
-#
-# Rendered HTML:
-#
-# >>>
-# Here's a block quote:
-# >>>
-# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
-# commodo quam iaculis massa posuere, dictum fringilla justo pulvinar.
-# Quisque turpis erat, pharetra eu dui at, sollicitudin accumsan nulla.
-#
-# Aenean congue ligula eu ligula molestie, eu pellentesque purus
-# faucibus. In id leo non ligula condimentum lobortis. Duis vestibulum,
-# diam in pellentesque aliquet, mi tellus placerat sapien, id euismod
-# purus magna ut tortor.
-#
-# Note that, unlike verbatim text, single newlines are not honored,
-# but that a double newline begins a new paragraph in the block quote.
-#
-# A block quote may contain nested blocks, including:
-#
-# - Other block quotes.
-# - {Paragraphs}[rdoc-ref:RDoc::MarkupReference@Paragraphs].
-# - {Verbatim text blocks}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks].
-# - {Code blocks}[rdoc-ref:RDoc::MarkupReference@Code+Blocks].
-# - {Lists}[rdoc-ref:RDoc::MarkupReference@Lists].
-# - {Headings}[rdoc-ref:RDoc::MarkupReference@Headings].
-# - {Horizontal rules}[rdoc-ref:RDoc::MarkupReference@Horizontal+Rules].
-# - {Text Markup}[rdoc-ref:RDoc:MarkupReference@Text+Markup].
-#
-# ==== Lists
-#
-# Each type of list item is marked by a special beginning:
-#
-# - Bullet list item: Begins with a hyphen or asterisk.
-# - Numbered list item: Begins with digits and a period.
-# - Lettered list item: Begins with an alphabetic character and a period.
-# - Labeled list item: Begins with one of:
-# - Square-bracketed text.
-# - A word followed by two colons.
-#
-# A list begins with a list item and continues, even across blank lines,
-# as long as list items of the same type are found at the same indentation level.
-#
-# A new list resets the current margin inward.
-# Additional lines of text aligned at that margin
-# are part of the continuing list item.
-#
-# A list item may be continued on additional lines that are aligned
-# with the first line. See examples below.
-#
-# A list item may contain nested blocks, including:
-#
-# - Other lists of any type.
-# - {Paragraphs}[rdoc-ref:RDoc::MarkupReference@Paragraphs].
-# - {Verbatim text blocks}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks].
-# - {Code blocks}[rdoc-ref:RDoc::MarkupReference@Code+Blocks].
-# - {Block quotes}[rdoc-ref:RDoc::MarkupReference@Block+Quotes].
-# - {Headings}[rdoc-ref:RDoc::MarkupReference@Headings].
-# - {Horizontal rules}[rdoc-ref:RDoc::MarkupReference@Horizontal+Rules].
-# - {Text Markup}[rdoc-ref:RDoc:MarkupReference@Text+Markup].
-#
-# ===== Bullet Lists
-#
-# A bullet list item begins with a hyphen or asterisk.
-#
-# Example input:
-#
-# - An item.
-# - Another.
-# - An item spanning
-# multiple lines.
-#
-# * Yet another.
-# - Last one.
-#
-# Rendered HTML:
-# >>>
-# - An item.
-# - Another.
-# - An item spanning
-# multiple lines.
-#
-# * Yet another.
-# - Last one.
-#
-# ===== Numbered Lists
-#
-# A numbered list item begins with digits and a period.
-#
-# The items are automatically re-numbered.
-#
-# Example input:
-#
-# 100. An item.
-# 10. Another.
-# 1. An item spanning
-# multiple lines.
-#
-# 1. Yet another.
-# 1000. Last one.
-#
-# Rendered HTML:
-# >>>
-# 100. An item.
-# 10. Another.
-# 1. An item spanning
-# multiple lines.
-#
-# 1. Yet another.
-# 1000. Last one.
-#
-# ===== Lettered Lists
-#
-# A lettered list item begins with letters and a period.
-#
-# The items are automatically "re-lettered."
-#
-# Example input:
-#
-# z. An item.
-# y. Another.
-# x. An item spanning
-# multiple lines.
-#
-# x. Yet another.
-# a. Last one.
-#
-# Rendered HTML:
-# >>>
-# z. An item.
-# y. Another.
-#
-# x. Yet another.
-# a. Last one.
-#
-# ===== Labeled Lists
-#
-# A labeled list item begins with one of:
-#
-# - Square-bracketed text: the label and text are on two lines.
-# - A word followed by two colons: the label and text are on the same line.
-#
-# Example input:
-#
-# [foo] An item.
-# bat:: Another.
-# [bag] An item spanning
-# multiple lines.
-#
-# [bar baz] Yet another.
-# bam:: Last one.
-#
-# Rendered HTML:
-# >>>
-# [foo] An item.
-# bat:: Another.
-# [bag] An item spanning
-# multiple lines.
-#
-# [bar baz] Yet another.
-# bam:: Last one.
-#
-# ==== Headings
-#
-# A heading begins with up to six equal-signs, followed by heading text.
-# Whitespace between those and the heading text is optional.
-#
-# Examples:
-#
-# = Section 1
-# == Section 1.1
-# === Section 1.1.1
-# === Section 1.1.2
-# == Section 1.2
-# = Section 2
-# = Foo
-# == Bar
-# === Baz
-# ==== Bam
-# ===== Bat
-# ====== Bad
-# ============Still a Heading (Level 6)
-# \== Not a Heading
-#
-# A heading may contain only one type of nested block:
-#
-# - {Text Markup}[rdoc-ref:RDoc:MarkupReference@Text+Markup].
-#
-# ==== Horizontal Rules
-#
-# A horizontal rule consists of a line with three or more hyphens
-# and nothing more.
-#
-# Example input:
-#
-# ---
-# --- Not a horizontal rule.
-#
-# -- Also not a horizontal rule.
-# ---
-#
-# Rendered HTML:
-# >>>
-# ---
-# --- Not a horizontal rule.
-#
-# -- Also not a horizontal rule.
-# ---
-#
-# ==== Directives
-#
-# ===== Directives for Allowing or Suppressing Documentation
-#
-# - <tt># :stopdoc:</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that \RDoc should ignore markup
-# until next <tt>:startdoc:</tt> directive or end-of-file.
-#
-# - <tt># :startdoc:</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that \RDoc should resume parsing markup.
-#
-# - <tt># :enddoc:</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that \RDoc should ignore markup to end-of-file
-# regardless of other directives.
-#
-# - <tt># :nodoc:</tt>:
-#
-# - Appended to a line of code
-# that defines a class, module, method, alias, constant, or attribute.
-# - Specifies that the defined object should not be documented.
-#
-# - <tt># :nodoc: all</tt>:
-#
-# - Appended to a line of code
-# that defines a class or module.
-# - Specifies that the class or module should not be documented.
-# By default, however, a nested class or module _will_ be documented.
-#
-# - <tt># :doc:</tt>:
-#
-# - Appended to a line of code
-# that defines a class, module, method, alias, constant, or attribute.
-# - Specifies the defined object should be documented, even if otherwise
-# would not be documented.
-#
-# - <tt># :notnew:</tt> (aliased as <tt>:not_new:</tt> and <tt>:not-new:</tt>):
-#
-# - Appended to a line of code
-# that defines instance method +initialize+.
-# - Specifies that singleton method +new+ should not be documented.
-# By default, Ruby fakes a corresponding singleton method +new+,
-# which \RDoc includes in the documentation.
-# Note that instance method +initialize+ is private, and so by default
-# is not documented.
-#
-# For Ruby code, but not for other \RDoc sources,
-# there is a shorthand for <tt>:stopdoc:</tt> and <tt>:startdoc:</tt>:
-#
-# # Documented.
-# #--
-# # Not documented.
-# #++
-# # Documented.
-#
-# For C code, any of directives <tt>:startdoc:</tt>, <tt>:enddoc:</tt>,
-# and <tt>:nodoc:</tt> may appear in a stand-alone comment:
-#
-# /* :startdoc: */
-# /* :stopdoc: */
-# /* :enddoc: */
-#
-# ===== Directive for Specifying \RDoc Source Format
-#
-# - <tt># :markup: _type_</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies the format for the \RDoc input;
-# parameter +type+ is one of +markdown+, +rd+, +rdoc+, +tomdoc+.
-#
-# ===== Directives for HTML Output
-#
-# - <tt># :title: _text_</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies the title for the HTML output.
-#
-# - <tt># :main: _filename_</tt>:
-# - Appears on a line by itself.
-# - Specifies the HTML file to be displayed first.
-#
-# ===== Directives for Method Documentation
-#
-# - <tt># :call-seq:</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies the calling sequence to be reported in the HTML,
-# overriding the actual calling sequence in the code.
-# See method #call_seq_directive.
-#
-# Note that \RDoc can build the calling sequence for a Ruby-coded method,
-# but not for other languages.
-# You may want to override that by explicitly giving a <tt>:call-seq:</tt>
-# directive if you want to include:
-#
-# - A return type, which is not automatically inferred.
-# - Multiple calling sequences.
-#
-# For C code, the directive may appear in a stand-alone comment.
-#
-# - <tt># :args: _arg_names_</tt> (aliased as <tt>:arg:</tt>):
-#
-# - Appears on a line by itself.
-# - Specifies the arguments to be reported in the HTML,
-# overriding the actual arguments in the code.
-# See method #args_directive.
-#
-# - <tt># :yields: _arg_names_</tt> (aliased as <tt>:yield:</tt>):
-#
-# - Appears on a line by itself.
-# - Specifies the yield arguments to be reported in the HTML,
-# overriding the actual yield in the code.
-# See method #yields_directive.
-#
-# ===== Directives for Organizing Documentation
-#
-# By default, \RDoc groups:
-#
-# - Singleton methods together in alphabetical order.
-# - Instance methods and their aliases together in alphabetical order.
-# - Attributes and their aliases together in alphabetical order.
-#
-# You can use directives to modify those behaviors.
-#
-# - <tt># :section: _section_title_</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that following methods are to be grouped into the section
-# with the given <em>section_title</em>,
-# or into the default section if no title is given.
-# The directive remains in effect until another such directive is given,
-# but may be temporarily overridden by directive <tt>:category:</tt>.
-# See below.
-#
-# The comment block containing this directive:
-#
-# - Must be separated by a blank line from the documentation for the next item.
-# - May have one or more lines preceding the directive.
-# These will be removed, along with any trailing lines that match them.
-# Such lines may be visually helpful.
-# - Lines of text that are not so removed become the descriptive text
-# for the section.
-#
-# Example:
-#
-# # ----------------------------------------
-# # :section: My Section
-# # This is the section that I wrote.
-# # See it glisten in the noon-day sun.
-# # ----------------------------------------
-#
-# ##
-# # Comment for some_method
-# def some_method
-# # ...
-# end
-#
-# You can use directive <tt>:category:</tt> to temporarily
-# override the current section.
-#
-# - <tt># :category: _section_title_</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that just one following method is to be included
-# in the given section, or in the default section if no title is given.
-# Subsequent methods are to be grouped into the current section.
-#
-# ===== Directive for Including a File
-#
-# - <tt># :include: _filepath_</tt>:
-#
-# - Appears on a line by itself.
-# - Specifies that the contents of the given file
-# are to be included at this point.
-# The file content is shifted to have the same indentation as the colon
-# at the start of the directive.
-#
-# The file is searched for in the directories
-# given with the <tt>--include</tt> command-line option,
-# or by default in the current directory.
-#
-# For C code, the directive may appear in a stand-alone comment
-#
-# ==== Text Markup
-#
-# Text markup is metatext that affects HTML rendering:
-#
-# - Typeface: italic, bold, monofont.
-# - Character conversions: copyright, trademark, certain punctuation.
-# - Links.
-# - Escapes: marking text as "not markup."
-#
-# ===== Typeface Markup
-#
-# Typeface markup can specify that text is to be rendered
-# as italic, bold, or monofont.
-#
-# Typeface markup may contain only one type of nested block:
-#
-# - More typeface markup:
-# italic, bold, monofont.
-#
-# ====== Italic
-#
-# Text may be marked as italic via HTML tag <tt><i></tt> or <tt><em></tt>.
-#
-# Example input:
-#
-# <i>Italicized words</i> in a paragraph.
-#
-# >>>
-# <i>Italicized words in a block quote</i>.
-#
-# - <i>Italicized words</i> in a list item.
-#
-# ====== <i>Italicized words</i> in a Heading
-#
-# <i>Italicized passage containing *bold* and +monofont+.</i>
-#
-# Rendered HTML:
-# >>>
-# <i>Italicized words</i> in a paragraph.
-#
-# >>>
-# <i>Italicized words in a block quote</i>.
-#
-# - <i>Italicized words</i> in a list item.
-#
-# ====== <i>Italicized words</i> in a Heading
-#
-# <i>Italicized passage containing *bold* and +monofont+.</i>
-#
-# A single word may be italicized via a shorthand:
-# prefixed and suffixed underscores.
-#
-# Example input:
-#
-# _Italic_ in a paragraph.
-#
-# >>>
-# _Italic_ in a block quote.
-#
-# - _Italic_ in a list item.
-#
-# ====== _Italic_ in a Heading
-#
-# Rendered HTML:
-# >>>
-# _Italic_ in a paragraph.
-#
-# >>>
-# _Italic_ in a block quote.
-#
-# - _Italic_ in a list item.
-#
-# ====== _Italic_ in a Heading
-#
-# ====== Bold
-#
-# Text may be marked as bold via HTML tag <tt><b></tt>.
-#
-# Example input:
-#
-# <b>Bold words</b> in a paragraph.
-#
-# >>>
-# <b>Bold words</b> in a block quote.
-#
-# - <b>Bold words</b> in a list item.
-#
-# ====== <b>Bold words</b> in a Heading
-#
-# <b>Bold passage containing _italics_ and +monofont+.</b>
-#
-# Rendered HTML:
-#
-# >>>
-# <b>Bold words</b> in a paragraph.
-#
-# >>>
-# <b>Bold words</b> in a block quote.
-#
-# - <b>Bold words</b> in a list item.
-#
-# ====== <b>Bold words</b> in a Heading
-#
-# <b>Bold passage containing _italics_ and +monofont+.</b>
-#
-# A single word may be made bold via a shorthand:
-# prefixed and suffixed asterisks.
-#
-# Example input:
-#
-# *Bold* in a paragraph.
-#
-# >>>
-# *Bold* in a block quote.
-#
-# - *Bold* in a list item.
-#
-# ===== *Bold* in a Heading
-#
-# Rendered HTML:
-#
-# >>>
-# *Bold* in a paragraph.
-#
-# >>>
-# *Bold* in a block quote.
-#
-# - *Bold* in a list item.
-#
-# ===== *Bold* in a Heading
-#
-# ====== Monofont
-#
-# Text may be marked as monofont
-# -- sometimes called 'typewriter font' --
-# via HTML tag <tt><tt></tt> or <tt><code></tt>.
-#
-# Example input:
-#
-# <tt>Monofont words</tt> in a paragraph.
-#
-# >>>
-# <tt>Monofont words</tt> in a block quote.
-#
-# - <tt>Monofont words</tt> in a list item.
-#
-# ====== <tt>Monofont words</tt> in heading
-#
-# <tt>Monofont passage containing _italics_ and *bold*.</tt>
-#
-# Rendered HTML:
-#
-# >>>
-# <tt>Monofont words</tt> in a paragraph.
-#
-# >>>
-# <tt>Monofont words</tt> in a block quote.
-#
-# - <tt>Monofont words</tt> in a list item.
-#
-# ====== <tt>Monofont words</tt> in heading
-#
-# <tt>Monofont passage containing _italics_ and *bold*.</tt>
-#
-# A single word may be made monofont by a shorthand:
-# prefixed and suffixed plus-signs.
-#
-# Example input:
-#
-# +Monofont+ in a paragraph.
-#
-# >>>
-# +Monofont+ in a block quote.
-#
-# - +Monofont+ in a list item.
-#
-# ====== +Monofont+ in a Heading
-#
-# Rendered HTML:
-#
-# >>>
-# +Monofont+ in a paragraph.
-#
-# >>>
-# +Monofont+ in a block quote.
-#
-# - +Monofont+ in a list item.
-#
-# ====== +Monofont+ in a Heading
-#
-# ==== Character Conversions
-#
-# Certain combinations of characters may be converted to special characters;
-# whether the conversion occurs depends on whether the special character
-# is available in the current encoding.
-#
-# - <tt>(c)</tt> converts to (c) (copyright character); must be lowercase.
-#
-# - <tt>(r)</tt> converts to (r) (registered trademark character); must be lowercase.
-#
-# - <tt>'foo'</tt> converts to 'foo' (smart single-quotes).
-#
-# - <tt>"foo"</tt> converts to "foo" (smart double-quotes).
-#
-# - <tt>foo ... bar</tt> converts to foo ... bar (1-character ellipsis).
-#
-# - <tt>foo -- bar</tt> converts to foo -- bar (1-character en-dash).
-#
-# - <tt>foo --- bar</tt> converts to foo --- bar (1-character em-dash).
-#
-# ==== Links
-#
-# Certain strings in \RDoc text are converted to links.
-# Any such link may be suppressed by prefixing a backslash.
-# This section shows how to link to various
-# targets.
-#
-# [Class]
-#
-# - On-page: <tt>DummyClass</tt> links to DummyClass.
-# - Off-page: <tt>RDoc::Alias</tt> links to RDoc::Alias.
-#
-# [Module]
-#
-# - On-page: <tt>DummyModule</tt> links to DummyModule.
-# - Off-page: <tt>RDoc</tt> links to RDoc.
-#
-# [Constant]
-#
-# - On-page: <tt>DUMMY_CONSTANT</tt> links to DUMMY_CONSTANT.
-# - Off-page: <tt>RDoc::Text::MARKUP_FORMAT</tt> links to RDoc::Text::MARKUP_FORMAT.
-#
-# [Singleton Method]
-#
-# - On-page: <tt>::dummy_singleton_method</tt> links to ::dummy_singleton_method.
-# - Off-page<tt>RDoc::TokenStream::to_html</tt> links to RDoc::TokenStream::to_html.
-#
-# Note: Occasionally \RDoc is not linked to a method whose name
-# has only special characters. Check whether the links you were expecting
-# are actually there. If not, you'll need to put in an explicit link;
-# see below.
-#
-# Pro tip: The link to any method is available in the alphabetical table of contents
-# at the top left of the page for the class or module.
-#
-# [Instance Method]
-#
-# - On-page: <tt>#dummy_instance_method</tt> links to #dummy_instance_method.
-# - Off-page: <tt>RDoc::Alias#html_name</tt> links to RDoc::Alias#html_name.
-#
-# See the Note and Pro Tip immediately above.
-#
-# [Attribute]
-#
-# - On-page: <tt>#dummy_attribute</tt> links to #dummy_attribute.
-# - Off-page: <tt>RDoc::Alias#name</tt> links to RDoc::Alias#name.
-#
-# [Alias]
-#
-# - On-page: <tt>#dummy_instance_alias</tt> links to #dummy_instance_alias.
-# - Off-page: <tt>RDoc::Alias#new_name</tt> links to RDoc::Alias#new_name.
-#
-# [Protocol +http+]
-#
-# - Linked: <tt>http://yahoo.com</tt> links to http://yahoo.com.
-#
-# [Protocol +https+]
-#
-# - Linked: <tt>https://github.com</tt> links to https://github.com.
-#
-# [Protocol +www+]
-#
-# - Linked: <tt>www.yahoo.com</tt> links to www.yahoo.com.
-#
-# [Protocol +ftp+]
-#
-# - Linked: <tt>ftp://nosuch.site</tt> links to ftp://nosuch.site.
-#
-# [Protocol +mailto+]
-#
-# - Linked: <tt>mailto:/foo@bar.com</tt> links to mailto://foo@bar.com.
-#
-# [Protocol +irc+]
-#
-# - link: <tt>irc://irc.freenode.net/ruby</tt> links to irc://irc.freenode.net/ruby.
-#
-# [Image Filename Extensions]
-#
-# - Link: <tt>https://www.ruby-lang.org/images/header-ruby-logo@2x.png</tt> is
-# converted to an in-line HTML +img+ tag, which displays the image in the HTML:
-#
-# https://www.ruby-lang.org/images/header-ruby-logo@2x.png
-#
-# Also works for +bmp+, +gif+, +jpeg+, and +jpg+ files.
-#
-# Note: Works only for a fully qualified URL.
-#
-# [Heading]
-#
-# - Link: <tt>RDoc::RD@LICENSE</tt> links to RDoc::RDoc::RD@LICENSE.
-#
-# Note that spaces in the actual heading are represented by <tt>+</tt> characters
-# in the linkable text.
-#
-# - Link: <tt>RDoc::Options@Saved+Options</tt>
-# links to RDoc::Options@Saved+Options.
-#
-# Punctuation and other special characters must be escaped like CGI.escape.
-#
-# Pro tip: The link to any heading is available in the alphabetical table of contents
-# at the top left of the page for the class or module.
-#
-# [Section]
-#
-# See {Directives for Organizing Documentation}[#class-RDoc::MarkupReference-label-Directives+for+Organizing+Documentation].
-#
-# - Link: <tt>RDoc::Markup::ToHtml@Visitor</tt> links to RDoc::Markup::ToHtml@Visitor.
-#
-# If a section and a heading share the same name, the link target is the section.
-#
-# [Single-Word Text Link]
-#
-# Use square brackets to create single-word text link:
-#
-# - <tt>GitHub[https://github.com]</tt> links to GitHub[https://github.com].
-#
-# [Multi-Word Text Link]
-#
-# Use square brackets and curly braces to create a multi-word text link.
-#
-# - <tt>{GitHub home page}[https://github.com]</tt> links to
-# {GitHub home page}[https://github.com].
-#
-# [<tt>rdoc-ref</tt> Scheme]
-#
-# A link with the <tt>rdoc-ref:</tt> scheme links to the referenced item,
-# if that item exists.
-# The referenced item may be a class, module, method, file, etc.
-#
-# - Class: <tt>Alias[rdoc-ref:RDoc::Alias]</tt> links to Alias[rdoc-ref:RDoc::Alias].
-# - Module: <tt>RDoc[rdoc-ref:RDoc]</tt> links to RDoc[rdoc-ref:RDoc].
-# - Method: <tt>foo[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]</tt>
-# links to foo[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK].
-# - Constant: <tt>bar[rdoc-ref:RDoc::Markup::ToHtml::LIST_TYPE_TO_HTML]</tt>
-# links to bar[rdoc-ref:RDoc::Markup::ToHtml::LIST_TYPE_TO_HTML].
-# - Attribute: <tt>baz[rdoc-ref:RDoc::Markup::ToHtml#code_object]</tt>
-# links to baz[rdoc-ref:RDoc::Markup::ToHtml#code_object].
-# - Alias: <tt>bad[rdoc-ref:RDoc::MarkupReference#dummy_instance_alias]</tt> links to
-# bad[rdoc-ref:RDoc::MarkupReference#dummy_instance_alias].
-#
-# If the referenced item does not exist, no link is generated
-# and entire <tt>rdoc-ref:</tt> square-bracketed clause is removed
-# from the resulting text.
-#
-# - <tt>Nosuch[rdoc-ref:RDoc::Nosuch]</tt> is rendered as
-# Nosuch[rdoc-ref:RDoc::Nosuch].
-#
-#
-# [<tt>rdoc-label</tt> Scheme]
-#
-# [Simple]
-#
-# You can specify a link target using this form,
-# where the second part cites the id of an HTML element.
-#
-# This link refers to the constant +DUMMY_CONSTANT+ on this page:
-#
-# - <tt>{DUMMY_CONSTANT}[rdoc-label:DUMMY_CONSTANT]</tt>
-#
-# Thus:
-#
-# {DUMMY_CONSTANT}[rdoc-label:DUMMY_CONSTANT]
-#
-# [With Return]
-#
-# You can specify both a link target and a local label
-# that can be used as the target for a return link.
-# These two links refer to each other:
-#
-# - <tt>{go to addressee}[rdoc-label:addressee:sender]</tt>
-# - <tt>{return to sender}[rdoc-label:sender:addressee]</tt>
-#
-# Thus:
-#
-# {go to addressee}[rdoc-label:addressee:sender]
-#
-# Some text.
-#
-# {return to sender}[rdoc-label:sender:addressee]
-#
-# [<tt>link:</tt> Scheme]
-#
-# - <tt>link:README_rdoc.html</tt> links to link:README_rdoc.html.
-#
-# [<tt>rdoc-image</tt> Scheme]
-#
-# Use the <tt>rdoc-image</tt> scheme to display an image that is also a link:
-#
-# # {rdoc-image:path/to/image}[link_target]
-#
-# - Link: <tt>{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[https://www.ruby-lang.org]</tt>
-# displays image <tt>https://www.ruby-lang.org/images/header-ruby-logo@2x.png</tt>
-# as a link to <tt>https://www.ruby-lang.org</tt>.
-#
-# {rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[https://www.ruby-lang.org]
-#
-# A relative path as the target also works:
-#
-# - Link: <tt>{rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[./Alias.html]</tt> links to <tt>./Alias.html</tt>
-#
-# {rdoc-image:https://www.ruby-lang.org/images/header-ruby-logo@2x.png}[./Alias.html]
-#
-# === Escaping Text
-#
-# Text that would otherwise be interpreted as markup
-# can be "escaped," so that it is not interpreted as markup;
-# the escape character is the backslash (<tt>'\\'</tt>).
-#
-# In a verbatim text block or a code block,
-# the escape character is always preserved:
-#
-# Example input:
-#
-# This is not verbatim text.
-#
-# This is verbatim text, with an escape character \.
-#
-# This is not a code block.
-#
-# def foo
-# 'String with an escape character.'
-# end
-#
-# Rendered HTML:
-#
-# >>>
-# This is not verbatim text.
-#
-# This is verbatim text, with an escape character \.
-#
-# This is not a code block.
-#
-# def foo
-# 'This is a code block with an escape character \.'
-# end
-#
-# In typeface markup (italic, bold, or monofont),
-# an escape character is preserved unless it is immediately
-# followed by nested typeface markup.
-#
-# Example input:
-#
-# This list is about escapes; it contains:
-#
-# - <tt>Monofont text with unescaped nested _italic_</tt>.
-# - <tt>Monofont text with escaped nested \_italic_</tt>.
-# - <tt>Monofont text with an escape character \</tt>.
-#
-# Rendered HTML:
-#
-# >>>
-# This list is about escapes; it contains:
-#
-# - <tt>Monofont text with unescaped nested _italic_</tt>.
-# - <tt>Monofont text with escaped nested \_italic_</tt>.
-# - <tt>Monofont text with an escape character \ </tt>.
-#
-# In other text-bearing blocks
-# (paragraphs, block quotes, list items, headings):
-#
-# - A single escape character immediately followed by markup
-# escapes the markup.
-# - A single escape character followed by whitespace is preserved.
-# - A single escape character anywhere else is ignored.
-# - A double escape character is rendered as a single backslash.
-#
-# Example input:
-#
-# This list is about escapes; it contains:
-#
-# - An unescaped class name, RDoc, that will become a link.
-# - An escaped class name, \RDoc, that will not become a link.
-# - An escape character followed by whitespace \ .
-# - An escape character \that is ignored.
-# - A double escape character \\ that is rendered
-# as a single backslash.
-#
-# Rendered HTML:
-#
-# >>>
-# This list is about escapes; it contains:
-#
-# - An unescaped class name, RDoc, that will become a link.
-# - An escaped class name, \RDoc, that will not become a link.
-# - An escape character followed by whitespace \ .
-# - An escape character \that is ignored.
-# - A double escape character \\ that is rendered
-# as a single backslash.
-#
-# == Documentation Derived from Ruby Code
-#
-# [Class]
-#
-# By default, \RDoc documents:
-#
-# - \Class name.
-# - Parent class.
-# - Singleton methods.
-# - Instance methods.
-# - Aliases.
-# - Constants.
-# - Attributes.
-#
-# [Module]
-#
-# By default, \RDoc documents:
-#
-# - \Module name.
-# - \Singleton methods.
-# - Instance methods.
-# - Aliases.
-# - Constants.
-# - Attributes.
-#
-# [Method]
-#
-# By default, \RDoc documents:
-#
-# - \Method name.
-# - Arguments.
-# - Yielded values.
-#
-# See #method.
-#
-# [Alias]
-#
-# By default, \RDoc documents:
-#
-# - Alias name.
-# - Aliased name.
-#
-# See #dummy_instance_alias and #dummy_instance_method.
-#
-# [Constant]
-#
-# By default, \RDoc documents:
-#
-# - \Constant name.
-#
-# See DUMMY_CONSTANT.
-#
-# [Attribute]
-#
-# By default, \RDoc documents:
-#
-# - Attribute name.
-# - Attribute type (<tt>[R]</tt>, <tt>[W]</tt>, or <tt>[RW]</tt>)
-#
-# See #dummy_attribute.
-#
-class RDoc::MarkupReference
-
- class DummyClass; end
- module DummyModule; end
- def self.dummy_singleton_method(foo, bar); end
- def dummy_instance_method(foo, bar); end;
- alias dummy_instance_alias dummy_instance_method
- attr_accessor :dummy_attribute
- alias dummy_attribute_alias dummy_attribute
- DUMMY_CONSTANT = ''
-
- # :call-seq:
- # call_seq_directive(foo, bar)
- # Can be anything -> bar
- # Also anything more -> baz or bat
- #
- # The <tt>:call-seq:</tt> directive overrides the actual calling sequence
- # found in the Ruby code.
- #
- # - It can specify anything at all.
- # - It can have multiple calling sequences.
- #
- # This one includes <tt>Can be anything -> foo</tt>, which is nonsense.
- #
- # Note that the "arrow" is two characters, hyphen and right angle-bracket,
- # which is made into a single character in the HTML.
- #
- # Click on the calling sequence to see the code.
- #
- # Here is the <tt>:call-seq:</tt> directive given for the method:
- #
- # :call-seq:
- # call_seq_directive(foo, bar)
- # Can be anything -> bar
- # Also anything more -> baz or bat
- #
- def call_seq_directive
- nil
- end
-
- # The <tt>:args:</tt> directive overrides the actual arguments found in the Ruby code.
- #
- # Click on the calling sequence to see the code.
- #
- def args_directive(foo, bar) # :args: baz
- nil
- end
-
- # The <tt>:yields:</tt> directive overrides the actual yield found in the Ruby code.
- #
- # Click on the calling sequence to see the code.
- #
- def yields_directive(foo, bar) # :yields: 'bat'
- yield 'baz'
- end
-
- # This method is documented only by \RDoc, except for these comments.
- #
- # Click on the calling sequence to see the code.
- #
- def method(foo, bar)
- yield 'baz'
- end
-
-end
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
deleted file mode 100644
index 51ea772062..0000000000
--- a/doc/regexp.rdoc
+++ /dev/null
@@ -1,810 +0,0 @@
-# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-
-Regular expressions (<i>regexp</i>s) are patterns which describe the
-contents of a string. They're used for testing whether a string contains a
-given pattern, or extracting the portions that match. They are created
-with the <tt>/</tt><i>pat</i><tt>/</tt> and
-<tt>%r{</tt><i>pat</i><tt>}</tt> literals or the <tt>Regexp.new</tt>
-constructor.
-
-A regexp is usually delimited with forward slashes (<tt>/</tt>). For
-example:
-
- /hay/ =~ 'haystack' #=> 0
- /y/.match('haystack') #=> #<MatchData "y">
-
-If a string contains the pattern it is said to <i>match</i>. A literal
-string matches itself.
-
-Here 'haystack' does not contain the pattern 'needle', so it doesn't match:
-
- /needle/.match('haystack') #=> nil
-
-Here 'haystack' contains the pattern 'hay', so it matches:
-
- /hay/.match('haystack') #=> #<MatchData "hay">
-
-Specifically, <tt>/st/</tt> requires that the string contains the letter
-_s_ followed by the letter _t_, so it matches _haystack_, also.
-
-Note that any Regexp matching will raise a RuntimeError if timeout is set and
-exceeded. See {"Timeout"}[#label-Timeout] section in detail.
-
-== \Regexp Interpolation
-
-A regexp may contain interpolated strings; trivially:
-
- foo = 'bar'
- /#{foo}/ # => /bar/
-
-== <tt>=~</tt> and Regexp#match
-
-Pattern matching may be achieved by using <tt>=~</tt> operator or Regexp#match
-method.
-
-=== <tt>=~</tt> Operator
-
-<tt>=~</tt> is Ruby's basic pattern-matching operator. When one operand is a
-regular expression and the other is a string then the regular expression is
-used as a pattern to match against the string. (This operator is equivalently
-defined by Regexp and String so the order of String and Regexp do not matter.
-Other classes may have different implementations of <tt>=~</tt>.) If a match
-is found, the operator returns index of first match in string, otherwise it
-returns +nil+.
-
- /hay/ =~ 'haystack' #=> 0
- 'haystack' =~ /hay/ #=> 0
- /a/ =~ 'haystack' #=> 1
- /u/ =~ 'haystack' #=> nil
-
-Using <tt>=~</tt> operator with a String and Regexp the <tt>$~</tt> global
-variable is set after a successful match. <tt>$~</tt> holds a MatchData
-object. Regexp.last_match is equivalent to <tt>$~</tt>.
-
-=== Regexp#match Method
-
-The #match method returns a MatchData object:
-
- /st/.match('haystack') #=> #<MatchData "st">
-
-== Metacharacters and Escapes
-
-The following are <i>metacharacters</i> <tt>(</tt>, <tt>)</tt>,
-<tt>[</tt>, <tt>]</tt>, <tt>{</tt>, <tt>}</tt>, <tt>.</tt>, <tt>?</tt>,
-<tt>+</tt>, <tt>*</tt>. They have a specific meaning when appearing in a
-pattern. To match them literally they must be backslash-escaped. To match
-a backslash literally, backslash-escape it: <tt>\\\\</tt>.
-
- /1 \+ 2 = 3\?/.match('Does 1 + 2 = 3?') #=> #<MatchData "1 + 2 = 3?">
- /a\\\\b/.match('a\\\\b') #=> #<MatchData "a\\b">
-
-Patterns behave like double-quoted strings and can contain the same
-backslash escapes (the meaning of <tt>\s</tt> is different, however,
-see below[#label-Character+Classes]).
-
- /\s\u{6771 4eac 90fd}/.match("Go to æ±äº¬éƒ½")
- #=> #<MatchData " æ±äº¬éƒ½">
-
-Arbitrary Ruby expressions can be embedded into patterns with the
-<tt>#{...}</tt> construct.
-
- place = "æ±äº¬éƒ½"
- /#{place}/.match("Go to æ±äº¬éƒ½")
- #=> #<MatchData "æ±äº¬éƒ½">
-
-== Character Classes
-
-A <i>character class</i> is delimited with square brackets (<tt>[</tt>,
-<tt>]</tt>) and lists characters that may appear at that point in the
-match. <tt>/[ab]/</tt> means _a_ or _b_, as opposed to <tt>/ab/</tt> which
-means _a_ followed by _b_.
-
- /W[aeiou]rd/.match("Word") #=> #<MatchData "Word">
-
-Within a character class the hyphen (<tt>-</tt>) is a metacharacter
-denoting an inclusive range of characters. <tt>[abcd]</tt> is equivalent
-to <tt>[a-d]</tt>. A range can be followed by another range, so
-<tt>[abcdwxyz]</tt> is equivalent to <tt>[a-dw-z]</tt>. The order in which
-ranges or individual characters appear inside a character class is
-irrelevant.
-
- /[0-9a-f]/.match('9f') #=> #<MatchData "9">
- /[9f]/.match('9f') #=> #<MatchData "9">
-
-If the first character of a character class is a caret (<tt>^</tt>) the
-class is inverted: it matches any character _except_ those named.
-
- /[^a-eg-z]/.match('f') #=> #<MatchData "f">
-
-A character class may contain another character class. By itself this
-isn't useful because <tt>[a-z[0-9]]</tt> describes the same set as
-<tt>[a-z0-9]</tt>. However, character classes also support the <tt>&&</tt>
-operator which performs set intersection on its arguments. The two can be
-combined as follows:
-
- /[a-w&&[^c-g]z]/ # ([a-w] AND ([^c-g] OR z))
-
-This is equivalent to:
-
- /[abh-w]/
-
-The following metacharacters also behave like character classes:
-
-* <tt>/./</tt> - Any character except a newline.
-* <tt>/./m</tt> - Any character (the +m+ modifier enables multiline mode)
-* <tt>/\w/</tt> - A word character (<tt>[a-zA-Z0-9_]</tt>)
-* <tt>/\W/</tt> - A non-word character (<tt>[^a-zA-Z0-9_]</tt>).
- Please take a look at {Bug #4044}[https://bugs.ruby-lang.org/issues/4044] if
- using <tt>/\W/</tt> with the <tt>/i</tt> modifier.
-* <tt>/\d/</tt> - A digit character (<tt>[0-9]</tt>)
-* <tt>/\D/</tt> - A non-digit character (<tt>[^0-9]</tt>)
-* <tt>/\h/</tt> - A hexdigit character (<tt>[0-9a-fA-F]</tt>)
-* <tt>/\H/</tt> - A non-hexdigit character (<tt>[^0-9a-fA-F]</tt>)
-* <tt>/\s/</tt> - A whitespace character: <tt>/[ \t\r\n\f\v]/</tt>
-* <tt>/\S/</tt> - A non-whitespace character: <tt>/[^ \t\r\n\f\v]/</tt>
-* <tt>/\R/</tt> - A linebreak: <tt>\n</tt>, <tt>\v</tt>, <tt>\f</tt>, <tt>\r</tt>
- <tt>\u0085</tt> (NEXT LINE), <tt>\u2028</tt> (LINE SEPARATOR), <tt>\u2029</tt> (PARAGRAPH SEPARATOR)
- or <tt>\r\n</tt>.
-
-POSIX <i>bracket expressions</i> are also similar to character classes.
-They provide a portable alternative to the above, with the added benefit
-that they encompass non-ASCII characters. For instance, <tt>/\d/</tt>
-matches only the ASCII decimal digits (0-9); whereas <tt>/[[:digit:]]/</tt>
-matches any character in the Unicode _Nd_ category.
-
-* <tt>/[[:alnum:]]/</tt> - Alphabetic and numeric character
-* <tt>/[[:alpha:]]/</tt> - Alphabetic character
-* <tt>/[[:blank:]]/</tt> - Space or tab
-* <tt>/[[:cntrl:]]/</tt> - Control character
-* <tt>/[[:digit:]]/</tt> - Digit
-* <tt>/[[:graph:]]/</tt> - Non-blank character (excludes spaces, control
- characters, and similar)
-* <tt>/[[:lower:]]/</tt> - Lowercase alphabetical character
-* <tt>/[[:print:]]/</tt> - Like [:graph:], but includes the space character
-* <tt>/[[:punct:]]/</tt> - Punctuation character
-* <tt>/[[:space:]]/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
- carriage return, etc.)
-* <tt>/[[:upper:]]/</tt> - Uppercase alphabetical
-* <tt>/[[:xdigit:]]/</tt> - Digit allowed in a hexadecimal number (i.e.,
- 0-9a-fA-F)
-
-Ruby also supports the following non-POSIX character classes:
-
-* <tt>/[[:word:]]/</tt> - A character in one of the following Unicode
- general categories _Letter_, _Mark_, _Number_,
- <i>Connector_Punctuation</i>
-* <tt>/[[:ascii:]]/</tt> - A character in the ASCII character set
-
- # U+06F2 is "EXTENDED ARABIC-INDIC DIGIT TWO"
- /[[:digit:]]/.match("\u06F2") #=> #<MatchData "\u{06F2}">
- /[[:upper:]][[:lower:]]/.match("Hello") #=> #<MatchData "He">
- /[[:xdigit:]][[:xdigit:]]/.match("A6") #=> #<MatchData "A6">
-
-== Repetition
-
-The constructs described so far match a single character. They can be
-followed by a repetition metacharacter to specify how many times they need
-to occur. Such metacharacters are called <i>quantifiers</i>.
-
-* <tt>*</tt> - Zero or more times
-* <tt>+</tt> - One or more times
-* <tt>?</tt> - Zero or one times (optional)
-* <tt>{</tt><i>n</i><tt>}</tt> - Exactly <i>n</i> times
-* <tt>{</tt><i>n</i><tt>,}</tt> - <i>n</i> or more times
-* <tt>{,</tt><i>m</i><tt>}</tt> - <i>m</i> or less times
-* <tt>{</tt><i>n</i><tt>,</tt><i>m</i><tt>}</tt> - At least <i>n</i> and
- at most <i>m</i> times
-
-At least one uppercase character ('H'), at least one lowercase character
-('e'), two 'l' characters, then one 'o':
-
- "Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/) #=> #<MatchData "Hello">
-
-=== Greedy Match
-
-Repetition is <i>greedy</i> by default: as many occurrences as possible
-are matched while still allowing the overall match to succeed. By
-contrast, <i>lazy</i> matching makes the minimal amount of matches
-necessary for overall success. Most greedy metacharacters can be made lazy
-by following them with <tt>?</tt>. For the <tt>{n}</tt> pattern, because
-it specifies an exact number of characters to match and not a variable
-number of characters, the <tt>?</tt> metacharacter instead makes the
-repeated pattern optional.
-
-Both patterns below match the string. The first uses a greedy quantifier so
-'.+' matches '<a><b>'; the second uses a lazy quantifier so '.+?' matches
-'<a>':
-
- /<.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
- /<.+?>/.match("<a><b>") #=> #<MatchData "<a>">
-
-=== Possessive Match
-
-A quantifier followed by <tt>+</tt> matches <i>possessively</i>: once it
-has matched it does not backtrack. They behave like greedy quantifiers,
-but having matched they refuse to "give up" their match even if this
-jeopardises the overall match.
-
- /<.*><.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
- /<.*+><.+>/.match("<a><b>") #=> nil
- /<.*><.++>/.match("<a><b>") #=> nil
-
-== Capturing
-
-Parentheses can be used for <i>capturing</i>. The text enclosed by the
-<i>n</i>th group of parentheses can be subsequently referred to
-with <i>n</i>. Within a pattern use the <i>backreference</i>
-<tt>\n</tt> (e.g. <tt>\1</tt>); outside of the pattern use
-<tt>MatchData[n]</tt> (e.g. <tt>MatchData[1]</tt>).
-
-In this example, <tt>'at'</tt> is captured by the first group of
-parentheses, then referred to later with <tt>\1</tt>:
-
- /[csh](..) [csh]\1 in/.match("The cat sat in the hat")
- #=> #<MatchData "cat sat in" 1:"at">
-
-Regexp#match returns a MatchData object which makes the captured text
-available with its #[] method:
-
- /[csh](..) [csh]\1 in/.match("The cat sat in the hat")[1] #=> 'at'
-
-While Ruby supports an arbitrary number of numbered captured groups,
-only groups 1-9 are supported using the <tt>\n</tt> backreference
-syntax.
-
-Ruby also supports <tt>\0</tt> as a special backreference, which
-references the entire matched string. This is also available at
-<tt>MatchData[0]</tt>. Note that the <tt>\0</tt> backreference cannot
-be used inside the regexp, as backreferences can only be used after the
-end of the capture group, and the <tt>\0</tt> backreference uses the
-implicit capture group of the entire match. However, you can use
-this backreference when doing substitution:
-
- "The cat sat in the hat".gsub(/[csh]at/, '\0s')
- # => "The cats sats in the hats"
-
-=== Named Captures
-
-Capture groups can be referred to by name when defined with the
-<tt>(?<</tt><i>name</i><tt>>)</tt> or <tt>(?'</tt><i>name</i><tt>')</tt>
-constructs.
-
- /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")
- #=> #<MatchData "$3.67" dollars:"3" cents:"67">
- /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")[:dollars] #=> "3"
-
-Named groups can be backreferenced with <tt>\k<</tt><i>name</i><tt>></tt>,
-where _name_ is the group name.
-
- /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
- #=> #<MatchData "ototo" vowel:"o">
-
-*Note*: A regexp can't use named backreferences and numbered
-backreferences simultaneously. Also, if a named capture is used in a
-regexp, then parentheses used for grouping which would otherwise result
-in a unnamed capture are treated as non-capturing.
-
- /(\w)(\w)/.match("ab").captures # => ["a", "b"]
- /(\w)(\w)/.match("ab").named_captures # => {}
-
- /(?<c>\w)(\w)/.match("ab").captures # => ["a"]
- /(?<c>\w)(\w)/.match("ab").named_captures # => {"c"=>"a"}
-
-When named capture groups are used with a literal regexp on the left-hand
-side of an expression and the <tt>=~</tt> operator, the captured text is
-also assigned to local variables with corresponding names.
-
- /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ "$3.67" #=> 0
- dollars #=> "3"
-
-== Grouping
-
-Parentheses also <i>group</i> the terms they enclose, allowing them to be
-quantified as one <i>atomic</i> whole.
-
-The pattern below matches a vowel followed by 2 word characters:
-
- /[aeiou]\w{2}/.match("Caenorhabditis elegans") #=> #<MatchData "aen">
-
-Whereas the following pattern matches a vowel followed by a word character,
-twice, i.e. <tt>[aeiou]\w[aeiou]\w</tt>: 'enor'.
-
- /([aeiou]\w){2}/.match("Caenorhabditis elegans")
- #=> #<MatchData "enor" 1:"or">
-
-The <tt>(?:</tt>...<tt>)</tt> construct provides grouping without
-capturing. That is, it combines the terms it contains into an atomic whole
-without creating a backreference. This benefits performance at the slight
-expense of readability.
-
-The first group of parentheses captures 'n' and the second 'ti'. The second
-group is referred to later with the backreference <tt>\2</tt>:
-
- /I(n)ves(ti)ga\2ons/.match("Investigations")
- #=> #<MatchData "Investigations" 1:"n" 2:"ti">
-
-The first group of parentheses is now made non-capturing with '?:', so it
-still matches 'n', but doesn't create the backreference. Thus, the
-backreference <tt>\1</tt> now refers to 'ti'.
-
- /I(?:n)ves(ti)ga\1ons/.match("Investigations")
- #=> #<MatchData "Investigations" 1:"ti">
-
-=== Atomic Grouping
-
-Grouping can be made <i>atomic</i> with
-<tt>(?></tt><i>pat</i><tt>)</tt>. This causes the subexpression <i>pat</i>
-to be matched independently of the rest of the expression such that what
-it matches becomes fixed for the remainder of the match, unless the entire
-subexpression must be abandoned and subsequently revisited. In this
-way <i>pat</i> is treated as a non-divisible whole. Atomic grouping is
-typically used to optimise patterns so as to prevent the regular
-expression engine from backtracking needlessly.
-
-The <tt>"</tt> in the pattern below matches the first character of the string,
-then <tt>.*</tt> matches <i>Quote"</i>. This causes the overall match to fail,
-so the text matched by <tt>.*</tt> is backtracked by one position, which
-leaves the final character of the string available to match <tt>"</tt>
-
- /".*"/.match('"Quote"') #=> #<MatchData "\"Quote\"">
-
-If <tt>.*</tt> is grouped atomically, it refuses to backtrack <i>Quote"</i>,
-even though this means that the overall match fails
-
- /"(?>.*)"/.match('"Quote"') #=> nil
-
-== Subexpression Calls
-
-The <tt>\g<</tt><i>name</i><tt>></tt> syntax matches the previous
-subexpression named _name_, which can be a group name or number, again.
-This differs from backreferences in that it re-executes the group rather
-than simply trying to re-match the same text.
-
-This pattern matches a <i>(</i> character and assigns it to the <tt>paren</tt>
-group, tries to call that the <tt>paren</tt> sub-expression again but fails,
-then matches a literal <i>)</i>:
-
- /\A(?<paren>\(\g<paren>*\))*\z/ =~ '()'
-
-
- /\A(?<paren>\(\g<paren>*\))*\z/ =~ '(())' #=> 0
- # ^1
- # ^2
- # ^3
- # ^4
- # ^5
- # ^6
- # ^7
- # ^8
- # ^9
- # ^10
-
-1. Matches at the beginning of the string, i.e. before the first
- character.
-2. Enters a named capture group called <tt>paren</tt>
-3. Matches a literal <i>(</i>, the first character in the string
-4. Calls the <tt>paren</tt> group again, i.e. recurses back to the
- second step
-5. Re-enters the <tt>paren</tt> group
-6. Matches a literal <i>(</i>, the second character in the
- string
-7. Try to call <tt>paren</tt> a third time, but fail because
- doing so would prevent an overall successful match
-8. Match a literal <i>)</i>, the third character in the string.
- Marks the end of the second recursive call
-9. Match a literal <i>)</i>, the fourth character in the string
-10. Match the end of the string
-
-== Alternation
-
-The vertical bar metacharacter (<tt>|</tt>) combines several expressions into
-a single one that matches any of the expressions. Each expression is an
-<i>alternative</i>.
-
- /\w(and|or)\w/.match("Feliformia") #=> #<MatchData "form" 1:"or">
- /\w(and|or)\w/.match("furandi") #=> #<MatchData "randi" 1:"and">
- /\w(and|or)\w/.match("dissemblance") #=> nil
-
-== Condition
-
-The <tt>(?(</tt><i>cond</i><tt>)</tt><i>yes</i><tt>|</tt><i>no</i><tt>)</tt>
-syntax matches _yes_ part if _cond_ is captured, otherwise matches _no_ part.
-In the case _no_ part is empty, also <tt>|</tt> can be omitted.
-
-The _cond_ may be a backreference number or a captured name. A backreference
-number is an absolute position, but can not be a relative position.
-
-== Character Properties
-
-The <tt>\p{}</tt> construct matches characters with the named property,
-much like POSIX bracket classes.
-
-* <tt>/\p{Alnum}/</tt> - Alphabetic and numeric character
-* <tt>/\p{Alpha}/</tt> - Alphabetic character
-* <tt>/\p{Blank}/</tt> - Space or tab
-* <tt>/\p{Cntrl}/</tt> - Control character
-* <tt>/\p{Digit}/</tt> - Digit
-* <tt>/\p{Emoji}/</tt> - Unicode emoji
-* <tt>/\p{Graph}/</tt> - Non-blank character (excludes spaces, control
- characters, and similar)
-* <tt>/\p{Lower}/</tt> - Lowercase alphabetical character
-* <tt>/\p{Print}/</tt> - Like <tt>\p{Graph}</tt>, but includes the space character
-* <tt>/\p{Punct}/</tt> - Punctuation character
-* <tt>/\p{Space}/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
- carriage return, etc.)
-* <tt>/\p{Upper}/</tt> - Uppercase alphabetical
-* <tt>/\p{XDigit}/</tt> - Digit allowed in a hexadecimal number (i.e., 0-9a-fA-F)
-* <tt>/\p{Word}/</tt> - A member of one of the following Unicode general
- category <i>Letter</i>, <i>Mark</i>, <i>Number</i>,
- <i>Connector\_Punctuation</i>
-* <tt>/\p{ASCII}/</tt> - A character in the ASCII character set
-* <tt>/\p{Any}/</tt> - Any Unicode character (including unassigned
- characters)
-* <tt>/\p{Assigned}/</tt> - An assigned character
-
-A Unicode character's <i>General Category</i> value can also be matched
-with <tt>\p{</tt><i>Ab</i><tt>}</tt> where <i>Ab</i> is the category's
-abbreviation as described below:
-
-* <tt>/\p{L}/</tt> - 'Letter'
-* <tt>/\p{Ll}/</tt> - 'Letter: Lowercase'
-* <tt>/\p{Lm}/</tt> - 'Letter: Mark'
-* <tt>/\p{Lo}/</tt> - 'Letter: Other'
-* <tt>/\p{Lt}/</tt> - 'Letter: Titlecase'
-* <tt>/\p{Lu}/</tt> - 'Letter: Uppercase
-* <tt>/\p{Lo}/</tt> - 'Letter: Other'
-* <tt>/\p{M}/</tt> - 'Mark'
-* <tt>/\p{Mn}/</tt> - 'Mark: Nonspacing'
-* <tt>/\p{Mc}/</tt> - 'Mark: Spacing Combining'
-* <tt>/\p{Me}/</tt> - 'Mark: Enclosing'
-* <tt>/\p{N}/</tt> - 'Number'
-* <tt>/\p{Nd}/</tt> - 'Number: Decimal Digit'
-* <tt>/\p{Nl}/</tt> - 'Number: Letter'
-* <tt>/\p{No}/</tt> - 'Number: Other'
-* <tt>/\p{P}/</tt> - 'Punctuation'
-* <tt>/\p{Pc}/</tt> - 'Punctuation: Connector'
-* <tt>/\p{Pd}/</tt> - 'Punctuation: Dash'
-* <tt>/\p{Ps}/</tt> - 'Punctuation: Open'
-* <tt>/\p{Pe}/</tt> - 'Punctuation: Close'
-* <tt>/\p{Pi}/</tt> - 'Punctuation: Initial Quote'
-* <tt>/\p{Pf}/</tt> - 'Punctuation: Final Quote'
-* <tt>/\p{Po}/</tt> - 'Punctuation: Other'
-* <tt>/\p{S}/</tt> - 'Symbol'
-* <tt>/\p{Sm}/</tt> - 'Symbol: Math'
-* <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
-* <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
-* <tt>/\p{Sk}/</tt> - 'Symbol: Modifier'
-* <tt>/\p{So}/</tt> - 'Symbol: Other'
-* <tt>/\p{Z}/</tt> - 'Separator'
-* <tt>/\p{Zs}/</tt> - 'Separator: Space'
-* <tt>/\p{Zl}/</tt> - 'Separator: Line'
-* <tt>/\p{Zp}/</tt> - 'Separator: Paragraph'
-* <tt>/\p{C}/</tt> - 'Other'
-* <tt>/\p{Cc}/</tt> - 'Other: Control'
-* <tt>/\p{Cf}/</tt> - 'Other: Format'
-* <tt>/\p{Cn}/</tt> - 'Other: Not Assigned'
-* <tt>/\p{Co}/</tt> - 'Other: Private Use'
-* <tt>/\p{Cs}/</tt> - 'Other: Surrogate'
-
-Lastly, <tt>\p{}</tt> matches a character's Unicode <i>script</i>. The
-following scripts are supported: <i>Arabic</i>, <i>Armenian</i>,
-<i>Balinese</i>, <i>Bengali</i>, <i>Bopomofo</i>, <i>Braille</i>,
-<i>Buginese</i>, <i>Buhid</i>, <i>Canadian_Aboriginal</i>, <i>Carian</i>,
-<i>Cham</i>, <i>Cherokee</i>, <i>Common</i>, <i>Coptic</i>,
-<i>Cuneiform</i>, <i>Cypriot</i>, <i>Cyrillic</i>, <i>Deseret</i>,
-<i>Devanagari</i>, <i>Ethiopic</i>, <i>Georgian</i>, <i>Glagolitic</i>,
-<i>Gothic</i>, <i>Greek</i>, <i>Gujarati</i>, <i>Gurmukhi</i>, <i>Han</i>,
-<i>Hangul</i>, <i>Hanunoo</i>, <i>Hebrew</i>, <i>Hiragana</i>,
-<i>Inherited</i>, <i>Kannada</i>, <i>Katakana</i>, <i>Kayah_Li</i>,
-<i>Kharoshthi</i>, <i>Khmer</i>, <i>Lao</i>, <i>Latin</i>, <i>Lepcha</i>,
-<i>Limbu</i>, <i>Linear_B</i>, <i>Lycian</i>, <i>Lydian</i>,
-<i>Malayalam</i>, <i>Mongolian</i>, <i>Myanmar</i>, <i>New_Tai_Lue</i>,
-<i>Nko</i>, <i>Ogham</i>, <i>Ol_Chiki</i>, <i>Old_Italic</i>,
-<i>Old_Persian</i>, <i>Oriya</i>, <i>Osmanya</i>, <i>Phags_Pa</i>,
-<i>Phoenician</i>, <i>Rejang</i>, <i>Runic</i>, <i>Saurashtra</i>,
-<i>Shavian</i>, <i>Sinhala</i>, <i>Sundanese</i>, <i>Syloti_Nagri</i>,
-<i>Syriac</i>, <i>Tagalog</i>, <i>Tagbanwa</i>, <i>Tai_Le</i>,
-<i>Tamil</i>, <i>Telugu</i>, <i>Thaana</i>, <i>Thai</i>, <i>Tibetan</i>,
-<i>Tifinagh</i>, <i>Ugaritic</i>, <i>Vai</i>, and <i>Yi</i>.
-
-Unicode codepoint U+06E9 is named "ARABIC PLACE OF SAJDAH" and belongs to the
-Arabic script:
-
- /\p{Arabic}/.match("\u06E9") #=> #<MatchData "\u06E9">
-
-All character properties can be inverted by prefixing their name with a
-caret (<tt>^</tt>).
-
-Letter 'A' is not in the Unicode Ll (Letter; Lowercase) category, so this
-match succeeds:
-
- /\p{^Ll}/.match("A") #=> #<MatchData "A">
-
-== Anchors
-
-Anchors are metacharacter that match the zero-width positions between
-characters, <i>anchoring</i> the match to a specific position.
-
-* <tt>^</tt> - Matches beginning of line
-* <tt>$</tt> - Matches end of line
-* <tt>\A</tt> - Matches beginning of string.
-* <tt>\Z</tt> - Matches end of string. If string ends with a newline,
- it matches just before newline
-* <tt>\z</tt> - Matches end of string
-* <tt>\G</tt> - Matches first matching position:
-
- In methods like <tt>String#gsub</tt> and <tt>String#scan</tt>, it changes on each iteration.
- It initially matches the beginning of subject, and in each following iteration it matches where the last match finished.
-
- " a b c".gsub(/ /, '_') #=> "____a_b_c"
- " a b c".gsub(/\G /, '_') #=> "____a b c"
-
- In methods like <tt>Regexp#match</tt> and <tt>String#match</tt> that take an (optional) offset, it matches where the search begins.
-
- "hello, world".match(/,/, 3) #=> #<MatchData ",">
- "hello, world".match(/\G,/, 3) #=> nil
-
-* <tt>\b</tt> - Matches word boundaries when outside brackets;
- backspace (0x08) when inside brackets
-* <tt>\B</tt> - Matches non-word boundaries
-* <tt>(?=</tt><i>pat</i><tt>)</tt> - <i>Positive lookahead</i> assertion:
- ensures that the following characters match <i>pat</i>, but doesn't
- include those characters in the matched text
-* <tt>(?!</tt><i>pat</i><tt>)</tt> - <i>Negative lookahead</i> assertion:
- ensures that the following characters do not match <i>pat</i>, but
- doesn't include those characters in the matched text
-* <tt>(?<=</tt><i>pat</i><tt>)</tt> - <i>Positive lookbehind</i>
- assertion: ensures that the preceding characters match <i>pat</i>, but
- doesn't include those characters in the matched text
-* <tt>(?<!</tt><i>pat</i><tt>)</tt> - <i>Negative lookbehind</i>
- assertion: ensures that the preceding characters do not match
- <i>pat</i>, but doesn't include those characters in the matched text
-
-* <tt>\K</tt> - <i>Match reset</i>: the matched content preceding
- <tt>\K</tt> in the regexp is excluded from the result. For example,
- the following two regexps are almost equivalent:
-
- /ab\Kc/ =~ "abc" #=> 0
- /(?<=ab)c/ =~ "abc" #=> 2
-
- These match same string and <i>$&</i> equals <tt>"c"</tt>, while the
- matched position is different.
-
- As are the following two regexps:
-
- /(a)\K(b)\Kc/
- /(?<=(?<=(a))(b))c/
-
-If a pattern isn't anchored it can begin at any point in the string:
-
- /real/.match("surrealist") #=> #<MatchData "real">
-
-Anchoring the pattern to the beginning of the string forces the match to start
-there. 'real' doesn't occur at the beginning of the string, so now the match
-fails:
-
- /\Areal/.match("surrealist") #=> nil
-
-The match below fails because although 'Demand' contains 'and', the pattern
-does not occur at a word boundary.
-
- /\band/.match("Demand")
-
-Whereas in the following example 'and' has been anchored to a non-word
-boundary so instead of matching the first 'and' it matches from the fourth
-letter of 'demand' instead:
-
- /\Band.+/.match("Supply and demand curve") #=> #<MatchData "and curve">
-
-The pattern below uses positive lookahead and positive lookbehind to match
-text appearing in <b></b> tags without including the tags in the match:
-
- /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>")
- #=> #<MatchData "bold">
-
-== Options
-
-The end delimiter for a regexp can be followed by one or more single-letter
-options which control how the pattern can match.
-
-* <tt>/pat/i</tt> - Ignore case
-* <tt>/pat/m</tt> - Treat a newline as a character matched by <tt>.</tt>
-* <tt>/pat/x</tt> - Ignore whitespace and comments in the pattern
-* <tt>/pat/o</tt> - Perform <tt>#{}</tt> interpolation only once
-
-<tt>i</tt>, <tt>m</tt>, and <tt>x</tt> can also be applied on the
-subexpression level with the
-<tt>(?</tt><i>on</i><tt>-</tt><i>off</i><tt>)</tt> construct, which
-enables options <i>on</i>, and disables options <i>off</i> for the
-expression enclosed by the parentheses:
-
- /a(?i:b)c/.match('aBc') #=> #<MatchData "aBc">
- /a(?-i:b)c/i.match('ABC') #=> nil
-
-Additionally, these options can also be toggled for the remainder of the
-pattern:
-
- /a(?i)bc/.match('abC') #=> #<MatchData "abC">
-
-Options may also be used with <tt>Regexp.new</tt>:
-
- Regexp.new("abc", Regexp::IGNORECASE) #=> /abc/i
- Regexp.new("abc", Regexp::MULTILINE) #=> /abc/m
- Regexp.new("abc # Comment", Regexp::EXTENDED) #=> /abc # Comment/x
- Regexp.new("abc", Regexp::IGNORECASE | Regexp::MULTILINE) #=> /abc/mi
-
- Regexp.new("abc", "i") #=> /abc/i
- Regexp.new("abc", "m") #=> /abc/m
- Regexp.new("abc # Comment", "x") #=> /abc # Comment/x
- Regexp.new("abc", "im") #=> /abc/mi
-
-== Free-Spacing Mode and Comments
-
-As mentioned above, the <tt>x</tt> option enables <i>free-spacing</i>
-mode. Literal white space inside the pattern is ignored, and the
-octothorpe (<tt>#</tt>) character introduces a comment until the end of
-the line. This allows the components of the pattern to be organized in a
-potentially more readable fashion.
-
-A contrived pattern to match a number with optional decimal places:
-
- float_pat = /\A
- [[:digit:]]+ # 1 or more digits before the decimal point
- (\. # Decimal point
- [[:digit:]]+ # 1 or more digits after the decimal point
- )? # The decimal point and following digits are optional
- \Z/x
- float_pat.match('3.14') #=> #<MatchData "3.14" 1:".14">
-
-There are a number of strategies for matching whitespace:
-
-* Use a pattern such as <tt>\s</tt> or <tt>\p{Space}</tt>.
-* Use escaped whitespace such as <tt>\ </tt>, i.e. a space preceded by a backslash.
-* Use a character class such as <tt>[ ]</tt>.
-
-Comments can be included in a non-<tt>x</tt> pattern with the
-<tt>(?#</tt><i>comment</i><tt>)</tt> construct, where <i>comment</i> is
-arbitrary text ignored by the regexp engine.
-
-Comments in regexp literals cannot include unescaped terminator
-characters.
-
-== Encoding
-
-Regular expressions are assumed to use the source encoding. This can be
-overridden with one of the following modifiers.
-
-* <tt>/</tt><i>pat</i><tt>/u</tt> - UTF-8
-* <tt>/</tt><i>pat</i><tt>/e</tt> - EUC-JP
-* <tt>/</tt><i>pat</i><tt>/s</tt> - Windows-31J
-* <tt>/</tt><i>pat</i><tt>/n</tt> - ASCII-8BIT
-
-A regexp can be matched against a string when they either share an
-encoding, or the regexp's encoding is _US-ASCII_ and the string's encoding
-is ASCII-compatible.
-
-If a match between incompatible encodings is attempted an
-<tt>Encoding::CompatibilityError</tt> exception is raised.
-
-The <tt>Regexp#fixed_encoding?</tt> predicate indicates whether the regexp
-has a <i>fixed</i> encoding, that is one incompatible with ASCII. A
-regexp's encoding can be explicitly fixed by supplying
-<tt>Regexp::FIXEDENCODING</tt> as the second argument of
-<tt>Regexp.new</tt>:
-
- r = Regexp.new("a".force_encoding("iso-8859-1"),Regexp::FIXEDENCODING)
- r =~ "a\u3042"
- # raises Encoding::CompatibilityError: incompatible encoding regexp match
- # (ISO-8859-1 regexp with UTF-8 string)
-
-== \Regexp Global Variables
-
-Pattern matching sets some global variables :
-
-* <tt>$~</tt> is equivalent to Regexp.last_match;
-* <tt>$&</tt> contains the complete matched text;
-* <tt>$`</tt> contains string before match;
-* <tt>$'</tt> contains string after match;
-* <tt>$1</tt>, <tt>$2</tt> and so on contain text matching first, second, etc
- capture group;
-* <tt>$+</tt> contains last capture group.
-
-Example:
-
- m = /s(\w{2}).*(c)/.match('haystack') #=> #<MatchData "stac" 1:"ta" 2:"c">
- $~ #=> #<MatchData "stac" 1:"ta" 2:"c">
- Regexp.last_match #=> #<MatchData "stac" 1:"ta" 2:"c">
-
- $& #=> "stac"
- # same as m[0]
- $` #=> "hay"
- # same as m.pre_match
- $' #=> "k"
- # same as m.post_match
- $1 #=> "ta"
- # same as m[1]
- $2 #=> "c"
- # same as m[2]
- $3 #=> nil
- # no third group in pattern
- $+ #=> "c"
- # same as m[-1]
-
-These global variables are thread-local and method-local variables.
-
-== Performance
-
-Certain pathological combinations of constructs can lead to abysmally bad
-performance.
-
-Consider a string of 25 <i>a</i>s, a <i>d</i>, 4 <i>a</i>s, and a
-<i>c</i>.
-
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- #=> "aaaaaaaaaaaaaaaaaaaaaaaaadaaaac"
-
-The following patterns match instantly as you would expect:
-
- /(b|a)/ =~ s #=> 0
- /(b|a+)/ =~ s #=> 0
- /(b|a+)*/ =~ s #=> 0
-
-However, the following pattern takes appreciably longer:
-
- /(b|a+)*c/ =~ s #=> 26
-
-This happens because an atom in the regexp is quantified by both an
-immediate <tt>+</tt> and an enclosing <tt>*</tt> with nothing to
-differentiate which is in control of any particular character. The
-nondeterminism that results produces super-linear performance. (Consult
-<i>Mastering Regular Expressions</i> (3rd ed.), pp 222, by
-<i>Jeffery Friedl</i>, for an in-depth analysis). This particular case
-can be fixed by use of atomic grouping, which prevents the unnecessary
-backtracking:
-
- (start = Time.now) && /(b|a+)*c/ =~ s && (Time.now - start)
- #=> 24.702736882
- (start = Time.now) && /(?>b|a+)*c/ =~ s && (Time.now - start)
- #=> 0.000166571
-
-A similar case is typified by the following example, which takes
-approximately 60 seconds to execute for me:
-
-Match a string of 29 <i>a</i>s against a pattern of 29 optional <i>a</i>s
-followed by 29 mandatory <i>a</i>s:
-
- Regexp.new('a?' * 29 + 'a' * 29) =~ 'a' * 29
-
-The 29 optional <i>a</i>s match the string, but this prevents the 29
-mandatory <i>a</i>s that follow from matching. Ruby must then backtrack
-repeatedly so as to satisfy as many of the optional matches as it can
-while still matching the mandatory 29. It is plain to us that none of the
-optional matches can succeed, but this fact unfortunately eludes Ruby.
-
-The best way to improve performance is to significantly reduce the amount of
-backtracking needed. For this case, instead of individually matching 29
-optional <i>a</i>s, a range of optional <i>a</i>s can be matched all at once
-with <i>a{0,29}</i>:
-
- Regexp.new('a{0,29}' + 'a' * 29) =~ 'a' * 29
-
-== Timeout
-
-There are two APIs to set timeout. One is Regexp.timeout=, which is
-process-global configuration of timeout for Regexp matching.
-
- Regexp.timeout = 3
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- /(b|a+)*c/ =~ s #=> This raises an exception in three seconds
-
-The other is timeout keyword of Regexp.new.
-
- re = Regexp.new("(b|a+)*c", timeout: 3)
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- /(b|a+)*c/ =~ s #=> This raises an exception in three seconds
-
-When using Regexps to process untrusted input, you should use the timeout
-feature to avoid excessive backtracking. Otherwise, a malicious user can
-provide input to Regexp causing Denial-of-Service attack.
-Note that the timeout is not set by default because an appropriate limit
-highly depends on an application requirement and context.
diff --git a/doc/rjit/rjit.md b/doc/rjit/rjit.md
deleted file mode 100644
index 77be56bfb5..0000000000
--- a/doc/rjit/rjit.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# RJIT: Ruby JIT
-
-This document has some tips that might be useful when you work on RJIT.
-
-## Project purpose
-
-This project is for experimental purposes.
-For production deployment, consider using YJIT instead.
-
-## Supported platforms
-
-The following platforms are assumed to work. `linux-x86_64` is tested on CI.
-
-* OS: Linux, macOS, BSD
-* Arch: x86\_64
-
-## configure
-### --enable-rjit
-
-On supported platforms, `--enable-rjit` is set by default. You usually don't need to specify this.
-You may still manually pass `--enable-rjit` to try RJIT on unsupported platforms.
-
-### --enable-rjit=dev
-
-`--enable-rjit=dev` makes the interpreter slower, but enables `ruby --rjit-stats` to work.
-
-## make
-### rjit-bindgen
-
-If you see an "RJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
-
-For doing the same thing locally, run `make rjit-bindgen` after installing libclang.
-macOS seems to have libclang by default. On Ubuntu, you can install it with `apt install libclang1`.
-
-## ruby
-### --rjit-stats
-
-This prints RJIT stats at exit. Available with `--enable-rjit=dev` on configure.
-
-### --rjit-dump-disasm
-
-This dumps all JIT code. You need to install libcapstone before configure.
-
-* Ubuntu: `sudo apt-get install -y libcapstone-dev`
-* macOS: `brew install capstone`
diff --git a/doc/security.rdoc b/doc/security.rdoc
deleted file mode 100644
index ae20ed30fa..0000000000
--- a/doc/security.rdoc
+++ /dev/null
@@ -1,139 +0,0 @@
-= Ruby Security
-
-The Ruby programming language is large and complex and there are many security
-pitfalls often encountered by newcomers and experienced Rubyists alike.
-
-This document aims to discuss many of these pitfalls and provide more secure
-alternatives where applicable.
-
-Please check the full list of publicly known CVEs and how to correctly report a
-security vulnerability, at: https://www.ruby-lang.org/en/security/
-Japanese version is here: https://www.ruby-lang.org/ja/security/
-
-Security vulnerabilities should be reported via an email to
-mailto:security@ruby-lang.org ({the PGP public
-key}[https://www.ruby-lang.org/security.asc]), which is a private mailing list.
-Reported problems will be published after fixes.
-
-== +Marshal.load+
-
-Ruby's +Marshal+ module provides methods for serializing and deserializing Ruby
-object trees to and from a binary data format.
-
-Never use +Marshal.load+ to deserialize untrusted or user supplied data.
-Because +Marshal+ can deserialize to almost any Ruby object and has full
-control over instance variables, it is possible to craft a malicious payload
-that executes code shortly after deserialization.
-
-If you need to deserialize untrusted data, you should use JSON as it is only
-capable of returning 'primitive' types such as strings, arrays, hashes, numbers
-and nil. If you need to deserialize other classes, you should handle this
-manually. Never deserialize to a user specified class.
-
-== YAML
-
-YAML is a popular human readable data serialization format used by many Ruby
-programs for configuration and database persistence of Ruby object trees.
-
-Similar to +Marshal+, it is able to deserialize into arbitrary Ruby classes.
-For example, the following YAML data will create an +ERB+ object when
-deserialized:
-
- !ruby/object:ERB
- src: puts `uname`
-
-Because of this, many of the security considerations applying to Marshal are
-also applicable to YAML. Do not use YAML to deserialize untrusted data.
-
-== Symbols
-
-Symbols are often seen as syntax sugar for simple strings, but they play a much
-more crucial role. The MRI Ruby implementation uses Symbols internally for
-method, variable and constant names. The reason for this is that symbols are
-simply integers with names attached to them, so they are faster to look up in
-hashtables.
-
-Starting in version 2.2, most symbols can be garbage collected; these are
-called <i>mortal</i> symbols. Most symbols you create (e.g. by calling
-+to_sym+) are mortal.
-
-<i>Immortal</i> symbols on the other hand will never be garbage collected.
-They are created when modifying code:
-* defining a method (e.g. with +define_method+),
-* setting an instance variable (e.g. with +instance_variable_set+),
-* creating a variable or constant (e.g. with +const_set+)
-C extensions that have not been updated and are still calling `SYM2ID`
-will create immortal symbols.
-Bugs in 2.2.0: +send+ and +__send__+ also created immortal symbols,
-and calling methods with keyword arguments could also create some.
-
-Don't create immortal symbols from user inputs. Otherwise, this would
-allow a user to mount a denial of service attack against your application by
-flooding it with unique strings, which will cause memory to grow indefinitely
-until the Ruby process is killed or causes the system to slow to a halt.
-
-While it might not be a good idea to call these with user inputs, methods that
-used to be vulnerable such as +to_sym+, +respond_to?+,
-+method+, +instance_variable_get+, +const_get+, etc. are no longer a threat.
-
-== Regular expressions
-
-Ruby's regular expression syntax has some minor differences when compared to
-other languages. In Ruby, the <code>^</code> and <code>$</code> anchors do not
-refer to the beginning and end of the string, rather the beginning and end of a
-*line*.
-
-This means that if you're using a regular expression like
-<code>/^[a-z]+$/</code> to restrict a string to only letters, an attacker can
-bypass this check by passing a string containing a letter, then a newline, then
-any string of their choosing.
-
-If you want to match the beginning and end of the entire string in Ruby, use
-the anchors +\A+ and +\z+.
-
-== +eval+
-
-Never pass untrusted or user controlled input to +eval+.
-
-Unless you are implementing a REPL like +irb+ or +pry+, +eval+ is almost
-certainly not what you want. Do not attempt to filter user input before passing
-it to +eval+ - this approach is fraught with danger and will most likely open
-your application up to a serious remote code execution vulnerability.
-
-== +send+
-
-'Global functions' in Ruby (+puts+, +exit+, etc.) are actually private instance
-methods on +Object+. This means it is possible to invoke these methods with
-+send+, even if the call to +send+ has an explicit receiver.
-
-For example, the following code snippet writes "Hello world" to the terminal:
-
- 1.send(:puts, "Hello world")
-
-You should never call +send+ with user supplied input as the first parameter.
-Doing so can introduce a denial of service vulnerability:
-
- foo.send(params[:bar]) # params[:bar] is "exit!"
-
-If an attacker can control the first two arguments to +send+, remote code
-execution is possible:
-
- # params is { :a => "eval", :b => "...ruby code to be executed..." }
- foo.send(params[:a], params[:b])
-
-When dispatching a method call based on user input, carefully verify that the
-method name. If possible, check it against a whitelist of safe method names.
-
-Note that the use of +public_send+ is also dangerous, as +send+ itself is
-public:
-
- 1.public_send("send", "eval", "...ruby code to be executed...")
-
-== DRb
-
-As DRb allows remote clients to invoke arbitrary methods, it is not suitable to
-expose to untrusted clients.
-
-When using DRb, try to avoid exposing it over the network if possible. If this
-isn't possible and you need to expose DRb to the world, you *must* configure an
-appropriate security policy with <code>DRb::ACL</code>.
diff --git a/doc/security/command_injection.rdoc b/doc/security/command_injection.rdoc
new file mode 100644
index 0000000000..d46e42f7be
--- /dev/null
+++ b/doc/security/command_injection.rdoc
@@ -0,0 +1,15 @@
+= Command Injection
+
+Some Ruby core methods accept string data
+that includes text to be executed as a system command.
+
+They should not be called with unknown or unsanitized commands.
+
+These methods include:
+
+- Kernel.exec
+- Kernel.spawn
+- Kernel.system
+- {\`command` (backtick method)}[rdoc-ref:Kernel#`]
+ (also called by the expression <tt>%x[command]</tt>).
+- IO.popen (when called with other than <tt>"-"</tt>).
diff --git a/doc/security/security.rdoc b/doc/security/security.rdoc
new file mode 100644
index 0000000000..af9970d336
--- /dev/null
+++ b/doc/security/security.rdoc
@@ -0,0 +1,127 @@
+= Ruby Security
+
+The Ruby programming language is large and complex and there are many security
+pitfalls often encountered by newcomers and experienced Rubyists alike.
+
+This document aims to discuss many of these pitfalls and provide more secure
+alternatives where applicable.
+
+Please check the full list of publicly known CVEs and how to correctly report a
+security vulnerability, at: https://www.ruby-lang.org/en/security/
+Japanese version is here: https://www.ruby-lang.org/ja/security/
+
+Security vulnerabilities should be reported via an email to
+mailto:security@ruby-lang.org ({the PGP public
+key}[https://www.ruby-lang.org/security.asc]), which is a private mailing list.
+Reported problems will be published after fixes.
+
+== +Marshal.load+
+
+Ruby's +Marshal+ module provides methods for serializing and deserializing Ruby
+object trees to and from a binary data format.
+
+Never use +Marshal.load+ to deserialize untrusted or user supplied data.
+Because +Marshal+ can deserialize to almost any Ruby object and has full
+control over instance variables, it is possible to craft a malicious payload
+that executes code shortly after deserialization.
+
+If you need to deserialize untrusted data, you should use JSON as it is only
+capable of returning 'primitive' types such as strings, arrays, hashes, numbers
+and nil. If you need to deserialize other classes, you should handle this
+manually. Never deserialize to a user specified class.
+
+== YAML
+
+YAML is a popular human readable data serialization format used by many Ruby
+programs for configuration and database persistence of Ruby object trees.
+
+Similar to +Marshal+, it is able to deserialize into arbitrary Ruby classes.
+For example, the following YAML data will create an +ERB+ object when
+deserialized, using the +unsafe_load+ method:
+
+ !ruby/object:ERB
+ src: puts `uname`
+
+Because of this, many of the security considerations applying to Marshal are
+also applicable to YAML. Do not use YAML to deserialize untrusted data.
+
+== Symbols
+
+Symbols are often seen as syntax sugar for simple strings, but they play a much
+more crucial role. The MRI Ruby implementation uses Symbols internally for
+method, variable and constant names. The reason for this is that symbols are
+simply integers with names attached to them, so they are faster to look up in
+hashtables.
+
+Most symbols can be garbage collected; these are called _mortal_
+symbols. Most symbols you create (e.g. by calling +to_sym+) are mortal.
+
+_Immortal_ symbols on the other hand will never be garbage collected.
+They are created when modifying code:
+* defining a method (e.g. with +define_method+),
+* setting an instance variable (e.g. with +instance_variable_set+),
+* creating a variable or constant (e.g. with +const_set+)
+C extensions that have not been updated and are still calling +SYM2ID+
+will create immortal symbols.
+
+Don't create immortal symbols from user inputs. Otherwise, this would
+allow a user to mount a denial of service attack against your application by
+flooding it with unique strings, which will cause memory to grow indefinitely
+until the Ruby process is killed or causes the system to slow to a halt.
+
+While it might not be a good idea to call these with user inputs, methods that
+used to be vulnerable such as +to_sym+, +respond_to?+,
++method+, +instance_variable_get+, +const_get+, etc. are no longer a threat.
+
+== Regular expressions
+
+Ruby's regular expression syntax has some minor differences when compared to
+other languages. In Ruby, the <code>^</code> and <code>$</code> anchors do not
+refer to the beginning and end of the string, rather the beginning and end of a
+*line*.
+
+This means that if you're using a regular expression like
+<code>/^[a-z]+$/</code> to restrict a string to only letters, an attacker can
+bypass this check by passing a string containing a letter, then a newline, then
+any string of their choosing.
+
+If you want to match the beginning and end of the entire string in Ruby, use
+the anchors +\A+ and +\z+.
+
+== +eval+
+
+Never pass untrusted or user controlled input to +eval+.
+
+Unless you are implementing a REPL like +irb+ or +pry+, +eval+ is almost
+certainly not what you want. Do not attempt to filter user input before passing
+it to +eval+ - this approach is fraught with danger and will most likely open
+your application up to a serious remote code execution vulnerability.
+
+== +send+
+
+'Global functions' in Ruby (+puts+, +exit+, etc.) are actually private instance
+methods on +Object+. This means it is possible to invoke these methods with
++send+, even if the call to +send+ has an explicit receiver.
+
+For example, the following code snippet writes "Hello world" to the terminal:
+
+ 1.send(:puts, "Hello world")
+
+You should never call +send+ with user supplied input as the first parameter.
+Doing so can introduce a denial of service vulnerability:
+
+ foo.send(params[:bar]) # params[:bar] is "exit!"
+
+If an attacker can control the first two arguments to +send+, remote code
+execution is possible:
+
+ # params is { :a => "eval", :b => "...ruby code to be executed..." }
+ foo.send(params[:a], params[:b])
+
+When dispatching a method call based on user input, carefully verify that the
+method name. If possible, check it against a whitelist of safe method names.
+
+Note that the use of +public_send+ is also dangerous, as +send+ itself is
+public:
+
+ 1.public_send("send", "eval", "...ruby code to be executed...")
diff --git a/doc/signals.rdoc b/doc/signals.rdoc
deleted file mode 100644
index 403eb66549..0000000000
--- a/doc/signals.rdoc
+++ /dev/null
@@ -1,106 +0,0 @@
-= Caveats for implementing Signal.trap callbacks
-
-As with implementing signal handlers in C or most other languages,
-all code passed to Signal.trap must be reentrant. If you are not
-familiar with reentrancy, you need to read up on it at
-{Wikipedia}[https://en.wikipedia.org/wiki/Reentrancy_(computing)] or
-elsewhere before reading the rest of this document.
-
-Most importantly, "thread-safety" does not guarantee reentrancy;
-and methods such as Mutex#lock and Mutex#synchronize which are
-commonly used for thread-safety even prevent reentrancy.
-
-== An implementation detail of the Ruby VM
-
-The Ruby VM defers Signal.trap callbacks from running until it is safe
-for its internal data structures, but it does not know when it is safe
-for data structures in YOUR code. Ruby implements deferred signal
-handling by registering short C functions with only
-{async-signal-safe functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html] as
-signal handlers. These short C functions only do enough tell the VM to
-run callbacks registered via Signal.trap later in the main Ruby Thread.
-
-== Unsafe methods to call in Signal.trap blocks
-
-When in doubt, consider anything not listed as safe below as being
-unsafe.
-
-* Mutex#lock, Mutex#synchronize and any code using them are explicitly
- unsafe. This includes Monitor in the standard library which uses
- Mutex to provide reentrancy.
-
-* Dir.chdir with block
-
-* any IO write operations when IO#sync is false;
- including IO#write, IO#write_nonblock, IO#puts.
- Pipes and sockets default to `IO#sync = true', so it is safe to
- write to them unless IO#sync was disabled.
-
-* File#flock, as the underlying flock(2) call is not specified by POSIX
-
-== Commonly safe operations inside Signal.trap blocks
-
-* Assignment and retrieval of local, instance, and class variables
-
-* Most object allocations and initializations of common types
- including Array, Hash, String, Struct, Time.
-
-* Common Array, Hash, String, Struct operations which do not execute a block
- are generally safe; but beware if iteration is occurring elsewhere.
-
-* Hash#[], Hash#[]= (unless Hash.new was given an unsafe block)
-
-* Thread::Queue#push and Thread::SizedQueue#push (since Ruby 2.1)
-
-* Creating a new Thread via Thread.new/Thread.start can used to get
- around the unusability of Mutexes inside a signal handler
-
-* Signal.trap is safe to use inside blocks passed to Signal.trap
-
-* arithmetic on Integer and Float (`+', `-', '%', '*', '/')
-
- Additionally, signal handlers do not run between two successive
- local variable accesses, so shortcuts such as `+=' and `-=' will
- not trigger a data race when used on Integer and Float classes in
- signal handlers.
-
-== System call wrapper methods which are safe inside Signal.trap
-
-Since Ruby has wrappers around many
-{async-signal-safe C functions}[http://man7.org/linux/man-pages/man7/signal-safety.7.html]
-the corresponding wrappers for many IO, File, Dir, and Socket methods
-are safe.
-
-(Incomplete list)
-
-* Dir.chdir (without block arg)
-* Dir.mkdir
-* Dir.open
-* File#truncate
-* File.link
-* File.open
-* File.readlink
-* File.rename
-* File.stat
-* File.symlink
-* File.truncate
-* File.unlink
-* File.utime
-* IO#close
-* IO#dup
-* IO#fsync
-* IO#read
-* IO#read_nonblock
-* IO#stat
-* IO#sysread
-* IO#syswrite
-* IO.select
-* IO.pipe
-* Process.clock_gettime
-* Process.exit!
-* Process.fork
-* Process.kill
-* Process.pid
-* Process.ppid
-* Process.waitpid
-...
diff --git a/doc/standard_library.md b/doc/standard_library.md
new file mode 100644
index 0000000000..782db10c37
--- /dev/null
+++ b/doc/standard_library.md
@@ -0,0 +1,223 @@
+# Ruby Standard Library
+
+The Ruby Standard Library is a large collection of classes and modules you can
+require in your code to gain additional features.
+
+Below is an overview of the libraries and extensions, followed by a brief description
+of each.
+
+## Libraries
+
+- `MakeMakefile`: A module used to generate a Makefile for C extensions
+- `RbConfig`: Information about your Ruby configuration and build
+- `Gem`: A package management framework for Ruby
+- `Pathname`: Representation of the name of a file or directory on the filesystem. Pathname is a core class, but only methods that depend on other libraries are provided as a library.
+
+## Extensions
+
+- `Coverage`: Provides coverage measurement for Ruby
+- `Monitor`: Provides a reentrant mutex
+- `objspace`: Extends the ObjectSpace module to add methods for internal statistics
+- `PTY`: Creates and manages pseudo-terminals
+- `Ripper`: Provides an interface for parsing Ruby programs into S-expressions
+- `Socket`: Accesses underlying OS socket implementations
+
+# Default gems
+
+- Default gems are shipped with Ruby releases and also available as rubygems.
+- Default gems are not uninstallable from the Ruby installation.
+- Default gems can be updated using rubygems.
+ - e.g. `gem update json`
+- Default gems can be used with bundler environments like `unbundled_env`.
+- Default gems can be used at any version in a Gemfile.
+ - e.g. `gem "json", ">= 2.6"`
+
+## Libraries
+
+- Bundler ([GitHub][bundler]): Manage your Ruby application's gem dependencies
+- Delegator ([GitHub][delegate]): Provides three abilities to delegate method calls to an object
+- DidYouMean ([GitHub][did_you_mean]): "Did you mean?" experience in Ruby
+- English ([GitHub][English]): Provides references to special global variables with less cryptic names
+- ERB ([GitHub][erb]): An easy-to-use but powerful templating system for Ruby
+- ErrorHighlight ([GitHub][error_highlight]): Highlight error locations in your code
+- FileUtils ([GitHub][fileutils]): Several file utility methods for copying, moving, removing, etc.
+- Find ([GitHub][find]): This module supports top-down traversal of a set of file paths
+- Forwardable ([GitHub][forwardable]): Provides delegation of specified methods to a designated object
+- IPAddr ([GitHub][ipaddr]): Provides methods to manipulate IPv4 and IPv6 IP addresses
+- OptionParser ([GitHub][optparse]): Ruby-oriented class for command-line option analysis
+- Net::HTTP ([GitHub][net-http]): HTTP client API for Ruby
+- Open3 ([GitHub][open3]): Provides access to stdin, stdout, and stderr when running other programs
+- OpenURI ([GitHub][open-uri]): An easy-to-use wrapper for URI::HTTP, URI::HTTPS, and URI::FTP
+- PP ([GitHub][pp]): Provides a PrettyPrinter for Ruby objects
+- PrettyPrint ([GitHub][prettyprint]): Implements a pretty printing algorithm for readable structure
+- Prism ([GitHub][prism]): A portable, error-tolerant Ruby parser
+- Resolv ([GitHub][resolv]): Thread-aware DNS resolver library in Ruby
+- SecureRandom ([GitHub][securerandom]): Interface for a secure random number generator
+- Shellwords ([GitHub][shellwords]): Manipulates strings with the word parsing rules of the UNIX Bourne shell
+- Singleton ([GitHub][singleton]): Implementation of the Singleton pattern for Ruby
+- Tempfile ([GitHub][tempfile]): A utility class for managing temporary files
+- Time ([GitHub][time]): Extends the Time class with methods for parsing and conversion
+- Timeout ([GitHub][timeout]): Auto-terminate potentially long-running operations in Ruby
+- TmpDir ([GitHub][tmpdir]): Extends the Dir class to manage the OS temporary file path
+- UN ([GitHub][un]): Utilities to replace common UNIX commands
+- URI ([GitHub][uri]): A Ruby module providing support for Uniform Resource Identifiers
+- YAML ([GitHub][yaml]): The Ruby client library for the Psych YAML implementation
+- WeakRef ([GitHub][weakref]): Allows a referenced object to be garbage-collected
+
+## Extensions
+
+- Date ([GitHub][date]): Represents dates, with a subclass for dates with time and timezones
+- Digest ([GitHub][digest]): Provides a framework for message digest libraries
+- Etc ([GitHub][etc]): Provides access to information typically stored in the UNIX /etc directory
+- Fcntl ([GitHub][fcntl]): Loads constants defined in the OS fcntl.h C header file
+- IO.console ([GitHub][io-console]): Extensions for the IO class, including `IO.console`, `IO.winsize`, etc.
+- IO#nonblock ([GitHub][io-nonblock]): Enable non-blocking mode with IO class.
+- IO#wait ([GitHub][io-wait]): Provides the feature for waiting until IO is readable or writable without blocking.
+- JSON ([GitHub][json]): Implements JavaScript Object Notation for Ruby
+- OpenSSL ([GitHub][openssl]): Provides SSL, TLS, and general-purpose cryptography for Ruby
+- Psych ([GitHub][psych]): A YAML parser and emitter for Ruby
+- StringIO ([GitHub][stringio]): Pseudo-I/O on String objects
+- StringScanner ([GitHub][strscan]): Provides lexical scanning operations on a String
+- Zlib ([GitHub][zlib]): Ruby interface for the zlib compression/decompression library
+
+# Bundled gems
+
+- Bundled gems are shipped with Ruby releases and also available as rubygems.
+ - They are only bundled with Ruby releases.
+ - They can be uninstalled from the Ruby installation.
+ - They need to be declared in a Gemfile when used with bundler.
+
+## Libraries
+
+- [minitest]: A test library supporting TDD, BDD, mocking, and benchmarking
+- [power_assert]: Power Assert for Ruby
+- [rake][rake-doc] ([GitHub][rake]): Ruby build program with capabilities similar to make
+- [test-unit]: A compatibility layer for MiniTest
+- [rexml][rexml-doc] ([GitHub][rexml]): An XML toolkit for Ruby
+- [rss]: A family of libraries supporting various XML-based "feeds"
+- [net-imap]: Ruby client API for the Internet Message Access Protocol
+- [net-smtp]: Simple Mail Transfer Protocol client library for Ruby
+- [matrix]: Represents a mathematical matrix
+- [prime]: Prime numbers and factorization library
+- [rbs]: RBS is a language to describe the structure of Ruby programs
+- [typeprof]: A type analysis tool for Ruby code based on abstract interpretation
+- [debug]: Debugging functionality for Ruby
+- [racc][racc-doc] ([GitHub][racc]): A LALR(1) parser generator written in Ruby
+- [mutex_m]: Mixin to extend objects to be handled like a Mutex
+- [getoptlong]: Parse command line options similar to the GNU C getopt_long()
+- [base64]: Support for encoding and decoding binary data using a Base64 representation
+- [bigdecimal]: Provides arbitrary-precision floating point decimal arithmetic
+- [observer]: Provides a mechanism for the publish/subscribe pattern in Ruby
+- [abbrev]: Calculates a set of unique abbreviations for a given set of strings
+- [resolv-replace]: Replace Socket DNS with Resolv
+- [rinda]: The Linda distributed computing paradigm in Ruby
+- [drb]: Distributed object system for Ruby
+- [nkf]: Ruby extension for the Network Kanji Filter
+- [syslog]: Ruby interface for the POSIX system logging facility
+- [csv][csv-doc] ([GitHub][csv]): Provides an interface to read and write CSV files and data
+- [ostruct]: A class to build custom data structures, similar to a Hash
+- [benchmark]: Provides methods to measure and report the time used to execute code
+- [logger][logger-doc] ([GitHub][logger]): Provides a simple logging utility for outputting messages
+- [pstore]: Implements a file-based persistence mechanism based on a Hash
+- [win32ole]: Provides an interface for OLE Automation in Ruby
+- [reline][reline-doc] ([GitHub][reline]): GNU Readline and Editline in a pure Ruby implementation
+- [readline]: Wrapper for the Readline extension and Reline
+- [fiddle]: A libffi wrapper for Ruby
+- [tsort]: Topological sorting using Tarjan's algorithm
+- [win32-registry]: Registry accessor library for the Windows platform.
+
+## Tools
+
+- [IRB][irb-doc] ([GitHub][irb]): Interactive Ruby command-line tool for REPL (Read Eval Print Loop)
+- [RDoc][rdoc-doc] ([GitHub][rdoc]): Documentation generator for Ruby
+
+[abbrev]: https://github.com/ruby/abbrev
+[base64]: https://github.com/ruby/base64
+[benchmark]: https://github.com/ruby/benchmark
+[bigdecimal]: https://github.com/ruby/bigdecimal
+[bundler]: https://github.com/rubygems/rubygems
+[csv]: https://github.com/ruby/csv
+[date]: https://github.com/ruby/date
+[debug]: https://github.com/ruby/debug
+[delegate]: https://github.com/ruby/delegate
+[did_you_mean]: https://github.com/ruby/did_you_mean
+[digest]: https://github.com/ruby/digest
+[drb]: https://github.com/ruby/drb
+[English]: https://github.com/ruby/English
+[erb]: https://github.com/ruby/erb
+[error_highlight]: https://github.com/ruby/error_highlight
+[etc]: https://github.com/ruby/etc
+[fcntl]: https://github.com/ruby/fcntl
+[fiddle]: https://github.com/ruby/fiddle
+[fileutils]: https://github.com/ruby/fileutils
+[find]: https://github.com/ruby/find
+[forwardable]: https://github.com/ruby/forwardable
+[getoptlong]: https://github.com/ruby/getoptlong
+[io-console]: https://github.com/ruby/io-console
+[io-nonblock]: https://github.com/ruby/io-nonblock
+[io-wait]: https://github.com/ruby/io-wait
+[ipaddr]: https://github.com/ruby/ipaddr
+[irb]: https://github.com/ruby/irb
+[json]: https://github.com/ruby/json
+[logger]: https://github.com/ruby/logger
+[matrix]: https://github.com/ruby/matrix
+[minitest]: https://github.com/seattlerb/minitest
+[mutex_m]: https://github.com/ruby/mutex_m
+[net-http]: https://github.com/ruby/net-http
+[net-imap]: https://github.com/ruby/net-imap
+[net-smtp]: https://github.com/ruby/net-smtp
+[nkf]: https://github.com/ruby/nkf
+[observer]: https://github.com/ruby/observer
+[open-uri]: https://github.com/ruby/open-uri
+[open3]: https://github.com/ruby/open3
+[openssl]: https://github.com/ruby/openssl
+[optparse]: https://github.com/ruby/optparse
+[ostruct]: https://github.com/ruby/ostruct
+[pathname]: https://github.com/ruby/pathname
+[power_assert]: https://github.com/ruby/power_assert
+[pp]: https://github.com/ruby/pp
+[prettyprint]: https://github.com/ruby/prettyprint
+[prime]: https://github.com/ruby/prime
+[prism]: https://github.com/ruby/prism
+[pstore]: https://github.com/ruby/pstore
+[psych]: https://github.com/ruby/psych
+[racc]: https://github.com/ruby/racc
+[rake]: https://github.com/ruby/rake
+[rbs]: https://github.com/ruby/rbs
+[rdoc]: https://github.com/ruby/rdoc
+[readline]: https://github.com/ruby/readline
+[reline]: https://github.com/ruby/reline
+[resolv-replace]: https://github.com/ruby/resolv-replace
+[resolv]: https://github.com/ruby/resolv
+[rexml]: https://github.com/ruby/rexml
+[rinda]: https://github.com/ruby/rinda
+[rss]: https://github.com/ruby/rss
+[securerandom]: https://github.com/ruby/securerandom
+[shellwords]: https://github.com/ruby/shellwords
+[singleton]: https://github.com/ruby/singleton
+[stringio]: https://github.com/ruby/stringio
+[strscan]: https://github.com/ruby/strscan
+[syslog]: https://github.com/ruby/syslog
+[tempfile]: https://github.com/ruby/tempfile
+[test-unit]: https://github.com/test-unit/test-unit
+[time]: https://github.com/ruby/time
+[timeout]: https://github.com/ruby/timeout
+[tmpdir]: https://github.com/ruby/tmpdir
+[tsort]: https://github.com/ruby/tsort
+[typeprof]: https://github.com/ruby/typeprof
+[un]: https://github.com/ruby/un
+[uri]: https://github.com/ruby/uri
+[weakref]: https://github.com/ruby/weakref
+[win32ole]: https://github.com/ruby/win32ole
+[win32-registry]: https://github.com/ruby/win32-registry
+[yaml]: https://github.com/ruby/yaml
+[zlib]: https://github.com/ruby/zlib
+
+[reline-doc]: https://ruby.github.io/reline/
+[rake-doc]: https://ruby.github.io/rake/
+[irb-doc]: https://ruby.github.io/irb/
+[rdoc-doc]: https://ruby.github.io/rdoc/
+[logger-doc]: https://ruby.github.io/logger/
+[racc-doc]: https://ruby.github.io/racc/
+[csv-doc]: https://ruby.github.io/csv/
+[rexml-doc]: https://ruby.github.io/rexml/
diff --git a/doc/standard_library.rdoc b/doc/standard_library.rdoc
deleted file mode 100644
index 7ff6a1f8af..0000000000
--- a/doc/standard_library.rdoc
+++ /dev/null
@@ -1,132 +0,0 @@
-= Ruby Standard Library
-
-The Ruby Standard Library is a vast collection of classes and modules that you
-can require in your code for additional features.
-
-Below is an overview of libraries and extensions followed by a brief
-description.
-
-== Libraries
-
-MakeMakefile:: Module used to generate a Makefile for C extensions
-RbConfig:: Information of your configure and build of Ruby
-Gem:: Package management framework for Ruby
-
-== Extensions
-
-Coverage:: Provides coverage measurement for Ruby
-Monitor:: Provides an object or module to use safely by more than one thread
-objspace:: Extends ObjectSpace module to add methods for internal statistics
-PTY:: Creates and manages pseudo terminals
-Ripper:: Provides an interface for parsing Ruby programs into S-expressions
-Socket:: Access underlying OS socket implementations
-
-= Default gems
-
-* default gems are shipped with Ruby releases and also available as rubygems.
-* default gems are not uninstallable from Ruby installation.
-* default gems can be updated used by rubygems.
- * e.g. `gem update json`
-* default gems can be used with bundler environment like `unbundled_env`.
-* default gems can be used any version on Gemfile.
- * e.g. `gem "json", ">= 2.6"`
-
-== Libraries
-
-Abbrev:: Calculates a set of unique abbreviations for a given set of strings
-Base64:: Support for encoding and decoding binary data using a Base64 representation
-Benchmark:: Provides methods to measure and report the time used to execute code
-Bundler:: Manage your Ruby application's gem dependencies
-CGI:: Support for the Common Gateway Interface protocol
-CSV:: Provides an interface to read and write CSV files and data
-Delegator:: Provides three abilities to delegate method calls to an object
-DidYouMean:: "Did you mean?" experience in Ruby
-DRb:: Distributed object system for Ruby
-English:: Provides references to special global variables with less cryptic names
-ERB:: An easy to use but powerful templating system for Ruby
-ErrorHighlight:: Highlight error location in your code
-FileUtils:: Several file utility methods for copying, moving, removing, etc
-Find:: This module supports top-down traversal of a set of file paths
-Forwardable:: Provides delegation of specified methods to a designated object
-GetoptLong:: Parse command line options similar to the GNU C getopt_long()
-IPAddr:: Provides methods to manipulate IPv4 and IPv6 IP addresses
-IRB:: Interactive Ruby command-line tool for REPL (Read Eval Print Loop)
-OptionParser:: Ruby-oriented class for command-line option analysis
-Logger:: Provides a simple logging utility for outputting messages
-Mutex_m:: Mixin to extend objects to be handled like a Mutex
-Net::HTTP:: HTTP client api for Ruby
-Observable:: Provides a mechanism for publish/subscribe pattern in Ruby
-Open3:: Provides access to stdin, stdout and stderr when running other programs
-OpenStruct:: Class to build custom data structures, similar to a Hash
-OpenURI:: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP
-PP:: Provides a PrettyPrinter for Ruby objects
-PrettyPrinter:: Implements a pretty printing algorithm for readable structure
-PStore:: Implements a file based persistence mechanism based on a Hash
-Readline:: Wrapper for Readline extencion and Reline
-Reline:: GNU Readline and Editline by pure Ruby implementation.
-Resolv:: Thread-aware DNS resolver library in Ruby
-resolv-replace.rb:: Replace Socket DNS with Resolv
-RDoc:: Produces HTML and command-line documentation for Ruby
-Rinda:: The Linda distributed computing paradigm in Ruby
-SecureRandom:: Interface for secure random number generator
-Set:: Provides a class to deal with collections of unordered, unique values
-Shellwords:: Manipulates strings with word parsing rules of UNIX Bourne shell
-Singleton:: Implementation of the Singleton pattern for Ruby
-Tempfile:: A utility class for managing temporary files
-Time:: Extends the Time class with methods for parsing and conversion
-Timeout:: Auto-terminate potentially long-running operations in Ruby
-tmpdir.rb:: Extends the Dir class to manage the OS temporary file path
-TSort:: Topological sorting using Tarjan's algorithm
-un.rb:: Utilities to replace common UNIX commands
-URI:: A Ruby module providing support for Uniform Resource Identifiers
-YAML:: Ruby client library for the Psych YAML implementation
-WeakRef:: Allows a referenced object to be garbage-collected
-
-== Extensions
-
-BigDecimal:: Provides arbitrary-precision floating point decimal arithmetic
-Date:: A subclass of Object includes Comparable module for handling dates
-DateTime:: Subclass of Date to handling dates, hours, minutes, seconds, offsets
-Digest:: Provides a framework for message digest libraries
-Etc:: Provides access to information typically stored in UNIX /etc directory
-Fcntl:: Loads constants defined in the OS fcntl.h C header file
-Fiddle:: A libffi wrapper for Ruby
-IO:: Extensions for Ruby IO class, including #wait, #nonblock and ::console
-JSON:: Implements Javascript Object Notation for Ruby
-NKF:: Ruby extension for Network Kanji Filter
-OpenSSL:: Provides SSL, TLS and general purpose cryptography for Ruby
-Pathname:: Representation of the name of a file or directory on the filesystem
-Psych:: A YAML parser and emitter for Ruby
-Racc:: A LALR(1) parser generator written in Ruby.
-Readline:: Provides an interface for GNU Readline and Edit Line (libedit)
-StringIO:: Pseudo I/O on String objects
-StringScanner:: Provides lexical scanning operations on a String
-Syslog:: Ruby interface for the POSIX system logging facility
-WIN32OLE:: Provides an interface for OLE Automation in Ruby
-Zlib:: Ruby interface for the zlib compression/decompression library
-
-= Bundled gems
-
-* bundled gems are shipped with Ruby releases and also available as rubygems.
-* bundled gems are same as normal gems like `rails`, `rack`.
- * They are only bundled with Ruby releases.
- * They can be uninstallable from Ruby installation.
- * They are needed to declare in Gemfile when use with bundler.
-
-== Libraries
-
-MiniTest:: A test suite with TDD, BDD, mocking and benchmarking
-PowerAssert:: Power Assert for Ruby.
-Rake:: Ruby build program with capabilities similar to make
-Test::Unit:: A compatibility layer for MiniTest
-REXML:: An XML toolkit for Ruby
-RSS:: Family of libraries that support various formats of XML "feeds"
-Net::FTP:: Support for the File Transfer Protocol
-Net::IMAP:: Ruby client api for Internet Message Access Protocol
-Net::POP3:: Ruby client library for POP3
-Net::SMTP:: Simple Mail Transfer Protocol client library for Ruby
-Matrix:: Represents a mathematical matrix.
-Prime:: Prime numbers and factorization library
-RBS:: RBS is a language to describe the structure of Ruby programs
-TypeProf:: A type analysis tool for Ruby code based on abstract interpretation
-DEBUGGER__:: Debugging functionality for Ruby
diff --git a/doc/strftime_formatting.rdoc b/doc/strftime_formatting.rdoc
deleted file mode 100644
index 30a629bf68..0000000000
--- a/doc/strftime_formatting.rdoc
+++ /dev/null
@@ -1,527 +0,0 @@
-== Formats for Dates and Times
-
-Several Ruby time-related classes have instance method +strftime+,
-which returns a formatted string representing all or part of a date or time:
-
-- Date#strftime.
-- DateTime#strftime.
-- Time#strftime.
-
-Each of these methods takes optional argument +format+,
-which has zero or more embedded _format_ _specifications_ (see below).
-
-Each of these methods returns the string resulting from replacing each
-format specification embedded in +format+ with a string form
-of one or more parts of the date or time.
-
-A simple example:
-
- Time.now.strftime('%H:%M:%S') # => "14:02:07"
-
-A format specification has the form:
-
- %[flags][width]conversion
-
-It consists of:
-
-- A leading percent character.
-- Zero or more _flags_ (each is a character).
-- An optional _width_ _specifier_ (an integer).
-- A _conversion_ _specifier_ (a character).
-
-Except for the leading percent character,
-the only required part is the conversion specifier, so we begin with that.
-
-=== Conversion Specifiers
-
-==== \Date (Year, Month, Day)
-
-- <tt>%Y</tt> - Year including century, zero-padded:
-
- Time.now.strftime('%Y') # => "2022"
- Time.new(-1000).strftime('%Y') # => "-1000" # Before common era.
- Time.new(10000).strftime('%Y') # => "10000" # Far future.
- Time.new(10).strftime('%Y') # => "0010" # Zero-padded by default.
-
-- <tt>%y</tt> - Year without century, in range (0.99), zero-padded:
-
- Time.now.strftime('%y') # => "22"
- Time.new(1).strftime('%y') # => "01" # Zero-padded by default.
-
-- <tt>%C</tt> - Century, zero-padded:
-
- Time.now.strftime('%C') # => "20"
- Time.new(-1000).strftime('%C') # => "-10" # Before common era.
- Time.new(10000).strftime('%C') # => "100" # Far future.
- Time.new(100).strftime('%C') # => "01" # Zero-padded by default.
-
-- <tt>%m</tt> - Month of the year, in range (1..12), zero-padded:
-
- Time.new(2022, 1).strftime('%m') # => "01" # Zero-padded by default.
- Time.new(2022, 12).strftime('%m') # => "12"
-
-- <tt>%B</tt> - Full month name, capitalized:
-
- Time.new(2022, 1).strftime('%B') # => "January"
- Time.new(2022, 12).strftime('%B') # => "December"
-
-- <tt>%b</tt> - Abbreviated month name, capitalized:
-
- Time.new(2022, 1).strftime('%b') # => "Jan"
- Time.new(2022, 12).strftime('%h') # => "Dec"
-
-- <tt>%h</tt> - Same as <tt>%b</tt>.
-
-- <tt>%d</tt> - Day of the month, in range (1..31), zero-padded:
-
- Time.new(2002, 1, 1).strftime('%d') # => "01"
- Time.new(2002, 1, 31).strftime('%d') # => "31"
-
-- <tt>%e</tt> - Day of the month, in range (1..31), blank-padded:
-
- Time.new(2002, 1, 1).strftime('%e') # => " 1"
- Time.new(2002, 1, 31).strftime('%e') # => "31"
-
-- <tt>%j</tt> - Day of the year, in range (1..366), zero-padded:
-
- Time.new(2002, 1, 1).strftime('%j') # => "001"
- Time.new(2002, 12, 31).strftime('%j') # => "365"
-
-==== \Time (Hour, Minute, Second, Subsecond)
-
-- <tt>%H</tt> - Hour of the day, in range (0..23), zero-padded:
-
- Time.new(2022, 1, 1, 1).strftime('%H') # => "01"
- Time.new(2022, 1, 1, 13).strftime('%H') # => "13"
-
-- <tt>%k</tt> - Hour of the day, in range (0..23), blank-padded:
-
- Time.new(2022, 1, 1, 1).strftime('%k') # => " 1"
- Time.new(2022, 1, 1, 13).strftime('%k') # => "13"
-
-- <tt>%I</tt> - Hour of the day, in range (1..12), zero-padded:
-
- Time.new(2022, 1, 1, 1).strftime('%I') # => "01"
- Time.new(2022, 1, 1, 13).strftime('%I') # => "01"
-
-- <tt>%l</tt> - Hour of the day, in range (1..12), blank-padded:
-
- Time.new(2022, 1, 1, 1).strftime('%l') # => " 1"
- Time.new(2022, 1, 1, 13).strftime('%l') # => " 1"
-
-- <tt>%P</tt> - Meridian indicator, lowercase:
-
- Time.new(2022, 1, 1, 1).strftime('%P') # => "am"
- Time.new(2022, 1, 1, 13).strftime('%P') # => "pm"
-
-- <tt>%p</tt> - Meridian indicator, uppercase:
-
- Time.new(2022, 1, 1, 1).strftime('%p') # => "AM"
- Time.new(2022, 1, 1, 13).strftime('%p') # => "PM"
-
-- <tt>%M</tt> - Minute of the hour, in range (0..59), zero-padded:
-
- Time.new(2022, 1, 1, 1, 0, 0).strftime('%M') # => "00"
-
-- <tt>%S</tt> - Second of the minute in range (0..59), zero-padded:
-
- Time.new(2022, 1, 1, 1, 0, 0, 0).strftime('%S') # => "00"
-
-- <tt>%L</tt> - Millisecond of the second, in range (0..999), zero-padded:
-
- Time.new(2022, 1, 1, 1, 0, 0, 0).strftime('%L') # => "000"
-
-- <tt>%N</tt> - Fractional seconds, default width is 9 digits (nanoseconds):
-
- t = Time.now # => 2022-06-29 07:10:20.3230914 -0500
- t.strftime('%N') # => "323091400" # Default.
-
- Use {width specifiers}[rdoc-ref:strftime_formatting.rdoc@Width+Specifiers]
- to adjust units:
-
- t.strftime('%3N') # => "323" # Milliseconds.
- t.strftime('%6N') # => "323091" # Microseconds.
- t.strftime('%9N') # => "323091400" # Nanoseconds.
- t.strftime('%12N') # => "323091400000" # Picoseconds.
- t.strftime('%15N') # => "323091400000000" # Femptoseconds.
- t.strftime('%18N') # => "323091400000000000" # Attoseconds.
- t.strftime('%21N') # => "323091400000000000000" # Zeptoseconds.
- t.strftime('%24N') # => "323091400000000000000000" # Yoctoseconds.
-
-- <tt>%s</tt> - Number of seconds since the epoch:
-
- Time.now.strftime('%s') # => "1656505136"
-
-==== Timezone
-
-- <tt>%z</tt> - Timezone as hour and minute offset from UTC:
-
- Time.now.strftime('%z') # => "-0500"
-
-- <tt>%Z</tt> - Timezone name (platform-dependent):
-
- Time.now.strftime('%Z') # => "Central Daylight Time"
-
-==== Weekday
-
-- <tt>%A</tt> - Full weekday name:
-
- Time.now.strftime('%A') # => "Wednesday"
-
-- <tt>%a</tt> - Abbreviated weekday name:
-
- Time.now.strftime('%a') # => "Wed"
-
-- <tt>%u</tt> - Day of the week, in range (1..7), Monday is 1:
-
- t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
- t.strftime('%a') # => "Sun"
- t.strftime('%u') # => "7"
-
-- <tt>%w</tt> - Day of the week, in range (0..6), Sunday is 0:
-
- t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
- t.strftime('%a') # => "Sun"
- t.strftime('%w') # => "0"
-
-==== Week Number
-
-- <tt>%U</tt> - Week number of the year, in range (0..53), zero-padded,
- where each week begins on a Sunday:
-
- t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
- t.strftime('%a') # => "Sun"
- t.strftime('%U') # => "26"
-
-- <tt>%W</tt> - Week number of the year, in range (0..53), zero-padded,
- where each week begins on a Monday:
-
- t = Time.new(2022, 6, 26) # => 2022-06-26 00:00:00 -0500
- t.strftime('%a') # => "Sun"
- t.strftime('%W') # => "25"
-
-==== Week Dates
-
-See {ISO 8601 week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates].
-
- t0 = Time.new(2023, 1, 1) # => 2023-01-01 00:00:00 -0600
- t1 = Time.new(2024, 1, 1) # => 2024-01-01 00:00:00 -0600
-
-- <tt>%G</tt> - Week-based year:
-
- t0.strftime('%G') # => "2022"
- t1.strftime('%G') # => "2024"
-
-- <tt>%g</tt> - Week-based year without century, in range (0..99), zero-padded:
-
- t0.strftime('%g') # => "22"
- t1.strftime('%g') # => "24"
-
-- <tt>%V</tt> - Week number of the week-based year, in range (1..53),
- zero-padded:
-
- t0.strftime('%V') # => "52"
- t1.strftime('%V') # => "01"
-
-==== Literals
-
-- <tt>%n</tt> - Newline character "\n":
-
- Time.now.strftime('%n') # => "\n"
-
-- <tt>%t</tt> - Tab character "\t":
-
- Time.now.strftime('%t') # => "\t"
-
-- <tt>%%</tt> - Percent character '%':
-
- Time.now.strftime('%%') # => "%"
-
-==== Shorthand Conversion Specifiers
-
-Each shorthand specifier here is shown with its corresponding
-longhand specifier.
-
-- <tt>%c</tt> - \Date and time:
-
- Time.now.strftime('%c') # => "Wed Jun 29 08:01:41 2022"
- Time.now.strftime('%a %b %e %T %Y') # => "Wed Jun 29 08:02:07 2022"
-
-- <tt>%D</tt> - \Date:
-
- Time.now.strftime('%D') # => "06/29/22"
- Time.now.strftime('%m/%d/%y') # => "06/29/22"
-
-- <tt>%F</tt> - ISO 8601 date:
-
- Time.now.strftime('%F') # => "2022-06-29"
- Time.now.strftime('%Y-%m-%d') # => "2022-06-29"
-
-- <tt>%v</tt> - VMS date:
-
- Time.now.strftime('%v') # => "29-JUN-2022"
- Time.now.strftime('%e-%^b-%4Y') # => "29-JUN-2022"
-
-- <tt>%x</tt> - Same as <tt>%D</tt>.
-
-- <tt>%X</tt> - Same as <tt>%T</tt>.
-
-- <tt>%r</tt> - 12-hour time:
-
- Time.new(2022, 1, 1, 1).strftime('%r') # => "01:00:00 AM"
- Time.new(2022, 1, 1, 1).strftime('%I:%M:%S %p') # => "01:00:00 AM"
- Time.new(2022, 1, 1, 13).strftime('%r') # => "01:00:00 PM"
- Time.new(2022, 1, 1, 13).strftime('%I:%M:%S %p') # => "01:00:00 PM"
-
-- <tt>%R</tt> - 24-hour time:
-
- Time.new(2022, 1, 1, 1).strftime('%R') # => "01:00"
- Time.new(2022, 1, 1, 1).strftime('%H:%M') # => "01:00"
- Time.new(2022, 1, 1, 13).strftime('%R') # => "13:00"
- Time.new(2022, 1, 1, 13).strftime('%H:%M') # => "13:00"
-
-- <tt>%T</tt> - 24-hour time:
-
- Time.new(2022, 1, 1, 1).strftime('%T') # => "01:00:00"
- Time.new(2022, 1, 1, 1).strftime('%H:%M:%S') # => "01:00:00"
- Time.new(2022, 1, 1, 13).strftime('%T') # => "13:00:00"
- Time.new(2022, 1, 1, 13).strftime('%H:%M:%S') # => "13:00:00"
-
-- <tt>%+</tt> (not supported in Time#strftime) - \Date and time:
-
- DateTime.now.strftime('%+')
- # => "Wed Jun 29 08:31:53 -05:00 2022"
- DateTime.now.strftime('%a %b %e %H:%M:%S %Z %Y')
- # => "Wed Jun 29 08:32:18 -05:00 2022"
-
-=== Flags
-
-Flags may affect certain formatting specifications.
-
-Multiple flags may be given with a single conversion specified;
-order does not matter.
-
-==== Padding Flags
-
-- <tt>0</tt> - Pad with zeroes:
-
- Time.new(10).strftime('%0Y') # => "0010"
-
-- <tt>_</tt> - Pad with blanks:
-
- Time.new(10).strftime('%_Y') # => " 10"
-
-- <tt>-</tt> - Don't pad:
-
- Time.new(10).strftime('%-Y') # => "10"
-
-==== Casing Flags
-
-- <tt>^</tt> - Upcase result:
-
- Time.new(2022, 1).strftime('%B') # => "January" # No casing flag.
- Time.new(2022, 1).strftime('%^B') # => "JANUARY"
-
-- <tt>#</tt> - Swapcase result:
-
- Time.now.strftime('%p') # => "AM"
- Time.now.strftime('%^p') # => "AM"
- Time.now.strftime('%#p') # => "am"
-
-==== Timezone Flags
-
-- <tt>:</tt> - Put timezone as colon-separated hours and minutes:
-
- Time.now.strftime('%:z') # => "-05:00"
-
-- <tt>::</tt> - Put timezone as colon-separated hours, minutes, and seconds:
-
- Time.now.strftime('%::z') # => "-05:00:00"
-
-=== Width Specifiers
-
-The integer width specifier gives a minimum width for the returned string:
-
- Time.new(2002).strftime('%Y') # => "2002" # No width specifier.
- Time.new(2002).strftime('%10Y') # => "0000002002"
- Time.new(2002, 12).strftime('%B') # => "December" # No width specifier.
- Time.new(2002, 12).strftime('%10B') # => " December"
- Time.new(2002, 12).strftime('%3B') # => "December" # Ignored if too small.
-
-== Specialized Format Strings
-
-Here are a few specialized format strings,
-each based on an external standard.
-
-=== HTTP Format
-
-The HTTP date format is based on
-{RFC 2616}[https://datatracker.ietf.org/doc/html/rfc2616],
-and treats dates in the format <tt>'%a, %d %b %Y %T GMT'</tt>:
-
- d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
- # Return HTTP-formatted string.
- httpdate = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
- # Return new date parsed from HTTP-formatted string.
- Date.httpdate(httpdate) # => #<Date: 2001-02-03>
- # Return hash parsed from HTTP-formatted string.
- Date._httpdate(httpdate)
- # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
-
-=== RFC 3339 Format
-
-The RFC 3339 date format is based on
-{RFC 3339}[https://datatracker.ietf.org/doc/html/rfc3339]:
-
- d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
- # Return 3339-formatted string.
- rfc3339 = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
- # Return new date parsed from 3339-formatted string.
- Date.rfc3339(rfc3339) # => #<Date: 2001-02-03>
- # Return hash parsed from 3339-formatted string.
- Date._rfc3339(rfc3339)
- # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
-
-=== RFC 2822 Format
-
-The RFC 2822 date format is based on
-{RFC 2822}[https://datatracker.ietf.org/doc/html/rfc2822],
-and treats dates in the format <tt>'%a, %-d %b %Y %T %z'</tt>]:
-
- d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
- # Return 2822-formatted string.
- rfc2822 = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
- # Return new date parsed from 2822-formatted string.
- Date.rfc2822(rfc2822) # => #<Date: 2001-02-03>
- # Return hash parsed from 2822-formatted string.
- Date._rfc2822(rfc2822)
- # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
-
-=== JIS X 0301 Format
-
-The JIS X 0301 format includes the
-{Japanese era name}[https://en.wikipedia.org/wiki/Japanese_era_name],
-and treats dates in the format <tt>'%Y-%m-%d'</tt>
-with the first letter of the romanized era name prefixed:
-
- d = Date.new(2001, 2, 3) # => #<Date: 2001-02-03>
- # Return 0301-formatted string.
- jisx0301 = d.jisx0301 # => "H13.02.03"
- # Return new date parsed from 0301-formatted string.
- Date.jisx0301(jisx0301) # => #<Date: 2001-02-03>
- # Return hash parsed from 0301-formatted string.
- Date._jisx0301(jisx0301) # => {:year=>2001, :mon=>2, :mday=>3}
-
-=== ISO 8601 Format Specifications
-
-This section shows format specifications that are compatible with
-{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601].
-Details for various formats may be seen at the links.
-
-Examples in this section assume:
-
- t = Time.now # => 2022-06-29 16:49:25.465246 -0500
-
-==== Dates
-
-See {ISO 8601 dates}[https://en.wikipedia.org/wiki/ISO_8601#Dates].
-
-- {Years}[https://en.wikipedia.org/wiki/ISO_8601#Years]:
-
- - Basic year (+YYYY+):
-
- t.strftime('%Y') # => "2022"
-
- - Expanded year (<tt>±YYYYY</tt>):
-
- t.strftime('+%5Y') # => "+02022"
- t.strftime('-%5Y') # => "-02022"
-
-- {Calendar dates}[https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates]:
-
- - Basic date (+YYYYMMDD+):
-
- t.strftime('%Y%m%d') # => "20220629"
-
- - Extended date (<tt>YYYY-MM-DD</tt>):
-
- t.strftime('%Y-%m-%d') # => "2022-06-29"
-
- - Reduced extended date (<tt>YYYY-MM</tt>):
-
- t.strftime('%Y-%m') # => "2022-06"
-
-- {Week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates]:
-
- - Basic date (+YYYYWww+ or +YYYYWwwD+):
-
- t.strftime('%Y%Ww') # => "202226w"
- t.strftime('%Y%Ww%u') # => "202226w3"
-
- - Extended date (<tt>YYYY-Www</tt> or <tt>YYYY-Www-D<tt>):
-
- t.strftime('%Y-%Ww') # => "2022-26w"
- t.strftime('%Y-%Ww-%u') # => "2022-26w-3"
-
-- {Ordinal dates}[https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates]:
-
- - Basic date (+YYYYDDD+):
-
- t.strftime('%Y%j') # => "2022180"
-
- - Extended date (<tt>YYYY-DDD</tt>):
-
- t.strftime('%Y-%j') # => "2022-180"
-
-==== Times
-
-See {ISO 8601 times}[https://en.wikipedia.org/wiki/ISO_8601#Times].
-
-- Times:
-
- - Basic time (+Thhmmss.sss+, +Thhmmss+, +Thhmm+, or +Thh+):
-
- t.strftime('T%H%M%S.%L') # => "T164925.465"
- t.strftime('T%H%M%S') # => "T164925"
- t.strftime('T%H%M') # => "T1649"
- t.strftime('T%H') # => "T16"
-
- - Extended time (+Thh:mm:ss.sss+, +Thh:mm:ss+, or +Thh:mm+):
-
- t.strftime('T%H:%M:%S.%L') # => "T16:49:25.465"
- t.strftime('T%H:%M:%S') # => "T16:49:25"
- t.strftime('T%H:%M') # => "T16:49"
-
-- {Time zone designators}[https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators]:
-
- - Timezone (+time+ represents a valid time,
- +hh+ represents a valid 2-digit hour,
- and +mm+ represents a valid 2-digit minute):
-
- - Basic timezone (<tt>time±hhmm</tt>, <tt>time±hh</tt>, or +timeZ+):
-
- t.strftime('T%H%M%S%z') # => "T164925-0500"
- t.strftime('T%H%M%S%z').slice(0..-3) # => "T164925-05"
- t.strftime('T%H%M%SZ') # => "T164925Z"
-
- - Extended timezone (<tt>time±hh:mm</tt>):
-
- t.strftime('T%H:%M:%S%z') # => "T16:49:25-0500"
-
- - See also:
-
- - {Local time (unqualified)}[https://en.wikipedia.org/wiki/ISO_8601#Local_time_(unqualified)].
- - {Coordinated Universal Time (UTC)}[https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_(UTC)].
- - {Time offsets from UTC}[https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC].
-
-==== Combined \Date and \Time
-
-See {ISO 8601 Combined date and time representations}[https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations].
-
-An ISO 8601 combined date and time representation may be any
-ISO 8601 date and any ISO 8601 time,
-separated by the letter +T+.
-
-For the relevant +strftime+ formats, see
-{Dates}[rdoc-ref:strftime_formatting.rdoc@Dates]
-and {Times}[rdoc-ref:strftime_formatting.rdoc@Times] above.
diff --git a/doc/string.rb b/doc/string.rb
new file mode 100644
index 0000000000..4dac94e93a
--- /dev/null
+++ b/doc/string.rb
@@ -0,0 +1,421 @@
+# A +String+ object has an arbitrary sequence of bytes,
+# typically representing text or binary data.
+# A +String+ object may be created using String::new or as literals.
+#
+# String objects differ from Symbol objects in that Symbol objects are
+# designed to be used as identifiers, instead of text or data.
+#
+# You can create a +String+ object explicitly with:
+#
+# - A {string literal}[rdoc-ref:syntax/literals.rdoc@String+Literals].
+# - A {heredoc literal}[rdoc-ref:syntax/literals.rdoc@Here+Document+Literals].
+#
+# You can convert certain objects to Strings with:
+#
+# - Method #String.
+#
+# Some +String+ methods modify +self+.
+# Typically, a method whose name ends with <tt>!</tt> modifies +self+
+# and returns +self+;
+# often, a similarly named method (without the <tt>!</tt>)
+# returns a new string.
+#
+# In general, if both bang and non-bang versions of a method exist,
+# the bang method mutates and the non-bang method does not.
+# However, a method without a bang can also mutate, such as String#replace.
+#
+# == Substitution Methods
+#
+# These methods perform substitutions:
+#
+# - String#sub: One substitution (or none); returns a new string.
+# - String#sub!: One substitution (or none); returns +self+ if any changes,
+# +nil+ otherwise.
+# - String#gsub: Zero or more substitutions; returns a new string.
+# - String#gsub!: Zero or more substitutions; returns +self+ if any changes,
+# +nil+ otherwise.
+#
+# Each of these methods takes:
+#
+# - A first argument, +pattern+ (String or Regexp),
+# that specifies the substring(s) to be replaced.
+#
+# - Either of the following:
+#
+# - A second argument, +replacement+ (String or Hash),
+# that determines the replacing string.
+# - A block that will determine the replacing string.
+#
+# The examples in this section mostly use the String#sub and String#gsub methods;
+# the principles illustrated apply to all four substitution methods.
+#
+# <b>Argument +pattern+</b>
+#
+# Argument +pattern+ is commonly a regular expression:
+#
+# s = 'hello'
+# s.sub(/[aeiou]/, '*') # => "h*llo"
+# s.gsub(/[aeiou]/, '*') # => "h*ll*"
+# s.gsub(/[aeiou]/, '') # => "hll"
+# s.sub(/ell/, 'al') # => "halo"
+# s.gsub(/xyzzy/, '*') # => "hello"
+# 'THX1138'.gsub(/\d+/, '00') # => "THX00"
+#
+# When +pattern+ is a string, all its characters are treated
+# as ordinary characters (not as Regexp special characters):
+#
+# 'THX1138'.gsub('\d+', '00') # => "THX1138"
+#
+# <b>+String+ +replacement+</b>
+#
+# If +replacement+ is a string, that string determines
+# the replacing string that is substituted for the matched text.
+#
+# Each of the examples above uses a simple string as the replacing string.
+#
+# +String+ +replacement+ may contain back-references to the pattern's captures:
+#
+# - <tt>\n</tt> (_n_ is a non-negative integer) refers to <tt>$n</tt>.
+# - <tt>\k<name></tt> refers to the named capture +name+.
+#
+# See Regexp for details.
+#
+# Note that within the string +replacement+, a character combination
+# such as <tt>$&</tt> is treated as ordinary text, not as
+# a special match variable.
+# However, you may refer to some special match variables using these
+# combinations:
+#
+# - <tt>\&</tt> and <tt>\0</tt> correspond to <tt>$&</tt>,
+# which contains the complete matched text.
+# - <tt>\'</tt> corresponds to <tt>$'</tt>,
+# which contains the string after the match.
+# - <tt>\`</tt> corresponds to <tt>$`</tt>,
+# which contains the string before the match.
+# - <tt>\\+</tt> corresponds to <tt>$+</tt>,
+# which contains the last capture group.
+#
+# See Regexp for details.
+#
+# Note that <tt>\\\\</tt> is interpreted as an escape, i.e., a single backslash.
+#
+# Note also that a string literal consumes backslashes.
+# See {String Literals}[rdoc-ref:syntax/literals.rdoc@String+Literals] for details about string literals.
+#
+# A back-reference is typically preceded by an additional backslash.
+# For example, if you want to write a back-reference <tt>\&</tt> in
+# +replacement+ with a double-quoted string literal, you need to write
+# <tt>"..\\\\&.."</tt>.
+#
+# If you want to write a non-back-reference string <tt>\&</tt> in
+# +replacement+, you need to first escape the backslash to prevent
+# this method from interpreting it as a back-reference, and then you
+# need to escape the backslashes again to prevent a string literal from
+# consuming them: <tt>"..\\\\\\\\&.."</tt>.
+#
+# You may want to use the block form to avoid excessive backslashes.
+#
+# <b>\Hash +replacement+</b>
+#
+# If the argument +replacement+ is a hash, and +pattern+ matches one of its keys,
+# the replacing string is the value for that key:
+#
+# h = {'foo' => 'bar', 'baz' => 'bat'}
+# 'food'.sub('foo', h) # => "bard"
+#
+# Note that a symbol key does not match:
+#
+# h = {foo: 'bar', baz: 'bat'}
+# 'food'.sub('foo', h) # => "d"
+#
+# <b>Block</b>
+#
+# In the block form, the current match string is passed to the block;
+# the block's return value becomes the replacing string:
+#
+# s = '@'
+# '1234'.gsub(/\d/) { |match| s.succ! } # => "ABCD"
+#
+# Special match variables such as <tt>$1</tt>, <tt>$2</tt>, <tt>$`</tt>,
+# <tt>$&</tt>, and <tt>$'</tt> are set appropriately.
+#
+# == Whitespace in Strings
+#
+# In the class +String+, _whitespace_ is defined as a contiguous sequence of characters
+# consisting of any mixture of the following:
+#
+# - NL (null): <tt>"\x00"</tt>, <tt>"\u0000"</tt>.
+# - HT (horizontal tab): <tt>"\x09"</tt>, <tt>"\t"</tt>.
+# - LF (line feed): <tt>"\x0a"</tt>, <tt>"\n"</tt>.
+# - VT (vertical tab): <tt>"\x0b"</tt>, <tt>"\v"</tt>.
+# - FF (form feed): <tt>"\x0c"</tt>, <tt>"\f"</tt>.
+# - CR (carriage return): <tt>"\x0d"</tt>, <tt>"\r"</tt>.
+# - SP (space): <tt>"\x20"</tt>, <tt>" "</tt>.
+#
+#
+# Whitespace is relevant for the following methods:
+#
+# - #lstrip, #lstrip!: Strip leading whitespace.
+# - #rstrip, #rstrip!: Strip trailing whitespace.
+# - #strip, #strip!: Strip leading and trailing whitespace.
+#
+# == What's Here
+#
+# First, what's elsewhere. Class +String+:
+#
+# - Inherits from the {Object class}[rdoc-ref:Object@Whats+Here].
+# - Includes the {Comparable module}[rdoc-ref:Comparable@Whats+Here].
+#
+# Here, class +String+ provides methods that are useful for:
+#
+# - {Creating a \String}[rdoc-ref:String@Creating+a+String].
+# - {Freezing/Unfreezing a \String}[rdoc-ref:String@FreezingUnfreezing].
+# - {Querying a \String}[rdoc-ref:String@Querying].
+# - {Comparing Strings}[rdoc-ref:String@Comparing].
+# - {Modifying a \String}[rdoc-ref:String@Modifying].
+# - {Converting to a new \String}[rdoc-ref:String@Converting+to+New+String].
+# - {Converting to a non-\String}[rdoc-ref:String@Converting+to+Non--5CString].
+# - {Iterating over a \String}[rdoc-ref:String@Iterating].
+#
+# === Creating a \String
+#
+# - ::new: Returns a new string.
+# - ::try_convert: Returns a new string created from a given object.
+#
+# === Freezing/Unfreezing
+#
+# - #+@: Returns a string that is not frozen: +self+ if not frozen;
+# +self.dup+ otherwise.
+# - #-@ (aliased as #dedup): Returns a string that is frozen: +self+ if already frozen;
+# +self.freeze+ otherwise.
+# - #freeze: Freezes +self+ if not already frozen; returns +self+.
+#
+# === Querying
+#
+# _Counts_
+#
+# - #bytesize: Returns the count of bytes.
+# - #count: Returns the count of substrings matching given strings.
+# - #empty?: Returns whether the length of +self+ is zero.
+# - #length (aliased as #size): Returns the count of characters (not bytes).
+#
+# _Substrings_
+#
+# - #=~: Returns the index of the first substring that matches a given
+# Regexp or other object; returns +nil+ if no match is found.
+# - #byteindex: Returns the byte index of the first occurrence of a given substring.
+# - #byterindex: Returns the byte index of the last occurrence of a given substring.
+# - #index: Returns the index of the _first_ occurrence of a given substring;
+# returns +nil+ if none found.
+# - #rindex: Returns the index of the _last_ occurrence of a given substring;
+# returns +nil+ if none found.
+# - #include?: Returns +true+ if the string contains a given substring; +false+ otherwise.
+# - #match: Returns a MatchData object if the string matches a given Regexp; +nil+ otherwise.
+# - #match?: Returns +true+ if the string matches a given Regexp; +false+ otherwise.
+# - #start_with?: Returns +true+ if the string begins with any of the given substrings.
+# - #end_with?: Returns +true+ if the string ends with any of the given substrings.
+#
+# _Encodings_
+#
+# - #encoding\: Returns the Encoding object that represents the encoding of the string.
+# - #unicode_normalized?: Returns +true+ if the string is in Unicode normalized form; +false+ otherwise.
+# - #valid_encoding?: Returns +true+ if the string contains only characters that are valid
+# for its encoding.
+# - #ascii_only?: Returns +true+ if the string has only ASCII characters; +false+ otherwise.
+#
+# _Other_
+#
+# - #sum: Returns a basic checksum for the string: the sum of each byte.
+# - #hash: Returns the integer hash code.
+#
+# === Comparing
+#
+# - #== (aliased as #===): Returns +true+ if a given other string has the same content as +self+.
+# - #eql?: Returns +true+ if the content is the same as the given other string.
+# - #<=>: Returns -1, 0, or 1 as a given other string is smaller than,
+# equal to, or larger than +self+.
+# - #casecmp: Ignoring case, returns -1, 0, or 1 as
+# +self+ is smaller than, equal to, or larger than a given other string.
+# - #casecmp?: Ignoring case, returns whether a given other string is equal to +self+.
+#
+# === Modifying
+#
+# Each of these methods modifies +self+.
+#
+# _Insertion_
+#
+# - #insert: Returns +self+ with a given string inserted at a specified offset.
+# - #<<: Returns +self+ concatenated with a given string or integer.
+# - #append_as_bytes: Returns +self+ concatenated with strings without performing any
+# encoding validation or conversion.
+# - #prepend: Prefixes to +self+ the concatenation of given other strings.
+#
+# _Substitution_
+#
+# - #bytesplice: Replaces bytes of +self+ with bytes from a given string; returns +self+.
+# - #sub!: Replaces the first substring that matches a given pattern with a given replacement string;
+# returns +self+ if any changes, +nil+ otherwise.
+# - #gsub!: Replaces each substring that matches a given pattern with a given replacement string;
+# returns +self+ if any changes, +nil+ otherwise.
+# - #succ! (aliased as #next!): Returns +self+ modified to become its own successor.
+# - #replace: Returns +self+ with its entire content replaced by a given string.
+# - #reverse!: Returns +self+ with its characters in reverse order.
+# - #setbyte: Sets the byte at a given integer offset to a given value; returns the argument.
+# - #tr!: Replaces specified characters in +self+ with specified replacement characters;
+# returns +self+ if any changes, +nil+ otherwise.
+# - #tr_s!: Replaces specified characters in +self+ with specified replacement characters,
+# removing duplicates from the substrings that were modified;
+# returns +self+ if any changes, +nil+ otherwise.
+#
+# _Casing_
+#
+# - #capitalize!: Upcases the initial character and downcases all others;
+# returns +self+ if any changes, +nil+ otherwise.
+# - #downcase!: Downcases all characters; returns +self+ if any changes, +nil+ otherwise.
+# - #upcase!: Upcases all characters; returns +self+ if any changes, +nil+ otherwise.
+# - #swapcase!: Upcases each downcase character and downcases each upcase character;
+# returns +self+ if any changes, +nil+ otherwise.
+#
+# _Encoding_
+#
+# - #encode!: Returns +self+ with all characters transcoded from one encoding to another.
+# - #unicode_normalize!: Unicode-normalizes +self+; returns +self+.
+# - #scrub!: Replaces each invalid byte with a given character; returns +self+.
+# - #force_encoding: Changes the encoding to a given encoding; returns +self+.
+#
+# _Deletion_
+#
+# - #clear: Removes all content, so that +self+ is empty; returns +self+.
+# - #slice!, #[]=: Removes a substring determined by a given index, start/length, range, regexp, or substring.
+# - #squeeze!: Removes contiguous duplicate characters; returns +self+.
+# - #delete!: Removes characters as determined by the intersection of substring arguments.
+# - #delete_prefix!: Removes leading prefix; returns +self+ if any changes, +nil+ otherwise.
+# - #delete_suffix!: Removes trailing suffix; returns +self+ if any changes, +nil+ otherwise.
+# - #lstrip!: Removes leading whitespace; returns +self+ if any changes, +nil+ otherwise.
+# - #rstrip!: Removes trailing whitespace; returns +self+ if any changes, +nil+ otherwise.
+# - #strip!: Removes leading and trailing whitespace; returns +self+ if any changes, +nil+ otherwise.
+# - #chomp!: Removes the trailing record separator, if found; returns +self+ if any changes, +nil+ otherwise.
+# - #chop!: Removes trailing newline characters if found; otherwise removes the last character;
+# returns +self+ if any changes, +nil+ otherwise.
+#
+# === Converting to New \String
+#
+# Each of these methods returns a new +String+ based on +self+,
+# often just a modified copy of +self+.
+#
+# _Extension_
+#
+# - #*: Returns the concatenation of multiple copies of +self+.
+# - #+: Returns the concatenation of +self+ and a given other string.
+# - #center: Returns a copy of +self+, centered by specified padding.
+# - #concat: Returns the concatenation of +self+ with given other strings.
+# - #ljust: Returns a copy of +self+ of a given length, right-padded with a given other string.
+# - #rjust: Returns a copy of +self+ of a given length, left-padded with a given other string.
+#
+# _Encoding_
+#
+# - #b: Returns a copy of +self+ with ASCII-8BIT encoding.
+# - #scrub: Returns a copy of +self+ with each invalid byte replaced with a given character.
+# - #unicode_normalize: Returns a copy of +self+ with each character Unicode-normalized.
+# - #encode: Returns a copy of +self+ with all characters transcoded from one encoding to another.
+#
+# _Substitution_
+#
+# - #dump: Returns a printable version of +self+, enclosed in double-quotes.
+# - #undump: Inverse of #dump; returns a copy of +self+ with changes of the kinds made by #dump "undone."
+# - #sub: Returns a copy of +self+ with the first substring matching a given pattern
+# replaced with a given replacement string.
+# - #gsub: Returns a copy of +self+ with each substring that matches a given pattern
+# replaced with a given replacement string.
+# - #succ (aliased as #next): Returns the string that is the successor to +self+.
+# - #reverse: Returns a copy of +self+ with its characters in reverse order.
+# - #tr: Returns a copy of +self+ with specified characters replaced with specified replacement characters.
+# - #tr_s: Returns a copy of +self+ with specified characters replaced with
+# specified replacement characters,
+# removing duplicates from the substrings that were modified.
+# - #%: Returns the string resulting from formatting a given object into +self+.
+#
+# _Casing_
+#
+# - #capitalize: Returns a copy of +self+ with the first character upcased
+# and all other characters downcased.
+# - #downcase: Returns a copy of +self+ with all characters downcased.
+# - #upcase: Returns a copy of +self+ with all characters upcased.
+# - #swapcase: Returns a copy of +self+ with all upcase characters downcased
+# and all downcase characters upcased.
+#
+# _Deletion_
+#
+# - #delete: Returns a copy of +self+ with characters removed.
+# - #delete_prefix: Returns a copy of +self+ with a given prefix removed.
+# - #delete_suffix: Returns a copy of +self+ with a given suffix removed.
+# - #lstrip: Returns a copy of +self+ with leading whitespace removed.
+# - #rstrip: Returns a copy of +self+ with trailing whitespace removed.
+# - #strip: Returns a copy of +self+ with leading and trailing whitespace removed.
+# - #chomp: Returns a copy of +self+ with a trailing record separator removed, if found.
+# - #chop: Returns a copy of +self+ with trailing newline characters or the last character removed.
+# - #squeeze: Returns a copy of +self+ with contiguous duplicate characters removed.
+# - #[] (aliased as #slice): Returns a substring determined by a given index, start/length, range, regexp, or string.
+# - #byteslice: Returns a substring determined by a given index, start/length, or range.
+# - #chr: Returns the first character.
+#
+# _Duplication_
+#
+# - #to_s (aliased as #to_str): If +self+ is a subclass of +String+, returns +self+ copied into a +String+;
+# otherwise, returns +self+.
+#
+# === Converting to Non-\String
+#
+# Each of these methods converts the contents of +self+ to a non-+String+.
+#
+# <em>Characters, Bytes, and Clusters</em>
+#
+# - #bytes: Returns an array of the bytes in +self+.
+# - #chars: Returns an array of the characters in +self+.
+# - #codepoints: Returns an array of the integer ordinals in +self+.
+# - #getbyte: Returns the integer byte at the given index in +self+.
+# - #grapheme_clusters: Returns an array of the grapheme clusters in +self+.
+#
+# _Splitting_
+#
+# - #lines: Returns an array of the lines in +self+, as determined by a given record separator.
+# - #partition: Returns a 3-element array determined by the first substring that matches
+# a given substring or regexp.
+# - #rpartition: Returns a 3-element array determined by the last substring that matches
+# a given substring or regexp.
+# - #split: Returns an array of substrings determined by a given delimiter -- regexp or string --
+# or, if a block is given, passes those substrings to the block.
+#
+# _Matching_
+#
+# - #scan: Returns an array of substrings matching a given regexp or string, or,
+# if a block is given, passes each matching substring to the block.
+# - #unpack: Returns an array of substrings extracted from +self+ according to a given format.
+# - #unpack1: Returns the first substring extracted from +self+ according to a given format.
+#
+# _Numerics_
+#
+# - #hex: Returns the integer value of the leading characters, interpreted as hexadecimal digits.
+# - #oct: Returns the integer value of the leading characters, interpreted as octal digits.
+# - #ord: Returns the integer ordinal of the first character in +self+.
+# - #to_c: Returns the complex value of leading characters, interpreted as a complex number.
+# - #to_i: Returns the integer value of leading characters, interpreted as an integer.
+# - #to_f: Returns the floating-point value of leading characters, interpreted as a floating-point number.
+# - #to_r: Returns the rational value of leading characters, interpreted as a rational.
+#
+# <em>Strings and Symbols</em>
+#
+# - #inspect: Returns a copy of +self+, enclosed in double quotes, with special characters escaped.
+# - #intern (aliased as #to_sym): Returns the symbol corresponding to +self+.
+#
+# === Iterating
+#
+# - #each_byte: Calls the given block with each successive byte in +self+.
+# - #each_char: Calls the given block with each successive character in +self+.
+# - #each_codepoint: Calls the given block with each successive integer codepoint in +self+.
+# - #each_grapheme_cluster: Calls the given block with each successive grapheme cluster in +self+.
+# - #each_line: Calls the given block with each successive line in +self+,
+# as determined by a given record separator.
+# - #upto: Calls the given block with each string value returned by successive calls to #succ.
+
+class String; end
diff --git a/doc/string/aref.rdoc b/doc/string/aref.rdoc
new file mode 100644
index 0000000000..a9ab8857bc
--- /dev/null
+++ b/doc/string/aref.rdoc
@@ -0,0 +1,96 @@
+Returns the substring of +self+ specified by the arguments.
+
+<b>Form <tt>self[offset]</tt></b>
+
+With non-negative integer argument +offset+ given,
+returns the 1-character substring found in self at character offset +offset+:
+
+ 'hello'[0] # => "h"
+ 'hello'[4] # => "o"
+ 'hello'[5] # => nil
+ 'ã“ã‚“ã«ã¡ã¯'[4] # => "ã¯"
+
+With negative integer argument +offset+ given,
+counts backward from the end of +self+:
+
+ 'hello'[-1] # => "o"
+ 'hello'[-5] # => "h"
+ 'hello'[-6] # => nil
+
+<b>Form <tt>self[offset, size]</tt></b>
+
+With integer arguments +offset+ and +size+ given,
+returns a substring of size +size+ characters (as available)
+beginning at character offset specified by +offset+.
+
+If argument +offset+ is non-negative,
+the offset is +offset+:
+
+ 'hello'[0, 1] # => "h"
+ 'hello'[0, 5] # => "hello"
+ 'hello'[0, 6] # => "hello"
+ 'hello'[2, 3] # => "llo"
+ 'hello'[2, 0] # => ""
+ 'hello'[2, -1] # => nil
+
+If argument +offset+ is negative,
+counts backward from the end of +self+:
+
+ 'hello'[-1, 1] # => "o"
+ 'hello'[-5, 5] # => "hello"
+ 'hello'[-1, 0] # => ""
+ 'hello'[-6, 5] # => nil
+
+Special case: if +offset+ equals the size of +self+,
+returns a new empty string:
+
+ 'hello'[5, 3] # => ""
+
+<b>Form <tt>self[range]</tt></b>
+
+With Range argument +range+ given,
+forms substring <tt>self[range.start, range.size]</tt>:
+
+ 'hello'[0..2] # => "hel"
+ 'hello'[0, 3] # => "hel"
+
+ 'hello'[0...2] # => "he"
+ 'hello'[0, 2] # => "he"
+
+ 'hello'[0, 0] # => ""
+ 'hello'[0...0] # => ""
+
+<b>Form <tt>self[regexp, capture = 0]</tt></b>
+
+With Regexp argument +regexp+ given and +capture+ as zero,
+searches for a matching substring in +self+;
+updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ 'hello'[/ell/] # => "ell"
+ 'hello'[/l+/] # => "ll"
+ 'hello'[//] # => ""
+ 'hello'[/nosuch/] # => nil
+
+With +capture+ as a positive integer +n+,
+returns the +n+th matched group:
+
+ 'hello'[/(h)(e)(l+)(o)/] # => "hello"
+ 'hello'[/(h)(e)(l+)(o)/, 1] # => "h"
+ $1 # => "h"
+ 'hello'[/(h)(e)(l+)(o)/, 2] # => "e"
+ $2 # => "e"
+ 'hello'[/(h)(e)(l+)(o)/, 3] # => "ll"
+ 'hello'[/(h)(e)(l+)(o)/, 4] # => "o"
+ 'hello'[/(h)(e)(l+)(o)/, 5] # => nil
+
+<b>Form <tt>self[substring]</tt></b>
+
+With string argument +substring+ given,
+returns the matching substring of +self+, if found:
+
+ 'hello'['ell'] # => "ell"
+ 'hello'[''] # => ""
+ 'hello'['nosuch'] # => nil
+ 'ã“ã‚“ã«ã¡ã¯'['ã‚“ã«ã¡'] # => "ã‚“ã«ã¡"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/aset.rdoc b/doc/string/aset.rdoc
new file mode 100644
index 0000000000..98c58b59cc
--- /dev/null
+++ b/doc/string/aset.rdoc
@@ -0,0 +1,179 @@
+Returns +self+ with all, a substring, or none of its contents replaced;
+returns the argument +other_string+.
+
+<b>Form <tt>self[index] = other_string</tt></b>
+
+With non-negative integer argument +index+ given,
+searches for the 1-character substring found in self at character offset index:
+
+ s = 'hello'
+ s[0] = 'foo' # => "foo"
+ s # => "fooello"
+
+ s = 'hello'
+ s[4] = 'foo' # => "foo"
+ s # => "hellfoo"
+
+ s = 'hello'
+ s[5] = 'foo' # => "foo"
+ s # => "hellofoo"
+
+ s = 'hello'
+ s[6] = 'foo' # Raises IndexError: index 6 out of string.
+
+With negative integer argument +index+ given,
+counts backward from the end of +self+:
+
+ s = 'hello'
+ s[-1] = 'foo' # => "foo"
+ s # => "hellfoo"
+
+ s = 'hello'
+ s[-5] = 'foo' # => "foo"
+ s # => "fooello"
+
+ s = 'hello'
+ s[-6] = 'foo' # Raises IndexError: index -6 out of string.
+
+<b>Form <tt>self[start, length] = other_string</tt></b>
+
+With integer arguments +start+ and +length+ given,
+searches for a substring of size +length+ characters (as available)
+beginning at character offset specified by +start+.
+
+If argument +start+ is non-negative,
+the offset is +start+:
+
+ s = 'hello'
+ s[0, 1] = 'foo' # => "foo"
+ s # => "fooello"
+
+ s = 'hello'
+ s[0, 5] = 'foo' # => "foo"
+ s # => "foo"
+
+ s = 'hello'
+ s[0, 9] = 'foo' # => "foo"
+ s # => "foo"
+
+ s = 'hello'
+ s[2, 0] = 'foo' # => "foo"
+ s # => "hefoollo"
+
+ s = 'hello'
+ s[2, -1] = 'foo' # Raises IndexError: negative length -1.
+
+If argument +start+ is negative,
+counts backward from the end of +self+:
+
+ s = 'hello'
+ s[-1, 1] = 'foo' # => "foo"
+ s # => "hellfoo"
+
+ s = 'hello'
+ s[-1, 9] = 'foo' # => "foo"
+ s # => "hellfoo"
+
+ s = 'hello'
+ s[-5, 2] = 'foo' # => "foo"
+ s # => "foollo"
+
+ s = 'hello'
+ s[-3, 0] = 'foo' # => "foo"
+ s # => "hefoollo"
+
+ s = 'hello'
+ s[-6, 2] = 'foo' # Raises IndexError: index -6 out of string.
+
+Special case: if +start+ equals the length of +self+,
+the argument is appended to +self+:
+
+ s = 'hello'
+ s[5, 3] = 'foo' # => "foo"
+ s # => "hellofoo"
+
+<b>Form <tt>self[range] = other_string</tt></b>
+
+With Range argument +range+ given,
+equivalent to <tt>self[range.start, range.size] = other_string</tt>:
+
+ s0 = 'hello'
+ s1 = 'hello'
+ s0[0..2] = 'foo' # => "foo"
+ s1[0, 3] = 'foo' # => "foo"
+ s0 # => "foolo"
+ s1 # => "foolo"
+
+ s = 'hello'
+ s[0...2] = 'foo' # => "foo"
+ s # => "foollo"
+
+ s = 'hello'
+ s[0...0] = 'foo' # => "foo"
+ s # => "foohello"
+
+ s = 'hello'
+ s[9..10] = 'foo' # Raises RangeError: 9..10 out of range
+
+<b>Form <tt>self[regexp, capture = 0] = other_string</tt></b>
+
+With Regexp argument +regexp+ given and +capture+ as zero,
+searches for a matching substring in +self+;
+updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ s = 'hello'
+ s[/l/] = 'L' # => "L"
+ [$`, $&, $'] # => ["he", "l", "lo"]
+ s[/eLlo/] = 'owdy' # => "owdy"
+ [$`, $&, $'] # => ["h", "eLlo", ""]
+ s[/eLlo/] = 'owdy' # Raises IndexError: regexp not matched.
+ [$`, $&, $'] # => [nil, nil, nil]
+
+With +capture+ as a positive integer +n+,
+searches for the +n+th matched group:
+
+ s = 'hello'
+ s[/(h)(e)(l+)(o)/] = 'foo' # => "foo"
+ [$`, $&, $'] # => ["", "hello", ""]
+
+ s = 'hello'
+ s[/(h)(e)(l+)(o)/, 1] = 'foo' # => "foo"
+ s # => "fooello"
+ [$`, $&, $'] # => ["", "hello", ""]
+
+ s = 'hello'
+ s[/(h)(e)(l+)(o)/, 2] = 'foo' # => "foo"
+ s # => "hfoollo"
+ [$`, $&, $'] # => ["", "hello", ""]
+
+ s = 'hello'
+ s[/(h)(e)(l+)(o)/, 4] = 'foo' # => "foo"
+ s # => "hellfoo"
+ [$`, $&, $'] # => ["", "hello", ""]
+
+ s = 'hello'
+ # => "hello"
+ s[/(h)(e)(l+)(o)/, 5] = 'foo # Raises IndexError: index 5 out of regexp.
+
+ s = 'hello'
+ s[/nosuch/] = 'foo' # Raises IndexError: regexp not matched.
+
+<b>Form <tt>self[substring] = other_string</tt></b>
+
+With string argument +substring+ given:
+
+ s = 'hello'
+ s['l'] = 'foo' # => "foo"
+ s # => "hefoolo"
+
+ s = 'hello'
+ s['ll'] = 'foo' # => "foo"
+ s # => "hefooo"
+
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s['ã‚“ã«ã¡'] = 'foo' # => "foo"
+ s # => "ã“fooã¯"
+
+ s['nosuch'] = 'foo' # Raises IndexError: string not matched.
+
+Related: see {Modifying}[rdoc-ref:String@Modifying].
diff --git a/doc/string/b.rdoc b/doc/string/b.rdoc
index f8ad2910b4..8abd6d9532 100644
--- a/doc/string/b.rdoc
+++ b/doc/string/b.rdoc
@@ -12,3 +12,5 @@ the underlying bytes are not modified:
t = s.b # => "\xE4\x82\x95"
t.encoding # => #<Encoding:ASCII-8BIT>
t.bytes # => [228, 130, 149]
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/bytes.rdoc b/doc/string/bytes.rdoc
index a9e89f1cd1..16fa8e0bb0 100644
--- a/doc/string/bytes.rdoc
+++ b/doc/string/bytes.rdoc
@@ -1,6 +1,7 @@
Returns an array of the bytes in +self+:
- 'hello'.bytes # => [104, 101, 108, 108, 111]
- 'теÑÑ‚'.bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
+ 'hello'.bytes # => [104, 101, 108, 108, 111]
'ã“ã‚“ã«ã¡ã¯'.bytes
# => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/bytesize.rdoc b/doc/string/bytesize.rdoc
index b0567ff67b..8d12a0d454 100644
--- a/doc/string/bytesize.rdoc
+++ b/doc/string/bytesize.rdoc
@@ -1,11 +1,12 @@
-Returns the count of bytes (not characters) in +self+:
+Returns the count of bytes in +self+.
- 'foo'.bytesize # => 3
- 'теÑÑ‚'.bytesize # => 8
- 'ã“ã‚“ã«ã¡ã¯'.bytesize # => 15
+Note that the byte count may be different from the character count (returned by #size):
-Contrast with String#length:
+ s = 'foo'
+ s.bytesize # => 3
+ s.size # => 3
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.bytesize # => 15
+ s.size # => 5
- 'foo'.length # => 3
- 'теÑÑ‚'.length # => 4
- 'ã“ã‚“ã«ã¡ã¯'.length # => 5
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/byteslice.rdoc b/doc/string/byteslice.rdoc
new file mode 100644
index 0000000000..d70441fb2b
--- /dev/null
+++ b/doc/string/byteslice.rdoc
@@ -0,0 +1,54 @@
+Returns a substring of +self+, or +nil+ if the substring cannot be constructed.
+
+With integer arguments +offset+ and +length+ given,
+returns the substring beginning at the given +offset+
+and of the given +length+ (as available):
+
+ s = '0123456789' # => "0123456789"
+ s.byteslice(2) # => "2"
+ s.byteslice(200) # => nil
+ s.byteslice(4, 3) # => "456"
+ s.byteslice(4, 30) # => "456789"
+
+Returns +nil+ if +length+ is negative or +offset+ falls outside of +self+:
+
+ s.byteslice(4, -1) # => nil
+ s.byteslice(40, 2) # => nil
+
+Counts backwards from the end of +self+
+if +offset+ is negative:
+
+ s = '0123456789' # => "0123456789"
+ s.byteslice(-4) # => "6"
+ s.byteslice(-4, 3) # => "678"
+
+With Range argument +range+ given, returns
+<tt>byteslice(range.begin, range.size)</tt>:
+
+ s = '0123456789' # => "0123456789"
+ s.byteslice(4..6) # => "456"
+ s.byteslice(-6..-4) # => "456"
+ s.byteslice(5..2) # => "" # range.size is zero.
+ s.byteslice(40..42) # => nil
+
+The starting and ending offsets need not be on character boundaries:
+
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.byteslice(0, 3) # => "ã“"
+ s.byteslice(1, 3) # => "\x81\x93\xE3"
+
+The encodings of +self+ and the returned substring
+are always the same:
+
+ s.encoding # => #<Encoding:UTF-8>
+ s.byteslice(0, 3).encoding # => #<Encoding:UTF-8>
+ s.byteslice(1, 3).encoding # => #<Encoding:UTF-8>
+
+But, depending on the character boundaries,
+the encoding of the returned substring may not be valid:
+
+ s.valid_encoding? # => true
+ s.byteslice(0, 3).valid_encoding? # => true
+ s.byteslice(1, 3).valid_encoding? # => false
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/bytesplice.rdoc b/doc/string/bytesplice.rdoc
new file mode 100644
index 0000000000..790f9eb9a0
--- /dev/null
+++ b/doc/string/bytesplice.rdoc
@@ -0,0 +1,65 @@
+Replaces <i>target bytes</i> in +self+ with <i>source bytes</i> from the given string +str+;
+returns +self+.
+
+In the first form, arguments +offset+ and +length+ determine the target bytes,
+and the source bytes are all of the given +str+:
+
+ '0123456789'.bytesplice(0, 3, 'abc') # => "abc3456789"
+ '0123456789'.bytesplice(3, 3, 'abc') # => "012abc6789"
+ '0123456789'.bytesplice(0, 50, 'abc') # => "abc"
+ '0123456789'.bytesplice(50, 3, 'abc') # Raises IndexError.
+
+The counts of the target bytes and source source bytes may be different:
+
+ '0123456789'.bytesplice(0, 6, 'abc') # => "abc6789" # Shorter source.
+ '0123456789'.bytesplice(0, 1, 'abc') # => "abc123456789" # Shorter target.
+
+And either count may be zero (i.e., specifying an empty string):
+
+ '0123456789'.bytesplice(0, 3, '') # => "3456789" # Empty source.
+ '0123456789'.bytesplice(0, 0, 'abc') # => "abc0123456789" # Empty target.
+
+In the second form, just as in the first,
+arguments +offset+ and +length+ determine the target bytes;
+argument +str+ _contains_ the source bytes,
+and the additional arguments +str_offset+ and +str_length+
+determine the actual source bytes:
+
+ '0123456789'.bytesplice(0, 3, 'abc', 0, 3) # => "abc3456789"
+ '0123456789'.bytesplice(0, 3, 'abc', 1, 1) # => "b3456789" # Shorter source.
+ '0123456789'.bytesplice(0, 1, 'abc', 0, 3) # => "abc123456789" # Shorter target.
+ '0123456789'.bytesplice(0, 3, 'abc', 1, 0) # => "3456789" # Empty source.
+ '0123456789'.bytesplice(0, 0, 'abc', 0, 3) # => "abc0123456789" # Empty target.
+
+In the third form, argument +range+ determines the target bytes
+and the source bytes are all of the given +str+:
+
+ '0123456789'.bytesplice(0..2, 'abc') # => "abc3456789"
+ '0123456789'.bytesplice(3..5, 'abc') # => "012abc6789"
+ '0123456789'.bytesplice(0..5, 'abc') # => "abc6789" # Shorter source.
+ '0123456789'.bytesplice(0..0, 'abc') # => "abc123456789" # Shorter target.
+ '0123456789'.bytesplice(0..2, '') # => "3456789" # Empty source.
+ '0123456789'.bytesplice(0...0, 'abc') # => "abc0123456789" # Empty target.
+
+In the fourth form, just as in the third,
+argument +range+ determines the target bytes;
+argument +str+ _contains_ the source bytes,
+and the additional argument +str_range+
+determines the actual source bytes:
+
+ '0123456789'.bytesplice(0..2, 'abc', 0..2) # => "abc3456789"
+ '0123456789'.bytesplice(3..5, 'abc', 0..2) # => "012abc6789"
+ '0123456789'.bytesplice(0..2, 'abc', 0..1) # => "ab3456789" # Shorter source.
+ '0123456789'.bytesplice(0..1, 'abc', 0..2) # => "abc23456789" # Shorter target.
+ '0123456789'.bytesplice(0..2, 'abc', 0...0) # => "3456789" # Empty source.
+ '0123456789'.bytesplice(0...0, 'abc', 0..2) # => "abc0123456789" # Empty target.
+
+In any of the forms, the beginnings and endings of both source and target
+must be on character boundaries.
+
+In these examples, +self+ has five 3-byte characters,
+and so has character boundaries at offsets 0, 3, 6, 9, 12, and 15.
+
+ 'ã“ã‚“ã«ã¡ã¯'.bytesplice(0, 3, 'abc') # => "abcã‚“ã«ã¡ã¯"
+ 'ã“ã‚“ã«ã¡ã¯'.bytesplice(1, 3, 'abc') # Raises IndexError.
+ 'ã“ã‚“ã«ã¡ã¯'.bytesplice(0, 2, 'abc') # Raises IndexError.
diff --git a/doc/string/capitalize.rdoc b/doc/string/capitalize.rdoc
new file mode 100644
index 0000000000..3a1a2dcb8b
--- /dev/null
+++ b/doc/string/capitalize.rdoc
@@ -0,0 +1,26 @@
+Returns a string containing the characters in +self+,
+each with possibly changed case:
+
+- The first character made uppercase.
+- All other characters are made lowercase.
+
+Examples:
+
+ 'hello'.capitalize # => "Hello"
+ 'HELLO'.capitalize # => "Hello"
+ 'straße'.capitalize # => "Straße" # Lowercase 'ß' not changed.
+ 'STRAẞE'.capitalize # => "Straße" # Uppercase 'ẞ' downcased to 'ß'.
+
+Some characters (and some character sets) do not have upcase and downcase versions;
+see {Case Mapping}[rdoc-ref:case_mapping.rdoc]:
+
+ s = '1, 2, 3, ...'
+ s.capitalize == s # => true
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.capitalize == s # => true
+
+The casing is affected by the given +mapping+,
+which may be +:ascii+, +:fold+, or +:turkic+;
+see {Case Mappings}[rdoc-ref:case_mapping.rdoc@Case+Mappings].
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/center.rdoc b/doc/string/center.rdoc
index d53d921ad5..b86c8b5916 100644
--- a/doc/string/center.rdoc
+++ b/doc/string/center.rdoc
@@ -2,15 +2,18 @@ Returns a centered copy of +self+.
If integer argument +size+ is greater than the size (in characters) of +self+,
returns a new string of length +size+ that is a copy of +self+,
-centered and padded on both ends with +pad_string+:
+centered and padded on one or both ends with +pad_string+:
- 'hello'.center(10) # => " hello "
- ' hello'.center(10) # => " hello "
- 'hello'.center(10, 'ab') # => "abhelloaba"
- 'теÑÑ‚'.center(10) # => " теÑÑ‚ "
- 'ã“ã‚“ã«ã¡ã¯'.center(10) # => " ã“ã‚“ã«ã¡ã¯ "
+ 'hello'.center(6) # => "hello " # Padded on one end.
+ 'hello'.center(10) # => " hello " # Padded on both ends.
+ 'hello'.center(20, '-|') # => "-|-|-|-hello-|-|-|-|" # Some padding repeated.
+ 'hello'.center(10, 'abcdefg') # => "abhelloabc" # Some padding not used.
+ ' hello '.center(13) # => " hello "
+ 'ã“ã‚“ã«ã¡ã¯'.center(10) # => " ã“ã‚“ã«ã¡ã¯ " # Multi-byte characters.
-If +size+ is not greater than the size of +self+, returns a copy of +self+:
+If +size+ is less than or equal to the size of +self+, returns an unpadded copy of +self+:
- 'hello'.center(5) # => "hello"
- 'hello'.center(1) # => "hello"
+ 'hello'.center(5) # => "hello"
+ 'hello'.center(-10) # => "hello"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/chars.rdoc b/doc/string/chars.rdoc
index d24a1cc3a9..47fb01b43a 100644
--- a/doc/string/chars.rdoc
+++ b/doc/string/chars.rdoc
@@ -1,5 +1,7 @@
Returns an array of the characters in +self+:
'hello'.chars # => ["h", "e", "l", "l", "o"]
- 'теÑÑ‚'.chars # => ["Ñ‚", "е", "Ñ", "Ñ‚"]
'ã“ã‚“ã«ã¡ã¯'.chars # => ["ã“", "ã‚“", "ã«", "ã¡", "ã¯"]
+ ''.chars # => []
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/chomp.rdoc b/doc/string/chomp.rdoc
index b6fb9ff38c..4efff5c291 100644
--- a/doc/string/chomp.rdoc
+++ b/doc/string/chomp.rdoc
@@ -9,7 +9,6 @@ if they are <tt>"\r"</tt>, <tt>"\n"</tt>, or <tt>"\r\n"</tt>
"abc\n".chomp # => "abc"
"abc\r\n".chomp # => "abc"
"abc\n\r".chomp # => "abc\n"
- "теÑÑ‚\r\n".chomp # => "теÑÑ‚"
"ã“ã‚“ã«ã¡ã¯\r\n".chomp # => "ã“ã‚“ã«ã¡ã¯"
When +line_sep+ is <tt>''</tt> (an empty string),
@@ -25,5 +24,8 @@ removes multiple trailing occurrences of <tt>"\n"</tt> or <tt>"\r\n"</tt>
When +line_sep+ is neither <tt>"\n"</tt> nor <tt>''</tt>,
removes a single trailing line separator if there is one:
- 'abcd'.chomp('d') # => "abc"
- 'abcdd'.chomp('d') # => "abcd"
+ 'abcd'.chomp('cd') # => "ab"
+ 'abcdcd'.chomp('cd') # => "abcd"
+ 'abcd'.chomp('xx') # => "abcd"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/chop.rdoc b/doc/string/chop.rdoc
index 8ef82f8a49..d818ba467a 100644
--- a/doc/string/chop.rdoc
+++ b/doc/string/chop.rdoc
@@ -3,14 +3,15 @@ Returns a new string copied from +self+, with trailing characters possibly remov
Removes <tt>"\r\n"</tt> if those are the last two characters.
"abc\r\n".chop # => "abc"
- "теÑÑ‚\r\n".chop # => "теÑÑ‚"
"ã“ã‚“ã«ã¡ã¯\r\n".chop # => "ã“ã‚“ã«ã¡ã¯"
Otherwise removes the last character if it exists.
'abcd'.chop # => "abc"
- 'теÑÑ‚'.chop # => "теÑ"
'ã“ã‚“ã«ã¡ã¯'.chop # => "ã“ã‚“ã«ã¡"
''.chop # => ""
-If you only need to remove the newline separator at the end of the string, String#chomp is a better alternative.
+If you only need to remove the newline separator at the end of the string,
+String#chomp is a better alternative.
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/chr.rdoc b/doc/string/chr.rdoc
new file mode 100644
index 0000000000..153d5d71c3
--- /dev/null
+++ b/doc/string/chr.rdoc
@@ -0,0 +1,7 @@
+Returns a string containing the first character of +self+:
+
+ 'hello'.chr # => "h"
+ 'ã“ã‚“ã«ã¡ã¯'.chr # => "ã“"
+ ''.chr # => ""
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/codepoints.rdoc b/doc/string/codepoints.rdoc
index 0c55d3f4b9..0ad866389e 100644
--- a/doc/string/codepoints.rdoc
+++ b/doc/string/codepoints.rdoc
@@ -2,5 +2,7 @@ Returns an array of the codepoints in +self+;
each codepoint is the integer value for a character:
'hello'.codepoints # => [104, 101, 108, 108, 111]
- 'теÑÑ‚'.codepoints # => [1090, 1077, 1089, 1090]
'ã“ã‚“ã«ã¡ã¯'.codepoints # => [12371, 12435, 12395, 12385, 12399]
+ ''.codepoints # => []
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/concat.rdoc b/doc/string/concat.rdoc
new file mode 100644
index 0000000000..92ba664b8c
--- /dev/null
+++ b/doc/string/concat.rdoc
@@ -0,0 +1,11 @@
+Concatenates each object in +objects+ to +self+; returns +self+:
+
+ 'foo'.concat('bar', 'baz') # => "foobarbaz"
+
+For each given object +object+ that is an integer,
+the value is considered a codepoint and converted to a character before concatenation:
+
+ 'foo'.concat(32, 'bar', 32, 'baz') # => "foo bar baz" # Embeds spaces.
+ 'ã“ã‚“'.concat(12395, 12385, 12399) # => "ã“ã‚“ã«ã¡ã¯"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/count.rdoc b/doc/string/count.rdoc
new file mode 100644
index 0000000000..7a3b9f1e21
--- /dev/null
+++ b/doc/string/count.rdoc
@@ -0,0 +1,74 @@
+Returns the total number of characters in +self+ that are specified by the given selectors.
+
+For one 1-character selector,
+returns the count of instances of that character:
+
+ s = 'abracadabra'
+ s.count('a') # => 5
+ s.count('b') # => 2
+ s.count('x') # => 0
+ s.count('') # => 0
+
+ s = 'よã‚ã—ããŠé¡˜ã„ã—ã¾ã™'
+ s.count('よ') # => 1
+ s.count('ã—') # => 2
+
+For one multi-character selector,
+returns the count of instances for all specified characters:
+
+ s = 'abracadabra'
+ s.count('ab') # => 7
+ s.count('abc') # => 8
+ s.count('abcd') # => 9
+ s.count('abcdr') # => 11
+ s.count('abcdrx') # => 11
+
+Order and repetition do not matter:
+
+ s.count('ba') == s.count('ab') # => true
+ s.count('baab') == s.count('ab') # => true
+
+For multiple selectors,
+forms a single selector that is the intersection of characters in all selectors
+and returns the count of instances for that selector:
+
+ s = 'abcdefg'
+ s.count('abcde', 'dcbfg') == s.count('bcd') # => true
+ s.count('abc', 'def') == s.count('') # => true
+
+In a character selector, three characters get special treatment:
+
+- A caret (<tt>'^'</tt>) functions as a _negation_ operator
+ for the immediately following characters:
+
+ s = 'abracadabra'
+ s.count('^bc') # => 8 # Count of all except 'b' and 'c'.
+
+- A hyphen (<tt>'-'</tt>) between two other characters defines a _range_ of characters:
+
+ s = 'abracadabra'
+ s.count('a-c') # => 8 # Count of all 'a', 'b', and 'c'.
+
+- A backslash (<tt>'\'</tt>) acts as an escape for a caret, a hyphen,
+ or another backslash:
+
+ s = 'abracadabra'
+ s.count('\^bc') # => 3 # Count of '^', 'b', and 'c'.
+ s.count('a\-c') # => 6 # Count of 'a', '-', and 'c'.
+ 'foo\bar\baz'.count('\\') # => 2 # Count of '\'.
+
+These usages may be mixed:
+
+ s = 'abracadabra'
+ s.count('a-cq-t') # => 10 # Multiple ranges.
+ s.count('ac-d') # => 7 # Range mixed with plain characters.
+ s.count('^a-c') # => 3 # Range mixed with negation.
+
+For multiple selectors, all forms may be used, including negations, ranges, and escapes.
+
+ s = 'abracadabra'
+ s.count('^abc', '^def') == s.count('^abcdef') # => true
+ s.count('a-e', 'c-g') == s.count('cde') # => true
+ s.count('^abc', 'c-g') == s.count('defg') # => true
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/delete.rdoc b/doc/string/delete.rdoc
new file mode 100644
index 0000000000..1827f177e6
--- /dev/null
+++ b/doc/string/delete.rdoc
@@ -0,0 +1,75 @@
+Returns a new string that is a copy of +self+ with certain characters removed;
+the removed characters are all instances of those specified by the given string +selectors+.
+
+For one 1-character selector,
+removes all instances of that character:
+
+ s = 'abracadabra'
+ s.delete('a') # => "brcdbr"
+ s.delete('b') # => "aracadara"
+ s.delete('x') # => "abracadabra"
+ s.delete('') # => "abracadabra"
+
+ s = 'よã‚ã—ããŠé¡˜ã„ã—ã¾ã™'
+ s.delete('よ') # => "ã‚ã—ããŠé¡˜ã„ã—ã¾ã™"
+ s.delete('ã—') # => "よã‚ããŠé¡˜ã„ã¾ã™"
+
+For one multi-character selector,
+removes all instances of the specified characters:
+
+ s = 'abracadabra'
+ s.delete('ab') # => "rcdr"
+ s.delete('abc') # => "rdr"
+ s.delete('abcd') # => "rr"
+ s.delete('abcdr') # => ""
+ s.delete('abcdrx') # => ""
+
+Order and repetition do not matter:
+
+ s.delete('ba') == s.delete('ab') # => true
+ s.delete('baab') == s.delete('ab') # => true
+
+For multiple selectors,
+forms a single selector that is the intersection of characters in all selectors
+and removes all instances of characters specified by that selector:
+
+ s = 'abcdefg'
+ s.delete('abcde', 'dcbfg') == s.delete('bcd') # => true
+ s.delete('abc', 'def') == s.delete('') # => true
+
+In a character selector, three characters get special treatment:
+
+- A caret (<tt>'^'</tt>) functions as a _negation_ operator
+ for the immediately following characters:
+
+ s = 'abracadabra'
+ s.delete('^bc') # => "bcb" # Deletes all except 'b' and 'c'.
+
+- A hyphen (<tt>'-'</tt>) between two other characters defines a _range_ of characters:
+
+ s = 'abracadabra'
+ s.delete('a-c') # => "rdr" # Deletes all 'a', 'b', and 'c'.
+
+- A backslash (<tt>'\'</tt>) acts as an escape for a caret, a hyphen,
+ or another backslash:
+
+ s = 'abracadabra'
+ s.delete('\^bc') # => "araadara" # Deletes all '^', 'b', and 'c'.
+ s.delete('a\-c') # => "brdbr" # Deletes all 'a', '-', and 'c'.
+ 'foo\bar\baz'.delete('\\') # => "foobarbaz" # Deletes all '\'.
+
+These usages may be mixed:
+
+ s = 'abracadabra'
+ s.delete('a-cq-t') # => "d" # Multiple ranges.
+ s.delete('ac-d') # => "brbr" # Range mixed with plain characters.
+ s.delete('^a-c') # => "abacaaba" # Range mixed with negation.
+
+For multiple selectors, all forms may be used, including negations, ranges, and escapes.
+
+ s = 'abracadabra'
+ s.delete('^abc', '^def') == s.delete('^abcdef') # => true
+ s.delete('a-e', 'c-g') == s.delete('cde') # => true
+ s.delete('^abc', 'c-g') == s.delete('defg') # => true
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/delete_prefix.rdoc b/doc/string/delete_prefix.rdoc
index fa9d8abd38..6255e300e3 100644
--- a/doc/string/delete_prefix.rdoc
+++ b/doc/string/delete_prefix.rdoc
@@ -1,8 +1,9 @@
-Returns a copy of +self+ with leading substring <tt>prefix</tt> removed:
+Returns a copy of +self+ with leading substring +prefix+ removed:
- 'hello'.delete_prefix('hel') # => "lo"
- 'hello'.delete_prefix('llo') # => "hello"
- 'теÑÑ‚'.delete_prefix('те') # => "ÑÑ‚"
+ 'oof'.delete_prefix('o') # => "of"
+ 'oof'.delete_prefix('oo') # => "f"
+ 'oof'.delete_prefix('oof') # => ""
+ 'oof'.delete_prefix('x') # => "oof"
'ã“ã‚“ã«ã¡ã¯'.delete_prefix('ã“ã‚“') # => "ã«ã¡ã¯"
-Related: String#delete_prefix!, String#delete_suffix.
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/delete_suffix.rdoc b/doc/string/delete_suffix.rdoc
index 4862b725cf..a4d9a80f85 100644
--- a/doc/string/delete_suffix.rdoc
+++ b/doc/string/delete_suffix.rdoc
@@ -1,8 +1,10 @@
Returns a copy of +self+ with trailing substring <tt>suffix</tt> removed:
- 'hello'.delete_suffix('llo') # => "he"
- 'hello'.delete_suffix('hel') # => "hello"
- 'теÑÑ‚'.delete_suffix('ÑÑ‚') # => "те"
+ 'foo'.delete_suffix('o') # => "fo"
+ 'foo'.delete_suffix('oo') # => "f"
+ 'foo'.delete_suffix('foo') # => ""
+ 'foo'.delete_suffix('f') # => "foo"
+ 'foo'.delete_suffix('x') # => "foo"
'ã“ã‚“ã«ã¡ã¯'.delete_suffix('ã¡ã¯') # => "ã“ã‚“ã«"
-Related: String#delete_suffix!, String#delete_prefix.
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/downcase.rdoc b/doc/string/downcase.rdoc
new file mode 100644
index 0000000000..d5fffa037b
--- /dev/null
+++ b/doc/string/downcase.rdoc
@@ -0,0 +1,20 @@
+Returns a new string containing the downcased characters in +self+:
+
+ 'HELLO'.downcase # => "hello"
+ 'STRAẞE'.downcase # => "straße"
+ 'ПРИВЕТ'.downcase # => "привет"
+ 'RubyGems.org'.downcase # => "rubygems.org"
+
+Some characters (and some character sets) do not have upcase and downcase versions;
+see {Case Mapping}[rdoc-ref:case_mapping.rdoc]:
+
+ s = '1, 2, 3, ...'
+ s.downcase == s # => true
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.downcase == s # => true
+
+The casing is affected by the given +mapping+,
+which may be +:ascii+, +:fold+, or +:turkic+;
+see {Case Mappings}[rdoc-ref:case_mapping.rdoc@Case+Mappings].
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/dump.rdoc b/doc/string/dump.rdoc
new file mode 100644
index 0000000000..7b688c28a6
--- /dev/null
+++ b/doc/string/dump.rdoc
@@ -0,0 +1,89 @@
+For an ordinary string, this method, +String#dump+,
+returns a printable ASCII-only version of +self+, enclosed in double-quotes.
+
+For a dumped string, method String#undump is the inverse of +String#dump+;
+it returns a "restored" version of +self+,
+where all the dumping changes have been undone.
+
+In the simplest case, the dumped string contains the original string,
+enclosed in double-quotes;
+this example is done in +irb+ (interactive Ruby), which uses method `inspect` to render the results:
+
+ s = 'hello' # => "hello"
+ s.dump # => "\"hello\""
+ s.dump.undump # => "hello"
+
+Keep in mind that in the second line above:
+
+- The outer double-quotes are put on by +inspect+,
+ and _are_ _not_ part of the output of #dump.
+- The inner double-quotes _are_ part of the output of +dump+,
+ and are escaped by +inspect+ because they are within the outer double-quotes.
+
+To avoid confusion, we'll use this helper method to omit the outer double-quotes:
+
+ def dump(s)
+ print "String: ", s, "\n"
+ print "Dumped: ", s.dump, "\n"
+ print "Undumped: ", s.dump.undump, "\n"
+ end
+
+So that for string <tt>'hello'</tt>, we'll see:
+
+ String: hello
+ Dumped: "hello"
+ Undumped: hello
+
+In a dump, certain special characters are escaped:
+
+ String: "
+ Dumped: "\""
+ Undumped: "
+
+ String: \
+ Dumped: "\\"
+ Undumped: \
+
+In a dump, unprintable characters are replaced by printable ones;
+the unprintable characters are the whitespace characters (other than space itself);
+here we see the ordinals for those characters, together with explanatory text:
+
+ h = {
+ 7 => 'Alert (BEL)',
+ 8 => 'Backspace (BS)',
+ 9 => 'Horizontal tab (HT)',
+ 10 => 'Linefeed (LF)',
+ 11 => 'Vertical tab (VT)',
+ 12 => 'Formfeed (FF)',
+ 13 => 'Carriage return (CR)'
+ }
+
+In this example, the dumped output is printed by method #inspect,
+and so contains both outer double-quotes and escaped inner double-quotes:
+
+ s = ''
+ h.keys.each {|i| s << i } # => [7, 8, 9, 10, 11, 12, 13]
+ s # => "\a\b\t\n\v\f\r"
+ s.dump # => "\"\\a\\b\\t\\n\\v\\f\\r\""
+
+If +self+ is encoded in UTF-8 and contains Unicode characters,
+each Unicode character is dumped as a Unicode escape sequence:
+
+ String: ã“ã‚“ã«ã¡ã¯
+ Dumped: "\u3053\u3093\u306B\u3061\u306F"
+ Undumped: ã“ã‚“ã«ã¡ã¯
+
+If the encoding of +self+ is not ASCII-compatible
+(i.e., if <tt>self.encoding.ascii_compatible?</tt> returns +false+),
+each ASCII-compatible byte is dumped as an ASCII character,
+and all other bytes are dumped as hexadecimal;
+also appends <tt>.dup.force_encoding(\"encoding\")</tt>,
+where <tt><encoding></tt> is <tt>self.encoding.name</tt>:
+
+ String: hello
+ Dumped: "\xFE\xFF\x00h\x00e\x00l\x00l\x00o".dup.force_encoding("UTF-16")
+ Undumped: hello
+
+ String: ã“ã‚“ã«ã¡ã¯
+ Dumped: "\xFE\xFF0S0\x930k0a0o".dup.force_encoding("UTF-16")
+ Undumped: ã“ã‚“ã«ã¡ã¯
diff --git a/doc/string/each_byte.rdoc b/doc/string/each_byte.rdoc
index 643118fea3..642d71e84b 100644
--- a/doc/string/each_byte.rdoc
+++ b/doc/string/each_byte.rdoc
@@ -1,17 +1,15 @@
-Calls the given block with each successive byte from +self+;
+With a block given, calls the block with each successive byte from +self+;
returns +self+:
- 'hello'.each_byte {|byte| print byte, ' ' }
- print "\n"
- 'теÑÑ‚'.each_byte {|byte| print byte, ' ' }
- print "\n"
- 'ã“ã‚“ã«ã¡ã¯'.each_byte {|byte| print byte, ' ' }
- print "\n"
+ a = []
+ 'hello'.each_byte {|byte| a.push(byte) } # Five 1-byte characters.
+ a # => [104, 101, 108, 108, 111]
+ a = []
+ 'ã“ã‚“ã«ã¡ã¯'.each_byte {|byte| a.push(byte) } # Five 3-byte characters.
+ a # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
-Output:
+With no block given, returns an enumerator.
+
+Related: see {Iterating}[rdoc-ref:String@Iterating].
- 104 101 108 108 111
- 209 130 208 181 209 129 209 130
- 227 129 147 227 130 147 227 129 171 227 129 161 227 129 175
-Returns an enumerator if no block is given.
diff --git a/doc/string/each_char.rdoc b/doc/string/each_char.rdoc
index e5ae5a1812..2dd56711d3 100644
--- a/doc/string/each_char.rdoc
+++ b/doc/string/each_char.rdoc
@@ -1,17 +1,17 @@
-Calls the given block with each successive character from +self+;
+With a block given, calls the block with each successive character from +self+;
returns +self+:
- 'hello'.each_char {|char| print char, ' ' }
- print "\n"
- 'теÑÑ‚'.each_char {|char| print char, ' ' }
- print "\n"
- 'ã“ã‚“ã«ã¡ã¯'.each_char {|char| print char, ' ' }
- print "\n"
+ a = []
+ 'hello'.each_char do |char|
+ a.push(char)
+ end
+ a # => ["h", "e", "l", "l", "o"]
+ a = []
+ 'ã“ã‚“ã«ã¡ã¯'.each_char do |char|
+ a.push(char)
+ end
+ a # => ["ã“", "ã‚“", "ã«", "ã¡", "ã¯"]
-Output:
+With no block given, returns an enumerator.
- h e l l o
- Ñ‚ е Ñ Ñ‚
- ã“ ã‚“ ã« ã¡ ã¯
-
-Returns an enumerator if no block is given.
+Related: see {Iterating}[rdoc-ref:String@Iterating].
diff --git a/doc/string/each_codepoint.rdoc b/doc/string/each_codepoint.rdoc
index 88bfcbd1c0..8e4e7545e6 100644
--- a/doc/string/each_codepoint.rdoc
+++ b/doc/string/each_codepoint.rdoc
@@ -1,18 +1,18 @@
-Calls the given block with each successive codepoint from +self+;
-each codepoint is the integer value for a character;
+With a block given, calls the block with each successive codepoint from +self+;
+each {codepoint}[https://en.wikipedia.org/wiki/Code_point] is the integer value for a character;
returns +self+:
- 'hello'.each_codepoint {|codepoint| print codepoint, ' ' }
- print "\n"
- 'теÑÑ‚'.each_codepoint {|codepoint| print codepoint, ' ' }
- print "\n"
- 'ã“ã‚“ã«ã¡ã¯'.each_codepoint {|codepoint| print codepoint, ' ' }
- print "\n"
+ a = []
+ 'hello'.each_codepoint do |codepoint|
+ a.push(codepoint)
+ end
+ a # => [104, 101, 108, 108, 111]
+ a = []
+ 'ã“ã‚“ã«ã¡ã¯'.each_codepoint do |codepoint|
+ a.push(codepoint)
+ end
+ a # => [12371, 12435, 12395, 12385, 12399]
-Output:
+With no block given, returns an enumerator.
- 104 101 108 108 111
- 1090 1077 1089 1090
- 12371 12435 12395 12385 12399
-
-Returns an enumerator if no block is given.
+Related: see {Iterating}[rdoc-ref:String@Iterating].
diff --git a/doc/string/each_grapheme_cluster.rdoc b/doc/string/each_grapheme_cluster.rdoc
index 40be95fcac..384cd6967d 100644
--- a/doc/string/each_grapheme_cluster.rdoc
+++ b/doc/string/each_grapheme_cluster.rdoc
@@ -1,12 +1,19 @@
-Calls the given block with each successive grapheme cluster from +self+
+With a block given, calls the given block with each successive grapheme cluster from +self+
(see {Unicode Grapheme Cluster Boundaries}[https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries]);
returns +self+:
- s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈"
- s.each_grapheme_cluster {|gc| print gc, ' ' }
+ a = []
+ 'hello'.each_grapheme_cluster do |grapheme_cluster|
+ a.push(grapheme_cluster)
+ end
+ a # => ["h", "e", "l", "l", "o"]
-Output:
+ a = []
+ 'ã“ã‚“ã«ã¡ã¯'.each_grapheme_cluster do |grapheme_cluster|
+ a.push(grapheme_cluster)
+ end
+ a # => ["ã“", "ã‚“", "ã«", "ã¡", "ã¯"]
- ä - p q r - b̈ - x y z - c̈
+With no block given, returns an enumerator.
-Returns an enumerator if no block is given.
+Related: see {Iterating}[rdoc-ref:String@Iterating].
diff --git a/doc/string/each_line.rdoc b/doc/string/each_line.rdoc
index e254c22d40..217c188e35 100644
--- a/doc/string/each_line.rdoc
+++ b/doc/string/each_line.rdoc
@@ -1,9 +1,12 @@
-With a block given, forms the substrings ("lines")
+With a block given, forms the substrings (lines)
that are the result of splitting +self+
-at each occurrence of the given line separator +line_sep+;
+at each occurrence of the given +record_separator+;
passes each line to the block;
-returns +self+:
+returns +self+.
+With the default +record_separator+:
+
+ $/ # => "\n"
s = <<~EOT
This is the first line.
This is line two.
@@ -11,7 +14,6 @@ returns +self+:
This is line four.
This is line five.
EOT
-
s.each_line {|line| p line }
Output:
@@ -22,9 +24,10 @@ Output:
"This is line four.\n"
"This is line five.\n"
-With a different +line_sep+:
+With a different +record_separator+:
- s.each_line(' is ') {|line| p line }
+ record_separator = ' is '
+ s.each_line(record_separator) {|line| p line }
Output:
@@ -34,7 +37,7 @@ Output:
"line four.\nThis is "
"line five.\n"
-With +chomp+ as +true+, removes the trailing +line_sep+ from each line:
+With +chomp+ as +true+, removes the trailing +record_separator+ from each line:
s.each_line(chomp: true) {|line| p line }
@@ -46,11 +49,12 @@ Output:
"This is line four."
"This is line five."
-With an empty string as +line_sep+,
+With an empty string as +record_separator+,
forms and passes "paragraphs" by splitting at each occurrence
of two or more newlines:
- s.each_line('') {|line| p line }
+ record_separator = ''
+ s.each_line(record_separator) {|line| p line }
Output:
@@ -58,3 +62,5 @@ Output:
"This is line four.\nThis is line five.\n"
With no block given, returns an enumerator.
+
+Related: see {Iterating}[rdoc-ref:String@Iterating].
diff --git a/doc/string/encode.rdoc b/doc/string/encode.rdoc
index 65872fdfd4..14b959ffff 100644
--- a/doc/string/encode.rdoc
+++ b/doc/string/encode.rdoc
@@ -1,4 +1,6 @@
-Returns a copy of +self+ transcoded as determined by +dst_encoding+.
+Returns a copy of +self+ transcoded as determined by +dst_encoding+;
+see {Encodings}[rdoc-ref:encodings.rdoc].
+
By default, raises an exception if +self+
contains an invalid byte or a character not defined in +dst_encoding+;
that behavior may be modified by encoding options; see below.
@@ -45,3 +47,4 @@ given, conversion from an encoding +enc+ to the same encoding +enc+
no-op, i.e. the string is simply copied without any changes, and no
exceptions are raised, even if there are invalid bytes.
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/end_with_p.rdoc b/doc/string/end_with_p.rdoc
index f959cf7aaa..9a95d74fde 100644
--- a/doc/string/end_with_p.rdoc
+++ b/doc/string/end_with_p.rdoc
@@ -1,11 +1,9 @@
-Returns whether +self+ ends with any of the given +strings+.
+Returns whether +self+ ends with any of the given +strings+:
-Returns +true+ if any given string matches the end, +false+ otherwise:
+ 'foo'.end_with?('oo') # => true
+ 'foo'.end_with?('bar', 'oo') # => true
+ 'foo'.end_with?('bar', 'baz') # => false
+ 'foo'.end_with?('') # => true
+ 'ã“ã‚“ã«ã¡ã¯'.end_with?('ã¯') # => true
- 'hello'.end_with?('ello') #=> true
- 'hello'.end_with?('heaven', 'ello') #=> true
- 'hello'.end_with?('heaven', 'paradise') #=> false
- 'теÑÑ‚'.end_with?('Ñ‚') # => true
- 'ã“ã‚“ã«ã¡ã¯'.end_with?('ã¯') # => true
-
-Related: String#start_with?.
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/eql_p.rdoc b/doc/string/eql_p.rdoc
new file mode 100644
index 0000000000..85409c5ed6
--- /dev/null
+++ b/doc/string/eql_p.rdoc
@@ -0,0 +1,18 @@
+Returns whether +self+ and +object+ have the same length and content:
+
+ s = 'foo'
+ s.eql?('foo') # => true
+ s.eql?('food') # => false
+ s.eql?('FOO') # => false
+
+Returns +false+ if the two strings' encodings are not compatible:
+
+ s0 = "äöü" # => "äöü"
+ s1 = s0.encode(Encoding::ISO_8859_1) # => "\xE4\xF6\xFC"
+ s0.encoding # => #<Encoding:UTF-8>
+ s1.encoding # => #<Encoding:ISO-8859-1>
+ s0.eql?(s1) # => false
+
+See {Encodings}[rdoc-ref:encodings.rdoc].
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/force_encoding.rdoc b/doc/string/force_encoding.rdoc
index fd9615caaa..a509e67f80 100644
--- a/doc/string/force_encoding.rdoc
+++ b/doc/string/force_encoding.rdoc
@@ -1,5 +1,6 @@
-Changes the encoding of +self+ to +encoding+,
+Changes the encoding of +self+ to the given +encoding+,
which may be a string encoding name or an Encoding object;
+does not change the underlying bytes;
returns self:
s = 'łał'
@@ -7,14 +8,14 @@ returns self:
s.encoding # => #<Encoding:UTF-8>
s.force_encoding('ascii') # => "\xC5\x82a\xC5\x82"
s.encoding # => #<Encoding:US-ASCII>
-
-Does not change the underlying bytes:
-
+ s.valid_encoding? # => true
s.bytes # => [197, 130, 97, 197, 130]
Makes the change even if the given +encoding+ is invalid
for +self+ (as is the change above):
- s.valid_encoding? # => false
- s.force_encoding(Encoding::UTF_8) # => "łał"
- s.valid_encoding? # => true
+ s.valid_encoding? # => false
+
+See {Encodings}[rdoc-ref:encodings.rdoc].
+
+Related: see {Modifying}[rdoc-ref:String@Modifying].
diff --git a/doc/string/getbyte.rdoc b/doc/string/getbyte.rdoc
new file mode 100644
index 0000000000..974e21c473
--- /dev/null
+++ b/doc/string/getbyte.rdoc
@@ -0,0 +1,23 @@
+Returns the byte at zero-based +index+ as an integer:
+
+ s = 'foo'
+ s.getbyte(0) # => 102
+ s.getbyte(1) # => 111
+ s.getbyte(2) # => 111
+
+Counts backward from the end if +index+ is negative:
+
+ s.getbyte(-3) # => 102
+
+Returns +nil+ if +index+ is out of range:
+
+ s.getbyte(3) # => nil
+ s.getbyte(-4) # => nil
+
+More examples:
+
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+ s.getbyte(2) # => 147
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/grapheme_clusters.rdoc b/doc/string/grapheme_clusters.rdoc
index 8c7f5a7259..ee8b45700e 100644
--- a/doc/string/grapheme_clusters.rdoc
+++ b/doc/string/grapheme_clusters.rdoc
@@ -1,6 +1,19 @@
Returns an array of the grapheme clusters in +self+
(see {Unicode Grapheme Cluster Boundaries}[https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries]):
- s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈"
+ s = "ä-pqr-b̈-xyz-c̈"
+ s.size # => 16
+ s.bytesize # => 19
+ s.grapheme_clusters.size # => 13
s.grapheme_clusters
# => ["ä", "-", "p", "q", "r", "-", "b̈", "-", "x", "y", "z", "-", "c̈"]
+
+Details:
+
+ s = "ä"
+ s.grapheme_clusters # => ["ä"] # One grapheme cluster.
+ s.bytes # => [97, 204, 136] # Three bytes.
+ s.chars # => ["a", "̈"] # Two characters.
+ s.chars.map {|char| char.ord } # => [97, 776] # Their values.
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/hash.rdoc b/doc/string/hash.rdoc
new file mode 100644
index 0000000000..fe94770ed9
--- /dev/null
+++ b/doc/string/hash.rdoc
@@ -0,0 +1,19 @@
+Returns the integer hash value for +self+.
+
+Two \String objects that have identical content and compatible encodings
+also have the same hash value;
+see Object#hash and {Encodings}[rdoc-ref:encodings.rdoc]:
+
+ s = 'foo'
+ h = s.hash # => -569050784
+ h == 'foo'.hash # => true
+ h == 'food'.hash # => false
+ h == 'FOO'.hash # => false
+
+ s0 = "äöü"
+ s1 = s0.encode(Encoding::ISO_8859_1)
+ s0.encoding # => #<Encoding:UTF-8>
+ s1.encoding # => #<Encoding:ISO-8859-1>
+ s0.hash == s1.hash # => false
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/index.rdoc b/doc/string/index.rdoc
index ce09a37bdf..c3cff24dac 100644
--- a/doc/string/index.rdoc
+++ b/doc/string/index.rdoc
@@ -1,31 +1,31 @@
-Returns the integer index of the first match for the given argument,
-or +nil+ if none found;
-the search of +self+ is forward, and begins at position +offset+ (in characters).
+Returns the integer position of the first substring that matches the given argument +pattern+,
+or +nil+ if none found.
-With string argument +substring+,
+When +pattern+ is a string,
returns the index of the first matching substring in +self+:
'foo'.index('f') # => 0
'foo'.index('o') # => 1
'foo'.index('oo') # => 1
'foo'.index('ooo') # => nil
- 'теÑÑ‚'.index('Ñ') # => 2
- 'ã“ã‚“ã«ã¡ã¯'.index('ã¡') # => 3
+ 'ã“ã‚“ã«ã¡ã¯'.index('ã¡') # => 3
-With Regexp argument +regexp+, returns the index of the first match in +self+:
+When +pattern+ is a Regexp, returns the index of the first match in +self+:
'foo'.index(/o./) # => 1
'foo'.index(/.o/) # => 0
-With positive integer +offset+, begins the search at position +offset+:
+When +offset+ is non-negative, begins the search at position +offset+;
+the returned index is relative to the beginning of +self+:
- 'foo'.index('o', 1) # => 1
- 'foo'.index('o', 2) # => 2
- 'foo'.index('o', 3) # => nil
- 'теÑÑ‚'.index('Ñ', 1) # => 2
- 'ã“ã‚“ã«ã¡ã¯'.index('ã¡', 2) # => 3
+ 'bar'.index('r', 0) # => 2
+ 'bar'.index('r', 1) # => 2
+ 'bar'.index('r', 2) # => 2
+ 'bar'.index('r', 3) # => nil
+ 'bar'.index(/[r-z]/, 0) # => 2
+ 'ã“ã‚“ã«ã¡ã¯'.index('ã¡', 2) # => 3
-With negative integer +offset+, selects the search position by counting backward
+With negative integer argument +offset+, selects the search position by counting backward
from the end of +self+:
'foo'.index('o', -1) # => 2
@@ -35,4 +35,4 @@ from the end of +self+:
'foo'.index(/o./, -2) # => 1
'foo'.index(/.o/, -2) # => 1
-Related: String#rindex.
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/insert.rdoc b/doc/string/insert.rdoc
new file mode 100644
index 0000000000..73205f2069
--- /dev/null
+++ b/doc/string/insert.rdoc
@@ -0,0 +1,15 @@
+Inserts the given +other_string+ into +self+; returns +self+.
+
+If the given +index+ is non-negative, inserts +other_string+ at offset +index+:
+
+ 'foo'.insert(0, 'bar') # => "barfoo"
+ 'foo'.insert(1, 'bar') # => "fbaroo"
+ 'foo'.insert(3, 'bar') # => "foobar"
+ 'ã“ã‚“ã«ã¡ã¯'.insert(2, 'bar') # => "ã“ã‚“barã«ã¡ã¯"
+
+If the +index+ is negative, counts backward from the end of +self+
+and inserts +other_string+ _after_ the offset:
+
+ 'foo'.insert(-2, 'bar') # => "fobaro"
+
+Related: see {Modifying}[rdoc-ref:String@Modifying].
diff --git a/doc/string/inspect.rdoc b/doc/string/inspect.rdoc
new file mode 100644
index 0000000000..398a5a74c5
--- /dev/null
+++ b/doc/string/inspect.rdoc
@@ -0,0 +1,38 @@
+Returns a printable version of +self+, enclosed in double-quotes.
+
+Most printable characters are rendered simply as themselves:
+
+ 'abc'.inspect # => "\"abc\""
+ '012'.inspect # => "\"012\""
+ ''.inspect # => "\"\""
+ "\u000012".inspect # => "\"\\u000012\""
+ 'ã“ã‚“ã«ã¡ã¯'.inspect # => "\"ã“ã‚“ã«ã¡ã¯\""
+
+But printable characters double-quote (<tt>'"'</tt>) and backslash and (<tt>'\\'</tt>) are escaped:
+
+ '"'.inspect # => "\"\\\"\""
+ '\\'.inspect # => "\"\\\\\""
+
+Unprintable characters are the {ASCII characters}[https://en.wikipedia.org/wiki/ASCII]
+whose values are in range <tt>0..31</tt>,
+along with the character whose value is +127+.
+
+Most of these characters are rendered thus:
+
+ 0.chr.inspect # => "\"\\x00\""
+ 1.chr.inspect # => "\"\\x01\""
+ 2.chr.inspect # => "\"\\x02\""
+ # ...
+
+A few, however, have special renderings:
+
+ 7.chr.inspect # => "\"\\a\"" # BEL
+ 8.chr.inspect # => "\"\\b\"" # BS
+ 9.chr.inspect # => "\"\\t\"" # TAB
+ 10.chr.inspect # => "\"\\n\"" # LF
+ 11.chr.inspect # => "\"\\v\"" # VT
+ 12.chr.inspect # => "\"\\f\"" # FF
+ 13.chr.inspect # => "\"\\r\"" # CR
+ 27.chr.inspect # => "\"\\e\"" # ESC
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/intern.rdoc b/doc/string/intern.rdoc
new file mode 100644
index 0000000000..c82302b906
--- /dev/null
+++ b/doc/string/intern.rdoc
@@ -0,0 +1,8 @@
+Returns the Symbol object derived from +self+,
+creating it if it did not already exist:
+
+ 'foo'.intern # => :foo
+ 'ã“ã‚“ã«ã¡ã¯'.intern # => :ã“ã‚“ã«ã¡ã¯
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
+
diff --git a/doc/string/length.rdoc b/doc/string/length.rdoc
index 544bca269f..eb68edb10c 100644
--- a/doc/string/length.rdoc
+++ b/doc/string/length.rdoc
@@ -1,12 +1,11 @@
Returns the count of characters (not bytes) in +self+:
'foo'.length # => 3
- 'теÑÑ‚'.length # => 4
- 'ã“ã‚“ã«ã¡ã¯'.length # => 5
+ 'ã“ã‚“ã«ã¡ã¯'.length # => 5
Contrast with String#bytesize:
'foo'.bytesize # => 3
- 'теÑÑ‚'.bytesize # => 8
- 'ã“ã‚“ã«ã¡ã¯'.bytesize # => 15
+ 'ã“ã‚“ã«ã¡ã¯'.bytesize # => 15
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/ljust.rdoc b/doc/string/ljust.rdoc
index 8e23c1fc8f..a8ca62ee76 100644
--- a/doc/string/ljust.rdoc
+++ b/doc/string/ljust.rdoc
@@ -1,16 +1,13 @@
-Returns a left-justified copy of +self+.
-
-If integer argument +size+ is greater than the size (in characters) of +self+,
-returns a new string of length +size+ that is a copy of +self+,
-left justified and padded on the right with +pad_string+:
+Returns a copy of +self+, left-justified and, if necessary, right-padded with the +pad_string+:
'hello'.ljust(10) # => "hello "
' hello'.ljust(10) # => " hello "
'hello'.ljust(10, 'ab') # => "helloababa"
- 'теÑÑ‚'.ljust(10) # => "теÑÑ‚ "
- 'ã“ã‚“ã«ã¡ã¯'.ljust(10) # => "ã“ã‚“ã«ã¡ã¯ "
+ 'ã“ã‚“ã«ã¡ã¯'.ljust(10) # => "ã“ã‚“ã«ã¡ã¯ "
-If +size+ is not greater than the size of +self+, returns a copy of +self+:
+If <tt>width <= self.length</tt>, returns a copy of +self+:
'hello'.ljust(5) # => "hello"
- 'hello'.ljust(1) # => "hello"
+ 'hello'.ljust(1) # => "hello" # Does not truncate to width.
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/new.rdoc b/doc/string/new.rdoc
index d955e61c87..e2752d6e1f 100644
--- a/doc/string/new.rdoc
+++ b/doc/string/new.rdoc
@@ -1,34 +1,38 @@
-Returns a new \String that is a copy of +string+.
+Returns a new \String object containing the given +string+.
-With no arguments, returns the empty string with the Encoding <tt>ASCII-8BIT</tt>:
+The +options+ are optional keyword options (see below).
- s = String.new
- s # => ""
- s.encoding # => #<Encoding:ASCII-8BIT>
+With no argument given and keyword +encoding+ also not given,
+returns an empty string with the Encoding <tt>ASCII-8BIT</tt>:
-With optional argument +string+ and no keyword arguments,
-returns a copy of +string+ with the same encoding:
+ s = String.new # => ""
+ s.encoding # => #<Encoding:ASCII-8BIT>
- String.new('foo') # => "foo"
- String.new('теÑÑ‚') # => "теÑÑ‚"
- String.new('ã“ã‚“ã«ã¡ã¯') # => "ã“ã‚“ã«ã¡ã¯"
+With argument +string+ given and keyword option +encoding+ not given,
+returns a new string with the same encoding as +string+:
+
+ s0 = 'foo'.encode(Encoding::UTF_16)
+ s1 = String.new(s0)
+ s1.encoding # => #<Encoding:UTF-16 (dummy)>
(Unlike \String.new,
a {string literal}[rdoc-ref:syntax/literals.rdoc@String+Literals] like <tt>''</tt> or a
{here document literal}[rdoc-ref:syntax/literals.rdoc@Here+Document+Literals]
always has {script encoding}[rdoc-ref:encodings.rdoc@Script+Encoding].)
-With optional keyword argument +encoding+, returns a copy of +string+
-with the specified encoding;
+With keyword option +encoding+ given,
+returns a string with the specified encoding;
the +encoding+ may be an Encoding object, an encoding name,
or an encoding name alias:
+ String.new(encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
+ String.new('', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
String.new('foo', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
String.new('foo', encoding: 'US-ASCII').encoding # => #<Encoding:US-ASCII>
String.new('foo', encoding: 'ASCII').encoding # => #<Encoding:US-ASCII>
The given encoding need not be valid for the string's content,
-and that validity is not checked:
+and its validity is not checked:
s = String.new('ã“ã‚“ã«ã¡ã¯', encoding: 'ascii')
s.valid_encoding? # => false
@@ -37,15 +41,11 @@ But the given +encoding+ itself is checked:
String.new('foo', encoding: 'bar') # Raises ArgumentError.
-With optional keyword argument +capacity+, returns a copy of +string+
-(or an empty string, if +string+ is not given);
-the given +capacity+ is advisory only,
+With keyword option +capacity+ given,
+the given value is advisory only,
and may or may not set the size of the internal buffer,
which may in turn affect performance:
- String.new(capacity: 1)
- String.new('foo', capacity: 4096)
-
-The +string+, +encoding+, and +capacity+ arguments may all be used together:
-
- String.new('hello', encoding: 'UTF-8', capacity: 25)
+ String.new('foo', capacity: 1) # Buffer size is at least 4 (includes terminal null byte).
+ String.new('foo', capacity: 4096) # Buffer size is at least 4;
+ # may be equal to, greater than, or less than 4096.
diff --git a/doc/string/ord.rdoc b/doc/string/ord.rdoc
index d586363d44..8c460d3ba4 100644
--- a/doc/string/ord.rdoc
+++ b/doc/string/ord.rdoc
@@ -2,5 +2,6 @@ Returns the integer ordinal of the first character of +self+:
'h'.ord # => 104
'hello'.ord # => 104
- 'теÑÑ‚'.ord # => 1090
'ã“ã‚“ã«ã¡ã¯'.ord # => 12371
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/partition.rdoc b/doc/string/partition.rdoc
index ebe575e8eb..b2e620a9fc 100644
--- a/doc/string/partition.rdoc
+++ b/doc/string/partition.rdoc
@@ -1,24 +1,43 @@
Returns a 3-element array of substrings of +self+.
-Matches a pattern against +self+, scanning from the beginning.
-The pattern is:
+If +pattern+ is matched, returns the array:
-- +string_or_regexp+ itself, if it is a Regexp.
-- <tt>Regexp.quote(string_or_regexp)</tt>, if +string_or_regexp+ is a string.
+ [pre_match, first_match, post_match]
-If the pattern is matched, returns pre-match, first-match, post-match:
+where:
- 'hello'.partition('l') # => ["he", "l", "lo"]
- 'hello'.partition('ll') # => ["he", "ll", "o"]
- 'hello'.partition('h') # => ["", "h", "ello"]
- 'hello'.partition('o') # => ["hell", "o", ""]
- 'hello'.partition(/l+/) #=> ["he", "ll", "o"]
- 'hello'.partition('') # => ["", "", "hello"]
- 'теÑÑ‚'.partition('Ñ‚') # => ["", "Ñ‚", "еÑÑ‚"]
- 'ã“ã‚“ã«ã¡ã¯'.partition('ã«') # => ["ã“ã‚“", "ã«", "ã¡ã¯"]
+- +first_match+ is the first-found matching substring.
+- +pre_match+ and +post_match+ are the preceding and following substrings.
-If the pattern is not matched, returns a copy of +self+ and two empty strings:
+If +pattern+ is not matched, returns the array:
- 'hello'.partition('x') # => ["hello", "", ""]
+ [self.dup, "", ""]
-Related: String#rpartition, String#split.
+Note that in the examples below, a returned string <tt>'hello'</tt>
+is a copy of +self+, not +self+.
+
+If +pattern+ is a Regexp, performs the equivalent of <tt>self.match(pattern)</tt>
+(also setting {matched-data variables}[rdoc-ref:language/globals.md@Matched+Data]):
+
+ 'hello'.partition(/h/) # => ["", "h", "ello"]
+ 'hello'.partition(/l/) # => ["he", "l", "lo"]
+ 'hello'.partition(/l+/) # => ["he", "ll", "o"]
+ 'hello'.partition(/o/) # => ["hell", "o", ""]
+ 'hello'.partition(/^/) # => ["", "", "hello"]
+ 'hello'.partition(//) # => ["", "", "hello"]
+ 'hello'.partition(/$/) # => ["hello", "", ""]
+ 'hello'.partition(/x/) # => ["hello", "", ""]
+
+If +pattern+ is not a Regexp, converts it to a string (if it is not already one),
+then performs the equivalent of <tt>self.index(pattern)</tt>
+(and does _not_ set {matched-data global variables}[rdoc-ref:language/globals.md@Matched+Data]):
+
+ 'hello'.partition('h') # => ["", "h", "ello"]
+ 'hello'.partition('l') # => ["he", "l", "lo"]
+ 'hello'.partition('ll') # => ["he", "ll", "o"]
+ 'hello'.partition('o') # => ["hell", "o", ""]
+ 'hello'.partition('') # => ["", "", "hello"]
+ 'hello'.partition('x') # => ["hello", "", ""]
+ 'ã“ã‚“ã«ã¡ã¯'.partition('ã«') # => ["ã“ã‚“", "ã«", "ã¡ã¯"]
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/rindex.rdoc b/doc/string/rindex.rdoc
new file mode 100644
index 0000000000..2b81c3716d
--- /dev/null
+++ b/doc/string/rindex.rdoc
@@ -0,0 +1,51 @@
+Returns the integer position of the _last_ substring that matches the given argument +pattern+,
+or +nil+ if none found.
+
+When +pattern+ is a string, returns the index of the last matching substring in self:
+
+ 'foo'.rindex('f') # => 0
+ 'foo'.rindex('o') # => 2
+ 'foo'.rindex('oo' # => 1
+ 'foo'.rindex('ooo') # => nil
+ 'ã“ã‚“ã«ã¡ã¯'.rindex('ã¡') # => 3
+
+When +pattern+ is a Regexp, returns the index of the last match in self:
+
+ 'foo'.rindex(/f/) # => 0
+ 'foo'.rindex(/o/) # => 2
+ 'foo'.rindex(/oo/) # => 1
+ 'foo'.rindex(/ooo/) # => nil
+
+When +offset+ is non-negative, it specifies the maximum starting position in the
+string to end the search:
+
+ 'foo'.rindex('o', 0) # => nil
+ 'foo'.rindex('o', 1) # => 1
+ 'foo'.rindex('o', 2) # => 2
+ 'foo'.rindex('o', 3) # => 2
+
+With negative integer argument +offset+,
+selects the search position by counting backward from the end of +self+:
+
+ 'foo'.rindex('o', -1) # => 2
+ 'foo'.rindex('o', -2) # => 1
+ 'foo'.rindex('o', -3) # => nil
+ 'foo'.rindex('o', -4) # => nil
+
+The last match means starting at the possible last position, not
+the last of longest matches:
+
+ 'foo'.rindex(/o+/) # => 2
+ $~ # => #<MatchData "o">
+
+To get the last longest match, combine with negative lookbehind:
+
+ 'foo'.rindex(/(?<!o)o+/) # => 1
+ $~ # => #<MatchData "oo">
+
+Or String#index with negative lookforward.
+
+ 'foo'.index(/o+(?!.*o)/) # => 1
+ $~ # => #<MatchData "oo">
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/rjust.rdoc b/doc/string/rjust.rdoc
index 24e7bf3159..acd3f198d4 100644
--- a/doc/string/rjust.rdoc
+++ b/doc/string/rjust.rdoc
@@ -1,16 +1,17 @@
Returns a right-justified copy of +self+.
-If integer argument +size+ is greater than the size (in characters) of +self+,
-returns a new string of length +size+ that is a copy of +self+,
+If integer argument +width+ is greater than the size (in characters) of +self+,
+returns a new string of length +width+ that is a copy of +self+,
right justified and padded on the left with +pad_string+:
'hello'.rjust(10) # => " hello"
'hello '.rjust(10) # => " hello "
'hello'.rjust(10, 'ab') # => "ababahello"
- 'теÑÑ‚'.rjust(10) # => " теÑÑ‚"
'ã“ã‚“ã«ã¡ã¯'.rjust(10) # => " ã“ã‚“ã«ã¡ã¯"
-If +size+ is not greater than the size of +self+, returns a copy of +self+:
+If <tt>width <= self.size</tt>, returns a copy of +self+:
'hello'.rjust(5, 'ab') # => "hello"
'hello'.rjust(1, 'ab') # => "hello"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/rpartition.rdoc b/doc/string/rpartition.rdoc
index d24106fb9f..add95b1f40 100644
--- a/doc/string/rpartition.rdoc
+++ b/doc/string/rpartition.rdoc
@@ -1,24 +1,47 @@
Returns a 3-element array of substrings of +self+.
-Matches a pattern against +self+, scanning backwards from the end.
-The pattern is:
+Searches +self+ for a match of +pattern+, seeking the _last_ match.
-- +string_or_regexp+ itself, if it is a Regexp.
-- <tt>Regexp.quote(string_or_regexp)</tt>, if +string_or_regexp+ is a string.
+If +pattern+ is not matched, returns the array:
-If the pattern is matched, returns pre-match, last-match, post-match:
+ ["", "", self.dup]
- 'hello'.rpartition('l') # => ["hel", "l", "o"]
- 'hello'.rpartition('ll') # => ["he", "ll", "o"]
- 'hello'.rpartition('h') # => ["", "h", "ello"]
- 'hello'.rpartition('o') # => ["hell", "o", ""]
- 'hello'.rpartition(/l+/) # => ["hel", "l", "o"]
- 'hello'.rpartition('') # => ["hello", "", ""]
- 'теÑÑ‚'.rpartition('Ñ‚') # => ["теÑ", "Ñ‚", ""]
- 'ã“ã‚“ã«ã¡ã¯'.rpartition('ã«') # => ["ã“ã‚“", "ã«", "ã¡ã¯"]
+If +pattern+ is matched, returns the array:
-If the pattern is not matched, returns two empty strings and a copy of +self+:
+ [pre_match, last_match, post_match]
- 'hello'.rpartition('x') # => ["", "", "hello"]
+where:
-Related: String#partition, String#split.
+- +last_match+ is the last-found matching substring.
+- +pre_match+ and +post_match+ are the preceding and following substrings.
+
+The pattern used is:
+
+- +pattern+ itself, if it is a Regexp.
+- <tt>Regexp.quote(pattern)</tt>, if +pattern+ is a string.
+
+Note that in the examples below, a returned string <tt>'hello'</tt> is a copy of +self+, not +self+.
+
+If +pattern+ is a Regexp, searches for the last matching substring
+(also setting {matched-data global variables}[rdoc-ref:language/globals.md@Matched+Data]):
+
+ 'hello'.rpartition(/l/) # => ["hel", "l", "o"]
+ 'hello'.rpartition(/ll/) # => ["he", "ll", "o"]
+ 'hello'.rpartition(/h/) # => ["", "h", "ello"]
+ 'hello'.rpartition(/o/) # => ["hell", "o", ""]
+ 'hello'.rpartition(//) # => ["hello", "", ""]
+ 'hello'.rpartition(/x/) # => ["", "", "hello"]
+ 'ã“ã‚“ã«ã¡ã¯'.rpartition(/ã«/) # => ["ã“ã‚“", "ã«", "ã¡ã¯"]
+
+If +pattern+ is not a Regexp, converts it to a string (if it is not already one),
+then searches for the last matching substring
+(and does _not_ set {matched-data global variables}[rdoc-ref:language/globals.md@Matched+Data]):
+
+ 'hello'.rpartition('l') # => ["hel", "l", "o"]
+ 'hello'.rpartition('ll') # => ["he", "ll", "o"]
+ 'hello'.rpartition('h') # => ["", "h", "ello"]
+ 'hello'.rpartition('o') # => ["hell", "o", ""]
+ 'hello'.rpartition('') # => ["hello", "", ""]
+ 'ã“ã‚“ã«ã¡ã¯'.rpartition('ã«') # => ["ã“ã‚“", "ã«", "ã¡ã¯"]
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/scan.rdoc b/doc/string/scan.rdoc
new file mode 100644
index 0000000000..d39b5b6dfa
--- /dev/null
+++ b/doc/string/scan.rdoc
@@ -0,0 +1,35 @@
+Matches a pattern against +self+:
+
+- If +pattern+ is a Regexp, the pattern used is +pattern+ itself.
+- If +pattern+ is a string, the pattern used is <tt>Regexp.quote(pattern)</tt>.
+
+Generates a collection of matching results
+and updates {regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+- If the pattern contains no groups, each result is a matched substring.
+- If the pattern contains groups, each result is an array
+ containing a matched substring for each group.
+
+With no block given, returns an array of the results:
+
+ 'cruel world'.scan(/\w+/) # => ["cruel", "world"]
+ 'cruel world'.scan(/.../) # => ["cru", "el ", "wor"]
+ 'cruel world'.scan(/(...)/) # => [["cru"], ["el "], ["wor"]]
+ 'cruel world'.scan(/(..)(..)/) # => [["cr", "ue"], ["l ", "wo"]]
+ 'ã“ã‚“ã«ã¡ã¯'.scan(/../) # => ["ã“ã‚“", "ã«ã¡"]
+ 'abracadabra'.scan('ab') # => ["ab", "ab"]
+ 'abracadabra'.scan('nosuch') # => []
+
+With a block given, calls the block with each result; returns +self+:
+
+ 'cruel world'.scan(/\w+/) {|w| p w }
+ # => "cruel"
+ # => "world"
+ 'cruel world'.scan(/(.)(.)/) {|x, y| p [x, y] }
+ # => ["c", "r"]
+ # => ["u", "e"]
+ # => ["l", " "]
+ # => ["w", "o"]
+ # => ["r", "l"]
+
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/scrub.rdoc b/doc/string/scrub.rdoc
index 1a5b1c79d0..314b28c465 100644
--- a/doc/string/scrub.rdoc
+++ b/doc/string/scrub.rdoc
@@ -1,25 +1,22 @@
Returns a copy of +self+ with each invalid byte sequence replaced
by the given +replacement_string+.
-With no block given and no argument, replaces each invalid sequence
-with the default replacement string
-(<tt>"�"</tt> for a Unicode encoding, <tt>'?'</tt> otherwise):
+With no block given, replaces each invalid sequence
+with the given +default_replacement_string+
+(by default, <tt>"�"</tt> for a Unicode encoding, <tt>'?'</tt> otherwise):
- s = "foo\x81\x81bar"
- s.scrub # => "foo��bar"
+ "foo\x81\x81bar".scrub # => "foo��bar"
+ "foo\x81\x81bar".force_encoding('US-ASCII').scrub # => "foo??bar"
+ "foo\x81\x81bar".scrub('xyzzy') # => "fooxyzzyxyzzybar"
-With no block given and argument +replacement_string+ given,
-replaces each invalid sequence with that string:
+With a block given, calls the block with each invalid sequence,
+and replaces that sequence with the return value of the block:
- "foo\x81\x81bar".scrub('xyzzy') # => "fooxyzzyxyzzybar"
+ "foo\x81\x81bar".scrub {|sequence| p sequence; 'XYZZY' } # => "fooXYZZYXYZZYbar"
-With a block given, replaces each invalid sequence with the value
-of the block:
-
- "foo\x81\x81bar".scrub {|bytes| p bytes; 'XYZZY' }
- # => "fooXYZZYXYZZYbar"
-
-Output:
+Output :
"\x81"
"\x81"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/split.rdoc b/doc/string/split.rdoc
index 2b5e14ddb6..8679149003 100644
--- a/doc/string/split.rdoc
+++ b/doc/string/split.rdoc
@@ -1,86 +1,101 @@
-Returns an array of substrings of +self+
-that are the result of splitting +self+
+Creates an array of substrings by splitting +self+
at each occurrence of the given field separator +field_sep+.
-When +field_sep+ is <tt>$;</tt>:
+With no arguments given,
+splits using the field separator <tt>$;</tt>,
+whose default value is +nil+.
-- If <tt>$;</tt> is +nil+ (its default value),
- the split occurs just as if +field_sep+ were given as a space character
- (see below).
+With no block given, returns the array of substrings:
-- If <tt>$;</tt> is a string,
- the split ocurs just as if +field_sep+ were given as that string
- (see below).
+ 'abracadabra'.split('a') # => ["", "br", "c", "d", "br"]
-When +field_sep+ is <tt>' '</tt> and +limit+ is +nil+,
-the split occurs at each sequence of whitespace:
+When +field_sep+ is +nil+ or <tt>' '</tt> (a single space),
+splits at each sequence of whitespace:
- 'abc def ghi'.split(' ') => ["abc", "def", "ghi"]
- "abc \n\tdef\t\n ghi".split(' ') # => ["abc", "def", "ghi"]
- 'abc def ghi'.split(' ') => ["abc", "def", "ghi"]
- ''.split(' ') => []
+ 'foo bar baz'.split(nil) # => ["foo", "bar", "baz"]
+ 'foo bar baz'.split(' ') # => ["foo", "bar", "baz"]
+ "foo \n\tbar\t\n baz".split(' ') # => ["foo", "bar", "baz"]
+ 'foo bar baz'.split(' ') # => ["foo", "bar", "baz"]
+ ''.split(' ') # => []
-When +field_sep+ is a string different from <tt>' '</tt>
-and +limit+ is +nil+,
-the split occurs at each occurrence of +field_sep+;
-trailing empty substrings are not returned:
+When +field_sep+ is an empty string,
+splits at every character:
- 'abracadabra'.split('ab') => ["", "racad", "ra"]
- 'aaabcdaaa'.split('a') => ["", "", "", "bcd"]
- ''.split('a') => []
- '3.14159'.split('1') => ["3.", "4", "59"]
- '!@#$%^$&*($)_+'.split('$') # => ["!@#", "%^", "&*(", ")_+"]
- 'теÑÑ‚'.split('Ñ‚') => ["", "еÑ"]
- 'ã“ã‚“ã«ã¡ã¯'.split('ã«') => ["ã“ã‚“", "ã¡ã¯"]
+ 'abracadabra'.split('') # => ["a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a"]
+ ''.split('') # => []
+ 'ã“ã‚“ã«ã¡ã¯'.split('') # => ["ã“", "ã‚“", "ã«", "ã¡", "ã¯"]
-When +field_sep+ is a Regexp and +limit+ is +nil+,
-the split occurs at each occurrence of a match;
-trailing empty substrings are not returned:
+When +field_sep+ is a non-empty string and different from <tt>' '</tt> (a single space),
+uses that string as the separator:
+
+ 'abracadabra'.split('a') # => ["", "br", "c", "d", "br"]
+ 'abracadabra'.split('ab') # => ["", "racad", "ra"]
+ ''.split('a') # => []
+ 'ã“ã‚“ã«ã¡ã¯'.split('ã«') # => ["ã“ã‚“", "ã¡ã¯"]
+
+When +field_sep+ is a Regexp,
+splits at each occurrence of a matching substring:
'abracadabra'.split(/ab/) # => ["", "racad", "ra"]
- 'aaabcdaaa'.split(/a/) => ["", "", "", "bcd"]
- 'aaabcdaaa'.split(//) => ["a", "a", "a", "b", "c", "d", "a", "a", "a"]
'1 + 1 == 2'.split(/\W+/) # => ["1", "1", "2"]
+ 'abracadabra'.split(//) # => ["a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a"]
-If the \Regexp contains groups, their matches are also included
+If the \Regexp contains groups, their matches are included
in the returned array:
'1:2:3'.split(/(:)()()/, 2) # => ["1", ":", "", "", "2:3"]
-As seen above, if +limit+ is +nil+,
-trailing empty substrings are not returned;
-the same is true if +limit+ is zero:
+Argument +limit+ sets a limit on the size of the returned array;
+it also determines whether trailing empty strings are included in the returned array.
+
+When +limit+ is zero,
+there is no limit on the size of the array,
+but trailing empty strings are omitted:
+
+ 'abracadabra'.split('', 0) # => ["a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a"]
+ 'abracadabra'.split('a', 0) # => ["", "br", "c", "d", "br"] # Empty string after last 'a' omitted.
+
+When +limit+ is a positive integer,
+there is a limit on the size of the array (no more than <tt>n - 1</tt> splits occur),
+and trailing empty strings are included:
+
+ 'abracadabra'.split('', 3) # => ["a", "b", "racadabra"]
+ 'abracadabra'.split('a', 3) # => ["", "br", "cadabra"]
+ 'abracadabra'.split('', 30) # => ["a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a", ""]
+ 'abracadabra'.split('a', 30) # => ["", "br", "c", "d", "br", ""]
+ 'abracadabra'.split('', 1) # => ["abracadabra"]
+ 'abracadabra'.split('a', 1) # => ["abracadabra"]
+
+When +limit+ is negative,
+there is no limit on the size of the array,
+and trailing empty strings are omitted:
+
+ 'abracadabra'.split('', -1) # => ["a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a", ""]
+ 'abracadabra'.split('a', -1) # => ["", "br", "c", "d", "br", ""]
- 'aaabcdaaa'.split('a') => ["", "", "", "bcd"]
- 'aaabcdaaa'.split('a', 0) # => ["", "", "", "bcd"]
+If a block is given, it is called with each substring and returns +self+:
-If +limit+ is positive integer +n+, no more than <tt>n - 1-</tt>
-splits occur, so that at most +n+ substrings are returned,
-and trailing empty substrings are included:
+ 'foo bar baz'.split(' ') {|substring| p substring }
- 'aaabcdaaa'.split('a', 1) # => ["aaabcdaaa"]
- 'aaabcdaaa'.split('a', 2) # => ["", "aabcdaaa"]
- 'aaabcdaaa'.split('a', 5) # => ["", "", "", "bcd", "aa"]
- 'aaabcdaaa'.split('a', 7) # => ["", "", "", "bcd", "", "", ""]
- 'aaabcdaaa'.split('a', 8) # => ["", "", "", "bcd", "", "", ""]
+Output :
-Note that if +field_sep+ is a \Regexp containing groups,
-their matches are in the returned array, but do not count toward the limit.
+ "foo"
+ "bar"
+ "baz"
-If +limit+ is negative, it behaves the same as if +limit+ was +nil+,
-meaning that there is no limit,
-and trailing empty substrings are included:
+Note that the above example is functionally equivalent to:
- 'aaabcdaaa'.split('a', -1) # => ["", "", "", "bcd", "", "", ""]
+ 'foo bar baz'.split(' ').each {|substring| p substring }
-If a block is given, it is called with each substring:
+Output :
- 'abc def ghi'.split(' ') {|substring| p substring }
+ "foo"
+ "bar"
+ "baz"
-Output:
+But the latter:
- "abc"
- "def"
- "ghi"
+- Has poorer performance because it creates an intermediate array.
+- Returns an array (instead of +self+).
-Related: String#partition, String#rpartition.
+Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non-String].
diff --git a/doc/string/squeeze.rdoc b/doc/string/squeeze.rdoc
new file mode 100644
index 0000000000..1a38c08b32
--- /dev/null
+++ b/doc/string/squeeze.rdoc
@@ -0,0 +1,33 @@
+Returns a copy of +self+ with each tuple (doubling, tripling, etc.) of specified characters
+"squeezed" down to a single character.
+
+The tuples to be squeezed are specified by arguments +selectors+,
+each of which is a string;
+see {Character Selectors}[rdoc-ref:character_selectors.rdoc@Character+Selectors].
+
+A single argument may be a single character:
+
+ 'Noooooo!'.squeeze('o') # => "No!"
+ 'foo bar baz'.squeeze(' ') # => "foo bar baz"
+ 'Mississippi'.squeeze('s') # => "Misisippi"
+ 'Mississippi'.squeeze('p') # => "Mississipi"
+ 'Mississippi'.squeeze('x') # => "Mississippi" # Unused selector character is ignored.
+ 'беÑÑонница'.squeeze('Ñ') # => "беÑонница"
+ 'беÑÑонница'.squeeze('н') # => "беÑÑоница"
+
+A single argument may be a string of characters:
+
+ 'Mississippi'.squeeze('sp') # => "Misisipi"
+ 'Mississippi'.squeeze('ps') # => "Misisipi" # Order doesn't matter.
+ 'Mississippi'.squeeze('nonsense') # => "Misisippi" # Unused selector characters are ignored.
+
+A single argument may be a range of characters:
+
+ 'Mississippi'.squeeze('a-p') # => "Mississipi"
+ 'Mississippi'.squeeze('q-z') # => "Misisippi"
+ 'Mississippi'.squeeze('a-z') # => "Misisipi"
+
+Multiple arguments are allowed;
+see {Multiple Character Selectors}[rdoc-ref:character_selectors.rdoc@Multiple+Character+Selectors].
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/start_with_p.rdoc b/doc/string/start_with_p.rdoc
index 5d1f9f9543..f78edc7fa3 100644
--- a/doc/string/start_with_p.rdoc
+++ b/doc/string/start_with_p.rdoc
@@ -1,10 +1,9 @@
-Returns whether +self+ starts with any of the given +string_or_regexp+.
+Returns whether +self+ starts with any of the given +patterns+.
-Matches patterns against the beginning of +self+.
-For each given +string_or_regexp+, the pattern is:
+For each argument, the pattern used is:
-- +string_or_regexp+ itself, if it is a Regexp.
-- <tt>Regexp.quote(string_or_regexp)</tt>, if +string_or_regexp+ is a string.
+- The pattern itself, if it is a Regexp.
+- <tt>Regexp.quote(pattern)</tt>, if it is a string.
Returns +true+ if any pattern matches the beginning, +false+ otherwise:
@@ -12,7 +11,6 @@ Returns +true+ if any pattern matches the beginning, +false+ otherwise:
'hello'.start_with?(/H/i) # => true
'hello'.start_with?('heaven', 'hell') # => true
'hello'.start_with?('heaven', 'paradise') # => false
- 'теÑÑ‚'.start_with?('Ñ‚') # => true
'ã“ã‚“ã«ã¡ã¯'.start_with?('ã“') # => true
-Related: String#end_with?.
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/sub.rdoc b/doc/string/sub.rdoc
new file mode 100644
index 0000000000..ff051ea177
--- /dev/null
+++ b/doc/string/sub.rdoc
@@ -0,0 +1,33 @@
+Returns a copy of self, possibly with a substring replaced.
+
+Argument +pattern+ may be a string or a Regexp;
+argument +replacement+ may be a string or a Hash.
+
+Varying types for the argument values makes this method very versatile.
+
+Below are some simple examples; for many more examples,
+see {Substitution Methods}[rdoc-ref:String@Substitution+Methods].
+
+With arguments +pattern+ and string +replacement+ given,
+replaces the first matching substring with the given replacement string:
+
+ s = 'abracadabra' # => "abracadabra"
+ s.sub('bra', 'xyzzy') # => "axyzzycadabra"
+ s.sub(/bra/, 'xyzzy') # => "axyzzycadabra"
+ s.sub('nope', 'xyzzy') # => "abracadabra"
+
+With arguments +pattern+ and hash +replacement+ given,
+replaces the first matching substring with a value from the given replacement hash, or removes it:
+
+ h = {'a' => 'A', 'b' => 'B', 'c' => 'C'}
+ s.sub('b', h) # => "aBracadabra"
+ s.sub(/b/, h) # => "aBracadabra"
+ s.sub(/d/, h) # => "abracaabra" # 'd' removed.
+
+With argument +pattern+ and a block given,
+calls the block with each matching substring;
+replaces that substring with the block’s return value:
+
+ s.sub('b') {|match| match.upcase } # => "aBracadabra"
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/succ.rdoc b/doc/string/succ.rdoc
new file mode 100644
index 0000000000..1b4b936a8e
--- /dev/null
+++ b/doc/string/succ.rdoc
@@ -0,0 +1,52 @@
+Returns the successor to +self+. The successor is calculated by
+incrementing characters.
+
+The first character to be incremented is the rightmost alphanumeric:
+or, if no alphanumerics, the rightmost character:
+
+ 'THX1138'.succ # => "THX1139"
+ '<<koala>>'.succ # => "<<koalb>>"
+ '***'.succ # => '**+'
+ 'ã“ã‚“ã«ã¡ã¯'.succ # => "ã“ã‚“ã«ã¡ã°"
+
+The successor to a digit is another digit, "carrying" to the next-left
+character for a "rollover" from 9 to 0, and prepending another digit
+if necessary:
+
+ '00'.succ # => "01"
+ '09'.succ # => "10"
+ '99'.succ # => "100"
+
+The successor to a letter is another letter of the same case,
+carrying to the next-left character for a rollover,
+and prepending another same-case letter if necessary:
+
+ 'aa'.succ # => "ab"
+ 'az'.succ # => "ba"
+ 'zz'.succ # => "aaa"
+ 'AA'.succ # => "AB"
+ 'AZ'.succ # => "BA"
+ 'ZZ'.succ # => "AAA"
+
+The successor to a non-alphanumeric character is the next character
+in the underlying character set's collating sequence,
+carrying to the next-left character for a rollover,
+and prepending another character if necessary:
+
+ s = 0.chr * 3 # => "\x00\x00\x00"
+ s.succ # => "\x00\x00\x01"
+ s = 255.chr * 3 # => "\xFF\xFF\xFF"
+ s.succ # => "\x01\x00\x00\x00"
+
+Carrying can occur between and among mixtures of alphanumeric characters:
+
+ s = 'zz99zz99' # => "zz99zz99"
+ s.succ # => "aaa00aa00"
+ s = '99zz99zz' # => "99zz99zz"
+ s.succ # => "100aa00aa"
+
+The successor to an empty +String+ is a new empty +String+:
+
+ ''.succ # => ""
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/sum.rdoc b/doc/string/sum.rdoc
index 5de24e6402..22045e5f4d 100644
--- a/doc/string/sum.rdoc
+++ b/doc/string/sum.rdoc
@@ -1,11 +1,12 @@
-Returns a basic +n+-bit checksum of the characters in +self+;
+Returns a basic +n+-bit {checksum}[https://en.wikipedia.org/wiki/Checksum] of the characters in +self+;
the checksum is the sum of the binary value of each byte in +self+,
modulo <tt>2**n - 1</tt>:
'hello'.sum # => 532
'hello'.sum(4) # => 4
'hello'.sum(64) # => 532
- 'теÑÑ‚'.sum # => 1405
'ã“ã‚“ã«ã¡ã¯'.sum # => 2582
This is not a particularly strong checksum.
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/string/swapcase.rdoc b/doc/string/swapcase.rdoc
new file mode 100644
index 0000000000..4353c8528a
--- /dev/null
+++ b/doc/string/swapcase.rdoc
@@ -0,0 +1,31 @@
+Returns a string containing the characters in +self+, with cases reversed:
+
+- Each uppercase character is downcased.
+- Each lowercase character is upcased.
+
+Examples:
+
+ 'Hello'.swapcase # => "hELLO"
+ 'Straße'.swapcase # => "sTRASSE"
+ 'RubyGems.org'.swapcase # => "rUBYgEMS.ORG"
+
+The sizes of +self+ and the upcased result may differ:
+
+ s = 'Straße'
+ s.size # => 6
+ s.swapcase # => "sTRASSE"
+ s.swapcase.size # => 7
+
+Some characters (and some character sets) do not have upcase and downcase versions;
+see {Case Mapping}[rdoc-ref:case_mapping.rdoc]:
+
+ s = '1, 2, 3, ...'
+ s.swapcase == s # => true
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.swapcase == s # => true
+
+The casing is affected by the given +mapping+,
+which may be +:ascii+, +:fold+, or +:turkic+;
+see {Case Mappings}[rdoc-ref:case_mapping.rdoc@Case+Mappings].
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/unicode_normalize.rdoc b/doc/string/unicode_normalize.rdoc
new file mode 100644
index 0000000000..5f733c0fb8
--- /dev/null
+++ b/doc/string/unicode_normalize.rdoc
@@ -0,0 +1,28 @@
+Returns a copy of +self+ with
+{Unicode normalization}[https://unicode.org/reports/tr15] applied.
+
+Argument +form+ must be one of the following symbols
+(see {Unicode normalization forms}[https://unicode.org/reports/tr15/#Norm_Forms]):
+
+- +:nfc+: Canonical decomposition, followed by canonical composition.
+- +:nfd+: Canonical decomposition.
+- +:nfkc+: Compatibility decomposition, followed by canonical composition.
+- +:nfkd+: Compatibility decomposition.
+
+The encoding of +self+ must be one of:
+
+- <tt>Encoding::UTF_8</tt>.
+- <tt>Encoding::UTF_16BE</tt>.
+- <tt>Encoding::UTF_16LE</tt>.
+- <tt>Encoding::UTF_32BE</tt>.
+- <tt>Encoding::UTF_32LE</tt>.
+- <tt>Encoding::GB18030</tt>.
+- <tt>Encoding::UCS_2BE</tt>.
+- <tt>Encoding::UCS_4BE</tt>.
+
+Examples:
+
+ "a\u0300".unicode_normalize # => "à" # Lowercase 'a' with grave accens.
+ "a\u0300".unicode_normalize(:nfd) # => "à" # Same.
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/upcase.rdoc b/doc/string/upcase.rdoc
new file mode 100644
index 0000000000..ad859e8973
--- /dev/null
+++ b/doc/string/upcase.rdoc
@@ -0,0 +1,27 @@
+Returns a new string containing the upcased characters in +self+:
+
+ 'hello'.upcase # => "HELLO"
+ 'straße'.upcase # => "STRASSE"
+ 'привет'.upcase # => "ПРИВЕТ"
+ 'RubyGems.org'.upcase # => "RUBYGEMS.ORG"
+
+The sizes of +self+ and the upcased result may differ:
+
+ s = 'Straße'
+ s.size # => 6
+ s.upcase # => "STRASSE"
+ s.upcase.size # => 7
+
+Some characters (and some character sets) do not have upcase and downcase versions;
+see {Case Mapping}[rdoc-ref:case_mapping.rdoc]:
+
+ s = '1, 2, 3, ...'
+ s.upcase == s # => true
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.upcase == s # => true
+
+The casing is affected by the given +mapping+,
+which may be +:ascii+, +:fold+, or +:turkic+;
+see {Case Mappings}[rdoc-ref:case_mapping.rdoc@Case+Mappings].
+
+Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
diff --git a/doc/string/upto.rdoc b/doc/string/upto.rdoc
new file mode 100644
index 0000000000..f860fe84fe
--- /dev/null
+++ b/doc/string/upto.rdoc
@@ -0,0 +1,38 @@
+With a block given, calls the block with each +String+ value
+returned by successive calls to String#succ;
+the first value is +self+, the next is <tt>self.succ</tt>, and so on;
+the sequence terminates when value +other_string+ is reached;
+returns +self+:
+
+ a = []
+ 'a'.upto('f') {|c| a.push(c) }
+ a # => ["a", "b", "c", "d", "e", "f"]
+
+ a = []
+ 'Ж'.upto('П') {|c| a.push(c) }
+ a # => ["Ж", "З", "И", "Й", "К", "Л", "М", "Ð", "О", "П"]
+
+ a = []
+ 'よ'.upto('ã‚') {|c| a.push(c) }
+ a # => ["よ", "ら", "り", "ã‚‹", "れ", "ã‚"]
+
+ a = []
+ 'a8'.upto('b6') {|c| a.push(c) }
+ a # => ["a8", "a9", "b0", "b1", "b2", "b3", "b4", "b5", "b6"]
+
+If argument +exclusive+ is given as a truthy object, the last value is omitted:
+
+ a = []
+ 'a'.upto('f', true) {|c| a.push(c) }
+ a # => ["a", "b", "c", "d", "e"]
+
+If +other_string+ would not be reached, does not call the block:
+
+ '25'.upto('5') {|s| fail s }
+ 'aa'.upto('a') {|s| fail s }
+
+With no block given, returns a new Enumerator:
+
+ 'a8'.upto('b6') # => #<Enumerator: "a8":upto("b6")>
+
+Related: see {Iterating}[rdoc-ref:String@Iterating].
diff --git a/doc/string/valid_encoding_p.rdoc b/doc/string/valid_encoding_p.rdoc
new file mode 100644
index 0000000000..e1db55174a
--- /dev/null
+++ b/doc/string/valid_encoding_p.rdoc
@@ -0,0 +1,8 @@
+Returns whether +self+ is encoded correctly:
+
+ s = 'Straße'
+ s.valid_encoding? # => true
+ s.encoding # => #<Encoding:UTF-8>
+ s.force_encoding(Encoding::ASCII).valid_encoding? # => false
+
+Related: see {Querying}[rdoc-ref:String@Querying].
diff --git a/doc/stringio/each_byte.rdoc b/doc/stringio/each_byte.rdoc
new file mode 100644
index 0000000000..708432b69e
--- /dev/null
+++ b/doc/stringio/each_byte.rdoc
@@ -0,0 +1,31 @@
+With a block given, calls the block with each remaining byte in the stream;
+positions the stream at end-of-file;
+returns +self+:
+
+ bytes = []
+ strio = StringIO.new('hello') # Five 1-byte characters.
+ strio.each_byte {|byte| bytes.push(byte) }
+ strio.eof? # => true
+ bytes # => [104, 101, 108, 108, 111]
+
+ bytes = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯') # Five 3-byte characters.
+ strio.each_byte {|byte| bytes.push(byte) }
+ bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+
+The position in the stream matters:
+
+ bytes = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.getc # => "ã“"
+ strio.pos # => 3 # 3-byte character was read.
+ strio.each_byte {|byte| bytes.push(byte) }
+ bytes # => [227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+
+If at end-of-file, does not call the block:
+
+ strio.eof? # => true
+ strio.each_byte {|byte| fail 'Boo!' }
+ strio.eof? # => true
+
+With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
diff --git a/doc/stringio/each_char.rdoc b/doc/stringio/each_char.rdoc
new file mode 100644
index 0000000000..bec5ecac3f
--- /dev/null
+++ b/doc/stringio/each_char.rdoc
@@ -0,0 +1,31 @@
+With a block given, calls the block with each remaining character in the stream;
+positions the stream at end-of-file;
+returns +self+:
+
+ chars = []
+ strio = StringIO.new('hello')
+ strio.each_char {|char| chars.push(char) }
+ strio.eof? # => true
+ chars # => ["h", "e", "l", "l", "o"]
+
+ chars = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.each_char {|char| chars.push(char) }
+ chars # => ["ã“", "ã‚“", "ã«", "ã¡", "ã¯"]
+
+Stream position matters:
+
+ chars = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.getc # => "ã“"
+ strio.pos # => 3 # 3-byte character was read.
+ strio.each_char {|char| chars.push(char) }
+ chars # => ["ã‚“", "ã«", "ã¡", "ã¯"]
+
+When at end-of-stream does not call the block:
+
+ strio.eof? # => true
+ strio.each_char {|char| fail 'Boo!' }
+ strio.eof? # => true
+
+With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
diff --git a/doc/stringio/each_codepoint.rdoc b/doc/stringio/each_codepoint.rdoc
new file mode 100644
index 0000000000..0d10831142
--- /dev/null
+++ b/doc/stringio/each_codepoint.rdoc
@@ -0,0 +1,33 @@
+With a block given, calls the block with each successive codepoint from self;
+sets the position to end-of-stream;
+returns +self+.
+
+Each codepoint is the integer value for a character; returns self:
+
+ codepoints = []
+ strio = StringIO.new('hello')
+ strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
+ strio.eof? # => true
+ codepoints # => [104, 101, 108, 108, 111]
+
+ codepoints = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
+ codepoints # => [12371, 12435, 12395, 12385, 12399]
+
+Position in the stream matters:
+
+ codepoints = []
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.getc # => "ã“"
+ strio.pos # => 3
+ strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
+ codepoints # => [12435, 12395, 12385, 12399]
+
+When at end-of-stream, the block is not called:
+
+ strio.eof? # => true
+ strio.each_codepoint {|codepoint| fail 'Boo!' }
+ strio.eof? # => true
+
+With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
diff --git a/doc/stringio/each_line.md b/doc/stringio/each_line.md
new file mode 100644
index 0000000000..e29640a12a
--- /dev/null
+++ b/doc/stringio/each_line.md
@@ -0,0 +1,189 @@
+With a block given calls the block with each remaining line (see "Position" below) in the stream;
+returns `self`.
+
+Leaves stream position at end-of-stream.
+
+**No Arguments**
+
+With no arguments given,
+reads lines using the default record separator
+(global variable `$/`, whose initial value is `"\n"`).
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line {|line| p line }
+strio.eof? # => true
+```
+
+Output:
+
+```
+"First line\n"
+"Second line\n"
+"\n"
+"Fourth line\n"
+"Fifth line\n"
+```
+
+**Argument `sep`**
+
+With only string argument `sep` given,
+reads lines using that string as the record separator:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line(' ') {|line| p line }
+```
+
+Output:
+
+```
+"First "
+"line\nSecond "
+"line\n\nFourth "
+"line\nFifth "
+"line\n"
+```
+
+**Argument `limit`**
+
+With only integer argument `limit` given,
+reads lines using the default record separator;
+also limits the size (in characters) of each line to the given limit:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line(10) {|line| p line }
+```
+
+Output:
+
+```
+"First line"
+"\n"
+"Second lin"
+"e\n"
+"\n"
+"Fourth lin"
+"e\n"
+"Fifth line"
+"\n"
+```
+
+**Arguments `sep` and `limit`**
+
+With arguments `sep` and `limit` both given,
+honors both:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line(' ', 10) {|line| p line }
+```
+
+Output:
+
+```
+"First "
+"line\nSecon"
+"d "
+"line\n\nFour"
+"th "
+"line\nFifth"
+" "
+"line\n"
+```
+
+**Position**
+
+As stated above, method `each` _remaining_ line in the stream.
+
+In the examples above each `strio` object starts with its position at beginning-of-stream;
+but in other cases the position may be anywhere (see StringIO#pos):
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.pos = 30 # Set stream position to character 30.
+strio.each_line {|line| p line }
+```
+
+Output:
+
+```
+" line\n"
+"Fifth line\n"
+```
+
+In all the examples above, the stream position is at the beginning of a character;
+in other cases, that need not be so:
+
+```ruby
+s = 'ã“ã‚“ã«ã¡ã¯' # Five 3-byte characters.
+strio = StringIO.new(s)
+strio.pos = 3 # At beginning of second character.
+strio.each_line {|line| p line }
+strio.pos = 4 # At second byte of second character.
+strio.each_line {|line| p line }
+strio.pos = 5 # At third byte of second character.
+strio.each_line {|line| p line }
+```
+
+Output:
+
+```
+"ã‚“ã«ã¡ã¯"
+"\x82\x93ã«ã¡ã¯"
+"\x93ã«ã¡ã¯"
+```
+
+**Special Record Separators**
+
+Like some methods in class `IO`, StringIO.each honors two special record separators;
+see {Special Line Separators}[https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Special+Line+Separator+Values].
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line('') {|line| p line } # Read as paragraphs (separated by blank lines).
+```
+
+Output:
+
+```
+"First line\nSecond line\n\n"
+"Fourth line\nFifth line\n"
+```
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line(nil) {|line| p line } # "Slurp"; read it all.
+```
+
+Output:
+
+```
+"First line\nSecond line\n\nFourth line\nFifth line\n"
+```
+
+**Keyword Argument `chomp`**
+
+With keyword argument `chomp` given as `true` (the default is `false`),
+removes trailing newline (if any) from each line:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.each_line(chomp: true) {|line| p line }
+```
+
+Output:
+
+```
+"First line"
+"Second line"
+""
+"Fourth line"
+"Fifth line"
+```
+
+With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
+
+
+Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.
diff --git a/doc/stringio/getbyte.rdoc b/doc/stringio/getbyte.rdoc
new file mode 100644
index 0000000000..148455abf4
--- /dev/null
+++ b/doc/stringio/getbyte.rdoc
@@ -0,0 +1,24 @@
+Reads and returns the next integer byte (not character) from the stream:
+
+ s = 'foo'
+ s.bytes # => [102, 111, 111]
+ strio = StringIO.new(s)
+ strio.getbyte # => 102
+ strio.getbyte # => 111
+ strio.getbyte # => 111
+
+Returns +nil+ if at end-of-stream:
+
+ strio.eof? # => true
+ strio.getbyte # => nil
+
+Returns a byte, not a character:
+
+ s = 'ã“ã‚“ã«ã¡ã¯'
+ s.bytes
+ # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+ strio = StringIO.new(s)
+ strio.getbyte # => 227
+ strio.getbyte # => 129
+
+Related: #each_byte, #ungetbyte, #getc.
diff --git a/doc/stringio/getc.rdoc b/doc/stringio/getc.rdoc
new file mode 100644
index 0000000000..58ce47c337
--- /dev/null
+++ b/doc/stringio/getc.rdoc
@@ -0,0 +1,30 @@
+Reads and returns the next character (or byte; see below) from the stream:
+
+ strio = StringIO.new('foo')
+ strio.getc # => "f"
+ strio.getc # => "o"
+ strio.getc # => "o"
+
+Returns +nil+ if at end-of-stream:
+
+ strio.eof? # => true
+ strio.getc # => nil
+
+Returns characters, not bytes:
+
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯')
+ strio.getc # => "ã“"
+ strio.getc # => "ã‚“"
+
+In each of the examples above, the stream is positioned at the beginning of a character;
+in other cases that need not be true:
+
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯') # Five 3-byte characters.
+ strio.pos = 3 # => 3 # At beginning of second character; returns character.
+ strio.getc # => "ã‚“"
+ strio.pos = 4 # => 4 # At second byte of second character; returns byte.
+ strio.getc # => "\x82"
+ strio.pos = 5 # => 5 # At third byte of second character; returns byte.
+ strio.getc # => "\x93"
+
+Related: #getbyte, #putc, #ungetc.
diff --git a/doc/stringio/gets.rdoc b/doc/stringio/gets.rdoc
new file mode 100644
index 0000000000..4152152a25
--- /dev/null
+++ b/doc/stringio/gets.rdoc
@@ -0,0 +1,99 @@
+Reads and returns a line from the stream;
+returns +nil+ if at end-of-stream.
+
+Side effects:
+
+- Increments stream position by the number of bytes read.
+- Assigns the return value to global variable <tt>$_</tt>.
+
+With no arguments given, reads a line using the default record separator
+(global variable <tt>$/</tt>,* whose initial value is <tt>"\n"</tt>):
+
+ strio = StringIO.new(TEXT)
+ strio.pos # => 0
+ strio.gets # => "First line\n"
+ strio.pos # => 11
+ $_ # => "First line\n"
+ strio.gets # => "Second line\n"
+ strio.read # => "\nFourth line\nFifth line\n"
+ strio.eof? # => true
+ strio.gets # => nil
+
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯') # Five 3-byte characters.
+ strio.pos # => 0
+ strio.gets # => "ã“ã‚“ã«ã¡ã¯"
+ strio.pos # => 15
+
+<b>Argument +sep+</b>
+
+With only string argument +sep+ given, reads a line using that string as the record separator:
+
+ strio = StringIO.new(TEXT)
+ strio.gets(' ') # => "First "
+ strio.gets(' ') # => "line\nSecond "
+ strio.gets(' ') # => "line\n\nFourth "
+
+<b>Argument +limit+</b>
+
+With only integer argument +limit+ given,
+reads a line using the default record separator;
+limits the size (in characters) of each line to the given limit:
+
+ strio = StringIO.new(TEXT)
+ strio.gets(10) # => "First line"
+ strio.gets(10) # => "\n"
+ strio.gets(10) # => "Second lin"
+ strio.gets(10) # => "e\n"
+
+<b>Arguments +sep+ and +limit+</b>
+
+With arguments +sep+ and +limit+ both given, honors both:
+
+ strio = StringIO.new(TEXT)
+ strio.gets(' ', 10) # => "First "
+ strio.gets(' ', 10) # => "line\nSecon"
+ strio.gets(' ', 10) # => "d "
+
+<b>Position</b>
+
+As stated above, method +gets+ reads and returns the next line in the stream.
+
+In the examples above each +strio+ object starts with its position at beginning-of-stream;
+but in other cases the position may be anywhere:
+
+ strio = StringIO.new(TEXT)
+ strio.pos = 12
+ strio.gets # => "econd line\n"
+
+The position need not be at a character boundary:
+
+ strio = StringIO.new('ã“ã‚“ã«ã¡ã¯') # Five 3-byte characters.
+ strio.pos = 3 # At beginning of second character.
+ strio.gets # => "ã‚“ã«ã¡ã¯"
+ strio.pos = 4 # Within second character.
+ strio.gets # => "\x82\x93ã«ã¡ã¯"
+
+<b>Special Record Separators</b>
+
+Like some methods in class IO, method +gets+ honors two special record separators;
+see {Special Line Separators}[https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Special+Line+Separator+Values]:
+
+ strio = StringIO.new(TEXT)
+ strio.gets('') # Read "paragraph" (up to empty line).
+ # => "First line\nSecond line\n\n"
+
+ strio = StringIO.new(TEXT)
+ strio.gets(nil) # "Slurp": read all.
+ # => "First line\nSecond line\n\nFourth line\nFifth line\n"
+
+<b>Keyword Argument +chomp+</b>
+
+With keyword argument +chomp+ given as +true+ (the default is +false+),
+removes the trailing newline (if any) from the returned line:
+
+ strio = StringIO.new(TEXT)
+ strio.gets # => "First line\n"
+ strio.gets(chomp: true) # => "Second line"
+
+Related: #each_line, #readlines,
+{Kernel#puts}[rdoc-ref:Kernel#puts].
diff --git a/doc/stringio/pread.rdoc b/doc/stringio/pread.rdoc
new file mode 100644
index 0000000000..2dcbc18ad8
--- /dev/null
+++ b/doc/stringio/pread.rdoc
@@ -0,0 +1,65 @@
+**Note**: \Method +pread+ is different from other reading methods
+in that it does not modify +self+ in any way;
+thus, multiple threads may read safely from the same stream.
+
+Reads up to +maxlen+ bytes from the stream,
+beginning at 0-based byte offset +offset+;
+returns a string containing the read bytes.
+
+The returned string:
+
+- Contains +maxlen+ bytes from the stream, if available;
+ otherwise contains all available bytes.
+- Has encoding +Encoding::ASCII_8BIT+.
+
+With only arguments +maxlen+ and +offset+ given,
+returns a new string:
+
+ english = 'Hello' # Five 1-byte characters.
+ strio = StringIO.new(english)
+ strio.pread(3, 0) # => "Hel"
+ strio.pread(3, 2) # => "llo"
+ strio.pread(0, 0) # => ""
+ strio.pread(50, 0) # => "Hello"
+ strio.pread(50, 2) # => "llo"
+ strio.pread(50, 4) # => "o"
+ strio.pread(0, 0).encoding
+ # => #<Encoding:BINARY (ASCII-8BIT)>
+
+ russian = 'Привет' # Six 2-byte characters.
+ strio = StringIO.new(russian)
+ strio.pread(50, 0) # All 12 bytes.
+ # => "\xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82"
+ strio.pread(3, 0) # => "\xD0\x9F\xD1"
+ strio.pread(3, 3) # => "\x80\xD0\xB8"
+ strio.pread(0, 0).encoding
+ # => #<Encoding:BINARY (ASCII-8BIT)>
+
+ japanese = 'ã“ã‚“ã«ã¡ã¯' # Five 3-byte characters.
+ strio = StringIO.new(japanese)
+ strio.pread(50, 0) # All 15 bytes.
+ # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ strio.pread(6, 0) # => "\xE3\x81\x93\xE3\x82\x93"
+ strio.pread(1, 2) # => "\x93"
+ strio.pread(0, 0).encoding
+ # => #<Encoding:BINARY (ASCII-8BIT)>
+
+Raises an exception if +offset+ is out-of-range:
+
+ strio = StringIO.new(english)
+ strio.pread(5, 50) # Raises EOFError: end of file reached
+
+With string argument +out_string+ given:
+
+- Reads as above.
+- Overwrites the content of +out_string+ with the read bytes.
+
+Examples:
+
+ out_string = 'Will be overwritten'
+ out_string.encoding # => #<Encoding:UTF-8>
+ result = StringIO.new(english).pread(50, 0, out_string)
+ result.__id__ == out_string.__id__ # => true
+ out_string # => "Hello"
+ out_string.encoding # => #<Encoding:BINARY (ASCII-8BIT)>
+
diff --git a/doc/stringio/putc.rdoc b/doc/stringio/putc.rdoc
new file mode 100644
index 0000000000..4636ffa0db
--- /dev/null
+++ b/doc/stringio/putc.rdoc
@@ -0,0 +1,82 @@
+Replaces one or more bytes at position +pos+
+with bytes of the given argument;
+advances the position by the count of bytes written;
+returns the argument.
+
+\StringIO object for 1-byte characters.
+
+ strio = StringIO.new('foo')
+ strio.pos # => 0
+
+With 1-byte argument, replaces one byte:
+
+ strio.putc('b')
+ strio.string # => "boo"
+ strio.pos # => 1
+ strio.putc('a') # => "a"
+ strio.string # => "bao"
+ strio.pos # => 2
+ strio.putc('r') # => "r"
+ strio.string # => "bar"
+ strio.pos # => 3
+ strio.putc('n') # => "n"
+ strio.string # => "barn"
+ strio.pos # => 4
+
+Fills with null characters if necessary:
+
+ strio.pos = 6
+ strio.putc('x') # => "x"
+ strio.string # => "barn\u0000\u0000x"
+ strio.pos # => 7
+
+With integer argument, replaces one byte with the low-order byte of the integer:
+
+ strio = StringIO.new('foo')
+ strio.putc(70)
+ strio.string # => "Foo"
+ strio.putc(79)
+ strio.string # => "FOo"
+ strio.putc(79 + 1024)
+ strio.string # => "FOO"
+
+\StringIO object for Multi-byte characters:
+
+ greek = 'αβγδε' # Five 2-byte characters.
+ strio = StringIO.new(greek)
+ strio.string# => "αβγδε"
+ strio.string.b # => "\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5"
+ strio.string.bytesize # => 10
+ strio.string.chars # => ["α", "β", "γ", "δ", "ε"]
+ strio.string.size # => 5
+
+With 1-byte argument, replaces one byte of the string:
+
+ strio.putc(' ') # 1-byte ascii space.
+ strio.pos # => 1
+ strio.string # => " \xB1βγδε"
+ strio.string.b # => " \xB1\xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5"
+ strio.string.bytesize # => 10
+ strio.string.chars # => [" ", "\xB1", "β", "γ", "δ", "ε"]
+ strio.string.size # => 6
+
+ strio.putc(' ')
+ strio.pos # => 2
+ strio.string # => " βγδε"
+ strio.string.b # => " \xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5"
+ strio.string.bytesize # => 10
+ strio.string.chars # => [" ", " ", "β", "γ", "δ", "ε"]
+ strio.string.size # => 6
+
+With 2-byte argument, replaces two bytes of the string:
+
+ strio.rewind
+ strio.putc('α')
+ strio.pos # => 2
+ strio.string # => "αβγδε"
+ strio.string.b # => "\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5"
+ strio.string.bytesize # => 10
+ strio.string.chars # => ["α", "β", "γ", "δ", "ε"]
+ strio.string.size # => 5
+
+Related: #getc, #ungetc.
diff --git a/doc/stringio/read.rdoc b/doc/stringio/read.rdoc
new file mode 100644
index 0000000000..46b9fa349f
--- /dev/null
+++ b/doc/stringio/read.rdoc
@@ -0,0 +1,83 @@
+Reads and returns a string containing bytes read from the stream,
+beginning at the current position;
+advances the position by the count of bytes read.
+
+With no arguments given,
+reads all remaining bytes in the stream;
+returns a new string containing bytes read:
+
+ strio = StringIO.new('Hello') # Five 1-byte characters.
+ strio.read # => "Hello"
+ strio.pos # => 5
+ strio.read # => ""
+ StringIO.new('').read # => ""
+
+With non-negative argument +maxlen+ given,
+reads +maxlen+ bytes as available;
+returns a new string containing the bytes read, or +nil+ if none:
+
+ strio.rewind
+ strio.read(3) # => "Hel"
+ strio.read(3) # => "lo"
+ strio.read(3) # => nil
+
+ russian = 'Привет' # Six 2-byte characters.
+ russian.b
+ # => "\xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82"
+ strio = StringIO.new(russian)
+ strio.read(6) # => "\xD0\x9F\xD1\x80\xD0\xB8"
+ strio.read(6) # => "\xD0\xB2\xD0\xB5\xD1\x82"
+ strio.read(6) # => nil
+
+ japanese = 'ã“ã‚“ã«ã¡ã¯'
+ japanese.b
+ # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ strio = StringIO.new(japanese)
+ strio.read(9) # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB"
+ strio.read(9) # => "\xE3\x81\xA1\xE3\x81\xAF"
+ strio.read(9) # => nil
+
+With argument +max_len+ as +nil+ and string argument +out_string+ given,
+reads the remaining bytes in the stream;
+clears +out_string+ and writes the bytes into it;
+returns +out_string+:
+
+ out_string = 'Will be overwritten'
+ strio = StringIO.new('Hello')
+ strio.read(nil, out_string) # => "Hello"
+ strio.read(nil, out_string) # => ""
+
+With non-negative argument +maxlen+ and string argument +out_string+ given,
+reads the +maxlen bytes from the stream, as availble;
+clears +out_string+ and writes the bytes into it;
+returns +out_string+ if any bytes were read, or +nil+ if none:
+
+ out_string = 'Will be overwritten'
+ strio = StringIO.new('Hello')
+ strio.read(3, out_string) # => "Hel"
+ strio.read(3, out_string) # => "lo"
+ strio.read(3, out_string) # => nil
+
+ out_string = 'Will be overwritten'
+ strio = StringIO.new(russian)
+ strio.read(6, out_string) # => "При"
+ strio.read(6, out_string) # => "вет"
+ strio.read(6, out_string) # => nil
+ strio.rewind
+ russian.b
+ # => "\xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82"
+ strio.read(3) # => "\xD0\x9F\xD1"
+ strio.read(3) # => "\x80\xD0\xB8"
+
+ out_string = 'Will be overwritten'
+ strio = StringIO.new(japanese)
+ strio.read(9, out_string) # => "ã“ã‚“ã«"
+ strio.read(9, out_string) # => "ã¡ã¯"
+ strio.read(9, out_string) # => nil
+ strio.rewind
+ japanese.b
+ # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ strio.read(4) # => "\xE3\x81\x93\xE3"
+ strio.read(4) # => "\x82\x93\xE3\x81"
+
+Related: #gets, #readlines.
diff --git a/doc/stringio/size.rdoc b/doc/stringio/size.rdoc
new file mode 100644
index 0000000000..253c612c43
--- /dev/null
+++ b/doc/stringio/size.rdoc
@@ -0,0 +1,4 @@
+Returns the number of bytes in the string in +self+:
+
+ StringIO.new('hello').size # => 5 # Five 1-byte characters.
+ StringIO.new('ã“ã‚“ã«ã¡ã¯').size # => 15 # Five 3-byte characters.
diff --git a/doc/stringio/stringio.md b/doc/stringio/stringio.md
new file mode 100644
index 0000000000..f81f79cfea
--- /dev/null
+++ b/doc/stringio/stringio.md
@@ -0,0 +1,702 @@
+\Class \StringIO supports accessing a string as a stream,
+similar in some ways to [class IO][io class].
+
+You can create a \StringIO instance using:
+
+- StringIO.new: returns a new \StringIO object containing the given string.
+- StringIO.open: passes a new \StringIO object to the given block.
+
+Like an \IO stream, a \StringIO stream has certain properties:
+
+- **Read/write mode**: whether the stream may be read, written, appended to, etc.;
+ see [Read/Write Mode][read/write mode].
+- **Data mode**: text-only or binary;
+ see [Data Mode][data mode].
+- **Encodings**: internal and external encodings;
+ see [Encodings][encodings].
+- **Position**: where in the stream the next read or write is to occur;
+ see [Position][position].
+- **Line number**: a special, line-oriented, "position" (different from the position mentioned above);
+ see [Line Number][line number].
+- **Open/closed**: whether the stream is open or closed, for reading or writing.
+ see [Open/Closed Streams][open/closed streams].
+- **BOM**: byte mark order;
+ see [Byte Order Mark][bom (byte order mark)].
+
+## About the Examples
+
+Examples on this page assume that \StringIO has been required:
+
+```ruby
+require 'stringio'
+```
+
+And that this constant has been defined:
+
+```ruby
+TEXT = <<EOT
+First line
+Second line
+
+Fourth line
+Fifth line
+EOT
+```
+
+## Stream Properties
+
+### Read/Write Mode
+
+#### Summary
+
+| Mode | Initial Clear? | Read | Write |
+|:--------------------------:|:--------------:|:--------:|:--------:|
+| <tt>'r'</tt>: read-only | No | Anywhere | Error |
+| <tt>'w'</tt>: write-only | Yes | Error | Anywhere |
+| <tt>'a'</tt>: append-only | No | Error | End only |
+| <tt>'r+'</tt>: read/write | No | Anywhere | Anywhere |
+| <tt>'w+'</tt>: read-write | Yes | Anywhere | Anywhere |
+| <tt>'a+'</tt>: read/append | No | Anywhere | End only |
+
+Each section below describes a read/write mode.
+
+Any of the modes may be given as a string or as file constants;
+example:
+
+```ruby
+strio = StringIO.new('foo', 'a')
+strio = StringIO.new('foo', File::WRONLY | File::APPEND)
+```
+
+#### `'r'`: Read-Only
+
+Mode specified as one of:
+
+- String: `'r'`.
+- Constant: `File::RDONLY`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foobarbaz', 'r')
+strio.pos # => 0 # Beginning-of-stream.
+strio.string # => "foobarbaz" # Not cleared.
+```
+
+May be read anywhere:
+
+```ruby
+strio.gets(3) # => "foo"
+strio.gets(3) # => "bar"
+strio.pos = 9
+strio.gets(3) # => nil
+```
+
+May not be written:
+
+```ruby
+strio.write('foo') # Raises IOError: not opened for writing
+```
+
+#### `'w'`: Write-Only
+
+Mode specified as one of:
+
+- String: `'w'`.
+- Constant: `File::WRONLY`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foo', 'w')
+strio.pos # => 0 # Beginning of stream.
+strio.string # => "" # Initially cleared.
+```
+
+May be written anywhere (even past end-of-stream):
+
+```ruby
+strio.write('foobar')
+strio.string # => "foobar"
+strio.rewind
+strio.write('FOO')
+strio.string # => "FOObar"
+strio.pos = 3
+strio.write('BAR')
+strio.string # => "FOOBAR"
+strio.pos = 9
+strio.write('baz')
+strio.string # => "FOOBAR\u0000\u0000\u0000baz" # Null-padded.
+```
+
+May not be read:
+
+```ruby
+strio.read # Raises IOError: not opened for reading
+```
+
+#### `'a'`: Append-Only
+
+Mode specified as one of:
+
+- String: `'a'`.
+- Constant: `File::WRONLY | File::APPEND`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foo', 'a')
+strio.pos # => 0 # Beginning-of-stream.
+strio.string # => "foo" # Not cleared.
+```
+
+May be written only at the end; position does not affect writing:
+
+```ruby
+strio.write('bar')
+strio.string # => "foobar"
+strio.write('baz')
+strio.string # => "foobarbaz"
+strio.pos = 400
+strio.write('bat')
+strio.string # => "foobarbazbat"
+```
+
+May not be read:
+
+```ruby
+strio.gets # Raises IOError: not opened for reading
+```
+
+#### `'r+'`: Read/Write
+
+Mode specified as one of:
+
+- String: `'r+'`.
+- Constant: `File::RDRW`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foobar', 'r+')
+strio.pos # => 0 # Beginning-of-stream.
+strio.string # => "foobar" # Not cleared.
+```
+
+May be written anywhere (even past end-of-stream):
+
+```ruby
+strio.write('FOO')
+strio.string # => "FOObar"
+strio.write('BAR')
+strio.string # => "FOOBAR"
+strio.write('BAZ')
+strio.string # => "FOOBARBAZ"
+strio.pos = 12
+strio.write('BAT')
+strio.string # => "FOOBARBAZ\u0000\u0000\u0000BAT" # Null padded.
+```
+
+May be read anywhere:
+
+```ruby
+strio.pos = 0
+strio.gets(3) # => "FOO"
+strio.pos = 6
+strio.gets(3) # => "BAZ"
+strio.pos = 400
+strio.gets(3) # => nil
+```
+
+#### `'w+'`: Read/Write (Initially Clear)
+
+Mode specified as one of:
+
+- String: `'w+'`.
+- Constant: `File::RDWR | File::TRUNC`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foo', 'w+')
+strio.pos # => 0 # Beginning-of-stream.
+strio.string # => "" # Truncated.
+```
+
+May be written anywhere (even past end-of-stream):
+
+```ruby
+strio.write('foobar')
+strio.string # => "foobar"
+strio.rewind
+strio.write('FOO')
+strio.string # => "FOObar"
+strio.write('BAR')
+strio.string # => "FOOBAR"
+strio.write('BAZ')
+strio.string # => "FOOBARBAZ"
+strio.pos = 12
+strio.write('BAT')
+strio.string # => "FOOBARBAZ\u0000\u0000\u0000BAT" # Null-padded.
+```
+
+May be read anywhere:
+
+```ruby
+strio.rewind
+strio.gets(3) # => "FOO"
+strio.gets(3) # => "BAR"
+strio.pos = 12
+strio.gets(3) # => "BAT"
+strio.pos = 400
+strio.gets(3) # => nil
+```
+
+#### `'a+'`: Read/Append
+
+Mode specified as one of:
+
+- String: `'a+'`.
+- Constant: `File::RDWR | File::APPEND`.
+
+Initial state:
+
+```ruby
+strio = StringIO.new('foo', 'a+')
+strio.pos # => 0 # Beginning-of-stream.
+strio.string # => "foo" # Not cleared.
+```
+
+May be written only at the end; #rewind; position does not affect writing:
+
+```ruby
+strio.write('bar')
+strio.string # => "foobar"
+strio.write('baz')
+strio.string # => "foobarbaz"
+strio.pos = 400
+strio.write('bat')
+strio.string # => "foobarbazbat"
+```
+
+May be read anywhere:
+
+```ruby
+strio.rewind
+strio.gets(3) # => "foo"
+strio.gets(3) # => "bar"
+strio.pos = 9
+strio.gets(3) # => "bat"
+strio.pos = 400
+strio.gets(3) # => nil
+```
+
+### Data Mode
+
+To specify whether the stream is to be treated as text or as binary data,
+either of the following may be suffixed to any of the string read/write modes above:
+
+- `'t'`: Text;
+ initializes the encoding as Encoding::UTF_8.
+- `'b'`: Binary;
+ initializes the encoding as Encoding::ASCII_8BIT.
+
+If neither is given, the stream defaults to text data.
+
+Examples:
+
+```ruby
+strio = StringIO.new('foo', 'rt')
+strio.external_encoding # => #<Encoding:UTF-8>
+data = "\u9990\u9991\u9992\u9993\u9994"
+strio = StringIO.new(data, 'rb')
+strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>
+```
+
+When the data mode is specified, the read/write mode may not be omitted:
+
+```ruby
+StringIO.new(data, 'b') # Raises ArgumentError: invalid access mode b
+```
+
+A text stream may be changed to binary by calling instance method #binmode;
+a binary stream may not be changed to text.
+
+### Encodings
+
+A stream has an encoding; see [Encodings][encodings document].
+
+The initial encoding for a new or re-opened stream depends on its [data mode][data mode]:
+
+- Text: `Encoding::UTF_8`.
+- Binary: `Encoding::ASCII_8BIT`.
+
+These instance methods are relevant:
+
+- #external_encoding: returns the current encoding of the stream as an `Encoding` object.
+- #internal_encoding: returns +nil+; a stream does not have an internal encoding.
+- #set_encoding: sets the encoding for the stream.
+- #set_encoding_by_bom: sets the encoding for the stream to the stream's BOM (byte order mark).
+
+Examples:
+
+```ruby
+strio = StringIO.new('foo', 'rt') # Text mode.
+strio.external_encoding # => #<Encoding:UTF-8>
+data = "\u9990\u9991\u9992\u9993\u9994"
+strio = StringIO.new(data, 'rb') # Binary mode.
+strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>
+strio = StringIO.new('foo')
+strio.external_encoding # => #<Encoding:UTF-8>
+strio.set_encoding('US-ASCII')
+strio.external_encoding # => #<Encoding:US-ASCII>
+```
+
+### Position
+
+A stream has a _position_, and integer offset (in bytes) into the stream.
+The initial position of a stream is zero.
+
+#### Getting and Setting the Position
+
+Each of these methods initializes (to zero) the position of a new or re-opened stream:
+
+- ::new: returns a new stream.
+- ::open: passes a new stream to the block.
+- #reopen: re-initializes the stream.
+
+Each of these methods queries, gets, or sets the position, without otherwise changing the stream:
+
+- #eof?: returns whether the position is at end-of-stream.
+- #pos: returns the position.
+- #pos=: sets the position.
+- #rewind: sets the position to zero.
+- #seek: sets the position.
+
+Examples:
+
+```ruby
+strio = StringIO.new('foobar')
+strio.pos # => 0
+strio.pos = 3
+strio.pos # => 3
+strio.eof? # => false
+strio.rewind
+strio.pos # => 0
+strio.seek(0, IO::SEEK_END)
+strio.pos # => 6
+strio.eof? # => true
+```
+
+#### Position Before and After Reading
+
+Except for #pread, a stream reading method (see [Basic Reading][basic reading])
+begins reading at the current position.
+
+Except for #pread, a read method advances the position past the read substring.
+
+Examples:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.string # => "First line\nSecond line\n\nFourth line\nFifth line\n"
+strio.pos # => 0
+strio.getc # => "F"
+strio.pos # => 1
+strio.gets # => "irst line\n"
+strio.pos # => 11
+strio.pos = 24
+strio.gets # => "Fourth line\n"
+strio.pos # => 36
+
+strio = StringIO.new('ã“ã‚“ã«ã¡ã¯') # Five 3-byte characters.
+strio.pos = 0 # At first byte of first character.
+strio.read # => "ã“ã‚“ã«ã¡ã¯"
+strio.pos = 1 # At second byte of first character.
+strio.read # => "\x81\x93ã‚“ã«ã¡ã¯"
+strio.pos = 2 # At third byte of first character.
+strio.read # => "\x93ã‚“ã«ã¡ã¯"
+strio.pos = 3 # At first byte of second character.
+strio.read # => "ã‚“ã«ã¡ã¯"
+
+strio = StringIO.new(TEXT)
+strio.pos = 15
+a = []
+strio.each_line {|line| a.push(line) }
+a # => ["nd line\n", "\n", "Fourth line\n", "Fifth line\n"]
+strio.pos # => 47 ## End-of-stream.
+```
+
+#### Position Before and After Writing
+
+Each of these methods begins writing at the current position,
+and advances the position to the end of the written substring:
+
+- #putc: writes the given character.
+- #write: writes the given objects as strings.
+- [Kernel#puts][kernel#puts]: writes given objects as strings, each followed by newline.
+
+Examples:
+
+```ruby
+strio = StringIO.new('foo')
+strio.pos # => 0
+strio.putc('b')
+strio.string # => "boo"
+strio.pos # => 1
+strio.write('r')
+strio.string # => "bro"
+strio.pos # => 2
+strio.puts('ew')
+strio.string # => "brew\n"
+strio.pos # => 5
+strio.pos = 8
+strio.write('foo')
+strio.string # => "brew\n\u0000\u0000\u0000foo"
+strio.pos # => 11
+```
+
+Each of these methods writes _before_ the current position, and decrements the position
+so that the written data is next to be read:
+
+- #ungetbyte: unshifts the given byte.
+- #ungetc: unshifts the given character.
+
+Examples:
+
+```ruby
+strio = StringIO.new('foo')
+strio.pos = 2
+strio.ungetc('x')
+strio.pos # => 1
+strio.string # => "fxo"
+strio.ungetc('x')
+strio.pos # => 0
+strio.string # => "xxo"
+```
+
+This method does not affect the position:
+
+- #truncate: truncates the stream's string to the given size.
+
+Examples:
+
+```ruby
+strio = StringIO.new('foobar')
+strio.pos # => 0
+strio.truncate(3)
+strio.string # => "foo"
+strio.pos # => 0
+strio.pos = 500
+strio.truncate(0)
+strio.string # => ""
+strio.pos # => 500
+```
+
+### Line Number
+
+A stream has a line number, which initially is zero:
+
+- Method #lineno returns the line number.
+- Method #lineno= sets the line number.
+
+The line number can be affected by reading (but never by writing);
+in general, the line number is incremented each time the record separator (default: `"\n"`) is read.
+
+Examples:
+
+```ruby
+strio = StringIO.new(TEXT)
+strio.string # => "First line\nSecond line\n\nFourth line\nFifth line\n"
+strio.lineno # => 0
+strio.gets # => "First line\n"
+strio.lineno # => 1
+strio.getc # => "S"
+strio.lineno # => 1
+strio.gets # => "econd line\n"
+strio.lineno # => 2
+strio.gets # => "\n"
+strio.lineno # => 3
+strio.gets # => "Fourth line\n"
+strio.lineno # => 4
+```
+
+Setting the position does not affect the line number:
+
+```ruby
+strio.pos = 0
+strio.lineno # => 4
+strio.gets # => "First line\n"
+strio.pos # => 11
+strio.lineno # => 5
+```
+
+And setting the line number does not affect the position:
+
+```ruby
+strio.lineno = 10
+strio.pos # => 11
+strio.gets # => "Second line\n"
+strio.lineno # => 11
+strio.pos # => 23
+```
+
+### Open/Closed Streams
+
+A new stream is open for either reading or writing, and may be open for both;
+see [Read/Write Mode][read/write mode].
+
+Each of these methods initializes the read/write mode for a new or re-opened stream:
+
+- ::new: returns a new stream.
+- ::open: passes a new stream to the block.
+- #reopen: re-initializes the stream.
+
+Other relevant methods:
+
+- #close: closes the stream for both reading and writing.
+- #close_read: closes the stream for reading.
+- #close_write: closes the stream for writing.
+- #closed?: returns whether the stream is closed for both reading and writing.
+- #closed_read?: returns whether the stream is closed for reading.
+- #closed_write?: returns whether the stream is closed for writing.
+
+### BOM (Byte Order Mark)
+
+The string provided for ::new, ::open, or #reopen
+may contain an optional [BOM][bom] (byte order mark) at the beginning of the string;
+the BOM can affect the stream's encoding.
+
+The BOM (if provided):
+
+- Is stored as part of the stream's string.
+- Does _not_ immediately affect the encoding.
+- Is _initially_ considered part of the stream.
+
+```ruby
+utf8_bom = "\xEF\xBB\xBF"
+string = utf8_bom + 'foo'
+string.bytes # => [239, 187, 191, 102, 111, 111]
+strio.string.bytes.take(3) # => [239, 187, 191] # The BOM.
+strio = StringIO.new(string, 'rb')
+strio.string.bytes # => [239, 187, 191, 102, 111, 111] # BOM is part of the stored string.
+strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)> # Default for a binary stream.
+strio.gets # => "\xEF\xBB\xBFfoo" # BOM is part of the stream.
+```
+
+You can call instance method #set_encoding_by_bom to "activate" the stored BOM;
+after doing so the BOM:
+
+- Is _still_ stored as part of the stream's string.
+- _Determines_ (and may have changed) the stream's encoding.
+- Is _no longer_ considered part of the stream.
+
+```ruby
+strio.set_encoding_by_bom
+strio.string.bytes # => [239, 187, 191, 102, 111, 111] # BOM is still part of the stored string.
+strio.external_encoding # => #<Encoding:UTF-8> # The new encoding.
+strio.rewind # => 0
+strio.gets # => "foo" # BOM is not part of the stream.
+```
+
+## Basic Stream \IO
+
+### Basic Reading
+
+You can read from the stream using these instance methods:
+
+- #getbyte: reads and returns the next byte.
+- #getc: reads and returns the next character.
+- #gets: reads and returns all or part of the next line.
+- #read: reads and returns all or part of the remaining data in the stream.
+- #readlines: reads the remaining data the stream and returns an array of its lines.
+- [Kernel#readline][kernel#readline]: like #gets, but raises an exception if at end-of-stream.
+
+You can iterate over the stream using these instance methods:
+
+- #each_byte: reads each remaining byte, passing it to the block.
+- #each_char: reads each remaining character, passing it to the block.
+- #each_codepoint: reads each remaining codepoint, passing it to the block.
+- #each_line: reads all or part of each remaining line, passing the read string to the block
+
+This instance method is useful in a multi-threaded application:
+
+- #pread: reads and returns all or part of the stream.
+
+### Basic Writing
+
+You can write to the stream, advancing the position, using these instance methods:
+
+- #putc: writes a given character.
+- #write: writes the given objects as strings.
+- [Kernel#puts][kernel#puts] writes given objects as strings, each followed by newline.
+
+You can "unshift" to the stream using these instance methods;
+each writes _before_ the current position, and decrements the position
+so that the written data is next to be read.
+
+- #ungetbyte: unshifts the given byte.
+- #ungetc: unshifts the given character.
+
+One more writing method:
+
+- #truncate: truncates the stream's string to the given size.
+
+## Line \IO
+
+Reading:
+
+- #gets: reads and returns the next line.
+- [Kernel#readline][kernel#readline]: like #gets, but raises an exception if at end-of-stream.
+- #readlines: reads the remaining data the stream and returns an array of its lines.
+- #each_line: reads each remaining line, passing it to the block
+
+Writing:
+
+- [Kernel#puts][kernel#puts]: writes given objects, each followed by newline.
+
+## Character \IO
+
+Reading:
+
+- #each_char: reads each remaining character, passing it to the block.
+- #getc: reads and returns the next character.
+
+Writing:
+
+- #putc: writes the given character.
+- #ungetc.: unshifts the given character.
+
+## Byte \IO
+
+Reading:
+
+- #each_byte: reads each remaining byte, passing it to the block.
+- #getbyte: reads and returns the next byte.
+
+Writing:
+
+- #ungetbyte: unshifts the given byte.
+
+## Codepoint \IO
+
+Reading:
+
+- #each_codepoint: reads each remaining codepoint, passing it to the block.
+
+[bom]: https://en.wikipedia.org/wiki/Byte_order_mark
+[encodings document]: https://docs.ruby-lang.org/en/master/language/encodings_rdoc.html
+[io class]: https://docs.ruby-lang.org/en/master/IO.html
+[kernel#puts]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-puts
+[kernel#readline]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-readline
+
+[basic reading]: rdoc-ref:StringIO@Basic+Reading
+[basic writing]: rdoc-ref:StringIO@Basic+Writing
+[bom (byte order mark)]: rdoc-ref:StringIO@BOM+Byte+Order+Mark
+[data mode]: rdoc-ref:StringIO@Data+Mode
+[encodings]: rdoc-ref:StringIO@Encodings
+[end-of-stream]: rdoc-ref:StringIO@End-of-Stream
+[line number]: rdoc-ref:StringIO@Line+Number
+[open/closed streams]: rdoc-ref:StringIO@OpenClosed+Streams
+[position]: rdoc-ref:StringIO@Position
+[read/write mode]: rdoc-ref:StringIO@ReadWrite+Mode
diff --git a/doc/strscan/.document b/doc/strscan/.document
new file mode 100644
index 0000000000..b8085a8474
--- /dev/null
+++ b/doc/strscan/.document
@@ -0,0 +1 @@
+helper_methods.md
diff --git a/doc/strscan/helper_methods.md b/doc/strscan/helper_methods.md
new file mode 100644
index 0000000000..9fb1d79bba
--- /dev/null
+++ b/doc/strscan/helper_methods.md
@@ -0,0 +1,124 @@
+## Helper Methods
+
+These helper methods display values returned by scanner's methods.
+
+### `put_situation(scanner)`
+
+Display scanner's situation:
+
+- Byte position (`#pos`).
+- Character position (`#charpos`)
+- Target string (`#rest`) and size (`#rest_size`).
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+scanner.scan(/foo/)
+put_situation(scanner)
+# Situation:
+# pos: 3
+# charpos: 3
+# rest: "barbaz"
+# rest_size: 6
+```
+
+### `put_match_values(scanner)`
+
+Display the scanner's match values:
+
+```rb
+scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+pattern = /(?<wday>\w+) (?<month>\w+) (?<day>\d+) /
+scanner.match?(pattern)
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 11
+# pre_match: ""
+# matched : "Fri Dec 12 "
+# post_match: "1975 14:39"
+# Captured match values:
+# size: 4
+# captures: ["Fri", "Dec", "12"]
+# named_captures: {"wday"=>"Fri", "month"=>"Dec", "day"=>"12"}
+# values_at: ["Fri Dec 12 ", "Fri", "Dec", "12", nil]
+# []:
+# [0]: "Fri Dec 12 "
+# [1]: "Fri"
+# [2]: "Dec"
+# [3]: "12"
+# [4]: nil
+```
+
+### `match_values_cleared?(scanner)`
+
+Returns whether the scanner's match values are all properly cleared:
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+match_values_cleared?(scanner) # => true
+put_match_values(scanner)
+# Basic match values:
+# matched?: false
+# matched_size: nil
+# pre_match: nil
+# matched : nil
+# post_match: nil
+# Captured match values:
+# size: nil
+# captures: nil
+# named_captures: {}
+# values_at: nil
+# [0]: nil
+scanner.scan(/foo/)
+match_values_cleared?(scanner) # => false
+```
+
+## The Code
+
+```rb
+def put_situation(scanner)
+ puts '# Situation:'
+ puts "# pos: #{scanner.pos}"
+ puts "# charpos: #{scanner.charpos}"
+ puts "# rest: #{scanner.rest.inspect}"
+ puts "# rest_size: #{scanner.rest_size}"
+end
+
+def put_match_values(scanner)
+ puts '# Basic match values:'
+ puts "# matched?: #{scanner.matched?}"
+ value = scanner.matched_size || 'nil'
+ puts "# matched_size: #{value}"
+ puts "# pre_match: #{scanner.pre_match.inspect}"
+ puts "# matched : #{scanner.matched.inspect}"
+ puts "# post_match: #{scanner.post_match.inspect}"
+ puts '# Captured match values:'
+ puts "# size: #{scanner.size}"
+ puts "# captures: #{scanner.captures}"
+ puts "# named_captures: #{scanner.named_captures}"
+ if scanner.size.nil?
+ puts "# values_at: #{scanner.values_at(0)}"
+ puts "# [0]: #{scanner[0]}"
+ else
+ puts "# values_at: #{scanner.values_at(*(0..scanner.size))}"
+ puts "# []:"
+ scanner.size.times do |i|
+ puts "# [#{i}]: #{scanner[i].inspect}"
+ end
+ end
+end
+
+def match_values_cleared?(scanner)
+ scanner.matched? == false &&
+ scanner.matched_size.nil? &&
+ scanner.matched.nil? &&
+ scanner.pre_match.nil? &&
+ scanner.post_match.nil? &&
+ scanner.size.nil? &&
+ scanner[0].nil? &&
+ scanner.captures.nil? &&
+ scanner.values_at(0..1).nil? &&
+ scanner.named_captures == {}
+end
+```
+
diff --git a/doc/strscan/link_refs.txt b/doc/strscan/link_refs.txt
new file mode 100644
index 0000000000..04c4419982
--- /dev/null
+++ b/doc/strscan/link_refs.txt
@@ -0,0 +1,17 @@
+[1]: rdoc-ref:StringScanner@Stored+String
+[2]: rdoc-ref:StringScanner@Byte+Position+Position
+[3]: rdoc-ref:StringScanner@Target+Substring
+[4]: rdoc-ref:StringScanner@Setting+the+Target+Substring
+[5]: rdoc-ref:StringScanner@Traversing+the+Target+Substring
+[6]: https://docs.ruby-lang.org/en/master/Regexp.html
+[7]: rdoc-ref:StringScanner@Character+Position
+[8]: https://docs.ruby-lang.org/en/master/String.html#method-i-5B-5D
+[9]: rdoc-ref:StringScanner@Match+Values
+[10]: rdoc-ref:StringScanner@Fixed-Anchor+Property
+[11]: rdoc-ref:StringScanner@Positions
+[13]: rdoc-ref:StringScanner@Captured+Match+Values
+[14]: rdoc-ref:StringScanner@Querying+the+Target+Substring
+[15]: rdoc-ref:StringScanner@Searching+the+Target+Substring
+[16]: https://docs.ruby-lang.org/en/master/Regexp.html#class-Regexp-label-Groups+and+Captures
+[17]: rdoc-ref:StringScanner@Matching
+[18]: rdoc-ref:StringScanner@Basic+Match+Values
diff --git a/doc/strscan/methods/get_byte.md b/doc/strscan/methods/get_byte.md
new file mode 100644
index 0000000000..775226638e
--- /dev/null
+++ b/doc/strscan/methods/get_byte.md
@@ -0,0 +1,27 @@
+Returns the next byte, if available:
+
+- If the [position][2]
+ is not at the end of the [stored string][1]:
+
+ - Returns the next byte.
+ - Increments the [byte position][2].
+ - Adjusts the [character position][7].
+
+ ```rb
+ scanner = StringScanner.new(HIRAGANA_TEXT)
+ # => #<StringScanner 0/15 @ "\xE3\x81\x93\xE3\x82...">
+ scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\xE3", 1, 1]
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\x81", 2, 2]
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\x93", 3, 1]
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\xE3", 4, 2]
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\x82", 5, 3]
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => ["\x93", 6, 2]
+ ```
+
+- Otherwise, returns `nil`, and does not change the positions.
+
+ ```rb
+ scanner.terminate
+ [scanner.get_byte, scanner.pos, scanner.charpos] # => [nil, 15, 5]
+ ```
diff --git a/doc/strscan/methods/get_charpos.md b/doc/strscan/methods/get_charpos.md
new file mode 100644
index 0000000000..4de07897dc
--- /dev/null
+++ b/doc/strscan/methods/get_charpos.md
@@ -0,0 +1,16 @@
+Returns the [character position][7] (initially zero),
+which may be different from the [byte position][2]
+given by method #pos:
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.getch # => "ã“" # 3-byte character.
+scanner.getch # => "ã‚“" # 3-byte character.
+put_situation(scanner)
+# Situation:
+# pos: 6
+# charpos: 2
+# rest: "ã«ã¡ã¯"
+# rest_size: 9
+```
diff --git a/doc/strscan/methods/get_pos.md b/doc/strscan/methods/get_pos.md
new file mode 100644
index 0000000000..56b1636812
--- /dev/null
+++ b/doc/strscan/methods/get_pos.md
@@ -0,0 +1,11 @@
+Returns the integer [byte position][2],
+which may be different from the [character position][7]:
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos # => 0
+scanner.getch # => "ã“" # 3-byte character.
+scanner.charpos # => 1
+scanner.pos # => 3
+```
diff --git a/doc/strscan/methods/getch.md b/doc/strscan/methods/getch.md
new file mode 100644
index 0000000000..ede1d2b071
--- /dev/null
+++ b/doc/strscan/methods/getch.md
@@ -0,0 +1,40 @@
+Returns the next (possibly multibyte) character,
+if available:
+
+- If the [position][2]
+ is at the beginning of a character:
+
+ - Returns the character.
+ - Increments the [character position][7] by 1.
+ - Increments the [byte position][2]
+ by the size (in bytes) of the character.
+
+ ```rb
+ scanner = StringScanner.new(HIRAGANA_TEXT)
+ scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã“", 3, 1]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã‚“", 6, 2]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã«", 9, 3]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã¡", 12, 4]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã¯", 15, 5]
+ [scanner.getch, scanner.pos, scanner.charpos] # => [nil, 15, 5]
+ ```
+
+- If the [position][2] is within a multi-byte character
+ (that is, not at its beginning),
+ behaves like #get_byte (returns a 1-byte character):
+
+ ```rb
+ scanner.pos = 1
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["\x81", 2, 2]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["\x93", 3, 1]
+ [scanner.getch, scanner.pos, scanner.charpos] # => ["ã‚“", 6, 2]
+ ```
+
+- If the [position][2] is at the end of the [stored string][1],
+ returns `nil` and does not modify the positions:
+
+ ```rb
+ scanner.terminate
+ [scanner.getch, scanner.pos, scanner.charpos] # => [nil, 15, 5]
+ ```
diff --git a/doc/strscan/methods/scan.md b/doc/strscan/methods/scan.md
new file mode 100644
index 0000000000..805c797913
--- /dev/null
+++ b/doc/strscan/methods/scan.md
@@ -0,0 +1,48 @@
+Attempts to [match][17] the given `pattern`
+at the beginning of the [target substring][3].
+
+If the match succeeds:
+
+- Returns the matched substring.
+- Increments the [byte position][2] by <tt>substring.bytesize</tt>,
+ and may increment the [character position][7].
+- Sets [match values][9].
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos = 6
+scanner.scan(/ã«/) # => "ã«"
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 3
+# pre_match: "ã“ã‚“"
+# matched : "ã«"
+# post_match: "ã¡ã¯"
+# Captured match values:
+# size: 1
+# captures: []
+# named_captures: {}
+# values_at: ["ã«", nil]
+# []:
+# [0]: "ã«"
+# [1]: nil
+put_situation(scanner)
+# Situation:
+# pos: 9
+# charpos: 3
+# rest: "ã¡ã¯"
+# rest_size: 6
+```
+
+If the match fails:
+
+- Returns `nil`.
+- Does not increment byte and character positions.
+- Clears match values.
+
+```rb
+scanner.scan(/nope/) # => nil
+match_values_cleared?(scanner) # => true
+```
diff --git a/doc/strscan/methods/scan_until.md b/doc/strscan/methods/scan_until.md
new file mode 100644
index 0000000000..5fb2912a1b
--- /dev/null
+++ b/doc/strscan/methods/scan_until.md
@@ -0,0 +1,49 @@
+Attempts to [match][17] the given `pattern`
+anywhere (at any [position][2]) in the [target substring][3].
+
+If the match attempt succeeds:
+
+- Sets [match values][9].
+- Sets the [byte position][2] to the end of the matched substring;
+ may adjust the [character position][7].
+- Returns the matched substring.
+
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos = 6
+scanner.scan_until(/ã¡/) # => "ã«ã¡"
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 3
+# pre_match: "ã“ã‚“ã«"
+# matched : "ã¡"
+# post_match: "ã¯"
+# Captured match values:
+# size: 1
+# captures: []
+# named_captures: {}
+# values_at: ["ã¡", nil]
+# []:
+# [0]: "ã¡"
+# [1]: nil
+put_situation(scanner)
+# Situation:
+# pos: 12
+# charpos: 4
+# rest: "ã¯"
+# rest_size: 3
+```
+
+If the match attempt fails:
+
+- Clears match data.
+- Returns `nil`.
+- Does not update positions.
+
+```rb
+scanner.scan_until(/nope/) # => nil
+match_values_cleared?(scanner) # => true
+```
diff --git a/doc/strscan/methods/set_pos.md b/doc/strscan/methods/set_pos.md
new file mode 100644
index 0000000000..6a43edeb41
--- /dev/null
+++ b/doc/strscan/methods/set_pos.md
@@ -0,0 +1,23 @@
+Sets the [byte position][2] and the [character position][11];
+returns `n`.
+
+Does not affect [match values][9].
+
+For non-negative `n`, sets the position to `n`:
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos = 3 # => 3
+scanner.rest # => "ã‚“ã«ã¡ã¯"
+scanner.charpos # => 1
+```
+
+For negative `n`, counts from the end of the [stored string][1]:
+
+```rb
+scanner.pos = -9 # => -9
+scanner.pos # => 6
+scanner.rest # => "ã«ã¡ã¯"
+scanner.charpos # => 2
+```
diff --git a/doc/strscan/methods/skip.md b/doc/strscan/methods/skip.md
new file mode 100644
index 0000000000..7e924b624b
--- /dev/null
+++ b/doc/strscan/methods/skip.md
@@ -0,0 +1,40 @@
+Attempts to [match][17] the given `pattern`
+at the beginning of the [target substring][3];
+
+If the match succeeds:
+
+- Increments the [byte position][2] by substring.bytesize,
+ and may increment the [character position][7].
+- Sets [match values][9].
+- Returns the size (bytes) of the matched substring.
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos = 6
+scanner.skip(/ã«/) # => 3
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 3
+# pre_match: "ã“ã‚“"
+# matched : "ã«"
+# post_match: "ã¡ã¯"
+# Captured match values:
+# size: 1
+# captures: []
+# named_captures: {}
+# values_at: ["ã«", nil]
+# []:
+# [0]: "ã«"
+# [1]: nil
+put_situation(scanner)
+# Situation:
+# pos: 9
+# charpos: 3
+# rest: "ã¡ã¯"
+# rest_size: 6
+
+scanner.skip(/nope/) # => nil
+match_values_cleared?(scanner) # => true
+```
diff --git a/doc/strscan/methods/skip_until.md b/doc/strscan/methods/skip_until.md
new file mode 100644
index 0000000000..a0ffab0b84
--- /dev/null
+++ b/doc/strscan/methods/skip_until.md
@@ -0,0 +1,48 @@
+Attempts to [match][17] the given `pattern`
+anywhere (at any [position][2]) in the [target substring][3].
+
+If the match attempt succeeds:
+
+- Sets [match values][9].
+- Sets the [byte position][2] to the end of the matched substring;
+ may adjust the [character position][7].
+- Returns the size of the matched substring.
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.pos = 6
+scanner.skip_until(/ã¡/) # => 6
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 3
+# pre_match: "ã“ã‚“ã«"
+# matched : "ã¡"
+# post_match: "ã¯"
+# Captured match values:
+# size: 1
+# captures: []
+# named_captures: {}
+# values_at: ["ã¡", nil]
+# []:
+# [0]: "ã¡"
+# [1]: nil
+put_situation(scanner)
+# Situation:
+# pos: 12
+# charpos: 4
+# rest: "ã¯"
+# rest_size: 3
+```
+
+If the match attempt fails:
+
+- Clears match values.
+- Returns `nil`.
+- Does not update positions.
+
+```rb
+scanner.skip_until(/nope/) # => nil
+match_values_cleared?(scanner) # => true
+```
diff --git a/doc/strscan/methods/terminate.md b/doc/strscan/methods/terminate.md
new file mode 100644
index 0000000000..27f7d41cb1
--- /dev/null
+++ b/doc/strscan/methods/terminate.md
@@ -0,0 +1,27 @@
+Sets the scanner to end-of-string;
+returns +self+:
+
+- Sets both [positions][11] to end-of-stream.
+- Clears [match values][9].
+
+```rb
+scanner = StringScanner.new(HIRAGANA_TEXT)
+scanner.string # => "ã“ã‚“ã«ã¡ã¯"
+scanner.scan_until(/ã«/)
+put_situation(scanner)
+# Situation:
+# pos: 9
+# charpos: 3
+# rest: "ã¡ã¯"
+# rest_size: 6
+match_values_cleared?(scanner) # => false
+
+scanner.terminate # => #<StringScanner fin>
+put_situation(scanner)
+# Situation:
+# pos: 15
+# charpos: 5
+# rest: ""
+# rest_size: 0
+match_values_cleared?(scanner) # => true
+```
diff --git a/doc/strscan/strscan.md b/doc/strscan/strscan.md
new file mode 100644
index 0000000000..bbdeccd75e
--- /dev/null
+++ b/doc/strscan/strscan.md
@@ -0,0 +1,544 @@
+\Class `StringScanner` supports processing a stored string as a stream;
+this code creates a new `StringScanner` object with string `'foobarbaz'`:
+
+```rb
+require 'strscan'
+scanner = StringScanner.new('foobarbaz')
+```
+
+## About the Examples
+
+All examples here assume that `StringScanner` has been required:
+
+```rb
+require 'strscan'
+```
+
+Some examples here assume that these constants are defined:
+
+```rb
+MULTILINE_TEXT = <<~EOT
+Go placidly amid the noise and haste,
+and remember what peace there may be in silence.
+EOT
+
+HIRAGANA_TEXT = 'ã“ã‚“ã«ã¡ã¯'
+
+ENGLISH_TEXT = 'Hello'
+```
+
+Some examples here assume that certain helper methods are defined:
+
+- `put_situation(scanner)`:
+ Displays the values of the scanner's
+ methods #pos, #charpos, #rest, and #rest_size.
+- `put_match_values(scanner)`:
+ Displays the scanner's [match values][9].
+- `match_values_cleared?(scanner)`:
+ Returns whether the scanner's [match values][9] are cleared.
+
+See examples at [helper methods](doc/strscan/helper_methods.md).
+
+## The `StringScanner` \Object
+
+This code creates a `StringScanner` object
+(we'll call it simply a _scanner_),
+and shows some of its basic properties:
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+scanner.string # => "foobarbaz"
+put_situation(scanner)
+# Situation:
+# pos: 0
+# charpos: 0
+# rest: "foobarbaz"
+# rest_size: 9
+```
+
+The scanner has:
+
+* A <i>stored string</i>, which is:
+
+ * Initially set by StringScanner.new(string) to the given `string`
+ (`'foobarbaz'` in the example above).
+ * Modifiable by methods #string=(new_string) and #concat(more_string).
+ * Returned by method #string.
+
+ More at [Stored String][1] below.
+
+* A _position_;
+ a zero-based index into the bytes of the stored string (_not_ into its characters):
+
+ * Initially set by StringScanner.new to `0`.
+ * Returned by method #pos.
+ * Modifiable explicitly by methods #reset, #terminate, and #pos=(new_pos).
+ * Modifiable implicitly (various traversing methods, among others).
+
+ More at [Byte Position][2] below.
+
+* A <i>target substring</i>,
+ which is a trailing substring of the stored string;
+ it extends from the current position to the end of the stored string:
+
+ * Initially set by StringScanner.new(string) to the given `string`
+ (`'foobarbaz'` in the example above).
+ * Returned by method #rest.
+ * Modified by any modification to either the stored string or the position.
+
+ <b>Most importantly</b>:
+ the searching and traversing methods operate on the target substring,
+ which may be (and often is) less than the entire stored string.
+
+ More at [Target Substring][3] below.
+
+## Stored \String
+
+The <i>stored string</i> is the string stored in the `StringScanner` object.
+
+Each of these methods sets, modifies, or returns the stored string:
+
+| Method | Effect |
+|----------------------|-------------------------------------------------|
+| ::new(string) | Creates a new scanner for the given string. |
+| #string=(new_string) | Replaces the existing stored string. |
+| #concat(more_string) | Appends a string to the existing stored string. |
+| #string | Returns the stored string. |
+
+## Positions
+
+A `StringScanner` object maintains a zero-based <i>byte position</i>
+and a zero-based <i>character position</i>.
+
+Each of these methods explicitly sets positions:
+
+| Method | Effect |
+|--------------------------|-----------------------------------------------------------|
+| #reset | Sets both positions to zero (beginning of stored string). |
+| #terminate | Sets both positions to the end of the stored string. |
+| #pos=(new_byte_position) | Sets byte position; adjusts character position. |
+
+### Byte Position (Position)
+
+The byte position (or simply _position_)
+is a zero-based index into the bytes in the scanner's stored string;
+for a new `StringScanner` object, the byte position is zero.
+
+When the byte position is:
+
+* Zero (at the beginning), the target substring is the entire stored string.
+* Equal to the size of the stored string (at the end),
+ the target substring is the empty string `''`.
+
+To get or set the byte position:
+
+* \#pos: returns the byte position.
+* \#pos=(new_pos): sets the byte position.
+
+Many methods use the byte position as the basis for finding matches;
+many others set, increment, or decrement the byte position:
+
+```rb
+scanner = StringScanner.new('foobar')
+scanner.pos # => 0
+scanner.scan(/foo/) # => "foo" # Match found.
+scanner.pos # => 3 # Byte position incremented.
+scanner.scan(/foo/) # => nil # Match not found.
+scanner.pos # => 3 # Byte position not changed.
+```
+
+Some methods implicitly modify the byte position;
+see:
+
+* [Setting the Target Substring][4].
+* [Traversing the Target Substring][5].
+
+The values of these methods are derived directly from the values of #pos and #string:
+
+- \#charpos: the [character position][7].
+- \#rest: the [target substring][3].
+- \#rest_size: `rest.size`.
+
+### Character Position
+
+The character position is a zero-based index into the _characters_
+in the stored string;
+for a new `StringScanner` object, the character position is zero.
+
+\Method #charpos returns the character position;
+its value may not be reset explicitly.
+
+Some methods change (increment or reset) the character position;
+see:
+
+* [Setting the Target Substring][4].
+* [Traversing the Target Substring][5].
+
+Example (string includes multi-byte characters):
+
+```rb
+scanner = StringScanner.new(ENGLISH_TEXT) # Five 1-byte characters.
+scanner.concat(HIRAGANA_TEXT) # Five 3-byte characters
+scanner.string # => "Helloã“ã‚“ã«ã¡ã¯" # Twenty bytes in all.
+put_situation(scanner)
+# Situation:
+# pos: 0
+# charpos: 0
+# rest: "Helloã“ã‚“ã«ã¡ã¯"
+# rest_size: 20
+scanner.scan(/Hello/) # => "Hello" # Five 1-byte characters.
+put_situation(scanner)
+# Situation:
+# pos: 5
+# charpos: 5
+# rest: "ã“ã‚“ã«ã¡ã¯"
+# rest_size: 15
+scanner.getch # => "ã“" # One 3-byte character.
+put_situation(scanner)
+# Situation:
+# pos: 8
+# charpos: 6
+# rest: "ã‚“ã«ã¡ã¯"
+# rest_size: 12
+```
+
+## Target Substring
+
+The target substring is the part of the [stored string][1]
+that extends from the current [byte position][2] to the end of the stored string;
+it is always either:
+
+- The entire stored string (byte position is zero).
+- A trailing substring of the stored string (byte position positive).
+
+The target substring is returned by method #rest,
+and its size is returned by method #rest_size.
+
+Examples:
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+put_situation(scanner)
+# Situation:
+# pos: 0
+# charpos: 0
+# rest: "foobarbaz"
+# rest_size: 9
+scanner.pos = 3
+put_situation(scanner)
+# Situation:
+# pos: 3
+# charpos: 3
+# rest: "barbaz"
+# rest_size: 6
+scanner.pos = 9
+put_situation(scanner)
+# Situation:
+# pos: 9
+# charpos: 9
+# rest: ""
+# rest_size: 0
+```
+
+### Setting the Target Substring
+
+The target substring is set whenever:
+
+* The [stored string][1] is set (position reset to zero; target substring set to stored string).
+* The [byte position][2] is set (target substring adjusted accordingly).
+
+### Querying the Target Substring
+
+This table summarizes (details and examples at the links):
+
+| Method | Returns |
+|------------|-----------------------------------|
+| #rest | Target substring. |
+| #rest_size | Size (bytes) of target substring. |
+
+### Searching the Target Substring
+
+A _search_ method examines the target substring,
+but does not advance the [positions][11]
+or (by implication) shorten the target substring.
+
+This table summarizes (details and examples at the links):
+
+| Method | Returns | Sets Match Values? |
+|-----------------------|-----------------------------------------------|--------------------|
+| #check(pattern) | Matched leading substring or +nil+. | Yes. |
+| #check_until(pattern) | Matched substring (anywhere) or +nil+. | Yes. |
+| #exist?(pattern) | Matched substring (anywhere) end index. | Yes. |
+| #match?(pattern) | Size of matched leading substring or +nil+. | Yes. |
+| #peek(size) | Leading substring of given length (bytes). | No. |
+| #peek_byte | Integer leading byte or +nil+. | No. |
+| #rest | Target substring (from byte position to end). | No. |
+
+### Traversing the Target Substring
+
+A _traversal_ method examines the target substring,
+and, if successful:
+
+- Advances the [positions][11].
+- Shortens the target substring.
+
+
+This table summarizes (details and examples at links):
+
+| Method | Returns | Sets Match Values? |
+|----------------------|------------------------------------------------------|--------------------|
+| #get_byte | Leading byte or +nil+. | No. |
+| #getch | Leading character or +nil+. | No. |
+| #scan(pattern) | Matched leading substring or +nil+. | Yes. |
+| #scan_byte | Integer leading byte or +nil+. | No. |
+| #scan_until(pattern) | Matched substring (anywhere) or +nil+. | Yes. |
+| #skip(pattern) | Matched leading substring size or +nil+. | Yes. |
+| #skip_until(pattern) | Position delta to end-of-matched-substring or +nil+. | Yes. |
+| #unscan | +self+. | No. |
+
+## Querying the Scanner
+
+Each of these methods queries the scanner object
+without modifying it (details and examples at links)
+
+| Method | Returns |
+|---------------------|----------------------------------|
+| #beginning_of_line? | +true+ or +false+. |
+| #charpos | Character position. |
+| #eos? | +true+ or +false+. |
+| #fixed_anchor? | +true+ or +false+. |
+| #inspect | String representation of +self+. |
+| #pos | Byte position. |
+| #rest | Target substring. |
+| #rest_size | Size of target substring. |
+| #string | Stored string. |
+
+## Matching
+
+`StringScanner` implements pattern matching via Ruby class [Regexp][6],
+and its matching behaviors are the same as Ruby's
+except for the [fixed-anchor property][10].
+
+### Matcher Methods
+
+Each <i>matcher method</i> takes a single argument `pattern`,
+and attempts to find a matching substring in the [target substring][3].
+
+| Method | Pattern Type | Matches Target Substring | Success Return | May Update Positions? |
+|--------------|-------------------|--------------------------|--------------------|-----------------------|
+| #check | Regexp or String. | At beginning. | Matched substring. | No. |
+| #check_until | Regexp or String. | Anywhere. | Substring. | No. |
+| #match? | Regexp or String. | At beginning. | Match size. | No. |
+| #exist? | Regexp or String. | Anywhere. | Substring size. | No. |
+| #scan | Regexp or String. | At beginning. | Matched substring. | Yes. |
+| #scan_until | Regexp or String. | Anywhere. | Substring. | Yes. |
+| #skip | Regexp or String. | At beginning. | Match size. | Yes. |
+| #skip_until | Regexp or String. | Anywhere. | Substring size. | Yes. |
+
+<br>
+
+Which matcher you choose will depend on:
+
+- Where you want to find a match:
+
+ - Only at the beginning of the target substring:
+ #check, #match?, #scan, #skip.
+ - Anywhere in the target substring:
+ #check_until, #exist?, #scan_until, #skip_until.
+
+- Whether you want to:
+
+ - Traverse, by advancing the positions:
+ #scan, #scan_until, #skip, #skip_until.
+ - Keep the positions unchanged:
+ #check, #check_until, #match?, #exist?.
+
+- What you want for the return value:
+
+ - The matched substring: #check, #scan.
+ - The substring: #check_until, #scan_until.
+ - The match size: #match?, #skip.
+ - The substring size: #exist?, #skip_until.
+
+### Match Values
+
+The <i>match values</i> in a `StringScanner` object
+generally contain the results of the most recent attempted match.
+
+Each match value may be thought of as:
+
+* _Clear_: Initially, or after an unsuccessful match attempt:
+ usually, `false`, `nil`, or `{}`.
+* _Set_: After a successful match attempt:
+ `true`, string, array, or hash.
+
+Each of these methods clears match values:
+
+- ::new(string).
+- \#reset.
+- \#terminate.
+
+Each of these methods attempts a match based on a pattern,
+and either sets match values (if successful) or clears them (if not);
+
+- \#check(pattern)
+- \#check_until(pattern)
+- \#exist?(pattern)
+- \#match?(pattern)
+- \#scan(pattern)
+- \#scan_until(pattern)
+- \#skip(pattern)
+- \#skip_until(pattern)
+
+#### Basic Match Values
+
+Basic match values are those not related to captures.
+
+Each of these methods returns a basic match value:
+
+| Method | Return After Match | Return After No Match |
+|-----------------|----------------------------------------|-----------------------|
+| #matched? | +true+. | +false+. |
+| #matched_size | Size of matched substring. | +nil+. |
+| #matched | Matched substring. | +nil+. |
+| #pre_match | Substring preceding matched substring. | +nil+. |
+| #post_match | Substring following matched substring. | +nil+. |
+
+<br>
+
+See examples below.
+
+#### Captured Match Values
+
+Captured match values are those related to [captures][16].
+
+Each of these methods returns a captured match value:
+
+| Method | Return After Match | Return After No Match |
+|-----------------|-----------------------------------------|-----------------------|
+| #size | Count of captured substrings. | +nil+. |
+| #\[\](n) | <tt>n</tt>th captured substring. | +nil+. |
+| #captures | Array of all captured substrings. | +nil+. |
+| #values_at(*n) | Array of specified captured substrings. | +nil+. |
+| #named_captures | Hash of named captures. | <tt>{}</tt>. |
+
+<br>
+
+See examples below.
+
+#### Match Values Examples
+
+Successful basic match attempt (no captures):
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+scanner.exist?(/bar/)
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 3
+# pre_match: "foo"
+# matched : "bar"
+# post_match: "baz"
+# Captured match values:
+# size: 1
+# captures: []
+# named_captures: {}
+# values_at: ["bar", nil]
+# []:
+# [0]: "bar"
+# [1]: nil
+```
+
+Failed basic match attempt (no captures);
+
+```rb
+scanner = StringScanner.new('foobarbaz')
+scanner.exist?(/nope/)
+match_values_cleared?(scanner) # => true
+```
+
+Successful unnamed capture match attempt:
+
+```rb
+scanner = StringScanner.new('foobarbazbatbam')
+scanner.exist?(/(foo)bar(baz)bat(bam)/)
+put_match_values(scanner)
+# Basic match values:
+# matched?: true
+# matched_size: 15
+# pre_match: ""
+# matched : "foobarbazbatbam"
+# post_match: ""
+# Captured match values:
+# size: 4
+# captures: ["foo", "baz", "bam"]
+# named_captures: {}
+# values_at: ["foobarbazbatbam", "foo", "baz", "bam", nil]
+# []:
+# [0]: "foobarbazbatbam"
+# [1]: "foo"
+# [2]: "baz"
+# [3]: "bam"
+# [4]: nil
+```
+
+Successful named capture match attempt;
+same as unnamed above, except for #named_captures:
+
+```rb
+scanner = StringScanner.new('foobarbazbatbam')
+scanner.exist?(/(?<x>foo)bar(?<y>baz)bat(?<z>bam)/)
+scanner.named_captures # => {"x"=>"foo", "y"=>"baz", "z"=>"bam"}
+```
+
+Failed unnamed capture match attempt:
+
+```rb
+scanner = StringScanner.new('somestring')
+scanner.exist?(/(foo)bar(baz)bat(bam)/)
+match_values_cleared?(scanner) # => true
+```
+
+Failed named capture match attempt;
+same as unnamed above, except for #named_captures:
+
+```rb
+scanner = StringScanner.new('somestring')
+scanner.exist?(/(?<x>foo)bar(?<y>baz)bat(?<z>bam)/)
+match_values_cleared?(scanner) # => false
+scanner.named_captures # => {"x"=>nil, "y"=>nil, "z"=>nil}
+```
+
+## Fixed-Anchor Property
+
+Pattern matching in `StringScanner` is the same as in Ruby's,
+except for its fixed-anchor property,
+which determines the meaning of `'\A'`:
+
+* `false` (the default): matches the current byte position.
+
+ ```rb
+ scanner = StringScanner.new('foobar')
+ scanner.scan(/\A./) # => "f"
+ scanner.scan(/\A./) # => "o"
+ scanner.scan(/\A./) # => "o"
+ scanner.scan(/\A./) # => "b"
+ ```
+
+* `true`: matches the beginning of the target substring;
+ never matches unless the byte position is zero:
+
+ ```rb
+ scanner = StringScanner.new('foobar', fixed_anchor: true)
+ scanner.scan(/\A./) # => "f"
+ scanner.scan(/\A./) # => nil
+ scanner.reset
+ scanner.scan(/\A./) # => "f"
+ ```
+
+The fixed-anchor property is set when the `StringScanner` object is created,
+and may not be modified
+(see StringScanner.new);
+method #fixed_anchor? returns the setting.
+
diff --git a/doc/syntax.rdoc b/doc/syntax.rdoc
index 5895673f36..a48c83ff15 100644
--- a/doc/syntax.rdoc
+++ b/doc/syntax.rdoc
@@ -2,6 +2,9 @@
The Ruby syntax is large and is split up into the following sections:
+{Code Layout}[rdoc-ref:syntax/layout.rdoc] ::
+ Breaking code in lines
+
Literals[rdoc-ref:syntax/literals.rdoc] ::
Numbers, Strings, Arrays, Hashes, etc.
@@ -12,7 +15,7 @@ Assignment[rdoc-ref:syntax/assignment.rdoc] ::
+if+, +unless+, +while+, +until+, +for+, +break+, +next+, +redo+
{Pattern matching}[rdoc-ref:syntax/pattern_matching.rdoc] ::
- Experimental structural pattern matching and variable binding syntax
+ Structural pattern matching and variable binding syntax
Methods[rdoc-ref:syntax/methods.rdoc] ::
Method and method argument syntax
@@ -37,3 +40,6 @@ Miscellaneous[rdoc-ref:syntax/miscellaneous.rdoc] ::
Comments[rdoc-ref:syntax/comments.rdoc] ::
Line and block code comments
+
+Operators[rdoc-ref:syntax/operators.rdoc] ::
+ Operator method behaviors
diff --git a/doc/syntax/assignment.rdoc b/doc/syntax/assignment.rdoc
index e30cb35adf..3988f82e5f 100644
--- a/doc/syntax/assignment.rdoc
+++ b/doc/syntax/assignment.rdoc
@@ -9,7 +9,7 @@ Assignment creates a local variable if the variable was not previously
referenced.
An assignment expression result is always the assigned value, including
-{assignment methods}[rdoc-ref:syntax/assignment.rdoc@Assignment+Methods].
+{assignment methods}[rdoc-ref:@Assignment+Methods].
== Local Variable Names
@@ -162,9 +162,7 @@ Here is an example of instance variable usage:
p object1.value # prints "some value"
p object2.value # prints "other value"
-An uninitialized instance variable has a value of +nil+. If you run Ruby with
-warnings enabled, you will get a warning when accessing an uninitialized
-instance variable.
+An uninitialized instance variable has a value of +nil+.
The +value+ method has access to the value set by the +initialize+ method, but
only for the same object.
@@ -281,7 +279,7 @@ An uninitialized global variable has a value of +nil+.
Ruby has some special globals that behave differently depending on context
such as the regular expression match variables or that have a side-effect when
-assigned to. See the {global variables documentation}[rdoc-ref:globals.rdoc]
+assigned to. See the {global variables documentation}[rdoc-ref:language/globals.md]
for details.
== Assignment Methods
diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc
index da061dbfdb..a24c5fbf1f 100644
--- a/doc/syntax/calling_methods.rdoc
+++ b/doc/syntax/calling_methods.rdoc
@@ -30,7 +30,7 @@ NoMethodError.
You may also use <code>::</code> to designate a receiver, but this is rarely
used due to the potential for confusion with <code>::</code> for namespaces.
-=== Chaining \Method Calls
+=== Chaining Method Calls
You can "chain" method calls by immediately following one method call with another.
@@ -210,7 +210,7 @@ definition. If a keyword argument is given that the method did not list,
and the method definition does not accept arbitrary keyword arguments, an
ArgumentError will be raised.
-Keyword argument value can be omitted, meaning the value will be be fetched
+Keyword argument value can be omitted, meaning the value will be fetched
from the context by the name of the key
keyword1 = 'some value'
@@ -291,16 +291,16 @@ override local arguments outside the block in the caller's scope:
This prints:
hello main this is block
- place is world
+ place is: world
So the +place+ variable in the block is not the same +place+ variable as
outside the block. Removing <code>; place</code> from the block arguments
gives this result:
hello main this is block
- place is block
+ place is: block
-=== Array to Arguments Conversion
+=== Unpacking Positional Arguments
Given the following method:
@@ -322,17 +322,58 @@ Both are equivalent to:
my_method(1, 2, 3)
-If the method accepts keyword arguments, the splat operator will convert a
-hash at the end of the array into keyword arguments:
+The <code>*</code> unpacking operator can be applied to any object, not only
+arrays. If the object responds to a <code>#to_a</code> method, this method
+is called, and is expected to return an Array, and elements of this array are passed
+as separate positional arguments:
- def my_method(a, b, c: 3)
+ class Name
+ def initialize(name)
+ @name = name
+ end
+
+ def to_a = @name.split(' ')
end
- arguments = [1, 2, { c: 4 }]
- my_method(*arguments)
+ name = Name.new('Jane Doe')
+ p(*name)
+ # prints separate values:
+ # Jane
+ # Doe
+
+If the object doesn't have a <code>#to_a</code> method, the object itself is passed
+as one argument:
+
+ class Name
+ def initialize(name)
+ @name = name
+ end
+ end
+
+ name = Name.new('Jane Doe')
+ p(*name)
+ # Prints the object itself:
+ # #<Name:0x00007f9d07bca650 @name="Jane Doe">
-Note that this behavior is currently deprecated and will emit a warning.
-This behavior will be removed in Ruby 3.0.
+This allows to handle one or many arguments polymorphically. Note also that <tt>*nil</tt>
+is unpacked to an empty list of arguments, so conditional unpacking is possible:
+
+ my_method(*(some_arguments if some_condition?))
+
+If <code>#to_a</code> method exists and does not return an Array, it would be an
+error on unpacking:
+
+ class Name
+ def initialize(name)
+ @name = name
+ end
+
+ def to_a = @name
+ end
+
+ name = Name.new('Jane Doe')
+ p(*name)
+ # can't convert Name to Array (Name#to_a gives String) (TypeError)
You may also use the <code>**</code> (described next) to convert a Hash into
keyword arguments.
@@ -341,12 +382,13 @@ If the number of objects in the Array do not match the number of arguments for
the method, an ArgumentError will be raised.
If the splat operator comes first in the call, parentheses must be used to
-avoid a warning:
+avoid an ambiguity of interpretation as an unpacking operator or multiplication
+operator. In this case, Ruby issues a warning in verbose mode:
- my_method *arguments # warning
+ my_method *arguments # warning: '*' interpreted as argument prefix
my_method(*arguments) # no warning
-=== Hash to Keyword Arguments Conversion
+=== Unpacking Keyword Arguments
Given the following method:
@@ -368,6 +410,35 @@ Both are equivalent to:
my_method(first: 3, second: 4, third: 5)
+The <code>**</code> unpacking operator can be applied to any object, not only
+hashes. If the object responds to a <code>#to_hash</code> method, this method
+is called, and is expected to return an Hash, and elements of this hash are passed
+as keyword arguments:
+
+ class Name
+ def initialize(name)
+ @name = name
+ end
+
+ def to_hash = {first: @name.split(' ').first, last: @name.split(' ').last}
+ end
+
+ name = Name.new('Jane Doe')
+ p(**name)
+ # Prints: {first: "Jane", last: "Doe"}
+
+Unlike <code>*</code> operator, <code>**</code> raises an error when used on an
+object that doesn't respond to <code>#to_hash</code>. The one exception is
++nil+, which doesn't explicitly define this method, but is still allowed to
+be used in <code>**</code> unpacking, not adding any keyword arguments.
+
+Again, this allows for conditional unpacking:
+
+ my_method(some: params, **(some_extra_params if pass_extra_params?))
+
+Like <code>*</code> operator, <code>**</code> raises an error when the object responds
+to <code>#to_hash</code>, but it doesn't return a Hash.
+
If the method definition uses the keyword splat operator to
gather arbitrary keyword arguments, they will not be gathered
by <code>*</code>:
diff --git a/doc/syntax/comments.rdoc b/doc/syntax/comments.rdoc
index dbc7816984..cb6829a984 100644
--- a/doc/syntax/comments.rdoc
+++ b/doc/syntax/comments.rdoc
@@ -170,7 +170,7 @@ In this mode, all values assigned to constants are made shareable.
# shareable_constant_value: experimental_everything
FOO = Set[1, 2, {foo: []}]
- # same as FOO = Ractor.make_sharable(...)
+ # same as FOO = Ractor.make_shareable(...)
# OR same as `FOO = Set[1, 2, {foo: [].freeze}.freeze].freeze`
var = [{foo: []}]
@@ -196,7 +196,7 @@ The method Module#const_set is not affected.
In this mode, all values assigned to constants are deeply copied and
made shareable. It is safer mode than +experimental_everything+.
- # shareable_constant_value: experimental_everything
+ # shareable_constant_value: experimental_copy
var = [{foo: []}]
var.frozen? # => false (assignment was made to local variable)
X = var # => calls `Ractor.make_shareable(var, copy: true)`
diff --git a/doc/syntax/control_expressions.rdoc b/doc/syntax/control_expressions.rdoc
index df3b5ced38..3de6cd293f 100644
--- a/doc/syntax/control_expressions.rdoc
+++ b/doc/syntax/control_expressions.rdoc
@@ -189,7 +189,7 @@ The same is true for +unless+.
The +case+ expression can be used in two ways.
The most common way is to compare an object against multiple patterns. The
-patterns are matched using the +===+ method which is aliased to +==+ on
+patterns are matched using the <tt>===</tt> method which is aliased to <tt>==</tt> on
Object. Other classes must override it to give meaningful behavior. See
Module#=== and Regexp#=== for examples.
@@ -255,7 +255,7 @@ Again, the +then+ and +else+ are optional.
The result value of a +case+ expression is the last value executed in the
expression.
-Since Ruby 2.7, +case+ expressions also provide a more powerful experimental
+Since Ruby 2.7, +case+ expressions also provide a more powerful
pattern matching feature via the +in+ keyword:
case {a: 1, b: 2, c: 3}
@@ -569,3 +569,71 @@ evaluated on the following iteration:
Here, the flip-flop turns on when +value+ equals 2, but doesn't turn off on the
same iteration. The `off' condition isn't evaluated until the following
iteration and +value+ will never be two again.
+
+== throw/catch
+
++throw+ and +catch+ are used to implement non-local control flow in Ruby. They
+operate similarly to exceptions, allowing control to pass directly from the
+place where +throw+ is called to the place where the matching +catch+ is
+called. The main difference between +throw+/+catch+ and the use of exceptions
+is that +throw+/+catch+ are designed for expected non-local control flow,
+while exceptions are designed for exceptional control flow situations, such
+as handling unexpected errors.
+
+When using +throw+, you provide 1-2 arguments. The first argument is the
+value for the matching +catch+. The second argument is optional (defaults to
++nil+), and will be the value that +catch+ returns if there is a matching
++throw+ inside the +catch+ block. If no matching +throw+ method is called
+inside a +catch+ block, the +catch+ method returns the return value of the
+block passed to it.
+
+ def a(n)
+ throw :d, :a if n == 0
+ b(n)
+ end
+
+ def b(n)
+ throw :d, :b if n == 1
+ c(n)
+ end
+
+ def c(n)
+ throw :d if n == 2
+ end
+
+ 4.times.map do |i|
+ catch(:d) do
+ a(i)
+ :default
+ end
+ end
+ # => [:a, :b, nil, :default]
+
+If the first argument you pass to +throw+ is not handled by a matching
++catch+, an UncaughtThrowError exception will be raised. This is because
++throw+/+catch+ should only be used for expected control flow changes, so
+using a value that is not already expected is an error.
+
++throw+/+catch+ are implemented as Kernel methods (Kernel#throw and
+Kernel#catch), not as keywords. So they are not usable directly if you are
+in a BasicObject context. You can use Kernel.throw and Kernel.catch in
+this case:
+
+ BasicObject.new.instance_exec do
+ def a
+ b
+ end
+
+ def b
+ c
+ end
+
+ def c
+ ::Kernel.throw :d, :e
+ end
+
+ result = ::Kernel.catch(:d) do
+ a
+ end
+ result # => :e
+ end
diff --git a/doc/syntax/exceptions.rdoc b/doc/syntax/exceptions.rdoc
index 31e2f0175c..cdf9d367a7 100644
--- a/doc/syntax/exceptions.rdoc
+++ b/doc/syntax/exceptions.rdoc
@@ -86,7 +86,7 @@ To always run some code whether an exception was raised or not, use +ensure+:
rescue
# ...
ensure
- # this always runs
+ # this always runs BUT does not implicitly return the last evaluated statement.
end
You may also run some code when an exception is not raised:
@@ -96,7 +96,11 @@ You may also run some code when an exception is not raised:
rescue
# ...
else
- # this runs only when no exception was raised
+ # this runs only when no exception was raised AND return the last evaluated statement
ensure
- # ...
+ # this always runs.
+ # It is evaluated after the evaluation of either the `rescue` or the `else` block.
+ # It will not return implicitly.
end
+
+NB : Without explicit +return+ in the +ensure+ block, +begin+/+end+ block will return the last evaluated statement before entering in the +ensure+ block.
diff --git a/doc/syntax/keywords.rdoc b/doc/syntax/keywords.rdoc
new file mode 100644
index 0000000000..7c368205ef
--- /dev/null
+++ b/doc/syntax/keywords.rdoc
@@ -0,0 +1,162 @@
+= Keywords
+
+The following keywords are used by Ruby.
+
+__ENCODING__::
+ The script encoding of the current file. See Encoding.
+
+__LINE__::
+ The line number of this keyword in the current file.
+
+__FILE__::
+ The path to the current file.
+
+BEGIN::
+ Runs before any other code in the current file. See {miscellaneous
+ syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
+
+END::
+ Runs after any other code in the current file. See {miscellaneous
+ syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
+
+alias::
+ Creates an alias between two methods (and other things). See {modules and
+ classes syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
+
+and::
+ Short-circuit Boolean and with lower precedence than <code>&&</code>
+
+begin::
+ Starts an exception handling block. See {exceptions
+ syntax}[rdoc-ref:syntax/exceptions.rdoc]
+
+break::
+ Leaves a block early. See {control expressions
+ syntax}[rdoc-ref:syntax/control_expressions.rdoc]
+
+case::
+ Starts a +case+ expression. See {control expressions
+ syntax}[rdoc-ref:syntax/control_expressions.rdoc]
+
+class::
+ Creates or opens a class. See {modules and classes
+ syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
+
+def::
+ Defines a method. See {methods syntax}[rdoc-ref:syntax/methods.rdoc]
+
+defined?::
+ Returns a string describing its argument. See {miscellaneous
+ syntax}[rdoc-ref:syntax/miscellaneous.rdoc]
+
+do::
+ Starts a block.
+
+else::
+ The unhandled condition in +case+, +if+ and +unless+ expressions. See
+ {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+elsif::
+ An alternate condition for an +if+ expression. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+end::
+ The end of a syntax block. Used by classes, modules, methods, exception
+ handling and control expressions.
+
+ensure::
+ Starts a section of code that is always run when an exception is raised.
+ See {exception handling}[rdoc-ref:syntax/exceptions.rdoc]
+
+false::
+ Boolean false. See {literals}[rdoc-ref:syntax/literals.rdoc]
+
+for::
+ A loop that is similar to using the +each+ method. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+if::
+ Used for +if+ and modifier +if+ statements. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+in::
+ Used to separate the iterable object and iterator variable in a +for+ loop.
+ See {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+ It also serves as a pattern in a +case+ expression.
+ See {pattern matching}[rdoc-ref:syntax/pattern_matching.rdoc]
+
+module::
+ Creates or opens a module. See {modules and classes
+ syntax}[rdoc-ref:syntax/modules_and_classes.rdoc]
+
+next::
+ Skips the rest of the block. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+nil::
+ A false value usually indicating "no value" or "unknown". See
+ {literals}[rdoc-ref:syntax/literals.rdoc]
+
+not::
+ Inverts the following boolean expression. Has a lower precedence than
+ <code>!</code>
+
+or::
+ Boolean or with lower precedence than <code>||</code>
+
+redo::
+ Restarts execution in the current block. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+rescue::
+ Starts an exception section of code in a +begin+ block. See {exception
+ handling}[rdoc-ref:syntax/exceptions.rdoc]
+
+retry::
+ Retries an exception block. See {exception
+ handling}[rdoc-ref:syntax/exceptions.rdoc]
+
+return::
+ Exits a method. See {methods}[rdoc-ref:syntax/methods.rdoc].
+ If met in top-level scope, immediately stops interpretation of
+ the current file.
+
+self::
+ The object the current method is attached to. See
+ {methods}[rdoc-ref:syntax/methods.rdoc]
+
+super::
+ Calls the current method in a superclass. See
+ {methods}[rdoc-ref:syntax/methods.rdoc]
+
+then::
+ Indicates the end of conditional blocks in control structures. See
+ {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+true::
+ Boolean true. See {literals}[rdoc-ref:syntax/literals.rdoc]
+
+undef::
+ Prevents a class or module from responding to a method call.
+ See {modules and classes}[rdoc-ref:syntax/modules_and_classes.rdoc]
+
+unless::
+ Used for +unless+ and modifier +unless+ statements. See {control
+ expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+until::
+ Creates a loop that executes until the condition is true. See
+ {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+when::
+ A condition in a +case+ expression. See
+ {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+while::
+ Creates a loop that executes while the condition is true. See
+ {control expressions}[rdoc-ref:syntax/control_expressions.rdoc]
+
+yield::
+ Starts execution of the block sent to the current method. See
+ {methods}[rdoc-ref:syntax/methods.rdoc]
+
diff --git a/doc/syntax/layout.rdoc b/doc/syntax/layout.rdoc
new file mode 100644
index 0000000000..31e51d9ff1
--- /dev/null
+++ b/doc/syntax/layout.rdoc
@@ -0,0 +1,118 @@
+= Code Layout
+
+Expressions in Ruby are separated by line breaks:
+
+ x = 1
+ y = 2
+ z = x + y
+
+Line breaks are also used as logical separators of the headers of some control structures from their bodies:
+
+ if z > 3 # line break ends the condition and starts the body
+ puts "more"
+ end
+
+ while x < 3 # line break ends the condition and starts the body
+ x += 1
+ end
+
+<tt>;</tt> can be used as an expressions separator instead of a line break:
+
+ x = 1; y = 2; z = x + y
+ if z > 3; puts "more"; end
+
+Traditionally, expressions separated by <tt>;</tt> are used only in short scripts and experiments.
+
+In some control structures, there is an optional keyword that can be used instead of a line break to separate their elements:
+
+ # if, elsif, until and case ... when: 'then' is an optional separator:
+
+ if z > 3 then puts "more" end
+
+ case x
+ when Numeric then "number"
+ when String then "string"
+ else "object"
+ end
+
+ # while and until: 'do' is an optional separator
+ while x < 3 do x +=1 end
+
+Also, line breaks can be skipped in some places where it doesn't create any ambiguity. Note in the example above: no line break needed before +end+, just as no line break needed after +else+.
+
+== Breaking expressions in lines
+
+One expression might be split into several lines when each line can be unambiguously identified as "incomplete" without the next one.
+
+These works:
+
+ x = # incomplete without something after =
+ 1 + # incomplete without something after +
+ 2
+
+ File.read "test.txt", # incomplete without something after ,
+ enconding: "utf-8"
+
+These would not:
+
+ # unintended interpretation:
+ x = 1 # already complete expression
+ + 2 # interpreted as a separate +2
+
+ # syntax error:
+ File.read "test.txt" # already complete expression
+ , encoding: "utf-8" # attempt to parse as a new expression, SyntaxError
+
+The exceptions to the rule are lines starting with <tt>.</tt> ("leading dot" style of method calls) or logical operators <tt>&&</tt>/<tt>||</tt> and <tt>and</tt>/<tt>or</tt>:
+
+ # OK, interpreted as a chain of calls
+ File.read('test.txt')
+ .strip("\n")
+ .split("\t")
+ .sort
+
+ # OK, interpreted as a chain of logical operators:
+ File.empty?('test.txt')
+ || File.size('test.txt') < 10
+ || File.read('test.txt').strip.empty?
+
+If the expressions is broken into multiple lines in any of the ways described above, comments between separate lines are allowed:
+
+ sum = base_salary +
+ # see "yearly bonuses section"
+ yearly_bonus(year) +
+ # per-employee coefficient is described
+ # in another module
+ personal_coeff(employee)
+
+ # We want to short-circuit on empty files
+ File.empty?('test.txt')
+ # Or almost empty ones
+ || File.size('test.txt') < 10
+ # Otherwise we check if it is full of spaces
+ || File.read('test.txt').strip.empty?
+
+Finally, the code can explicitly tell Ruby that the expression is continued on the next line with <tt>\\</tt>:
+
+ # Unusual, but works
+ File.read "test.txt" \
+ , encoding: "utf-8"
+
+ # More regular usage (joins the strings on parsing instead
+ # of concatenating them in runtime, as + would do):
+ TEXT = "One pretty long line" \
+ "one more long line" \
+ "one other line of the text"
+
+The <tt>\\</tt> works as a parse time line break escape, so with it, comments can not be inserted between the lines:
+
+ TEXT = "line 1" \
+ # here would be line 2:
+ "line 2"
+
+ # This is interpreted as if there was no line break where \ is,
+ # i.e. the same as
+ TEXT = "line 1" # here would be line 2:
+ "line 2"
+
+ puts TEXT #=> "line 1"
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index 5e10e6a140..c876558d4e 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -3,7 +3,7 @@
Literals create objects you can use in your program. Literals include:
* {Boolean and Nil Literals}[#label-Boolean+and+Nil+Literals]
-* {Number Literals}[#label-Number+Literals]
+* {Numeric Literals}[#label-Numeric+Literals]
* {Integer Literals}[#label-Integer+Literals]
* {Float Literals}[#label-Float+Literals]
@@ -36,7 +36,7 @@ Literals create objects you can use in your program. Literals include:
+true+ is a true value. All objects except +nil+ and +false+ evaluate to a
true value in conditional expressions.
-== Number Literals
+== \Numeric Literals
=== \Integer Literals
@@ -136,9 +136,9 @@ Also \Rational numbers may be imaginary numbers.
12.3ir #=> Syntax error
-== Strings
+== \String Literals
-=== \String Literals
+=== Double-Quoted \String Literals
The most common way of writing strings is using <tt>"</tt>:
@@ -150,35 +150,14 @@ Any internal <tt>"</tt> must be escaped:
"This string has a quote: \". As you can see, it is escaped"
-Double-quote strings allow escaped characters such as <tt>\n</tt> for
-newline, <tt>\t</tt> for tab, etc. The full list of supported escape
-sequences are as follows:
+Double-quoted strings allow escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences].
- \a bell, ASCII 07h (BEL)
- \b backspace, ASCII 08h (BS)
- \t horizontal tab, ASCII 09h (TAB)
- \n newline (line feed), ASCII 0Ah (LF)
- \v vertical tab, ASCII 0Bh (VT)
- \f form feed, ASCII 0Ch (FF)
- \r carriage return, ASCII 0Dh (CR)
- \e escape, ASCII 1Bh (ESC)
- \s space, ASCII 20h (SPC)
- \\ backslash, \
- \nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7])
- \xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
- \unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
- \u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
- \cx or \C-x control character, where x is an ASCII printable character
- \M-x meta character, where x is an ASCII printable character
- \M-\C-x meta control character, where x is an ASCII printable character
- \M-\cx same as above
- \c\M-x same as above
- \c? or \C-? delete, ASCII 7Fh (DEL)
-
-Any other character following a backslash is interpreted as the
+In a double-quoted string,
+any other character following a backslash is interpreted as the
character itself.
-Double-quote strings allow interpolation of other values using
+Double-quoted strings allow interpolation of other values using
<tt>#{...}</tt>:
"One plus one is two: #{1 + 1}"
@@ -190,8 +169,14 @@ You can also use <tt>#@foo</tt>, <tt>#@@foo</tt> and <tt>#$foo</tt> as a
shorthand for, respectively, <tt>#{ @foo }</tt>, <tt>#{ @@foo }</tt> and
<tt>#{ $foo }</tt>.
+See also:
+
+* {% and %Q: Interpolable String Literals}[#label-25+and+-25Q-3A+Interpolable+String+Literals]
+
+=== Single-Quoted \String Literals
+
Interpolation may be disabled by escaping the "#" character or using
-single-quote strings:
+single-quoted strings:
'#{1 + 1}' #=> "\#{1 + 1}"
@@ -199,6 +184,16 @@ In addition to disabling interpolation, single-quoted strings also disable all
escape sequences except for the single-quote (<tt>\'</tt>) and backslash
(<tt>\\\\</tt>).
+In a single-quoted string,
+any other character following a backslash is interpreted as is:
+a backslash and the character itself.
+
+See also:
+
+* {%q: Non-Interpolable String Literals}[#label-25q-3A+Non-Interpolable+String+Literals]
+
+=== Literal String Concatenation
+
Adjacent string literals are automatically concatenated by the interpreter:
"con" "cat" "en" "at" "ion" #=> "concatenation"
@@ -209,12 +204,14 @@ Any combination of adjacent single-quote, double-quote, percent strings will
be concatenated as long as a percent-string is not last.
%q{a} 'b' "c" #=> "abc"
- "a" 'b' %q{c} #=> NameError: uninitialized constant q
+ "a" 'b' %q{c} #=> NoMethodError: undefined method 'q' for main
+
+=== Character Literal
There is also a character literal notation to represent single
character strings, which syntax is a question mark (<tt>?</tt>)
-followed by a single character or escape sequence that corresponds to
-a single codepoint in the script encoding:
+followed by a single character or escape sequence (except continuation line)
+that corresponds to a single codepoint in the script encoding:
?a #=> "a"
?abc #=> SyntaxError
@@ -228,10 +225,45 @@ a single codepoint in the script encoding:
?\C-\M-a #=> "\x81", same as above
?ã‚ #=> "ã‚"
-See also:
+=== Escape Sequences
-* {%q: Non-Interpolable String Literals}[#label-25q-3A+Non-Interpolable+String+Literals]
-* {% and %Q: Interpolable String Literals}[#label-25+and+-25Q-3A+Interpolable+String+Literals]
+Some characters can be represented as escape sequences in
+double-quoted strings,
+character literals,
+here document literals (non-quoted, double-quoted, and with backticks),
+double-quoted symbols,
+double-quoted symbol keys in Hash literals,
+Regexp literals, and
+several percent literals (<tt>%</tt>, <tt>%Q</tt>, <tt>%W</tt>, <tt>%I</tt>, <tt>%r</tt>, <tt>%x</tt>).
+
+They allow escape sequences such as <tt>\n</tt> for
+newline, <tt>\t</tt> for tab, etc. The full list of supported escape
+sequences are as follows:
+
+ \a bell, ASCII 07h (BEL)
+ \b backspace, ASCII 08h (BS)
+ \t horizontal tab, ASCII 09h (TAB)
+ \n newline (line feed), ASCII 0Ah (LF)
+ \v vertical tab, ASCII 0Bh (VT)
+ \f form feed, ASCII 0Ch (FF)
+ \r carriage return, ASCII 0Dh (CR)
+ \e escape, ASCII 1Bh (ESC)
+ \s space, ASCII 20h (SPC)
+ \\ backslash, \
+ \nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7])
+ \xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
+ \unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
+ \u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
+ \cx or \C-x control character, where x is an ASCII printable character
+ \M-x meta character, where x is an ASCII printable character
+ \M-\C-x meta control character, where x is an ASCII printable character
+ \M-\cx same as above
+ \c\M-x same as above
+ \c? or \C-? delete, ASCII 7Fh (DEL)
+ \<newline> continuation line (empty string)
+
+The last one, <tt>\<newline></tt>, represents an empty string instead of a character.
+It is used to fold a line in a string.
=== Here Document Literals
@@ -277,9 +309,16 @@ the content. Note that empty lines and lines consisting solely of literal tabs
and spaces will be ignored for the purposes of determining indentation, but
escaped tabs and spaces are considered non-indentation characters.
-A heredoc allows interpolation and escaped characters. You may disable
-interpolation and escaping by surrounding the opening identifier with single
-quotes:
+For the purpose of measuring an indentation, a horizontal tab is regarded as a
+sequence of one to eight spaces such that the column position corresponding to
+its end is a multiple of eight. The amount to be removed is counted in terms
+of the number of spaces. If the boundary appears in the middle of a tab, that
+tab is not removed.
+
+A heredoc allows interpolation and the escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences].
+You may disable interpolation and the escaping by surrounding the opening
+identifier with single quotes:
expected_result = <<-'EXPECTED'
One plus one is #{1 + 1}
@@ -320,12 +359,15 @@ details on what symbols are and when ruby creates them internally.
You may reference a symbol using a colon: <tt>:my_symbol</tt>.
-You may also create symbols by interpolation:
+You may also create symbols by interpolation and escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences] with double-quotes:
:"my_symbol1"
:"my_symbol#{1 + 1}"
+ :"foo\sbar"
-Like strings, a single-quote may be used to disable interpolation:
+Like strings, a single-quote may be used to disable interpolation and
+escape sequences:
:'my_symbol#{1 + 1}' #=> :"my_symbol\#{1 + 1}"
@@ -408,9 +450,9 @@ slash (<tt>'/'</tt>) characters:
re = /foo/ # => /foo/
re.class # => Regexp
-The trailing slash may be followed by one or more _flag_ characters
-that modify the behavior.
-See {Regexp options}[rdoc-ref:Regexp@Options] for details.
+The trailing slash may be followed by one or more modifiers characters
+that set modes for the regexp.
+See {Regexp modes}[rdoc-ref:Regexp@Modes] for details.
Interpolation may be used inside regular expressions along with escaped
characters. Note that a regular expression may require additional escaped
@@ -445,7 +487,12 @@ may use these paired delimiters:
* <tt>(</tt> and <tt>)</tt>.
* <tt>{</tt> and <tt>}</tt>.
* <tt><</tt> and <tt>></tt>.
-* Any other character, as both beginning and ending delimiters.
+* Non-alphanumeric ASCII character except above, as both beginning and ending delimiters.
+
+The delimiters can be escaped with a backslash.
+However, the first four pairs (brackets, parenthesis, braces, and
+angle brackets) are allowed without backslash as far as they are correctly
+paired.
These are demonstrated in the next section.
@@ -454,13 +501,20 @@ These are demonstrated in the next section.
You can write a non-interpolable string with <tt>%q</tt>.
The created string is the same as if you created it with single quotes:
- %[foo bar baz] # => "foo bar baz" # Using [].
- %(foo bar baz) # => "foo bar baz" # Using ().
- %{foo bar baz} # => "foo bar baz" # Using {}.
- %<foo bar baz> # => "foo bar baz" # Using <>.
- %|foo bar baz| # => "foo bar baz" # Using two |.
- %:foo bar baz: # => "foo bar baz" # Using two :.
+ %q[foo bar baz] # => "foo bar baz" # Using [].
+ %q(foo bar baz) # => "foo bar baz" # Using ().
+ %q{foo bar baz} # => "foo bar baz" # Using {}.
+ %q<foo bar baz> # => "foo bar baz" # Using <>.
+ %q|foo bar baz| # => "foo bar baz" # Using two |.
+ %q:foo bar baz: # => "foo bar baz" # Using two :.
%q(1 + 1 is #{1 + 1}) # => "1 + 1 is \#{1 + 1}" # No interpolation.
+ %q[foo[bar]baz] # => "foo[bar]baz" # brackets can be nested.
+ %q(foo(bar)baz) # => "foo(bar)baz" # parenthesis can be nested.
+ %q{foo{bar}baz} # => "foo{bar}baz" # braces can be nested.
+ %q<foo<bar>baz> # => "foo<bar>baz" # angle brackets can be nested.
+
+This is similar to single-quoted string but only backslashes and
+the specified delimiters can be escaped with a backslash.
=== <tt>% and %Q</tt>: Interpolable String Literals
@@ -470,30 +524,70 @@ or with its alias <tt>%</tt>:
%[foo bar baz] # => "foo bar baz"
%(1 + 1 is #{1 + 1}) # => "1 + 1 is 2" # Interpolation.
+This is similar to double-quoted string.
+It allow escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences].
+Other escaped characters (a backslash followed by a character) are
+interpreted as the character.
+
=== <tt>%w and %W</tt>: String-Array Literals
-You can write an array of strings with <tt>%w</tt> (non-interpolable)
-or <tt>%W</tt> (interpolable):
+You can write an array of strings as whitespace-separated words
+with <tt>%w</tt> (non-interpolable) or <tt>%W</tt> (interpolable):
%w[foo bar baz] # => ["foo", "bar", "baz"]
%w[1 % *] # => ["1", "%", "*"]
# Use backslash to embed spaces in the strings.
%w[foo\ bar baz\ bat] # => ["foo bar", "baz bat"]
+ %W[foo\ bar baz\ bat] # => ["foo bar", "baz bat"]
%w(#{1 + 1}) # => ["\#{1", "+", "1}"]
%W(#{1 + 1}) # => ["2"]
+ # The nested delimiters evaluated to a flat array of strings
+ # (not nested array).
+ %w[foo[bar baz]qux] # => ["foo[bar", "baz]qux"]
+
+The interpolated string is treated as a single word even if it contains
+whitespace.
+
+ s = "bar baz"
+ %W[foo #{s} zot] #=> ["foo", "bar baz", "zot"]
+ %W[foo #{"bar baz zot"} qux] # => ["foo", "bar baz zot", "qux"]
+
+The following characters are considered as white spaces to separate words:
+
+* space, ASCII 20h (SPC)
+* form feed, ASCII 0Ch (FF)
+* newline (line feed), ASCII 0Ah (LF)
+* carriage return, ASCII 0Dh (CR)
+* horizontal tab, ASCII 09h (TAB)
+* vertical tab, ASCII 0Bh (VT)
+
+The white space characters can be escaped with a backslash to make them
+part of a word.
+
+<tt>%W</tt> allow escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences].
+However the continuation line <tt>\<newline></tt> is not usable because
+it is interpreted as the escaped newline described above.
+
=== <tt>%i and %I</tt>: Symbol-Array Literals
-You can write an array of symbols with <tt>%i</tt> (non-interpolable)
-or <tt>%I</tt> (interpolable):
+You can write an array of symbols as whitespace-separated words
+with <tt>%i</tt> (non-interpolable) or <tt>%I</tt> (interpolable):
%i[foo bar baz] # => [:foo, :bar, :baz]
%i[1 % *] # => [:"1", :%, :*]
# Use backslash to embed spaces in the symbols.
%i[foo\ bar baz\ bat] # => [:"foo bar", :"baz bat"]
+ %I[foo\ bar baz\ bat] # => [:"foo bar", :"baz bat"]
%i(#{1 + 1}) # => [:"\#{1", :+, :"1}"]
%I(#{1 + 1}) # => [:"2"]
+The white space characters and its escapes are interpreted as the same as
+string-array literals described in
+{%w and %W: String-Array Literals}[#label-25w+and+-25W-3A+String-Array+Literals].
+
=== <tt>%s</tt>: Symbol Literals
You can write a symbol with <tt>%s</tt>:
@@ -501,6 +595,10 @@ You can write a symbol with <tt>%s</tt>:
%s[foo] # => :foo
%s[foo bar] # => :"foo bar"
+This is non-interpolable.
+No interpolation allowed.
+Only backslashes and the specified delimiters can be escaped with a backslash.
+
=== <tt>%r</tt>: Regexp Literals
You can write a regular expression with <tt>%r</tt>;
@@ -517,12 +615,18 @@ A few "symmetrical" character pairs may be used as delimiters:
%r(foo) # => /foo/
%r<foo> # => /foo/
-The trailing delimiter may be followed by one or more _flag_ characters
-that modify the behavior.
-See {Regexp options}[rdoc-ref:Regexp@Options] for details.
+The trailing delimiter may be followed by one or more modifier characters
+that set modes for the regexp.
+See {Regexp modes}[rdoc-ref:Regexp@Modes] for details.
=== <tt>%x</tt>: Backtick Literals
You can write and execute a shell command with <tt>%x</tt>:
- %x(echo 1) # => "1\n"
+ %x(echo 1) # => "1\n"
+ %x[echo #{1 + 2}] # => "3\n"
+ %x[echo \u0030] # => "0\n"
+
+This is interpolable.
+<tt>%x</tt> allow escape sequences described in
+{Escape Sequences}[#label-Escape+Sequences].
diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc
index 8dafa6bb0c..14810a188f 100644
--- a/doc/syntax/methods.rdoc
+++ b/doc/syntax/methods.rdoc
@@ -100,6 +100,7 @@ operators.
<code>/</code> :: divide
<code>%</code> :: modulus division, String#%
<code>&</code> :: AND
+<code>|</code> :: OR
<code>^</code> :: XOR (exclusive OR)
<code>>></code> :: right-shift
<code><<</code> :: left-shift, append
diff --git a/doc/syntax/modules_and_classes.rdoc b/doc/syntax/modules_and_classes.rdoc
index 024815a5a6..9e05c5c774 100644
--- a/doc/syntax/modules_and_classes.rdoc
+++ b/doc/syntax/modules_and_classes.rdoc
@@ -40,9 +40,9 @@ functionality:
remove_method :my_method
end
-Reopening classes is a very powerful feature of Ruby, but it is best to only
-reopen classes you own. Reopening classes you do not own may lead to naming
-conflicts or difficult to diagnose bugs.
+Reopening modules (or classes) is a very powerful feature of Ruby, but it is
+best to only reopen modules you own. Reopening modules you do not own may lead
+to naming conflicts or difficult to diagnose bugs.
== Nesting
@@ -259,6 +259,28 @@ includes a minimum of built-in methods. You can use BasicObject to create an
independent inheritance structure. See the BasicObject documentation for
further details.
+Just like modules, classes can also be reopened. You can omit its superclass
+when you reopen a class. Specifying a different superclass than the previous
+definition will raise an error.
+
+ class C
+ end
+
+ class D < C
+ end
+
+ # OK
+ class D < C
+ end
+
+ # OK
+ class D
+ end
+
+ # TypeError: superclass mismatch for class D
+ class D < String
+ end
+
== Inheritance
Any method defined on a class is callable from its subclass:
diff --git a/doc/syntax/operators.rdoc b/doc/syntax/operators.rdoc
new file mode 100644
index 0000000000..d3045ac99e
--- /dev/null
+++ b/doc/syntax/operators.rdoc
@@ -0,0 +1,75 @@
+= Operators
+
+In Ruby, operators such as <code>+</code>, are defined as methods on the class.
+Literals[rdoc-ref:syntax/literals.rdoc] define their methods within the lower
+level, C language. String class, for example.
+
+Ruby objects can define or overload their own implementation for most operators.
+
+Here is an example:
+
+ class Foo < String
+ def +(str)
+ self.concat(str).concat("another string")
+ end
+ end
+
+ foobar = Foo.new("test ")
+ puts foobar + "baz "
+
+This prints:
+
+ test baz another string
+
+What operators are available is dependent on the implementing class.
+
+== Operator Behavior
+
+How a class behaves to a given operator is specific to that class, since
+operators are method implementations.
+
+When using an operator, it's the expression on the left-hand side of the
+operation that specifies the behavior.
+
+ 'a' * 3 #=> "aaa"
+ 3 * 'a' # TypeError: String can't be coerced into Integer
+
+== Logical Operators
+
+Logical operators are not methods, and therefore cannot be
+redefined/overloaded. They are tokenized at a lower level.
+
+Short-circuit logical operators (<code>&&</code>, <code>||</code>,
+<code>and</code>, and <code>or</code>) do not always result in a boolean value.
+Similar to blocks, it's the last evaluated expression that defines the result
+of the operation.
+
+=== <code>&&</code>, <code>and</code>
+
+Both <code>&&</code>/<code>and</code> operators provide short-circuiting by executing each
+side of the operator, left to right, and stopping at the first occurrence of a
+falsey expression. The expression that defines the result is the last one
+executed, whether it be the final expression, or the first occurrence of a falsey
+expression.
+
+Some examples:
+
+ true && 9 && "string" #=> "string"
+ (1 + 2) && nil && "string" #=> nil
+ (a = 1) && (b = false) && (c = "string") #=> false
+
+ puts a #=> 1
+ puts b #=> false
+ puts c #=> nil
+
+In this last example, <code>c</code> was initialized, but not defined.
+
+=== <code>||</code>, <code>or</code>
+
+The means by which <code>||</code>/<code>or</code> short-circuits, is to return the result of
+the first expression that is truthy.
+
+Some examples:
+
+ (1 + 2) || true || "string" #=> 3
+ false || nil || "string" #=> "string"
diff --git a/doc/syntax/pattern_matching.rdoc b/doc/syntax/pattern_matching.rdoc
index e49c09a1f8..06aae26d49 100644
--- a/doc/syntax/pattern_matching.rdoc
+++ b/doc/syntax/pattern_matching.rdoc
@@ -221,7 +221,7 @@ For hash patterns, even a simpler form exists: key-only specification (without a
end
#=> "matched: 1"
-Binding works for nested patterns as well:
+\Binding works for nested patterns as well:
case {name: 'John', friends: [{name: 'Jane'}, {name: 'Rajesh'}]}
in name:, friends: [{name: first_friend}, *]
@@ -247,17 +247,17 @@ The "rest" part of a pattern also can be bound to a variable:
else
"not matched"
end
- #=> "matched: 1, {:b=>2, :c=>3}"
+ #=> "matched: 1, {b: 2, c: 3}"
-Binding to variables currently does NOT work for alternative patterns joined with <code>|</code>:
+\Binding to variables currently does NOT work for alternative patterns joined with <code>|</code>:
case {a: 1, b: 2}
in {a: } | Array
+ # ^ SyntaxError (variable capture in alternative pattern)
"matched: #{a}"
else
"not matched"
end
- # SyntaxError (illegal variable in alternative pattern (a))
Variables that start with <code>_</code> are the only exclusions from this rule:
@@ -422,7 +422,8 @@ These core and library classes implement deconstruction:
== Guard clauses
-+if+ can be used to attach an additional condition (guard clause) when the pattern matches. This condition may use bound variables:
++if+ can be used to attach an additional condition (guard clause) when the pattern matches in +case+/+in+ expressions.
+This condition may use bound variables:
case [1, 2]
in a, b if b == a*2
@@ -450,6 +451,11 @@ These core and library classes implement deconstruction:
end
#=> "matched"
+Note that <code>=></code> and +in+ operator can not have a guard clause.
+The following examples is parsed as a standalone expression with modifier +if+.
+
+ [1, 2] in a, b if b == a*2
+
== Appendix A. Pattern syntax
Approximate syntax is:
diff --git a/doc/syntax/refinements.rdoc b/doc/syntax/refinements.rdoc
index c900ab1bdc..80595eb445 100644
--- a/doc/syntax/refinements.rdoc
+++ b/doc/syntax/refinements.rdoc
@@ -210,43 +210,58 @@ all refinements from the same module are active when a refined method
== Method Lookup
-When looking up a method for an instance of class +C+ Ruby checks:
+Method lookup in Ruby is based on the ancestor chain. You can see the
+ancestor chain for any object in Ruby by doing:
-* If refinements are active for +C+, in the reverse order they were activated:
- * The prepended modules from the refinement for +C+
- * The refinement for +C+
- * The included modules from the refinement for +C+
-* The prepended modules of +C+
-* +C+
-* The included modules of +C+
+ object.singleton_class.ancestors
+ # or, if the object does not support a singleton class:
+ object.class.ancestors
-If no method was found at any point this repeats with the superclass of +C+.
+The ancestor chain is constructed as follows:
-Note that methods in a subclass have priority over refinements in a
-superclass. For example, if the method <code>/</code> is defined in a
-refinement for Numeric <code>1 / 2</code> invokes the original Integer#/
-because Integer is a subclass of Numeric and is searched before the refinements
-for the superclass Numeric. Since the method <code>/</code> is also present
-in child +Integer+, the method lookup does not move up to the superclass.
+* Subclasses are before superclasses in the ancestor chain
+* Prepended modules are before the class they prepend in the ancestor
+ chain, in reverse order in which they were prepended.
+* Included modules are after the class they are included in in the
+ ancestor chain, in reverse order in which they were included.
+
+When looking up a method for an object, Ruby goes through each ancestor:
+
+* If the class/module has been refined, Ruby will consider the refinements
+ activated at the point the method was called, in reverse order of
+ activation.
+* Otherwise, Ruby will check the methods of the class/module itself.
+
+If no method was found at either point this repeats with the next
+ancestor.
-However, if a method +foo+ is defined on Numeric in a refinement, <code>1.foo</code>
+Note that methods in a earlier ancestor have priority over refinements in a
+later ancestor. For example, if the method <code>/</code> is defined in a
+refinement for Numeric <code>1 / 2</code> invokes the original Integer#/
+because Integer is a comes before Numeric in the ancestor chain. However,
+if a method +foo+ is defined on Numeric in a refinement, <code>1.foo</code>
invokes that method since +foo+ does not exist on Integer.
== +super+
-When +super+ is invoked method lookup checks:
+When +super+ is invoked, method lookup starts:
+
+* If the method is in a refinement, at the refined class or module
+* Otherwise, at the next ancestor
+
+Method lookup then proceeds as described in the Method Lookup section
+above.
-* The included modules of the current class. Note that the current class may
- be a refinement.
-* If the current class is a refinement, the method lookup proceeds as in the
- Method Lookup section above.
-* If the current class has a direct superclass, the method proceeds as in the
- Method Lookup section above using the superclass.
+Refinements activated at the call site of a refinement method do not
+affect +super+ inside that method. Only refinements activated at the
+point +super+ was called affect method lookup for that +super+ call.
+You cannot use refinements to insert into the middle of a method
+lookup chain, only to insert at the start of a method lookup chain,
+unless you control the +super+ call sites.
-Note that +super+ in a method of a refinement invokes the method in the
-refined class even if there is another refinement which has been activated in
-the same context. This is only true for +super+ in a method of a refinement, it
-does not apply to +super+ in a method in a module that is included in a refinement.
+Note that if you refine a module, the refinement method can call +super+
+to call the method in the module, but the method in the module cannot
+call +super+ to continue the method lookup process to further ancestors.
== Methods Introspection
@@ -279,6 +294,6 @@ Refinements in descendants have higher precedence than those of ancestors.
== Further Reading
-See https://bugs.ruby-lang.org/projects/ruby-master/wiki/RefinementsSpec for the
+See https://github.com/ruby/ruby/wiki/Refinements-Spec for the
current specification for implementing refinements. The specification also
contains more details.
diff --git a/doc/timezones.rdoc b/doc/timezones.rdoc
deleted file mode 100644
index c3aae88fde..0000000000
--- a/doc/timezones.rdoc
+++ /dev/null
@@ -1,108 +0,0 @@
-== Timezones
-
-=== Timezone Specifiers
-
-Certain \Time methods accept arguments that specify timezones:
-
-- Time.at: keyword argument +in:+.
-- Time.new: positional argument +zone+ or keyword argument +in:+.
-- Time.now: keyword argument +in:+.
-- Time#getlocal: positional argument +zone+.
-- Time#localtime: positional argument +zone+.
-
-The value given with any of these must be one of the following
-(each detailed below):
-
-- {Hours/minutes offset}[rdoc-ref:timezones.rdoc@Hours-2FMinutes+Offsets].
-- {Single-letter offset}[rdoc-ref:timezones.rdoc@Single-Letter+Offsets].
-- {Integer offset}[rdoc-ref:timezones.rdoc@Integer+Offsets].
-- {Timezone object}[rdoc-ref:timezones.rdoc@Timezone+Objects].
-
-==== Hours/Minutes Offsets
-
-The zone value may be a string offset from UTC
-in the form <tt>'+HH:MM'</tt> or <tt>'-HH:MM'</tt>,
-where:
-
-- +HH+ is the 2-digit hour in the range <tt>0..23</tt>.
-- +MM+ is the 2-digit minute in the range <tt>0..59</tt>.
-
-Examples:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
- Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
-
-==== Single-Letter Offsets
-
-The zone value may be a letter in the range <tt>'A'..'I'</tt>
-or <tt>'K'..'Z'</tt>;
-see {List of military time zones}[https://en.wikipedia.org/wiki/List_of_military_time_zones]:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
- Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
- Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
- Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
- Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
-
-==== \Integer Offsets
-
-The zone value may be an integer number of seconds
-in the range <tt>-86399..86399</tt>:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
- Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
-
-==== Timezone Objects
-
-In most cases, the zone value may be an object
-responding to certain timezone methods.
-
-\Exceptions (timezone object not allowed):
-
-- Time.new with positional argument +zone+.
-- Time.now with keyword argument +in:+.
-
-The timezone methods are:
-
-- +local_to_utc+:
-
- - Called when Time.new is invoked with +tz+
- as the value of positional argument +zone+ or keyword argument +in:+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a \Time-like object in the UTC timezone.
-
-- +utc_to_local+:
-
- - Called when Time.at or Time.now is invoked with +tz+
- as the value for keyword argument +in:+,
- and when Time#getlocal or Time#localtime is called with +tz+
- as the value for positional argument +zone+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a \Time-like object in the local timezone.
-
-A custom timezone class may have these instance methods,
-which will be called if defined:
-
-- +abbr+:
-
- - Called when Time#strftime is invoked with a format involving <tt>%Z</tt>.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a string abbreviation for the timezone name.
-
-- +dst?+:
-
- - Called when Time.at or Time.now is invoked with +tz+
- as the value for keyword argument +in:+,
- and when Time#getlocal or Time#localtime is called with +tz+
- as the value for positional argument +zone+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: whether the time is daylight saving time.
-
-- +name+:
-
- - Called when <tt>Marshal.dump(t) is invoked
- - Argument: none.
- - Returns: the string name of the timezone.
diff --git a/doc/windows.md b/doc/windows.md
deleted file mode 100644
index d0f447350e..0000000000
--- a/doc/windows.md
+++ /dev/null
@@ -1,234 +0,0 @@
-# Windows
-
-Ruby supports a few native build platforms for Windows.
-
-* mswin: Build using Microsoft Visual C++ compiler
-* mingw-msvcrt: Build using compiler for Mingw with msvcrtXX.dll
-* mingw-ucrt: Build using compiler for Mingw with vcruntime.dll
-
-## Building Ruby using Mingw with UCRT
-
-The easiest build environment is just a standard [RubyInstaller-Devkit]
-installation and [git-for-windows]. You might like to use [VSCode] as an
-editor.
-
-### Build examples
-
-Ruby core development can be done either in Windows `cmd` like:
-
-```
-ridk enable ucrt64
-
-pacman -S --needed bison %MINGW_PACKAGE_PREFIX%-openssl %MINGW_PACKAGE_PREFIX%-libyaml %MINGW_PACKAGE_PREFIX%-readline
-
-cd c:\
-mkdir work
-cd work
-git clone https://github.com/ruby/ruby
-
-cd c:\work\ruby
-sh autogen.sh
-sh configure -C --disable-install-doc
-make
-```
-
-or in MSYS2 `bash` like:
-
-```
-ridk enable ucrt64
-bash
-
-pacman -S --needed bison $MINGW_PACKAGE_PREFIX-openssl $MINGW_PACKAGE_PREFIX-libyaml $MINGW_PACKAGE_PREFIX-readline
-
-cd /c/
-mkdir work
-cd work
-git clone https://github.com/ruby/ruby
-cd ruby
-
-./autogen.sh
-./configure -C --disable-install-doc
-make
-```
-
-[RubyInstaller-Devkit]: https://rubyinstaller.org/
-[git-for-windows]: https://gitforwindows.org/
-[VSCode]: https://code.visualstudio.com/
-
-## Building Ruby using Visual C++
-
-### Requirement
-
-1. Windows 7 or later.
-
-2. Visual C++ 12.0 (2013) or later.
-
- **Note** if you want to build x64 version, use native compiler for
- x64.
-
-3. Please set environment variable `INCLUDE`, `LIB`, `PATH`
- to run required commands properly from the command line.
-
- **Note** building ruby requires following commands.
-
- * nmake
- * cl
- * ml
- * lib
- * dumpbin
-
-4. If you want to build from GIT source, following commands are required.
- * bison
- * patch
- * sed
- * ruby 2.0 or later
-
- You can use [scoop](https://scoop.sh/) to install them like:
-
- ```
- scoop install git ruby winflexbison sed patch
- ```
-
-5. You need to install required libraries using [vcpkg](https://vcpkg.io/) like:
-
- ```
- vcpkg --triplet x64-windows install openssl libffi libyaml zlib
- ```
-
-6. Enable Command Extension of your command line. It's the default behavior
- of `cmd.exe`. If you want to enable it explicitly, run `cmd.exe` with
- `/E:ON` option.
-
-### How to compile and install
-
-1. Execute `win32\configure.bat` on your build directory.
- You can specify the target platform as an argument.
- For example, run `configure --target=i686-mswin32`
- You can also specify the install directory.
- For example, run `configure --prefix=<install_directory>`
- Default of the install directory is `/usr` .
- The default _PLATFORM_ is `i386-mswin32_`_MSRTVERSION_ on 32-bit
- platforms, or `x64-mswin64_`_MSRTVERSION_ on x64 platforms.
- _MSRTVERSION_ is the 2- or 3-digits version of the Microsoft
- Runtime Library.
-
-2. Change _RUBY_INSTALL_NAME_ and _RUBY_SO_NAME_ in `Makefile`
- if you want to change the name of the executable files.
- And add _RUBYW_INSTALL_NAME_ to change the name of the
- executable without console window if also you want.
-
-3. You need specify vcpkg directory to use `--with-opt-dir`
- option like `configure --with-opt-dir=C:\vcpkg\installed\x64-windows`
-
-4. Run `nmake up` if you are building from GIT source.
-
-5. Run `nmake`
-
-6. Run `nmake check`
-
-7. Run `nmake install`
-
-### Build examples
-
-* Build on the ruby source directory.
-
- ```
- ruby source directory: C:\ruby
- build directory: C:\ruby
- install directory: C:\usr\local
- ```
-
- ```
- C:
- cd \ruby
- win32\configure --prefix=/usr/local
- nmake
- nmake check
- nmake install
- ```
-
-* Build on the relative directory from the ruby source directory.
-
- ```
- ruby source directory: C:\ruby
- build directory: C:\ruby\mswin32
- install directory: C:\usr\local
- ```
-
- ```
- C:
- cd \ruby
- mkdir mswin32
- cd mswin32
- ..\win32\configure --prefix=/usr/local
- nmake
- nmake check
- nmake install
- ```
-
-* Build on the different drive.
-
- ```
- ruby source directory: C:\src\ruby
- build directory: D:\build\ruby
- install directory: C:\usr\local
- ```
-
- ```
- D:
- cd D:\build\ruby
- C:\src\ruby\win32\configure --prefix=/usr/local
- nmake
- nmake check
- nmake install DESTDIR=C:
- ```
-
-* Build x64 version (requires native x64 VC++ compiler)
-
- ```
- ruby source directory: C:\ruby
- build directory: C:\ruby
- install directory: C:\usr\local
- ```
-
- ```
- C:
- cd \ruby
- win32\configure --prefix=/usr/local --target=x64-mswin64
- nmake
- nmake check
- nmake install
- ```
-
-### Bugs
-
-You can **NOT** use a path name that contains any white space characters
-as the ruby source directory, this restriction comes from the behavior
-of `!INCLUDE` directives of `NMAKE`.
-
-You can build ruby in any directory including the source directory,
-except `win32` directory in the source directory.
-This is restriction originating in the path search method of `NMAKE`.
-
-## Icons
-
-Any icon files(`*.ico`) in the build directory, directories specified with
-_icondirs_ make variable and `win32` directory under the ruby
-source directory will be included in DLL or executable files, according
-to their base names.
- $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
- $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
- the others --> $(RUBY_SO_NAME).dll
-
-Although no icons are distributed with the ruby source, you can use
-anything you like. You will be able to find many images by search engines.
-For example, followings are made from [Ruby logo kit]:
-
-* Small [favicon] in the official site
-
-* [vit-ruby.ico] or [icon itself]
-
-[Ruby logo kit]: https://cache.ruby-lang.org/pub/misc/logo/ruby-logo-kit.zip
-[favicon]: https://www.ruby-lang.org/favicon.ico
-[vit-ruby.ico]: http://ruby.morphball.net/vit-ruby-ico_en.html
-[icon itself]: http://ruby.morphball.net/icon/vit-ruby.ico
diff --git a/doc/yarvarch.en b/doc/yarvarch.en
deleted file mode 100644
index 7a76e25b7e..0000000000
--- a/doc/yarvarch.en
+++ /dev/null
@@ -1,7 +0,0 @@
-#title YARV: Yet another RubyVM - Software Architecture
-
-maybe writing.
-
-* YARV instruction set
-
-<%= d %>
diff --git a/doc/yarvarch.ja b/doc/yarvarch.ja
deleted file mode 100644
index 2739ec6b14..0000000000
--- a/doc/yarvarch.ja
+++ /dev/null
@@ -1,454 +0,0 @@
-#title YARVアーキテクãƒãƒ£
-#set author 日本 Ruby ã®ä¼š ã•ã•ã ã“ã†ã„ã¡
-
-
-- 2005-03-03(Thu) 00:31:12 +0900 ã„ã‚ã„ã‚ã¨æ›¸ãç›´ã—
-
-----
-
-* ã“れã¯ï¼Ÿ
-
-[[YARV: Yet Another RubyVM|http://www.atdot.net/yarv]] 㮠設計メモã§ã™ã€‚
-
-
-YARV ã¯ã€Ruby プログラムã®ãŸã‚ã®æ¬¡ã®æ©Ÿèƒ½ã‚’æä¾›ã—ã¾ã™ã€‚
-
-- Compiler
-- VM Generator
-- VM (Virtual Machine)
-- Assembler
-- Dis-Assembler
-- (experimental) JIT Compiler
-- (experimental) AOT Compiler
-
-
-ç¾åœ¨ã® YARV 㯠Ruby ã‚¤ãƒ³ã‚¿ãƒ—ãƒªã‚¿ã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリã¨ã—ã¦å®Ÿè£…ã—ã¦ã„ã¾ã™ã€‚ã“
-れã«ã‚ˆã‚Šã€Ruby インタプリタã®å¿…è¦ãªæ©Ÿèƒ½ï¼ˆãƒ‘ーサã€ã‚ªãƒ–ジェクト管ç†ã€æ—¢å­˜
-ã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリ)ãªã©ãŒã»ã¼ãã®ã¾ã¾åˆ©ç”¨ã§ãã¾ã™ã€‚
-
-ãŸã ã—ã€ã„ãã¤ã‹ã®ãƒ‘ッãƒã‚’ Ruby インタプリタã«å½“ã¦ãªã‘れã°ãªã‚Šã¾ã›ã‚“。
-
-今後ã¯ã€Ruby 本体ã®ã‚¤ãƒ³ã‚¿ãƒ—リタ部分(eval.cï¼‰ã‚’ç½®ãæ›ãˆã‚‹ã“ã¨ã‚’目指ã—ã¦
-開発を継続ã™ã‚‹äºˆå®šã§ã™ã€‚
-
-
-* Compiler (compile.h, compile.c)
-
-コンパイラã¯ã€Ruby インタプリタã®ãƒ‘ーサã«ã‚ˆã£ã¦ç”Ÿæˆã•ã‚ŒãŸæ§‹æ–‡æœ¨ï¼ˆRNode
-データã«ã‚ˆã‚‹æœ¨ï¼‰ã‚’ YARV 命令列ã«å¤‰æ›ã—ã¾ã™ã€‚YARV 命令ã«ã¤ã„ã¦ã¯å¾Œè¿°ã—ã¾
-ã™ã€‚
-
-ã¨ãã«é›£ã—ã„ã“ã¨ã¯ã—ã¦ã„ã¾ã›ã‚“ãŒã€ã‚¹ã‚³ãƒ¼ãƒ—ãªã©ã®é–‹å§‹æ™‚ã«ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®åˆ
-期化ãªã©ã‚’行ã„ã€ã‚ã¨ã¯æ§‹æ–‡æœ¨ã‚’辿り変æ›ã—ã¦ã„ãã¾ã™ã€‚
-
-変æ›ä¸­ã¯ Ruby ã® Array オブジェクト㫠YARV 命令オブジェクトã€ãŠã‚ˆã³ã‚ªãƒš
-ランドを格ç´ã—ã¦ã„ãã€æœ€å¾Œã«å®Ÿè¡Œã§ãã‚‹å½¢ã«å¤‰æ›ã—ã¾ã™ã€‚コンパイラã§ã¯ã€ã‚³
-ンパイル中ã«ç”Ÿæˆã™ã‚‹ãƒ¡ãƒ¢ãƒªé ˜åŸŸã®ç®¡ç†ãŒå•題ã«ãªã‚‹ã“ã¨ãŒã‚りã¾ã™ãŒã€YARV
-ã®å ´åˆã€Ruby インタプリタãŒã™ã¹ã¦é¢å€’ã‚’ã¿ã¦ãれるã®ã§ã“ã®éƒ¨åˆ†ã¯éžå¸¸ã«æ¥½
-ã«ä½œã‚‹ã“ã¨ãŒã§ãã¾ã—ãŸï¼ˆã‚¬ãƒ¼ãƒ™ãƒ¼ã‚¸ã‚³ãƒ¬ã‚¯ã‚¿ã«ã‚ˆã£ã¦è‡ªå‹•çš„ã«ãƒ¡ãƒ¢ãƒªç®¡ç†ã‚’ã—
-ã¦ãれるãŸã‚)。
-
-YARV 命令ã¯ã€å‘½ä»¤ã‚’示ã™è­˜åˆ¥å­ã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ãªã©ã€ã™ã¹ã¦ 1 word (マシンã§
-表ç¾ã§ãる自然ãªå€¤ã€‚C 言語ã§ã¯ãƒã‚¤ãƒ³ã‚¿ã®ã‚µã‚¤ã‚ºã€‚Ruby インタプリタ用語ã§
-㯠VALUE ã®ã‚µã‚¤ã‚ºï¼‰ã§è¡¨ç¾ã•れã¾ã™ã€‚ãã®ãŸã‚ã€YARV 命令ã¯ã„ã‚ゆる「ãƒã‚¤ãƒˆ
-コードã€ã§ã¯ã‚りã¾ã›ã‚“。ãã®ãŸã‚ã€YARV ã®èª¬æ˜Žãªã©ã§ã¯ã€Œå‘½ä»¤åˆ—ã€ã¨ã„ã†ç”¨
-語を使ã£ã¦ã„ã¾ã™ã€‚
-
-1 word ã§ã‚ã‚‹ãŸã‚ã€ãƒ¡ãƒ¢ãƒªã®åˆ©ç”¨åŠ¹çŽ‡ã¯å¤šå°‘悪ããªã‚Šã¾ã™ãŒã€ã‚¢ã‚¯ã‚»ã‚¹é€Ÿåº¦ãª
-ã©ã‚’考慮ã™ã‚‹ã¨ã€æœ¬æ–¹å¼ãŒä¸€ç•ªã„ã„ã¨è€ƒãˆã¦ãŠã‚Šã¾ã™ã€‚ãŸã¨ãˆã°ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’コ
-ãƒ³ã‚¹ã‚¿ãƒ³ãƒˆãƒ—ãƒ¼ãƒ«ã«æ ¼ç´ã—ã€ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã®ã¿ã‚’オペランドã§ç¤ºã™ã“ã¨ã‚‚å¯èƒ½ã§
-ã™ãŒã€é–“接アクセスã«ãªã£ã¦ã—ã¾ã†ã®ã§æ€§èƒ½ã«å½±éŸ¿ãŒå‡ºã‚‹ãŸã‚ã€å´ä¸‹ã—ã¾ã—ãŸã€‚
-
-
-* VM Generator (rb/insns2vm.rb, insns.def)
-
-rb/insns2vm.rb ã¨ã„ã†ã‚¹ã‚¯ãƒªãƒ—トã¯ã€insns.def ã¨ã„ã†ãƒ•ァイルを読ã¿è¾¼ã¿ã€
-VM ã®ãŸã‚ã«å¿…è¦ãªãƒ•ァイルを生æˆã—ã¾ã™ã€‚具体的ã«ã¯ã€å‘½ä»¤ã‚’実行ã™ã‚‹éƒ¨åˆ†ã‚’
-生æˆã—ã¾ã™ãŒã€ã»ã‹ã«ã‚‚コンパイルã«å¿…è¦ãªæƒ…å ±ã€æœ€é©åŒ–ã«å¿…è¦ãªæƒ…å ±ã€ã‚„アセ
-ンブラã€é€†ã‚¢ã‚»ãƒ³ãƒ–ラã«å¿…è¦ãªæƒ…報を示ã™ãƒ•ァイルも生æˆã—ã¾ã™ã€‚
-
-
-** 命令記述
-
-insns.def ã«ã¯ã€å„命令ãŒã©ã®ã‚ˆã†ãªå‘½ä»¤ã§ã‚ã‚‹ã‹ã‚’記述ã—ã¾ã™ã€‚具体的ã«ã¯æ¬¡
-ã®æƒ…報を記述ã—ã¾ã™ã€‚
-
-- 命令ã®åå‰
-- ãã®å‘½ä»¤ã®ã‚«ãƒ†ã‚´ãƒªã€ã‚³ãƒ¡ãƒ³ãƒˆï¼ˆè‹±èªžã€æ—¥æœ¬èªžï¼‰
-- オペランドã®åå‰
-- ãã®å‘½ä»¤å®Ÿè¡Œå‰ã«ã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ãƒãƒƒãƒ—ã™ã‚‹å€¤
-- ãã®å‘½ä»¤å®Ÿè¡Œå¾Œã«ã‚¹ã‚¿ãƒƒã‚¯ã«ãƒ—ッシュã™ã‚‹å€¤
-- ãã®å‘½ä»¤ã®ãƒ­ã‚¸ãƒƒã‚¯ï¼ˆC 言語ã§è¨˜è¿°ï¼‰
-
-ãŸã¨ãˆã°ã€ã‚¹ã‚¿ãƒƒã‚¯ã« self ã‚’ãŠã putself ã¨ã„ã†å‘½ä»¤ã¯æ¬¡ã®ã‚ˆã†ã«è¨˜è¿°ã—ã¾
-ã™ã€‚
-
-#code
-/**
- @c put
- @e put self.
- @j self ã‚’ç½®ã。
- */
-DEFINE_INSN
-putself
-()
-()
-(VALUE val)
-{
- val = GET_SELF();
-}
-#end
-
-ã“ã®å ´åˆã€ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã¨ã€ã‚¹ã‚¿ãƒƒã‚¯ã‹ã‚‰ãƒãƒƒãƒ—ã™ã‚‹å€¤ã¯ç„¡ã„ã“ã¨ã«ãªã‚Šã¾ã™ã€‚命
-令終了後ã€self をスタックトップã«ç½®ããŸã„ã‚ã‘ã§ã™ãŒã€ãれ㯠val ã¨ã„ã†ã€
-スタックã«ãƒ—ッシュã™ã‚‹å€¤ã¨ã—ã¦å®£è¨€ã—ã¦ãŠã„ãŸå¤‰æ•°ã«ä»£å…¥ã—ã¦ãŠãã“ã¨ã§ã€ã“
-れを変æ›ã™ã‚‹ã¨ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒƒãƒ—ã«ç½®ã C プログラムãŒç”Ÿæˆã•れã¾ã™ã€‚
-
-ç´°ã‹ã„フォーマット㯠insns.def ã®å†’é ­ã‚’å‚ç…§ã—ã¦ãã ã•ã„。ãã‚“ãªã«é›£ã—ã
-ãªã„ã¨æ€ã„ã¾ã™ã€‚
-
-insnhelper.h ã¨ã„ã†ãƒ•ァイルã«ã€å‘½ä»¤ãƒ­ã‚¸ãƒƒã‚¯ã‚’記述ã™ã‚‹ãŸã‚ã«å¿…è¦ãªãƒžã‚¯ãƒ­
-ãŒå®šç¾©ã•れã¦ã„ã¾ã™ã€‚ã¾ãŸã€VM ã®å†…部構造ã«é–¢ã™ã‚‹å®šç¾©ã¯ vm.h ã¨ã„ã†ãƒ•ァイ
-ルã«ã‚りã¾ã™ã€‚
-
-
-* VM (Virtual Machine, vm.h, vm.c)
-
-VM ã¯ã€å®Ÿéš›ã«ã‚³ãƒ³ãƒ‘イルã—ãŸçµæžœç”Ÿæˆã•れる YARV 命令列を実行ã—ã¾ã™ã€‚ã¾ã•
-ã«ã€ã“ã®éƒ¨åˆ†ãŒ YARV ã®ã‚­ãƒ¢ã«ãªã‚Šã€å°†æ¥çš„ã«ã¯ eval.c ã‚’ã“ã® VM ã§ç½®ãæ›ãˆ
-ãŸã„ã¨è€ƒãˆã¦ã„ã¾ã™ã€‚
-
-ç¾åœ¨ã® Ruby インタプリタã§å®Ÿè¡Œã§ãã‚‹ã™ã¹ã¦ã®ã“ã¨ãŒã€ã“ã® VM ã§å®Ÿç¾ã§ãã‚‹
-よã†ã«ä½œã£ã¦ã„ã¾ã™ï¼ˆç¾æ®µéšŽã§ã¯ã¾ã å®Œå…¨ã§ã¯ã‚りã¾ã›ã‚“ãŒã€ãã†ãªã‚‹ã¹ãã§ã™ï¼‰ã€‚
-
-VM ã¯ã€å˜ç´”ãªã‚¹ã‚¿ãƒƒã‚¯ãƒžã‚·ãƒ³ã¨ã—ã¦å®Ÿè£…ã—ã¦ã„ã¾ã™ã€‚スレッドã²ã¨ã¤ã«ã‚¹ã‚¿ãƒƒ
-クã²ã¨ã¤ã‚’ä¿æŒã—ã¾ã™ã€‚スタックã®é ˜åŸŸã¯ãƒ’ープã‹ã‚‰å–å¾—ã™ã‚‹ã®ã§ã€æŸ”軟ãªé ˜åŸŸ
-設定ãŒå¯èƒ½ã§ã™ã€‚
-
-
-** レジスタ
-
-VM 㯠5 ã¤ã®ä»®æƒ³çš„ãªãƒ¬ã‚¸ã‚¹ã‚¿ã«ã‚ˆã£ã¦åˆ¶å¾¡ã•れã¾ã™ã€‚
-
-- PC (Program Counter)
-- SP (Stack Pointer)
-- CFP (Control Frame Pointer)
-- LFP (Local Frame Pointer)
-- DFP (Dynamic Frame Pointer)
-
-PC ã¯ç¾åœ¨å®Ÿè¡Œä¸­ã®å‘½ä»¤åˆ—ã®ä½ç½®ã‚’示ã—ã¾ã™ã€‚SP ã¯ã‚¹ã‚¿ãƒƒã‚¯ãƒˆãƒƒãƒ—ã®ä½ç½®ã‚’示ã—
-ã¾ã™ã€‚CFPã€LFPã€DFP ã¯ãれãžã‚Œãƒ•ãƒ¬ãƒ¼ãƒ ã®æƒ…報を示ã—ã¾ã™ã€‚詳細ã¯å¾Œè¿°ã—ã¾ã™ã€‚
-
-
-** スタックフレーム
-
-obsolete (update soon)
-
-
-** フレームデザインã«ã¤ã„ã¦ã®è£œè¶³
-
-Lisp ã®å‡¦ç†ç³»ãªã©ã‚’ã‹ã‚“ãŒãˆã‚‹ã¨ã€ã‚ã–ã‚ã–ブロックローカルフレームã¨ãƒ¡ã‚½
-ッドローカルフレームã®ã‚ˆã†ãªã‚‚ã®ã‚’用æ„ã™ã‚‹ã®ã¯å¥‡ç•°ã«è¦‹ãˆã‚‹ã‹ã‚‚ã—れã¾ã›ã‚“。
-ã‚るフレームをã€å…¥ã‚Œå­æ§‹é€ ã«ã—ã¦ã€ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã®ã‚¢ã‚¯ã‚»ã‚¹ã¯ãã®å…¥ã‚Œå­ã‚’外
-å´ã«è¾¿ã‚Œã°å¿…ãšãŸã©ã‚Šç€ãã“ã¨ãŒã§ãã‚‹ã‹ã‚‰ã§ã™ï¼ˆã¤ã¾ã‚Šã€lfp ã¯å¿…è¦ãªã„)。
-
-ã—ã‹ã—ã€Ruby ã§ã¯ã„ãã¤ã‹çжæ³ãŒé•ã„ã¾ã™ã€‚ã¾ãšã€ãƒ¡ã‚½ãƒƒãƒ‰ãƒ­ãƒ¼ã‚«ãƒ«ãªæƒ…å ±ãŒ
-ã‚ã‚‹ã“ã¨ã€å…·ä½“çš„ã«ã¯ãƒ–ロックã¨self(callee ã‹ã‚‰ã¿ã‚‹ã¨ receiver)ã§ã™ã€‚ã“
-ã®æƒ…報をãれãžã‚Œã®ãƒ•レームã«ã‚‚ãŸã›ã‚‹ã®ã¯ç„¡é§„ã§ã™ã€‚
-
-ã¾ãŸã€Ruby2.0 ã‹ã‚‰ã¯ãƒ–ロックローカル変数ã¯ãªããªã‚Šã¾ã™ï¼ˆãƒ–ロックローカル
-å¼•æ•°ã¯æ®‹ã‚‹ã®ã§ã€æ§‹é€ è‡ªä½“ã¯ã‚ã¾ã‚Šå¤‰ã‚りã¾ã›ã‚“)。ãã®ãŸã‚ã€ãƒ¡ã‚½ãƒƒãƒ‰ãƒ­ãƒ¼ã‚«
-ル変数ã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ãŒé »ç™ºã™ã‚‹ã“ã¨ãŒäºˆæƒ³ã•れã¾ã™ã€‚
-
-ã“ã®ã¨ãã€ãƒ¡ã‚½ãƒƒãƒ‰ãƒ­ãƒ¼ã‚«ãƒ«å¤‰æ•°ã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ã®ãŸã³ã«ãƒ•レーム(スコープ)ã®
-リストをãŸã©ã‚‹ã®ã¯ç„¡é§„ã§ã‚ã‚‹ã¨åˆ¤æ–­ã—ã€æ˜Žç¤ºçš„ã«ãƒ¡ã‚½ãƒƒãƒ‰ãƒ­ãƒ¼ã‚«ãƒ«ã‚¹ã‚³ãƒ¼ãƒ—ã¨
-ブロックフレームを分離ã—ã€ãƒ–ロックフレームã‹ã‚‰ã¯ãƒ¡ã‚½ãƒƒãƒ‰ãƒ­ãƒ¼ã‚«ãƒ«ãƒ•レーム
-㌠lfpレジスタã«ã‚ˆã£ã¦å®¹æ˜“ã«ã‚¢ã‚¯ã‚»ã‚¹ã§ãるよã†ã«ã—ã¾ã—ãŸã€‚
-
-
-** メソッド呼ã³å‡ºã—ã«ã¤ã„ã¦
-
-メソッド呼ã³å‡ºã—ã¯ã€YARV 命令列ã§è¨˜è¿°ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã‹ã€C ã§è¨˜è¿°ã•れãŸãƒ¡
-ソッドã‹ã«ã‚ˆã£ã¦ãƒ‡ã‚£ã‚¹ãƒ‘ãƒƒãƒæ‰‹æ³•ãŒå¤‰ã‚りã¾ã™ã€‚
-
-YARV 命令列ã§ã‚ã£ãŸå ´åˆã€ä¸Šè¿°ã—ãŸã‚¹ã‚¿ãƒƒã‚¯ãƒ•レームを作æˆã—ã¦å‘½ä»¤ã‚’継続ã—
-ã¾ã™ã€‚ã¨ãã« VM ã®é–¢æ•°ã‚’å†å¸°å‘¼ã³å‡ºã™ã™ã‚‹ã“ã¨ã¯è¡Œãªã„ã¾ã›ã‚“。
-
-C ã§è¨˜è¿°ã•れãŸãƒ¡ã‚½ãƒƒãƒ‰ã ã£ãŸå ´åˆã€å˜ç´”ã«ãã®é–¢æ•°ã‚’呼ã³å‡ºã—ã¾ã™ï¼ˆãŸã ã—ã€
-ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’æ­£ã—ã生æˆã™ã‚‹ãŸã‚ã«ãƒ¡ã‚½ãƒƒãƒ‰å‘¼ã³å‡ºã—ã®æƒ…報を付加ã—ã¦ã‹ã‚‰
-行ãªã„ã¾ã™ï¼‰ã€‚
-
-ã“ã®ãŸã‚ã€VM 用スタックを別途用æ„ã—ãŸã‚‚ã®ã®ã€ãƒ—ログラムã«ã‚ˆã£ã¦ã¯ãƒžã‚·ãƒ³
-スタックを使ã„切ã£ã¦ã—ã¾ã†å¯èƒ½æ€§ãŒã‚りã¾ã™ï¼ˆC -> Ruby -> C -> ... ã¨ã„ã†
-呼ã³å‡ºã—ãŒç¶šã„ãŸå ´åˆï¼‰ã€‚ã“れã¯ã€ç¾åœ¨ã§ã¯é¿ã‘られãªã„仕様ã¨ãªã£ã¦ã„ã¾ã™ã€‚
-
-
-** 例外
-
-例外ã¯ã€Java ã® JVM ã¨åŒæ§˜ã«ä¾‹å¤–テーブルを用æ„ã™ã‚‹ã“ã¨ã§å®Ÿç¾ã—ã¾ã™ã€‚例外
-ãŒç™ºç”Ÿã—ãŸã‚‰ã€å½“該フレームをã€ä¾‹å¤–テーブルを検査ã—ã¾ã™ã€‚ãã“ã§ã€ä¾‹å¤–ãŒç™º
-生ã—ãŸã¨ãã® PC ã®å€¤ã«åˆè‡´ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªãŒã‚ã£ãŸå ´åˆã€ãã®ã‚¨ãƒ³ãƒˆãƒªã«å¾“ã£ã¦
-動作ã—ã¾ã™ã€‚ã‚‚ã—エントリãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸå ´åˆã€ã‚¹ã‚¿ãƒƒã‚¯ã‚’æ’’ãæˆ»ã—ã¦ã¾ãŸ
-åŒæ§˜ã«ãã®ã‚¹ã‚³ãƒ¼ãƒ—ã®ä¾‹å¤–テーブルを検査ã—ã¾ã™ã€‚
-
-ã¾ãŸã€breakã€return(ブロック中)ã€retry ãªã©ã‚‚åŒæ§˜ã®ä»•組ã¿ã§å®Ÿç¾ã—ã¾ã™ã€‚
-
-*** 例外テーブル
-
-例外テーブルエントリã¯å…·ä½“çš„ã«ã¯æ¬¡ã®æƒ…å ±ãŒæ ¼ç´ã•れã¦ã„ã¾ã™ã€‚
-
-- 対象ã¨ã™ã‚‹ PC ã®ç¯„囲
-- 対象ã¨ã™ã‚‹ä¾‹å¤–ã®ç¨®é¡ž
-- ã‚‚ã—対象ã¨ãªã£ãŸã¨ãã«ã‚¸ãƒ£ãƒ³ãƒ—ã™ã‚‹å…ˆï¼ˆç¨®é¡žã«ã‚ˆã‚‹ï¼‰
-- ã‚‚ã—対象ã¨ãªã£ãŸã¨ãã«èµ·å‹•ã™ã‚‹ãƒ–ロック㮠iseq
-
-
-*** rescue
-
-rescue 節ã¯ãƒ–ロックã¨ã—ã¦å®Ÿç¾ã—ã¦ã„ã¾ã™ã€‚$! ã®å€¤ã‚’唯一ã®å¼•æ•°ã¨ã—ã¦æŒã¡ã¾
-ã™ã€‚
-
-#code
-begin
-rescue A
-rescue B
-rescue C
-end
-#end
-
-ã¯ã€æ¬¡ã®ã‚ˆã†ãª Ruby スクリプトã«å¤‰æ›ã•れã¾ã™ã€‚
-
-#code
-{|err|
- case err
- when A === err
- when B === err
- when C === err
- else
- raise # yarv ã®å‘½ä»¤ã§ã¯ throw
- end
-}
-#end
-
-
-*** ensure
-
-正常系(例外ãŒç™ºç”Ÿã—ãªã‹ã£ãŸå ´åˆï¼‰ã¨ç•°å¸¸ç³»ï¼ˆä¾‹å¤–ãŒç™ºç”Ÿã—ãŸã¨ããªã©ï¼‰ã®2
-種類ã®å‘½ä»¤åˆ—ãŒç”Ÿæˆã•れã¾ã™ã€‚正常系ã§ã¯ã€ãŸã ã®é€£ç¶šã—ãŸã‚³ãƒ¼ãƒ‰é ˜åŸŸã¨ã—ã¦ã‚³
-ンパイルã•れã¾ã™ã€‚ã¾ãŸã€ç•°å¸¸ç³»ã§ã¯ãƒ–ロックã¨ã—ã¦å®Ÿè£…ã—ã¾ã™ã€‚最後ã¯å¿…ãš
-throw 命令ã§ç· ã‚ã‚‹ã“ã¨ã«ãªã‚Šã¾ã™ã€‚
-
-
-*** break, return(ブロック中)ã€retry
-
-break æ–‡ã€ãƒ–ロック中㮠return æ–‡ã€retry 文㯠throw 命令ã¨ã—ã¦ã‚³ãƒ³ãƒ‘イル
-ã•れã¾ã™ã€‚ã©ã“ã¾ã§æˆ»ã‚‹ã‹ã¯ã€break をフックã™ã‚‹ä¾‹å¤–テーブルã®ã‚¨ãƒ³ãƒˆãƒªãŒåˆ¤
-æ–­ã—ã¾ã™ã€‚
-
-
-** å®šæ•°ã®æ¤œç´¢
-
-定数ã¨ã„ã†åå‰ãªã®ã«ã€Ruby ã§ã¯ã‚³ãƒ³ãƒ‘ã‚¤ãƒ«æ™‚ã«æ±ºå®šã—ã¾ã›ã‚“。ã¨ã„ã†ã‹ã€ã„
-ã¤ã¾ã§ã‚‚å†å®šç¾©å¯èƒ½ã«ãªã£ã¦ã„ã¾ã™ã€‚
-
-定数アクセスã®ãŸã‚ã®Rubyè¨˜è¿°ã¯æ¬¡ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚
-
-#code
-Ruby表ç¾:
-expr::ID::...::ID
-#end
-
-ã“れã¯ã€yarv命令セットã§ã¯æ¬¡ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚
-
-#code
-(expr)
-getconstant ID
-...
-getconstant ID
-#end
-
-
-*** 定数検索パス
-
-ã‚‚ã— expr ㌠nil ã ã£ãŸå ´åˆã€å®šæ•°æ¤œç´¢ãƒ‘スã«å¾“ã£ã¦å®šæ•°ã‚’検索ã—ã¾ã™ã€‚ã“ã®
-挙動ã¯ä»Šå¾Œ Ruby 2.0 ã«å‘ã‘ã¦å¤‰æ›´ã•れる場åˆãŒã‚りã¾ã™ã€‚
-
-+ クラスã€ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã®å‹•çš„ãƒã‚¹ãƒˆé–¢ä¿‚(プログラムã®å­—é¢ä¸Šï¼‰ã‚’ルートã¾ã§è¾¿ã‚‹
-+ 継承関係をルート(Object)ã¾ã§è¾¿ã‚‹
-
-ã“ã®ãŸã‚ã€ã‚¯ãƒ©ã‚¹ã€ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã®å‹•çš„ãƒã‚¹ãƒˆé–¢ä¿‚ã‚’ä¿å­˜ã—ãªã‘れã°ãªã‚Šã¾ã›ã‚“。
-ã“ã®ãŸã‚ã«ã€thread_object ã«ã¯ klass_nest_stack ã¨ã„ã†ã‚‚ã®ã‚’用æ„ã—ã¾ã—ãŸã€‚
-ã“れã¯ã€ç¾åœ¨ã®ãƒã‚¹ãƒˆã®æƒ…報をä¿å­˜ã—ã¾ã™ã€‚
-
-メソッド定義時ã€ãã®ç¾åœ¨ã®ãƒã‚¹ãƒˆæƒ…報をメソッド定義時ã«ï¼ˆdupã—ã¦ï¼‰åŠ ãˆã‚‹
-ã“ã¨ã§ã€ãã®ãƒ¡ã‚½ãƒƒãƒ‰ã®å®Ÿè¡Œæ™‚ã€ãã®ãƒã‚¹ãƒˆæƒ…報をå‚ç…§ã™ã‚‹ã“ã¨ãŒå¯èƒ½ã«ãªã‚Šã¾
-ã™ã€‚
-
-トップレベルã§ã¯ã€ãã®æƒ…å ±ã¯ãªã„ã“ã¨ã«ãªã‚Šã¾ã™ã€‚
-
-クラス/モジュール定義文実行時ã¯ã€ç¾åœ¨ã®æƒ…å ±ãã®ã‚‚ã®ã‚’å‚ç…§ã™ã‚‹ã“ã¨ã«ãªã‚Š
-ã¾ã™ã€‚ã“れã¯ã€ã‚¯ãƒ©ã‚¹ã‚¹ã‚³ãƒ¼ãƒ—çªå…¥æ™‚ã€ãã®æƒ…報をクラス定義文ã«ã‚³ãƒ”ーã—ã¾ã™
-(ã™ã§ã«ã‚³ãƒ”ーã•れã¦ã„れã°ã€ã“れを行ã„ã¾ã›ã‚“)。
-
-ã“れã«ã‚ˆã‚Šã€å‹•çš„ãªãƒã‚¹ãƒˆæƒ…å ±ã‚’çµ±ä¸€çš„ã«æ‰±ã†ã“ã¨ãŒã§ãã¾ã™ã€‚
-
-
-** 最é©åŒ–手法
-
-YARV ã§ã¯é«˜é€ŸåŒ–を目的ã¨ã—ã¦ã„ã‚‹ã®ã§ã€ã•ã¾ã–ã¾ãªæœ€é©åŒ–手法を利用ã—ã¦ã„ã¾
-ã™ã€‚詳細ã¯å‰²æ„›ã—ã¾ã™ãŒã€ä»¥ä¸‹ã«è¿°ã¹ã‚‹æœ€é©åŒ–ãªã©ã‚’行ãªã£ã¦ãŠã‚Šã¾ã™ã€‚
-
-
-*** threaded code
-
-GCC ã® C 言語拡張ã§ã‚る値ã¨ã—ã¦ã®ãƒ©ãƒ™ãƒ«ã‚’利用ã—㦠direct threaded code
-を実ç¾ã—ã¦ã„ã¾ã™ã€‚
-
-
-*** Peephole optimization
-
-ã„ãã¤ã‹ã®ç°¡å˜ãªæœ€é©åŒ–ã‚’ã—ã¦ã„ã¾ã™ã€‚
-
-
-*** inline method cache
-
-命令列ã®ä¸­ã«ãƒ¡ã‚½ãƒƒãƒ‰æ¤œç´¢çµæžœã‚’埋ã‚è¾¼ã¿ã¾ã™ã€‚
-
-
-*** inline constant cache
-
-命令列ã®ä¸­ã«å®šæ•°æ¤œç´¢çµæžœã‚’埋ã‚è¾¼ã¿ã¾ã™ã€‚
-
-
-*** ブロック㨠Proc オブジェクトã®åˆ†é›¢
-
-ブロック付ãメソッド呼ã³å‡ºã—ãŒè¡Œãªã‚れãŸã¨ãã«ã¯ã™ãã«ã¯ãƒ–ロックを Proc
-オブジェクトã¨ã—ã¦ç”Ÿæˆã—ã¾ã›ã‚“。ã“れã«ã‚ˆã‚Šã€å¿…è¦ãªã„ Proc オブジェクトã®
-生æˆã‚’抑ãˆã¦ã„ã¾ã™ã€‚
-
-Proc メソッドã¯ã€å®Ÿéš›ã«å¿…è¦ã«ãªã£ãŸæ™‚点ã§ä½œã‚‰ã‚Œã€ãã®ã¨ãã«ç’°å¢ƒï¼ˆã‚¹ã‚³ãƒ¼
-プ上ã«ç¢ºä¿ã•れãŸå¤‰æ•°ãªã©ï¼‰ã‚’ヒープã«ä¿å­˜ã—ã¾ã™ã€‚
-
-
-*** 特化命令
-
-Fixnum åŒå£«ã®åŠ ç®—ãªã©ã‚’正直ã«é–¢æ•°å‘¼ã³å‡ºã—ã«ã‚ˆã£ã¦è¡Œãªã†ã¨ã€ã‚³ã‚¹ãƒˆãŒã‹ã‹
-ã‚‹ã®ã§ã€ã“れらã®ãƒ—ãƒªãƒŸãƒ†ã‚£ãƒ–ãªæ“作を行ãªã†ãŸã‚ã®ãƒ¡ã‚½ãƒƒãƒ‰å‘¼ã³å‡ºã—ã¯å°‚用命
-令を用æ„ã—ã¾ã—ãŸã€‚
-
-
-*** 命令èžåˆ
-
-複数ã®å‘½ä»¤ã‚’ 1 命令ã«å¤‰æ›ã—ã¾ã™ã€‚èžåˆå‘½ä»¤ã¯ opt_insn_unif.def ã®è¨˜è¿°ã«ã‚ˆ
-り自動的ã«ç”Ÿæˆã•れã¾ã™ã€‚
-
-
-*** オペランドèžåˆ
-
-複数ã®ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã‚’å«ã‚ãŸå‘½ä»¤ã‚’生æˆã—ã¾ã™ã€‚èžåˆå‘½ä»¤ã¯ opt_operand.def ã®
-記述ã«ã‚ˆã£ã¦è‡ªå‹•çš„ã«ç”Ÿæˆã•れã¾ã™ã€‚
-
-
-*** stack caching
-
-スタックトップを仮想レジスタã«ä¿æŒã™ã‚‹ã‚ˆã†ã«ã—ã¾ã™ã€‚ç¾åœ¨ã¯ 2 個ã®ä»®æƒ³ãƒ¬
-ジスタを想定ã—ã€5状態ã®ã‚¹ã‚¿ãƒƒã‚¯ã‚­ãƒ£ãƒƒã‚·ãƒ³ã‚°ã‚’行ãªã„ã¾ã™ã€‚スタックキャッ
-シングã™ã‚‹å‘½ä»¤ã¯è‡ªå‹•çš„ã«ç”Ÿæˆã•れã¾ã™ã€‚
-
-
-*** JIT Compile
-
-機械語を切り貼りã—ã¾ã™ã€‚éžå¸¸ã«å®Ÿé¨“çš„ãªã‚³ãƒ¼ãƒ‰ã‚‚ã®ã—ã‹ä½œã£ã¦ãŠã‚Šã¾ã›ã‚“。ã»
-ã¨ã‚“ã©ã®ãƒ—ログラムã¯å‹•ãã¾ã›ã‚“。
-
-
-*** AOT Compile
-
-YARV 命令列を C 言語ã«å¤‰æ›ã—ã¾ã™ã€‚ã¾ã ååˆ†ãªæœ€é©åŒ–を行ãªãˆã¦ãŠã‚Šã¾ã›ã‚“ãŒã€
-ãれãªã‚Šã«å‹•ãã¾ã™ã€‚rb/aotc.rb ãŒã‚³ãƒ³ãƒ‘イラã§ã™ã€‚
-
-
-* Assembler (rb/yasm.rb)
-
-YARV 命令列ã®ã‚¢ã‚»ãƒ³ãƒ–ラを用æ„ã—ã¾ã—ãŸã€‚ä½¿ã„æ–¹ã¯ rb/yasm.rb ã‚’å‚ç…§ã—ã¦ã
-ã ã•ã„(ã¾ã ã€ä¾‹ç¤ºã—ã¦ã‚ã‚‹ç”Ÿæˆæ‰‹æ³•ã®ã™ã¹ã¦ã‚’サãƒãƒ¼ãƒˆã—ã¦ã„ã‚‹ã‚ã‘ã§ã¯ã‚り
-ã¾ã›ã‚“)。
-
-
-* Dis-Assembler (disasm.c)
-
-YARV 命令列を示ã™ã‚ªãƒ–ジェクト YARVCore::InstructionSequence ã«ã¯ disasm
-メソッドãŒã‚りã¾ã™ã€‚ã“れã¯ã€å‘½ä»¤åˆ—を逆アセンブルã—ãŸæ–‡å­—列を返ã—ã¾ã™ã€‚
-
-
-* YARV 命令セット
-
-<%= d %>
-
-* ãã®ä»–
-
-** テスト
-
-test/test_* ãŒãƒ†ã‚¹ãƒˆã‚±ãƒ¼ã‚¹ã§ã™ã€‚一応ã€ãƒŸã‚¹ãªãå‹•ãã¯ãšã§ã™ã€‚逆ã«ã„ã†ã¨ã€
-ã“ã®ãƒ†ã‚¹ãƒˆã«è¨˜è¿°ã•れã¦ã„る例ã§ã¯ãã¡ã‚“ã¨å‹•作ã™ã‚‹ã¨ã„ã†ã“ã¨ã§ã™ã€‚
-
-
-** ベンãƒãƒžãƒ¼ã‚¯
-
-benchmark/bm_* ã«ãƒ™ãƒ³ãƒãƒžãƒ¼ã‚¯ãƒ—ログラムãŒãŠã„ã¦ã‚りã¾ã™ã€‚
-
-
-** 今後ã®äºˆå®š
-
-ã¾ã ã¾ã ã‚„らãªã‘れã°ã„ã‘ãªã„ã“ã¨ã€æœªå®Ÿè£…部分ãŒãŸãã•ã‚“ã‚りã¾ã™ã‚“ã§ã‚„ã£ã¦
-ã„ã‹ãªã‘れã°ãªã‚Šã¾ã›ã‚“。一番大ããªç›®æ¨™ã¯ eval.c ã‚’ç½®ãæ›ãˆã‚‹ã“ã¨ã§ã—ょã†
-ã‹ã€‚
-
-
-*** Verifier
-
-YARV 命令列ã¯ã€ãƒŸã‚¹ãŒã‚ã£ã¦ã‚‚å‹•ã‹ã—ã¦ã—ã¾ã†ãŸã‚å±é™ºã§ã‚ã‚‹å¯èƒ½æ€§ãŒã‚りã¾
-ã™ã€‚ãã®ãŸã‚ã€ã‚¹ã‚¿ãƒƒã‚¯ã®åˆ©ç”¨çŠ¶æ…‹ã‚’ãã¡ã‚“ã¨äº‹å‰ã«æ¤œè¨¼ã™ã‚‹ã‚ˆã†ãªãƒ™ãƒªãƒ•ァイ
-アを用æ„ã—ãªã‘れã°ãªã‚‰ãªã„ã¨è€ƒãˆã¦ã„ã¾ã™ã€‚
-
-
-*** Compiled File ã®æ§‹æƒ³
-
-Ruby プログラムをã“ã®å‘½ä»¤ã‚»ãƒƒãƒˆã«ã‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºã—ãŸãƒ‡ãƒ¼ã‚¿æ§‹é€ ã‚’ファイルã«
-出力ã§ãるよã†ã«ã—ãŸã„ã¨è€ƒãˆã¦ã„ã¾ã™ã€‚ã“れを利用ã—ã¦ä¸€åº¦ã‚³ãƒ³ãƒ‘イルã—ãŸå‘½
-令列をファイルã«ä¿å­˜ã—ã¦ãŠã‘ã°ã€æ¬¡å›žãƒ­ãƒ¼ãƒ‰æ™‚ã«ã¯ã‚³ãƒ³ãƒ‘ã‚¤ãƒ«ã®æ‰‹é–“ã€ã‚³ã‚¹ãƒˆ
-ã‚’çœãã“ã¨ãŒã§ãã¾ã™ã€‚
-
-
-**** 全体構æˆ
-
-次ã®ã‚ˆã†ãªãƒ•ァイル構æˆã‚’考ãˆã¦ã„ã¾ã™ãŒã€ã¾ã æœªå®šã§ã™ã€‚
-
-#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 ã®ãƒ‘クリ。
-
diff --git a/doc/yjit/yjit.md b/doc/yjit/yjit.md
deleted file mode 100644
index b3607cf8f0..0000000000
--- a/doc/yjit/yjit.md
+++ /dev/null
@@ -1,360 +0,0 @@
-<p align="center">
- <a href="https://yjit.org/" target="_blank" rel="noopener noreferrer">
- <img src="https://user-images.githubusercontent.com/224488/131155756-aa8fb528-a813-4dfd-99ac-8785c3d5eed7.png" width="400">
- </a>
-</p>
-
-
-YJIT - Yet Another Ruby JIT
-===========================
-
-YJIT is a lightweight, minimalistic Ruby JIT built inside CRuby.
-It lazily compiles code using a Basic Block Versioning (BBV) architecture.
-The target use case is that of servers running Ruby on Rails.
-YJIT is currently supported for macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs.
-This project is open source and falls under the same license as CRuby.
-
-<p align="center"><b>
- If you're using YJIT in production, please
- <a href="mailto:maxime.chevalierboisvert@shopify.com">share your success stories with us!</a>
- </b></p>
-
-If you wish to learn more about the approach taken, here are some conference talks and publications:
-- RubyKaigi 2022 keynote: [Stories from developing YJIT](https://www.youtube.com/watch?v=EMchdR9C8XM)
-- RubyKaigi 2022 talk: [Building a Lightweight IR and Backend for YJIT](https://www.youtube.com/watch?v=BbLGqTxTRp0)
-- RubyKaigi 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=PBVLf3yfMs8)
-- Blog post: [YJIT: Building a New JIT Compiler Inside CRuby](https://pointersgonewild.com/2021/06/02/yjit-building-a-new-jit-compiler-inside-cruby/)
-- VMIL 2021 paper: [YJIT: A Basic Block Versioning JIT Compiler for CRuby](https://dl.acm.org/doi/10.1145/3486606.3486781)
-- MoreVMs 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=vucLAqv7qpc)
-- ECOOP 2016 talk: [Interprocedural Type Specialization of JavaScript Programs Without Type Analysis](https://www.youtube.com/watch?v=sRNBY7Ss97A)
-- ECOOP 2016 paper: [Interprocedural Type Specialization of JavaScript Programs Without Type Analysis](https://drops.dagstuhl.de/opus/volltexte/2016/6101/pdf/LIPIcs-ECOOP-2016-7.pdf)
-- ECOOP 2015 talk: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://www.youtube.com/watch?v=S-aHBuoiYE0)
-- ECOOP 2015 paper: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://arxiv.org/pdf/1411.0352.pdf)
-
-To cite YJIT in your publications, please cite the VMIL 2021 paper:
-
-```
-@inproceedings{yjit_vmil2021,
-author = {Chevalier-Boisvert, Maxime and Gibbs, Noah and Boussier, Jean and Wu, Si Xing (Alan) and Patterson, Aaron and Newton, Kevin and Hawthorn, John},
-title = {YJIT: A Basic Block Versioning JIT Compiler for CRuby},
-year = {2021},
-isbn = {9781450391092},
-publisher = {Association for Computing Machinery},
-address = {New York, NY, USA},
-url = {https://doi.org/10.1145/3486606.3486781},
-doi = {10.1145/3486606.3486781},
-booktitle = {Proceedings of the 13th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages},
-pages = {25–32},
-numpages = {8},
-keywords = {ruby, dynamically typed, compiler, optimization, just-in-time, bytecode},
-location = {Chicago, IL, USA},
-series = {VMIL 2021}
-}
-```
-
-## Current Limitations
-
-YJIT may not be suitable for certain applications. It currently only supports macOS and Linux on x86-64 and arm64/aarch64 CPUs. YJIT will use more memory than the Ruby interpreter because the JIT compiler needs to generate machine code in memory and maintain additional state
-information.
-You can change how much executable memory is allocated using [YJIT's command-line options](#command-line-options). There is a slight performance tradeoff because allocating less executable memory could result in the generated machine code being collected more often.
-
-## Installation
-
-### Requirements
-
-You will need to install:
-- A C compiler such as GCC or Clang
-- GNU Make and Autoconf
-- The Rust compiler `rustc` and Cargo (if you want to build in dev/debug mode)
- - The Rust version must be [>= 1.58.0](../../yjit/Cargo.toml).
-
-To install the Rust build toolchain, we suggest following the [recommended installation method][rust-install]. Rust also provides first class [support][editor-tools] for many source code editors.
-
-[rust-install]: https://www.rust-lang.org/tools/install
-[editor-tools]: https://www.rust-lang.org/tools
-
-### Building YJIT
-
-Start by cloning the `ruby/ruby` repository:
-
-```sh
-git clone https://github.com/ruby/ruby yjit
-cd yjit
-```
-
-The YJIT `ruby` binary can be built with either GCC or Clang. It can be built either in dev (debug) mode or in release mode. For maximum performance, compile YJIT in release mode with GCC. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-compile-and-install).
-
-```sh
-# Configure in release mode for maximum performance, build and install
-./autogen.sh
-./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
-```
-
-or
-
-```sh
-# Configure in dev (debug) mode for development, build and install
-./autogen.sh
-./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
-```
-
-On macOS, you may need to specify where to find some libraries:
-
-```sh
-# Install dependencies
-brew install openssl readline libyaml
-
-# Configure in dev (debug) mode for development, build and install
-./autogen.sh
-./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
-make -j install
-```
-
-Typically configure will choose the default C compiler. To specify the C compiler, use
-
-```sh
-# Choosing a specific c compiler
-export CC=/path/to/my/chosen/c/compiler
-```
-
-before running `./configure`.
-
-You can test that YJIT works correctly by running:
-
-```sh
-# Quick tests found in /bootstraptest
-make btest
-
-# Complete set of tests
-make -j test-all
-```
-
-## Usage
-
-### Examples
-
-Once YJIT is built, you can either use `./miniruby` from within your build directory, or switch to the YJIT version of `ruby`
-by using the `chruby` tool:
-
-```sh
-chruby ruby-yjit
-ruby myscript.rb
-```
-
-You can dump statistics about compilation and execution by running YJIT with the `--yjit-stats` command-line option:
-
-```sh
-./miniruby --yjit-stats myscript.rb
-```
-
-The machine code generated for a given method can be printed by adding `puts RubyVM::YJIT.disasm(method(:method_name))` to a Ruby script. Note that no code will be generated if the method is not compiled.
-
-### Command-Line Options
-
-YJIT supports all command-line options supported by upstream CRuby, but also adds a few YJIT-specific options:
-
-- `--yjit`: enable YJIT (disabled by default)
-- `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function (default 30)
-- `--yjit-exec-mem-size=N`: size of the executable memory block to allocate, in MiB (default 64 MiB)
-- `--yjit-stats`: produce statistics after the execution of a program (incurs a run-time cost)
-- `--yjit-trace-exits`: produce a Marshal dump of backtraces from specific exits. Automatically enables `--yjit-stats` (must configure and build with `--enable-yjit=stats` to use this)
-- `--yjit-max-versions=N`: maximum number of versions to generate per basic block (default 4)
-- `--yjit-greedy-versioning`: greedy versioning mode (disabled by default, may increase code size)
-
-Note that there is also an environment variable `RUBY_YJIT_ENABLE` which can be used to enable YJIT.
-This can be useful for some deployment scripts where specifying an extra command-line option to Ruby is not practical.
-
-You can verify that YJIT is enabled by checking that `ruby -v --yjit` includes the string `+YJIT`:
-
-```sh
-ruby -v --yjit
-ruby 3.3.0dev (2023-01-31T15:11:10Z master 2a0bf269c9) +YJIT dev [x86_64-darwin22]
-```
-
-### Benchmarking
-
-We have collected a set of benchmarks and implemented a simple benchmarking harness in the [yjit-bench](https://github.com/Shopify/yjit-bench) repository. This benchmarking harness is designed to disable CPU frequency scaling, set process affinity and disable address space randomization so that the variance between benchmarking runs will be as small as possible. Please kindly note that we are at an early stage in this project.
-
-### Performance Tips
-
-This section contains tips on writing Ruby code that will run as fast as possible on YJIT. Some of this advice is based on current limitations of YJIT, while other advice is broadly applicable. It probably won't be practical to apply these tips everywhere in your codebase. You should ideally start by profiling your application using a tool such as [stackprof](https://github.com/tmm1/stackprof) so that you can determine which methods make up most of the execution time. You can then refactor the specific methods that make up the largest fractions of the execution time. We do not recommend modifying your entire codebase based on the current limitations of YJIT.
-
-- Use exceptions for error recovery only, not as part of normal control-flow
-- Avoid redefining basic integer operations (i.e. +, -, <, >, etc.)
-- Avoid redefining the meaning of `nil`, equality, etc.
-- Avoid allocating objects in the hot parts of your code
-- Minimize layers of indirection
- - Avoid classes that wrap objects if you can
- - Avoid methods that just call another method, trivial one liner methods
-- Try to write code so that the same variables always have the same type
-- Use while loops if you can, instead of `integer.times`
- - This is not idiomatic Ruby, but could help in hot methods
-- CRuby method calls are costly. Avoid things such as methods that only return a value from a hash or return a constant.
-
-You can also use the `--yjit-stats` command-line option to see which bytecodes cause YJIT to exit, and refactor your code to avoid using these instructions in the hottest methods of your code.
-
-### Other Statistics
-
-If you compile Ruby with `RUBY_DEBUG` and/or `YJIT_STATS` defined and run with `--yjit --yjit-stats`, YJIT will track and return performance statistics in `RubyVM::YJIT.runtime_stats`.
-
-```rb
-$ RUBYOPT="--yjit --yjit-stats" irb
-irb(main):001:0> RubyVM::YJIT.runtime_stats
-=>
-{:inline_code_size=>340745,
- :outlined_code_size=>297664,
- :all_stats=>true,
- :exec_instruction=>1547816,
- :send_callsite_not_simple=>7267,
- :send_kw_splat=>7,
- :send_ivar_set_method=>72,
-...
-```
-
-Some of the counters include:
-
-:exec_instruction - how many Ruby bytecode instructions have been executed
-:binding_allocations - number of bindings allocated
-:binding_set - number of variables set via a binding
-:vm_insns_count - number of instructions executed by the Ruby interpreter
-:compiled_iseq_count - number of bytecode sequences compiled
-
-Counters starting with "exit_" show reasons for YJIT code taking a side exit (return to the interpreter.) See yjit_hacking.md for more details.
-
-Performance counter names are not guaranteed to remain the same between Ruby versions. If you're curious what one does, it's usually best to search the source code for it &mdash; but it may change in a later Ruby version.
-
-## Contributing
-
-We welcome open source contributors. You should feel free to open new issues to report bugs or just to ask questions.
-Suggestions on how to make this readme file more helpful for new contributors are most welcome.
-
-Bug fixes and bug reports are very valuable to us. If you find a bug in YJIT, it's very possible be that nobody has reported it before,
-or that we don't have a good reproduction for it, so please open an issue and provide as much information as you can about your configuration and a description of how you encountered the problem. List the commands you used to run YJIT so that we can easily reproduce the issue on our end and investigate it. If you are able to produce a small program reproducing the error to help us track it down, that is very much appreciated as well.
-
-If you would like to contribute a large patch to YJIT, we suggest opening an issue or a discussion on this repository so that
-we can have an active discussion. A common problem is that sometimes people submit large pull requests to open source projects
-without prior communication, and we have to reject them because the work they implemented does not fit within the design of the
-project. We want to save you time and frustration, so please reach out and we can have a productive discussion as to how
-you can contribute things we will want to merge into YJIT.
-
-### Source Code Organization
-
-The YJIT source code is divided between:
-- `yjit.c`: code YJIT uses to interface with the rest of CRuby
-- `yjit.h`: C definitions YJIT exposes to the rest of the CRuby
-- `yjit.rb`: `YJIT` Ruby module that is exposed to Ruby
-- `yjit/src/asm/*`: in-memory assembler we use to generate machine code
-- `yjit/src/codegen.rs`: logic for translating Ruby bytecode to machine code
-- `yjit/src/core.rb`: basic block versioning logic, core structure of YJIT
-- `yjit/src/stats.rs`: gathering of run-time statistics
-- `yjit/src/options.rs`: handling of command-line options
-- `yjit/bindgen/src/main.rs`: C bindings exposed to the Rust codebase through bindgen
-- `yjit/src/cruby.rs`: C bindings manually exposed to the Rust codebase
-
-The core of CRuby's interpreter logic is found in:
-- `insns.def`: defines Ruby's bytecode instructions (gets compiled into `vm.inc`)
-- `vm_insnshelper.c`: logic used by Ruby's bytecode instructions
-- `vm_exec.c`: Ruby interpreter loop
-
-### Generating C bindings with bindgen
-
-In order to expose C functions to the Rust codebase, you will need to generate C bindings:
-
-```sh
-CC=clang ./configure --enable-yjit=dev
-make -j yjit-bindgen
-```
-
-This uses the bindgen tools to generate/update `yjit/src/cruby_bindings.inc.rs` based on the
-bindings listed in `yjit/bindgen/src/main.rs`. Avoid manually editing this file
-as it could be automatically regenerated at a later time. If you need to manually add C bindings,
-add them to `yjit/cruby.rs` instead.
-
-### Coding & Debugging Protips
-
-There are 3 test suites:
-- `make btest` (see `/bootstraptest`)
-- `make test-all`
-- `make test-spec`
-- `make check` runs all of the above
-
-The tests can be run in parallel like this:
-
-```sh
-make -j test-all RUN_OPTS="--yjit-call-threshold=1"
-```
-
-Or single-threaded like this, to more easily identify which specific test is failing:
-
-```sh
-make test-all TESTOPTS=--verbose RUN_OPTS="--yjit-call-threshold=1"
-```
-
-To debug a single test in `test-all`:
-
-```sh
-make test-all TESTS='test/-ext-/marshal/test_usrmarshal.rb' RUNRUBYOPT=--debugger=lldb RUN_OPTS="--yjit-call-threshold=1"
-```
-
-You can also run one specific test in `btest`:
-
-```sh
-make btest BTESTS=bootstraptest/test_ractor.rb RUN_OPTS="--yjit-call-threshold=1"
-```
-
-There are shortcuts to run/debug your own test/repro in `test.rb`:
-
-```sh
-make run # runs ./miniruby test.rb
-make lldb # launches ./miniruby test.rb in lldb
-```
-
-You can use the Intel syntax for disassembly in LLDB, keeping it consistent with YJIT's disassembly:
-
-```sh
-echo "settings set target.x86-disassembly-flavor intel" >> ~/.lldbinit
-```
-
-## Running x86 YJIT on Apple's Rosetta
-
-For development purposes, it is possible to run x86 YJIT on an Apple M1 via Rosetta. You can find basic
-instructions below, but there are a few caveats listed further down.
-
-First, install Rosetta:
-
-```sh
-$ softwareupdate --install-rosetta
-```
-
-Now any command can be run with Rosetta via the `arch` command line tool.
-
-Then you can start your shell in an x86 environment:
-
-```sh
-$ arch -x86_64 zsh
-```
-
-You can double check your current architecture via the `arch` command:
-
-```sh
-$ arch -x86_64 zsh
-$ arch
-i386
-```
-
-You may need to set the default target for `rustc` to x86-64, e.g.
-
-```sh
-$ rustup default stable-x86_64-apple-darwin
-```
-
-While in your i386 shell, install Cargo and Homebrew, then hack away!
-
-### Rosetta Caveats
-
-1. You must install a version of Homebrew for each architecture
-2. Cargo will install in $HOME/.cargo by default, and I don't know a good way to change architectures after install
-
-If you use Fish shell you can [read this link](https://tenderlovemaking.com/2022/01/07/homebrew-rosetta-and-ruby.html) for information on making the dev environment easier.
diff --git a/doc/yjit/yjit_hacking.md b/doc/yjit/yjit_hacking.md
deleted file mode 100644
index 4c4d742b73..0000000000
--- a/doc/yjit/yjit_hacking.md
+++ /dev/null
@@ -1,75 +0,0 @@
-# YJIT Hacking
-
-## Code Generation and Assembly Language
-
-YJIT’s basic purpose is to take ISEQs and generate machine code.
-
-Documentation on each Ruby bytecode can be found in insns.def.
-
-YJIT uses those bytecodes as the “Basic Blocks†in Lazy Basic Block Versioning (LBBV.) For more deep details of LBBV, see yjit.md in this directory.
-
-Current YJIT has a simple assembler as a backend. Each method that generates code does it by emitting machine code:
-
-```
-# Excerpt of yjit_gen_exit() from yjit_codegen.c, Sept 2021
-// Generate an exit to return to the interpreter
-static uint32_t
-yjit_gen_exit(VALUE *exit_pc, ctx_t *ctx, codeblock_t *cb)
-{
- const uint32_t code_pos = cb->write_pos;
-
- ADD_COMMENT(cb, "exit to interpreter");
-
- // Generate the code to exit to the interpreters
- // Write the adjusted SP back into the CFP
- if (ctx->sp_offset != 0) {
- x86opnd_t stack_pointer = ctx_sp_opnd(ctx, 0);
- lea(cb, REG_SP, stack_pointer);
- mov(cb, member_opnd(REG_CFP, rb_control_frame_t, sp), REG_SP);
- }
-
- // Update CFP->PC
- mov(cb, RAX, const_ptr_opnd(exit_pc));
- mov(cb, member_opnd(REG_CFP, rb_control_frame_t, pc), RAX);
-```
-
-Later there will be a more complex backend.
-
-## Code Generation vs Code Execution
-
-When you see lea() call above (“load effective address,â€) it’s not running the LEA x86 instruction. It’s generating an LEA instruction to the codeblock pointer in the first argument. It will execute that instruction later, when the codeblock gets executed.
-
-This is subtle because YJIT will often wait to compile the method until you’re about to run it -- that’s when it knows the most about what types of arguments the method will receive. So it’s a compile-time instruction, but often it will defer compile-time until just barely before runtime.
-
-The ctx structure tracks what is known at compile time about the arguments being passed into the Ruby bytecode. Often YJIT will “peek†at an expected type before it generates machine code.
-
-## Inlined and Outlined Code
-
-When YJIT is generating code, it needs a code pointer. In many cases it needs two, usually called “cb†(codeblock) and “ocb†(out-of-line codeblock.)
-
-cb is for “inlined†normal code and ocb is for “outline†code such as exits. Inlined code is normal generated code for Ruby operations, while outlined code is for unusual and error conditions, such as encountering an unexpected parameter type and exiting to the interpreter.
-
-The purpose of the outlined code block is to keep things we believe are going to be infrequent somewhere else. That way we can keep the code in the inline block more linear and compact. Linear code, with as few branches as possible, is more easily predicted by the CPU. An exception or unsupported operation will cause YJIT to generate outlined code to handle it.
-
-If you search for ocb in yjit_codegen.c, you can see some places where out-of-line code is generated.
-
-YJIT statistics are only gathered when RUBY_DEBUG or YJIT_STATS is true. In some cases the code to increment YJIT statistics will be generated out-of-line, especially if those statistics are gathered when a side exit happens.
-
-## Statistics and Comments
-
-When RUBY_DEBUG is defined to a true value, YJIT will emit comments into the generated machine code. This can make disassemblies a lot more readable. When RUBY_DEBUG or YJIT_STATS is defined and stats are active (--yjit-stats or export YJIT_STATS=1), code will be generated to collect statistics during the run, and a report will be printed when the process exits.
-
-## Entering and Exiting the Interpreter
-
-YJIT won’t generate machine code for an ISEQ until it’s been run a certain number of times (10 by default.) Then, the next time the interpreter would call that ISEQ, it will call the generated machine code version instead. If YJIT hits an unexpected or unsupported operation, it will return to the normal interpreter.
-
-If YJIT returns to the interpreter, the behaviour will be correct but slower. YJIT only optimises part of some operations - for instance, YJIT will not optimise a BMETHOD call yet.
-
-When the interpreter calls to a YJIT-optimised method again, control will return to YJIT’s generated machine code. The more time that’s spent in YJIT-generated code (“ratio in YJIT,â€) the more CPU time YJIT can save with its optimisations.
-
-## Side Exits
-
-When YJIT has compiled an ISEQ and is running it later, sometimes it will hit an unexpected condition. It might see a parameter of a different type than before, or square-brackets might be used on a hash when they were first used on an array. In those cases, the generated code will contain a call to return to the interpreter at runtime, called a “side exit.â€
-
-Side exits are generated as out-of-line code.
-
diff --git a/enc/Makefile.in b/enc/Makefile.in
index dd8ca1b528..2a3c45169f 100644
--- a/enc/Makefile.in
+++ b/enc/Makefile.in
@@ -24,13 +24,14 @@ OBJEXT = @OBJEXT@
LIBEXT = @LIBEXT@
EXEEXT = @EXEEXT@
TIMESTAMPDIR = $(EXTOUT)/.timestamp
-ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-trans.time
-ENC_TRANS_SO_D = $(TIMESTAMPDIR)/.enc-trans.so.time
+ENC_TRANS_D = $(TIMESTAMPDIR)/enc-trans.time
+ENC_TRANS_SO_D = $(TIMESTAMPDIR)/enc-trans-$(arch).time
BUILTIN_ENCS = enc/ascii.c enc/us_ascii.c\
enc/unicode.c enc/utf_8.c
BUILTIN_TRANSES = enc/trans/newline.trans
+BUILTIN_TRANS_CSRCS = $(BUILTIN_TRANSES:.trans=.c)
RUBY_SO_NAME = @RUBY_SO_NAME@
LIBRUBY = @LIBRUBY@
@@ -40,6 +41,7 @@ BUILTRUBY = $(topdir)/miniruby$(EXEEXT)
empty =
AR = @AR@
+LD = @LD@
CC = @CC@
ARFLAGS = @ARFLAGS@$(empty)
RANLIB = @RANLIB@
@@ -51,11 +53,12 @@ optflags = @optflags@
debugflags = @debugflags@
warnflags = @warnflags@
CCDLFLAGS = @CCDLFLAGS@
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir) @incflags@
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@ -DONIG_ENC_REGISTER=rb_enc_register
LDFLAGS = @LDFLAGS@
LDSHARED = @LDSHARED@
+POSTLINK = @POSTLINK@
ldflags = $(LDFLAGS)
dldflags = @DLDFLAGS@
extdldflags = @EXTDLDFLAGS@
@@ -70,6 +73,7 @@ WORKDIRS = @WORKDIRS@
NULLCMD = @NULLCMD@
RM = @RM@
+RMALL = @RMALL@
RMDIR = @RMDIR@
RMDIRS = @RMDIRS@
MAKEDIRS = @MAKEDIRS@
@@ -81,6 +85,9 @@ all:
make-workdir:
$(Q)$(MAKEDIRS) $(WORKDIRS)
+.PHONY: encs all modencs libencs enc libenc trans libtrans srcs
+.PHONY: clean distclean realclean clean-srcs
+
clean:
distclean: clean
diff --git a/enc/ascii.c b/enc/ascii.c
index ae7db97f25..4ba93f4feb 100644
--- a/enc/ascii.c
+++ b/enc/ascii.c
@@ -54,7 +54,11 @@ OnigEncodingDefine(ascii, ASCII) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
ENCINDEX_ASCII_8BIT,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/big5.c b/enc/big5.c
index ab4fb69819..e141ebdbe3 100644
--- a/enc/big5.c
+++ b/enc/big5.c
@@ -300,7 +300,11 @@ OnigEncodingDefine(big5, BIG5) = {
onigenc_not_support_get_ctype_code_range,
big5_left_adjust_char_head,
big5_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
@@ -335,7 +339,11 @@ OnigEncodingDefine(big5_hkscs, BIG5_HKSCS) = {
onigenc_not_support_get_ctype_code_range,
big5_left_adjust_char_head,
big5_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
@@ -370,7 +378,11 @@ OnigEncodingDefine(big5_uao, BIG5_UAO) = {
onigenc_not_support_get_ctype_code_range,
big5_left_adjust_char_head,
big5_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/cesu_8.c b/enc/cesu_8.c
index decbb928f4..75f62df280 100644
--- a/enc/cesu_8.c
+++ b/enc/cesu_8.c
@@ -42,6 +42,8 @@
#define VALID_CODE_LIMIT 0x0010ffff
#define utf8_islead(c) ((UChar )((c) & 0xc0) != 0x80)
+#define utf16_is_high_surrogate(v) ((v >> 10) == 0x36)
+#define utf16_is_low_surrogate(v) ((v >> 10) == 0x37)
static const int EncLen_CESU8[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -283,6 +285,12 @@ is_mbc_newline(const UChar* p, const UChar* end, OnigEncoding enc)
return 0;
}
+static int
+utf8_decode_3byte_sequence(const UChar* p)
+{
+ return ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
+}
+
static OnigCodePoint
mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
{
@@ -295,11 +303,11 @@ mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
case 2:
return ((p[0] & 0x1F) << 6) | (p[1] & 0x3f);
case 3:
- return ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
+ return utf8_decode_3byte_sequence(p);
case 6:
{
- int high = ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
- int low = ((p[3] & 0xF) << 12) | ((p[4] & 0x3f) << 6) | (p[5] & 0x3f);
+ int high = utf8_decode_3byte_sequence(p);
+ int low = utf8_decode_3byte_sequence(p + 3);
return ((high & 0x03ff) << 10) + (low & 0x03ff) + 0x10000;
}
}
@@ -410,7 +418,6 @@ get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out,
return onigenc_unicode_ctype_code_range(ctype, ranges);
}
-
static UChar*
left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)
{
@@ -420,6 +427,14 @@ left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, Onig
p = s;
while (!utf8_islead(*p) && p > start) p--;
+
+ if (p > start && s - p == 2 && utf16_is_low_surrogate(utf8_decode_3byte_sequence(p))) {
+ const UChar *p_surrogate_pair = p - 1;
+ while (!utf8_islead(*p_surrogate_pair) && p_surrogate_pair > start) p_surrogate_pair--;
+ if (p - p_surrogate_pair == 3 && utf16_is_high_surrogate(utf8_decode_3byte_sequence(p_surrogate_pair))) {
+ return (UChar* )p_surrogate_pair;
+ }
+ }
return (UChar* )p;
}
diff --git a/enc/cp949.c b/enc/cp949.c
index 1600d0cd5b..77e961a7cd 100644
--- a/enc/cp949.c
+++ b/enc/cp949.c
@@ -211,7 +211,11 @@ OnigEncodingDefine(cp949, CP949) = {
onigenc_not_support_get_ctype_code_range,
cp949_left_adjust_char_head,
cp949_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/depend b/enc/depend
index 47a20e957a..4bf97dc880 100644
--- a/enc/depend
+++ b/enc/depend
@@ -35,6 +35,7 @@ ENCSOS =<%ENCS.map {|e|%> $(ENCSODIR)/<%=e%>.$(DLEXT) \
<%}%> #
ENCCLEANLIBS = <%=cleanlibs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(ENCOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
+ .gsub(/\$\(\KTARGET_SO(?=[:\)])/) {"ENCSOS"}
}.join(" ")%>
ENCCLEANOBJS = <%=cleanobjs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(ENCOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
@@ -51,6 +52,7 @@ TRANSSOS =<%TRANS.map {|e|%> $(ENCSODIR)/<%=e%>.$(DLEXT) \
<%}%> #
TRANSCLEANLIBS = <%=cleanlibs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
+ .gsub(/\$\(\KTARGET_SO(?=[:\)])/) {"TRANSSOS"}
}.join(" ")%>
TRANSCLEANOBJS = <%=cleanobjs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
@@ -58,12 +60,8 @@ TRANSCLEANOBJS = <%=cleanobjs.map {|clean|
LIBTRANS=enc/libtrans.$(LIBEXT)
UNICODE_HDR_DIR = --missing-unicode-header-dir--
-encs: all
-% if MODULE_TYPE == :static
-all: libenc libtrans
-% else
-all: enc trans
-%end
+encs all: <%= MODULE_TYPE == :static ? "lib" : "mod" %>encs
+modencs: enc trans
libencs: libenc libtrans
enc: $(ENCSOS)
libenc: $(LIBENC)
@@ -155,19 +153,19 @@ enc/trans/transdb.$(OBJEXT): transdb.h
clean:
% %w[$(ENCSOS) $(LIBENC) $(ENCOBJS) $(ENCCLEANOBJS) $(ENCCLEANLIBS) $(TRANSSOS) $(LIBTRANS) $(TRANSOBJS) $(TRANSCLEANOBJS) $(TRANSCLEANLIBS) $(ENC_TRANS_D) $(ENC_TRANS_SO_D)].each do |clean|
- $(Q)$(RM) <%=pathrep[clean]%>
+ $(Q)$(RMALL) <%=pathrep[clean]%>
% end
% unless inplace
$(Q)$(RM) enc/unicode/*/casefold.h enc/unicode/*/name2ctype.h
- $(Q)$(RM) enc/jis/props.h
- -$(Q)$(RMDIR) enc/unicode<%=ignore_error%>
+ $(Q)$(RM) enc/trans/newline.c enc/jis/props.h
+ -$(Q)$(RMDIR) enc/trnas enc/unicode<%=ignore_error%>
% end
% workdirs.reverse_each do|d|
-$(Q)$(RMDIR) <%=pathrep[d]%><%=ignore_error%>
% end
clean-srcs:
- $(Q)$(RM) <%=pathrep['$(TRANSCSRCS)']%>
+ $(Q)$(RM) <%=pathrep['$(TRANSCSRCS)']%> <%=pathrep['$(BUILTIN_TRANS_CSRCS)']%>
-$(Q)$(RMDIR) <%=pathrep['enc/trans']%><%=ignore_error%>
$(Q)$(RM) enc/unicode/*/casefold.h enc/unicode/*/name2ctype.h
$(Q)$(RM) enc/jis/props.h
@@ -319,6 +317,7 @@ enc/ascii.$(OBJEXT): internal/intern/re.h
enc/ascii.$(OBJEXT): internal/intern/ruby.h
enc/ascii.$(OBJEXT): internal/intern/select.h
enc/ascii.$(OBJEXT): internal/intern/select/largesize.h
+enc/ascii.$(OBJEXT): internal/intern/set.h
enc/ascii.$(OBJEXT): internal/intern/signal.h
enc/ascii.$(OBJEXT): internal/intern/sprintf.h
enc/ascii.$(OBJEXT): internal/intern/string.h
@@ -338,6 +337,7 @@ enc/ascii.$(OBJEXT): internal/special_consts.h
enc/ascii.$(OBJEXT): internal/static_assert.h
enc/ascii.$(OBJEXT): internal/stdalign.h
enc/ascii.$(OBJEXT): internal/stdbool.h
+enc/ascii.$(OBJEXT): internal/stdckdint.h
enc/ascii.$(OBJEXT): internal/symbol.h
enc/ascii.$(OBJEXT): internal/value.h
enc/ascii.$(OBJEXT): internal/value_type.h
@@ -480,6 +480,7 @@ enc/big5.$(OBJEXT): internal/intern/re.h
enc/big5.$(OBJEXT): internal/intern/ruby.h
enc/big5.$(OBJEXT): internal/intern/select.h
enc/big5.$(OBJEXT): internal/intern/select/largesize.h
+enc/big5.$(OBJEXT): internal/intern/set.h
enc/big5.$(OBJEXT): internal/intern/signal.h
enc/big5.$(OBJEXT): internal/intern/sprintf.h
enc/big5.$(OBJEXT): internal/intern/string.h
@@ -499,6 +500,7 @@ enc/big5.$(OBJEXT): internal/special_consts.h
enc/big5.$(OBJEXT): internal/static_assert.h
enc/big5.$(OBJEXT): internal/stdalign.h
enc/big5.$(OBJEXT): internal/stdbool.h
+enc/big5.$(OBJEXT): internal/stdckdint.h
enc/big5.$(OBJEXT): internal/symbol.h
enc/big5.$(OBJEXT): internal/value.h
enc/big5.$(OBJEXT): internal/value_type.h
@@ -651,6 +653,7 @@ enc/cesu_8.$(OBJEXT): internal/intern/re.h
enc/cesu_8.$(OBJEXT): internal/intern/ruby.h
enc/cesu_8.$(OBJEXT): internal/intern/select.h
enc/cesu_8.$(OBJEXT): internal/intern/select/largesize.h
+enc/cesu_8.$(OBJEXT): internal/intern/set.h
enc/cesu_8.$(OBJEXT): internal/intern/signal.h
enc/cesu_8.$(OBJEXT): internal/intern/sprintf.h
enc/cesu_8.$(OBJEXT): internal/intern/string.h
@@ -670,6 +673,7 @@ enc/cesu_8.$(OBJEXT): internal/special_consts.h
enc/cesu_8.$(OBJEXT): internal/static_assert.h
enc/cesu_8.$(OBJEXT): internal/stdalign.h
enc/cesu_8.$(OBJEXT): internal/stdbool.h
+enc/cesu_8.$(OBJEXT): internal/stdckdint.h
enc/cesu_8.$(OBJEXT): internal/symbol.h
enc/cesu_8.$(OBJEXT): internal/value.h
enc/cesu_8.$(OBJEXT): internal/value_type.h
@@ -812,6 +816,7 @@ enc/cp949.$(OBJEXT): internal/intern/re.h
enc/cp949.$(OBJEXT): internal/intern/ruby.h
enc/cp949.$(OBJEXT): internal/intern/select.h
enc/cp949.$(OBJEXT): internal/intern/select/largesize.h
+enc/cp949.$(OBJEXT): internal/intern/set.h
enc/cp949.$(OBJEXT): internal/intern/signal.h
enc/cp949.$(OBJEXT): internal/intern/sprintf.h
enc/cp949.$(OBJEXT): internal/intern/string.h
@@ -831,6 +836,7 @@ enc/cp949.$(OBJEXT): internal/special_consts.h
enc/cp949.$(OBJEXT): internal/static_assert.h
enc/cp949.$(OBJEXT): internal/stdalign.h
enc/cp949.$(OBJEXT): internal/stdbool.h
+enc/cp949.$(OBJEXT): internal/stdckdint.h
enc/cp949.$(OBJEXT): internal/symbol.h
enc/cp949.$(OBJEXT): internal/value.h
enc/cp949.$(OBJEXT): internal/value_type.h
@@ -972,6 +978,7 @@ enc/emacs_mule.$(OBJEXT): internal/intern/re.h
enc/emacs_mule.$(OBJEXT): internal/intern/ruby.h
enc/emacs_mule.$(OBJEXT): internal/intern/select.h
enc/emacs_mule.$(OBJEXT): internal/intern/select/largesize.h
+enc/emacs_mule.$(OBJEXT): internal/intern/set.h
enc/emacs_mule.$(OBJEXT): internal/intern/signal.h
enc/emacs_mule.$(OBJEXT): internal/intern/sprintf.h
enc/emacs_mule.$(OBJEXT): internal/intern/string.h
@@ -991,6 +998,7 @@ enc/emacs_mule.$(OBJEXT): internal/special_consts.h
enc/emacs_mule.$(OBJEXT): internal/static_assert.h
enc/emacs_mule.$(OBJEXT): internal/stdalign.h
enc/emacs_mule.$(OBJEXT): internal/stdbool.h
+enc/emacs_mule.$(OBJEXT): internal/stdckdint.h
enc/emacs_mule.$(OBJEXT): internal/symbol.h
enc/emacs_mule.$(OBJEXT): internal/value.h
enc/emacs_mule.$(OBJEXT): internal/value_type.h
@@ -1142,6 +1150,7 @@ enc/encdb.$(OBJEXT): internal/intern/re.h
enc/encdb.$(OBJEXT): internal/intern/ruby.h
enc/encdb.$(OBJEXT): internal/intern/select.h
enc/encdb.$(OBJEXT): internal/intern/select/largesize.h
+enc/encdb.$(OBJEXT): internal/intern/set.h
enc/encdb.$(OBJEXT): internal/intern/signal.h
enc/encdb.$(OBJEXT): internal/intern/sprintf.h
enc/encdb.$(OBJEXT): internal/intern/string.h
@@ -1161,6 +1170,7 @@ enc/encdb.$(OBJEXT): internal/special_consts.h
enc/encdb.$(OBJEXT): internal/static_assert.h
enc/encdb.$(OBJEXT): internal/stdalign.h
enc/encdb.$(OBJEXT): internal/stdbool.h
+enc/encdb.$(OBJEXT): internal/stdckdint.h
enc/encdb.$(OBJEXT): internal/symbol.h
enc/encdb.$(OBJEXT): internal/value.h
enc/encdb.$(OBJEXT): internal/value_type.h
@@ -1305,6 +1315,7 @@ enc/euc_jp.$(OBJEXT): internal/intern/re.h
enc/euc_jp.$(OBJEXT): internal/intern/ruby.h
enc/euc_jp.$(OBJEXT): internal/intern/select.h
enc/euc_jp.$(OBJEXT): internal/intern/select/largesize.h
+enc/euc_jp.$(OBJEXT): internal/intern/set.h
enc/euc_jp.$(OBJEXT): internal/intern/signal.h
enc/euc_jp.$(OBJEXT): internal/intern/sprintf.h
enc/euc_jp.$(OBJEXT): internal/intern/string.h
@@ -1324,6 +1335,7 @@ enc/euc_jp.$(OBJEXT): internal/special_consts.h
enc/euc_jp.$(OBJEXT): internal/static_assert.h
enc/euc_jp.$(OBJEXT): internal/stdalign.h
enc/euc_jp.$(OBJEXT): internal/stdbool.h
+enc/euc_jp.$(OBJEXT): internal/stdckdint.h
enc/euc_jp.$(OBJEXT): internal/symbol.h
enc/euc_jp.$(OBJEXT): internal/value.h
enc/euc_jp.$(OBJEXT): internal/value_type.h
@@ -1465,6 +1477,7 @@ enc/euc_kr.$(OBJEXT): internal/intern/re.h
enc/euc_kr.$(OBJEXT): internal/intern/ruby.h
enc/euc_kr.$(OBJEXT): internal/intern/select.h
enc/euc_kr.$(OBJEXT): internal/intern/select/largesize.h
+enc/euc_kr.$(OBJEXT): internal/intern/set.h
enc/euc_kr.$(OBJEXT): internal/intern/signal.h
enc/euc_kr.$(OBJEXT): internal/intern/sprintf.h
enc/euc_kr.$(OBJEXT): internal/intern/string.h
@@ -1484,6 +1497,7 @@ enc/euc_kr.$(OBJEXT): internal/special_consts.h
enc/euc_kr.$(OBJEXT): internal/static_assert.h
enc/euc_kr.$(OBJEXT): internal/stdalign.h
enc/euc_kr.$(OBJEXT): internal/stdbool.h
+enc/euc_kr.$(OBJEXT): internal/stdckdint.h
enc/euc_kr.$(OBJEXT): internal/symbol.h
enc/euc_kr.$(OBJEXT): internal/value.h
enc/euc_kr.$(OBJEXT): internal/value_type.h
@@ -1625,6 +1639,7 @@ enc/euc_tw.$(OBJEXT): internal/intern/re.h
enc/euc_tw.$(OBJEXT): internal/intern/ruby.h
enc/euc_tw.$(OBJEXT): internal/intern/select.h
enc/euc_tw.$(OBJEXT): internal/intern/select/largesize.h
+enc/euc_tw.$(OBJEXT): internal/intern/set.h
enc/euc_tw.$(OBJEXT): internal/intern/signal.h
enc/euc_tw.$(OBJEXT): internal/intern/sprintf.h
enc/euc_tw.$(OBJEXT): internal/intern/string.h
@@ -1644,6 +1659,7 @@ enc/euc_tw.$(OBJEXT): internal/special_consts.h
enc/euc_tw.$(OBJEXT): internal/static_assert.h
enc/euc_tw.$(OBJEXT): internal/stdalign.h
enc/euc_tw.$(OBJEXT): internal/stdbool.h
+enc/euc_tw.$(OBJEXT): internal/stdckdint.h
enc/euc_tw.$(OBJEXT): internal/symbol.h
enc/euc_tw.$(OBJEXT): internal/value.h
enc/euc_tw.$(OBJEXT): internal/value_type.h
@@ -1785,6 +1801,7 @@ enc/gb18030.$(OBJEXT): internal/intern/re.h
enc/gb18030.$(OBJEXT): internal/intern/ruby.h
enc/gb18030.$(OBJEXT): internal/intern/select.h
enc/gb18030.$(OBJEXT): internal/intern/select/largesize.h
+enc/gb18030.$(OBJEXT): internal/intern/set.h
enc/gb18030.$(OBJEXT): internal/intern/signal.h
enc/gb18030.$(OBJEXT): internal/intern/sprintf.h
enc/gb18030.$(OBJEXT): internal/intern/string.h
@@ -1804,6 +1821,7 @@ enc/gb18030.$(OBJEXT): internal/special_consts.h
enc/gb18030.$(OBJEXT): internal/static_assert.h
enc/gb18030.$(OBJEXT): internal/stdalign.h
enc/gb18030.$(OBJEXT): internal/stdbool.h
+enc/gb18030.$(OBJEXT): internal/stdckdint.h
enc/gb18030.$(OBJEXT): internal/symbol.h
enc/gb18030.$(OBJEXT): internal/value.h
enc/gb18030.$(OBJEXT): internal/value_type.h
@@ -1945,6 +1963,7 @@ enc/gb2312.$(OBJEXT): internal/intern/re.h
enc/gb2312.$(OBJEXT): internal/intern/ruby.h
enc/gb2312.$(OBJEXT): internal/intern/select.h
enc/gb2312.$(OBJEXT): internal/intern/select/largesize.h
+enc/gb2312.$(OBJEXT): internal/intern/set.h
enc/gb2312.$(OBJEXT): internal/intern/signal.h
enc/gb2312.$(OBJEXT): internal/intern/sprintf.h
enc/gb2312.$(OBJEXT): internal/intern/string.h
@@ -1964,6 +1983,7 @@ enc/gb2312.$(OBJEXT): internal/special_consts.h
enc/gb2312.$(OBJEXT): internal/static_assert.h
enc/gb2312.$(OBJEXT): internal/stdalign.h
enc/gb2312.$(OBJEXT): internal/stdbool.h
+enc/gb2312.$(OBJEXT): internal/stdckdint.h
enc/gb2312.$(OBJEXT): internal/symbol.h
enc/gb2312.$(OBJEXT): internal/value.h
enc/gb2312.$(OBJEXT): internal/value_type.h
@@ -2105,6 +2125,7 @@ enc/gbk.$(OBJEXT): internal/intern/re.h
enc/gbk.$(OBJEXT): internal/intern/ruby.h
enc/gbk.$(OBJEXT): internal/intern/select.h
enc/gbk.$(OBJEXT): internal/intern/select/largesize.h
+enc/gbk.$(OBJEXT): internal/intern/set.h
enc/gbk.$(OBJEXT): internal/intern/signal.h
enc/gbk.$(OBJEXT): internal/intern/sprintf.h
enc/gbk.$(OBJEXT): internal/intern/string.h
@@ -2124,6 +2145,7 @@ enc/gbk.$(OBJEXT): internal/special_consts.h
enc/gbk.$(OBJEXT): internal/static_assert.h
enc/gbk.$(OBJEXT): internal/stdalign.h
enc/gbk.$(OBJEXT): internal/stdbool.h
+enc/gbk.$(OBJEXT): internal/stdckdint.h
enc/gbk.$(OBJEXT): internal/symbol.h
enc/gbk.$(OBJEXT): internal/value.h
enc/gbk.$(OBJEXT): internal/value_type.h
@@ -2266,6 +2288,7 @@ enc/iso_8859_1.$(OBJEXT): internal/intern/re.h
enc/iso_8859_1.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_1.$(OBJEXT): internal/intern/select.h
enc/iso_8859_1.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_1.$(OBJEXT): internal/intern/set.h
enc/iso_8859_1.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_1.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_1.$(OBJEXT): internal/intern/string.h
@@ -2285,6 +2308,7 @@ enc/iso_8859_1.$(OBJEXT): internal/special_consts.h
enc/iso_8859_1.$(OBJEXT): internal/static_assert.h
enc/iso_8859_1.$(OBJEXT): internal/stdalign.h
enc/iso_8859_1.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_1.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_1.$(OBJEXT): internal/symbol.h
enc/iso_8859_1.$(OBJEXT): internal/value.h
enc/iso_8859_1.$(OBJEXT): internal/value_type.h
@@ -2427,6 +2451,7 @@ enc/iso_8859_10.$(OBJEXT): internal/intern/re.h
enc/iso_8859_10.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_10.$(OBJEXT): internal/intern/select.h
enc/iso_8859_10.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_10.$(OBJEXT): internal/intern/set.h
enc/iso_8859_10.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_10.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_10.$(OBJEXT): internal/intern/string.h
@@ -2446,6 +2471,7 @@ enc/iso_8859_10.$(OBJEXT): internal/special_consts.h
enc/iso_8859_10.$(OBJEXT): internal/static_assert.h
enc/iso_8859_10.$(OBJEXT): internal/stdalign.h
enc/iso_8859_10.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_10.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_10.$(OBJEXT): internal/symbol.h
enc/iso_8859_10.$(OBJEXT): internal/value.h
enc/iso_8859_10.$(OBJEXT): internal/value_type.h
@@ -2587,6 +2613,7 @@ enc/iso_8859_11.$(OBJEXT): internal/intern/re.h
enc/iso_8859_11.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_11.$(OBJEXT): internal/intern/select.h
enc/iso_8859_11.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_11.$(OBJEXT): internal/intern/set.h
enc/iso_8859_11.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_11.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_11.$(OBJEXT): internal/intern/string.h
@@ -2606,6 +2633,7 @@ enc/iso_8859_11.$(OBJEXT): internal/special_consts.h
enc/iso_8859_11.$(OBJEXT): internal/static_assert.h
enc/iso_8859_11.$(OBJEXT): internal/stdalign.h
enc/iso_8859_11.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_11.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_11.$(OBJEXT): internal/symbol.h
enc/iso_8859_11.$(OBJEXT): internal/value.h
enc/iso_8859_11.$(OBJEXT): internal/value_type.h
@@ -2748,6 +2776,7 @@ enc/iso_8859_13.$(OBJEXT): internal/intern/re.h
enc/iso_8859_13.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_13.$(OBJEXT): internal/intern/select.h
enc/iso_8859_13.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_13.$(OBJEXT): internal/intern/set.h
enc/iso_8859_13.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_13.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_13.$(OBJEXT): internal/intern/string.h
@@ -2767,6 +2796,7 @@ enc/iso_8859_13.$(OBJEXT): internal/special_consts.h
enc/iso_8859_13.$(OBJEXT): internal/static_assert.h
enc/iso_8859_13.$(OBJEXT): internal/stdalign.h
enc/iso_8859_13.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_13.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_13.$(OBJEXT): internal/symbol.h
enc/iso_8859_13.$(OBJEXT): internal/value.h
enc/iso_8859_13.$(OBJEXT): internal/value_type.h
@@ -2909,6 +2939,7 @@ enc/iso_8859_14.$(OBJEXT): internal/intern/re.h
enc/iso_8859_14.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_14.$(OBJEXT): internal/intern/select.h
enc/iso_8859_14.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_14.$(OBJEXT): internal/intern/set.h
enc/iso_8859_14.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_14.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_14.$(OBJEXT): internal/intern/string.h
@@ -2928,6 +2959,7 @@ enc/iso_8859_14.$(OBJEXT): internal/special_consts.h
enc/iso_8859_14.$(OBJEXT): internal/static_assert.h
enc/iso_8859_14.$(OBJEXT): internal/stdalign.h
enc/iso_8859_14.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_14.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_14.$(OBJEXT): internal/symbol.h
enc/iso_8859_14.$(OBJEXT): internal/value.h
enc/iso_8859_14.$(OBJEXT): internal/value_type.h
@@ -3070,6 +3102,7 @@ enc/iso_8859_15.$(OBJEXT): internal/intern/re.h
enc/iso_8859_15.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_15.$(OBJEXT): internal/intern/select.h
enc/iso_8859_15.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_15.$(OBJEXT): internal/intern/set.h
enc/iso_8859_15.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_15.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_15.$(OBJEXT): internal/intern/string.h
@@ -3089,6 +3122,7 @@ enc/iso_8859_15.$(OBJEXT): internal/special_consts.h
enc/iso_8859_15.$(OBJEXT): internal/static_assert.h
enc/iso_8859_15.$(OBJEXT): internal/stdalign.h
enc/iso_8859_15.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_15.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_15.$(OBJEXT): internal/symbol.h
enc/iso_8859_15.$(OBJEXT): internal/value.h
enc/iso_8859_15.$(OBJEXT): internal/value_type.h
@@ -3231,6 +3265,7 @@ enc/iso_8859_16.$(OBJEXT): internal/intern/re.h
enc/iso_8859_16.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_16.$(OBJEXT): internal/intern/select.h
enc/iso_8859_16.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_16.$(OBJEXT): internal/intern/set.h
enc/iso_8859_16.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_16.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_16.$(OBJEXT): internal/intern/string.h
@@ -3250,6 +3285,7 @@ enc/iso_8859_16.$(OBJEXT): internal/special_consts.h
enc/iso_8859_16.$(OBJEXT): internal/static_assert.h
enc/iso_8859_16.$(OBJEXT): internal/stdalign.h
enc/iso_8859_16.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_16.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_16.$(OBJEXT): internal/symbol.h
enc/iso_8859_16.$(OBJEXT): internal/value.h
enc/iso_8859_16.$(OBJEXT): internal/value_type.h
@@ -3392,6 +3428,7 @@ enc/iso_8859_2.$(OBJEXT): internal/intern/re.h
enc/iso_8859_2.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_2.$(OBJEXT): internal/intern/select.h
enc/iso_8859_2.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_2.$(OBJEXT): internal/intern/set.h
enc/iso_8859_2.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_2.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_2.$(OBJEXT): internal/intern/string.h
@@ -3411,6 +3448,7 @@ enc/iso_8859_2.$(OBJEXT): internal/special_consts.h
enc/iso_8859_2.$(OBJEXT): internal/static_assert.h
enc/iso_8859_2.$(OBJEXT): internal/stdalign.h
enc/iso_8859_2.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_2.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_2.$(OBJEXT): internal/symbol.h
enc/iso_8859_2.$(OBJEXT): internal/value.h
enc/iso_8859_2.$(OBJEXT): internal/value_type.h
@@ -3553,6 +3591,7 @@ enc/iso_8859_3.$(OBJEXT): internal/intern/re.h
enc/iso_8859_3.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_3.$(OBJEXT): internal/intern/select.h
enc/iso_8859_3.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_3.$(OBJEXT): internal/intern/set.h
enc/iso_8859_3.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_3.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_3.$(OBJEXT): internal/intern/string.h
@@ -3572,6 +3611,7 @@ enc/iso_8859_3.$(OBJEXT): internal/special_consts.h
enc/iso_8859_3.$(OBJEXT): internal/static_assert.h
enc/iso_8859_3.$(OBJEXT): internal/stdalign.h
enc/iso_8859_3.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_3.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_3.$(OBJEXT): internal/symbol.h
enc/iso_8859_3.$(OBJEXT): internal/value.h
enc/iso_8859_3.$(OBJEXT): internal/value_type.h
@@ -3714,6 +3754,7 @@ enc/iso_8859_4.$(OBJEXT): internal/intern/re.h
enc/iso_8859_4.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_4.$(OBJEXT): internal/intern/select.h
enc/iso_8859_4.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_4.$(OBJEXT): internal/intern/set.h
enc/iso_8859_4.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_4.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_4.$(OBJEXT): internal/intern/string.h
@@ -3733,6 +3774,7 @@ enc/iso_8859_4.$(OBJEXT): internal/special_consts.h
enc/iso_8859_4.$(OBJEXT): internal/static_assert.h
enc/iso_8859_4.$(OBJEXT): internal/stdalign.h
enc/iso_8859_4.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_4.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_4.$(OBJEXT): internal/symbol.h
enc/iso_8859_4.$(OBJEXT): internal/value.h
enc/iso_8859_4.$(OBJEXT): internal/value_type.h
@@ -3874,6 +3916,7 @@ enc/iso_8859_5.$(OBJEXT): internal/intern/re.h
enc/iso_8859_5.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_5.$(OBJEXT): internal/intern/select.h
enc/iso_8859_5.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_5.$(OBJEXT): internal/intern/set.h
enc/iso_8859_5.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_5.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_5.$(OBJEXT): internal/intern/string.h
@@ -3893,6 +3936,7 @@ enc/iso_8859_5.$(OBJEXT): internal/special_consts.h
enc/iso_8859_5.$(OBJEXT): internal/static_assert.h
enc/iso_8859_5.$(OBJEXT): internal/stdalign.h
enc/iso_8859_5.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_5.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_5.$(OBJEXT): internal/symbol.h
enc/iso_8859_5.$(OBJEXT): internal/value.h
enc/iso_8859_5.$(OBJEXT): internal/value_type.h
@@ -4034,6 +4078,7 @@ enc/iso_8859_6.$(OBJEXT): internal/intern/re.h
enc/iso_8859_6.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_6.$(OBJEXT): internal/intern/select.h
enc/iso_8859_6.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_6.$(OBJEXT): internal/intern/set.h
enc/iso_8859_6.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_6.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_6.$(OBJEXT): internal/intern/string.h
@@ -4053,6 +4098,7 @@ enc/iso_8859_6.$(OBJEXT): internal/special_consts.h
enc/iso_8859_6.$(OBJEXT): internal/static_assert.h
enc/iso_8859_6.$(OBJEXT): internal/stdalign.h
enc/iso_8859_6.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_6.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_6.$(OBJEXT): internal/symbol.h
enc/iso_8859_6.$(OBJEXT): internal/value.h
enc/iso_8859_6.$(OBJEXT): internal/value_type.h
@@ -4194,6 +4240,7 @@ enc/iso_8859_7.$(OBJEXT): internal/intern/re.h
enc/iso_8859_7.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_7.$(OBJEXT): internal/intern/select.h
enc/iso_8859_7.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_7.$(OBJEXT): internal/intern/set.h
enc/iso_8859_7.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_7.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_7.$(OBJEXT): internal/intern/string.h
@@ -4213,6 +4260,7 @@ enc/iso_8859_7.$(OBJEXT): internal/special_consts.h
enc/iso_8859_7.$(OBJEXT): internal/static_assert.h
enc/iso_8859_7.$(OBJEXT): internal/stdalign.h
enc/iso_8859_7.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_7.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_7.$(OBJEXT): internal/symbol.h
enc/iso_8859_7.$(OBJEXT): internal/value.h
enc/iso_8859_7.$(OBJEXT): internal/value_type.h
@@ -4354,6 +4402,7 @@ enc/iso_8859_8.$(OBJEXT): internal/intern/re.h
enc/iso_8859_8.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_8.$(OBJEXT): internal/intern/select.h
enc/iso_8859_8.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_8.$(OBJEXT): internal/intern/set.h
enc/iso_8859_8.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_8.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_8.$(OBJEXT): internal/intern/string.h
@@ -4373,6 +4422,7 @@ enc/iso_8859_8.$(OBJEXT): internal/special_consts.h
enc/iso_8859_8.$(OBJEXT): internal/static_assert.h
enc/iso_8859_8.$(OBJEXT): internal/stdalign.h
enc/iso_8859_8.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_8.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_8.$(OBJEXT): internal/symbol.h
enc/iso_8859_8.$(OBJEXT): internal/value.h
enc/iso_8859_8.$(OBJEXT): internal/value_type.h
@@ -4515,6 +4565,7 @@ enc/iso_8859_9.$(OBJEXT): internal/intern/re.h
enc/iso_8859_9.$(OBJEXT): internal/intern/ruby.h
enc/iso_8859_9.$(OBJEXT): internal/intern/select.h
enc/iso_8859_9.$(OBJEXT): internal/intern/select/largesize.h
+enc/iso_8859_9.$(OBJEXT): internal/intern/set.h
enc/iso_8859_9.$(OBJEXT): internal/intern/signal.h
enc/iso_8859_9.$(OBJEXT): internal/intern/sprintf.h
enc/iso_8859_9.$(OBJEXT): internal/intern/string.h
@@ -4534,6 +4585,7 @@ enc/iso_8859_9.$(OBJEXT): internal/special_consts.h
enc/iso_8859_9.$(OBJEXT): internal/static_assert.h
enc/iso_8859_9.$(OBJEXT): internal/stdalign.h
enc/iso_8859_9.$(OBJEXT): internal/stdbool.h
+enc/iso_8859_9.$(OBJEXT): internal/stdckdint.h
enc/iso_8859_9.$(OBJEXT): internal/symbol.h
enc/iso_8859_9.$(OBJEXT): internal/value.h
enc/iso_8859_9.$(OBJEXT): internal/value_type.h
@@ -4675,6 +4727,7 @@ enc/koi8_r.$(OBJEXT): internal/intern/re.h
enc/koi8_r.$(OBJEXT): internal/intern/ruby.h
enc/koi8_r.$(OBJEXT): internal/intern/select.h
enc/koi8_r.$(OBJEXT): internal/intern/select/largesize.h
+enc/koi8_r.$(OBJEXT): internal/intern/set.h
enc/koi8_r.$(OBJEXT): internal/intern/signal.h
enc/koi8_r.$(OBJEXT): internal/intern/sprintf.h
enc/koi8_r.$(OBJEXT): internal/intern/string.h
@@ -4694,6 +4747,7 @@ enc/koi8_r.$(OBJEXT): internal/special_consts.h
enc/koi8_r.$(OBJEXT): internal/static_assert.h
enc/koi8_r.$(OBJEXT): internal/stdalign.h
enc/koi8_r.$(OBJEXT): internal/stdbool.h
+enc/koi8_r.$(OBJEXT): internal/stdckdint.h
enc/koi8_r.$(OBJEXT): internal/symbol.h
enc/koi8_r.$(OBJEXT): internal/value.h
enc/koi8_r.$(OBJEXT): internal/value_type.h
@@ -4835,6 +4889,7 @@ enc/koi8_u.$(OBJEXT): internal/intern/re.h
enc/koi8_u.$(OBJEXT): internal/intern/ruby.h
enc/koi8_u.$(OBJEXT): internal/intern/select.h
enc/koi8_u.$(OBJEXT): internal/intern/select/largesize.h
+enc/koi8_u.$(OBJEXT): internal/intern/set.h
enc/koi8_u.$(OBJEXT): internal/intern/signal.h
enc/koi8_u.$(OBJEXT): internal/intern/sprintf.h
enc/koi8_u.$(OBJEXT): internal/intern/string.h
@@ -4854,6 +4909,7 @@ enc/koi8_u.$(OBJEXT): internal/special_consts.h
enc/koi8_u.$(OBJEXT): internal/static_assert.h
enc/koi8_u.$(OBJEXT): internal/stdalign.h
enc/koi8_u.$(OBJEXT): internal/stdbool.h
+enc/koi8_u.$(OBJEXT): internal/stdckdint.h
enc/koi8_u.$(OBJEXT): internal/symbol.h
enc/koi8_u.$(OBJEXT): internal/value.h
enc/koi8_u.$(OBJEXT): internal/value_type.h
@@ -4998,6 +5054,7 @@ enc/shift_jis.$(OBJEXT): internal/intern/re.h
enc/shift_jis.$(OBJEXT): internal/intern/ruby.h
enc/shift_jis.$(OBJEXT): internal/intern/select.h
enc/shift_jis.$(OBJEXT): internal/intern/select/largesize.h
+enc/shift_jis.$(OBJEXT): internal/intern/set.h
enc/shift_jis.$(OBJEXT): internal/intern/signal.h
enc/shift_jis.$(OBJEXT): internal/intern/sprintf.h
enc/shift_jis.$(OBJEXT): internal/intern/string.h
@@ -5017,6 +5074,7 @@ enc/shift_jis.$(OBJEXT): internal/special_consts.h
enc/shift_jis.$(OBJEXT): internal/static_assert.h
enc/shift_jis.$(OBJEXT): internal/stdalign.h
enc/shift_jis.$(OBJEXT): internal/stdbool.h
+enc/shift_jis.$(OBJEXT): internal/stdckdint.h
enc/shift_jis.$(OBJEXT): internal/symbol.h
enc/shift_jis.$(OBJEXT): internal/value.h
enc/shift_jis.$(OBJEXT): internal/value_type.h
@@ -5157,6 +5215,7 @@ enc/trans/big5.$(OBJEXT): internal/intern/re.h
enc/trans/big5.$(OBJEXT): internal/intern/ruby.h
enc/trans/big5.$(OBJEXT): internal/intern/select.h
enc/trans/big5.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/big5.$(OBJEXT): internal/intern/set.h
enc/trans/big5.$(OBJEXT): internal/intern/signal.h
enc/trans/big5.$(OBJEXT): internal/intern/sprintf.h
enc/trans/big5.$(OBJEXT): internal/intern/string.h
@@ -5176,6 +5235,7 @@ enc/trans/big5.$(OBJEXT): internal/special_consts.h
enc/trans/big5.$(OBJEXT): internal/static_assert.h
enc/trans/big5.$(OBJEXT): internal/stdalign.h
enc/trans/big5.$(OBJEXT): internal/stdbool.h
+enc/trans/big5.$(OBJEXT): internal/stdckdint.h
enc/trans/big5.$(OBJEXT): internal/symbol.h
enc/trans/big5.$(OBJEXT): internal/value.h
enc/trans/big5.$(OBJEXT): internal/value_type.h
@@ -5315,6 +5375,7 @@ enc/trans/cesu_8.$(OBJEXT): internal/intern/re.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/ruby.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/select.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/cesu_8.$(OBJEXT): internal/intern/set.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/signal.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/sprintf.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/string.h
@@ -5334,6 +5395,7 @@ enc/trans/cesu_8.$(OBJEXT): internal/special_consts.h
enc/trans/cesu_8.$(OBJEXT): internal/static_assert.h
enc/trans/cesu_8.$(OBJEXT): internal/stdalign.h
enc/trans/cesu_8.$(OBJEXT): internal/stdbool.h
+enc/trans/cesu_8.$(OBJEXT): internal/stdckdint.h
enc/trans/cesu_8.$(OBJEXT): internal/symbol.h
enc/trans/cesu_8.$(OBJEXT): internal/value.h
enc/trans/cesu_8.$(OBJEXT): internal/value_type.h
@@ -5473,6 +5535,7 @@ enc/trans/chinese.$(OBJEXT): internal/intern/re.h
enc/trans/chinese.$(OBJEXT): internal/intern/ruby.h
enc/trans/chinese.$(OBJEXT): internal/intern/select.h
enc/trans/chinese.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/chinese.$(OBJEXT): internal/intern/set.h
enc/trans/chinese.$(OBJEXT): internal/intern/signal.h
enc/trans/chinese.$(OBJEXT): internal/intern/sprintf.h
enc/trans/chinese.$(OBJEXT): internal/intern/string.h
@@ -5492,6 +5555,7 @@ enc/trans/chinese.$(OBJEXT): internal/special_consts.h
enc/trans/chinese.$(OBJEXT): internal/static_assert.h
enc/trans/chinese.$(OBJEXT): internal/stdalign.h
enc/trans/chinese.$(OBJEXT): internal/stdbool.h
+enc/trans/chinese.$(OBJEXT): internal/stdckdint.h
enc/trans/chinese.$(OBJEXT): internal/symbol.h
enc/trans/chinese.$(OBJEXT): internal/value.h
enc/trans/chinese.$(OBJEXT): internal/value_type.h
@@ -5631,6 +5695,7 @@ enc/trans/ebcdic.$(OBJEXT): internal/intern/re.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/ruby.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/select.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/ebcdic.$(OBJEXT): internal/intern/set.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/signal.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/sprintf.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/string.h
@@ -5650,6 +5715,7 @@ enc/trans/ebcdic.$(OBJEXT): internal/special_consts.h
enc/trans/ebcdic.$(OBJEXT): internal/static_assert.h
enc/trans/ebcdic.$(OBJEXT): internal/stdalign.h
enc/trans/ebcdic.$(OBJEXT): internal/stdbool.h
+enc/trans/ebcdic.$(OBJEXT): internal/stdckdint.h
enc/trans/ebcdic.$(OBJEXT): internal/symbol.h
enc/trans/ebcdic.$(OBJEXT): internal/value.h
enc/trans/ebcdic.$(OBJEXT): internal/value_type.h
@@ -5789,6 +5855,7 @@ enc/trans/emoji.$(OBJEXT): internal/intern/re.h
enc/trans/emoji.$(OBJEXT): internal/intern/ruby.h
enc/trans/emoji.$(OBJEXT): internal/intern/select.h
enc/trans/emoji.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/emoji.$(OBJEXT): internal/intern/set.h
enc/trans/emoji.$(OBJEXT): internal/intern/signal.h
enc/trans/emoji.$(OBJEXT): internal/intern/sprintf.h
enc/trans/emoji.$(OBJEXT): internal/intern/string.h
@@ -5808,6 +5875,7 @@ enc/trans/emoji.$(OBJEXT): internal/special_consts.h
enc/trans/emoji.$(OBJEXT): internal/static_assert.h
enc/trans/emoji.$(OBJEXT): internal/stdalign.h
enc/trans/emoji.$(OBJEXT): internal/stdbool.h
+enc/trans/emoji.$(OBJEXT): internal/stdckdint.h
enc/trans/emoji.$(OBJEXT): internal/symbol.h
enc/trans/emoji.$(OBJEXT): internal/value.h
enc/trans/emoji.$(OBJEXT): internal/value_type.h
@@ -5947,6 +6015,7 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/re.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/ruby.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/select.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/set.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/signal.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/sprintf.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/string.h
@@ -5966,6 +6035,7 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/static_assert.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/stdalign.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/stdbool.h
+enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/stdckdint.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/symbol.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/value.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/value_type.h
@@ -6105,6 +6175,7 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/re.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/ruby.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/select.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/set.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/signal.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/sprintf.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/string.h
@@ -6124,6 +6195,7 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/static_assert.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/stdalign.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/stdbool.h
+enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/stdckdint.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/symbol.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/value.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/value_type.h
@@ -6263,6 +6335,7 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/re.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/ruby.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/select.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/set.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/signal.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/sprintf.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/string.h
@@ -6282,6 +6355,7 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/static_assert.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/stdalign.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/stdbool.h
+enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/stdckdint.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/symbol.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/value.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/value_type.h
@@ -6421,6 +6495,7 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/re.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/ruby.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/select.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/set.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/signal.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/sprintf.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/string.h
@@ -6440,6 +6515,7 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/static_assert.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/stdalign.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/stdbool.h
+enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/stdckdint.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/symbol.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/value.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/value_type.h
@@ -6579,6 +6655,7 @@ enc/trans/escape.$(OBJEXT): internal/intern/re.h
enc/trans/escape.$(OBJEXT): internal/intern/ruby.h
enc/trans/escape.$(OBJEXT): internal/intern/select.h
enc/trans/escape.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/escape.$(OBJEXT): internal/intern/set.h
enc/trans/escape.$(OBJEXT): internal/intern/signal.h
enc/trans/escape.$(OBJEXT): internal/intern/sprintf.h
enc/trans/escape.$(OBJEXT): internal/intern/string.h
@@ -6598,6 +6675,7 @@ enc/trans/escape.$(OBJEXT): internal/special_consts.h
enc/trans/escape.$(OBJEXT): internal/static_assert.h
enc/trans/escape.$(OBJEXT): internal/stdalign.h
enc/trans/escape.$(OBJEXT): internal/stdbool.h
+enc/trans/escape.$(OBJEXT): internal/stdckdint.h
enc/trans/escape.$(OBJEXT): internal/symbol.h
enc/trans/escape.$(OBJEXT): internal/value.h
enc/trans/escape.$(OBJEXT): internal/value_type.h
@@ -6737,6 +6815,7 @@ enc/trans/gb18030.$(OBJEXT): internal/intern/re.h
enc/trans/gb18030.$(OBJEXT): internal/intern/ruby.h
enc/trans/gb18030.$(OBJEXT): internal/intern/select.h
enc/trans/gb18030.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/gb18030.$(OBJEXT): internal/intern/set.h
enc/trans/gb18030.$(OBJEXT): internal/intern/signal.h
enc/trans/gb18030.$(OBJEXT): internal/intern/sprintf.h
enc/trans/gb18030.$(OBJEXT): internal/intern/string.h
@@ -6756,6 +6835,7 @@ enc/trans/gb18030.$(OBJEXT): internal/special_consts.h
enc/trans/gb18030.$(OBJEXT): internal/static_assert.h
enc/trans/gb18030.$(OBJEXT): internal/stdalign.h
enc/trans/gb18030.$(OBJEXT): internal/stdbool.h
+enc/trans/gb18030.$(OBJEXT): internal/stdckdint.h
enc/trans/gb18030.$(OBJEXT): internal/symbol.h
enc/trans/gb18030.$(OBJEXT): internal/value.h
enc/trans/gb18030.$(OBJEXT): internal/value_type.h
@@ -6895,6 +6975,7 @@ enc/trans/gbk.$(OBJEXT): internal/intern/re.h
enc/trans/gbk.$(OBJEXT): internal/intern/ruby.h
enc/trans/gbk.$(OBJEXT): internal/intern/select.h
enc/trans/gbk.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/gbk.$(OBJEXT): internal/intern/set.h
enc/trans/gbk.$(OBJEXT): internal/intern/signal.h
enc/trans/gbk.$(OBJEXT): internal/intern/sprintf.h
enc/trans/gbk.$(OBJEXT): internal/intern/string.h
@@ -6914,6 +6995,7 @@ enc/trans/gbk.$(OBJEXT): internal/special_consts.h
enc/trans/gbk.$(OBJEXT): internal/static_assert.h
enc/trans/gbk.$(OBJEXT): internal/stdalign.h
enc/trans/gbk.$(OBJEXT): internal/stdbool.h
+enc/trans/gbk.$(OBJEXT): internal/stdckdint.h
enc/trans/gbk.$(OBJEXT): internal/symbol.h
enc/trans/gbk.$(OBJEXT): internal/value.h
enc/trans/gbk.$(OBJEXT): internal/value_type.h
@@ -6976,6 +7058,7 @@ enc/trans/iso2022.$(OBJEXT): internal/attr/nodiscard.h
enc/trans/iso2022.$(OBJEXT): internal/attr/noexcept.h
enc/trans/iso2022.$(OBJEXT): internal/attr/noinline.h
enc/trans/iso2022.$(OBJEXT): internal/attr/nonnull.h
+enc/trans/iso2022.$(OBJEXT): internal/attr/nonstring.h
enc/trans/iso2022.$(OBJEXT): internal/attr/noreturn.h
enc/trans/iso2022.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/iso2022.$(OBJEXT): internal/attr/pure.h
@@ -7053,6 +7136,7 @@ enc/trans/iso2022.$(OBJEXT): internal/intern/re.h
enc/trans/iso2022.$(OBJEXT): internal/intern/ruby.h
enc/trans/iso2022.$(OBJEXT): internal/intern/select.h
enc/trans/iso2022.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/iso2022.$(OBJEXT): internal/intern/set.h
enc/trans/iso2022.$(OBJEXT): internal/intern/signal.h
enc/trans/iso2022.$(OBJEXT): internal/intern/sprintf.h
enc/trans/iso2022.$(OBJEXT): internal/intern/string.h
@@ -7072,6 +7156,7 @@ enc/trans/iso2022.$(OBJEXT): internal/special_consts.h
enc/trans/iso2022.$(OBJEXT): internal/static_assert.h
enc/trans/iso2022.$(OBJEXT): internal/stdalign.h
enc/trans/iso2022.$(OBJEXT): internal/stdbool.h
+enc/trans/iso2022.$(OBJEXT): internal/stdckdint.h
enc/trans/iso2022.$(OBJEXT): internal/symbol.h
enc/trans/iso2022.$(OBJEXT): internal/value.h
enc/trans/iso2022.$(OBJEXT): internal/value_type.h
@@ -7211,6 +7296,7 @@ enc/trans/japanese.$(OBJEXT): internal/intern/re.h
enc/trans/japanese.$(OBJEXT): internal/intern/ruby.h
enc/trans/japanese.$(OBJEXT): internal/intern/select.h
enc/trans/japanese.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/japanese.$(OBJEXT): internal/intern/set.h
enc/trans/japanese.$(OBJEXT): internal/intern/signal.h
enc/trans/japanese.$(OBJEXT): internal/intern/sprintf.h
enc/trans/japanese.$(OBJEXT): internal/intern/string.h
@@ -7230,6 +7316,7 @@ enc/trans/japanese.$(OBJEXT): internal/special_consts.h
enc/trans/japanese.$(OBJEXT): internal/static_assert.h
enc/trans/japanese.$(OBJEXT): internal/stdalign.h
enc/trans/japanese.$(OBJEXT): internal/stdbool.h
+enc/trans/japanese.$(OBJEXT): internal/stdckdint.h
enc/trans/japanese.$(OBJEXT): internal/symbol.h
enc/trans/japanese.$(OBJEXT): internal/value.h
enc/trans/japanese.$(OBJEXT): internal/value_type.h
@@ -7369,6 +7456,7 @@ enc/trans/japanese_euc.$(OBJEXT): internal/intern/re.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/ruby.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/select.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/japanese_euc.$(OBJEXT): internal/intern/set.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/signal.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/sprintf.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/string.h
@@ -7388,6 +7476,7 @@ enc/trans/japanese_euc.$(OBJEXT): internal/special_consts.h
enc/trans/japanese_euc.$(OBJEXT): internal/static_assert.h
enc/trans/japanese_euc.$(OBJEXT): internal/stdalign.h
enc/trans/japanese_euc.$(OBJEXT): internal/stdbool.h
+enc/trans/japanese_euc.$(OBJEXT): internal/stdckdint.h
enc/trans/japanese_euc.$(OBJEXT): internal/symbol.h
enc/trans/japanese_euc.$(OBJEXT): internal/value.h
enc/trans/japanese_euc.$(OBJEXT): internal/value_type.h
@@ -7527,6 +7616,7 @@ enc/trans/japanese_sjis.$(OBJEXT): internal/intern/re.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/ruby.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/select.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/japanese_sjis.$(OBJEXT): internal/intern/set.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/signal.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/sprintf.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/string.h
@@ -7546,6 +7636,7 @@ enc/trans/japanese_sjis.$(OBJEXT): internal/special_consts.h
enc/trans/japanese_sjis.$(OBJEXT): internal/static_assert.h
enc/trans/japanese_sjis.$(OBJEXT): internal/stdalign.h
enc/trans/japanese_sjis.$(OBJEXT): internal/stdbool.h
+enc/trans/japanese_sjis.$(OBJEXT): internal/stdckdint.h
enc/trans/japanese_sjis.$(OBJEXT): internal/symbol.h
enc/trans/japanese_sjis.$(OBJEXT): internal/value.h
enc/trans/japanese_sjis.$(OBJEXT): internal/value_type.h
@@ -7685,6 +7776,7 @@ enc/trans/korean.$(OBJEXT): internal/intern/re.h
enc/trans/korean.$(OBJEXT): internal/intern/ruby.h
enc/trans/korean.$(OBJEXT): internal/intern/select.h
enc/trans/korean.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/korean.$(OBJEXT): internal/intern/set.h
enc/trans/korean.$(OBJEXT): internal/intern/signal.h
enc/trans/korean.$(OBJEXT): internal/intern/sprintf.h
enc/trans/korean.$(OBJEXT): internal/intern/string.h
@@ -7704,6 +7796,7 @@ enc/trans/korean.$(OBJEXT): internal/special_consts.h
enc/trans/korean.$(OBJEXT): internal/static_assert.h
enc/trans/korean.$(OBJEXT): internal/stdalign.h
enc/trans/korean.$(OBJEXT): internal/stdbool.h
+enc/trans/korean.$(OBJEXT): internal/stdckdint.h
enc/trans/korean.$(OBJEXT): internal/symbol.h
enc/trans/korean.$(OBJEXT): internal/value.h
enc/trans/korean.$(OBJEXT): internal/value_type.h
@@ -7842,6 +7935,7 @@ enc/trans/newline.$(OBJEXT): internal/intern/re.h
enc/trans/newline.$(OBJEXT): internal/intern/ruby.h
enc/trans/newline.$(OBJEXT): internal/intern/select.h
enc/trans/newline.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/newline.$(OBJEXT): internal/intern/set.h
enc/trans/newline.$(OBJEXT): internal/intern/signal.h
enc/trans/newline.$(OBJEXT): internal/intern/sprintf.h
enc/trans/newline.$(OBJEXT): internal/intern/string.h
@@ -7861,6 +7955,7 @@ enc/trans/newline.$(OBJEXT): internal/special_consts.h
enc/trans/newline.$(OBJEXT): internal/static_assert.h
enc/trans/newline.$(OBJEXT): internal/stdalign.h
enc/trans/newline.$(OBJEXT): internal/stdbool.h
+enc/trans/newline.$(OBJEXT): internal/stdckdint.h
enc/trans/newline.$(OBJEXT): internal/symbol.h
enc/trans/newline.$(OBJEXT): internal/value.h
enc/trans/newline.$(OBJEXT): internal/value_type.h
@@ -8000,6 +8095,7 @@ enc/trans/single_byte.$(OBJEXT): internal/intern/re.h
enc/trans/single_byte.$(OBJEXT): internal/intern/ruby.h
enc/trans/single_byte.$(OBJEXT): internal/intern/select.h
enc/trans/single_byte.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/single_byte.$(OBJEXT): internal/intern/set.h
enc/trans/single_byte.$(OBJEXT): internal/intern/signal.h
enc/trans/single_byte.$(OBJEXT): internal/intern/sprintf.h
enc/trans/single_byte.$(OBJEXT): internal/intern/string.h
@@ -8019,6 +8115,7 @@ enc/trans/single_byte.$(OBJEXT): internal/special_consts.h
enc/trans/single_byte.$(OBJEXT): internal/static_assert.h
enc/trans/single_byte.$(OBJEXT): internal/stdalign.h
enc/trans/single_byte.$(OBJEXT): internal/stdbool.h
+enc/trans/single_byte.$(OBJEXT): internal/stdckdint.h
enc/trans/single_byte.$(OBJEXT): internal/symbol.h
enc/trans/single_byte.$(OBJEXT): internal/value.h
enc/trans/single_byte.$(OBJEXT): internal/value_type.h
@@ -8158,6 +8255,7 @@ enc/trans/transdb.$(OBJEXT): internal/intern/re.h
enc/trans/transdb.$(OBJEXT): internal/intern/ruby.h
enc/trans/transdb.$(OBJEXT): internal/intern/select.h
enc/trans/transdb.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/transdb.$(OBJEXT): internal/intern/set.h
enc/trans/transdb.$(OBJEXT): internal/intern/signal.h
enc/trans/transdb.$(OBJEXT): internal/intern/sprintf.h
enc/trans/transdb.$(OBJEXT): internal/intern/string.h
@@ -8177,6 +8275,7 @@ enc/trans/transdb.$(OBJEXT): internal/special_consts.h
enc/trans/transdb.$(OBJEXT): internal/static_assert.h
enc/trans/transdb.$(OBJEXT): internal/stdalign.h
enc/trans/transdb.$(OBJEXT): internal/stdbool.h
+enc/trans/transdb.$(OBJEXT): internal/stdckdint.h
enc/trans/transdb.$(OBJEXT): internal/symbol.h
enc/trans/transdb.$(OBJEXT): internal/value.h
enc/trans/transdb.$(OBJEXT): internal/value_type.h
@@ -8317,6 +8416,7 @@ enc/trans/utf8_mac.$(OBJEXT): internal/intern/re.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/ruby.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/select.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/utf8_mac.$(OBJEXT): internal/intern/set.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/signal.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/sprintf.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/string.h
@@ -8336,6 +8436,7 @@ enc/trans/utf8_mac.$(OBJEXT): internal/special_consts.h
enc/trans/utf8_mac.$(OBJEXT): internal/static_assert.h
enc/trans/utf8_mac.$(OBJEXT): internal/stdalign.h
enc/trans/utf8_mac.$(OBJEXT): internal/stdbool.h
+enc/trans/utf8_mac.$(OBJEXT): internal/stdckdint.h
enc/trans/utf8_mac.$(OBJEXT): internal/symbol.h
enc/trans/utf8_mac.$(OBJEXT): internal/value.h
enc/trans/utf8_mac.$(OBJEXT): internal/value_type.h
@@ -8475,6 +8576,7 @@ enc/trans/utf_16_32.$(OBJEXT): internal/intern/re.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/ruby.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/select.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/select/largesize.h
+enc/trans/utf_16_32.$(OBJEXT): internal/intern/set.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/signal.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/sprintf.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/string.h
@@ -8494,6 +8596,7 @@ enc/trans/utf_16_32.$(OBJEXT): internal/special_consts.h
enc/trans/utf_16_32.$(OBJEXT): internal/static_assert.h
enc/trans/utf_16_32.$(OBJEXT): internal/stdalign.h
enc/trans/utf_16_32.$(OBJEXT): internal/stdbool.h
+enc/trans/utf_16_32.$(OBJEXT): internal/stdckdint.h
enc/trans/utf_16_32.$(OBJEXT): internal/symbol.h
enc/trans/utf_16_32.$(OBJEXT): internal/value.h
enc/trans/utf_16_32.$(OBJEXT): internal/value_type.h
@@ -8636,6 +8739,7 @@ enc/unicode.$(OBJEXT): internal/intern/re.h
enc/unicode.$(OBJEXT): internal/intern/ruby.h
enc/unicode.$(OBJEXT): internal/intern/select.h
enc/unicode.$(OBJEXT): internal/intern/select/largesize.h
+enc/unicode.$(OBJEXT): internal/intern/set.h
enc/unicode.$(OBJEXT): internal/intern/signal.h
enc/unicode.$(OBJEXT): internal/intern/sprintf.h
enc/unicode.$(OBJEXT): internal/intern/string.h
@@ -8655,6 +8759,7 @@ enc/unicode.$(OBJEXT): internal/special_consts.h
enc/unicode.$(OBJEXT): internal/static_assert.h
enc/unicode.$(OBJEXT): internal/stdalign.h
enc/unicode.$(OBJEXT): internal/stdbool.h
+enc/unicode.$(OBJEXT): internal/stdckdint.h
enc/unicode.$(OBJEXT): internal/symbol.h
enc/unicode.$(OBJEXT): internal/value.h
enc/unicode.$(OBJEXT): internal/value_type.h
@@ -8806,6 +8911,7 @@ enc/us_ascii.$(OBJEXT): internal/intern/re.h
enc/us_ascii.$(OBJEXT): internal/intern/ruby.h
enc/us_ascii.$(OBJEXT): internal/intern/select.h
enc/us_ascii.$(OBJEXT): internal/intern/select/largesize.h
+enc/us_ascii.$(OBJEXT): internal/intern/set.h
enc/us_ascii.$(OBJEXT): internal/intern/signal.h
enc/us_ascii.$(OBJEXT): internal/intern/sprintf.h
enc/us_ascii.$(OBJEXT): internal/intern/string.h
@@ -8825,6 +8931,7 @@ enc/us_ascii.$(OBJEXT): internal/special_consts.h
enc/us_ascii.$(OBJEXT): internal/static_assert.h
enc/us_ascii.$(OBJEXT): internal/stdalign.h
enc/us_ascii.$(OBJEXT): internal/stdbool.h
+enc/us_ascii.$(OBJEXT): internal/stdckdint.h
enc/us_ascii.$(OBJEXT): internal/symbol.h
enc/us_ascii.$(OBJEXT): internal/value.h
enc/us_ascii.$(OBJEXT): internal/value_type.h
@@ -8968,6 +9075,7 @@ enc/utf_16be.$(OBJEXT): internal/intern/re.h
enc/utf_16be.$(OBJEXT): internal/intern/ruby.h
enc/utf_16be.$(OBJEXT): internal/intern/select.h
enc/utf_16be.$(OBJEXT): internal/intern/select/largesize.h
+enc/utf_16be.$(OBJEXT): internal/intern/set.h
enc/utf_16be.$(OBJEXT): internal/intern/signal.h
enc/utf_16be.$(OBJEXT): internal/intern/sprintf.h
enc/utf_16be.$(OBJEXT): internal/intern/string.h
@@ -8987,6 +9095,7 @@ enc/utf_16be.$(OBJEXT): internal/special_consts.h
enc/utf_16be.$(OBJEXT): internal/static_assert.h
enc/utf_16be.$(OBJEXT): internal/stdalign.h
enc/utf_16be.$(OBJEXT): internal/stdbool.h
+enc/utf_16be.$(OBJEXT): internal/stdckdint.h
enc/utf_16be.$(OBJEXT): internal/symbol.h
enc/utf_16be.$(OBJEXT): internal/value.h
enc/utf_16be.$(OBJEXT): internal/value_type.h
@@ -9129,6 +9238,7 @@ enc/utf_16le.$(OBJEXT): internal/intern/re.h
enc/utf_16le.$(OBJEXT): internal/intern/ruby.h
enc/utf_16le.$(OBJEXT): internal/intern/select.h
enc/utf_16le.$(OBJEXT): internal/intern/select/largesize.h
+enc/utf_16le.$(OBJEXT): internal/intern/set.h
enc/utf_16le.$(OBJEXT): internal/intern/signal.h
enc/utf_16le.$(OBJEXT): internal/intern/sprintf.h
enc/utf_16le.$(OBJEXT): internal/intern/string.h
@@ -9148,6 +9258,7 @@ enc/utf_16le.$(OBJEXT): internal/special_consts.h
enc/utf_16le.$(OBJEXT): internal/static_assert.h
enc/utf_16le.$(OBJEXT): internal/stdalign.h
enc/utf_16le.$(OBJEXT): internal/stdbool.h
+enc/utf_16le.$(OBJEXT): internal/stdckdint.h
enc/utf_16le.$(OBJEXT): internal/symbol.h
enc/utf_16le.$(OBJEXT): internal/value.h
enc/utf_16le.$(OBJEXT): internal/value_type.h
@@ -9290,6 +9401,7 @@ enc/utf_32be.$(OBJEXT): internal/intern/re.h
enc/utf_32be.$(OBJEXT): internal/intern/ruby.h
enc/utf_32be.$(OBJEXT): internal/intern/select.h
enc/utf_32be.$(OBJEXT): internal/intern/select/largesize.h
+enc/utf_32be.$(OBJEXT): internal/intern/set.h
enc/utf_32be.$(OBJEXT): internal/intern/signal.h
enc/utf_32be.$(OBJEXT): internal/intern/sprintf.h
enc/utf_32be.$(OBJEXT): internal/intern/string.h
@@ -9309,6 +9421,7 @@ enc/utf_32be.$(OBJEXT): internal/special_consts.h
enc/utf_32be.$(OBJEXT): internal/static_assert.h
enc/utf_32be.$(OBJEXT): internal/stdalign.h
enc/utf_32be.$(OBJEXT): internal/stdbool.h
+enc/utf_32be.$(OBJEXT): internal/stdckdint.h
enc/utf_32be.$(OBJEXT): internal/symbol.h
enc/utf_32be.$(OBJEXT): internal/value.h
enc/utf_32be.$(OBJEXT): internal/value_type.h
@@ -9451,6 +9564,7 @@ enc/utf_32le.$(OBJEXT): internal/intern/re.h
enc/utf_32le.$(OBJEXT): internal/intern/ruby.h
enc/utf_32le.$(OBJEXT): internal/intern/select.h
enc/utf_32le.$(OBJEXT): internal/intern/select/largesize.h
+enc/utf_32le.$(OBJEXT): internal/intern/set.h
enc/utf_32le.$(OBJEXT): internal/intern/signal.h
enc/utf_32le.$(OBJEXT): internal/intern/sprintf.h
enc/utf_32le.$(OBJEXT): internal/intern/string.h
@@ -9470,6 +9584,7 @@ enc/utf_32le.$(OBJEXT): internal/special_consts.h
enc/utf_32le.$(OBJEXT): internal/static_assert.h
enc/utf_32le.$(OBJEXT): internal/stdalign.h
enc/utf_32le.$(OBJEXT): internal/stdbool.h
+enc/utf_32le.$(OBJEXT): internal/stdckdint.h
enc/utf_32le.$(OBJEXT): internal/symbol.h
enc/utf_32le.$(OBJEXT): internal/value.h
enc/utf_32le.$(OBJEXT): internal/value_type.h
@@ -9621,6 +9736,7 @@ enc/utf_8.$(OBJEXT): internal/intern/re.h
enc/utf_8.$(OBJEXT): internal/intern/ruby.h
enc/utf_8.$(OBJEXT): internal/intern/select.h
enc/utf_8.$(OBJEXT): internal/intern/select/largesize.h
+enc/utf_8.$(OBJEXT): internal/intern/set.h
enc/utf_8.$(OBJEXT): internal/intern/signal.h
enc/utf_8.$(OBJEXT): internal/intern/sprintf.h
enc/utf_8.$(OBJEXT): internal/intern/string.h
@@ -9640,6 +9756,7 @@ enc/utf_8.$(OBJEXT): internal/special_consts.h
enc/utf_8.$(OBJEXT): internal/static_assert.h
enc/utf_8.$(OBJEXT): internal/stdalign.h
enc/utf_8.$(OBJEXT): internal/stdbool.h
+enc/utf_8.$(OBJEXT): internal/stdckdint.h
enc/utf_8.$(OBJEXT): internal/symbol.h
enc/utf_8.$(OBJEXT): internal/value.h
enc/utf_8.$(OBJEXT): internal/value_type.h
@@ -9783,6 +9900,7 @@ enc/windows_1250.$(OBJEXT): internal/intern/re.h
enc/windows_1250.$(OBJEXT): internal/intern/ruby.h
enc/windows_1250.$(OBJEXT): internal/intern/select.h
enc/windows_1250.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1250.$(OBJEXT): internal/intern/set.h
enc/windows_1250.$(OBJEXT): internal/intern/signal.h
enc/windows_1250.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1250.$(OBJEXT): internal/intern/string.h
@@ -9802,6 +9920,7 @@ enc/windows_1250.$(OBJEXT): internal/special_consts.h
enc/windows_1250.$(OBJEXT): internal/static_assert.h
enc/windows_1250.$(OBJEXT): internal/stdalign.h
enc/windows_1250.$(OBJEXT): internal/stdbool.h
+enc/windows_1250.$(OBJEXT): internal/stdckdint.h
enc/windows_1250.$(OBJEXT): internal/symbol.h
enc/windows_1250.$(OBJEXT): internal/value.h
enc/windows_1250.$(OBJEXT): internal/value_type.h
@@ -9943,6 +10062,7 @@ enc/windows_1251.$(OBJEXT): internal/intern/re.h
enc/windows_1251.$(OBJEXT): internal/intern/ruby.h
enc/windows_1251.$(OBJEXT): internal/intern/select.h
enc/windows_1251.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1251.$(OBJEXT): internal/intern/set.h
enc/windows_1251.$(OBJEXT): internal/intern/signal.h
enc/windows_1251.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1251.$(OBJEXT): internal/intern/string.h
@@ -9962,6 +10082,7 @@ enc/windows_1251.$(OBJEXT): internal/special_consts.h
enc/windows_1251.$(OBJEXT): internal/static_assert.h
enc/windows_1251.$(OBJEXT): internal/stdalign.h
enc/windows_1251.$(OBJEXT): internal/stdbool.h
+enc/windows_1251.$(OBJEXT): internal/stdckdint.h
enc/windows_1251.$(OBJEXT): internal/symbol.h
enc/windows_1251.$(OBJEXT): internal/value.h
enc/windows_1251.$(OBJEXT): internal/value_type.h
@@ -10104,6 +10225,7 @@ enc/windows_1252.$(OBJEXT): internal/intern/re.h
enc/windows_1252.$(OBJEXT): internal/intern/ruby.h
enc/windows_1252.$(OBJEXT): internal/intern/select.h
enc/windows_1252.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1252.$(OBJEXT): internal/intern/set.h
enc/windows_1252.$(OBJEXT): internal/intern/signal.h
enc/windows_1252.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1252.$(OBJEXT): internal/intern/string.h
@@ -10123,6 +10245,7 @@ enc/windows_1252.$(OBJEXT): internal/special_consts.h
enc/windows_1252.$(OBJEXT): internal/static_assert.h
enc/windows_1252.$(OBJEXT): internal/stdalign.h
enc/windows_1252.$(OBJEXT): internal/stdbool.h
+enc/windows_1252.$(OBJEXT): internal/stdckdint.h
enc/windows_1252.$(OBJEXT): internal/symbol.h
enc/windows_1252.$(OBJEXT): internal/value.h
enc/windows_1252.$(OBJEXT): internal/value_type.h
@@ -10264,6 +10387,7 @@ enc/windows_1253.$(OBJEXT): internal/intern/re.h
enc/windows_1253.$(OBJEXT): internal/intern/ruby.h
enc/windows_1253.$(OBJEXT): internal/intern/select.h
enc/windows_1253.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1253.$(OBJEXT): internal/intern/set.h
enc/windows_1253.$(OBJEXT): internal/intern/signal.h
enc/windows_1253.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1253.$(OBJEXT): internal/intern/string.h
@@ -10283,6 +10407,7 @@ enc/windows_1253.$(OBJEXT): internal/special_consts.h
enc/windows_1253.$(OBJEXT): internal/static_assert.h
enc/windows_1253.$(OBJEXT): internal/stdalign.h
enc/windows_1253.$(OBJEXT): internal/stdbool.h
+enc/windows_1253.$(OBJEXT): internal/stdckdint.h
enc/windows_1253.$(OBJEXT): internal/symbol.h
enc/windows_1253.$(OBJEXT): internal/value.h
enc/windows_1253.$(OBJEXT): internal/value_type.h
@@ -10425,6 +10550,7 @@ enc/windows_1254.$(OBJEXT): internal/intern/re.h
enc/windows_1254.$(OBJEXT): internal/intern/ruby.h
enc/windows_1254.$(OBJEXT): internal/intern/select.h
enc/windows_1254.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1254.$(OBJEXT): internal/intern/set.h
enc/windows_1254.$(OBJEXT): internal/intern/signal.h
enc/windows_1254.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1254.$(OBJEXT): internal/intern/string.h
@@ -10444,6 +10570,7 @@ enc/windows_1254.$(OBJEXT): internal/special_consts.h
enc/windows_1254.$(OBJEXT): internal/static_assert.h
enc/windows_1254.$(OBJEXT): internal/stdalign.h
enc/windows_1254.$(OBJEXT): internal/stdbool.h
+enc/windows_1254.$(OBJEXT): internal/stdckdint.h
enc/windows_1254.$(OBJEXT): internal/symbol.h
enc/windows_1254.$(OBJEXT): internal/value.h
enc/windows_1254.$(OBJEXT): internal/value_type.h
@@ -10586,6 +10713,7 @@ enc/windows_1257.$(OBJEXT): internal/intern/re.h
enc/windows_1257.$(OBJEXT): internal/intern/ruby.h
enc/windows_1257.$(OBJEXT): internal/intern/select.h
enc/windows_1257.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_1257.$(OBJEXT): internal/intern/set.h
enc/windows_1257.$(OBJEXT): internal/intern/signal.h
enc/windows_1257.$(OBJEXT): internal/intern/sprintf.h
enc/windows_1257.$(OBJEXT): internal/intern/string.h
@@ -10605,6 +10733,7 @@ enc/windows_1257.$(OBJEXT): internal/special_consts.h
enc/windows_1257.$(OBJEXT): internal/static_assert.h
enc/windows_1257.$(OBJEXT): internal/stdalign.h
enc/windows_1257.$(OBJEXT): internal/stdbool.h
+enc/windows_1257.$(OBJEXT): internal/stdckdint.h
enc/windows_1257.$(OBJEXT): internal/symbol.h
enc/windows_1257.$(OBJEXT): internal/value.h
enc/windows_1257.$(OBJEXT): internal/value_type.h
@@ -10749,6 +10878,7 @@ enc/windows_31j.$(OBJEXT): internal/intern/re.h
enc/windows_31j.$(OBJEXT): internal/intern/ruby.h
enc/windows_31j.$(OBJEXT): internal/intern/select.h
enc/windows_31j.$(OBJEXT): internal/intern/select/largesize.h
+enc/windows_31j.$(OBJEXT): internal/intern/set.h
enc/windows_31j.$(OBJEXT): internal/intern/signal.h
enc/windows_31j.$(OBJEXT): internal/intern/sprintf.h
enc/windows_31j.$(OBJEXT): internal/intern/string.h
@@ -10768,6 +10898,7 @@ enc/windows_31j.$(OBJEXT): internal/special_consts.h
enc/windows_31j.$(OBJEXT): internal/static_assert.h
enc/windows_31j.$(OBJEXT): internal/stdalign.h
enc/windows_31j.$(OBJEXT): internal/stdbool.h
+enc/windows_31j.$(OBJEXT): internal/stdckdint.h
enc/windows_31j.$(OBJEXT): internal/symbol.h
enc/windows_31j.$(OBJEXT): internal/value.h
enc/windows_31j.$(OBJEXT): internal/value_type.h
diff --git a/enc/ebcdic.h b/enc/ebcdic.h
index a3b380a327..5109bf7065 100644
--- a/enc/ebcdic.h
+++ b/enc/ebcdic.h
@@ -7,5 +7,5 @@ ENC_ALIAS("ebcdic-cp-us", "IBM037");
* hopefully the most widely used one.
*
* See http://www.iana.org/assignments/character-sets/character-sets.xhtml
- * http://tools.ietf.org/html/rfc1345
+ * https://www.rfc-editor.org/rfc/rfc1345
*/
diff --git a/enc/emacs_mule.c b/enc/emacs_mule.c
index f92eb183cf..abd986a187 100644
--- a/enc/emacs_mule.c
+++ b/enc/emacs_mule.c
@@ -334,7 +334,11 @@ OnigEncodingDefine(emacs_mule, Emacs_Mule) = {
onigenc_not_support_get_ctype_code_range,
left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/encinit.c.erb b/enc/encinit.c.erb
index 120408f8e3..3662ba200d 100644
--- a/enc/encinit.c.erb
+++ b/enc/encinit.c.erb
@@ -1,3 +1,6 @@
+/* Automatically generated from <%= erb.filename %>
+ * Do not edit<%# directly%>.
+ */
/* Copyright 2012 Google Inc. Some Rights Reserved.
* Author: yugui@google.com (Yugui Sonoda)
*/
diff --git a/enc/euc_jp.c b/enc/euc_jp.c
index d283bf4ebb..678d011668 100644
--- a/enc/euc_jp.c
+++ b/enc/euc_jp.c
@@ -576,7 +576,11 @@ OnigEncodingDefine(euc_jp, EUC_JP) = {
get_ctype_code_range,
left_adjust_char_head,
is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/euc_kr.c b/enc/euc_kr.c
index 21d6ab4e1c..4079a0ece0 100644
--- a/enc/euc_kr.c
+++ b/enc/euc_kr.c
@@ -188,7 +188,11 @@ OnigEncodingDefine(euc_kr, EUC_KR) = {
onigenc_not_support_get_ctype_code_range,
euckr_left_adjust_char_head,
euckr_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
@@ -213,7 +217,11 @@ OnigEncodingDefine(euc_cn, EUC_CN) = {
onigenc_not_support_get_ctype_code_range,
euckr_left_adjust_char_head,
euckr_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/euc_tw.c b/enc/euc_tw.c
index 1c5659cb1d..722e29a9da 100644
--- a/enc/euc_tw.c
+++ b/enc/euc_tw.c
@@ -221,7 +221,11 @@ OnigEncodingDefine(euc_tw, EUC_TW) = {
onigenc_not_support_get_ctype_code_range,
euctw_left_adjust_char_head,
euctw_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/gb18030.c b/enc/gb18030.c
index 63d2e633ec..316737db11 100644
--- a/enc/gb18030.c
+++ b/enc/gb18030.c
@@ -597,7 +597,11 @@ OnigEncodingDefine(gb18030, GB18030) = {
onigenc_not_support_get_ctype_code_range,
gb18030_left_adjust_char_head,
gb18030_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/gbk.c b/enc/gbk.c
index 31032553bf..3df4e4b6d6 100644
--- a/enc/gbk.c
+++ b/enc/gbk.c
@@ -211,7 +211,11 @@ OnigEncodingDefine(gbk, GBK) = {
onigenc_not_support_get_ctype_code_range,
gbk_left_adjust_char_head,
gbk_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_1.c b/enc/iso_8859_1.c
index 7af0888c3e..78ea1fba60 100644
--- a/enc/iso_8859_1.c
+++ b/enc/iso_8859_1.c
@@ -255,6 +255,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSE
return FALSE;
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -297,6 +298,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_1, ISO_8859_1) = {
onigenc_single_byte_mbc_enc_len,
@@ -315,7 +317,11 @@ OnigEncodingDefine(iso_8859_1, ISO_8859_1) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_10.c b/enc/iso_8859_10.c
index cae4be2db0..bf1c884cb2 100644
--- a/enc/iso_8859_10.c
+++ b/enc/iso_8859_10.c
@@ -224,6 +224,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -269,6 +270,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_10, ISO_8859_10) = {
onigenc_single_byte_mbc_enc_len,
@@ -287,7 +289,11 @@ OnigEncodingDefine(iso_8859_10, ISO_8859_10) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_11.c b/enc/iso_8859_11.c
index b9c6119fd9..403ae6499e 100644
--- a/enc/iso_8859_11.c
+++ b/enc/iso_8859_11.c
@@ -93,7 +93,11 @@ OnigEncodingDefine(iso_8859_11, ISO_8859_11) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_13.c b/enc/iso_8859_13.c
index fe1ddd7065..8c6e758b80 100644
--- a/enc/iso_8859_13.c
+++ b/enc/iso_8859_13.c
@@ -217,6 +217,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -264,6 +265,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_13, ISO_8859_13) = {
onigenc_single_byte_mbc_enc_len,
@@ -282,7 +284,11 @@ OnigEncodingDefine(iso_8859_13, ISO_8859_13) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_14.c b/enc/iso_8859_14.c
index 647514a016..21dffea76f 100644
--- a/enc/iso_8859_14.c
+++ b/enc/iso_8859_14.c
@@ -226,6 +226,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -280,6 +281,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_14, ISO_8859_14) = {
onigenc_single_byte_mbc_enc_len,
@@ -298,7 +300,11 @@ OnigEncodingDefine(iso_8859_14, ISO_8859_14) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_15.c b/enc/iso_8859_15.c
index 377a3afc7b..dd6c29a643 100644
--- a/enc/iso_8859_15.c
+++ b/enc/iso_8859_15.c
@@ -220,6 +220,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -271,6 +272,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_15, ISO_8859_15) = {
onigenc_single_byte_mbc_enc_len,
@@ -289,7 +291,11 @@ OnigEncodingDefine(iso_8859_15, ISO_8859_15) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_16.c b/enc/iso_8859_16.c
index 135630eb73..aa7ce99fba 100644
--- a/enc/iso_8859_16.c
+++ b/enc/iso_8859_16.c
@@ -222,6 +222,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -275,6 +276,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_16, ISO_8859_16) = {
onigenc_single_byte_mbc_enc_len,
@@ -293,7 +295,11 @@ OnigEncodingDefine(iso_8859_16, ISO_8859_16) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_2.c b/enc/iso_8859_2.c
index 3a05c6320d..859073fd14 100644
--- a/enc/iso_8859_2.c
+++ b/enc/iso_8859_2.c
@@ -220,6 +220,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSE
return FALSE;
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -266,6 +267,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_2, ISO_8859_2) = {
onigenc_single_byte_mbc_enc_len,
@@ -284,7 +286,11 @@ OnigEncodingDefine(iso_8859_2, ISO_8859_2) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_3.c b/enc/iso_8859_3.c
index 2a343eac63..d8199d5125 100644
--- a/enc/iso_8859_3.c
+++ b/enc/iso_8859_3.c
@@ -220,6 +220,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
#define DOTLESS_i (0xB9)
#define I_WITH_DOT_ABOVE (0xA9)
static int
@@ -276,6 +277,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_3, ISO_8859_3) = {
onigenc_single_byte_mbc_enc_len,
@@ -294,7 +296,11 @@ OnigEncodingDefine(iso_8859_3, ISO_8859_3) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_4.c b/enc/iso_8859_4.c
index e2134e8c0b..5f01f01575 100644
--- a/enc/iso_8859_4.c
+++ b/enc/iso_8859_4.c
@@ -223,6 +223,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -272,6 +273,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_4, ISO_8859_4) = {
onigenc_single_byte_mbc_enc_len,
@@ -290,7 +292,11 @@ OnigEncodingDefine(iso_8859_4, ISO_8859_4) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_5.c b/enc/iso_8859_5.c
index 6fafc35823..8223fc0ec7 100644
--- a/enc/iso_8859_5.c
+++ b/enc/iso_8859_5.c
@@ -209,6 +209,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -240,6 +241,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_5, ISO_8859_5) = {
onigenc_single_byte_mbc_enc_len,
@@ -258,7 +260,11 @@ OnigEncodingDefine(iso_8859_5, ISO_8859_5) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_6.c b/enc/iso_8859_6.c
index cdb74054d1..78543ea307 100644
--- a/enc/iso_8859_6.c
+++ b/enc/iso_8859_6.c
@@ -93,7 +93,11 @@ OnigEncodingDefine(iso_8859_6, ISO_8859_6) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_7.c b/enc/iso_8859_7.c
index ac973f74ba..e84f5c3460 100644
--- a/enc/iso_8859_7.c
+++ b/enc/iso_8859_7.c
@@ -205,6 +205,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -259,6 +260,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_7, ISO_8859_7) = {
onigenc_single_byte_mbc_enc_len,
@@ -277,7 +279,11 @@ OnigEncodingDefine(iso_8859_7, ISO_8859_7) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_8.c b/enc/iso_8859_8.c
index e256855f21..b757a283de 100644
--- a/enc/iso_8859_8.c
+++ b/enc/iso_8859_8.c
@@ -93,7 +93,11 @@ OnigEncodingDefine(iso_8859_8, ISO_8859_8) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/iso_8859_9.c b/enc/iso_8859_9.c
index 004eec310f..f15953963b 100644
--- a/enc/iso_8859_9.c
+++ b/enc/iso_8859_9.c
@@ -213,6 +213,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
#define DOTLESS_i (0xFD)
#define I_WITH_DOT_ABOVE (0xDD)
static int
@@ -265,6 +266,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(iso_8859_9, ISO_8859_9) = {
onigenc_single_byte_mbc_enc_len,
@@ -283,7 +285,11 @@ OnigEncodingDefine(iso_8859_9, ISO_8859_9) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/jis/props.h.blt b/enc/jis/props.h.blt
index 508a084449..865ae6b651 100644
--- a/enc/jis/props.h.blt
+++ b/enc/jis/props.h.blt
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property enc/jis/props.kwd */
+/* Command-line: gperf -L ANSI-C -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property enc/jis/props.kwd */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,7 +28,6 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
-#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "enc/jis/props.kwd"
/* -*- c -*- */
#define GPERF_DOWNCASE 1
@@ -82,7 +81,7 @@ struct enc_property;
#ifndef GPERF_DOWNCASE
#define GPERF_DOWNCASE 1
-static const unsigned char gperf_downcase[256] =
+static unsigned char gperf_downcase[256] =
{
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,
@@ -180,19 +179,19 @@ onig_jis_property (register const char *str, register size_t len)
{
{-1}, {-1}, {-1}, {-1}, {-1},
#line 48 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 5), onigenc_jis_han},
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str5, onigenc_jis_han},
{-1},
#line 49 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 7), onigenc_jis_latin},
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str7, onigenc_jis_latin},
#line 50 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 8), onigenc_jis_greek},
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str8, onigenc_jis_greek},
{-1},
#line 46 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 10), onigenc_jis_hiragana},
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str10, onigenc_jis_hiragana},
#line 47 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 11), onigenc_jis_katakana},
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str11, onigenc_jis_katakana},
#line 51 "enc/jis/props.kwd"
- {gperf_offsetof(onig_jis_property_pool, 12), onigenc_jis_cyrillic}
+ {(int)(size_t)&((struct onig_jis_property_pool_t *)0)->onig_jis_property_pool_str12, onigenc_jis_cyrillic}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/enc/koi8_r.c b/enc/koi8_r.c
index a520975774..39f2482465 100644
--- a/enc/koi8_r.c
+++ b/enc/koi8_r.c
@@ -214,7 +214,11 @@ OnigEncodingDefine(koi8_r, KOI8_R) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/koi8_u.c b/enc/koi8_u.c
index 50bb78bd04..8cd890dd16 100644
--- a/enc/koi8_u.c
+++ b/enc/koi8_u.c
@@ -218,7 +218,11 @@ OnigEncodingDefine(koi8_u, KOI8_U) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
index fcfc2c9267..e5ed4eb4b5 100755
--- a/enc/make_encmake.rb
+++ b/enc/make_encmake.rb
@@ -1,8 +1,11 @@
#! ./miniruby
dir = File.expand_path("../..", __FILE__)
-$:.unshift(dir)
-$:.unshift(".")
+# The source lib directory provides the standard library for miniruby.
+# Don't add it when running with baseruby to avoid loading both
+# baseruby's cgi/escape.so and source cgi/escape.rb via erb.
+$:.unshift("#{dir}/lib") unless defined?(CROSS_COMPILING)
+$:.unshift(Dir.pwd, "#{dir}/tool/lib")
if $".grep(/mkmf/).empty?
$" << "mkmf.rb"
load File.expand_path("lib/mkmf.rb", dir)
@@ -121,39 +124,32 @@ ENCS, ENC_DEPS = target_encodings
ATRANS, TRANS = target_transcoders
if File.exist?(depend = File.join($srcdir, "depend"))
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- erb = ERB.new(File.read(depend), trim_mode: '%')
- else
- erb = ERB.new(File.read(depend), nil, '%')
- end
+ erb = ERB.new(File.read(depend), trim_mode: '%')
erb.filename = depend
tmp = erb.result(binding)
- dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
+ 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]}
+# Variables that should not be expanded in Makefile.in to allow
+# overriding inherited variables at make-time.
+not_expand_vars = %w(CFLAGS)
+mkin.gsub!(/@(#{RbConfig::CONFIG.keys.join('|')})@/) do
+ not_expand_vars.include?($1) ? CONFIG[$1] : RbConfig::CONFIG[$1]
+end
File.open(ARGV[0], 'wb') {|f|
f.puts mkin, dep
}
if MODULE_TYPE == :static
filename = "encinit.c.erb"
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
- else
- erb = ERB.new(File.read(File.join($srcdir, filename)), nil, '%-')
- end
+ erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
erb.filename = "enc/#{filename}"
tmp = erb.result(binding)
begin
Dir.mkdir 'enc'
rescue Errno::EEXIST
end
- File.open("enc/encinit.c", "w") {|f|
- f.puts "/* Automatically generated from enc/encinit.c.erb"
- f.puts " * Do not edit."
- f.puts " */"
- f.puts tmp
- }
+ require 'output'
+ Output.new(path: "enc/encinit.c", ifchange: true).write(tmp)
end
diff --git a/enc/shift_jis.c b/enc/shift_jis.c
index f1355d2d95..48f648868a 100644
--- a/enc/shift_jis.c
+++ b/enc/shift_jis.c
@@ -47,7 +47,11 @@ OnigEncodingDefine(shift_jis, Shift_JIS) = {
get_ctype_code_range,
left_adjust_char_head,
is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/trans/ibm864-tbl.rb b/enc/trans/ibm864-tbl.rb
new file mode 100644
index 0000000000..13f8a27f1d
--- /dev/null
+++ b/enc/trans/ibm864-tbl.rb
@@ -0,0 +1,126 @@
+IBM864_TO_UCS_TBL = [
+ ["80",0x00B0],
+ ["81",0x00B7],
+ ["82",0x2219],
+ ["83",0x221A],
+ ["84",0x2592],
+ ["85",0x2500],
+ ["86",0x2502],
+ ["87",0x253C],
+ ["88",0x2524],
+ ["89",0x252C],
+ ["8A",0x251C],
+ ["8B",0x2534],
+ ["8C",0x2510],
+ ["8D",0x250C],
+ ["8E",0x2514],
+ ["8F",0x2518],
+ ["90",0x03B2],
+ ["91",0x221E],
+ ["92",0x03C6],
+ ["93",0x00B1],
+ ["94",0x00BD],
+ ["95",0x00BC],
+ ["96",0x2248],
+ ["97",0x00AB],
+ ["98",0x00BB],
+ ["99",0xFEF7],
+ ["9A",0xFEF8],
+ ["9D",0xFEFB],
+ ["9E",0xFEFC],
+ ["9F",0xFE73],
+ ["A0",0x00A0],
+ ["A1",0x00AD],
+ ["A2",0xFE82],
+ ["A3",0x00A3],
+ ["A4",0x00A4],
+ ["A5",0xFE84],
+ ["A7",0x20AC], # Euro sign from CCSID 864
+ ["A8",0xFE8E],
+ ["A9",0xFE8F],
+ ["AA",0xFE95],
+ ["AB",0xFE99],
+ ["AC",0x060C],
+ ["AD",0xFE9D],
+ ["AE",0xFEA1],
+ ["AF",0xFEA5],
+ ["B0",0x0660],
+ ["B1",0x0661],
+ ["B2",0x0662],
+ ["B3",0x0663],
+ ["B4",0x0664],
+ ["B5",0x0665],
+ ["B6",0x0666],
+ ["B7",0x0667],
+ ["B8",0x0668],
+ ["B9",0x0669],
+ ["BA",0xFED1],
+ ["BB",0x061B],
+ ["BC",0xFEB1],
+ ["BD",0xFEB5],
+ ["BE",0xFEB9],
+ ["BF",0x061F],
+ ["C0",0x00A2],
+ ["C1",0xFE80],
+ ["C2",0xFE81],
+ ["C3",0xFE83],
+ ["C4",0xFE85],
+ ["C5",0xFECA],
+ ["C6",0xFE8B],
+ ["C7",0xFE8D],
+ ["C8",0xFE91],
+ ["C9",0xFE93],
+ ["CA",0xFE97],
+ ["CB",0xFE9B],
+ ["CC",0xFE9F],
+ ["CD",0xFEA3],
+ ["CE",0xFEA7],
+ ["CF",0xFEA9],
+ ["D0",0xFEAB],
+ ["D1",0xFEAD],
+ ["D2",0xFEAF],
+ ["D3",0xFEB3],
+ ["D4",0xFEB7],
+ ["D5",0xFEBB],
+ ["D6",0xFEBF],
+ ["D7",0xFEC1],
+ ["D8",0xFEC5],
+ ["D9",0xFECB],
+ ["DA",0xFECF],
+ ["DB",0x00A6],
+ ["DC",0x00AC],
+ ["DD",0x00F7],
+ ["DE",0x00D7],
+ ["DF",0xFEC9],
+ ["E0",0x0640],
+ ["E1",0xFED3],
+ ["E2",0xFED7],
+ ["E3",0xFEDB],
+ ["E4",0xFEDF],
+ ["E5",0xFEE3],
+ ["E6",0xFEE7],
+ ["E7",0xFEEB],
+ ["E8",0xFEED],
+ ["E9",0xFEEF],
+ ["EA",0xFEF3],
+ ["EB",0xFEBD],
+ ["EC",0xFECC],
+ ["ED",0xFECE],
+ ["EE",0xFECD],
+ ["EF",0xFEE1],
+ ["F0",0xFE7D],
+ ["F1",0x0651],
+ ["F2",0xFEE5],
+ ["F3",0xFEE9],
+ ["F4",0xFEEC],
+ ["F5",0xFEF0],
+ ["F6",0xFEF2],
+ ["F7",0xFED0],
+ ["F8",0xFED5],
+ ["F9",0xFEF5],
+ ["FA",0xFEF6],
+ ["FB",0xFEDD],
+ ["FC",0xFED9],
+ ["FD",0xFEF1],
+ ["FE",0x25A0]
+]
diff --git a/enc/trans/iso2022.trans b/enc/trans/iso2022.trans
index a441f1596d..bc42bbc19c 100644
--- a/enc/trans/iso2022.trans
+++ b/enc/trans/iso2022.trans
@@ -1,4 +1,5 @@
#include "transcode_data.h"
+#include "ruby/internal/attr/nonstring.h"
<%
map = {
@@ -79,6 +80,34 @@ iso2022jp_init(void *statep)
return 0;
}
+static unsigned char *
+iso2022jp_put_state(unsigned char *sp, unsigned char *o, int oldstate, int newstate)
+{
+ if (oldstate != newstate) {
+ *o++ = 0x1b;
+ switch (newstate) {
+ case G0_ASCII:
+ *o++ = '(';
+ *o++ = 'B';
+ break;
+ case G0_JISX0201_KATAKANA:
+ *o++ = '(';
+ *o++ = 'I';
+ break;
+ case G0_JISX0208_1978:
+ *o++ = '$';
+ *o++ = '@';
+ break;
+ default:
+ *o++ = '$';
+ *o++ = 'B';
+ break;
+ }
+ *sp = newstate;
+ }
+ return o;
+}
+
static VALUE
fun_si_iso2022jp_decoder(void *statep, const unsigned char *s, size_t l)
{
@@ -154,24 +183,7 @@ fun_so_iso2022jp_encoder(void *statep, const unsigned char *s, size_t l, unsigne
else
newstate = G0_JISX0208_1983;
- if (*sp != newstate) {
- if (newstate == G0_ASCII) {
- *o++ = 0x1b;
- *o++ = '(';
- *o++ = 'B';
- }
- else if (newstate == G0_JISX0208_1978) {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = '@';
- }
- else {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = 'B';
- }
- *sp = newstate;
- }
+ o = iso2022jp_put_state(sp, o, *sp, newstate);
if (l == 1) {
*o++ = s[0] & 0x7f;
@@ -202,10 +214,7 @@ finish_iso2022jp_encoder(void *statep, unsigned char *o, size_t osize)
if (*sp == G0_ASCII)
return 0;
- *o++ = 0x1b;
- *o++ = '(';
- *o++ = 'B';
- *sp = G0_ASCII;
+ o = iso2022jp_put_state(sp, o, *sp, G0_ASCII);
return o - output0;
}
@@ -399,24 +408,7 @@ fun_so_cp5022x_encoder(void *statep, const unsigned char *s, size_t l,
else
newstate = G0_JISX0208_1983;
- if (*sp != newstate) {
- if (newstate == G0_ASCII) {
- *o++ = 0x1b;
- *o++ = '(';
- *o++ = 'B';
- }
- else if (newstate == G0_JISX0201_KATAKANA) {
- *o++ = 0x1b;
- *o++ = '(';
- *o++ = 'I';
- }
- else {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = 'B';
- }
- *sp = newstate;
- }
+ o = iso2022jp_put_state(sp, o, sp[0], newstate);
if (l == 1) {
*o++ = s[0] & 0x7f;
@@ -443,15 +435,26 @@ rb_cp50221_encoder = {
iso2022jp_encoder_reset_sequence_size, finish_iso2022jp_encoder
};
-static const char *tbl0208 =
- "\x21\x23\x21\x56\x21\x57\x21\x22\x21\x26\x25\x72\x25\x21\x25\x23" \
- "\x25\x25\x25\x27\x25\x29\x25\x63\x25\x65\x25\x67\x25\x43\x21\x3C" \
- "\x25\x22\x25\x24\x25\x26\x25\x28\x25\x2A\x25\x2B\x25\x2D\x25\x2F" \
- "\x25\x31\x25\x33\x25\x35\x25\x37\x25\x39\x25\x3B\x25\x3D\x25\x3F" \
- "\x25\x41\x25\x44\x25\x46\x25\x48\x25\x4A\x25\x4B\x25\x4C\x25\x4D" \
- "\x25\x4E\x25\x4F\x25\x52\x25\x55\x25\x58\x25\x5B\x25\x5E\x25\x5F" \
- "\x25\x60\x25\x61\x25\x62\x25\x64\x25\x66\x25\x68\x25\x69\x25\x6A" \
- "\x25\x6B\x25\x6C\x25\x6D\x25\x6F\x25\x73\x21\x2B\x21\x2C";
+/* JIS0201 to JIS0208 conversion table */
+enum {tbl0208_num = 0xDF - 0xA1 + 1};
+RBIMPL_ATTR_NONSTRING_ARRAY() static const char tbl0208[tbl0208_num][2] = {
+ "\x21\x23", "\x21\x56", "\x21\x57", "\x21\x22",
+ "\x21\x26", "\x25\x72", "\x25\x21", "\x25\x23",
+ "\x25\x25", "\x25\x27", "\x25\x29", "\x25\x63",
+ "\x25\x65", "\x25\x67", "\x25\x43", "\x21\x3C",
+ "\x25\x22", "\x25\x24", "\x25\x26", "\x25\x28",
+ "\x25\x2A", "\x25\x2B", "\x25\x2D", "\x25\x2F",
+ "\x25\x31", "\x25\x33", "\x25\x35", "\x25\x37",
+ "\x25\x39", "\x25\x3B", "\x25\x3D", "\x25\x3F",
+ "\x25\x41", "\x25\x44", "\x25\x46", "\x25\x48",
+ "\x25\x4A", "\x25\x4B", "\x25\x4C", "\x25\x4D",
+ "\x25\x4E", "\x25\x4F", "\x25\x52", "\x25\x55",
+ "\x25\x58", "\x25\x5B", "\x25\x5E", "\x25\x5F",
+ "\x25\x60", "\x25\x61", "\x25\x62", "\x25\x64",
+ "\x25\x66", "\x25\x68", "\x25\x69", "\x25\x6A",
+ "\x25\x6B", "\x25\x6C", "\x25\x6D", "\x25\x6F",
+ "\x25\x73", "\x21\x2B", "\x21\x2C"
+};
static ssize_t
fun_so_cp50220_encoder(void *statep, const unsigned char *s, size_t l,
@@ -460,22 +463,21 @@ fun_so_cp50220_encoder(void *statep, const unsigned char *s, size_t l,
unsigned char *output0 = o;
unsigned char *sp = statep;
- if (sp[0] == G0_JISX0201_KATAKANA) {
+ if (sp[0] == G0_JISX0201_KATAKANA && sp[2]) {
int c = sp[2] & 0x7F;
- const char *p = tbl0208 + (c - 0x21) * 2;
- if (sp[1] != G0_JISX0208_1983) {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = 'B';
- }
+ const char *p = tbl0208[c - 0x21];
+ sp[2] = 0;
+ o = iso2022jp_put_state(sp, o, sp[1], G0_JISX0208_1983);
sp[0] = G0_JISX0208_1983;
*o++ = *p++;
if (l == 2 && s[0] == 0x8E) {
if (s[1] == 0xDE) {
+ /* VOICED SOUND MARK */
*o++ = *p + 1;
return o - output0;
}
else if (s[1] == 0xDF && (0x4A <= c && c <= 0x4E)) {
+ /* SEMI-VOICED SOUND MARK */
*o++ = *p + 2;
return o - output0;
}
@@ -484,21 +486,25 @@ fun_so_cp50220_encoder(void *statep, const unsigned char *s, size_t l,
}
if (l == 2 && s[0] == 0x8E) {
- const char *p = tbl0208 + (s[1] - 0xA1) * 2;
if ((0xA1 <= s[1] && s[1] <= 0xB5) ||
(0xC5 <= s[1] && s[1] <= 0xC9) ||
(0xCF <= s[1] && s[1] <= 0xDF)) {
- if (*sp != G0_JISX0208_1983) {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = 'B';
- *sp = G0_JISX0208_1983;
- }
+ /* May not be followed by a sound mark */
+ const char *p = tbl0208[s[1] - 0xA1];
+ o = iso2022jp_put_state(sp, o, *sp, G0_JISX0208_1983);
*o++ = *p++;
*o++ = *p;
return o - output0;
}
+ if (s[1] > 0xDF) { /* undef */
+ o = iso2022jp_put_state(sp, o, *sp, G0_JISX0201_KATAKANA);
+ *o++ = s[1] & 0x7F;
+ sp[2] = 0;
+ return o - output0;
+ }
+
+ /* Katakana that may be followed by a sound mark */
sp[2] = s[1];
sp[1] = sp[0];
sp[0] = G0_JISX0201_KATAKANA;
@@ -518,23 +524,16 @@ finish_cp50220_encoder(void *statep, unsigned char *o, size_t osize)
if (*sp == G0_ASCII)
return 0;
- if (sp[0] == G0_JISX0201_KATAKANA) {
+ if (sp[0] == G0_JISX0201_KATAKANA && sp[2]) {
int c = sp[2] & 0x7F;
- const char *p = tbl0208 + (c - 0x21) * 2;
- if (sp[1] != G0_JISX0208_1983) {
- *o++ = 0x1b;
- *o++ = '$';
- *o++ = 'B';
- }
+ const char *p = tbl0208[c - 0x21];
+ o = iso2022jp_put_state(sp, o, sp[1], G0_JISX0208_1983);
sp[0] = G0_JISX0208_1983;
*o++ = *p++;
*o++ = *p;
}
- *o++ = 0x1b;
- *o++ = '(';
- *o++ = 'B';
- *sp = G0_ASCII;
+ o = iso2022jp_put_state(sp, o, sp[0], G0_ASCII);
return o - output0;
}
@@ -564,4 +563,3 @@ TRANS_INIT(iso2022)
rb_register_transcoder(&rb_cp50220_encoder);
rb_register_transcoder(&rb_cp50221_encoder);
}
-
diff --git a/enc/trans/single_byte.trans b/enc/trans/single_byte.trans
index 0d5407b918..c326cbebea 100644
--- a/enc/trans/single_byte.trans
+++ b/enc/trans/single_byte.trans
@@ -61,6 +61,7 @@
transcode_tblgen_singlebyte "IBM861"
transcode_tblgen_singlebyte "IBM862"
transcode_tblgen_singlebyte "IBM863"
+ transcode_tblgen_singlebyte "IBM864"
transcode_tblgen_singlebyte "IBM865"
transcode_tblgen_singlebyte "IBM866"
transcode_tblgen_singlebyte "IBM869"
diff --git a/enc/unicode.c b/enc/unicode.c
index 18fba02476..5bc806863e 100644
--- a/enc/unicode.c
+++ b/enc/unicode.c
@@ -655,6 +655,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
return n;
}
+#ifdef USE_CASE_MAP_API
/* length in bytes for three characters in UTF-32; e.g. needed for ffi (U+FB03) */
#define CASE_MAPPING_SLACK 12
#define MODIFIED (flags |= ONIGENC_CASE_MODIFIED)
@@ -682,15 +683,13 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
*pp += codepoint_length;
if (code <= 'z') { /* ASCII comes first */
- if (code >= 'a' && code <= 'z') {
+ if (code >= 'a' /*&& code <= 'z'*/) {
if (flags & ONIGENC_CASE_UPCASE) {
MODIFIED;
if (flags & ONIGENC_CASE_FOLD_TURKISH_AZERI && code == 'i')
code = I_WITH_DOT_ABOVE;
- else {
- code -= 'a';
- code += 'A';
- }
+ else
+ code -= 'a' - 'A';
}
}
else if (code >= 'A' && code <= 'Z') {
@@ -800,8 +799,8 @@ SpecialsCopy:
*flagP = flags;
return (int )(to - to_start);
}
+#endif
-#if 0
const char onigenc_unicode_version_string[] =
#ifdef ONIG_UNICODE_VERSION_STRING
ONIG_UNICODE_VERSION_STRING
@@ -817,4 +816,3 @@ const int onigenc_unicode_version_number[3] = {
0
#endif
};
-#endif
diff --git a/enc/unicode/15.0.0/casefold.h b/enc/unicode/15.0.0/casefold.h
deleted file mode 100644
index 51120d867d..0000000000
--- a/enc/unicode/15.0.0/casefold.h
+++ /dev/null
@@ -1,7629 +0,0 @@
-/* DO NOT EDIT THIS FILE. */
-/* Generated by enc-case-folding.rb */
-
-#if defined ONIG_UNICODE_VERSION_STRING && !( \
- ONIG_UNICODE_VERSION_MAJOR == 15 && \
- ONIG_UNICODE_VERSION_MINOR == 0 && \
- ONIG_UNICODE_VERSION_TEENY == 0 && \
- 1)
-# error ONIG_UNICODE_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_VERSION_STRING "15.0.0"
-#define ONIG_UNICODE_VERSION_MAJOR 15
-#define ONIG_UNICODE_VERSION_MINOR 0
-#define ONIG_UNICODE_VERSION_TEENY 0
-
-static const CaseFold_11_Type CaseFold_11_Table[] = {
-#define CaseFold (*(CaseFold_11_Type (*)[1528])(CaseFold_11_Table+0))
- {0x0041, {1|F|D, {0x0061}}},
- {0x0042, {1|F|D, {0x0062}}},
- {0x0043, {1|F|D, {0x0063}}},
- {0x0044, {1|F|D, {0x0064}}},
- {0x0045, {1|F|D, {0x0065}}},
- {0x0046, {1|F|D, {0x0066}}},
- {0x0047, {1|F|D, {0x0067}}},
- {0x0048, {1|F|D, {0x0068}}},
- {0x004a, {1|F|D, {0x006a}}},
- {0x004b, {1|F|D, {0x006b}}},
- {0x004c, {1|F|D, {0x006c}}},
- {0x004d, {1|F|D, {0x006d}}},
- {0x004e, {1|F|D, {0x006e}}},
- {0x004f, {1|F|D, {0x006f}}},
- {0x0050, {1|F|D, {0x0070}}},
- {0x0051, {1|F|D, {0x0071}}},
- {0x0052, {1|F|D, {0x0072}}},
- {0x0053, {1|F|D, {0x0073}}},
- {0x0054, {1|F|D, {0x0074}}},
- {0x0055, {1|F|D, {0x0075}}},
- {0x0056, {1|F|D, {0x0076}}},
- {0x0057, {1|F|D, {0x0077}}},
- {0x0058, {1|F|D, {0x0078}}},
- {0x0059, {1|F|D, {0x0079}}},
- {0x005a, {1|F|D, {0x007a}}},
- {0x00b5, {1|F|SU|I(0), {0x03bc}}},
- {0x00c0, {1|F|D, {0x00e0}}},
- {0x00c1, {1|F|D, {0x00e1}}},
- {0x00c2, {1|F|D, {0x00e2}}},
- {0x00c3, {1|F|D, {0x00e3}}},
- {0x00c4, {1|F|D, {0x00e4}}},
- {0x00c5, {1|F|D, {0x00e5}}},
- {0x00c6, {1|F|D, {0x00e6}}},
- {0x00c7, {1|F|D, {0x00e7}}},
- {0x00c8, {1|F|D, {0x00e8}}},
- {0x00c9, {1|F|D, {0x00e9}}},
- {0x00ca, {1|F|D, {0x00ea}}},
- {0x00cb, {1|F|D, {0x00eb}}},
- {0x00cc, {1|F|D, {0x00ec}}},
- {0x00cd, {1|F|D, {0x00ed}}},
- {0x00ce, {1|F|D, {0x00ee}}},
- {0x00cf, {1|F|D, {0x00ef}}},
- {0x00d0, {1|F|D, {0x00f0}}},
- {0x00d1, {1|F|D, {0x00f1}}},
- {0x00d2, {1|F|D, {0x00f2}}},
- {0x00d3, {1|F|D, {0x00f3}}},
- {0x00d4, {1|F|D, {0x00f4}}},
- {0x00d5, {1|F|D, {0x00f5}}},
- {0x00d6, {1|F|D, {0x00f6}}},
- {0x00d8, {1|F|D, {0x00f8}}},
- {0x00d9, {1|F|D, {0x00f9}}},
- {0x00da, {1|F|D, {0x00fa}}},
- {0x00db, {1|F|D, {0x00fb}}},
- {0x00dc, {1|F|D, {0x00fc}}},
- {0x00dd, {1|F|D, {0x00fd}}},
- {0x00de, {1|F|D, {0x00fe}}},
- {0x00df, {2|F|ST|SU|I(1), {0x0073, 0x0073}}},
- {0x0100, {1|F|D, {0x0101}}},
- {0x0102, {1|F|D, {0x0103}}},
- {0x0104, {1|F|D, {0x0105}}},
- {0x0106, {1|F|D, {0x0107}}},
- {0x0108, {1|F|D, {0x0109}}},
- {0x010a, {1|F|D, {0x010b}}},
- {0x010c, {1|F|D, {0x010d}}},
- {0x010e, {1|F|D, {0x010f}}},
- {0x0110, {1|F|D, {0x0111}}},
- {0x0112, {1|F|D, {0x0113}}},
- {0x0114, {1|F|D, {0x0115}}},
- {0x0116, {1|F|D, {0x0117}}},
- {0x0118, {1|F|D, {0x0119}}},
- {0x011a, {1|F|D, {0x011b}}},
- {0x011c, {1|F|D, {0x011d}}},
- {0x011e, {1|F|D, {0x011f}}},
- {0x0120, {1|F|D, {0x0121}}},
- {0x0122, {1|F|D, {0x0123}}},
- {0x0124, {1|F|D, {0x0125}}},
- {0x0126, {1|F|D, {0x0127}}},
- {0x0128, {1|F|D, {0x0129}}},
- {0x012a, {1|F|D, {0x012b}}},
- {0x012c, {1|F|D, {0x012d}}},
- {0x012e, {1|F|D, {0x012f}}},
- {0x0132, {1|F|D, {0x0133}}},
- {0x0134, {1|F|D, {0x0135}}},
- {0x0136, {1|F|D, {0x0137}}},
- {0x0139, {1|F|D, {0x013a}}},
- {0x013b, {1|F|D, {0x013c}}},
- {0x013d, {1|F|D, {0x013e}}},
- {0x013f, {1|F|D, {0x0140}}},
- {0x0141, {1|F|D, {0x0142}}},
- {0x0143, {1|F|D, {0x0144}}},
- {0x0145, {1|F|D, {0x0146}}},
- {0x0147, {1|F|D, {0x0148}}},
- {0x0149, {2|F|SU|I(5), {0x02bc, 0x006e}}},
- {0x014a, {1|F|D, {0x014b}}},
- {0x014c, {1|F|D, {0x014d}}},
- {0x014e, {1|F|D, {0x014f}}},
- {0x0150, {1|F|D, {0x0151}}},
- {0x0152, {1|F|D, {0x0153}}},
- {0x0154, {1|F|D, {0x0155}}},
- {0x0156, {1|F|D, {0x0157}}},
- {0x0158, {1|F|D, {0x0159}}},
- {0x015a, {1|F|D, {0x015b}}},
- {0x015c, {1|F|D, {0x015d}}},
- {0x015e, {1|F|D, {0x015f}}},
- {0x0160, {1|F|D, {0x0161}}},
- {0x0162, {1|F|D, {0x0163}}},
- {0x0164, {1|F|D, {0x0165}}},
- {0x0166, {1|F|D, {0x0167}}},
- {0x0168, {1|F|D, {0x0169}}},
- {0x016a, {1|F|D, {0x016b}}},
- {0x016c, {1|F|D, {0x016d}}},
- {0x016e, {1|F|D, {0x016f}}},
- {0x0170, {1|F|D, {0x0171}}},
- {0x0172, {1|F|D, {0x0173}}},
- {0x0174, {1|F|D, {0x0175}}},
- {0x0176, {1|F|D, {0x0177}}},
- {0x0178, {1|F|D, {0x00ff}}},
- {0x0179, {1|F|D, {0x017a}}},
- {0x017b, {1|F|D, {0x017c}}},
- {0x017d, {1|F|D, {0x017e}}},
- {0x017f, {1|F|SU|I(7), {0x0073}}},
- {0x0181, {1|F|D, {0x0253}}},
- {0x0182, {1|F|D, {0x0183}}},
- {0x0184, {1|F|D, {0x0185}}},
- {0x0186, {1|F|D, {0x0254}}},
- {0x0187, {1|F|D, {0x0188}}},
- {0x0189, {1|F|D, {0x0256}}},
- {0x018a, {1|F|D, {0x0257}}},
- {0x018b, {1|F|D, {0x018c}}},
- {0x018e, {1|F|D, {0x01dd}}},
- {0x018f, {1|F|D, {0x0259}}},
- {0x0190, {1|F|D, {0x025b}}},
- {0x0191, {1|F|D, {0x0192}}},
- {0x0193, {1|F|D, {0x0260}}},
- {0x0194, {1|F|D, {0x0263}}},
- {0x0196, {1|F|D, {0x0269}}},
- {0x0197, {1|F|D, {0x0268}}},
- {0x0198, {1|F|D, {0x0199}}},
- {0x019c, {1|F|D, {0x026f}}},
- {0x019d, {1|F|D, {0x0272}}},
- {0x019f, {1|F|D, {0x0275}}},
- {0x01a0, {1|F|D, {0x01a1}}},
- {0x01a2, {1|F|D, {0x01a3}}},
- {0x01a4, {1|F|D, {0x01a5}}},
- {0x01a6, {1|F|D, {0x0280}}},
- {0x01a7, {1|F|D, {0x01a8}}},
- {0x01a9, {1|F|D, {0x0283}}},
- {0x01ac, {1|F|D, {0x01ad}}},
- {0x01ae, {1|F|D, {0x0288}}},
- {0x01af, {1|F|D, {0x01b0}}},
- {0x01b1, {1|F|D, {0x028a}}},
- {0x01b2, {1|F|D, {0x028b}}},
- {0x01b3, {1|F|D, {0x01b4}}},
- {0x01b5, {1|F|D, {0x01b6}}},
- {0x01b7, {1|F|D, {0x0292}}},
- {0x01b8, {1|F|D, {0x01b9}}},
- {0x01bc, {1|F|D, {0x01bd}}},
- {0x01c4, {1|F|D|ST|I(8), {0x01c6}}},
- {0x01c5, {1|F|D|IT|SU|I(9), {0x01c6}}},
- {0x01c7, {1|F|D|ST|I(12), {0x01c9}}},
- {0x01c8, {1|F|D|IT|SU|I(13), {0x01c9}}},
- {0x01ca, {1|F|D|ST|I(16), {0x01cc}}},
- {0x01cb, {1|F|D|IT|SU|I(17), {0x01cc}}},
- {0x01cd, {1|F|D, {0x01ce}}},
- {0x01cf, {1|F|D, {0x01d0}}},
- {0x01d1, {1|F|D, {0x01d2}}},
- {0x01d3, {1|F|D, {0x01d4}}},
- {0x01d5, {1|F|D, {0x01d6}}},
- {0x01d7, {1|F|D, {0x01d8}}},
- {0x01d9, {1|F|D, {0x01da}}},
- {0x01db, {1|F|D, {0x01dc}}},
- {0x01de, {1|F|D, {0x01df}}},
- {0x01e0, {1|F|D, {0x01e1}}},
- {0x01e2, {1|F|D, {0x01e3}}},
- {0x01e4, {1|F|D, {0x01e5}}},
- {0x01e6, {1|F|D, {0x01e7}}},
- {0x01e8, {1|F|D, {0x01e9}}},
- {0x01ea, {1|F|D, {0x01eb}}},
- {0x01ec, {1|F|D, {0x01ed}}},
- {0x01ee, {1|F|D, {0x01ef}}},
- {0x01f0, {2|F|SU|I(20), {0x006a, 0x030c}}},
- {0x01f1, {1|F|D|ST|I(22), {0x01f3}}},
- {0x01f2, {1|F|D|IT|SU|I(23), {0x01f3}}},
- {0x01f4, {1|F|D, {0x01f5}}},
- {0x01f6, {1|F|D, {0x0195}}},
- {0x01f7, {1|F|D, {0x01bf}}},
- {0x01f8, {1|F|D, {0x01f9}}},
- {0x01fa, {1|F|D, {0x01fb}}},
- {0x01fc, {1|F|D, {0x01fd}}},
- {0x01fe, {1|F|D, {0x01ff}}},
- {0x0200, {1|F|D, {0x0201}}},
- {0x0202, {1|F|D, {0x0203}}},
- {0x0204, {1|F|D, {0x0205}}},
- {0x0206, {1|F|D, {0x0207}}},
- {0x0208, {1|F|D, {0x0209}}},
- {0x020a, {1|F|D, {0x020b}}},
- {0x020c, {1|F|D, {0x020d}}},
- {0x020e, {1|F|D, {0x020f}}},
- {0x0210, {1|F|D, {0x0211}}},
- {0x0212, {1|F|D, {0x0213}}},
- {0x0214, {1|F|D, {0x0215}}},
- {0x0216, {1|F|D, {0x0217}}},
- {0x0218, {1|F|D, {0x0219}}},
- {0x021a, {1|F|D, {0x021b}}},
- {0x021c, {1|F|D, {0x021d}}},
- {0x021e, {1|F|D, {0x021f}}},
- {0x0220, {1|F|D, {0x019e}}},
- {0x0222, {1|F|D, {0x0223}}},
- {0x0224, {1|F|D, {0x0225}}},
- {0x0226, {1|F|D, {0x0227}}},
- {0x0228, {1|F|D, {0x0229}}},
- {0x022a, {1|F|D, {0x022b}}},
- {0x022c, {1|F|D, {0x022d}}},
- {0x022e, {1|F|D, {0x022f}}},
- {0x0230, {1|F|D, {0x0231}}},
- {0x0232, {1|F|D, {0x0233}}},
- {0x023a, {1|F|D, {0x2c65}}},
- {0x023b, {1|F|D, {0x023c}}},
- {0x023d, {1|F|D, {0x019a}}},
- {0x023e, {1|F|D, {0x2c66}}},
- {0x0241, {1|F|D, {0x0242}}},
- {0x0243, {1|F|D, {0x0180}}},
- {0x0244, {1|F|D, {0x0289}}},
- {0x0245, {1|F|D, {0x028c}}},
- {0x0246, {1|F|D, {0x0247}}},
- {0x0248, {1|F|D, {0x0249}}},
- {0x024a, {1|F|D, {0x024b}}},
- {0x024c, {1|F|D, {0x024d}}},
- {0x024e, {1|F|D, {0x024f}}},
- {0x0345, {1|F|SU|I(26), {0x03b9}}},
- {0x0370, {1|F|D, {0x0371}}},
- {0x0372, {1|F|D, {0x0373}}},
- {0x0376, {1|F|D, {0x0377}}},
- {0x037f, {1|F|D, {0x03f3}}},
- {0x0386, {1|F|D, {0x03ac}}},
- {0x0388, {1|F|D, {0x03ad}}},
- {0x0389, {1|F|D, {0x03ae}}},
- {0x038a, {1|F|D, {0x03af}}},
- {0x038c, {1|F|D, {0x03cc}}},
- {0x038e, {1|F|D, {0x03cd}}},
- {0x038f, {1|F|D, {0x03ce}}},
- {0x0390, {3|F|SU|I(27), {0x03b9, 0x0308, 0x0301}}},
- {0x0391, {1|F|D, {0x03b1}}},
- {0x0392, {1|F|D, {0x03b2}}},
- {0x0393, {1|F|D, {0x03b3}}},
- {0x0394, {1|F|D, {0x03b4}}},
- {0x0395, {1|F|D, {0x03b5}}},
- {0x0396, {1|F|D, {0x03b6}}},
- {0x0397, {1|F|D, {0x03b7}}},
- {0x0398, {1|F|D, {0x03b8}}},
- {0x0399, {1|F|D, {0x03b9}}},
- {0x039a, {1|F|D, {0x03ba}}},
- {0x039b, {1|F|D, {0x03bb}}},
- {0x039c, {1|F|D, {0x03bc}}},
- {0x039d, {1|F|D, {0x03bd}}},
- {0x039e, {1|F|D, {0x03be}}},
- {0x039f, {1|F|D, {0x03bf}}},
- {0x03a0, {1|F|D, {0x03c0}}},
- {0x03a1, {1|F|D, {0x03c1}}},
- {0x03a3, {1|F|D, {0x03c3}}},
- {0x03a4, {1|F|D, {0x03c4}}},
- {0x03a5, {1|F|D, {0x03c5}}},
- {0x03a6, {1|F|D, {0x03c6}}},
- {0x03a7, {1|F|D, {0x03c7}}},
- {0x03a8, {1|F|D, {0x03c8}}},
- {0x03a9, {1|F|D, {0x03c9}}},
- {0x03aa, {1|F|D, {0x03ca}}},
- {0x03ab, {1|F|D, {0x03cb}}},
- {0x03b0, {3|F|SU|I(30), {0x03c5, 0x0308, 0x0301}}},
- {0x03c2, {1|F|SU|I(33), {0x03c3}}},
- {0x03cf, {1|F|D, {0x03d7}}},
- {0x03d0, {1|F|SU|I(34), {0x03b2}}},
- {0x03d1, {1|F|SU|I(35), {0x03b8}}},
- {0x03d5, {1|F|SU|I(36), {0x03c6}}},
- {0x03d6, {1|F|SU|I(37), {0x03c0}}},
- {0x03d8, {1|F|D, {0x03d9}}},
- {0x03da, {1|F|D, {0x03db}}},
- {0x03dc, {1|F|D, {0x03dd}}},
- {0x03de, {1|F|D, {0x03df}}},
- {0x03e0, {1|F|D, {0x03e1}}},
- {0x03e2, {1|F|D, {0x03e3}}},
- {0x03e4, {1|F|D, {0x03e5}}},
- {0x03e6, {1|F|D, {0x03e7}}},
- {0x03e8, {1|F|D, {0x03e9}}},
- {0x03ea, {1|F|D, {0x03eb}}},
- {0x03ec, {1|F|D, {0x03ed}}},
- {0x03ee, {1|F|D, {0x03ef}}},
- {0x03f0, {1|F|SU|I(38), {0x03ba}}},
- {0x03f1, {1|F|SU|I(39), {0x03c1}}},
- {0x03f4, {1|F|D, {0x03b8}}},
- {0x03f5, {1|F|SU|I(40), {0x03b5}}},
- {0x03f7, {1|F|D, {0x03f8}}},
- {0x03f9, {1|F|D, {0x03f2}}},
- {0x03fa, {1|F|D, {0x03fb}}},
- {0x03fd, {1|F|D, {0x037b}}},
- {0x03fe, {1|F|D, {0x037c}}},
- {0x03ff, {1|F|D, {0x037d}}},
- {0x0400, {1|F|D, {0x0450}}},
- {0x0401, {1|F|D, {0x0451}}},
- {0x0402, {1|F|D, {0x0452}}},
- {0x0403, {1|F|D, {0x0453}}},
- {0x0404, {1|F|D, {0x0454}}},
- {0x0405, {1|F|D, {0x0455}}},
- {0x0406, {1|F|D, {0x0456}}},
- {0x0407, {1|F|D, {0x0457}}},
- {0x0408, {1|F|D, {0x0458}}},
- {0x0409, {1|F|D, {0x0459}}},
- {0x040a, {1|F|D, {0x045a}}},
- {0x040b, {1|F|D, {0x045b}}},
- {0x040c, {1|F|D, {0x045c}}},
- {0x040d, {1|F|D, {0x045d}}},
- {0x040e, {1|F|D, {0x045e}}},
- {0x040f, {1|F|D, {0x045f}}},
- {0x0410, {1|F|D, {0x0430}}},
- {0x0411, {1|F|D, {0x0431}}},
- {0x0412, {1|F|D, {0x0432}}},
- {0x0413, {1|F|D, {0x0433}}},
- {0x0414, {1|F|D, {0x0434}}},
- {0x0415, {1|F|D, {0x0435}}},
- {0x0416, {1|F|D, {0x0436}}},
- {0x0417, {1|F|D, {0x0437}}},
- {0x0418, {1|F|D, {0x0438}}},
- {0x0419, {1|F|D, {0x0439}}},
- {0x041a, {1|F|D, {0x043a}}},
- {0x041b, {1|F|D, {0x043b}}},
- {0x041c, {1|F|D, {0x043c}}},
- {0x041d, {1|F|D, {0x043d}}},
- {0x041e, {1|F|D, {0x043e}}},
- {0x041f, {1|F|D, {0x043f}}},
- {0x0420, {1|F|D, {0x0440}}},
- {0x0421, {1|F|D, {0x0441}}},
- {0x0422, {1|F|D, {0x0442}}},
- {0x0423, {1|F|D, {0x0443}}},
- {0x0424, {1|F|D, {0x0444}}},
- {0x0425, {1|F|D, {0x0445}}},
- {0x0426, {1|F|D, {0x0446}}},
- {0x0427, {1|F|D, {0x0447}}},
- {0x0428, {1|F|D, {0x0448}}},
- {0x0429, {1|F|D, {0x0449}}},
- {0x042a, {1|F|D, {0x044a}}},
- {0x042b, {1|F|D, {0x044b}}},
- {0x042c, {1|F|D, {0x044c}}},
- {0x042d, {1|F|D, {0x044d}}},
- {0x042e, {1|F|D, {0x044e}}},
- {0x042f, {1|F|D, {0x044f}}},
- {0x0460, {1|F|D, {0x0461}}},
- {0x0462, {1|F|D, {0x0463}}},
- {0x0464, {1|F|D, {0x0465}}},
- {0x0466, {1|F|D, {0x0467}}},
- {0x0468, {1|F|D, {0x0469}}},
- {0x046a, {1|F|D, {0x046b}}},
- {0x046c, {1|F|D, {0x046d}}},
- {0x046e, {1|F|D, {0x046f}}},
- {0x0470, {1|F|D, {0x0471}}},
- {0x0472, {1|F|D, {0x0473}}},
- {0x0474, {1|F|D, {0x0475}}},
- {0x0476, {1|F|D, {0x0477}}},
- {0x0478, {1|F|D, {0x0479}}},
- {0x047a, {1|F|D, {0x047b}}},
- {0x047c, {1|F|D, {0x047d}}},
- {0x047e, {1|F|D, {0x047f}}},
- {0x0480, {1|F|D, {0x0481}}},
- {0x048a, {1|F|D, {0x048b}}},
- {0x048c, {1|F|D, {0x048d}}},
- {0x048e, {1|F|D, {0x048f}}},
- {0x0490, {1|F|D, {0x0491}}},
- {0x0492, {1|F|D, {0x0493}}},
- {0x0494, {1|F|D, {0x0495}}},
- {0x0496, {1|F|D, {0x0497}}},
- {0x0498, {1|F|D, {0x0499}}},
- {0x049a, {1|F|D, {0x049b}}},
- {0x049c, {1|F|D, {0x049d}}},
- {0x049e, {1|F|D, {0x049f}}},
- {0x04a0, {1|F|D, {0x04a1}}},
- {0x04a2, {1|F|D, {0x04a3}}},
- {0x04a4, {1|F|D, {0x04a5}}},
- {0x04a6, {1|F|D, {0x04a7}}},
- {0x04a8, {1|F|D, {0x04a9}}},
- {0x04aa, {1|F|D, {0x04ab}}},
- {0x04ac, {1|F|D, {0x04ad}}},
- {0x04ae, {1|F|D, {0x04af}}},
- {0x04b0, {1|F|D, {0x04b1}}},
- {0x04b2, {1|F|D, {0x04b3}}},
- {0x04b4, {1|F|D, {0x04b5}}},
- {0x04b6, {1|F|D, {0x04b7}}},
- {0x04b8, {1|F|D, {0x04b9}}},
- {0x04ba, {1|F|D, {0x04bb}}},
- {0x04bc, {1|F|D, {0x04bd}}},
- {0x04be, {1|F|D, {0x04bf}}},
- {0x04c0, {1|F|D, {0x04cf}}},
- {0x04c1, {1|F|D, {0x04c2}}},
- {0x04c3, {1|F|D, {0x04c4}}},
- {0x04c5, {1|F|D, {0x04c6}}},
- {0x04c7, {1|F|D, {0x04c8}}},
- {0x04c9, {1|F|D, {0x04ca}}},
- {0x04cb, {1|F|D, {0x04cc}}},
- {0x04cd, {1|F|D, {0x04ce}}},
- {0x04d0, {1|F|D, {0x04d1}}},
- {0x04d2, {1|F|D, {0x04d3}}},
- {0x04d4, {1|F|D, {0x04d5}}},
- {0x04d6, {1|F|D, {0x04d7}}},
- {0x04d8, {1|F|D, {0x04d9}}},
- {0x04da, {1|F|D, {0x04db}}},
- {0x04dc, {1|F|D, {0x04dd}}},
- {0x04de, {1|F|D, {0x04df}}},
- {0x04e0, {1|F|D, {0x04e1}}},
- {0x04e2, {1|F|D, {0x04e3}}},
- {0x04e4, {1|F|D, {0x04e5}}},
- {0x04e6, {1|F|D, {0x04e7}}},
- {0x04e8, {1|F|D, {0x04e9}}},
- {0x04ea, {1|F|D, {0x04eb}}},
- {0x04ec, {1|F|D, {0x04ed}}},
- {0x04ee, {1|F|D, {0x04ef}}},
- {0x04f0, {1|F|D, {0x04f1}}},
- {0x04f2, {1|F|D, {0x04f3}}},
- {0x04f4, {1|F|D, {0x04f5}}},
- {0x04f6, {1|F|D, {0x04f7}}},
- {0x04f8, {1|F|D, {0x04f9}}},
- {0x04fa, {1|F|D, {0x04fb}}},
- {0x04fc, {1|F|D, {0x04fd}}},
- {0x04fe, {1|F|D, {0x04ff}}},
- {0x0500, {1|F|D, {0x0501}}},
- {0x0502, {1|F|D, {0x0503}}},
- {0x0504, {1|F|D, {0x0505}}},
- {0x0506, {1|F|D, {0x0507}}},
- {0x0508, {1|F|D, {0x0509}}},
- {0x050a, {1|F|D, {0x050b}}},
- {0x050c, {1|F|D, {0x050d}}},
- {0x050e, {1|F|D, {0x050f}}},
- {0x0510, {1|F|D, {0x0511}}},
- {0x0512, {1|F|D, {0x0513}}},
- {0x0514, {1|F|D, {0x0515}}},
- {0x0516, {1|F|D, {0x0517}}},
- {0x0518, {1|F|D, {0x0519}}},
- {0x051a, {1|F|D, {0x051b}}},
- {0x051c, {1|F|D, {0x051d}}},
- {0x051e, {1|F|D, {0x051f}}},
- {0x0520, {1|F|D, {0x0521}}},
- {0x0522, {1|F|D, {0x0523}}},
- {0x0524, {1|F|D, {0x0525}}},
- {0x0526, {1|F|D, {0x0527}}},
- {0x0528, {1|F|D, {0x0529}}},
- {0x052a, {1|F|D, {0x052b}}},
- {0x052c, {1|F|D, {0x052d}}},
- {0x052e, {1|F|D, {0x052f}}},
- {0x0531, {1|F|D, {0x0561}}},
- {0x0532, {1|F|D, {0x0562}}},
- {0x0533, {1|F|D, {0x0563}}},
- {0x0534, {1|F|D, {0x0564}}},
- {0x0535, {1|F|D, {0x0565}}},
- {0x0536, {1|F|D, {0x0566}}},
- {0x0537, {1|F|D, {0x0567}}},
- {0x0538, {1|F|D, {0x0568}}},
- {0x0539, {1|F|D, {0x0569}}},
- {0x053a, {1|F|D, {0x056a}}},
- {0x053b, {1|F|D, {0x056b}}},
- {0x053c, {1|F|D, {0x056c}}},
- {0x053d, {1|F|D, {0x056d}}},
- {0x053e, {1|F|D, {0x056e}}},
- {0x053f, {1|F|D, {0x056f}}},
- {0x0540, {1|F|D, {0x0570}}},
- {0x0541, {1|F|D, {0x0571}}},
- {0x0542, {1|F|D, {0x0572}}},
- {0x0543, {1|F|D, {0x0573}}},
- {0x0544, {1|F|D, {0x0574}}},
- {0x0545, {1|F|D, {0x0575}}},
- {0x0546, {1|F|D, {0x0576}}},
- {0x0547, {1|F|D, {0x0577}}},
- {0x0548, {1|F|D, {0x0578}}},
- {0x0549, {1|F|D, {0x0579}}},
- {0x054a, {1|F|D, {0x057a}}},
- {0x054b, {1|F|D, {0x057b}}},
- {0x054c, {1|F|D, {0x057c}}},
- {0x054d, {1|F|D, {0x057d}}},
- {0x054e, {1|F|D, {0x057e}}},
- {0x054f, {1|F|D, {0x057f}}},
- {0x0550, {1|F|D, {0x0580}}},
- {0x0551, {1|F|D, {0x0581}}},
- {0x0552, {1|F|D, {0x0582}}},
- {0x0553, {1|F|D, {0x0583}}},
- {0x0554, {1|F|D, {0x0584}}},
- {0x0555, {1|F|D, {0x0585}}},
- {0x0556, {1|F|D, {0x0586}}},
- {0x0587, {2|F|ST|SU|I(41), {0x0565, 0x0582}}},
- {0x10a0, {1|F|D, {0x2d00}}},
- {0x10a1, {1|F|D, {0x2d01}}},
- {0x10a2, {1|F|D, {0x2d02}}},
- {0x10a3, {1|F|D, {0x2d03}}},
- {0x10a4, {1|F|D, {0x2d04}}},
- {0x10a5, {1|F|D, {0x2d05}}},
- {0x10a6, {1|F|D, {0x2d06}}},
- {0x10a7, {1|F|D, {0x2d07}}},
- {0x10a8, {1|F|D, {0x2d08}}},
- {0x10a9, {1|F|D, {0x2d09}}},
- {0x10aa, {1|F|D, {0x2d0a}}},
- {0x10ab, {1|F|D, {0x2d0b}}},
- {0x10ac, {1|F|D, {0x2d0c}}},
- {0x10ad, {1|F|D, {0x2d0d}}},
- {0x10ae, {1|F|D, {0x2d0e}}},
- {0x10af, {1|F|D, {0x2d0f}}},
- {0x10b0, {1|F|D, {0x2d10}}},
- {0x10b1, {1|F|D, {0x2d11}}},
- {0x10b2, {1|F|D, {0x2d12}}},
- {0x10b3, {1|F|D, {0x2d13}}},
- {0x10b4, {1|F|D, {0x2d14}}},
- {0x10b5, {1|F|D, {0x2d15}}},
- {0x10b6, {1|F|D, {0x2d16}}},
- {0x10b7, {1|F|D, {0x2d17}}},
- {0x10b8, {1|F|D, {0x2d18}}},
- {0x10b9, {1|F|D, {0x2d19}}},
- {0x10ba, {1|F|D, {0x2d1a}}},
- {0x10bb, {1|F|D, {0x2d1b}}},
- {0x10bc, {1|F|D, {0x2d1c}}},
- {0x10bd, {1|F|D, {0x2d1d}}},
- {0x10be, {1|F|D, {0x2d1e}}},
- {0x10bf, {1|F|D, {0x2d1f}}},
- {0x10c0, {1|F|D, {0x2d20}}},
- {0x10c1, {1|F|D, {0x2d21}}},
- {0x10c2, {1|F|D, {0x2d22}}},
- {0x10c3, {1|F|D, {0x2d23}}},
- {0x10c4, {1|F|D, {0x2d24}}},
- {0x10c5, {1|F|D, {0x2d25}}},
- {0x10c7, {1|F|D, {0x2d27}}},
- {0x10cd, {1|F|D, {0x2d2d}}},
- {0x13f8, {1|F|U, {0x13f0}}},
- {0x13f9, {1|F|U, {0x13f1}}},
- {0x13fa, {1|F|U, {0x13f2}}},
- {0x13fb, {1|F|U, {0x13f3}}},
- {0x13fc, {1|F|U, {0x13f4}}},
- {0x13fd, {1|F|U, {0x13f5}}},
- {0x1c80, {1|F|SU|I(45), {0x0432}}},
- {0x1c81, {1|F|SU|I(46), {0x0434}}},
- {0x1c82, {1|F|SU|I(47), {0x043e}}},
- {0x1c83, {1|F|SU|I(48), {0x0441}}},
- {0x1c84, {1|F|SU|I(49), {0x0442}}},
- {0x1c85, {1|F|SU|I(50), {0x0442}}},
- {0x1c86, {1|F|SU|I(51), {0x044a}}},
- {0x1c87, {1|F|SU|I(52), {0x0463}}},
- {0x1c88, {1|F|SU|I(53), {0xa64b}}},
- {0x1c90, {1|F|D, {0x10d0}}},
- {0x1c91, {1|F|D, {0x10d1}}},
- {0x1c92, {1|F|D, {0x10d2}}},
- {0x1c93, {1|F|D, {0x10d3}}},
- {0x1c94, {1|F|D, {0x10d4}}},
- {0x1c95, {1|F|D, {0x10d5}}},
- {0x1c96, {1|F|D, {0x10d6}}},
- {0x1c97, {1|F|D, {0x10d7}}},
- {0x1c98, {1|F|D, {0x10d8}}},
- {0x1c99, {1|F|D, {0x10d9}}},
- {0x1c9a, {1|F|D, {0x10da}}},
- {0x1c9b, {1|F|D, {0x10db}}},
- {0x1c9c, {1|F|D, {0x10dc}}},
- {0x1c9d, {1|F|D, {0x10dd}}},
- {0x1c9e, {1|F|D, {0x10de}}},
- {0x1c9f, {1|F|D, {0x10df}}},
- {0x1ca0, {1|F|D, {0x10e0}}},
- {0x1ca1, {1|F|D, {0x10e1}}},
- {0x1ca2, {1|F|D, {0x10e2}}},
- {0x1ca3, {1|F|D, {0x10e3}}},
- {0x1ca4, {1|F|D, {0x10e4}}},
- {0x1ca5, {1|F|D, {0x10e5}}},
- {0x1ca6, {1|F|D, {0x10e6}}},
- {0x1ca7, {1|F|D, {0x10e7}}},
- {0x1ca8, {1|F|D, {0x10e8}}},
- {0x1ca9, {1|F|D, {0x10e9}}},
- {0x1caa, {1|F|D, {0x10ea}}},
- {0x1cab, {1|F|D, {0x10eb}}},
- {0x1cac, {1|F|D, {0x10ec}}},
- {0x1cad, {1|F|D, {0x10ed}}},
- {0x1cae, {1|F|D, {0x10ee}}},
- {0x1caf, {1|F|D, {0x10ef}}},
- {0x1cb0, {1|F|D, {0x10f0}}},
- {0x1cb1, {1|F|D, {0x10f1}}},
- {0x1cb2, {1|F|D, {0x10f2}}},
- {0x1cb3, {1|F|D, {0x10f3}}},
- {0x1cb4, {1|F|D, {0x10f4}}},
- {0x1cb5, {1|F|D, {0x10f5}}},
- {0x1cb6, {1|F|D, {0x10f6}}},
- {0x1cb7, {1|F|D, {0x10f7}}},
- {0x1cb8, {1|F|D, {0x10f8}}},
- {0x1cb9, {1|F|D, {0x10f9}}},
- {0x1cba, {1|F|D, {0x10fa}}},
- {0x1cbd, {1|F|D, {0x10fd}}},
- {0x1cbe, {1|F|D, {0x10fe}}},
- {0x1cbf, {1|F|D, {0x10ff}}},
- {0x1e00, {1|F|D, {0x1e01}}},
- {0x1e02, {1|F|D, {0x1e03}}},
- {0x1e04, {1|F|D, {0x1e05}}},
- {0x1e06, {1|F|D, {0x1e07}}},
- {0x1e08, {1|F|D, {0x1e09}}},
- {0x1e0a, {1|F|D, {0x1e0b}}},
- {0x1e0c, {1|F|D, {0x1e0d}}},
- {0x1e0e, {1|F|D, {0x1e0f}}},
- {0x1e10, {1|F|D, {0x1e11}}},
- {0x1e12, {1|F|D, {0x1e13}}},
- {0x1e14, {1|F|D, {0x1e15}}},
- {0x1e16, {1|F|D, {0x1e17}}},
- {0x1e18, {1|F|D, {0x1e19}}},
- {0x1e1a, {1|F|D, {0x1e1b}}},
- {0x1e1c, {1|F|D, {0x1e1d}}},
- {0x1e1e, {1|F|D, {0x1e1f}}},
- {0x1e20, {1|F|D, {0x1e21}}},
- {0x1e22, {1|F|D, {0x1e23}}},
- {0x1e24, {1|F|D, {0x1e25}}},
- {0x1e26, {1|F|D, {0x1e27}}},
- {0x1e28, {1|F|D, {0x1e29}}},
- {0x1e2a, {1|F|D, {0x1e2b}}},
- {0x1e2c, {1|F|D, {0x1e2d}}},
- {0x1e2e, {1|F|D, {0x1e2f}}},
- {0x1e30, {1|F|D, {0x1e31}}},
- {0x1e32, {1|F|D, {0x1e33}}},
- {0x1e34, {1|F|D, {0x1e35}}},
- {0x1e36, {1|F|D, {0x1e37}}},
- {0x1e38, {1|F|D, {0x1e39}}},
- {0x1e3a, {1|F|D, {0x1e3b}}},
- {0x1e3c, {1|F|D, {0x1e3d}}},
- {0x1e3e, {1|F|D, {0x1e3f}}},
- {0x1e40, {1|F|D, {0x1e41}}},
- {0x1e42, {1|F|D, {0x1e43}}},
- {0x1e44, {1|F|D, {0x1e45}}},
- {0x1e46, {1|F|D, {0x1e47}}},
- {0x1e48, {1|F|D, {0x1e49}}},
- {0x1e4a, {1|F|D, {0x1e4b}}},
- {0x1e4c, {1|F|D, {0x1e4d}}},
- {0x1e4e, {1|F|D, {0x1e4f}}},
- {0x1e50, {1|F|D, {0x1e51}}},
- {0x1e52, {1|F|D, {0x1e53}}},
- {0x1e54, {1|F|D, {0x1e55}}},
- {0x1e56, {1|F|D, {0x1e57}}},
- {0x1e58, {1|F|D, {0x1e59}}},
- {0x1e5a, {1|F|D, {0x1e5b}}},
- {0x1e5c, {1|F|D, {0x1e5d}}},
- {0x1e5e, {1|F|D, {0x1e5f}}},
- {0x1e60, {1|F|D, {0x1e61}}},
- {0x1e62, {1|F|D, {0x1e63}}},
- {0x1e64, {1|F|D, {0x1e65}}},
- {0x1e66, {1|F|D, {0x1e67}}},
- {0x1e68, {1|F|D, {0x1e69}}},
- {0x1e6a, {1|F|D, {0x1e6b}}},
- {0x1e6c, {1|F|D, {0x1e6d}}},
- {0x1e6e, {1|F|D, {0x1e6f}}},
- {0x1e70, {1|F|D, {0x1e71}}},
- {0x1e72, {1|F|D, {0x1e73}}},
- {0x1e74, {1|F|D, {0x1e75}}},
- {0x1e76, {1|F|D, {0x1e77}}},
- {0x1e78, {1|F|D, {0x1e79}}},
- {0x1e7a, {1|F|D, {0x1e7b}}},
- {0x1e7c, {1|F|D, {0x1e7d}}},
- {0x1e7e, {1|F|D, {0x1e7f}}},
- {0x1e80, {1|F|D, {0x1e81}}},
- {0x1e82, {1|F|D, {0x1e83}}},
- {0x1e84, {1|F|D, {0x1e85}}},
- {0x1e86, {1|F|D, {0x1e87}}},
- {0x1e88, {1|F|D, {0x1e89}}},
- {0x1e8a, {1|F|D, {0x1e8b}}},
- {0x1e8c, {1|F|D, {0x1e8d}}},
- {0x1e8e, {1|F|D, {0x1e8f}}},
- {0x1e90, {1|F|D, {0x1e91}}},
- {0x1e92, {1|F|D, {0x1e93}}},
- {0x1e94, {1|F|D, {0x1e95}}},
- {0x1e96, {2|F|SU|I(54), {0x0068, 0x0331}}},
- {0x1e97, {2|F|SU|I(56), {0x0074, 0x0308}}},
- {0x1e98, {2|F|SU|I(58), {0x0077, 0x030a}}},
- {0x1e99, {2|F|SU|I(60), {0x0079, 0x030a}}},
- {0x1e9a, {2|F|SU|I(62), {0x0061, 0x02be}}},
- {0x1e9b, {1|F|SU|I(64), {0x1e61}}},
- {0x1e9e, {2|F|SL|I(65), {0x0073, 0x0073}}},
- {0x1ea0, {1|F|D, {0x1ea1}}},
- {0x1ea2, {1|F|D, {0x1ea3}}},
- {0x1ea4, {1|F|D, {0x1ea5}}},
- {0x1ea6, {1|F|D, {0x1ea7}}},
- {0x1ea8, {1|F|D, {0x1ea9}}},
- {0x1eaa, {1|F|D, {0x1eab}}},
- {0x1eac, {1|F|D, {0x1ead}}},
- {0x1eae, {1|F|D, {0x1eaf}}},
- {0x1eb0, {1|F|D, {0x1eb1}}},
- {0x1eb2, {1|F|D, {0x1eb3}}},
- {0x1eb4, {1|F|D, {0x1eb5}}},
- {0x1eb6, {1|F|D, {0x1eb7}}},
- {0x1eb8, {1|F|D, {0x1eb9}}},
- {0x1eba, {1|F|D, {0x1ebb}}},
- {0x1ebc, {1|F|D, {0x1ebd}}},
- {0x1ebe, {1|F|D, {0x1ebf}}},
- {0x1ec0, {1|F|D, {0x1ec1}}},
- {0x1ec2, {1|F|D, {0x1ec3}}},
- {0x1ec4, {1|F|D, {0x1ec5}}},
- {0x1ec6, {1|F|D, {0x1ec7}}},
- {0x1ec8, {1|F|D, {0x1ec9}}},
- {0x1eca, {1|F|D, {0x1ecb}}},
- {0x1ecc, {1|F|D, {0x1ecd}}},
- {0x1ece, {1|F|D, {0x1ecf}}},
- {0x1ed0, {1|F|D, {0x1ed1}}},
- {0x1ed2, {1|F|D, {0x1ed3}}},
- {0x1ed4, {1|F|D, {0x1ed5}}},
- {0x1ed6, {1|F|D, {0x1ed7}}},
- {0x1ed8, {1|F|D, {0x1ed9}}},
- {0x1eda, {1|F|D, {0x1edb}}},
- {0x1edc, {1|F|D, {0x1edd}}},
- {0x1ede, {1|F|D, {0x1edf}}},
- {0x1ee0, {1|F|D, {0x1ee1}}},
- {0x1ee2, {1|F|D, {0x1ee3}}},
- {0x1ee4, {1|F|D, {0x1ee5}}},
- {0x1ee6, {1|F|D, {0x1ee7}}},
- {0x1ee8, {1|F|D, {0x1ee9}}},
- {0x1eea, {1|F|D, {0x1eeb}}},
- {0x1eec, {1|F|D, {0x1eed}}},
- {0x1eee, {1|F|D, {0x1eef}}},
- {0x1ef0, {1|F|D, {0x1ef1}}},
- {0x1ef2, {1|F|D, {0x1ef3}}},
- {0x1ef4, {1|F|D, {0x1ef5}}},
- {0x1ef6, {1|F|D, {0x1ef7}}},
- {0x1ef8, {1|F|D, {0x1ef9}}},
- {0x1efa, {1|F|D, {0x1efb}}},
- {0x1efc, {1|F|D, {0x1efd}}},
- {0x1efe, {1|F|D, {0x1eff}}},
- {0x1f08, {1|F|D, {0x1f00}}},
- {0x1f09, {1|F|D, {0x1f01}}},
- {0x1f0a, {1|F|D, {0x1f02}}},
- {0x1f0b, {1|F|D, {0x1f03}}},
- {0x1f0c, {1|F|D, {0x1f04}}},
- {0x1f0d, {1|F|D, {0x1f05}}},
- {0x1f0e, {1|F|D, {0x1f06}}},
- {0x1f0f, {1|F|D, {0x1f07}}},
- {0x1f18, {1|F|D, {0x1f10}}},
- {0x1f19, {1|F|D, {0x1f11}}},
- {0x1f1a, {1|F|D, {0x1f12}}},
- {0x1f1b, {1|F|D, {0x1f13}}},
- {0x1f1c, {1|F|D, {0x1f14}}},
- {0x1f1d, {1|F|D, {0x1f15}}},
- {0x1f28, {1|F|D, {0x1f20}}},
- {0x1f29, {1|F|D, {0x1f21}}},
- {0x1f2a, {1|F|D, {0x1f22}}},
- {0x1f2b, {1|F|D, {0x1f23}}},
- {0x1f2c, {1|F|D, {0x1f24}}},
- {0x1f2d, {1|F|D, {0x1f25}}},
- {0x1f2e, {1|F|D, {0x1f26}}},
- {0x1f2f, {1|F|D, {0x1f27}}},
- {0x1f38, {1|F|D, {0x1f30}}},
- {0x1f39, {1|F|D, {0x1f31}}},
- {0x1f3a, {1|F|D, {0x1f32}}},
- {0x1f3b, {1|F|D, {0x1f33}}},
- {0x1f3c, {1|F|D, {0x1f34}}},
- {0x1f3d, {1|F|D, {0x1f35}}},
- {0x1f3e, {1|F|D, {0x1f36}}},
- {0x1f3f, {1|F|D, {0x1f37}}},
- {0x1f48, {1|F|D, {0x1f40}}},
- {0x1f49, {1|F|D, {0x1f41}}},
- {0x1f4a, {1|F|D, {0x1f42}}},
- {0x1f4b, {1|F|D, {0x1f43}}},
- {0x1f4c, {1|F|D, {0x1f44}}},
- {0x1f4d, {1|F|D, {0x1f45}}},
- {0x1f50, {2|F|SU|I(66), {0x03c5, 0x0313}}},
- {0x1f52, {3|F|SU|I(68), {0x03c5, 0x0313, 0x0300}}},
- {0x1f54, {3|F|SU|I(71), {0x03c5, 0x0313, 0x0301}}},
- {0x1f56, {3|F|SU|I(74), {0x03c5, 0x0313, 0x0342}}},
- {0x1f59, {1|F|D, {0x1f51}}},
- {0x1f5b, {1|F|D, {0x1f53}}},
- {0x1f5d, {1|F|D, {0x1f55}}},
- {0x1f5f, {1|F|D, {0x1f57}}},
- {0x1f68, {1|F|D, {0x1f60}}},
- {0x1f69, {1|F|D, {0x1f61}}},
- {0x1f6a, {1|F|D, {0x1f62}}},
- {0x1f6b, {1|F|D, {0x1f63}}},
- {0x1f6c, {1|F|D, {0x1f64}}},
- {0x1f6d, {1|F|D, {0x1f65}}},
- {0x1f6e, {1|F|D, {0x1f66}}},
- {0x1f6f, {1|F|D, {0x1f67}}},
- {0x1f80, {2|F|ST|SU|I(77), {0x1f00, 0x03b9}}},
- {0x1f81, {2|F|ST|SU|I(80), {0x1f01, 0x03b9}}},
- {0x1f82, {2|F|ST|SU|I(83), {0x1f02, 0x03b9}}},
- {0x1f83, {2|F|ST|SU|I(86), {0x1f03, 0x03b9}}},
- {0x1f84, {2|F|ST|SU|I(89), {0x1f04, 0x03b9}}},
- {0x1f85, {2|F|ST|SU|I(92), {0x1f05, 0x03b9}}},
- {0x1f86, {2|F|ST|SU|I(95), {0x1f06, 0x03b9}}},
- {0x1f87, {2|F|ST|SU|I(98), {0x1f07, 0x03b9}}},
- {0x1f88, {2|F|IT|SL|SU|I(101), {0x1f00, 0x03b9}}},
- {0x1f89, {2|F|IT|SL|SU|I(106), {0x1f01, 0x03b9}}},
- {0x1f8a, {2|F|IT|SL|SU|I(111), {0x1f02, 0x03b9}}},
- {0x1f8b, {2|F|IT|SL|SU|I(116), {0x1f03, 0x03b9}}},
- {0x1f8c, {2|F|IT|SL|SU|I(121), {0x1f04, 0x03b9}}},
- {0x1f8d, {2|F|IT|SL|SU|I(126), {0x1f05, 0x03b9}}},
- {0x1f8e, {2|F|IT|SL|SU|I(131), {0x1f06, 0x03b9}}},
- {0x1f8f, {2|F|IT|SL|SU|I(136), {0x1f07, 0x03b9}}},
- {0x1f90, {2|F|ST|SU|I(141), {0x1f20, 0x03b9}}},
- {0x1f91, {2|F|ST|SU|I(144), {0x1f21, 0x03b9}}},
- {0x1f92, {2|F|ST|SU|I(147), {0x1f22, 0x03b9}}},
- {0x1f93, {2|F|ST|SU|I(150), {0x1f23, 0x03b9}}},
- {0x1f94, {2|F|ST|SU|I(153), {0x1f24, 0x03b9}}},
- {0x1f95, {2|F|ST|SU|I(156), {0x1f25, 0x03b9}}},
- {0x1f96, {2|F|ST|SU|I(159), {0x1f26, 0x03b9}}},
- {0x1f97, {2|F|ST|SU|I(162), {0x1f27, 0x03b9}}},
- {0x1f98, {2|F|IT|SL|SU|I(165), {0x1f20, 0x03b9}}},
- {0x1f99, {2|F|IT|SL|SU|I(170), {0x1f21, 0x03b9}}},
- {0x1f9a, {2|F|IT|SL|SU|I(175), {0x1f22, 0x03b9}}},
- {0x1f9b, {2|F|IT|SL|SU|I(180), {0x1f23, 0x03b9}}},
- {0x1f9c, {2|F|IT|SL|SU|I(185), {0x1f24, 0x03b9}}},
- {0x1f9d, {2|F|IT|SL|SU|I(190), {0x1f25, 0x03b9}}},
- {0x1f9e, {2|F|IT|SL|SU|I(195), {0x1f26, 0x03b9}}},
- {0x1f9f, {2|F|IT|SL|SU|I(200), {0x1f27, 0x03b9}}},
- {0x1fa0, {2|F|ST|SU|I(205), {0x1f60, 0x03b9}}},
- {0x1fa1, {2|F|ST|SU|I(208), {0x1f61, 0x03b9}}},
- {0x1fa2, {2|F|ST|SU|I(211), {0x1f62, 0x03b9}}},
- {0x1fa3, {2|F|ST|SU|I(214), {0x1f63, 0x03b9}}},
- {0x1fa4, {2|F|ST|SU|I(217), {0x1f64, 0x03b9}}},
- {0x1fa5, {2|F|ST|SU|I(220), {0x1f65, 0x03b9}}},
- {0x1fa6, {2|F|ST|SU|I(223), {0x1f66, 0x03b9}}},
- {0x1fa7, {2|F|ST|SU|I(226), {0x1f67, 0x03b9}}},
- {0x1fa8, {2|F|IT|SL|SU|I(229), {0x1f60, 0x03b9}}},
- {0x1fa9, {2|F|IT|SL|SU|I(234), {0x1f61, 0x03b9}}},
- {0x1faa, {2|F|IT|SL|SU|I(239), {0x1f62, 0x03b9}}},
- {0x1fab, {2|F|IT|SL|SU|I(244), {0x1f63, 0x03b9}}},
- {0x1fac, {2|F|IT|SL|SU|I(249), {0x1f64, 0x03b9}}},
- {0x1fad, {2|F|IT|SL|SU|I(254), {0x1f65, 0x03b9}}},
- {0x1fae, {2|F|IT|SL|SU|I(259), {0x1f66, 0x03b9}}},
- {0x1faf, {2|F|IT|SL|SU|I(264), {0x1f67, 0x03b9}}},
- {0x1fb2, {2|F|ST|SU|I(269), {0x1f70, 0x03b9}}},
- {0x1fb3, {2|F|ST|SU|I(273), {0x03b1, 0x03b9}}},
- {0x1fb4, {2|F|ST|SU|I(276), {0x03ac, 0x03b9}}},
- {0x1fb6, {2|F|SU|I(280), {0x03b1, 0x0342}}},
- {0x1fb7, {3|F|ST|SU|I(282), {0x03b1, 0x0342, 0x03b9}}},
- {0x1fb8, {1|F|D, {0x1fb0}}},
- {0x1fb9, {1|F|D, {0x1fb1}}},
- {0x1fba, {1|F|D, {0x1f70}}},
- {0x1fbb, {1|F|D, {0x1f71}}},
- {0x1fbc, {2|F|IT|SL|SU|I(288), {0x03b1, 0x03b9}}},
- {0x1fbe, {1|F|SU|I(293), {0x03b9}}},
- {0x1fc2, {2|F|ST|SU|I(294), {0x1f74, 0x03b9}}},
- {0x1fc3, {2|F|ST|SU|I(298), {0x03b7, 0x03b9}}},
- {0x1fc4, {2|F|ST|SU|I(301), {0x03ae, 0x03b9}}},
- {0x1fc6, {2|F|SU|I(305), {0x03b7, 0x0342}}},
- {0x1fc7, {3|F|ST|SU|I(307), {0x03b7, 0x0342, 0x03b9}}},
- {0x1fc8, {1|F|D, {0x1f72}}},
- {0x1fc9, {1|F|D, {0x1f73}}},
- {0x1fca, {1|F|D, {0x1f74}}},
- {0x1fcb, {1|F|D, {0x1f75}}},
- {0x1fcc, {2|F|IT|SL|SU|I(313), {0x03b7, 0x03b9}}},
- {0x1fd2, {3|F|SU|I(318), {0x03b9, 0x0308, 0x0300}}},
- {0x1fd3, {3|F|SU|I(321), {0x03b9, 0x0308, 0x0301}}},
- {0x1fd6, {2|F|SU|I(324), {0x03b9, 0x0342}}},
- {0x1fd7, {3|F|SU|I(326), {0x03b9, 0x0308, 0x0342}}},
- {0x1fd8, {1|F|D, {0x1fd0}}},
- {0x1fd9, {1|F|D, {0x1fd1}}},
- {0x1fda, {1|F|D, {0x1f76}}},
- {0x1fdb, {1|F|D, {0x1f77}}},
- {0x1fe2, {3|F|SU|I(329), {0x03c5, 0x0308, 0x0300}}},
- {0x1fe3, {3|F|SU|I(332), {0x03c5, 0x0308, 0x0301}}},
- {0x1fe4, {2|F|SU|I(335), {0x03c1, 0x0313}}},
- {0x1fe6, {2|F|SU|I(337), {0x03c5, 0x0342}}},
- {0x1fe7, {3|F|SU|I(339), {0x03c5, 0x0308, 0x0342}}},
- {0x1fe8, {1|F|D, {0x1fe0}}},
- {0x1fe9, {1|F|D, {0x1fe1}}},
- {0x1fea, {1|F|D, {0x1f7a}}},
- {0x1feb, {1|F|D, {0x1f7b}}},
- {0x1fec, {1|F|D, {0x1fe5}}},
- {0x1ff2, {2|F|ST|SU|I(342), {0x1f7c, 0x03b9}}},
- {0x1ff3, {2|F|ST|SU|I(346), {0x03c9, 0x03b9}}},
- {0x1ff4, {2|F|ST|SU|I(349), {0x03ce, 0x03b9}}},
- {0x1ff6, {2|F|SU|I(353), {0x03c9, 0x0342}}},
- {0x1ff7, {3|F|ST|SU|I(355), {0x03c9, 0x0342, 0x03b9}}},
- {0x1ff8, {1|F|D, {0x1f78}}},
- {0x1ff9, {1|F|D, {0x1f79}}},
- {0x1ffa, {1|F|D, {0x1f7c}}},
- {0x1ffb, {1|F|D, {0x1f7d}}},
- {0x1ffc, {2|F|IT|SL|SU|I(361), {0x03c9, 0x03b9}}},
- {0x2126, {1|F|D, {0x03c9}}},
- {0x212a, {1|F|D, {0x006b}}},
- {0x212b, {1|F|D, {0x00e5}}},
- {0x2132, {1|F|D, {0x214e}}},
- {0x2160, {1|F|D, {0x2170}}},
- {0x2161, {1|F|D, {0x2171}}},
- {0x2162, {1|F|D, {0x2172}}},
- {0x2163, {1|F|D, {0x2173}}},
- {0x2164, {1|F|D, {0x2174}}},
- {0x2165, {1|F|D, {0x2175}}},
- {0x2166, {1|F|D, {0x2176}}},
- {0x2167, {1|F|D, {0x2177}}},
- {0x2168, {1|F|D, {0x2178}}},
- {0x2169, {1|F|D, {0x2179}}},
- {0x216a, {1|F|D, {0x217a}}},
- {0x216b, {1|F|D, {0x217b}}},
- {0x216c, {1|F|D, {0x217c}}},
- {0x216d, {1|F|D, {0x217d}}},
- {0x216e, {1|F|D, {0x217e}}},
- {0x216f, {1|F|D, {0x217f}}},
- {0x2183, {1|F|D, {0x2184}}},
- {0x24b6, {1|F|D, {0x24d0}}},
- {0x24b7, {1|F|D, {0x24d1}}},
- {0x24b8, {1|F|D, {0x24d2}}},
- {0x24b9, {1|F|D, {0x24d3}}},
- {0x24ba, {1|F|D, {0x24d4}}},
- {0x24bb, {1|F|D, {0x24d5}}},
- {0x24bc, {1|F|D, {0x24d6}}},
- {0x24bd, {1|F|D, {0x24d7}}},
- {0x24be, {1|F|D, {0x24d8}}},
- {0x24bf, {1|F|D, {0x24d9}}},
- {0x24c0, {1|F|D, {0x24da}}},
- {0x24c1, {1|F|D, {0x24db}}},
- {0x24c2, {1|F|D, {0x24dc}}},
- {0x24c3, {1|F|D, {0x24dd}}},
- {0x24c4, {1|F|D, {0x24de}}},
- {0x24c5, {1|F|D, {0x24df}}},
- {0x24c6, {1|F|D, {0x24e0}}},
- {0x24c7, {1|F|D, {0x24e1}}},
- {0x24c8, {1|F|D, {0x24e2}}},
- {0x24c9, {1|F|D, {0x24e3}}},
- {0x24ca, {1|F|D, {0x24e4}}},
- {0x24cb, {1|F|D, {0x24e5}}},
- {0x24cc, {1|F|D, {0x24e6}}},
- {0x24cd, {1|F|D, {0x24e7}}},
- {0x24ce, {1|F|D, {0x24e8}}},
- {0x24cf, {1|F|D, {0x24e9}}},
- {0x2c00, {1|F|D, {0x2c30}}},
- {0x2c01, {1|F|D, {0x2c31}}},
- {0x2c02, {1|F|D, {0x2c32}}},
- {0x2c03, {1|F|D, {0x2c33}}},
- {0x2c04, {1|F|D, {0x2c34}}},
- {0x2c05, {1|F|D, {0x2c35}}},
- {0x2c06, {1|F|D, {0x2c36}}},
- {0x2c07, {1|F|D, {0x2c37}}},
- {0x2c08, {1|F|D, {0x2c38}}},
- {0x2c09, {1|F|D, {0x2c39}}},
- {0x2c0a, {1|F|D, {0x2c3a}}},
- {0x2c0b, {1|F|D, {0x2c3b}}},
- {0x2c0c, {1|F|D, {0x2c3c}}},
- {0x2c0d, {1|F|D, {0x2c3d}}},
- {0x2c0e, {1|F|D, {0x2c3e}}},
- {0x2c0f, {1|F|D, {0x2c3f}}},
- {0x2c10, {1|F|D, {0x2c40}}},
- {0x2c11, {1|F|D, {0x2c41}}},
- {0x2c12, {1|F|D, {0x2c42}}},
- {0x2c13, {1|F|D, {0x2c43}}},
- {0x2c14, {1|F|D, {0x2c44}}},
- {0x2c15, {1|F|D, {0x2c45}}},
- {0x2c16, {1|F|D, {0x2c46}}},
- {0x2c17, {1|F|D, {0x2c47}}},
- {0x2c18, {1|F|D, {0x2c48}}},
- {0x2c19, {1|F|D, {0x2c49}}},
- {0x2c1a, {1|F|D, {0x2c4a}}},
- {0x2c1b, {1|F|D, {0x2c4b}}},
- {0x2c1c, {1|F|D, {0x2c4c}}},
- {0x2c1d, {1|F|D, {0x2c4d}}},
- {0x2c1e, {1|F|D, {0x2c4e}}},
- {0x2c1f, {1|F|D, {0x2c4f}}},
- {0x2c20, {1|F|D, {0x2c50}}},
- {0x2c21, {1|F|D, {0x2c51}}},
- {0x2c22, {1|F|D, {0x2c52}}},
- {0x2c23, {1|F|D, {0x2c53}}},
- {0x2c24, {1|F|D, {0x2c54}}},
- {0x2c25, {1|F|D, {0x2c55}}},
- {0x2c26, {1|F|D, {0x2c56}}},
- {0x2c27, {1|F|D, {0x2c57}}},
- {0x2c28, {1|F|D, {0x2c58}}},
- {0x2c29, {1|F|D, {0x2c59}}},
- {0x2c2a, {1|F|D, {0x2c5a}}},
- {0x2c2b, {1|F|D, {0x2c5b}}},
- {0x2c2c, {1|F|D, {0x2c5c}}},
- {0x2c2d, {1|F|D, {0x2c5d}}},
- {0x2c2e, {1|F|D, {0x2c5e}}},
- {0x2c2f, {1|F|D, {0x2c5f}}},
- {0x2c60, {1|F|D, {0x2c61}}},
- {0x2c62, {1|F|D, {0x026b}}},
- {0x2c63, {1|F|D, {0x1d7d}}},
- {0x2c64, {1|F|D, {0x027d}}},
- {0x2c67, {1|F|D, {0x2c68}}},
- {0x2c69, {1|F|D, {0x2c6a}}},
- {0x2c6b, {1|F|D, {0x2c6c}}},
- {0x2c6d, {1|F|D, {0x0251}}},
- {0x2c6e, {1|F|D, {0x0271}}},
- {0x2c6f, {1|F|D, {0x0250}}},
- {0x2c70, {1|F|D, {0x0252}}},
- {0x2c72, {1|F|D, {0x2c73}}},
- {0x2c75, {1|F|D, {0x2c76}}},
- {0x2c7e, {1|F|D, {0x023f}}},
- {0x2c7f, {1|F|D, {0x0240}}},
- {0x2c80, {1|F|D, {0x2c81}}},
- {0x2c82, {1|F|D, {0x2c83}}},
- {0x2c84, {1|F|D, {0x2c85}}},
- {0x2c86, {1|F|D, {0x2c87}}},
- {0x2c88, {1|F|D, {0x2c89}}},
- {0x2c8a, {1|F|D, {0x2c8b}}},
- {0x2c8c, {1|F|D, {0x2c8d}}},
- {0x2c8e, {1|F|D, {0x2c8f}}},
- {0x2c90, {1|F|D, {0x2c91}}},
- {0x2c92, {1|F|D, {0x2c93}}},
- {0x2c94, {1|F|D, {0x2c95}}},
- {0x2c96, {1|F|D, {0x2c97}}},
- {0x2c98, {1|F|D, {0x2c99}}},
- {0x2c9a, {1|F|D, {0x2c9b}}},
- {0x2c9c, {1|F|D, {0x2c9d}}},
- {0x2c9e, {1|F|D, {0x2c9f}}},
- {0x2ca0, {1|F|D, {0x2ca1}}},
- {0x2ca2, {1|F|D, {0x2ca3}}},
- {0x2ca4, {1|F|D, {0x2ca5}}},
- {0x2ca6, {1|F|D, {0x2ca7}}},
- {0x2ca8, {1|F|D, {0x2ca9}}},
- {0x2caa, {1|F|D, {0x2cab}}},
- {0x2cac, {1|F|D, {0x2cad}}},
- {0x2cae, {1|F|D, {0x2caf}}},
- {0x2cb0, {1|F|D, {0x2cb1}}},
- {0x2cb2, {1|F|D, {0x2cb3}}},
- {0x2cb4, {1|F|D, {0x2cb5}}},
- {0x2cb6, {1|F|D, {0x2cb7}}},
- {0x2cb8, {1|F|D, {0x2cb9}}},
- {0x2cba, {1|F|D, {0x2cbb}}},
- {0x2cbc, {1|F|D, {0x2cbd}}},
- {0x2cbe, {1|F|D, {0x2cbf}}},
- {0x2cc0, {1|F|D, {0x2cc1}}},
- {0x2cc2, {1|F|D, {0x2cc3}}},
- {0x2cc4, {1|F|D, {0x2cc5}}},
- {0x2cc6, {1|F|D, {0x2cc7}}},
- {0x2cc8, {1|F|D, {0x2cc9}}},
- {0x2cca, {1|F|D, {0x2ccb}}},
- {0x2ccc, {1|F|D, {0x2ccd}}},
- {0x2cce, {1|F|D, {0x2ccf}}},
- {0x2cd0, {1|F|D, {0x2cd1}}},
- {0x2cd2, {1|F|D, {0x2cd3}}},
- {0x2cd4, {1|F|D, {0x2cd5}}},
- {0x2cd6, {1|F|D, {0x2cd7}}},
- {0x2cd8, {1|F|D, {0x2cd9}}},
- {0x2cda, {1|F|D, {0x2cdb}}},
- {0x2cdc, {1|F|D, {0x2cdd}}},
- {0x2cde, {1|F|D, {0x2cdf}}},
- {0x2ce0, {1|F|D, {0x2ce1}}},
- {0x2ce2, {1|F|D, {0x2ce3}}},
- {0x2ceb, {1|F|D, {0x2cec}}},
- {0x2ced, {1|F|D, {0x2cee}}},
- {0x2cf2, {1|F|D, {0x2cf3}}},
- {0xa640, {1|F|D, {0xa641}}},
- {0xa642, {1|F|D, {0xa643}}},
- {0xa644, {1|F|D, {0xa645}}},
- {0xa646, {1|F|D, {0xa647}}},
- {0xa648, {1|F|D, {0xa649}}},
- {0xa64a, {1|F|D, {0xa64b}}},
- {0xa64c, {1|F|D, {0xa64d}}},
- {0xa64e, {1|F|D, {0xa64f}}},
- {0xa650, {1|F|D, {0xa651}}},
- {0xa652, {1|F|D, {0xa653}}},
- {0xa654, {1|F|D, {0xa655}}},
- {0xa656, {1|F|D, {0xa657}}},
- {0xa658, {1|F|D, {0xa659}}},
- {0xa65a, {1|F|D, {0xa65b}}},
- {0xa65c, {1|F|D, {0xa65d}}},
- {0xa65e, {1|F|D, {0xa65f}}},
- {0xa660, {1|F|D, {0xa661}}},
- {0xa662, {1|F|D, {0xa663}}},
- {0xa664, {1|F|D, {0xa665}}},
- {0xa666, {1|F|D, {0xa667}}},
- {0xa668, {1|F|D, {0xa669}}},
- {0xa66a, {1|F|D, {0xa66b}}},
- {0xa66c, {1|F|D, {0xa66d}}},
- {0xa680, {1|F|D, {0xa681}}},
- {0xa682, {1|F|D, {0xa683}}},
- {0xa684, {1|F|D, {0xa685}}},
- {0xa686, {1|F|D, {0xa687}}},
- {0xa688, {1|F|D, {0xa689}}},
- {0xa68a, {1|F|D, {0xa68b}}},
- {0xa68c, {1|F|D, {0xa68d}}},
- {0xa68e, {1|F|D, {0xa68f}}},
- {0xa690, {1|F|D, {0xa691}}},
- {0xa692, {1|F|D, {0xa693}}},
- {0xa694, {1|F|D, {0xa695}}},
- {0xa696, {1|F|D, {0xa697}}},
- {0xa698, {1|F|D, {0xa699}}},
- {0xa69a, {1|F|D, {0xa69b}}},
- {0xa722, {1|F|D, {0xa723}}},
- {0xa724, {1|F|D, {0xa725}}},
- {0xa726, {1|F|D, {0xa727}}},
- {0xa728, {1|F|D, {0xa729}}},
- {0xa72a, {1|F|D, {0xa72b}}},
- {0xa72c, {1|F|D, {0xa72d}}},
- {0xa72e, {1|F|D, {0xa72f}}},
- {0xa732, {1|F|D, {0xa733}}},
- {0xa734, {1|F|D, {0xa735}}},
- {0xa736, {1|F|D, {0xa737}}},
- {0xa738, {1|F|D, {0xa739}}},
- {0xa73a, {1|F|D, {0xa73b}}},
- {0xa73c, {1|F|D, {0xa73d}}},
- {0xa73e, {1|F|D, {0xa73f}}},
- {0xa740, {1|F|D, {0xa741}}},
- {0xa742, {1|F|D, {0xa743}}},
- {0xa744, {1|F|D, {0xa745}}},
- {0xa746, {1|F|D, {0xa747}}},
- {0xa748, {1|F|D, {0xa749}}},
- {0xa74a, {1|F|D, {0xa74b}}},
- {0xa74c, {1|F|D, {0xa74d}}},
- {0xa74e, {1|F|D, {0xa74f}}},
- {0xa750, {1|F|D, {0xa751}}},
- {0xa752, {1|F|D, {0xa753}}},
- {0xa754, {1|F|D, {0xa755}}},
- {0xa756, {1|F|D, {0xa757}}},
- {0xa758, {1|F|D, {0xa759}}},
- {0xa75a, {1|F|D, {0xa75b}}},
- {0xa75c, {1|F|D, {0xa75d}}},
- {0xa75e, {1|F|D, {0xa75f}}},
- {0xa760, {1|F|D, {0xa761}}},
- {0xa762, {1|F|D, {0xa763}}},
- {0xa764, {1|F|D, {0xa765}}},
- {0xa766, {1|F|D, {0xa767}}},
- {0xa768, {1|F|D, {0xa769}}},
- {0xa76a, {1|F|D, {0xa76b}}},
- {0xa76c, {1|F|D, {0xa76d}}},
- {0xa76e, {1|F|D, {0xa76f}}},
- {0xa779, {1|F|D, {0xa77a}}},
- {0xa77b, {1|F|D, {0xa77c}}},
- {0xa77d, {1|F|D, {0x1d79}}},
- {0xa77e, {1|F|D, {0xa77f}}},
- {0xa780, {1|F|D, {0xa781}}},
- {0xa782, {1|F|D, {0xa783}}},
- {0xa784, {1|F|D, {0xa785}}},
- {0xa786, {1|F|D, {0xa787}}},
- {0xa78b, {1|F|D, {0xa78c}}},
- {0xa78d, {1|F|D, {0x0265}}},
- {0xa790, {1|F|D, {0xa791}}},
- {0xa792, {1|F|D, {0xa793}}},
- {0xa796, {1|F|D, {0xa797}}},
- {0xa798, {1|F|D, {0xa799}}},
- {0xa79a, {1|F|D, {0xa79b}}},
- {0xa79c, {1|F|D, {0xa79d}}},
- {0xa79e, {1|F|D, {0xa79f}}},
- {0xa7a0, {1|F|D, {0xa7a1}}},
- {0xa7a2, {1|F|D, {0xa7a3}}},
- {0xa7a4, {1|F|D, {0xa7a5}}},
- {0xa7a6, {1|F|D, {0xa7a7}}},
- {0xa7a8, {1|F|D, {0xa7a9}}},
- {0xa7aa, {1|F|D, {0x0266}}},
- {0xa7ab, {1|F|D, {0x025c}}},
- {0xa7ac, {1|F|D, {0x0261}}},
- {0xa7ad, {1|F|D, {0x026c}}},
- {0xa7ae, {1|F|D, {0x026a}}},
- {0xa7b0, {1|F|D, {0x029e}}},
- {0xa7b1, {1|F|D, {0x0287}}},
- {0xa7b2, {1|F|D, {0x029d}}},
- {0xa7b3, {1|F|D, {0xab53}}},
- {0xa7b4, {1|F|D, {0xa7b5}}},
- {0xa7b6, {1|F|D, {0xa7b7}}},
- {0xa7b8, {1|F|D, {0xa7b9}}},
- {0xa7ba, {1|F|D, {0xa7bb}}},
- {0xa7bc, {1|F|D, {0xa7bd}}},
- {0xa7be, {1|F|D, {0xa7bf}}},
- {0xa7c0, {1|F|D, {0xa7c1}}},
- {0xa7c2, {1|F|D, {0xa7c3}}},
- {0xa7c4, {1|F|D, {0xa794}}},
- {0xa7c5, {1|F|D, {0x0282}}},
- {0xa7c6, {1|F|D, {0x1d8e}}},
- {0xa7c7, {1|F|D, {0xa7c8}}},
- {0xa7c9, {1|F|D, {0xa7ca}}},
- {0xa7d0, {1|F|D, {0xa7d1}}},
- {0xa7d6, {1|F|D, {0xa7d7}}},
- {0xa7d8, {1|F|D, {0xa7d9}}},
- {0xa7f5, {1|F|D, {0xa7f6}}},
- {0xab70, {1|F|U, {0x13a0}}},
- {0xab71, {1|F|U, {0x13a1}}},
- {0xab72, {1|F|U, {0x13a2}}},
- {0xab73, {1|F|U, {0x13a3}}},
- {0xab74, {1|F|U, {0x13a4}}},
- {0xab75, {1|F|U, {0x13a5}}},
- {0xab76, {1|F|U, {0x13a6}}},
- {0xab77, {1|F|U, {0x13a7}}},
- {0xab78, {1|F|U, {0x13a8}}},
- {0xab79, {1|F|U, {0x13a9}}},
- {0xab7a, {1|F|U, {0x13aa}}},
- {0xab7b, {1|F|U, {0x13ab}}},
- {0xab7c, {1|F|U, {0x13ac}}},
- {0xab7d, {1|F|U, {0x13ad}}},
- {0xab7e, {1|F|U, {0x13ae}}},
- {0xab7f, {1|F|U, {0x13af}}},
- {0xab80, {1|F|U, {0x13b0}}},
- {0xab81, {1|F|U, {0x13b1}}},
- {0xab82, {1|F|U, {0x13b2}}},
- {0xab83, {1|F|U, {0x13b3}}},
- {0xab84, {1|F|U, {0x13b4}}},
- {0xab85, {1|F|U, {0x13b5}}},
- {0xab86, {1|F|U, {0x13b6}}},
- {0xab87, {1|F|U, {0x13b7}}},
- {0xab88, {1|F|U, {0x13b8}}},
- {0xab89, {1|F|U, {0x13b9}}},
- {0xab8a, {1|F|U, {0x13ba}}},
- {0xab8b, {1|F|U, {0x13bb}}},
- {0xab8c, {1|F|U, {0x13bc}}},
- {0xab8d, {1|F|U, {0x13bd}}},
- {0xab8e, {1|F|U, {0x13be}}},
- {0xab8f, {1|F|U, {0x13bf}}},
- {0xab90, {1|F|U, {0x13c0}}},
- {0xab91, {1|F|U, {0x13c1}}},
- {0xab92, {1|F|U, {0x13c2}}},
- {0xab93, {1|F|U, {0x13c3}}},
- {0xab94, {1|F|U, {0x13c4}}},
- {0xab95, {1|F|U, {0x13c5}}},
- {0xab96, {1|F|U, {0x13c6}}},
- {0xab97, {1|F|U, {0x13c7}}},
- {0xab98, {1|F|U, {0x13c8}}},
- {0xab99, {1|F|U, {0x13c9}}},
- {0xab9a, {1|F|U, {0x13ca}}},
- {0xab9b, {1|F|U, {0x13cb}}},
- {0xab9c, {1|F|U, {0x13cc}}},
- {0xab9d, {1|F|U, {0x13cd}}},
- {0xab9e, {1|F|U, {0x13ce}}},
- {0xab9f, {1|F|U, {0x13cf}}},
- {0xaba0, {1|F|U, {0x13d0}}},
- {0xaba1, {1|F|U, {0x13d1}}},
- {0xaba2, {1|F|U, {0x13d2}}},
- {0xaba3, {1|F|U, {0x13d3}}},
- {0xaba4, {1|F|U, {0x13d4}}},
- {0xaba5, {1|F|U, {0x13d5}}},
- {0xaba6, {1|F|U, {0x13d6}}},
- {0xaba7, {1|F|U, {0x13d7}}},
- {0xaba8, {1|F|U, {0x13d8}}},
- {0xaba9, {1|F|U, {0x13d9}}},
- {0xabaa, {1|F|U, {0x13da}}},
- {0xabab, {1|F|U, {0x13db}}},
- {0xabac, {1|F|U, {0x13dc}}},
- {0xabad, {1|F|U, {0x13dd}}},
- {0xabae, {1|F|U, {0x13de}}},
- {0xabaf, {1|F|U, {0x13df}}},
- {0xabb0, {1|F|U, {0x13e0}}},
- {0xabb1, {1|F|U, {0x13e1}}},
- {0xabb2, {1|F|U, {0x13e2}}},
- {0xabb3, {1|F|U, {0x13e3}}},
- {0xabb4, {1|F|U, {0x13e4}}},
- {0xabb5, {1|F|U, {0x13e5}}},
- {0xabb6, {1|F|U, {0x13e6}}},
- {0xabb7, {1|F|U, {0x13e7}}},
- {0xabb8, {1|F|U, {0x13e8}}},
- {0xabb9, {1|F|U, {0x13e9}}},
- {0xabba, {1|F|U, {0x13ea}}},
- {0xabbb, {1|F|U, {0x13eb}}},
- {0xabbc, {1|F|U, {0x13ec}}},
- {0xabbd, {1|F|U, {0x13ed}}},
- {0xabbe, {1|F|U, {0x13ee}}},
- {0xabbf, {1|F|U, {0x13ef}}},
- {0xfb00, {2|F|ST|SU|I(366), {0x0066, 0x0066}}},
- {0xfb01, {2|F|ST|SU|I(370), {0x0066, 0x0069}}},
- {0xfb02, {2|F|ST|SU|I(374), {0x0066, 0x006c}}},
- {0xfb03, {3|F|ST|SU|I(378), {0x0066, 0x0066, 0x0069}}},
- {0xfb04, {3|F|ST|SU|I(384), {0x0066, 0x0066, 0x006c}}},
- {0xfb05, {2|F|ST|SU|I(390), {0x0073, 0x0074}}},
- {0xfb06, {2|F|ST|SU|I(394), {0x0073, 0x0074}}},
- {0xfb13, {2|F|ST|SU|I(398), {0x0574, 0x0576}}},
- {0xfb14, {2|F|ST|SU|I(402), {0x0574, 0x0565}}},
- {0xfb15, {2|F|ST|SU|I(406), {0x0574, 0x056b}}},
- {0xfb16, {2|F|ST|SU|I(410), {0x057e, 0x0576}}},
- {0xfb17, {2|F|ST|SU|I(414), {0x0574, 0x056d}}},
- {0xff21, {1|F|D, {0xff41}}},
- {0xff22, {1|F|D, {0xff42}}},
- {0xff23, {1|F|D, {0xff43}}},
- {0xff24, {1|F|D, {0xff44}}},
- {0xff25, {1|F|D, {0xff45}}},
- {0xff26, {1|F|D, {0xff46}}},
- {0xff27, {1|F|D, {0xff47}}},
- {0xff28, {1|F|D, {0xff48}}},
- {0xff29, {1|F|D, {0xff49}}},
- {0xff2a, {1|F|D, {0xff4a}}},
- {0xff2b, {1|F|D, {0xff4b}}},
- {0xff2c, {1|F|D, {0xff4c}}},
- {0xff2d, {1|F|D, {0xff4d}}},
- {0xff2e, {1|F|D, {0xff4e}}},
- {0xff2f, {1|F|D, {0xff4f}}},
- {0xff30, {1|F|D, {0xff50}}},
- {0xff31, {1|F|D, {0xff51}}},
- {0xff32, {1|F|D, {0xff52}}},
- {0xff33, {1|F|D, {0xff53}}},
- {0xff34, {1|F|D, {0xff54}}},
- {0xff35, {1|F|D, {0xff55}}},
- {0xff36, {1|F|D, {0xff56}}},
- {0xff37, {1|F|D, {0xff57}}},
- {0xff38, {1|F|D, {0xff58}}},
- {0xff39, {1|F|D, {0xff59}}},
- {0xff3a, {1|F|D, {0xff5a}}},
- {0x10400, {1|F|D, {0x10428}}},
- {0x10401, {1|F|D, {0x10429}}},
- {0x10402, {1|F|D, {0x1042a}}},
- {0x10403, {1|F|D, {0x1042b}}},
- {0x10404, {1|F|D, {0x1042c}}},
- {0x10405, {1|F|D, {0x1042d}}},
- {0x10406, {1|F|D, {0x1042e}}},
- {0x10407, {1|F|D, {0x1042f}}},
- {0x10408, {1|F|D, {0x10430}}},
- {0x10409, {1|F|D, {0x10431}}},
- {0x1040a, {1|F|D, {0x10432}}},
- {0x1040b, {1|F|D, {0x10433}}},
- {0x1040c, {1|F|D, {0x10434}}},
- {0x1040d, {1|F|D, {0x10435}}},
- {0x1040e, {1|F|D, {0x10436}}},
- {0x1040f, {1|F|D, {0x10437}}},
- {0x10410, {1|F|D, {0x10438}}},
- {0x10411, {1|F|D, {0x10439}}},
- {0x10412, {1|F|D, {0x1043a}}},
- {0x10413, {1|F|D, {0x1043b}}},
- {0x10414, {1|F|D, {0x1043c}}},
- {0x10415, {1|F|D, {0x1043d}}},
- {0x10416, {1|F|D, {0x1043e}}},
- {0x10417, {1|F|D, {0x1043f}}},
- {0x10418, {1|F|D, {0x10440}}},
- {0x10419, {1|F|D, {0x10441}}},
- {0x1041a, {1|F|D, {0x10442}}},
- {0x1041b, {1|F|D, {0x10443}}},
- {0x1041c, {1|F|D, {0x10444}}},
- {0x1041d, {1|F|D, {0x10445}}},
- {0x1041e, {1|F|D, {0x10446}}},
- {0x1041f, {1|F|D, {0x10447}}},
- {0x10420, {1|F|D, {0x10448}}},
- {0x10421, {1|F|D, {0x10449}}},
- {0x10422, {1|F|D, {0x1044a}}},
- {0x10423, {1|F|D, {0x1044b}}},
- {0x10424, {1|F|D, {0x1044c}}},
- {0x10425, {1|F|D, {0x1044d}}},
- {0x10426, {1|F|D, {0x1044e}}},
- {0x10427, {1|F|D, {0x1044f}}},
- {0x104b0, {1|F|D, {0x104d8}}},
- {0x104b1, {1|F|D, {0x104d9}}},
- {0x104b2, {1|F|D, {0x104da}}},
- {0x104b3, {1|F|D, {0x104db}}},
- {0x104b4, {1|F|D, {0x104dc}}},
- {0x104b5, {1|F|D, {0x104dd}}},
- {0x104b6, {1|F|D, {0x104de}}},
- {0x104b7, {1|F|D, {0x104df}}},
- {0x104b8, {1|F|D, {0x104e0}}},
- {0x104b9, {1|F|D, {0x104e1}}},
- {0x104ba, {1|F|D, {0x104e2}}},
- {0x104bb, {1|F|D, {0x104e3}}},
- {0x104bc, {1|F|D, {0x104e4}}},
- {0x104bd, {1|F|D, {0x104e5}}},
- {0x104be, {1|F|D, {0x104e6}}},
- {0x104bf, {1|F|D, {0x104e7}}},
- {0x104c0, {1|F|D, {0x104e8}}},
- {0x104c1, {1|F|D, {0x104e9}}},
- {0x104c2, {1|F|D, {0x104ea}}},
- {0x104c3, {1|F|D, {0x104eb}}},
- {0x104c4, {1|F|D, {0x104ec}}},
- {0x104c5, {1|F|D, {0x104ed}}},
- {0x104c6, {1|F|D, {0x104ee}}},
- {0x104c7, {1|F|D, {0x104ef}}},
- {0x104c8, {1|F|D, {0x104f0}}},
- {0x104c9, {1|F|D, {0x104f1}}},
- {0x104ca, {1|F|D, {0x104f2}}},
- {0x104cb, {1|F|D, {0x104f3}}},
- {0x104cc, {1|F|D, {0x104f4}}},
- {0x104cd, {1|F|D, {0x104f5}}},
- {0x104ce, {1|F|D, {0x104f6}}},
- {0x104cf, {1|F|D, {0x104f7}}},
- {0x104d0, {1|F|D, {0x104f8}}},
- {0x104d1, {1|F|D, {0x104f9}}},
- {0x104d2, {1|F|D, {0x104fa}}},
- {0x104d3, {1|F|D, {0x104fb}}},
- {0x10570, {1|F|D, {0x10597}}},
- {0x10571, {1|F|D, {0x10598}}},
- {0x10572, {1|F|D, {0x10599}}},
- {0x10573, {1|F|D, {0x1059a}}},
- {0x10574, {1|F|D, {0x1059b}}},
- {0x10575, {1|F|D, {0x1059c}}},
- {0x10576, {1|F|D, {0x1059d}}},
- {0x10577, {1|F|D, {0x1059e}}},
- {0x10578, {1|F|D, {0x1059f}}},
- {0x10579, {1|F|D, {0x105a0}}},
- {0x1057a, {1|F|D, {0x105a1}}},
- {0x1057c, {1|F|D, {0x105a3}}},
- {0x1057d, {1|F|D, {0x105a4}}},
- {0x1057e, {1|F|D, {0x105a5}}},
- {0x1057f, {1|F|D, {0x105a6}}},
- {0x10580, {1|F|D, {0x105a7}}},
- {0x10581, {1|F|D, {0x105a8}}},
- {0x10582, {1|F|D, {0x105a9}}},
- {0x10583, {1|F|D, {0x105aa}}},
- {0x10584, {1|F|D, {0x105ab}}},
- {0x10585, {1|F|D, {0x105ac}}},
- {0x10586, {1|F|D, {0x105ad}}},
- {0x10587, {1|F|D, {0x105ae}}},
- {0x10588, {1|F|D, {0x105af}}},
- {0x10589, {1|F|D, {0x105b0}}},
- {0x1058a, {1|F|D, {0x105b1}}},
- {0x1058c, {1|F|D, {0x105b3}}},
- {0x1058d, {1|F|D, {0x105b4}}},
- {0x1058e, {1|F|D, {0x105b5}}},
- {0x1058f, {1|F|D, {0x105b6}}},
- {0x10590, {1|F|D, {0x105b7}}},
- {0x10591, {1|F|D, {0x105b8}}},
- {0x10592, {1|F|D, {0x105b9}}},
- {0x10594, {1|F|D, {0x105bb}}},
- {0x10595, {1|F|D, {0x105bc}}},
- {0x10c80, {1|F|D, {0x10cc0}}},
- {0x10c81, {1|F|D, {0x10cc1}}},
- {0x10c82, {1|F|D, {0x10cc2}}},
- {0x10c83, {1|F|D, {0x10cc3}}},
- {0x10c84, {1|F|D, {0x10cc4}}},
- {0x10c85, {1|F|D, {0x10cc5}}},
- {0x10c86, {1|F|D, {0x10cc6}}},
- {0x10c87, {1|F|D, {0x10cc7}}},
- {0x10c88, {1|F|D, {0x10cc8}}},
- {0x10c89, {1|F|D, {0x10cc9}}},
- {0x10c8a, {1|F|D, {0x10cca}}},
- {0x10c8b, {1|F|D, {0x10ccb}}},
- {0x10c8c, {1|F|D, {0x10ccc}}},
- {0x10c8d, {1|F|D, {0x10ccd}}},
- {0x10c8e, {1|F|D, {0x10cce}}},
- {0x10c8f, {1|F|D, {0x10ccf}}},
- {0x10c90, {1|F|D, {0x10cd0}}},
- {0x10c91, {1|F|D, {0x10cd1}}},
- {0x10c92, {1|F|D, {0x10cd2}}},
- {0x10c93, {1|F|D, {0x10cd3}}},
- {0x10c94, {1|F|D, {0x10cd4}}},
- {0x10c95, {1|F|D, {0x10cd5}}},
- {0x10c96, {1|F|D, {0x10cd6}}},
- {0x10c97, {1|F|D, {0x10cd7}}},
- {0x10c98, {1|F|D, {0x10cd8}}},
- {0x10c99, {1|F|D, {0x10cd9}}},
- {0x10c9a, {1|F|D, {0x10cda}}},
- {0x10c9b, {1|F|D, {0x10cdb}}},
- {0x10c9c, {1|F|D, {0x10cdc}}},
- {0x10c9d, {1|F|D, {0x10cdd}}},
- {0x10c9e, {1|F|D, {0x10cde}}},
- {0x10c9f, {1|F|D, {0x10cdf}}},
- {0x10ca0, {1|F|D, {0x10ce0}}},
- {0x10ca1, {1|F|D, {0x10ce1}}},
- {0x10ca2, {1|F|D, {0x10ce2}}},
- {0x10ca3, {1|F|D, {0x10ce3}}},
- {0x10ca4, {1|F|D, {0x10ce4}}},
- {0x10ca5, {1|F|D, {0x10ce5}}},
- {0x10ca6, {1|F|D, {0x10ce6}}},
- {0x10ca7, {1|F|D, {0x10ce7}}},
- {0x10ca8, {1|F|D, {0x10ce8}}},
- {0x10ca9, {1|F|D, {0x10ce9}}},
- {0x10caa, {1|F|D, {0x10cea}}},
- {0x10cab, {1|F|D, {0x10ceb}}},
- {0x10cac, {1|F|D, {0x10cec}}},
- {0x10cad, {1|F|D, {0x10ced}}},
- {0x10cae, {1|F|D, {0x10cee}}},
- {0x10caf, {1|F|D, {0x10cef}}},
- {0x10cb0, {1|F|D, {0x10cf0}}},
- {0x10cb1, {1|F|D, {0x10cf1}}},
- {0x10cb2, {1|F|D, {0x10cf2}}},
- {0x118a0, {1|F|D, {0x118c0}}},
- {0x118a1, {1|F|D, {0x118c1}}},
- {0x118a2, {1|F|D, {0x118c2}}},
- {0x118a3, {1|F|D, {0x118c3}}},
- {0x118a4, {1|F|D, {0x118c4}}},
- {0x118a5, {1|F|D, {0x118c5}}},
- {0x118a6, {1|F|D, {0x118c6}}},
- {0x118a7, {1|F|D, {0x118c7}}},
- {0x118a8, {1|F|D, {0x118c8}}},
- {0x118a9, {1|F|D, {0x118c9}}},
- {0x118aa, {1|F|D, {0x118ca}}},
- {0x118ab, {1|F|D, {0x118cb}}},
- {0x118ac, {1|F|D, {0x118cc}}},
- {0x118ad, {1|F|D, {0x118cd}}},
- {0x118ae, {1|F|D, {0x118ce}}},
- {0x118af, {1|F|D, {0x118cf}}},
- {0x118b0, {1|F|D, {0x118d0}}},
- {0x118b1, {1|F|D, {0x118d1}}},
- {0x118b2, {1|F|D, {0x118d2}}},
- {0x118b3, {1|F|D, {0x118d3}}},
- {0x118b4, {1|F|D, {0x118d4}}},
- {0x118b5, {1|F|D, {0x118d5}}},
- {0x118b6, {1|F|D, {0x118d6}}},
- {0x118b7, {1|F|D, {0x118d7}}},
- {0x118b8, {1|F|D, {0x118d8}}},
- {0x118b9, {1|F|D, {0x118d9}}},
- {0x118ba, {1|F|D, {0x118da}}},
- {0x118bb, {1|F|D, {0x118db}}},
- {0x118bc, {1|F|D, {0x118dc}}},
- {0x118bd, {1|F|D, {0x118dd}}},
- {0x118be, {1|F|D, {0x118de}}},
- {0x118bf, {1|F|D, {0x118df}}},
- {0x16e40, {1|F|D, {0x16e60}}},
- {0x16e41, {1|F|D, {0x16e61}}},
- {0x16e42, {1|F|D, {0x16e62}}},
- {0x16e43, {1|F|D, {0x16e63}}},
- {0x16e44, {1|F|D, {0x16e64}}},
- {0x16e45, {1|F|D, {0x16e65}}},
- {0x16e46, {1|F|D, {0x16e66}}},
- {0x16e47, {1|F|D, {0x16e67}}},
- {0x16e48, {1|F|D, {0x16e68}}},
- {0x16e49, {1|F|D, {0x16e69}}},
- {0x16e4a, {1|F|D, {0x16e6a}}},
- {0x16e4b, {1|F|D, {0x16e6b}}},
- {0x16e4c, {1|F|D, {0x16e6c}}},
- {0x16e4d, {1|F|D, {0x16e6d}}},
- {0x16e4e, {1|F|D, {0x16e6e}}},
- {0x16e4f, {1|F|D, {0x16e6f}}},
- {0x16e50, {1|F|D, {0x16e70}}},
- {0x16e51, {1|F|D, {0x16e71}}},
- {0x16e52, {1|F|D, {0x16e72}}},
- {0x16e53, {1|F|D, {0x16e73}}},
- {0x16e54, {1|F|D, {0x16e74}}},
- {0x16e55, {1|F|D, {0x16e75}}},
- {0x16e56, {1|F|D, {0x16e76}}},
- {0x16e57, {1|F|D, {0x16e77}}},
- {0x16e58, {1|F|D, {0x16e78}}},
- {0x16e59, {1|F|D, {0x16e79}}},
- {0x16e5a, {1|F|D, {0x16e7a}}},
- {0x16e5b, {1|F|D, {0x16e7b}}},
- {0x16e5c, {1|F|D, {0x16e7c}}},
- {0x16e5d, {1|F|D, {0x16e7d}}},
- {0x16e5e, {1|F|D, {0x16e7e}}},
- {0x16e5f, {1|F|D, {0x16e7f}}},
- {0x1e900, {1|F|D, {0x1e922}}},
- {0x1e901, {1|F|D, {0x1e923}}},
- {0x1e902, {1|F|D, {0x1e924}}},
- {0x1e903, {1|F|D, {0x1e925}}},
- {0x1e904, {1|F|D, {0x1e926}}},
- {0x1e905, {1|F|D, {0x1e927}}},
- {0x1e906, {1|F|D, {0x1e928}}},
- {0x1e907, {1|F|D, {0x1e929}}},
- {0x1e908, {1|F|D, {0x1e92a}}},
- {0x1e909, {1|F|D, {0x1e92b}}},
- {0x1e90a, {1|F|D, {0x1e92c}}},
- {0x1e90b, {1|F|D, {0x1e92d}}},
- {0x1e90c, {1|F|D, {0x1e92e}}},
- {0x1e90d, {1|F|D, {0x1e92f}}},
- {0x1e90e, {1|F|D, {0x1e930}}},
- {0x1e90f, {1|F|D, {0x1e931}}},
- {0x1e910, {1|F|D, {0x1e932}}},
- {0x1e911, {1|F|D, {0x1e933}}},
- {0x1e912, {1|F|D, {0x1e934}}},
- {0x1e913, {1|F|D, {0x1e935}}},
- {0x1e914, {1|F|D, {0x1e936}}},
- {0x1e915, {1|F|D, {0x1e937}}},
- {0x1e916, {1|F|D, {0x1e938}}},
- {0x1e917, {1|F|D, {0x1e939}}},
- {0x1e918, {1|F|D, {0x1e93a}}},
- {0x1e919, {1|F|D, {0x1e93b}}},
- {0x1e91a, {1|F|D, {0x1e93c}}},
- {0x1e91b, {1|F|D, {0x1e93d}}},
- {0x1e91c, {1|F|D, {0x1e93e}}},
- {0x1e91d, {1|F|D, {0x1e93f}}},
- {0x1e91e, {1|F|D, {0x1e940}}},
- {0x1e91f, {1|F|D, {0x1e941}}},
- {0x1e920, {1|F|D, {0x1e942}}},
- {0x1e921, {1|F|D, {0x1e943}}},
-#define CaseFold_Locale (*(CaseFold_11_Type (*)[2])(CaseFold_11_Table+1528))
- {0x0049, {1|F|D, {0x0069}}},
- {0x0130, {2|F|D, {0x0069, 0x0307}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseFold_11_hash -N onigenc_unicode_CaseFold_11_lookup -n */
-
-/* maximum key range = 3080, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseFold_11_hash(const OnigCodePoint code)
-{
- static const unsigned short asso_values[] =
- {
- 1, 3085, 2, 20, 3, 307, 200, 8, 31, 159,
- 2, 253, 33, 967, 3085, 3085, 3085, 3085, 3085, 3085,
- 3085, 3085, 3085, 3085, 3085, 3085, 3085, 30, 3085, 3085,
- 3085, 3085, 3085, 3085, 3085, 352, 3085, 3085, 3085, 3085,
- 3085, 93, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085,
- 3085, 407, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 201,
- 3085, 3085, 14, 13, 373, 1, 3085, 3085, 503, 19,
- 3085, 3085, 3085, 3085, 3085, 325, 3085, 3085, 290, 1064,
- 484, 28, 1906, 447, 272, 414, 2002, 79, 905, 5,
- 11, 22, 2024, 623, 761, 617, 1893, 45, 1874, 113,
- 1856, 255, 1823, 96, 1463, 62, 1841, 130, 1798, 331,
- 1771, 238, 1977, 147, 1387, 464, 1691, 187, 1639, 181,
- 366, 580, 1331, 508, 1287, 547, 1583, 541, 400, 783,
- 1944, 657, 1850, 932, 1785, 858, 1645, 681, 1412, 722,
- 1622, 972, 1306, 807, 1942, 1282, 283, 1218, 1557, 1055,
- 1406, 1258, 1401, 1168, 1327, 864, 893, 1123, 1714, 1195,
- 1885, 1083, 2016, 1232, 823, 678, 1420, 1017, 155, 1261,
- 86, 1351, 794, 1929, 51, 1525, 50, 221, 4, 1383,
- 196, 325, 1, 1562, 102, 1441, 3, 1356, 226, 1304,
- 271, 1516, 68, 1752, 37, 1469, 51, 1920, 143, 2059,
- 198, 2095, 370, 2069, 137, 718, 407, 1926, 136
- };
- return asso_values[bits_of(code, 2)+81] + asso_values[bits_of(code, 1)+2] + asso_values[bits_of(code, 0)];
-}
-
-static const CodePointList3 *
-onigenc_unicode_CaseFold_11_lookup(const OnigCodePoint code)
-{
- enum
- {
- MIN_CODE_VALUE = 0x41,
- MAX_CODE_VALUE = 0x1e921,
- TOTAL_KEYWORDS = 1530,
- MIN_WORD_LENGTH = 3,
- MAX_WORD_LENGTH = 3,
- MIN_HASH_VALUE = 5,
- MAX_HASH_VALUE = 3084
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1,
- /*0x1fe9*/ 850,
- -1,
- /*0x1f88*/ 775,
- /*0x0408*/ 305,
- /*0x0108*/ 61,
- /*0x10408*/ 1276,
- -1,
- /*0xab88*/ 1174,
- /*0x1f89*/ 776,
- /*0x0409*/ 306,
- /*0x2c69*/ 964,
- /*0x10409*/ 1277,
- /*0x2c08*/ 919,
- /*0xab89*/ 1175,
- /*0x1e88*/ 653,
- /*0x1e08*/ 589,
- -1, -1,
- /*0x2c09*/ 920,
- /*0x1f8a*/ 777,
- /*0x040a*/ 307,
- /*0x010a*/ 62,
- /*0x1040a*/ 1278,
- /*0x2c88*/ 978,
- /*0xab8a*/ 1176,
- /*0x1f80*/ 767,
- /*0x0400*/ 297,
- /*0x0100*/ 57,
- /*0x10400*/ 1268,
- /*0x2c0a*/ 921,
- /*0xab80*/ 1166,
- /*0x1e8a*/ 654,
- /*0x1e0a*/ 590,
- /*0x10c88*/ 1387,
- /*0x0508*/ 425,
- /*0x2c00*/ 911,
- -1,
- /*0x1e80*/ 649,
- /*0x1e00*/ 585,
- /*0x10c89*/ 1388,
- /*0x2c8a*/ 979,
- -1,
- /*0x1f90*/ 783,
- /*0x0410*/ 313,
- /*0x0110*/ 65,
- /*0x10410*/ 1284,
- /*0x2c80*/ 974,
- /*0xab90*/ 1182,
- /*0x1ff3*/ 855,
- -1,
- /*0x10c8a*/ 1389,
- /*0x050a*/ 426,
- /*0x2c10*/ 927,
- /*0xa780*/ 1106,
- /*0x1e90*/ 657,
- /*0x1e10*/ 593,
- /*0x10c80*/ 1379,
- /*0x0500*/ 421,
- -1,
- /*0x1f98*/ 791,
- /*0x0418*/ 321,
- /*0x0118*/ 69,
- /*0x10418*/ 1292,
- /*0x2c90*/ 982,
- /*0xab98*/ 1190,
- -1,
- /*0x00df*/ 56,
- /*0x00dd*/ 54,
- /*0x10571*/ 1345,
- /*0x2c18*/ 935,
- /*0xa790*/ 1112,
- /*0x1e98*/ 662,
- /*0x1e18*/ 597,
- /*0x10c90*/ 1395,
- /*0x0510*/ 429,
- /*0x2c6f*/ 968,
- /*0x1f86*/ 773,
- /*0x0406*/ 303,
- /*0x0106*/ 60,
- /*0x10406*/ 1274,
- /*0x2c98*/ 986,
- /*0xab86*/ 1172,
- /*0x10573*/ 1347,
- /*0x1fd9*/ 841,
- /*0x0059*/ 23,
- -1,
- /*0x2c06*/ 917,
- /*0xa798*/ 1115,
- /*0x1e86*/ 652,
- /*0x1e06*/ 588,
- /*0x10c98*/ 1403,
- /*0x0518*/ 433,
- -1,
- /*0x1f96*/ 789,
- /*0x0416*/ 319,
- /*0x0116*/ 68,
- /*0x10416*/ 1290,
- /*0x2c86*/ 977,
- /*0xab96*/ 1188,
- /*0x1fe7*/ 848,
- -1, -1,
- /*0x00d9*/ 50,
- /*0x2c16*/ 933,
- /*0xa786*/ 1109,
- /*0x1e96*/ 660,
- /*0x1e16*/ 596,
- /*0x10c86*/ 1385,
- /*0x0506*/ 424,
- /*0x2c67*/ 963,
- /*0x1f92*/ 785,
- /*0x0412*/ 315,
- /*0x0112*/ 66,
- /*0x10412*/ 1286,
- /*0x2c96*/ 985,
- /*0xab92*/ 1184,
- -1, -1, -1, -1,
- /*0x2c12*/ 929,
- /*0xa796*/ 1114,
- /*0x1e92*/ 658,
- /*0x1e12*/ 594,
- /*0x10c96*/ 1401,
- /*0x0516*/ 432,
- -1,
- /*0x1f9a*/ 793,
- /*0x041a*/ 323,
- /*0x011a*/ 70,
- /*0x1041a*/ 1294,
- /*0x2c92*/ 983,
- /*0xab9a*/ 1192,
- -1,
- /*0x1ffb*/ 862,
- /*0x017f*/ 120,
- /*0x017b*/ 118,
- /*0x2c1a*/ 937,
- /*0xa792*/ 1113,
- /*0x1e9a*/ 664,
- /*0x1e1a*/ 598,
- /*0x10c92*/ 1397,
- /*0x0512*/ 430,
- /*0x2c7f*/ 973,
- /*0x1fa0*/ 799,
- /*0x0420*/ 329,
- /*0x0120*/ 73,
- /*0x10420*/ 1300,
- /*0x2c9a*/ 987,
- /*0xaba0*/ 1198,
- /*0x2c75*/ 971,
- -1,
- /*0x1fd7*/ 839,
- /*0x0057*/ 21,
- /*0x2c20*/ 943,
- /*0xa79a*/ 1116,
- /*0x1ea0*/ 667,
- /*0x1e20*/ 601,
- /*0x10c9a*/ 1405,
- /*0x051a*/ 434,
- /*0x0388*/ 235,
- -1, -1,
- /*0x037f*/ 233,
- -1,
- /*0x2ca0*/ 990,
- /*0x0389*/ 236,
- /*0x1057f*/ 1358,
- /*0xa7f5*/ 1149,
- -1, -1, -1,
- /*0xa7a0*/ 1119,
- -1,
- /*0x10575*/ 1349,
- /*0x10ca0*/ 1411,
- /*0x0520*/ 437,
- /*0x038a*/ 237,
- /*0x1fa6*/ 805,
- /*0x0426*/ 335,
- /*0x0126*/ 76,
- /*0x10426*/ 1306,
- -1,
- /*0xaba6*/ 1204,
- /*0x1fa4*/ 803,
- /*0x0424*/ 333,
- /*0x0124*/ 75,
- /*0x10424*/ 1304,
- /*0x2c26*/ 949,
- /*0xaba4*/ 1202,
- /*0x1ea6*/ 670,
- /*0x1e26*/ 604,
- /*0x03f1*/ 288,
- /*0x1fe3*/ 845,
- /*0x2c24*/ 947,
- /*0x1ff7*/ 858,
- /*0x1ea4*/ 669,
- /*0x1e24*/ 603,
- -1,
- /*0x2ca6*/ 993,
- /*0x0390*/ 241,
- /*0x0208*/ 194,
- /*0x1c88*/ 538,
- /*0x2c63*/ 961,
- -1,
- /*0x2ca4*/ 992,
- /*0xa7a6*/ 1122,
- -1, -1,
- /*0x10ca6*/ 1417,
- /*0x0526*/ 440,
- -1,
- /*0xa7a4*/ 1121,
- -1, -1,
- /*0x10ca4*/ 1415,
- /*0x0524*/ 439,
- /*0x0398*/ 249,
- /*0x020a*/ 195,
- /*0x0460*/ 345,
- /*0x0160*/ 104,
- -1, -1,
- /*0x1feb*/ 852,
- /*0x0200*/ 190,
- /*0x1c80*/ 530,
- /*0x13fb*/ 527,
- -1,
- /*0x2c60*/ 959,
- /*0x10577*/ 1351,
- /*0x1ee0*/ 699,
- /*0x1e60*/ 633,
- -1,
- /*0x2c6b*/ 965,
- /*0x0386*/ 234,
- /*0x1f9e*/ 797,
- /*0x041e*/ 327,
- /*0x011e*/ 72,
- /*0x1041e*/ 1298,
- /*0x2ce0*/ 1022,
- /*0xab9e*/ 1196,
- /*0x0210*/ 198,
- /*0x1c90*/ 539,
- -1,
- /*0x2ceb*/ 1024,
- /*0x2c1e*/ 941,
- -1,
- /*0x1e9e*/ 666,
- /*0x1e1e*/ 600,
- -1, -1,
- /*0x0396*/ 247,
- /*0x1f94*/ 787,
- /*0x0414*/ 317,
- /*0x0114*/ 67,
- /*0x10414*/ 1288,
- /*0x2c9e*/ 989,
- /*0xab94*/ 1186,
- /*0x0218*/ 202,
- /*0x1c98*/ 547,
- -1, -1,
- /*0x2c14*/ 931,
- /*0xa79e*/ 1118,
- /*0x1e94*/ 659,
- /*0x1e14*/ 595,
- /*0x10c9e*/ 1409,
- /*0x051e*/ 436,
- /*0x0392*/ 243,
- /*0x1f83*/ 770,
- /*0x0403*/ 300,
- /*0x048a*/ 362,
- /*0x10403*/ 1271,
- /*0x2c94*/ 984,
- /*0xab83*/ 1169,
- /*0x0206*/ 193,
- /*0x1c86*/ 536,
- /*0x0480*/ 361,
- /*0x2c6d*/ 966,
- /*0x2c03*/ 914,
- /*0x1e908*/ 1502,
- /*0x0041*/ 0,
- /*0x0141*/ 88,
- /*0x10c94*/ 1399,
- /*0x0514*/ 431,
- /*0x039a*/ 251,
- /*0x1e909*/ 1503,
- /*0x2183*/ 884,
- -1,
- /*0x2ced*/ 1025,
- -1,
- /*0x03ff*/ 296,
- /*0x0216*/ 201,
- /*0x1c96*/ 545,
- /*0x0490*/ 365,
- -1, -1,
- /*0x1e90a*/ 1504,
- /*0x03f5*/ 290,
- /*0x00c1*/ 27,
- /*0x10c83*/ 1382,
- -1,
- /*0x03a0*/ 257,
- /*0x1e900*/ 1494,
- -1, -1, -1, -1, -1,
- /*0x0212*/ 199,
- /*0x1c92*/ 541,
- /*0x0498*/ 369,
- /*0x0541*/ 461,
- -1,
- /*0x0189*/ 126,
- -1, -1, -1, -1, -1,
- /*0x1e910*/ 1510,
- -1,
- /*0x1fe4*/ 846,
- /*0x0464*/ 347,
- /*0x0164*/ 106,
- /*0x018a*/ 127,
- /*0x021a*/ 203,
- /*0x1c9a*/ 549,
- /*0x1f9c*/ 795,
- /*0x041c*/ 325,
- /*0x011c*/ 71,
- /*0x1041c*/ 1296,
- /*0x2c64*/ 962,
- /*0xab9c*/ 1194,
- /*0x1ee4*/ 701,
- /*0x1e64*/ 635,
- /*0x03a6*/ 262,
- /*0x1e918*/ 1518,
- /*0x2c1c*/ 939,
- -1,
- /*0x01f1*/ 181,
- /*0x1e1c*/ 599,
- /*0x03a4*/ 260,
- /*0x0220*/ 206,
- /*0x1ca0*/ 555,
- /*0x0496*/ 368,
- -1, -1,
- /*0x0190*/ 131,
- /*0x2c9c*/ 988,
- -1, -1, -1,
- /*0x03f7*/ 291,
- /*0x1e906*/ 1500,
- -1,
- /*0xa79c*/ 1117,
- -1, -1,
- /*0x10c9c*/ 1407,
- /*0x051c*/ 435,
- -1,
- /*0x0492*/ 366,
- /*0x1fa7*/ 806,
- /*0x0427*/ 336,
- /*0x0198*/ 137,
- /*0x10427*/ 1307,
- /*0x1ff9*/ 860,
- /*0xaba7*/ 1205,
- /*0x0179*/ 117,
- -1,
- /*0x1e916*/ 1516,
- /*0x1f69*/ 760,
- /*0x2c27*/ 950,
- /*0x1f08*/ 715,
- -1,
- /*0x03e0*/ 279,
- /*0x0226*/ 209,
- /*0x1ca6*/ 561,
- /*0x049a*/ 370,
- /*0x1f09*/ 716,
- -1,
- /*0x0186*/ 124,
- /*0x0224*/ 208,
- /*0x1ca4*/ 559,
- -1, -1, -1,
- /*0x1e912*/ 1512,
- /*0x01d9*/ 169,
- -1,
- /*0x1f0a*/ 717,
- -1,
- /*0x039e*/ 255,
- /*0x10ca7*/ 1418,
- -1,
- /*0x04a0*/ 373,
- /*0x1faf*/ 814,
- /*0x042f*/ 344,
- /*0x0196*/ 135,
- -1,
- /*0x10579*/ 1353,
- /*0xabaf*/ 1213,
- -1, -1,
- /*0x1e91a*/ 1520,
- /*0x017d*/ 119,
- /*0x2c2f*/ 958,
- -1,
- /*0xfb00*/ 1230,
- /*0x0394*/ 245,
- /*0x1f84*/ 771,
- /*0x0404*/ 301,
- /*0x0104*/ 59,
- /*0x10404*/ 1272,
- -1,
- /*0xab84*/ 1170,
- -1, -1,
- /*0x1f5f*/ 758,
- /*0x1f5d*/ 757,
- /*0x2c04*/ 915,
- /*0x1e920*/ 1526,
- /*0x1e84*/ 651,
- /*0x1e04*/ 587,
- -1, -1, -1,
- /*0x10caf*/ 1426,
- -1,
- /*0x04a6*/ 376,
- /*0x1f18*/ 723,
- /*0x2c84*/ 976,
- -1,
- /*0x021e*/ 205,
- /*0x1c9e*/ 553,
- /*0x04a4*/ 375,
- /*0x1f6f*/ 766,
- /*0x1057d*/ 1356,
- /*0xa784*/ 1108,
- -1, -1,
- /*0x10c84*/ 1383,
- /*0x0504*/ 423,
- /*0x1f82*/ 769,
- /*0x0402*/ 299,
- /*0x0102*/ 58,
- /*0x10402*/ 1270,
- -1,
- /*0xab82*/ 1168,
- /*0x01a0*/ 141,
- /*0x0214*/ 200,
- /*0x1c94*/ 543,
- -1,
- /*0x2c02*/ 913,
- /*0x1f59*/ 755,
- /*0x1e82*/ 650,
- /*0x1e02*/ 586,
- /*0x01d7*/ 168,
- /*0x13f9*/ 525,
- /*0xfb06*/ 1236,
- /*0x1fa2*/ 801,
- /*0x0422*/ 331,
- /*0x0122*/ 74,
- /*0x10422*/ 1302,
- /*0x2c82*/ 975,
- /*0xaba2*/ 1200,
- -1, -1,
- /*0x1c83*/ 533,
- /*0x04e0*/ 405,
- /*0x2c22*/ 945,
- /*0xa782*/ 1107,
- /*0x1ea2*/ 668,
- /*0x1e22*/ 602,
- /*0x10c82*/ 1381,
- /*0x0502*/ 422,
- /*0xfb16*/ 1240,
- -1,
- /*0x0241*/ 220,
- /*0x03e4*/ 281,
- -1,
- /*0x2ca2*/ 991,
- -1,
- /*0x01a6*/ 144,
- -1,
- /*0x039c*/ 253,
- /*0x049e*/ 372,
- -1,
- /*0xa7a2*/ 1120,
- /*0x01a4*/ 143,
- -1,
- /*0x10ca2*/ 1413,
- /*0x0522*/ 438,
- -1,
- /*0x10a0*/ 484,
- /*0x13fd*/ 529,
- -1, -1,
- /*0x1f1a*/ 725,
- /*0x2165*/ 873,
- /*0x01f7*/ 185,
- /*0x2169*/ 877,
- /*0x2161*/ 869,
- /*0x0494*/ 367,
- /*0x1faa*/ 809,
- /*0x042a*/ 339,
- /*0x012a*/ 78,
- /*0xa660*/ 1043,
- -1,
- /*0xabaa*/ 1208,
- -1, -1,
- /*0x1e91e*/ 1524,
- -1,
- /*0x2c2a*/ 953,
- -1,
- /*0x1eaa*/ 672,
- /*0x1e2a*/ 606,
- -1, -1,
- /*0x03a7*/ 263,
- -1, -1,
- /*0x01e0*/ 172,
- /*0x03f9*/ 292,
- /*0x2caa*/ 995,
- /*0x021c*/ 204,
- /*0x1c9c*/ 551,
- /*0x10a6*/ 490,
- /*0x1e914*/ 1514,
- -1,
- /*0x04c1*/ 390,
- /*0xa7aa*/ 1124,
- /*0x104c1*/ 1325,
- /*0x10a4*/ 488,
- /*0x10caa*/ 1421,
- /*0x052a*/ 442,
- /*0x1fae*/ 813,
- /*0x042e*/ 343,
- /*0x012e*/ 80,
- -1, -1,
- /*0xabae*/ 1212,
- /*0x1fac*/ 811,
- /*0x042c*/ 341,
- /*0x012c*/ 79,
- /*0x1e903*/ 1497,
- /*0x2c2e*/ 957,
- /*0xabac*/ 1210,
- /*0x1eae*/ 674,
- /*0x1e2e*/ 608,
- /*0x118a0*/ 1430,
- -1,
- /*0x2c2c*/ 955,
- -1,
- /*0x1eac*/ 673,
- /*0x1e2c*/ 607,
- /*0x0194*/ 134,
- /*0x2cae*/ 997,
- -1, -1,
- /*0x03fd*/ 294,
- /*0x1ca7*/ 562,
- -1,
- /*0x2cac*/ 996,
- /*0xa7ae*/ 1128,
- /*0x216f*/ 883,
- -1,
- /*0x10cae*/ 1425,
- /*0x052e*/ 444,
- -1,
- /*0xa7ac*/ 1126,
- -1,
- /*0x04e4*/ 407,
- /*0x10cac*/ 1423,
- /*0x052c*/ 443,
- /*0x1fa8*/ 807,
- /*0x0428*/ 337,
- /*0x0128*/ 77,
- /*0x049c*/ 371,
- -1,
- /*0xaba8*/ 1206,
- -1, -1, -1,
- /*0x118a6*/ 1436,
- /*0x2c28*/ 951,
- -1,
- /*0x1ea8*/ 671,
- /*0x1e28*/ 605,
- -1,
- /*0x118a4*/ 1434,
- -1, -1,
- /*0x1f6b*/ 762,
- /*0xff26*/ 1247,
- /*0x1caf*/ 570,
- /*0x2ca8*/ 994,
- -1, -1,
- /*0x2167*/ 875,
- /*0xff24*/ 1245,
- -1,
- /*0x24c1*/ 896,
- /*0xa7a8*/ 1123,
- /*0x1e91c*/ 1522,
- -1,
- /*0x10ca8*/ 1419,
- /*0x0528*/ 441,
- /*0x0204*/ 192,
- /*0x1c84*/ 534,
- /*0xa664*/ 1045,
- -1,
- /*0x1f8e*/ 781,
- /*0x040e*/ 311,
- /*0x010e*/ 64,
- /*0x1040e*/ 1282,
- /*0xa77b*/ 1103,
- /*0xab8e*/ 1180,
- /*0x1f8c*/ 779,
- /*0x040c*/ 309,
- /*0x010c*/ 63,
- /*0x1040c*/ 1280,
- /*0x2c0e*/ 925,
- /*0xab8c*/ 1178,
- /*0x1e8e*/ 656,
- /*0x1e0e*/ 592,
- /*0x01e4*/ 174,
- -1,
- /*0x2c0c*/ 923,
- /*0x10c1*/ 517,
- /*0x1e8c*/ 655,
- /*0x1e0c*/ 591,
- /*0x019c*/ 138,
- /*0x2c8e*/ 981,
- /*0xfb14*/ 1238,
- -1, -1, -1,
- /*0x1f6d*/ 764,
- /*0x2c8c*/ 980,
- -1,
- /*0x0202*/ 191,
- /*0x1c82*/ 532,
- /*0x10c8e*/ 1393,
- /*0x050e*/ 428,
- -1, -1, -1, -1,
- /*0x10c8c*/ 1391,
- /*0x050c*/ 427,
- /*0xfb03*/ 1233,
- /*0x1fb2*/ 815,
- -1,
- /*0x0132*/ 81,
- -1, -1,
- /*0xabb2*/ 1216,
- /*0x0222*/ 207,
- /*0x1ca2*/ 557,
- /*0xa726*/ 1066,
- /*0x03aa*/ 266,
- -1, -1,
- /*0x1eb2*/ 676,
- /*0x1e32*/ 610,
- /*0xa724*/ 1065,
- /*0x01a7*/ 145,
- -1, -1, -1, -1, -1,
- /*0x2cb2*/ 999,
- /*0x0054*/ 18,
- /*0x0154*/ 98,
- /*0x1fb8*/ 820,
- -1,
- /*0x2126*/ 864,
- -1,
- /*0xa7b2*/ 1131,
- /*0xabb8*/ 1222,
- -1,
- /*0x10cb2*/ 1429,
- /*0x0532*/ 446,
- /*0x1ed4*/ 693,
- /*0x1e54*/ 627,
- /*0x1e904*/ 1498,
- /*0x1eb8*/ 679,
- /*0x1e38*/ 613,
- -1, -1,
- /*0x00d4*/ 46,
- /*0x2163*/ 871,
- /*0x2cd4*/ 1016,
- -1, -1,
- /*0x2cb8*/ 1002,
- /*0x1f1c*/ 727,
- -1,
- /*0xa760*/ 1094,
- /*0x01af*/ 149,
- /*0x022a*/ 211,
- /*0x1caa*/ 565,
- /*0xa7b8*/ 1135,
- /*0x0554*/ 480,
- -1, -1,
- /*0x0538*/ 452,
- -1, -1,
- /*0x04a2*/ 374,
- /*0x10a7*/ 491,
- /*0x1ffc*/ 863,
- /*0x047c*/ 359,
- /*0x0184*/ 123,
- -1,
- /*0x1fba*/ 822,
- /*0x2160*/ 868,
- -1,
- /*0x1e902*/ 1496,
- -1,
- /*0xabba*/ 1224,
- /*0x216b*/ 879,
- -1,
- /*0x1efc*/ 713,
- /*0x1e7c*/ 647,
- -1, -1,
- /*0x1eba*/ 680,
- /*0x1e3a*/ 614,
- -1, -1,
- /*0x03a8*/ 264,
- -1,
- /*0x022e*/ 213,
- /*0x1cae*/ 569,
- -1,
- /*0x2cba*/ 1003,
- -1, -1,
- /*0x022c*/ 212,
- /*0x1cac*/ 567,
- -1, -1,
- /*0xa7ba*/ 1136,
- /*0x10af*/ 499,
- /*0x1057c*/ 1355,
- /*0x0182*/ 122,
- /*0x053a*/ 454,
- -1, -1, -1, -1, -1,
- /*0x04aa*/ 378,
- /*0x1f8d*/ 780,
- /*0x040d*/ 310,
- -1,
- /*0x1040d*/ 1281,
- -1,
- /*0xab8d*/ 1179,
- -1, -1, -1,
- /*0x01a2*/ 142,
- /*0x2c0d*/ 924,
- /*0x1f2f*/ 736,
- /*0x216d*/ 881,
- /*0x118a7*/ 1437,
- /*0x038e*/ 239,
- -1, -1, -1,
- /*0x0228*/ 210,
- /*0x1ca8*/ 563,
- /*0x038c*/ 238,
- -1, -1,
- /*0xff27*/ 1248,
- /*0x0130*/ 1529,
- -1, -1,
- /*0xabb0*/ 1214,
- /*0xa78d*/ 1111,
- -1, -1,
- /*0x10c8d*/ 1392,
- /*0x04ae*/ 380,
- /*0x1fdb*/ 843,
- /*0x1eb0*/ 675,
- /*0x1e30*/ 609,
- -1,
- /*0xfb04*/ 1234,
- /*0x04ac*/ 379,
- -1, -1, -1, -1,
- /*0x2cb0*/ 998,
- -1, -1,
- /*0x1fbe*/ 825,
- /*0x118af*/ 1445,
- /*0xa764*/ 1096,
- /*0x13fc*/ 528,
- /*0xa7b0*/ 1129,
- /*0xabbe*/ 1228,
- /*0x00db*/ 52,
- /*0x10cb0*/ 1427,
- /*0x10a2*/ 486,
- /*0x020e*/ 197,
- -1,
- /*0xff2f*/ 1256,
- /*0x1ebe*/ 682,
- /*0x1e3e*/ 616,
- -1,
- /*0x020c*/ 196,
- /*0x1fd3*/ 837,
- /*0x0053*/ 17,
- -1, -1,
- /*0x2164*/ 872,
- /*0x2cbe*/ 1005,
- -1, -1,
- /*0xfb02*/ 1232,
- /*0x04a8*/ 377,
- -1, -1,
- /*0xa7be*/ 1138,
- -1, -1, -1,
- /*0x053e*/ 458,
- -1, -1,
- /*0x00d3*/ 45,
- -1, -1, -1, -1,
- /*0x01ae*/ 148,
- -1, -1, -1, -1, -1,
- /*0x01ac*/ 147,
- /*0xa779*/ 1102,
- /*0x0553*/ 479,
- /*0x0232*/ 215,
- /*0x1cb2*/ 573,
- /*0x1fb6*/ 818,
- /*0x10aa*/ 494,
- /*0x0136*/ 83,
- -1, -1,
- /*0xabb6*/ 1220,
- /*0x1fca*/ 833,
- /*0x004a*/ 8,
- /*0x014a*/ 93,
- -1, -1,
- /*0x048e*/ 364,
- /*0x1eb6*/ 678,
- /*0x1e36*/ 612,
- /*0x118a2*/ 1432,
- -1, -1,
- /*0x048c*/ 363,
- /*0x1eca*/ 688,
- /*0x1e4a*/ 622,
- -1,
- /*0x2cb6*/ 1001,
- /*0x1f2a*/ 731,
- /*0x1cb8*/ 579,
- /*0xff22*/ 1243,
- /*0x00ca*/ 36,
- -1,
- /*0x2cca*/ 1011,
- /*0xa7b6*/ 1134,
- -1, -1, -1,
- /*0x0536*/ 450,
- /*0xa77d*/ 1104,
- /*0x10ae*/ 498,
- /*0x1fcb*/ 834,
- /*0x004b*/ 9,
- /*0x1e90e*/ 1508,
- /*0x054a*/ 470,
- -1,
- /*0x10ac*/ 496,
- -1, -1,
- /*0x1e90c*/ 1506,
- -1, -1, -1,
- /*0x1f87*/ 774,
- /*0x0407*/ 304,
- -1,
- /*0x10407*/ 1275,
- /*0x04b2*/ 382,
- /*0xab87*/ 1173,
- /*0x104b2*/ 1310,
- /*0x00cb*/ 37,
- /*0x1f2e*/ 735,
- -1,
- /*0x2c07*/ 918,
- /*0x118aa*/ 1440,
- -1, -1,
- /*0x1f2c*/ 733,
- -1,
- /*0x023a*/ 216,
- /*0x1cba*/ 581,
- /*0x018e*/ 129,
- -1,
- /*0x054b*/ 471,
- /*0xff2a*/ 1251,
- -1, -1, -1,
- /*0x04d4*/ 399,
- /*0x10a8*/ 492,
- /*0x1fb4*/ 817,
- /*0x04b8*/ 385,
- /*0x0134*/ 82,
- /*0x104b8*/ 1316,
- /*0x10c87*/ 1386,
- /*0xabb4*/ 1218,
- -1, -1, -1,
- /*0x03b0*/ 268,
- /*0xab71*/ 1151,
- -1,
- /*0x1eb4*/ 677,
- /*0x1e34*/ 611,
- -1, -1,
- /*0xa722*/ 1064,
- /*0x118ae*/ 1444,
- -1, -1,
- /*0x1f28*/ 729,
- /*0x2cb4*/ 1000,
- -1,
- /*0x118ac*/ 1442,
- /*0xab73*/ 1153,
- -1, -1,
- /*0xff2e*/ 1255,
- /*0xa7b4*/ 1133,
- -1, -1,
- /*0x01b2*/ 151,
- /*0x0534*/ 448,
- /*0xff2c*/ 1253,
- -1, -1,
- /*0xa654*/ 1037,
- -1,
- /*0x04fc*/ 419,
- -1,
- /*0x1fbc*/ 824,
- /*0x10588*/ 1367,
- /*0x04ba*/ 386,
- -1,
- /*0x104ba*/ 1318,
- /*0xabbc*/ 1226,
- -1,
- /*0x10589*/ 1368,
- -1, -1,
- /*0x0230*/ 214,
- /*0x1cb0*/ 571,
- /*0x1ebc*/ 681,
- /*0x1e3c*/ 615,
- -1,
- /*0x01b8*/ 155,
- /*0x118a8*/ 1438,
- /*0x1f0e*/ 721,
- /*0x1058a*/ 1369,
- -1,
- /*0xa72a*/ 1068,
- /*0x2cbc*/ 1004,
- -1,
- /*0x1f0c*/ 719,
- /*0x10580*/ 1359,
- -1,
- /*0xff28*/ 1249,
- -1,
- /*0xa7bc*/ 1137,
- -1, -1, -1,
- /*0x053c*/ 456,
- /*0x24b8*/ 887,
- /*0x023e*/ 219,
- /*0x1cbe*/ 583,
- /*0x10b2*/ 502,
- -1,
- /*0x212a*/ 865,
- -1, -1,
- /*0x10590*/ 1374,
- -1, -1, -1,
- /*0x1fd6*/ 838,
- /*0x0056*/ 20,
- /*0x0156*/ 99,
- -1, -1, -1, -1,
- /*0x01fc*/ 188,
- /*0xa72e*/ 1070,
- -1, -1, -1,
- /*0x1ed6*/ 694,
- /*0x1e56*/ 628,
- /*0xa72c*/ 1069,
- /*0x10b8*/ 508,
- -1, -1,
- /*0x04b0*/ 381,
- /*0x00d6*/ 48,
- /*0x104b0*/ 1308,
- /*0x2cd6*/ 1017,
- /*0x1e90d*/ 1507,
- -1,
- /*0xab7f*/ 1165,
- /*0xab7b*/ 1161,
- -1, -1,
- /*0xa7d6*/ 1147,
- /*0x24ba*/ 889,
- /*0x10586*/ 1365,
- /*0xab75*/ 1155,
- /*0x0556*/ 482,
- /*0x1f54*/ 753,
- -1, -1,
- /*0x1f38*/ 737,
- -1,
- /*0x1fc4*/ 828,
- /*0x0044*/ 3,
- -1,
- /*0x1cb6*/ 577,
- /*0x04be*/ 388,
- -1,
- /*0x104be*/ 1322,
- -1,
- /*0x024a*/ 226,
- /*0xa728*/ 1067,
- /*0x118b2*/ 1448,
- -1,
- /*0x1ec4*/ 685,
- /*0x1e44*/ 619,
- /*0xa688*/ 1054,
- -1, -1, -1,
- /*0x10ba*/ 510,
- /*0x00c4*/ 30,
- /*0xff32*/ 1259,
- /*0x2cc4*/ 1008,
- /*0x104d3*/ 1343,
- -1, -1, -1,
- /*0x10592*/ 1376,
- -1,
- /*0xa7c4*/ 1141,
- /*0x0050*/ 14,
- /*0x0150*/ 96,
- /*0xa68a*/ 1055,
- /*0x0544*/ 464,
- -1,
- /*0x118b8*/ 1454,
- -1, -1,
- /*0xa680*/ 1050,
- -1,
- /*0x1f3a*/ 739,
- /*0x1ed0*/ 691,
- /*0x1e50*/ 625,
- -1, -1,
- /*0xff38*/ 1265,
- /*0x01db*/ 170,
- -1,
- /*0x00d0*/ 42,
- /*0xab77*/ 1157,
- /*0x2cd0*/ 1014,
- /*0x1c87*/ 537,
- -1, -1, -1,
- /*0xa690*/ 1058,
- /*0x04b6*/ 384,
- /*0xa7d0*/ 1146,
- /*0x104b6*/ 1314,
- -1, -1,
- /*0x0550*/ 476,
- /*0x16e5f*/ 1493,
- /*0x16e5d*/ 1491,
- /*0x104ca*/ 1334,
- -1, -1, -1, -1,
- /*0x1fcc*/ 835,
- /*0x004c*/ 10,
- /*0x014c*/ 94,
- /*0xa698*/ 1062,
- -1, -1,
- /*0x01d3*/ 166,
- /*0x118ba*/ 1456,
- /*0x24be*/ 893,
- /*0x1cb4*/ 575,
- /*0x1f0d*/ 720,
- /*0x10b0*/ 500,
- /*0x1ecc*/ 689,
- /*0x1e4c*/ 623,
- -1, -1, -1,
- /*0xff3a*/ 1267,
- /*0xa732*/ 1071,
- /*0x00cc*/ 38,
- /*0xa686*/ 1053,
- /*0x2ccc*/ 1012,
- /*0x04cb*/ 395,
- -1,
- /*0x104cb*/ 1335,
- -1, -1, -1, -1,
- /*0x16e59*/ 1487,
- -1,
- /*0xa64a*/ 1032,
- /*0x054c*/ 472,
- -1, -1,
- /*0x10be*/ 514,
- /*0x2132*/ 867,
- /*0xa696*/ 1061,
- -1,
- /*0xa754*/ 1088,
- -1, -1,
- /*0xa738*/ 1074,
- /*0x1f5b*/ 756,
- -1,
- /*0x1fc8*/ 831,
- /*0x0048*/ 7,
- /*0x01ca*/ 161,
- -1, -1, -1, -1,
- /*0x03d6*/ 274,
- -1,
- /*0xa692*/ 1059,
- -1,
- /*0x1f3e*/ 743,
- /*0x1ec8*/ 687,
- /*0x1e48*/ 621,
- /*0x24b6*/ 885,
- /*0x1e907*/ 1501,
- /*0x04b4*/ 383,
- -1,
- /*0x104b4*/ 1312,
- /*0x00c8*/ 34,
- /*0x24ca*/ 905,
- /*0x2cc8*/ 1010,
- -1,
- /*0x118b0*/ 1446,
- -1, -1,
- /*0xa69a*/ 1063,
- -1,
- /*0x004e*/ 12,
- /*0x014e*/ 95,
- -1,
- /*0x01cb*/ 162,
- /*0x0548*/ 468,
- /*0xff30*/ 1257,
- -1, -1, -1, -1,
- /*0xa73a*/ 1075,
- /*0x1ece*/ 690,
- /*0x1e4e*/ 624,
- /*0x10b6*/ 506,
- -1,
- /*0x0187*/ 125,
- -1, -1,
- /*0x00ce*/ 40,
- /*0x118be*/ 1460,
- /*0x2cce*/ 1013,
- /*0x24cb*/ 906,
- /*0x1fc2*/ 826,
- /*0x0042*/ 1,
- -1,
- /*0x16e57*/ 1485,
- -1,
- /*0x10594*/ 1377,
- /*0x04bc*/ 387,
- -1,
- /*0x104bc*/ 1320,
- /*0x054e*/ 474,
- -1, -1,
- /*0x1ec2*/ 684,
- /*0x1e42*/ 618,
- /*0x1fd2*/ 836,
- /*0x0052*/ 16,
- /*0x0152*/ 97,
- -1,
- /*0x1f4a*/ 747,
- /*0x00c2*/ 28,
- -1,
- /*0x2cc2*/ 1007,
- /*0x10583*/ 1362,
- /*0x03d0*/ 271,
- -1, -1,
- /*0x1ed2*/ 692,
- /*0x1e52*/ 626,
- /*0xa7c2*/ 1140,
- -1, -1, -1,
- /*0x0542*/ 462,
- /*0x00d2*/ 44,
- -1,
- /*0x2cd2*/ 1015,
- /*0x0244*/ 222,
- -1, -1, -1,
- /*0x1fc6*/ 829,
- /*0x0046*/ 5,
- -1,
- /*0x1fd8*/ 840,
- /*0x0058*/ 22,
- /*0x0158*/ 100,
- /*0x0552*/ 478,
- /*0x1f4b*/ 748,
- /*0x118b6*/ 1452,
- -1, -1,
- /*0x04d6*/ 400,
- /*0x1ec6*/ 686,
- /*0x1e46*/ 620,
- -1,
- /*0x1ed8*/ 695,
- /*0x1e58*/ 629,
- /*0xab79*/ 1159,
- /*0xff36*/ 1263,
- /*0x00c6*/ 32,
- /*0x01bc*/ 156,
- /*0x2cc6*/ 1009,
- /*0x00d8*/ 49,
- -1,
- /*0x2cd8*/ 1018,
- /*0x10b4*/ 504,
- -1, -1,
- /*0xa7c6*/ 1143,
- /*0x1fab*/ 810,
- /*0x042b*/ 340,
- /*0xa7d8*/ 1148,
- /*0x0546*/ 466,
- /*0xa73e*/ 1077,
- /*0xabab*/ 1209,
- -1,
- /*0x1ec0*/ 683,
- /*0x1e40*/ 617,
- /*0x24bc*/ 891,
- /*0x2c2b*/ 954,
- -1, -1, -1,
- /*0x00c0*/ 26,
- -1,
- /*0x2cc0*/ 1006,
- /*0x1fec*/ 853,
- /*0x046c*/ 351,
- /*0x016c*/ 110,
- /*0xa656*/ 1038,
- /*0x013d*/ 86,
- /*0x104c4*/ 1328,
- /*0xa7c0*/ 1139,
- /*0xabbd*/ 1227,
- /*0xab7d*/ 1163,
- -1,
- /*0x0540*/ 460,
- /*0xa7ab*/ 1125,
- /*0x1eec*/ 705,
- /*0x1e6c*/ 639,
- /*0x10cab*/ 1422,
- /*0xa694*/ 1060,
- -1, -1,
- /*0x024c*/ 227,
- /*0x10bc*/ 512,
- -1, -1, -1,
- /*0x1fc9*/ 832,
- /*0x0049*/ 1528,
- /*0x0149*/ 92,
- -1,
- /*0x1fa9*/ 808,
- /*0x0429*/ 338,
- -1, -1,
- /*0x04d0*/ 397,
- /*0xaba9*/ 1207,
- /*0x104d0*/ 1340,
- /*0x053d*/ 457,
- -1,
- /*0x118b4*/ 1450,
- /*0x2c29*/ 952,
- /*0xa736*/ 1073,
- -1,
- /*0x1f3c*/ 741,
- /*0xa644*/ 1029,
- /*0x00c9*/ 35,
- -1,
- /*0xa74a*/ 1083,
- /*0x16e41*/ 1463,
- /*0xff34*/ 1261,
- /*0x1fda*/ 842,
- /*0x005a*/ 24,
- /*0x015a*/ 101,
- -1,
- /*0xa7c9*/ 1145,
- /*0x1fea*/ 851,
- /*0x046a*/ 350,
- /*0x016a*/ 109,
- /*0x0549*/ 469,
- -1,
- /*0x01c4*/ 157,
- /*0x10ca9*/ 1420,
- /*0x1eda*/ 696,
- /*0x1e5a*/ 630,
- -1, -1,
- /*0x0248*/ 225,
- /*0x1eea*/ 704,
- /*0x1e6a*/ 638,
- /*0x00da*/ 51,
- -1,
- /*0x2cda*/ 1019,
- /*0xa650*/ 1035,
- -1, -1,
- /*0x03c2*/ 269,
- /*0x104cc*/ 1336,
- -1,
- /*0x24c4*/ 899,
- /*0x118bc*/ 1458,
- -1,
- /*0x10584*/ 1363,
- /*0x1fe2*/ 844,
- /*0x0462*/ 346,
- /*0x0162*/ 105,
- -1,
- /*0x1fa1*/ 800,
- /*0x0421*/ 330,
- /*0x1f56*/ 754,
- /*0x10421*/ 1301,
- -1,
- /*0xaba1*/ 1199,
- /*0x2c62*/ 960,
- /*0x024e*/ 228,
- /*0x1ee2*/ 700,
- /*0x1e62*/ 634,
- /*0x2c21*/ 944,
- -1, -1, -1,
- /*0x1fc7*/ 830,
- /*0x0047*/ 6,
- /*0x0147*/ 91,
- /*0x2ce2*/ 1023,
- -1,
- /*0x10c4*/ 520,
- /*0x0045*/ 4,
- /*0x0145*/ 90,
- -1, -1, -1,
- /*0x1fb9*/ 821,
- /*0xa64c*/ 1033,
- /*0x0139*/ 84,
- /*0x10582*/ 1361,
- /*0xa734*/ 1072,
- /*0xabb9*/ 1223,
- /*0x10ca1*/ 1412,
- /*0x03d8*/ 275,
- /*0x00c7*/ 33,
- /*0x0055*/ 19,
- /*0x104c8*/ 1332,
- -1, -1,
- /*0x00c5*/ 31,
- -1, -1, -1,
- /*0xa7c7*/ 1144,
- -1, -1, -1,
- /*0x0547*/ 467,
- /*0xa7c5*/ 1142,
- -1,
- /*0x0345*/ 229,
- -1,
- /*0x0545*/ 465,
- /*0x00d5*/ 47,
- -1,
- /*0x1fe8*/ 849,
- /*0x0468*/ 349,
- /*0x0168*/ 108,
- /*0x0539*/ 453,
- /*0x03ab*/ 267,
- -1,
- /*0x24cc*/ 907,
- -1,
- /*0x104ce*/ 1338,
- -1, -1,
- /*0x0555*/ 481,
- /*0x1ee8*/ 703,
- /*0x1e68*/ 637,
- /*0x1f50*/ 751,
- /*0xa73c*/ 1076,
- /*0x0246*/ 224,
- /*0xa648*/ 1031,
- -1, -1, -1,
- /*0x03ec*/ 285,
- /*0x1f97*/ 790,
- /*0x0417*/ 320,
- -1,
- /*0x10417*/ 1291,
- -1,
- /*0xab97*/ 1189,
- /*0x1ff2*/ 854,
- /*0x0472*/ 354,
- /*0x0172*/ 113,
- /*0x104c2*/ 1326,
- /*0x2c17*/ 934,
- /*0x01c8*/ 160,
- /*0x1e97*/ 661,
- -1, -1,
- /*0xa684*/ 1052,
- /*0x2c72*/ 970,
- -1,
- /*0x1ef2*/ 708,
- /*0x1e72*/ 642,
- -1,
- /*0x04d2*/ 398,
- /*0xa64e*/ 1034,
- /*0x104d2*/ 1342,
- /*0x1cab*/ 566,
- -1,
- /*0x03a9*/ 265,
- /*0x2cf2*/ 1026,
- -1,
- /*0x24c8*/ 903,
- -1,
- /*0x10c97*/ 1402,
- /*0x1f4c*/ 749,
- -1, -1, -1,
- /*0x0372*/ 231,
- -1,
- /*0xa756*/ 1089,
- -1,
- /*0x10572*/ 1346,
- -1,
- /*0x023d*/ 218,
- /*0x1cbd*/ 582,
- -1,
- /*0xa642*/ 1028,
- /*0x03da*/ 276,
- -1,
- /*0xa682*/ 1051,
- /*0x104c6*/ 1330,
- /*0x04d8*/ 401,
- /*0x03ea*/ 284,
- -1, -1,
- /*0x046e*/ 352,
- /*0x016e*/ 111,
- /*0x24ce*/ 909,
- -1, -1,
- /*0xa652*/ 1036,
- -1, -1, -1,
- /*0x2c6e*/ 967,
- /*0x015e*/ 103,
- /*0x1eee*/ 706,
- /*0x1e6e*/ 640,
- -1,
- /*0x1ca9*/ 564,
- -1, -1,
- /*0x04c0*/ 389,
- -1,
- /*0x104c0*/ 1324,
- /*0x1ede*/ 698,
- /*0x1e5e*/ 632,
- /*0xa744*/ 1080,
- /*0x1f48*/ 745,
- /*0x03e2*/ 280,
- /*0x24c2*/ 897,
- -1,
- /*0x00de*/ 55,
- /*0x03a1*/ 258,
- /*0x2cde*/ 1021,
- -1,
- /*0xa646*/ 1030,
- -1, -1,
- /*0xa658*/ 1039,
- -1, -1, -1, -1,
- /*0x04ec*/ 411,
- /*0x1fc3*/ 827,
- /*0x0043*/ 2,
- /*0x0143*/ 89,
- /*0x104bd*/ 1321,
- -1,
- /*0x1fe6*/ 847,
- /*0x0466*/ 348,
- /*0x0166*/ 107,
- -1, -1,
- /*0xa750*/ 1086,
- -1,
- /*0x10c2*/ 518,
- -1, -1,
- /*0xa640*/ 1027,
- -1,
- /*0x1ee6*/ 702,
- /*0x1e66*/ 636,
- /*0x00c3*/ 29,
- -1,
- /*0x03d5*/ 273,
- /*0x04c9*/ 394,
- -1,
- /*0x104c9*/ 1333,
- /*0x24c6*/ 901,
- /*0x1fad*/ 812,
- /*0x042d*/ 342,
- /*0x1058e*/ 1372,
- -1,
- /*0x1ca1*/ 556,
- /*0xabad*/ 1211,
- /*0x0543*/ 463,
- -1,
- /*0x1058c*/ 1370,
- -1,
- /*0x2c2d*/ 956,
- /*0xa66c*/ 1049,
- -1, -1, -1, -1,
- /*0x03e8*/ 283,
- -1, -1, -1,
- /*0x04da*/ 402,
- /*0x1f52*/ 752,
- /*0x0245*/ 223,
- /*0x24c0*/ 895,
- /*0xa74c*/ 1084,
- /*0x04ea*/ 410,
- -1,
- /*0x01ec*/ 178,
- /*0xa7ad*/ 1127,
- /*0x1cb9*/ 580,
- -1,
- /*0x10cad*/ 1424,
- -1, -1, -1, -1, -1, -1,
- /*0x0397*/ 248,
- /*0x1fbb*/ 823,
- /*0xab7c*/ 1162,
- /*0x013b*/ 85,
- -1, -1,
- /*0xabbb*/ 1225,
- -1, -1,
- /*0x24bd*/ 892,
- -1, -1,
- /*0x10c0*/ 516,
- -1,
- /*0x04e2*/ 406,
- -1,
- /*0x01a9*/ 146,
- /*0x10ab*/ 495,
- /*0x1fa5*/ 804,
- /*0x0425*/ 334,
- /*0xa65a*/ 1040,
- /*0x10425*/ 1305,
- -1,
- /*0xaba5*/ 1203,
- /*0x1fb7*/ 819,
- /*0xa66a*/ 1048,
- -1, -1,
- /*0x2c25*/ 948,
- /*0xabb7*/ 1221,
- /*0x24c9*/ 904,
- /*0xa748*/ 1082,
- /*0x04c7*/ 393,
- /*0x053b*/ 455,
- /*0x104c7*/ 1331,
- -1,
- /*0x10bd*/ 513,
- /*0x04c5*/ 392,
- /*0x1f2b*/ 732,
- /*0x104c5*/ 1329,
- -1,
- /*0x01ea*/ 177,
- /*0x1c97*/ 546,
- -1,
- /*0x1e921*/ 1527,
- /*0x104b9*/ 1317,
- -1, -1, -1,
- /*0x10ca5*/ 1416,
- -1, -1,
- /*0xa662*/ 1044,
- /*0x03ee*/ 286,
- -1,
- /*0x1f6c*/ 763,
- /*0x0537*/ 451,
- /*0x1f3d*/ 742,
- /*0xa74e*/ 1085,
- -1,
- /*0xa68e*/ 1057,
- /*0x10a9*/ 493,
- /*0x03de*/ 278,
- -1, -1, -1,
- /*0xa68c*/ 1056,
- -1,
- /*0x01e2*/ 173,
- -1,
- /*0x1fa3*/ 802,
- /*0x0423*/ 332,
- /*0x04e8*/ 409,
- /*0x10423*/ 1303,
- /*0x118ab*/ 1441,
- /*0xaba3*/ 1201,
- -1, -1,
- /*0x1f49*/ 746,
- -1,
- /*0x2c23*/ 946,
- /*0xa742*/ 1079,
- /*0x1f29*/ 730,
- -1,
- /*0xff2b*/ 1252,
- -1,
- /*0x01c7*/ 159,
- -1, -1, -1, -1,
- /*0x01c5*/ 158,
- -1,
- /*0x118bd*/ 1459,
- /*0x004d*/ 11,
- /*0xa752*/ 1087,
- -1, -1, -1,
- /*0x03e6*/ 282,
- /*0x04f2*/ 414,
- /*0x10ca3*/ 1414,
- -1, -1,
- /*0x24c7*/ 902,
- /*0x01d5*/ 167,
- -1,
- /*0x1f6a*/ 761,
- /*0x1058d*/ 1371,
- /*0x24c5*/ 900,
- /*0xa668*/ 1047,
- -1,
- /*0x00cd*/ 39,
- -1, -1,
- /*0x24b9*/ 888,
- -1,
- /*0x10a1*/ 485,
- /*0x118a9*/ 1439,
- -1,
- /*0x1e917*/ 1517,
- /*0xa746*/ 1081,
- -1,
- /*0x16e54*/ 1482,
- /*0xa758*/ 1090,
- /*0x054d*/ 473,
- /*0x01e8*/ 176,
- -1,
- /*0xff29*/ 1250,
- -1, -1,
- /*0x10c7*/ 522,
- /*0x0470*/ 353,
- /*0x0170*/ 112,
- -1,
- /*0x0243*/ 221,
- /*0x10c5*/ 521,
- -1, -1, -1, -1,
- /*0x2c70*/ 969,
- /*0x10b9*/ 509,
- /*0x1ef0*/ 707,
- /*0x1e70*/ 641,
- /*0xa740*/ 1078,
- -1,
- /*0x04ee*/ 412,
- /*0x0197*/ 136,
- -1,
- /*0x1f9d*/ 796,
- /*0x041d*/ 326,
- -1,
- /*0x1041d*/ 1297,
- /*0x01f2*/ 182,
- /*0xab9d*/ 1195,
- /*0x04de*/ 404,
- -1, -1, -1,
- /*0x2c1d*/ 940,
- /*0x0370*/ 230,
- /*0x1cad*/ 568,
- /*0x1f39*/ 738,
- -1,
- /*0x10570*/ 1344,
- -1,
- /*0xa76c*/ 1100,
- /*0x212b*/ 866,
- /*0xabb5*/ 1219,
- -1, -1, -1, -1,
- /*0x118a1*/ 1431,
- -1,
- /*0x03a5*/ 261,
- /*0x1f9b*/ 794,
- /*0x041b*/ 324,
- -1,
- /*0x1041b*/ 1295,
- /*0x10c9d*/ 1408,
- /*0xab9b*/ 1193,
- /*0x00b5*/ 25,
- /*0xff21*/ 1242,
- /*0x216c*/ 880,
- -1,
- /*0x2c1b*/ 938,
- /*0x04c3*/ 391,
- /*0x1e9b*/ 665,
- /*0x104c3*/ 1327,
- -1,
- /*0x1f68*/ 759,
- /*0x04e6*/ 408,
- /*0xa65e*/ 1042,
- -1,
- /*0x0535*/ 449,
- -1, -1,
- /*0x118b9*/ 1455,
- /*0x023b*/ 217,
- /*0x01ee*/ 179,
- /*0x1f95*/ 788,
- /*0x0415*/ 318,
- -1,
- /*0x10415*/ 1289,
- -1,
- /*0xab95*/ 1187,
- /*0x10c9b*/ 1406,
- /*0xff39*/ 1266,
- /*0x01de*/ 171,
- -1,
- /*0x2c15*/ 932,
- -1,
- /*0xa75a*/ 1091,
- -1, -1, -1,
- /*0x1ca5*/ 560,
- /*0xa76a*/ 1099,
- /*0x1f99*/ 792,
- /*0x0419*/ 322,
- -1,
- /*0x10419*/ 1293,
- /*0x1cb7*/ 578,
- /*0xab99*/ 1191,
- /*0xfb17*/ 1241,
- -1,
- /*0x03a3*/ 259,
- /*0x1fb3*/ 816,
- /*0x2c19*/ 936,
- /*0xa666*/ 1046,
- /*0x1e99*/ 663,
- /*0x10c95*/ 1400,
- /*0xabb3*/ 1217,
- /*0x1f93*/ 786,
- /*0x0413*/ 316,
- /*0x216a*/ 878,
- /*0x10413*/ 1287,
- /*0x16e5b*/ 1489,
- /*0xab93*/ 1185,
- -1, -1, -1, -1,
- /*0x2c13*/ 930,
- /*0xa762*/ 1095,
- /*0x01e6*/ 175,
- -1, -1,
- /*0x0587*/ 483,
- /*0x10c99*/ 1404,
- /*0x10587*/ 1366,
- /*0x1f91*/ 784,
- /*0x0411*/ 314,
- /*0x104bb*/ 1319,
- /*0x10411*/ 1285,
- /*0xa7b3*/ 1132,
- /*0xab91*/ 1183,
- -1,
- /*0x24c3*/ 898,
- /*0x0533*/ 447,
- -1,
- /*0x2c11*/ 928,
- /*0x2162*/ 870,
- /*0x004f*/ 13,
- /*0x10c93*/ 1398,
- /*0x1f6e*/ 765,
- /*0x16e53*/ 1481,
- -1,
- /*0x1ca3*/ 558,
- -1,
- /*0x1f8f*/ 782,
- /*0x040f*/ 312,
- -1,
- /*0x1040f*/ 1283,
- -1,
- /*0xab8f*/ 1181,
- /*0x104b7*/ 1315,
- -1, -1, -1,
- /*0x2c0f*/ 926,
- /*0x00cf*/ 41,
- /*0x10c91*/ 1396,
- /*0x1f81*/ 768,
- /*0x0401*/ 298,
- /*0x10c3*/ 519,
- /*0x10401*/ 1269,
- /*0x03f0*/ 287,
- /*0xab81*/ 1167,
- -1, -1, -1, -1,
- /*0x2c01*/ 912,
- /*0x054f*/ 475,
- -1, -1,
- /*0x1ff4*/ 856,
- /*0x0474*/ 355,
- /*0x0174*/ 114,
- -1,
- /*0x10c8f*/ 1394,
- /*0xa768*/ 1098,
- -1,
- /*0x047e*/ 360,
- -1,
- /*0x039d*/ 254,
- /*0x16e4a*/ 1472,
- /*0x015c*/ 102,
- /*0x1ef4*/ 709,
- /*0x1e74*/ 643,
- /*0x10ad*/ 497,
- -1,
- /*0x2c7e*/ 972,
- /*0x10c81*/ 1380,
- /*0x1efe*/ 714,
- /*0x1e7e*/ 648,
- -1,
- /*0x1edc*/ 697,
- /*0x1e5c*/ 631,
- /*0x2168*/ 876,
- /*0x013f*/ 87,
- -1,
- /*0x24bb*/ 890,
- /*0xabbf*/ 1229,
- /*0x00dc*/ 53,
- /*0xabb1*/ 1215,
- /*0x2cdc*/ 1020,
- /*0x01b7*/ 154,
- -1, -1,
- /*0x10574*/ 1348,
- /*0x1f2d*/ 734,
- /*0x039b*/ 252,
- -1, -1,
- /*0x16e4b*/ 1473,
- /*0x1057e*/ 1357,
- -1, -1, -1, -1, -1,
- /*0x04cd*/ 396,
- -1,
- /*0x104cd*/ 1337,
- /*0x24b7*/ 886,
- -1,
- /*0x1c9d*/ 552,
- /*0xa7b1*/ 1130,
- /*0x10bb*/ 511,
- /*0x053f*/ 459,
- /*0x10cb1*/ 1428,
- /*0x0531*/ 445,
- /*0x1f9f*/ 798,
- /*0x041f*/ 328,
- -1,
- /*0x1041f*/ 1299,
- /*0x0395*/ 246,
- /*0xab9f*/ 1197,
- -1, -1,
- /*0x1cb5*/ 576,
- -1,
- /*0x2c1f*/ 942,
- -1, -1,
- /*0x10a5*/ 489,
- /*0x118ad*/ 1443,
- -1, -1,
- /*0x1f3b*/ 740,
- -1,
- /*0x10b7*/ 507,
- -1,
- /*0x1c9b*/ 550,
- /*0x0399*/ 250,
- /*0xa76e*/ 1101,
- /*0xff2d*/ 1254,
- /*0x1f85*/ 772,
- /*0x0405*/ 302,
- /*0x04f0*/ 413,
- /*0x10405*/ 1273,
- -1,
- /*0xab85*/ 1171,
- /*0x10c9f*/ 1410,
- /*0xa75e*/ 1093,
- -1, -1,
- /*0x2c05*/ 916,
- -1,
- /*0x0393*/ 244,
- -1, -1,
- /*0x0051*/ 15,
- /*0x216e*/ 882,
- -1,
- /*0x01cd*/ 163,
- -1, -1,
- /*0x1c95*/ 544,
- /*0x1f8b*/ 778,
- /*0x040b*/ 308,
- -1,
- /*0x1040b*/ 1279,
- -1,
- /*0xab8b*/ 1177,
- /*0x118bb*/ 1457,
- -1,
- /*0x0391*/ 242,
- /*0x10c85*/ 1384,
- /*0x2c0b*/ 922,
- /*0x00d1*/ 43,
- -1, -1,
- /*0x24cd*/ 908,
- /*0x104b5*/ 1313,
- -1,
- /*0x1c99*/ 548,
- /*0x10a3*/ 487,
- /*0x03cf*/ 270,
- -1, -1,
- /*0xa766*/ 1097,
- /*0x118a5*/ 1435,
- /*0x0551*/ 477,
- /*0x1e91d*/ 1523,
- /*0x1cb3*/ 574,
- /*0x038f*/ 240,
- /*0xa78b*/ 1110,
- /*0x118b7*/ 1453,
- -1,
- /*0x10c8b*/ 1390,
- /*0x1c93*/ 542,
- /*0xff25*/ 1246,
- /*0x01f0*/ 180,
- /*0x1ff6*/ 857,
- /*0x0476*/ 356,
- /*0x0176*/ 115,
- -1,
- /*0xff37*/ 1264,
- /*0x2166*/ 874,
- /*0x10cd*/ 523,
- -1, -1, -1,
- /*0x1ffa*/ 861,
- /*0x047a*/ 358,
- /*0x1ef6*/ 710,
- /*0x1e76*/ 644,
- -1,
- /*0x1c91*/ 540,
- -1,
- /*0x1e91b*/ 1521,
- /*0x019d*/ 139,
- /*0x03f4*/ 289,
- -1, -1,
- /*0x1efa*/ 712,
- /*0x1e7a*/ 646,
- /*0x16e56*/ 1484,
- /*0x03fe*/ 295,
- -1,
- /*0x1f4d*/ 750,
- /*0x03dc*/ 277,
- -1,
- /*0x0376*/ 232,
- -1,
- /*0x01b5*/ 153,
- -1,
- /*0x10576*/ 1350,
- -1,
- /*0x1ff8*/ 859,
- /*0x0478*/ 357,
- /*0x0178*/ 116,
- -1,
- /*0x118a3*/ 1433,
- -1,
- /*0x1e915*/ 1515,
- -1,
- /*0x1057a*/ 1354,
- /*0x104b3*/ 1311,
- -1,
- /*0x1c81*/ 531,
- /*0x1ef8*/ 711,
- /*0x1e78*/ 645,
- /*0xff23*/ 1244,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x1e919*/ 1519,
- -1,
- /*0x16e44*/ 1466,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x10578*/ 1352,
- -1, -1, -1, -1,
- /*0x1e913*/ 1513,
- /*0x039f*/ 256,
- /*0x10b5*/ 505,
- -1, -1,
- /*0x104cf*/ 1339,
- -1, -1,
- /*0x1cbf*/ 584,
- /*0x1f1d*/ 728,
- /*0x1cb1*/ 572,
- -1, -1, -1, -1,
- /*0x16e50*/ 1478,
- -1, -1,
- /*0x1e911*/ 1511,
- -1, -1, -1,
- /*0x01b3*/ 152,
- -1, -1, -1, -1,
- /*0x13fa*/ 526,
- /*0x0193*/ 133,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x1f1b*/ 726,
- /*0x1e90f*/ 1509,
- /*0x04f4*/ 415,
- -1,
- /*0x03d1*/ 272,
- -1, -1,
- /*0x1c9f*/ 554,
- /*0x04fe*/ 420,
- -1,
- /*0x0191*/ 132,
- /*0x04dc*/ 403,
- -1, -1,
- /*0x1e901*/ 1495,
- -1, -1,
- /*0x13f8*/ 524,
- -1,
- /*0x16e4c*/ 1474,
- -1,
- /*0x01cf*/ 164,
- -1,
- /*0x118b5*/ 1451,
- -1, -1,
- /*0x104bf*/ 1323,
- -1,
- /*0x104b1*/ 1309,
- /*0x018f*/ 130,
- -1,
- /*0x10b3*/ 503,
- /*0x1c85*/ 535,
- /*0xff35*/ 1262,
- -1, -1, -1,
- /*0xfb15*/ 1239,
- -1,
- /*0x24cf*/ 910,
- -1, -1,
- /*0x0181*/ 121,
- /*0x1f19*/ 724,
- -1, -1, -1, -1, -1,
- /*0xa65c*/ 1041,
- -1, -1, -1, -1, -1, -1,
- /*0x01f4*/ 183,
- /*0x03fa*/ 293,
- -1, -1, -1, -1,
- /*0x01fe*/ 189,
- -1,
- /*0x16e48*/ 1470,
- -1, -1, -1, -1, -1,
- /*0xfb13*/ 1237,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x01b1*/ 150,
- -1, -1, -1, -1,
- /*0x1e91f*/ 1525,
- -1, -1,
- /*0x118b3*/ 1449,
- -1, -1,
- /*0x16e4e*/ 1476,
- -1, -1, -1,
- /*0x1f0f*/ 722,
- /*0x24bf*/ 894,
- -1,
- /*0xff33*/ 1260,
- -1,
- /*0x104d1*/ 1341,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x1e905*/ 1499,
- -1, -1,
- /*0x019f*/ 140,
- /*0x16e42*/ 1464,
- -1, -1, -1, -1, -1,
- /*0xfb01*/ 1231,
- -1, -1,
- /*0x10bf*/ 515,
- -1,
- /*0x10b1*/ 501,
- -1, -1,
- /*0x16e52*/ 1480,
- -1, -1, -1,
- /*0x1e90b*/ 1505,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x04f6*/ 416,
- -1, -1,
- /*0x1f3f*/ 744,
- -1, -1, -1, -1, -1, -1,
- /*0x04fa*/ 418,
- /*0x01d1*/ 165,
- -1,
- /*0x16e46*/ 1468,
- -1, -1,
- /*0x16e58*/ 1486,
- -1, -1,
- /*0x018b*/ 128,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x04f8*/ 417,
- /*0x16e40*/ 1462,
- -1,
- /*0x118bf*/ 1461,
- -1,
- /*0x118b1*/ 1447,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff31*/ 1258,
- -1, -1,
- /*0x01f6*/ 184,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xab72*/ 1152,
- /*0x01fa*/ 187,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xfb05*/ 1235,
- -1, -1, -1, -1, -1, -1,
- /*0x16e49*/ 1471,
- -1, -1,
- /*0x1f0b*/ 718,
- -1, -1, -1, -1,
- /*0x01f8*/ 186,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xa77e*/ 1105,
- -1, -1,
- /*0xa75c*/ 1092,
- -1, -1, -1,
- /*0x16e5a*/ 1488,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e47*/ 1469,
- -1, -1, -1, -1,
- /*0x16e45*/ 1467,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e55*/ 1483,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e5e*/ 1492,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x16e43*/ 1465,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xab70*/ 1150,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e4d*/ 1475,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x10595*/ 1378,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xab74*/ 1154,
- -1, -1, -1, -1, -1,
- /*0xab7e*/ 1164,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x10591*/ 1375,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x1058f*/ 1373,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x10581*/ 1360,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x16e4f*/ 1477,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xab76*/ 1156,
- -1, -1, -1, -1, -1,
- /*0x10585*/ 1364,
- -1, -1, -1,
- /*0xab7a*/ 1160,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x16e5c*/ 1490,
- -1, -1, -1, -1,
- /*0xab78*/ 1158,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x16e51*/ 1479
- };
-
- if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseFold_11_hash(code);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code1_equal(code, CaseFold_11_Table[s].from))
- return &CaseFold_11_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_11_Type CaseUnfold_11_Table[] = {
-#define CaseUnfold_11 (*(CaseUnfold_11_Type (*)[1395])(CaseUnfold_11_Table+0))
- {0x0061, {1|U, {0x0041}}},
- {0x0062, {1|U, {0x0042}}},
- {0x0063, {1|U, {0x0043}}},
- {0x0064, {1|U, {0x0044}}},
- {0x0065, {1|U, {0x0045}}},
- {0x0066, {1|U, {0x0046}}},
- {0x0067, {1|U, {0x0047}}},
- {0x0068, {1|U, {0x0048}}},
- {0x006a, {1|U, {0x004a}}},
- {0x006b, {2|U, {0x004b, 0x212a}}},
- {0x006c, {1|U, {0x004c}}},
- {0x006d, {1|U, {0x004d}}},
- {0x006e, {1|U, {0x004e}}},
- {0x006f, {1|U, {0x004f}}},
- {0x0070, {1|U, {0x0050}}},
- {0x0071, {1|U, {0x0051}}},
- {0x0072, {1|U, {0x0052}}},
- {0x0073, {2|U, {0x0053, 0x017f}}},
- {0x0074, {1|U, {0x0054}}},
- {0x0075, {1|U, {0x0055}}},
- {0x0076, {1|U, {0x0056}}},
- {0x0077, {1|U, {0x0057}}},
- {0x0078, {1|U, {0x0058}}},
- {0x0079, {1|U, {0x0059}}},
- {0x007a, {1|U, {0x005a}}},
- {0x00e0, {1|U, {0x00c0}}},
- {0x00e1, {1|U, {0x00c1}}},
- {0x00e2, {1|U, {0x00c2}}},
- {0x00e3, {1|U, {0x00c3}}},
- {0x00e4, {1|U, {0x00c4}}},
- {0x00e5, {2|U, {0x00c5, 0x212b}}},
- {0x00e6, {1|U, {0x00c6}}},
- {0x00e7, {1|U, {0x00c7}}},
- {0x00e8, {1|U, {0x00c8}}},
- {0x00e9, {1|U, {0x00c9}}},
- {0x00ea, {1|U, {0x00ca}}},
- {0x00eb, {1|U, {0x00cb}}},
- {0x00ec, {1|U, {0x00cc}}},
- {0x00ed, {1|U, {0x00cd}}},
- {0x00ee, {1|U, {0x00ce}}},
- {0x00ef, {1|U, {0x00cf}}},
- {0x00f0, {1|U, {0x00d0}}},
- {0x00f1, {1|U, {0x00d1}}},
- {0x00f2, {1|U, {0x00d2}}},
- {0x00f3, {1|U, {0x00d3}}},
- {0x00f4, {1|U, {0x00d4}}},
- {0x00f5, {1|U, {0x00d5}}},
- {0x00f6, {1|U, {0x00d6}}},
- {0x00f8, {1|U, {0x00d8}}},
- {0x00f9, {1|U, {0x00d9}}},
- {0x00fa, {1|U, {0x00da}}},
- {0x00fb, {1|U, {0x00db}}},
- {0x00fc, {1|U, {0x00dc}}},
- {0x00fd, {1|U, {0x00dd}}},
- {0x00fe, {1|U, {0x00de}}},
- {0x00ff, {1|U, {0x0178}}},
- {0x0101, {1|U, {0x0100}}},
- {0x0103, {1|U, {0x0102}}},
- {0x0105, {1|U, {0x0104}}},
- {0x0107, {1|U, {0x0106}}},
- {0x0109, {1|U, {0x0108}}},
- {0x010b, {1|U, {0x010a}}},
- {0x010d, {1|U, {0x010c}}},
- {0x010f, {1|U, {0x010e}}},
- {0x0111, {1|U, {0x0110}}},
- {0x0113, {1|U, {0x0112}}},
- {0x0115, {1|U, {0x0114}}},
- {0x0117, {1|U, {0x0116}}},
- {0x0119, {1|U, {0x0118}}},
- {0x011b, {1|U, {0x011a}}},
- {0x011d, {1|U, {0x011c}}},
- {0x011f, {1|U, {0x011e}}},
- {0x0121, {1|U, {0x0120}}},
- {0x0123, {1|U, {0x0122}}},
- {0x0125, {1|U, {0x0124}}},
- {0x0127, {1|U, {0x0126}}},
- {0x0129, {1|U, {0x0128}}},
- {0x012b, {1|U, {0x012a}}},
- {0x012d, {1|U, {0x012c}}},
- {0x012f, {1|U, {0x012e}}},
- {0x0133, {1|U, {0x0132}}},
- {0x0135, {1|U, {0x0134}}},
- {0x0137, {1|U, {0x0136}}},
- {0x013a, {1|U, {0x0139}}},
- {0x013c, {1|U, {0x013b}}},
- {0x013e, {1|U, {0x013d}}},
- {0x0140, {1|U, {0x013f}}},
- {0x0142, {1|U, {0x0141}}},
- {0x0144, {1|U, {0x0143}}},
- {0x0146, {1|U, {0x0145}}},
- {0x0148, {1|U, {0x0147}}},
- {0x014b, {1|U, {0x014a}}},
- {0x014d, {1|U, {0x014c}}},
- {0x014f, {1|U, {0x014e}}},
- {0x0151, {1|U, {0x0150}}},
- {0x0153, {1|U, {0x0152}}},
- {0x0155, {1|U, {0x0154}}},
- {0x0157, {1|U, {0x0156}}},
- {0x0159, {1|U, {0x0158}}},
- {0x015b, {1|U, {0x015a}}},
- {0x015d, {1|U, {0x015c}}},
- {0x015f, {1|U, {0x015e}}},
- {0x0161, {1|U, {0x0160}}},
- {0x0163, {1|U, {0x0162}}},
- {0x0165, {1|U, {0x0164}}},
- {0x0167, {1|U, {0x0166}}},
- {0x0169, {1|U, {0x0168}}},
- {0x016b, {1|U, {0x016a}}},
- {0x016d, {1|U, {0x016c}}},
- {0x016f, {1|U, {0x016e}}},
- {0x0171, {1|U, {0x0170}}},
- {0x0173, {1|U, {0x0172}}},
- {0x0175, {1|U, {0x0174}}},
- {0x0177, {1|U, {0x0176}}},
- {0x017a, {1|U, {0x0179}}},
- {0x017c, {1|U, {0x017b}}},
- {0x017e, {1|U, {0x017d}}},
- {0x0180, {1|U, {0x0243}}},
- {0x0183, {1|U, {0x0182}}},
- {0x0185, {1|U, {0x0184}}},
- {0x0188, {1|U, {0x0187}}},
- {0x018c, {1|U, {0x018b}}},
- {0x0192, {1|U, {0x0191}}},
- {0x0195, {1|U, {0x01f6}}},
- {0x0199, {1|U, {0x0198}}},
- {0x019a, {1|U, {0x023d}}},
- {0x019e, {1|U, {0x0220}}},
- {0x01a1, {1|U, {0x01a0}}},
- {0x01a3, {1|U, {0x01a2}}},
- {0x01a5, {1|U, {0x01a4}}},
- {0x01a8, {1|U, {0x01a7}}},
- {0x01ad, {1|U, {0x01ac}}},
- {0x01b0, {1|U, {0x01af}}},
- {0x01b4, {1|U, {0x01b3}}},
- {0x01b6, {1|U, {0x01b5}}},
- {0x01b9, {1|U, {0x01b8}}},
- {0x01bd, {1|U, {0x01bc}}},
- {0x01bf, {1|U, {0x01f7}}},
- {0x01c6, {2|U|ST, {0x01c4, 0x01c5}}},
- {0x01c9, {2|U|ST, {0x01c7, 0x01c8}}},
- {0x01cc, {2|U|ST, {0x01ca, 0x01cb}}},
- {0x01ce, {1|U, {0x01cd}}},
- {0x01d0, {1|U, {0x01cf}}},
- {0x01d2, {1|U, {0x01d1}}},
- {0x01d4, {1|U, {0x01d3}}},
- {0x01d6, {1|U, {0x01d5}}},
- {0x01d8, {1|U, {0x01d7}}},
- {0x01da, {1|U, {0x01d9}}},
- {0x01dc, {1|U, {0x01db}}},
- {0x01dd, {1|U, {0x018e}}},
- {0x01df, {1|U, {0x01de}}},
- {0x01e1, {1|U, {0x01e0}}},
- {0x01e3, {1|U, {0x01e2}}},
- {0x01e5, {1|U, {0x01e4}}},
- {0x01e7, {1|U, {0x01e6}}},
- {0x01e9, {1|U, {0x01e8}}},
- {0x01eb, {1|U, {0x01ea}}},
- {0x01ed, {1|U, {0x01ec}}},
- {0x01ef, {1|U, {0x01ee}}},
- {0x01f3, {2|U|ST, {0x01f1, 0x01f2}}},
- {0x01f5, {1|U, {0x01f4}}},
- {0x01f9, {1|U, {0x01f8}}},
- {0x01fb, {1|U, {0x01fa}}},
- {0x01fd, {1|U, {0x01fc}}},
- {0x01ff, {1|U, {0x01fe}}},
- {0x0201, {1|U, {0x0200}}},
- {0x0203, {1|U, {0x0202}}},
- {0x0205, {1|U, {0x0204}}},
- {0x0207, {1|U, {0x0206}}},
- {0x0209, {1|U, {0x0208}}},
- {0x020b, {1|U, {0x020a}}},
- {0x020d, {1|U, {0x020c}}},
- {0x020f, {1|U, {0x020e}}},
- {0x0211, {1|U, {0x0210}}},
- {0x0213, {1|U, {0x0212}}},
- {0x0215, {1|U, {0x0214}}},
- {0x0217, {1|U, {0x0216}}},
- {0x0219, {1|U, {0x0218}}},
- {0x021b, {1|U, {0x021a}}},
- {0x021d, {1|U, {0x021c}}},
- {0x021f, {1|U, {0x021e}}},
- {0x0223, {1|U, {0x0222}}},
- {0x0225, {1|U, {0x0224}}},
- {0x0227, {1|U, {0x0226}}},
- {0x0229, {1|U, {0x0228}}},
- {0x022b, {1|U, {0x022a}}},
- {0x022d, {1|U, {0x022c}}},
- {0x022f, {1|U, {0x022e}}},
- {0x0231, {1|U, {0x0230}}},
- {0x0233, {1|U, {0x0232}}},
- {0x023c, {1|U, {0x023b}}},
- {0x023f, {1|U, {0x2c7e}}},
- {0x0240, {1|U, {0x2c7f}}},
- {0x0242, {1|U, {0x0241}}},
- {0x0247, {1|U, {0x0246}}},
- {0x0249, {1|U, {0x0248}}},
- {0x024b, {1|U, {0x024a}}},
- {0x024d, {1|U, {0x024c}}},
- {0x024f, {1|U, {0x024e}}},
- {0x0250, {1|U, {0x2c6f}}},
- {0x0251, {1|U, {0x2c6d}}},
- {0x0252, {1|U, {0x2c70}}},
- {0x0253, {1|U, {0x0181}}},
- {0x0254, {1|U, {0x0186}}},
- {0x0256, {1|U, {0x0189}}},
- {0x0257, {1|U, {0x018a}}},
- {0x0259, {1|U, {0x018f}}},
- {0x025b, {1|U, {0x0190}}},
- {0x025c, {1|U, {0xa7ab}}},
- {0x0260, {1|U, {0x0193}}},
- {0x0261, {1|U, {0xa7ac}}},
- {0x0263, {1|U, {0x0194}}},
- {0x0265, {1|U, {0xa78d}}},
- {0x0266, {1|U, {0xa7aa}}},
- {0x0268, {1|U, {0x0197}}},
- {0x0269, {1|U, {0x0196}}},
- {0x026a, {1|U, {0xa7ae}}},
- {0x026b, {1|U, {0x2c62}}},
- {0x026c, {1|U, {0xa7ad}}},
- {0x026f, {1|U, {0x019c}}},
- {0x0271, {1|U, {0x2c6e}}},
- {0x0272, {1|U, {0x019d}}},
- {0x0275, {1|U, {0x019f}}},
- {0x027d, {1|U, {0x2c64}}},
- {0x0280, {1|U, {0x01a6}}},
- {0x0282, {1|U, {0xa7c5}}},
- {0x0283, {1|U, {0x01a9}}},
- {0x0287, {1|U, {0xa7b1}}},
- {0x0288, {1|U, {0x01ae}}},
- {0x0289, {1|U, {0x0244}}},
- {0x028a, {1|U, {0x01b1}}},
- {0x028b, {1|U, {0x01b2}}},
- {0x028c, {1|U, {0x0245}}},
- {0x0292, {1|U, {0x01b7}}},
- {0x029d, {1|U, {0xa7b2}}},
- {0x029e, {1|U, {0xa7b0}}},
- {0x0371, {1|U, {0x0370}}},
- {0x0373, {1|U, {0x0372}}},
- {0x0377, {1|U, {0x0376}}},
- {0x037b, {1|U, {0x03fd}}},
- {0x037c, {1|U, {0x03fe}}},
- {0x037d, {1|U, {0x03ff}}},
- {0x03ac, {1|U, {0x0386}}},
- {0x03ad, {1|U, {0x0388}}},
- {0x03ae, {1|U, {0x0389}}},
- {0x03af, {1|U, {0x038a}}},
- {0x03b1, {1|U, {0x0391}}},
- {0x03b2, {2|U, {0x0392, 0x03d0}}},
- {0x03b3, {1|U, {0x0393}}},
- {0x03b4, {1|U, {0x0394}}},
- {0x03b5, {2|U, {0x0395, 0x03f5}}},
- {0x03b6, {1|U, {0x0396}}},
- {0x03b7, {1|U, {0x0397}}},
- {0x03b8, {3|U, {0x0398, 0x03d1, 0x03f4}}},
- {0x03b9, {3|U, {0x0399, 0x0345, 0x1fbe}}},
- {0x03ba, {2|U, {0x039a, 0x03f0}}},
- {0x03bb, {1|U, {0x039b}}},
- {0x03bc, {2|U, {0x039c, 0x00b5}}},
- {0x03bd, {1|U, {0x039d}}},
- {0x03be, {1|U, {0x039e}}},
- {0x03bf, {1|U, {0x039f}}},
- {0x03c0, {2|U, {0x03a0, 0x03d6}}},
- {0x03c1, {2|U, {0x03a1, 0x03f1}}},
- {0x03c3, {2|U, {0x03a3, 0x03c2}}},
- {0x03c4, {1|U, {0x03a4}}},
- {0x03c5, {1|U, {0x03a5}}},
- {0x03c6, {2|U, {0x03a6, 0x03d5}}},
- {0x03c7, {1|U, {0x03a7}}},
- {0x03c8, {1|U, {0x03a8}}},
- {0x03c9, {2|U, {0x03a9, 0x2126}}},
- {0x03ca, {1|U, {0x03aa}}},
- {0x03cb, {1|U, {0x03ab}}},
- {0x03cc, {1|U, {0x038c}}},
- {0x03cd, {1|U, {0x038e}}},
- {0x03ce, {1|U, {0x038f}}},
- {0x03d7, {1|U, {0x03cf}}},
- {0x03d9, {1|U, {0x03d8}}},
- {0x03db, {1|U, {0x03da}}},
- {0x03dd, {1|U, {0x03dc}}},
- {0x03df, {1|U, {0x03de}}},
- {0x03e1, {1|U, {0x03e0}}},
- {0x03e3, {1|U, {0x03e2}}},
- {0x03e5, {1|U, {0x03e4}}},
- {0x03e7, {1|U, {0x03e6}}},
- {0x03e9, {1|U, {0x03e8}}},
- {0x03eb, {1|U, {0x03ea}}},
- {0x03ed, {1|U, {0x03ec}}},
- {0x03ef, {1|U, {0x03ee}}},
- {0x03f2, {1|U, {0x03f9}}},
- {0x03f3, {1|U, {0x037f}}},
- {0x03f8, {1|U, {0x03f7}}},
- {0x03fb, {1|U, {0x03fa}}},
- {0x0430, {1|U, {0x0410}}},
- {0x0431, {1|U, {0x0411}}},
- {0x0432, {2|U, {0x0412, 0x1c80}}},
- {0x0433, {1|U, {0x0413}}},
- {0x0434, {2|U, {0x0414, 0x1c81}}},
- {0x0435, {1|U, {0x0415}}},
- {0x0436, {1|U, {0x0416}}},
- {0x0437, {1|U, {0x0417}}},
- {0x0438, {1|U, {0x0418}}},
- {0x0439, {1|U, {0x0419}}},
- {0x043a, {1|U, {0x041a}}},
- {0x043b, {1|U, {0x041b}}},
- {0x043c, {1|U, {0x041c}}},
- {0x043d, {1|U, {0x041d}}},
- {0x043e, {2|U, {0x041e, 0x1c82}}},
- {0x043f, {1|U, {0x041f}}},
- {0x0440, {1|U, {0x0420}}},
- {0x0441, {2|U, {0x0421, 0x1c83}}},
- {0x0442, {3|U, {0x0422, 0x1c84, 0x1c85}}},
- {0x0443, {1|U, {0x0423}}},
- {0x0444, {1|U, {0x0424}}},
- {0x0445, {1|U, {0x0425}}},
- {0x0446, {1|U, {0x0426}}},
- {0x0447, {1|U, {0x0427}}},
- {0x0448, {1|U, {0x0428}}},
- {0x0449, {1|U, {0x0429}}},
- {0x044a, {2|U, {0x042a, 0x1c86}}},
- {0x044b, {1|U, {0x042b}}},
- {0x044c, {1|U, {0x042c}}},
- {0x044d, {1|U, {0x042d}}},
- {0x044e, {1|U, {0x042e}}},
- {0x044f, {1|U, {0x042f}}},
- {0x0450, {1|U, {0x0400}}},
- {0x0451, {1|U, {0x0401}}},
- {0x0452, {1|U, {0x0402}}},
- {0x0453, {1|U, {0x0403}}},
- {0x0454, {1|U, {0x0404}}},
- {0x0455, {1|U, {0x0405}}},
- {0x0456, {1|U, {0x0406}}},
- {0x0457, {1|U, {0x0407}}},
- {0x0458, {1|U, {0x0408}}},
- {0x0459, {1|U, {0x0409}}},
- {0x045a, {1|U, {0x040a}}},
- {0x045b, {1|U, {0x040b}}},
- {0x045c, {1|U, {0x040c}}},
- {0x045d, {1|U, {0x040d}}},
- {0x045e, {1|U, {0x040e}}},
- {0x045f, {1|U, {0x040f}}},
- {0x0461, {1|U, {0x0460}}},
- {0x0463, {2|U, {0x0462, 0x1c87}}},
- {0x0465, {1|U, {0x0464}}},
- {0x0467, {1|U, {0x0466}}},
- {0x0469, {1|U, {0x0468}}},
- {0x046b, {1|U, {0x046a}}},
- {0x046d, {1|U, {0x046c}}},
- {0x046f, {1|U, {0x046e}}},
- {0x0471, {1|U, {0x0470}}},
- {0x0473, {1|U, {0x0472}}},
- {0x0475, {1|U, {0x0474}}},
- {0x0477, {1|U, {0x0476}}},
- {0x0479, {1|U, {0x0478}}},
- {0x047b, {1|U, {0x047a}}},
- {0x047d, {1|U, {0x047c}}},
- {0x047f, {1|U, {0x047e}}},
- {0x0481, {1|U, {0x0480}}},
- {0x048b, {1|U, {0x048a}}},
- {0x048d, {1|U, {0x048c}}},
- {0x048f, {1|U, {0x048e}}},
- {0x0491, {1|U, {0x0490}}},
- {0x0493, {1|U, {0x0492}}},
- {0x0495, {1|U, {0x0494}}},
- {0x0497, {1|U, {0x0496}}},
- {0x0499, {1|U, {0x0498}}},
- {0x049b, {1|U, {0x049a}}},
- {0x049d, {1|U, {0x049c}}},
- {0x049f, {1|U, {0x049e}}},
- {0x04a1, {1|U, {0x04a0}}},
- {0x04a3, {1|U, {0x04a2}}},
- {0x04a5, {1|U, {0x04a4}}},
- {0x04a7, {1|U, {0x04a6}}},
- {0x04a9, {1|U, {0x04a8}}},
- {0x04ab, {1|U, {0x04aa}}},
- {0x04ad, {1|U, {0x04ac}}},
- {0x04af, {1|U, {0x04ae}}},
- {0x04b1, {1|U, {0x04b0}}},
- {0x04b3, {1|U, {0x04b2}}},
- {0x04b5, {1|U, {0x04b4}}},
- {0x04b7, {1|U, {0x04b6}}},
- {0x04b9, {1|U, {0x04b8}}},
- {0x04bb, {1|U, {0x04ba}}},
- {0x04bd, {1|U, {0x04bc}}},
- {0x04bf, {1|U, {0x04be}}},
- {0x04c2, {1|U, {0x04c1}}},
- {0x04c4, {1|U, {0x04c3}}},
- {0x04c6, {1|U, {0x04c5}}},
- {0x04c8, {1|U, {0x04c7}}},
- {0x04ca, {1|U, {0x04c9}}},
- {0x04cc, {1|U, {0x04cb}}},
- {0x04ce, {1|U, {0x04cd}}},
- {0x04cf, {1|U, {0x04c0}}},
- {0x04d1, {1|U, {0x04d0}}},
- {0x04d3, {1|U, {0x04d2}}},
- {0x04d5, {1|U, {0x04d4}}},
- {0x04d7, {1|U, {0x04d6}}},
- {0x04d9, {1|U, {0x04d8}}},
- {0x04db, {1|U, {0x04da}}},
- {0x04dd, {1|U, {0x04dc}}},
- {0x04df, {1|U, {0x04de}}},
- {0x04e1, {1|U, {0x04e0}}},
- {0x04e3, {1|U, {0x04e2}}},
- {0x04e5, {1|U, {0x04e4}}},
- {0x04e7, {1|U, {0x04e6}}},
- {0x04e9, {1|U, {0x04e8}}},
- {0x04eb, {1|U, {0x04ea}}},
- {0x04ed, {1|U, {0x04ec}}},
- {0x04ef, {1|U, {0x04ee}}},
- {0x04f1, {1|U, {0x04f0}}},
- {0x04f3, {1|U, {0x04f2}}},
- {0x04f5, {1|U, {0x04f4}}},
- {0x04f7, {1|U, {0x04f6}}},
- {0x04f9, {1|U, {0x04f8}}},
- {0x04fb, {1|U, {0x04fa}}},
- {0x04fd, {1|U, {0x04fc}}},
- {0x04ff, {1|U, {0x04fe}}},
- {0x0501, {1|U, {0x0500}}},
- {0x0503, {1|U, {0x0502}}},
- {0x0505, {1|U, {0x0504}}},
- {0x0507, {1|U, {0x0506}}},
- {0x0509, {1|U, {0x0508}}},
- {0x050b, {1|U, {0x050a}}},
- {0x050d, {1|U, {0x050c}}},
- {0x050f, {1|U, {0x050e}}},
- {0x0511, {1|U, {0x0510}}},
- {0x0513, {1|U, {0x0512}}},
- {0x0515, {1|U, {0x0514}}},
- {0x0517, {1|U, {0x0516}}},
- {0x0519, {1|U, {0x0518}}},
- {0x051b, {1|U, {0x051a}}},
- {0x051d, {1|U, {0x051c}}},
- {0x051f, {1|U, {0x051e}}},
- {0x0521, {1|U, {0x0520}}},
- {0x0523, {1|U, {0x0522}}},
- {0x0525, {1|U, {0x0524}}},
- {0x0527, {1|U, {0x0526}}},
- {0x0529, {1|U, {0x0528}}},
- {0x052b, {1|U, {0x052a}}},
- {0x052d, {1|U, {0x052c}}},
- {0x052f, {1|U, {0x052e}}},
- {0x0561, {1|U, {0x0531}}},
- {0x0562, {1|U, {0x0532}}},
- {0x0563, {1|U, {0x0533}}},
- {0x0564, {1|U, {0x0534}}},
- {0x0565, {1|U, {0x0535}}},
- {0x0566, {1|U, {0x0536}}},
- {0x0567, {1|U, {0x0537}}},
- {0x0568, {1|U, {0x0538}}},
- {0x0569, {1|U, {0x0539}}},
- {0x056a, {1|U, {0x053a}}},
- {0x056b, {1|U, {0x053b}}},
- {0x056c, {1|U, {0x053c}}},
- {0x056d, {1|U, {0x053d}}},
- {0x056e, {1|U, {0x053e}}},
- {0x056f, {1|U, {0x053f}}},
- {0x0570, {1|U, {0x0540}}},
- {0x0571, {1|U, {0x0541}}},
- {0x0572, {1|U, {0x0542}}},
- {0x0573, {1|U, {0x0543}}},
- {0x0574, {1|U, {0x0544}}},
- {0x0575, {1|U, {0x0545}}},
- {0x0576, {1|U, {0x0546}}},
- {0x0577, {1|U, {0x0547}}},
- {0x0578, {1|U, {0x0548}}},
- {0x0579, {1|U, {0x0549}}},
- {0x057a, {1|U, {0x054a}}},
- {0x057b, {1|U, {0x054b}}},
- {0x057c, {1|U, {0x054c}}},
- {0x057d, {1|U, {0x054d}}},
- {0x057e, {1|U, {0x054e}}},
- {0x057f, {1|U, {0x054f}}},
- {0x0580, {1|U, {0x0550}}},
- {0x0581, {1|U, {0x0551}}},
- {0x0582, {1|U, {0x0552}}},
- {0x0583, {1|U, {0x0553}}},
- {0x0584, {1|U, {0x0554}}},
- {0x0585, {1|U, {0x0555}}},
- {0x0586, {1|U, {0x0556}}},
- {0x10d0, {1|U|IT, {0x1c90}}},
- {0x10d1, {1|U|IT, {0x1c91}}},
- {0x10d2, {1|U|IT, {0x1c92}}},
- {0x10d3, {1|U|IT, {0x1c93}}},
- {0x10d4, {1|U|IT, {0x1c94}}},
- {0x10d5, {1|U|IT, {0x1c95}}},
- {0x10d6, {1|U|IT, {0x1c96}}},
- {0x10d7, {1|U|IT, {0x1c97}}},
- {0x10d8, {1|U|IT, {0x1c98}}},
- {0x10d9, {1|U|IT, {0x1c99}}},
- {0x10da, {1|U|IT, {0x1c9a}}},
- {0x10db, {1|U|IT, {0x1c9b}}},
- {0x10dc, {1|U|IT, {0x1c9c}}},
- {0x10dd, {1|U|IT, {0x1c9d}}},
- {0x10de, {1|U|IT, {0x1c9e}}},
- {0x10df, {1|U|IT, {0x1c9f}}},
- {0x10e0, {1|U|IT, {0x1ca0}}},
- {0x10e1, {1|U|IT, {0x1ca1}}},
- {0x10e2, {1|U|IT, {0x1ca2}}},
- {0x10e3, {1|U|IT, {0x1ca3}}},
- {0x10e4, {1|U|IT, {0x1ca4}}},
- {0x10e5, {1|U|IT, {0x1ca5}}},
- {0x10e6, {1|U|IT, {0x1ca6}}},
- {0x10e7, {1|U|IT, {0x1ca7}}},
- {0x10e8, {1|U|IT, {0x1ca8}}},
- {0x10e9, {1|U|IT, {0x1ca9}}},
- {0x10ea, {1|U|IT, {0x1caa}}},
- {0x10eb, {1|U|IT, {0x1cab}}},
- {0x10ec, {1|U|IT, {0x1cac}}},
- {0x10ed, {1|U|IT, {0x1cad}}},
- {0x10ee, {1|U|IT, {0x1cae}}},
- {0x10ef, {1|U|IT, {0x1caf}}},
- {0x10f0, {1|U|IT, {0x1cb0}}},
- {0x10f1, {1|U|IT, {0x1cb1}}},
- {0x10f2, {1|U|IT, {0x1cb2}}},
- {0x10f3, {1|U|IT, {0x1cb3}}},
- {0x10f4, {1|U|IT, {0x1cb4}}},
- {0x10f5, {1|U|IT, {0x1cb5}}},
- {0x10f6, {1|U|IT, {0x1cb6}}},
- {0x10f7, {1|U|IT, {0x1cb7}}},
- {0x10f8, {1|U|IT, {0x1cb8}}},
- {0x10f9, {1|U|IT, {0x1cb9}}},
- {0x10fa, {1|U|IT, {0x1cba}}},
- {0x10fd, {1|U|IT, {0x1cbd}}},
- {0x10fe, {1|U|IT, {0x1cbe}}},
- {0x10ff, {1|U|IT, {0x1cbf}}},
- {0x13a0, {1|D, {0xab70}}},
- {0x13a1, {1|D, {0xab71}}},
- {0x13a2, {1|D, {0xab72}}},
- {0x13a3, {1|D, {0xab73}}},
- {0x13a4, {1|D, {0xab74}}},
- {0x13a5, {1|D, {0xab75}}},
- {0x13a6, {1|D, {0xab76}}},
- {0x13a7, {1|D, {0xab77}}},
- {0x13a8, {1|D, {0xab78}}},
- {0x13a9, {1|D, {0xab79}}},
- {0x13aa, {1|D, {0xab7a}}},
- {0x13ab, {1|D, {0xab7b}}},
- {0x13ac, {1|D, {0xab7c}}},
- {0x13ad, {1|D, {0xab7d}}},
- {0x13ae, {1|D, {0xab7e}}},
- {0x13af, {1|D, {0xab7f}}},
- {0x13b0, {1|D, {0xab80}}},
- {0x13b1, {1|D, {0xab81}}},
- {0x13b2, {1|D, {0xab82}}},
- {0x13b3, {1|D, {0xab83}}},
- {0x13b4, {1|D, {0xab84}}},
- {0x13b5, {1|D, {0xab85}}},
- {0x13b6, {1|D, {0xab86}}},
- {0x13b7, {1|D, {0xab87}}},
- {0x13b8, {1|D, {0xab88}}},
- {0x13b9, {1|D, {0xab89}}},
- {0x13ba, {1|D, {0xab8a}}},
- {0x13bb, {1|D, {0xab8b}}},
- {0x13bc, {1|D, {0xab8c}}},
- {0x13bd, {1|D, {0xab8d}}},
- {0x13be, {1|D, {0xab8e}}},
- {0x13bf, {1|D, {0xab8f}}},
- {0x13c0, {1|D, {0xab90}}},
- {0x13c1, {1|D, {0xab91}}},
- {0x13c2, {1|D, {0xab92}}},
- {0x13c3, {1|D, {0xab93}}},
- {0x13c4, {1|D, {0xab94}}},
- {0x13c5, {1|D, {0xab95}}},
- {0x13c6, {1|D, {0xab96}}},
- {0x13c7, {1|D, {0xab97}}},
- {0x13c8, {1|D, {0xab98}}},
- {0x13c9, {1|D, {0xab99}}},
- {0x13ca, {1|D, {0xab9a}}},
- {0x13cb, {1|D, {0xab9b}}},
- {0x13cc, {1|D, {0xab9c}}},
- {0x13cd, {1|D, {0xab9d}}},
- {0x13ce, {1|D, {0xab9e}}},
- {0x13cf, {1|D, {0xab9f}}},
- {0x13d0, {1|D, {0xaba0}}},
- {0x13d1, {1|D, {0xaba1}}},
- {0x13d2, {1|D, {0xaba2}}},
- {0x13d3, {1|D, {0xaba3}}},
- {0x13d4, {1|D, {0xaba4}}},
- {0x13d5, {1|D, {0xaba5}}},
- {0x13d6, {1|D, {0xaba6}}},
- {0x13d7, {1|D, {0xaba7}}},
- {0x13d8, {1|D, {0xaba8}}},
- {0x13d9, {1|D, {0xaba9}}},
- {0x13da, {1|D, {0xabaa}}},
- {0x13db, {1|D, {0xabab}}},
- {0x13dc, {1|D, {0xabac}}},
- {0x13dd, {1|D, {0xabad}}},
- {0x13de, {1|D, {0xabae}}},
- {0x13df, {1|D, {0xabaf}}},
- {0x13e0, {1|D, {0xabb0}}},
- {0x13e1, {1|D, {0xabb1}}},
- {0x13e2, {1|D, {0xabb2}}},
- {0x13e3, {1|D, {0xabb3}}},
- {0x13e4, {1|D, {0xabb4}}},
- {0x13e5, {1|D, {0xabb5}}},
- {0x13e6, {1|D, {0xabb6}}},
- {0x13e7, {1|D, {0xabb7}}},
- {0x13e8, {1|D, {0xabb8}}},
- {0x13e9, {1|D, {0xabb9}}},
- {0x13ea, {1|D, {0xabba}}},
- {0x13eb, {1|D, {0xabbb}}},
- {0x13ec, {1|D, {0xabbc}}},
- {0x13ed, {1|D, {0xabbd}}},
- {0x13ee, {1|D, {0xabbe}}},
- {0x13ef, {1|D, {0xabbf}}},
- {0x13f0, {1|D, {0x13f8}}},
- {0x13f1, {1|D, {0x13f9}}},
- {0x13f2, {1|D, {0x13fa}}},
- {0x13f3, {1|D, {0x13fb}}},
- {0x13f4, {1|D, {0x13fc}}},
- {0x13f5, {1|D, {0x13fd}}},
- {0x1d79, {1|U, {0xa77d}}},
- {0x1d7d, {1|U, {0x2c63}}},
- {0x1d8e, {1|U, {0xa7c6}}},
- {0x1e01, {1|U, {0x1e00}}},
- {0x1e03, {1|U, {0x1e02}}},
- {0x1e05, {1|U, {0x1e04}}},
- {0x1e07, {1|U, {0x1e06}}},
- {0x1e09, {1|U, {0x1e08}}},
- {0x1e0b, {1|U, {0x1e0a}}},
- {0x1e0d, {1|U, {0x1e0c}}},
- {0x1e0f, {1|U, {0x1e0e}}},
- {0x1e11, {1|U, {0x1e10}}},
- {0x1e13, {1|U, {0x1e12}}},
- {0x1e15, {1|U, {0x1e14}}},
- {0x1e17, {1|U, {0x1e16}}},
- {0x1e19, {1|U, {0x1e18}}},
- {0x1e1b, {1|U, {0x1e1a}}},
- {0x1e1d, {1|U, {0x1e1c}}},
- {0x1e1f, {1|U, {0x1e1e}}},
- {0x1e21, {1|U, {0x1e20}}},
- {0x1e23, {1|U, {0x1e22}}},
- {0x1e25, {1|U, {0x1e24}}},
- {0x1e27, {1|U, {0x1e26}}},
- {0x1e29, {1|U, {0x1e28}}},
- {0x1e2b, {1|U, {0x1e2a}}},
- {0x1e2d, {1|U, {0x1e2c}}},
- {0x1e2f, {1|U, {0x1e2e}}},
- {0x1e31, {1|U, {0x1e30}}},
- {0x1e33, {1|U, {0x1e32}}},
- {0x1e35, {1|U, {0x1e34}}},
- {0x1e37, {1|U, {0x1e36}}},
- {0x1e39, {1|U, {0x1e38}}},
- {0x1e3b, {1|U, {0x1e3a}}},
- {0x1e3d, {1|U, {0x1e3c}}},
- {0x1e3f, {1|U, {0x1e3e}}},
- {0x1e41, {1|U, {0x1e40}}},
- {0x1e43, {1|U, {0x1e42}}},
- {0x1e45, {1|U, {0x1e44}}},
- {0x1e47, {1|U, {0x1e46}}},
- {0x1e49, {1|U, {0x1e48}}},
- {0x1e4b, {1|U, {0x1e4a}}},
- {0x1e4d, {1|U, {0x1e4c}}},
- {0x1e4f, {1|U, {0x1e4e}}},
- {0x1e51, {1|U, {0x1e50}}},
- {0x1e53, {1|U, {0x1e52}}},
- {0x1e55, {1|U, {0x1e54}}},
- {0x1e57, {1|U, {0x1e56}}},
- {0x1e59, {1|U, {0x1e58}}},
- {0x1e5b, {1|U, {0x1e5a}}},
- {0x1e5d, {1|U, {0x1e5c}}},
- {0x1e5f, {1|U, {0x1e5e}}},
- {0x1e61, {2|U, {0x1e60, 0x1e9b}}},
- {0x1e63, {1|U, {0x1e62}}},
- {0x1e65, {1|U, {0x1e64}}},
- {0x1e67, {1|U, {0x1e66}}},
- {0x1e69, {1|U, {0x1e68}}},
- {0x1e6b, {1|U, {0x1e6a}}},
- {0x1e6d, {1|U, {0x1e6c}}},
- {0x1e6f, {1|U, {0x1e6e}}},
- {0x1e71, {1|U, {0x1e70}}},
- {0x1e73, {1|U, {0x1e72}}},
- {0x1e75, {1|U, {0x1e74}}},
- {0x1e77, {1|U, {0x1e76}}},
- {0x1e79, {1|U, {0x1e78}}},
- {0x1e7b, {1|U, {0x1e7a}}},
- {0x1e7d, {1|U, {0x1e7c}}},
- {0x1e7f, {1|U, {0x1e7e}}},
- {0x1e81, {1|U, {0x1e80}}},
- {0x1e83, {1|U, {0x1e82}}},
- {0x1e85, {1|U, {0x1e84}}},
- {0x1e87, {1|U, {0x1e86}}},
- {0x1e89, {1|U, {0x1e88}}},
- {0x1e8b, {1|U, {0x1e8a}}},
- {0x1e8d, {1|U, {0x1e8c}}},
- {0x1e8f, {1|U, {0x1e8e}}},
- {0x1e91, {1|U, {0x1e90}}},
- {0x1e93, {1|U, {0x1e92}}},
- {0x1e95, {1|U, {0x1e94}}},
- {0x1ea1, {1|U, {0x1ea0}}},
- {0x1ea3, {1|U, {0x1ea2}}},
- {0x1ea5, {1|U, {0x1ea4}}},
- {0x1ea7, {1|U, {0x1ea6}}},
- {0x1ea9, {1|U, {0x1ea8}}},
- {0x1eab, {1|U, {0x1eaa}}},
- {0x1ead, {1|U, {0x1eac}}},
- {0x1eaf, {1|U, {0x1eae}}},
- {0x1eb1, {1|U, {0x1eb0}}},
- {0x1eb3, {1|U, {0x1eb2}}},
- {0x1eb5, {1|U, {0x1eb4}}},
- {0x1eb7, {1|U, {0x1eb6}}},
- {0x1eb9, {1|U, {0x1eb8}}},
- {0x1ebb, {1|U, {0x1eba}}},
- {0x1ebd, {1|U, {0x1ebc}}},
- {0x1ebf, {1|U, {0x1ebe}}},
- {0x1ec1, {1|U, {0x1ec0}}},
- {0x1ec3, {1|U, {0x1ec2}}},
- {0x1ec5, {1|U, {0x1ec4}}},
- {0x1ec7, {1|U, {0x1ec6}}},
- {0x1ec9, {1|U, {0x1ec8}}},
- {0x1ecb, {1|U, {0x1eca}}},
- {0x1ecd, {1|U, {0x1ecc}}},
- {0x1ecf, {1|U, {0x1ece}}},
- {0x1ed1, {1|U, {0x1ed0}}},
- {0x1ed3, {1|U, {0x1ed2}}},
- {0x1ed5, {1|U, {0x1ed4}}},
- {0x1ed7, {1|U, {0x1ed6}}},
- {0x1ed9, {1|U, {0x1ed8}}},
- {0x1edb, {1|U, {0x1eda}}},
- {0x1edd, {1|U, {0x1edc}}},
- {0x1edf, {1|U, {0x1ede}}},
- {0x1ee1, {1|U, {0x1ee0}}},
- {0x1ee3, {1|U, {0x1ee2}}},
- {0x1ee5, {1|U, {0x1ee4}}},
- {0x1ee7, {1|U, {0x1ee6}}},
- {0x1ee9, {1|U, {0x1ee8}}},
- {0x1eeb, {1|U, {0x1eea}}},
- {0x1eed, {1|U, {0x1eec}}},
- {0x1eef, {1|U, {0x1eee}}},
- {0x1ef1, {1|U, {0x1ef0}}},
- {0x1ef3, {1|U, {0x1ef2}}},
- {0x1ef5, {1|U, {0x1ef4}}},
- {0x1ef7, {1|U, {0x1ef6}}},
- {0x1ef9, {1|U, {0x1ef8}}},
- {0x1efb, {1|U, {0x1efa}}},
- {0x1efd, {1|U, {0x1efc}}},
- {0x1eff, {1|U, {0x1efe}}},
- {0x1f00, {1|U, {0x1f08}}},
- {0x1f01, {1|U, {0x1f09}}},
- {0x1f02, {1|U, {0x1f0a}}},
- {0x1f03, {1|U, {0x1f0b}}},
- {0x1f04, {1|U, {0x1f0c}}},
- {0x1f05, {1|U, {0x1f0d}}},
- {0x1f06, {1|U, {0x1f0e}}},
- {0x1f07, {1|U, {0x1f0f}}},
- {0x1f10, {1|U, {0x1f18}}},
- {0x1f11, {1|U, {0x1f19}}},
- {0x1f12, {1|U, {0x1f1a}}},
- {0x1f13, {1|U, {0x1f1b}}},
- {0x1f14, {1|U, {0x1f1c}}},
- {0x1f15, {1|U, {0x1f1d}}},
- {0x1f20, {1|U, {0x1f28}}},
- {0x1f21, {1|U, {0x1f29}}},
- {0x1f22, {1|U, {0x1f2a}}},
- {0x1f23, {1|U, {0x1f2b}}},
- {0x1f24, {1|U, {0x1f2c}}},
- {0x1f25, {1|U, {0x1f2d}}},
- {0x1f26, {1|U, {0x1f2e}}},
- {0x1f27, {1|U, {0x1f2f}}},
- {0x1f30, {1|U, {0x1f38}}},
- {0x1f31, {1|U, {0x1f39}}},
- {0x1f32, {1|U, {0x1f3a}}},
- {0x1f33, {1|U, {0x1f3b}}},
- {0x1f34, {1|U, {0x1f3c}}},
- {0x1f35, {1|U, {0x1f3d}}},
- {0x1f36, {1|U, {0x1f3e}}},
- {0x1f37, {1|U, {0x1f3f}}},
- {0x1f40, {1|U, {0x1f48}}},
- {0x1f41, {1|U, {0x1f49}}},
- {0x1f42, {1|U, {0x1f4a}}},
- {0x1f43, {1|U, {0x1f4b}}},
- {0x1f44, {1|U, {0x1f4c}}},
- {0x1f45, {1|U, {0x1f4d}}},
- {0x1f51, {1|U, {0x1f59}}},
- {0x1f53, {1|U, {0x1f5b}}},
- {0x1f55, {1|U, {0x1f5d}}},
- {0x1f57, {1|U, {0x1f5f}}},
- {0x1f60, {1|U, {0x1f68}}},
- {0x1f61, {1|U, {0x1f69}}},
- {0x1f62, {1|U, {0x1f6a}}},
- {0x1f63, {1|U, {0x1f6b}}},
- {0x1f64, {1|U, {0x1f6c}}},
- {0x1f65, {1|U, {0x1f6d}}},
- {0x1f66, {1|U, {0x1f6e}}},
- {0x1f67, {1|U, {0x1f6f}}},
- {0x1f70, {1|U, {0x1fba}}},
- {0x1f71, {1|U, {0x1fbb}}},
- {0x1f72, {1|U, {0x1fc8}}},
- {0x1f73, {1|U, {0x1fc9}}},
- {0x1f74, {1|U, {0x1fca}}},
- {0x1f75, {1|U, {0x1fcb}}},
- {0x1f76, {1|U, {0x1fda}}},
- {0x1f77, {1|U, {0x1fdb}}},
- {0x1f78, {1|U, {0x1ff8}}},
- {0x1f79, {1|U, {0x1ff9}}},
- {0x1f7a, {1|U, {0x1fea}}},
- {0x1f7b, {1|U, {0x1feb}}},
- {0x1f7c, {1|U, {0x1ffa}}},
- {0x1f7d, {1|U, {0x1ffb}}},
- {0x1fb0, {1|U, {0x1fb8}}},
- {0x1fb1, {1|U, {0x1fb9}}},
- {0x1fd0, {1|U, {0x1fd8}}},
- {0x1fd1, {1|U, {0x1fd9}}},
- {0x1fe0, {1|U, {0x1fe8}}},
- {0x1fe1, {1|U, {0x1fe9}}},
- {0x1fe5, {1|U, {0x1fec}}},
- {0x214e, {1|U, {0x2132}}},
- {0x2170, {1|U, {0x2160}}},
- {0x2171, {1|U, {0x2161}}},
- {0x2172, {1|U, {0x2162}}},
- {0x2173, {1|U, {0x2163}}},
- {0x2174, {1|U, {0x2164}}},
- {0x2175, {1|U, {0x2165}}},
- {0x2176, {1|U, {0x2166}}},
- {0x2177, {1|U, {0x2167}}},
- {0x2178, {1|U, {0x2168}}},
- {0x2179, {1|U, {0x2169}}},
- {0x217a, {1|U, {0x216a}}},
- {0x217b, {1|U, {0x216b}}},
- {0x217c, {1|U, {0x216c}}},
- {0x217d, {1|U, {0x216d}}},
- {0x217e, {1|U, {0x216e}}},
- {0x217f, {1|U, {0x216f}}},
- {0x2184, {1|U, {0x2183}}},
- {0x24d0, {1|U, {0x24b6}}},
- {0x24d1, {1|U, {0x24b7}}},
- {0x24d2, {1|U, {0x24b8}}},
- {0x24d3, {1|U, {0x24b9}}},
- {0x24d4, {1|U, {0x24ba}}},
- {0x24d5, {1|U, {0x24bb}}},
- {0x24d6, {1|U, {0x24bc}}},
- {0x24d7, {1|U, {0x24bd}}},
- {0x24d8, {1|U, {0x24be}}},
- {0x24d9, {1|U, {0x24bf}}},
- {0x24da, {1|U, {0x24c0}}},
- {0x24db, {1|U, {0x24c1}}},
- {0x24dc, {1|U, {0x24c2}}},
- {0x24dd, {1|U, {0x24c3}}},
- {0x24de, {1|U, {0x24c4}}},
- {0x24df, {1|U, {0x24c5}}},
- {0x24e0, {1|U, {0x24c6}}},
- {0x24e1, {1|U, {0x24c7}}},
- {0x24e2, {1|U, {0x24c8}}},
- {0x24e3, {1|U, {0x24c9}}},
- {0x24e4, {1|U, {0x24ca}}},
- {0x24e5, {1|U, {0x24cb}}},
- {0x24e6, {1|U, {0x24cc}}},
- {0x24e7, {1|U, {0x24cd}}},
- {0x24e8, {1|U, {0x24ce}}},
- {0x24e9, {1|U, {0x24cf}}},
- {0x2c30, {1|U, {0x2c00}}},
- {0x2c31, {1|U, {0x2c01}}},
- {0x2c32, {1|U, {0x2c02}}},
- {0x2c33, {1|U, {0x2c03}}},
- {0x2c34, {1|U, {0x2c04}}},
- {0x2c35, {1|U, {0x2c05}}},
- {0x2c36, {1|U, {0x2c06}}},
- {0x2c37, {1|U, {0x2c07}}},
- {0x2c38, {1|U, {0x2c08}}},
- {0x2c39, {1|U, {0x2c09}}},
- {0x2c3a, {1|U, {0x2c0a}}},
- {0x2c3b, {1|U, {0x2c0b}}},
- {0x2c3c, {1|U, {0x2c0c}}},
- {0x2c3d, {1|U, {0x2c0d}}},
- {0x2c3e, {1|U, {0x2c0e}}},
- {0x2c3f, {1|U, {0x2c0f}}},
- {0x2c40, {1|U, {0x2c10}}},
- {0x2c41, {1|U, {0x2c11}}},
- {0x2c42, {1|U, {0x2c12}}},
- {0x2c43, {1|U, {0x2c13}}},
- {0x2c44, {1|U, {0x2c14}}},
- {0x2c45, {1|U, {0x2c15}}},
- {0x2c46, {1|U, {0x2c16}}},
- {0x2c47, {1|U, {0x2c17}}},
- {0x2c48, {1|U, {0x2c18}}},
- {0x2c49, {1|U, {0x2c19}}},
- {0x2c4a, {1|U, {0x2c1a}}},
- {0x2c4b, {1|U, {0x2c1b}}},
- {0x2c4c, {1|U, {0x2c1c}}},
- {0x2c4d, {1|U, {0x2c1d}}},
- {0x2c4e, {1|U, {0x2c1e}}},
- {0x2c4f, {1|U, {0x2c1f}}},
- {0x2c50, {1|U, {0x2c20}}},
- {0x2c51, {1|U, {0x2c21}}},
- {0x2c52, {1|U, {0x2c22}}},
- {0x2c53, {1|U, {0x2c23}}},
- {0x2c54, {1|U, {0x2c24}}},
- {0x2c55, {1|U, {0x2c25}}},
- {0x2c56, {1|U, {0x2c26}}},
- {0x2c57, {1|U, {0x2c27}}},
- {0x2c58, {1|U, {0x2c28}}},
- {0x2c59, {1|U, {0x2c29}}},
- {0x2c5a, {1|U, {0x2c2a}}},
- {0x2c5b, {1|U, {0x2c2b}}},
- {0x2c5c, {1|U, {0x2c2c}}},
- {0x2c5d, {1|U, {0x2c2d}}},
- {0x2c5e, {1|U, {0x2c2e}}},
- {0x2c5f, {1|U, {0x2c2f}}},
- {0x2c61, {1|U, {0x2c60}}},
- {0x2c65, {1|U, {0x023a}}},
- {0x2c66, {1|U, {0x023e}}},
- {0x2c68, {1|U, {0x2c67}}},
- {0x2c6a, {1|U, {0x2c69}}},
- {0x2c6c, {1|U, {0x2c6b}}},
- {0x2c73, {1|U, {0x2c72}}},
- {0x2c76, {1|U, {0x2c75}}},
- {0x2c81, {1|U, {0x2c80}}},
- {0x2c83, {1|U, {0x2c82}}},
- {0x2c85, {1|U, {0x2c84}}},
- {0x2c87, {1|U, {0x2c86}}},
- {0x2c89, {1|U, {0x2c88}}},
- {0x2c8b, {1|U, {0x2c8a}}},
- {0x2c8d, {1|U, {0x2c8c}}},
- {0x2c8f, {1|U, {0x2c8e}}},
- {0x2c91, {1|U, {0x2c90}}},
- {0x2c93, {1|U, {0x2c92}}},
- {0x2c95, {1|U, {0x2c94}}},
- {0x2c97, {1|U, {0x2c96}}},
- {0x2c99, {1|U, {0x2c98}}},
- {0x2c9b, {1|U, {0x2c9a}}},
- {0x2c9d, {1|U, {0x2c9c}}},
- {0x2c9f, {1|U, {0x2c9e}}},
- {0x2ca1, {1|U, {0x2ca0}}},
- {0x2ca3, {1|U, {0x2ca2}}},
- {0x2ca5, {1|U, {0x2ca4}}},
- {0x2ca7, {1|U, {0x2ca6}}},
- {0x2ca9, {1|U, {0x2ca8}}},
- {0x2cab, {1|U, {0x2caa}}},
- {0x2cad, {1|U, {0x2cac}}},
- {0x2caf, {1|U, {0x2cae}}},
- {0x2cb1, {1|U, {0x2cb0}}},
- {0x2cb3, {1|U, {0x2cb2}}},
- {0x2cb5, {1|U, {0x2cb4}}},
- {0x2cb7, {1|U, {0x2cb6}}},
- {0x2cb9, {1|U, {0x2cb8}}},
- {0x2cbb, {1|U, {0x2cba}}},
- {0x2cbd, {1|U, {0x2cbc}}},
- {0x2cbf, {1|U, {0x2cbe}}},
- {0x2cc1, {1|U, {0x2cc0}}},
- {0x2cc3, {1|U, {0x2cc2}}},
- {0x2cc5, {1|U, {0x2cc4}}},
- {0x2cc7, {1|U, {0x2cc6}}},
- {0x2cc9, {1|U, {0x2cc8}}},
- {0x2ccb, {1|U, {0x2cca}}},
- {0x2ccd, {1|U, {0x2ccc}}},
- {0x2ccf, {1|U, {0x2cce}}},
- {0x2cd1, {1|U, {0x2cd0}}},
- {0x2cd3, {1|U, {0x2cd2}}},
- {0x2cd5, {1|U, {0x2cd4}}},
- {0x2cd7, {1|U, {0x2cd6}}},
- {0x2cd9, {1|U, {0x2cd8}}},
- {0x2cdb, {1|U, {0x2cda}}},
- {0x2cdd, {1|U, {0x2cdc}}},
- {0x2cdf, {1|U, {0x2cde}}},
- {0x2ce1, {1|U, {0x2ce0}}},
- {0x2ce3, {1|U, {0x2ce2}}},
- {0x2cec, {1|U, {0x2ceb}}},
- {0x2cee, {1|U, {0x2ced}}},
- {0x2cf3, {1|U, {0x2cf2}}},
- {0x2d00, {1|U, {0x10a0}}},
- {0x2d01, {1|U, {0x10a1}}},
- {0x2d02, {1|U, {0x10a2}}},
- {0x2d03, {1|U, {0x10a3}}},
- {0x2d04, {1|U, {0x10a4}}},
- {0x2d05, {1|U, {0x10a5}}},
- {0x2d06, {1|U, {0x10a6}}},
- {0x2d07, {1|U, {0x10a7}}},
- {0x2d08, {1|U, {0x10a8}}},
- {0x2d09, {1|U, {0x10a9}}},
- {0x2d0a, {1|U, {0x10aa}}},
- {0x2d0b, {1|U, {0x10ab}}},
- {0x2d0c, {1|U, {0x10ac}}},
- {0x2d0d, {1|U, {0x10ad}}},
- {0x2d0e, {1|U, {0x10ae}}},
- {0x2d0f, {1|U, {0x10af}}},
- {0x2d10, {1|U, {0x10b0}}},
- {0x2d11, {1|U, {0x10b1}}},
- {0x2d12, {1|U, {0x10b2}}},
- {0x2d13, {1|U, {0x10b3}}},
- {0x2d14, {1|U, {0x10b4}}},
- {0x2d15, {1|U, {0x10b5}}},
- {0x2d16, {1|U, {0x10b6}}},
- {0x2d17, {1|U, {0x10b7}}},
- {0x2d18, {1|U, {0x10b8}}},
- {0x2d19, {1|U, {0x10b9}}},
- {0x2d1a, {1|U, {0x10ba}}},
- {0x2d1b, {1|U, {0x10bb}}},
- {0x2d1c, {1|U, {0x10bc}}},
- {0x2d1d, {1|U, {0x10bd}}},
- {0x2d1e, {1|U, {0x10be}}},
- {0x2d1f, {1|U, {0x10bf}}},
- {0x2d20, {1|U, {0x10c0}}},
- {0x2d21, {1|U, {0x10c1}}},
- {0x2d22, {1|U, {0x10c2}}},
- {0x2d23, {1|U, {0x10c3}}},
- {0x2d24, {1|U, {0x10c4}}},
- {0x2d25, {1|U, {0x10c5}}},
- {0x2d27, {1|U, {0x10c7}}},
- {0x2d2d, {1|U, {0x10cd}}},
- {0xa641, {1|U, {0xa640}}},
- {0xa643, {1|U, {0xa642}}},
- {0xa645, {1|U, {0xa644}}},
- {0xa647, {1|U, {0xa646}}},
- {0xa649, {1|U, {0xa648}}},
- {0xa64b, {2|U, {0xa64a, 0x1c88}}},
- {0xa64d, {1|U, {0xa64c}}},
- {0xa64f, {1|U, {0xa64e}}},
- {0xa651, {1|U, {0xa650}}},
- {0xa653, {1|U, {0xa652}}},
- {0xa655, {1|U, {0xa654}}},
- {0xa657, {1|U, {0xa656}}},
- {0xa659, {1|U, {0xa658}}},
- {0xa65b, {1|U, {0xa65a}}},
- {0xa65d, {1|U, {0xa65c}}},
- {0xa65f, {1|U, {0xa65e}}},
- {0xa661, {1|U, {0xa660}}},
- {0xa663, {1|U, {0xa662}}},
- {0xa665, {1|U, {0xa664}}},
- {0xa667, {1|U, {0xa666}}},
- {0xa669, {1|U, {0xa668}}},
- {0xa66b, {1|U, {0xa66a}}},
- {0xa66d, {1|U, {0xa66c}}},
- {0xa681, {1|U, {0xa680}}},
- {0xa683, {1|U, {0xa682}}},
- {0xa685, {1|U, {0xa684}}},
- {0xa687, {1|U, {0xa686}}},
- {0xa689, {1|U, {0xa688}}},
- {0xa68b, {1|U, {0xa68a}}},
- {0xa68d, {1|U, {0xa68c}}},
- {0xa68f, {1|U, {0xa68e}}},
- {0xa691, {1|U, {0xa690}}},
- {0xa693, {1|U, {0xa692}}},
- {0xa695, {1|U, {0xa694}}},
- {0xa697, {1|U, {0xa696}}},
- {0xa699, {1|U, {0xa698}}},
- {0xa69b, {1|U, {0xa69a}}},
- {0xa723, {1|U, {0xa722}}},
- {0xa725, {1|U, {0xa724}}},
- {0xa727, {1|U, {0xa726}}},
- {0xa729, {1|U, {0xa728}}},
- {0xa72b, {1|U, {0xa72a}}},
- {0xa72d, {1|U, {0xa72c}}},
- {0xa72f, {1|U, {0xa72e}}},
- {0xa733, {1|U, {0xa732}}},
- {0xa735, {1|U, {0xa734}}},
- {0xa737, {1|U, {0xa736}}},
- {0xa739, {1|U, {0xa738}}},
- {0xa73b, {1|U, {0xa73a}}},
- {0xa73d, {1|U, {0xa73c}}},
- {0xa73f, {1|U, {0xa73e}}},
- {0xa741, {1|U, {0xa740}}},
- {0xa743, {1|U, {0xa742}}},
- {0xa745, {1|U, {0xa744}}},
- {0xa747, {1|U, {0xa746}}},
- {0xa749, {1|U, {0xa748}}},
- {0xa74b, {1|U, {0xa74a}}},
- {0xa74d, {1|U, {0xa74c}}},
- {0xa74f, {1|U, {0xa74e}}},
- {0xa751, {1|U, {0xa750}}},
- {0xa753, {1|U, {0xa752}}},
- {0xa755, {1|U, {0xa754}}},
- {0xa757, {1|U, {0xa756}}},
- {0xa759, {1|U, {0xa758}}},
- {0xa75b, {1|U, {0xa75a}}},
- {0xa75d, {1|U, {0xa75c}}},
- {0xa75f, {1|U, {0xa75e}}},
- {0xa761, {1|U, {0xa760}}},
- {0xa763, {1|U, {0xa762}}},
- {0xa765, {1|U, {0xa764}}},
- {0xa767, {1|U, {0xa766}}},
- {0xa769, {1|U, {0xa768}}},
- {0xa76b, {1|U, {0xa76a}}},
- {0xa76d, {1|U, {0xa76c}}},
- {0xa76f, {1|U, {0xa76e}}},
- {0xa77a, {1|U, {0xa779}}},
- {0xa77c, {1|U, {0xa77b}}},
- {0xa77f, {1|U, {0xa77e}}},
- {0xa781, {1|U, {0xa780}}},
- {0xa783, {1|U, {0xa782}}},
- {0xa785, {1|U, {0xa784}}},
- {0xa787, {1|U, {0xa786}}},
- {0xa78c, {1|U, {0xa78b}}},
- {0xa791, {1|U, {0xa790}}},
- {0xa793, {1|U, {0xa792}}},
- {0xa794, {1|U, {0xa7c4}}},
- {0xa797, {1|U, {0xa796}}},
- {0xa799, {1|U, {0xa798}}},
- {0xa79b, {1|U, {0xa79a}}},
- {0xa79d, {1|U, {0xa79c}}},
- {0xa79f, {1|U, {0xa79e}}},
- {0xa7a1, {1|U, {0xa7a0}}},
- {0xa7a3, {1|U, {0xa7a2}}},
- {0xa7a5, {1|U, {0xa7a4}}},
- {0xa7a7, {1|U, {0xa7a6}}},
- {0xa7a9, {1|U, {0xa7a8}}},
- {0xa7b5, {1|U, {0xa7b4}}},
- {0xa7b7, {1|U, {0xa7b6}}},
- {0xa7b9, {1|U, {0xa7b8}}},
- {0xa7bb, {1|U, {0xa7ba}}},
- {0xa7bd, {1|U, {0xa7bc}}},
- {0xa7bf, {1|U, {0xa7be}}},
- {0xa7c1, {1|U, {0xa7c0}}},
- {0xa7c3, {1|U, {0xa7c2}}},
- {0xa7c8, {1|U, {0xa7c7}}},
- {0xa7ca, {1|U, {0xa7c9}}},
- {0xa7d1, {1|U, {0xa7d0}}},
- {0xa7d7, {1|U, {0xa7d6}}},
- {0xa7d9, {1|U, {0xa7d8}}},
- {0xa7f6, {1|U, {0xa7f5}}},
- {0xab53, {1|U, {0xa7b3}}},
- {0xff41, {1|U, {0xff21}}},
- {0xff42, {1|U, {0xff22}}},
- {0xff43, {1|U, {0xff23}}},
- {0xff44, {1|U, {0xff24}}},
- {0xff45, {1|U, {0xff25}}},
- {0xff46, {1|U, {0xff26}}},
- {0xff47, {1|U, {0xff27}}},
- {0xff48, {1|U, {0xff28}}},
- {0xff49, {1|U, {0xff29}}},
- {0xff4a, {1|U, {0xff2a}}},
- {0xff4b, {1|U, {0xff2b}}},
- {0xff4c, {1|U, {0xff2c}}},
- {0xff4d, {1|U, {0xff2d}}},
- {0xff4e, {1|U, {0xff2e}}},
- {0xff4f, {1|U, {0xff2f}}},
- {0xff50, {1|U, {0xff30}}},
- {0xff51, {1|U, {0xff31}}},
- {0xff52, {1|U, {0xff32}}},
- {0xff53, {1|U, {0xff33}}},
- {0xff54, {1|U, {0xff34}}},
- {0xff55, {1|U, {0xff35}}},
- {0xff56, {1|U, {0xff36}}},
- {0xff57, {1|U, {0xff37}}},
- {0xff58, {1|U, {0xff38}}},
- {0xff59, {1|U, {0xff39}}},
- {0xff5a, {1|U, {0xff3a}}},
- {0x10428, {1|U, {0x10400}}},
- {0x10429, {1|U, {0x10401}}},
- {0x1042a, {1|U, {0x10402}}},
- {0x1042b, {1|U, {0x10403}}},
- {0x1042c, {1|U, {0x10404}}},
- {0x1042d, {1|U, {0x10405}}},
- {0x1042e, {1|U, {0x10406}}},
- {0x1042f, {1|U, {0x10407}}},
- {0x10430, {1|U, {0x10408}}},
- {0x10431, {1|U, {0x10409}}},
- {0x10432, {1|U, {0x1040a}}},
- {0x10433, {1|U, {0x1040b}}},
- {0x10434, {1|U, {0x1040c}}},
- {0x10435, {1|U, {0x1040d}}},
- {0x10436, {1|U, {0x1040e}}},
- {0x10437, {1|U, {0x1040f}}},
- {0x10438, {1|U, {0x10410}}},
- {0x10439, {1|U, {0x10411}}},
- {0x1043a, {1|U, {0x10412}}},
- {0x1043b, {1|U, {0x10413}}},
- {0x1043c, {1|U, {0x10414}}},
- {0x1043d, {1|U, {0x10415}}},
- {0x1043e, {1|U, {0x10416}}},
- {0x1043f, {1|U, {0x10417}}},
- {0x10440, {1|U, {0x10418}}},
- {0x10441, {1|U, {0x10419}}},
- {0x10442, {1|U, {0x1041a}}},
- {0x10443, {1|U, {0x1041b}}},
- {0x10444, {1|U, {0x1041c}}},
- {0x10445, {1|U, {0x1041d}}},
- {0x10446, {1|U, {0x1041e}}},
- {0x10447, {1|U, {0x1041f}}},
- {0x10448, {1|U, {0x10420}}},
- {0x10449, {1|U, {0x10421}}},
- {0x1044a, {1|U, {0x10422}}},
- {0x1044b, {1|U, {0x10423}}},
- {0x1044c, {1|U, {0x10424}}},
- {0x1044d, {1|U, {0x10425}}},
- {0x1044e, {1|U, {0x10426}}},
- {0x1044f, {1|U, {0x10427}}},
- {0x104d8, {1|U, {0x104b0}}},
- {0x104d9, {1|U, {0x104b1}}},
- {0x104da, {1|U, {0x104b2}}},
- {0x104db, {1|U, {0x104b3}}},
- {0x104dc, {1|U, {0x104b4}}},
- {0x104dd, {1|U, {0x104b5}}},
- {0x104de, {1|U, {0x104b6}}},
- {0x104df, {1|U, {0x104b7}}},
- {0x104e0, {1|U, {0x104b8}}},
- {0x104e1, {1|U, {0x104b9}}},
- {0x104e2, {1|U, {0x104ba}}},
- {0x104e3, {1|U, {0x104bb}}},
- {0x104e4, {1|U, {0x104bc}}},
- {0x104e5, {1|U, {0x104bd}}},
- {0x104e6, {1|U, {0x104be}}},
- {0x104e7, {1|U, {0x104bf}}},
- {0x104e8, {1|U, {0x104c0}}},
- {0x104e9, {1|U, {0x104c1}}},
- {0x104ea, {1|U, {0x104c2}}},
- {0x104eb, {1|U, {0x104c3}}},
- {0x104ec, {1|U, {0x104c4}}},
- {0x104ed, {1|U, {0x104c5}}},
- {0x104ee, {1|U, {0x104c6}}},
- {0x104ef, {1|U, {0x104c7}}},
- {0x104f0, {1|U, {0x104c8}}},
- {0x104f1, {1|U, {0x104c9}}},
- {0x104f2, {1|U, {0x104ca}}},
- {0x104f3, {1|U, {0x104cb}}},
- {0x104f4, {1|U, {0x104cc}}},
- {0x104f5, {1|U, {0x104cd}}},
- {0x104f6, {1|U, {0x104ce}}},
- {0x104f7, {1|U, {0x104cf}}},
- {0x104f8, {1|U, {0x104d0}}},
- {0x104f9, {1|U, {0x104d1}}},
- {0x104fa, {1|U, {0x104d2}}},
- {0x104fb, {1|U, {0x104d3}}},
- {0x10597, {1|U, {0x10570}}},
- {0x10598, {1|U, {0x10571}}},
- {0x10599, {1|U, {0x10572}}},
- {0x1059a, {1|U, {0x10573}}},
- {0x1059b, {1|U, {0x10574}}},
- {0x1059c, {1|U, {0x10575}}},
- {0x1059d, {1|U, {0x10576}}},
- {0x1059e, {1|U, {0x10577}}},
- {0x1059f, {1|U, {0x10578}}},
- {0x105a0, {1|U, {0x10579}}},
- {0x105a1, {1|U, {0x1057a}}},
- {0x105a3, {1|U, {0x1057c}}},
- {0x105a4, {1|U, {0x1057d}}},
- {0x105a5, {1|U, {0x1057e}}},
- {0x105a6, {1|U, {0x1057f}}},
- {0x105a7, {1|U, {0x10580}}},
- {0x105a8, {1|U, {0x10581}}},
- {0x105a9, {1|U, {0x10582}}},
- {0x105aa, {1|U, {0x10583}}},
- {0x105ab, {1|U, {0x10584}}},
- {0x105ac, {1|U, {0x10585}}},
- {0x105ad, {1|U, {0x10586}}},
- {0x105ae, {1|U, {0x10587}}},
- {0x105af, {1|U, {0x10588}}},
- {0x105b0, {1|U, {0x10589}}},
- {0x105b1, {1|U, {0x1058a}}},
- {0x105b3, {1|U, {0x1058c}}},
- {0x105b4, {1|U, {0x1058d}}},
- {0x105b5, {1|U, {0x1058e}}},
- {0x105b6, {1|U, {0x1058f}}},
- {0x105b7, {1|U, {0x10590}}},
- {0x105b8, {1|U, {0x10591}}},
- {0x105b9, {1|U, {0x10592}}},
- {0x105bb, {1|U, {0x10594}}},
- {0x105bc, {1|U, {0x10595}}},
- {0x10cc0, {1|U, {0x10c80}}},
- {0x10cc1, {1|U, {0x10c81}}},
- {0x10cc2, {1|U, {0x10c82}}},
- {0x10cc3, {1|U, {0x10c83}}},
- {0x10cc4, {1|U, {0x10c84}}},
- {0x10cc5, {1|U, {0x10c85}}},
- {0x10cc6, {1|U, {0x10c86}}},
- {0x10cc7, {1|U, {0x10c87}}},
- {0x10cc8, {1|U, {0x10c88}}},
- {0x10cc9, {1|U, {0x10c89}}},
- {0x10cca, {1|U, {0x10c8a}}},
- {0x10ccb, {1|U, {0x10c8b}}},
- {0x10ccc, {1|U, {0x10c8c}}},
- {0x10ccd, {1|U, {0x10c8d}}},
- {0x10cce, {1|U, {0x10c8e}}},
- {0x10ccf, {1|U, {0x10c8f}}},
- {0x10cd0, {1|U, {0x10c90}}},
- {0x10cd1, {1|U, {0x10c91}}},
- {0x10cd2, {1|U, {0x10c92}}},
- {0x10cd3, {1|U, {0x10c93}}},
- {0x10cd4, {1|U, {0x10c94}}},
- {0x10cd5, {1|U, {0x10c95}}},
- {0x10cd6, {1|U, {0x10c96}}},
- {0x10cd7, {1|U, {0x10c97}}},
- {0x10cd8, {1|U, {0x10c98}}},
- {0x10cd9, {1|U, {0x10c99}}},
- {0x10cda, {1|U, {0x10c9a}}},
- {0x10cdb, {1|U, {0x10c9b}}},
- {0x10cdc, {1|U, {0x10c9c}}},
- {0x10cdd, {1|U, {0x10c9d}}},
- {0x10cde, {1|U, {0x10c9e}}},
- {0x10cdf, {1|U, {0x10c9f}}},
- {0x10ce0, {1|U, {0x10ca0}}},
- {0x10ce1, {1|U, {0x10ca1}}},
- {0x10ce2, {1|U, {0x10ca2}}},
- {0x10ce3, {1|U, {0x10ca3}}},
- {0x10ce4, {1|U, {0x10ca4}}},
- {0x10ce5, {1|U, {0x10ca5}}},
- {0x10ce6, {1|U, {0x10ca6}}},
- {0x10ce7, {1|U, {0x10ca7}}},
- {0x10ce8, {1|U, {0x10ca8}}},
- {0x10ce9, {1|U, {0x10ca9}}},
- {0x10cea, {1|U, {0x10caa}}},
- {0x10ceb, {1|U, {0x10cab}}},
- {0x10cec, {1|U, {0x10cac}}},
- {0x10ced, {1|U, {0x10cad}}},
- {0x10cee, {1|U, {0x10cae}}},
- {0x10cef, {1|U, {0x10caf}}},
- {0x10cf0, {1|U, {0x10cb0}}},
- {0x10cf1, {1|U, {0x10cb1}}},
- {0x10cf2, {1|U, {0x10cb2}}},
- {0x118c0, {1|U, {0x118a0}}},
- {0x118c1, {1|U, {0x118a1}}},
- {0x118c2, {1|U, {0x118a2}}},
- {0x118c3, {1|U, {0x118a3}}},
- {0x118c4, {1|U, {0x118a4}}},
- {0x118c5, {1|U, {0x118a5}}},
- {0x118c6, {1|U, {0x118a6}}},
- {0x118c7, {1|U, {0x118a7}}},
- {0x118c8, {1|U, {0x118a8}}},
- {0x118c9, {1|U, {0x118a9}}},
- {0x118ca, {1|U, {0x118aa}}},
- {0x118cb, {1|U, {0x118ab}}},
- {0x118cc, {1|U, {0x118ac}}},
- {0x118cd, {1|U, {0x118ad}}},
- {0x118ce, {1|U, {0x118ae}}},
- {0x118cf, {1|U, {0x118af}}},
- {0x118d0, {1|U, {0x118b0}}},
- {0x118d1, {1|U, {0x118b1}}},
- {0x118d2, {1|U, {0x118b2}}},
- {0x118d3, {1|U, {0x118b3}}},
- {0x118d4, {1|U, {0x118b4}}},
- {0x118d5, {1|U, {0x118b5}}},
- {0x118d6, {1|U, {0x118b6}}},
- {0x118d7, {1|U, {0x118b7}}},
- {0x118d8, {1|U, {0x118b8}}},
- {0x118d9, {1|U, {0x118b9}}},
- {0x118da, {1|U, {0x118ba}}},
- {0x118db, {1|U, {0x118bb}}},
- {0x118dc, {1|U, {0x118bc}}},
- {0x118dd, {1|U, {0x118bd}}},
- {0x118de, {1|U, {0x118be}}},
- {0x118df, {1|U, {0x118bf}}},
- {0x16e60, {1|U, {0x16e40}}},
- {0x16e61, {1|U, {0x16e41}}},
- {0x16e62, {1|U, {0x16e42}}},
- {0x16e63, {1|U, {0x16e43}}},
- {0x16e64, {1|U, {0x16e44}}},
- {0x16e65, {1|U, {0x16e45}}},
- {0x16e66, {1|U, {0x16e46}}},
- {0x16e67, {1|U, {0x16e47}}},
- {0x16e68, {1|U, {0x16e48}}},
- {0x16e69, {1|U, {0x16e49}}},
- {0x16e6a, {1|U, {0x16e4a}}},
- {0x16e6b, {1|U, {0x16e4b}}},
- {0x16e6c, {1|U, {0x16e4c}}},
- {0x16e6d, {1|U, {0x16e4d}}},
- {0x16e6e, {1|U, {0x16e4e}}},
- {0x16e6f, {1|U, {0x16e4f}}},
- {0x16e70, {1|U, {0x16e50}}},
- {0x16e71, {1|U, {0x16e51}}},
- {0x16e72, {1|U, {0x16e52}}},
- {0x16e73, {1|U, {0x16e53}}},
- {0x16e74, {1|U, {0x16e54}}},
- {0x16e75, {1|U, {0x16e55}}},
- {0x16e76, {1|U, {0x16e56}}},
- {0x16e77, {1|U, {0x16e57}}},
- {0x16e78, {1|U, {0x16e58}}},
- {0x16e79, {1|U, {0x16e59}}},
- {0x16e7a, {1|U, {0x16e5a}}},
- {0x16e7b, {1|U, {0x16e5b}}},
- {0x16e7c, {1|U, {0x16e5c}}},
- {0x16e7d, {1|U, {0x16e5d}}},
- {0x16e7e, {1|U, {0x16e5e}}},
- {0x16e7f, {1|U, {0x16e5f}}},
- {0x1e922, {1|U, {0x1e900}}},
- {0x1e923, {1|U, {0x1e901}}},
- {0x1e924, {1|U, {0x1e902}}},
- {0x1e925, {1|U, {0x1e903}}},
- {0x1e926, {1|U, {0x1e904}}},
- {0x1e927, {1|U, {0x1e905}}},
- {0x1e928, {1|U, {0x1e906}}},
- {0x1e929, {1|U, {0x1e907}}},
- {0x1e92a, {1|U, {0x1e908}}},
- {0x1e92b, {1|U, {0x1e909}}},
- {0x1e92c, {1|U, {0x1e90a}}},
- {0x1e92d, {1|U, {0x1e90b}}},
- {0x1e92e, {1|U, {0x1e90c}}},
- {0x1e92f, {1|U, {0x1e90d}}},
- {0x1e930, {1|U, {0x1e90e}}},
- {0x1e931, {1|U, {0x1e90f}}},
- {0x1e932, {1|U, {0x1e910}}},
- {0x1e933, {1|U, {0x1e911}}},
- {0x1e934, {1|U, {0x1e912}}},
- {0x1e935, {1|U, {0x1e913}}},
- {0x1e936, {1|U, {0x1e914}}},
- {0x1e937, {1|U, {0x1e915}}},
- {0x1e938, {1|U, {0x1e916}}},
- {0x1e939, {1|U, {0x1e917}}},
- {0x1e93a, {1|U, {0x1e918}}},
- {0x1e93b, {1|U, {0x1e919}}},
- {0x1e93c, {1|U, {0x1e91a}}},
- {0x1e93d, {1|U, {0x1e91b}}},
- {0x1e93e, {1|U, {0x1e91c}}},
- {0x1e93f, {1|U, {0x1e91d}}},
- {0x1e940, {1|U, {0x1e91e}}},
- {0x1e941, {1|U, {0x1e91f}}},
- {0x1e942, {1|U, {0x1e920}}},
- {0x1e943, {1|U, {0x1e921}}},
-#define CaseUnfold_11_Locale (*(CaseUnfold_11_Type (*)[1])(CaseUnfold_11_Table+1395))
- {0x0069, {1|U, {0x0049}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_11_hash -N onigenc_unicode_CaseUnfold_11_lookup -n */
-
-/* maximum key range = 2771, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_11_hash(const OnigCodePoint code)
-{
- static const unsigned short asso_values[] =
- {
- 1, 2774, 2, 2, 4, 421, 9, 371, 231, 463,
- 37, 20, 2, 3, 419, 408, 2774, 2774, 2774, 2774,
- 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 2774, 112,
- 2774, 2774, 2774, 2774, 2774, 2774, 2774, 120, 2774, 2774,
- 2774, 2774, 2774, 1, 2774, 2774, 2774, 2774, 2774, 2774,
- 2774, 2774, 2774, 355, 2774, 2774, 2774, 2774, 2774, 2774,
- 2774, 2774, 10, 9, 7, 8, 244, 689, 226, 993,
- 561, 710, 104, 1429, 36, 1190, 28, 15, 114, 1768,
- 241, 1003, 87, 285, 26, 1399, 78, 1360, 7, 1455,
- 90, 1076, 113, 10, 724, 1460, 167, 1727, 155, 1040,
- 67, 754, 66, 705, 246, 886, 331, 1140, 430, 1251,
- 864, 768, 643, 1064, 1591, 865, 834, 720, 1700, 671,
- 1581, 657, 1794, 842, 1782, 1050, 1537, 1024, 1760, 814,
- 975, 440, 1187, 407, 1440, 951, 1384, 909, 1320, 555,
- 1567, 541, 1723, 525, 383, 501, 1179, 250, 1596, 342,
- 1575, 352, 1501, 194, 1559, 70, 1512, 85, 1509, 129,
- 467, 100, 1413, 1, 1485, 25, 1351, 35, 1088, 55,
- 1262, 45, 1277, 160, 1245, 317, 118, 220, 1300, 596,
- 1100, 373, 1632, 617, 1337, 1236, 1500, 1152, 148, 793,
- 1538, 979, 385, 1228
- };
- return asso_values[bits_of(code, 2)+66] + asso_values[bits_of(code, 1)+4] + asso_values[bits_of(code, 0)];
-}
-
-static const CodePointList3 *
-onigenc_unicode_CaseUnfold_11_lookup(const OnigCodePoint code)
-{
- enum
- {
- MIN_CODE_VALUE = 0x61,
- MAX_CODE_VALUE = 0x1e943,
- TOTAL_KEYWORDS = 1396,
- MIN_WORD_LENGTH = 3,
- MAX_WORD_LENGTH = 3,
- MIN_HASH_VALUE = 3,
- MAX_HASH_VALUE = 2773
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1,
- /*0x13e1*/ 589,
- /*0x0461*/ 340,
- /*0x04e1*/ 400,
- /*0x0061*/ 0,
- -1,
- /*0x104e1*/ 1184,
- /*0x1e61*/ 661,
- /*0x1ee1*/ 720,
- /*0x0161*/ 102,
- /*0x2ce1*/ 953,
- -1,
- /*0x049b*/ 365,
- -1, -1,
- /*0x24e1*/ 840,
- /*0x1e1b*/ 626,
- /*0x048b*/ 357,
- /*0x011b*/ 69,
- /*0x2c9b*/ 918,
- /*0x03e1*/ 280,
- /*0x1e0b*/ 618,
- /*0x1e8b*/ 682,
- /*0x010b*/ 61,
- /*0x2c8b*/ 910,
- /*0x13e3*/ 591,
- /*0x0463*/ 341,
- /*0x04e3*/ 401,
- /*0x0063*/ 2,
- -1,
- /*0x104e3*/ 1186,
- /*0x1e63*/ 662,
- /*0x1ee3*/ 721,
- /*0x0163*/ 103,
- /*0x2ce3*/ 954,
- /*0x13e5*/ 593,
- /*0x0465*/ 342,
- /*0x04e5*/ 402,
- /*0x0065*/ 4,
- /*0x24e3*/ 842,
- /*0x104e5*/ 1188,
- /*0x1e65*/ 663,
- /*0x1ee5*/ 722,
- /*0x0165*/ 104,
- /*0x03e3*/ 281,
- /*0x13e9*/ 597,
- /*0x0469*/ 344,
- /*0x04e9*/ 404,
- /*0x0069*/ 1395,
- /*0x24e5*/ 844,
- /*0x104e9*/ 1192,
- /*0x1e69*/ 665,
- /*0x1ee9*/ 724,
- /*0x0169*/ 106,
- /*0x03e5*/ 282,
- /*0x13e7*/ 595,
- /*0x0467*/ 343,
- /*0x04e7*/ 403,
- /*0x0067*/ 6,
- /*0x24e9*/ 848,
- /*0x104e7*/ 1190,
- /*0x1e67*/ 664,
- /*0x1ee7*/ 723,
- /*0x0167*/ 105,
- /*0x03e9*/ 284,
- -1,
- /*0x13a4*/ 528,
- /*0x13a2*/ 526,
- -1,
- /*0x24e7*/ 846,
- /*0x13d9*/ 581,
- /*0x0459*/ 333,
- /*0x04d9*/ 396,
- -1,
- /*0x03e7*/ 283,
- /*0x104d9*/ 1176,
- /*0x1e59*/ 657,
- /*0x1ed9*/ 716,
- /*0x0159*/ 98,
- /*0x2cd9*/ 949,
- -1, -1, -1, -1,
- /*0x24d9*/ 832,
- /*0x13db*/ 583,
- /*0x045b*/ 335,
- /*0x04db*/ 397,
- /*0xa761*/ 1065,
- /*0x03d9*/ 276,
- /*0x104db*/ 1178,
- /*0x1e5b*/ 658,
- /*0x1edb*/ 717,
- /*0x015b*/ 99,
- /*0x2cdb*/ 950,
- -1, -1, -1, -1,
- /*0x24db*/ 834,
- /*0x13df*/ 587,
- /*0x045f*/ 339,
- /*0x04df*/ 399,
- -1,
- /*0x03db*/ 277,
- /*0x104df*/ 1182,
- /*0x1e5f*/ 660,
- /*0x1edf*/ 719,
- /*0x015f*/ 101,
- /*0x2cdf*/ 952,
- -1, -1,
- /*0xa763*/ 1066,
- /*0x2c61*/ 897,
- /*0x24df*/ 838,
- /*0x10ce1*/ 1279,
- -1, -1,
- /*0x13ee*/ 602,
- /*0x03df*/ 279,
- /*0x10e1*/ 495,
- /*0x006e*/ 12,
- /*0xa765*/ 1067,
- /*0x104ee*/ 1197,
- -1, -1, -1,
- /*0x2cee*/ 956,
- -1,
- /*0x13dd*/ 585,
- /*0x045d*/ 337,
- /*0x04dd*/ 398,
- /*0xa769*/ 1069,
- -1,
- /*0x104dd*/ 1180,
- /*0x1e5d*/ 659,
- /*0x1edd*/ 718,
- /*0x015d*/ 100,
- /*0x2cdd*/ 951,
- /*0x10ce3*/ 1281,
- -1, -1,
- /*0xa767*/ 1068,
- /*0x24dd*/ 836,
- /*0x10e3*/ 497,
- -1, -1,
- /*0x2c65*/ 898,
- /*0x03dd*/ 278,
- /*0x10ce5*/ 1283,
- -1,
- /*0x007a*/ 24,
- -1,
- /*0x104fa*/ 1209,
- /*0x10e5*/ 499,
- /*0x13a0*/ 524,
- /*0x017a*/ 114,
- /*0xa759*/ 1061,
- -1,
- /*0x10ce9*/ 1287,
- /*0x13eb*/ 599,
- /*0x046b*/ 345,
- /*0x04eb*/ 405,
- /*0x006b*/ 9,
- /*0x10e9*/ 503,
- /*0x104eb*/ 1194,
- /*0x1e6b*/ 666,
- /*0x1eeb*/ 725,
- /*0x016b*/ 107,
- /*0x10ce7*/ 1285,
- -1, -1,
- /*0xa75b*/ 1062,
- -1,
- /*0x10e7*/ 501,
- -1, -1, -1, -1,
- /*0x03eb*/ 285,
- -1, -1,
- /*0x2c59*/ 890,
- -1,
- /*0x10cd9*/ 1271,
- -1, -1,
- /*0xa75f*/ 1064,
- -1,
- /*0x10d9*/ 487,
- -1, -1, -1, -1,
- /*0x13d7*/ 579,
- /*0x0457*/ 331,
- /*0x04d7*/ 395,
- /*0x2c5b*/ 892,
- -1,
- /*0x10cdb*/ 1273,
- /*0x1e57*/ 656,
- /*0x1ed7*/ 715,
- /*0x0157*/ 97,
- /*0x2cd7*/ 948,
- /*0x10db*/ 489,
- -1, -1, -1,
- /*0x24d7*/ 830,
- -1, -1, -1,
- /*0x2c5f*/ 896,
- /*0x03d7*/ 275,
- /*0x10cdf*/ 1277,
- -1,
- /*0xa75d*/ 1063,
- -1, -1,
- /*0x10df*/ 493,
- /*0x13ef*/ 603,
- /*0x046f*/ 347,
- /*0x04ef*/ 407,
- /*0x006f*/ 13,
- -1,
- /*0x104ef*/ 1198,
- /*0x1e6f*/ 668,
- /*0x1eef*/ 727,
- /*0x016f*/ 109,
- -1, -1,
- /*0x0261*/ 210,
- /*0x10cee*/ 1292,
- -1, -1,
- /*0xa77a*/ 1073,
- -1,
- /*0x10ee*/ 508,
- -1,
- /*0x03ef*/ 287,
- /*0x021b*/ 178,
- /*0x2c5d*/ 894,
- /*0xa661*/ 1014,
- /*0x10cdd*/ 1275,
- /*0x1f61*/ 777,
- /*0x020b*/ 170,
- /*0x13a6*/ 530,
- /*0xa76b*/ 1070,
- /*0x10dd*/ 491,
- /*0x1d8e*/ 612,
- /*0x13d1*/ 573,
- /*0x0451*/ 325,
- /*0x04d1*/ 392,
- -1, -1,
- /*0x0263*/ 211,
- /*0x1e51*/ 653,
- /*0x1ed1*/ 712,
- /*0x0151*/ 94,
- /*0x2cd1*/ 945,
- -1, -1, -1, -1,
- /*0x24d1*/ 824,
- /*0x0265*/ 212,
- /*0xa663*/ 1015,
- /*0x10fa*/ 520,
- /*0x1f63*/ 779,
- /*0x1f12*/ 746,
- -1, -1, -1, -1,
- /*0x10ceb*/ 1289,
- /*0x0269*/ 215,
- /*0xa665*/ 1016,
- -1,
- /*0x1f65*/ 781,
- /*0x10eb*/ 505,
- -1,
- /*0xa757*/ 1060,
- -1, -1, -1, -1,
- /*0xa669*/ 1018,
- /*0x0491*/ 360,
- -1, -1, -1,
- /*0x1e11*/ 621,
- /*0x1e91*/ 685,
- /*0x0111*/ 64,
- /*0x2c91*/ 913,
- /*0xa79b*/ 1086,
- /*0xa667*/ 1017,
- -1,
- /*0x1f67*/ 783,
- -1,
- /*0x0259*/ 206,
- -1, -1, -1, -1, -1,
- /*0x2c57*/ 888,
- /*0xa76f*/ 1072,
- /*0x10cd7*/ 1269,
- /*0x1f24*/ 754,
- /*0x1f22*/ 752,
- /*0xa659*/ 1010,
- -1,
- /*0x10d7*/ 485,
- -1,
- /*0x025b*/ 207,
- -1,
- /*0x13ed*/ 601,
- /*0x046d*/ 346,
- /*0x04ed*/ 406,
- /*0x006d*/ 11,
- /*0x1f14*/ 748,
- /*0x104ed*/ 1196,
- /*0x1e6d*/ 667,
- /*0x1eed*/ 726,
- /*0x016d*/ 108,
- /*0xa65b*/ 1011,
- -1, -1, -1,
- /*0x1f10*/ 744,
- /*0x13a8*/ 532,
- -1, -1,
- /*0x10cef*/ 1293,
- /*0x10428*/ 1135,
- /*0x03ed*/ 286,
- /*0xa751*/ 1057,
- -1,
- /*0x10ef*/ 509,
- -1,
- /*0xa65f*/ 1013,
- /*0x13d3*/ 575,
- /*0x0453*/ 327,
- /*0x04d3*/ 393,
- -1, -1,
- /*0x1f06*/ 742,
- /*0x1e53*/ 654,
- /*0x1ed3*/ 713,
- /*0x0153*/ 95,
- /*0x2cd3*/ 946,
- /*0x13d5*/ 577,
- /*0x0455*/ 329,
- /*0x04d5*/ 394,
- /*0xa7d9*/ 1106,
- /*0x24d3*/ 826,
- -1,
- /*0x1e55*/ 655,
- /*0x1ed5*/ 714,
- /*0x0155*/ 96,
- /*0x2cd5*/ 947,
- /*0x2c51*/ 882,
- /*0xa794*/ 1083,
- /*0x10cd1*/ 1263,
- -1,
- /*0x24d5*/ 828,
- -1, -1,
- /*0x10d1*/ 479,
- /*0xa65d*/ 1012,
- /*0x01e1*/ 151,
- -1,
- /*0x13f3*/ 607,
- /*0x0473*/ 349,
- /*0x04f3*/ 409,
- /*0x0073*/ 17,
- -1,
- /*0x104f3*/ 1202,
- /*0x1e73*/ 670,
- /*0x1ef3*/ 729,
- /*0x0173*/ 111,
- /*0x2cf3*/ 957,
- /*0x13ce*/ 570,
- /*0x044e*/ 322,
- /*0x04ce*/ 390,
- -1,
- /*0x1044e*/ 1173,
- -1, -1,
- /*0x026b*/ 217,
- /*0x1f7a*/ 794,
- /*0x03f3*/ 289,
- /*0x017e*/ 116,
- -1,
- /*0x01e3*/ 152,
- /*0x0192*/ 122,
- -1,
- /*0x1f20*/ 750,
- /*0xa78c*/ 1080,
- -1,
- /*0xa66b*/ 1019,
- /*0x03ce*/ 274,
- -1,
- /*0xa76d*/ 1071,
- /*0x01e5*/ 153,
- /*0x0188*/ 120,
- /*0x13c3*/ 559,
- /*0x0443*/ 311,
- /*0x0373*/ 237,
- -1,
- /*0x10443*/ 1162,
- -1,
- /*0x1e43*/ 646,
- /*0x1ec3*/ 705,
- /*0x01e9*/ 155,
- /*0x2cc3*/ 938,
- -1, -1,
- /*0x0561*/ 440,
- /*0x1059b*/ 1215,
- /*0x00e1*/ 26,
- -1, -1,
- /*0x0257*/ 205,
- /*0x01e7*/ 154,
- /*0x03c3*/ 263,
- /*0x118d9*/ 1322,
- /*0x051b*/ 429,
- /*0xa753*/ 1058,
- /*0x13aa*/ 534,
- /*0x10ced*/ 1291,
- /*0xab53*/ 1108,
- /*0x050b*/ 421,
- /*0x1042a*/ 1137,
- /*0xa657*/ 1009,
- /*0x10ed*/ 507,
- /*0x1f57*/ 775,
- -1,
- /*0xa755*/ 1059,
- /*0x13c1*/ 557,
- /*0x0441*/ 309,
- /*0x118db*/ 1324,
- /*0x0563*/ 442,
- /*0x10441*/ 1160,
- /*0x00e3*/ 28,
- /*0x1e41*/ 645,
- /*0x1ec1*/ 704,
- -1,
- /*0x2cc1*/ 937,
- /*0x026f*/ 219,
- -1, -1,
- /*0x0565*/ 444,
- /*0x2c53*/ 884,
- /*0x00e5*/ 30,
- /*0x10cd3*/ 1265,
- /*0x118df*/ 1328,
- -1,
- /*0x03c1*/ 262,
- -1,
- /*0x10d3*/ 481,
- -1,
- /*0x0569*/ 448,
- /*0x2c55*/ 886,
- /*0x00e9*/ 34,
- /*0x10cd5*/ 1267,
- /*0x13de*/ 586,
- /*0x045e*/ 338,
- /*0x1f02*/ 738,
- /*0x01df*/ 150,
- /*0x10d5*/ 483,
- /*0x104de*/ 1181,
- /*0x0567*/ 446,
- -1,
- /*0x00e7*/ 32,
- /*0x105a4*/ 1223,
- /*0x028b*/ 231,
- -1,
- /*0xa7d7*/ 1105,
- /*0x0251*/ 200,
- /*0x24de*/ 837,
- -1,
- /*0x019a*/ 125,
- /*0x018c*/ 121,
- /*0x2c73*/ 903,
- /*0x118dd*/ 1326,
- /*0x1f00*/ 736,
- /*0x0292*/ 233,
- /*0x1f26*/ 756,
- /*0x028a*/ 230,
- /*0xa651*/ 1006,
- /*0x10f3*/ 513,
- /*0x1f51*/ 772,
- /*0xa743*/ 1050,
- /*0x2c4e*/ 879,
- -1,
- /*0x10cce*/ 1260,
- /*0x0288*/ 228,
- /*0x01dd*/ 149,
- /*0x10598*/ 1212,
- /*0x13cf*/ 571,
- /*0x044f*/ 323,
- /*0x04cf*/ 391,
- /*0x10fe*/ 522,
- /*0x1044f*/ 1174,
- -1,
- /*0x1e4f*/ 652,
- /*0x1ecf*/ 711,
- /*0x014f*/ 93,
- /*0x2ccf*/ 944,
- /*0x0586*/ 477,
- -1,
- /*0x1e924*/ 1363,
- /*0x1e922*/ 1361,
- /*0x0211*/ 173,
- -1, -1, -1,
- /*0x2c43*/ 868,
- -1,
- /*0x10cc3*/ 1249,
- -1,
- /*0x1059a*/ 1214,
- -1,
- /*0x13cd*/ 569,
- /*0x044d*/ 321,
- /*0xa741*/ 1049,
- /*0x1f11*/ 745,
- /*0x1044d*/ 1172,
- /*0x01eb*/ 156,
- /*0x1e4d*/ 651,
- /*0x1ecd*/ 710,
- /*0x014d*/ 92,
- /*0x2ccd*/ 943,
- /*0xa7d1*/ 1104,
- /*0x056e*/ 453,
- /*0x019e*/ 126,
- /*0x00ee*/ 39,
- -1, -1,
- /*0x13cb*/ 567,
- /*0x044b*/ 319,
- -1,
- /*0x03cd*/ 273,
- /*0x1044b*/ 1170,
- -1,
- /*0x1e4b*/ 650,
- /*0x1ecb*/ 709,
- /*0x014b*/ 91,
- /*0x2ccb*/ 942,
- /*0x118d7*/ 1320,
- /*0x2c41*/ 866,
- -1,
- /*0x10cc1*/ 1247,
- /*0x13c9*/ 565,
- /*0x0449*/ 317,
- -1,
- /*0xa66d*/ 1020,
- /*0x10449*/ 1168,
- /*0x03cb*/ 271,
- /*0x1e49*/ 649,
- /*0x1ec9*/ 708,
- -1,
- /*0x2cc9*/ 941,
- /*0x105a0*/ 1220,
- /*0x057a*/ 465,
- -1,
- /*0x00fa*/ 50,
- -1,
- /*0xa791*/ 1081,
- -1,
- /*0x0253*/ 202,
- -1,
- /*0x03c9*/ 269,
- -1,
- /*0x028c*/ 232,
- /*0x1059e*/ 1218,
- /*0x056b*/ 450,
- /*0x2c5e*/ 895,
- /*0x00eb*/ 36,
- /*0x10cde*/ 1276,
- -1,
- /*0xa653*/ 1007,
- -1,
- /*0x1f53*/ 773,
- /*0x10de*/ 492,
- /*0x16e61*/ 1330,
- /*0xa74f*/ 1056,
- -1,
- /*0x01ef*/ 158,
- -1, -1,
- /*0xa655*/ 1008,
- -1,
- /*0x1f55*/ 774,
- /*0x13f1*/ 605,
- /*0x0471*/ 348,
- /*0x04f1*/ 408,
- /*0x0071*/ 15,
- -1,
- /*0x104f1*/ 1200,
- /*0x1e71*/ 669,
- /*0x1ef1*/ 728,
- /*0x0171*/ 110,
- -1, -1,
- /*0x118d1*/ 1314,
- -1, -1, -1,
- /*0x16e63*/ 1332,
- /*0xa74d*/ 1055,
- /*0x2c4f*/ 880,
- /*0x0180*/ 117,
- /*0x10ccf*/ 1261,
- /*0x1f73*/ 787,
- /*0x13f5*/ 609,
- /*0x0475*/ 350,
- /*0x04f5*/ 410,
- /*0x0075*/ 19,
- /*0x16e65*/ 1334,
- /*0x104f5*/ 1204,
- /*0x1e75*/ 671,
- /*0x1ef5*/ 730,
- /*0x0175*/ 112,
- -1, -1,
- /*0xa74b*/ 1054,
- /*0x029e*/ 235,
- -1,
- /*0x16e69*/ 1338,
- /*0x0371*/ 236,
- /*0x0582*/ 473,
- -1, -1, -1,
- /*0x2c4d*/ 878,
- /*0x056f*/ 454,
- /*0x10ccd*/ 1259,
- /*0x00ef*/ 40,
- /*0x16e67*/ 1336,
- /*0xa749*/ 1053,
- /*0x13ae*/ 538,
- -1, -1, -1,
- /*0x1042e*/ 1141,
- /*0xa643*/ 999,
- -1,
- /*0x1f43*/ 769,
- /*0x0580*/ 471,
- -1,
- /*0x2c4b*/ 876,
- -1,
- /*0x10ccb*/ 1257,
- /*0x105a6*/ 1225,
- /*0x13b7*/ 547,
- /*0x0437*/ 299,
- /*0x04b7*/ 379,
- -1,
- /*0x10437*/ 1150,
- /*0x03ae*/ 244,
- /*0x1e37*/ 640,
- /*0x1eb7*/ 699,
- /*0x0137*/ 82,
- /*0x2cb7*/ 932,
- /*0x2c49*/ 874,
- -1,
- /*0x10cc9*/ 1255,
- -1,
- /*0x13b5*/ 545,
- /*0x0435*/ 297,
- /*0x04b5*/ 378,
- -1,
- /*0x10435*/ 1148,
- /*0x03b7*/ 252,
- /*0x1e35*/ 639,
- /*0x1eb5*/ 698,
- /*0x0135*/ 81,
- /*0x2cb5*/ 931,
- /*0xa641*/ 998,
- -1,
- /*0x1f41*/ 767,
- -1, -1, -1,
- /*0x01ed*/ 157,
- /*0x0282*/ 225,
- /*0x1fe1*/ 803,
- /*0x03b5*/ 250,
- /*0x0481*/ 356,
- /*0xa7c3*/ 1101,
- /*0x1e926*/ 1365,
- -1,
- /*0x1e01*/ 613,
- /*0x1e81*/ 677,
- /*0x0101*/ 56,
- /*0x2c81*/ 905,
- /*0x118d3*/ 1316,
- -1,
- /*0x01a8*/ 130,
- -1,
- /*0x0511*/ 424,
- /*0x16e6e*/ 1343,
- /*0x13a5*/ 529,
- /*0x0280*/ 224,
- /*0x04a5*/ 370,
- /*0x217a*/ 816,
- /*0x118d5*/ 1318,
- /*0x10cf1*/ 1295,
- /*0x1e25*/ 631,
- /*0x1ea5*/ 690,
- /*0x0125*/ 74,
- /*0x2ca5*/ 923,
- /*0x10f1*/ 511,
- /*0x1e05*/ 615,
- /*0x1e85*/ 679,
- /*0x0105*/ 58,
- /*0x2c85*/ 907,
- /*0x13b3*/ 543,
- /*0x0433*/ 295,
- /*0x04b3*/ 377,
- /*0x1fe5*/ 804,
- /*0x10433*/ 1146,
- /*0xa7c1*/ 1100,
- /*0x1e33*/ 638,
- /*0x1eb3*/ 697,
- /*0x0133*/ 80,
- /*0x2cb3*/ 930,
- /*0x2d16*/ 980,
- /*0x024f*/ 198,
- -1,
- /*0x2d1b*/ 985,
- /*0x16e7a*/ 1355,
- /*0x056d*/ 452,
- /*0x10f5*/ 515,
- /*0x00ed*/ 38,
- /*0x2d0b*/ 969,
- /*0x03b3*/ 248,
- /*0x118ce*/ 1311,
- /*0x105a8*/ 1227,
- /*0xa64f*/ 1005,
- /*0x01f3*/ 159,
- /*0xa737*/ 1044,
- -1,
- /*0x16e6b*/ 1340,
- -1, -1,
- /*0x2d12*/ 976,
- -1,
- /*0x2d0a*/ 968,
- -1,
- /*0x01ce*/ 141,
- /*0x13a3*/ 527,
- /*0x024d*/ 197,
- /*0x04a3*/ 369,
- -1,
- /*0xa735*/ 1043,
- /*0x2d08*/ 966,
- /*0x1e23*/ 630,
- /*0x1ea3*/ 689,
- /*0x0123*/ 73,
- /*0x2ca3*/ 922,
- /*0x118c3*/ 1300,
- -1,
- /*0xa64d*/ 1004,
- -1,
- /*0x13ad*/ 537,
- /*0x2c37*/ 856,
- /*0x04ad*/ 374,
- /*0x024b*/ 196,
- /*0x1042d*/ 1140,
- -1,
- /*0x1e2d*/ 635,
- /*0x1ead*/ 694,
- /*0x012d*/ 78,
- /*0x2cad*/ 927,
- /*0x1e928*/ 1367,
- -1, -1, -1,
- /*0xa64b*/ 1003,
- /*0x2c35*/ 854,
- -1,
- /*0x0249*/ 195,
- -1,
- /*0x03ad*/ 243,
- -1,
- /*0x2d24*/ 994,
- /*0x2d22*/ 992,
- /*0x0573*/ 458,
- /*0xa725*/ 1036,
- /*0x00f3*/ 44,
- /*0x047b*/ 353,
- /*0x04fb*/ 413,
- /*0xa649*/ 1002,
- /*0x118c1*/ 1298,
- /*0x104fb*/ 1210,
- /*0x1e7b*/ 674,
- /*0x1efb*/ 733,
- /*0x2d14*/ 978,
- -1,
- /*0x057e*/ 469,
- /*0x1f04*/ 740,
- /*0x00fe*/ 54,
- /*0x16e6f*/ 1344,
- /*0xa733*/ 1042,
- -1, -1,
- /*0x2d10*/ 974,
- -1,
- /*0x03fb*/ 291,
- /*0x2d18*/ 982,
- /*0x13bf*/ 555,
- /*0x043f*/ 307,
- /*0x04bf*/ 383,
- -1,
- /*0x1043f*/ 1158,
- -1,
- /*0x1e3f*/ 644,
- /*0x1ebf*/ 703,
- -1,
- /*0x2cbf*/ 936,
- /*0x118de*/ 1327,
- -1,
- /*0x0271*/ 220,
- /*0x2d06*/ 964,
- -1,
- /*0x037b*/ 239,
- -1, -1,
- /*0x2c33*/ 852,
- /*0x03bf*/ 260,
- /*0x13b2*/ 542,
- /*0x0432*/ 294,
- /*0x2d1a*/ 984,
- /*0x2d0c*/ 970,
- /*0x10432*/ 1145,
- /*0x1f71*/ 785,
- /*0x105aa*/ 1229,
- /*0xa723*/ 1035,
- /*0x13b9*/ 549,
- /*0x0439*/ 301,
- /*0x04b9*/ 380,
- -1,
- /*0x10439*/ 1152,
- /*0x0275*/ 222,
- /*0x1e39*/ 641,
- /*0x1eb9*/ 700,
- -1,
- /*0x2cb9*/ 933,
- -1,
- /*0x03b2*/ 247,
- /*0x1e943*/ 1394,
- /*0xa72d*/ 1040,
- -1, -1,
- /*0x118cf*/ 1312,
- -1,
- /*0x1f75*/ 789,
- /*0x03b9*/ 254,
- -1, -1,
- /*0x13ac*/ 536,
- /*0x13b1*/ 541,
- /*0x0431*/ 293,
- /*0x04b1*/ 376,
- /*0x1042c*/ 1139,
- /*0x10431*/ 1144,
- -1,
- /*0x1e31*/ 637,
- /*0x1eb1*/ 696,
- -1,
- /*0x2cb1*/ 929,
- -1, -1,
- /*0x1e92a*/ 1369,
- /*0x2d20*/ 990,
- -1, -1, -1,
- /*0x118cd*/ 1310,
- /*0x03ac*/ 242,
- /*0x03b1*/ 246,
- -1,
- /*0x13a7*/ 531,
- /*0x1e941*/ 1392,
- /*0x04a7*/ 371,
- -1,
- /*0x2d1e*/ 988,
- -1,
- /*0x1e27*/ 632,
- /*0x1ea7*/ 691,
- /*0x0127*/ 75,
- /*0x2ca7*/ 924,
- -1, -1,
- /*0x118cb*/ 1308,
- -1,
- /*0x1f37*/ 765,
- /*0xa73f*/ 1048,
- -1,
- /*0x16e6d*/ 1342,
- -1, -1, -1, -1, -1,
- /*0x13c7*/ 563,
- /*0x0447*/ 315,
- -1,
- /*0x118c9*/ 1306,
- /*0x10447*/ 1166,
- /*0x1f35*/ 763,
- /*0x1e47*/ 648,
- /*0x1ec7*/ 707,
- -1,
- /*0x2cc7*/ 940,
- /*0x0201*/ 165,
- -1, -1, -1, -1, -1,
- /*0x01c9*/ 139,
- /*0x2c3f*/ 864,
- -1,
- /*0x03c7*/ 267,
- /*0xa739*/ 1045,
- -1, -1,
- /*0x1f01*/ 737,
- /*0x2173*/ 809,
- -1,
- /*0x0225*/ 182,
- -1, -1,
- /*0x1fd1*/ 801,
- -1,
- /*0x0205*/ 167,
- -1,
- /*0xa7b7*/ 1095,
- /*0x214e*/ 805,
- -1,
- /*0x217e*/ 820,
- /*0x2c32*/ 851,
- -1,
- /*0x1f25*/ 755,
- /*0x2d02*/ 960,
- /*0x0233*/ 189,
- /*0x13c5*/ 561,
- /*0x0445*/ 313,
- /*0x1f05*/ 741,
- /*0x2c39*/ 858,
- /*0x10445*/ 1164,
- /*0xa7b5*/ 1094,
- /*0x1e45*/ 647,
- /*0x1ec5*/ 706,
- /*0x16e73*/ 1348,
- /*0x2cc5*/ 939,
- -1, -1,
- /*0x1f33*/ 761,
- /*0x2d0e*/ 972,
- -1, -1,
- /*0x2d00*/ 958,
- /*0x0584*/ 475,
- -1,
- /*0x03c5*/ 265,
- /*0x16e7e*/ 1359,
- -1,
- /*0xa727*/ 1037,
- /*0xa781*/ 1076,
- /*0x13c0*/ 556,
- /*0x0440*/ 308,
- /*0x2c31*/ 850,
- -1,
- /*0x10440*/ 1159,
- /*0x047d*/ 354,
- /*0x04fd*/ 414,
- -1,
- /*0x0140*/ 86,
- /*0x0223*/ 181,
- /*0x1e7d*/ 675,
- /*0x1efd*/ 734,
- /*0x01f5*/ 160,
- /*0x1d7d*/ 611,
- -1,
- /*0xa7a5*/ 1091,
- -1, -1, -1,
- /*0x03c0*/ 261,
- /*0xa785*/ 1078,
- /*0xa747*/ 1052,
- /*0x1f23*/ 753,
- /*0x022d*/ 186,
- /*0x1e03*/ 614,
- /*0x1e83*/ 678,
- /*0x0103*/ 57,
- /*0x2c83*/ 906,
- -1, -1,
- /*0x048f*/ 359,
- -1, -1,
- /*0x2d11*/ 975,
- /*0x1e0f*/ 620,
- /*0x1e8f*/ 684,
- /*0x010f*/ 63,
- /*0x2c8f*/ 912,
- /*0xa69b*/ 1034,
- /*0x0571*/ 456,
- /*0x037d*/ 241,
- /*0x00f1*/ 42,
- -1,
- /*0xa68b*/ 1026,
- -1, -1,
- /*0x2c47*/ 872,
- -1,
- /*0x10cc7*/ 1253,
- /*0x13bd*/ 553,
- /*0x043d*/ 305,
- /*0x04bd*/ 382,
- -1,
- /*0x1043d*/ 1156,
- -1,
- /*0x1e3d*/ 643,
- /*0x1ebd*/ 702,
- -1,
- /*0x2cbd*/ 935,
- -1,
- /*0x0575*/ 460,
- /*0x1f7b*/ 795,
- /*0x00f5*/ 46,
- /*0xa745*/ 1051,
- /*0xa7a3*/ 1090,
- /*0x13a1*/ 525,
- -1,
- /*0x04a1*/ 368,
- /*0x03bd*/ 258,
- /*0x023f*/ 191,
- /*0xff59*/ 1133,
- /*0x1e21*/ 629,
- /*0x1ea1*/ 688,
- /*0x0121*/ 72,
- /*0x2ca1*/ 921,
- /*0x13bb*/ 551,
- /*0x043b*/ 303,
- /*0x04bb*/ 381,
- /*0x105ae*/ 1233,
- /*0x1043b*/ 1154,
- -1,
- /*0x1e3b*/ 642,
- /*0x1ebb*/ 701,
- -1,
- /*0x2cbb*/ 934,
- -1, -1, -1,
- /*0x2c45*/ 870,
- /*0x13af*/ 539,
- /*0x10cc5*/ 1251,
- /*0x04af*/ 375,
- /*0x105b7*/ 1241,
- /*0x1042f*/ 1142,
- /*0x03bb*/ 256,
- /*0x1e2f*/ 636,
- /*0x1eaf*/ 695,
- /*0x012f*/ 79,
- /*0x2caf*/ 928,
- -1,
- /*0x01a5*/ 129,
- -1,
- /*0x1f32*/ 760,
- /*0x0499*/ 364,
- -1,
- /*0x0185*/ 119,
- /*0x105b5*/ 1239,
- /*0x1e19*/ 625,
- /*0x03af*/ 245,
- /*0x0119*/ 68,
- /*0x2c99*/ 917,
- -1,
- /*0x2c40*/ 865,
- /*0x13e6*/ 594,
- /*0x10cc0*/ 1246,
- /*0x1e92e*/ 1373,
- /*0x0066*/ 5,
- -1,
- /*0x104e6*/ 1189,
- -1,
- /*0x0231*/ 188,
- /*0x0581*/ 472,
- -1,
- /*0x10fd*/ 521,
- /*0xa7bf*/ 1099,
- /*0x13f2*/ 606,
- -1,
- /*0x24e6*/ 845,
- /*0x0072*/ 16,
- /*0x1e937*/ 1382,
- /*0x104f2*/ 1201,
- -1,
- /*0x0501*/ 416,
- /*0x1f31*/ 759,
- -1, -1,
- /*0xa73d*/ 1047,
- -1, -1, -1,
- /*0x105a5*/ 1224,
- /*0x0227*/ 183,
- /*0x0585*/ 476,
- /*0x1e935*/ 1380,
- /*0x03f2*/ 288,
- -1, -1, -1,
- /*0x0525*/ 434,
- /*0x01a3*/ 128,
- -1, -1,
- /*0xa7b9*/ 1096,
- /*0x0505*/ 418,
- /*0x1f27*/ 757,
- /*0x105b3*/ 1237,
- -1, -1, -1,
- /*0x1059c*/ 1216,
- -1,
- /*0x2c3d*/ 862,
- /*0xa73b*/ 1046,
- /*0x01ad*/ 131,
- /*0x0247*/ 194,
- /*0x13a9*/ 533,
- -1,
- /*0x04a9*/ 372,
- -1,
- /*0x10429*/ 1136,
- -1,
- /*0x1e29*/ 633,
- /*0x1ea9*/ 692,
- /*0x0129*/ 76,
- /*0x2ca9*/ 925,
- /*0xa647*/ 1001,
- /*0xa72f*/ 1041,
- /*0x1e925*/ 1364,
- /*0x0479*/ 352,
- /*0x04f9*/ 412,
- /*0x0079*/ 23,
- /*0x2171*/ 807,
- /*0x104f9*/ 1208,
- /*0x1e79*/ 673,
- /*0x1ef9*/ 732,
- -1,
- /*0x1d79*/ 610,
- /*0x2c3b*/ 860,
- /*0x01fb*/ 162,
- /*0x105a3*/ 1222,
- -1, -1,
- /*0x1e933*/ 1378,
- -1,
- /*0xff57*/ 1131,
- -1,
- /*0xa7a7*/ 1092,
- /*0x0523*/ 433,
- -1, -1, -1, -1,
- /*0x2175*/ 811,
- /*0x105ad*/ 1232,
- /*0x13d0*/ 572,
- /*0x0450*/ 324,
- -1,
- /*0x16e71*/ 1346,
- -1,
- /*0x01bf*/ 137,
- -1,
- /*0x052d*/ 438,
- /*0x13c2*/ 558,
- /*0x0442*/ 310,
- /*0x04c2*/ 384,
- -1,
- /*0x10442*/ 1161,
- /*0xa645*/ 1000,
- /*0x24d0*/ 823,
- /*0x1f45*/ 771,
- /*0x0142*/ 87,
- /*0x1e09*/ 617,
- /*0x1e89*/ 681,
- /*0x0109*/ 60,
- /*0x2c89*/ 909,
- /*0x2c66*/ 899,
- /*0x1e923*/ 1362,
- /*0x10ce6*/ 1284,
- /*0x16e75*/ 1350,
- -1,
- /*0x0240*/ 192,
- -1,
- /*0x10e6*/ 500,
- -1,
- /*0x027d*/ 223,
- -1,
- /*0x057b*/ 466,
- /*0x01b9*/ 135,
- /*0x00fb*/ 51,
- /*0x10cf2*/ 1296,
- /*0x1e92d*/ 1372,
- -1, -1,
- /*0x1f40*/ 766,
- /*0x10f2*/ 512,
- -1, -1,
- /*0x1f7d*/ 797,
- /*0x0203*/ 166,
- -1,
- /*0xff51*/ 1125,
- -1,
- /*0xa729*/ 1038,
- -1,
- /*0x047f*/ 355,
- /*0x04ff*/ 415,
- -1, -1,
- /*0x020f*/ 172,
- /*0x1e7f*/ 676,
- /*0x1eff*/ 735,
- /*0x1f03*/ 739,
- /*0x0477*/ 351,
- /*0x04f7*/ 411,
- /*0x0077*/ 21,
- -1,
- /*0x104f7*/ 1206,
- /*0x1e77*/ 672,
- /*0x1ef7*/ 731,
- /*0x0177*/ 113,
- /*0x13ec*/ 600,
- -1, -1,
- /*0x006c*/ 10,
- -1,
- /*0x104ec*/ 1195,
- /*0x13ab*/ 535,
- /*0x105b9*/ 1243,
- /*0x04ab*/ 373,
- /*0x2cec*/ 955,
- /*0x1042b*/ 1138,
- -1,
- /*0x1e2b*/ 634,
- /*0x1eab*/ 693,
- /*0x012b*/ 77,
- /*0x2cab*/ 926,
- /*0x1e93f*/ 1390,
- /*0x13e8*/ 596,
- -1, -1,
- /*0x0068*/ 7,
- /*0x118c7*/ 1304,
- /*0x104e8*/ 1191,
- -1, -1,
- /*0x2184*/ 822,
- /*0x10f9*/ 519,
- /*0x0377*/ 238,
- -1,
- /*0x105ac*/ 1231,
- /*0x105b1*/ 1236,
- /*0x24e8*/ 847,
- /*0x13ea*/ 598,
- /*0xa783*/ 1077,
- -1,
- /*0x006a*/ 8,
- /*0x1e932*/ 1377,
- /*0x104ea*/ 1193,
- /*0x1f21*/ 751,
- /*0x2d04*/ 962,
- -1, -1, -1,
- /*0xa691*/ 1029,
- /*0x1e939*/ 1384,
- -1,
- /*0x2c50*/ 881,
- -1,
- /*0x10cd0*/ 1262,
- /*0x022f*/ 187,
- -1,
- /*0x105a7*/ 1226,
- -1,
- /*0x10d0*/ 478,
- /*0x2c42*/ 867,
- /*0x13f0*/ 604,
- /*0x10cc2*/ 1248,
- -1,
- /*0x0070*/ 14,
- /*0x0527*/ 435,
- /*0x104f0*/ 1199,
- /*0x0219*/ 177,
- -1,
- /*0x118c5*/ 1302,
- /*0xa7bd*/ 1098,
- -1,
- /*0x1e92c*/ 1371,
- /*0x1e931*/ 1376,
- -1, -1,
- /*0xa77f*/ 1075,
- -1,
- /*0xff53*/ 1127,
- /*0x0266*/ 213,
- -1,
- /*0x13c8*/ 564,
- /*0x0448*/ 316,
- /*0x04c8*/ 387,
- -1,
- /*0x10448*/ 1167,
- /*0xa7a1*/ 1089,
- -1,
- /*0xff55*/ 1129,
- /*0x0148*/ 90,
- -1,
- /*0x0272*/ 221,
- /*0x1f66*/ 782,
- /*0x118c0*/ 1297,
- /*0x1e927*/ 1366,
- -1,
- /*0xa7bb*/ 1097,
- -1, -1,
- /*0xa72b*/ 1039,
- /*0x03c8*/ 268,
- /*0x0076*/ 20,
- -1,
- /*0x104f6*/ 1205,
- /*0x1f72*/ 786,
- -1, -1, -1,
- /*0x10ff*/ 523,
- -1,
- /*0x01fd*/ 163,
- -1,
- /*0x13e4*/ 592,
- -1,
- /*0x217b*/ 817,
- /*0x0064*/ 3,
- /*0x10f7*/ 517,
- /*0x104e4*/ 1187,
- /*0x2c6c*/ 902,
- /*0xff4e*/ 1122,
- /*0x10cec*/ 1290,
- -1,
- /*0xa799*/ 1085,
- /*0x0495*/ 362,
- /*0x0183*/ 118,
- /*0x10ec*/ 506,
- /*0x24e4*/ 843,
- /*0x1e15*/ 623,
- /*0x1e95*/ 687,
- /*0x0115*/ 66,
- /*0x2c95*/ 915,
- /*0x0229*/ 184,
- -1, -1, -1,
- /*0x2c68*/ 900,
- -1,
- /*0x10ce8*/ 1286,
- -1, -1,
- /*0x16e7b*/ 1356,
- -1,
- /*0x10e8*/ 502,
- /*0xff43*/ 1111,
- -1,
- /*0x13c6*/ 562,
- /*0x0446*/ 314,
- /*0x04c6*/ 386,
- -1,
- /*0x10446*/ 1165,
- /*0x2c6a*/ 901,
- -1,
- /*0x10cea*/ 1288,
- /*0x0146*/ 89,
- -1,
- /*0x01bd*/ 136,
- /*0x1f79*/ 793,
- /*0x10ea*/ 504,
- /*0x057d*/ 468,
- -1,
- /*0x00fd*/ 53,
- /*0x0583*/ 474,
- /*0x0493*/ 361,
- -1,
- /*0x03c6*/ 266,
- -1,
- /*0x1e13*/ 622,
- /*0x1e93*/ 686,
- /*0x0113*/ 65,
- /*0x2c93*/ 914,
- /*0x0250*/ 199,
- /*0x01a1*/ 127,
- /*0x0503*/ 417,
- /*0x2d01*/ 959,
- /*0x13e0*/ 588,
- /*0x10cf0*/ 1294,
- /*0xff41*/ 1109,
- -1,
- /*0x0242*/ 193,
- /*0x104e0*/ 1183,
- /*0x10f0*/ 510,
- /*0x0209*/ 169,
- /*0x050f*/ 423,
- /*0x1e940*/ 1391,
- -1, -1,
- /*0xa7a9*/ 1093,
- -1,
- /*0x24e0*/ 839,
- /*0x2d25*/ 995,
- -1,
- /*0x1f42*/ 768,
- -1,
- /*0x2c48*/ 873,
- /*0x2d05*/ 963,
- /*0x10cc8*/ 1254,
- /*0x1e07*/ 616,
- /*0x1e87*/ 680,
- /*0x0107*/ 59,
- /*0x2c87*/ 908,
- -1,
- /*0x13c4*/ 560,
- /*0x0444*/ 312,
- /*0x04c4*/ 385,
- -1,
- /*0x10444*/ 1163,
- -1,
- /*0x0199*/ 124,
- /*0x2d1c*/ 986,
- /*0x0144*/ 88,
- /*0x2c76*/ 904,
- /*0x105a1*/ 1221,
- -1, -1, -1, -1,
- /*0x0283*/ 226,
- /*0x10f6*/ 516,
- /*0x0497*/ 363,
- /*0x0521*/ 432,
- /*0x03c4*/ 264,
- /*0x105bb*/ 1244,
- /*0x1e17*/ 624,
- /*0x049d*/ 366,
- /*0x0117*/ 67,
- /*0x2c97*/ 916,
- /*0x10ce4*/ 1282,
- /*0x1e1d*/ 627,
- -1,
- /*0x011d*/ 70,
- /*0x2c9d*/ 919,
- /*0x10e4*/ 498,
- /*0x1e93d*/ 1388,
- -1, -1,
- /*0x105af*/ 1234,
- /*0x026c*/ 218,
- /*0xff4f*/ 1123,
- /*0x2d23*/ 993,
- -1,
- /*0x1f77*/ 791,
- -1,
- /*0x022b*/ 185,
- /*0x052f*/ 439,
- -1, -1,
- /*0x13e2*/ 590,
- /*0x10599*/ 1213,
- -1,
- /*0x0062*/ 1,
- -1,
- /*0x104e2*/ 1185,
- /*0x2d2d*/ 997,
- /*0x0268*/ 214,
- -1,
- /*0x0519*/ 428,
- -1,
- /*0x2c46*/ 871,
- /*0x1e93b*/ 1386,
- /*0x10cc6*/ 1252,
- /*0x24e2*/ 841,
- /*0xff4d*/ 1121,
- /*0x13d6*/ 578,
- /*0x0456*/ 330,
- /*0x0078*/ 22,
- -1,
- /*0x104f8*/ 1207,
- /*0x0566*/ 445,
- /*0x026a*/ 216,
- /*0x00e6*/ 31,
- /*0x13dc*/ 584,
- /*0x045c*/ 336,
- /*0x1e92f*/ 1374,
- /*0x13da*/ 582,
- /*0x045a*/ 334,
- /*0x104dc*/ 1179,
- /*0x24d6*/ 829,
- /*0xff4b*/ 1119,
- /*0x104da*/ 1177,
- /*0x0572*/ 457,
- /*0x03f8*/ 290,
- /*0x00f2*/ 43,
- -1,
- /*0x01f9*/ 161,
- /*0x24dc*/ 835,
- -1, -1,
- /*0x24da*/ 833,
- /*0x10ce0*/ 1278,
- -1, -1,
- /*0xff49*/ 1117,
- -1,
- /*0x10e0*/ 494,
- -1, -1, -1,
- /*0x118d0*/ 1313,
- /*0x13bc*/ 552,
- /*0x043c*/ 304,
- /*0x217d*/ 819,
- -1,
- /*0x1043c*/ 1155,
- -1,
- /*0x1f70*/ 784,
- /*0x118c2*/ 1299,
- /*0x013c*/ 84,
- /*0x017c*/ 115,
- -1, -1,
- /*0x01d0*/ 142,
- /*0x105a9*/ 1228,
- -1,
- /*0x2c44*/ 869,
- /*0x1fb1*/ 799,
- /*0x10cc4*/ 1250,
- -1,
- /*0x03bc*/ 257,
- -1,
- /*0x0529*/ 436,
- /*0x13d8*/ 580,
- /*0x0458*/ 332,
- -1, -1, -1,
- /*0x104d8*/ 1175,
- /*0x16e7d*/ 1358,
- -1,
- /*0x13ca*/ 566,
- /*0x044a*/ 318,
- /*0x04ca*/ 388,
- /*0x0579*/ 464,
- /*0x1044a*/ 1169,
- /*0x00f9*/ 49,
- /*0x24d8*/ 831,
- /*0x037c*/ 240,
- /*0x13d4*/ 576,
- /*0x0454*/ 328,
- -1, -1, -1,
- /*0x1f76*/ 790,
- /*0x13b6*/ 546,
- /*0x0436*/ 298,
- -1, -1,
- /*0x10436*/ 1149,
- /*0x03ca*/ 270,
- /*0x1e929*/ 1368,
- -1,
- /*0x24d4*/ 827,
- /*0x0215*/ 175,
- /*0x13b0*/ 540,
- /*0x0430*/ 292,
- -1,
- /*0x1f64*/ 780,
- /*0x10430*/ 1143,
- /*0x13d2*/ 574,
- /*0x0452*/ 326,
- /*0x01ff*/ 164,
- /*0x10ce2*/ 1280,
- /*0x03b6*/ 251,
- -1, -1,
- /*0x1f15*/ 749,
- /*0x10e2*/ 496,
- /*0xa7c8*/ 1102,
- -1, -1,
- /*0x0509*/ 420,
- /*0x2d27*/ 996,
- /*0x24d2*/ 825,
- -1, -1,
- /*0x2c56*/ 887,
- -1,
- /*0x10cd6*/ 1268,
- -1, -1, -1,
- /*0x10f8*/ 518,
- /*0x10d6*/ 484,
- /*0x2c5c*/ 893,
- /*0xa7f6*/ 1107,
- /*0x10cdc*/ 1274,
- /*0x2c5a*/ 891,
- /*0xa77c*/ 1074,
- /*0x10cda*/ 1272,
- -1,
- /*0x10dc*/ 490,
- /*0x0213*/ 174,
- -1,
- /*0x10da*/ 488,
- /*0x13f4*/ 608,
- -1,
- /*0x1e942*/ 1393,
- /*0x0074*/ 18,
- -1,
- /*0x104f4*/ 1203,
- -1, -1, -1, -1,
- /*0x1f13*/ 747,
- /*0x0260*/ 209,
- -1, -1,
- /*0x057f*/ 470,
- -1,
- /*0x00ff*/ 55,
- /*0x2c3c*/ 861,
- -1, -1,
- /*0x0289*/ 229,
- -1,
- /*0x0577*/ 462,
- -1,
- /*0x1f60*/ 776,
- -1, -1,
- /*0x0207*/ 168,
- /*0x2172*/ 808,
- /*0x105ab*/ 1230,
- -1,
- /*0x056c*/ 451,
- -1,
- /*0x00ec*/ 37,
- -1, -1, -1,
- /*0x052b*/ 437,
- -1,
- /*0x2c58*/ 889,
- /*0x1f07*/ 743,
- /*0x10cd8*/ 1270,
- /*0x16e66*/ 1335,
- -1, -1,
- /*0x118c8*/ 1305,
- /*0x10d8*/ 486,
- /*0x2c4a*/ 875,
- /*0x0568*/ 447,
- /*0x10cca*/ 1256,
- /*0x00e8*/ 33,
- /*0x1f44*/ 770,
- /*0xa793*/ 1082,
- /*0x0217*/ 176,
- /*0x16e72*/ 1347,
- /*0x2c54*/ 885,
- -1,
- /*0x10cd4*/ 1266,
- /*0x021d*/ 179,
- -1,
- /*0xa681*/ 1021,
- /*0x2c36*/ 855,
- /*0x10d4*/ 482,
- /*0x056a*/ 449,
- -1,
- /*0x00ea*/ 35,
- /*0x1e92b*/ 1370,
- -1,
- /*0x13b4*/ 544,
- /*0x0434*/ 296,
- -1,
- /*0x2c30*/ 849,
- /*0x10434*/ 1147,
- -1, -1, -1,
- /*0x2c52*/ 883,
- -1,
- /*0x10cd2*/ 1264,
- -1,
- /*0x2179*/ 815,
- /*0xa685*/ 1023,
- /*0xa787*/ 1079,
- /*0x10d2*/ 480,
- /*0x2d03*/ 961,
- -1,
- /*0x0570*/ 455,
- /*0x03b4*/ 249,
- /*0x00f0*/ 41,
- -1, -1,
- /*0x13cc*/ 568,
- /*0x044c*/ 320,
- /*0x04cc*/ 389,
- /*0x2d0f*/ 973,
- /*0x1044c*/ 1171,
- /*0x1f62*/ 778,
- /*0x049f*/ 367,
- /*0x0195*/ 123,
- /*0x0256*/ 204,
- -1,
- /*0x1e1f*/ 628,
- -1,
- /*0x011f*/ 71,
- /*0x2c9f*/ 920,
- -1,
- /*0x16e79*/ 1354,
- /*0x025c*/ 208,
- /*0xa797*/ 1084,
- /*0x118c6*/ 1303,
- /*0x03cc*/ 272,
- /*0x1f78*/ 792,
- -1,
- /*0xa79d*/ 1087,
- -1, -1, -1, -1, -1,
- /*0x10f4*/ 514,
- -1, -1,
- /*0x01c6*/ 138,
- /*0x0576*/ 461,
- -1,
- /*0x00f6*/ 47,
- -1, -1,
- /*0x13be*/ 554,
- /*0x043e*/ 306,
- -1,
- /*0x2d21*/ 991,
- /*0x1043e*/ 1157,
- -1, -1,
- /*0x023c*/ 190,
- /*0x013e*/ 85,
- /*0x0564*/ 443,
- /*0x048d*/ 358,
- /*0x00e4*/ 29,
- -1, -1,
- /*0x1e0d*/ 619,
- /*0x1e8d*/ 683,
- /*0x010d*/ 62,
- /*0x2c8d*/ 911,
- /*0x0515*/ 426,
- /*0x03be*/ 259,
- -1,
- /*0x1f7c*/ 796,
- /*0x13ba*/ 550,
- /*0x043a*/ 302,
- -1, -1,
- /*0x1043a*/ 1153,
- -1,
- /*0x217f*/ 821,
- -1,
- /*0x013a*/ 83,
- -1, -1, -1,
- /*0x13b8*/ 548,
- /*0x0438*/ 300,
- /*0x2177*/ 813,
- /*0x118c4*/ 1301,
- /*0x10438*/ 1151,
- /*0x2d19*/ 983,
- -1,
- /*0x03ba*/ 255,
- -1, -1, -1,
- /*0x0254*/ 203,
- -1, -1, -1, -1, -1, -1,
- /*0x2c34*/ 853,
- /*0x03b8*/ 253,
- /*0x16e7f*/ 1360,
- -1, -1,
- /*0x0513*/ 425,
- -1, -1, -1, -1,
- /*0x16e77*/ 1352,
- -1,
- /*0x1f36*/ 764,
- -1,
- /*0x0252*/ 201,
- -1, -1, -1, -1,
- /*0x16e6c*/ 1341,
- -1,
- /*0x00e0*/ 25,
- /*0x1f30*/ 758,
- /*0x2c4c*/ 877,
- -1,
- /*0x10ccc*/ 1258,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x0507*/ 419,
- /*0x16e68*/ 1337,
- -1, -1, -1,
- /*0xa7ca*/ 1103,
- -1, -1, -1, -1, -1,
- /*0x118d6*/ 1319,
- -1,
- /*0x2170*/ 806,
- -1, -1,
- /*0x16e6a*/ 1339,
- -1,
- /*0x10597*/ 1211,
- /*0x118dc*/ 1325,
- /*0x1fd0*/ 800,
- -1,
- /*0x118da*/ 1323,
- /*0x1059d*/ 1217,
- /*0x01d6*/ 145,
- /*0x2c3e*/ 863,
- /*0x0517*/ 427,
- -1,
- /*0x1f74*/ 788,
- -1, -1,
- /*0x051d*/ 430,
- /*0x01dc*/ 148,
- -1, -1,
- /*0x01da*/ 147,
- -1,
- /*0xff47*/ 1115,
- -1,
- /*0x16e70*/ 1345,
- -1, -1, -1, -1,
- /*0x0287*/ 227,
- -1, -1,
- /*0x2c3a*/ 859,
- -1, -1,
- /*0x2176*/ 812,
- -1, -1, -1, -1, -1,
- /*0x0562*/ 441,
- -1,
- /*0x00e2*/ 27,
- /*0x2c38*/ 857,
- -1, -1, -1, -1, -1, -1,
- /*0x2d09*/ 967,
- -1, -1,
- /*0x118d8*/ 1321,
- -1,
- /*0x0578*/ 463,
- -1,
- /*0x00f8*/ 48,
- -1,
- /*0x029d*/ 234,
- /*0x16e76*/ 1351,
- /*0x118ca*/ 1307,
- -1,
- /*0xff45*/ 1113,
- -1, -1,
- /*0x01d8*/ 146,
- -1, -1,
- /*0x118d4*/ 1317,
- -1, -1, -1, -1,
- /*0x16e64*/ 1333,
- -1, -1, -1, -1, -1,
- /*0x1f34*/ 762,
- -1,
- /*0x01d4*/ 144,
- -1,
- /*0x105bc*/ 1245,
- -1, -1, -1,
- /*0x01b6*/ 134,
- -1,
- /*0x118d2*/ 1315,
- -1, -1,
- /*0x057c*/ 467,
- /*0x021f*/ 180,
- /*0x00fc*/ 52,
- -1, -1,
- /*0x01b0*/ 132,
- -1, -1, -1, -1,
- /*0x01d2*/ 143,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x1e93c*/ 1387,
- -1, -1, -1, -1, -1, -1,
- /*0x105b6*/ 1240,
- -1, -1, -1, -1,
- /*0xa683*/ 1022,
- -1,
- /*0x020d*/ 171,
- /*0x16e60*/ 1329,
- -1,
- /*0x105b0*/ 1235,
- -1, -1, -1, -1,
- /*0xa68f*/ 1028,
- -1, -1, -1, -1, -1,
- /*0xa79f*/ 1088,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x1e936*/ 1381,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x1e930*/ 1375,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x0574*/ 459,
- -1,
- /*0x00f4*/ 45,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x2178*/ 814,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x01b4*/ 133,
- /*0x16e62*/ 1331,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xa699*/ 1033,
- /*0x118cc*/ 1309,
- -1, -1,
- /*0x2d15*/ 979,
- -1, -1,
- /*0x16e78*/ 1353,
- -1, -1, -1, -1, -1, -1,
- /*0x01cc*/ 140,
- -1, -1, -1, -1,
- /*0x217c*/ 818,
- -1, -1,
- /*0x1fe0*/ 802,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0x105b4*/ 1238,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x2d13*/ 977,
- -1,
- /*0x16e7c*/ 1357,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x1059f*/ 1219,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x051f*/ 431,
- -1,
- /*0x1e934*/ 1379,
- -1, -1, -1, -1,
- /*0x2d07*/ 965,
- -1,
- /*0xff50*/ 1124,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xff42*/ 1110,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x2d17*/ 981,
- -1, -1, -1, -1,
- /*0x2d1d*/ 987,
- -1, -1,
- /*0x050d*/ 422,
- -1, -1, -1, -1, -1,
- /*0x2174*/ 810,
- /*0xa689*/ 1025,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x105b8*/ 1242,
- -1, -1,
- /*0x1e93e*/ 1389,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x16e74*/ 1349,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0x1e93a*/ 1385,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x1e938*/ 1383,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0x1fb0*/ 798,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff48*/ 1116,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0xff46*/ 1114,
- -1, -1, -1,
- /*0xa695*/ 1031,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xa693*/ 1030,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xff44*/ 1112,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xa687*/ 1024,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x2d1f*/ 989,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xa697*/ 1032,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0xff56*/ 1130,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1,
- /*0xff5a*/ 1134,
- -1, -1, -1,
- /*0x2d0d*/ 971,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xff58*/ 1132,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xff4a*/ 1118,
- -1, -1, -1, -1, -1, -1,
- -1,
- /*0xff54*/ 1128,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1,
- /*0xff52*/ 1126,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xff4c*/ 1120,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0xa68d*/ 1027
- };
-
- if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_11_hash(code);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code1_equal(code, CaseUnfold_11_Table[s].from))
- return &CaseUnfold_11_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_12_Type CaseUnfold_12_Table[] = {
-#define CaseUnfold_12 (*(CaseUnfold_12_Type (*)[58])(CaseUnfold_12_Table+0))
- {{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}, {2, {0x00df, 0x1e9e}}},
- {{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, {0x1f80, 0x1f88}}},
- {{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}}},
-#define CaseUnfold_12_Locale (*(CaseUnfold_12_Type (*)[1])(CaseUnfold_12_Table+58))
- {{0x0069, 0x0307}, {1, {0x0130}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3,4,5,6 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_12_hash -N onigenc_unicode_CaseUnfold_12_lookup -n */
-
-/* maximum key range = 71, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_12_hash(const OnigCodePoint *codes)
-{
- static const unsigned char asso_values[] =
- {
- 3, 58, 54, 57, 56, 16, 8, 2, 43, 82,
- 3, 1, 23, 82, 82, 82, 82, 82, 82, 4,
- 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
- 82, 82, 52, 51, 50, 49, 48, 47, 46, 45,
- 82, 82, 82, 82, 43, 82, 42, 82, 82, 13,
- 82, 82, 82, 82, 82, 11, 82, 1, 82, 82,
- 14, 82, 1, 82, 82, 31, 3, 82, 82, 30,
- 82, 82, 82, 10, 82, 82, 82, 82, 37, 82,
- 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
- 82, 82, 82, 82, 82, 82, 37, 15, 36, 35,
- 34, 17, 1, 33, 12, 4, 23, 23, 26, 21,
- 13, 82, 27, 82, 82, 2, 5, 82, 11, 16,
- 82, 15, 82, 82, 23, 82, 8, 82
- };
- return asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
-}
-
-static const CodePointList2 *
-onigenc_unicode_CaseUnfold_12_lookup(const OnigCodePoint *codes)
-{
- enum
- {
- MIN_CODE_VALUE = 0x61,
- MAX_CODE_VALUE = 0x1f7c,
- TOTAL_KEYWORDS = 59,
- MIN_WORD_LENGTH = 6,
- MAX_WORD_LENGTH = 6,
- MIN_HASH_VALUE = 11,
- MAX_HASH_VALUE = 81
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1,
- /*0x1f66,0x03b9*/ 53,
- /*0x1f07,0x03b9*/ 38,
- /*0x1f00,0x03b9*/ 31,
- /*0x0066,0x0066*/ 1,
- /*0x1f74,0x03b9*/ 56,
- /*0x0073,0x0073*/ 6,
- /*0x0066,0x0069*/ 2,
- /*0x1f06,0x03b9*/ 37,
- /*0x0073,0x0074*/ 7,
- /*0x03b9,0x0342*/ 18,
- /*0x03c9,0x03b9*/ 23,
- /*0x03b7,0x03b9*/ 17,
- /*0x0069,0x0307*/ 58,
- /*0x03b1,0x03b9*/ 15,
- /*0x1f61,0x03b9*/ 48,
- /*0x1f05,0x03b9*/ 36,
- /*0x1f65,0x03b9*/ 52,
- /*0x0574,0x0576*/ 29,
- /*0x03c9,0x0342*/ 22,
- /*0x03b7,0x0342*/ 16,
- /*0x057e,0x0576*/ 30,
- /*0x03b1,0x0342*/ 14,
- /*0x1f7c,0x03b9*/ 57,
- /*0x0574,0x0565*/ 26,
- /*0x0079,0x030a*/ 10,
- /*0x0077,0x030a*/ 9,
- /*0x1f70,0x03b9*/ 55,
- /*0x0574,0x056d*/ 28,
- /*0x0066,0x006c*/ 3,
- /*0x0574,0x056b*/ 27,
- /*0x0061,0x02be*/ 0,
- /*0x0068,0x0331*/ 4,
- /*0x1f67,0x03b9*/ 54,
- /*0x1f64,0x03b9*/ 51,
- /*0x1f63,0x03b9*/ 50,
- /*0x1f62,0x03b9*/ 49,
- /*0x1f60,0x03b9*/ 47,
- /*0x03ce,0x03b9*/ 24,
- /*0x03c5,0x0342*/ 21,
- /*0x03c5,0x0313*/ 20,
- /*0x03c1,0x0313*/ 19,
- /*0x02bc,0x006e*/ 11,
- /*0x03ae,0x03b9*/ 13,
- /*0x03ac,0x03b9*/ 12,
- /*0x1f27,0x03b9*/ 46,
- /*0x1f26,0x03b9*/ 45,
- /*0x1f25,0x03b9*/ 44,
- /*0x1f24,0x03b9*/ 43,
- /*0x1f23,0x03b9*/ 42,
- /*0x1f22,0x03b9*/ 41,
- /*0x1f21,0x03b9*/ 40,
- /*0x1f20,0x03b9*/ 39,
- /*0x006a,0x030c*/ 5,
- /*0x1f02,0x03b9*/ 33,
- /*0x0074,0x0308*/ 8,
- /*0x1f04,0x03b9*/ 35,
- /*0x1f03,0x03b9*/ 34,
- /*0x1f01,0x03b9*/ 32,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- /*0x0565,0x0582*/ 25
- };
-
- if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
- codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_12_hash(codes);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code2_equal(codes, CaseUnfold_12_Table[s].from))
- return &CaseUnfold_12_Table[s].to;
- }
- }
- return 0;
-}
-
-static const CaseUnfold_13_Type CaseUnfold_13_Table[] = {
-#define CaseUnfold_13 (*(CaseUnfold_13_Type (*)[14])(CaseUnfold_13_Table+0))
- {{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}}},
-};
-
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -k1,2,3,4,5,6,7,8,9 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_13_hash -N onigenc_unicode_CaseUnfold_13_lookup -n */
-
-/* maximum key range = 20, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-/*ARGSUSED*/
-static unsigned int
-onigenc_unicode_CaseUnfold_13_hash(const OnigCodePoint *codes)
-{
- static const unsigned char asso_values[] =
- {
- 7, 4, 47, 47, 47, 47, 1, 1, 2, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 1,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 11,
- 47, 47, 47, 47, 47, 10, 47, 2, 47, 47,
- 47, 47, 47, 47, 47, 47, 1, 47, 47, 1,
- 47, 47, 47, 9, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 1, 47, 47, 2, 47, 47, 1, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47
- };
- return asso_values[bits_at(codes, 8)] + asso_values[bits_at(codes, 7)] + asso_values[bits_at(codes, 6)] + asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
-}
-
-static const CodePointList2 *
-onigenc_unicode_CaseUnfold_13_lookup(const OnigCodePoint *codes)
-{
- enum
- {
- MIN_CODE_VALUE = 0x66,
- MAX_CODE_VALUE = 0x3c9,
- TOTAL_KEYWORDS = 14,
- MIN_WORD_LENGTH = 9,
- MAX_WORD_LENGTH = 9,
- MIN_HASH_VALUE = 27,
- MAX_HASH_VALUE = 46
- };
-
- static const short wordlist[] =
- {
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1,
- -1, -1, -1,
- /*0x03c5,0x0313,0x0342*/ 12,
- /*0x03c5,0x0308,0x0342*/ 9,
- /*0x03b9,0x0308,0x0342*/ 6,
- /*0x03c5,0x0313,0x0301*/ 11,
- /*0x03c5,0x0308,0x0301*/ 8,
- /*0x03b9,0x0308,0x0301*/ 5,
- /*0x03c5,0x0313,0x0300*/ 10,
- /*0x03c5,0x0308,0x0300*/ 7,
- /*0x03b9,0x0308,0x0300*/ 4,
- /*0x03c9,0x0342,0x03b9*/ 13,
- /*0x03b7,0x0342,0x03b9*/ 3,
- /*0x03b1,0x0342,0x03b9*/ 2,
- -1, -1, -1, -1, -1, -1,
- /*0x0066,0x0066,0x006c*/ 1,
- /*0x0066,0x0066,0x0069*/ 0
- };
-
- if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
- codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE &&
- codes[2] <= MAX_CODE_VALUE && codes[2] >= MIN_CODE_VALUE)
- {
- register unsigned int key = onigenc_unicode_CaseUnfold_13_hash(codes);
-
- if (key <= MAX_HASH_VALUE)
- {
- register short s = wordlist[key];
-
- if (s >= 0 && code3_equal(codes, CaseUnfold_13_Table[s].from))
- return &CaseUnfold_13_Table[s].to;
- }
- }
- return 0;
-}
-
-static const OnigCodePoint CaseMappingSpecials[] = {
- L(1)|0x039C,
- L(2)|0x0053, 0x0073, L(2)|0x0053, 0x0053,
- L(2)|0x02BC, 0x004E,
- L(1)|0x0053,
- L(1)|0x01C5,
- L(2)|0x0064, 0x017D, L(1)|0x01C4,
- L(1)|0x01C8,
- L(2)|0x006C, 0x004A, L(1)|0x01C7,
- L(1)|0x01CB,
- L(2)|0x006E, 0x004A, L(1)|0x01CA,
- L(2)|0x004A, 0x030C,
- L(1)|0x01F2,
- L(2)|0x0064, 0x005A, L(1)|0x01F1,
- L(1)|0x0399,
- L(3)|0x0399, 0x0308, 0x0301,
- L(3)|0x03A5, 0x0308, 0x0301,
- L(1)|0x03A3,
- L(1)|0x0392,
- L(1)|0x0398,
- L(1)|0x03A6,
- L(1)|0x03A0,
- L(1)|0x039A,
- L(1)|0x03A1,
- L(1)|0x0395,
- L(2)|0x0535, 0x0582, L(2)|0x0535, 0x0552,
- L(1)|0x0412,
- L(1)|0x0414,
- L(1)|0x041E,
- L(1)|0x0421,
- L(1)|0x0422,
- L(1)|0x0422,
- L(1)|0x042A,
- L(1)|0x0462,
- L(1)|0xA64A,
- L(2)|0x0048, 0x0331,
- L(2)|0x0054, 0x0308,
- L(2)|0x0057, 0x030A,
- L(2)|0x0059, 0x030A,
- L(2)|0x0041, 0x02BE,
- L(1)|0x1E60,
- L(1)|0x00DF,
- L(2)|0x03A5, 0x0313,
- L(3)|0x03A5, 0x0313, 0x0300,
- L(3)|0x03A5, 0x0313, 0x0301,
- L(3)|0x03A5, 0x0313, 0x0342,
- L(1)|0x1F88, L(2)|0x1F08, 0x0399,
- L(1)|0x1F89, L(2)|0x1F09, 0x0399,
- L(1)|0x1F8A, L(2)|0x1F0A, 0x0399,
- L(1)|0x1F8B, L(2)|0x1F0B, 0x0399,
- L(1)|0x1F8C, L(2)|0x1F0C, 0x0399,
- L(1)|0x1F8D, L(2)|0x1F0D, 0x0399,
- L(1)|0x1F8E, L(2)|0x1F0E, 0x0399,
- L(1)|0x1F8F, L(2)|0x1F0F, 0x0399,
- L(2)|0x1F00, 0x0399, L(1)|0x1F80, L(2)|0x1F08, 0x0399,
- L(2)|0x1F01, 0x0399, L(1)|0x1F81, L(2)|0x1F09, 0x0399,
- L(2)|0x1F02, 0x0399, L(1)|0x1F82, L(2)|0x1F0A, 0x0399,
- L(2)|0x1F03, 0x0399, L(1)|0x1F83, L(2)|0x1F0B, 0x0399,
- L(2)|0x1F04, 0x0399, L(1)|0x1F84, L(2)|0x1F0C, 0x0399,
- L(2)|0x1F05, 0x0399, L(1)|0x1F85, L(2)|0x1F0D, 0x0399,
- L(2)|0x1F06, 0x0399, L(1)|0x1F86, L(2)|0x1F0E, 0x0399,
- L(2)|0x1F07, 0x0399, L(1)|0x1F87, L(2)|0x1F0F, 0x0399,
- L(1)|0x1F98, L(2)|0x1F28, 0x0399,
- L(1)|0x1F99, L(2)|0x1F29, 0x0399,
- L(1)|0x1F9A, L(2)|0x1F2A, 0x0399,
- L(1)|0x1F9B, L(2)|0x1F2B, 0x0399,
- L(1)|0x1F9C, L(2)|0x1F2C, 0x0399,
- L(1)|0x1F9D, L(2)|0x1F2D, 0x0399,
- L(1)|0x1F9E, L(2)|0x1F2E, 0x0399,
- L(1)|0x1F9F, L(2)|0x1F2F, 0x0399,
- L(2)|0x1F20, 0x0399, L(1)|0x1F90, L(2)|0x1F28, 0x0399,
- L(2)|0x1F21, 0x0399, L(1)|0x1F91, L(2)|0x1F29, 0x0399,
- L(2)|0x1F22, 0x0399, L(1)|0x1F92, L(2)|0x1F2A, 0x0399,
- L(2)|0x1F23, 0x0399, L(1)|0x1F93, L(2)|0x1F2B, 0x0399,
- L(2)|0x1F24, 0x0399, L(1)|0x1F94, L(2)|0x1F2C, 0x0399,
- L(2)|0x1F25, 0x0399, L(1)|0x1F95, L(2)|0x1F2D, 0x0399,
- L(2)|0x1F26, 0x0399, L(1)|0x1F96, L(2)|0x1F2E, 0x0399,
- L(2)|0x1F27, 0x0399, L(1)|0x1F97, L(2)|0x1F2F, 0x0399,
- L(1)|0x1FA8, L(2)|0x1F68, 0x0399,
- L(1)|0x1FA9, L(2)|0x1F69, 0x0399,
- L(1)|0x1FAA, L(2)|0x1F6A, 0x0399,
- L(1)|0x1FAB, L(2)|0x1F6B, 0x0399,
- L(1)|0x1FAC, L(2)|0x1F6C, 0x0399,
- L(1)|0x1FAD, L(2)|0x1F6D, 0x0399,
- L(1)|0x1FAE, L(2)|0x1F6E, 0x0399,
- L(1)|0x1FAF, L(2)|0x1F6F, 0x0399,
- L(2)|0x1F60, 0x0399, L(1)|0x1FA0, L(2)|0x1F68, 0x0399,
- L(2)|0x1F61, 0x0399, L(1)|0x1FA1, L(2)|0x1F69, 0x0399,
- L(2)|0x1F62, 0x0399, L(1)|0x1FA2, L(2)|0x1F6A, 0x0399,
- L(2)|0x1F63, 0x0399, L(1)|0x1FA3, L(2)|0x1F6B, 0x0399,
- L(2)|0x1F64, 0x0399, L(1)|0x1FA4, L(2)|0x1F6C, 0x0399,
- L(2)|0x1F65, 0x0399, L(1)|0x1FA5, L(2)|0x1F6D, 0x0399,
- L(2)|0x1F66, 0x0399, L(1)|0x1FA6, L(2)|0x1F6E, 0x0399,
- L(2)|0x1F67, 0x0399, L(1)|0x1FA7, L(2)|0x1F6F, 0x0399,
- L(2)|0x1FBA, 0x0345, L(2)|0x1FBA, 0x0399,
- L(1)|0x1FBC, L(2)|0x0391, 0x0399,
- L(2)|0x0386, 0x0345, L(2)|0x0386, 0x0399,
- L(2)|0x0391, 0x0342,
- L(3)|0x0391, 0x0342, 0x0345, L(3)|0x0391, 0x0342, 0x0399,
- L(2)|0x03B1, 0x0399, L(1)|0x1FB3, L(2)|0x0391, 0x0399,
- L(1)|0x0399,
- L(2)|0x1FCA, 0x0345, L(2)|0x1FCA, 0x0399,
- L(1)|0x1FCC, L(2)|0x0397, 0x0399,
- L(2)|0x0389, 0x0345, L(2)|0x0389, 0x0399,
- L(2)|0x0397, 0x0342,
- L(3)|0x0397, 0x0342, 0x0345, L(3)|0x0397, 0x0342, 0x0399,
- L(2)|0x03B7, 0x0399, L(1)|0x1FC3, L(2)|0x0397, 0x0399,
- L(3)|0x0399, 0x0308, 0x0300,
- L(3)|0x0399, 0x0308, 0x0301,
- L(2)|0x0399, 0x0342,
- L(3)|0x0399, 0x0308, 0x0342,
- L(3)|0x03A5, 0x0308, 0x0300,
- L(3)|0x03A5, 0x0308, 0x0301,
- L(2)|0x03A1, 0x0313,
- L(2)|0x03A5, 0x0342,
- L(3)|0x03A5, 0x0308, 0x0342,
- L(2)|0x1FFA, 0x0345, L(2)|0x1FFA, 0x0399,
- L(1)|0x1FFC, L(2)|0x03A9, 0x0399,
- L(2)|0x038F, 0x0345, L(2)|0x038F, 0x0399,
- L(2)|0x03A9, 0x0342,
- L(3)|0x03A9, 0x0342, 0x0345, L(3)|0x03A9, 0x0342, 0x0399,
- L(2)|0x03C9, 0x0399, L(1)|0x1FF3, L(2)|0x03A9, 0x0399,
- L(2)|0x0046, 0x0066, L(2)|0x0046, 0x0046,
- L(2)|0x0046, 0x0069, L(2)|0x0046, 0x0049,
- L(2)|0x0046, 0x006C, L(2)|0x0046, 0x004C,
- L(3)|0x0046, 0x0066, 0x0069, L(3)|0x0046, 0x0046, 0x0049,
- L(3)|0x0046, 0x0066, 0x006C, L(3)|0x0046, 0x0046, 0x004C,
- L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
- L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
- L(2)|0x0544, 0x0576, L(2)|0x0544, 0x0546,
- L(2)|0x0544, 0x0565, L(2)|0x0544, 0x0535,
- L(2)|0x0544, 0x056B, L(2)|0x0544, 0x053B,
- L(2)|0x054E, 0x0576, L(2)|0x054E, 0x0546,
- L(2)|0x0544, 0x056D, L(2)|0x0544, 0x053D,
-};
diff --git a/enc/unicode/15.0.0/name2ctype.h b/enc/unicode/15.0.0/name2ctype.h
deleted file mode 100644
index a2c996423d..0000000000
--- a/enc/unicode/15.0.0/name2ctype.h
+++ /dev/null
@@ -1,45690 +0,0 @@
-/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p */
-#ifndef USE_UNICODE_PROPERTIES
-/* Computed positions: -k'1,3' */
-#else /* USE_UNICODE_PROPERTIES */
-/* Computed positions: -k'1-3,5-6,12,16,$' */
-#endif /* USE_UNICODE_PROPERTIES */
-
-#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-gperf@gnu.org>."
-#endif
-
-
-
-/* 'NEWLINE': [[:NEWLINE:]] */
-static const OnigCodePoint CR_NEWLINE[] = {
- 1,
- 0x000a, 0x000a,
-}; /* CR_NEWLINE */
-
-/* 'Alpha': [[:Alpha:]] */
-static const OnigCodePoint CR_Alpha[] = {
- 732,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0345, 0x0345,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0657,
- 0x0659, 0x065f,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06e1, 0x06e8,
- 0x06ed, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x073f,
- 0x074d, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0817,
- 0x081a, 0x082c,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c9,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x093b,
- 0x093d, 0x094c,
- 0x094e, 0x0950,
- 0x0955, 0x0963,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a70, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0af9, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d7a, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e46,
- 0x0e4d, 0x0e4d,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ecd, 0x0ecd,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f83,
- 0x0f88, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x1000, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x103f,
- 0x1050, 0x108f,
- 0x109a, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1713,
- 0x171f, 0x1733,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17c8,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1aa7, 0x1aa7,
- 0x1abf, 0x1ac0,
- 0x1acc, 0x1ace,
- 0x1b00, 0x1b33,
- 0x1b35, 0x1b43,
- 0x1b45, 0x1b4c,
- 0x1b80, 0x1ba9,
- 0x1bac, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1be7, 0x1bf1,
- 0x1c00, 0x1c36,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1de7, 0x1df4,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa674, 0xa67b,
- 0xa67f, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa805,
- 0xa807, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8ff,
- 0xa90a, 0xa92a,
- 0xa930, 0xa952,
- 0xa960, 0xa97c,
- 0xa980, 0xa9b2,
- 0xa9b4, 0xa9bf,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaabe,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabea,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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,
- 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,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10eac,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11045,
- 0x11071, 0x11075,
- 0x11080, 0x110b8,
- 0x110c2, 0x110c2,
- 0x110d0, 0x110e8,
- 0x11100, 0x11132,
- 0x11144, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11180, 0x111bf,
- 0x111c1, 0x111c4,
- 0x111ce, 0x111cf,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112e8,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11400, 0x11441,
- 0x11443, 0x11445,
- 0x11447, 0x1144a,
- 0x1145f, 0x11461,
- 0x11480, 0x114c1,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115b5,
- 0x115b8, 0x115be,
- 0x115d8, 0x115dd,
- 0x11600, 0x1163e,
- 0x11640, 0x11640,
- 0x11644, 0x11644,
- 0x11680, 0x116b5,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172a,
- 0x11740, 0x11746,
- 0x11800, 0x11838,
- 0x118a0, 0x118df,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x1193c,
- 0x1193f, 0x11942,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119df,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a32,
- 0x11a35, 0x11a3e,
- 0x11a50, 0x11a97,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d46, 0x11d47,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef6,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f40,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a70, 0x16abe,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9e, 0x1bc9e,
- 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, 0x1d7cb,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e4d0, 0x1e4eb,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e947, 0x1e947,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Alpha */
-
-/* 'Blank': [[:Blank:]] */
-static const OnigCodePoint CR_Blank[] = {
- 8,
- 0x0009, 0x0009,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Blank */
-
-/* 'Cntrl': [[:Cntrl:]] */
-static const OnigCodePoint CR_Cntrl[] = {
- 2,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
-}; /* CR_Cntrl */
-
-/* 'Digit': [[:Digit:]] */
-static const OnigCodePoint CR_Digit[] = {
- 64,
- 0x0030, 0x0039,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x07c0, 0x07c9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0be6, 0x0bef,
- 0x0c66, 0x0c6f,
- 0x0ce6, 0x0cef,
- 0x0d66, 0x0d6f,
- 0x0de6, 0x0def,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f29,
- 0x1040, 0x1049,
- 0x1090, 0x1099,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19d9,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1b50, 0x1b59,
- 0x1bb0, 0x1bb9,
- 0x1c40, 0x1c49,
- 0x1c50, 0x1c59,
- 0xa620, 0xa629,
- 0xa8d0, 0xa8d9,
- 0xa900, 0xa909,
- 0xa9d0, 0xa9d9,
- 0xa9f0, 0xa9f9,
- 0xaa50, 0xaa59,
- 0xabf0, 0xabf9,
- 0xff10, 0xff19,
- 0x104a0, 0x104a9,
- 0x10d30, 0x10d39,
- 0x11066, 0x1106f,
- 0x110f0, 0x110f9,
- 0x11136, 0x1113f,
- 0x111d0, 0x111d9,
- 0x112f0, 0x112f9,
- 0x11450, 0x11459,
- 0x114d0, 0x114d9,
- 0x11650, 0x11659,
- 0x116c0, 0x116c9,
- 0x11730, 0x11739,
- 0x118e0, 0x118e9,
- 0x11950, 0x11959,
- 0x11c50, 0x11c59,
- 0x11d50, 0x11d59,
- 0x11da0, 0x11da9,
- 0x11f50, 0x11f59,
- 0x16a60, 0x16a69,
- 0x16ac0, 0x16ac9,
- 0x16b50, 0x16b59,
- 0x1d7ce, 0x1d7ff,
- 0x1e140, 0x1e149,
- 0x1e2f0, 0x1e2f9,
- 0x1e4f0, 0x1e4f9,
- 0x1e950, 0x1e959,
- 0x1fbf0, 0x1fbf9,
-}; /* CR_Digit */
-
-/* 'Graph': [[:Graph:]] */
-static const OnigCodePoint CR_Graph[] = {
- 712,
- 0x0021, 0x007e,
- 0x00a1, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x167f,
- 0x1681, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3001, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xe000, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfdcf,
- 0xfdf0, 0xfe19,
- 0xfe20, 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, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10f70, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x110c2,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11b00, 0x11b09,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1ea,
- 0x1d200, 0x1d245,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Graph */
-
-/* 'Lower': [[:Lower:]] */
-static const OnigCodePoint CR_Lower[] = {
- 671,
- 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,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0293,
- 0x0295, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037a, 0x037d,
- 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, 0x04cf,
- 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,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0560, 0x0588,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d00, 0x1dbf,
- 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, 0x1e9d,
- 0x1e9f, 0x1e9f,
- 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,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 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,
- 0x2090, 0x209c,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5f,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c71, 0x2c71,
- 0x2c73, 0x2c74,
- 0x2c76, 0x2c7d,
- 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,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69d,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa731,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa778,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa78e, 0xa78e,
- 0xa791, 0xa791,
- 0xa793, 0xa795,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7af, 0xa7af,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c1, 0xa7c1,
- 0xa7c3, 0xa7c3,
- 0xa7c8, 0xa7c8,
- 0xa7ca, 0xa7ca,
- 0xa7d1, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d5,
- 0xa7d7, 0xa7d7,
- 0xa7d9, 0xa7d9,
- 0xa7f2, 0xa7f4,
- 0xa7f6, 0xa7f6,
- 0xa7f8, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10780, 0x10780,
- 0x10783, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 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,
- 0x1d7cb, 0x1d7cb,
- 0x1df00, 0x1df09,
- 0x1df0b, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e922, 0x1e943,
-}; /* CR_Lower */
-
-/* 'Print': [[:Print:]] */
-static const OnigCodePoint CR_Print[] = {
- 709,
- 0x0020, 0x007e,
- 0x00a0, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 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, 0x2027,
- 0x202a, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xe000, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfdcf,
- 0xfdf0, 0xfe19,
- 0xfe20, 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, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10f70, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x110c2,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11b00, 0x11b09,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1ea,
- 0x1d200, 0x1d245,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Print */
-
-/* 'XPosixPunct': [[:Punct:]] */
-static const OnigCodePoint CR_XPosixPunct[] = {
- 186,
- 0x0021, 0x002f,
- 0x003a, 0x0040,
- 0x005b, 0x0060,
- 0x007b, 0x007e,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00ab, 0x00ab,
- 0x00b6, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061d, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x1400, 0x1400,
- 0x166e, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1b7d, 0x1b7e,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2308, 0x230b,
- 0x2329, 0x232a,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e2e,
- 0x2e30, 0x2e4f,
- 0x2e52, 0x2e5d,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 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, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10ead, 0x10ead,
- 0x10f55, 0x10f59,
- 0x10f86, 0x10f89,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145a, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x116b9, 0x116b9,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x11944, 0x11946,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11b00, 0x11b09,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11f43, 0x11f4f,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x12ff1, 0x12ff2,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_XPosixPunct */
-
-/* 'Space': [[:Space:]] */
-static const OnigCodePoint CR_Space[] = {
- 10,
- 0x0009, 0x000d,
- 0x0020, 0x0020,
- 0x0085, 0x0085,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x2028, 0x2029,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Space */
-
-/* 'Upper': [[:Upper:]] */
-static const OnigCodePoint CR_Upper[] = {
- 651,
- 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,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 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,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 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,
- 0x1e9e, 0x1e9e,
- 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,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 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, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2f,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 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,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c0, 0xa7c0,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c7,
- 0xa7c9, 0xa7c9,
- 0xa7d0, 0xa7d0,
- 0xa7d6, 0xa7d6,
- 0xa7d8, 0xa7d8,
- 0xa7f5, 0xa7f5,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 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,
- 0x1d7ca, 0x1d7ca,
- 0x1e900, 0x1e921,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* 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[] = {
- 770,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x0898, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 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,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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,
- 0x135d, 0x135f,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x180f, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 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,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa672,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa827,
- 0xa82c, 0xa82c,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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, 0xfe2f,
- 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,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10eac,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10f70, 0x10f85,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x11075,
- 0x1107f, 0x110ba,
- 0x110c2, 0x110c2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11147,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111ce, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x11461,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11740, 0x11746,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11943,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f42,
- 0x11f50, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13440, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a70, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0100, 0xe01ef,
-}; /* CR_Word */
-
-/* 'Alnum': [[:Alnum:]] */
-static const OnigCodePoint CR_Alnum[] = {
- 772,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0345, 0x0345,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0657,
- 0x0659, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06e1, 0x06e8,
- 0x06ed, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x073f,
- 0x074d, 0x07b1,
- 0x07c0, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0817,
- 0x081a, 0x082c,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c9,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x093b,
- 0x093d, 0x094c,
- 0x094e, 0x0950,
- 0x0955, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09fc, 0x09fc,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af9, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e46,
- 0x0e4d, 0x0e4d,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ecd, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f20, 0x0f29,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f83,
- 0x0f88, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x1000, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1713,
- 0x171f, 0x1733,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17c8,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1abf, 0x1ac0,
- 0x1acc, 0x1ace,
- 0x1b00, 0x1b33,
- 0x1b35, 0x1b43,
- 0x1b45, 0x1b4c,
- 0x1b50, 0x1b59,
- 0x1b80, 0x1ba9,
- 0x1bac, 0x1be5,
- 0x1be7, 0x1bf1,
- 0x1c00, 0x1c36,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1de7, 0x1df4,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66e,
- 0xa674, 0xa67b,
- 0xa67f, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa805,
- 0xa807, 0xa827,
- 0xa840, 0xa873,
- 0xa880, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92a,
- 0xa930, 0xa952,
- 0xa960, 0xa97c,
- 0xa980, 0xa9b2,
- 0xa9b4, 0xa9bf,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaabe,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabea,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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,
- 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,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10eac,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11045,
- 0x11066, 0x1106f,
- 0x11071, 0x11075,
- 0x11080, 0x110b8,
- 0x110c2, 0x110c2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11132,
- 0x11136, 0x1113f,
- 0x11144, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11180, 0x111bf,
- 0x111c1, 0x111c4,
- 0x111ce, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112e8,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11400, 0x11441,
- 0x11443, 0x11445,
- 0x11447, 0x1144a,
- 0x11450, 0x11459,
- 0x1145f, 0x11461,
- 0x11480, 0x114c1,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115be,
- 0x115d8, 0x115dd,
- 0x11600, 0x1163e,
- 0x11640, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b5,
- 0x116b8, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172a,
- 0x11730, 0x11739,
- 0x11740, 0x11746,
- 0x11800, 0x11838,
- 0x118a0, 0x118e9,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x1193c,
- 0x1193f, 0x11942,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119df,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a32,
- 0x11a35, 0x11a3e,
- 0x11a50, 0x11a97,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c40, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d46, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f40,
- 0x11f50, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a70, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9e, 0x1bc9e,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e2f0, 0x1e2f9,
- 0x1e4d0, 0x1e4eb,
- 0x1e4f0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e947, 0x1e947,
- 0x1e94b, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Alnum */
-
-/* 'ASCII': [[:ASCII:]] */
-static const OnigCodePoint CR_ASCII[] = {
- 1,
- 0x0000, 0x007f,
-}; /* CR_ASCII */
-
-/* 'Punct' */
-static const OnigCodePoint CR_Punct[] = {
- 191,
- 0x0021, 0x0023,
- 0x0025, 0x002a,
- 0x002c, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005b, 0x005d,
- 0x005f, 0x005f,
- 0x007b, 0x007b,
- 0x007d, 0x007d,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00ab, 0x00ab,
- 0x00b6, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061d, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x1400, 0x1400,
- 0x166e, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1b7d, 0x1b7e,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2308, 0x230b,
- 0x2329, 0x232a,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e2e,
- 0x2e30, 0x2e4f,
- 0x2e52, 0x2e5d,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 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, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10ead, 0x10ead,
- 0x10f55, 0x10f59,
- 0x10f86, 0x10f89,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145a, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x116b9, 0x116b9,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x11944, 0x11946,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11b00, 0x11b09,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11f43, 0x11f4f,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x12ff1, 0x12ff2,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_Punct */
-
-#ifdef USE_UNICODE_PROPERTIES
-/* 'Any': - */
-static const OnigCodePoint CR_Any[] = {
- 1,
- 0x0000, 0x10ffff,
-}; /* CR_Any */
-
-/* 'Assigned': - */
-static const OnigCodePoint CR_Assigned[] = {
- 707,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfdcf,
- 0xfdf0, 0xfe19,
- 0xfe20, 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, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10f70, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x110c2,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11b00, 0x11b09,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1ea,
- 0x1d200, 0x1d245,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd,
-}; /* CR_Assigned */
-
-/* 'C': Major Category */
-static const OnigCodePoint CR_C[] = {
- 712,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x0605,
- 0x061c, 0x061c,
- 0x06dd, 0x06dd,
- 0x070e, 0x070f,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x086f,
- 0x088f, 0x0897,
- 0x08e2, 0x08e2,
- 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,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 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,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b54,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 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, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3b,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5c,
- 0x0c5e, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdc,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf4, 0x0cff,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d80,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ecf, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 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, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x1716, 0x171e,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180e, 0x180e,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1acf, 0x1aff,
- 0x1b4d, 0x1b4f,
- 0x1b7f, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 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,
- 0x209d, 0x209f,
- 0x20c1, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b96,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e5e, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7cb, 0xa7cf,
- 0xa7d2, 0xa7d2,
- 0xa7d4, 0xa7d4,
- 0xa7da, 0xa7f1,
- 0xa82d, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab6c, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xf8ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc3, 0xfbd2,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdce,
- 0xfdd0, 0xfdef,
- 0xfe1a, 0xfe1f,
- 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,
- 0x1018f, 0x1018f,
- 0x1019d, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x1057b, 0x1057b,
- 0x1058b, 0x1058b,
- 0x10593, 0x10593,
- 0x10596, 0x10596,
- 0x105a2, 0x105a2,
- 0x105b2, 0x105b2,
- 0x105ba, 0x105ba,
- 0x105bd, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x1077f,
- 0x10786, 0x10786,
- 0x107b1, 0x107b1,
- 0x107bb, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10e7f,
- 0x10eaa, 0x10eaa,
- 0x10eae, 0x10eaf,
- 0x10eb2, 0x10efc,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10f6f,
- 0x10f8a, 0x10faf,
- 0x10fcc, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11076, 0x1107e,
- 0x110bd, 0x110bd,
- 0x110c3, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11148, 0x1114f,
- 0x11177, 0x1117f,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x11242, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145c, 0x1145c,
- 0x11462, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116ba, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11747, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11907, 0x11908,
- 0x1190a, 0x1190b,
- 0x11914, 0x11914,
- 0x11917, 0x11917,
- 0x11936, 0x11936,
- 0x11939, 0x1193a,
- 0x11947, 0x1194f,
- 0x1195a, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11aaf,
- 0x11af9, 0x11aff,
- 0x11b0a, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11eff,
- 0x11f11, 0x11f11,
- 0x11f3b, 0x11f3d,
- 0x11f5a, 0x11faf,
- 0x11fb1, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12f8f,
- 0x12ff3, 0x12fff,
- 0x13430, 0x1343f,
- 0x13456, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16abf, 0x16abf,
- 0x16aca, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe5, 0x16fef,
- 0x16ff2, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18cd6, 0x18cff,
- 0x18d09, 0x1afef,
- 0x1aff4, 0x1aff4,
- 0x1affc, 0x1affc,
- 0x1afff, 0x1afff,
- 0x1b123, 0x1b131,
- 0x1b133, 0x1b14f,
- 0x1b153, 0x1b154,
- 0x1b156, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca0, 0x1ceff,
- 0x1cf2e, 0x1cf2f,
- 0x1cf47, 0x1cf4f,
- 0x1cfc4, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d173, 0x1d17a,
- 0x1d1eb, 0x1d1ff,
- 0x1d246, 0x1d2bf,
- 0x1d2d4, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 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,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1deff,
- 0x1df1f, 0x1df24,
- 0x1df2b, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e02f,
- 0x1e06e, 0x1e08e,
- 0x1e090, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e28f,
- 0x1e2af, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e4cf,
- 0x1e4fa, 0x1e7df,
- 0x1e7e7, 0x1e7e7,
- 0x1e7ec, 0x1e7ec,
- 0x1e7ef, 0x1e7ef,
- 0x1e7ff, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f1ae, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d8, 0x1f6db,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fd, 0x1f6ff,
- 0x1f777, 0x1f77a,
- 0x1f7da, 0x1f7df,
- 0x1f7ec, 0x1f7ef,
- 0x1f7f1, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8af,
- 0x1f8b2, 0x1f8ff,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa7d, 0x1fa7f,
- 0x1fa89, 0x1fa8f,
- 0x1fabe, 0x1fabe,
- 0x1fac6, 0x1facd,
- 0x1fadc, 0x1fadf,
- 0x1fae9, 0x1faef,
- 0x1faf9, 0x1faff,
- 0x1fb93, 0x1fb93,
- 0x1fbcb, 0x1fbef,
- 0x1fbfa, 0x1ffff,
- 0x2a6e0, 0x2a6ff,
- 0x2b73a, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0x2ffff,
- 0x3134b, 0x3134f,
- 0x323b0, 0xe00ff,
- 0xe01f0, 0x10ffff,
-}; /* CR_C */
-
-/* 'Cc': General Category */
-#define CR_Cc CR_Cntrl
-
-/* 'Cf': General Category */
-static const OnigCodePoint CR_Cf[] = {
- 21,
- 0x00ad, 0x00ad,
- 0x0600, 0x0605,
- 0x061c, 0x061c,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x0890, 0x0891,
- 0x08e2, 0x08e2,
- 0x180e, 0x180e,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x2064,
- 0x2066, 0x206f,
- 0xfeff, 0xfeff,
- 0xfff9, 0xfffb,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
- 0x13430, 0x1343f,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
-}; /* CR_Cf */
-
-/* 'Cn': General Category */
-static const OnigCodePoint CR_Cn[] = {
- 707,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x05ff,
- 0x070e, 0x070e,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x086f,
- 0x088f, 0x088f,
- 0x0892, 0x0897,
- 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,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 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,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b54,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 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, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3b,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5c,
- 0x0c5e, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdc,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf4, 0x0cff,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d80,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ecf, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 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, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x1716, 0x171e,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1acf, 0x1aff,
- 0x1b4d, 0x1b4f,
- 0x1b7f, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 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,
- 0x2065, 0x2065,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x209d, 0x209f,
- 0x20c1, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b96,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e5e, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7cb, 0xa7cf,
- 0xa7d2, 0xa7d2,
- 0xa7d4, 0xa7d4,
- 0xa7da, 0xa7f1,
- 0xa82d, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab6c, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xd7ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc3, 0xfbd2,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdce,
- 0xfdd0, 0xfdef,
- 0xfe1a, 0xfe1f,
- 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,
- 0x1018f, 0x1018f,
- 0x1019d, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x1057b, 0x1057b,
- 0x1058b, 0x1058b,
- 0x10593, 0x10593,
- 0x10596, 0x10596,
- 0x105a2, 0x105a2,
- 0x105b2, 0x105b2,
- 0x105ba, 0x105ba,
- 0x105bd, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x1077f,
- 0x10786, 0x10786,
- 0x107b1, 0x107b1,
- 0x107bb, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10e7f,
- 0x10eaa, 0x10eaa,
- 0x10eae, 0x10eaf,
- 0x10eb2, 0x10efc,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10f6f,
- 0x10f8a, 0x10faf,
- 0x10fcc, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11076, 0x1107e,
- 0x110c3, 0x110cc,
- 0x110ce, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11148, 0x1114f,
- 0x11177, 0x1117f,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x11242, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145c, 0x1145c,
- 0x11462, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116ba, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11747, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11907, 0x11908,
- 0x1190a, 0x1190b,
- 0x11914, 0x11914,
- 0x11917, 0x11917,
- 0x11936, 0x11936,
- 0x11939, 0x1193a,
- 0x11947, 0x1194f,
- 0x1195a, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11aaf,
- 0x11af9, 0x11aff,
- 0x11b0a, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11eff,
- 0x11f11, 0x11f11,
- 0x11f3b, 0x11f3d,
- 0x11f5a, 0x11faf,
- 0x11fb1, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12f8f,
- 0x12ff3, 0x12fff,
- 0x13456, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16abf, 0x16abf,
- 0x16aca, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe5, 0x16fef,
- 0x16ff2, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18cd6, 0x18cff,
- 0x18d09, 0x1afef,
- 0x1aff4, 0x1aff4,
- 0x1affc, 0x1affc,
- 0x1afff, 0x1afff,
- 0x1b123, 0x1b131,
- 0x1b133, 0x1b14f,
- 0x1b153, 0x1b154,
- 0x1b156, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca4, 0x1ceff,
- 0x1cf2e, 0x1cf2f,
- 0x1cf47, 0x1cf4f,
- 0x1cfc4, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d1eb, 0x1d1ff,
- 0x1d246, 0x1d2bf,
- 0x1d2d4, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 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,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1deff,
- 0x1df1f, 0x1df24,
- 0x1df2b, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e02f,
- 0x1e06e, 0x1e08e,
- 0x1e090, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e28f,
- 0x1e2af, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e4cf,
- 0x1e4fa, 0x1e7df,
- 0x1e7e7, 0x1e7e7,
- 0x1e7ec, 0x1e7ec,
- 0x1e7ef, 0x1e7ef,
- 0x1e7ff, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f1ae, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d8, 0x1f6db,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fd, 0x1f6ff,
- 0x1f777, 0x1f77a,
- 0x1f7da, 0x1f7df,
- 0x1f7ec, 0x1f7ef,
- 0x1f7f1, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8af,
- 0x1f8b2, 0x1f8ff,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa7d, 0x1fa7f,
- 0x1fa89, 0x1fa8f,
- 0x1fabe, 0x1fabe,
- 0x1fac6, 0x1facd,
- 0x1fadc, 0x1fadf,
- 0x1fae9, 0x1faef,
- 0x1faf9, 0x1faff,
- 0x1fb93, 0x1fb93,
- 0x1fbcb, 0x1fbef,
- 0x1fbfa, 0x1ffff,
- 0x2a6e0, 0x2a6ff,
- 0x2b73a, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0x2ffff,
- 0x3134b, 0x3134f,
- 0x323b0, 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[] = {
- 659,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c9,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 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,
- 0x0af9, 0x0af9,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d04, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16f1, 0x16f8,
- 0x1700, 0x1711,
- 0x171f, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4c,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2183, 0x2184,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3006,
- 0x3031, 0x3035,
- 0x303b, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6e5,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x10340,
- 0x10342, 0x10349,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10e80, 0x10ea9,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11071, 0x11072,
- 0x11075, 0x11075,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11147, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x1123f, 0x11240,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x11461,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11740, 0x11746,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x1192f,
- 0x1193f, 0x1193f,
- 0x11941, 0x11941,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x11f02, 0x11f02,
- 0x11f04, 0x11f10,
- 0x11f12, 0x11f33,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a70, 0x16abe,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 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, 0x1d7cb,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e4d0, 0x1e4eb,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_L */
-
-/* 'LC': General Category */
-static const OnigCodePoint CR_LC[] = {
- 143,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x01ba,
- 0x01bc, 0x01bf,
- 0x01c4, 0x0293,
- 0x0295, 0x02af,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0560, 0x0588,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d00, 0x1d2b,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1d9a,
- 0x1e00, 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,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2183, 0x2184,
- 0x2c00, 0x2c7b,
- 0x2c7e, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69b,
- 0xa722, 0xa76f,
- 0xa771, 0xa787,
- 0xa78b, 0xa78e,
- 0xa790, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f5, 0xa7f6,
- 0xa7fa, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab60, 0xab68,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 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, 0x1d7cb,
- 0x1df00, 0x1df09,
- 0x1df0b, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e900, 0x1e943,
-}; /* CR_LC */
-
-/* 'Ll': General Category */
-static const OnigCodePoint CR_Ll[] = {
- 658,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 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,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0293,
- 0x0295, 0x02af,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 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, 0x04cf,
- 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,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0560, 0x0588,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d00, 0x1d2b,
- 0x1d6b, 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, 0x1e9d,
- 0x1e9f, 0x1e9f,
- 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,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 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,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x214e, 0x214e,
- 0x2184, 0x2184,
- 0x2c30, 0x2c5f,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c71, 0x2c71,
- 0x2c73, 0x2c74,
- 0x2c76, 0x2c7b,
- 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,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa731,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa771, 0xa778,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa78e, 0xa78e,
- 0xa791, 0xa791,
- 0xa793, 0xa795,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7af, 0xa7af,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c1, 0xa7c1,
- 0xa7c3, 0xa7c3,
- 0xa7c8, 0xa7c8,
- 0xa7ca, 0xa7ca,
- 0xa7d1, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d5,
- 0xa7d7, 0xa7d7,
- 0xa7d9, 0xa7d9,
- 0xa7f6, 0xa7f6,
- 0xa7fa, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab60, 0xab68,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 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,
- 0x1d7cb, 0x1d7cb,
- 0x1df00, 0x1df09,
- 0x1df0b, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e922, 0x1e943,
-}; /* CR_Ll */
-
-/* 'Lm': General Category */
-static const OnigCodePoint CR_Lm[] = {
- 71,
- 0x02b0, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0374, 0x0374,
- 0x037a, 0x037a,
- 0x0559, 0x0559,
- 0x0640, 0x0640,
- 0x06e5, 0x06e6,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x08c9, 0x08c9,
- 0x0971, 0x0971,
- 0x0e46, 0x0e46,
- 0x0ec6, 0x0ec6,
- 0x10fc, 0x10fc,
- 0x17d7, 0x17d7,
- 0x1843, 0x1843,
- 0x1aa7, 0x1aa7,
- 0x1c78, 0x1c7d,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dbf,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2c7c, 0x2c7d,
- 0x2d6f, 0x2d6f,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3005,
- 0x3031, 0x3035,
- 0x303b, 0x303b,
- 0x309d, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa4f8, 0xa4fd,
- 0xa60c, 0xa60c,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69d,
- 0xa717, 0xa71f,
- 0xa770, 0xa770,
- 0xa788, 0xa788,
- 0xa7f2, 0xa7f4,
- 0xa7f8, 0xa7f9,
- 0xa9cf, 0xa9cf,
- 0xa9e6, 0xa9e6,
- 0xaa70, 0xaa70,
- 0xaadd, 0xaadd,
- 0xaaf3, 0xaaf4,
- 0xab5c, 0xab5f,
- 0xab69, 0xab69,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x16b40, 0x16b43,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1e030, 0x1e06d,
- 0x1e137, 0x1e13d,
- 0x1e4eb, 0x1e4eb,
- 0x1e94b, 0x1e94b,
-}; /* CR_Lm */
-
-/* 'Lo': General Category */
-static const OnigCodePoint CR_Lo[] = {
- 510,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x01bb, 0x01bb,
- 0x01c0, 0x01c3,
- 0x0294, 0x0294,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x063f,
- 0x0641, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x0800, 0x0815,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c8,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0972, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 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,
- 0x0af9, 0x0af9,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d04, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e45,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x1100, 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,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16f1, 0x16f8,
- 0x1700, 0x1711,
- 0x171f, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17dc, 0x17dc,
- 0x1820, 0x1842,
- 0x1844, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4c,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c77,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x2135, 0x2138,
- 0x2d30, 0x2d67,
- 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, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa014,
- 0xa016, 0xa48c,
- 0xa4d0, 0xa4f7,
- 0xa500, 0xa60b,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa66e, 0xa66e,
- 0xa6a0, 0xa6e5,
- 0xa78f, 0xa78f,
- 0xa7f7, 0xa7f7,
- 0xa7fb, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9e0, 0xa9e4,
- 0xa9e7, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa6f,
- 0xaa71, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadc,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf2,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x10340,
- 0x10342, 0x10349,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10450, 0x1049d,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10d00, 0x10d23,
- 0x10e80, 0x10ea9,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11071, 0x11072,
- 0x11075, 0x11075,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11147, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x1123f, 0x11240,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x11461,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11740, 0x11746,
- 0x11800, 0x1182b,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x1192f,
- 0x1193f, 0x1193f,
- 0x11941, 0x11941,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x11f02, 0x11f02,
- 0x11f04, 0x11f10,
- 0x11f12, 0x11f33,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a70, 0x16abe,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1df0a, 0x1df0a,
- 0x1e100, 0x1e12c,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e4d0, 0x1e4ea,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* 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[] = {
- 646,
- 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,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 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,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 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,
- 0x1e9e, 0x1e9e,
- 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,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 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, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2183, 0x2183,
- 0x2c00, 0x2c2f,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 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,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c0, 0xa7c0,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c7,
- 0xa7c9, 0xa7c9,
- 0xa7d0, 0xa7d0,
- 0xa7d6, 0xa7d6,
- 0xa7d8, 0xa7d8,
- 0xa7f5, 0xa7f5,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 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,
- 0x1d7ca, 0x1d7ca,
- 0x1e900, 0x1e921,
-}; /* CR_Lu */
-
-/* 'M': Major Category */
-static const OnigCodePoint CR_M[] = {
- 310,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x0898, 0x089f,
- 0x08ca, 0x08e1,
- 0x08e3, 0x0903,
- 0x093a, 0x093c,
- 0x093e, 0x094f,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0983,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0abc, 0x0abc,
- 0x0abe, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c04,
- 0x0c3c, 0x0c3c,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c83,
- 0x0cbc, 0x0cbc,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0cf3, 0x0cf3,
- 0x0d00, 0x0d03,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d83,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ece,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f3f,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102b, 0x103e,
- 0x1056, 0x1059,
- 0x105e, 0x1060,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1071, 0x1074,
- 0x1082, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1715,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x180f, 0x180f,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1a17, 0x1a1b,
- 0x1a55, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b04,
- 0x1b34, 0x1b44,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b82,
- 0x1ba1, 0x1bad,
- 0x1be6, 0x1bf3,
- 0x1c24, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf7, 0x1cf9,
- 0x1dc0, 0x1dff,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa823, 0xa827,
- 0xa82c, 0xa82c,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa953,
- 0xa980, 0xa983,
- 0xa9b3, 0xa9c0,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4d,
- 0xaa7b, 0xaa7d,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaeb, 0xaaef,
- 0xaaf5, 0xaaf6,
- 0xabe3, 0xabea,
- 0xabec, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11000, 0x11002,
- 0x11038, 0x11046,
- 0x11070, 0x11070,
- 0x11073, 0x11074,
- 0x1107f, 0x11082,
- 0x110b0, 0x110ba,
- 0x110c2, 0x110c2,
- 0x11100, 0x11102,
- 0x11127, 0x11134,
- 0x11145, 0x11146,
- 0x11173, 0x11173,
- 0x11180, 0x11182,
- 0x111b3, 0x111c0,
- 0x111c9, 0x111cc,
- 0x111ce, 0x111cf,
- 0x1122c, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112ea,
- 0x11300, 0x11303,
- 0x1133b, 0x1133c,
- 0x1133e, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11435, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114c3,
- 0x115af, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11630, 0x11640,
- 0x116ab, 0x116b7,
- 0x1171d, 0x1172b,
- 0x1182c, 0x1183a,
- 0x11930, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x1193e,
- 0x11940, 0x11940,
- 0x11942, 0x11943,
- 0x119d1, 0x119d7,
- 0x119da, 0x119e0,
- 0x119e4, 0x119e4,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a39,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a5b,
- 0x11a8a, 0x11a99,
- 0x11c2f, 0x11c36,
- 0x11c38, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d8a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d97,
- 0x11ef3, 0x11ef6,
- 0x11f00, 0x11f01,
- 0x11f03, 0x11f03,
- 0x11f34, 0x11f3a,
- 0x11f3e, 0x11f42,
- 0x13440, 0x13440,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f51, 0x16f87,
- 0x16f8f, 0x16f92,
- 0x16fe4, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e08f, 0x1e08f,
- 0x1e130, 0x1e136,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e4ec, 0x1e4ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0100, 0xe01ef,
-}; /* CR_M */
-
-/* 'Mc': General Category */
-static const OnigCodePoint CR_Mc[] = {
- 182,
- 0x0903, 0x0903,
- 0x093b, 0x093b,
- 0x093e, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x094f,
- 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,
- 0x0cf3, 0x0cf3,
- 0x0d02, 0x0d03,
- 0x0d3e, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d57, 0x0d57,
- 0x0d82, 0x0d83,
- 0x0dcf, 0x0dd1,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0f3e, 0x0f3f,
- 0x0f7f, 0x0f7f,
- 0x102b, 0x102c,
- 0x1031, 0x1031,
- 0x1038, 0x1038,
- 0x103b, 0x103c,
- 0x1056, 0x1057,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1083, 0x1084,
- 0x1087, 0x108c,
- 0x108f, 0x108f,
- 0x109a, 0x109c,
- 0x1715, 0x1715,
- 0x1734, 0x1734,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1a19, 0x1a1a,
- 0x1a55, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a61, 0x1a61,
- 0x1a63, 0x1a64,
- 0x1a6d, 0x1a72,
- 0x1b04, 0x1b04,
- 0x1b35, 0x1b35,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b44,
- 0x1b82, 0x1b82,
- 0x1ba1, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1c24, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1ce1, 0x1ce1,
- 0x1cf7, 0x1cf7,
- 0x302e, 0x302f,
- 0xa823, 0xa824,
- 0xa827, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa952, 0xa953,
- 0xa983, 0xa983,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9c0,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa4d, 0xaa4d,
- 0xaa7b, 0xaa7b,
- 0xaa7d, 0xaa7d,
- 0xaaeb, 0xaaeb,
- 0xaaee, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabea,
- 0xabec, 0xabec,
- 0x11000, 0x11000,
- 0x11002, 0x11002,
- 0x11082, 0x11082,
- 0x110b0, 0x110b2,
- 0x110b7, 0x110b8,
- 0x1112c, 0x1112c,
- 0x11145, 0x11146,
- 0x11182, 0x11182,
- 0x111b3, 0x111b5,
- 0x111bf, 0x111c0,
- 0x111ce, 0x111ce,
- 0x1122c, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x112e0, 0x112e2,
- 0x11302, 0x11303,
- 0x1133e, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11435, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x114b0, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114be,
- 0x114c1, 0x114c1,
- 0x115af, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x11630, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x11720, 0x11721,
- 0x11726, 0x11726,
- 0x1182c, 0x1182e,
- 0x11838, 0x11838,
- 0x11930, 0x11935,
- 0x11937, 0x11938,
- 0x1193d, 0x1193d,
- 0x11940, 0x11940,
- 0x11942, 0x11942,
- 0x119d1, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a39, 0x11a39,
- 0x11a57, 0x11a58,
- 0x11a97, 0x11a97,
- 0x11c2f, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d8a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11ef5, 0x11ef6,
- 0x11f03, 0x11f03,
- 0x11f34, 0x11f35,
- 0x11f3e, 0x11f3f,
- 0x11f41, 0x11f41,
- 0x16f51, 0x16f87,
- 0x16ff0, 0x16ff1,
- 0x1d165, 0x1d166,
- 0x1d16d, 0x1d172,
-}; /* CR_Mc */
-
-/* 'Me': General Category */
-static const OnigCodePoint CR_Me[] = {
- 5,
- 0x0488, 0x0489,
- 0x1abe, 0x1abe,
- 0x20dd, 0x20e0,
- 0x20e2, 0x20e4,
- 0xa670, 0xa672,
-}; /* CR_Me */
-
-/* 'Mn': General Category */
-static const OnigCodePoint CR_Mn[] = {
- 346,
- 0x0300, 0x036f,
- 0x0483, 0x0487,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x0898, 0x089f,
- 0x08ca, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3f, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b55, 0x0b56,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3c, 0x0c3c,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d81,
- 0x0dca, 0x0dca,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ece,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x180f, 0x180f,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abd,
- 0x1abf, 0x1ace,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b34,
- 0x1b36, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1dff,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302d,
- 0x3099, 0x309a,
- 0xa66f, 0xa66f,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa82c, 0xa82c,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x11070, 0x11070,
- 0x11073, 0x11074,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x110c2, 0x110c2,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x111cf, 0x111cf,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x11340, 0x11340,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x1193b, 0x1193c,
- 0x1193e, 0x1193e,
- 0x11943, 0x11943,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x11f00, 0x11f01,
- 0x11f36, 0x11f3a,
- 0x11f40, 0x11f40,
- 0x11f42, 0x11f42,
- 0x13440, 0x13440,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x16fe4, 0x16fe4,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e08f, 0x1e08f,
- 0x1e130, 0x1e136,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e4ec, 0x1e4ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0100, 0xe01ef,
-}; /* CR_Mn */
-
-/* 'N': Major Category */
-static const OnigCodePoint CR_N[] = {
- 137,
- 0x0030, 0x0039,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x07c0, 0x07c9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x09f4, 0x09f9,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0b72, 0x0b77,
- 0x0be6, 0x0bf2,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7e,
- 0x0ce6, 0x0cef,
- 0x0d58, 0x0d5e,
- 0x0d66, 0x0d78,
- 0x0de6, 0x0def,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f33,
- 0x1040, 0x1049,
- 0x1090, 0x1099,
- 0x1369, 0x137c,
- 0x16ee, 0x16f0,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19da,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1b50, 0x1b59,
- 0x1bb0, 0x1bb9,
- 0x1c40, 0x1c49,
- 0x1c50, 0x1c59,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2150, 0x2182,
- 0x2185, 0x2189,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3248, 0x324f,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0xa620, 0xa629,
- 0xa6e6, 0xa6ef,
- 0xa830, 0xa835,
- 0xa8d0, 0xa8d9,
- 0xa900, 0xa909,
- 0xa9d0, 0xa9d9,
- 0xa9f0, 0xa9f9,
- 0xaa50, 0xaa59,
- 0xabf0, 0xabf9,
- 0xff10, 0xff19,
- 0x10107, 0x10133,
- 0x10140, 0x10178,
- 0x1018a, 0x1018b,
- 0x102e1, 0x102fb,
- 0x10320, 0x10323,
- 0x10341, 0x10341,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5,
- 0x104a0, 0x104a9,
- 0x10858, 0x1085f,
- 0x10879, 0x1087f,
- 0x108a7, 0x108af,
- 0x108fb, 0x108ff,
- 0x10916, 0x1091b,
- 0x109bc, 0x109bd,
- 0x109c0, 0x109cf,
- 0x109d2, 0x109ff,
- 0x10a40, 0x10a48,
- 0x10a7d, 0x10a7e,
- 0x10a9d, 0x10a9f,
- 0x10aeb, 0x10aef,
- 0x10b58, 0x10b5f,
- 0x10b78, 0x10b7f,
- 0x10ba9, 0x10baf,
- 0x10cfa, 0x10cff,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f1d, 0x10f26,
- 0x10f51, 0x10f54,
- 0x10fc5, 0x10fcb,
- 0x11052, 0x1106f,
- 0x110f0, 0x110f9,
- 0x11136, 0x1113f,
- 0x111d0, 0x111d9,
- 0x111e1, 0x111f4,
- 0x112f0, 0x112f9,
- 0x11450, 0x11459,
- 0x114d0, 0x114d9,
- 0x11650, 0x11659,
- 0x116c0, 0x116c9,
- 0x11730, 0x1173b,
- 0x118e0, 0x118f2,
- 0x11950, 0x11959,
- 0x11c50, 0x11c6c,
- 0x11d50, 0x11d59,
- 0x11da0, 0x11da9,
- 0x11f50, 0x11f59,
- 0x11fc0, 0x11fd4,
- 0x12400, 0x1246e,
- 0x16a60, 0x16a69,
- 0x16ac0, 0x16ac9,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16e80, 0x16e96,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d360, 0x1d378,
- 0x1d7ce, 0x1d7ff,
- 0x1e140, 0x1e149,
- 0x1e2f0, 0x1e2f9,
- 0x1e4f0, 0x1e4f9,
- 0x1e8c7, 0x1e8cf,
- 0x1e950, 0x1e959,
- 0x1ec71, 0x1ecab,
- 0x1ecad, 0x1ecaf,
- 0x1ecb1, 0x1ecb4,
- 0x1ed01, 0x1ed2d,
- 0x1ed2f, 0x1ed3d,
- 0x1f100, 0x1f10c,
- 0x1fbf0, 0x1fbf9,
-}; /* CR_N */
-
-/* 'Nd': General Category */
-#define CR_Nd CR_Digit
-
-/* 'Nl': General Category */
-static const OnigCodePoint CR_Nl[] = {
- 12,
- 0x16ee, 0x16f0,
- 0x2160, 0x2182,
- 0x2185, 0x2188,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0xa6e6, 0xa6ef,
- 0x10140, 0x10174,
- 0x10341, 0x10341,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5,
- 0x12400, 0x1246e,
-}; /* CR_Nl */
-
-/* 'No': General Category */
-static const OnigCodePoint CR_No[] = {
- 72,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x09f4, 0x09f9,
- 0x0b72, 0x0b77,
- 0x0bf0, 0x0bf2,
- 0x0c78, 0x0c7e,
- 0x0d58, 0x0d5e,
- 0x0d70, 0x0d78,
- 0x0f2a, 0x0f33,
- 0x1369, 0x137c,
- 0x17f0, 0x17f9,
- 0x19da, 0x19da,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2150, 0x215f,
- 0x2189, 0x2189,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3248, 0x324f,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0xa830, 0xa835,
- 0x10107, 0x10133,
- 0x10175, 0x10178,
- 0x1018a, 0x1018b,
- 0x102e1, 0x102fb,
- 0x10320, 0x10323,
- 0x10858, 0x1085f,
- 0x10879, 0x1087f,
- 0x108a7, 0x108af,
- 0x108fb, 0x108ff,
- 0x10916, 0x1091b,
- 0x109bc, 0x109bd,
- 0x109c0, 0x109cf,
- 0x109d2, 0x109ff,
- 0x10a40, 0x10a48,
- 0x10a7d, 0x10a7e,
- 0x10a9d, 0x10a9f,
- 0x10aeb, 0x10aef,
- 0x10b58, 0x10b5f,
- 0x10b78, 0x10b7f,
- 0x10ba9, 0x10baf,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x10f1d, 0x10f26,
- 0x10f51, 0x10f54,
- 0x10fc5, 0x10fcb,
- 0x11052, 0x11065,
- 0x111e1, 0x111f4,
- 0x1173a, 0x1173b,
- 0x118ea, 0x118f2,
- 0x11c5a, 0x11c6c,
- 0x11fc0, 0x11fd4,
- 0x16b5b, 0x16b61,
- 0x16e80, 0x16e96,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d360, 0x1d378,
- 0x1e8c7, 0x1e8cf,
- 0x1ec71, 0x1ecab,
- 0x1ecad, 0x1ecaf,
- 0x1ecb1, 0x1ecb4,
- 0x1ed01, 0x1ed2d,
- 0x1ed2f, 0x1ed3d,
- 0x1f100, 0x1f10c,
-}; /* CR_No */
-
-/* 'P': Major Category */
-#define CR_P CR_Punct
-
-/* '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[] = {
- 19,
- 0x002d, 0x002d,
- 0x058a, 0x058a,
- 0x05be, 0x05be,
- 0x1400, 0x1400,
- 0x1806, 0x1806,
- 0x2010, 0x2015,
- 0x2e17, 0x2e17,
- 0x2e1a, 0x2e1a,
- 0x2e3a, 0x2e3b,
- 0x2e40, 0x2e40,
- 0x2e5d, 0x2e5d,
- 0x301c, 0x301c,
- 0x3030, 0x3030,
- 0x30a0, 0x30a0,
- 0xfe31, 0xfe32,
- 0xfe58, 0xfe58,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
- 0x10ead, 0x10ead,
-}; /* CR_Pd */
-
-/* 'Pe': General Category */
-static const OnigCodePoint CR_Pe[] = {
- 76,
- 0x0029, 0x0029,
- 0x005d, 0x005d,
- 0x007d, 0x007d,
- 0x0f3b, 0x0f3b,
- 0x0f3d, 0x0f3d,
- 0x169c, 0x169c,
- 0x2046, 0x2046,
- 0x207e, 0x207e,
- 0x208e, 0x208e,
- 0x2309, 0x2309,
- 0x230b, 0x230b,
- 0x232a, 0x232a,
- 0x2769, 0x2769,
- 0x276b, 0x276b,
- 0x276d, 0x276d,
- 0x276f, 0x276f,
- 0x2771, 0x2771,
- 0x2773, 0x2773,
- 0x2775, 0x2775,
- 0x27c6, 0x27c6,
- 0x27e7, 0x27e7,
- 0x27e9, 0x27e9,
- 0x27eb, 0x27eb,
- 0x27ed, 0x27ed,
- 0x27ef, 0x27ef,
- 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,
- 0x2e23, 0x2e23,
- 0x2e25, 0x2e25,
- 0x2e27, 0x2e27,
- 0x2e29, 0x2e29,
- 0x2e56, 0x2e56,
- 0x2e58, 0x2e58,
- 0x2e5a, 0x2e5a,
- 0x2e5c, 0x2e5c,
- 0x3009, 0x3009,
- 0x300b, 0x300b,
- 0x300d, 0x300d,
- 0x300f, 0x300f,
- 0x3011, 0x3011,
- 0x3015, 0x3015,
- 0x3017, 0x3017,
- 0x3019, 0x3019,
- 0x301b, 0x301b,
- 0x301e, 0x301f,
- 0xfd3e, 0xfd3e,
- 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[] = {
- 10,
- 0x00bb, 0x00bb,
- 0x2019, 0x2019,
- 0x201d, 0x201d,
- 0x203a, 0x203a,
- 0x2e03, 0x2e03,
- 0x2e05, 0x2e05,
- 0x2e0a, 0x2e0a,
- 0x2e0d, 0x2e0d,
- 0x2e1d, 0x2e1d,
- 0x2e21, 0x2e21,
-}; /* CR_Pf */
-
-/* 'Pi': General Category */
-static const OnigCodePoint CR_Pi[] = {
- 11,
- 0x00ab, 0x00ab,
- 0x2018, 0x2018,
- 0x201b, 0x201c,
- 0x201f, 0x201f,
- 0x2039, 0x2039,
- 0x2e02, 0x2e02,
- 0x2e04, 0x2e04,
- 0x2e09, 0x2e09,
- 0x2e0c, 0x2e0c,
- 0x2e1c, 0x2e1c,
- 0x2e20, 0x2e20,
-}; /* CR_Pi */
-
-/* 'Po': General Category */
-static const OnigCodePoint CR_Po[] = {
- 187,
- 0x0021, 0x0023,
- 0x0025, 0x0027,
- 0x002a, 0x002a,
- 0x002c, 0x002c,
- 0x002e, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005c, 0x005c,
- 0x00a1, 0x00a1,
- 0x00a7, 0x00a7,
- 0x00b6, 0x00b7,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x0589,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x0609, 0x060a,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061d, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x07f7, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x09fd, 0x09fd,
- 0x0a76, 0x0a76,
- 0x0af0, 0x0af0,
- 0x0c77, 0x0c77,
- 0x0c84, 0x0c84,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f14, 0x0f14,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd4,
- 0x0fd9, 0x0fda,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1360, 0x1368,
- 0x166e, 0x166e,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x1805,
- 0x1807, 0x180a,
- 0x1944, 0x1945,
- 0x1a1e, 0x1a1f,
- 0x1aa0, 0x1aa6,
- 0x1aa8, 0x1aad,
- 0x1b5a, 0x1b60,
- 0x1b7d, 0x1b7e,
- 0x1bfc, 0x1bff,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x2016, 0x2017,
- 0x2020, 0x2027,
- 0x2030, 0x2038,
- 0x203b, 0x203e,
- 0x2041, 0x2043,
- 0x2047, 0x2051,
- 0x2053, 0x2053,
- 0x2055, 0x205e,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2d70, 0x2d70,
- 0x2e00, 0x2e01,
- 0x2e06, 0x2e08,
- 0x2e0b, 0x2e0b,
- 0x2e0e, 0x2e16,
- 0x2e18, 0x2e19,
- 0x2e1b, 0x2e1b,
- 0x2e1e, 0x2e1f,
- 0x2e2a, 0x2e2e,
- 0x2e30, 0x2e39,
- 0x2e3c, 0x2e3f,
- 0x2e41, 0x2e41,
- 0x2e43, 0x2e4f,
- 0x2e52, 0x2e54,
- 0x3001, 0x3003,
- 0x303d, 0x303d,
- 0x30fb, 0x30fb,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa673, 0xa673,
- 0xa67e, 0xa67e,
- 0xa6f2, 0xa6f7,
- 0xa874, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa8f8, 0xa8fa,
- 0xa8fc, 0xa8fc,
- 0xa92e, 0xa92f,
- 0xa95f, 0xa95f,
- 0xa9c1, 0xa9cd,
- 0xa9de, 0xa9df,
- 0xaa5c, 0xaa5f,
- 0xaade, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 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, 0x10102,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x1056f, 0x1056f,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x1093f, 0x1093f,
- 0x10a50, 0x10a58,
- 0x10a7f, 0x10a7f,
- 0x10af0, 0x10af6,
- 0x10b39, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x10f86, 0x10f89,
- 0x11047, 0x1104d,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x11140, 0x11143,
- 0x11174, 0x11175,
- 0x111c5, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111db, 0x111db,
- 0x111dd, 0x111df,
- 0x11238, 0x1123d,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144f,
- 0x1145a, 0x1145b,
- 0x1145d, 0x1145d,
- 0x114c6, 0x114c6,
- 0x115c1, 0x115d7,
- 0x11641, 0x11643,
- 0x11660, 0x1166c,
- 0x116b9, 0x116b9,
- 0x1173c, 0x1173e,
- 0x1183b, 0x1183b,
- 0x11944, 0x11946,
- 0x119e2, 0x119e2,
- 0x11a3f, 0x11a46,
- 0x11a9a, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11b00, 0x11b09,
- 0x11c41, 0x11c45,
- 0x11c70, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11f43, 0x11f4f,
- 0x11fff, 0x11fff,
- 0x12470, 0x12474,
- 0x12ff1, 0x12ff2,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b3b,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e9a,
- 0x16fe2, 0x16fe2,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8b,
- 0x1e95e, 0x1e95f,
-}; /* CR_Po */
-
-/* 'Ps': General Category */
-static const OnigCodePoint CR_Ps[] = {
- 79,
- 0x0028, 0x0028,
- 0x005b, 0x005b,
- 0x007b, 0x007b,
- 0x0f3a, 0x0f3a,
- 0x0f3c, 0x0f3c,
- 0x169b, 0x169b,
- 0x201a, 0x201a,
- 0x201e, 0x201e,
- 0x2045, 0x2045,
- 0x207d, 0x207d,
- 0x208d, 0x208d,
- 0x2308, 0x2308,
- 0x230a, 0x230a,
- 0x2329, 0x2329,
- 0x2768, 0x2768,
- 0x276a, 0x276a,
- 0x276c, 0x276c,
- 0x276e, 0x276e,
- 0x2770, 0x2770,
- 0x2772, 0x2772,
- 0x2774, 0x2774,
- 0x27c5, 0x27c5,
- 0x27e6, 0x27e6,
- 0x27e8, 0x27e8,
- 0x27ea, 0x27ea,
- 0x27ec, 0x27ec,
- 0x27ee, 0x27ee,
- 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,
- 0x2e22, 0x2e22,
- 0x2e24, 0x2e24,
- 0x2e26, 0x2e26,
- 0x2e28, 0x2e28,
- 0x2e42, 0x2e42,
- 0x2e55, 0x2e55,
- 0x2e57, 0x2e57,
- 0x2e59, 0x2e59,
- 0x2e5b, 0x2e5b,
- 0x3008, 0x3008,
- 0x300a, 0x300a,
- 0x300c, 0x300c,
- 0x300e, 0x300e,
- 0x3010, 0x3010,
- 0x3014, 0x3014,
- 0x3016, 0x3016,
- 0x3018, 0x3018,
- 0x301a, 0x301a,
- 0x301d, 0x301d,
- 0xfd3f, 0xfd3f,
- 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[] = {
- 232,
- 0x0024, 0x0024,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00a2, 0x00a6,
- 0x00a8, 0x00a9,
- 0x00ac, 0x00ac,
- 0x00ae, 0x00b1,
- 0x00b4, 0x00b4,
- 0x00b8, 0x00b8,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02eb,
- 0x02ed, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0375, 0x0375,
- 0x0384, 0x0385,
- 0x03f6, 0x03f6,
- 0x0482, 0x0482,
- 0x058d, 0x058f,
- 0x0606, 0x0608,
- 0x060b, 0x060b,
- 0x060e, 0x060f,
- 0x06de, 0x06de,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x07f6, 0x07f6,
- 0x07fe, 0x07ff,
- 0x0888, 0x0888,
- 0x09f2, 0x09f3,
- 0x09fa, 0x09fb,
- 0x0af1, 0x0af1,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bfa,
- 0x0c7f, 0x0c7f,
- 0x0d4f, 0x0d4f,
- 0x0d79, 0x0d79,
- 0x0e3f, 0x0e3f,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f13,
- 0x0f15, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fcf,
- 0x0fd5, 0x0fd8,
- 0x109e, 0x109f,
- 0x1390, 0x1399,
- 0x166d, 0x166d,
- 0x17db, 0x17db,
- 0x1940, 0x1940,
- 0x19de, 0x19ff,
- 0x1b61, 0x1b6a,
- 0x1b74, 0x1b7c,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x20a0, 0x20c0,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2118,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x213a, 0x213b,
- 0x2140, 0x2144,
- 0x214a, 0x214d,
- 0x214f, 0x214f,
- 0x218a, 0x218b,
- 0x2190, 0x2307,
- 0x230c, 0x2328,
- 0x232b, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x2767,
- 0x2794, 0x27c4,
- 0x27c7, 0x27e5,
- 0x27f0, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2bff,
- 0x2ce5, 0x2cea,
- 0x2e50, 0x2e51,
- 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, 0x31e3,
- 0x3200, 0x321e,
- 0x322a, 0x3247,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa720, 0xa721,
- 0xa789, 0xa78a,
- 0xa828, 0xa82b,
- 0xa836, 0xa839,
- 0xaa77, 0xaa79,
- 0xab5b, 0xab5b,
- 0xab6a, 0xab6b,
- 0xfb29, 0xfb29,
- 0xfbb2, 0xfbc2,
- 0xfd40, 0xfd4f,
- 0xfdcf, 0xfdcf,
- 0xfdfc, 0xfdff,
- 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,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x1018c, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10877, 0x10878,
- 0x10ac8, 0x10ac8,
- 0x1173f, 0x1173f,
- 0x11fd5, 0x11ff1,
- 0x16b3c, 0x16b3f,
- 0x16b45, 0x16b45,
- 0x1bc9c, 0x1bc9c,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1ea,
- 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,
- 0x1d800, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da86,
- 0x1e14f, 0x1e14f,
- 0x1e2ff, 0x1e2ff,
- 0x1ecac, 0x1ecac,
- 0x1ecb0, 0x1ecb0,
- 0x1ed2e, 0x1ed2e,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f10d, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
-}; /* CR_S */
-
-/* 'Sc': General Category */
-static const OnigCodePoint CR_Sc[] = {
- 21,
- 0x0024, 0x0024,
- 0x00a2, 0x00a5,
- 0x058f, 0x058f,
- 0x060b, 0x060b,
- 0x07fe, 0x07ff,
- 0x09f2, 0x09f3,
- 0x09fb, 0x09fb,
- 0x0af1, 0x0af1,
- 0x0bf9, 0x0bf9,
- 0x0e3f, 0x0e3f,
- 0x17db, 0x17db,
- 0x20a0, 0x20c0,
- 0xa838, 0xa838,
- 0xfdfc, 0xfdfc,
- 0xfe69, 0xfe69,
- 0xff04, 0xff04,
- 0xffe0, 0xffe1,
- 0xffe5, 0xffe6,
- 0x11fdd, 0x11fe0,
- 0x1e2ff, 0x1e2ff,
- 0x1ecb0, 0x1ecb0,
-}; /* CR_Sc */
-
-/* 'Sk': General Category */
-static const OnigCodePoint CR_Sk[] = {
- 31,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b8, 0x00b8,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02eb,
- 0x02ed, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0375, 0x0375,
- 0x0384, 0x0385,
- 0x0888, 0x0888,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x309b, 0x309c,
- 0xa700, 0xa716,
- 0xa720, 0xa721,
- 0xa789, 0xa78a,
- 0xab5b, 0xab5b,
- 0xab6a, 0xab6b,
- 0xfbb2, 0xfbc2,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xffe3, 0xffe3,
- 0x1f3fb, 0x1f3ff,
-}; /* CR_Sk */
-
-/* 'Sm': General Category */
-static const OnigCodePoint CR_Sm[] = {
- 64,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00ac, 0x00ac,
- 0x00b1, 0x00b1,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x03f6, 0x03f6,
- 0x0606, 0x0608,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x2118, 0x2118,
- 0x2140, 0x2144,
- 0x214b, 0x214b,
- 0x2190, 0x2194,
- 0x219a, 0x219b,
- 0x21a0, 0x21a0,
- 0x21a3, 0x21a3,
- 0x21a6, 0x21a6,
- 0x21ae, 0x21ae,
- 0x21ce, 0x21cf,
- 0x21d2, 0x21d2,
- 0x21d4, 0x21d4,
- 0x21f4, 0x22ff,
- 0x2320, 0x2321,
- 0x237c, 0x237c,
- 0x239b, 0x23b3,
- 0x23dc, 0x23e1,
- 0x25b7, 0x25b7,
- 0x25c1, 0x25c1,
- 0x25f8, 0x25ff,
- 0x266f, 0x266f,
- 0x27c0, 0x27c4,
- 0x27c7, 0x27e5,
- 0x27f0, 0x27ff,
- 0x2900, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2aff,
- 0x2b30, 0x2b44,
- 0x2b47, 0x2b4c,
- 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,
- 0x1eef0, 0x1eef1,
-}; /* CR_Sm */
-
-/* 'So': General Category */
-static const OnigCodePoint CR_So[] = {
- 184,
- 0x00a6, 0x00a6,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x00b0, 0x00b0,
- 0x0482, 0x0482,
- 0x058d, 0x058e,
- 0x060e, 0x060f,
- 0x06de, 0x06de,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x07f6, 0x07f6,
- 0x09fa, 0x09fa,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bf8,
- 0x0bfa, 0x0bfa,
- 0x0c7f, 0x0c7f,
- 0x0d4f, 0x0d4f,
- 0x0d79, 0x0d79,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f13,
- 0x0f15, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fcf,
- 0x0fd5, 0x0fd8,
- 0x109e, 0x109f,
- 0x1390, 0x1399,
- 0x166d, 0x166d,
- 0x1940, 0x1940,
- 0x19de, 0x19ff,
- 0x1b61, 0x1b6a,
- 0x1b74, 0x1b7c,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2117,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x213a, 0x213b,
- 0x214a, 0x214a,
- 0x214c, 0x214d,
- 0x214f, 0x214f,
- 0x218a, 0x218b,
- 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,
- 0x23b4, 0x23db,
- 0x23e2, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x25b6,
- 0x25b8, 0x25c0,
- 0x25c2, 0x25f7,
- 0x2600, 0x266e,
- 0x2670, 0x2767,
- 0x2794, 0x27bf,
- 0x2800, 0x28ff,
- 0x2b00, 0x2b2f,
- 0x2b45, 0x2b46,
- 0x2b4d, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2bff,
- 0x2ce5, 0x2cea,
- 0x2e50, 0x2e51,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3004, 0x3004,
- 0x3012, 0x3013,
- 0x3020, 0x3020,
- 0x3036, 0x3037,
- 0x303e, 0x303f,
- 0x3190, 0x3191,
- 0x3196, 0x319f,
- 0x31c0, 0x31e3,
- 0x3200, 0x321e,
- 0x322a, 0x3247,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa828, 0xa82b,
- 0xa836, 0xa837,
- 0xa839, 0xa839,
- 0xaa77, 0xaa79,
- 0xfd40, 0xfd4f,
- 0xfdcf, 0xfdcf,
- 0xfdfd, 0xfdff,
- 0xffe4, 0xffe4,
- 0xffe8, 0xffe8,
- 0xffed, 0xffee,
- 0xfffc, 0xfffd,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x1018c, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10877, 0x10878,
- 0x10ac8, 0x10ac8,
- 0x1173f, 0x1173f,
- 0x11fd5, 0x11fdc,
- 0x11fe1, 0x11ff1,
- 0x16b3c, 0x16b3f,
- 0x16b45, 0x16b45,
- 0x1bc9c, 0x1bc9c,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1ea,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d800, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da86,
- 0x1e14f, 0x1e14f,
- 0x1ecac, 0x1ecac,
- 0x1ed2e, 0x1ed2e,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f10d, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f3fa,
- 0x1f400, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
-}; /* CR_So */
-
-/* 'Z': Major Category */
-static const OnigCodePoint CR_Z[] = {
- 8,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 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[] = {
- 7,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000,
-}; /* CR_Zs */
-
-/* 'Math': Derived Property */
-static const OnigCodePoint CR_Math[] = {
- 138,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x005e, 0x005e,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00ac, 0x00ac,
- 0x00b1, 0x00b1,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x03d0, 0x03d2,
- 0x03d5, 0x03d5,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f6,
- 0x0606, 0x0608,
- 0x2016, 0x2016,
- 0x2032, 0x2034,
- 0x2040, 0x2040,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x2061, 0x2064,
- 0x207a, 0x207e,
- 0x208a, 0x208e,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20e6,
- 0x20eb, 0x20ef,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2128, 0x2129,
- 0x212c, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2138,
- 0x213c, 0x2149,
- 0x214b, 0x214b,
- 0x2190, 0x21a7,
- 0x21a9, 0x21ae,
- 0x21b0, 0x21b1,
- 0x21b6, 0x21b7,
- 0x21bc, 0x21db,
- 0x21dd, 0x21dd,
- 0x21e4, 0x21e5,
- 0x21f4, 0x22ff,
- 0x2308, 0x230b,
- 0x2320, 0x2321,
- 0x237c, 0x237c,
- 0x239b, 0x23b5,
- 0x23b7, 0x23b7,
- 0x23d0, 0x23d0,
- 0x23dc, 0x23e2,
- 0x25a0, 0x25a1,
- 0x25ae, 0x25b7,
- 0x25bc, 0x25c1,
- 0x25c6, 0x25c7,
- 0x25ca, 0x25cb,
- 0x25cf, 0x25d3,
- 0x25e2, 0x25e2,
- 0x25e4, 0x25e4,
- 0x25e7, 0x25ec,
- 0x25f8, 0x25ff,
- 0x2605, 0x2606,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2660, 0x2663,
- 0x266d, 0x266f,
- 0x27c0, 0x27ff,
- 0x2900, 0x2aff,
- 0x2b30, 0x2b44,
- 0x2b47, 0x2b4c,
- 0xfb29, 0xfb29,
- 0xfe61, 0xfe66,
- 0xfe68, 0xfe68,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff3c, 0xff3c,
- 0xff3e, 0xff3e,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe2, 0xffe2,
- 0xffe9, 0xffec,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
-}; /* CR_Math */
-
-/* 'Alphabetic': Derived Property */
-#define CR_Alphabetic CR_Alpha
-
-/* 'Lowercase': Derived Property */
-#define CR_Lowercase CR_Lower
-
-/* 'Uppercase': Derived Property */
-#define CR_Uppercase CR_Upper
-
-/* 'Cased': Derived Property */
-static const OnigCodePoint CR_Cased[] = {
- 157,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x01ba,
- 0x01bc, 0x01bf,
- 0x01c4, 0x0293,
- 0x0295, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0560, 0x0588,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d00, 0x1dbf,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x217f,
- 0x2183, 0x2184,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69d,
- 0xa722, 0xa787,
- 0xa78b, 0xa78e,
- 0xa790, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa7f6,
- 0xa7f8, 0xa7fa,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10780, 0x10780,
- 0x10783, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 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, 0x1d7cb,
- 0x1df00, 0x1df09,
- 0x1df0b, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e900, 0x1e943,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Cased */
-
-/* 'Case_Ignorable': Derived Property */
-static const OnigCodePoint CR_Case_Ignorable[] = {
- 437,
- 0x0027, 0x0027,
- 0x002e, 0x002e,
- 0x003a, 0x003a,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00ad, 0x00ad,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b7, 0x00b8,
- 0x02b0, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x0384, 0x0385,
- 0x0387, 0x0387,
- 0x0483, 0x0489,
- 0x0559, 0x0559,
- 0x055f, 0x055f,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05f4, 0x05f4,
- 0x0600, 0x0605,
- 0x0610, 0x061a,
- 0x061c, 0x061c,
- 0x0640, 0x0640,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dd,
- 0x06df, 0x06e8,
- 0x06ea, 0x06ed,
- 0x070f, 0x070f,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0816, 0x082d,
- 0x0859, 0x085b,
- 0x0888, 0x0888,
- 0x0890, 0x0891,
- 0x0898, 0x089f,
- 0x08c9, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0971, 0x0971,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3f, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b55, 0x0b56,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3c, 0x0c3c,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d81,
- 0x0dca, 0x0dca,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e46, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x10fc, 0x10fc,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dd, 0x17dd,
- 0x180b, 0x180f,
- 0x1843, 0x1843,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b34,
- 0x1b36, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1c78, 0x1c7d,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dff,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x200b, 0x200f,
- 0x2018, 0x2019,
- 0x2024, 0x2024,
- 0x2027, 0x2027,
- 0x202a, 0x202e,
- 0x2060, 0x2064,
- 0x2066, 0x206f,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20f0,
- 0x2c7c, 0x2c7d,
- 0x2cef, 0x2cf1,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x2e2f, 0x2e2f,
- 0x3005, 0x3005,
- 0x302a, 0x302d,
- 0x3031, 0x3035,
- 0x303b, 0x303b,
- 0x3099, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa4f8, 0xa4fd,
- 0xa60c, 0xa60c,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa700, 0xa721,
- 0xa770, 0xa770,
- 0xa788, 0xa78a,
- 0xa7f2, 0xa7f4,
- 0xa7f8, 0xa7f9,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa82c, 0xa82c,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9cf, 0xa9cf,
- 0xa9e5, 0xa9e6,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa70, 0xaa70,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaadd, 0xaadd,
- 0xaaec, 0xaaed,
- 0xaaf3, 0xaaf4,
- 0xaaf6, 0xaaf6,
- 0xab5b, 0xab5f,
- 0xab69, 0xab6b,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfbb2, 0xfbc2,
- 0xfe00, 0xfe0f,
- 0xfe13, 0xfe13,
- 0xfe20, 0xfe2f,
- 0xfe52, 0xfe52,
- 0xfe55, 0xfe55,
- 0xfeff, 0xfeff,
- 0xff07, 0xff07,
- 0xff0e, 0xff0e,
- 0xff1a, 0xff1a,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe3, 0xffe3,
- 0xfff9, 0xfffb,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x11070, 0x11070,
- 0x11073, 0x11074,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x110bd, 0x110bd,
- 0x110c2, 0x110c2,
- 0x110cd, 0x110cd,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x111cf, 0x111cf,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x11340, 0x11340,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x1193b, 0x1193c,
- 0x1193e, 0x1193e,
- 0x11943, 0x11943,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x11f00, 0x11f01,
- 0x11f36, 0x11f3a,
- 0x11f40, 0x11f40,
- 0x11f42, 0x11f42,
- 0x13430, 0x13440,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe4,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1bc9d, 0x1bc9e,
- 0x1bca0, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d167, 0x1d169,
- 0x1d173, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e130, 0x1e13d,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e4eb, 0x1e4ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94b,
- 0x1f3fb, 0x1f3ff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Case_Ignorable */
-
-/* 'Changes_When_Lowercased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Lowercased[] = {
- 609,
- 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, 0x01c5,
- 0x01c7, 0x01c8,
- 0x01ca, 0x01cb,
- 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, 0x01f2,
- 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,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03cf, 0x03cf,
- 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,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13a0, 0x13f5,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 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,
- 0x1e9e, 0x1e9e,
- 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,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1f88, 0x1f8f,
- 0x1f98, 0x1f9f,
- 0x1fa8, 0x1faf,
- 0x1fb8, 0x1fbc,
- 0x1fc8, 0x1fcc,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffc,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2f,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 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,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c0, 0xa7c0,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c7,
- 0xa7c9, 0xa7c9,
- 0xa7d0, 0xa7d0,
- 0xa7d6, 0xa7d6,
- 0xa7d8, 0xa7d8,
- 0xa7f5, 0xa7f5,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1e900, 0x1e921,
-}; /* CR_Changes_When_Lowercased */
-
-/* 'Changes_When_Uppercased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Uppercased[] = {
- 627,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 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, 0x0137,
- 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, 0x018c,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019a,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01b9,
- 0x01bd, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c5, 0x01c6,
- 0x01c8, 0x01c9,
- 0x01cb, 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,
- 0x01f2, 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,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0233,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 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, 0x03fb,
- 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, 0x04cf,
- 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,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0561, 0x0587,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 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,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbc, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fcc, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x1ffc, 0x1ffc,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5f,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c73, 0x2c73,
- 0x2c76, 0x2c76,
- 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, 0x2ce3,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa72f,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa791, 0xa791,
- 0xa793, 0xa794,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c1, 0xa7c1,
- 0xa7c3, 0xa7c3,
- 0xa7c8, 0xa7c8,
- 0xa7ca, 0xa7ca,
- 0xa7d1, 0xa7d1,
- 0xa7d7, 0xa7d7,
- 0xa7d9, 0xa7d9,
- 0xa7f6, 0xa7f6,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1e922, 0x1e943,
-}; /* CR_Changes_When_Uppercased */
-
-/* 'Changes_When_Titlecased': Derived Property */
-static const OnigCodePoint CR_Changes_When_Titlecased[] = {
- 626,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 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, 0x0137,
- 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, 0x018c,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019a,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01b9,
- 0x01bd, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c4, 0x01c4,
- 0x01c6, 0x01c7,
- 0x01c9, 0x01ca,
- 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, 0x01f1,
- 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,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0233,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0242, 0x0242,
- 0x0247, 0x0247,
- 0x0249, 0x0249,
- 0x024b, 0x024b,
- 0x024d, 0x024d,
- 0x024f, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0371, 0x0371,
- 0x0373, 0x0373,
- 0x0377, 0x0377,
- 0x037b, 0x037d,
- 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, 0x03fb,
- 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, 0x04cf,
- 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,
- 0x04fb, 0x04fb,
- 0x04fd, 0x04fd,
- 0x04ff, 0x04ff,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0511, 0x0511,
- 0x0513, 0x0513,
- 0x0515, 0x0515,
- 0x0517, 0x0517,
- 0x0519, 0x0519,
- 0x051b, 0x051b,
- 0x051d, 0x051d,
- 0x051f, 0x051f,
- 0x0521, 0x0521,
- 0x0523, 0x0523,
- 0x0525, 0x0525,
- 0x0527, 0x0527,
- 0x0529, 0x0529,
- 0x052b, 0x052b,
- 0x052d, 0x052d,
- 0x052f, 0x052f,
- 0x0561, 0x0587,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 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,
- 0x1efb, 0x1efb,
- 0x1efd, 0x1efd,
- 0x1eff, 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,
- 0x214e, 0x214e,
- 0x2170, 0x217f,
- 0x2184, 0x2184,
- 0x24d0, 0x24e9,
- 0x2c30, 0x2c5f,
- 0x2c61, 0x2c61,
- 0x2c65, 0x2c66,
- 0x2c68, 0x2c68,
- 0x2c6a, 0x2c6a,
- 0x2c6c, 0x2c6c,
- 0x2c73, 0x2c73,
- 0x2c76, 0x2c76,
- 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, 0x2ce3,
- 0x2cec, 0x2cec,
- 0x2cee, 0x2cee,
- 0x2cf3, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa641, 0xa641,
- 0xa643, 0xa643,
- 0xa645, 0xa645,
- 0xa647, 0xa647,
- 0xa649, 0xa649,
- 0xa64b, 0xa64b,
- 0xa64d, 0xa64d,
- 0xa64f, 0xa64f,
- 0xa651, 0xa651,
- 0xa653, 0xa653,
- 0xa655, 0xa655,
- 0xa657, 0xa657,
- 0xa659, 0xa659,
- 0xa65b, 0xa65b,
- 0xa65d, 0xa65d,
- 0xa65f, 0xa65f,
- 0xa661, 0xa661,
- 0xa663, 0xa663,
- 0xa665, 0xa665,
- 0xa667, 0xa667,
- 0xa669, 0xa669,
- 0xa66b, 0xa66b,
- 0xa66d, 0xa66d,
- 0xa681, 0xa681,
- 0xa683, 0xa683,
- 0xa685, 0xa685,
- 0xa687, 0xa687,
- 0xa689, 0xa689,
- 0xa68b, 0xa68b,
- 0xa68d, 0xa68d,
- 0xa68f, 0xa68f,
- 0xa691, 0xa691,
- 0xa693, 0xa693,
- 0xa695, 0xa695,
- 0xa697, 0xa697,
- 0xa699, 0xa699,
- 0xa69b, 0xa69b,
- 0xa723, 0xa723,
- 0xa725, 0xa725,
- 0xa727, 0xa727,
- 0xa729, 0xa729,
- 0xa72b, 0xa72b,
- 0xa72d, 0xa72d,
- 0xa72f, 0xa72f,
- 0xa733, 0xa733,
- 0xa735, 0xa735,
- 0xa737, 0xa737,
- 0xa739, 0xa739,
- 0xa73b, 0xa73b,
- 0xa73d, 0xa73d,
- 0xa73f, 0xa73f,
- 0xa741, 0xa741,
- 0xa743, 0xa743,
- 0xa745, 0xa745,
- 0xa747, 0xa747,
- 0xa749, 0xa749,
- 0xa74b, 0xa74b,
- 0xa74d, 0xa74d,
- 0xa74f, 0xa74f,
- 0xa751, 0xa751,
- 0xa753, 0xa753,
- 0xa755, 0xa755,
- 0xa757, 0xa757,
- 0xa759, 0xa759,
- 0xa75b, 0xa75b,
- 0xa75d, 0xa75d,
- 0xa75f, 0xa75f,
- 0xa761, 0xa761,
- 0xa763, 0xa763,
- 0xa765, 0xa765,
- 0xa767, 0xa767,
- 0xa769, 0xa769,
- 0xa76b, 0xa76b,
- 0xa76d, 0xa76d,
- 0xa76f, 0xa76f,
- 0xa77a, 0xa77a,
- 0xa77c, 0xa77c,
- 0xa77f, 0xa77f,
- 0xa781, 0xa781,
- 0xa783, 0xa783,
- 0xa785, 0xa785,
- 0xa787, 0xa787,
- 0xa78c, 0xa78c,
- 0xa791, 0xa791,
- 0xa793, 0xa794,
- 0xa797, 0xa797,
- 0xa799, 0xa799,
- 0xa79b, 0xa79b,
- 0xa79d, 0xa79d,
- 0xa79f, 0xa79f,
- 0xa7a1, 0xa7a1,
- 0xa7a3, 0xa7a3,
- 0xa7a5, 0xa7a5,
- 0xa7a7, 0xa7a7,
- 0xa7a9, 0xa7a9,
- 0xa7b5, 0xa7b5,
- 0xa7b7, 0xa7b7,
- 0xa7b9, 0xa7b9,
- 0xa7bb, 0xa7bb,
- 0xa7bd, 0xa7bd,
- 0xa7bf, 0xa7bf,
- 0xa7c1, 0xa7c1,
- 0xa7c3, 0xa7c3,
- 0xa7c8, 0xa7c8,
- 0xa7ca, 0xa7ca,
- 0xa7d1, 0xa7d1,
- 0xa7d7, 0xa7d7,
- 0xa7d9, 0xa7d9,
- 0xa7f6, 0xa7f6,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x104d8, 0x104fb,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10cc0, 0x10cf2,
- 0x118c0, 0x118df,
- 0x16e60, 0x16e7f,
- 0x1e922, 0x1e943,
-}; /* CR_Changes_When_Titlecased */
-
-/* 'Changes_When_Casefolded': Derived Property */
-static const OnigCodePoint CR_Changes_When_Casefolded[] = {
- 622,
- 0x0041, 0x005a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00df,
- 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,
- 0x0149, 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,
- 0x017f, 0x017f,
- 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, 0x01c5,
- 0x01c7, 0x01c8,
- 0x01ca, 0x01cb,
- 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, 0x01f2,
- 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,
- 0x0243, 0x0246,
- 0x0248, 0x0248,
- 0x024a, 0x024a,
- 0x024c, 0x024c,
- 0x024e, 0x024e,
- 0x0345, 0x0345,
- 0x0370, 0x0370,
- 0x0372, 0x0372,
- 0x0376, 0x0376,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03c2, 0x03c2,
- 0x03cf, 0x03d1,
- 0x03d5, 0x03d6,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f5,
- 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,
- 0x04fa, 0x04fa,
- 0x04fc, 0x04fc,
- 0x04fe, 0x04fe,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0510, 0x0510,
- 0x0512, 0x0512,
- 0x0514, 0x0514,
- 0x0516, 0x0516,
- 0x0518, 0x0518,
- 0x051a, 0x051a,
- 0x051c, 0x051c,
- 0x051e, 0x051e,
- 0x0520, 0x0520,
- 0x0522, 0x0522,
- 0x0524, 0x0524,
- 0x0526, 0x0526,
- 0x0528, 0x0528,
- 0x052a, 0x052a,
- 0x052c, 0x052c,
- 0x052e, 0x052e,
- 0x0531, 0x0556,
- 0x0587, 0x0587,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 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,
- 0x1e9a, 0x1e9b,
- 0x1e9e, 0x1e9e,
- 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,
- 0x1efa, 0x1efa,
- 0x1efc, 0x1efc,
- 0x1efe, 0x1efe,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1f80, 0x1faf,
- 0x1fb2, 0x1fb4,
- 0x1fb7, 0x1fbc,
- 0x1fc2, 0x1fc4,
- 0x1fc7, 0x1fcc,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff7, 0x1ffc,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x2160, 0x216f,
- 0x2183, 0x2183,
- 0x24b6, 0x24cf,
- 0x2c00, 0x2c2f,
- 0x2c60, 0x2c60,
- 0x2c62, 0x2c64,
- 0x2c67, 0x2c67,
- 0x2c69, 0x2c69,
- 0x2c6b, 0x2c6b,
- 0x2c6d, 0x2c70,
- 0x2c72, 0x2c72,
- 0x2c75, 0x2c75,
- 0x2c7e, 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,
- 0x2ceb, 0x2ceb,
- 0x2ced, 0x2ced,
- 0x2cf2, 0x2cf2,
- 0xa640, 0xa640,
- 0xa642, 0xa642,
- 0xa644, 0xa644,
- 0xa646, 0xa646,
- 0xa648, 0xa648,
- 0xa64a, 0xa64a,
- 0xa64c, 0xa64c,
- 0xa64e, 0xa64e,
- 0xa650, 0xa650,
- 0xa652, 0xa652,
- 0xa654, 0xa654,
- 0xa656, 0xa656,
- 0xa658, 0xa658,
- 0xa65a, 0xa65a,
- 0xa65c, 0xa65c,
- 0xa65e, 0xa65e,
- 0xa660, 0xa660,
- 0xa662, 0xa662,
- 0xa664, 0xa664,
- 0xa666, 0xa666,
- 0xa668, 0xa668,
- 0xa66a, 0xa66a,
- 0xa66c, 0xa66c,
- 0xa680, 0xa680,
- 0xa682, 0xa682,
- 0xa684, 0xa684,
- 0xa686, 0xa686,
- 0xa688, 0xa688,
- 0xa68a, 0xa68a,
- 0xa68c, 0xa68c,
- 0xa68e, 0xa68e,
- 0xa690, 0xa690,
- 0xa692, 0xa692,
- 0xa694, 0xa694,
- 0xa696, 0xa696,
- 0xa698, 0xa698,
- 0xa69a, 0xa69a,
- 0xa722, 0xa722,
- 0xa724, 0xa724,
- 0xa726, 0xa726,
- 0xa728, 0xa728,
- 0xa72a, 0xa72a,
- 0xa72c, 0xa72c,
- 0xa72e, 0xa72e,
- 0xa732, 0xa732,
- 0xa734, 0xa734,
- 0xa736, 0xa736,
- 0xa738, 0xa738,
- 0xa73a, 0xa73a,
- 0xa73c, 0xa73c,
- 0xa73e, 0xa73e,
- 0xa740, 0xa740,
- 0xa742, 0xa742,
- 0xa744, 0xa744,
- 0xa746, 0xa746,
- 0xa748, 0xa748,
- 0xa74a, 0xa74a,
- 0xa74c, 0xa74c,
- 0xa74e, 0xa74e,
- 0xa750, 0xa750,
- 0xa752, 0xa752,
- 0xa754, 0xa754,
- 0xa756, 0xa756,
- 0xa758, 0xa758,
- 0xa75a, 0xa75a,
- 0xa75c, 0xa75c,
- 0xa75e, 0xa75e,
- 0xa760, 0xa760,
- 0xa762, 0xa762,
- 0xa764, 0xa764,
- 0xa766, 0xa766,
- 0xa768, 0xa768,
- 0xa76a, 0xa76a,
- 0xa76c, 0xa76c,
- 0xa76e, 0xa76e,
- 0xa779, 0xa779,
- 0xa77b, 0xa77b,
- 0xa77d, 0xa77e,
- 0xa780, 0xa780,
- 0xa782, 0xa782,
- 0xa784, 0xa784,
- 0xa786, 0xa786,
- 0xa78b, 0xa78b,
- 0xa78d, 0xa78d,
- 0xa790, 0xa790,
- 0xa792, 0xa792,
- 0xa796, 0xa796,
- 0xa798, 0xa798,
- 0xa79a, 0xa79a,
- 0xa79c, 0xa79c,
- 0xa79e, 0xa79e,
- 0xa7a0, 0xa7a0,
- 0xa7a2, 0xa7a2,
- 0xa7a4, 0xa7a4,
- 0xa7a6, 0xa7a6,
- 0xa7a8, 0xa7a8,
- 0xa7aa, 0xa7ae,
- 0xa7b0, 0xa7b4,
- 0xa7b6, 0xa7b6,
- 0xa7b8, 0xa7b8,
- 0xa7ba, 0xa7ba,
- 0xa7bc, 0xa7bc,
- 0xa7be, 0xa7be,
- 0xa7c0, 0xa7c0,
- 0xa7c2, 0xa7c2,
- 0xa7c4, 0xa7c7,
- 0xa7c9, 0xa7c9,
- 0xa7d0, 0xa7d0,
- 0xa7d6, 0xa7d6,
- 0xa7d8, 0xa7d8,
- 0xa7f5, 0xa7f5,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x104b0, 0x104d3,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10c80, 0x10cb2,
- 0x118a0, 0x118bf,
- 0x16e40, 0x16e5f,
- 0x1e900, 0x1e921,
-}; /* CR_Changes_When_Casefolded */
-
-/* 'Changes_When_Casemapped': Derived Property */
-static const OnigCodePoint CR_Changes_When_Casemapped[] = {
- 131,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00b5, 0x00b5,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0137,
- 0x0139, 0x018c,
- 0x018e, 0x019a,
- 0x019c, 0x01a9,
- 0x01ac, 0x01b9,
- 0x01bc, 0x01bd,
- 0x01bf, 0x01bf,
- 0x01c4, 0x0220,
- 0x0222, 0x0233,
- 0x023a, 0x0254,
- 0x0256, 0x0257,
- 0x0259, 0x0259,
- 0x025b, 0x025c,
- 0x0260, 0x0261,
- 0x0263, 0x0263,
- 0x0265, 0x0266,
- 0x0268, 0x026c,
- 0x026f, 0x026f,
- 0x0271, 0x0272,
- 0x0275, 0x0275,
- 0x027d, 0x027d,
- 0x0280, 0x0280,
- 0x0282, 0x0283,
- 0x0287, 0x028c,
- 0x0292, 0x0292,
- 0x029d, 0x029e,
- 0x0345, 0x0345,
- 0x0370, 0x0373,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03d1,
- 0x03d5, 0x03f5,
- 0x03f7, 0x03fb,
- 0x03fd, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0561, 0x0587,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fd, 0x10ff,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1d79, 0x1d79,
- 0x1d7d, 0x1d7d,
- 0x1d8e, 0x1d8e,
- 0x1e00, 0x1e9b,
- 0x1e9e, 0x1e9e,
- 0x1ea0, 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,
- 0x2126, 0x2126,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x214e, 0x214e,
- 0x2160, 0x217f,
- 0x2183, 0x2184,
- 0x24b6, 0x24e9,
- 0x2c00, 0x2c70,
- 0x2c72, 0x2c73,
- 0x2c75, 0x2c76,
- 0x2c7e, 0x2ce3,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0xa640, 0xa66d,
- 0xa680, 0xa69b,
- 0xa722, 0xa72f,
- 0xa732, 0xa76f,
- 0xa779, 0xa787,
- 0xa78b, 0xa78d,
- 0xa790, 0xa794,
- 0xa796, 0xa7ae,
- 0xa7b0, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d6, 0xa7d9,
- 0xa7f5, 0xa7f6,
- 0xab53, 0xab53,
- 0xab70, 0xabbf,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10400, 0x1044f,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x118a0, 0x118df,
- 0x16e40, 0x16e7f,
- 0x1e900, 0x1e943,
-}; /* CR_Changes_When_Casemapped */
-
-/* 'ID_Start': Derived Property */
-static const OnigCodePoint CR_ID_Start[] = {
- 659,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c9,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 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,
- 0x0af9, 0x0af9,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d04, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1711,
- 0x171f, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4c,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309b, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10e80, 0x10ea9,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11071, 0x11072,
- 0x11075, 0x11075,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11147, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x1123f, 0x11240,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x11461,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11740, 0x11746,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x1192f,
- 0x1193f, 0x1193f,
- 0x11941, 0x11941,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x11f02, 0x11f02,
- 0x11f04, 0x11f10,
- 0x11f12, 0x11f33,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a70, 0x16abe,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 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, 0x1d7cb,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e4d0, 0x1e4eb,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_ID_Start */
-
-/* 'ID_Continue': Derived Property */
-static const OnigCodePoint CR_ID_Continue[] = {
- 768,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00b7, 0x00b7,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0487,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x0898, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 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,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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,
- 0x135d, 0x135f,
- 0x1369, 0x1371,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x180f, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abd,
- 0x1abf, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 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,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66f,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa827,
- 0xa82c, 0xa82c,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 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, 0xfe2f,
- 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,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10eac,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10f70, 0x10f85,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x11075,
- 0x1107f, 0x110ba,
- 0x110c2, 0x110c2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11147,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111ce, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x11461,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11740, 0x11746,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11943,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f42,
- 0x11f50, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13440, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a70, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0100, 0xe01ef,
-}; /* CR_ID_Continue */
-
-/* 'XID_Start': Derived Property */
-static const OnigCodePoint CR_XID_Start[] = {
- 666,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0370, 0x0374,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0620, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07ca, 0x07ea,
- 0x07f4, 0x07f5,
- 0x07fa, 0x07fa,
- 0x0800, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0840, 0x0858,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x08a0, 0x08c9,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x0971, 0x0980,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x09fc, 0x09fc,
- 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,
- 0x0af9, 0x0af9,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c61,
- 0x0c80, 0x0c80,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0cf1, 0x0cf2,
- 0x0d04, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d4e, 0x0d4e,
- 0x0d54, 0x0d56,
- 0x0d5f, 0x0d61,
- 0x0d7a, 0x0d7f,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e32,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb2,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f88, 0x0f8c,
- 0x1000, 0x102a,
- 0x103f, 0x103f,
- 0x1050, 0x1055,
- 0x105a, 0x105d,
- 0x1061, 0x1061,
- 0x1065, 0x1066,
- 0x106e, 0x1070,
- 0x1075, 0x1081,
- 0x108e, 0x108e,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1711,
- 0x171f, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1878,
- 0x1880, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a16,
- 0x1a20, 0x1a54,
- 0x1aa7, 0x1aa7,
- 0x1b05, 0x1b33,
- 0x1b45, 0x1b4c,
- 0x1b83, 0x1ba0,
- 0x1bae, 0x1baf,
- 0x1bba, 0x1be5,
- 0x1c00, 0x1c23,
- 0x1c4d, 0x1c4f,
- 0x1c5a, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf6,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 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, 0x209c,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3007,
- 0x3021, 0x3029,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa61f,
- 0xa62a, 0xa62b,
- 0xa640, 0xa66e,
- 0xa67f, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xa840, 0xa873,
- 0xa882, 0xa8b3,
- 0xa8f2, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa8fe,
- 0xa90a, 0xa925,
- 0xa930, 0xa946,
- 0xa960, 0xa97c,
- 0xa984, 0xa9b2,
- 0xa9cf, 0xa9cf,
- 0xa9e0, 0xa9e4,
- 0xa9e6, 0xa9ef,
- 0xa9fa, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaa7a,
- 0xaa7e, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaea,
- 0xaaf2, 0xaaf4,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabe2,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfc5d,
- 0xfc64, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdf9,
- 0xfe71, 0xfe71,
- 0xfe73, 0xfe73,
- 0xfe77, 0xfe77,
- 0xfe79, 0xfe79,
- 0xfe7b, 0xfe7b,
- 0xfe7d, 0xfe7d,
- 0xfe7f, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 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,
- 0x10140, 0x10174,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae4,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d23,
- 0x10e80, 0x10ea9,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f70, 0x10f81,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11003, 0x11037,
- 0x11071, 0x11072,
- 0x11075, 0x11075,
- 0x11083, 0x110af,
- 0x110d0, 0x110e8,
- 0x11103, 0x11126,
- 0x11144, 0x11144,
- 0x11147, 0x11147,
- 0x11150, 0x11172,
- 0x11176, 0x11176,
- 0x11183, 0x111b2,
- 0x111c1, 0x111c4,
- 0x111da, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x1122b,
- 0x1123f, 0x11240,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112de,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x11350, 0x11350,
- 0x1135d, 0x11361,
- 0x11400, 0x11434,
- 0x11447, 0x1144a,
- 0x1145f, 0x11461,
- 0x11480, 0x114af,
- 0x114c4, 0x114c5,
- 0x114c7, 0x114c7,
- 0x11580, 0x115ae,
- 0x115d8, 0x115db,
- 0x11600, 0x1162f,
- 0x11644, 0x11644,
- 0x11680, 0x116aa,
- 0x116b8, 0x116b8,
- 0x11700, 0x1171a,
- 0x11740, 0x11746,
- 0x11800, 0x1182b,
- 0x118a0, 0x118df,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x1192f,
- 0x1193f, 0x1193f,
- 0x11941, 0x11941,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d0,
- 0x119e1, 0x119e1,
- 0x119e3, 0x119e3,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a3a, 0x11a3a,
- 0x11a50, 0x11a50,
- 0x11a5c, 0x11a89,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2e,
- 0x11c40, 0x11c40,
- 0x11c72, 0x11c8f,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d89,
- 0x11d98, 0x11d98,
- 0x11ee0, 0x11ef2,
- 0x11f02, 0x11f02,
- 0x11f04, 0x11f10,
- 0x11f12, 0x11f33,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a70, 0x16abe,
- 0x16ad0, 0x16aed,
- 0x16b00, 0x16b2f,
- 0x16b40, 0x16b43,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f50,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 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, 0x1d7cb,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e4d0, 0x1e4eb,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_XID_Start */
-
-/* 'XID_Continue': Derived Property */
-static const OnigCodePoint CR_XID_Continue[] = {
- 775,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00b7, 0x00b7,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ec, 0x02ec,
- 0x02ee, 0x02ee,
- 0x0300, 0x0374,
- 0x0376, 0x0377,
- 0x037b, 0x037d,
- 0x037f, 0x037f,
- 0x0386, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0487,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0560, 0x0588,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f2,
- 0x0610, 0x061a,
- 0x0620, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06df, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07f5,
- 0x07fa, 0x07fa,
- 0x07fd, 0x07fd,
- 0x0800, 0x082d,
- 0x0840, 0x085b,
- 0x0860, 0x086a,
- 0x0870, 0x0887,
- 0x0889, 0x088e,
- 0x0898, 0x08e1,
- 0x08e3, 0x0963,
- 0x0966, 0x096f,
- 0x0971, 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,
- 0x09fc, 0x09fc,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c80, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d54, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d6f,
- 0x0d7a, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1049,
- 0x1050, 0x109d,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 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,
- 0x135d, 0x135f,
- 0x1369, 0x1371,
- 0x1380, 0x138f,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1401, 0x166c,
- 0x166f, 0x167f,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x180f, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x1a00, 0x1a1b,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa7, 0x1aa7,
- 0x1ab0, 0x1abd,
- 0x1abf, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b59,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1bf3,
- 0x1c00, 0x1c37,
- 0x1c40, 0x1c49,
- 0x1c4d, 0x1c7d,
- 0x1c80, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1cfa,
- 0x1d00, 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,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20f0,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2118, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c00, 0x2ce4,
- 0x2ceb, 0x2cf3,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d6f,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2dff,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x31a0, 0x31bf,
- 0x31f0, 0x31ff,
- 0x3400, 0x4dbf,
- 0x4e00, 0xa48c,
- 0xa4d0, 0xa4fd,
- 0xa500, 0xa60c,
- 0xa610, 0xa62b,
- 0xa640, 0xa66f,
- 0xa674, 0xa67d,
- 0xa67f, 0xa6f1,
- 0xa717, 0xa71f,
- 0xa722, 0xa788,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa827,
- 0xa82c, 0xa82c,
- 0xa840, 0xa873,
- 0xa880, 0xa8c5,
- 0xa8d0, 0xa8d9,
- 0xa8e0, 0xa8f7,
- 0xa8fb, 0xa8fb,
- 0xa8fd, 0xa92d,
- 0xa930, 0xa953,
- 0xa960, 0xa97c,
- 0xa980, 0xa9c0,
- 0xa9cf, 0xa9d9,
- 0xa9e0, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa60, 0xaa76,
- 0xaa7a, 0xaac2,
- 0xaadb, 0xaadd,
- 0xaae0, 0xaaef,
- 0xaaf2, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5a,
- 0xab5c, 0xab69,
- 0xab70, 0xabea,
- 0xabec, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfc5d,
- 0xfc64, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdf9,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xfe71, 0xfe71,
- 0xfe73, 0xfe73,
- 0xfe77, 0xfe77,
- 0xfe79, 0xfe79,
- 0xfe7b, 0xfe7b,
- 0xfe7d, 0xfe7d,
- 0xfe7f, 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,
- 0x10140, 0x10174,
- 0x101fd, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102e0,
- 0x10300, 0x1031f,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10860, 0x10876,
- 0x10880, 0x1089e,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x10900, 0x10915,
- 0x10920, 0x10939,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10a60, 0x10a7c,
- 0x10a80, 0x10a9c,
- 0x10ac0, 0x10ac7,
- 0x10ac9, 0x10ae6,
- 0x10b00, 0x10b35,
- 0x10b40, 0x10b55,
- 0x10b60, 0x10b72,
- 0x10b80, 0x10b91,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10eac,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f1c,
- 0x10f27, 0x10f27,
- 0x10f30, 0x10f50,
- 0x10f70, 0x10f85,
- 0x10fb0, 0x10fc4,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11046,
- 0x11066, 0x11075,
- 0x1107f, 0x110ba,
- 0x110c2, 0x110c2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x1113f,
- 0x11144, 0x11147,
- 0x11150, 0x11173,
- 0x11176, 0x11176,
- 0x11180, 0x111c4,
- 0x111c9, 0x111cc,
- 0x111ce, 0x111da,
- 0x111dc, 0x111dc,
- 0x11200, 0x11211,
- 0x11213, 0x11237,
- 0x1123e, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a8,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1144a,
- 0x11450, 0x11459,
- 0x1145e, 0x11461,
- 0x11480, 0x114c5,
- 0x114c7, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c0,
- 0x115d8, 0x115dd,
- 0x11600, 0x11640,
- 0x11644, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11739,
- 0x11740, 0x11746,
- 0x11800, 0x1183a,
- 0x118a0, 0x118e9,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11943,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e1,
- 0x119e3, 0x119e4,
- 0x11a00, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a50, 0x11a99,
- 0x11a9d, 0x11a9d,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c40,
- 0x11c50, 0x11c59,
- 0x11c72, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef6,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f42,
- 0x11f50, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff0,
- 0x13000, 0x1342f,
- 0x13440, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a70, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af4,
- 0x16b00, 0x16b36,
- 0x16b40, 0x16b43,
- 0x16b50, 0x16b59,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e7f,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14e,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8d0, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
- 0xe0100, 0xe01ef,
-}; /* CR_XID_Continue */
-
-/* 'Default_Ignorable_Code_Point': Derived Property */
-static const OnigCodePoint CR_Default_Ignorable_Code_Point[] = {
- 17,
- 0x00ad, 0x00ad,
- 0x034f, 0x034f,
- 0x061c, 0x061c,
- 0x115f, 0x1160,
- 0x17b4, 0x17b5,
- 0x180b, 0x180f,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x206f,
- 0x3164, 0x3164,
- 0xfe00, 0xfe0f,
- 0xfeff, 0xfeff,
- 0xffa0, 0xffa0,
- 0xfff0, 0xfff8,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0000, 0xe0fff,
-}; /* CR_Default_Ignorable_Code_Point */
-
-/* 'Grapheme_Extend': Derived Property */
-static const OnigCodePoint CR_Grapheme_Extend[] = {
- 363,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x0898, 0x089f,
- 0x08ca, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09be, 0x09be,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bbe,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3c, 0x0c3c,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc2, 0x0cc2,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d3e,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d81,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dcf,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0ddf, 0x0ddf,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ece,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x180f, 0x180f,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1dff,
- 0x200c, 0x200c,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa82c, 0xa82c,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xff9e, 0xff9f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x11070, 0x11070,
- 0x11073, 0x11074,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x110c2, 0x110c2,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x111cf, 0x111cf,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x1133e, 0x1133e,
- 0x11340, 0x11340,
- 0x11357, 0x11357,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114b0,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bd, 0x114bd,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115af, 0x115af,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x11930, 0x11930,
- 0x1193b, 0x1193c,
- 0x1193e, 0x1193e,
- 0x11943, 0x11943,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x11f00, 0x11f01,
- 0x11f36, 0x11f3a,
- 0x11f40, 0x11f40,
- 0x11f42, 0x11f42,
- 0x13440, 0x13440,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x16fe4, 0x16fe4,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d165, 0x1d165,
- 0x1d167, 0x1d169,
- 0x1d16e, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e08f, 0x1e08f,
- 0x1e130, 0x1e136,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e4ec, 0x1e4ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Grapheme_Extend */
-
-/* 'Grapheme_Base': Derived Property */
-static const OnigCodePoint CR_Grapheme_Base[] = {
- 875,
- 0x0020, 0x007e,
- 0x00a0, 0x00ac,
- 0x00ae, 0x02ff,
- 0x0370, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0482,
- 0x048a, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0606, 0x060f,
- 0x061b, 0x061b,
- 0x061d, 0x064a,
- 0x0660, 0x066f,
- 0x0671, 0x06d5,
- 0x06de, 0x06de,
- 0x06e5, 0x06e6,
- 0x06e9, 0x06e9,
- 0x06ee, 0x070d,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x07a5,
- 0x07b1, 0x07b1,
- 0x07c0, 0x07ea,
- 0x07f4, 0x07fa,
- 0x07fe, 0x0815,
- 0x081a, 0x081a,
- 0x0824, 0x0824,
- 0x0828, 0x0828,
- 0x0830, 0x083e,
- 0x0840, 0x0858,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x08a0, 0x08c9,
- 0x0903, 0x0939,
- 0x093b, 0x093b,
- 0x093d, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x0950,
- 0x0958, 0x0961,
- 0x0964, 0x0980,
- 0x0982, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09bf, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09e6, 0x09fd,
- 0x0a03, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3e, 0x0a40,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a6f,
- 0x0a72, 0x0a74,
- 0x0a76, 0x0a76,
- 0x0a83, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0ae6, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b02, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b77,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbf, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd0, 0x0bd0,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c3d,
- 0x0c41, 0x0c44,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c80,
- 0x0c82, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbe,
- 0x0cc0, 0x0cc1,
- 0x0cc3, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d02, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d3d,
- 0x0d3f, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d4e, 0x0d4f,
- 0x0d54, 0x0d56,
- 0x0d58, 0x0d61,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dd0, 0x0dd1,
- 0x0dd8, 0x0dde,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e3f, 0x0e46,
- 0x0e4f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f17,
- 0x0f1a, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0f3a, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f7f, 0x0f7f,
- 0x0f85, 0x0f85,
- 0x0f88, 0x0f8c,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x102c,
- 0x1031, 0x1031,
- 0x1038, 0x1038,
- 0x103b, 0x103c,
- 0x103f, 0x1057,
- 0x105a, 0x105d,
- 0x1061, 0x1070,
- 0x1075, 0x1081,
- 0x1083, 0x1084,
- 0x1087, 0x108c,
- 0x108e, 0x109c,
- 0x109e, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x1360, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1711,
- 0x1715, 0x1715,
- 0x171f, 0x1731,
- 0x1734, 0x1736,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x17d4, 0x17dc,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180a,
- 0x1810, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x1884,
- 0x1887, 0x18a8,
- 0x18aa, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a16,
- 0x1a19, 0x1a1a,
- 0x1a1e, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a61, 0x1a61,
- 0x1a63, 0x1a64,
- 0x1a6d, 0x1a72,
- 0x1a80, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b04, 0x1b33,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b4c,
- 0x1b50, 0x1b6a,
- 0x1b74, 0x1b7e,
- 0x1b82, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1bae, 0x1be5,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1bfc, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd3, 0x1cd3,
- 0x1ce1, 0x1ce1,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf7,
- 0x1cfa, 0x1cfa,
- 0x1d00, 0x1dbf,
- 0x1e00, 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, 0x200a,
- 0x2010, 0x2027,
- 0x202f, 0x205f,
- 0x2070, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cee,
- 0x2cf2, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x3029,
- 0x3030, 0x303f,
- 0x3041, 0x3096,
- 0x309b, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa66e,
- 0xa673, 0xa673,
- 0xa67e, 0xa69d,
- 0xa6a0, 0xa6ef,
- 0xa6f2, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa824,
- 0xa827, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c3,
- 0xa8ce, 0xa8d9,
- 0xa8f2, 0xa8fe,
- 0xa900, 0xa925,
- 0xa92e, 0xa946,
- 0xa952, 0xa953,
- 0xa95f, 0xa97c,
- 0xa983, 0xa9b2,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9e4,
- 0xa9e6, 0xa9fe,
- 0xaa00, 0xaa28,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa40, 0xaa42,
- 0xaa44, 0xaa4b,
- 0xaa4d, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa7d, 0xaaaf,
- 0xaab1, 0xaab1,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaabd,
- 0xaac0, 0xaac0,
- 0xaac2, 0xaac2,
- 0xaadb, 0xaaeb,
- 0xaaee, 0xaaf5,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabec,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfdcf,
- 0xfdf0, 0xfdff,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff01, 0xff9d,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fc,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e1, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x10375,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a40, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae4,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d23,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10ead, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f45,
- 0x10f51, 0x10f59,
- 0x10f70, 0x10f81,
- 0x10f86, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x11000,
- 0x11002, 0x11037,
- 0x11047, 0x1104d,
- 0x11052, 0x1106f,
- 0x11071, 0x11072,
- 0x11075, 0x11075,
- 0x11082, 0x110b2,
- 0x110b7, 0x110b8,
- 0x110bb, 0x110bc,
- 0x110be, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11103, 0x11126,
- 0x1112c, 0x1112c,
- 0x11136, 0x11147,
- 0x11150, 0x11172,
- 0x11174, 0x11176,
- 0x11182, 0x111b5,
- 0x111bf, 0x111c8,
- 0x111cd, 0x111ce,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x11238, 0x1123d,
- 0x1123f, 0x11240,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112de,
- 0x112e0, 0x112e2,
- 0x112f0, 0x112f9,
- 0x11302, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133d, 0x1133d,
- 0x1133f, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x1135d, 0x11363,
- 0x11400, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x11447, 0x1145b,
- 0x1145d, 0x1145d,
- 0x1145f, 0x11461,
- 0x11480, 0x114af,
- 0x114b1, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114bc,
- 0x114be, 0x114be,
- 0x114c1, 0x114c1,
- 0x114c4, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115ae,
- 0x115b0, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x115c1, 0x115db,
- 0x11600, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x11641, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116aa,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x116b8, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x11720, 0x11721,
- 0x11726, 0x11726,
- 0x11730, 0x11746,
- 0x11800, 0x1182e,
- 0x11838, 0x11838,
- 0x1183b, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x1192f,
- 0x11931, 0x11935,
- 0x11937, 0x11938,
- 0x1193d, 0x1193d,
- 0x1193f, 0x11942,
- 0x11944, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e1, 0x119e4,
- 0x11a00, 0x11a00,
- 0x11a0b, 0x11a32,
- 0x11a39, 0x11a3a,
- 0x11a3f, 0x11a46,
- 0x11a50, 0x11a50,
- 0x11a57, 0x11a58,
- 0x11a5c, 0x11a89,
- 0x11a97, 0x11a97,
- 0x11a9a, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11b00, 0x11b09,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11c40, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d30,
- 0x11d46, 0x11d46,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11d98, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef2,
- 0x11ef5, 0x11ef8,
- 0x11f02, 0x11f10,
- 0x11f12, 0x11f35,
- 0x11f3e, 0x11f3f,
- 0x11f41, 0x11f41,
- 0x11f43, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x1342f,
- 0x13441, 0x13446,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af5, 0x16af5,
- 0x16b00, 0x16b2f,
- 0x16b37, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f50, 0x16f87,
- 0x16f93, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bc9c,
- 0x1bc9f, 0x1bc9f,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d164,
- 0x1d166, 0x1d166,
- 0x1d16a, 0x1d16d,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1ea,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d9ff,
- 0x1da37, 0x1da3a,
- 0x1da6d, 0x1da74,
- 0x1da76, 0x1da83,
- 0x1da85, 0x1da8b,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e030, 0x1e06d,
- 0x1e100, 0x1e12c,
- 0x1e137, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ad,
- 0x1e2c0, 0x1e2eb,
- 0x1e2f0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e4d0, 0x1e4eb,
- 0x1e4f0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8cf,
- 0x1e900, 0x1e943,
- 0x1e94b, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Grapheme_Base */
-
-/* 'Grapheme_Link': Derived Property */
-static const OnigCodePoint CR_Grapheme_Link[] = {
- 56,
- 0x094d, 0x094d,
- 0x09cd, 0x09cd,
- 0x0a4d, 0x0a4d,
- 0x0acd, 0x0acd,
- 0x0b4d, 0x0b4d,
- 0x0bcd, 0x0bcd,
- 0x0c4d, 0x0c4d,
- 0x0ccd, 0x0ccd,
- 0x0d3b, 0x0d3c,
- 0x0d4d, 0x0d4d,
- 0x0dca, 0x0dca,
- 0x0e3a, 0x0e3a,
- 0x0eba, 0x0eba,
- 0x0f84, 0x0f84,
- 0x1039, 0x103a,
- 0x1714, 0x1715,
- 0x1734, 0x1734,
- 0x17d2, 0x17d2,
- 0x1a60, 0x1a60,
- 0x1b44, 0x1b44,
- 0x1baa, 0x1bab,
- 0x1bf2, 0x1bf3,
- 0x2d7f, 0x2d7f,
- 0xa806, 0xa806,
- 0xa82c, 0xa82c,
- 0xa8c4, 0xa8c4,
- 0xa953, 0xa953,
- 0xa9c0, 0xa9c0,
- 0xaaf6, 0xaaf6,
- 0xabed, 0xabed,
- 0x10a3f, 0x10a3f,
- 0x11046, 0x11046,
- 0x11070, 0x11070,
- 0x1107f, 0x1107f,
- 0x110b9, 0x110b9,
- 0x11133, 0x11134,
- 0x111c0, 0x111c0,
- 0x11235, 0x11235,
- 0x112ea, 0x112ea,
- 0x1134d, 0x1134d,
- 0x11442, 0x11442,
- 0x114c2, 0x114c2,
- 0x115bf, 0x115bf,
- 0x1163f, 0x1163f,
- 0x116b6, 0x116b6,
- 0x1172b, 0x1172b,
- 0x11839, 0x11839,
- 0x1193d, 0x1193e,
- 0x119e0, 0x119e0,
- 0x11a34, 0x11a34,
- 0x11a47, 0x11a47,
- 0x11a99, 0x11a99,
- 0x11c3f, 0x11c3f,
- 0x11d44, 0x11d45,
- 0x11d97, 0x11d97,
- 0x11f41, 0x11f42,
-}; /* CR_Grapheme_Link */
-
-/* 'Common': Script */
-static const OnigCodePoint CR_Common[] = {
- 173,
- 0x0000, 0x0040,
- 0x005b, 0x0060,
- 0x007b, 0x00a9,
- 0x00ab, 0x00b9,
- 0x00bb, 0x00bf,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02b9, 0x02df,
- 0x02e5, 0x02e9,
- 0x02ec, 0x02ff,
- 0x0374, 0x0374,
- 0x037e, 0x037e,
- 0x0385, 0x0385,
- 0x0387, 0x0387,
- 0x0605, 0x0605,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0640, 0x0640,
- 0x06dd, 0x06dd,
- 0x08e2, 0x08e2,
- 0x0964, 0x0965,
- 0x0e3f, 0x0e3f,
- 0x0fd5, 0x0fd8,
- 0x10fb, 0x10fb,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x1802, 0x1803,
- 0x1805, 0x1805,
- 0x1cd3, 0x1cd3,
- 0x1ce1, 0x1ce1,
- 0x1ce9, 0x1cec,
- 0x1cee, 0x1cf3,
- 0x1cf5, 0x1cf7,
- 0x1cfa, 0x1cfa,
- 0x2000, 0x200b,
- 0x200e, 0x2064,
- 0x2066, 0x2070,
- 0x2074, 0x207e,
- 0x2080, 0x208e,
- 0x20a0, 0x20c0,
- 0x2100, 0x2125,
- 0x2127, 0x2129,
- 0x212c, 0x2131,
- 0x2133, 0x214d,
- 0x214f, 0x215f,
- 0x2189, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x27ff,
- 0x2900, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2bff,
- 0x2e00, 0x2e5d,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x3004,
- 0x3006, 0x3006,
- 0x3008, 0x3020,
- 0x3030, 0x3037,
- 0x303c, 0x303f,
- 0x309b, 0x309c,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fc,
- 0x3190, 0x319f,
- 0x31c0, 0x31e3,
- 0x3220, 0x325f,
- 0x327f, 0x32cf,
- 0x32ff, 0x32ff,
- 0x3358, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa700, 0xa721,
- 0xa788, 0xa78a,
- 0xa830, 0xa839,
- 0xa92e, 0xa92e,
- 0xa9cf, 0xa9cf,
- 0xab5b, 0xab5b,
- 0xab6a, 0xab6b,
- 0xfd3e, 0xfd3f,
- 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,
- 0x10190, 0x1019c,
- 0x101d0, 0x101fc,
- 0x102e1, 0x102fb,
- 0x1bca0, 0x1bca3,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d166,
- 0x1d16a, 0x1d17a,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1ea,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
-}; /* CR_Common */
-
-/* 'Latin': Script */
-static const OnigCodePoint CR_Latin[] = {
- 39,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x02b8,
- 0x02e0, 0x02e4,
- 0x1d00, 0x1d25,
- 0x1d2c, 0x1d5c,
- 0x1d62, 0x1d65,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1dbe,
- 0x1e00, 0x1eff,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x212a, 0x212b,
- 0x2132, 0x2132,
- 0x214e, 0x214e,
- 0x2160, 0x2188,
- 0x2c60, 0x2c7f,
- 0xa722, 0xa787,
- 0xa78b, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa7ff,
- 0xab30, 0xab5a,
- 0xab5c, 0xab64,
- 0xab66, 0xab69,
- 0xfb00, 0xfb06,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
-}; /* CR_Latin */
-
-/* 'Greek': Script */
-static const OnigCodePoint CR_Greek[] = {
- 36,
- 0x0370, 0x0373,
- 0x0375, 0x0377,
- 0x037a, 0x037d,
- 0x037f, 0x037f,
- 0x0384, 0x0384,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03e1,
- 0x03f0, 0x03ff,
- 0x1d26, 0x1d2a,
- 0x1d5d, 0x1d61,
- 0x1d66, 0x1d6a,
- 0x1dbf, 0x1dbf,
- 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,
- 0xab65, 0xab65,
- 0x10140, 0x1018e,
- 0x101a0, 0x101a0,
- 0x1d200, 0x1d245,
-}; /* CR_Greek */
-
-/* 'Cyrillic': Script */
-static const OnigCodePoint CR_Cyrillic[] = {
- 10,
- 0x0400, 0x0484,
- 0x0487, 0x052f,
- 0x1c80, 0x1c88,
- 0x1d2b, 0x1d2b,
- 0x1d78, 0x1d78,
- 0x2de0, 0x2dff,
- 0xa640, 0xa69f,
- 0xfe2e, 0xfe2f,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
-}; /* CR_Cyrillic */
-
-/* 'Armenian': Script */
-static const OnigCodePoint CR_Armenian[] = {
- 4,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0xfb13, 0xfb17,
-}; /* CR_Armenian */
-
-/* 'Hebrew': Script */
-static const OnigCodePoint CR_Hebrew[] = {
- 9,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfb4f,
-}; /* CR_Hebrew */
-
-/* 'Arabic': Script */
-static const OnigCodePoint CR_Arabic[] = {
- 58,
- 0x0600, 0x0604,
- 0x0606, 0x060b,
- 0x060d, 0x061a,
- 0x061c, 0x061e,
- 0x0620, 0x063f,
- 0x0641, 0x064a,
- 0x0656, 0x066f,
- 0x0671, 0x06dc,
- 0x06de, 0x06ff,
- 0x0750, 0x077f,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 0x08e1,
- 0x08e3, 0x08ff,
- 0xfb50, 0xfbc2,
- 0xfbd3, 0xfd3d,
- 0xfd40, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfdcf,
- 0xfdf0, 0xfdff,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0x10e60, 0x10e7e,
- 0x10efd, 0x10eff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
-}; /* CR_Arabic */
-
-/* 'Syriac': Script */
-static const OnigCodePoint CR_Syriac[] = {
- 4,
- 0x0700, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x074f,
- 0x0860, 0x086a,
-}; /* CR_Syriac */
-
-/* 'Thaana': Script */
-static const OnigCodePoint CR_Thaana[] = {
- 1,
- 0x0780, 0x07b1,
-}; /* CR_Thaana */
-
-/* 'Devanagari': Script */
-static const OnigCodePoint CR_Devanagari[] = {
- 5,
- 0x0900, 0x0950,
- 0x0955, 0x0963,
- 0x0966, 0x097f,
- 0xa8e0, 0xa8ff,
- 0x11b00, 0x11b09,
-}; /* CR_Devanagari */
-
-/* 'Bengali': Script */
-static const OnigCodePoint CR_Bengali[] = {
- 14,
- 0x0980, 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, 0x09fe,
-}; /* CR_Bengali */
-
-/* 'Gurmukhi': Script */
-static const OnigCodePoint CR_Gurmukhi[] = {
- 16,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
-}; /* CR_Gurmukhi */
-
-/* '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, 0x0af1,
- 0x0af9, 0x0aff,
-}; /* CR_Gujarati */
-
-/* 'Oriya': Script */
-static const OnigCodePoint CR_Oriya[] = {
- 14,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
-}; /* CR_Oriya */
-
-/* 'Tamil': Script */
-static const OnigCodePoint CR_Tamil[] = {
- 18,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x11fff,
-}; /* CR_Tamil */
-
-/* 'Telugu': Script */
-static const OnigCodePoint CR_Telugu[] = {
- 13,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c7f,
-}; /* CR_Telugu */
-
-/* 'Kannada': Script */
-static const OnigCodePoint CR_Kannada[] = {
- 13,
- 0x0c80, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
-}; /* CR_Kannada */
-
-/* 'Malayalam': Script */
-static const OnigCodePoint CR_Malayalam[] = {
- 7,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
-}; /* CR_Malayalam */
-
-/* 'Sinhala': Script */
-static const OnigCodePoint CR_Sinhala[] = {
- 13,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x111e1, 0x111f4,
-}; /* CR_Sinhala */
-
-/* 'Thai': Script */
-static const OnigCodePoint CR_Thai[] = {
- 2,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e5b,
-}; /* CR_Thai */
-
-/* 'Lao': Script */
-static const OnigCodePoint CR_Lao[] = {
- 11,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
-}; /* CR_Lao */
-
-/* 'Tibetan': Script */
-static const OnigCodePoint CR_Tibetan[] = {
- 7,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd4,
- 0x0fd9, 0x0fda,
-}; /* CR_Tibetan */
-
-/* 'Myanmar': Script */
-static const OnigCodePoint CR_Myanmar[] = {
- 3,
- 0x1000, 0x109f,
- 0xa9e0, 0xa9fe,
- 0xaa60, 0xaa7f,
-}; /* CR_Myanmar */
-
-/* 'Georgian': Script */
-static const OnigCodePoint CR_Georgian[] = {
- 10,
- 0x10a0, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10ff,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cbf,
- 0x2d00, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
-}; /* CR_Georgian */
-
-/* 'Hangul': Script */
-static const OnigCodePoint CR_Hangul[] = {
- 14,
- 0x1100, 0x11ff,
- 0x302e, 0x302f,
- 0x3131, 0x318e,
- 0x3200, 0x321e,
- 0x3260, 0x327e,
- 0xa960, 0xa97c,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
-}; /* CR_Hangul */
-
-/* 'Ethiopic': Script */
-static const OnigCodePoint CR_Ethiopic[] = {
- 36,
- 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
-}; /* CR_Ethiopic */
-
-/* 'Cherokee': Script */
-static const OnigCodePoint CR_Cherokee[] = {
- 3,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0xab70, 0xabbf,
-}; /* CR_Cherokee */
-
-/* 'Canadian_Aboriginal': Script */
-static const OnigCodePoint CR_Canadian_Aboriginal[] = {
- 3,
- 0x1400, 0x167f,
- 0x18b0, 0x18f5,
- 0x11ab0, 0x11abf,
-}; /* CR_Canadian_Aboriginal */
-
-/* 'Ogham': Script */
-static const OnigCodePoint CR_Ogham[] = {
- 1,
- 0x1680, 0x169c,
-}; /* CR_Ogham */
-
-/* 'Runic': Script */
-static const OnigCodePoint CR_Runic[] = {
- 2,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f8,
-}; /* CR_Runic */
-
-/* 'Khmer': Script */
-static const OnigCodePoint CR_Khmer[] = {
- 4,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x19e0, 0x19ff,
-}; /* CR_Khmer */
-
-/* 'Mongolian': Script */
-static const OnigCodePoint CR_Mongolian[] = {
- 6,
- 0x1800, 0x1801,
- 0x1804, 0x1804,
- 0x1806, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x11660, 0x1166c,
-}; /* CR_Mongolian */
-
-/* 'Hiragana': Script */
-static const OnigCodePoint CR_Hiragana[] = {
- 6,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x1b001, 0x1b11f,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1f200, 0x1f200,
-}; /* CR_Hiragana */
-
-/* 'Katakana': Script */
-static const OnigCodePoint CR_Katakana[] = {
- 14,
- 0x30a1, 0x30fa,
- 0x30fd, 0x30ff,
- 0x31f0, 0x31ff,
- 0x32d0, 0x32fe,
- 0x3300, 0x3357,
- 0xff66, 0xff6f,
- 0xff71, 0xff9d,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b000,
- 0x1b120, 0x1b122,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
-}; /* CR_Katakana */
-
-/* 'Bopomofo': Script */
-static const OnigCodePoint CR_Bopomofo[] = {
- 3,
- 0x02ea, 0x02eb,
- 0x3105, 0x312f,
- 0x31a0, 0x31bf,
-}; /* CR_Bopomofo */
-
-/* 'Han': Script */
-static const OnigCodePoint CR_Han[] = {
- 21,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x3005, 0x3005,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303b,
- 0x3400, 0x4dbf,
- 0x4e00, 0x9fff,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0x16fe2, 0x16fe3,
- 0x16ff0, 0x16ff1,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Han */
-
-/* 'Yi': Script */
-static const OnigCodePoint CR_Yi[] = {
- 2,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
-}; /* CR_Yi */
-
-/* 'Old_Italic': Script */
-static const OnigCodePoint CR_Old_Italic[] = {
- 2,
- 0x10300, 0x10323,
- 0x1032d, 0x1032f,
-}; /* CR_Old_Italic */
-
-/* 'Gothic': Script */
-static const OnigCodePoint CR_Gothic[] = {
- 1,
- 0x10330, 0x1034a,
-}; /* CR_Gothic */
-
-/* 'Deseret': Script */
-static const OnigCodePoint CR_Deseret[] = {
- 1,
- 0x10400, 0x1044f,
-}; /* CR_Deseret */
-
-/* 'Inherited': Script */
-static const OnigCodePoint CR_Inherited[] = {
- 29,
- 0x0300, 0x036f,
- 0x0485, 0x0486,
- 0x064b, 0x0655,
- 0x0670, 0x0670,
- 0x0951, 0x0954,
- 0x1ab0, 0x1ace,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1dff,
- 0x200c, 0x200d,
- 0x20d0, 0x20f0,
- 0x302a, 0x302d,
- 0x3099, 0x309a,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2d,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x1133b, 0x1133b,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0xe0100, 0xe01ef,
-}; /* CR_Inherited */
-
-/* 'Tagalog': Script */
-static const OnigCodePoint CR_Tagalog[] = {
- 2,
- 0x1700, 0x1715,
- 0x171f, 0x171f,
-}; /* CR_Tagalog */
-
-/* 'Hanunoo': Script */
-static const OnigCodePoint CR_Hanunoo[] = {
- 1,
- 0x1720, 0x1734,
-}; /* CR_Hanunoo */
-
-/* 'Buhid': Script */
-static const OnigCodePoint CR_Buhid[] = {
- 1,
- 0x1740, 0x1753,
-}; /* CR_Buhid */
-
-/* 'Tagbanwa': Script */
-static const OnigCodePoint CR_Tagbanwa[] = {
- 3,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
-}; /* CR_Tagbanwa */
-
-/* 'Limbu': Script */
-static const OnigCodePoint CR_Limbu[] = {
- 5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x194f,
-}; /* CR_Limbu */
-
-/* 'Tai_Le': Script */
-static const OnigCodePoint CR_Tai_Le[] = {
- 2,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
-}; /* CR_Tai_Le */
-
-/* '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 */
-
-/* 'Ugaritic': Script */
-static const OnigCodePoint CR_Ugaritic[] = {
- 2,
- 0x10380, 0x1039d,
- 0x1039f, 0x1039f,
-}; /* CR_Ugaritic */
-
-/* 'Shavian': Script */
-static const OnigCodePoint CR_Shavian[] = {
- 1,
- 0x10450, 0x1047f,
-}; /* CR_Shavian */
-
-/* 'Osmanya': Script */
-static const OnigCodePoint CR_Osmanya[] = {
- 2,
- 0x10480, 0x1049d,
- 0x104a0, 0x104a9,
-}; /* CR_Osmanya */
-
-/* 'Cypriot': Script */
-static const OnigCodePoint CR_Cypriot[] = {
- 6,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
-}; /* CR_Cypriot */
-
-/* '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 */
-
-/* 'Coptic': Script */
-static const OnigCodePoint CR_Coptic[] = {
- 3,
- 0x03e2, 0x03ef,
- 0x2c80, 0x2cf3,
- 0x2cf9, 0x2cff,
-}; /* CR_Coptic */
-
-/* 'New_Tai_Lue': Script */
-static const OnigCodePoint CR_New_Tai_Lue[] = {
- 4,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x19df,
-}; /* CR_New_Tai_Lue */
-
-/* 'Glagolitic': Script */
-static const OnigCodePoint CR_Glagolitic[] = {
- 6,
- 0x2c00, 0x2c5f,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
-}; /* CR_Glagolitic */
-
-/* 'Tifinagh': Script */
-static const OnigCodePoint CR_Tifinagh[] = {
- 3,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d7f,
-}; /* CR_Tifinagh */
-
-/* 'Syloti_Nagri': Script */
-static const OnigCodePoint CR_Syloti_Nagri[] = {
- 1,
- 0xa800, 0xa82c,
-}; /* CR_Syloti_Nagri */
-
-/* 'Old_Persian': Script */
-static const OnigCodePoint CR_Old_Persian[] = {
- 2,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103d5,
-}; /* CR_Old_Persian */
-
-/* 'Kharoshthi': Script */
-static const OnigCodePoint CR_Kharoshthi[] = {
- 8,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
-}; /* CR_Kharoshthi */
-
-/* 'Balinese': Script */
-static const OnigCodePoint CR_Balinese[] = {
- 2,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
-}; /* CR_Balinese */
-
-/* 'Cuneiform': Script */
-static const OnigCodePoint CR_Cuneiform[] = {
- 4,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
-}; /* CR_Cuneiform */
-
-/* 'Phoenician': Script */
-static const OnigCodePoint CR_Phoenician[] = {
- 2,
- 0x10900, 0x1091b,
- 0x1091f, 0x1091f,
-}; /* CR_Phoenician */
-
-/* 'Phags_Pa': Script */
-static const OnigCodePoint CR_Phags_Pa[] = {
- 1,
- 0xa840, 0xa877,
-}; /* CR_Phags_Pa */
-
-/* 'Nko': Script */
-static const OnigCodePoint CR_Nko[] = {
- 2,
- 0x07c0, 0x07fa,
- 0x07fd, 0x07ff,
-}; /* CR_Nko */
-
-/* 'Sundanese': Script */
-static const OnigCodePoint CR_Sundanese[] = {
- 2,
- 0x1b80, 0x1bbf,
- 0x1cc0, 0x1cc7,
-}; /* CR_Sundanese */
-
-/* 'Lepcha': Script */
-static const OnigCodePoint CR_Lepcha[] = {
- 3,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c4f,
-}; /* CR_Lepcha */
-
-/* 'Ol_Chiki': Script */
-static const OnigCodePoint CR_Ol_Chiki[] = {
- 1,
- 0x1c50, 0x1c7f,
-}; /* CR_Ol_Chiki */
-
-/* 'Vai': Script */
-static const OnigCodePoint CR_Vai[] = {
- 1,
- 0xa500, 0xa62b,
-}; /* CR_Vai */
-
-/* 'Saurashtra': Script */
-static const OnigCodePoint CR_Saurashtra[] = {
- 2,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
-}; /* CR_Saurashtra */
-
-/* 'Kayah_Li': Script */
-static const OnigCodePoint CR_Kayah_Li[] = {
- 2,
- 0xa900, 0xa92d,
- 0xa92f, 0xa92f,
-}; /* CR_Kayah_Li */
-
-/* 'Rejang': Script */
-static const OnigCodePoint CR_Rejang[] = {
- 2,
- 0xa930, 0xa953,
- 0xa95f, 0xa95f,
-}; /* CR_Rejang */
-
-/* 'Lycian': Script */
-static const OnigCodePoint CR_Lycian[] = {
- 1,
- 0x10280, 0x1029c,
-}; /* CR_Lycian */
-
-/* 'Carian': Script */
-static const OnigCodePoint CR_Carian[] = {
- 1,
- 0x102a0, 0x102d0,
-}; /* CR_Carian */
-
-/* 'Lydian': Script */
-static const OnigCodePoint CR_Lydian[] = {
- 2,
- 0x10920, 0x10939,
- 0x1093f, 0x1093f,
-}; /* CR_Lydian */
-
-/* 'Cham': Script */
-static const OnigCodePoint CR_Cham[] = {
- 4,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa5f,
-}; /* CR_Cham */
-
-/* 'Tai_Tham': Script */
-static const OnigCodePoint CR_Tai_Tham[] = {
- 5,
- 0x1a20, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
-}; /* CR_Tai_Tham */
-
-/* 'Tai_Viet': Script */
-static const OnigCodePoint CR_Tai_Viet[] = {
- 2,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
-}; /* CR_Tai_Viet */
-
-/* 'Avestan': Script */
-static const OnigCodePoint CR_Avestan[] = {
- 2,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b3f,
-}; /* CR_Avestan */
-
-/* 'Egyptian_Hieroglyphs': Script */
-static const OnigCodePoint CR_Egyptian_Hieroglyphs[] = {
- 1,
- 0x13000, 0x13455,
-}; /* CR_Egyptian_Hieroglyphs */
-
-/* 'Samaritan': Script */
-static const OnigCodePoint CR_Samaritan[] = {
- 2,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
-}; /* CR_Samaritan */
-
-/* 'Lisu': Script */
-static const OnigCodePoint CR_Lisu[] = {
- 2,
- 0xa4d0, 0xa4ff,
- 0x11fb0, 0x11fb0,
-}; /* CR_Lisu */
-
-/* 'Bamum': Script */
-static const OnigCodePoint CR_Bamum[] = {
- 2,
- 0xa6a0, 0xa6f7,
- 0x16800, 0x16a38,
-}; /* CR_Bamum */
-
-/* 'Javanese': Script */
-static const OnigCodePoint CR_Javanese[] = {
- 3,
- 0xa980, 0xa9cd,
- 0xa9d0, 0xa9d9,
- 0xa9de, 0xa9df,
-}; /* CR_Javanese */
-
-/* 'Meetei_Mayek': Script */
-static const OnigCodePoint CR_Meetei_Mayek[] = {
- 3,
- 0xaae0, 0xaaf6,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
-}; /* CR_Meetei_Mayek */
-
-/* 'Imperial_Aramaic': Script */
-static const OnigCodePoint CR_Imperial_Aramaic[] = {
- 2,
- 0x10840, 0x10855,
- 0x10857, 0x1085f,
-}; /* CR_Imperial_Aramaic */
-
-/* 'Old_South_Arabian': Script */
-static const OnigCodePoint CR_Old_South_Arabian[] = {
- 1,
- 0x10a60, 0x10a7f,
-}; /* CR_Old_South_Arabian */
-
-/* 'Inscriptional_Parthian': Script */
-static const OnigCodePoint CR_Inscriptional_Parthian[] = {
- 2,
- 0x10b40, 0x10b55,
- 0x10b58, 0x10b5f,
-}; /* CR_Inscriptional_Parthian */
-
-/* 'Inscriptional_Pahlavi': Script */
-static const OnigCodePoint CR_Inscriptional_Pahlavi[] = {
- 2,
- 0x10b60, 0x10b72,
- 0x10b78, 0x10b7f,
-}; /* CR_Inscriptional_Pahlavi */
-
-/* 'Old_Turkic': Script */
-static const OnigCodePoint CR_Old_Turkic[] = {
- 1,
- 0x10c00, 0x10c48,
-}; /* CR_Old_Turkic */
-
-/* 'Kaithi': Script */
-static const OnigCodePoint CR_Kaithi[] = {
- 2,
- 0x11080, 0x110c2,
- 0x110cd, 0x110cd,
-}; /* CR_Kaithi */
-
-/* 'Batak': Script */
-static const OnigCodePoint CR_Batak[] = {
- 2,
- 0x1bc0, 0x1bf3,
- 0x1bfc, 0x1bff,
-}; /* CR_Batak */
-
-/* 'Brahmi': Script */
-static const OnigCodePoint CR_Brahmi[] = {
- 3,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x1107f,
-}; /* CR_Brahmi */
-
-/* 'Mandaic': Script */
-static const OnigCodePoint CR_Mandaic[] = {
- 2,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
-}; /* CR_Mandaic */
-
-/* 'Chakma': Script */
-static const OnigCodePoint CR_Chakma[] = {
- 2,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
-}; /* CR_Chakma */
-
-/* 'Meroitic_Cursive': Script */
-static const OnigCodePoint CR_Meroitic_Cursive[] = {
- 3,
- 0x109a0, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x109ff,
-}; /* CR_Meroitic_Cursive */
-
-/* 'Meroitic_Hieroglyphs': Script */
-static const OnigCodePoint CR_Meroitic_Hieroglyphs[] = {
- 1,
- 0x10980, 0x1099f,
-}; /* CR_Meroitic_Hieroglyphs */
-
-/* 'Miao': Script */
-static const OnigCodePoint CR_Miao[] = {
- 3,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
-}; /* CR_Miao */
-
-/* 'Sharada': Script */
-static const OnigCodePoint CR_Sharada[] = {
- 1,
- 0x11180, 0x111df,
-}; /* CR_Sharada */
-
-/* 'Sora_Sompeng': Script */
-static const OnigCodePoint CR_Sora_Sompeng[] = {
- 2,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
-}; /* CR_Sora_Sompeng */
-
-/* 'Takri': Script */
-static const OnigCodePoint CR_Takri[] = {
- 2,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
-}; /* CR_Takri */
-
-/* 'Caucasian_Albanian': Script */
-static const OnigCodePoint CR_Caucasian_Albanian[] = {
- 2,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
-}; /* CR_Caucasian_Albanian */
-
-/* 'Bassa_Vah': Script */
-static const OnigCodePoint CR_Bassa_Vah[] = {
- 2,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
-}; /* CR_Bassa_Vah */
-
-/* 'Duployan': Script */
-static const OnigCodePoint CR_Duployan[] = {
- 5,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bc9f,
-}; /* CR_Duployan */
-
-/* 'Elbasan': Script */
-static const OnigCodePoint CR_Elbasan[] = {
- 1,
- 0x10500, 0x10527,
-}; /* CR_Elbasan */
-
-/* 'Grantha': Script */
-static const OnigCodePoint CR_Grantha[] = {
- 15,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
-}; /* CR_Grantha */
-
-/* 'Pahawh_Hmong': Script */
-static const OnigCodePoint CR_Pahawh_Hmong[] = {
- 5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
-}; /* CR_Pahawh_Hmong */
-
-/* 'Khojki': Script */
-static const OnigCodePoint CR_Khojki[] = {
- 2,
- 0x11200, 0x11211,
- 0x11213, 0x11241,
-}; /* CR_Khojki */
-
-/* 'Linear_A': Script */
-static const OnigCodePoint CR_Linear_A[] = {
- 3,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
-}; /* CR_Linear_A */
-
-/* 'Mahajani': Script */
-static const OnigCodePoint CR_Mahajani[] = {
- 1,
- 0x11150, 0x11176,
-}; /* CR_Mahajani */
-
-/* 'Manichaean': Script */
-static const OnigCodePoint CR_Manichaean[] = {
- 2,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
-}; /* CR_Manichaean */
-
-/* 'Mende_Kikakui': Script */
-static const OnigCodePoint CR_Mende_Kikakui[] = {
- 2,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
-}; /* CR_Mende_Kikakui */
-
-/* 'Modi': Script */
-static const OnigCodePoint CR_Modi[] = {
- 2,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
-}; /* CR_Modi */
-
-/* 'Mro': Script */
-static const OnigCodePoint CR_Mro[] = {
- 3,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
-}; /* CR_Mro */
-
-/* 'Old_North_Arabian': Script */
-static const OnigCodePoint CR_Old_North_Arabian[] = {
- 1,
- 0x10a80, 0x10a9f,
-}; /* CR_Old_North_Arabian */
-
-/* 'Nabataean': Script */
-static const OnigCodePoint CR_Nabataean[] = {
- 2,
- 0x10880, 0x1089e,
- 0x108a7, 0x108af,
-}; /* CR_Nabataean */
-
-/* 'Palmyrene': Script */
-static const OnigCodePoint CR_Palmyrene[] = {
- 1,
- 0x10860, 0x1087f,
-}; /* CR_Palmyrene */
-
-/* 'Pau_Cin_Hau': Script */
-static const OnigCodePoint CR_Pau_Cin_Hau[] = {
- 1,
- 0x11ac0, 0x11af8,
-}; /* CR_Pau_Cin_Hau */
-
-/* 'Old_Permic': Script */
-static const OnigCodePoint CR_Old_Permic[] = {
- 1,
- 0x10350, 0x1037a,
-}; /* CR_Old_Permic */
-
-/* 'Psalter_Pahlavi': Script */
-static const OnigCodePoint CR_Psalter_Pahlavi[] = {
- 3,
- 0x10b80, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
-}; /* CR_Psalter_Pahlavi */
-
-/* 'Siddham': Script */
-static const OnigCodePoint CR_Siddham[] = {
- 2,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
-}; /* CR_Siddham */
-
-/* 'Khudawadi': Script */
-static const OnigCodePoint CR_Khudawadi[] = {
- 2,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
-}; /* CR_Khudawadi */
-
-/* 'Tirhuta': Script */
-static const OnigCodePoint CR_Tirhuta[] = {
- 2,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
-}; /* CR_Tirhuta */
-
-/* 'Warang_Citi': Script */
-static const OnigCodePoint CR_Warang_Citi[] = {
- 2,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
-}; /* CR_Warang_Citi */
-
-/* 'Ahom': Script */
-static const OnigCodePoint CR_Ahom[] = {
- 3,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
-}; /* CR_Ahom */
-
-/* 'Anatolian_Hieroglyphs': Script */
-static const OnigCodePoint CR_Anatolian_Hieroglyphs[] = {
- 1,
- 0x14400, 0x14646,
-}; /* CR_Anatolian_Hieroglyphs */
-
-/* 'Hatran': Script */
-static const OnigCodePoint CR_Hatran[] = {
- 3,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x108ff,
-}; /* CR_Hatran */
-
-/* 'Multani': Script */
-static const OnigCodePoint CR_Multani[] = {
- 5,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
-}; /* CR_Multani */
-
-/* 'Old_Hungarian': Script */
-static const OnigCodePoint CR_Old_Hungarian[] = {
- 3,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
-}; /* CR_Old_Hungarian */
-
-/* 'SignWriting': Script */
-static const OnigCodePoint CR_SignWriting[] = {
- 3,
- 0x1d800, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
-}; /* CR_SignWriting */
-
-/* 'Adlam': Script */
-static const OnigCodePoint CR_Adlam[] = {
- 3,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
-}; /* CR_Adlam */
-
-/* 'Bhaiksuki': Script */
-static const OnigCodePoint CR_Bhaiksuki[] = {
- 4,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
-}; /* CR_Bhaiksuki */
-
-/* 'Marchen': Script */
-static const OnigCodePoint CR_Marchen[] = {
- 3,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
-}; /* CR_Marchen */
-
-/* 'Newa': Script */
-static const OnigCodePoint CR_Newa[] = {
- 2,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
-}; /* CR_Newa */
-
-/* 'Osage': Script */
-static const OnigCodePoint CR_Osage[] = {
- 2,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
-}; /* CR_Osage */
-
-/* 'Tangut': Script */
-static const OnigCodePoint CR_Tangut[] = {
- 4,
- 0x16fe0, 0x16fe0,
- 0x17000, 0x187f7,
- 0x18800, 0x18aff,
- 0x18d00, 0x18d08,
-}; /* CR_Tangut */
-
-/* 'Masaram_Gondi': Script */
-static const OnigCodePoint CR_Masaram_Gondi[] = {
- 7,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
-}; /* CR_Masaram_Gondi */
-
-/* 'Nushu': Script */
-static const OnigCodePoint CR_Nushu[] = {
- 2,
- 0x16fe1, 0x16fe1,
- 0x1b170, 0x1b2fb,
-}; /* CR_Nushu */
-
-/* 'Soyombo': Script */
-static const OnigCodePoint CR_Soyombo[] = {
- 1,
- 0x11a50, 0x11aa2,
-}; /* CR_Soyombo */
-
-/* 'Zanabazar_Square': Script */
-static const OnigCodePoint CR_Zanabazar_Square[] = {
- 1,
- 0x11a00, 0x11a47,
-}; /* CR_Zanabazar_Square */
-
-/* 'Dogra': Script */
-static const OnigCodePoint CR_Dogra[] = {
- 1,
- 0x11800, 0x1183b,
-}; /* CR_Dogra */
-
-/* 'Gunjala_Gondi': Script */
-static const OnigCodePoint CR_Gunjala_Gondi[] = {
- 6,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
-}; /* CR_Gunjala_Gondi */
-
-/* 'Makasar': Script */
-static const OnigCodePoint CR_Makasar[] = {
- 1,
- 0x11ee0, 0x11ef8,
-}; /* CR_Makasar */
-
-/* 'Medefaidrin': Script */
-static const OnigCodePoint CR_Medefaidrin[] = {
- 1,
- 0x16e40, 0x16e9a,
-}; /* CR_Medefaidrin */
-
-/* 'Hanifi_Rohingya': Script */
-static const OnigCodePoint CR_Hanifi_Rohingya[] = {
- 2,
- 0x10d00, 0x10d27,
- 0x10d30, 0x10d39,
-}; /* CR_Hanifi_Rohingya */
-
-/* 'Sogdian': Script */
-static const OnigCodePoint CR_Sogdian[] = {
- 1,
- 0x10f30, 0x10f59,
-}; /* CR_Sogdian */
-
-/* 'Old_Sogdian': Script */
-static const OnigCodePoint CR_Old_Sogdian[] = {
- 1,
- 0x10f00, 0x10f27,
-}; /* CR_Old_Sogdian */
-
-/* 'Elymaic': Script */
-static const OnigCodePoint CR_Elymaic[] = {
- 1,
- 0x10fe0, 0x10ff6,
-}; /* CR_Elymaic */
-
-/* 'Nandinagari': Script */
-static const OnigCodePoint CR_Nandinagari[] = {
- 3,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
-}; /* CR_Nandinagari */
-
-/* 'Nyiakeng_Puachue_Hmong': Script */
-static const OnigCodePoint CR_Nyiakeng_Puachue_Hmong[] = {
- 4,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
-}; /* CR_Nyiakeng_Puachue_Hmong */
-
-/* 'Wancho': Script */
-static const OnigCodePoint CR_Wancho[] = {
- 2,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
-}; /* CR_Wancho */
-
-/* 'Chorasmian': Script */
-static const OnigCodePoint CR_Chorasmian[] = {
- 1,
- 0x10fb0, 0x10fcb,
-}; /* CR_Chorasmian */
-
-/* 'Dives_Akuru': Script */
-static const OnigCodePoint CR_Dives_Akuru[] = {
- 8,
- 0x11900, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
-}; /* CR_Dives_Akuru */
-
-/* 'Khitan_Small_Script': Script */
-static const OnigCodePoint CR_Khitan_Small_Script[] = {
- 2,
- 0x16fe4, 0x16fe4,
- 0x18b00, 0x18cd5,
-}; /* CR_Khitan_Small_Script */
-
-/* 'Yezidi': Script */
-static const OnigCodePoint CR_Yezidi[] = {
- 3,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
-}; /* CR_Yezidi */
-
-/* 'Cypro_Minoan': Script */
-static const OnigCodePoint CR_Cypro_Minoan[] = {
- 1,
- 0x12f90, 0x12ff2,
-}; /* CR_Cypro_Minoan */
-
-/* 'Old_Uyghur': Script */
-static const OnigCodePoint CR_Old_Uyghur[] = {
- 1,
- 0x10f70, 0x10f89,
-}; /* CR_Old_Uyghur */
-
-/* 'Tangsa': Script */
-static const OnigCodePoint CR_Tangsa[] = {
- 2,
- 0x16a70, 0x16abe,
- 0x16ac0, 0x16ac9,
-}; /* CR_Tangsa */
-
-/* 'Toto': Script */
-static const OnigCodePoint CR_Toto[] = {
- 1,
- 0x1e290, 0x1e2ae,
-}; /* CR_Toto */
-
-/* 'Vithkuqi': Script */
-static const OnigCodePoint CR_Vithkuqi[] = {
- 8,
- 0x10570, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
-}; /* CR_Vithkuqi */
-
-/* 'Kawi': Script */
-static const OnigCodePoint CR_Kawi[] = {
- 3,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f59,
-}; /* CR_Kawi */
-
-/* 'Nag_Mundari': Script */
-static const OnigCodePoint CR_Nag_Mundari[] = {
- 1,
- 0x1e4d0, 0x1e4f9,
-}; /* CR_Nag_Mundari */
-
-/* 'White_Space': Binary Property */
-#define CR_White_Space CR_Space
-
-/* 'Bidi_Control': Binary Property */
-static const OnigCodePoint CR_Bidi_Control[] = {
- 4,
- 0x061c, 0x061c,
- 0x200e, 0x200f,
- 0x202a, 0x202e,
- 0x2066, 0x2069,
-}; /* CR_Bidi_Control */
-
-/* 'Join_Control': Binary Property */
-static const OnigCodePoint CR_Join_Control[] = {
- 1,
- 0x200c, 0x200d,
-}; /* CR_Join_Control */
-
-/* 'Dash': Binary Property */
-static const OnigCodePoint CR_Dash[] = {
- 23,
- 0x002d, 0x002d,
- 0x058a, 0x058a,
- 0x05be, 0x05be,
- 0x1400, 0x1400,
- 0x1806, 0x1806,
- 0x2010, 0x2015,
- 0x2053, 0x2053,
- 0x207b, 0x207b,
- 0x208b, 0x208b,
- 0x2212, 0x2212,
- 0x2e17, 0x2e17,
- 0x2e1a, 0x2e1a,
- 0x2e3a, 0x2e3b,
- 0x2e40, 0x2e40,
- 0x2e5d, 0x2e5d,
- 0x301c, 0x301c,
- 0x3030, 0x3030,
- 0x30a0, 0x30a0,
- 0xfe31, 0xfe32,
- 0xfe58, 0xfe58,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
- 0x10ead, 0x10ead,
-}; /* CR_Dash */
-
-/* 'Hyphen': Binary Property */
-static const OnigCodePoint CR_Hyphen[] = {
- 10,
- 0x002d, 0x002d,
- 0x00ad, 0x00ad,
- 0x058a, 0x058a,
- 0x1806, 0x1806,
- 0x2010, 0x2011,
- 0x2e17, 0x2e17,
- 0x30fb, 0x30fb,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d,
- 0xff65, 0xff65,
-}; /* CR_Hyphen */
-
-/* 'Quotation_Mark': Binary Property */
-static const OnigCodePoint CR_Quotation_Mark[] = {
- 13,
- 0x0022, 0x0022,
- 0x0027, 0x0027,
- 0x00ab, 0x00ab,
- 0x00bb, 0x00bb,
- 0x2018, 0x201f,
- 0x2039, 0x203a,
- 0x2e42, 0x2e42,
- 0x300c, 0x300f,
- 0x301d, 0x301f,
- 0xfe41, 0xfe44,
- 0xff02, 0xff02,
- 0xff07, 0xff07,
- 0xff62, 0xff63,
-}; /* CR_Quotation_Mark */
-
-/* 'Terminal_Punctuation': Binary Property */
-static const OnigCodePoint CR_Terminal_Punctuation[] = {
- 108,
- 0x0021, 0x0021,
- 0x002c, 0x002c,
- 0x002e, 0x002e,
- 0x003a, 0x003b,
- 0x003f, 0x003f,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x0589, 0x0589,
- 0x05c3, 0x05c3,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061d, 0x061f,
- 0x06d4, 0x06d4,
- 0x0700, 0x070a,
- 0x070c, 0x070c,
- 0x07f8, 0x07f9,
- 0x0830, 0x083e,
- 0x085e, 0x085e,
- 0x0964, 0x0965,
- 0x0e5a, 0x0e5b,
- 0x0f08, 0x0f08,
- 0x0f0d, 0x0f12,
- 0x104a, 0x104b,
- 0x1361, 0x1368,
- 0x166e, 0x166e,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17da, 0x17da,
- 0x1802, 0x1805,
- 0x1808, 0x1809,
- 0x1944, 0x1945,
- 0x1aa8, 0x1aab,
- 0x1b5a, 0x1b5b,
- 0x1b5d, 0x1b5f,
- 0x1b7d, 0x1b7e,
- 0x1c3b, 0x1c3f,
- 0x1c7e, 0x1c7f,
- 0x203c, 0x203d,
- 0x2047, 0x2049,
- 0x2e2e, 0x2e2e,
- 0x2e3c, 0x2e3c,
- 0x2e41, 0x2e41,
- 0x2e4c, 0x2e4c,
- 0x2e4e, 0x2e4f,
- 0x2e53, 0x2e54,
- 0x3001, 0x3002,
- 0xa4fe, 0xa4ff,
- 0xa60d, 0xa60f,
- 0xa6f3, 0xa6f7,
- 0xa876, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa92f, 0xa92f,
- 0xa9c7, 0xa9c9,
- 0xaa5d, 0xaa5f,
- 0xaadf, 0xaadf,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfe50, 0xfe52,
- 0xfe54, 0xfe57,
- 0xff01, 0xff01,
- 0xff0c, 0xff0c,
- 0xff0e, 0xff0e,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff1f,
- 0xff61, 0xff61,
- 0xff64, 0xff64,
- 0x1039f, 0x1039f,
- 0x103d0, 0x103d0,
- 0x10857, 0x10857,
- 0x1091f, 0x1091f,
- 0x10a56, 0x10a57,
- 0x10af0, 0x10af5,
- 0x10b3a, 0x10b3f,
- 0x10b99, 0x10b9c,
- 0x10f55, 0x10f59,
- 0x10f86, 0x10f89,
- 0x11047, 0x1104d,
- 0x110be, 0x110c1,
- 0x11141, 0x11143,
- 0x111c5, 0x111c6,
- 0x111cd, 0x111cd,
- 0x111de, 0x111df,
- 0x11238, 0x1123c,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144d,
- 0x1145a, 0x1145b,
- 0x115c2, 0x115c5,
- 0x115c9, 0x115d7,
- 0x11641, 0x11642,
- 0x1173c, 0x1173e,
- 0x11944, 0x11944,
- 0x11946, 0x11946,
- 0x11a42, 0x11a43,
- 0x11a9b, 0x11a9c,
- 0x11aa1, 0x11aa2,
- 0x11c41, 0x11c43,
- 0x11c71, 0x11c71,
- 0x11ef7, 0x11ef8,
- 0x11f43, 0x11f44,
- 0x12470, 0x12474,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b39,
- 0x16b44, 0x16b44,
- 0x16e97, 0x16e98,
- 0x1bc9f, 0x1bc9f,
- 0x1da87, 0x1da8a,
-}; /* CR_Terminal_Punctuation */
-
-/* 'Other_Math': Binary Property */
-static const OnigCodePoint CR_Other_Math[] = {
- 134,
- 0x005e, 0x005e,
- 0x03d0, 0x03d2,
- 0x03d5, 0x03d5,
- 0x03f0, 0x03f1,
- 0x03f4, 0x03f5,
- 0x2016, 0x2016,
- 0x2032, 0x2034,
- 0x2040, 0x2040,
- 0x2061, 0x2064,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20e6,
- 0x20eb, 0x20ef,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2128, 0x2129,
- 0x212c, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2138,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2195, 0x2199,
- 0x219c, 0x219f,
- 0x21a1, 0x21a2,
- 0x21a4, 0x21a5,
- 0x21a7, 0x21a7,
- 0x21a9, 0x21ad,
- 0x21b0, 0x21b1,
- 0x21b6, 0x21b7,
- 0x21bc, 0x21cd,
- 0x21d0, 0x21d1,
- 0x21d3, 0x21d3,
- 0x21d5, 0x21db,
- 0x21dd, 0x21dd,
- 0x21e4, 0x21e5,
- 0x2308, 0x230b,
- 0x23b4, 0x23b5,
- 0x23b7, 0x23b7,
- 0x23d0, 0x23d0,
- 0x23e2, 0x23e2,
- 0x25a0, 0x25a1,
- 0x25ae, 0x25b6,
- 0x25bc, 0x25c0,
- 0x25c6, 0x25c7,
- 0x25ca, 0x25cb,
- 0x25cf, 0x25d3,
- 0x25e2, 0x25e2,
- 0x25e4, 0x25e4,
- 0x25e7, 0x25ec,
- 0x2605, 0x2606,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2660, 0x2663,
- 0x266d, 0x266e,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27ef,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0xfe61, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xff3c, 0xff3c,
- 0xff3e, 0xff3e,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
-}; /* CR_Other_Math */
-
-/* 'Hex_Digit': Binary Property */
-static const OnigCodePoint CR_Hex_Digit[] = {
- 6,
- 0x0030, 0x0039,
- 0x0041, 0x0046,
- 0x0061, 0x0066,
- 0xff10, 0xff19,
- 0xff21, 0xff26,
- 0xff41, 0xff46,
-}; /* CR_Hex_Digit */
-
-/* 'ASCII_Hex_Digit': Binary Property */
-#define CR_ASCII_Hex_Digit CR_XDigit
-
-/* 'Other_Alphabetic': Binary Property */
-static const OnigCodePoint CR_Other_Alphabetic[] = {
- 240,
- 0x0345, 0x0345,
- 0x05b0, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x0657,
- 0x0659, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06e1, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ed, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x073f,
- 0x07a6, 0x07b0,
- 0x0816, 0x0817,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082c,
- 0x08d4, 0x08df,
- 0x08e3, 0x08e9,
- 0x08f0, 0x0903,
- 0x093a, 0x093b,
- 0x093e, 0x094c,
- 0x094e, 0x094f,
- 0x0955, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0983,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x0a01, 0x0a03,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4c,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a83,
- 0x0abe, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0afc,
- 0x0b01, 0x0b03,
- 0x0b3e, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b56, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c04,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4c,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c83,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccc,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0cf3, 0x0cf3,
- 0x0d00, 0x0d03,
- 0x0d3e, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d83,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e4d, 0x0e4d,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0eb9,
- 0x0ebb, 0x0ebc,
- 0x0ecd, 0x0ecd,
- 0x0f71, 0x0f83,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x102b, 0x1036,
- 0x1038, 0x1038,
- 0x103b, 0x103e,
- 0x1056, 0x1059,
- 0x105e, 0x1060,
- 0x1062, 0x1064,
- 0x1067, 0x106d,
- 0x1071, 0x1074,
- 0x1082, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109d,
- 0x1712, 0x1713,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b6, 0x17c8,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x192b,
- 0x1930, 0x1938,
- 0x1a17, 0x1a1b,
- 0x1a55, 0x1a5e,
- 0x1a61, 0x1a74,
- 0x1abf, 0x1ac0,
- 0x1acc, 0x1ace,
- 0x1b00, 0x1b04,
- 0x1b35, 0x1b43,
- 0x1b80, 0x1b82,
- 0x1ba1, 0x1ba9,
- 0x1bac, 0x1bad,
- 0x1be7, 0x1bf1,
- 0x1c24, 0x1c36,
- 0x1de7, 0x1df4,
- 0x24b6, 0x24e9,
- 0x2de0, 0x2dff,
- 0xa674, 0xa67b,
- 0xa69e, 0xa69f,
- 0xa802, 0xa802,
- 0xa80b, 0xa80b,
- 0xa823, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa8c5, 0xa8c5,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92a,
- 0xa947, 0xa952,
- 0xa980, 0xa983,
- 0xa9b4, 0xa9bf,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4d,
- 0xaa7b, 0xaa7d,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabe,
- 0xaaeb, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabea,
- 0xfb1e, 0xfb1e,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x11000, 0x11002,
- 0x11038, 0x11045,
- 0x11073, 0x11074,
- 0x11080, 0x11082,
- 0x110b0, 0x110b8,
- 0x110c2, 0x110c2,
- 0x11100, 0x11102,
- 0x11127, 0x11132,
- 0x11145, 0x11146,
- 0x11180, 0x11182,
- 0x111b3, 0x111bf,
- 0x111ce, 0x111cf,
- 0x1122c, 0x11234,
- 0x11237, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112e8,
- 0x11300, 0x11303,
- 0x1133e, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134c,
- 0x11357, 0x11357,
- 0x11362, 0x11363,
- 0x11435, 0x11441,
- 0x11443, 0x11445,
- 0x114b0, 0x114c1,
- 0x115af, 0x115b5,
- 0x115b8, 0x115be,
- 0x115dc, 0x115dd,
- 0x11630, 0x1163e,
- 0x11640, 0x11640,
- 0x116ab, 0x116b5,
- 0x1171d, 0x1172a,
- 0x1182c, 0x11838,
- 0x11930, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x1193c,
- 0x11940, 0x11940,
- 0x11942, 0x11942,
- 0x119d1, 0x119d7,
- 0x119da, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a01, 0x11a0a,
- 0x11a35, 0x11a39,
- 0x11a3b, 0x11a3e,
- 0x11a51, 0x11a5b,
- 0x11a8a, 0x11a97,
- 0x11c2f, 0x11c36,
- 0x11c38, 0x11c3e,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d41,
- 0x11d43, 0x11d43,
- 0x11d47, 0x11d47,
- 0x11d8a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d96,
- 0x11ef3, 0x11ef6,
- 0x11f00, 0x11f01,
- 0x11f03, 0x11f03,
- 0x11f34, 0x11f3a,
- 0x11f3e, 0x11f40,
- 0x16f4f, 0x16f4f,
- 0x16f51, 0x16f87,
- 0x16f8f, 0x16f92,
- 0x16ff0, 0x16ff1,
- 0x1bc9e, 0x1bc9e,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e08f, 0x1e08f,
- 0x1e947, 0x1e947,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Other_Alphabetic */
-
-/* 'Ideographic': Binary Property */
-static const OnigCodePoint CR_Ideographic[] = {
- 20,
- 0x3006, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x3400, 0x4dbf,
- 0x4e00, 0x9fff,
- 0xf900, 0xfa6d,
- 0xfa70, 0xfad9,
- 0x16fe4, 0x16fe4,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1b170, 0x1b2fb,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Ideographic */
-
-/* 'Diacritic': Binary Property */
-static const OnigCodePoint CR_Diacritic[] = {
- 195,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b7, 0x00b8,
- 0x02b0, 0x034e,
- 0x0350, 0x0357,
- 0x035d, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x0384, 0x0385,
- 0x0483, 0x0487,
- 0x0559, 0x0559,
- 0x0591, 0x05a1,
- 0x05a3, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c4,
- 0x064b, 0x0652,
- 0x0657, 0x0658,
- 0x06df, 0x06e0,
- 0x06e5, 0x06e6,
- 0x06ea, 0x06ec,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f5,
- 0x0818, 0x0819,
- 0x0898, 0x089f,
- 0x08c9, 0x08d2,
- 0x08e3, 0x08fe,
- 0x093c, 0x093c,
- 0x094d, 0x094d,
- 0x0951, 0x0954,
- 0x0971, 0x0971,
- 0x09bc, 0x09bc,
- 0x09cd, 0x09cd,
- 0x0a3c, 0x0a3c,
- 0x0a4d, 0x0a4d,
- 0x0abc, 0x0abc,
- 0x0acd, 0x0acd,
- 0x0afd, 0x0aff,
- 0x0b3c, 0x0b3c,
- 0x0b4d, 0x0b4d,
- 0x0b55, 0x0b55,
- 0x0bcd, 0x0bcd,
- 0x0c3c, 0x0c3c,
- 0x0c4d, 0x0c4d,
- 0x0cbc, 0x0cbc,
- 0x0ccd, 0x0ccd,
- 0x0d3b, 0x0d3c,
- 0x0d4d, 0x0d4d,
- 0x0dca, 0x0dca,
- 0x0e47, 0x0e4c,
- 0x0e4e, 0x0e4e,
- 0x0eba, 0x0eba,
- 0x0ec8, 0x0ecc,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f3f,
- 0x0f82, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0fc6, 0x0fc6,
- 0x1037, 0x1037,
- 0x1039, 0x103a,
- 0x1063, 0x1064,
- 0x1069, 0x106d,
- 0x1087, 0x108d,
- 0x108f, 0x108f,
- 0x109a, 0x109b,
- 0x135d, 0x135f,
- 0x1714, 0x1715,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x1939, 0x193b,
- 0x1a75, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1abe,
- 0x1ac1, 0x1acb,
- 0x1b34, 0x1b34,
- 0x1b44, 0x1b44,
- 0x1b6b, 0x1b73,
- 0x1baa, 0x1bab,
- 0x1c36, 0x1c37,
- 0x1c78, 0x1c7d,
- 0x1cd0, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf7, 0x1cf9,
- 0x1d2c, 0x1d6a,
- 0x1dc4, 0x1dcf,
- 0x1df5, 0x1dff,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x2cef, 0x2cf1,
- 0x2e2f, 0x2e2f,
- 0x302a, 0x302f,
- 0x3099, 0x309c,
- 0x30fc, 0x30fc,
- 0xa66f, 0xa66f,
- 0xa67c, 0xa67d,
- 0xa67f, 0xa67f,
- 0xa69c, 0xa69d,
- 0xa6f0, 0xa6f1,
- 0xa700, 0xa721,
- 0xa788, 0xa78a,
- 0xa7f8, 0xa7f9,
- 0xa8c4, 0xa8c4,
- 0xa8e0, 0xa8f1,
- 0xa92b, 0xa92e,
- 0xa953, 0xa953,
- 0xa9b3, 0xa9b3,
- 0xa9c0, 0xa9c0,
- 0xa9e5, 0xa9e5,
- 0xaa7b, 0xaa7d,
- 0xaabf, 0xaac2,
- 0xaaf6, 0xaaf6,
- 0xab5b, 0xab5f,
- 0xab69, 0xab6b,
- 0xabec, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe20, 0xfe2f,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe3, 0xffe3,
- 0x102e0, 0x102e0,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10ae5, 0x10ae6,
- 0x10d22, 0x10d27,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11046, 0x11046,
- 0x11070, 0x11070,
- 0x110b9, 0x110ba,
- 0x11133, 0x11134,
- 0x11173, 0x11173,
- 0x111c0, 0x111c0,
- 0x111ca, 0x111cc,
- 0x11235, 0x11236,
- 0x112e9, 0x112ea,
- 0x1133c, 0x1133c,
- 0x1134d, 0x1134d,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11442, 0x11442,
- 0x11446, 0x11446,
- 0x114c2, 0x114c3,
- 0x115bf, 0x115c0,
- 0x1163f, 0x1163f,
- 0x116b6, 0x116b7,
- 0x1172b, 0x1172b,
- 0x11839, 0x1183a,
- 0x1193d, 0x1193e,
- 0x11943, 0x11943,
- 0x119e0, 0x119e0,
- 0x11a34, 0x11a34,
- 0x11a47, 0x11a47,
- 0x11a99, 0x11a99,
- 0x11c3f, 0x11c3f,
- 0x11d42, 0x11d42,
- 0x11d44, 0x11d45,
- 0x11d97, 0x11d97,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f8f, 0x16f9f,
- 0x16ff0, 0x16ff1,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d167, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1e030, 0x1e06d,
- 0x1e130, 0x1e136,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e946,
- 0x1e948, 0x1e94a,
-}; /* CR_Diacritic */
-
-/* 'Extender': Binary Property */
-static const OnigCodePoint CR_Extender[] = {
- 33,
- 0x00b7, 0x00b7,
- 0x02d0, 0x02d1,
- 0x0640, 0x0640,
- 0x07fa, 0x07fa,
- 0x0b55, 0x0b55,
- 0x0e46, 0x0e46,
- 0x0ec6, 0x0ec6,
- 0x180a, 0x180a,
- 0x1843, 0x1843,
- 0x1aa7, 0x1aa7,
- 0x1c36, 0x1c36,
- 0x1c7b, 0x1c7b,
- 0x3005, 0x3005,
- 0x3031, 0x3035,
- 0x309d, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xa60c, 0xa60c,
- 0xa9cf, 0xa9cf,
- 0xa9e6, 0xa9e6,
- 0xaa70, 0xaa70,
- 0xaadd, 0xaadd,
- 0xaaf3, 0xaaf4,
- 0xff70, 0xff70,
- 0x10781, 0x10782,
- 0x1135d, 0x1135d,
- 0x115c6, 0x115c8,
- 0x11a98, 0x11a98,
- 0x16b42, 0x16b43,
- 0x16fe0, 0x16fe1,
- 0x16fe3, 0x16fe3,
- 0x1e13c, 0x1e13d,
- 0x1e944, 0x1e946,
-}; /* CR_Extender */
-
-/* 'Other_Lowercase': Binary Property */
-static const OnigCodePoint CR_Other_Lowercase[] = {
- 28,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x02b0, 0x02b8,
- 0x02c0, 0x02c1,
- 0x02e0, 0x02e4,
- 0x0345, 0x0345,
- 0x037a, 0x037a,
- 0x10fc, 0x10fc,
- 0x1d2c, 0x1d6a,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dbf,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x209c,
- 0x2170, 0x217f,
- 0x24d0, 0x24e9,
- 0x2c7c, 0x2c7d,
- 0xa69c, 0xa69d,
- 0xa770, 0xa770,
- 0xa7f2, 0xa7f4,
- 0xa7f8, 0xa7f9,
- 0xab5c, 0xab5f,
- 0xab69, 0xab69,
- 0x10780, 0x10780,
- 0x10783, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x1e030, 0x1e06d,
-}; /* CR_Other_Lowercase */
-
-/* 'Other_Uppercase': Binary Property */
-static const OnigCodePoint CR_Other_Uppercase[] = {
- 5,
- 0x2160, 0x216f,
- 0x24b6, 0x24cf,
- 0x1f130, 0x1f149,
- 0x1f150, 0x1f169,
- 0x1f170, 0x1f189,
-}; /* CR_Other_Uppercase */
-
-/* 'Noncharacter_Code_Point': Binary Property */
-static const OnigCodePoint CR_Noncharacter_Code_Point[] = {
- 18,
- 0xfdd0, 0xfdef,
- 0xfffe, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0xeffff,
- 0xffffe, 0xfffff,
- 0x10fffe, 0x10ffff,
-}; /* CR_Noncharacter_Code_Point */
-
-/* 'Other_Grapheme_Extend': Binary Property */
-static const OnigCodePoint CR_Other_Grapheme_Extend[] = {
- 25,
- 0x09be, 0x09be,
- 0x09d7, 0x09d7,
- 0x0b3e, 0x0b3e,
- 0x0b57, 0x0b57,
- 0x0bbe, 0x0bbe,
- 0x0bd7, 0x0bd7,
- 0x0cc2, 0x0cc2,
- 0x0cd5, 0x0cd6,
- 0x0d3e, 0x0d3e,
- 0x0d57, 0x0d57,
- 0x0dcf, 0x0dcf,
- 0x0ddf, 0x0ddf,
- 0x1b35, 0x1b35,
- 0x200c, 0x200c,
- 0x302e, 0x302f,
- 0xff9e, 0xff9f,
- 0x1133e, 0x1133e,
- 0x11357, 0x11357,
- 0x114b0, 0x114b0,
- 0x114bd, 0x114bd,
- 0x115af, 0x115af,
- 0x11930, 0x11930,
- 0x1d165, 0x1d165,
- 0x1d16e, 0x1d172,
- 0xe0020, 0xe007f,
-}; /* CR_Other_Grapheme_Extend */
-
-/* 'IDS_Binary_Operator': Binary Property */
-static const OnigCodePoint CR_IDS_Binary_Operator[] = {
- 2,
- 0x2ff0, 0x2ff1,
- 0x2ff4, 0x2ffb,
-}; /* CR_IDS_Binary_Operator */
-
-/* 'IDS_Trinary_Operator': Binary Property */
-static const OnigCodePoint CR_IDS_Trinary_Operator[] = {
- 1,
- 0x2ff2, 0x2ff3,
-}; /* CR_IDS_Trinary_Operator */
-
-/* 'Radical': Binary Property */
-static const OnigCodePoint CR_Radical[] = {
- 3,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
-}; /* CR_Radical */
-
-/* 'Unified_Ideograph': Binary Property */
-static const OnigCodePoint CR_Unified_Ideograph[] = {
- 16,
- 0x3400, 0x4dbf,
- 0x4e00, 0x9fff,
- 0xfa0e, 0xfa0f,
- 0xfa11, 0xfa11,
- 0xfa13, 0xfa14,
- 0xfa1f, 0xfa1f,
- 0xfa21, 0xfa21,
- 0xfa23, 0xfa24,
- 0xfa27, 0xfa29,
- 0x20000, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x30000, 0x3134a,
- 0x31350, 0x323af,
-}; /* CR_Unified_Ideograph */
-
-/* 'Other_Default_Ignorable_Code_Point': Binary Property */
-static const OnigCodePoint CR_Other_Default_Ignorable_Code_Point[] = {
- 11,
- 0x034f, 0x034f,
- 0x115f, 0x1160,
- 0x17b4, 0x17b5,
- 0x2065, 0x2065,
- 0x3164, 0x3164,
- 0xffa0, 0xffa0,
- 0xfff0, 0xfff8,
- 0xe0000, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xe0fff,
-}; /* CR_Other_Default_Ignorable_Code_Point */
-
-/* 'Deprecated': Binary Property */
-static const OnigCodePoint CR_Deprecated[] = {
- 8,
- 0x0149, 0x0149,
- 0x0673, 0x0673,
- 0x0f77, 0x0f77,
- 0x0f79, 0x0f79,
- 0x17a3, 0x17a4,
- 0x206a, 0x206f,
- 0x2329, 0x232a,
- 0xe0001, 0xe0001,
-}; /* CR_Deprecated */
-
-/* 'Soft_Dotted': Binary Property */
-static const OnigCodePoint CR_Soft_Dotted[] = {
- 34,
- 0x0069, 0x006a,
- 0x012f, 0x012f,
- 0x0249, 0x0249,
- 0x0268, 0x0268,
- 0x029d, 0x029d,
- 0x02b2, 0x02b2,
- 0x03f3, 0x03f3,
- 0x0456, 0x0456,
- 0x0458, 0x0458,
- 0x1d62, 0x1d62,
- 0x1d96, 0x1d96,
- 0x1da4, 0x1da4,
- 0x1da8, 0x1da8,
- 0x1e2d, 0x1e2d,
- 0x1ecb, 0x1ecb,
- 0x2071, 0x2071,
- 0x2148, 0x2149,
- 0x2c7c, 0x2c7c,
- 0x1d422, 0x1d423,
- 0x1d456, 0x1d457,
- 0x1d48a, 0x1d48b,
- 0x1d4be, 0x1d4bf,
- 0x1d4f2, 0x1d4f3,
- 0x1d526, 0x1d527,
- 0x1d55a, 0x1d55b,
- 0x1d58e, 0x1d58f,
- 0x1d5c2, 0x1d5c3,
- 0x1d5f6, 0x1d5f7,
- 0x1d62a, 0x1d62b,
- 0x1d65e, 0x1d65f,
- 0x1d692, 0x1d693,
- 0x1df1a, 0x1df1a,
- 0x1e04c, 0x1e04d,
- 0x1e068, 0x1e068,
-}; /* CR_Soft_Dotted */
-
-/* 'Logical_Order_Exception': Binary Property */
-static const OnigCodePoint CR_Logical_Order_Exception[] = {
- 7,
- 0x0e40, 0x0e44,
- 0x0ec0, 0x0ec4,
- 0x19b5, 0x19b7,
- 0x19ba, 0x19ba,
- 0xaab5, 0xaab6,
- 0xaab9, 0xaab9,
- 0xaabb, 0xaabc,
-}; /* CR_Logical_Order_Exception */
-
-/* 'Other_ID_Start': Binary Property */
-static const OnigCodePoint CR_Other_ID_Start[] = {
- 4,
- 0x1885, 0x1886,
- 0x2118, 0x2118,
- 0x212e, 0x212e,
- 0x309b, 0x309c,
-}; /* CR_Other_ID_Start */
-
-/* 'Other_ID_Continue': Binary Property */
-static const OnigCodePoint CR_Other_ID_Continue[] = {
- 4,
- 0x00b7, 0x00b7,
- 0x0387, 0x0387,
- 0x1369, 0x1371,
- 0x19da, 0x19da,
-}; /* CR_Other_ID_Continue */
-
-/* 'Sentence_Terminal': Binary Property */
-static const OnigCodePoint CR_Sentence_Terminal[] = {
- 80,
- 0x0021, 0x0021,
- 0x002e, 0x002e,
- 0x003f, 0x003f,
- 0x0589, 0x0589,
- 0x061d, 0x061f,
- 0x06d4, 0x06d4,
- 0x0700, 0x0702,
- 0x07f9, 0x07f9,
- 0x0837, 0x0837,
- 0x0839, 0x0839,
- 0x083d, 0x083e,
- 0x0964, 0x0965,
- 0x104a, 0x104b,
- 0x1362, 0x1362,
- 0x1367, 0x1368,
- 0x166e, 0x166e,
- 0x1735, 0x1736,
- 0x1803, 0x1803,
- 0x1809, 0x1809,
- 0x1944, 0x1945,
- 0x1aa8, 0x1aab,
- 0x1b5a, 0x1b5b,
- 0x1b5e, 0x1b5f,
- 0x1b7d, 0x1b7e,
- 0x1c3b, 0x1c3c,
- 0x1c7e, 0x1c7f,
- 0x203c, 0x203d,
- 0x2047, 0x2049,
- 0x2e2e, 0x2e2e,
- 0x2e3c, 0x2e3c,
- 0x2e53, 0x2e54,
- 0x3002, 0x3002,
- 0xa4ff, 0xa4ff,
- 0xa60e, 0xa60f,
- 0xa6f3, 0xa6f3,
- 0xa6f7, 0xa6f7,
- 0xa876, 0xa877,
- 0xa8ce, 0xa8cf,
- 0xa92f, 0xa92f,
- 0xa9c8, 0xa9c9,
- 0xaa5d, 0xaa5f,
- 0xaaf0, 0xaaf1,
- 0xabeb, 0xabeb,
- 0xfe52, 0xfe52,
- 0xfe56, 0xfe57,
- 0xff01, 0xff01,
- 0xff0e, 0xff0e,
- 0xff1f, 0xff1f,
- 0xff61, 0xff61,
- 0x10a56, 0x10a57,
- 0x10f55, 0x10f59,
- 0x10f86, 0x10f89,
- 0x11047, 0x11048,
- 0x110be, 0x110c1,
- 0x11141, 0x11143,
- 0x111c5, 0x111c6,
- 0x111cd, 0x111cd,
- 0x111de, 0x111df,
- 0x11238, 0x11239,
- 0x1123b, 0x1123c,
- 0x112a9, 0x112a9,
- 0x1144b, 0x1144c,
- 0x115c2, 0x115c3,
- 0x115c9, 0x115d7,
- 0x11641, 0x11642,
- 0x1173c, 0x1173e,
- 0x11944, 0x11944,
- 0x11946, 0x11946,
- 0x11a42, 0x11a43,
- 0x11a9b, 0x11a9c,
- 0x11c41, 0x11c42,
- 0x11ef7, 0x11ef8,
- 0x11f43, 0x11f44,
- 0x16a6e, 0x16a6f,
- 0x16af5, 0x16af5,
- 0x16b37, 0x16b38,
- 0x16b44, 0x16b44,
- 0x16e98, 0x16e98,
- 0x1bc9f, 0x1bc9f,
- 0x1da88, 0x1da88,
-}; /* CR_Sentence_Terminal */
-
-/* 'Variation_Selector': Binary Property */
-static const OnigCodePoint CR_Variation_Selector[] = {
- 4,
- 0x180b, 0x180d,
- 0x180f, 0x180f,
- 0xfe00, 0xfe0f,
- 0xe0100, 0xe01ef,
-}; /* CR_Variation_Selector */
-
-/* 'Pattern_White_Space': Binary Property */
-static const OnigCodePoint CR_Pattern_White_Space[] = {
- 5,
- 0x0009, 0x000d,
- 0x0020, 0x0020,
- 0x0085, 0x0085,
- 0x200e, 0x200f,
- 0x2028, 0x2029,
-}; /* CR_Pattern_White_Space */
-
-/* 'Pattern_Syntax': Binary Property */
-static const OnigCodePoint CR_Pattern_Syntax[] = {
- 28,
- 0x0021, 0x002f,
- 0x003a, 0x0040,
- 0x005b, 0x005e,
- 0x0060, 0x0060,
- 0x007b, 0x007e,
- 0x00a1, 0x00a7,
- 0x00a9, 0x00a9,
- 0x00ab, 0x00ac,
- 0x00ae, 0x00ae,
- 0x00b0, 0x00b1,
- 0x00b6, 0x00b6,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x2010, 0x2027,
- 0x2030, 0x203e,
- 0x2041, 0x2053,
- 0x2055, 0x205e,
- 0x2190, 0x245f,
- 0x2500, 0x2775,
- 0x2794, 0x2bff,
- 0x2e00, 0x2e7f,
- 0x3001, 0x3003,
- 0x3008, 0x3020,
- 0x3030, 0x3030,
- 0xfd3e, 0xfd3f,
- 0xfe45, 0xfe46,
-}; /* CR_Pattern_Syntax */
-
-/* 'Prepended_Concatenation_Mark': Binary Property */
-static const OnigCodePoint CR_Prepended_Concatenation_Mark[] = {
- 7,
- 0x0600, 0x0605,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x0890, 0x0891,
- 0x08e2, 0x08e2,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
-}; /* CR_Prepended_Concatenation_Mark */
-
-/* 'Regional_Indicator': Binary Property */
-static const OnigCodePoint CR_Regional_Indicator[] = {
- 1,
- 0x1f1e6, 0x1f1ff,
-}; /* CR_Regional_Indicator */
-
-/* 'Emoji': Emoji */
-static const OnigCodePoint CR_Emoji[] = {
- 151,
- 0x0023, 0x0023,
- 0x002a, 0x002a,
- 0x0030, 0x0039,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x203c, 0x203c,
- 0x2049, 0x2049,
- 0x2122, 0x2122,
- 0x2139, 0x2139,
- 0x2194, 0x2199,
- 0x21a9, 0x21aa,
- 0x231a, 0x231b,
- 0x2328, 0x2328,
- 0x23cf, 0x23cf,
- 0x23e9, 0x23f3,
- 0x23f8, 0x23fa,
- 0x24c2, 0x24c2,
- 0x25aa, 0x25ab,
- 0x25b6, 0x25b6,
- 0x25c0, 0x25c0,
- 0x25fb, 0x25fe,
- 0x2600, 0x2604,
- 0x260e, 0x260e,
- 0x2611, 0x2611,
- 0x2614, 0x2615,
- 0x2618, 0x2618,
- 0x261d, 0x261d,
- 0x2620, 0x2620,
- 0x2622, 0x2623,
- 0x2626, 0x2626,
- 0x262a, 0x262a,
- 0x262e, 0x262f,
- 0x2638, 0x263a,
- 0x2640, 0x2640,
- 0x2642, 0x2642,
- 0x2648, 0x2653,
- 0x265f, 0x2660,
- 0x2663, 0x2663,
- 0x2665, 0x2666,
- 0x2668, 0x2668,
- 0x267b, 0x267b,
- 0x267e, 0x267f,
- 0x2692, 0x2697,
- 0x2699, 0x2699,
- 0x269b, 0x269c,
- 0x26a0, 0x26a1,
- 0x26a7, 0x26a7,
- 0x26aa, 0x26ab,
- 0x26b0, 0x26b1,
- 0x26bd, 0x26be,
- 0x26c4, 0x26c5,
- 0x26c8, 0x26c8,
- 0x26ce, 0x26cf,
- 0x26d1, 0x26d1,
- 0x26d3, 0x26d4,
- 0x26e9, 0x26ea,
- 0x26f0, 0x26f5,
- 0x26f7, 0x26fa,
- 0x26fd, 0x26fd,
- 0x2702, 0x2702,
- 0x2705, 0x2705,
- 0x2708, 0x270d,
- 0x270f, 0x270f,
- 0x2712, 0x2712,
- 0x2714, 0x2714,
- 0x2716, 0x2716,
- 0x271d, 0x271d,
- 0x2721, 0x2721,
- 0x2728, 0x2728,
- 0x2733, 0x2734,
- 0x2744, 0x2744,
- 0x2747, 0x2747,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2763, 0x2764,
- 0x2795, 0x2797,
- 0x27a1, 0x27a1,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2934, 0x2935,
- 0x2b05, 0x2b07,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x3297, 0x3297,
- 0x3299, 0x3299,
- 0x1f004, 0x1f004,
- 0x1f0cf, 0x1f0cf,
- 0x1f170, 0x1f171,
- 0x1f17e, 0x1f17f,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f202,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f23a,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f321,
- 0x1f324, 0x1f393,
- 0x1f396, 0x1f397,
- 0x1f399, 0x1f39b,
- 0x1f39e, 0x1f3f0,
- 0x1f3f3, 0x1f3f5,
- 0x1f3f7, 0x1f4fd,
- 0x1f4ff, 0x1f53d,
- 0x1f549, 0x1f54e,
- 0x1f550, 0x1f567,
- 0x1f56f, 0x1f570,
- 0x1f573, 0x1f57a,
- 0x1f587, 0x1f587,
- 0x1f58a, 0x1f58d,
- 0x1f590, 0x1f590,
- 0x1f595, 0x1f596,
- 0x1f5a4, 0x1f5a5,
- 0x1f5a8, 0x1f5a8,
- 0x1f5b1, 0x1f5b2,
- 0x1f5bc, 0x1f5bc,
- 0x1f5c2, 0x1f5c4,
- 0x1f5d1, 0x1f5d3,
- 0x1f5dc, 0x1f5de,
- 0x1f5e1, 0x1f5e1,
- 0x1f5e3, 0x1f5e3,
- 0x1f5e8, 0x1f5e8,
- 0x1f5ef, 0x1f5ef,
- 0x1f5f3, 0x1f5f3,
- 0x1f5fa, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f6cb, 0x1f6d2,
- 0x1f6d5, 0x1f6d7,
- 0x1f6dc, 0x1f6e5,
- 0x1f6e9, 0x1f6e9,
- 0x1f6eb, 0x1f6ec,
- 0x1f6f0, 0x1f6f0,
- 0x1f6f3, 0x1f6fc,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f90c, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1f9ff,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
-}; /* CR_Emoji */
-
-/* 'Emoji_Presentation': Emoji */
-static const OnigCodePoint CR_Emoji_Presentation[] = {
- 81,
- 0x231a, 0x231b,
- 0x23e9, 0x23ec,
- 0x23f0, 0x23f0,
- 0x23f3, 0x23f3,
- 0x25fd, 0x25fe,
- 0x2614, 0x2615,
- 0x2648, 0x2653,
- 0x267f, 0x267f,
- 0x2693, 0x2693,
- 0x26a1, 0x26a1,
- 0x26aa, 0x26ab,
- 0x26bd, 0x26be,
- 0x26c4, 0x26c5,
- 0x26ce, 0x26ce,
- 0x26d4, 0x26d4,
- 0x26ea, 0x26ea,
- 0x26f2, 0x26f3,
- 0x26f5, 0x26f5,
- 0x26fa, 0x26fa,
- 0x26fd, 0x26fd,
- 0x2705, 0x2705,
- 0x270a, 0x270b,
- 0x2728, 0x2728,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2795, 0x2797,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x1f004, 0x1f004,
- 0x1f0cf, 0x1f0cf,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1e6, 0x1f1ff,
- 0x1f201, 0x1f201,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f236,
- 0x1f238, 0x1f23a,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f32d, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f37e, 0x1f393,
- 0x1f3a0, 0x1f3ca,
- 0x1f3cf, 0x1f3d3,
- 0x1f3e0, 0x1f3f0,
- 0x1f3f4, 0x1f3f4,
- 0x1f3f8, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4fc,
- 0x1f4ff, 0x1f53d,
- 0x1f54b, 0x1f54e,
- 0x1f550, 0x1f567,
- 0x1f57a, 0x1f57a,
- 0x1f595, 0x1f596,
- 0x1f5a4, 0x1f5a4,
- 0x1f5fb, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f6cc, 0x1f6cc,
- 0x1f6d0, 0x1f6d2,
- 0x1f6d5, 0x1f6d7,
- 0x1f6dc, 0x1f6df,
- 0x1f6eb, 0x1f6ec,
- 0x1f6f4, 0x1f6fc,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f90c, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1f9ff,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
-}; /* CR_Emoji_Presentation */
-
-/* 'Emoji_Modifier': Emoji */
-static const OnigCodePoint CR_Emoji_Modifier[] = {
- 1,
- 0x1f3fb, 0x1f3ff,
-}; /* CR_Emoji_Modifier */
-
-/* 'Emoji_Modifier_Base': Emoji */
-static const OnigCodePoint CR_Emoji_Modifier_Base[] = {
- 40,
- 0x261d, 0x261d,
- 0x26f9, 0x26f9,
- 0x270a, 0x270d,
- 0x1f385, 0x1f385,
- 0x1f3c2, 0x1f3c4,
- 0x1f3c7, 0x1f3c7,
- 0x1f3ca, 0x1f3cc,
- 0x1f442, 0x1f443,
- 0x1f446, 0x1f450,
- 0x1f466, 0x1f478,
- 0x1f47c, 0x1f47c,
- 0x1f481, 0x1f483,
- 0x1f485, 0x1f487,
- 0x1f48f, 0x1f48f,
- 0x1f491, 0x1f491,
- 0x1f4aa, 0x1f4aa,
- 0x1f574, 0x1f575,
- 0x1f57a, 0x1f57a,
- 0x1f590, 0x1f590,
- 0x1f595, 0x1f596,
- 0x1f645, 0x1f647,
- 0x1f64b, 0x1f64f,
- 0x1f6a3, 0x1f6a3,
- 0x1f6b4, 0x1f6b6,
- 0x1f6c0, 0x1f6c0,
- 0x1f6cc, 0x1f6cc,
- 0x1f90c, 0x1f90c,
- 0x1f90f, 0x1f90f,
- 0x1f918, 0x1f91f,
- 0x1f926, 0x1f926,
- 0x1f930, 0x1f939,
- 0x1f93c, 0x1f93e,
- 0x1f977, 0x1f977,
- 0x1f9b5, 0x1f9b6,
- 0x1f9b8, 0x1f9b9,
- 0x1f9bb, 0x1f9bb,
- 0x1f9cd, 0x1f9cf,
- 0x1f9d1, 0x1f9dd,
- 0x1fac3, 0x1fac5,
- 0x1faf0, 0x1faf8,
-}; /* CR_Emoji_Modifier_Base */
-
-/* 'Emoji_Component': Emoji */
-static const OnigCodePoint CR_Emoji_Component[] = {
- 10,
- 0x0023, 0x0023,
- 0x002a, 0x002a,
- 0x0030, 0x0039,
- 0x200d, 0x200d,
- 0x20e3, 0x20e3,
- 0xfe0f, 0xfe0f,
- 0x1f1e6, 0x1f1ff,
- 0x1f3fb, 0x1f3ff,
- 0x1f9b0, 0x1f9b3,
- 0xe0020, 0xe007f,
-}; /* CR_Emoji_Component */
-
-/* 'Extended_Pictographic': Emoji */
-static const OnigCodePoint CR_Extended_Pictographic[] = {
- 78,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x203c, 0x203c,
- 0x2049, 0x2049,
- 0x2122, 0x2122,
- 0x2139, 0x2139,
- 0x2194, 0x2199,
- 0x21a9, 0x21aa,
- 0x231a, 0x231b,
- 0x2328, 0x2328,
- 0x2388, 0x2388,
- 0x23cf, 0x23cf,
- 0x23e9, 0x23f3,
- 0x23f8, 0x23fa,
- 0x24c2, 0x24c2,
- 0x25aa, 0x25ab,
- 0x25b6, 0x25b6,
- 0x25c0, 0x25c0,
- 0x25fb, 0x25fe,
- 0x2600, 0x2605,
- 0x2607, 0x2612,
- 0x2614, 0x2685,
- 0x2690, 0x2705,
- 0x2708, 0x2712,
- 0x2714, 0x2714,
- 0x2716, 0x2716,
- 0x271d, 0x271d,
- 0x2721, 0x2721,
- 0x2728, 0x2728,
- 0x2733, 0x2734,
- 0x2744, 0x2744,
- 0x2747, 0x2747,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x2763, 0x2767,
- 0x2795, 0x2797,
- 0x27a1, 0x27a1,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x2934, 0x2935,
- 0x2b05, 0x2b07,
- 0x2b1b, 0x2b1c,
- 0x2b50, 0x2b50,
- 0x2b55, 0x2b55,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x3297, 0x3297,
- 0x3299, 0x3299,
- 0x1f000, 0x1f0ff,
- 0x1f10d, 0x1f10f,
- 0x1f12f, 0x1f12f,
- 0x1f16c, 0x1f171,
- 0x1f17e, 0x1f17f,
- 0x1f18e, 0x1f18e,
- 0x1f191, 0x1f19a,
- 0x1f1ad, 0x1f1e5,
- 0x1f201, 0x1f20f,
- 0x1f21a, 0x1f21a,
- 0x1f22f, 0x1f22f,
- 0x1f232, 0x1f23a,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f3fa,
- 0x1f400, 0x1f53d,
- 0x1f546, 0x1f64f,
- 0x1f680, 0x1f6ff,
- 0x1f774, 0x1f77f,
- 0x1f7d5, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8ff,
- 0x1f90c, 0x1f93a,
- 0x1f93c, 0x1f945,
- 0x1f947, 0x1faff,
- 0x1fc00, 0x1fffd,
-}; /* CR_Extended_Pictographic */
-
-/* 'Unknown': Script */
-static const OnigCodePoint CR_Unknown[] = {
- 705,
- 0x0378, 0x0379,
- 0x0380, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x0530, 0x0530,
- 0x0557, 0x0558,
- 0x058b, 0x058c,
- 0x0590, 0x0590,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ee,
- 0x05f5, 0x05ff,
- 0x070e, 0x070e,
- 0x074b, 0x074c,
- 0x07b2, 0x07bf,
- 0x07fb, 0x07fc,
- 0x082e, 0x082f,
- 0x083f, 0x083f,
- 0x085c, 0x085d,
- 0x085f, 0x085f,
- 0x086b, 0x086f,
- 0x088f, 0x088f,
- 0x0892, 0x0897,
- 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,
- 0x09ff, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a50,
- 0x0a52, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a77, 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,
- 0x0af2, 0x0af8,
- 0x0b00, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b45, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b54,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b64, 0x0b65,
- 0x0b78, 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, 0x0bcf,
- 0x0bd1, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0bff,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c3a, 0x0c3b,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c57,
- 0x0c5b, 0x0c5c,
- 0x0c5e, 0x0c5f,
- 0x0c64, 0x0c65,
- 0x0c70, 0x0c76,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdc,
- 0x0cdf, 0x0cdf,
- 0x0ce4, 0x0ce5,
- 0x0cf0, 0x0cf0,
- 0x0cf4, 0x0cff,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d45, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d50, 0x0d53,
- 0x0d64, 0x0d65,
- 0x0d80, 0x0d80,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0de5,
- 0x0df0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e85,
- 0x0e8b, 0x0e8b,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ecf, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ee0, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6d, 0x0f70,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fcd,
- 0x0fdb, 0x0fff,
- 0x10c6, 0x10c6,
- 0x10c8, 0x10cc,
- 0x10ce, 0x10cf,
- 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, 0x135c,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f6, 0x13f7,
- 0x13fe, 0x13ff,
- 0x169d, 0x169f,
- 0x16f9, 0x16ff,
- 0x1716, 0x171e,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x181a, 0x181f,
- 0x1879, 0x187f,
- 0x18ab, 0x18af,
- 0x18f6, 0x18ff,
- 0x191f, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19ac, 0x19af,
- 0x19ca, 0x19cf,
- 0x19db, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a5f, 0x1a5f,
- 0x1a7d, 0x1a7e,
- 0x1a8a, 0x1a8f,
- 0x1a9a, 0x1a9f,
- 0x1aae, 0x1aaf,
- 0x1acf, 0x1aff,
- 0x1b4d, 0x1b4f,
- 0x1b7f, 0x1b7f,
- 0x1bf4, 0x1bfb,
- 0x1c38, 0x1c3a,
- 0x1c4a, 0x1c4c,
- 0x1c89, 0x1c8f,
- 0x1cbb, 0x1cbc,
- 0x1cc8, 0x1ccf,
- 0x1cfb, 0x1cff,
- 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,
- 0x2065, 0x2065,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x209d, 0x209f,
- 0x20c1, 0x20cf,
- 0x20f1, 0x20ff,
- 0x218c, 0x218f,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x2b74, 0x2b75,
- 0x2b96, 0x2b96,
- 0x2cf4, 0x2cf8,
- 0x2d26, 0x2d26,
- 0x2d28, 0x2d2c,
- 0x2d2e, 0x2d2f,
- 0x2d68, 0x2d6e,
- 0x2d71, 0x2d7e,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2ddf,
- 0x2e5e, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x3130, 0x3130,
- 0x318f, 0x318f,
- 0x31e4, 0x31ef,
- 0x321f, 0x321f,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa4cf,
- 0xa62c, 0xa63f,
- 0xa6f8, 0xa6ff,
- 0xa7cb, 0xa7cf,
- 0xa7d2, 0xa7d2,
- 0xa7d4, 0xa7d4,
- 0xa7da, 0xa7f1,
- 0xa82d, 0xa82f,
- 0xa83a, 0xa83f,
- 0xa878, 0xa87f,
- 0xa8c6, 0xa8cd,
- 0xa8da, 0xa8df,
- 0xa954, 0xa95e,
- 0xa97d, 0xa97f,
- 0xa9ce, 0xa9ce,
- 0xa9da, 0xa9dd,
- 0xa9ff, 0xa9ff,
- 0xaa37, 0xaa3f,
- 0xaa4e, 0xaa4f,
- 0xaa5a, 0xaa5b,
- 0xaac3, 0xaada,
- 0xaaf7, 0xab00,
- 0xab07, 0xab08,
- 0xab0f, 0xab10,
- 0xab17, 0xab1f,
- 0xab27, 0xab27,
- 0xab2f, 0xab2f,
- 0xab6c, 0xab6f,
- 0xabee, 0xabef,
- 0xabfa, 0xabff,
- 0xd7a4, 0xd7af,
- 0xd7c7, 0xd7ca,
- 0xd7fc, 0xf8ff,
- 0xfa6e, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbc3, 0xfbd2,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdce,
- 0xfdd0, 0xfdef,
- 0xfe1a, 0xfe1f,
- 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,
- 0x1018f, 0x1018f,
- 0x1019d, 0x1019f,
- 0x101a1, 0x101cf,
- 0x101fe, 0x1027f,
- 0x1029d, 0x1029f,
- 0x102d1, 0x102df,
- 0x102fc, 0x102ff,
- 0x10324, 0x1032c,
- 0x1034b, 0x1034f,
- 0x1037b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x104af,
- 0x104d4, 0x104d7,
- 0x104fc, 0x104ff,
- 0x10528, 0x1052f,
- 0x10564, 0x1056e,
- 0x1057b, 0x1057b,
- 0x1058b, 0x1058b,
- 0x10593, 0x10593,
- 0x10596, 0x10596,
- 0x105a2, 0x105a2,
- 0x105b2, 0x105b2,
- 0x105ba, 0x105ba,
- 0x105bd, 0x105ff,
- 0x10737, 0x1073f,
- 0x10756, 0x1075f,
- 0x10768, 0x1077f,
- 0x10786, 0x10786,
- 0x107b1, 0x107b1,
- 0x107bb, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10856, 0x10856,
- 0x1089f, 0x108a6,
- 0x108b0, 0x108df,
- 0x108f3, 0x108f3,
- 0x108f6, 0x108fa,
- 0x1091c, 0x1091e,
- 0x1093a, 0x1093e,
- 0x10940, 0x1097f,
- 0x109b8, 0x109bb,
- 0x109d0, 0x109d1,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a36, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a49, 0x10a4f,
- 0x10a59, 0x10a5f,
- 0x10aa0, 0x10abf,
- 0x10ae7, 0x10aea,
- 0x10af7, 0x10aff,
- 0x10b36, 0x10b38,
- 0x10b56, 0x10b57,
- 0x10b73, 0x10b77,
- 0x10b92, 0x10b98,
- 0x10b9d, 0x10ba8,
- 0x10bb0, 0x10bff,
- 0x10c49, 0x10c7f,
- 0x10cb3, 0x10cbf,
- 0x10cf3, 0x10cf9,
- 0x10d28, 0x10d2f,
- 0x10d3a, 0x10e5f,
- 0x10e7f, 0x10e7f,
- 0x10eaa, 0x10eaa,
- 0x10eae, 0x10eaf,
- 0x10eb2, 0x10efc,
- 0x10f28, 0x10f2f,
- 0x10f5a, 0x10f6f,
- 0x10f8a, 0x10faf,
- 0x10fcc, 0x10fdf,
- 0x10ff7, 0x10fff,
- 0x1104e, 0x11051,
- 0x11076, 0x1107e,
- 0x110c3, 0x110cc,
- 0x110ce, 0x110cf,
- 0x110e9, 0x110ef,
- 0x110fa, 0x110ff,
- 0x11135, 0x11135,
- 0x11148, 0x1114f,
- 0x11177, 0x1117f,
- 0x111e0, 0x111e0,
- 0x111f5, 0x111ff,
- 0x11212, 0x11212,
- 0x11242, 0x1127f,
- 0x11287, 0x11287,
- 0x11289, 0x11289,
- 0x1128e, 0x1128e,
- 0x1129e, 0x1129e,
- 0x112aa, 0x112af,
- 0x112eb, 0x112ef,
- 0x112fa, 0x112ff,
- 0x11304, 0x11304,
- 0x1130d, 0x1130e,
- 0x11311, 0x11312,
- 0x11329, 0x11329,
- 0x11331, 0x11331,
- 0x11334, 0x11334,
- 0x1133a, 0x1133a,
- 0x11345, 0x11346,
- 0x11349, 0x1134a,
- 0x1134e, 0x1134f,
- 0x11351, 0x11356,
- 0x11358, 0x1135c,
- 0x11364, 0x11365,
- 0x1136d, 0x1136f,
- 0x11375, 0x113ff,
- 0x1145c, 0x1145c,
- 0x11462, 0x1147f,
- 0x114c8, 0x114cf,
- 0x114da, 0x1157f,
- 0x115b6, 0x115b7,
- 0x115de, 0x115ff,
- 0x11645, 0x1164f,
- 0x1165a, 0x1165f,
- 0x1166d, 0x1167f,
- 0x116ba, 0x116bf,
- 0x116ca, 0x116ff,
- 0x1171b, 0x1171c,
- 0x1172c, 0x1172f,
- 0x11747, 0x117ff,
- 0x1183c, 0x1189f,
- 0x118f3, 0x118fe,
- 0x11907, 0x11908,
- 0x1190a, 0x1190b,
- 0x11914, 0x11914,
- 0x11917, 0x11917,
- 0x11936, 0x11936,
- 0x11939, 0x1193a,
- 0x11947, 0x1194f,
- 0x1195a, 0x1199f,
- 0x119a8, 0x119a9,
- 0x119d8, 0x119d9,
- 0x119e5, 0x119ff,
- 0x11a48, 0x11a4f,
- 0x11aa3, 0x11aaf,
- 0x11af9, 0x11aff,
- 0x11b0a, 0x11bff,
- 0x11c09, 0x11c09,
- 0x11c37, 0x11c37,
- 0x11c46, 0x11c4f,
- 0x11c6d, 0x11c6f,
- 0x11c90, 0x11c91,
- 0x11ca8, 0x11ca8,
- 0x11cb7, 0x11cff,
- 0x11d07, 0x11d07,
- 0x11d0a, 0x11d0a,
- 0x11d37, 0x11d39,
- 0x11d3b, 0x11d3b,
- 0x11d3e, 0x11d3e,
- 0x11d48, 0x11d4f,
- 0x11d5a, 0x11d5f,
- 0x11d66, 0x11d66,
- 0x11d69, 0x11d69,
- 0x11d8f, 0x11d8f,
- 0x11d92, 0x11d92,
- 0x11d99, 0x11d9f,
- 0x11daa, 0x11edf,
- 0x11ef9, 0x11eff,
- 0x11f11, 0x11f11,
- 0x11f3b, 0x11f3d,
- 0x11f5a, 0x11faf,
- 0x11fb1, 0x11fbf,
- 0x11ff2, 0x11ffe,
- 0x1239a, 0x123ff,
- 0x1246f, 0x1246f,
- 0x12475, 0x1247f,
- 0x12544, 0x12f8f,
- 0x12ff3, 0x12fff,
- 0x13456, 0x143ff,
- 0x14647, 0x167ff,
- 0x16a39, 0x16a3f,
- 0x16a5f, 0x16a5f,
- 0x16a6a, 0x16a6d,
- 0x16abf, 0x16abf,
- 0x16aca, 0x16acf,
- 0x16aee, 0x16aef,
- 0x16af6, 0x16aff,
- 0x16b46, 0x16b4f,
- 0x16b5a, 0x16b5a,
- 0x16b62, 0x16b62,
- 0x16b78, 0x16b7c,
- 0x16b90, 0x16e3f,
- 0x16e9b, 0x16eff,
- 0x16f4b, 0x16f4e,
- 0x16f88, 0x16f8e,
- 0x16fa0, 0x16fdf,
- 0x16fe5, 0x16fef,
- 0x16ff2, 0x16fff,
- 0x187f8, 0x187ff,
- 0x18cd6, 0x18cff,
- 0x18d09, 0x1afef,
- 0x1aff4, 0x1aff4,
- 0x1affc, 0x1affc,
- 0x1afff, 0x1afff,
- 0x1b123, 0x1b131,
- 0x1b133, 0x1b14f,
- 0x1b153, 0x1b154,
- 0x1b156, 0x1b163,
- 0x1b168, 0x1b16f,
- 0x1b2fc, 0x1bbff,
- 0x1bc6b, 0x1bc6f,
- 0x1bc7d, 0x1bc7f,
- 0x1bc89, 0x1bc8f,
- 0x1bc9a, 0x1bc9b,
- 0x1bca4, 0x1ceff,
- 0x1cf2e, 0x1cf2f,
- 0x1cf47, 0x1cf4f,
- 0x1cfc4, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d128,
- 0x1d1eb, 0x1d1ff,
- 0x1d246, 0x1d2bf,
- 0x1d2d4, 0x1d2df,
- 0x1d2f4, 0x1d2ff,
- 0x1d357, 0x1d35f,
- 0x1d379, 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,
- 0x1d7cc, 0x1d7cd,
- 0x1da8c, 0x1da9a,
- 0x1daa0, 0x1daa0,
- 0x1dab0, 0x1deff,
- 0x1df1f, 0x1df24,
- 0x1df2b, 0x1dfff,
- 0x1e007, 0x1e007,
- 0x1e019, 0x1e01a,
- 0x1e022, 0x1e022,
- 0x1e025, 0x1e025,
- 0x1e02b, 0x1e02f,
- 0x1e06e, 0x1e08e,
- 0x1e090, 0x1e0ff,
- 0x1e12d, 0x1e12f,
- 0x1e13e, 0x1e13f,
- 0x1e14a, 0x1e14d,
- 0x1e150, 0x1e28f,
- 0x1e2af, 0x1e2bf,
- 0x1e2fa, 0x1e2fe,
- 0x1e300, 0x1e4cf,
- 0x1e4fa, 0x1e7df,
- 0x1e7e7, 0x1e7e7,
- 0x1e7ec, 0x1e7ec,
- 0x1e7ef, 0x1e7ef,
- 0x1e7ff, 0x1e7ff,
- 0x1e8c5, 0x1e8c6,
- 0x1e8d7, 0x1e8ff,
- 0x1e94c, 0x1e94f,
- 0x1e95a, 0x1e95d,
- 0x1e960, 0x1ec70,
- 0x1ecb5, 0x1ed00,
- 0x1ed3e, 0x1edff,
- 0x1ee04, 0x1ee04,
- 0x1ee20, 0x1ee20,
- 0x1ee23, 0x1ee23,
- 0x1ee25, 0x1ee26,
- 0x1ee28, 0x1ee28,
- 0x1ee33, 0x1ee33,
- 0x1ee38, 0x1ee38,
- 0x1ee3a, 0x1ee3a,
- 0x1ee3c, 0x1ee41,
- 0x1ee43, 0x1ee46,
- 0x1ee48, 0x1ee48,
- 0x1ee4a, 0x1ee4a,
- 0x1ee4c, 0x1ee4c,
- 0x1ee50, 0x1ee50,
- 0x1ee53, 0x1ee53,
- 0x1ee55, 0x1ee56,
- 0x1ee58, 0x1ee58,
- 0x1ee5a, 0x1ee5a,
- 0x1ee5c, 0x1ee5c,
- 0x1ee5e, 0x1ee5e,
- 0x1ee60, 0x1ee60,
- 0x1ee63, 0x1ee63,
- 0x1ee65, 0x1ee66,
- 0x1ee6b, 0x1ee6b,
- 0x1ee73, 0x1ee73,
- 0x1ee78, 0x1ee78,
- 0x1ee7d, 0x1ee7d,
- 0x1ee7f, 0x1ee7f,
- 0x1ee8a, 0x1ee8a,
- 0x1ee9c, 0x1eea0,
- 0x1eea4, 0x1eea4,
- 0x1eeaa, 0x1eeaa,
- 0x1eebc, 0x1eeef,
- 0x1eef2, 0x1efff,
- 0x1f02c, 0x1f02f,
- 0x1f094, 0x1f09f,
- 0x1f0af, 0x1f0b0,
- 0x1f0c0, 0x1f0c0,
- 0x1f0d0, 0x1f0d0,
- 0x1f0f6, 0x1f0ff,
- 0x1f1ae, 0x1f1e5,
- 0x1f203, 0x1f20f,
- 0x1f23c, 0x1f23f,
- 0x1f249, 0x1f24f,
- 0x1f252, 0x1f25f,
- 0x1f266, 0x1f2ff,
- 0x1f6d8, 0x1f6db,
- 0x1f6ed, 0x1f6ef,
- 0x1f6fd, 0x1f6ff,
- 0x1f777, 0x1f77a,
- 0x1f7da, 0x1f7df,
- 0x1f7ec, 0x1f7ef,
- 0x1f7f1, 0x1f7ff,
- 0x1f80c, 0x1f80f,
- 0x1f848, 0x1f84f,
- 0x1f85a, 0x1f85f,
- 0x1f888, 0x1f88f,
- 0x1f8ae, 0x1f8af,
- 0x1f8b2, 0x1f8ff,
- 0x1fa54, 0x1fa5f,
- 0x1fa6e, 0x1fa6f,
- 0x1fa7d, 0x1fa7f,
- 0x1fa89, 0x1fa8f,
- 0x1fabe, 0x1fabe,
- 0x1fac6, 0x1facd,
- 0x1fadc, 0x1fadf,
- 0x1fae9, 0x1faef,
- 0x1faf9, 0x1faff,
- 0x1fb93, 0x1fb93,
- 0x1fbcb, 0x1fbef,
- 0x1fbfa, 0x1ffff,
- 0x2a6e0, 0x2a6ff,
- 0x2b73a, 0x2b73f,
- 0x2b81e, 0x2b81f,
- 0x2cea2, 0x2ceaf,
- 0x2ebe1, 0x2f7ff,
- 0x2fa1e, 0x2ffff,
- 0x3134b, 0x3134f,
- 0x323b0, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0x10ffff,
-}; /* CR_Unknown */
-
-#ifdef USE_UNICODE_AGE_PROPERTIES
-/* 'Age_1_1': Derived Age 1.1 */
-static const OnigCodePoint CR_Age_1_1[] = {
- 288,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x05b0, 0x05b9,
- 0x05bb, 0x05c3,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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,
- 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,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1e00, 0x1e9a,
- 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, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20aa,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xe000, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffd, 0xffff,
-}; /* CR_Age_1_1 */
-
-/* 'Age_2_0': Derived Age 2.0 */
-static const OnigCodePoint CR_Age_2_0[] = {
- 312,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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,
- 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, 0x0f69,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f95,
- 0x0f97, 0x0f97,
- 0x0f99, 0x0fad,
- 0x0fb1, 0x0fb7,
- 0x0fb9, 0x0fb9,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 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, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20ab,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffd, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_2_0 */
-
-/* 'Age_2_1': Derived Age 2.1 */
-static const OnigCodePoint CR_Age_2_1[] = {
- 312,
- 0x0000, 0x01f5,
- 0x01fa, 0x0217,
- 0x0250, 0x02a8,
- 0x02b0, 0x02de,
- 0x02e0, 0x02e9,
- 0x0300, 0x0345,
- 0x0360, 0x0361,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d6,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03f3,
- 0x0401, 0x040c,
- 0x040e, 0x044f,
- 0x0451, 0x045c,
- 0x045e, 0x0486,
- 0x0490, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04eb,
- 0x04ee, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x0589,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0652,
- 0x0660, 0x066d,
- 0x0670, 0x06b7,
- 0x06ba, 0x06be,
- 0x06c0, 0x06ce,
- 0x06d0, 0x06ed,
- 0x06f0, 0x06f9,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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,
- 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, 0x0f69,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f95,
- 0x0f97, 0x0f97,
- 0x0f99, 0x0fad,
- 0x0fb1, 0x0fb7,
- 0x0fb9, 0x0fb9,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 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, 0x202e,
- 0x2030, 0x2046,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20ac,
- 0x20d0, 0x20e1,
- 0x2100, 0x2138,
- 0x2153, 0x2182,
- 0x2190, 0x21ea,
- 0x2200, 0x22f1,
- 0x2300, 0x2300,
- 0x2302, 0x237a,
- 0x2400, 0x2424,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25ef,
- 0x2600, 0x2613,
- 0x261a, 0x266f,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x3000, 0x3037,
- 0x303f, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x319f,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x4e00, 0x9fa5,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1e, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_2_1 */
-
-/* 'Age_3_0': Derived Age 3.0 */
-static const OnigCodePoint CR_Age_3_0[] = {
- 369,
- 0x0000, 0x021f,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034e,
- 0x0360, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d7,
- 0x03da, 0x03f3,
- 0x0400, 0x0486,
- 0x0488, 0x0489,
- 0x048c, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x066d,
- 0x0670, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b0,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 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, 0x2046,
- 0x2048, 0x204d,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20af,
- 0x20d0, 0x20e3,
- 0x2100, 0x213a,
- 0x2153, 0x2183,
- 0x2190, 0x21f3,
- 0x2200, 0x22f1,
- 0x2300, 0x237b,
- 0x237d, 0x239a,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25f7,
- 0x2600, 0x2613,
- 0x2619, 0x2671,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x2800, 0x28ff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303a,
- 0x303e, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4a1,
- 0xa4a4, 0xa4b3,
- 0xa4b5, 0xa4c0,
- 0xa4c2, 0xa4c4,
- 0xa4c6, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xffff,
- 0x1fffe, 0x1ffff,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_0 */
-
-/* 'Age_3_1': Derived Age 3.1 */
-static const OnigCodePoint CR_Age_3_1[] = {
- 402,
- 0x0000, 0x021f,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034e,
- 0x0360, 0x0362,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03d7,
- 0x03da, 0x03f5,
- 0x0400, 0x0486,
- 0x0488, 0x0489,
- 0x048c, 0x04c4,
- 0x04c7, 0x04c8,
- 0x04cb, 0x04cc,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x066d,
- 0x0670, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b0,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f6,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 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, 0x2046,
- 0x2048, 0x204d,
- 0x206a, 0x2070,
- 0x2074, 0x208e,
- 0x20a0, 0x20af,
- 0x20d0, 0x20e3,
- 0x2100, 0x213a,
- 0x2153, 0x2183,
- 0x2190, 0x21f3,
- 0x2200, 0x22f1,
- 0x2300, 0x237b,
- 0x237d, 0x239a,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24ea,
- 0x2500, 0x2595,
- 0x25a0, 0x25f7,
- 0x2600, 0x2613,
- 0x2619, 0x2671,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2776, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x2800, 0x28ff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303a,
- 0x303e, 0x303f,
- 0x3041, 0x3094,
- 0x3099, 0x309e,
- 0x30a1, 0x30fe,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x3200, 0x321c,
- 0x3220, 0x3243,
- 0x3260, 0x327b,
- 0x327f, 0x32b0,
- 0x32c0, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4a1,
- 0xa4a4, 0xa4b3,
- 0xa4b5, 0xa4c0,
- 0xa4c2, 0xa4c4,
- 0xa4c6, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfb,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe44,
- 0xfe49, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe72,
- 0xfe74, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xff5e,
- 0xff61, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xffff,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10400, 0x10425,
- 0x10428, 0x1044d,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c0,
- 0x1d4c2, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_1 */
-
-/* 'Age_3_2': Derived Age 3.2 */
-static const OnigCodePoint CR_Age_3_2[] = {
- 397,
- 0x0000, 0x0220,
- 0x0222, 0x0233,
- 0x0250, 0x02ad,
- 0x02b0, 0x02ee,
- 0x0300, 0x034f,
- 0x0360, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f6,
- 0x0400, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0655,
- 0x0660, 0x06ed,
- 0x06f0, 0x06fe,
- 0x0700, 0x070d,
- 0x070f, 0x072c,
- 0x0730, 0x074a,
- 0x0780, 0x07b1,
- 0x0901, 0x0903,
- 0x0905, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a02, 0x0a02,
- 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, 0x0a8b,
- 0x0a8d, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae0,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b36, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b70,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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,
- 0x0cbe, 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, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f8,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dc,
- 0x17e0, 0x17e9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 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, 0x2052,
- 0x2057, 0x2057,
- 0x205f, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x20a0, 0x20b1,
- 0x20d0, 0x20ea,
- 0x2100, 0x213a,
- 0x213d, 0x214b,
- 0x2153, 0x2183,
- 0x2190, 0x23ce,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x24fe,
- 0x2500, 0x2613,
- 0x2616, 0x2617,
- 0x2619, 0x267d,
- 0x2680, 0x2689,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2aff,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31f0, 0x321c,
- 0x3220, 0x3243,
- 0x3251, 0x327b,
- 0x327f, 0x32cb,
- 0x32d0, 0x32fe,
- 0x3300, 0x3376,
- 0x337b, 0x33dd,
- 0x33e0, 0x33fe,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfc,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe46,
- 0xfe49, 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, 0xffff,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10400, 0x10425,
- 0x10428, 0x1044d,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c0,
- 0x1d4c2, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_3_2 */
-
-/* 'Age_4_0': Derived Age 4.0 */
-static const OnigCodePoint CR_Age_4_0[] = {
- 412,
- 0x0000, 0x0236,
- 0x0250, 0x0357,
- 0x035d, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03fb,
- 0x0400, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f5,
- 0x04f8, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05a1,
- 0x05a3, 0x05b9,
- 0x05bb, 0x05c4,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060c, 0x0615,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x0658,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x074f,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 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, 0x0bb5,
- 0x0bb7, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be7, 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, 0x0fcf,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10f8,
- 0x10fb, 0x10fb,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1206,
- 0x1208, 0x1246,
- 0x1248, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1286,
- 0x1288, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12ae,
- 0x12b0, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12ce,
- 0x12d0, 0x12d6,
- 0x12d8, 0x12ee,
- 0x12f0, 0x130e,
- 0x1310, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x131e,
- 0x1320, 0x1346,
- 0x1348, 0x135a,
- 0x1361, 0x137c,
- 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,
- 0x19e0, 0x19ff,
- 0x1d00, 0x1d6b,
- 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, 0x2054,
- 0x2057, 0x2057,
- 0x205f, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x20a0, 0x20b1,
- 0x20d0, 0x20ea,
- 0x2100, 0x213b,
- 0x213d, 0x214b,
- 0x2153, 0x2183,
- 0x2190, 0x23d0,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2617,
- 0x2619, 0x267d,
- 0x2680, 0x2691,
- 0x26a0, 0x26a1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b0d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x327d,
- 0x327f, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fa5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe0f,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1013f,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x1039f,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 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, 0x1d6a3,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_4_0 */
-
-/* 'Age_4_1': Derived Age 4.1 */
-static const OnigCodePoint CR_Age_4_1[] = {
- 430,
- 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,
- 0xfdd0, 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, 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,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_4_1 */
-
-/* 'Age_5_0': Derived Age 5.0 */
-static const OnigCodePoint CR_Age_5_0[] = {
- 440,
- 0x0000, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x0513,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 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,
- 0x07c0, 0x07fa,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097b, 0x097f,
- 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, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 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,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1d00, 0x1dca,
- 0x1dfe, 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, 0x20ef,
- 0x2100, 0x214e,
- 0x2153, 0x2184,
- 0x2190, 0x23e7,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b2,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b1a,
- 0x2b20, 0x2b23,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c6c,
- 0x2c74, 0x2c77,
- 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, 0xa71a,
- 0xa720, 0xa721,
- 0xa800, 0xa82b,
- 0xa840, 0xa877,
- 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,
- 0xfdd0, 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, 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,
- 0x10900, 0x10919,
- 0x1091f, 0x1091f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_0 */
-
-/* 'Age_5_1': Derived Age 5.1 */
-static const OnigCodePoint CR_Age_5_1[] = {
- 455,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0523,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0972,
- 0x097b, 0x097f,
- 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,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0f6c,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd4,
- 0x1000, 0x1099,
- 0x109e, 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, 0x18aa,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1d00, 0x1de6,
- 0x1dfe, 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, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20f0,
- 0x2100, 0x214f,
- 0x2153, 0x2188,
- 0x2190, 0x23e7,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269d,
- 0x26a0, 0x26bc,
- 0x26c0, 0x26c3,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27d0, 0x2b4c,
- 0x2b50, 0x2b54,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2c6f,
- 0x2c71, 0x2c7d,
- 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,
- 0x2de0, 0x2e30,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fc3,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa500, 0xa62b,
- 0xa640, 0xa65f,
- 0xa662, 0xa673,
- 0xa67c, 0xa697,
- 0xa700, 0xa78c,
- 0xa7fb, 0xa82b,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa900, 0xa953,
- 0xa95f, 0xa95f,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa5f,
- 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,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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,
- 0x10900, 0x10919,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1fffe, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_1 */
-
-/* 'Age_5_2': Derived Age 5.2 */
-static const OnigCodePoint CR_Age_5_2[] = {
- 495,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0525,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0900, 0x0939,
- 0x093c, 0x094e,
- 0x0950, 0x0955,
- 0x0958, 0x0972,
- 0x0979, 0x097f,
- 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0f6c,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fd8,
- 0x1000, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 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,
- 0x1400, 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1c00, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cd0, 0x1cf2,
- 0x1d00, 0x1de6,
- 0x1dfd, 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, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b8,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23e8,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26cd,
- 0x26cf, 0x26e1,
- 0x26e3, 0x26e3,
- 0x26e8, 0x26ff,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27d0, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf1,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e31,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa65f,
- 0xa662, 0xa673,
- 0xa67c, 0xa697,
- 0xa6a0, 0xa6f7,
- 0xa700, 0xa78c,
- 0xa7fb, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11080, 0x110c1,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f131, 0x1f131,
- 0x1f13d, 0x1f13d,
- 0x1f13f, 0x1f13f,
- 0x1f142, 0x1f142,
- 0x1f146, 0x1f146,
- 0x1f14a, 0x1f14e,
- 0x1f157, 0x1f157,
- 0x1f15f, 0x1f15f,
- 0x1f179, 0x1f179,
- 0x1f17b, 0x1f17c,
- 0x1f17f, 0x1f17f,
- 0x1f18a, 0x1f18d,
- 0x1f190, 0x1f190,
- 0x1f200, 0x1f200,
- 0x1f210, 0x1f231,
- 0x1f240, 0x1f248,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_5_2 */
-
-/* 'Age_6_0': Derived Age 6.0 */
-static const OnigCodePoint CR_Age_6_0[] = {
- 511,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1baa,
- 0x1bae, 0x1bb9,
- 0x1bc0, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cd0, 0x1cf2,
- 0x1d00, 0x1de6,
- 0x1dfc, 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, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20b9,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x27ca,
- 0x27cc, 0x27cc,
- 0x27ce, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf1,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e31,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa673,
- 0xa67c, 0xa697,
- 0xa6a0, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa791,
- 0xa7a0, 0xa7a9,
- 0xa7fa, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaadf,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f169,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f5ff,
- 0x1f601, 0x1f610,
- 0x1f612, 0x1f614,
- 0x1f616, 0x1f616,
- 0x1f618, 0x1f618,
- 0x1f61a, 0x1f61a,
- 0x1f61c, 0x1f61e,
- 0x1f620, 0x1f625,
- 0x1f628, 0x1f62b,
- 0x1f62d, 0x1f62d,
- 0x1f630, 0x1f633,
- 0x1f635, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_0 */
-
-/* 'Age_6_1': Derived Age 6.1 */
-static const OnigCodePoint CR_Age_6_1[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 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, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20b9,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_1 */
-
-/* 'Age_6_2': Derived Age 6.2 */
-static const OnigCodePoint CR_Age_6_2[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061b,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 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, 0x2064,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20ba,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_2 */
-
-/* 'Age_6_3': Derived Age 6.3 */
-static const OnigCodePoint CR_Age_6_3[] = {
- 549,
- 0x0000, 0x0377,
- 0x037a, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x0527,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058f, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0604,
- 0x0606, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08a0,
- 0x08a2, 0x08ac,
- 0x08e4, 0x08fe,
- 0x0900, 0x0977,
- 0x0979, 0x097f,
- 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1d00, 0x1de6,
- 0x1dfc, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20ba,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23f3,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x26ff,
- 0x2701, 0x2b4c,
- 0x2b50, 0x2b59,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e3b,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa697,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa793,
- 0xa7a0, 0xa7aa,
- 0xa7f8, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9df,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaa7b,
- 0xaa80, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe26,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10190, 0x1019b,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 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, 0x10855,
- 0x10857, 0x1085f,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a7f,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b7f,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x11080, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11180, 0x111c8,
- 0x111d0, 0x111d9,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x12000, 0x1236e,
- 0x12400, 0x12462,
- 0x12470, 0x12473,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0be,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0df,
- 0x1f100, 0x1f10a,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f320,
- 0x1f330, 0x1f335,
- 0x1f337, 0x1f37c,
- 0x1f380, 0x1f393,
- 0x1f3a0, 0x1f3c4,
- 0x1f3c6, 0x1f3ca,
- 0x1f3e0, 0x1f3f0,
- 0x1f400, 0x1f43e,
- 0x1f440, 0x1f440,
- 0x1f442, 0x1f4f7,
- 0x1f4f9, 0x1f4fc,
- 0x1f500, 0x1f53d,
- 0x1f540, 0x1f543,
- 0x1f550, 0x1f567,
- 0x1f5fb, 0x1f640,
- 0x1f645, 0x1f64f,
- 0x1f680, 0x1f6c5,
- 0x1f700, 0x1f773,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_6_3 */
-
-/* 'Age_7_0': Derived Age 7.0 */
-static const OnigCodePoint CR_Age_7_0[] = {
- 610,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b2,
- 0x08e4, 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c59,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c81, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfc, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bd,
- 0x20d0, 0x20f0,
- 0x2100, 0x2189,
- 0x2190, 0x23fa,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e42,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fcc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa69d,
- 0xa69f, 0xa6f7,
- 0xa700, 0xa78e,
- 0xa790, 0xa7ad,
- 0xa7b0, 0xa7b1,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fb,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab5f,
- 0xab64, 0xab65,
- 0xabc0, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe2d,
- 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018c,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x10900, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109be, 0x109bf,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111c8,
- 0x111cd, 0x111cd,
- 0x111d0, 0x111da,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123d,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11301, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115c9,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x12000, 0x12398,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x13000, 0x1342e,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1d7ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f32c,
- 0x1f330, 0x1f37d,
- 0x1f380, 0x1f3ce,
- 0x1f3d4, 0x1f3f7,
- 0x1f400, 0x1f4fe,
- 0x1f500, 0x1f54a,
- 0x1f550, 0x1f579,
- 0x1f57b, 0x1f5a3,
- 0x1f5a5, 0x1f642,
- 0x1f645, 0x1f6cf,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f3,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_7_0 */
-
-/* 'Age_8_0': Derived Age 8.0 */
-static const OnigCodePoint CR_Age_8_0[] = {
- 623,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b4,
- 0x08e3, 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c7f,
- 0x0c81, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4e,
- 0x0d57, 0x0d57,
- 0x0d5f, 0x0d63,
- 0x0d66, 0x0d75,
- 0x0d79, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c7f,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfc, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20be,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x23fa,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e42,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fd5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ad,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c4,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018c,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123d,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f19a,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23a,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f579,
- 0x1f57b, 0x1f5a3,
- 0x1f5a5, 0x1f6d0,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f3,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f910, 0x1f918,
- 0x1f980, 0x1f984,
- 0x1f9c0, 0x1f9c0,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_8_0 */
-
-/* 'Age_9_0': Derived Age 9.0 */
-static const OnigCodePoint CR_Age_9_0[] = {
- 648,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 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, 0x09fb,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0af9, 0x0af9,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d01, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d3a,
- 0x0d3d, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf6,
- 0x1cf8, 0x1cf9,
- 0x1d00, 0x1df5,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20be,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x23fe,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd1,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e44,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312d,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fd5,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ae,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x10330, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe0,
- 0x17000, 0x187ec,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b001,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f300, 0x1f6d2,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f6,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f910, 0x1f91e,
- 0x1f920, 0x1f927,
- 0x1f930, 0x1f930,
- 0x1f933, 0x1f93e,
- 0x1f940, 0x1f94b,
- 0x1f950, 0x1f95e,
- 0x1f980, 0x1f991,
- 0x1f9c0, 0x1f9c0,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_9_0 */
-
-/* 'Age_10_0': Derived Age 10.0 */
-static const OnigCodePoint CR_Age_10_0[] = {
- 659,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x0800, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d4, 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, 0x09fd,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a75,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1cc0, 0x1cc7,
- 0x1cd0, 0x1cf9,
- 0x1d00, 0x1df9,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bb9,
- 0x2bbd, 0x2bc8,
- 0x2bca, 0x2bd2,
- 0x2bec, 0x2bef,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e49,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312e,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fea,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ae,
- 0xa7b0, 0xa7b7,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa8fd,
- 0xa900, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10cff,
- 0x10e60, 0x10e7e,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11143,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133c, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145d,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x11719,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11a83,
- 0x11a86, 0x11a9c,
- 0x11a9e, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x17000, 0x187ec,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d371,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f12e,
- 0x1f130, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d4,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f8,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d4,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f910, 0x1f93e,
- 0x1f940, 0x1f94c,
- 0x1f950, 0x1f96b,
- 0x1f980, 0x1f997,
- 0x1f9c0, 0x1f9c0,
- 0x1f9d0, 0x1f9e6,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_10_0 */
-
-/* 'Age_11_0': Derived Age 11.0 */
-static const OnigCodePoint CR_Age_11_0[] = {
- 668,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c78, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 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, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cf9,
- 0x1d00, 0x1df9,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2bc8,
- 0x2bca, 0x2bfe,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4e,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7b9,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab65,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145e,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b7,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11a83,
- 0x11a86, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x12000, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f44,
- 0x16f50, 0x16f7e,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe1,
- 0x17000, 0x187f1,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94a,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16b,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d4,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6f9,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f910, 0x1f93e,
- 0x1f940, 0x1f970,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f97a,
- 0x1f97c, 0x1f9a2,
- 0x1f9b0, 0x1f9b9,
- 0x1f9c0, 0x1f9c2,
- 0x1f9d0, 0x1f9ff,
- 0x1fa60, 0x1fa6d,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_11_0 */
-
-/* 'Age_12_0': Derived Age 12.0 */
-static const OnigCodePoint CR_Age_12_0[] = {
- 677,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_12_0 */
-
-/* 'Age_12_1': Derived Age 12.1 */
-static const OnigCodePoint CR_Age_12_1[] = {
- 676,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08bd,
- 0x08d3, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1abe,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b98, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e4f,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31ba,
- 0x31c0, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x4db5,
- 0x4dc0, 0x9fef,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7c6,
- 0xa7f7, 0xa82b,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab67,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019b,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11146,
- 0x11150, 0x11176,
- 0x11180, 0x111cd,
- 0x111d0, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x11459,
- 0x1145b, 0x1145b,
- 0x1145d, 0x1145f,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x118ff,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe3,
- 0x17000, 0x187f7,
- 0x18800, 0x18af2,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f10c,
- 0x1f110, 0x1f16c,
- 0x1f170, 0x1f1ac,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d5,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fa,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f900, 0x1f90b,
- 0x1f90d, 0x1f971,
- 0x1f973, 0x1f976,
- 0x1f97a, 0x1f9a2,
- 0x1f9a5, 0x1f9aa,
- 0x1f9ae, 0x1f9ca,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa73,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa82,
- 0x1fa90, 0x1fa95,
- 0x1fffe, 0x2a6d6,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x2ffff,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_12_1 */
-
-/* 'Age_13_0': Derived Age 13.0 */
-static const OnigCodePoint CR_Age_13_0[] = {
- 686,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x061c,
- 0x061e, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x08a0, 0x08b4,
- 0x08b6, 0x08c7,
- 0x08d3, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3d, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 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, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ac0,
- 0x1b00, 0x1b4b,
- 0x1b50, 0x1b7c,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 0x1df9,
- 0x1dfb, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20bf,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c60, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e52,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0x9ffc,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7bf,
- 0xa7c2, 0xa7ca,
- 0xa7f5, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdd0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1056f,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x1106f,
- 0x1107f, 0x110c1,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b8,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x1173f,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ac0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16a6f,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1b000, 0x1b11e,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1e8,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6e0, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1f978,
- 0x1f97a, 0x1f9cb,
- 0x1f9cd, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa74,
- 0x1fa78, 0x1fa7a,
- 0x1fa80, 0x1fa86,
- 0x1fa90, 0x1faa8,
- 0x1fab0, 0x1fab6,
- 0x1fac0, 0x1fac2,
- 0x1fad0, 0x1fad6,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x1fffe, 0x2a6dd,
- 0x2a700, 0x2b734,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x3134a,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_13_0 */
-
-/* 'Age_14_0': Derived Age 14.0 */
-static const OnigCodePoint CR_Age_14_0[] = {
- 706,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf2,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10f00, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10f70, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x110c2,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x1123e,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x1342e,
- 0x13430, 0x13438,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b150, 0x1b152,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1ea,
- 0x1d200, 0x1d245,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dd, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f773,
- 0x1f780, 0x1f7d8,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa74,
- 0x1fa78, 0x1fa7c,
- 0x1fa80, 0x1fa86,
- 0x1fa90, 0x1faac,
- 0x1fab0, 0x1faba,
- 0x1fac0, 0x1fac5,
- 0x1fad0, 0x1fad9,
- 0x1fae0, 0x1fae7,
- 0x1faf0, 0x1faf6,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x1fffe, 0x2a6df,
- 0x2a700, 0x2b738,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x3134a,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_14_0 */
-
-/* 'Age_15_0': Derived Age 15.0 */
-static const OnigCodePoint CR_Age_15_0[] = {
- 715,
- 0x0000, 0x0377,
- 0x037a, 0x037f,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x052f,
- 0x0531, 0x0556,
- 0x0559, 0x058a,
- 0x058d, 0x058f,
- 0x0591, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05ef, 0x05f4,
- 0x0600, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x07b1,
- 0x07c0, 0x07fa,
- 0x07fd, 0x082d,
- 0x0830, 0x083e,
- 0x0840, 0x085b,
- 0x085e, 0x085e,
- 0x0860, 0x086a,
- 0x0870, 0x088e,
- 0x0890, 0x0891,
- 0x0898, 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, 0x09fe,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a76,
- 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, 0x0af1,
- 0x0af9, 0x0aff,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b44,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b63,
- 0x0b66, 0x0b77,
- 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,
- 0x0bd0, 0x0bd0,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c00, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c39,
- 0x0c3c, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c58, 0x0c5a,
- 0x0c5d, 0x0c5d,
- 0x0c60, 0x0c63,
- 0x0c66, 0x0c6f,
- 0x0c77, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cdd, 0x0cde,
- 0x0ce0, 0x0ce3,
- 0x0ce6, 0x0cef,
- 0x0cf1, 0x0cf3,
- 0x0d00, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d44,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4f,
- 0x0d54, 0x0d63,
- 0x0d66, 0x0d7f,
- 0x0d81, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0de6, 0x0def,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e86, 0x0e8a,
- 0x0e8c, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ece,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edf,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6c,
- 0x0f71, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fce, 0x0fda,
- 0x1000, 0x10c5,
- 0x10c7, 0x10c7,
- 0x10cd, 0x10cd,
- 0x10d0, 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,
- 0x135d, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f5,
- 0x13f8, 0x13fd,
- 0x1400, 0x169c,
- 0x16a0, 0x16f8,
- 0x1700, 0x1715,
- 0x171f, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x1819,
- 0x1820, 0x1878,
- 0x1880, 0x18aa,
- 0x18b0, 0x18f5,
- 0x1900, 0x191e,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19ab,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19da,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a5e,
- 0x1a60, 0x1a7c,
- 0x1a7f, 0x1a89,
- 0x1a90, 0x1a99,
- 0x1aa0, 0x1aad,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b4c,
- 0x1b50, 0x1b7e,
- 0x1b80, 0x1bf3,
- 0x1bfc, 0x1c37,
- 0x1c3b, 0x1c49,
- 0x1c4d, 0x1c88,
- 0x1c90, 0x1cba,
- 0x1cbd, 0x1cc7,
- 0x1cd0, 0x1cfa,
- 0x1d00, 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, 0x2064,
- 0x2066, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x209c,
- 0x20a0, 0x20c0,
- 0x20d0, 0x20f0,
- 0x2100, 0x218b,
- 0x2190, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x2b73,
- 0x2b76, 0x2b95,
- 0x2b97, 0x2cf3,
- 0x2cf9, 0x2d25,
- 0x2d27, 0x2d27,
- 0x2d2d, 0x2d2d,
- 0x2d30, 0x2d67,
- 0x2d6f, 0x2d70,
- 0x2d7f, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2de0, 0x2e5d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312f,
- 0x3131, 0x318e,
- 0x3190, 0x31e3,
- 0x31f0, 0x321e,
- 0x3220, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa4d0, 0xa62b,
- 0xa640, 0xa6f7,
- 0xa700, 0xa7ca,
- 0xa7d0, 0xa7d1,
- 0xa7d3, 0xa7d3,
- 0xa7d5, 0xa7d9,
- 0xa7f2, 0xa82c,
- 0xa830, 0xa839,
- 0xa840, 0xa877,
- 0xa880, 0xa8c5,
- 0xa8ce, 0xa8d9,
- 0xa8e0, 0xa953,
- 0xa95f, 0xa97c,
- 0xa980, 0xa9cd,
- 0xa9cf, 0xa9d9,
- 0xa9de, 0xa9fe,
- 0xaa00, 0xaa36,
- 0xaa40, 0xaa4d,
- 0xaa50, 0xaa59,
- 0xaa5c, 0xaac2,
- 0xaadb, 0xaaf6,
- 0xab01, 0xab06,
- 0xab09, 0xab0e,
- 0xab11, 0xab16,
- 0xab20, 0xab26,
- 0xab28, 0xab2e,
- 0xab30, 0xab6b,
- 0xab70, 0xabed,
- 0xabf0, 0xabf9,
- 0xac00, 0xd7a3,
- 0xd7b0, 0xd7c6,
- 0xd7cb, 0xd7fb,
- 0xd800, 0xfa6d,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbc2,
- 0xfbd3, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdcf, 0xfe19,
- 0xfe20, 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, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018e,
- 0x10190, 0x1019c,
- 0x101a0, 0x101a0,
- 0x101d0, 0x101fd,
- 0x10280, 0x1029c,
- 0x102a0, 0x102d0,
- 0x102e0, 0x102fb,
- 0x10300, 0x10323,
- 0x1032d, 0x1034a,
- 0x10350, 0x1037a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x104b0, 0x104d3,
- 0x104d8, 0x104fb,
- 0x10500, 0x10527,
- 0x10530, 0x10563,
- 0x1056f, 0x1057a,
- 0x1057c, 0x1058a,
- 0x1058c, 0x10592,
- 0x10594, 0x10595,
- 0x10597, 0x105a1,
- 0x105a3, 0x105b1,
- 0x105b3, 0x105b9,
- 0x105bb, 0x105bc,
- 0x10600, 0x10736,
- 0x10740, 0x10755,
- 0x10760, 0x10767,
- 0x10780, 0x10785,
- 0x10787, 0x107b0,
- 0x107b2, 0x107ba,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x10855,
- 0x10857, 0x1089e,
- 0x108a7, 0x108af,
- 0x108e0, 0x108f2,
- 0x108f4, 0x108f5,
- 0x108fb, 0x1091b,
- 0x1091f, 0x10939,
- 0x1093f, 0x1093f,
- 0x10980, 0x109b7,
- 0x109bc, 0x109cf,
- 0x109d2, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a35,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a48,
- 0x10a50, 0x10a58,
- 0x10a60, 0x10a9f,
- 0x10ac0, 0x10ae6,
- 0x10aeb, 0x10af6,
- 0x10b00, 0x10b35,
- 0x10b39, 0x10b55,
- 0x10b58, 0x10b72,
- 0x10b78, 0x10b91,
- 0x10b99, 0x10b9c,
- 0x10ba9, 0x10baf,
- 0x10c00, 0x10c48,
- 0x10c80, 0x10cb2,
- 0x10cc0, 0x10cf2,
- 0x10cfa, 0x10d27,
- 0x10d30, 0x10d39,
- 0x10e60, 0x10e7e,
- 0x10e80, 0x10ea9,
- 0x10eab, 0x10ead,
- 0x10eb0, 0x10eb1,
- 0x10efd, 0x10f27,
- 0x10f30, 0x10f59,
- 0x10f70, 0x10f89,
- 0x10fb0, 0x10fcb,
- 0x10fe0, 0x10ff6,
- 0x11000, 0x1104d,
- 0x11052, 0x11075,
- 0x1107f, 0x110c2,
- 0x110cd, 0x110cd,
- 0x110d0, 0x110e8,
- 0x110f0, 0x110f9,
- 0x11100, 0x11134,
- 0x11136, 0x11147,
- 0x11150, 0x11176,
- 0x11180, 0x111df,
- 0x111e1, 0x111f4,
- 0x11200, 0x11211,
- 0x11213, 0x11241,
- 0x11280, 0x11286,
- 0x11288, 0x11288,
- 0x1128a, 0x1128d,
- 0x1128f, 0x1129d,
- 0x1129f, 0x112a9,
- 0x112b0, 0x112ea,
- 0x112f0, 0x112f9,
- 0x11300, 0x11303,
- 0x11305, 0x1130c,
- 0x1130f, 0x11310,
- 0x11313, 0x11328,
- 0x1132a, 0x11330,
- 0x11332, 0x11333,
- 0x11335, 0x11339,
- 0x1133b, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11350, 0x11350,
- 0x11357, 0x11357,
- 0x1135d, 0x11363,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11400, 0x1145b,
- 0x1145d, 0x11461,
- 0x11480, 0x114c7,
- 0x114d0, 0x114d9,
- 0x11580, 0x115b5,
- 0x115b8, 0x115dd,
- 0x11600, 0x11644,
- 0x11650, 0x11659,
- 0x11660, 0x1166c,
- 0x11680, 0x116b9,
- 0x116c0, 0x116c9,
- 0x11700, 0x1171a,
- 0x1171d, 0x1172b,
- 0x11730, 0x11746,
- 0x11800, 0x1183b,
- 0x118a0, 0x118f2,
- 0x118ff, 0x11906,
- 0x11909, 0x11909,
- 0x1190c, 0x11913,
- 0x11915, 0x11916,
- 0x11918, 0x11935,
- 0x11937, 0x11938,
- 0x1193b, 0x11946,
- 0x11950, 0x11959,
- 0x119a0, 0x119a7,
- 0x119aa, 0x119d7,
- 0x119da, 0x119e4,
- 0x11a00, 0x11a47,
- 0x11a50, 0x11aa2,
- 0x11ab0, 0x11af8,
- 0x11b00, 0x11b09,
- 0x11c00, 0x11c08,
- 0x11c0a, 0x11c36,
- 0x11c38, 0x11c45,
- 0x11c50, 0x11c6c,
- 0x11c70, 0x11c8f,
- 0x11c92, 0x11ca7,
- 0x11ca9, 0x11cb6,
- 0x11d00, 0x11d06,
- 0x11d08, 0x11d09,
- 0x11d0b, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d47,
- 0x11d50, 0x11d59,
- 0x11d60, 0x11d65,
- 0x11d67, 0x11d68,
- 0x11d6a, 0x11d8e,
- 0x11d90, 0x11d91,
- 0x11d93, 0x11d98,
- 0x11da0, 0x11da9,
- 0x11ee0, 0x11ef8,
- 0x11f00, 0x11f10,
- 0x11f12, 0x11f3a,
- 0x11f3e, 0x11f59,
- 0x11fb0, 0x11fb0,
- 0x11fc0, 0x11ff1,
- 0x11fff, 0x12399,
- 0x12400, 0x1246e,
- 0x12470, 0x12474,
- 0x12480, 0x12543,
- 0x12f90, 0x12ff2,
- 0x13000, 0x13455,
- 0x14400, 0x14646,
- 0x16800, 0x16a38,
- 0x16a40, 0x16a5e,
- 0x16a60, 0x16a69,
- 0x16a6e, 0x16abe,
- 0x16ac0, 0x16ac9,
- 0x16ad0, 0x16aed,
- 0x16af0, 0x16af5,
- 0x16b00, 0x16b45,
- 0x16b50, 0x16b59,
- 0x16b5b, 0x16b61,
- 0x16b63, 0x16b77,
- 0x16b7d, 0x16b8f,
- 0x16e40, 0x16e9a,
- 0x16f00, 0x16f4a,
- 0x16f4f, 0x16f87,
- 0x16f8f, 0x16f9f,
- 0x16fe0, 0x16fe4,
- 0x16ff0, 0x16ff1,
- 0x17000, 0x187f7,
- 0x18800, 0x18cd5,
- 0x18d00, 0x18d08,
- 0x1aff0, 0x1aff3,
- 0x1aff5, 0x1affb,
- 0x1affd, 0x1affe,
- 0x1b000, 0x1b122,
- 0x1b132, 0x1b132,
- 0x1b150, 0x1b152,
- 0x1b155, 0x1b155,
- 0x1b164, 0x1b167,
- 0x1b170, 0x1b2fb,
- 0x1bc00, 0x1bc6a,
- 0x1bc70, 0x1bc7c,
- 0x1bc80, 0x1bc88,
- 0x1bc90, 0x1bc99,
- 0x1bc9c, 0x1bca3,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1cf50, 0x1cfc3,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d129, 0x1d1ea,
- 0x1d200, 0x1d245,
- 0x1d2c0, 0x1d2d3,
- 0x1d2e0, 0x1d2f3,
- 0x1d300, 0x1d356,
- 0x1d360, 0x1d378,
- 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, 0x1d7cb,
- 0x1d7ce, 0x1da8b,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1df00, 0x1df1e,
- 0x1df25, 0x1df2a,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e030, 0x1e06d,
- 0x1e08f, 0x1e08f,
- 0x1e100, 0x1e12c,
- 0x1e130, 0x1e13d,
- 0x1e140, 0x1e149,
- 0x1e14e, 0x1e14f,
- 0x1e290, 0x1e2ae,
- 0x1e2c0, 0x1e2f9,
- 0x1e2ff, 0x1e2ff,
- 0x1e4d0, 0x1e4f9,
- 0x1e7e0, 0x1e7e6,
- 0x1e7e8, 0x1e7eb,
- 0x1e7ed, 0x1e7ee,
- 0x1e7f0, 0x1e7fe,
- 0x1e800, 0x1e8c4,
- 0x1e8c7, 0x1e8d6,
- 0x1e900, 0x1e94b,
- 0x1e950, 0x1e959,
- 0x1e95e, 0x1e95f,
- 0x1ec71, 0x1ecb4,
- 0x1ed01, 0x1ed3d,
- 0x1ee00, 0x1ee03,
- 0x1ee05, 0x1ee1f,
- 0x1ee21, 0x1ee22,
- 0x1ee24, 0x1ee24,
- 0x1ee27, 0x1ee27,
- 0x1ee29, 0x1ee32,
- 0x1ee34, 0x1ee37,
- 0x1ee39, 0x1ee39,
- 0x1ee3b, 0x1ee3b,
- 0x1ee42, 0x1ee42,
- 0x1ee47, 0x1ee47,
- 0x1ee49, 0x1ee49,
- 0x1ee4b, 0x1ee4b,
- 0x1ee4d, 0x1ee4f,
- 0x1ee51, 0x1ee52,
- 0x1ee54, 0x1ee54,
- 0x1ee57, 0x1ee57,
- 0x1ee59, 0x1ee59,
- 0x1ee5b, 0x1ee5b,
- 0x1ee5d, 0x1ee5d,
- 0x1ee5f, 0x1ee5f,
- 0x1ee61, 0x1ee62,
- 0x1ee64, 0x1ee64,
- 0x1ee67, 0x1ee6a,
- 0x1ee6c, 0x1ee72,
- 0x1ee74, 0x1ee77,
- 0x1ee79, 0x1ee7c,
- 0x1ee7e, 0x1ee7e,
- 0x1ee80, 0x1ee89,
- 0x1ee8b, 0x1ee9b,
- 0x1eea1, 0x1eea3,
- 0x1eea5, 0x1eea9,
- 0x1eeab, 0x1eebb,
- 0x1eef0, 0x1eef1,
- 0x1f000, 0x1f02b,
- 0x1f030, 0x1f093,
- 0x1f0a0, 0x1f0ae,
- 0x1f0b1, 0x1f0bf,
- 0x1f0c1, 0x1f0cf,
- 0x1f0d1, 0x1f0f5,
- 0x1f100, 0x1f1ad,
- 0x1f1e6, 0x1f202,
- 0x1f210, 0x1f23b,
- 0x1f240, 0x1f248,
- 0x1f250, 0x1f251,
- 0x1f260, 0x1f265,
- 0x1f300, 0x1f6d7,
- 0x1f6dc, 0x1f6ec,
- 0x1f6f0, 0x1f6fc,
- 0x1f700, 0x1f776,
- 0x1f77b, 0x1f7d9,
- 0x1f7e0, 0x1f7eb,
- 0x1f7f0, 0x1f7f0,
- 0x1f800, 0x1f80b,
- 0x1f810, 0x1f847,
- 0x1f850, 0x1f859,
- 0x1f860, 0x1f887,
- 0x1f890, 0x1f8ad,
- 0x1f8b0, 0x1f8b1,
- 0x1f900, 0x1fa53,
- 0x1fa60, 0x1fa6d,
- 0x1fa70, 0x1fa7c,
- 0x1fa80, 0x1fa88,
- 0x1fa90, 0x1fabd,
- 0x1fabf, 0x1fac5,
- 0x1face, 0x1fadb,
- 0x1fae0, 0x1fae8,
- 0x1faf0, 0x1faf8,
- 0x1fb00, 0x1fb92,
- 0x1fb94, 0x1fbca,
- 0x1fbf0, 0x1fbf9,
- 0x1fffe, 0x2a6df,
- 0x2a700, 0x2b739,
- 0x2b740, 0x2b81d,
- 0x2b820, 0x2cea1,
- 0x2ceb0, 0x2ebe0,
- 0x2f800, 0x2fa1d,
- 0x2fffe, 0x3134a,
- 0x31350, 0x323af,
- 0x3fffe, 0x3ffff,
- 0x4fffe, 0x4ffff,
- 0x5fffe, 0x5ffff,
- 0x6fffe, 0x6ffff,
- 0x7fffe, 0x7ffff,
- 0x8fffe, 0x8ffff,
- 0x9fffe, 0x9ffff,
- 0xafffe, 0xaffff,
- 0xbfffe, 0xbffff,
- 0xcfffe, 0xcffff,
- 0xdfffe, 0xdffff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xefffe, 0x10ffff,
-}; /* CR_Age_15_0 */
-
-#endif /* USE_UNICODE_AGE_PROPERTIES */
-/* 'Grapheme_Cluster_Break_Prepend': Grapheme_Cluster_Break=Prepend */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Prepend[] = {
- 15,
- 0x0600, 0x0605,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x0890, 0x0891,
- 0x08e2, 0x08e2,
- 0x0d4e, 0x0d4e,
- 0x110bd, 0x110bd,
- 0x110cd, 0x110cd,
- 0x111c2, 0x111c3,
- 0x1193f, 0x1193f,
- 0x11941, 0x11941,
- 0x11a3a, 0x11a3a,
- 0x11a84, 0x11a89,
- 0x11d46, 0x11d46,
- 0x11f02, 0x11f02,
-}; /* CR_Grapheme_Cluster_Break_Prepend */
-
-/* 'Grapheme_Cluster_Break_CR': Grapheme_Cluster_Break=CR */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_CR[] = {
- 1,
- 0x000d, 0x000d,
-}; /* CR_Grapheme_Cluster_Break_CR */
-
-/* 'Grapheme_Cluster_Break_LF': Grapheme_Cluster_Break=LF */
-#define CR_Grapheme_Cluster_Break_LF CR_NEWLINE
-
-/* 'Grapheme_Cluster_Break_Control': Grapheme_Cluster_Break=Control */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Control[] = {
- 19,
- 0x0000, 0x0009,
- 0x000b, 0x000c,
- 0x000e, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x061c, 0x061c,
- 0x180e, 0x180e,
- 0x200b, 0x200b,
- 0x200e, 0x200f,
- 0x2028, 0x202e,
- 0x2060, 0x206f,
- 0xfeff, 0xfeff,
- 0xfff0, 0xfffb,
- 0x13430, 0x1343f,
- 0x1bca0, 0x1bca3,
- 0x1d173, 0x1d17a,
- 0xe0000, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xe0fff,
-}; /* CR_Grapheme_Cluster_Break_Control */
-
-/* 'Grapheme_Cluster_Break_Extend': Grapheme_Cluster_Break=Extend */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_Extend[] = {
- 364,
- 0x0300, 0x036f,
- 0x0483, 0x0489,
- 0x0591, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x061a,
- 0x064b, 0x065f,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x07eb, 0x07f3,
- 0x07fd, 0x07fd,
- 0x0816, 0x0819,
- 0x081b, 0x0823,
- 0x0825, 0x0827,
- 0x0829, 0x082d,
- 0x0859, 0x085b,
- 0x0898, 0x089f,
- 0x08ca, 0x08e1,
- 0x08e3, 0x0902,
- 0x093a, 0x093a,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0957,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09be, 0x09be,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x09fe, 0x09fe,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a51, 0x0a51,
- 0x0a70, 0x0a71,
- 0x0a75, 0x0a75,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0afa, 0x0aff,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b3f,
- 0x0b41, 0x0b44,
- 0x0b4d, 0x0b4d,
- 0x0b55, 0x0b57,
- 0x0b62, 0x0b63,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bbe,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c00, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c3c, 0x0c3c,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c62, 0x0c63,
- 0x0c81, 0x0c81,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc2, 0x0cc2,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0ce2, 0x0ce3,
- 0x0d00, 0x0d01,
- 0x0d3b, 0x0d3c,
- 0x0d3e, 0x0d3e,
- 0x0d41, 0x0d44,
- 0x0d4d, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d62, 0x0d63,
- 0x0d81, 0x0d81,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dcf,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0ddf, 0x0ddf,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0ebc,
- 0x0ec8, 0x0ece,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f8d, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1037,
- 0x1039, 0x103a,
- 0x103d, 0x103e,
- 0x1058, 0x1059,
- 0x105e, 0x1060,
- 0x1071, 0x1074,
- 0x1082, 0x1082,
- 0x1085, 0x1086,
- 0x108d, 0x108d,
- 0x109d, 0x109d,
- 0x135d, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1733,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b4, 0x17b5,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x180f, 0x180f,
- 0x1885, 0x1886,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1a1b, 0x1a1b,
- 0x1a56, 0x1a56,
- 0x1a58, 0x1a5e,
- 0x1a60, 0x1a60,
- 0x1a62, 0x1a62,
- 0x1a65, 0x1a6c,
- 0x1a73, 0x1a7c,
- 0x1a7f, 0x1a7f,
- 0x1ab0, 0x1ace,
- 0x1b00, 0x1b03,
- 0x1b34, 0x1b3a,
- 0x1b3c, 0x1b3c,
- 0x1b42, 0x1b42,
- 0x1b6b, 0x1b73,
- 0x1b80, 0x1b81,
- 0x1ba2, 0x1ba5,
- 0x1ba8, 0x1ba9,
- 0x1bab, 0x1bad,
- 0x1be6, 0x1be6,
- 0x1be8, 0x1be9,
- 0x1bed, 0x1bed,
- 0x1bef, 0x1bf1,
- 0x1c2c, 0x1c33,
- 0x1c36, 0x1c37,
- 0x1cd0, 0x1cd2,
- 0x1cd4, 0x1ce0,
- 0x1ce2, 0x1ce8,
- 0x1ced, 0x1ced,
- 0x1cf4, 0x1cf4,
- 0x1cf8, 0x1cf9,
- 0x1dc0, 0x1dff,
- 0x200c, 0x200c,
- 0x20d0, 0x20f0,
- 0x2cef, 0x2cf1,
- 0x2d7f, 0x2d7f,
- 0x2de0, 0x2dff,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa66f, 0xa672,
- 0xa674, 0xa67d,
- 0xa69e, 0xa69f,
- 0xa6f0, 0xa6f1,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xa82c, 0xa82c,
- 0xa8c4, 0xa8c5,
- 0xa8e0, 0xa8f1,
- 0xa8ff, 0xa8ff,
- 0xa926, 0xa92d,
- 0xa947, 0xa951,
- 0xa980, 0xa982,
- 0xa9b3, 0xa9b3,
- 0xa9b6, 0xa9b9,
- 0xa9bc, 0xa9bd,
- 0xa9e5, 0xa9e5,
- 0xaa29, 0xaa2e,
- 0xaa31, 0xaa32,
- 0xaa35, 0xaa36,
- 0xaa43, 0xaa43,
- 0xaa4c, 0xaa4c,
- 0xaa7c, 0xaa7c,
- 0xaab0, 0xaab0,
- 0xaab2, 0xaab4,
- 0xaab7, 0xaab8,
- 0xaabe, 0xaabf,
- 0xaac1, 0xaac1,
- 0xaaec, 0xaaed,
- 0xaaf6, 0xaaf6,
- 0xabe5, 0xabe5,
- 0xabe8, 0xabe8,
- 0xabed, 0xabed,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe2f,
- 0xff9e, 0xff9f,
- 0x101fd, 0x101fd,
- 0x102e0, 0x102e0,
- 0x10376, 0x1037a,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x10ae5, 0x10ae6,
- 0x10d24, 0x10d27,
- 0x10eab, 0x10eac,
- 0x10efd, 0x10eff,
- 0x10f46, 0x10f50,
- 0x10f82, 0x10f85,
- 0x11001, 0x11001,
- 0x11038, 0x11046,
- 0x11070, 0x11070,
- 0x11073, 0x11074,
- 0x1107f, 0x11081,
- 0x110b3, 0x110b6,
- 0x110b9, 0x110ba,
- 0x110c2, 0x110c2,
- 0x11100, 0x11102,
- 0x11127, 0x1112b,
- 0x1112d, 0x11134,
- 0x11173, 0x11173,
- 0x11180, 0x11181,
- 0x111b6, 0x111be,
- 0x111c9, 0x111cc,
- 0x111cf, 0x111cf,
- 0x1122f, 0x11231,
- 0x11234, 0x11234,
- 0x11236, 0x11237,
- 0x1123e, 0x1123e,
- 0x11241, 0x11241,
- 0x112df, 0x112df,
- 0x112e3, 0x112ea,
- 0x11300, 0x11301,
- 0x1133b, 0x1133c,
- 0x1133e, 0x1133e,
- 0x11340, 0x11340,
- 0x11357, 0x11357,
- 0x11366, 0x1136c,
- 0x11370, 0x11374,
- 0x11438, 0x1143f,
- 0x11442, 0x11444,
- 0x11446, 0x11446,
- 0x1145e, 0x1145e,
- 0x114b0, 0x114b0,
- 0x114b3, 0x114b8,
- 0x114ba, 0x114ba,
- 0x114bd, 0x114bd,
- 0x114bf, 0x114c0,
- 0x114c2, 0x114c3,
- 0x115af, 0x115af,
- 0x115b2, 0x115b5,
- 0x115bc, 0x115bd,
- 0x115bf, 0x115c0,
- 0x115dc, 0x115dd,
- 0x11633, 0x1163a,
- 0x1163d, 0x1163d,
- 0x1163f, 0x11640,
- 0x116ab, 0x116ab,
- 0x116ad, 0x116ad,
- 0x116b0, 0x116b5,
- 0x116b7, 0x116b7,
- 0x1171d, 0x1171f,
- 0x11722, 0x11725,
- 0x11727, 0x1172b,
- 0x1182f, 0x11837,
- 0x11839, 0x1183a,
- 0x11930, 0x11930,
- 0x1193b, 0x1193c,
- 0x1193e, 0x1193e,
- 0x11943, 0x11943,
- 0x119d4, 0x119d7,
- 0x119da, 0x119db,
- 0x119e0, 0x119e0,
- 0x11a01, 0x11a0a,
- 0x11a33, 0x11a38,
- 0x11a3b, 0x11a3e,
- 0x11a47, 0x11a47,
- 0x11a51, 0x11a56,
- 0x11a59, 0x11a5b,
- 0x11a8a, 0x11a96,
- 0x11a98, 0x11a99,
- 0x11c30, 0x11c36,
- 0x11c38, 0x11c3d,
- 0x11c3f, 0x11c3f,
- 0x11c92, 0x11ca7,
- 0x11caa, 0x11cb0,
- 0x11cb2, 0x11cb3,
- 0x11cb5, 0x11cb6,
- 0x11d31, 0x11d36,
- 0x11d3a, 0x11d3a,
- 0x11d3c, 0x11d3d,
- 0x11d3f, 0x11d45,
- 0x11d47, 0x11d47,
- 0x11d90, 0x11d91,
- 0x11d95, 0x11d95,
- 0x11d97, 0x11d97,
- 0x11ef3, 0x11ef4,
- 0x11f00, 0x11f01,
- 0x11f36, 0x11f3a,
- 0x11f40, 0x11f40,
- 0x11f42, 0x11f42,
- 0x13440, 0x13440,
- 0x13447, 0x13455,
- 0x16af0, 0x16af4,
- 0x16b30, 0x16b36,
- 0x16f4f, 0x16f4f,
- 0x16f8f, 0x16f92,
- 0x16fe4, 0x16fe4,
- 0x1bc9d, 0x1bc9e,
- 0x1cf00, 0x1cf2d,
- 0x1cf30, 0x1cf46,
- 0x1d165, 0x1d165,
- 0x1d167, 0x1d169,
- 0x1d16e, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1da00, 0x1da36,
- 0x1da3b, 0x1da6c,
- 0x1da75, 0x1da75,
- 0x1da84, 0x1da84,
- 0x1da9b, 0x1da9f,
- 0x1daa1, 0x1daaf,
- 0x1e000, 0x1e006,
- 0x1e008, 0x1e018,
- 0x1e01b, 0x1e021,
- 0x1e023, 0x1e024,
- 0x1e026, 0x1e02a,
- 0x1e08f, 0x1e08f,
- 0x1e130, 0x1e136,
- 0x1e2ae, 0x1e2ae,
- 0x1e2ec, 0x1e2ef,
- 0x1e4ec, 0x1e4ef,
- 0x1e8d0, 0x1e8d6,
- 0x1e944, 0x1e94a,
- 0x1f3fb, 0x1f3ff,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
-}; /* CR_Grapheme_Cluster_Break_Extend */
-
-/* 'Grapheme_Cluster_Break_Regional_Indicator': Grapheme_Cluster_Break=Regional_Indicator */
-#define CR_Grapheme_Cluster_Break_Regional_Indicator CR_Regional_Indicator
-
-/* 'Grapheme_Cluster_Break_SpacingMark': Grapheme_Cluster_Break=SpacingMark */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_SpacingMark[] = {
- 165,
- 0x0903, 0x0903,
- 0x093b, 0x093b,
- 0x093e, 0x0940,
- 0x0949, 0x094c,
- 0x094e, 0x094f,
- 0x0982, 0x0983,
- 0x09bf, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x0a03, 0x0a03,
- 0x0a3e, 0x0a40,
- 0x0a83, 0x0a83,
- 0x0abe, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0b02, 0x0b03,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0bbf, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0c01, 0x0c03,
- 0x0c41, 0x0c44,
- 0x0c82, 0x0c83,
- 0x0cbe, 0x0cbe,
- 0x0cc0, 0x0cc1,
- 0x0cc3, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0cf3, 0x0cf3,
- 0x0d02, 0x0d03,
- 0x0d3f, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d82, 0x0d83,
- 0x0dd0, 0x0dd1,
- 0x0dd8, 0x0dde,
- 0x0df2, 0x0df3,
- 0x0e33, 0x0e33,
- 0x0eb3, 0x0eb3,
- 0x0f3e, 0x0f3f,
- 0x0f7f, 0x0f7f,
- 0x1031, 0x1031,
- 0x103b, 0x103c,
- 0x1056, 0x1057,
- 0x1084, 0x1084,
- 0x1715, 0x1715,
- 0x1734, 0x1734,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x1a19, 0x1a1a,
- 0x1a55, 0x1a55,
- 0x1a57, 0x1a57,
- 0x1a6d, 0x1a72,
- 0x1b04, 0x1b04,
- 0x1b3b, 0x1b3b,
- 0x1b3d, 0x1b41,
- 0x1b43, 0x1b44,
- 0x1b82, 0x1b82,
- 0x1ba1, 0x1ba1,
- 0x1ba6, 0x1ba7,
- 0x1baa, 0x1baa,
- 0x1be7, 0x1be7,
- 0x1bea, 0x1bec,
- 0x1bee, 0x1bee,
- 0x1bf2, 0x1bf3,
- 0x1c24, 0x1c2b,
- 0x1c34, 0x1c35,
- 0x1ce1, 0x1ce1,
- 0x1cf7, 0x1cf7,
- 0xa823, 0xa824,
- 0xa827, 0xa827,
- 0xa880, 0xa881,
- 0xa8b4, 0xa8c3,
- 0xa952, 0xa953,
- 0xa983, 0xa983,
- 0xa9b4, 0xa9b5,
- 0xa9ba, 0xa9bb,
- 0xa9be, 0xa9c0,
- 0xaa2f, 0xaa30,
- 0xaa33, 0xaa34,
- 0xaa4d, 0xaa4d,
- 0xaaeb, 0xaaeb,
- 0xaaee, 0xaaef,
- 0xaaf5, 0xaaf5,
- 0xabe3, 0xabe4,
- 0xabe6, 0xabe7,
- 0xabe9, 0xabea,
- 0xabec, 0xabec,
- 0x11000, 0x11000,
- 0x11002, 0x11002,
- 0x11082, 0x11082,
- 0x110b0, 0x110b2,
- 0x110b7, 0x110b8,
- 0x1112c, 0x1112c,
- 0x11145, 0x11146,
- 0x11182, 0x11182,
- 0x111b3, 0x111b5,
- 0x111bf, 0x111c0,
- 0x111ce, 0x111ce,
- 0x1122c, 0x1122e,
- 0x11232, 0x11233,
- 0x11235, 0x11235,
- 0x112e0, 0x112e2,
- 0x11302, 0x11303,
- 0x1133f, 0x1133f,
- 0x11341, 0x11344,
- 0x11347, 0x11348,
- 0x1134b, 0x1134d,
- 0x11362, 0x11363,
- 0x11435, 0x11437,
- 0x11440, 0x11441,
- 0x11445, 0x11445,
- 0x114b1, 0x114b2,
- 0x114b9, 0x114b9,
- 0x114bb, 0x114bc,
- 0x114be, 0x114be,
- 0x114c1, 0x114c1,
- 0x115b0, 0x115b1,
- 0x115b8, 0x115bb,
- 0x115be, 0x115be,
- 0x11630, 0x11632,
- 0x1163b, 0x1163c,
- 0x1163e, 0x1163e,
- 0x116ac, 0x116ac,
- 0x116ae, 0x116af,
- 0x116b6, 0x116b6,
- 0x11726, 0x11726,
- 0x1182c, 0x1182e,
- 0x11838, 0x11838,
- 0x11931, 0x11935,
- 0x11937, 0x11938,
- 0x1193d, 0x1193d,
- 0x11940, 0x11940,
- 0x11942, 0x11942,
- 0x119d1, 0x119d3,
- 0x119dc, 0x119df,
- 0x119e4, 0x119e4,
- 0x11a39, 0x11a39,
- 0x11a57, 0x11a58,
- 0x11a97, 0x11a97,
- 0x11c2f, 0x11c2f,
- 0x11c3e, 0x11c3e,
- 0x11ca9, 0x11ca9,
- 0x11cb1, 0x11cb1,
- 0x11cb4, 0x11cb4,
- 0x11d8a, 0x11d8e,
- 0x11d93, 0x11d94,
- 0x11d96, 0x11d96,
- 0x11ef5, 0x11ef6,
- 0x11f03, 0x11f03,
- 0x11f34, 0x11f35,
- 0x11f3e, 0x11f3f,
- 0x11f41, 0x11f41,
- 0x16f51, 0x16f87,
- 0x16ff0, 0x16ff1,
- 0x1d166, 0x1d166,
- 0x1d16d, 0x1d16d,
-}; /* CR_Grapheme_Cluster_Break_SpacingMark */
-
-/* 'Grapheme_Cluster_Break_L': Grapheme_Cluster_Break=L */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_L[] = {
- 2,
- 0x1100, 0x115f,
- 0xa960, 0xa97c,
-}; /* CR_Grapheme_Cluster_Break_L */
-
-/* 'Grapheme_Cluster_Break_V': Grapheme_Cluster_Break=V */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_V[] = {
- 2,
- 0x1160, 0x11a7,
- 0xd7b0, 0xd7c6,
-}; /* CR_Grapheme_Cluster_Break_V */
-
-/* 'Grapheme_Cluster_Break_T': Grapheme_Cluster_Break=T */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_T[] = {
- 2,
- 0x11a8, 0x11ff,
- 0xd7cb, 0xd7fb,
-}; /* CR_Grapheme_Cluster_Break_T */
-
-/* 'Grapheme_Cluster_Break_LV': Grapheme_Cluster_Break=LV */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_LV[] = {
- 399,
- 0xac00, 0xac00,
- 0xac1c, 0xac1c,
- 0xac38, 0xac38,
- 0xac54, 0xac54,
- 0xac70, 0xac70,
- 0xac8c, 0xac8c,
- 0xaca8, 0xaca8,
- 0xacc4, 0xacc4,
- 0xace0, 0xace0,
- 0xacfc, 0xacfc,
- 0xad18, 0xad18,
- 0xad34, 0xad34,
- 0xad50, 0xad50,
- 0xad6c, 0xad6c,
- 0xad88, 0xad88,
- 0xada4, 0xada4,
- 0xadc0, 0xadc0,
- 0xaddc, 0xaddc,
- 0xadf8, 0xadf8,
- 0xae14, 0xae14,
- 0xae30, 0xae30,
- 0xae4c, 0xae4c,
- 0xae68, 0xae68,
- 0xae84, 0xae84,
- 0xaea0, 0xaea0,
- 0xaebc, 0xaebc,
- 0xaed8, 0xaed8,
- 0xaef4, 0xaef4,
- 0xaf10, 0xaf10,
- 0xaf2c, 0xaf2c,
- 0xaf48, 0xaf48,
- 0xaf64, 0xaf64,
- 0xaf80, 0xaf80,
- 0xaf9c, 0xaf9c,
- 0xafb8, 0xafb8,
- 0xafd4, 0xafd4,
- 0xaff0, 0xaff0,
- 0xb00c, 0xb00c,
- 0xb028, 0xb028,
- 0xb044, 0xb044,
- 0xb060, 0xb060,
- 0xb07c, 0xb07c,
- 0xb098, 0xb098,
- 0xb0b4, 0xb0b4,
- 0xb0d0, 0xb0d0,
- 0xb0ec, 0xb0ec,
- 0xb108, 0xb108,
- 0xb124, 0xb124,
- 0xb140, 0xb140,
- 0xb15c, 0xb15c,
- 0xb178, 0xb178,
- 0xb194, 0xb194,
- 0xb1b0, 0xb1b0,
- 0xb1cc, 0xb1cc,
- 0xb1e8, 0xb1e8,
- 0xb204, 0xb204,
- 0xb220, 0xb220,
- 0xb23c, 0xb23c,
- 0xb258, 0xb258,
- 0xb274, 0xb274,
- 0xb290, 0xb290,
- 0xb2ac, 0xb2ac,
- 0xb2c8, 0xb2c8,
- 0xb2e4, 0xb2e4,
- 0xb300, 0xb300,
- 0xb31c, 0xb31c,
- 0xb338, 0xb338,
- 0xb354, 0xb354,
- 0xb370, 0xb370,
- 0xb38c, 0xb38c,
- 0xb3a8, 0xb3a8,
- 0xb3c4, 0xb3c4,
- 0xb3e0, 0xb3e0,
- 0xb3fc, 0xb3fc,
- 0xb418, 0xb418,
- 0xb434, 0xb434,
- 0xb450, 0xb450,
- 0xb46c, 0xb46c,
- 0xb488, 0xb488,
- 0xb4a4, 0xb4a4,
- 0xb4c0, 0xb4c0,
- 0xb4dc, 0xb4dc,
- 0xb4f8, 0xb4f8,
- 0xb514, 0xb514,
- 0xb530, 0xb530,
- 0xb54c, 0xb54c,
- 0xb568, 0xb568,
- 0xb584, 0xb584,
- 0xb5a0, 0xb5a0,
- 0xb5bc, 0xb5bc,
- 0xb5d8, 0xb5d8,
- 0xb5f4, 0xb5f4,
- 0xb610, 0xb610,
- 0xb62c, 0xb62c,
- 0xb648, 0xb648,
- 0xb664, 0xb664,
- 0xb680, 0xb680,
- 0xb69c, 0xb69c,
- 0xb6b8, 0xb6b8,
- 0xb6d4, 0xb6d4,
- 0xb6f0, 0xb6f0,
- 0xb70c, 0xb70c,
- 0xb728, 0xb728,
- 0xb744, 0xb744,
- 0xb760, 0xb760,
- 0xb77c, 0xb77c,
- 0xb798, 0xb798,
- 0xb7b4, 0xb7b4,
- 0xb7d0, 0xb7d0,
- 0xb7ec, 0xb7ec,
- 0xb808, 0xb808,
- 0xb824, 0xb824,
- 0xb840, 0xb840,
- 0xb85c, 0xb85c,
- 0xb878, 0xb878,
- 0xb894, 0xb894,
- 0xb8b0, 0xb8b0,
- 0xb8cc, 0xb8cc,
- 0xb8e8, 0xb8e8,
- 0xb904, 0xb904,
- 0xb920, 0xb920,
- 0xb93c, 0xb93c,
- 0xb958, 0xb958,
- 0xb974, 0xb974,
- 0xb990, 0xb990,
- 0xb9ac, 0xb9ac,
- 0xb9c8, 0xb9c8,
- 0xb9e4, 0xb9e4,
- 0xba00, 0xba00,
- 0xba1c, 0xba1c,
- 0xba38, 0xba38,
- 0xba54, 0xba54,
- 0xba70, 0xba70,
- 0xba8c, 0xba8c,
- 0xbaa8, 0xbaa8,
- 0xbac4, 0xbac4,
- 0xbae0, 0xbae0,
- 0xbafc, 0xbafc,
- 0xbb18, 0xbb18,
- 0xbb34, 0xbb34,
- 0xbb50, 0xbb50,
- 0xbb6c, 0xbb6c,
- 0xbb88, 0xbb88,
- 0xbba4, 0xbba4,
- 0xbbc0, 0xbbc0,
- 0xbbdc, 0xbbdc,
- 0xbbf8, 0xbbf8,
- 0xbc14, 0xbc14,
- 0xbc30, 0xbc30,
- 0xbc4c, 0xbc4c,
- 0xbc68, 0xbc68,
- 0xbc84, 0xbc84,
- 0xbca0, 0xbca0,
- 0xbcbc, 0xbcbc,
- 0xbcd8, 0xbcd8,
- 0xbcf4, 0xbcf4,
- 0xbd10, 0xbd10,
- 0xbd2c, 0xbd2c,
- 0xbd48, 0xbd48,
- 0xbd64, 0xbd64,
- 0xbd80, 0xbd80,
- 0xbd9c, 0xbd9c,
- 0xbdb8, 0xbdb8,
- 0xbdd4, 0xbdd4,
- 0xbdf0, 0xbdf0,
- 0xbe0c, 0xbe0c,
- 0xbe28, 0xbe28,
- 0xbe44, 0xbe44,
- 0xbe60, 0xbe60,
- 0xbe7c, 0xbe7c,
- 0xbe98, 0xbe98,
- 0xbeb4, 0xbeb4,
- 0xbed0, 0xbed0,
- 0xbeec, 0xbeec,
- 0xbf08, 0xbf08,
- 0xbf24, 0xbf24,
- 0xbf40, 0xbf40,
- 0xbf5c, 0xbf5c,
- 0xbf78, 0xbf78,
- 0xbf94, 0xbf94,
- 0xbfb0, 0xbfb0,
- 0xbfcc, 0xbfcc,
- 0xbfe8, 0xbfe8,
- 0xc004, 0xc004,
- 0xc020, 0xc020,
- 0xc03c, 0xc03c,
- 0xc058, 0xc058,
- 0xc074, 0xc074,
- 0xc090, 0xc090,
- 0xc0ac, 0xc0ac,
- 0xc0c8, 0xc0c8,
- 0xc0e4, 0xc0e4,
- 0xc100, 0xc100,
- 0xc11c, 0xc11c,
- 0xc138, 0xc138,
- 0xc154, 0xc154,
- 0xc170, 0xc170,
- 0xc18c, 0xc18c,
- 0xc1a8, 0xc1a8,
- 0xc1c4, 0xc1c4,
- 0xc1e0, 0xc1e0,
- 0xc1fc, 0xc1fc,
- 0xc218, 0xc218,
- 0xc234, 0xc234,
- 0xc250, 0xc250,
- 0xc26c, 0xc26c,
- 0xc288, 0xc288,
- 0xc2a4, 0xc2a4,
- 0xc2c0, 0xc2c0,
- 0xc2dc, 0xc2dc,
- 0xc2f8, 0xc2f8,
- 0xc314, 0xc314,
- 0xc330, 0xc330,
- 0xc34c, 0xc34c,
- 0xc368, 0xc368,
- 0xc384, 0xc384,
- 0xc3a0, 0xc3a0,
- 0xc3bc, 0xc3bc,
- 0xc3d8, 0xc3d8,
- 0xc3f4, 0xc3f4,
- 0xc410, 0xc410,
- 0xc42c, 0xc42c,
- 0xc448, 0xc448,
- 0xc464, 0xc464,
- 0xc480, 0xc480,
- 0xc49c, 0xc49c,
- 0xc4b8, 0xc4b8,
- 0xc4d4, 0xc4d4,
- 0xc4f0, 0xc4f0,
- 0xc50c, 0xc50c,
- 0xc528, 0xc528,
- 0xc544, 0xc544,
- 0xc560, 0xc560,
- 0xc57c, 0xc57c,
- 0xc598, 0xc598,
- 0xc5b4, 0xc5b4,
- 0xc5d0, 0xc5d0,
- 0xc5ec, 0xc5ec,
- 0xc608, 0xc608,
- 0xc624, 0xc624,
- 0xc640, 0xc640,
- 0xc65c, 0xc65c,
- 0xc678, 0xc678,
- 0xc694, 0xc694,
- 0xc6b0, 0xc6b0,
- 0xc6cc, 0xc6cc,
- 0xc6e8, 0xc6e8,
- 0xc704, 0xc704,
- 0xc720, 0xc720,
- 0xc73c, 0xc73c,
- 0xc758, 0xc758,
- 0xc774, 0xc774,
- 0xc790, 0xc790,
- 0xc7ac, 0xc7ac,
- 0xc7c8, 0xc7c8,
- 0xc7e4, 0xc7e4,
- 0xc800, 0xc800,
- 0xc81c, 0xc81c,
- 0xc838, 0xc838,
- 0xc854, 0xc854,
- 0xc870, 0xc870,
- 0xc88c, 0xc88c,
- 0xc8a8, 0xc8a8,
- 0xc8c4, 0xc8c4,
- 0xc8e0, 0xc8e0,
- 0xc8fc, 0xc8fc,
- 0xc918, 0xc918,
- 0xc934, 0xc934,
- 0xc950, 0xc950,
- 0xc96c, 0xc96c,
- 0xc988, 0xc988,
- 0xc9a4, 0xc9a4,
- 0xc9c0, 0xc9c0,
- 0xc9dc, 0xc9dc,
- 0xc9f8, 0xc9f8,
- 0xca14, 0xca14,
- 0xca30, 0xca30,
- 0xca4c, 0xca4c,
- 0xca68, 0xca68,
- 0xca84, 0xca84,
- 0xcaa0, 0xcaa0,
- 0xcabc, 0xcabc,
- 0xcad8, 0xcad8,
- 0xcaf4, 0xcaf4,
- 0xcb10, 0xcb10,
- 0xcb2c, 0xcb2c,
- 0xcb48, 0xcb48,
- 0xcb64, 0xcb64,
- 0xcb80, 0xcb80,
- 0xcb9c, 0xcb9c,
- 0xcbb8, 0xcbb8,
- 0xcbd4, 0xcbd4,
- 0xcbf0, 0xcbf0,
- 0xcc0c, 0xcc0c,
- 0xcc28, 0xcc28,
- 0xcc44, 0xcc44,
- 0xcc60, 0xcc60,
- 0xcc7c, 0xcc7c,
- 0xcc98, 0xcc98,
- 0xccb4, 0xccb4,
- 0xccd0, 0xccd0,
- 0xccec, 0xccec,
- 0xcd08, 0xcd08,
- 0xcd24, 0xcd24,
- 0xcd40, 0xcd40,
- 0xcd5c, 0xcd5c,
- 0xcd78, 0xcd78,
- 0xcd94, 0xcd94,
- 0xcdb0, 0xcdb0,
- 0xcdcc, 0xcdcc,
- 0xcde8, 0xcde8,
- 0xce04, 0xce04,
- 0xce20, 0xce20,
- 0xce3c, 0xce3c,
- 0xce58, 0xce58,
- 0xce74, 0xce74,
- 0xce90, 0xce90,
- 0xceac, 0xceac,
- 0xcec8, 0xcec8,
- 0xcee4, 0xcee4,
- 0xcf00, 0xcf00,
- 0xcf1c, 0xcf1c,
- 0xcf38, 0xcf38,
- 0xcf54, 0xcf54,
- 0xcf70, 0xcf70,
- 0xcf8c, 0xcf8c,
- 0xcfa8, 0xcfa8,
- 0xcfc4, 0xcfc4,
- 0xcfe0, 0xcfe0,
- 0xcffc, 0xcffc,
- 0xd018, 0xd018,
- 0xd034, 0xd034,
- 0xd050, 0xd050,
- 0xd06c, 0xd06c,
- 0xd088, 0xd088,
- 0xd0a4, 0xd0a4,
- 0xd0c0, 0xd0c0,
- 0xd0dc, 0xd0dc,
- 0xd0f8, 0xd0f8,
- 0xd114, 0xd114,
- 0xd130, 0xd130,
- 0xd14c, 0xd14c,
- 0xd168, 0xd168,
- 0xd184, 0xd184,
- 0xd1a0, 0xd1a0,
- 0xd1bc, 0xd1bc,
- 0xd1d8, 0xd1d8,
- 0xd1f4, 0xd1f4,
- 0xd210, 0xd210,
- 0xd22c, 0xd22c,
- 0xd248, 0xd248,
- 0xd264, 0xd264,
- 0xd280, 0xd280,
- 0xd29c, 0xd29c,
- 0xd2b8, 0xd2b8,
- 0xd2d4, 0xd2d4,
- 0xd2f0, 0xd2f0,
- 0xd30c, 0xd30c,
- 0xd328, 0xd328,
- 0xd344, 0xd344,
- 0xd360, 0xd360,
- 0xd37c, 0xd37c,
- 0xd398, 0xd398,
- 0xd3b4, 0xd3b4,
- 0xd3d0, 0xd3d0,
- 0xd3ec, 0xd3ec,
- 0xd408, 0xd408,
- 0xd424, 0xd424,
- 0xd440, 0xd440,
- 0xd45c, 0xd45c,
- 0xd478, 0xd478,
- 0xd494, 0xd494,
- 0xd4b0, 0xd4b0,
- 0xd4cc, 0xd4cc,
- 0xd4e8, 0xd4e8,
- 0xd504, 0xd504,
- 0xd520, 0xd520,
- 0xd53c, 0xd53c,
- 0xd558, 0xd558,
- 0xd574, 0xd574,
- 0xd590, 0xd590,
- 0xd5ac, 0xd5ac,
- 0xd5c8, 0xd5c8,
- 0xd5e4, 0xd5e4,
- 0xd600, 0xd600,
- 0xd61c, 0xd61c,
- 0xd638, 0xd638,
- 0xd654, 0xd654,
- 0xd670, 0xd670,
- 0xd68c, 0xd68c,
- 0xd6a8, 0xd6a8,
- 0xd6c4, 0xd6c4,
- 0xd6e0, 0xd6e0,
- 0xd6fc, 0xd6fc,
- 0xd718, 0xd718,
- 0xd734, 0xd734,
- 0xd750, 0xd750,
- 0xd76c, 0xd76c,
- 0xd788, 0xd788,
-}; /* CR_Grapheme_Cluster_Break_LV */
-
-/* 'Grapheme_Cluster_Break_LVT': Grapheme_Cluster_Break=LVT */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_LVT[] = {
- 399,
- 0xac01, 0xac1b,
- 0xac1d, 0xac37,
- 0xac39, 0xac53,
- 0xac55, 0xac6f,
- 0xac71, 0xac8b,
- 0xac8d, 0xaca7,
- 0xaca9, 0xacc3,
- 0xacc5, 0xacdf,
- 0xace1, 0xacfb,
- 0xacfd, 0xad17,
- 0xad19, 0xad33,
- 0xad35, 0xad4f,
- 0xad51, 0xad6b,
- 0xad6d, 0xad87,
- 0xad89, 0xada3,
- 0xada5, 0xadbf,
- 0xadc1, 0xaddb,
- 0xaddd, 0xadf7,
- 0xadf9, 0xae13,
- 0xae15, 0xae2f,
- 0xae31, 0xae4b,
- 0xae4d, 0xae67,
- 0xae69, 0xae83,
- 0xae85, 0xae9f,
- 0xaea1, 0xaebb,
- 0xaebd, 0xaed7,
- 0xaed9, 0xaef3,
- 0xaef5, 0xaf0f,
- 0xaf11, 0xaf2b,
- 0xaf2d, 0xaf47,
- 0xaf49, 0xaf63,
- 0xaf65, 0xaf7f,
- 0xaf81, 0xaf9b,
- 0xaf9d, 0xafb7,
- 0xafb9, 0xafd3,
- 0xafd5, 0xafef,
- 0xaff1, 0xb00b,
- 0xb00d, 0xb027,
- 0xb029, 0xb043,
- 0xb045, 0xb05f,
- 0xb061, 0xb07b,
- 0xb07d, 0xb097,
- 0xb099, 0xb0b3,
- 0xb0b5, 0xb0cf,
- 0xb0d1, 0xb0eb,
- 0xb0ed, 0xb107,
- 0xb109, 0xb123,
- 0xb125, 0xb13f,
- 0xb141, 0xb15b,
- 0xb15d, 0xb177,
- 0xb179, 0xb193,
- 0xb195, 0xb1af,
- 0xb1b1, 0xb1cb,
- 0xb1cd, 0xb1e7,
- 0xb1e9, 0xb203,
- 0xb205, 0xb21f,
- 0xb221, 0xb23b,
- 0xb23d, 0xb257,
- 0xb259, 0xb273,
- 0xb275, 0xb28f,
- 0xb291, 0xb2ab,
- 0xb2ad, 0xb2c7,
- 0xb2c9, 0xb2e3,
- 0xb2e5, 0xb2ff,
- 0xb301, 0xb31b,
- 0xb31d, 0xb337,
- 0xb339, 0xb353,
- 0xb355, 0xb36f,
- 0xb371, 0xb38b,
- 0xb38d, 0xb3a7,
- 0xb3a9, 0xb3c3,
- 0xb3c5, 0xb3df,
- 0xb3e1, 0xb3fb,
- 0xb3fd, 0xb417,
- 0xb419, 0xb433,
- 0xb435, 0xb44f,
- 0xb451, 0xb46b,
- 0xb46d, 0xb487,
- 0xb489, 0xb4a3,
- 0xb4a5, 0xb4bf,
- 0xb4c1, 0xb4db,
- 0xb4dd, 0xb4f7,
- 0xb4f9, 0xb513,
- 0xb515, 0xb52f,
- 0xb531, 0xb54b,
- 0xb54d, 0xb567,
- 0xb569, 0xb583,
- 0xb585, 0xb59f,
- 0xb5a1, 0xb5bb,
- 0xb5bd, 0xb5d7,
- 0xb5d9, 0xb5f3,
- 0xb5f5, 0xb60f,
- 0xb611, 0xb62b,
- 0xb62d, 0xb647,
- 0xb649, 0xb663,
- 0xb665, 0xb67f,
- 0xb681, 0xb69b,
- 0xb69d, 0xb6b7,
- 0xb6b9, 0xb6d3,
- 0xb6d5, 0xb6ef,
- 0xb6f1, 0xb70b,
- 0xb70d, 0xb727,
- 0xb729, 0xb743,
- 0xb745, 0xb75f,
- 0xb761, 0xb77b,
- 0xb77d, 0xb797,
- 0xb799, 0xb7b3,
- 0xb7b5, 0xb7cf,
- 0xb7d1, 0xb7eb,
- 0xb7ed, 0xb807,
- 0xb809, 0xb823,
- 0xb825, 0xb83f,
- 0xb841, 0xb85b,
- 0xb85d, 0xb877,
- 0xb879, 0xb893,
- 0xb895, 0xb8af,
- 0xb8b1, 0xb8cb,
- 0xb8cd, 0xb8e7,
- 0xb8e9, 0xb903,
- 0xb905, 0xb91f,
- 0xb921, 0xb93b,
- 0xb93d, 0xb957,
- 0xb959, 0xb973,
- 0xb975, 0xb98f,
- 0xb991, 0xb9ab,
- 0xb9ad, 0xb9c7,
- 0xb9c9, 0xb9e3,
- 0xb9e5, 0xb9ff,
- 0xba01, 0xba1b,
- 0xba1d, 0xba37,
- 0xba39, 0xba53,
- 0xba55, 0xba6f,
- 0xba71, 0xba8b,
- 0xba8d, 0xbaa7,
- 0xbaa9, 0xbac3,
- 0xbac5, 0xbadf,
- 0xbae1, 0xbafb,
- 0xbafd, 0xbb17,
- 0xbb19, 0xbb33,
- 0xbb35, 0xbb4f,
- 0xbb51, 0xbb6b,
- 0xbb6d, 0xbb87,
- 0xbb89, 0xbba3,
- 0xbba5, 0xbbbf,
- 0xbbc1, 0xbbdb,
- 0xbbdd, 0xbbf7,
- 0xbbf9, 0xbc13,
- 0xbc15, 0xbc2f,
- 0xbc31, 0xbc4b,
- 0xbc4d, 0xbc67,
- 0xbc69, 0xbc83,
- 0xbc85, 0xbc9f,
- 0xbca1, 0xbcbb,
- 0xbcbd, 0xbcd7,
- 0xbcd9, 0xbcf3,
- 0xbcf5, 0xbd0f,
- 0xbd11, 0xbd2b,
- 0xbd2d, 0xbd47,
- 0xbd49, 0xbd63,
- 0xbd65, 0xbd7f,
- 0xbd81, 0xbd9b,
- 0xbd9d, 0xbdb7,
- 0xbdb9, 0xbdd3,
- 0xbdd5, 0xbdef,
- 0xbdf1, 0xbe0b,
- 0xbe0d, 0xbe27,
- 0xbe29, 0xbe43,
- 0xbe45, 0xbe5f,
- 0xbe61, 0xbe7b,
- 0xbe7d, 0xbe97,
- 0xbe99, 0xbeb3,
- 0xbeb5, 0xbecf,
- 0xbed1, 0xbeeb,
- 0xbeed, 0xbf07,
- 0xbf09, 0xbf23,
- 0xbf25, 0xbf3f,
- 0xbf41, 0xbf5b,
- 0xbf5d, 0xbf77,
- 0xbf79, 0xbf93,
- 0xbf95, 0xbfaf,
- 0xbfb1, 0xbfcb,
- 0xbfcd, 0xbfe7,
- 0xbfe9, 0xc003,
- 0xc005, 0xc01f,
- 0xc021, 0xc03b,
- 0xc03d, 0xc057,
- 0xc059, 0xc073,
- 0xc075, 0xc08f,
- 0xc091, 0xc0ab,
- 0xc0ad, 0xc0c7,
- 0xc0c9, 0xc0e3,
- 0xc0e5, 0xc0ff,
- 0xc101, 0xc11b,
- 0xc11d, 0xc137,
- 0xc139, 0xc153,
- 0xc155, 0xc16f,
- 0xc171, 0xc18b,
- 0xc18d, 0xc1a7,
- 0xc1a9, 0xc1c3,
- 0xc1c5, 0xc1df,
- 0xc1e1, 0xc1fb,
- 0xc1fd, 0xc217,
- 0xc219, 0xc233,
- 0xc235, 0xc24f,
- 0xc251, 0xc26b,
- 0xc26d, 0xc287,
- 0xc289, 0xc2a3,
- 0xc2a5, 0xc2bf,
- 0xc2c1, 0xc2db,
- 0xc2dd, 0xc2f7,
- 0xc2f9, 0xc313,
- 0xc315, 0xc32f,
- 0xc331, 0xc34b,
- 0xc34d, 0xc367,
- 0xc369, 0xc383,
- 0xc385, 0xc39f,
- 0xc3a1, 0xc3bb,
- 0xc3bd, 0xc3d7,
- 0xc3d9, 0xc3f3,
- 0xc3f5, 0xc40f,
- 0xc411, 0xc42b,
- 0xc42d, 0xc447,
- 0xc449, 0xc463,
- 0xc465, 0xc47f,
- 0xc481, 0xc49b,
- 0xc49d, 0xc4b7,
- 0xc4b9, 0xc4d3,
- 0xc4d5, 0xc4ef,
- 0xc4f1, 0xc50b,
- 0xc50d, 0xc527,
- 0xc529, 0xc543,
- 0xc545, 0xc55f,
- 0xc561, 0xc57b,
- 0xc57d, 0xc597,
- 0xc599, 0xc5b3,
- 0xc5b5, 0xc5cf,
- 0xc5d1, 0xc5eb,
- 0xc5ed, 0xc607,
- 0xc609, 0xc623,
- 0xc625, 0xc63f,
- 0xc641, 0xc65b,
- 0xc65d, 0xc677,
- 0xc679, 0xc693,
- 0xc695, 0xc6af,
- 0xc6b1, 0xc6cb,
- 0xc6cd, 0xc6e7,
- 0xc6e9, 0xc703,
- 0xc705, 0xc71f,
- 0xc721, 0xc73b,
- 0xc73d, 0xc757,
- 0xc759, 0xc773,
- 0xc775, 0xc78f,
- 0xc791, 0xc7ab,
- 0xc7ad, 0xc7c7,
- 0xc7c9, 0xc7e3,
- 0xc7e5, 0xc7ff,
- 0xc801, 0xc81b,
- 0xc81d, 0xc837,
- 0xc839, 0xc853,
- 0xc855, 0xc86f,
- 0xc871, 0xc88b,
- 0xc88d, 0xc8a7,
- 0xc8a9, 0xc8c3,
- 0xc8c5, 0xc8df,
- 0xc8e1, 0xc8fb,
- 0xc8fd, 0xc917,
- 0xc919, 0xc933,
- 0xc935, 0xc94f,
- 0xc951, 0xc96b,
- 0xc96d, 0xc987,
- 0xc989, 0xc9a3,
- 0xc9a5, 0xc9bf,
- 0xc9c1, 0xc9db,
- 0xc9dd, 0xc9f7,
- 0xc9f9, 0xca13,
- 0xca15, 0xca2f,
- 0xca31, 0xca4b,
- 0xca4d, 0xca67,
- 0xca69, 0xca83,
- 0xca85, 0xca9f,
- 0xcaa1, 0xcabb,
- 0xcabd, 0xcad7,
- 0xcad9, 0xcaf3,
- 0xcaf5, 0xcb0f,
- 0xcb11, 0xcb2b,
- 0xcb2d, 0xcb47,
- 0xcb49, 0xcb63,
- 0xcb65, 0xcb7f,
- 0xcb81, 0xcb9b,
- 0xcb9d, 0xcbb7,
- 0xcbb9, 0xcbd3,
- 0xcbd5, 0xcbef,
- 0xcbf1, 0xcc0b,
- 0xcc0d, 0xcc27,
- 0xcc29, 0xcc43,
- 0xcc45, 0xcc5f,
- 0xcc61, 0xcc7b,
- 0xcc7d, 0xcc97,
- 0xcc99, 0xccb3,
- 0xccb5, 0xcccf,
- 0xccd1, 0xcceb,
- 0xcced, 0xcd07,
- 0xcd09, 0xcd23,
- 0xcd25, 0xcd3f,
- 0xcd41, 0xcd5b,
- 0xcd5d, 0xcd77,
- 0xcd79, 0xcd93,
- 0xcd95, 0xcdaf,
- 0xcdb1, 0xcdcb,
- 0xcdcd, 0xcde7,
- 0xcde9, 0xce03,
- 0xce05, 0xce1f,
- 0xce21, 0xce3b,
- 0xce3d, 0xce57,
- 0xce59, 0xce73,
- 0xce75, 0xce8f,
- 0xce91, 0xceab,
- 0xcead, 0xcec7,
- 0xcec9, 0xcee3,
- 0xcee5, 0xceff,
- 0xcf01, 0xcf1b,
- 0xcf1d, 0xcf37,
- 0xcf39, 0xcf53,
- 0xcf55, 0xcf6f,
- 0xcf71, 0xcf8b,
- 0xcf8d, 0xcfa7,
- 0xcfa9, 0xcfc3,
- 0xcfc5, 0xcfdf,
- 0xcfe1, 0xcffb,
- 0xcffd, 0xd017,
- 0xd019, 0xd033,
- 0xd035, 0xd04f,
- 0xd051, 0xd06b,
- 0xd06d, 0xd087,
- 0xd089, 0xd0a3,
- 0xd0a5, 0xd0bf,
- 0xd0c1, 0xd0db,
- 0xd0dd, 0xd0f7,
- 0xd0f9, 0xd113,
- 0xd115, 0xd12f,
- 0xd131, 0xd14b,
- 0xd14d, 0xd167,
- 0xd169, 0xd183,
- 0xd185, 0xd19f,
- 0xd1a1, 0xd1bb,
- 0xd1bd, 0xd1d7,
- 0xd1d9, 0xd1f3,
- 0xd1f5, 0xd20f,
- 0xd211, 0xd22b,
- 0xd22d, 0xd247,
- 0xd249, 0xd263,
- 0xd265, 0xd27f,
- 0xd281, 0xd29b,
- 0xd29d, 0xd2b7,
- 0xd2b9, 0xd2d3,
- 0xd2d5, 0xd2ef,
- 0xd2f1, 0xd30b,
- 0xd30d, 0xd327,
- 0xd329, 0xd343,
- 0xd345, 0xd35f,
- 0xd361, 0xd37b,
- 0xd37d, 0xd397,
- 0xd399, 0xd3b3,
- 0xd3b5, 0xd3cf,
- 0xd3d1, 0xd3eb,
- 0xd3ed, 0xd407,
- 0xd409, 0xd423,
- 0xd425, 0xd43f,
- 0xd441, 0xd45b,
- 0xd45d, 0xd477,
- 0xd479, 0xd493,
- 0xd495, 0xd4af,
- 0xd4b1, 0xd4cb,
- 0xd4cd, 0xd4e7,
- 0xd4e9, 0xd503,
- 0xd505, 0xd51f,
- 0xd521, 0xd53b,
- 0xd53d, 0xd557,
- 0xd559, 0xd573,
- 0xd575, 0xd58f,
- 0xd591, 0xd5ab,
- 0xd5ad, 0xd5c7,
- 0xd5c9, 0xd5e3,
- 0xd5e5, 0xd5ff,
- 0xd601, 0xd61b,
- 0xd61d, 0xd637,
- 0xd639, 0xd653,
- 0xd655, 0xd66f,
- 0xd671, 0xd68b,
- 0xd68d, 0xd6a7,
- 0xd6a9, 0xd6c3,
- 0xd6c5, 0xd6df,
- 0xd6e1, 0xd6fb,
- 0xd6fd, 0xd717,
- 0xd719, 0xd733,
- 0xd735, 0xd74f,
- 0xd751, 0xd76b,
- 0xd76d, 0xd787,
- 0xd789, 0xd7a3,
-}; /* CR_Grapheme_Cluster_Break_LVT */
-
-/* 'Grapheme_Cluster_Break_ZWJ': Grapheme_Cluster_Break=ZWJ */
-static const OnigCodePoint CR_Grapheme_Cluster_Break_ZWJ[] = {
- 1,
- 0x200d, 0x200d,
-}; /* CR_Grapheme_Cluster_Break_ZWJ */
-
-/* 'In_Basic_Latin': Block */
-#define CR_In_Basic_Latin CR_ASCII
-
-/* 'In_Latin_1_Supplement': Block */
-static const OnigCodePoint CR_In_Latin_1_Supplement[] = {
- 1,
- 0x0080, 0x00ff,
-}; /* CR_In_Latin_1_Supplement */
-
-/* 'In_Latin_Extended_A': Block */
-static const OnigCodePoint CR_In_Latin_Extended_A[] = {
- 1,
- 0x0100, 0x017f,
-}; /* CR_In_Latin_Extended_A */
-
-/* 'In_Latin_Extended_B': Block */
-static const OnigCodePoint CR_In_Latin_Extended_B[] = {
- 1,
- 0x0180, 0x024f,
-}; /* CR_In_Latin_Extended_B */
-
-/* 'In_IPA_Extensions': Block */
-static const OnigCodePoint CR_In_IPA_Extensions[] = {
- 1,
- 0x0250, 0x02af,
-}; /* CR_In_IPA_Extensions */
-
-/* 'In_Spacing_Modifier_Letters': Block */
-static const OnigCodePoint CR_In_Spacing_Modifier_Letters[] = {
- 1,
- 0x02b0, 0x02ff,
-}; /* CR_In_Spacing_Modifier_Letters */
-
-/* 'In_Combining_Diacritical_Marks': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks[] = {
- 1,
- 0x0300, 0x036f,
-}; /* CR_In_Combining_Diacritical_Marks */
-
-/* 'In_Greek_and_Coptic': Block */
-static const OnigCodePoint CR_In_Greek_and_Coptic[] = {
- 1,
- 0x0370, 0x03ff,
-}; /* CR_In_Greek_and_Coptic */
-
-/* 'In_Cyrillic': Block */
-static const OnigCodePoint CR_In_Cyrillic[] = {
- 1,
- 0x0400, 0x04ff,
-}; /* CR_In_Cyrillic */
-
-/* 'In_Cyrillic_Supplement': Block */
-static const OnigCodePoint CR_In_Cyrillic_Supplement[] = {
- 1,
- 0x0500, 0x052f,
-}; /* CR_In_Cyrillic_Supplement */
-
-/* 'In_Armenian': Block */
-static const OnigCodePoint CR_In_Armenian[] = {
- 1,
- 0x0530, 0x058f,
-}; /* CR_In_Armenian */
-
-/* 'In_Hebrew': Block */
-static const OnigCodePoint CR_In_Hebrew[] = {
- 1,
- 0x0590, 0x05ff,
-}; /* CR_In_Hebrew */
-
-/* 'In_Arabic': Block */
-static const OnigCodePoint CR_In_Arabic[] = {
- 1,
- 0x0600, 0x06ff,
-}; /* CR_In_Arabic */
-
-/* 'In_Syriac': Block */
-static const OnigCodePoint CR_In_Syriac[] = {
- 1,
- 0x0700, 0x074f,
-}; /* CR_In_Syriac */
-
-/* 'In_Arabic_Supplement': Block */
-static const OnigCodePoint CR_In_Arabic_Supplement[] = {
- 1,
- 0x0750, 0x077f,
-}; /* CR_In_Arabic_Supplement */
-
-/* 'In_Thaana': Block */
-static const OnigCodePoint CR_In_Thaana[] = {
- 1,
- 0x0780, 0x07bf,
-}; /* CR_In_Thaana */
-
-/* 'In_NKo': Block */
-static const OnigCodePoint CR_In_NKo[] = {
- 1,
- 0x07c0, 0x07ff,
-}; /* CR_In_NKo */
-
-/* 'In_Samaritan': Block */
-static const OnigCodePoint CR_In_Samaritan[] = {
- 1,
- 0x0800, 0x083f,
-}; /* CR_In_Samaritan */
-
-/* 'In_Mandaic': Block */
-static const OnigCodePoint CR_In_Mandaic[] = {
- 1,
- 0x0840, 0x085f,
-}; /* CR_In_Mandaic */
-
-/* 'In_Syriac_Supplement': Block */
-static const OnigCodePoint CR_In_Syriac_Supplement[] = {
- 1,
- 0x0860, 0x086f,
-}; /* CR_In_Syriac_Supplement */
-
-/* 'In_Arabic_Extended_B': Block */
-static const OnigCodePoint CR_In_Arabic_Extended_B[] = {
- 1,
- 0x0870, 0x089f,
-}; /* CR_In_Arabic_Extended_B */
-
-/* 'In_Arabic_Extended_A': Block */
-static const OnigCodePoint CR_In_Arabic_Extended_A[] = {
- 1,
- 0x08a0, 0x08ff,
-}; /* CR_In_Arabic_Extended_A */
-
-/* 'In_Devanagari': Block */
-static const OnigCodePoint CR_In_Devanagari[] = {
- 1,
- 0x0900, 0x097f,
-}; /* CR_In_Devanagari */
-
-/* 'In_Bengali': Block */
-static const OnigCodePoint CR_In_Bengali[] = {
- 1,
- 0x0980, 0x09ff,
-}; /* CR_In_Bengali */
-
-/* 'In_Gurmukhi': Block */
-static const OnigCodePoint CR_In_Gurmukhi[] = {
- 1,
- 0x0a00, 0x0a7f,
-}; /* CR_In_Gurmukhi */
-
-/* 'In_Gujarati': Block */
-static const OnigCodePoint CR_In_Gujarati[] = {
- 1,
- 0x0a80, 0x0aff,
-}; /* CR_In_Gujarati */
-
-/* 'In_Oriya': Block */
-static const OnigCodePoint CR_In_Oriya[] = {
- 1,
- 0x0b00, 0x0b7f,
-}; /* CR_In_Oriya */
-
-/* 'In_Tamil': Block */
-static const OnigCodePoint CR_In_Tamil[] = {
- 1,
- 0x0b80, 0x0bff,
-}; /* CR_In_Tamil */
-
-/* 'In_Telugu': Block */
-static const OnigCodePoint CR_In_Telugu[] = {
- 1,
- 0x0c00, 0x0c7f,
-}; /* CR_In_Telugu */
-
-/* 'In_Kannada': Block */
-static const OnigCodePoint CR_In_Kannada[] = {
- 1,
- 0x0c80, 0x0cff,
-}; /* CR_In_Kannada */
-
-/* 'In_Malayalam': Block */
-static const OnigCodePoint CR_In_Malayalam[] = {
- 1,
- 0x0d00, 0x0d7f,
-}; /* CR_In_Malayalam */
-
-/* 'In_Sinhala': Block */
-static const OnigCodePoint CR_In_Sinhala[] = {
- 1,
- 0x0d80, 0x0dff,
-}; /* CR_In_Sinhala */
-
-/* 'In_Thai': Block */
-static const OnigCodePoint CR_In_Thai[] = {
- 1,
- 0x0e00, 0x0e7f,
-}; /* CR_In_Thai */
-
-/* 'In_Lao': Block */
-static const OnigCodePoint CR_In_Lao[] = {
- 1,
- 0x0e80, 0x0eff,
-}; /* CR_In_Lao */
-
-/* 'In_Tibetan': Block */
-static const OnigCodePoint CR_In_Tibetan[] = {
- 1,
- 0x0f00, 0x0fff,
-}; /* CR_In_Tibetan */
-
-/* 'In_Myanmar': Block */
-static const OnigCodePoint CR_In_Myanmar[] = {
- 1,
- 0x1000, 0x109f,
-}; /* CR_In_Myanmar */
-
-/* 'In_Georgian': Block */
-static const OnigCodePoint CR_In_Georgian[] = {
- 1,
- 0x10a0, 0x10ff,
-}; /* CR_In_Georgian */
-
-/* 'In_Hangul_Jamo': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo[] = {
- 1,
- 0x1100, 0x11ff,
-}; /* CR_In_Hangul_Jamo */
-
-/* 'In_Ethiopic': Block */
-static const OnigCodePoint CR_In_Ethiopic[] = {
- 1,
- 0x1200, 0x137f,
-}; /* CR_In_Ethiopic */
-
-/* 'In_Ethiopic_Supplement': Block */
-static const OnigCodePoint CR_In_Ethiopic_Supplement[] = {
- 1,
- 0x1380, 0x139f,
-}; /* CR_In_Ethiopic_Supplement */
-
-/* 'In_Cherokee': Block */
-static const OnigCodePoint CR_In_Cherokee[] = {
- 1,
- 0x13a0, 0x13ff,
-}; /* CR_In_Cherokee */
-
-/* 'In_Unified_Canadian_Aboriginal_Syllabics': Block */
-static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics[] = {
- 1,
- 0x1400, 0x167f,
-}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics */
-
-/* 'In_Ogham': Block */
-static const OnigCodePoint CR_In_Ogham[] = {
- 1,
- 0x1680, 0x169f,
-}; /* CR_In_Ogham */
-
-/* 'In_Runic': Block */
-static const OnigCodePoint CR_In_Runic[] = {
- 1,
- 0x16a0, 0x16ff,
-}; /* CR_In_Runic */
-
-/* 'In_Tagalog': Block */
-static const OnigCodePoint CR_In_Tagalog[] = {
- 1,
- 0x1700, 0x171f,
-}; /* CR_In_Tagalog */
-
-/* 'In_Hanunoo': Block */
-static const OnigCodePoint CR_In_Hanunoo[] = {
- 1,
- 0x1720, 0x173f,
-}; /* CR_In_Hanunoo */
-
-/* 'In_Buhid': Block */
-static const OnigCodePoint CR_In_Buhid[] = {
- 1,
- 0x1740, 0x175f,
-}; /* CR_In_Buhid */
-
-/* 'In_Tagbanwa': Block */
-static const OnigCodePoint CR_In_Tagbanwa[] = {
- 1,
- 0x1760, 0x177f,
-}; /* CR_In_Tagbanwa */
-
-/* 'In_Khmer': Block */
-static const OnigCodePoint CR_In_Khmer[] = {
- 1,
- 0x1780, 0x17ff,
-}; /* CR_In_Khmer */
-
-/* 'In_Mongolian': Block */
-static const OnigCodePoint CR_In_Mongolian[] = {
- 1,
- 0x1800, 0x18af,
-}; /* CR_In_Mongolian */
-
-/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended': Block */
-static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended[] = {
- 1,
- 0x18b0, 0x18ff,
-}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended */
-
-/* 'In_Limbu': Block */
-static const OnigCodePoint CR_In_Limbu[] = {
- 1,
- 0x1900, 0x194f,
-}; /* CR_In_Limbu */
-
-/* 'In_Tai_Le': Block */
-static const OnigCodePoint CR_In_Tai_Le[] = {
- 1,
- 0x1950, 0x197f,
-}; /* CR_In_Tai_Le */
-
-/* 'In_New_Tai_Lue': Block */
-static const OnigCodePoint CR_In_New_Tai_Lue[] = {
- 1,
- 0x1980, 0x19df,
-}; /* CR_In_New_Tai_Lue */
-
-/* 'In_Khmer_Symbols': Block */
-static const OnigCodePoint CR_In_Khmer_Symbols[] = {
- 1,
- 0x19e0, 0x19ff,
-}; /* CR_In_Khmer_Symbols */
-
-/* 'In_Buginese': Block */
-static const OnigCodePoint CR_In_Buginese[] = {
- 1,
- 0x1a00, 0x1a1f,
-}; /* CR_In_Buginese */
-
-/* 'In_Tai_Tham': Block */
-static const OnigCodePoint CR_In_Tai_Tham[] = {
- 1,
- 0x1a20, 0x1aaf,
-}; /* CR_In_Tai_Tham */
-
-/* 'In_Combining_Diacritical_Marks_Extended': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Extended[] = {
- 1,
- 0x1ab0, 0x1aff,
-}; /* CR_In_Combining_Diacritical_Marks_Extended */
-
-/* 'In_Balinese': Block */
-static const OnigCodePoint CR_In_Balinese[] = {
- 1,
- 0x1b00, 0x1b7f,
-}; /* CR_In_Balinese */
-
-/* 'In_Sundanese': Block */
-static const OnigCodePoint CR_In_Sundanese[] = {
- 1,
- 0x1b80, 0x1bbf,
-}; /* CR_In_Sundanese */
-
-/* 'In_Batak': Block */
-static const OnigCodePoint CR_In_Batak[] = {
- 1,
- 0x1bc0, 0x1bff,
-}; /* CR_In_Batak */
-
-/* 'In_Lepcha': Block */
-static const OnigCodePoint CR_In_Lepcha[] = {
- 1,
- 0x1c00, 0x1c4f,
-}; /* CR_In_Lepcha */
-
-/* 'In_Ol_Chiki': Block */
-#define CR_In_Ol_Chiki CR_Ol_Chiki
-
-/* 'In_Cyrillic_Extended_C': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_C[] = {
- 1,
- 0x1c80, 0x1c8f,
-}; /* CR_In_Cyrillic_Extended_C */
-
-/* 'In_Georgian_Extended': Block */
-static const OnigCodePoint CR_In_Georgian_Extended[] = {
- 1,
- 0x1c90, 0x1cbf,
-}; /* CR_In_Georgian_Extended */
-
-/* 'In_Sundanese_Supplement': Block */
-static const OnigCodePoint CR_In_Sundanese_Supplement[] = {
- 1,
- 0x1cc0, 0x1ccf,
-}; /* CR_In_Sundanese_Supplement */
-
-/* 'In_Vedic_Extensions': Block */
-static const OnigCodePoint CR_In_Vedic_Extensions[] = {
- 1,
- 0x1cd0, 0x1cff,
-}; /* CR_In_Vedic_Extensions */
-
-/* 'In_Phonetic_Extensions': Block */
-static const OnigCodePoint CR_In_Phonetic_Extensions[] = {
- 1,
- 0x1d00, 0x1d7f,
-}; /* CR_In_Phonetic_Extensions */
-
-/* 'In_Phonetic_Extensions_Supplement': Block */
-static const OnigCodePoint CR_In_Phonetic_Extensions_Supplement[] = {
- 1,
- 0x1d80, 0x1dbf,
-}; /* CR_In_Phonetic_Extensions_Supplement */
-
-/* 'In_Combining_Diacritical_Marks_Supplement': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Supplement[] = {
- 1,
- 0x1dc0, 0x1dff,
-}; /* CR_In_Combining_Diacritical_Marks_Supplement */
-
-/* 'In_Latin_Extended_Additional': Block */
-static const OnigCodePoint CR_In_Latin_Extended_Additional[] = {
- 1,
- 0x1e00, 0x1eff,
-}; /* CR_In_Latin_Extended_Additional */
-
-/* 'In_Greek_Extended': Block */
-static const OnigCodePoint CR_In_Greek_Extended[] = {
- 1,
- 0x1f00, 0x1fff,
-}; /* CR_In_Greek_Extended */
-
-/* 'In_General_Punctuation': Block */
-static const OnigCodePoint CR_In_General_Punctuation[] = {
- 1,
- 0x2000, 0x206f,
-}; /* CR_In_General_Punctuation */
-
-/* 'In_Superscripts_and_Subscripts': Block */
-static const OnigCodePoint CR_In_Superscripts_and_Subscripts[] = {
- 1,
- 0x2070, 0x209f,
-}; /* CR_In_Superscripts_and_Subscripts */
-
-/* 'In_Currency_Symbols': Block */
-static const OnigCodePoint CR_In_Currency_Symbols[] = {
- 1,
- 0x20a0, 0x20cf,
-}; /* CR_In_Currency_Symbols */
-
-/* 'In_Combining_Diacritical_Marks_for_Symbols': Block */
-static const OnigCodePoint CR_In_Combining_Diacritical_Marks_for_Symbols[] = {
- 1,
- 0x20d0, 0x20ff,
-}; /* CR_In_Combining_Diacritical_Marks_for_Symbols */
-
-/* 'In_Letterlike_Symbols': Block */
-static const OnigCodePoint CR_In_Letterlike_Symbols[] = {
- 1,
- 0x2100, 0x214f,
-}; /* CR_In_Letterlike_Symbols */
-
-/* 'In_Number_Forms': Block */
-static const OnigCodePoint CR_In_Number_Forms[] = {
- 1,
- 0x2150, 0x218f,
-}; /* CR_In_Number_Forms */
-
-/* 'In_Arrows': Block */
-static const OnigCodePoint CR_In_Arrows[] = {
- 1,
- 0x2190, 0x21ff,
-}; /* CR_In_Arrows */
-
-/* 'In_Mathematical_Operators': Block */
-static const OnigCodePoint CR_In_Mathematical_Operators[] = {
- 1,
- 0x2200, 0x22ff,
-}; /* CR_In_Mathematical_Operators */
-
-/* 'In_Miscellaneous_Technical': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Technical[] = {
- 1,
- 0x2300, 0x23ff,
-}; /* CR_In_Miscellaneous_Technical */
-
-/* 'In_Control_Pictures': Block */
-static const OnigCodePoint CR_In_Control_Pictures[] = {
- 1,
- 0x2400, 0x243f,
-}; /* CR_In_Control_Pictures */
-
-/* 'In_Optical_Character_Recognition': Block */
-static const OnigCodePoint CR_In_Optical_Character_Recognition[] = {
- 1,
- 0x2440, 0x245f,
-}; /* CR_In_Optical_Character_Recognition */
-
-/* 'In_Enclosed_Alphanumerics': Block */
-static const OnigCodePoint CR_In_Enclosed_Alphanumerics[] = {
- 1,
- 0x2460, 0x24ff,
-}; /* CR_In_Enclosed_Alphanumerics */
-
-/* 'In_Box_Drawing': Block */
-static const OnigCodePoint CR_In_Box_Drawing[] = {
- 1,
- 0x2500, 0x257f,
-}; /* CR_In_Box_Drawing */
-
-/* 'In_Block_Elements': Block */
-static const OnigCodePoint CR_In_Block_Elements[] = {
- 1,
- 0x2580, 0x259f,
-}; /* CR_In_Block_Elements */
-
-/* 'In_Geometric_Shapes': Block */
-static const OnigCodePoint CR_In_Geometric_Shapes[] = {
- 1,
- 0x25a0, 0x25ff,
-}; /* CR_In_Geometric_Shapes */
-
-/* 'In_Miscellaneous_Symbols': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols[] = {
- 1,
- 0x2600, 0x26ff,
-}; /* CR_In_Miscellaneous_Symbols */
-
-/* 'In_Dingbats': Block */
-static const OnigCodePoint CR_In_Dingbats[] = {
- 1,
- 0x2700, 0x27bf,
-}; /* CR_In_Dingbats */
-
-/* 'In_Miscellaneous_Mathematical_Symbols_A': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_A[] = {
- 1,
- 0x27c0, 0x27ef,
-}; /* CR_In_Miscellaneous_Mathematical_Symbols_A */
-
-/* 'In_Supplemental_Arrows_A': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_A[] = {
- 1,
- 0x27f0, 0x27ff,
-}; /* CR_In_Supplemental_Arrows_A */
-
-/* 'In_Braille_Patterns': Block */
-#define CR_In_Braille_Patterns CR_Braille
-
-/* 'In_Supplemental_Arrows_B': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_B[] = {
- 1,
- 0x2900, 0x297f,
-}; /* CR_In_Supplemental_Arrows_B */
-
-/* 'In_Miscellaneous_Mathematical_Symbols_B': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_B[] = {
- 1,
- 0x2980, 0x29ff,
-}; /* CR_In_Miscellaneous_Mathematical_Symbols_B */
-
-/* 'In_Supplemental_Mathematical_Operators': Block */
-static const OnigCodePoint CR_In_Supplemental_Mathematical_Operators[] = {
- 1,
- 0x2a00, 0x2aff,
-}; /* CR_In_Supplemental_Mathematical_Operators */
-
-/* 'In_Miscellaneous_Symbols_and_Arrows': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Arrows[] = {
- 1,
- 0x2b00, 0x2bff,
-}; /* CR_In_Miscellaneous_Symbols_and_Arrows */
-
-/* 'In_Glagolitic': Block */
-static const OnigCodePoint CR_In_Glagolitic[] = {
- 1,
- 0x2c00, 0x2c5f,
-}; /* CR_In_Glagolitic */
-
-/* 'In_Latin_Extended_C': Block */
-static const OnigCodePoint CR_In_Latin_Extended_C[] = {
- 1,
- 0x2c60, 0x2c7f,
-}; /* CR_In_Latin_Extended_C */
-
-/* 'In_Coptic': Block */
-static const OnigCodePoint CR_In_Coptic[] = {
- 1,
- 0x2c80, 0x2cff,
-}; /* CR_In_Coptic */
-
-/* 'In_Georgian_Supplement': Block */
-static const OnigCodePoint CR_In_Georgian_Supplement[] = {
- 1,
- 0x2d00, 0x2d2f,
-}; /* CR_In_Georgian_Supplement */
-
-/* 'In_Tifinagh': Block */
-static const OnigCodePoint CR_In_Tifinagh[] = {
- 1,
- 0x2d30, 0x2d7f,
-}; /* CR_In_Tifinagh */
-
-/* 'In_Ethiopic_Extended': Block */
-static const OnigCodePoint CR_In_Ethiopic_Extended[] = {
- 1,
- 0x2d80, 0x2ddf,
-}; /* CR_In_Ethiopic_Extended */
-
-/* 'In_Cyrillic_Extended_A': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_A[] = {
- 1,
- 0x2de0, 0x2dff,
-}; /* CR_In_Cyrillic_Extended_A */
-
-/* 'In_Supplemental_Punctuation': Block */
-static const OnigCodePoint CR_In_Supplemental_Punctuation[] = {
- 1,
- 0x2e00, 0x2e7f,
-}; /* CR_In_Supplemental_Punctuation */
-
-/* 'In_CJK_Radicals_Supplement': Block */
-static const OnigCodePoint CR_In_CJK_Radicals_Supplement[] = {
- 1,
- 0x2e80, 0x2eff,
-}; /* CR_In_CJK_Radicals_Supplement */
-
-/* 'In_Kangxi_Radicals': Block */
-static const OnigCodePoint CR_In_Kangxi_Radicals[] = {
- 1,
- 0x2f00, 0x2fdf,
-}; /* CR_In_Kangxi_Radicals */
-
-/* 'In_Ideographic_Description_Characters': Block */
-static const OnigCodePoint CR_In_Ideographic_Description_Characters[] = {
- 1,
- 0x2ff0, 0x2fff,
-}; /* CR_In_Ideographic_Description_Characters */
-
-/* 'In_CJK_Symbols_and_Punctuation': Block */
-static const OnigCodePoint CR_In_CJK_Symbols_and_Punctuation[] = {
- 1,
- 0x3000, 0x303f,
-}; /* CR_In_CJK_Symbols_and_Punctuation */
-
-/* 'In_Hiragana': Block */
-static const OnigCodePoint CR_In_Hiragana[] = {
- 1,
- 0x3040, 0x309f,
-}; /* CR_In_Hiragana */
-
-/* 'In_Katakana': Block */
-static const OnigCodePoint CR_In_Katakana[] = {
- 1,
- 0x30a0, 0x30ff,
-}; /* CR_In_Katakana */
-
-/* 'In_Bopomofo': Block */
-static const OnigCodePoint CR_In_Bopomofo[] = {
- 1,
- 0x3100, 0x312f,
-}; /* CR_In_Bopomofo */
-
-/* 'In_Hangul_Compatibility_Jamo': Block */
-static const OnigCodePoint CR_In_Hangul_Compatibility_Jamo[] = {
- 1,
- 0x3130, 0x318f,
-}; /* CR_In_Hangul_Compatibility_Jamo */
-
-/* 'In_Kanbun': Block */
-static const OnigCodePoint CR_In_Kanbun[] = {
- 1,
- 0x3190, 0x319f,
-}; /* CR_In_Kanbun */
-
-/* 'In_Bopomofo_Extended': Block */
-static const OnigCodePoint CR_In_Bopomofo_Extended[] = {
- 1,
- 0x31a0, 0x31bf,
-}; /* CR_In_Bopomofo_Extended */
-
-/* 'In_CJK_Strokes': Block */
-static const OnigCodePoint CR_In_CJK_Strokes[] = {
- 1,
- 0x31c0, 0x31ef,
-}; /* CR_In_CJK_Strokes */
-
-/* 'In_Katakana_Phonetic_Extensions': Block */
-static const OnigCodePoint CR_In_Katakana_Phonetic_Extensions[] = {
- 1,
- 0x31f0, 0x31ff,
-}; /* CR_In_Katakana_Phonetic_Extensions */
-
-/* 'In_Enclosed_CJK_Letters_and_Months': Block */
-static const OnigCodePoint CR_In_Enclosed_CJK_Letters_and_Months[] = {
- 1,
- 0x3200, 0x32ff,
-}; /* CR_In_Enclosed_CJK_Letters_and_Months */
-
-/* 'In_CJK_Compatibility': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility[] = {
- 1,
- 0x3300, 0x33ff,
-}; /* CR_In_CJK_Compatibility */
-
-/* 'In_CJK_Unified_Ideographs_Extension_A': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_A[] = {
- 1,
- 0x3400, 0x4dbf,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_A */
-
-/* 'In_Yijing_Hexagram_Symbols': Block */
-static const OnigCodePoint CR_In_Yijing_Hexagram_Symbols[] = {
- 1,
- 0x4dc0, 0x4dff,
-}; /* CR_In_Yijing_Hexagram_Symbols */
-
-/* 'In_CJK_Unified_Ideographs': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs[] = {
- 1,
- 0x4e00, 0x9fff,
-}; /* CR_In_CJK_Unified_Ideographs */
-
-/* 'In_Yi_Syllables': Block */
-static const OnigCodePoint CR_In_Yi_Syllables[] = {
- 1,
- 0xa000, 0xa48f,
-}; /* CR_In_Yi_Syllables */
-
-/* 'In_Yi_Radicals': Block */
-static const OnigCodePoint CR_In_Yi_Radicals[] = {
- 1,
- 0xa490, 0xa4cf,
-}; /* CR_In_Yi_Radicals */
-
-/* 'In_Lisu': Block */
-static const OnigCodePoint CR_In_Lisu[] = {
- 1,
- 0xa4d0, 0xa4ff,
-}; /* CR_In_Lisu */
-
-/* 'In_Vai': Block */
-static const OnigCodePoint CR_In_Vai[] = {
- 1,
- 0xa500, 0xa63f,
-}; /* CR_In_Vai */
-
-/* 'In_Cyrillic_Extended_B': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_B[] = {
- 1,
- 0xa640, 0xa69f,
-}; /* CR_In_Cyrillic_Extended_B */
-
-/* 'In_Bamum': Block */
-static const OnigCodePoint CR_In_Bamum[] = {
- 1,
- 0xa6a0, 0xa6ff,
-}; /* CR_In_Bamum */
-
-/* 'In_Modifier_Tone_Letters': Block */
-static const OnigCodePoint CR_In_Modifier_Tone_Letters[] = {
- 1,
- 0xa700, 0xa71f,
-}; /* CR_In_Modifier_Tone_Letters */
-
-/* 'In_Latin_Extended_D': Block */
-static const OnigCodePoint CR_In_Latin_Extended_D[] = {
- 1,
- 0xa720, 0xa7ff,
-}; /* CR_In_Latin_Extended_D */
-
-/* 'In_Syloti_Nagri': Block */
-static const OnigCodePoint CR_In_Syloti_Nagri[] = {
- 1,
- 0xa800, 0xa82f,
-}; /* CR_In_Syloti_Nagri */
-
-/* 'In_Common_Indic_Number_Forms': Block */
-static const OnigCodePoint CR_In_Common_Indic_Number_Forms[] = {
- 1,
- 0xa830, 0xa83f,
-}; /* CR_In_Common_Indic_Number_Forms */
-
-/* 'In_Phags_pa': Block */
-static const OnigCodePoint CR_In_Phags_pa[] = {
- 1,
- 0xa840, 0xa87f,
-}; /* CR_In_Phags_pa */
-
-/* 'In_Saurashtra': Block */
-static const OnigCodePoint CR_In_Saurashtra[] = {
- 1,
- 0xa880, 0xa8df,
-}; /* CR_In_Saurashtra */
-
-/* 'In_Devanagari_Extended': Block */
-static const OnigCodePoint CR_In_Devanagari_Extended[] = {
- 1,
- 0xa8e0, 0xa8ff,
-}; /* CR_In_Devanagari_Extended */
-
-/* 'In_Kayah_Li': Block */
-static const OnigCodePoint CR_In_Kayah_Li[] = {
- 1,
- 0xa900, 0xa92f,
-}; /* CR_In_Kayah_Li */
-
-/* 'In_Rejang': Block */
-static const OnigCodePoint CR_In_Rejang[] = {
- 1,
- 0xa930, 0xa95f,
-}; /* CR_In_Rejang */
-
-/* 'In_Hangul_Jamo_Extended_A': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo_Extended_A[] = {
- 1,
- 0xa960, 0xa97f,
-}; /* CR_In_Hangul_Jamo_Extended_A */
-
-/* 'In_Javanese': Block */
-static const OnigCodePoint CR_In_Javanese[] = {
- 1,
- 0xa980, 0xa9df,
-}; /* CR_In_Javanese */
-
-/* 'In_Myanmar_Extended_B': Block */
-static const OnigCodePoint CR_In_Myanmar_Extended_B[] = {
- 1,
- 0xa9e0, 0xa9ff,
-}; /* CR_In_Myanmar_Extended_B */
-
-/* 'In_Cham': Block */
-static const OnigCodePoint CR_In_Cham[] = {
- 1,
- 0xaa00, 0xaa5f,
-}; /* CR_In_Cham */
-
-/* 'In_Myanmar_Extended_A': Block */
-static const OnigCodePoint CR_In_Myanmar_Extended_A[] = {
- 1,
- 0xaa60, 0xaa7f,
-}; /* CR_In_Myanmar_Extended_A */
-
-/* 'In_Tai_Viet': Block */
-static const OnigCodePoint CR_In_Tai_Viet[] = {
- 1,
- 0xaa80, 0xaadf,
-}; /* CR_In_Tai_Viet */
-
-/* 'In_Meetei_Mayek_Extensions': Block */
-static const OnigCodePoint CR_In_Meetei_Mayek_Extensions[] = {
- 1,
- 0xaae0, 0xaaff,
-}; /* CR_In_Meetei_Mayek_Extensions */
-
-/* 'In_Ethiopic_Extended_A': Block */
-static const OnigCodePoint CR_In_Ethiopic_Extended_A[] = {
- 1,
- 0xab00, 0xab2f,
-}; /* CR_In_Ethiopic_Extended_A */
-
-/* 'In_Latin_Extended_E': Block */
-static const OnigCodePoint CR_In_Latin_Extended_E[] = {
- 1,
- 0xab30, 0xab6f,
-}; /* CR_In_Latin_Extended_E */
-
-/* 'In_Cherokee_Supplement': Block */
-static const OnigCodePoint CR_In_Cherokee_Supplement[] = {
- 1,
- 0xab70, 0xabbf,
-}; /* CR_In_Cherokee_Supplement */
-
-/* 'In_Meetei_Mayek': Block */
-static const OnigCodePoint CR_In_Meetei_Mayek[] = {
- 1,
- 0xabc0, 0xabff,
-}; /* CR_In_Meetei_Mayek */
-
-/* 'In_Hangul_Syllables': Block */
-static const OnigCodePoint CR_In_Hangul_Syllables[] = {
- 1,
- 0xac00, 0xd7af,
-}; /* CR_In_Hangul_Syllables */
-
-/* 'In_Hangul_Jamo_Extended_B': Block */
-static const OnigCodePoint CR_In_Hangul_Jamo_Extended_B[] = {
- 1,
- 0xd7b0, 0xd7ff,
-}; /* CR_In_Hangul_Jamo_Extended_B */
-
-/* 'In_High_Surrogates': Block */
-static const OnigCodePoint CR_In_High_Surrogates[] = {
- 1,
- 0xd800, 0xdb7f,
-}; /* CR_In_High_Surrogates */
-
-/* 'In_High_Private_Use_Surrogates': Block */
-static const OnigCodePoint CR_In_High_Private_Use_Surrogates[] = {
- 1,
- 0xdb80, 0xdbff,
-}; /* CR_In_High_Private_Use_Surrogates */
-
-/* 'In_Low_Surrogates': Block */
-static const OnigCodePoint CR_In_Low_Surrogates[] = {
- 1,
- 0xdc00, 0xdfff,
-}; /* CR_In_Low_Surrogates */
-
-/* 'In_Private_Use_Area': Block */
-static const OnigCodePoint CR_In_Private_Use_Area[] = {
- 1,
- 0xe000, 0xf8ff,
-}; /* CR_In_Private_Use_Area */
-
-/* 'In_CJK_Compatibility_Ideographs': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs[] = {
- 1,
- 0xf900, 0xfaff,
-}; /* CR_In_CJK_Compatibility_Ideographs */
-
-/* 'In_Alphabetic_Presentation_Forms': Block */
-static const OnigCodePoint CR_In_Alphabetic_Presentation_Forms[] = {
- 1,
- 0xfb00, 0xfb4f,
-}; /* CR_In_Alphabetic_Presentation_Forms */
-
-/* 'In_Arabic_Presentation_Forms_A': Block */
-static const OnigCodePoint CR_In_Arabic_Presentation_Forms_A[] = {
- 1,
- 0xfb50, 0xfdff,
-}; /* CR_In_Arabic_Presentation_Forms_A */
-
-/* 'In_Variation_Selectors': Block */
-static const OnigCodePoint CR_In_Variation_Selectors[] = {
- 1,
- 0xfe00, 0xfe0f,
-}; /* CR_In_Variation_Selectors */
-
-/* 'In_Vertical_Forms': Block */
-static const OnigCodePoint CR_In_Vertical_Forms[] = {
- 1,
- 0xfe10, 0xfe1f,
-}; /* CR_In_Vertical_Forms */
-
-/* 'In_Combining_Half_Marks': Block */
-static const OnigCodePoint CR_In_Combining_Half_Marks[] = {
- 1,
- 0xfe20, 0xfe2f,
-}; /* CR_In_Combining_Half_Marks */
-
-/* 'In_CJK_Compatibility_Forms': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Forms[] = {
- 1,
- 0xfe30, 0xfe4f,
-}; /* CR_In_CJK_Compatibility_Forms */
-
-/* 'In_Small_Form_Variants': Block */
-static const OnigCodePoint CR_In_Small_Form_Variants[] = {
- 1,
- 0xfe50, 0xfe6f,
-}; /* CR_In_Small_Form_Variants */
-
-/* 'In_Arabic_Presentation_Forms_B': Block */
-static const OnigCodePoint CR_In_Arabic_Presentation_Forms_B[] = {
- 1,
- 0xfe70, 0xfeff,
-}; /* CR_In_Arabic_Presentation_Forms_B */
-
-/* 'In_Halfwidth_and_Fullwidth_Forms': Block */
-static const OnigCodePoint CR_In_Halfwidth_and_Fullwidth_Forms[] = {
- 1,
- 0xff00, 0xffef,
-}; /* CR_In_Halfwidth_and_Fullwidth_Forms */
-
-/* 'In_Specials': Block */
-static const OnigCodePoint CR_In_Specials[] = {
- 1,
- 0xfff0, 0xffff,
-}; /* CR_In_Specials */
-
-/* 'In_Linear_B_Syllabary': Block */
-static const OnigCodePoint CR_In_Linear_B_Syllabary[] = {
- 1,
- 0x10000, 0x1007f,
-}; /* CR_In_Linear_B_Syllabary */
-
-/* 'In_Linear_B_Ideograms': Block */
-static const OnigCodePoint CR_In_Linear_B_Ideograms[] = {
- 1,
- 0x10080, 0x100ff,
-}; /* CR_In_Linear_B_Ideograms */
-
-/* 'In_Aegean_Numbers': Block */
-static const OnigCodePoint CR_In_Aegean_Numbers[] = {
- 1,
- 0x10100, 0x1013f,
-}; /* CR_In_Aegean_Numbers */
-
-/* 'In_Ancient_Greek_Numbers': Block */
-static const OnigCodePoint CR_In_Ancient_Greek_Numbers[] = {
- 1,
- 0x10140, 0x1018f,
-}; /* CR_In_Ancient_Greek_Numbers */
-
-/* 'In_Ancient_Symbols': Block */
-static const OnigCodePoint CR_In_Ancient_Symbols[] = {
- 1,
- 0x10190, 0x101cf,
-}; /* CR_In_Ancient_Symbols */
-
-/* 'In_Phaistos_Disc': Block */
-static const OnigCodePoint CR_In_Phaistos_Disc[] = {
- 1,
- 0x101d0, 0x101ff,
-}; /* CR_In_Phaistos_Disc */
-
-/* 'In_Lycian': Block */
-static const OnigCodePoint CR_In_Lycian[] = {
- 1,
- 0x10280, 0x1029f,
-}; /* CR_In_Lycian */
-
-/* 'In_Carian': Block */
-static const OnigCodePoint CR_In_Carian[] = {
- 1,
- 0x102a0, 0x102df,
-}; /* CR_In_Carian */
-
-/* 'In_Coptic_Epact_Numbers': Block */
-static const OnigCodePoint CR_In_Coptic_Epact_Numbers[] = {
- 1,
- 0x102e0, 0x102ff,
-}; /* CR_In_Coptic_Epact_Numbers */
-
-/* 'In_Old_Italic': Block */
-static const OnigCodePoint CR_In_Old_Italic[] = {
- 1,
- 0x10300, 0x1032f,
-}; /* CR_In_Old_Italic */
-
-/* 'In_Gothic': Block */
-static const OnigCodePoint CR_In_Gothic[] = {
- 1,
- 0x10330, 0x1034f,
-}; /* CR_In_Gothic */
-
-/* 'In_Old_Permic': Block */
-static const OnigCodePoint CR_In_Old_Permic[] = {
- 1,
- 0x10350, 0x1037f,
-}; /* CR_In_Old_Permic */
-
-/* 'In_Ugaritic': Block */
-static const OnigCodePoint CR_In_Ugaritic[] = {
- 1,
- 0x10380, 0x1039f,
-}; /* CR_In_Ugaritic */
-
-/* 'In_Old_Persian': Block */
-static const OnigCodePoint CR_In_Old_Persian[] = {
- 1,
- 0x103a0, 0x103df,
-}; /* CR_In_Old_Persian */
-
-/* 'In_Deseret': Block */
-#define CR_In_Deseret CR_Deseret
-
-/* 'In_Shavian': Block */
-#define CR_In_Shavian CR_Shavian
-
-/* 'In_Osmanya': Block */
-static const OnigCodePoint CR_In_Osmanya[] = {
- 1,
- 0x10480, 0x104af,
-}; /* CR_In_Osmanya */
-
-/* 'In_Osage': Block */
-static const OnigCodePoint CR_In_Osage[] = {
- 1,
- 0x104b0, 0x104ff,
-}; /* CR_In_Osage */
-
-/* 'In_Elbasan': Block */
-static const OnigCodePoint CR_In_Elbasan[] = {
- 1,
- 0x10500, 0x1052f,
-}; /* CR_In_Elbasan */
-
-/* 'In_Caucasian_Albanian': Block */
-static const OnigCodePoint CR_In_Caucasian_Albanian[] = {
- 1,
- 0x10530, 0x1056f,
-}; /* CR_In_Caucasian_Albanian */
-
-/* 'In_Vithkuqi': Block */
-static const OnigCodePoint CR_In_Vithkuqi[] = {
- 1,
- 0x10570, 0x105bf,
-}; /* CR_In_Vithkuqi */
-
-/* 'In_Linear_A': Block */
-static const OnigCodePoint CR_In_Linear_A[] = {
- 1,
- 0x10600, 0x1077f,
-}; /* CR_In_Linear_A */
-
-/* 'In_Latin_Extended_F': Block */
-static const OnigCodePoint CR_In_Latin_Extended_F[] = {
- 1,
- 0x10780, 0x107bf,
-}; /* CR_In_Latin_Extended_F */
-
-/* 'In_Cypriot_Syllabary': Block */
-static const OnigCodePoint CR_In_Cypriot_Syllabary[] = {
- 1,
- 0x10800, 0x1083f,
-}; /* CR_In_Cypriot_Syllabary */
-
-/* 'In_Imperial_Aramaic': Block */
-static const OnigCodePoint CR_In_Imperial_Aramaic[] = {
- 1,
- 0x10840, 0x1085f,
-}; /* CR_In_Imperial_Aramaic */
-
-/* 'In_Palmyrene': Block */
-#define CR_In_Palmyrene CR_Palmyrene
-
-/* 'In_Nabataean': Block */
-static const OnigCodePoint CR_In_Nabataean[] = {
- 1,
- 0x10880, 0x108af,
-}; /* CR_In_Nabataean */
-
-/* 'In_Hatran': Block */
-static const OnigCodePoint CR_In_Hatran[] = {
- 1,
- 0x108e0, 0x108ff,
-}; /* CR_In_Hatran */
-
-/* 'In_Phoenician': Block */
-static const OnigCodePoint CR_In_Phoenician[] = {
- 1,
- 0x10900, 0x1091f,
-}; /* CR_In_Phoenician */
-
-/* 'In_Lydian': Block */
-static const OnigCodePoint CR_In_Lydian[] = {
- 1,
- 0x10920, 0x1093f,
-}; /* CR_In_Lydian */
-
-/* 'In_Meroitic_Hieroglyphs': Block */
-#define CR_In_Meroitic_Hieroglyphs CR_Meroitic_Hieroglyphs
-
-/* 'In_Meroitic_Cursive': Block */
-static const OnigCodePoint CR_In_Meroitic_Cursive[] = {
- 1,
- 0x109a0, 0x109ff,
-}; /* CR_In_Meroitic_Cursive */
-
-/* 'In_Kharoshthi': Block */
-static const OnigCodePoint CR_In_Kharoshthi[] = {
- 1,
- 0x10a00, 0x10a5f,
-}; /* CR_In_Kharoshthi */
-
-/* 'In_Old_South_Arabian': Block */
-#define CR_In_Old_South_Arabian CR_Old_South_Arabian
-
-/* 'In_Old_North_Arabian': Block */
-#define CR_In_Old_North_Arabian CR_Old_North_Arabian
-
-/* 'In_Manichaean': Block */
-static const OnigCodePoint CR_In_Manichaean[] = {
- 1,
- 0x10ac0, 0x10aff,
-}; /* CR_In_Manichaean */
-
-/* 'In_Avestan': Block */
-static const OnigCodePoint CR_In_Avestan[] = {
- 1,
- 0x10b00, 0x10b3f,
-}; /* CR_In_Avestan */
-
-/* 'In_Inscriptional_Parthian': Block */
-static const OnigCodePoint CR_In_Inscriptional_Parthian[] = {
- 1,
- 0x10b40, 0x10b5f,
-}; /* CR_In_Inscriptional_Parthian */
-
-/* 'In_Inscriptional_Pahlavi': Block */
-static const OnigCodePoint CR_In_Inscriptional_Pahlavi[] = {
- 1,
- 0x10b60, 0x10b7f,
-}; /* CR_In_Inscriptional_Pahlavi */
-
-/* 'In_Psalter_Pahlavi': Block */
-static const OnigCodePoint CR_In_Psalter_Pahlavi[] = {
- 1,
- 0x10b80, 0x10baf,
-}; /* CR_In_Psalter_Pahlavi */
-
-/* 'In_Old_Turkic': Block */
-static const OnigCodePoint CR_In_Old_Turkic[] = {
- 1,
- 0x10c00, 0x10c4f,
-}; /* CR_In_Old_Turkic */
-
-/* 'In_Old_Hungarian': Block */
-static const OnigCodePoint CR_In_Old_Hungarian[] = {
- 1,
- 0x10c80, 0x10cff,
-}; /* CR_In_Old_Hungarian */
-
-/* 'In_Hanifi_Rohingya': Block */
-static const OnigCodePoint CR_In_Hanifi_Rohingya[] = {
- 1,
- 0x10d00, 0x10d3f,
-}; /* CR_In_Hanifi_Rohingya */
-
-/* 'In_Rumi_Numeral_Symbols': Block */
-static const OnigCodePoint CR_In_Rumi_Numeral_Symbols[] = {
- 1,
- 0x10e60, 0x10e7f,
-}; /* CR_In_Rumi_Numeral_Symbols */
-
-/* 'In_Yezidi': Block */
-static const OnigCodePoint CR_In_Yezidi[] = {
- 1,
- 0x10e80, 0x10ebf,
-}; /* CR_In_Yezidi */
-
-/* 'In_Arabic_Extended_C': Block */
-static const OnigCodePoint CR_In_Arabic_Extended_C[] = {
- 1,
- 0x10ec0, 0x10eff,
-}; /* CR_In_Arabic_Extended_C */
-
-/* 'In_Old_Sogdian': Block */
-static const OnigCodePoint CR_In_Old_Sogdian[] = {
- 1,
- 0x10f00, 0x10f2f,
-}; /* CR_In_Old_Sogdian */
-
-/* 'In_Sogdian': Block */
-static const OnigCodePoint CR_In_Sogdian[] = {
- 1,
- 0x10f30, 0x10f6f,
-}; /* CR_In_Sogdian */
-
-/* 'In_Old_Uyghur': Block */
-static const OnigCodePoint CR_In_Old_Uyghur[] = {
- 1,
- 0x10f70, 0x10faf,
-}; /* CR_In_Old_Uyghur */
-
-/* 'In_Chorasmian': Block */
-static const OnigCodePoint CR_In_Chorasmian[] = {
- 1,
- 0x10fb0, 0x10fdf,
-}; /* CR_In_Chorasmian */
-
-/* 'In_Elymaic': Block */
-static const OnigCodePoint CR_In_Elymaic[] = {
- 1,
- 0x10fe0, 0x10fff,
-}; /* CR_In_Elymaic */
-
-/* 'In_Brahmi': Block */
-static const OnigCodePoint CR_In_Brahmi[] = {
- 1,
- 0x11000, 0x1107f,
-}; /* CR_In_Brahmi */
-
-/* 'In_Kaithi': Block */
-static const OnigCodePoint CR_In_Kaithi[] = {
- 1,
- 0x11080, 0x110cf,
-}; /* CR_In_Kaithi */
-
-/* 'In_Sora_Sompeng': Block */
-static const OnigCodePoint CR_In_Sora_Sompeng[] = {
- 1,
- 0x110d0, 0x110ff,
-}; /* CR_In_Sora_Sompeng */
-
-/* 'In_Chakma': Block */
-static const OnigCodePoint CR_In_Chakma[] = {
- 1,
- 0x11100, 0x1114f,
-}; /* CR_In_Chakma */
-
-/* 'In_Mahajani': Block */
-static const OnigCodePoint CR_In_Mahajani[] = {
- 1,
- 0x11150, 0x1117f,
-}; /* CR_In_Mahajani */
-
-/* 'In_Sharada': Block */
-#define CR_In_Sharada CR_Sharada
-
-/* 'In_Sinhala_Archaic_Numbers': Block */
-static const OnigCodePoint CR_In_Sinhala_Archaic_Numbers[] = {
- 1,
- 0x111e0, 0x111ff,
-}; /* CR_In_Sinhala_Archaic_Numbers */
-
-/* 'In_Khojki': Block */
-static const OnigCodePoint CR_In_Khojki[] = {
- 1,
- 0x11200, 0x1124f,
-}; /* CR_In_Khojki */
-
-/* 'In_Multani': Block */
-static const OnigCodePoint CR_In_Multani[] = {
- 1,
- 0x11280, 0x112af,
-}; /* CR_In_Multani */
-
-/* 'In_Khudawadi': Block */
-static const OnigCodePoint CR_In_Khudawadi[] = {
- 1,
- 0x112b0, 0x112ff,
-}; /* CR_In_Khudawadi */
-
-/* 'In_Grantha': Block */
-static const OnigCodePoint CR_In_Grantha[] = {
- 1,
- 0x11300, 0x1137f,
-}; /* CR_In_Grantha */
-
-/* 'In_Newa': Block */
-static const OnigCodePoint CR_In_Newa[] = {
- 1,
- 0x11400, 0x1147f,
-}; /* CR_In_Newa */
-
-/* 'In_Tirhuta': Block */
-static const OnigCodePoint CR_In_Tirhuta[] = {
- 1,
- 0x11480, 0x114df,
-}; /* CR_In_Tirhuta */
-
-/* 'In_Siddham': Block */
-static const OnigCodePoint CR_In_Siddham[] = {
- 1,
- 0x11580, 0x115ff,
-}; /* CR_In_Siddham */
-
-/* 'In_Modi': Block */
-static const OnigCodePoint CR_In_Modi[] = {
- 1,
- 0x11600, 0x1165f,
-}; /* CR_In_Modi */
-
-/* 'In_Mongolian_Supplement': Block */
-static const OnigCodePoint CR_In_Mongolian_Supplement[] = {
- 1,
- 0x11660, 0x1167f,
-}; /* CR_In_Mongolian_Supplement */
-
-/* 'In_Takri': Block */
-static const OnigCodePoint CR_In_Takri[] = {
- 1,
- 0x11680, 0x116cf,
-}; /* CR_In_Takri */
-
-/* 'In_Ahom': Block */
-static const OnigCodePoint CR_In_Ahom[] = {
- 1,
- 0x11700, 0x1174f,
-}; /* CR_In_Ahom */
-
-/* 'In_Dogra': Block */
-static const OnigCodePoint CR_In_Dogra[] = {
- 1,
- 0x11800, 0x1184f,
-}; /* CR_In_Dogra */
-
-/* 'In_Warang_Citi': Block */
-static const OnigCodePoint CR_In_Warang_Citi[] = {
- 1,
- 0x118a0, 0x118ff,
-}; /* CR_In_Warang_Citi */
-
-/* 'In_Dives_Akuru': Block */
-static const OnigCodePoint CR_In_Dives_Akuru[] = {
- 1,
- 0x11900, 0x1195f,
-}; /* CR_In_Dives_Akuru */
-
-/* 'In_Nandinagari': Block */
-static const OnigCodePoint CR_In_Nandinagari[] = {
- 1,
- 0x119a0, 0x119ff,
-}; /* CR_In_Nandinagari */
-
-/* 'In_Zanabazar_Square': Block */
-static const OnigCodePoint CR_In_Zanabazar_Square[] = {
- 1,
- 0x11a00, 0x11a4f,
-}; /* CR_In_Zanabazar_Square */
-
-/* 'In_Soyombo': Block */
-static const OnigCodePoint CR_In_Soyombo[] = {
- 1,
- 0x11a50, 0x11aaf,
-}; /* CR_In_Soyombo */
-
-/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended_A': Block */
-static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A[] = {
- 1,
- 0x11ab0, 0x11abf,
-}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A */
-
-/* 'In_Pau_Cin_Hau': Block */
-static const OnigCodePoint CR_In_Pau_Cin_Hau[] = {
- 1,
- 0x11ac0, 0x11aff,
-}; /* CR_In_Pau_Cin_Hau */
-
-/* 'In_Devanagari_Extended_A': Block */
-static const OnigCodePoint CR_In_Devanagari_Extended_A[] = {
- 1,
- 0x11b00, 0x11b5f,
-}; /* CR_In_Devanagari_Extended_A */
-
-/* 'In_Bhaiksuki': Block */
-static const OnigCodePoint CR_In_Bhaiksuki[] = {
- 1,
- 0x11c00, 0x11c6f,
-}; /* CR_In_Bhaiksuki */
-
-/* 'In_Marchen': Block */
-static const OnigCodePoint CR_In_Marchen[] = {
- 1,
- 0x11c70, 0x11cbf,
-}; /* CR_In_Marchen */
-
-/* 'In_Masaram_Gondi': Block */
-static const OnigCodePoint CR_In_Masaram_Gondi[] = {
- 1,
- 0x11d00, 0x11d5f,
-}; /* CR_In_Masaram_Gondi */
-
-/* 'In_Gunjala_Gondi': Block */
-static const OnigCodePoint CR_In_Gunjala_Gondi[] = {
- 1,
- 0x11d60, 0x11daf,
-}; /* CR_In_Gunjala_Gondi */
-
-/* 'In_Makasar': Block */
-static const OnigCodePoint CR_In_Makasar[] = {
- 1,
- 0x11ee0, 0x11eff,
-}; /* CR_In_Makasar */
-
-/* 'In_Kawi': Block */
-static const OnigCodePoint CR_In_Kawi[] = {
- 1,
- 0x11f00, 0x11f5f,
-}; /* CR_In_Kawi */
-
-/* 'In_Lisu_Supplement': Block */
-static const OnigCodePoint CR_In_Lisu_Supplement[] = {
- 1,
- 0x11fb0, 0x11fbf,
-}; /* CR_In_Lisu_Supplement */
-
-/* 'In_Tamil_Supplement': Block */
-static const OnigCodePoint CR_In_Tamil_Supplement[] = {
- 1,
- 0x11fc0, 0x11fff,
-}; /* CR_In_Tamil_Supplement */
-
-/* 'In_Cuneiform': Block */
-static const OnigCodePoint CR_In_Cuneiform[] = {
- 1,
- 0x12000, 0x123ff,
-}; /* CR_In_Cuneiform */
-
-/* 'In_Cuneiform_Numbers_and_Punctuation': Block */
-static const OnigCodePoint CR_In_Cuneiform_Numbers_and_Punctuation[] = {
- 1,
- 0x12400, 0x1247f,
-}; /* CR_In_Cuneiform_Numbers_and_Punctuation */
-
-/* 'In_Early_Dynastic_Cuneiform': Block */
-static const OnigCodePoint CR_In_Early_Dynastic_Cuneiform[] = {
- 1,
- 0x12480, 0x1254f,
-}; /* CR_In_Early_Dynastic_Cuneiform */
-
-/* 'In_Cypro_Minoan': Block */
-static const OnigCodePoint CR_In_Cypro_Minoan[] = {
- 1,
- 0x12f90, 0x12fff,
-}; /* CR_In_Cypro_Minoan */
-
-/* 'In_Egyptian_Hieroglyphs': Block */
-static const OnigCodePoint CR_In_Egyptian_Hieroglyphs[] = {
- 1,
- 0x13000, 0x1342f,
-}; /* CR_In_Egyptian_Hieroglyphs */
-
-/* 'In_Egyptian_Hieroglyph_Format_Controls': Block */
-static const OnigCodePoint CR_In_Egyptian_Hieroglyph_Format_Controls[] = {
- 1,
- 0x13430, 0x1345f,
-}; /* CR_In_Egyptian_Hieroglyph_Format_Controls */
-
-/* 'In_Anatolian_Hieroglyphs': Block */
-static const OnigCodePoint CR_In_Anatolian_Hieroglyphs[] = {
- 1,
- 0x14400, 0x1467f,
-}; /* CR_In_Anatolian_Hieroglyphs */
-
-/* 'In_Bamum_Supplement': Block */
-static const OnigCodePoint CR_In_Bamum_Supplement[] = {
- 1,
- 0x16800, 0x16a3f,
-}; /* CR_In_Bamum_Supplement */
-
-/* 'In_Mro': Block */
-static const OnigCodePoint CR_In_Mro[] = {
- 1,
- 0x16a40, 0x16a6f,
-}; /* CR_In_Mro */
-
-/* 'In_Tangsa': Block */
-static const OnigCodePoint CR_In_Tangsa[] = {
- 1,
- 0x16a70, 0x16acf,
-}; /* CR_In_Tangsa */
-
-/* 'In_Bassa_Vah': Block */
-static const OnigCodePoint CR_In_Bassa_Vah[] = {
- 1,
- 0x16ad0, 0x16aff,
-}; /* CR_In_Bassa_Vah */
-
-/* 'In_Pahawh_Hmong': Block */
-static const OnigCodePoint CR_In_Pahawh_Hmong[] = {
- 1,
- 0x16b00, 0x16b8f,
-}; /* CR_In_Pahawh_Hmong */
-
-/* 'In_Medefaidrin': Block */
-static const OnigCodePoint CR_In_Medefaidrin[] = {
- 1,
- 0x16e40, 0x16e9f,
-}; /* CR_In_Medefaidrin */
-
-/* 'In_Miao': Block */
-static const OnigCodePoint CR_In_Miao[] = {
- 1,
- 0x16f00, 0x16f9f,
-}; /* CR_In_Miao */
-
-/* 'In_Ideographic_Symbols_and_Punctuation': Block */
-static const OnigCodePoint CR_In_Ideographic_Symbols_and_Punctuation[] = {
- 1,
- 0x16fe0, 0x16fff,
-}; /* CR_In_Ideographic_Symbols_and_Punctuation */
-
-/* 'In_Tangut': Block */
-static const OnigCodePoint CR_In_Tangut[] = {
- 1,
- 0x17000, 0x187ff,
-}; /* CR_In_Tangut */
-
-/* 'In_Tangut_Components': Block */
-static const OnigCodePoint CR_In_Tangut_Components[] = {
- 1,
- 0x18800, 0x18aff,
-}; /* CR_In_Tangut_Components */
-
-/* 'In_Khitan_Small_Script': Block */
-static const OnigCodePoint CR_In_Khitan_Small_Script[] = {
- 1,
- 0x18b00, 0x18cff,
-}; /* CR_In_Khitan_Small_Script */
-
-/* 'In_Tangut_Supplement': Block */
-static const OnigCodePoint CR_In_Tangut_Supplement[] = {
- 1,
- 0x18d00, 0x18d7f,
-}; /* CR_In_Tangut_Supplement */
-
-/* 'In_Kana_Extended_B': Block */
-static const OnigCodePoint CR_In_Kana_Extended_B[] = {
- 1,
- 0x1aff0, 0x1afff,
-}; /* CR_In_Kana_Extended_B */
-
-/* 'In_Kana_Supplement': Block */
-static const OnigCodePoint CR_In_Kana_Supplement[] = {
- 1,
- 0x1b000, 0x1b0ff,
-}; /* CR_In_Kana_Supplement */
-
-/* 'In_Kana_Extended_A': Block */
-static const OnigCodePoint CR_In_Kana_Extended_A[] = {
- 1,
- 0x1b100, 0x1b12f,
-}; /* CR_In_Kana_Extended_A */
-
-/* 'In_Small_Kana_Extension': Block */
-static const OnigCodePoint CR_In_Small_Kana_Extension[] = {
- 1,
- 0x1b130, 0x1b16f,
-}; /* CR_In_Small_Kana_Extension */
-
-/* 'In_Nushu': Block */
-static const OnigCodePoint CR_In_Nushu[] = {
- 1,
- 0x1b170, 0x1b2ff,
-}; /* CR_In_Nushu */
-
-/* 'In_Duployan': Block */
-static const OnigCodePoint CR_In_Duployan[] = {
- 1,
- 0x1bc00, 0x1bc9f,
-}; /* CR_In_Duployan */
-
-/* 'In_Shorthand_Format_Controls': Block */
-static const OnigCodePoint CR_In_Shorthand_Format_Controls[] = {
- 1,
- 0x1bca0, 0x1bcaf,
-}; /* CR_In_Shorthand_Format_Controls */
-
-/* 'In_Znamenny_Musical_Notation': Block */
-static const OnigCodePoint CR_In_Znamenny_Musical_Notation[] = {
- 1,
- 0x1cf00, 0x1cfcf,
-}; /* CR_In_Znamenny_Musical_Notation */
-
-/* 'In_Byzantine_Musical_Symbols': Block */
-static const OnigCodePoint CR_In_Byzantine_Musical_Symbols[] = {
- 1,
- 0x1d000, 0x1d0ff,
-}; /* CR_In_Byzantine_Musical_Symbols */
-
-/* 'In_Musical_Symbols': Block */
-static const OnigCodePoint CR_In_Musical_Symbols[] = {
- 1,
- 0x1d100, 0x1d1ff,
-}; /* CR_In_Musical_Symbols */
-
-/* 'In_Ancient_Greek_Musical_Notation': Block */
-static const OnigCodePoint CR_In_Ancient_Greek_Musical_Notation[] = {
- 1,
- 0x1d200, 0x1d24f,
-}; /* CR_In_Ancient_Greek_Musical_Notation */
-
-/* 'In_Kaktovik_Numerals': Block */
-static const OnigCodePoint CR_In_Kaktovik_Numerals[] = {
- 1,
- 0x1d2c0, 0x1d2df,
-}; /* CR_In_Kaktovik_Numerals */
-
-/* 'In_Mayan_Numerals': Block */
-static const OnigCodePoint CR_In_Mayan_Numerals[] = {
- 1,
- 0x1d2e0, 0x1d2ff,
-}; /* CR_In_Mayan_Numerals */
-
-/* 'In_Tai_Xuan_Jing_Symbols': Block */
-static const OnigCodePoint CR_In_Tai_Xuan_Jing_Symbols[] = {
- 1,
- 0x1d300, 0x1d35f,
-}; /* CR_In_Tai_Xuan_Jing_Symbols */
-
-/* 'In_Counting_Rod_Numerals': Block */
-static const OnigCodePoint CR_In_Counting_Rod_Numerals[] = {
- 1,
- 0x1d360, 0x1d37f,
-}; /* CR_In_Counting_Rod_Numerals */
-
-/* 'In_Mathematical_Alphanumeric_Symbols': Block */
-static const OnigCodePoint CR_In_Mathematical_Alphanumeric_Symbols[] = {
- 1,
- 0x1d400, 0x1d7ff,
-}; /* CR_In_Mathematical_Alphanumeric_Symbols */
-
-/* 'In_Sutton_SignWriting': Block */
-static const OnigCodePoint CR_In_Sutton_SignWriting[] = {
- 1,
- 0x1d800, 0x1daaf,
-}; /* CR_In_Sutton_SignWriting */
-
-/* 'In_Latin_Extended_G': Block */
-static const OnigCodePoint CR_In_Latin_Extended_G[] = {
- 1,
- 0x1df00, 0x1dfff,
-}; /* CR_In_Latin_Extended_G */
-
-/* 'In_Glagolitic_Supplement': Block */
-static const OnigCodePoint CR_In_Glagolitic_Supplement[] = {
- 1,
- 0x1e000, 0x1e02f,
-}; /* CR_In_Glagolitic_Supplement */
-
-/* 'In_Cyrillic_Extended_D': Block */
-static const OnigCodePoint CR_In_Cyrillic_Extended_D[] = {
- 1,
- 0x1e030, 0x1e08f,
-}; /* CR_In_Cyrillic_Extended_D */
-
-/* 'In_Nyiakeng_Puachue_Hmong': Block */
-static const OnigCodePoint CR_In_Nyiakeng_Puachue_Hmong[] = {
- 1,
- 0x1e100, 0x1e14f,
-}; /* CR_In_Nyiakeng_Puachue_Hmong */
-
-/* 'In_Toto': Block */
-static const OnigCodePoint CR_In_Toto[] = {
- 1,
- 0x1e290, 0x1e2bf,
-}; /* CR_In_Toto */
-
-/* 'In_Wancho': Block */
-static const OnigCodePoint CR_In_Wancho[] = {
- 1,
- 0x1e2c0, 0x1e2ff,
-}; /* CR_In_Wancho */
-
-/* 'In_Nag_Mundari': Block */
-static const OnigCodePoint CR_In_Nag_Mundari[] = {
- 1,
- 0x1e4d0, 0x1e4ff,
-}; /* CR_In_Nag_Mundari */
-
-/* 'In_Ethiopic_Extended_B': Block */
-static const OnigCodePoint CR_In_Ethiopic_Extended_B[] = {
- 1,
- 0x1e7e0, 0x1e7ff,
-}; /* CR_In_Ethiopic_Extended_B */
-
-/* 'In_Mende_Kikakui': Block */
-static const OnigCodePoint CR_In_Mende_Kikakui[] = {
- 1,
- 0x1e800, 0x1e8df,
-}; /* CR_In_Mende_Kikakui */
-
-/* 'In_Adlam': Block */
-static const OnigCodePoint CR_In_Adlam[] = {
- 1,
- 0x1e900, 0x1e95f,
-}; /* CR_In_Adlam */
-
-/* 'In_Indic_Siyaq_Numbers': Block */
-static const OnigCodePoint CR_In_Indic_Siyaq_Numbers[] = {
- 1,
- 0x1ec70, 0x1ecbf,
-}; /* CR_In_Indic_Siyaq_Numbers */
-
-/* 'In_Ottoman_Siyaq_Numbers': Block */
-static const OnigCodePoint CR_In_Ottoman_Siyaq_Numbers[] = {
- 1,
- 0x1ed00, 0x1ed4f,
-}; /* CR_In_Ottoman_Siyaq_Numbers */
-
-/* 'In_Arabic_Mathematical_Alphabetic_Symbols': Block */
-static const OnigCodePoint CR_In_Arabic_Mathematical_Alphabetic_Symbols[] = {
- 1,
- 0x1ee00, 0x1eeff,
-}; /* CR_In_Arabic_Mathematical_Alphabetic_Symbols */
-
-/* 'In_Mahjong_Tiles': Block */
-static const OnigCodePoint CR_In_Mahjong_Tiles[] = {
- 1,
- 0x1f000, 0x1f02f,
-}; /* CR_In_Mahjong_Tiles */
-
-/* 'In_Domino_Tiles': Block */
-static const OnigCodePoint CR_In_Domino_Tiles[] = {
- 1,
- 0x1f030, 0x1f09f,
-}; /* CR_In_Domino_Tiles */
-
-/* 'In_Playing_Cards': Block */
-static const OnigCodePoint CR_In_Playing_Cards[] = {
- 1,
- 0x1f0a0, 0x1f0ff,
-}; /* CR_In_Playing_Cards */
-
-/* 'In_Enclosed_Alphanumeric_Supplement': Block */
-static const OnigCodePoint CR_In_Enclosed_Alphanumeric_Supplement[] = {
- 1,
- 0x1f100, 0x1f1ff,
-}; /* CR_In_Enclosed_Alphanumeric_Supplement */
-
-/* 'In_Enclosed_Ideographic_Supplement': Block */
-static const OnigCodePoint CR_In_Enclosed_Ideographic_Supplement[] = {
- 1,
- 0x1f200, 0x1f2ff,
-}; /* CR_In_Enclosed_Ideographic_Supplement */
-
-/* 'In_Miscellaneous_Symbols_and_Pictographs': Block */
-static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Pictographs[] = {
- 1,
- 0x1f300, 0x1f5ff,
-}; /* CR_In_Miscellaneous_Symbols_and_Pictographs */
-
-/* 'In_Emoticons': Block */
-static const OnigCodePoint CR_In_Emoticons[] = {
- 1,
- 0x1f600, 0x1f64f,
-}; /* CR_In_Emoticons */
-
-/* 'In_Ornamental_Dingbats': Block */
-static const OnigCodePoint CR_In_Ornamental_Dingbats[] = {
- 1,
- 0x1f650, 0x1f67f,
-}; /* CR_In_Ornamental_Dingbats */
-
-/* 'In_Transport_and_Map_Symbols': Block */
-static const OnigCodePoint CR_In_Transport_and_Map_Symbols[] = {
- 1,
- 0x1f680, 0x1f6ff,
-}; /* CR_In_Transport_and_Map_Symbols */
-
-/* 'In_Alchemical_Symbols': Block */
-static const OnigCodePoint CR_In_Alchemical_Symbols[] = {
- 1,
- 0x1f700, 0x1f77f,
-}; /* CR_In_Alchemical_Symbols */
-
-/* 'In_Geometric_Shapes_Extended': Block */
-static const OnigCodePoint CR_In_Geometric_Shapes_Extended[] = {
- 1,
- 0x1f780, 0x1f7ff,
-}; /* CR_In_Geometric_Shapes_Extended */
-
-/* 'In_Supplemental_Arrows_C': Block */
-static const OnigCodePoint CR_In_Supplemental_Arrows_C[] = {
- 1,
- 0x1f800, 0x1f8ff,
-}; /* CR_In_Supplemental_Arrows_C */
-
-/* 'In_Supplemental_Symbols_and_Pictographs': Block */
-static const OnigCodePoint CR_In_Supplemental_Symbols_and_Pictographs[] = {
- 1,
- 0x1f900, 0x1f9ff,
-}; /* CR_In_Supplemental_Symbols_and_Pictographs */
-
-/* 'In_Chess_Symbols': Block */
-static const OnigCodePoint CR_In_Chess_Symbols[] = {
- 1,
- 0x1fa00, 0x1fa6f,
-}; /* CR_In_Chess_Symbols */
-
-/* 'In_Symbols_and_Pictographs_Extended_A': Block */
-static const OnigCodePoint CR_In_Symbols_and_Pictographs_Extended_A[] = {
- 1,
- 0x1fa70, 0x1faff,
-}; /* CR_In_Symbols_and_Pictographs_Extended_A */
-
-/* 'In_Symbols_for_Legacy_Computing': Block */
-static const OnigCodePoint CR_In_Symbols_for_Legacy_Computing[] = {
- 1,
- 0x1fb00, 0x1fbff,
-}; /* CR_In_Symbols_for_Legacy_Computing */
-
-/* 'In_CJK_Unified_Ideographs_Extension_B': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_B[] = {
- 1,
- 0x20000, 0x2a6df,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_B */
-
-/* 'In_CJK_Unified_Ideographs_Extension_C': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_C[] = {
- 1,
- 0x2a700, 0x2b73f,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_C */
-
-/* 'In_CJK_Unified_Ideographs_Extension_D': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_D[] = {
- 1,
- 0x2b740, 0x2b81f,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_D */
-
-/* 'In_CJK_Unified_Ideographs_Extension_E': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_E[] = {
- 1,
- 0x2b820, 0x2ceaf,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_E */
-
-/* 'In_CJK_Unified_Ideographs_Extension_F': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_F[] = {
- 1,
- 0x2ceb0, 0x2ebef,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_F */
-
-/* 'In_CJK_Compatibility_Ideographs_Supplement': Block */
-static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs_Supplement[] = {
- 1,
- 0x2f800, 0x2fa1f,
-}; /* CR_In_CJK_Compatibility_Ideographs_Supplement */
-
-/* 'In_CJK_Unified_Ideographs_Extension_G': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_G[] = {
- 1,
- 0x30000, 0x3134f,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_G */
-
-/* 'In_CJK_Unified_Ideographs_Extension_H': Block */
-static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_H[] = {
- 1,
- 0x31350, 0x323af,
-}; /* CR_In_CJK_Unified_Ideographs_Extension_H */
-
-/* 'In_Tags': Block */
-static const OnigCodePoint CR_In_Tags[] = {
- 1,
- 0xe0000, 0xe007f,
-}; /* CR_In_Tags */
-
-/* 'In_Variation_Selectors_Supplement': Block */
-static const OnigCodePoint CR_In_Variation_Selectors_Supplement[] = {
- 1,
- 0xe0100, 0xe01ef,
-}; /* CR_In_Variation_Selectors_Supplement */
-
-/* 'In_Supplementary_Private_Use_Area_A': Block */
-static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_A[] = {
- 1,
- 0xf0000, 0xfffff,
-}; /* CR_In_Supplementary_Private_Use_Area_A */
-
-/* 'In_Supplementary_Private_Use_Area_B': Block */
-static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_B[] = {
- 1,
- 0x100000, 0x10ffff,
-}; /* CR_In_Supplementary_Private_Use_Area_B */
-
-/* 'In_No_Block': Block */
-static const OnigCodePoint CR_In_No_Block[] = {
- 51,
- 0x2fe0, 0x2fef,
- 0x10200, 0x1027f,
- 0x103e0, 0x103ff,
- 0x105c0, 0x105ff,
- 0x107c0, 0x107ff,
- 0x108b0, 0x108df,
- 0x10940, 0x1097f,
- 0x10aa0, 0x10abf,
- 0x10bb0, 0x10bff,
- 0x10c50, 0x10c7f,
- 0x10d40, 0x10e5f,
- 0x11250, 0x1127f,
- 0x11380, 0x113ff,
- 0x114e0, 0x1157f,
- 0x116d0, 0x116ff,
- 0x11750, 0x117ff,
- 0x11850, 0x1189f,
- 0x11960, 0x1199f,
- 0x11b60, 0x11bff,
- 0x11cc0, 0x11cff,
- 0x11db0, 0x11edf,
- 0x11f60, 0x11faf,
- 0x12550, 0x12f8f,
- 0x13460, 0x143ff,
- 0x14680, 0x167ff,
- 0x16b90, 0x16e3f,
- 0x16ea0, 0x16eff,
- 0x16fa0, 0x16fdf,
- 0x18d80, 0x1afef,
- 0x1b300, 0x1bbff,
- 0x1bcb0, 0x1ceff,
- 0x1cfd0, 0x1cfff,
- 0x1d250, 0x1d2bf,
- 0x1d380, 0x1d3ff,
- 0x1dab0, 0x1deff,
- 0x1e090, 0x1e0ff,
- 0x1e150, 0x1e28f,
- 0x1e300, 0x1e4cf,
- 0x1e500, 0x1e7df,
- 0x1e8e0, 0x1e8ff,
- 0x1e960, 0x1ec6f,
- 0x1ecc0, 0x1ecff,
- 0x1ed50, 0x1edff,
- 0x1ef00, 0x1efff,
- 0x1fc00, 0x1ffff,
- 0x2a6e0, 0x2a6ff,
- 0x2ebf0, 0x2f7ff,
- 0x2fa20, 0x2ffff,
- 0x323b0, 0xdffff,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xeffff,
-}; /* CR_In_No_Block */
-
-#endif /* USE_UNICODE_PROPERTIES */
-static const OnigCodePoint* const CodeRanges[] = {
- CR_NEWLINE,
- CR_Alpha,
- CR_Blank,
- CR_Cntrl,
- CR_Digit,
- CR_Graph,
- CR_Lower,
- CR_Print,
- CR_XPosixPunct,
- CR_Space,
- CR_Upper,
- CR_XDigit,
- CR_Word,
- CR_Alnum,
- CR_ASCII,
- CR_Punct,
-#ifdef USE_UNICODE_PROPERTIES
- CR_Any,
- CR_Assigned,
- CR_C,
- CR_Cc,
- CR_Cf,
- CR_Cn,
- CR_Co,
- CR_Cs,
- CR_L,
- CR_LC,
- CR_Ll,
- CR_Lm,
- CR_Lo,
- CR_Lt,
- CR_Lu,
- CR_M,
- CR_Mc,
- CR_Me,
- CR_Mn,
- CR_N,
- CR_Nd,
- CR_Nl,
- CR_No,
- CR_P,
- CR_Pc,
- CR_Pd,
- CR_Pe,
- CR_Pf,
- CR_Pi,
- CR_Po,
- CR_Ps,
- CR_S,
- CR_Sc,
- CR_Sk,
- CR_Sm,
- CR_So,
- CR_Z,
- CR_Zl,
- CR_Zp,
- CR_Zs,
- CR_Math,
- CR_Alphabetic,
- CR_Lowercase,
- CR_Uppercase,
- CR_Cased,
- CR_Case_Ignorable,
- CR_Changes_When_Lowercased,
- CR_Changes_When_Uppercased,
- CR_Changes_When_Titlecased,
- CR_Changes_When_Casefolded,
- CR_Changes_When_Casemapped,
- CR_ID_Start,
- CR_ID_Continue,
- CR_XID_Start,
- CR_XID_Continue,
- CR_Default_Ignorable_Code_Point,
- CR_Grapheme_Extend,
- CR_Grapheme_Base,
- CR_Grapheme_Link,
- CR_Common,
- CR_Latin,
- CR_Greek,
- CR_Cyrillic,
- CR_Armenian,
- CR_Hebrew,
- CR_Arabic,
- CR_Syriac,
- CR_Thaana,
- CR_Devanagari,
- CR_Bengali,
- CR_Gurmukhi,
- CR_Gujarati,
- CR_Oriya,
- CR_Tamil,
- CR_Telugu,
- CR_Kannada,
- CR_Malayalam,
- CR_Sinhala,
- CR_Thai,
- CR_Lao,
- CR_Tibetan,
- CR_Myanmar,
- CR_Georgian,
- CR_Hangul,
- CR_Ethiopic,
- CR_Cherokee,
- CR_Canadian_Aboriginal,
- CR_Ogham,
- CR_Runic,
- CR_Khmer,
- CR_Mongolian,
- CR_Hiragana,
- CR_Katakana,
- CR_Bopomofo,
- CR_Han,
- CR_Yi,
- CR_Old_Italic,
- CR_Gothic,
- CR_Deseret,
- CR_Inherited,
- CR_Tagalog,
- CR_Hanunoo,
- CR_Buhid,
- CR_Tagbanwa,
- CR_Limbu,
- CR_Tai_Le,
- CR_Linear_B,
- CR_Ugaritic,
- CR_Shavian,
- CR_Osmanya,
- CR_Cypriot,
- CR_Braille,
- CR_Buginese,
- CR_Coptic,
- CR_New_Tai_Lue,
- CR_Glagolitic,
- CR_Tifinagh,
- CR_Syloti_Nagri,
- CR_Old_Persian,
- CR_Kharoshthi,
- CR_Balinese,
- CR_Cuneiform,
- CR_Phoenician,
- CR_Phags_Pa,
- CR_Nko,
- CR_Sundanese,
- CR_Lepcha,
- CR_Ol_Chiki,
- CR_Vai,
- CR_Saurashtra,
- CR_Kayah_Li,
- CR_Rejang,
- CR_Lycian,
- CR_Carian,
- CR_Lydian,
- CR_Cham,
- CR_Tai_Tham,
- CR_Tai_Viet,
- CR_Avestan,
- CR_Egyptian_Hieroglyphs,
- CR_Samaritan,
- CR_Lisu,
- CR_Bamum,
- CR_Javanese,
- CR_Meetei_Mayek,
- CR_Imperial_Aramaic,
- CR_Old_South_Arabian,
- CR_Inscriptional_Parthian,
- CR_Inscriptional_Pahlavi,
- CR_Old_Turkic,
- CR_Kaithi,
- CR_Batak,
- CR_Brahmi,
- CR_Mandaic,
- CR_Chakma,
- CR_Meroitic_Cursive,
- CR_Meroitic_Hieroglyphs,
- CR_Miao,
- CR_Sharada,
- CR_Sora_Sompeng,
- CR_Takri,
- CR_Caucasian_Albanian,
- CR_Bassa_Vah,
- CR_Duployan,
- CR_Elbasan,
- CR_Grantha,
- CR_Pahawh_Hmong,
- CR_Khojki,
- CR_Linear_A,
- CR_Mahajani,
- CR_Manichaean,
- CR_Mende_Kikakui,
- CR_Modi,
- CR_Mro,
- CR_Old_North_Arabian,
- CR_Nabataean,
- CR_Palmyrene,
- CR_Pau_Cin_Hau,
- CR_Old_Permic,
- CR_Psalter_Pahlavi,
- CR_Siddham,
- CR_Khudawadi,
- CR_Tirhuta,
- CR_Warang_Citi,
- CR_Ahom,
- CR_Anatolian_Hieroglyphs,
- CR_Hatran,
- CR_Multani,
- CR_Old_Hungarian,
- CR_SignWriting,
- CR_Adlam,
- CR_Bhaiksuki,
- CR_Marchen,
- CR_Newa,
- CR_Osage,
- CR_Tangut,
- CR_Masaram_Gondi,
- CR_Nushu,
- CR_Soyombo,
- CR_Zanabazar_Square,
- CR_Dogra,
- CR_Gunjala_Gondi,
- CR_Makasar,
- CR_Medefaidrin,
- CR_Hanifi_Rohingya,
- CR_Sogdian,
- CR_Old_Sogdian,
- CR_Elymaic,
- CR_Nandinagari,
- CR_Nyiakeng_Puachue_Hmong,
- CR_Wancho,
- CR_Chorasmian,
- CR_Dives_Akuru,
- CR_Khitan_Small_Script,
- CR_Yezidi,
- CR_Cypro_Minoan,
- CR_Old_Uyghur,
- CR_Tangsa,
- CR_Toto,
- CR_Vithkuqi,
- CR_Kawi,
- CR_Nag_Mundari,
- CR_White_Space,
- CR_Bidi_Control,
- CR_Join_Control,
- CR_Dash,
- CR_Hyphen,
- CR_Quotation_Mark,
- CR_Terminal_Punctuation,
- CR_Other_Math,
- CR_Hex_Digit,
- CR_ASCII_Hex_Digit,
- CR_Other_Alphabetic,
- CR_Ideographic,
- CR_Diacritic,
- CR_Extender,
- CR_Other_Lowercase,
- CR_Other_Uppercase,
- CR_Noncharacter_Code_Point,
- CR_Other_Grapheme_Extend,
- CR_IDS_Binary_Operator,
- CR_IDS_Trinary_Operator,
- CR_Radical,
- CR_Unified_Ideograph,
- CR_Other_Default_Ignorable_Code_Point,
- CR_Deprecated,
- CR_Soft_Dotted,
- CR_Logical_Order_Exception,
- CR_Other_ID_Start,
- CR_Other_ID_Continue,
- CR_Sentence_Terminal,
- CR_Variation_Selector,
- CR_Pattern_White_Space,
- CR_Pattern_Syntax,
- CR_Prepended_Concatenation_Mark,
- CR_Regional_Indicator,
- CR_Emoji,
- CR_Emoji_Presentation,
- CR_Emoji_Modifier,
- CR_Emoji_Modifier_Base,
- CR_Emoji_Component,
- CR_Extended_Pictographic,
- CR_Unknown,
-#ifdef USE_UNICODE_AGE_PROPERTIES
- CR_Age_1_1,
- CR_Age_2_0,
- CR_Age_2_1,
- CR_Age_3_0,
- CR_Age_3_1,
- CR_Age_3_2,
- CR_Age_4_0,
- CR_Age_4_1,
- CR_Age_5_0,
- CR_Age_5_1,
- CR_Age_5_2,
- CR_Age_6_0,
- CR_Age_6_1,
- CR_Age_6_2,
- CR_Age_6_3,
- CR_Age_7_0,
- CR_Age_8_0,
- CR_Age_9_0,
- CR_Age_10_0,
- CR_Age_11_0,
- CR_Age_12_0,
- CR_Age_12_1,
- CR_Age_13_0,
- CR_Age_14_0,
- CR_Age_15_0,
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- CR_Grapheme_Cluster_Break_Prepend,
- CR_Grapheme_Cluster_Break_CR,
- CR_Grapheme_Cluster_Break_LF,
- CR_Grapheme_Cluster_Break_Control,
- CR_Grapheme_Cluster_Break_Extend,
- CR_Grapheme_Cluster_Break_Regional_Indicator,
- CR_Grapheme_Cluster_Break_SpacingMark,
- CR_Grapheme_Cluster_Break_L,
- CR_Grapheme_Cluster_Break_V,
- CR_Grapheme_Cluster_Break_T,
- CR_Grapheme_Cluster_Break_LV,
- CR_Grapheme_Cluster_Break_LVT,
- CR_Grapheme_Cluster_Break_ZWJ,
- CR_In_Basic_Latin,
- CR_In_Latin_1_Supplement,
- CR_In_Latin_Extended_A,
- CR_In_Latin_Extended_B,
- CR_In_IPA_Extensions,
- CR_In_Spacing_Modifier_Letters,
- CR_In_Combining_Diacritical_Marks,
- CR_In_Greek_and_Coptic,
- CR_In_Cyrillic,
- CR_In_Cyrillic_Supplement,
- CR_In_Armenian,
- CR_In_Hebrew,
- CR_In_Arabic,
- CR_In_Syriac,
- CR_In_Arabic_Supplement,
- CR_In_Thaana,
- CR_In_NKo,
- CR_In_Samaritan,
- CR_In_Mandaic,
- CR_In_Syriac_Supplement,
- CR_In_Arabic_Extended_B,
- CR_In_Arabic_Extended_A,
- CR_In_Devanagari,
- CR_In_Bengali,
- CR_In_Gurmukhi,
- CR_In_Gujarati,
- CR_In_Oriya,
- CR_In_Tamil,
- CR_In_Telugu,
- CR_In_Kannada,
- CR_In_Malayalam,
- CR_In_Sinhala,
- CR_In_Thai,
- CR_In_Lao,
- CR_In_Tibetan,
- CR_In_Myanmar,
- CR_In_Georgian,
- CR_In_Hangul_Jamo,
- CR_In_Ethiopic,
- CR_In_Ethiopic_Supplement,
- CR_In_Cherokee,
- CR_In_Unified_Canadian_Aboriginal_Syllabics,
- CR_In_Ogham,
- CR_In_Runic,
- CR_In_Tagalog,
- CR_In_Hanunoo,
- CR_In_Buhid,
- CR_In_Tagbanwa,
- CR_In_Khmer,
- CR_In_Mongolian,
- CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended,
- CR_In_Limbu,
- CR_In_Tai_Le,
- CR_In_New_Tai_Lue,
- CR_In_Khmer_Symbols,
- CR_In_Buginese,
- CR_In_Tai_Tham,
- CR_In_Combining_Diacritical_Marks_Extended,
- CR_In_Balinese,
- CR_In_Sundanese,
- CR_In_Batak,
- CR_In_Lepcha,
- CR_In_Ol_Chiki,
- CR_In_Cyrillic_Extended_C,
- CR_In_Georgian_Extended,
- CR_In_Sundanese_Supplement,
- CR_In_Vedic_Extensions,
- CR_In_Phonetic_Extensions,
- CR_In_Phonetic_Extensions_Supplement,
- CR_In_Combining_Diacritical_Marks_Supplement,
- CR_In_Latin_Extended_Additional,
- CR_In_Greek_Extended,
- CR_In_General_Punctuation,
- CR_In_Superscripts_and_Subscripts,
- CR_In_Currency_Symbols,
- CR_In_Combining_Diacritical_Marks_for_Symbols,
- CR_In_Letterlike_Symbols,
- CR_In_Number_Forms,
- CR_In_Arrows,
- CR_In_Mathematical_Operators,
- CR_In_Miscellaneous_Technical,
- CR_In_Control_Pictures,
- CR_In_Optical_Character_Recognition,
- CR_In_Enclosed_Alphanumerics,
- CR_In_Box_Drawing,
- CR_In_Block_Elements,
- CR_In_Geometric_Shapes,
- CR_In_Miscellaneous_Symbols,
- CR_In_Dingbats,
- CR_In_Miscellaneous_Mathematical_Symbols_A,
- CR_In_Supplemental_Arrows_A,
- CR_In_Braille_Patterns,
- CR_In_Supplemental_Arrows_B,
- CR_In_Miscellaneous_Mathematical_Symbols_B,
- CR_In_Supplemental_Mathematical_Operators,
- CR_In_Miscellaneous_Symbols_and_Arrows,
- CR_In_Glagolitic,
- CR_In_Latin_Extended_C,
- CR_In_Coptic,
- CR_In_Georgian_Supplement,
- CR_In_Tifinagh,
- CR_In_Ethiopic_Extended,
- CR_In_Cyrillic_Extended_A,
- CR_In_Supplemental_Punctuation,
- CR_In_CJK_Radicals_Supplement,
- CR_In_Kangxi_Radicals,
- CR_In_Ideographic_Description_Characters,
- CR_In_CJK_Symbols_and_Punctuation,
- CR_In_Hiragana,
- CR_In_Katakana,
- CR_In_Bopomofo,
- CR_In_Hangul_Compatibility_Jamo,
- CR_In_Kanbun,
- CR_In_Bopomofo_Extended,
- CR_In_CJK_Strokes,
- CR_In_Katakana_Phonetic_Extensions,
- CR_In_Enclosed_CJK_Letters_and_Months,
- CR_In_CJK_Compatibility,
- CR_In_CJK_Unified_Ideographs_Extension_A,
- CR_In_Yijing_Hexagram_Symbols,
- CR_In_CJK_Unified_Ideographs,
- CR_In_Yi_Syllables,
- CR_In_Yi_Radicals,
- CR_In_Lisu,
- CR_In_Vai,
- CR_In_Cyrillic_Extended_B,
- CR_In_Bamum,
- CR_In_Modifier_Tone_Letters,
- CR_In_Latin_Extended_D,
- CR_In_Syloti_Nagri,
- CR_In_Common_Indic_Number_Forms,
- CR_In_Phags_pa,
- CR_In_Saurashtra,
- CR_In_Devanagari_Extended,
- CR_In_Kayah_Li,
- CR_In_Rejang,
- CR_In_Hangul_Jamo_Extended_A,
- CR_In_Javanese,
- CR_In_Myanmar_Extended_B,
- CR_In_Cham,
- CR_In_Myanmar_Extended_A,
- CR_In_Tai_Viet,
- CR_In_Meetei_Mayek_Extensions,
- CR_In_Ethiopic_Extended_A,
- CR_In_Latin_Extended_E,
- CR_In_Cherokee_Supplement,
- CR_In_Meetei_Mayek,
- CR_In_Hangul_Syllables,
- CR_In_Hangul_Jamo_Extended_B,
- CR_In_High_Surrogates,
- CR_In_High_Private_Use_Surrogates,
- CR_In_Low_Surrogates,
- CR_In_Private_Use_Area,
- CR_In_CJK_Compatibility_Ideographs,
- CR_In_Alphabetic_Presentation_Forms,
- CR_In_Arabic_Presentation_Forms_A,
- CR_In_Variation_Selectors,
- CR_In_Vertical_Forms,
- CR_In_Combining_Half_Marks,
- CR_In_CJK_Compatibility_Forms,
- CR_In_Small_Form_Variants,
- CR_In_Arabic_Presentation_Forms_B,
- CR_In_Halfwidth_and_Fullwidth_Forms,
- CR_In_Specials,
- CR_In_Linear_B_Syllabary,
- CR_In_Linear_B_Ideograms,
- CR_In_Aegean_Numbers,
- CR_In_Ancient_Greek_Numbers,
- CR_In_Ancient_Symbols,
- CR_In_Phaistos_Disc,
- CR_In_Lycian,
- CR_In_Carian,
- CR_In_Coptic_Epact_Numbers,
- CR_In_Old_Italic,
- CR_In_Gothic,
- CR_In_Old_Permic,
- CR_In_Ugaritic,
- CR_In_Old_Persian,
- CR_In_Deseret,
- CR_In_Shavian,
- CR_In_Osmanya,
- CR_In_Osage,
- CR_In_Elbasan,
- CR_In_Caucasian_Albanian,
- CR_In_Vithkuqi,
- CR_In_Linear_A,
- CR_In_Latin_Extended_F,
- CR_In_Cypriot_Syllabary,
- CR_In_Imperial_Aramaic,
- CR_In_Palmyrene,
- CR_In_Nabataean,
- CR_In_Hatran,
- CR_In_Phoenician,
- CR_In_Lydian,
- CR_In_Meroitic_Hieroglyphs,
- CR_In_Meroitic_Cursive,
- CR_In_Kharoshthi,
- CR_In_Old_South_Arabian,
- CR_In_Old_North_Arabian,
- CR_In_Manichaean,
- CR_In_Avestan,
- CR_In_Inscriptional_Parthian,
- CR_In_Inscriptional_Pahlavi,
- CR_In_Psalter_Pahlavi,
- CR_In_Old_Turkic,
- CR_In_Old_Hungarian,
- CR_In_Hanifi_Rohingya,
- CR_In_Rumi_Numeral_Symbols,
- CR_In_Yezidi,
- CR_In_Arabic_Extended_C,
- CR_In_Old_Sogdian,
- CR_In_Sogdian,
- CR_In_Old_Uyghur,
- CR_In_Chorasmian,
- CR_In_Elymaic,
- CR_In_Brahmi,
- CR_In_Kaithi,
- CR_In_Sora_Sompeng,
- CR_In_Chakma,
- CR_In_Mahajani,
- CR_In_Sharada,
- CR_In_Sinhala_Archaic_Numbers,
- CR_In_Khojki,
- CR_In_Multani,
- CR_In_Khudawadi,
- CR_In_Grantha,
- CR_In_Newa,
- CR_In_Tirhuta,
- CR_In_Siddham,
- CR_In_Modi,
- CR_In_Mongolian_Supplement,
- CR_In_Takri,
- CR_In_Ahom,
- CR_In_Dogra,
- CR_In_Warang_Citi,
- CR_In_Dives_Akuru,
- CR_In_Nandinagari,
- CR_In_Zanabazar_Square,
- CR_In_Soyombo,
- CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A,
- CR_In_Pau_Cin_Hau,
- CR_In_Devanagari_Extended_A,
- CR_In_Bhaiksuki,
- CR_In_Marchen,
- CR_In_Masaram_Gondi,
- CR_In_Gunjala_Gondi,
- CR_In_Makasar,
- CR_In_Kawi,
- CR_In_Lisu_Supplement,
- CR_In_Tamil_Supplement,
- CR_In_Cuneiform,
- CR_In_Cuneiform_Numbers_and_Punctuation,
- CR_In_Early_Dynastic_Cuneiform,
- CR_In_Cypro_Minoan,
- CR_In_Egyptian_Hieroglyphs,
- CR_In_Egyptian_Hieroglyph_Format_Controls,
- CR_In_Anatolian_Hieroglyphs,
- CR_In_Bamum_Supplement,
- CR_In_Mro,
- CR_In_Tangsa,
- CR_In_Bassa_Vah,
- CR_In_Pahawh_Hmong,
- CR_In_Medefaidrin,
- CR_In_Miao,
- CR_In_Ideographic_Symbols_and_Punctuation,
- CR_In_Tangut,
- CR_In_Tangut_Components,
- CR_In_Khitan_Small_Script,
- CR_In_Tangut_Supplement,
- CR_In_Kana_Extended_B,
- CR_In_Kana_Supplement,
- CR_In_Kana_Extended_A,
- CR_In_Small_Kana_Extension,
- CR_In_Nushu,
- CR_In_Duployan,
- CR_In_Shorthand_Format_Controls,
- CR_In_Znamenny_Musical_Notation,
- CR_In_Byzantine_Musical_Symbols,
- CR_In_Musical_Symbols,
- CR_In_Ancient_Greek_Musical_Notation,
- CR_In_Kaktovik_Numerals,
- CR_In_Mayan_Numerals,
- CR_In_Tai_Xuan_Jing_Symbols,
- CR_In_Counting_Rod_Numerals,
- CR_In_Mathematical_Alphanumeric_Symbols,
- CR_In_Sutton_SignWriting,
- CR_In_Latin_Extended_G,
- CR_In_Glagolitic_Supplement,
- CR_In_Cyrillic_Extended_D,
- CR_In_Nyiakeng_Puachue_Hmong,
- CR_In_Toto,
- CR_In_Wancho,
- CR_In_Nag_Mundari,
- CR_In_Ethiopic_Extended_B,
- CR_In_Mende_Kikakui,
- CR_In_Adlam,
- CR_In_Indic_Siyaq_Numbers,
- CR_In_Ottoman_Siyaq_Numbers,
- CR_In_Arabic_Mathematical_Alphabetic_Symbols,
- CR_In_Mahjong_Tiles,
- CR_In_Domino_Tiles,
- CR_In_Playing_Cards,
- CR_In_Enclosed_Alphanumeric_Supplement,
- CR_In_Enclosed_Ideographic_Supplement,
- CR_In_Miscellaneous_Symbols_and_Pictographs,
- CR_In_Emoticons,
- CR_In_Ornamental_Dingbats,
- CR_In_Transport_and_Map_Symbols,
- CR_In_Alchemical_Symbols,
- CR_In_Geometric_Shapes_Extended,
- CR_In_Supplemental_Arrows_C,
- CR_In_Supplemental_Symbols_and_Pictographs,
- CR_In_Chess_Symbols,
- CR_In_Symbols_and_Pictographs_Extended_A,
- CR_In_Symbols_for_Legacy_Computing,
- CR_In_CJK_Unified_Ideographs_Extension_B,
- CR_In_CJK_Unified_Ideographs_Extension_C,
- CR_In_CJK_Unified_Ideographs_Extension_D,
- CR_In_CJK_Unified_Ideographs_Extension_E,
- CR_In_CJK_Unified_Ideographs_Extension_F,
- CR_In_CJK_Compatibility_Ideographs_Supplement,
- CR_In_CJK_Unified_Ideographs_Extension_G,
- CR_In_CJK_Unified_Ideographs_Extension_H,
- CR_In_Tags,
- CR_In_Variation_Selectors_Supplement,
- CR_In_Supplementary_Private_Use_Area_A,
- CR_In_Supplementary_Private_Use_Area_B,
- CR_In_No_Block,
-#endif /* USE_UNICODE_PROPERTIES */
-};
-struct uniname2ctype_struct {
- short name;
- unsigned short ctype;
-};
-#define uniname2ctype_offset(str) offsetof(struct uniname2ctype_pool_t, uniname2ctype_pool_##str)
-
-static const struct uniname2ctype_struct *uniname2ctype_p(register const char *str, register size_t len);
-
-#ifndef USE_UNICODE_PROPERTIES
-#define TOTAL_KEYWORDS 15
-#define MIN_WORD_LENGTH 4
-#define MAX_WORD_LENGTH 11
-#define MIN_HASH_VALUE 6
-#define MAX_HASH_VALUE 20
-/* maximum key range = 15, duplicates = 0 */
-#else /* USE_UNICODE_PROPERTIES */
-#ifndef USE_UNICODE_AGE_PROPERTIES
-#define TOTAL_KEYWORDS 866
-#else /* USE_UNICODE_AGE_PROPERTIES */
-#define TOTAL_KEYWORDS 891
-#endif /* USE_UNICODE_AGE_PROPERTIES */
-#define MIN_WORD_LENGTH 1
-#define MAX_WORD_LENGTH 45
-#define MIN_HASH_VALUE 11
-#define MAX_HASH_VALUE 6098
-/* maximum key range = 6088, duplicates = 0 */
-#endif /* USE_UNICODE_PROPERTIES */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-uniname2ctype_hash (register const char *str, register size_t len)
-{
-#ifndef USE_UNICODE_PROPERTIES
- static const unsigned char asso_values[] =
-#else /* USE_UNICODE_PROPERTIES */
- static const unsigned short asso_values[] =
-#endif /* USE_UNICODE_PROPERTIES */
- {
-#ifndef USE_UNICODE_PROPERTIES
- 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,
- 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,
- 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,
- 21, 21, 21, 21, 21, 21, 21, 3, 12, 5,
- 4, 21, 21, 10, 21, 1, 21, 21, 11, 21,
- 2, 1, 1, 21, 1, 7, 4, 6, 21, 1,
- 4, 21, 21, 21, 21, 21, 21, 21
-#else /* USE_UNICODE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
-#ifndef USE_UNICODE_AGE_PROPERTIES
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
-#else /* USE_UNICODE_AGE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 12, 6099, 3, 1,
- 4, 8, 32, 26, 14, 17, 10, 7, 6099, 6099,
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099, 6099,
- 6099, 6099, 6099, 6099, 6099, 6099, 6099, 1, 1425, 113,
- 437, 37, 1086, 1071, 1051, 4, 1984, 9, 500, 88,
- 8, 18, 1371, 1287, 54, 203, 310, 619, 1958, 603,
- 275, 1624, 44, 1, 22, 6099, 6099, 6099, 6099, 6099
-#endif /* USE_UNICODE_PROPERTIES */
- };
-#ifndef USE_UNICODE_PROPERTIES
- return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];
-#else /* USE_UNICODE_PROPERTIES */
- register unsigned int hval = (unsigned int)len;
-
- switch (hval)
- {
- default:
- hval += asso_values[(unsigned char)str[15]];
- /*FALLTHROUGH*/
- case 15:
- case 14:
- case 13:
- case 12:
- hval += asso_values[(unsigned char)str[11]];
- /*FALLTHROUGH*/
- case 11:
- case 10:
- case 9:
- case 8:
- case 7:
- case 6:
- hval += asso_values[(unsigned char)str[5]];
- /*FALLTHROUGH*/
- case 5:
- hval += asso_values[(unsigned char)str[4]];
- /*FALLTHROUGH*/
- case 4:
- case 3:
- hval += asso_values[(unsigned char)str[2]];
- /*FALLTHROUGH*/
- case 2:
- hval += asso_values[(unsigned char)str[1]];
- /*FALLTHROUGH*/
- case 1:
- hval += asso_values[(unsigned char)str[0]+2];
- break;
- }
- return hval + asso_values[(unsigned char)str[len - 1]];
-#endif /* USE_UNICODE_PROPERTIES */
-}
-
-struct uniname2ctype_pool_t
- {
-#ifndef USE_UNICODE_PROPERTIES
- char uniname2ctype_pool_str6[sizeof("word")];
- char uniname2ctype_pool_str7[sizeof("print")];
- char uniname2ctype_pool_str8[sizeof("punct")];
- char uniname2ctype_pool_str9[sizeof("alpha")];
- char uniname2ctype_pool_str10[sizeof("alnum")];
- char uniname2ctype_pool_str11[sizeof("xdigit")];
- char uniname2ctype_pool_str12[sizeof("upper")];
- char uniname2ctype_pool_str13[sizeof("ascii")];
- char uniname2ctype_pool_str14[sizeof("cntrl")];
- char uniname2ctype_pool_str15[sizeof("space")];
- char uniname2ctype_pool_str16[sizeof("xposixpunct")];
- char uniname2ctype_pool_str17[sizeof("lower")];
- char uniname2ctype_pool_str18[sizeof("graph")];
- char uniname2ctype_pool_str19[sizeof("digit")];
- char uniname2ctype_pool_str20[sizeof("blank")];
-#else /* USE_UNICODE_PROPERTIES */
- char uniname2ctype_pool_str11[sizeof("yi")];
- char uniname2ctype_pool_str17[sizeof("yiii")];
- char uniname2ctype_pool_str22[sizeof("lana")];
- char uniname2ctype_pool_str25[sizeof("lina")];
- char uniname2ctype_pool_str33[sizeof("maka")];
- char uniname2ctype_pool_str35[sizeof("mani")];
- char uniname2ctype_pool_str36[sizeof("mn")];
- char uniname2ctype_pool_str45[sizeof("miao")];
- char uniname2ctype_pool_str46[sizeof("lo")];
- char uniname2ctype_pool_str47[sizeof("ci")];
- char uniname2ctype_pool_str48[sizeof("lao")];
- char uniname2ctype_pool_str49[sizeof("laoo")];
- char uniname2ctype_pool_str52[sizeof("inkannada")];
- char uniname2ctype_pool_str55[sizeof("cn")];
- char uniname2ctype_pool_str64[sizeof("pi")];
- char uniname2ctype_pool_str66[sizeof("innko")];
- char uniname2ctype_pool_str67[sizeof("z")];
- char uniname2ctype_pool_str71[sizeof("gran")];
- char uniname2ctype_pool_str75[sizeof("co")];
- char uniname2ctype_pool_str83[sizeof("lineara")];
- char uniname2ctype_pool_str86[sizeof("mark")];
- char uniname2ctype_pool_str90[sizeof("yezi")];
- char uniname2ctype_pool_str92[sizeof("po")];
- char uniname2ctype_pool_str94[sizeof("me")];
- char uniname2ctype_pool_str100[sizeof("cari")];
- char uniname2ctype_pool_str101[sizeof("inkharoshthi")];
- char uniname2ctype_pool_str102[sizeof("kana")];
- char uniname2ctype_pool_str103[sizeof("loe")];
- char uniname2ctype_pool_str107[sizeof("m")];
- char uniname2ctype_pool_str108[sizeof("grek")];
- char uniname2ctype_pool_str111[sizeof("mro")];
- char uniname2ctype_pool_str112[sizeof("mroo")];
- char uniname2ctype_pool_str115[sizeof("carian")];
- char uniname2ctype_pool_str117[sizeof("geor")];
- char uniname2ctype_pool_str118[sizeof("greek")];
- char uniname2ctype_pool_str122[sizeof("gonm")];
- char uniname2ctype_pool_str129[sizeof("mendekikakui")];
- char uniname2ctype_pool_str130[sizeof("pe")];
- char uniname2ctype_pool_str131[sizeof("mero")];
- char uniname2ctype_pool_str134[sizeof("inosmanya")];
- char uniname2ctype_pool_str139[sizeof("cakm")];
- char uniname2ctype_pool_str145[sizeof("inmanichaean")];
- char uniname2ctype_pool_str146[sizeof("inmro")];
- char uniname2ctype_pool_str148[sizeof("inmiao")];
- char uniname2ctype_pool_str149[sizeof("inchakma")];
- char uniname2ctype_pool_str151[sizeof("c")];
- char uniname2ctype_pool_str152[sizeof("mandaic")];
- char uniname2ctype_pool_str153[sizeof("meeteimayek")];
- char uniname2ctype_pool_str158[sizeof("zzzz")];
- char uniname2ctype_pool_str161[sizeof("inarmenian")];
- char uniname2ctype_pool_str177[sizeof("inmyanmar")];
- char uniname2ctype_pool_str178[sizeof("inmakasar")];
- char uniname2ctype_pool_str183[sizeof("common")];
- char uniname2ctype_pool_str186[sizeof("lm")];
- char uniname2ctype_pool_str190[sizeof("marc")];
- char uniname2ctype_pool_str203[sizeof("inrunic")];
- char uniname2ctype_pool_str204[sizeof("incarian")];
- char uniname2ctype_pool_str210[sizeof("inideographicsymbolsandpunctuation")];
- char uniname2ctype_pool_str212[sizeof("inkhmer")];
- char uniname2ctype_pool_str213[sizeof("qaai")];
- char uniname2ctype_pool_str218[sizeof("inahom")];
- char uniname2ctype_pool_str226[sizeof("merc")];
- char uniname2ctype_pool_str230[sizeof("inchorasmian")];
- char uniname2ctype_pool_str231[sizeof("combiningmark")];
- char uniname2ctype_pool_str236[sizeof("lc")];
- char uniname2ctype_pool_str237[sizeof("perm")];
- char uniname2ctype_pool_str246[sizeof("mc")];
- char uniname2ctype_pool_str250[sizeof("connectorpunctuation")];
- char uniname2ctype_pool_str253[sizeof("cans")];
- char uniname2ctype_pool_str260[sizeof("incuneiformnumbersandpunctuation")];
- char uniname2ctype_pool_str263[sizeof("armi")];
- char uniname2ctype_pool_str265[sizeof("cc")];
- char uniname2ctype_pool_str267[sizeof("armn")];
- char uniname2ctype_pool_str268[sizeof("incherokee")];
- char uniname2ctype_pool_str270[sizeof("prependedconcatenationmark")];
- char uniname2ctype_pool_str274[sizeof("incuneiform")];
- char uniname2ctype_pool_str275[sizeof("inavestan")];
- char uniname2ctype_pool_str281[sizeof("inipaextensions")];
- char uniname2ctype_pool_str282[sizeof("pc")];
- char uniname2ctype_pool_str283[sizeof("armenian")];
- char uniname2ctype_pool_str285[sizeof("insharada")];
- char uniname2ctype_pool_str287[sizeof("vai")];
- char uniname2ctype_pool_str288[sizeof("vaii")];
- char uniname2ctype_pool_str289[sizeof("inmarchen")];
- char uniname2ctype_pool_str293[sizeof("makasar")];
- char uniname2ctype_pool_str297[sizeof("masaramgondi")];
- char uniname2ctype_pool_str301[sizeof("inarrows")];
- char uniname2ctype_pool_str311[sizeof("incyrillic")];
- char uniname2ctype_pool_str313[sizeof("incham")];
- char uniname2ctype_pool_str315[sizeof("qmark")];
- char uniname2ctype_pool_str320[sizeof("ri")];
- char uniname2ctype_pool_str322[sizeof("qaac")];
- char uniname2ctype_pool_str328[sizeof("insamaritan")];
- char uniname2ctype_pool_str331[sizeof("latn")];
- char uniname2ctype_pool_str335[sizeof("inmasaramgondi")];
- char uniname2ctype_pool_str338[sizeof("inthaana")];
- char uniname2ctype_pool_str340[sizeof("latin")];
- char uniname2ctype_pool_str342[sizeof("inthai")];
- char uniname2ctype_pool_str345[sizeof("lineseparator")];
- char uniname2ctype_pool_str346[sizeof("pcm")];
- char uniname2ctype_pool_str348[sizeof("inkatakana")];
- char uniname2ctype_pool_str352[sizeof("inkaithi")];
- char uniname2ctype_pool_str362[sizeof("inscriptionalparthian")];
- char uniname2ctype_pool_str366[sizeof("initialpunctuation")];
- char uniname2ctype_pool_str373[sizeof("mtei")];
- char uniname2ctype_pool_str381[sizeof("inzanabazarsquare")];
- char uniname2ctype_pool_str386[sizeof("inkhmersymbols")];
- char uniname2ctype_pool_str399[sizeof("insyriac")];
- char uniname2ctype_pool_str401[sizeof("intakri")];
- char uniname2ctype_pool_str404[sizeof("arabic")];
- char uniname2ctype_pool_str418[sizeof("katakana")];
- char uniname2ctype_pool_str426[sizeof("prti")];
- char uniname2ctype_pool_str430[sizeof("zs")];
- char uniname2ctype_pool_str442[sizeof("ascii")];
- char uniname2ctype_pool_str445[sizeof("cs")];
- char uniname2ctype_pool_str462[sizeof("ps")];
- char uniname2ctype_pool_str468[sizeof("mand")];
- char uniname2ctype_pool_str470[sizeof("privateuse")];
- char uniname2ctype_pool_str475[sizeof("inruminumeralsymbols")];
- char uniname2ctype_pool_str480[sizeof("inmyanmarextendeda")];
- char uniname2ctype_pool_str481[sizeof("modi")];
- char uniname2ctype_pool_str486[sizeof("incjkcompatibilityforms")];
- char uniname2ctype_pool_str488[sizeof("inkanaextendeda")];
- char uniname2ctype_pool_str491[sizeof("incjkcompatibilityideographs")];
- char uniname2ctype_pool_str500[sizeof("brai")];
- char uniname2ctype_pool_str504[sizeof("mend")];
- char uniname2ctype_pool_str505[sizeof("ideo")];
- char uniname2ctype_pool_str506[sizeof("letter")];
- char uniname2ctype_pool_str509[sizeof("l")];
- char uniname2ctype_pool_str511[sizeof("inmeeteimayek")];
- char uniname2ctype_pool_str520[sizeof("inideographicdescriptioncharacters")];
- char uniname2ctype_pool_str533[sizeof("yezidi")];
- char uniname2ctype_pool_str538[sizeof("knda")];
- char uniname2ctype_pool_str541[sizeof("innandinagari")];
- char uniname2ctype_pool_str543[sizeof("kannada")];
- char uniname2ctype_pool_str556[sizeof("inmodi")];
- char uniname2ctype_pool_str558[sizeof("inlao")];
- char uniname2ctype_pool_str559[sizeof("xidcontinue")];
- char uniname2ctype_pool_str560[sizeof("inoldnortharabian")];
- char uniname2ctype_pool_str565[sizeof("intransportandmapsymbols")];
- char uniname2ctype_pool_str566[sizeof("letternumber")];
- char uniname2ctype_pool_str568[sizeof("gothic")];
- char uniname2ctype_pool_str572[sizeof("inlineara")];
- char uniname2ctype_pool_str577[sizeof("inmendekikakui")];
- char uniname2ctype_pool_str579[sizeof("mongolian")];
- char uniname2ctype_pool_str582[sizeof("inmiscellaneousmathematicalsymbolsa")];
- char uniname2ctype_pool_str583[sizeof("inspecials")];
- char uniname2ctype_pool_str590[sizeof("grlink")];
- char uniname2ctype_pool_str594[sizeof("brahmi")];
- char uniname2ctype_pool_str596[sizeof("inemoticons")];
- char uniname2ctype_pool_str597[sizeof("kali")];
- char uniname2ctype_pool_str600[sizeof("inolditalic")];
- char uniname2ctype_pool_str602[sizeof("xidc")];
- char uniname2ctype_pool_str604[sizeof("inmedefaidrin")];
- char uniname2ctype_pool_str605[sizeof("inchesssymbols")];
- char uniname2ctype_pool_str608[sizeof("incjkcompatibilityideographssupplement")];
- char uniname2ctype_pool_str609[sizeof("kits")];
- char uniname2ctype_pool_str614[sizeof("inadlam")];
- char uniname2ctype_pool_str624[sizeof("psalterpahlavi")];
- char uniname2ctype_pool_str625[sizeof("incommonindicnumberforms")];
- char uniname2ctype_pool_str630[sizeof("lt")];
- char uniname2ctype_pool_str636[sizeof("innewa")];
- char uniname2ctype_pool_str639[sizeof("sk")];
- char uniname2ctype_pool_str642[sizeof("control")];
- char uniname2ctype_pool_str643[sizeof("inkawi")];
- char uniname2ctype_pool_str645[sizeof("inancientsymbols")];
- char uniname2ctype_pool_str647[sizeof("palm")];
- char uniname2ctype_pool_str650[sizeof("inlycian")];
- char uniname2ctype_pool_str657[sizeof("so")];
- char uniname2ctype_pool_str660[sizeof("patternwhitespace")];
- char uniname2ctype_pool_str672[sizeof("inmandaic")];
- char uniname2ctype_pool_str675[sizeof("idc")];
- char uniname2ctype_pool_str678[sizeof("meroiticcursive")];
- char uniname2ctype_pool_str679[sizeof("intoto")];
- char uniname2ctype_pool_str683[sizeof("vs")];
- char uniname2ctype_pool_str692[sizeof("xids")];
- char uniname2ctype_pool_str695[sizeof("inwarangciti")];
- char uniname2ctype_pool_str696[sizeof("sora")];
- char uniname2ctype_pool_str697[sizeof("inopticalcharacterrecognition")];
- char uniname2ctype_pool_str700[sizeof("kawi")];
- char uniname2ctype_pool_str703[sizeof("inoldsogdian")];
- char uniname2ctype_pool_str705[sizeof("inmalayalam")];
- char uniname2ctype_pool_str707[sizeof("bamum")];
- char uniname2ctype_pool_str708[sizeof("inkanasupplement")];
- char uniname2ctype_pool_str713[sizeof("insundanese")];
- char uniname2ctype_pool_str720[sizeof("grext")];
- char uniname2ctype_pool_str737[sizeof("print")];
- char uniname2ctype_pool_str738[sizeof("intaitham")];
- char uniname2ctype_pool_str742[sizeof("lower")];
- char uniname2ctype_pool_str745[sizeof("patternsyntax")];
- char uniname2ctype_pool_str753[sizeof("joinc")];
- char uniname2ctype_pool_str755[sizeof("inoldsoutharabian")];
- char uniname2ctype_pool_str760[sizeof("incjkstrokes")];
- char uniname2ctype_pool_str761[sizeof("batk")];
- char uniname2ctype_pool_str766[sizeof("samr")];
- char uniname2ctype_pool_str767[sizeof("inwancho")];
- char uniname2ctype_pool_str771[sizeof("batak")];
- char uniname2ctype_pool_str776[sizeof("patws")];
- char uniname2ctype_pool_str783[sizeof("samaritan")];
- char uniname2ctype_pool_str787[sizeof("idsbinaryoperator")];
- char uniname2ctype_pool_str791[sizeof("pauc")];
- char uniname2ctype_pool_str794[sizeof("insmallkanaextension")];
- char uniname2ctype_pool_str797[sizeof("sm")];
- char uniname2ctype_pool_str799[sizeof("indominotiles")];
- char uniname2ctype_pool_str802[sizeof("alnum")];
- char uniname2ctype_pool_str803[sizeof("inznamennymusicalnotation")];
- char uniname2ctype_pool_str809[sizeof("insylotinagri")];
- char uniname2ctype_pool_str814[sizeof("inugaritic")];
- char uniname2ctype_pool_str818[sizeof("incontrolpictures")];
- char uniname2ctype_pool_str821[sizeof("inlinearbideograms")];
- char uniname2ctype_pool_str822[sizeof("inmusicalsymbols")];
- char uniname2ctype_pool_str823[sizeof("s")];
- char uniname2ctype_pool_str824[sizeof("ital")];
- char uniname2ctype_pool_str825[sizeof("inmodifiertoneletters")];
- char uniname2ctype_pool_str828[sizeof("inancientgreekmusicalnotation")];
- char uniname2ctype_pool_str838[sizeof("lisu")];
- char uniname2ctype_pool_str842[sizeof("lowercase")];
- char uniname2ctype_pool_str845[sizeof("cwcm")];
- char uniname2ctype_pool_str847[sizeof("sc")];
- char uniname2ctype_pool_str848[sizeof("bass")];
- char uniname2ctype_pool_str855[sizeof("ids")];
- char uniname2ctype_pool_str857[sizeof("inlatinextendeda")];
- char uniname2ctype_pool_str875[sizeof("intaile")];
- char uniname2ctype_pool_str886[sizeof("inmiscellaneoussymbols")];
- char uniname2ctype_pool_str895[sizeof("inmiscellaneoussymbolsandarrows")];
- char uniname2ctype_pool_str898[sizeof("incaucasianalbanian")];
- char uniname2ctype_pool_str900[sizeof("inmiscellaneoussymbolsandpictographs")];
- char uniname2ctype_pool_str906[sizeof("inoldturkic")];
- char uniname2ctype_pool_str907[sizeof("insaurashtra")];
- char uniname2ctype_pool_str920[sizeof("incyrillicextendeda")];
- char uniname2ctype_pool_str924[sizeof("idcontinue")];
- char uniname2ctype_pool_str925[sizeof("intaixuanjingsymbols")];
- char uniname2ctype_pool_str926[sizeof("intamil")];
- char uniname2ctype_pool_str928[sizeof("inmultani")];
- char uniname2ctype_pool_str929[sizeof("inlatinextendede")];
- char uniname2ctype_pool_str930[sizeof("pd")];
- char uniname2ctype_pool_str946[sizeof("bali")];
- char uniname2ctype_pool_str961[sizeof("blank")];
- char uniname2ctype_pool_str963[sizeof("idst")];
- char uniname2ctype_pool_str974[sizeof("inlydian")];
- char uniname2ctype_pool_str986[sizeof("innewtailue")];
- char uniname2ctype_pool_str994[sizeof("bengali")];
- char uniname2ctype_pool_str995[sizeof("runr")];
- char uniname2ctype_pool_str1010[sizeof("ll")];
- char uniname2ctype_pool_str1013[sizeof("indeseret")];
- char uniname2ctype_pool_str1015[sizeof("inancientgreeknumbers")];
- char uniname2ctype_pool_str1021[sizeof("idstart")];
- char uniname2ctype_pool_str1024[sizeof("zl")];
- char uniname2ctype_pool_str1025[sizeof("inmeeteimayekextensions")];
- char uniname2ctype_pool_str1028[sizeof("balinese")];
- char uniname2ctype_pool_str1032[sizeof("incyrillicextendedc")];
- char uniname2ctype_pool_str1035[sizeof("inspacingmodifierletters")];
- char uniname2ctype_pool_str1036[sizeof("inearlydynasticcuneiform")];
- char uniname2ctype_pool_str1049[sizeof("plrd")];
- char uniname2ctype_pool_str1067[sizeof("canadianaboriginal")];
- char uniname2ctype_pool_str1072[sizeof("sind")];
- char uniname2ctype_pool_str1081[sizeof("inlatinextendedc")];
- char uniname2ctype_pool_str1085[sizeof("uideo")];
- char uniname2ctype_pool_str1087[sizeof("incountingrodnumerals")];
- char uniname2ctype_pool_str1089[sizeof("zinh")];
- char uniname2ctype_pool_str1095[sizeof("dia")];
- char uniname2ctype_pool_str1096[sizeof("di")];
- char uniname2ctype_pool_str1097[sizeof("inkhudawadi")];
- char uniname2ctype_pool_str1102[sizeof("inhanifirohingya")];
- char uniname2ctype_pool_str1104[sizeof("diak")];
- char uniname2ctype_pool_str1105[sizeof("gong")];
- char uniname2ctype_pool_str1107[sizeof("ingrantha")];
- char uniname2ctype_pool_str1109[sizeof("bidic")];
- char uniname2ctype_pool_str1114[sizeof("xidstart")];
- char uniname2ctype_pool_str1115[sizeof("xdigit")];
- char uniname2ctype_pool_str1119[sizeof("mong")];
- char uniname2ctype_pool_str1120[sizeof("cased")];
- char uniname2ctype_pool_str1134[sizeof("inhiragana")];
- char uniname2ctype_pool_str1140[sizeof("sinhala")];
- char uniname2ctype_pool_str1142[sizeof("adlm")];
- char uniname2ctype_pool_str1145[sizeof("xsux")];
- char uniname2ctype_pool_str1146[sizeof("glagolitic")];
- char uniname2ctype_pool_str1147[sizeof("sterm")];
- char uniname2ctype_pool_str1149[sizeof("bamu")];
- char uniname2ctype_pool_str1150[sizeof("georgian")];
- char uniname2ctype_pool_str1151[sizeof("inosage")];
- char uniname2ctype_pool_str1152[sizeof("gunjalagondi")];
- char uniname2ctype_pool_str1153[sizeof("phoenician")];
- char uniname2ctype_pool_str1156[sizeof("inolduyghur")];
- char uniname2ctype_pool_str1157[sizeof("multani")];
- char uniname2ctype_pool_str1158[sizeof("kaithi")];
- char uniname2ctype_pool_str1164[sizeof("joincontrol")];
- char uniname2ctype_pool_str1168[sizeof("runic")];
- char uniname2ctype_pool_str1170[sizeof("ingeneralpunctuation")];
- char uniname2ctype_pool_str1171[sizeof("inmahajani")];
- char uniname2ctype_pool_str1174[sizeof("incyrillicsupplement")];
- char uniname2ctype_pool_str1175[sizeof("lowercaseletter")];
- char uniname2ctype_pool_str1176[sizeof("marchen")];
- char uniname2ctype_pool_str1177[sizeof("graphemelink")];
- char uniname2ctype_pool_str1178[sizeof("ingeorgian")];
- char uniname2ctype_pool_str1180[sizeof("khojki")];
- char uniname2ctype_pool_str1181[sizeof("cham")];
- char uniname2ctype_pool_str1182[sizeof("inogham")];
- char uniname2ctype_pool_str1183[sizeof("cher")];
- char uniname2ctype_pool_str1185[sizeof("chakma")];
- char uniname2ctype_pool_str1186[sizeof("inkaktoviknumerals")];
- char uniname2ctype_pool_str1190[sizeof("emoji")];
- char uniname2ctype_pool_str1191[sizeof("insiddham")];
- char uniname2ctype_pool_str1197[sizeof("cherokee")];
- char uniname2ctype_pool_str1198[sizeof("khar")];
- char uniname2ctype_pool_str1203[sizeof("inmongolian")];
- char uniname2ctype_pool_str1204[sizeof("innagmundari")];
- char uniname2ctype_pool_str1207[sizeof("incherokeesupplement")];
- char uniname2ctype_pool_str1209[sizeof("manichaean")];
- char uniname2ctype_pool_str1212[sizeof("inolchiki")];
- char uniname2ctype_pool_str1223[sizeof("inkhitansmallscript")];
- char uniname2ctype_pool_str1227[sizeof("quotationmark")];
- char uniname2ctype_pool_str1229[sizeof("vithkuqi")];
- char uniname2ctype_pool_str1230[sizeof("variationselector")];
- char uniname2ctype_pool_str1231[sizeof("adlam")];
- char uniname2ctype_pool_str1232[sizeof("inethiopic")];
- char uniname2ctype_pool_str1233[sizeof("graphemebase")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1234[sizeof("age=11.0")];
- char uniname2ctype_pool_str1235[sizeof("age=12.1")];
- char uniname2ctype_pool_str1236[sizeof("age=10.0")];
- char uniname2ctype_pool_str1237[sizeof("age=12.0")];
- char uniname2ctype_pool_str1241[sizeof("age=13.0")];
- char uniname2ctype_pool_str1242[sizeof("age=1.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1243[sizeof("casedletter")];
- char uniname2ctype_pool_str1244[sizeof("ingurmukhi")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1245[sizeof("age=2.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1246[sizeof("incjkunifiedideographsextensiona")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1247[sizeof("age=2.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1248[sizeof("lu")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1249[sizeof("age=3.1")];
- char uniname2ctype_pool_str1250[sizeof("age=9.0")];
- char uniname2ctype_pool_str1251[sizeof("age=3.0")];
- char uniname2ctype_pool_str1252[sizeof("age=3.2")];
- char uniname2ctype_pool_str1253[sizeof("age=8.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1254[sizeof("intamilsupplement")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1255[sizeof("age=6.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1256[sizeof("unknown")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1257[sizeof("age=6.0")];
- char uniname2ctype_pool_str1258[sizeof("age=6.2")];
- char uniname2ctype_pool_str1259[sizeof("age=15.0")];
- char uniname2ctype_pool_str1260[sizeof("age=7.0")];
- char uniname2ctype_pool_str1262[sizeof("age=6.3")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1263[sizeof("cwt")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1265[sizeof("age=14.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1266[sizeof("unassigned")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1267[sizeof("age=5.1")];
- char uniname2ctype_pool_str1269[sizeof("age=5.0")];
- char uniname2ctype_pool_str1270[sizeof("age=5.2")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1271[sizeof("diacritic")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1273[sizeof("age=4.1")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1274[sizeof("ahom")];
-#ifdef USE_UNICODE_AGE_PROPERTIES
- char uniname2ctype_pool_str1275[sizeof("age=4.0")];
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- char uniname2ctype_pool_str1282[sizeof("incjkunifiedideographsextensione")];
- char uniname2ctype_pool_str1285[sizeof("khmr")];
- char uniname2ctype_pool_str1289[sizeof("insinhala")];
- char uniname2ctype_pool_str1292[sizeof("inmiscellaneoustechnical")];
- char uniname2ctype_pool_str1297[sizeof("saur")];
- char uniname2ctype_pool_str1300[sizeof("guru")];
- char uniname2ctype_pool_str1301[sizeof("sundanese")];
- char uniname2ctype_pool_str1306[sizeof("punct")];
- char uniname2ctype_pool_str1314[sizeof("paucinhau")];
- char uniname2ctype_pool_str1317[sizeof("gurmukhi")];
- char uniname2ctype_pool_str1328[sizeof("chorasmian")];
- char uniname2ctype_pool_str1331[sizeof("logicalorderexception")];
- char uniname2ctype_pool_str1340[sizeof("khmer")];
- char uniname2ctype_pool_str1343[sizeof("limbu")];
- char uniname2ctype_pool_str1349[sizeof("chrs")];
- char uniname2ctype_pool_str1352[sizeof("oriya")];
- char uniname2ctype_pool_str1354[sizeof("inscriptionalpahlavi")];
- char uniname2ctype_pool_str1356[sizeof("incyrillicextendedd")];
- char uniname2ctype_pool_str1358[sizeof("incjkunifiedideographsextensionc")];
- char uniname2ctype_pool_str1360[sizeof("cntrl")];
- char uniname2ctype_pool_str1365[sizeof("inlatinextendedadditional")];
- char uniname2ctype_pool_str1367[sizeof("insorasompeng")];
- char uniname2ctype_pool_str1369[sizeof("radical")];
- char uniname2ctype_pool_str1373[sizeof("emojimodifier")];
- char uniname2ctype_pool_str1375[sizeof("kharoshthi")];
- char uniname2ctype_pool_str1380[sizeof("n")];
- char uniname2ctype_pool_str1384[sizeof("math")];
- char uniname2ctype_pool_str1387[sizeof("goth")];
- char uniname2ctype_pool_str1392[sizeof("phnx")];
- char uniname2ctype_pool_str1400[sizeof("anatolianhieroglyphs")];
- char uniname2ctype_pool_str1401[sizeof("inenclosedalphanumerics")];
- char uniname2ctype_pool_str1407[sizeof("nandinagari")];
- char uniname2ctype_pool_str1409[sizeof("no")];
- char uniname2ctype_pool_str1415[sizeof("intangsa")];
- char uniname2ctype_pool_str1419[sizeof("nko")];
- char uniname2ctype_pool_str1420[sizeof("nkoo")];
- char uniname2ctype_pool_str1422[sizeof("ingreekandcoptic")];
- char uniname2ctype_pool_str1426[sizeof("p")];
- char uniname2ctype_pool_str1428[sizeof("grantha")];
- char uniname2ctype_pool_str1429[sizeof("decimalnumber")];
- char uniname2ctype_pool_str1438[sizeof("incjkunifiedideographs")];
- char uniname2ctype_pool_str1442[sizeof("intirhuta")];
- char uniname2ctype_pool_str1448[sizeof("inhatran")];
- char uniname2ctype_pool_str1449[sizeof("linb")];
- char uniname2ctype_pool_str1451[sizeof("mult")];
- char uniname2ctype_pool_str1454[sizeof("saurashtra")];
- char uniname2ctype_pool_str1457[sizeof("kthi")];
- char uniname2ctype_pool_str1460[sizeof("zanb")];
- char uniname2ctype_pool_str1462[sizeof("inbhaiksuki")];
- char uniname2ctype_pool_str1470[sizeof("innabataean")];
- char uniname2ctype_pool_str1471[sizeof("inphoenician")];
- char uniname2ctype_pool_str1474[sizeof("xpeo")];
- char uniname2ctype_pool_str1475[sizeof("inkanbun")];
- char uniname2ctype_pool_str1476[sizeof("inmeroitichieroglyphs")];
- char uniname2ctype_pool_str1480[sizeof("ahex")];
- char uniname2ctype_pool_str1489[sizeof("enclosingmark")];
- char uniname2ctype_pool_str1495[sizeof("sd")];
- char uniname2ctype_pool_str1497[sizeof("inelbasan")];
- char uniname2ctype_pool_str1499[sizeof("inenclosedideographicsupplement")];
- char uniname2ctype_pool_str1501[sizeof("sidd")];
- char uniname2ctype_pool_str1507[sizeof("linearb")];
- char uniname2ctype_pool_str1508[sizeof("cpmn")];
- char uniname2ctype_pool_str1517[sizeof("inenclosedalphanumericsupplement")];
- char uniname2ctype_pool_str1520[sizeof("bidicontrol")];
- char uniname2ctype_pool_str1524[sizeof("inphaistosdisc")];
- char uniname2ctype_pool_str1529[sizeof("limb")];
- char uniname2ctype_pool_str1531[sizeof("inkangxiradicals")];
- char uniname2ctype_pool_str1533[sizeof("lepc")];
- char uniname2ctype_pool_str1536[sizeof("braille")];
- char uniname2ctype_pool_str1537[sizeof("regionalindicator")];
- char uniname2ctype_pool_str1542[sizeof("inlowsurrogates")];
- char uniname2ctype_pool_str1547[sizeof("brah")];
- char uniname2ctype_pool_str1549[sizeof("inoldhungarian")];
- char uniname2ctype_pool_str1557[sizeof("beng")];
- char uniname2ctype_pool_str1563[sizeof("emojimodifierbase")];
- char uniname2ctype_pool_str1565[sizeof("inarabic")];
- char uniname2ctype_pool_str1570[sizeof("osage")];
- char uniname2ctype_pool_str1572[sizeof("inherited")];
- char uniname2ctype_pool_str1577[sizeof("incyprominoan")];
- char uniname2ctype_pool_str1580[sizeof("glag")];
- char uniname2ctype_pool_str1582[sizeof("medf")];
- char uniname2ctype_pool_str1583[sizeof("osma")];
- char uniname2ctype_pool_str1587[sizeof("indogra")];
- char uniname2ctype_pool_str1597[sizeof("arab")];
- char uniname2ctype_pool_str1598[sizeof("medefaidrin")];
- char uniname2ctype_pool_str1607[sizeof("inshorthandformatcontrols")];
- char uniname2ctype_pool_str1613[sizeof("phli")];
- char uniname2ctype_pool_str1617[sizeof("inimperialaramaic")];
- char uniname2ctype_pool_str1618[sizeof("emod")];
- char uniname2ctype_pool_str1622[sizeof("ingreekextended")];
- char uniname2ctype_pool_str1623[sizeof("inanatolianhieroglyphs")];
- char uniname2ctype_pool_str1629[sizeof("punctuation")];
- char uniname2ctype_pool_str1635[sizeof("graphemeextend")];
- char uniname2ctype_pool_str1643[sizeof("cwl")];
- char uniname2ctype_pool_str1644[sizeof("vith")];
- char uniname2ctype_pool_str1654[sizeof("ingeometricshapes")];
- char uniname2ctype_pool_str1655[sizeof("emojicomponent")];
- char uniname2ctype_pool_str1657[sizeof("dsrt")];
- char uniname2ctype_pool_str1662[sizeof("coptic")];
- char uniname2ctype_pool_str1664[sizeof("inkayahli")];
- char uniname2ctype_pool_str1671[sizeof("inoriya")];
- char uniname2ctype_pool_str1675[sizeof("inarabicpresentationformsa")];
- char uniname2ctype_pool_str1677[sizeof("inbasiclatin")];
- char uniname2ctype_pool_str1682[sizeof("incjkunifiedideographsextensiond")];
- char uniname2ctype_pool_str1684[sizeof("wara")];
- char uniname2ctype_pool_str1686[sizeof("sinh")];
- char uniname2ctype_pool_str1687[sizeof("sund")];
- char uniname2ctype_pool_str1691[sizeof("shavian")];
- char uniname2ctype_pool_str1699[sizeof("insundanesesupplement")];
- char uniname2ctype_pool_str1701[sizeof("inyezidi")];
- char uniname2ctype_pool_str1704[sizeof("bhks")];
- char uniname2ctype_pool_str1714[sizeof("bhaiksuki")];
- char uniname2ctype_pool_str1722[sizeof("inhanunoo")];
- char uniname2ctype_pool_str1724[sizeof("intangut")];
- char uniname2ctype_pool_str1728[sizeof("sogdian")];
- char uniname2ctype_pool_str1729[sizeof("inlatinextendedd")];
- char uniname2ctype_pool_str1730[sizeof("sogo")];
- char uniname2ctype_pool_str1731[sizeof("insinhalaarchaicnumbers")];
- char uniname2ctype_pool_str1732[sizeof("ideographic")];
- char uniname2ctype_pool_str1733[sizeof("ugar")];
- char uniname2ctype_pool_str1734[sizeof("deseret")];
- char uniname2ctype_pool_str1735[sizeof("odi")];
- char uniname2ctype_pool_str1740[sizeof("copt")];
- char uniname2ctype_pool_str1742[sizeof("imperialaramaic")];
- char uniname2ctype_pool_str1745[sizeof("insogdian")];
- char uniname2ctype_pool_str1746[sizeof("indingbats")];
- char uniname2ctype_pool_str1750[sizeof("format")];
- char uniname2ctype_pool_str1752[sizeof("ininscriptionalpahlavi")];
- char uniname2ctype_pool_str1753[sizeof("lyci")];
- char uniname2ctype_pool_str1757[sizeof("ininscriptionalparthian")];
- char uniname2ctype_pool_str1766[sizeof("grbase")];
- char uniname2ctype_pool_str1768[sizeof("lycian")];
- char uniname2ctype_pool_str1769[sizeof("inbatak")];
- char uniname2ctype_pool_str1776[sizeof("cprt")];
- char uniname2ctype_pool_str1781[sizeof("inunifiedcanadianaboriginalsyllabicsextendeda")];
- char uniname2ctype_pool_str1788[sizeof("mymr")];
- char uniname2ctype_pool_str1793[sizeof("myanmar")];
- char uniname2ctype_pool_str1806[sizeof("intibetan")];
- char uniname2ctype_pool_str1810[sizeof("intags")];
- char uniname2ctype_pool_str1811[sizeof("asciihexdigit")];
- char uniname2ctype_pool_str1813[sizeof("sentenceterminal")];
- char uniname2ctype_pool_str1821[sizeof("nand")];
- char uniname2ctype_pool_str1828[sizeof("inblockelements")];
- char uniname2ctype_pool_str1838[sizeof("inornamentaldingbats")];
- char uniname2ctype_pool_str1841[sizeof("inethiopicextendeda")];
- char uniname2ctype_pool_str1842[sizeof("innumberforms")];
- char uniname2ctype_pool_str1843[sizeof("cwcf")];
- char uniname2ctype_pool_str1845[sizeof("oidc")];
- char uniname2ctype_pool_str1848[sizeof("bopo")];
- char uniname2ctype_pool_str1851[sizeof("cuneiform")];
- char uniname2ctype_pool_str1866[sizeof("caseignorable")];
- char uniname2ctype_pool_str1871[sizeof("inoldpersian")];
- char uniname2ctype_pool_str1881[sizeof("cwu")];
- char uniname2ctype_pool_str1888[sizeof("inelymaic")];
- char uniname2ctype_pool_str1889[sizeof("insoyombo")];
- char uniname2ctype_pool_str1896[sizeof("ingeometricshapesextended")];
- char uniname2ctype_pool_str1902[sizeof("incjkcompatibility")];
- char uniname2ctype_pool_str1904[sizeof("inmyanmarextendedb")];
- char uniname2ctype_pool_str1905[sizeof("innushu")];
- char uniname2ctype_pool_str1912[sizeof("inkanaextendedb")];
- char uniname2ctype_pool_str1913[sizeof("olck")];
- char uniname2ctype_pool_str1916[sizeof("inbyzantinemusicalsymbols")];
- char uniname2ctype_pool_str1924[sizeof("olchiki")];
- char uniname2ctype_pool_str1929[sizeof("inkatakanaphoneticextensions")];
- char uniname2ctype_pool_str1932[sizeof("incoptic")];
- char uniname2ctype_pool_str1935[sizeof("oids")];
- char uniname2ctype_pool_str1936[sizeof("inarabicextendeda")];
- char uniname2ctype_pool_str1941[sizeof("modifierletter")];
- char uniname2ctype_pool_str1950[sizeof("incjksymbolsandpunctuation")];
- char uniname2ctype_pool_str1956[sizeof("olower")];
- char uniname2ctype_pool_str1958[sizeof("bopomofo")];
- char uniname2ctype_pool_str1964[sizeof("inlisu")];
- char uniname2ctype_pool_str1967[sizeof("inoldpermic")];
- char uniname2ctype_pool_str1968[sizeof("innoblock")];
- char uniname2ctype_pool_str1969[sizeof("ext")];
- char uniname2ctype_pool_str1974[sizeof("inunifiedcanadianaboriginalsyllabics")];
- char uniname2ctype_pool_str1981[sizeof("takri")];
- char uniname2ctype_pool_str1985[sizeof("inbraillepatterns")];
- char uniname2ctype_pool_str1988[sizeof("invai")];
- char uniname2ctype_pool_str1991[sizeof("alpha")];
- char uniname2ctype_pool_str1993[sizeof("inbalinese")];
- char uniname2ctype_pool_str1994[sizeof("sorasompeng")];
- char uniname2ctype_pool_str1996[sizeof("closepunctuation")];
- char uniname2ctype_pool_str2001[sizeof("hani")];
- char uniname2ctype_pool_str2002[sizeof("inmayannumerals")];
- char uniname2ctype_pool_str2004[sizeof("han")];
- char uniname2ctype_pool_str2006[sizeof("inmiscellaneousmathematicalsymbolsb")];
- char uniname2ctype_pool_str2010[sizeof("inlepcha")];
- char uniname2ctype_pool_str2011[sizeof("patsyn")];
- char uniname2ctype_pool_str2012[sizeof("inlisusupplement")];
- char uniname2ctype_pool_str2014[sizeof("insyriacsupplement")];
- char uniname2ctype_pool_str2015[sizeof("hano")];
- char uniname2ctype_pool_str2016[sizeof("newa")];
- char uniname2ctype_pool_str2023[sizeof("spacingmark")];
- char uniname2ctype_pool_str2024[sizeof("inpalmyrene")];
- char uniname2ctype_pool_str2026[sizeof("takr")];
- char uniname2ctype_pool_str2033[sizeof("xposixpunct")];
- char uniname2ctype_pool_str2040[sizeof("inkhojki")];
- char uniname2ctype_pool_str2042[sizeof("taile")];
- char uniname2ctype_pool_str2043[sizeof("assigned")];
- char uniname2ctype_pool_str2044[sizeof("hanunoo")];
- char uniname2ctype_pool_str2047[sizeof("hira")];
- char uniname2ctype_pool_str2048[sizeof("inarabicextendedc")];
- char uniname2ctype_pool_str2062[sizeof("newtailue")];
- char uniname2ctype_pool_str2070[sizeof("space")];
- char uniname2ctype_pool_str2073[sizeof("intelugu")];
- char uniname2ctype_pool_str2077[sizeof("lydi")];
- char uniname2ctype_pool_str2078[sizeof("idsb")];
- char uniname2ctype_pool_str2090[sizeof("extpict")];
- char uniname2ctype_pool_str2092[sizeof("lydian")];
- char uniname2ctype_pool_str2095[sizeof("inethiopicsupplement")];
- char uniname2ctype_pool_str2103[sizeof("sarb")];
- char uniname2ctype_pool_str2110[sizeof("ugaritic")];
- char uniname2ctype_pool_str2114[sizeof("inyiradicals")];
- char uniname2ctype_pool_str2115[sizeof("inphoneticextensions")];
- char uniname2ctype_pool_str2117[sizeof("sharada")];
- char uniname2ctype_pool_str2128[sizeof("zanabazarsquare")];
- char uniname2ctype_pool_str2135[sizeof("bugi")];
- char uniname2ctype_pool_str2137[sizeof("word")];
- char uniname2ctype_pool_str2141[sizeof("term")];
- char uniname2ctype_pool_str2145[sizeof("separator")];
- char uniname2ctype_pool_str2146[sizeof("ingeorgiansupplement")];
- char uniname2ctype_pool_str2149[sizeof("sogd")];
- char uniname2ctype_pool_str2163[sizeof("extender")];
- char uniname2ctype_pool_str2165[sizeof("shrd")];
- char uniname2ctype_pool_str2166[sizeof("graph")];
- char uniname2ctype_pool_str2174[sizeof("tnsa")];
- char uniname2ctype_pool_str2178[sizeof("tangsa")];
- char uniname2ctype_pool_str2181[sizeof("phag")];
- char uniname2ctype_pool_str2182[sizeof("dogra")];
- char uniname2ctype_pool_str2195[sizeof("inhanguljamo")];
- char uniname2ctype_pool_str2196[sizeof("inshavian")];
- char uniname2ctype_pool_str2207[sizeof("siddham")];
- char uniname2ctype_pool_str2211[sizeof("cf")];
- char uniname2ctype_pool_str2216[sizeof("inunifiedcanadianaboriginalsyllabicsextended")];
- char uniname2ctype_pool_str2217[sizeof("buginese")];
- char uniname2ctype_pool_str2218[sizeof("inmongoliansupplement")];
- char uniname2ctype_pool_str2219[sizeof("cyrl")];
- char uniname2ctype_pool_str2224[sizeof("inhanguljamoextendeda")];
- char uniname2ctype_pool_str2228[sizeof("pf")];
- char uniname2ctype_pool_str2229[sizeof("number")];
- char uniname2ctype_pool_str2232[sizeof("inphoneticextensionssupplement")];
- char uniname2ctype_pool_str2233[sizeof("dogr")];
- char uniname2ctype_pool_str2234[sizeof("mlym")];
- char uniname2ctype_pool_str2235[sizeof("incopticepactnumbers")];
- char uniname2ctype_pool_str2241[sizeof("malayalam")];
- char uniname2ctype_pool_str2244[sizeof("inbamum")];
- char uniname2ctype_pool_str2247[sizeof("nd")];
- char uniname2ctype_pool_str2248[sizeof("insuttonsignwriting")];
- char uniname2ctype_pool_str2276[sizeof("inethiopicextended")];
- char uniname2ctype_pool_str2278[sizeof("shaw")];
- char uniname2ctype_pool_str2279[sizeof("palmyrene")];
- char uniname2ctype_pool_str2283[sizeof("soyo")];
- char uniname2ctype_pool_str2296[sizeof("incjkunifiedideographsextensionh")];
- char uniname2ctype_pool_str2305[sizeof("sgnw")];
- char uniname2ctype_pool_str2308[sizeof("toto")];
- char uniname2ctype_pool_str2312[sizeof("caucasianalbanian")];
- char uniname2ctype_pool_str2315[sizeof("inmathematicalalphanumericsymbols")];
- char uniname2ctype_pool_str2316[sizeof("incjkunifiedideographsextensiong")];
- char uniname2ctype_pool_str2318[sizeof("hatran")];
- char uniname2ctype_pool_str2321[sizeof("taiviet")];
- char uniname2ctype_pool_str2323[sizeof("meroitichieroglyphs")];
- char uniname2ctype_pool_str2327[sizeof("ingeorgianextended")];
- char uniname2ctype_pool_str2331[sizeof("incjkunifiedideographsextensionf")];
- char uniname2ctype_pool_str2333[sizeof("oldpersian")];
- char uniname2ctype_pool_str2343[sizeof("induployan")];
- char uniname2ctype_pool_str2344[sizeof("incyrillicextendedb")];
- char uniname2ctype_pool_str2345[sizeof("dash")];
- char uniname2ctype_pool_str2353[sizeof("hatr")];
- char uniname2ctype_pool_str2361[sizeof("innyiakengpuachuehmong")];
- char uniname2ctype_pool_str2364[sizeof("incombiningdiacriticalmarks")];
- char uniname2ctype_pool_str2373[sizeof("nl")];
- char uniname2ctype_pool_str2374[sizeof("incombiningdiacriticalmarksforsymbols")];
- char uniname2ctype_pool_str2375[sizeof("khudawadi")];
- char uniname2ctype_pool_str2397[sizeof("incjkradicalssupplement")];
- char uniname2ctype_pool_str2398[sizeof("inglagolitic")];
- char uniname2ctype_pool_str2405[sizeof("orkh")];
- char uniname2ctype_pool_str2414[sizeof("syrc")];
- char uniname2ctype_pool_str2427[sizeof("surrogate")];
- char uniname2ctype_pool_str2433[sizeof("indevanagari")];
- char uniname2ctype_pool_str2434[sizeof("avestan")];
- char uniname2ctype_pool_str2437[sizeof("oldpermic")];
- char uniname2ctype_pool_str2440[sizeof("ethi")];
- char uniname2ctype_pool_str2451[sizeof("ogam")];
- char uniname2ctype_pool_str2454[sizeof("rohg")];
- char uniname2ctype_pool_str2460[sizeof("idstrinaryoperator")];
- char uniname2ctype_pool_str2464[sizeof("java")];
- char uniname2ctype_pool_str2470[sizeof("inphagspa")];
- char uniname2ctype_pool_str2475[sizeof("lepcha")];
- char uniname2ctype_pool_str2476[sizeof("indevanagariextendeda")];
- char uniname2ctype_pool_str2478[sizeof("intifinagh")];
- char uniname2ctype_pool_str2479[sizeof("intagalog")];
- char uniname2ctype_pool_str2481[sizeof("incombiningdiacriticalmarkssupplement")];
- char uniname2ctype_pool_str2500[sizeof("tale")];
- char uniname2ctype_pool_str2506[sizeof("inbrahmi")];
- char uniname2ctype_pool_str2511[sizeof("terminalpunctuation")];
- char uniname2ctype_pool_str2513[sizeof("insymbolsandpictographsextendeda")];
- char uniname2ctype_pool_str2530[sizeof("syriac")];
- char uniname2ctype_pool_str2534[sizeof("inbengali")];
- char uniname2ctype_pool_str2535[sizeof("nagm")];
- char uniname2ctype_pool_str2545[sizeof("extendedpictographic")];
- char uniname2ctype_pool_str2548[sizeof("buhd")];
- char uniname2ctype_pool_str2549[sizeof("javanese")];
- char uniname2ctype_pool_str2551[sizeof("taml")];
- char uniname2ctype_pool_str2564[sizeof("inbuginese")];
- char uniname2ctype_pool_str2567[sizeof("inlatin1supplement")];
- char uniname2ctype_pool_str2570[sizeof("ingothic")];
- char uniname2ctype_pool_str2572[sizeof("invariationselectors")];
- char uniname2ctype_pool_str2574[sizeof("hex")];
- char uniname2ctype_pool_str2575[sizeof("inverticalforms")];
- char uniname2ctype_pool_str2576[sizeof("ebase")];
- char uniname2ctype_pool_str2582[sizeof("incurrencysymbols")];
- char uniname2ctype_pool_str2588[sizeof("avst")];
- char uniname2ctype_pool_str2602[sizeof("osge")];
- char uniname2ctype_pool_str2606[sizeof("incombiningdiacriticalmarksextended")];
- char uniname2ctype_pool_str2608[sizeof("intaiviet")];
- char uniname2ctype_pool_str2609[sizeof("spaceseparator")];
- char uniname2ctype_pool_str2625[sizeof("softdotted")];
- char uniname2ctype_pool_str2648[sizeof("nchar")];
- char uniname2ctype_pool_str2652[sizeof("invedicextensions")];
- char uniname2ctype_pool_str2656[sizeof("inlimbu")];
- char uniname2ctype_pool_str2657[sizeof("olditalic")];
- char uniname2ctype_pool_str2665[sizeof("gujr")];
- char uniname2ctype_pool_str2666[sizeof("mathsymbol")];
- char uniname2ctype_pool_str2670[sizeof("incjkunifiedideographsextensionb")];
- char uniname2ctype_pool_str2674[sizeof("gujarati")];
- char uniname2ctype_pool_str2688[sizeof("phagspa")];
- char uniname2ctype_pool_str2689[sizeof("invariationselectorssupplement")];
- char uniname2ctype_pool_str2694[sizeof("currencysymbol")];
- char uniname2ctype_pool_str2705[sizeof("inlinearbsyllabary")];
- char uniname2ctype_pool_str2726[sizeof("wancho")];
- char uniname2ctype_pool_str2750[sizeof("inpaucinhau")];
- char uniname2ctype_pool_str2761[sizeof("other")];
- char uniname2ctype_pool_str2762[sizeof("otheridcontinue")];
- char uniname2ctype_pool_str2765[sizeof("sylo")];
- char uniname2ctype_pool_str2766[sizeof("zp")];
- char uniname2ctype_pool_str2769[sizeof("inaegeannumbers")];
- char uniname2ctype_pool_str2772[sizeof("warangciti")];
- char uniname2ctype_pool_str2775[sizeof("othernumber")];
- char uniname2ctype_pool_str2786[sizeof("digit")];
- char uniname2ctype_pool_str2793[sizeof("nonspacingmark")];
- char uniname2ctype_pool_str2801[sizeof("titlecaseletter")];
- char uniname2ctype_pool_str2808[sizeof("inmeroiticcursive")];
- char uniname2ctype_pool_str2810[sizeof("wcho")];
- char uniname2ctype_pool_str2816[sizeof("graphemeclusterbreak=spacingmark")];
- char uniname2ctype_pool_str2821[sizeof("inletterlikesymbols")];
- char uniname2ctype_pool_str2830[sizeof("inottomansiyaqnumbers")];
- char uniname2ctype_pool_str2834[sizeof("intagbanwa")];
- char uniname2ctype_pool_str2836[sizeof("cyrillic")];
- char uniname2ctype_pool_str2847[sizeof("oalpha")];
- char uniname2ctype_pool_str2852[sizeof("graphemeclusterbreak=cr")];
- char uniname2ctype_pool_str2855[sizeof("narb")];
- char uniname2ctype_pool_str2856[sizeof("changeswhencasemapped")];
- char uniname2ctype_pool_str2859[sizeof("inbopomofo")];
- char uniname2ctype_pool_str2867[sizeof("graphemeclusterbreak=regionalindicator")];
- char uniname2ctype_pool_str2868[sizeof("otheralphabetic")];
- char uniname2ctype_pool_str2871[sizeof("noncharactercodepoint")];
- char uniname2ctype_pool_str2879[sizeof("oldhungarian")];
- char uniname2ctype_pool_str2886[sizeof("insymbolsforlegacycomputing")];
- char uniname2ctype_pool_str2902[sizeof("insmallformvariants")];
- char uniname2ctype_pool_str2904[sizeof("inhangulsyllables")];
- char uniname2ctype_pool_str2905[sizeof("emojipresentation")];
- char uniname2ctype_pool_str2907[sizeof("epres")];
- char uniname2ctype_pool_str2909[sizeof("inbassavah")];
- char uniname2ctype_pool_str2911[sizeof("indevanagariextended")];
- char uniname2ctype_pool_str2941[sizeof("inbuhid")];
- char uniname2ctype_pool_str2953[sizeof("tirhuta")];
- char uniname2ctype_pool_str2964[sizeof("inpsalterpahlavi")];
- char uniname2ctype_pool_str2966[sizeof("whitespace")];
- char uniname2ctype_pool_str2967[sizeof("finalpunctuation")];
- char uniname2ctype_pool_str2970[sizeof("orya")];
- char uniname2ctype_pool_str2980[sizeof("phlp")];
- char uniname2ctype_pool_str2984[sizeof("inbamumsupplement")];
- char uniname2ctype_pool_str2986[sizeof("buhid")];
- char uniname2ctype_pool_str2987[sizeof("paragraphseparator")];
- char uniname2ctype_pool_str2988[sizeof("inalphabeticpresentationforms")];
- char uniname2ctype_pool_str2997[sizeof("inlatinextendedg")];
- char uniname2ctype_pool_str3001[sizeof("elba")];
- char uniname2ctype_pool_str3002[sizeof("changeswhentitlecased")];
- char uniname2ctype_pool_str3005[sizeof("incombininghalfmarks")];
- char uniname2ctype_pool_str3006[sizeof("intangutcomponents")];
- char uniname2ctype_pool_str3015[sizeof("thaa")];
- char uniname2ctype_pool_str3018[sizeof("thai")];
- char uniname2ctype_pool_str3019[sizeof("oldturkic")];
- char uniname2ctype_pool_str3026[sizeof("thaana")];
- char uniname2ctype_pool_str3027[sizeof("inlatinextendedf")];
- char uniname2ctype_pool_str3035[sizeof("ougr")];
- char uniname2ctype_pool_str3042[sizeof("tang")];
- char uniname2ctype_pool_str3045[sizeof("inarabicmathematicalalphabeticsymbols")];
- char uniname2ctype_pool_str3048[sizeof("tagbanwa")];
- char uniname2ctype_pool_str3052[sizeof("tamil")];
- char uniname2ctype_pool_str3053[sizeof("khitansmallscript")];
- char uniname2ctype_pool_str3058[sizeof("mahj")];
- char uniname2ctype_pool_str3067[sizeof("mahajani")];
- char uniname2ctype_pool_str3068[sizeof("hang")];
- char uniname2ctype_pool_str3071[sizeof("tirh")];
- char uniname2ctype_pool_str3072[sizeof("sylotinagri")];
- char uniname2ctype_pool_str3082[sizeof("talu")];
- char uniname2ctype_pool_str3084[sizeof("nagmundari")];
- char uniname2ctype_pool_str3086[sizeof("deva")];
- char uniname2ctype_pool_str3087[sizeof("ingujarati")];
- char uniname2ctype_pool_str3091[sizeof("deprecated")];
- char uniname2ctype_pool_str3099[sizeof("inarabicpresentationformsb")];
- char uniname2ctype_pool_str3104[sizeof("devanagari")];
- char uniname2ctype_pool_str3106[sizeof("ingunjalagondi")];
- char uniname2ctype_pool_str3107[sizeof("graphemeclusterbreak=t")];
- char uniname2ctype_pool_str3109[sizeof("graphemeclusterbreak=lvt")];
- char uniname2ctype_pool_str3110[sizeof("taitham")];
- char uniname2ctype_pool_str3111[sizeof("nbat")];
- char uniname2ctype_pool_str3118[sizeof("telu")];
- char uniname2ctype_pool_str3123[sizeof("hiragana")];
- char uniname2ctype_pool_str3125[sizeof("nabataean")];
- char uniname2ctype_pool_str3135[sizeof("inrejang")];
- char uniname2ctype_pool_str3142[sizeof("intangutsupplement")];
- char uniname2ctype_pool_str3145[sizeof("khoj")];
- char uniname2ctype_pool_str3155[sizeof("hmng")];
- char uniname2ctype_pool_str3157[sizeof("cyprominoan")];
- char uniname2ctype_pool_str3158[sizeof("inhebrew")];
- char uniname2ctype_pool_str3176[sizeof("inmathematicaloperators")];
- char uniname2ctype_pool_str3180[sizeof("inarabicsupplement")];
- char uniname2ctype_pool_str3193[sizeof("inenclosedcjklettersandmonths")];
- char uniname2ctype_pool_str3209[sizeof("changeswhenlowercased")];
- char uniname2ctype_pool_str3212[sizeof("tangut")];
- char uniname2ctype_pool_str3215[sizeof("elbasan")];
- char uniname2ctype_pool_str3218[sizeof("osmanya")];
- char uniname2ctype_pool_str3237[sizeof("insuperscriptsandsubscripts")];
- char uniname2ctype_pool_str3239[sizeof("graphemeclusterbreak=extend")];
- char uniname2ctype_pool_str3240[sizeof("graphemeclusterbreak=prepend")];
- char uniname2ctype_pool_str3248[sizeof("nshu")];
- char uniname2ctype_pool_str3254[sizeof("otherlowercase")];
- char uniname2ctype_pool_str3265[sizeof("inethiopicextendedb")];
- char uniname2ctype_pool_str3267[sizeof("otherletter")];
- char uniname2ctype_pool_str3275[sizeof("kayahli")];
- char uniname2ctype_pool_str3284[sizeof("inplayingcards")];
- char uniname2ctype_pool_str3287[sizeof("elym")];
- char uniname2ctype_pool_str3297[sizeof("graphemeclusterbreak=l")];
- char uniname2ctype_pool_str3303[sizeof("graphemeclusterbreak=control")];
- char uniname2ctype_pool_str3313[sizeof("ogrext")];
- char uniname2ctype_pool_str3320[sizeof("elymaic")];
- char uniname2ctype_pool_str3328[sizeof("changeswhenuppercased")];
- char uniname2ctype_pool_str3329[sizeof("inalchemicalsymbols")];
- char uniname2ctype_pool_str3331[sizeof("oldsogdian")];
- char uniname2ctype_pool_str3338[sizeof("otheridstart")];
- char uniname2ctype_pool_str3348[sizeof("insupplementalarrowsa")];
- char uniname2ctype_pool_str3350[sizeof("invithkuqi")];
- char uniname2ctype_pool_str3355[sizeof("symbol")];
- char uniname2ctype_pool_str3360[sizeof("inarabicextendedb")];
- char uniname2ctype_pool_str3371[sizeof("cypriot")];
- char uniname2ctype_pool_str3372[sizeof("any")];
- char uniname2ctype_pool_str3373[sizeof("otheruppercase")];
- char uniname2ctype_pool_str3377[sizeof("rjng")];
- char uniname2ctype_pool_str3391[sizeof("wspace")];
- char uniname2ctype_pool_str3396[sizeof("inindicsiyaqnumbers")];
- char uniname2ctype_pool_str3405[sizeof("inprivateusearea")];
- char uniname2ctype_pool_str3416[sizeof("othersymbol")];
- char uniname2ctype_pool_str3428[sizeof("oupper")];
- char uniname2ctype_pool_str3433[sizeof("signwriting")];
- char uniname2ctype_pool_str3436[sizeof("nushu")];
- char uniname2ctype_pool_str3455[sizeof("hmnp")];
- char uniname2ctype_pool_str3458[sizeof("upper")];
- char uniname2ctype_pool_str3460[sizeof("insupplementalarrowsc")];
- char uniname2ctype_pool_str3483[sizeof("omath")];
- char uniname2ctype_pool_str3502[sizeof("modifiersymbol")];
- char uniname2ctype_pool_str3504[sizeof("hebr")];
- char uniname2ctype_pool_str3505[sizeof("inhalfwidthandfullwidthforms")];
- char uniname2ctype_pool_str3511[sizeof("insupplementalmathematicaloperators")];
- char uniname2ctype_pool_str3532[sizeof("inpahawhhmong")];
- char uniname2ctype_pool_str3533[sizeof("alphabetic")];
- char uniname2ctype_pool_str3558[sizeof("uppercase")];
- char uniname2ctype_pool_str3580[sizeof("dupl")];
- char uniname2ctype_pool_str3590[sizeof("ogham")];
- char uniname2ctype_pool_str3613[sizeof("dashpunctuation")];
- char uniname2ctype_pool_str3618[sizeof("hangul")];
- char uniname2ctype_pool_str3648[sizeof("inhanguljamoextendedb")];
- char uniname2ctype_pool_str3659[sizeof("bassavah")];
- char uniname2ctype_pool_str3664[sizeof("aghb")];
- char uniname2ctype_pool_str3686[sizeof("hung")];
- char uniname2ctype_pool_str3689[sizeof("hexdigit")];
- char uniname2ctype_pool_str3698[sizeof("incypriotsyllabary")];
- char uniname2ctype_pool_str3699[sizeof("indivesakuru")];
- char uniname2ctype_pool_str3701[sizeof("tibt")];
- char uniname2ctype_pool_str3705[sizeof("inlatinextendedb")];
- char uniname2ctype_pool_str3710[sizeof("hluw")];
- char uniname2ctype_pool_str3713[sizeof("tibetan")];
- char uniname2ctype_pool_str3721[sizeof("inyisyllables")];
- char uniname2ctype_pool_str3744[sizeof("oldnortharabian")];
- char uniname2ctype_pool_str3754[sizeof("defaultignorablecodepoint")];
- char uniname2ctype_pool_str3766[sizeof("inhighprivateusesurrogates")];
- char uniname2ctype_pool_str3799[sizeof("soyombo")];
- char uniname2ctype_pool_str3807[sizeof("otherdefaultignorablecodepoint")];
- char uniname2ctype_pool_str3842[sizeof("pahawhhmong")];
- char uniname2ctype_pool_str3845[sizeof("unifiedideograph")];
- char uniname2ctype_pool_str3850[sizeof("othermath")];
- char uniname2ctype_pool_str3854[sizeof("changeswhencasefolded")];
- char uniname2ctype_pool_str3857[sizeof("inmahjongtiles")];
- char uniname2ctype_pool_str3868[sizeof("dep")];
- char uniname2ctype_pool_str3881[sizeof("divesakuru")];
- char uniname2ctype_pool_str3884[sizeof("graphemeclusterbreak=lf")];
- char uniname2ctype_pool_str3891[sizeof("uppercaseletter")];
- char uniname2ctype_pool_str3924[sizeof("insupplementalpunctuation")];
- char uniname2ctype_pool_str3942[sizeof("ethiopic")];
- char uniname2ctype_pool_str3944[sizeof("inyijinghexagramsymbols")];
- char uniname2ctype_pool_str3949[sizeof("ecomp")];
- char uniname2ctype_pool_str3976[sizeof("inglagoliticsupplement")];
- char uniname2ctype_pool_str3998[sizeof("inbopomofoextended")];
- char uniname2ctype_pool_str4007[sizeof("injavanese")];
- char uniname2ctype_pool_str4106[sizeof("otherpunctuation")];
- char uniname2ctype_pool_str4116[sizeof("tifinagh")];
- char uniname2ctype_pool_str4127[sizeof("tfng")];
- char uniname2ctype_pool_str4169[sizeof("hanifirohingya")];
- char uniname2ctype_pool_str4231[sizeof("tavt")];
- char uniname2ctype_pool_str4308[sizeof("inboxdrawing")];
- char uniname2ctype_pool_str4309[sizeof("oldsoutharabian")];
- char uniname2ctype_pool_str4348[sizeof("inegyptianhieroglyphs")];
- char uniname2ctype_pool_str4361[sizeof("inegyptianhieroglyphformatcontrols")];
- char uniname2ctype_pool_str4459[sizeof("tagb")];
- char uniname2ctype_pool_str4487[sizeof("rejang")];
- char uniname2ctype_pool_str4604[sizeof("tglg")];
- char uniname2ctype_pool_str4626[sizeof("tagalog")];
- char uniname2ctype_pool_str4627[sizeof("othergraphemeextend")];
- char uniname2ctype_pool_str4674[sizeof("insupplementaryprivateuseareaa")];
- char uniname2ctype_pool_str4683[sizeof("inhighsurrogates")];
- char uniname2ctype_pool_str4695[sizeof("hebrew")];
- char uniname2ctype_pool_str4734[sizeof("duployan")];
- char uniname2ctype_pool_str4755[sizeof("graphemeclusterbreak=v")];
- char uniname2ctype_pool_str4756[sizeof("graphemeclusterbreak=lv")];
- char uniname2ctype_pool_str4772[sizeof("insupplementalarrowsb")];
- char uniname2ctype_pool_str4783[sizeof("graphemeclusterbreak=zwj")];
- char uniname2ctype_pool_str4810[sizeof("telugu")];
- char uniname2ctype_pool_str4898[sizeof("zyyy")];
- char uniname2ctype_pool_str4982[sizeof("olduyghur")];
- char uniname2ctype_pool_str4986[sizeof("inhangulcompatibilityjamo")];
- char uniname2ctype_pool_str5018[sizeof("openpunctuation")];
- char uniname2ctype_pool_str5038[sizeof("hyphen")];
- char uniname2ctype_pool_str5134[sizeof("insupplementalsymbolsandpictographs")];
- char uniname2ctype_pool_str5141[sizeof("egyp")];
- char uniname2ctype_pool_str5300[sizeof("nyiakengpuachuehmong")];
- char uniname2ctype_pool_str5980[sizeof("egyptianhieroglyphs")];
- char uniname2ctype_pool_str6098[sizeof("insupplementaryprivateuseareab")];
-#endif /* USE_UNICODE_PROPERTIES */
- };
-static const struct uniname2ctype_pool_t uniname2ctype_pool_contents =
- {
-#ifndef USE_UNICODE_PROPERTIES
- "word",
-#else /* USE_UNICODE_PROPERTIES */
- "yi",
- "yiii",
- "lana",
- "lina",
- "maka",
- "mani",
- "mn",
- "miao",
- "lo",
- "ci",
- "lao",
- "laoo",
- "inkannada",
- "cn",
- "pi",
- "innko",
- "z",
- "gran",
- "co",
- "lineara",
- "mark",
- "yezi",
- "po",
- "me",
- "cari",
- "inkharoshthi",
- "kana",
- "loe",
- "m",
- "grek",
- "mro",
- "mroo",
- "carian",
- "geor",
- "greek",
- "gonm",
- "mendekikakui",
- "pe",
- "mero",
- "inosmanya",
- "cakm",
- "inmanichaean",
- "inmro",
- "inmiao",
- "inchakma",
- "c",
- "mandaic",
- "meeteimayek",
- "zzzz",
- "inarmenian",
- "inmyanmar",
- "inmakasar",
- "common",
- "lm",
- "marc",
- "inrunic",
- "incarian",
- "inideographicsymbolsandpunctuation",
- "inkhmer",
- "qaai",
- "inahom",
- "merc",
- "inchorasmian",
- "combiningmark",
- "lc",
- "perm",
- "mc",
- "connectorpunctuation",
- "cans",
- "incuneiformnumbersandpunctuation",
- "armi",
- "cc",
- "armn",
- "incherokee",
- "prependedconcatenationmark",
- "incuneiform",
- "inavestan",
- "inipaextensions",
- "pc",
- "armenian",
- "insharada",
- "vai",
- "vaii",
- "inmarchen",
- "makasar",
- "masaramgondi",
- "inarrows",
- "incyrillic",
- "incham",
- "qmark",
- "ri",
- "qaac",
- "insamaritan",
- "latn",
- "inmasaramgondi",
- "inthaana",
- "latin",
- "inthai",
- "lineseparator",
- "pcm",
- "inkatakana",
- "inkaithi",
- "inscriptionalparthian",
- "initialpunctuation",
- "mtei",
- "inzanabazarsquare",
- "inkhmersymbols",
- "insyriac",
- "intakri",
- "arabic",
- "katakana",
- "prti",
- "zs",
- "ascii",
- "cs",
- "ps",
- "mand",
- "privateuse",
- "inruminumeralsymbols",
- "inmyanmarextendeda",
- "modi",
- "incjkcompatibilityforms",
- "inkanaextendeda",
- "incjkcompatibilityideographs",
- "brai",
- "mend",
- "ideo",
- "letter",
- "l",
- "inmeeteimayek",
- "inideographicdescriptioncharacters",
- "yezidi",
- "knda",
- "innandinagari",
- "kannada",
- "inmodi",
- "inlao",
- "xidcontinue",
- "inoldnortharabian",
- "intransportandmapsymbols",
- "letternumber",
- "gothic",
- "inlineara",
- "inmendekikakui",
- "mongolian",
- "inmiscellaneousmathematicalsymbolsa",
- "inspecials",
- "grlink",
- "brahmi",
- "inemoticons",
- "kali",
- "inolditalic",
- "xidc",
- "inmedefaidrin",
- "inchesssymbols",
- "incjkcompatibilityideographssupplement",
- "kits",
- "inadlam",
- "psalterpahlavi",
- "incommonindicnumberforms",
- "lt",
- "innewa",
- "sk",
- "control",
- "inkawi",
- "inancientsymbols",
- "palm",
- "inlycian",
- "so",
- "patternwhitespace",
- "inmandaic",
- "idc",
- "meroiticcursive",
- "intoto",
- "vs",
- "xids",
- "inwarangciti",
- "sora",
- "inopticalcharacterrecognition",
- "kawi",
- "inoldsogdian",
- "inmalayalam",
- "bamum",
- "inkanasupplement",
- "insundanese",
- "grext",
-#endif /* USE_UNICODE_PROPERTIES */
- "print",
-#ifndef USE_UNICODE_PROPERTIES
- "punct",
- "alpha",
-#else /* USE_UNICODE_PROPERTIES */
- "intaitham",
- "lower",
- "patternsyntax",
- "joinc",
- "inoldsoutharabian",
- "incjkstrokes",
- "batk",
- "samr",
- "inwancho",
- "batak",
- "patws",
- "samaritan",
- "idsbinaryoperator",
- "pauc",
- "insmallkanaextension",
- "sm",
- "indominotiles",
-#endif /* USE_UNICODE_PROPERTIES */
- "alnum",
-#ifdef USE_UNICODE_PROPERTIES
- "inznamennymusicalnotation",
- "insylotinagri",
- "inugaritic",
- "incontrolpictures",
- "inlinearbideograms",
- "inmusicalsymbols",
- "s",
- "ital",
- "inmodifiertoneletters",
- "inancientgreekmusicalnotation",
- "lisu",
- "lowercase",
- "cwcm",
- "sc",
- "bass",
- "ids",
- "inlatinextendeda",
- "intaile",
- "inmiscellaneoussymbols",
- "inmiscellaneoussymbolsandarrows",
- "incaucasianalbanian",
- "inmiscellaneoussymbolsandpictographs",
- "inoldturkic",
- "insaurashtra",
- "incyrillicextendeda",
- "idcontinue",
- "intaixuanjingsymbols",
- "intamil",
- "inmultani",
- "inlatinextendede",
- "pd",
- "bali",
- "blank",
- "idst",
- "inlydian",
- "innewtailue",
- "bengali",
- "runr",
- "ll",
- "indeseret",
- "inancientgreeknumbers",
- "idstart",
- "zl",
- "inmeeteimayekextensions",
- "balinese",
- "incyrillicextendedc",
- "inspacingmodifierletters",
- "inearlydynasticcuneiform",
- "plrd",
- "canadianaboriginal",
- "sind",
- "inlatinextendedc",
- "uideo",
- "incountingrodnumerals",
- "zinh",
- "dia",
- "di",
- "inkhudawadi",
- "inhanifirohingya",
- "diak",
- "gong",
- "ingrantha",
- "bidic",
- "xidstart",
-#endif /* USE_UNICODE_PROPERTIES */
- "xdigit",
-#ifndef USE_UNICODE_PROPERTIES
- "upper",
- "ascii",
-#else /* USE_UNICODE_PROPERTIES */
- "mong",
- "cased",
- "inhiragana",
- "sinhala",
- "adlm",
- "xsux",
- "glagolitic",
- "sterm",
- "bamu",
- "georgian",
- "inosage",
- "gunjalagondi",
- "phoenician",
- "inolduyghur",
- "multani",
- "kaithi",
- "joincontrol",
- "runic",
- "ingeneralpunctuation",
- "inmahajani",
- "incyrillicsupplement",
- "lowercaseletter",
- "marchen",
- "graphemelink",
- "ingeorgian",
- "khojki",
- "cham",
- "inogham",
- "cher",
- "chakma",
- "inkaktoviknumerals",
- "emoji",
- "insiddham",
- "cherokee",
- "khar",
- "inmongolian",
- "innagmundari",
- "incherokeesupplement",
- "manichaean",
- "inolchiki",
- "inkhitansmallscript",
- "quotationmark",
- "vithkuqi",
- "variationselector",
- "adlam",
- "inethiopic",
- "graphemebase",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=11.0",
- "age=12.1",
- "age=10.0",
- "age=12.0",
- "age=13.0",
- "age=1.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "casedletter",
- "ingurmukhi",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=2.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "incjkunifiedideographsextensiona",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=2.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "lu",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=3.1",
- "age=9.0",
- "age=3.0",
- "age=3.2",
- "age=8.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "intamilsupplement",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=6.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "unknown",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=6.0",
- "age=6.2",
- "age=15.0",
- "age=7.0",
- "age=6.3",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "cwt",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=14.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "unassigned",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=5.1",
- "age=5.0",
- "age=5.2",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "diacritic",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=4.1",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "ahom",
-#ifdef USE_UNICODE_AGE_PROPERTIES
- "age=4.0",
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- "incjkunifiedideographsextensione",
- "khmr",
- "insinhala",
- "inmiscellaneoustechnical",
- "saur",
- "guru",
- "sundanese",
- "punct",
- "paucinhau",
- "gurmukhi",
- "chorasmian",
- "logicalorderexception",
- "khmer",
- "limbu",
- "chrs",
- "oriya",
- "inscriptionalpahlavi",
- "incyrillicextendedd",
- "incjkunifiedideographsextensionc",
-#endif /* USE_UNICODE_PROPERTIES */
- "cntrl",
-#ifndef USE_UNICODE_PROPERTIES
- "space",
-#else /* USE_UNICODE_PROPERTIES */
- "inlatinextendedadditional",
- "insorasompeng",
- "radical",
- "emojimodifier",
- "kharoshthi",
- "n",
- "math",
- "goth",
- "phnx",
- "anatolianhieroglyphs",
- "inenclosedalphanumerics",
- "nandinagari",
- "no",
- "intangsa",
- "nko",
- "nkoo",
- "ingreekandcoptic",
- "p",
- "grantha",
- "decimalnumber",
- "incjkunifiedideographs",
- "intirhuta",
- "inhatran",
- "linb",
- "mult",
- "saurashtra",
- "kthi",
- "zanb",
- "inbhaiksuki",
- "innabataean",
- "inphoenician",
- "xpeo",
- "inkanbun",
- "inmeroitichieroglyphs",
- "ahex",
- "enclosingmark",
- "sd",
- "inelbasan",
- "inenclosedideographicsupplement",
- "sidd",
- "linearb",
- "cpmn",
- "inenclosedalphanumericsupplement",
- "bidicontrol",
- "inphaistosdisc",
- "limb",
- "inkangxiradicals",
- "lepc",
- "braille",
- "regionalindicator",
- "inlowsurrogates",
- "brah",
- "inoldhungarian",
- "beng",
- "emojimodifierbase",
- "inarabic",
- "osage",
- "inherited",
- "incyprominoan",
- "glag",
- "medf",
- "osma",
- "indogra",
- "arab",
- "medefaidrin",
- "inshorthandformatcontrols",
- "phli",
- "inimperialaramaic",
- "emod",
- "ingreekextended",
- "inanatolianhieroglyphs",
- "punctuation",
- "graphemeextend",
- "cwl",
- "vith",
- "ingeometricshapes",
- "emojicomponent",
- "dsrt",
- "coptic",
- "inkayahli",
- "inoriya",
- "inarabicpresentationformsa",
- "inbasiclatin",
- "incjkunifiedideographsextensiond",
- "wara",
- "sinh",
- "sund",
- "shavian",
- "insundanesesupplement",
- "inyezidi",
- "bhks",
- "bhaiksuki",
- "inhanunoo",
- "intangut",
- "sogdian",
- "inlatinextendedd",
- "sogo",
- "insinhalaarchaicnumbers",
- "ideographic",
- "ugar",
- "deseret",
- "odi",
- "copt",
- "imperialaramaic",
- "insogdian",
- "indingbats",
- "format",
- "ininscriptionalpahlavi",
- "lyci",
- "ininscriptionalparthian",
- "grbase",
- "lycian",
- "inbatak",
- "cprt",
- "inunifiedcanadianaboriginalsyllabicsextendeda",
- "mymr",
- "myanmar",
- "intibetan",
- "intags",
- "asciihexdigit",
- "sentenceterminal",
- "nand",
- "inblockelements",
- "inornamentaldingbats",
- "inethiopicextendeda",
- "innumberforms",
- "cwcf",
- "oidc",
- "bopo",
- "cuneiform",
- "caseignorable",
- "inoldpersian",
- "cwu",
- "inelymaic",
- "insoyombo",
- "ingeometricshapesextended",
- "incjkcompatibility",
- "inmyanmarextendedb",
- "innushu",
- "inkanaextendedb",
- "olck",
- "inbyzantinemusicalsymbols",
- "olchiki",
- "inkatakanaphoneticextensions",
- "incoptic",
- "oids",
- "inarabicextendeda",
- "modifierletter",
- "incjksymbolsandpunctuation",
- "olower",
- "bopomofo",
- "inlisu",
- "inoldpermic",
- "innoblock",
- "ext",
- "inunifiedcanadianaboriginalsyllabics",
- "takri",
- "inbraillepatterns",
- "invai",
- "alpha",
- "inbalinese",
- "sorasompeng",
- "closepunctuation",
- "hani",
- "inmayannumerals",
- "han",
- "inmiscellaneousmathematicalsymbolsb",
- "inlepcha",
- "patsyn",
- "inlisusupplement",
- "insyriacsupplement",
- "hano",
- "newa",
- "spacingmark",
- "inpalmyrene",
- "takr",
-#endif /* USE_UNICODE_PROPERTIES */
- "xposixpunct",
-#ifndef USE_UNICODE_PROPERTIES
- "lower",
-#else /* USE_UNICODE_PROPERTIES */
- "inkhojki",
- "taile",
- "assigned",
- "hanunoo",
- "hira",
- "inarabicextendedc",
- "newtailue",
- "space",
- "intelugu",
- "lydi",
- "idsb",
- "extpict",
- "lydian",
- "inethiopicsupplement",
- "sarb",
- "ugaritic",
- "inyiradicals",
- "inphoneticextensions",
- "sharada",
- "zanabazarsquare",
- "bugi",
- "word",
- "term",
- "separator",
- "ingeorgiansupplement",
- "sogd",
- "extender",
- "shrd",
-#endif /* USE_UNICODE_PROPERTIES */
- "graph",
-#ifdef USE_UNICODE_PROPERTIES
- "tnsa",
- "tangsa",
- "phag",
- "dogra",
- "inhanguljamo",
- "inshavian",
- "siddham",
- "cf",
- "inunifiedcanadianaboriginalsyllabicsextended",
- "buginese",
- "inmongoliansupplement",
- "cyrl",
- "inhanguljamoextendeda",
- "pf",
- "number",
- "inphoneticextensionssupplement",
- "dogr",
- "mlym",
- "incopticepactnumbers",
- "malayalam",
- "inbamum",
- "nd",
- "insuttonsignwriting",
- "inethiopicextended",
- "shaw",
- "palmyrene",
- "soyo",
- "incjkunifiedideographsextensionh",
- "sgnw",
- "toto",
- "caucasianalbanian",
- "inmathematicalalphanumericsymbols",
- "incjkunifiedideographsextensiong",
- "hatran",
- "taiviet",
- "meroitichieroglyphs",
- "ingeorgianextended",
- "incjkunifiedideographsextensionf",
- "oldpersian",
- "induployan",
- "incyrillicextendedb",
- "dash",
- "hatr",
- "innyiakengpuachuehmong",
- "incombiningdiacriticalmarks",
- "nl",
- "incombiningdiacriticalmarksforsymbols",
- "khudawadi",
- "incjkradicalssupplement",
- "inglagolitic",
- "orkh",
- "syrc",
- "surrogate",
- "indevanagari",
- "avestan",
- "oldpermic",
- "ethi",
- "ogam",
- "rohg",
- "idstrinaryoperator",
- "java",
- "inphagspa",
- "lepcha",
- "indevanagariextendeda",
- "intifinagh",
- "intagalog",
- "incombiningdiacriticalmarkssupplement",
- "tale",
- "inbrahmi",
- "terminalpunctuation",
- "insymbolsandpictographsextendeda",
- "syriac",
- "inbengali",
- "nagm",
- "extendedpictographic",
- "buhd",
- "javanese",
- "taml",
- "inbuginese",
- "inlatin1supplement",
- "ingothic",
- "invariationselectors",
- "hex",
- "inverticalforms",
- "ebase",
- "incurrencysymbols",
- "avst",
- "osge",
- "incombiningdiacriticalmarksextended",
- "intaiviet",
- "spaceseparator",
- "softdotted",
- "nchar",
- "invedicextensions",
- "inlimbu",
- "olditalic",
- "gujr",
- "mathsymbol",
- "incjkunifiedideographsextensionb",
- "gujarati",
- "phagspa",
- "invariationselectorssupplement",
- "currencysymbol",
- "inlinearbsyllabary",
- "wancho",
- "inpaucinhau",
- "other",
- "otheridcontinue",
- "sylo",
- "zp",
- "inaegeannumbers",
- "warangciti",
- "othernumber",
-#endif /* USE_UNICODE_PROPERTIES */
- "digit",
-#ifndef USE_UNICODE_PROPERTIES
- "blank"
-#else /* USE_UNICODE_PROPERTIES */
- "nonspacingmark",
- "titlecaseletter",
- "inmeroiticcursive",
- "wcho",
- "graphemeclusterbreak=spacingmark",
- "inletterlikesymbols",
- "inottomansiyaqnumbers",
- "intagbanwa",
- "cyrillic",
- "oalpha",
- "graphemeclusterbreak=cr",
- "narb",
- "changeswhencasemapped",
- "inbopomofo",
- "graphemeclusterbreak=regionalindicator",
- "otheralphabetic",
- "noncharactercodepoint",
- "oldhungarian",
- "insymbolsforlegacycomputing",
- "insmallformvariants",
- "inhangulsyllables",
- "emojipresentation",
- "epres",
- "inbassavah",
- "indevanagariextended",
- "inbuhid",
- "tirhuta",
- "inpsalterpahlavi",
- "whitespace",
- "finalpunctuation",
- "orya",
- "phlp",
- "inbamumsupplement",
- "buhid",
- "paragraphseparator",
- "inalphabeticpresentationforms",
- "inlatinextendedg",
- "elba",
- "changeswhentitlecased",
- "incombininghalfmarks",
- "intangutcomponents",
- "thaa",
- "thai",
- "oldturkic",
- "thaana",
- "inlatinextendedf",
- "ougr",
- "tang",
- "inarabicmathematicalalphabeticsymbols",
- "tagbanwa",
- "tamil",
- "khitansmallscript",
- "mahj",
- "mahajani",
- "hang",
- "tirh",
- "sylotinagri",
- "talu",
- "nagmundari",
- "deva",
- "ingujarati",
- "deprecated",
- "inarabicpresentationformsb",
- "devanagari",
- "ingunjalagondi",
- "graphemeclusterbreak=t",
- "graphemeclusterbreak=lvt",
- "taitham",
- "nbat",
- "telu",
- "hiragana",
- "nabataean",
- "inrejang",
- "intangutsupplement",
- "khoj",
- "hmng",
- "cyprominoan",
- "inhebrew",
- "inmathematicaloperators",
- "inarabicsupplement",
- "inenclosedcjklettersandmonths",
- "changeswhenlowercased",
- "tangut",
- "elbasan",
- "osmanya",
- "insuperscriptsandsubscripts",
- "graphemeclusterbreak=extend",
- "graphemeclusterbreak=prepend",
- "nshu",
- "otherlowercase",
- "inethiopicextendedb",
- "otherletter",
- "kayahli",
- "inplayingcards",
- "elym",
- "graphemeclusterbreak=l",
- "graphemeclusterbreak=control",
- "ogrext",
- "elymaic",
- "changeswhenuppercased",
- "inalchemicalsymbols",
- "oldsogdian",
- "otheridstart",
- "insupplementalarrowsa",
- "invithkuqi",
- "symbol",
- "inarabicextendedb",
- "cypriot",
- "any",
- "otheruppercase",
- "rjng",
- "wspace",
- "inindicsiyaqnumbers",
- "inprivateusearea",
- "othersymbol",
- "oupper",
- "signwriting",
- "nushu",
- "hmnp",
- "upper",
- "insupplementalarrowsc",
- "omath",
- "modifiersymbol",
- "hebr",
- "inhalfwidthandfullwidthforms",
- "insupplementalmathematicaloperators",
- "inpahawhhmong",
- "alphabetic",
- "uppercase",
- "dupl",
- "ogham",
- "dashpunctuation",
- "hangul",
- "inhanguljamoextendedb",
- "bassavah",
- "aghb",
- "hung",
- "hexdigit",
- "incypriotsyllabary",
- "indivesakuru",
- "tibt",
- "inlatinextendedb",
- "hluw",
- "tibetan",
- "inyisyllables",
- "oldnortharabian",
- "defaultignorablecodepoint",
- "inhighprivateusesurrogates",
- "soyombo",
- "otherdefaultignorablecodepoint",
- "pahawhhmong",
- "unifiedideograph",
- "othermath",
- "changeswhencasefolded",
- "inmahjongtiles",
- "dep",
- "divesakuru",
- "graphemeclusterbreak=lf",
- "uppercaseletter",
- "insupplementalpunctuation",
- "ethiopic",
- "inyijinghexagramsymbols",
- "ecomp",
- "inglagoliticsupplement",
- "inbopomofoextended",
- "injavanese",
- "otherpunctuation",
- "tifinagh",
- "tfng",
- "hanifirohingya",
- "tavt",
- "inboxdrawing",
- "oldsoutharabian",
- "inegyptianhieroglyphs",
- "inegyptianhieroglyphformatcontrols",
- "tagb",
- "rejang",
- "tglg",
- "tagalog",
- "othergraphemeextend",
- "insupplementaryprivateuseareaa",
- "inhighsurrogates",
- "hebrew",
- "duployan",
- "graphemeclusterbreak=v",
- "graphemeclusterbreak=lv",
- "insupplementalarrowsb",
- "graphemeclusterbreak=zwj",
- "telugu",
- "zyyy",
- "olduyghur",
- "inhangulcompatibilityjamo",
- "openpunctuation",
- "hyphen",
- "insupplementalsymbolsandpictographs",
- "egyp",
- "nyiakengpuachuehmong",
- "egyptianhieroglyphs",
- "insupplementaryprivateuseareab"
-#endif /* USE_UNICODE_PROPERTIES */
- };
-#define uniname2ctype_pool ((const char *) &uniname2ctype_pool_contents)
-const struct uniname2ctype_struct *
-uniname2ctype_p (register const char *str, register size_t len)
-{
- static const struct uniname2ctype_struct wordlist[] =
- {
-#ifdef USE_UNICODE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str11), 111},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str17), 111},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str22), 152},
- {-1}, {-1},
- {uniname2ctype_offset(str25), 184},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str33), 218},
- {-1},
- {uniname2ctype_offset(str35), 186},
- {uniname2ctype_offset(str36), 34},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str45), 173},
- {uniname2ctype_offset(str46), 28},
- {uniname2ctype_offset(str47), 61},
- {uniname2ctype_offset(str48), 95},
- {uniname2ctype_offset(str49), 95},
- {-1}, {-1},
- {uniname2ctype_offset(str52), 346},
- {-1}, {-1},
- {uniname2ctype_offset(str55), 21},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str64), 44},
- {-1},
- {uniname2ctype_offset(str66), 333},
- {uniname2ctype_offset(str67), 52},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str71), 181},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str75), 22},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str83), 184},
- {-1}, {-1},
- {uniname2ctype_offset(str86), 31},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str90), 230},
- {-1},
- {uniname2ctype_offset(str92), 45},
- {-1},
- {uniname2ctype_offset(str94), 33},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str100), 149},
- {uniname2ctype_offset(str101), 513},
- {uniname2ctype_offset(str102), 108},
- {uniname2ctype_offset(str103), 263},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str107), 31},
- {uniname2ctype_offset(str108), 77},
- {-1}, {-1},
- {uniname2ctype_offset(str111), 189},
- {uniname2ctype_offset(str112), 189},
- {-1}, {-1},
- {uniname2ctype_offset(str115), 149},
- {-1},
- {uniname2ctype_offset(str117), 98},
- {uniname2ctype_offset(str118), 77},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str122), 212},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str129), 187},
- {uniname2ctype_offset(str130), 42},
- {uniname2ctype_offset(str131), 172},
- {-1}, {-1},
- {uniname2ctype_offset(str134), 497},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str139), 170},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str145), 516},
- {uniname2ctype_offset(str146), 575},
- {-1},
- {uniname2ctype_offset(str148), 580},
- {uniname2ctype_offset(str149), 535},
- {-1},
- {uniname2ctype_offset(str151), 18},
- {uniname2ctype_offset(str152), 169},
- {uniname2ctype_offset(str153), 160},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str158), 278},
- {-1}, {-1},
- {uniname2ctype_offset(str161), 327},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str177), 352},
- {uniname2ctype_offset(str178), 563},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str183), 75},
- {-1}, {-1},
- {uniname2ctype_offset(str186), 27},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str190), 208},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str203), 360},
- {uniname2ctype_offset(str204), 488},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str210), 581},
- {-1},
- {uniname2ctype_offset(str212), 365},
- {uniname2ctype_offset(str213), 115},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str218), 549},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str226), 171},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str230), 530},
- {uniname2ctype_offset(str231), 31},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str236), 25},
- {uniname2ctype_offset(str237), 194},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str246), 32},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str250), 40},
- {-1}, {-1},
- {uniname2ctype_offset(str253), 102},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str260), 568},
- {-1}, {-1},
- {uniname2ctype_offset(str263), 161},
- {-1},
- {uniname2ctype_offset(str265), 19},
- {-1},
- {uniname2ctype_offset(str267), 79},
- {uniname2ctype_offset(str268), 357},
- {-1},
- {uniname2ctype_offset(str270), 270},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str274), 567},
- {uniname2ctype_offset(str275), 517},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str281), 321},
- {uniname2ctype_offset(str282), 40},
- {uniname2ctype_offset(str283), 79},
- {-1},
- {uniname2ctype_offset(str285), 537},
- {-1},
- {uniname2ctype_offset(str287), 144},
- {uniname2ctype_offset(str288), 144},
- {uniname2ctype_offset(str289), 560},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str293), 218},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str297), 212},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str301), 395},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str311), 325},
- {-1},
- {uniname2ctype_offset(str313), 456},
- {-1},
- {uniname2ctype_offset(str315), 243},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str320), 271},
- {-1},
- {uniname2ctype_offset(str322), 129},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str328), 334},
- {-1}, {-1},
- {uniname2ctype_offset(str331), 76},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str335), 561},
- {-1}, {-1},
- {uniname2ctype_offset(str338), 332},
- {-1},
- {uniname2ctype_offset(str340), 76},
- {-1},
- {uniname2ctype_offset(str342), 349},
- {-1}, {-1},
- {uniname2ctype_offset(str345), 53},
- {uniname2ctype_offset(str346), 270},
- {-1},
- {uniname2ctype_offset(str348), 426},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str352), 533},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str362), 163},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str366), 44},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str373), 160},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str381), 554},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str386), 371},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str399), 330},
- {-1},
- {uniname2ctype_offset(str401), 548},
- {-1}, {-1},
- {uniname2ctype_offset(str404), 81},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str418), 108},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str426), 163},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str430), 55},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str442), 14},
- {-1}, {-1},
- {uniname2ctype_offset(str445), 23},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str462), 46},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str468), 169},
- {-1},
- {uniname2ctype_offset(str470), 22},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str475), 524},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str480), 457},
- {uniname2ctype_offset(str481), 188},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str486), 476},
- {-1},
- {uniname2ctype_offset(str488), 588},
- {-1}, {-1},
- {uniname2ctype_offset(str491), 470},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str500), 127},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str504), 187},
- {uniname2ctype_offset(str505), 249},
- {uniname2ctype_offset(str506), 24},
- {-1}, {-1},
- {uniname2ctype_offset(str509), 24},
- {-1},
- {uniname2ctype_offset(str511), 463},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str520), 423},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str533), 230},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str538), 91},
- {-1}, {-1},
- {uniname2ctype_offset(str541), 553},
- {-1},
- {uniname2ctype_offset(str543), 91},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str556), 546},
- {-1},
- {uniname2ctype_offset(str558), 350},
- {uniname2ctype_offset(str559), 70},
- {uniname2ctype_offset(str560), 515},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str565), 624},
- {uniname2ctype_offset(str566), 37},
- {-1},
- {uniname2ctype_offset(str568), 113},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str572), 502},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str577), 611},
- {-1},
- {uniname2ctype_offset(str579), 106},
- {-1}, {-1},
- {uniname2ctype_offset(str582), 406},
- {uniname2ctype_offset(str583), 480},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str590), 74},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str594), 168},
- {-1},
- {uniname2ctype_offset(str596), 622},
- {uniname2ctype_offset(str597), 146},
- {-1}, {-1},
- {uniname2ctype_offset(str600), 490},
- {-1},
- {uniname2ctype_offset(str602), 70},
- {-1},
- {uniname2ctype_offset(str604), 579},
- {uniname2ctype_offset(str605), 629},
- {-1}, {-1},
- {uniname2ctype_offset(str608), 637},
- {uniname2ctype_offset(str609), 229},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str614), 612},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str624), 195},
- {uniname2ctype_offset(str625), 447},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str630), 29},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str636), 543},
- {-1}, {-1},
- {uniname2ctype_offset(str639), 49},
- {-1}, {-1},
- {uniname2ctype_offset(str642), 19},
- {uniname2ctype_offset(str643), 564},
- {-1},
- {uniname2ctype_offset(str645), 485},
- {-1},
- {uniname2ctype_offset(str647), 192},
- {-1}, {-1},
- {uniname2ctype_offset(str650), 487},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str657), 51},
- {-1}, {-1},
- {uniname2ctype_offset(str660), 268},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str672), 335},
- {-1}, {-1},
- {uniname2ctype_offset(str675), 68},
- {-1}, {-1},
- {uniname2ctype_offset(str678), 171},
- {uniname2ctype_offset(str679), 607},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str683), 267},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str692), 69},
- {-1}, {-1},
- {uniname2ctype_offset(str695), 551},
- {uniname2ctype_offset(str696), 175},
- {uniname2ctype_offset(str697), 399},
- {-1}, {-1},
- {uniname2ctype_offset(str700), 236},
- {-1}, {-1},
- {uniname2ctype_offset(str703), 527},
- {-1},
- {uniname2ctype_offset(str705), 347},
- {-1},
- {uniname2ctype_offset(str707), 158},
- {uniname2ctype_offset(str708), 587},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str713), 376},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str720), 72},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str737), 7},
- {uniname2ctype_offset(str738), 373},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str742), 6},
- {-1}, {-1},
- {uniname2ctype_offset(str745), 269},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str753), 240},
- {-1},
- {uniname2ctype_offset(str755), 514},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str760), 431},
- {uniname2ctype_offset(str761), 167},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str766), 156},
- {uniname2ctype_offset(str767), 608},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str771), 167},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str776), 268},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str783), 156},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str787), 256},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str791), 193},
- {-1}, {-1},
- {uniname2ctype_offset(str794), 589},
- {-1}, {-1},
- {uniname2ctype_offset(str797), 50},
- {-1},
- {uniname2ctype_offset(str799), 617},
- {-1}, {-1},
- {uniname2ctype_offset(str802), 13},
- {uniname2ctype_offset(str803), 593},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str809), 446},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str814), 493},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str818), 398},
- {-1}, {-1},
- {uniname2ctype_offset(str821), 482},
- {uniname2ctype_offset(str822), 595},
- {uniname2ctype_offset(str823), 47},
- {uniname2ctype_offset(str824), 112},
- {uniname2ctype_offset(str825), 444},
- {-1}, {-1},
- {uniname2ctype_offset(str828), 596},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str838), 157},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str842), 58},
- {-1}, {-1},
- {uniname2ctype_offset(str845), 66},
- {-1},
- {uniname2ctype_offset(str847), 48},
- {uniname2ctype_offset(str848), 178},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str855), 67},
- {-1},
- {uniname2ctype_offset(str857), 319},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str875), 369},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str886), 404},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str895), 412},
- {-1}, {-1},
- {uniname2ctype_offset(str898), 500},
- {-1},
- {uniname2ctype_offset(str900), 621},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str906), 521},
- {uniname2ctype_offset(str907), 449},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str920), 419},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str924), 68},
- {uniname2ctype_offset(str925), 599},
- {uniname2ctype_offset(str926), 344},
- {-1},
- {uniname2ctype_offset(str928), 540},
- {uniname2ctype_offset(str929), 461},
- {uniname2ctype_offset(str930), 41},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str946), 136},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str961), 2},
- {-1},
- {uniname2ctype_offset(str963), 257},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str974), 510},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str986), 370},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str994), 85},
- {uniname2ctype_offset(str995), 104},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1010), 26},
- {-1}, {-1},
- {uniname2ctype_offset(str1013), 495},
- {-1},
- {uniname2ctype_offset(str1015), 484},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1021), 67},
- {-1}, {-1},
- {uniname2ctype_offset(str1024), 53},
- {uniname2ctype_offset(str1025), 459},
- {-1}, {-1},
- {uniname2ctype_offset(str1028), 136},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1032), 380},
- {-1}, {-1},
- {uniname2ctype_offset(str1035), 322},
- {uniname2ctype_offset(str1036), 569},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1049), 173},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1067), 102},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1072), 197},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1081), 414},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1085), 259},
- {-1},
- {uniname2ctype_offset(str1087), 600},
- {-1},
- {uniname2ctype_offset(str1089), 115},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1095), 250},
- {uniname2ctype_offset(str1096), 71},
- {uniname2ctype_offset(str1097), 541},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1102), 523},
- {-1},
- {uniname2ctype_offset(str1104), 228},
- {uniname2ctype_offset(str1105), 217},
- {-1},
- {uniname2ctype_offset(str1107), 542},
- {-1},
- {uniname2ctype_offset(str1109), 239},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1114), 69},
- {uniname2ctype_offset(str1115), 11},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1119), 106},
- {uniname2ctype_offset(str1120), 60},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1134), 425},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1140), 93},
- {-1},
- {uniname2ctype_offset(str1142), 206},
- {-1}, {-1},
- {uniname2ctype_offset(str1145), 137},
- {uniname2ctype_offset(str1146), 131},
- {uniname2ctype_offset(str1147), 266},
- {-1},
- {uniname2ctype_offset(str1149), 158},
- {uniname2ctype_offset(str1150), 98},
- {uniname2ctype_offset(str1151), 498},
- {uniname2ctype_offset(str1152), 217},
- {uniname2ctype_offset(str1153), 138},
- {-1}, {-1},
- {uniname2ctype_offset(str1156), 529},
- {uniname2ctype_offset(str1157), 203},
- {uniname2ctype_offset(str1158), 166},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1164), 240},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1168), 104},
- {-1},
- {uniname2ctype_offset(str1170), 389},
- {uniname2ctype_offset(str1171), 536},
- {-1}, {-1},
- {uniname2ctype_offset(str1174), 326},
- {uniname2ctype_offset(str1175), 26},
- {uniname2ctype_offset(str1176), 208},
- {uniname2ctype_offset(str1177), 74},
- {uniname2ctype_offset(str1178), 353},
- {-1},
- {uniname2ctype_offset(str1180), 183},
- {uniname2ctype_offset(str1181), 151},
- {uniname2ctype_offset(str1182), 359},
- {uniname2ctype_offset(str1183), 101},
- {-1},
- {uniname2ctype_offset(str1185), 170},
- {uniname2ctype_offset(str1186), 597},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1190), 272},
- {uniname2ctype_offset(str1191), 545},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1197), 101},
- {uniname2ctype_offset(str1198), 135},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1203), 366},
- {uniname2ctype_offset(str1204), 609},
- {-1}, {-1},
- {uniname2ctype_offset(str1207), 462},
- {-1},
- {uniname2ctype_offset(str1209), 186},
- {-1}, {-1},
- {uniname2ctype_offset(str1212), 379},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str1223), 584},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1227), 243},
- {-1},
- {uniname2ctype_offset(str1229), 235},
- {uniname2ctype_offset(str1230), 267},
- {uniname2ctype_offset(str1231), 206},
- {uniname2ctype_offset(str1232), 355},
- {uniname2ctype_offset(str1233), 73},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1234), 298},
- {uniname2ctype_offset(str1235), 300},
- {uniname2ctype_offset(str1236), 297},
- {uniname2ctype_offset(str1237), 299},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1241), 301},
- {uniname2ctype_offset(str1242), 279},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1243), 25},
- {uniname2ctype_offset(str1244), 341},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1245), 281},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1246), 435},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1247), 280},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1248), 30},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1249), 283},
- {uniname2ctype_offset(str1250), 296},
- {uniname2ctype_offset(str1251), 282},
- {uniname2ctype_offset(str1252), 284},
- {uniname2ctype_offset(str1253), 295},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1254), 566},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1255), 291},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1256), 278},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1257), 290},
- {uniname2ctype_offset(str1258), 292},
- {uniname2ctype_offset(str1259), 303},
- {uniname2ctype_offset(str1260), 294},
- {-1},
- {uniname2ctype_offset(str1262), 293},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1263), 64},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {-1},
- {uniname2ctype_offset(str1265), 302},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1266), 21},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1267), 288},
- {-1},
- {uniname2ctype_offset(str1269), 287},
- {uniname2ctype_offset(str1270), 289},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1271), 250},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {-1},
- {uniname2ctype_offset(str1273), 286},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1274), 200},
-#ifndef USE_UNICODE_AGE_PROPERTIES
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#else /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1275), 285},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#endif /* USE_UNICODE_AGE_PROPERTIES */
- {uniname2ctype_offset(str1282), 635},
- {-1}, {-1},
- {uniname2ctype_offset(str1285), 105},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1289), 348},
- {-1}, {-1},
- {uniname2ctype_offset(str1292), 397},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1297), 145},
- {-1}, {-1},
- {uniname2ctype_offset(str1300), 86},
- {uniname2ctype_offset(str1301), 141},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1306), 15},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1314), 193},
- {-1}, {-1},
- {uniname2ctype_offset(str1317), 86},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str1328), 227},
- {-1}, {-1},
- {uniname2ctype_offset(str1331), 263},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1340), 105},
- {-1}, {-1},
- {uniname2ctype_offset(str1343), 120},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1349), 227},
- {-1}, {-1},
- {uniname2ctype_offset(str1352), 88},
- {-1},
- {uniname2ctype_offset(str1354), 164},
- {-1},
- {uniname2ctype_offset(str1356), 605},
- {-1},
- {uniname2ctype_offset(str1358), 633},
- {-1},
- {uniname2ctype_offset(str1360), 3},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1365), 387},
- {-1},
- {uniname2ctype_offset(str1367), 534},
- {-1},
- {uniname2ctype_offset(str1369), 258},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1373), 274},
- {-1},
- {uniname2ctype_offset(str1375), 135},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1380), 35},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1384), 56},
- {-1}, {-1},
- {uniname2ctype_offset(str1387), 113},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1392), 138},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1400), 201},
- {uniname2ctype_offset(str1401), 400},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1407), 224},
- {-1},
- {uniname2ctype_offset(str1409), 38},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1415), 576},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1419), 140},
- {uniname2ctype_offset(str1420), 140},
- {-1},
- {uniname2ctype_offset(str1422), 324},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1426), 39},
- {-1},
- {uniname2ctype_offset(str1428), 181},
- {uniname2ctype_offset(str1429), 36},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1438), 437},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1442), 544},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1448), 508},
- {uniname2ctype_offset(str1449), 122},
- {-1},
- {uniname2ctype_offset(str1451), 203},
- {-1}, {-1},
- {uniname2ctype_offset(str1454), 145},
- {-1}, {-1},
- {uniname2ctype_offset(str1457), 166},
- {-1}, {-1},
- {uniname2ctype_offset(str1460), 215},
- {-1},
- {uniname2ctype_offset(str1462), 559},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1470), 507},
- {uniname2ctype_offset(str1471), 509},
- {-1}, {-1},
- {uniname2ctype_offset(str1474), 134},
- {uniname2ctype_offset(str1475), 429},
- {uniname2ctype_offset(str1476), 511},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1480), 247},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1489), 33},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1495), 262},
- {-1},
- {uniname2ctype_offset(str1497), 499},
- {-1},
- {uniname2ctype_offset(str1499), 620},
- {-1},
- {uniname2ctype_offset(str1501), 196},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1507), 122},
- {uniname2ctype_offset(str1508), 231},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1517), 619},
- {-1}, {-1},
- {uniname2ctype_offset(str1520), 239},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1524), 486},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1529), 120},
- {-1},
- {uniname2ctype_offset(str1531), 422},
- {-1},
- {uniname2ctype_offset(str1533), 142},
- {-1}, {-1},
- {uniname2ctype_offset(str1536), 127},
- {uniname2ctype_offset(str1537), 271},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1542), 468},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1547), 168},
- {-1},
- {uniname2ctype_offset(str1549), 522},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1557), 85},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1563), 275},
- {-1},
- {uniname2ctype_offset(str1565), 329},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1570), 210},
- {-1},
- {uniname2ctype_offset(str1572), 115},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1577), 570},
- {-1}, {-1},
- {uniname2ctype_offset(str1580), 131},
- {-1},
- {uniname2ctype_offset(str1582), 219},
- {uniname2ctype_offset(str1583), 125},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1587), 550},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1597), 81},
- {uniname2ctype_offset(str1598), 219},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1607), 592},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1613), 164},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1617), 505},
- {uniname2ctype_offset(str1618), 274},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1622), 388},
- {uniname2ctype_offset(str1623), 573},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1629), 39},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1635), 72},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1643), 62},
- {uniname2ctype_offset(str1644), 235},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1654), 403},
- {uniname2ctype_offset(str1655), 276},
- {-1},
- {uniname2ctype_offset(str1657), 114},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1662), 129},
- {-1},
- {uniname2ctype_offset(str1664), 451},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1671), 343},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1675), 472},
- {-1},
- {uniname2ctype_offset(str1677), 317},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1682), 634},
- {-1},
- {uniname2ctype_offset(str1684), 199},
- {-1},
- {uniname2ctype_offset(str1686), 93},
- {uniname2ctype_offset(str1687), 141},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1691), 124},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1699), 382},
- {-1},
- {uniname2ctype_offset(str1701), 525},
- {-1}, {-1},
- {uniname2ctype_offset(str1704), 207},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1714), 207},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1722), 362},
- {-1},
- {uniname2ctype_offset(str1724), 582},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1728), 221},
- {uniname2ctype_offset(str1729), 445},
- {uniname2ctype_offset(str1730), 222},
- {uniname2ctype_offset(str1731), 538},
- {uniname2ctype_offset(str1732), 249},
- {uniname2ctype_offset(str1733), 123},
- {uniname2ctype_offset(str1734), 114},
- {uniname2ctype_offset(str1735), 260},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1740), 129},
- {-1},
- {uniname2ctype_offset(str1742), 161},
- {-1}, {-1},
- {uniname2ctype_offset(str1745), 528},
- {uniname2ctype_offset(str1746), 405},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1750), 20},
- {-1},
- {uniname2ctype_offset(str1752), 519},
- {uniname2ctype_offset(str1753), 148},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1757), 518},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1766), 73},
- {-1},
- {uniname2ctype_offset(str1768), 148},
- {uniname2ctype_offset(str1769), 377},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1776), 126},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1781), 556},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1788), 97},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1793), 97},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1806), 351},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1810), 640},
- {uniname2ctype_offset(str1811), 247},
- {-1},
- {uniname2ctype_offset(str1813), 266},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1821), 224},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1828), 402},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1838), 623},
- {-1}, {-1},
- {uniname2ctype_offset(str1841), 460},
- {uniname2ctype_offset(str1842), 394},
- {uniname2ctype_offset(str1843), 65},
- {-1},
- {uniname2ctype_offset(str1845), 265},
- {-1}, {-1},
- {uniname2ctype_offset(str1848), 109},
- {-1}, {-1},
- {uniname2ctype_offset(str1851), 137},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1866), 61},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1871), 494},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1881), 63},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1888), 531},
- {uniname2ctype_offset(str1889), 555},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1896), 626},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1902), 434},
- {-1},
- {uniname2ctype_offset(str1904), 455},
- {uniname2ctype_offset(str1905), 590},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1912), 586},
- {uniname2ctype_offset(str1913), 143},
- {-1}, {-1},
- {uniname2ctype_offset(str1916), 594},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1924), 143},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1929), 432},
- {-1}, {-1},
- {uniname2ctype_offset(str1932), 415},
- {-1}, {-1},
- {uniname2ctype_offset(str1935), 264},
- {uniname2ctype_offset(str1936), 338},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1941), 27},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1950), 424},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1956), 252},
- {-1},
- {uniname2ctype_offset(str1958), 109},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1964), 440},
- {-1}, {-1},
- {uniname2ctype_offset(str1967), 492},
- {uniname2ctype_offset(str1968), 644},
- {uniname2ctype_offset(str1969), 251},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1974), 358},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1981), 176},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str1985), 408},
- {-1}, {-1},
- {uniname2ctype_offset(str1988), 441},
- {-1}, {-1},
- {uniname2ctype_offset(str1991), 1},
- {-1},
- {uniname2ctype_offset(str1993), 375},
- {uniname2ctype_offset(str1994), 175},
- {-1},
- {uniname2ctype_offset(str1996), 42},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2001), 110},
- {uniname2ctype_offset(str2002), 598},
- {-1},
- {uniname2ctype_offset(str2004), 110},
- {-1},
- {uniname2ctype_offset(str2006), 410},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2010), 378},
- {uniname2ctype_offset(str2011), 269},
- {uniname2ctype_offset(str2012), 565},
- {-1},
- {uniname2ctype_offset(str2014), 336},
- {uniname2ctype_offset(str2015), 117},
- {uniname2ctype_offset(str2016), 209},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2023), 32},
- {uniname2ctype_offset(str2024), 506},
- {-1},
- {uniname2ctype_offset(str2026), 176},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2033), 8},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2040), 539},
- {-1},
- {uniname2ctype_offset(str2042), 121},
- {uniname2ctype_offset(str2043), 17},
- {uniname2ctype_offset(str2044), 117},
- {-1}, {-1},
- {uniname2ctype_offset(str2047), 107},
- {uniname2ctype_offset(str2048), 526},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2062), 130},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2070), 9},
- {-1}, {-1},
- {uniname2ctype_offset(str2073), 345},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2077), 150},
- {uniname2ctype_offset(str2078), 256},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2090), 277},
- {-1},
- {uniname2ctype_offset(str2092), 150},
- {-1}, {-1},
- {uniname2ctype_offset(str2095), 356},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2103), 162},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2110), 123},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2114), 439},
- {uniname2ctype_offset(str2115), 384},
- {-1},
- {uniname2ctype_offset(str2117), 174},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2128), 215},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2135), 128},
- {-1},
- {uniname2ctype_offset(str2137), 12},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2141), 244},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2145), 52},
- {uniname2ctype_offset(str2146), 416},
- {-1}, {-1},
- {uniname2ctype_offset(str2149), 221},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2163), 251},
- {-1},
- {uniname2ctype_offset(str2165), 174},
- {uniname2ctype_offset(str2166), 5},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2174), 233},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2178), 233},
- {-1}, {-1},
- {uniname2ctype_offset(str2181), 139},
- {uniname2ctype_offset(str2182), 216},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2195), 354},
- {uniname2ctype_offset(str2196), 496},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2207), 196},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2211), 20},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2216), 367},
- {uniname2ctype_offset(str2217), 128},
- {uniname2ctype_offset(str2218), 547},
- {uniname2ctype_offset(str2219), 78},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2224), 453},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2228), 43},
- {uniname2ctype_offset(str2229), 35},
- {-1}, {-1},
- {uniname2ctype_offset(str2232), 385},
- {uniname2ctype_offset(str2233), 216},
- {uniname2ctype_offset(str2234), 92},
- {uniname2ctype_offset(str2235), 489},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2241), 92},
- {-1}, {-1},
- {uniname2ctype_offset(str2244), 443},
- {-1}, {-1},
- {uniname2ctype_offset(str2247), 36},
- {uniname2ctype_offset(str2248), 602},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2276), 418},
- {-1},
- {uniname2ctype_offset(str2278), 124},
- {uniname2ctype_offset(str2279), 192},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2283), 214},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2296), 639},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2305), 205},
- {-1}, {-1},
- {uniname2ctype_offset(str2308), 234},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2312), 177},
- {-1}, {-1},
- {uniname2ctype_offset(str2315), 601},
- {uniname2ctype_offset(str2316), 638},
- {-1},
- {uniname2ctype_offset(str2318), 202},
- {-1}, {-1},
- {uniname2ctype_offset(str2321), 153},
- {-1},
- {uniname2ctype_offset(str2323), 172},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2327), 381},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2331), 636},
- {-1},
- {uniname2ctype_offset(str2333), 134},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2343), 591},
- {uniname2ctype_offset(str2344), 442},
- {uniname2ctype_offset(str2345), 241},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2353), 202},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2361), 606},
- {-1}, {-1},
- {uniname2ctype_offset(str2364), 323},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2373), 37},
- {uniname2ctype_offset(str2374), 392},
- {uniname2ctype_offset(str2375), 197},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2397), 421},
- {uniname2ctype_offset(str2398), 413},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2405), 165},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2414), 82},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2427), 23},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2433), 339},
- {uniname2ctype_offset(str2434), 154},
- {-1}, {-1},
- {uniname2ctype_offset(str2437), 194},
- {-1}, {-1},
- {uniname2ctype_offset(str2440), 100},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2451), 103},
- {-1}, {-1},
- {uniname2ctype_offset(str2454), 220},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2460), 257},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2464), 159},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2470), 448},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2475), 142},
- {uniname2ctype_offset(str2476), 558},
- {-1},
- {uniname2ctype_offset(str2478), 417},
- {uniname2ctype_offset(str2479), 361},
- {-1},
- {uniname2ctype_offset(str2481), 386},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2500), 121},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2506), 532},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2511), 244},
- {-1},
- {uniname2ctype_offset(str2513), 630},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2530), 82},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2534), 340},
- {uniname2ctype_offset(str2535), 237},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2545), 277},
- {-1}, {-1},
- {uniname2ctype_offset(str2548), 118},
- {uniname2ctype_offset(str2549), 159},
- {-1},
- {uniname2ctype_offset(str2551), 89},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2564), 372},
- {-1}, {-1},
- {uniname2ctype_offset(str2567), 318},
- {-1}, {-1},
- {uniname2ctype_offset(str2570), 491},
- {-1},
- {uniname2ctype_offset(str2572), 473},
- {-1},
- {uniname2ctype_offset(str2574), 246},
- {uniname2ctype_offset(str2575), 474},
- {uniname2ctype_offset(str2576), 275},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2582), 391},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2588), 154},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2602), 210},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2606), 374},
- {-1},
- {uniname2ctype_offset(str2608), 458},
- {uniname2ctype_offset(str2609), 55},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2625), 262},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2648), 254},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2652), 383},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2656), 368},
- {uniname2ctype_offset(str2657), 112},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2665), 87},
- {uniname2ctype_offset(str2666), 50},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2670), 632},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2674), 87},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2688), 139},
- {uniname2ctype_offset(str2689), 641},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2694), 48},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2705), 481},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2726), 226},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2750), 557},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2761), 18},
- {uniname2ctype_offset(str2762), 265},
- {-1}, {-1},
- {uniname2ctype_offset(str2765), 133},
- {uniname2ctype_offset(str2766), 54},
- {-1}, {-1},
- {uniname2ctype_offset(str2769), 483},
- {-1}, {-1},
- {uniname2ctype_offset(str2772), 199},
- {-1}, {-1},
- {uniname2ctype_offset(str2775), 38},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2786), 4},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2793), 34},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2801), 29},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2808), 512},
- {-1},
- {uniname2ctype_offset(str2810), 226},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2816), 310},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2821), 393},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2830), 614},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2834), 364},
- {-1},
- {uniname2ctype_offset(str2836), 78},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2847), 248},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2852), 305},
- {-1}, {-1},
- {uniname2ctype_offset(str2855), 190},
- {uniname2ctype_offset(str2856), 66},
- {-1}, {-1},
- {uniname2ctype_offset(str2859), 427},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2867), 309},
- {uniname2ctype_offset(str2868), 248},
- {-1}, {-1},
- {uniname2ctype_offset(str2871), 254},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2879), 204},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2886), 631},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2902), 477},
- {-1},
- {uniname2ctype_offset(str2904), 464},
- {uniname2ctype_offset(str2905), 273},
- {-1},
- {uniname2ctype_offset(str2907), 273},
- {-1},
- {uniname2ctype_offset(str2909), 577},
- {-1},
- {uniname2ctype_offset(str2911), 450},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2941), 363},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str2953), 198},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str2964), 520},
- {-1},
- {uniname2ctype_offset(str2966), 238},
- {uniname2ctype_offset(str2967), 43},
- {-1}, {-1},
- {uniname2ctype_offset(str2970), 88},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2980), 195},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2984), 574},
- {-1},
- {uniname2ctype_offset(str2986), 118},
- {uniname2ctype_offset(str2987), 54},
- {uniname2ctype_offset(str2988), 471},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str2997), 603},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3001), 180},
- {uniname2ctype_offset(str3002), 64},
- {-1}, {-1},
- {uniname2ctype_offset(str3005), 475},
- {uniname2ctype_offset(str3006), 583},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3015), 83},
- {-1}, {-1},
- {uniname2ctype_offset(str3018), 94},
- {uniname2ctype_offset(str3019), 165},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3026), 83},
- {uniname2ctype_offset(str3027), 503},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3035), 232},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3042), 211},
- {-1}, {-1},
- {uniname2ctype_offset(str3045), 615},
- {-1}, {-1},
- {uniname2ctype_offset(str3048), 119},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3052), 89},
- {uniname2ctype_offset(str3053), 229},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3058), 185},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3067), 185},
- {uniname2ctype_offset(str3068), 99},
- {-1}, {-1},
- {uniname2ctype_offset(str3071), 198},
- {uniname2ctype_offset(str3072), 133},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3082), 130},
- {-1},
- {uniname2ctype_offset(str3084), 237},
- {-1},
- {uniname2ctype_offset(str3086), 84},
- {uniname2ctype_offset(str3087), 342},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3091), 261},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3099), 478},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3104), 84},
- {-1},
- {uniname2ctype_offset(str3106), 562},
- {uniname2ctype_offset(str3107), 313},
- {-1},
- {uniname2ctype_offset(str3109), 315},
- {uniname2ctype_offset(str3110), 152},
- {uniname2ctype_offset(str3111), 191},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3118), 90},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3123), 107},
- {-1},
- {uniname2ctype_offset(str3125), 191},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3135), 452},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3142), 585},
- {-1}, {-1},
- {uniname2ctype_offset(str3145), 183},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3155), 182},
- {-1},
- {uniname2ctype_offset(str3157), 231},
- {uniname2ctype_offset(str3158), 328},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3176), 396},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3180), 331},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3193), 433},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3209), 62},
- {-1}, {-1},
- {uniname2ctype_offset(str3212), 211},
- {-1}, {-1},
- {uniname2ctype_offset(str3215), 180},
- {-1}, {-1},
- {uniname2ctype_offset(str3218), 125},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3237), 390},
- {-1},
- {uniname2ctype_offset(str3239), 308},
- {uniname2ctype_offset(str3240), 304},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3248), 213},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3254), 252},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3265), 610},
- {-1},
- {uniname2ctype_offset(str3267), 28},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3275), 146},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3284), 618},
- {-1}, {-1},
- {uniname2ctype_offset(str3287), 223},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3297), 311},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3303), 307},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3313), 255},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3320), 223},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3328), 63},
- {uniname2ctype_offset(str3329), 625},
- {-1},
- {uniname2ctype_offset(str3331), 222},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3338), 264},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3348), 407},
- {-1},
- {uniname2ctype_offset(str3350), 501},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3355), 47},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3360), 337},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3371), 126},
- {uniname2ctype_offset(str3372), 16},
- {uniname2ctype_offset(str3373), 253},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3377), 147},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3391), 238},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3396), 613},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3405), 469},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3416), 51},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3428), 253},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3433), 205},
- {-1}, {-1},
- {uniname2ctype_offset(str3436), 213},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3455), 225},
- {-1}, {-1},
- {uniname2ctype_offset(str3458), 10},
- {-1},
- {uniname2ctype_offset(str3460), 627},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3483), 245},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3502), 49},
- {-1},
- {uniname2ctype_offset(str3504), 80},
- {uniname2ctype_offset(str3505), 479},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3511), 411},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3532), 578},
- {uniname2ctype_offset(str3533), 57},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3558), 59},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3580), 179},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3590), 103},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3613), 41},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3618), 99},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3648), 465},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3659), 178},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3664), 177},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3686), 204},
- {-1}, {-1},
- {uniname2ctype_offset(str3689), 246},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3698), 504},
- {uniname2ctype_offset(str3699), 552},
- {-1},
- {uniname2ctype_offset(str3701), 96},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3705), 320},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3710), 201},
- {-1}, {-1},
- {uniname2ctype_offset(str3713), 96},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3721), 438},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3744), 190},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3754), 71},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str3766), 467},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3799), 214},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3807), 260},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3842), 182},
- {-1}, {-1},
- {uniname2ctype_offset(str3845), 259},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3850), 245},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3854), 65},
- {-1}, {-1},
- {uniname2ctype_offset(str3857), 616},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str3868), 261},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3881), 228},
- {-1}, {-1},
- {uniname2ctype_offset(str3884), 306},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3891), 30},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3924), 420},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3942), 100},
- {-1},
- {uniname2ctype_offset(str3944), 436},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3949), 276},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3976), 604},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str3998), 430},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4007), 454},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4106), 45},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4116), 132},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str4127), 132},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4169), 220},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4231), 153},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4308), 401},
- {uniname2ctype_offset(str4309), 162},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4348), 571},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4361), 572},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4459), 119},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4487), 147},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4604), 116},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4626), 116},
- {uniname2ctype_offset(str4627), 255},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str4674), 642},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4683), 466},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4695), 80},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4734), 179},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4755), 312},
- {uniname2ctype_offset(str4756), 314},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4772), 409},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str4783), 316},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4810), 90},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4898), 75},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1},
- {uniname2ctype_offset(str4982), 232},
- {-1}, {-1}, {-1},
- {uniname2ctype_offset(str4986), 428},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str5018), 46},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1},
- {uniname2ctype_offset(str5038), 242},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str5134), 628},
-#endif /* USE_UNICODE_PROPERTIES */
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#ifndef USE_UNICODE_PROPERTIES
- {uniname2ctype_offset(str6), 12},
- {uniname2ctype_offset(str7), 7},
- {uniname2ctype_offset(str8), 15},
- {uniname2ctype_offset(str9), 1},
- {uniname2ctype_offset(str10), 13},
- {uniname2ctype_offset(str11), 11},
- {uniname2ctype_offset(str12), 10},
- {uniname2ctype_offset(str13), 14},
- {uniname2ctype_offset(str14), 3},
- {uniname2ctype_offset(str15), 9},
- {uniname2ctype_offset(str16), 8},
- {uniname2ctype_offset(str17), 6},
- {uniname2ctype_offset(str18), 5},
- {uniname2ctype_offset(str19), 4},
- {uniname2ctype_offset(str20), 2}
-#else /* USE_UNICODE_PROPERTIES */
- {uniname2ctype_offset(str5141), 155},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str5300), 225},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str5980), 155},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {uniname2ctype_offset(str6098), 643}
-#endif /* USE_UNICODE_PROPERTIES */
- };
-
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- {
- register unsigned int key = uniname2ctype_hash (str, len);
-
- if (key <= MAX_HASH_VALUE)
- {
- register int o = wordlist[key].name;
- if (o >= 0)
- {
- register const char *s = o + uniname2ctype_pool;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &wordlist[key];
- }
- }
- }
- return 0;
-}
-
-static int
-uniname2ctype(const UChar *name, unsigned int len)
-{
- const struct uniname2ctype_struct *p = uniname2ctype_p((const char *)name, len);
- if (p) return p->ctype;
- return -1;
-}
-#if defined ONIG_UNICODE_VERSION_STRING && !( \
- ONIG_UNICODE_VERSION_MAJOR == 15 && \
- ONIG_UNICODE_VERSION_MINOR == 0 && \
- ONIG_UNICODE_VERSION_TEENY == 0 && \
- 1)
-# error ONIG_UNICODE_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_VERSION_STRING "15.0.0"
-#define ONIG_UNICODE_VERSION_MAJOR 15
-#define ONIG_UNICODE_VERSION_MINOR 0
-#define ONIG_UNICODE_VERSION_TEENY 0
-#if defined ONIG_UNICODE_EMOJI_VERSION_STRING && !( \
- ONIG_UNICODE_EMOJI_VERSION_MAJOR == 15 && \
- ONIG_UNICODE_EMOJI_VERSION_MINOR == 0 && \
- 1)
-# error ONIG_UNICODE_EMOJI_VERSION_STRING mismatch
-#endif
-#define ONIG_UNICODE_EMOJI_VERSION_STRING "15.0"
-#define ONIG_UNICODE_EMOJI_VERSION_MAJOR 15
-#define ONIG_UNICODE_EMOJI_VERSION_MINOR 0
diff --git a/enc/unicode/17.0.0/casefold.h b/enc/unicode/17.0.0/casefold.h
new file mode 100644
index 0000000000..82439f35fb
--- /dev/null
+++ b/enc/unicode/17.0.0/casefold.h
@@ -0,0 +1,8013 @@
+/* DO NOT EDIT THIS FILE. */
+/* Generated by enc-case-folding.rb */
+
+#if defined ONIG_UNICODE_VERSION_STRING && !( \
+ ONIG_UNICODE_VERSION_MAJOR == 17 && \
+ ONIG_UNICODE_VERSION_MINOR == 0 && \
+ ONIG_UNICODE_VERSION_TEENY == 0 && \
+ 1)
+# error ONIG_UNICODE_VERSION_STRING mismatch
+#endif
+#define ONIG_UNICODE_VERSION_STRING "17.0.0"
+#define ONIG_UNICODE_VERSION_MAJOR 17
+#define ONIG_UNICODE_VERSION_MINOR 0
+#define ONIG_UNICODE_VERSION_TEENY 0
+
+static const CaseFold_11_Type CaseFold_11_Table[] = {
+#define CaseFold (*(CaseFold_11_Type (*)[1583])(CaseFold_11_Table+0))
+ {0x0041, {1|F|D, {0x0061}}},
+ {0x0042, {1|F|D, {0x0062}}},
+ {0x0043, {1|F|D, {0x0063}}},
+ {0x0044, {1|F|D, {0x0064}}},
+ {0x0045, {1|F|D, {0x0065}}},
+ {0x0046, {1|F|D, {0x0066}}},
+ {0x0047, {1|F|D, {0x0067}}},
+ {0x0048, {1|F|D, {0x0068}}},
+ {0x004a, {1|F|D, {0x006a}}},
+ {0x004b, {1|F|D, {0x006b}}},
+ {0x004c, {1|F|D, {0x006c}}},
+ {0x004d, {1|F|D, {0x006d}}},
+ {0x004e, {1|F|D, {0x006e}}},
+ {0x004f, {1|F|D, {0x006f}}},
+ {0x0050, {1|F|D, {0x0070}}},
+ {0x0051, {1|F|D, {0x0071}}},
+ {0x0052, {1|F|D, {0x0072}}},
+ {0x0053, {1|F|D, {0x0073}}},
+ {0x0054, {1|F|D, {0x0074}}},
+ {0x0055, {1|F|D, {0x0075}}},
+ {0x0056, {1|F|D, {0x0076}}},
+ {0x0057, {1|F|D, {0x0077}}},
+ {0x0058, {1|F|D, {0x0078}}},
+ {0x0059, {1|F|D, {0x0079}}},
+ {0x005a, {1|F|D, {0x007a}}},
+ {0x00b5, {1|F|SU|I(0), {0x03bc}}},
+ {0x00c0, {1|F|D, {0x00e0}}},
+ {0x00c1, {1|F|D, {0x00e1}}},
+ {0x00c2, {1|F|D, {0x00e2}}},
+ {0x00c3, {1|F|D, {0x00e3}}},
+ {0x00c4, {1|F|D, {0x00e4}}},
+ {0x00c5, {1|F|D, {0x00e5}}},
+ {0x00c6, {1|F|D, {0x00e6}}},
+ {0x00c7, {1|F|D, {0x00e7}}},
+ {0x00c8, {1|F|D, {0x00e8}}},
+ {0x00c9, {1|F|D, {0x00e9}}},
+ {0x00ca, {1|F|D, {0x00ea}}},
+ {0x00cb, {1|F|D, {0x00eb}}},
+ {0x00cc, {1|F|D, {0x00ec}}},
+ {0x00cd, {1|F|D, {0x00ed}}},
+ {0x00ce, {1|F|D, {0x00ee}}},
+ {0x00cf, {1|F|D, {0x00ef}}},
+ {0x00d0, {1|F|D, {0x00f0}}},
+ {0x00d1, {1|F|D, {0x00f1}}},
+ {0x00d2, {1|F|D, {0x00f2}}},
+ {0x00d3, {1|F|D, {0x00f3}}},
+ {0x00d4, {1|F|D, {0x00f4}}},
+ {0x00d5, {1|F|D, {0x00f5}}},
+ {0x00d6, {1|F|D, {0x00f6}}},
+ {0x00d8, {1|F|D, {0x00f8}}},
+ {0x00d9, {1|F|D, {0x00f9}}},
+ {0x00da, {1|F|D, {0x00fa}}},
+ {0x00db, {1|F|D, {0x00fb}}},
+ {0x00dc, {1|F|D, {0x00fc}}},
+ {0x00dd, {1|F|D, {0x00fd}}},
+ {0x00de, {1|F|D, {0x00fe}}},
+ {0x00df, {2|F|ST|SU|I(1), {0x0073, 0x0073}}},
+ {0x0100, {1|F|D, {0x0101}}},
+ {0x0102, {1|F|D, {0x0103}}},
+ {0x0104, {1|F|D, {0x0105}}},
+ {0x0106, {1|F|D, {0x0107}}},
+ {0x0108, {1|F|D, {0x0109}}},
+ {0x010a, {1|F|D, {0x010b}}},
+ {0x010c, {1|F|D, {0x010d}}},
+ {0x010e, {1|F|D, {0x010f}}},
+ {0x0110, {1|F|D, {0x0111}}},
+ {0x0112, {1|F|D, {0x0113}}},
+ {0x0114, {1|F|D, {0x0115}}},
+ {0x0116, {1|F|D, {0x0117}}},
+ {0x0118, {1|F|D, {0x0119}}},
+ {0x011a, {1|F|D, {0x011b}}},
+ {0x011c, {1|F|D, {0x011d}}},
+ {0x011e, {1|F|D, {0x011f}}},
+ {0x0120, {1|F|D, {0x0121}}},
+ {0x0122, {1|F|D, {0x0123}}},
+ {0x0124, {1|F|D, {0x0125}}},
+ {0x0126, {1|F|D, {0x0127}}},
+ {0x0128, {1|F|D, {0x0129}}},
+ {0x012a, {1|F|D, {0x012b}}},
+ {0x012c, {1|F|D, {0x012d}}},
+ {0x012e, {1|F|D, {0x012f}}},
+ {0x0132, {1|F|D, {0x0133}}},
+ {0x0134, {1|F|D, {0x0135}}},
+ {0x0136, {1|F|D, {0x0137}}},
+ {0x0139, {1|F|D, {0x013a}}},
+ {0x013b, {1|F|D, {0x013c}}},
+ {0x013d, {1|F|D, {0x013e}}},
+ {0x013f, {1|F|D, {0x0140}}},
+ {0x0141, {1|F|D, {0x0142}}},
+ {0x0143, {1|F|D, {0x0144}}},
+ {0x0145, {1|F|D, {0x0146}}},
+ {0x0147, {1|F|D, {0x0148}}},
+ {0x0149, {2|F|SU|I(5), {0x02bc, 0x006e}}},
+ {0x014a, {1|F|D, {0x014b}}},
+ {0x014c, {1|F|D, {0x014d}}},
+ {0x014e, {1|F|D, {0x014f}}},
+ {0x0150, {1|F|D, {0x0151}}},
+ {0x0152, {1|F|D, {0x0153}}},
+ {0x0154, {1|F|D, {0x0155}}},
+ {0x0156, {1|F|D, {0x0157}}},
+ {0x0158, {1|F|D, {0x0159}}},
+ {0x015a, {1|F|D, {0x015b}}},
+ {0x015c, {1|F|D, {0x015d}}},
+ {0x015e, {1|F|D, {0x015f}}},
+ {0x0160, {1|F|D, {0x0161}}},
+ {0x0162, {1|F|D, {0x0163}}},
+ {0x0164, {1|F|D, {0x0165}}},
+ {0x0166, {1|F|D, {0x0167}}},
+ {0x0168, {1|F|D, {0x0169}}},
+ {0x016a, {1|F|D, {0x016b}}},
+ {0x016c, {1|F|D, {0x016d}}},
+ {0x016e, {1|F|D, {0x016f}}},
+ {0x0170, {1|F|D, {0x0171}}},
+ {0x0172, {1|F|D, {0x0173}}},
+ {0x0174, {1|F|D, {0x0175}}},
+ {0x0176, {1|F|D, {0x0177}}},
+ {0x0178, {1|F|D, {0x00ff}}},
+ {0x0179, {1|F|D, {0x017a}}},
+ {0x017b, {1|F|D, {0x017c}}},
+ {0x017d, {1|F|D, {0x017e}}},
+ {0x017f, {1|F|SU|I(7), {0x0073}}},
+ {0x0181, {1|F|D, {0x0253}}},
+ {0x0182, {1|F|D, {0x0183}}},
+ {0x0184, {1|F|D, {0x0185}}},
+ {0x0186, {1|F|D, {0x0254}}},
+ {0x0187, {1|F|D, {0x0188}}},
+ {0x0189, {1|F|D, {0x0256}}},
+ {0x018a, {1|F|D, {0x0257}}},
+ {0x018b, {1|F|D, {0x018c}}},
+ {0x018e, {1|F|D, {0x01dd}}},
+ {0x018f, {1|F|D, {0x0259}}},
+ {0x0190, {1|F|D, {0x025b}}},
+ {0x0191, {1|F|D, {0x0192}}},
+ {0x0193, {1|F|D, {0x0260}}},
+ {0x0194, {1|F|D, {0x0263}}},
+ {0x0196, {1|F|D, {0x0269}}},
+ {0x0197, {1|F|D, {0x0268}}},
+ {0x0198, {1|F|D, {0x0199}}},
+ {0x019c, {1|F|D, {0x026f}}},
+ {0x019d, {1|F|D, {0x0272}}},
+ {0x019f, {1|F|D, {0x0275}}},
+ {0x01a0, {1|F|D, {0x01a1}}},
+ {0x01a2, {1|F|D, {0x01a3}}},
+ {0x01a4, {1|F|D, {0x01a5}}},
+ {0x01a6, {1|F|D, {0x0280}}},
+ {0x01a7, {1|F|D, {0x01a8}}},
+ {0x01a9, {1|F|D, {0x0283}}},
+ {0x01ac, {1|F|D, {0x01ad}}},
+ {0x01ae, {1|F|D, {0x0288}}},
+ {0x01af, {1|F|D, {0x01b0}}},
+ {0x01b1, {1|F|D, {0x028a}}},
+ {0x01b2, {1|F|D, {0x028b}}},
+ {0x01b3, {1|F|D, {0x01b4}}},
+ {0x01b5, {1|F|D, {0x01b6}}},
+ {0x01b7, {1|F|D, {0x0292}}},
+ {0x01b8, {1|F|D, {0x01b9}}},
+ {0x01bc, {1|F|D, {0x01bd}}},
+ {0x01c4, {1|F|D|ST|I(8), {0x01c6}}},
+ {0x01c5, {1|F|D|IT|SU|I(9), {0x01c6}}},
+ {0x01c7, {1|F|D|ST|I(12), {0x01c9}}},
+ {0x01c8, {1|F|D|IT|SU|I(13), {0x01c9}}},
+ {0x01ca, {1|F|D|ST|I(16), {0x01cc}}},
+ {0x01cb, {1|F|D|IT|SU|I(17), {0x01cc}}},
+ {0x01cd, {1|F|D, {0x01ce}}},
+ {0x01cf, {1|F|D, {0x01d0}}},
+ {0x01d1, {1|F|D, {0x01d2}}},
+ {0x01d3, {1|F|D, {0x01d4}}},
+ {0x01d5, {1|F|D, {0x01d6}}},
+ {0x01d7, {1|F|D, {0x01d8}}},
+ {0x01d9, {1|F|D, {0x01da}}},
+ {0x01db, {1|F|D, {0x01dc}}},
+ {0x01de, {1|F|D, {0x01df}}},
+ {0x01e0, {1|F|D, {0x01e1}}},
+ {0x01e2, {1|F|D, {0x01e3}}},
+ {0x01e4, {1|F|D, {0x01e5}}},
+ {0x01e6, {1|F|D, {0x01e7}}},
+ {0x01e8, {1|F|D, {0x01e9}}},
+ {0x01ea, {1|F|D, {0x01eb}}},
+ {0x01ec, {1|F|D, {0x01ed}}},
+ {0x01ee, {1|F|D, {0x01ef}}},
+ {0x01f0, {2|F|SU|I(20), {0x006a, 0x030c}}},
+ {0x01f1, {1|F|D|ST|I(22), {0x01f3}}},
+ {0x01f2, {1|F|D|IT|SU|I(23), {0x01f3}}},
+ {0x01f4, {1|F|D, {0x01f5}}},
+ {0x01f6, {1|F|D, {0x0195}}},
+ {0x01f7, {1|F|D, {0x01bf}}},
+ {0x01f8, {1|F|D, {0x01f9}}},
+ {0x01fa, {1|F|D, {0x01fb}}},
+ {0x01fc, {1|F|D, {0x01fd}}},
+ {0x01fe, {1|F|D, {0x01ff}}},
+ {0x0200, {1|F|D, {0x0201}}},
+ {0x0202, {1|F|D, {0x0203}}},
+ {0x0204, {1|F|D, {0x0205}}},
+ {0x0206, {1|F|D, {0x0207}}},
+ {0x0208, {1|F|D, {0x0209}}},
+ {0x020a, {1|F|D, {0x020b}}},
+ {0x020c, {1|F|D, {0x020d}}},
+ {0x020e, {1|F|D, {0x020f}}},
+ {0x0210, {1|F|D, {0x0211}}},
+ {0x0212, {1|F|D, {0x0213}}},
+ {0x0214, {1|F|D, {0x0215}}},
+ {0x0216, {1|F|D, {0x0217}}},
+ {0x0218, {1|F|D, {0x0219}}},
+ {0x021a, {1|F|D, {0x021b}}},
+ {0x021c, {1|F|D, {0x021d}}},
+ {0x021e, {1|F|D, {0x021f}}},
+ {0x0220, {1|F|D, {0x019e}}},
+ {0x0222, {1|F|D, {0x0223}}},
+ {0x0224, {1|F|D, {0x0225}}},
+ {0x0226, {1|F|D, {0x0227}}},
+ {0x0228, {1|F|D, {0x0229}}},
+ {0x022a, {1|F|D, {0x022b}}},
+ {0x022c, {1|F|D, {0x022d}}},
+ {0x022e, {1|F|D, {0x022f}}},
+ {0x0230, {1|F|D, {0x0231}}},
+ {0x0232, {1|F|D, {0x0233}}},
+ {0x023a, {1|F|D, {0x2c65}}},
+ {0x023b, {1|F|D, {0x023c}}},
+ {0x023d, {1|F|D, {0x019a}}},
+ {0x023e, {1|F|D, {0x2c66}}},
+ {0x0241, {1|F|D, {0x0242}}},
+ {0x0243, {1|F|D, {0x0180}}},
+ {0x0244, {1|F|D, {0x0289}}},
+ {0x0245, {1|F|D, {0x028c}}},
+ {0x0246, {1|F|D, {0x0247}}},
+ {0x0248, {1|F|D, {0x0249}}},
+ {0x024a, {1|F|D, {0x024b}}},
+ {0x024c, {1|F|D, {0x024d}}},
+ {0x024e, {1|F|D, {0x024f}}},
+ {0x0345, {1|F|SU|I(26), {0x03b9}}},
+ {0x0370, {1|F|D, {0x0371}}},
+ {0x0372, {1|F|D, {0x0373}}},
+ {0x0376, {1|F|D, {0x0377}}},
+ {0x037f, {1|F|D, {0x03f3}}},
+ {0x0386, {1|F|D, {0x03ac}}},
+ {0x0388, {1|F|D, {0x03ad}}},
+ {0x0389, {1|F|D, {0x03ae}}},
+ {0x038a, {1|F|D, {0x03af}}},
+ {0x038c, {1|F|D, {0x03cc}}},
+ {0x038e, {1|F|D, {0x03cd}}},
+ {0x038f, {1|F|D, {0x03ce}}},
+ {0x0390, {3|F|SU|I(27), {0x03b9, 0x0308, 0x0301}}},
+ {0x0391, {1|F|D, {0x03b1}}},
+ {0x0392, {1|F|D, {0x03b2}}},
+ {0x0393, {1|F|D, {0x03b3}}},
+ {0x0394, {1|F|D, {0x03b4}}},
+ {0x0395, {1|F|D, {0x03b5}}},
+ {0x0396, {1|F|D, {0x03b6}}},
+ {0x0397, {1|F|D, {0x03b7}}},
+ {0x0398, {1|F|D, {0x03b8}}},
+ {0x0399, {1|F|D, {0x03b9}}},
+ {0x039a, {1|F|D, {0x03ba}}},
+ {0x039b, {1|F|D, {0x03bb}}},
+ {0x039c, {1|F|D, {0x03bc}}},
+ {0x039d, {1|F|D, {0x03bd}}},
+ {0x039e, {1|F|D, {0x03be}}},
+ {0x039f, {1|F|D, {0x03bf}}},
+ {0x03a0, {1|F|D, {0x03c0}}},
+ {0x03a1, {1|F|D, {0x03c1}}},
+ {0x03a3, {1|F|D, {0x03c3}}},
+ {0x03a4, {1|F|D, {0x03c4}}},
+ {0x03a5, {1|F|D, {0x03c5}}},
+ {0x03a6, {1|F|D, {0x03c6}}},
+ {0x03a7, {1|F|D, {0x03c7}}},
+ {0x03a8, {1|F|D, {0x03c8}}},
+ {0x03a9, {1|F|D, {0x03c9}}},
+ {0x03aa, {1|F|D, {0x03ca}}},
+ {0x03ab, {1|F|D, {0x03cb}}},
+ {0x03b0, {3|F|SU|I(30), {0x03c5, 0x0308, 0x0301}}},
+ {0x03c2, {1|F|SU|I(33), {0x03c3}}},
+ {0x03cf, {1|F|D, {0x03d7}}},
+ {0x03d0, {1|F|SU|I(34), {0x03b2}}},
+ {0x03d1, {1|F|SU|I(35), {0x03b8}}},
+ {0x03d5, {1|F|SU|I(36), {0x03c6}}},
+ {0x03d6, {1|F|SU|I(37), {0x03c0}}},
+ {0x03d8, {1|F|D, {0x03d9}}},
+ {0x03da, {1|F|D, {0x03db}}},
+ {0x03dc, {1|F|D, {0x03dd}}},
+ {0x03de, {1|F|D, {0x03df}}},
+ {0x03e0, {1|F|D, {0x03e1}}},
+ {0x03e2, {1|F|D, {0x03e3}}},
+ {0x03e4, {1|F|D, {0x03e5}}},
+ {0x03e6, {1|F|D, {0x03e7}}},
+ {0x03e8, {1|F|D, {0x03e9}}},
+ {0x03ea, {1|F|D, {0x03eb}}},
+ {0x03ec, {1|F|D, {0x03ed}}},
+ {0x03ee, {1|F|D, {0x03ef}}},
+ {0x03f0, {1|F|SU|I(38), {0x03ba}}},
+ {0x03f1, {1|F|SU|I(39), {0x03c1}}},
+ {0x03f4, {1|F|D, {0x03b8}}},
+ {0x03f5, {1|F|SU|I(40), {0x03b5}}},
+ {0x03f7, {1|F|D, {0x03f8}}},
+ {0x03f9, {1|F|D, {0x03f2}}},
+ {0x03fa, {1|F|D, {0x03fb}}},
+ {0x03fd, {1|F|D, {0x037b}}},
+ {0x03fe, {1|F|D, {0x037c}}},
+ {0x03ff, {1|F|D, {0x037d}}},
+ {0x0400, {1|F|D, {0x0450}}},
+ {0x0401, {1|F|D, {0x0451}}},
+ {0x0402, {1|F|D, {0x0452}}},
+ {0x0403, {1|F|D, {0x0453}}},
+ {0x0404, {1|F|D, {0x0454}}},
+ {0x0405, {1|F|D, {0x0455}}},
+ {0x0406, {1|F|D, {0x0456}}},
+ {0x0407, {1|F|D, {0x0457}}},
+ {0x0408, {1|F|D, {0x0458}}},
+ {0x0409, {1|F|D, {0x0459}}},
+ {0x040a, {1|F|D, {0x045a}}},
+ {0x040b, {1|F|D, {0x045b}}},
+ {0x040c, {1|F|D, {0x045c}}},
+ {0x040d, {1|F|D, {0x045d}}},
+ {0x040e, {1|F|D, {0x045e}}},
+ {0x040f, {1|F|D, {0x045f}}},
+ {0x0410, {1|F|D, {0x0430}}},
+ {0x0411, {1|F|D, {0x0431}}},
+ {0x0412, {1|F|D, {0x0432}}},
+ {0x0413, {1|F|D, {0x0433}}},
+ {0x0414, {1|F|D, {0x0434}}},
+ {0x0415, {1|F|D, {0x0435}}},
+ {0x0416, {1|F|D, {0x0436}}},
+ {0x0417, {1|F|D, {0x0437}}},
+ {0x0418, {1|F|D, {0x0438}}},
+ {0x0419, {1|F|D, {0x0439}}},
+ {0x041a, {1|F|D, {0x043a}}},
+ {0x041b, {1|F|D, {0x043b}}},
+ {0x041c, {1|F|D, {0x043c}}},
+ {0x041d, {1|F|D, {0x043d}}},
+ {0x041e, {1|F|D, {0x043e}}},
+ {0x041f, {1|F|D, {0x043f}}},
+ {0x0420, {1|F|D, {0x0440}}},
+ {0x0421, {1|F|D, {0x0441}}},
+ {0x0422, {1|F|D, {0x0442}}},
+ {0x0423, {1|F|D, {0x0443}}},
+ {0x0424, {1|F|D, {0x0444}}},
+ {0x0425, {1|F|D, {0x0445}}},
+ {0x0426, {1|F|D, {0x0446}}},
+ {0x0427, {1|F|D, {0x0447}}},
+ {0x0428, {1|F|D, {0x0448}}},
+ {0x0429, {1|F|D, {0x0449}}},
+ {0x042a, {1|F|D, {0x044a}}},
+ {0x042b, {1|F|D, {0x044b}}},
+ {0x042c, {1|F|D, {0x044c}}},
+ {0x042d, {1|F|D, {0x044d}}},
+ {0x042e, {1|F|D, {0x044e}}},
+ {0x042f, {1|F|D, {0x044f}}},
+ {0x0460, {1|F|D, {0x0461}}},
+ {0x0462, {1|F|D, {0x0463}}},
+ {0x0464, {1|F|D, {0x0465}}},
+ {0x0466, {1|F|D, {0x0467}}},
+ {0x0468, {1|F|D, {0x0469}}},
+ {0x046a, {1|F|D, {0x046b}}},
+ {0x046c, {1|F|D, {0x046d}}},
+ {0x046e, {1|F|D, {0x046f}}},
+ {0x0470, {1|F|D, {0x0471}}},
+ {0x0472, {1|F|D, {0x0473}}},
+ {0x0474, {1|F|D, {0x0475}}},
+ {0x0476, {1|F|D, {0x0477}}},
+ {0x0478, {1|F|D, {0x0479}}},
+ {0x047a, {1|F|D, {0x047b}}},
+ {0x047c, {1|F|D, {0x047d}}},
+ {0x047e, {1|F|D, {0x047f}}},
+ {0x0480, {1|F|D, {0x0481}}},
+ {0x048a, {1|F|D, {0x048b}}},
+ {0x048c, {1|F|D, {0x048d}}},
+ {0x048e, {1|F|D, {0x048f}}},
+ {0x0490, {1|F|D, {0x0491}}},
+ {0x0492, {1|F|D, {0x0493}}},
+ {0x0494, {1|F|D, {0x0495}}},
+ {0x0496, {1|F|D, {0x0497}}},
+ {0x0498, {1|F|D, {0x0499}}},
+ {0x049a, {1|F|D, {0x049b}}},
+ {0x049c, {1|F|D, {0x049d}}},
+ {0x049e, {1|F|D, {0x049f}}},
+ {0x04a0, {1|F|D, {0x04a1}}},
+ {0x04a2, {1|F|D, {0x04a3}}},
+ {0x04a4, {1|F|D, {0x04a5}}},
+ {0x04a6, {1|F|D, {0x04a7}}},
+ {0x04a8, {1|F|D, {0x04a9}}},
+ {0x04aa, {1|F|D, {0x04ab}}},
+ {0x04ac, {1|F|D, {0x04ad}}},
+ {0x04ae, {1|F|D, {0x04af}}},
+ {0x04b0, {1|F|D, {0x04b1}}},
+ {0x04b2, {1|F|D, {0x04b3}}},
+ {0x04b4, {1|F|D, {0x04b5}}},
+ {0x04b6, {1|F|D, {0x04b7}}},
+ {0x04b8, {1|F|D, {0x04b9}}},
+ {0x04ba, {1|F|D, {0x04bb}}},
+ {0x04bc, {1|F|D, {0x04bd}}},
+ {0x04be, {1|F|D, {0x04bf}}},
+ {0x04c0, {1|F|D, {0x04cf}}},
+ {0x04c1, {1|F|D, {0x04c2}}},
+ {0x04c3, {1|F|D, {0x04c4}}},
+ {0x04c5, {1|F|D, {0x04c6}}},
+ {0x04c7, {1|F|D, {0x04c8}}},
+ {0x04c9, {1|F|D, {0x04ca}}},
+ {0x04cb, {1|F|D, {0x04cc}}},
+ {0x04cd, {1|F|D, {0x04ce}}},
+ {0x04d0, {1|F|D, {0x04d1}}},
+ {0x04d2, {1|F|D, {0x04d3}}},
+ {0x04d4, {1|F|D, {0x04d5}}},
+ {0x04d6, {1|F|D, {0x04d7}}},
+ {0x04d8, {1|F|D, {0x04d9}}},
+ {0x04da, {1|F|D, {0x04db}}},
+ {0x04dc, {1|F|D, {0x04dd}}},
+ {0x04de, {1|F|D, {0x04df}}},
+ {0x04e0, {1|F|D, {0x04e1}}},
+ {0x04e2, {1|F|D, {0x04e3}}},
+ {0x04e4, {1|F|D, {0x04e5}}},
+ {0x04e6, {1|F|D, {0x04e7}}},
+ {0x04e8, {1|F|D, {0x04e9}}},
+ {0x04ea, {1|F|D, {0x04eb}}},
+ {0x04ec, {1|F|D, {0x04ed}}},
+ {0x04ee, {1|F|D, {0x04ef}}},
+ {0x04f0, {1|F|D, {0x04f1}}},
+ {0x04f2, {1|F|D, {0x04f3}}},
+ {0x04f4, {1|F|D, {0x04f5}}},
+ {0x04f6, {1|F|D, {0x04f7}}},
+ {0x04f8, {1|F|D, {0x04f9}}},
+ {0x04fa, {1|F|D, {0x04fb}}},
+ {0x04fc, {1|F|D, {0x04fd}}},
+ {0x04fe, {1|F|D, {0x04ff}}},
+ {0x0500, {1|F|D, {0x0501}}},
+ {0x0502, {1|F|D, {0x0503}}},
+ {0x0504, {1|F|D, {0x0505}}},
+ {0x0506, {1|F|D, {0x0507}}},
+ {0x0508, {1|F|D, {0x0509}}},
+ {0x050a, {1|F|D, {0x050b}}},
+ {0x050c, {1|F|D, {0x050d}}},
+ {0x050e, {1|F|D, {0x050f}}},
+ {0x0510, {1|F|D, {0x0511}}},
+ {0x0512, {1|F|D, {0x0513}}},
+ {0x0514, {1|F|D, {0x0515}}},
+ {0x0516, {1|F|D, {0x0517}}},
+ {0x0518, {1|F|D, {0x0519}}},
+ {0x051a, {1|F|D, {0x051b}}},
+ {0x051c, {1|F|D, {0x051d}}},
+ {0x051e, {1|F|D, {0x051f}}},
+ {0x0520, {1|F|D, {0x0521}}},
+ {0x0522, {1|F|D, {0x0523}}},
+ {0x0524, {1|F|D, {0x0525}}},
+ {0x0526, {1|F|D, {0x0527}}},
+ {0x0528, {1|F|D, {0x0529}}},
+ {0x052a, {1|F|D, {0x052b}}},
+ {0x052c, {1|F|D, {0x052d}}},
+ {0x052e, {1|F|D, {0x052f}}},
+ {0x0531, {1|F|D, {0x0561}}},
+ {0x0532, {1|F|D, {0x0562}}},
+ {0x0533, {1|F|D, {0x0563}}},
+ {0x0534, {1|F|D, {0x0564}}},
+ {0x0535, {1|F|D, {0x0565}}},
+ {0x0536, {1|F|D, {0x0566}}},
+ {0x0537, {1|F|D, {0x0567}}},
+ {0x0538, {1|F|D, {0x0568}}},
+ {0x0539, {1|F|D, {0x0569}}},
+ {0x053a, {1|F|D, {0x056a}}},
+ {0x053b, {1|F|D, {0x056b}}},
+ {0x053c, {1|F|D, {0x056c}}},
+ {0x053d, {1|F|D, {0x056d}}},
+ {0x053e, {1|F|D, {0x056e}}},
+ {0x053f, {1|F|D, {0x056f}}},
+ {0x0540, {1|F|D, {0x0570}}},
+ {0x0541, {1|F|D, {0x0571}}},
+ {0x0542, {1|F|D, {0x0572}}},
+ {0x0543, {1|F|D, {0x0573}}},
+ {0x0544, {1|F|D, {0x0574}}},
+ {0x0545, {1|F|D, {0x0575}}},
+ {0x0546, {1|F|D, {0x0576}}},
+ {0x0547, {1|F|D, {0x0577}}},
+ {0x0548, {1|F|D, {0x0578}}},
+ {0x0549, {1|F|D, {0x0579}}},
+ {0x054a, {1|F|D, {0x057a}}},
+ {0x054b, {1|F|D, {0x057b}}},
+ {0x054c, {1|F|D, {0x057c}}},
+ {0x054d, {1|F|D, {0x057d}}},
+ {0x054e, {1|F|D, {0x057e}}},
+ {0x054f, {1|F|D, {0x057f}}},
+ {0x0550, {1|F|D, {0x0580}}},
+ {0x0551, {1|F|D, {0x0581}}},
+ {0x0552, {1|F|D, {0x0582}}},
+ {0x0553, {1|F|D, {0x0583}}},
+ {0x0554, {1|F|D, {0x0584}}},
+ {0x0555, {1|F|D, {0x0585}}},
+ {0x0556, {1|F|D, {0x0586}}},
+ {0x0587, {2|F|ST|SU|I(41), {0x0565, 0x0582}}},
+ {0x10a0, {1|F|D, {0x2d00}}},
+ {0x10a1, {1|F|D, {0x2d01}}},
+ {0x10a2, {1|F|D, {0x2d02}}},
+ {0x10a3, {1|F|D, {0x2d03}}},
+ {0x10a4, {1|F|D, {0x2d04}}},
+ {0x10a5, {1|F|D, {0x2d05}}},
+ {0x10a6, {1|F|D, {0x2d06}}},
+ {0x10a7, {1|F|D, {0x2d07}}},
+ {0x10a8, {1|F|D, {0x2d08}}},
+ {0x10a9, {1|F|D, {0x2d09}}},
+ {0x10aa, {1|F|D, {0x2d0a}}},
+ {0x10ab, {1|F|D, {0x2d0b}}},
+ {0x10ac, {1|F|D, {0x2d0c}}},
+ {0x10ad, {1|F|D, {0x2d0d}}},
+ {0x10ae, {1|F|D, {0x2d0e}}},
+ {0x10af, {1|F|D, {0x2d0f}}},
+ {0x10b0, {1|F|D, {0x2d10}}},
+ {0x10b1, {1|F|D, {0x2d11}}},
+ {0x10b2, {1|F|D, {0x2d12}}},
+ {0x10b3, {1|F|D, {0x2d13}}},
+ {0x10b4, {1|F|D, {0x2d14}}},
+ {0x10b5, {1|F|D, {0x2d15}}},
+ {0x10b6, {1|F|D, {0x2d16}}},
+ {0x10b7, {1|F|D, {0x2d17}}},
+ {0x10b8, {1|F|D, {0x2d18}}},
+ {0x10b9, {1|F|D, {0x2d19}}},
+ {0x10ba, {1|F|D, {0x2d1a}}},
+ {0x10bb, {1|F|D, {0x2d1b}}},
+ {0x10bc, {1|F|D, {0x2d1c}}},
+ {0x10bd, {1|F|D, {0x2d1d}}},
+ {0x10be, {1|F|D, {0x2d1e}}},
+ {0x10bf, {1|F|D, {0x2d1f}}},
+ {0x10c0, {1|F|D, {0x2d20}}},
+ {0x10c1, {1|F|D, {0x2d21}}},
+ {0x10c2, {1|F|D, {0x2d22}}},
+ {0x10c3, {1|F|D, {0x2d23}}},
+ {0x10c4, {1|F|D, {0x2d24}}},
+ {0x10c5, {1|F|D, {0x2d25}}},
+ {0x10c7, {1|F|D, {0x2d27}}},
+ {0x10cd, {1|F|D, {0x2d2d}}},
+ {0x13f8, {1|F|U, {0x13f0}}},
+ {0x13f9, {1|F|U, {0x13f1}}},
+ {0x13fa, {1|F|U, {0x13f2}}},
+ {0x13fb, {1|F|U, {0x13f3}}},
+ {0x13fc, {1|F|U, {0x13f4}}},
+ {0x13fd, {1|F|U, {0x13f5}}},
+ {0x1c80, {1|F|SU|I(45), {0x0432}}},
+ {0x1c81, {1|F|SU|I(46), {0x0434}}},
+ {0x1c82, {1|F|SU|I(47), {0x043e}}},
+ {0x1c83, {1|F|SU|I(48), {0x0441}}},
+ {0x1c84, {1|F|SU|I(49), {0x0442}}},
+ {0x1c85, {1|F|SU|I(50), {0x0442}}},
+ {0x1c86, {1|F|SU|I(51), {0x044a}}},
+ {0x1c87, {1|F|SU|I(52), {0x0463}}},
+ {0x1c88, {1|F|SU|I(53), {0xa64b}}},
+ {0x1c89, {1|F|D, {0x1c8a}}},
+ {0x1c90, {1|F|D, {0x10d0}}},
+ {0x1c91, {1|F|D, {0x10d1}}},
+ {0x1c92, {1|F|D, {0x10d2}}},
+ {0x1c93, {1|F|D, {0x10d3}}},
+ {0x1c94, {1|F|D, {0x10d4}}},
+ {0x1c95, {1|F|D, {0x10d5}}},
+ {0x1c96, {1|F|D, {0x10d6}}},
+ {0x1c97, {1|F|D, {0x10d7}}},
+ {0x1c98, {1|F|D, {0x10d8}}},
+ {0x1c99, {1|F|D, {0x10d9}}},
+ {0x1c9a, {1|F|D, {0x10da}}},
+ {0x1c9b, {1|F|D, {0x10db}}},
+ {0x1c9c, {1|F|D, {0x10dc}}},
+ {0x1c9d, {1|F|D, {0x10dd}}},
+ {0x1c9e, {1|F|D, {0x10de}}},
+ {0x1c9f, {1|F|D, {0x10df}}},
+ {0x1ca0, {1|F|D, {0x10e0}}},
+ {0x1ca1, {1|F|D, {0x10e1}}},
+ {0x1ca2, {1|F|D, {0x10e2}}},
+ {0x1ca3, {1|F|D, {0x10e3}}},
+ {0x1ca4, {1|F|D, {0x10e4}}},
+ {0x1ca5, {1|F|D, {0x10e5}}},
+ {0x1ca6, {1|F|D, {0x10e6}}},
+ {0x1ca7, {1|F|D, {0x10e7}}},
+ {0x1ca8, {1|F|D, {0x10e8}}},
+ {0x1ca9, {1|F|D, {0x10e9}}},
+ {0x1caa, {1|F|D, {0x10ea}}},
+ {0x1cab, {1|F|D, {0x10eb}}},
+ {0x1cac, {1|F|D, {0x10ec}}},
+ {0x1cad, {1|F|D, {0x10ed}}},
+ {0x1cae, {1|F|D, {0x10ee}}},
+ {0x1caf, {1|F|D, {0x10ef}}},
+ {0x1cb0, {1|F|D, {0x10f0}}},
+ {0x1cb1, {1|F|D, {0x10f1}}},
+ {0x1cb2, {1|F|D, {0x10f2}}},
+ {0x1cb3, {1|F|D, {0x10f3}}},
+ {0x1cb4, {1|F|D, {0x10f4}}},
+ {0x1cb5, {1|F|D, {0x10f5}}},
+ {0x1cb6, {1|F|D, {0x10f6}}},
+ {0x1cb7, {1|F|D, {0x10f7}}},
+ {0x1cb8, {1|F|D, {0x10f8}}},
+ {0x1cb9, {1|F|D, {0x10f9}}},
+ {0x1cba, {1|F|D, {0x10fa}}},
+ {0x1cbd, {1|F|D, {0x10fd}}},
+ {0x1cbe, {1|F|D, {0x10fe}}},
+ {0x1cbf, {1|F|D, {0x10ff}}},
+ {0x1e00, {1|F|D, {0x1e01}}},
+ {0x1e02, {1|F|D, {0x1e03}}},
+ {0x1e04, {1|F|D, {0x1e05}}},
+ {0x1e06, {1|F|D, {0x1e07}}},
+ {0x1e08, {1|F|D, {0x1e09}}},
+ {0x1e0a, {1|F|D, {0x1e0b}}},
+ {0x1e0c, {1|F|D, {0x1e0d}}},
+ {0x1e0e, {1|F|D, {0x1e0f}}},
+ {0x1e10, {1|F|D, {0x1e11}}},
+ {0x1e12, {1|F|D, {0x1e13}}},
+ {0x1e14, {1|F|D, {0x1e15}}},
+ {0x1e16, {1|F|D, {0x1e17}}},
+ {0x1e18, {1|F|D, {0x1e19}}},
+ {0x1e1a, {1|F|D, {0x1e1b}}},
+ {0x1e1c, {1|F|D, {0x1e1d}}},
+ {0x1e1e, {1|F|D, {0x1e1f}}},
+ {0x1e20, {1|F|D, {0x1e21}}},
+ {0x1e22, {1|F|D, {0x1e23}}},
+ {0x1e24, {1|F|D, {0x1e25}}},
+ {0x1e26, {1|F|D, {0x1e27}}},
+ {0x1e28, {1|F|D, {0x1e29}}},
+ {0x1e2a, {1|F|D, {0x1e2b}}},
+ {0x1e2c, {1|F|D, {0x1e2d}}},
+ {0x1e2e, {1|F|D, {0x1e2f}}},
+ {0x1e30, {1|F|D, {0x1e31}}},
+ {0x1e32, {1|F|D, {0x1e33}}},
+ {0x1e34, {1|F|D, {0x1e35}}},
+ {0x1e36, {1|F|D, {0x1e37}}},
+ {0x1e38, {1|F|D, {0x1e39}}},
+ {0x1e3a, {1|F|D, {0x1e3b}}},
+ {0x1e3c, {1|F|D, {0x1e3d}}},
+ {0x1e3e, {1|F|D, {0x1e3f}}},
+ {0x1e40, {1|F|D, {0x1e41}}},
+ {0x1e42, {1|F|D, {0x1e43}}},
+ {0x1e44, {1|F|D, {0x1e45}}},
+ {0x1e46, {1|F|D, {0x1e47}}},
+ {0x1e48, {1|F|D, {0x1e49}}},
+ {0x1e4a, {1|F|D, {0x1e4b}}},
+ {0x1e4c, {1|F|D, {0x1e4d}}},
+ {0x1e4e, {1|F|D, {0x1e4f}}},
+ {0x1e50, {1|F|D, {0x1e51}}},
+ {0x1e52, {1|F|D, {0x1e53}}},
+ {0x1e54, {1|F|D, {0x1e55}}},
+ {0x1e56, {1|F|D, {0x1e57}}},
+ {0x1e58, {1|F|D, {0x1e59}}},
+ {0x1e5a, {1|F|D, {0x1e5b}}},
+ {0x1e5c, {1|F|D, {0x1e5d}}},
+ {0x1e5e, {1|F|D, {0x1e5f}}},
+ {0x1e60, {1|F|D, {0x1e61}}},
+ {0x1e62, {1|F|D, {0x1e63}}},
+ {0x1e64, {1|F|D, {0x1e65}}},
+ {0x1e66, {1|F|D, {0x1e67}}},
+ {0x1e68, {1|F|D, {0x1e69}}},
+ {0x1e6a, {1|F|D, {0x1e6b}}},
+ {0x1e6c, {1|F|D, {0x1e6d}}},
+ {0x1e6e, {1|F|D, {0x1e6f}}},
+ {0x1e70, {1|F|D, {0x1e71}}},
+ {0x1e72, {1|F|D, {0x1e73}}},
+ {0x1e74, {1|F|D, {0x1e75}}},
+ {0x1e76, {1|F|D, {0x1e77}}},
+ {0x1e78, {1|F|D, {0x1e79}}},
+ {0x1e7a, {1|F|D, {0x1e7b}}},
+ {0x1e7c, {1|F|D, {0x1e7d}}},
+ {0x1e7e, {1|F|D, {0x1e7f}}},
+ {0x1e80, {1|F|D, {0x1e81}}},
+ {0x1e82, {1|F|D, {0x1e83}}},
+ {0x1e84, {1|F|D, {0x1e85}}},
+ {0x1e86, {1|F|D, {0x1e87}}},
+ {0x1e88, {1|F|D, {0x1e89}}},
+ {0x1e8a, {1|F|D, {0x1e8b}}},
+ {0x1e8c, {1|F|D, {0x1e8d}}},
+ {0x1e8e, {1|F|D, {0x1e8f}}},
+ {0x1e90, {1|F|D, {0x1e91}}},
+ {0x1e92, {1|F|D, {0x1e93}}},
+ {0x1e94, {1|F|D, {0x1e95}}},
+ {0x1e96, {2|F|SU|I(54), {0x0068, 0x0331}}},
+ {0x1e97, {2|F|SU|I(56), {0x0074, 0x0308}}},
+ {0x1e98, {2|F|SU|I(58), {0x0077, 0x030a}}},
+ {0x1e99, {2|F|SU|I(60), {0x0079, 0x030a}}},
+ {0x1e9a, {2|F|SU|I(62), {0x0061, 0x02be}}},
+ {0x1e9b, {1|F|SU|I(64), {0x1e61}}},
+ {0x1e9e, {2|F|SL|I(65), {0x0073, 0x0073}}},
+ {0x1ea0, {1|F|D, {0x1ea1}}},
+ {0x1ea2, {1|F|D, {0x1ea3}}},
+ {0x1ea4, {1|F|D, {0x1ea5}}},
+ {0x1ea6, {1|F|D, {0x1ea7}}},
+ {0x1ea8, {1|F|D, {0x1ea9}}},
+ {0x1eaa, {1|F|D, {0x1eab}}},
+ {0x1eac, {1|F|D, {0x1ead}}},
+ {0x1eae, {1|F|D, {0x1eaf}}},
+ {0x1eb0, {1|F|D, {0x1eb1}}},
+ {0x1eb2, {1|F|D, {0x1eb3}}},
+ {0x1eb4, {1|F|D, {0x1eb5}}},
+ {0x1eb6, {1|F|D, {0x1eb7}}},
+ {0x1eb8, {1|F|D, {0x1eb9}}},
+ {0x1eba, {1|F|D, {0x1ebb}}},
+ {0x1ebc, {1|F|D, {0x1ebd}}},
+ {0x1ebe, {1|F|D, {0x1ebf}}},
+ {0x1ec0, {1|F|D, {0x1ec1}}},
+ {0x1ec2, {1|F|D, {0x1ec3}}},
+ {0x1ec4, {1|F|D, {0x1ec5}}},
+ {0x1ec6, {1|F|D, {0x1ec7}}},
+ {0x1ec8, {1|F|D, {0x1ec9}}},
+ {0x1eca, {1|F|D, {0x1ecb}}},
+ {0x1ecc, {1|F|D, {0x1ecd}}},
+ {0x1ece, {1|F|D, {0x1ecf}}},
+ {0x1ed0, {1|F|D, {0x1ed1}}},
+ {0x1ed2, {1|F|D, {0x1ed3}}},
+ {0x1ed4, {1|F|D, {0x1ed5}}},
+ {0x1ed6, {1|F|D, {0x1ed7}}},
+ {0x1ed8, {1|F|D, {0x1ed9}}},
+ {0x1eda, {1|F|D, {0x1edb}}},
+ {0x1edc, {1|F|D, {0x1edd}}},
+ {0x1ede, {1|F|D, {0x1edf}}},
+ {0x1ee0, {1|F|D, {0x1ee1}}},
+ {0x1ee2, {1|F|D, {0x1ee3}}},
+ {0x1ee4, {1|F|D, {0x1ee5}}},
+ {0x1ee6, {1|F|D, {0x1ee7}}},
+ {0x1ee8, {1|F|D, {0x1ee9}}},
+ {0x1eea, {1|F|D, {0x1eeb}}},
+ {0x1eec, {1|F|D, {0x1eed}}},
+ {0x1eee, {1|F|D, {0x1eef}}},
+ {0x1ef0, {1|F|D, {0x1ef1}}},
+ {0x1ef2, {1|F|D, {0x1ef3}}},
+ {0x1ef4, {1|F|D, {0x1ef5}}},
+ {0x1ef6, {1|F|D, {0x1ef7}}},
+ {0x1ef8, {1|F|D, {0x1ef9}}},
+ {0x1efa, {1|F|D, {0x1efb}}},
+ {0x1efc, {1|F|D, {0x1efd}}},
+ {0x1efe, {1|F|D, {0x1eff}}},
+ {0x1f08, {1|F|D, {0x1f00}}},
+ {0x1f09, {1|F|D, {0x1f01}}},
+ {0x1f0a, {1|F|D, {0x1f02}}},
+ {0x1f0b, {1|F|D, {0x1f03}}},
+ {0x1f0c, {1|F|D, {0x1f04}}},
+ {0x1f0d, {1|F|D, {0x1f05}}},
+ {0x1f0e, {1|F|D, {0x1f06}}},
+ {0x1f0f, {1|F|D, {0x1f07}}},
+ {0x1f18, {1|F|D, {0x1f10}}},
+ {0x1f19, {1|F|D, {0x1f11}}},
+ {0x1f1a, {1|F|D, {0x1f12}}},
+ {0x1f1b, {1|F|D, {0x1f13}}},
+ {0x1f1c, {1|F|D, {0x1f14}}},
+ {0x1f1d, {1|F|D, {0x1f15}}},
+ {0x1f28, {1|F|D, {0x1f20}}},
+ {0x1f29, {1|F|D, {0x1f21}}},
+ {0x1f2a, {1|F|D, {0x1f22}}},
+ {0x1f2b, {1|F|D, {0x1f23}}},
+ {0x1f2c, {1|F|D, {0x1f24}}},
+ {0x1f2d, {1|F|D, {0x1f25}}},
+ {0x1f2e, {1|F|D, {0x1f26}}},
+ {0x1f2f, {1|F|D, {0x1f27}}},
+ {0x1f38, {1|F|D, {0x1f30}}},
+ {0x1f39, {1|F|D, {0x1f31}}},
+ {0x1f3a, {1|F|D, {0x1f32}}},
+ {0x1f3b, {1|F|D, {0x1f33}}},
+ {0x1f3c, {1|F|D, {0x1f34}}},
+ {0x1f3d, {1|F|D, {0x1f35}}},
+ {0x1f3e, {1|F|D, {0x1f36}}},
+ {0x1f3f, {1|F|D, {0x1f37}}},
+ {0x1f48, {1|F|D, {0x1f40}}},
+ {0x1f49, {1|F|D, {0x1f41}}},
+ {0x1f4a, {1|F|D, {0x1f42}}},
+ {0x1f4b, {1|F|D, {0x1f43}}},
+ {0x1f4c, {1|F|D, {0x1f44}}},
+ {0x1f4d, {1|F|D, {0x1f45}}},
+ {0x1f50, {2|F|SU|I(66), {0x03c5, 0x0313}}},
+ {0x1f52, {3|F|SU|I(68), {0x03c5, 0x0313, 0x0300}}},
+ {0x1f54, {3|F|SU|I(71), {0x03c5, 0x0313, 0x0301}}},
+ {0x1f56, {3|F|SU|I(74), {0x03c5, 0x0313, 0x0342}}},
+ {0x1f59, {1|F|D, {0x1f51}}},
+ {0x1f5b, {1|F|D, {0x1f53}}},
+ {0x1f5d, {1|F|D, {0x1f55}}},
+ {0x1f5f, {1|F|D, {0x1f57}}},
+ {0x1f68, {1|F|D, {0x1f60}}},
+ {0x1f69, {1|F|D, {0x1f61}}},
+ {0x1f6a, {1|F|D, {0x1f62}}},
+ {0x1f6b, {1|F|D, {0x1f63}}},
+ {0x1f6c, {1|F|D, {0x1f64}}},
+ {0x1f6d, {1|F|D, {0x1f65}}},
+ {0x1f6e, {1|F|D, {0x1f66}}},
+ {0x1f6f, {1|F|D, {0x1f67}}},
+ {0x1f80, {2|F|ST|SU|I(77), {0x1f00, 0x03b9}}},
+ {0x1f81, {2|F|ST|SU|I(80), {0x1f01, 0x03b9}}},
+ {0x1f82, {2|F|ST|SU|I(83), {0x1f02, 0x03b9}}},
+ {0x1f83, {2|F|ST|SU|I(86), {0x1f03, 0x03b9}}},
+ {0x1f84, {2|F|ST|SU|I(89), {0x1f04, 0x03b9}}},
+ {0x1f85, {2|F|ST|SU|I(92), {0x1f05, 0x03b9}}},
+ {0x1f86, {2|F|ST|SU|I(95), {0x1f06, 0x03b9}}},
+ {0x1f87, {2|F|ST|SU|I(98), {0x1f07, 0x03b9}}},
+ {0x1f88, {2|F|IT|SL|SU|I(101), {0x1f00, 0x03b9}}},
+ {0x1f89, {2|F|IT|SL|SU|I(106), {0x1f01, 0x03b9}}},
+ {0x1f8a, {2|F|IT|SL|SU|I(111), {0x1f02, 0x03b9}}},
+ {0x1f8b, {2|F|IT|SL|SU|I(116), {0x1f03, 0x03b9}}},
+ {0x1f8c, {2|F|IT|SL|SU|I(121), {0x1f04, 0x03b9}}},
+ {0x1f8d, {2|F|IT|SL|SU|I(126), {0x1f05, 0x03b9}}},
+ {0x1f8e, {2|F|IT|SL|SU|I(131), {0x1f06, 0x03b9}}},
+ {0x1f8f, {2|F|IT|SL|SU|I(136), {0x1f07, 0x03b9}}},
+ {0x1f90, {2|F|ST|SU|I(141), {0x1f20, 0x03b9}}},
+ {0x1f91, {2|F|ST|SU|I(144), {0x1f21, 0x03b9}}},
+ {0x1f92, {2|F|ST|SU|I(147), {0x1f22, 0x03b9}}},
+ {0x1f93, {2|F|ST|SU|I(150), {0x1f23, 0x03b9}}},
+ {0x1f94, {2|F|ST|SU|I(153), {0x1f24, 0x03b9}}},
+ {0x1f95, {2|F|ST|SU|I(156), {0x1f25, 0x03b9}}},
+ {0x1f96, {2|F|ST|SU|I(159), {0x1f26, 0x03b9}}},
+ {0x1f97, {2|F|ST|SU|I(162), {0x1f27, 0x03b9}}},
+ {0x1f98, {2|F|IT|SL|SU|I(165), {0x1f20, 0x03b9}}},
+ {0x1f99, {2|F|IT|SL|SU|I(170), {0x1f21, 0x03b9}}},
+ {0x1f9a, {2|F|IT|SL|SU|I(175), {0x1f22, 0x03b9}}},
+ {0x1f9b, {2|F|IT|SL|SU|I(180), {0x1f23, 0x03b9}}},
+ {0x1f9c, {2|F|IT|SL|SU|I(185), {0x1f24, 0x03b9}}},
+ {0x1f9d, {2|F|IT|SL|SU|I(190), {0x1f25, 0x03b9}}},
+ {0x1f9e, {2|F|IT|SL|SU|I(195), {0x1f26, 0x03b9}}},
+ {0x1f9f, {2|F|IT|SL|SU|I(200), {0x1f27, 0x03b9}}},
+ {0x1fa0, {2|F|ST|SU|I(205), {0x1f60, 0x03b9}}},
+ {0x1fa1, {2|F|ST|SU|I(208), {0x1f61, 0x03b9}}},
+ {0x1fa2, {2|F|ST|SU|I(211), {0x1f62, 0x03b9}}},
+ {0x1fa3, {2|F|ST|SU|I(214), {0x1f63, 0x03b9}}},
+ {0x1fa4, {2|F|ST|SU|I(217), {0x1f64, 0x03b9}}},
+ {0x1fa5, {2|F|ST|SU|I(220), {0x1f65, 0x03b9}}},
+ {0x1fa6, {2|F|ST|SU|I(223), {0x1f66, 0x03b9}}},
+ {0x1fa7, {2|F|ST|SU|I(226), {0x1f67, 0x03b9}}},
+ {0x1fa8, {2|F|IT|SL|SU|I(229), {0x1f60, 0x03b9}}},
+ {0x1fa9, {2|F|IT|SL|SU|I(234), {0x1f61, 0x03b9}}},
+ {0x1faa, {2|F|IT|SL|SU|I(239), {0x1f62, 0x03b9}}},
+ {0x1fab, {2|F|IT|SL|SU|I(244), {0x1f63, 0x03b9}}},
+ {0x1fac, {2|F|IT|SL|SU|I(249), {0x1f64, 0x03b9}}},
+ {0x1fad, {2|F|IT|SL|SU|I(254), {0x1f65, 0x03b9}}},
+ {0x1fae, {2|F|IT|SL|SU|I(259), {0x1f66, 0x03b9}}},
+ {0x1faf, {2|F|IT|SL|SU|I(264), {0x1f67, 0x03b9}}},
+ {0x1fb2, {2|F|ST|SU|I(269), {0x1f70, 0x03b9}}},
+ {0x1fb3, {2|F|ST|SU|I(273), {0x03b1, 0x03b9}}},
+ {0x1fb4, {2|F|ST|SU|I(276), {0x03ac, 0x03b9}}},
+ {0x1fb6, {2|F|SU|I(280), {0x03b1, 0x0342}}},
+ {0x1fb7, {3|F|ST|SU|I(282), {0x03b1, 0x0342, 0x03b9}}},
+ {0x1fb8, {1|F|D, {0x1fb0}}},
+ {0x1fb9, {1|F|D, {0x1fb1}}},
+ {0x1fba, {1|F|D, {0x1f70}}},
+ {0x1fbb, {1|F|D, {0x1f71}}},
+ {0x1fbc, {2|F|IT|SL|SU|I(288), {0x03b1, 0x03b9}}},
+ {0x1fbe, {1|F|SU|I(293), {0x03b9}}},
+ {0x1fc2, {2|F|ST|SU|I(294), {0x1f74, 0x03b9}}},
+ {0x1fc3, {2|F|ST|SU|I(298), {0x03b7, 0x03b9}}},
+ {0x1fc4, {2|F|ST|SU|I(301), {0x03ae, 0x03b9}}},
+ {0x1fc6, {2|F|SU|I(305), {0x03b7, 0x0342}}},
+ {0x1fc7, {3|F|ST|SU|I(307), {0x03b7, 0x0342, 0x03b9}}},
+ {0x1fc8, {1|F|D, {0x1f72}}},
+ {0x1fc9, {1|F|D, {0x1f73}}},
+ {0x1fca, {1|F|D, {0x1f74}}},
+ {0x1fcb, {1|F|D, {0x1f75}}},
+ {0x1fcc, {2|F|IT|SL|SU|I(313), {0x03b7, 0x03b9}}},
+ {0x1fd2, {3|F|SU|I(318), {0x03b9, 0x0308, 0x0300}}},
+ {0x1fd3, {3|F|SU|I(321), {0x03b9, 0x0308, 0x0301}}},
+ {0x1fd6, {2|F|SU|I(324), {0x03b9, 0x0342}}},
+ {0x1fd7, {3|F|SU|I(326), {0x03b9, 0x0308, 0x0342}}},
+ {0x1fd8, {1|F|D, {0x1fd0}}},
+ {0x1fd9, {1|F|D, {0x1fd1}}},
+ {0x1fda, {1|F|D, {0x1f76}}},
+ {0x1fdb, {1|F|D, {0x1f77}}},
+ {0x1fe2, {3|F|SU|I(329), {0x03c5, 0x0308, 0x0300}}},
+ {0x1fe3, {3|F|SU|I(332), {0x03c5, 0x0308, 0x0301}}},
+ {0x1fe4, {2|F|SU|I(335), {0x03c1, 0x0313}}},
+ {0x1fe6, {2|F|SU|I(337), {0x03c5, 0x0342}}},
+ {0x1fe7, {3|F|SU|I(339), {0x03c5, 0x0308, 0x0342}}},
+ {0x1fe8, {1|F|D, {0x1fe0}}},
+ {0x1fe9, {1|F|D, {0x1fe1}}},
+ {0x1fea, {1|F|D, {0x1f7a}}},
+ {0x1feb, {1|F|D, {0x1f7b}}},
+ {0x1fec, {1|F|D, {0x1fe5}}},
+ {0x1ff2, {2|F|ST|SU|I(342), {0x1f7c, 0x03b9}}},
+ {0x1ff3, {2|F|ST|SU|I(346), {0x03c9, 0x03b9}}},
+ {0x1ff4, {2|F|ST|SU|I(349), {0x03ce, 0x03b9}}},
+ {0x1ff6, {2|F|SU|I(353), {0x03c9, 0x0342}}},
+ {0x1ff7, {3|F|ST|SU|I(355), {0x03c9, 0x0342, 0x03b9}}},
+ {0x1ff8, {1|F|D, {0x1f78}}},
+ {0x1ff9, {1|F|D, {0x1f79}}},
+ {0x1ffa, {1|F|D, {0x1f7c}}},
+ {0x1ffb, {1|F|D, {0x1f7d}}},
+ {0x1ffc, {2|F|IT|SL|SU|I(361), {0x03c9, 0x03b9}}},
+ {0x2126, {1|F|D, {0x03c9}}},
+ {0x212a, {1|F|D, {0x006b}}},
+ {0x212b, {1|F|D, {0x00e5}}},
+ {0x2132, {1|F|D, {0x214e}}},
+ {0x2160, {1|F|D, {0x2170}}},
+ {0x2161, {1|F|D, {0x2171}}},
+ {0x2162, {1|F|D, {0x2172}}},
+ {0x2163, {1|F|D, {0x2173}}},
+ {0x2164, {1|F|D, {0x2174}}},
+ {0x2165, {1|F|D, {0x2175}}},
+ {0x2166, {1|F|D, {0x2176}}},
+ {0x2167, {1|F|D, {0x2177}}},
+ {0x2168, {1|F|D, {0x2178}}},
+ {0x2169, {1|F|D, {0x2179}}},
+ {0x216a, {1|F|D, {0x217a}}},
+ {0x216b, {1|F|D, {0x217b}}},
+ {0x216c, {1|F|D, {0x217c}}},
+ {0x216d, {1|F|D, {0x217d}}},
+ {0x216e, {1|F|D, {0x217e}}},
+ {0x216f, {1|F|D, {0x217f}}},
+ {0x2183, {1|F|D, {0x2184}}},
+ {0x24b6, {1|F|D, {0x24d0}}},
+ {0x24b7, {1|F|D, {0x24d1}}},
+ {0x24b8, {1|F|D, {0x24d2}}},
+ {0x24b9, {1|F|D, {0x24d3}}},
+ {0x24ba, {1|F|D, {0x24d4}}},
+ {0x24bb, {1|F|D, {0x24d5}}},
+ {0x24bc, {1|F|D, {0x24d6}}},
+ {0x24bd, {1|F|D, {0x24d7}}},
+ {0x24be, {1|F|D, {0x24d8}}},
+ {0x24bf, {1|F|D, {0x24d9}}},
+ {0x24c0, {1|F|D, {0x24da}}},
+ {0x24c1, {1|F|D, {0x24db}}},
+ {0x24c2, {1|F|D, {0x24dc}}},
+ {0x24c3, {1|F|D, {0x24dd}}},
+ {0x24c4, {1|F|D, {0x24de}}},
+ {0x24c5, {1|F|D, {0x24df}}},
+ {0x24c6, {1|F|D, {0x24e0}}},
+ {0x24c7, {1|F|D, {0x24e1}}},
+ {0x24c8, {1|F|D, {0x24e2}}},
+ {0x24c9, {1|F|D, {0x24e3}}},
+ {0x24ca, {1|F|D, {0x24e4}}},
+ {0x24cb, {1|F|D, {0x24e5}}},
+ {0x24cc, {1|F|D, {0x24e6}}},
+ {0x24cd, {1|F|D, {0x24e7}}},
+ {0x24ce, {1|F|D, {0x24e8}}},
+ {0x24cf, {1|F|D, {0x24e9}}},
+ {0x2c00, {1|F|D, {0x2c30}}},
+ {0x2c01, {1|F|D, {0x2c31}}},
+ {0x2c02, {1|F|D, {0x2c32}}},
+ {0x2c03, {1|F|D, {0x2c33}}},
+ {0x2c04, {1|F|D, {0x2c34}}},
+ {0x2c05, {1|F|D, {0x2c35}}},
+ {0x2c06, {1|F|D, {0x2c36}}},
+ {0x2c07, {1|F|D, {0x2c37}}},
+ {0x2c08, {1|F|D, {0x2c38}}},
+ {0x2c09, {1|F|D, {0x2c39}}},
+ {0x2c0a, {1|F|D, {0x2c3a}}},
+ {0x2c0b, {1|F|D, {0x2c3b}}},
+ {0x2c0c, {1|F|D, {0x2c3c}}},
+ {0x2c0d, {1|F|D, {0x2c3d}}},
+ {0x2c0e, {1|F|D, {0x2c3e}}},
+ {0x2c0f, {1|F|D, {0x2c3f}}},
+ {0x2c10, {1|F|D, {0x2c40}}},
+ {0x2c11, {1|F|D, {0x2c41}}},
+ {0x2c12, {1|F|D, {0x2c42}}},
+ {0x2c13, {1|F|D, {0x2c43}}},
+ {0x2c14, {1|F|D, {0x2c44}}},
+ {0x2c15, {1|F|D, {0x2c45}}},
+ {0x2c16, {1|F|D, {0x2c46}}},
+ {0x2c17, {1|F|D, {0x2c47}}},
+ {0x2c18, {1|F|D, {0x2c48}}},
+ {0x2c19, {1|F|D, {0x2c49}}},
+ {0x2c1a, {1|F|D, {0x2c4a}}},
+ {0x2c1b, {1|F|D, {0x2c4b}}},
+ {0x2c1c, {1|F|D, {0x2c4c}}},
+ {0x2c1d, {1|F|D, {0x2c4d}}},
+ {0x2c1e, {1|F|D, {0x2c4e}}},
+ {0x2c1f, {1|F|D, {0x2c4f}}},
+ {0x2c20, {1|F|D, {0x2c50}}},
+ {0x2c21, {1|F|D, {0x2c51}}},
+ {0x2c22, {1|F|D, {0x2c52}}},
+ {0x2c23, {1|F|D, {0x2c53}}},
+ {0x2c24, {1|F|D, {0x2c54}}},
+ {0x2c25, {1|F|D, {0x2c55}}},
+ {0x2c26, {1|F|D, {0x2c56}}},
+ {0x2c27, {1|F|D, {0x2c57}}},
+ {0x2c28, {1|F|D, {0x2c58}}},
+ {0x2c29, {1|F|D, {0x2c59}}},
+ {0x2c2a, {1|F|D, {0x2c5a}}},
+ {0x2c2b, {1|F|D, {0x2c5b}}},
+ {0x2c2c, {1|F|D, {0x2c5c}}},
+ {0x2c2d, {1|F|D, {0x2c5d}}},
+ {0x2c2e, {1|F|D, {0x2c5e}}},
+ {0x2c2f, {1|F|D, {0x2c5f}}},
+ {0x2c60, {1|F|D, {0x2c61}}},
+ {0x2c62, {1|F|D, {0x026b}}},
+ {0x2c63, {1|F|D, {0x1d7d}}},
+ {0x2c64, {1|F|D, {0x027d}}},
+ {0x2c67, {1|F|D, {0x2c68}}},
+ {0x2c69, {1|F|D, {0x2c6a}}},
+ {0x2c6b, {1|F|D, {0x2c6c}}},
+ {0x2c6d, {1|F|D, {0x0251}}},
+ {0x2c6e, {1|F|D, {0x0271}}},
+ {0x2c6f, {1|F|D, {0x0250}}},
+ {0x2c70, {1|F|D, {0x0252}}},
+ {0x2c72, {1|F|D, {0x2c73}}},
+ {0x2c75, {1|F|D, {0x2c76}}},
+ {0x2c7e, {1|F|D, {0x023f}}},
+ {0x2c7f, {1|F|D, {0x0240}}},
+ {0x2c80, {1|F|D, {0x2c81}}},
+ {0x2c82, {1|F|D, {0x2c83}}},
+ {0x2c84, {1|F|D, {0x2c85}}},
+ {0x2c86, {1|F|D, {0x2c87}}},
+ {0x2c88, {1|F|D, {0x2c89}}},
+ {0x2c8a, {1|F|D, {0x2c8b}}},
+ {0x2c8c, {1|F|D, {0x2c8d}}},
+ {0x2c8e, {1|F|D, {0x2c8f}}},
+ {0x2c90, {1|F|D, {0x2c91}}},
+ {0x2c92, {1|F|D, {0x2c93}}},
+ {0x2c94, {1|F|D, {0x2c95}}},
+ {0x2c96, {1|F|D, {0x2c97}}},
+ {0x2c98, {1|F|D, {0x2c99}}},
+ {0x2c9a, {1|F|D, {0x2c9b}}},
+ {0x2c9c, {1|F|D, {0x2c9d}}},
+ {0x2c9e, {1|F|D, {0x2c9f}}},
+ {0x2ca0, {1|F|D, {0x2ca1}}},
+ {0x2ca2, {1|F|D, {0x2ca3}}},
+ {0x2ca4, {1|F|D, {0x2ca5}}},
+ {0x2ca6, {1|F|D, {0x2ca7}}},
+ {0x2ca8, {1|F|D, {0x2ca9}}},
+ {0x2caa, {1|F|D, {0x2cab}}},
+ {0x2cac, {1|F|D, {0x2cad}}},
+ {0x2cae, {1|F|D, {0x2caf}}},
+ {0x2cb0, {1|F|D, {0x2cb1}}},
+ {0x2cb2, {1|F|D, {0x2cb3}}},
+ {0x2cb4, {1|F|D, {0x2cb5}}},
+ {0x2cb6, {1|F|D, {0x2cb7}}},
+ {0x2cb8, {1|F|D, {0x2cb9}}},
+ {0x2cba, {1|F|D, {0x2cbb}}},
+ {0x2cbc, {1|F|D, {0x2cbd}}},
+ {0x2cbe, {1|F|D, {0x2cbf}}},
+ {0x2cc0, {1|F|D, {0x2cc1}}},
+ {0x2cc2, {1|F|D, {0x2cc3}}},
+ {0x2cc4, {1|F|D, {0x2cc5}}},
+ {0x2cc6, {1|F|D, {0x2cc7}}},
+ {0x2cc8, {1|F|D, {0x2cc9}}},
+ {0x2cca, {1|F|D, {0x2ccb}}},
+ {0x2ccc, {1|F|D, {0x2ccd}}},
+ {0x2cce, {1|F|D, {0x2ccf}}},
+ {0x2cd0, {1|F|D, {0x2cd1}}},
+ {0x2cd2, {1|F|D, {0x2cd3}}},
+ {0x2cd4, {1|F|D, {0x2cd5}}},
+ {0x2cd6, {1|F|D, {0x2cd7}}},
+ {0x2cd8, {1|F|D, {0x2cd9}}},
+ {0x2cda, {1|F|D, {0x2cdb}}},
+ {0x2cdc, {1|F|D, {0x2cdd}}},
+ {0x2cde, {1|F|D, {0x2cdf}}},
+ {0x2ce0, {1|F|D, {0x2ce1}}},
+ {0x2ce2, {1|F|D, {0x2ce3}}},
+ {0x2ceb, {1|F|D, {0x2cec}}},
+ {0x2ced, {1|F|D, {0x2cee}}},
+ {0x2cf2, {1|F|D, {0x2cf3}}},
+ {0xa640, {1|F|D, {0xa641}}},
+ {0xa642, {1|F|D, {0xa643}}},
+ {0xa644, {1|F|D, {0xa645}}},
+ {0xa646, {1|F|D, {0xa647}}},
+ {0xa648, {1|F|D, {0xa649}}},
+ {0xa64a, {1|F|D, {0xa64b}}},
+ {0xa64c, {1|F|D, {0xa64d}}},
+ {0xa64e, {1|F|D, {0xa64f}}},
+ {0xa650, {1|F|D, {0xa651}}},
+ {0xa652, {1|F|D, {0xa653}}},
+ {0xa654, {1|F|D, {0xa655}}},
+ {0xa656, {1|F|D, {0xa657}}},
+ {0xa658, {1|F|D, {0xa659}}},
+ {0xa65a, {1|F|D, {0xa65b}}},
+ {0xa65c, {1|F|D, {0xa65d}}},
+ {0xa65e, {1|F|D, {0xa65f}}},
+ {0xa660, {1|F|D, {0xa661}}},
+ {0xa662, {1|F|D, {0xa663}}},
+ {0xa664, {1|F|D, {0xa665}}},
+ {0xa666, {1|F|D, {0xa667}}},
+ {0xa668, {1|F|D, {0xa669}}},
+ {0xa66a, {1|F|D, {0xa66b}}},
+ {0xa66c, {1|F|D, {0xa66d}}},
+ {0xa680, {1|F|D, {0xa681}}},
+ {0xa682, {1|F|D, {0xa683}}},
+ {0xa684, {1|F|D, {0xa685}}},
+ {0xa686, {1|F|D, {0xa687}}},
+ {0xa688, {1|F|D, {0xa689}}},
+ {0xa68a, {1|F|D, {0xa68b}}},
+ {0xa68c, {1|F|D, {0xa68d}}},
+ {0xa68e, {1|F|D, {0xa68f}}},
+ {0xa690, {1|F|D, {0xa691}}},
+ {0xa692, {1|F|D, {0xa693}}},
+ {0xa694, {1|F|D, {0xa695}}},
+ {0xa696, {1|F|D, {0xa697}}},
+ {0xa698, {1|F|D, {0xa699}}},
+ {0xa69a, {1|F|D, {0xa69b}}},
+ {0xa722, {1|F|D, {0xa723}}},
+ {0xa724, {1|F|D, {0xa725}}},
+ {0xa726, {1|F|D, {0xa727}}},
+ {0xa728, {1|F|D, {0xa729}}},
+ {0xa72a, {1|F|D, {0xa72b}}},
+ {0xa72c, {1|F|D, {0xa72d}}},
+ {0xa72e, {1|F|D, {0xa72f}}},
+ {0xa732, {1|F|D, {0xa733}}},
+ {0xa734, {1|F|D, {0xa735}}},
+ {0xa736, {1|F|D, {0xa737}}},
+ {0xa738, {1|F|D, {0xa739}}},
+ {0xa73a, {1|F|D, {0xa73b}}},
+ {0xa73c, {1|F|D, {0xa73d}}},
+ {0xa73e, {1|F|D, {0xa73f}}},
+ {0xa740, {1|F|D, {0xa741}}},
+ {0xa742, {1|F|D, {0xa743}}},
+ {0xa744, {1|F|D, {0xa745}}},
+ {0xa746, {1|F|D, {0xa747}}},
+ {0xa748, {1|F|D, {0xa749}}},
+ {0xa74a, {1|F|D, {0xa74b}}},
+ {0xa74c, {1|F|D, {0xa74d}}},
+ {0xa74e, {1|F|D, {0xa74f}}},
+ {0xa750, {1|F|D, {0xa751}}},
+ {0xa752, {1|F|D, {0xa753}}},
+ {0xa754, {1|F|D, {0xa755}}},
+ {0xa756, {1|F|D, {0xa757}}},
+ {0xa758, {1|F|D, {0xa759}}},
+ {0xa75a, {1|F|D, {0xa75b}}},
+ {0xa75c, {1|F|D, {0xa75d}}},
+ {0xa75e, {1|F|D, {0xa75f}}},
+ {0xa760, {1|F|D, {0xa761}}},
+ {0xa762, {1|F|D, {0xa763}}},
+ {0xa764, {1|F|D, {0xa765}}},
+ {0xa766, {1|F|D, {0xa767}}},
+ {0xa768, {1|F|D, {0xa769}}},
+ {0xa76a, {1|F|D, {0xa76b}}},
+ {0xa76c, {1|F|D, {0xa76d}}},
+ {0xa76e, {1|F|D, {0xa76f}}},
+ {0xa779, {1|F|D, {0xa77a}}},
+ {0xa77b, {1|F|D, {0xa77c}}},
+ {0xa77d, {1|F|D, {0x1d79}}},
+ {0xa77e, {1|F|D, {0xa77f}}},
+ {0xa780, {1|F|D, {0xa781}}},
+ {0xa782, {1|F|D, {0xa783}}},
+ {0xa784, {1|F|D, {0xa785}}},
+ {0xa786, {1|F|D, {0xa787}}},
+ {0xa78b, {1|F|D, {0xa78c}}},
+ {0xa78d, {1|F|D, {0x0265}}},
+ {0xa790, {1|F|D, {0xa791}}},
+ {0xa792, {1|F|D, {0xa793}}},
+ {0xa796, {1|F|D, {0xa797}}},
+ {0xa798, {1|F|D, {0xa799}}},
+ {0xa79a, {1|F|D, {0xa79b}}},
+ {0xa79c, {1|F|D, {0xa79d}}},
+ {0xa79e, {1|F|D, {0xa79f}}},
+ {0xa7a0, {1|F|D, {0xa7a1}}},
+ {0xa7a2, {1|F|D, {0xa7a3}}},
+ {0xa7a4, {1|F|D, {0xa7a5}}},
+ {0xa7a6, {1|F|D, {0xa7a7}}},
+ {0xa7a8, {1|F|D, {0xa7a9}}},
+ {0xa7aa, {1|F|D, {0x0266}}},
+ {0xa7ab, {1|F|D, {0x025c}}},
+ {0xa7ac, {1|F|D, {0x0261}}},
+ {0xa7ad, {1|F|D, {0x026c}}},
+ {0xa7ae, {1|F|D, {0x026a}}},
+ {0xa7b0, {1|F|D, {0x029e}}},
+ {0xa7b1, {1|F|D, {0x0287}}},
+ {0xa7b2, {1|F|D, {0x029d}}},
+ {0xa7b3, {1|F|D, {0xab53}}},
+ {0xa7b4, {1|F|D, {0xa7b5}}},
+ {0xa7b6, {1|F|D, {0xa7b7}}},
+ {0xa7b8, {1|F|D, {0xa7b9}}},
+ {0xa7ba, {1|F|D, {0xa7bb}}},
+ {0xa7bc, {1|F|D, {0xa7bd}}},
+ {0xa7be, {1|F|D, {0xa7bf}}},
+ {0xa7c0, {1|F|D, {0xa7c1}}},
+ {0xa7c2, {1|F|D, {0xa7c3}}},
+ {0xa7c4, {1|F|D, {0xa794}}},
+ {0xa7c5, {1|F|D, {0x0282}}},
+ {0xa7c6, {1|F|D, {0x1d8e}}},
+ {0xa7c7, {1|F|D, {0xa7c8}}},
+ {0xa7c9, {1|F|D, {0xa7ca}}},
+ {0xa7cb, {1|F|D, {0x0264}}},
+ {0xa7cc, {1|F|D, {0xa7cd}}},
+ {0xa7ce, {1|F|D, {0xa7cf}}},
+ {0xa7d0, {1|F|D, {0xa7d1}}},
+ {0xa7d2, {1|F|D, {0xa7d3}}},
+ {0xa7d4, {1|F|D, {0xa7d5}}},
+ {0xa7d6, {1|F|D, {0xa7d7}}},
+ {0xa7d8, {1|F|D, {0xa7d9}}},
+ {0xa7da, {1|F|D, {0xa7db}}},
+ {0xa7dc, {1|F|D, {0x019b}}},
+ {0xa7f5, {1|F|D, {0xa7f6}}},
+ {0xab70, {1|F|U, {0x13a0}}},
+ {0xab71, {1|F|U, {0x13a1}}},
+ {0xab72, {1|F|U, {0x13a2}}},
+ {0xab73, {1|F|U, {0x13a3}}},
+ {0xab74, {1|F|U, {0x13a4}}},
+ {0xab75, {1|F|U, {0x13a5}}},
+ {0xab76, {1|F|U, {0x13a6}}},
+ {0xab77, {1|F|U, {0x13a7}}},
+ {0xab78, {1|F|U, {0x13a8}}},
+ {0xab79, {1|F|U, {0x13a9}}},
+ {0xab7a, {1|F|U, {0x13aa}}},
+ {0xab7b, {1|F|U, {0x13ab}}},
+ {0xab7c, {1|F|U, {0x13ac}}},
+ {0xab7d, {1|F|U, {0x13ad}}},
+ {0xab7e, {1|F|U, {0x13ae}}},
+ {0xab7f, {1|F|U, {0x13af}}},
+ {0xab80, {1|F|U, {0x13b0}}},
+ {0xab81, {1|F|U, {0x13b1}}},
+ {0xab82, {1|F|U, {0x13b2}}},
+ {0xab83, {1|F|U, {0x13b3}}},
+ {0xab84, {1|F|U, {0x13b4}}},
+ {0xab85, {1|F|U, {0x13b5}}},
+ {0xab86, {1|F|U, {0x13b6}}},
+ {0xab87, {1|F|U, {0x13b7}}},
+ {0xab88, {1|F|U, {0x13b8}}},
+ {0xab89, {1|F|U, {0x13b9}}},
+ {0xab8a, {1|F|U, {0x13ba}}},
+ {0xab8b, {1|F|U, {0x13bb}}},
+ {0xab8c, {1|F|U, {0x13bc}}},
+ {0xab8d, {1|F|U, {0x13bd}}},
+ {0xab8e, {1|F|U, {0x13be}}},
+ {0xab8f, {1|F|U, {0x13bf}}},
+ {0xab90, {1|F|U, {0x13c0}}},
+ {0xab91, {1|F|U, {0x13c1}}},
+ {0xab92, {1|F|U, {0x13c2}}},
+ {0xab93, {1|F|U, {0x13c3}}},
+ {0xab94, {1|F|U, {0x13c4}}},
+ {0xab95, {1|F|U, {0x13c5}}},
+ {0xab96, {1|F|U, {0x13c6}}},
+ {0xab97, {1|F|U, {0x13c7}}},
+ {0xab98, {1|F|U, {0x13c8}}},
+ {0xab99, {1|F|U, {0x13c9}}},
+ {0xab9a, {1|F|U, {0x13ca}}},
+ {0xab9b, {1|F|U, {0x13cb}}},
+ {0xab9c, {1|F|U, {0x13cc}}},
+ {0xab9d, {1|F|U, {0x13cd}}},
+ {0xab9e, {1|F|U, {0x13ce}}},
+ {0xab9f, {1|F|U, {0x13cf}}},
+ {0xaba0, {1|F|U, {0x13d0}}},
+ {0xaba1, {1|F|U, {0x13d1}}},
+ {0xaba2, {1|F|U, {0x13d2}}},
+ {0xaba3, {1|F|U, {0x13d3}}},
+ {0xaba4, {1|F|U, {0x13d4}}},
+ {0xaba5, {1|F|U, {0x13d5}}},
+ {0xaba6, {1|F|U, {0x13d6}}},
+ {0xaba7, {1|F|U, {0x13d7}}},
+ {0xaba8, {1|F|U, {0x13d8}}},
+ {0xaba9, {1|F|U, {0x13d9}}},
+ {0xabaa, {1|F|U, {0x13da}}},
+ {0xabab, {1|F|U, {0x13db}}},
+ {0xabac, {1|F|U, {0x13dc}}},
+ {0xabad, {1|F|U, {0x13dd}}},
+ {0xabae, {1|F|U, {0x13de}}},
+ {0xabaf, {1|F|U, {0x13df}}},
+ {0xabb0, {1|F|U, {0x13e0}}},
+ {0xabb1, {1|F|U, {0x13e1}}},
+ {0xabb2, {1|F|U, {0x13e2}}},
+ {0xabb3, {1|F|U, {0x13e3}}},
+ {0xabb4, {1|F|U, {0x13e4}}},
+ {0xabb5, {1|F|U, {0x13e5}}},
+ {0xabb6, {1|F|U, {0x13e6}}},
+ {0xabb7, {1|F|U, {0x13e7}}},
+ {0xabb8, {1|F|U, {0x13e8}}},
+ {0xabb9, {1|F|U, {0x13e9}}},
+ {0xabba, {1|F|U, {0x13ea}}},
+ {0xabbb, {1|F|U, {0x13eb}}},
+ {0xabbc, {1|F|U, {0x13ec}}},
+ {0xabbd, {1|F|U, {0x13ed}}},
+ {0xabbe, {1|F|U, {0x13ee}}},
+ {0xabbf, {1|F|U, {0x13ef}}},
+ {0xfb00, {2|F|ST|SU|I(366), {0x0066, 0x0066}}},
+ {0xfb01, {2|F|ST|SU|I(370), {0x0066, 0x0069}}},
+ {0xfb02, {2|F|ST|SU|I(374), {0x0066, 0x006c}}},
+ {0xfb03, {3|F|ST|SU|I(378), {0x0066, 0x0066, 0x0069}}},
+ {0xfb04, {3|F|ST|SU|I(384), {0x0066, 0x0066, 0x006c}}},
+ {0xfb05, {2|F|ST|SU|I(390), {0x0073, 0x0074}}},
+ {0xfb06, {2|F|ST|SU|I(394), {0x0073, 0x0074}}},
+ {0xfb13, {2|F|ST|SU|I(398), {0x0574, 0x0576}}},
+ {0xfb14, {2|F|ST|SU|I(402), {0x0574, 0x0565}}},
+ {0xfb15, {2|F|ST|SU|I(406), {0x0574, 0x056b}}},
+ {0xfb16, {2|F|ST|SU|I(410), {0x057e, 0x0576}}},
+ {0xfb17, {2|F|ST|SU|I(414), {0x0574, 0x056d}}},
+ {0xff21, {1|F|D, {0xff41}}},
+ {0xff22, {1|F|D, {0xff42}}},
+ {0xff23, {1|F|D, {0xff43}}},
+ {0xff24, {1|F|D, {0xff44}}},
+ {0xff25, {1|F|D, {0xff45}}},
+ {0xff26, {1|F|D, {0xff46}}},
+ {0xff27, {1|F|D, {0xff47}}},
+ {0xff28, {1|F|D, {0xff48}}},
+ {0xff29, {1|F|D, {0xff49}}},
+ {0xff2a, {1|F|D, {0xff4a}}},
+ {0xff2b, {1|F|D, {0xff4b}}},
+ {0xff2c, {1|F|D, {0xff4c}}},
+ {0xff2d, {1|F|D, {0xff4d}}},
+ {0xff2e, {1|F|D, {0xff4e}}},
+ {0xff2f, {1|F|D, {0xff4f}}},
+ {0xff30, {1|F|D, {0xff50}}},
+ {0xff31, {1|F|D, {0xff51}}},
+ {0xff32, {1|F|D, {0xff52}}},
+ {0xff33, {1|F|D, {0xff53}}},
+ {0xff34, {1|F|D, {0xff54}}},
+ {0xff35, {1|F|D, {0xff55}}},
+ {0xff36, {1|F|D, {0xff56}}},
+ {0xff37, {1|F|D, {0xff57}}},
+ {0xff38, {1|F|D, {0xff58}}},
+ {0xff39, {1|F|D, {0xff59}}},
+ {0xff3a, {1|F|D, {0xff5a}}},
+ {0x10400, {1|F|D, {0x10428}}},
+ {0x10401, {1|F|D, {0x10429}}},
+ {0x10402, {1|F|D, {0x1042a}}},
+ {0x10403, {1|F|D, {0x1042b}}},
+ {0x10404, {1|F|D, {0x1042c}}},
+ {0x10405, {1|F|D, {0x1042d}}},
+ {0x10406, {1|F|D, {0x1042e}}},
+ {0x10407, {1|F|D, {0x1042f}}},
+ {0x10408, {1|F|D, {0x10430}}},
+ {0x10409, {1|F|D, {0x10431}}},
+ {0x1040a, {1|F|D, {0x10432}}},
+ {0x1040b, {1|F|D, {0x10433}}},
+ {0x1040c, {1|F|D, {0x10434}}},
+ {0x1040d, {1|F|D, {0x10435}}},
+ {0x1040e, {1|F|D, {0x10436}}},
+ {0x1040f, {1|F|D, {0x10437}}},
+ {0x10410, {1|F|D, {0x10438}}},
+ {0x10411, {1|F|D, {0x10439}}},
+ {0x10412, {1|F|D, {0x1043a}}},
+ {0x10413, {1|F|D, {0x1043b}}},
+ {0x10414, {1|F|D, {0x1043c}}},
+ {0x10415, {1|F|D, {0x1043d}}},
+ {0x10416, {1|F|D, {0x1043e}}},
+ {0x10417, {1|F|D, {0x1043f}}},
+ {0x10418, {1|F|D, {0x10440}}},
+ {0x10419, {1|F|D, {0x10441}}},
+ {0x1041a, {1|F|D, {0x10442}}},
+ {0x1041b, {1|F|D, {0x10443}}},
+ {0x1041c, {1|F|D, {0x10444}}},
+ {0x1041d, {1|F|D, {0x10445}}},
+ {0x1041e, {1|F|D, {0x10446}}},
+ {0x1041f, {1|F|D, {0x10447}}},
+ {0x10420, {1|F|D, {0x10448}}},
+ {0x10421, {1|F|D, {0x10449}}},
+ {0x10422, {1|F|D, {0x1044a}}},
+ {0x10423, {1|F|D, {0x1044b}}},
+ {0x10424, {1|F|D, {0x1044c}}},
+ {0x10425, {1|F|D, {0x1044d}}},
+ {0x10426, {1|F|D, {0x1044e}}},
+ {0x10427, {1|F|D, {0x1044f}}},
+ {0x104b0, {1|F|D, {0x104d8}}},
+ {0x104b1, {1|F|D, {0x104d9}}},
+ {0x104b2, {1|F|D, {0x104da}}},
+ {0x104b3, {1|F|D, {0x104db}}},
+ {0x104b4, {1|F|D, {0x104dc}}},
+ {0x104b5, {1|F|D, {0x104dd}}},
+ {0x104b6, {1|F|D, {0x104de}}},
+ {0x104b7, {1|F|D, {0x104df}}},
+ {0x104b8, {1|F|D, {0x104e0}}},
+ {0x104b9, {1|F|D, {0x104e1}}},
+ {0x104ba, {1|F|D, {0x104e2}}},
+ {0x104bb, {1|F|D, {0x104e3}}},
+ {0x104bc, {1|F|D, {0x104e4}}},
+ {0x104bd, {1|F|D, {0x104e5}}},
+ {0x104be, {1|F|D, {0x104e6}}},
+ {0x104bf, {1|F|D, {0x104e7}}},
+ {0x104c0, {1|F|D, {0x104e8}}},
+ {0x104c1, {1|F|D, {0x104e9}}},
+ {0x104c2, {1|F|D, {0x104ea}}},
+ {0x104c3, {1|F|D, {0x104eb}}},
+ {0x104c4, {1|F|D, {0x104ec}}},
+ {0x104c5, {1|F|D, {0x104ed}}},
+ {0x104c6, {1|F|D, {0x104ee}}},
+ {0x104c7, {1|F|D, {0x104ef}}},
+ {0x104c8, {1|F|D, {0x104f0}}},
+ {0x104c9, {1|F|D, {0x104f1}}},
+ {0x104ca, {1|F|D, {0x104f2}}},
+ {0x104cb, {1|F|D, {0x104f3}}},
+ {0x104cc, {1|F|D, {0x104f4}}},
+ {0x104cd, {1|F|D, {0x104f5}}},
+ {0x104ce, {1|F|D, {0x104f6}}},
+ {0x104cf, {1|F|D, {0x104f7}}},
+ {0x104d0, {1|F|D, {0x104f8}}},
+ {0x104d1, {1|F|D, {0x104f9}}},
+ {0x104d2, {1|F|D, {0x104fa}}},
+ {0x104d3, {1|F|D, {0x104fb}}},
+ {0x10570, {1|F|D, {0x10597}}},
+ {0x10571, {1|F|D, {0x10598}}},
+ {0x10572, {1|F|D, {0x10599}}},
+ {0x10573, {1|F|D, {0x1059a}}},
+ {0x10574, {1|F|D, {0x1059b}}},
+ {0x10575, {1|F|D, {0x1059c}}},
+ {0x10576, {1|F|D, {0x1059d}}},
+ {0x10577, {1|F|D, {0x1059e}}},
+ {0x10578, {1|F|D, {0x1059f}}},
+ {0x10579, {1|F|D, {0x105a0}}},
+ {0x1057a, {1|F|D, {0x105a1}}},
+ {0x1057c, {1|F|D, {0x105a3}}},
+ {0x1057d, {1|F|D, {0x105a4}}},
+ {0x1057e, {1|F|D, {0x105a5}}},
+ {0x1057f, {1|F|D, {0x105a6}}},
+ {0x10580, {1|F|D, {0x105a7}}},
+ {0x10581, {1|F|D, {0x105a8}}},
+ {0x10582, {1|F|D, {0x105a9}}},
+ {0x10583, {1|F|D, {0x105aa}}},
+ {0x10584, {1|F|D, {0x105ab}}},
+ {0x10585, {1|F|D, {0x105ac}}},
+ {0x10586, {1|F|D, {0x105ad}}},
+ {0x10587, {1|F|D, {0x105ae}}},
+ {0x10588, {1|F|D, {0x105af}}},
+ {0x10589, {1|F|D, {0x105b0}}},
+ {0x1058a, {1|F|D, {0x105b1}}},
+ {0x1058c, {1|F|D, {0x105b3}}},
+ {0x1058d, {1|F|D, {0x105b4}}},
+ {0x1058e, {1|F|D, {0x105b5}}},
+ {0x1058f, {1|F|D, {0x105b6}}},
+ {0x10590, {1|F|D, {0x105b7}}},
+ {0x10591, {1|F|D, {0x105b8}}},
+ {0x10592, {1|F|D, {0x105b9}}},
+ {0x10594, {1|F|D, {0x105bb}}},
+ {0x10595, {1|F|D, {0x105bc}}},
+ {0x10c80, {1|F|D, {0x10cc0}}},
+ {0x10c81, {1|F|D, {0x10cc1}}},
+ {0x10c82, {1|F|D, {0x10cc2}}},
+ {0x10c83, {1|F|D, {0x10cc3}}},
+ {0x10c84, {1|F|D, {0x10cc4}}},
+ {0x10c85, {1|F|D, {0x10cc5}}},
+ {0x10c86, {1|F|D, {0x10cc6}}},
+ {0x10c87, {1|F|D, {0x10cc7}}},
+ {0x10c88, {1|F|D, {0x10cc8}}},
+ {0x10c89, {1|F|D, {0x10cc9}}},
+ {0x10c8a, {1|F|D, {0x10cca}}},
+ {0x10c8b, {1|F|D, {0x10ccb}}},
+ {0x10c8c, {1|F|D, {0x10ccc}}},
+ {0x10c8d, {1|F|D, {0x10ccd}}},
+ {0x10c8e, {1|F|D, {0x10cce}}},
+ {0x10c8f, {1|F|D, {0x10ccf}}},
+ {0x10c90, {1|F|D, {0x10cd0}}},
+ {0x10c91, {1|F|D, {0x10cd1}}},
+ {0x10c92, {1|F|D, {0x10cd2}}},
+ {0x10c93, {1|F|D, {0x10cd3}}},
+ {0x10c94, {1|F|D, {0x10cd4}}},
+ {0x10c95, {1|F|D, {0x10cd5}}},
+ {0x10c96, {1|F|D, {0x10cd6}}},
+ {0x10c97, {1|F|D, {0x10cd7}}},
+ {0x10c98, {1|F|D, {0x10cd8}}},
+ {0x10c99, {1|F|D, {0x10cd9}}},
+ {0x10c9a, {1|F|D, {0x10cda}}},
+ {0x10c9b, {1|F|D, {0x10cdb}}},
+ {0x10c9c, {1|F|D, {0x10cdc}}},
+ {0x10c9d, {1|F|D, {0x10cdd}}},
+ {0x10c9e, {1|F|D, {0x10cde}}},
+ {0x10c9f, {1|F|D, {0x10cdf}}},
+ {0x10ca0, {1|F|D, {0x10ce0}}},
+ {0x10ca1, {1|F|D, {0x10ce1}}},
+ {0x10ca2, {1|F|D, {0x10ce2}}},
+ {0x10ca3, {1|F|D, {0x10ce3}}},
+ {0x10ca4, {1|F|D, {0x10ce4}}},
+ {0x10ca5, {1|F|D, {0x10ce5}}},
+ {0x10ca6, {1|F|D, {0x10ce6}}},
+ {0x10ca7, {1|F|D, {0x10ce7}}},
+ {0x10ca8, {1|F|D, {0x10ce8}}},
+ {0x10ca9, {1|F|D, {0x10ce9}}},
+ {0x10caa, {1|F|D, {0x10cea}}},
+ {0x10cab, {1|F|D, {0x10ceb}}},
+ {0x10cac, {1|F|D, {0x10cec}}},
+ {0x10cad, {1|F|D, {0x10ced}}},
+ {0x10cae, {1|F|D, {0x10cee}}},
+ {0x10caf, {1|F|D, {0x10cef}}},
+ {0x10cb0, {1|F|D, {0x10cf0}}},
+ {0x10cb1, {1|F|D, {0x10cf1}}},
+ {0x10cb2, {1|F|D, {0x10cf2}}},
+ {0x10d50, {1|F|D, {0x10d70}}},
+ {0x10d51, {1|F|D, {0x10d71}}},
+ {0x10d52, {1|F|D, {0x10d72}}},
+ {0x10d53, {1|F|D, {0x10d73}}},
+ {0x10d54, {1|F|D, {0x10d74}}},
+ {0x10d55, {1|F|D, {0x10d75}}},
+ {0x10d56, {1|F|D, {0x10d76}}},
+ {0x10d57, {1|F|D, {0x10d77}}},
+ {0x10d58, {1|F|D, {0x10d78}}},
+ {0x10d59, {1|F|D, {0x10d79}}},
+ {0x10d5a, {1|F|D, {0x10d7a}}},
+ {0x10d5b, {1|F|D, {0x10d7b}}},
+ {0x10d5c, {1|F|D, {0x10d7c}}},
+ {0x10d5d, {1|F|D, {0x10d7d}}},
+ {0x10d5e, {1|F|D, {0x10d7e}}},
+ {0x10d5f, {1|F|D, {0x10d7f}}},
+ {0x10d60, {1|F|D, {0x10d80}}},
+ {0x10d61, {1|F|D, {0x10d81}}},
+ {0x10d62, {1|F|D, {0x10d82}}},
+ {0x10d63, {1|F|D, {0x10d83}}},
+ {0x10d64, {1|F|D, {0x10d84}}},
+ {0x10d65, {1|F|D, {0x10d85}}},
+ {0x118a0, {1|F|D, {0x118c0}}},
+ {0x118a1, {1|F|D, {0x118c1}}},
+ {0x118a2, {1|F|D, {0x118c2}}},
+ {0x118a3, {1|F|D, {0x118c3}}},
+ {0x118a4, {1|F|D, {0x118c4}}},
+ {0x118a5, {1|F|D, {0x118c5}}},
+ {0x118a6, {1|F|D, {0x118c6}}},
+ {0x118a7, {1|F|D, {0x118c7}}},
+ {0x118a8, {1|F|D, {0x118c8}}},
+ {0x118a9, {1|F|D, {0x118c9}}},
+ {0x118aa, {1|F|D, {0x118ca}}},
+ {0x118ab, {1|F|D, {0x118cb}}},
+ {0x118ac, {1|F|D, {0x118cc}}},
+ {0x118ad, {1|F|D, {0x118cd}}},
+ {0x118ae, {1|F|D, {0x118ce}}},
+ {0x118af, {1|F|D, {0x118cf}}},
+ {0x118b0, {1|F|D, {0x118d0}}},
+ {0x118b1, {1|F|D, {0x118d1}}},
+ {0x118b2, {1|F|D, {0x118d2}}},
+ {0x118b3, {1|F|D, {0x118d3}}},
+ {0x118b4, {1|F|D, {0x118d4}}},
+ {0x118b5, {1|F|D, {0x118d5}}},
+ {0x118b6, {1|F|D, {0x118d6}}},
+ {0x118b7, {1|F|D, {0x118d7}}},
+ {0x118b8, {1|F|D, {0x118d8}}},
+ {0x118b9, {1|F|D, {0x118d9}}},
+ {0x118ba, {1|F|D, {0x118da}}},
+ {0x118bb, {1|F|D, {0x118db}}},
+ {0x118bc, {1|F|D, {0x118dc}}},
+ {0x118bd, {1|F|D, {0x118dd}}},
+ {0x118be, {1|F|D, {0x118de}}},
+ {0x118bf, {1|F|D, {0x118df}}},
+ {0x16e40, {1|F|D, {0x16e60}}},
+ {0x16e41, {1|F|D, {0x16e61}}},
+ {0x16e42, {1|F|D, {0x16e62}}},
+ {0x16e43, {1|F|D, {0x16e63}}},
+ {0x16e44, {1|F|D, {0x16e64}}},
+ {0x16e45, {1|F|D, {0x16e65}}},
+ {0x16e46, {1|F|D, {0x16e66}}},
+ {0x16e47, {1|F|D, {0x16e67}}},
+ {0x16e48, {1|F|D, {0x16e68}}},
+ {0x16e49, {1|F|D, {0x16e69}}},
+ {0x16e4a, {1|F|D, {0x16e6a}}},
+ {0x16e4b, {1|F|D, {0x16e6b}}},
+ {0x16e4c, {1|F|D, {0x16e6c}}},
+ {0x16e4d, {1|F|D, {0x16e6d}}},
+ {0x16e4e, {1|F|D, {0x16e6e}}},
+ {0x16e4f, {1|F|D, {0x16e6f}}},
+ {0x16e50, {1|F|D, {0x16e70}}},
+ {0x16e51, {1|F|D, {0x16e71}}},
+ {0x16e52, {1|F|D, {0x16e72}}},
+ {0x16e53, {1|F|D, {0x16e73}}},
+ {0x16e54, {1|F|D, {0x16e74}}},
+ {0x16e55, {1|F|D, {0x16e75}}},
+ {0x16e56, {1|F|D, {0x16e76}}},
+ {0x16e57, {1|F|D, {0x16e77}}},
+ {0x16e58, {1|F|D, {0x16e78}}},
+ {0x16e59, {1|F|D, {0x16e79}}},
+ {0x16e5a, {1|F|D, {0x16e7a}}},
+ {0x16e5b, {1|F|D, {0x16e7b}}},
+ {0x16e5c, {1|F|D, {0x16e7c}}},
+ {0x16e5d, {1|F|D, {0x16e7d}}},
+ {0x16e5e, {1|F|D, {0x16e7e}}},
+ {0x16e5f, {1|F|D, {0x16e7f}}},
+ {0x16ea0, {1|F|D, {0x16ebb}}},
+ {0x16ea1, {1|F|D, {0x16ebc}}},
+ {0x16ea2, {1|F|D, {0x16ebd}}},
+ {0x16ea3, {1|F|D, {0x16ebe}}},
+ {0x16ea4, {1|F|D, {0x16ebf}}},
+ {0x16ea5, {1|F|D, {0x16ec0}}},
+ {0x16ea6, {1|F|D, {0x16ec1}}},
+ {0x16ea7, {1|F|D, {0x16ec2}}},
+ {0x16ea8, {1|F|D, {0x16ec3}}},
+ {0x16ea9, {1|F|D, {0x16ec4}}},
+ {0x16eaa, {1|F|D, {0x16ec5}}},
+ {0x16eab, {1|F|D, {0x16ec6}}},
+ {0x16eac, {1|F|D, {0x16ec7}}},
+ {0x16ead, {1|F|D, {0x16ec8}}},
+ {0x16eae, {1|F|D, {0x16ec9}}},
+ {0x16eaf, {1|F|D, {0x16eca}}},
+ {0x16eb0, {1|F|D, {0x16ecb}}},
+ {0x16eb1, {1|F|D, {0x16ecc}}},
+ {0x16eb2, {1|F|D, {0x16ecd}}},
+ {0x16eb3, {1|F|D, {0x16ece}}},
+ {0x16eb4, {1|F|D, {0x16ecf}}},
+ {0x16eb5, {1|F|D, {0x16ed0}}},
+ {0x16eb6, {1|F|D, {0x16ed1}}},
+ {0x16eb7, {1|F|D, {0x16ed2}}},
+ {0x16eb8, {1|F|D, {0x16ed3}}},
+ {0x1e900, {1|F|D, {0x1e922}}},
+ {0x1e901, {1|F|D, {0x1e923}}},
+ {0x1e902, {1|F|D, {0x1e924}}},
+ {0x1e903, {1|F|D, {0x1e925}}},
+ {0x1e904, {1|F|D, {0x1e926}}},
+ {0x1e905, {1|F|D, {0x1e927}}},
+ {0x1e906, {1|F|D, {0x1e928}}},
+ {0x1e907, {1|F|D, {0x1e929}}},
+ {0x1e908, {1|F|D, {0x1e92a}}},
+ {0x1e909, {1|F|D, {0x1e92b}}},
+ {0x1e90a, {1|F|D, {0x1e92c}}},
+ {0x1e90b, {1|F|D, {0x1e92d}}},
+ {0x1e90c, {1|F|D, {0x1e92e}}},
+ {0x1e90d, {1|F|D, {0x1e92f}}},
+ {0x1e90e, {1|F|D, {0x1e930}}},
+ {0x1e90f, {1|F|D, {0x1e931}}},
+ {0x1e910, {1|F|D, {0x1e932}}},
+ {0x1e911, {1|F|D, {0x1e933}}},
+ {0x1e912, {1|F|D, {0x1e934}}},
+ {0x1e913, {1|F|D, {0x1e935}}},
+ {0x1e914, {1|F|D, {0x1e936}}},
+ {0x1e915, {1|F|D, {0x1e937}}},
+ {0x1e916, {1|F|D, {0x1e938}}},
+ {0x1e917, {1|F|D, {0x1e939}}},
+ {0x1e918, {1|F|D, {0x1e93a}}},
+ {0x1e919, {1|F|D, {0x1e93b}}},
+ {0x1e91a, {1|F|D, {0x1e93c}}},
+ {0x1e91b, {1|F|D, {0x1e93d}}},
+ {0x1e91c, {1|F|D, {0x1e93e}}},
+ {0x1e91d, {1|F|D, {0x1e93f}}},
+ {0x1e91e, {1|F|D, {0x1e940}}},
+ {0x1e91f, {1|F|D, {0x1e941}}},
+ {0x1e920, {1|F|D, {0x1e942}}},
+ {0x1e921, {1|F|D, {0x1e943}}},
+#define CaseFold_Locale (*(CaseFold_11_Type (*)[2])(CaseFold_11_Table+1583))
+ {0x0049, {1|F|D, {0x0069}}},
+ {0x0130, {2|F|D, {0x0069, 0x0307}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseFold_11_hash -N onigenc_unicode_CaseFold_11_lookup -n */
+
+/* maximum key range = 3756, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseFold_11_hash(const OnigCodePoint code)
+{
+ static const unsigned short asso_values[] =
+ {
+ 2, 107, 6, 43, 1, 5, 70, 14, 5, 396,
+ 239, 925, 3763, 3763, 3763, 3763, 3763, 3763, 3763, 3763,
+ 3763, 3763, 3763, 3763, 3763, 45, 404, 3763, 3763, 3763,
+ 3763, 3763, 3763, 400, 3763, 3763, 3763, 3763, 3763, 20,
+ 3763, 3763, 3763, 3763, 3763, 3763, 3763, 3763, 3763, 472,
+ 3763, 3763, 3763, 3763, 3763, 3763, 3763, 163, 3763, 3763,
+ 311, 310, 445, 3, 3763, 3763, 482, 10, 3763, 3763,
+ 3763, 3763, 3763, 604, 3763, 3763, 315, 863, 428, 38,
+ 2198, 226, 42, 182, 240, 94, 1542, 7, 12, 24,
+ 2250, 764, 872, 684, 2182, 168, 1933, 308, 2170, 153,
+ 2106, 108, 1653, 261, 1889, 426, 1851, 484, 470, 506,
+ 2234, 286, 1417, 411, 1461, 366, 1436, 352, 60, 667,
+ 1357, 551, 1110, 611, 1440, 597, 631, 614, 1630, 691,
+ 1762, 821, 1950, 747, 1682, 542, 1752, 740, 1949, 855,
+ 1912, 845, 1840, 1230, 1928, 1106, 1572, 1003, 1323, 1223,
+ 500, 1203, 1783, 1094, 1602, 957, 1472, 1157, 2059, 1188,
+ 2140, 947, 937, 1257, 1395, 1168, 196, 1317, 258, 1246,
+ 141, 1587, 38, 1563, 3, 1663, 53, 1371, 178, 1480,
+ 41, 1745, 57, 1723, 356, 1698, 122, 1609, 77, 1726,
+ 76, 1710, 44, 1740, 2, 1815, 568, 2094, 146, 2214,
+ 340, 2126, 73, 408, 101, 1980, 149
+ };
+ return asso_values[bits_of(code, 2)+79] + asso_values[bits_of(code, 1)] + asso_values[bits_of(code, 0)];
+}
+
+static const CodePointList3 *
+onigenc_unicode_CaseFold_11_lookup(const OnigCodePoint code)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x41,
+ MAX_CODE_VALUE = 0x1e921,
+ TOTAL_KEYWORDS = 1585,
+ MIN_WORD_LENGTH = 3,
+ MAX_WORD_LENGTH = 3,
+ MIN_HASH_VALUE = 7,
+ MAX_HASH_VALUE = 3762
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1ff3*/ 856,
+ -1, -1,
+ /*0x0208*/ 194,
+ -1,
+ /*0x1f88*/ 776,
+ /*0x10408*/ 1284,
+ /*0x0408*/ 305,
+ /*0x0108*/ 61,
+ -1,
+ /*0x1f89*/ 777,
+ /*0x10409*/ 1285,
+ /*0x0409*/ 306,
+ /*0xab88*/ 1182,
+ /*0x2c08*/ 920,
+ -1,
+ /*0x0388*/ 235,
+ -1,
+ /*0xab89*/ 1183,
+ /*0x2c09*/ 921,
+ /*0x020a*/ 195,
+ /*0x0389*/ 236,
+ /*0x1f8a*/ 778,
+ /*0x1040a*/ 1286,
+ /*0x040a*/ 307,
+ /*0x010a*/ 62,
+ /*0x2c88*/ 979,
+ -1, -1, -1,
+ /*0xab8a*/ 1184,
+ /*0x2c0a*/ 922,
+ -1,
+ /*0x038a*/ 237,
+ /*0x0200*/ 190,
+ -1,
+ /*0x1f80*/ 768,
+ /*0x10400*/ 1276,
+ /*0x0400*/ 297,
+ /*0x0100*/ 57,
+ /*0x1f83*/ 771,
+ /*0x10403*/ 1279,
+ /*0x0403*/ 300,
+ /*0x2c8a*/ 980,
+ /*0xab80*/ 1174,
+ /*0x2c00*/ 912,
+ /*0x10c88*/ 1395,
+ /*0x2183*/ 885,
+ /*0xab83*/ 1177,
+ /*0x2c03*/ 915,
+ /*0x0189*/ 126,
+ /*0x10c89*/ 1396,
+ -1,
+ /*0x03f1*/ 288,
+ -1,
+ /*0x1fe7*/ 849,
+ /*0x1e908*/ 1557,
+ /*0x2c80*/ 975,
+ /*0x1fa7*/ 807,
+ /*0x10427*/ 1315,
+ /*0x0427*/ 336,
+ /*0x1e909*/ 1558,
+ /*0x018a*/ 127,
+ /*0x10c8a*/ 1397,
+ /*0x2c67*/ 964,
+ -1,
+ /*0xaba7*/ 1213,
+ /*0x2c27*/ 951,
+ -1,
+ /*0x03a7*/ 263,
+ -1,
+ /*0x1ffb*/ 863,
+ -1,
+ /*0x1e90a*/ 1559,
+ /*0x017b*/ 118,
+ /*0xa780*/ 1107,
+ -1,
+ /*0x10c80*/ 1387,
+ -1, -1, -1,
+ /*0x10c83*/ 1390,
+ /*0x01f1*/ 181,
+ /*0x2c6f*/ 969,
+ /*0x2c6d*/ 967,
+ -1, -1,
+ /*0x1e900*/ 1549,
+ /*0x13fb*/ 527,
+ -1,
+ /*0x0206*/ 193,
+ /*0x1e903*/ 1552,
+ /*0x1f86*/ 774,
+ /*0x10406*/ 1282,
+ /*0x0406*/ 303,
+ /*0x0106*/ 60,
+ /*0x2ced*/ 1026,
+ -1,
+ /*0x01a7*/ 145,
+ /*0x10ca7*/ 1426,
+ /*0xab86*/ 1180,
+ /*0x2c06*/ 918,
+ /*0x017d*/ 119,
+ /*0x0386*/ 234,
+ /*0x0216*/ 201,
+ /*0x00df*/ 56,
+ /*0x1f96*/ 790,
+ /*0x10416*/ 1298,
+ /*0x0416*/ 319,
+ /*0x0116*/ 68,
+ /*0x03fd*/ 294,
+ -1, -1,
+ /*0x2c86*/ 978,
+ /*0xab96*/ 1196,
+ /*0x2c16*/ 934,
+ /*0x13fd*/ 529,
+ /*0x0396*/ 247,
+ -1, -1,
+ /*0x1feb*/ 853,
+ -1, -1, -1, -1, -1, -1,
+ /*0x2c96*/ 986,
+ -1,
+ /*0x2c6b*/ 966,
+ -1,
+ /*0xa786*/ 1110,
+ /*0x0186*/ 124,
+ /*0x10c86*/ 1393,
+ /*0xfb00*/ 1238,
+ -1, -1, -1,
+ /*0xfb03*/ 1241,
+ /*0x1fdb*/ 844,
+ /*0x00dd*/ 54,
+ /*0x2ceb*/ 1025,
+ -1,
+ /*0x1e906*/ 1555,
+ /*0x1ff7*/ 859,
+ /*0xa796*/ 1115,
+ /*0x0196*/ 135,
+ /*0x10c96*/ 1409,
+ -1,
+ /*0x0214*/ 200,
+ /*0x017f*/ 120,
+ /*0x1f94*/ 788,
+ /*0x10414*/ 1296,
+ /*0x0414*/ 317,
+ /*0x0114*/ 67,
+ /*0x03f7*/ 291,
+ /*0x2c7f*/ 974,
+ /*0x1e916*/ 1571,
+ /*0x03ff*/ 296,
+ /*0xab94*/ 1194,
+ /*0x2c14*/ 932,
+ -1,
+ /*0x0394*/ 245,
+ -1,
+ /*0x0210*/ 198,
+ /*0x1c88*/ 538,
+ /*0x1f90*/ 784,
+ /*0x10410*/ 1292,
+ /*0x0410*/ 313,
+ /*0x0110*/ 65,
+ /*0x1c89*/ 539,
+ -1,
+ /*0x2c94*/ 985,
+ -1,
+ /*0xab90*/ 1190,
+ /*0x2c10*/ 928,
+ /*0x1fe3*/ 846,
+ /*0x0390*/ 241,
+ /*0x0204*/ 192,
+ /*0x01db*/ 170,
+ /*0x1f84*/ 772,
+ /*0x10404*/ 1280,
+ /*0x0404*/ 301,
+ /*0x0104*/ 59,
+ /*0x01f7*/ 185,
+ /*0x2c63*/ 962,
+ -1,
+ /*0x2c90*/ 983,
+ /*0xab84*/ 1178,
+ /*0x2c04*/ 916,
+ /*0xfb06*/ 1244,
+ /*0x0194*/ 134,
+ /*0x10c94*/ 1407,
+ /*0x0057*/ 21,
+ /*0x1fd7*/ 840,
+ -1,
+ /*0x1c80*/ 530,
+ -1, -1, -1,
+ /*0x1c83*/ 533,
+ /*0x2c84*/ 977,
+ /*0x1e914*/ 1569,
+ -1,
+ /*0xfb16*/ 1248,
+ /*0xa790*/ 1113,
+ /*0x0190*/ 131,
+ /*0x10c90*/ 1403,
+ -1, -1, -1, -1, -1, -1,
+ /*0x037f*/ 233,
+ -1, -1,
+ /*0x1e910*/ 1565,
+ /*0x1ca7*/ 563,
+ /*0xa784*/ 1109,
+ /*0x0184*/ 123,
+ /*0x10c84*/ 1391,
+ /*0x0202*/ 191,
+ -1,
+ /*0x1f82*/ 770,
+ /*0x10402*/ 1278,
+ /*0x0402*/ 299,
+ /*0x0102*/ 58,
+ -1, -1, -1,
+ /*0x1e904*/ 1553,
+ /*0xab82*/ 1176,
+ /*0x2c02*/ 914,
+ /*0x01d7*/ 168,
+ /*0x10573*/ 1355,
+ -1, -1,
+ /*0x1f85*/ 773,
+ /*0x10405*/ 1281,
+ /*0x0405*/ 302,
+ /*0x0508*/ 425,
+ -1,
+ /*0x00db*/ 52,
+ -1,
+ /*0x2c82*/ 976,
+ /*0xab85*/ 1179,
+ /*0x2c05*/ 917,
+ -1,
+ /*0xfb14*/ 1246,
+ -1, -1,
+ /*0x1c86*/ 536,
+ -1, -1,
+ /*0x0059*/ 23,
+ /*0x1fd9*/ 842,
+ /*0x0218*/ 202,
+ /*0x050a*/ 426,
+ /*0x1f98*/ 792,
+ /*0x10418*/ 1300,
+ /*0x0418*/ 321,
+ /*0x0118*/ 69,
+ /*0xa782*/ 1108,
+ /*0x0182*/ 122,
+ /*0x10c82*/ 1389,
+ /*0x1c96*/ 546,
+ /*0xab98*/ 1198,
+ /*0x2c18*/ 936,
+ -1,
+ /*0x0398*/ 249,
+ -1,
+ /*0x0500*/ 421,
+ -1, -1,
+ /*0x1e902*/ 1551,
+ -1,
+ /*0x10571*/ 1353,
+ /*0xfb04*/ 1242,
+ /*0x10c85*/ 1392,
+ /*0x2c98*/ 987,
+ -1,
+ /*0x0220*/ 206,
+ -1,
+ /*0x1fa0*/ 800,
+ /*0x10420*/ 1308,
+ /*0x0420*/ 329,
+ /*0x0120*/ 73,
+ -1,
+ /*0x1e905*/ 1554,
+ -1, -1,
+ /*0xaba0*/ 1206,
+ /*0x2c20*/ 944,
+ -1,
+ /*0x03a0*/ 257,
+ /*0x01d9*/ 169,
+ -1,
+ /*0xa798*/ 1116,
+ /*0x0198*/ 137,
+ /*0x10c98*/ 1411,
+ -1, -1, -1,
+ /*0x0212*/ 199,
+ /*0x2ca0*/ 991,
+ /*0x1f92*/ 786,
+ /*0x10412*/ 1294,
+ /*0x0412*/ 315,
+ /*0x0112*/ 66,
+ /*0x1e918*/ 1573,
+ /*0x1c94*/ 544,
+ /*0x1e88*/ 654,
+ /*0x1e08*/ 590,
+ /*0xab92*/ 1192,
+ /*0x2c12*/ 930,
+ -1,
+ /*0x0392*/ 243,
+ -1, -1, -1, -1,
+ /*0xfb02*/ 1240,
+ /*0xa7a0*/ 1120,
+ /*0x01a0*/ 141,
+ /*0x10ca0*/ 1419,
+ /*0x1c90*/ 540,
+ /*0x2c92*/ 984,
+ /*0x0506*/ 424,
+ /*0x1e8a*/ 655,
+ /*0x1e0a*/ 591,
+ -1, -1, -1,
+ /*0x1057d*/ 1364,
+ /*0x1e920*/ 1581,
+ /*0xfb05*/ 1243,
+ -1,
+ /*0x1ff9*/ 861,
+ -1,
+ /*0x1c84*/ 534,
+ /*0x0179*/ 117,
+ /*0x0516*/ 432,
+ /*0x1e80*/ 650,
+ /*0x1e00*/ 586,
+ /*0xa792*/ 1114,
+ -1,
+ /*0x10c92*/ 1405,
+ /*0x0226*/ 209,
+ /*0x03f9*/ 292,
+ /*0x1fa6*/ 806,
+ /*0x10426*/ 1314,
+ /*0x0426*/ 335,
+ /*0x0126*/ 76,
+ /*0x1fe9*/ 851,
+ /*0x13f9*/ 525,
+ -1,
+ /*0x1e912*/ 1567,
+ /*0xaba6*/ 1212,
+ /*0x2c26*/ 950,
+ /*0x00d9*/ 50,
+ /*0x03a6*/ 262,
+ /*0x0224*/ 208,
+ /*0x2c69*/ 965,
+ /*0x1fa4*/ 804,
+ /*0x10424*/ 1312,
+ /*0x0424*/ 333,
+ /*0x0124*/ 75,
+ -1, -1, -1,
+ /*0x2ca6*/ 994,
+ /*0xaba4*/ 1210,
+ /*0x2c24*/ 948,
+ -1,
+ /*0x03a4*/ 260,
+ -1, -1, -1,
+ /*0x10577*/ 1359,
+ -1, -1,
+ /*0x1057f*/ 1366,
+ -1,
+ /*0x1c82*/ 532,
+ /*0x2ca4*/ 993,
+ -1,
+ /*0x0514*/ 431,
+ -1,
+ /*0xa7a6*/ 1123,
+ /*0x01a6*/ 144,
+ /*0x10ca6*/ 1425,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1c85*/ 535,
+ /*0x1e86*/ 653,
+ /*0x1e06*/ 589,
+ /*0x10d5f*/ 1453,
+ /*0x0510*/ 429,
+ /*0xa7a4*/ 1122,
+ /*0x01a4*/ 143,
+ /*0x10ca4*/ 1423,
+ /*0x1ffc*/ 864,
+ /*0x0222*/ 207,
+ /*0x047c*/ 359,
+ /*0x1fa2*/ 802,
+ /*0x10422*/ 1310,
+ /*0x0422*/ 331,
+ /*0x0122*/ 74,
+ /*0x1e96*/ 661,
+ /*0x1e16*/ 597,
+ /*0x048a*/ 362,
+ /*0x0504*/ 423,
+ /*0xaba2*/ 1208,
+ /*0x2c22*/ 946,
+ /*0x1c98*/ 548,
+ -1, -1,
+ /*0x021a*/ 203,
+ /*0x13fc*/ 528,
+ /*0x1f9a*/ 794,
+ /*0x1041a*/ 1302,
+ /*0x041a*/ 323,
+ /*0x011a*/ 70,
+ -1,
+ /*0x0480*/ 361,
+ /*0x2ca2*/ 992,
+ -1,
+ /*0xab9a*/ 1200,
+ /*0x2c1a*/ 938,
+ -1,
+ /*0x039a*/ 251,
+ /*0x10d5d*/ 1451,
+ -1, -1,
+ /*0x10d65*/ 1459,
+ -1, -1, -1,
+ /*0x1f5f*/ 759,
+ /*0x1ca0*/ 556,
+ /*0x2c9a*/ 988,
+ /*0x01fc*/ 188,
+ /*0x1f08*/ 716,
+ /*0xa7a2*/ 1121,
+ /*0x01a2*/ 142,
+ /*0x10ca2*/ 1421,
+ /*0x10d61*/ 1455,
+ /*0x1f09*/ 717,
+ -1, -1,
+ /*0x10a7*/ 491,
+ -1, -1,
+ /*0x1e94*/ 660,
+ /*0x1e14*/ 596,
+ /*0x0502*/ 422,
+ -1, -1,
+ /*0xa79a*/ 1117,
+ /*0x1f0a*/ 718,
+ /*0x10c9a*/ 1413,
+ /*0x1c92*/ 542,
+ -1,
+ /*0x1f9d*/ 797,
+ /*0x1041d*/ 1305,
+ /*0x041d*/ 326,
+ -1, -1,
+ /*0x1e90*/ 658,
+ /*0x1e10*/ 594,
+ /*0x1e91a*/ 1575,
+ /*0xab9d*/ 1203,
+ /*0x2c1d*/ 941,
+ /*0x1f5d*/ 758,
+ /*0x039d*/ 254,
+ /*0x021c*/ 204,
+ -1,
+ /*0x1f9c*/ 796,
+ /*0x1041c*/ 1304,
+ /*0x041c*/ 325,
+ /*0x011c*/ 71,
+ -1,
+ /*0x1e84*/ 652,
+ /*0x1e04*/ 588,
+ -1,
+ /*0xab9c*/ 1202,
+ /*0x2c1c*/ 940,
+ -1,
+ /*0x039c*/ 253,
+ -1,
+ /*0x0518*/ 433,
+ -1,
+ /*0x0047*/ 6,
+ /*0x1fc7*/ 831,
+ /*0x0496*/ 368,
+ /*0xa77b*/ 1104,
+ /*0x0147*/ 91,
+ /*0x021e*/ 205,
+ /*0x2c9c*/ 989,
+ /*0x1f9e*/ 798,
+ /*0x1041e*/ 1306,
+ /*0x041e*/ 327,
+ /*0x011e*/ 72,
+ /*0x019d*/ 139,
+ /*0x10c9d*/ 1416,
+ /*0x1ca6*/ 562,
+ -1,
+ /*0xab9e*/ 1204,
+ /*0x2c1e*/ 942,
+ -1,
+ /*0x039e*/ 255,
+ /*0x1f6f*/ 767,
+ /*0x1f6d*/ 765,
+ /*0x2165*/ 874,
+ /*0x1e91d*/ 1578,
+ /*0x0520*/ 437,
+ /*0xa79c*/ 1118,
+ /*0x019c*/ 138,
+ /*0x10c9c*/ 1415,
+ /*0x1ca4*/ 560,
+ /*0x2c9e*/ 990,
+ /*0x118a7*/ 1467,
+ -1,
+ /*0xa77d*/ 1105,
+ -1,
+ /*0x2161*/ 870,
+ /*0x1e82*/ 651,
+ /*0x1e02*/ 587,
+ /*0x1e91c*/ 1577,
+ /*0x2167*/ 876,
+ -1, -1,
+ /*0xa7c7*/ 1145,
+ /*0x01c7*/ 159,
+ /*0x10d5b*/ 1449,
+ /*0x1fb8*/ 821,
+ -1,
+ /*0x0512*/ 430,
+ /*0xa79e*/ 1119,
+ /*0x0494*/ 367,
+ /*0x10c9e*/ 1417,
+ -1,
+ /*0x022a*/ 211,
+ /*0xabb8*/ 1230,
+ /*0x1faa*/ 810,
+ -1,
+ /*0x042a*/ 339,
+ /*0x012a*/ 78,
+ /*0x216f*/ 884,
+ /*0x216d*/ 882,
+ /*0x1e91e*/ 1579,
+ -1,
+ /*0xabaa*/ 1216,
+ /*0x2c2a*/ 954,
+ /*0x0490*/ 365,
+ /*0x03aa*/ 266,
+ /*0x2cb8*/ 1003,
+ /*0x1f6b*/ 763,
+ -1, -1, -1,
+ /*0x1e98*/ 663,
+ /*0x1e18*/ 598,
+ -1,
+ /*0x1ca2*/ 558,
+ /*0x2caa*/ 996,
+ -1, -1,
+ /*0x10579*/ 1361,
+ -1,
+ /*0x2c75*/ 972,
+ /*0x10d63*/ 1457,
+ /*0x03f5*/ 290,
+ -1,
+ /*0xa7b8*/ 1136,
+ /*0x01b8*/ 155,
+ /*0x1f5b*/ 757,
+ -1, -1,
+ /*0x1c9a*/ 550,
+ -1,
+ /*0x0526*/ 440,
+ -1,
+ /*0xa7aa*/ 1125,
+ -1,
+ /*0x10caa*/ 1429,
+ /*0x1ea0*/ 668,
+ /*0x1e20*/ 602,
+ /*0x022e*/ 213,
+ /*0x10d57*/ 1445,
+ /*0x1fae*/ 814,
+ -1,
+ /*0x042e*/ 343,
+ /*0x012e*/ 80,
+ /*0x216b*/ 880,
+ /*0x0524*/ 439,
+ -1,
+ /*0x00c7*/ 33,
+ /*0xabae*/ 1220,
+ /*0x2c2e*/ 958,
+ /*0xa7f5*/ 1157,
+ -1,
+ /*0x022c*/ 212,
+ -1,
+ /*0x1fac*/ 812,
+ /*0x0230*/ 214,
+ /*0x042c*/ 341,
+ /*0x012c*/ 79,
+ /*0x1e92*/ 659,
+ /*0x1e12*/ 595,
+ /*0x0130*/ 1584,
+ /*0x2cae*/ 998,
+ /*0xabac*/ 1218,
+ /*0x2c2c*/ 956,
+ -1,
+ /*0xabb0*/ 1222,
+ -1, -1,
+ /*0x03b0*/ 268,
+ -1, -1, -1, -1,
+ /*0x1c9d*/ 553,
+ /*0x1faf*/ 815,
+ /*0x2cac*/ 997,
+ /*0x042f*/ 344,
+ -1,
+ /*0x2cb0*/ 999,
+ /*0xa7ae*/ 1129,
+ /*0x01ae*/ 148,
+ /*0x10cae*/ 1433,
+ /*0xabaf*/ 1221,
+ /*0x2c2f*/ 959,
+ -1, -1,
+ /*0x1057c*/ 1363,
+ /*0x1c9c*/ 552,
+ -1, -1,
+ /*0x0522*/ 438,
+ -1, -1,
+ /*0xa7ac*/ 1127,
+ /*0x01ac*/ 147,
+ /*0x10cac*/ 1431,
+ /*0xa7b0*/ 1130,
+ /*0x0498*/ 369,
+ /*0x10cb0*/ 1435,
+ -1,
+ /*0x2163*/ 872,
+ /*0x10d59*/ 1447,
+ /*0x1ea6*/ 671,
+ /*0x1e26*/ 605,
+ -1,
+ /*0x051a*/ 434,
+ -1, -1,
+ /*0x0228*/ 210,
+ /*0x1c9e*/ 554,
+ /*0x1fa8*/ 808,
+ -1,
+ /*0x0428*/ 337,
+ /*0x0128*/ 77,
+ /*0x01af*/ 149,
+ /*0x10caf*/ 1434,
+ /*0x1ea4*/ 670,
+ /*0x1e24*/ 604,
+ /*0xaba8*/ 1214,
+ /*0x2c28*/ 952,
+ -1,
+ /*0x03a8*/ 264,
+ /*0x04a0*/ 373,
+ -1, -1,
+ /*0x020e*/ 197,
+ /*0x10a0*/ 484,
+ /*0x1f8e*/ 782,
+ /*0x1040e*/ 1290,
+ /*0x040e*/ 311,
+ /*0x010e*/ 64,
+ /*0x2ca8*/ 995,
+ /*0x0232*/ 215,
+ -1,
+ /*0x1fb2*/ 816,
+ /*0xab8e*/ 1188,
+ /*0x2c0e*/ 926,
+ /*0x0132*/ 81,
+ /*0x038e*/ 239,
+ -1, -1, -1,
+ /*0xabb2*/ 1224,
+ /*0x1f59*/ 756,
+ /*0x0492*/ 366,
+ /*0x1cb8*/ 580,
+ /*0x1f18*/ 724,
+ -1,
+ /*0x2c8e*/ 982,
+ /*0xa7a8*/ 1124,
+ -1,
+ /*0x10ca8*/ 1427,
+ -1, -1,
+ /*0x1caa*/ 566,
+ /*0x2cb2*/ 1000,
+ -1, -1,
+ /*0x1efc*/ 714,
+ /*0x1e7c*/ 648,
+ -1,
+ /*0x1ea2*/ 669,
+ /*0x1e22*/ 603,
+ /*0x051c*/ 435,
+ -1, -1, -1,
+ /*0x018e*/ 129,
+ /*0x10c8e*/ 1401,
+ -1, -1, -1,
+ /*0xff27*/ 1256,
+ /*0xa7b2*/ 1132,
+ /*0x01b2*/ 151,
+ /*0x10cb2*/ 1437,
+ /*0x1e9a*/ 665,
+ /*0x1e1a*/ 599,
+ /*0x1e90e*/ 1563,
+ /*0x0547*/ 467,
+ -1,
+ /*0x023a*/ 216,
+ -1,
+ /*0x1fba*/ 823,
+ -1,
+ /*0x051e*/ 436,
+ -1,
+ /*0x16ea7*/ 1531,
+ /*0x04a6*/ 376,
+ -1,
+ /*0x1fb6*/ 819,
+ /*0xabba*/ 1232,
+ /*0x10a6*/ 490,
+ /*0x0136*/ 83,
+ -1, -1, -1,
+ /*0x118a0*/ 1460,
+ /*0xabb6*/ 1228,
+ -1,
+ /*0x1cae*/ 570,
+ -1,
+ /*0x04a4*/ 375,
+ -1,
+ /*0x2cba*/ 1004,
+ /*0x020c*/ 196,
+ /*0x10a4*/ 488,
+ /*0x1f8c*/ 780,
+ /*0x1040c*/ 1288,
+ /*0x040c*/ 309,
+ /*0x010c*/ 63,
+ /*0x2cb6*/ 1002,
+ /*0xa779*/ 1103,
+ -1,
+ /*0x1cac*/ 568,
+ /*0xab8c*/ 1186,
+ /*0x2c0c*/ 924,
+ /*0x1cb0*/ 572,
+ /*0x038c*/ 238,
+ -1, -1,
+ /*0x0538*/ 452,
+ /*0xa7ba*/ 1137,
+ -1,
+ /*0xa726*/ 1067,
+ -1, -1, -1,
+ /*0x2c8c*/ 981,
+ /*0xa7b6*/ 1135,
+ /*0x052a*/ 442,
+ -1, -1, -1,
+ /*0x1caf*/ 571,
+ /*0x1e1c*/ 600,
+ -1, -1,
+ /*0xa724*/ 1066,
+ -1, -1,
+ /*0x1f69*/ 761,
+ -1, -1,
+ /*0x04fc*/ 419,
+ -1,
+ /*0x10575*/ 1357,
+ /*0x04a2*/ 374,
+ /*0x10c8c*/ 1399,
+ -1, -1,
+ /*0x10a2*/ 486,
+ -1, -1, -1, -1,
+ /*0x1e9e*/ 667,
+ /*0x1e1e*/ 601,
+ /*0x1e90c*/ 1561,
+ -1, -1, -1,
+ /*0x049a*/ 370,
+ /*0x118a6*/ 1466,
+ /*0x1fb4*/ 818,
+ -1, -1,
+ /*0x0134*/ 82,
+ -1, -1,
+ /*0x1ca8*/ 564,
+ -1,
+ /*0xabb4*/ 1226,
+ -1,
+ /*0x2126*/ 865,
+ -1,
+ /*0x052e*/ 444,
+ /*0x118a4*/ 1464,
+ /*0x2169*/ 878,
+ -1, -1, -1, -1,
+ /*0xa722*/ 1065,
+ -1,
+ /*0x2cb4*/ 1001,
+ /*0x023e*/ 219,
+ -1,
+ /*0x1fbe*/ 826,
+ -1,
+ /*0x052c*/ 443,
+ -1,
+ /*0x1eb8*/ 680,
+ /*0x1e38*/ 614,
+ /*0x1cb2*/ 574,
+ -1,
+ /*0xabbe*/ 1236,
+ -1,
+ /*0x1fbc*/ 825,
+ -1, -1,
+ /*0x1eaa*/ 673,
+ /*0x1e2a*/ 607,
+ /*0xa7b4*/ 1134,
+ -1, -1,
+ /*0xabbc*/ 1234,
+ -1, -1,
+ /*0x2cbe*/ 1006,
+ -1,
+ /*0x1f1a*/ 726,
+ -1, -1,
+ /*0xa688*/ 1055,
+ /*0x1f8d*/ 781,
+ /*0x1040d*/ 1289,
+ /*0x040d*/ 310,
+ /*0x16e5f*/ 1523,
+ /*0x2cbc*/ 1005,
+ /*0x049c*/ 371,
+ -1,
+ /*0x118a2*/ 1462,
+ /*0xab8d*/ 1187,
+ /*0x2c0d*/ 925,
+ -1, -1,
+ /*0xa7be*/ 1139,
+ -1, -1, -1,
+ /*0xa68a*/ 1056,
+ -1, -1, -1,
+ /*0x104c7*/ 1339,
+ /*0x04c7*/ 393,
+ /*0xa7bc*/ 1138,
+ /*0x01bc*/ 156,
+ -1,
+ /*0x10c7*/ 522,
+ -1,
+ /*0x049e*/ 372,
+ /*0x1cba*/ 582,
+ -1,
+ /*0xa680*/ 1051,
+ /*0x0528*/ 441,
+ /*0x1eae*/ 675,
+ /*0x1e2e*/ 609,
+ -1,
+ /*0x1cb6*/ 578,
+ -1, -1,
+ /*0x16e5d*/ 1521,
+ /*0xa78d*/ 1112,
+ /*0x1f1d*/ 729,
+ /*0x10c8d*/ 1400,
+ -1, -1, -1, -1,
+ /*0x1eac*/ 674,
+ /*0x1e2c*/ 608,
+ /*0x050e*/ 428,
+ /*0x1eb0*/ 676,
+ /*0x1e30*/ 610,
+ /*0x1e90d*/ 1562,
+ -1, -1,
+ /*0x1f1c*/ 728,
+ /*0x0532*/ 446,
+ /*0x10588*/ 1375,
+ -1, -1, -1, -1,
+ /*0x10589*/ 1376,
+ /*0x104b8*/ 1324,
+ /*0x04b8*/ 385,
+ /*0x0053*/ 17,
+ /*0x1fd3*/ 838,
+ -1,
+ /*0x10b8*/ 508,
+ -1, -1, -1, -1,
+ /*0x04aa*/ 378,
+ /*0x1058a*/ 1377,
+ /*0x0052*/ 16,
+ /*0x1fd2*/ 837,
+ /*0x10aa*/ 494,
+ -1,
+ /*0x0152*/ 97,
+ -1, -1, -1, -1,
+ /*0x024c*/ 227,
+ /*0x004c*/ 10,
+ /*0x1fcc*/ 836,
+ /*0xa686*/ 1054,
+ /*0x10580*/ 1367,
+ /*0x014c*/ 94,
+ -1, -1,
+ /*0x10583*/ 1370,
+ -1, -1, -1, -1,
+ /*0x2cd2*/ 1016,
+ -1,
+ /*0x16ea0*/ 1524,
+ /*0xa738*/ 1075,
+ /*0xa696*/ 1062,
+ -1,
+ /*0x1ea8*/ 672,
+ /*0x1e28*/ 606,
+ /*0x053a*/ 454,
+ /*0x01d3*/ 166,
+ /*0x2ccc*/ 1013,
+ -1,
+ /*0xa72a*/ 1069,
+ /*0x1cb4*/ 576,
+ -1,
+ /*0x0536*/ 450,
+ /*0x1f38*/ 738,
+ -1,
+ /*0xa7d2*/ 1151,
+ -1, -1, -1,
+ /*0x04ae*/ 380,
+ /*0x1e8e*/ 657,
+ /*0x1e0e*/ 593,
+ /*0x1f2a*/ 732,
+ /*0x10ae*/ 498,
+ -1,
+ /*0xa7cc*/ 1148,
+ -1,
+ /*0x1eb2*/ 677,
+ /*0x1e32*/ 611,
+ /*0x050c*/ 427,
+ /*0x0244*/ 222,
+ /*0x0044*/ 3,
+ /*0x1fc4*/ 829,
+ /*0x04ac*/ 379,
+ /*0x1cbe*/ 584,
+ /*0x104b0*/ 1316,
+ /*0x04b0*/ 381,
+ /*0x10ac*/ 496,
+ -1,
+ /*0x118b8*/ 1484,
+ /*0x10b0*/ 500,
+ -1,
+ /*0x16e5b*/ 1519,
+ -1,
+ /*0x10586*/ 1373,
+ -1,
+ /*0xa694*/ 1061,
+ -1,
+ /*0x118aa*/ 1470,
+ -1,
+ /*0xff26*/ 1255,
+ -1, -1,
+ /*0x2cc4*/ 1009,
+ -1,
+ /*0xa72e*/ 1071,
+ -1,
+ /*0x10af*/ 499,
+ -1,
+ /*0x212a*/ 866,
+ -1,
+ /*0xa690*/ 1059,
+ -1, -1,
+ /*0xff24*/ 1253,
+ /*0x16ea6*/ 1530,
+ -1, -1,
+ /*0x1f2e*/ 736,
+ /*0xa72c*/ 1070,
+ /*0x00d3*/ 45,
+ /*0xa7c4*/ 1142,
+ /*0x01c4*/ 157,
+ -1, -1,
+ /*0xa684*/ 1053,
+ /*0x1eba*/ 681,
+ /*0x1e3a*/ 615,
+ -1,
+ /*0x16ea4*/ 1528,
+ /*0x00d2*/ 44,
+ -1,
+ /*0x1f2c*/ 734,
+ /*0x1eb6*/ 679,
+ /*0x1e36*/ 613,
+ -1,
+ /*0x0534*/ 448,
+ -1, -1,
+ /*0x04a8*/ 377,
+ /*0x00cc*/ 38,
+ -1, -1,
+ /*0x10a8*/ 492,
+ /*0x118ae*/ 1474,
+ -1, -1,
+ /*0x16e57*/ 1515,
+ -1, -1,
+ /*0x1e8c*/ 656,
+ /*0x1e0c*/ 592,
+ /*0x1f2f*/ 737,
+ /*0x10594*/ 1385,
+ -1, -1,
+ /*0x048e*/ 364,
+ -1,
+ /*0x118ac*/ 1472,
+ /*0xff22*/ 1251,
+ /*0x053e*/ 458,
+ /*0x118b0*/ 1476,
+ /*0x104b2*/ 1318,
+ /*0x04b2*/ 382,
+ -1, -1, -1,
+ /*0x10b2*/ 502,
+ /*0x10590*/ 1382,
+ /*0xa682*/ 1052,
+ /*0x053c*/ 456,
+ /*0x024a*/ 226,
+ /*0x004a*/ 8,
+ /*0x1fca*/ 834,
+ /*0x16ea2*/ 1526,
+ /*0xa728*/ 1068,
+ /*0x014a*/ 93,
+ -1,
+ /*0x118af*/ 1475,
+ -1,
+ /*0x24c7*/ 903,
+ -1,
+ /*0x10584*/ 1371,
+ -1,
+ /*0x0042*/ 1,
+ /*0x1fc2*/ 827,
+ /*0x00c4*/ 30,
+ -1,
+ /*0x1f28*/ 730,
+ /*0x1fab*/ 811,
+ -1,
+ /*0x042b*/ 340,
+ -1, -1,
+ /*0x2cca*/ 1012,
+ -1,
+ /*0x03c2*/ 269,
+ /*0xabab*/ 1217,
+ /*0x2c2b*/ 955,
+ /*0xa732*/ 1072,
+ /*0x03ab*/ 267,
+ -1, -1, -1,
+ /*0xa698*/ 1063,
+ /*0x1f0e*/ 722,
+ /*0x2cc2*/ 1008,
+ /*0x1eb4*/ 678,
+ /*0x1e34*/ 612,
+ /*0x16e59*/ 1517,
+ -1,
+ /*0x104ba*/ 1326,
+ /*0x04ba*/ 386,
+ /*0x01ca*/ 161,
+ /*0x118a8*/ 1468,
+ -1,
+ /*0x10ba*/ 510,
+ -1,
+ /*0x104b6*/ 1322,
+ /*0x04b6*/ 384,
+ -1, -1,
+ /*0x24b8*/ 888,
+ /*0x10b6*/ 506,
+ /*0xa7c2*/ 1141,
+ -1,
+ /*0x10582*/ 1369,
+ -1,
+ /*0xa7ab*/ 1126,
+ -1,
+ /*0x10cab*/ 1430,
+ /*0x1ebe*/ 683,
+ /*0x1e3e*/ 617,
+ -1,
+ /*0x024e*/ 228,
+ /*0x004e*/ 12,
+ /*0x048c*/ 363,
+ -1,
+ /*0x118b2*/ 1478,
+ /*0x014e*/ 95,
+ /*0x10585*/ 1372,
+ /*0x1ebc*/ 682,
+ /*0x1e3c*/ 616,
+ -1, -1, -1,
+ /*0x0056*/ 20,
+ /*0x1fd6*/ 839,
+ /*0xa73a*/ 1076,
+ /*0x2132*/ 868,
+ /*0x0156*/ 99,
+ /*0xa692*/ 1060,
+ /*0x0553*/ 479,
+ -1, -1,
+ /*0xa736*/ 1074,
+ -1,
+ /*0x2cce*/ 1014,
+ /*0x03d6*/ 274,
+ -1, -1,
+ /*0x1f3a*/ 740,
+ /*0x0552*/ 478,
+ -1, -1, -1,
+ /*0x0050*/ 14,
+ -1,
+ /*0x2cd6*/ 1018,
+ -1,
+ /*0x0150*/ 96,
+ -1,
+ /*0x054c*/ 472,
+ -1, -1,
+ /*0xa7ce*/ 1149,
+ -1,
+ /*0x00ca*/ 36,
+ /*0x03d0*/ 271,
+ -1,
+ /*0x0248*/ 225,
+ /*0x0048*/ 7,
+ /*0x1fc8*/ 832,
+ -1, -1,
+ /*0x1f0c*/ 720,
+ /*0xa7d6*/ 1153,
+ /*0x118ba*/ 1486,
+ /*0x2cd0*/ 1015,
+ /*0x00c2*/ 28,
+ /*0xff38*/ 1273,
+ -1,
+ /*0x104b4*/ 1320,
+ /*0x04b4*/ 383,
+ /*0x118b6*/ 1482,
+ -1, -1,
+ /*0x10b4*/ 504,
+ -1,
+ /*0xff2a*/ 1259,
+ /*0x0246*/ 224,
+ /*0x0046*/ 5,
+ /*0x1fc6*/ 830,
+ /*0x2cc8*/ 1011,
+ -1,
+ /*0x16eb8*/ 1548,
+ /*0xa7d0*/ 1150,
+ -1,
+ /*0x10592*/ 1384,
+ -1, -1, -1, -1, -1,
+ /*0x16eaa*/ 1534,
+ -1,
+ /*0x104be*/ 1330,
+ /*0x04be*/ 388,
+ /*0x0544*/ 464,
+ -1, -1,
+ /*0x10be*/ 514,
+ /*0x01c8*/ 160,
+ /*0x2cc6*/ 1010,
+ /*0x005a*/ 24,
+ /*0x1fda*/ 843,
+ /*0x104bc*/ 1328,
+ /*0x04bc*/ 387,
+ /*0x015a*/ 101,
+ /*0xa734*/ 1073,
+ /*0x2cc0*/ 1007,
+ /*0x10bc*/ 512,
+ -1,
+ /*0x1ed2*/ 693,
+ /*0x1e52*/ 627,
+ /*0x0054*/ 18,
+ /*0x03da*/ 276,
+ -1, -1,
+ /*0x0154*/ 98,
+ /*0x00ce*/ 40,
+ /*0xa7c6*/ 1144,
+ /*0xa652*/ 1037,
+ /*0x1ecc*/ 690,
+ /*0x1e4c*/ 624,
+ /*0xff2e*/ 1263,
+ /*0x2cda*/ 1020,
+ -1,
+ /*0xa7c0*/ 1140,
+ /*0x1cab*/ 567,
+ -1,
+ /*0x00d6*/ 48,
+ /*0xa64c*/ 1034,
+ /*0xa73e*/ 1078,
+ -1, -1, -1,
+ /*0x2cd4*/ 1017,
+ -1,
+ /*0xff2c*/ 1261,
+ /*0x16eae*/ 1538,
+ -1,
+ /*0xff30*/ 1265,
+ /*0xa73c*/ 1077,
+ /*0xa7da*/ 1155,
+ -1,
+ /*0x1f3e*/ 744,
+ -1,
+ /*0x118b4*/ 1480,
+ /*0xa69a*/ 1064,
+ -1,
+ /*0x00d0*/ 42,
+ -1, -1,
+ /*0x16eac*/ 1536,
+ /*0xa7d4*/ 1152,
+ /*0x1f3c*/ 742,
+ /*0x16eb0*/ 1540,
+ -1,
+ /*0xff2f*/ 1264,
+ -1, -1, -1, -1, -1, -1,
+ /*0x00c8*/ 34,
+ -1, -1,
+ /*0x1ec4*/ 686,
+ /*0x1e44*/ 620,
+ -1,
+ /*0x118be*/ 1490,
+ /*0x1f0d*/ 721,
+ /*0x16eaf*/ 1539,
+ /*0x0058*/ 22,
+ /*0x1fd8*/ 841,
+ -1,
+ /*0xa644*/ 1030,
+ /*0x0158*/ 100,
+ /*0x0245*/ 223,
+ /*0x0045*/ 4,
+ /*0x118bc*/ 1488,
+ -1, -1,
+ /*0x0145*/ 90,
+ /*0x00c6*/ 32,
+ /*0x03d8*/ 275,
+ /*0x104d3*/ 1351,
+ /*0x054a*/ 470,
+ -1, -1, -1,
+ /*0x00c0*/ 26,
+ -1,
+ /*0xff28*/ 1257,
+ /*0x10d53*/ 1441,
+ /*0x2cd8*/ 1019,
+ /*0x104d2*/ 1350,
+ /*0x04d2*/ 398,
+ /*0x24ba*/ 890,
+ /*0x0542*/ 462,
+ -1, -1, -1, -1,
+ /*0x10d52*/ 1440,
+ /*0x24b6*/ 886,
+ /*0x104cc*/ 1344,
+ /*0x00da*/ 51,
+ /*0x16ea8*/ 1532,
+ -1, -1, -1, -1,
+ /*0xa7d8*/ 1154,
+ /*0x1fa9*/ 809,
+ -1,
+ /*0x0429*/ 338,
+ /*0xff32*/ 1267,
+ /*0x00d4*/ 46,
+ /*0xa7c5*/ 1143,
+ /*0x01c5*/ 158,
+ -1,
+ /*0xaba9*/ 1215,
+ /*0x2c29*/ 953,
+ -1,
+ /*0x03a9*/ 265,
+ -1, -1,
+ /*0x1fe2*/ 845,
+ /*0x16e47*/ 1499,
+ /*0x0462*/ 346,
+ /*0x0162*/ 105,
+ /*0x16eb2*/ 1542,
+ /*0xa752*/ 1088,
+ -1, -1, -1,
+ /*0x2c62*/ 961,
+ -1,
+ /*0x03e2*/ 280,
+ -1, -1, -1,
+ /*0xa74c*/ 1085,
+ -1, -1,
+ /*0x1f52*/ 753,
+ /*0x0345*/ 229,
+ -1,
+ /*0x2ce2*/ 1024,
+ /*0x054e*/ 474,
+ /*0x0055*/ 19,
+ /*0x104c4*/ 1336,
+ -1,
+ /*0x01a9*/ 146,
+ /*0x10ca9*/ 1428,
+ /*0x1f4c*/ 750,
+ /*0x10c4*/ 520,
+ /*0x1eca*/ 689,
+ /*0x1e4a*/ 623,
+ -1,
+ /*0x0556*/ 482,
+ -1,
+ /*0x03d5*/ 273,
+ -1, -1,
+ /*0xff3a*/ 1275,
+ /*0xa64a*/ 1033,
+ /*0x01e2*/ 173,
+ -1,
+ /*0x1ec2*/ 685,
+ /*0x1e42*/ 619,
+ -1,
+ /*0xff36*/ 1271,
+ /*0x1fa1*/ 801,
+ /*0x10421*/ 1309,
+ /*0x0421*/ 330,
+ -1,
+ /*0x00d8*/ 49,
+ /*0xa642*/ 1029,
+ -1,
+ /*0x0550*/ 476,
+ /*0xaba1*/ 1207,
+ /*0x2c21*/ 945,
+ /*0x00c5*/ 31,
+ /*0x03a1*/ 258,
+ -1, -1,
+ /*0x16eb6*/ 1546,
+ /*0xa744*/ 1081,
+ -1, -1,
+ /*0x01d5*/ 167,
+ /*0x1fa5*/ 805,
+ /*0x10425*/ 1313,
+ /*0x0425*/ 334,
+ /*0x0548*/ 468,
+ /*0x1fad*/ 813,
+ -1,
+ /*0x042d*/ 342,
+ -1,
+ /*0xaba5*/ 1211,
+ /*0x2c25*/ 949,
+ /*0x24be*/ 894,
+ /*0x03a5*/ 261,
+ /*0xabad*/ 1219,
+ /*0x2c2d*/ 957,
+ -1, -1, -1, -1, -1, -1,
+ /*0x24bc*/ 892,
+ -1,
+ /*0x10ca1*/ 1420,
+ /*0x0546*/ 466,
+ -1,
+ /*0x1fa3*/ 803,
+ /*0x10423*/ 1311,
+ /*0x0423*/ 332,
+ /*0x1ece*/ 691,
+ /*0x1e4e*/ 625,
+ /*0x0540*/ 460,
+ -1,
+ /*0x1e921*/ 1582,
+ /*0xaba3*/ 1209,
+ /*0x2c23*/ 947,
+ /*0x004d*/ 11,
+ /*0x03a3*/ 259,
+ /*0xa64e*/ 1035,
+ -1,
+ /*0x1ed6*/ 695,
+ /*0x1e56*/ 629,
+ /*0x10ca5*/ 1424,
+ -1,
+ /*0xa7ad*/ 1128,
+ /*0x1fe4*/ 847,
+ /*0x10cad*/ 1432,
+ /*0x0464*/ 347,
+ /*0x0164*/ 106,
+ /*0xa656*/ 1039,
+ -1,
+ /*0x104ca*/ 1342,
+ -1, -1,
+ /*0x2c64*/ 963,
+ /*0xff34*/ 1269,
+ /*0x03e4*/ 281,
+ -1,
+ /*0x0554*/ 480,
+ -1,
+ /*0x1ed0*/ 692,
+ /*0x1e50*/ 626,
+ -1,
+ /*0x104c2*/ 1334,
+ /*0x00d5*/ 47,
+ -1, -1,
+ /*0x10ca3*/ 1422,
+ /*0x10c2*/ 518,
+ /*0xa650*/ 1036,
+ /*0x16eb4*/ 1544,
+ -1,
+ /*0x10ab*/ 495,
+ -1, -1,
+ /*0x1ec8*/ 688,
+ /*0x1e48*/ 622,
+ /*0x01cd*/ 163,
+ -1, -1, -1, -1,
+ /*0x1ca9*/ 565,
+ -1,
+ /*0xa648*/ 1032,
+ /*0x01e4*/ 174,
+ -1, -1,
+ /*0xa74a*/ 1084,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1ec6*/ 687,
+ /*0x1e46*/ 621,
+ -1, -1, -1,
+ /*0xa742*/ 1080,
+ /*0x1f4a*/ 748,
+ /*0x1ec0*/ 684,
+ /*0x1e40*/ 618,
+ /*0xa646*/ 1031,
+ -1, -1,
+ /*0x1f87*/ 775,
+ /*0x10407*/ 1283,
+ /*0x0407*/ 304,
+ /*0xab73*/ 1161,
+ /*0xa640*/ 1028,
+ -1,
+ /*0xa68e*/ 1058,
+ /*0x104ce*/ 1346,
+ /*0xab87*/ 1181,
+ /*0x2c07*/ 919,
+ /*0x1f2b*/ 733,
+ /*0x1eda*/ 697,
+ /*0x1e5a*/ 631,
+ -1, -1, -1,
+ /*0x24cc*/ 908,
+ /*0x0545*/ 465,
+ -1,
+ /*0x04d6*/ 400,
+ /*0xa65a*/ 1041,
+ -1,
+ /*0x1ed4*/ 694,
+ /*0x1e54*/ 628,
+ /*0x015e*/ 103,
+ -1,
+ /*0x10d56*/ 1444,
+ -1,
+ /*0x0243*/ 221,
+ /*0x0043*/ 2,
+ /*0x1fc3*/ 828,
+ /*0xa654*/ 1038,
+ /*0x03de*/ 278,
+ /*0x0143*/ 89,
+ /*0x00cd*/ 39,
+ /*0x1ca1*/ 557,
+ /*0x118ab*/ 1471,
+ -1,
+ /*0x104d0*/ 1348,
+ /*0x04d0*/ 397,
+ /*0x0187*/ 125,
+ /*0x10c87*/ 1394,
+ /*0x2cde*/ 1022,
+ -1,
+ /*0xa74e*/ 1086,
+ /*0xab71*/ 1159,
+ /*0x10d50*/ 1438,
+ /*0x212b*/ 867,
+ /*0x015c*/ 102,
+ -1, -1,
+ /*0x1e907*/ 1556,
+ -1,
+ /*0x104c8*/ 1340,
+ /*0x1ca5*/ 561,
+ /*0xa756*/ 1090,
+ /*0x03dc*/ 277,
+ -1,
+ /*0x1cad*/ 569,
+ /*0x004b*/ 9,
+ /*0x1fcb*/ 835,
+ /*0x01de*/ 171,
+ /*0x24c4*/ 900,
+ /*0x1058e*/ 1380,
+ -1, -1,
+ /*0x2cdc*/ 1021,
+ /*0x1fec*/ 854,
+ /*0x1f56*/ 755,
+ /*0x046c*/ 351,
+ /*0x016c*/ 110,
+ -1, -1,
+ /*0x104c6*/ 1338,
+ /*0xab7b*/ 1169,
+ /*0xa750*/ 1087,
+ -1, -1,
+ /*0x03ec*/ 285,
+ /*0x1ca3*/ 559,
+ /*0x104c0*/ 1332,
+ /*0x04c0*/ 389,
+ /*0x1ed8*/ 696,
+ /*0x1e58*/ 630,
+ /*0xa7dc*/ 1156,
+ /*0x10c0*/ 516,
+ /*0xa68c*/ 1057,
+ -1,
+ /*0x1f50*/ 752,
+ /*0x0555*/ 481,
+ /*0xa748*/ 1083,
+ /*0xa658*/ 1040,
+ -1, -1, -1, -1,
+ /*0xabb1*/ 1223,
+ /*0x04da*/ 402,
+ -1,
+ /*0xa7cb*/ 1147,
+ /*0x01cb*/ 162,
+ -1,
+ /*0xab7d*/ 1171,
+ /*0x1f48*/ 746,
+ /*0x10d5a*/ 1448,
+ -1, -1,
+ /*0x01ec*/ 178,
+ /*0x04d4*/ 399,
+ -1,
+ /*0xa746*/ 1082,
+ /*0x1f97*/ 791,
+ /*0x10417*/ 1299,
+ /*0x0417*/ 320,
+ -1,
+ /*0x10d54*/ 1442,
+ -1,
+ /*0xa740*/ 1079,
+ -1,
+ /*0xab97*/ 1197,
+ /*0x2c17*/ 935,
+ -1,
+ /*0x0397*/ 248,
+ /*0x0460*/ 345,
+ /*0x0160*/ 104,
+ /*0x00de*/ 55,
+ -1,
+ /*0xa7b1*/ 1131,
+ /*0x01b1*/ 150,
+ /*0x10cb1*/ 1436,
+ /*0x2c60*/ 960,
+ -1,
+ /*0x03e0*/ 279,
+ /*0xa75a*/ 1092,
+ /*0x00c3*/ 29,
+ -1,
+ /*0x1ee2*/ 701,
+ /*0x1e62*/ 635,
+ -1, -1,
+ /*0x1fb7*/ 820,
+ -1,
+ /*0x2ce0*/ 1023,
+ /*0x1058c*/ 1378,
+ /*0xa754*/ 1089,
+ /*0xa662*/ 1045,
+ -1,
+ /*0xab77*/ 1165,
+ /*0xabb7*/ 1229,
+ /*0x00dc*/ 53,
+ /*0xab7f*/ 1173,
+ /*0x0197*/ 136,
+ /*0x10c97*/ 1410,
+ /*0x24ca*/ 906,
+ -1, -1,
+ /*0x1fea*/ 852,
+ /*0x1f54*/ 754,
+ /*0x046a*/ 350,
+ /*0x016a*/ 109,
+ /*0x1c87*/ 537,
+ /*0x01e0*/ 172,
+ /*0x1e917*/ 1572,
+ -1,
+ /*0x00cb*/ 37,
+ /*0x24c2*/ 898,
+ /*0x054d*/ 473,
+ /*0x03ea*/ 284,
+ /*0x04d8*/ 401,
+ -1,
+ /*0x0470*/ 353,
+ /*0x0170*/ 112,
+ -1,
+ /*0x104c5*/ 1337,
+ /*0x04c5*/ 392,
+ /*0x10d58*/ 1446,
+ -1,
+ /*0x2c70*/ 970,
+ /*0x10c5*/ 521,
+ /*0x03f0*/ 287,
+ /*0x01b7*/ 154,
+ /*0x1fe8*/ 850,
+ -1,
+ /*0x0468*/ 349,
+ /*0x0168*/ 108,
+ -1,
+ /*0x046e*/ 352,
+ /*0x016e*/ 111,
+ -1, -1, -1, -1,
+ /*0x03e8*/ 283,
+ /*0x2c6e*/ 968,
+ -1,
+ /*0x03ee*/ 286,
+ /*0x01ea*/ 177,
+ -1,
+ /*0x1ff2*/ 855,
+ -1,
+ /*0x0472*/ 354,
+ /*0x0172*/ 113,
+ -1,
+ /*0x1fe6*/ 848,
+ /*0xa758*/ 1091,
+ /*0x0466*/ 348,
+ /*0x0166*/ 107,
+ /*0x2c72*/ 971,
+ /*0x01f0*/ 180,
+ /*0xfb17*/ 1249,
+ /*0x1fb9*/ 822,
+ -1,
+ /*0x10a9*/ 493,
+ /*0x0139*/ 84,
+ /*0x03e6*/ 282,
+ -1,
+ /*0x24ce*/ 910,
+ -1,
+ /*0xabb9*/ 1231,
+ /*0x2cf2*/ 1027,
+ /*0x1fb3*/ 817,
+ /*0x01e8*/ 176,
+ /*0x04e2*/ 406,
+ -1,
+ /*0x01ee*/ 179,
+ -1, -1, -1,
+ /*0xabb3*/ 1225,
+ /*0x10d62*/ 1456,
+ -1, -1, -1, -1, -1,
+ /*0x0370*/ 230,
+ -1,
+ /*0xff2b*/ 1260,
+ /*0x01f2*/ 182,
+ -1,
+ /*0x0049*/ 1583,
+ /*0x1fc9*/ 833,
+ -1,
+ /*0x01e6*/ 175,
+ /*0x0149*/ 92,
+ /*0x1ee4*/ 702,
+ /*0x1e64*/ 636,
+ -1,
+ /*0x1cb1*/ 573,
+ -1, -1,
+ /*0x1058d*/ 1379,
+ /*0x16eab*/ 1535,
+ /*0x10d55*/ 1443,
+ /*0xa664*/ 1046,
+ -1, -1,
+ /*0x1f29*/ 731,
+ /*0xa762*/ 1096,
+ /*0xa7b3*/ 1133,
+ /*0x01b3*/ 152,
+ -1,
+ /*0x24c8*/ 904,
+ -1, -1,
+ /*0x0372*/ 231,
+ /*0x0543*/ 463,
+ /*0x16e53*/ 1511,
+ -1, -1, -1,
+ /*0x1c97*/ 547,
+ /*0x10a1*/ 485,
+ /*0x1ff4*/ 857,
+ -1,
+ /*0x0474*/ 355,
+ /*0x0174*/ 114,
+ /*0x16e52*/ 1510,
+ -1, -1,
+ /*0xa7c9*/ 1146,
+ -1,
+ /*0x24c6*/ 902,
+ /*0x118a9*/ 1469,
+ /*0x03f4*/ 289,
+ -1, -1,
+ /*0x16e4c*/ 1504,
+ -1,
+ /*0x24c0*/ 896,
+ -1,
+ /*0x10a5*/ 489,
+ -1, -1, -1,
+ /*0x10ad*/ 497,
+ /*0x054b*/ 471,
+ -1, -1, -1,
+ /*0x1cb7*/ 579,
+ /*0x013f*/ 87,
+ -1, -1, -1, -1,
+ /*0xabbf*/ 1237,
+ -1,
+ /*0x2162*/ 871,
+ /*0x1f9b*/ 795,
+ /*0x1041b*/ 1303,
+ /*0x041b*/ 324,
+ -1,
+ /*0x01f4*/ 183,
+ -1, -1,
+ /*0x10a3*/ 487,
+ /*0xab9b*/ 1201,
+ /*0x2c1b*/ 939,
+ -1,
+ /*0x039b*/ 252,
+ -1,
+ /*0x104cd*/ 1345,
+ /*0x04cd*/ 396,
+ /*0x0531*/ 445,
+ -1, -1,
+ /*0x10cd*/ 523,
+ /*0x1ede*/ 699,
+ /*0x1e5e*/ 633,
+ -1,
+ /*0x04e4*/ 407,
+ -1,
+ /*0x16e44*/ 1496,
+ -1, -1, -1,
+ /*0xa65e*/ 1043,
+ /*0x10d64*/ 1458,
+ -1,
+ /*0x1f2d*/ 735,
+ /*0xab79*/ 1167,
+ -1,
+ /*0x118a1*/ 1461,
+ -1,
+ /*0x00c9*/ 35,
+ -1,
+ /*0x1f99*/ 793,
+ /*0x10419*/ 1301,
+ /*0x0419*/ 322,
+ /*0x10c9b*/ 1414,
+ -1,
+ /*0x1edc*/ 698,
+ /*0x1e5c*/ 632,
+ -1,
+ /*0xab99*/ 1199,
+ /*0x2c19*/ 937,
+ -1,
+ /*0x0399*/ 250,
+ -1,
+ /*0x1e91b*/ 1576,
+ /*0xa65c*/ 1042,
+ /*0x118a5*/ 1465,
+ -1, -1, -1,
+ /*0x118ad*/ 1473,
+ /*0xa764*/ 1097,
+ /*0x023d*/ 218,
+ -1,
+ /*0x1cb9*/ 581,
+ -1,
+ /*0x1f4d*/ 751,
+ /*0x013d*/ 86,
+ /*0x1eec*/ 706,
+ /*0x1e6c*/ 640,
+ /*0x0537*/ 451,
+ -1,
+ /*0xabbd*/ 1235,
+ -1,
+ /*0x1cb3*/ 575,
+ -1,
+ /*0x24c5*/ 901,
+ /*0xa66c*/ 1050,
+ /*0x0241*/ 220,
+ /*0x0041*/ 0,
+ -1,
+ /*0x118a3*/ 1463,
+ /*0x10c99*/ 1412,
+ /*0x0141*/ 88,
+ -1,
+ /*0x1f91*/ 785,
+ /*0x10411*/ 1293,
+ /*0x0411*/ 314,
+ -1, -1, -1, -1,
+ /*0x1e919*/ 1574,
+ /*0xab91*/ 1191,
+ /*0x2c11*/ 929,
+ -1,
+ /*0x0391*/ 242,
+ /*0x10570*/ 1352,
+ -1,
+ /*0x023b*/ 217,
+ -1,
+ /*0x1fbb*/ 824,
+ -1,
+ /*0xab7c*/ 1170,
+ /*0x013b*/ 85,
+ -1, -1, -1,
+ /*0x04de*/ 404,
+ /*0xabbb*/ 1233,
+ /*0xabb5*/ 1227,
+ /*0x2164*/ 873,
+ /*0x1e97*/ 662,
+ -1, -1,
+ /*0x10d5e*/ 1452,
+ /*0x104c3*/ 1335,
+ /*0x04c3*/ 391,
+ /*0x16e4a*/ 1502,
+ -1, -1,
+ /*0x10c3*/ 519,
+ /*0x1ee0*/ 700,
+ /*0x1e60*/ 634,
+ -1,
+ /*0x0191*/ 132,
+ /*0x10c91*/ 1404,
+ /*0x10572*/ 1354,
+ -1, -1,
+ /*0x16e42*/ 1494,
+ /*0xa660*/ 1044,
+ /*0x04dc*/ 403,
+ -1,
+ /*0x047e*/ 360,
+ -1,
+ /*0x1e911*/ 1566,
+ -1, -1,
+ /*0x10d5c*/ 1450,
+ /*0x0539*/ 453,
+ /*0x2c7e*/ 973,
+ /*0x01b5*/ 153,
+ /*0x03fe*/ 295,
+ /*0xa75e*/ 1094,
+ -1,
+ /*0x104cb*/ 1343,
+ /*0x04cb*/ 395,
+ -1, -1,
+ /*0x0533*/ 447,
+ -1,
+ /*0x1cbf*/ 585,
+ -1,
+ /*0x04ec*/ 411,
+ -1, -1,
+ /*0x1eea*/ 705,
+ /*0x1e6a*/ 639,
+ -1, -1, -1, -1,
+ /*0x1c9b*/ 551,
+ -1, -1,
+ /*0xa66a*/ 1049,
+ -1,
+ /*0xa75c*/ 1093,
+ /*0x1ef0*/ 708,
+ /*0x1e70*/ 642,
+ /*0x0549*/ 469,
+ /*0x01fe*/ 189,
+ -1,
+ /*0x104b1*/ 1317,
+ -1, -1, -1,
+ /*0xff29*/ 1258,
+ /*0x10b1*/ 501,
+ -1,
+ /*0x16e4e*/ 1506,
+ /*0x1ee8*/ 704,
+ /*0x1e68*/ 638,
+ /*0x00c1*/ 27,
+ /*0x1eee*/ 707,
+ /*0x1e6e*/ 641,
+ -1, -1, -1,
+ /*0xa76c*/ 1101,
+ /*0xa668*/ 1048,
+ /*0x16e56*/ 1514,
+ /*0x16ea9*/ 1533,
+ -1, -1,
+ /*0x1f4b*/ 749,
+ -1, -1,
+ /*0x1ef2*/ 709,
+ /*0x1e72*/ 643,
+ /*0x1c99*/ 549,
+ /*0x10574*/ 1356,
+ /*0x1f6c*/ 764,
+ /*0x1ee6*/ 703,
+ /*0x1e66*/ 637,
+ /*0x00b5*/ 25,
+ -1,
+ /*0x04e0*/ 405,
+ -1,
+ /*0x004f*/ 13,
+ -1,
+ /*0x16e50*/ 1508,
+ /*0xa666*/ 1047,
+ -1,
+ /*0x10d60*/ 1454,
+ -1, -1, -1, -1, -1, -1,
+ /*0x03cf*/ 270,
+ -1,
+ /*0x1cbd*/ 583,
+ /*0x24cd*/ 909,
+ /*0x104b7*/ 1323,
+ /*0x16e48*/ 1500,
+ /*0x053f*/ 459,
+ -1, -1,
+ /*0x10b7*/ 507,
+ -1, -1, -1, -1, -1, -1,
+ /*0xff21*/ 1250,
+ -1,
+ /*0x216c*/ 881,
+ -1, -1,
+ /*0x04ea*/ 410,
+ /*0xa760*/ 1095,
+ /*0x1c91*/ 541,
+ /*0x1ff6*/ 858,
+ /*0x16e46*/ 1498,
+ /*0x0476*/ 356,
+ /*0x0176*/ 115,
+ /*0x118b1*/ 1477,
+ /*0x01cf*/ 164,
+ -1,
+ /*0x16ea1*/ 1525,
+ /*0x16e40*/ 1492,
+ /*0x04f0*/ 413,
+ -1,
+ /*0xff25*/ 1254,
+ /*0x1f95*/ 789,
+ /*0x10415*/ 1297,
+ /*0x0415*/ 318,
+ /*0xff2d*/ 1262,
+ /*0x1cb5*/ 577,
+ /*0xab75*/ 1163,
+ -1, -1,
+ /*0xab95*/ 1195,
+ /*0x2c15*/ 933,
+ /*0x04e8*/ 409,
+ /*0x0395*/ 246,
+ /*0x16e5a*/ 1518,
+ /*0x04ee*/ 412,
+ /*0x16ea5*/ 1529,
+ -1,
+ /*0x1ef4*/ 710,
+ /*0x1e74*/ 644,
+ /*0x16ead*/ 1537,
+ -1,
+ /*0x1ffa*/ 862,
+ /*0xa76a*/ 1100,
+ /*0x047a*/ 358,
+ /*0x16e54*/ 1512,
+ /*0xff23*/ 1252,
+ -1, -1,
+ /*0x04f2*/ 414,
+ /*0x01f6*/ 184,
+ -1, -1,
+ /*0x03fa*/ 293,
+ /*0x04e6*/ 408,
+ /*0x0051*/ 15,
+ /*0x1f6a*/ 762,
+ -1,
+ /*0x2160*/ 869,
+ /*0x13fa*/ 526,
+ /*0x104b9*/ 1325,
+ /*0x16ea3*/ 1527,
+ -1,
+ /*0x10c95*/ 1408,
+ /*0x053d*/ 457,
+ /*0x10b9*/ 509,
+ /*0x118b7*/ 1483,
+ /*0x03d1*/ 272,
+ /*0xa768*/ 1099,
+ -1,
+ /*0x104b3*/ 1319,
+ /*0xa76e*/ 1102,
+ -1,
+ /*0x1e915*/ 1570,
+ /*0x1e9b*/ 666,
+ /*0x10b3*/ 503,
+ -1,
+ /*0x0376*/ 232,
+ -1,
+ /*0x00cf*/ 41,
+ /*0x0541*/ 461,
+ /*0x1f68*/ 760,
+ /*0x01fa*/ 187,
+ -1,
+ /*0x1f6e*/ 766,
+ -1,
+ /*0x1f93*/ 787,
+ /*0x10413*/ 1295,
+ /*0x0413*/ 316,
+ /*0x24c3*/ 899,
+ /*0xa766*/ 1098,
+ /*0x104c9*/ 1341,
+ /*0x04c9*/ 394,
+ /*0x216a*/ 879,
+ /*0xab93*/ 1193,
+ /*0x2c13*/ 931,
+ /*0x01d1*/ 165,
+ /*0x0393*/ 244,
+ /*0x1f8f*/ 783,
+ /*0x1040f*/ 1291,
+ /*0x040f*/ 312,
+ /*0x053b*/ 455,
+ /*0x0535*/ 449,
+ -1, -1,
+ /*0x16e58*/ 1516,
+ /*0xab8f*/ 1189,
+ /*0x2c0f*/ 927,
+ -1,
+ /*0x038f*/ 240,
+ /*0x1f39*/ 739,
+ /*0x16e45*/ 1497,
+ /*0x1e99*/ 664,
+ -1,
+ /*0x1f81*/ 769,
+ /*0x10401*/ 1277,
+ /*0x0401*/ 298,
+ -1,
+ /*0x2168*/ 877,
+ /*0x24cb*/ 907,
+ /*0xfb15*/ 1247,
+ /*0x216e*/ 883,
+ /*0xab81*/ 1175,
+ /*0x2c01*/ 913,
+ /*0x04f4*/ 415,
+ -1,
+ /*0x0193*/ 133,
+ /*0x10c93*/ 1406,
+ -1, -1,
+ /*0x1ff8*/ 860,
+ /*0x1057e*/ 1365,
+ /*0x0478*/ 357,
+ /*0x0178*/ 116,
+ -1, -1,
+ /*0x118b9*/ 1485,
+ /*0x1e913*/ 1568,
+ /*0x018f*/ 130,
+ /*0x10c8f*/ 1402,
+ /*0x2166*/ 875,
+ /*0x1f49*/ 747,
+ -1, -1, -1, -1,
+ /*0x118b3*/ 1479,
+ /*0x13f8*/ 524,
+ /*0x104bf*/ 1331,
+ /*0x1e90f*/ 1564,
+ /*0x1f9f*/ 799,
+ /*0x1041f*/ 1307,
+ /*0x041f*/ 328,
+ /*0x10bf*/ 515,
+ /*0x0181*/ 121,
+ /*0x10c81*/ 1388,
+ -1, -1,
+ /*0xab9f*/ 1205,
+ /*0x2c1f*/ 943,
+ /*0x00d1*/ 43,
+ /*0x039f*/ 256,
+ -1, -1, -1,
+ /*0x1e901*/ 1550,
+ /*0x1f8b*/ 779,
+ /*0x1040b*/ 1287,
+ /*0x040b*/ 308,
+ -1,
+ /*0x01f8*/ 186,
+ -1, -1, -1,
+ /*0xab8b*/ 1185,
+ /*0x2c0b*/ 923,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1c95*/ 545,
+ /*0x16e55*/ 1513,
+ /*0xfb13*/ 1245,
+ -1, -1, -1, -1, -1,
+ /*0x019f*/ 140,
+ /*0x10c9f*/ 1418,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1f3f*/ 745,
+ /*0x24b7*/ 887,
+ -1,
+ /*0x1e91f*/ 1580,
+ -1,
+ /*0x1efe*/ 715,
+ /*0x1e7e*/ 649,
+ /*0xa78b*/ 1111,
+ /*0x018b*/ 128,
+ /*0x10c8b*/ 1398,
+ -1,
+ /*0x1f1b*/ 727,
+ -1,
+ /*0x054f*/ 475,
+ /*0xfb01*/ 1239,
+ -1, -1,
+ /*0xff31*/ 1266,
+ -1,
+ /*0x1e90b*/ 1560,
+ -1, -1,
+ /*0x104bd*/ 1329,
+ -1, -1, -1,
+ /*0x118bf*/ 1491,
+ /*0x10bd*/ 513,
+ -1, -1, -1, -1,
+ /*0x16eb1*/ 1541,
+ -1, -1, -1, -1, -1,
+ /*0x104c1*/ 1333,
+ /*0x04c1*/ 390,
+ -1, -1, -1,
+ /*0x10c1*/ 517,
+ -1, -1, -1,
+ /*0x10576*/ 1358,
+ /*0x1c93*/ 543,
+ /*0x1f19*/ 725,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x104bb*/ 1327,
+ /*0x104b5*/ 1321,
+ -1,
+ /*0x16e4d*/ 1505,
+ -1,
+ /*0x10bb*/ 511,
+ /*0x10b5*/ 505,
+ -1, -1, -1,
+ /*0xff37*/ 1272,
+ -1,
+ /*0x24b9*/ 889,
+ /*0x1f3d*/ 743,
+ -1, -1, -1,
+ /*0x1c81*/ 531,
+ -1, -1,
+ /*0x1057a*/ 1362,
+ -1, -1, -1, -1,
+ /*0x16eb7*/ 1547,
+ -1, -1, -1, -1, -1, -1,
+ /*0x04fe*/ 420,
+ -1, -1,
+ /*0x0551*/ 477,
+ -1, -1, -1,
+ /*0x118bd*/ 1489,
+ -1, -1, -1,
+ /*0x24c9*/ 905,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1f3b*/ 741,
+ -1, -1,
+ /*0x1c9f*/ 555,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1ef6*/ 711,
+ /*0x1e76*/ 645,
+ -1, -1, -1, -1, -1, -1,
+ /*0xa77e*/ 1106,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x118bb*/ 1487,
+ /*0x118b5*/ 1481,
+ -1, -1,
+ /*0xff39*/ 1274,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0xff33*/ 1268,
+ -1,
+ /*0x1efa*/ 713,
+ /*0x1e7a*/ 647,
+ /*0x16e5e*/ 1522,
+ -1, -1, -1, -1, -1,
+ /*0x24bf*/ 895,
+ -1, -1,
+ /*0x16e43*/ 1495,
+ -1,
+ /*0x16eb3*/ 1543,
+ -1, -1,
+ /*0x10578*/ 1360,
+ -1,
+ /*0x104cf*/ 1347,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x16e5c*/ 1520,
+ -1, -1, -1,
+ /*0x10587*/ 1374,
+ /*0x0587*/ 483,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x16e4b*/ 1503,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x04f6*/ 416,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x24bd*/ 893,
+ -1, -1, -1, -1, -1,
+ /*0x04fa*/ 418,
+ -1,
+ /*0x1ef8*/ 712,
+ /*0x1e78*/ 646,
+ -1, -1, -1, -1, -1, -1,
+ /*0x24c1*/ 897,
+ -1, -1,
+ /*0x104d1*/ 1349,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x10d51*/ 1439,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x24bb*/ 891,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x04f8*/ 417,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xff35*/ 1270,
+ -1, -1, -1, -1,
+ /*0x1f0f*/ 723,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x16eb5*/ 1545,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x16e49*/ 1501,
+ -1, -1, -1, -1,
+ /*0x24cf*/ 911,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1f0b*/ 719,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x16e41*/ 1493,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x10591*/ 1383,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0x16e4f*/ 1507,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x16e51*/ 1509,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x10595*/ 1386,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x1058f*/ 1381,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x10581*/ 1368,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xab70*/ 1158,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xab72*/ 1160,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0xab74*/ 1162,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0xab7e*/ 1172,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xab76*/ 1164,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xab7a*/ 1168,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0xab78*/ 1166
+ };
+
+ if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseFold_11_hash(code);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code1_equal(code, CaseFold_11_Table[s].from))
+ return &CaseFold_11_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_11_Type CaseUnfold_11_Table[] = {
+#define CaseUnfold_11 (*(CaseUnfold_11_Type (*)[1450])(CaseUnfold_11_Table+0))
+ {0x0061, {1|U, {0x0041}}},
+ {0x0062, {1|U, {0x0042}}},
+ {0x0063, {1|U, {0x0043}}},
+ {0x0064, {1|U, {0x0044}}},
+ {0x0065, {1|U, {0x0045}}},
+ {0x0066, {1|U, {0x0046}}},
+ {0x0067, {1|U, {0x0047}}},
+ {0x0068, {1|U, {0x0048}}},
+ {0x006a, {1|U, {0x004a}}},
+ {0x006b, {2|U, {0x004b, 0x212a}}},
+ {0x006c, {1|U, {0x004c}}},
+ {0x006d, {1|U, {0x004d}}},
+ {0x006e, {1|U, {0x004e}}},
+ {0x006f, {1|U, {0x004f}}},
+ {0x0070, {1|U, {0x0050}}},
+ {0x0071, {1|U, {0x0051}}},
+ {0x0072, {1|U, {0x0052}}},
+ {0x0073, {2|U, {0x0053, 0x017f}}},
+ {0x0074, {1|U, {0x0054}}},
+ {0x0075, {1|U, {0x0055}}},
+ {0x0076, {1|U, {0x0056}}},
+ {0x0077, {1|U, {0x0057}}},
+ {0x0078, {1|U, {0x0058}}},
+ {0x0079, {1|U, {0x0059}}},
+ {0x007a, {1|U, {0x005a}}},
+ {0x00e0, {1|U, {0x00c0}}},
+ {0x00e1, {1|U, {0x00c1}}},
+ {0x00e2, {1|U, {0x00c2}}},
+ {0x00e3, {1|U, {0x00c3}}},
+ {0x00e4, {1|U, {0x00c4}}},
+ {0x00e5, {2|U, {0x00c5, 0x212b}}},
+ {0x00e6, {1|U, {0x00c6}}},
+ {0x00e7, {1|U, {0x00c7}}},
+ {0x00e8, {1|U, {0x00c8}}},
+ {0x00e9, {1|U, {0x00c9}}},
+ {0x00ea, {1|U, {0x00ca}}},
+ {0x00eb, {1|U, {0x00cb}}},
+ {0x00ec, {1|U, {0x00cc}}},
+ {0x00ed, {1|U, {0x00cd}}},
+ {0x00ee, {1|U, {0x00ce}}},
+ {0x00ef, {1|U, {0x00cf}}},
+ {0x00f0, {1|U, {0x00d0}}},
+ {0x00f1, {1|U, {0x00d1}}},
+ {0x00f2, {1|U, {0x00d2}}},
+ {0x00f3, {1|U, {0x00d3}}},
+ {0x00f4, {1|U, {0x00d4}}},
+ {0x00f5, {1|U, {0x00d5}}},
+ {0x00f6, {1|U, {0x00d6}}},
+ {0x00f8, {1|U, {0x00d8}}},
+ {0x00f9, {1|U, {0x00d9}}},
+ {0x00fa, {1|U, {0x00da}}},
+ {0x00fb, {1|U, {0x00db}}},
+ {0x00fc, {1|U, {0x00dc}}},
+ {0x00fd, {1|U, {0x00dd}}},
+ {0x00fe, {1|U, {0x00de}}},
+ {0x00ff, {1|U, {0x0178}}},
+ {0x0101, {1|U, {0x0100}}},
+ {0x0103, {1|U, {0x0102}}},
+ {0x0105, {1|U, {0x0104}}},
+ {0x0107, {1|U, {0x0106}}},
+ {0x0109, {1|U, {0x0108}}},
+ {0x010b, {1|U, {0x010a}}},
+ {0x010d, {1|U, {0x010c}}},
+ {0x010f, {1|U, {0x010e}}},
+ {0x0111, {1|U, {0x0110}}},
+ {0x0113, {1|U, {0x0112}}},
+ {0x0115, {1|U, {0x0114}}},
+ {0x0117, {1|U, {0x0116}}},
+ {0x0119, {1|U, {0x0118}}},
+ {0x011b, {1|U, {0x011a}}},
+ {0x011d, {1|U, {0x011c}}},
+ {0x011f, {1|U, {0x011e}}},
+ {0x0121, {1|U, {0x0120}}},
+ {0x0123, {1|U, {0x0122}}},
+ {0x0125, {1|U, {0x0124}}},
+ {0x0127, {1|U, {0x0126}}},
+ {0x0129, {1|U, {0x0128}}},
+ {0x012b, {1|U, {0x012a}}},
+ {0x012d, {1|U, {0x012c}}},
+ {0x012f, {1|U, {0x012e}}},
+ {0x0133, {1|U, {0x0132}}},
+ {0x0135, {1|U, {0x0134}}},
+ {0x0137, {1|U, {0x0136}}},
+ {0x013a, {1|U, {0x0139}}},
+ {0x013c, {1|U, {0x013b}}},
+ {0x013e, {1|U, {0x013d}}},
+ {0x0140, {1|U, {0x013f}}},
+ {0x0142, {1|U, {0x0141}}},
+ {0x0144, {1|U, {0x0143}}},
+ {0x0146, {1|U, {0x0145}}},
+ {0x0148, {1|U, {0x0147}}},
+ {0x014b, {1|U, {0x014a}}},
+ {0x014d, {1|U, {0x014c}}},
+ {0x014f, {1|U, {0x014e}}},
+ {0x0151, {1|U, {0x0150}}},
+ {0x0153, {1|U, {0x0152}}},
+ {0x0155, {1|U, {0x0154}}},
+ {0x0157, {1|U, {0x0156}}},
+ {0x0159, {1|U, {0x0158}}},
+ {0x015b, {1|U, {0x015a}}},
+ {0x015d, {1|U, {0x015c}}},
+ {0x015f, {1|U, {0x015e}}},
+ {0x0161, {1|U, {0x0160}}},
+ {0x0163, {1|U, {0x0162}}},
+ {0x0165, {1|U, {0x0164}}},
+ {0x0167, {1|U, {0x0166}}},
+ {0x0169, {1|U, {0x0168}}},
+ {0x016b, {1|U, {0x016a}}},
+ {0x016d, {1|U, {0x016c}}},
+ {0x016f, {1|U, {0x016e}}},
+ {0x0171, {1|U, {0x0170}}},
+ {0x0173, {1|U, {0x0172}}},
+ {0x0175, {1|U, {0x0174}}},
+ {0x0177, {1|U, {0x0176}}},
+ {0x017a, {1|U, {0x0179}}},
+ {0x017c, {1|U, {0x017b}}},
+ {0x017e, {1|U, {0x017d}}},
+ {0x0180, {1|U, {0x0243}}},
+ {0x0183, {1|U, {0x0182}}},
+ {0x0185, {1|U, {0x0184}}},
+ {0x0188, {1|U, {0x0187}}},
+ {0x018c, {1|U, {0x018b}}},
+ {0x0192, {1|U, {0x0191}}},
+ {0x0195, {1|U, {0x01f6}}},
+ {0x0199, {1|U, {0x0198}}},
+ {0x019a, {1|U, {0x023d}}},
+ {0x019b, {1|U, {0xa7dc}}},
+ {0x019e, {1|U, {0x0220}}},
+ {0x01a1, {1|U, {0x01a0}}},
+ {0x01a3, {1|U, {0x01a2}}},
+ {0x01a5, {1|U, {0x01a4}}},
+ {0x01a8, {1|U, {0x01a7}}},
+ {0x01ad, {1|U, {0x01ac}}},
+ {0x01b0, {1|U, {0x01af}}},
+ {0x01b4, {1|U, {0x01b3}}},
+ {0x01b6, {1|U, {0x01b5}}},
+ {0x01b9, {1|U, {0x01b8}}},
+ {0x01bd, {1|U, {0x01bc}}},
+ {0x01bf, {1|U, {0x01f7}}},
+ {0x01c6, {2|U|ST, {0x01c4, 0x01c5}}},
+ {0x01c9, {2|U|ST, {0x01c7, 0x01c8}}},
+ {0x01cc, {2|U|ST, {0x01ca, 0x01cb}}},
+ {0x01ce, {1|U, {0x01cd}}},
+ {0x01d0, {1|U, {0x01cf}}},
+ {0x01d2, {1|U, {0x01d1}}},
+ {0x01d4, {1|U, {0x01d3}}},
+ {0x01d6, {1|U, {0x01d5}}},
+ {0x01d8, {1|U, {0x01d7}}},
+ {0x01da, {1|U, {0x01d9}}},
+ {0x01dc, {1|U, {0x01db}}},
+ {0x01dd, {1|U, {0x018e}}},
+ {0x01df, {1|U, {0x01de}}},
+ {0x01e1, {1|U, {0x01e0}}},
+ {0x01e3, {1|U, {0x01e2}}},
+ {0x01e5, {1|U, {0x01e4}}},
+ {0x01e7, {1|U, {0x01e6}}},
+ {0x01e9, {1|U, {0x01e8}}},
+ {0x01eb, {1|U, {0x01ea}}},
+ {0x01ed, {1|U, {0x01ec}}},
+ {0x01ef, {1|U, {0x01ee}}},
+ {0x01f3, {2|U|ST, {0x01f1, 0x01f2}}},
+ {0x01f5, {1|U, {0x01f4}}},
+ {0x01f9, {1|U, {0x01f8}}},
+ {0x01fb, {1|U, {0x01fa}}},
+ {0x01fd, {1|U, {0x01fc}}},
+ {0x01ff, {1|U, {0x01fe}}},
+ {0x0201, {1|U, {0x0200}}},
+ {0x0203, {1|U, {0x0202}}},
+ {0x0205, {1|U, {0x0204}}},
+ {0x0207, {1|U, {0x0206}}},
+ {0x0209, {1|U, {0x0208}}},
+ {0x020b, {1|U, {0x020a}}},
+ {0x020d, {1|U, {0x020c}}},
+ {0x020f, {1|U, {0x020e}}},
+ {0x0211, {1|U, {0x0210}}},
+ {0x0213, {1|U, {0x0212}}},
+ {0x0215, {1|U, {0x0214}}},
+ {0x0217, {1|U, {0x0216}}},
+ {0x0219, {1|U, {0x0218}}},
+ {0x021b, {1|U, {0x021a}}},
+ {0x021d, {1|U, {0x021c}}},
+ {0x021f, {1|U, {0x021e}}},
+ {0x0223, {1|U, {0x0222}}},
+ {0x0225, {1|U, {0x0224}}},
+ {0x0227, {1|U, {0x0226}}},
+ {0x0229, {1|U, {0x0228}}},
+ {0x022b, {1|U, {0x022a}}},
+ {0x022d, {1|U, {0x022c}}},
+ {0x022f, {1|U, {0x022e}}},
+ {0x0231, {1|U, {0x0230}}},
+ {0x0233, {1|U, {0x0232}}},
+ {0x023c, {1|U, {0x023b}}},
+ {0x023f, {1|U, {0x2c7e}}},
+ {0x0240, {1|U, {0x2c7f}}},
+ {0x0242, {1|U, {0x0241}}},
+ {0x0247, {1|U, {0x0246}}},
+ {0x0249, {1|U, {0x0248}}},
+ {0x024b, {1|U, {0x024a}}},
+ {0x024d, {1|U, {0x024c}}},
+ {0x024f, {1|U, {0x024e}}},
+ {0x0250, {1|U, {0x2c6f}}},
+ {0x0251, {1|U, {0x2c6d}}},
+ {0x0252, {1|U, {0x2c70}}},
+ {0x0253, {1|U, {0x0181}}},
+ {0x0254, {1|U, {0x0186}}},
+ {0x0256, {1|U, {0x0189}}},
+ {0x0257, {1|U, {0x018a}}},
+ {0x0259, {1|U, {0x018f}}},
+ {0x025b, {1|U, {0x0190}}},
+ {0x025c, {1|U, {0xa7ab}}},
+ {0x0260, {1|U, {0x0193}}},
+ {0x0261, {1|U, {0xa7ac}}},
+ {0x0263, {1|U, {0x0194}}},
+ {0x0264, {1|U, {0xa7cb}}},
+ {0x0265, {1|U, {0xa78d}}},
+ {0x0266, {1|U, {0xa7aa}}},
+ {0x0268, {1|U, {0x0197}}},
+ {0x0269, {1|U, {0x0196}}},
+ {0x026a, {1|U, {0xa7ae}}},
+ {0x026b, {1|U, {0x2c62}}},
+ {0x026c, {1|U, {0xa7ad}}},
+ {0x026f, {1|U, {0x019c}}},
+ {0x0271, {1|U, {0x2c6e}}},
+ {0x0272, {1|U, {0x019d}}},
+ {0x0275, {1|U, {0x019f}}},
+ {0x027d, {1|U, {0x2c64}}},
+ {0x0280, {1|U, {0x01a6}}},
+ {0x0282, {1|U, {0xa7c5}}},
+ {0x0283, {1|U, {0x01a9}}},
+ {0x0287, {1|U, {0xa7b1}}},
+ {0x0288, {1|U, {0x01ae}}},
+ {0x0289, {1|U, {0x0244}}},
+ {0x028a, {1|U, {0x01b1}}},
+ {0x028b, {1|U, {0x01b2}}},
+ {0x028c, {1|U, {0x0245}}},
+ {0x0292, {1|U, {0x01b7}}},
+ {0x029d, {1|U, {0xa7b2}}},
+ {0x029e, {1|U, {0xa7b0}}},
+ {0x0371, {1|U, {0x0370}}},
+ {0x0373, {1|U, {0x0372}}},
+ {0x0377, {1|U, {0x0376}}},
+ {0x037b, {1|U, {0x03fd}}},
+ {0x037c, {1|U, {0x03fe}}},
+ {0x037d, {1|U, {0x03ff}}},
+ {0x03ac, {1|U, {0x0386}}},
+ {0x03ad, {1|U, {0x0388}}},
+ {0x03ae, {1|U, {0x0389}}},
+ {0x03af, {1|U, {0x038a}}},
+ {0x03b1, {1|U, {0x0391}}},
+ {0x03b2, {2|U, {0x0392, 0x03d0}}},
+ {0x03b3, {1|U, {0x0393}}},
+ {0x03b4, {1|U, {0x0394}}},
+ {0x03b5, {2|U, {0x0395, 0x03f5}}},
+ {0x03b6, {1|U, {0x0396}}},
+ {0x03b7, {1|U, {0x0397}}},
+ {0x03b8, {3|U, {0x0398, 0x03d1, 0x03f4}}},
+ {0x03b9, {3|U, {0x0399, 0x0345, 0x1fbe}}},
+ {0x03ba, {2|U, {0x039a, 0x03f0}}},
+ {0x03bb, {1|U, {0x039b}}},
+ {0x03bc, {2|U, {0x039c, 0x00b5}}},
+ {0x03bd, {1|U, {0x039d}}},
+ {0x03be, {1|U, {0x039e}}},
+ {0x03bf, {1|U, {0x039f}}},
+ {0x03c0, {2|U, {0x03a0, 0x03d6}}},
+ {0x03c1, {2|U, {0x03a1, 0x03f1}}},
+ {0x03c3, {2|U, {0x03a3, 0x03c2}}},
+ {0x03c4, {1|U, {0x03a4}}},
+ {0x03c5, {1|U, {0x03a5}}},
+ {0x03c6, {2|U, {0x03a6, 0x03d5}}},
+ {0x03c7, {1|U, {0x03a7}}},
+ {0x03c8, {1|U, {0x03a8}}},
+ {0x03c9, {2|U, {0x03a9, 0x2126}}},
+ {0x03ca, {1|U, {0x03aa}}},
+ {0x03cb, {1|U, {0x03ab}}},
+ {0x03cc, {1|U, {0x038c}}},
+ {0x03cd, {1|U, {0x038e}}},
+ {0x03ce, {1|U, {0x038f}}},
+ {0x03d7, {1|U, {0x03cf}}},
+ {0x03d9, {1|U, {0x03d8}}},
+ {0x03db, {1|U, {0x03da}}},
+ {0x03dd, {1|U, {0x03dc}}},
+ {0x03df, {1|U, {0x03de}}},
+ {0x03e1, {1|U, {0x03e0}}},
+ {0x03e3, {1|U, {0x03e2}}},
+ {0x03e5, {1|U, {0x03e4}}},
+ {0x03e7, {1|U, {0x03e6}}},
+ {0x03e9, {1|U, {0x03e8}}},
+ {0x03eb, {1|U, {0x03ea}}},
+ {0x03ed, {1|U, {0x03ec}}},
+ {0x03ef, {1|U, {0x03ee}}},
+ {0x03f2, {1|U, {0x03f9}}},
+ {0x03f3, {1|U, {0x037f}}},
+ {0x03f8, {1|U, {0x03f7}}},
+ {0x03fb, {1|U, {0x03fa}}},
+ {0x0430, {1|U, {0x0410}}},
+ {0x0431, {1|U, {0x0411}}},
+ {0x0432, {2|U, {0x0412, 0x1c80}}},
+ {0x0433, {1|U, {0x0413}}},
+ {0x0434, {2|U, {0x0414, 0x1c81}}},
+ {0x0435, {1|U, {0x0415}}},
+ {0x0436, {1|U, {0x0416}}},
+ {0x0437, {1|U, {0x0417}}},
+ {0x0438, {1|U, {0x0418}}},
+ {0x0439, {1|U, {0x0419}}},
+ {0x043a, {1|U, {0x041a}}},
+ {0x043b, {1|U, {0x041b}}},
+ {0x043c, {1|U, {0x041c}}},
+ {0x043d, {1|U, {0x041d}}},
+ {0x043e, {2|U, {0x041e, 0x1c82}}},
+ {0x043f, {1|U, {0x041f}}},
+ {0x0440, {1|U, {0x0420}}},
+ {0x0441, {2|U, {0x0421, 0x1c83}}},
+ {0x0442, {3|U, {0x0422, 0x1c84, 0x1c85}}},
+ {0x0443, {1|U, {0x0423}}},
+ {0x0444, {1|U, {0x0424}}},
+ {0x0445, {1|U, {0x0425}}},
+ {0x0446, {1|U, {0x0426}}},
+ {0x0447, {1|U, {0x0427}}},
+ {0x0448, {1|U, {0x0428}}},
+ {0x0449, {1|U, {0x0429}}},
+ {0x044a, {2|U, {0x042a, 0x1c86}}},
+ {0x044b, {1|U, {0x042b}}},
+ {0x044c, {1|U, {0x042c}}},
+ {0x044d, {1|U, {0x042d}}},
+ {0x044e, {1|U, {0x042e}}},
+ {0x044f, {1|U, {0x042f}}},
+ {0x0450, {1|U, {0x0400}}},
+ {0x0451, {1|U, {0x0401}}},
+ {0x0452, {1|U, {0x0402}}},
+ {0x0453, {1|U, {0x0403}}},
+ {0x0454, {1|U, {0x0404}}},
+ {0x0455, {1|U, {0x0405}}},
+ {0x0456, {1|U, {0x0406}}},
+ {0x0457, {1|U, {0x0407}}},
+ {0x0458, {1|U, {0x0408}}},
+ {0x0459, {1|U, {0x0409}}},
+ {0x045a, {1|U, {0x040a}}},
+ {0x045b, {1|U, {0x040b}}},
+ {0x045c, {1|U, {0x040c}}},
+ {0x045d, {1|U, {0x040d}}},
+ {0x045e, {1|U, {0x040e}}},
+ {0x045f, {1|U, {0x040f}}},
+ {0x0461, {1|U, {0x0460}}},
+ {0x0463, {2|U, {0x0462, 0x1c87}}},
+ {0x0465, {1|U, {0x0464}}},
+ {0x0467, {1|U, {0x0466}}},
+ {0x0469, {1|U, {0x0468}}},
+ {0x046b, {1|U, {0x046a}}},
+ {0x046d, {1|U, {0x046c}}},
+ {0x046f, {1|U, {0x046e}}},
+ {0x0471, {1|U, {0x0470}}},
+ {0x0473, {1|U, {0x0472}}},
+ {0x0475, {1|U, {0x0474}}},
+ {0x0477, {1|U, {0x0476}}},
+ {0x0479, {1|U, {0x0478}}},
+ {0x047b, {1|U, {0x047a}}},
+ {0x047d, {1|U, {0x047c}}},
+ {0x047f, {1|U, {0x047e}}},
+ {0x0481, {1|U, {0x0480}}},
+ {0x048b, {1|U, {0x048a}}},
+ {0x048d, {1|U, {0x048c}}},
+ {0x048f, {1|U, {0x048e}}},
+ {0x0491, {1|U, {0x0490}}},
+ {0x0493, {1|U, {0x0492}}},
+ {0x0495, {1|U, {0x0494}}},
+ {0x0497, {1|U, {0x0496}}},
+ {0x0499, {1|U, {0x0498}}},
+ {0x049b, {1|U, {0x049a}}},
+ {0x049d, {1|U, {0x049c}}},
+ {0x049f, {1|U, {0x049e}}},
+ {0x04a1, {1|U, {0x04a0}}},
+ {0x04a3, {1|U, {0x04a2}}},
+ {0x04a5, {1|U, {0x04a4}}},
+ {0x04a7, {1|U, {0x04a6}}},
+ {0x04a9, {1|U, {0x04a8}}},
+ {0x04ab, {1|U, {0x04aa}}},
+ {0x04ad, {1|U, {0x04ac}}},
+ {0x04af, {1|U, {0x04ae}}},
+ {0x04b1, {1|U, {0x04b0}}},
+ {0x04b3, {1|U, {0x04b2}}},
+ {0x04b5, {1|U, {0x04b4}}},
+ {0x04b7, {1|U, {0x04b6}}},
+ {0x04b9, {1|U, {0x04b8}}},
+ {0x04bb, {1|U, {0x04ba}}},
+ {0x04bd, {1|U, {0x04bc}}},
+ {0x04bf, {1|U, {0x04be}}},
+ {0x04c2, {1|U, {0x04c1}}},
+ {0x04c4, {1|U, {0x04c3}}},
+ {0x04c6, {1|U, {0x04c5}}},
+ {0x04c8, {1|U, {0x04c7}}},
+ {0x04ca, {1|U, {0x04c9}}},
+ {0x04cc, {1|U, {0x04cb}}},
+ {0x04ce, {1|U, {0x04cd}}},
+ {0x04cf, {1|U, {0x04c0}}},
+ {0x04d1, {1|U, {0x04d0}}},
+ {0x04d3, {1|U, {0x04d2}}},
+ {0x04d5, {1|U, {0x04d4}}},
+ {0x04d7, {1|U, {0x04d6}}},
+ {0x04d9, {1|U, {0x04d8}}},
+ {0x04db, {1|U, {0x04da}}},
+ {0x04dd, {1|U, {0x04dc}}},
+ {0x04df, {1|U, {0x04de}}},
+ {0x04e1, {1|U, {0x04e0}}},
+ {0x04e3, {1|U, {0x04e2}}},
+ {0x04e5, {1|U, {0x04e4}}},
+ {0x04e7, {1|U, {0x04e6}}},
+ {0x04e9, {1|U, {0x04e8}}},
+ {0x04eb, {1|U, {0x04ea}}},
+ {0x04ed, {1|U, {0x04ec}}},
+ {0x04ef, {1|U, {0x04ee}}},
+ {0x04f1, {1|U, {0x04f0}}},
+ {0x04f3, {1|U, {0x04f2}}},
+ {0x04f5, {1|U, {0x04f4}}},
+ {0x04f7, {1|U, {0x04f6}}},
+ {0x04f9, {1|U, {0x04f8}}},
+ {0x04fb, {1|U, {0x04fa}}},
+ {0x04fd, {1|U, {0x04fc}}},
+ {0x04ff, {1|U, {0x04fe}}},
+ {0x0501, {1|U, {0x0500}}},
+ {0x0503, {1|U, {0x0502}}},
+ {0x0505, {1|U, {0x0504}}},
+ {0x0507, {1|U, {0x0506}}},
+ {0x0509, {1|U, {0x0508}}},
+ {0x050b, {1|U, {0x050a}}},
+ {0x050d, {1|U, {0x050c}}},
+ {0x050f, {1|U, {0x050e}}},
+ {0x0511, {1|U, {0x0510}}},
+ {0x0513, {1|U, {0x0512}}},
+ {0x0515, {1|U, {0x0514}}},
+ {0x0517, {1|U, {0x0516}}},
+ {0x0519, {1|U, {0x0518}}},
+ {0x051b, {1|U, {0x051a}}},
+ {0x051d, {1|U, {0x051c}}},
+ {0x051f, {1|U, {0x051e}}},
+ {0x0521, {1|U, {0x0520}}},
+ {0x0523, {1|U, {0x0522}}},
+ {0x0525, {1|U, {0x0524}}},
+ {0x0527, {1|U, {0x0526}}},
+ {0x0529, {1|U, {0x0528}}},
+ {0x052b, {1|U, {0x052a}}},
+ {0x052d, {1|U, {0x052c}}},
+ {0x052f, {1|U, {0x052e}}},
+ {0x0561, {1|U, {0x0531}}},
+ {0x0562, {1|U, {0x0532}}},
+ {0x0563, {1|U, {0x0533}}},
+ {0x0564, {1|U, {0x0534}}},
+ {0x0565, {1|U, {0x0535}}},
+ {0x0566, {1|U, {0x0536}}},
+ {0x0567, {1|U, {0x0537}}},
+ {0x0568, {1|U, {0x0538}}},
+ {0x0569, {1|U, {0x0539}}},
+ {0x056a, {1|U, {0x053a}}},
+ {0x056b, {1|U, {0x053b}}},
+ {0x056c, {1|U, {0x053c}}},
+ {0x056d, {1|U, {0x053d}}},
+ {0x056e, {1|U, {0x053e}}},
+ {0x056f, {1|U, {0x053f}}},
+ {0x0570, {1|U, {0x0540}}},
+ {0x0571, {1|U, {0x0541}}},
+ {0x0572, {1|U, {0x0542}}},
+ {0x0573, {1|U, {0x0543}}},
+ {0x0574, {1|U, {0x0544}}},
+ {0x0575, {1|U, {0x0545}}},
+ {0x0576, {1|U, {0x0546}}},
+ {0x0577, {1|U, {0x0547}}},
+ {0x0578, {1|U, {0x0548}}},
+ {0x0579, {1|U, {0x0549}}},
+ {0x057a, {1|U, {0x054a}}},
+ {0x057b, {1|U, {0x054b}}},
+ {0x057c, {1|U, {0x054c}}},
+ {0x057d, {1|U, {0x054d}}},
+ {0x057e, {1|U, {0x054e}}},
+ {0x057f, {1|U, {0x054f}}},
+ {0x0580, {1|U, {0x0550}}},
+ {0x0581, {1|U, {0x0551}}},
+ {0x0582, {1|U, {0x0552}}},
+ {0x0583, {1|U, {0x0553}}},
+ {0x0584, {1|U, {0x0554}}},
+ {0x0585, {1|U, {0x0555}}},
+ {0x0586, {1|U, {0x0556}}},
+ {0x10d0, {1|U|IT, {0x1c90}}},
+ {0x10d1, {1|U|IT, {0x1c91}}},
+ {0x10d2, {1|U|IT, {0x1c92}}},
+ {0x10d3, {1|U|IT, {0x1c93}}},
+ {0x10d4, {1|U|IT, {0x1c94}}},
+ {0x10d5, {1|U|IT, {0x1c95}}},
+ {0x10d6, {1|U|IT, {0x1c96}}},
+ {0x10d7, {1|U|IT, {0x1c97}}},
+ {0x10d8, {1|U|IT, {0x1c98}}},
+ {0x10d9, {1|U|IT, {0x1c99}}},
+ {0x10da, {1|U|IT, {0x1c9a}}},
+ {0x10db, {1|U|IT, {0x1c9b}}},
+ {0x10dc, {1|U|IT, {0x1c9c}}},
+ {0x10dd, {1|U|IT, {0x1c9d}}},
+ {0x10de, {1|U|IT, {0x1c9e}}},
+ {0x10df, {1|U|IT, {0x1c9f}}},
+ {0x10e0, {1|U|IT, {0x1ca0}}},
+ {0x10e1, {1|U|IT, {0x1ca1}}},
+ {0x10e2, {1|U|IT, {0x1ca2}}},
+ {0x10e3, {1|U|IT, {0x1ca3}}},
+ {0x10e4, {1|U|IT, {0x1ca4}}},
+ {0x10e5, {1|U|IT, {0x1ca5}}},
+ {0x10e6, {1|U|IT, {0x1ca6}}},
+ {0x10e7, {1|U|IT, {0x1ca7}}},
+ {0x10e8, {1|U|IT, {0x1ca8}}},
+ {0x10e9, {1|U|IT, {0x1ca9}}},
+ {0x10ea, {1|U|IT, {0x1caa}}},
+ {0x10eb, {1|U|IT, {0x1cab}}},
+ {0x10ec, {1|U|IT, {0x1cac}}},
+ {0x10ed, {1|U|IT, {0x1cad}}},
+ {0x10ee, {1|U|IT, {0x1cae}}},
+ {0x10ef, {1|U|IT, {0x1caf}}},
+ {0x10f0, {1|U|IT, {0x1cb0}}},
+ {0x10f1, {1|U|IT, {0x1cb1}}},
+ {0x10f2, {1|U|IT, {0x1cb2}}},
+ {0x10f3, {1|U|IT, {0x1cb3}}},
+ {0x10f4, {1|U|IT, {0x1cb4}}},
+ {0x10f5, {1|U|IT, {0x1cb5}}},
+ {0x10f6, {1|U|IT, {0x1cb6}}},
+ {0x10f7, {1|U|IT, {0x1cb7}}},
+ {0x10f8, {1|U|IT, {0x1cb8}}},
+ {0x10f9, {1|U|IT, {0x1cb9}}},
+ {0x10fa, {1|U|IT, {0x1cba}}},
+ {0x10fd, {1|U|IT, {0x1cbd}}},
+ {0x10fe, {1|U|IT, {0x1cbe}}},
+ {0x10ff, {1|U|IT, {0x1cbf}}},
+ {0x13a0, {1|D, {0xab70}}},
+ {0x13a1, {1|D, {0xab71}}},
+ {0x13a2, {1|D, {0xab72}}},
+ {0x13a3, {1|D, {0xab73}}},
+ {0x13a4, {1|D, {0xab74}}},
+ {0x13a5, {1|D, {0xab75}}},
+ {0x13a6, {1|D, {0xab76}}},
+ {0x13a7, {1|D, {0xab77}}},
+ {0x13a8, {1|D, {0xab78}}},
+ {0x13a9, {1|D, {0xab79}}},
+ {0x13aa, {1|D, {0xab7a}}},
+ {0x13ab, {1|D, {0xab7b}}},
+ {0x13ac, {1|D, {0xab7c}}},
+ {0x13ad, {1|D, {0xab7d}}},
+ {0x13ae, {1|D, {0xab7e}}},
+ {0x13af, {1|D, {0xab7f}}},
+ {0x13b0, {1|D, {0xab80}}},
+ {0x13b1, {1|D, {0xab81}}},
+ {0x13b2, {1|D, {0xab82}}},
+ {0x13b3, {1|D, {0xab83}}},
+ {0x13b4, {1|D, {0xab84}}},
+ {0x13b5, {1|D, {0xab85}}},
+ {0x13b6, {1|D, {0xab86}}},
+ {0x13b7, {1|D, {0xab87}}},
+ {0x13b8, {1|D, {0xab88}}},
+ {0x13b9, {1|D, {0xab89}}},
+ {0x13ba, {1|D, {0xab8a}}},
+ {0x13bb, {1|D, {0xab8b}}},
+ {0x13bc, {1|D, {0xab8c}}},
+ {0x13bd, {1|D, {0xab8d}}},
+ {0x13be, {1|D, {0xab8e}}},
+ {0x13bf, {1|D, {0xab8f}}},
+ {0x13c0, {1|D, {0xab90}}},
+ {0x13c1, {1|D, {0xab91}}},
+ {0x13c2, {1|D, {0xab92}}},
+ {0x13c3, {1|D, {0xab93}}},
+ {0x13c4, {1|D, {0xab94}}},
+ {0x13c5, {1|D, {0xab95}}},
+ {0x13c6, {1|D, {0xab96}}},
+ {0x13c7, {1|D, {0xab97}}},
+ {0x13c8, {1|D, {0xab98}}},
+ {0x13c9, {1|D, {0xab99}}},
+ {0x13ca, {1|D, {0xab9a}}},
+ {0x13cb, {1|D, {0xab9b}}},
+ {0x13cc, {1|D, {0xab9c}}},
+ {0x13cd, {1|D, {0xab9d}}},
+ {0x13ce, {1|D, {0xab9e}}},
+ {0x13cf, {1|D, {0xab9f}}},
+ {0x13d0, {1|D, {0xaba0}}},
+ {0x13d1, {1|D, {0xaba1}}},
+ {0x13d2, {1|D, {0xaba2}}},
+ {0x13d3, {1|D, {0xaba3}}},
+ {0x13d4, {1|D, {0xaba4}}},
+ {0x13d5, {1|D, {0xaba5}}},
+ {0x13d6, {1|D, {0xaba6}}},
+ {0x13d7, {1|D, {0xaba7}}},
+ {0x13d8, {1|D, {0xaba8}}},
+ {0x13d9, {1|D, {0xaba9}}},
+ {0x13da, {1|D, {0xabaa}}},
+ {0x13db, {1|D, {0xabab}}},
+ {0x13dc, {1|D, {0xabac}}},
+ {0x13dd, {1|D, {0xabad}}},
+ {0x13de, {1|D, {0xabae}}},
+ {0x13df, {1|D, {0xabaf}}},
+ {0x13e0, {1|D, {0xabb0}}},
+ {0x13e1, {1|D, {0xabb1}}},
+ {0x13e2, {1|D, {0xabb2}}},
+ {0x13e3, {1|D, {0xabb3}}},
+ {0x13e4, {1|D, {0xabb4}}},
+ {0x13e5, {1|D, {0xabb5}}},
+ {0x13e6, {1|D, {0xabb6}}},
+ {0x13e7, {1|D, {0xabb7}}},
+ {0x13e8, {1|D, {0xabb8}}},
+ {0x13e9, {1|D, {0xabb9}}},
+ {0x13ea, {1|D, {0xabba}}},
+ {0x13eb, {1|D, {0xabbb}}},
+ {0x13ec, {1|D, {0xabbc}}},
+ {0x13ed, {1|D, {0xabbd}}},
+ {0x13ee, {1|D, {0xabbe}}},
+ {0x13ef, {1|D, {0xabbf}}},
+ {0x13f0, {1|D, {0x13f8}}},
+ {0x13f1, {1|D, {0x13f9}}},
+ {0x13f2, {1|D, {0x13fa}}},
+ {0x13f3, {1|D, {0x13fb}}},
+ {0x13f4, {1|D, {0x13fc}}},
+ {0x13f5, {1|D, {0x13fd}}},
+ {0x1c8a, {1|U, {0x1c89}}},
+ {0x1d79, {1|U, {0xa77d}}},
+ {0x1d7d, {1|U, {0x2c63}}},
+ {0x1d8e, {1|U, {0xa7c6}}},
+ {0x1e01, {1|U, {0x1e00}}},
+ {0x1e03, {1|U, {0x1e02}}},
+ {0x1e05, {1|U, {0x1e04}}},
+ {0x1e07, {1|U, {0x1e06}}},
+ {0x1e09, {1|U, {0x1e08}}},
+ {0x1e0b, {1|U, {0x1e0a}}},
+ {0x1e0d, {1|U, {0x1e0c}}},
+ {0x1e0f, {1|U, {0x1e0e}}},
+ {0x1e11, {1|U, {0x1e10}}},
+ {0x1e13, {1|U, {0x1e12}}},
+ {0x1e15, {1|U, {0x1e14}}},
+ {0x1e17, {1|U, {0x1e16}}},
+ {0x1e19, {1|U, {0x1e18}}},
+ {0x1e1b, {1|U, {0x1e1a}}},
+ {0x1e1d, {1|U, {0x1e1c}}},
+ {0x1e1f, {1|U, {0x1e1e}}},
+ {0x1e21, {1|U, {0x1e20}}},
+ {0x1e23, {1|U, {0x1e22}}},
+ {0x1e25, {1|U, {0x1e24}}},
+ {0x1e27, {1|U, {0x1e26}}},
+ {0x1e29, {1|U, {0x1e28}}},
+ {0x1e2b, {1|U, {0x1e2a}}},
+ {0x1e2d, {1|U, {0x1e2c}}},
+ {0x1e2f, {1|U, {0x1e2e}}},
+ {0x1e31, {1|U, {0x1e30}}},
+ {0x1e33, {1|U, {0x1e32}}},
+ {0x1e35, {1|U, {0x1e34}}},
+ {0x1e37, {1|U, {0x1e36}}},
+ {0x1e39, {1|U, {0x1e38}}},
+ {0x1e3b, {1|U, {0x1e3a}}},
+ {0x1e3d, {1|U, {0x1e3c}}},
+ {0x1e3f, {1|U, {0x1e3e}}},
+ {0x1e41, {1|U, {0x1e40}}},
+ {0x1e43, {1|U, {0x1e42}}},
+ {0x1e45, {1|U, {0x1e44}}},
+ {0x1e47, {1|U, {0x1e46}}},
+ {0x1e49, {1|U, {0x1e48}}},
+ {0x1e4b, {1|U, {0x1e4a}}},
+ {0x1e4d, {1|U, {0x1e4c}}},
+ {0x1e4f, {1|U, {0x1e4e}}},
+ {0x1e51, {1|U, {0x1e50}}},
+ {0x1e53, {1|U, {0x1e52}}},
+ {0x1e55, {1|U, {0x1e54}}},
+ {0x1e57, {1|U, {0x1e56}}},
+ {0x1e59, {1|U, {0x1e58}}},
+ {0x1e5b, {1|U, {0x1e5a}}},
+ {0x1e5d, {1|U, {0x1e5c}}},
+ {0x1e5f, {1|U, {0x1e5e}}},
+ {0x1e61, {2|U, {0x1e60, 0x1e9b}}},
+ {0x1e63, {1|U, {0x1e62}}},
+ {0x1e65, {1|U, {0x1e64}}},
+ {0x1e67, {1|U, {0x1e66}}},
+ {0x1e69, {1|U, {0x1e68}}},
+ {0x1e6b, {1|U, {0x1e6a}}},
+ {0x1e6d, {1|U, {0x1e6c}}},
+ {0x1e6f, {1|U, {0x1e6e}}},
+ {0x1e71, {1|U, {0x1e70}}},
+ {0x1e73, {1|U, {0x1e72}}},
+ {0x1e75, {1|U, {0x1e74}}},
+ {0x1e77, {1|U, {0x1e76}}},
+ {0x1e79, {1|U, {0x1e78}}},
+ {0x1e7b, {1|U, {0x1e7a}}},
+ {0x1e7d, {1|U, {0x1e7c}}},
+ {0x1e7f, {1|U, {0x1e7e}}},
+ {0x1e81, {1|U, {0x1e80}}},
+ {0x1e83, {1|U, {0x1e82}}},
+ {0x1e85, {1|U, {0x1e84}}},
+ {0x1e87, {1|U, {0x1e86}}},
+ {0x1e89, {1|U, {0x1e88}}},
+ {0x1e8b, {1|U, {0x1e8a}}},
+ {0x1e8d, {1|U, {0x1e8c}}},
+ {0x1e8f, {1|U, {0x1e8e}}},
+ {0x1e91, {1|U, {0x1e90}}},
+ {0x1e93, {1|U, {0x1e92}}},
+ {0x1e95, {1|U, {0x1e94}}},
+ {0x1ea1, {1|U, {0x1ea0}}},
+ {0x1ea3, {1|U, {0x1ea2}}},
+ {0x1ea5, {1|U, {0x1ea4}}},
+ {0x1ea7, {1|U, {0x1ea6}}},
+ {0x1ea9, {1|U, {0x1ea8}}},
+ {0x1eab, {1|U, {0x1eaa}}},
+ {0x1ead, {1|U, {0x1eac}}},
+ {0x1eaf, {1|U, {0x1eae}}},
+ {0x1eb1, {1|U, {0x1eb0}}},
+ {0x1eb3, {1|U, {0x1eb2}}},
+ {0x1eb5, {1|U, {0x1eb4}}},
+ {0x1eb7, {1|U, {0x1eb6}}},
+ {0x1eb9, {1|U, {0x1eb8}}},
+ {0x1ebb, {1|U, {0x1eba}}},
+ {0x1ebd, {1|U, {0x1ebc}}},
+ {0x1ebf, {1|U, {0x1ebe}}},
+ {0x1ec1, {1|U, {0x1ec0}}},
+ {0x1ec3, {1|U, {0x1ec2}}},
+ {0x1ec5, {1|U, {0x1ec4}}},
+ {0x1ec7, {1|U, {0x1ec6}}},
+ {0x1ec9, {1|U, {0x1ec8}}},
+ {0x1ecb, {1|U, {0x1eca}}},
+ {0x1ecd, {1|U, {0x1ecc}}},
+ {0x1ecf, {1|U, {0x1ece}}},
+ {0x1ed1, {1|U, {0x1ed0}}},
+ {0x1ed3, {1|U, {0x1ed2}}},
+ {0x1ed5, {1|U, {0x1ed4}}},
+ {0x1ed7, {1|U, {0x1ed6}}},
+ {0x1ed9, {1|U, {0x1ed8}}},
+ {0x1edb, {1|U, {0x1eda}}},
+ {0x1edd, {1|U, {0x1edc}}},
+ {0x1edf, {1|U, {0x1ede}}},
+ {0x1ee1, {1|U, {0x1ee0}}},
+ {0x1ee3, {1|U, {0x1ee2}}},
+ {0x1ee5, {1|U, {0x1ee4}}},
+ {0x1ee7, {1|U, {0x1ee6}}},
+ {0x1ee9, {1|U, {0x1ee8}}},
+ {0x1eeb, {1|U, {0x1eea}}},
+ {0x1eed, {1|U, {0x1eec}}},
+ {0x1eef, {1|U, {0x1eee}}},
+ {0x1ef1, {1|U, {0x1ef0}}},
+ {0x1ef3, {1|U, {0x1ef2}}},
+ {0x1ef5, {1|U, {0x1ef4}}},
+ {0x1ef7, {1|U, {0x1ef6}}},
+ {0x1ef9, {1|U, {0x1ef8}}},
+ {0x1efb, {1|U, {0x1efa}}},
+ {0x1efd, {1|U, {0x1efc}}},
+ {0x1eff, {1|U, {0x1efe}}},
+ {0x1f00, {1|U, {0x1f08}}},
+ {0x1f01, {1|U, {0x1f09}}},
+ {0x1f02, {1|U, {0x1f0a}}},
+ {0x1f03, {1|U, {0x1f0b}}},
+ {0x1f04, {1|U, {0x1f0c}}},
+ {0x1f05, {1|U, {0x1f0d}}},
+ {0x1f06, {1|U, {0x1f0e}}},
+ {0x1f07, {1|U, {0x1f0f}}},
+ {0x1f10, {1|U, {0x1f18}}},
+ {0x1f11, {1|U, {0x1f19}}},
+ {0x1f12, {1|U, {0x1f1a}}},
+ {0x1f13, {1|U, {0x1f1b}}},
+ {0x1f14, {1|U, {0x1f1c}}},
+ {0x1f15, {1|U, {0x1f1d}}},
+ {0x1f20, {1|U, {0x1f28}}},
+ {0x1f21, {1|U, {0x1f29}}},
+ {0x1f22, {1|U, {0x1f2a}}},
+ {0x1f23, {1|U, {0x1f2b}}},
+ {0x1f24, {1|U, {0x1f2c}}},
+ {0x1f25, {1|U, {0x1f2d}}},
+ {0x1f26, {1|U, {0x1f2e}}},
+ {0x1f27, {1|U, {0x1f2f}}},
+ {0x1f30, {1|U, {0x1f38}}},
+ {0x1f31, {1|U, {0x1f39}}},
+ {0x1f32, {1|U, {0x1f3a}}},
+ {0x1f33, {1|U, {0x1f3b}}},
+ {0x1f34, {1|U, {0x1f3c}}},
+ {0x1f35, {1|U, {0x1f3d}}},
+ {0x1f36, {1|U, {0x1f3e}}},
+ {0x1f37, {1|U, {0x1f3f}}},
+ {0x1f40, {1|U, {0x1f48}}},
+ {0x1f41, {1|U, {0x1f49}}},
+ {0x1f42, {1|U, {0x1f4a}}},
+ {0x1f43, {1|U, {0x1f4b}}},
+ {0x1f44, {1|U, {0x1f4c}}},
+ {0x1f45, {1|U, {0x1f4d}}},
+ {0x1f51, {1|U, {0x1f59}}},
+ {0x1f53, {1|U, {0x1f5b}}},
+ {0x1f55, {1|U, {0x1f5d}}},
+ {0x1f57, {1|U, {0x1f5f}}},
+ {0x1f60, {1|U, {0x1f68}}},
+ {0x1f61, {1|U, {0x1f69}}},
+ {0x1f62, {1|U, {0x1f6a}}},
+ {0x1f63, {1|U, {0x1f6b}}},
+ {0x1f64, {1|U, {0x1f6c}}},
+ {0x1f65, {1|U, {0x1f6d}}},
+ {0x1f66, {1|U, {0x1f6e}}},
+ {0x1f67, {1|U, {0x1f6f}}},
+ {0x1f70, {1|U, {0x1fba}}},
+ {0x1f71, {1|U, {0x1fbb}}},
+ {0x1f72, {1|U, {0x1fc8}}},
+ {0x1f73, {1|U, {0x1fc9}}},
+ {0x1f74, {1|U, {0x1fca}}},
+ {0x1f75, {1|U, {0x1fcb}}},
+ {0x1f76, {1|U, {0x1fda}}},
+ {0x1f77, {1|U, {0x1fdb}}},
+ {0x1f78, {1|U, {0x1ff8}}},
+ {0x1f79, {1|U, {0x1ff9}}},
+ {0x1f7a, {1|U, {0x1fea}}},
+ {0x1f7b, {1|U, {0x1feb}}},
+ {0x1f7c, {1|U, {0x1ffa}}},
+ {0x1f7d, {1|U, {0x1ffb}}},
+ {0x1fb0, {1|U, {0x1fb8}}},
+ {0x1fb1, {1|U, {0x1fb9}}},
+ {0x1fd0, {1|U, {0x1fd8}}},
+ {0x1fd1, {1|U, {0x1fd9}}},
+ {0x1fe0, {1|U, {0x1fe8}}},
+ {0x1fe1, {1|U, {0x1fe9}}},
+ {0x1fe5, {1|U, {0x1fec}}},
+ {0x214e, {1|U, {0x2132}}},
+ {0x2170, {1|U, {0x2160}}},
+ {0x2171, {1|U, {0x2161}}},
+ {0x2172, {1|U, {0x2162}}},
+ {0x2173, {1|U, {0x2163}}},
+ {0x2174, {1|U, {0x2164}}},
+ {0x2175, {1|U, {0x2165}}},
+ {0x2176, {1|U, {0x2166}}},
+ {0x2177, {1|U, {0x2167}}},
+ {0x2178, {1|U, {0x2168}}},
+ {0x2179, {1|U, {0x2169}}},
+ {0x217a, {1|U, {0x216a}}},
+ {0x217b, {1|U, {0x216b}}},
+ {0x217c, {1|U, {0x216c}}},
+ {0x217d, {1|U, {0x216d}}},
+ {0x217e, {1|U, {0x216e}}},
+ {0x217f, {1|U, {0x216f}}},
+ {0x2184, {1|U, {0x2183}}},
+ {0x24d0, {1|U, {0x24b6}}},
+ {0x24d1, {1|U, {0x24b7}}},
+ {0x24d2, {1|U, {0x24b8}}},
+ {0x24d3, {1|U, {0x24b9}}},
+ {0x24d4, {1|U, {0x24ba}}},
+ {0x24d5, {1|U, {0x24bb}}},
+ {0x24d6, {1|U, {0x24bc}}},
+ {0x24d7, {1|U, {0x24bd}}},
+ {0x24d8, {1|U, {0x24be}}},
+ {0x24d9, {1|U, {0x24bf}}},
+ {0x24da, {1|U, {0x24c0}}},
+ {0x24db, {1|U, {0x24c1}}},
+ {0x24dc, {1|U, {0x24c2}}},
+ {0x24dd, {1|U, {0x24c3}}},
+ {0x24de, {1|U, {0x24c4}}},
+ {0x24df, {1|U, {0x24c5}}},
+ {0x24e0, {1|U, {0x24c6}}},
+ {0x24e1, {1|U, {0x24c7}}},
+ {0x24e2, {1|U, {0x24c8}}},
+ {0x24e3, {1|U, {0x24c9}}},
+ {0x24e4, {1|U, {0x24ca}}},
+ {0x24e5, {1|U, {0x24cb}}},
+ {0x24e6, {1|U, {0x24cc}}},
+ {0x24e7, {1|U, {0x24cd}}},
+ {0x24e8, {1|U, {0x24ce}}},
+ {0x24e9, {1|U, {0x24cf}}},
+ {0x2c30, {1|U, {0x2c00}}},
+ {0x2c31, {1|U, {0x2c01}}},
+ {0x2c32, {1|U, {0x2c02}}},
+ {0x2c33, {1|U, {0x2c03}}},
+ {0x2c34, {1|U, {0x2c04}}},
+ {0x2c35, {1|U, {0x2c05}}},
+ {0x2c36, {1|U, {0x2c06}}},
+ {0x2c37, {1|U, {0x2c07}}},
+ {0x2c38, {1|U, {0x2c08}}},
+ {0x2c39, {1|U, {0x2c09}}},
+ {0x2c3a, {1|U, {0x2c0a}}},
+ {0x2c3b, {1|U, {0x2c0b}}},
+ {0x2c3c, {1|U, {0x2c0c}}},
+ {0x2c3d, {1|U, {0x2c0d}}},
+ {0x2c3e, {1|U, {0x2c0e}}},
+ {0x2c3f, {1|U, {0x2c0f}}},
+ {0x2c40, {1|U, {0x2c10}}},
+ {0x2c41, {1|U, {0x2c11}}},
+ {0x2c42, {1|U, {0x2c12}}},
+ {0x2c43, {1|U, {0x2c13}}},
+ {0x2c44, {1|U, {0x2c14}}},
+ {0x2c45, {1|U, {0x2c15}}},
+ {0x2c46, {1|U, {0x2c16}}},
+ {0x2c47, {1|U, {0x2c17}}},
+ {0x2c48, {1|U, {0x2c18}}},
+ {0x2c49, {1|U, {0x2c19}}},
+ {0x2c4a, {1|U, {0x2c1a}}},
+ {0x2c4b, {1|U, {0x2c1b}}},
+ {0x2c4c, {1|U, {0x2c1c}}},
+ {0x2c4d, {1|U, {0x2c1d}}},
+ {0x2c4e, {1|U, {0x2c1e}}},
+ {0x2c4f, {1|U, {0x2c1f}}},
+ {0x2c50, {1|U, {0x2c20}}},
+ {0x2c51, {1|U, {0x2c21}}},
+ {0x2c52, {1|U, {0x2c22}}},
+ {0x2c53, {1|U, {0x2c23}}},
+ {0x2c54, {1|U, {0x2c24}}},
+ {0x2c55, {1|U, {0x2c25}}},
+ {0x2c56, {1|U, {0x2c26}}},
+ {0x2c57, {1|U, {0x2c27}}},
+ {0x2c58, {1|U, {0x2c28}}},
+ {0x2c59, {1|U, {0x2c29}}},
+ {0x2c5a, {1|U, {0x2c2a}}},
+ {0x2c5b, {1|U, {0x2c2b}}},
+ {0x2c5c, {1|U, {0x2c2c}}},
+ {0x2c5d, {1|U, {0x2c2d}}},
+ {0x2c5e, {1|U, {0x2c2e}}},
+ {0x2c5f, {1|U, {0x2c2f}}},
+ {0x2c61, {1|U, {0x2c60}}},
+ {0x2c65, {1|U, {0x023a}}},
+ {0x2c66, {1|U, {0x023e}}},
+ {0x2c68, {1|U, {0x2c67}}},
+ {0x2c6a, {1|U, {0x2c69}}},
+ {0x2c6c, {1|U, {0x2c6b}}},
+ {0x2c73, {1|U, {0x2c72}}},
+ {0x2c76, {1|U, {0x2c75}}},
+ {0x2c81, {1|U, {0x2c80}}},
+ {0x2c83, {1|U, {0x2c82}}},
+ {0x2c85, {1|U, {0x2c84}}},
+ {0x2c87, {1|U, {0x2c86}}},
+ {0x2c89, {1|U, {0x2c88}}},
+ {0x2c8b, {1|U, {0x2c8a}}},
+ {0x2c8d, {1|U, {0x2c8c}}},
+ {0x2c8f, {1|U, {0x2c8e}}},
+ {0x2c91, {1|U, {0x2c90}}},
+ {0x2c93, {1|U, {0x2c92}}},
+ {0x2c95, {1|U, {0x2c94}}},
+ {0x2c97, {1|U, {0x2c96}}},
+ {0x2c99, {1|U, {0x2c98}}},
+ {0x2c9b, {1|U, {0x2c9a}}},
+ {0x2c9d, {1|U, {0x2c9c}}},
+ {0x2c9f, {1|U, {0x2c9e}}},
+ {0x2ca1, {1|U, {0x2ca0}}},
+ {0x2ca3, {1|U, {0x2ca2}}},
+ {0x2ca5, {1|U, {0x2ca4}}},
+ {0x2ca7, {1|U, {0x2ca6}}},
+ {0x2ca9, {1|U, {0x2ca8}}},
+ {0x2cab, {1|U, {0x2caa}}},
+ {0x2cad, {1|U, {0x2cac}}},
+ {0x2caf, {1|U, {0x2cae}}},
+ {0x2cb1, {1|U, {0x2cb0}}},
+ {0x2cb3, {1|U, {0x2cb2}}},
+ {0x2cb5, {1|U, {0x2cb4}}},
+ {0x2cb7, {1|U, {0x2cb6}}},
+ {0x2cb9, {1|U, {0x2cb8}}},
+ {0x2cbb, {1|U, {0x2cba}}},
+ {0x2cbd, {1|U, {0x2cbc}}},
+ {0x2cbf, {1|U, {0x2cbe}}},
+ {0x2cc1, {1|U, {0x2cc0}}},
+ {0x2cc3, {1|U, {0x2cc2}}},
+ {0x2cc5, {1|U, {0x2cc4}}},
+ {0x2cc7, {1|U, {0x2cc6}}},
+ {0x2cc9, {1|U, {0x2cc8}}},
+ {0x2ccb, {1|U, {0x2cca}}},
+ {0x2ccd, {1|U, {0x2ccc}}},
+ {0x2ccf, {1|U, {0x2cce}}},
+ {0x2cd1, {1|U, {0x2cd0}}},
+ {0x2cd3, {1|U, {0x2cd2}}},
+ {0x2cd5, {1|U, {0x2cd4}}},
+ {0x2cd7, {1|U, {0x2cd6}}},
+ {0x2cd9, {1|U, {0x2cd8}}},
+ {0x2cdb, {1|U, {0x2cda}}},
+ {0x2cdd, {1|U, {0x2cdc}}},
+ {0x2cdf, {1|U, {0x2cde}}},
+ {0x2ce1, {1|U, {0x2ce0}}},
+ {0x2ce3, {1|U, {0x2ce2}}},
+ {0x2cec, {1|U, {0x2ceb}}},
+ {0x2cee, {1|U, {0x2ced}}},
+ {0x2cf3, {1|U, {0x2cf2}}},
+ {0x2d00, {1|U, {0x10a0}}},
+ {0x2d01, {1|U, {0x10a1}}},
+ {0x2d02, {1|U, {0x10a2}}},
+ {0x2d03, {1|U, {0x10a3}}},
+ {0x2d04, {1|U, {0x10a4}}},
+ {0x2d05, {1|U, {0x10a5}}},
+ {0x2d06, {1|U, {0x10a6}}},
+ {0x2d07, {1|U, {0x10a7}}},
+ {0x2d08, {1|U, {0x10a8}}},
+ {0x2d09, {1|U, {0x10a9}}},
+ {0x2d0a, {1|U, {0x10aa}}},
+ {0x2d0b, {1|U, {0x10ab}}},
+ {0x2d0c, {1|U, {0x10ac}}},
+ {0x2d0d, {1|U, {0x10ad}}},
+ {0x2d0e, {1|U, {0x10ae}}},
+ {0x2d0f, {1|U, {0x10af}}},
+ {0x2d10, {1|U, {0x10b0}}},
+ {0x2d11, {1|U, {0x10b1}}},
+ {0x2d12, {1|U, {0x10b2}}},
+ {0x2d13, {1|U, {0x10b3}}},
+ {0x2d14, {1|U, {0x10b4}}},
+ {0x2d15, {1|U, {0x10b5}}},
+ {0x2d16, {1|U, {0x10b6}}},
+ {0x2d17, {1|U, {0x10b7}}},
+ {0x2d18, {1|U, {0x10b8}}},
+ {0x2d19, {1|U, {0x10b9}}},
+ {0x2d1a, {1|U, {0x10ba}}},
+ {0x2d1b, {1|U, {0x10bb}}},
+ {0x2d1c, {1|U, {0x10bc}}},
+ {0x2d1d, {1|U, {0x10bd}}},
+ {0x2d1e, {1|U, {0x10be}}},
+ {0x2d1f, {1|U, {0x10bf}}},
+ {0x2d20, {1|U, {0x10c0}}},
+ {0x2d21, {1|U, {0x10c1}}},
+ {0x2d22, {1|U, {0x10c2}}},
+ {0x2d23, {1|U, {0x10c3}}},
+ {0x2d24, {1|U, {0x10c4}}},
+ {0x2d25, {1|U, {0x10c5}}},
+ {0x2d27, {1|U, {0x10c7}}},
+ {0x2d2d, {1|U, {0x10cd}}},
+ {0xa641, {1|U, {0xa640}}},
+ {0xa643, {1|U, {0xa642}}},
+ {0xa645, {1|U, {0xa644}}},
+ {0xa647, {1|U, {0xa646}}},
+ {0xa649, {1|U, {0xa648}}},
+ {0xa64b, {2|U, {0xa64a, 0x1c88}}},
+ {0xa64d, {1|U, {0xa64c}}},
+ {0xa64f, {1|U, {0xa64e}}},
+ {0xa651, {1|U, {0xa650}}},
+ {0xa653, {1|U, {0xa652}}},
+ {0xa655, {1|U, {0xa654}}},
+ {0xa657, {1|U, {0xa656}}},
+ {0xa659, {1|U, {0xa658}}},
+ {0xa65b, {1|U, {0xa65a}}},
+ {0xa65d, {1|U, {0xa65c}}},
+ {0xa65f, {1|U, {0xa65e}}},
+ {0xa661, {1|U, {0xa660}}},
+ {0xa663, {1|U, {0xa662}}},
+ {0xa665, {1|U, {0xa664}}},
+ {0xa667, {1|U, {0xa666}}},
+ {0xa669, {1|U, {0xa668}}},
+ {0xa66b, {1|U, {0xa66a}}},
+ {0xa66d, {1|U, {0xa66c}}},
+ {0xa681, {1|U, {0xa680}}},
+ {0xa683, {1|U, {0xa682}}},
+ {0xa685, {1|U, {0xa684}}},
+ {0xa687, {1|U, {0xa686}}},
+ {0xa689, {1|U, {0xa688}}},
+ {0xa68b, {1|U, {0xa68a}}},
+ {0xa68d, {1|U, {0xa68c}}},
+ {0xa68f, {1|U, {0xa68e}}},
+ {0xa691, {1|U, {0xa690}}},
+ {0xa693, {1|U, {0xa692}}},
+ {0xa695, {1|U, {0xa694}}},
+ {0xa697, {1|U, {0xa696}}},
+ {0xa699, {1|U, {0xa698}}},
+ {0xa69b, {1|U, {0xa69a}}},
+ {0xa723, {1|U, {0xa722}}},
+ {0xa725, {1|U, {0xa724}}},
+ {0xa727, {1|U, {0xa726}}},
+ {0xa729, {1|U, {0xa728}}},
+ {0xa72b, {1|U, {0xa72a}}},
+ {0xa72d, {1|U, {0xa72c}}},
+ {0xa72f, {1|U, {0xa72e}}},
+ {0xa733, {1|U, {0xa732}}},
+ {0xa735, {1|U, {0xa734}}},
+ {0xa737, {1|U, {0xa736}}},
+ {0xa739, {1|U, {0xa738}}},
+ {0xa73b, {1|U, {0xa73a}}},
+ {0xa73d, {1|U, {0xa73c}}},
+ {0xa73f, {1|U, {0xa73e}}},
+ {0xa741, {1|U, {0xa740}}},
+ {0xa743, {1|U, {0xa742}}},
+ {0xa745, {1|U, {0xa744}}},
+ {0xa747, {1|U, {0xa746}}},
+ {0xa749, {1|U, {0xa748}}},
+ {0xa74b, {1|U, {0xa74a}}},
+ {0xa74d, {1|U, {0xa74c}}},
+ {0xa74f, {1|U, {0xa74e}}},
+ {0xa751, {1|U, {0xa750}}},
+ {0xa753, {1|U, {0xa752}}},
+ {0xa755, {1|U, {0xa754}}},
+ {0xa757, {1|U, {0xa756}}},
+ {0xa759, {1|U, {0xa758}}},
+ {0xa75b, {1|U, {0xa75a}}},
+ {0xa75d, {1|U, {0xa75c}}},
+ {0xa75f, {1|U, {0xa75e}}},
+ {0xa761, {1|U, {0xa760}}},
+ {0xa763, {1|U, {0xa762}}},
+ {0xa765, {1|U, {0xa764}}},
+ {0xa767, {1|U, {0xa766}}},
+ {0xa769, {1|U, {0xa768}}},
+ {0xa76b, {1|U, {0xa76a}}},
+ {0xa76d, {1|U, {0xa76c}}},
+ {0xa76f, {1|U, {0xa76e}}},
+ {0xa77a, {1|U, {0xa779}}},
+ {0xa77c, {1|U, {0xa77b}}},
+ {0xa77f, {1|U, {0xa77e}}},
+ {0xa781, {1|U, {0xa780}}},
+ {0xa783, {1|U, {0xa782}}},
+ {0xa785, {1|U, {0xa784}}},
+ {0xa787, {1|U, {0xa786}}},
+ {0xa78c, {1|U, {0xa78b}}},
+ {0xa791, {1|U, {0xa790}}},
+ {0xa793, {1|U, {0xa792}}},
+ {0xa794, {1|U, {0xa7c4}}},
+ {0xa797, {1|U, {0xa796}}},
+ {0xa799, {1|U, {0xa798}}},
+ {0xa79b, {1|U, {0xa79a}}},
+ {0xa79d, {1|U, {0xa79c}}},
+ {0xa79f, {1|U, {0xa79e}}},
+ {0xa7a1, {1|U, {0xa7a0}}},
+ {0xa7a3, {1|U, {0xa7a2}}},
+ {0xa7a5, {1|U, {0xa7a4}}},
+ {0xa7a7, {1|U, {0xa7a6}}},
+ {0xa7a9, {1|U, {0xa7a8}}},
+ {0xa7b5, {1|U, {0xa7b4}}},
+ {0xa7b7, {1|U, {0xa7b6}}},
+ {0xa7b9, {1|U, {0xa7b8}}},
+ {0xa7bb, {1|U, {0xa7ba}}},
+ {0xa7bd, {1|U, {0xa7bc}}},
+ {0xa7bf, {1|U, {0xa7be}}},
+ {0xa7c1, {1|U, {0xa7c0}}},
+ {0xa7c3, {1|U, {0xa7c2}}},
+ {0xa7c8, {1|U, {0xa7c7}}},
+ {0xa7ca, {1|U, {0xa7c9}}},
+ {0xa7cd, {1|U, {0xa7cc}}},
+ {0xa7cf, {1|U, {0xa7ce}}},
+ {0xa7d1, {1|U, {0xa7d0}}},
+ {0xa7d3, {1|U, {0xa7d2}}},
+ {0xa7d5, {1|U, {0xa7d4}}},
+ {0xa7d7, {1|U, {0xa7d6}}},
+ {0xa7d9, {1|U, {0xa7d8}}},
+ {0xa7db, {1|U, {0xa7da}}},
+ {0xa7f6, {1|U, {0xa7f5}}},
+ {0xab53, {1|U, {0xa7b3}}},
+ {0xff41, {1|U, {0xff21}}},
+ {0xff42, {1|U, {0xff22}}},
+ {0xff43, {1|U, {0xff23}}},
+ {0xff44, {1|U, {0xff24}}},
+ {0xff45, {1|U, {0xff25}}},
+ {0xff46, {1|U, {0xff26}}},
+ {0xff47, {1|U, {0xff27}}},
+ {0xff48, {1|U, {0xff28}}},
+ {0xff49, {1|U, {0xff29}}},
+ {0xff4a, {1|U, {0xff2a}}},
+ {0xff4b, {1|U, {0xff2b}}},
+ {0xff4c, {1|U, {0xff2c}}},
+ {0xff4d, {1|U, {0xff2d}}},
+ {0xff4e, {1|U, {0xff2e}}},
+ {0xff4f, {1|U, {0xff2f}}},
+ {0xff50, {1|U, {0xff30}}},
+ {0xff51, {1|U, {0xff31}}},
+ {0xff52, {1|U, {0xff32}}},
+ {0xff53, {1|U, {0xff33}}},
+ {0xff54, {1|U, {0xff34}}},
+ {0xff55, {1|U, {0xff35}}},
+ {0xff56, {1|U, {0xff36}}},
+ {0xff57, {1|U, {0xff37}}},
+ {0xff58, {1|U, {0xff38}}},
+ {0xff59, {1|U, {0xff39}}},
+ {0xff5a, {1|U, {0xff3a}}},
+ {0x10428, {1|U, {0x10400}}},
+ {0x10429, {1|U, {0x10401}}},
+ {0x1042a, {1|U, {0x10402}}},
+ {0x1042b, {1|U, {0x10403}}},
+ {0x1042c, {1|U, {0x10404}}},
+ {0x1042d, {1|U, {0x10405}}},
+ {0x1042e, {1|U, {0x10406}}},
+ {0x1042f, {1|U, {0x10407}}},
+ {0x10430, {1|U, {0x10408}}},
+ {0x10431, {1|U, {0x10409}}},
+ {0x10432, {1|U, {0x1040a}}},
+ {0x10433, {1|U, {0x1040b}}},
+ {0x10434, {1|U, {0x1040c}}},
+ {0x10435, {1|U, {0x1040d}}},
+ {0x10436, {1|U, {0x1040e}}},
+ {0x10437, {1|U, {0x1040f}}},
+ {0x10438, {1|U, {0x10410}}},
+ {0x10439, {1|U, {0x10411}}},
+ {0x1043a, {1|U, {0x10412}}},
+ {0x1043b, {1|U, {0x10413}}},
+ {0x1043c, {1|U, {0x10414}}},
+ {0x1043d, {1|U, {0x10415}}},
+ {0x1043e, {1|U, {0x10416}}},
+ {0x1043f, {1|U, {0x10417}}},
+ {0x10440, {1|U, {0x10418}}},
+ {0x10441, {1|U, {0x10419}}},
+ {0x10442, {1|U, {0x1041a}}},
+ {0x10443, {1|U, {0x1041b}}},
+ {0x10444, {1|U, {0x1041c}}},
+ {0x10445, {1|U, {0x1041d}}},
+ {0x10446, {1|U, {0x1041e}}},
+ {0x10447, {1|U, {0x1041f}}},
+ {0x10448, {1|U, {0x10420}}},
+ {0x10449, {1|U, {0x10421}}},
+ {0x1044a, {1|U, {0x10422}}},
+ {0x1044b, {1|U, {0x10423}}},
+ {0x1044c, {1|U, {0x10424}}},
+ {0x1044d, {1|U, {0x10425}}},
+ {0x1044e, {1|U, {0x10426}}},
+ {0x1044f, {1|U, {0x10427}}},
+ {0x104d8, {1|U, {0x104b0}}},
+ {0x104d9, {1|U, {0x104b1}}},
+ {0x104da, {1|U, {0x104b2}}},
+ {0x104db, {1|U, {0x104b3}}},
+ {0x104dc, {1|U, {0x104b4}}},
+ {0x104dd, {1|U, {0x104b5}}},
+ {0x104de, {1|U, {0x104b6}}},
+ {0x104df, {1|U, {0x104b7}}},
+ {0x104e0, {1|U, {0x104b8}}},
+ {0x104e1, {1|U, {0x104b9}}},
+ {0x104e2, {1|U, {0x104ba}}},
+ {0x104e3, {1|U, {0x104bb}}},
+ {0x104e4, {1|U, {0x104bc}}},
+ {0x104e5, {1|U, {0x104bd}}},
+ {0x104e6, {1|U, {0x104be}}},
+ {0x104e7, {1|U, {0x104bf}}},
+ {0x104e8, {1|U, {0x104c0}}},
+ {0x104e9, {1|U, {0x104c1}}},
+ {0x104ea, {1|U, {0x104c2}}},
+ {0x104eb, {1|U, {0x104c3}}},
+ {0x104ec, {1|U, {0x104c4}}},
+ {0x104ed, {1|U, {0x104c5}}},
+ {0x104ee, {1|U, {0x104c6}}},
+ {0x104ef, {1|U, {0x104c7}}},
+ {0x104f0, {1|U, {0x104c8}}},
+ {0x104f1, {1|U, {0x104c9}}},
+ {0x104f2, {1|U, {0x104ca}}},
+ {0x104f3, {1|U, {0x104cb}}},
+ {0x104f4, {1|U, {0x104cc}}},
+ {0x104f5, {1|U, {0x104cd}}},
+ {0x104f6, {1|U, {0x104ce}}},
+ {0x104f7, {1|U, {0x104cf}}},
+ {0x104f8, {1|U, {0x104d0}}},
+ {0x104f9, {1|U, {0x104d1}}},
+ {0x104fa, {1|U, {0x104d2}}},
+ {0x104fb, {1|U, {0x104d3}}},
+ {0x10597, {1|U, {0x10570}}},
+ {0x10598, {1|U, {0x10571}}},
+ {0x10599, {1|U, {0x10572}}},
+ {0x1059a, {1|U, {0x10573}}},
+ {0x1059b, {1|U, {0x10574}}},
+ {0x1059c, {1|U, {0x10575}}},
+ {0x1059d, {1|U, {0x10576}}},
+ {0x1059e, {1|U, {0x10577}}},
+ {0x1059f, {1|U, {0x10578}}},
+ {0x105a0, {1|U, {0x10579}}},
+ {0x105a1, {1|U, {0x1057a}}},
+ {0x105a3, {1|U, {0x1057c}}},
+ {0x105a4, {1|U, {0x1057d}}},
+ {0x105a5, {1|U, {0x1057e}}},
+ {0x105a6, {1|U, {0x1057f}}},
+ {0x105a7, {1|U, {0x10580}}},
+ {0x105a8, {1|U, {0x10581}}},
+ {0x105a9, {1|U, {0x10582}}},
+ {0x105aa, {1|U, {0x10583}}},
+ {0x105ab, {1|U, {0x10584}}},
+ {0x105ac, {1|U, {0x10585}}},
+ {0x105ad, {1|U, {0x10586}}},
+ {0x105ae, {1|U, {0x10587}}},
+ {0x105af, {1|U, {0x10588}}},
+ {0x105b0, {1|U, {0x10589}}},
+ {0x105b1, {1|U, {0x1058a}}},
+ {0x105b3, {1|U, {0x1058c}}},
+ {0x105b4, {1|U, {0x1058d}}},
+ {0x105b5, {1|U, {0x1058e}}},
+ {0x105b6, {1|U, {0x1058f}}},
+ {0x105b7, {1|U, {0x10590}}},
+ {0x105b8, {1|U, {0x10591}}},
+ {0x105b9, {1|U, {0x10592}}},
+ {0x105bb, {1|U, {0x10594}}},
+ {0x105bc, {1|U, {0x10595}}},
+ {0x10cc0, {1|U, {0x10c80}}},
+ {0x10cc1, {1|U, {0x10c81}}},
+ {0x10cc2, {1|U, {0x10c82}}},
+ {0x10cc3, {1|U, {0x10c83}}},
+ {0x10cc4, {1|U, {0x10c84}}},
+ {0x10cc5, {1|U, {0x10c85}}},
+ {0x10cc6, {1|U, {0x10c86}}},
+ {0x10cc7, {1|U, {0x10c87}}},
+ {0x10cc8, {1|U, {0x10c88}}},
+ {0x10cc9, {1|U, {0x10c89}}},
+ {0x10cca, {1|U, {0x10c8a}}},
+ {0x10ccb, {1|U, {0x10c8b}}},
+ {0x10ccc, {1|U, {0x10c8c}}},
+ {0x10ccd, {1|U, {0x10c8d}}},
+ {0x10cce, {1|U, {0x10c8e}}},
+ {0x10ccf, {1|U, {0x10c8f}}},
+ {0x10cd0, {1|U, {0x10c90}}},
+ {0x10cd1, {1|U, {0x10c91}}},
+ {0x10cd2, {1|U, {0x10c92}}},
+ {0x10cd3, {1|U, {0x10c93}}},
+ {0x10cd4, {1|U, {0x10c94}}},
+ {0x10cd5, {1|U, {0x10c95}}},
+ {0x10cd6, {1|U, {0x10c96}}},
+ {0x10cd7, {1|U, {0x10c97}}},
+ {0x10cd8, {1|U, {0x10c98}}},
+ {0x10cd9, {1|U, {0x10c99}}},
+ {0x10cda, {1|U, {0x10c9a}}},
+ {0x10cdb, {1|U, {0x10c9b}}},
+ {0x10cdc, {1|U, {0x10c9c}}},
+ {0x10cdd, {1|U, {0x10c9d}}},
+ {0x10cde, {1|U, {0x10c9e}}},
+ {0x10cdf, {1|U, {0x10c9f}}},
+ {0x10ce0, {1|U, {0x10ca0}}},
+ {0x10ce1, {1|U, {0x10ca1}}},
+ {0x10ce2, {1|U, {0x10ca2}}},
+ {0x10ce3, {1|U, {0x10ca3}}},
+ {0x10ce4, {1|U, {0x10ca4}}},
+ {0x10ce5, {1|U, {0x10ca5}}},
+ {0x10ce6, {1|U, {0x10ca6}}},
+ {0x10ce7, {1|U, {0x10ca7}}},
+ {0x10ce8, {1|U, {0x10ca8}}},
+ {0x10ce9, {1|U, {0x10ca9}}},
+ {0x10cea, {1|U, {0x10caa}}},
+ {0x10ceb, {1|U, {0x10cab}}},
+ {0x10cec, {1|U, {0x10cac}}},
+ {0x10ced, {1|U, {0x10cad}}},
+ {0x10cee, {1|U, {0x10cae}}},
+ {0x10cef, {1|U, {0x10caf}}},
+ {0x10cf0, {1|U, {0x10cb0}}},
+ {0x10cf1, {1|U, {0x10cb1}}},
+ {0x10cf2, {1|U, {0x10cb2}}},
+ {0x10d70, {1|U, {0x10d50}}},
+ {0x10d71, {1|U, {0x10d51}}},
+ {0x10d72, {1|U, {0x10d52}}},
+ {0x10d73, {1|U, {0x10d53}}},
+ {0x10d74, {1|U, {0x10d54}}},
+ {0x10d75, {1|U, {0x10d55}}},
+ {0x10d76, {1|U, {0x10d56}}},
+ {0x10d77, {1|U, {0x10d57}}},
+ {0x10d78, {1|U, {0x10d58}}},
+ {0x10d79, {1|U, {0x10d59}}},
+ {0x10d7a, {1|U, {0x10d5a}}},
+ {0x10d7b, {1|U, {0x10d5b}}},
+ {0x10d7c, {1|U, {0x10d5c}}},
+ {0x10d7d, {1|U, {0x10d5d}}},
+ {0x10d7e, {1|U, {0x10d5e}}},
+ {0x10d7f, {1|U, {0x10d5f}}},
+ {0x10d80, {1|U, {0x10d60}}},
+ {0x10d81, {1|U, {0x10d61}}},
+ {0x10d82, {1|U, {0x10d62}}},
+ {0x10d83, {1|U, {0x10d63}}},
+ {0x10d84, {1|U, {0x10d64}}},
+ {0x10d85, {1|U, {0x10d65}}},
+ {0x118c0, {1|U, {0x118a0}}},
+ {0x118c1, {1|U, {0x118a1}}},
+ {0x118c2, {1|U, {0x118a2}}},
+ {0x118c3, {1|U, {0x118a3}}},
+ {0x118c4, {1|U, {0x118a4}}},
+ {0x118c5, {1|U, {0x118a5}}},
+ {0x118c6, {1|U, {0x118a6}}},
+ {0x118c7, {1|U, {0x118a7}}},
+ {0x118c8, {1|U, {0x118a8}}},
+ {0x118c9, {1|U, {0x118a9}}},
+ {0x118ca, {1|U, {0x118aa}}},
+ {0x118cb, {1|U, {0x118ab}}},
+ {0x118cc, {1|U, {0x118ac}}},
+ {0x118cd, {1|U, {0x118ad}}},
+ {0x118ce, {1|U, {0x118ae}}},
+ {0x118cf, {1|U, {0x118af}}},
+ {0x118d0, {1|U, {0x118b0}}},
+ {0x118d1, {1|U, {0x118b1}}},
+ {0x118d2, {1|U, {0x118b2}}},
+ {0x118d3, {1|U, {0x118b3}}},
+ {0x118d4, {1|U, {0x118b4}}},
+ {0x118d5, {1|U, {0x118b5}}},
+ {0x118d6, {1|U, {0x118b6}}},
+ {0x118d7, {1|U, {0x118b7}}},
+ {0x118d8, {1|U, {0x118b8}}},
+ {0x118d9, {1|U, {0x118b9}}},
+ {0x118da, {1|U, {0x118ba}}},
+ {0x118db, {1|U, {0x118bb}}},
+ {0x118dc, {1|U, {0x118bc}}},
+ {0x118dd, {1|U, {0x118bd}}},
+ {0x118de, {1|U, {0x118be}}},
+ {0x118df, {1|U, {0x118bf}}},
+ {0x16e60, {1|U, {0x16e40}}},
+ {0x16e61, {1|U, {0x16e41}}},
+ {0x16e62, {1|U, {0x16e42}}},
+ {0x16e63, {1|U, {0x16e43}}},
+ {0x16e64, {1|U, {0x16e44}}},
+ {0x16e65, {1|U, {0x16e45}}},
+ {0x16e66, {1|U, {0x16e46}}},
+ {0x16e67, {1|U, {0x16e47}}},
+ {0x16e68, {1|U, {0x16e48}}},
+ {0x16e69, {1|U, {0x16e49}}},
+ {0x16e6a, {1|U, {0x16e4a}}},
+ {0x16e6b, {1|U, {0x16e4b}}},
+ {0x16e6c, {1|U, {0x16e4c}}},
+ {0x16e6d, {1|U, {0x16e4d}}},
+ {0x16e6e, {1|U, {0x16e4e}}},
+ {0x16e6f, {1|U, {0x16e4f}}},
+ {0x16e70, {1|U, {0x16e50}}},
+ {0x16e71, {1|U, {0x16e51}}},
+ {0x16e72, {1|U, {0x16e52}}},
+ {0x16e73, {1|U, {0x16e53}}},
+ {0x16e74, {1|U, {0x16e54}}},
+ {0x16e75, {1|U, {0x16e55}}},
+ {0x16e76, {1|U, {0x16e56}}},
+ {0x16e77, {1|U, {0x16e57}}},
+ {0x16e78, {1|U, {0x16e58}}},
+ {0x16e79, {1|U, {0x16e59}}},
+ {0x16e7a, {1|U, {0x16e5a}}},
+ {0x16e7b, {1|U, {0x16e5b}}},
+ {0x16e7c, {1|U, {0x16e5c}}},
+ {0x16e7d, {1|U, {0x16e5d}}},
+ {0x16e7e, {1|U, {0x16e5e}}},
+ {0x16e7f, {1|U, {0x16e5f}}},
+ {0x16ebb, {1|U, {0x16ea0}}},
+ {0x16ebc, {1|U, {0x16ea1}}},
+ {0x16ebd, {1|U, {0x16ea2}}},
+ {0x16ebe, {1|U, {0x16ea3}}},
+ {0x16ebf, {1|U, {0x16ea4}}},
+ {0x16ec0, {1|U, {0x16ea5}}},
+ {0x16ec1, {1|U, {0x16ea6}}},
+ {0x16ec2, {1|U, {0x16ea7}}},
+ {0x16ec3, {1|U, {0x16ea8}}},
+ {0x16ec4, {1|U, {0x16ea9}}},
+ {0x16ec5, {1|U, {0x16eaa}}},
+ {0x16ec6, {1|U, {0x16eab}}},
+ {0x16ec7, {1|U, {0x16eac}}},
+ {0x16ec8, {1|U, {0x16ead}}},
+ {0x16ec9, {1|U, {0x16eae}}},
+ {0x16eca, {1|U, {0x16eaf}}},
+ {0x16ecb, {1|U, {0x16eb0}}},
+ {0x16ecc, {1|U, {0x16eb1}}},
+ {0x16ecd, {1|U, {0x16eb2}}},
+ {0x16ece, {1|U, {0x16eb3}}},
+ {0x16ecf, {1|U, {0x16eb4}}},
+ {0x16ed0, {1|U, {0x16eb5}}},
+ {0x16ed1, {1|U, {0x16eb6}}},
+ {0x16ed2, {1|U, {0x16eb7}}},
+ {0x16ed3, {1|U, {0x16eb8}}},
+ {0x1e922, {1|U, {0x1e900}}},
+ {0x1e923, {1|U, {0x1e901}}},
+ {0x1e924, {1|U, {0x1e902}}},
+ {0x1e925, {1|U, {0x1e903}}},
+ {0x1e926, {1|U, {0x1e904}}},
+ {0x1e927, {1|U, {0x1e905}}},
+ {0x1e928, {1|U, {0x1e906}}},
+ {0x1e929, {1|U, {0x1e907}}},
+ {0x1e92a, {1|U, {0x1e908}}},
+ {0x1e92b, {1|U, {0x1e909}}},
+ {0x1e92c, {1|U, {0x1e90a}}},
+ {0x1e92d, {1|U, {0x1e90b}}},
+ {0x1e92e, {1|U, {0x1e90c}}},
+ {0x1e92f, {1|U, {0x1e90d}}},
+ {0x1e930, {1|U, {0x1e90e}}},
+ {0x1e931, {1|U, {0x1e90f}}},
+ {0x1e932, {1|U, {0x1e910}}},
+ {0x1e933, {1|U, {0x1e911}}},
+ {0x1e934, {1|U, {0x1e912}}},
+ {0x1e935, {1|U, {0x1e913}}},
+ {0x1e936, {1|U, {0x1e914}}},
+ {0x1e937, {1|U, {0x1e915}}},
+ {0x1e938, {1|U, {0x1e916}}},
+ {0x1e939, {1|U, {0x1e917}}},
+ {0x1e93a, {1|U, {0x1e918}}},
+ {0x1e93b, {1|U, {0x1e919}}},
+ {0x1e93c, {1|U, {0x1e91a}}},
+ {0x1e93d, {1|U, {0x1e91b}}},
+ {0x1e93e, {1|U, {0x1e91c}}},
+ {0x1e93f, {1|U, {0x1e91d}}},
+ {0x1e940, {1|U, {0x1e91e}}},
+ {0x1e941, {1|U, {0x1e91f}}},
+ {0x1e942, {1|U, {0x1e920}}},
+ {0x1e943, {1|U, {0x1e921}}},
+#define CaseUnfold_11_Locale (*(CaseUnfold_11_Type (*)[1])(CaseUnfold_11_Table+1450))
+ {0x0069, {1|U, {0x0049}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_11_hash -N onigenc_unicode_CaseUnfold_11_lookup -n */
+
+/* maximum key range = 2881, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_11_hash(const OnigCodePoint code)
+{
+ static const unsigned short asso_values[] =
+ {
+ 1, 2884, 2, 29, 4, 134, 9, 131, 10, 229,
+ 121, 246, 2, 3, 540, 359, 2884, 2884, 2884, 2884,
+ 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 103,
+ 401, 111, 2884, 2884, 2884, 2884, 2884, 127, 2884, 2884,
+ 2884, 2884, 2884, 1, 2884, 2884, 2884, 2884, 2884, 2884,
+ 2884, 2884, 2884, 339, 2884, 2884, 2884, 2884, 2884, 2884,
+ 2884, 15, 9, 1, 7, 8, 341, 797, 60, 1080,
+ 101, 804, 35, 1589, 7, 1841, 17, 16, 58, 1709,
+ 216, 1040, 47, 103, 64, 1339, 219, 1539, 4, 1704,
+ 52, 1508, 344, 11, 501, 1733, 526, 347, 133, 1161,
+ 340, 913, 104, 883, 170, 743, 339, 1103, 398, 1465,
+ 376, 829, 138, 1092, 280, 967, 1876, 785, 1694, 774,
+ 1640, 721, 1852, 951, 1830, 937, 1573, 925, 1736, 666,
+ 897, 502, 693, 475, 1385, 651, 1356, 639, 1184, 532,
+ 1532, 520, 1479, 420, 1225, 203, 1248, 82, 1277, 115,
+ 1758, 289, 1673, 93, 1686, 71, 1666, 60, 1650, 256,
+ 1789, 232, 1552, 1, 1649, 27, 1489, 38, 1247, 144,
+ 1445, 49, 1624, 221, 1418, 327, 1769, 312, 1306, 584,
+ 1075, 363, 1506, 609, 1405, 1213, 1074, 1065, 1362, 1151,
+ 1556, 863, 726, 1429
+ };
+ return asso_values[bits_of(code, 2)+66] + asso_values[bits_of(code, 1)+4] + asso_values[bits_of(code, 0)];
+}
+
+static const CodePointList3 *
+onigenc_unicode_CaseUnfold_11_lookup(const OnigCodePoint code)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x61,
+ MAX_CODE_VALUE = 0x1e943,
+ TOTAL_KEYWORDS = 1451,
+ MIN_WORD_LENGTH = 3,
+ MAX_WORD_LENGTH = 3,
+ MIN_HASH_VALUE = 3,
+ MAX_HASH_VALUE = 2883
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1,
+ /*0x13e1*/ 591,
+ /*0x0461*/ 342,
+ /*0x04e1*/ 402,
+ /*0x0061*/ 0,
+ -1,
+ /*0x104e1*/ 1192,
+ /*0x1e61*/ 664,
+ /*0x1ee1*/ 723,
+ /*0x0161*/ 102,
+ /*0x0261*/ 211,
+ /*0x2ce1*/ 956,
+ -1,
+ /*0x049b*/ 367,
+ -1, -1,
+ /*0x24e1*/ 843,
+ /*0x1e1b*/ 629,
+ /*0x048b*/ 359,
+ /*0x011b*/ 69,
+ /*0x021b*/ 179,
+ /*0x2c9b*/ 921,
+ /*0x1e0b*/ 621,
+ /*0x1e8b*/ 685,
+ /*0x010b*/ 61,
+ /*0x020b*/ 171,
+ /*0x2c8b*/ 913,
+ /*0x13e3*/ 593,
+ /*0x0463*/ 343,
+ /*0x04e3*/ 403,
+ /*0x0063*/ 2,
+ /*0x1c8a*/ 612,
+ /*0x104e3*/ 1194,
+ /*0x1e63*/ 665,
+ /*0x1ee3*/ 724,
+ /*0x0163*/ 103,
+ /*0x0263*/ 212,
+ /*0x2ce3*/ 957,
+ /*0x13e5*/ 595,
+ /*0x0465*/ 344,
+ /*0x04e5*/ 404,
+ /*0x0065*/ 4,
+ /*0x24e3*/ 845,
+ /*0x104e5*/ 1196,
+ /*0x1e65*/ 666,
+ /*0x1ee5*/ 725,
+ /*0x0165*/ 104,
+ /*0x0265*/ 214,
+ /*0xa761*/ 1068,
+ /*0x13e9*/ 599,
+ /*0x0469*/ 346,
+ /*0x04e9*/ 406,
+ /*0x0069*/ 1450,
+ /*0x24e5*/ 847,
+ /*0x104e9*/ 1200,
+ /*0x1e69*/ 668,
+ /*0x1ee9*/ 727,
+ /*0x0169*/ 106,
+ /*0x0269*/ 217,
+ -1,
+ /*0x13db*/ 585,
+ /*0x045b*/ 337,
+ /*0x04db*/ 399,
+ -1,
+ /*0x24e9*/ 851,
+ /*0x104db*/ 1186,
+ /*0x1e5b*/ 661,
+ /*0x1edb*/ 720,
+ /*0x015b*/ 99,
+ /*0x025b*/ 208,
+ /*0x2cdb*/ 953,
+ /*0x13d9*/ 583,
+ /*0x0459*/ 335,
+ /*0x04d9*/ 398,
+ /*0xa763*/ 1069,
+ /*0x24db*/ 837,
+ /*0x104d9*/ 1184,
+ /*0x1e59*/ 660,
+ /*0x1ed9*/ 719,
+ /*0x0159*/ 98,
+ /*0x0259*/ 207,
+ /*0x2cd9*/ 952,
+ /*0x13d1*/ 575,
+ /*0x0451*/ 327,
+ /*0x04d1*/ 394,
+ /*0xa765*/ 1070,
+ /*0x24d9*/ 835,
+ -1,
+ /*0x1e51*/ 656,
+ /*0x1ed1*/ 715,
+ /*0x0151*/ 94,
+ /*0x0251*/ 201,
+ /*0x2cd1*/ 948,
+ /*0x13d7*/ 581,
+ /*0x0457*/ 333,
+ /*0x04d7*/ 397,
+ /*0xa769*/ 1072,
+ /*0x24d1*/ 827,
+ -1,
+ /*0x1e57*/ 659,
+ /*0x1ed7*/ 718,
+ /*0x0157*/ 97,
+ /*0x0257*/ 206,
+ /*0x2cd7*/ 951,
+ /*0x13a4*/ 530,
+ /*0x0491*/ 362,
+ /*0x10ce1*/ 1287,
+ /*0xa75b*/ 1065,
+ /*0x24d7*/ 833,
+ /*0x1e11*/ 624,
+ /*0x1e91*/ 688,
+ /*0x0111*/ 64,
+ /*0x0211*/ 174,
+ /*0x2c91*/ 916,
+ /*0xa79b*/ 1089,
+ /*0x13d3*/ 577,
+ /*0x0453*/ 329,
+ /*0x04d3*/ 395,
+ /*0xa759*/ 1064,
+ -1, -1,
+ /*0x1e53*/ 657,
+ /*0x1ed3*/ 716,
+ /*0x0153*/ 95,
+ /*0x0253*/ 203,
+ /*0x2cd3*/ 949,
+ -1,
+ /*0x10e1*/ 497,
+ -1,
+ /*0xa751*/ 1060,
+ /*0x24d3*/ 829,
+ /*0x01e1*/ 152,
+ /*0x10ce3*/ 1289,
+ /*0x13a0*/ 526,
+ /*0x00e1*/ 26,
+ -1, -1,
+ /*0x0188*/ 120,
+ /*0x13ae*/ 540,
+ -1,
+ /*0xa757*/ 1063,
+ /*0x019b*/ 126,
+ /*0x1042e*/ 1149,
+ /*0x10ce5*/ 1291,
+ /*0x13e7*/ 597,
+ /*0x0467*/ 345,
+ /*0x04e7*/ 405,
+ /*0x0067*/ 6,
+ -1,
+ /*0x104e7*/ 1198,
+ /*0x1e67*/ 667,
+ /*0x1ee7*/ 726,
+ /*0x0167*/ 105,
+ /*0x10e3*/ 499,
+ /*0x10ce9*/ 1295,
+ -1, -1,
+ /*0x01e3*/ 153,
+ -1,
+ /*0x24e7*/ 849,
+ /*0x00e3*/ 28,
+ /*0xa78c*/ 1083,
+ /*0xa753*/ 1061,
+ /*0xa7db*/ 1114,
+ /*0x10e5*/ 501,
+ /*0x10cdb*/ 1281,
+ -1,
+ /*0xab53*/ 1116,
+ /*0x01e5*/ 154,
+ -1,
+ /*0x13a6*/ 532,
+ /*0x00e5*/ 30,
+ -1,
+ /*0x10d82*/ 1323,
+ /*0xa7d9*/ 1113,
+ /*0x10e9*/ 505,
+ /*0x10cd9*/ 1279,
+ -1, -1,
+ /*0x01e9*/ 156,
+ -1, -1,
+ /*0x00e9*/ 34,
+ -1, -1,
+ /*0xa7d1*/ 1109,
+ /*0x10db*/ 491,
+ /*0x10cd1*/ 1271,
+ /*0x018c*/ 121,
+ -1, -1,
+ /*0xa767*/ 1071,
+ -1, -1,
+ /*0x0192*/ 122,
+ -1,
+ /*0xa7d7*/ 1112,
+ /*0x10d9*/ 489,
+ /*0x10cd7*/ 1277,
+ -1, -1, -1, -1,
+ /*0x13cf*/ 573,
+ /*0x044f*/ 325,
+ /*0x04cf*/ 393,
+ /*0xa791*/ 1084,
+ /*0x1044f*/ 1182,
+ /*0x10d1*/ 481,
+ /*0x1e4f*/ 655,
+ /*0x1ecf*/ 714,
+ /*0x014f*/ 93,
+ /*0x024f*/ 199,
+ /*0x2ccf*/ 947,
+ /*0x10d84*/ 1325,
+ -1,
+ /*0x1d8e*/ 615,
+ /*0xa661*/ 1017,
+ /*0xa7d3*/ 1110,
+ /*0x10d7*/ 487,
+ /*0x10cd3*/ 1273,
+ /*0x13eb*/ 601,
+ /*0x046b*/ 347,
+ /*0x04eb*/ 407,
+ /*0x006b*/ 9,
+ -1,
+ /*0x104eb*/ 1202,
+ /*0x1e6b*/ 669,
+ /*0x1eeb*/ 728,
+ /*0x016b*/ 107,
+ /*0x026b*/ 219,
+ -1,
+ /*0x13df*/ 589,
+ /*0x045f*/ 341,
+ /*0x04df*/ 401,
+ /*0x0288*/ 230,
+ -1,
+ /*0x104df*/ 1190,
+ /*0x1e5f*/ 663,
+ /*0x1edf*/ 722,
+ /*0x015f*/ 101,
+ /*0x10d3*/ 483,
+ /*0x2cdf*/ 955,
+ /*0xa663*/ 1018,
+ /*0x028b*/ 233,
+ /*0x028a*/ 232,
+ /*0x03e1*/ 282,
+ /*0x24df*/ 841,
+ -1,
+ /*0x10ce7*/ 1293,
+ /*0xa74f*/ 1059,
+ -1, -1, -1,
+ /*0xa665*/ 1019,
+ -1,
+ /*0x13dd*/ 587,
+ /*0x045d*/ 339,
+ /*0x04dd*/ 400,
+ -1, -1,
+ /*0x104dd*/ 1188,
+ /*0x1e5d*/ 662,
+ /*0x1edd*/ 721,
+ /*0x015d*/ 100,
+ /*0xa669*/ 1021,
+ /*0x2cdd*/ 954,
+ -1,
+ /*0xa76b*/ 1073,
+ -1,
+ /*0x10e7*/ 503,
+ /*0x24dd*/ 839,
+ /*0x03e3*/ 283,
+ -1,
+ /*0x01e7*/ 155,
+ -1,
+ /*0xa65b*/ 1014,
+ /*0x00e7*/ 32,
+ -1,
+ /*0xa75f*/ 1067,
+ /*0x13b0*/ 542,
+ /*0x0430*/ 294,
+ -1,
+ /*0x03e5*/ 284,
+ /*0x10430*/ 1151,
+ -1,
+ /*0x028c*/ 234,
+ /*0xa659*/ 1013,
+ /*0x0282*/ 227,
+ /*0x13d5*/ 579,
+ /*0x0455*/ 331,
+ /*0x04d5*/ 396,
+ /*0x0292*/ 235,
+ -1,
+ /*0x03e9*/ 286,
+ /*0x1e55*/ 658,
+ /*0x1ed5*/ 717,
+ /*0x0155*/ 96,
+ /*0xa651*/ 1009,
+ /*0x2cd5*/ 950,
+ -1, -1, -1,
+ /*0xa75d*/ 1066,
+ /*0x24d5*/ 831,
+ /*0x03db*/ 279,
+ /*0xa7cf*/ 1108,
+ -1,
+ /*0x10ccf*/ 1269,
+ /*0xa657*/ 1012,
+ -1, -1,
+ /*0x13ef*/ 605,
+ /*0x046f*/ 349,
+ /*0x04ef*/ 409,
+ /*0x006f*/ 13,
+ /*0x03d9*/ 278,
+ /*0x104ef*/ 1206,
+ /*0x1e6f*/ 671,
+ /*0x1eef*/ 730,
+ /*0x016f*/ 109,
+ /*0x026f*/ 221,
+ /*0xa794*/ 1086,
+ -1, -1, -1,
+ /*0x10ceb*/ 1297,
+ /*0x13ed*/ 603,
+ /*0x046d*/ 348,
+ /*0x04ed*/ 408,
+ /*0x006d*/ 11,
+ /*0xa653*/ 1010,
+ /*0x104ed*/ 1204,
+ /*0x1e6d*/ 670,
+ /*0x1eed*/ 729,
+ /*0x016d*/ 108,
+ /*0xa755*/ 1062,
+ /*0x10cdf*/ 1285,
+ /*0x03d7*/ 277,
+ /*0x13a8*/ 534,
+ /*0x13a2*/ 528,
+ /*0x1f61*/ 780,
+ -1,
+ /*0x10428*/ 1143,
+ /*0x2c61*/ 900,
+ -1, -1,
+ /*0x10eb*/ 507,
+ -1,
+ /*0x049f*/ 369,
+ -1,
+ /*0x01eb*/ 157,
+ -1,
+ /*0x1e1f*/ 631,
+ /*0x00eb*/ 36,
+ /*0x011f*/ 71,
+ /*0x021f*/ 181,
+ /*0x2c9f*/ 923,
+ /*0x10df*/ 495,
+ /*0xa76f*/ 1075,
+ /*0xa667*/ 1020,
+ /*0x10cdd*/ 1283,
+ /*0x01df*/ 151,
+ /*0x13f3*/ 609,
+ /*0x0473*/ 351,
+ /*0x04f3*/ 411,
+ /*0x0073*/ 17,
+ /*0x1f63*/ 782,
+ /*0x104f3*/ 1210,
+ /*0x1e73*/ 673,
+ /*0x1ef3*/ 732,
+ /*0x0173*/ 111,
+ /*0x1059b*/ 1223,
+ /*0x2cf3*/ 960,
+ /*0xa76d*/ 1074,
+ /*0x1f06*/ 745,
+ /*0x13ac*/ 538,
+ -1,
+ /*0x1f65*/ 784,
+ -1,
+ /*0x1042c*/ 1147,
+ /*0x2c65*/ 901,
+ /*0x10dd*/ 493,
+ /*0x03ae*/ 246,
+ -1, -1,
+ /*0x01dd*/ 150,
+ /*0x1f10*/ 747,
+ -1,
+ /*0x03e7*/ 285,
+ -1, -1,
+ /*0xa7d5*/ 1111,
+ /*0x0586*/ 479,
+ /*0x10cd5*/ 1275,
+ -1, -1, -1,
+ /*0x13aa*/ 536,
+ -1,
+ /*0x1f02*/ 741,
+ /*0x118db*/ 1354,
+ /*0x1042a*/ 1145,
+ /*0x2c5b*/ 895,
+ /*0x1f12*/ 749,
+ -1, -1, -1, -1, -1,
+ /*0x01b0*/ 133,
+ -1,
+ /*0x118d9*/ 1352,
+ /*0x10598*/ 1220,
+ /*0x2c59*/ 893,
+ /*0x10d5*/ 485,
+ -1,
+ /*0x10cef*/ 1301,
+ /*0x0582*/ 475,
+ /*0xa64f*/ 1008,
+ /*0x13cd*/ 571,
+ /*0x044d*/ 323,
+ /*0x1f51*/ 775,
+ /*0x118d1*/ 1344,
+ /*0x1044d*/ 1180,
+ /*0x2c51*/ 885,
+ /*0x1e4d*/ 654,
+ /*0x1ecd*/ 713,
+ /*0x014d*/ 92,
+ /*0x024d*/ 198,
+ /*0x2ccd*/ 946,
+ -1,
+ /*0x10ced*/ 1299,
+ /*0x1f57*/ 778,
+ /*0x118d7*/ 1350,
+ -1,
+ /*0x2c57*/ 891,
+ /*0xa66b*/ 1022,
+ /*0x10ef*/ 511,
+ -1, -1,
+ /*0x1f04*/ 743,
+ /*0x01ef*/ 159,
+ /*0x1f11*/ 748,
+ /*0x1f24*/ 757,
+ /*0x00ef*/ 40,
+ -1, -1,
+ /*0xa65f*/ 1016,
+ -1,
+ /*0xa79f*/ 1091,
+ -1,
+ /*0x1e924*/ 1418,
+ /*0x10ed*/ 509,
+ /*0x10d80*/ 1321,
+ /*0x1f53*/ 776,
+ /*0x118d3*/ 1346,
+ /*0x01ed*/ 158,
+ /*0x2c53*/ 887,
+ /*0x0584*/ 477,
+ /*0x00ed*/ 38,
+ -1, -1,
+ /*0x2173*/ 812,
+ -1,
+ /*0x105a4*/ 1231,
+ /*0x03eb*/ 287,
+ /*0xa74d*/ 1058,
+ -1,
+ /*0x01a8*/ 131,
+ -1,
+ /*0x0180*/ 117,
+ /*0xa65d*/ 1015,
+ /*0x1f20*/ 753,
+ /*0x019a*/ 125,
+ /*0x13c3*/ 561,
+ /*0x0443*/ 313,
+ /*0x03df*/ 281,
+ -1,
+ /*0x10443*/ 1170,
+ -1,
+ /*0x1e43*/ 649,
+ /*0x1ec3*/ 708,
+ /*0x0373*/ 239,
+ /*0x1f67*/ 786,
+ /*0x2cc3*/ 941,
+ /*0x1e92e*/ 1428,
+ -1, -1,
+ /*0x10f3*/ 515,
+ -1, -1, -1,
+ /*0x01f3*/ 160,
+ /*0x105a0*/ 1228,
+ -1,
+ /*0x00f3*/ 44,
+ -1, -1,
+ /*0x105ae*/ 1241,
+ -1,
+ /*0x03dd*/ 280,
+ /*0x13c1*/ 559,
+ /*0x0441*/ 311,
+ /*0x2d16*/ 983,
+ /*0xa655*/ 1011,
+ /*0x10441*/ 1168,
+ /*0x2d08*/ 969,
+ /*0x1e41*/ 648,
+ /*0x1ec1*/ 707,
+ /*0x1f26*/ 759,
+ /*0x2d1b*/ 988,
+ /*0x2cc1*/ 940,
+ -1, -1, -1,
+ /*0x2d0b*/ 972,
+ /*0x2d0a*/ 971,
+ /*0x1e926*/ 1420,
+ -1,
+ /*0x13cb*/ 569,
+ /*0x044b*/ 321,
+ /*0xa743*/ 1053,
+ /*0xa7cd*/ 1107,
+ /*0x1044b*/ 1178,
+ /*0x10ccd*/ 1267,
+ /*0x1e4b*/ 653,
+ /*0x1ecb*/ 712,
+ /*0x014b*/ 91,
+ /*0x024b*/ 197,
+ /*0x2ccb*/ 945,
+ /*0x105a6*/ 1233,
+ /*0x13c9*/ 567,
+ /*0x0449*/ 319,
+ -1,
+ /*0x2d06*/ 967,
+ /*0x10449*/ 1176,
+ -1,
+ /*0x1e49*/ 652,
+ /*0x1ec9*/ 711,
+ /*0x0561*/ 442,
+ /*0x0249*/ 196,
+ /*0x2cc9*/ 944,
+ /*0xa66d*/ 1023,
+ /*0x118cf*/ 1342,
+ -1,
+ /*0x2c4f*/ 883,
+ /*0x2d10*/ 977,
+ -1,
+ /*0xa741*/ 1052,
+ /*0x051b*/ 431,
+ -1,
+ /*0x2d18*/ 985,
+ -1, -1,
+ /*0x050b*/ 423,
+ -1,
+ /*0x03ef*/ 289,
+ /*0x2d0c*/ 973,
+ /*0x1f14*/ 751,
+ /*0x2d02*/ 963,
+ /*0x16ed1*/ 1413,
+ -1, -1,
+ /*0x2d12*/ 979,
+ -1,
+ /*0x0563*/ 444,
+ /*0xa74b*/ 1057,
+ -1,
+ /*0x0280*/ 226,
+ -1, -1,
+ /*0x03ed*/ 288,
+ /*0x118df*/ 1358,
+ -1,
+ /*0x2c5f*/ 899,
+ -1,
+ /*0x0565*/ 446,
+ /*0xa7c3*/ 1104,
+ /*0xa749*/ 1056,
+ /*0x10cc3*/ 1257,
+ -1, -1, -1,
+ /*0x13f1*/ 607,
+ /*0x0471*/ 350,
+ /*0x04f1*/ 410,
+ /*0x0071*/ 15,
+ /*0x0569*/ 450,
+ /*0x104f1*/ 1208,
+ /*0x1e71*/ 672,
+ /*0x1ef1*/ 731,
+ /*0x0171*/ 110,
+ /*0x0271*/ 222,
+ /*0x16ed3*/ 1415,
+ -1, -1,
+ /*0x118dd*/ 1356,
+ -1,
+ /*0x2c5d*/ 897,
+ -1,
+ /*0x2d04*/ 965,
+ -1,
+ /*0x2d11*/ 978,
+ /*0x2d24*/ 997,
+ /*0xa7c1*/ 1103,
+ -1,
+ /*0x10cc1*/ 1255,
+ /*0x03f3*/ 291,
+ /*0x13f5*/ 611,
+ /*0x0475*/ 352,
+ /*0x04f5*/ 412,
+ /*0x0075*/ 19,
+ -1,
+ /*0x104f5*/ 1212,
+ /*0x1e75*/ 674,
+ /*0x1ef5*/ 733,
+ /*0x0175*/ 112,
+ /*0x0275*/ 224,
+ -1,
+ /*0x1f30*/ 761,
+ /*0x03ac*/ 244,
+ -1,
+ /*0x2c30*/ 852,
+ -1,
+ /*0x10ccb*/ 1265,
+ -1, -1,
+ /*0x1e930*/ 1430,
+ /*0x1f55*/ 777,
+ /*0x118d5*/ 1348,
+ -1,
+ /*0x2c55*/ 889,
+ /*0x2d20*/ 993,
+ -1, -1,
+ /*0xa64d*/ 1007,
+ /*0x10cc9*/ 1263,
+ -1,
+ /*0x13c7*/ 565,
+ /*0x0447*/ 317,
+ /*0x105b0*/ 1243,
+ /*0x0511*/ 426,
+ /*0x10447*/ 1174,
+ -1,
+ /*0x1e47*/ 651,
+ /*0x1ec7*/ 710,
+ -1,
+ /*0x0247*/ 195,
+ /*0x2cc7*/ 943,
+ -1,
+ /*0x13c5*/ 563,
+ /*0x0445*/ 315,
+ -1, -1,
+ /*0x10445*/ 1172,
+ /*0x019e*/ 127,
+ /*0x1e45*/ 650,
+ /*0x1ec5*/ 709,
+ /*0x16e61*/ 1360,
+ -1,
+ /*0x2cc5*/ 942,
+ /*0x01c9*/ 140,
+ -1, -1,
+ /*0x03cd*/ 275,
+ /*0x13bf*/ 557,
+ /*0x043f*/ 309,
+ /*0x04bf*/ 385,
+ -1,
+ /*0x1043f*/ 1166,
+ -1,
+ /*0x1e3f*/ 647,
+ /*0x1ebf*/ 706,
+ -1,
+ /*0x023f*/ 192,
+ /*0x2cbf*/ 939,
+ -1, -1, -1,
+ /*0x1f22*/ 755,
+ /*0x1f00*/ 739,
+ /*0x16ecf*/ 1411,
+ /*0x0567*/ 448,
+ /*0x2171*/ 810,
+ /*0x16e63*/ 1362,
+ /*0xa747*/ 1055,
+ /*0x1e928*/ 1422,
+ /*0x1e922*/ 1416,
+ /*0x10cf1*/ 1303,
+ -1,
+ /*0xa643*/ 1002,
+ -1,
+ /*0x13c2*/ 560,
+ /*0x0442*/ 312,
+ /*0x04c2*/ 386,
+ /*0x16e65*/ 1364,
+ /*0x10442*/ 1169,
+ /*0xa745*/ 1054,
+ /*0x0580*/ 473,
+ /*0x105a8*/ 1235,
+ /*0x0142*/ 87,
+ /*0x0242*/ 194,
+ /*0x1f73*/ 790,
+ /*0x0371*/ 238,
+ /*0x1059a*/ 1222,
+ /*0x2c73*/ 906,
+ /*0x16e69*/ 1368,
+ /*0x1059f*/ 1227,
+ /*0x2175*/ 814,
+ /*0x10f1*/ 513,
+ -1, -1,
+ /*0xa73f*/ 1051,
+ -1, -1,
+ /*0x2d0e*/ 975,
+ /*0x00f1*/ 42,
+ /*0xa641*/ 1001,
+ /*0x2d14*/ 981,
+ /*0x03c3*/ 265,
+ /*0x13b7*/ 549,
+ /*0x0437*/ 301,
+ /*0x04b7*/ 381,
+ /*0x1e92c*/ 1426,
+ /*0x10437*/ 1158,
+ -1,
+ /*0x1e37*/ 643,
+ /*0x1eb7*/ 702,
+ /*0x0137*/ 82,
+ -1,
+ /*0x2cb7*/ 935,
+ -1, -1,
+ /*0x017e*/ 116,
+ /*0x10f5*/ 517,
+ /*0xa64b*/ 1006,
+ /*0x105ac*/ 1239,
+ -1,
+ /*0x01f5*/ 161,
+ -1, -1,
+ /*0x00f5*/ 46,
+ /*0x13a7*/ 533,
+ /*0x10cc7*/ 1261,
+ /*0x04a7*/ 373,
+ /*0x1e92a*/ 1424,
+ /*0x03c1*/ 264,
+ /*0xa649*/ 1005,
+ /*0x1e27*/ 635,
+ /*0x1ea7*/ 694,
+ /*0x0127*/ 75,
+ /*0x0227*/ 184,
+ /*0x2ca7*/ 927,
+ /*0x029e*/ 237,
+ -1,
+ /*0x10cc5*/ 1259,
+ -1, -1,
+ /*0x105aa*/ 1237,
+ /*0x056b*/ 452,
+ /*0x118cd*/ 1340,
+ -1,
+ /*0x2c4d*/ 881,
+ -1,
+ /*0x03cb*/ 273,
+ /*0x10d73*/ 1308,
+ -1,
+ /*0xa737*/ 1047,
+ /*0xa7bf*/ 1102,
+ -1, -1, -1, -1,
+ /*0x13b5*/ 547,
+ /*0x0435*/ 299,
+ /*0x04b5*/ 380,
+ /*0x03c9*/ 271,
+ /*0x10435*/ 1156,
+ -1,
+ /*0x1e35*/ 642,
+ /*0x1eb5*/ 701,
+ /*0x0135*/ 81,
+ -1,
+ /*0x2cb5*/ 934,
+ /*0x13b3*/ 545,
+ /*0x0433*/ 297,
+ /*0x04b3*/ 379,
+ -1,
+ /*0x10433*/ 1154,
+ /*0xa727*/ 1040,
+ /*0x1e33*/ 641,
+ /*0x1eb3*/ 700,
+ /*0x0133*/ 80,
+ /*0x0233*/ 190,
+ /*0x2cb3*/ 933,
+ /*0x01bf*/ 138,
+ /*0x1fe1*/ 806,
+ /*0x10cc2*/ 1256,
+ /*0x0481*/ 358,
+ -1, -1,
+ /*0x16e67*/ 1366,
+ /*0x1e01*/ 616,
+ /*0x1e81*/ 680,
+ /*0x0101*/ 56,
+ /*0x0201*/ 166,
+ /*0x2c81*/ 908,
+ -1, -1,
+ /*0x1e05*/ 618,
+ /*0x1e85*/ 682,
+ /*0x0105*/ 58,
+ /*0x0205*/ 168,
+ /*0x2c85*/ 910,
+ /*0x1f43*/ 772,
+ /*0x118c3*/ 1330,
+ -1,
+ /*0x2c43*/ 871,
+ -1, -1,
+ /*0xa735*/ 1046,
+ -1,
+ /*0x1e943*/ 1449,
+ /*0xa7b7*/ 1098,
+ -1,
+ /*0x217e*/ 823,
+ -1, -1,
+ /*0x13ad*/ 539,
+ -1,
+ /*0x04ad*/ 376,
+ /*0xa733*/ 1045,
+ /*0x1042d*/ 1148,
+ /*0x1fe5*/ 807,
+ /*0x1e2d*/ 638,
+ /*0x1ead*/ 697,
+ /*0x012d*/ 78,
+ /*0x022d*/ 187,
+ /*0x2cad*/ 930,
+ /*0x2d22*/ 995,
+ /*0x2d00*/ 961,
+ /*0x1f41*/ 770,
+ /*0x118c1*/ 1328,
+ /*0x2d1a*/ 987,
+ /*0x2c41*/ 869,
+ /*0xa7a7*/ 1095,
+ /*0x2d1f*/ 992,
+ -1, -1,
+ /*0x1e941*/ 1447,
+ /*0x056f*/ 456,
+ /*0x10fe*/ 524,
+ -1, -1,
+ /*0xa647*/ 1004,
+ -1, -1, -1,
+ /*0x00fe*/ 54,
+ -1,
+ /*0x118cb*/ 1338,
+ /*0x1059c*/ 1224,
+ /*0x2c4b*/ 879,
+ /*0x047d*/ 356,
+ /*0x04fd*/ 416,
+ /*0x056d*/ 454,
+ /*0xa645*/ 1003,
+ -1,
+ /*0x1e7d*/ 678,
+ /*0x1efd*/ 737,
+ /*0x1d7d*/ 614,
+ /*0x027d*/ 225,
+ /*0x118c9*/ 1336,
+ -1,
+ /*0x2c49*/ 877,
+ /*0xa72d*/ 1043,
+ /*0xa7b5*/ 1097,
+ /*0x1fd1*/ 804,
+ /*0x16e6b*/ 1370,
+ -1, -1, -1,
+ /*0x13a5*/ 531,
+ /*0x03c7*/ 269,
+ /*0x04a5*/ 372,
+ /*0x051f*/ 433,
+ /*0x1059e*/ 1226,
+ -1,
+ /*0x1e25*/ 634,
+ /*0x1ea5*/ 693,
+ /*0x0125*/ 74,
+ /*0x0225*/ 183,
+ /*0x2ca5*/ 926,
+ -1, -1,
+ /*0x03c5*/ 267,
+ /*0x13c0*/ 558,
+ /*0x0440*/ 310,
+ /*0x16ecd*/ 1409,
+ /*0xa781*/ 1079,
+ /*0x10440*/ 1167,
+ /*0x0573*/ 460,
+ -1,
+ /*0x2184*/ 825,
+ /*0x0140*/ 86,
+ /*0x0240*/ 193,
+ /*0xa785*/ 1081,
+ -1, -1,
+ /*0x10d81*/ 1322,
+ /*0x03bf*/ 262,
+ -1,
+ /*0x13a3*/ 529,
+ -1,
+ /*0x04a3*/ 371,
+ -1,
+ /*0x10d85*/ 1326,
+ -1,
+ /*0x1e23*/ 633,
+ /*0x1ea3*/ 692,
+ /*0x0123*/ 73,
+ /*0x0223*/ 182,
+ /*0x2ca3*/ 925,
+ /*0x1f71*/ 788,
+ /*0x13bd*/ 555,
+ /*0x043d*/ 307,
+ /*0x04bd*/ 384,
+ -1,
+ /*0x1043d*/ 1164,
+ /*0xa725*/ 1039,
+ /*0x1e3d*/ 646,
+ /*0x1ebd*/ 705,
+ -1,
+ /*0x0185*/ 119,
+ /*0x2cbd*/ 938,
+ -1,
+ /*0x13bb*/ 553,
+ /*0x043b*/ 305,
+ /*0x04bb*/ 383,
+ -1,
+ /*0x1043b*/ 1162,
+ -1,
+ /*0x1e3b*/ 645,
+ /*0x1ebb*/ 704,
+ -1, -1,
+ /*0x2cbb*/ 937,
+ -1,
+ /*0x1f75*/ 792,
+ -1,
+ /*0x13b9*/ 551,
+ /*0x0439*/ 303,
+ /*0x04b9*/ 382,
+ /*0x16ec3*/ 1399,
+ /*0x10439*/ 1160,
+ -1,
+ /*0x1e39*/ 644,
+ /*0x1eb9*/ 703,
+ /*0x01ad*/ 132,
+ /*0xa723*/ 1038,
+ /*0x2cb9*/ 936,
+ -1,
+ /*0x217d*/ 822,
+ -1, -1,
+ /*0x03b7*/ 254,
+ /*0x13b1*/ 543,
+ /*0x0431*/ 295,
+ /*0x04b1*/ 378,
+ /*0x16e6f*/ 1374,
+ /*0x10431*/ 1152,
+ /*0xa73d*/ 1050,
+ /*0x1e31*/ 640,
+ /*0x1eb1*/ 699,
+ -1,
+ /*0x0231*/ 189,
+ /*0x2cb1*/ 932,
+ -1, -1,
+ /*0x118c7*/ 1334,
+ /*0x16ec1*/ 1397,
+ /*0x2c47*/ 875,
+ /*0x037d*/ 243,
+ /*0xa73b*/ 1049,
+ /*0x16e6d*/ 1372,
+ /*0xa7a5*/ 1094,
+ /*0x10d71*/ 1306,
+ -1,
+ /*0x10fd*/ 523,
+ -1,
+ /*0x1f45*/ 774,
+ /*0x118c5*/ 1332,
+ /*0x01fd*/ 164,
+ /*0x2c45*/ 873,
+ /*0xff59*/ 1141,
+ /*0x00fd*/ 53,
+ -1,
+ /*0xa739*/ 1048,
+ /*0x16ecb*/ 1407,
+ -1,
+ /*0x2d1c*/ 989,
+ /*0x10cc0*/ 1254,
+ -1, -1, -1,
+ /*0xff51*/ 1133,
+ -1, -1,
+ /*0x2c3f*/ 867,
+ -1,
+ /*0x16ec9*/ 1405,
+ /*0x10d75*/ 1310,
+ /*0x01a5*/ 130,
+ /*0x1e93f*/ 1445,
+ -1,
+ /*0xa7a3*/ 1093,
+ /*0xff57*/ 1139,
+ -1,
+ /*0x03b5*/ 252,
+ -1,
+ /*0x16e73*/ 1378,
+ -1, -1, -1, -1,
+ /*0x2d1e*/ 991,
+ -1,
+ /*0xa7bd*/ 1101,
+ -1,
+ /*0x03b3*/ 250,
+ -1, -1,
+ /*0x1f42*/ 771,
+ /*0x118c2*/ 1329,
+ -1,
+ /*0x2c42*/ 870,
+ -1, -1,
+ /*0xff53*/ 1135,
+ /*0xa7bb*/ 1100,
+ /*0x1e942*/ 1448,
+ /*0x048f*/ 361,
+ /*0x01a3*/ 129,
+ -1, -1,
+ /*0x1e0f*/ 623,
+ /*0x1e8f*/ 687,
+ /*0x010f*/ 63,
+ /*0x020f*/ 173,
+ /*0x2c8f*/ 915,
+ /*0xa69b*/ 1037,
+ -1, -1,
+ /*0xa7b9*/ 1099,
+ /*0x01bd*/ 137,
+ /*0xa68b*/ 1029,
+ -1, -1, -1, -1,
+ /*0x1f37*/ 768,
+ -1, -1,
+ /*0x2c37*/ 859,
+ -1,
+ /*0x0479*/ 354,
+ /*0x04f9*/ 414,
+ /*0x0079*/ 23,
+ /*0x1e937*/ 1437,
+ /*0x104f9*/ 1216,
+ /*0x1e79*/ 676,
+ /*0x1ef9*/ 735,
+ /*0x1d79*/ 613,
+ /*0x03ad*/ 245,
+ /*0x13f2*/ 608,
+ /*0x1fb0*/ 801,
+ /*0x0078*/ 22,
+ /*0x0072*/ 16,
+ /*0x104f8*/ 1215,
+ /*0x104f2*/ 1209,
+ /*0x01b9*/ 136,
+ /*0x105b7*/ 1249,
+ /*0x1f27*/ 760,
+ /*0x0272*/ 223,
+ -1,
+ /*0x1e03*/ 617,
+ /*0x1e83*/ 681,
+ /*0x0103*/ 57,
+ /*0x0203*/ 167,
+ /*0x2c83*/ 909,
+ /*0x1e927*/ 1421,
+ /*0x13af*/ 541,
+ -1,
+ /*0x04af*/ 377,
+ -1,
+ /*0x1042f*/ 1150,
+ -1,
+ /*0x1e2f*/ 639,
+ /*0x1eaf*/ 698,
+ /*0x012f*/ 79,
+ /*0x022f*/ 188,
+ /*0x2caf*/ 931,
+ /*0x13a9*/ 535,
+ /*0x105a7*/ 1234,
+ /*0x04a9*/ 374,
+ -1,
+ /*0x10429*/ 1144,
+ -1,
+ /*0x1e29*/ 636,
+ /*0x1ea9*/ 695,
+ /*0x0129*/ 76,
+ /*0x0229*/ 185,
+ /*0x2ca9*/ 928,
+ /*0x1f35*/ 766,
+ -1, -1,
+ /*0x2c35*/ 857,
+ /*0x16ec7*/ 1403,
+ -1, -1, -1,
+ /*0x1e935*/ 1435,
+ /*0x0571*/ 458,
+ -1,
+ /*0x1f33*/ 764,
+ -1,
+ /*0xff4f*/ 1131,
+ /*0x2c33*/ 855,
+ /*0x10d7e*/ 1319,
+ /*0x16ec5*/ 1401,
+ -1, -1,
+ /*0x1e933*/ 1433,
+ -1,
+ /*0x105b5*/ 1247,
+ -1,
+ /*0x1f01*/ 740,
+ -1,
+ /*0xa72f*/ 1044,
+ -1, -1,
+ /*0x03c0*/ 263,
+ /*0xa691*/ 1032,
+ /*0x1f05*/ 744,
+ /*0x16ebf*/ 1395,
+ /*0x105b3*/ 1245,
+ -1,
+ /*0x0575*/ 462,
+ -1,
+ /*0xa729*/ 1041,
+ -1,
+ /*0x047b*/ 355,
+ /*0x04fb*/ 415,
+ -1,
+ /*0x0581*/ 474,
+ /*0x104fb*/ 1218,
+ /*0x1e7b*/ 677,
+ /*0x1efb*/ 736,
+ -1, -1,
+ /*0x13a1*/ 527,
+ /*0x0585*/ 478,
+ /*0x04a1*/ 370,
+ -1,
+ /*0x2179*/ 818,
+ -1,
+ /*0x1e21*/ 632,
+ /*0x1ea1*/ 691,
+ /*0x0121*/ 72,
+ /*0x03bd*/ 260,
+ /*0x2ca1*/ 924,
+ /*0x16ec2*/ 1398,
+ -1,
+ /*0x2178*/ 817,
+ /*0x2172*/ 811,
+ -1,
+ /*0x1e92d*/ 1427,
+ -1, -1,
+ /*0x10cf2*/ 1304,
+ -1,
+ /*0x03bb*/ 258,
+ /*0xa783*/ 1080,
+ /*0x13c8*/ 566,
+ /*0x0448*/ 318,
+ /*0x04c8*/ 389,
+ -1,
+ /*0x10448*/ 1175,
+ -1,
+ /*0x105ad*/ 1240,
+ /*0x10f9*/ 521,
+ /*0x0148*/ 90,
+ /*0x10d83*/ 1324,
+ -1,
+ /*0x01f9*/ 162,
+ /*0x03b9*/ 256,
+ -1,
+ /*0x00f9*/ 49,
+ -1,
+ /*0x10f8*/ 520,
+ /*0x10f2*/ 514,
+ -1,
+ /*0x1f7d*/ 800,
+ -1, -1,
+ /*0xa7a9*/ 1096,
+ /*0x00f8*/ 48,
+ /*0x00f2*/ 43,
+ -1,
+ /*0x0183*/ 118,
+ -1,
+ /*0x03b1*/ 248,
+ /*0xff55*/ 1137,
+ /*0x0477*/ 353,
+ /*0x04f7*/ 413,
+ /*0x0077*/ 21,
+ -1,
+ /*0x104f7*/ 1214,
+ /*0x1e77*/ 675,
+ /*0x1ef7*/ 734,
+ /*0x0177*/ 113,
+ -1,
+ /*0x1f25*/ 758,
+ -1,
+ /*0x13ce*/ 572,
+ /*0x044e*/ 324,
+ /*0x04ce*/ 392,
+ -1,
+ /*0x1044e*/ 1181,
+ -1,
+ /*0x1e925*/ 1419,
+ -1, -1, -1, -1, -1,
+ /*0x1f40*/ 769,
+ /*0x118c0*/ 1327,
+ -1,
+ /*0x2c40*/ 868,
+ -1,
+ /*0x16e71*/ 1376,
+ /*0x2d27*/ 999,
+ /*0x105a5*/ 1232,
+ /*0x1e940*/ 1446,
+ -1,
+ /*0x13e6*/ 596,
+ /*0x13d0*/ 574,
+ /*0x0450*/ 326,
+ /*0x0066*/ 5,
+ /*0x217b*/ 820,
+ /*0x104e6*/ 1197,
+ /*0x1f23*/ 756,
+ -1, -1,
+ /*0x0266*/ 215,
+ /*0x0250*/ 200,
+ -1, -1, -1,
+ /*0x1e923*/ 1417,
+ /*0x24e6*/ 848,
+ /*0x24d0*/ 826,
+ /*0xa7a1*/ 1092,
+ /*0x057e*/ 471,
+ /*0x10d7d*/ 1318,
+ /*0x16e75*/ 1380,
+ /*0x2c3d*/ 865,
+ -1, -1,
+ /*0x037b*/ 241,
+ -1,
+ /*0x1e93d*/ 1443,
+ /*0x105a3*/ 1230,
+ -1, -1,
+ /*0x13d2*/ 576,
+ /*0x0452*/ 328,
+ -1,
+ /*0x2c3b*/ 863,
+ /*0x01fb*/ 163,
+ /*0x0527*/ 437,
+ -1,
+ /*0x00fb*/ 51,
+ /*0x1e93b*/ 1441,
+ /*0x0252*/ 202,
+ /*0xa7c8*/ 1105,
+ -1,
+ /*0x10cc8*/ 1262,
+ -1,
+ /*0x01a1*/ 128,
+ /*0x24d2*/ 828,
+ -1,
+ /*0x2c39*/ 861,
+ -1, -1,
+ /*0x2d01*/ 962,
+ /*0x105bb*/ 1252,
+ /*0x1e939*/ 1439,
+ -1, -1, -1, -1,
+ /*0x2d05*/ 966,
+ -1,
+ /*0x13f0*/ 606,
+ /*0x1f31*/ 762,
+ /*0x0283*/ 228,
+ /*0x0070*/ 14,
+ /*0x2c31*/ 853,
+ /*0x104f0*/ 1207,
+ /*0x105b9*/ 1251,
+ /*0x2177*/ 816,
+ -1,
+ /*0x1e931*/ 1431,
+ -1, -1, -1,
+ /*0x03f8*/ 292,
+ /*0x03f2*/ 290,
+ -1, -1, -1, -1,
+ /*0x214e*/ 808,
+ -1, -1,
+ /*0x105b1*/ 1244,
+ /*0x2d2d*/ 1000,
+ /*0x10cce*/ 1268,
+ -1, -1,
+ /*0x0377*/ 240,
+ -1, -1,
+ /*0x0501*/ 418,
+ /*0x03af*/ 247,
+ -1,
+ /*0x10f7*/ 519,
+ -1,
+ /*0x0493*/ 363,
+ -1,
+ /*0x0505*/ 420,
+ /*0xff4d*/ 1129,
+ /*0x1e13*/ 625,
+ /*0x1e93*/ 689,
+ /*0x0113*/ 65,
+ /*0x0213*/ 175,
+ /*0x2c93*/ 917,
+ -1, -1,
+ /*0x10ce6*/ 1292,
+ /*0x10cd0*/ 1270,
+ -1,
+ /*0x01ce*/ 142,
+ /*0x13c6*/ 564,
+ /*0x0446*/ 316,
+ /*0x04c6*/ 388,
+ -1,
+ /*0x10446*/ 1173,
+ -1, -1, -1,
+ /*0x0146*/ 89,
+ /*0x007a*/ 24,
+ -1,
+ /*0x104fa*/ 1217,
+ /*0x052d*/ 440,
+ -1,
+ /*0x017a*/ 114,
+ -1, -1,
+ /*0x10e6*/ 502,
+ /*0x10d0*/ 480,
+ -1,
+ /*0x16ec0*/ 1396,
+ -1,
+ /*0x01d0*/ 143,
+ -1,
+ /*0x00e6*/ 31,
+ -1,
+ /*0x10cd2*/ 1272,
+ /*0x2d25*/ 998,
+ /*0x16e7e*/ 1389,
+ /*0x13c4*/ 562,
+ /*0x0444*/ 314,
+ /*0x04c4*/ 387,
+ -1,
+ /*0x10444*/ 1171,
+ -1, -1, -1,
+ /*0x0144*/ 88,
+ -1, -1,
+ /*0x03fb*/ 293,
+ -1, -1,
+ /*0xff43*/ 1119,
+ -1, -1,
+ /*0x057d*/ 470,
+ /*0x10d2*/ 482,
+ /*0x16ebd*/ 1393,
+ /*0x1f79*/ 796,
+ /*0x2170*/ 809,
+ /*0x01d2*/ 144,
+ /*0x0076*/ 20,
+ /*0xa77a*/ 1076,
+ /*0x104f6*/ 1213,
+ /*0x10cf0*/ 1302,
+ -1,
+ /*0x2d23*/ 996,
+ /*0x1f78*/ 795,
+ /*0x1f72*/ 789,
+ /*0x16ebb*/ 1391,
+ -1,
+ /*0x13ec*/ 602,
+ -1,
+ /*0x1f03*/ 742,
+ /*0x006c*/ 10,
+ /*0x0525*/ 436,
+ /*0x104ec*/ 1203,
+ -1, -1,
+ /*0xff41*/ 1117,
+ /*0x026c*/ 220,
+ /*0x2cec*/ 958,
+ /*0x03c8*/ 270,
+ /*0x047f*/ 357,
+ /*0x04ff*/ 417,
+ /*0x10f0*/ 512,
+ -1, -1,
+ /*0x1e7f*/ 679,
+ /*0x1eff*/ 738,
+ -1,
+ /*0x0583*/ 476,
+ /*0x00f0*/ 41,
+ /*0x1e92f*/ 1429,
+ -1,
+ /*0xa793*/ 1085,
+ -1,
+ /*0xff4b*/ 1127,
+ /*0x13e8*/ 598,
+ -1, -1,
+ /*0x0068*/ 7,
+ -1,
+ /*0x104e8*/ 1199,
+ /*0x1e929*/ 1423,
+ /*0x0523*/ 435,
+ /*0x105af*/ 1242,
+ /*0x0268*/ 216,
+ -1,
+ /*0xff49*/ 1125,
+ -1, -1, -1,
+ /*0x24e8*/ 850,
+ /*0x10cc6*/ 1260,
+ /*0x217a*/ 819,
+ -1,
+ /*0x105a9*/ 1236,
+ /*0x13ab*/ 537,
+ -1,
+ /*0x04ab*/ 375,
+ /*0x10d79*/ 1314,
+ /*0x1042b*/ 1146,
+ /*0x03ce*/ 276,
+ /*0x1e2b*/ 637,
+ /*0x1eab*/ 696,
+ /*0x012b*/ 77,
+ /*0x022b*/ 186,
+ /*0x2cab*/ 929,
+ /*0xa77f*/ 1078,
+ /*0x10d78*/ 1313,
+ /*0x10d72*/ 1307,
+ /*0x13cc*/ 570,
+ /*0x044c*/ 322,
+ /*0x04cc*/ 391,
+ -1,
+ /*0x1044c*/ 1179,
+ -1, -1,
+ /*0x01c6*/ 139,
+ -1,
+ /*0x10fa*/ 522,
+ /*0x13e4*/ 594,
+ /*0x10cc4*/ 1258,
+ /*0x1f7b*/ 798,
+ /*0x0064*/ 3,
+ -1,
+ /*0x104e4*/ 1195,
+ /*0x00fa*/ 50,
+ -1, -1,
+ /*0x0264*/ 213,
+ -1, -1,
+ /*0x1f21*/ 754,
+ -1, -1,
+ /*0x24e4*/ 846,
+ /*0x2176*/ 815,
+ /*0x13f4*/ 610,
+ -1,
+ /*0xa7f6*/ 1115,
+ /*0x0074*/ 18,
+ /*0x0499*/ 366,
+ /*0x104f4*/ 1211,
+ /*0xa72b*/ 1042,
+ -1,
+ /*0x1e19*/ 628,
+ -1,
+ /*0x0119*/ 68,
+ /*0x0219*/ 178,
+ /*0x2c99*/ 920,
+ -1, -1,
+ /*0x16e7d*/ 1388,
+ /*0x105a1*/ 1229,
+ /*0x10cec*/ 1298,
+ -1,
+ /*0x118c8*/ 1335,
+ -1,
+ /*0x2c48*/ 876,
+ -1,
+ /*0x217f*/ 824,
+ -1,
+ /*0x10f6*/ 518,
+ /*0x13ca*/ 568,
+ /*0x044a*/ 320,
+ /*0x04ca*/ 390,
+ -1,
+ /*0x1044a*/ 1177,
+ -1,
+ /*0x00f6*/ 47,
+ -1,
+ /*0x2d0f*/ 976,
+ /*0x0495*/ 364,
+ -1, -1,
+ /*0x10ec*/ 508,
+ /*0x1e15*/ 626,
+ /*0x1e95*/ 690,
+ /*0x0115*/ 66,
+ /*0x0215*/ 176,
+ /*0x2c95*/ 918,
+ /*0x10ce8*/ 1294,
+ /*0x00ec*/ 37,
+ /*0x13e0*/ 590,
+ /*0x1f77*/ 794,
+ /*0x10d7b*/ 1316,
+ /*0x10ff*/ 525,
+ -1,
+ /*0x104e0*/ 1191,
+ -1,
+ /*0x01ff*/ 165,
+ -1,
+ /*0x0260*/ 210,
+ /*0x00ff*/ 55,
+ /*0xff47*/ 1123,
+ /*0x017c*/ 115,
+ -1,
+ /*0x118ce*/ 1341,
+ /*0x24e0*/ 842,
+ /*0x2c4e*/ 882,
+ -1, -1,
+ /*0x10e8*/ 504,
+ -1,
+ /*0x13bc*/ 554,
+ /*0x043c*/ 306,
+ /*0xff45*/ 1121,
+ -1,
+ /*0x1043c*/ 1163,
+ /*0x00e8*/ 33,
+ /*0x050f*/ 425,
+ /*0x2d03*/ 964,
+ /*0x013c*/ 84,
+ /*0x023c*/ 191,
+ -1,
+ /*0x10ccc*/ 1266,
+ -1, -1,
+ /*0x1f66*/ 785,
+ -1,
+ /*0x118d0*/ 1343,
+ /*0x2c66*/ 902,
+ /*0x2c50*/ 884,
+ -1, -1,
+ /*0x10ce4*/ 1290,
+ /*0x1e07*/ 619,
+ /*0x1e87*/ 683,
+ /*0x0107*/ 59,
+ /*0x0207*/ 169,
+ /*0x2c87*/ 911,
+ -1,
+ /*0x03c6*/ 268,
+ -1,
+ /*0xa77c*/ 1077,
+ /*0x0579*/ 466,
+ -1,
+ /*0x2174*/ 813,
+ -1, -1,
+ /*0x01cc*/ 141,
+ -1,
+ /*0xa799*/ 1088,
+ -1,
+ /*0x0578*/ 465,
+ /*0x0572*/ 459,
+ /*0x10e4*/ 500,
+ /*0x10d77*/ 1312,
+ /*0xff42*/ 1118,
+ /*0x118d2*/ 1345,
+ /*0x0503*/ 419,
+ /*0x2c52*/ 886,
+ -1,
+ /*0x00e4*/ 29,
+ -1,
+ /*0x13ea*/ 600,
+ -1, -1,
+ /*0x006a*/ 8,
+ -1,
+ /*0x104ea*/ 1201,
+ /*0x03c4*/ 266,
+ /*0x052f*/ 441,
+ /*0x10f4*/ 516,
+ /*0x026a*/ 218,
+ -1,
+ /*0xa7ca*/ 1106,
+ -1,
+ /*0x10cca*/ 1264,
+ /*0x0199*/ 124,
+ /*0x00f4*/ 45,
+ /*0x13b6*/ 548,
+ /*0x0436*/ 300,
+ /*0x0529*/ 438,
+ -1,
+ /*0x10436*/ 1157,
+ -1,
+ /*0x1f70*/ 787,
+ -1, -1,
+ /*0x13e2*/ 592,
+ /*0x13dc*/ 586,
+ /*0x045c*/ 338,
+ /*0x0062*/ 1,
+ -1,
+ /*0x104e2*/ 1193,
+ /*0x104dc*/ 1187,
+ /*0x217c*/ 821,
+ /*0x10ce0*/ 1286,
+ -1,
+ /*0x025c*/ 209,
+ -1,
+ /*0x2d21*/ 994,
+ -1,
+ /*0x16ec8*/ 1404,
+ /*0x24e2*/ 844,
+ /*0x24dc*/ 838,
+ /*0x13da*/ 584,
+ /*0x045a*/ 336,
+ -1,
+ /*0x0195*/ 123,
+ -1,
+ /*0x104da*/ 1185,
+ -1,
+ /*0x13d6*/ 580,
+ /*0x0456*/ 332,
+ -1,
+ /*0x037c*/ 242,
+ -1,
+ /*0x10e0*/ 496,
+ /*0x1f13*/ 750,
+ -1,
+ /*0x24da*/ 836,
+ /*0x0256*/ 205,
+ -1, -1,
+ /*0x00e0*/ 25,
+ /*0x13d8*/ 582,
+ /*0x0458*/ 334,
+ /*0x24d6*/ 832,
+ /*0x00fc*/ 52,
+ /*0x057b*/ 468,
+ /*0x104d8*/ 1183,
+ /*0xa787*/ 1082,
+ -1,
+ /*0x13b4*/ 546,
+ /*0x0434*/ 298,
+ -1,
+ /*0x118c6*/ 1333,
+ /*0x10434*/ 1155,
+ /*0x2c46*/ 874,
+ /*0x0521*/ 434,
+ /*0x24d8*/ 834,
+ /*0x1f7a*/ 797,
+ -1,
+ /*0x16ece*/ 1410,
+ -1,
+ /*0x0497*/ 365,
+ -1, -1,
+ /*0x10d70*/ 1305,
+ /*0x1e17*/ 627,
+ /*0x048d*/ 360,
+ /*0x0117*/ 67,
+ /*0x0217*/ 177,
+ /*0x2c97*/ 919,
+ /*0x1e0d*/ 622,
+ /*0x1e8d*/ 686,
+ /*0x010d*/ 62,
+ /*0x020d*/ 172,
+ /*0x2c8d*/ 914,
+ -1, -1, -1,
+ /*0x16e79*/ 1384,
+ /*0x03cc*/ 274,
+ /*0x1f44*/ 773,
+ /*0x118c4*/ 1331,
+ /*0x16ed0*/ 1412,
+ /*0x2c44*/ 872,
+ /*0x10cea*/ 1296,
+ -1, -1,
+ /*0x16e78*/ 1383,
+ /*0x16e72*/ 1377,
+ -1,
+ /*0x049d*/ 368,
+ /*0x13be*/ 556,
+ /*0x043e*/ 308,
+ -1,
+ /*0x1e1d*/ 630,
+ /*0x1043e*/ 1165,
+ /*0x011d*/ 70,
+ /*0x021d*/ 180,
+ /*0x2c9d*/ 922,
+ /*0x013e*/ 85,
+ /*0x1f76*/ 793,
+ -1, -1,
+ /*0x2c76*/ 907,
+ -1,
+ /*0x10ea*/ 506,
+ -1,
+ /*0x0577*/ 464,
+ -1,
+ /*0x10ce2*/ 1288,
+ /*0x10cdc*/ 1282,
+ /*0x16ed2*/ 1414,
+ /*0x00ea*/ 35,
+ /*0x13d4*/ 578,
+ /*0x0454*/ 330,
+ -1,
+ /*0x2c6c*/ 905,
+ -1,
+ /*0x1fb1*/ 802,
+ -1,
+ /*0x10d7a*/ 1315,
+ -1,
+ /*0x0254*/ 204,
+ -1,
+ /*0x13ee*/ 604,
+ /*0x01b6*/ 135,
+ /*0x10cda*/ 1280,
+ /*0x006e*/ 12,
+ /*0x24d4*/ 830,
+ /*0x104ee*/ 1205,
+ /*0x10e2*/ 498,
+ /*0x10dc*/ 492,
+ /*0x03ca*/ 272,
+ /*0x10cd6*/ 1276,
+ /*0x2cee*/ 959,
+ /*0x01dc*/ 149,
+ -1,
+ /*0x00e2*/ 27,
+ -1, -1, -1,
+ /*0x0566*/ 447,
+ -1,
+ /*0x2c68*/ 903,
+ /*0x13de*/ 588,
+ /*0x045e*/ 340,
+ /*0x10cd8*/ 1278,
+ /*0x10da*/ 490,
+ -1,
+ /*0x104de*/ 1189,
+ -1,
+ /*0x01da*/ 148,
+ -1, -1,
+ /*0x10d6*/ 486,
+ -1, -1, -1,
+ /*0x01d6*/ 146,
+ /*0x24de*/ 840,
+ -1, -1,
+ /*0xa797*/ 1087,
+ /*0x10d76*/ 1311,
+ /*0x16e7b*/ 1386,
+ -1, -1,
+ /*0x10d8*/ 488,
+ /*0x1e92b*/ 1425,
+ -1, -1,
+ /*0x01d8*/ 147,
+ /*0x0287*/ 229,
+ /*0x03bc*/ 259,
+ -1,
+ /*0x118cc*/ 1339,
+ -1,
+ /*0x2c4c*/ 880,
+ -1,
+ /*0x01b4*/ 134,
+ -1,
+ /*0x105ab*/ 1238,
+ -1, -1,
+ /*0x1f64*/ 783,
+ /*0x13ba*/ 552,
+ /*0x043a*/ 304,
+ /*0x10d7f*/ 1320,
+ -1,
+ /*0x1043a*/ 1161,
+ /*0x16ec6*/ 1402,
+ /*0xa79d*/ 1090,
+ /*0xa681*/ 1024,
+ /*0x013a*/ 83,
+ /*0x2d13*/ 980,
+ -1, -1, -1, -1,
+ /*0xa685*/ 1026,
+ /*0x0570*/ 457,
+ /*0x1f74*/ 791,
+ /*0x1e09*/ 620,
+ /*0x1e89*/ 684,
+ /*0x0109*/ 60,
+ /*0x0209*/ 170,
+ /*0x2c89*/ 912,
+ /*0x13b8*/ 550,
+ /*0x0438*/ 302,
+ -1, -1,
+ /*0x10438*/ 1159,
+ -1, -1, -1, -1, -1, -1,
+ /*0x10cd4*/ 1274,
+ /*0x16ec4*/ 1400,
+ -1, -1, -1, -1,
+ /*0x10599*/ 1221,
+ -1,
+ /*0x16e77*/ 1382,
+ -1,
+ /*0x118ca*/ 1337,
+ /*0x10cee*/ 1300,
+ /*0x2c4a*/ 878,
+ /*0x13b2*/ 544,
+ /*0x0432*/ 296,
+ /*0x0513*/ 427,
+ /*0x1f15*/ 752,
+ /*0x10432*/ 1153,
+ -1, -1, -1,
+ /*0x10d4*/ 484,
+ /*0x03b6*/ 253,
+ -1, -1,
+ /*0x01d4*/ 145,
+ -1, -1, -1,
+ /*0x1f60*/ 779,
+ -1,
+ /*0x10cde*/ 1284,
+ /*0x10ee*/ 510,
+ /*0x1f7c*/ 799,
+ -1, -1, -1, -1,
+ /*0x057a*/ 467,
+ /*0x00ee*/ 39,
+ -1, -1,
+ /*0x16e66*/ 1365,
+ -1, -1, -1,
+ /*0x10d74*/ 1309,
+ -1, -1, -1, -1, -1,
+ /*0x10de*/ 494,
+ /*0x2c3c*/ 864,
+ -1, -1, -1, -1,
+ /*0x1e93c*/ 1442,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x1f07*/ 746,
+ -1, -1, -1, -1,
+ /*0x105bc*/ 1253,
+ -1, -1, -1, -1,
+ /*0x03b4*/ 251,
+ -1, -1, -1, -1,
+ /*0x0576*/ 463,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x056c*/ 453,
+ /*0x16ecc*/ 1408,
+ /*0x10d7c*/ 1317,
+ -1,
+ /*0x029d*/ 236,
+ -1, -1,
+ /*0x16e70*/ 1375,
+ -1, -1,
+ /*0x2c6a*/ 904,
+ /*0x057f*/ 472,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x1f36*/ 767,
+ /*0x03be*/ 261,
+ -1,
+ /*0x2c36*/ 858,
+ /*0x0568*/ 449,
+ -1, -1, -1,
+ /*0x1e936*/ 1436,
+ /*0x1f62*/ 781,
+ -1,
+ /*0x118dc*/ 1355,
+ -1,
+ /*0x2c5c*/ 896,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x105b6*/ 1248,
+ -1, -1,
+ /*0x052b*/ 439,
+ -1, -1,
+ /*0x118da*/ 1353,
+ /*0x2d19*/ 986,
+ /*0x2c5a*/ 894,
+ -1,
+ /*0x16eca*/ 1406,
+ -1, -1,
+ /*0x118d6*/ 1349,
+ -1,
+ /*0x2c56*/ 890,
+ -1, -1, -1,
+ /*0x16e7a*/ 1385,
+ -1, -1, -1, -1, -1, -1,
+ /*0x118d8*/ 1351,
+ /*0x0564*/ 445,
+ /*0x2c58*/ 892,
+ -1, -1, -1, -1,
+ /*0x1f34*/ 765,
+ -1, -1,
+ /*0x2c34*/ 856,
+ -1,
+ /*0x2d15*/ 982,
+ -1, -1,
+ /*0x1e934*/ 1434,
+ -1,
+ /*0x1fd0*/ 803,
+ /*0x0574*/ 461,
+ -1,
+ /*0x0519*/ 430,
+ -1, -1, -1, -1,
+ /*0x16ebc*/ 1392,
+ -1, -1,
+ /*0x105b4*/ 1246,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x16e76*/ 1381,
+ -1,
+ /*0x10597*/ 1219,
+ -1, -1, -1,
+ /*0x0289*/ 231,
+ -1, -1, -1, -1, -1,
+ /*0x03ba*/ 257,
+ /*0x16e6c*/ 1371,
+ -1,
+ /*0x0515*/ 428,
+ /*0x2c3e*/ 866,
+ /*0xa68f*/ 1031,
+ -1, -1, -1,
+ /*0x1e93e*/ 1444,
+ -1, -1,
+ /*0x16e7f*/ 1390,
+ -1,
+ /*0x2d07*/ 968,
+ -1, -1, -1, -1,
+ /*0x1059d*/ 1225,
+ /*0x057c*/ 469,
+ -1,
+ /*0x03b8*/ 255,
+ -1,
+ /*0x118d4*/ 1347,
+ -1,
+ /*0x2c54*/ 888,
+ -1,
+ /*0x16e68*/ 1367,
+ -1, -1, -1, -1,
+ /*0xff48*/ 1124,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xa683*/ 1025,
+ /*0x03b2*/ 249,
+ -1, -1, -1, -1, -1, -1,
+ /*0x0507*/ 421,
+ -1,
+ /*0x118de*/ 1357,
+ -1,
+ /*0x2c5e*/ 898,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x16e64*/ 1363,
+ -1,
+ /*0xff4e*/ 1130,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x056a*/ 451,
+ /*0x16e74*/ 1379,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xff50*/ 1132,
+ /*0x2c3a*/ 862,
+ -1, -1, -1, -1,
+ /*0x1e93a*/ 1440,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x0562*/ 443,
+ -1, -1, -1, -1, -1, -1,
+ /*0x2c38*/ 860,
+ -1, -1, -1, -1,
+ /*0x1e938*/ 1438,
+ /*0xff52*/ 1134,
+ -1, -1,
+ /*0x2d17*/ 984,
+ -1, -1, -1, -1,
+ /*0x2d0d*/ 974,
+ /*0x16e60*/ 1359,
+ -1, -1,
+ /*0x105b8*/ 1250,
+ /*0x16e7c*/ 1387,
+ /*0x16ebe*/ 1394,
+ /*0x1f32*/ 763,
+ -1, -1,
+ /*0x2c32*/ 854,
+ -1, -1, -1, -1,
+ /*0x1e932*/ 1432,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1,
+ /*0x2d1d*/ 990,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x0517*/ 429,
+ -1, -1, -1, -1,
+ /*0x050d*/ 424,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x051d*/ 432,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xff46*/ 1122,
+ -1,
+ /*0x16e6a*/ 1369,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x16e62*/ 1361,
+ /*0x056e*/ 455,
+ /*0xff44*/ 1120,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0x2d09*/ 970,
+ -1, -1, -1, -1, -1, -1,
+ /*0x1fe0*/ 805,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0xa693*/ 1033,
+ /*0x0509*/ 422,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xff4c*/ 1128,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x16e6e*/ 1373,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xff4a*/ 1126,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xa699*/ 1036,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0xa695*/ 1034,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xff5a*/ 1142,
+ -1, -1, -1, -1, -1, -1,
+ /*0xff56*/ 1138,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0xff58*/ 1140,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0xa687*/ 1027,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ /*0xff54*/ 1136,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1,
+ /*0xa697*/ 1035,
+ -1, -1, -1, -1,
+ /*0xa68d*/ 1030,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0xa689*/ 1028
+ };
+
+ if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_11_hash(code);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code1_equal(code, CaseUnfold_11_Table[s].from))
+ return &CaseUnfold_11_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_12_Type CaseUnfold_12_Table[] = {
+#define CaseUnfold_12 (*(CaseUnfold_12_Type (*)[58])(CaseUnfold_12_Table+0))
+ {{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}, {2, {0x00df, 0x1e9e}}},
+ {{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, {0x1f80, 0x1f88}}},
+ {{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}}},
+#define CaseUnfold_12_Locale (*(CaseUnfold_12_Type (*)[1])(CaseUnfold_12_Table+58))
+ {{0x0069, 0x0307}, {1, {0x0130}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_12_hash -N onigenc_unicode_CaseUnfold_12_lookup -n */
+
+/* maximum key range = 71, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_12_hash(const OnigCodePoint *codes)
+{
+ static const unsigned char asso_values[] =
+ {
+ 3, 58, 54, 57, 56, 16, 8, 2, 43, 82,
+ 3, 1, 23, 82, 82, 82, 82, 82, 82, 4,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 52, 51, 50, 49, 48, 47, 46, 45,
+ 82, 82, 82, 82, 43, 82, 42, 82, 82, 13,
+ 82, 82, 82, 82, 82, 11, 82, 1, 82, 82,
+ 14, 82, 1, 82, 82, 31, 3, 82, 82, 30,
+ 82, 82, 82, 10, 82, 82, 82, 82, 37, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 37, 15, 36, 35,
+ 34, 17, 1, 33, 12, 4, 23, 23, 26, 21,
+ 13, 82, 27, 82, 82, 2, 5, 82, 11, 16,
+ 82, 15, 82, 82, 23, 82, 8, 82
+ };
+ return asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_12_lookup(const OnigCodePoint *codes)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x61,
+ MAX_CODE_VALUE = 0x1f7c,
+ TOTAL_KEYWORDS = 59,
+ MIN_WORD_LENGTH = 6,
+ MAX_WORD_LENGTH = 6,
+ MIN_HASH_VALUE = 11,
+ MAX_HASH_VALUE = 81
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1,
+ /*0x1f66,0x03b9*/ 53,
+ /*0x1f07,0x03b9*/ 38,
+ /*0x1f00,0x03b9*/ 31,
+ /*0x0066,0x0066*/ 1,
+ /*0x1f74,0x03b9*/ 56,
+ /*0x0073,0x0073*/ 6,
+ /*0x0066,0x0069*/ 2,
+ /*0x1f06,0x03b9*/ 37,
+ /*0x0073,0x0074*/ 7,
+ /*0x03b9,0x0342*/ 18,
+ /*0x03c9,0x03b9*/ 23,
+ /*0x03b7,0x03b9*/ 17,
+ /*0x0069,0x0307*/ 58,
+ /*0x03b1,0x03b9*/ 15,
+ /*0x1f61,0x03b9*/ 48,
+ /*0x1f05,0x03b9*/ 36,
+ /*0x1f65,0x03b9*/ 52,
+ /*0x0574,0x0576*/ 29,
+ /*0x03c9,0x0342*/ 22,
+ /*0x03b7,0x0342*/ 16,
+ /*0x057e,0x0576*/ 30,
+ /*0x03b1,0x0342*/ 14,
+ /*0x1f7c,0x03b9*/ 57,
+ /*0x0574,0x0565*/ 26,
+ /*0x0079,0x030a*/ 10,
+ /*0x0077,0x030a*/ 9,
+ /*0x1f70,0x03b9*/ 55,
+ /*0x0574,0x056d*/ 28,
+ /*0x0066,0x006c*/ 3,
+ /*0x0574,0x056b*/ 27,
+ /*0x0061,0x02be*/ 0,
+ /*0x0068,0x0331*/ 4,
+ /*0x1f67,0x03b9*/ 54,
+ /*0x1f64,0x03b9*/ 51,
+ /*0x1f63,0x03b9*/ 50,
+ /*0x1f62,0x03b9*/ 49,
+ /*0x1f60,0x03b9*/ 47,
+ /*0x03ce,0x03b9*/ 24,
+ /*0x03c5,0x0342*/ 21,
+ /*0x03c5,0x0313*/ 20,
+ /*0x03c1,0x0313*/ 19,
+ /*0x02bc,0x006e*/ 11,
+ /*0x03ae,0x03b9*/ 13,
+ /*0x03ac,0x03b9*/ 12,
+ /*0x1f27,0x03b9*/ 46,
+ /*0x1f26,0x03b9*/ 45,
+ /*0x1f25,0x03b9*/ 44,
+ /*0x1f24,0x03b9*/ 43,
+ /*0x1f23,0x03b9*/ 42,
+ /*0x1f22,0x03b9*/ 41,
+ /*0x1f21,0x03b9*/ 40,
+ /*0x1f20,0x03b9*/ 39,
+ /*0x006a,0x030c*/ 5,
+ /*0x1f02,0x03b9*/ 33,
+ /*0x0074,0x0308*/ 8,
+ /*0x1f04,0x03b9*/ 35,
+ /*0x1f03,0x03b9*/ 34,
+ /*0x1f01,0x03b9*/ 32,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ /*0x0565,0x0582*/ 25
+ };
+
+ if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+ codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_12_hash(codes);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code2_equal(codes, CaseUnfold_12_Table[s].from))
+ return &CaseUnfold_12_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const CaseUnfold_13_Type CaseUnfold_13_Table[] = {
+#define CaseUnfold_13 (*(CaseUnfold_13_Type (*)[14])(CaseUnfold_13_Table+0))
+ {{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}}},
+};
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6,7,8,9 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_13_hash -N onigenc_unicode_CaseUnfold_13_lookup -n */
+
+/* maximum key range = 20, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_13_hash(const OnigCodePoint *codes)
+{
+ static const unsigned char asso_values[] =
+ {
+ 7, 4, 47, 47, 47, 47, 1, 1, 2, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 1,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 11,
+ 47, 47, 47, 47, 47, 10, 47, 2, 47, 47,
+ 47, 47, 47, 47, 47, 47, 1, 47, 47, 1,
+ 47, 47, 47, 9, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 1, 47, 47, 2, 47, 47, 1, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+ 47, 47, 47, 47, 47, 47, 47, 47
+ };
+ return asso_values[bits_at(codes, 8)] + asso_values[bits_at(codes, 7)] + asso_values[bits_at(codes, 6)] + asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_13_lookup(const OnigCodePoint *codes)
+{
+ enum
+ {
+ MIN_CODE_VALUE = 0x66,
+ MAX_CODE_VALUE = 0x3c9,
+ TOTAL_KEYWORDS = 14,
+ MIN_WORD_LENGTH = 9,
+ MAX_WORD_LENGTH = 9,
+ MIN_HASH_VALUE = 27,
+ MAX_HASH_VALUE = 46
+ };
+
+ static const short wordlist[] =
+ {
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
+ -1, -1, -1,
+ /*0x03c5,0x0313,0x0342*/ 12,
+ /*0x03c5,0x0308,0x0342*/ 9,
+ /*0x03b9,0x0308,0x0342*/ 6,
+ /*0x03c5,0x0313,0x0301*/ 11,
+ /*0x03c5,0x0308,0x0301*/ 8,
+ /*0x03b9,0x0308,0x0301*/ 5,
+ /*0x03c5,0x0313,0x0300*/ 10,
+ /*0x03c5,0x0308,0x0300*/ 7,
+ /*0x03b9,0x0308,0x0300*/ 4,
+ /*0x03c9,0x0342,0x03b9*/ 13,
+ /*0x03b7,0x0342,0x03b9*/ 3,
+ /*0x03b1,0x0342,0x03b9*/ 2,
+ -1, -1, -1, -1, -1, -1,
+ /*0x0066,0x0066,0x006c*/ 1,
+ /*0x0066,0x0066,0x0069*/ 0
+ };
+
+ if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+ codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE &&
+ codes[2] <= MAX_CODE_VALUE && codes[2] >= MIN_CODE_VALUE)
+ {
+ register unsigned int key = onigenc_unicode_CaseUnfold_13_hash(codes);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register short s = wordlist[key];
+
+ if (s >= 0 && code3_equal(codes, CaseUnfold_13_Table[s].from))
+ return &CaseUnfold_13_Table[s].to;
+ }
+ }
+ return 0;
+}
+
+static const OnigCodePoint CaseMappingSpecials[] = {
+ L(1)|0x039C,
+ L(2)|0x0053, 0x0073, L(2)|0x0053, 0x0053,
+ L(2)|0x02BC, 0x004E,
+ L(1)|0x0053,
+ L(1)|0x01C5,
+ L(2)|0x0064, 0x017D, L(1)|0x01C4,
+ L(1)|0x01C8,
+ L(2)|0x006C, 0x004A, L(1)|0x01C7,
+ L(1)|0x01CB,
+ L(2)|0x006E, 0x004A, L(1)|0x01CA,
+ L(2)|0x004A, 0x030C,
+ L(1)|0x01F2,
+ L(2)|0x0064, 0x005A, L(1)|0x01F1,
+ L(1)|0x0399,
+ L(3)|0x0399, 0x0308, 0x0301,
+ L(3)|0x03A5, 0x0308, 0x0301,
+ L(1)|0x03A3,
+ L(1)|0x0392,
+ L(1)|0x0398,
+ L(1)|0x03A6,
+ L(1)|0x03A0,
+ L(1)|0x039A,
+ L(1)|0x03A1,
+ L(1)|0x0395,
+ L(2)|0x0535, 0x0582, L(2)|0x0535, 0x0552,
+ L(1)|0x0412,
+ L(1)|0x0414,
+ L(1)|0x041E,
+ L(1)|0x0421,
+ L(1)|0x0422,
+ L(1)|0x0422,
+ L(1)|0x042A,
+ L(1)|0x0462,
+ L(1)|0xA64A,
+ L(2)|0x0048, 0x0331,
+ L(2)|0x0054, 0x0308,
+ L(2)|0x0057, 0x030A,
+ L(2)|0x0059, 0x030A,
+ L(2)|0x0041, 0x02BE,
+ L(1)|0x1E60,
+ L(1)|0x00DF,
+ L(2)|0x03A5, 0x0313,
+ L(3)|0x03A5, 0x0313, 0x0300,
+ L(3)|0x03A5, 0x0313, 0x0301,
+ L(3)|0x03A5, 0x0313, 0x0342,
+ L(1)|0x1F88, L(2)|0x1F08, 0x0399,
+ L(1)|0x1F89, L(2)|0x1F09, 0x0399,
+ L(1)|0x1F8A, L(2)|0x1F0A, 0x0399,
+ L(1)|0x1F8B, L(2)|0x1F0B, 0x0399,
+ L(1)|0x1F8C, L(2)|0x1F0C, 0x0399,
+ L(1)|0x1F8D, L(2)|0x1F0D, 0x0399,
+ L(1)|0x1F8E, L(2)|0x1F0E, 0x0399,
+ L(1)|0x1F8F, L(2)|0x1F0F, 0x0399,
+ L(2)|0x1F00, 0x0399, L(1)|0x1F80, L(2)|0x1F08, 0x0399,
+ L(2)|0x1F01, 0x0399, L(1)|0x1F81, L(2)|0x1F09, 0x0399,
+ L(2)|0x1F02, 0x0399, L(1)|0x1F82, L(2)|0x1F0A, 0x0399,
+ L(2)|0x1F03, 0x0399, L(1)|0x1F83, L(2)|0x1F0B, 0x0399,
+ L(2)|0x1F04, 0x0399, L(1)|0x1F84, L(2)|0x1F0C, 0x0399,
+ L(2)|0x1F05, 0x0399, L(1)|0x1F85, L(2)|0x1F0D, 0x0399,
+ L(2)|0x1F06, 0x0399, L(1)|0x1F86, L(2)|0x1F0E, 0x0399,
+ L(2)|0x1F07, 0x0399, L(1)|0x1F87, L(2)|0x1F0F, 0x0399,
+ L(1)|0x1F98, L(2)|0x1F28, 0x0399,
+ L(1)|0x1F99, L(2)|0x1F29, 0x0399,
+ L(1)|0x1F9A, L(2)|0x1F2A, 0x0399,
+ L(1)|0x1F9B, L(2)|0x1F2B, 0x0399,
+ L(1)|0x1F9C, L(2)|0x1F2C, 0x0399,
+ L(1)|0x1F9D, L(2)|0x1F2D, 0x0399,
+ L(1)|0x1F9E, L(2)|0x1F2E, 0x0399,
+ L(1)|0x1F9F, L(2)|0x1F2F, 0x0399,
+ L(2)|0x1F20, 0x0399, L(1)|0x1F90, L(2)|0x1F28, 0x0399,
+ L(2)|0x1F21, 0x0399, L(1)|0x1F91, L(2)|0x1F29, 0x0399,
+ L(2)|0x1F22, 0x0399, L(1)|0x1F92, L(2)|0x1F2A, 0x0399,
+ L(2)|0x1F23, 0x0399, L(1)|0x1F93, L(2)|0x1F2B, 0x0399,
+ L(2)|0x1F24, 0x0399, L(1)|0x1F94, L(2)|0x1F2C, 0x0399,
+ L(2)|0x1F25, 0x0399, L(1)|0x1F95, L(2)|0x1F2D, 0x0399,
+ L(2)|0x1F26, 0x0399, L(1)|0x1F96, L(2)|0x1F2E, 0x0399,
+ L(2)|0x1F27, 0x0399, L(1)|0x1F97, L(2)|0x1F2F, 0x0399,
+ L(1)|0x1FA8, L(2)|0x1F68, 0x0399,
+ L(1)|0x1FA9, L(2)|0x1F69, 0x0399,
+ L(1)|0x1FAA, L(2)|0x1F6A, 0x0399,
+ L(1)|0x1FAB, L(2)|0x1F6B, 0x0399,
+ L(1)|0x1FAC, L(2)|0x1F6C, 0x0399,
+ L(1)|0x1FAD, L(2)|0x1F6D, 0x0399,
+ L(1)|0x1FAE, L(2)|0x1F6E, 0x0399,
+ L(1)|0x1FAF, L(2)|0x1F6F, 0x0399,
+ L(2)|0x1F60, 0x0399, L(1)|0x1FA0, L(2)|0x1F68, 0x0399,
+ L(2)|0x1F61, 0x0399, L(1)|0x1FA1, L(2)|0x1F69, 0x0399,
+ L(2)|0x1F62, 0x0399, L(1)|0x1FA2, L(2)|0x1F6A, 0x0399,
+ L(2)|0x1F63, 0x0399, L(1)|0x1FA3, L(2)|0x1F6B, 0x0399,
+ L(2)|0x1F64, 0x0399, L(1)|0x1FA4, L(2)|0x1F6C, 0x0399,
+ L(2)|0x1F65, 0x0399, L(1)|0x1FA5, L(2)|0x1F6D, 0x0399,
+ L(2)|0x1F66, 0x0399, L(1)|0x1FA6, L(2)|0x1F6E, 0x0399,
+ L(2)|0x1F67, 0x0399, L(1)|0x1FA7, L(2)|0x1F6F, 0x0399,
+ L(2)|0x1FBA, 0x0345, L(2)|0x1FBA, 0x0399,
+ L(1)|0x1FBC, L(2)|0x0391, 0x0399,
+ L(2)|0x0386, 0x0345, L(2)|0x0386, 0x0399,
+ L(2)|0x0391, 0x0342,
+ L(3)|0x0391, 0x0342, 0x0345, L(3)|0x0391, 0x0342, 0x0399,
+ L(2)|0x03B1, 0x0399, L(1)|0x1FB3, L(2)|0x0391, 0x0399,
+ L(1)|0x0399,
+ L(2)|0x1FCA, 0x0345, L(2)|0x1FCA, 0x0399,
+ L(1)|0x1FCC, L(2)|0x0397, 0x0399,
+ L(2)|0x0389, 0x0345, L(2)|0x0389, 0x0399,
+ L(2)|0x0397, 0x0342,
+ L(3)|0x0397, 0x0342, 0x0345, L(3)|0x0397, 0x0342, 0x0399,
+ L(2)|0x03B7, 0x0399, L(1)|0x1FC3, L(2)|0x0397, 0x0399,
+ L(3)|0x0399, 0x0308, 0x0300,
+ L(3)|0x0399, 0x0308, 0x0301,
+ L(2)|0x0399, 0x0342,
+ L(3)|0x0399, 0x0308, 0x0342,
+ L(3)|0x03A5, 0x0308, 0x0300,
+ L(3)|0x03A5, 0x0308, 0x0301,
+ L(2)|0x03A1, 0x0313,
+ L(2)|0x03A5, 0x0342,
+ L(3)|0x03A5, 0x0308, 0x0342,
+ L(2)|0x1FFA, 0x0345, L(2)|0x1FFA, 0x0399,
+ L(1)|0x1FFC, L(2)|0x03A9, 0x0399,
+ L(2)|0x038F, 0x0345, L(2)|0x038F, 0x0399,
+ L(2)|0x03A9, 0x0342,
+ L(3)|0x03A9, 0x0342, 0x0345, L(3)|0x03A9, 0x0342, 0x0399,
+ L(2)|0x03C9, 0x0399, L(1)|0x1FF3, L(2)|0x03A9, 0x0399,
+ L(2)|0x0046, 0x0066, L(2)|0x0046, 0x0046,
+ L(2)|0x0046, 0x0069, L(2)|0x0046, 0x0049,
+ L(2)|0x0046, 0x006C, L(2)|0x0046, 0x004C,
+ L(3)|0x0046, 0x0066, 0x0069, L(3)|0x0046, 0x0046, 0x0049,
+ L(3)|0x0046, 0x0066, 0x006C, L(3)|0x0046, 0x0046, 0x004C,
+ L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
+ L(2)|0x0053, 0x0074, L(2)|0x0053, 0x0054,
+ L(2)|0x0544, 0x0576, L(2)|0x0544, 0x0546,
+ L(2)|0x0544, 0x0565, L(2)|0x0544, 0x0535,
+ L(2)|0x0544, 0x056B, L(2)|0x0544, 0x053B,
+ L(2)|0x054E, 0x0576, L(2)|0x054E, 0x0546,
+ L(2)|0x0544, 0x056D, L(2)|0x0544, 0x053D,
+};
diff --git a/enc/unicode/17.0.0/name2ctype.h b/enc/unicode/17.0.0/name2ctype.h
new file mode 100644
index 0000000000..8c1c0659ac
--- /dev/null
+++ b/enc/unicode/17.0.0/name2ctype.h
@@ -0,0 +1,49725 @@
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p */
+#ifndef USE_UNICODE_PROPERTIES
+/* Computed positions: -k'1,3' */
+#else /* USE_UNICODE_PROPERTIES */
+/* Computed positions: -k'1-3,5-6,12,16,$' */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#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-gperf@gnu.org>."
+#endif
+
+
+
+/* 'NEWLINE': [[:NEWLINE:]] */
+static const OnigCodePoint CR_NEWLINE[] = {
+ 1,
+ 0x000a, 0x000a,
+}; /* CR_NEWLINE */
+
+/* 'Alpha': [[:Alpha:]] */
+static const OnigCodePoint CR_Alpha[] = {
+ 761,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0345, 0x0345,
+ 0x0363, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0657,
+ 0x0659, 0x065f,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06e1, 0x06e8,
+ 0x06ed, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x073f,
+ 0x074d, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0817,
+ 0x081a, 0x082c,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x0897, 0x0897,
+ 0x08a0, 0x08c9,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x093b,
+ 0x093d, 0x094c,
+ 0x094e, 0x0950,
+ 0x0955, 0x0963,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a70, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0af9, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d7a, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e46,
+ 0x0e4d, 0x0e4d,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ecd, 0x0ecd,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f83,
+ 0x0f88, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x103f,
+ 0x1050, 0x108f,
+ 0x109a, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1713,
+ 0x171f, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17c8,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1aa7, 0x1aa7,
+ 0x1abf, 0x1ac0,
+ 0x1acc, 0x1ace,
+ 0x1b00, 0x1b33,
+ 0x1b35, 0x1b43,
+ 0x1b45, 0x1b4c,
+ 0x1b80, 0x1ba9,
+ 0x1bac, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1be7, 0x1bf1,
+ 0x1c00, 0x1c36,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1dd3, 0x1df4,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa674, 0xa67b,
+ 0xa67f, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa805,
+ 0xa807, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8ff,
+ 0xa90a, 0xa92a,
+ 0xa930, 0xa952,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9b2,
+ 0xa9b4, 0xa9bf,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaabe,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabea,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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,
+ 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d27,
+ 0x10d4a, 0x10d65,
+ 0x10d69, 0x10d69,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10eac,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10efa, 0x10efc,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11045,
+ 0x11071, 0x11075,
+ 0x11080, 0x110b8,
+ 0x110c2, 0x110c2,
+ 0x110d0, 0x110e8,
+ 0x11100, 0x11132,
+ 0x11144, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111bf,
+ 0x111c1, 0x111c4,
+ 0x111ce, 0x111cf,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112e8,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144a,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114c1,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x1163e,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11680, 0x116b5,
+ 0x116b8, 0x116b8,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172a,
+ 0x11740, 0x11746,
+ 0x11800, 0x11838,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x1193c,
+ 0x1193f, 0x11942,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119df,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e4,
+ 0x11a00, 0x11a32,
+ 0x11a35, 0x11a3e,
+ 0x11a50, 0x11a97,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be0,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d46, 0x11d47,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d96,
+ 0x11d98, 0x11d98,
+ 0x11db0, 0x11ddb,
+ 0x11ee0, 0x11ef6,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f40,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1612e,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a70, 0x16abe,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9e, 0x1bc9e,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5f0,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e947, 0x1e947,
+ 0x1e94b, 0x1e94b,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Alpha */
+
+/* 'Blank': [[:Blank:]] */
+static const OnigCodePoint CR_Blank[] = {
+ 8,
+ 0x0009, 0x0009,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Blank */
+
+/* 'Cntrl': [[:Cntrl:]] */
+static const OnigCodePoint CR_Cntrl[] = {
+ 2,
+ 0x0000, 0x001f,
+ 0x007f, 0x009f,
+}; /* CR_Cntrl */
+
+/* 'Digit': [[:Digit:]] */
+static const OnigCodePoint CR_Digit[] = {
+ 72,
+ 0x0030, 0x0039,
+ 0x0660, 0x0669,
+ 0x06f0, 0x06f9,
+ 0x07c0, 0x07c9,
+ 0x0966, 0x096f,
+ 0x09e6, 0x09ef,
+ 0x0a66, 0x0a6f,
+ 0x0ae6, 0x0aef,
+ 0x0b66, 0x0b6f,
+ 0x0be6, 0x0bef,
+ 0x0c66, 0x0c6f,
+ 0x0ce6, 0x0cef,
+ 0x0d66, 0x0d6f,
+ 0x0de6, 0x0def,
+ 0x0e50, 0x0e59,
+ 0x0ed0, 0x0ed9,
+ 0x0f20, 0x0f29,
+ 0x1040, 0x1049,
+ 0x1090, 0x1099,
+ 0x17e0, 0x17e9,
+ 0x1810, 0x1819,
+ 0x1946, 0x194f,
+ 0x19d0, 0x19d9,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1b50, 0x1b59,
+ 0x1bb0, 0x1bb9,
+ 0x1c40, 0x1c49,
+ 0x1c50, 0x1c59,
+ 0xa620, 0xa629,
+ 0xa8d0, 0xa8d9,
+ 0xa900, 0xa909,
+ 0xa9d0, 0xa9d9,
+ 0xa9f0, 0xa9f9,
+ 0xaa50, 0xaa59,
+ 0xabf0, 0xabf9,
+ 0xff10, 0xff19,
+ 0x104a0, 0x104a9,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d49,
+ 0x11066, 0x1106f,
+ 0x110f0, 0x110f9,
+ 0x11136, 0x1113f,
+ 0x111d0, 0x111d9,
+ 0x112f0, 0x112f9,
+ 0x11450, 0x11459,
+ 0x114d0, 0x114d9,
+ 0x11650, 0x11659,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11730, 0x11739,
+ 0x118e0, 0x118e9,
+ 0x11950, 0x11959,
+ 0x11bf0, 0x11bf9,
+ 0x11c50, 0x11c59,
+ 0x11d50, 0x11d59,
+ 0x11da0, 0x11da9,
+ 0x11de0, 0x11de9,
+ 0x11f50, 0x11f59,
+ 0x16130, 0x16139,
+ 0x16a60, 0x16a69,
+ 0x16ac0, 0x16ac9,
+ 0x16b50, 0x16b59,
+ 0x16d70, 0x16d79,
+ 0x1ccf0, 0x1ccf9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e140, 0x1e149,
+ 0x1e2f0, 0x1e2f9,
+ 0x1e4f0, 0x1e4f9,
+ 0x1e5f1, 0x1e5fa,
+ 0x1e950, 0x1e959,
+ 0x1fbf0, 0x1fbf9,
+}; /* CR_Digit */
+
+/* 'Graph': [[:Graph:]] */
+static const OnigCodePoint CR_Graph[] = {
+ 741,
+ 0x0021, 0x007e,
+ 0x00a1, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x0891,
+ 0x0897, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x167f,
+ 0x1681, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c1,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2fff,
+ 0x3001, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7dc,
+ 0xa7f1, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xe000, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfdcf,
+ 0xfdf0, 0xfe19,
+ 0xfe20, 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, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10efa, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Graph */
+
+/* 'Lower': [[:Lower:]] */
+static const OnigCodePoint CR_Lower[] = {
+ 677,
+ 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,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0293,
+ 0x0296, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037a, 0x037d,
+ 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, 0x04cf,
+ 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,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0560, 0x0588,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x10ff,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1c8a, 0x1c8a,
+ 0x1d00, 0x1dbf,
+ 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, 0x1e9d,
+ 0x1e9f, 0x1e9f,
+ 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,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 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,
+ 0x2090, 0x209c,
+ 0x210a, 0x210a,
+ 0x210e, 0x210f,
+ 0x2113, 0x2113,
+ 0x212f, 0x212f,
+ 0x2134, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213d,
+ 0x2146, 0x2149,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5f,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c71, 0x2c71,
+ 0x2c73, 0x2c74,
+ 0x2c76, 0x2c7d,
+ 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,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69d,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa731,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa778,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa78e, 0xa78e,
+ 0xa791, 0xa791,
+ 0xa793, 0xa795,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7af, 0xa7af,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7b9, 0xa7b9,
+ 0xa7bb, 0xa7bb,
+ 0xa7bd, 0xa7bd,
+ 0xa7bf, 0xa7bf,
+ 0xa7c1, 0xa7c1,
+ 0xa7c3, 0xa7c3,
+ 0xa7c8, 0xa7c8,
+ 0xa7ca, 0xa7ca,
+ 0xa7cd, 0xa7cd,
+ 0xa7cf, 0xa7cf,
+ 0xa7d1, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d5,
+ 0xa7d7, 0xa7d7,
+ 0xa7d9, 0xa7d9,
+ 0xa7db, 0xa7db,
+ 0xa7f1, 0xa7f4,
+ 0xa7f6, 0xa7f6,
+ 0xa7f8, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10780, 0x10780,
+ 0x10783, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10cc0, 0x10cf2,
+ 0x10d70, 0x10d85,
+ 0x118c0, 0x118df,
+ 0x16e60, 0x16e7f,
+ 0x16ebb, 0x16ed3,
+ 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,
+ 0x1d7cb, 0x1d7cb,
+ 0x1df00, 0x1df09,
+ 0x1df0b, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e922, 0x1e943,
+}; /* CR_Lower */
+
+/* 'Print': [[:Print:]] */
+static const OnigCodePoint CR_Print[] = {
+ 737,
+ 0x0020, 0x007e,
+ 0x00a0, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x0891,
+ 0x0897, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2027,
+ 0x202a, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c1,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7dc,
+ 0xa7f1, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xe000, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfdcf,
+ 0xfdf0, 0xfe19,
+ 0xfe20, 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, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10efa, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Print */
+
+/* 'XPosixPunct': [[:Punct:]] */
+static const OnigCodePoint CR_XPosixPunct[] = {
+ 194,
+ 0x0021, 0x002f,
+ 0x003a, 0x0040,
+ 0x005b, 0x0060,
+ 0x007b, 0x007e,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00ab, 0x00ab,
+ 0x00b6, 0x00b7,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x058a,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061d, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0a76, 0x0a76,
+ 0x0af0, 0x0af0,
+ 0x0c77, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f3a, 0x0f3d,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x1400, 0x1400,
+ 0x166e, 0x166e,
+ 0x169b, 0x169c,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b4e, 0x1b4f,
+ 0x1b5a, 0x1b60,
+ 0x1b7d, 0x1b7f,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2010, 0x2027,
+ 0x2030, 0x2043,
+ 0x2045, 0x2051,
+ 0x2053, 0x205e,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x2308, 0x230b,
+ 0x2329, 0x232a,
+ 0x2768, 0x2775,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e2e,
+ 0x2e30, 0x2e4f,
+ 0x2e52, 0x2e5d,
+ 0x3001, 0x3003,
+ 0x3008, 0x3011,
+ 0x3014, 0x301f,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 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, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x10d6e, 0x10d6e,
+ 0x10ead, 0x10ead,
+ 0x10ed0, 0x10ed0,
+ 0x10f55, 0x10f59,
+ 0x10f86, 0x10f89,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c8,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x113d4, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x1144b, 0x1144f,
+ 0x1145a, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x116b9, 0x116b9,
+ 0x1173c, 0x1173e,
+ 0x1183b, 0x1183b,
+ 0x11944, 0x11946,
+ 0x119e2, 0x119e2,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11b00, 0x11b09,
+ 0x11be1, 0x11be1,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x11ef7, 0x11ef8,
+ 0x11f43, 0x11f4f,
+ 0x11fff, 0x11fff,
+ 0x12470, 0x12474,
+ 0x12ff1, 0x12ff2,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x16d6d, 0x16d6f,
+ 0x16e97, 0x16e9a,
+ 0x16fe2, 0x16fe2,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e95e, 0x1e95f,
+}; /* CR_XPosixPunct */
+
+/* 'Space': [[:Space:]] */
+static const OnigCodePoint CR_Space[] = {
+ 10,
+ 0x0009, 0x000d,
+ 0x0020, 0x0020,
+ 0x0085, 0x0085,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x2028, 0x2029,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Space */
+
+/* 'Upper': [[:Upper:]] */
+static const OnigCodePoint CR_Upper[] = {
+ 660,
+ 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,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 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,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1c89, 0x1c89,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 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,
+ 0x1e9e, 0x1e9e,
+ 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,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 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, 0x2133,
+ 0x213e, 0x213f,
+ 0x2145, 0x2145,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2f,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 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,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xa7b8, 0xa7b8,
+ 0xa7ba, 0xa7ba,
+ 0xa7bc, 0xa7bc,
+ 0xa7be, 0xa7be,
+ 0xa7c0, 0xa7c0,
+ 0xa7c2, 0xa7c2,
+ 0xa7c4, 0xa7c7,
+ 0xa7c9, 0xa7c9,
+ 0xa7cb, 0xa7cc,
+ 0xa7ce, 0xa7ce,
+ 0xa7d0, 0xa7d0,
+ 0xa7d2, 0xa7d2,
+ 0xa7d4, 0xa7d4,
+ 0xa7d6, 0xa7d6,
+ 0xa7d8, 0xa7d8,
+ 0xa7da, 0xa7da,
+ 0xa7dc, 0xa7dc,
+ 0xa7f5, 0xa7f5,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10c80, 0x10cb2,
+ 0x10d50, 0x10d65,
+ 0x118a0, 0x118bf,
+ 0x16e40, 0x16e5f,
+ 0x16ea0, 0x16eb8,
+ 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,
+ 0x1d7ca, 0x1d7ca,
+ 0x1e900, 0x1e921,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* 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[] = {
+ 802,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x07fd, 0x07fd,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x0897, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 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,
+ 0x09fc, 0x09fc,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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,
+ 0x135d, 0x135f,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x180f, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cfa,
+ 0x1d00, 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,
+ 0x200c, 0x200d,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309a,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa827,
+ 0xa82c, 0xa82c,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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, 0xfe2f,
+ 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,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d6d,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10eac,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10efa, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f50,
+ 0x10f70, 0x10f85,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11046,
+ 0x11066, 0x11075,
+ 0x1107f, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11144, 0x11147,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111c9, 0x111cc,
+ 0x111ce, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d3,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x1145e, 0x11461,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x11740, 0x11746,
+ 0x11800, 0x1183a,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11943,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e1,
+ 0x119e3, 0x119e4,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a99,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be0,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef6,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f42,
+ 0x11f50, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13440, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a70, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16d70, 0x16d79,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1ccf0, 0x1ccf9,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x1fbf0, 0x1fbf9,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0100, 0xe01ef,
+}; /* CR_Word */
+
+/* 'Alnum': [[:Alnum:]] */
+static const OnigCodePoint CR_Alnum[] = {
+ 807,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0345, 0x0345,
+ 0x0363, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0657,
+ 0x0659, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06e1, 0x06e8,
+ 0x06ed, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x073f,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0817,
+ 0x081a, 0x082c,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x0897, 0x0897,
+ 0x08a0, 0x08c9,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x093b,
+ 0x093d, 0x094c,
+ 0x094e, 0x0950,
+ 0x0955, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09f1,
+ 0x09fc, 0x09fc,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae3,
+ 0x0ae6, 0x0aef,
+ 0x0af9, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e46,
+ 0x0e4d, 0x0e4d,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb9,
+ 0x0ebb, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ecd, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f20, 0x0f29,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f83,
+ 0x0f88, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1713,
+ 0x171f, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17c8,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1810, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1abf, 0x1ac0,
+ 0x1acc, 0x1ace,
+ 0x1b00, 0x1b33,
+ 0x1b35, 0x1b43,
+ 0x1b45, 0x1b4c,
+ 0x1b50, 0x1b59,
+ 0x1b80, 0x1ba9,
+ 0x1bac, 0x1be5,
+ 0x1be7, 0x1bf1,
+ 0x1c00, 0x1c36,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1dd3, 0x1df4,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa674, 0xa67b,
+ 0xa67f, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa805,
+ 0xa807, 0xa827,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa92a,
+ 0xa930, 0xa952,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9b2,
+ 0xa9b4, 0xa9bf,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaabe,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabea,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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,
+ 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d69,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10eac,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10efa, 0x10efc,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11045,
+ 0x11066, 0x1106f,
+ 0x11071, 0x11075,
+ 0x11080, 0x110b8,
+ 0x110c2, 0x110c2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11132,
+ 0x11136, 0x1113f,
+ 0x11144, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111bf,
+ 0x111c1, 0x111c4,
+ 0x111ce, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112e8,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144a,
+ 0x11450, 0x11459,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114c1,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x1163e,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b5,
+ 0x116b8, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172a,
+ 0x11730, 0x11739,
+ 0x11740, 0x11746,
+ 0x11800, 0x11838,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x1193c,
+ 0x1193f, 0x11942,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119df,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e4,
+ 0x11a00, 0x11a32,
+ 0x11a35, 0x11a3e,
+ 0x11a50, 0x11a97,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be0,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c40, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d46, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d96,
+ 0x11d98, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef6,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f40,
+ 0x11f50, 0x11f59,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1612e,
+ 0x16130, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a70, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16d70, 0x16d79,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9e, 0x1bc9e,
+ 0x1ccf0, 0x1ccf9,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e2f0, 0x1e2f9,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e4f0, 0x1e4f9,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5fa,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e947, 0x1e947,
+ 0x1e94b, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+ 0x1fbf0, 0x1fbf9,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Alnum */
+
+/* 'ASCII': [[:ASCII:]] */
+static const OnigCodePoint CR_ASCII[] = {
+ 1,
+ 0x0000, 0x007f,
+}; /* CR_ASCII */
+
+/* 'Punct': [[:Punct:]] */
+static const OnigCodePoint CR_Punct[] = {
+ 199,
+ 0x0021, 0x0023,
+ 0x0025, 0x002a,
+ 0x002c, 0x002f,
+ 0x003a, 0x003b,
+ 0x003f, 0x0040,
+ 0x005b, 0x005d,
+ 0x005f, 0x005f,
+ 0x007b, 0x007b,
+ 0x007d, 0x007d,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00ab, 0x00ab,
+ 0x00b6, 0x00b7,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x058a,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061d, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0a76, 0x0a76,
+ 0x0af0, 0x0af0,
+ 0x0c77, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f3a, 0x0f3d,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x1400, 0x1400,
+ 0x166e, 0x166e,
+ 0x169b, 0x169c,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b4e, 0x1b4f,
+ 0x1b5a, 0x1b60,
+ 0x1b7d, 0x1b7f,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2010, 0x2027,
+ 0x2030, 0x2043,
+ 0x2045, 0x2051,
+ 0x2053, 0x205e,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x2308, 0x230b,
+ 0x2329, 0x232a,
+ 0x2768, 0x2775,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e2e,
+ 0x2e30, 0x2e4f,
+ 0x2e52, 0x2e5d,
+ 0x3001, 0x3003,
+ 0x3008, 0x3011,
+ 0x3014, 0x301f,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 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, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x10d6e, 0x10d6e,
+ 0x10ead, 0x10ead,
+ 0x10ed0, 0x10ed0,
+ 0x10f55, 0x10f59,
+ 0x10f86, 0x10f89,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c8,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x113d4, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x1144b, 0x1144f,
+ 0x1145a, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x116b9, 0x116b9,
+ 0x1173c, 0x1173e,
+ 0x1183b, 0x1183b,
+ 0x11944, 0x11946,
+ 0x119e2, 0x119e2,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11b00, 0x11b09,
+ 0x11be1, 0x11be1,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x11ef7, 0x11ef8,
+ 0x11f43, 0x11f4f,
+ 0x11fff, 0x11fff,
+ 0x12470, 0x12474,
+ 0x12ff1, 0x12ff2,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x16d6d, 0x16d6f,
+ 0x16e97, 0x16e9a,
+ 0x16fe2, 0x16fe2,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Punct */
+
+#ifdef USE_UNICODE_PROPERTIES
+/* 'Any': - */
+static const OnigCodePoint CR_Any[] = {
+ 1,
+ 0x0000, 0x10ffff,
+}; /* CR_Any */
+
+/* 'Assigned': - */
+static const OnigCodePoint CR_Assigned[] = {
+ 735,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x0891,
+ 0x0897, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c1,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7dc,
+ 0xa7f1, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfdcf,
+ 0xfdf0, 0xfe19,
+ 0xfe20, 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, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10efa, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xf0000, 0xffffd,
+ 0x100000, 0x10fffd,
+}; /* CR_Assigned */
+
+/* 'C': Major Category */
+static const OnigCodePoint CR_C[] = {
+ 741,
+ 0x0000, 0x001f,
+ 0x007f, 0x009f,
+ 0x00ad, 0x00ad,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ee,
+ 0x05f5, 0x0605,
+ 0x061c, 0x061c,
+ 0x06dd, 0x06dd,
+ 0x070e, 0x070f,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07fc,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x086f,
+ 0x0890, 0x0896,
+ 0x08e2, 0x08e2,
+ 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,
+ 0x09ff, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a77, 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,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b54,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 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, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3b,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5b,
+ 0x0c5e, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c76,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdb,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf4, 0x0cff,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d80,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e85,
+ 0x0e8b, 0x0e8b,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ecf, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 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, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x1716, 0x171e,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x180e, 0x180e,
+ 0x181a, 0x181f,
+ 0x1879, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1ade, 0x1adf,
+ 0x1aec, 0x1aff,
+ 0x1b4d, 0x1b4d,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c8b, 0x1c8f,
+ 0x1cbb, 0x1cbc,
+ 0x1cc8, 0x1ccf,
+ 0x1cfb, 0x1cff,
+ 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,
+ 0x209d, 0x209f,
+ 0x20c2, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x242a, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e5e, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x3130, 0x3130,
+ 0x318f, 0x318f,
+ 0x31e6, 0x31ee,
+ 0x321f, 0x321f,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7dd, 0xa7f0,
+ 0xa82d, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab6c, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xf8ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfdd0, 0xfdef,
+ 0xfe1a, 0xfe1f,
+ 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,
+ 0x1018f, 0x1018f,
+ 0x1019d, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x1057b, 0x1057b,
+ 0x1058b, 0x1058b,
+ 0x10593, 0x10593,
+ 0x10596, 0x10596,
+ 0x105a2, 0x105a2,
+ 0x105b2, 0x105b2,
+ 0x105ba, 0x105ba,
+ 0x105bd, 0x105bf,
+ 0x105f4, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x1077f,
+ 0x10786, 0x10786,
+ 0x107b1, 0x107b1,
+ 0x107bb, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x1095a, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a36, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a49, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d28, 0x10d2f,
+ 0x10d3a, 0x10d3f,
+ 0x10d66, 0x10d68,
+ 0x10d86, 0x10d8d,
+ 0x10d90, 0x10e5f,
+ 0x10e7f, 0x10e7f,
+ 0x10eaa, 0x10eaa,
+ 0x10eae, 0x10eaf,
+ 0x10eb2, 0x10ec1,
+ 0x10ec8, 0x10ecf,
+ 0x10ed9, 0x10ef9,
+ 0x10f28, 0x10f2f,
+ 0x10f5a, 0x10f6f,
+ 0x10f8a, 0x10faf,
+ 0x10fcc, 0x10fdf,
+ 0x10ff7, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11076, 0x1107e,
+ 0x110bd, 0x110bd,
+ 0x110c3, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11148, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x11242, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133a,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x1137f,
+ 0x1138a, 0x1138a,
+ 0x1138c, 0x1138d,
+ 0x1138f, 0x1138f,
+ 0x113b6, 0x113b6,
+ 0x113c1, 0x113c1,
+ 0x113c3, 0x113c4,
+ 0x113c6, 0x113c6,
+ 0x113cb, 0x113cb,
+ 0x113d6, 0x113d6,
+ 0x113d9, 0x113e0,
+ 0x113e3, 0x113ff,
+ 0x1145c, 0x1145c,
+ 0x11462, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116ba, 0x116bf,
+ 0x116ca, 0x116cf,
+ 0x116e4, 0x116ff,
+ 0x1171b, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11747, 0x117ff,
+ 0x1183c, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11907, 0x11908,
+ 0x1190a, 0x1190b,
+ 0x11914, 0x11914,
+ 0x11917, 0x11917,
+ 0x11936, 0x11936,
+ 0x11939, 0x1193a,
+ 0x11947, 0x1194f,
+ 0x1195a, 0x1199f,
+ 0x119a8, 0x119a9,
+ 0x119d8, 0x119d9,
+ 0x119e5, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11aa3, 0x11aaf,
+ 0x11af9, 0x11aff,
+ 0x11b0a, 0x11b5f,
+ 0x11b68, 0x11bbf,
+ 0x11be2, 0x11bef,
+ 0x11bfa, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11d5f,
+ 0x11d66, 0x11d66,
+ 0x11d69, 0x11d69,
+ 0x11d8f, 0x11d8f,
+ 0x11d92, 0x11d92,
+ 0x11d99, 0x11d9f,
+ 0x11daa, 0x11daf,
+ 0x11ddc, 0x11ddf,
+ 0x11dea, 0x11edf,
+ 0x11ef9, 0x11eff,
+ 0x11f11, 0x11f11,
+ 0x11f3b, 0x11f3d,
+ 0x11f5b, 0x11faf,
+ 0x11fb1, 0x11fbf,
+ 0x11ff2, 0x11ffe,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12f8f,
+ 0x12ff3, 0x12fff,
+ 0x13430, 0x1343f,
+ 0x13456, 0x1345f,
+ 0x143fb, 0x143ff,
+ 0x14647, 0x160ff,
+ 0x1613a, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16abf, 0x16abf,
+ 0x16aca, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16d3f,
+ 0x16d7a, 0x16e3f,
+ 0x16e9b, 0x16e9f,
+ 0x16eb9, 0x16eba,
+ 0x16ed4, 0x16eff,
+ 0x16f4b, 0x16f4e,
+ 0x16f88, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe5, 0x16fef,
+ 0x16ff7, 0x16fff,
+ 0x18cd6, 0x18cfe,
+ 0x18d1f, 0x18d7f,
+ 0x18df3, 0x1afef,
+ 0x1aff4, 0x1aff4,
+ 0x1affc, 0x1affc,
+ 0x1afff, 0x1afff,
+ 0x1b123, 0x1b131,
+ 0x1b133, 0x1b14f,
+ 0x1b153, 0x1b154,
+ 0x1b156, 0x1b163,
+ 0x1b168, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca0, 0x1cbff,
+ 0x1ccfd, 0x1ccff,
+ 0x1ceb4, 0x1ceb9,
+ 0x1ced1, 0x1cedf,
+ 0x1cef1, 0x1ceff,
+ 0x1cf2e, 0x1cf2f,
+ 0x1cf47, 0x1cf4f,
+ 0x1cfc4, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d173, 0x1d17a,
+ 0x1d1eb, 0x1d1ff,
+ 0x1d246, 0x1d2bf,
+ 0x1d2d4, 0x1d2df,
+ 0x1d2f4, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d379, 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,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1deff,
+ 0x1df1f, 0x1df24,
+ 0x1df2b, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e02f,
+ 0x1e06e, 0x1e08e,
+ 0x1e090, 0x1e0ff,
+ 0x1e12d, 0x1e12f,
+ 0x1e13e, 0x1e13f,
+ 0x1e14a, 0x1e14d,
+ 0x1e150, 0x1e28f,
+ 0x1e2af, 0x1e2bf,
+ 0x1e2fa, 0x1e2fe,
+ 0x1e300, 0x1e4cf,
+ 0x1e4fa, 0x1e5cf,
+ 0x1e5fb, 0x1e5fe,
+ 0x1e600, 0x1e6bf,
+ 0x1e6df, 0x1e6df,
+ 0x1e6f6, 0x1e6fd,
+ 0x1e700, 0x1e7df,
+ 0x1e7e7, 0x1e7e7,
+ 0x1e7ec, 0x1e7ec,
+ 0x1e7ef, 0x1e7ef,
+ 0x1e7ff, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94c, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1ec70,
+ 0x1ecb5, 0x1ed00,
+ 0x1ed3e, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f1ae, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d9, 0x1f6db,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6fd, 0x1f6ff,
+ 0x1f7da, 0x1f7df,
+ 0x1f7ec, 0x1f7ef,
+ 0x1f7f1, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8af,
+ 0x1f8bc, 0x1f8bf,
+ 0x1f8c2, 0x1f8cf,
+ 0x1f8d9, 0x1f8ff,
+ 0x1fa58, 0x1fa5f,
+ 0x1fa6e, 0x1fa6f,
+ 0x1fa7d, 0x1fa7f,
+ 0x1fa8b, 0x1fa8d,
+ 0x1fac7, 0x1fac7,
+ 0x1fac9, 0x1facc,
+ 0x1fadd, 0x1fade,
+ 0x1faeb, 0x1faee,
+ 0x1faf9, 0x1faff,
+ 0x1fb93, 0x1fb93,
+ 0x1fbfb, 0x1ffff,
+ 0x2a6e0, 0x2a6ff,
+ 0x2b81e, 0x2b81f,
+ 0x2ceae, 0x2ceaf,
+ 0x2ebe1, 0x2ebef,
+ 0x2ee5e, 0x2f7ff,
+ 0x2fa1e, 0x2ffff,
+ 0x3134b, 0x3134f,
+ 0x3347a, 0xe00ff,
+ 0xe01f0, 0x10ffff,
+}; /* CR_C */
+
+/* 'Cc': General Category */
+#define CR_Cc CR_Cntrl
+
+/* 'Cf': General Category */
+static const OnigCodePoint CR_Cf[] = {
+ 21,
+ 0x00ad, 0x00ad,
+ 0x0600, 0x0605,
+ 0x061c, 0x061c,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x0890, 0x0891,
+ 0x08e2, 0x08e2,
+ 0x180e, 0x180e,
+ 0x200b, 0x200f,
+ 0x202a, 0x202e,
+ 0x2060, 0x2064,
+ 0x2066, 0x206f,
+ 0xfeff, 0xfeff,
+ 0xfff9, 0xfffb,
+ 0x110bd, 0x110bd,
+ 0x110cd, 0x110cd,
+ 0x13430, 0x1343f,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+}; /* CR_Cf */
+
+/* 'Cn': General Category */
+static const OnigCodePoint CR_Cn[] = {
+ 735,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ee,
+ 0x05f5, 0x05ff,
+ 0x070e, 0x070e,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07fc,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x086f,
+ 0x0892, 0x0896,
+ 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,
+ 0x09ff, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a77, 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,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b54,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 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, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3b,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5b,
+ 0x0c5e, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c76,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdb,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf4, 0x0cff,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d80,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e85,
+ 0x0e8b, 0x0e8b,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ecf, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 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, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x1716, 0x171e,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x181a, 0x181f,
+ 0x1879, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1ade, 0x1adf,
+ 0x1aec, 0x1aff,
+ 0x1b4d, 0x1b4d,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c8b, 0x1c8f,
+ 0x1cbb, 0x1cbc,
+ 0x1cc8, 0x1ccf,
+ 0x1cfb, 0x1cff,
+ 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,
+ 0x2065, 0x2065,
+ 0x2072, 0x2073,
+ 0x208f, 0x208f,
+ 0x209d, 0x209f,
+ 0x20c2, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x242a, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e5e, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x3130, 0x3130,
+ 0x318f, 0x318f,
+ 0x31e6, 0x31ee,
+ 0x321f, 0x321f,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7dd, 0xa7f0,
+ 0xa82d, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab6c, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xd7ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfdd0, 0xfdef,
+ 0xfe1a, 0xfe1f,
+ 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,
+ 0x1018f, 0x1018f,
+ 0x1019d, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x1057b, 0x1057b,
+ 0x1058b, 0x1058b,
+ 0x10593, 0x10593,
+ 0x10596, 0x10596,
+ 0x105a2, 0x105a2,
+ 0x105b2, 0x105b2,
+ 0x105ba, 0x105ba,
+ 0x105bd, 0x105bf,
+ 0x105f4, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x1077f,
+ 0x10786, 0x10786,
+ 0x107b1, 0x107b1,
+ 0x107bb, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x1095a, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a36, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a49, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d28, 0x10d2f,
+ 0x10d3a, 0x10d3f,
+ 0x10d66, 0x10d68,
+ 0x10d86, 0x10d8d,
+ 0x10d90, 0x10e5f,
+ 0x10e7f, 0x10e7f,
+ 0x10eaa, 0x10eaa,
+ 0x10eae, 0x10eaf,
+ 0x10eb2, 0x10ec1,
+ 0x10ec8, 0x10ecf,
+ 0x10ed9, 0x10ef9,
+ 0x10f28, 0x10f2f,
+ 0x10f5a, 0x10f6f,
+ 0x10f8a, 0x10faf,
+ 0x10fcc, 0x10fdf,
+ 0x10ff7, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11076, 0x1107e,
+ 0x110c3, 0x110cc,
+ 0x110ce, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11148, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x11242, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133a,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x1137f,
+ 0x1138a, 0x1138a,
+ 0x1138c, 0x1138d,
+ 0x1138f, 0x1138f,
+ 0x113b6, 0x113b6,
+ 0x113c1, 0x113c1,
+ 0x113c3, 0x113c4,
+ 0x113c6, 0x113c6,
+ 0x113cb, 0x113cb,
+ 0x113d6, 0x113d6,
+ 0x113d9, 0x113e0,
+ 0x113e3, 0x113ff,
+ 0x1145c, 0x1145c,
+ 0x11462, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116ba, 0x116bf,
+ 0x116ca, 0x116cf,
+ 0x116e4, 0x116ff,
+ 0x1171b, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11747, 0x117ff,
+ 0x1183c, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11907, 0x11908,
+ 0x1190a, 0x1190b,
+ 0x11914, 0x11914,
+ 0x11917, 0x11917,
+ 0x11936, 0x11936,
+ 0x11939, 0x1193a,
+ 0x11947, 0x1194f,
+ 0x1195a, 0x1199f,
+ 0x119a8, 0x119a9,
+ 0x119d8, 0x119d9,
+ 0x119e5, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11aa3, 0x11aaf,
+ 0x11af9, 0x11aff,
+ 0x11b0a, 0x11b5f,
+ 0x11b68, 0x11bbf,
+ 0x11be2, 0x11bef,
+ 0x11bfa, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11d5f,
+ 0x11d66, 0x11d66,
+ 0x11d69, 0x11d69,
+ 0x11d8f, 0x11d8f,
+ 0x11d92, 0x11d92,
+ 0x11d99, 0x11d9f,
+ 0x11daa, 0x11daf,
+ 0x11ddc, 0x11ddf,
+ 0x11dea, 0x11edf,
+ 0x11ef9, 0x11eff,
+ 0x11f11, 0x11f11,
+ 0x11f3b, 0x11f3d,
+ 0x11f5b, 0x11faf,
+ 0x11fb1, 0x11fbf,
+ 0x11ff2, 0x11ffe,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12f8f,
+ 0x12ff3, 0x12fff,
+ 0x13456, 0x1345f,
+ 0x143fb, 0x143ff,
+ 0x14647, 0x160ff,
+ 0x1613a, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16abf, 0x16abf,
+ 0x16aca, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16d3f,
+ 0x16d7a, 0x16e3f,
+ 0x16e9b, 0x16e9f,
+ 0x16eb9, 0x16eba,
+ 0x16ed4, 0x16eff,
+ 0x16f4b, 0x16f4e,
+ 0x16f88, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe5, 0x16fef,
+ 0x16ff7, 0x16fff,
+ 0x18cd6, 0x18cfe,
+ 0x18d1f, 0x18d7f,
+ 0x18df3, 0x1afef,
+ 0x1aff4, 0x1aff4,
+ 0x1affc, 0x1affc,
+ 0x1afff, 0x1afff,
+ 0x1b123, 0x1b131,
+ 0x1b133, 0x1b14f,
+ 0x1b153, 0x1b154,
+ 0x1b156, 0x1b163,
+ 0x1b168, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca4, 0x1cbff,
+ 0x1ccfd, 0x1ccff,
+ 0x1ceb4, 0x1ceb9,
+ 0x1ced1, 0x1cedf,
+ 0x1cef1, 0x1ceff,
+ 0x1cf2e, 0x1cf2f,
+ 0x1cf47, 0x1cf4f,
+ 0x1cfc4, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d1eb, 0x1d1ff,
+ 0x1d246, 0x1d2bf,
+ 0x1d2d4, 0x1d2df,
+ 0x1d2f4, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d379, 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,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1deff,
+ 0x1df1f, 0x1df24,
+ 0x1df2b, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e02f,
+ 0x1e06e, 0x1e08e,
+ 0x1e090, 0x1e0ff,
+ 0x1e12d, 0x1e12f,
+ 0x1e13e, 0x1e13f,
+ 0x1e14a, 0x1e14d,
+ 0x1e150, 0x1e28f,
+ 0x1e2af, 0x1e2bf,
+ 0x1e2fa, 0x1e2fe,
+ 0x1e300, 0x1e4cf,
+ 0x1e4fa, 0x1e5cf,
+ 0x1e5fb, 0x1e5fe,
+ 0x1e600, 0x1e6bf,
+ 0x1e6df, 0x1e6df,
+ 0x1e6f6, 0x1e6fd,
+ 0x1e700, 0x1e7df,
+ 0x1e7e7, 0x1e7e7,
+ 0x1e7ec, 0x1e7ec,
+ 0x1e7ef, 0x1e7ef,
+ 0x1e7ff, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94c, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1ec70,
+ 0x1ecb5, 0x1ed00,
+ 0x1ed3e, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f1ae, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d9, 0x1f6db,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6fd, 0x1f6ff,
+ 0x1f7da, 0x1f7df,
+ 0x1f7ec, 0x1f7ef,
+ 0x1f7f1, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8af,
+ 0x1f8bc, 0x1f8bf,
+ 0x1f8c2, 0x1f8cf,
+ 0x1f8d9, 0x1f8ff,
+ 0x1fa58, 0x1fa5f,
+ 0x1fa6e, 0x1fa6f,
+ 0x1fa7d, 0x1fa7f,
+ 0x1fa8b, 0x1fa8d,
+ 0x1fac7, 0x1fac7,
+ 0x1fac9, 0x1facc,
+ 0x1fadd, 0x1fade,
+ 0x1faeb, 0x1faee,
+ 0x1faf9, 0x1faff,
+ 0x1fb93, 0x1fb93,
+ 0x1fbfb, 0x1ffff,
+ 0x2a6e0, 0x2a6ff,
+ 0x2b81e, 0x2b81f,
+ 0x2ceae, 0x2ceaf,
+ 0x2ebe1, 0x2ebef,
+ 0x2ee5e, 0x2f7ff,
+ 0x2fa1e, 0x2ffff,
+ 0x3134b, 0x3134f,
+ 0x3347a, 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[] = {
+ 684,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x08a0, 0x08c9,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 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,
+ 0x0af9, 0x0af9,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d04, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16f1, 0x16f8,
+ 0x1700, 0x1711,
+ 0x171f, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1878,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4c,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2183, 0x2184,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3006,
+ 0x3031, 0x3035,
+ 0x303b, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6e5,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fe,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x10340,
+ 0x10342, 0x10349,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d23,
+ 0x10d4a, 0x10d65,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11003, 0x11037,
+ 0x11071, 0x11072,
+ 0x11075, 0x11075,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11144, 0x11144,
+ 0x11147, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x1123f, 0x11240,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113b7,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x116b8, 0x116b8,
+ 0x11700, 0x1171a,
+ 0x11740, 0x11746,
+ 0x11800, 0x1182b,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x1193f, 0x1193f,
+ 0x11941, 0x11941,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d0,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e3,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a89,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11bc0, 0x11be0,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d89,
+ 0x11d98, 0x11d98,
+ 0x11db0, 0x11ddb,
+ 0x11ee0, 0x11ef2,
+ 0x11f02, 0x11f02,
+ 0x11f04, 0x11f10,
+ 0x11f12, 0x11f33,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1611d,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a70, 0x16abe,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff2, 0x16ff3,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5f0,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6e2,
+ 0x1e6e4, 0x1e6e5,
+ 0x1e6e7, 0x1e6ed,
+ 0x1e6f0, 0x1e6f4,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e94b, 0x1e94b,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_L */
+
+/* 'LC': General Category */
+static const OnigCodePoint CR_LC[] = {
+ 144,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x01ba,
+ 0x01bc, 0x01bf,
+ 0x01c4, 0x0293,
+ 0x0296, 0x02af,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0560, 0x0588,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fd, 0x10ff,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1d00, 0x1d2b,
+ 0x1d6b, 0x1d77,
+ 0x1d79, 0x1d9a,
+ 0x1e00, 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,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2183, 0x2184,
+ 0x2c00, 0x2c7b,
+ 0x2c7e, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69b,
+ 0xa722, 0xa76f,
+ 0xa771, 0xa787,
+ 0xa78b, 0xa78e,
+ 0xa790, 0xa7dc,
+ 0xa7f5, 0xa7f6,
+ 0xa7fa, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab60, 0xab68,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d50, 0x10d65,
+ 0x10d70, 0x10d85,
+ 0x118a0, 0x118df,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df09,
+ 0x1df0b, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e900, 0x1e943,
+}; /* CR_LC */
+
+/* 'Ll': General Category */
+static const OnigCodePoint CR_Ll[] = {
+ 664,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 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,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0293,
+ 0x0296, 0x02af,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 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, 0x04cf,
+ 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,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0560, 0x0588,
+ 0x10d0, 0x10fa,
+ 0x10fd, 0x10ff,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1c8a, 0x1c8a,
+ 0x1d00, 0x1d2b,
+ 0x1d6b, 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, 0x1e9d,
+ 0x1e9f, 0x1e9f,
+ 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,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 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,
+ 0x210a, 0x210a,
+ 0x210e, 0x210f,
+ 0x2113, 0x2113,
+ 0x212f, 0x212f,
+ 0x2134, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213d,
+ 0x2146, 0x2149,
+ 0x214e, 0x214e,
+ 0x2184, 0x2184,
+ 0x2c30, 0x2c5f,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c71, 0x2c71,
+ 0x2c73, 0x2c74,
+ 0x2c76, 0x2c7b,
+ 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,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa731,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa771, 0xa778,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa78e, 0xa78e,
+ 0xa791, 0xa791,
+ 0xa793, 0xa795,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7af, 0xa7af,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7b9, 0xa7b9,
+ 0xa7bb, 0xa7bb,
+ 0xa7bd, 0xa7bd,
+ 0xa7bf, 0xa7bf,
+ 0xa7c1, 0xa7c1,
+ 0xa7c3, 0xa7c3,
+ 0xa7c8, 0xa7c8,
+ 0xa7ca, 0xa7ca,
+ 0xa7cd, 0xa7cd,
+ 0xa7cf, 0xa7cf,
+ 0xa7d1, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d5,
+ 0xa7d7, 0xa7d7,
+ 0xa7d9, 0xa7d9,
+ 0xa7db, 0xa7db,
+ 0xa7f6, 0xa7f6,
+ 0xa7fa, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab60, 0xab68,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10cc0, 0x10cf2,
+ 0x10d70, 0x10d85,
+ 0x118c0, 0x118df,
+ 0x16e60, 0x16e7f,
+ 0x16ebb, 0x16ed3,
+ 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,
+ 0x1d7cb, 0x1d7cb,
+ 0x1df00, 0x1df09,
+ 0x1df0b, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e922, 0x1e943,
+}; /* CR_Ll */
+
+/* 'Lm': General Category */
+static const OnigCodePoint CR_Lm[] = {
+ 79,
+ 0x02b0, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0374, 0x0374,
+ 0x037a, 0x037a,
+ 0x0559, 0x0559,
+ 0x0640, 0x0640,
+ 0x06e5, 0x06e6,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x08c9, 0x08c9,
+ 0x0971, 0x0971,
+ 0x0e46, 0x0e46,
+ 0x0ec6, 0x0ec6,
+ 0x10fc, 0x10fc,
+ 0x17d7, 0x17d7,
+ 0x1843, 0x1843,
+ 0x1aa7, 0x1aa7,
+ 0x1c78, 0x1c7d,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1dbf,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2c7c, 0x2c7d,
+ 0x2d6f, 0x2d6f,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3005,
+ 0x3031, 0x3035,
+ 0x303b, 0x303b,
+ 0x309d, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa4f8, 0xa4fd,
+ 0xa60c, 0xa60c,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69d,
+ 0xa717, 0xa71f,
+ 0xa770, 0xa770,
+ 0xa788, 0xa788,
+ 0xa7f1, 0xa7f4,
+ 0xa7f8, 0xa7f9,
+ 0xa9cf, 0xa9cf,
+ 0xa9e6, 0xa9e6,
+ 0xaa70, 0xaa70,
+ 0xaadd, 0xaadd,
+ 0xaaf3, 0xaaf4,
+ 0xab5c, 0xab5f,
+ 0xab69, 0xab69,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10d4e, 0x10d4e,
+ 0x10d6f, 0x10d6f,
+ 0x10ec5, 0x10ec5,
+ 0x11dd9, 0x11dd9,
+ 0x16b40, 0x16b43,
+ 0x16d40, 0x16d42,
+ 0x16d6b, 0x16d6c,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff2, 0x16ff3,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1e030, 0x1e06d,
+ 0x1e137, 0x1e13d,
+ 0x1e4eb, 0x1e4eb,
+ 0x1e6ff, 0x1e6ff,
+ 0x1e94b, 0x1e94b,
+}; /* CR_Lm */
+
+/* 'Lo': General Category */
+static const OnigCodePoint CR_Lo[] = {
+ 537,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x01bb, 0x01bb,
+ 0x01c0, 0x01c3,
+ 0x0294, 0x0295,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0620, 0x063f,
+ 0x0641, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x0800, 0x0815,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x08a0, 0x08c8,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0972, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 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,
+ 0x0af9, 0x0af9,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d04, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e45,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x1100, 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,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16f1, 0x16f8,
+ 0x1700, 0x1711,
+ 0x171f, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1842,
+ 0x1844, 0x1878,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4c,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c77,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x2135, 0x2138,
+ 0x2d30, 0x2d67,
+ 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, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa014,
+ 0xa016, 0xa48c,
+ 0xa4d0, 0xa4f7,
+ 0xa500, 0xa60b,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa66e, 0xa66e,
+ 0xa6a0, 0xa6e5,
+ 0xa78f, 0xa78f,
+ 0xa7f7, 0xa7f7,
+ 0xa7fb, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fe,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9e0, 0xa9e4,
+ 0xa9e7, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa6f,
+ 0xaa71, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadc,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf2,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x10340,
+ 0x10342, 0x10349,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x10450, 0x1049d,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10d00, 0x10d23,
+ 0x10d4a, 0x10d4d,
+ 0x10d4f, 0x10d4f,
+ 0x10e80, 0x10ea9,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec4,
+ 0x10ec6, 0x10ec7,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11003, 0x11037,
+ 0x11071, 0x11072,
+ 0x11075, 0x11075,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11144, 0x11144,
+ 0x11147, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x1123f, 0x11240,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113b7,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x116b8, 0x116b8,
+ 0x11700, 0x1171a,
+ 0x11740, 0x11746,
+ 0x11800, 0x1182b,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x1193f, 0x1193f,
+ 0x11941, 0x11941,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d0,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e3,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a89,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11bc0, 0x11be0,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d89,
+ 0x11d98, 0x11d98,
+ 0x11db0, 0x11dd8,
+ 0x11dda, 0x11ddb,
+ 0x11ee0, 0x11ef2,
+ 0x11f02, 0x11f02,
+ 0x11f04, 0x11f10,
+ 0x11f12, 0x11f33,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1611d,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a70, 0x16abe,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d43, 0x16d6a,
+ 0x16f00, 0x16f4a,
+ 0x16f50, 0x16f50,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1df0a, 0x1df0a,
+ 0x1e100, 0x1e12c,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e4d0, 0x1e4ea,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5f0,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6e2,
+ 0x1e6e4, 0x1e6e5,
+ 0x1e6e7, 0x1e6ed,
+ 0x1e6f0, 0x1e6f4,
+ 0x1e6fe, 0x1e6fe,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* 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[] = {
+ 655,
+ 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,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 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,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1c89, 0x1c89,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 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,
+ 0x1e9e, 0x1e9e,
+ 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,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 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, 0x2133,
+ 0x213e, 0x213f,
+ 0x2145, 0x2145,
+ 0x2183, 0x2183,
+ 0x2c00, 0x2c2f,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 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,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xa7b8, 0xa7b8,
+ 0xa7ba, 0xa7ba,
+ 0xa7bc, 0xa7bc,
+ 0xa7be, 0xa7be,
+ 0xa7c0, 0xa7c0,
+ 0xa7c2, 0xa7c2,
+ 0xa7c4, 0xa7c7,
+ 0xa7c9, 0xa7c9,
+ 0xa7cb, 0xa7cc,
+ 0xa7ce, 0xa7ce,
+ 0xa7d0, 0xa7d0,
+ 0xa7d2, 0xa7d2,
+ 0xa7d4, 0xa7d4,
+ 0xa7d6, 0xa7d6,
+ 0xa7d8, 0xa7d8,
+ 0xa7da, 0xa7da,
+ 0xa7dc, 0xa7dc,
+ 0xa7f5, 0xa7f5,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10c80, 0x10cb2,
+ 0x10d50, 0x10d65,
+ 0x118a0, 0x118bf,
+ 0x16e40, 0x16e5f,
+ 0x16ea0, 0x16eb8,
+ 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,
+ 0x1d7ca, 0x1d7ca,
+ 0x1e900, 0x1e921,
+}; /* CR_Lu */
+
+/* 'M': Major Category */
+static const OnigCodePoint CR_M[] = {
+ 327,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x0897, 0x089f,
+ 0x08ca, 0x08e1,
+ 0x08e3, 0x0903,
+ 0x093a, 0x093c,
+ 0x093e, 0x094f,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0983,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0abc, 0x0abc,
+ 0x0abe, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c83,
+ 0x0cbc, 0x0cbc,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0cf3, 0x0cf3,
+ 0x0d00, 0x0d03,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d83,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f3f,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102b, 0x103e,
+ 0x1056, 0x1059,
+ 0x105e, 0x1060,
+ 0x1062, 0x1064,
+ 0x1067, 0x106d,
+ 0x1071, 0x1074,
+ 0x1082, 0x108d,
+ 0x108f, 0x108f,
+ 0x109a, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1715,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1a17, 0x1a1b,
+ 0x1a55, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b04,
+ 0x1b34, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b82,
+ 0x1ba1, 0x1bad,
+ 0x1be6, 0x1bf3,
+ 0x1c24, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf7, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa823, 0xa827,
+ 0xa82c, 0xa82c,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa953,
+ 0xa980, 0xa983,
+ 0xa9b3, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4d,
+ 0xaa7b, 0xaa7d,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaeb, 0xaaef,
+ 0xaaf5, 0xaaf6,
+ 0xabe3, 0xabea,
+ 0xabec, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d6d,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11000, 0x11002,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11082,
+ 0x110b0, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x11134,
+ 0x11145, 0x11146,
+ 0x11173, 0x11173,
+ 0x11180, 0x11182,
+ 0x111b3, 0x111c0,
+ 0x111c9, 0x111cc,
+ 0x111ce, 0x111cf,
+ 0x1122c, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112ea,
+ 0x11300, 0x11303,
+ 0x1133b, 0x1133c,
+ 0x1133e, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113b8, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d0,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11435, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b0, 0x114c3,
+ 0x115af, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11630, 0x11640,
+ 0x116ab, 0x116b7,
+ 0x1171d, 0x1172b,
+ 0x1182c, 0x1183a,
+ 0x11930, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x1193e,
+ 0x11940, 0x11940,
+ 0x11942, 0x11943,
+ 0x119d1, 0x119d7,
+ 0x119da, 0x119e0,
+ 0x119e4, 0x119e4,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a39,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a5b,
+ 0x11a8a, 0x11a99,
+ 0x11b60, 0x11b67,
+ 0x11c2f, 0x11c36,
+ 0x11c38, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d8a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d97,
+ 0x11ef3, 0x11ef6,
+ 0x11f00, 0x11f01,
+ 0x11f03, 0x11f03,
+ 0x11f34, 0x11f3a,
+ 0x11f3e, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13440, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f4f, 0x16f4f,
+ 0x16f51, 0x16f87,
+ 0x16f8f, 0x16f92,
+ 0x16fe4, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x1bc9d, 0x1bc9e,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4ec, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0100, 0xe01ef,
+}; /* CR_M */
+
+/* 'Mc': General Category */
+static const OnigCodePoint CR_Mc[] = {
+ 193,
+ 0x0903, 0x0903,
+ 0x093b, 0x093b,
+ 0x093e, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x094f,
+ 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,
+ 0x0cf3, 0x0cf3,
+ 0x0d02, 0x0d03,
+ 0x0d3e, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d57, 0x0d57,
+ 0x0d82, 0x0d83,
+ 0x0dcf, 0x0dd1,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0f3e, 0x0f3f,
+ 0x0f7f, 0x0f7f,
+ 0x102b, 0x102c,
+ 0x1031, 0x1031,
+ 0x1038, 0x1038,
+ 0x103b, 0x103c,
+ 0x1056, 0x1057,
+ 0x1062, 0x1064,
+ 0x1067, 0x106d,
+ 0x1083, 0x1084,
+ 0x1087, 0x108c,
+ 0x108f, 0x108f,
+ 0x109a, 0x109c,
+ 0x1715, 0x1715,
+ 0x1734, 0x1734,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1a19, 0x1a1a,
+ 0x1a55, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a61, 0x1a61,
+ 0x1a63, 0x1a64,
+ 0x1a6d, 0x1a72,
+ 0x1b04, 0x1b04,
+ 0x1b35, 0x1b35,
+ 0x1b3b, 0x1b3b,
+ 0x1b3d, 0x1b41,
+ 0x1b43, 0x1b44,
+ 0x1b82, 0x1b82,
+ 0x1ba1, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1baa, 0x1baa,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1bf2, 0x1bf3,
+ 0x1c24, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1ce1, 0x1ce1,
+ 0x1cf7, 0x1cf7,
+ 0x302e, 0x302f,
+ 0xa823, 0xa824,
+ 0xa827, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa952, 0xa953,
+ 0xa983, 0xa983,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9be, 0xa9c0,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa4d, 0xaa4d,
+ 0xaa7b, 0xaa7b,
+ 0xaa7d, 0xaa7d,
+ 0xaaeb, 0xaaeb,
+ 0xaaee, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabea,
+ 0xabec, 0xabec,
+ 0x11000, 0x11000,
+ 0x11002, 0x11002,
+ 0x11082, 0x11082,
+ 0x110b0, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x1112c, 0x1112c,
+ 0x11145, 0x11146,
+ 0x11182, 0x11182,
+ 0x111b3, 0x111b5,
+ 0x111bf, 0x111c0,
+ 0x111ce, 0x111ce,
+ 0x1122c, 0x1122e,
+ 0x11232, 0x11233,
+ 0x11235, 0x11235,
+ 0x112e0, 0x112e2,
+ 0x11302, 0x11303,
+ 0x1133e, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x113b8, 0x113ba,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x113cf, 0x113cf,
+ 0x11435, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x114b0, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x115af, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x11630, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x116b6, 0x116b6,
+ 0x1171e, 0x1171e,
+ 0x11720, 0x11721,
+ 0x11726, 0x11726,
+ 0x1182c, 0x1182e,
+ 0x11838, 0x11838,
+ 0x11930, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193d, 0x1193d,
+ 0x11940, 0x11940,
+ 0x11942, 0x11942,
+ 0x119d1, 0x119d3,
+ 0x119dc, 0x119df,
+ 0x119e4, 0x119e4,
+ 0x11a39, 0x11a39,
+ 0x11a57, 0x11a58,
+ 0x11a97, 0x11a97,
+ 0x11b61, 0x11b61,
+ 0x11b65, 0x11b65,
+ 0x11b67, 0x11b67,
+ 0x11c2f, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x11d8a, 0x11d8e,
+ 0x11d93, 0x11d94,
+ 0x11d96, 0x11d96,
+ 0x11ef5, 0x11ef6,
+ 0x11f03, 0x11f03,
+ 0x11f34, 0x11f35,
+ 0x11f3e, 0x11f3f,
+ 0x11f41, 0x11f41,
+ 0x1612a, 0x1612c,
+ 0x16f51, 0x16f87,
+ 0x16ff0, 0x16ff1,
+ 0x1d165, 0x1d166,
+ 0x1d16d, 0x1d172,
+}; /* CR_Mc */
+
+/* 'Me': General Category */
+static const OnigCodePoint CR_Me[] = {
+ 5,
+ 0x0488, 0x0489,
+ 0x1abe, 0x1abe,
+ 0x20dd, 0x20e0,
+ 0x20e2, 0x20e4,
+ 0xa670, 0xa672,
+}; /* CR_Me */
+
+/* 'Mn': General Category */
+static const OnigCodePoint CR_Mn[] = {
+ 365,
+ 0x0300, 0x036f,
+ 0x0483, 0x0487,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x0897, 0x089f,
+ 0x08ca, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3f, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b55, 0x0b56,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0c00, 0x0c00,
+ 0x0c04, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cbf,
+ 0x0cc6, 0x0cc6,
+ 0x0ccc, 0x0ccd,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d81,
+ 0x0dca, 0x0dca,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1733,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abd,
+ 0x1abf, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b34,
+ 0x1b36, 0x1b3a,
+ 0x1b3c, 0x1b3c,
+ 0x1b42, 0x1b42,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1ba9,
+ 0x1bab, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf1,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302d,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bd,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xaaf6, 0xaaf6,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d6d,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111c9, 0x111cc,
+ 0x111cf, 0x111cf,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11234,
+ 0x11236, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133b, 0x1133c,
+ 0x11340, 0x11340,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113bb, 0x113c0,
+ 0x113ce, 0x113ce,
+ 0x113d0, 0x113d0,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b5,
+ 0x116b7, 0x116b7,
+ 0x1171d, 0x1171d,
+ 0x1171f, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x1182f, 0x11837,
+ 0x11839, 0x1183a,
+ 0x1193b, 0x1193c,
+ 0x1193e, 0x1193e,
+ 0x11943, 0x11943,
+ 0x119d4, 0x119d7,
+ 0x119da, 0x119db,
+ 0x119e0, 0x119e0,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11b60, 0x11b60,
+ 0x11b62, 0x11b64,
+ 0x11b66, 0x11b66,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d90, 0x11d91,
+ 0x11d95, 0x11d95,
+ 0x11d97, 0x11d97,
+ 0x11ef3, 0x11ef4,
+ 0x11f00, 0x11f01,
+ 0x11f36, 0x11f3a,
+ 0x11f40, 0x11f40,
+ 0x11f42, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13440, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x16129,
+ 0x1612d, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f4f, 0x16f4f,
+ 0x16f8f, 0x16f92,
+ 0x16fe4, 0x16fe4,
+ 0x1bc9d, 0x1bc9e,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d167, 0x1d169,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4ec, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0100, 0xe01ef,
+}; /* CR_Mn */
+
+/* 'N': Major Category */
+static const OnigCodePoint CR_N[] = {
+ 146,
+ 0x0030, 0x0039,
+ 0x00b2, 0x00b3,
+ 0x00b9, 0x00b9,
+ 0x00bc, 0x00be,
+ 0x0660, 0x0669,
+ 0x06f0, 0x06f9,
+ 0x07c0, 0x07c9,
+ 0x0966, 0x096f,
+ 0x09e6, 0x09ef,
+ 0x09f4, 0x09f9,
+ 0x0a66, 0x0a6f,
+ 0x0ae6, 0x0aef,
+ 0x0b66, 0x0b6f,
+ 0x0b72, 0x0b77,
+ 0x0be6, 0x0bf2,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7e,
+ 0x0ce6, 0x0cef,
+ 0x0d58, 0x0d5e,
+ 0x0d66, 0x0d78,
+ 0x0de6, 0x0def,
+ 0x0e50, 0x0e59,
+ 0x0ed0, 0x0ed9,
+ 0x0f20, 0x0f33,
+ 0x1040, 0x1049,
+ 0x1090, 0x1099,
+ 0x1369, 0x137c,
+ 0x16ee, 0x16f0,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1810, 0x1819,
+ 0x1946, 0x194f,
+ 0x19d0, 0x19da,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1b50, 0x1b59,
+ 0x1bb0, 0x1bb9,
+ 0x1c40, 0x1c49,
+ 0x1c50, 0x1c59,
+ 0x2070, 0x2070,
+ 0x2074, 0x2079,
+ 0x2080, 0x2089,
+ 0x2150, 0x2182,
+ 0x2185, 0x2189,
+ 0x2460, 0x249b,
+ 0x24ea, 0x24ff,
+ 0x2776, 0x2793,
+ 0x2cfd, 0x2cfd,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0x3192, 0x3195,
+ 0x3220, 0x3229,
+ 0x3248, 0x324f,
+ 0x3251, 0x325f,
+ 0x3280, 0x3289,
+ 0x32b1, 0x32bf,
+ 0xa620, 0xa629,
+ 0xa6e6, 0xa6ef,
+ 0xa830, 0xa835,
+ 0xa8d0, 0xa8d9,
+ 0xa900, 0xa909,
+ 0xa9d0, 0xa9d9,
+ 0xa9f0, 0xa9f9,
+ 0xaa50, 0xaa59,
+ 0xabf0, 0xabf9,
+ 0xff10, 0xff19,
+ 0x10107, 0x10133,
+ 0x10140, 0x10178,
+ 0x1018a, 0x1018b,
+ 0x102e1, 0x102fb,
+ 0x10320, 0x10323,
+ 0x10341, 0x10341,
+ 0x1034a, 0x1034a,
+ 0x103d1, 0x103d5,
+ 0x104a0, 0x104a9,
+ 0x10858, 0x1085f,
+ 0x10879, 0x1087f,
+ 0x108a7, 0x108af,
+ 0x108fb, 0x108ff,
+ 0x10916, 0x1091b,
+ 0x109bc, 0x109bd,
+ 0x109c0, 0x109cf,
+ 0x109d2, 0x109ff,
+ 0x10a40, 0x10a48,
+ 0x10a7d, 0x10a7e,
+ 0x10a9d, 0x10a9f,
+ 0x10aeb, 0x10aef,
+ 0x10b58, 0x10b5f,
+ 0x10b78, 0x10b7f,
+ 0x10ba9, 0x10baf,
+ 0x10cfa, 0x10cff,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d49,
+ 0x10e60, 0x10e7e,
+ 0x10f1d, 0x10f26,
+ 0x10f51, 0x10f54,
+ 0x10fc5, 0x10fcb,
+ 0x11052, 0x1106f,
+ 0x110f0, 0x110f9,
+ 0x11136, 0x1113f,
+ 0x111d0, 0x111d9,
+ 0x111e1, 0x111f4,
+ 0x112f0, 0x112f9,
+ 0x11450, 0x11459,
+ 0x114d0, 0x114d9,
+ 0x11650, 0x11659,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11730, 0x1173b,
+ 0x118e0, 0x118f2,
+ 0x11950, 0x11959,
+ 0x11bf0, 0x11bf9,
+ 0x11c50, 0x11c6c,
+ 0x11d50, 0x11d59,
+ 0x11da0, 0x11da9,
+ 0x11de0, 0x11de9,
+ 0x11f50, 0x11f59,
+ 0x11fc0, 0x11fd4,
+ 0x12400, 0x1246e,
+ 0x16130, 0x16139,
+ 0x16a60, 0x16a69,
+ 0x16ac0, 0x16ac9,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16d70, 0x16d79,
+ 0x16e80, 0x16e96,
+ 0x16ff4, 0x16ff6,
+ 0x1ccf0, 0x1ccf9,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d360, 0x1d378,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e140, 0x1e149,
+ 0x1e2f0, 0x1e2f9,
+ 0x1e4f0, 0x1e4f9,
+ 0x1e5f1, 0x1e5fa,
+ 0x1e8c7, 0x1e8cf,
+ 0x1e950, 0x1e959,
+ 0x1ec71, 0x1ecab,
+ 0x1ecad, 0x1ecaf,
+ 0x1ecb1, 0x1ecb4,
+ 0x1ed01, 0x1ed2d,
+ 0x1ed2f, 0x1ed3d,
+ 0x1f100, 0x1f10c,
+ 0x1fbf0, 0x1fbf9,
+}; /* CR_N */
+
+/* 'Nd': General Category */
+#define CR_Nd CR_Digit
+
+/* 'Nl': General Category */
+static const OnigCodePoint CR_Nl[] = {
+ 13,
+ 0x16ee, 0x16f0,
+ 0x2160, 0x2182,
+ 0x2185, 0x2188,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0xa6e6, 0xa6ef,
+ 0x10140, 0x10174,
+ 0x10341, 0x10341,
+ 0x1034a, 0x1034a,
+ 0x103d1, 0x103d5,
+ 0x12400, 0x1246e,
+ 0x16ff4, 0x16ff6,
+}; /* CR_Nl */
+
+/* 'No': General Category */
+static const OnigCodePoint CR_No[] = {
+ 72,
+ 0x00b2, 0x00b3,
+ 0x00b9, 0x00b9,
+ 0x00bc, 0x00be,
+ 0x09f4, 0x09f9,
+ 0x0b72, 0x0b77,
+ 0x0bf0, 0x0bf2,
+ 0x0c78, 0x0c7e,
+ 0x0d58, 0x0d5e,
+ 0x0d70, 0x0d78,
+ 0x0f2a, 0x0f33,
+ 0x1369, 0x137c,
+ 0x17f0, 0x17f9,
+ 0x19da, 0x19da,
+ 0x2070, 0x2070,
+ 0x2074, 0x2079,
+ 0x2080, 0x2089,
+ 0x2150, 0x215f,
+ 0x2189, 0x2189,
+ 0x2460, 0x249b,
+ 0x24ea, 0x24ff,
+ 0x2776, 0x2793,
+ 0x2cfd, 0x2cfd,
+ 0x3192, 0x3195,
+ 0x3220, 0x3229,
+ 0x3248, 0x324f,
+ 0x3251, 0x325f,
+ 0x3280, 0x3289,
+ 0x32b1, 0x32bf,
+ 0xa830, 0xa835,
+ 0x10107, 0x10133,
+ 0x10175, 0x10178,
+ 0x1018a, 0x1018b,
+ 0x102e1, 0x102fb,
+ 0x10320, 0x10323,
+ 0x10858, 0x1085f,
+ 0x10879, 0x1087f,
+ 0x108a7, 0x108af,
+ 0x108fb, 0x108ff,
+ 0x10916, 0x1091b,
+ 0x109bc, 0x109bd,
+ 0x109c0, 0x109cf,
+ 0x109d2, 0x109ff,
+ 0x10a40, 0x10a48,
+ 0x10a7d, 0x10a7e,
+ 0x10a9d, 0x10a9f,
+ 0x10aeb, 0x10aef,
+ 0x10b58, 0x10b5f,
+ 0x10b78, 0x10b7f,
+ 0x10ba9, 0x10baf,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x10f1d, 0x10f26,
+ 0x10f51, 0x10f54,
+ 0x10fc5, 0x10fcb,
+ 0x11052, 0x11065,
+ 0x111e1, 0x111f4,
+ 0x1173a, 0x1173b,
+ 0x118ea, 0x118f2,
+ 0x11c5a, 0x11c6c,
+ 0x11fc0, 0x11fd4,
+ 0x16b5b, 0x16b61,
+ 0x16e80, 0x16e96,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d360, 0x1d378,
+ 0x1e8c7, 0x1e8cf,
+ 0x1ec71, 0x1ecab,
+ 0x1ecad, 0x1ecaf,
+ 0x1ecb1, 0x1ecb4,
+ 0x1ed01, 0x1ed2d,
+ 0x1ed2f, 0x1ed3d,
+ 0x1f100, 0x1f10c,
+}; /* CR_No */
+
+/* 'P': Major Category */
+#define CR_P CR_Punct
+
+/* '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[] = {
+ 20,
+ 0x002d, 0x002d,
+ 0x058a, 0x058a,
+ 0x05be, 0x05be,
+ 0x1400, 0x1400,
+ 0x1806, 0x1806,
+ 0x2010, 0x2015,
+ 0x2e17, 0x2e17,
+ 0x2e1a, 0x2e1a,
+ 0x2e3a, 0x2e3b,
+ 0x2e40, 0x2e40,
+ 0x2e5d, 0x2e5d,
+ 0x301c, 0x301c,
+ 0x3030, 0x3030,
+ 0x30a0, 0x30a0,
+ 0xfe31, 0xfe32,
+ 0xfe58, 0xfe58,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+ 0x10d6e, 0x10d6e,
+ 0x10ead, 0x10ead,
+}; /* CR_Pd */
+
+/* 'Pe': General Category */
+static const OnigCodePoint CR_Pe[] = {
+ 76,
+ 0x0029, 0x0029,
+ 0x005d, 0x005d,
+ 0x007d, 0x007d,
+ 0x0f3b, 0x0f3b,
+ 0x0f3d, 0x0f3d,
+ 0x169c, 0x169c,
+ 0x2046, 0x2046,
+ 0x207e, 0x207e,
+ 0x208e, 0x208e,
+ 0x2309, 0x2309,
+ 0x230b, 0x230b,
+ 0x232a, 0x232a,
+ 0x2769, 0x2769,
+ 0x276b, 0x276b,
+ 0x276d, 0x276d,
+ 0x276f, 0x276f,
+ 0x2771, 0x2771,
+ 0x2773, 0x2773,
+ 0x2775, 0x2775,
+ 0x27c6, 0x27c6,
+ 0x27e7, 0x27e7,
+ 0x27e9, 0x27e9,
+ 0x27eb, 0x27eb,
+ 0x27ed, 0x27ed,
+ 0x27ef, 0x27ef,
+ 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,
+ 0x2e23, 0x2e23,
+ 0x2e25, 0x2e25,
+ 0x2e27, 0x2e27,
+ 0x2e29, 0x2e29,
+ 0x2e56, 0x2e56,
+ 0x2e58, 0x2e58,
+ 0x2e5a, 0x2e5a,
+ 0x2e5c, 0x2e5c,
+ 0x3009, 0x3009,
+ 0x300b, 0x300b,
+ 0x300d, 0x300d,
+ 0x300f, 0x300f,
+ 0x3011, 0x3011,
+ 0x3015, 0x3015,
+ 0x3017, 0x3017,
+ 0x3019, 0x3019,
+ 0x301b, 0x301b,
+ 0x301e, 0x301f,
+ 0xfd3e, 0xfd3e,
+ 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[] = {
+ 10,
+ 0x00bb, 0x00bb,
+ 0x2019, 0x2019,
+ 0x201d, 0x201d,
+ 0x203a, 0x203a,
+ 0x2e03, 0x2e03,
+ 0x2e05, 0x2e05,
+ 0x2e0a, 0x2e0a,
+ 0x2e0d, 0x2e0d,
+ 0x2e1d, 0x2e1d,
+ 0x2e21, 0x2e21,
+}; /* CR_Pf */
+
+/* 'Pi': General Category */
+static const OnigCodePoint CR_Pi[] = {
+ 11,
+ 0x00ab, 0x00ab,
+ 0x2018, 0x2018,
+ 0x201b, 0x201c,
+ 0x201f, 0x201f,
+ 0x2039, 0x2039,
+ 0x2e02, 0x2e02,
+ 0x2e04, 0x2e04,
+ 0x2e09, 0x2e09,
+ 0x2e0c, 0x2e0c,
+ 0x2e1c, 0x2e1c,
+ 0x2e20, 0x2e20,
+}; /* CR_Pi */
+
+/* 'Po': General Category */
+static const OnigCodePoint CR_Po[] = {
+ 194,
+ 0x0021, 0x0023,
+ 0x0025, 0x0027,
+ 0x002a, 0x002a,
+ 0x002c, 0x002c,
+ 0x002e, 0x002f,
+ 0x003a, 0x003b,
+ 0x003f, 0x0040,
+ 0x005c, 0x005c,
+ 0x00a1, 0x00a1,
+ 0x00a7, 0x00a7,
+ 0x00b6, 0x00b7,
+ 0x00bf, 0x00bf,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x055a, 0x055f,
+ 0x0589, 0x0589,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05f3, 0x05f4,
+ 0x0609, 0x060a,
+ 0x060c, 0x060d,
+ 0x061b, 0x061b,
+ 0x061d, 0x061f,
+ 0x066a, 0x066d,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070d,
+ 0x07f7, 0x07f9,
+ 0x0830, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0970, 0x0970,
+ 0x09fd, 0x09fd,
+ 0x0a76, 0x0a76,
+ 0x0af0, 0x0af0,
+ 0x0c77, 0x0c77,
+ 0x0c84, 0x0c84,
+ 0x0df4, 0x0df4,
+ 0x0e4f, 0x0e4f,
+ 0x0e5a, 0x0e5b,
+ 0x0f04, 0x0f12,
+ 0x0f14, 0x0f14,
+ 0x0f85, 0x0f85,
+ 0x0fd0, 0x0fd4,
+ 0x0fd9, 0x0fda,
+ 0x104a, 0x104f,
+ 0x10fb, 0x10fb,
+ 0x1360, 0x1368,
+ 0x166e, 0x166e,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17d8, 0x17da,
+ 0x1800, 0x1805,
+ 0x1807, 0x180a,
+ 0x1944, 0x1945,
+ 0x1a1e, 0x1a1f,
+ 0x1aa0, 0x1aa6,
+ 0x1aa8, 0x1aad,
+ 0x1b4e, 0x1b4f,
+ 0x1b5a, 0x1b60,
+ 0x1b7d, 0x1b7f,
+ 0x1bfc, 0x1bff,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x2016, 0x2017,
+ 0x2020, 0x2027,
+ 0x2030, 0x2038,
+ 0x203b, 0x203e,
+ 0x2041, 0x2043,
+ 0x2047, 0x2051,
+ 0x2053, 0x2053,
+ 0x2055, 0x205e,
+ 0x2cf9, 0x2cfc,
+ 0x2cfe, 0x2cff,
+ 0x2d70, 0x2d70,
+ 0x2e00, 0x2e01,
+ 0x2e06, 0x2e08,
+ 0x2e0b, 0x2e0b,
+ 0x2e0e, 0x2e16,
+ 0x2e18, 0x2e19,
+ 0x2e1b, 0x2e1b,
+ 0x2e1e, 0x2e1f,
+ 0x2e2a, 0x2e2e,
+ 0x2e30, 0x2e39,
+ 0x2e3c, 0x2e3f,
+ 0x2e41, 0x2e41,
+ 0x2e43, 0x2e4f,
+ 0x2e52, 0x2e54,
+ 0x3001, 0x3003,
+ 0x303d, 0x303d,
+ 0x30fb, 0x30fb,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa67e,
+ 0xa6f2, 0xa6f7,
+ 0xa874, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa8f8, 0xa8fa,
+ 0xa8fc, 0xa8fc,
+ 0xa92e, 0xa92f,
+ 0xa95f, 0xa95f,
+ 0xa9c1, 0xa9cd,
+ 0xa9de, 0xa9df,
+ 0xaa5c, 0xaa5f,
+ 0xaade, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 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, 0x10102,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x1056f, 0x1056f,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x1093f, 0x1093f,
+ 0x10a50, 0x10a58,
+ 0x10a7f, 0x10a7f,
+ 0x10af0, 0x10af6,
+ 0x10b39, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x10ed0, 0x10ed0,
+ 0x10f55, 0x10f59,
+ 0x10f86, 0x10f89,
+ 0x11047, 0x1104d,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x11140, 0x11143,
+ 0x11174, 0x11175,
+ 0x111c5, 0x111c8,
+ 0x111cd, 0x111cd,
+ 0x111db, 0x111db,
+ 0x111dd, 0x111df,
+ 0x11238, 0x1123d,
+ 0x112a9, 0x112a9,
+ 0x113d4, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x1144b, 0x1144f,
+ 0x1145a, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x114c6, 0x114c6,
+ 0x115c1, 0x115d7,
+ 0x11641, 0x11643,
+ 0x11660, 0x1166c,
+ 0x116b9, 0x116b9,
+ 0x1173c, 0x1173e,
+ 0x1183b, 0x1183b,
+ 0x11944, 0x11946,
+ 0x119e2, 0x119e2,
+ 0x11a3f, 0x11a46,
+ 0x11a9a, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11b00, 0x11b09,
+ 0x11be1, 0x11be1,
+ 0x11c41, 0x11c45,
+ 0x11c70, 0x11c71,
+ 0x11ef7, 0x11ef8,
+ 0x11f43, 0x11f4f,
+ 0x11fff, 0x11fff,
+ 0x12470, 0x12474,
+ 0x12ff1, 0x12ff2,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b3b,
+ 0x16b44, 0x16b44,
+ 0x16d6d, 0x16d6f,
+ 0x16e97, 0x16e9a,
+ 0x16fe2, 0x16fe2,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8b,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Po */
+
+/* 'Ps': General Category */
+static const OnigCodePoint CR_Ps[] = {
+ 79,
+ 0x0028, 0x0028,
+ 0x005b, 0x005b,
+ 0x007b, 0x007b,
+ 0x0f3a, 0x0f3a,
+ 0x0f3c, 0x0f3c,
+ 0x169b, 0x169b,
+ 0x201a, 0x201a,
+ 0x201e, 0x201e,
+ 0x2045, 0x2045,
+ 0x207d, 0x207d,
+ 0x208d, 0x208d,
+ 0x2308, 0x2308,
+ 0x230a, 0x230a,
+ 0x2329, 0x2329,
+ 0x2768, 0x2768,
+ 0x276a, 0x276a,
+ 0x276c, 0x276c,
+ 0x276e, 0x276e,
+ 0x2770, 0x2770,
+ 0x2772, 0x2772,
+ 0x2774, 0x2774,
+ 0x27c5, 0x27c5,
+ 0x27e6, 0x27e6,
+ 0x27e8, 0x27e8,
+ 0x27ea, 0x27ea,
+ 0x27ec, 0x27ec,
+ 0x27ee, 0x27ee,
+ 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,
+ 0x2e22, 0x2e22,
+ 0x2e24, 0x2e24,
+ 0x2e26, 0x2e26,
+ 0x2e28, 0x2e28,
+ 0x2e42, 0x2e42,
+ 0x2e55, 0x2e55,
+ 0x2e57, 0x2e57,
+ 0x2e59, 0x2e59,
+ 0x2e5b, 0x2e5b,
+ 0x3008, 0x3008,
+ 0x300a, 0x300a,
+ 0x300c, 0x300c,
+ 0x300e, 0x300e,
+ 0x3010, 0x3010,
+ 0x3014, 0x3014,
+ 0x3016, 0x3016,
+ 0x3018, 0x3018,
+ 0x301a, 0x301a,
+ 0x301d, 0x301d,
+ 0xfd3f, 0xfd3f,
+ 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[] = {
+ 242,
+ 0x0024, 0x0024,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00a2, 0x00a6,
+ 0x00a8, 0x00a9,
+ 0x00ac, 0x00ac,
+ 0x00ae, 0x00b1,
+ 0x00b4, 0x00b4,
+ 0x00b8, 0x00b8,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x02c2, 0x02c5,
+ 0x02d2, 0x02df,
+ 0x02e5, 0x02eb,
+ 0x02ed, 0x02ed,
+ 0x02ef, 0x02ff,
+ 0x0375, 0x0375,
+ 0x0384, 0x0385,
+ 0x03f6, 0x03f6,
+ 0x0482, 0x0482,
+ 0x058d, 0x058f,
+ 0x0606, 0x0608,
+ 0x060b, 0x060b,
+ 0x060e, 0x060f,
+ 0x06de, 0x06de,
+ 0x06e9, 0x06e9,
+ 0x06fd, 0x06fe,
+ 0x07f6, 0x07f6,
+ 0x07fe, 0x07ff,
+ 0x0888, 0x0888,
+ 0x09f2, 0x09f3,
+ 0x09fa, 0x09fb,
+ 0x0af1, 0x0af1,
+ 0x0b70, 0x0b70,
+ 0x0bf3, 0x0bfa,
+ 0x0c7f, 0x0c7f,
+ 0x0d4f, 0x0d4f,
+ 0x0d79, 0x0d79,
+ 0x0e3f, 0x0e3f,
+ 0x0f01, 0x0f03,
+ 0x0f13, 0x0f13,
+ 0x0f15, 0x0f17,
+ 0x0f1a, 0x0f1f,
+ 0x0f34, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fcf,
+ 0x0fd5, 0x0fd8,
+ 0x109e, 0x109f,
+ 0x1390, 0x1399,
+ 0x166d, 0x166d,
+ 0x17db, 0x17db,
+ 0x1940, 0x1940,
+ 0x19de, 0x19ff,
+ 0x1b61, 0x1b6a,
+ 0x1b74, 0x1b7c,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x207a, 0x207c,
+ 0x208a, 0x208c,
+ 0x20a0, 0x20c1,
+ 0x2100, 0x2101,
+ 0x2103, 0x2106,
+ 0x2108, 0x2109,
+ 0x2114, 0x2114,
+ 0x2116, 0x2118,
+ 0x211e, 0x2123,
+ 0x2125, 0x2125,
+ 0x2127, 0x2127,
+ 0x2129, 0x2129,
+ 0x212e, 0x212e,
+ 0x213a, 0x213b,
+ 0x2140, 0x2144,
+ 0x214a, 0x214d,
+ 0x214f, 0x214f,
+ 0x218a, 0x218b,
+ 0x2190, 0x2307,
+ 0x230c, 0x2328,
+ 0x232b, 0x2429,
+ 0x2440, 0x244a,
+ 0x249c, 0x24e9,
+ 0x2500, 0x2767,
+ 0x2794, 0x27c4,
+ 0x27c7, 0x27e5,
+ 0x27f0, 0x2982,
+ 0x2999, 0x29d7,
+ 0x29dc, 0x29fb,
+ 0x29fe, 0x2b73,
+ 0x2b76, 0x2bff,
+ 0x2ce5, 0x2cea,
+ 0x2e50, 0x2e51,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2fff,
+ 0x3004, 0x3004,
+ 0x3012, 0x3013,
+ 0x3020, 0x3020,
+ 0x3036, 0x3037,
+ 0x303e, 0x303f,
+ 0x309b, 0x309c,
+ 0x3190, 0x3191,
+ 0x3196, 0x319f,
+ 0x31c0, 0x31e5,
+ 0x31ef, 0x31ef,
+ 0x3200, 0x321e,
+ 0x322a, 0x3247,
+ 0x3250, 0x3250,
+ 0x3260, 0x327f,
+ 0x328a, 0x32b0,
+ 0x32c0, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa490, 0xa4c6,
+ 0xa700, 0xa716,
+ 0xa720, 0xa721,
+ 0xa789, 0xa78a,
+ 0xa828, 0xa82b,
+ 0xa836, 0xa839,
+ 0xaa77, 0xaa79,
+ 0xab5b, 0xab5b,
+ 0xab6a, 0xab6b,
+ 0xfb29, 0xfb29,
+ 0xfbb2, 0xfbd2,
+ 0xfd40, 0xfd4f,
+ 0xfd90, 0xfd91,
+ 0xfdc8, 0xfdcf,
+ 0xfdfc, 0xfdff,
+ 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,
+ 0x10137, 0x1013f,
+ 0x10179, 0x10189,
+ 0x1018c, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10877, 0x10878,
+ 0x10ac8, 0x10ac8,
+ 0x10d8e, 0x10d8f,
+ 0x10ed1, 0x10ed8,
+ 0x1173f, 0x1173f,
+ 0x11fd5, 0x11ff1,
+ 0x16b3c, 0x16b3f,
+ 0x16b45, 0x16b45,
+ 0x1bc9c, 0x1bc9c,
+ 0x1cc00, 0x1ccef,
+ 0x1ccfa, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d16a, 0x1d16c,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1ea,
+ 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,
+ 0x1d800, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da86,
+ 0x1e14f, 0x1e14f,
+ 0x1e2ff, 0x1e2ff,
+ 0x1ecac, 0x1ecac,
+ 0x1ecb0, 0x1ecb0,
+ 0x1ed2e, 0x1ed2e,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f10d, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbef,
+ 0x1fbfa, 0x1fbfa,
+}; /* CR_S */
+
+/* 'Sc': General Category */
+static const OnigCodePoint CR_Sc[] = {
+ 21,
+ 0x0024, 0x0024,
+ 0x00a2, 0x00a5,
+ 0x058f, 0x058f,
+ 0x060b, 0x060b,
+ 0x07fe, 0x07ff,
+ 0x09f2, 0x09f3,
+ 0x09fb, 0x09fb,
+ 0x0af1, 0x0af1,
+ 0x0bf9, 0x0bf9,
+ 0x0e3f, 0x0e3f,
+ 0x17db, 0x17db,
+ 0x20a0, 0x20c1,
+ 0xa838, 0xa838,
+ 0xfdfc, 0xfdfc,
+ 0xfe69, 0xfe69,
+ 0xff04, 0xff04,
+ 0xffe0, 0xffe1,
+ 0xffe5, 0xffe6,
+ 0x11fdd, 0x11fe0,
+ 0x1e2ff, 0x1e2ff,
+ 0x1ecb0, 0x1ecb0,
+}; /* CR_Sc */
+
+/* 'Sk': General Category */
+static const OnigCodePoint CR_Sk[] = {
+ 31,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b8, 0x00b8,
+ 0x02c2, 0x02c5,
+ 0x02d2, 0x02df,
+ 0x02e5, 0x02eb,
+ 0x02ed, 0x02ed,
+ 0x02ef, 0x02ff,
+ 0x0375, 0x0375,
+ 0x0384, 0x0385,
+ 0x0888, 0x0888,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x309b, 0x309c,
+ 0xa700, 0xa716,
+ 0xa720, 0xa721,
+ 0xa789, 0xa78a,
+ 0xab5b, 0xab5b,
+ 0xab6a, 0xab6b,
+ 0xfbb2, 0xfbc2,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xffe3, 0xffe3,
+ 0x1f3fb, 0x1f3ff,
+}; /* CR_Sk */
+
+/* 'Sm': General Category */
+static const OnigCodePoint CR_Sm[] = {
+ 67,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00ac, 0x00ac,
+ 0x00b1, 0x00b1,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x03f6, 0x03f6,
+ 0x0606, 0x0608,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x207a, 0x207c,
+ 0x208a, 0x208c,
+ 0x2118, 0x2118,
+ 0x2140, 0x2144,
+ 0x214b, 0x214b,
+ 0x2190, 0x2194,
+ 0x219a, 0x219b,
+ 0x21a0, 0x21a0,
+ 0x21a3, 0x21a3,
+ 0x21a6, 0x21a6,
+ 0x21ae, 0x21ae,
+ 0x21ce, 0x21cf,
+ 0x21d2, 0x21d2,
+ 0x21d4, 0x21d4,
+ 0x21f4, 0x22ff,
+ 0x2320, 0x2321,
+ 0x237c, 0x237c,
+ 0x239b, 0x23b3,
+ 0x23dc, 0x23e1,
+ 0x25b7, 0x25b7,
+ 0x25c1, 0x25c1,
+ 0x25f8, 0x25ff,
+ 0x266f, 0x266f,
+ 0x27c0, 0x27c4,
+ 0x27c7, 0x27e5,
+ 0x27f0, 0x27ff,
+ 0x2900, 0x2982,
+ 0x2999, 0x29d7,
+ 0x29dc, 0x29fb,
+ 0x29fe, 0x2aff,
+ 0x2b30, 0x2b44,
+ 0x2b47, 0x2b4c,
+ 0xfb29, 0xfb29,
+ 0xfe62, 0xfe62,
+ 0xfe64, 0xfe66,
+ 0xff0b, 0xff0b,
+ 0xff1c, 0xff1e,
+ 0xff5c, 0xff5c,
+ 0xff5e, 0xff5e,
+ 0xffe2, 0xffe2,
+ 0xffe9, 0xffec,
+ 0x10d8e, 0x10d8f,
+ 0x1cef0, 0x1cef0,
+ 0x1d6c1, 0x1d6c1,
+ 0x1d6db, 0x1d6db,
+ 0x1d6fb, 0x1d6fb,
+ 0x1d715, 0x1d715,
+ 0x1d735, 0x1d735,
+ 0x1d74f, 0x1d74f,
+ 0x1d76f, 0x1d76f,
+ 0x1d789, 0x1d789,
+ 0x1d7a9, 0x1d7a9,
+ 0x1d7c3, 0x1d7c3,
+ 0x1eef0, 0x1eef1,
+ 0x1f8d0, 0x1f8d8,
+}; /* CR_Sm */
+
+/* 'So': General Category */
+static const OnigCodePoint CR_So[] = {
+ 193,
+ 0x00a6, 0x00a6,
+ 0x00a9, 0x00a9,
+ 0x00ae, 0x00ae,
+ 0x00b0, 0x00b0,
+ 0x0482, 0x0482,
+ 0x058d, 0x058e,
+ 0x060e, 0x060f,
+ 0x06de, 0x06de,
+ 0x06e9, 0x06e9,
+ 0x06fd, 0x06fe,
+ 0x07f6, 0x07f6,
+ 0x09fa, 0x09fa,
+ 0x0b70, 0x0b70,
+ 0x0bf3, 0x0bf8,
+ 0x0bfa, 0x0bfa,
+ 0x0c7f, 0x0c7f,
+ 0x0d4f, 0x0d4f,
+ 0x0d79, 0x0d79,
+ 0x0f01, 0x0f03,
+ 0x0f13, 0x0f13,
+ 0x0f15, 0x0f17,
+ 0x0f1a, 0x0f1f,
+ 0x0f34, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fcf,
+ 0x0fd5, 0x0fd8,
+ 0x109e, 0x109f,
+ 0x1390, 0x1399,
+ 0x166d, 0x166d,
+ 0x1940, 0x1940,
+ 0x19de, 0x19ff,
+ 0x1b61, 0x1b6a,
+ 0x1b74, 0x1b7c,
+ 0x2100, 0x2101,
+ 0x2103, 0x2106,
+ 0x2108, 0x2109,
+ 0x2114, 0x2114,
+ 0x2116, 0x2117,
+ 0x211e, 0x2123,
+ 0x2125, 0x2125,
+ 0x2127, 0x2127,
+ 0x2129, 0x2129,
+ 0x212e, 0x212e,
+ 0x213a, 0x213b,
+ 0x214a, 0x214a,
+ 0x214c, 0x214d,
+ 0x214f, 0x214f,
+ 0x218a, 0x218b,
+ 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,
+ 0x23b4, 0x23db,
+ 0x23e2, 0x2429,
+ 0x2440, 0x244a,
+ 0x249c, 0x24e9,
+ 0x2500, 0x25b6,
+ 0x25b8, 0x25c0,
+ 0x25c2, 0x25f7,
+ 0x2600, 0x266e,
+ 0x2670, 0x2767,
+ 0x2794, 0x27bf,
+ 0x2800, 0x28ff,
+ 0x2b00, 0x2b2f,
+ 0x2b45, 0x2b46,
+ 0x2b4d, 0x2b73,
+ 0x2b76, 0x2bff,
+ 0x2ce5, 0x2cea,
+ 0x2e50, 0x2e51,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2fff,
+ 0x3004, 0x3004,
+ 0x3012, 0x3013,
+ 0x3020, 0x3020,
+ 0x3036, 0x3037,
+ 0x303e, 0x303f,
+ 0x3190, 0x3191,
+ 0x3196, 0x319f,
+ 0x31c0, 0x31e5,
+ 0x31ef, 0x31ef,
+ 0x3200, 0x321e,
+ 0x322a, 0x3247,
+ 0x3250, 0x3250,
+ 0x3260, 0x327f,
+ 0x328a, 0x32b0,
+ 0x32c0, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa490, 0xa4c6,
+ 0xa828, 0xa82b,
+ 0xa836, 0xa837,
+ 0xa839, 0xa839,
+ 0xaa77, 0xaa79,
+ 0xfbc3, 0xfbd2,
+ 0xfd40, 0xfd4f,
+ 0xfd90, 0xfd91,
+ 0xfdc8, 0xfdcf,
+ 0xfdfd, 0xfdff,
+ 0xffe4, 0xffe4,
+ 0xffe8, 0xffe8,
+ 0xffed, 0xffee,
+ 0xfffc, 0xfffd,
+ 0x10137, 0x1013f,
+ 0x10179, 0x10189,
+ 0x1018c, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10877, 0x10878,
+ 0x10ac8, 0x10ac8,
+ 0x10ed1, 0x10ed8,
+ 0x1173f, 0x1173f,
+ 0x11fd5, 0x11fdc,
+ 0x11fe1, 0x11ff1,
+ 0x16b3c, 0x16b3f,
+ 0x16b45, 0x16b45,
+ 0x1bc9c, 0x1bc9c,
+ 0x1cc00, 0x1ccef,
+ 0x1ccfa, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1ceef,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d16a, 0x1d16c,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1ea,
+ 0x1d200, 0x1d241,
+ 0x1d245, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d800, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da86,
+ 0x1e14f, 0x1e14f,
+ 0x1ecac, 0x1ecac,
+ 0x1ed2e, 0x1ed2e,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f10d, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f3fa,
+ 0x1f400, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbef,
+ 0x1fbfa, 0x1fbfa,
+}; /* CR_So */
+
+/* 'Z': Major Category */
+static const OnigCodePoint CR_Z[] = {
+ 8,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 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[] = {
+ 7,
+ 0x0020, 0x0020,
+ 0x00a0, 0x00a0,
+ 0x1680, 0x1680,
+ 0x2000, 0x200a,
+ 0x202f, 0x202f,
+ 0x205f, 0x205f,
+ 0x3000, 0x3000,
+}; /* CR_Zs */
+
+/* 'Math': Derived Property */
+static const OnigCodePoint CR_Math[] = {
+ 141,
+ 0x002b, 0x002b,
+ 0x003c, 0x003e,
+ 0x005e, 0x005e,
+ 0x007c, 0x007c,
+ 0x007e, 0x007e,
+ 0x00ac, 0x00ac,
+ 0x00b1, 0x00b1,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x03d0, 0x03d2,
+ 0x03d5, 0x03d5,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f6,
+ 0x0606, 0x0608,
+ 0x2016, 0x2016,
+ 0x2032, 0x2034,
+ 0x2040, 0x2040,
+ 0x2044, 0x2044,
+ 0x2052, 0x2052,
+ 0x2061, 0x2064,
+ 0x207a, 0x207e,
+ 0x208a, 0x208e,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20e6,
+ 0x20eb, 0x20ef,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2128, 0x2129,
+ 0x212c, 0x212d,
+ 0x212f, 0x2131,
+ 0x2133, 0x2138,
+ 0x213c, 0x2149,
+ 0x214b, 0x214b,
+ 0x2190, 0x21a7,
+ 0x21a9, 0x21ae,
+ 0x21b0, 0x21b1,
+ 0x21b6, 0x21b7,
+ 0x21bc, 0x21db,
+ 0x21dd, 0x21dd,
+ 0x21e4, 0x21e5,
+ 0x21f4, 0x22ff,
+ 0x2308, 0x230b,
+ 0x2320, 0x2321,
+ 0x237c, 0x237c,
+ 0x239b, 0x23b5,
+ 0x23b7, 0x23b7,
+ 0x23d0, 0x23d0,
+ 0x23dc, 0x23e2,
+ 0x25a0, 0x25a1,
+ 0x25ae, 0x25b7,
+ 0x25bc, 0x25c1,
+ 0x25c6, 0x25c7,
+ 0x25ca, 0x25cb,
+ 0x25cf, 0x25d3,
+ 0x25e2, 0x25e2,
+ 0x25e4, 0x25e4,
+ 0x25e7, 0x25ec,
+ 0x25f8, 0x25ff,
+ 0x2605, 0x2606,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2660, 0x2663,
+ 0x266d, 0x266f,
+ 0x27c0, 0x27ff,
+ 0x2900, 0x2aff,
+ 0x2b30, 0x2b44,
+ 0x2b47, 0x2b4c,
+ 0xfb29, 0xfb29,
+ 0xfe61, 0xfe66,
+ 0xfe68, 0xfe68,
+ 0xff0b, 0xff0b,
+ 0xff1c, 0xff1e,
+ 0xff3c, 0xff3c,
+ 0xff3e, 0xff3e,
+ 0xff5c, 0xff5c,
+ 0xff5e, 0xff5e,
+ 0xffe2, 0xffe2,
+ 0xffe9, 0xffec,
+ 0x10d8e, 0x10d8f,
+ 0x1cef0, 0x1cef0,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f8d0, 0x1f8d8,
+}; /* CR_Math */
+
+/* 'Alphabetic': Derived Property */
+#define CR_Alphabetic CR_Alpha
+
+/* 'Lowercase': Derived Property */
+#define CR_Lowercase CR_Lower
+
+/* 'Uppercase': Derived Property */
+#define CR_Uppercase CR_Upper
+
+/* 'Cased': Derived Property */
+static const OnigCodePoint CR_Cased[] = {
+ 158,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x01ba,
+ 0x01bc, 0x01bf,
+ 0x01c4, 0x0293,
+ 0x0296, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0560, 0x0588,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x10ff,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x212d,
+ 0x212f, 0x2134,
+ 0x2139, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x217f,
+ 0x2183, 0x2184,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69d,
+ 0xa722, 0xa787,
+ 0xa78b, 0xa78e,
+ 0xa790, 0xa7dc,
+ 0xa7f1, 0xa7f6,
+ 0xa7f8, 0xa7fa,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10780, 0x10780,
+ 0x10783, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d50, 0x10d65,
+ 0x10d70, 0x10d85,
+ 0x118a0, 0x118df,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df09,
+ 0x1df0b, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e900, 0x1e943,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Cased */
+
+/* 'Case_Ignorable': Derived Property */
+static const OnigCodePoint CR_Case_Ignorable[] = {
+ 464,
+ 0x0027, 0x0027,
+ 0x002e, 0x002e,
+ 0x003a, 0x003a,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00ad, 0x00ad,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b7, 0x00b8,
+ 0x02b0, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x0384, 0x0385,
+ 0x0387, 0x0387,
+ 0x0483, 0x0489,
+ 0x0559, 0x0559,
+ 0x055f, 0x055f,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05f4, 0x05f4,
+ 0x0600, 0x0605,
+ 0x0610, 0x061a,
+ 0x061c, 0x061c,
+ 0x0640, 0x0640,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dd,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x070f, 0x070f,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x082d,
+ 0x0859, 0x085b,
+ 0x0888, 0x0888,
+ 0x0890, 0x0891,
+ 0x0897, 0x089f,
+ 0x08c9, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0971, 0x0971,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3f, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b55, 0x0b56,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0c00, 0x0c00,
+ 0x0c04, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cbf,
+ 0x0cc6, 0x0cc6,
+ 0x0ccc, 0x0ccd,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d81,
+ 0x0dca, 0x0dca,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e46, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x10fc, 0x10fc,
+ 0x135d, 0x135f,
+ 0x1712, 0x1714,
+ 0x1732, 0x1733,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180f,
+ 0x1843, 0x1843,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b34,
+ 0x1b36, 0x1b3a,
+ 0x1b3c, 0x1b3c,
+ 0x1b42, 0x1b42,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1ba9,
+ 0x1bab, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf1,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1c78, 0x1c7d,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1dff,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x200b, 0x200f,
+ 0x2018, 0x2019,
+ 0x2024, 0x2024,
+ 0x2027, 0x2027,
+ 0x202a, 0x202e,
+ 0x2060, 0x2064,
+ 0x2066, 0x206f,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20f0,
+ 0x2c7c, 0x2c7d,
+ 0x2cef, 0x2cf1,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x2e2f, 0x2e2f,
+ 0x3005, 0x3005,
+ 0x302a, 0x302d,
+ 0x3031, 0x3035,
+ 0x303b, 0x303b,
+ 0x3099, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa4f8, 0xa4fd,
+ 0xa60c, 0xa60c,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa700, 0xa721,
+ 0xa770, 0xa770,
+ 0xa788, 0xa78a,
+ 0xa7f1, 0xa7f4,
+ 0xa7f8, 0xa7f9,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bd,
+ 0xa9cf, 0xa9cf,
+ 0xa9e5, 0xa9e6,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa70, 0xaa70,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaadd, 0xaadd,
+ 0xaaec, 0xaaed,
+ 0xaaf3, 0xaaf4,
+ 0xaaf6, 0xaaf6,
+ 0xab5b, 0xab5f,
+ 0xab69, 0xab6b,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfbb2, 0xfbc2,
+ 0xfe00, 0xfe0f,
+ 0xfe13, 0xfe13,
+ 0xfe20, 0xfe2f,
+ 0xfe52, 0xfe52,
+ 0xfe55, 0xfe55,
+ 0xfeff, 0xfeff,
+ 0xff07, 0xff07,
+ 0xff0e, 0xff0e,
+ 0xff1a, 0xff1a,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0xffe3, 0xffe3,
+ 0xfff9, 0xfffb,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d4e, 0x10d4e,
+ 0x10d69, 0x10d6d,
+ 0x10d6f, 0x10d6f,
+ 0x10eab, 0x10eac,
+ 0x10ec5, 0x10ec5,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110bd, 0x110bd,
+ 0x110c2, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111c9, 0x111cc,
+ 0x111cf, 0x111cf,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11234,
+ 0x11236, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133b, 0x1133c,
+ 0x11340, 0x11340,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113bb, 0x113c0,
+ 0x113ce, 0x113ce,
+ 0x113d0, 0x113d0,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b5,
+ 0x116b7, 0x116b7,
+ 0x1171d, 0x1171d,
+ 0x1171f, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x1182f, 0x11837,
+ 0x11839, 0x1183a,
+ 0x1193b, 0x1193c,
+ 0x1193e, 0x1193e,
+ 0x11943, 0x11943,
+ 0x119d4, 0x119d7,
+ 0x119da, 0x119db,
+ 0x119e0, 0x119e0,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11b60, 0x11b60,
+ 0x11b62, 0x11b64,
+ 0x11b66, 0x11b66,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d90, 0x11d91,
+ 0x11d95, 0x11d95,
+ 0x11d97, 0x11d97,
+ 0x11dd9, 0x11dd9,
+ 0x11ef3, 0x11ef4,
+ 0x11f00, 0x11f01,
+ 0x11f36, 0x11f3a,
+ 0x11f40, 0x11f40,
+ 0x11f42, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13430, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x16129,
+ 0x1612d, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16d40, 0x16d42,
+ 0x16d6b, 0x16d6c,
+ 0x16f4f, 0x16f4f,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe4,
+ 0x16ff2, 0x16ff3,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1bc9d, 0x1bc9e,
+ 0x1bca0, 0x1bca3,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d167, 0x1d169,
+ 0x1d173, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e13d,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4eb, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e6ff, 0x1e6ff,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94b,
+ 0x1f3fb, 0x1f3ff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Case_Ignorable */
+
+/* 'Changes_When_Lowercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Lowercased[] = {
+ 618,
+ 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, 0x01c5,
+ 0x01c7, 0x01c8,
+ 0x01ca, 0x01cb,
+ 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, 0x01f2,
+ 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,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03cf, 0x03cf,
+ 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,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13a0, 0x13f5,
+ 0x1c89, 0x1c89,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 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,
+ 0x1e9e, 0x1e9e,
+ 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,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1f88, 0x1f8f,
+ 0x1f98, 0x1f9f,
+ 0x1fa8, 0x1faf,
+ 0x1fb8, 0x1fbc,
+ 0x1fc8, 0x1fcc,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff8, 0x1ffc,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2f,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 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,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xa7b8, 0xa7b8,
+ 0xa7ba, 0xa7ba,
+ 0xa7bc, 0xa7bc,
+ 0xa7be, 0xa7be,
+ 0xa7c0, 0xa7c0,
+ 0xa7c2, 0xa7c2,
+ 0xa7c4, 0xa7c7,
+ 0xa7c9, 0xa7c9,
+ 0xa7cb, 0xa7cc,
+ 0xa7ce, 0xa7ce,
+ 0xa7d0, 0xa7d0,
+ 0xa7d2, 0xa7d2,
+ 0xa7d4, 0xa7d4,
+ 0xa7d6, 0xa7d6,
+ 0xa7d8, 0xa7d8,
+ 0xa7da, 0xa7da,
+ 0xa7dc, 0xa7dc,
+ 0xa7f5, 0xa7f5,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10c80, 0x10cb2,
+ 0x10d50, 0x10d65,
+ 0x118a0, 0x118bf,
+ 0x16e40, 0x16e5f,
+ 0x16ea0, 0x16eb8,
+ 0x1e900, 0x1e921,
+}; /* CR_Changes_When_Lowercased */
+
+/* 'Changes_When_Uppercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Uppercased[] = {
+ 634,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 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, 0x0137,
+ 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, 0x018c,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019b,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01b9,
+ 0x01bd, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c5, 0x01c6,
+ 0x01c8, 0x01c9,
+ 0x01cb, 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,
+ 0x01f2, 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,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0233,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0282, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 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, 0x03fb,
+ 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, 0x04cf,
+ 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,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x10d0, 0x10fa,
+ 0x10fd, 0x10ff,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1c8a, 0x1c8a,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1d8e, 0x1d8e,
+ 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,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 0x1f07,
+ 0x1f10, 0x1f15,
+ 0x1f20, 0x1f27,
+ 0x1f30, 0x1f37,
+ 0x1f40, 0x1f45,
+ 0x1f50, 0x1f57,
+ 0x1f60, 0x1f67,
+ 0x1f70, 0x1f7d,
+ 0x1f80, 0x1fb4,
+ 0x1fb6, 0x1fb7,
+ 0x1fbc, 0x1fbc,
+ 0x1fbe, 0x1fbe,
+ 0x1fc2, 0x1fc4,
+ 0x1fc6, 0x1fc7,
+ 0x1fcc, 0x1fcc,
+ 0x1fd0, 0x1fd3,
+ 0x1fd6, 0x1fd7,
+ 0x1fe0, 0x1fe7,
+ 0x1ff2, 0x1ff4,
+ 0x1ff6, 0x1ff7,
+ 0x1ffc, 0x1ffc,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5f,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c73, 0x2c73,
+ 0x2c76, 0x2c76,
+ 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, 0x2ce3,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa72f,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa791, 0xa791,
+ 0xa793, 0xa794,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7b9, 0xa7b9,
+ 0xa7bb, 0xa7bb,
+ 0xa7bd, 0xa7bd,
+ 0xa7bf, 0xa7bf,
+ 0xa7c1, 0xa7c1,
+ 0xa7c3, 0xa7c3,
+ 0xa7c8, 0xa7c8,
+ 0xa7ca, 0xa7ca,
+ 0xa7cd, 0xa7cd,
+ 0xa7cf, 0xa7cf,
+ 0xa7d1, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d5,
+ 0xa7d7, 0xa7d7,
+ 0xa7d9, 0xa7d9,
+ 0xa7db, 0xa7db,
+ 0xa7f6, 0xa7f6,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10cc0, 0x10cf2,
+ 0x10d70, 0x10d85,
+ 0x118c0, 0x118df,
+ 0x16e60, 0x16e7f,
+ 0x16ebb, 0x16ed3,
+ 0x1e922, 0x1e943,
+}; /* CR_Changes_When_Uppercased */
+
+/* 'Changes_When_Titlecased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Titlecased[] = {
+ 633,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 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, 0x0137,
+ 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, 0x018c,
+ 0x0192, 0x0192,
+ 0x0195, 0x0195,
+ 0x0199, 0x019b,
+ 0x019e, 0x019e,
+ 0x01a1, 0x01a1,
+ 0x01a3, 0x01a3,
+ 0x01a5, 0x01a5,
+ 0x01a8, 0x01a8,
+ 0x01ad, 0x01ad,
+ 0x01b0, 0x01b0,
+ 0x01b4, 0x01b4,
+ 0x01b6, 0x01b6,
+ 0x01b9, 0x01b9,
+ 0x01bd, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c4, 0x01c4,
+ 0x01c6, 0x01c7,
+ 0x01c9, 0x01ca,
+ 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, 0x01f1,
+ 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,
+ 0x0223, 0x0223,
+ 0x0225, 0x0225,
+ 0x0227, 0x0227,
+ 0x0229, 0x0229,
+ 0x022b, 0x022b,
+ 0x022d, 0x022d,
+ 0x022f, 0x022f,
+ 0x0231, 0x0231,
+ 0x0233, 0x0233,
+ 0x023c, 0x023c,
+ 0x023f, 0x0240,
+ 0x0242, 0x0242,
+ 0x0247, 0x0247,
+ 0x0249, 0x0249,
+ 0x024b, 0x024b,
+ 0x024d, 0x024d,
+ 0x024f, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0282, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0371, 0x0371,
+ 0x0373, 0x0373,
+ 0x0377, 0x0377,
+ 0x037b, 0x037d,
+ 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, 0x03fb,
+ 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, 0x04cf,
+ 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,
+ 0x04fb, 0x04fb,
+ 0x04fd, 0x04fd,
+ 0x04ff, 0x04ff,
+ 0x0501, 0x0501,
+ 0x0503, 0x0503,
+ 0x0505, 0x0505,
+ 0x0507, 0x0507,
+ 0x0509, 0x0509,
+ 0x050b, 0x050b,
+ 0x050d, 0x050d,
+ 0x050f, 0x050f,
+ 0x0511, 0x0511,
+ 0x0513, 0x0513,
+ 0x0515, 0x0515,
+ 0x0517, 0x0517,
+ 0x0519, 0x0519,
+ 0x051b, 0x051b,
+ 0x051d, 0x051d,
+ 0x051f, 0x051f,
+ 0x0521, 0x0521,
+ 0x0523, 0x0523,
+ 0x0525, 0x0525,
+ 0x0527, 0x0527,
+ 0x0529, 0x0529,
+ 0x052b, 0x052b,
+ 0x052d, 0x052d,
+ 0x052f, 0x052f,
+ 0x0561, 0x0587,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c88,
+ 0x1c8a, 0x1c8a,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1d8e, 0x1d8e,
+ 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,
+ 0x1efb, 0x1efb,
+ 0x1efd, 0x1efd,
+ 0x1eff, 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,
+ 0x214e, 0x214e,
+ 0x2170, 0x217f,
+ 0x2184, 0x2184,
+ 0x24d0, 0x24e9,
+ 0x2c30, 0x2c5f,
+ 0x2c61, 0x2c61,
+ 0x2c65, 0x2c66,
+ 0x2c68, 0x2c68,
+ 0x2c6a, 0x2c6a,
+ 0x2c6c, 0x2c6c,
+ 0x2c73, 0x2c73,
+ 0x2c76, 0x2c76,
+ 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, 0x2ce3,
+ 0x2cec, 0x2cec,
+ 0x2cee, 0x2cee,
+ 0x2cf3, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa641, 0xa641,
+ 0xa643, 0xa643,
+ 0xa645, 0xa645,
+ 0xa647, 0xa647,
+ 0xa649, 0xa649,
+ 0xa64b, 0xa64b,
+ 0xa64d, 0xa64d,
+ 0xa64f, 0xa64f,
+ 0xa651, 0xa651,
+ 0xa653, 0xa653,
+ 0xa655, 0xa655,
+ 0xa657, 0xa657,
+ 0xa659, 0xa659,
+ 0xa65b, 0xa65b,
+ 0xa65d, 0xa65d,
+ 0xa65f, 0xa65f,
+ 0xa661, 0xa661,
+ 0xa663, 0xa663,
+ 0xa665, 0xa665,
+ 0xa667, 0xa667,
+ 0xa669, 0xa669,
+ 0xa66b, 0xa66b,
+ 0xa66d, 0xa66d,
+ 0xa681, 0xa681,
+ 0xa683, 0xa683,
+ 0xa685, 0xa685,
+ 0xa687, 0xa687,
+ 0xa689, 0xa689,
+ 0xa68b, 0xa68b,
+ 0xa68d, 0xa68d,
+ 0xa68f, 0xa68f,
+ 0xa691, 0xa691,
+ 0xa693, 0xa693,
+ 0xa695, 0xa695,
+ 0xa697, 0xa697,
+ 0xa699, 0xa699,
+ 0xa69b, 0xa69b,
+ 0xa723, 0xa723,
+ 0xa725, 0xa725,
+ 0xa727, 0xa727,
+ 0xa729, 0xa729,
+ 0xa72b, 0xa72b,
+ 0xa72d, 0xa72d,
+ 0xa72f, 0xa72f,
+ 0xa733, 0xa733,
+ 0xa735, 0xa735,
+ 0xa737, 0xa737,
+ 0xa739, 0xa739,
+ 0xa73b, 0xa73b,
+ 0xa73d, 0xa73d,
+ 0xa73f, 0xa73f,
+ 0xa741, 0xa741,
+ 0xa743, 0xa743,
+ 0xa745, 0xa745,
+ 0xa747, 0xa747,
+ 0xa749, 0xa749,
+ 0xa74b, 0xa74b,
+ 0xa74d, 0xa74d,
+ 0xa74f, 0xa74f,
+ 0xa751, 0xa751,
+ 0xa753, 0xa753,
+ 0xa755, 0xa755,
+ 0xa757, 0xa757,
+ 0xa759, 0xa759,
+ 0xa75b, 0xa75b,
+ 0xa75d, 0xa75d,
+ 0xa75f, 0xa75f,
+ 0xa761, 0xa761,
+ 0xa763, 0xa763,
+ 0xa765, 0xa765,
+ 0xa767, 0xa767,
+ 0xa769, 0xa769,
+ 0xa76b, 0xa76b,
+ 0xa76d, 0xa76d,
+ 0xa76f, 0xa76f,
+ 0xa77a, 0xa77a,
+ 0xa77c, 0xa77c,
+ 0xa77f, 0xa77f,
+ 0xa781, 0xa781,
+ 0xa783, 0xa783,
+ 0xa785, 0xa785,
+ 0xa787, 0xa787,
+ 0xa78c, 0xa78c,
+ 0xa791, 0xa791,
+ 0xa793, 0xa794,
+ 0xa797, 0xa797,
+ 0xa799, 0xa799,
+ 0xa79b, 0xa79b,
+ 0xa79d, 0xa79d,
+ 0xa79f, 0xa79f,
+ 0xa7a1, 0xa7a1,
+ 0xa7a3, 0xa7a3,
+ 0xa7a5, 0xa7a5,
+ 0xa7a7, 0xa7a7,
+ 0xa7a9, 0xa7a9,
+ 0xa7b5, 0xa7b5,
+ 0xa7b7, 0xa7b7,
+ 0xa7b9, 0xa7b9,
+ 0xa7bb, 0xa7bb,
+ 0xa7bd, 0xa7bd,
+ 0xa7bf, 0xa7bf,
+ 0xa7c1, 0xa7c1,
+ 0xa7c3, 0xa7c3,
+ 0xa7c8, 0xa7c8,
+ 0xa7ca, 0xa7ca,
+ 0xa7cd, 0xa7cd,
+ 0xa7cf, 0xa7cf,
+ 0xa7d1, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d5,
+ 0xa7d7, 0xa7d7,
+ 0xa7d9, 0xa7d9,
+ 0xa7db, 0xa7db,
+ 0xa7f6, 0xa7f6,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff41, 0xff5a,
+ 0x10428, 0x1044f,
+ 0x104d8, 0x104fb,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10cc0, 0x10cf2,
+ 0x10d70, 0x10d85,
+ 0x118c0, 0x118df,
+ 0x16e60, 0x16e7f,
+ 0x16ebb, 0x16ed3,
+ 0x1e922, 0x1e943,
+}; /* CR_Changes_When_Titlecased */
+
+/* 'Changes_When_Casefolded': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casefolded[] = {
+ 630,
+ 0x0041, 0x005a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00df,
+ 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,
+ 0x0149, 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,
+ 0x017f, 0x017f,
+ 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, 0x01c5,
+ 0x01c7, 0x01c8,
+ 0x01ca, 0x01cb,
+ 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, 0x01f2,
+ 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,
+ 0x0243, 0x0246,
+ 0x0248, 0x0248,
+ 0x024a, 0x024a,
+ 0x024c, 0x024c,
+ 0x024e, 0x024e,
+ 0x0345, 0x0345,
+ 0x0370, 0x0370,
+ 0x0372, 0x0372,
+ 0x0376, 0x0376,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x038f,
+ 0x0391, 0x03a1,
+ 0x03a3, 0x03ab,
+ 0x03c2, 0x03c2,
+ 0x03cf, 0x03d1,
+ 0x03d5, 0x03d6,
+ 0x03d8, 0x03d8,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03e2,
+ 0x03e4, 0x03e4,
+ 0x03e6, 0x03e6,
+ 0x03e8, 0x03e8,
+ 0x03ea, 0x03ea,
+ 0x03ec, 0x03ec,
+ 0x03ee, 0x03ee,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f5,
+ 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,
+ 0x04fa, 0x04fa,
+ 0x04fc, 0x04fc,
+ 0x04fe, 0x04fe,
+ 0x0500, 0x0500,
+ 0x0502, 0x0502,
+ 0x0504, 0x0504,
+ 0x0506, 0x0506,
+ 0x0508, 0x0508,
+ 0x050a, 0x050a,
+ 0x050c, 0x050c,
+ 0x050e, 0x050e,
+ 0x0510, 0x0510,
+ 0x0512, 0x0512,
+ 0x0514, 0x0514,
+ 0x0516, 0x0516,
+ 0x0518, 0x0518,
+ 0x051a, 0x051a,
+ 0x051c, 0x051c,
+ 0x051e, 0x051e,
+ 0x0520, 0x0520,
+ 0x0522, 0x0522,
+ 0x0524, 0x0524,
+ 0x0526, 0x0526,
+ 0x0528, 0x0528,
+ 0x052a, 0x052a,
+ 0x052c, 0x052c,
+ 0x052e, 0x052e,
+ 0x0531, 0x0556,
+ 0x0587, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c89,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 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,
+ 0x1e9a, 0x1e9b,
+ 0x1e9e, 0x1e9e,
+ 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,
+ 0x1efa, 0x1efa,
+ 0x1efc, 0x1efc,
+ 0x1efe, 0x1efe,
+ 0x1f08, 0x1f0f,
+ 0x1f18, 0x1f1d,
+ 0x1f28, 0x1f2f,
+ 0x1f38, 0x1f3f,
+ 0x1f48, 0x1f4d,
+ 0x1f59, 0x1f59,
+ 0x1f5b, 0x1f5b,
+ 0x1f5d, 0x1f5d,
+ 0x1f5f, 0x1f5f,
+ 0x1f68, 0x1f6f,
+ 0x1f80, 0x1faf,
+ 0x1fb2, 0x1fb4,
+ 0x1fb7, 0x1fbc,
+ 0x1fc2, 0x1fc4,
+ 0x1fc7, 0x1fcc,
+ 0x1fd8, 0x1fdb,
+ 0x1fe8, 0x1fec,
+ 0x1ff2, 0x1ff4,
+ 0x1ff7, 0x1ffc,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x2160, 0x216f,
+ 0x2183, 0x2183,
+ 0x24b6, 0x24cf,
+ 0x2c00, 0x2c2f,
+ 0x2c60, 0x2c60,
+ 0x2c62, 0x2c64,
+ 0x2c67, 0x2c67,
+ 0x2c69, 0x2c69,
+ 0x2c6b, 0x2c6b,
+ 0x2c6d, 0x2c70,
+ 0x2c72, 0x2c72,
+ 0x2c75, 0x2c75,
+ 0x2c7e, 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,
+ 0x2ceb, 0x2ceb,
+ 0x2ced, 0x2ced,
+ 0x2cf2, 0x2cf2,
+ 0xa640, 0xa640,
+ 0xa642, 0xa642,
+ 0xa644, 0xa644,
+ 0xa646, 0xa646,
+ 0xa648, 0xa648,
+ 0xa64a, 0xa64a,
+ 0xa64c, 0xa64c,
+ 0xa64e, 0xa64e,
+ 0xa650, 0xa650,
+ 0xa652, 0xa652,
+ 0xa654, 0xa654,
+ 0xa656, 0xa656,
+ 0xa658, 0xa658,
+ 0xa65a, 0xa65a,
+ 0xa65c, 0xa65c,
+ 0xa65e, 0xa65e,
+ 0xa660, 0xa660,
+ 0xa662, 0xa662,
+ 0xa664, 0xa664,
+ 0xa666, 0xa666,
+ 0xa668, 0xa668,
+ 0xa66a, 0xa66a,
+ 0xa66c, 0xa66c,
+ 0xa680, 0xa680,
+ 0xa682, 0xa682,
+ 0xa684, 0xa684,
+ 0xa686, 0xa686,
+ 0xa688, 0xa688,
+ 0xa68a, 0xa68a,
+ 0xa68c, 0xa68c,
+ 0xa68e, 0xa68e,
+ 0xa690, 0xa690,
+ 0xa692, 0xa692,
+ 0xa694, 0xa694,
+ 0xa696, 0xa696,
+ 0xa698, 0xa698,
+ 0xa69a, 0xa69a,
+ 0xa722, 0xa722,
+ 0xa724, 0xa724,
+ 0xa726, 0xa726,
+ 0xa728, 0xa728,
+ 0xa72a, 0xa72a,
+ 0xa72c, 0xa72c,
+ 0xa72e, 0xa72e,
+ 0xa732, 0xa732,
+ 0xa734, 0xa734,
+ 0xa736, 0xa736,
+ 0xa738, 0xa738,
+ 0xa73a, 0xa73a,
+ 0xa73c, 0xa73c,
+ 0xa73e, 0xa73e,
+ 0xa740, 0xa740,
+ 0xa742, 0xa742,
+ 0xa744, 0xa744,
+ 0xa746, 0xa746,
+ 0xa748, 0xa748,
+ 0xa74a, 0xa74a,
+ 0xa74c, 0xa74c,
+ 0xa74e, 0xa74e,
+ 0xa750, 0xa750,
+ 0xa752, 0xa752,
+ 0xa754, 0xa754,
+ 0xa756, 0xa756,
+ 0xa758, 0xa758,
+ 0xa75a, 0xa75a,
+ 0xa75c, 0xa75c,
+ 0xa75e, 0xa75e,
+ 0xa760, 0xa760,
+ 0xa762, 0xa762,
+ 0xa764, 0xa764,
+ 0xa766, 0xa766,
+ 0xa768, 0xa768,
+ 0xa76a, 0xa76a,
+ 0xa76c, 0xa76c,
+ 0xa76e, 0xa76e,
+ 0xa779, 0xa779,
+ 0xa77b, 0xa77b,
+ 0xa77d, 0xa77e,
+ 0xa780, 0xa780,
+ 0xa782, 0xa782,
+ 0xa784, 0xa784,
+ 0xa786, 0xa786,
+ 0xa78b, 0xa78b,
+ 0xa78d, 0xa78d,
+ 0xa790, 0xa790,
+ 0xa792, 0xa792,
+ 0xa796, 0xa796,
+ 0xa798, 0xa798,
+ 0xa79a, 0xa79a,
+ 0xa79c, 0xa79c,
+ 0xa79e, 0xa79e,
+ 0xa7a0, 0xa7a0,
+ 0xa7a2, 0xa7a2,
+ 0xa7a4, 0xa7a4,
+ 0xa7a6, 0xa7a6,
+ 0xa7a8, 0xa7a8,
+ 0xa7aa, 0xa7ae,
+ 0xa7b0, 0xa7b4,
+ 0xa7b6, 0xa7b6,
+ 0xa7b8, 0xa7b8,
+ 0xa7ba, 0xa7ba,
+ 0xa7bc, 0xa7bc,
+ 0xa7be, 0xa7be,
+ 0xa7c0, 0xa7c0,
+ 0xa7c2, 0xa7c2,
+ 0xa7c4, 0xa7c7,
+ 0xa7c9, 0xa7c9,
+ 0xa7cb, 0xa7cc,
+ 0xa7ce, 0xa7ce,
+ 0xa7d0, 0xa7d0,
+ 0xa7d2, 0xa7d2,
+ 0xa7d4, 0xa7d4,
+ 0xa7d6, 0xa7d6,
+ 0xa7d8, 0xa7d8,
+ 0xa7da, 0xa7da,
+ 0xa7dc, 0xa7dc,
+ 0xa7f5, 0xa7f5,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0x10400, 0x10427,
+ 0x104b0, 0x104d3,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10c80, 0x10cb2,
+ 0x10d50, 0x10d65,
+ 0x118a0, 0x118bf,
+ 0x16e40, 0x16e5f,
+ 0x16ea0, 0x16eb8,
+ 0x1e900, 0x1e921,
+}; /* CR_Changes_When_Casefolded */
+
+/* 'Changes_When_Casemapped': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casemapped[] = {
+ 131,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00b5, 0x00b5,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x0137,
+ 0x0139, 0x018c,
+ 0x018e, 0x01a9,
+ 0x01ac, 0x01b9,
+ 0x01bc, 0x01bd,
+ 0x01bf, 0x01bf,
+ 0x01c4, 0x0220,
+ 0x0222, 0x0233,
+ 0x023a, 0x0254,
+ 0x0256, 0x0257,
+ 0x0259, 0x0259,
+ 0x025b, 0x025c,
+ 0x0260, 0x0261,
+ 0x0263, 0x0266,
+ 0x0268, 0x026c,
+ 0x026f, 0x026f,
+ 0x0271, 0x0272,
+ 0x0275, 0x0275,
+ 0x027d, 0x027d,
+ 0x0280, 0x0280,
+ 0x0282, 0x0283,
+ 0x0287, 0x028c,
+ 0x0292, 0x0292,
+ 0x029d, 0x029e,
+ 0x0345, 0x0345,
+ 0x0370, 0x0373,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03d1,
+ 0x03d5, 0x03f5,
+ 0x03f7, 0x03fb,
+ 0x03fd, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0561, 0x0587,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fd, 0x10ff,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1d79, 0x1d79,
+ 0x1d7d, 0x1d7d,
+ 0x1d8e, 0x1d8e,
+ 0x1e00, 0x1e9b,
+ 0x1e9e, 0x1e9e,
+ 0x1ea0, 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,
+ 0x2126, 0x2126,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x214e, 0x214e,
+ 0x2160, 0x217f,
+ 0x2183, 0x2184,
+ 0x24b6, 0x24e9,
+ 0x2c00, 0x2c70,
+ 0x2c72, 0x2c73,
+ 0x2c75, 0x2c76,
+ 0x2c7e, 0x2ce3,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0xa640, 0xa66d,
+ 0xa680, 0xa69b,
+ 0xa722, 0xa72f,
+ 0xa732, 0xa76f,
+ 0xa779, 0xa787,
+ 0xa78b, 0xa78d,
+ 0xa790, 0xa794,
+ 0xa796, 0xa7ae,
+ 0xa7b0, 0xa7dc,
+ 0xa7f5, 0xa7f6,
+ 0xab53, 0xab53,
+ 0xab70, 0xabbf,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10400, 0x1044f,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d50, 0x10d65,
+ 0x10d70, 0x10d85,
+ 0x118a0, 0x118df,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x1e900, 0x1e943,
+}; /* CR_Changes_When_Casemapped */
+
+/* 'ID_Start': Derived Property */
+static const OnigCodePoint CR_ID_Start[] = {
+ 684,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x08a0, 0x08c9,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 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,
+ 0x0af9, 0x0af9,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d04, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1711,
+ 0x171f, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1878,
+ 0x1880, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4c,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309b, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fe,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d23,
+ 0x10d4a, 0x10d65,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11003, 0x11037,
+ 0x11071, 0x11072,
+ 0x11075, 0x11075,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11144, 0x11144,
+ 0x11147, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x1123f, 0x11240,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113b7,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x116b8, 0x116b8,
+ 0x11700, 0x1171a,
+ 0x11740, 0x11746,
+ 0x11800, 0x1182b,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x1193f, 0x1193f,
+ 0x11941, 0x11941,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d0,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e3,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a89,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11bc0, 0x11be0,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d89,
+ 0x11d98, 0x11d98,
+ 0x11db0, 0x11ddb,
+ 0x11ee0, 0x11ef2,
+ 0x11f02, 0x11f02,
+ 0x11f04, 0x11f10,
+ 0x11f12, 0x11f33,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1611d,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a70, 0x16abe,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff2, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5f0,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6e2,
+ 0x1e6e4, 0x1e6e5,
+ 0x1e6e7, 0x1e6ed,
+ 0x1e6f0, 0x1e6f4,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e94b, 0x1e94b,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_ID_Start */
+
+/* 'ID_Continue': Derived Property */
+static const OnigCodePoint CR_ID_Continue[] = {
+ 799,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00b7, 0x00b7,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x0487,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x07fd, 0x07fd,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x0897, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 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,
+ 0x09fc, 0x09fc,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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,
+ 0x135d, 0x135f,
+ 0x1369, 0x1371,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x180f, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abd,
+ 0x1abf, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cfa,
+ 0x1d00, 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,
+ 0x200c, 0x200d,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309f,
+ 0x30a1, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa827,
+ 0xa82c, 0xa82c,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 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, 0xfe2f,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff3f, 0xff3f,
+ 0xff41, 0xff5a,
+ 0xff65, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d6d,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10eac,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10efa, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f50,
+ 0x10f70, 0x10f85,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11046,
+ 0x11066, 0x11075,
+ 0x1107f, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11144, 0x11147,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111c9, 0x111cc,
+ 0x111ce, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d3,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x1145e, 0x11461,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x11740, 0x11746,
+ 0x11800, 0x1183a,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11943,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e1,
+ 0x119e3, 0x119e4,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a99,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be0,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef6,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f42,
+ 0x11f50, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13440, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a70, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16d70, 0x16d79,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1ccf0, 0x1ccf9,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1fbf0, 0x1fbf9,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0100, 0xe01ef,
+}; /* CR_ID_Continue */
+
+/* 'XID_Start': Derived Property */
+static const OnigCodePoint CR_XID_Start[] = {
+ 691,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0370, 0x0374,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0620, 0x064a,
+ 0x066e, 0x066f,
+ 0x0671, 0x06d3,
+ 0x06d5, 0x06d5,
+ 0x06e5, 0x06e6,
+ 0x06ee, 0x06ef,
+ 0x06fa, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07ca, 0x07ea,
+ 0x07f4, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x0800, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0840, 0x0858,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x08a0, 0x08c9,
+ 0x0904, 0x0939,
+ 0x093d, 0x093d,
+ 0x0950, 0x0950,
+ 0x0958, 0x0961,
+ 0x0971, 0x0980,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09f0, 0x09f1,
+ 0x09fc, 0x09fc,
+ 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,
+ 0x0af9, 0x0af9,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c61,
+ 0x0c80, 0x0c80,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbd,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0cf1, 0x0cf2,
+ 0x0d04, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d4e, 0x0d4e,
+ 0x0d54, 0x0d56,
+ 0x0d5f, 0x0d61,
+ 0x0d7a, 0x0d7f,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e32,
+ 0x0e40, 0x0e46,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb0,
+ 0x0eb2, 0x0eb2,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f40, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f88, 0x0f8c,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1711,
+ 0x171f, 0x1731,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dc,
+ 0x1820, 0x1878,
+ 0x1880, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x1a00, 0x1a16,
+ 0x1a20, 0x1a54,
+ 0x1aa7, 0x1aa7,
+ 0x1b05, 0x1b33,
+ 0x1b45, 0x1b4c,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bba, 0x1be5,
+ 0x1c00, 0x1c23,
+ 0x1c4d, 0x1c4f,
+ 0x1c5a, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf6,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 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, 0x209c,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30fa,
+ 0x30fc, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa61f,
+ 0xa62a, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa67f, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa822,
+ 0xa840, 0xa873,
+ 0xa882, 0xa8b3,
+ 0xa8f2, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa8fe,
+ 0xa90a, 0xa925,
+ 0xa930, 0xa946,
+ 0xa960, 0xa97c,
+ 0xa984, 0xa9b2,
+ 0xa9cf, 0xa9cf,
+ 0xa9e0, 0xa9e4,
+ 0xa9e6, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaea,
+ 0xaaf2, 0xaaf4,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabe2,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfc5d,
+ 0xfc64, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdf9,
+ 0xfe71, 0xfe71,
+ 0xfe73, 0xfe73,
+ 0xfe77, 0xfe77,
+ 0xfe79, 0xfe79,
+ 0xfe7b, 0xfe7b,
+ 0xfe7d, 0xfe7d,
+ 0xfe7f, 0xfefc,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0xff66, 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae4,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d23,
+ 0x10d4a, 0x10d65,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10f00, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f70, 0x10f81,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11003, 0x11037,
+ 0x11071, 0x11072,
+ 0x11075, 0x11075,
+ 0x11083, 0x110af,
+ 0x110d0, 0x110e8,
+ 0x11103, 0x11126,
+ 0x11144, 0x11144,
+ 0x11147, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11183, 0x111b2,
+ 0x111c1, 0x111c4,
+ 0x111da, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122b,
+ 0x1123f, 0x11240,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112de,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11361,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113b7,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d3,
+ 0x11400, 0x11434,
+ 0x11447, 0x1144a,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114af,
+ 0x114c4, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x11580, 0x115ae,
+ 0x115d8, 0x115db,
+ 0x11600, 0x1162f,
+ 0x11644, 0x11644,
+ 0x11680, 0x116aa,
+ 0x116b8, 0x116b8,
+ 0x11700, 0x1171a,
+ 0x11740, 0x11746,
+ 0x11800, 0x1182b,
+ 0x118a0, 0x118df,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x1193f, 0x1193f,
+ 0x11941, 0x11941,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d0,
+ 0x119e1, 0x119e1,
+ 0x119e3, 0x119e3,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a3a, 0x11a3a,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a89,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11bc0, 0x11be0,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2e,
+ 0x11c40, 0x11c40,
+ 0x11c72, 0x11c8f,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d89,
+ 0x11d98, 0x11d98,
+ 0x11db0, 0x11ddb,
+ 0x11ee0, 0x11ef2,
+ 0x11f02, 0x11f02,
+ 0x11f04, 0x11f10,
+ 0x11f12, 0x11f33,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1611d,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a70, 0x16abe,
+ 0x16ad0, 0x16aed,
+ 0x16b00, 0x16b2f,
+ 0x16b40, 0x16b43,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f50, 0x16f50,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff2, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 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, 0x1d7cb,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5f0,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6e2,
+ 0x1e6e4, 0x1e6e5,
+ 0x1e6e7, 0x1e6ed,
+ 0x1e6f0, 0x1e6f4,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e900, 0x1e943,
+ 0x1e94b, 0x1e94b,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_XID_Start */
+
+/* 'XID_Continue': Derived Property */
+static const OnigCodePoint CR_XID_Continue[] = {
+ 806,
+ 0x0030, 0x0039,
+ 0x0041, 0x005a,
+ 0x005f, 0x005f,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00b5, 0x00b5,
+ 0x00b7, 0x00b7,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02c1,
+ 0x02c6, 0x02d1,
+ 0x02e0, 0x02e4,
+ 0x02ec, 0x02ec,
+ 0x02ee, 0x02ee,
+ 0x0300, 0x0374,
+ 0x0376, 0x0377,
+ 0x037b, 0x037d,
+ 0x037f, 0x037f,
+ 0x0386, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03f5,
+ 0x03f7, 0x0481,
+ 0x0483, 0x0487,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x0559,
+ 0x0560, 0x0588,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f2,
+ 0x0610, 0x061a,
+ 0x0620, 0x0669,
+ 0x066e, 0x06d3,
+ 0x06d5, 0x06dc,
+ 0x06df, 0x06e8,
+ 0x06ea, 0x06fc,
+ 0x06ff, 0x06ff,
+ 0x0710, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07f5,
+ 0x07fa, 0x07fa,
+ 0x07fd, 0x07fd,
+ 0x0800, 0x082d,
+ 0x0840, 0x085b,
+ 0x0860, 0x086a,
+ 0x0870, 0x0887,
+ 0x0889, 0x088f,
+ 0x0897, 0x08e1,
+ 0x08e3, 0x0963,
+ 0x0966, 0x096f,
+ 0x0971, 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,
+ 0x09fc, 0x09fc,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bef,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c80, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d54, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d6f,
+ 0x0d7a, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df3,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e4e,
+ 0x0e50, 0x0e59,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f00,
+ 0x0f18, 0x0f19,
+ 0x0f20, 0x0f29,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f84,
+ 0x0f86, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x1000, 0x1049,
+ 0x1050, 0x109d,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 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,
+ 0x135d, 0x135f,
+ 0x1369, 0x1371,
+ 0x1380, 0x138f,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1401, 0x166c,
+ 0x166f, 0x167f,
+ 0x1681, 0x169a,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1734,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17d3,
+ 0x17d7, 0x17d7,
+ 0x17dc, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x180b, 0x180d,
+ 0x180f, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1946, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x1a00, 0x1a1b,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa7, 0x1aa7,
+ 0x1ab0, 0x1abd,
+ 0x1abf, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b59,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1bf3,
+ 0x1c00, 0x1c37,
+ 0x1c40, 0x1c49,
+ 0x1c4d, 0x1c7d,
+ 0x1c80, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1cfa,
+ 0x1d00, 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,
+ 0x200c, 0x200d,
+ 0x203f, 0x2040,
+ 0x2054, 0x2054,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20f0,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2118, 0x211d,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212a, 0x2139,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c00, 0x2ce4,
+ 0x2ceb, 0x2cf3,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d6f,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2dff,
+ 0x3005, 0x3007,
+ 0x3021, 0x302f,
+ 0x3031, 0x3035,
+ 0x3038, 0x303c,
+ 0x3041, 0x3096,
+ 0x3099, 0x309a,
+ 0x309d, 0x309f,
+ 0x30a1, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x31a0, 0x31bf,
+ 0x31f0, 0x31ff,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0xa48c,
+ 0xa4d0, 0xa4fd,
+ 0xa500, 0xa60c,
+ 0xa610, 0xa62b,
+ 0xa640, 0xa66f,
+ 0xa674, 0xa67d,
+ 0xa67f, 0xa6f1,
+ 0xa717, 0xa71f,
+ 0xa722, 0xa788,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa827,
+ 0xa82c, 0xa82c,
+ 0xa840, 0xa873,
+ 0xa880, 0xa8c5,
+ 0xa8d0, 0xa8d9,
+ 0xa8e0, 0xa8f7,
+ 0xa8fb, 0xa8fb,
+ 0xa8fd, 0xa92d,
+ 0xa930, 0xa953,
+ 0xa960, 0xa97c,
+ 0xa980, 0xa9c0,
+ 0xa9cf, 0xa9d9,
+ 0xa9e0, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa60, 0xaa76,
+ 0xaa7a, 0xaac2,
+ 0xaadb, 0xaadd,
+ 0xaae0, 0xaaef,
+ 0xaaf2, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab69,
+ 0xab70, 0xabea,
+ 0xabec, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb28,
+ 0xfb2a, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfc5d,
+ 0xfc64, 0xfd3d,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdf9,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xfe33, 0xfe34,
+ 0xfe4d, 0xfe4f,
+ 0xfe71, 0xfe71,
+ 0xfe73, 0xfe73,
+ 0xfe77, 0xfe77,
+ 0xfe79, 0xfe79,
+ 0xfe7b, 0xfe7b,
+ 0xfe7d, 0xfe7d,
+ 0xfe7f, 0xfefc,
+ 0xff10, 0xff19,
+ 0xff21, 0xff3a,
+ 0xff3f, 0xff3f,
+ 0xff41, 0xff5a,
+ 0xff65, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10140, 0x10174,
+ 0x101fd, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102e0,
+ 0x10300, 0x1031f,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103cf,
+ 0x103d1, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089e,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10a60, 0x10a7c,
+ 0x10a80, 0x10a9c,
+ 0x10ac0, 0x10ac7,
+ 0x10ac9, 0x10ae6,
+ 0x10b00, 0x10b35,
+ 0x10b40, 0x10b55,
+ 0x10b60, 0x10b72,
+ 0x10b80, 0x10b91,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10d00, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d6d,
+ 0x10d6f, 0x10d85,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10eac,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10efa, 0x10f1c,
+ 0x10f27, 0x10f27,
+ 0x10f30, 0x10f50,
+ 0x10f70, 0x10f85,
+ 0x10fb0, 0x10fc4,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11046,
+ 0x11066, 0x11075,
+ 0x1107f, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x1113f,
+ 0x11144, 0x11147,
+ 0x11150, 0x11173,
+ 0x11176, 0x11176,
+ 0x11180, 0x111c4,
+ 0x111c9, 0x111cc,
+ 0x111ce, 0x111da,
+ 0x111dc, 0x111dc,
+ 0x11200, 0x11211,
+ 0x11213, 0x11237,
+ 0x1123e, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a8,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d3,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1144a,
+ 0x11450, 0x11459,
+ 0x1145e, 0x11461,
+ 0x11480, 0x114c5,
+ 0x114c7, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c0,
+ 0x115d8, 0x115dd,
+ 0x11600, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11739,
+ 0x11740, 0x11746,
+ 0x11800, 0x1183a,
+ 0x118a0, 0x118e9,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11943,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e1,
+ 0x119e3, 0x119e4,
+ 0x11a00, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a50, 0x11a99,
+ 0x11a9d, 0x11a9d,
+ 0x11ab0, 0x11af8,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be0,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c40,
+ 0x11c50, 0x11c59,
+ 0x11c72, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef6,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f42,
+ 0x11f50, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff0,
+ 0x13000, 0x1342f,
+ 0x13440, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a70, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af4,
+ 0x16b00, 0x16b36,
+ 0x16b40, 0x16b43,
+ 0x16b50, 0x16b59,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d6c,
+ 0x16d70, 0x16d79,
+ 0x16e40, 0x16e7f,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9d, 0x1bc9e,
+ 0x1ccf0, 0x1ccf9,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14e,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1fbf0, 0x1fbf9,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+ 0xe0100, 0xe01ef,
+}; /* CR_XID_Continue */
+
+/* 'Default_Ignorable_Code_Point': Derived Property */
+static const OnigCodePoint CR_Default_Ignorable_Code_Point[] = {
+ 17,
+ 0x00ad, 0x00ad,
+ 0x034f, 0x034f,
+ 0x061c, 0x061c,
+ 0x115f, 0x1160,
+ 0x17b4, 0x17b5,
+ 0x180b, 0x180f,
+ 0x200b, 0x200f,
+ 0x202a, 0x202e,
+ 0x2060, 0x206f,
+ 0x3164, 0x3164,
+ 0xfe00, 0xfe0f,
+ 0xfeff, 0xfeff,
+ 0xffa0, 0xffa0,
+ 0xfff0, 0xfff8,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0000, 0xe0fff,
+}; /* CR_Default_Ignorable_Code_Point */
+
+/* 'Grapheme_Extend': Derived Property */
+static const OnigCodePoint CR_Grapheme_Extend[] = {
+ 383,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x0897, 0x089f,
+ 0x08ca, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09be,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bbe,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c00,
+ 0x0c04, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cc0,
+ 0x0cc2, 0x0cc2,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d3e,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d81,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dcf,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0ddf, 0x0ddf,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1715,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b3d,
+ 0x1b42, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf3,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x200c, 0x200c,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa953, 0xa953,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bd,
+ 0xa9c0, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xaaf6, 0xaaf6,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xff9e, 0xff9f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d6d,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111c0, 0x111c0,
+ 0x111c9, 0x111cc,
+ 0x111cf, 0x111cf,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133b, 0x1133c,
+ 0x1133e, 0x1133e,
+ 0x11340, 0x11340,
+ 0x1134d, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113b8, 0x113b8,
+ 0x113bb, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113c9,
+ 0x113ce, 0x113d0,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b0, 0x114b0,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bd, 0x114bd,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115af, 0x115af,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b7,
+ 0x1171d, 0x1171d,
+ 0x1171f, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x1182f, 0x11837,
+ 0x11839, 0x1183a,
+ 0x11930, 0x11930,
+ 0x1193b, 0x1193e,
+ 0x11943, 0x11943,
+ 0x119d4, 0x119d7,
+ 0x119da, 0x119db,
+ 0x119e0, 0x119e0,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11b60, 0x11b60,
+ 0x11b62, 0x11b64,
+ 0x11b66, 0x11b66,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d90, 0x11d91,
+ 0x11d95, 0x11d95,
+ 0x11d97, 0x11d97,
+ 0x11ef3, 0x11ef4,
+ 0x11f00, 0x11f01,
+ 0x11f36, 0x11f3a,
+ 0x11f40, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13440, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x16129,
+ 0x1612d, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f4f, 0x16f4f,
+ 0x16f8f, 0x16f92,
+ 0x16fe4, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x1bc9d, 0x1bc9e,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4ec, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Grapheme_Extend */
+
+/* 'Grapheme_Base': Derived Property */
+static const OnigCodePoint CR_Grapheme_Base[] = {
+ 904,
+ 0x0020, 0x007e,
+ 0x00a0, 0x00ac,
+ 0x00ae, 0x02ff,
+ 0x0370, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0482,
+ 0x048a, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x05be, 0x05be,
+ 0x05c0, 0x05c0,
+ 0x05c3, 0x05c3,
+ 0x05c6, 0x05c6,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0606, 0x060f,
+ 0x061b, 0x061b,
+ 0x061d, 0x064a,
+ 0x0660, 0x066f,
+ 0x0671, 0x06d5,
+ 0x06de, 0x06de,
+ 0x06e5, 0x06e6,
+ 0x06e9, 0x06e9,
+ 0x06ee, 0x070d,
+ 0x0710, 0x0710,
+ 0x0712, 0x072f,
+ 0x074d, 0x07a5,
+ 0x07b1, 0x07b1,
+ 0x07c0, 0x07ea,
+ 0x07f4, 0x07fa,
+ 0x07fe, 0x0815,
+ 0x081a, 0x081a,
+ 0x0824, 0x0824,
+ 0x0828, 0x0828,
+ 0x0830, 0x083e,
+ 0x0840, 0x0858,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x088f,
+ 0x08a0, 0x08c9,
+ 0x0903, 0x0939,
+ 0x093b, 0x093b,
+ 0x093d, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x0950,
+ 0x0958, 0x0961,
+ 0x0964, 0x0980,
+ 0x0982, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bd, 0x09bd,
+ 0x09bf, 0x09c0,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09ce, 0x09ce,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e1,
+ 0x09e6, 0x09fd,
+ 0x0a03, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3e, 0x0a40,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a6f,
+ 0x0a72, 0x0a74,
+ 0x0a76, 0x0a76,
+ 0x0a83, 0x0a83,
+ 0x0a85, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abd, 0x0ac0,
+ 0x0ac9, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae1,
+ 0x0ae6, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b02, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3d, 0x0b3d,
+ 0x0b40, 0x0b40,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b77,
+ 0x0b83, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb9,
+ 0x0bbf, 0x0bbf,
+ 0x0bc1, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd0, 0x0bd0,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c3d,
+ 0x0c41, 0x0c44,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c61,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c80,
+ 0x0c82, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbd, 0x0cbe,
+ 0x0cc1, 0x0cc1,
+ 0x0cc3, 0x0cc4,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce1,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d02, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d3d,
+ 0x0d3f, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d4e, 0x0d4f,
+ 0x0d54, 0x0d56,
+ 0x0d58, 0x0d61,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dd0, 0x0dd1,
+ 0x0dd8, 0x0dde,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e30,
+ 0x0e32, 0x0e33,
+ 0x0e3f, 0x0e46,
+ 0x0e4f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0eb0,
+ 0x0eb2, 0x0eb3,
+ 0x0ebd, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f17,
+ 0x0f1a, 0x0f34,
+ 0x0f36, 0x0f36,
+ 0x0f38, 0x0f38,
+ 0x0f3a, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f7f, 0x0f7f,
+ 0x0f85, 0x0f85,
+ 0x0f88, 0x0f8c,
+ 0x0fbe, 0x0fc5,
+ 0x0fc7, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x102c,
+ 0x1031, 0x1031,
+ 0x1038, 0x1038,
+ 0x103b, 0x103c,
+ 0x103f, 0x1057,
+ 0x105a, 0x105d,
+ 0x1061, 0x1070,
+ 0x1075, 0x1081,
+ 0x1083, 0x1084,
+ 0x1087, 0x108c,
+ 0x108e, 0x109c,
+ 0x109e, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x1360, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1711,
+ 0x171f, 0x1731,
+ 0x1735, 0x1736,
+ 0x1740, 0x1751,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1780, 0x17b3,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x17d4, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x180a,
+ 0x1810, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x1884,
+ 0x1887, 0x18a8,
+ 0x18aa, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a16,
+ 0x1a19, 0x1a1a,
+ 0x1a1e, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a61, 0x1a61,
+ 0x1a63, 0x1a64,
+ 0x1a6d, 0x1a72,
+ 0x1a80, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b04, 0x1b33,
+ 0x1b3e, 0x1b41,
+ 0x1b45, 0x1b4c,
+ 0x1b4e, 0x1b6a,
+ 0x1b74, 0x1b7f,
+ 0x1b82, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1bae, 0x1be5,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1bfc, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd3, 0x1cd3,
+ 0x1ce1, 0x1ce1,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf7,
+ 0x1cfa, 0x1cfa,
+ 0x1d00, 0x1dbf,
+ 0x1e00, 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, 0x200a,
+ 0x2010, 0x2027,
+ 0x202f, 0x205f,
+ 0x2070, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c1,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2cee,
+ 0x2cf2, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2e00, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x3029,
+ 0x3030, 0x303f,
+ 0x3041, 0x3096,
+ 0x309b, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa66e,
+ 0xa673, 0xa673,
+ 0xa67e, 0xa69d,
+ 0xa6a0, 0xa6ef,
+ 0xa6f2, 0xa6f7,
+ 0xa700, 0xa7dc,
+ 0xa7f1, 0xa801,
+ 0xa803, 0xa805,
+ 0xa807, 0xa80a,
+ 0xa80c, 0xa824,
+ 0xa827, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c3,
+ 0xa8ce, 0xa8d9,
+ 0xa8f2, 0xa8fe,
+ 0xa900, 0xa925,
+ 0xa92e, 0xa946,
+ 0xa952, 0xa952,
+ 0xa95f, 0xa97c,
+ 0xa983, 0xa9b2,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9be, 0xa9bf,
+ 0xa9c1, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9e4,
+ 0xa9e6, 0xa9fe,
+ 0xaa00, 0xaa28,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa40, 0xaa42,
+ 0xaa44, 0xaa4b,
+ 0xaa4d, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa7d, 0xaaaf,
+ 0xaab1, 0xaab1,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaabd,
+ 0xaac0, 0xaac0,
+ 0xaac2, 0xaac2,
+ 0xaadb, 0xaaeb,
+ 0xaaee, 0xaaf5,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabec,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb1d,
+ 0xfb1f, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfdcf,
+ 0xfdf0, 0xfdff,
+ 0xfe10, 0xfe19,
+ 0xfe30, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xff01, 0xff9d,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffc, 0xfffd,
+ 0x10000, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fc,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e1, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x10375,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a40, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae4,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d23,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d6e, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10ead, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f45,
+ 0x10f51, 0x10f59,
+ 0x10f70, 0x10f81,
+ 0x10f86, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x11000,
+ 0x11002, 0x11037,
+ 0x11047, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11071, 0x11072,
+ 0x11075, 0x11075,
+ 0x11082, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x110bb, 0x110bc,
+ 0x110be, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11103, 0x11126,
+ 0x1112c, 0x1112c,
+ 0x11136, 0x11147,
+ 0x11150, 0x11172,
+ 0x11174, 0x11176,
+ 0x11182, 0x111b5,
+ 0x111bf, 0x111bf,
+ 0x111c1, 0x111c8,
+ 0x111cd, 0x111ce,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1122e,
+ 0x11232, 0x11233,
+ 0x11238, 0x1123d,
+ 0x1123f, 0x11240,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112de,
+ 0x112e0, 0x112e2,
+ 0x112f0, 0x112f9,
+ 0x11302, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133d, 0x1133d,
+ 0x1133f, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11350, 0x11350,
+ 0x1135d, 0x11363,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113b7,
+ 0x113b9, 0x113ba,
+ 0x113ca, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x113d1, 0x113d1,
+ 0x113d3, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x11400, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x11447, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x1145f, 0x11461,
+ 0x11480, 0x114af,
+ 0x114b1, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114bc,
+ 0x114be, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x114c4, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115ae,
+ 0x115b0, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x115c1, 0x115db,
+ 0x11600, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x11641, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116aa,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x116b8, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171e, 0x1171e,
+ 0x11720, 0x11721,
+ 0x11726, 0x11726,
+ 0x11730, 0x11746,
+ 0x11800, 0x1182e,
+ 0x11838, 0x11838,
+ 0x1183b, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x11931, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193f, 0x11942,
+ 0x11944, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d3,
+ 0x119dc, 0x119df,
+ 0x119e1, 0x119e4,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a39, 0x11a3a,
+ 0x11a3f, 0x11a46,
+ 0x11a50, 0x11a50,
+ 0x11a57, 0x11a58,
+ 0x11a5c, 0x11a89,
+ 0x11a97, 0x11a97,
+ 0x11a9a, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11b61, 0x11b61,
+ 0x11b65, 0x11b65,
+ 0x11b67, 0x11b67,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11c40, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d30,
+ 0x11d46, 0x11d46,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d93, 0x11d94,
+ 0x11d96, 0x11d96,
+ 0x11d98, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef2,
+ 0x11ef5, 0x11ef8,
+ 0x11f02, 0x11f10,
+ 0x11f12, 0x11f35,
+ 0x11f3e, 0x11f3f,
+ 0x11f43, 0x11f59,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x1342f,
+ 0x13441, 0x13446,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x1611d,
+ 0x1612a, 0x1612c,
+ 0x16130, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af5, 0x16af5,
+ 0x16b00, 0x16b2f,
+ 0x16b37, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f50, 0x16f87,
+ 0x16f93, 0x16f9f,
+ 0x16fe0, 0x16fe3,
+ 0x16ff2, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bc9c,
+ 0x1bc9f, 0x1bc9f,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d164,
+ 0x1d16a, 0x1d16c,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1ea,
+ 0x1d200, 0x1d241,
+ 0x1d245, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d9ff,
+ 0x1da37, 0x1da3a,
+ 0x1da6d, 0x1da74,
+ 0x1da76, 0x1da83,
+ 0x1da85, 0x1da8b,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e030, 0x1e06d,
+ 0x1e100, 0x1e12c,
+ 0x1e137, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ad,
+ 0x1e2c0, 0x1e2eb,
+ 0x1e2f0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4eb,
+ 0x1e4f0, 0x1e4f9,
+ 0x1e5d0, 0x1e5ed,
+ 0x1e5f0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6e2,
+ 0x1e6e4, 0x1e6e5,
+ 0x1e6e7, 0x1e6ed,
+ 0x1e6f0, 0x1e6f4,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8cf,
+ 0x1e900, 0x1e943,
+ 0x1e94b, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Grapheme_Base */
+
+/* 'Grapheme_Link': Derived Property */
+static const OnigCodePoint CR_Grapheme_Link[] = {
+ 58,
+ 0x094d, 0x094d,
+ 0x09cd, 0x09cd,
+ 0x0a4d, 0x0a4d,
+ 0x0acd, 0x0acd,
+ 0x0b4d, 0x0b4d,
+ 0x0bcd, 0x0bcd,
+ 0x0c4d, 0x0c4d,
+ 0x0ccd, 0x0ccd,
+ 0x0d3b, 0x0d3c,
+ 0x0d4d, 0x0d4d,
+ 0x0dca, 0x0dca,
+ 0x0e3a, 0x0e3a,
+ 0x0eba, 0x0eba,
+ 0x0f84, 0x0f84,
+ 0x1039, 0x103a,
+ 0x1714, 0x1715,
+ 0x1734, 0x1734,
+ 0x17d2, 0x17d2,
+ 0x1a60, 0x1a60,
+ 0x1b44, 0x1b44,
+ 0x1baa, 0x1bab,
+ 0x1bf2, 0x1bf3,
+ 0x2d7f, 0x2d7f,
+ 0xa806, 0xa806,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c4,
+ 0xa953, 0xa953,
+ 0xa9c0, 0xa9c0,
+ 0xaaf6, 0xaaf6,
+ 0xabed, 0xabed,
+ 0x10a3f, 0x10a3f,
+ 0x11046, 0x11046,
+ 0x11070, 0x11070,
+ 0x1107f, 0x1107f,
+ 0x110b9, 0x110b9,
+ 0x11133, 0x11134,
+ 0x111c0, 0x111c0,
+ 0x11235, 0x11235,
+ 0x112ea, 0x112ea,
+ 0x1134d, 0x1134d,
+ 0x113ce, 0x113d0,
+ 0x11442, 0x11442,
+ 0x114c2, 0x114c2,
+ 0x115bf, 0x115bf,
+ 0x1163f, 0x1163f,
+ 0x116b6, 0x116b6,
+ 0x1172b, 0x1172b,
+ 0x11839, 0x11839,
+ 0x1193d, 0x1193e,
+ 0x119e0, 0x119e0,
+ 0x11a34, 0x11a34,
+ 0x11a47, 0x11a47,
+ 0x11a99, 0x11a99,
+ 0x11c3f, 0x11c3f,
+ 0x11d44, 0x11d45,
+ 0x11d97, 0x11d97,
+ 0x11f41, 0x11f42,
+ 0x1612f, 0x1612f,
+}; /* CR_Grapheme_Link */
+
+/* 'InCB_Linker': Derived Property */
+static const OnigCodePoint CR_InCB_Linker[] = {
+ 20,
+ 0x094d, 0x094d,
+ 0x09cd, 0x09cd,
+ 0x0acd, 0x0acd,
+ 0x0b4d, 0x0b4d,
+ 0x0c4d, 0x0c4d,
+ 0x0d4d, 0x0d4d,
+ 0x1039, 0x1039,
+ 0x17d2, 0x17d2,
+ 0x1a60, 0x1a60,
+ 0x1b44, 0x1b44,
+ 0x1bab, 0x1bab,
+ 0xa9c0, 0xa9c0,
+ 0xaaf6, 0xaaf6,
+ 0x10a3f, 0x10a3f,
+ 0x11133, 0x11133,
+ 0x113d0, 0x113d0,
+ 0x1193e, 0x1193e,
+ 0x11a47, 0x11a47,
+ 0x11a99, 0x11a99,
+ 0x11f42, 0x11f42,
+}; /* CR_InCB_Linker */
+
+/* 'InCB_Consonant': Derived Property */
+static const OnigCodePoint CR_InCB_Consonant[] = {
+ 76,
+ 0x0915, 0x0939,
+ 0x0958, 0x095f,
+ 0x0978, 0x097f,
+ 0x0995, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09df,
+ 0x09f0, 0x09f1,
+ 0x0a95, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0af9, 0x0af9,
+ 0x0b15, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b5f,
+ 0x0b71, 0x0b71,
+ 0x0c15, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c58, 0x0c5a,
+ 0x0d15, 0x0d3a,
+ 0x1000, 0x102a,
+ 0x103f, 0x103f,
+ 0x1050, 0x1055,
+ 0x105a, 0x105d,
+ 0x1061, 0x1061,
+ 0x1065, 0x1066,
+ 0x106e, 0x1070,
+ 0x1075, 0x1081,
+ 0x108e, 0x108e,
+ 0x1780, 0x17b3,
+ 0x1a20, 0x1a54,
+ 0x1b0b, 0x1b0c,
+ 0x1b13, 0x1b33,
+ 0x1b45, 0x1b4c,
+ 0x1b83, 0x1ba0,
+ 0x1bae, 0x1baf,
+ 0x1bbb, 0x1bbd,
+ 0xa989, 0xa98b,
+ 0xa98f, 0xa9b2,
+ 0xa9e0, 0xa9e4,
+ 0xa9e7, 0xa9ef,
+ 0xa9fa, 0xa9fe,
+ 0xaa60, 0xaa6f,
+ 0xaa71, 0xaa73,
+ 0xaa7a, 0xaa7a,
+ 0xaa7e, 0xaa7f,
+ 0xaae0, 0xaaea,
+ 0xabc0, 0xabda,
+ 0x10a00, 0x10a00,
+ 0x10a10, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x11103, 0x11126,
+ 0x11144, 0x11144,
+ 0x11147, 0x11147,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x11900, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x1192f,
+ 0x11a00, 0x11a00,
+ 0x11a0b, 0x11a32,
+ 0x11a50, 0x11a50,
+ 0x11a5c, 0x11a83,
+ 0x11f04, 0x11f10,
+ 0x11f12, 0x11f33,
+}; /* CR_InCB_Consonant */
+
+/* 'InCB_Extend': Derived Property */
+static const OnigCodePoint CR_InCB_Extend[] = {
+ 377,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x0897, 0x089f,
+ 0x08ca, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09be,
+ 0x09c1, 0x09c4,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b55, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bbe,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c00,
+ 0x0c04, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cc0,
+ 0x0cc2, 0x0cc2,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d3e,
+ 0x0d41, 0x0d44,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d81,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dcf,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0ddf, 0x0ddf,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x103a, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1715,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d1,
+ 0x17d3, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b3d,
+ 0x1b42, 0x1b43,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1baa,
+ 0x1bac, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf3,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x200d, 0x200d,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa953, 0xa953,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bd,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xff9e, 0xff9f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d6d,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11132,
+ 0x11134, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111c0, 0x111c0,
+ 0x111c9, 0x111cc,
+ 0x111cf, 0x111cf,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133b, 0x1133c,
+ 0x1133e, 0x1133e,
+ 0x11340, 0x11340,
+ 0x1134d, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113b8, 0x113b8,
+ 0x113bb, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113c9,
+ 0x113ce, 0x113cf,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b0, 0x114b0,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bd, 0x114bd,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115af, 0x115af,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b7,
+ 0x1171d, 0x1171d,
+ 0x1171f, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x1182f, 0x11837,
+ 0x11839, 0x1183a,
+ 0x11930, 0x11930,
+ 0x1193b, 0x1193d,
+ 0x11943, 0x11943,
+ 0x119d4, 0x119d7,
+ 0x119da, 0x119db,
+ 0x119e0, 0x119e0,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a98,
+ 0x11b60, 0x11b60,
+ 0x11b62, 0x11b64,
+ 0x11b66, 0x11b66,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d90, 0x11d91,
+ 0x11d95, 0x11d95,
+ 0x11d97, 0x11d97,
+ 0x11ef3, 0x11ef4,
+ 0x11f00, 0x11f01,
+ 0x11f36, 0x11f3a,
+ 0x11f40, 0x11f41,
+ 0x11f5a, 0x11f5a,
+ 0x13440, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x16129,
+ 0x1612d, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f4f, 0x16f4f,
+ 0x16f8f, 0x16f92,
+ 0x16fe4, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x1bc9d, 0x1bc9e,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4ec, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0x1f3fb, 0x1f3ff,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_InCB_Extend */
+
+/* 'Common': Script */
+static const OnigCodePoint CR_Common[] = {
+ 176,
+ 0x0000, 0x0040,
+ 0x005b, 0x0060,
+ 0x007b, 0x00a9,
+ 0x00ab, 0x00b9,
+ 0x00bb, 0x00bf,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x02b9, 0x02df,
+ 0x02e5, 0x02e9,
+ 0x02ec, 0x02ff,
+ 0x0374, 0x0374,
+ 0x037e, 0x037e,
+ 0x0385, 0x0385,
+ 0x0387, 0x0387,
+ 0x0605, 0x0605,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0640, 0x0640,
+ 0x06dd, 0x06dd,
+ 0x08e2, 0x08e2,
+ 0x0964, 0x0965,
+ 0x0e3f, 0x0e3f,
+ 0x0fd5, 0x0fd8,
+ 0x10fb, 0x10fb,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x1802, 0x1803,
+ 0x1805, 0x1805,
+ 0x1cd3, 0x1cd3,
+ 0x1ce1, 0x1ce1,
+ 0x1ce9, 0x1cec,
+ 0x1cee, 0x1cf3,
+ 0x1cf5, 0x1cf7,
+ 0x1cfa, 0x1cfa,
+ 0x2000, 0x200b,
+ 0x200e, 0x2064,
+ 0x2066, 0x2070,
+ 0x2074, 0x207e,
+ 0x2080, 0x208e,
+ 0x20a0, 0x20c1,
+ 0x2100, 0x2125,
+ 0x2127, 0x2129,
+ 0x212c, 0x2131,
+ 0x2133, 0x214d,
+ 0x214f, 0x215f,
+ 0x2189, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x27ff,
+ 0x2900, 0x2b73,
+ 0x2b76, 0x2bff,
+ 0x2e00, 0x2e5d,
+ 0x2ff0, 0x3004,
+ 0x3006, 0x3006,
+ 0x3008, 0x3020,
+ 0x3030, 0x3037,
+ 0x303c, 0x303f,
+ 0x309b, 0x309c,
+ 0x30a0, 0x30a0,
+ 0x30fb, 0x30fc,
+ 0x3190, 0x319f,
+ 0x31c0, 0x31e5,
+ 0x31ef, 0x31ef,
+ 0x3220, 0x325f,
+ 0x327f, 0x32cf,
+ 0x32ff, 0x32ff,
+ 0x3358, 0x33ff,
+ 0x4dc0, 0x4dff,
+ 0xa700, 0xa721,
+ 0xa788, 0xa78a,
+ 0xa830, 0xa839,
+ 0xa92e, 0xa92e,
+ 0xa9cf, 0xa9cf,
+ 0xab5b, 0xab5b,
+ 0xab6a, 0xab6b,
+ 0xfd3e, 0xfd3f,
+ 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,
+ 0x10190, 0x1019c,
+ 0x101d0, 0x101fc,
+ 0x102e1, 0x102fb,
+ 0x1bca0, 0x1bca3,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d166,
+ 0x1d16a, 0x1d17a,
+ 0x1d183, 0x1d184,
+ 0x1d18c, 0x1d1a9,
+ 0x1d1ae, 0x1d1ea,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+}; /* CR_Common */
+
+/* 'Latin': Script */
+static const OnigCodePoint CR_Latin[] = {
+ 36,
+ 0x0041, 0x005a,
+ 0x0061, 0x007a,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x00c0, 0x00d6,
+ 0x00d8, 0x00f6,
+ 0x00f8, 0x02b8,
+ 0x02e0, 0x02e4,
+ 0x1d00, 0x1d25,
+ 0x1d2c, 0x1d5c,
+ 0x1d62, 0x1d65,
+ 0x1d6b, 0x1d77,
+ 0x1d79, 0x1dbe,
+ 0x1e00, 0x1eff,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x212a, 0x212b,
+ 0x2132, 0x2132,
+ 0x214e, 0x214e,
+ 0x2160, 0x2188,
+ 0x2c60, 0x2c7f,
+ 0xa722, 0xa787,
+ 0xa78b, 0xa7dc,
+ 0xa7f1, 0xa7ff,
+ 0xab30, 0xab5a,
+ 0xab5c, 0xab64,
+ 0xab66, 0xab69,
+ 0xfb00, 0xfb06,
+ 0xff21, 0xff3a,
+ 0xff41, 0xff5a,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+}; /* CR_Latin */
+
+/* 'Greek': Script */
+static const OnigCodePoint CR_Greek[] = {
+ 36,
+ 0x0370, 0x0373,
+ 0x0375, 0x0377,
+ 0x037a, 0x037d,
+ 0x037f, 0x037f,
+ 0x0384, 0x0384,
+ 0x0386, 0x0386,
+ 0x0388, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03e1,
+ 0x03f0, 0x03ff,
+ 0x1d26, 0x1d2a,
+ 0x1d5d, 0x1d61,
+ 0x1d66, 0x1d6a,
+ 0x1dbf, 0x1dbf,
+ 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,
+ 0xab65, 0xab65,
+ 0x10140, 0x1018e,
+ 0x101a0, 0x101a0,
+ 0x1d200, 0x1d245,
+}; /* CR_Greek */
+
+/* 'Cyrillic': Script */
+static const OnigCodePoint CR_Cyrillic[] = {
+ 10,
+ 0x0400, 0x0484,
+ 0x0487, 0x052f,
+ 0x1c80, 0x1c8a,
+ 0x1d2b, 0x1d2b,
+ 0x1d78, 0x1d78,
+ 0x2de0, 0x2dff,
+ 0xa640, 0xa69f,
+ 0xfe2e, 0xfe2f,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+}; /* CR_Cyrillic */
+
+/* 'Armenian': Script */
+static const OnigCodePoint CR_Armenian[] = {
+ 4,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0xfb13, 0xfb17,
+}; /* CR_Armenian */
+
+/* 'Hebrew': Script */
+static const OnigCodePoint CR_Hebrew[] = {
+ 9,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfb4f,
+}; /* CR_Hebrew */
+
+/* 'Arabic': Script */
+static const OnigCodePoint CR_Arabic[] = {
+ 56,
+ 0x0600, 0x0604,
+ 0x0606, 0x060b,
+ 0x060d, 0x061a,
+ 0x061c, 0x061e,
+ 0x0620, 0x063f,
+ 0x0641, 0x064a,
+ 0x0656, 0x066f,
+ 0x0671, 0x06dc,
+ 0x06de, 0x06ff,
+ 0x0750, 0x077f,
+ 0x0870, 0x0891,
+ 0x0897, 0x08e1,
+ 0x08e3, 0x08ff,
+ 0xfb50, 0xfd3d,
+ 0xfd40, 0xfdcf,
+ 0xfdf0, 0xfdff,
+ 0xfe70, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0x10e60, 0x10e7e,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10efa, 0x10eff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+}; /* CR_Arabic */
+
+/* 'Syriac': Script */
+static const OnigCodePoint CR_Syriac[] = {
+ 4,
+ 0x0700, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x074f,
+ 0x0860, 0x086a,
+}; /* CR_Syriac */
+
+/* 'Thaana': Script */
+static const OnigCodePoint CR_Thaana[] = {
+ 1,
+ 0x0780, 0x07b1,
+}; /* CR_Thaana */
+
+/* 'Devanagari': Script */
+static const OnigCodePoint CR_Devanagari[] = {
+ 5,
+ 0x0900, 0x0950,
+ 0x0955, 0x0963,
+ 0x0966, 0x097f,
+ 0xa8e0, 0xa8ff,
+ 0x11b00, 0x11b09,
+}; /* CR_Devanagari */
+
+/* 'Bengali': Script */
+static const OnigCodePoint CR_Bengali[] = {
+ 14,
+ 0x0980, 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, 0x09fe,
+}; /* CR_Bengali */
+
+/* 'Gurmukhi': Script */
+static const OnigCodePoint CR_Gurmukhi[] = {
+ 16,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+}; /* CR_Gurmukhi */
+
+/* '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, 0x0af1,
+ 0x0af9, 0x0aff,
+}; /* CR_Gujarati */
+
+/* 'Oriya': Script */
+static const OnigCodePoint CR_Oriya[] = {
+ 14,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+}; /* CR_Oriya */
+
+/* 'Tamil': Script */
+static const OnigCodePoint CR_Tamil[] = {
+ 18,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x11fff,
+}; /* CR_Tamil */
+
+/* 'Telugu': Script */
+static const OnigCodePoint CR_Telugu[] = {
+ 13,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c7f,
+}; /* CR_Telugu */
+
+/* 'Kannada': Script */
+static const OnigCodePoint CR_Kannada[] = {
+ 13,
+ 0x0c80, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+}; /* CR_Kannada */
+
+/* 'Malayalam': Script */
+static const OnigCodePoint CR_Malayalam[] = {
+ 7,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+}; /* CR_Malayalam */
+
+/* 'Sinhala': Script */
+static const OnigCodePoint CR_Sinhala[] = {
+ 13,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x111e1, 0x111f4,
+}; /* CR_Sinhala */
+
+/* 'Thai': Script */
+static const OnigCodePoint CR_Thai[] = {
+ 2,
+ 0x0e01, 0x0e3a,
+ 0x0e40, 0x0e5b,
+}; /* CR_Thai */
+
+/* 'Lao': Script */
+static const OnigCodePoint CR_Lao[] = {
+ 11,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+}; /* CR_Lao */
+
+/* 'Tibetan': Script */
+static const OnigCodePoint CR_Tibetan[] = {
+ 7,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd4,
+ 0x0fd9, 0x0fda,
+}; /* CR_Tibetan */
+
+/* 'Myanmar': Script */
+static const OnigCodePoint CR_Myanmar[] = {
+ 4,
+ 0x1000, 0x109f,
+ 0xa9e0, 0xa9fe,
+ 0xaa60, 0xaa7f,
+ 0x116d0, 0x116e3,
+}; /* CR_Myanmar */
+
+/* 'Georgian': Script */
+static const OnigCodePoint CR_Georgian[] = {
+ 10,
+ 0x10a0, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 0x10fa,
+ 0x10fc, 0x10ff,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cbf,
+ 0x2d00, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+}; /* CR_Georgian */
+
+/* 'Hangul': Script */
+static const OnigCodePoint CR_Hangul[] = {
+ 14,
+ 0x1100, 0x11ff,
+ 0x302e, 0x302f,
+ 0x3131, 0x318e,
+ 0x3200, 0x321e,
+ 0x3260, 0x327e,
+ 0xa960, 0xa97c,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xffa0, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+}; /* CR_Hangul */
+
+/* 'Ethiopic': Script */
+static const OnigCodePoint CR_Ethiopic[] = {
+ 36,
+ 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+}; /* CR_Ethiopic */
+
+/* 'Cherokee': Script */
+static const OnigCodePoint CR_Cherokee[] = {
+ 3,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0xab70, 0xabbf,
+}; /* CR_Cherokee */
+
+/* 'Canadian_Aboriginal': Script */
+static const OnigCodePoint CR_Canadian_Aboriginal[] = {
+ 3,
+ 0x1400, 0x167f,
+ 0x18b0, 0x18f5,
+ 0x11ab0, 0x11abf,
+}; /* CR_Canadian_Aboriginal */
+
+/* 'Ogham': Script */
+static const OnigCodePoint CR_Ogham[] = {
+ 1,
+ 0x1680, 0x169c,
+}; /* CR_Ogham */
+
+/* 'Runic': Script */
+static const OnigCodePoint CR_Runic[] = {
+ 2,
+ 0x16a0, 0x16ea,
+ 0x16ee, 0x16f8,
+}; /* CR_Runic */
+
+/* 'Khmer': Script */
+static const OnigCodePoint CR_Khmer[] = {
+ 4,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x19e0, 0x19ff,
+}; /* CR_Khmer */
+
+/* 'Mongolian': Script */
+static const OnigCodePoint CR_Mongolian[] = {
+ 6,
+ 0x1800, 0x1801,
+ 0x1804, 0x1804,
+ 0x1806, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x11660, 0x1166c,
+}; /* CR_Mongolian */
+
+/* 'Hiragana': Script */
+static const OnigCodePoint CR_Hiragana[] = {
+ 6,
+ 0x3041, 0x3096,
+ 0x309d, 0x309f,
+ 0x1b001, 0x1b11f,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1f200, 0x1f200,
+}; /* CR_Hiragana */
+
+/* 'Katakana': Script */
+static const OnigCodePoint CR_Katakana[] = {
+ 14,
+ 0x30a1, 0x30fa,
+ 0x30fd, 0x30ff,
+ 0x31f0, 0x31ff,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3357,
+ 0xff66, 0xff6f,
+ 0xff71, 0xff9d,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b000,
+ 0x1b120, 0x1b122,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+}; /* CR_Katakana */
+
+/* 'Bopomofo': Script */
+static const OnigCodePoint CR_Bopomofo[] = {
+ 3,
+ 0x02ea, 0x02eb,
+ 0x3105, 0x312f,
+ 0x31a0, 0x31bf,
+}; /* CR_Bopomofo */
+
+/* 'Han': Script */
+static const OnigCodePoint CR_Han[] = {
+ 21,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x3005, 0x3005,
+ 0x3007, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303b,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0x9fff,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0x16fe2, 0x16fe3,
+ 0x16ff0, 0x16ff6,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Han */
+
+/* 'Yi': Script */
+static const OnigCodePoint CR_Yi[] = {
+ 2,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+}; /* CR_Yi */
+
+/* 'Old_Italic': Script */
+static const OnigCodePoint CR_Old_Italic[] = {
+ 2,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1032f,
+}; /* CR_Old_Italic */
+
+/* 'Gothic': Script */
+static const OnigCodePoint CR_Gothic[] = {
+ 1,
+ 0x10330, 0x1034a,
+}; /* CR_Gothic */
+
+/* 'Deseret': Script */
+static const OnigCodePoint CR_Deseret[] = {
+ 1,
+ 0x10400, 0x1044f,
+}; /* CR_Deseret */
+
+/* 'Inherited': Script */
+static const OnigCodePoint CR_Inherited[] = {
+ 30,
+ 0x0300, 0x036f,
+ 0x0485, 0x0486,
+ 0x064b, 0x0655,
+ 0x0670, 0x0670,
+ 0x0951, 0x0954,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x200c, 0x200d,
+ 0x20d0, 0x20f0,
+ 0x302a, 0x302d,
+ 0x3099, 0x309a,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2d,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x1133b, 0x1133b,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d167, 0x1d169,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0xe0100, 0xe01ef,
+}; /* CR_Inherited */
+
+/* 'Tagalog': Script */
+static const OnigCodePoint CR_Tagalog[] = {
+ 2,
+ 0x1700, 0x1715,
+ 0x171f, 0x171f,
+}; /* CR_Tagalog */
+
+/* 'Hanunoo': Script */
+static const OnigCodePoint CR_Hanunoo[] = {
+ 1,
+ 0x1720, 0x1734,
+}; /* CR_Hanunoo */
+
+/* 'Buhid': Script */
+static const OnigCodePoint CR_Buhid[] = {
+ 1,
+ 0x1740, 0x1753,
+}; /* CR_Buhid */
+
+/* 'Tagbanwa': Script */
+static const OnigCodePoint CR_Tagbanwa[] = {
+ 3,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+}; /* CR_Tagbanwa */
+
+/* 'Limbu': Script */
+static const OnigCodePoint CR_Limbu[] = {
+ 5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x194f,
+}; /* CR_Limbu */
+
+/* 'Tai_Le': Script */
+static const OnigCodePoint CR_Tai_Le[] = {
+ 2,
+ 0x1950, 0x196d,
+ 0x1970, 0x1974,
+}; /* CR_Tai_Le */
+
+/* '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 */
+
+/* 'Ugaritic': Script */
+static const OnigCodePoint CR_Ugaritic[] = {
+ 2,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x1039f,
+}; /* CR_Ugaritic */
+
+/* 'Shavian': Script */
+static const OnigCodePoint CR_Shavian[] = {
+ 1,
+ 0x10450, 0x1047f,
+}; /* CR_Shavian */
+
+/* 'Osmanya': Script */
+static const OnigCodePoint CR_Osmanya[] = {
+ 2,
+ 0x10480, 0x1049d,
+ 0x104a0, 0x104a9,
+}; /* CR_Osmanya */
+
+/* 'Cypriot': Script */
+static const OnigCodePoint CR_Cypriot[] = {
+ 6,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+}; /* CR_Cypriot */
+
+/* '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 */
+
+/* 'Coptic': Script */
+static const OnigCodePoint CR_Coptic[] = {
+ 3,
+ 0x03e2, 0x03ef,
+ 0x2c80, 0x2cf3,
+ 0x2cf9, 0x2cff,
+}; /* CR_Coptic */
+
+/* 'New_Tai_Lue': Script */
+static const OnigCodePoint CR_New_Tai_Lue[] = {
+ 4,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x19df,
+}; /* CR_New_Tai_Lue */
+
+/* 'Glagolitic': Script */
+static const OnigCodePoint CR_Glagolitic[] = {
+ 6,
+ 0x2c00, 0x2c5f,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+}; /* CR_Glagolitic */
+
+/* 'Tifinagh': Script */
+static const OnigCodePoint CR_Tifinagh[] = {
+ 3,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d7f,
+}; /* CR_Tifinagh */
+
+/* 'Syloti_Nagri': Script */
+static const OnigCodePoint CR_Syloti_Nagri[] = {
+ 1,
+ 0xa800, 0xa82c,
+}; /* CR_Syloti_Nagri */
+
+/* 'Old_Persian': Script */
+static const OnigCodePoint CR_Old_Persian[] = {
+ 2,
+ 0x103a0, 0x103c3,
+ 0x103c8, 0x103d5,
+}; /* CR_Old_Persian */
+
+/* 'Kharoshthi': Script */
+static const OnigCodePoint CR_Kharoshthi[] = {
+ 8,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+}; /* CR_Kharoshthi */
+
+/* 'Balinese': Script */
+static const OnigCodePoint CR_Balinese[] = {
+ 2,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1b7f,
+}; /* CR_Balinese */
+
+/* 'Cuneiform': Script */
+static const OnigCodePoint CR_Cuneiform[] = {
+ 4,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+}; /* CR_Cuneiform */
+
+/* 'Phoenician': Script */
+static const OnigCodePoint CR_Phoenician[] = {
+ 2,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x1091f,
+}; /* CR_Phoenician */
+
+/* 'Phags_Pa': Script */
+static const OnigCodePoint CR_Phags_Pa[] = {
+ 1,
+ 0xa840, 0xa877,
+}; /* CR_Phags_Pa */
+
+/* 'Nko': Script */
+static const OnigCodePoint CR_Nko[] = {
+ 2,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x07ff,
+}; /* CR_Nko */
+
+/* 'Sundanese': Script */
+static const OnigCodePoint CR_Sundanese[] = {
+ 2,
+ 0x1b80, 0x1bbf,
+ 0x1cc0, 0x1cc7,
+}; /* CR_Sundanese */
+
+/* 'Lepcha': Script */
+static const OnigCodePoint CR_Lepcha[] = {
+ 3,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c4f,
+}; /* CR_Lepcha */
+
+/* 'Ol_Chiki': Script */
+static const OnigCodePoint CR_Ol_Chiki[] = {
+ 1,
+ 0x1c50, 0x1c7f,
+}; /* CR_Ol_Chiki */
+
+/* 'Vai': Script */
+static const OnigCodePoint CR_Vai[] = {
+ 1,
+ 0xa500, 0xa62b,
+}; /* CR_Vai */
+
+/* 'Saurashtra': Script */
+static const OnigCodePoint CR_Saurashtra[] = {
+ 2,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+}; /* CR_Saurashtra */
+
+/* 'Kayah_Li': Script */
+static const OnigCodePoint CR_Kayah_Li[] = {
+ 2,
+ 0xa900, 0xa92d,
+ 0xa92f, 0xa92f,
+}; /* CR_Kayah_Li */
+
+/* 'Rejang': Script */
+static const OnigCodePoint CR_Rejang[] = {
+ 2,
+ 0xa930, 0xa953,
+ 0xa95f, 0xa95f,
+}; /* CR_Rejang */
+
+/* 'Lycian': Script */
+static const OnigCodePoint CR_Lycian[] = {
+ 1,
+ 0x10280, 0x1029c,
+}; /* CR_Lycian */
+
+/* 'Carian': Script */
+static const OnigCodePoint CR_Carian[] = {
+ 1,
+ 0x102a0, 0x102d0,
+}; /* CR_Carian */
+
+/* 'Lydian': Script */
+static const OnigCodePoint CR_Lydian[] = {
+ 2,
+ 0x10920, 0x10939,
+ 0x1093f, 0x1093f,
+}; /* CR_Lydian */
+
+/* 'Cham': Script */
+static const OnigCodePoint CR_Cham[] = {
+ 4,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa5f,
+}; /* CR_Cham */
+
+/* 'Tai_Tham': Script */
+static const OnigCodePoint CR_Tai_Tham[] = {
+ 5,
+ 0x1a20, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+}; /* CR_Tai_Tham */
+
+/* 'Tai_Viet': Script */
+static const OnigCodePoint CR_Tai_Viet[] = {
+ 2,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+}; /* CR_Tai_Viet */
+
+/* 'Avestan': Script */
+static const OnigCodePoint CR_Avestan[] = {
+ 2,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b3f,
+}; /* CR_Avestan */
+
+/* 'Egyptian_Hieroglyphs': Script */
+static const OnigCodePoint CR_Egyptian_Hieroglyphs[] = {
+ 2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+}; /* CR_Egyptian_Hieroglyphs */
+
+/* 'Samaritan': Script */
+static const OnigCodePoint CR_Samaritan[] = {
+ 2,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+}; /* CR_Samaritan */
+
+/* 'Lisu': Script */
+static const OnigCodePoint CR_Lisu[] = {
+ 2,
+ 0xa4d0, 0xa4ff,
+ 0x11fb0, 0x11fb0,
+}; /* CR_Lisu */
+
+/* 'Bamum': Script */
+static const OnigCodePoint CR_Bamum[] = {
+ 2,
+ 0xa6a0, 0xa6f7,
+ 0x16800, 0x16a38,
+}; /* CR_Bamum */
+
+/* 'Javanese': Script */
+static const OnigCodePoint CR_Javanese[] = {
+ 3,
+ 0xa980, 0xa9cd,
+ 0xa9d0, 0xa9d9,
+ 0xa9de, 0xa9df,
+}; /* CR_Javanese */
+
+/* 'Meetei_Mayek': Script */
+static const OnigCodePoint CR_Meetei_Mayek[] = {
+ 3,
+ 0xaae0, 0xaaf6,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+}; /* CR_Meetei_Mayek */
+
+/* 'Imperial_Aramaic': Script */
+static const OnigCodePoint CR_Imperial_Aramaic[] = {
+ 2,
+ 0x10840, 0x10855,
+ 0x10857, 0x1085f,
+}; /* CR_Imperial_Aramaic */
+
+/* 'Old_South_Arabian': Script */
+static const OnigCodePoint CR_Old_South_Arabian[] = {
+ 1,
+ 0x10a60, 0x10a7f,
+}; /* CR_Old_South_Arabian */
+
+/* 'Inscriptional_Parthian': Script */
+static const OnigCodePoint CR_Inscriptional_Parthian[] = {
+ 2,
+ 0x10b40, 0x10b55,
+ 0x10b58, 0x10b5f,
+}; /* CR_Inscriptional_Parthian */
+
+/* 'Inscriptional_Pahlavi': Script */
+static const OnigCodePoint CR_Inscriptional_Pahlavi[] = {
+ 2,
+ 0x10b60, 0x10b72,
+ 0x10b78, 0x10b7f,
+}; /* CR_Inscriptional_Pahlavi */
+
+/* 'Old_Turkic': Script */
+static const OnigCodePoint CR_Old_Turkic[] = {
+ 1,
+ 0x10c00, 0x10c48,
+}; /* CR_Old_Turkic */
+
+/* 'Kaithi': Script */
+static const OnigCodePoint CR_Kaithi[] = {
+ 2,
+ 0x11080, 0x110c2,
+ 0x110cd, 0x110cd,
+}; /* CR_Kaithi */
+
+/* 'Batak': Script */
+static const OnigCodePoint CR_Batak[] = {
+ 2,
+ 0x1bc0, 0x1bf3,
+ 0x1bfc, 0x1bff,
+}; /* CR_Batak */
+
+/* 'Brahmi': Script */
+static const OnigCodePoint CR_Brahmi[] = {
+ 3,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x1107f,
+}; /* CR_Brahmi */
+
+/* 'Mandaic': Script */
+static const OnigCodePoint CR_Mandaic[] = {
+ 2,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+}; /* CR_Mandaic */
+
+/* 'Chakma': Script */
+static const OnigCodePoint CR_Chakma[] = {
+ 2,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+}; /* CR_Chakma */
+
+/* 'Meroitic_Cursive': Script */
+static const OnigCodePoint CR_Meroitic_Cursive[] = {
+ 3,
+ 0x109a0, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x109ff,
+}; /* CR_Meroitic_Cursive */
+
+/* 'Meroitic_Hieroglyphs': Script */
+static const OnigCodePoint CR_Meroitic_Hieroglyphs[] = {
+ 1,
+ 0x10980, 0x1099f,
+}; /* CR_Meroitic_Hieroglyphs */
+
+/* 'Miao': Script */
+static const OnigCodePoint CR_Miao[] = {
+ 3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+}; /* CR_Miao */
+
+/* 'Sharada': Script */
+static const OnigCodePoint CR_Sharada[] = {
+ 2,
+ 0x11180, 0x111df,
+ 0x11b60, 0x11b67,
+}; /* CR_Sharada */
+
+/* 'Sora_Sompeng': Script */
+static const OnigCodePoint CR_Sora_Sompeng[] = {
+ 2,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+}; /* CR_Sora_Sompeng */
+
+/* 'Takri': Script */
+static const OnigCodePoint CR_Takri[] = {
+ 2,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+}; /* CR_Takri */
+
+/* 'Caucasian_Albanian': Script */
+static const OnigCodePoint CR_Caucasian_Albanian[] = {
+ 2,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+}; /* CR_Caucasian_Albanian */
+
+/* 'Bassa_Vah': Script */
+static const OnigCodePoint CR_Bassa_Vah[] = {
+ 2,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+}; /* CR_Bassa_Vah */
+
+/* 'Duployan': Script */
+static const OnigCodePoint CR_Duployan[] = {
+ 5,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bc9f,
+}; /* CR_Duployan */
+
+/* 'Elbasan': Script */
+static const OnigCodePoint CR_Elbasan[] = {
+ 1,
+ 0x10500, 0x10527,
+}; /* CR_Elbasan */
+
+/* 'Grantha': Script */
+static const OnigCodePoint CR_Grantha[] = {
+ 15,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+}; /* CR_Grantha */
+
+/* 'Pahawh_Hmong': Script */
+static const OnigCodePoint CR_Pahawh_Hmong[] = {
+ 5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+}; /* CR_Pahawh_Hmong */
+
+/* 'Khojki': Script */
+static const OnigCodePoint CR_Khojki[] = {
+ 2,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+}; /* CR_Khojki */
+
+/* 'Linear_A': Script */
+static const OnigCodePoint CR_Linear_A[] = {
+ 3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+}; /* CR_Linear_A */
+
+/* 'Mahajani': Script */
+static const OnigCodePoint CR_Mahajani[] = {
+ 1,
+ 0x11150, 0x11176,
+}; /* CR_Mahajani */
+
+/* 'Manichaean': Script */
+static const OnigCodePoint CR_Manichaean[] = {
+ 2,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+}; /* CR_Manichaean */
+
+/* 'Mende_Kikakui': Script */
+static const OnigCodePoint CR_Mende_Kikakui[] = {
+ 2,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+}; /* CR_Mende_Kikakui */
+
+/* 'Modi': Script */
+static const OnigCodePoint CR_Modi[] = {
+ 2,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+}; /* CR_Modi */
+
+/* 'Mro': Script */
+static const OnigCodePoint CR_Mro[] = {
+ 3,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+}; /* CR_Mro */
+
+/* 'Old_North_Arabian': Script */
+static const OnigCodePoint CR_Old_North_Arabian[] = {
+ 1,
+ 0x10a80, 0x10a9f,
+}; /* CR_Old_North_Arabian */
+
+/* 'Nabataean': Script */
+static const OnigCodePoint CR_Nabataean[] = {
+ 2,
+ 0x10880, 0x1089e,
+ 0x108a7, 0x108af,
+}; /* CR_Nabataean */
+
+/* 'Palmyrene': Script */
+static const OnigCodePoint CR_Palmyrene[] = {
+ 1,
+ 0x10860, 0x1087f,
+}; /* CR_Palmyrene */
+
+/* 'Pau_Cin_Hau': Script */
+static const OnigCodePoint CR_Pau_Cin_Hau[] = {
+ 1,
+ 0x11ac0, 0x11af8,
+}; /* CR_Pau_Cin_Hau */
+
+/* 'Old_Permic': Script */
+static const OnigCodePoint CR_Old_Permic[] = {
+ 1,
+ 0x10350, 0x1037a,
+}; /* CR_Old_Permic */
+
+/* 'Psalter_Pahlavi': Script */
+static const OnigCodePoint CR_Psalter_Pahlavi[] = {
+ 3,
+ 0x10b80, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+}; /* CR_Psalter_Pahlavi */
+
+/* 'Siddham': Script */
+static const OnigCodePoint CR_Siddham[] = {
+ 2,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+}; /* CR_Siddham */
+
+/* 'Khudawadi': Script */
+static const OnigCodePoint CR_Khudawadi[] = {
+ 2,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+}; /* CR_Khudawadi */
+
+/* 'Tirhuta': Script */
+static const OnigCodePoint CR_Tirhuta[] = {
+ 2,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+}; /* CR_Tirhuta */
+
+/* 'Warang_Citi': Script */
+static const OnigCodePoint CR_Warang_Citi[] = {
+ 2,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+}; /* CR_Warang_Citi */
+
+/* 'Ahom': Script */
+static const OnigCodePoint CR_Ahom[] = {
+ 3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+}; /* CR_Ahom */
+
+/* 'Anatolian_Hieroglyphs': Script */
+static const OnigCodePoint CR_Anatolian_Hieroglyphs[] = {
+ 1,
+ 0x14400, 0x14646,
+}; /* CR_Anatolian_Hieroglyphs */
+
+/* 'Hatran': Script */
+static const OnigCodePoint CR_Hatran[] = {
+ 3,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x108ff,
+}; /* CR_Hatran */
+
+/* 'Multani': Script */
+static const OnigCodePoint CR_Multani[] = {
+ 5,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+}; /* CR_Multani */
+
+/* 'Old_Hungarian': Script */
+static const OnigCodePoint CR_Old_Hungarian[] = {
+ 3,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+}; /* CR_Old_Hungarian */
+
+/* 'SignWriting': Script */
+static const OnigCodePoint CR_SignWriting[] = {
+ 3,
+ 0x1d800, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+}; /* CR_SignWriting */
+
+/* 'Adlam': Script */
+static const OnigCodePoint CR_Adlam[] = {
+ 3,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+}; /* CR_Adlam */
+
+/* 'Bhaiksuki': Script */
+static const OnigCodePoint CR_Bhaiksuki[] = {
+ 4,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+}; /* CR_Bhaiksuki */
+
+/* 'Marchen': Script */
+static const OnigCodePoint CR_Marchen[] = {
+ 3,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+}; /* CR_Marchen */
+
+/* 'Newa': Script */
+static const OnigCodePoint CR_Newa[] = {
+ 2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+}; /* CR_Newa */
+
+/* 'Osage': Script */
+static const OnigCodePoint CR_Osage[] = {
+ 2,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+}; /* CR_Osage */
+
+/* 'Tangut': Script */
+static const OnigCodePoint CR_Tangut[] = {
+ 4,
+ 0x16fe0, 0x16fe0,
+ 0x17000, 0x18aff,
+ 0x18d00, 0x18d1e,
+ 0x18d80, 0x18df2,
+}; /* CR_Tangut */
+
+/* 'Masaram_Gondi': Script */
+static const OnigCodePoint CR_Masaram_Gondi[] = {
+ 7,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+}; /* CR_Masaram_Gondi */
+
+/* 'Nushu': Script */
+static const OnigCodePoint CR_Nushu[] = {
+ 2,
+ 0x16fe1, 0x16fe1,
+ 0x1b170, 0x1b2fb,
+}; /* CR_Nushu */
+
+/* 'Soyombo': Script */
+static const OnigCodePoint CR_Soyombo[] = {
+ 1,
+ 0x11a50, 0x11aa2,
+}; /* CR_Soyombo */
+
+/* 'Zanabazar_Square': Script */
+static const OnigCodePoint CR_Zanabazar_Square[] = {
+ 1,
+ 0x11a00, 0x11a47,
+}; /* CR_Zanabazar_Square */
+
+/* 'Dogra': Script */
+static const OnigCodePoint CR_Dogra[] = {
+ 1,
+ 0x11800, 0x1183b,
+}; /* CR_Dogra */
+
+/* 'Gunjala_Gondi': Script */
+static const OnigCodePoint CR_Gunjala_Gondi[] = {
+ 6,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+}; /* CR_Gunjala_Gondi */
+
+/* 'Makasar': Script */
+static const OnigCodePoint CR_Makasar[] = {
+ 1,
+ 0x11ee0, 0x11ef8,
+}; /* CR_Makasar */
+
+/* 'Medefaidrin': Script */
+static const OnigCodePoint CR_Medefaidrin[] = {
+ 1,
+ 0x16e40, 0x16e9a,
+}; /* CR_Medefaidrin */
+
+/* 'Hanifi_Rohingya': Script */
+static const OnigCodePoint CR_Hanifi_Rohingya[] = {
+ 2,
+ 0x10d00, 0x10d27,
+ 0x10d30, 0x10d39,
+}; /* CR_Hanifi_Rohingya */
+
+/* 'Sogdian': Script */
+static const OnigCodePoint CR_Sogdian[] = {
+ 1,
+ 0x10f30, 0x10f59,
+}; /* CR_Sogdian */
+
+/* 'Old_Sogdian': Script */
+static const OnigCodePoint CR_Old_Sogdian[] = {
+ 1,
+ 0x10f00, 0x10f27,
+}; /* CR_Old_Sogdian */
+
+/* 'Elymaic': Script */
+static const OnigCodePoint CR_Elymaic[] = {
+ 1,
+ 0x10fe0, 0x10ff6,
+}; /* CR_Elymaic */
+
+/* 'Nandinagari': Script */
+static const OnigCodePoint CR_Nandinagari[] = {
+ 3,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+}; /* CR_Nandinagari */
+
+/* 'Nyiakeng_Puachue_Hmong': Script */
+static const OnigCodePoint CR_Nyiakeng_Puachue_Hmong[] = {
+ 4,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+}; /* CR_Nyiakeng_Puachue_Hmong */
+
+/* 'Wancho': Script */
+static const OnigCodePoint CR_Wancho[] = {
+ 2,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+}; /* CR_Wancho */
+
+/* 'Chorasmian': Script */
+static const OnigCodePoint CR_Chorasmian[] = {
+ 1,
+ 0x10fb0, 0x10fcb,
+}; /* CR_Chorasmian */
+
+/* 'Dives_Akuru': Script */
+static const OnigCodePoint CR_Dives_Akuru[] = {
+ 8,
+ 0x11900, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+}; /* CR_Dives_Akuru */
+
+/* 'Khitan_Small_Script': Script */
+static const OnigCodePoint CR_Khitan_Small_Script[] = {
+ 3,
+ 0x16fe4, 0x16fe4,
+ 0x18b00, 0x18cd5,
+ 0x18cff, 0x18cff,
+}; /* CR_Khitan_Small_Script */
+
+/* 'Yezidi': Script */
+static const OnigCodePoint CR_Yezidi[] = {
+ 3,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+}; /* CR_Yezidi */
+
+/* 'Cypro_Minoan': Script */
+static const OnigCodePoint CR_Cypro_Minoan[] = {
+ 1,
+ 0x12f90, 0x12ff2,
+}; /* CR_Cypro_Minoan */
+
+/* 'Old_Uyghur': Script */
+static const OnigCodePoint CR_Old_Uyghur[] = {
+ 1,
+ 0x10f70, 0x10f89,
+}; /* CR_Old_Uyghur */
+
+/* 'Tangsa': Script */
+static const OnigCodePoint CR_Tangsa[] = {
+ 2,
+ 0x16a70, 0x16abe,
+ 0x16ac0, 0x16ac9,
+}; /* CR_Tangsa */
+
+/* 'Toto': Script */
+static const OnigCodePoint CR_Toto[] = {
+ 1,
+ 0x1e290, 0x1e2ae,
+}; /* CR_Toto */
+
+/* 'Vithkuqi': Script */
+static const OnigCodePoint CR_Vithkuqi[] = {
+ 8,
+ 0x10570, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+}; /* CR_Vithkuqi */
+
+/* 'Kawi': Script */
+static const OnigCodePoint CR_Kawi[] = {
+ 3,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+}; /* CR_Kawi */
+
+/* 'Nag_Mundari': Script */
+static const OnigCodePoint CR_Nag_Mundari[] = {
+ 1,
+ 0x1e4d0, 0x1e4f9,
+}; /* CR_Nag_Mundari */
+
+/* 'Garay': Script */
+static const OnigCodePoint CR_Garay[] = {
+ 3,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+}; /* CR_Garay */
+
+/* 'Gurung_Khema': Script */
+static const OnigCodePoint CR_Gurung_Khema[] = {
+ 1,
+ 0x16100, 0x16139,
+}; /* CR_Gurung_Khema */
+
+/* 'Kirat_Rai': Script */
+static const OnigCodePoint CR_Kirat_Rai[] = {
+ 1,
+ 0x16d40, 0x16d79,
+}; /* CR_Kirat_Rai */
+
+/* 'Ol_Onal': Script */
+static const OnigCodePoint CR_Ol_Onal[] = {
+ 2,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+}; /* CR_Ol_Onal */
+
+/* 'Sunuwar': Script */
+static const OnigCodePoint CR_Sunuwar[] = {
+ 2,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+}; /* CR_Sunuwar */
+
+/* 'Todhri': Script */
+static const OnigCodePoint CR_Todhri[] = {
+ 1,
+ 0x105c0, 0x105f3,
+}; /* CR_Todhri */
+
+/* 'Tulu_Tigalari': Script */
+static const OnigCodePoint CR_Tulu_Tigalari[] = {
+ 11,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+}; /* CR_Tulu_Tigalari */
+
+/* 'Sidetic': Script */
+static const OnigCodePoint CR_Sidetic[] = {
+ 1,
+ 0x10940, 0x10959,
+}; /* CR_Sidetic */
+
+/* 'Tai_Yo': Script */
+static const OnigCodePoint CR_Tai_Yo[] = {
+ 3,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+}; /* CR_Tai_Yo */
+
+/* 'Tolong_Siki': Script */
+static const OnigCodePoint CR_Tolong_Siki[] = {
+ 2,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+}; /* CR_Tolong_Siki */
+
+/* 'Beria_Erfe': Script */
+static const OnigCodePoint CR_Beria_Erfe[] = {
+ 2,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+}; /* CR_Beria_Erfe */
+
+/* 'White_Space': Binary Property */
+#define CR_White_Space CR_Space
+
+/* 'Bidi_Control': Binary Property */
+static const OnigCodePoint CR_Bidi_Control[] = {
+ 4,
+ 0x061c, 0x061c,
+ 0x200e, 0x200f,
+ 0x202a, 0x202e,
+ 0x2066, 0x2069,
+}; /* CR_Bidi_Control */
+
+/* 'Join_Control': Binary Property */
+static const OnigCodePoint CR_Join_Control[] = {
+ 1,
+ 0x200c, 0x200d,
+}; /* CR_Join_Control */
+
+/* 'Dash': Binary Property */
+static const OnigCodePoint CR_Dash[] = {
+ 24,
+ 0x002d, 0x002d,
+ 0x058a, 0x058a,
+ 0x05be, 0x05be,
+ 0x1400, 0x1400,
+ 0x1806, 0x1806,
+ 0x2010, 0x2015,
+ 0x2053, 0x2053,
+ 0x207b, 0x207b,
+ 0x208b, 0x208b,
+ 0x2212, 0x2212,
+ 0x2e17, 0x2e17,
+ 0x2e1a, 0x2e1a,
+ 0x2e3a, 0x2e3b,
+ 0x2e40, 0x2e40,
+ 0x2e5d, 0x2e5d,
+ 0x301c, 0x301c,
+ 0x3030, 0x3030,
+ 0x30a0, 0x30a0,
+ 0xfe31, 0xfe32,
+ 0xfe58, 0xfe58,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+ 0x10d6e, 0x10d6e,
+ 0x10ead, 0x10ead,
+}; /* CR_Dash */
+
+/* 'Hyphen': Binary Property */
+static const OnigCodePoint CR_Hyphen[] = {
+ 10,
+ 0x002d, 0x002d,
+ 0x00ad, 0x00ad,
+ 0x058a, 0x058a,
+ 0x1806, 0x1806,
+ 0x2010, 0x2011,
+ 0x2e17, 0x2e17,
+ 0x30fb, 0x30fb,
+ 0xfe63, 0xfe63,
+ 0xff0d, 0xff0d,
+ 0xff65, 0xff65,
+}; /* CR_Hyphen */
+
+/* 'Quotation_Mark': Binary Property */
+static const OnigCodePoint CR_Quotation_Mark[] = {
+ 13,
+ 0x0022, 0x0022,
+ 0x0027, 0x0027,
+ 0x00ab, 0x00ab,
+ 0x00bb, 0x00bb,
+ 0x2018, 0x201f,
+ 0x2039, 0x203a,
+ 0x2e42, 0x2e42,
+ 0x300c, 0x300f,
+ 0x301d, 0x301f,
+ 0xfe41, 0xfe44,
+ 0xff02, 0xff02,
+ 0xff07, 0xff07,
+ 0xff62, 0xff63,
+}; /* CR_Quotation_Mark */
+
+/* 'Terminal_Punctuation': Binary Property */
+static const OnigCodePoint CR_Terminal_Punctuation[] = {
+ 116,
+ 0x0021, 0x0021,
+ 0x002c, 0x002c,
+ 0x002e, 0x002e,
+ 0x003a, 0x003b,
+ 0x003f, 0x003f,
+ 0x037e, 0x037e,
+ 0x0387, 0x0387,
+ 0x0589, 0x0589,
+ 0x05c3, 0x05c3,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061d, 0x061f,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x070a,
+ 0x070c, 0x070c,
+ 0x07f8, 0x07f9,
+ 0x0830, 0x0835,
+ 0x0837, 0x083e,
+ 0x085e, 0x085e,
+ 0x0964, 0x0965,
+ 0x0e5a, 0x0e5b,
+ 0x0f08, 0x0f08,
+ 0x0f0d, 0x0f12,
+ 0x104a, 0x104b,
+ 0x1361, 0x1368,
+ 0x166e, 0x166e,
+ 0x16eb, 0x16ed,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d6,
+ 0x17da, 0x17da,
+ 0x1802, 0x1805,
+ 0x1808, 0x1809,
+ 0x1944, 0x1945,
+ 0x1aa8, 0x1aab,
+ 0x1b4e, 0x1b4f,
+ 0x1b5a, 0x1b5b,
+ 0x1b5d, 0x1b5f,
+ 0x1b7d, 0x1b7f,
+ 0x1c3b, 0x1c3f,
+ 0x1c7e, 0x1c7f,
+ 0x2024, 0x2024,
+ 0x203c, 0x203d,
+ 0x2047, 0x2049,
+ 0x2cf9, 0x2cfb,
+ 0x2e2e, 0x2e2e,
+ 0x2e3c, 0x2e3c,
+ 0x2e41, 0x2e41,
+ 0x2e4c, 0x2e4c,
+ 0x2e4e, 0x2e4f,
+ 0x2e53, 0x2e54,
+ 0x3001, 0x3002,
+ 0xa4fe, 0xa4ff,
+ 0xa60d, 0xa60f,
+ 0xa6f3, 0xa6f7,
+ 0xa876, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa92f, 0xa92f,
+ 0xa9c7, 0xa9c9,
+ 0xaa5d, 0xaa5f,
+ 0xaadf, 0xaadf,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfe12, 0xfe12,
+ 0xfe15, 0xfe16,
+ 0xfe50, 0xfe52,
+ 0xfe54, 0xfe57,
+ 0xff01, 0xff01,
+ 0xff0c, 0xff0c,
+ 0xff0e, 0xff0e,
+ 0xff1a, 0xff1b,
+ 0xff1f, 0xff1f,
+ 0xff61, 0xff61,
+ 0xff64, 0xff64,
+ 0x1039f, 0x1039f,
+ 0x103d0, 0x103d0,
+ 0x10857, 0x10857,
+ 0x1091f, 0x1091f,
+ 0x10a56, 0x10a57,
+ 0x10af0, 0x10af5,
+ 0x10b3a, 0x10b3f,
+ 0x10b99, 0x10b9c,
+ 0x10f55, 0x10f59,
+ 0x10f86, 0x10f89,
+ 0x11047, 0x1104d,
+ 0x110be, 0x110c1,
+ 0x11141, 0x11143,
+ 0x111c5, 0x111c6,
+ 0x111cd, 0x111cd,
+ 0x111de, 0x111df,
+ 0x11238, 0x1123c,
+ 0x112a9, 0x112a9,
+ 0x113d4, 0x113d5,
+ 0x1144b, 0x1144d,
+ 0x1145a, 0x1145b,
+ 0x115c2, 0x115c5,
+ 0x115c9, 0x115d7,
+ 0x11641, 0x11642,
+ 0x1173c, 0x1173e,
+ 0x11944, 0x11944,
+ 0x11946, 0x11946,
+ 0x11a42, 0x11a43,
+ 0x11a9b, 0x11a9c,
+ 0x11aa1, 0x11aa2,
+ 0x11c41, 0x11c43,
+ 0x11c71, 0x11c71,
+ 0x11ef7, 0x11ef8,
+ 0x11f43, 0x11f44,
+ 0x12470, 0x12474,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b39,
+ 0x16b44, 0x16b44,
+ 0x16d6e, 0x16d6f,
+ 0x16e97, 0x16e98,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da87, 0x1da8a,
+}; /* CR_Terminal_Punctuation */
+
+/* 'Other_Math': Binary Property */
+static const OnigCodePoint CR_Other_Math[] = {
+ 134,
+ 0x005e, 0x005e,
+ 0x03d0, 0x03d2,
+ 0x03d5, 0x03d5,
+ 0x03f0, 0x03f1,
+ 0x03f4, 0x03f5,
+ 0x2016, 0x2016,
+ 0x2032, 0x2034,
+ 0x2040, 0x2040,
+ 0x2061, 0x2064,
+ 0x207d, 0x207e,
+ 0x208d, 0x208e,
+ 0x20d0, 0x20dc,
+ 0x20e1, 0x20e1,
+ 0x20e5, 0x20e6,
+ 0x20eb, 0x20ef,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210a, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211d,
+ 0x2124, 0x2124,
+ 0x2128, 0x2129,
+ 0x212c, 0x212d,
+ 0x212f, 0x2131,
+ 0x2133, 0x2138,
+ 0x213c, 0x213f,
+ 0x2145, 0x2149,
+ 0x2195, 0x2199,
+ 0x219c, 0x219f,
+ 0x21a1, 0x21a2,
+ 0x21a4, 0x21a5,
+ 0x21a7, 0x21a7,
+ 0x21a9, 0x21ad,
+ 0x21b0, 0x21b1,
+ 0x21b6, 0x21b7,
+ 0x21bc, 0x21cd,
+ 0x21d0, 0x21d1,
+ 0x21d3, 0x21d3,
+ 0x21d5, 0x21db,
+ 0x21dd, 0x21dd,
+ 0x21e4, 0x21e5,
+ 0x2308, 0x230b,
+ 0x23b4, 0x23b5,
+ 0x23b7, 0x23b7,
+ 0x23d0, 0x23d0,
+ 0x23e2, 0x23e2,
+ 0x25a0, 0x25a1,
+ 0x25ae, 0x25b6,
+ 0x25bc, 0x25c0,
+ 0x25c6, 0x25c7,
+ 0x25ca, 0x25cb,
+ 0x25cf, 0x25d3,
+ 0x25e2, 0x25e2,
+ 0x25e4, 0x25e4,
+ 0x25e7, 0x25ec,
+ 0x2605, 0x2606,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2660, 0x2663,
+ 0x266d, 0x266e,
+ 0x27c5, 0x27c6,
+ 0x27e6, 0x27ef,
+ 0x2983, 0x2998,
+ 0x29d8, 0x29db,
+ 0x29fc, 0x29fd,
+ 0xfe61, 0xfe61,
+ 0xfe63, 0xfe63,
+ 0xfe68, 0xfe68,
+ 0xff3c, 0xff3c,
+ 0xff3e, 0xff3e,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+}; /* CR_Other_Math */
+
+/* 'Hex_Digit': Binary Property */
+static const OnigCodePoint CR_Hex_Digit[] = {
+ 6,
+ 0x0030, 0x0039,
+ 0x0041, 0x0046,
+ 0x0061, 0x0066,
+ 0xff10, 0xff19,
+ 0xff21, 0xff26,
+ 0xff41, 0xff46,
+}; /* CR_Hex_Digit */
+
+/* 'ASCII_Hex_Digit': Binary Property */
+#define CR_ASCII_Hex_Digit CR_XDigit
+
+/* 'Other_Alphabetic': Binary Property */
+static const OnigCodePoint CR_Other_Alphabetic[] = {
+ 255,
+ 0x0345, 0x0345,
+ 0x0363, 0x036f,
+ 0x05b0, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x0657,
+ 0x0659, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06e1, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ed, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x073f,
+ 0x07a6, 0x07b0,
+ 0x0816, 0x0817,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082c,
+ 0x0897, 0x0897,
+ 0x08d4, 0x08df,
+ 0x08e3, 0x08e9,
+ 0x08f0, 0x0903,
+ 0x093a, 0x093b,
+ 0x093e, 0x094c,
+ 0x094e, 0x094f,
+ 0x0955, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0983,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x0a01, 0x0a03,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4c,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a83,
+ 0x0abe, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0afc,
+ 0x0b01, 0x0b03,
+ 0x0b3e, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0b56, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c04,
+ 0x0c3e, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4c,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c83,
+ 0x0cbe, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccc,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0cf3, 0x0cf3,
+ 0x0d00, 0x0d03,
+ 0x0d3e, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d83,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0df2, 0x0df3,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e4d, 0x0e4d,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0eb9,
+ 0x0ebb, 0x0ebc,
+ 0x0ecd, 0x0ecd,
+ 0x0f71, 0x0f83,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x102b, 0x1036,
+ 0x1038, 0x1038,
+ 0x103b, 0x103e,
+ 0x1056, 0x1059,
+ 0x105e, 0x1060,
+ 0x1062, 0x1064,
+ 0x1067, 0x106d,
+ 0x1071, 0x1074,
+ 0x1082, 0x108d,
+ 0x108f, 0x108f,
+ 0x109a, 0x109d,
+ 0x1712, 0x1713,
+ 0x1732, 0x1733,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b6, 0x17c8,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x192b,
+ 0x1930, 0x1938,
+ 0x1a17, 0x1a1b,
+ 0x1a55, 0x1a5e,
+ 0x1a61, 0x1a74,
+ 0x1abf, 0x1ac0,
+ 0x1acc, 0x1ace,
+ 0x1b00, 0x1b04,
+ 0x1b35, 0x1b43,
+ 0x1b80, 0x1b82,
+ 0x1ba1, 0x1ba9,
+ 0x1bac, 0x1bad,
+ 0x1be7, 0x1bf1,
+ 0x1c24, 0x1c36,
+ 0x1dd3, 0x1df4,
+ 0x24b6, 0x24e9,
+ 0x2de0, 0x2dff,
+ 0xa674, 0xa67b,
+ 0xa69e, 0xa69f,
+ 0xa802, 0xa802,
+ 0xa80b, 0xa80b,
+ 0xa823, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa8c5, 0xa8c5,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92a,
+ 0xa947, 0xa952,
+ 0xa980, 0xa983,
+ 0xa9b4, 0xa9bf,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4d,
+ 0xaa7b, 0xaa7d,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabe,
+ 0xaaeb, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabea,
+ 0xfb1e, 0xfb1e,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d69,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10efc,
+ 0x11000, 0x11002,
+ 0x11038, 0x11045,
+ 0x11073, 0x11074,
+ 0x11080, 0x11082,
+ 0x110b0, 0x110b8,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x11132,
+ 0x11145, 0x11146,
+ 0x11180, 0x11182,
+ 0x111b3, 0x111bf,
+ 0x111ce, 0x111cf,
+ 0x1122c, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112e8,
+ 0x11300, 0x11303,
+ 0x1133e, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11357, 0x11357,
+ 0x11362, 0x11363,
+ 0x113b8, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x11435, 0x11441,
+ 0x11443, 0x11445,
+ 0x114b0, 0x114c1,
+ 0x115af, 0x115b5,
+ 0x115b8, 0x115be,
+ 0x115dc, 0x115dd,
+ 0x11630, 0x1163e,
+ 0x11640, 0x11640,
+ 0x116ab, 0x116b5,
+ 0x1171d, 0x1172a,
+ 0x1182c, 0x11838,
+ 0x11930, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x1193c,
+ 0x11940, 0x11940,
+ 0x11942, 0x11942,
+ 0x119d1, 0x119d7,
+ 0x119da, 0x119df,
+ 0x119e4, 0x119e4,
+ 0x11a01, 0x11a0a,
+ 0x11a35, 0x11a39,
+ 0x11a3b, 0x11a3e,
+ 0x11a51, 0x11a5b,
+ 0x11a8a, 0x11a97,
+ 0x11b60, 0x11b67,
+ 0x11c2f, 0x11c36,
+ 0x11c38, 0x11c3e,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d41,
+ 0x11d43, 0x11d43,
+ 0x11d47, 0x11d47,
+ 0x11d8a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d96,
+ 0x11ef3, 0x11ef6,
+ 0x11f00, 0x11f01,
+ 0x11f03, 0x11f03,
+ 0x11f34, 0x11f3a,
+ 0x11f3e, 0x11f40,
+ 0x1611e, 0x1612e,
+ 0x16f4f, 0x16f4f,
+ 0x16f51, 0x16f87,
+ 0x16f8f, 0x16f92,
+ 0x16ff0, 0x16ff1,
+ 0x1bc9e, 0x1bc9e,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e947, 0x1e947,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Other_Alphabetic */
+
+/* 'Ideographic': Binary Property */
+static const OnigCodePoint CR_Ideographic[] = {
+ 21,
+ 0x3006, 0x3007,
+ 0x3021, 0x3029,
+ 0x3038, 0x303a,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0x9fff,
+ 0xf900, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0x16fe4, 0x16fe4,
+ 0x16ff2, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1b170, 0x1b2fb,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Ideographic */
+
+/* 'Diacritic': Binary Property */
+static const OnigCodePoint CR_Diacritic[] = {
+ 220,
+ 0x005e, 0x005e,
+ 0x0060, 0x0060,
+ 0x00a8, 0x00a8,
+ 0x00af, 0x00af,
+ 0x00b4, 0x00b4,
+ 0x00b7, 0x00b8,
+ 0x02b0, 0x034e,
+ 0x0350, 0x0357,
+ 0x035d, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x0384, 0x0385,
+ 0x0483, 0x0487,
+ 0x0559, 0x0559,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x064b, 0x0652,
+ 0x0657, 0x0658,
+ 0x06df, 0x06e0,
+ 0x06e5, 0x06e6,
+ 0x06ea, 0x06ec,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f5,
+ 0x0818, 0x0819,
+ 0x0898, 0x089f,
+ 0x08c9, 0x08d2,
+ 0x08e3, 0x08fe,
+ 0x093c, 0x093c,
+ 0x094d, 0x094d,
+ 0x0951, 0x0954,
+ 0x0971, 0x0971,
+ 0x09bc, 0x09bc,
+ 0x09cd, 0x09cd,
+ 0x0a3c, 0x0a3c,
+ 0x0a4d, 0x0a4d,
+ 0x0abc, 0x0abc,
+ 0x0acd, 0x0acd,
+ 0x0afd, 0x0aff,
+ 0x0b3c, 0x0b3c,
+ 0x0b4d, 0x0b4d,
+ 0x0b55, 0x0b55,
+ 0x0bcd, 0x0bcd,
+ 0x0c3c, 0x0c3c,
+ 0x0c4d, 0x0c4d,
+ 0x0cbc, 0x0cbc,
+ 0x0ccd, 0x0ccd,
+ 0x0d3b, 0x0d3c,
+ 0x0d4d, 0x0d4d,
+ 0x0dca, 0x0dca,
+ 0x0e3a, 0x0e3a,
+ 0x0e47, 0x0e4c,
+ 0x0e4e, 0x0e4e,
+ 0x0eba, 0x0eba,
+ 0x0ec8, 0x0ecc,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f3e, 0x0f3f,
+ 0x0f82, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0fc6, 0x0fc6,
+ 0x1037, 0x1037,
+ 0x1039, 0x103a,
+ 0x1063, 0x1064,
+ 0x1069, 0x106d,
+ 0x1087, 0x108d,
+ 0x108f, 0x108f,
+ 0x109a, 0x109b,
+ 0x135d, 0x135f,
+ 0x1714, 0x1715,
+ 0x1734, 0x1734,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x1939, 0x193b,
+ 0x1a60, 0x1a60,
+ 0x1a75, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1abe,
+ 0x1ac1, 0x1acb,
+ 0x1acf, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b34, 0x1b34,
+ 0x1b44, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1baa, 0x1bab,
+ 0x1be6, 0x1be6,
+ 0x1bf2, 0x1bf3,
+ 0x1c36, 0x1c37,
+ 0x1c78, 0x1c7d,
+ 0x1cd0, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf7, 0x1cf9,
+ 0x1d2c, 0x1d6a,
+ 0x1d9b, 0x1dbe,
+ 0x1dc4, 0x1dcf,
+ 0x1df5, 0x1dff,
+ 0x1fbd, 0x1fbd,
+ 0x1fbf, 0x1fc1,
+ 0x1fcd, 0x1fcf,
+ 0x1fdd, 0x1fdf,
+ 0x1fed, 0x1fef,
+ 0x1ffd, 0x1ffe,
+ 0x2cef, 0x2cf1,
+ 0x2e2f, 0x2e2f,
+ 0x302a, 0x302f,
+ 0x3099, 0x309c,
+ 0x30fc, 0x30fc,
+ 0xa66f, 0xa66f,
+ 0xa67c, 0xa67d,
+ 0xa67f, 0xa67f,
+ 0xa69c, 0xa69d,
+ 0xa6f0, 0xa6f1,
+ 0xa700, 0xa721,
+ 0xa788, 0xa78a,
+ 0xa7f1, 0xa7f1,
+ 0xa7f8, 0xa7f9,
+ 0xa806, 0xa806,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c4,
+ 0xa8e0, 0xa8f1,
+ 0xa92b, 0xa92e,
+ 0xa953, 0xa953,
+ 0xa9b3, 0xa9b3,
+ 0xa9c0, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa7b, 0xaa7d,
+ 0xaabf, 0xaac2,
+ 0xaaf6, 0xaaf6,
+ 0xab5b, 0xab5f,
+ 0xab69, 0xab6b,
+ 0xabec, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe20, 0xfe2f,
+ 0xff3e, 0xff3e,
+ 0xff40, 0xff40,
+ 0xff70, 0xff70,
+ 0xff9e, 0xff9f,
+ 0xffe3, 0xffe3,
+ 0x102e0, 0x102e0,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d22, 0x10d27,
+ 0x10d4e, 0x10d4e,
+ 0x10d69, 0x10d6d,
+ 0x10efa, 0x10efa,
+ 0x10efd, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11046, 0x11046,
+ 0x11070, 0x11070,
+ 0x110b9, 0x110ba,
+ 0x11133, 0x11134,
+ 0x11173, 0x11173,
+ 0x111c0, 0x111c0,
+ 0x111ca, 0x111cc,
+ 0x11235, 0x11236,
+ 0x112e9, 0x112ea,
+ 0x1133b, 0x1133c,
+ 0x1134d, 0x1134d,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113ce, 0x113d0,
+ 0x113d2, 0x113d3,
+ 0x113e1, 0x113e2,
+ 0x11442, 0x11442,
+ 0x11446, 0x11446,
+ 0x114c2, 0x114c3,
+ 0x115bf, 0x115c0,
+ 0x1163f, 0x1163f,
+ 0x116b6, 0x116b7,
+ 0x1172b, 0x1172b,
+ 0x11839, 0x1183a,
+ 0x1193d, 0x1193e,
+ 0x11943, 0x11943,
+ 0x119e0, 0x119e0,
+ 0x11a34, 0x11a34,
+ 0x11a47, 0x11a47,
+ 0x11a99, 0x11a99,
+ 0x11c3f, 0x11c3f,
+ 0x11d42, 0x11d42,
+ 0x11d44, 0x11d45,
+ 0x11d97, 0x11d97,
+ 0x11dd9, 0x11dd9,
+ 0x11f41, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13447, 0x13455,
+ 0x1612f, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16d6b, 0x16d6c,
+ 0x16f8f, 0x16f9f,
+ 0x16ff0, 0x16ff1,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d167, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1e030, 0x1e06d,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e946,
+ 0x1e948, 0x1e94a,
+}; /* CR_Diacritic */
+
+/* 'Extender': Binary Property */
+static const OnigCodePoint CR_Extender[] = {
+ 43,
+ 0x00b7, 0x00b7,
+ 0x02d0, 0x02d1,
+ 0x0640, 0x0640,
+ 0x07fa, 0x07fa,
+ 0x0a71, 0x0a71,
+ 0x0afb, 0x0afb,
+ 0x0b55, 0x0b55,
+ 0x0e46, 0x0e46,
+ 0x0ec6, 0x0ec6,
+ 0x180a, 0x180a,
+ 0x1843, 0x1843,
+ 0x1aa7, 0x1aa7,
+ 0x1c36, 0x1c36,
+ 0x1c7b, 0x1c7b,
+ 0x3005, 0x3005,
+ 0x3031, 0x3035,
+ 0x309d, 0x309e,
+ 0x30fc, 0x30fe,
+ 0xa015, 0xa015,
+ 0xa60c, 0xa60c,
+ 0xa9cf, 0xa9cf,
+ 0xa9e6, 0xa9e6,
+ 0xaa70, 0xaa70,
+ 0xaadd, 0xaadd,
+ 0xaaf3, 0xaaf4,
+ 0xff70, 0xff70,
+ 0x10781, 0x10782,
+ 0x10d4e, 0x10d4e,
+ 0x10d6a, 0x10d6a,
+ 0x10d6f, 0x10d6f,
+ 0x11237, 0x11237,
+ 0x1135d, 0x1135d,
+ 0x113d2, 0x113d3,
+ 0x115c6, 0x115c8,
+ 0x11a98, 0x11a98,
+ 0x11dd9, 0x11dd9,
+ 0x16b42, 0x16b43,
+ 0x16fe0, 0x16fe1,
+ 0x16fe3, 0x16fe3,
+ 0x16ff2, 0x16ff3,
+ 0x1e13c, 0x1e13d,
+ 0x1e5ef, 0x1e5ef,
+ 0x1e944, 0x1e946,
+}; /* CR_Extender */
+
+/* 'Other_Lowercase': Binary Property */
+static const OnigCodePoint CR_Other_Lowercase[] = {
+ 28,
+ 0x00aa, 0x00aa,
+ 0x00ba, 0x00ba,
+ 0x02b0, 0x02b8,
+ 0x02c0, 0x02c1,
+ 0x02e0, 0x02e4,
+ 0x0345, 0x0345,
+ 0x037a, 0x037a,
+ 0x10fc, 0x10fc,
+ 0x1d2c, 0x1d6a,
+ 0x1d78, 0x1d78,
+ 0x1d9b, 0x1dbf,
+ 0x2071, 0x2071,
+ 0x207f, 0x207f,
+ 0x2090, 0x209c,
+ 0x2170, 0x217f,
+ 0x24d0, 0x24e9,
+ 0x2c7c, 0x2c7d,
+ 0xa69c, 0xa69d,
+ 0xa770, 0xa770,
+ 0xa7f1, 0xa7f4,
+ 0xa7f8, 0xa7f9,
+ 0xab5c, 0xab5f,
+ 0xab69, 0xab69,
+ 0x10780, 0x10780,
+ 0x10783, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x1e030, 0x1e06d,
+}; /* CR_Other_Lowercase */
+
+/* 'Other_Uppercase': Binary Property */
+static const OnigCodePoint CR_Other_Uppercase[] = {
+ 5,
+ 0x2160, 0x216f,
+ 0x24b6, 0x24cf,
+ 0x1f130, 0x1f149,
+ 0x1f150, 0x1f169,
+ 0x1f170, 0x1f189,
+}; /* CR_Other_Uppercase */
+
+/* 'Noncharacter_Code_Point': Binary Property */
+static const OnigCodePoint CR_Noncharacter_Code_Point[] = {
+ 18,
+ 0xfdd0, 0xfdef,
+ 0xfffe, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0xeffff,
+ 0xffffe, 0xfffff,
+ 0x10fffe, 0x10ffff,
+}; /* CR_Noncharacter_Code_Point */
+
+/* 'Other_Grapheme_Extend': Binary Property */
+static const OnigCodePoint CR_Other_Grapheme_Extend[] = {
+ 49,
+ 0x09be, 0x09be,
+ 0x09d7, 0x09d7,
+ 0x0b3e, 0x0b3e,
+ 0x0b57, 0x0b57,
+ 0x0bbe, 0x0bbe,
+ 0x0bd7, 0x0bd7,
+ 0x0cc0, 0x0cc0,
+ 0x0cc2, 0x0cc2,
+ 0x0cc7, 0x0cc8,
+ 0x0cca, 0x0ccb,
+ 0x0cd5, 0x0cd6,
+ 0x0d3e, 0x0d3e,
+ 0x0d57, 0x0d57,
+ 0x0dcf, 0x0dcf,
+ 0x0ddf, 0x0ddf,
+ 0x1715, 0x1715,
+ 0x1734, 0x1734,
+ 0x1b35, 0x1b35,
+ 0x1b3b, 0x1b3b,
+ 0x1b3d, 0x1b3d,
+ 0x1b43, 0x1b44,
+ 0x1baa, 0x1baa,
+ 0x1bf2, 0x1bf3,
+ 0x200c, 0x200c,
+ 0x302e, 0x302f,
+ 0xa953, 0xa953,
+ 0xa9c0, 0xa9c0,
+ 0xff9e, 0xff9f,
+ 0x111c0, 0x111c0,
+ 0x11235, 0x11235,
+ 0x1133e, 0x1133e,
+ 0x1134d, 0x1134d,
+ 0x11357, 0x11357,
+ 0x113b8, 0x113b8,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113c9,
+ 0x113cf, 0x113cf,
+ 0x114b0, 0x114b0,
+ 0x114bd, 0x114bd,
+ 0x115af, 0x115af,
+ 0x116b6, 0x116b6,
+ 0x11930, 0x11930,
+ 0x1193d, 0x1193d,
+ 0x11f41, 0x11f41,
+ 0x16ff0, 0x16ff1,
+ 0x1d165, 0x1d166,
+ 0x1d16d, 0x1d172,
+ 0xe0020, 0xe007f,
+}; /* CR_Other_Grapheme_Extend */
+
+/* 'IDS_Binary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Binary_Operator[] = {
+ 3,
+ 0x2ff0, 0x2ff1,
+ 0x2ff4, 0x2ffd,
+ 0x31ef, 0x31ef,
+}; /* CR_IDS_Binary_Operator */
+
+/* 'IDS_Trinary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Trinary_Operator[] = {
+ 1,
+ 0x2ff2, 0x2ff3,
+}; /* CR_IDS_Trinary_Operator */
+
+/* 'IDS_Unary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Unary_Operator[] = {
+ 1,
+ 0x2ffe, 0x2fff,
+}; /* CR_IDS_Unary_Operator */
+
+/* 'Radical': Binary Property */
+static const OnigCodePoint CR_Radical[] = {
+ 3,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+}; /* CR_Radical */
+
+/* 'Unified_Ideograph': Binary Property */
+static const OnigCodePoint CR_Unified_Ideograph[] = {
+ 16,
+ 0x3400, 0x4dbf,
+ 0x4e00, 0x9fff,
+ 0xfa0e, 0xfa0f,
+ 0xfa11, 0xfa11,
+ 0xfa13, 0xfa14,
+ 0xfa1f, 0xfa1f,
+ 0xfa21, 0xfa21,
+ 0xfa23, 0xfa24,
+ 0xfa27, 0xfa29,
+ 0x20000, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x30000, 0x3134a,
+ 0x31350, 0x33479,
+}; /* CR_Unified_Ideograph */
+
+/* 'Other_Default_Ignorable_Code_Point': Binary Property */
+static const OnigCodePoint CR_Other_Default_Ignorable_Code_Point[] = {
+ 11,
+ 0x034f, 0x034f,
+ 0x115f, 0x1160,
+ 0x17b4, 0x17b5,
+ 0x2065, 0x2065,
+ 0x3164, 0x3164,
+ 0xffa0, 0xffa0,
+ 0xfff0, 0xfff8,
+ 0xe0000, 0xe0000,
+ 0xe0002, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xe0fff,
+}; /* CR_Other_Default_Ignorable_Code_Point */
+
+/* 'Deprecated': Binary Property */
+static const OnigCodePoint CR_Deprecated[] = {
+ 8,
+ 0x0149, 0x0149,
+ 0x0673, 0x0673,
+ 0x0f77, 0x0f77,
+ 0x0f79, 0x0f79,
+ 0x17a3, 0x17a4,
+ 0x206a, 0x206f,
+ 0x2329, 0x232a,
+ 0xe0001, 0xe0001,
+}; /* CR_Deprecated */
+
+/* 'Soft_Dotted': Binary Property */
+static const OnigCodePoint CR_Soft_Dotted[] = {
+ 34,
+ 0x0069, 0x006a,
+ 0x012f, 0x012f,
+ 0x0249, 0x0249,
+ 0x0268, 0x0268,
+ 0x029d, 0x029d,
+ 0x02b2, 0x02b2,
+ 0x03f3, 0x03f3,
+ 0x0456, 0x0456,
+ 0x0458, 0x0458,
+ 0x1d62, 0x1d62,
+ 0x1d96, 0x1d96,
+ 0x1da4, 0x1da4,
+ 0x1da8, 0x1da8,
+ 0x1e2d, 0x1e2d,
+ 0x1ecb, 0x1ecb,
+ 0x2071, 0x2071,
+ 0x2148, 0x2149,
+ 0x2c7c, 0x2c7c,
+ 0x1d422, 0x1d423,
+ 0x1d456, 0x1d457,
+ 0x1d48a, 0x1d48b,
+ 0x1d4be, 0x1d4bf,
+ 0x1d4f2, 0x1d4f3,
+ 0x1d526, 0x1d527,
+ 0x1d55a, 0x1d55b,
+ 0x1d58e, 0x1d58f,
+ 0x1d5c2, 0x1d5c3,
+ 0x1d5f6, 0x1d5f7,
+ 0x1d62a, 0x1d62b,
+ 0x1d65e, 0x1d65f,
+ 0x1d692, 0x1d693,
+ 0x1df1a, 0x1df1a,
+ 0x1e04c, 0x1e04d,
+ 0x1e068, 0x1e068,
+}; /* CR_Soft_Dotted */
+
+/* 'Logical_Order_Exception': Binary Property */
+static const OnigCodePoint CR_Logical_Order_Exception[] = {
+ 7,
+ 0x0e40, 0x0e44,
+ 0x0ec0, 0x0ec4,
+ 0x19b5, 0x19b7,
+ 0x19ba, 0x19ba,
+ 0xaab5, 0xaab6,
+ 0xaab9, 0xaab9,
+ 0xaabb, 0xaabc,
+}; /* CR_Logical_Order_Exception */
+
+/* 'Other_ID_Start': Binary Property */
+static const OnigCodePoint CR_Other_ID_Start[] = {
+ 4,
+ 0x1885, 0x1886,
+ 0x2118, 0x2118,
+ 0x212e, 0x212e,
+ 0x309b, 0x309c,
+}; /* CR_Other_ID_Start */
+
+/* 'Other_ID_Continue': Binary Property */
+static const OnigCodePoint CR_Other_ID_Continue[] = {
+ 7,
+ 0x00b7, 0x00b7,
+ 0x0387, 0x0387,
+ 0x1369, 0x1371,
+ 0x19da, 0x19da,
+ 0x200c, 0x200d,
+ 0x30fb, 0x30fb,
+ 0xff65, 0xff65,
+}; /* CR_Other_ID_Continue */
+
+/* 'ID_Compat_Math_Continue': Binary Property */
+static const OnigCodePoint CR_ID_Compat_Math_Continue[] = {
+ 18,
+ 0x00b2, 0x00b3,
+ 0x00b9, 0x00b9,
+ 0x2070, 0x2070,
+ 0x2074, 0x207e,
+ 0x2080, 0x208e,
+ 0x2202, 0x2202,
+ 0x2207, 0x2207,
+ 0x221e, 0x221e,
+ 0x1d6c1, 0x1d6c1,
+ 0x1d6db, 0x1d6db,
+ 0x1d6fb, 0x1d6fb,
+ 0x1d715, 0x1d715,
+ 0x1d735, 0x1d735,
+ 0x1d74f, 0x1d74f,
+ 0x1d76f, 0x1d76f,
+ 0x1d789, 0x1d789,
+ 0x1d7a9, 0x1d7a9,
+ 0x1d7c3, 0x1d7c3,
+}; /* CR_ID_Compat_Math_Continue */
+
+/* 'ID_Compat_Math_Start': Binary Property */
+static const OnigCodePoint CR_ID_Compat_Math_Start[] = {
+ 13,
+ 0x2202, 0x2202,
+ 0x2207, 0x2207,
+ 0x221e, 0x221e,
+ 0x1d6c1, 0x1d6c1,
+ 0x1d6db, 0x1d6db,
+ 0x1d6fb, 0x1d6fb,
+ 0x1d715, 0x1d715,
+ 0x1d735, 0x1d735,
+ 0x1d74f, 0x1d74f,
+ 0x1d76f, 0x1d76f,
+ 0x1d789, 0x1d789,
+ 0x1d7a9, 0x1d7a9,
+ 0x1d7c3, 0x1d7c3,
+}; /* CR_ID_Compat_Math_Start */
+
+/* 'Sentence_Terminal': Binary Property */
+static const OnigCodePoint CR_Sentence_Terminal[] = {
+ 88,
+ 0x0021, 0x0021,
+ 0x002e, 0x002e,
+ 0x003f, 0x003f,
+ 0x0589, 0x0589,
+ 0x061d, 0x061f,
+ 0x06d4, 0x06d4,
+ 0x0700, 0x0702,
+ 0x07f9, 0x07f9,
+ 0x0837, 0x0837,
+ 0x0839, 0x0839,
+ 0x083d, 0x083e,
+ 0x0964, 0x0965,
+ 0x104a, 0x104b,
+ 0x1362, 0x1362,
+ 0x1367, 0x1368,
+ 0x166e, 0x166e,
+ 0x1735, 0x1736,
+ 0x17d4, 0x17d5,
+ 0x1803, 0x1803,
+ 0x1809, 0x1809,
+ 0x1944, 0x1945,
+ 0x1aa8, 0x1aab,
+ 0x1b4e, 0x1b4f,
+ 0x1b5a, 0x1b5b,
+ 0x1b5e, 0x1b5f,
+ 0x1b7d, 0x1b7f,
+ 0x1c3b, 0x1c3c,
+ 0x1c7e, 0x1c7f,
+ 0x2024, 0x2024,
+ 0x203c, 0x203d,
+ 0x2047, 0x2049,
+ 0x2cf9, 0x2cfb,
+ 0x2e2e, 0x2e2e,
+ 0x2e3c, 0x2e3c,
+ 0x2e53, 0x2e54,
+ 0x3002, 0x3002,
+ 0xa4ff, 0xa4ff,
+ 0xa60e, 0xa60f,
+ 0xa6f3, 0xa6f3,
+ 0xa6f7, 0xa6f7,
+ 0xa876, 0xa877,
+ 0xa8ce, 0xa8cf,
+ 0xa92f, 0xa92f,
+ 0xa9c8, 0xa9c9,
+ 0xaa5d, 0xaa5f,
+ 0xaaf0, 0xaaf1,
+ 0xabeb, 0xabeb,
+ 0xfe12, 0xfe12,
+ 0xfe15, 0xfe16,
+ 0xfe52, 0xfe52,
+ 0xfe56, 0xfe57,
+ 0xff01, 0xff01,
+ 0xff0e, 0xff0e,
+ 0xff1f, 0xff1f,
+ 0xff61, 0xff61,
+ 0x10a56, 0x10a57,
+ 0x10f55, 0x10f59,
+ 0x10f86, 0x10f89,
+ 0x11047, 0x11048,
+ 0x110be, 0x110c1,
+ 0x11141, 0x11143,
+ 0x111c5, 0x111c6,
+ 0x111cd, 0x111cd,
+ 0x111de, 0x111df,
+ 0x11238, 0x11239,
+ 0x1123b, 0x1123c,
+ 0x112a9, 0x112a9,
+ 0x113d4, 0x113d5,
+ 0x1144b, 0x1144c,
+ 0x115c2, 0x115c3,
+ 0x115c9, 0x115d7,
+ 0x11641, 0x11642,
+ 0x1173c, 0x1173e,
+ 0x11944, 0x11944,
+ 0x11946, 0x11946,
+ 0x11a42, 0x11a43,
+ 0x11a9b, 0x11a9c,
+ 0x11c41, 0x11c42,
+ 0x11ef7, 0x11ef8,
+ 0x11f43, 0x11f44,
+ 0x16a6e, 0x16a6f,
+ 0x16af5, 0x16af5,
+ 0x16b37, 0x16b38,
+ 0x16b44, 0x16b44,
+ 0x16d6e, 0x16d6f,
+ 0x16e98, 0x16e98,
+ 0x1bc9f, 0x1bc9f,
+ 0x1da88, 0x1da88,
+}; /* CR_Sentence_Terminal */
+
+/* 'Variation_Selector': Binary Property */
+static const OnigCodePoint CR_Variation_Selector[] = {
+ 4,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0xfe00, 0xfe0f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Variation_Selector */
+
+/* 'Pattern_White_Space': Binary Property */
+static const OnigCodePoint CR_Pattern_White_Space[] = {
+ 5,
+ 0x0009, 0x000d,
+ 0x0020, 0x0020,
+ 0x0085, 0x0085,
+ 0x200e, 0x200f,
+ 0x2028, 0x2029,
+}; /* CR_Pattern_White_Space */
+
+/* 'Pattern_Syntax': Binary Property */
+static const OnigCodePoint CR_Pattern_Syntax[] = {
+ 28,
+ 0x0021, 0x002f,
+ 0x003a, 0x0040,
+ 0x005b, 0x005e,
+ 0x0060, 0x0060,
+ 0x007b, 0x007e,
+ 0x00a1, 0x00a7,
+ 0x00a9, 0x00a9,
+ 0x00ab, 0x00ac,
+ 0x00ae, 0x00ae,
+ 0x00b0, 0x00b1,
+ 0x00b6, 0x00b6,
+ 0x00bb, 0x00bb,
+ 0x00bf, 0x00bf,
+ 0x00d7, 0x00d7,
+ 0x00f7, 0x00f7,
+ 0x2010, 0x2027,
+ 0x2030, 0x203e,
+ 0x2041, 0x2053,
+ 0x2055, 0x205e,
+ 0x2190, 0x245f,
+ 0x2500, 0x2775,
+ 0x2794, 0x2bff,
+ 0x2e00, 0x2e7f,
+ 0x3001, 0x3003,
+ 0x3008, 0x3020,
+ 0x3030, 0x3030,
+ 0xfd3e, 0xfd3f,
+ 0xfe45, 0xfe46,
+}; /* CR_Pattern_Syntax */
+
+/* 'Prepended_Concatenation_Mark': Binary Property */
+static const OnigCodePoint CR_Prepended_Concatenation_Mark[] = {
+ 7,
+ 0x0600, 0x0605,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x0890, 0x0891,
+ 0x08e2, 0x08e2,
+ 0x110bd, 0x110bd,
+ 0x110cd, 0x110cd,
+}; /* CR_Prepended_Concatenation_Mark */
+
+/* 'Regional_Indicator': Binary Property */
+static const OnigCodePoint CR_Regional_Indicator[] = {
+ 1,
+ 0x1f1e6, 0x1f1ff,
+}; /* CR_Regional_Indicator */
+
+/* 'Modifier_Combining_Mark': Binary Property */
+static const OnigCodePoint CR_Modifier_Combining_Mark[] = {
+ 9,
+ 0x0654, 0x0655,
+ 0x0658, 0x0658,
+ 0x06dc, 0x06dc,
+ 0x06e3, 0x06e3,
+ 0x06e7, 0x06e8,
+ 0x08ca, 0x08cb,
+ 0x08cd, 0x08cf,
+ 0x08d3, 0x08d3,
+ 0x08f3, 0x08f3,
+}; /* CR_Modifier_Combining_Mark */
+
+/* 'Emoji': Emoji */
+static const OnigCodePoint CR_Emoji[] = {
+ 151,
+ 0x0023, 0x0023,
+ 0x002a, 0x002a,
+ 0x0030, 0x0039,
+ 0x00a9, 0x00a9,
+ 0x00ae, 0x00ae,
+ 0x203c, 0x203c,
+ 0x2049, 0x2049,
+ 0x2122, 0x2122,
+ 0x2139, 0x2139,
+ 0x2194, 0x2199,
+ 0x21a9, 0x21aa,
+ 0x231a, 0x231b,
+ 0x2328, 0x2328,
+ 0x23cf, 0x23cf,
+ 0x23e9, 0x23f3,
+ 0x23f8, 0x23fa,
+ 0x24c2, 0x24c2,
+ 0x25aa, 0x25ab,
+ 0x25b6, 0x25b6,
+ 0x25c0, 0x25c0,
+ 0x25fb, 0x25fe,
+ 0x2600, 0x2604,
+ 0x260e, 0x260e,
+ 0x2611, 0x2611,
+ 0x2614, 0x2615,
+ 0x2618, 0x2618,
+ 0x261d, 0x261d,
+ 0x2620, 0x2620,
+ 0x2622, 0x2623,
+ 0x2626, 0x2626,
+ 0x262a, 0x262a,
+ 0x262e, 0x262f,
+ 0x2638, 0x263a,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2648, 0x2653,
+ 0x265f, 0x2660,
+ 0x2663, 0x2663,
+ 0x2665, 0x2666,
+ 0x2668, 0x2668,
+ 0x267b, 0x267b,
+ 0x267e, 0x267f,
+ 0x2692, 0x2697,
+ 0x2699, 0x2699,
+ 0x269b, 0x269c,
+ 0x26a0, 0x26a1,
+ 0x26a7, 0x26a7,
+ 0x26aa, 0x26ab,
+ 0x26b0, 0x26b1,
+ 0x26bd, 0x26be,
+ 0x26c4, 0x26c5,
+ 0x26c8, 0x26c8,
+ 0x26ce, 0x26cf,
+ 0x26d1, 0x26d1,
+ 0x26d3, 0x26d4,
+ 0x26e9, 0x26ea,
+ 0x26f0, 0x26f5,
+ 0x26f7, 0x26fa,
+ 0x26fd, 0x26fd,
+ 0x2702, 0x2702,
+ 0x2705, 0x2705,
+ 0x2708, 0x270d,
+ 0x270f, 0x270f,
+ 0x2712, 0x2712,
+ 0x2714, 0x2714,
+ 0x2716, 0x2716,
+ 0x271d, 0x271d,
+ 0x2721, 0x2721,
+ 0x2728, 0x2728,
+ 0x2733, 0x2734,
+ 0x2744, 0x2744,
+ 0x2747, 0x2747,
+ 0x274c, 0x274c,
+ 0x274e, 0x274e,
+ 0x2753, 0x2755,
+ 0x2757, 0x2757,
+ 0x2763, 0x2764,
+ 0x2795, 0x2797,
+ 0x27a1, 0x27a1,
+ 0x27b0, 0x27b0,
+ 0x27bf, 0x27bf,
+ 0x2934, 0x2935,
+ 0x2b05, 0x2b07,
+ 0x2b1b, 0x2b1c,
+ 0x2b50, 0x2b50,
+ 0x2b55, 0x2b55,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x3297, 0x3297,
+ 0x3299, 0x3299,
+ 0x1f004, 0x1f004,
+ 0x1f0cf, 0x1f0cf,
+ 0x1f170, 0x1f171,
+ 0x1f17e, 0x1f17f,
+ 0x1f18e, 0x1f18e,
+ 0x1f191, 0x1f19a,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f202,
+ 0x1f21a, 0x1f21a,
+ 0x1f22f, 0x1f22f,
+ 0x1f232, 0x1f23a,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f321,
+ 0x1f324, 0x1f393,
+ 0x1f396, 0x1f397,
+ 0x1f399, 0x1f39b,
+ 0x1f39e, 0x1f3f0,
+ 0x1f3f3, 0x1f3f5,
+ 0x1f3f7, 0x1f4fd,
+ 0x1f4ff, 0x1f53d,
+ 0x1f549, 0x1f54e,
+ 0x1f550, 0x1f567,
+ 0x1f56f, 0x1f570,
+ 0x1f573, 0x1f57a,
+ 0x1f587, 0x1f587,
+ 0x1f58a, 0x1f58d,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f5a4, 0x1f5a5,
+ 0x1f5a8, 0x1f5a8,
+ 0x1f5b1, 0x1f5b2,
+ 0x1f5bc, 0x1f5bc,
+ 0x1f5c2, 0x1f5c4,
+ 0x1f5d1, 0x1f5d3,
+ 0x1f5dc, 0x1f5de,
+ 0x1f5e1, 0x1f5e1,
+ 0x1f5e3, 0x1f5e3,
+ 0x1f5e8, 0x1f5e8,
+ 0x1f5ef, 0x1f5ef,
+ 0x1f5f3, 0x1f5f3,
+ 0x1f5fa, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f6cb, 0x1f6d2,
+ 0x1f6d5, 0x1f6d8,
+ 0x1f6dc, 0x1f6e5,
+ 0x1f6e9, 0x1f6e9,
+ 0x1f6eb, 0x1f6ec,
+ 0x1f6f0, 0x1f6f0,
+ 0x1f6f3, 0x1f6fc,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f90c, 0x1f93a,
+ 0x1f93c, 0x1f945,
+ 0x1f947, 0x1f9ff,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+}; /* CR_Emoji */
+
+/* 'Emoji_Presentation': Emoji */
+static const OnigCodePoint CR_Emoji_Presentation[] = {
+ 81,
+ 0x231a, 0x231b,
+ 0x23e9, 0x23ec,
+ 0x23f0, 0x23f0,
+ 0x23f3, 0x23f3,
+ 0x25fd, 0x25fe,
+ 0x2614, 0x2615,
+ 0x2648, 0x2653,
+ 0x267f, 0x267f,
+ 0x2693, 0x2693,
+ 0x26a1, 0x26a1,
+ 0x26aa, 0x26ab,
+ 0x26bd, 0x26be,
+ 0x26c4, 0x26c5,
+ 0x26ce, 0x26ce,
+ 0x26d4, 0x26d4,
+ 0x26ea, 0x26ea,
+ 0x26f2, 0x26f3,
+ 0x26f5, 0x26f5,
+ 0x26fa, 0x26fa,
+ 0x26fd, 0x26fd,
+ 0x2705, 0x2705,
+ 0x270a, 0x270b,
+ 0x2728, 0x2728,
+ 0x274c, 0x274c,
+ 0x274e, 0x274e,
+ 0x2753, 0x2755,
+ 0x2757, 0x2757,
+ 0x2795, 0x2797,
+ 0x27b0, 0x27b0,
+ 0x27bf, 0x27bf,
+ 0x2b1b, 0x2b1c,
+ 0x2b50, 0x2b50,
+ 0x2b55, 0x2b55,
+ 0x1f004, 0x1f004,
+ 0x1f0cf, 0x1f0cf,
+ 0x1f18e, 0x1f18e,
+ 0x1f191, 0x1f19a,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f201, 0x1f201,
+ 0x1f21a, 0x1f21a,
+ 0x1f22f, 0x1f22f,
+ 0x1f232, 0x1f236,
+ 0x1f238, 0x1f23a,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f32d, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f37e, 0x1f393,
+ 0x1f3a0, 0x1f3ca,
+ 0x1f3cf, 0x1f3d3,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f3f4, 0x1f3f4,
+ 0x1f3f8, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4fc,
+ 0x1f4ff, 0x1f53d,
+ 0x1f54b, 0x1f54e,
+ 0x1f550, 0x1f567,
+ 0x1f57a, 0x1f57a,
+ 0x1f595, 0x1f596,
+ 0x1f5a4, 0x1f5a4,
+ 0x1f5fb, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f6cc, 0x1f6cc,
+ 0x1f6d0, 0x1f6d2,
+ 0x1f6d5, 0x1f6d8,
+ 0x1f6dc, 0x1f6df,
+ 0x1f6eb, 0x1f6ec,
+ 0x1f6f4, 0x1f6fc,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f90c, 0x1f93a,
+ 0x1f93c, 0x1f945,
+ 0x1f947, 0x1f9ff,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+}; /* CR_Emoji_Presentation */
+
+/* 'Emoji_Modifier': Emoji */
+static const OnigCodePoint CR_Emoji_Modifier[] = {
+ 1,
+ 0x1f3fb, 0x1f3ff,
+}; /* CR_Emoji_Modifier */
+
+/* 'Emoji_Modifier_Base': Emoji */
+static const OnigCodePoint CR_Emoji_Modifier_Base[] = {
+ 40,
+ 0x261d, 0x261d,
+ 0x26f9, 0x26f9,
+ 0x270a, 0x270d,
+ 0x1f385, 0x1f385,
+ 0x1f3c2, 0x1f3c4,
+ 0x1f3c7, 0x1f3c7,
+ 0x1f3ca, 0x1f3cc,
+ 0x1f442, 0x1f443,
+ 0x1f446, 0x1f450,
+ 0x1f466, 0x1f478,
+ 0x1f47c, 0x1f47c,
+ 0x1f481, 0x1f483,
+ 0x1f485, 0x1f487,
+ 0x1f48f, 0x1f48f,
+ 0x1f491, 0x1f491,
+ 0x1f4aa, 0x1f4aa,
+ 0x1f574, 0x1f575,
+ 0x1f57a, 0x1f57a,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f645, 0x1f647,
+ 0x1f64b, 0x1f64f,
+ 0x1f6a3, 0x1f6a3,
+ 0x1f6b4, 0x1f6b6,
+ 0x1f6c0, 0x1f6c0,
+ 0x1f6cc, 0x1f6cc,
+ 0x1f90c, 0x1f90c,
+ 0x1f90f, 0x1f90f,
+ 0x1f918, 0x1f91f,
+ 0x1f926, 0x1f926,
+ 0x1f930, 0x1f939,
+ 0x1f93c, 0x1f93e,
+ 0x1f977, 0x1f977,
+ 0x1f9b5, 0x1f9b6,
+ 0x1f9b8, 0x1f9b9,
+ 0x1f9bb, 0x1f9bb,
+ 0x1f9cd, 0x1f9cf,
+ 0x1f9d1, 0x1f9dd,
+ 0x1fac3, 0x1fac5,
+ 0x1faf0, 0x1faf8,
+}; /* CR_Emoji_Modifier_Base */
+
+/* 'Emoji_Component': Emoji */
+static const OnigCodePoint CR_Emoji_Component[] = {
+ 10,
+ 0x0023, 0x0023,
+ 0x002a, 0x002a,
+ 0x0030, 0x0039,
+ 0x200d, 0x200d,
+ 0x20e3, 0x20e3,
+ 0xfe0f, 0xfe0f,
+ 0x1f1e6, 0x1f1ff,
+ 0x1f3fb, 0x1f3ff,
+ 0x1f9b0, 0x1f9b3,
+ 0xe0020, 0xe007f,
+}; /* CR_Emoji_Component */
+
+/* 'Extended_Pictographic': Emoji */
+static const OnigCodePoint CR_Extended_Pictographic[] = {
+ 156,
+ 0x00a9, 0x00a9,
+ 0x00ae, 0x00ae,
+ 0x203c, 0x203c,
+ 0x2049, 0x2049,
+ 0x2122, 0x2122,
+ 0x2139, 0x2139,
+ 0x2194, 0x2199,
+ 0x21a9, 0x21aa,
+ 0x231a, 0x231b,
+ 0x2328, 0x2328,
+ 0x23cf, 0x23cf,
+ 0x23e9, 0x23f3,
+ 0x23f8, 0x23fa,
+ 0x24c2, 0x24c2,
+ 0x25aa, 0x25ab,
+ 0x25b6, 0x25b6,
+ 0x25c0, 0x25c0,
+ 0x25fb, 0x25fe,
+ 0x2600, 0x2604,
+ 0x260e, 0x260e,
+ 0x2611, 0x2611,
+ 0x2614, 0x2615,
+ 0x2618, 0x2618,
+ 0x261d, 0x261d,
+ 0x2620, 0x2620,
+ 0x2622, 0x2623,
+ 0x2626, 0x2626,
+ 0x262a, 0x262a,
+ 0x262e, 0x262f,
+ 0x2638, 0x263a,
+ 0x2640, 0x2640,
+ 0x2642, 0x2642,
+ 0x2648, 0x2653,
+ 0x265f, 0x2660,
+ 0x2663, 0x2663,
+ 0x2665, 0x2666,
+ 0x2668, 0x2668,
+ 0x267b, 0x267b,
+ 0x267e, 0x267f,
+ 0x2692, 0x2697,
+ 0x2699, 0x2699,
+ 0x269b, 0x269c,
+ 0x26a0, 0x26a1,
+ 0x26a7, 0x26a7,
+ 0x26aa, 0x26ab,
+ 0x26b0, 0x26b1,
+ 0x26bd, 0x26be,
+ 0x26c4, 0x26c5,
+ 0x26c8, 0x26c8,
+ 0x26ce, 0x26cf,
+ 0x26d1, 0x26d1,
+ 0x26d3, 0x26d4,
+ 0x26e9, 0x26ea,
+ 0x26f0, 0x26f5,
+ 0x26f7, 0x26fa,
+ 0x26fd, 0x26fd,
+ 0x2702, 0x2702,
+ 0x2705, 0x2705,
+ 0x2708, 0x270d,
+ 0x270f, 0x270f,
+ 0x2712, 0x2712,
+ 0x2714, 0x2714,
+ 0x2716, 0x2716,
+ 0x271d, 0x271d,
+ 0x2721, 0x2721,
+ 0x2728, 0x2728,
+ 0x2733, 0x2734,
+ 0x2744, 0x2744,
+ 0x2747, 0x2747,
+ 0x274c, 0x274c,
+ 0x274e, 0x274e,
+ 0x2753, 0x2755,
+ 0x2757, 0x2757,
+ 0x2763, 0x2764,
+ 0x2795, 0x2797,
+ 0x27a1, 0x27a1,
+ 0x27b0, 0x27b0,
+ 0x27bf, 0x27bf,
+ 0x2934, 0x2935,
+ 0x2b05, 0x2b07,
+ 0x2b1b, 0x2b1c,
+ 0x2b50, 0x2b50,
+ 0x2b55, 0x2b55,
+ 0x3030, 0x3030,
+ 0x303d, 0x303d,
+ 0x3297, 0x3297,
+ 0x3299, 0x3299,
+ 0x1f004, 0x1f004,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0cf, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f170, 0x1f171,
+ 0x1f17e, 0x1f17f,
+ 0x1f18e, 0x1f18e,
+ 0x1f191, 0x1f19a,
+ 0x1f1ae, 0x1f1e5,
+ 0x1f201, 0x1f20f,
+ 0x1f21a, 0x1f21a,
+ 0x1f22f, 0x1f22f,
+ 0x1f232, 0x1f23a,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f25f,
+ 0x1f266, 0x1f321,
+ 0x1f324, 0x1f393,
+ 0x1f396, 0x1f397,
+ 0x1f399, 0x1f39b,
+ 0x1f39e, 0x1f3f0,
+ 0x1f3f3, 0x1f3f5,
+ 0x1f3f7, 0x1f3fa,
+ 0x1f400, 0x1f4fd,
+ 0x1f4ff, 0x1f53d,
+ 0x1f549, 0x1f54e,
+ 0x1f550, 0x1f567,
+ 0x1f56f, 0x1f570,
+ 0x1f573, 0x1f57a,
+ 0x1f587, 0x1f587,
+ 0x1f58a, 0x1f58d,
+ 0x1f590, 0x1f590,
+ 0x1f595, 0x1f596,
+ 0x1f5a4, 0x1f5a5,
+ 0x1f5a8, 0x1f5a8,
+ 0x1f5b1, 0x1f5b2,
+ 0x1f5bc, 0x1f5bc,
+ 0x1f5c2, 0x1f5c4,
+ 0x1f5d1, 0x1f5d3,
+ 0x1f5dc, 0x1f5de,
+ 0x1f5e1, 0x1f5e1,
+ 0x1f5e3, 0x1f5e3,
+ 0x1f5e8, 0x1f5e8,
+ 0x1f5ef, 0x1f5ef,
+ 0x1f5f3, 0x1f5f3,
+ 0x1f5fa, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f6cb, 0x1f6d2,
+ 0x1f6d5, 0x1f6e5,
+ 0x1f6e9, 0x1f6e9,
+ 0x1f6eb, 0x1f6f0,
+ 0x1f6f3, 0x1f6ff,
+ 0x1f7da, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8af,
+ 0x1f8bc, 0x1f8bf,
+ 0x1f8c2, 0x1f8cf,
+ 0x1f8d9, 0x1f8ff,
+ 0x1f90c, 0x1f93a,
+ 0x1f93c, 0x1f945,
+ 0x1f947, 0x1f9ff,
+ 0x1fa58, 0x1fa5f,
+ 0x1fa6e, 0x1faff,
+ 0x1fc00, 0x1fffd,
+}; /* CR_Extended_Pictographic */
+
+/* 'Unknown': Script */
+static const OnigCodePoint CR_Unknown[] = {
+ 733,
+ 0x0378, 0x0379,
+ 0x0380, 0x0383,
+ 0x038b, 0x038b,
+ 0x038d, 0x038d,
+ 0x03a2, 0x03a2,
+ 0x0530, 0x0530,
+ 0x0557, 0x0558,
+ 0x058b, 0x058c,
+ 0x0590, 0x0590,
+ 0x05c8, 0x05cf,
+ 0x05eb, 0x05ee,
+ 0x05f5, 0x05ff,
+ 0x070e, 0x070e,
+ 0x074b, 0x074c,
+ 0x07b2, 0x07bf,
+ 0x07fb, 0x07fc,
+ 0x082e, 0x082f,
+ 0x083f, 0x083f,
+ 0x085c, 0x085d,
+ 0x085f, 0x085f,
+ 0x086b, 0x086f,
+ 0x0892, 0x0896,
+ 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,
+ 0x09ff, 0x0a00,
+ 0x0a04, 0x0a04,
+ 0x0a0b, 0x0a0e,
+ 0x0a11, 0x0a12,
+ 0x0a29, 0x0a29,
+ 0x0a31, 0x0a31,
+ 0x0a34, 0x0a34,
+ 0x0a37, 0x0a37,
+ 0x0a3a, 0x0a3b,
+ 0x0a3d, 0x0a3d,
+ 0x0a43, 0x0a46,
+ 0x0a49, 0x0a4a,
+ 0x0a4e, 0x0a50,
+ 0x0a52, 0x0a58,
+ 0x0a5d, 0x0a5d,
+ 0x0a5f, 0x0a65,
+ 0x0a77, 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,
+ 0x0af2, 0x0af8,
+ 0x0b00, 0x0b00,
+ 0x0b04, 0x0b04,
+ 0x0b0d, 0x0b0e,
+ 0x0b11, 0x0b12,
+ 0x0b29, 0x0b29,
+ 0x0b31, 0x0b31,
+ 0x0b34, 0x0b34,
+ 0x0b3a, 0x0b3b,
+ 0x0b45, 0x0b46,
+ 0x0b49, 0x0b4a,
+ 0x0b4e, 0x0b54,
+ 0x0b58, 0x0b5b,
+ 0x0b5e, 0x0b5e,
+ 0x0b64, 0x0b65,
+ 0x0b78, 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, 0x0bcf,
+ 0x0bd1, 0x0bd6,
+ 0x0bd8, 0x0be5,
+ 0x0bfb, 0x0bff,
+ 0x0c0d, 0x0c0d,
+ 0x0c11, 0x0c11,
+ 0x0c29, 0x0c29,
+ 0x0c3a, 0x0c3b,
+ 0x0c45, 0x0c45,
+ 0x0c49, 0x0c49,
+ 0x0c4e, 0x0c54,
+ 0x0c57, 0x0c57,
+ 0x0c5b, 0x0c5b,
+ 0x0c5e, 0x0c5f,
+ 0x0c64, 0x0c65,
+ 0x0c70, 0x0c76,
+ 0x0c8d, 0x0c8d,
+ 0x0c91, 0x0c91,
+ 0x0ca9, 0x0ca9,
+ 0x0cb4, 0x0cb4,
+ 0x0cba, 0x0cbb,
+ 0x0cc5, 0x0cc5,
+ 0x0cc9, 0x0cc9,
+ 0x0cce, 0x0cd4,
+ 0x0cd7, 0x0cdb,
+ 0x0cdf, 0x0cdf,
+ 0x0ce4, 0x0ce5,
+ 0x0cf0, 0x0cf0,
+ 0x0cf4, 0x0cff,
+ 0x0d0d, 0x0d0d,
+ 0x0d11, 0x0d11,
+ 0x0d45, 0x0d45,
+ 0x0d49, 0x0d49,
+ 0x0d50, 0x0d53,
+ 0x0d64, 0x0d65,
+ 0x0d80, 0x0d80,
+ 0x0d84, 0x0d84,
+ 0x0d97, 0x0d99,
+ 0x0db2, 0x0db2,
+ 0x0dbc, 0x0dbc,
+ 0x0dbe, 0x0dbf,
+ 0x0dc7, 0x0dc9,
+ 0x0dcb, 0x0dce,
+ 0x0dd5, 0x0dd5,
+ 0x0dd7, 0x0dd7,
+ 0x0de0, 0x0de5,
+ 0x0df0, 0x0df1,
+ 0x0df5, 0x0e00,
+ 0x0e3b, 0x0e3e,
+ 0x0e5c, 0x0e80,
+ 0x0e83, 0x0e83,
+ 0x0e85, 0x0e85,
+ 0x0e8b, 0x0e8b,
+ 0x0ea4, 0x0ea4,
+ 0x0ea6, 0x0ea6,
+ 0x0ebe, 0x0ebf,
+ 0x0ec5, 0x0ec5,
+ 0x0ec7, 0x0ec7,
+ 0x0ecf, 0x0ecf,
+ 0x0eda, 0x0edb,
+ 0x0ee0, 0x0eff,
+ 0x0f48, 0x0f48,
+ 0x0f6d, 0x0f70,
+ 0x0f98, 0x0f98,
+ 0x0fbd, 0x0fbd,
+ 0x0fcd, 0x0fcd,
+ 0x0fdb, 0x0fff,
+ 0x10c6, 0x10c6,
+ 0x10c8, 0x10cc,
+ 0x10ce, 0x10cf,
+ 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, 0x135c,
+ 0x137d, 0x137f,
+ 0x139a, 0x139f,
+ 0x13f6, 0x13f7,
+ 0x13fe, 0x13ff,
+ 0x169d, 0x169f,
+ 0x16f9, 0x16ff,
+ 0x1716, 0x171e,
+ 0x1737, 0x173f,
+ 0x1754, 0x175f,
+ 0x176d, 0x176d,
+ 0x1771, 0x1771,
+ 0x1774, 0x177f,
+ 0x17de, 0x17df,
+ 0x17ea, 0x17ef,
+ 0x17fa, 0x17ff,
+ 0x181a, 0x181f,
+ 0x1879, 0x187f,
+ 0x18ab, 0x18af,
+ 0x18f6, 0x18ff,
+ 0x191f, 0x191f,
+ 0x192c, 0x192f,
+ 0x193c, 0x193f,
+ 0x1941, 0x1943,
+ 0x196e, 0x196f,
+ 0x1975, 0x197f,
+ 0x19ac, 0x19af,
+ 0x19ca, 0x19cf,
+ 0x19db, 0x19dd,
+ 0x1a1c, 0x1a1d,
+ 0x1a5f, 0x1a5f,
+ 0x1a7d, 0x1a7e,
+ 0x1a8a, 0x1a8f,
+ 0x1a9a, 0x1a9f,
+ 0x1aae, 0x1aaf,
+ 0x1ade, 0x1adf,
+ 0x1aec, 0x1aff,
+ 0x1b4d, 0x1b4d,
+ 0x1bf4, 0x1bfb,
+ 0x1c38, 0x1c3a,
+ 0x1c4a, 0x1c4c,
+ 0x1c8b, 0x1c8f,
+ 0x1cbb, 0x1cbc,
+ 0x1cc8, 0x1ccf,
+ 0x1cfb, 0x1cff,
+ 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,
+ 0x2065, 0x2065,
+ 0x2072, 0x2073,
+ 0x208f, 0x208f,
+ 0x209d, 0x209f,
+ 0x20c2, 0x20cf,
+ 0x20f1, 0x20ff,
+ 0x218c, 0x218f,
+ 0x242a, 0x243f,
+ 0x244b, 0x245f,
+ 0x2b74, 0x2b75,
+ 0x2cf4, 0x2cf8,
+ 0x2d26, 0x2d26,
+ 0x2d28, 0x2d2c,
+ 0x2d2e, 0x2d2f,
+ 0x2d68, 0x2d6e,
+ 0x2d71, 0x2d7e,
+ 0x2d97, 0x2d9f,
+ 0x2da7, 0x2da7,
+ 0x2daf, 0x2daf,
+ 0x2db7, 0x2db7,
+ 0x2dbf, 0x2dbf,
+ 0x2dc7, 0x2dc7,
+ 0x2dcf, 0x2dcf,
+ 0x2dd7, 0x2dd7,
+ 0x2ddf, 0x2ddf,
+ 0x2e5e, 0x2e7f,
+ 0x2e9a, 0x2e9a,
+ 0x2ef4, 0x2eff,
+ 0x2fd6, 0x2fef,
+ 0x3040, 0x3040,
+ 0x3097, 0x3098,
+ 0x3100, 0x3104,
+ 0x3130, 0x3130,
+ 0x318f, 0x318f,
+ 0x31e6, 0x31ee,
+ 0x321f, 0x321f,
+ 0xa48d, 0xa48f,
+ 0xa4c7, 0xa4cf,
+ 0xa62c, 0xa63f,
+ 0xa6f8, 0xa6ff,
+ 0xa7dd, 0xa7f0,
+ 0xa82d, 0xa82f,
+ 0xa83a, 0xa83f,
+ 0xa878, 0xa87f,
+ 0xa8c6, 0xa8cd,
+ 0xa8da, 0xa8df,
+ 0xa954, 0xa95e,
+ 0xa97d, 0xa97f,
+ 0xa9ce, 0xa9ce,
+ 0xa9da, 0xa9dd,
+ 0xa9ff, 0xa9ff,
+ 0xaa37, 0xaa3f,
+ 0xaa4e, 0xaa4f,
+ 0xaa5a, 0xaa5b,
+ 0xaac3, 0xaada,
+ 0xaaf7, 0xab00,
+ 0xab07, 0xab08,
+ 0xab0f, 0xab10,
+ 0xab17, 0xab1f,
+ 0xab27, 0xab27,
+ 0xab2f, 0xab2f,
+ 0xab6c, 0xab6f,
+ 0xabee, 0xabef,
+ 0xabfa, 0xabff,
+ 0xd7a4, 0xd7af,
+ 0xd7c7, 0xd7ca,
+ 0xd7fc, 0xf8ff,
+ 0xfa6e, 0xfa6f,
+ 0xfada, 0xfaff,
+ 0xfb07, 0xfb12,
+ 0xfb18, 0xfb1c,
+ 0xfb37, 0xfb37,
+ 0xfb3d, 0xfb3d,
+ 0xfb3f, 0xfb3f,
+ 0xfb42, 0xfb42,
+ 0xfb45, 0xfb45,
+ 0xfdd0, 0xfdef,
+ 0xfe1a, 0xfe1f,
+ 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,
+ 0x1018f, 0x1018f,
+ 0x1019d, 0x1019f,
+ 0x101a1, 0x101cf,
+ 0x101fe, 0x1027f,
+ 0x1029d, 0x1029f,
+ 0x102d1, 0x102df,
+ 0x102fc, 0x102ff,
+ 0x10324, 0x1032c,
+ 0x1034b, 0x1034f,
+ 0x1037b, 0x1037f,
+ 0x1039e, 0x1039e,
+ 0x103c4, 0x103c7,
+ 0x103d6, 0x103ff,
+ 0x1049e, 0x1049f,
+ 0x104aa, 0x104af,
+ 0x104d4, 0x104d7,
+ 0x104fc, 0x104ff,
+ 0x10528, 0x1052f,
+ 0x10564, 0x1056e,
+ 0x1057b, 0x1057b,
+ 0x1058b, 0x1058b,
+ 0x10593, 0x10593,
+ 0x10596, 0x10596,
+ 0x105a2, 0x105a2,
+ 0x105b2, 0x105b2,
+ 0x105ba, 0x105ba,
+ 0x105bd, 0x105bf,
+ 0x105f4, 0x105ff,
+ 0x10737, 0x1073f,
+ 0x10756, 0x1075f,
+ 0x10768, 0x1077f,
+ 0x10786, 0x10786,
+ 0x107b1, 0x107b1,
+ 0x107bb, 0x107ff,
+ 0x10806, 0x10807,
+ 0x10809, 0x10809,
+ 0x10836, 0x10836,
+ 0x10839, 0x1083b,
+ 0x1083d, 0x1083e,
+ 0x10856, 0x10856,
+ 0x1089f, 0x108a6,
+ 0x108b0, 0x108df,
+ 0x108f3, 0x108f3,
+ 0x108f6, 0x108fa,
+ 0x1091c, 0x1091e,
+ 0x1093a, 0x1093e,
+ 0x1095a, 0x1097f,
+ 0x109b8, 0x109bb,
+ 0x109d0, 0x109d1,
+ 0x10a04, 0x10a04,
+ 0x10a07, 0x10a0b,
+ 0x10a14, 0x10a14,
+ 0x10a18, 0x10a18,
+ 0x10a36, 0x10a37,
+ 0x10a3b, 0x10a3e,
+ 0x10a49, 0x10a4f,
+ 0x10a59, 0x10a5f,
+ 0x10aa0, 0x10abf,
+ 0x10ae7, 0x10aea,
+ 0x10af7, 0x10aff,
+ 0x10b36, 0x10b38,
+ 0x10b56, 0x10b57,
+ 0x10b73, 0x10b77,
+ 0x10b92, 0x10b98,
+ 0x10b9d, 0x10ba8,
+ 0x10bb0, 0x10bff,
+ 0x10c49, 0x10c7f,
+ 0x10cb3, 0x10cbf,
+ 0x10cf3, 0x10cf9,
+ 0x10d28, 0x10d2f,
+ 0x10d3a, 0x10d3f,
+ 0x10d66, 0x10d68,
+ 0x10d86, 0x10d8d,
+ 0x10d90, 0x10e5f,
+ 0x10e7f, 0x10e7f,
+ 0x10eaa, 0x10eaa,
+ 0x10eae, 0x10eaf,
+ 0x10eb2, 0x10ec1,
+ 0x10ec8, 0x10ecf,
+ 0x10ed9, 0x10ef9,
+ 0x10f28, 0x10f2f,
+ 0x10f5a, 0x10f6f,
+ 0x10f8a, 0x10faf,
+ 0x10fcc, 0x10fdf,
+ 0x10ff7, 0x10fff,
+ 0x1104e, 0x11051,
+ 0x11076, 0x1107e,
+ 0x110c3, 0x110cc,
+ 0x110ce, 0x110cf,
+ 0x110e9, 0x110ef,
+ 0x110fa, 0x110ff,
+ 0x11135, 0x11135,
+ 0x11148, 0x1114f,
+ 0x11177, 0x1117f,
+ 0x111e0, 0x111e0,
+ 0x111f5, 0x111ff,
+ 0x11212, 0x11212,
+ 0x11242, 0x1127f,
+ 0x11287, 0x11287,
+ 0x11289, 0x11289,
+ 0x1128e, 0x1128e,
+ 0x1129e, 0x1129e,
+ 0x112aa, 0x112af,
+ 0x112eb, 0x112ef,
+ 0x112fa, 0x112ff,
+ 0x11304, 0x11304,
+ 0x1130d, 0x1130e,
+ 0x11311, 0x11312,
+ 0x11329, 0x11329,
+ 0x11331, 0x11331,
+ 0x11334, 0x11334,
+ 0x1133a, 0x1133a,
+ 0x11345, 0x11346,
+ 0x11349, 0x1134a,
+ 0x1134e, 0x1134f,
+ 0x11351, 0x11356,
+ 0x11358, 0x1135c,
+ 0x11364, 0x11365,
+ 0x1136d, 0x1136f,
+ 0x11375, 0x1137f,
+ 0x1138a, 0x1138a,
+ 0x1138c, 0x1138d,
+ 0x1138f, 0x1138f,
+ 0x113b6, 0x113b6,
+ 0x113c1, 0x113c1,
+ 0x113c3, 0x113c4,
+ 0x113c6, 0x113c6,
+ 0x113cb, 0x113cb,
+ 0x113d6, 0x113d6,
+ 0x113d9, 0x113e0,
+ 0x113e3, 0x113ff,
+ 0x1145c, 0x1145c,
+ 0x11462, 0x1147f,
+ 0x114c8, 0x114cf,
+ 0x114da, 0x1157f,
+ 0x115b6, 0x115b7,
+ 0x115de, 0x115ff,
+ 0x11645, 0x1164f,
+ 0x1165a, 0x1165f,
+ 0x1166d, 0x1167f,
+ 0x116ba, 0x116bf,
+ 0x116ca, 0x116cf,
+ 0x116e4, 0x116ff,
+ 0x1171b, 0x1171c,
+ 0x1172c, 0x1172f,
+ 0x11747, 0x117ff,
+ 0x1183c, 0x1189f,
+ 0x118f3, 0x118fe,
+ 0x11907, 0x11908,
+ 0x1190a, 0x1190b,
+ 0x11914, 0x11914,
+ 0x11917, 0x11917,
+ 0x11936, 0x11936,
+ 0x11939, 0x1193a,
+ 0x11947, 0x1194f,
+ 0x1195a, 0x1199f,
+ 0x119a8, 0x119a9,
+ 0x119d8, 0x119d9,
+ 0x119e5, 0x119ff,
+ 0x11a48, 0x11a4f,
+ 0x11aa3, 0x11aaf,
+ 0x11af9, 0x11aff,
+ 0x11b0a, 0x11b5f,
+ 0x11b68, 0x11bbf,
+ 0x11be2, 0x11bef,
+ 0x11bfa, 0x11bff,
+ 0x11c09, 0x11c09,
+ 0x11c37, 0x11c37,
+ 0x11c46, 0x11c4f,
+ 0x11c6d, 0x11c6f,
+ 0x11c90, 0x11c91,
+ 0x11ca8, 0x11ca8,
+ 0x11cb7, 0x11cff,
+ 0x11d07, 0x11d07,
+ 0x11d0a, 0x11d0a,
+ 0x11d37, 0x11d39,
+ 0x11d3b, 0x11d3b,
+ 0x11d3e, 0x11d3e,
+ 0x11d48, 0x11d4f,
+ 0x11d5a, 0x11d5f,
+ 0x11d66, 0x11d66,
+ 0x11d69, 0x11d69,
+ 0x11d8f, 0x11d8f,
+ 0x11d92, 0x11d92,
+ 0x11d99, 0x11d9f,
+ 0x11daa, 0x11daf,
+ 0x11ddc, 0x11ddf,
+ 0x11dea, 0x11edf,
+ 0x11ef9, 0x11eff,
+ 0x11f11, 0x11f11,
+ 0x11f3b, 0x11f3d,
+ 0x11f5b, 0x11faf,
+ 0x11fb1, 0x11fbf,
+ 0x11ff2, 0x11ffe,
+ 0x1239a, 0x123ff,
+ 0x1246f, 0x1246f,
+ 0x12475, 0x1247f,
+ 0x12544, 0x12f8f,
+ 0x12ff3, 0x12fff,
+ 0x13456, 0x1345f,
+ 0x143fb, 0x143ff,
+ 0x14647, 0x160ff,
+ 0x1613a, 0x167ff,
+ 0x16a39, 0x16a3f,
+ 0x16a5f, 0x16a5f,
+ 0x16a6a, 0x16a6d,
+ 0x16abf, 0x16abf,
+ 0x16aca, 0x16acf,
+ 0x16aee, 0x16aef,
+ 0x16af6, 0x16aff,
+ 0x16b46, 0x16b4f,
+ 0x16b5a, 0x16b5a,
+ 0x16b62, 0x16b62,
+ 0x16b78, 0x16b7c,
+ 0x16b90, 0x16d3f,
+ 0x16d7a, 0x16e3f,
+ 0x16e9b, 0x16e9f,
+ 0x16eb9, 0x16eba,
+ 0x16ed4, 0x16eff,
+ 0x16f4b, 0x16f4e,
+ 0x16f88, 0x16f8e,
+ 0x16fa0, 0x16fdf,
+ 0x16fe5, 0x16fef,
+ 0x16ff7, 0x16fff,
+ 0x18cd6, 0x18cfe,
+ 0x18d1f, 0x18d7f,
+ 0x18df3, 0x1afef,
+ 0x1aff4, 0x1aff4,
+ 0x1affc, 0x1affc,
+ 0x1afff, 0x1afff,
+ 0x1b123, 0x1b131,
+ 0x1b133, 0x1b14f,
+ 0x1b153, 0x1b154,
+ 0x1b156, 0x1b163,
+ 0x1b168, 0x1b16f,
+ 0x1b2fc, 0x1bbff,
+ 0x1bc6b, 0x1bc6f,
+ 0x1bc7d, 0x1bc7f,
+ 0x1bc89, 0x1bc8f,
+ 0x1bc9a, 0x1bc9b,
+ 0x1bca4, 0x1cbff,
+ 0x1ccfd, 0x1ccff,
+ 0x1ceb4, 0x1ceb9,
+ 0x1ced1, 0x1cedf,
+ 0x1cef1, 0x1ceff,
+ 0x1cf2e, 0x1cf2f,
+ 0x1cf47, 0x1cf4f,
+ 0x1cfc4, 0x1cfff,
+ 0x1d0f6, 0x1d0ff,
+ 0x1d127, 0x1d128,
+ 0x1d1eb, 0x1d1ff,
+ 0x1d246, 0x1d2bf,
+ 0x1d2d4, 0x1d2df,
+ 0x1d2f4, 0x1d2ff,
+ 0x1d357, 0x1d35f,
+ 0x1d379, 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,
+ 0x1d7cc, 0x1d7cd,
+ 0x1da8c, 0x1da9a,
+ 0x1daa0, 0x1daa0,
+ 0x1dab0, 0x1deff,
+ 0x1df1f, 0x1df24,
+ 0x1df2b, 0x1dfff,
+ 0x1e007, 0x1e007,
+ 0x1e019, 0x1e01a,
+ 0x1e022, 0x1e022,
+ 0x1e025, 0x1e025,
+ 0x1e02b, 0x1e02f,
+ 0x1e06e, 0x1e08e,
+ 0x1e090, 0x1e0ff,
+ 0x1e12d, 0x1e12f,
+ 0x1e13e, 0x1e13f,
+ 0x1e14a, 0x1e14d,
+ 0x1e150, 0x1e28f,
+ 0x1e2af, 0x1e2bf,
+ 0x1e2fa, 0x1e2fe,
+ 0x1e300, 0x1e4cf,
+ 0x1e4fa, 0x1e5cf,
+ 0x1e5fb, 0x1e5fe,
+ 0x1e600, 0x1e6bf,
+ 0x1e6df, 0x1e6df,
+ 0x1e6f6, 0x1e6fd,
+ 0x1e700, 0x1e7df,
+ 0x1e7e7, 0x1e7e7,
+ 0x1e7ec, 0x1e7ec,
+ 0x1e7ef, 0x1e7ef,
+ 0x1e7ff, 0x1e7ff,
+ 0x1e8c5, 0x1e8c6,
+ 0x1e8d7, 0x1e8ff,
+ 0x1e94c, 0x1e94f,
+ 0x1e95a, 0x1e95d,
+ 0x1e960, 0x1ec70,
+ 0x1ecb5, 0x1ed00,
+ 0x1ed3e, 0x1edff,
+ 0x1ee04, 0x1ee04,
+ 0x1ee20, 0x1ee20,
+ 0x1ee23, 0x1ee23,
+ 0x1ee25, 0x1ee26,
+ 0x1ee28, 0x1ee28,
+ 0x1ee33, 0x1ee33,
+ 0x1ee38, 0x1ee38,
+ 0x1ee3a, 0x1ee3a,
+ 0x1ee3c, 0x1ee41,
+ 0x1ee43, 0x1ee46,
+ 0x1ee48, 0x1ee48,
+ 0x1ee4a, 0x1ee4a,
+ 0x1ee4c, 0x1ee4c,
+ 0x1ee50, 0x1ee50,
+ 0x1ee53, 0x1ee53,
+ 0x1ee55, 0x1ee56,
+ 0x1ee58, 0x1ee58,
+ 0x1ee5a, 0x1ee5a,
+ 0x1ee5c, 0x1ee5c,
+ 0x1ee5e, 0x1ee5e,
+ 0x1ee60, 0x1ee60,
+ 0x1ee63, 0x1ee63,
+ 0x1ee65, 0x1ee66,
+ 0x1ee6b, 0x1ee6b,
+ 0x1ee73, 0x1ee73,
+ 0x1ee78, 0x1ee78,
+ 0x1ee7d, 0x1ee7d,
+ 0x1ee7f, 0x1ee7f,
+ 0x1ee8a, 0x1ee8a,
+ 0x1ee9c, 0x1eea0,
+ 0x1eea4, 0x1eea4,
+ 0x1eeaa, 0x1eeaa,
+ 0x1eebc, 0x1eeef,
+ 0x1eef2, 0x1efff,
+ 0x1f02c, 0x1f02f,
+ 0x1f094, 0x1f09f,
+ 0x1f0af, 0x1f0b0,
+ 0x1f0c0, 0x1f0c0,
+ 0x1f0d0, 0x1f0d0,
+ 0x1f0f6, 0x1f0ff,
+ 0x1f1ae, 0x1f1e5,
+ 0x1f203, 0x1f20f,
+ 0x1f23c, 0x1f23f,
+ 0x1f249, 0x1f24f,
+ 0x1f252, 0x1f25f,
+ 0x1f266, 0x1f2ff,
+ 0x1f6d9, 0x1f6db,
+ 0x1f6ed, 0x1f6ef,
+ 0x1f6fd, 0x1f6ff,
+ 0x1f7da, 0x1f7df,
+ 0x1f7ec, 0x1f7ef,
+ 0x1f7f1, 0x1f7ff,
+ 0x1f80c, 0x1f80f,
+ 0x1f848, 0x1f84f,
+ 0x1f85a, 0x1f85f,
+ 0x1f888, 0x1f88f,
+ 0x1f8ae, 0x1f8af,
+ 0x1f8bc, 0x1f8bf,
+ 0x1f8c2, 0x1f8cf,
+ 0x1f8d9, 0x1f8ff,
+ 0x1fa58, 0x1fa5f,
+ 0x1fa6e, 0x1fa6f,
+ 0x1fa7d, 0x1fa7f,
+ 0x1fa8b, 0x1fa8d,
+ 0x1fac7, 0x1fac7,
+ 0x1fac9, 0x1facc,
+ 0x1fadd, 0x1fade,
+ 0x1faeb, 0x1faee,
+ 0x1faf9, 0x1faff,
+ 0x1fb93, 0x1fb93,
+ 0x1fbfb, 0x1ffff,
+ 0x2a6e0, 0x2a6ff,
+ 0x2b81e, 0x2b81f,
+ 0x2ceae, 0x2ceaf,
+ 0x2ebe1, 0x2ebef,
+ 0x2ee5e, 0x2f7ff,
+ 0x2fa1e, 0x2ffff,
+ 0x3134b, 0x3134f,
+ 0x3347a, 0xe0000,
+ 0xe0002, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0x10ffff,
+}; /* CR_Unknown */
+
+#ifdef USE_UNICODE_AGE_PROPERTIES
+/* 'Age_1_1': Derived Age 1.1 */
+static const OnigCodePoint CR_Age_1_1[] = {
+ 288,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x05b0, 0x05b9,
+ 0x05bb, 0x05c3,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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,
+ 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,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1e00, 0x1e9a,
+ 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, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20aa,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xe000, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffd, 0xffff,
+}; /* CR_Age_1_1 */
+
+/* 'Age_2_0': Derived Age 2.0 */
+static const OnigCodePoint CR_Age_2_0[] = {
+ 312,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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,
+ 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, 0x0f69,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f95,
+ 0x0f97, 0x0f97,
+ 0x0f99, 0x0fad,
+ 0x0fb1, 0x0fb7,
+ 0x0fb9, 0x0fb9,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 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, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20ab,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffd, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_2_0 */
+
+/* 'Age_2_1': Derived Age 2.1 */
+static const OnigCodePoint CR_Age_2_1[] = {
+ 312,
+ 0x0000, 0x01f5,
+ 0x01fa, 0x0217,
+ 0x0250, 0x02a8,
+ 0x02b0, 0x02de,
+ 0x02e0, 0x02e9,
+ 0x0300, 0x0345,
+ 0x0360, 0x0361,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d6,
+ 0x03da, 0x03da,
+ 0x03dc, 0x03dc,
+ 0x03de, 0x03de,
+ 0x03e0, 0x03e0,
+ 0x03e2, 0x03f3,
+ 0x0401, 0x040c,
+ 0x040e, 0x044f,
+ 0x0451, 0x045c,
+ 0x045e, 0x0486,
+ 0x0490, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04eb,
+ 0x04ee, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x0589,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0652,
+ 0x0660, 0x066d,
+ 0x0670, 0x06b7,
+ 0x06ba, 0x06be,
+ 0x06c0, 0x06ce,
+ 0x06d0, 0x06ed,
+ 0x06f0, 0x06f9,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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,
+ 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, 0x0f69,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f95,
+ 0x0f97, 0x0f97,
+ 0x0f99, 0x0fad,
+ 0x0fb1, 0x0fb7,
+ 0x0fb9, 0x0fb9,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 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, 0x202e,
+ 0x2030, 0x2046,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20ac,
+ 0x20d0, 0x20e1,
+ 0x2100, 0x2138,
+ 0x2153, 0x2182,
+ 0x2190, 0x21ea,
+ 0x2200, 0x22f1,
+ 0x2300, 0x2300,
+ 0x2302, 0x237a,
+ 0x2400, 0x2424,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25ef,
+ 0x2600, 0x2613,
+ 0x261a, 0x266f,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x3000, 0x3037,
+ 0x303f, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x319f,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x4e00, 0x9fa5,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1e, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfffc, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_2_1 */
+
+/* 'Age_3_0': Derived Age 3.0 */
+static const OnigCodePoint CR_Age_3_0[] = {
+ 369,
+ 0x0000, 0x021f,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034e,
+ 0x0360, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d7,
+ 0x03da, 0x03f3,
+ 0x0400, 0x0486,
+ 0x0488, 0x0489,
+ 0x048c, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x066d,
+ 0x0670, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b0,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 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, 0x2046,
+ 0x2048, 0x204d,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20af,
+ 0x20d0, 0x20e3,
+ 0x2100, 0x213a,
+ 0x2153, 0x2183,
+ 0x2190, 0x21f3,
+ 0x2200, 0x22f1,
+ 0x2300, 0x237b,
+ 0x237d, 0x239a,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25f7,
+ 0x2600, 0x2613,
+ 0x2619, 0x2671,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x2800, 0x28ff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303a,
+ 0x303e, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4a1,
+ 0xa4a4, 0xa4b3,
+ 0xa4b5, 0xa4c0,
+ 0xa4c2, 0xa4c4,
+ 0xa4c6, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdf0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xffff,
+ 0x1fffe, 0x1ffff,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_0 */
+
+/* 'Age_3_1': Derived Age 3.1 */
+static const OnigCodePoint CR_Age_3_1[] = {
+ 402,
+ 0x0000, 0x021f,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034e,
+ 0x0360, 0x0362,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03d7,
+ 0x03da, 0x03f5,
+ 0x0400, 0x0486,
+ 0x0488, 0x0489,
+ 0x048c, 0x04c4,
+ 0x04c7, 0x04c8,
+ 0x04cb, 0x04cc,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x066d,
+ 0x0670, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b0,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f6,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 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, 0x2046,
+ 0x2048, 0x204d,
+ 0x206a, 0x2070,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20af,
+ 0x20d0, 0x20e3,
+ 0x2100, 0x213a,
+ 0x2153, 0x2183,
+ 0x2190, 0x21f3,
+ 0x2200, 0x22f1,
+ 0x2300, 0x237b,
+ 0x237d, 0x239a,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24ea,
+ 0x2500, 0x2595,
+ 0x25a0, 0x25f7,
+ 0x2600, 0x2613,
+ 0x2619, 0x2671,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2767,
+ 0x2776, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x2800, 0x28ff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303a,
+ 0x303e, 0x303f,
+ 0x3041, 0x3094,
+ 0x3099, 0x309e,
+ 0x30a1, 0x30fe,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x3200, 0x321c,
+ 0x3220, 0x3243,
+ 0x3260, 0x327b,
+ 0x327f, 0x32b0,
+ 0x32c0, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4a1,
+ 0xa4a4, 0xa4b3,
+ 0xa4b5, 0xa4c0,
+ 0xa4c2, 0xa4c4,
+ 0xa4c6, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfb,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe44,
+ 0xfe49, 0xfe52,
+ 0xfe54, 0xfe66,
+ 0xfe68, 0xfe6b,
+ 0xfe70, 0xfe72,
+ 0xfe74, 0xfe74,
+ 0xfe76, 0xfefc,
+ 0xfeff, 0xfeff,
+ 0xff01, 0xff5e,
+ 0xff61, 0xffbe,
+ 0xffc2, 0xffc7,
+ 0xffca, 0xffcf,
+ 0xffd2, 0xffd7,
+ 0xffda, 0xffdc,
+ 0xffe0, 0xffe6,
+ 0xffe8, 0xffee,
+ 0xfff9, 0xffff,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10400, 0x10425,
+ 0x10428, 0x1044d,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c0,
+ 0x1d4c2, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_1 */
+
+/* 'Age_3_2': Derived Age 3.2 */
+static const OnigCodePoint CR_Age_3_2[] = {
+ 397,
+ 0x0000, 0x0220,
+ 0x0222, 0x0233,
+ 0x0250, 0x02ad,
+ 0x02b0, 0x02ee,
+ 0x0300, 0x034f,
+ 0x0360, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03f6,
+ 0x0400, 0x0486,
+ 0x0488, 0x04ce,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0500, 0x050f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x060c, 0x060c,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0655,
+ 0x0660, 0x06ed,
+ 0x06f0, 0x06fe,
+ 0x0700, 0x070d,
+ 0x070f, 0x072c,
+ 0x0730, 0x074a,
+ 0x0780, 0x07b1,
+ 0x0901, 0x0903,
+ 0x0905, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09dc, 0x09dd,
+ 0x09df, 0x09e3,
+ 0x09e6, 0x09fa,
+ 0x0a02, 0x0a02,
+ 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, 0x0a8b,
+ 0x0a8d, 0x0a8d,
+ 0x0a8f, 0x0a91,
+ 0x0a93, 0x0aa8,
+ 0x0aaa, 0x0ab0,
+ 0x0ab2, 0x0ab3,
+ 0x0ab5, 0x0ab9,
+ 0x0abc, 0x0ac5,
+ 0x0ac7, 0x0ac9,
+ 0x0acb, 0x0acd,
+ 0x0ad0, 0x0ad0,
+ 0x0ae0, 0x0ae0,
+ 0x0ae6, 0x0aef,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b36, 0x0b39,
+ 0x0b3c, 0x0b43,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b61,
+ 0x0b66, 0x0b70,
+ 0x0b82, 0x0b83,
+ 0x0b85, 0x0b8a,
+ 0x0b8e, 0x0b90,
+ 0x0b92, 0x0b95,
+ 0x0b99, 0x0b9a,
+ 0x0b9c, 0x0b9c,
+ 0x0b9e, 0x0b9f,
+ 0x0ba3, 0x0ba4,
+ 0x0ba8, 0x0baa,
+ 0x0bae, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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,
+ 0x0cbe, 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, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f8,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 0x13a0, 0x13f4,
+ 0x1401, 0x1676,
+ 0x1680, 0x169c,
+ 0x16a0, 0x16f0,
+ 0x1700, 0x170c,
+ 0x170e, 0x1714,
+ 0x1720, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dc,
+ 0x17e0, 0x17e9,
+ 0x1800, 0x180e,
+ 0x1810, 0x1819,
+ 0x1820, 0x1877,
+ 0x1880, 0x18a9,
+ 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, 0x2052,
+ 0x2057, 0x2057,
+ 0x205f, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20b1,
+ 0x20d0, 0x20ea,
+ 0x2100, 0x213a,
+ 0x213d, 0x214b,
+ 0x2153, 0x2183,
+ 0x2190, 0x23ce,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x24fe,
+ 0x2500, 0x2613,
+ 0x2616, 0x2617,
+ 0x2619, 0x267d,
+ 0x2680, 0x2689,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2aff,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31f0, 0x321c,
+ 0x3220, 0x3243,
+ 0x3251, 0x327b,
+ 0x327f, 0x32cb,
+ 0x32d0, 0x32fe,
+ 0x3300, 0x3376,
+ 0x337b, 0x33dd,
+ 0x33e0, 0x33fe,
+ 0x3400, 0x4db5,
+ 0x4e00, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfc,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe23,
+ 0xfe30, 0xfe46,
+ 0xfe49, 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, 0xffff,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10400, 0x10425,
+ 0x10428, 0x1044d,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d400, 0x1d454,
+ 0x1d456, 0x1d49c,
+ 0x1d49e, 0x1d49f,
+ 0x1d4a2, 0x1d4a2,
+ 0x1d4a5, 0x1d4a6,
+ 0x1d4a9, 0x1d4ac,
+ 0x1d4ae, 0x1d4b9,
+ 0x1d4bb, 0x1d4bb,
+ 0x1d4bd, 0x1d4c0,
+ 0x1d4c2, 0x1d4c3,
+ 0x1d4c5, 0x1d505,
+ 0x1d507, 0x1d50a,
+ 0x1d50d, 0x1d514,
+ 0x1d516, 0x1d51c,
+ 0x1d51e, 0x1d539,
+ 0x1d53b, 0x1d53e,
+ 0x1d540, 0x1d544,
+ 0x1d546, 0x1d546,
+ 0x1d54a, 0x1d550,
+ 0x1d552, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_3_2 */
+
+/* 'Age_4_0': Derived Age 4.0 */
+static const OnigCodePoint CR_Age_4_0[] = {
+ 412,
+ 0x0000, 0x0236,
+ 0x0250, 0x0357,
+ 0x035d, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037a,
+ 0x037e, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x03fb,
+ 0x0400, 0x0486,
+ 0x0488, 0x04ce,
+ 0x04d0, 0x04f5,
+ 0x04f8, 0x04f9,
+ 0x0500, 0x050f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05a1,
+ 0x05a3, 0x05b9,
+ 0x05bb, 0x05c4,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x060c, 0x0615,
+ 0x061b, 0x061b,
+ 0x061f, 0x061f,
+ 0x0621, 0x063a,
+ 0x0640, 0x0658,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x074f,
+ 0x0780, 0x07b1,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x0981, 0x0983,
+ 0x0985, 0x098c,
+ 0x098f, 0x0990,
+ 0x0993, 0x09a8,
+ 0x09aa, 0x09b0,
+ 0x09b2, 0x09b2,
+ 0x09b6, 0x09b9,
+ 0x09bc, 0x09c4,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cd,
+ 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, 0x0bb5,
+ 0x0bb7, 0x0bb9,
+ 0x0bbe, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0be7, 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, 0x0fcf,
+ 0x1000, 0x1021,
+ 0x1023, 0x1027,
+ 0x1029, 0x102a,
+ 0x102c, 0x1032,
+ 0x1036, 0x1039,
+ 0x1040, 0x1059,
+ 0x10a0, 0x10c5,
+ 0x10d0, 0x10f8,
+ 0x10fb, 0x10fb,
+ 0x1100, 0x1159,
+ 0x115f, 0x11a2,
+ 0x11a8, 0x11f9,
+ 0x1200, 0x1206,
+ 0x1208, 0x1246,
+ 0x1248, 0x1248,
+ 0x124a, 0x124d,
+ 0x1250, 0x1256,
+ 0x1258, 0x1258,
+ 0x125a, 0x125d,
+ 0x1260, 0x1286,
+ 0x1288, 0x1288,
+ 0x128a, 0x128d,
+ 0x1290, 0x12ae,
+ 0x12b0, 0x12b0,
+ 0x12b2, 0x12b5,
+ 0x12b8, 0x12be,
+ 0x12c0, 0x12c0,
+ 0x12c2, 0x12c5,
+ 0x12c8, 0x12ce,
+ 0x12d0, 0x12d6,
+ 0x12d8, 0x12ee,
+ 0x12f0, 0x130e,
+ 0x1310, 0x1310,
+ 0x1312, 0x1315,
+ 0x1318, 0x131e,
+ 0x1320, 0x1346,
+ 0x1348, 0x135a,
+ 0x1361, 0x137c,
+ 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,
+ 0x19e0, 0x19ff,
+ 0x1d00, 0x1d6b,
+ 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, 0x2054,
+ 0x2057, 0x2057,
+ 0x205f, 0x2063,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x20a0, 0x20b1,
+ 0x20d0, 0x20ea,
+ 0x2100, 0x213b,
+ 0x213d, 0x214b,
+ 0x2153, 0x2183,
+ 0x2190, 0x23d0,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2617,
+ 0x2619, 0x267d,
+ 0x2680, 0x2691,
+ 0x26a0, 0x26a1,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2b0d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312c,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x327d,
+ 0x327f, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fa5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xac00, 0xd7a3,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6a,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe0f,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1013f,
+ 0x10300, 0x1031e,
+ 0x10320, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x1039f,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x1083f,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 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, 0x1d6a3,
+ 0x1d6a8, 0x1d7c9,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_4_0 */
+
+/* 'Age_4_1': Derived Age 4.1 */
+static const OnigCodePoint CR_Age_4_1[] = {
+ 430,
+ 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,
+ 0xfdd0, 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, 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,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_4_1 */
+
+/* 'Age_5_0': Derived Age 5.0 */
+static const OnigCodePoint CR_Age_5_0[] = {
+ 440,
+ 0x0000, 0x036f,
+ 0x0374, 0x0375,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x03ce,
+ 0x03d0, 0x0486,
+ 0x0488, 0x0513,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 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,
+ 0x07c0, 0x07fa,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0970,
+ 0x097b, 0x097f,
+ 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, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 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,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1d00, 0x1dca,
+ 0x1dfe, 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, 0x20ef,
+ 0x2100, 0x214e,
+ 0x2153, 0x2184,
+ 0x2190, 0x23e7,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x269c,
+ 0x26a0, 0x26b2,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27d0, 0x27eb,
+ 0x27f0, 0x2b1a,
+ 0x2b20, 0x2b23,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c6c,
+ 0x2c74, 0x2c77,
+ 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, 0xa71a,
+ 0xa720, 0xa721,
+ 0xa800, 0xa82b,
+ 0xa840, 0xa877,
+ 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,
+ 0xfdd0, 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, 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,
+ 0x10900, 0x10919,
+ 0x1091f, 0x1091f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d12a, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_0 */
+
+/* 'Age_5_1': Derived Age 5.1 */
+static const OnigCodePoint CR_Age_5_1[] = {
+ 455,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0523,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0901, 0x0939,
+ 0x093c, 0x094d,
+ 0x0950, 0x0954,
+ 0x0958, 0x0972,
+ 0x097b, 0x097f,
+ 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,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0f6c,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd4,
+ 0x1000, 0x1099,
+ 0x109e, 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, 0x18aa,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19a9,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19d9,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a1f,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1d00, 0x1de6,
+ 0x1dfe, 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, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b5,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x214f,
+ 0x2153, 0x2188,
+ 0x2190, 0x23e7,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x269d,
+ 0x26a0, 0x26bc,
+ 0x26c0, 0x26c3,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x2756,
+ 0x2758, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27d0, 0x2b4c,
+ 0x2b50, 0x2b54,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2c6f,
+ 0x2c71, 0x2c7d,
+ 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,
+ 0x2de0, 0x2e30,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x3243,
+ 0x3250, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fc3,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa500, 0xa62b,
+ 0xa640, 0xa65f,
+ 0xa662, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa700, 0xa78c,
+ 0xa7fb, 0xa82b,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa95f,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa5f,
+ 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,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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,
+ 0x10900, 0x10919,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1fffe, 0x2a6d6,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_1 */
+
+/* 'Age_5_2': Derived Age 5.2 */
+static const OnigCodePoint CR_Age_5_2[] = {
+ 495,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0525,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x061f,
+ 0x0621, 0x065e,
+ 0x0660, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0900, 0x0939,
+ 0x093c, 0x094e,
+ 0x0950, 0x0955,
+ 0x0958, 0x0972,
+ 0x0979, 0x097f,
+ 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d28,
+ 0x0d2a, 0x0d39,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0f6c,
+ 0x0f71, 0x0f8b,
+ 0x0f90, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fd8,
+ 0x1000, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 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,
+ 0x1400, 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1c00, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cd0, 0x1cf2,
+ 0x1d00, 0x1de6,
+ 0x1dfd, 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, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x2094,
+ 0x20a0, 0x20b8,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23e8,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26cd,
+ 0x26cf, 0x26e1,
+ 0x26e3, 0x26e3,
+ 0x26e8, 0x26ff,
+ 0x2701, 0x2704,
+ 0x2706, 0x2709,
+ 0x270c, 0x2727,
+ 0x2729, 0x274b,
+ 0x274d, 0x274d,
+ 0x274f, 0x2752,
+ 0x2756, 0x275e,
+ 0x2761, 0x2794,
+ 0x2798, 0x27af,
+ 0x27b1, 0x27be,
+ 0x27c0, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27d0, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf1,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d6f,
+ 0x2d80, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e31,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31b7,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa65f,
+ 0xa662, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa6a0, 0xa6f7,
+ 0xa700, 0xa78c,
+ 0xa7fb, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbb1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11080, 0x110c1,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f131, 0x1f131,
+ 0x1f13d, 0x1f13d,
+ 0x1f13f, 0x1f13f,
+ 0x1f142, 0x1f142,
+ 0x1f146, 0x1f146,
+ 0x1f14a, 0x1f14e,
+ 0x1f157, 0x1f157,
+ 0x1f15f, 0x1f15f,
+ 0x1f179, 0x1f179,
+ 0x1f17b, 0x1f17c,
+ 0x1f17f, 0x1f17f,
+ 0x1f18a, 0x1f18d,
+ 0x1f190, 0x1f190,
+ 0x1f200, 0x1f200,
+ 0x1f210, 0x1f231,
+ 0x1f240, 0x1f248,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_5_2 */
+
+/* 'Age_6_0': Derived Age 6.0 */
+static const OnigCodePoint CR_Age_6_0[] = {
+ 511,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0603,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10d0, 0x10fc,
+ 0x1100, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1baa,
+ 0x1bae, 0x1bb9,
+ 0x1bc0, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cd0, 0x1cf2,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 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, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20b9,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x27ca,
+ 0x27cc, 0x27cc,
+ 0x27ce, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf1,
+ 0x2cf9, 0x2d25,
+ 0x2d30, 0x2d65,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e31,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcb,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa673,
+ 0xa67c, 0xa697,
+ 0xa6a0, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa791,
+ 0xa7a0, 0xa7a9,
+ 0xa7fa, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaadf,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa2d,
+ 0xfa30, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f169,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f5ff,
+ 0x1f601, 0x1f610,
+ 0x1f612, 0x1f614,
+ 0x1f616, 0x1f616,
+ 0x1f618, 0x1f618,
+ 0x1f61a, 0x1f61a,
+ 0x1f61c, 0x1f61e,
+ 0x1f620, 0x1f625,
+ 0x1f628, 0x1f62b,
+ 0x1f62d, 0x1f62d,
+ 0x1f630, 0x1f633,
+ 0x1f635, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_0 */
+
+/* 'Age_6_1': Derived Age 6.1 */
+static const OnigCodePoint CR_Age_6_1[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 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, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20b9,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_1 */
+
+/* 'Age_6_2': Derived Age 6.2 */
+static const OnigCodePoint CR_Age_6_2[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061b,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 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, 0x2064,
+ 0x206a, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20ba,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_2 */
+
+/* 'Age_6_3': Derived Age 6.3 */
+static const OnigCodePoint CR_Age_6_3[] = {
+ 549,
+ 0x0000, 0x0377,
+ 0x037a, 0x037e,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x0527,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058f, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x0604,
+ 0x0606, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08a0,
+ 0x08a2, 0x08ac,
+ 0x08e4, 0x08fe,
+ 0x0900, 0x0977,
+ 0x0979, 0x097f,
+ 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c01, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c33,
+ 0x0c35, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c82, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d02, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191c,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1d00, 0x1de6,
+ 0x1dfc, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20ba,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23f3,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x26ff,
+ 0x2701, 0x2b4c,
+ 0x2b50, 0x2b59,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e3b,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa697,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa793,
+ 0xa7a0, 0xa7aa,
+ 0xa7f8, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9df,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaa7b,
+ 0xaa80, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe26,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018a,
+ 0x10190, 0x1019b,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 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, 0x10855,
+ 0x10857, 0x1085f,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a7f,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b7f,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x11080, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11180, 0x111c8,
+ 0x111d0, 0x111d9,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x12000, 0x1236e,
+ 0x12400, 0x12462,
+ 0x12470, 0x12473,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0be,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0df,
+ 0x1f100, 0x1f10a,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f320,
+ 0x1f330, 0x1f335,
+ 0x1f337, 0x1f37c,
+ 0x1f380, 0x1f393,
+ 0x1f3a0, 0x1f3c4,
+ 0x1f3c6, 0x1f3ca,
+ 0x1f3e0, 0x1f3f0,
+ 0x1f400, 0x1f43e,
+ 0x1f440, 0x1f440,
+ 0x1f442, 0x1f4f7,
+ 0x1f4f9, 0x1f4fc,
+ 0x1f500, 0x1f53d,
+ 0x1f540, 0x1f543,
+ 0x1f550, 0x1f567,
+ 0x1f5fb, 0x1f640,
+ 0x1f645, 0x1f64f,
+ 0x1f680, 0x1f6c5,
+ 0x1f700, 0x1f773,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_6_3 */
+
+/* 'Age_7_0': Derived Age 7.0 */
+static const OnigCodePoint CR_Age_7_0[] = {
+ 610,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b2,
+ 0x08e4, 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c59,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c81, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d60, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f4,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfc, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bd,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x2189,
+ 0x2190, 0x23fa,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e42,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fcc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa69d,
+ 0xa69f, 0xa6f7,
+ 0xa700, 0xa78e,
+ 0xa790, 0xa7ad,
+ 0xa7b0, 0xa7b1,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fb,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab5f,
+ 0xab64, 0xab65,
+ 0xabc0, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 0xfe2d,
+ 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018c,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x10900, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109be, 0x109bf,
+ 0x10a00, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111c8,
+ 0x111cd, 0x111cd,
+ 0x111d0, 0x111da,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123d,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11301, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115c9,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x12000, 0x12398,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x13000, 0x1342e,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1dd,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1d7ff,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f32c,
+ 0x1f330, 0x1f37d,
+ 0x1f380, 0x1f3ce,
+ 0x1f3d4, 0x1f3f7,
+ 0x1f400, 0x1f4fe,
+ 0x1f500, 0x1f54a,
+ 0x1f550, 0x1f579,
+ 0x1f57b, 0x1f5a3,
+ 0x1f5a5, 0x1f642,
+ 0x1f645, 0x1f6cf,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f3,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_7_0 */
+
+/* 'Age_8_0': Derived Age 8.0 */
+static const OnigCodePoint CR_Age_8_0[] = {
+ 623,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b4,
+ 0x08e3, 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c7f,
+ 0x0c81, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4e,
+ 0x0d57, 0x0d57,
+ 0x0d5f, 0x0d63,
+ 0x0d66, 0x0d75,
+ 0x0d79, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c7f,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfc, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20be,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x23fa,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e42,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fd5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ad,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c4,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018c,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123d,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f19a,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23a,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f579,
+ 0x1f57b, 0x1f5a3,
+ 0x1f5a5, 0x1f6d0,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f3,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f910, 0x1f918,
+ 0x1f980, 0x1f984,
+ 0x1f9c0, 0x1f9c0,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_8_0 */
+
+/* 'Age_9_0': Derived Age 9.0 */
+static const OnigCodePoint CR_Age_9_0[] = {
+ 648,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 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, 0x09fb,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0af9, 0x0af9,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d01, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d3a,
+ 0x0d3d, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf6,
+ 0x1cf8, 0x1cf9,
+ 0x1d00, 0x1df5,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20be,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x23fe,
+ 0x2400, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd1,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e44,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312d,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fd5,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x10330, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe0,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b001,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f300, 0x1f6d2,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f6,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f910, 0x1f91e,
+ 0x1f920, 0x1f927,
+ 0x1f930, 0x1f930,
+ 0x1f933, 0x1f93e,
+ 0x1f940, 0x1f94b,
+ 0x1f950, 0x1f95e,
+ 0x1f980, 0x1f991,
+ 0x1f9c0, 0x1f9c0,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_9_0 */
+
+/* 'Age_10_0': Derived Age 10.0 */
+static const OnigCodePoint CR_Age_10_0[] = {
+ 659,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x055f,
+ 0x0561, 0x0587,
+ 0x0589, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05f0, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x0800, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d4, 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, 0x09fd,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a75,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c03,
+ 0x0c05, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c83,
+ 0x0c85, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1cc0, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bb9,
+ 0x2bbd, 0x2bc8,
+ 0x2bca, 0x2bd2,
+ 0x2bec, 0x2bef,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e49,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312e,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fea,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ae,
+ 0xa7b0, 0xa7b7,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa8fd,
+ 0xa900, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a33,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a47,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10cff,
+ 0x10e60, 0x10e7e,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11143,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133c, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145d,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x11719,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11a9c,
+ 0x11a9e, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187ec,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d371,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f12e,
+ 0x1f130, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f8,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d4,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f94c,
+ 0x1f950, 0x1f96b,
+ 0x1f980, 0x1f997,
+ 0x1f9c0, 0x1f9c0,
+ 0x1f9d0, 0x1f9e6,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_10_0 */
+
+/* 'Age_11_0': Derived Age 11.0 */
+static const OnigCodePoint CR_Age_11_0[] = {
+ 668,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d3, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c78, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 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, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cf9,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2bc8,
+ 0x2bca, 0x2bfe,
+ 0x2c00, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e4e,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fef,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7b9,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab65,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11146,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145e,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b7,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11a83,
+ 0x11a86, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f44,
+ 0x16f50, 0x16f7e,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe1,
+ 0x17000, 0x187f1,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94a,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f16b,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d4,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6f9,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d8,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f910, 0x1f93e,
+ 0x1f940, 0x1f970,
+ 0x1f973, 0x1f976,
+ 0x1f97a, 0x1f97a,
+ 0x1f97c, 0x1f9a2,
+ 0x1f9b0, 0x1f9b9,
+ 0x1f9c0, 0x1f9c2,
+ 0x1f9d0, 0x1f9ff,
+ 0x1fa60, 0x1fa6d,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_11_0 */
+
+/* 'Age_12_0': Derived Age 12.0 */
+static const OnigCodePoint CR_Age_12_0[] = {
+ 677,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d3, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e4f,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x32fe,
+ 0x3300, 0x4db5,
+ 0x4dc0, 0x9fef,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7bf,
+ 0xa7c2, 0xa7c6,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab67,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11146,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145f,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x13430, 0x13438,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe3,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b150, 0x1b152,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f16c,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d5,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6fa,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d8,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f90d, 0x1f971,
+ 0x1f973, 0x1f976,
+ 0x1f97a, 0x1f9a2,
+ 0x1f9a5, 0x1f9aa,
+ 0x1f9ae, 0x1f9ca,
+ 0x1f9cd, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa73,
+ 0x1fa78, 0x1fa7a,
+ 0x1fa80, 0x1fa82,
+ 0x1fa90, 0x1fa95,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_12_0 */
+
+/* 'Age_12_1': Derived Age 12.1 */
+static const OnigCodePoint CR_Age_12_1[] = {
+ 676,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08bd,
+ 0x08d3, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b56, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d03,
+ 0x0d05, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d82, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1abe,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b98, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e4f,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31ba,
+ 0x31c0, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x4db5,
+ 0x4dc0, 0x9fef,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7bf,
+ 0xa7c2, 0xa7c6,
+ 0xa7f7, 0xa82b,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab67,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019b,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11146,
+ 0x11150, 0x11176,
+ 0x11180, 0x111cd,
+ 0x111d0, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x11459,
+ 0x1145b, 0x1145b,
+ 0x1145d, 0x1145f,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x118ff,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x13430, 0x13438,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe3,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18af2,
+ 0x1b000, 0x1b11e,
+ 0x1b150, 0x1b152,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f10c,
+ 0x1f110, 0x1f16c,
+ 0x1f170, 0x1f1ac,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d5,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6fa,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d8,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f900, 0x1f90b,
+ 0x1f90d, 0x1f971,
+ 0x1f973, 0x1f976,
+ 0x1f97a, 0x1f9a2,
+ 0x1f9a5, 0x1f9aa,
+ 0x1f9ae, 0x1f9ca,
+ 0x1f9cd, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa73,
+ 0x1fa78, 0x1fa7a,
+ 0x1fa80, 0x1fa82,
+ 0x1fa90, 0x1fa95,
+ 0x1fffe, 0x2a6d6,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x2ffff,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_12_1 */
+
+/* 'Age_13_0': Derived Age 13.0 */
+static const OnigCodePoint CR_Age_13_0[] = {
+ 686,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x061c,
+ 0x061e, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x08a0, 0x08b4,
+ 0x08b6, 0x08c7,
+ 0x08d3, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3d, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cde, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 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, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1ac0,
+ 0x1b00, 0x1b4b,
+ 0x1b50, 0x1b7c,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 0x1df9,
+ 0x1dfb, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20bf,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b97, 0x2c2e,
+ 0x2c30, 0x2c5e,
+ 0x2c60, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e52,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0x9ffc,
+ 0xa000, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7bf,
+ 0xa7c2, 0xa7ca,
+ 0xa7f5, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc1,
+ 0xfbd3, 0xfd3f,
+ 0xfd50, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdd0, 0xfdfd,
+ 0xfe00, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1056f,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x1106f,
+ 0x1107f, 0x110c1,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b8,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x1173f,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ac0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x13000, 0x1342e,
+ 0x13430, 0x13438,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16a6f,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18cd5,
+ 0x18d00, 0x18d08,
+ 0x1b000, 0x1b11e,
+ 0x1b150, 0x1b152,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1e8,
+ 0x1d200, 0x1d245,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d7,
+ 0x1f6e0, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d8,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8b1,
+ 0x1f900, 0x1f978,
+ 0x1f97a, 0x1f9cb,
+ 0x1f9cd, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa74,
+ 0x1fa78, 0x1fa7a,
+ 0x1fa80, 0x1fa86,
+ 0x1fa90, 0x1faa8,
+ 0x1fab0, 0x1fab6,
+ 0x1fac0, 0x1fac2,
+ 0x1fad0, 0x1fad6,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbca,
+ 0x1fbf0, 0x1fbf9,
+ 0x1fffe, 0x2a6dd,
+ 0x2a700, 0x2b734,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_13_0 */
+
+/* 'Age_14_0': Derived Age 14.0 */
+static const OnigCodePoint CR_Age_14_0[] = {
+ 706,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x088e,
+ 0x0890, 0x0891,
+ 0x0898, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5d, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdd, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf2,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ecd,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1ace,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b7e,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c0,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b97, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ca,
+ 0xa7d0, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d9,
+ 0xa7f2, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc2,
+ 0xfbd3, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdcf, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10f00, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x1123e,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x1342e,
+ 0x13430, 0x13438,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18cd5,
+ 0x18d00, 0x18d08,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b150, 0x1b152,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d7,
+ 0x1f6dd, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f773,
+ 0x1f780, 0x1f7d8,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8b1,
+ 0x1f900, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa74,
+ 0x1fa78, 0x1fa7c,
+ 0x1fa80, 0x1fa86,
+ 0x1fa90, 0x1faac,
+ 0x1fab0, 0x1faba,
+ 0x1fac0, 0x1fac5,
+ 0x1fad0, 0x1fad9,
+ 0x1fae0, 0x1fae7,
+ 0x1faf0, 0x1faf6,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbca,
+ 0x1fbf0, 0x1fbf9,
+ 0x1fffe, 0x2a6df,
+ 0x2a700, 0x2b738,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_14_0 */
+
+/* 'Age_15_0': Derived Age 15.0 */
+static const OnigCodePoint CR_Age_15_0[] = {
+ 715,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x088e,
+ 0x0890, 0x0891,
+ 0x0898, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5d, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdd, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1ace,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b7e,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c0,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b97, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x2ffb,
+ 0x3000, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e3,
+ 0x31f0, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ca,
+ 0xa7d0, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d9,
+ 0xa7f2, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc2,
+ 0xfbd3, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdcf, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10efd, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f59,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18cd5,
+ 0x18d00, 0x18d08,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d7,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f776,
+ 0x1f77b, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8b1,
+ 0x1f900, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa88,
+ 0x1fa90, 0x1fabd,
+ 0x1fabf, 0x1fac5,
+ 0x1face, 0x1fadb,
+ 0x1fae0, 0x1fae8,
+ 0x1faf0, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbca,
+ 0x1fbf0, 0x1fbf9,
+ 0x1fffe, 0x2a6df,
+ 0x2a700, 0x2b739,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x31350, 0x323af,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_15_0 */
+
+/* 'Age_15_1': Derived Age 15.1 */
+static const OnigCodePoint CR_Age_15_1[] = {
+ 715,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x088e,
+ 0x0890, 0x0891,
+ 0x0898, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5d, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdd, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1ace,
+ 0x1b00, 0x1b4c,
+ 0x1b50, 0x1b7e,
+ 0x1b80, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c88,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c0,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2426,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b97, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e3,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7ca,
+ 0xa7d0, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7d9,
+ 0xa7f2, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc2,
+ 0xfbd3, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdcf, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10efd, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f59,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x14400, 0x14646,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18cd5,
+ 0x18d00, 0x18d08,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d7,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f776,
+ 0x1f77b, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8b1,
+ 0x1f900, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa88,
+ 0x1fa90, 0x1fabd,
+ 0x1fabf, 0x1fac5,
+ 0x1face, 0x1fadb,
+ 0x1fae0, 0x1fae8,
+ 0x1faf0, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbca,
+ 0x1fbf0, 0x1fbf9,
+ 0x1fffe, 0x2a6df,
+ 0x2a700, 0x2b739,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x31350, 0x323af,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_15_1 */
+
+/* 'Age_16_0': Derived Age 16.0 */
+static const OnigCodePoint CR_Age_16_0[] = {
+ 739,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x088e,
+ 0x0890, 0x0891,
+ 0x0897, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5d, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdd, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1ace,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c0,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2b95,
+ 0x2b97, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7cd,
+ 0xa7d0, 0xa7d1,
+ 0xa7d3, 0xa7d3,
+ 0xa7d5, 0xa7dc,
+ 0xa7f2, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfbc2,
+ 0xfbd3, 0xfd8f,
+ 0xfd92, 0xfdc7,
+ 0xfdcf, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x1093f,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec4,
+ 0x10efc, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x17000, 0x187f7,
+ 0x18800, 0x18cd5,
+ 0x18cff, 0x18d08,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cc00, 0x1ccf9,
+ 0x1cd00, 0x1ceb3,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d7,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f776,
+ 0x1f77b, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f900, 0x1fa53,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa89,
+ 0x1fa8f, 0x1fac6,
+ 0x1face, 0x1fadc,
+ 0x1fadf, 0x1fae9,
+ 0x1faf0, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbf9,
+ 0x1fffe, 0x2a6df,
+ 0x2a700, 0x2b739,
+ 0x2b740, 0x2b81d,
+ 0x2b820, 0x2cea1,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x31350, 0x323af,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_16_0 */
+
+/* 'Age_17_0': Derived Age 17.0 */
+static const OnigCodePoint CR_Age_17_0[] = {
+ 743,
+ 0x0000, 0x0377,
+ 0x037a, 0x037f,
+ 0x0384, 0x038a,
+ 0x038c, 0x038c,
+ 0x038e, 0x03a1,
+ 0x03a3, 0x052f,
+ 0x0531, 0x0556,
+ 0x0559, 0x058a,
+ 0x058d, 0x058f,
+ 0x0591, 0x05c7,
+ 0x05d0, 0x05ea,
+ 0x05ef, 0x05f4,
+ 0x0600, 0x070d,
+ 0x070f, 0x074a,
+ 0x074d, 0x07b1,
+ 0x07c0, 0x07fa,
+ 0x07fd, 0x082d,
+ 0x0830, 0x083e,
+ 0x0840, 0x085b,
+ 0x085e, 0x085e,
+ 0x0860, 0x086a,
+ 0x0870, 0x0891,
+ 0x0897, 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, 0x09fe,
+ 0x0a01, 0x0a03,
+ 0x0a05, 0x0a0a,
+ 0x0a0f, 0x0a10,
+ 0x0a13, 0x0a28,
+ 0x0a2a, 0x0a30,
+ 0x0a32, 0x0a33,
+ 0x0a35, 0x0a36,
+ 0x0a38, 0x0a39,
+ 0x0a3c, 0x0a3c,
+ 0x0a3e, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a59, 0x0a5c,
+ 0x0a5e, 0x0a5e,
+ 0x0a66, 0x0a76,
+ 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, 0x0af1,
+ 0x0af9, 0x0aff,
+ 0x0b01, 0x0b03,
+ 0x0b05, 0x0b0c,
+ 0x0b0f, 0x0b10,
+ 0x0b13, 0x0b28,
+ 0x0b2a, 0x0b30,
+ 0x0b32, 0x0b33,
+ 0x0b35, 0x0b39,
+ 0x0b3c, 0x0b44,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b5c, 0x0b5d,
+ 0x0b5f, 0x0b63,
+ 0x0b66, 0x0b77,
+ 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,
+ 0x0bd0, 0x0bd0,
+ 0x0bd7, 0x0bd7,
+ 0x0be6, 0x0bfa,
+ 0x0c00, 0x0c0c,
+ 0x0c0e, 0x0c10,
+ 0x0c12, 0x0c28,
+ 0x0c2a, 0x0c39,
+ 0x0c3c, 0x0c44,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c58, 0x0c5a,
+ 0x0c5c, 0x0c5d,
+ 0x0c60, 0x0c63,
+ 0x0c66, 0x0c6f,
+ 0x0c77, 0x0c8c,
+ 0x0c8e, 0x0c90,
+ 0x0c92, 0x0ca8,
+ 0x0caa, 0x0cb3,
+ 0x0cb5, 0x0cb9,
+ 0x0cbc, 0x0cc4,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0cdc, 0x0cde,
+ 0x0ce0, 0x0ce3,
+ 0x0ce6, 0x0cef,
+ 0x0cf1, 0x0cf3,
+ 0x0d00, 0x0d0c,
+ 0x0d0e, 0x0d10,
+ 0x0d12, 0x0d44,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4f,
+ 0x0d54, 0x0d63,
+ 0x0d66, 0x0d7f,
+ 0x0d81, 0x0d83,
+ 0x0d85, 0x0d96,
+ 0x0d9a, 0x0db1,
+ 0x0db3, 0x0dbb,
+ 0x0dbd, 0x0dbd,
+ 0x0dc0, 0x0dc6,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0dd8, 0x0ddf,
+ 0x0de6, 0x0def,
+ 0x0df2, 0x0df4,
+ 0x0e01, 0x0e3a,
+ 0x0e3f, 0x0e5b,
+ 0x0e81, 0x0e82,
+ 0x0e84, 0x0e84,
+ 0x0e86, 0x0e8a,
+ 0x0e8c, 0x0ea3,
+ 0x0ea5, 0x0ea5,
+ 0x0ea7, 0x0ebd,
+ 0x0ec0, 0x0ec4,
+ 0x0ec6, 0x0ec6,
+ 0x0ec8, 0x0ece,
+ 0x0ed0, 0x0ed9,
+ 0x0edc, 0x0edf,
+ 0x0f00, 0x0f47,
+ 0x0f49, 0x0f6c,
+ 0x0f71, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fbe, 0x0fcc,
+ 0x0fce, 0x0fda,
+ 0x1000, 0x10c5,
+ 0x10c7, 0x10c7,
+ 0x10cd, 0x10cd,
+ 0x10d0, 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,
+ 0x135d, 0x137c,
+ 0x1380, 0x1399,
+ 0x13a0, 0x13f5,
+ 0x13f8, 0x13fd,
+ 0x1400, 0x169c,
+ 0x16a0, 0x16f8,
+ 0x1700, 0x1715,
+ 0x171f, 0x1736,
+ 0x1740, 0x1753,
+ 0x1760, 0x176c,
+ 0x176e, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17dd,
+ 0x17e0, 0x17e9,
+ 0x17f0, 0x17f9,
+ 0x1800, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18aa,
+ 0x18b0, 0x18f5,
+ 0x1900, 0x191e,
+ 0x1920, 0x192b,
+ 0x1930, 0x193b,
+ 0x1940, 0x1940,
+ 0x1944, 0x196d,
+ 0x1970, 0x1974,
+ 0x1980, 0x19ab,
+ 0x19b0, 0x19c9,
+ 0x19d0, 0x19da,
+ 0x19de, 0x1a1b,
+ 0x1a1e, 0x1a5e,
+ 0x1a60, 0x1a7c,
+ 0x1a7f, 0x1a89,
+ 0x1a90, 0x1a99,
+ 0x1aa0, 0x1aad,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b4c,
+ 0x1b4e, 0x1bf3,
+ 0x1bfc, 0x1c37,
+ 0x1c3b, 0x1c49,
+ 0x1c4d, 0x1c8a,
+ 0x1c90, 0x1cba,
+ 0x1cbd, 0x1cc7,
+ 0x1cd0, 0x1cfa,
+ 0x1d00, 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, 0x2064,
+ 0x2066, 0x2071,
+ 0x2074, 0x208e,
+ 0x2090, 0x209c,
+ 0x20a0, 0x20c1,
+ 0x20d0, 0x20f0,
+ 0x2100, 0x218b,
+ 0x2190, 0x2429,
+ 0x2440, 0x244a,
+ 0x2460, 0x2b73,
+ 0x2b76, 0x2cf3,
+ 0x2cf9, 0x2d25,
+ 0x2d27, 0x2d27,
+ 0x2d2d, 0x2d2d,
+ 0x2d30, 0x2d67,
+ 0x2d6f, 0x2d70,
+ 0x2d7f, 0x2d96,
+ 0x2da0, 0x2da6,
+ 0x2da8, 0x2dae,
+ 0x2db0, 0x2db6,
+ 0x2db8, 0x2dbe,
+ 0x2dc0, 0x2dc6,
+ 0x2dc8, 0x2dce,
+ 0x2dd0, 0x2dd6,
+ 0x2dd8, 0x2dde,
+ 0x2de0, 0x2e5d,
+ 0x2e80, 0x2e99,
+ 0x2e9b, 0x2ef3,
+ 0x2f00, 0x2fd5,
+ 0x2ff0, 0x303f,
+ 0x3041, 0x3096,
+ 0x3099, 0x30ff,
+ 0x3105, 0x312f,
+ 0x3131, 0x318e,
+ 0x3190, 0x31e5,
+ 0x31ef, 0x321e,
+ 0x3220, 0xa48c,
+ 0xa490, 0xa4c6,
+ 0xa4d0, 0xa62b,
+ 0xa640, 0xa6f7,
+ 0xa700, 0xa7dc,
+ 0xa7f1, 0xa82c,
+ 0xa830, 0xa839,
+ 0xa840, 0xa877,
+ 0xa880, 0xa8c5,
+ 0xa8ce, 0xa8d9,
+ 0xa8e0, 0xa953,
+ 0xa95f, 0xa97c,
+ 0xa980, 0xa9cd,
+ 0xa9cf, 0xa9d9,
+ 0xa9de, 0xa9fe,
+ 0xaa00, 0xaa36,
+ 0xaa40, 0xaa4d,
+ 0xaa50, 0xaa59,
+ 0xaa5c, 0xaac2,
+ 0xaadb, 0xaaf6,
+ 0xab01, 0xab06,
+ 0xab09, 0xab0e,
+ 0xab11, 0xab16,
+ 0xab20, 0xab26,
+ 0xab28, 0xab2e,
+ 0xab30, 0xab6b,
+ 0xab70, 0xabed,
+ 0xabf0, 0xabf9,
+ 0xac00, 0xd7a3,
+ 0xd7b0, 0xd7c6,
+ 0xd7cb, 0xd7fb,
+ 0xd800, 0xfa6d,
+ 0xfa70, 0xfad9,
+ 0xfb00, 0xfb06,
+ 0xfb13, 0xfb17,
+ 0xfb1d, 0xfb36,
+ 0xfb38, 0xfb3c,
+ 0xfb3e, 0xfb3e,
+ 0xfb40, 0xfb41,
+ 0xfb43, 0xfb44,
+ 0xfb46, 0xfe19,
+ 0xfe20, 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, 0x1000b,
+ 0x1000d, 0x10026,
+ 0x10028, 0x1003a,
+ 0x1003c, 0x1003d,
+ 0x1003f, 0x1004d,
+ 0x10050, 0x1005d,
+ 0x10080, 0x100fa,
+ 0x10100, 0x10102,
+ 0x10107, 0x10133,
+ 0x10137, 0x1018e,
+ 0x10190, 0x1019c,
+ 0x101a0, 0x101a0,
+ 0x101d0, 0x101fd,
+ 0x10280, 0x1029c,
+ 0x102a0, 0x102d0,
+ 0x102e0, 0x102fb,
+ 0x10300, 0x10323,
+ 0x1032d, 0x1034a,
+ 0x10350, 0x1037a,
+ 0x10380, 0x1039d,
+ 0x1039f, 0x103c3,
+ 0x103c8, 0x103d5,
+ 0x10400, 0x1049d,
+ 0x104a0, 0x104a9,
+ 0x104b0, 0x104d3,
+ 0x104d8, 0x104fb,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x1056f, 0x1057a,
+ 0x1057c, 0x1058a,
+ 0x1058c, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105a1,
+ 0x105a3, 0x105b1,
+ 0x105b3, 0x105b9,
+ 0x105bb, 0x105bc,
+ 0x105c0, 0x105f3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107b0,
+ 0x107b2, 0x107ba,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080a, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083c, 0x1083c,
+ 0x1083f, 0x10855,
+ 0x10857, 0x1089e,
+ 0x108a7, 0x108af,
+ 0x108e0, 0x108f2,
+ 0x108f4, 0x108f5,
+ 0x108fb, 0x1091b,
+ 0x1091f, 0x10939,
+ 0x1093f, 0x10959,
+ 0x10980, 0x109b7,
+ 0x109bc, 0x109cf,
+ 0x109d2, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a13,
+ 0x10a15, 0x10a17,
+ 0x10a19, 0x10a35,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a48,
+ 0x10a50, 0x10a58,
+ 0x10a60, 0x10a9f,
+ 0x10ac0, 0x10ae6,
+ 0x10aeb, 0x10af6,
+ 0x10b00, 0x10b35,
+ 0x10b39, 0x10b55,
+ 0x10b58, 0x10b72,
+ 0x10b78, 0x10b91,
+ 0x10b99, 0x10b9c,
+ 0x10ba9, 0x10baf,
+ 0x10c00, 0x10c48,
+ 0x10c80, 0x10cb2,
+ 0x10cc0, 0x10cf2,
+ 0x10cfa, 0x10d27,
+ 0x10d30, 0x10d39,
+ 0x10d40, 0x10d65,
+ 0x10d69, 0x10d85,
+ 0x10d8e, 0x10d8f,
+ 0x10e60, 0x10e7e,
+ 0x10e80, 0x10ea9,
+ 0x10eab, 0x10ead,
+ 0x10eb0, 0x10eb1,
+ 0x10ec2, 0x10ec7,
+ 0x10ed0, 0x10ed8,
+ 0x10efa, 0x10f27,
+ 0x10f30, 0x10f59,
+ 0x10f70, 0x10f89,
+ 0x10fb0, 0x10fcb,
+ 0x10fe0, 0x10ff6,
+ 0x11000, 0x1104d,
+ 0x11052, 0x11075,
+ 0x1107f, 0x110c2,
+ 0x110cd, 0x110cd,
+ 0x110d0, 0x110e8,
+ 0x110f0, 0x110f9,
+ 0x11100, 0x11134,
+ 0x11136, 0x11147,
+ 0x11150, 0x11176,
+ 0x11180, 0x111df,
+ 0x111e1, 0x111f4,
+ 0x11200, 0x11211,
+ 0x11213, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128a, 0x1128d,
+ 0x1128f, 0x1129d,
+ 0x1129f, 0x112a9,
+ 0x112b0, 0x112ea,
+ 0x112f0, 0x112f9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130c,
+ 0x1130f, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132a, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133b, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134d,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135d, 0x11363,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x11380, 0x11389,
+ 0x1138b, 0x1138b,
+ 0x1138e, 0x1138e,
+ 0x11390, 0x113b5,
+ 0x113b7, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113ca,
+ 0x113cc, 0x113d5,
+ 0x113d7, 0x113d8,
+ 0x113e1, 0x113e2,
+ 0x11400, 0x1145b,
+ 0x1145d, 0x11461,
+ 0x11480, 0x114c7,
+ 0x114d0, 0x114d9,
+ 0x11580, 0x115b5,
+ 0x115b8, 0x115dd,
+ 0x11600, 0x11644,
+ 0x11650, 0x11659,
+ 0x11660, 0x1166c,
+ 0x11680, 0x116b9,
+ 0x116c0, 0x116c9,
+ 0x116d0, 0x116e3,
+ 0x11700, 0x1171a,
+ 0x1171d, 0x1172b,
+ 0x11730, 0x11746,
+ 0x11800, 0x1183b,
+ 0x118a0, 0x118f2,
+ 0x118ff, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190c, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193b, 0x11946,
+ 0x11950, 0x11959,
+ 0x119a0, 0x119a7,
+ 0x119aa, 0x119d7,
+ 0x119da, 0x119e4,
+ 0x11a00, 0x11a47,
+ 0x11a50, 0x11aa2,
+ 0x11ab0, 0x11af8,
+ 0x11b00, 0x11b09,
+ 0x11b60, 0x11b67,
+ 0x11bc0, 0x11be1,
+ 0x11bf0, 0x11bf9,
+ 0x11c00, 0x11c08,
+ 0x11c0a, 0x11c36,
+ 0x11c38, 0x11c45,
+ 0x11c50, 0x11c6c,
+ 0x11c70, 0x11c8f,
+ 0x11c92, 0x11ca7,
+ 0x11ca9, 0x11cb6,
+ 0x11d00, 0x11d06,
+ 0x11d08, 0x11d09,
+ 0x11d0b, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d47,
+ 0x11d50, 0x11d59,
+ 0x11d60, 0x11d65,
+ 0x11d67, 0x11d68,
+ 0x11d6a, 0x11d8e,
+ 0x11d90, 0x11d91,
+ 0x11d93, 0x11d98,
+ 0x11da0, 0x11da9,
+ 0x11db0, 0x11ddb,
+ 0x11de0, 0x11de9,
+ 0x11ee0, 0x11ef8,
+ 0x11f00, 0x11f10,
+ 0x11f12, 0x11f3a,
+ 0x11f3e, 0x11f5a,
+ 0x11fb0, 0x11fb0,
+ 0x11fc0, 0x11ff1,
+ 0x11fff, 0x12399,
+ 0x12400, 0x1246e,
+ 0x12470, 0x12474,
+ 0x12480, 0x12543,
+ 0x12f90, 0x12ff2,
+ 0x13000, 0x13455,
+ 0x13460, 0x143fa,
+ 0x14400, 0x14646,
+ 0x16100, 0x16139,
+ 0x16800, 0x16a38,
+ 0x16a40, 0x16a5e,
+ 0x16a60, 0x16a69,
+ 0x16a6e, 0x16abe,
+ 0x16ac0, 0x16ac9,
+ 0x16ad0, 0x16aed,
+ 0x16af0, 0x16af5,
+ 0x16b00, 0x16b45,
+ 0x16b50, 0x16b59,
+ 0x16b5b, 0x16b61,
+ 0x16b63, 0x16b77,
+ 0x16b7d, 0x16b8f,
+ 0x16d40, 0x16d79,
+ 0x16e40, 0x16e9a,
+ 0x16ea0, 0x16eb8,
+ 0x16ebb, 0x16ed3,
+ 0x16f00, 0x16f4a,
+ 0x16f4f, 0x16f87,
+ 0x16f8f, 0x16f9f,
+ 0x16fe0, 0x16fe4,
+ 0x16ff0, 0x16ff6,
+ 0x17000, 0x18cd5,
+ 0x18cff, 0x18d1e,
+ 0x18d80, 0x18df2,
+ 0x1aff0, 0x1aff3,
+ 0x1aff5, 0x1affb,
+ 0x1affd, 0x1affe,
+ 0x1b000, 0x1b122,
+ 0x1b132, 0x1b132,
+ 0x1b150, 0x1b152,
+ 0x1b155, 0x1b155,
+ 0x1b164, 0x1b167,
+ 0x1b170, 0x1b2fb,
+ 0x1bc00, 0x1bc6a,
+ 0x1bc70, 0x1bc7c,
+ 0x1bc80, 0x1bc88,
+ 0x1bc90, 0x1bc99,
+ 0x1bc9c, 0x1bca3,
+ 0x1cc00, 0x1ccfc,
+ 0x1cd00, 0x1ceb3,
+ 0x1ceba, 0x1ced0,
+ 0x1cee0, 0x1cef0,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1cf50, 0x1cfc3,
+ 0x1d000, 0x1d0f5,
+ 0x1d100, 0x1d126,
+ 0x1d129, 0x1d1ea,
+ 0x1d200, 0x1d245,
+ 0x1d2c0, 0x1d2d3,
+ 0x1d2e0, 0x1d2f3,
+ 0x1d300, 0x1d356,
+ 0x1d360, 0x1d378,
+ 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, 0x1d7cb,
+ 0x1d7ce, 0x1da8b,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1df00, 0x1df1e,
+ 0x1df25, 0x1df2a,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e030, 0x1e06d,
+ 0x1e08f, 0x1e08f,
+ 0x1e100, 0x1e12c,
+ 0x1e130, 0x1e13d,
+ 0x1e140, 0x1e149,
+ 0x1e14e, 0x1e14f,
+ 0x1e290, 0x1e2ae,
+ 0x1e2c0, 0x1e2f9,
+ 0x1e2ff, 0x1e2ff,
+ 0x1e4d0, 0x1e4f9,
+ 0x1e5d0, 0x1e5fa,
+ 0x1e5ff, 0x1e5ff,
+ 0x1e6c0, 0x1e6de,
+ 0x1e6e0, 0x1e6f5,
+ 0x1e6fe, 0x1e6ff,
+ 0x1e7e0, 0x1e7e6,
+ 0x1e7e8, 0x1e7eb,
+ 0x1e7ed, 0x1e7ee,
+ 0x1e7f0, 0x1e7fe,
+ 0x1e800, 0x1e8c4,
+ 0x1e8c7, 0x1e8d6,
+ 0x1e900, 0x1e94b,
+ 0x1e950, 0x1e959,
+ 0x1e95e, 0x1e95f,
+ 0x1ec71, 0x1ecb4,
+ 0x1ed01, 0x1ed3d,
+ 0x1ee00, 0x1ee03,
+ 0x1ee05, 0x1ee1f,
+ 0x1ee21, 0x1ee22,
+ 0x1ee24, 0x1ee24,
+ 0x1ee27, 0x1ee27,
+ 0x1ee29, 0x1ee32,
+ 0x1ee34, 0x1ee37,
+ 0x1ee39, 0x1ee39,
+ 0x1ee3b, 0x1ee3b,
+ 0x1ee42, 0x1ee42,
+ 0x1ee47, 0x1ee47,
+ 0x1ee49, 0x1ee49,
+ 0x1ee4b, 0x1ee4b,
+ 0x1ee4d, 0x1ee4f,
+ 0x1ee51, 0x1ee52,
+ 0x1ee54, 0x1ee54,
+ 0x1ee57, 0x1ee57,
+ 0x1ee59, 0x1ee59,
+ 0x1ee5b, 0x1ee5b,
+ 0x1ee5d, 0x1ee5d,
+ 0x1ee5f, 0x1ee5f,
+ 0x1ee61, 0x1ee62,
+ 0x1ee64, 0x1ee64,
+ 0x1ee67, 0x1ee6a,
+ 0x1ee6c, 0x1ee72,
+ 0x1ee74, 0x1ee77,
+ 0x1ee79, 0x1ee7c,
+ 0x1ee7e, 0x1ee7e,
+ 0x1ee80, 0x1ee89,
+ 0x1ee8b, 0x1ee9b,
+ 0x1eea1, 0x1eea3,
+ 0x1eea5, 0x1eea9,
+ 0x1eeab, 0x1eebb,
+ 0x1eef0, 0x1eef1,
+ 0x1f000, 0x1f02b,
+ 0x1f030, 0x1f093,
+ 0x1f0a0, 0x1f0ae,
+ 0x1f0b1, 0x1f0bf,
+ 0x1f0c1, 0x1f0cf,
+ 0x1f0d1, 0x1f0f5,
+ 0x1f100, 0x1f1ad,
+ 0x1f1e6, 0x1f202,
+ 0x1f210, 0x1f23b,
+ 0x1f240, 0x1f248,
+ 0x1f250, 0x1f251,
+ 0x1f260, 0x1f265,
+ 0x1f300, 0x1f6d8,
+ 0x1f6dc, 0x1f6ec,
+ 0x1f6f0, 0x1f6fc,
+ 0x1f700, 0x1f7d9,
+ 0x1f7e0, 0x1f7eb,
+ 0x1f7f0, 0x1f7f0,
+ 0x1f800, 0x1f80b,
+ 0x1f810, 0x1f847,
+ 0x1f850, 0x1f859,
+ 0x1f860, 0x1f887,
+ 0x1f890, 0x1f8ad,
+ 0x1f8b0, 0x1f8bb,
+ 0x1f8c0, 0x1f8c1,
+ 0x1f8d0, 0x1f8d8,
+ 0x1f900, 0x1fa57,
+ 0x1fa60, 0x1fa6d,
+ 0x1fa70, 0x1fa7c,
+ 0x1fa80, 0x1fa8a,
+ 0x1fa8e, 0x1fac6,
+ 0x1fac8, 0x1fac8,
+ 0x1facd, 0x1fadc,
+ 0x1fadf, 0x1faea,
+ 0x1faef, 0x1faf8,
+ 0x1fb00, 0x1fb92,
+ 0x1fb94, 0x1fbfa,
+ 0x1fffe, 0x2a6df,
+ 0x2a700, 0x2b81d,
+ 0x2b820, 0x2cead,
+ 0x2ceb0, 0x2ebe0,
+ 0x2ebf0, 0x2ee5d,
+ 0x2f800, 0x2fa1d,
+ 0x2fffe, 0x3134a,
+ 0x31350, 0x33479,
+ 0x3fffe, 0x3ffff,
+ 0x4fffe, 0x4ffff,
+ 0x5fffe, 0x5ffff,
+ 0x6fffe, 0x6ffff,
+ 0x7fffe, 0x7ffff,
+ 0x8fffe, 0x8ffff,
+ 0x9fffe, 0x9ffff,
+ 0xafffe, 0xaffff,
+ 0xbfffe, 0xbffff,
+ 0xcfffe, 0xcffff,
+ 0xdfffe, 0xdffff,
+ 0xe0001, 0xe0001,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+ 0xefffe, 0x10ffff,
+}; /* CR_Age_17_0 */
+
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+/* 'Grapheme_Cluster_Break_Prepend': Grapheme_Cluster_Break=Prepend */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Prepend[] = {
+ 15,
+ 0x0600, 0x0605,
+ 0x06dd, 0x06dd,
+ 0x070f, 0x070f,
+ 0x0890, 0x0891,
+ 0x08e2, 0x08e2,
+ 0x0d4e, 0x0d4e,
+ 0x110bd, 0x110bd,
+ 0x110cd, 0x110cd,
+ 0x111c2, 0x111c3,
+ 0x113d1, 0x113d1,
+ 0x1193f, 0x1193f,
+ 0x11941, 0x11941,
+ 0x11a84, 0x11a89,
+ 0x11d46, 0x11d46,
+ 0x11f02, 0x11f02,
+}; /* CR_Grapheme_Cluster_Break_Prepend */
+
+/* 'Grapheme_Cluster_Break_CR': Grapheme_Cluster_Break=CR */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_CR[] = {
+ 1,
+ 0x000d, 0x000d,
+}; /* CR_Grapheme_Cluster_Break_CR */
+
+/* 'Grapheme_Cluster_Break_LF': Grapheme_Cluster_Break=LF */
+#define CR_Grapheme_Cluster_Break_LF CR_NEWLINE
+
+/* 'Grapheme_Cluster_Break_Control': Grapheme_Cluster_Break=Control */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Control[] = {
+ 19,
+ 0x0000, 0x0009,
+ 0x000b, 0x000c,
+ 0x000e, 0x001f,
+ 0x007f, 0x009f,
+ 0x00ad, 0x00ad,
+ 0x061c, 0x061c,
+ 0x180e, 0x180e,
+ 0x200b, 0x200b,
+ 0x200e, 0x200f,
+ 0x2028, 0x202e,
+ 0x2060, 0x206f,
+ 0xfeff, 0xfeff,
+ 0xfff0, 0xfffb,
+ 0x13430, 0x1343f,
+ 0x1bca0, 0x1bca3,
+ 0x1d173, 0x1d17a,
+ 0xe0000, 0xe001f,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xe0fff,
+}; /* CR_Grapheme_Cluster_Break_Control */
+
+/* 'Grapheme_Cluster_Break_Extend': Grapheme_Cluster_Break=Extend */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_Extend[] = {
+ 384,
+ 0x0300, 0x036f,
+ 0x0483, 0x0489,
+ 0x0591, 0x05bd,
+ 0x05bf, 0x05bf,
+ 0x05c1, 0x05c2,
+ 0x05c4, 0x05c5,
+ 0x05c7, 0x05c7,
+ 0x0610, 0x061a,
+ 0x064b, 0x065f,
+ 0x0670, 0x0670,
+ 0x06d6, 0x06dc,
+ 0x06df, 0x06e4,
+ 0x06e7, 0x06e8,
+ 0x06ea, 0x06ed,
+ 0x0711, 0x0711,
+ 0x0730, 0x074a,
+ 0x07a6, 0x07b0,
+ 0x07eb, 0x07f3,
+ 0x07fd, 0x07fd,
+ 0x0816, 0x0819,
+ 0x081b, 0x0823,
+ 0x0825, 0x0827,
+ 0x0829, 0x082d,
+ 0x0859, 0x085b,
+ 0x0897, 0x089f,
+ 0x08ca, 0x08e1,
+ 0x08e3, 0x0902,
+ 0x093a, 0x093a,
+ 0x093c, 0x093c,
+ 0x0941, 0x0948,
+ 0x094d, 0x094d,
+ 0x0951, 0x0957,
+ 0x0962, 0x0963,
+ 0x0981, 0x0981,
+ 0x09bc, 0x09bc,
+ 0x09be, 0x09be,
+ 0x09c1, 0x09c4,
+ 0x09cd, 0x09cd,
+ 0x09d7, 0x09d7,
+ 0x09e2, 0x09e3,
+ 0x09fe, 0x09fe,
+ 0x0a01, 0x0a02,
+ 0x0a3c, 0x0a3c,
+ 0x0a41, 0x0a42,
+ 0x0a47, 0x0a48,
+ 0x0a4b, 0x0a4d,
+ 0x0a51, 0x0a51,
+ 0x0a70, 0x0a71,
+ 0x0a75, 0x0a75,
+ 0x0a81, 0x0a82,
+ 0x0abc, 0x0abc,
+ 0x0ac1, 0x0ac5,
+ 0x0ac7, 0x0ac8,
+ 0x0acd, 0x0acd,
+ 0x0ae2, 0x0ae3,
+ 0x0afa, 0x0aff,
+ 0x0b01, 0x0b01,
+ 0x0b3c, 0x0b3c,
+ 0x0b3e, 0x0b3f,
+ 0x0b41, 0x0b44,
+ 0x0b4d, 0x0b4d,
+ 0x0b55, 0x0b57,
+ 0x0b62, 0x0b63,
+ 0x0b82, 0x0b82,
+ 0x0bbe, 0x0bbe,
+ 0x0bc0, 0x0bc0,
+ 0x0bcd, 0x0bcd,
+ 0x0bd7, 0x0bd7,
+ 0x0c00, 0x0c00,
+ 0x0c04, 0x0c04,
+ 0x0c3c, 0x0c3c,
+ 0x0c3e, 0x0c40,
+ 0x0c46, 0x0c48,
+ 0x0c4a, 0x0c4d,
+ 0x0c55, 0x0c56,
+ 0x0c62, 0x0c63,
+ 0x0c81, 0x0c81,
+ 0x0cbc, 0x0cbc,
+ 0x0cbf, 0x0cc0,
+ 0x0cc2, 0x0cc2,
+ 0x0cc6, 0x0cc8,
+ 0x0cca, 0x0ccd,
+ 0x0cd5, 0x0cd6,
+ 0x0ce2, 0x0ce3,
+ 0x0d00, 0x0d01,
+ 0x0d3b, 0x0d3c,
+ 0x0d3e, 0x0d3e,
+ 0x0d41, 0x0d44,
+ 0x0d4d, 0x0d4d,
+ 0x0d57, 0x0d57,
+ 0x0d62, 0x0d63,
+ 0x0d81, 0x0d81,
+ 0x0dca, 0x0dca,
+ 0x0dcf, 0x0dcf,
+ 0x0dd2, 0x0dd4,
+ 0x0dd6, 0x0dd6,
+ 0x0ddf, 0x0ddf,
+ 0x0e31, 0x0e31,
+ 0x0e34, 0x0e3a,
+ 0x0e47, 0x0e4e,
+ 0x0eb1, 0x0eb1,
+ 0x0eb4, 0x0ebc,
+ 0x0ec8, 0x0ece,
+ 0x0f18, 0x0f19,
+ 0x0f35, 0x0f35,
+ 0x0f37, 0x0f37,
+ 0x0f39, 0x0f39,
+ 0x0f71, 0x0f7e,
+ 0x0f80, 0x0f84,
+ 0x0f86, 0x0f87,
+ 0x0f8d, 0x0f97,
+ 0x0f99, 0x0fbc,
+ 0x0fc6, 0x0fc6,
+ 0x102d, 0x1030,
+ 0x1032, 0x1037,
+ 0x1039, 0x103a,
+ 0x103d, 0x103e,
+ 0x1058, 0x1059,
+ 0x105e, 0x1060,
+ 0x1071, 0x1074,
+ 0x1082, 0x1082,
+ 0x1085, 0x1086,
+ 0x108d, 0x108d,
+ 0x109d, 0x109d,
+ 0x135d, 0x135f,
+ 0x1712, 0x1715,
+ 0x1732, 0x1734,
+ 0x1752, 0x1753,
+ 0x1772, 0x1773,
+ 0x17b4, 0x17b5,
+ 0x17b7, 0x17bd,
+ 0x17c6, 0x17c6,
+ 0x17c9, 0x17d3,
+ 0x17dd, 0x17dd,
+ 0x180b, 0x180d,
+ 0x180f, 0x180f,
+ 0x1885, 0x1886,
+ 0x18a9, 0x18a9,
+ 0x1920, 0x1922,
+ 0x1927, 0x1928,
+ 0x1932, 0x1932,
+ 0x1939, 0x193b,
+ 0x1a17, 0x1a18,
+ 0x1a1b, 0x1a1b,
+ 0x1a56, 0x1a56,
+ 0x1a58, 0x1a5e,
+ 0x1a60, 0x1a60,
+ 0x1a62, 0x1a62,
+ 0x1a65, 0x1a6c,
+ 0x1a73, 0x1a7c,
+ 0x1a7f, 0x1a7f,
+ 0x1ab0, 0x1add,
+ 0x1ae0, 0x1aeb,
+ 0x1b00, 0x1b03,
+ 0x1b34, 0x1b3d,
+ 0x1b42, 0x1b44,
+ 0x1b6b, 0x1b73,
+ 0x1b80, 0x1b81,
+ 0x1ba2, 0x1ba5,
+ 0x1ba8, 0x1bad,
+ 0x1be6, 0x1be6,
+ 0x1be8, 0x1be9,
+ 0x1bed, 0x1bed,
+ 0x1bef, 0x1bf3,
+ 0x1c2c, 0x1c33,
+ 0x1c36, 0x1c37,
+ 0x1cd0, 0x1cd2,
+ 0x1cd4, 0x1ce0,
+ 0x1ce2, 0x1ce8,
+ 0x1ced, 0x1ced,
+ 0x1cf4, 0x1cf4,
+ 0x1cf8, 0x1cf9,
+ 0x1dc0, 0x1dff,
+ 0x200c, 0x200c,
+ 0x20d0, 0x20f0,
+ 0x2cef, 0x2cf1,
+ 0x2d7f, 0x2d7f,
+ 0x2de0, 0x2dff,
+ 0x302a, 0x302f,
+ 0x3099, 0x309a,
+ 0xa66f, 0xa672,
+ 0xa674, 0xa67d,
+ 0xa69e, 0xa69f,
+ 0xa6f0, 0xa6f1,
+ 0xa802, 0xa802,
+ 0xa806, 0xa806,
+ 0xa80b, 0xa80b,
+ 0xa825, 0xa826,
+ 0xa82c, 0xa82c,
+ 0xa8c4, 0xa8c5,
+ 0xa8e0, 0xa8f1,
+ 0xa8ff, 0xa8ff,
+ 0xa926, 0xa92d,
+ 0xa947, 0xa951,
+ 0xa953, 0xa953,
+ 0xa980, 0xa982,
+ 0xa9b3, 0xa9b3,
+ 0xa9b6, 0xa9b9,
+ 0xa9bc, 0xa9bd,
+ 0xa9c0, 0xa9c0,
+ 0xa9e5, 0xa9e5,
+ 0xaa29, 0xaa2e,
+ 0xaa31, 0xaa32,
+ 0xaa35, 0xaa36,
+ 0xaa43, 0xaa43,
+ 0xaa4c, 0xaa4c,
+ 0xaa7c, 0xaa7c,
+ 0xaab0, 0xaab0,
+ 0xaab2, 0xaab4,
+ 0xaab7, 0xaab8,
+ 0xaabe, 0xaabf,
+ 0xaac1, 0xaac1,
+ 0xaaec, 0xaaed,
+ 0xaaf6, 0xaaf6,
+ 0xabe5, 0xabe5,
+ 0xabe8, 0xabe8,
+ 0xabed, 0xabed,
+ 0xfb1e, 0xfb1e,
+ 0xfe00, 0xfe0f,
+ 0xfe20, 0xfe2f,
+ 0xff9e, 0xff9f,
+ 0x101fd, 0x101fd,
+ 0x102e0, 0x102e0,
+ 0x10376, 0x1037a,
+ 0x10a01, 0x10a03,
+ 0x10a05, 0x10a06,
+ 0x10a0c, 0x10a0f,
+ 0x10a38, 0x10a3a,
+ 0x10a3f, 0x10a3f,
+ 0x10ae5, 0x10ae6,
+ 0x10d24, 0x10d27,
+ 0x10d69, 0x10d6d,
+ 0x10eab, 0x10eac,
+ 0x10efa, 0x10eff,
+ 0x10f46, 0x10f50,
+ 0x10f82, 0x10f85,
+ 0x11001, 0x11001,
+ 0x11038, 0x11046,
+ 0x11070, 0x11070,
+ 0x11073, 0x11074,
+ 0x1107f, 0x11081,
+ 0x110b3, 0x110b6,
+ 0x110b9, 0x110ba,
+ 0x110c2, 0x110c2,
+ 0x11100, 0x11102,
+ 0x11127, 0x1112b,
+ 0x1112d, 0x11134,
+ 0x11173, 0x11173,
+ 0x11180, 0x11181,
+ 0x111b6, 0x111be,
+ 0x111c0, 0x111c0,
+ 0x111c9, 0x111cc,
+ 0x111cf, 0x111cf,
+ 0x1122f, 0x11231,
+ 0x11234, 0x11237,
+ 0x1123e, 0x1123e,
+ 0x11241, 0x11241,
+ 0x112df, 0x112df,
+ 0x112e3, 0x112ea,
+ 0x11300, 0x11301,
+ 0x1133b, 0x1133c,
+ 0x1133e, 0x1133e,
+ 0x11340, 0x11340,
+ 0x1134d, 0x1134d,
+ 0x11357, 0x11357,
+ 0x11366, 0x1136c,
+ 0x11370, 0x11374,
+ 0x113b8, 0x113b8,
+ 0x113bb, 0x113c0,
+ 0x113c2, 0x113c2,
+ 0x113c5, 0x113c5,
+ 0x113c7, 0x113c9,
+ 0x113ce, 0x113d0,
+ 0x113d2, 0x113d2,
+ 0x113e1, 0x113e2,
+ 0x11438, 0x1143f,
+ 0x11442, 0x11444,
+ 0x11446, 0x11446,
+ 0x1145e, 0x1145e,
+ 0x114b0, 0x114b0,
+ 0x114b3, 0x114b8,
+ 0x114ba, 0x114ba,
+ 0x114bd, 0x114bd,
+ 0x114bf, 0x114c0,
+ 0x114c2, 0x114c3,
+ 0x115af, 0x115af,
+ 0x115b2, 0x115b5,
+ 0x115bc, 0x115bd,
+ 0x115bf, 0x115c0,
+ 0x115dc, 0x115dd,
+ 0x11633, 0x1163a,
+ 0x1163d, 0x1163d,
+ 0x1163f, 0x11640,
+ 0x116ab, 0x116ab,
+ 0x116ad, 0x116ad,
+ 0x116b0, 0x116b7,
+ 0x1171d, 0x1171d,
+ 0x1171f, 0x1171f,
+ 0x11722, 0x11725,
+ 0x11727, 0x1172b,
+ 0x1182f, 0x11837,
+ 0x11839, 0x1183a,
+ 0x11930, 0x11930,
+ 0x1193b, 0x1193e,
+ 0x11943, 0x11943,
+ 0x119d4, 0x119d7,
+ 0x119da, 0x119db,
+ 0x119e0, 0x119e0,
+ 0x11a01, 0x11a0a,
+ 0x11a33, 0x11a38,
+ 0x11a3b, 0x11a3e,
+ 0x11a47, 0x11a47,
+ 0x11a51, 0x11a56,
+ 0x11a59, 0x11a5b,
+ 0x11a8a, 0x11a96,
+ 0x11a98, 0x11a99,
+ 0x11b60, 0x11b60,
+ 0x11b62, 0x11b64,
+ 0x11b66, 0x11b66,
+ 0x11c30, 0x11c36,
+ 0x11c38, 0x11c3d,
+ 0x11c3f, 0x11c3f,
+ 0x11c92, 0x11ca7,
+ 0x11caa, 0x11cb0,
+ 0x11cb2, 0x11cb3,
+ 0x11cb5, 0x11cb6,
+ 0x11d31, 0x11d36,
+ 0x11d3a, 0x11d3a,
+ 0x11d3c, 0x11d3d,
+ 0x11d3f, 0x11d45,
+ 0x11d47, 0x11d47,
+ 0x11d90, 0x11d91,
+ 0x11d95, 0x11d95,
+ 0x11d97, 0x11d97,
+ 0x11ef3, 0x11ef4,
+ 0x11f00, 0x11f01,
+ 0x11f36, 0x11f3a,
+ 0x11f40, 0x11f42,
+ 0x11f5a, 0x11f5a,
+ 0x13440, 0x13440,
+ 0x13447, 0x13455,
+ 0x1611e, 0x16129,
+ 0x1612d, 0x1612f,
+ 0x16af0, 0x16af4,
+ 0x16b30, 0x16b36,
+ 0x16f4f, 0x16f4f,
+ 0x16f8f, 0x16f92,
+ 0x16fe4, 0x16fe4,
+ 0x16ff0, 0x16ff1,
+ 0x1bc9d, 0x1bc9e,
+ 0x1cf00, 0x1cf2d,
+ 0x1cf30, 0x1cf46,
+ 0x1d165, 0x1d169,
+ 0x1d16d, 0x1d172,
+ 0x1d17b, 0x1d182,
+ 0x1d185, 0x1d18b,
+ 0x1d1aa, 0x1d1ad,
+ 0x1d242, 0x1d244,
+ 0x1da00, 0x1da36,
+ 0x1da3b, 0x1da6c,
+ 0x1da75, 0x1da75,
+ 0x1da84, 0x1da84,
+ 0x1da9b, 0x1da9f,
+ 0x1daa1, 0x1daaf,
+ 0x1e000, 0x1e006,
+ 0x1e008, 0x1e018,
+ 0x1e01b, 0x1e021,
+ 0x1e023, 0x1e024,
+ 0x1e026, 0x1e02a,
+ 0x1e08f, 0x1e08f,
+ 0x1e130, 0x1e136,
+ 0x1e2ae, 0x1e2ae,
+ 0x1e2ec, 0x1e2ef,
+ 0x1e4ec, 0x1e4ef,
+ 0x1e5ee, 0x1e5ef,
+ 0x1e6e3, 0x1e6e3,
+ 0x1e6e6, 0x1e6e6,
+ 0x1e6ee, 0x1e6ef,
+ 0x1e6f5, 0x1e6f5,
+ 0x1e8d0, 0x1e8d6,
+ 0x1e944, 0x1e94a,
+ 0x1f3fb, 0x1f3ff,
+ 0xe0020, 0xe007f,
+ 0xe0100, 0xe01ef,
+}; /* CR_Grapheme_Cluster_Break_Extend */
+
+/* 'Grapheme_Cluster_Break_Regional_Indicator': Grapheme_Cluster_Break=Regional_Indicator */
+#define CR_Grapheme_Cluster_Break_Regional_Indicator CR_Regional_Indicator
+
+/* 'Grapheme_Cluster_Break_SpacingMark': Grapheme_Cluster_Break=SpacingMark */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_SpacingMark[] = {
+ 158,
+ 0x0903, 0x0903,
+ 0x093b, 0x093b,
+ 0x093e, 0x0940,
+ 0x0949, 0x094c,
+ 0x094e, 0x094f,
+ 0x0982, 0x0983,
+ 0x09bf, 0x09c0,
+ 0x09c7, 0x09c8,
+ 0x09cb, 0x09cc,
+ 0x0a03, 0x0a03,
+ 0x0a3e, 0x0a40,
+ 0x0a83, 0x0a83,
+ 0x0abe, 0x0ac0,
+ 0x0ac9, 0x0ac9,
+ 0x0acb, 0x0acc,
+ 0x0b02, 0x0b03,
+ 0x0b40, 0x0b40,
+ 0x0b47, 0x0b48,
+ 0x0b4b, 0x0b4c,
+ 0x0bbf, 0x0bbf,
+ 0x0bc1, 0x0bc2,
+ 0x0bc6, 0x0bc8,
+ 0x0bca, 0x0bcc,
+ 0x0c01, 0x0c03,
+ 0x0c41, 0x0c44,
+ 0x0c82, 0x0c83,
+ 0x0cbe, 0x0cbe,
+ 0x0cc1, 0x0cc1,
+ 0x0cc3, 0x0cc4,
+ 0x0cf3, 0x0cf3,
+ 0x0d02, 0x0d03,
+ 0x0d3f, 0x0d40,
+ 0x0d46, 0x0d48,
+ 0x0d4a, 0x0d4c,
+ 0x0d82, 0x0d83,
+ 0x0dd0, 0x0dd1,
+ 0x0dd8, 0x0dde,
+ 0x0df2, 0x0df3,
+ 0x0e33, 0x0e33,
+ 0x0eb3, 0x0eb3,
+ 0x0f3e, 0x0f3f,
+ 0x0f7f, 0x0f7f,
+ 0x1031, 0x1031,
+ 0x103b, 0x103c,
+ 0x1056, 0x1057,
+ 0x1084, 0x1084,
+ 0x17b6, 0x17b6,
+ 0x17be, 0x17c5,
+ 0x17c7, 0x17c8,
+ 0x1923, 0x1926,
+ 0x1929, 0x192b,
+ 0x1930, 0x1931,
+ 0x1933, 0x1938,
+ 0x1a19, 0x1a1a,
+ 0x1a55, 0x1a55,
+ 0x1a57, 0x1a57,
+ 0x1a6d, 0x1a72,
+ 0x1b04, 0x1b04,
+ 0x1b3e, 0x1b41,
+ 0x1b82, 0x1b82,
+ 0x1ba1, 0x1ba1,
+ 0x1ba6, 0x1ba7,
+ 0x1be7, 0x1be7,
+ 0x1bea, 0x1bec,
+ 0x1bee, 0x1bee,
+ 0x1c24, 0x1c2b,
+ 0x1c34, 0x1c35,
+ 0x1ce1, 0x1ce1,
+ 0x1cf7, 0x1cf7,
+ 0xa823, 0xa824,
+ 0xa827, 0xa827,
+ 0xa880, 0xa881,
+ 0xa8b4, 0xa8c3,
+ 0xa952, 0xa952,
+ 0xa983, 0xa983,
+ 0xa9b4, 0xa9b5,
+ 0xa9ba, 0xa9bb,
+ 0xa9be, 0xa9bf,
+ 0xaa2f, 0xaa30,
+ 0xaa33, 0xaa34,
+ 0xaa4d, 0xaa4d,
+ 0xaaeb, 0xaaeb,
+ 0xaaee, 0xaaef,
+ 0xaaf5, 0xaaf5,
+ 0xabe3, 0xabe4,
+ 0xabe6, 0xabe7,
+ 0xabe9, 0xabea,
+ 0xabec, 0xabec,
+ 0x11000, 0x11000,
+ 0x11002, 0x11002,
+ 0x11082, 0x11082,
+ 0x110b0, 0x110b2,
+ 0x110b7, 0x110b8,
+ 0x1112c, 0x1112c,
+ 0x11145, 0x11146,
+ 0x11182, 0x11182,
+ 0x111b3, 0x111b5,
+ 0x111bf, 0x111bf,
+ 0x111ce, 0x111ce,
+ 0x1122c, 0x1122e,
+ 0x11232, 0x11233,
+ 0x112e0, 0x112e2,
+ 0x11302, 0x11303,
+ 0x1133f, 0x1133f,
+ 0x11341, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134b, 0x1134c,
+ 0x11362, 0x11363,
+ 0x113b9, 0x113ba,
+ 0x113ca, 0x113ca,
+ 0x113cc, 0x113cd,
+ 0x11435, 0x11437,
+ 0x11440, 0x11441,
+ 0x11445, 0x11445,
+ 0x114b1, 0x114b2,
+ 0x114b9, 0x114b9,
+ 0x114bb, 0x114bc,
+ 0x114be, 0x114be,
+ 0x114c1, 0x114c1,
+ 0x115b0, 0x115b1,
+ 0x115b8, 0x115bb,
+ 0x115be, 0x115be,
+ 0x11630, 0x11632,
+ 0x1163b, 0x1163c,
+ 0x1163e, 0x1163e,
+ 0x116ac, 0x116ac,
+ 0x116ae, 0x116af,
+ 0x1171e, 0x1171e,
+ 0x11726, 0x11726,
+ 0x1182c, 0x1182e,
+ 0x11838, 0x11838,
+ 0x11931, 0x11935,
+ 0x11937, 0x11938,
+ 0x11940, 0x11940,
+ 0x11942, 0x11942,
+ 0x119d1, 0x119d3,
+ 0x119dc, 0x119df,
+ 0x119e4, 0x119e4,
+ 0x11a39, 0x11a39,
+ 0x11a57, 0x11a58,
+ 0x11a97, 0x11a97,
+ 0x11b61, 0x11b61,
+ 0x11b65, 0x11b65,
+ 0x11b67, 0x11b67,
+ 0x11c2f, 0x11c2f,
+ 0x11c3e, 0x11c3e,
+ 0x11ca9, 0x11ca9,
+ 0x11cb1, 0x11cb1,
+ 0x11cb4, 0x11cb4,
+ 0x11d8a, 0x11d8e,
+ 0x11d93, 0x11d94,
+ 0x11d96, 0x11d96,
+ 0x11ef5, 0x11ef6,
+ 0x11f03, 0x11f03,
+ 0x11f34, 0x11f35,
+ 0x11f3e, 0x11f3f,
+ 0x1612a, 0x1612c,
+ 0x16f51, 0x16f87,
+}; /* CR_Grapheme_Cluster_Break_SpacingMark */
+
+/* 'Grapheme_Cluster_Break_L': Grapheme_Cluster_Break=L */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_L[] = {
+ 2,
+ 0x1100, 0x115f,
+ 0xa960, 0xa97c,
+}; /* CR_Grapheme_Cluster_Break_L */
+
+/* 'Grapheme_Cluster_Break_V': Grapheme_Cluster_Break=V */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_V[] = {
+ 4,
+ 0x1160, 0x11a7,
+ 0xd7b0, 0xd7c6,
+ 0x16d63, 0x16d63,
+ 0x16d67, 0x16d6a,
+}; /* CR_Grapheme_Cluster_Break_V */
+
+/* 'Grapheme_Cluster_Break_T': Grapheme_Cluster_Break=T */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_T[] = {
+ 2,
+ 0x11a8, 0x11ff,
+ 0xd7cb, 0xd7fb,
+}; /* CR_Grapheme_Cluster_Break_T */
+
+/* 'Grapheme_Cluster_Break_LV': Grapheme_Cluster_Break=LV */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_LV[] = {
+ 399,
+ 0xac00, 0xac00,
+ 0xac1c, 0xac1c,
+ 0xac38, 0xac38,
+ 0xac54, 0xac54,
+ 0xac70, 0xac70,
+ 0xac8c, 0xac8c,
+ 0xaca8, 0xaca8,
+ 0xacc4, 0xacc4,
+ 0xace0, 0xace0,
+ 0xacfc, 0xacfc,
+ 0xad18, 0xad18,
+ 0xad34, 0xad34,
+ 0xad50, 0xad50,
+ 0xad6c, 0xad6c,
+ 0xad88, 0xad88,
+ 0xada4, 0xada4,
+ 0xadc0, 0xadc0,
+ 0xaddc, 0xaddc,
+ 0xadf8, 0xadf8,
+ 0xae14, 0xae14,
+ 0xae30, 0xae30,
+ 0xae4c, 0xae4c,
+ 0xae68, 0xae68,
+ 0xae84, 0xae84,
+ 0xaea0, 0xaea0,
+ 0xaebc, 0xaebc,
+ 0xaed8, 0xaed8,
+ 0xaef4, 0xaef4,
+ 0xaf10, 0xaf10,
+ 0xaf2c, 0xaf2c,
+ 0xaf48, 0xaf48,
+ 0xaf64, 0xaf64,
+ 0xaf80, 0xaf80,
+ 0xaf9c, 0xaf9c,
+ 0xafb8, 0xafb8,
+ 0xafd4, 0xafd4,
+ 0xaff0, 0xaff0,
+ 0xb00c, 0xb00c,
+ 0xb028, 0xb028,
+ 0xb044, 0xb044,
+ 0xb060, 0xb060,
+ 0xb07c, 0xb07c,
+ 0xb098, 0xb098,
+ 0xb0b4, 0xb0b4,
+ 0xb0d0, 0xb0d0,
+ 0xb0ec, 0xb0ec,
+ 0xb108, 0xb108,
+ 0xb124, 0xb124,
+ 0xb140, 0xb140,
+ 0xb15c, 0xb15c,
+ 0xb178, 0xb178,
+ 0xb194, 0xb194,
+ 0xb1b0, 0xb1b0,
+ 0xb1cc, 0xb1cc,
+ 0xb1e8, 0xb1e8,
+ 0xb204, 0xb204,
+ 0xb220, 0xb220,
+ 0xb23c, 0xb23c,
+ 0xb258, 0xb258,
+ 0xb274, 0xb274,
+ 0xb290, 0xb290,
+ 0xb2ac, 0xb2ac,
+ 0xb2c8, 0xb2c8,
+ 0xb2e4, 0xb2e4,
+ 0xb300, 0xb300,
+ 0xb31c, 0xb31c,
+ 0xb338, 0xb338,
+ 0xb354, 0xb354,
+ 0xb370, 0xb370,
+ 0xb38c, 0xb38c,
+ 0xb3a8, 0xb3a8,
+ 0xb3c4, 0xb3c4,
+ 0xb3e0, 0xb3e0,
+ 0xb3fc, 0xb3fc,
+ 0xb418, 0xb418,
+ 0xb434, 0xb434,
+ 0xb450, 0xb450,
+ 0xb46c, 0xb46c,
+ 0xb488, 0xb488,
+ 0xb4a4, 0xb4a4,
+ 0xb4c0, 0xb4c0,
+ 0xb4dc, 0xb4dc,
+ 0xb4f8, 0xb4f8,
+ 0xb514, 0xb514,
+ 0xb530, 0xb530,
+ 0xb54c, 0xb54c,
+ 0xb568, 0xb568,
+ 0xb584, 0xb584,
+ 0xb5a0, 0xb5a0,
+ 0xb5bc, 0xb5bc,
+ 0xb5d8, 0xb5d8,
+ 0xb5f4, 0xb5f4,
+ 0xb610, 0xb610,
+ 0xb62c, 0xb62c,
+ 0xb648, 0xb648,
+ 0xb664, 0xb664,
+ 0xb680, 0xb680,
+ 0xb69c, 0xb69c,
+ 0xb6b8, 0xb6b8,
+ 0xb6d4, 0xb6d4,
+ 0xb6f0, 0xb6f0,
+ 0xb70c, 0xb70c,
+ 0xb728, 0xb728,
+ 0xb744, 0xb744,
+ 0xb760, 0xb760,
+ 0xb77c, 0xb77c,
+ 0xb798, 0xb798,
+ 0xb7b4, 0xb7b4,
+ 0xb7d0, 0xb7d0,
+ 0xb7ec, 0xb7ec,
+ 0xb808, 0xb808,
+ 0xb824, 0xb824,
+ 0xb840, 0xb840,
+ 0xb85c, 0xb85c,
+ 0xb878, 0xb878,
+ 0xb894, 0xb894,
+ 0xb8b0, 0xb8b0,
+ 0xb8cc, 0xb8cc,
+ 0xb8e8, 0xb8e8,
+ 0xb904, 0xb904,
+ 0xb920, 0xb920,
+ 0xb93c, 0xb93c,
+ 0xb958, 0xb958,
+ 0xb974, 0xb974,
+ 0xb990, 0xb990,
+ 0xb9ac, 0xb9ac,
+ 0xb9c8, 0xb9c8,
+ 0xb9e4, 0xb9e4,
+ 0xba00, 0xba00,
+ 0xba1c, 0xba1c,
+ 0xba38, 0xba38,
+ 0xba54, 0xba54,
+ 0xba70, 0xba70,
+ 0xba8c, 0xba8c,
+ 0xbaa8, 0xbaa8,
+ 0xbac4, 0xbac4,
+ 0xbae0, 0xbae0,
+ 0xbafc, 0xbafc,
+ 0xbb18, 0xbb18,
+ 0xbb34, 0xbb34,
+ 0xbb50, 0xbb50,
+ 0xbb6c, 0xbb6c,
+ 0xbb88, 0xbb88,
+ 0xbba4, 0xbba4,
+ 0xbbc0, 0xbbc0,
+ 0xbbdc, 0xbbdc,
+ 0xbbf8, 0xbbf8,
+ 0xbc14, 0xbc14,
+ 0xbc30, 0xbc30,
+ 0xbc4c, 0xbc4c,
+ 0xbc68, 0xbc68,
+ 0xbc84, 0xbc84,
+ 0xbca0, 0xbca0,
+ 0xbcbc, 0xbcbc,
+ 0xbcd8, 0xbcd8,
+ 0xbcf4, 0xbcf4,
+ 0xbd10, 0xbd10,
+ 0xbd2c, 0xbd2c,
+ 0xbd48, 0xbd48,
+ 0xbd64, 0xbd64,
+ 0xbd80, 0xbd80,
+ 0xbd9c, 0xbd9c,
+ 0xbdb8, 0xbdb8,
+ 0xbdd4, 0xbdd4,
+ 0xbdf0, 0xbdf0,
+ 0xbe0c, 0xbe0c,
+ 0xbe28, 0xbe28,
+ 0xbe44, 0xbe44,
+ 0xbe60, 0xbe60,
+ 0xbe7c, 0xbe7c,
+ 0xbe98, 0xbe98,
+ 0xbeb4, 0xbeb4,
+ 0xbed0, 0xbed0,
+ 0xbeec, 0xbeec,
+ 0xbf08, 0xbf08,
+ 0xbf24, 0xbf24,
+ 0xbf40, 0xbf40,
+ 0xbf5c, 0xbf5c,
+ 0xbf78, 0xbf78,
+ 0xbf94, 0xbf94,
+ 0xbfb0, 0xbfb0,
+ 0xbfcc, 0xbfcc,
+ 0xbfe8, 0xbfe8,
+ 0xc004, 0xc004,
+ 0xc020, 0xc020,
+ 0xc03c, 0xc03c,
+ 0xc058, 0xc058,
+ 0xc074, 0xc074,
+ 0xc090, 0xc090,
+ 0xc0ac, 0xc0ac,
+ 0xc0c8, 0xc0c8,
+ 0xc0e4, 0xc0e4,
+ 0xc100, 0xc100,
+ 0xc11c, 0xc11c,
+ 0xc138, 0xc138,
+ 0xc154, 0xc154,
+ 0xc170, 0xc170,
+ 0xc18c, 0xc18c,
+ 0xc1a8, 0xc1a8,
+ 0xc1c4, 0xc1c4,
+ 0xc1e0, 0xc1e0,
+ 0xc1fc, 0xc1fc,
+ 0xc218, 0xc218,
+ 0xc234, 0xc234,
+ 0xc250, 0xc250,
+ 0xc26c, 0xc26c,
+ 0xc288, 0xc288,
+ 0xc2a4, 0xc2a4,
+ 0xc2c0, 0xc2c0,
+ 0xc2dc, 0xc2dc,
+ 0xc2f8, 0xc2f8,
+ 0xc314, 0xc314,
+ 0xc330, 0xc330,
+ 0xc34c, 0xc34c,
+ 0xc368, 0xc368,
+ 0xc384, 0xc384,
+ 0xc3a0, 0xc3a0,
+ 0xc3bc, 0xc3bc,
+ 0xc3d8, 0xc3d8,
+ 0xc3f4, 0xc3f4,
+ 0xc410, 0xc410,
+ 0xc42c, 0xc42c,
+ 0xc448, 0xc448,
+ 0xc464, 0xc464,
+ 0xc480, 0xc480,
+ 0xc49c, 0xc49c,
+ 0xc4b8, 0xc4b8,
+ 0xc4d4, 0xc4d4,
+ 0xc4f0, 0xc4f0,
+ 0xc50c, 0xc50c,
+ 0xc528, 0xc528,
+ 0xc544, 0xc544,
+ 0xc560, 0xc560,
+ 0xc57c, 0xc57c,
+ 0xc598, 0xc598,
+ 0xc5b4, 0xc5b4,
+ 0xc5d0, 0xc5d0,
+ 0xc5ec, 0xc5ec,
+ 0xc608, 0xc608,
+ 0xc624, 0xc624,
+ 0xc640, 0xc640,
+ 0xc65c, 0xc65c,
+ 0xc678, 0xc678,
+ 0xc694, 0xc694,
+ 0xc6b0, 0xc6b0,
+ 0xc6cc, 0xc6cc,
+ 0xc6e8, 0xc6e8,
+ 0xc704, 0xc704,
+ 0xc720, 0xc720,
+ 0xc73c, 0xc73c,
+ 0xc758, 0xc758,
+ 0xc774, 0xc774,
+ 0xc790, 0xc790,
+ 0xc7ac, 0xc7ac,
+ 0xc7c8, 0xc7c8,
+ 0xc7e4, 0xc7e4,
+ 0xc800, 0xc800,
+ 0xc81c, 0xc81c,
+ 0xc838, 0xc838,
+ 0xc854, 0xc854,
+ 0xc870, 0xc870,
+ 0xc88c, 0xc88c,
+ 0xc8a8, 0xc8a8,
+ 0xc8c4, 0xc8c4,
+ 0xc8e0, 0xc8e0,
+ 0xc8fc, 0xc8fc,
+ 0xc918, 0xc918,
+ 0xc934, 0xc934,
+ 0xc950, 0xc950,
+ 0xc96c, 0xc96c,
+ 0xc988, 0xc988,
+ 0xc9a4, 0xc9a4,
+ 0xc9c0, 0xc9c0,
+ 0xc9dc, 0xc9dc,
+ 0xc9f8, 0xc9f8,
+ 0xca14, 0xca14,
+ 0xca30, 0xca30,
+ 0xca4c, 0xca4c,
+ 0xca68, 0xca68,
+ 0xca84, 0xca84,
+ 0xcaa0, 0xcaa0,
+ 0xcabc, 0xcabc,
+ 0xcad8, 0xcad8,
+ 0xcaf4, 0xcaf4,
+ 0xcb10, 0xcb10,
+ 0xcb2c, 0xcb2c,
+ 0xcb48, 0xcb48,
+ 0xcb64, 0xcb64,
+ 0xcb80, 0xcb80,
+ 0xcb9c, 0xcb9c,
+ 0xcbb8, 0xcbb8,
+ 0xcbd4, 0xcbd4,
+ 0xcbf0, 0xcbf0,
+ 0xcc0c, 0xcc0c,
+ 0xcc28, 0xcc28,
+ 0xcc44, 0xcc44,
+ 0xcc60, 0xcc60,
+ 0xcc7c, 0xcc7c,
+ 0xcc98, 0xcc98,
+ 0xccb4, 0xccb4,
+ 0xccd0, 0xccd0,
+ 0xccec, 0xccec,
+ 0xcd08, 0xcd08,
+ 0xcd24, 0xcd24,
+ 0xcd40, 0xcd40,
+ 0xcd5c, 0xcd5c,
+ 0xcd78, 0xcd78,
+ 0xcd94, 0xcd94,
+ 0xcdb0, 0xcdb0,
+ 0xcdcc, 0xcdcc,
+ 0xcde8, 0xcde8,
+ 0xce04, 0xce04,
+ 0xce20, 0xce20,
+ 0xce3c, 0xce3c,
+ 0xce58, 0xce58,
+ 0xce74, 0xce74,
+ 0xce90, 0xce90,
+ 0xceac, 0xceac,
+ 0xcec8, 0xcec8,
+ 0xcee4, 0xcee4,
+ 0xcf00, 0xcf00,
+ 0xcf1c, 0xcf1c,
+ 0xcf38, 0xcf38,
+ 0xcf54, 0xcf54,
+ 0xcf70, 0xcf70,
+ 0xcf8c, 0xcf8c,
+ 0xcfa8, 0xcfa8,
+ 0xcfc4, 0xcfc4,
+ 0xcfe0, 0xcfe0,
+ 0xcffc, 0xcffc,
+ 0xd018, 0xd018,
+ 0xd034, 0xd034,
+ 0xd050, 0xd050,
+ 0xd06c, 0xd06c,
+ 0xd088, 0xd088,
+ 0xd0a4, 0xd0a4,
+ 0xd0c0, 0xd0c0,
+ 0xd0dc, 0xd0dc,
+ 0xd0f8, 0xd0f8,
+ 0xd114, 0xd114,
+ 0xd130, 0xd130,
+ 0xd14c, 0xd14c,
+ 0xd168, 0xd168,
+ 0xd184, 0xd184,
+ 0xd1a0, 0xd1a0,
+ 0xd1bc, 0xd1bc,
+ 0xd1d8, 0xd1d8,
+ 0xd1f4, 0xd1f4,
+ 0xd210, 0xd210,
+ 0xd22c, 0xd22c,
+ 0xd248, 0xd248,
+ 0xd264, 0xd264,
+ 0xd280, 0xd280,
+ 0xd29c, 0xd29c,
+ 0xd2b8, 0xd2b8,
+ 0xd2d4, 0xd2d4,
+ 0xd2f0, 0xd2f0,
+ 0xd30c, 0xd30c,
+ 0xd328, 0xd328,
+ 0xd344, 0xd344,
+ 0xd360, 0xd360,
+ 0xd37c, 0xd37c,
+ 0xd398, 0xd398,
+ 0xd3b4, 0xd3b4,
+ 0xd3d0, 0xd3d0,
+ 0xd3ec, 0xd3ec,
+ 0xd408, 0xd408,
+ 0xd424, 0xd424,
+ 0xd440, 0xd440,
+ 0xd45c, 0xd45c,
+ 0xd478, 0xd478,
+ 0xd494, 0xd494,
+ 0xd4b0, 0xd4b0,
+ 0xd4cc, 0xd4cc,
+ 0xd4e8, 0xd4e8,
+ 0xd504, 0xd504,
+ 0xd520, 0xd520,
+ 0xd53c, 0xd53c,
+ 0xd558, 0xd558,
+ 0xd574, 0xd574,
+ 0xd590, 0xd590,
+ 0xd5ac, 0xd5ac,
+ 0xd5c8, 0xd5c8,
+ 0xd5e4, 0xd5e4,
+ 0xd600, 0xd600,
+ 0xd61c, 0xd61c,
+ 0xd638, 0xd638,
+ 0xd654, 0xd654,
+ 0xd670, 0xd670,
+ 0xd68c, 0xd68c,
+ 0xd6a8, 0xd6a8,
+ 0xd6c4, 0xd6c4,
+ 0xd6e0, 0xd6e0,
+ 0xd6fc, 0xd6fc,
+ 0xd718, 0xd718,
+ 0xd734, 0xd734,
+ 0xd750, 0xd750,
+ 0xd76c, 0xd76c,
+ 0xd788, 0xd788,
+}; /* CR_Grapheme_Cluster_Break_LV */
+
+/* 'Grapheme_Cluster_Break_LVT': Grapheme_Cluster_Break=LVT */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_LVT[] = {
+ 399,
+ 0xac01, 0xac1b,
+ 0xac1d, 0xac37,
+ 0xac39, 0xac53,
+ 0xac55, 0xac6f,
+ 0xac71, 0xac8b,
+ 0xac8d, 0xaca7,
+ 0xaca9, 0xacc3,
+ 0xacc5, 0xacdf,
+ 0xace1, 0xacfb,
+ 0xacfd, 0xad17,
+ 0xad19, 0xad33,
+ 0xad35, 0xad4f,
+ 0xad51, 0xad6b,
+ 0xad6d, 0xad87,
+ 0xad89, 0xada3,
+ 0xada5, 0xadbf,
+ 0xadc1, 0xaddb,
+ 0xaddd, 0xadf7,
+ 0xadf9, 0xae13,
+ 0xae15, 0xae2f,
+ 0xae31, 0xae4b,
+ 0xae4d, 0xae67,
+ 0xae69, 0xae83,
+ 0xae85, 0xae9f,
+ 0xaea1, 0xaebb,
+ 0xaebd, 0xaed7,
+ 0xaed9, 0xaef3,
+ 0xaef5, 0xaf0f,
+ 0xaf11, 0xaf2b,
+ 0xaf2d, 0xaf47,
+ 0xaf49, 0xaf63,
+ 0xaf65, 0xaf7f,
+ 0xaf81, 0xaf9b,
+ 0xaf9d, 0xafb7,
+ 0xafb9, 0xafd3,
+ 0xafd5, 0xafef,
+ 0xaff1, 0xb00b,
+ 0xb00d, 0xb027,
+ 0xb029, 0xb043,
+ 0xb045, 0xb05f,
+ 0xb061, 0xb07b,
+ 0xb07d, 0xb097,
+ 0xb099, 0xb0b3,
+ 0xb0b5, 0xb0cf,
+ 0xb0d1, 0xb0eb,
+ 0xb0ed, 0xb107,
+ 0xb109, 0xb123,
+ 0xb125, 0xb13f,
+ 0xb141, 0xb15b,
+ 0xb15d, 0xb177,
+ 0xb179, 0xb193,
+ 0xb195, 0xb1af,
+ 0xb1b1, 0xb1cb,
+ 0xb1cd, 0xb1e7,
+ 0xb1e9, 0xb203,
+ 0xb205, 0xb21f,
+ 0xb221, 0xb23b,
+ 0xb23d, 0xb257,
+ 0xb259, 0xb273,
+ 0xb275, 0xb28f,
+ 0xb291, 0xb2ab,
+ 0xb2ad, 0xb2c7,
+ 0xb2c9, 0xb2e3,
+ 0xb2e5, 0xb2ff,
+ 0xb301, 0xb31b,
+ 0xb31d, 0xb337,
+ 0xb339, 0xb353,
+ 0xb355, 0xb36f,
+ 0xb371, 0xb38b,
+ 0xb38d, 0xb3a7,
+ 0xb3a9, 0xb3c3,
+ 0xb3c5, 0xb3df,
+ 0xb3e1, 0xb3fb,
+ 0xb3fd, 0xb417,
+ 0xb419, 0xb433,
+ 0xb435, 0xb44f,
+ 0xb451, 0xb46b,
+ 0xb46d, 0xb487,
+ 0xb489, 0xb4a3,
+ 0xb4a5, 0xb4bf,
+ 0xb4c1, 0xb4db,
+ 0xb4dd, 0xb4f7,
+ 0xb4f9, 0xb513,
+ 0xb515, 0xb52f,
+ 0xb531, 0xb54b,
+ 0xb54d, 0xb567,
+ 0xb569, 0xb583,
+ 0xb585, 0xb59f,
+ 0xb5a1, 0xb5bb,
+ 0xb5bd, 0xb5d7,
+ 0xb5d9, 0xb5f3,
+ 0xb5f5, 0xb60f,
+ 0xb611, 0xb62b,
+ 0xb62d, 0xb647,
+ 0xb649, 0xb663,
+ 0xb665, 0xb67f,
+ 0xb681, 0xb69b,
+ 0xb69d, 0xb6b7,
+ 0xb6b9, 0xb6d3,
+ 0xb6d5, 0xb6ef,
+ 0xb6f1, 0xb70b,
+ 0xb70d, 0xb727,
+ 0xb729, 0xb743,
+ 0xb745, 0xb75f,
+ 0xb761, 0xb77b,
+ 0xb77d, 0xb797,
+ 0xb799, 0xb7b3,
+ 0xb7b5, 0xb7cf,
+ 0xb7d1, 0xb7eb,
+ 0xb7ed, 0xb807,
+ 0xb809, 0xb823,
+ 0xb825, 0xb83f,
+ 0xb841, 0xb85b,
+ 0xb85d, 0xb877,
+ 0xb879, 0xb893,
+ 0xb895, 0xb8af,
+ 0xb8b1, 0xb8cb,
+ 0xb8cd, 0xb8e7,
+ 0xb8e9, 0xb903,
+ 0xb905, 0xb91f,
+ 0xb921, 0xb93b,
+ 0xb93d, 0xb957,
+ 0xb959, 0xb973,
+ 0xb975, 0xb98f,
+ 0xb991, 0xb9ab,
+ 0xb9ad, 0xb9c7,
+ 0xb9c9, 0xb9e3,
+ 0xb9e5, 0xb9ff,
+ 0xba01, 0xba1b,
+ 0xba1d, 0xba37,
+ 0xba39, 0xba53,
+ 0xba55, 0xba6f,
+ 0xba71, 0xba8b,
+ 0xba8d, 0xbaa7,
+ 0xbaa9, 0xbac3,
+ 0xbac5, 0xbadf,
+ 0xbae1, 0xbafb,
+ 0xbafd, 0xbb17,
+ 0xbb19, 0xbb33,
+ 0xbb35, 0xbb4f,
+ 0xbb51, 0xbb6b,
+ 0xbb6d, 0xbb87,
+ 0xbb89, 0xbba3,
+ 0xbba5, 0xbbbf,
+ 0xbbc1, 0xbbdb,
+ 0xbbdd, 0xbbf7,
+ 0xbbf9, 0xbc13,
+ 0xbc15, 0xbc2f,
+ 0xbc31, 0xbc4b,
+ 0xbc4d, 0xbc67,
+ 0xbc69, 0xbc83,
+ 0xbc85, 0xbc9f,
+ 0xbca1, 0xbcbb,
+ 0xbcbd, 0xbcd7,
+ 0xbcd9, 0xbcf3,
+ 0xbcf5, 0xbd0f,
+ 0xbd11, 0xbd2b,
+ 0xbd2d, 0xbd47,
+ 0xbd49, 0xbd63,
+ 0xbd65, 0xbd7f,
+ 0xbd81, 0xbd9b,
+ 0xbd9d, 0xbdb7,
+ 0xbdb9, 0xbdd3,
+ 0xbdd5, 0xbdef,
+ 0xbdf1, 0xbe0b,
+ 0xbe0d, 0xbe27,
+ 0xbe29, 0xbe43,
+ 0xbe45, 0xbe5f,
+ 0xbe61, 0xbe7b,
+ 0xbe7d, 0xbe97,
+ 0xbe99, 0xbeb3,
+ 0xbeb5, 0xbecf,
+ 0xbed1, 0xbeeb,
+ 0xbeed, 0xbf07,
+ 0xbf09, 0xbf23,
+ 0xbf25, 0xbf3f,
+ 0xbf41, 0xbf5b,
+ 0xbf5d, 0xbf77,
+ 0xbf79, 0xbf93,
+ 0xbf95, 0xbfaf,
+ 0xbfb1, 0xbfcb,
+ 0xbfcd, 0xbfe7,
+ 0xbfe9, 0xc003,
+ 0xc005, 0xc01f,
+ 0xc021, 0xc03b,
+ 0xc03d, 0xc057,
+ 0xc059, 0xc073,
+ 0xc075, 0xc08f,
+ 0xc091, 0xc0ab,
+ 0xc0ad, 0xc0c7,
+ 0xc0c9, 0xc0e3,
+ 0xc0e5, 0xc0ff,
+ 0xc101, 0xc11b,
+ 0xc11d, 0xc137,
+ 0xc139, 0xc153,
+ 0xc155, 0xc16f,
+ 0xc171, 0xc18b,
+ 0xc18d, 0xc1a7,
+ 0xc1a9, 0xc1c3,
+ 0xc1c5, 0xc1df,
+ 0xc1e1, 0xc1fb,
+ 0xc1fd, 0xc217,
+ 0xc219, 0xc233,
+ 0xc235, 0xc24f,
+ 0xc251, 0xc26b,
+ 0xc26d, 0xc287,
+ 0xc289, 0xc2a3,
+ 0xc2a5, 0xc2bf,
+ 0xc2c1, 0xc2db,
+ 0xc2dd, 0xc2f7,
+ 0xc2f9, 0xc313,
+ 0xc315, 0xc32f,
+ 0xc331, 0xc34b,
+ 0xc34d, 0xc367,
+ 0xc369, 0xc383,
+ 0xc385, 0xc39f,
+ 0xc3a1, 0xc3bb,
+ 0xc3bd, 0xc3d7,
+ 0xc3d9, 0xc3f3,
+ 0xc3f5, 0xc40f,
+ 0xc411, 0xc42b,
+ 0xc42d, 0xc447,
+ 0xc449, 0xc463,
+ 0xc465, 0xc47f,
+ 0xc481, 0xc49b,
+ 0xc49d, 0xc4b7,
+ 0xc4b9, 0xc4d3,
+ 0xc4d5, 0xc4ef,
+ 0xc4f1, 0xc50b,
+ 0xc50d, 0xc527,
+ 0xc529, 0xc543,
+ 0xc545, 0xc55f,
+ 0xc561, 0xc57b,
+ 0xc57d, 0xc597,
+ 0xc599, 0xc5b3,
+ 0xc5b5, 0xc5cf,
+ 0xc5d1, 0xc5eb,
+ 0xc5ed, 0xc607,
+ 0xc609, 0xc623,
+ 0xc625, 0xc63f,
+ 0xc641, 0xc65b,
+ 0xc65d, 0xc677,
+ 0xc679, 0xc693,
+ 0xc695, 0xc6af,
+ 0xc6b1, 0xc6cb,
+ 0xc6cd, 0xc6e7,
+ 0xc6e9, 0xc703,
+ 0xc705, 0xc71f,
+ 0xc721, 0xc73b,
+ 0xc73d, 0xc757,
+ 0xc759, 0xc773,
+ 0xc775, 0xc78f,
+ 0xc791, 0xc7ab,
+ 0xc7ad, 0xc7c7,
+ 0xc7c9, 0xc7e3,
+ 0xc7e5, 0xc7ff,
+ 0xc801, 0xc81b,
+ 0xc81d, 0xc837,
+ 0xc839, 0xc853,
+ 0xc855, 0xc86f,
+ 0xc871, 0xc88b,
+ 0xc88d, 0xc8a7,
+ 0xc8a9, 0xc8c3,
+ 0xc8c5, 0xc8df,
+ 0xc8e1, 0xc8fb,
+ 0xc8fd, 0xc917,
+ 0xc919, 0xc933,
+ 0xc935, 0xc94f,
+ 0xc951, 0xc96b,
+ 0xc96d, 0xc987,
+ 0xc989, 0xc9a3,
+ 0xc9a5, 0xc9bf,
+ 0xc9c1, 0xc9db,
+ 0xc9dd, 0xc9f7,
+ 0xc9f9, 0xca13,
+ 0xca15, 0xca2f,
+ 0xca31, 0xca4b,
+ 0xca4d, 0xca67,
+ 0xca69, 0xca83,
+ 0xca85, 0xca9f,
+ 0xcaa1, 0xcabb,
+ 0xcabd, 0xcad7,
+ 0xcad9, 0xcaf3,
+ 0xcaf5, 0xcb0f,
+ 0xcb11, 0xcb2b,
+ 0xcb2d, 0xcb47,
+ 0xcb49, 0xcb63,
+ 0xcb65, 0xcb7f,
+ 0xcb81, 0xcb9b,
+ 0xcb9d, 0xcbb7,
+ 0xcbb9, 0xcbd3,
+ 0xcbd5, 0xcbef,
+ 0xcbf1, 0xcc0b,
+ 0xcc0d, 0xcc27,
+ 0xcc29, 0xcc43,
+ 0xcc45, 0xcc5f,
+ 0xcc61, 0xcc7b,
+ 0xcc7d, 0xcc97,
+ 0xcc99, 0xccb3,
+ 0xccb5, 0xcccf,
+ 0xccd1, 0xcceb,
+ 0xcced, 0xcd07,
+ 0xcd09, 0xcd23,
+ 0xcd25, 0xcd3f,
+ 0xcd41, 0xcd5b,
+ 0xcd5d, 0xcd77,
+ 0xcd79, 0xcd93,
+ 0xcd95, 0xcdaf,
+ 0xcdb1, 0xcdcb,
+ 0xcdcd, 0xcde7,
+ 0xcde9, 0xce03,
+ 0xce05, 0xce1f,
+ 0xce21, 0xce3b,
+ 0xce3d, 0xce57,
+ 0xce59, 0xce73,
+ 0xce75, 0xce8f,
+ 0xce91, 0xceab,
+ 0xcead, 0xcec7,
+ 0xcec9, 0xcee3,
+ 0xcee5, 0xceff,
+ 0xcf01, 0xcf1b,
+ 0xcf1d, 0xcf37,
+ 0xcf39, 0xcf53,
+ 0xcf55, 0xcf6f,
+ 0xcf71, 0xcf8b,
+ 0xcf8d, 0xcfa7,
+ 0xcfa9, 0xcfc3,
+ 0xcfc5, 0xcfdf,
+ 0xcfe1, 0xcffb,
+ 0xcffd, 0xd017,
+ 0xd019, 0xd033,
+ 0xd035, 0xd04f,
+ 0xd051, 0xd06b,
+ 0xd06d, 0xd087,
+ 0xd089, 0xd0a3,
+ 0xd0a5, 0xd0bf,
+ 0xd0c1, 0xd0db,
+ 0xd0dd, 0xd0f7,
+ 0xd0f9, 0xd113,
+ 0xd115, 0xd12f,
+ 0xd131, 0xd14b,
+ 0xd14d, 0xd167,
+ 0xd169, 0xd183,
+ 0xd185, 0xd19f,
+ 0xd1a1, 0xd1bb,
+ 0xd1bd, 0xd1d7,
+ 0xd1d9, 0xd1f3,
+ 0xd1f5, 0xd20f,
+ 0xd211, 0xd22b,
+ 0xd22d, 0xd247,
+ 0xd249, 0xd263,
+ 0xd265, 0xd27f,
+ 0xd281, 0xd29b,
+ 0xd29d, 0xd2b7,
+ 0xd2b9, 0xd2d3,
+ 0xd2d5, 0xd2ef,
+ 0xd2f1, 0xd30b,
+ 0xd30d, 0xd327,
+ 0xd329, 0xd343,
+ 0xd345, 0xd35f,
+ 0xd361, 0xd37b,
+ 0xd37d, 0xd397,
+ 0xd399, 0xd3b3,
+ 0xd3b5, 0xd3cf,
+ 0xd3d1, 0xd3eb,
+ 0xd3ed, 0xd407,
+ 0xd409, 0xd423,
+ 0xd425, 0xd43f,
+ 0xd441, 0xd45b,
+ 0xd45d, 0xd477,
+ 0xd479, 0xd493,
+ 0xd495, 0xd4af,
+ 0xd4b1, 0xd4cb,
+ 0xd4cd, 0xd4e7,
+ 0xd4e9, 0xd503,
+ 0xd505, 0xd51f,
+ 0xd521, 0xd53b,
+ 0xd53d, 0xd557,
+ 0xd559, 0xd573,
+ 0xd575, 0xd58f,
+ 0xd591, 0xd5ab,
+ 0xd5ad, 0xd5c7,
+ 0xd5c9, 0xd5e3,
+ 0xd5e5, 0xd5ff,
+ 0xd601, 0xd61b,
+ 0xd61d, 0xd637,
+ 0xd639, 0xd653,
+ 0xd655, 0xd66f,
+ 0xd671, 0xd68b,
+ 0xd68d, 0xd6a7,
+ 0xd6a9, 0xd6c3,
+ 0xd6c5, 0xd6df,
+ 0xd6e1, 0xd6fb,
+ 0xd6fd, 0xd717,
+ 0xd719, 0xd733,
+ 0xd735, 0xd74f,
+ 0xd751, 0xd76b,
+ 0xd76d, 0xd787,
+ 0xd789, 0xd7a3,
+}; /* CR_Grapheme_Cluster_Break_LVT */
+
+/* 'Grapheme_Cluster_Break_ZWJ': Grapheme_Cluster_Break=ZWJ */
+static const OnigCodePoint CR_Grapheme_Cluster_Break_ZWJ[] = {
+ 1,
+ 0x200d, 0x200d,
+}; /* CR_Grapheme_Cluster_Break_ZWJ */
+
+/* 'In_Basic_Latin': Block */
+#define CR_In_Basic_Latin CR_ASCII
+
+/* 'In_Latin_1_Supplement': Block */
+static const OnigCodePoint CR_In_Latin_1_Supplement[] = {
+ 1,
+ 0x0080, 0x00ff,
+}; /* CR_In_Latin_1_Supplement */
+
+/* 'In_Latin_Extended_A': Block */
+static const OnigCodePoint CR_In_Latin_Extended_A[] = {
+ 1,
+ 0x0100, 0x017f,
+}; /* CR_In_Latin_Extended_A */
+
+/* 'In_Latin_Extended_B': Block */
+static const OnigCodePoint CR_In_Latin_Extended_B[] = {
+ 1,
+ 0x0180, 0x024f,
+}; /* CR_In_Latin_Extended_B */
+
+/* 'In_IPA_Extensions': Block */
+static const OnigCodePoint CR_In_IPA_Extensions[] = {
+ 1,
+ 0x0250, 0x02af,
+}; /* CR_In_IPA_Extensions */
+
+/* 'In_Spacing_Modifier_Letters': Block */
+static const OnigCodePoint CR_In_Spacing_Modifier_Letters[] = {
+ 1,
+ 0x02b0, 0x02ff,
+}; /* CR_In_Spacing_Modifier_Letters */
+
+/* 'In_Combining_Diacritical_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks[] = {
+ 1,
+ 0x0300, 0x036f,
+}; /* CR_In_Combining_Diacritical_Marks */
+
+/* 'In_Greek_and_Coptic': Block */
+static const OnigCodePoint CR_In_Greek_and_Coptic[] = {
+ 1,
+ 0x0370, 0x03ff,
+}; /* CR_In_Greek_and_Coptic */
+
+/* 'In_Cyrillic': Block */
+static const OnigCodePoint CR_In_Cyrillic[] = {
+ 1,
+ 0x0400, 0x04ff,
+}; /* CR_In_Cyrillic */
+
+/* 'In_Cyrillic_Supplement': Block */
+static const OnigCodePoint CR_In_Cyrillic_Supplement[] = {
+ 1,
+ 0x0500, 0x052f,
+}; /* CR_In_Cyrillic_Supplement */
+
+/* 'In_Armenian': Block */
+static const OnigCodePoint CR_In_Armenian[] = {
+ 1,
+ 0x0530, 0x058f,
+}; /* CR_In_Armenian */
+
+/* 'In_Hebrew': Block */
+static const OnigCodePoint CR_In_Hebrew[] = {
+ 1,
+ 0x0590, 0x05ff,
+}; /* CR_In_Hebrew */
+
+/* 'In_Arabic': Block */
+static const OnigCodePoint CR_In_Arabic[] = {
+ 1,
+ 0x0600, 0x06ff,
+}; /* CR_In_Arabic */
+
+/* 'In_Syriac': Block */
+static const OnigCodePoint CR_In_Syriac[] = {
+ 1,
+ 0x0700, 0x074f,
+}; /* CR_In_Syriac */
+
+/* 'In_Arabic_Supplement': Block */
+static const OnigCodePoint CR_In_Arabic_Supplement[] = {
+ 1,
+ 0x0750, 0x077f,
+}; /* CR_In_Arabic_Supplement */
+
+/* 'In_Thaana': Block */
+static const OnigCodePoint CR_In_Thaana[] = {
+ 1,
+ 0x0780, 0x07bf,
+}; /* CR_In_Thaana */
+
+/* 'In_NKo': Block */
+static const OnigCodePoint CR_In_NKo[] = {
+ 1,
+ 0x07c0, 0x07ff,
+}; /* CR_In_NKo */
+
+/* 'In_Samaritan': Block */
+static const OnigCodePoint CR_In_Samaritan[] = {
+ 1,
+ 0x0800, 0x083f,
+}; /* CR_In_Samaritan */
+
+/* 'In_Mandaic': Block */
+static const OnigCodePoint CR_In_Mandaic[] = {
+ 1,
+ 0x0840, 0x085f,
+}; /* CR_In_Mandaic */
+
+/* 'In_Syriac_Supplement': Block */
+static const OnigCodePoint CR_In_Syriac_Supplement[] = {
+ 1,
+ 0x0860, 0x086f,
+}; /* CR_In_Syriac_Supplement */
+
+/* 'In_Arabic_Extended_B': Block */
+static const OnigCodePoint CR_In_Arabic_Extended_B[] = {
+ 1,
+ 0x0870, 0x089f,
+}; /* CR_In_Arabic_Extended_B */
+
+/* 'In_Arabic_Extended_A': Block */
+static const OnigCodePoint CR_In_Arabic_Extended_A[] = {
+ 1,
+ 0x08a0, 0x08ff,
+}; /* CR_In_Arabic_Extended_A */
+
+/* 'In_Devanagari': Block */
+static const OnigCodePoint CR_In_Devanagari[] = {
+ 1,
+ 0x0900, 0x097f,
+}; /* CR_In_Devanagari */
+
+/* 'In_Bengali': Block */
+static const OnigCodePoint CR_In_Bengali[] = {
+ 1,
+ 0x0980, 0x09ff,
+}; /* CR_In_Bengali */
+
+/* 'In_Gurmukhi': Block */
+static const OnigCodePoint CR_In_Gurmukhi[] = {
+ 1,
+ 0x0a00, 0x0a7f,
+}; /* CR_In_Gurmukhi */
+
+/* 'In_Gujarati': Block */
+static const OnigCodePoint CR_In_Gujarati[] = {
+ 1,
+ 0x0a80, 0x0aff,
+}; /* CR_In_Gujarati */
+
+/* 'In_Oriya': Block */
+static const OnigCodePoint CR_In_Oriya[] = {
+ 1,
+ 0x0b00, 0x0b7f,
+}; /* CR_In_Oriya */
+
+/* 'In_Tamil': Block */
+static const OnigCodePoint CR_In_Tamil[] = {
+ 1,
+ 0x0b80, 0x0bff,
+}; /* CR_In_Tamil */
+
+/* 'In_Telugu': Block */
+static const OnigCodePoint CR_In_Telugu[] = {
+ 1,
+ 0x0c00, 0x0c7f,
+}; /* CR_In_Telugu */
+
+/* 'In_Kannada': Block */
+static const OnigCodePoint CR_In_Kannada[] = {
+ 1,
+ 0x0c80, 0x0cff,
+}; /* CR_In_Kannada */
+
+/* 'In_Malayalam': Block */
+static const OnigCodePoint CR_In_Malayalam[] = {
+ 1,
+ 0x0d00, 0x0d7f,
+}; /* CR_In_Malayalam */
+
+/* 'In_Sinhala': Block */
+static const OnigCodePoint CR_In_Sinhala[] = {
+ 1,
+ 0x0d80, 0x0dff,
+}; /* CR_In_Sinhala */
+
+/* 'In_Thai': Block */
+static const OnigCodePoint CR_In_Thai[] = {
+ 1,
+ 0x0e00, 0x0e7f,
+}; /* CR_In_Thai */
+
+/* 'In_Lao': Block */
+static const OnigCodePoint CR_In_Lao[] = {
+ 1,
+ 0x0e80, 0x0eff,
+}; /* CR_In_Lao */
+
+/* 'In_Tibetan': Block */
+static const OnigCodePoint CR_In_Tibetan[] = {
+ 1,
+ 0x0f00, 0x0fff,
+}; /* CR_In_Tibetan */
+
+/* 'In_Myanmar': Block */
+static const OnigCodePoint CR_In_Myanmar[] = {
+ 1,
+ 0x1000, 0x109f,
+}; /* CR_In_Myanmar */
+
+/* 'In_Georgian': Block */
+static const OnigCodePoint CR_In_Georgian[] = {
+ 1,
+ 0x10a0, 0x10ff,
+}; /* CR_In_Georgian */
+
+/* 'In_Hangul_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo[] = {
+ 1,
+ 0x1100, 0x11ff,
+}; /* CR_In_Hangul_Jamo */
+
+/* 'In_Ethiopic': Block */
+static const OnigCodePoint CR_In_Ethiopic[] = {
+ 1,
+ 0x1200, 0x137f,
+}; /* CR_In_Ethiopic */
+
+/* 'In_Ethiopic_Supplement': Block */
+static const OnigCodePoint CR_In_Ethiopic_Supplement[] = {
+ 1,
+ 0x1380, 0x139f,
+}; /* CR_In_Ethiopic_Supplement */
+
+/* 'In_Cherokee': Block */
+static const OnigCodePoint CR_In_Cherokee[] = {
+ 1,
+ 0x13a0, 0x13ff,
+}; /* CR_In_Cherokee */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics[] = {
+ 1,
+ 0x1400, 0x167f,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics */
+
+/* 'In_Ogham': Block */
+static const OnigCodePoint CR_In_Ogham[] = {
+ 1,
+ 0x1680, 0x169f,
+}; /* CR_In_Ogham */
+
+/* 'In_Runic': Block */
+static const OnigCodePoint CR_In_Runic[] = {
+ 1,
+ 0x16a0, 0x16ff,
+}; /* CR_In_Runic */
+
+/* 'In_Tagalog': Block */
+static const OnigCodePoint CR_In_Tagalog[] = {
+ 1,
+ 0x1700, 0x171f,
+}; /* CR_In_Tagalog */
+
+/* 'In_Hanunoo': Block */
+static const OnigCodePoint CR_In_Hanunoo[] = {
+ 1,
+ 0x1720, 0x173f,
+}; /* CR_In_Hanunoo */
+
+/* 'In_Buhid': Block */
+static const OnigCodePoint CR_In_Buhid[] = {
+ 1,
+ 0x1740, 0x175f,
+}; /* CR_In_Buhid */
+
+/* 'In_Tagbanwa': Block */
+static const OnigCodePoint CR_In_Tagbanwa[] = {
+ 1,
+ 0x1760, 0x177f,
+}; /* CR_In_Tagbanwa */
+
+/* 'In_Khmer': Block */
+static const OnigCodePoint CR_In_Khmer[] = {
+ 1,
+ 0x1780, 0x17ff,
+}; /* CR_In_Khmer */
+
+/* 'In_Mongolian': Block */
+static const OnigCodePoint CR_In_Mongolian[] = {
+ 1,
+ 0x1800, 0x18af,
+}; /* CR_In_Mongolian */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended[] = {
+ 1,
+ 0x18b0, 0x18ff,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended */
+
+/* 'In_Limbu': Block */
+static const OnigCodePoint CR_In_Limbu[] = {
+ 1,
+ 0x1900, 0x194f,
+}; /* CR_In_Limbu */
+
+/* 'In_Tai_Le': Block */
+static const OnigCodePoint CR_In_Tai_Le[] = {
+ 1,
+ 0x1950, 0x197f,
+}; /* CR_In_Tai_Le */
+
+/* 'In_New_Tai_Lue': Block */
+static const OnigCodePoint CR_In_New_Tai_Lue[] = {
+ 1,
+ 0x1980, 0x19df,
+}; /* CR_In_New_Tai_Lue */
+
+/* 'In_Khmer_Symbols': Block */
+static const OnigCodePoint CR_In_Khmer_Symbols[] = {
+ 1,
+ 0x19e0, 0x19ff,
+}; /* CR_In_Khmer_Symbols */
+
+/* 'In_Buginese': Block */
+static const OnigCodePoint CR_In_Buginese[] = {
+ 1,
+ 0x1a00, 0x1a1f,
+}; /* CR_In_Buginese */
+
+/* 'In_Tai_Tham': Block */
+static const OnigCodePoint CR_In_Tai_Tham[] = {
+ 1,
+ 0x1a20, 0x1aaf,
+}; /* CR_In_Tai_Tham */
+
+/* 'In_Combining_Diacritical_Marks_Extended': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Extended[] = {
+ 1,
+ 0x1ab0, 0x1aff,
+}; /* CR_In_Combining_Diacritical_Marks_Extended */
+
+/* 'In_Balinese': Block */
+static const OnigCodePoint CR_In_Balinese[] = {
+ 1,
+ 0x1b00, 0x1b7f,
+}; /* CR_In_Balinese */
+
+/* 'In_Sundanese': Block */
+static const OnigCodePoint CR_In_Sundanese[] = {
+ 1,
+ 0x1b80, 0x1bbf,
+}; /* CR_In_Sundanese */
+
+/* 'In_Batak': Block */
+static const OnigCodePoint CR_In_Batak[] = {
+ 1,
+ 0x1bc0, 0x1bff,
+}; /* CR_In_Batak */
+
+/* 'In_Lepcha': Block */
+static const OnigCodePoint CR_In_Lepcha[] = {
+ 1,
+ 0x1c00, 0x1c4f,
+}; /* CR_In_Lepcha */
+
+/* 'In_Ol_Chiki': Block */
+#define CR_In_Ol_Chiki CR_Ol_Chiki
+
+/* 'In_Cyrillic_Extended_C': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_C[] = {
+ 1,
+ 0x1c80, 0x1c8f,
+}; /* CR_In_Cyrillic_Extended_C */
+
+/* 'In_Georgian_Extended': Block */
+static const OnigCodePoint CR_In_Georgian_Extended[] = {
+ 1,
+ 0x1c90, 0x1cbf,
+}; /* CR_In_Georgian_Extended */
+
+/* 'In_Sundanese_Supplement': Block */
+static const OnigCodePoint CR_In_Sundanese_Supplement[] = {
+ 1,
+ 0x1cc0, 0x1ccf,
+}; /* CR_In_Sundanese_Supplement */
+
+/* 'In_Vedic_Extensions': Block */
+static const OnigCodePoint CR_In_Vedic_Extensions[] = {
+ 1,
+ 0x1cd0, 0x1cff,
+}; /* CR_In_Vedic_Extensions */
+
+/* 'In_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions[] = {
+ 1,
+ 0x1d00, 0x1d7f,
+}; /* CR_In_Phonetic_Extensions */
+
+/* 'In_Phonetic_Extensions_Supplement': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions_Supplement[] = {
+ 1,
+ 0x1d80, 0x1dbf,
+}; /* CR_In_Phonetic_Extensions_Supplement */
+
+/* 'In_Combining_Diacritical_Marks_Supplement': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Supplement[] = {
+ 1,
+ 0x1dc0, 0x1dff,
+}; /* CR_In_Combining_Diacritical_Marks_Supplement */
+
+/* 'In_Latin_Extended_Additional': Block */
+static const OnigCodePoint CR_In_Latin_Extended_Additional[] = {
+ 1,
+ 0x1e00, 0x1eff,
+}; /* CR_In_Latin_Extended_Additional */
+
+/* 'In_Greek_Extended': Block */
+static const OnigCodePoint CR_In_Greek_Extended[] = {
+ 1,
+ 0x1f00, 0x1fff,
+}; /* CR_In_Greek_Extended */
+
+/* 'In_General_Punctuation': Block */
+static const OnigCodePoint CR_In_General_Punctuation[] = {
+ 1,
+ 0x2000, 0x206f,
+}; /* CR_In_General_Punctuation */
+
+/* 'In_Superscripts_and_Subscripts': Block */
+static const OnigCodePoint CR_In_Superscripts_and_Subscripts[] = {
+ 1,
+ 0x2070, 0x209f,
+}; /* CR_In_Superscripts_and_Subscripts */
+
+/* 'In_Currency_Symbols': Block */
+static const OnigCodePoint CR_In_Currency_Symbols[] = {
+ 1,
+ 0x20a0, 0x20cf,
+}; /* CR_In_Currency_Symbols */
+
+/* 'In_Combining_Diacritical_Marks_for_Symbols': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_for_Symbols[] = {
+ 1,
+ 0x20d0, 0x20ff,
+}; /* CR_In_Combining_Diacritical_Marks_for_Symbols */
+
+/* 'In_Letterlike_Symbols': Block */
+static const OnigCodePoint CR_In_Letterlike_Symbols[] = {
+ 1,
+ 0x2100, 0x214f,
+}; /* CR_In_Letterlike_Symbols */
+
+/* 'In_Number_Forms': Block */
+static const OnigCodePoint CR_In_Number_Forms[] = {
+ 1,
+ 0x2150, 0x218f,
+}; /* CR_In_Number_Forms */
+
+/* 'In_Arrows': Block */
+static const OnigCodePoint CR_In_Arrows[] = {
+ 1,
+ 0x2190, 0x21ff,
+}; /* CR_In_Arrows */
+
+/* 'In_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Mathematical_Operators[] = {
+ 1,
+ 0x2200, 0x22ff,
+}; /* CR_In_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Technical': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Technical[] = {
+ 1,
+ 0x2300, 0x23ff,
+}; /* CR_In_Miscellaneous_Technical */
+
+/* 'In_Control_Pictures': Block */
+static const OnigCodePoint CR_In_Control_Pictures[] = {
+ 1,
+ 0x2400, 0x243f,
+}; /* CR_In_Control_Pictures */
+
+/* 'In_Optical_Character_Recognition': Block */
+static const OnigCodePoint CR_In_Optical_Character_Recognition[] = {
+ 1,
+ 0x2440, 0x245f,
+}; /* CR_In_Optical_Character_Recognition */
+
+/* 'In_Enclosed_Alphanumerics': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumerics[] = {
+ 1,
+ 0x2460, 0x24ff,
+}; /* CR_In_Enclosed_Alphanumerics */
+
+/* 'In_Box_Drawing': Block */
+static const OnigCodePoint CR_In_Box_Drawing[] = {
+ 1,
+ 0x2500, 0x257f,
+}; /* CR_In_Box_Drawing */
+
+/* 'In_Block_Elements': Block */
+static const OnigCodePoint CR_In_Block_Elements[] = {
+ 1,
+ 0x2580, 0x259f,
+}; /* CR_In_Block_Elements */
+
+/* 'In_Geometric_Shapes': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes[] = {
+ 1,
+ 0x25a0, 0x25ff,
+}; /* CR_In_Geometric_Shapes */
+
+/* 'In_Miscellaneous_Symbols': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols[] = {
+ 1,
+ 0x2600, 0x26ff,
+}; /* CR_In_Miscellaneous_Symbols */
+
+/* 'In_Dingbats': Block */
+static const OnigCodePoint CR_In_Dingbats[] = {
+ 1,
+ 0x2700, 0x27bf,
+}; /* CR_In_Dingbats */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_A': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_A[] = {
+ 1,
+ 0x27c0, 0x27ef,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_A */
+
+/* 'In_Supplemental_Arrows_A': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_A[] = {
+ 1,
+ 0x27f0, 0x27ff,
+}; /* CR_In_Supplemental_Arrows_A */
+
+/* 'In_Braille_Patterns': Block */
+#define CR_In_Braille_Patterns CR_Braille
+
+/* 'In_Supplemental_Arrows_B': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_B[] = {
+ 1,
+ 0x2900, 0x297f,
+}; /* CR_In_Supplemental_Arrows_B */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_B': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_B[] = {
+ 1,
+ 0x2980, 0x29ff,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_B */
+
+/* 'In_Supplemental_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Supplemental_Mathematical_Operators[] = {
+ 1,
+ 0x2a00, 0x2aff,
+}; /* CR_In_Supplemental_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Symbols_and_Arrows': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Arrows[] = {
+ 1,
+ 0x2b00, 0x2bff,
+}; /* CR_In_Miscellaneous_Symbols_and_Arrows */
+
+/* 'In_Glagolitic': Block */
+static const OnigCodePoint CR_In_Glagolitic[] = {
+ 1,
+ 0x2c00, 0x2c5f,
+}; /* CR_In_Glagolitic */
+
+/* 'In_Latin_Extended_C': Block */
+static const OnigCodePoint CR_In_Latin_Extended_C[] = {
+ 1,
+ 0x2c60, 0x2c7f,
+}; /* CR_In_Latin_Extended_C */
+
+/* 'In_Coptic': Block */
+static const OnigCodePoint CR_In_Coptic[] = {
+ 1,
+ 0x2c80, 0x2cff,
+}; /* CR_In_Coptic */
+
+/* 'In_Georgian_Supplement': Block */
+static const OnigCodePoint CR_In_Georgian_Supplement[] = {
+ 1,
+ 0x2d00, 0x2d2f,
+}; /* CR_In_Georgian_Supplement */
+
+/* 'In_Tifinagh': Block */
+static const OnigCodePoint CR_In_Tifinagh[] = {
+ 1,
+ 0x2d30, 0x2d7f,
+}; /* CR_In_Tifinagh */
+
+/* 'In_Ethiopic_Extended': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended[] = {
+ 1,
+ 0x2d80, 0x2ddf,
+}; /* CR_In_Ethiopic_Extended */
+
+/* 'In_Cyrillic_Extended_A': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_A[] = {
+ 1,
+ 0x2de0, 0x2dff,
+}; /* CR_In_Cyrillic_Extended_A */
+
+/* 'In_Supplemental_Punctuation': Block */
+static const OnigCodePoint CR_In_Supplemental_Punctuation[] = {
+ 1,
+ 0x2e00, 0x2e7f,
+}; /* CR_In_Supplemental_Punctuation */
+
+/* 'In_CJK_Radicals_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Radicals_Supplement[] = {
+ 1,
+ 0x2e80, 0x2eff,
+}; /* CR_In_CJK_Radicals_Supplement */
+
+/* 'In_Kangxi_Radicals': Block */
+static const OnigCodePoint CR_In_Kangxi_Radicals[] = {
+ 1,
+ 0x2f00, 0x2fdf,
+}; /* CR_In_Kangxi_Radicals */
+
+/* 'In_Ideographic_Description_Characters': Block */
+static const OnigCodePoint CR_In_Ideographic_Description_Characters[] = {
+ 1,
+ 0x2ff0, 0x2fff,
+}; /* CR_In_Ideographic_Description_Characters */
+
+/* 'In_CJK_Symbols_and_Punctuation': Block */
+static const OnigCodePoint CR_In_CJK_Symbols_and_Punctuation[] = {
+ 1,
+ 0x3000, 0x303f,
+}; /* CR_In_CJK_Symbols_and_Punctuation */
+
+/* 'In_Hiragana': Block */
+static const OnigCodePoint CR_In_Hiragana[] = {
+ 1,
+ 0x3040, 0x309f,
+}; /* CR_In_Hiragana */
+
+/* 'In_Katakana': Block */
+static const OnigCodePoint CR_In_Katakana[] = {
+ 1,
+ 0x30a0, 0x30ff,
+}; /* CR_In_Katakana */
+
+/* 'In_Bopomofo': Block */
+static const OnigCodePoint CR_In_Bopomofo[] = {
+ 1,
+ 0x3100, 0x312f,
+}; /* CR_In_Bopomofo */
+
+/* 'In_Hangul_Compatibility_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Compatibility_Jamo[] = {
+ 1,
+ 0x3130, 0x318f,
+}; /* CR_In_Hangul_Compatibility_Jamo */
+
+/* 'In_Kanbun': Block */
+static const OnigCodePoint CR_In_Kanbun[] = {
+ 1,
+ 0x3190, 0x319f,
+}; /* CR_In_Kanbun */
+
+/* 'In_Bopomofo_Extended': Block */
+static const OnigCodePoint CR_In_Bopomofo_Extended[] = {
+ 1,
+ 0x31a0, 0x31bf,
+}; /* CR_In_Bopomofo_Extended */
+
+/* 'In_CJK_Strokes': Block */
+static const OnigCodePoint CR_In_CJK_Strokes[] = {
+ 1,
+ 0x31c0, 0x31ef,
+}; /* CR_In_CJK_Strokes */
+
+/* 'In_Katakana_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Katakana_Phonetic_Extensions[] = {
+ 1,
+ 0x31f0, 0x31ff,
+}; /* CR_In_Katakana_Phonetic_Extensions */
+
+/* 'In_Enclosed_CJK_Letters_and_Months': Block */
+static const OnigCodePoint CR_In_Enclosed_CJK_Letters_and_Months[] = {
+ 1,
+ 0x3200, 0x32ff,
+}; /* CR_In_Enclosed_CJK_Letters_and_Months */
+
+/* 'In_CJK_Compatibility': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility[] = {
+ 1,
+ 0x3300, 0x33ff,
+}; /* CR_In_CJK_Compatibility */
+
+/* 'In_CJK_Unified_Ideographs_Extension_A': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_A[] = {
+ 1,
+ 0x3400, 0x4dbf,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_A */
+
+/* 'In_Yijing_Hexagram_Symbols': Block */
+static const OnigCodePoint CR_In_Yijing_Hexagram_Symbols[] = {
+ 1,
+ 0x4dc0, 0x4dff,
+}; /* CR_In_Yijing_Hexagram_Symbols */
+
+/* 'In_CJK_Unified_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs[] = {
+ 1,
+ 0x4e00, 0x9fff,
+}; /* CR_In_CJK_Unified_Ideographs */
+
+/* 'In_Yi_Syllables': Block */
+static const OnigCodePoint CR_In_Yi_Syllables[] = {
+ 1,
+ 0xa000, 0xa48f,
+}; /* CR_In_Yi_Syllables */
+
+/* 'In_Yi_Radicals': Block */
+static const OnigCodePoint CR_In_Yi_Radicals[] = {
+ 1,
+ 0xa490, 0xa4cf,
+}; /* CR_In_Yi_Radicals */
+
+/* 'In_Lisu': Block */
+static const OnigCodePoint CR_In_Lisu[] = {
+ 1,
+ 0xa4d0, 0xa4ff,
+}; /* CR_In_Lisu */
+
+/* 'In_Vai': Block */
+static const OnigCodePoint CR_In_Vai[] = {
+ 1,
+ 0xa500, 0xa63f,
+}; /* CR_In_Vai */
+
+/* 'In_Cyrillic_Extended_B': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_B[] = {
+ 1,
+ 0xa640, 0xa69f,
+}; /* CR_In_Cyrillic_Extended_B */
+
+/* 'In_Bamum': Block */
+static const OnigCodePoint CR_In_Bamum[] = {
+ 1,
+ 0xa6a0, 0xa6ff,
+}; /* CR_In_Bamum */
+
+/* 'In_Modifier_Tone_Letters': Block */
+static const OnigCodePoint CR_In_Modifier_Tone_Letters[] = {
+ 1,
+ 0xa700, 0xa71f,
+}; /* CR_In_Modifier_Tone_Letters */
+
+/* 'In_Latin_Extended_D': Block */
+static const OnigCodePoint CR_In_Latin_Extended_D[] = {
+ 1,
+ 0xa720, 0xa7ff,
+}; /* CR_In_Latin_Extended_D */
+
+/* 'In_Syloti_Nagri': Block */
+static const OnigCodePoint CR_In_Syloti_Nagri[] = {
+ 1,
+ 0xa800, 0xa82f,
+}; /* CR_In_Syloti_Nagri */
+
+/* 'In_Common_Indic_Number_Forms': Block */
+static const OnigCodePoint CR_In_Common_Indic_Number_Forms[] = {
+ 1,
+ 0xa830, 0xa83f,
+}; /* CR_In_Common_Indic_Number_Forms */
+
+/* 'In_Phags_pa': Block */
+static const OnigCodePoint CR_In_Phags_pa[] = {
+ 1,
+ 0xa840, 0xa87f,
+}; /* CR_In_Phags_pa */
+
+/* 'In_Saurashtra': Block */
+static const OnigCodePoint CR_In_Saurashtra[] = {
+ 1,
+ 0xa880, 0xa8df,
+}; /* CR_In_Saurashtra */
+
+/* 'In_Devanagari_Extended': Block */
+static const OnigCodePoint CR_In_Devanagari_Extended[] = {
+ 1,
+ 0xa8e0, 0xa8ff,
+}; /* CR_In_Devanagari_Extended */
+
+/* 'In_Kayah_Li': Block */
+static const OnigCodePoint CR_In_Kayah_Li[] = {
+ 1,
+ 0xa900, 0xa92f,
+}; /* CR_In_Kayah_Li */
+
+/* 'In_Rejang': Block */
+static const OnigCodePoint CR_In_Rejang[] = {
+ 1,
+ 0xa930, 0xa95f,
+}; /* CR_In_Rejang */
+
+/* 'In_Hangul_Jamo_Extended_A': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_A[] = {
+ 1,
+ 0xa960, 0xa97f,
+}; /* CR_In_Hangul_Jamo_Extended_A */
+
+/* 'In_Javanese': Block */
+static const OnigCodePoint CR_In_Javanese[] = {
+ 1,
+ 0xa980, 0xa9df,
+}; /* CR_In_Javanese */
+
+/* 'In_Myanmar_Extended_B': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_B[] = {
+ 1,
+ 0xa9e0, 0xa9ff,
+}; /* CR_In_Myanmar_Extended_B */
+
+/* 'In_Cham': Block */
+static const OnigCodePoint CR_In_Cham[] = {
+ 1,
+ 0xaa00, 0xaa5f,
+}; /* CR_In_Cham */
+
+/* 'In_Myanmar_Extended_A': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_A[] = {
+ 1,
+ 0xaa60, 0xaa7f,
+}; /* CR_In_Myanmar_Extended_A */
+
+/* 'In_Tai_Viet': Block */
+static const OnigCodePoint CR_In_Tai_Viet[] = {
+ 1,
+ 0xaa80, 0xaadf,
+}; /* CR_In_Tai_Viet */
+
+/* 'In_Meetei_Mayek_Extensions': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek_Extensions[] = {
+ 1,
+ 0xaae0, 0xaaff,
+}; /* CR_In_Meetei_Mayek_Extensions */
+
+/* 'In_Ethiopic_Extended_A': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended_A[] = {
+ 1,
+ 0xab00, 0xab2f,
+}; /* CR_In_Ethiopic_Extended_A */
+
+/* 'In_Latin_Extended_E': Block */
+static const OnigCodePoint CR_In_Latin_Extended_E[] = {
+ 1,
+ 0xab30, 0xab6f,
+}; /* CR_In_Latin_Extended_E */
+
+/* 'In_Cherokee_Supplement': Block */
+static const OnigCodePoint CR_In_Cherokee_Supplement[] = {
+ 1,
+ 0xab70, 0xabbf,
+}; /* CR_In_Cherokee_Supplement */
+
+/* 'In_Meetei_Mayek': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek[] = {
+ 1,
+ 0xabc0, 0xabff,
+}; /* CR_In_Meetei_Mayek */
+
+/* 'In_Hangul_Syllables': Block */
+static const OnigCodePoint CR_In_Hangul_Syllables[] = {
+ 1,
+ 0xac00, 0xd7af,
+}; /* CR_In_Hangul_Syllables */
+
+/* 'In_Hangul_Jamo_Extended_B': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_B[] = {
+ 1,
+ 0xd7b0, 0xd7ff,
+}; /* CR_In_Hangul_Jamo_Extended_B */
+
+/* 'In_High_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Surrogates[] = {
+ 1,
+ 0xd800, 0xdb7f,
+}; /* CR_In_High_Surrogates */
+
+/* 'In_High_Private_Use_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Private_Use_Surrogates[] = {
+ 1,
+ 0xdb80, 0xdbff,
+}; /* CR_In_High_Private_Use_Surrogates */
+
+/* 'In_Low_Surrogates': Block */
+static const OnigCodePoint CR_In_Low_Surrogates[] = {
+ 1,
+ 0xdc00, 0xdfff,
+}; /* CR_In_Low_Surrogates */
+
+/* 'In_Private_Use_Area': Block */
+static const OnigCodePoint CR_In_Private_Use_Area[] = {
+ 1,
+ 0xe000, 0xf8ff,
+}; /* CR_In_Private_Use_Area */
+
+/* 'In_CJK_Compatibility_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs[] = {
+ 1,
+ 0xf900, 0xfaff,
+}; /* CR_In_CJK_Compatibility_Ideographs */
+
+/* 'In_Alphabetic_Presentation_Forms': Block */
+static const OnigCodePoint CR_In_Alphabetic_Presentation_Forms[] = {
+ 1,
+ 0xfb00, 0xfb4f,
+}; /* CR_In_Alphabetic_Presentation_Forms */
+
+/* 'In_Arabic_Presentation_Forms_A': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_A[] = {
+ 1,
+ 0xfb50, 0xfdff,
+}; /* CR_In_Arabic_Presentation_Forms_A */
+
+/* 'In_Variation_Selectors': Block */
+static const OnigCodePoint CR_In_Variation_Selectors[] = {
+ 1,
+ 0xfe00, 0xfe0f,
+}; /* CR_In_Variation_Selectors */
+
+/* 'In_Vertical_Forms': Block */
+static const OnigCodePoint CR_In_Vertical_Forms[] = {
+ 1,
+ 0xfe10, 0xfe1f,
+}; /* CR_In_Vertical_Forms */
+
+/* 'In_Combining_Half_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Half_Marks[] = {
+ 1,
+ 0xfe20, 0xfe2f,
+}; /* CR_In_Combining_Half_Marks */
+
+/* 'In_CJK_Compatibility_Forms': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Forms[] = {
+ 1,
+ 0xfe30, 0xfe4f,
+}; /* CR_In_CJK_Compatibility_Forms */
+
+/* 'In_Small_Form_Variants': Block */
+static const OnigCodePoint CR_In_Small_Form_Variants[] = {
+ 1,
+ 0xfe50, 0xfe6f,
+}; /* CR_In_Small_Form_Variants */
+
+/* 'In_Arabic_Presentation_Forms_B': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_B[] = {
+ 1,
+ 0xfe70, 0xfeff,
+}; /* CR_In_Arabic_Presentation_Forms_B */
+
+/* 'In_Halfwidth_and_Fullwidth_Forms': Block */
+static const OnigCodePoint CR_In_Halfwidth_and_Fullwidth_Forms[] = {
+ 1,
+ 0xff00, 0xffef,
+}; /* CR_In_Halfwidth_and_Fullwidth_Forms */
+
+/* 'In_Specials': Block */
+static const OnigCodePoint CR_In_Specials[] = {
+ 1,
+ 0xfff0, 0xffff,
+}; /* CR_In_Specials */
+
+/* 'In_Linear_B_Syllabary': Block */
+static const OnigCodePoint CR_In_Linear_B_Syllabary[] = {
+ 1,
+ 0x10000, 0x1007f,
+}; /* CR_In_Linear_B_Syllabary */
+
+/* 'In_Linear_B_Ideograms': Block */
+static const OnigCodePoint CR_In_Linear_B_Ideograms[] = {
+ 1,
+ 0x10080, 0x100ff,
+}; /* CR_In_Linear_B_Ideograms */
+
+/* 'In_Aegean_Numbers': Block */
+static const OnigCodePoint CR_In_Aegean_Numbers[] = {
+ 1,
+ 0x10100, 0x1013f,
+}; /* CR_In_Aegean_Numbers */
+
+/* 'In_Ancient_Greek_Numbers': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Numbers[] = {
+ 1,
+ 0x10140, 0x1018f,
+}; /* CR_In_Ancient_Greek_Numbers */
+
+/* 'In_Ancient_Symbols': Block */
+static const OnigCodePoint CR_In_Ancient_Symbols[] = {
+ 1,
+ 0x10190, 0x101cf,
+}; /* CR_In_Ancient_Symbols */
+
+/* 'In_Phaistos_Disc': Block */
+static const OnigCodePoint CR_In_Phaistos_Disc[] = {
+ 1,
+ 0x101d0, 0x101ff,
+}; /* CR_In_Phaistos_Disc */
+
+/* 'In_Lycian': Block */
+static const OnigCodePoint CR_In_Lycian[] = {
+ 1,
+ 0x10280, 0x1029f,
+}; /* CR_In_Lycian */
+
+/* 'In_Carian': Block */
+static const OnigCodePoint CR_In_Carian[] = {
+ 1,
+ 0x102a0, 0x102df,
+}; /* CR_In_Carian */
+
+/* 'In_Coptic_Epact_Numbers': Block */
+static const OnigCodePoint CR_In_Coptic_Epact_Numbers[] = {
+ 1,
+ 0x102e0, 0x102ff,
+}; /* CR_In_Coptic_Epact_Numbers */
+
+/* 'In_Old_Italic': Block */
+static const OnigCodePoint CR_In_Old_Italic[] = {
+ 1,
+ 0x10300, 0x1032f,
+}; /* CR_In_Old_Italic */
+
+/* 'In_Gothic': Block */
+static const OnigCodePoint CR_In_Gothic[] = {
+ 1,
+ 0x10330, 0x1034f,
+}; /* CR_In_Gothic */
+
+/* 'In_Old_Permic': Block */
+static const OnigCodePoint CR_In_Old_Permic[] = {
+ 1,
+ 0x10350, 0x1037f,
+}; /* CR_In_Old_Permic */
+
+/* 'In_Ugaritic': Block */
+static const OnigCodePoint CR_In_Ugaritic[] = {
+ 1,
+ 0x10380, 0x1039f,
+}; /* CR_In_Ugaritic */
+
+/* 'In_Old_Persian': Block */
+static const OnigCodePoint CR_In_Old_Persian[] = {
+ 1,
+ 0x103a0, 0x103df,
+}; /* CR_In_Old_Persian */
+
+/* 'In_Deseret': Block */
+#define CR_In_Deseret CR_Deseret
+
+/* 'In_Shavian': Block */
+#define CR_In_Shavian CR_Shavian
+
+/* 'In_Osmanya': Block */
+static const OnigCodePoint CR_In_Osmanya[] = {
+ 1,
+ 0x10480, 0x104af,
+}; /* CR_In_Osmanya */
+
+/* 'In_Osage': Block */
+static const OnigCodePoint CR_In_Osage[] = {
+ 1,
+ 0x104b0, 0x104ff,
+}; /* CR_In_Osage */
+
+/* 'In_Elbasan': Block */
+static const OnigCodePoint CR_In_Elbasan[] = {
+ 1,
+ 0x10500, 0x1052f,
+}; /* CR_In_Elbasan */
+
+/* 'In_Caucasian_Albanian': Block */
+static const OnigCodePoint CR_In_Caucasian_Albanian[] = {
+ 1,
+ 0x10530, 0x1056f,
+}; /* CR_In_Caucasian_Albanian */
+
+/* 'In_Vithkuqi': Block */
+static const OnigCodePoint CR_In_Vithkuqi[] = {
+ 1,
+ 0x10570, 0x105bf,
+}; /* CR_In_Vithkuqi */
+
+/* 'In_Todhri': Block */
+static const OnigCodePoint CR_In_Todhri[] = {
+ 1,
+ 0x105c0, 0x105ff,
+}; /* CR_In_Todhri */
+
+/* 'In_Linear_A': Block */
+static const OnigCodePoint CR_In_Linear_A[] = {
+ 1,
+ 0x10600, 0x1077f,
+}; /* CR_In_Linear_A */
+
+/* 'In_Latin_Extended_F': Block */
+static const OnigCodePoint CR_In_Latin_Extended_F[] = {
+ 1,
+ 0x10780, 0x107bf,
+}; /* CR_In_Latin_Extended_F */
+
+/* 'In_Cypriot_Syllabary': Block */
+static const OnigCodePoint CR_In_Cypriot_Syllabary[] = {
+ 1,
+ 0x10800, 0x1083f,
+}; /* CR_In_Cypriot_Syllabary */
+
+/* 'In_Imperial_Aramaic': Block */
+static const OnigCodePoint CR_In_Imperial_Aramaic[] = {
+ 1,
+ 0x10840, 0x1085f,
+}; /* CR_In_Imperial_Aramaic */
+
+/* 'In_Palmyrene': Block */
+#define CR_In_Palmyrene CR_Palmyrene
+
+/* 'In_Nabataean': Block */
+static const OnigCodePoint CR_In_Nabataean[] = {
+ 1,
+ 0x10880, 0x108af,
+}; /* CR_In_Nabataean */
+
+/* 'In_Hatran': Block */
+static const OnigCodePoint CR_In_Hatran[] = {
+ 1,
+ 0x108e0, 0x108ff,
+}; /* CR_In_Hatran */
+
+/* 'In_Phoenician': Block */
+static const OnigCodePoint CR_In_Phoenician[] = {
+ 1,
+ 0x10900, 0x1091f,
+}; /* CR_In_Phoenician */
+
+/* 'In_Lydian': Block */
+static const OnigCodePoint CR_In_Lydian[] = {
+ 1,
+ 0x10920, 0x1093f,
+}; /* CR_In_Lydian */
+
+/* 'In_Sidetic': Block */
+static const OnigCodePoint CR_In_Sidetic[] = {
+ 1,
+ 0x10940, 0x1095f,
+}; /* CR_In_Sidetic */
+
+/* 'In_Meroitic_Hieroglyphs': Block */
+#define CR_In_Meroitic_Hieroglyphs CR_Meroitic_Hieroglyphs
+
+/* 'In_Meroitic_Cursive': Block */
+static const OnigCodePoint CR_In_Meroitic_Cursive[] = {
+ 1,
+ 0x109a0, 0x109ff,
+}; /* CR_In_Meroitic_Cursive */
+
+/* 'In_Kharoshthi': Block */
+static const OnigCodePoint CR_In_Kharoshthi[] = {
+ 1,
+ 0x10a00, 0x10a5f,
+}; /* CR_In_Kharoshthi */
+
+/* 'In_Old_South_Arabian': Block */
+#define CR_In_Old_South_Arabian CR_Old_South_Arabian
+
+/* 'In_Old_North_Arabian': Block */
+#define CR_In_Old_North_Arabian CR_Old_North_Arabian
+
+/* 'In_Manichaean': Block */
+static const OnigCodePoint CR_In_Manichaean[] = {
+ 1,
+ 0x10ac0, 0x10aff,
+}; /* CR_In_Manichaean */
+
+/* 'In_Avestan': Block */
+static const OnigCodePoint CR_In_Avestan[] = {
+ 1,
+ 0x10b00, 0x10b3f,
+}; /* CR_In_Avestan */
+
+/* 'In_Inscriptional_Parthian': Block */
+static const OnigCodePoint CR_In_Inscriptional_Parthian[] = {
+ 1,
+ 0x10b40, 0x10b5f,
+}; /* CR_In_Inscriptional_Parthian */
+
+/* 'In_Inscriptional_Pahlavi': Block */
+static const OnigCodePoint CR_In_Inscriptional_Pahlavi[] = {
+ 1,
+ 0x10b60, 0x10b7f,
+}; /* CR_In_Inscriptional_Pahlavi */
+
+/* 'In_Psalter_Pahlavi': Block */
+static const OnigCodePoint CR_In_Psalter_Pahlavi[] = {
+ 1,
+ 0x10b80, 0x10baf,
+}; /* CR_In_Psalter_Pahlavi */
+
+/* 'In_Old_Turkic': Block */
+static const OnigCodePoint CR_In_Old_Turkic[] = {
+ 1,
+ 0x10c00, 0x10c4f,
+}; /* CR_In_Old_Turkic */
+
+/* 'In_Old_Hungarian': Block */
+static const OnigCodePoint CR_In_Old_Hungarian[] = {
+ 1,
+ 0x10c80, 0x10cff,
+}; /* CR_In_Old_Hungarian */
+
+/* 'In_Hanifi_Rohingya': Block */
+static const OnigCodePoint CR_In_Hanifi_Rohingya[] = {
+ 1,
+ 0x10d00, 0x10d3f,
+}; /* CR_In_Hanifi_Rohingya */
+
+/* 'In_Garay': Block */
+static const OnigCodePoint CR_In_Garay[] = {
+ 1,
+ 0x10d40, 0x10d8f,
+}; /* CR_In_Garay */
+
+/* 'In_Rumi_Numeral_Symbols': Block */
+static const OnigCodePoint CR_In_Rumi_Numeral_Symbols[] = {
+ 1,
+ 0x10e60, 0x10e7f,
+}; /* CR_In_Rumi_Numeral_Symbols */
+
+/* 'In_Yezidi': Block */
+static const OnigCodePoint CR_In_Yezidi[] = {
+ 1,
+ 0x10e80, 0x10ebf,
+}; /* CR_In_Yezidi */
+
+/* 'In_Arabic_Extended_C': Block */
+static const OnigCodePoint CR_In_Arabic_Extended_C[] = {
+ 1,
+ 0x10ec0, 0x10eff,
+}; /* CR_In_Arabic_Extended_C */
+
+/* 'In_Old_Sogdian': Block */
+static const OnigCodePoint CR_In_Old_Sogdian[] = {
+ 1,
+ 0x10f00, 0x10f2f,
+}; /* CR_In_Old_Sogdian */
+
+/* 'In_Sogdian': Block */
+static const OnigCodePoint CR_In_Sogdian[] = {
+ 1,
+ 0x10f30, 0x10f6f,
+}; /* CR_In_Sogdian */
+
+/* 'In_Old_Uyghur': Block */
+static const OnigCodePoint CR_In_Old_Uyghur[] = {
+ 1,
+ 0x10f70, 0x10faf,
+}; /* CR_In_Old_Uyghur */
+
+/* 'In_Chorasmian': Block */
+static const OnigCodePoint CR_In_Chorasmian[] = {
+ 1,
+ 0x10fb0, 0x10fdf,
+}; /* CR_In_Chorasmian */
+
+/* 'In_Elymaic': Block */
+static const OnigCodePoint CR_In_Elymaic[] = {
+ 1,
+ 0x10fe0, 0x10fff,
+}; /* CR_In_Elymaic */
+
+/* 'In_Brahmi': Block */
+static const OnigCodePoint CR_In_Brahmi[] = {
+ 1,
+ 0x11000, 0x1107f,
+}; /* CR_In_Brahmi */
+
+/* 'In_Kaithi': Block */
+static const OnigCodePoint CR_In_Kaithi[] = {
+ 1,
+ 0x11080, 0x110cf,
+}; /* CR_In_Kaithi */
+
+/* 'In_Sora_Sompeng': Block */
+static const OnigCodePoint CR_In_Sora_Sompeng[] = {
+ 1,
+ 0x110d0, 0x110ff,
+}; /* CR_In_Sora_Sompeng */
+
+/* 'In_Chakma': Block */
+static const OnigCodePoint CR_In_Chakma[] = {
+ 1,
+ 0x11100, 0x1114f,
+}; /* CR_In_Chakma */
+
+/* 'In_Mahajani': Block */
+static const OnigCodePoint CR_In_Mahajani[] = {
+ 1,
+ 0x11150, 0x1117f,
+}; /* CR_In_Mahajani */
+
+/* 'In_Sharada': Block */
+static const OnigCodePoint CR_In_Sharada[] = {
+ 1,
+ 0x11180, 0x111df,
+}; /* CR_In_Sharada */
+
+/* 'In_Sinhala_Archaic_Numbers': Block */
+static const OnigCodePoint CR_In_Sinhala_Archaic_Numbers[] = {
+ 1,
+ 0x111e0, 0x111ff,
+}; /* CR_In_Sinhala_Archaic_Numbers */
+
+/* 'In_Khojki': Block */
+static const OnigCodePoint CR_In_Khojki[] = {
+ 1,
+ 0x11200, 0x1124f,
+}; /* CR_In_Khojki */
+
+/* 'In_Multani': Block */
+static const OnigCodePoint CR_In_Multani[] = {
+ 1,
+ 0x11280, 0x112af,
+}; /* CR_In_Multani */
+
+/* 'In_Khudawadi': Block */
+static const OnigCodePoint CR_In_Khudawadi[] = {
+ 1,
+ 0x112b0, 0x112ff,
+}; /* CR_In_Khudawadi */
+
+/* 'In_Grantha': Block */
+static const OnigCodePoint CR_In_Grantha[] = {
+ 1,
+ 0x11300, 0x1137f,
+}; /* CR_In_Grantha */
+
+/* 'In_Tulu_Tigalari': Block */
+static const OnigCodePoint CR_In_Tulu_Tigalari[] = {
+ 1,
+ 0x11380, 0x113ff,
+}; /* CR_In_Tulu_Tigalari */
+
+/* 'In_Newa': Block */
+static const OnigCodePoint CR_In_Newa[] = {
+ 1,
+ 0x11400, 0x1147f,
+}; /* CR_In_Newa */
+
+/* 'In_Tirhuta': Block */
+static const OnigCodePoint CR_In_Tirhuta[] = {
+ 1,
+ 0x11480, 0x114df,
+}; /* CR_In_Tirhuta */
+
+/* 'In_Siddham': Block */
+static const OnigCodePoint CR_In_Siddham[] = {
+ 1,
+ 0x11580, 0x115ff,
+}; /* CR_In_Siddham */
+
+/* 'In_Modi': Block */
+static const OnigCodePoint CR_In_Modi[] = {
+ 1,
+ 0x11600, 0x1165f,
+}; /* CR_In_Modi */
+
+/* 'In_Mongolian_Supplement': Block */
+static const OnigCodePoint CR_In_Mongolian_Supplement[] = {
+ 1,
+ 0x11660, 0x1167f,
+}; /* CR_In_Mongolian_Supplement */
+
+/* 'In_Takri': Block */
+static const OnigCodePoint CR_In_Takri[] = {
+ 1,
+ 0x11680, 0x116cf,
+}; /* CR_In_Takri */
+
+/* 'In_Myanmar_Extended_C': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_C[] = {
+ 1,
+ 0x116d0, 0x116ff,
+}; /* CR_In_Myanmar_Extended_C */
+
+/* 'In_Ahom': Block */
+static const OnigCodePoint CR_In_Ahom[] = {
+ 1,
+ 0x11700, 0x1174f,
+}; /* CR_In_Ahom */
+
+/* 'In_Dogra': Block */
+static const OnigCodePoint CR_In_Dogra[] = {
+ 1,
+ 0x11800, 0x1184f,
+}; /* CR_In_Dogra */
+
+/* 'In_Warang_Citi': Block */
+static const OnigCodePoint CR_In_Warang_Citi[] = {
+ 1,
+ 0x118a0, 0x118ff,
+}; /* CR_In_Warang_Citi */
+
+/* 'In_Dives_Akuru': Block */
+static const OnigCodePoint CR_In_Dives_Akuru[] = {
+ 1,
+ 0x11900, 0x1195f,
+}; /* CR_In_Dives_Akuru */
+
+/* 'In_Nandinagari': Block */
+static const OnigCodePoint CR_In_Nandinagari[] = {
+ 1,
+ 0x119a0, 0x119ff,
+}; /* CR_In_Nandinagari */
+
+/* 'In_Zanabazar_Square': Block */
+static const OnigCodePoint CR_In_Zanabazar_Square[] = {
+ 1,
+ 0x11a00, 0x11a4f,
+}; /* CR_In_Zanabazar_Square */
+
+/* 'In_Soyombo': Block */
+static const OnigCodePoint CR_In_Soyombo[] = {
+ 1,
+ 0x11a50, 0x11aaf,
+}; /* CR_In_Soyombo */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended_A': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A[] = {
+ 1,
+ 0x11ab0, 0x11abf,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A */
+
+/* 'In_Pau_Cin_Hau': Block */
+static const OnigCodePoint CR_In_Pau_Cin_Hau[] = {
+ 1,
+ 0x11ac0, 0x11aff,
+}; /* CR_In_Pau_Cin_Hau */
+
+/* 'In_Devanagari_Extended_A': Block */
+static const OnigCodePoint CR_In_Devanagari_Extended_A[] = {
+ 1,
+ 0x11b00, 0x11b5f,
+}; /* CR_In_Devanagari_Extended_A */
+
+/* 'In_Sharada_Supplement': Block */
+static const OnigCodePoint CR_In_Sharada_Supplement[] = {
+ 1,
+ 0x11b60, 0x11b7f,
+}; /* CR_In_Sharada_Supplement */
+
+/* 'In_Sunuwar': Block */
+static const OnigCodePoint CR_In_Sunuwar[] = {
+ 1,
+ 0x11bc0, 0x11bff,
+}; /* CR_In_Sunuwar */
+
+/* 'In_Bhaiksuki': Block */
+static const OnigCodePoint CR_In_Bhaiksuki[] = {
+ 1,
+ 0x11c00, 0x11c6f,
+}; /* CR_In_Bhaiksuki */
+
+/* 'In_Marchen': Block */
+static const OnigCodePoint CR_In_Marchen[] = {
+ 1,
+ 0x11c70, 0x11cbf,
+}; /* CR_In_Marchen */
+
+/* 'In_Masaram_Gondi': Block */
+static const OnigCodePoint CR_In_Masaram_Gondi[] = {
+ 1,
+ 0x11d00, 0x11d5f,
+}; /* CR_In_Masaram_Gondi */
+
+/* 'In_Gunjala_Gondi': Block */
+static const OnigCodePoint CR_In_Gunjala_Gondi[] = {
+ 1,
+ 0x11d60, 0x11daf,
+}; /* CR_In_Gunjala_Gondi */
+
+/* 'In_Tolong_Siki': Block */
+static const OnigCodePoint CR_In_Tolong_Siki[] = {
+ 1,
+ 0x11db0, 0x11def,
+}; /* CR_In_Tolong_Siki */
+
+/* 'In_Makasar': Block */
+static const OnigCodePoint CR_In_Makasar[] = {
+ 1,
+ 0x11ee0, 0x11eff,
+}; /* CR_In_Makasar */
+
+/* 'In_Kawi': Block */
+static const OnigCodePoint CR_In_Kawi[] = {
+ 1,
+ 0x11f00, 0x11f5f,
+}; /* CR_In_Kawi */
+
+/* 'In_Lisu_Supplement': Block */
+static const OnigCodePoint CR_In_Lisu_Supplement[] = {
+ 1,
+ 0x11fb0, 0x11fbf,
+}; /* CR_In_Lisu_Supplement */
+
+/* 'In_Tamil_Supplement': Block */
+static const OnigCodePoint CR_In_Tamil_Supplement[] = {
+ 1,
+ 0x11fc0, 0x11fff,
+}; /* CR_In_Tamil_Supplement */
+
+/* 'In_Cuneiform': Block */
+static const OnigCodePoint CR_In_Cuneiform[] = {
+ 1,
+ 0x12000, 0x123ff,
+}; /* CR_In_Cuneiform */
+
+/* 'In_Cuneiform_Numbers_and_Punctuation': Block */
+static const OnigCodePoint CR_In_Cuneiform_Numbers_and_Punctuation[] = {
+ 1,
+ 0x12400, 0x1247f,
+}; /* CR_In_Cuneiform_Numbers_and_Punctuation */
+
+/* 'In_Early_Dynastic_Cuneiform': Block */
+static const OnigCodePoint CR_In_Early_Dynastic_Cuneiform[] = {
+ 1,
+ 0x12480, 0x1254f,
+}; /* CR_In_Early_Dynastic_Cuneiform */
+
+/* 'In_Cypro_Minoan': Block */
+static const OnigCodePoint CR_In_Cypro_Minoan[] = {
+ 1,
+ 0x12f90, 0x12fff,
+}; /* CR_In_Cypro_Minoan */
+
+/* 'In_Egyptian_Hieroglyphs': Block */
+static const OnigCodePoint CR_In_Egyptian_Hieroglyphs[] = {
+ 1,
+ 0x13000, 0x1342f,
+}; /* CR_In_Egyptian_Hieroglyphs */
+
+/* 'In_Egyptian_Hieroglyph_Format_Controls': Block */
+static const OnigCodePoint CR_In_Egyptian_Hieroglyph_Format_Controls[] = {
+ 1,
+ 0x13430, 0x1345f,
+}; /* CR_In_Egyptian_Hieroglyph_Format_Controls */
+
+/* 'In_Egyptian_Hieroglyphs_Extended_A': Block */
+static const OnigCodePoint CR_In_Egyptian_Hieroglyphs_Extended_A[] = {
+ 1,
+ 0x13460, 0x143ff,
+}; /* CR_In_Egyptian_Hieroglyphs_Extended_A */
+
+/* 'In_Anatolian_Hieroglyphs': Block */
+static const OnigCodePoint CR_In_Anatolian_Hieroglyphs[] = {
+ 1,
+ 0x14400, 0x1467f,
+}; /* CR_In_Anatolian_Hieroglyphs */
+
+/* 'In_Gurung_Khema': Block */
+static const OnigCodePoint CR_In_Gurung_Khema[] = {
+ 1,
+ 0x16100, 0x1613f,
+}; /* CR_In_Gurung_Khema */
+
+/* 'In_Bamum_Supplement': Block */
+static const OnigCodePoint CR_In_Bamum_Supplement[] = {
+ 1,
+ 0x16800, 0x16a3f,
+}; /* CR_In_Bamum_Supplement */
+
+/* 'In_Mro': Block */
+static const OnigCodePoint CR_In_Mro[] = {
+ 1,
+ 0x16a40, 0x16a6f,
+}; /* CR_In_Mro */
+
+/* 'In_Tangsa': Block */
+static const OnigCodePoint CR_In_Tangsa[] = {
+ 1,
+ 0x16a70, 0x16acf,
+}; /* CR_In_Tangsa */
+
+/* 'In_Bassa_Vah': Block */
+static const OnigCodePoint CR_In_Bassa_Vah[] = {
+ 1,
+ 0x16ad0, 0x16aff,
+}; /* CR_In_Bassa_Vah */
+
+/* 'In_Pahawh_Hmong': Block */
+static const OnigCodePoint CR_In_Pahawh_Hmong[] = {
+ 1,
+ 0x16b00, 0x16b8f,
+}; /* CR_In_Pahawh_Hmong */
+
+/* 'In_Kirat_Rai': Block */
+static const OnigCodePoint CR_In_Kirat_Rai[] = {
+ 1,
+ 0x16d40, 0x16d7f,
+}; /* CR_In_Kirat_Rai */
+
+/* 'In_Medefaidrin': Block */
+static const OnigCodePoint CR_In_Medefaidrin[] = {
+ 1,
+ 0x16e40, 0x16e9f,
+}; /* CR_In_Medefaidrin */
+
+/* 'In_Beria_Erfe': Block */
+static const OnigCodePoint CR_In_Beria_Erfe[] = {
+ 1,
+ 0x16ea0, 0x16edf,
+}; /* CR_In_Beria_Erfe */
+
+/* 'In_Miao': Block */
+static const OnigCodePoint CR_In_Miao[] = {
+ 1,
+ 0x16f00, 0x16f9f,
+}; /* CR_In_Miao */
+
+/* 'In_Ideographic_Symbols_and_Punctuation': Block */
+static const OnigCodePoint CR_In_Ideographic_Symbols_and_Punctuation[] = {
+ 1,
+ 0x16fe0, 0x16fff,
+}; /* CR_In_Ideographic_Symbols_and_Punctuation */
+
+/* 'In_Tangut': Block */
+static const OnigCodePoint CR_In_Tangut[] = {
+ 1,
+ 0x17000, 0x187ff,
+}; /* CR_In_Tangut */
+
+/* 'In_Tangut_Components': Block */
+static const OnigCodePoint CR_In_Tangut_Components[] = {
+ 1,
+ 0x18800, 0x18aff,
+}; /* CR_In_Tangut_Components */
+
+/* 'In_Khitan_Small_Script': Block */
+static const OnigCodePoint CR_In_Khitan_Small_Script[] = {
+ 1,
+ 0x18b00, 0x18cff,
+}; /* CR_In_Khitan_Small_Script */
+
+/* 'In_Tangut_Supplement': Block */
+static const OnigCodePoint CR_In_Tangut_Supplement[] = {
+ 1,
+ 0x18d00, 0x18d7f,
+}; /* CR_In_Tangut_Supplement */
+
+/* 'In_Tangut_Components_Supplement': Block */
+static const OnigCodePoint CR_In_Tangut_Components_Supplement[] = {
+ 1,
+ 0x18d80, 0x18dff,
+}; /* CR_In_Tangut_Components_Supplement */
+
+/* 'In_Kana_Extended_B': Block */
+static const OnigCodePoint CR_In_Kana_Extended_B[] = {
+ 1,
+ 0x1aff0, 0x1afff,
+}; /* CR_In_Kana_Extended_B */
+
+/* 'In_Kana_Supplement': Block */
+static const OnigCodePoint CR_In_Kana_Supplement[] = {
+ 1,
+ 0x1b000, 0x1b0ff,
+}; /* CR_In_Kana_Supplement */
+
+/* 'In_Kana_Extended_A': Block */
+static const OnigCodePoint CR_In_Kana_Extended_A[] = {
+ 1,
+ 0x1b100, 0x1b12f,
+}; /* CR_In_Kana_Extended_A */
+
+/* 'In_Small_Kana_Extension': Block */
+static const OnigCodePoint CR_In_Small_Kana_Extension[] = {
+ 1,
+ 0x1b130, 0x1b16f,
+}; /* CR_In_Small_Kana_Extension */
+
+/* 'In_Nushu': Block */
+static const OnigCodePoint CR_In_Nushu[] = {
+ 1,
+ 0x1b170, 0x1b2ff,
+}; /* CR_In_Nushu */
+
+/* 'In_Duployan': Block */
+static const OnigCodePoint CR_In_Duployan[] = {
+ 1,
+ 0x1bc00, 0x1bc9f,
+}; /* CR_In_Duployan */
+
+/* 'In_Shorthand_Format_Controls': Block */
+static const OnigCodePoint CR_In_Shorthand_Format_Controls[] = {
+ 1,
+ 0x1bca0, 0x1bcaf,
+}; /* CR_In_Shorthand_Format_Controls */
+
+/* 'In_Symbols_for_Legacy_Computing_Supplement': Block */
+static const OnigCodePoint CR_In_Symbols_for_Legacy_Computing_Supplement[] = {
+ 1,
+ 0x1cc00, 0x1cebf,
+}; /* CR_In_Symbols_for_Legacy_Computing_Supplement */
+
+/* 'In_Miscellaneous_Symbols_Supplement': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_Supplement[] = {
+ 1,
+ 0x1cec0, 0x1ceff,
+}; /* CR_In_Miscellaneous_Symbols_Supplement */
+
+/* 'In_Znamenny_Musical_Notation': Block */
+static const OnigCodePoint CR_In_Znamenny_Musical_Notation[] = {
+ 1,
+ 0x1cf00, 0x1cfcf,
+}; /* CR_In_Znamenny_Musical_Notation */
+
+/* 'In_Byzantine_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Byzantine_Musical_Symbols[] = {
+ 1,
+ 0x1d000, 0x1d0ff,
+}; /* CR_In_Byzantine_Musical_Symbols */
+
+/* 'In_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Musical_Symbols[] = {
+ 1,
+ 0x1d100, 0x1d1ff,
+}; /* CR_In_Musical_Symbols */
+
+/* 'In_Ancient_Greek_Musical_Notation': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Musical_Notation[] = {
+ 1,
+ 0x1d200, 0x1d24f,
+}; /* CR_In_Ancient_Greek_Musical_Notation */
+
+/* 'In_Kaktovik_Numerals': Block */
+static const OnigCodePoint CR_In_Kaktovik_Numerals[] = {
+ 1,
+ 0x1d2c0, 0x1d2df,
+}; /* CR_In_Kaktovik_Numerals */
+
+/* 'In_Mayan_Numerals': Block */
+static const OnigCodePoint CR_In_Mayan_Numerals[] = {
+ 1,
+ 0x1d2e0, 0x1d2ff,
+}; /* CR_In_Mayan_Numerals */
+
+/* 'In_Tai_Xuan_Jing_Symbols': Block */
+static const OnigCodePoint CR_In_Tai_Xuan_Jing_Symbols[] = {
+ 1,
+ 0x1d300, 0x1d35f,
+}; /* CR_In_Tai_Xuan_Jing_Symbols */
+
+/* 'In_Counting_Rod_Numerals': Block */
+static const OnigCodePoint CR_In_Counting_Rod_Numerals[] = {
+ 1,
+ 0x1d360, 0x1d37f,
+}; /* CR_In_Counting_Rod_Numerals */
+
+/* 'In_Mathematical_Alphanumeric_Symbols': Block */
+static const OnigCodePoint CR_In_Mathematical_Alphanumeric_Symbols[] = {
+ 1,
+ 0x1d400, 0x1d7ff,
+}; /* CR_In_Mathematical_Alphanumeric_Symbols */
+
+/* 'In_Sutton_SignWriting': Block */
+static const OnigCodePoint CR_In_Sutton_SignWriting[] = {
+ 1,
+ 0x1d800, 0x1daaf,
+}; /* CR_In_Sutton_SignWriting */
+
+/* 'In_Latin_Extended_G': Block */
+static const OnigCodePoint CR_In_Latin_Extended_G[] = {
+ 1,
+ 0x1df00, 0x1dfff,
+}; /* CR_In_Latin_Extended_G */
+
+/* 'In_Glagolitic_Supplement': Block */
+static const OnigCodePoint CR_In_Glagolitic_Supplement[] = {
+ 1,
+ 0x1e000, 0x1e02f,
+}; /* CR_In_Glagolitic_Supplement */
+
+/* 'In_Cyrillic_Extended_D': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_D[] = {
+ 1,
+ 0x1e030, 0x1e08f,
+}; /* CR_In_Cyrillic_Extended_D */
+
+/* 'In_Nyiakeng_Puachue_Hmong': Block */
+static const OnigCodePoint CR_In_Nyiakeng_Puachue_Hmong[] = {
+ 1,
+ 0x1e100, 0x1e14f,
+}; /* CR_In_Nyiakeng_Puachue_Hmong */
+
+/* 'In_Toto': Block */
+static const OnigCodePoint CR_In_Toto[] = {
+ 1,
+ 0x1e290, 0x1e2bf,
+}; /* CR_In_Toto */
+
+/* 'In_Wancho': Block */
+static const OnigCodePoint CR_In_Wancho[] = {
+ 1,
+ 0x1e2c0, 0x1e2ff,
+}; /* CR_In_Wancho */
+
+/* 'In_Nag_Mundari': Block */
+static const OnigCodePoint CR_In_Nag_Mundari[] = {
+ 1,
+ 0x1e4d0, 0x1e4ff,
+}; /* CR_In_Nag_Mundari */
+
+/* 'In_Ol_Onal': Block */
+static const OnigCodePoint CR_In_Ol_Onal[] = {
+ 1,
+ 0x1e5d0, 0x1e5ff,
+}; /* CR_In_Ol_Onal */
+
+/* 'In_Tai_Yo': Block */
+static const OnigCodePoint CR_In_Tai_Yo[] = {
+ 1,
+ 0x1e6c0, 0x1e6ff,
+}; /* CR_In_Tai_Yo */
+
+/* 'In_Ethiopic_Extended_B': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended_B[] = {
+ 1,
+ 0x1e7e0, 0x1e7ff,
+}; /* CR_In_Ethiopic_Extended_B */
+
+/* 'In_Mende_Kikakui': Block */
+static const OnigCodePoint CR_In_Mende_Kikakui[] = {
+ 1,
+ 0x1e800, 0x1e8df,
+}; /* CR_In_Mende_Kikakui */
+
+/* 'In_Adlam': Block */
+static const OnigCodePoint CR_In_Adlam[] = {
+ 1,
+ 0x1e900, 0x1e95f,
+}; /* CR_In_Adlam */
+
+/* 'In_Indic_Siyaq_Numbers': Block */
+static const OnigCodePoint CR_In_Indic_Siyaq_Numbers[] = {
+ 1,
+ 0x1ec70, 0x1ecbf,
+}; /* CR_In_Indic_Siyaq_Numbers */
+
+/* 'In_Ottoman_Siyaq_Numbers': Block */
+static const OnigCodePoint CR_In_Ottoman_Siyaq_Numbers[] = {
+ 1,
+ 0x1ed00, 0x1ed4f,
+}; /* CR_In_Ottoman_Siyaq_Numbers */
+
+/* 'In_Arabic_Mathematical_Alphabetic_Symbols': Block */
+static const OnigCodePoint CR_In_Arabic_Mathematical_Alphabetic_Symbols[] = {
+ 1,
+ 0x1ee00, 0x1eeff,
+}; /* CR_In_Arabic_Mathematical_Alphabetic_Symbols */
+
+/* 'In_Mahjong_Tiles': Block */
+static const OnigCodePoint CR_In_Mahjong_Tiles[] = {
+ 1,
+ 0x1f000, 0x1f02f,
+}; /* CR_In_Mahjong_Tiles */
+
+/* 'In_Domino_Tiles': Block */
+static const OnigCodePoint CR_In_Domino_Tiles[] = {
+ 1,
+ 0x1f030, 0x1f09f,
+}; /* CR_In_Domino_Tiles */
+
+/* 'In_Playing_Cards': Block */
+static const OnigCodePoint CR_In_Playing_Cards[] = {
+ 1,
+ 0x1f0a0, 0x1f0ff,
+}; /* CR_In_Playing_Cards */
+
+/* 'In_Enclosed_Alphanumeric_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumeric_Supplement[] = {
+ 1,
+ 0x1f100, 0x1f1ff,
+}; /* CR_In_Enclosed_Alphanumeric_Supplement */
+
+/* 'In_Enclosed_Ideographic_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Ideographic_Supplement[] = {
+ 1,
+ 0x1f200, 0x1f2ff,
+}; /* CR_In_Enclosed_Ideographic_Supplement */
+
+/* 'In_Miscellaneous_Symbols_and_Pictographs': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Pictographs[] = {
+ 1,
+ 0x1f300, 0x1f5ff,
+}; /* CR_In_Miscellaneous_Symbols_and_Pictographs */
+
+/* 'In_Emoticons': Block */
+static const OnigCodePoint CR_In_Emoticons[] = {
+ 1,
+ 0x1f600, 0x1f64f,
+}; /* CR_In_Emoticons */
+
+/* 'In_Ornamental_Dingbats': Block */
+static const OnigCodePoint CR_In_Ornamental_Dingbats[] = {
+ 1,
+ 0x1f650, 0x1f67f,
+}; /* CR_In_Ornamental_Dingbats */
+
+/* 'In_Transport_and_Map_Symbols': Block */
+static const OnigCodePoint CR_In_Transport_and_Map_Symbols[] = {
+ 1,
+ 0x1f680, 0x1f6ff,
+}; /* CR_In_Transport_and_Map_Symbols */
+
+/* 'In_Alchemical_Symbols': Block */
+static const OnigCodePoint CR_In_Alchemical_Symbols[] = {
+ 1,
+ 0x1f700, 0x1f77f,
+}; /* CR_In_Alchemical_Symbols */
+
+/* 'In_Geometric_Shapes_Extended': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes_Extended[] = {
+ 1,
+ 0x1f780, 0x1f7ff,
+}; /* CR_In_Geometric_Shapes_Extended */
+
+/* 'In_Supplemental_Arrows_C': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_C[] = {
+ 1,
+ 0x1f800, 0x1f8ff,
+}; /* CR_In_Supplemental_Arrows_C */
+
+/* 'In_Supplemental_Symbols_and_Pictographs': Block */
+static const OnigCodePoint CR_In_Supplemental_Symbols_and_Pictographs[] = {
+ 1,
+ 0x1f900, 0x1f9ff,
+}; /* CR_In_Supplemental_Symbols_and_Pictographs */
+
+/* 'In_Chess_Symbols': Block */
+static const OnigCodePoint CR_In_Chess_Symbols[] = {
+ 1,
+ 0x1fa00, 0x1fa6f,
+}; /* CR_In_Chess_Symbols */
+
+/* 'In_Symbols_and_Pictographs_Extended_A': Block */
+static const OnigCodePoint CR_In_Symbols_and_Pictographs_Extended_A[] = {
+ 1,
+ 0x1fa70, 0x1faff,
+}; /* CR_In_Symbols_and_Pictographs_Extended_A */
+
+/* 'In_Symbols_for_Legacy_Computing': Block */
+static const OnigCodePoint CR_In_Symbols_for_Legacy_Computing[] = {
+ 1,
+ 0x1fb00, 0x1fbff,
+}; /* CR_In_Symbols_for_Legacy_Computing */
+
+/* 'In_CJK_Unified_Ideographs_Extension_B': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_B[] = {
+ 1,
+ 0x20000, 0x2a6df,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_B */
+
+/* 'In_CJK_Unified_Ideographs_Extension_C': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_C[] = {
+ 1,
+ 0x2a700, 0x2b73f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_C */
+
+/* 'In_CJK_Unified_Ideographs_Extension_D': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_D[] = {
+ 1,
+ 0x2b740, 0x2b81f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_D */
+
+/* 'In_CJK_Unified_Ideographs_Extension_E': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_E[] = {
+ 1,
+ 0x2b820, 0x2ceaf,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_E */
+
+/* 'In_CJK_Unified_Ideographs_Extension_F': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_F[] = {
+ 1,
+ 0x2ceb0, 0x2ebef,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_F */
+
+/* 'In_CJK_Unified_Ideographs_Extension_I': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_I[] = {
+ 1,
+ 0x2ebf0, 0x2ee5f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_I */
+
+/* 'In_CJK_Compatibility_Ideographs_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs_Supplement[] = {
+ 1,
+ 0x2f800, 0x2fa1f,
+}; /* CR_In_CJK_Compatibility_Ideographs_Supplement */
+
+/* 'In_CJK_Unified_Ideographs_Extension_G': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_G[] = {
+ 1,
+ 0x30000, 0x3134f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_G */
+
+/* 'In_CJK_Unified_Ideographs_Extension_H': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_H[] = {
+ 1,
+ 0x31350, 0x323af,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_H */
+
+/* 'In_CJK_Unified_Ideographs_Extension_J': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_J[] = {
+ 1,
+ 0x323b0, 0x3347f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_J */
+
+/* 'In_Tags': Block */
+static const OnigCodePoint CR_In_Tags[] = {
+ 1,
+ 0xe0000, 0xe007f,
+}; /* CR_In_Tags */
+
+/* 'In_Variation_Selectors_Supplement': Block */
+static const OnigCodePoint CR_In_Variation_Selectors_Supplement[] = {
+ 1,
+ 0xe0100, 0xe01ef,
+}; /* CR_In_Variation_Selectors_Supplement */
+
+/* 'In_Supplementary_Private_Use_Area_A': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_A[] = {
+ 1,
+ 0xf0000, 0xfffff,
+}; /* CR_In_Supplementary_Private_Use_Area_A */
+
+/* 'In_Supplementary_Private_Use_Area_B': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_B[] = {
+ 1,
+ 0x100000, 0x10ffff,
+}; /* CR_In_Supplementary_Private_Use_Area_B */
+
+/* 'In_No_Block': Block */
+static const OnigCodePoint CR_In_No_Block[] = {
+ 51,
+ 0x2fe0, 0x2fef,
+ 0x10200, 0x1027f,
+ 0x103e0, 0x103ff,
+ 0x107c0, 0x107ff,
+ 0x108b0, 0x108df,
+ 0x10960, 0x1097f,
+ 0x10aa0, 0x10abf,
+ 0x10bb0, 0x10bff,
+ 0x10c50, 0x10c7f,
+ 0x10d90, 0x10e5f,
+ 0x11250, 0x1127f,
+ 0x114e0, 0x1157f,
+ 0x11750, 0x117ff,
+ 0x11850, 0x1189f,
+ 0x11960, 0x1199f,
+ 0x11b80, 0x11bbf,
+ 0x11cc0, 0x11cff,
+ 0x11df0, 0x11edf,
+ 0x11f60, 0x11faf,
+ 0x12550, 0x12f8f,
+ 0x14680, 0x160ff,
+ 0x16140, 0x167ff,
+ 0x16b90, 0x16d3f,
+ 0x16d80, 0x16e3f,
+ 0x16ee0, 0x16eff,
+ 0x16fa0, 0x16fdf,
+ 0x18e00, 0x1afef,
+ 0x1b300, 0x1bbff,
+ 0x1bcb0, 0x1cbff,
+ 0x1cfd0, 0x1cfff,
+ 0x1d250, 0x1d2bf,
+ 0x1d380, 0x1d3ff,
+ 0x1dab0, 0x1deff,
+ 0x1e090, 0x1e0ff,
+ 0x1e150, 0x1e28f,
+ 0x1e300, 0x1e4cf,
+ 0x1e500, 0x1e5cf,
+ 0x1e600, 0x1e6bf,
+ 0x1e700, 0x1e7df,
+ 0x1e8e0, 0x1e8ff,
+ 0x1e960, 0x1ec6f,
+ 0x1ecc0, 0x1ecff,
+ 0x1ed50, 0x1edff,
+ 0x1ef00, 0x1efff,
+ 0x1fc00, 0x1ffff,
+ 0x2a6e0, 0x2a6ff,
+ 0x2ee60, 0x2f7ff,
+ 0x2fa20, 0x2ffff,
+ 0x33480, 0xdffff,
+ 0xe0080, 0xe00ff,
+ 0xe01f0, 0xeffff,
+}; /* CR_In_No_Block */
+
+#endif /* USE_UNICODE_PROPERTIES */
+static const OnigCodePoint* const CodeRanges[] = {
+ CR_NEWLINE,
+ CR_Alpha,
+ CR_Blank,
+ CR_Cntrl,
+ CR_Digit,
+ CR_Graph,
+ CR_Lower,
+ CR_Print,
+ CR_XPosixPunct,
+ CR_Space,
+ CR_Upper,
+ CR_XDigit,
+ CR_Word,
+ CR_Alnum,
+ CR_ASCII,
+ CR_Punct,
+#ifdef USE_UNICODE_PROPERTIES
+ CR_Any,
+ CR_Assigned,
+ CR_C,
+ CR_Cc,
+ CR_Cf,
+ CR_Cn,
+ CR_Co,
+ CR_Cs,
+ CR_L,
+ CR_LC,
+ CR_Ll,
+ CR_Lm,
+ CR_Lo,
+ CR_Lt,
+ CR_Lu,
+ CR_M,
+ CR_Mc,
+ CR_Me,
+ CR_Mn,
+ CR_N,
+ CR_Nd,
+ CR_Nl,
+ CR_No,
+ CR_P,
+ CR_Pc,
+ CR_Pd,
+ CR_Pe,
+ CR_Pf,
+ CR_Pi,
+ CR_Po,
+ CR_Ps,
+ CR_S,
+ CR_Sc,
+ CR_Sk,
+ CR_Sm,
+ CR_So,
+ CR_Z,
+ CR_Zl,
+ CR_Zp,
+ CR_Zs,
+ CR_Math,
+ CR_Alphabetic,
+ CR_Lowercase,
+ CR_Uppercase,
+ CR_Cased,
+ CR_Case_Ignorable,
+ CR_Changes_When_Lowercased,
+ CR_Changes_When_Uppercased,
+ CR_Changes_When_Titlecased,
+ CR_Changes_When_Casefolded,
+ CR_Changes_When_Casemapped,
+ CR_ID_Start,
+ CR_ID_Continue,
+ CR_XID_Start,
+ CR_XID_Continue,
+ CR_Default_Ignorable_Code_Point,
+ CR_Grapheme_Extend,
+ CR_Grapheme_Base,
+ CR_Grapheme_Link,
+ CR_InCB_Linker,
+ CR_InCB_Consonant,
+ CR_InCB_Extend,
+ CR_Common,
+ CR_Latin,
+ CR_Greek,
+ CR_Cyrillic,
+ CR_Armenian,
+ CR_Hebrew,
+ CR_Arabic,
+ CR_Syriac,
+ CR_Thaana,
+ CR_Devanagari,
+ CR_Bengali,
+ CR_Gurmukhi,
+ CR_Gujarati,
+ CR_Oriya,
+ CR_Tamil,
+ CR_Telugu,
+ CR_Kannada,
+ CR_Malayalam,
+ CR_Sinhala,
+ CR_Thai,
+ CR_Lao,
+ CR_Tibetan,
+ CR_Myanmar,
+ CR_Georgian,
+ CR_Hangul,
+ CR_Ethiopic,
+ CR_Cherokee,
+ CR_Canadian_Aboriginal,
+ CR_Ogham,
+ CR_Runic,
+ CR_Khmer,
+ CR_Mongolian,
+ CR_Hiragana,
+ CR_Katakana,
+ CR_Bopomofo,
+ CR_Han,
+ CR_Yi,
+ CR_Old_Italic,
+ CR_Gothic,
+ CR_Deseret,
+ CR_Inherited,
+ CR_Tagalog,
+ CR_Hanunoo,
+ CR_Buhid,
+ CR_Tagbanwa,
+ CR_Limbu,
+ CR_Tai_Le,
+ CR_Linear_B,
+ CR_Ugaritic,
+ CR_Shavian,
+ CR_Osmanya,
+ CR_Cypriot,
+ CR_Braille,
+ CR_Buginese,
+ CR_Coptic,
+ CR_New_Tai_Lue,
+ CR_Glagolitic,
+ CR_Tifinagh,
+ CR_Syloti_Nagri,
+ CR_Old_Persian,
+ CR_Kharoshthi,
+ CR_Balinese,
+ CR_Cuneiform,
+ CR_Phoenician,
+ CR_Phags_Pa,
+ CR_Nko,
+ CR_Sundanese,
+ CR_Lepcha,
+ CR_Ol_Chiki,
+ CR_Vai,
+ CR_Saurashtra,
+ CR_Kayah_Li,
+ CR_Rejang,
+ CR_Lycian,
+ CR_Carian,
+ CR_Lydian,
+ CR_Cham,
+ CR_Tai_Tham,
+ CR_Tai_Viet,
+ CR_Avestan,
+ CR_Egyptian_Hieroglyphs,
+ CR_Samaritan,
+ CR_Lisu,
+ CR_Bamum,
+ CR_Javanese,
+ CR_Meetei_Mayek,
+ CR_Imperial_Aramaic,
+ CR_Old_South_Arabian,
+ CR_Inscriptional_Parthian,
+ CR_Inscriptional_Pahlavi,
+ CR_Old_Turkic,
+ CR_Kaithi,
+ CR_Batak,
+ CR_Brahmi,
+ CR_Mandaic,
+ CR_Chakma,
+ CR_Meroitic_Cursive,
+ CR_Meroitic_Hieroglyphs,
+ CR_Miao,
+ CR_Sharada,
+ CR_Sora_Sompeng,
+ CR_Takri,
+ CR_Caucasian_Albanian,
+ CR_Bassa_Vah,
+ CR_Duployan,
+ CR_Elbasan,
+ CR_Grantha,
+ CR_Pahawh_Hmong,
+ CR_Khojki,
+ CR_Linear_A,
+ CR_Mahajani,
+ CR_Manichaean,
+ CR_Mende_Kikakui,
+ CR_Modi,
+ CR_Mro,
+ CR_Old_North_Arabian,
+ CR_Nabataean,
+ CR_Palmyrene,
+ CR_Pau_Cin_Hau,
+ CR_Old_Permic,
+ CR_Psalter_Pahlavi,
+ CR_Siddham,
+ CR_Khudawadi,
+ CR_Tirhuta,
+ CR_Warang_Citi,
+ CR_Ahom,
+ CR_Anatolian_Hieroglyphs,
+ CR_Hatran,
+ CR_Multani,
+ CR_Old_Hungarian,
+ CR_SignWriting,
+ CR_Adlam,
+ CR_Bhaiksuki,
+ CR_Marchen,
+ CR_Newa,
+ CR_Osage,
+ CR_Tangut,
+ CR_Masaram_Gondi,
+ CR_Nushu,
+ CR_Soyombo,
+ CR_Zanabazar_Square,
+ CR_Dogra,
+ CR_Gunjala_Gondi,
+ CR_Makasar,
+ CR_Medefaidrin,
+ CR_Hanifi_Rohingya,
+ CR_Sogdian,
+ CR_Old_Sogdian,
+ CR_Elymaic,
+ CR_Nandinagari,
+ CR_Nyiakeng_Puachue_Hmong,
+ CR_Wancho,
+ CR_Chorasmian,
+ CR_Dives_Akuru,
+ CR_Khitan_Small_Script,
+ CR_Yezidi,
+ CR_Cypro_Minoan,
+ CR_Old_Uyghur,
+ CR_Tangsa,
+ CR_Toto,
+ CR_Vithkuqi,
+ CR_Kawi,
+ CR_Nag_Mundari,
+ CR_Garay,
+ CR_Gurung_Khema,
+ CR_Kirat_Rai,
+ CR_Ol_Onal,
+ CR_Sunuwar,
+ CR_Todhri,
+ CR_Tulu_Tigalari,
+ CR_Sidetic,
+ CR_Tai_Yo,
+ CR_Tolong_Siki,
+ CR_Beria_Erfe,
+ CR_White_Space,
+ CR_Bidi_Control,
+ CR_Join_Control,
+ CR_Dash,
+ CR_Hyphen,
+ CR_Quotation_Mark,
+ CR_Terminal_Punctuation,
+ CR_Other_Math,
+ CR_Hex_Digit,
+ CR_ASCII_Hex_Digit,
+ CR_Other_Alphabetic,
+ CR_Ideographic,
+ CR_Diacritic,
+ CR_Extender,
+ CR_Other_Lowercase,
+ CR_Other_Uppercase,
+ CR_Noncharacter_Code_Point,
+ CR_Other_Grapheme_Extend,
+ CR_IDS_Binary_Operator,
+ CR_IDS_Trinary_Operator,
+ CR_IDS_Unary_Operator,
+ CR_Radical,
+ CR_Unified_Ideograph,
+ CR_Other_Default_Ignorable_Code_Point,
+ CR_Deprecated,
+ CR_Soft_Dotted,
+ CR_Logical_Order_Exception,
+ CR_Other_ID_Start,
+ CR_Other_ID_Continue,
+ CR_ID_Compat_Math_Continue,
+ CR_ID_Compat_Math_Start,
+ CR_Sentence_Terminal,
+ CR_Variation_Selector,
+ CR_Pattern_White_Space,
+ CR_Pattern_Syntax,
+ CR_Prepended_Concatenation_Mark,
+ CR_Regional_Indicator,
+ CR_Modifier_Combining_Mark,
+ CR_Emoji,
+ CR_Emoji_Presentation,
+ CR_Emoji_Modifier,
+ CR_Emoji_Modifier_Base,
+ CR_Emoji_Component,
+ CR_Extended_Pictographic,
+ CR_Unknown,
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ CR_Age_1_1,
+ CR_Age_2_0,
+ CR_Age_2_1,
+ CR_Age_3_0,
+ CR_Age_3_1,
+ CR_Age_3_2,
+ CR_Age_4_0,
+ CR_Age_4_1,
+ CR_Age_5_0,
+ CR_Age_5_1,
+ CR_Age_5_2,
+ CR_Age_6_0,
+ CR_Age_6_1,
+ CR_Age_6_2,
+ CR_Age_6_3,
+ CR_Age_7_0,
+ CR_Age_8_0,
+ CR_Age_9_0,
+ CR_Age_10_0,
+ CR_Age_11_0,
+ CR_Age_12_0,
+ CR_Age_12_1,
+ CR_Age_13_0,
+ CR_Age_14_0,
+ CR_Age_15_0,
+ CR_Age_15_1,
+ CR_Age_16_0,
+ CR_Age_17_0,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ CR_Grapheme_Cluster_Break_Prepend,
+ CR_Grapheme_Cluster_Break_CR,
+ CR_Grapheme_Cluster_Break_LF,
+ CR_Grapheme_Cluster_Break_Control,
+ CR_Grapheme_Cluster_Break_Extend,
+ CR_Grapheme_Cluster_Break_Regional_Indicator,
+ CR_Grapheme_Cluster_Break_SpacingMark,
+ CR_Grapheme_Cluster_Break_L,
+ CR_Grapheme_Cluster_Break_V,
+ CR_Grapheme_Cluster_Break_T,
+ CR_Grapheme_Cluster_Break_LV,
+ CR_Grapheme_Cluster_Break_LVT,
+ CR_Grapheme_Cluster_Break_ZWJ,
+ CR_In_Basic_Latin,
+ CR_In_Latin_1_Supplement,
+ CR_In_Latin_Extended_A,
+ CR_In_Latin_Extended_B,
+ CR_In_IPA_Extensions,
+ CR_In_Spacing_Modifier_Letters,
+ CR_In_Combining_Diacritical_Marks,
+ CR_In_Greek_and_Coptic,
+ CR_In_Cyrillic,
+ CR_In_Cyrillic_Supplement,
+ CR_In_Armenian,
+ CR_In_Hebrew,
+ CR_In_Arabic,
+ CR_In_Syriac,
+ CR_In_Arabic_Supplement,
+ CR_In_Thaana,
+ CR_In_NKo,
+ CR_In_Samaritan,
+ CR_In_Mandaic,
+ CR_In_Syriac_Supplement,
+ CR_In_Arabic_Extended_B,
+ CR_In_Arabic_Extended_A,
+ CR_In_Devanagari,
+ CR_In_Bengali,
+ CR_In_Gurmukhi,
+ CR_In_Gujarati,
+ CR_In_Oriya,
+ CR_In_Tamil,
+ CR_In_Telugu,
+ CR_In_Kannada,
+ CR_In_Malayalam,
+ CR_In_Sinhala,
+ CR_In_Thai,
+ CR_In_Lao,
+ CR_In_Tibetan,
+ CR_In_Myanmar,
+ CR_In_Georgian,
+ CR_In_Hangul_Jamo,
+ CR_In_Ethiopic,
+ CR_In_Ethiopic_Supplement,
+ CR_In_Cherokee,
+ CR_In_Unified_Canadian_Aboriginal_Syllabics,
+ CR_In_Ogham,
+ CR_In_Runic,
+ CR_In_Tagalog,
+ CR_In_Hanunoo,
+ CR_In_Buhid,
+ CR_In_Tagbanwa,
+ CR_In_Khmer,
+ CR_In_Mongolian,
+ CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended,
+ CR_In_Limbu,
+ CR_In_Tai_Le,
+ CR_In_New_Tai_Lue,
+ CR_In_Khmer_Symbols,
+ CR_In_Buginese,
+ CR_In_Tai_Tham,
+ CR_In_Combining_Diacritical_Marks_Extended,
+ CR_In_Balinese,
+ CR_In_Sundanese,
+ CR_In_Batak,
+ CR_In_Lepcha,
+ CR_In_Ol_Chiki,
+ CR_In_Cyrillic_Extended_C,
+ CR_In_Georgian_Extended,
+ CR_In_Sundanese_Supplement,
+ CR_In_Vedic_Extensions,
+ CR_In_Phonetic_Extensions,
+ CR_In_Phonetic_Extensions_Supplement,
+ CR_In_Combining_Diacritical_Marks_Supplement,
+ CR_In_Latin_Extended_Additional,
+ CR_In_Greek_Extended,
+ CR_In_General_Punctuation,
+ CR_In_Superscripts_and_Subscripts,
+ CR_In_Currency_Symbols,
+ CR_In_Combining_Diacritical_Marks_for_Symbols,
+ CR_In_Letterlike_Symbols,
+ CR_In_Number_Forms,
+ CR_In_Arrows,
+ CR_In_Mathematical_Operators,
+ CR_In_Miscellaneous_Technical,
+ CR_In_Control_Pictures,
+ CR_In_Optical_Character_Recognition,
+ CR_In_Enclosed_Alphanumerics,
+ CR_In_Box_Drawing,
+ CR_In_Block_Elements,
+ CR_In_Geometric_Shapes,
+ CR_In_Miscellaneous_Symbols,
+ CR_In_Dingbats,
+ CR_In_Miscellaneous_Mathematical_Symbols_A,
+ CR_In_Supplemental_Arrows_A,
+ CR_In_Braille_Patterns,
+ CR_In_Supplemental_Arrows_B,
+ CR_In_Miscellaneous_Mathematical_Symbols_B,
+ CR_In_Supplemental_Mathematical_Operators,
+ CR_In_Miscellaneous_Symbols_and_Arrows,
+ CR_In_Glagolitic,
+ CR_In_Latin_Extended_C,
+ CR_In_Coptic,
+ CR_In_Georgian_Supplement,
+ CR_In_Tifinagh,
+ CR_In_Ethiopic_Extended,
+ CR_In_Cyrillic_Extended_A,
+ CR_In_Supplemental_Punctuation,
+ CR_In_CJK_Radicals_Supplement,
+ CR_In_Kangxi_Radicals,
+ CR_In_Ideographic_Description_Characters,
+ CR_In_CJK_Symbols_and_Punctuation,
+ CR_In_Hiragana,
+ CR_In_Katakana,
+ CR_In_Bopomofo,
+ CR_In_Hangul_Compatibility_Jamo,
+ CR_In_Kanbun,
+ CR_In_Bopomofo_Extended,
+ CR_In_CJK_Strokes,
+ CR_In_Katakana_Phonetic_Extensions,
+ CR_In_Enclosed_CJK_Letters_and_Months,
+ CR_In_CJK_Compatibility,
+ CR_In_CJK_Unified_Ideographs_Extension_A,
+ CR_In_Yijing_Hexagram_Symbols,
+ CR_In_CJK_Unified_Ideographs,
+ CR_In_Yi_Syllables,
+ CR_In_Yi_Radicals,
+ CR_In_Lisu,
+ CR_In_Vai,
+ CR_In_Cyrillic_Extended_B,
+ CR_In_Bamum,
+ CR_In_Modifier_Tone_Letters,
+ CR_In_Latin_Extended_D,
+ CR_In_Syloti_Nagri,
+ CR_In_Common_Indic_Number_Forms,
+ CR_In_Phags_pa,
+ CR_In_Saurashtra,
+ CR_In_Devanagari_Extended,
+ CR_In_Kayah_Li,
+ CR_In_Rejang,
+ CR_In_Hangul_Jamo_Extended_A,
+ CR_In_Javanese,
+ CR_In_Myanmar_Extended_B,
+ CR_In_Cham,
+ CR_In_Myanmar_Extended_A,
+ CR_In_Tai_Viet,
+ CR_In_Meetei_Mayek_Extensions,
+ CR_In_Ethiopic_Extended_A,
+ CR_In_Latin_Extended_E,
+ CR_In_Cherokee_Supplement,
+ CR_In_Meetei_Mayek,
+ CR_In_Hangul_Syllables,
+ CR_In_Hangul_Jamo_Extended_B,
+ CR_In_High_Surrogates,
+ CR_In_High_Private_Use_Surrogates,
+ CR_In_Low_Surrogates,
+ CR_In_Private_Use_Area,
+ CR_In_CJK_Compatibility_Ideographs,
+ CR_In_Alphabetic_Presentation_Forms,
+ CR_In_Arabic_Presentation_Forms_A,
+ CR_In_Variation_Selectors,
+ CR_In_Vertical_Forms,
+ CR_In_Combining_Half_Marks,
+ CR_In_CJK_Compatibility_Forms,
+ CR_In_Small_Form_Variants,
+ CR_In_Arabic_Presentation_Forms_B,
+ CR_In_Halfwidth_and_Fullwidth_Forms,
+ CR_In_Specials,
+ CR_In_Linear_B_Syllabary,
+ CR_In_Linear_B_Ideograms,
+ CR_In_Aegean_Numbers,
+ CR_In_Ancient_Greek_Numbers,
+ CR_In_Ancient_Symbols,
+ CR_In_Phaistos_Disc,
+ CR_In_Lycian,
+ CR_In_Carian,
+ CR_In_Coptic_Epact_Numbers,
+ CR_In_Old_Italic,
+ CR_In_Gothic,
+ CR_In_Old_Permic,
+ CR_In_Ugaritic,
+ CR_In_Old_Persian,
+ CR_In_Deseret,
+ CR_In_Shavian,
+ CR_In_Osmanya,
+ CR_In_Osage,
+ CR_In_Elbasan,
+ CR_In_Caucasian_Albanian,
+ CR_In_Vithkuqi,
+ CR_In_Todhri,
+ CR_In_Linear_A,
+ CR_In_Latin_Extended_F,
+ CR_In_Cypriot_Syllabary,
+ CR_In_Imperial_Aramaic,
+ CR_In_Palmyrene,
+ CR_In_Nabataean,
+ CR_In_Hatran,
+ CR_In_Phoenician,
+ CR_In_Lydian,
+ CR_In_Sidetic,
+ CR_In_Meroitic_Hieroglyphs,
+ CR_In_Meroitic_Cursive,
+ CR_In_Kharoshthi,
+ CR_In_Old_South_Arabian,
+ CR_In_Old_North_Arabian,
+ CR_In_Manichaean,
+ CR_In_Avestan,
+ CR_In_Inscriptional_Parthian,
+ CR_In_Inscriptional_Pahlavi,
+ CR_In_Psalter_Pahlavi,
+ CR_In_Old_Turkic,
+ CR_In_Old_Hungarian,
+ CR_In_Hanifi_Rohingya,
+ CR_In_Garay,
+ CR_In_Rumi_Numeral_Symbols,
+ CR_In_Yezidi,
+ CR_In_Arabic_Extended_C,
+ CR_In_Old_Sogdian,
+ CR_In_Sogdian,
+ CR_In_Old_Uyghur,
+ CR_In_Chorasmian,
+ CR_In_Elymaic,
+ CR_In_Brahmi,
+ CR_In_Kaithi,
+ CR_In_Sora_Sompeng,
+ CR_In_Chakma,
+ CR_In_Mahajani,
+ CR_In_Sharada,
+ CR_In_Sinhala_Archaic_Numbers,
+ CR_In_Khojki,
+ CR_In_Multani,
+ CR_In_Khudawadi,
+ CR_In_Grantha,
+ CR_In_Tulu_Tigalari,
+ CR_In_Newa,
+ CR_In_Tirhuta,
+ CR_In_Siddham,
+ CR_In_Modi,
+ CR_In_Mongolian_Supplement,
+ CR_In_Takri,
+ CR_In_Myanmar_Extended_C,
+ CR_In_Ahom,
+ CR_In_Dogra,
+ CR_In_Warang_Citi,
+ CR_In_Dives_Akuru,
+ CR_In_Nandinagari,
+ CR_In_Zanabazar_Square,
+ CR_In_Soyombo,
+ CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended_A,
+ CR_In_Pau_Cin_Hau,
+ CR_In_Devanagari_Extended_A,
+ CR_In_Sharada_Supplement,
+ CR_In_Sunuwar,
+ CR_In_Bhaiksuki,
+ CR_In_Marchen,
+ CR_In_Masaram_Gondi,
+ CR_In_Gunjala_Gondi,
+ CR_In_Tolong_Siki,
+ CR_In_Makasar,
+ CR_In_Kawi,
+ CR_In_Lisu_Supplement,
+ CR_In_Tamil_Supplement,
+ CR_In_Cuneiform,
+ CR_In_Cuneiform_Numbers_and_Punctuation,
+ CR_In_Early_Dynastic_Cuneiform,
+ CR_In_Cypro_Minoan,
+ CR_In_Egyptian_Hieroglyphs,
+ CR_In_Egyptian_Hieroglyph_Format_Controls,
+ CR_In_Egyptian_Hieroglyphs_Extended_A,
+ CR_In_Anatolian_Hieroglyphs,
+ CR_In_Gurung_Khema,
+ CR_In_Bamum_Supplement,
+ CR_In_Mro,
+ CR_In_Tangsa,
+ CR_In_Bassa_Vah,
+ CR_In_Pahawh_Hmong,
+ CR_In_Kirat_Rai,
+ CR_In_Medefaidrin,
+ CR_In_Beria_Erfe,
+ CR_In_Miao,
+ CR_In_Ideographic_Symbols_and_Punctuation,
+ CR_In_Tangut,
+ CR_In_Tangut_Components,
+ CR_In_Khitan_Small_Script,
+ CR_In_Tangut_Supplement,
+ CR_In_Tangut_Components_Supplement,
+ CR_In_Kana_Extended_B,
+ CR_In_Kana_Supplement,
+ CR_In_Kana_Extended_A,
+ CR_In_Small_Kana_Extension,
+ CR_In_Nushu,
+ CR_In_Duployan,
+ CR_In_Shorthand_Format_Controls,
+ CR_In_Symbols_for_Legacy_Computing_Supplement,
+ CR_In_Miscellaneous_Symbols_Supplement,
+ CR_In_Znamenny_Musical_Notation,
+ CR_In_Byzantine_Musical_Symbols,
+ CR_In_Musical_Symbols,
+ CR_In_Ancient_Greek_Musical_Notation,
+ CR_In_Kaktovik_Numerals,
+ CR_In_Mayan_Numerals,
+ CR_In_Tai_Xuan_Jing_Symbols,
+ CR_In_Counting_Rod_Numerals,
+ CR_In_Mathematical_Alphanumeric_Symbols,
+ CR_In_Sutton_SignWriting,
+ CR_In_Latin_Extended_G,
+ CR_In_Glagolitic_Supplement,
+ CR_In_Cyrillic_Extended_D,
+ CR_In_Nyiakeng_Puachue_Hmong,
+ CR_In_Toto,
+ CR_In_Wancho,
+ CR_In_Nag_Mundari,
+ CR_In_Ol_Onal,
+ CR_In_Tai_Yo,
+ CR_In_Ethiopic_Extended_B,
+ CR_In_Mende_Kikakui,
+ CR_In_Adlam,
+ CR_In_Indic_Siyaq_Numbers,
+ CR_In_Ottoman_Siyaq_Numbers,
+ CR_In_Arabic_Mathematical_Alphabetic_Symbols,
+ CR_In_Mahjong_Tiles,
+ CR_In_Domino_Tiles,
+ CR_In_Playing_Cards,
+ CR_In_Enclosed_Alphanumeric_Supplement,
+ CR_In_Enclosed_Ideographic_Supplement,
+ CR_In_Miscellaneous_Symbols_and_Pictographs,
+ CR_In_Emoticons,
+ CR_In_Ornamental_Dingbats,
+ CR_In_Transport_and_Map_Symbols,
+ CR_In_Alchemical_Symbols,
+ CR_In_Geometric_Shapes_Extended,
+ CR_In_Supplemental_Arrows_C,
+ CR_In_Supplemental_Symbols_and_Pictographs,
+ CR_In_Chess_Symbols,
+ CR_In_Symbols_and_Pictographs_Extended_A,
+ CR_In_Symbols_for_Legacy_Computing,
+ CR_In_CJK_Unified_Ideographs_Extension_B,
+ CR_In_CJK_Unified_Ideographs_Extension_C,
+ CR_In_CJK_Unified_Ideographs_Extension_D,
+ CR_In_CJK_Unified_Ideographs_Extension_E,
+ CR_In_CJK_Unified_Ideographs_Extension_F,
+ CR_In_CJK_Unified_Ideographs_Extension_I,
+ CR_In_CJK_Compatibility_Ideographs_Supplement,
+ CR_In_CJK_Unified_Ideographs_Extension_G,
+ CR_In_CJK_Unified_Ideographs_Extension_H,
+ CR_In_CJK_Unified_Ideographs_Extension_J,
+ CR_In_Tags,
+ CR_In_Variation_Selectors_Supplement,
+ CR_In_Supplementary_Private_Use_Area_A,
+ CR_In_Supplementary_Private_Use_Area_B,
+ CR_In_No_Block,
+#endif /* USE_UNICODE_PROPERTIES */
+};
+struct uniname2ctype_struct {
+ short name;
+ unsigned short ctype;
+};
+#define uniname2ctype_offset(str) offsetof(struct uniname2ctype_pool_t, uniname2ctype_pool_##str)
+
+static const struct uniname2ctype_struct *uniname2ctype_p(register const char *str, register size_t len);
+
+#ifndef USE_UNICODE_PROPERTIES
+#define TOTAL_KEYWORDS 15
+#define MIN_WORD_LENGTH 4
+#define MAX_WORD_LENGTH 11
+#define MIN_HASH_VALUE 6
+#define MAX_HASH_VALUE 20
+/* maximum key range = 15, duplicates = 0 */
+#else /* USE_UNICODE_PROPERTIES */
+#ifndef USE_UNICODE_AGE_PROPERTIES
+#define TOTAL_KEYWORDS 916
+#else /* USE_UNICODE_AGE_PROPERTIES */
+#define TOTAL_KEYWORDS 944
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+#define MIN_WORD_LENGTH 1
+#define MAX_WORD_LENGTH 45
+#define MIN_HASH_VALUE 10
+#define MAX_HASH_VALUE 6068
+/* maximum key range = 6059, duplicates = 0 */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+uniname2ctype_hash (register const char *str, register size_t len)
+{
+#ifndef USE_UNICODE_PROPERTIES
+ static const unsigned char asso_values[] =
+#else /* USE_UNICODE_PROPERTIES */
+ static const unsigned short asso_values[] =
+#endif /* USE_UNICODE_PROPERTIES */
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ 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,
+ 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,
+ 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,
+ 21, 21, 21, 21, 21, 21, 21, 3, 12, 5,
+ 4, 21, 21, 10, 21, 1, 21, 21, 11, 21,
+ 2, 1, 1, 21, 1, 7, 4, 6, 21, 1,
+ 4, 21, 21, 21, 21, 21, 21, 21
+#else /* USE_UNICODE_PROPERTIES */
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ 6069, 6069, 6069, 6069, 6069, 6069, 8, 6069, 2, 1,
+ 4, 31, 11, 20, 27, 15, 23, 17, 6069, 6069,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ 6069, 1, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069, 6069,
+ 6069, 6069, 6069, 6069, 6069, 6069, 6069, 22, 28, 165,
+ 250, 131, 1160, 1288, 949, 4, 12, 1918, 452, 7,
+ 8, 1, 756, 2041, 623, 20, 68, 1025, 1509, 246,
+ 1475, 944, 814, 2, 6069, 6069, 6069, 6069, 6069
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+#ifndef USE_UNICODE_PROPERTIES
+ return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];
+#else /* USE_UNICODE_PROPERTIES */
+ register unsigned int hval = (unsigned int)len;
+
+ switch (hval)
+ {
+ default:
+ hval += asso_values[(unsigned char)str[15]];
+ /*FALLTHROUGH*/
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ hval += asso_values[(unsigned char)str[11]];
+ /*FALLTHROUGH*/
+ case 11:
+ case 10:
+ case 9:
+ case 8:
+ case 7:
+ case 6:
+ hval += asso_values[(unsigned char)str[5]];
+ /*FALLTHROUGH*/
+ case 5:
+ hval += asso_values[(unsigned char)str[4]];
+ /*FALLTHROUGH*/
+ case 4:
+ case 3:
+ hval += asso_values[(unsigned char)str[2]];
+ /*FALLTHROUGH*/
+ case 2:
+ hval += asso_values[(unsigned char)str[1]+1];
+ /*FALLTHROUGH*/
+ case 1:
+ hval += asso_values[(unsigned char)str[0]+1];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+#endif /* USE_UNICODE_PROPERTIES */
+}
+
+struct uniname2ctype_pool_t
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ char uniname2ctype_pool_str6[sizeof("word")];
+ char uniname2ctype_pool_str7[sizeof("print")];
+ char uniname2ctype_pool_str8[sizeof("punct")];
+ char uniname2ctype_pool_str9[sizeof("alpha")];
+ char uniname2ctype_pool_str10[sizeof("alnum")];
+ char uniname2ctype_pool_str11[sizeof("xdigit")];
+ char uniname2ctype_pool_str12[sizeof("upper")];
+ char uniname2ctype_pool_str13[sizeof("ascii")];
+ char uniname2ctype_pool_str14[sizeof("cntrl")];
+ char uniname2ctype_pool_str15[sizeof("space")];
+ char uniname2ctype_pool_str16[sizeof("xposixpunct")];
+ char uniname2ctype_pool_str17[sizeof("lower")];
+ char uniname2ctype_pool_str18[sizeof("graph")];
+ char uniname2ctype_pool_str19[sizeof("digit")];
+ char uniname2ctype_pool_str20[sizeof("blank")];
+#else /* USE_UNICODE_PROPERTIES */
+ char uniname2ctype_pool_str10[sizeof("n")];
+ char uniname2ctype_pool_str16[sizeof("m")];
+ char uniname2ctype_pool_str19[sizeof("mn")];
+ char uniname2ctype_pool_str24[sizeof("lm")];
+ char uniname2ctype_pool_str27[sizeof("inmro")];
+ char uniname2ctype_pool_str28[sizeof("innko")];
+ char uniname2ctype_pool_str33[sizeof("mro")];
+ char uniname2ctype_pool_str34[sizeof("mroo")];
+ char uniname2ctype_pool_str38[sizeof("ri")];
+ char uniname2ctype_pool_str40[sizeof("lao")];
+ char uniname2ctype_pool_str41[sizeof("laoo")];
+ char uniname2ctype_pool_str44[sizeof("ahom")];
+ char uniname2ctype_pool_str45[sizeof("hano")];
+ char uniname2ctype_pool_str47[sizeof("miao")];
+ char uniname2ctype_pool_str48[sizeof("hani")];
+ char uniname2ctype_pool_str50[sizeof("inmiao")];
+ char uniname2ctype_pool_str51[sizeof("han")];
+ char uniname2ctype_pool_str52[sizeof("mani")];
+ char uniname2ctype_pool_str53[sizeof("lina")];
+ char uniname2ctype_pool_str56[sizeof("inahom")];
+ char uniname2ctype_pool_str57[sizeof("hanunoo")];
+ char uniname2ctype_pool_str58[sizeof("limb")];
+ char uniname2ctype_pool_str59[sizeof("linb")];
+ char uniname2ctype_pool_str60[sizeof("inmanichaean")];
+ char uniname2ctype_pool_str62[sizeof("alnum")];
+ char uniname2ctype_pool_str63[sizeof("armi")];
+ char uniname2ctype_pool_str64[sizeof("nandinagari")];
+ char uniname2ctype_pool_str67[sizeof("armn")];
+ char uniname2ctype_pool_str69[sizeof("lana")];
+ char uniname2ctype_pool_str70[sizeof("zanb")];
+ char uniname2ctype_pool_str74[sizeof("inosmanya")];
+ char uniname2ctype_pool_str81[sizeof("insamaritan")];
+ char uniname2ctype_pool_str82[sizeof("inbhaiksuki")];
+ char uniname2ctype_pool_str83[sizeof("armenian")];
+ char uniname2ctype_pool_str85[sizeof("sm")];
+ char uniname2ctype_pool_str88[sizeof("inmasaramgondi")];
+ char uniname2ctype_pool_str89[sizeof("s")];
+ char uniname2ctype_pool_str90[sizeof("innabataean")];
+ char uniname2ctype_pool_str92[sizeof("zs")];
+ char uniname2ctype_pool_str93[sizeof("inbasiclatin")];
+ char uniname2ctype_pool_str96[sizeof("innumberforms")];
+ char uniname2ctype_pool_str102[sizeof("arab")];
+ char uniname2ctype_pool_str107[sizeof("inmusicalsymbols")];
+ char uniname2ctype_pool_str115[sizeof("latn")];
+ char uniname2ctype_pool_str117[sizeof("inthai")];
+ char uniname2ctype_pool_str124[sizeof("latin")];
+ char uniname2ctype_pool_str135[sizeof("shavian")];
+ char uniname2ctype_pool_str141[sizeof("initialpunctuation")];
+ char uniname2ctype_pool_str144[sizeof("hatran")];
+ char uniname2ctype_pool_str149[sizeof("di")];
+ char uniname2ctype_pool_str155[sizeof("inthaana")];
+ char uniname2ctype_pool_str157[sizeof("intoto")];
+ char uniname2ctype_pool_str164[sizeof("nabataean")];
+ char uniname2ctype_pool_str169[sizeof("intaitham")];
+ char uniname2ctype_pool_str175[sizeof("inarabicpresentationformsa")];
+ char uniname2ctype_pool_str180[sizeof("inbraillepatterns")];
+ char uniname2ctype_pool_str181[sizeof("inarabicpresentationformsb")];
+ char uniname2ctype_pool_str186[sizeof("ids")];
+ char uniname2ctype_pool_str190[sizeof("dia")];
+ char uniname2ctype_pool_str191[sizeof("inarmenian")];
+ char uniname2ctype_pool_str195[sizeof("idsb")];
+ char uniname2ctype_pool_str199[sizeof("intransportandmapsymbols")];
+ char uniname2ctype_pool_str202[sizeof("inideographicsymbolsandpunctuation")];
+ char uniname2ctype_pool_str203[sizeof("inavestan")];
+ char uniname2ctype_pool_str209[sizeof("inipaextensions")];
+ char uniname2ctype_pool_str211[sizeof("inelbasan")];
+ char uniname2ctype_pool_str213[sizeof("inopticalcharacterrecognition")];
+ char uniname2ctype_pool_str215[sizeof("brai")];
+ char uniname2ctype_pool_str219[sizeof("bamum")];
+ char uniname2ctype_pool_str220[sizeof("incham")];
+ char uniname2ctype_pool_str227[sizeof("inideographicdescriptioncharacters")];
+ char uniname2ctype_pool_str228[sizeof("brahmi")];
+ char uniname2ctype_pool_str235[sizeof("idst")];
+ char uniname2ctype_pool_str237[sizeof("bass")];
+ char uniname2ctype_pool_str242[sizeof("mandaic")];
+ char uniname2ctype_pool_str244[sizeof("inemoticons")];
+ char uniname2ctype_pool_str247[sizeof("incommonindicnumberforms")];
+ char uniname2ctype_pool_str257[sizeof("intibetan")];
+ char uniname2ctype_pool_str258[sizeof("inarabic")];
+ char uniname2ctype_pool_str260[sizeof("nbat")];
+ char uniname2ctype_pool_str261[sizeof("cn")];
+ char uniname2ctype_pool_str267[sizeof("inancientsymbols")];
+ char uniname2ctype_pool_str268[sizeof("ci")];
+ char uniname2ctype_pool_str274[sizeof("ascii")];
+ char uniname2ctype_pool_str275[sizeof("mcm")];
+ char uniname2ctype_pool_str279[sizeof("ideo")];
+ char uniname2ctype_pool_str284[sizeof("inmodi")];
+ char uniname2ctype_pool_str285[sizeof("vai")];
+ char uniname2ctype_pool_str286[sizeof("vaii")];
+ char uniname2ctype_pool_str287[sizeof("cham")];
+ char uniname2ctype_pool_str289[sizeof("inmyanmarextendeda")];
+ char uniname2ctype_pool_str291[sizeof("nand")];
+ char uniname2ctype_pool_str295[sizeof("inmyanmarextendedb")];
+ char uniname2ctype_pool_str298[sizeof("mand")];
+ char uniname2ctype_pool_str310[sizeof("cans")];
+ char uniname2ctype_pool_str312[sizeof("inoldsogdian")];
+ char uniname2ctype_pool_str315[sizeof("chorasmian")];
+ char uniname2ctype_pool_str317[sizeof("innewa")];
+ char uniname2ctype_pool_str333[sizeof("chakma")];
+ char uniname2ctype_pool_str335[sizeof("incuneiform")];
+ char uniname2ctype_pool_str336[sizeof("vs")];
+ char uniname2ctype_pool_str340[sizeof("cs")];
+ char uniname2ctype_pool_str342[sizeof("sind")];
+ char uniname2ctype_pool_str344[sizeof("shaw")];
+ char uniname2ctype_pool_str359[sizeof("inspecials")];
+ char uniname2ctype_pool_str364[sizeof("inchesssymbols")];
+ char uniname2ctype_pool_str366[sizeof("avst")];
+ char uniname2ctype_pool_str373[sizeof("inblockelements")];
+ char uniname2ctype_pool_str384[sizeof("nd")];
+ char uniname2ctype_pool_str395[sizeof("sharada")];
+ char uniname2ctype_pool_str398[sizeof("inmiscellaneoussymbols")];
+ char uniname2ctype_pool_str400[sizeof("inmiscellaneousmathematicalsymbolsa")];
+ char uniname2ctype_pool_str402[sizeof("sidt")];
+ char uniname2ctype_pool_str406[sizeof("inmiscellaneousmathematicalsymbolsb")];
+ char uniname2ctype_pool_str407[sizeof("inmiscellaneoussymbolsandarrows")];
+ char uniname2ctype_pool_str410[sizeof("arabic")];
+ char uniname2ctype_pool_str412[sizeof("inmiscellaneoussymbolsandpictographs")];
+ char uniname2ctype_pool_str416[sizeof("c")];
+ char uniname2ctype_pool_str424[sizeof("lc")];
+ char uniname2ctype_pool_str425[sizeof("mc")];
+ char uniname2ctype_pool_str426[sizeof("inmedefaidrin")];
+ char uniname2ctype_pool_str432[sizeof("inmyanmarextendedc")];
+ char uniname2ctype_pool_str433[sizeof("insundanese")];
+ char uniname2ctype_pool_str438[sizeof("indominotiles")];
+ char uniname2ctype_pool_str440[sizeof("insymbolsandpictographsextendeda")];
+ char uniname2ctype_pool_str441[sizeof("inwancho")];
+ char uniname2ctype_pool_str444[sizeof("inolditalic")];
+ char uniname2ctype_pool_str447[sizeof("inmodifiertoneletters")];
+ char uniname2ctype_pool_str448[sizeof("incb=consonant")];
+ char uniname2ctype_pool_str451[sizeof("sd")];
+ char uniname2ctype_pool_str452[sizeof("inmandaic")];
+ char uniname2ctype_pool_str456[sizeof("inmiscellaneoussymbolssupplement")];
+ char uniname2ctype_pool_str458[sizeof("nko")];
+ char uniname2ctype_pool_str459[sizeof("nkoo")];
+ char uniname2ctype_pool_str460[sizeof("l")];
+ char uniname2ctype_pool_str461[sizeof("inmeeteimayekextensions")];
+ char uniname2ctype_pool_str462[sizeof("nl")];
+ char uniname2ctype_pool_str463[sizeof("zl")];
+ char uniname2ctype_pool_str468[sizeof("ll")];
+ char uniname2ctype_pool_str472[sizeof("inlao")];
+ char uniname2ctype_pool_str473[sizeof("khoj")];
+ char uniname2ctype_pool_str476[sizeof("idc")];
+ char uniname2ctype_pool_str477[sizeof("innewtailue")];
+ char uniname2ctype_pool_str483[sizeof("inolonal")];
+ char uniname2ctype_pool_str485[sizeof("sc")];
+ char uniname2ctype_pool_str491[sizeof("indeseret")];
+ char uniname2ctype_pool_str496[sizeof("incuneiformnumbersandpunctuation")];
+ char uniname2ctype_pool_str502[sizeof("krai")];
+ char uniname2ctype_pool_str505[sizeof("inarabicextendeda")];
+ char uniname2ctype_pool_str508[sizeof("inoldturkic")];
+ char uniname2ctype_pool_str510[sizeof("avestan")];
+ char uniname2ctype_pool_str511[sizeof("inarabicextendedb")];
+ char uniname2ctype_pool_str512[sizeof("inmalayalam")];
+ char uniname2ctype_pool_str513[sizeof("kharoshthi")];
+ char uniname2ctype_pool_str514[sizeof("kana")];
+ char uniname2ctype_pool_str523[sizeof("inadlam")];
+ char uniname2ctype_pool_str525[sizeof("idcontinue")];
+ char uniname2ctype_pool_str549[sizeof("insiddham")];
+ char uniname2ctype_pool_str551[sizeof("intamil")];
+ char uniname2ctype_pool_str553[sizeof("inmultani")];
+ char uniname2ctype_pool_str554[sizeof("intolongsiki")];
+ char uniname2ctype_pool_str556[sizeof("kits")];
+ char uniname2ctype_pool_str571[sizeof("incb=extend")];
+ char uniname2ctype_pool_str574[sizeof("sidetic")];
+ char uniname2ctype_pool_str584[sizeof("sidd")];
+ char uniname2ctype_pool_str587[sizeof("incontrolpictures")];
+ char uniname2ctype_pool_str588[sizeof("insidetic")];
+ char uniname2ctype_pool_str591[sizeof("sinhala")];
+ char uniname2ctype_pool_str605[sizeof("inlatinextendeda")];
+ char uniname2ctype_pool_str617[sizeof("inlatinextendedb")];
+ char uniname2ctype_pool_str622[sizeof("adlm")];
+ char uniname2ctype_pool_str630[sizeof("adlam")];
+ char uniname2ctype_pool_str635[sizeof("inlineara")];
+ char uniname2ctype_pool_str637[sizeof("intamilsupplement")];
+ char uniname2ctype_pool_str638[sizeof("inbalinese")];
+ char uniname2ctype_pool_str645[sizeof("inspacingmodifierletters")];
+ char uniname2ctype_pool_str648[sizeof("inarabicextendedc")];
+ char uniname2ctype_pool_str650[sizeof("inlycian")];
+ char uniname2ctype_pool_str653[sizeof("bali")];
+ char uniname2ctype_pool_str665[sizeof("hira")];
+ char uniname2ctype_pool_str667[sizeof("cc")];
+ char uniname2ctype_pool_str674[sizeof("insmallkanaextension")];
+ char uniname2ctype_pool_str675[sizeof("intaile")];
+ char uniname2ctype_pool_str681[sizeof("qaai")];
+ char uniname2ctype_pool_str682[sizeof("inmyanmar")];
+ char uniname2ctype_pool_str684[sizeof("narb")];
+ char uniname2ctype_pool_str687[sizeof("inarrows")];
+ char uniname2ctype_pool_str701[sizeof("lineara")];
+ char uniname2ctype_pool_str707[sizeof("linearb")];
+ char uniname2ctype_pool_str709[sizeof("insharada")];
+ char uniname2ctype_pool_str716[sizeof("inruminumeralsymbols")];
+ char uniname2ctype_pool_str721[sizeof("masaramgondi")];
+ char uniname2ctype_pool_str727[sizeof("hatr")];
+ char uniname2ctype_pool_str729[sizeof("knda")];
+ char uniname2ctype_pool_str730[sizeof("samr")];
+ char uniname2ctype_pool_str734[sizeof("kawi")];
+ char uniname2ctype_pool_str735[sizeof("inlydian")];
+ char uniname2ctype_pool_str747[sizeof("samaritan")];
+ char uniname2ctype_pool_str751[sizeof("sarb")];
+ char uniname2ctype_pool_str760[sizeof("no")];
+ char uniname2ctype_pool_str762[sizeof("bidic")];
+ char uniname2ctype_pool_str766[sizeof("lo")];
+ char uniname2ctype_pool_str780[sizeof("hmnp")];
+ char uniname2ctype_pool_str784[sizeof("onao")];
+ char uniname2ctype_pool_str788[sizeof("inlowsurrogates")];
+ char uniname2ctype_pool_str789[sizeof("kannada")];
+ char uniname2ctype_pool_str795[sizeof("inlinearbideograms")];
+ char uniname2ctype_pool_str799[sizeof("inletterlikesymbols")];
+ char uniname2ctype_pool_str803[sizeof("cased")];
+ char uniname2ctype_pool_str809[sizeof("inbopomofo")];
+ char uniname2ctype_pool_str810[sizeof("inberiaerfe")];
+ char uniname2ctype_pool_str815[sizeof("lineseparator")];
+ char uniname2ctype_pool_str817[sizeof("z")];
+ char uniname2ctype_pool_str818[sizeof("insymbolsforlegacycomputingsupplement")];
+ char uniname2ctype_pool_str820[sizeof("inrunic")];
+ char uniname2ctype_pool_str821[sizeof("incarian")];
+ char uniname2ctype_pool_str823[sizeof("inlatinextendede")];
+ char uniname2ctype_pool_str825[sizeof("inmarchen")];
+ char uniname2ctype_pool_str827[sizeof("so")];
+ char uniname2ctype_pool_str828[sizeof("marc")];
+ char uniname2ctype_pool_str829[sizeof("oriya")];
+ char uniname2ctype_pool_str830[sizeof("inchorasmian")];
+ char uniname2ctype_pool_str832[sizeof("yi")];
+ char uniname2ctype_pool_str833[sizeof("insyriac")];
+ char uniname2ctype_pool_str838[sizeof("yiii")];
+ char uniname2ctype_pool_str840[sizeof("alpha")];
+ char uniname2ctype_pool_str842[sizeof("qaac")];
+ char uniname2ctype_pool_str852[sizeof("insundanesesupplement")];
+ char uniname2ctype_pool_str857[sizeof("osma")];
+ char uniname2ctype_pool_str880[sizeof("inmiscellaneoustechnical")];
+ char uniname2ctype_pool_str883[sizeof("idstart")];
+ char uniname2ctype_pool_str890[sizeof("inenclosedcjklettersandmonths")];
+ char uniname2ctype_pool_str891[sizeof("inlatinextendedc")];
+ char uniname2ctype_pool_str894[sizeof("dsrt")];
+ char uniname2ctype_pool_str898[sizeof("odi")];
+ char uniname2ctype_pool_str901[sizeof("chrs")];
+ char uniname2ctype_pool_str909[sizeof("cari")];
+ char uniname2ctype_pool_str919[sizeof("innandinagari")];
+ char uniname2ctype_pool_str923[sizeof("balinese")];
+ char uniname2ctype_pool_str924[sizeof("inwarangciti")];
+ char uniname2ctype_pool_str929[sizeof("inphoenician")];
+ char uniname2ctype_pool_str940[sizeof("kali")];
+ char uniname2ctype_pool_str942[sizeof("inoldnortharabian")];
+ char uniname2ctype_pool_str944[sizeof("radical")];
+ char uniname2ctype_pool_str945[sizeof("carian")];
+ char uniname2ctype_pool_str947[sizeof("idsbinaryoperator")];
+ char uniname2ctype_pool_str949[sizeof("shrd")];
+ char uniname2ctype_pool_str954[sizeof("inoldsoutharabian")];
+ char uniname2ctype_pool_str966[sizeof("diacritic")];
+ char uniname2ctype_pool_str970[sizeof("mlym")];
+ char uniname2ctype_pool_str975[sizeof("zinh")];
+ char uniname2ctype_pool_str978[sizeof("inphaistosdisc")];
+ char uniname2ctype_pool_str980[sizeof("incyrillic")];
+ char uniname2ctype_pool_str985[sizeof("ininscriptionalpahlavi")];
+ char uniname2ctype_pool_str988[sizeof("insoyombo")];
+ char uniname2ctype_pool_str990[sizeof("ininscriptionalparthian")];
+ char uniname2ctype_pool_str991[sizeof("inoriya")];
+ char uniname2ctype_pool_str994[sizeof("lyci")];
+ char uniname2ctype_pool_str999[sizeof("inogham")];
+ char uniname2ctype_pool_str1001[sizeof("mahj")];
+ char uniname2ctype_pool_str1003[sizeof("gran")];
+ char uniname2ctype_pool_str1005[sizeof("inmahajani")];
+ char uniname2ctype_pool_str1009[sizeof("co")];
+ char uniname2ctype_pool_str1012[sizeof("cher")];
+ char uniname2ctype_pool_str1016[sizeof("alphabetic")];
+ char uniname2ctype_pool_str1021[sizeof("insinhala")];
+ char uniname2ctype_pool_str1022[sizeof("modi")];
+ char uniname2ctype_pool_str1024[sizeof("inbrahmi")];
+ char uniname2ctype_pool_str1028[sizeof("loe")];
+ char uniname2ctype_pool_str1030[sizeof("lycian")];
+ char uniname2ctype_pool_str1031[sizeof("mahajani")];
+ char uniname2ctype_pool_str1036[sizeof("common")];
+ char uniname2ctype_pool_str1037[sizeof("intaiyo")];
+ char uniname2ctype_pool_str1038[sizeof("inhanifirohingya")];
+ char uniname2ctype_pool_str1040[sizeof("inbassavah")];
+ char uniname2ctype_pool_str1041[sizeof("sinh")];
+ char uniname2ctype_pool_str1042[sizeof("oids")];
+ char uniname2ctype_pool_str1044[sizeof("inlatinextendedadditional")];
+ char uniname2ctype_pool_str1045[sizeof("inyijinghexagramsymbols")];
+ char uniname2ctype_pool_str1048[sizeof("inoldpersian")];
+ char uniname2ctype_pool_str1056[sizeof("bidicontrol")];
+ char uniname2ctype_pool_str1057[sizeof("math")];
+ char uniname2ctype_pool_str1058[sizeof("inarabicsupplement")];
+ char uniname2ctype_pool_str1059[sizeof("thai")];
+ char uniname2ctype_pool_str1061[sizeof("inlatinextendedd")];
+ char uniname2ctype_pool_str1064[sizeof("taiyo")];
+ char uniname2ctype_pool_str1068[sizeof("lisu")];
+ char uniname2ctype_pool_str1072[sizeof("tnsa")];
+ char uniname2ctype_pool_str1073[sizeof("incherokee")];
+ char uniname2ctype_pool_str1077[sizeof("thaa")];
+ char uniname2ctype_pool_str1079[sizeof("lydi")];
+ char uniname2ctype_pool_str1087[sizeof("inbamum")];
+ char uniname2ctype_pool_str1090[sizeof("khmr")];
+ char uniname2ctype_pool_str1094[sizeof("inbyzantinemusicalsymbols")];
+ char uniname2ctype_pool_str1102[sizeof("lt")];
+ char uniname2ctype_pool_str1105[sizeof("khar")];
+ char uniname2ctype_pool_str1109[sizeof("thaana")];
+ char uniname2ctype_pool_str1113[sizeof("osage")];
+ char uniname2ctype_pool_str1115[sizeof("lydian")];
+ char uniname2ctype_pool_str1117[sizeof("inanatolianhieroglyphs")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1120[sizeof("age=11.0")];
+ char uniname2ctype_pool_str1121[sizeof("age=10.0")];
+ char uniname2ctype_pool_str1122[sizeof("age=12.1")];
+ char uniname2ctype_pool_str1123[sizeof("age=12.0")];
+ char uniname2ctype_pool_str1125[sizeof("age=1.1")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1126[sizeof("insylotinagri")];
+ char uniname2ctype_pool_str1127[sizeof("anatolianhieroglyphs")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1128[sizeof("age=2.1")];
+ char uniname2ctype_pool_str1129[sizeof("age=2.0")];
+ char uniname2ctype_pool_str1130[sizeof("age=14.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1131[sizeof("tangsa")];
+ char uniname2ctype_pool_str1132[sizeof("dash")];
+ char uniname2ctype_pool_str1133[sizeof("incombiningdiacriticalmarks")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1134[sizeof("age=17.0")];
+ char uniname2ctype_pool_str1135[sizeof("age=4.1")];
+ char uniname2ctype_pool_str1136[sizeof("age=4.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1137[sizeof("tibt")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1138[sizeof("age=15.1")];
+ char uniname2ctype_pool_str1139[sizeof("age=15.0")];
+ char uniname2ctype_pool_str1140[sizeof("age=7.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1141[sizeof("inolchiki")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1142[sizeof("age=9.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1143[sizeof("incombiningdiacriticalmarksforsymbols")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1144[sizeof("age=5.1")];
+ char uniname2ctype_pool_str1145[sizeof("age=5.0")];
+ char uniname2ctype_pool_str1146[sizeof("age=16.0")];
+ char uniname2ctype_pool_str1147[sizeof("age=5.2")];
+ char uniname2ctype_pool_str1148[sizeof("age=8.0")];
+ char uniname2ctype_pool_str1150[sizeof("age=13.0")];
+ char uniname2ctype_pool_str1151[sizeof("age=6.1")];
+ char uniname2ctype_pool_str1152[sizeof("age=6.0")];
+ char uniname2ctype_pool_str1154[sizeof("age=6.2")];
+ char uniname2ctype_pool_str1155[sizeof("age=3.1")];
+ char uniname2ctype_pool_str1156[sizeof("age=3.0")];
+ char uniname2ctype_pool_str1158[sizeof("age=3.2")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1159[sizeof("inarabicmathematicalalphabeticsymbols")];
+ char uniname2ctype_pool_str1160[sizeof("brah")];
+ char uniname2ctype_pool_str1170[sizeof("tibetan")];
+ char uniname2ctype_pool_str1172[sizeof("mtei")];
+ char uniname2ctype_pool_str1175[sizeof("incoptic")];
+ char uniname2ctype_pool_str1176[sizeof("manichaean")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ char uniname2ctype_pool_str1181[sizeof("age=6.3")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ char uniname2ctype_pool_str1182[sizeof("emoji")];
+ char uniname2ctype_pool_str1187[sizeof("oidc")];
+ char uniname2ctype_pool_str1191[sizeof("incombiningdiacriticalmarkssupplement")];
+ char uniname2ctype_pool_str1192[sizeof("idsu")];
+ char uniname2ctype_pool_str1195[sizeof("saurashtra")];
+ char uniname2ctype_pool_str1196[sizeof("inoldpermic")];
+ char uniname2ctype_pool_str1199[sizeof("closepunctuation")];
+ char uniname2ctype_pool_str1209[sizeof("incombininghalfmarks")];
+ char uniname2ctype_pool_str1214[sizeof("incopticepactnumbers")];
+ char uniname2ctype_pool_str1221[sizeof("elba")];
+ char uniname2ctype_pool_str1225[sizeof("xdigit")];
+ char uniname2ctype_pool_str1228[sizeof("cntrl")];
+ char uniname2ctype_pool_str1229[sizeof("bamu")];
+ char uniname2ctype_pool_str1230[sizeof("xids")];
+ char uniname2ctype_pool_str1239[sizeof("inoldhungarian")];
+ char uniname2ctype_pool_str1241[sizeof("grext")];
+ char uniname2ctype_pool_str1242[sizeof("mongolian")];
+ char uniname2ctype_pool_str1243[sizeof("sterm")];
+ char uniname2ctype_pool_str1249[sizeof("braille")];
+ char uniname2ctype_pool_str1251[sizeof("inbuhid")];
+ char uniname2ctype_pool_str1252[sizeof("elbasan")];
+ char uniname2ctype_pool_str1259[sizeof("zanabazarsquare")];
+ char uniname2ctype_pool_str1260[sizeof("incountingrodnumerals")];
+ char uniname2ctype_pool_str1264[sizeof("inenclosedalphanumerics")];
+ char uniname2ctype_pool_str1265[sizeof("incb=linker")];
+ char uniname2ctype_pool_str1267[sizeof("taiviet")];
+ char uniname2ctype_pool_str1269[sizeof("inelymaic")];
+ char uniname2ctype_pool_str1272[sizeof("inethiopic")];
+ char uniname2ctype_pool_str1275[sizeof("sgnw")];
+ char uniname2ctype_pool_str1277[sizeof("olditalic")];
+ char uniname2ctype_pool_str1279[sizeof("vith")];
+ char uniname2ctype_pool_str1285[sizeof("grbase")];
+ char uniname2ctype_pool_str1286[sizeof("hluw")];
+ char uniname2ctype_pool_str1292[sizeof("intodhri")];
+ char uniname2ctype_pool_str1299[sizeof("asciihexdigit")];
+ char uniname2ctype_pool_str1301[sizeof("me")];
+ char uniname2ctype_pool_str1312[sizeof("hmng")];
+ char uniname2ctype_pool_str1315[sizeof("siddham")];
+ char uniname2ctype_pool_str1321[sizeof("inenclosedalphanumericsupplement")];
+ char uniname2ctype_pool_str1324[sizeof("taile")];
+ char uniname2ctype_pool_str1328[sizeof("nagm")];
+ char uniname2ctype_pool_str1332[sizeof("hang")];
+ char uniname2ctype_pool_str1334[sizeof("inscriptionalparthian")];
+ char uniname2ctype_pool_str1335[sizeof("inmongolian")];
+ char uniname2ctype_pool_str1336[sizeof("innagmundari")];
+ char uniname2ctype_pool_str1339[sizeof("sylo")];
+ char uniname2ctype_pool_str1347[sizeof("ingunjalagondi")];
+ char uniname2ctype_pool_str1349[sizeof("ingujarati")];
+ char uniname2ctype_pool_str1350[sizeof("inbengali")];
+ char uniname2ctype_pool_str1351[sizeof("khitansmallscript")];
+ char uniname2ctype_pool_str1357[sizeof("xidcontinue")];
+ char uniname2ctype_pool_str1362[sizeof("ingrantha")];
+ char uniname2ctype_pool_str1363[sizeof("insinhalaarchaicnumbers")];
+ char uniname2ctype_pool_str1368[sizeof("connectorpunctuation")];
+ char uniname2ctype_pool_str1370[sizeof("inpalmyrene")];
+ char uniname2ctype_pool_str1371[sizeof("incombiningdiacriticalmarksextended")];
+ char uniname2ctype_pool_str1372[sizeof("xidstart")];
+ char uniname2ctype_pool_str1375[sizeof("xidc")];
+ char uniname2ctype_pool_str1397[sizeof("inancientgreekmusicalnotation")];
+ char uniname2ctype_pool_str1401[sizeof("inancientgreeknumbers")];
+ char uniname2ctype_pool_str1407[sizeof("intangsa")];
+ char uniname2ctype_pool_str1415[sizeof("intags")];
+ char uniname2ctype_pool_str1416[sizeof("inlepcha")];
+ char uniname2ctype_pool_str1420[sizeof("caucasianalbanian")];
+ char uniname2ctype_pool_str1421[sizeof("sylotinagri")];
+ char uniname2ctype_pool_str1423[sizeof("emod")];
+ char uniname2ctype_pool_str1425[sizeof("incaucasianalbanian")];
+ char uniname2ctype_pool_str1429[sizeof("intagbanwa")];
+ char uniname2ctype_pool_str1430[sizeof("mend")];
+ char uniname2ctype_pool_str1433[sizeof("newa")];
+ char uniname2ctype_pool_str1435[sizeof("inearlydynasticcuneiform")];
+ char uniname2ctype_pool_str1447[sizeof("kaithi")];
+ char uniname2ctype_pool_str1453[sizeof("intangut")];
+ char uniname2ctype_pool_str1456[sizeof("mymr")];
+ char uniname2ctype_pool_str1462[sizeof("inosage")];
+ char uniname2ctype_pool_str1467[sizeof("inmahjongtiles")];
+ char uniname2ctype_pool_str1470[sizeof("malayalam")];
+ char uniname2ctype_pool_str1473[sizeof("sora")];
+ char uniname2ctype_pool_str1474[sizeof("inbuginese")];
+ char uniname2ctype_pool_str1479[sizeof("emojimodifierbase")];
+ char uniname2ctype_pool_str1489[sizeof("induployan")];
+ char uniname2ctype_pool_str1497[sizeof("ingeometricshapes")];
+ char uniname2ctype_pool_str1498[sizeof("ingeneralpunctuation")];
+ char uniname2ctype_pool_str1503[sizeof("myanmar")];
+ char uniname2ctype_pool_str1510[sizeof("inlatin1supplement")];
+ char uniname2ctype_pool_str1515[sizeof("ital")];
+ char uniname2ctype_pool_str1516[sizeof("taml")];
+ char uniname2ctype_pool_str1517[sizeof("inaegeannumbers")];
+ char uniname2ctype_pool_str1528[sizeof("insharadasupplement")];
+ char uniname2ctype_pool_str1530[sizeof("mathsymbol")];
+ char uniname2ctype_pool_str1532[sizeof("inlimbu")];
+ char uniname2ctype_pool_str1535[sizeof("invai")];
+ char uniname2ctype_pool_str1551[sizeof("emojicomponent")];
+ char uniname2ctype_pool_str1552[sizeof("insuttonsignwriting")];
+ char uniname2ctype_pool_str1572[sizeof("digit")];
+ char uniname2ctype_pool_str1573[sizeof("newtailue")];
+ char uniname2ctype_pool_str1581[sizeof("inshavian")];
+ char uniname2ctype_pool_str1588[sizeof("insogdian")];
+ char uniname2ctype_pool_str1589[sizeof("indingbats")];
+ char uniname2ctype_pool_str1590[sizeof("imperialaramaic")];
+ char uniname2ctype_pool_str1598[sizeof("intulutigalari")];
+ char uniname2ctype_pool_str1600[sizeof("incyprominoan")];
+ char uniname2ctype_pool_str1606[sizeof("glagolitic")];
+ char uniname2ctype_pool_str1614[sizeof("ebase")];
+ char uniname2ctype_pool_str1615[sizeof("intaixuanjingsymbols")];
+ char uniname2ctype_pool_str1618[sizeof("inbamumsupplement")];
+ char uniname2ctype_pool_str1626[sizeof("gara")];
+ char uniname2ctype_pool_str1633[sizeof("insyriacsupplement")];
+ char uniname2ctype_pool_str1634[sizeof("casedletter")];
+ char uniname2ctype_pool_str1636[sizeof("zzzz")];
+ char uniname2ctype_pool_str1639[sizeof("inhiragana")];
+ char uniname2ctype_pool_str1640[sizeof("tale")];
+ char uniname2ctype_pool_str1641[sizeof("canadianaboriginal")];
+ char uniname2ctype_pool_str1642[sizeof("ahex")];
+ char uniname2ctype_pool_str1644[sizeof("inmayannumerals")];
+ char uniname2ctype_pool_str1648[sizeof("inzanabazarsquare")];
+ char uniname2ctype_pool_str1654[sizeof("inyiradicals")];
+ char uniname2ctype_pool_str1655[sizeof("inscriptionalpahlavi")];
+ char uniname2ctype_pool_str1668[sizeof("inalchemicalsymbols")];
+ char uniname2ctype_pool_str1669[sizeof("inhatran")];
+ char uniname2ctype_pool_str1670[sizeof("assigned")];
+ char uniname2ctype_pool_str1671[sizeof("intaiviet")];
+ char uniname2ctype_pool_str1674[sizeof("syrc")];
+ char uniname2ctype_pool_str1682[sizeof("bopo")];
+ char uniname2ctype_pool_str1684[sizeof("intirhuta")];
+ char uniname2ctype_pool_str1688[sizeof("oldnortharabian")];
+ char uniname2ctype_pool_str1690[sizeof("insupplementalmathematicaloperators")];
+ char uniname2ctype_pool_str1694[sizeof("bopomofo")];
+ char uniname2ctype_pool_str1696[sizeof("olonal")];
+ char uniname2ctype_pool_str1697[sizeof("injavanese")];
+ char uniname2ctype_pool_str1698[sizeof("insunuwar")];
+ char uniname2ctype_pool_str1707[sizeof("inmathematicalalphanumericsymbols")];
+ char uniname2ctype_pool_str1713[sizeof("inimperialaramaic")];
+ char uniname2ctype_pool_str1714[sizeof("khmer")];
+ char uniname2ctype_pool_str1724[sizeof("gonm")];
+ char uniname2ctype_pool_str1727[sizeof("hyphen")];
+ char uniname2ctype_pool_str1731[sizeof("insuperscriptsandsubscripts")];
+ char uniname2ctype_pool_str1733[sizeof("inenclosedideographicsupplement")];
+ char uniname2ctype_pool_str1735[sizeof("ingeometricshapesextended")];
+ char uniname2ctype_pool_str1737[sizeof("insaurashtra")];
+ char uniname2ctype_pool_str1738[sizeof("ogam")];
+ char uniname2ctype_pool_str1746[sizeof("orya")];
+ char uniname2ctype_pool_str1748[sizeof("saur")];
+ char uniname2ctype_pool_str1754[sizeof("marchen")];
+ char uniname2ctype_pool_str1755[sizeof("sundanese")];
+ char uniname2ctype_pool_str1762[sizeof("khudawadi")];
+ char uniname2ctype_pool_str1773[sizeof("soyo")];
+ char uniname2ctype_pool_str1775[sizeof("whitespace")];
+ char uniname2ctype_pool_str1778[sizeof("uideo")];
+ char uniname2ctype_pool_str1785[sizeof("oldpersian")];
+ char uniname2ctype_pool_str1787[sizeof("inyezidi")];
+ char uniname2ctype_pool_str1790[sizeof("kiratrai")];
+ char uniname2ctype_pool_str1793[sizeof("inlisusupplement")];
+ char uniname2ctype_pool_str1796[sizeof("mero")];
+ char uniname2ctype_pool_str1800[sizeof("symbol")];
+ char uniname2ctype_pool_str1811[sizeof("soyombo")];
+ char uniname2ctype_pool_str1812[sizeof("osmanya")];
+ char uniname2ctype_pool_str1814[sizeof("indevanagari")];
+ char uniname2ctype_pool_str1816[sizeof("unassigned")];
+ char uniname2ctype_pool_str1818[sizeof("bengali")];
+ char uniname2ctype_pool_str1819[sizeof("hebr")];
+ char uniname2ctype_pool_str1821[sizeof("hebrew")];
+ char uniname2ctype_pool_str1824[sizeof("inornamentaldingbats")];
+ char uniname2ctype_pool_str1829[sizeof("invedicextensions")];
+ char uniname2ctype_pool_str1834[sizeof("copt")];
+ char uniname2ctype_pool_str1836[sizeof("ingreekextended")];
+ char uniname2ctype_pool_str1839[sizeof("sund")];
+ char uniname2ctype_pool_str1847[sizeof("cyprominoan")];
+ char uniname2ctype_pool_str1848[sizeof("inherited")];
+ char uniname2ctype_pool_str1854[sizeof("toto")];
+ char uniname2ctype_pool_str1858[sizeof("inugaritic")];
+ char uniname2ctype_pool_str1863[sizeof("syriac")];
+ char uniname2ctype_pool_str1864[sizeof("cwt")];
+ char uniname2ctype_pool_str1867[sizeof("inhebrew")];
+ char uniname2ctype_pool_str1872[sizeof("runic")];
+ char uniname2ctype_pool_str1877[sizeof("inmongoliansupplement")];
+ char uniname2ctype_pool_str1884[sizeof("inshorthandformatcontrols")];
+ char uniname2ctype_pool_str1900[sizeof("cypriot")];
+ char uniname2ctype_pool_str1901[sizeof("cwcm")];
+ char uniname2ctype_pool_str1910[sizeof("ingreekandcoptic")];
+ char uniname2ctype_pool_str1920[sizeof("any")];
+ char uniname2ctype_pool_str1923[sizeof("inolduyghur")];
+ char uniname2ctype_pool_str1936[sizeof("inznamennymusicalnotation")];
+ char uniname2ctype_pool_str1937[sizeof("lowercase")];
+ char uniname2ctype_pool_str1941[sizeof("oldpermic")];
+ char uniname2ctype_pool_str1943[sizeof("ingeorgian")];
+ char uniname2ctype_pool_str1945[sizeof("ingurmukhi")];
+ char uniname2ctype_pool_str1947[sizeof("emojimodifier")];
+ char uniname2ctype_pool_str1956[sizeof("inkhojki")];
+ char uniname2ctype_pool_str1958[sizeof("aghb")];
+ char uniname2ctype_pool_str1960[sizeof("merc")];
+ char uniname2ctype_pool_str1966[sizeof("inrejang")];
+ char uniname2ctype_pool_str1969[sizeof("tamil")];
+ char uniname2ctype_pool_str1972[sizeof("indevanagariextendeda")];
+ char uniname2ctype_pool_str1974[sizeof("inalphabeticpresentationforms")];
+ char uniname2ctype_pool_str1975[sizeof("hangul")];
+ char uniname2ctype_pool_str1977[sizeof("inmeroitichieroglyphs")];
+ char uniname2ctype_pool_str1978[sizeof("inkannada")];
+ char uniname2ctype_pool_str1979[sizeof("hiragana")];
+ char uniname2ctype_pool_str1980[sizeof("maka")];
+ char uniname2ctype_pool_str1983[sizeof("inkanbun")];
+ char uniname2ctype_pool_str1987[sizeof("insorasompeng")];
+ char uniname2ctype_pool_str2001[sizeof("inmathematicaloperators")];
+ char uniname2ctype_pool_str2002[sizeof("tayo")];
+ char uniname2ctype_pool_str2005[sizeof("inhanunoo")];
+ char uniname2ctype_pool_str2010[sizeof("multani")];
+ char uniname2ctype_pool_str2015[sizeof("inkaithi")];
+ char uniname2ctype_pool_str2022[sizeof("innushu")];
+ char uniname2ctype_pool_str2023[sizeof("emojipresentation")];
+ char uniname2ctype_pool_str2028[sizeof("insymbolsforlegacycomputing")];
+ char uniname2ctype_pool_str2029[sizeof("meroiticcursive")];
+ char uniname2ctype_pool_str2037[sizeof("grantha")];
+ char uniname2ctype_pool_str2040[sizeof("inlinearbsyllabary")];
+ char uniname2ctype_pool_str2041[sizeof("mult")];
+ char uniname2ctype_pool_str2042[sizeof("taitham")];
+ char uniname2ctype_pool_str2047[sizeof("nshu")];
+ char uniname2ctype_pool_str2049[sizeof("incyrillicsupplement")];
+ char uniname2ctype_pool_str2051[sizeof("dashpunctuation")];
+ char uniname2ctype_pool_str2053[sizeof("inkatakana")];
+ char uniname2ctype_pool_str2056[sizeof("inbatak")];
+ char uniname2ctype_pool_str2059[sizeof("pi")];
+ char uniname2ctype_pool_str2064[sizeof("mong")];
+ char uniname2ctype_pool_str2074[sizeof("oldhungarian")];
+ char uniname2ctype_pool_str2076[sizeof("phoenician")];
+ char uniname2ctype_pool_str2077[sizeof("insmallformvariants")];
+ char uniname2ctype_pool_str2078[sizeof("idsunaryoperator")];
+ char uniname2ctype_pool_str2080[sizeof("variationselector")];
+ char uniname2ctype_pool_str2081[sizeof("limbu")];
+ char uniname2ctype_pool_str2085[sizeof("inyisyllables")];
+ char uniname2ctype_pool_str2087[sizeof("diak")];
+ char uniname2ctype_pool_str2090[sizeof("oldsoutharabian")];
+ char uniname2ctype_pool_str2092[sizeof("lepc")];
+ char uniname2ctype_pool_str2093[sizeof("inottomansiyaqnumbers")];
+ char uniname2ctype_pool_str2097[sizeof("control")];
+ char uniname2ctype_pool_str2102[sizeof("coptic")];
+ char uniname2ctype_pool_str2104[sizeof("inkhmersymbols")];
+ char uniname2ctype_pool_str2107[sizeof("titlecaseletter")];
+ char uniname2ctype_pool_str2110[sizeof("inphagspa")];
+ char uniname2ctype_pool_str2111[sizeof("bhks")];
+ char uniname2ctype_pool_str2113[sizeof("gothic")];
+ char uniname2ctype_pool_str2117[sizeof("sogo")];
+ char uniname2ctype_pool_str2122[sizeof("elym")];
+ char uniname2ctype_pool_str2131[sizeof("ps")];
+ char uniname2ctype_pool_str2137[sizeof("prti")];
+ char uniname2ctype_pool_str2138[sizeof("changeswhencasemapped")];
+ char uniname2ctype_pool_str2140[sizeof("deseret")];
+ char uniname2ctype_pool_str2142[sizeof("bhaiksuki")];
+ char uniname2ctype_pool_str2143[sizeof("cyrl")];
+ char uniname2ctype_pool_str2147[sizeof("olower")];
+ char uniname2ctype_pool_str2148[sizeof("inchakma")];
+ char uniname2ctype_pool_str2152[sizeof("wara")];
+ char uniname2ctype_pool_str2153[sizeof("sogdian")];
+ char uniname2ctype_pool_str2155[sizeof("graphemeclusterbreak=zwj")];
+ char uniname2ctype_pool_str2164[sizeof("runr")];
+ char uniname2ctype_pool_str2165[sizeof("changeswhentitlecased")];
+ char uniname2ctype_pool_str2168[sizeof("incjkstrokes")];
+ char uniname2ctype_pool_str2176[sizeof("incherokeesupplement")];
+ char uniname2ctype_pool_str2179[sizeof("intangutcomponents")];
+ char uniname2ctype_pool_str2182[sizeof("patws")];
+ char uniname2ctype_pool_str2183[sizeof("batk")];
+ char uniname2ctype_pool_str2186[sizeof("caseignorable")];
+ char uniname2ctype_pool_str2191[sizeof("inkawi")];
+ char uniname2ctype_pool_str2199[sizeof("indevanagariextended")];
+ char uniname2ctype_pool_str2203[sizeof("indogra")];
+ char uniname2ctype_pool_str2204[sizeof("intifinagh")];
+ char uniname2ctype_pool_str2206[sizeof("print")];
+ char uniname2ctype_pool_str2207[sizeof("cakm")];
+ char uniname2ctype_pool_str2209[sizeof("graphemeclusterbreak=t")];
+ char uniname2ctype_pool_str2211[sizeof("graphemeclusterbreak=lvt")];
+ char uniname2ctype_pool_str2214[sizeof("inmendekikakui")];
+ char uniname2ctype_pool_str2216[sizeof("inpsalterpahlavi")];
+ char uniname2ctype_pool_str2224[sizeof("dogra")];
+ char uniname2ctype_pool_str2228[sizeof("tangut")];
+ char uniname2ctype_pool_str2235[sizeof("oalpha")];
+ char uniname2ctype_pool_str2237[sizeof("intangutcomponentssupplement")];
+ char uniname2ctype_pool_str2239[sizeof("idcompatmathcontinue")];
+ char uniname2ctype_pool_str2241[sizeof("beriaerfe")];
+ char uniname2ctype_pool_str2243[sizeof("ext")];
+ char uniname2ctype_pool_str2244[sizeof("inkanasupplement")];
+ char uniname2ctype_pool_str2247[sizeof("osge")];
+ char uniname2ctype_pool_str2248[sizeof("inkanaextendeda")];
+ char uniname2ctype_pool_str2249[sizeof("inverticalforms")];
+ char uniname2ctype_pool_str2252[sizeof("decimalnumber")];
+ char uniname2ctype_pool_str2254[sizeof("inkanaextendedb")];
+ char uniname2ctype_pool_str2255[sizeof("idstrinaryoperator")];
+ char uniname2ctype_pool_str2257[sizeof("tols")];
+ char uniname2ctype_pool_str2260[sizeof("lower")];
+ char uniname2ctype_pool_str2270[sizeof("glag")];
+ char uniname2ctype_pool_str2272[sizeof("inhanguljamo")];
+ char uniname2ctype_pool_str2279[sizeof("insupplementalarrowsa")];
+ char uniname2ctype_pool_str2281[sizeof("inmeeteimayek")];
+ char uniname2ctype_pool_str2285[sizeof("insupplementalarrowsb")];
+ char uniname2ctype_pool_str2288[sizeof("inunifiedcanadianaboriginalsyllabics")];
+ char uniname2ctype_pool_str2296[sizeof("privateuse")];
+ char uniname2ctype_pool_str2299[sizeof("inunifiedcanadianaboriginalsyllabicsextendeda")];
+ char uniname2ctype_pool_str2302[sizeof("sentenceterminal")];
+ char uniname2ctype_pool_str2308[sizeof("pcm")];
+ char uniname2ctype_pool_str2309[sizeof("elymaic")];
+ char uniname2ctype_pool_str2310[sizeof("cpmn")];
+ char uniname2ctype_pool_str2312[sizeof("incjkcompatibilityforms")];
+ char uniname2ctype_pool_str2313[sizeof("inphoneticextensions")];
+ char uniname2ctype_pool_str2317[sizeof("incjkcompatibilityideographs")];
+ char uniname2ctype_pool_str2320[sizeof("oldsogdian")];
+ char uniname2ctype_pool_str2341[sizeof("inethiopicsupplement")];
+ char uniname2ctype_pool_str2345[sizeof("graphemebase")];
+ char uniname2ctype_pool_str2350[sizeof("intangutsupplement")];
+ char uniname2ctype_pool_str2353[sizeof("tang")];
+ char uniname2ctype_pool_str2361[sizeof("ideographic")];
+ char uniname2ctype_pool_str2364[sizeof("nagmundari")];
+ char uniname2ctype_pool_str2366[sizeof("sogd")];
+ char uniname2ctype_pool_str2370[sizeof("psalterpahlavi")];
+ char uniname2ctype_pool_str2371[sizeof("inphoneticextensionssupplement")];
+ char uniname2ctype_pool_str2373[sizeof("tagb")];
+ char uniname2ctype_pool_str2374[sizeof("invariationselectors")];
+ char uniname2ctype_pool_str2375[sizeof("incjkcompatibilityideographssupplement")];
+ char uniname2ctype_pool_str2379[sizeof("inindicsiyaqnumbers")];
+ char uniname2ctype_pool_str2389[sizeof("khojki")];
+ char uniname2ctype_pool_str2392[sizeof("inplayingcards")];
+ char uniname2ctype_pool_str2396[sizeof("graphemeclusterbreak=extend")];
+ char uniname2ctype_pool_str2397[sizeof("graphemeclusterbreak=prepend")];
+ char uniname2ctype_pool_str2398[sizeof("space")];
+ char uniname2ctype_pool_str2401[sizeof("tagbanwa")];
+ char uniname2ctype_pool_str2416[sizeof("extpict")];
+ char uniname2ctype_pool_str2421[sizeof("insupplementaryprivateuseareaa")];
+ char uniname2ctype_pool_str2422[sizeof("insupplementalarrowsc")];
+ char uniname2ctype_pool_str2424[sizeof("pd")];
+ char uniname2ctype_pool_str2427[sizeof("insupplementaryprivateuseareab")];
+ char uniname2ctype_pool_str2428[sizeof("innoblock")];
+ char uniname2ctype_pool_str2432[sizeof("invariationselectorssupplement")];
+ char uniname2ctype_pool_str2433[sizeof("inhanguljamoextendeda")];
+ char uniname2ctype_pool_str2434[sizeof("kthi")];
+ char uniname2ctype_pool_str2439[sizeof("inhanguljamoextendedb")];
+ char uniname2ctype_pool_str2440[sizeof("sk")];
+ char uniname2ctype_pool_str2443[sizeof("cherokee")];
+ char uniname2ctype_pool_str2451[sizeof("nchar")];
+ char uniname2ctype_pool_str2458[sizeof("pc")];
+ char uniname2ctype_pool_str2466[sizeof("graphemeextend")];
+ char uniname2ctype_pool_str2468[sizeof("wancho")];
+ char uniname2ctype_pool_str2473[sizeof("inprivateusearea")];
+ char uniname2ctype_pool_str2483[sizeof("sunuwar")];
+ char uniname2ctype_pool_str2491[sizeof("ingothic")];
+ char uniname2ctype_pool_str2495[sizeof("softdotted")];
+ char uniname2ctype_pool_str2503[sizeof("lowercaseletter")];
+ char uniname2ctype_pool_str2505[sizeof("phli")];
+ char uniname2ctype_pool_str2518[sizeof("katakana")];
+ char uniname2ctype_pool_str2526[sizeof("inunifiedcanadianaboriginalsyllabicsextended")];
+ char uniname2ctype_pool_str2528[sizeof("hanifirohingya")];
+ char uniname2ctype_pool_str2532[sizeof("palm")];
+ char uniname2ctype_pool_str2534[sizeof("talu")];
+ char uniname2ctype_pool_str2541[sizeof("inlisu")];
+ char uniname2ctype_pool_str2543[sizeof("lu")];
+ char uniname2ctype_pool_str2553[sizeof("invithkuqi")];
+ char uniname2ctype_pool_str2570[sizeof("finalpunctuation")];
+ char uniname2ctype_pool_str2571[sizeof("incyrillicextendeda")];
+ char uniname2ctype_pool_str2577[sizeof("incyrillicextendedb")];
+ char uniname2ctype_pool_str2579[sizeof("noncharactercodepoint")];
+ char uniname2ctype_pool_str2581[sizeof("mark")];
+ char uniname2ctype_pool_str2582[sizeof("medf")];
+ char uniname2ctype_pool_str2590[sizeof("inkiratrai")];
+ char uniname2ctype_pool_str2591[sizeof("intelugu")];
+ char uniname2ctype_pool_str2592[sizeof("inmakasar")];
+ char uniname2ctype_pool_str2593[sizeof("graphemeclusterbreak=l")];
+ char uniname2ctype_pool_str2596[sizeof("inkharoshthi")];
+ char uniname2ctype_pool_str2599[sizeof("graphemeclusterbreak=control")];
+ char uniname2ctype_pool_str2603[sizeof("deprecated")];
+ char uniname2ctype_pool_str2612[sizeof("insupplementalsymbolsandpictographs")];
+ char uniname2ctype_pool_str2613[sizeof("tirh")];
+ char uniname2ctype_pool_str2614[sizeof("sunu")];
+ char uniname2ctype_pool_str2618[sizeof("letter")];
+ char uniname2ctype_pool_str2619[sizeof("medefaidrin")];
+ char uniname2ctype_pool_str2625[sizeof("beng")];
+ char uniname2ctype_pool_str2626[sizeof("makasar")];
+ char uniname2ctype_pool_str2632[sizeof("cwl")];
+ char uniname2ctype_pool_str2633[sizeof("intakri")];
+ char uniname2ctype_pool_str2634[sizeof("tavt")];
+ char uniname2ctype_pool_str2658[sizeof("todr")];
+ char uniname2ctype_pool_str2668[sizeof("todhri")];
+ char uniname2ctype_pool_str2671[sizeof("insupplementalpunctuation")];
+ char uniname2ctype_pool_str2672[sizeof("modifiersymbol")];
+ char uniname2ctype_pool_str2673[sizeof("ogham")];
+ char uniname2ctype_pool_str2679[sizeof("wcho")];
+ char uniname2ctype_pool_str2688[sizeof("intagalog")];
+ char uniname2ctype_pool_str2689[sizeof("omath")];
+ char uniname2ctype_pool_str2699[sizeof("inkhmer")];
+ char uniname2ctype_pool_str2700[sizeof("cf")];
+ char uniname2ctype_pool_str2701[sizeof("bassavah")];
+ char uniname2ctype_pool_str2705[sizeof("extendedpictographic")];
+ char uniname2ctype_pool_str2708[sizeof("zyyy")];
+ char uniname2ctype_pool_str2714[sizeof("incyrillicextendedc")];
+ char uniname2ctype_pool_str2725[sizeof("ugaritic")];
+ char uniname2ctype_pool_str2726[sizeof("goth")];
+ char uniname2ctype_pool_str2728[sizeof("idcompatmathstart")];
+ char uniname2ctype_pool_str2729[sizeof("divesakuru")];
+ char uniname2ctype_pool_str2732[sizeof("wspace")];
+ char uniname2ctype_pool_str2737[sizeof("geor")];
+ char uniname2ctype_pool_str2764[sizeof("cyrillic")];
+ char uniname2ctype_pool_str2765[sizeof("graphemeclusterbreak=cr")];
+ char uniname2ctype_pool_str2767[sizeof("sorasompeng")];
+ char uniname2ctype_pool_str2780[sizeof("graphemeclusterbreak=regionalindicator")];
+ char uniname2ctype_pool_str2782[sizeof("tirhuta")];
+ char uniname2ctype_pool_str2791[sizeof("inbopomofoextended")];
+ char uniname2ctype_pool_str2796[sizeof("yezi")];
+ char uniname2ctype_pool_str2798[sizeof("p")];
+ char uniname2ctype_pool_str2799[sizeof("incyrillicextendedd")];
+ char uniname2ctype_pool_str2800[sizeof("po")];
+ char uniname2ctype_pool_str2801[sizeof("zp")];
+ char uniname2ctype_pool_str2802[sizeof("dogr")];
+ char uniname2ctype_pool_str2806[sizeof("dep")];
+ char uniname2ctype_pool_str2813[sizeof("hung")];
+ char uniname2ctype_pool_str2819[sizeof("term")];
+ char uniname2ctype_pool_str2826[sizeof("deva")];
+ char uniname2ctype_pool_str2831[sizeof("format")];
+ char uniname2ctype_pool_str2835[sizeof("oldturkic")];
+ char uniname2ctype_pool_str2836[sizeof("kayahli")];
+ char uniname2ctype_pool_str2844[sizeof("devanagari")];
+ char uniname2ctype_pool_str2850[sizeof("olck")];
+ char uniname2ctype_pool_str2852[sizeof("dupl")];
+ char uniname2ctype_pool_str2857[sizeof("incurrencysymbols")];
+ char uniname2ctype_pool_str2861[sizeof("olchiki")];
+ char uniname2ctype_pool_str2863[sizeof("inethiopicextendeda")];
+ char uniname2ctype_pool_str2869[sizeof("inethiopicextendedb")];
+ char uniname2ctype_pool_str2872[sizeof("phagspa")];
+ char uniname2ctype_pool_str2877[sizeof("buhd")];
+ char uniname2ctype_pool_str2878[sizeof("inhangulsyllables")];
+ char uniname2ctype_pool_str2881[sizeof("inlatinextendedf")];
+ char uniname2ctype_pool_str2883[sizeof("modifierletter")];
+ char uniname2ctype_pool_str2894[sizeof("graph")];
+ char uniname2ctype_pool_str2897[sizeof("ingaray")];
+ char uniname2ctype_pool_str2900[sizeof("number")];
+ char uniname2ctype_pool_str2910[sizeof("inkayahli")];
+ char uniname2ctype_pool_str2922[sizeof("lepcha")];
+ char uniname2ctype_pool_str2925[sizeof("plrd")];
+ char uniname2ctype_pool_str2926[sizeof("incjksymbolsandpunctuation")];
+ char uniname2ctype_pool_str2928[sizeof("ecomp")];
+ char uniname2ctype_pool_str2947[sizeof("cuneiform")];
+ char uniname2ctype_pool_str2953[sizeof("inglagolitic")];
+ char uniname2ctype_pool_str2960[sizeof("gunjalagondi")];
+ char uniname2ctype_pool_str2970[sizeof("bugi")];
+ char uniname2ctype_pool_str2984[sizeof("takri")];
+ char uniname2ctype_pool_str2986[sizeof("cprt")];
+ char uniname2ctype_pool_str2987[sizeof("spaceseparator")];
+ char uniname2ctype_pool_str2991[sizeof("ingurungkhema")];
+ char uniname2ctype_pool_str2993[sizeof("incypriotsyllabary")];
+ char uniname2ctype_pool_str2995[sizeof("inpaucinhau")];
+ char uniname2ctype_pool_str3005[sizeof("gong")];
+ char uniname2ctype_pool_str3013[sizeof("joinc")];
+ char uniname2ctype_pool_str3015[sizeof("currencysymbol")];
+ char uniname2ctype_pool_str3017[sizeof("rohg")];
+ char uniname2ctype_pool_str3021[sizeof("logicalorderexception")];
+ char uniname2ctype_pool_str3022[sizeof("grek")];
+ char uniname2ctype_pool_str3041[sizeof("changeswhenlowercased")];
+ char uniname2ctype_pool_str3049[sizeof("inpahawhhmong")];
+ char uniname2ctype_pool_str3052[sizeof("yezidi")];
+ char uniname2ctype_pool_str3054[sizeof("cwcf")];
+ char uniname2ctype_pool_str3061[sizeof("extender")];
+ char uniname2ctype_pool_str3068[sizeof("inhangulcompatibilityjamo")];
+ char uniname2ctype_pool_str3078[sizeof("tulutigalari")];
+ char uniname2ctype_pool_str3080[sizeof("terminalpunctuation")];
+ char uniname2ctype_pool_str3086[sizeof("inkatakanaphoneticextensions")];
+ char uniname2ctype_pool_str3090[sizeof("inethiopicextended")];
+ char uniname2ctype_pool_str3097[sizeof("gujr")];
+ char uniname2ctype_pool_str3103[sizeof("patsyn")];
+ char uniname2ctype_pool_str3107[sizeof("ugar")];
+ char uniname2ctype_pool_str3108[sizeof("word")];
+ char uniname2ctype_pool_str3112[sizeof("berf")];
+ char uniname2ctype_pool_str3121[sizeof("xpeo")];
+ char uniname2ctype_pool_str3122[sizeof("regionalindicator")];
+ char uniname2ctype_pool_str3127[sizeof("gujarati")];
+ char uniname2ctype_pool_str3128[sizeof("buhid")];
+ char uniname2ctype_pool_str3137[sizeof("inlatinextendedg")];
+ char uniname2ctype_pool_str3142[sizeof("ethi")];
+ char uniname2ctype_pool_str3165[sizeof("inkhitansmallscript")];
+ char uniname2ctype_pool_str3169[sizeof("ingeorgiansupplement")];
+ char uniname2ctype_pool_str3177[sizeof("inegyptianhieroglyphs")];
+ char uniname2ctype_pool_str3184[sizeof("tifinagh")];
+ char uniname2ctype_pool_str3188[sizeof("inegyptianhieroglyphsextendeda")];
+ char uniname2ctype_pool_str3190[sizeof("inegyptianhieroglyphformatcontrols")];
+ char uniname2ctype_pool_str3221[sizeof("inkhudawadi")];
+ char uniname2ctype_pool_str3231[sizeof("incjkcompatibility")];
+ char uniname2ctype_pool_str3238[sizeof("rjng")];
+ char uniname2ctype_pool_str3240[sizeof("buginese")];
+ char uniname2ctype_pool_str3245[sizeof("mendekikakui")];
+ char uniname2ctype_pool_str3247[sizeof("letternumber")];
+ char uniname2ctype_pool_str3257[sizeof("phlp")];
+ char uniname2ctype_pool_str3261[sizeof("separator")];
+ char uniname2ctype_pool_str3263[sizeof("pauc")];
+ char uniname2ctype_pool_str3281[sizeof("vithkuqi")];
+ char uniname2ctype_pool_str3287[sizeof("inkangxiradicals")];
+ char uniname2ctype_pool_str3291[sizeof("changeswhencasefolded")];
+ char uniname2ctype_pool_str3302[sizeof("graphemeclusterbreak=lf")];
+ char uniname2ctype_pool_str3307[sizeof("joincontrol")];
+ char uniname2ctype_pool_str3326[sizeof("inmeroiticcursive")];
+ char uniname2ctype_pool_str3334[sizeof("pe")];
+ char uniname2ctype_pool_str3335[sizeof("patternwhitespace")];
+ char uniname2ctype_pool_str3357[sizeof("duployan")];
+ char uniname2ctype_pool_str3359[sizeof("phag")];
+ char uniname2ctype_pool_str3363[sizeof("meeteimayek")];
+ char uniname2ctype_pool_str3407[sizeof("innyiakengpuachuehmong")];
+ char uniname2ctype_pool_str3408[sizeof("incjkunifiedideographsextensioni")];
+ char uniname2ctype_pool_str3414[sizeof("incjkunifiedideographs")];
+ char uniname2ctype_pool_str3416[sizeof("incjkunifiedideographsextensionj")];
+ char uniname2ctype_pool_str3418[sizeof("georgian")];
+ char uniname2ctype_pool_str3426[sizeof("incjkunifiedideographsextensiona")];
+ char uniname2ctype_pool_str3432[sizeof("incjkunifiedideographsextensionb")];
+ char uniname2ctype_pool_str3436[sizeof("warangciti")];
+ char uniname2ctype_pool_str3444[sizeof("inhighprivateusesurrogates")];
+ char uniname2ctype_pool_str3469[sizeof("meroitichieroglyphs")];
+ char uniname2ctype_pool_str3481[sizeof("java")];
+ char uniname2ctype_pool_str3493[sizeof("garay")];
+ char uniname2ctype_pool_str3497[sizeof("nonspacingmark")];
+ char uniname2ctype_pool_str3505[sizeof("otheridstart")];
+ char uniname2ctype_pool_str3507[sizeof("otheridcontinue")];
+ char uniname2ctype_pool_str3516[sizeof("xsux")];
+ char uniname2ctype_pool_str3532[sizeof("phnx")];
+ char uniname2ctype_pool_str3535[sizeof("incjkunifiedideographsextensione")];
+ char uniname2ctype_pool_str3536[sizeof("signwriting")];
+ char uniname2ctype_pool_str3543[sizeof("tolongsiki")];
+ char uniname2ctype_pool_str3569[sizeof("incjkunifiedideographsextensionc")];
+ char uniname2ctype_pool_str3579[sizeof("combiningmark")];
+ char uniname2ctype_pool_str3585[sizeof("nushu")];
+ char uniname2ctype_pool_str3598[sizeof("takr")];
+ char uniname2ctype_pool_str3613[sizeof("tfng")];
+ char uniname2ctype_pool_str3614[sizeof("changeswhenuppercased")];
+ char uniname2ctype_pool_str3622[sizeof("inglagoliticsupplement")];
+ char uniname2ctype_pool_str3629[sizeof("surrogate")];
+ char uniname2ctype_pool_str3647[sizeof("orkh")];
+ char uniname2ctype_pool_str3650[sizeof("graphemeclusterbreak=v")];
+ char uniname2ctype_pool_str3651[sizeof("graphemeclusterbreak=lv")];
+ char uniname2ctype_pool_str3654[sizeof("incjkunifiedideographsextensiond")];
+ char uniname2ctype_pool_str3666[sizeof("telu")];
+ char uniname2ctype_pool_str3669[sizeof("inhalfwidthandfullwidthforms")];
+ char uniname2ctype_pool_str3686[sizeof("otheralphabetic")];
+ char uniname2ctype_pool_str3690[sizeof("unknown")];
+ char uniname2ctype_pool_str3699[sizeof("punct")];
+ char uniname2ctype_pool_str3718[sizeof("tglg")];
+ char uniname2ctype_pool_str3733[sizeof("javanese")];
+ char uniname2ctype_pool_str3770[sizeof("otherdefaultignorablecodepoint")];
+ char uniname2ctype_pool_str3778[sizeof("cwu")];
+ char uniname2ctype_pool_str3782[sizeof("rejang")];
+ char uniname2ctype_pool_str3813[sizeof("egyp")];
+ char uniname2ctype_pool_str3835[sizeof("perm")];
+ char uniname2ctype_pool_str3836[sizeof("othersymbol")];
+ char uniname2ctype_pool_str3869[sizeof("epres")];
+ char uniname2ctype_pool_str3877[sizeof("olduyghur")];
+ char uniname2ctype_pool_str3894[sizeof("tutg")];
+ char uniname2ctype_pool_str3901[sizeof("enclosingmark")];
+ char uniname2ctype_pool_str3918[sizeof("ingeorgianextended")];
+ char uniname2ctype_pool_str3945[sizeof("ogrext")];
+ char uniname2ctype_pool_str3965[sizeof("indivesakuru")];
+ char uniname2ctype_pool_str3972[sizeof("otherlowercase")];
+ char uniname2ctype_pool_str3981[sizeof("other")];
+ char uniname2ctype_pool_str3995[sizeof("othernumber")];
+ char uniname2ctype_pool_str4007[sizeof("hexdigit")];
+ char uniname2ctype_pool_str4018[sizeof("incjkradicalssupplement")];
+ char uniname2ctype_pool_str4035[sizeof("blank")];
+ char uniname2ctype_pool_str4064[sizeof("ethiopic")];
+ char uniname2ctype_pool_str4069[sizeof("graphemeclusterbreak=spacingmark")];
+ char uniname2ctype_pool_str4072[sizeof("spacingmark")];
+ char uniname2ctype_pool_str4089[sizeof("tagalog")];
+ char uniname2ctype_pool_str4102[sizeof("batak")];
+ char uniname2ctype_pool_str4110[sizeof("guru")];
+ char uniname2ctype_pool_str4117[sizeof("hex")];
+ char uniname2ctype_pool_str4140[sizeof("paucinhau")];
+ char uniname2ctype_pool_str4153[sizeof("modifiercombiningmark")];
+ char uniname2ctype_pool_str4163[sizeof("otherpunctuation")];
+ char uniname2ctype_pool_str4180[sizeof("ougr")];
+ char uniname2ctype_pool_str4228[sizeof("palmyrene")];
+ char uniname2ctype_pool_str4318[sizeof("othermath")];
+ char uniname2ctype_pool_str4353[sizeof("incjkunifiedideographsextensionh")];
+ char uniname2ctype_pool_str4354[sizeof("inboxdrawing")];
+ char uniname2ctype_pool_str4401[sizeof("patternsyntax")];
+ char uniname2ctype_pool_str4404[sizeof("oupper")];
+ char uniname2ctype_pool_str4410[sizeof("gurungkhema")];
+ char uniname2ctype_pool_str4414[sizeof("prependedconcatenationmark")];
+ char uniname2ctype_pool_str4439[sizeof("otherletter")];
+ char uniname2ctype_pool_str4491[sizeof("pf")];
+ char uniname2ctype_pool_str4494[sizeof("qmark")];
+ char uniname2ctype_pool_str4543[sizeof("inhighsurrogates")];
+ char uniname2ctype_pool_str4544[sizeof("xposixpunct")];
+ char uniname2ctype_pool_str4545[sizeof("otheruppercase")];
+ char uniname2ctype_pool_str4564[sizeof("incjkunifiedideographsextensionf")];
+ char uniname2ctype_pool_str4670[sizeof("punctuation")];
+ char uniname2ctype_pool_str4692[sizeof("incjkunifiedideographsextensiong")];
+ char uniname2ctype_pool_str4731[sizeof("egyptianhieroglyphs")];
+ char uniname2ctype_pool_str4775[sizeof("defaultignorablecodepoint")];
+ char uniname2ctype_pool_str4777[sizeof("quotationmark")];
+ char uniname2ctype_pool_str4800[sizeof("openpunctuation")];
+ char uniname2ctype_pool_str4851[sizeof("unifiedideograph")];
+ char uniname2ctype_pool_str4941[sizeof("greek")];
+ char uniname2ctype_pool_str4985[sizeof("othergraphemeextend")];
+ char uniname2ctype_pool_str5002[sizeof("inkaktoviknumerals")];
+ char uniname2ctype_pool_str5234[sizeof("uppercase")];
+ char uniname2ctype_pool_str5271[sizeof("grlink")];
+ char uniname2ctype_pool_str5290[sizeof("nyiakengpuachuehmong")];
+ char uniname2ctype_pool_str5329[sizeof("gukh")];
+ char uniname2ctype_pool_str5512[sizeof("pahawhhmong")];
+ char uniname2ctype_pool_str5557[sizeof("upper")];
+ char uniname2ctype_pool_str5800[sizeof("uppercaseletter")];
+ char uniname2ctype_pool_str5919[sizeof("graphemelink")];
+ char uniname2ctype_pool_str5981[sizeof("telugu")];
+ char uniname2ctype_pool_str6036[sizeof("gurmukhi")];
+ char uniname2ctype_pool_str6068[sizeof("paragraphseparator")];
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+static const struct uniname2ctype_pool_t uniname2ctype_pool_contents =
+ {
+#ifndef USE_UNICODE_PROPERTIES
+ "word",
+ "print",
+ "punct",
+ "alpha",
+#else /* USE_UNICODE_PROPERTIES */
+ "n",
+ "m",
+ "mn",
+ "lm",
+ "inmro",
+ "innko",
+ "mro",
+ "mroo",
+ "ri",
+ "lao",
+ "laoo",
+ "ahom",
+ "hano",
+ "miao",
+ "hani",
+ "inmiao",
+ "han",
+ "mani",
+ "lina",
+ "inahom",
+ "hanunoo",
+ "limb",
+ "linb",
+ "inmanichaean",
+#endif /* USE_UNICODE_PROPERTIES */
+ "alnum",
+#ifndef USE_UNICODE_PROPERTIES
+ "xdigit",
+ "upper",
+#else /* USE_UNICODE_PROPERTIES */
+ "armi",
+ "nandinagari",
+ "armn",
+ "lana",
+ "zanb",
+ "inosmanya",
+ "insamaritan",
+ "inbhaiksuki",
+ "armenian",
+ "sm",
+ "inmasaramgondi",
+ "s",
+ "innabataean",
+ "zs",
+ "inbasiclatin",
+ "innumberforms",
+ "arab",
+ "inmusicalsymbols",
+ "latn",
+ "inthai",
+ "latin",
+ "shavian",
+ "initialpunctuation",
+ "hatran",
+ "di",
+ "inthaana",
+ "intoto",
+ "nabataean",
+ "intaitham",
+ "inarabicpresentationformsa",
+ "inbraillepatterns",
+ "inarabicpresentationformsb",
+ "ids",
+ "dia",
+ "inarmenian",
+ "idsb",
+ "intransportandmapsymbols",
+ "inideographicsymbolsandpunctuation",
+ "inavestan",
+ "inipaextensions",
+ "inelbasan",
+ "inopticalcharacterrecognition",
+ "brai",
+ "bamum",
+ "incham",
+ "inideographicdescriptioncharacters",
+ "brahmi",
+ "idst",
+ "bass",
+ "mandaic",
+ "inemoticons",
+ "incommonindicnumberforms",
+ "intibetan",
+ "inarabic",
+ "nbat",
+ "cn",
+ "inancientsymbols",
+ "ci",
+#endif /* USE_UNICODE_PROPERTIES */
+ "ascii",
+#ifdef USE_UNICODE_PROPERTIES
+ "mcm",
+ "ideo",
+ "inmodi",
+ "vai",
+ "vaii",
+ "cham",
+ "inmyanmarextendeda",
+ "nand",
+ "inmyanmarextendedb",
+ "mand",
+ "cans",
+ "inoldsogdian",
+ "chorasmian",
+ "innewa",
+ "chakma",
+ "incuneiform",
+ "vs",
+ "cs",
+ "sind",
+ "shaw",
+ "inspecials",
+ "inchesssymbols",
+ "avst",
+ "inblockelements",
+ "nd",
+ "sharada",
+ "inmiscellaneoussymbols",
+ "inmiscellaneousmathematicalsymbolsa",
+ "sidt",
+ "inmiscellaneousmathematicalsymbolsb",
+ "inmiscellaneoussymbolsandarrows",
+ "arabic",
+ "inmiscellaneoussymbolsandpictographs",
+ "c",
+ "lc",
+ "mc",
+ "inmedefaidrin",
+ "inmyanmarextendedc",
+ "insundanese",
+ "indominotiles",
+ "insymbolsandpictographsextendeda",
+ "inwancho",
+ "inolditalic",
+ "inmodifiertoneletters",
+ "incb=consonant",
+ "sd",
+ "inmandaic",
+ "inmiscellaneoussymbolssupplement",
+ "nko",
+ "nkoo",
+ "l",
+ "inmeeteimayekextensions",
+ "nl",
+ "zl",
+ "ll",
+ "inlao",
+ "khoj",
+ "idc",
+ "innewtailue",
+ "inolonal",
+ "sc",
+ "indeseret",
+ "incuneiformnumbersandpunctuation",
+ "krai",
+ "inarabicextendeda",
+ "inoldturkic",
+ "avestan",
+ "inarabicextendedb",
+ "inmalayalam",
+ "kharoshthi",
+ "kana",
+ "inadlam",
+ "idcontinue",
+ "insiddham",
+ "intamil",
+ "inmultani",
+ "intolongsiki",
+ "kits",
+ "incb=extend",
+ "sidetic",
+ "sidd",
+ "incontrolpictures",
+ "insidetic",
+ "sinhala",
+ "inlatinextendeda",
+ "inlatinextendedb",
+ "adlm",
+ "adlam",
+ "inlineara",
+ "intamilsupplement",
+ "inbalinese",
+ "inspacingmodifierletters",
+ "inarabicextendedc",
+ "inlycian",
+ "bali",
+ "hira",
+ "cc",
+ "insmallkanaextension",
+ "intaile",
+ "qaai",
+ "inmyanmar",
+ "narb",
+ "inarrows",
+ "lineara",
+ "linearb",
+ "insharada",
+ "inruminumeralsymbols",
+ "masaramgondi",
+ "hatr",
+ "knda",
+ "samr",
+ "kawi",
+ "inlydian",
+ "samaritan",
+ "sarb",
+ "no",
+ "bidic",
+ "lo",
+ "hmnp",
+ "onao",
+ "inlowsurrogates",
+ "kannada",
+ "inlinearbideograms",
+ "inletterlikesymbols",
+ "cased",
+ "inbopomofo",
+ "inberiaerfe",
+ "lineseparator",
+ "z",
+ "insymbolsforlegacycomputingsupplement",
+ "inrunic",
+ "incarian",
+ "inlatinextendede",
+ "inmarchen",
+ "so",
+ "marc",
+ "oriya",
+ "inchorasmian",
+ "yi",
+ "insyriac",
+ "yiii",
+ "alpha",
+ "qaac",
+ "insundanesesupplement",
+ "osma",
+ "inmiscellaneoustechnical",
+ "idstart",
+ "inenclosedcjklettersandmonths",
+ "inlatinextendedc",
+ "dsrt",
+ "odi",
+ "chrs",
+ "cari",
+ "innandinagari",
+ "balinese",
+ "inwarangciti",
+ "inphoenician",
+ "kali",
+ "inoldnortharabian",
+ "radical",
+ "carian",
+ "idsbinaryoperator",
+ "shrd",
+ "inoldsoutharabian",
+ "diacritic",
+ "mlym",
+ "zinh",
+ "inphaistosdisc",
+ "incyrillic",
+ "ininscriptionalpahlavi",
+ "insoyombo",
+ "ininscriptionalparthian",
+ "inoriya",
+ "lyci",
+ "inogham",
+ "mahj",
+ "gran",
+ "inmahajani",
+ "co",
+ "cher",
+ "alphabetic",
+ "insinhala",
+ "modi",
+ "inbrahmi",
+ "loe",
+ "lycian",
+ "mahajani",
+ "common",
+ "intaiyo",
+ "inhanifirohingya",
+ "inbassavah",
+ "sinh",
+ "oids",
+ "inlatinextendedadditional",
+ "inyijinghexagramsymbols",
+ "inoldpersian",
+ "bidicontrol",
+ "math",
+ "inarabicsupplement",
+ "thai",
+ "inlatinextendedd",
+ "taiyo",
+ "lisu",
+ "tnsa",
+ "incherokee",
+ "thaa",
+ "lydi",
+ "inbamum",
+ "khmr",
+ "inbyzantinemusicalsymbols",
+ "lt",
+ "khar",
+ "thaana",
+ "osage",
+ "lydian",
+ "inanatolianhieroglyphs",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=11.0",
+ "age=10.0",
+ "age=12.1",
+ "age=12.0",
+ "age=1.1",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "insylotinagri",
+ "anatolianhieroglyphs",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=2.1",
+ "age=2.0",
+ "age=14.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "tangsa",
+ "dash",
+ "incombiningdiacriticalmarks",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=17.0",
+ "age=4.1",
+ "age=4.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "tibt",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=15.1",
+ "age=15.0",
+ "age=7.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "inolchiki",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=9.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "incombiningdiacriticalmarksforsymbols",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=5.1",
+ "age=5.0",
+ "age=16.0",
+ "age=5.2",
+ "age=8.0",
+ "age=13.0",
+ "age=6.1",
+ "age=6.0",
+ "age=6.2",
+ "age=3.1",
+ "age=3.0",
+ "age=3.2",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "inarabicmathematicalalphabeticsymbols",
+ "brah",
+ "tibetan",
+ "mtei",
+ "incoptic",
+ "manichaean",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+ "age=6.3",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ "emoji",
+ "oidc",
+ "incombiningdiacriticalmarkssupplement",
+ "idsu",
+ "saurashtra",
+ "inoldpermic",
+ "closepunctuation",
+ "incombininghalfmarks",
+ "incopticepactnumbers",
+ "elba",
+ "xdigit",
+#endif /* USE_UNICODE_PROPERTIES */
+ "cntrl",
+#ifndef USE_UNICODE_PROPERTIES
+ "space",
+ "xposixpunct",
+#else /* USE_UNICODE_PROPERTIES */
+ "bamu",
+ "xids",
+ "inoldhungarian",
+ "grext",
+ "mongolian",
+ "sterm",
+ "braille",
+ "inbuhid",
+ "elbasan",
+ "zanabazarsquare",
+ "incountingrodnumerals",
+ "inenclosedalphanumerics",
+ "incb=linker",
+ "taiviet",
+ "inelymaic",
+ "inethiopic",
+ "sgnw",
+ "olditalic",
+ "vith",
+ "grbase",
+ "hluw",
+ "intodhri",
+ "asciihexdigit",
+ "me",
+ "hmng",
+ "siddham",
+ "inenclosedalphanumericsupplement",
+ "taile",
+ "nagm",
+ "hang",
+ "inscriptionalparthian",
+ "inmongolian",
+ "innagmundari",
+ "sylo",
+ "ingunjalagondi",
+ "ingujarati",
+ "inbengali",
+ "khitansmallscript",
+ "xidcontinue",
+ "ingrantha",
+ "insinhalaarchaicnumbers",
+ "connectorpunctuation",
+ "inpalmyrene",
+ "incombiningdiacriticalmarksextended",
+ "xidstart",
+ "xidc",
+ "inancientgreekmusicalnotation",
+ "inancientgreeknumbers",
+ "intangsa",
+ "intags",
+ "inlepcha",
+ "caucasianalbanian",
+ "sylotinagri",
+ "emod",
+ "incaucasianalbanian",
+ "intagbanwa",
+ "mend",
+ "newa",
+ "inearlydynasticcuneiform",
+ "kaithi",
+ "intangut",
+ "mymr",
+ "inosage",
+ "inmahjongtiles",
+ "malayalam",
+ "sora",
+ "inbuginese",
+ "emojimodifierbase",
+ "induployan",
+ "ingeometricshapes",
+ "ingeneralpunctuation",
+ "myanmar",
+ "inlatin1supplement",
+ "ital",
+ "taml",
+ "inaegeannumbers",
+ "insharadasupplement",
+ "mathsymbol",
+ "inlimbu",
+ "invai",
+ "emojicomponent",
+ "insuttonsignwriting",
+ "digit",
+ "newtailue",
+ "inshavian",
+ "insogdian",
+ "indingbats",
+ "imperialaramaic",
+ "intulutigalari",
+ "incyprominoan",
+ "glagolitic",
+ "ebase",
+ "intaixuanjingsymbols",
+ "inbamumsupplement",
+ "gara",
+ "insyriacsupplement",
+ "casedletter",
+ "zzzz",
+ "inhiragana",
+ "tale",
+ "canadianaboriginal",
+ "ahex",
+ "inmayannumerals",
+ "inzanabazarsquare",
+ "inyiradicals",
+ "inscriptionalpahlavi",
+ "inalchemicalsymbols",
+ "inhatran",
+ "assigned",
+ "intaiviet",
+ "syrc",
+ "bopo",
+ "intirhuta",
+ "oldnortharabian",
+ "insupplementalmathematicaloperators",
+ "bopomofo",
+ "olonal",
+ "injavanese",
+ "insunuwar",
+ "inmathematicalalphanumericsymbols",
+ "inimperialaramaic",
+ "khmer",
+ "gonm",
+ "hyphen",
+ "insuperscriptsandsubscripts",
+ "inenclosedideographicsupplement",
+ "ingeometricshapesextended",
+ "insaurashtra",
+ "ogam",
+ "orya",
+ "saur",
+ "marchen",
+ "sundanese",
+ "khudawadi",
+ "soyo",
+ "whitespace",
+ "uideo",
+ "oldpersian",
+ "inyezidi",
+ "kiratrai",
+ "inlisusupplement",
+ "mero",
+ "symbol",
+ "soyombo",
+ "osmanya",
+ "indevanagari",
+ "unassigned",
+ "bengali",
+ "hebr",
+ "hebrew",
+ "inornamentaldingbats",
+ "invedicextensions",
+ "copt",
+ "ingreekextended",
+ "sund",
+ "cyprominoan",
+ "inherited",
+ "toto",
+ "inugaritic",
+ "syriac",
+ "cwt",
+ "inhebrew",
+ "runic",
+ "inmongoliansupplement",
+ "inshorthandformatcontrols",
+ "cypriot",
+ "cwcm",
+ "ingreekandcoptic",
+ "any",
+ "inolduyghur",
+ "inznamennymusicalnotation",
+ "lowercase",
+ "oldpermic",
+ "ingeorgian",
+ "ingurmukhi",
+ "emojimodifier",
+ "inkhojki",
+ "aghb",
+ "merc",
+ "inrejang",
+ "tamil",
+ "indevanagariextendeda",
+ "inalphabeticpresentationforms",
+ "hangul",
+ "inmeroitichieroglyphs",
+ "inkannada",
+ "hiragana",
+ "maka",
+ "inkanbun",
+ "insorasompeng",
+ "inmathematicaloperators",
+ "tayo",
+ "inhanunoo",
+ "multani",
+ "inkaithi",
+ "innushu",
+ "emojipresentation",
+ "insymbolsforlegacycomputing",
+ "meroiticcursive",
+ "grantha",
+ "inlinearbsyllabary",
+ "mult",
+ "taitham",
+ "nshu",
+ "incyrillicsupplement",
+ "dashpunctuation",
+ "inkatakana",
+ "inbatak",
+ "pi",
+ "mong",
+ "oldhungarian",
+ "phoenician",
+ "insmallformvariants",
+ "idsunaryoperator",
+ "variationselector",
+ "limbu",
+ "inyisyllables",
+ "diak",
+ "oldsoutharabian",
+ "lepc",
+ "inottomansiyaqnumbers",
+ "control",
+ "coptic",
+ "inkhmersymbols",
+ "titlecaseletter",
+ "inphagspa",
+ "bhks",
+ "gothic",
+ "sogo",
+ "elym",
+ "ps",
+ "prti",
+ "changeswhencasemapped",
+ "deseret",
+ "bhaiksuki",
+ "cyrl",
+ "olower",
+ "inchakma",
+ "wara",
+ "sogdian",
+ "graphemeclusterbreak=zwj",
+ "runr",
+ "changeswhentitlecased",
+ "incjkstrokes",
+ "incherokeesupplement",
+ "intangutcomponents",
+ "patws",
+ "batk",
+ "caseignorable",
+ "inkawi",
+ "indevanagariextended",
+ "indogra",
+ "intifinagh",
+ "print",
+ "cakm",
+ "graphemeclusterbreak=t",
+ "graphemeclusterbreak=lvt",
+ "inmendekikakui",
+ "inpsalterpahlavi",
+ "dogra",
+ "tangut",
+ "oalpha",
+ "intangutcomponentssupplement",
+ "idcompatmathcontinue",
+ "beriaerfe",
+ "ext",
+ "inkanasupplement",
+ "osge",
+ "inkanaextendeda",
+ "inverticalforms",
+ "decimalnumber",
+ "inkanaextendedb",
+ "idstrinaryoperator",
+ "tols",
+#endif /* USE_UNICODE_PROPERTIES */
+ "lower",
+#ifdef USE_UNICODE_PROPERTIES
+ "glag",
+ "inhanguljamo",
+ "insupplementalarrowsa",
+ "inmeeteimayek",
+ "insupplementalarrowsb",
+ "inunifiedcanadianaboriginalsyllabics",
+ "privateuse",
+ "inunifiedcanadianaboriginalsyllabicsextendeda",
+ "sentenceterminal",
+ "pcm",
+ "elymaic",
+ "cpmn",
+ "incjkcompatibilityforms",
+ "inphoneticextensions",
+ "incjkcompatibilityideographs",
+ "oldsogdian",
+ "inethiopicsupplement",
+ "graphemebase",
+ "intangutsupplement",
+ "tang",
+ "ideographic",
+ "nagmundari",
+ "sogd",
+ "psalterpahlavi",
+ "inphoneticextensionssupplement",
+ "tagb",
+ "invariationselectors",
+ "incjkcompatibilityideographssupplement",
+ "inindicsiyaqnumbers",
+ "khojki",
+ "inplayingcards",
+ "graphemeclusterbreak=extend",
+ "graphemeclusterbreak=prepend",
+ "space",
+ "tagbanwa",
+ "extpict",
+ "insupplementaryprivateuseareaa",
+ "insupplementalarrowsc",
+ "pd",
+ "insupplementaryprivateuseareab",
+ "innoblock",
+ "invariationselectorssupplement",
+ "inhanguljamoextendeda",
+ "kthi",
+ "inhanguljamoextendedb",
+ "sk",
+ "cherokee",
+ "nchar",
+ "pc",
+ "graphemeextend",
+ "wancho",
+ "inprivateusearea",
+ "sunuwar",
+ "ingothic",
+ "softdotted",
+ "lowercaseletter",
+ "phli",
+ "katakana",
+ "inunifiedcanadianaboriginalsyllabicsextended",
+ "hanifirohingya",
+ "palm",
+ "talu",
+ "inlisu",
+ "lu",
+ "invithkuqi",
+ "finalpunctuation",
+ "incyrillicextendeda",
+ "incyrillicextendedb",
+ "noncharactercodepoint",
+ "mark",
+ "medf",
+ "inkiratrai",
+ "intelugu",
+ "inmakasar",
+ "graphemeclusterbreak=l",
+ "inkharoshthi",
+ "graphemeclusterbreak=control",
+ "deprecated",
+ "insupplementalsymbolsandpictographs",
+ "tirh",
+ "sunu",
+ "letter",
+ "medefaidrin",
+ "beng",
+ "makasar",
+ "cwl",
+ "intakri",
+ "tavt",
+ "todr",
+ "todhri",
+ "insupplementalpunctuation",
+ "modifiersymbol",
+ "ogham",
+ "wcho",
+ "intagalog",
+ "omath",
+ "inkhmer",
+ "cf",
+ "bassavah",
+ "extendedpictographic",
+ "zyyy",
+ "incyrillicextendedc",
+ "ugaritic",
+ "goth",
+ "idcompatmathstart",
+ "divesakuru",
+ "wspace",
+ "geor",
+ "cyrillic",
+ "graphemeclusterbreak=cr",
+ "sorasompeng",
+ "graphemeclusterbreak=regionalindicator",
+ "tirhuta",
+ "inbopomofoextended",
+ "yezi",
+ "p",
+ "incyrillicextendedd",
+ "po",
+ "zp",
+ "dogr",
+ "dep",
+ "hung",
+ "term",
+ "deva",
+ "format",
+ "oldturkic",
+ "kayahli",
+ "devanagari",
+ "olck",
+ "dupl",
+ "incurrencysymbols",
+ "olchiki",
+ "inethiopicextendeda",
+ "inethiopicextendedb",
+ "phagspa",
+ "buhd",
+ "inhangulsyllables",
+ "inlatinextendedf",
+ "modifierletter",
+#endif /* USE_UNICODE_PROPERTIES */
+ "graph",
+#ifndef USE_UNICODE_PROPERTIES
+ "digit",
+ "blank"
+#else /* USE_UNICODE_PROPERTIES */
+ "ingaray",
+ "number",
+ "inkayahli",
+ "lepcha",
+ "plrd",
+ "incjksymbolsandpunctuation",
+ "ecomp",
+ "cuneiform",
+ "inglagolitic",
+ "gunjalagondi",
+ "bugi",
+ "takri",
+ "cprt",
+ "spaceseparator",
+ "ingurungkhema",
+ "incypriotsyllabary",
+ "inpaucinhau",
+ "gong",
+ "joinc",
+ "currencysymbol",
+ "rohg",
+ "logicalorderexception",
+ "grek",
+ "changeswhenlowercased",
+ "inpahawhhmong",
+ "yezidi",
+ "cwcf",
+ "extender",
+ "inhangulcompatibilityjamo",
+ "tulutigalari",
+ "terminalpunctuation",
+ "inkatakanaphoneticextensions",
+ "inethiopicextended",
+ "gujr",
+ "patsyn",
+ "ugar",
+ "word",
+ "berf",
+ "xpeo",
+ "regionalindicator",
+ "gujarati",
+ "buhid",
+ "inlatinextendedg",
+ "ethi",
+ "inkhitansmallscript",
+ "ingeorgiansupplement",
+ "inegyptianhieroglyphs",
+ "tifinagh",
+ "inegyptianhieroglyphsextendeda",
+ "inegyptianhieroglyphformatcontrols",
+ "inkhudawadi",
+ "incjkcompatibility",
+ "rjng",
+ "buginese",
+ "mendekikakui",
+ "letternumber",
+ "phlp",
+ "separator",
+ "pauc",
+ "vithkuqi",
+ "inkangxiradicals",
+ "changeswhencasefolded",
+ "graphemeclusterbreak=lf",
+ "joincontrol",
+ "inmeroiticcursive",
+ "pe",
+ "patternwhitespace",
+ "duployan",
+ "phag",
+ "meeteimayek",
+ "innyiakengpuachuehmong",
+ "incjkunifiedideographsextensioni",
+ "incjkunifiedideographs",
+ "incjkunifiedideographsextensionj",
+ "georgian",
+ "incjkunifiedideographsextensiona",
+ "incjkunifiedideographsextensionb",
+ "warangciti",
+ "inhighprivateusesurrogates",
+ "meroitichieroglyphs",
+ "java",
+ "garay",
+ "nonspacingmark",
+ "otheridstart",
+ "otheridcontinue",
+ "xsux",
+ "phnx",
+ "incjkunifiedideographsextensione",
+ "signwriting",
+ "tolongsiki",
+ "incjkunifiedideographsextensionc",
+ "combiningmark",
+ "nushu",
+ "takr",
+ "tfng",
+ "changeswhenuppercased",
+ "inglagoliticsupplement",
+ "surrogate",
+ "orkh",
+ "graphemeclusterbreak=v",
+ "graphemeclusterbreak=lv",
+ "incjkunifiedideographsextensiond",
+ "telu",
+ "inhalfwidthandfullwidthforms",
+ "otheralphabetic",
+ "unknown",
+ "punct",
+ "tglg",
+ "javanese",
+ "otherdefaultignorablecodepoint",
+ "cwu",
+ "rejang",
+ "egyp",
+ "perm",
+ "othersymbol",
+ "epres",
+ "olduyghur",
+ "tutg",
+ "enclosingmark",
+ "ingeorgianextended",
+ "ogrext",
+ "indivesakuru",
+ "otherlowercase",
+ "other",
+ "othernumber",
+ "hexdigit",
+ "incjkradicalssupplement",
+ "blank",
+ "ethiopic",
+ "graphemeclusterbreak=spacingmark",
+ "spacingmark",
+ "tagalog",
+ "batak",
+ "guru",
+ "hex",
+ "paucinhau",
+ "modifiercombiningmark",
+ "otherpunctuation",
+ "ougr",
+ "palmyrene",
+ "othermath",
+ "incjkunifiedideographsextensionh",
+ "inboxdrawing",
+ "patternsyntax",
+ "oupper",
+ "gurungkhema",
+ "prependedconcatenationmark",
+ "otherletter",
+ "pf",
+ "qmark",
+ "inhighsurrogates",
+ "xposixpunct",
+ "otheruppercase",
+ "incjkunifiedideographsextensionf",
+ "punctuation",
+ "incjkunifiedideographsextensiong",
+ "egyptianhieroglyphs",
+ "defaultignorablecodepoint",
+ "quotationmark",
+ "openpunctuation",
+ "unifiedideograph",
+ "greek",
+ "othergraphemeextend",
+ "inkaktoviknumerals",
+ "uppercase",
+ "grlink",
+ "nyiakengpuachuehmong",
+ "gukh",
+ "pahawhhmong",
+ "upper",
+ "uppercaseletter",
+ "graphemelink",
+ "telugu",
+ "gurmukhi",
+ "paragraphseparator"
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+#define uniname2ctype_pool ((const char *) &uniname2ctype_pool_contents)
+const struct uniname2ctype_struct *
+uniname2ctype_p (register const char *str, register size_t len)
+{
+ static const struct uniname2ctype_struct wordlist[] =
+ {
+#ifdef USE_UNICODE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str10), 35},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str16), 31},
+ {-1}, {-1},
+ {uniname2ctype_offset(str19), 34},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str24), 27},
+ {-1}, {-1},
+ {uniname2ctype_offset(str27), 606},
+ {uniname2ctype_offset(str28), 354},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str33), 192},
+ {uniname2ctype_offset(str34), 192},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str38), 288},
+ {-1},
+ {uniname2ctype_offset(str40), 98},
+ {uniname2ctype_offset(str41), 98},
+ {-1}, {-1},
+ {uniname2ctype_offset(str44), 203},
+ {uniname2ctype_offset(str45), 120},
+ {-1},
+ {uniname2ctype_offset(str47), 176},
+ {uniname2ctype_offset(str48), 113},
+ {-1},
+ {uniname2ctype_offset(str50), 613},
+ {uniname2ctype_offset(str51), 113},
+ {uniname2ctype_offset(str52), 189},
+ {uniname2ctype_offset(str53), 187},
+ {-1}, {-1},
+ {uniname2ctype_offset(str56), 575},
+ {uniname2ctype_offset(str57), 120},
+ {uniname2ctype_offset(str58), 123},
+ {uniname2ctype_offset(str59), 125},
+ {uniname2ctype_offset(str60), 539},
+ {-1},
+ {uniname2ctype_offset(str62), 13},
+ {uniname2ctype_offset(str63), 164},
+ {uniname2ctype_offset(str64), 227},
+ {-1}, {-1},
+ {uniname2ctype_offset(str67), 82},
+ {-1},
+ {uniname2ctype_offset(str69), 155},
+ {uniname2ctype_offset(str70), 218},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str74), 518},
+#endif /* USE_UNICODE_PROPERTIES */
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#ifndef USE_UNICODE_PROPERTIES
+ {uniname2ctype_offset(str6), 12},
+ {uniname2ctype_offset(str7), 7},
+ {uniname2ctype_offset(str8), 15},
+ {uniname2ctype_offset(str9), 1},
+ {uniname2ctype_offset(str10), 13},
+ {uniname2ctype_offset(str11), 11},
+ {uniname2ctype_offset(str12), 10},
+ {uniname2ctype_offset(str13), 14},
+ {uniname2ctype_offset(str14), 3},
+ {uniname2ctype_offset(str15), 9},
+ {uniname2ctype_offset(str16), 8},
+ {uniname2ctype_offset(str17), 6},
+ {uniname2ctype_offset(str18), 5},
+ {uniname2ctype_offset(str19), 4},
+ {uniname2ctype_offset(str20), 2}
+#else /* USE_UNICODE_PROPERTIES */
+ {uniname2ctype_offset(str81), 355},
+ {uniname2ctype_offset(str82), 587},
+ {uniname2ctype_offset(str83), 82},
+ {-1},
+ {uniname2ctype_offset(str85), 50},
+ {-1}, {-1},
+ {uniname2ctype_offset(str88), 589},
+ {uniname2ctype_offset(str89), 47},
+ {uniname2ctype_offset(str90), 529},
+ {-1},
+ {uniname2ctype_offset(str92), 55},
+ {uniname2ctype_offset(str93), 338},
+ {-1}, {-1},
+ {uniname2ctype_offset(str96), 415},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str102), 84},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str107), 631},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str115), 79},
+ {-1},
+ {uniname2ctype_offset(str117), 370},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str124), 79},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str135), 127},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str141), 44},
+ {-1}, {-1},
+ {uniname2ctype_offset(str144), 205},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str149), 71},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str155), 353},
+ {-1},
+ {uniname2ctype_offset(str157), 643},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str164), 194},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str169), 394},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str175), 493},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str180), 429},
+ {uniname2ctype_offset(str181), 499},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str186), 67},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str190), 264},
+ {uniname2ctype_offset(str191), 348},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str195), 270},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str199), 662},
+ {-1}, {-1},
+ {uniname2ctype_offset(str202), 614},
+ {uniname2ctype_offset(str203), 540},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str209), 342},
+ {-1},
+ {uniname2ctype_offset(str211), 520},
+ {-1},
+ {uniname2ctype_offset(str213), 420},
+ {-1},
+ {uniname2ctype_offset(str215), 130},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str219), 161},
+ {uniname2ctype_offset(str220), 477},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str227), 444},
+ {uniname2ctype_offset(str228), 171},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str235), 271},
+ {-1},
+ {uniname2ctype_offset(str237), 181},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str242), 172},
+ {-1},
+ {uniname2ctype_offset(str244), 660},
+ {-1}, {-1},
+ {uniname2ctype_offset(str247), 468},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str257), 372},
+ {uniname2ctype_offset(str258), 350},
+ {-1},
+ {uniname2ctype_offset(str260), 194},
+ {uniname2ctype_offset(str261), 21},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str267), 506},
+ {uniname2ctype_offset(str268), 61},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str274), 14},
+ {uniname2ctype_offset(str275), 289},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str279), 263},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str284), 571},
+ {uniname2ctype_offset(str285), 147},
+ {uniname2ctype_offset(str286), 147},
+ {uniname2ctype_offset(str287), 154},
+ {-1},
+ {uniname2ctype_offset(str289), 478},
+ {-1},
+ {uniname2ctype_offset(str291), 227},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str295), 476},
+ {-1}, {-1},
+ {uniname2ctype_offset(str298), 172},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str310), 105},
+ {-1},
+ {uniname2ctype_offset(str312), 551},
+ {-1}, {-1},
+ {uniname2ctype_offset(str315), 230},
+ {-1},
+ {uniname2ctype_offset(str317), 568},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str333), 173},
+ {-1},
+ {uniname2ctype_offset(str335), 596},
+ {uniname2ctype_offset(str336), 284},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str340), 23},
+ {-1},
+ {uniname2ctype_offset(str342), 200},
+ {-1},
+ {uniname2ctype_offset(str344), 127},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str359), 501},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str364), 667},
+ {-1},
+ {uniname2ctype_offset(str366), 157},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str373), 423},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str384), 36},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str395), 177},
+ {-1}, {-1},
+ {uniname2ctype_offset(str398), 425},
+ {-1},
+ {uniname2ctype_offset(str400), 427},
+ {-1},
+ {uniname2ctype_offset(str402), 248},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str406), 431},
+ {uniname2ctype_offset(str407), 433},
+ {-1}, {-1},
+ {uniname2ctype_offset(str410), 84},
+ {-1},
+ {uniname2ctype_offset(str412), 659},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str416), 18},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str424), 25},
+ {uniname2ctype_offset(str425), 32},
+ {uniname2ctype_offset(str426), 611},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str432), 574},
+ {uniname2ctype_offset(str433), 397},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str438), 655},
+ {-1},
+ {uniname2ctype_offset(str440), 668},
+ {uniname2ctype_offset(str441), 644},
+ {-1}, {-1},
+ {uniname2ctype_offset(str444), 511},
+ {-1}, {-1},
+ {uniname2ctype_offset(str447), 465},
+ {uniname2ctype_offset(str448), 76},
+ {-1}, {-1},
+ {uniname2ctype_offset(str451), 277},
+ {uniname2ctype_offset(str452), 356},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str456), 628},
+ {-1},
+ {uniname2ctype_offset(str458), 143},
+ {uniname2ctype_offset(str459), 143},
+ {uniname2ctype_offset(str460), 24},
+ {uniname2ctype_offset(str461), 480},
+ {uniname2ctype_offset(str462), 37},
+ {uniname2ctype_offset(str463), 53},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str468), 26},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str472), 371},
+ {uniname2ctype_offset(str473), 186},
+ {-1}, {-1},
+ {uniname2ctype_offset(str476), 68},
+ {uniname2ctype_offset(str477), 391},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str483), 646},
+ {-1},
+ {uniname2ctype_offset(str485), 48},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str491), 516},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str496), 597},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str502), 243},
+ {-1}, {-1},
+ {uniname2ctype_offset(str505), 359},
+ {-1}, {-1},
+ {uniname2ctype_offset(str508), 544},
+ {-1},
+ {uniname2ctype_offset(str510), 157},
+ {uniname2ctype_offset(str511), 358},
+ {uniname2ctype_offset(str512), 368},
+ {uniname2ctype_offset(str513), 138},
+ {uniname2ctype_offset(str514), 111},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str523), 650},
+ {-1},
+ {uniname2ctype_offset(str525), 68},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str549), 570},
+ {-1},
+ {uniname2ctype_offset(str551), 365},
+ {-1},
+ {uniname2ctype_offset(str553), 564},
+ {uniname2ctype_offset(str554), 591},
+ {-1},
+ {uniname2ctype_offset(str556), 232},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str571), 77},
+ {-1}, {-1},
+ {uniname2ctype_offset(str574), 248},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str584), 199},
+ {-1}, {-1},
+ {uniname2ctype_offset(str587), 419},
+ {uniname2ctype_offset(str588), 533},
+ {-1}, {-1},
+ {uniname2ctype_offset(str591), 96},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str605), 340},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str617), 341},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str622), 209},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str630), 209},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str635), 524},
+ {-1},
+ {uniname2ctype_offset(str637), 595},
+ {uniname2ctype_offset(str638), 396},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str645), 343},
+ {-1}, {-1},
+ {uniname2ctype_offset(str648), 550},
+ {-1},
+ {uniname2ctype_offset(str650), 508},
+ {-1}, {-1},
+ {uniname2ctype_offset(str653), 139},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str665), 110},
+ {-1},
+ {uniname2ctype_offset(str667), 19},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str674), 623},
+ {uniname2ctype_offset(str675), 390},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str681), 118},
+ {uniname2ctype_offset(str682), 373},
+ {-1},
+ {uniname2ctype_offset(str684), 193},
+ {-1}, {-1},
+ {uniname2ctype_offset(str687), 416},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str701), 187},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str707), 125},
+ {-1},
+ {uniname2ctype_offset(str709), 561},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str716), 548},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str721), 215},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str727), 205},
+ {-1},
+ {uniname2ctype_offset(str729), 94},
+ {uniname2ctype_offset(str730), 159},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str734), 239},
+ {uniname2ctype_offset(str735), 532},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str747), 159},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str751), 165},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str760), 38},
+ {-1},
+ {uniname2ctype_offset(str762), 253},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str766), 28},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str780), 228},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str784), 244},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str788), 489},
+ {uniname2ctype_offset(str789), 94},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str795), 503},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str799), 414},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str803), 60},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str809), 448},
+ {uniname2ctype_offset(str810), 612},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str815), 53},
+ {-1},
+ {uniname2ctype_offset(str817), 52},
+ {uniname2ctype_offset(str818), 627},
+ {-1},
+ {uniname2ctype_offset(str820), 381},
+ {uniname2ctype_offset(str821), 509},
+ {-1},
+ {uniname2ctype_offset(str823), 482},
+ {-1},
+ {uniname2ctype_offset(str825), 588},
+ {-1},
+ {uniname2ctype_offset(str827), 51},
+ {uniname2ctype_offset(str828), 211},
+ {uniname2ctype_offset(str829), 91},
+ {uniname2ctype_offset(str830), 554},
+ {-1},
+ {uniname2ctype_offset(str832), 114},
+ {uniname2ctype_offset(str833), 351},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str838), 114},
+ {-1},
+ {uniname2ctype_offset(str840), 1},
+ {-1},
+ {uniname2ctype_offset(str842), 132},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str852), 403},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str857), 128},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str880), 418},
+ {-1}, {-1},
+ {uniname2ctype_offset(str883), 67},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str890), 454},
+ {uniname2ctype_offset(str891), 435},
+ {-1}, {-1},
+ {uniname2ctype_offset(str894), 117},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str898), 275},
+ {-1}, {-1},
+ {uniname2ctype_offset(str901), 230},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str909), 152},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str919), 579},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str923), 139},
+ {uniname2ctype_offset(str924), 577},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str929), 531},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str940), 149},
+ {-1},
+ {uniname2ctype_offset(str942), 538},
+ {-1},
+ {uniname2ctype_offset(str944), 273},
+ {uniname2ctype_offset(str945), 152},
+ {-1},
+ {uniname2ctype_offset(str947), 270},
+ {-1},
+ {uniname2ctype_offset(str949), 177},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str954), 537},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str966), 264},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str970), 95},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str975), 118},
+ {-1}, {-1},
+ {uniname2ctype_offset(str978), 507},
+ {-1},
+ {uniname2ctype_offset(str980), 346},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str985), 542},
+ {-1}, {-1},
+ {uniname2ctype_offset(str988), 581},
+ {-1},
+ {uniname2ctype_offset(str990), 541},
+ {uniname2ctype_offset(str991), 364},
+ {-1}, {-1},
+ {uniname2ctype_offset(str994), 151},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str999), 380},
+ {-1},
+ {uniname2ctype_offset(str1001), 188},
+ {-1},
+ {uniname2ctype_offset(str1003), 184},
+ {-1},
+ {uniname2ctype_offset(str1005), 560},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1009), 22},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1012), 104},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1016), 57},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1021), 369},
+ {uniname2ctype_offset(str1022), 191},
+ {-1},
+ {uniname2ctype_offset(str1024), 556},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1028), 278},
+ {-1},
+ {uniname2ctype_offset(str1030), 151},
+ {uniname2ctype_offset(str1031), 188},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1036), 78},
+ {uniname2ctype_offset(str1037), 647},
+ {uniname2ctype_offset(str1038), 546},
+ {-1},
+ {uniname2ctype_offset(str1040), 608},
+ {uniname2ctype_offset(str1041), 96},
+ {uniname2ctype_offset(str1042), 279},
+ {-1},
+ {uniname2ctype_offset(str1044), 408},
+ {uniname2ctype_offset(str1045), 457},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1048), 515},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1056), 253},
+ {uniname2ctype_offset(str1057), 56},
+ {uniname2ctype_offset(str1058), 352},
+ {uniname2ctype_offset(str1059), 97},
+ {-1},
+ {uniname2ctype_offset(str1061), 466},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1064), 249},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1068), 160},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1072), 236},
+ {uniname2ctype_offset(str1073), 378},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1077), 86},
+ {-1},
+ {uniname2ctype_offset(str1079), 153},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1087), 464},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1090), 108},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1094), 630},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1102), 29},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1105), 138},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1109), 86},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1113), 213},
+ {-1},
+ {uniname2ctype_offset(str1115), 153},
+ {-1},
+ {uniname2ctype_offset(str1117), 603},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {-1}, {-1},
+ {uniname2ctype_offset(str1120), 316},
+ {uniname2ctype_offset(str1121), 315},
+ {uniname2ctype_offset(str1122), 318},
+ {uniname2ctype_offset(str1123), 317},
+ {-1},
+ {uniname2ctype_offset(str1125), 297},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1126), 467},
+ {uniname2ctype_offset(str1127), 204},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1128), 299},
+ {uniname2ctype_offset(str1129), 298},
+ {uniname2ctype_offset(str1130), 320},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1131), 236},
+ {uniname2ctype_offset(str1132), 255},
+ {uniname2ctype_offset(str1133), 344},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1134), 324},
+ {uniname2ctype_offset(str1135), 304},
+ {uniname2ctype_offset(str1136), 303},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1137), 99},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1138), 322},
+ {uniname2ctype_offset(str1139), 321},
+ {uniname2ctype_offset(str1140), 312},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1141), 400},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1142), 314},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1143), 413},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1144), 306},
+ {uniname2ctype_offset(str1145), 305},
+ {uniname2ctype_offset(str1146), 323},
+ {uniname2ctype_offset(str1147), 307},
+ {uniname2ctype_offset(str1148), 313},
+ {-1},
+ {uniname2ctype_offset(str1150), 319},
+ {uniname2ctype_offset(str1151), 309},
+ {uniname2ctype_offset(str1152), 308},
+ {-1},
+ {uniname2ctype_offset(str1154), 310},
+ {uniname2ctype_offset(str1155), 301},
+ {uniname2ctype_offset(str1156), 300},
+ {-1},
+ {uniname2ctype_offset(str1158), 302},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1159), 653},
+ {uniname2ctype_offset(str1160), 171},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1170), 99},
+ {-1},
+ {uniname2ctype_offset(str1172), 163},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1175), 436},
+ {uniname2ctype_offset(str1176), 189},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+ {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1181), 311},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+ {uniname2ctype_offset(str1182), 290},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1187), 280},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1191), 407},
+ {uniname2ctype_offset(str1192), 272},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1195), 148},
+ {uniname2ctype_offset(str1196), 513},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1199), 42},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1209), 496},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1214), 510},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1221), 183},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1225), 11},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1228), 3},
+ {uniname2ctype_offset(str1229), 161},
+ {uniname2ctype_offset(str1230), 69},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1239), 545},
+ {-1},
+ {uniname2ctype_offset(str1241), 72},
+ {uniname2ctype_offset(str1242), 109},
+ {uniname2ctype_offset(str1243), 283},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1249), 130},
+ {-1},
+ {uniname2ctype_offset(str1251), 384},
+ {uniname2ctype_offset(str1252), 183},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1259), 218},
+ {uniname2ctype_offset(str1260), 636},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1264), 421},
+ {uniname2ctype_offset(str1265), 75},
+ {-1},
+ {uniname2ctype_offset(str1267), 156},
+ {-1},
+ {uniname2ctype_offset(str1269), 555},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1272), 376},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1275), 208},
+ {-1},
+ {uniname2ctype_offset(str1277), 115},
+ {-1},
+ {uniname2ctype_offset(str1279), 238},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1285), 73},
+ {uniname2ctype_offset(str1286), 204},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1292), 523},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1299), 261},
+ {-1},
+ {uniname2ctype_offset(str1301), 33},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1312), 185},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1315), 199},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1321), 657},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1324), 124},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1328), 240},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1332), 102},
+ {-1},
+ {uniname2ctype_offset(str1334), 166},
+ {uniname2ctype_offset(str1335), 387},
+ {uniname2ctype_offset(str1336), 645},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1339), 136},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1347), 590},
+ {-1},
+ {uniname2ctype_offset(str1349), 363},
+ {uniname2ctype_offset(str1350), 361},
+ {uniname2ctype_offset(str1351), 232},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1357), 70},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1362), 566},
+ {uniname2ctype_offset(str1363), 562},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1368), 40},
+ {-1},
+ {uniname2ctype_offset(str1370), 528},
+ {uniname2ctype_offset(str1371), 395},
+ {uniname2ctype_offset(str1372), 69},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1375), 70},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1397), 632},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1401), 505},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1407), 607},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1415), 680},
+ {uniname2ctype_offset(str1416), 399},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1420), 180},
+ {uniname2ctype_offset(str1421), 136},
+ {-1},
+ {uniname2ctype_offset(str1423), 292},
+ {-1},
+ {uniname2ctype_offset(str1425), 521},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1429), 385},
+ {uniname2ctype_offset(str1430), 190},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1433), 212},
+ {-1},
+ {uniname2ctype_offset(str1435), 598},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1447), 169},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1453), 615},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1456), 100},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1462), 519},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1467), 654},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1470), 95},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1473), 178},
+ {uniname2ctype_offset(str1474), 393},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1479), 293},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1489), 625},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1497), 424},
+ {uniname2ctype_offset(str1498), 410},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1503), 100},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1510), 339},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1515), 115},
+ {uniname2ctype_offset(str1516), 92},
+ {uniname2ctype_offset(str1517), 504},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1528), 585},
+ {-1},
+ {uniname2ctype_offset(str1530), 50},
+ {-1},
+ {uniname2ctype_offset(str1532), 389},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1535), 462},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1551), 294},
+ {uniname2ctype_offset(str1552), 638},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1572), 4},
+ {uniname2ctype_offset(str1573), 133},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1581), 517},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1588), 552},
+ {uniname2ctype_offset(str1589), 426},
+ {uniname2ctype_offset(str1590), 164},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1598), 567},
+ {-1},
+ {uniname2ctype_offset(str1600), 599},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1606), 134},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1614), 293},
+ {uniname2ctype_offset(str1615), 635},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1618), 605},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1626), 241},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1633), 357},
+ {uniname2ctype_offset(str1634), 25},
+ {-1},
+ {uniname2ctype_offset(str1636), 296},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1639), 446},
+ {uniname2ctype_offset(str1640), 124},
+ {uniname2ctype_offset(str1641), 105},
+ {uniname2ctype_offset(str1642), 261},
+ {-1},
+ {uniname2ctype_offset(str1644), 634},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1648), 580},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1654), 460},
+ {uniname2ctype_offset(str1655), 167},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1668), 663},
+ {uniname2ctype_offset(str1669), 530},
+ {uniname2ctype_offset(str1670), 17},
+ {uniname2ctype_offset(str1671), 479},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1674), 85},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1682), 112},
+ {-1},
+ {uniname2ctype_offset(str1684), 569},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1688), 193},
+ {-1},
+ {uniname2ctype_offset(str1690), 432},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1694), 112},
+ {-1},
+ {uniname2ctype_offset(str1696), 244},
+ {uniname2ctype_offset(str1697), 475},
+ {uniname2ctype_offset(str1698), 586},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1707), 637},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1713), 527},
+ {uniname2ctype_offset(str1714), 108},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1724), 215},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1727), 256},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1731), 411},
+ {-1},
+ {uniname2ctype_offset(str1733), 658},
+ {-1},
+ {uniname2ctype_offset(str1735), 664},
+ {-1},
+ {uniname2ctype_offset(str1737), 470},
+ {uniname2ctype_offset(str1738), 106},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1746), 91},
+ {-1},
+ {uniname2ctype_offset(str1748), 148},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1754), 211},
+ {uniname2ctype_offset(str1755), 144},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1762), 200},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1773), 217},
+ {-1},
+ {uniname2ctype_offset(str1775), 252},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1778), 274},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1785), 137},
+ {-1},
+ {uniname2ctype_offset(str1787), 549},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1790), 243},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1793), 594},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1796), 175},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1800), 47},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str1811), 217},
+ {uniname2ctype_offset(str1812), 128},
+ {-1},
+ {uniname2ctype_offset(str1814), 360},
+ {-1},
+ {uniname2ctype_offset(str1816), 21},
+ {-1},
+ {uniname2ctype_offset(str1818), 88},
+ {uniname2ctype_offset(str1819), 83},
+ {-1},
+ {uniname2ctype_offset(str1821), 83},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1824), 661},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1829), 404},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1834), 132},
+ {-1},
+ {uniname2ctype_offset(str1836), 409},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1839), 144},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1847), 234},
+ {uniname2ctype_offset(str1848), 118},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1854), 237},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1858), 514},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1863), 85},
+ {uniname2ctype_offset(str1864), 64},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1867), 349},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1872), 107},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1877), 572},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1884), 626},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1900), 129},
+ {uniname2ctype_offset(str1901), 66},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1910), 345},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1920), 16},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1923), 553},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1936), 629},
+ {uniname2ctype_offset(str1937), 58},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1941), 197},
+ {-1},
+ {uniname2ctype_offset(str1943), 374},
+ {-1},
+ {uniname2ctype_offset(str1945), 362},
+ {-1},
+ {uniname2ctype_offset(str1947), 292},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1956), 563},
+ {-1},
+ {uniname2ctype_offset(str1958), 180},
+ {-1},
+ {uniname2ctype_offset(str1960), 174},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1966), 473},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1969), 92},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1972), 584},
+ {-1},
+ {uniname2ctype_offset(str1974), 492},
+ {uniname2ctype_offset(str1975), 102},
+ {-1},
+ {uniname2ctype_offset(str1977), 534},
+ {uniname2ctype_offset(str1978), 367},
+ {uniname2ctype_offset(str1979), 110},
+ {uniname2ctype_offset(str1980), 221},
+ {-1}, {-1},
+ {uniname2ctype_offset(str1983), 450},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str1987), 558},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2001), 417},
+ {uniname2ctype_offset(str2002), 249},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2005), 383},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2010), 206},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2015), 557},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2022), 624},
+ {uniname2ctype_offset(str2023), 291},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2028), 669},
+ {uniname2ctype_offset(str2029), 174},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2037), 184},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2040), 502},
+ {uniname2ctype_offset(str2041), 206},
+ {uniname2ctype_offset(str2042), 155},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2047), 216},
+ {-1},
+ {uniname2ctype_offset(str2049), 347},
+ {-1},
+ {uniname2ctype_offset(str2051), 41},
+ {-1},
+ {uniname2ctype_offset(str2053), 447},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2056), 398},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2059), 44},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2064), 109},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2074), 207},
+ {-1},
+ {uniname2ctype_offset(str2076), 141},
+ {uniname2ctype_offset(str2077), 498},
+ {uniname2ctype_offset(str2078), 272},
+ {-1},
+ {uniname2ctype_offset(str2080), 284},
+ {uniname2ctype_offset(str2081), 123},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2085), 459},
+ {-1},
+ {uniname2ctype_offset(str2087), 231},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2090), 165},
+ {-1},
+ {uniname2ctype_offset(str2092), 145},
+ {uniname2ctype_offset(str2093), 652},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2097), 19},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2102), 132},
+ {-1},
+ {uniname2ctype_offset(str2104), 392},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2107), 29},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2110), 469},
+ {uniname2ctype_offset(str2111), 210},
+ {-1},
+ {uniname2ctype_offset(str2113), 116},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2117), 225},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2122), 226},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2131), 46},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2137), 166},
+ {uniname2ctype_offset(str2138), 66},
+ {-1},
+ {uniname2ctype_offset(str2140), 117},
+ {-1},
+ {uniname2ctype_offset(str2142), 210},
+ {uniname2ctype_offset(str2143), 81},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2147), 266},
+ {uniname2ctype_offset(str2148), 559},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2152), 202},
+ {uniname2ctype_offset(str2153), 224},
+ {-1},
+ {uniname2ctype_offset(str2155), 337},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2164), 107},
+ {uniname2ctype_offset(str2165), 64},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2168), 452},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2176), 483},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2179), 616},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2182), 285},
+ {uniname2ctype_offset(str2183), 170},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2186), 61},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2191), 593},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2199), 471},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2203), 576},
+ {uniname2ctype_offset(str2204), 438},
+ {-1},
+ {uniname2ctype_offset(str2206), 7},
+ {uniname2ctype_offset(str2207), 173},
+ {-1},
+ {uniname2ctype_offset(str2209), 334},
+ {-1},
+ {uniname2ctype_offset(str2211), 336},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2214), 649},
+ {-1},
+ {uniname2ctype_offset(str2216), 543},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2224), 219},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2228), 214},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2235), 262},
+ {-1},
+ {uniname2ctype_offset(str2237), 619},
+ {-1},
+ {uniname2ctype_offset(str2239), 281},
+ {-1},
+ {uniname2ctype_offset(str2241), 251},
+ {-1},
+ {uniname2ctype_offset(str2243), 265},
+ {uniname2ctype_offset(str2244), 621},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2247), 213},
+ {uniname2ctype_offset(str2248), 622},
+ {uniname2ctype_offset(str2249), 495},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2252), 36},
+ {-1},
+ {uniname2ctype_offset(str2254), 620},
+ {uniname2ctype_offset(str2255), 271},
+ {-1},
+ {uniname2ctype_offset(str2257), 250},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2260), 6},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2270), 134},
+ {-1},
+ {uniname2ctype_offset(str2272), 375},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2279), 428},
+ {-1},
+ {uniname2ctype_offset(str2281), 484},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2285), 430},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2288), 379},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2296), 22},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2299), 582},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2302), 283},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2308), 287},
+ {uniname2ctype_offset(str2309), 226},
+ {uniname2ctype_offset(str2310), 234},
+ {-1},
+ {uniname2ctype_offset(str2312), 497},
+ {uniname2ctype_offset(str2313), 405},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2317), 491},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2320), 225},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2341), 377},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2345), 73},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2350), 618},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2353), 214},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2361), 263},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2364), 240},
+ {-1},
+ {uniname2ctype_offset(str2366), 224},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2370), 198},
+ {uniname2ctype_offset(str2371), 406},
+ {-1},
+ {uniname2ctype_offset(str2373), 122},
+ {uniname2ctype_offset(str2374), 494},
+ {uniname2ctype_offset(str2375), 676},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2379), 651},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2389), 186},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2392), 656},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2396), 329},
+ {uniname2ctype_offset(str2397), 325},
+ {uniname2ctype_offset(str2398), 9},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2401), 122},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2416), 295},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2421), 682},
+ {uniname2ctype_offset(str2422), 665},
+ {-1},
+ {uniname2ctype_offset(str2424), 41},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2427), 683},
+ {uniname2ctype_offset(str2428), 684},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2432), 681},
+ {uniname2ctype_offset(str2433), 474},
+ {uniname2ctype_offset(str2434), 169},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2439), 486},
+ {uniname2ctype_offset(str2440), 49},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2443), 104},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2451), 268},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2458), 40},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2466), 72},
+ {-1},
+ {uniname2ctype_offset(str2468), 229},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2473), 490},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2483), 245},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2491), 512},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2495), 277},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2503), 26},
+ {-1},
+ {uniname2ctype_offset(str2505), 167},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2518), 111},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2526), 388},
+ {-1},
+ {uniname2ctype_offset(str2528), 223},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2532), 195},
+ {-1},
+ {uniname2ctype_offset(str2534), 133},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2541), 461},
+ {-1},
+ {uniname2ctype_offset(str2543), 30},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2553), 522},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2570), 43},
+ {uniname2ctype_offset(str2571), 440},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2577), 463},
+ {-1},
+ {uniname2ctype_offset(str2579), 268},
+ {-1},
+ {uniname2ctype_offset(str2581), 31},
+ {uniname2ctype_offset(str2582), 222},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2590), 610},
+ {uniname2ctype_offset(str2591), 366},
+ {uniname2ctype_offset(str2592), 592},
+ {uniname2ctype_offset(str2593), 332},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2596), 536},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2599), 328},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2603), 276},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2612), 666},
+ {uniname2ctype_offset(str2613), 201},
+ {uniname2ctype_offset(str2614), 245},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2618), 24},
+ {uniname2ctype_offset(str2619), 222},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2625), 88},
+ {uniname2ctype_offset(str2626), 221},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2632), 62},
+ {uniname2ctype_offset(str2633), 573},
+ {uniname2ctype_offset(str2634), 156},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2658), 246},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2668), 246},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2671), 441},
+ {uniname2ctype_offset(str2672), 49},
+ {uniname2ctype_offset(str2673), 106},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2679), 229},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2688), 382},
+ {uniname2ctype_offset(str2689), 259},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2699), 386},
+ {uniname2ctype_offset(str2700), 20},
+ {uniname2ctype_offset(str2701), 181},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2705), 295},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2708), 78},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2714), 401},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str2725), 126},
+ {uniname2ctype_offset(str2726), 116},
+ {-1},
+ {uniname2ctype_offset(str2728), 282},
+ {uniname2ctype_offset(str2729), 231},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2732), 252},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2737), 101},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2764), 81},
+ {uniname2ctype_offset(str2765), 326},
+ {-1},
+ {uniname2ctype_offset(str2767), 178},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2780), 330},
+ {-1},
+ {uniname2ctype_offset(str2782), 201},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2791), 451},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2796), 233},
+ {-1},
+ {uniname2ctype_offset(str2798), 39},
+ {uniname2ctype_offset(str2799), 641},
+ {uniname2ctype_offset(str2800), 45},
+ {uniname2ctype_offset(str2801), 54},
+ {uniname2ctype_offset(str2802), 219},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2806), 276},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2813), 207},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2819), 258},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2826), 87},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2831), 20},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2835), 168},
+ {uniname2ctype_offset(str2836), 149},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2844), 87},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2850), 146},
+ {-1},
+ {uniname2ctype_offset(str2852), 182},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2857), 412},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2861), 146},
+ {-1},
+ {uniname2ctype_offset(str2863), 481},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2869), 648},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2872), 142},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2877), 121},
+ {uniname2ctype_offset(str2878), 485},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2881), 525},
+ {-1},
+ {uniname2ctype_offset(str2883), 27},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str2894), 5},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2897), 547},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2900), 35},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2910), 472},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2922), 145},
+ {-1}, {-1},
+ {uniname2ctype_offset(str2925), 176},
+ {uniname2ctype_offset(str2926), 445},
+ {-1},
+ {uniname2ctype_offset(str2928), 294},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2947), 140},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2953), 434},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2960), 220},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2970), 131},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2984), 179},
+ {-1},
+ {uniname2ctype_offset(str2986), 129},
+ {uniname2ctype_offset(str2987), 55},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str2991), 604},
+ {-1},
+ {uniname2ctype_offset(str2993), 526},
+ {-1},
+ {uniname2ctype_offset(str2995), 583},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3005), 220},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3013), 254},
+ {-1},
+ {uniname2ctype_offset(str3015), 48},
+ {-1},
+ {uniname2ctype_offset(str3017), 223},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3021), 278},
+ {uniname2ctype_offset(str3022), 80},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3041), 62},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3049), 609},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3052), 233},
+ {-1},
+ {uniname2ctype_offset(str3054), 65},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3061), 265},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3068), 449},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3078), 247},
+ {-1},
+ {uniname2ctype_offset(str3080), 258},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3086), 453},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3090), 439},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3097), 90},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3103), 286},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3107), 126},
+ {uniname2ctype_offset(str3108), 12},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3112), 251},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3121), 137},
+ {uniname2ctype_offset(str3122), 288},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3127), 90},
+ {uniname2ctype_offset(str3128), 121},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3137), 639},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3142), 103},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3165), 617},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3169), 437},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3177), 600},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3184), 135},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3188), 602},
+ {-1},
+ {uniname2ctype_offset(str3190), 601},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3221), 565},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3231), 455},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3238), 150},
+ {-1},
+ {uniname2ctype_offset(str3240), 131},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3245), 190},
+ {-1},
+ {uniname2ctype_offset(str3247), 37},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3257), 198},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3261), 52},
+ {-1},
+ {uniname2ctype_offset(str3263), 196},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3281), 238},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3287), 443},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3291), 65},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3302), 327},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3307), 254},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3326), 535},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3334), 42},
+ {uniname2ctype_offset(str3335), 285},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3357), 182},
+ {-1},
+ {uniname2ctype_offset(str3359), 142},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3363), 163},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3407), 642},
+ {uniname2ctype_offset(str3408), 675},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3414), 458},
+ {-1},
+ {uniname2ctype_offset(str3416), 679},
+ {-1},
+ {uniname2ctype_offset(str3418), 101},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3426), 456},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3432), 670},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3436), 202},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3444), 488},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3469), 175},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3481), 162},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3493), 241},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3497), 34},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3505), 279},
+ {-1},
+ {uniname2ctype_offset(str3507), 280},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3516), 140},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3532), 141},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3535), 673},
+ {uniname2ctype_offset(str3536), 208},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3543), 250},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3569), 671},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3579), 31},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3585), 216},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3598), 179},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3613), 135},
+ {uniname2ctype_offset(str3614), 63},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3622), 640},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3629), 23},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3647), 168},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3650), 333},
+ {uniname2ctype_offset(str3651), 335},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3654), 672},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3666), 93},
+ {-1}, {-1},
+ {uniname2ctype_offset(str3669), 500},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3686), 262},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3690), 296},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3699), 15},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3718), 119},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3733), 162},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3770), 275},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3778), 63},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3782), 150},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3813), 158},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3835), 197},
+ {uniname2ctype_offset(str3836), 51},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3869), 291},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3877), 235},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3894), 247},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3901), 33},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3918), 402},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3945), 269},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str3965), 578},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3972), 266},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3981), 18},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str3995), 38},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4007), 260},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str4018), 442},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4035), 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},
+ {uniname2ctype_offset(str4064), 103},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4069), 331},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4072), 32},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4089), 119},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4102), 170},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4110), 89},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4117), 260},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4140), 196},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4153), 289},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4163), 45},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4180), 235},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4228), 195},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4318), 259},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4353), 678},
+ {uniname2ctype_offset(str4354), 422},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str4401), 286},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4404), 267},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4410), 242},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4414), 287},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4439), 28},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4491), 43},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4494), 257},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4543), 487},
+ {uniname2ctype_offset(str4544), 8},
+ {uniname2ctype_offset(str4545), 267},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4564), 674},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4670), 39},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4692), 677},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str4731), 158},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4775), 71},
+ {-1},
+ {uniname2ctype_offset(str4777), 257},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4800), 46},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4851), 274},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4941), 80},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str4985), 269},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5002), 633},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5234), 59},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5271), 74},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5290), 228},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str5329), 242},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1},
+ {uniname2ctype_offset(str5512), 185},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5557), 10},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5800), 30},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1},
+ {uniname2ctype_offset(str5919), 74},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str5981), 93},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str6036), 89},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1},
+ {uniname2ctype_offset(str6068), 54}
+#endif /* USE_UNICODE_PROPERTIES */
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register unsigned int key = uniname2ctype_hash (str, len);
+
+ if (key <= MAX_HASH_VALUE)
+ {
+ register int o = wordlist[key].name;
+ if (o >= 0)
+ {
+ register const char *s = o + uniname2ctype_pool;
+
+ if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+ return &wordlist[key];
+ }
+ }
+ }
+ return 0;
+}
+
+static int
+uniname2ctype(const UChar *name, unsigned int len)
+{
+ const struct uniname2ctype_struct *p = uniname2ctype_p((const char *)name, len);
+ if (p) return p->ctype;
+ return -1;
+}
+#if defined ONIG_UNICODE_VERSION_STRING && !( \
+ ONIG_UNICODE_VERSION_MAJOR == 17 && \
+ ONIG_UNICODE_VERSION_MINOR == 0 && \
+ ONIG_UNICODE_VERSION_TEENY == 0 && \
+ 1)
+# error ONIG_UNICODE_VERSION_STRING mismatch
+#endif
+#define ONIG_UNICODE_VERSION_STRING "17.0.0"
+#define ONIG_UNICODE_VERSION_MAJOR 17
+#define ONIG_UNICODE_VERSION_MINOR 0
+#define ONIG_UNICODE_VERSION_TEENY 0
+#if defined ONIG_UNICODE_EMOJI_VERSION_STRING && !( \
+ ONIG_UNICODE_EMOJI_VERSION_MAJOR == 17 && \
+ ONIG_UNICODE_EMOJI_VERSION_MINOR == 0 && \
+ 1)
+# error ONIG_UNICODE_EMOJI_VERSION_STRING mismatch
+#endif
+#define ONIG_UNICODE_EMOJI_VERSION_STRING "17.0"
+#define ONIG_UNICODE_EMOJI_VERSION_MAJOR 17
+#define ONIG_UNICODE_EMOJI_VERSION_MINOR 0
diff --git a/enc/us_ascii.c b/enc/us_ascii.c
index 08f9072c43..253ee69572 100644
--- a/enc/us_ascii.c
+++ b/enc/us_ascii.c
@@ -32,7 +32,11 @@ OnigEncodingDefine(us_ascii, US_ASCII) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_single_byte_ascii_only_case_map,
+#else
+ NULL,
+#endif
ENCINDEX_US_ASCII,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/utf_16be.c b/enc/utf_16be.c
index f9dd7119d6..0086040b5d 100644
--- a/enc/utf_16be.c
+++ b/enc/utf_16be.c
@@ -249,7 +249,11 @@ OnigEncodingDefine(utf_16be, UTF_16BE) = {
onigenc_utf16_32_get_ctype_code_range,
utf16be_left_adjust_char_head,
onigenc_always_false_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_unicode_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_UNICODE,
};
diff --git a/enc/utf_16le.c b/enc/utf_16le.c
index 2c8438d0be..ca0fce5387 100644
--- a/enc/utf_16le.c
+++ b/enc/utf_16le.c
@@ -242,7 +242,11 @@ OnigEncodingDefine(utf_16le, UTF_16LE) = {
onigenc_utf16_32_get_ctype_code_range,
utf16le_left_adjust_char_head,
onigenc_always_false_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_unicode_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_UNICODE,
};
diff --git a/enc/utf_32be.c b/enc/utf_32be.c
index 17841e52a4..e05cfaf1b2 100644
--- a/enc/utf_32be.c
+++ b/enc/utf_32be.c
@@ -199,7 +199,11 @@ OnigEncodingDefine(utf_32be, UTF_32BE) = {
onigenc_utf16_32_get_ctype_code_range,
utf32be_left_adjust_char_head,
onigenc_always_false_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_unicode_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_UNICODE,
};
diff --git a/enc/utf_32le.c b/enc/utf_32le.c
index 18b798f102..651efdcec5 100644
--- a/enc/utf_32le.c
+++ b/enc/utf_32le.c
@@ -199,7 +199,11 @@ OnigEncodingDefine(utf_32le, UTF_32LE) = {
onigenc_utf16_32_get_ctype_code_range,
utf32le_left_adjust_char_head,
onigenc_always_false_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_unicode_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_UNICODE,
};
diff --git a/enc/utf_8.c b/enc/utf_8.c
index cdf2510d84..ae7c98469d 100644
--- a/enc/utf_8.c
+++ b/enc/utf_8.c
@@ -431,7 +431,11 @@ OnigEncodingDefine(utf_8, UTF_8) = {
get_ctype_code_range,
left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_unicode_case_map,
+#else
+ NULL,
+#endif
ENCINDEX_UTF_8,
ONIGENC_FLAG_UNICODE,
};
diff --git a/enc/windows_1250.c b/enc/windows_1250.c
index daf23e9d1e..d38d50a01d 100644
--- a/enc/windows_1250.c
+++ b/enc/windows_1250.c
@@ -190,6 +190,7 @@ cp1250_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -239,6 +240,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1250, Windows_1250) = {
onigenc_single_byte_mbc_enc_len,
@@ -257,7 +259,11 @@ OnigEncodingDefine(windows_1250, Windows_1250) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_1251.c b/enc/windows_1251.c
index 6c892c1b8c..81641d0337 100644
--- a/enc/windows_1251.c
+++ b/enc/windows_1251.c
@@ -180,6 +180,7 @@ cp1251_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -221,6 +222,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1251, Windows_1251) = {
onigenc_single_byte_mbc_enc_len,
@@ -239,7 +241,11 @@ OnigEncodingDefine(windows_1251, Windows_1251) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_1252.c b/enc/windows_1252.c
index b685878d3f..6aece95c0a 100644
--- a/enc/windows_1252.c
+++ b/enc/windows_1252.c
@@ -181,6 +181,7 @@ cp1252_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -228,6 +229,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1252, Windows_1252) = {
onigenc_single_byte_mbc_enc_len,
@@ -246,7 +248,11 @@ OnigEncodingDefine(windows_1252, Windows_1252) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_1253.c b/enc/windows_1253.c
index b2a43581c3..c95ea3f41c 100644
--- a/enc/windows_1253.c
+++ b/enc/windows_1253.c
@@ -213,6 +213,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
@@ -272,6 +273,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1253, Windows_1253) = {
onigenc_single_byte_mbc_enc_len,
@@ -290,7 +292,11 @@ OnigEncodingDefine(windows_1253, Windows_1253) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_1254.c b/enc/windows_1254.c
index 5e6d92d3d2..c8d5991686 100644
--- a/enc/windows_1254.c
+++ b/enc/windows_1254.c
@@ -221,6 +221,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
#define DOTLESS_i (0xFD)
#define I_WITH_DOT_ABOVE (0xDD)
static int
@@ -277,6 +278,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1254, Windows_1254) = {
onigenc_single_byte_mbc_enc_len,
@@ -295,7 +297,11 @@ OnigEncodingDefine(windows_1254, Windows_1254) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_1257.c b/enc/windows_1257.c
index ada03b72bf..def13c8c49 100644
--- a/enc/windows_1257.c
+++ b/enc/windows_1257.c
@@ -225,6 +225,7 @@ get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}
+#ifdef USE_CASE_MAP_API
#define DOTLESS_i (0xB9)
#define I_WITH_DOT_ABOVE (0xA9)
static int
@@ -279,6 +280,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
*flagP = flags;
return (int )(to - to_start);
}
+#endif
OnigEncodingDefine(windows_1257, Windows_1257) = {
onigenc_single_byte_mbc_enc_len,
@@ -297,7 +299,11 @@ OnigEncodingDefine(windows_1257, Windows_1257) = {
onigenc_not_support_get_ctype_code_range,
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/enc/windows_31j.c b/enc/windows_31j.c
index 1eb859596a..cd8bd83fdd 100644
--- a/enc/windows_31j.c
+++ b/enc/windows_31j.c
@@ -48,7 +48,11 @@ OnigEncodingDefine(windows_31j, Windows_31J) = {
get_ctype_code_range,
left_adjust_char_head,
is_allowed_reverse_match,
+#ifdef USE_CASE_MAP_API
onigenc_ascii_only_case_map,
+#else
+ NULL,
+#endif
0,
ONIGENC_FLAG_NONE,
};
diff --git a/encoding.c b/encoding.c
index 8bfab73177..c17f118eef 100644
--- a/encoding.c
+++ b/encoding.c
@@ -24,10 +24,13 @@
#include "internal/string.h"
#include "internal/vm.h"
#include "regenc.h"
+#include "ruby/atomic.h"
#include "ruby/encoding.h"
#include "ruby/util.h"
+#include "ruby/ractor.h"
#include "ruby_assert.h"
#include "vm_sync.h"
+#include "ruby_atomic.h"
#ifndef ENC_DEBUG
#define ENC_DEBUG 0
@@ -53,13 +56,14 @@ int rb_encdb_alias(const char *alias, const char *orig);
#pragma GCC visibility pop
#endif
-static ID id_encoding;
+static ID id_encoding, id_i_name;
VALUE rb_cEncoding;
#define ENCODING_LIST_CAPA 256
static VALUE rb_encoding_list;
struct rb_encoding_entry {
+ rb_atomic_t loaded;
const char *name;
rb_encoding *enc;
rb_encoding *base;
@@ -71,19 +75,36 @@ static struct enc_table {
st_table *names;
} global_enc_table;
+static int
+enc_names_free_i(st_data_t name, st_data_t idx, st_data_t args)
+{
+ ruby_xfree((void *)name);
+ return ST_DELETE;
+}
+
+void
+rb_free_global_enc_table(void)
+{
+ for (size_t i = 0; i < ENCODING_LIST_CAPA; i++) {
+ xfree((void *)global_enc_table.list[i].enc);
+ }
+
+ st_foreach(global_enc_table.names, enc_names_free_i, (st_data_t)0);
+ st_free_table(global_enc_table.names);
+}
+
static rb_encoding *global_enc_ascii,
*global_enc_utf_8,
*global_enc_us_ascii;
-#define GLOBAL_ENC_TABLE_ENTER(enc_table) struct enc_table *enc_table = &global_enc_table; RB_VM_LOCK_ENTER()
-#define GLOBAL_ENC_TABLE_LEAVE() RB_VM_LOCK_LEAVE()
-#define GLOBAL_ENC_TABLE_EVAL(enc_table, expr) do { \
- GLOBAL_ENC_TABLE_ENTER(enc_table); \
- { \
- expr; \
- } \
- GLOBAL_ENC_TABLE_LEAVE(); \
-} while (0)
+static int filesystem_encindex = ENCINDEX_ASCII_8BIT;
+static rb_atomic_t locale_alias_registered;
+
+#define GLOBAL_ENC_TABLE_LOCKING(tbl) \
+ for (struct enc_table *tbl = &global_enc_table, **locking = &tbl; \
+ locking; \
+ locking = NULL) \
+ RB_VM_LOCKING()
#define ENC_DUMMY_FLAG (1<<24)
@@ -105,8 +126,9 @@ static const rb_data_type_t encoding_data_type = {
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
-#define is_data_encoding(obj) (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type)
-#define is_obj_encoding(obj) (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj))
+#define is_encoding_type(obj) (RTYPEDDATA_TYPE(obj) == &encoding_data_type)
+#define is_data_encoding(obj) is_encoding_type(obj)
+#define is_obj_encoding(obj) (rbimpl_obj_typeddata_p(obj) && is_encoding_type(obj))
int
rb_data_is_encoding(VALUE obj)
@@ -118,8 +140,8 @@ static VALUE
enc_new(rb_encoding *encoding)
{
VALUE enc = TypedData_Wrap_Struct(rb_cEncoding, &encoding_data_type, (void *)encoding);
- rb_obj_freeze(enc);
- FL_SET_RAW(enc, RUBY_FL_SHAREABLE);
+ rb_ivar_set(enc, id_i_name, rb_fstring_cstr(encoding->name));
+ RB_OBJ_SET_FROZEN_SHAREABLE(enc);
return enc;
}
@@ -128,10 +150,16 @@ enc_list_update(int index, rb_raw_encoding *encoding)
{
RUBY_ASSERT(index < ENCODING_LIST_CAPA);
- VALUE list = rb_encoding_list;
+ VALUE list = RUBY_ATOMIC_VALUE_LOAD(rb_encoding_list);
+
if (list && NIL_P(rb_ary_entry(list, index))) {
+ VALUE new_list = rb_ary_dup(list);
+ RBASIC_CLEAR_CLASS(new_list);
/* initialize encoding data */
- rb_ary_store(list, index, enc_new(encoding));
+ rb_ary_store(new_list, index, enc_new(encoding));
+ rb_ary_freeze(new_list);
+ FL_SET_RAW(new_list, RUBY_FL_SHAREABLE);
+ RUBY_ATOMIC_VALUE_SET(rb_encoding_list, new_list);
}
}
@@ -141,7 +169,7 @@ enc_list_lookup(int idx)
VALUE list, enc = Qnil;
if (idx < ENCODING_LIST_CAPA) {
- list = rb_encoding_list;
+ list = RUBY_ATOMIC_VALUE_LOAD(rb_encoding_list);
RUBY_ASSERT(list);
enc = rb_ary_entry(list, idx);
}
@@ -199,7 +227,7 @@ enc_check_encoding(VALUE obj)
if (!is_obj_encoding(obj)) {
return -1;
}
- return check_encoding(RDATA(obj)->data);
+ return check_encoding(RTYPEDDATA_GET_DATA(obj));
}
NORETURN(static void not_encoding(VALUE enc));
@@ -217,7 +245,7 @@ must_encoding(VALUE enc)
if (index < 0) {
not_encoding(enc);
}
- return DATA_PTR(enc);
+ return RTYPEDDATA_GET_DATA(enc);
}
static rb_encoding *
@@ -228,20 +256,21 @@ must_encindex(int index)
rb_raise(rb_eEncodingError, "encoding index out of bound: %d",
index);
}
- if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) {
- rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)",
- index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc));
- }
if (rb_enc_autoload_p(enc) && rb_enc_autoload(enc) == -1) {
rb_loaderror("failed to load encoding (%s)",
rb_enc_name(enc));
}
+ if (ENC_TO_ENCINDEX(enc) != (int)(index & ENC_INDEX_MASK)) {
+ rb_raise(rb_eEncodingError, "wrong encoding index %d for %s (expected %d)",
+ index, rb_enc_name(enc), ENC_TO_ENCINDEX(enc));
+ }
return enc;
}
int
rb_to_encoding_index(VALUE enc)
{
+ ASSERT_vm_unlocking(); // can load encoding, so must not hold VM lock
int idx;
const char *name;
@@ -304,7 +333,7 @@ str_to_encoding(VALUE enc)
rb_encoding *
rb_to_encoding(VALUE enc)
{
- if (enc_check_encoding(enc) >= 0) return RDATA(enc)->data;
+ if (enc_check_encoding(enc) >= 0) return RTYPEDDATA_GET_DATA(enc);
return str_to_encoding(enc);
}
@@ -312,7 +341,7 @@ rb_encoding *
rb_find_encoding(VALUE enc)
{
int idx;
- if (enc_check_encoding(enc) >= 0) return RDATA(enc)->data;
+ if (enc_check_encoding(enc) >= 0) return RTYPEDDATA_GET_DATA(enc);
idx = str_find_encindex(enc);
if (idx < 0) return NULL;
return rb_enc_from_index(idx);
@@ -327,41 +356,81 @@ enc_table_expand(struct enc_table *enc_table, int newsize)
return newsize;
}
+/* Load an encoding using the values from base_encoding */
+static void
+enc_load_from_base(struct enc_table *enc_table, int index, rb_encoding *base_encoding)
+{
+ ASSERT_vm_locking();
+
+ struct rb_encoding_entry *ent = &enc_table->list[index];
+
+ if (ent->loaded) {
+ return;
+ }
+
+ rb_raw_encoding *encoding = (rb_raw_encoding *)ent->enc;
+ RUBY_ASSERT(encoding);
+
+ // FIXME: Before the base is loaded, the encoding may be accessed
+ // concurrently by other Ractors.
+ // We're copying all fields from base_encoding except name and
+ // ruby_encoding_index which we preserve from the original. Since these are
+ // the only fields other threads should read it is likely safe despite
+ // technically being a data race.
+ rb_raw_encoding tmp_encoding = *base_encoding;
+ tmp_encoding.name = encoding->name;
+ tmp_encoding.ruby_encoding_index = encoding->ruby_encoding_index;
+ *encoding = tmp_encoding;
+
+ RUBY_ATOMIC_SET(ent->loaded, encoding->max_enc_len);
+}
+
static int
enc_register_at(struct enc_table *enc_table, int index, const char *name, rb_encoding *base_encoding)
{
+ ASSERT_vm_locking();
+
struct rb_encoding_entry *ent = &enc_table->list[index];
rb_raw_encoding *encoding;
- if (!valid_encoding_name_p(name)) return -1;
- if (!ent->name) {
- ent->name = name = strdup(name);
- }
- else if (STRCASECMP(name, ent->name)) {
- return -1;
- }
- encoding = (rb_raw_encoding *)ent->enc;
- if (!encoding) {
- encoding = xmalloc(sizeof(rb_encoding));
+ RUBY_ASSERT(!ent->loaded);
+ RUBY_ASSERT(!ent->name);
+ RUBY_ASSERT(!ent->enc);
+ RUBY_ASSERT(!ent->base);
+
+ RUBY_ASSERT(valid_encoding_name_p(name));
+
+ ent->name = name = strdup(name);
+
+ encoding = ZALLOC(rb_raw_encoding);
+ encoding->name = name;
+ encoding->ruby_encoding_index = index;
+ ent->enc = encoding;
+
+ if (st_insert(enc_table->names, (st_data_t)name, (st_data_t)index)) {
+ rb_bug("encoding name was somehow registered twice");
}
+
+ enc_list_update(index, encoding);
+
if (base_encoding) {
- *encoding = *base_encoding;
+ enc_load_from_base(enc_table, index, base_encoding);
}
else {
- memset(encoding, 0, sizeof(*ent->enc));
+ /* it should not be loaded yet */
+ RUBY_ASSERT(!encoding->max_enc_len);
}
- encoding->name = name;
- encoding->ruby_encoding_index = index;
- ent->enc = encoding;
- st_insert(enc_table->names, (st_data_t)name, (st_data_t)index);
- enc_list_update(index, encoding);
return index;
}
static int
enc_register(struct enc_table *enc_table, const char *name, rb_encoding *encoding)
{
+ ASSERT_vm_locking();
+
+ if (!valid_encoding_name_p(name)) return -1;
+
int index = enc_table->count;
enc_table->count = enc_table_expand(enc_table, index + 1);
@@ -377,7 +446,9 @@ enc_from_index(struct enc_table *enc_table, int index)
if (UNLIKELY(index < 0 || enc_table->count <= (index &= ENC_INDEX_MASK))) {
return 0;
}
- return enc_table->list[index].enc;
+ rb_encoding *enc = enc_table->list[index].enc;
+ RUBY_ASSERT(ENC_TO_ENCINDEX(enc) == index);
+ return enc;
}
rb_encoding *
@@ -391,8 +462,7 @@ rb_enc_register(const char *name, rb_encoding *encoding)
{
int index;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
index = enc_registered(enc_table, name);
if (index >= 0) {
@@ -401,7 +471,7 @@ rb_enc_register(const char *name, rb_encoding *encoding)
index = enc_register(enc_table, name, encoding);
}
else if (rb_enc_autoload_p(oldenc) || !ENC_DUMMY_P(oldenc)) {
- enc_register_at(enc_table, index, name, encoding);
+ enc_load_from_base(enc_table, index, encoding);
}
else {
rb_raise(rb_eArgError, "encoding %s is already registered", name);
@@ -412,13 +482,13 @@ rb_enc_register(const char *name, rb_encoding *encoding)
set_encoding_const(name, rb_enc_from_index(index));
}
}
- GLOBAL_ENC_TABLE_LEAVE();
return index;
}
int
enc_registered(struct enc_table *enc_table, const char *name)
{
+ ASSERT_vm_locking();
st_data_t idx = 0;
if (!name) return -1;
@@ -429,18 +499,26 @@ enc_registered(struct enc_table *enc_table, const char *name)
return -1;
}
+int
+rb_enc_registered(const char *name)
+{
+ int idx;
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ idx = enc_registered(enc_table, name);
+ }
+ return idx;
+}
+
void
rb_encdb_declare(const char *name)
{
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
int idx = enc_registered(enc_table, name);
if (idx < 0) {
idx = enc_register(enc_table, name, 0);
}
set_encoding_const(name, rb_enc_from_index(idx));
}
- GLOBAL_ENC_TABLE_LEAVE();
}
static void
@@ -472,13 +550,11 @@ set_base_encoding(struct enc_table *enc_table, int index, rb_encoding *base)
void
rb_enc_set_base(const char *name, const char *orig)
{
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
int idx = enc_registered(enc_table, name);
int origidx = enc_registered(enc_table, orig);
set_base_encoding(enc_table, idx, rb_enc_from_index(origidx));
}
- GLOBAL_ENC_TABLE_LEAVE();
}
/* for encdb.h
@@ -512,7 +588,7 @@ enc_replicate_with_index(struct enc_table *enc_table, const char *name, rb_encod
idx = enc_register(enc_table, name, origenc);
}
else {
- idx = enc_register_at(enc_table, idx, name, origenc);
+ enc_load_from_base(enc_table, idx, origenc);
}
if (idx >= 0) {
set_base_encoding(enc_table, idx, origenc);
@@ -529,8 +605,7 @@ rb_encdb_replicate(const char *name, const char *orig)
{
int r;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
int origidx = enc_registered(enc_table, orig);
int idx = enc_registered(enc_table, name);
@@ -539,7 +614,6 @@ rb_encdb_replicate(const char *name, const char *orig)
}
r = enc_replicate_with_index(enc_table, name, rb_enc_from_index(origidx), idx);
}
- GLOBAL_ENC_TABLE_LEAVE();
return r;
}
@@ -549,13 +623,11 @@ rb_define_dummy_encoding(const char *name)
{
int index;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
index = enc_replicate(enc_table, name, rb_ascii8bit_encoding());
rb_encoding *enc = enc_table->list[index].enc;
ENC_SET_DUMMY((rb_raw_encoding *)enc);
}
- GLOBAL_ENC_TABLE_LEAVE();
return index;
}
@@ -565,15 +637,13 @@ rb_encdb_dummy(const char *name)
{
int index;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
index = enc_replicate_with_index(enc_table, name,
rb_ascii8bit_encoding(),
enc_registered(enc_table, name));
rb_encoding *enc = enc_table->list[index].enc;
ENC_SET_DUMMY((rb_raw_encoding *)enc);
}
- GLOBAL_ENC_TABLE_LEAVE();
return index;
}
@@ -635,6 +705,7 @@ enc_dup_name(st_data_t name)
static int
enc_alias_internal(struct enc_table *enc_table, const char *alias, int idx)
{
+ ASSERT_vm_locking();
return st_insert2(enc_table->names, (st_data_t)alias, (st_data_t)idx,
enc_dup_name);
}
@@ -652,18 +723,16 @@ int
rb_enc_alias(const char *alias, const char *orig)
{
int idx, r;
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ enc_check_addable(enc_table, alias); // can raise
+ }
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
- enc_check_addable(enc_table, alias);
- if ((idx = rb_enc_find_index(orig)) < 0) {
- r = -1;
- }
- else {
- r = enc_alias(enc_table, alias, idx);
- }
+ idx = rb_enc_find_index(orig);
+ if (idx < 0) return -1;
+
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ r = enc_alias(enc_table, alias, idx);
}
- GLOBAL_ENC_TABLE_LEAVE();
return r;
}
@@ -673,8 +742,7 @@ rb_encdb_alias(const char *alias, const char *orig)
{
int r;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
int idx = enc_registered(enc_table, orig);
if (idx < 0) {
@@ -682,7 +750,6 @@ rb_encdb_alias(const char *alias, const char *orig)
}
r = enc_alias(enc_table, alias, idx);
}
- GLOBAL_ENC_TABLE_LEAVE();
return r;
}
@@ -690,6 +757,7 @@ rb_encdb_alias(const char *alias, const char *orig)
static void
rb_enc_init(struct enc_table *enc_table)
{
+ ASSERT_vm_locking();
enc_table_expand(enc_table, ENCODING_COUNT + 1);
if (!enc_table->names) {
enc_table->names = st_init_strcasetable_with_size(ENCODING_LIST_CAPA);
@@ -730,6 +798,7 @@ int rb_require_internal_silent(VALUE fname);
static int
load_encoding(const char *name)
{
+ ASSERT_vm_unlocking();
VALUE enclib = rb_sprintf("enc/%s.so", name);
VALUE debug = ruby_debug;
VALUE errinfo;
@@ -745,12 +814,11 @@ load_encoding(const char *name)
enclib = rb_fstring(enclib);
ruby_debug = Qfalse;
errinfo = rb_errinfo();
- loaded = rb_require_internal_silent(enclib);
+ loaded = rb_require_internal_silent(enclib); // must run without VM_LOCK
ruby_debug = debug;
rb_set_errinfo(errinfo);
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
if (loaded < 0 || 1 < loaded) {
idx = -1;
}
@@ -761,51 +829,73 @@ load_encoding(const char *name)
idx = -1;
}
}
- GLOBAL_ENC_TABLE_LEAVE();
return idx;
}
static int
-enc_autoload_body(struct enc_table *enc_table, rb_encoding *enc)
+enc_autoload_body(rb_encoding *enc)
{
- rb_encoding *base = enc_table->list[ENC_TO_ENCINDEX(enc)].base;
+ rb_encoding *base;
+ int i = 0;
+ ASSERT_vm_unlocking();
+
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ base = enc_table->list[ENC_TO_ENCINDEX(enc)].base;
+ }
if (base) {
- int i = 0;
- do {
- if (i >= enc_table->count) return -1;
- } while (enc_table->list[i].enc != base && (++i, 1));
+ bool do_register = true;
if (rb_enc_autoload_p(base)) {
- if (rb_enc_autoload(base) < 0) return -1;
+ if (rb_enc_autoload(base) < 0) {
+ do_register = false;
+ i = -1;
+ }
+ }
+
+ if (do_register) {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ i = ENC_TO_ENCINDEX(enc);
+ enc_load_from_base(enc_table, i, base);
+ RUBY_ASSERT(((rb_raw_encoding *)enc)->ruby_encoding_index == i);
+ }
}
- i = enc->ruby_encoding_index;
- enc_register_at(enc_table, i & ENC_INDEX_MASK, rb_enc_name(enc), base);
- ((rb_raw_encoding *)enc)->ruby_encoding_index = i;
- i &= ENC_INDEX_MASK;
- return i;
}
else {
- return -2;
+ i = -2;
}
+
+ return i;
}
int
rb_enc_autoload(rb_encoding *enc)
{
- int i;
- GLOBAL_ENC_TABLE_EVAL(enc_table, i = enc_autoload_body(enc_table, enc));
+ ASSERT_vm_unlocking();
+ int i = enc_autoload_body(enc);
if (i == -2) {
i = load_encoding(rb_enc_name(enc));
}
return i;
}
+bool
+rb_enc_autoload_p(rb_encoding *enc)
+{
+ int idx = ENC_TO_ENCINDEX(enc);
+ RUBY_ASSERT(rb_enc_from_index(idx) == enc);
+ return !RUBY_ATOMIC_LOAD(global_enc_table.list[idx].loaded);
+}
+
/* Return encoding index or UNSPECIFIED_ENCODING from encoding name */
int
rb_enc_find_index(const char *name)
{
- int i = enc_registered(&global_enc_table, name);
+ int i;
+ ASSERT_vm_unlocking(); // it needs to be unlocked so it can call `load_encoding` if necessary
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ i = enc_registered(enc_table, name);
+ }
rb_encoding *enc;
if (i < 0) {
@@ -950,6 +1040,21 @@ enc_set_index(VALUE obj, int idx)
}
void
+rb_enc_raw_set(VALUE obj, rb_encoding *enc)
+{
+ RUBY_ASSERT(enc_capable(obj));
+
+ int idx = enc ? ENC_TO_ENCINDEX(enc) : 0;
+
+ if (idx < ENCODING_INLINE_MAX) {
+ ENCODING_SET_INLINED(obj, idx);
+ return;
+ }
+ ENCODING_SET_INLINED(obj, ENCODING_INLINE_MAX);
+ rb_ivar_set(obj, rb_id_encoding(), INT2NUM(idx));
+}
+
+void
rb_enc_set_index(VALUE obj, int idx)
{
rb_check_frozen(obj);
@@ -963,7 +1068,6 @@ rb_enc_associate_index(VALUE obj, int idx)
rb_encoding *enc;
int oldidx, oldtermlen, termlen;
-/* enc_check_capable(obj);*/
rb_check_frozen(obj);
oldidx = rb_enc_get_index(obj);
if (oldidx == idx)
@@ -997,13 +1101,22 @@ rb_enc_get(VALUE obj)
return rb_enc_from_index(rb_enc_get_index(obj));
}
+const char *
+rb_enc_inspect_name(rb_encoding *enc)
+{
+ if (enc == global_enc_ascii) {
+ return "BINARY (ASCII-8BIT)";
+ }
+ return enc->name;
+}
+
static rb_encoding*
rb_encoding_check(rb_encoding* enc, VALUE str1, VALUE str2)
{
if (!enc)
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
- rb_enc_name(rb_enc_get(str1)),
- rb_enc_name(rb_enc_get(str2)));
+ rb_enc_inspect_name(rb_enc_get(str1)),
+ rb_enc_inspect_name(rb_enc_get(str2)));
return enc;
}
@@ -1026,6 +1139,13 @@ rb_enc_check(VALUE str1, VALUE str2)
static rb_encoding*
enc_compatible_latter(VALUE str1, VALUE str2, int idx1, int idx2)
{
+ if (idx1 < 0 || idx2 < 0)
+ return 0;
+
+ if (idx1 == idx2) {
+ return rb_enc_from_index(idx1);
+ }
+
int isstr1, isstr2;
rb_encoding *enc1 = rb_enc_from_index(idx1);
rb_encoding *enc2 = rb_enc_from_index(idx2);
@@ -1084,15 +1204,7 @@ enc_compatible_str(VALUE str1, VALUE str2)
int idx1 = enc_get_index_str(str1);
int idx2 = enc_get_index_str(str2);
- if (idx1 < 0 || idx2 < 0)
- return 0;
-
- if (idx1 == idx2) {
- return rb_enc_from_index(idx1);
- }
- else {
- return enc_compatible_latter(str1, str2, idx1, idx2);
- }
+ return enc_compatible_latter(str1, str2, idx1, idx2);
}
rb_encoding*
@@ -1101,13 +1213,6 @@ rb_enc_compatible(VALUE str1, VALUE str2)
int idx1 = rb_enc_get_index(str1);
int idx2 = rb_enc_get_index(str2);
- if (idx1 < 0 || idx2 < 0)
- return 0;
-
- if (idx1 == idx2) {
- return rb_enc_from_index(idx1);
- }
-
return enc_compatible_latter(str1, str2, idx1, idx2);
}
@@ -1120,9 +1225,12 @@ rb_enc_copy(VALUE obj1, VALUE obj2)
/*
* call-seq:
- * obj.encoding -> encoding
+ * encoding -> encoding
*
- * Returns the Encoding object that represents the encoding of obj.
+ * Returns an Encoding object that represents the encoding of +self+;
+ * see {Encodings}[rdoc-ref:encodings.rdoc].
+ *
+ * Related: see {Querying}[rdoc-ref:String@Querying].
*/
VALUE
@@ -1239,33 +1347,20 @@ enc_inspect(VALUE self)
{
rb_encoding *enc;
- if (!is_data_encoding(self)) {
+ if (!is_obj_encoding(self)) { /* do not resolve autoload */
not_encoding(self);
}
- if (!(enc = DATA_PTR(self)) || rb_enc_from_index(rb_enc_to_index(enc)) != enc) {
+ if (!(enc = RTYPEDDATA_GET_DATA(self)) || rb_enc_from_index(rb_enc_to_index(enc)) != enc) {
rb_raise(rb_eTypeError, "broken Encoding");
}
+
return rb_enc_sprintf(rb_usascii_encoding(),
"#<%"PRIsVALUE":%s%s%s>", rb_obj_class(self),
- rb_enc_name(enc),
+ rb_enc_inspect_name(enc),
(ENC_DUMMY_P(enc) ? " (dummy)" : ""),
rb_enc_autoload_p(enc) ? " (autoload)" : "");
}
-/*
- * call-seq:
- * enc.name -> string
- * enc.to_s -> string
- *
- * Returns the name of the encoding.
- *
- * Encoding::UTF_8.name #=> "UTF-8"
- */
-static VALUE
-enc_name(VALUE self)
-{
- return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self)));
-}
static int
enc_names_i(st_data_t name, st_data_t idx, st_data_t args)
@@ -1273,7 +1368,7 @@ enc_names_i(st_data_t name, st_data_t idx, st_data_t args)
VALUE *arg = (VALUE *)args;
if ((int)idx == (int)arg[0]) {
- VALUE str = rb_fstring_cstr((char *)name);
+ VALUE str = rb_interned_str_cstr((char *)name);
rb_ary_push(arg[1], str);
}
return ST_CONTINUE;
@@ -1294,7 +1389,10 @@ enc_names(VALUE self)
args[0] = (VALUE)rb_to_encoding_index(self);
args[1] = rb_ary_new2(0);
- st_foreach(global_enc_table.names, enc_names_i, (st_data_t)args);
+
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ st_foreach(enc_table->names, enc_names_i, (st_data_t)args);
+ }
return args[1];
}
@@ -1319,9 +1417,8 @@ enc_names(VALUE self)
static VALUE
enc_list(VALUE klass)
{
- VALUE ary = rb_ary_new2(0);
- rb_ary_replace(ary, rb_encoding_list);
- return ary;
+ VALUE list = RUBY_ATOMIC_VALUE_LOAD(rb_encoding_list);
+ return rb_ary_dup(list);
}
/*
@@ -1407,7 +1504,7 @@ static VALUE
enc_dump(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 1);
- return enc_name(self);
+ return rb_attr_get(self, id_i_name);
}
/* :nodoc: */
@@ -1465,20 +1562,24 @@ int rb_locale_charmap_index(void);
int
rb_locale_encindex(void)
{
+ // `rb_locale_charmap_index` can call `enc_find_index`, which can
+ // load an encoding. This needs to be done without VM lock held.
+ ASSERT_vm_unlocking();
int idx = rb_locale_charmap_index();
if (idx < 0) idx = ENCINDEX_UTF_8;
- if (enc_registered(&global_enc_table, "locale") < 0) {
+ if (!RUBY_ATOMIC_LOAD(locale_alias_registered)) {
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ if (enc_registered(enc_table, "locale") < 0) {
# if defined _WIN32
- void Init_w32_codepage(void);
- Init_w32_codepage();
+ void Init_w32_codepage(void);
+ Init_w32_codepage();
# endif
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
- enc_alias_internal(enc_table, "locale", idx);
+ enc_alias_internal(enc_table, "locale", idx);
+ }
+ RUBY_ATOMIC_SET(locale_alias_registered, 1);
}
- GLOBAL_ENC_TABLE_LEAVE();
}
return idx;
@@ -1493,9 +1594,7 @@ rb_locale_encoding(void)
int
rb_filesystem_encindex(void)
{
- int idx = enc_registered(&global_enc_table, "filesystem");
- if (idx < 0) idx = ENCINDEX_ASCII_8BIT;
- return idx;
+ return filesystem_encindex;
}
rb_encoding *
@@ -1520,25 +1619,38 @@ enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const cha
/* Already set */
overridden = TRUE;
- GLOBAL_ENC_TABLE_ENTER(enc_table);
- {
+ int index = 0;
+ if (!NIL_P(encoding)) {
+ enc_check_encoding(encoding); // loads it if necessary. Needs to be done outside of VM lock.
+ index = rb_enc_to_index(rb_to_encoding(encoding));
+ }
+
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
if (NIL_P(encoding)) {
def->index = -1;
def->enc = 0;
- st_insert(enc_table->names, (st_data_t)strdup(name),
+ char *name_dup = strdup(name);
+
+ st_data_t existing_name = (st_data_t)name_dup;
+ if (st_delete(enc_table->names, &existing_name, NULL)) {
+ xfree((void *)existing_name);
+ }
+
+ st_insert(enc_table->names, (st_data_t)name_dup,
(st_data_t)UNSPECIFIED_ENCODING);
}
else {
- def->index = rb_enc_to_index(rb_to_encoding(encoding));
+ def->index = index;
def->enc = 0;
enc_alias_internal(enc_table, name, def->index);
}
if (def == &default_external) {
- enc_alias_internal(enc_table, "filesystem", Init_enc_set_filesystem_encoding());
+ int fs_idx = Init_enc_set_filesystem_encoding();
+ enc_alias_internal(enc_table, "filesystem", fs_idx);
+ filesystem_encindex = fs_idx;
}
}
- GLOBAL_ENC_TABLE_LEAVE();
return overridden;
}
@@ -1763,7 +1875,7 @@ static int
rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
{
VALUE ary = (VALUE)arg;
- VALUE str = rb_fstring_cstr((char *)name);
+ VALUE str = rb_interned_str_cstr((char *)name);
rb_ary_push(ary, str);
return ST_CONTINUE;
}
@@ -1785,8 +1897,11 @@ rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
static VALUE
rb_enc_name_list(VALUE klass)
{
- VALUE ary = rb_ary_new2(global_enc_table.names->num_entries);
- st_foreach(global_enc_table.names, rb_enc_name_list_i, (st_data_t)ary);
+ VALUE ary;
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ ary = rb_ary_new2(enc_table->names->num_entries);
+ st_foreach(enc_table->names, rb_enc_name_list_i, (st_data_t)ary);
+ }
return ary;
}
@@ -1808,7 +1923,7 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
str = rb_fstring_cstr(rb_enc_name(enc));
rb_ary_store(ary, idx, str);
}
- key = rb_fstring_cstr((char *)name);
+ key = rb_interned_str_cstr((char *)name);
rb_hash_aset(aliases, key, str);
return ST_CONTINUE;
}
@@ -1832,7 +1947,9 @@ rb_enc_aliases(VALUE klass)
aliases[0] = rb_hash_new();
aliases[1] = rb_ary_new();
- st_foreach(global_enc_table.names, rb_enc_aliases_enc_i, (st_data_t)aliases);
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ st_foreach(enc_table->names, rb_enc_aliases_enc_i, (st_data_t)aliases);
+ }
return aliases[0];
}
@@ -1874,12 +1991,19 @@ Init_Encoding(void)
VALUE list;
int i;
+ id_i_name = rb_intern_const("@name");
rb_cEncoding = rb_define_class("Encoding", rb_cObject);
rb_define_alloc_func(rb_cEncoding, enc_s_alloc);
rb_undef_method(CLASS_OF(rb_cEncoding), "new");
- rb_define_method(rb_cEncoding, "to_s", enc_name, 0);
+
+ /* The name of the encoding.
+ *
+ * Encoding::UTF_8.name #=> "UTF-8"
+ */
+ rb_attr(rb_cEncoding, rb_intern("name"), TRUE, FALSE, Qfalse);
+ rb_define_alias(rb_cEncoding, "to_s", "name");
+
rb_define_method(rb_cEncoding, "inspect", enc_inspect, 0);
- rb_define_method(rb_cEncoding, "name", enc_name, 0);
rb_define_method(rb_cEncoding, "names", enc_names, 0);
rb_define_method(rb_cEncoding, "dummy?", enc_dummy_p, 0);
rb_define_method(rb_cEncoding, "ascii_compatible?", enc_ascii_compatible_p, 0);
@@ -1900,9 +2024,9 @@ Init_Encoding(void)
struct enc_table *enc_table = &global_enc_table;
+ rb_gc_register_address(&rb_encoding_list);
list = rb_encoding_list = rb_ary_new2(ENCODING_LIST_CAPA);
RBASIC_CLEAR_CLASS(list);
- rb_gc_register_mark_object(list);
for (i = 0; i < enc_table->count; ++i) {
rb_ary_push(list, enc_new(enc_table->list[i].enc));
@@ -1912,6 +2036,18 @@ Init_Encoding(void)
}
void
+Init_unicode_version(void)
+{
+ extern const char onigenc_unicode_version_string[];
+
+ VALUE str = rb_usascii_str_new_static(onigenc_unicode_version_string,
+ strlen(onigenc_unicode_version_string));
+ OBJ_FREEZE(str);
+ /* The supported Unicode version. */
+ rb_define_const(rb_cEncoding, "UNICODE_VERSION", str);
+}
+
+void
Init_encodings(void)
{
rb_enc_init(&global_enc_table);
@@ -1922,5 +2058,7 @@ Init_encodings(void)
void
rb_enc_foreach_name(int (*func)(st_data_t name, st_data_t idx, st_data_t arg), st_data_t arg)
{
- st_foreach(global_enc_table.names, func, arg);
+ GLOBAL_ENC_TABLE_LOCKING(enc_table) {
+ st_foreach(enc_table->names, func, arg);
+ }
}
diff --git a/enum.c b/enum.c
index 8e89b603a6..a2941dd7dd 100644
--- a/enum.c
+++ b/enum.c
@@ -127,7 +127,7 @@ static VALUE
enum_grep0(VALUE obj, VALUE pat, VALUE test)
{
VALUE ary = rb_ary_new();
- struct MEMO *memo = MEMO_NEW(pat, ary, test);
+ struct MEMO *memo = rb_imemo_memo_new_value(pat, ary, test);
rb_block_call_func_t fn;
if (rb_block_given_p()) {
fn = grep_iter_i;
@@ -207,27 +207,32 @@ enum_grep_v(VALUE obj, VALUE pat)
return enum_grep0(obj, pat, Qfalse);
}
-#define COUNT_BIGNUM IMEMO_FL_USER0
-#define MEMO_V3_SET(m, v) RB_OBJ_WRITE((m), &(m)->u3.value, (v))
+static inline void
+MEMO_V3_SET(struct MEMO *m, VALUE v)
+{
+ RB_OBJ_WRITE(m, &m->u3.value, v);
+ m->flags |= MEMO_U3_IS_VALUE;
+}
static void
imemo_count_up(struct MEMO *memo)
{
- if (memo->flags & COUNT_BIGNUM) {
+ if (memo->flags & MEMO_U3_IS_VALUE) {
+ RUBY_ASSERT(RB_TYPE_P(memo->u3.value, T_BIGNUM));
MEMO_V3_SET(memo, rb_int_succ(memo->u3.value));
}
else if (++memo->u3.cnt == 0) {
/* overflow */
unsigned long buf[2] = {0, 1};
MEMO_V3_SET(memo, rb_big_unpack(buf, 2));
- memo->flags |= COUNT_BIGNUM;
}
}
static VALUE
imemo_count_value(struct MEMO *memo)
{
- if (memo->flags & COUNT_BIGNUM) {
+ if (memo->flags & MEMO_U3_IS_VALUE) {
+ RUBY_ASSERT(RB_TYPE_P(memo->u3.value, T_BIGNUM));
return memo->u3.value;
}
else {
@@ -317,21 +322,38 @@ enum_count(int argc, VALUE *argv, VALUE obj)
func = count_i;
}
- memo = MEMO_NEW(item, 0, 0);
+ memo = rb_imemo_memo_new(item, 0, 0);
rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
return imemo_count_value(memo);
}
+NORETURN(static void found(VALUE i, VALUE memop));
+static void
+found(VALUE i, VALUE memop)
+{
+ struct MEMO *memo = MEMO_CAST(memop);
+ MEMO_V1_SET(memo, i);
+ memo->u3.cnt = 1;
+ rb_iter_break();
+}
+
+static VALUE
+find_i_fast(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
+{
+ if (RTEST(rb_yield_values2(argc, argv))) {
+ ENUM_WANT_SVALUE();
+ found(i, memop);
+ }
+ return Qnil;
+}
+
static VALUE
find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
{
ENUM_WANT_SVALUE();
if (RTEST(enum_yield(argc, i))) {
- struct MEMO *memo = MEMO_CAST(memop);
- MEMO_V1_SET(memo, i);
- memo->u3.cnt = 1;
- rb_iter_break();
+ found(i, memop);
}
return Qnil;
}
@@ -354,7 +376,7 @@ find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
* {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1]
* {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => []
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
*/
static VALUE
@@ -365,8 +387,11 @@ enum_find(int argc, VALUE *argv, VALUE obj)
if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
RETURN_ENUMERATOR(obj, argc, argv);
- memo = MEMO_NEW(Qundef, 0, 0);
- rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo);
+ memo = rb_imemo_memo_new(Qundef, 0, 0);
+ if (rb_block_pair_yield_optimizable())
+ rb_block_call2(obj, id_each, 0, 0, find_i_fast, (VALUE)memo, RB_BLOCK_NO_USE_PACKED_ARGS);
+ else
+ rb_block_call2(obj, id_each, 0, 0, find_i, (VALUE)memo, RB_BLOCK_NO_USE_PACKED_ARGS);
if (memo->u3.cnt) {
return memo->v1;
}
@@ -424,7 +449,7 @@ find_index_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
* ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1
* {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2
*
- * With no argument and no block given, returns an \Enumerator.
+ * With no argument and no block given, returns an Enumerator.
*
*/
@@ -447,7 +472,7 @@ enum_find_index(int argc, VALUE *argv, VALUE obj)
func = find_index_i;
}
- memo = MEMO_NEW(Qnil, condition_value, 0);
+ memo = rb_imemo_memo_new(Qnil, condition_value, 0);
rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
return memo->v1;
}
@@ -501,7 +526,7 @@ enum_size_over_p(VALUE obj, long n)
* a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') }
* a # => {:bar=>1, :baz=>2}
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
* Related: #reject.
*/
@@ -543,7 +568,7 @@ filter_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16]
* {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz]
*
- * When no block given, returns an \Enumerator.
+ * When no block given, returns an Enumerator.
*
*/
static VALUE
@@ -584,7 +609,7 @@ reject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9]
* {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2}
*
- * When no block given, returns an \Enumerator.
+ * When no block given, returns an Enumerator.
*
* Related: #select.
*/
@@ -631,7 +656,7 @@ collect_all(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16]
* {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4]
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
*/
static VALUE
@@ -681,7 +706,7 @@ flat_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100]
* {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2]
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
* Alias: #collect_concat.
*/
@@ -870,134 +895,151 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
/*
* call-seq:
- * inject(symbol) -> object
- * inject(initial_operand, symbol) -> object
- * inject {|memo, operand| ... } -> object
- * inject(initial_operand) {|memo, operand| ... } -> object
- *
- * Returns an object formed from operands via either:
+ * inject(symbol) -> object
+ * inject(initial_value, symbol) -> object
+ * inject {|memo, value| ... } -> object
+ * inject(initial_value) {|memo, value| ... } -> object
*
- * - A method named by +symbol+.
- * - A block to which each operand is passed.
- *
- * With method-name argument +symbol+,
- * combines operands using the method:
- *
- * # Sum, without initial_operand.
- * (1..4).inject(:+) # => 10
- * # Sum, with initial_operand.
- * (1..4).inject(10, :+) # => 20
+ * Returns the result of applying a reducer to an initial value and
+ * the first element of the Enumerable. It then takes the result and applies the
+ * function to it and the second element of the collection, and so on. The
+ * return value is the result returned by the final call to the function.
*
- * With a block, passes each operand to the block:
- *
- * # Sum of squares, without initial_operand.
- * (1..4).inject {|sum, n| sum + n*n } # => 30
- * # Sum of squares, with initial_operand.
- * (1..4).inject(2) {|sum, n| sum + n*n } # => 32
+ * You can think of
*
- * <b>Operands</b>
+ * [ a, b, c, d ].inject(i) { |r, v| fn(r, v) }
*
- * If argument +initial_operand+ is not given,
- * the operands for +inject+ are simply the elements of +self+.
- * Example calls and their operands:
+ * as being
*
- * - <tt>(1..4).inject(:+)</tt>:: <tt>[1, 2, 3, 4]</tt>.
- * - <tt>(1...4).inject(:+)</tt>:: <tt>[1, 2, 3]</tt>.
- * - <tt>('a'..'d').inject(:+)</tt>:: <tt>['a', 'b', 'c', 'd']</tt>.
- * - <tt>('a'...'d').inject(:+)</tt>:: <tt>['a', 'b', 'c']</tt>.
+ * fn(fn(fn(fn(i, a), b), c), d)
*
- * Examples with first operand (which is <tt>self.first</tt>) of various types:
+ * In a way the +inject+ function _injects_ the function
+ * between the elements of the enumerable.
*
- * # Integer.
- * (1..4).inject(:+) # => 10
- * # Float.
- * [1.0, 2, 3, 4].inject(:+) # => 10.0
- * # Character.
- * ('a'..'d').inject(:+) # => "abcd"
- * # Complex.
- * [Complex(1, 2), 3, 4].inject(:+) # => (8+2i)
+ * +inject+ is aliased as +reduce+. You use it when you want to
+ * _reduce_ a collection to a single value.
*
- * If argument +initial_operand+ is given,
- * the operands for +inject+ are that value plus the elements of +self+.
- * Example calls their operands:
+ * <b>The Calling Sequences</b>
*
- * - <tt>(1..4).inject(10, :+)</tt>:: <tt>[10, 1, 2, 3, 4]</tt>.
- * - <tt>(1...4).inject(10, :+)</tt>:: <tt>[10, 1, 2, 3]</tt>.
- * - <tt>('a'..'d').inject('e', :+)</tt>:: <tt>['e', 'a', 'b', 'c', 'd']</tt>.
- * - <tt>('a'...'d').inject('e', :+)</tt>:: <tt>['e', 'a', 'b', 'c']</tt>.
+ * Let's start with the most verbose:
*
- * Examples with +initial_operand+ of various types:
+ * enum.inject(initial_value) do |result, next_value|
+ * # do something with +result+ and +next_value+
+ * # the value returned by the block becomes the
+ * # value passed in to the next iteration
+ * # as +result+
+ * end
*
- * # Integer.
- * (1..4).inject(2, :+) # => 12
- * # Float.
- * (1..4).inject(2.0, :+) # => 12.0
- * # String.
- * ('a'..'d').inject('foo', :+) # => "fooabcd"
- * # Array.
- * %w[a b c].inject(['x'], :push) # => ["x", "a", "b", "c"]
- * # Complex.
- * (1..4).inject(Complex(2, 2), :+) # => (12+2i)
+ * For example:
*
- * <b>Combination by Given \Method</b>
+ * product = [ 2, 3, 4 ].inject(1) do |result, next_value|
+ * result * next_value
+ * end
+ * product #=> 24
*
- * If the method-name argument +symbol+ is given,
- * the operands are combined by that method:
+ * When this runs, the block is first called with +1+ (the initial value) and
+ * +2+ (the first element of the array). The block returns <tt>1*2</tt>, so on
+ * the next iteration the block is called with +2+ (the previous result) and
+ * +3+. The block returns +6+, and is called one last time with +6+ and +4+.
+ * The result of the block, +24+ becomes the value returned by +inject+. This
+ * code returns the product of the elements in the enumerable.
*
- * - The first and second operands are combined.
- * - That result is combined with the third operand.
- * - That result is combined with the fourth operand.
- * - And so on.
+ * <b>First Shortcut: Default Initial value</b>
*
- * The return value from +inject+ is the result of the last combination.
+ * In the case of the previous example, the initial value, +1+, wasn't really
+ * necessary: the calculation of the product of a list of numbers is self-contained.
*
- * This call to +inject+ computes the sum of the operands:
+ * In these circumstances, you can omit the +initial_value+ parameter. +inject+
+ * will then initially call the block with the first element of the collection
+ * as the +result+ parameter and the second element as the +next_value+.
*
- * (1..4).inject(:+) # => 10
+ * [ 2, 3, 4 ].inject do |result, next_value|
+ * result * next_value
+ * end
*
- * Examples with various methods:
+ * This shortcut is convenient, but can only be used when the block produces a result
+ * which can be passed back to it as a first parameter.
*
- * # Integer addition.
- * (1..4).inject(:+) # => 10
- * # Integer multiplication.
- * (1..4).inject(:*) # => 24
- * # Character range concatenation.
- * ('a'..'d').inject('', :+) # => "abcd"
- * # String array concatenation.
- * %w[foo bar baz].inject('', :+) # => "foobarbaz"
- * # Hash update.
- * h = [{foo: 0, bar: 1}, {baz: 2}, {bat: 3}].inject(:update)
- * h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3}
- * # Hash conversion to nested arrays.
- * h = {foo: 0, bar: 1}.inject([], :push)
- * h # => [[:foo, 0], [:bar, 1]]
+ * Here's an example where that's not the case: it returns a hash where the keys are words
+ * and the values are the number of occurrences of that word in the enumerable.
*
- * <b>Combination by Given Block</b>
+ * freqs = File.read("README.md")
+ * .scan(/\w{2,}/)
+ * .reduce(Hash.new(0)) do |counts, word|
+ * counts[word] += 1
+ * counts
+ * end
+ * freqs #=> {"Actions"=>4,
+ * "Status"=>5,
+ * "MinGW"=>3,
+ * "https"=>27,
+ * "github"=>10,
+ * "com"=>15, ...
*
- * If a block is given, the operands are passed to the block:
+ * Note that the last line of the block is just the word +counts+. This ensures the
+ * return value of the block is the result that's being calculated.
*
- * - The first call passes the first and second operands.
- * - The second call passes the result of the first call,
- * along with the third operand.
- * - The third call passes the result of the second call,
- * along with the fourth operand.
- * - And so on.
+ * <b>Second Shortcut: a Reducer function</b>
*
- * The return value from +inject+ is the return value from the last block call.
- *
- * This call to +inject+ gives a block
- * that writes the memo and element, and also sums the elements:
+ * A <i>reducer function</i> is a function that takes a partial result and the next value,
+ * returning the next partial result. The block that is given to +inject+ is a reducer.
*
- * (1..4).inject do |memo, element|
- * p "Memo: #{memo}; element: #{element}"
- * memo + element
- * end # => 10
+ * You can also write a reducer as a function and pass the name of that function
+ * (as a symbol) to +inject+. However, for this to work, the function
*
- * Output:
+ * 1. Must be defined on the type of the result value
+ * 2. Must accept a single parameter, the next value in the collection, and
+ * 3. Must return an updated result which will also implement the function.
+ *
+ * Here's an example that adds elements to a string. The two calls invoke the functions
+ * String#concat and String#+ on the result so far, passing it the next value.
+ *
+ * s = [ "cat", " ", "dog" ].inject("", :concat)
+ * s #=> "cat dog"
+ * s = [ "cat", " ", "dog" ].inject("The result is:", :+)
+ * s #=> "The result is: cat dog"
+ *
+ * Here's a more complex example when the result object maintains
+ * state of a different type to the enumerable elements.
+ *
+ * class Turtle
+ *
+ * def initialize
+ * @x = @y = 0
+ * end
+ *
+ * def move(dir)
+ * case dir
+ * when "n" then @y += 1
+ * when "s" then @y -= 1
+ * when "e" then @x += 1
+ * when "w" then @x -= 1
+ * end
+ * self
+ * end
+ * end
+ *
+ * position = "nnneesw".chars.reduce(Turtle.new, :move)
+ * position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
+ *
+ * <b>Third Shortcut: Reducer With no Initial Value</b>
+ *
+ * If your reducer returns a value that it can accept as a parameter, then you
+ * don't have to pass in an initial value. Here <tt>:*</tt> is the name of the
+ * _times_ function:
+ *
+ * product = [ 2, 3, 4 ].inject(:*)
+ * product # => 24
*
- * "Memo: 1; element: 2"
- * "Memo: 3; element: 3"
- * "Memo: 6; element: 4"
+ * String concatenation again:
+ *
+ * s = [ "cat", " ", "dog" ].inject(:+)
+ * s #=> "cat dog"
+ *
+ * And an example that converts a hash to an array of two-element subarrays.
+ *
+ * nested = {foo: 0, bar: 1}.inject([], :push)
+ * nested # => [[:foo, 0], [:bar, 1]]
*
*
*/
@@ -1047,7 +1089,7 @@ enum_inject(int argc, VALUE *argv, VALUE obj)
return ary_inject_op(obj, init, op);
}
- memo = MEMO_NEW(init, Qnil, op);
+ memo = rb_imemo_memo_new_value(init, Qnil, op);
rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
if (UNDEF_P(memo->v1)) return Qnil;
return memo->v1;
@@ -1105,7 +1147,7 @@ enum_partition(VALUE obj)
RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
- memo = MEMO_NEW(rb_ary_new(), rb_ary_new(), 0);
+ memo = rb_imemo_memo_new(rb_ary_new(), rb_ary_new(), 0);
rb_block_call(obj, id_each, 0, 0, partition_i, (VALUE)memo);
return rb_assoc_new(memo->v1, memo->v2);
@@ -1178,14 +1220,15 @@ tally_up(st_data_t *group, st_data_t *value, st_data_t arg, int existing)
RB_OBJ_WRITTEN(hash, Qundef, tally);
}
*value = (st_data_t)tally;
- if (!SPECIAL_CONST_P(*group)) RB_OBJ_WRITTEN(hash, Qundef, *group);
return ST_CONTINUE;
}
static VALUE
rb_enum_tally_up(VALUE hash, VALUE group)
{
- rb_hash_stlike_update(hash, group, tally_up, (st_data_t)hash);
+ if (!rb_hash_stlike_update(hash, group, tally_up, (st_data_t)hash)) {
+ RB_OBJ_WRITTEN(hash, Qundef, group);
+ }
return hash;
}
@@ -1199,29 +1242,47 @@ tally_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
/*
* call-seq:
- * tally -> new_hash
- * tally(hash) -> hash
+ * tally(hash = {}) -> hash
*
- * Returns a hash containing the counts of equal elements:
+ * When argument +hash+ is not given,
+ * returns a new hash whose keys are the distinct elements in +self+;
+ * each integer value is the count of occurrences of each element:
*
- * - Each key is an element of +self+.
- * - Each value is the number elements equal to that key.
+ * %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3}
*
- * With no argument:
+ * When argument +hash+ is given,
+ * returns +hash+, possibly augmented; for each element +ele+ in +self+:
*
- * %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3}
+ * - Adds it as a key with a zero value if that key does not already exist:
+ *
+ * hash[ele] = 0 unless hash.include?(ele)
+ *
+ * - Increments the value of key +ele+:
+ *
+ * hash[ele] += 1
*
- * With a hash argument, that hash is used for the tally (instead of a new hash),
- * and is returned;
- * this may be useful for accumulating tallies across multiple enumerables:
+ * This is useful for accumulating tallies across multiple enumerables:
*
- * hash = {}
- * hash = %w[a c d b c a].tally(hash)
- * hash # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1}
- * hash = %w[b a z].tally(hash)
- * hash # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1}
- * hash = %w[b a m].tally(hash)
- * hash # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=> 1}
+ * h = {} # => {}
+ * %w[a c d b c a].tally(h) # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1}
+ * %w[b a z].tally(h) # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1}
+ * %w[b a m].tally(h) # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=>1}
+ *
+ * The key to be added or found for an element depends on the class of +self+;
+ * see {Enumerable in Ruby Classes}[rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes].
+ *
+ * Examples:
+ *
+ * - Array (and certain array-like classes):
+ * the key is the element (as above).
+ * - Hash (and certain hash-like classes):
+ * the key is the 2-element array formed from the key-value pair:
+ *
+ * h = {} # => {}
+ * {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1}
+ * {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>1, [:bar, "b"]=>1, [:foo, "c"]=>1, [:bar, "d"]=>1}
+ * {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1}
+ * {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2}
*
*/
@@ -1289,7 +1350,7 @@ enum_first(int argc, VALUE *argv, VALUE obj)
return enum_take(obj, argv[0]);
}
else {
- memo = MEMO_NEW(Qnil, 0, 0);
+ memo = rb_imemo_memo_new(Qnil, 0, 0);
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)memo);
return memo->v1;
}
@@ -1304,7 +1365,7 @@ enum_first(int argc, VALUE *argv, VALUE obj)
* The ordering of equal elements is indeterminate and may be unstable.
*
* With no block given, the sort compares
- * using the elements' own method <tt><=></tt>:
+ * using the elements' own method <tt>#<=></tt>:
*
* %w[b c a d].sort # => ["a", "b", "c", "d"]
* {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]]
@@ -1334,10 +1395,12 @@ enum_sort(VALUE obj)
}
#define SORT_BY_BUFSIZE 16
+#define SORT_BY_UNIFORMED(num, flo, fix) (((num&1)<<2)|((flo&1)<<1)|fix)
struct sort_by_data {
const VALUE ary;
const VALUE buf;
- long n;
+ uint8_t n;
+ uint8_t primitive_uniformed;
};
static VALUE
@@ -1358,6 +1421,11 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _data))
rb_raise(rb_eRuntimeError, "sort_by reentered");
}
+ if (data->primitive_uniformed) {
+ data->primitive_uniformed &= SORT_BY_UNIFORMED((FIXNUM_P(v)) || (RB_FLOAT_TYPE_P(v)),
+ RB_FLOAT_TYPE_P(v),
+ FIXNUM_P(v));
+ }
RARRAY_ASET(data->buf, data->n*2, v);
RARRAY_ASET(data->buf, data->n*2+1, i);
data->n++;
@@ -1385,6 +1453,179 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
return OPTIMIZED_CMP(a, b);
}
+
+/*
+ This is parts of uniform sort
+*/
+
+#define uless rb_uniform_is_less
+#define UNIFORM_SWAP(a,b)\
+ do{struct rb_uniform_sort_data tmp = a; a = b; b = tmp;} while(0)
+
+struct rb_uniform_sort_data {
+ VALUE v;
+ VALUE i;
+};
+
+static inline bool
+rb_uniform_is_less(VALUE a, VALUE b)
+{
+
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ return (SIGNED_VALUE)a < (SIGNED_VALUE)b;
+ }
+ else if (FIXNUM_P(a)) {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(b));
+ return rb_float_cmp(b, a) > 0;
+ }
+ else {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(a));
+ return rb_float_cmp(a, b) < 0;
+ }
+}
+
+static inline bool
+rb_uniform_is_larger(VALUE a, VALUE b)
+{
+
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ return (SIGNED_VALUE)a > (SIGNED_VALUE)b;
+ }
+ else if (FIXNUM_P(a)) {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(b));
+ return rb_float_cmp(b, a) < 0;
+ }
+ else {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(a));
+ return rb_float_cmp(a, b) > 0;
+ }
+}
+
+#define med3_val(a,b,c) (uless(a,b)?(uless(b,c)?b:uless(c,a)?a:c):(uless(c,b)?b:uless(a,c)?a:c))
+
+static void
+rb_uniform_insertionsort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ if ((ptr_end - ptr_begin) < 2) return;
+ struct rb_uniform_sort_data tmp, *j, *k,
+ *index = ptr_begin+1;
+ for (; index < ptr_end; index++) {
+ tmp = *index;
+ j = k = index;
+ if (uless(tmp.v, ptr_begin->v)) {
+ while (ptr_begin < j) {
+ *j = *(--k);
+ j = k;
+ }
+ }
+ else {
+ while (uless(tmp.v, (--k)->v)) {
+ *j = *k;
+ j = k;
+ }
+ }
+ *j = tmp;
+ }
+}
+
+static inline void
+rb_uniform_heap_down_2(struct rb_uniform_sort_data* ptr_begin,
+ size_t offset, size_t len)
+{
+ size_t c;
+ struct rb_uniform_sort_data tmp = ptr_begin[offset];
+ while ((c = (offset<<1)+1) <= len) {
+ if (c < len && uless(ptr_begin[c].v, ptr_begin[c+1].v)) {
+ c++;
+ }
+ if (!uless(tmp.v, ptr_begin[c].v)) break;
+ ptr_begin[offset] = ptr_begin[c];
+ offset = c;
+ }
+ ptr_begin[offset] = tmp;
+}
+
+static void
+rb_uniform_heapsort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ size_t n = ptr_end - ptr_begin;
+ if (n < 2) return;
+
+ for (size_t offset = n>>1; offset > 0;) {
+ rb_uniform_heap_down_2(ptr_begin, --offset, n-1);
+ }
+ for (size_t offset = n-1; offset > 0;) {
+ UNIFORM_SWAP(*ptr_begin, ptr_begin[offset]);
+ rb_uniform_heap_down_2(ptr_begin, 0, --offset);
+ }
+}
+
+
+static void
+rb_uniform_quicksort_intro_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end, size_t d)
+{
+
+ if (ptr_end - ptr_begin <= 16) {
+ rb_uniform_insertionsort_2(ptr_begin, ptr_end);
+ return;
+ }
+ if (d == 0) {
+ rb_uniform_heapsort_2(ptr_begin, ptr_end);
+ return;
+ }
+
+ VALUE x = med3_val(ptr_begin->v,
+ ptr_begin[(ptr_end - ptr_begin)>>1].v,
+ ptr_end[-1].v);
+ struct rb_uniform_sort_data *i = ptr_begin;
+ struct rb_uniform_sort_data *j = ptr_end-1;
+
+ do {
+ while (uless(i->v, x)) i++;
+ while (uless(x, j->v)) j--;
+ if (i <= j) {
+ UNIFORM_SWAP(*i, *j);
+ i++;
+ j--;
+ }
+ } while (i <= j);
+ j++;
+ if (ptr_end - j > 1) rb_uniform_quicksort_intro_2(j, ptr_end, d-1);
+ if (i - ptr_begin > 1) rb_uniform_quicksort_intro_2(ptr_begin, i, d-1);
+}
+
+/**
+ * Direct primitive data compare sort. Implement with intro sort.
+ * @param[in] ptr_begin The begin address of target rb_ary's raw pointer.
+ * @param[in] ptr_end The end address of target rb_ary's raw pointer.
+**/
+static void
+rb_uniform_intro_sort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ size_t n = ptr_end - ptr_begin;
+ size_t d = CHAR_BIT * sizeof(n) - nlz_intptr(n) - 1;
+ bool sorted_flag = true;
+
+ for (struct rb_uniform_sort_data* ptr = ptr_begin+1; ptr < ptr_end; ptr++) {
+ if (rb_uniform_is_larger((ptr-1)->v, (ptr)->v)) {
+ sorted_flag = false;
+ break;
+ }
+ }
+
+ if (sorted_flag) {
+ return;
+ }
+ rb_uniform_quicksort_intro_2(ptr_begin, ptr_end, d<<1);
+}
+
+#undef uless
+
+
/*
* call-seq:
* sort_by {|element| ... } -> array
@@ -1486,11 +1727,14 @@ enum_sort_by(VALUE obj)
RBASIC_CLEAR_CLASS(ary);
buf = rb_ary_hidden_new(SORT_BY_BUFSIZE*2);
rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil);
- memo = MEMO_NEW(0, 0, 0);
+ memo = rb_imemo_memo_new(0, 0, 0);
data = (struct sort_by_data *)&memo->v1;
RB_OBJ_WRITE(memo, &data->ary, ary);
RB_OBJ_WRITE(memo, &data->buf, buf);
data->n = 0;
+ data->primitive_uniformed = SORT_BY_UNIFORMED((CMP_OPTIMIZABLE(FLOAT) && CMP_OPTIMIZABLE(INTEGER)),
+ CMP_OPTIMIZABLE(FLOAT),
+ CMP_OPTIMIZABLE(INTEGER));
rb_block_call(obj, id_each, 0, 0, sort_by_i, (VALUE)memo);
ary = data->ary;
buf = data->buf;
@@ -1499,9 +1743,16 @@ enum_sort_by(VALUE obj)
rb_ary_concat(ary, buf);
}
if (RARRAY_LEN(ary) > 2) {
- RARRAY_PTR_USE(ary, ptr,
- ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
- sort_by_cmp, (void *)ary));
+ if (data->primitive_uniformed) {
+ RARRAY_PTR_USE(ary, ptr,
+ rb_uniform_intro_sort_2((struct rb_uniform_sort_data*)ptr,
+ (struct rb_uniform_sort_data*)(ptr + RARRAY_LEN(ary))));
+ }
+ else {
+ RARRAY_PTR_USE(ary, ptr,
+ ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
+ sort_by_cmp, (void *)ary));
+ }
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
@@ -1517,7 +1768,10 @@ enum_sort_by(VALUE obj)
#define ENUMFUNC(name) argc ? name##_eqq : rb_block_given_p() ? name##_iter_i : name##_i
-#define MEMO_ENUM_NEW(v1) (rb_check_arity(argc, 0, 1), MEMO_NEW((v1), (argc ? *argv : 0), 0))
+#define ENUM_BLOCK_CALL(name) \
+ rb_block_call2(obj, id_each, 0, 0, ENUMFUNC(name), (VALUE)memo, rb_block_given_p() && rb_block_pair_yield_optimizable() ? RB_BLOCK_NO_USE_PACKED_ARGS : 0);
+
+#define MEMO_ENUM_NEW(v1) (rb_check_arity(argc, 0, 1), rb_imemo_memo_new((v1), (argc ? *argv : 0), 0))
#define DEFINE_ENUMFUNCS(name) \
static VALUE enum_##name##_func(VALUE result, struct MEMO *memo); \
@@ -1567,6 +1821,9 @@ DEFINE_ENUMFUNCS(all)
*
* Returns whether every element meets a given criterion.
*
+ * If +self+ has no element, returns +true+ and argument or block
+ * are not used.
+ *
* With no argument and no block,
* returns whether every element is truthy:
*
@@ -1607,7 +1864,7 @@ enum_all(int argc, VALUE *argv, VALUE obj)
{
struct MEMO *memo = MEMO_ENUM_NEW(Qtrue);
WARN_UNUSED_BLOCK(argc);
- rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)memo);
+ ENUM_BLOCK_CALL(all);
return memo->v1;
}
@@ -1628,6 +1885,9 @@ DEFINE_ENUMFUNCS(any)
*
* Returns whether any element meets a given criterion.
*
+ * If +self+ has no element, returns +false+ and argument or block
+ * are not used.
+ *
* With no argument and no block,
* returns whether any element is truthy:
*
@@ -1658,7 +1918,6 @@ DEFINE_ENUMFUNCS(any)
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false
*
- *
* Related: #all?, #none?, #one?.
*/
@@ -1667,7 +1926,7 @@ enum_any(int argc, VALUE *argv, VALUE obj)
{
struct MEMO *memo = MEMO_ENUM_NEW(Qfalse);
WARN_UNUSED_BLOCK(argc);
- rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)memo);
+ ENUM_BLOCK_CALL(any);
return memo->v1;
}
@@ -1956,7 +2215,7 @@ enum_one(int argc, VALUE *argv, VALUE obj)
VALUE result;
WARN_UNUSED_BLOCK(argc);
- rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)memo);
+ ENUM_BLOCK_CALL(one);
result = memo->v1;
if (UNDEF_P(result)) return Qfalse;
return result;
@@ -2017,7 +2276,7 @@ enum_none(int argc, VALUE *argv, VALUE obj)
struct MEMO *memo = MEMO_ENUM_NEW(Qtrue);
WARN_UNUSED_BLOCK(argc);
- rb_block_call(obj, id_each, 0, 0, ENUMFUNC(none), (VALUE)memo);
+ ENUM_BLOCK_CALL(none);
return memo->v1;
}
@@ -2075,7 +2334,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* The ordering of equal elements is indeterminate and may be unstable.
*
* With no argument and no block, returns the minimum element,
- * using the elements' own method <tt><=></tt> for comparison:
+ * using the elements' own method <tt>#<=></tt> for comparison:
*
* (1..4).min # => 1
* (-4..-1).min # => -4
@@ -2197,7 +2456,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* The ordering of equal elements is indeterminate and may be unstable.
*
* With no argument and no block, returns the maximum element,
- * using the elements' own method <tt><=></tt> for comparison:
+ * using the elements' own method <tt>#<=></tt> for comparison:
*
* (1..4).max # => 4
* (-4..-1).max # => -1
@@ -2386,7 +2645,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
* The ordering of equal elements is indeterminate and may be unstable.
*
* With no argument and no block, returns the minimum and maximum elements,
- * using the elements' own method <tt><=></tt> for comparison:
+ * using the elements' own method <tt>#<=></tt> for comparison:
*
* (1..4).minmax # => [1, 4]
* (-4..-1).minmax # => [-4, -1]
@@ -2500,7 +2759,7 @@ enum_min_by(int argc, VALUE *argv, VALUE obj)
if (argc && !NIL_P(num = argv[0]))
return rb_nmin_run(obj, num, 1, 0, 0);
- memo = MEMO_NEW(Qundef, Qnil, 0);
+ memo = rb_imemo_memo_new(Qundef, Qnil, 0);
rb_block_call(obj, id_each, 0, 0, min_by_i, (VALUE)memo);
return memo->v2;
}
@@ -2574,7 +2833,7 @@ enum_max_by(int argc, VALUE *argv, VALUE obj)
if (argc && !NIL_P(num = argv[0]))
return rb_nmin_run(obj, num, 1, 1, 0);
- memo = MEMO_NEW(Qundef, Qnil, 0);
+ memo = rb_imemo_memo_new(Qundef, Qnil, 0);
rb_block_call(obj, id_each, 0, 0, max_by_i, (VALUE)memo);
return memo->v2;
}
@@ -2725,20 +2984,19 @@ member_i(RB_BLOCK_CALL_FUNC_ARGLIST(iter, args))
static VALUE
enum_member(VALUE obj, VALUE val)
{
- struct MEMO *memo = MEMO_NEW(val, Qfalse, 0);
+ struct MEMO *memo = rb_imemo_memo_new(val, Qfalse, 0);
rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo);
return memo->v2;
}
static VALUE
-each_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo))
+each_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(_, index))
{
- struct MEMO *m = MEMO_CAST(memo);
- VALUE n = imemo_count_value(m);
+ struct vm_ifunc *ifunc = rb_current_ifunc();
+ ifunc->data = (const void *)rb_int_succ(index);
- imemo_count_up(m);
- return rb_yield_values(2, rb_enum_values_pack(argc, argv), n);
+ return rb_yield_values(2, rb_enum_values_pack(argc, argv), index);
}
/*
@@ -2746,7 +3004,8 @@ each_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo))
* each_with_index(*args) {|element, i| ..... } -> self
* each_with_index(*args) -> enumerator
*
- * With a block given, calls the block with each element and its index;
+ * Invoke <tt>self.each</tt> with <tt>*args</tt>.
+ * With a block given, the block receives each element and its index;
* returns +self+:
*
* h = {}
@@ -2771,12 +3030,9 @@ each_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memo))
static VALUE
enum_each_with_index(int argc, VALUE *argv, VALUE obj)
{
- struct MEMO *memo;
-
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
- memo = MEMO_NEW(0, 0, 0);
- rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)memo);
+ rb_block_call(obj, id_each, argc, argv, each_with_index_i, INT2FIX(0));
return obj;
}
@@ -2980,7 +3236,7 @@ enum_each_slice(VALUE obj, VALUE n)
size = limit_by_enum_size(obj, size);
ary = rb_ary_new2(size);
arity = rb_block_arity();
- memo = MEMO_NEW(ary, dont_recycle_block_arg(arity), size);
+ memo = rb_imemo_memo_new(ary, dont_recycle_block_arg(arity), size);
rb_block_call(obj, id_each, 0, 0, each_slice_i, (VALUE)memo);
ary = memo->v1;
if (RARRAY_LEN(ary) > 0) rb_yield(ary);
@@ -3056,7 +3312,7 @@ enum_each_cons(VALUE obj, VALUE n)
RETURN_SIZED_ENUMERATOR(obj, 1, &n, enum_each_cons_size);
arity = rb_block_arity();
if (enum_size_over_p(obj, size)) return obj;
- memo = MEMO_NEW(rb_ary_new2(size), dont_recycle_block_arg(arity), size);
+ memo = rb_imemo_memo_new(rb_ary_new2(size), dont_recycle_block_arg(arity), size);
rb_block_call(obj, id_each, 0, 0, each_cons_i, (VALUE)memo);
return obj;
@@ -3285,7 +3541,7 @@ enum_zip(int argc, VALUE *argv, VALUE obj)
}
/* TODO: use NODE_DOT2 as memo(v, v, -) */
- memo = MEMO_NEW(result, args, 0);
+ memo = rb_imemo_memo_new(result, args, 0);
rb_block_call(obj, id_each, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
return result;
@@ -3328,7 +3584,7 @@ enum_take(VALUE obj, VALUE n)
if (len == 0) return rb_ary_new2(0);
result = rb_ary_new2(len);
- memo = MEMO_NEW(result, 0, len);
+ memo = rb_imemo_memo_new(result, 0, len);
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)memo);
return result;
}
@@ -3416,7 +3672,7 @@ enum_drop(VALUE obj, VALUE n)
}
result = rb_ary_new();
- memo = MEMO_NEW(result, 0, len);
+ memo = rb_imemo_memo_new(result, 0, len);
rb_block_call(obj, id_each, 0, 0, drop_i, (VALUE)memo);
return result;
}
@@ -3454,6 +3710,17 @@ drop_while_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
*
* With no block given, returns an Enumerator.
*
+ * e = (1..4).drop_while
+ * p e #=> #<Enumerator: 1..4:drop_while>
+ * i = e.next; p i; e.feed(i < 3) #=> 1
+ * i = e.next; p i; e.feed(i < 3) #=> 2
+ * i = e.next; p i; e.feed(i < 3) #=> 3
+ * begin
+ * e.next
+ * rescue StopIteration
+ * p $!.result #=> [3, 4]
+ * end
+ *
*/
static VALUE
@@ -3464,7 +3731,7 @@ enum_drop_while(VALUE obj)
RETURN_ENUMERATOR(obj, 0, 0);
result = rb_ary_new();
- memo = MEMO_NEW(result, 0, FALSE);
+ memo = rb_imemo_memo_new(result, 0, FALSE);
rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)memo);
return result;
}
@@ -3663,7 +3930,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator))
* e.next # => [2, [6, 7, 8]]
* e.next # => [3, [9, 10]]
*
- * \Method +chunk+ is especially useful for an enumerable that is already sorted.
+ * Method +chunk+ is especially useful for an enumerable that is already sorted.
* This example counts words for each initial letter in a large array of words:
*
* # Get sorted words from a web page.
@@ -3684,7 +3951,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator))
* ["F", 6860]
*
* You can use the special symbol <tt>:_alone</tt> to force an element
- * into its own separate chuck:
+ * into its own separate chunk:
*
* a = [0, 0, 1, 1]
* e = a.chunk{|i| i.even? ? :_alone : true }
@@ -4343,7 +4610,7 @@ struct enum_sum_memo {
static void
sum_iter_normalize_memo(struct enum_sum_memo *memo)
{
- assert(FIXABLE(memo->n));
+ RUBY_ASSERT(FIXABLE(memo->n));
memo->v = rb_fix_plus(LONG2FIX(memo->n), memo->v);
memo->n = 0;
@@ -4445,7 +4712,7 @@ sum_iter_Kahan_Babuska(VALUE i, struct enum_sum_memo *memo)
static void
sum_iter(VALUE i, struct enum_sum_memo *memo)
{
- assert(memo != NULL);
+ RUBY_ASSERT(memo != NULL);
if (memo->block_given) {
i = rb_yield(i);
}
@@ -4455,7 +4722,7 @@ sum_iter(VALUE i, struct enum_sum_memo *memo)
}
else switch (TYPE(memo->v)) {
default: sum_iter_some_value(i, memo); return;
- case T_FLOAT: sum_iter_Kahan_Babuska(i, memo); return;
+ case T_FLOAT:
case T_FIXNUM:
case T_BIGNUM:
case T_RATIONAL:
@@ -4496,8 +4763,8 @@ hash_sum_i(VALUE key, VALUE value, VALUE arg)
static void
hash_sum(VALUE hash, struct enum_sum_memo *memo)
{
- assert(RB_TYPE_P(hash, T_HASH));
- assert(memo != NULL);
+ RUBY_ASSERT(RB_TYPE_P(hash, T_HASH));
+ RUBY_ASSERT(memo != NULL);
rb_hash_foreach(hash, hash_sum_i, (VALUE)memo);
}
@@ -4629,13 +4896,13 @@ uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
* %w[a b c c b a a b c].uniq # => ["a", "b", "c"]
* [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2]
*
- * With a block, returns a new array containing only for which the block
+ * With a block, returns a new array containing elements only for which the block
* returns a unique value:
*
* a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]
* a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4]
* a = %w[a b c d e e d c b a a b c d e]
- a.uniq {|c| c < 'c' } # => ["a", "c"]
+ * a.uniq {|c| c < 'c' } # => ["a", "c"]
*
*/
@@ -4690,11 +4957,11 @@ enum_compact(VALUE obj)
/*
* == What's Here
*
- * \Module \Enumerable provides methods that are useful to a collection class for:
+ * Module \Enumerable provides methods that are useful to a collection class for:
*
* - {Querying}[rdoc-ref:Enumerable@Methods+for+Querying]
* - {Fetching}[rdoc-ref:Enumerable@Methods+for+Fetching]
- * - {Searching}[rdoc-ref:Enumerable@Methods+for+Searching]
+ * - {Searching and Filtering}[rdoc-ref:Enumerable@Methods+for+Searching+and+Filtering]
* - {Sorting}[rdoc-ref:Enumerable@Methods+for+Sorting]
* - {Iterating}[rdoc-ref:Enumerable@Methods+for+Iterating]
* - {And more....}[rdoc-ref:Enumerable@Other+Methods]
@@ -4703,14 +4970,14 @@ enum_compact(VALUE obj)
*
* These methods return information about the \Enumerable other than the elements themselves:
*
- * - #include?, #member?: Returns +true+ if <tt>self == object</tt>, +false+ otherwise.
+ * - #member? (aliased as #include?): Returns +true+ if <tt>self == object</tt>, +false+ otherwise.
* - #all?: Returns +true+ if all elements meet a specified criterion; +false+ otherwise.
* - #any?: Returns +true+ if any element meets a specified criterion; +false+ otherwise.
* - #none?: Returns +true+ if no element meets a specified criterion; +false+ otherwise.
* - #one?: Returns +true+ if exactly one element meets a specified criterion; +false+ otherwise.
* - #count: Returns the count of elements,
* based on an argument or block criterion, if given.
- * - #tally: Returns a new \Hash containing the counts of occurrences of each element.
+ * - #tally: Returns a new Hash containing the counts of occurrences of each element.
*
* === Methods for Fetching
*
@@ -4718,7 +4985,7 @@ enum_compact(VALUE obj)
*
* <i>Leading, trailing, or all elements</i>:
*
- * - #entries, #to_a: Returns all elements.
+ * - #to_a (aliased as #entries): Returns all elements.
* - #first: Returns the first element or leading elements.
* - #take: Returns a specified number of leading elements.
* - #drop: Returns a specified number of trailing elements.
@@ -4728,24 +4995,24 @@ enum_compact(VALUE obj)
* <i>Minimum and maximum value elements</i>:
*
* - #min: Returns the elements whose values are smallest among the elements,
- * as determined by <tt><=></tt> or a given block.
+ * as determined by <tt>#<=></tt> or a given block.
* - #max: Returns the elements whose values are largest among the elements,
- * as determined by <tt><=></tt> or a given block.
- * - #minmax: Returns a 2-element \Array containing the smallest and largest elements.
+ * as determined by <tt>#<=></tt> or a given block.
+ * - #minmax: Returns a 2-element Array containing the smallest and largest elements.
* - #min_by: Returns the smallest element, as determined by the given block.
* - #max_by: Returns the largest element, as determined by the given block.
* - #minmax_by: Returns the smallest and largest elements, as determined by the given block.
*
* <i>Groups, slices, and partitions</i>:
*
- * - #group_by: Returns a \Hash that partitions the elements into groups.
+ * - #group_by: Returns a Hash that partitions the elements into groups.
* - #partition: Returns elements partitioned into two new Arrays, as determined by the given block.
- * - #slice_after: Returns a new \Enumerator whose entries are a partition of +self+,
- based either on a given +object+ or a given block.
- * - #slice_before: Returns a new \Enumerator whose entries are a partition of +self+,
- based either on a given +object+ or a given block.
- * - #slice_when: Returns a new \Enumerator whose entries are a partition of +self+
- based on the given block.
+ * - #slice_after: Returns a new Enumerator whose entries are a partition of +self+,
+ * based either on a given +object+ or a given block.
+ * - #slice_before: Returns a new Enumerator whose entries are a partition of +self+,
+ * based either on a given +object+ or a given block.
+ * - #slice_when: Returns a new Enumerator whose entries are a partition of +self+
+ * based on the given block.
* - #chunk: Returns elements organized into chunks as specified by the given block.
* - #chunk_while: Returns elements organized into chunks as specified by the given block.
*
@@ -4753,8 +5020,8 @@ enum_compact(VALUE obj)
*
* These methods return elements that meet a specified criterion:
*
- * - #find, #detect: Returns an element selected by the block.
- * - #find_all, #filter, #select: Returns elements selected by the block.
+ * - #find (aliased as #detect): Returns an element selected by the block.
+ * - #find_all (aliased as #filter, #select): Returns elements selected by the block.
* - #find_index: Returns the index of an element selected by a given object or block.
* - #reject: Returns elements not rejected by the block.
* - #uniq: Returns elements that are not duplicates.
@@ -4763,7 +5030,7 @@ enum_compact(VALUE obj)
*
* These methods return elements in sorted order:
*
- * - #sort: Returns the elements, sorted by <tt><=></tt> or the given block.
+ * - #sort: Returns the elements, sorted by <tt>#<=></tt> or the given block.
* - #sort_by: Returns the elements, sorted by the given block.
*
* === Methods for Iterating
@@ -4779,14 +5046,14 @@ enum_compact(VALUE obj)
*
* === Other Methods
*
- * - #map, #collect: Returns objects returned by the block.
+ * - #collect (aliased as #map): Returns objects returned by the block.
* - #filter_map: Returns truthy objects returned by the block.
- * - #flat_map, #collect_concat: Returns flattened objects returned by the block.
+ * - #flat_map (aliased as #collect_concat): Returns flattened objects returned by the block.
* - #grep: Returns elements selected by a given object
* or objects returned by a given block.
- * - #grep_v: Returns elements selected by a given object
+ * - #grep_v: Returns elements not selected by a given object
* or objects returned by a given block.
- * - #reduce, #inject: Returns the object formed by combining all elements.
+ * - #inject (aliased as #reduce): Returns the object formed by combining all elements.
* - #sum: Returns the sum of the elements, using method <tt>+</tt>.
* - #zip: Combines each element with elements from other enumerables;
* returns the n-tuples or calls the block with each.
@@ -4845,18 +5112,94 @@ enum_compact(VALUE obj)
*
* Virtually all methods in \Enumerable call method +#each+ in the including class:
*
- * - <tt>Hash#each</tt> yields the next key-value pair as a 2-element \Array.
- * - <tt>Struct#each</tt> yields the next name-value pair as a 2-element \Array.
+ * - <tt>Hash#each</tt> yields the next key-value pair as a 2-element Array.
+ * - <tt>Struct#each</tt> yields the next name-value pair as a 2-element Array.
* - For the other classes above, +#each+ yields the next object from the collection.
*
* == About the Examples
*
* The example code snippets for the \Enumerable methods:
*
- * - Always show the use of one or more \Array-like classes (often \Array itself).
- * - Sometimes show the use of a \Hash-like class.
+ * - Always show the use of one or more Array-like classes (often Array itself).
+ * - Sometimes show the use of a Hash-like class.
* For some methods, though, the usage would not make sense,
- * and so it is not shown. Example: #tally would find exactly one of each \Hash entry.
+ * and so it is not shown. Example: #tally would find exactly one of each Hash entry.
+ *
+ * == Extended Methods
+ *
+ * A Enumerable class may define extended methods. This section describes the standard
+ * behavior of extension methods for reference purposes.
+ *
+ * === #size
+ *
+ * \Enumerator has a #size method.
+ * It uses the size function argument passed to +Enumerator.new+.
+ *
+ * e = Enumerator.new(-> { 3 }) {|y| p y; y.yield :a; y.yield :b; y.yield :c; :z }
+ * p e.size #=> 3
+ * p e.next #=> :a
+ * p e.next #=> :b
+ * p e.next #=> :c
+ * begin
+ * e.next
+ * rescue StopIteration
+ * p $!.result #=> :z
+ * end
+ *
+ * The result of the size function should represent the number of iterations
+ * (i.e., the number of times you yield to the block argument).
+ * In the above example, the block calls #yield three times, and
+ * the size function, +-> { 3 }+, returns 3 accordingly.
+ * The result of the size function can be an integer, +Float::INFINITY+,
+ * or +nil+.
+ * An integer means the exact number of times #yield will be called,
+ * as shown above.
+ * +Float::INFINITY+ indicates an infinite number of #yield calls.
+ * +nil+ means the number of #yield calls is difficult or impossible to
+ * determine.
+ *
+ * Many iteration methods return an \Enumerator object with an
+ * appropriate size function if no block is given.
+ *
+ * Examples:
+ *
+ * ["a", "b", "c"].each.size #=> 3
+ * {a: "x", b: "y", c: "z"}.each.size #=> 3
+ * (0..20).to_a.permutation.size #=> 51090942171709440000
+ * loop.size #=> Float::INFINITY
+ * (1..100).drop_while.size #=> nil # size depends on the block's behavior
+ * STDIN.each.size #=> nil # cannot be computed without consuming input
+ * File.open("/etc/resolv.conf").each.size #=> nil # cannot be computed without reading the file
+ *
+ * The behavior of #size for Range-based enumerators depends on the #begin element:
+ *
+ * - If the #begin element is an Integer, the #size method returns an Integer or +Float::INFINITY+.
+ * - If the #begin element is an object with a #succ method (other than Integer), #size returns +nil+.
+ * (Computing the size would require repeatedly calling #succ, which may be too slow.)
+ * - If the #begin element does not have a #succ method, #size raises a TypeError.
+ *
+ * Examples:
+ *
+ * (10..42).each.size #=> 33
+ * (10..42.9).each.size #=> 33 (the #end element may be a non-integer numeric)
+ * (10..).each.size #=> Float::INFINITY
+ * ("a".."z").each.size #=> nil
+ * ("a"..).each.size #=> nil
+ * (1.0..9.0).each.size # raises TypeError (Float does not have #succ)
+ * (..10).each.size # raises TypeError (beginless range has nil as its #begin)
+ *
+ * The \Enumerable module itself does not define a #size method.
+ * A class that includes \Enumerable may define its own #size method.
+ * It is recommended that such a #size method be consistent with
+ * Enumerator#size.
+ *
+ * Array and Hash implement #size and return values consistent with
+ * Enumerator#size.
+ * IO and Dir do not define #size, which is also consistent because the
+ * corresponding enumerator's size function returns +nil+.
+ *
+ * However, it is not strictly required for a class's #size method to match Enumerator#size.
+ * For example, File#size returns the number of bytes in the file, not the number of lines.
*
*/
diff --git a/enumerator.c b/enumerator.c
index b2f8855503..69c96b2d8f 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -18,6 +18,7 @@
#include <float.h>
#endif
+#include <limits.h>
#include "id.h"
#include "internal.h"
#include "internal/class.h"
@@ -33,75 +34,93 @@
/*
* Document-class: Enumerator
*
- * A class which allows both internal and external iteration.
+ * \Class \Enumerator supports:
*
- * An Enumerator can be created by the following methods.
- * - Object#to_enum
- * - Object#enum_for
- * - Enumerator.new
+ * - {External iteration}[rdoc-ref:Enumerator@External+Iteration].
+ * - {Internal iteration}[rdoc-ref:Enumerator@Internal+Iteration].
*
- * Most methods have two forms: a block form where the contents
- * are evaluated for each item in the enumeration, and a non-block form
- * which returns a new Enumerator wrapping the iteration.
+ * An \Enumerator may be created by the following methods:
*
- * enumerator = %w(one two three).each
- * puts enumerator.class # => Enumerator
+ * - Object#to_enum.
+ * - Object#enum_for.
+ * - Enumerator.new.
*
- * enumerator.each_with_object("foo") do |item, obj|
- * puts "#{obj}: #{item}"
- * end
+ * In addition, certain Ruby methods return \Enumerator objects:
+ * a Ruby iterator method that accepts a block
+ * may return an \Enumerator if no block is given.
+ * There are many such methods, for example, in classes Array and Hash.
+ * (In the documentation for those classes, search for `new_enumerator`.)
*
- * # foo: one
- * # foo: two
- * # foo: three
+ * == Internal Iteration
*
- * enum_with_obj = enumerator.each_with_object("foo")
- * puts enum_with_obj.class # => Enumerator
+ * In _internal iteration_, an iterator method drives the iteration
+ * and the caller's block handles the processing;
+ * this example uses method #each_with_index:
*
- * enum_with_obj.each do |item, obj|
- * puts "#{obj}: #{item}"
- * end
+ * words = %w[foo bar baz] # => ["foo", "bar", "baz"]
+ * enumerator = words.each # => #<Enumerator: ...>
+ * enumerator.each_with_index {|word, i| puts "#{i}: #{word}" }
+ * 0: foo
+ * 1: bar
+ * 2: baz
*
- * # foo: one
- * # foo: two
- * # foo: three
+ * Iterator methods in class \Enumerator include:
*
- * This allows you to chain Enumerators together. For example, you
- * can map a list's elements to strings containing the index
- * and the element as a string via:
+ * - #each:
+ * passes each item to the block.
+ * - #each_with_index:
+ * passes each item and its index to the block.
+ * - #each_with_object (aliased as #with_object):
+ * passes each item and a given object to the block.
+ * - #with_index:
+ * like #each_with_index, but starting at a given offset (instead of zero).
*
- * puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
- * # => ["0:foo", "1:bar", "2:baz"]
+ * \Class \Enumerator includes module Enumerable,
+ * which provides many more iterator methods.
*
* == External Iteration
*
- * An Enumerator can also be used as an external iterator.
- * For example, Enumerator#next returns the next value of the iterator
- * or raises StopIteration if the Enumerator is at the end.
- *
- * e = [1,2,3].each # returns an enumerator object.
- * puts e.next # => 1
- * puts e.next # => 2
- * puts e.next # => 3
- * puts e.next # raises StopIteration
- *
- * +next+, +next_values+, +peek+ and +peek_values+ are the only methods
- * which use external iteration (and Array#zip(Enumerable-not-Array) which uses +next+).
- *
- * These methods do not affect other internal enumeration methods,
- * unless the underlying iteration method itself has side-effect, e.g. IO#each_line.
- *
- * External iteration differs *significantly* from internal iteration
- * due to using a Fiber:
- * - The Fiber adds some overhead compared to internal enumeration.
- * - The stacktrace will only include the stack from the Enumerator, not above.
- * - Fiber-local variables are *not* inherited inside the Enumerator Fiber,
- * which instead starts with no Fiber-local variables.
- * - Fiber storage variables *are* inherited and are designed
- * to handle Enumerator Fibers. Assigning to a Fiber storage variable
- * only affects the current Fiber, so if you want to change state
- * in the caller Fiber of the Enumerator Fiber, you need to use an
- * extra indirection (e.g., use some object in the Fiber storage
+ * In _external iteration_, the user's program both drives the iteration
+ * and handles the processing in stream-like fashion;
+ * this example uses method #next:
+ *
+ * words = %w[foo bar baz]
+ * enumerator = words.each
+ * enumerator.next # => "foo"
+ * enumerator.next # => "bar"
+ * enumerator.next # => "baz"
+ * enumerator.next # Raises StopIteration: iteration reached an end
+ *
+ * External iteration methods in class \Enumerator include:
+ *
+ * - #feed:
+ * sets the value that is next to be returned.
+ * - #next:
+ * returns the next value and increments the position.
+ * - #next_values:
+ * returns the next value in a 1-element array and increments the position.
+ * - #peek:
+ * returns the next value but does not increment the position.
+ * - #peek_values:
+ * returns the next value in a 1-element array but does not increment the position.
+ * - #rewind:
+ * sets the position to zero.
+ *
+ * Each of these methods raises FrozenError if called from a frozen \Enumerator.
+ *
+ * == External Iteration and \Fiber
+ *
+ * External iteration that uses Fiber differs *significantly* from internal iteration:
+ *
+ * - Using \Fiber adds some overhead compared to internal enumeration.
+ * - The stacktrace will only include the stack from the \Enumerator, not above.
+ * - \Fiber-local variables are *not* inherited inside the \Enumerator \Fiber,
+ * which instead starts with no \Fiber-local variables.
+ * - \Fiber storage variables *are* inherited and are designed
+ * to handle \Enumerator Fibers. Assigning to a \Fiber storage variable
+ * only affects the current \Fiber, so if you want to change state
+ * in the caller \Fiber of the \Enumerator \Fiber, you need to use an
+ * extra indirection (e.g., use some object in the \Fiber storage
* variable and mutate some ivar of it).
*
* Concretely:
@@ -121,7 +140,7 @@
* e.each { p _1 }
* p Fiber[:storage_var] # => 2 (it ran in the same Fiber/"stack" as the current Fiber)
*
- * == Convert External Iteration to Internal Iteration
+ * == Converting External Iteration to Internal Iteration
*
* You can use an external iterator to implement an internal iterator as follows:
*
@@ -158,14 +177,16 @@
*/
VALUE rb_cEnumerator;
static VALUE rb_cLazy;
-static ID id_rewind, id_new, id_to_enum, id_each_entry;
+static ID id_rewind, id_to_enum, id_each_entry;
static ID id_next, id_result, id_receiver, id_arguments, id_memo, id_method, id_force;
-static ID id_begin, id_end, id_step, id_exclude_end;
-static VALUE sym_each, sym_cycle, sym_yield;
+static VALUE sym_each, sym_yield;
static VALUE lazy_use_super_method;
+extern ID ruby_static_id_cause;
+
#define id_call idCall
+#define id_cause ruby_static_id_cause
#define id_each idEach
#define id_eqq idEqq
#define id_initialize idInitialize
@@ -188,6 +209,19 @@ struct enumerator {
int kw_splat;
};
+RUBY_REFERENCES(enumerator_refs) = {
+ RUBY_REF_EDGE(struct enumerator, obj),
+ RUBY_REF_EDGE(struct enumerator, args),
+ RUBY_REF_EDGE(struct enumerator, fib),
+ RUBY_REF_EDGE(struct enumerator, dst),
+ RUBY_REF_EDGE(struct enumerator, lookahead),
+ RUBY_REF_EDGE(struct enumerator, feedvalue),
+ RUBY_REF_EDGE(struct enumerator, stop_exc),
+ RUBY_REF_EDGE(struct enumerator, size),
+ RUBY_REF_EDGE(struct enumerator, procs),
+ RUBY_REF_END
+};
+
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
struct generator {
@@ -202,6 +236,7 @@ struct yielder {
struct producer {
VALUE init;
VALUE proc;
+ VALUE size;
};
typedef struct MEMO *lazyenum_proc_func(VALUE, struct MEMO *, VALUE, long);
@@ -237,56 +272,15 @@ struct enum_product {
VALUE rb_cArithSeq;
-/*
- * Enumerator
- */
-static void
-enumerator_mark(void *p)
-{
- struct enumerator *ptr = p;
- rb_gc_mark_movable(ptr->obj);
- rb_gc_mark_movable(ptr->args);
- rb_gc_mark_movable(ptr->fib);
- rb_gc_mark_movable(ptr->dst);
- rb_gc_mark_movable(ptr->lookahead);
- rb_gc_mark_movable(ptr->feedvalue);
- rb_gc_mark_movable(ptr->stop_exc);
- rb_gc_mark_movable(ptr->size);
- rb_gc_mark_movable(ptr->procs);
-}
-
-static void
-enumerator_compact(void *p)
-{
- struct enumerator *ptr = p;
- ptr->obj = rb_gc_location(ptr->obj);
- ptr->args = rb_gc_location(ptr->args);
- ptr->fib = rb_gc_location(ptr->fib);
- ptr->dst = rb_gc_location(ptr->dst);
- ptr->lookahead = rb_gc_location(ptr->lookahead);
- ptr->feedvalue = rb_gc_location(ptr->feedvalue);
- ptr->stop_exc = rb_gc_location(ptr->stop_exc);
- ptr->size = rb_gc_location(ptr->size);
- ptr->procs = rb_gc_location(ptr->procs);
-}
-
-#define enumerator_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-enumerator_memsize(const void *p)
-{
- return sizeof(struct enumerator);
-}
-
static const rb_data_type_t enumerator_data_type = {
"enumerator",
{
- enumerator_mark,
- enumerator_free,
- enumerator_memsize,
- enumerator_compact,
+ RUBY_REFS_LIST_PTR(enumerator_refs),
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ NULL,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, NULL, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
};
static struct enumerator *
@@ -302,37 +296,22 @@ enumerator_ptr(VALUE obj)
}
static void
-proc_entry_mark(void *p)
+proc_entry_mark_and_move(void *p)
{
struct proc_entry *ptr = p;
- rb_gc_mark_movable(ptr->proc);
- rb_gc_mark_movable(ptr->memo);
-}
-
-static void
-proc_entry_compact(void *p)
-{
- struct proc_entry *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
- ptr->memo = rb_gc_location(ptr->memo);
-}
-
-#define proc_entry_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-proc_entry_memsize(const void *p)
-{
- return p ? sizeof(struct proc_entry) : 0;
+ rb_gc_mark_and_move(&ptr->proc);
+ rb_gc_mark_and_move(&ptr->memo);
}
static const rb_data_type_t proc_entry_data_type = {
"proc_entry",
{
- proc_entry_mark,
- proc_entry_free,
- proc_entry_memsize,
- proc_entry_compact,
+ proc_entry_mark_and_move,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ proc_entry_mark_and_move,
},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct proc_entry *
@@ -417,7 +396,7 @@ obj_to_enum(int argc, VALUE *argv, VALUE obj)
}
enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0);
if (rb_block_given_p()) {
- enumerator_ptr(enumerator)->size = rb_block_proc();
+ RB_OBJ_WRITE(enumerator, &enumerator_ptr(enumerator)->size, rb_block_proc());
}
return enumerator;
}
@@ -446,15 +425,15 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar
rb_raise(rb_eArgError, "unallocated enumerator");
}
- ptr->obj = obj;
+ RB_OBJ_WRITE(enum_obj, &ptr->obj, obj);
ptr->meth = rb_to_id(meth);
- if (argc) ptr->args = rb_ary_new4(argc, argv);
+ if (argc) RB_OBJ_WRITE(enum_obj, &ptr->args, rb_ary_new4(argc, argv));
ptr->fib = 0;
ptr->dst = Qnil;
ptr->lookahead = Qundef;
ptr->feedvalue = Qundef;
ptr->stop_exc = Qfalse;
- ptr->size = size;
+ RB_OBJ_WRITE(enum_obj, &ptr->size, size);
ptr->size_fn = size_fn;
ptr->kw_splat = kw_splat;
@@ -480,28 +459,31 @@ convert_to_feasible_size_value(VALUE obj)
/*
* call-seq:
- * Enumerator.new(size = nil) { |yielder| ... }
+ * Enumerator.new(size = nil) {|yielder| ... }
*
- * Creates a new Enumerator object, which can be used as an
- * Enumerable.
+ * Returns a new \Enumerator object that can be used for iteration.
*
- * Iteration is defined by the given block, in
- * which a "yielder" object, given as block parameter, can be used to
- * yield a value by calling the +yield+ method (aliased as <code><<</code>):
+ * The given block defines the iteration;
+ * it is called with a "yielder" object that can yield an object
+ * via a call to method <tt>yielder.yield</tt>:
*
- * fib = Enumerator.new do |y|
- * a = b = 1
- * loop do
- * y << a
- * a, b = b, a + b
+ * fib = Enumerator.new do |yielder|
+ * n = next_n = 1
+ * while true do
+ * yielder.yield(n)
+ * n, next_n = next_n, n + next_n
* end
* end
*
* fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
*
- * The optional parameter can be used to specify how to calculate the size
- * in a lazy fashion (see Enumerator#size). It can either be a value or
- * a callable object.
+ * Parameter +size+ specifies how the size is to be calculated (see #size);
+ * it can either be a value or a callable object:
+ *
+ * Enumerator.new{}.size # => nil
+ * Enumerator.new(42){}.size # => 42
+ * Enumerator.new(-> {42}){}.size # => 42
+ *
*/
static VALUE
enumerator_initialize(int argc, VALUE *argv, VALUE obj)
@@ -533,13 +515,13 @@ enumerator_init_copy(VALUE obj, VALUE orig)
rb_raise(rb_eArgError, "unallocated enumerator");
}
- ptr1->obj = ptr0->obj;
+ RB_OBJ_WRITE(obj, &ptr1->obj, ptr0->obj);
ptr1->meth = ptr0->meth;
- ptr1->args = ptr0->args;
+ RB_OBJ_WRITE(obj, &ptr1->args, ptr0->args);
ptr1->fib = 0;
ptr1->lookahead = Qundef;
ptr1->feedvalue = Qundef;
- ptr1->size = ptr0->size;
+ RB_OBJ_WRITE(obj, &ptr1->size, ptr0->size);
ptr1->size_fn = ptr0->size_fn;
return obj;
@@ -587,11 +569,17 @@ enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
const struct enumerator *e = enumerator_ptr(obj);
ID meth = e->meth;
- if (e->args) {
- argc = RARRAY_LENINT(e->args);
- argv = RARRAY_CONST_PTR(e->args);
+ VALUE args = e->args;
+ if (args) {
+ argc = RARRAY_LENINT(args);
+ argv = RARRAY_CONST_PTR(args);
}
- return rb_block_call_kw(e->obj, meth, argc, argv, func, arg, e->kw_splat);
+
+ VALUE ret = rb_block_call_kw(e->obj, meth, argc, argv, func, arg, e->kw_splat);
+
+ RB_GC_GUARD(args);
+
+ return ret;
}
/*
@@ -648,7 +636,7 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
else {
args = rb_ary_new4(argc, argv);
}
- e->args = args;
+ RB_OBJ_WRITE(obj, &e->args, args);
e->size = Qnil;
e->size_fn = 0;
}
@@ -701,7 +689,7 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj)
rb_check_arity(argc, 0, 1);
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size);
memo = (!argc || NIL_P(memo = argv[0])) ? INT2FIX(0) : rb_to_int(memo);
- return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0));
+ return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)rb_imemo_memo_new(memo, 0, 0));
}
/*
@@ -789,7 +777,7 @@ next_i(RB_BLOCK_CALL_FUNC_ARGLIST(_, obj))
VALUE result;
result = rb_block_call(obj, id_each, 0, 0, next_ii, obj);
- e->stop_exc = rb_exc_new2(rb_eStopIteration, "iteration reached an end");
+ RB_OBJ_WRITE(obj, &e->stop_exc, rb_exc_new2(rb_eStopIteration, "iteration reached an end"));
rb_ivar_set(e->stop_exc, id_result, result);
return rb_fiber_yield(1, &nil);
}
@@ -798,8 +786,8 @@ 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);
+ RB_OBJ_WRITE(obj, &e->dst, curr);
+ RB_OBJ_WRITE(obj, &e->fib, rb_fiber_new(next_i, obj));
e->lookahead = Qundef;
}
@@ -808,8 +796,16 @@ get_next_values(VALUE obj, struct enumerator *e)
{
VALUE curr, vs;
- if (e->stop_exc)
- rb_exc_raise(e->stop_exc);
+ if (e->stop_exc) {
+ VALUE exc = e->stop_exc;
+ VALUE result = rb_attr_get(exc, id_result);
+ VALUE mesg = rb_attr_get(exc, idMesg);
+ if (!NIL_P(mesg)) mesg = rb_str_dup(mesg);
+ VALUE stop_exc = rb_exc_new_str(rb_eStopIteration, mesg);
+ rb_ivar_set(stop_exc, id_cause, exc);
+ rb_ivar_set(stop_exc, id_result, result);
+ rb_exc_raise(stop_exc);
+ }
curr = rb_fiber_current();
@@ -879,6 +875,8 @@ enumerator_next_values(VALUE obj)
struct enumerator *e = enumerator_ptr(obj);
VALUE vs;
+ rb_check_frozen(obj);
+
if (!UNDEF_P(e->lookahead)) {
vs = e->lookahead;
e->lookahead = Qundef;
@@ -940,9 +938,12 @@ enumerator_peek_values(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
if (UNDEF_P(e->lookahead)) {
- e->lookahead = get_next_values(obj, e);
+ RB_OBJ_WRITE(obj, &e->lookahead, get_next_values(obj, e));
}
+
return e->lookahead;
}
@@ -1064,10 +1065,12 @@ enumerator_feed(VALUE obj, VALUE v)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
if (!UNDEF_P(e->feedvalue)) {
rb_raise(rb_eTypeError, "feed value already set");
}
- e->feedvalue = v;
+ RB_OBJ_WRITE(obj, &e->feedvalue, v);
return Qnil;
}
@@ -1086,6 +1089,8 @@ enumerator_rewind(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
rb_check_funcall(e->obj, id_rewind, 0, 0);
e->fib = 0;
@@ -1098,6 +1103,7 @@ enumerator_rewind(VALUE obj)
static struct generator *generator_ptr(VALUE obj);
static VALUE append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args);
+static VALUE append_method_args(VALUE obj, VALUE str, VALUE default_args);
static VALUE
inspect_enumerator(VALUE obj, VALUE dummy, int recur)
@@ -1170,7 +1176,7 @@ kwd_append(VALUE key, VALUE val, VALUE str)
static VALUE
append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
{
- VALUE method, eargs;
+ VALUE method;
method = rb_attr_get(obj, id_method);
if (method != Qfalse) {
@@ -1184,6 +1190,13 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
rb_str_buf_cat2(str, ":");
rb_str_buf_append(str, method);
}
+ return append_method_args(obj, str, default_args);
+}
+
+static VALUE
+append_method_args(VALUE obj, VALUE str, VALUE default_args)
+{
+ VALUE eargs;
eargs = rb_attr_get(obj, id_arguments);
if (NIL_P(eargs)) {
@@ -1213,10 +1226,11 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
if (!NIL_P(kwds)) {
rb_hash_foreach(kwds, kwd_append, str);
}
- rb_str_set_len(str, RSTRING_LEN(str)-2);
+ rb_str_set_len(str, RSTRING_LEN(str)-2); /* drop the last ", " */
rb_str_buf_cat2(str, ")");
}
}
+ RB_GC_GUARD(eargs);
return str;
}
@@ -1243,6 +1257,24 @@ enumerator_inspect(VALUE obj)
* (1..100).to_a.permutation(4).size # => 94109400
* loop.size # => Float::INFINITY
* (1..100).drop_while.size # => nil
+ *
+ * Note that enumerator size might be inaccurate, and should be rather treated as a hint.
+ * For example, there is no check that the size provided to ::new is accurate:
+ *
+ * e = Enumerator.new(5) { |y| 2.times { y << it} }
+ * e.size # => 5
+ * e.to_a.size # => 2
+ *
+ * Another example is an enumerator created by ::produce without a +size+ argument.
+ * Such enumerators return +Infinity+ for size, but this is inaccurate if the passed
+ * block raises StopIteration:
+ *
+ * e = Enumerator.produce(1) { it + 1 }
+ * e.size # => Infinity
+ *
+ * e = Enumerator.produce(1) { it > 3 ? raise(StopIteration) : it + 1 }
+ * e.size # => Infinity
+ * e.to_a.size # => 4
*/
static VALUE
@@ -1286,36 +1318,21 @@ enumerator_size(VALUE obj)
* Yielder
*/
static void
-yielder_mark(void *p)
+yielder_mark_and_move(void *p)
{
struct yielder *ptr = p;
- rb_gc_mark_movable(ptr->proc);
-}
-
-static void
-yielder_compact(void *p)
-{
- struct yielder *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
-}
-
-#define yielder_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-yielder_memsize(const void *p)
-{
- return sizeof(struct yielder);
+ rb_gc_mark_and_move(&ptr->proc);
}
static const rb_data_type_t yielder_data_type = {
"yielder",
{
- yielder_mark,
- yielder_free,
- yielder_memsize,
- yielder_compact,
+ yielder_mark_and_move,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL,
+ yielder_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct yielder *
@@ -1354,7 +1371,7 @@ yielder_init(VALUE obj, VALUE proc)
rb_raise(rb_eArgError, "unallocated yielder");
}
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
return obj;
}
@@ -1424,38 +1441,22 @@ yielder_new(void)
* Generator
*/
static void
-generator_mark(void *p)
+generator_mark_and_move(void *p)
{
struct generator *ptr = p;
- rb_gc_mark_movable(ptr->proc);
- rb_gc_mark_movable(ptr->obj);
-}
-
-static void
-generator_compact(void *p)
-{
- struct generator *ptr = p;
- ptr->proc = rb_gc_location(ptr->proc);
- ptr->obj = rb_gc_location(ptr->obj);
-}
-
-#define generator_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-generator_memsize(const void *p)
-{
- return sizeof(struct generator);
+ rb_gc_mark_and_move(&ptr->proc);
+ rb_gc_mark_and_move(&ptr->obj);
}
static const rb_data_type_t generator_data_type = {
"generator",
{
- generator_mark,
- generator_free,
- generator_memsize,
- generator_compact,
+ generator_mark_and_move,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL,
+ generator_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct generator *
@@ -1495,7 +1496,7 @@ generator_init(VALUE obj, VALUE proc)
rb_raise(rb_eArgError, "unallocated generator");
}
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
return obj;
}
@@ -1543,7 +1544,7 @@ generator_init_copy(VALUE obj, VALUE orig)
rb_raise(rb_eArgError, "unallocated generator");
}
- ptr1->proc = ptr0->proc;
+ RB_OBJ_WRITE(obj, &ptr1->proc, ptr0->proc);
return obj;
}
@@ -1624,6 +1625,11 @@ lazy_init_block_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
#define LAZY_MEMO_SET_PACKED(memo) ((memo)->memo_flags |= LAZY_MEMO_PACKED)
#define LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)
+#define LAZY_NEED_BLOCK(func) \
+ if (!rb_block_given_p()) { \
+ rb_raise(rb_eArgError, "tried to call lazy " #func " without a block"); \
+ }
+
static VALUE lazy_yielder_result(struct MEMO *result, VALUE yielder, VALUE procs_array, VALUE memos, long i);
static VALUE
@@ -1634,7 +1640,7 @@ lazy_init_yielder(RB_BLOCK_CALL_FUNC_ARGLIST(_, m))
VALUE memos = rb_attr_get(yielder, id_memo);
struct MEMO *result;
- result = MEMO_NEW(m, rb_enum_values_pack(argc, argv),
+ result = rb_imemo_memo_new(m, rb_enum_values_pack(argc, argv),
argc > 1 ? LAZY_MEMO_PACKED : 0);
return lazy_yielder_result(result, yielder, procs_array, memos, 0);
}
@@ -1710,7 +1716,7 @@ lazy_generator_init(VALUE enumerator, VALUE procs)
lazy_init_block, rb_ary_new3(2, obj, procs));
gen_ptr = generator_ptr(generator);
- gen_ptr->obj = obj;
+ RB_OBJ_WRITE(generator, &gen_ptr->obj, obj);
return generator;
}
@@ -1827,9 +1833,7 @@ lazy_initialize(int argc, VALUE *argv, VALUE self)
VALUE generator;
rb_check_arity(argc, 1, 2);
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy new without a block");
- }
+ LAZY_NEED_BLOCK(new);
obj = argv[0];
if (argc > 1) {
size = argv[1];
@@ -1895,10 +1899,10 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
VALUE entry_obj = TypedData_Make_Struct(rb_cObject, struct proc_entry,
&proc_entry_data_type, entry);
if (rb_block_given_p()) {
- entry->proc = rb_block_proc();
+ RB_OBJ_WRITE(entry_obj, &entry->proc, rb_block_proc());
}
entry->fn = fn;
- entry->memo = args;
+ RB_OBJ_WRITE(entry_obj, &entry->memo, args);
lazy_set_args(entry_obj, memo);
@@ -1907,9 +1911,9 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
rb_ary_push(new_procs, entry_obj);
new_obj = enumerator_init_copy(enumerator_allocate(rb_cLazy), obj);
- new_e = DATA_PTR(new_obj);
- new_e->obj = new_generator;
- new_e->procs = new_procs;
+ new_e = RTYPEDDATA_GET_DATA(new_obj);
+ RB_OBJ_WRITE(new_obj, &new_e->obj, new_generator);
+ RB_OBJ_WRITE(new_obj, &new_e->procs, new_procs);
if (argc > 0) {
new_e->meth = rb_to_id(*argv++);
@@ -1918,7 +1922,9 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
else {
new_e->meth = id_each;
}
- new_e->args = rb_ary_new4(argc, argv);
+
+ RB_OBJ_WRITE(new_obj, &new_e->args, rb_ary_new4(argc, argv));
+
return new_obj;
}
@@ -2004,7 +2010,7 @@ lazy_to_enum(int argc, VALUE *argv, VALUE self)
}
lazy = lazy_to_enum_i(self, meth, argc, argv, 0, rb_keyword_given_p());
if (rb_block_given_p()) {
- enumerator_ptr(lazy)->size = rb_block_proc();
+ RB_OBJ_WRITE(lazy, &enumerator_ptr(lazy)->size, rb_block_proc());
}
return lazy;
}
@@ -2085,10 +2091,7 @@ static const lazyenum_funcs lazy_map_funcs = {
static VALUE
lazy_map(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy map without a block");
- }
-
+ LAZY_NEED_BLOCK(map);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_map_funcs);
}
@@ -2170,10 +2173,7 @@ static const lazyenum_funcs lazy_flat_map_funcs = {
static VALUE
lazy_flat_map(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy flat_map without a block");
- }
-
+ LAZY_NEED_BLOCK(flat_map);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_flat_map_funcs);
}
@@ -2200,10 +2200,7 @@ static const lazyenum_funcs lazy_select_funcs = {
static VALUE
lazy_select(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy select without a block");
- }
-
+ LAZY_NEED_BLOCK(select);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_select_funcs);
}
@@ -2234,10 +2231,7 @@ static const lazyenum_funcs lazy_filter_map_funcs = {
static VALUE
lazy_filter_map(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy filter_map without a block");
- }
-
+ LAZY_NEED_BLOCK(filter_map);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_filter_map_funcs);
}
@@ -2263,10 +2257,7 @@ static const lazyenum_funcs lazy_reject_funcs = {
static VALUE
lazy_reject(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy reject without a block");
- }
-
+ LAZY_NEED_BLOCK(reject);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_reject_funcs);
}
@@ -2390,7 +2381,6 @@ lazy_zip_arrays_func(VALUE proc_entry, struct MEMO *result, VALUE memos, long me
rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count));
}
LAZY_MEMO_SET_VALUE(result, ary);
- LAZY_MEMO_SET_PACKED(result);
rb_ary_store(memos, memo_index, LONG2NUM(++count));
return result;
}
@@ -2420,7 +2410,6 @@ lazy_zip_func(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_inde
rb_ary_push(ary, v);
}
LAZY_MEMO_SET_VALUE(result, ary);
- LAZY_MEMO_SET_PACKED(result);
return result;
}
@@ -2551,10 +2540,7 @@ static const lazyenum_funcs lazy_take_while_funcs = {
static VALUE
lazy_take_while(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy take_while without a block");
- }
-
+ LAZY_NEED_BLOCK(take_while);
return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_take_while_funcs);
}
@@ -2649,10 +2635,7 @@ static const lazyenum_funcs lazy_drop_while_funcs = {
static VALUE
lazy_drop_while(VALUE obj)
{
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "tried to call lazy drop_while without a block");
- }
-
+ LAZY_NEED_BLOCK(drop_while);
return lazy_add_method(obj, 0, 0, Qfalse, Qnil, &lazy_drop_while_funcs);
}
@@ -2797,6 +2780,52 @@ lazy_with_index(int argc, VALUE *argv, VALUE obj)
return lazy_add_method(obj, 0, 0, memo, rb_ary_new_from_values(1, &memo), &lazy_with_index_funcs);
}
+static struct MEMO *
+lazy_tap_each_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
+{
+ struct proc_entry *entry = proc_entry_ptr(proc_entry);
+
+ rb_proc_call_with_block(entry->proc, 1, &result->memo_value, Qnil);
+
+ return result;
+}
+
+static const lazyenum_funcs lazy_tap_each_funcs = {
+ lazy_tap_each_proc, 0,
+};
+
+/*
+ * call-seq:
+ * lazy.tap_each { |item| ... } -> lazy_enumerator
+ *
+ * Passes each element through to the block for side effects only,
+ * without modifying the element or affecting the enumeration.
+ * Returns a new lazy enumerator.
+ *
+ * This is useful for debugging or logging inside lazy chains,
+ * without breaking laziness or misusing +map+.
+ *
+ * (1..).lazy
+ * .tap_each { |x| puts "got #{x}" }
+ * .select(&:even?)
+ * .first(3)
+ * # prints: got 1, got 2, ..., got 6
+ * # returns: [2, 4, 6]
+ *
+ * Similar in intent to Java's Stream#peek.
+ */
+
+static VALUE
+lazy_tap_each(VALUE obj)
+{
+ if (!rb_block_given_p())
+ {
+ rb_raise(rb_eArgError, "tried to call lazy tap_each without a block");
+ }
+
+ return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_tap_each_funcs);
+}
+
#if 0 /* for RDoc */
/*
@@ -2934,19 +2963,12 @@ stop_result(VALUE self)
*/
static void
-producer_mark(void *p)
+producer_mark_and_move(void *p)
{
struct producer *ptr = p;
- rb_gc_mark_movable(ptr->init);
- rb_gc_mark_movable(ptr->proc);
-}
-
-static void
-producer_compact(void *p)
-{
- struct producer *ptr = p;
- ptr->init = rb_gc_location(ptr->init);
- ptr->proc = rb_gc_location(ptr->proc);
+ rb_gc_mark_and_move(&ptr->init);
+ rb_gc_mark_and_move(&ptr->proc);
+ rb_gc_mark_and_move(&ptr->size);
}
#define producer_free RUBY_TYPED_DEFAULT_FREE
@@ -2960,12 +2982,12 @@ producer_memsize(const void *p)
static const rb_data_type_t producer_data_type = {
"producer",
{
- producer_mark,
+ producer_mark_and_move,
producer_free,
producer_memsize,
- producer_compact,
+ producer_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct producer *
@@ -2990,12 +3012,13 @@ producer_allocate(VALUE klass)
obj = TypedData_Make_Struct(klass, struct producer, &producer_data_type, ptr);
ptr->init = Qundef;
ptr->proc = Qundef;
+ ptr->size = Qnil;
return obj;
}
static VALUE
-producer_init(VALUE obj, VALUE init, VALUE proc)
+producer_init(VALUE obj, VALUE init, VALUE proc, VALUE size)
{
struct producer *ptr;
@@ -3005,8 +3028,9 @@ producer_init(VALUE obj, VALUE init, VALUE proc)
rb_raise(rb_eArgError, "unallocated producer");
}
- ptr->init = init;
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->init, init);
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
+ RB_OBJ_WRITE(obj, &ptr->size, size);
return obj;
}
@@ -3057,12 +3081,18 @@ producer_each(VALUE obj)
static VALUE
producer_size(VALUE obj, VALUE args, VALUE eobj)
{
- return DBL2NUM(HUGE_VAL);
+ struct producer *ptr = producer_ptr(obj);
+ VALUE size = ptr->size;
+
+ if (NIL_P(size)) return Qnil;
+ if (RB_INTEGER_TYPE_P(size) || RB_FLOAT_TYPE_P(size)) return size;
+
+ return rb_funcall(size, id_call, 0);
}
/*
* call-seq:
- * Enumerator.produce(initial = nil) { |prev| block } -> enumerator
+ * Enumerator.produce(initial = nil, size: nil) { |prev| block } -> enumerator
*
* Creates an infinite enumerator from any block, just called over and
* over. The result of the previous iteration is passed to the next one.
@@ -3094,19 +3124,50 @@ producer_size(VALUE obj, VALUE args, VALUE eobj)
* PATTERN = %r{\d+|[-/+*]}
* Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
* # => ["7", "+", "38", "/", "6"]
+ *
+ * The optional +size+ keyword argument specifies the size of the enumerator,
+ * which can be retrieved by Enumerator#size. It can be an integer,
+ * +Float::INFINITY+, a callable object (such as a lambda), or +nil+ to
+ * indicate unknown size. When not specified, the size defaults to
+ * +Float::INFINITY+.
+ *
+ * # Infinite enumerator
+ * enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
+ * enum.size # => Float::INFINITY
+ *
+ * # Finite enumerator with known/computable size
+ * abs_dir = File.expand_path("./baz") # => "/foo/bar/baz"
+ * traverser = Enumerator.produce(abs_dir, size: -> { abs_dir.count("/") + 1 }) {
+ * raise StopIteration if it == "/"
+ * File.dirname(it)
+ * }
+ * traverser.size # => 4
+ *
+ * # Finite enumerator with unknown size
+ * calendar = Enumerator.produce(Date.today, size: nil) {
+ * it.monday? ? raise(StopIteration) : it + 1
+ * }
+ * calendar.size # => nil
*/
static VALUE
enumerator_s_produce(int argc, VALUE *argv, VALUE klass)
{
- VALUE init, producer;
+ VALUE init, producer, opts, size;
+ ID keyword_ids[1];
if (!rb_block_given_p()) rb_raise(rb_eArgError, "no block given");
- if (rb_scan_args(argc, argv, "01", &init) == 0) {
+ keyword_ids[0] = rb_intern("size");
+ rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS, argc, argv, "01:", &init, &opts);
+ rb_get_kwargs(opts, keyword_ids, 0, 1, &size);
+
+ size = UNDEF_P(size) ? DBL2NUM(HUGE_VAL) : convert_to_feasible_size_value(size);
+
+ if (argc == 0 || (argc == 1 && !NIL_P(opts))) {
init = Qundef;
}
- producer = producer_init(producer_allocate(rb_cEnumProducer), init, rb_block_proc());
+ producer = producer_init(producer_allocate(rb_cEnumProducer), init, rb_block_proc(), size);
return rb_enumeratorize_with_size_kw(producer, sym_each, 0, 0, producer_size, RB_NO_KEYWORDS);
}
@@ -3122,17 +3183,10 @@ enumerator_s_produce(int argc, VALUE *argv, VALUE klass)
*/
static void
-enum_chain_mark(void *p)
+enum_chain_mark_and_move(void *p)
{
struct enum_chain *ptr = p;
- rb_gc_mark_movable(ptr->enums);
-}
-
-static void
-enum_chain_compact(void *p)
-{
- struct enum_chain *ptr = p;
- ptr->enums = rb_gc_location(ptr->enums);
+ rb_gc_mark_and_move(&ptr->enums);
}
#define enum_chain_free RUBY_TYPED_DEFAULT_FREE
@@ -3146,12 +3200,12 @@ enum_chain_memsize(const void *p)
static const rb_data_type_t enum_chain_data_type = {
"chain",
{
- enum_chain_mark,
+ enum_chain_mark_and_move,
enum_chain_free,
enum_chain_memsize,
- enum_chain_compact,
+ enum_chain_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static struct enum_chain *
@@ -3201,7 +3255,7 @@ enum_chain_initialize(VALUE obj, VALUE enums)
if (!ptr) rb_raise(rb_eArgError, "unallocated chain");
- ptr->enums = rb_obj_freeze(enums);
+ RB_OBJ_WRITE(obj, &ptr->enums, rb_ary_freeze(enums));
ptr->pos = -1;
return obj;
@@ -3235,7 +3289,7 @@ enum_chain_init_copy(VALUE obj, VALUE orig)
if (!ptr1) rb_raise(rb_eArgError, "unallocated chain");
- ptr1->enums = ptr0->enums;
+ RB_OBJ_WRITE(obj, &ptr1->enums, ptr0->enums);
ptr1->pos = ptr0->pos;
return obj;
@@ -3444,17 +3498,10 @@ enumerator_plus(VALUE obj, VALUE eobj)
*/
static void
-enum_product_mark(void *p)
-{
- struct enum_product *ptr = p;
- rb_gc_mark_movable(ptr->enums);
-}
-
-static void
-enum_product_compact(void *p)
+enum_product_mark_and_move(void *p)
{
struct enum_product *ptr = p;
- ptr->enums = rb_gc_location(ptr->enums);
+ rb_gc_mark_and_move(&ptr->enums);
}
#define enum_product_free RUBY_TYPED_DEFAULT_FREE
@@ -3468,12 +3515,12 @@ enum_product_memsize(const void *p)
static const rb_data_type_t enum_product_data_type = {
"product",
{
- enum_product_mark,
+ enum_product_mark_and_move,
enum_product_free,
enum_product_memsize,
- enum_product_compact,
+ enum_product_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static struct enum_product *
@@ -3529,7 +3576,7 @@ enum_product_initialize(int argc, VALUE *argv, VALUE obj)
if (!ptr) rb_raise(rb_eArgError, "unallocated product");
- ptr->enums = rb_obj_freeze(enums);
+ RB_OBJ_WRITE(obj, &ptr->enums, rb_ary_freeze(enums));
return obj;
}
@@ -3547,7 +3594,7 @@ enum_product_init_copy(VALUE obj, VALUE orig)
if (!ptr1) rb_raise(rb_eArgError, "unallocated product");
- ptr1->enums = ptr0->enums;
+ RB_OBJ_WRITE(obj, &ptr1->enums, ptr0->enums);
return obj;
}
@@ -3556,10 +3603,19 @@ static VALUE
enum_product_total_size(VALUE enums)
{
VALUE total = INT2FIX(1);
+ VALUE sizes = rb_ary_hidden_new(RARRAY_LEN(enums));
long i;
for (i = 0; i < RARRAY_LEN(enums); i++) {
VALUE size = enum_size(RARRAY_AREF(enums, i));
+ if (size == INT2FIX(0)) {
+ rb_ary_resize(sizes, 0);
+ return size;
+ }
+ rb_ary_push(sizes, size);
+ }
+ for (i = 0; i < RARRAY_LEN(sizes); i++) {
+ VALUE size = RARRAY_AREF(sizes, i);
if (NIL_P(size) || (RB_TYPE_P(size, T_FLOAT) && isinf(NUM2DBL(size)))) {
return size;
@@ -3598,9 +3654,9 @@ enum_product_enum_size(VALUE obj, VALUE args, VALUE eobj)
struct product_state {
VALUE obj;
VALUE block;
+ int index;
int argc;
VALUE *argv;
- int index;
};
static VALUE product_each(VALUE, struct product_state *);
@@ -3639,15 +3695,23 @@ enum_product_run(VALUE obj, VALUE block)
{
struct enum_product *ptr = enum_product_ptr(obj);
int argc = RARRAY_LENINT(ptr->enums);
+ if (argc == 0) { /* no need to allocate state.argv */
+ rb_funcall(block, id_call, 1, rb_ary_new());
+ return obj;
+ }
+
+ VALUE argsbuf = 0;
struct product_state state = {
.obj = obj,
.block = block,
.index = 0,
.argc = argc,
- .argv = ALLOCA_N(VALUE, argc),
+ .argv = ALLOCV_N(VALUE, argsbuf, argc),
};
- return product_each(obj, &state);
+ VALUE ret = product_each(obj, &state);
+ ALLOCV_END(argsbuf);
+ return ret;
}
/*
@@ -3760,6 +3824,55 @@ enumerator_s_product(int argc, VALUE *argv, VALUE klass)
return obj;
}
+struct arith_seq {
+ struct enumerator enumerator;
+ VALUE begin;
+ VALUE end;
+ VALUE step;
+ bool exclude_end;
+};
+
+RUBY_REFERENCES(arith_seq_refs) = {
+ RUBY_REF_EDGE(struct enumerator, obj),
+ RUBY_REF_EDGE(struct enumerator, args),
+ RUBY_REF_EDGE(struct enumerator, fib),
+ RUBY_REF_EDGE(struct enumerator, dst),
+ RUBY_REF_EDGE(struct enumerator, lookahead),
+ RUBY_REF_EDGE(struct enumerator, feedvalue),
+ RUBY_REF_EDGE(struct enumerator, stop_exc),
+ RUBY_REF_EDGE(struct enumerator, size),
+ RUBY_REF_EDGE(struct enumerator, procs),
+
+ RUBY_REF_EDGE(struct arith_seq, begin),
+ RUBY_REF_EDGE(struct arith_seq, end),
+ RUBY_REF_EDGE(struct arith_seq, step),
+ RUBY_REF_END
+};
+
+static const rb_data_type_t arith_seq_data_type = {
+ "arithmetic_sequence",
+ {
+ RUBY_REFS_LIST_PTR(arith_seq_refs),
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ NULL,
+ },
+ .parent = &enumerator_data_type,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
+};
+
+static VALUE
+arith_seq_allocate(VALUE klass)
+{
+ struct arith_seq *ptr;
+ VALUE enum_obj;
+
+ enum_obj = TypedData_Make_Struct(klass, struct arith_seq, &arith_seq_data_type, ptr);
+ ptr->enumerator.obj = Qundef;
+
+ return enum_obj;
+}
+
/*
* Document-class: Enumerator::ArithmeticSequence
*
@@ -3777,12 +3890,16 @@ rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
rb_enumerator_size_func *size_fn,
VALUE beg, VALUE end, VALUE step, int excl)
{
- VALUE aseq = enumerator_init(enumerator_allocate(rb_cArithSeq),
+ VALUE aseq = enumerator_init(arith_seq_allocate(rb_cArithSeq),
obj, meth, argc, argv, size_fn, Qnil, rb_keyword_given_p());
- rb_ivar_set(aseq, id_begin, beg);
- rb_ivar_set(aseq, id_end, end);
- rb_ivar_set(aseq, id_step, step);
- rb_ivar_set(aseq, id_exclude_end, RBOOL(excl));
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(aseq, struct arith_seq, &enumerator_data_type, ptr);
+
+ RB_OBJ_WRITE(aseq, &ptr->begin, beg);
+ RB_OBJ_WRITE(aseq, &ptr->end, end);
+ RB_OBJ_WRITE(aseq, &ptr->step, step);
+ ptr->exclude_end = excl;
+
return aseq;
}
@@ -3795,7 +3912,9 @@ rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
static inline VALUE
arith_seq_begin(VALUE self)
{
- return rb_ivar_get(self, id_begin);
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(self, struct arith_seq, &enumerator_data_type, ptr);
+ return ptr->begin;
}
/*
@@ -3806,7 +3925,9 @@ arith_seq_begin(VALUE self)
static inline VALUE
arith_seq_end(VALUE self)
{
- return rb_ivar_get(self, id_end);
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(self, struct arith_seq, &enumerator_data_type, ptr);
+ return ptr->end;
}
/*
@@ -3818,7 +3939,9 @@ arith_seq_end(VALUE self)
static inline VALUE
arith_seq_step(VALUE self)
{
- return rb_ivar_get(self, id_step);
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(self, struct arith_seq, &enumerator_data_type, ptr);
+ return ptr->step;
}
/*
@@ -3829,13 +3952,17 @@ arith_seq_step(VALUE self)
static inline VALUE
arith_seq_exclude_end(VALUE self)
{
- return rb_ivar_get(self, id_exclude_end);
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(self, struct arith_seq, &enumerator_data_type, ptr);
+ return RBOOL(ptr->exclude_end);
}
static inline int
arith_seq_exclude_end_p(VALUE self)
{
- return RTEST(arith_seq_exclude_end(self));
+ struct arith_seq *ptr;
+ TypedData_Get_Struct(self, struct arith_seq, &enumerator_data_type, ptr);
+ return ptr->exclude_end;
}
int
@@ -3902,46 +4029,14 @@ rb_arithmetic_sequence_beg_len_step(VALUE obj, long *begp, long *lenp, long *ste
return Qnil;
}
-/*
- * call-seq:
- * aseq.first -> num or nil
- * aseq.first(n) -> an_array
- *
- * Returns the first number in this arithmetic sequence,
- * or an array of the first +n+ elements.
- */
static VALUE
-arith_seq_first(int argc, VALUE *argv, VALUE self)
+arith_seq_take(VALUE self, VALUE num)
{
VALUE b, e, s, ary;
long n;
int x;
- rb_check_arity(argc, 0, 1);
-
- b = arith_seq_begin(self);
- e = arith_seq_end(self);
- s = arith_seq_step(self);
- if (argc == 0) {
- if (NIL_P(b)) {
- return Qnil;
- }
- if (!NIL_P(e)) {
- VALUE zero = INT2FIX(0);
- int r = rb_cmpint(rb_num_coerce_cmp(s, zero, idCmp), s, zero);
- if (r > 0 && RTEST(rb_funcall(b, '>', 1, e))) {
- return Qnil;
- }
- if (r < 0 && RTEST(rb_funcall(b, '<', 1, e))) {
- return Qnil;
- }
- }
- return b;
- }
-
- // TODO: the following code should be extracted as arith_seq_take
-
- n = NUM2LONG(argv[0]);
+ n = NUM2LONG(num);
if (n < 0) {
rb_raise(rb_eArgError, "attempt to take negative size");
}
@@ -3949,6 +4044,9 @@ arith_seq_first(int argc, VALUE *argv, VALUE self)
return rb_ary_new_capa(0);
}
+ b = arith_seq_begin(self);
+ e = arith_seq_end(self);
+ s = arith_seq_step(self);
x = arith_seq_exclude_end_p(self);
if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(s)) {
@@ -3983,7 +4081,7 @@ arith_seq_first(int argc, VALUE *argv, VALUE self)
ary = rb_ary_new_capa((n < len) ? n : len);
while (n > 0 && i < end) {
rb_ary_push(ary, LONG2FIX(i));
- if (i + unit < i) break;
+ if (i > LONG_MAX - unit) break;
i += unit;
--n;
}
@@ -3996,7 +4094,7 @@ arith_seq_first(int argc, VALUE *argv, VALUE self)
ary = rb_ary_new_capa((n < len) ? n : len);
while (n > 0 && i > end) {
rb_ary_push(ary, LONG2FIX(i));
- if (i + unit > i) break;
+ if (i < LONG_MIN - unit) break;
i += unit;
--n;
}
@@ -4043,7 +4141,49 @@ arith_seq_first(int argc, VALUE *argv, VALUE self)
return ary;
}
- return rb_call_super(argc, argv);
+ {
+ VALUE argv[1];
+ argv[0] = num;
+ return rb_call_super(1, argv);
+ }
+}
+
+/*
+ * call-seq:
+ * aseq.first -> num or nil
+ * aseq.first(n) -> an_array
+ *
+ * Returns the first number in this arithmetic sequence,
+ * or an array of the first +n+ elements.
+ */
+static VALUE
+arith_seq_first(int argc, VALUE *argv, VALUE self)
+{
+ VALUE b, e, s;
+
+ rb_check_arity(argc, 0, 1);
+
+ b = arith_seq_begin(self);
+ e = arith_seq_end(self);
+ s = arith_seq_step(self);
+ if (argc == 0) {
+ if (NIL_P(b)) {
+ return Qnil;
+ }
+ if (!NIL_P(e)) {
+ VALUE zero = INT2FIX(0);
+ int r = rb_cmpint(rb_num_coerce_cmp(s, zero, idCmp), s, zero);
+ if (r > 0 && RTEST(rb_funcall(b, '>', 1, e))) {
+ return Qnil;
+ }
+ if (r < 0 && RTEST(rb_funcall(b, '<', 1, e))) {
+ return Qnil;
+ }
+ }
+ return b;
+ }
+
+ return arith_seq_take(self, argv[0]);
}
static inline VALUE
@@ -4209,7 +4349,7 @@ static VALUE
arith_seq_inspect(VALUE self)
{
struct enumerator *e;
- VALUE eobj, str, eargs;
+ VALUE eobj, str;
int range_p;
TypedData_Get_Struct(self, struct enumerator, &enumerator_data_type, e);
@@ -4223,39 +4363,7 @@ arith_seq_inspect(VALUE self)
str = rb_sprintf("(%s%"PRIsVALUE"%s.", range_p ? "(" : "", eobj, range_p ? ")" : "");
rb_str_buf_append(str, rb_id2str(e->meth));
-
- eargs = rb_attr_get(eobj, id_arguments);
- if (NIL_P(eargs)) {
- eargs = e->args;
- }
- if (eargs != Qfalse) {
- long argc = RARRAY_LEN(eargs);
- const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */
-
- if (argc > 0) {
- VALUE kwds = Qnil;
-
- rb_str_buf_cat2(str, "(");
-
- if (RB_TYPE_P(argv[argc-1], T_HASH)) {
- int all_key = TRUE;
- rb_hash_foreach(argv[argc-1], key_symbol_p, (VALUE)&all_key);
- if (all_key) kwds = argv[--argc];
- }
-
- while (argc--) {
- VALUE arg = *argv++;
-
- rb_str_append(str, rb_inspect(arg));
- rb_str_buf_cat2(str, ", ");
- }
- if (!NIL_P(kwds)) {
- rb_hash_foreach(kwds, kwd_append, str);
- }
- rb_str_set_len(str, RSTRING_LEN(str)-2); /* drop the last ", " */
- rb_str_buf_cat2(str, ")");
- }
- }
+ append_method_args(eobj, str, e->args);
rb_str_buf_cat2(str, ")");
@@ -4561,6 +4669,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cLazy, "uniq", lazy_uniq, 0);
rb_define_method(rb_cLazy, "compact", lazy_compact, 0);
rb_define_method(rb_cLazy, "with_index", lazy_with_index, -1);
+ rb_define_method(rb_cLazy, "tap_each", lazy_tap_each, 0);
lazy_use_super_method = rb_hash_new_with_size(18);
rb_hash_aset(lazy_use_super_method, sym("map"), sym("_enumerable_map"));
@@ -4582,7 +4691,7 @@ InitVM_Enumerator(void)
rb_hash_aset(lazy_use_super_method, sym("uniq"), sym("_enumerable_uniq"));
rb_hash_aset(lazy_use_super_method, sym("with_index"), sym("_enumerable_with_index"));
rb_obj_freeze(lazy_use_super_method);
- rb_gc_register_mark_object(lazy_use_super_method);
+ rb_vm_register_global_object(lazy_use_super_method);
#if 0 /* for RDoc */
rb_define_method(rb_cLazy, "to_a", lazy_to_a, 0);
@@ -4597,7 +4706,7 @@ InitVM_Enumerator(void)
rb_eStopIteration = rb_define_class("StopIteration", rb_eIndexError);
rb_define_method(rb_eStopIteration, "result", stop_result, 0);
- /* Generator */
+ /* :nodoc: Generator */
rb_cGenerator = rb_define_class_under(rb_cEnumerator, "Generator", rb_cObject);
rb_include_module(rb_cGenerator, rb_mEnumerable);
rb_define_alloc_func(rb_cGenerator, generator_allocate);
@@ -4605,7 +4714,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cGenerator, "initialize_copy", generator_init_copy, 1);
rb_define_method(rb_cGenerator, "each", generator_each, -1);
- /* Yielder */
+ /* :nodoc: Yielder */
rb_cYielder = rb_define_class_under(rb_cEnumerator, "Yielder", rb_cObject);
rb_define_alloc_func(rb_cYielder, yielder_allocate);
rb_define_method(rb_cYielder, "initialize", yielder_initialize, 0);
@@ -4613,7 +4722,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cYielder, "<<", yielder_yield_push, 1);
rb_define_method(rb_cYielder, "to_proc", yielder_to_proc, 0);
- /* Producer */
+ /* :nodoc: Producer */
rb_cEnumProducer = rb_define_class_under(rb_cEnumerator, "Producer", rb_cObject);
rb_define_alloc_func(rb_cEnumProducer, producer_allocate);
rb_define_method(rb_cEnumProducer, "each", producer_each, 0);
@@ -4676,7 +4785,6 @@ void
Init_Enumerator(void)
{
id_rewind = rb_intern_const("rewind");
- id_new = rb_intern_const("new");
id_next = rb_intern_const("next");
id_result = rb_intern_const("result");
id_receiver = rb_intern_const("receiver");
@@ -4686,12 +4794,7 @@ Init_Enumerator(void)
id_force = rb_intern_const("force");
id_to_enum = rb_intern_const("to_enum");
id_each_entry = rb_intern_const("each_entry");
- id_begin = rb_intern_const("begin");
- id_end = rb_intern_const("end");
- id_step = rb_intern_const("step");
- id_exclude_end = rb_intern_const("exclude_end");
sym_each = ID2SYM(id_each);
- sym_cycle = ID2SYM(rb_intern_const("cycle"));
sym_yield = ID2SYM(rb_intern_const("yield"));
InitVM(Enumerator);
diff --git a/error.c b/error.c
index 3b1a80755c..7a08fd2b9e 100644
--- a/error.c
+++ b/error.c
@@ -23,25 +23,34 @@
# include <unistd.h>
#endif
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
#if defined __APPLE__
# include <AvailabilityMacros.h>
#endif
#include "internal.h"
+#include "internal/class.h"
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/hash.h"
#include "internal/io.h"
#include "internal/load.h"
#include "internal/object.h"
+#include "internal/process.h"
#include "internal/string.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "ruby/encoding.h"
#include "ruby/st.h"
+#include "ruby/util.h"
#include "ruby_assert.h"
#include "vm_core.h"
+#include "yjit.h"
+#include "zjit.h"
#include "builtin.h"
@@ -77,6 +86,8 @@ static ID id_warn;
static ID id_category;
static ID id_deprecated;
static ID id_experimental;
+static ID id_performance;
+static ID id_strict_unused_block;
static VALUE sym_category;
static VALUE sym_highlight;
static struct {
@@ -148,8 +159,8 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column,
}
static unsigned int warning_disabled_categories = (
- 1U << RB_WARN_CATEGORY_DEPRECATED |
- 0);
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ ~RB_WARN_CATEGORY_DEFAULT_BITS);
static unsigned int
rb_warning_category_mask(VALUE category)
@@ -200,14 +211,18 @@ rb_warning_category_enabled_p(rb_warning_category_t category)
* Returns the flag to show the warning messages for +category+.
* Supported categories are:
*
- * +:deprecated+ :: deprecation warnings
- * * assignment of non-nil value to <code>$,</code> and <code>$;</code>
- * * keyword arguments
- * * proc/lambda without block
- * etc.
+ * +:deprecated+ ::
+ * deprecation warnings
+ * * assignment of non-nil value to <code>$,</code> and <code>$;</code>
+ * * keyword arguments
+ * etc.
+ *
+ * +:experimental+ ::
+ * experimental features
*
- * +:experimental+ :: experimental features
- * * Pattern matching
+ * +:performance+ ::
+ * performance hints
+ * * Shape variation limit
*/
static VALUE
@@ -240,6 +255,26 @@ rb_warning_s_aset(VALUE mod, VALUE category, VALUE flag)
/*
* call-seq:
+ * categories -> array
+ *
+ * Returns a list of the supported category symbols.
+ */
+
+static VALUE
+rb_warning_s_categories(VALUE mod)
+{
+ st_index_t num = warning_categories.id2enum->num_entries;
+ ID *ids = ALLOCA_N(ID, num);
+ num = st_keys(warning_categories.id2enum, ids, num);
+ VALUE ary = rb_ary_new_capa(num);
+ for (st_index_t i = 0; i < num; ++i) {
+ rb_ary_push(ary, ID2SYM(ids[i]));
+ }
+ return rb_ary_freeze(ary);
+}
+
+/*
+ * call-seq:
* warn(msg, category: nil) -> nil
*
* Writes warning message +msg+ to $stderr. This method is called by
@@ -279,11 +314,11 @@ rb_warning_s_warn(int argc, VALUE *argv, VALUE mod)
*
* Changing the behavior of Warning.warn is useful to customize how warnings are
* handled by Ruby, for instance by filtering some warnings, and/or outputting
- * warnings somewhere other than $stderr.
+ * warnings somewhere other than <tt>$stderr</tt>.
*
* If you want to change the behavior of Warning.warn you should use
- * +Warning.extend(MyNewModuleWithWarnMethod)+ and you can use `super`
- * to get the default behavior of printing the warning to $stderr.
+ * <tt>Warning.extend(MyNewModuleWithWarnMethod)</tt> and you can use +super+
+ * to get the default behavior of printing the warning to <tt>$stderr</tt>.
*
* Example:
* module MyWarningFilter
@@ -300,7 +335,7 @@ rb_warning_s_warn(int argc, VALUE *argv, VALUE mod)
* You should never redefine Warning#warn (the instance method), as that will
* then no longer provide a way to use the default behavior.
*
- * The +warning+ gem provides convenient ways to customize Warning.warn.
+ * The warning[https://rubygems.org/gems/warning] gem provides convenient ways to customize Warning.warn.
*/
static VALUE
@@ -352,18 +387,28 @@ warn_vsprintf(rb_encoding *enc, const char *file, int line, const char *fmt, va_
return rb_str_cat2(str, "\n");
}
-#define with_warn_vsprintf(file, line, fmt) \
+#define with_warn_vsprintf(enc, file, line, fmt) \
VALUE str; \
va_list args; \
va_start(args, fmt); \
- str = warn_vsprintf(NULL, file, line, fmt, args); \
+ str = warn_vsprintf(enc, file, line, fmt, args); \
va_end(args);
void
rb_compile_warn(const char *file, int line, const char *fmt, ...)
{
if (!NIL_P(ruby_verbose)) {
- with_warn_vsprintf(file, line, fmt) {
+ with_warn_vsprintf(NULL, file, line, fmt) {
+ rb_write_warning_str(str);
+ }
+ }
+}
+
+void
+rb_enc_compile_warn(rb_encoding *enc, const char *file, int line, const char *fmt, ...)
+{
+ if (!NIL_P(ruby_verbose)) {
+ with_warn_vsprintf(enc, file, line, fmt) {
rb_write_warning_str(str);
}
}
@@ -374,7 +419,18 @@ void
rb_compile_warning(const char *file, int line, const char *fmt, ...)
{
if (RTEST(ruby_verbose)) {
- with_warn_vsprintf(file, line, fmt) {
+ with_warn_vsprintf(NULL, file, line, fmt) {
+ rb_write_warning_str(str);
+ }
+ }
+}
+
+/* rb_enc_compile_warning() reports only in verbose mode */
+void
+rb_enc_compile_warning(rb_encoding *enc, const char *file, int line, const char *fmt, ...)
+{
+ if (RTEST(ruby_verbose)) {
+ with_warn_vsprintf(enc, file, line, fmt) {
rb_write_warning_str(str);
}
}
@@ -384,7 +440,7 @@ void
rb_category_compile_warn(rb_warning_category_t category, const char *file, int line, const char *fmt, ...)
{
if (!NIL_P(ruby_verbose)) {
- with_warn_vsprintf(file, line, fmt) {
+ with_warn_vsprintf(NULL, file, line, fmt) {
rb_warn_category(str, rb_warning_category_to_name(category));
}
}
@@ -420,7 +476,7 @@ rb_warn(const char *fmt, ...)
void
rb_category_warn(rb_warning_category_t category, const char *fmt, ...)
{
- if (!NIL_P(ruby_verbose)) {
+ if (!NIL_P(ruby_verbose) && rb_warning_category_enabled_p(category)) {
with_warning_string(mesg, 0, fmt) {
rb_warn_category(mesg, rb_warning_category_to_name(category));
}
@@ -452,7 +508,7 @@ rb_warning(const char *fmt, ...)
void
rb_category_warning(rb_warning_category_t category, const char *fmt, ...)
{
- if (RTEST(ruby_verbose)) {
+ if (RTEST(ruby_verbose) && rb_warning_category_enabled_p(category)) {
with_warning_string(mesg, 0, fmt) {
rb_warn_category(mesg, rb_warning_category_to_name(category));
}
@@ -520,6 +576,18 @@ rb_warn_deprecated_to_remove(const char *removal, const char *fmt, const char *s
}
}
+void
+rb_warn_reserved_name(const char *coming, const char *fmt, ...)
+{
+ if (!deprecation_warning_enabled()) return;
+
+ with_warning_string_from(mesg, 0, fmt, fmt) {
+ rb_str_set_len(mesg, RSTRING_LEN(mesg) - 1);
+ rb_str_catf(mesg, " is reserved for Ruby %s\n", coming);
+ rb_warn_category(mesg, ID2SYM(id_deprecated));
+ }
+}
+
static inline int
end_with_asciichar(VALUE str, int c)
{
@@ -616,18 +684,243 @@ rb_bug_reporter_add(void (*func)(FILE *, void *), void *data)
return 1;
}
+/* returns true if x can not be used as file name */
+static bool
+path_sep_p(char x)
+{
+#if defined __CYGWIN__ || defined DOSISH
+# define PATH_SEP_ENCODING 1
+ // Assume that "/" is only the first byte in any encoding.
+ if (x == ':') return true; // drive letter or ADS
+ if (x == '\\') return true;
+#endif
+ return x == '/';
+}
+
+struct path_string {
+ const char *ptr;
+ size_t len;
+};
+
+static const char PATHSEP_REPLACE = '!';
+
+static char *
+append_pathname(char *p, const char *pe, VALUE str)
+{
+#ifdef PATH_SEP_ENCODING
+ rb_encoding *enc = rb_enc_get(str);
+#endif
+ const char *s = RSTRING_PTR(str);
+ const char *const se = s + RSTRING_LEN(str);
+ char c;
+
+ --pe; // for terminator
+
+ while (p < pe && s < se && (c = *s) != '\0') {
+ if (c == '.') {
+ if (s == se || !*s) break; // chomp "." basename
+ if (path_sep_p(s[1])) goto skipsep; // skip "./"
+ }
+ else if (path_sep_p(c)) {
+ // squeeze successive separators
+ *p++ = PATHSEP_REPLACE;
+ skipsep:
+ while (++s < se && path_sep_p(*s));
+ continue;
+ }
+ const char *const ss = s;
+ while (p < pe && s < se && *s && !path_sep_p(*s)) {
+#ifdef PATH_SEP_ENCODING
+ int n = rb_enc_mbclen(s, se, enc);
+#else
+ const int n = 1;
+#endif
+ p += n;
+ s += n;
+ }
+ if (s > ss) memcpy(p - (s - ss), ss, s - ss);
+ }
+
+ return p;
+}
+
+static char *
+append_basename(char *p, const char *pe, struct path_string *path, VALUE str)
+{
+ if (!path->ptr) {
+#ifdef PATH_SEP_ENCODING
+ rb_encoding *enc = rb_enc_get(str);
+#endif
+ const char *const b = RSTRING_PTR(str), *const e = RSTRING_END(str), *p = e;
+
+ while (p > b) {
+ if (path_sep_p(p[-1])) {
+#ifdef PATH_SEP_ENCODING
+ const char *t = rb_enc_prev_char(b, p, e, enc);
+ if (t == p-1) break;
+ p = t;
+#else
+ break;
+#endif
+ }
+ else {
+ --p;
+ }
+ }
+
+ path->ptr = p;
+ path->len = e - p;
+ }
+ size_t n = path->len;
+ if (p + n > pe) n = pe - p;
+ memcpy(p, path->ptr, n);
+ return p + n;
+}
+
+static void
+finish_report(FILE *out, rb_pid_t pid)
+{
+ if (out != stdout && out != stderr) fclose(out);
+#ifdef HAVE_WORKING_FORK
+ if (pid > 0) waitpid(pid, NULL, 0);
+#endif
+}
+
+struct report_expansion {
+ struct path_string exe, script;
+ rb_pid_t pid;
+ time_t time;
+};
+
+/*
+ * Open a bug report file to write. The `RUBY_CRASH_REPORT`
+ * environment variable can be set to define a template that is used
+ * to name bug report files. The template can contain % specifiers
+ * which are substituted by the following values when a bug report
+ * file is created:
+ *
+ * %% A single % character.
+ * %e The base name of the executable filename.
+ * %E Pathname of executable, with slashes ('/') replaced by
+ * exclamation marks ('!').
+ * %f Similar to %e with the main script filename.
+ * %F Similar to %E with the main script filename.
+ * %p PID of dumped process in decimal.
+ * %t Time of dump, expressed as seconds since the Epoch,
+ * 1970-01-01 00:00:00 +0000 (UTC).
+ * %NNN Octal char code, upto 3 digits.
+ */
+static char *
+expand_report_argument(const char **input_template, struct report_expansion *values,
+ char *buf, size_t size, bool word)
+{
+ char *p = buf;
+ char *end = buf + size;
+ const char *template = *input_template;
+ bool store = true;
+
+ if (p >= end-1 || !*template) return NULL;
+ do {
+ char c = *template++;
+ if (word && ISSPACE(c)) break;
+ if (!store) continue;
+ if (c == '%') {
+ size_t n;
+ switch (c = *template++) {
+ case 'e':
+ p = append_basename(p, end, &values->exe, rb_argv0);
+ continue;
+ case 'E':
+ p = append_pathname(p, end, rb_argv0);
+ continue;
+ case 'f':
+ p = append_basename(p, end, &values->script, GET_VM()->orig_progname);
+ continue;
+ case 'F':
+ p = append_pathname(p, end, GET_VM()->orig_progname);
+ continue;
+ case 'p':
+ if (!values->pid) values->pid = getpid();
+ snprintf(p, end-p, "%" PRI_PIDT_PREFIX "d", values->pid);
+ p += strlen(p);
+ continue;
+ case 't':
+ if (!values->time) values->time = time(NULL);
+ snprintf(p, end-p, "%" PRI_TIMET_PREFIX "d", values->time);
+ p += strlen(p);
+ continue;
+ default:
+ if (c >= '0' && c <= '7') {
+ c = (unsigned char)ruby_scan_oct(template-1, 3, &n);
+ template += n - 1;
+ if (!c) store = false;
+ }
+ break;
+ }
+ }
+ if (p < end-1) *p++ = c;
+ } while (*template);
+ *input_template = template;
+ *p = '\0';
+ return ++p;
+}
+
+FILE *ruby_popen_writer(char *const *argv, rb_pid_t *pid);
+
+static FILE *
+open_report_path(const char *template, char *buf, size_t size, rb_pid_t *pid)
+{
+ struct report_expansion values = {{0}};
+
+ if (!template) return NULL;
+ if (0) fprintf(stderr, "RUBY_CRASH_REPORT=%s\n", buf);
+ if (*template == '|') {
+ char *argv[16], *bufend = buf + size, *p;
+ int argc;
+ template++;
+ for (argc = 0; argc < numberof(argv) - 1; ++argc) {
+ while (*template && ISSPACE(*template)) template++;
+ p = expand_report_argument(&template, &values, buf, bufend-buf, true);
+ if (!p) break;
+ argv[argc] = buf;
+ buf = p;
+ }
+ argv[argc] = NULL;
+ if (!p) return ruby_popen_writer(argv, pid);
+ }
+ else if (*template) {
+ expand_report_argument(&template, &values, buf, size, false);
+ return fopen(buf, "w");
+ }
+ return NULL;
+}
+
+static const char *crash_report;
+
/* SIGSEGV handler might have a very small stack. Thus we need to use it carefully. */
#define REPORT_BUG_BUFSIZ 256
static FILE *
-bug_report_file(const char *file, int line)
+bug_report_file(const char *file, int line, rb_pid_t *pid)
{
char buf[REPORT_BUG_BUFSIZ];
- FILE *out = stderr;
+ const char *report = crash_report;
+ if (!report) report = getenv("RUBY_CRASH_REPORT");
+ FILE *out = open_report_path(report, buf, sizeof(buf), pid);
int len = err_position_0(buf, sizeof(buf), file, line);
- if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len ||
- (ssize_t)fwrite(buf, 1, len, (out = stdout)) == (ssize_t)len) {
- return out;
+ if (out) {
+ /* Disable buffering so crash report output is not lost if
+ * rb_vm_bugreport() triggers a secondary crash (e.g. SIGSEGV
+ * while walking JIT frames). */
+ setvbuf(out, NULL, _IONBF, 0);
+ if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len) return out;
+ fclose(out);
+ }
+ if ((ssize_t)fwrite(buf, 1, len, stderr) == (ssize_t)len) {
+ return stderr;
+ }
+ if ((ssize_t)fwrite(buf, 1, len, stdout) == (ssize_t)len) {
+ return stdout;
}
return NULL;
@@ -734,7 +1027,7 @@ bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
} while (0)
static void
-bug_report_end(FILE *out)
+bug_report_end(FILE *out, rb_pid_t pid)
{
/* call additional bug reporters */
{
@@ -745,57 +1038,91 @@ bug_report_end(FILE *out)
}
}
postscript_dump(out);
+ finish_report(out, pid);
}
#define report_bug(file, line, fmt, ctx) do { \
- FILE *out = bug_report_file(file, line); \
+ rb_pid_t pid = -1; \
+ FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin(out, fmt); \
- rb_vm_bugreport(ctx); \
- bug_report_end(out); \
+ rb_vm_bugreport(ctx, out); \
+ bug_report_end(out, pid); \
} \
} while (0) \
#define report_bug_valist(file, line, fmt, ctx, args) do { \
- FILE *out = bug_report_file(file, line); \
+ rb_pid_t pid = -1; \
+ FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin_valist(out, fmt, args); \
- rb_vm_bugreport(ctx); \
- bug_report_end(out); \
+ rb_vm_bugreport(ctx, out); \
+ bug_report_end(out, pid); \
} \
} while (0) \
+void
+ruby_set_crash_report(const char *template)
+{
+ crash_report = template;
+#if RUBY_DEBUG
+ rb_pid_t pid = -1;
+ char buf[REPORT_BUG_BUFSIZ];
+ FILE *out = open_report_path(template, buf, sizeof(buf), &pid);
+ if (out) {
+ time_t t = time(NULL);
+ fprintf(out, "ruby_test_bug_report: %s", ctime(&t));
+ finish_report(out, pid);
+ }
+#endif
+}
+
NORETURN(static void die(void));
static void
die(void)
{
#if defined(_WIN32) && defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 80
+ /* mingw32 declares in stdlib.h but does not provide. */
_set_abort_behavior( 0, _CALL_REPORTFAULT);
#endif
+ /* Reset SIGABRT to default so that abort() does not trigger our custom
+ * handler (sigabrt), which would re-open the crash report file with "w"
+ * and truncate the report already written by rb_bug(). */
+ signal(SIGABRT, SIG_DFL);
abort();
}
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 0)
-void
-rb_bug_without_die(const char *fmt, va_list args)
+static void
+rb_bug_without_die_internal(const char *fmt, va_list args)
{
const char *file = NULL;
int line = 0;
- if (GET_EC()) {
+ if (rb_current_execution_context(false)) {
file = rb_source_location_cstr(&line);
}
report_bug_valist(file, line, fmt, NULL, args);
}
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 0)
+void
+rb_bug_without_die(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ rb_bug_without_die_internal(fmt, args);
+ va_end(args);
+}
+
void
rb_bug(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- rb_bug_without_die(fmt, args);
+ rb_bug_without_die_internal(fmt, args);
va_end(args);
die();
}
@@ -806,7 +1133,7 @@ rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const voi
const char *file = NULL;
int line = 0;
- if (GET_EC()) {
+ if (rb_current_execution_context(false)) {
file = rb_source_location_cstr(&line);
}
@@ -814,6 +1141,7 @@ rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const voi
if (default_sighandler) default_sighandler(sig);
+ ruby_default_signal(sig);
die();
}
@@ -870,13 +1198,34 @@ rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args)
void
rb_assert_failure(const char *file, int line, const char *name, const char *expr)
{
- FILE *out = stderr;
- fprintf(out, "Assertion Failed: %s:%d:", file, line);
- if (name) fprintf(out, "%s:", name);
- fprintf(out, "%s\n%s\n\n", expr, rb_dynamic_description);
- preface_dump(out);
- rb_vm_bugreport(NULL);
- bug_report_end(out);
+ rb_assert_failure_detail(file, line, name, expr, NULL);
+}
+
+void
+rb_assert_failure_detail(const char *file, int line, const char *name, const char *expr,
+ const char *fmt, ...)
+{
+ rb_pid_t pid = -1;
+ FILE *out = bug_report_file(file, line, &pid);
+ if (out) {
+ fputs("Assertion Failed: ", out);
+ if (name) fprintf(out, "%s:", name);
+ fputs(expr, out);
+
+ if (fmt && *fmt) {
+ va_list args;
+ va_start(args, fmt);
+ fputs(": ", out);
+ vfprintf(out, fmt, args);
+ va_end(args);
+ }
+ fprintf(out, "\n%s\n\n", rb_dynamic_description);
+
+ preface_dump(out);
+ rb_vm_bugreport(NULL, out);
+ bug_report_end(out, pid);
+ }
+
die();
}
@@ -973,6 +1322,20 @@ rb_builtin_class_name(VALUE x)
COLDFUNC NORETURN(static void unexpected_type(VALUE, int, int));
#define UNDEF_LEAKED "undef leaked to the Ruby space"
+void
+rb_unexpected_typeddata(const rb_data_type_t *actual, const rb_data_type_t *expected)
+{
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
+ actual->wrap_struct_name, expected->wrap_struct_name);
+}
+
+void
+rb_unexpected_object_type(VALUE obj, const char *expected)
+{
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected %s)",
+ displaying_class_of(obj), expected);
+}
+
static void
unexpected_type(VALUE x, int xt, int t)
{
@@ -980,9 +1343,7 @@ unexpected_type(VALUE x, int xt, int t)
VALUE mesg, exc = rb_eFatal;
if (tname) {
- mesg = rb_sprintf("wrong argument type %"PRIsVALUE" (expected %s)",
- displaying_class_of(x), tname);
- exc = rb_eTypeError;
+ rb_unexpected_object_type(x, tname);
}
else if (xt > T_MASK && xt <= 0x3f) {
mesg = rb_sprintf("unknown type 0x%x (0x%x given, probably comes"
@@ -1003,8 +1364,7 @@ rb_check_type(VALUE x, int t)
rb_bug(UNDEF_LEAKED);
}
- xt = TYPE(x);
- if (xt != t || (xt == T_DATA && rbimpl_rtypeddata_p(x))) {
+ if (t == T_DATA) {
/*
* Typed data is not simple `T_DATA`, but in a sense an
* extension of `struct RVALUE`, which are incompatible with
@@ -1013,6 +1373,10 @@ rb_check_type(VALUE x, int t)
* So it is not enough to just check `T_DATA`, it must be
* identified by its `type` using `Check_TypedStruct` instead.
*/
+ rb_unexpected_object_type(x, builtin_types[t]);
+ }
+ xt = TYPE(x);
+ if (xt != t) {
unexpected_type(x, xt, t);
}
}
@@ -1027,24 +1391,18 @@ rb_unexpected_type(VALUE x, int t)
unexpected_type(x, TYPE(x), t);
}
+#undef rb_typeddata_inherited_p
int
rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent)
{
- while (child) {
- if (child == parent) return 1;
- child = child->parent;
- }
- return 0;
+ return rbimpl_typeddata_inherited_p_inline(child, parent);
}
+#undef rb_typeddata_is_kind_of
int
rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
{
- if (!RB_TYPE_P(obj, T_DATA) ||
- !RTYPEDDATA_P(obj) || !rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type)) {
- return 0;
- }
- return 1;
+ return rbimpl_typeddata_is_kind_of_inline(obj, data_type);
}
#undef rb_typeddata_is_instance_of
@@ -1057,26 +1415,7 @@ rb_typeddata_is_instance_of(VALUE obj, const rb_data_type_t *data_type)
void *
rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
{
- VALUE actual;
-
- if (!RB_TYPE_P(obj, T_DATA)) {
- actual = displaying_class_of(obj);
- }
- else if (!RTYPEDDATA_P(obj)) {
- actual = displaying_class_of(obj);
- }
- else if (!rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type)) {
- const char *name = RTYPEDDATA_TYPE(obj)->wrap_struct_name;
- actual = rb_str_new_cstr(name); /* or rb_fstring_cstr? not sure... */
- }
- else {
- return DATA_PTR(obj);
- }
-
- const char *expected = data_type->wrap_struct_name;
- rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected %s)",
- actual, expected);
- UNREACHABLE_RETURN(NULL);
+ return rbimpl_check_typeddata(obj, data_type);
}
/* exception classes */
@@ -1141,6 +1480,7 @@ rb_exc_new_cstr(VALUE etype, const char *s)
VALUE
rb_exc_new_str(VALUE etype, VALUE str)
{
+ rb_yjit_lazy_push_frame(GET_EC()->cfp->pc);
StringValue(str);
return rb_class_new_instance(1, &str, etype);
}
@@ -1155,12 +1495,23 @@ exc_init(VALUE exc, VALUE mesg)
}
/*
- * call-seq:
- * Exception.new(msg = nil) -> exception
- * Exception.exception(msg = nil) -> exception
+ * call-seq:
+ * Exception.new(message = nil) -> exception
+ *
+ * Returns a new exception object.
+ *
+ * The given +message+ should be
+ * a {string-convertible object}[rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects];
+ * see method #message;
+ * if not given, the message is the class name of the new instance
+ * (which may be the name of a subclass):
+ *
+ * Examples:
+ *
+ * Exception.new # => #<Exception: Exception>
+ * LoadError.new # => #<LoadError: LoadError> # Subclass of Exception.
+ * Exception.new('Boom') # => #<Exception: Boom>
*
- * Construct a new Exception object, optionally passing in
- * a message.
*/
static VALUE
@@ -1176,12 +1527,24 @@ exc_initialize(int argc, VALUE *argv, VALUE exc)
* Document-method: exception
*
* call-seq:
- * exc.exception([string]) -> an_exception or exc
+ * exception(message = nil) -> self or new_exception
+ *
+ * Returns an exception object of the same class as +self+;
+ * useful for creating a similar exception, but with a different message.
*
- * With no argument, or if the argument is the same as the receiver,
- * return the receiver. Otherwise, create a new
- * exception object of the same class as the receiver, but with a
- * message equal to <code>string.to_str</code>.
+ * With +message+ +nil+, returns +self+:
+ *
+ * x0 = StandardError.new('Boom') # => #<StandardError: Boom>
+ * x1 = x0.exception # => #<StandardError: Boom>
+ * x0.equal?(x1) # => true
+ *
+ * With {string-convertible object}[rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects]
+ * +message+ (even the same as the original message),
+ * returns a new exception object whose class is the same as +self+,
+ * and whose message is the given +message+:
+ *
+ * x1 = x0.exception('Boom') # => #<StandardError: Boom>
+ * x0.equal?(x1) # => false
*
*/
@@ -1200,10 +1563,15 @@ exc_exception(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * exception.to_s -> string
+ * to_s -> string
+ *
+ * Returns a string representation of +self+:
+ *
+ * x = RuntimeError.new('Boom')
+ * x.to_s # => "Boom"
+ * x = RuntimeError.new
+ * x.to_s # => "RuntimeError"
*
- * Returns exception's message (or the name of the exception if
- * no message is set).
*/
static VALUE
@@ -1243,10 +1611,10 @@ rb_get_detailed_message(VALUE exc, VALUE opt)
}
/*
- * call-seq:
- * Exception.to_tty? -> true or false
+ * call-seq:
+ * Exception.to_tty? -> true or false
*
- * Returns +true+ if exception messages will be sent to a tty.
+ * Returns +true+ if exception messages will be sent to a terminal device.
*/
static VALUE
exc_s_to_tty_p(VALUE self)
@@ -1306,20 +1674,51 @@ check_order_keyword(VALUE opt)
/*
* call-seq:
- * exception.full_message(highlight: bool, order: [:top or :bottom]) -> string
+ * full_message(highlight: true, order: :top) -> string
+ *
+ * Returns an enhanced message string:
*
- * Returns formatted string of _exception_.
- * The returned string is formatted using the same format that Ruby uses
- * when printing an uncaught exceptions to stderr.
+ * - Includes the exception class name.
+ * - If the value of keyword +highlight+ is true (not +nil+ or +false+),
+ * includes bolding ANSI codes (see below) to enhance the appearance of the message.
+ * - Includes the {backtrace}[rdoc-ref:exceptions.md@Backtraces]:
*
- * If _highlight_ is +true+ the default error handler will send the
- * messages to a tty.
+ * - If the value of keyword +order+ is +:top+ (the default),
+ * lists the error message and the innermost backtrace entry first.
+ * - If the value of keyword +order+ is +:bottom+,
+ * lists the error message the innermost entry last.
*
- * _order_ must be either of +:top+ or +:bottom+, and places the error
- * message and the innermost backtrace come at the top or the bottom.
+ * Example:
*
- * The default values of these options depend on <code>$stderr</code>
- * and its +tty?+ at the timing of a call.
+ * def baz
+ * begin
+ * 1 / 0
+ * rescue => x
+ * pp x.message
+ * pp x.full_message(highlight: false).split("\n")
+ * pp x.full_message.split("\n")
+ * end
+ * end
+ * def bar; baz; end
+ * def foo; bar; end
+ * foo
+ *
+ * Output:
+ *
+ * "divided by 0"
+ * ["t.rb:3:in 'Integer#/': divided by 0 (ZeroDivisionError)",
+ * "\tfrom t.rb:3:in 'Object#baz'",
+ * "\tfrom t.rb:10:in 'Object#bar'",
+ * "\tfrom t.rb:11:in 'Object#foo'",
+ * "\tfrom t.rb:12:in '<main>'"]
+ * ["t.rb:3:in 'Integer#/': \e[1mdivided by 0 (\e[1;4mZeroDivisionError\e[m\e[1m)\e[m",
+ * "\tfrom t.rb:3:in 'Object#baz'",
+ * "\tfrom t.rb:10:in 'Object#bar'",
+ * "\tfrom t.rb:11:in 'Object#foo'",
+ * "\tfrom t.rb:12:in '<main>'"]
+ *
+ * An overriding method should be careful with ANSI code enhancements;
+ * see {Messages}[rdoc-ref:exceptions.md@Messages].
*/
static VALUE
@@ -1348,10 +1747,11 @@ exc_full_message(int argc, VALUE *argv, VALUE exc)
/*
* call-seq:
- * exception.message -> string
+ * message -> string
+ *
+ * Returns #to_s.
*
- * Returns the result of invoking <code>exception.to_s</code>.
- * Normally this returns the exception's message or name.
+ * See {Messages}[rdoc-ref:exceptions.md@Messages].
*/
static VALUE
@@ -1362,42 +1762,47 @@ exc_message(VALUE exc)
/*
* call-seq:
- * exception.detailed_message(highlight: bool, **opt) -> string
+ * detailed_message(highlight: false, **kwargs) -> string
*
- * Processes a string returned by #message.
+ * Returns the message string with enhancements:
*
- * It may add the class name of the exception to the end of the first line.
- * Also, when +highlight+ keyword is true, it adds ANSI escape sequences to
- * make the message bold.
+ * - Includes the exception class name in the first line.
+ * - If the value of keyword +highlight+ is +true+,
+ * includes bolding and underlining ANSI codes (see below)
+ * to enhance the appearance of the message.
*
- * If you override this method, it must be tolerant for unknown keyword
- * arguments. All keyword arguments passed to #full_message are delegated
- * to this method.
+ * Examples:
*
- * This method is overridden by did_you_mean and error_highlight to add
- * their information.
+ * begin
+ * 1 / 0
+ * rescue => x
+ * p x.message
+ * p x.detailed_message # Class name added.
+ * p x.detailed_message(highlight: true) # Class name, bolding, and underlining added.
+ * end
*
- * A user-defined exception class can also define their own
- * +detailed_message+ method to add supplemental information.
- * When +highlight+ is true, it can return a string containing escape
- * sequences, but use widely-supported ones. It is recommended to limit
- * the following codes:
+ * Output:
*
- * - Reset (+\e[0m+)
- * - Bold (+\e[1m+)
- * - Underline (+\e[4m+)
- * - Foreground color except white and black
- * - Red (+\e[31m+)
- * - Green (+\e[32m+)
- * - Yellow (+\e[33m+)
- * - Blue (+\e[34m+)
- * - Magenta (+\e[35m+)
- * - Cyan (+\e[36m+)
+ * "divided by 0"
+ * "divided by 0 (ZeroDivisionError)"
+ * "\e[1mdivided by 0 (\e[1;4mZeroDivisionError\e[m\e[1m)\e[m"
*
- * Use escape sequences carefully even if +highlight+ is true.
- * Do not use escape sequences to express essential information;
- * the message should be readable even if all escape sequences are
- * ignored.
+ * This method is overridden by some gems in the Ruby standard library to add information:
+ *
+ * - DidYouMean::Correctable#detailed_message.
+ * - ErrorHighlight::CoreExt#detailed_message.
+ * - SyntaxSuggest#detailed_message.
+ *
+ * An overriding method must be tolerant of passed keyword arguments,
+ * which may include (but may not be limited to):
+ *
+ * - +:highlight+.
+ * - +:did_you_mean+.
+ * - +:error_highlight+.
+ * - +:syntax_suggest+.
+ *
+ * An overriding method should also be careful with ANSI code enhancements;
+ * see {Messages}[rdoc-ref:exceptions.md@Messages].
*/
static VALUE
@@ -1409,16 +1814,22 @@ exc_detailed_message(int argc, VALUE *argv, VALUE exc)
VALUE highlight = check_highlight_keyword(opt, 0);
- extern VALUE rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight);
+ extern VALUE rb_decorate_message(const VALUE eclass, VALUE emesg, int highlight);
return rb_decorate_message(CLASS_OF(exc), rb_get_message(exc), RTEST(highlight));
}
/*
* call-seq:
- * exception.inspect -> string
+ * inspect -> string
+ *
+ * Returns a string representation of +self+:
+ *
+ * x = RuntimeError.new('Boom')
+ * x.inspect # => "#<RuntimeError: Boom>"
+ * x = RuntimeError.new
+ * x.inspect # => "#<RuntimeError: RuntimeError>"
*
- * Return this exception's class name and message.
*/
static VALUE
@@ -1451,38 +1862,36 @@ exc_inspect(VALUE exc)
/*
* call-seq:
- * exception.backtrace -> array or nil
- *
- * Returns any backtrace associated with the exception. The backtrace
- * is an array of strings, each containing either ``filename:lineNo: in
- * `method''' or ``filename:lineNo.''
+ * backtrace -> array or nil
*
- * def a
- * raise "boom"
- * end
+ * Returns the backtrace (the list of code locations that led to the exception),
+ * as an array of strings.
*
- * def b
- * a()
- * end
+ * Example (assuming the code is stored in the file named <tt>t.rb</tt>):
*
- * begin
- * b()
- * rescue => detail
- * print detail.backtrace.join("\n")
- * end
+ * def division(numerator, denominator)
+ * numerator / denominator
+ * end
*
- * <em>produces:</em>
+ * begin
+ * division(1, 0)
+ * rescue => ex
+ * p ex.backtrace
+ * # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '<main>'"]
+ * loc = ex.backtrace.first
+ * p loc.class
+ * # String
+ * end
*
- * prog.rb:2:in `a'
- * prog.rb:6:in `b'
- * prog.rb:10
+ * The value returned by this method might be adjusted when raising (see Kernel#raise),
+ * or during intermediate handling by #set_backtrace.
*
- * In the case no backtrace has been set, +nil+ is returned
+ * See also #backtrace_locations that provide the same value, as structured objects.
+ * (Note though that two values might not be consistent with each other when
+ * backtraces are manually adjusted.)
*
- * ex = StandardError.new
- * ex.backtrace
- * #=> nil
-*/
+ * see {Backtraces}[rdoc-ref:exceptions.md@Backtraces].
+ */
static VALUE
exc_backtrace(VALUE exc)
@@ -1524,13 +1933,41 @@ rb_get_backtrace(VALUE exc)
/*
* call-seq:
- * exception.backtrace_locations -> array or nil
+ * backtrace_locations -> array or nil
+ *
+ * Returns the backtrace (the list of code locations that led to the exception),
+ * as an array of Thread::Backtrace::Location instances.
*
- * Returns any backtrace associated with the exception. This method is
- * similar to Exception#backtrace, but the backtrace is an array of
- * Thread::Backtrace::Location.
+ * Example (assuming the code is stored in the file named <tt>t.rb</tt>):
*
- * This method is not affected by Exception#set_backtrace().
+ * def division(numerator, denominator)
+ * numerator / denominator
+ * end
+ *
+ * begin
+ * division(1, 0)
+ * rescue => ex
+ * p ex.backtrace_locations
+ * # ["t.rb:2:in 'Integer#/'", "t.rb:2:in 'Object#division'", "t.rb:6:in '<main>'"]
+ * loc = ex.backtrace_locations.first
+ * p loc.class
+ * # Thread::Backtrace::Location
+ * p loc.path
+ * # "t.rb"
+ * p loc.lineno
+ * # 2
+ * p loc.label
+ * # "Integer#/"
+ * end
+ *
+ * The value returned by this method might be adjusted when raising (see Kernel#raise),
+ * or during intermediate handling by #set_backtrace.
+ *
+ * See also #backtrace that provide the same value as an array of strings.
+ * (Note though that two values might not be consistent with each other when
+ * backtraces are manually adjusted.)
+ *
+ * See {Backtraces}[rdoc-ref:exceptions.md@Backtraces].
*/
static VALUE
exc_backtrace_locations(VALUE exc)
@@ -1548,7 +1985,7 @@ static VALUE
rb_check_backtrace(VALUE bt)
{
long i;
- static const char err[] = "backtrace must be Array of String";
+ static const char err[] = "backtrace must be an Array of String or an Array of Thread::Backtrace::Location";
if (!NIL_P(bt)) {
if (RB_TYPE_P(bt, T_STRING)) return rb_ary_new3(1, bt);
@@ -1568,18 +2005,118 @@ rb_check_backtrace(VALUE bt)
/*
* call-seq:
- * exc.set_backtrace(backtrace) -> array
+ * set_backtrace(value) -> value
*
- * Sets the backtrace information associated with +exc+. The +backtrace+ must
- * be an array of String objects or a single String in the format described
- * in Exception#backtrace.
+ * Sets the backtrace value for +self+; returns the given +value+.
+ *
+ * The +value+ might be:
+ *
+ * - an array of Thread::Backtrace::Location;
+ * - an array of String instances;
+ * - a single String instance; or
+ * - +nil+.
+ *
+ * Using array of Thread::Backtrace::Location is the most consistent
+ * option: it sets both #backtrace and #backtrace_locations. It should be
+ * preferred when possible. The suitable array of locations can be obtained
+ * from Kernel#caller_locations, copied from another error, or just set to
+ * the adjusted result of the current error's #backtrace_locations:
+ *
+ * require 'json'
+ *
+ * def parse_payload(text)
+ * JSON.parse(text) # test.rb, line 4
+ * rescue JSON::ParserError => ex
+ * ex.set_backtrace(ex.backtrace_locations[2...])
+ * raise
+ * end
*
+ * parse_payload('{"wrong: "json"')
+ * # test.rb:4:in 'Object#parse_payload': unexpected token at '{"wrong: "json"' (JSON::ParserError)
+ * #
+ * # An error points to the body of parse_payload method,
+ * # hiding the parts of the backtrace related to the internals
+ * # of the "json" library
+ *
+ * # The error has both #backtace and #backtrace_locations set
+ * # consistently:
+ * begin
+ * parse_payload('{"wrong: "json"')
+ * rescue => ex
+ * p ex.backtrace
+ * # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '<main>'"]
+ * p ex.backtrace_locations
+ * # ["test.rb:4:in 'Object#parse_payload'", "test.rb:20:in '<main>'"]
+ * end
+ *
+ * When the desired stack of locations is not available and should
+ * be constructed from scratch, an array of strings or a singular
+ * string can be used. In this case, only #backtrace is affected:
+ *
+ * def parse_payload(text)
+ * JSON.parse(text)
+ * rescue JSON::ParserError => ex
+ * ex.set_backtrace(["dsl.rb:34", "framework.rb:1"])
+ * # The error have the new value in #backtrace:
+ * p ex.backtrace
+ * # ["dsl.rb:34", "framework.rb:1"]
+ *
+ * # but the original one in #backtrace_locations
+ * p ex.backtrace_locations
+ * # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...]
+ * end
+ *
+ * parse_payload('{"wrong: "json"')
+ *
+ * Calling #set_backtrace with +nil+ clears up #backtrace but doesn't affect
+ * #backtrace_locations:
+ *
+ * def parse_payload(text)
+ * JSON.parse(text)
+ * rescue JSON::ParserError => ex
+ * ex.set_backtrace(nil)
+ * p ex.backtrace
+ * # nil
+ * p ex.backtrace_locations
+ * # [".../json/common.rb:221:in 'JSON::Ext::Parser.parse'", ...]
+ * end
+ *
+ * parse_payload('{"wrong: "json"')
+ *
+ * On reraising of such an exception, both #backtrace and #backtrace_locations
+ * is set to the place of reraising:
+ *
+ * def parse_payload(text)
+ * JSON.parse(text)
+ * rescue JSON::ParserError => ex
+ * ex.set_backtrace(nil)
+ * raise # test.rb, line 7
+ * end
+ *
+ * begin
+ * parse_payload('{"wrong: "json"')
+ * rescue => ex
+ * p ex.backtrace
+ * # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '<main>'"]
+ * p ex.backtrace_locations
+ * # ["test.rb:7:in 'Object#parse_payload'", "test.rb:11:in '<main>'"]
+ * end
+ *
+ * See {Backtraces}[rdoc-ref:exceptions.md@Backtraces].
*/
static VALUE
exc_set_backtrace(VALUE exc, VALUE bt)
{
- return rb_ivar_set(exc, id_bt, rb_check_backtrace(bt));
+ VALUE btobj = rb_location_ary_to_backtrace(bt);
+ if (RTEST(btobj)) {
+ rb_ivar_set(exc, id_bt, btobj);
+ rb_ivar_set(exc, id_bt_locations, btobj);
+ return bt;
+ }
+ else {
+ return rb_ivar_set(exc, id_bt, rb_check_backtrace(bt));
+ }
}
VALUE
@@ -1589,12 +2126,35 @@ rb_exc_set_backtrace(VALUE exc, VALUE bt)
}
/*
- * call-seq:
- * exception.cause -> an_exception or nil
+ * call-seq:
+ * cause -> exception or nil
+ *
+ * Returns the previous value of global variable <tt>$!</tt>,
+ * which may be +nil+
+ * (see {Global Variables}[rdoc-ref:exceptions.md@Global+Variables]):
+ *
+ * begin
+ * raise('Boom 0')
+ * rescue => x0
+ * puts "Exception: #{x0}; $!: #{$!}; cause: #{x0.cause.inspect}."
+ * begin
+ * raise('Boom 1')
+ * rescue => x1
+ * puts "Exception: #{x1}; $!: #{$!}; cause: #{x1.cause}."
+ * begin
+ * raise('Boom 2')
+ * rescue => x2
+ * puts "Exception: #{x2}; $!: #{$!}; cause: #{x2.cause}."
+ * end
+ * end
+ * end
+ *
+ * Output:
+ *
+ * Exception: Boom 0; $!: Boom 0; cause: nil.
+ * Exception: Boom 1; $!: Boom 1; cause: Boom 0.
+ * Exception: Boom 2; $!: Boom 2; cause: Boom 1.
*
- * Returns the previous exception ($!) at the time this exception was raised.
- * This is useful for wrapping exceptions and retaining the original exception
- * information.
*/
static VALUE
@@ -1611,11 +2171,11 @@ try_convert_to_exception(VALUE obj)
/*
* call-seq:
- * exc == obj -> true or false
+ * self == other -> true or false
+ *
+ * Returns whether +other+ is the same class as +self+
+ * and its #message and #backtrace are equal to those of +self+.
*
- * Equality---If <i>obj</i> is not an Exception, 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
@@ -1818,7 +2378,9 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method)
cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
rb_ivar_set(exc, id_name, method);
err_init_recv(exc, recv);
- if (cfp) rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq));
+ if (cfp && VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) {
+ rb_ivar_set(exc, id_iseq, rb_iseqw_new(CFP_ISEQ(cfp)));
+ }
return exc;
}
@@ -1948,50 +2510,41 @@ rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
return nometh_err_init_attr(exc, args, priv);
}
-/* :nodoc: */
-enum {
- NAME_ERR_MESG__MESG,
- NAME_ERR_MESG__RECV,
- NAME_ERR_MESG__NAME,
- NAME_ERR_MESG_COUNT
-};
+typedef struct name_error_message_struct {
+ VALUE mesg;
+ VALUE recv;
+ VALUE name;
+} name_error_message_t;
static void
-name_err_mesg_mark(void *p)
-{
- VALUE *ptr = p;
- rb_gc_mark_locations(ptr, ptr+NAME_ERR_MESG_COUNT);
-}
-
-#define name_err_mesg_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-name_err_mesg_memsize(const void *p)
+name_err_mesg_mark_and_move(void *p)
{
- return NAME_ERR_MESG_COUNT * sizeof(VALUE);
+ name_error_message_t *ptr = (name_error_message_t *)p;
+ rb_gc_mark_and_move(&ptr->mesg);
+ rb_gc_mark_and_move(&ptr->recv);
+ rb_gc_mark_and_move(&ptr->name);
}
static const rb_data_type_t name_err_mesg_data_type = {
"name_err_mesg",
{
- name_err_mesg_mark,
- name_err_mesg_free,
- name_err_mesg_memsize,
+ name_err_mesg_mark_and_move,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // No external memory to report,
+ name_err_mesg_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
/* :nodoc: */
static VALUE
-rb_name_err_mesg_init(VALUE klass, VALUE mesg, VALUE recv, VALUE method)
+rb_name_err_mesg_init(VALUE klass, VALUE mesg, VALUE recv, VALUE name)
{
- VALUE result = TypedData_Wrap_Struct(klass, &name_err_mesg_data_type, 0);
- VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT);
-
- ptr[NAME_ERR_MESG__MESG] = mesg;
- ptr[NAME_ERR_MESG__RECV] = recv;
- ptr[NAME_ERR_MESG__NAME] = method;
- RTYPEDDATA_DATA(result) = ptr;
+ name_error_message_t *message;
+ VALUE result = TypedData_Make_Struct(klass, name_error_message_t, &name_err_mesg_data_type, message);
+ RB_OBJ_WRITE(result, &message->mesg, mesg);
+ RB_OBJ_WRITE(result, &message->recv, recv);
+ RB_OBJ_WRITE(result, &message->name, name);
return result;
}
@@ -2013,14 +2566,16 @@ name_err_mesg_alloc(VALUE klass)
static VALUE
name_err_mesg_init_copy(VALUE obj1, VALUE obj2)
{
- VALUE *ptr1, *ptr2;
-
if (obj1 == obj2) return obj1;
rb_obj_init_copy(obj1, obj2);
- TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
- TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
- MEMCPY(ptr1, ptr2, VALUE, NAME_ERR_MESG_COUNT);
+ name_error_message_t *ptr1, *ptr2;
+ TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1);
+ TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2);
+
+ RB_OBJ_WRITE(obj1, &ptr1->mesg, ptr2->mesg);
+ RB_OBJ_WRITE(obj1, &ptr1->recv, ptr2->recv);
+ RB_OBJ_WRITE(obj1, &ptr1->name, ptr2->name);
return obj1;
}
@@ -2028,19 +2583,18 @@ name_err_mesg_init_copy(VALUE obj1, VALUE obj2)
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;
- TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
- TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
- for (i=0; i<NAME_ERR_MESG_COUNT; i++) {
- if (!rb_equal(ptr1[i], ptr2[i]))
- return Qfalse;
- }
+ name_error_message_t *ptr1, *ptr2;
+ TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1);
+ TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2);
+
+ if (!rb_equal(ptr1->mesg, ptr2->mesg)) return Qfalse;
+ if (!rb_equal(ptr1->recv, ptr2->recv)) return Qfalse;
+ if (!rb_equal(ptr1->name, ptr2->name)) return Qfalse;
return Qtrue;
}
@@ -2059,20 +2613,20 @@ name_err_mesg_receiver_name(VALUE obj)
static VALUE
name_err_mesg_to_str(VALUE obj)
{
- VALUE *ptr, mesg;
- TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);
+ name_error_message_t *ptr;
+ TypedData_Get_Struct(obj, name_error_message_t, &name_err_mesg_data_type, ptr);
- mesg = ptr[NAME_ERR_MESG__MESG];
+ VALUE mesg = ptr->mesg;
if (NIL_P(mesg)) return Qnil;
else {
- struct RString s_str, c_str, d_str;
+ struct RString s_str = {RBASIC_INIT}, c_str = {RBASIC_INIT}, d_str = {RBASIC_INIT};
VALUE c, s, d = 0, args[4], c2;
int state = 0;
rb_encoding *usascii = rb_usascii_encoding();
#define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii)
c = s = FAKE_CSTR(&s_str, "");
- obj = ptr[NAME_ERR_MESG__RECV];
+ obj = ptr->recv;
switch (obj) {
case Qnil:
c = d = FAKE_CSTR(&d_str, "nil");
@@ -2115,7 +2669,7 @@ name_err_mesg_to_str(VALUE obj)
VALUE klass;
object:
klass = CLASS_OF(obj);
- if (RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON)) {
+ if (RB_TYPE_P(klass, T_CLASS) && RCLASS_SINGLETON_P(klass)) {
s = FAKE_CSTR(&s_str, "");
if (obj == rb_vm_top_self()) {
c = FAKE_CSTR(&c_str, "main");
@@ -2143,7 +2697,7 @@ name_err_mesg_to_str(VALUE obj)
c = c2;
break;
}
- args[0] = rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]);
+ args[0] = rb_obj_as_string(ptr->name);
args[1] = d;
args[2] = s;
args[3] = c;
@@ -2176,17 +2730,17 @@ name_err_mesg_load(VALUE klass, VALUE str)
static VALUE
name_err_receiver(VALUE self)
{
- VALUE *ptr, recv, mesg;
-
- recv = rb_ivar_lookup(self, id_recv, Qundef);
+ VALUE recv = rb_ivar_lookup(self, id_recv, Qundef);
if (!UNDEF_P(recv)) return recv;
- mesg = rb_attr_get(self, id_mesg);
+ VALUE mesg = rb_attr_get(self, id_mesg);
if (!rb_typeddata_is_kind_of(mesg, &name_err_mesg_data_type)) {
rb_raise(rb_eArgError, "no receiver is available");
}
- ptr = DATA_PTR(mesg);
- return ptr[NAME_ERR_MESG__RECV];
+
+ name_error_message_t *ptr;
+ TypedData_Get_Struct(mesg, name_error_message_t, &name_err_mesg_data_type, ptr);
+ return ptr->recv;
}
/*
@@ -2216,6 +2770,68 @@ nometh_err_private_call_p(VALUE self)
return rb_attr_get(self, id_private_call_p);
}
+static const char *
+type_err_cname(VALUE val)
+{
+ if (NIL_P(val)) {
+ return "nil";
+ }
+ else if (val == Qtrue) {
+ return "true";
+ }
+ else if (val == Qfalse) {
+ return "false";
+ }
+ return NULL;
+}
+
+NORETURN(static void type_err_raise(VALUE val, const char *tname, const char *msg));
+static void
+type_err_raise(VALUE val, const char *tname, const char *msg)
+{
+ const char *cname = type_err_cname(val);
+ rb_encoding *enc = rb_utf8_encoding();
+ if (cname) {
+ rb_enc_raise(enc, rb_eTypeError, "%s %s into %s", msg, cname, tname);
+ }
+ rb_enc_raise(enc, rb_eTypeError, "%s %"PRIsVALUE" into %s", msg, rb_obj_class(val), tname);
+}
+
+NORETURN(void rb_no_implicit_conversion(VALUE val, const char *tname));
+void
+rb_no_implicit_conversion(VALUE val, const char *tname)
+{
+ type_err_raise(val, tname, "no implicit conversion of");
+}
+
+NORETURN(void rb_cant_convert(VALUE val, const char *tname));
+void
+rb_cant_convert(VALUE val, const char *tname)
+{
+ type_err_raise(val, tname, "can't convert");
+}
+
+NORETURN(void rb_cant_convert_invalid_return(VALUE val, const char *tname, const char *method_name, VALUE ret));
+void
+rb_cant_convert_invalid_return(VALUE val, const char *tname, const char *method_name, VALUE ret)
+{
+ const char *cname = type_err_cname(val);
+ rb_encoding *enc = rb_utf8_encoding();
+ if (cname) {
+ rb_enc_raise(
+ enc, rb_eTypeError, "can't convert %s into %s (%s#%s gives %s)",
+ cname, tname, cname, method_name, type_err_cname(ret));
+ }
+ VALUE klass = rb_obj_class(val);
+ const char *retname = type_err_cname(ret);
+ if (!retname) {
+ retname = rb_obj_classname(ret);
+ }
+ rb_enc_raise(
+ enc, rb_eTypeError, "can't convert %"PRIsVALUE" into %s (%"PRIsVALUE"#%s gives %s)",
+ klass, tname, klass, method_name, retname);
+}
+
void
rb_invalid_str(const char *str, const char *type)
{
@@ -2396,8 +3012,18 @@ syntax_error_with_path(VALUE exc, VALUE path, VALUE *mesg, rb_encoding *enc)
rb_ivar_set(exc, id_i_path, path);
}
else {
- if (rb_attr_get(exc, id_i_path) != path) {
- rb_raise(rb_eArgError, "SyntaxError#path changed");
+ VALUE old_path = rb_attr_get(exc, id_i_path);
+ if (old_path != path) {
+ if (rb_str_equal(path, old_path)) {
+ rb_raise(rb_eArgError, "SyntaxError#path changed: %+"PRIsVALUE" (%p->%p)",
+ old_path, (void *)old_path, (void *)path);
+ }
+ else {
+ rb_raise(rb_eArgError, "SyntaxError#path changed: %+"PRIsVALUE"(%s%s)->%+"PRIsVALUE"(%s)",
+ old_path, rb_enc_name(rb_enc_get(old_path)),
+ (FL_TEST(old_path, RSTRING_FSTR) ? ":FSTR" : ""),
+ path, rb_enc_name(rb_enc_get(path)));
+ }
}
VALUE s = *mesg = rb_attr_get(exc, idMesg);
if (RSTRING_LEN(s) > 0 && *(RSTRING_END(s)-1) != '\n')
@@ -2409,67 +3035,105 @@ syntax_error_with_path(VALUE exc, VALUE path, VALUE *mesg, rb_encoding *enc)
/*
* Document-module: Errno
*
- * Ruby exception objects are subclasses of Exception. However,
- * operating systems typically report errors using plain
- * integers. Module Errno is created dynamically to map these
- * operating system errors to Ruby classes, with each error number
- * generating its own subclass of SystemCallError. As the subclass
- * is created in module Errno, its name will start
- * <code>Errno::</code>.
+ * When an operating system encounters an error,
+ * it typically reports the error as an integer error code:
+ *
+ * $ ls nosuch.txt
+ * ls: cannot access 'nosuch.txt': No such file or directory
+ * $ echo $? # Code for last error.
+ * 2
+ *
+ * When the Ruby interpreter interacts with the operating system
+ * and receives such an error code (e.g., +2+),
+ * it maps the code to a particular Ruby exception class (e.g., +Errno::ENOENT+):
+ *
+ * File.open('nosuch.txt')
+ * # => No such file or directory @ rb_sysopen - nosuch.txt (Errno::ENOENT)
+ *
+ * Each such class is:
+ *
+ * - A nested class in this module, +Errno+.
+ * - A subclass of class SystemCallError.
+ * - Associated with an error code.
*
- * The names of the <code>Errno::</code> classes depend on the
- * environment in which Ruby runs. On a typical Unix or Windows
- * platform, there are Errno classes such as Errno::EACCES,
- * Errno::EAGAIN, Errno::EINTR, and so on.
+ * Thus:
*
- * The integer operating system error number corresponding to a
- * particular error is available as the class constant
- * <code>Errno::</code><em>error</em><code>::Errno</code>.
+ * Errno::ENOENT.superclass # => SystemCallError
+ * Errno::ENOENT::Errno # => 2
*
- * Errno::EACCES::Errno #=> 13
- * Errno::EAGAIN::Errno #=> 11
- * Errno::EINTR::Errno #=> 4
+ * The names of nested classes are returned by method +Errno.constants+:
*
- * The full list of operating system errors on your particular platform
- * are available as the constants of Errno.
+ * Errno.constants.size # => 158
+ * Errno.constants.sort.take(5) # => [:E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, :EADV]
*
- * Errno.constants #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ...
+ * As seen above, the error code associated with each class
+ * is available as the value of a constant;
+ * the value for a particular class may vary among operating systems.
+ * If the class is not needed for the particular operating system,
+ * the value is zero:
+ *
+ * Errno::ENOENT::Errno # => 2
+ * Errno::ENOTCAPABLE::Errno # => 0
+ *
+ * Each class in Errno can be created with optional messages:
+ *
+ * Errno::EPIPE.new # => #<Errno::EPIPE: Broken pipe>
+ * Errno::EPIPE.new("foo") # => #<Errno::EPIPE: Broken pipe - foo>
+ * Errno::EPIPE.new("foo", "here") # => #<Errno::EPIPE: Broken pipe @ here - foo>
+ *
+ * See SystemCallError.new.
*/
static st_table *syserr_tbl;
-static VALUE
-set_syserr(int n, const char *name)
+void
+rb_free_warning(void)
{
- st_data_t error;
+ st_free_table(warning_categories.id2enum);
+ st_free_table(warning_categories.enum2id);
+ st_free_table(syserr_tbl);
+}
- if (!st_lookup(syserr_tbl, n, &error)) {
- error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
+static VALUE
+setup_syserr(int n, const char *name)
+{
+ VALUE error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
- /* capture nonblock errnos for WaitReadable/WaitWritable subclasses */
- switch (n) {
- case EAGAIN:
- rb_eEAGAIN = error;
+ /* capture nonblock errnos for WaitReadable/WaitWritable subclasses */
+ switch (n) {
+ case EAGAIN:
+ rb_eEAGAIN = error;
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
- break;
- case EWOULDBLOCK:
+ break;
+ case EWOULDBLOCK:
#endif
- rb_eEWOULDBLOCK = error;
- break;
- case EINPROGRESS:
- rb_eEINPROGRESS = error;
- break;
- }
+ rb_eEWOULDBLOCK = error;
+ break;
+ case EINPROGRESS:
+ rb_eEINPROGRESS = error;
+ break;
+ }
- rb_define_const(error, "Errno", INT2NUM(n));
- st_add_direct(syserr_tbl, n, error);
+ rb_define_const(error, "Errno", INT2NUM(n));
+ st_add_direct(syserr_tbl, n, (st_data_t)error);
+ return error;
+}
+
+static VALUE
+set_syserr(int n, const char *name)
+{
+ st_data_t error;
+
+ if (!st_lookup(syserr_tbl, n, &error)) {
+ return setup_syserr(n, name);
}
else {
- rb_define_const(rb_mErrno, name, error);
+ VALUE errclass = (VALUE)error;
+ rb_define_const(rb_mErrno, name, errclass);
+ return errclass;
}
- return error;
}
static VALUE
@@ -2478,22 +3142,43 @@ get_syserr(int n)
st_data_t error;
if (!st_lookup(syserr_tbl, n, &error)) {
- char name[8]; /* some Windows' errno have 5 digits. */
+ char name[DECIMAL_SIZE_OF(n) + sizeof("E-")];
snprintf(name, sizeof(name), "E%03d", n);
- error = set_syserr(n, name);
+ return setup_syserr(n, name);
}
- return error;
+ return (VALUE)error;
}
/*
* call-seq:
- * SystemCallError.new(msg, errno) -> system_call_error_subclass
+ * SystemCallError.new(msg, errno = nil, func = nil) -> system_call_error_subclass
*
* If _errno_ corresponds to a known system error code, constructs the
* appropriate Errno class for that error, otherwise constructs a
* generic SystemCallError object. The error number is subsequently
* available via the #errno method.
+ *
+ * If only numeric object is given, it is treated as an Integer _errno_,
+ * and _msg_ is omitted, otherwise the first argument _msg_ is used as
+ * the additional error message.
+ *
+ * SystemCallError.new(Errno::EPIPE::Errno)
+ * #=> #<Errno::EPIPE: Broken pipe>
+ *
+ * SystemCallError.new("foo")
+ * #=> #<SystemCallError: unknown error - foo>
+ *
+ * SystemCallError.new("foo", Errno::EPIPE::Errno)
+ * #=> #<Errno::EPIPE: Broken pipe - foo>
+ *
+ * If _func_ is not +nil+, it is appended to the message with "<tt> @ </tt>".
+ *
+ * SystemCallError.new("foo", Errno::EPIPE::Errno, "here")
+ * #=> #<Errno::EPIPE: Broken pipe @ here - foo>
+ *
+ * A subclass of SystemCallError can also be instantiated via the
+ * +new+ method of the subclass. See Errno.
*/
static VALUE
@@ -2797,7 +3482,7 @@ syserr_eqq(VALUE self, VALUE exc)
*
* <em>raises the exception:</em>
*
- * NoMethodError: undefined method `to_ary' for "hello":String
+ * NoMethodError: undefined method `to_ary' for an instance of String
*/
/*
@@ -2868,9 +3553,21 @@ syserr_eqq(VALUE self, VALUE exc)
*/
/*
+ * Document-class: NoMatchingPatternError
+ *
+ * Raised when matching pattern not found.
+ */
+
+/*
+ * Document-class: NoMatchingPatternKeyError
+ *
+ * Raised when matching key not found.
+ */
+
+/*
* Document-class: fatal
*
- * fatal is an Exception that is raised when Ruby has encountered a fatal
+ * +fatal+ is an Exception that is raised when Ruby has encountered a fatal
* error and must exit.
*/
@@ -2882,62 +3579,26 @@ syserr_eqq(VALUE self, VALUE exc)
/*
* Document-class: Exception
*
- * \Class Exception and its subclasses are used to communicate between
- * Kernel#raise and +rescue+ statements in <code>begin ... end</code> blocks.
- *
- * An Exception object carries information about an exception:
- * - Its type (the exception's class).
- * - An optional descriptive message.
- * - Optional backtrace information.
- *
- * Some built-in subclasses of Exception have additional methods: e.g., NameError#name.
+ * Class +Exception+ and its subclasses are used to indicate that an error
+ * or other problem has occurred,
+ * and may need to be handled.
+ * See {Exceptions}[rdoc-ref:exceptions.md].
*
- * == Defaults
+ * An +Exception+ object carries certain information:
*
- * Two Ruby statements have default exception classes:
- * - +raise+: defaults to RuntimeError.
- * - +rescue+: defaults to StandardError.
+ * - The type (the exception's class),
+ * commonly StandardError, RuntimeError, or a subclass of one or the other;
+ * see {Built-In Exception Class Hierarchy}[rdoc-ref:Exception@Built-In+Exception+Class+Hierarchy].
+ * - An optional descriptive message;
+ * see methods ::new, #message.
+ * - Optional backtrace information;
+ * see methods #backtrace, #backtrace_locations, #set_backtrace.
+ * - An optional cause;
+ * see method #cause.
*
- * == Global Variables
+ * == Built-In \Exception Class Hierarchy
*
- * When an exception has been raised but not yet handled (in +rescue+,
- * +ensure+, +at_exit+ and +END+ blocks), two global variables are set:
- * - <code>$!</code> contains the current exception.
- * - <code>$@</code> contains its backtrace.
- *
- * == Custom Exceptions
- *
- * To provide additional or alternate information,
- * a program may create custom exception classes
- * that derive from the built-in exception classes.
- *
- * A good practice is for a library to create a single "generic" exception class
- * (typically a subclass of StandardError or RuntimeError)
- * and have its other exception classes derive from that class.
- * This allows the user to rescue the generic exception, thus catching all exceptions
- * the library may raise even if future versions of the library add new
- * exception subclasses.
- *
- * For example:
- *
- * class MyLibrary
- * class Error < ::StandardError
- * end
- *
- * class WidgetError < Error
- * end
- *
- * class FrobError < Error
- * end
- *
- * end
- *
- * To handle both MyLibrary::WidgetError and MyLibrary::FrobError the library
- * user can rescue MyLibrary::Error.
- *
- * == Built-In Exception Classes
- *
- * The built-in subclasses of Exception are:
+ * The hierarchy of built-in subclasses of class +Exception+:
*
* * NoMemoryError
* * ScriptError
@@ -2967,13 +3628,14 @@ syserr_eqq(VALUE self, VALUE exc)
* * RuntimeError
* * FrozenError
* * SystemCallError
- * * Errno::*
+ * * Errno (and its subclasses, representing system errors)
* * ThreadError
* * TypeError
* * ZeroDivisionError
* * SystemExit
* * SystemStackError
- * * fatal
+ * * {fatal}[rdoc-ref:fatal]
+ *
*/
static VALUE
@@ -2993,9 +3655,9 @@ exception_dumper(VALUE exc)
}
static int
-ivar_copy_i(st_data_t key, st_data_t val, st_data_t exc)
+ivar_copy_i(ID key, VALUE val, st_data_t exc)
{
- rb_ivar_set((VALUE) exc, (ID) key, (VALUE) val);
+ rb_ivar_set((VALUE)exc, key, val);
return ST_CONTINUE;
}
@@ -3072,11 +3734,11 @@ Init_Exception(void)
* and will render `idPath` as an attribute name without this trick */
ID path = idPath;
- /* the path failed to parse */
+ /* the path that failed to parse */
rb_attr(rb_eSyntaxError, path, TRUE, FALSE, FALSE);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
- /* the path failed to load */
+ /* the path that failed to load */
rb_attr(rb_eLoadError, path, TRUE, FALSE, FALSE);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
@@ -3123,6 +3785,7 @@ Init_Exception(void)
rb_mWarning = rb_define_module("Warning");
rb_define_singleton_method(rb_mWarning, "[]", rb_warning_s_aref, 1);
rb_define_singleton_method(rb_mWarning, "[]=", rb_warning_s_aset, 2);
+ rb_define_singleton_method(rb_mWarning, "categories", rb_warning_s_categories, 0);
rb_define_method(rb_mWarning, "warn", rb_warning_s_warn, -1);
rb_extend_object(rb_mWarning, rb_mWarning);
@@ -3147,6 +3810,8 @@ Init_Exception(void)
id_category = rb_intern_const("category");
id_deprecated = rb_intern_const("deprecated");
id_experimental = rb_intern_const("experimental");
+ id_performance = rb_intern_const("performance");
+ id_strict_unused_block = rb_intern_const("strict_unused_block");
id_top = rb_intern_const("top");
id_bottom = rb_intern_const("bottom");
id_iseq = rb_make_internal_id();
@@ -3158,11 +3823,15 @@ Init_Exception(void)
warning_categories.id2enum = rb_init_identtable();
st_add_direct(warning_categories.id2enum, id_deprecated, RB_WARN_CATEGORY_DEPRECATED);
st_add_direct(warning_categories.id2enum, id_experimental, RB_WARN_CATEGORY_EXPERIMENTAL);
+ st_add_direct(warning_categories.id2enum, id_performance, RB_WARN_CATEGORY_PERFORMANCE);
+ st_add_direct(warning_categories.id2enum, id_strict_unused_block, RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK);
warning_categories.enum2id = rb_init_identtable();
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_NONE, 0);
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_DEPRECATED, id_deprecated);
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_EXPERIMENTAL, id_experimental);
+ st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_PERFORMANCE, id_performance);
+ st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK, id_strict_unused_block);
}
void
@@ -3185,12 +3854,13 @@ rb_vraise(VALUE exc, const char *fmt, va_list ap)
}
void
-rb_raise(VALUE exc, const char *fmt, ...)
+rb_raise(VALUE exc_class, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- rb_vraise(exc, fmt, args);
+ VALUE exc = rb_exc_new3(exc_class, rb_vsprintf(fmt, args));
va_end(args);
+ rb_exc_raise(exc);
}
NORETURN(static void raise_loaderror(VALUE path, VALUE mesg));
@@ -3245,7 +3915,7 @@ rb_fatal(const char *fmt, ...)
/* The thread has no GVL. Object allocation impossible (cant run GC),
* thus no message can be printed out. */
fprintf(stderr, "[FATAL] rb_fatal() outside of GVL\n");
- rb_print_backtrace();
+ rb_print_backtrace(stderr);
die();
}
@@ -3308,12 +3978,14 @@ rb_syserr_fail_str(int e, VALUE mesg)
rb_exc_raise(rb_syserr_new_str(e, mesg));
}
+#undef rb_sys_fail
void
rb_sys_fail(const char *mesg)
{
rb_exc_raise(make_errno_exc(mesg));
}
+#undef rb_sys_fail_str
void
rb_sys_fail_str(VALUE mesg)
{
@@ -3532,48 +4204,107 @@ inspect_frozen_obj(VALUE obj, VALUE mesg, int recur)
return mesg;
}
+static VALUE
+get_created_info(VALUE obj, int *pline)
+{
+ VALUE info = rb_attr_get(obj, id_debug_created_info);
+
+ if (NIL_P(info)) return Qnil;
+
+ VALUE path = rb_ary_entry(info, 0);
+ VALUE line = rb_ary_entry(info, 1);
+ if (NIL_P(path)) return Qnil;
+ *pline = NUM2INT(line);
+ return StringValue(path);
+}
+
void
rb_error_frozen_object(VALUE frozen_obj)
{
- VALUE debug_info;
- const ID created_info = id_debug_created_info;
+ rb_yjit_lazy_push_frame(GET_EC()->cfp->pc);
+
VALUE mesg = rb_sprintf("can't modify frozen %"PRIsVALUE": ",
- CLASS_OF(frozen_obj));
+ rb_obj_class(frozen_obj));
VALUE exc = rb_exc_new_str(rb_eFrozenError, mesg);
rb_ivar_set(exc, id_recv, frozen_obj);
rb_exec_recursive(inspect_frozen_obj, frozen_obj, mesg);
- if (!NIL_P(debug_info = rb_attr_get(frozen_obj, created_info))) {
- VALUE path = rb_ary_entry(debug_info, 0);
- VALUE line = rb_ary_entry(debug_info, 1);
-
- rb_str_catf(mesg, ", created at %"PRIsVALUE":%"PRIsVALUE, path, line);
+ int created_line;
+ VALUE created_path = get_created_info(frozen_obj, &created_line);
+ if (!NIL_P(created_path)) {
+ rb_str_catf(mesg, ", created at %"PRIsVALUE":%d", created_path, created_line);
}
rb_exc_raise(exc);
}
+void
+rb_warn_unchilled_literal(VALUE obj)
+{
+ rb_warning_category_t category = RB_WARN_CATEGORY_DEPRECATED;
+ if (!NIL_P(ruby_verbose) && rb_warning_category_enabled_p(category)) {
+ int line;
+ VALUE file = rb_source_location(&line);
+ VALUE mesg = NIL_P(file) ? rb_str_new(0, 0) : rb_str_dup(file);
+
+ if (!NIL_P(file)) {
+ if (line) rb_str_catf(mesg, ":%d", line);
+ rb_str_cat2(mesg, ": ");
+ }
+ rb_str_cat2(mesg, "warning: literal string will be frozen in the future");
+
+ VALUE str = obj;
+ if (STR_SHARED_P(str)) {
+ str = RSTRING(obj)->as.heap.aux.shared;
+ }
+ VALUE created = get_created_info(str, &line);
+ if (NIL_P(created)) {
+ rb_str_cat2(mesg, " (run with --debug-frozen-string-literal for more information)\n");
+ }
+ else {
+ rb_str_cat2(mesg, "\n");
+ rb_str_append(mesg, created);
+ if (line) rb_str_catf(mesg, ":%d", line);
+ rb_str_cat2(mesg, ": info: the string was created here\n");
+ }
+ rb_warn_category(mesg, rb_warning_category_to_name(category));
+ }
+}
+
+void
+rb_warn_unchilled_symbol_to_s(VALUE obj)
+{
+ rb_category_warn(
+ RB_WARN_CATEGORY_DEPRECATED,
+ "string returned by :%s.to_s will be frozen in the future", RSTRING_PTR(obj)
+ );
+}
+
#undef rb_check_frozen
void
rb_check_frozen(VALUE obj)
{
- rb_check_frozen_internal(obj);
+ rb_check_frozen_inline(obj);
}
void
rb_check_copyable(VALUE obj, VALUE orig)
{
if (!FL_ABLE(obj)) return;
- rb_check_frozen_internal(obj);
+ rb_check_frozen(obj);
if (!FL_ABLE(orig)) return;
}
void
Init_syserr(void)
{
- rb_eNOERROR = set_syserr(0, "NOERROR");
+ rb_eNOERROR = setup_syserr(0, "NOERROR");
+#if 0
+ /* No error */
+ rb_define_const(rb_mErrno, "NOERROR", rb_eNOERROR);
+#endif
#define defined_error(name, num) set_syserr((num), (name));
-#define undefined_error(name) set_syserr(0, (name));
+#define undefined_error(name) rb_define_const(rb_mErrno, (name), rb_eNOERROR);
#include "known_errors.inc"
#undef defined_error
#undef undefined_error
diff --git a/eval.c b/eval.c
index adacde9e2f..b6fedf11f3 100644
--- a/eval.c
+++ b/eval.c
@@ -32,12 +32,12 @@
#include "internal/variable.h"
#include "ruby/fiber/scheduler.h"
#include "iseq.h"
-#include "rjit.h"
#include "probes.h"
#include "probes_helper.h"
#include "ruby/vm.h"
#include "vm_core.h"
#include "ractor_core.h"
+#include "zjit.h"
NORETURN(static void rb_raise_jump(VALUE, VALUE));
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
@@ -70,8 +70,6 @@ ruby_setup(void)
if (GET_VM())
return 0;
- ruby_init_stack((void *)&state);
-
/*
* Disable THP early before mallocs happen because we want this to
* affect as many future pages as possible for CoW-friendliness
@@ -80,9 +78,11 @@ ruby_setup(void)
prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
#endif
Init_BareVM();
- Init_heap();
rb_vm_encoded_insn_data_table_init();
+ Init_enable_box();
Init_vm_objects();
+ Init_master_box();
+ Init_fstring_table();
EC_PUSH_TAG(GET_EC());
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
@@ -115,10 +115,9 @@ ruby_options(int argc, char **argv)
enum ruby_tag_type state;
void *volatile iseq = 0;
- ruby_init_stack((void *)&iseq);
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
+ iseq = ruby_process_options(argc, argv);
}
else {
rb_ec_clear_current_thread_trace_func(ec);
@@ -165,7 +164,7 @@ rb_ec_finalize(rb_execution_context_t *ec)
{
ruby_sig_finalize();
ec->errinfo = Qnil;
- rb_objspace_call_finalizer(rb_ec_vm_ptr(ec)->objspace);
+ rb_objspace_call_finalizer();
}
void
@@ -200,16 +199,15 @@ rb_ec_cleanup(rb_execution_context_t *ec, enum ruby_tag_type ex)
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(ec); });
+ RUBY_VM_CHECK_INTS(ec);
step_0: step++;
save_error = ec->errinfo;
if (THROW_DATA_P(ec->errinfo)) ec->errinfo = Qnil;
- ruby_init_stack(&message);
/* exits with failure but silently when an exception raised
* here */
- SAVE_ROOT_JMPBUF(th, rb_ec_teardown(ec));
+ rb_ec_teardown(ec);
step_1: step++;
VALUE err = ec->errinfo;
@@ -227,7 +225,7 @@ rb_ec_cleanup(rb_execution_context_t *ec, enum ruby_tag_type ex)
mode1 = exiting_split(err, (mode0 & EXITING_WITH_STATUS) ? NULL : &sysex, &signaled);
if (mode1 & EXITING_WITH_MESSAGE) {
buf = rb_str_new(NULL, 0);
- SAVE_ROOT_JMPBUF(th, rb_ec_error_print_detailed(ec, err, buf, Qundef));
+ rb_ec_error_print_detailed(ec, err, buf, Qundef);
message = buf;
}
}
@@ -236,7 +234,7 @@ rb_ec_cleanup(rb_execution_context_t *ec, enum ruby_tag_type ex)
/* protect from Thread#raise */
th->status = THREAD_KILLED;
- SAVE_ROOT_JMPBUF(th, rb_ractor_terminate_all());
+ rb_ractor_terminate_all();
step_3: step++;
if (!NIL_P(buf = message)) {
@@ -283,10 +281,7 @@ rb_ec_exec_node(rb_execution_context_t *ec, void *n)
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- rb_thread_t *const th = rb_ec_thread_ptr(ec);
- SAVE_ROOT_JMPBUF(th, {
- rb_iseq_eval_main(iseq);
- });
+ rb_iseq_eval_main(iseq);
}
EC_POP_TAG();
return state;
@@ -324,30 +319,35 @@ ruby_run_node(void *n)
rb_ec_cleanup(ec, (NIL_P(ec->errinfo) ? TAG_NONE : TAG_RAISE));
return status;
}
- ruby_init_stack((void *)&status);
return rb_ec_cleanup(ec, rb_ec_exec_node(ec, n));
}
int
ruby_exec_node(void *n)
{
- ruby_init_stack((void *)&n);
return rb_ec_exec_node(GET_EC(), n);
}
/*
* call-seq:
- * Module.nesting -> array
+ * Module.nesting -> array
*
- * Returns the list of +Modules+ nested at the point of call.
+ * Returns nested module as an array of Module objects:
+ *
+ * module M0
+ * def self.speak = Module.nesting
+ * module M1
+ * def self.speak = Module.nesting
+ * module M2
+ * def self.speak = Module.nesting
+ * end
+ * end
+ * end
+ * M0.speak # => [M0]
+ * M0.speak.first.class # => Module
+ * M0::M1.speak # => [M0::M1, M0]
+ * M0::M1::M2.speak # => [M0::M1::M2, M0::M1, M0]
*
- * module M1
- * module M2
- * $a = Module.nesting
- * end
- * end
- * $a #=> [M1::M2, M1]
- * $a[0].name #=> "M1::M2"
*/
static VALUE
@@ -419,11 +419,11 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
return rb_const_list(data);
}
-/*!
- * Asserts that \a klass is not a frozen class.
- * \param[in] klass a \c Module object
- * \exception RuntimeError if \a klass is not a class or frozen.
- * \ingroup class
+/**
+ * Asserts that `klass` is not a frozen class.
+ * @param[in] klass a `Module` object
+ * @exception RuntimeError if `klass` is not a class or frozen.
+ * @ingroup class
*/
void
rb_class_modify_check(VALUE klass)
@@ -432,47 +432,18 @@ rb_class_modify_check(VALUE klass)
Check_Type(klass, T_CLASS);
}
if (RB_TYPE_P(klass, T_MODULE)) {
- rb_module_set_initialized(klass);
+ // TODO: shouldn't this only happen in a few places?
+ rb_class_set_initialized(klass);
}
if (OBJ_FROZEN(klass)) {
- const char *desc;
-
- if (FL_TEST(klass, FL_SINGLETON)) {
- desc = "object";
+ if (RCLASS_SINGLETON_P(klass)) {
klass = RCLASS_ATTACHED_OBJECT(klass);
- if (!SPECIAL_CONST_P(klass)) {
- switch (BUILTIN_TYPE(klass)) {
- case T_MODULE:
- case T_ICLASS:
- desc = "Module";
- break;
- case T_CLASS:
- desc = "Class";
- break;
- default:
- break;
- }
- }
- }
- else {
- switch (BUILTIN_TYPE(klass)) {
- case T_MODULE:
- case T_ICLASS:
- desc = "module";
- break;
- case T_CLASS:
- desc = "class";
- break;
- default:
- Check_Type(klass, T_CLASS);
- UNREACHABLE;
- }
}
- rb_frozen_error_raise(klass, "can't modify frozen %s: %"PRIsVALUE, desc, klass);
+ rb_error_frozen_object(klass);
}
}
-NORETURN(static void rb_longjmp(rb_execution_context_t *, int, volatile VALUE, VALUE));
+NORETURN(static void rb_longjmp(rb_execution_context_t *, enum ruby_tag_type, volatile VALUE, VALUE));
static VALUE get_errinfo(void);
#define get_ec_errinfo(ec) rb_ec_get_errinfo(ec)
@@ -539,10 +510,14 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
rb_exc_check_circular_cause(*cause);
#else
VALUE c = *cause;
- while (!NIL_P(c = rb_attr_get(c, id_cause))) {
+ while (!NIL_P(c)) {
if (c == mesg) {
rb_raise(rb_eArgError, "circular causes");
}
+ if (THROW_DATA_P(c)) {
+ break;
+ }
+ c = rb_attr_get(c, id_cause);
}
#endif
}
@@ -550,7 +525,7 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
}
static void
-setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause)
+setup_exception(rb_execution_context_t *ec, enum ruby_tag_type tag, volatile VALUE mesg, VALUE cause)
{
VALUE e;
int line;
@@ -598,15 +573,15 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
e = rb_obj_as_string(mesg);
ec->errinfo = mesg;
if (file && line) {
- e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
+ e = rb_sprintf("Exception '%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
rb_obj_class(mesg), file, line, e);
}
else if (file) {
- e = rb_sprintf("Exception `%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
+ e = rb_sprintf("Exception '%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
rb_obj_class(mesg), file, e);
}
else {
- e = rb_sprintf("Exception `%"PRIsVALUE"' - %"PRIsVALUE"\n",
+ e = rb_sprintf("Exception '%"PRIsVALUE"' - %"PRIsVALUE"\n",
rb_obj_class(mesg), e);
}
warn_print_str(e);
@@ -645,12 +620,16 @@ rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause)
cause = get_ec_errinfo(ec);
}
if (cause != mesg) {
+ if (THROW_DATA_P(cause)) {
+ cause = Qnil;
+ }
+
rb_ivar_set(mesg, id_cause, cause);
}
}
static void
-rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause)
+rb_longjmp(rb_execution_context_t *ec, enum ruby_tag_type tag, volatile VALUE mesg, VALUE cause)
{
mesg = exc_setup_message(ec, mesg, &cause);
setup_exception(ec, tag, mesg, cause);
@@ -660,10 +639,10 @@ rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause
static VALUE make_exception(int argc, const VALUE *argv, int isstr);
-NORETURN(static void rb_exc_exception(VALUE mesg, int tag, VALUE cause));
+NORETURN(static void rb_exc_exception(VALUE mesg, enum ruby_tag_type tag, VALUE cause));
static void
-rb_exc_exception(VALUE mesg, int tag, VALUE cause)
+rb_exc_exception(VALUE mesg, enum ruby_tag_type tag, VALUE cause)
{
if (!NIL_P(mesg)) {
mesg = make_exception(1, &mesg, FALSE);
@@ -671,12 +650,12 @@ rb_exc_exception(VALUE mesg, int tag, VALUE cause)
rb_longjmp(GET_EC(), tag, mesg, cause);
}
-/*!
+/**
* Raises an exception in the current thread.
- * \param[in] mesg an Exception class or an \c Exception object.
- * \exception always raises an instance of the given exception class or
- * the given \c Exception object.
- * \ingroup exception
+ * @param[in] mesg an Exception class or an `Exception` object.
+ * @exception always raises an instance of the given exception class or
+ * the given `Exception` object.
+ * @ingroup exception
*/
void
rb_exc_raise(VALUE mesg)
@@ -703,80 +682,257 @@ rb_interrupt(void)
rb_exc_raise(rb_exc_new(rb_eInterrupt, 0, 0));
}
-enum {raise_opt_cause, raise_max_opt}; /*< \private */
-
static int
-extract_raise_opts(int argc, VALUE *argv, VALUE *opts)
+extract_raise_options(int argc, VALUE *argv, VALUE *cause)
{
- int i;
+ // Keyword arguments:
+ static ID keywords[1] = {0};
+ if (!keywords[0]) {
+ CONST_ID(keywords[0], "cause");
+ }
+
if (argc > 0) {
- VALUE opt;
- argc = rb_scan_args(argc, argv, "*:", NULL, &opt);
- if (!NIL_P(opt)) {
- if (!RHASH_EMPTY_P(opt)) {
- ID keywords[1];
- CONST_ID(keywords[0], "cause");
- rb_get_kwargs(opt, keywords, 0, -1-raise_max_opt, opts);
- if (!RHASH_EMPTY_P(opt)) argv[argc++] = opt;
- return argc;
+ VALUE options;
+ argc = rb_scan_args(argc, argv, "*:", NULL, &options);
+
+ if (!NIL_P(options)) {
+ if (!RHASH_EMPTY_P(options)) {
+ // Extract optional cause keyword argument, leaving any other options alone:
+ rb_get_kwargs(options, keywords, 0, -2, cause);
+
+ // If there were any other options, add them back to the arguments:
+ if (!RHASH_EMPTY_P(options)) argv[argc++] = options;
}
}
}
- for (i = 0; i < raise_max_opt; ++i) {
- opts[i] = Qundef;
- }
+
return argc;
}
+/**
+ * Complete exception setup for cross-context raises (Thread#raise, Fiber#raise).
+ * Handles keyword extraction, validation, exception creation, and cause assignment.
+ *
+ * @param[in] argc Number of arguments
+ * @param[in] argv Argument array (will be modified for keyword extraction)
+ * @return Prepared exception object with cause applied
+ */
+VALUE
+rb_exception_setup(int argc, VALUE *argv)
+{
+ rb_execution_context_t *ec = GET_EC();
+
+ // Extract cause keyword argument:
+ VALUE cause = Qundef;
+ argc = extract_raise_options(argc, argv, &cause);
+
+ // Validate cause-only case:
+ if (argc == 0 && !UNDEF_P(cause)) {
+ rb_raise(rb_eArgError, "only cause is given with no arguments");
+ }
+
+ // Create exception:
+ VALUE exception;
+ if (argc == 0) {
+ exception = rb_exc_new(rb_eRuntimeError, 0, 0);
+ }
+ else {
+ exception = rb_make_exception(argc, argv);
+ }
+
+ VALUE resolved_cause = Qnil;
+
+ // Resolve cause with validation:
+ if (UNDEF_P(cause)) {
+ // No explicit cause - use automatic cause chaining from calling context:
+ resolved_cause = rb_ec_get_errinfo(ec);
+
+ // Prevent self-referential cause (e.g. `raise $!`):
+ if (resolved_cause == exception) {
+ resolved_cause = Qnil;
+ }
+ }
+ else if (NIL_P(cause)) {
+ // Explicit nil cause - prevent chaining:
+ resolved_cause = Qnil;
+ }
+ else {
+ // Explicit cause - validate and assign:
+ if (!rb_obj_is_kind_of(cause, rb_eException)) {
+ rb_raise(rb_eTypeError, "exception object expected");
+ }
+
+ if (cause == exception) {
+ // Prevent self-referential cause (e.g. `raise error, cause: error`) - although I'm not sure this is good behaviour, it's inherited from `Kernel#raise`.
+ resolved_cause = Qnil;
+ }
+ else {
+ // Check for circular causes:
+ VALUE current_cause = cause;
+ while (!NIL_P(current_cause)) {
+ // We guarantee that the cause chain is always terminated. Then, creating an exception with an existing cause is not circular as long as exception is not an existing cause of any other exception.
+ if (current_cause == exception) {
+ rb_raise(rb_eArgError, "circular causes");
+ }
+ if (THROW_DATA_P(current_cause)) {
+ break;
+ }
+ current_cause = rb_attr_get(current_cause, id_cause);
+ }
+ resolved_cause = cause;
+ }
+ }
+
+ // Apply cause to exception object (duplicate if frozen):
+ if (!UNDEF_P(resolved_cause)) {
+ if (OBJ_FROZEN(exception)) {
+ exception = rb_obj_dup(exception);
+ }
+ rb_ivar_set(exception, id_cause, resolved_cause);
+ }
+
+ return exception;
+}
+
VALUE
rb_f_raise(int argc, VALUE *argv)
{
- VALUE err;
- VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause];
+ VALUE cause = Qundef;
+ argc = extract_raise_options(argc, argv, &cause);
+
+ VALUE exception;
- argc = extract_raise_opts(argc, argv, opts);
+ // Bare re-raise case:
if (argc == 0) {
- if (!UNDEF_P(*cause)) {
+ // Cause was extracted, but no arguments were provided:
+ if (!UNDEF_P(cause)) {
rb_raise(rb_eArgError, "only cause is given with no arguments");
}
- err = get_errinfo();
- if (!NIL_P(err)) {
+
+ // Otherwise, re-raise the current exception:
+ exception = get_errinfo();
+ if (!NIL_P(exception)) {
argc = 1;
- argv = &err;
+ argv = &exception;
}
}
- rb_raise_jump(rb_make_exception(argc, argv), *cause);
+
+ rb_raise_jump(rb_make_exception(argc, argv), cause);
UNREACHABLE_RETURN(Qnil);
}
/*
* call-seq:
- * raise
- * raise(string, cause: $!)
- * raise(exception [, string [, array]], cause: $!)
- * fail
- * fail(string, cause: $!)
- * fail(exception [, string [, array]], cause: $!)
- *
- * With no arguments, raises the exception in <code>$!</code> or raises
- * a RuntimeError if <code>$!</code> is +nil+. With a single +String+
- * argument, raises a +RuntimeError+ with the string as a message. Otherwise,
- * the first parameter should be an +Exception+ class (or another
- * object that returns an +Exception+ object when sent an +exception+
- * message). The optional second parameter sets the message associated with
- * the exception (accessible via Exception#message), and the third parameter
- * is an array of callback information (accessible via Exception#backtrace).
- * The +cause+ of the generated exception (accessible via Exception#cause)
- * is automatically set to the "current" exception (<code>$!</code>), if any.
- * An alternative value, either an +Exception+ object or +nil+, can be
- * specified via the +:cause+ argument.
- *
- * Exceptions are caught by the +rescue+ clause of
- * <code>begin...end</code> blocks.
- *
- * raise "Failed to create socket"
- * raise ArgumentError, "No parameters", caller
+ * raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
+ * raise(message = nil, cause: $!)
+ *
+ * Raises an exception;
+ * see {Exceptions}[rdoc-ref:exceptions.md].
+ *
+ * Argument +exception+ sets the class of the new exception;
+ * it should be class Exception or one of its subclasses
+ * (most commonly, RuntimeError or StandardError),
+ * or an instance of one of those classes:
+ *
+ * begin
+ * raise(StandardError)
+ * rescue => x
+ * p x.class
+ * end
+ * # => StandardError
+ *
+ * Argument +message+ sets the stored message in the new exception,
+ * which may be retrieved by method Exception#message;
+ * the message must be
+ * a {string-convertible object}[rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects]
+ * or +nil+:
+ *
+ * begin
+ * raise(StandardError, 'Boom')
+ * rescue => x
+ * p x.message
+ * end
+ * # => "Boom"
+ *
+ * If argument +message+ is not given,
+ * the message is the exception class name.
+ *
+ * See {Messages}[rdoc-ref:exceptions.md@Messages].
+ *
+ * Argument +backtrace+ might be used to modify the backtrace of the new exception,
+ * as reported by Exception#backtrace and Exception#backtrace_locations;
+ * the backtrace must be an array of Thread::Backtrace::Location, an array of
+ * strings, a single string, or +nil+.
+ *
+ * Using the array of Thread::Backtrace::Location instances is the most consistent option
+ * and should be preferred when possible. The necessary value might be obtained
+ * from #caller_locations, or copied from Exception#backtrace_locations of another
+ * error:
+ *
+ * begin
+ * do_some_work()
+ * rescue ZeroDivisionError => ex
+ * raise(LogicalError, "You have an error in your math", ex.backtrace_locations)
+ * end
+ *
+ * The ways, both Exception#backtrace and Exception#backtrace_locations of the
+ * raised error are set to the same backtrace.
+ *
+ * When the desired stack of locations is not available and should
+ * be constructed from scratch, an array of strings or a singular
+ * string can be used. In this case, only Exception#backtrace is set:
+ *
+ * begin
+ * raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1])
+ * rescue => ex
+ * p ex.backtrace
+ * # => ["dsl.rb:3", "framework.rb:1"]
+ * p ex.backtrace_locations
+ * # => nil
+ * end
+ *
+ * If argument +backtrace+ is not given,
+ * the backtrace is set according to an array of Thread::Backtrace::Location objects,
+ * as derived from the call stack.
+ *
+ * See {Backtraces}[rdoc-ref:exceptions.md@Backtraces].
+ *
+ * Keyword argument +cause+ sets the stored cause in the new exception,
+ * which may be retrieved by method Exception#cause;
+ * the cause must be an exception object (Exception or one of its subclasses),
+ * or +nil+:
+ *
+ * begin
+ * raise(StandardError, cause: RuntimeError.new)
+ * rescue => x
+ * p x.cause
+ * end
+ * # => #<RuntimeError: RuntimeError>
+ *
+ * If keyword argument +cause+ is not given,
+ * the cause is the value of <tt>$!</tt>.
+ *
+ * See {Cause}[rdoc-ref:exceptions.md@Cause].
+ *
+ * In the alternate calling sequence,
+ * where argument +exception+ _not_ given,
+ * raises a new exception of the class given by <tt>$!</tt>,
+ * or of class RuntimeError if <tt>$!</tt> is +nil+:
+ *
+ * begin
+ * raise
+ * rescue => x
+ * p x
+ * end
+ * # => RuntimeError
+ *
+ * With argument +exception+ not given,
+ * argument +message+ and keyword argument +cause+ may be given,
+ * but argument +backtrace+ may not be given.
+ *
+ * +cause+ can not be given as an only argument.
+ *
*/
static VALUE
@@ -976,7 +1132,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- SAVE_ROOT_JMPBUF(rb_ec_thread_ptr(ec), result = (*proc) (data));
+ result = (*proc)(data);
}
else {
rb_vm_rewind_cfp(ec, cfp);
@@ -988,18 +1144,11 @@ rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
}
VALUE
-rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2)
+rb_ec_ensure(rb_execution_context_t *ec, VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2)
{
- int state;
+ enum ruby_tag_type state;
volatile VALUE result = Qnil;
VALUE errinfo;
- rb_execution_context_t * volatile ec = GET_EC();
- rb_ensure_list_t ensure_list;
- ensure_list.entry.marker = 0;
- ensure_list.entry.e_proc = e_proc;
- ensure_list.entry.data2 = data2;
- ensure_list.next = ec->ensure_list;
- ec->ensure_list = &ensure_list;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
result = (*b_proc) (data1);
@@ -1009,14 +1158,19 @@ rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE dat
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
ec->errinfo = Qnil;
}
- ec->ensure_list=ensure_list.next;
- (*ensure_list.entry.e_proc)(ensure_list.entry.data2);
+ (*e_proc)(data2);
ec->errinfo = errinfo;
if (state)
EC_JUMP_TAG(ec, state);
return result;
}
+VALUE
+rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2)
+{
+ return rb_ec_ensure(GET_EC(), b_proc, data1, e_proc, data2);
+}
+
static ID
frame_func_id(const rb_control_frame_t *cfp)
{
@@ -1124,6 +1278,8 @@ rb_mod_append_features(VALUE module, VALUE include)
return module;
}
+static VALUE refinement_import_methods(int argc, VALUE *argv, VALUE refinement);
+
/*
* call-seq:
* include(module, ...) -> self
@@ -1277,16 +1433,12 @@ rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
}
superclass = refinement_superclass(superclass);
c = iclass = rb_include_class_new(module, superclass);
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ RCLASS_SET_REFINED_CLASS(c, klass);
- RCLASS_M_TBL(c) = RCLASS_M_TBL(module);
+ RCLASS_WRITE_M_TBL(c, RCLASS_M_TBL(module));
+
+ rb_class_subclass_add(klass, iclass);
- module = RCLASS_SUPER(module);
- while (module && module != klass) {
- c = RCLASS_SET_SUPER(c, rb_include_class_new(module, RCLASS_SUPER(c)));
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
- module = RCLASS_SUPER(module);
- }
rb_hash_aset(CREF_REFINEMENTS(cref), klass, iclass);
}
@@ -1337,14 +1489,27 @@ rb_using_module(const rb_cref_t *cref, VALUE module)
{
Check_Type(module, T_MODULE);
using_module_recursive(cref, module);
- rb_clear_method_cache_all();
+ rb_clear_all_refinement_method_cache();
+}
+
+void
+rb_vm_using_module(VALUE module)
+{
+ rb_using_module(rb_vm_cref_replace_with_duplicated_cref(), module);
}
/*
* call-seq:
- * refined_class -> class
+ * target -> class_or_module
+ *
+ * Return the class or module refined by the receiver.
*
- * Return the class refined by the receiver.
+ * module M
+ * refine String do
+ * end
+ * end
+ *
+ * M.refinements[0].target # => String
*/
VALUE
rb_refinement_module_get_refined_class(VALUE module)
@@ -1373,43 +1538,26 @@ add_activated_refinement(VALUE activated_refinements,
}
superclass = refinement_superclass(superclass);
c = iclass = rb_include_class_new(refinement, superclass);
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ RCLASS_SET_REFINED_CLASS(c, klass);
+ rb_class_subclass_add(klass, iclass);
refinement = RCLASS_SUPER(refinement);
while (refinement && refinement != klass) {
- c = RCLASS_SET_SUPER(c, rb_include_class_new(refinement, RCLASS_SUPER(c)));
- RB_OBJ_WRITE(c, &RCLASS_REFINED_CLASS(c), klass);
+ c = rb_class_set_super(c, rb_include_class_new(refinement, RCLASS_SUPER(c)));
+ RCLASS_SET_REFINED_CLASS(c, klass);
+ rb_class_subclass_add(klass, c);
refinement = RCLASS_SUPER(refinement);
}
rb_hash_aset(activated_refinements, klass, iclass);
}
-/*
- * call-seq:
- * refine(mod) { block } -> module
- *
- * Refine <i>mod</i> in the receiver.
- *
- * Returns a module, where refined methods are defined.
- */
-
-static VALUE
-rb_mod_refine(VALUE module, VALUE klass)
+void
+rb_refinement_setup(struct rb_refinements_data *data, VALUE module, VALUE klass)
{
VALUE refinement;
ID id_refinements, id_activated_refinements,
id_refined_class, id_defined_at;
VALUE refinements, activated_refinements;
- rb_thread_t *th = GET_THREAD();
- VALUE block_handler = rb_vm_frame_block_handler(th->ec->cfp);
- if (block_handler == VM_BLOCK_HANDLER_NONE) {
- rb_raise(rb_eArgError, "no block given");
- }
- if (vm_block_handler_type(block_handler) != block_handler_type_iseq) {
- rb_raise(rb_eArgError, "can't pass a Proc as a block to Module#refine");
- }
-
- ensure_class_or_module(klass);
CONST_ID(id_refinements, "__refinements__");
refinements = rb_attr_get(module, id_refinements);
if (NIL_P(refinements)) {
@@ -1427,7 +1575,7 @@ rb_mod_refine(VALUE module, VALUE klass)
if (NIL_P(refinement)) {
VALUE superclass = refinement_superclass(klass);
refinement = rb_refinement_new();
- RCLASS_SET_SUPER(refinement, superclass);
+ rb_class_set_super(refinement, superclass);
RUBY_ASSERT(BUILTIN_TYPE(refinement) == T_MODULE);
FL_SET(refinement, RMODULE_IS_REFINEMENT);
CONST_ID(id_refined_class, "__refined_class__");
@@ -1437,8 +1585,41 @@ rb_mod_refine(VALUE module, VALUE klass)
rb_hash_aset(refinements, klass, refinement);
add_activated_refinement(activated_refinements, klass, refinement);
}
- rb_yield_refine_block(refinement, activated_refinements);
- return refinement;
+
+ data->refinement = refinement;
+ data->refinements = activated_refinements;
+}
+
+/*
+ * call-seq:
+ * refine(mod) { block } -> module
+ *
+ * Refine <i>mod</i> in the receiver.
+ *
+ * Returns a module, where refined methods are defined.
+ */
+
+static VALUE
+rb_mod_refine(VALUE module, VALUE klass)
+{
+ /* module is the receiver of #refine, klass is a module to be refined (`mod` in the doc) */
+ rb_thread_t *th = GET_THREAD();
+ VALUE block_handler = rb_vm_frame_block_handler(th->ec->cfp);
+ struct rb_refinements_data data;
+
+ if (block_handler == VM_BLOCK_HANDLER_NONE) {
+ rb_raise(rb_eArgError, "no block given");
+ }
+ if (vm_block_handler_type(block_handler) != block_handler_type_iseq) {
+ rb_raise(rb_eArgError, "can't pass a Proc as a block to Module#refine");
+ }
+
+ ensure_class_or_module(klass);
+
+ rb_refinement_setup(&data, module, klass);
+
+ rb_yield_refine_block(data.refinement, data.refinements);
+ return data.refinement;
}
static void
@@ -1484,7 +1665,7 @@ mod_using(VALUE self, VALUE module)
* call-seq:
* refinements -> array
*
- * Returns an array of modules defined within the receiver.
+ * Returns an array of +Refinement+ defined within the receiver.
*
* module A
* refine Integer do
@@ -1771,6 +1952,16 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
return obj;
}
+VALUE
+rb_top_main_class(const char *method)
+{
+ VALUE klass = GET_THREAD()->top_wrapper;
+
+ if (!klass) return rb_cObject;
+ rb_warning("main.%s in the wrapped load is effective only in wrapper module", method);
+ return klass;
+}
+
/*
* call-seq:
* include(module, ...) -> self
@@ -1783,13 +1974,7 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
static VALUE
top_include(int argc, VALUE *argv, VALUE self)
{
- rb_thread_t *th = GET_THREAD();
-
- 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);
- }
- return rb_mod_include(argc, argv, rb_cObject);
+ return rb_mod_include(argc, argv, rb_top_main_class("include"));
}
/*
@@ -1803,7 +1988,7 @@ top_include(int argc, VALUE *argv, VALUE self)
static VALUE
top_using(VALUE self, VALUE module)
{
- const rb_cref_t *cref = CREF_NEXT(rb_vm_cref());;
+ const rb_cref_t *cref = CREF_NEXT(rb_vm_cref());
rb_control_frame_t *prev_cfp = previous_frame(GET_EC());
rb_thread_t *th = GET_THREAD();
@@ -1826,10 +2011,10 @@ errinfo_place(const rb_execution_context_t *ec)
while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
if (VM_FRAME_RUBYFRAME_P(cfp)) {
- if (ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_RESCUE) {
+ if (ISEQ_BODY(CFP_ISEQ(cfp))->type == ISEQ_TYPE_RESCUE) {
return &cfp->ep[VM_ENV_INDEX_LAST_LVAR];
}
- else if (ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_ENSURE &&
+ else if (ISEQ_BODY(CFP_ISEQ(cfp))->type == ISEQ_TYPE_ENSURE &&
!THROW_DATA_P(cfp->ep[VM_ENV_INDEX_LAST_LVAR]) &&
!FIXNUM_P(cfp->ep[VM_ENV_INDEX_LAST_LVAR])) {
return &cfp->ep[VM_ENV_INDEX_LAST_LVAR];
@@ -1996,7 +2181,7 @@ f_global_variables(VALUE _)
* +Proc+ object) or block is executed whenever the variable
* is assigned. The block or +Proc+ object receives the
* variable's new value as a parameter. Also see
- * Kernel::untrace_var.
+ * #untrace_var.
*
* trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
* $_ = "hello"
@@ -2039,6 +2224,9 @@ Init_eval(void)
rb_gvar_ractor_local("$@");
rb_gvar_ractor_local("$!");
+ rb_gvar_box_dynamic("$@");
+ rb_gvar_box_dynamic("$!");
+
rb_define_global_function("raise", f_raise, -1);
rb_define_global_function("fail", f_raise, -1);
@@ -2063,7 +2251,7 @@ Init_eval(void)
rb_mod_s_used_refinements, 0);
rb_undef_method(rb_cClass, "refine");
rb_define_private_method(rb_cRefinement, "import_methods", refinement_import_methods, -1);
- rb_define_method(rb_cRefinement, "refined_class", rb_refinement_module_get_refined_class, 0);
+ rb_define_method(rb_cRefinement, "target", rb_refinement_module_get_refined_class, 0);
rb_undef_method(rb_cRefinement, "append_features");
rb_undef_method(rb_cRefinement, "prepend_features");
rb_undef_method(rb_cRefinement, "extend_object");
@@ -2092,3 +2280,21 @@ Init_eval(void)
id_signo = rb_intern_const("signo");
id_status = rb_intern_const("status");
}
+
+int
+rb_errno(void)
+{
+ return *rb_orig_errno_ptr();
+}
+
+void
+rb_errno_set(int e)
+{
+ *rb_orig_errno_ptr() = e;
+}
+
+int *
+rb_errno_ptr(void)
+{
+ return rb_orig_errno_ptr();
+}
diff --git a/eval_error.c b/eval_error.c
index 948a205dd9..f3d05a1043 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -7,6 +7,8 @@
(NIL_P(str) ? warn_print(x) : (void)rb_str_cat_cstr(str, x))
#define write_warn2(str, x, l) \
(NIL_P(str) ? warn_print2(x, l) : (void)rb_str_cat(str, x, l))
+#define write_warn_enc(str, x, l, enc) \
+ (NIL_P(str) ? warn_print2(x, l) : (void)rb_enc_str_buf_cat(str, x, l, enc))
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
#define warn_print(x) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(x)) ? \
@@ -45,7 +47,7 @@ error_pos_str(void)
return rb_sprintf("%"PRIsVALUE": ", sourcefile);
}
else if ((caller_name = rb_frame_callee()) != 0) {
- return rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"': ",
+ return rb_sprintf("%"PRIsVALUE":%d:in '%"PRIsVALUE"': ",
sourcefile, sourceline,
rb_id2str(caller_name));
}
@@ -103,7 +105,7 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
if (highlight) write_warn(str, underline);
write_warn(str, "unhandled exception");
if (highlight) write_warn(str, reset);
- write_warn2(str, "\n", 1);
+ write_warn(str, "\n");
}
else {
VALUE epath;
@@ -123,17 +125,21 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
}
VALUE
-rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
+rb_decorate_message(const VALUE eclass, VALUE emesg, int highlight)
{
const char *einfo = "";
long elen = 0;
+ rb_encoding *eenc;
- VALUE str = rb_str_new2("");
+ VALUE str = rb_usascii_str_new_cstr("");
- if (!NIL_P(emesg)) {
+ if (!NIL_P(emesg) && rb_enc_asciicompat(eenc = rb_enc_get(emesg))) {
einfo = RSTRING_PTR(emesg);
elen = RSTRING_LEN(emesg);
}
+ else {
+ eenc = NULL;
+ }
if (eclass == rb_eRuntimeError && elen == 0) {
if (highlight) write_warn(str, underline);
write_warn(str, "unhandled exception");
@@ -156,7 +162,7 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
if (RSTRING_PTR(epath)[0] == '#')
epath = 0;
if ((tail = memchr(einfo, '\n', elen)) != 0) {
- write_warn2(str, einfo, tail - einfo);
+ write_warn_enc(str, einfo, tail - einfo, eenc);
tail++; /* skip newline */
}
else {
@@ -170,23 +176,23 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
write_warn(str, reset);
write_warn(str, bold);
}
- write_warn2(str, ")", 1);
+ write_warn(str, ")");
if (highlight) write_warn(str, reset);
}
if (tail && einfo+elen > tail) {
if (!highlight) {
- write_warn2(str, "\n", 1);
- write_warn2(str, tail, einfo+elen-tail);
+ write_warn(str, "\n");
+ write_warn_enc(str, tail, einfo+elen-tail, eenc);
}
else {
elen -= tail - einfo;
einfo = tail;
- write_warn2(str, "\n", 1);
+ write_warn(str, "\n");
while (elen > 0) {
tail = memchr(einfo, '\n', elen);
if (!tail || tail > einfo) {
write_warn(str, bold);
- write_warn2(str, einfo, tail ? tail-einfo : elen);
+ write_warn_enc(str, einfo, tail ? tail-einfo : elen, eenc);
write_warn(str, reset);
if (!tail) {
break;
@@ -195,7 +201,7 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
elen -= tail - einfo;
einfo = tail;
do ++tail; while (tail < einfo+elen && *tail == '\n');
- write_warn2(str, einfo, tail-einfo);
+ write_warn_enc(str, einfo, tail-einfo, eenc);
elen -= tail - einfo;
einfo = tail;
}
@@ -204,6 +210,8 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
}
}
+ RB_GC_GUARD(emesg);
+
return str;
}
@@ -384,7 +392,7 @@ rb_ec_error_print(rb_execution_context_t *volatile ec, volatile VALUE errinfo)
rb_ec_error_print_detailed(ec, errinfo, Qnil, Qundef);
}
-#define undef_mesg_for(v, k) rb_fstring_lit("undefined"v" method `%1$s' for "k" `%2$s'")
+#define undef_mesg_for(v, k) rb_fstring_lit("undefined"v" method '%1$s' for "k" '%2$s'")
#define undef_mesg(v) ( \
is_mod ? \
undef_mesg_for(v, "module") : \
@@ -412,7 +420,7 @@ rb_print_undef_str(VALUE klass, VALUE name)
rb_name_err_raise_str(undef_mesg(""), klass, name);
}
-#define inaccessible_mesg_for(v, k) rb_fstring_lit("method `%1$s' for "k" `%2$s' is "v)
+#define inaccessible_mesg_for(v, k) rb_fstring_lit("method '%1$s' for "k" '%2$s' is "v)
#define inaccessible_mesg(v) ( \
is_mod ? \
inaccessible_mesg_for(v, "module") : \
@@ -455,7 +463,12 @@ exiting_split(VALUE errinfo, volatile int *exitcode, volatile int *sigstatus)
if (NIL_P(errinfo)) return 0;
- if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
+ if (THROW_DATA_P(errinfo)) {
+ int throw_state = ((const struct vm_throw_data *)errinfo)->throw_state;
+ ex = throw_state & VM_THROW_STATE_MASK;
+ result |= EXITING_WITH_STATUS;
+ }
+ else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
ex = sysexit_status(errinfo);
result |= EXITING_WITH_STATUS;
}
diff --git a/eval_intern.h b/eval_intern.h
index 6cbaa51361..954ba6a184 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -3,6 +3,7 @@
#include "ruby/ruby.h"
#include "vm_core.h"
+#include "zjit.h"
static inline void
vm_passed_block_handler_set(rb_execution_context_t *ec, VALUE block_handler)
@@ -95,14 +96,6 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
#include <sys/stat.h>
-
-#define SAVE_ROOT_JMPBUF(th, stmt) do \
- if (true) { \
- stmt; \
- } \
- else if (th) { /* suppress unused-variable warning */ \
- } while (0)
-
#define EC_PUSH_TAG(ec) do { \
rb_execution_context_t * const _ec = (ec); \
struct rb_vm_tag _tag; \
@@ -110,9 +103,21 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
_tag.tag = Qundef; \
_tag.prev = _ec->tag; \
_tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
+ EC_SAVE_TAG_CFP(_tag, _ec); \
+ rb_vm_tag_jmpbuf_init(&_tag.buf); \
+
+// Remember the CFP as of EC_PUSH_TAG so that ZJIT can materialize frames
+// only up to longjmp's target CFP. When a C method does longjmp inside it,
+// the target CFP may not be equal to the VM_FRAME_FLAG_FINISH frame.
+#if USE_ZJIT
+# define EC_SAVE_TAG_CFP(_tag, _ec) _tag.cfp = _ec->cfp
+#else
+# define EC_SAVE_TAG_CFP(_tag, _ec)
+#endif
#define EC_POP_TAG() \
_ec->tag = _tag.prev; \
+ rb_vm_tag_jmpbuf_deinit(&_tag.buf); \
} while (0)
#define EC_TMPPOP_TAG() \
@@ -151,6 +156,8 @@ rb_ec_tag_state(const rb_execution_context_t *ec)
enum ruby_tag_type state = tag->state;
tag->state = TAG_NONE;
rb_ec_vm_lock_rec_check(ec, tag->lock_rec);
+ RBIMPL_ASSUME(state > TAG_NONE);
+ RBIMPL_ASSUME(state <= TAG_FATAL);
return state;
}
@@ -158,8 +165,12 @@ NORETURN(static inline void rb_ec_tag_jump(const rb_execution_context_t *ec, enu
static inline void
rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
{
+ RUBY_ASSERT(st > TAG_NONE && st <= TAG_FATAL, ": Invalid tag jump: %d", (int)st);
+#if USE_ZJIT
+ rb_zjit_materialize_frames(ec, ec->cfp);
+#endif
ec->tag->state = st;
- ruby_longjmp(ec->tag->buf, 1);
+ ruby_longjmp(RB_VM_TAG_JMPBUF_GET(ec->tag->buf), 1);
}
/*
@@ -167,7 +178,7 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
[ISO/IEC 9899:1999] 7.13.1.1
*/
#define EC_EXEC_TAG() \
- (ruby_setjmp(_tag.buf) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
+ (UNLIKELY(ruby_setjmp(RB_VM_TAG_JMPBUF_GET(_tag.buf))) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
#define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)
@@ -175,9 +186,10 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
/* CREF operators */
-#define CREF_FL_PUSHED_BY_EVAL IMEMO_FL_USER1
-#define CREF_FL_OMOD_SHARED IMEMO_FL_USER2
-#define CREF_FL_SINGLETON IMEMO_FL_USER3
+#define CREF_FL_PUSHED_BY_EVAL IMEMO_FL_USER1
+#define CREF_FL_OMOD_SHARED IMEMO_FL_USER2
+#define CREF_FL_SINGLETON IMEMO_FL_USER3
+#define CREF_FL_DYNAMIC_CREF IMEMO_FL_USER4
static inline int CREF_SINGLETON(const rb_cref_t *cref);
@@ -263,6 +275,18 @@ CREF_OMOD_SHARED_SET(rb_cref_t *cref)
cref->flags |= CREF_FL_OMOD_SHARED;
}
+static inline int
+CREF_DYNAMIC(const rb_cref_t *cref)
+{
+ return cref->flags & CREF_FL_DYNAMIC_CREF;
+}
+
+static inline void
+CREF_DYNAMIC_SET(rb_cref_t *cref)
+{
+ cref->flags |= CREF_FL_DYNAMIC_CREF;
+}
+
static inline void
CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
{
@@ -293,16 +317,23 @@ NORETURN(void rb_print_undef(VALUE, ID, rb_method_visibility_t));
NORETURN(void rb_print_undef_str(VALUE, VALUE));
NORETURN(void rb_print_inaccessible(VALUE, ID, rb_method_visibility_t));
NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
-NORETURN(void rb_vm_jump_tag_but_local_jump(int));
+NORETURN(void rb_vm_jump_tag_but_local_jump(enum ruby_tag_type));
-VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
+VALUE rb_vm_make_jump_tag_but_local_jump(enum ruby_tag_type state, VALUE val);
rb_cref_t *rb_vm_cref(void);
rb_cref_t *rb_vm_cref_replace_with_duplicated_cref(void);
VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, VALUE block_handler, VALUE filename);
+VALUE rb_vm_call_cfunc_in_box(VALUE recv, VALUE (*func)(VALUE, VALUE), VALUE arg1, VALUE arg2, VALUE filename, const rb_box_t *box);
+void rb_vm_frame_flag_set_box_require(const rb_execution_context_t *ec);
+const rb_box_t *rb_vm_current_box(const rb_execution_context_t *ec);
+const rb_box_t *rb_vm_caller_box(const rb_execution_context_t *ec);
+const rb_box_t *rb_vm_loading_box(const rb_execution_context_t *ec);
void rb_vm_set_progname(VALUE filename);
VALUE rb_vm_cbase(void);
/* vm_backtrace.c */
+#define RUBY_BACKTRACE_START 0
+#define RUBY_ALL_BACKTRACE_LINES -1
VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec);
VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n);
VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n, bool skip_internal);
@@ -324,16 +355,4 @@ rb_char_next(const char *p)
# endif
#endif
-#if defined DOSISH || defined __CYGWIN__
-static inline void
-translit_char(char *p, int from, int to)
-{
- while (*p) {
- if ((unsigned char)*p == from)
- *p = to;
- p = CharNext(p);
- }
-}
-#endif
-
#endif /* RUBY_EVAL_INTERN_H */
diff --git a/eval_jump.c b/eval_jump.c
index e8e74f4e70..6ee8ff4a6f 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -101,7 +101,7 @@ exec_end_procs_chain(struct end_proc_data *volatile *procs, VALUE *errp)
while ((link = *procs) != 0) {
*procs = link->next;
endproc = *link;
- xfree(link);
+ SIZED_FREE(link);
(*endproc.func) (endproc.data);
*errp = errinfo;
}
@@ -112,21 +112,21 @@ rb_ec_exec_end_proc(rb_execution_context_t * ec)
{
enum ruby_tag_type state;
volatile VALUE errinfo = ec->errinfo;
-
- EC_PUSH_TAG(ec);
- if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- again:
- exec_end_procs_chain(&ephemeral_end_procs, &ec->errinfo);
- exec_end_procs_chain(&end_procs, &ec->errinfo);
- }
- else {
- EC_TMPPOP_TAG();
- error_handle(ec, ec->errinfo, state);
- if (!NIL_P(ec->errinfo)) errinfo = ec->errinfo;
- EC_REPUSH_TAG();
- goto again;
+ volatile bool finished = false;
+
+ while (!finished) {
+ EC_PUSH_TAG(ec);
+ if ((state = EC_EXEC_TAG()) == TAG_NONE) {
+ exec_end_procs_chain(&ephemeral_end_procs, &ec->errinfo);
+ exec_end_procs_chain(&end_procs, &ec->errinfo);
+ finished = true;
+ }
+ EC_POP_TAG();
+ if (state != TAG_NONE) {
+ error_handle(ec, ec->errinfo, state);
+ if (!NIL_P(ec->errinfo)) errinfo = ec->errinfo;
+ }
}
- EC_POP_TAG();
ec->errinfo = errinfo;
}
diff --git a/ext/-test-/RUBY_ALIGNOF/depend b/ext/-test-/RUBY_ALIGNOF/depend
index 3011b637e5..103d20b33c 100644
--- a/ext/-test-/RUBY_ALIGNOF/depend
+++ b/ext/-test-/RUBY_ALIGNOF/depend
@@ -128,6 +128,7 @@ c.o: $(hdrdir)/ruby/internal/intern/re.h
c.o: $(hdrdir)/ruby/internal/intern/ruby.h
c.o: $(hdrdir)/ruby/internal/intern/select.h
c.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+c.o: $(hdrdir)/ruby/internal/intern/set.h
c.o: $(hdrdir)/ruby/internal/intern/signal.h
c.o: $(hdrdir)/ruby/internal/intern/sprintf.h
c.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ c.o: $(hdrdir)/ruby/internal/special_consts.h
c.o: $(hdrdir)/ruby/internal/static_assert.h
c.o: $(hdrdir)/ruby/internal/stdalign.h
c.o: $(hdrdir)/ruby/internal/stdbool.h
+c.o: $(hdrdir)/ruby/internal/stdckdint.h
c.o: $(hdrdir)/ruby/internal/symbol.h
c.o: $(hdrdir)/ruby/internal/value.h
c.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/abi/depend b/ext/-test-/abi/depend
new file mode 100644
index 0000000000..716a7b1356
--- /dev/null
+++ b/ext/-test-/abi/depend
@@ -0,0 +1,3 @@
+# AUTOGENERATED DEPENDENCIES START
+abi.o: abi.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/arith_seq/beg_len_step/depend b/ext/-test-/arith_seq/beg_len_step/depend
index dc807eaa99..098c8ff1f0 100644
--- a/ext/-test-/arith_seq/beg_len_step/depend
+++ b/ext/-test-/arith_seq/beg_len_step/depend
@@ -127,6 +127,7 @@ beg_len_step.o: $(hdrdir)/ruby/internal/intern/re.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/ruby.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/select.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+beg_len_step.o: $(hdrdir)/ruby/internal/intern/set.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/signal.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/sprintf.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ beg_len_step.o: $(hdrdir)/ruby/internal/special_consts.h
beg_len_step.o: $(hdrdir)/ruby/internal/static_assert.h
beg_len_step.o: $(hdrdir)/ruby/internal/stdalign.h
beg_len_step.o: $(hdrdir)/ruby/internal/stdbool.h
+beg_len_step.o: $(hdrdir)/ruby/internal/stdckdint.h
beg_len_step.o: $(hdrdir)/ruby/internal/symbol.h
beg_len_step.o: $(hdrdir)/ruby/internal/value.h
beg_len_step.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/arith_seq/extract/depend b/ext/-test-/arith_seq/extract/depend
index 231736b277..5c07cea4b4 100644
--- a/ext/-test-/arith_seq/extract/depend
+++ b/ext/-test-/arith_seq/extract/depend
@@ -127,6 +127,7 @@ extract.o: $(hdrdir)/ruby/internal/intern/re.h
extract.o: $(hdrdir)/ruby/internal/intern/ruby.h
extract.o: $(hdrdir)/ruby/internal/intern/select.h
extract.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+extract.o: $(hdrdir)/ruby/internal/intern/set.h
extract.o: $(hdrdir)/ruby/internal/intern/signal.h
extract.o: $(hdrdir)/ruby/internal/intern/sprintf.h
extract.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ extract.o: $(hdrdir)/ruby/internal/special_consts.h
extract.o: $(hdrdir)/ruby/internal/static_assert.h
extract.o: $(hdrdir)/ruby/internal/stdalign.h
extract.o: $(hdrdir)/ruby/internal/stdbool.h
+extract.o: $(hdrdir)/ruby/internal/stdckdint.h
extract.o: $(hdrdir)/ruby/internal/symbol.h
extract.o: $(hdrdir)/ruby/internal/value.h
extract.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/array/concat/depend b/ext/-test-/array/concat/depend
index d66e7a540f..8edf45465f 100644
--- a/ext/-test-/array/concat/depend
+++ b/ext/-test-/array/concat/depend
@@ -128,6 +128,7 @@ to_ary_concat.o: $(hdrdir)/ruby/internal/intern/re.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/ruby.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/select.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+to_ary_concat.o: $(hdrdir)/ruby/internal/intern/set.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/signal.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/sprintf.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ to_ary_concat.o: $(hdrdir)/ruby/internal/special_consts.h
to_ary_concat.o: $(hdrdir)/ruby/internal/static_assert.h
to_ary_concat.o: $(hdrdir)/ruby/internal/stdalign.h
to_ary_concat.o: $(hdrdir)/ruby/internal/stdbool.h
+to_ary_concat.o: $(hdrdir)/ruby/internal/stdckdint.h
to_ary_concat.o: $(hdrdir)/ruby/internal/symbol.h
to_ary_concat.o: $(hdrdir)/ruby/internal/value.h
to_ary_concat.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/array/resize/depend b/ext/-test-/array/resize/depend
index a9c02b3db2..e6a228b43d 100644
--- a/ext/-test-/array/resize/depend
+++ b/ext/-test-/array/resize/depend
@@ -127,6 +127,7 @@ resize.o: $(hdrdir)/ruby/internal/intern/re.h
resize.o: $(hdrdir)/ruby/internal/intern/ruby.h
resize.o: $(hdrdir)/ruby/internal/intern/select.h
resize.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+resize.o: $(hdrdir)/ruby/internal/intern/set.h
resize.o: $(hdrdir)/ruby/internal/intern/signal.h
resize.o: $(hdrdir)/ruby/internal/intern/sprintf.h
resize.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ resize.o: $(hdrdir)/ruby/internal/special_consts.h
resize.o: $(hdrdir)/ruby/internal/static_assert.h
resize.o: $(hdrdir)/ruby/internal/stdalign.h
resize.o: $(hdrdir)/ruby/internal/stdbool.h
+resize.o: $(hdrdir)/ruby/internal/stdckdint.h
resize.o: $(hdrdir)/ruby/internal/symbol.h
resize.o: $(hdrdir)/ruby/internal/value.h
resize.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/bignum/depend b/ext/-test-/bignum/depend
index d4392bb6a1..82972f1032 100644
--- a/ext/-test-/bignum/depend
+++ b/ext/-test-/bignum/depend
@@ -6,6 +6,7 @@ big2str.o: $(hdrdir)/ruby/backward.h
big2str.o: $(hdrdir)/ruby/backward/2/assume.h
big2str.o: $(hdrdir)/ruby/backward/2/attributes.h
big2str.o: $(hdrdir)/ruby/backward/2/bool.h
+big2str.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
big2str.o: $(hdrdir)/ruby/backward/2/inttypes.h
big2str.o: $(hdrdir)/ruby/backward/2/limits.h
big2str.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -127,6 +128,7 @@ big2str.o: $(hdrdir)/ruby/internal/intern/re.h
big2str.o: $(hdrdir)/ruby/internal/intern/ruby.h
big2str.o: $(hdrdir)/ruby/internal/intern/select.h
big2str.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+big2str.o: $(hdrdir)/ruby/internal/intern/set.h
big2str.o: $(hdrdir)/ruby/internal/intern/signal.h
big2str.o: $(hdrdir)/ruby/internal/intern/sprintf.h
big2str.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +148,7 @@ big2str.o: $(hdrdir)/ruby/internal/special_consts.h
big2str.o: $(hdrdir)/ruby/internal/static_assert.h
big2str.o: $(hdrdir)/ruby/internal/stdalign.h
big2str.o: $(hdrdir)/ruby/internal/stdbool.h
+big2str.o: $(hdrdir)/ruby/internal/stdckdint.h
big2str.o: $(hdrdir)/ruby/internal/symbol.h
big2str.o: $(hdrdir)/ruby/internal/value.h
big2str.o: $(hdrdir)/ruby/internal/value_type.h
@@ -157,6 +160,7 @@ big2str.o: $(hdrdir)/ruby/ruby.h
big2str.o: $(hdrdir)/ruby/st.h
big2str.o: $(hdrdir)/ruby/subst.h
big2str.o: $(top_srcdir)/internal/bignum.h
+big2str.o: $(top_srcdir)/internal/compilers.h
big2str.o: big2str.c
bigzero.o: $(RUBY_EXTCONF_H)
bigzero.o: $(arch_hdrdir)/ruby/config.h
@@ -165,6 +169,7 @@ bigzero.o: $(hdrdir)/ruby/backward.h
bigzero.o: $(hdrdir)/ruby/backward/2/assume.h
bigzero.o: $(hdrdir)/ruby/backward/2/attributes.h
bigzero.o: $(hdrdir)/ruby/backward/2/bool.h
+bigzero.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
bigzero.o: $(hdrdir)/ruby/backward/2/inttypes.h
bigzero.o: $(hdrdir)/ruby/backward/2/limits.h
bigzero.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -286,6 +291,7 @@ bigzero.o: $(hdrdir)/ruby/internal/intern/re.h
bigzero.o: $(hdrdir)/ruby/internal/intern/ruby.h
bigzero.o: $(hdrdir)/ruby/internal/intern/select.h
bigzero.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bigzero.o: $(hdrdir)/ruby/internal/intern/set.h
bigzero.o: $(hdrdir)/ruby/internal/intern/signal.h
bigzero.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bigzero.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -305,6 +311,7 @@ bigzero.o: $(hdrdir)/ruby/internal/special_consts.h
bigzero.o: $(hdrdir)/ruby/internal/static_assert.h
bigzero.o: $(hdrdir)/ruby/internal/stdalign.h
bigzero.o: $(hdrdir)/ruby/internal/stdbool.h
+bigzero.o: $(hdrdir)/ruby/internal/stdckdint.h
bigzero.o: $(hdrdir)/ruby/internal/symbol.h
bigzero.o: $(hdrdir)/ruby/internal/value.h
bigzero.o: $(hdrdir)/ruby/internal/value_type.h
@@ -316,6 +323,7 @@ bigzero.o: $(hdrdir)/ruby/ruby.h
bigzero.o: $(hdrdir)/ruby/st.h
bigzero.o: $(hdrdir)/ruby/subst.h
bigzero.o: $(top_srcdir)/internal/bignum.h
+bigzero.o: $(top_srcdir)/internal/compilers.h
bigzero.o: bigzero.c
div.o: $(RUBY_EXTCONF_H)
div.o: $(arch_hdrdir)/ruby/config.h
@@ -324,6 +332,7 @@ div.o: $(hdrdir)/ruby/backward.h
div.o: $(hdrdir)/ruby/backward/2/assume.h
div.o: $(hdrdir)/ruby/backward/2/attributes.h
div.o: $(hdrdir)/ruby/backward/2/bool.h
+div.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
div.o: $(hdrdir)/ruby/backward/2/inttypes.h
div.o: $(hdrdir)/ruby/backward/2/limits.h
div.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -445,6 +454,7 @@ div.o: $(hdrdir)/ruby/internal/intern/re.h
div.o: $(hdrdir)/ruby/internal/intern/ruby.h
div.o: $(hdrdir)/ruby/internal/intern/select.h
div.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+div.o: $(hdrdir)/ruby/internal/intern/set.h
div.o: $(hdrdir)/ruby/internal/intern/signal.h
div.o: $(hdrdir)/ruby/internal/intern/sprintf.h
div.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -464,6 +474,7 @@ div.o: $(hdrdir)/ruby/internal/special_consts.h
div.o: $(hdrdir)/ruby/internal/static_assert.h
div.o: $(hdrdir)/ruby/internal/stdalign.h
div.o: $(hdrdir)/ruby/internal/stdbool.h
+div.o: $(hdrdir)/ruby/internal/stdckdint.h
div.o: $(hdrdir)/ruby/internal/symbol.h
div.o: $(hdrdir)/ruby/internal/value.h
div.o: $(hdrdir)/ruby/internal/value_type.h
@@ -475,6 +486,7 @@ div.o: $(hdrdir)/ruby/ruby.h
div.o: $(hdrdir)/ruby/st.h
div.o: $(hdrdir)/ruby/subst.h
div.o: $(top_srcdir)/internal/bignum.h
+div.o: $(top_srcdir)/internal/compilers.h
div.o: div.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
@@ -605,6 +617,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -624,6 +637,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -642,6 +656,7 @@ intpack.o: $(hdrdir)/ruby/backward.h
intpack.o: $(hdrdir)/ruby/backward/2/assume.h
intpack.o: $(hdrdir)/ruby/backward/2/attributes.h
intpack.o: $(hdrdir)/ruby/backward/2/bool.h
+intpack.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
intpack.o: $(hdrdir)/ruby/backward/2/inttypes.h
intpack.o: $(hdrdir)/ruby/backward/2/limits.h
intpack.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -763,6 +778,7 @@ intpack.o: $(hdrdir)/ruby/internal/intern/re.h
intpack.o: $(hdrdir)/ruby/internal/intern/ruby.h
intpack.o: $(hdrdir)/ruby/internal/intern/select.h
intpack.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+intpack.o: $(hdrdir)/ruby/internal/intern/set.h
intpack.o: $(hdrdir)/ruby/internal/intern/signal.h
intpack.o: $(hdrdir)/ruby/internal/intern/sprintf.h
intpack.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -782,6 +798,7 @@ intpack.o: $(hdrdir)/ruby/internal/special_consts.h
intpack.o: $(hdrdir)/ruby/internal/static_assert.h
intpack.o: $(hdrdir)/ruby/internal/stdalign.h
intpack.o: $(hdrdir)/ruby/internal/stdbool.h
+intpack.o: $(hdrdir)/ruby/internal/stdckdint.h
intpack.o: $(hdrdir)/ruby/internal/symbol.h
intpack.o: $(hdrdir)/ruby/internal/value.h
intpack.o: $(hdrdir)/ruby/internal/value_type.h
@@ -793,6 +810,7 @@ intpack.o: $(hdrdir)/ruby/ruby.h
intpack.o: $(hdrdir)/ruby/st.h
intpack.o: $(hdrdir)/ruby/subst.h
intpack.o: $(top_srcdir)/internal/bignum.h
+intpack.o: $(top_srcdir)/internal/compilers.h
intpack.o: intpack.c
mul.o: $(RUBY_EXTCONF_H)
mul.o: $(arch_hdrdir)/ruby/config.h
@@ -801,6 +819,7 @@ mul.o: $(hdrdir)/ruby/backward.h
mul.o: $(hdrdir)/ruby/backward/2/assume.h
mul.o: $(hdrdir)/ruby/backward/2/attributes.h
mul.o: $(hdrdir)/ruby/backward/2/bool.h
+mul.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
mul.o: $(hdrdir)/ruby/backward/2/inttypes.h
mul.o: $(hdrdir)/ruby/backward/2/limits.h
mul.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -922,6 +941,7 @@ mul.o: $(hdrdir)/ruby/internal/intern/re.h
mul.o: $(hdrdir)/ruby/internal/intern/ruby.h
mul.o: $(hdrdir)/ruby/internal/intern/select.h
mul.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+mul.o: $(hdrdir)/ruby/internal/intern/set.h
mul.o: $(hdrdir)/ruby/internal/intern/signal.h
mul.o: $(hdrdir)/ruby/internal/intern/sprintf.h
mul.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -941,6 +961,7 @@ mul.o: $(hdrdir)/ruby/internal/special_consts.h
mul.o: $(hdrdir)/ruby/internal/static_assert.h
mul.o: $(hdrdir)/ruby/internal/stdalign.h
mul.o: $(hdrdir)/ruby/internal/stdbool.h
+mul.o: $(hdrdir)/ruby/internal/stdckdint.h
mul.o: $(hdrdir)/ruby/internal/symbol.h
mul.o: $(hdrdir)/ruby/internal/value.h
mul.o: $(hdrdir)/ruby/internal/value_type.h
@@ -952,6 +973,7 @@ mul.o: $(hdrdir)/ruby/ruby.h
mul.o: $(hdrdir)/ruby/st.h
mul.o: $(hdrdir)/ruby/subst.h
mul.o: $(top_srcdir)/internal/bignum.h
+mul.o: $(top_srcdir)/internal/compilers.h
mul.o: mul.c
str2big.o: $(RUBY_EXTCONF_H)
str2big.o: $(arch_hdrdir)/ruby/config.h
@@ -960,6 +982,7 @@ str2big.o: $(hdrdir)/ruby/backward.h
str2big.o: $(hdrdir)/ruby/backward/2/assume.h
str2big.o: $(hdrdir)/ruby/backward/2/attributes.h
str2big.o: $(hdrdir)/ruby/backward/2/bool.h
+str2big.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
str2big.o: $(hdrdir)/ruby/backward/2/inttypes.h
str2big.o: $(hdrdir)/ruby/backward/2/limits.h
str2big.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -1081,6 +1104,7 @@ str2big.o: $(hdrdir)/ruby/internal/intern/re.h
str2big.o: $(hdrdir)/ruby/internal/intern/ruby.h
str2big.o: $(hdrdir)/ruby/internal/intern/select.h
str2big.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+str2big.o: $(hdrdir)/ruby/internal/intern/set.h
str2big.o: $(hdrdir)/ruby/internal/intern/signal.h
str2big.o: $(hdrdir)/ruby/internal/intern/sprintf.h
str2big.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1100,6 +1124,7 @@ str2big.o: $(hdrdir)/ruby/internal/special_consts.h
str2big.o: $(hdrdir)/ruby/internal/static_assert.h
str2big.o: $(hdrdir)/ruby/internal/stdalign.h
str2big.o: $(hdrdir)/ruby/internal/stdbool.h
+str2big.o: $(hdrdir)/ruby/internal/stdckdint.h
str2big.o: $(hdrdir)/ruby/internal/symbol.h
str2big.o: $(hdrdir)/ruby/internal/value.h
str2big.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1111,5 +1136,6 @@ str2big.o: $(hdrdir)/ruby/ruby.h
str2big.o: $(hdrdir)/ruby/st.h
str2big.o: $(hdrdir)/ruby/subst.h
str2big.o: $(top_srcdir)/internal/bignum.h
+str2big.o: $(top_srcdir)/internal/compilers.h
str2big.o: str2big.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/box/yay1/extconf.rb b/ext/-test-/box/yay1/extconf.rb
new file mode 100644
index 0000000000..54387cedf1
--- /dev/null
+++ b/ext/-test-/box/yay1/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/box/yay1')
diff --git a/ext/-test-/box/yay1/yay1.c b/ext/-test-/box/yay1/yay1.c
new file mode 100644
index 0000000000..564a221c8c
--- /dev/null
+++ b/ext/-test-/box/yay1/yay1.c
@@ -0,0 +1,28 @@
+#include "yay1.h"
+
+VALUE
+yay_value(void)
+{
+ return rb_str_new_cstr("yay");
+}
+
+static VALUE
+yay1_f_version(VALUE klass)
+{
+ return rb_str_new_cstr("1.0.0");
+}
+
+static VALUE
+yay1_yay(VALUE klass)
+{
+ return yay_value();
+}
+
+void
+Init_yay1(void)
+{
+ VALUE mod = rb_define_module("Yay");
+ rb_define_const(mod, "VERSION", rb_str_new_cstr("1.0.0"));
+ rb_define_singleton_method(mod, "version", yay1_f_version, 0);
+ rb_define_singleton_method(mod, "yay", yay1_yay, 0);
+}
diff --git a/ext/-test-/box/yay1/yay1.def b/ext/-test-/box/yay1/yay1.def
new file mode 100644
index 0000000000..510fbe7017
--- /dev/null
+++ b/ext/-test-/box/yay1/yay1.def
@@ -0,0 +1,3 @@
+EXPORTS
+ Init_yay1
+ yay_value
diff --git a/ext/-test-/box/yay1/yay1.h b/ext/-test-/box/yay1/yay1.h
new file mode 100644
index 0000000000..c4dade928a
--- /dev/null
+++ b/ext/-test-/box/yay1/yay1.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_FUNC_EXPORTED VALUE yay_value(void);
diff --git a/ext/-test-/box/yay2/extconf.rb b/ext/-test-/box/yay2/extconf.rb
new file mode 100644
index 0000000000..850ef3edc9
--- /dev/null
+++ b/ext/-test-/box/yay2/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/box/yay2')
diff --git a/ext/-test-/box/yay2/yay2.c b/ext/-test-/box/yay2/yay2.c
new file mode 100644
index 0000000000..b632ae8495
--- /dev/null
+++ b/ext/-test-/box/yay2/yay2.c
@@ -0,0 +1,28 @@
+#include "yay2.h"
+
+VALUE
+yay_value(void)
+{
+ return rb_str_new_cstr("yaaay");
+}
+
+static VALUE
+yay2_f_version(VALUE klass)
+{
+ return rb_str_new_cstr("2.0.0");
+}
+
+static VALUE
+yay2_yay(VALUE klass)
+{
+ return yay_value();
+}
+
+void
+Init_yay2(void)
+{
+ VALUE mod = rb_define_module("Yay");
+ rb_define_const(mod, "VERSION", rb_str_new_cstr("2.0.0"));
+ rb_define_singleton_method(mod, "version", yay2_f_version, 0);
+ rb_define_singleton_method(mod, "yay", yay2_yay, 0);
+}
diff --git a/ext/-test-/box/yay2/yay2.def b/ext/-test-/box/yay2/yay2.def
new file mode 100644
index 0000000000..163fc44c04
--- /dev/null
+++ b/ext/-test-/box/yay2/yay2.def
@@ -0,0 +1,3 @@
+EXPORTS
+ Init_yay2
+ yay_value
diff --git a/ext/-test-/box/yay2/yay2.h b/ext/-test-/box/yay2/yay2.h
new file mode 100644
index 0000000000..c4dade928a
--- /dev/null
+++ b/ext/-test-/box/yay2/yay2.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_FUNC_EXPORTED VALUE yay_value(void);
diff --git a/ext/-test-/bug-14834/bug-14384.c b/ext/-test-/bug-14834/bug-14384.c
deleted file mode 100644
index 3a16a2d222..0000000000
--- a/ext/-test-/bug-14834/bug-14384.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <ruby/ruby.h>
-#include <ruby/debug.h>
-
-#ifndef MAYBE_UNUSED
-# define MAYBE_UNUSED(x) x
-#endif
-
-static NOINLINE(VALUE f(VALUE));
-static NOINLINE(void g(VALUE, void*));
-extern NOINLINE(void Init_bug_14384(void));
-
-void
-Init_bug_14834(void)
-{
- VALUE q = rb_define_module("Bug");
- rb_define_module_function(q, "bug_14834", f, 0);
-}
-
-VALUE
-f(VALUE q)
-{
- int w[] = { 0, 1024 };
- VALUE e = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_NEWOBJ, g, w);
-
- rb_tracepoint_enable(e);
- return rb_ensure(rb_yield, q, rb_tracepoint_disable, e);
-}
-
-void
-g(MAYBE_UNUSED(VALUE q), void* w)
-{
- const int *e = (const int *)w;
- const int r = *e++;
- const int t = *e++;
- VALUE *y = ALLOCA_N(VALUE, t);
- int *u = ALLOCA_N(int, t);
-
- rb_profile_frames(r, t, y, u);
-}
diff --git a/ext/-test-/bug-14834/bug-14834.c b/ext/-test-/bug-14834/bug-14834.c
new file mode 100644
index 0000000000..af2070d303
--- /dev/null
+++ b/ext/-test-/bug-14834/bug-14834.c
@@ -0,0 +1,39 @@
+#include <ruby/ruby.h>
+#include <ruby/debug.h>
+
+#ifndef MAYBE_UNUSED
+# define MAYBE_UNUSED(x) x
+#endif
+
+static NOINLINE(VALUE f(VALUE));
+static NOINLINE(void g(VALUE, void*));
+extern NOINLINE(void Init_bug_14834(void));
+
+void
+Init_bug_14834(void)
+{
+ VALUE q = rb_define_module("Bug");
+ rb_define_module_function(q, "bug_14834", f, 0);
+}
+
+VALUE
+f(VALUE q)
+{
+ int w[] = { 0, 1024 };
+ VALUE e = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_NEWOBJ, g, w);
+
+ rb_tracepoint_enable(e);
+ return rb_ensure(rb_yield, q, rb_tracepoint_disable, e);
+}
+
+void
+g(MAYBE_UNUSED(VALUE q), void* w)
+{
+ const int *e = (const int *)w;
+ const int r = *e++;
+ const int t = *e++;
+ VALUE *y = ALLOCA_N(VALUE, t);
+ int *u = ALLOCA_N(int, t);
+
+ rb_profile_frames(r, t, y, u);
+}
diff --git a/ext/-test-/bug-14834/depend b/ext/-test-/bug-14834/depend
index bf26a571aa..f83939d559 100644
--- a/ext/-test-/bug-14834/depend
+++ b/ext/-test-/bug-14834/depend
@@ -1,161 +1,163 @@
# AUTOGENERATED DEPENDENCIES START
-bug-14384.o: $(RUBY_EXTCONF_H)
-bug-14384.o: $(arch_hdrdir)/ruby/config.h
-bug-14384.o: $(hdrdir)/ruby/assert.h
-bug-14384.o: $(hdrdir)/ruby/backward.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/assume.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/attributes.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/bool.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/inttypes.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/limits.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/long_long.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/stdalign.h
-bug-14384.o: $(hdrdir)/ruby/backward/2/stdarg.h
-bug-14384.o: $(hdrdir)/ruby/debug.h
-bug-14384.o: $(hdrdir)/ruby/defines.h
-bug-14384.o: $(hdrdir)/ruby/intern.h
-bug-14384.o: $(hdrdir)/ruby/internal/abi.h
-bug-14384.o: $(hdrdir)/ruby/internal/anyargs.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-bug-14384.o: $(hdrdir)/ruby/internal/assume.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/artificial.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/cold.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/const.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/error.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/format.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/noalias.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/noinline.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/pure.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/restrict.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/warning.h
-bug-14384.o: $(hdrdir)/ruby/internal/attr/weakref.h
-bug-14384.o: $(hdrdir)/ruby/internal/cast.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-bug-14384.o: $(hdrdir)/ruby/internal/compiler_since.h
-bug-14384.o: $(hdrdir)/ruby/internal/config.h
-bug-14384.o: $(hdrdir)/ruby/internal/constant_p.h
-bug-14384.o: $(hdrdir)/ruby/internal/core.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rarray.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rbasic.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rbignum.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rclass.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rdata.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rfile.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rhash.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/robject.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rregexp.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rstring.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rstruct.h
-bug-14384.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-bug-14384.o: $(hdrdir)/ruby/internal/ctype.h
-bug-14384.o: $(hdrdir)/ruby/internal/dllexport.h
-bug-14384.o: $(hdrdir)/ruby/internal/dosish.h
-bug-14384.o: $(hdrdir)/ruby/internal/error.h
-bug-14384.o: $(hdrdir)/ruby/internal/eval.h
-bug-14384.o: $(hdrdir)/ruby/internal/event.h
-bug-14384.o: $(hdrdir)/ruby/internal/fl_type.h
-bug-14384.o: $(hdrdir)/ruby/internal/gc.h
-bug-14384.o: $(hdrdir)/ruby/internal/glob.h
-bug-14384.o: $(hdrdir)/ruby/internal/globals.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/attribute.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/builtin.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/extension.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/feature.h
-bug-14384.o: $(hdrdir)/ruby/internal/has/warning.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/array.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/bignum.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/class.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/compar.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/complex.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/cont.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/dir.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/enum.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/error.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/eval.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/file.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/hash.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/io.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/load.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/marshal.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/numeric.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/object.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/parse.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/proc.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/process.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/random.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/range.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/rational.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/re.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/ruby.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/select.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/signal.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/string.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/struct.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/thread.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/time.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/variable.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/vm.h
-bug-14384.o: $(hdrdir)/ruby/internal/interpreter.h
-bug-14384.o: $(hdrdir)/ruby/internal/iterator.h
-bug-14384.o: $(hdrdir)/ruby/internal/memory.h
-bug-14384.o: $(hdrdir)/ruby/internal/method.h
-bug-14384.o: $(hdrdir)/ruby/internal/module.h
-bug-14384.o: $(hdrdir)/ruby/internal/newobj.h
-bug-14384.o: $(hdrdir)/ruby/internal/scan_args.h
-bug-14384.o: $(hdrdir)/ruby/internal/special_consts.h
-bug-14384.o: $(hdrdir)/ruby/internal/static_assert.h
-bug-14384.o: $(hdrdir)/ruby/internal/stdalign.h
-bug-14384.o: $(hdrdir)/ruby/internal/stdbool.h
-bug-14384.o: $(hdrdir)/ruby/internal/symbol.h
-bug-14384.o: $(hdrdir)/ruby/internal/value.h
-bug-14384.o: $(hdrdir)/ruby/internal/value_type.h
-bug-14384.o: $(hdrdir)/ruby/internal/variable.h
-bug-14384.o: $(hdrdir)/ruby/internal/warning_push.h
-bug-14384.o: $(hdrdir)/ruby/internal/xmalloc.h
-bug-14384.o: $(hdrdir)/ruby/missing.h
-bug-14384.o: $(hdrdir)/ruby/ruby.h
-bug-14384.o: $(hdrdir)/ruby/st.h
-bug-14384.o: $(hdrdir)/ruby/subst.h
-bug-14384.o: bug-14384.c
+bug-14834.o: $(RUBY_EXTCONF_H)
+bug-14834.o: $(arch_hdrdir)/ruby/config.h
+bug-14834.o: $(hdrdir)/ruby/assert.h
+bug-14834.o: $(hdrdir)/ruby/backward.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/assume.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/attributes.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/bool.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/inttypes.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/limits.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/long_long.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/stdalign.h
+bug-14834.o: $(hdrdir)/ruby/backward/2/stdarg.h
+bug-14834.o: $(hdrdir)/ruby/debug.h
+bug-14834.o: $(hdrdir)/ruby/defines.h
+bug-14834.o: $(hdrdir)/ruby/intern.h
+bug-14834.o: $(hdrdir)/ruby/internal/abi.h
+bug-14834.o: $(hdrdir)/ruby/internal/anyargs.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+bug-14834.o: $(hdrdir)/ruby/internal/assume.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/artificial.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/cold.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/const.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/error.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/format.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/noalias.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/noinline.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/pure.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/restrict.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/warning.h
+bug-14834.o: $(hdrdir)/ruby/internal/attr/weakref.h
+bug-14834.o: $(hdrdir)/ruby/internal/cast.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+bug-14834.o: $(hdrdir)/ruby/internal/compiler_since.h
+bug-14834.o: $(hdrdir)/ruby/internal/config.h
+bug-14834.o: $(hdrdir)/ruby/internal/constant_p.h
+bug-14834.o: $(hdrdir)/ruby/internal/core.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rarray.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rbasic.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rbignum.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rclass.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rdata.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rfile.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rhash.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/robject.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rregexp.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rstring.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rstruct.h
+bug-14834.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+bug-14834.o: $(hdrdir)/ruby/internal/ctype.h
+bug-14834.o: $(hdrdir)/ruby/internal/dllexport.h
+bug-14834.o: $(hdrdir)/ruby/internal/dosish.h
+bug-14834.o: $(hdrdir)/ruby/internal/error.h
+bug-14834.o: $(hdrdir)/ruby/internal/eval.h
+bug-14834.o: $(hdrdir)/ruby/internal/event.h
+bug-14834.o: $(hdrdir)/ruby/internal/fl_type.h
+bug-14834.o: $(hdrdir)/ruby/internal/gc.h
+bug-14834.o: $(hdrdir)/ruby/internal/glob.h
+bug-14834.o: $(hdrdir)/ruby/internal/globals.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/attribute.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/builtin.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/extension.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/feature.h
+bug-14834.o: $(hdrdir)/ruby/internal/has/warning.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/array.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/bignum.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/class.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/compar.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/complex.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/cont.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/dir.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/enum.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/error.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/eval.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/file.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/hash.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/io.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/load.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/marshal.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/numeric.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/object.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/parse.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/proc.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/process.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/random.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/range.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/rational.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/re.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/ruby.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/select.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/set.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/signal.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/string.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/struct.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/thread.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/time.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/variable.h
+bug-14834.o: $(hdrdir)/ruby/internal/intern/vm.h
+bug-14834.o: $(hdrdir)/ruby/internal/interpreter.h
+bug-14834.o: $(hdrdir)/ruby/internal/iterator.h
+bug-14834.o: $(hdrdir)/ruby/internal/memory.h
+bug-14834.o: $(hdrdir)/ruby/internal/method.h
+bug-14834.o: $(hdrdir)/ruby/internal/module.h
+bug-14834.o: $(hdrdir)/ruby/internal/newobj.h
+bug-14834.o: $(hdrdir)/ruby/internal/scan_args.h
+bug-14834.o: $(hdrdir)/ruby/internal/special_consts.h
+bug-14834.o: $(hdrdir)/ruby/internal/static_assert.h
+bug-14834.o: $(hdrdir)/ruby/internal/stdalign.h
+bug-14834.o: $(hdrdir)/ruby/internal/stdbool.h
+bug-14834.o: $(hdrdir)/ruby/internal/stdckdint.h
+bug-14834.o: $(hdrdir)/ruby/internal/symbol.h
+bug-14834.o: $(hdrdir)/ruby/internal/value.h
+bug-14834.o: $(hdrdir)/ruby/internal/value_type.h
+bug-14834.o: $(hdrdir)/ruby/internal/variable.h
+bug-14834.o: $(hdrdir)/ruby/internal/warning_push.h
+bug-14834.o: $(hdrdir)/ruby/internal/xmalloc.h
+bug-14834.o: $(hdrdir)/ruby/missing.h
+bug-14834.o: $(hdrdir)/ruby/ruby.h
+bug-14834.o: $(hdrdir)/ruby/st.h
+bug-14834.o: $(hdrdir)/ruby/subst.h
+bug-14834.o: bug-14834.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/bug-3571/depend b/ext/-test-/bug-3571/depend
index 9105093b0d..69c970b6f2 100644
--- a/ext/-test-/bug-3571/depend
+++ b/ext/-test-/bug-3571/depend
@@ -128,6 +128,7 @@ bug.o: $(hdrdir)/ruby/internal/intern/re.h
bug.o: $(hdrdir)/ruby/internal/intern/ruby.h
bug.o: $(hdrdir)/ruby/internal/intern/select.h
bug.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bug.o: $(hdrdir)/ruby/internal/intern/set.h
bug.o: $(hdrdir)/ruby/internal/intern/signal.h
bug.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bug.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
bug.o: $(hdrdir)/ruby/internal/stdalign.h
bug.o: $(hdrdir)/ruby/internal/stdbool.h
+bug.o: $(hdrdir)/ruby/internal/stdckdint.h
bug.o: $(hdrdir)/ruby/internal/symbol.h
bug.o: $(hdrdir)/ruby/internal/value.h
bug.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/bug-5832/depend b/ext/-test-/bug-5832/depend
index 9105093b0d..69c970b6f2 100644
--- a/ext/-test-/bug-5832/depend
+++ b/ext/-test-/bug-5832/depend
@@ -128,6 +128,7 @@ bug.o: $(hdrdir)/ruby/internal/intern/re.h
bug.o: $(hdrdir)/ruby/internal/intern/ruby.h
bug.o: $(hdrdir)/ruby/internal/intern/select.h
bug.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bug.o: $(hdrdir)/ruby/internal/intern/set.h
bug.o: $(hdrdir)/ruby/internal/intern/signal.h
bug.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bug.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
bug.o: $(hdrdir)/ruby/internal/stdalign.h
bug.o: $(hdrdir)/ruby/internal/stdbool.h
+bug.o: $(hdrdir)/ruby/internal/stdckdint.h
bug.o: $(hdrdir)/ruby/internal/symbol.h
bug.o: $(hdrdir)/ruby/internal/value.h
bug.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/bug_reporter/depend b/ext/-test-/bug_reporter/depend
index 20882708d1..e9993c3295 100644
--- a/ext/-test-/bug_reporter/depend
+++ b/ext/-test-/bug_reporter/depend
@@ -128,6 +128,7 @@ bug_reporter.o: $(hdrdir)/ruby/internal/intern/re.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/ruby.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/select.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bug_reporter.o: $(hdrdir)/ruby/internal/intern/set.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/signal.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ bug_reporter.o: $(hdrdir)/ruby/internal/special_consts.h
bug_reporter.o: $(hdrdir)/ruby/internal/static_assert.h
bug_reporter.o: $(hdrdir)/ruby/internal/stdalign.h
bug_reporter.o: $(hdrdir)/ruby/internal/stdbool.h
+bug_reporter.o: $(hdrdir)/ruby/internal/stdckdint.h
bug_reporter.o: $(hdrdir)/ruby/internal/symbol.h
bug_reporter.o: $(hdrdir)/ruby/internal/value.h
bug_reporter.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/class/depend b/ext/-test-/class/depend
index 0a805f815e..557206cefb 100644
--- a/ext/-test-/class/depend
+++ b/ext/-test-/class/depend
@@ -127,6 +127,7 @@ class2name.o: $(hdrdir)/ruby/internal/intern/re.h
class2name.o: $(hdrdir)/ruby/internal/intern/ruby.h
class2name.o: $(hdrdir)/ruby/internal/intern/select.h
class2name.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+class2name.o: $(hdrdir)/ruby/internal/intern/set.h
class2name.o: $(hdrdir)/ruby/internal/intern/signal.h
class2name.o: $(hdrdir)/ruby/internal/intern/sprintf.h
class2name.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ class2name.o: $(hdrdir)/ruby/internal/special_consts.h
class2name.o: $(hdrdir)/ruby/internal/static_assert.h
class2name.o: $(hdrdir)/ruby/internal/stdalign.h
class2name.o: $(hdrdir)/ruby/internal/stdbool.h
+class2name.o: $(hdrdir)/ruby/internal/stdckdint.h
class2name.o: $(hdrdir)/ruby/internal/symbol.h
class2name.o: $(hdrdir)/ruby/internal/value.h
class2name.o: $(hdrdir)/ruby/internal/value_type.h
@@ -286,6 +288,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -305,6 +308,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/class/init.c b/ext/-test-/class/init.c
index ed715c1942..108ff7525c 100644
--- a/ext/-test-/class/init.c
+++ b/ext/-test-/class/init.c
@@ -7,5 +7,6 @@ Init_class(void)
{
VALUE mBug = rb_define_module("Bug");
VALUE mod = rb_define_module_under(mBug, "Class");
+ rb_define_class_under(mod, "TestClassDefinedInC", rb_cObject);
TEST_INIT_FUNCS(init);
}
diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp
index eded13e2ee..c7df7f9038 100644
--- a/ext/-test-/cxxanyargs/cxxanyargs.cpp
+++ b/ext/-test-/cxxanyargs/cxxanyargs.cpp
@@ -97,31 +97,6 @@ struct test_rb_define_hooked_variable {
};
VALUE test_rb_define_hooked_variable::v = Qundef;
-namespace test_rb_iterate {
- VALUE
- iter(VALUE self)
- {
- return rb_funcall(self, rb_intern("yield"), 0);
- }
-
- VALUE
- block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
- {
- return rb_funcall(arg, rb_intern("=="), 1, param);
- }
-
- VALUE
- test(VALUE self)
- {
-#ifdef HAVE_NULLPTR
- rb_iterate(iter, self, nullptr, self);
-#endif
-
- rb_iterate(iter, self, RUBY_METHOD_FUNC(block), self); // old
- return rb_iterate(iter, self, block, self); // new
- }
-}
-
namespace test_rb_block_call {
VALUE
block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
@@ -936,7 +911,6 @@ Init_cxxanyargs(void)
test(rb_define_virtual_variable);
test(rb_define_hooked_variable);
- test(rb_iterate);
test(rb_block_call);
test(rb_rescue);
test(rb_rescue2);
diff --git a/ext/-test-/debug/depend b/ext/-test-/debug/depend
index 5feeea6d98..4ae0378ef2 100644
--- a/ext/-test-/debug/depend
+++ b/ext/-test-/debug/depend
@@ -128,6 +128,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ inspector.o: $(hdrdir)/ruby/internal/intern/re.h
inspector.o: $(hdrdir)/ruby/internal/intern/ruby.h
inspector.o: $(hdrdir)/ruby/internal/intern/select.h
inspector.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+inspector.o: $(hdrdir)/ruby/internal/intern/set.h
inspector.o: $(hdrdir)/ruby/internal/intern/signal.h
inspector.o: $(hdrdir)/ruby/internal/intern/sprintf.h
inspector.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ inspector.o: $(hdrdir)/ruby/internal/special_consts.h
inspector.o: $(hdrdir)/ruby/internal/static_assert.h
inspector.o: $(hdrdir)/ruby/internal/stdalign.h
inspector.o: $(hdrdir)/ruby/internal/stdbool.h
+inspector.o: $(hdrdir)/ruby/internal/stdckdint.h
inspector.o: $(hdrdir)/ruby/internal/symbol.h
inspector.o: $(hdrdir)/ruby/internal/value.h
inspector.o: $(hdrdir)/ruby/internal/value_type.h
@@ -446,6 +450,7 @@ profile_frames.o: $(hdrdir)/ruby/internal/intern/re.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/ruby.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/select.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+profile_frames.o: $(hdrdir)/ruby/internal/intern/set.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/signal.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/sprintf.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -465,6 +470,7 @@ profile_frames.o: $(hdrdir)/ruby/internal/special_consts.h
profile_frames.o: $(hdrdir)/ruby/internal/static_assert.h
profile_frames.o: $(hdrdir)/ruby/internal/stdalign.h
profile_frames.o: $(hdrdir)/ruby/internal/stdbool.h
+profile_frames.o: $(hdrdir)/ruby/internal/stdckdint.h
profile_frames.o: $(hdrdir)/ruby/internal/symbol.h
profile_frames.o: $(hdrdir)/ruby/internal/value.h
profile_frames.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/debug/profile_frames.c b/ext/-test-/debug/profile_frames.c
index d2bba7d183..f9a77a5a78 100644
--- a/ext/-test-/debug/profile_frames.c
+++ b/ext/-test-/debug/profile_frames.c
@@ -37,8 +37,29 @@ profile_frames(VALUE self, VALUE start_v, VALUE num_v)
return result;
}
+static VALUE
+profile_thread_frames(VALUE self, VALUE thread, VALUE start_v, VALUE num_v)
+{
+ int i, collected_size;
+ int start = NUM2INT(start_v);
+ int buff_size = NUM2INT(num_v);
+ VALUE buff[MAX_BUF_SIZE];
+ int lines[MAX_BUF_SIZE];
+ VALUE result = rb_ary_new();
+
+ if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size");
+
+ collected_size = rb_profile_thread_frames(thread, start, buff_size, buff, lines);
+ for (i=0; i<collected_size; i++) {
+ rb_ary_push(result, rb_profile_frame_full_label(buff[i]));
+ }
+
+ return result;
+}
+
void
Init_profile_frames(VALUE klass)
{
rb_define_module_function(klass, "profile_frames", profile_frames, 2);
+ rb_define_module_function(klass, "profile_thread_frames", profile_thread_frames, 3);
}
diff --git a/ext/-test-/dln/empty/depend b/ext/-test-/dln/empty/depend
index a460159087..58f1508598 100644
--- a/ext/-test-/dln/empty/depend
+++ b/ext/-test-/dln/empty/depend
@@ -128,6 +128,7 @@ empty.o: $(hdrdir)/ruby/internal/intern/re.h
empty.o: $(hdrdir)/ruby/internal/intern/ruby.h
empty.o: $(hdrdir)/ruby/internal/intern/select.h
empty.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+empty.o: $(hdrdir)/ruby/internal/intern/set.h
empty.o: $(hdrdir)/ruby/internal/intern/signal.h
empty.o: $(hdrdir)/ruby/internal/intern/sprintf.h
empty.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ empty.o: $(hdrdir)/ruby/internal/special_consts.h
empty.o: $(hdrdir)/ruby/internal/static_assert.h
empty.o: $(hdrdir)/ruby/internal/stdalign.h
empty.o: $(hdrdir)/ruby/internal/stdbool.h
+empty.o: $(hdrdir)/ruby/internal/stdckdint.h
empty.o: $(hdrdir)/ruby/internal/symbol.h
empty.o: $(hdrdir)/ruby/internal/value.h
empty.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/econv/append.c b/ext/-test-/econv/append.c
index 724cd136c0..eb473c47a3 100644
--- a/ext/-test-/econv/append.c
+++ b/ext/-test-/econv/append.c
@@ -5,6 +5,8 @@ static VALUE
econv_append(VALUE self, VALUE src, VALUE dst)
{
rb_econv_t *ec = DATA_PTR(self);
+ StringValue(src);
+ StringValue(dst);
return rb_econv_str_append(ec, src, dst, 0);
}
diff --git a/ext/-test-/econv/depend b/ext/-test-/econv/depend
new file mode 100644
index 0000000000..3a5bc9c659
--- /dev/null
+++ b/ext/-test-/econv/depend
@@ -0,0 +1,336 @@
+# AUTOGENERATED DEPENDENCIES START
+append.o: $(RUBY_EXTCONF_H)
+append.o: $(arch_hdrdir)/ruby/config.h
+append.o: $(hdrdir)/ruby.h
+append.o: $(hdrdir)/ruby/assert.h
+append.o: $(hdrdir)/ruby/backward.h
+append.o: $(hdrdir)/ruby/backward/2/assume.h
+append.o: $(hdrdir)/ruby/backward/2/attributes.h
+append.o: $(hdrdir)/ruby/backward/2/bool.h
+append.o: $(hdrdir)/ruby/backward/2/inttypes.h
+append.o: $(hdrdir)/ruby/backward/2/limits.h
+append.o: $(hdrdir)/ruby/backward/2/long_long.h
+append.o: $(hdrdir)/ruby/backward/2/stdalign.h
+append.o: $(hdrdir)/ruby/backward/2/stdarg.h
+append.o: $(hdrdir)/ruby/defines.h
+append.o: $(hdrdir)/ruby/encoding.h
+append.o: $(hdrdir)/ruby/intern.h
+append.o: $(hdrdir)/ruby/internal/abi.h
+append.o: $(hdrdir)/ruby/internal/anyargs.h
+append.o: $(hdrdir)/ruby/internal/arithmetic.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+append.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+append.o: $(hdrdir)/ruby/internal/assume.h
+append.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+append.o: $(hdrdir)/ruby/internal/attr/artificial.h
+append.o: $(hdrdir)/ruby/internal/attr/cold.h
+append.o: $(hdrdir)/ruby/internal/attr/const.h
+append.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+append.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+append.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+append.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+append.o: $(hdrdir)/ruby/internal/attr/error.h
+append.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+append.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+append.o: $(hdrdir)/ruby/internal/attr/format.h
+append.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+append.o: $(hdrdir)/ruby/internal/attr/noalias.h
+append.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+append.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+append.o: $(hdrdir)/ruby/internal/attr/noinline.h
+append.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+append.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+append.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+append.o: $(hdrdir)/ruby/internal/attr/pure.h
+append.o: $(hdrdir)/ruby/internal/attr/restrict.h
+append.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+append.o: $(hdrdir)/ruby/internal/attr/warning.h
+append.o: $(hdrdir)/ruby/internal/attr/weakref.h
+append.o: $(hdrdir)/ruby/internal/cast.h
+append.o: $(hdrdir)/ruby/internal/compiler_is.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+append.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+append.o: $(hdrdir)/ruby/internal/compiler_since.h
+append.o: $(hdrdir)/ruby/internal/config.h
+append.o: $(hdrdir)/ruby/internal/constant_p.h
+append.o: $(hdrdir)/ruby/internal/core.h
+append.o: $(hdrdir)/ruby/internal/core/rarray.h
+append.o: $(hdrdir)/ruby/internal/core/rbasic.h
+append.o: $(hdrdir)/ruby/internal/core/rbignum.h
+append.o: $(hdrdir)/ruby/internal/core/rclass.h
+append.o: $(hdrdir)/ruby/internal/core/rdata.h
+append.o: $(hdrdir)/ruby/internal/core/rfile.h
+append.o: $(hdrdir)/ruby/internal/core/rhash.h
+append.o: $(hdrdir)/ruby/internal/core/robject.h
+append.o: $(hdrdir)/ruby/internal/core/rregexp.h
+append.o: $(hdrdir)/ruby/internal/core/rstring.h
+append.o: $(hdrdir)/ruby/internal/core/rstruct.h
+append.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+append.o: $(hdrdir)/ruby/internal/ctype.h
+append.o: $(hdrdir)/ruby/internal/dllexport.h
+append.o: $(hdrdir)/ruby/internal/dosish.h
+append.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+append.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+append.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+append.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+append.o: $(hdrdir)/ruby/internal/encoding/re.h
+append.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+append.o: $(hdrdir)/ruby/internal/encoding/string.h
+append.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+append.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+append.o: $(hdrdir)/ruby/internal/error.h
+append.o: $(hdrdir)/ruby/internal/eval.h
+append.o: $(hdrdir)/ruby/internal/event.h
+append.o: $(hdrdir)/ruby/internal/fl_type.h
+append.o: $(hdrdir)/ruby/internal/gc.h
+append.o: $(hdrdir)/ruby/internal/glob.h
+append.o: $(hdrdir)/ruby/internal/globals.h
+append.o: $(hdrdir)/ruby/internal/has/attribute.h
+append.o: $(hdrdir)/ruby/internal/has/builtin.h
+append.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+append.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+append.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+append.o: $(hdrdir)/ruby/internal/has/extension.h
+append.o: $(hdrdir)/ruby/internal/has/feature.h
+append.o: $(hdrdir)/ruby/internal/has/warning.h
+append.o: $(hdrdir)/ruby/internal/intern/array.h
+append.o: $(hdrdir)/ruby/internal/intern/bignum.h
+append.o: $(hdrdir)/ruby/internal/intern/class.h
+append.o: $(hdrdir)/ruby/internal/intern/compar.h
+append.o: $(hdrdir)/ruby/internal/intern/complex.h
+append.o: $(hdrdir)/ruby/internal/intern/cont.h
+append.o: $(hdrdir)/ruby/internal/intern/dir.h
+append.o: $(hdrdir)/ruby/internal/intern/enum.h
+append.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+append.o: $(hdrdir)/ruby/internal/intern/error.h
+append.o: $(hdrdir)/ruby/internal/intern/eval.h
+append.o: $(hdrdir)/ruby/internal/intern/file.h
+append.o: $(hdrdir)/ruby/internal/intern/hash.h
+append.o: $(hdrdir)/ruby/internal/intern/io.h
+append.o: $(hdrdir)/ruby/internal/intern/load.h
+append.o: $(hdrdir)/ruby/internal/intern/marshal.h
+append.o: $(hdrdir)/ruby/internal/intern/numeric.h
+append.o: $(hdrdir)/ruby/internal/intern/object.h
+append.o: $(hdrdir)/ruby/internal/intern/parse.h
+append.o: $(hdrdir)/ruby/internal/intern/proc.h
+append.o: $(hdrdir)/ruby/internal/intern/process.h
+append.o: $(hdrdir)/ruby/internal/intern/random.h
+append.o: $(hdrdir)/ruby/internal/intern/range.h
+append.o: $(hdrdir)/ruby/internal/intern/rational.h
+append.o: $(hdrdir)/ruby/internal/intern/re.h
+append.o: $(hdrdir)/ruby/internal/intern/ruby.h
+append.o: $(hdrdir)/ruby/internal/intern/select.h
+append.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+append.o: $(hdrdir)/ruby/internal/intern/set.h
+append.o: $(hdrdir)/ruby/internal/intern/signal.h
+append.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+append.o: $(hdrdir)/ruby/internal/intern/string.h
+append.o: $(hdrdir)/ruby/internal/intern/struct.h
+append.o: $(hdrdir)/ruby/internal/intern/thread.h
+append.o: $(hdrdir)/ruby/internal/intern/time.h
+append.o: $(hdrdir)/ruby/internal/intern/variable.h
+append.o: $(hdrdir)/ruby/internal/intern/vm.h
+append.o: $(hdrdir)/ruby/internal/interpreter.h
+append.o: $(hdrdir)/ruby/internal/iterator.h
+append.o: $(hdrdir)/ruby/internal/memory.h
+append.o: $(hdrdir)/ruby/internal/method.h
+append.o: $(hdrdir)/ruby/internal/module.h
+append.o: $(hdrdir)/ruby/internal/newobj.h
+append.o: $(hdrdir)/ruby/internal/scan_args.h
+append.o: $(hdrdir)/ruby/internal/special_consts.h
+append.o: $(hdrdir)/ruby/internal/static_assert.h
+append.o: $(hdrdir)/ruby/internal/stdalign.h
+append.o: $(hdrdir)/ruby/internal/stdbool.h
+append.o: $(hdrdir)/ruby/internal/stdckdint.h
+append.o: $(hdrdir)/ruby/internal/symbol.h
+append.o: $(hdrdir)/ruby/internal/value.h
+append.o: $(hdrdir)/ruby/internal/value_type.h
+append.o: $(hdrdir)/ruby/internal/variable.h
+append.o: $(hdrdir)/ruby/internal/warning_push.h
+append.o: $(hdrdir)/ruby/internal/xmalloc.h
+append.o: $(hdrdir)/ruby/missing.h
+append.o: $(hdrdir)/ruby/onigmo.h
+append.o: $(hdrdir)/ruby/oniguruma.h
+append.o: $(hdrdir)/ruby/ruby.h
+append.o: $(hdrdir)/ruby/st.h
+append.o: $(hdrdir)/ruby/subst.h
+append.o: append.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby.h
+init.o: $(hdrdir)/ruby/assert.h
+init.o: $(hdrdir)/ruby/backward.h
+init.o: $(hdrdir)/ruby/backward/2/assume.h
+init.o: $(hdrdir)/ruby/backward/2/attributes.h
+init.o: $(hdrdir)/ruby/backward/2/bool.h
+init.o: $(hdrdir)/ruby/backward/2/inttypes.h
+init.o: $(hdrdir)/ruby/backward/2/limits.h
+init.o: $(hdrdir)/ruby/backward/2/long_long.h
+init.o: $(hdrdir)/ruby/backward/2/stdalign.h
+init.o: $(hdrdir)/ruby/backward/2/stdarg.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/internal/abi.h
+init.o: $(hdrdir)/ruby/internal/anyargs.h
+init.o: $(hdrdir)/ruby/internal/arithmetic.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+init.o: $(hdrdir)/ruby/internal/assume.h
+init.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+init.o: $(hdrdir)/ruby/internal/attr/artificial.h
+init.o: $(hdrdir)/ruby/internal/attr/cold.h
+init.o: $(hdrdir)/ruby/internal/attr/const.h
+init.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+init.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+init.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+init.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+init.o: $(hdrdir)/ruby/internal/attr/error.h
+init.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+init.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+init.o: $(hdrdir)/ruby/internal/attr/format.h
+init.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+init.o: $(hdrdir)/ruby/internal/attr/noalias.h
+init.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+init.o: $(hdrdir)/ruby/internal/attr/noinline.h
+init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+init.o: $(hdrdir)/ruby/internal/attr/pure.h
+init.o: $(hdrdir)/ruby/internal/attr/restrict.h
+init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+init.o: $(hdrdir)/ruby/internal/attr/warning.h
+init.o: $(hdrdir)/ruby/internal/attr/weakref.h
+init.o: $(hdrdir)/ruby/internal/cast.h
+init.o: $(hdrdir)/ruby/internal/compiler_is.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+init.o: $(hdrdir)/ruby/internal/compiler_since.h
+init.o: $(hdrdir)/ruby/internal/config.h
+init.o: $(hdrdir)/ruby/internal/constant_p.h
+init.o: $(hdrdir)/ruby/internal/core.h
+init.o: $(hdrdir)/ruby/internal/core/rarray.h
+init.o: $(hdrdir)/ruby/internal/core/rbasic.h
+init.o: $(hdrdir)/ruby/internal/core/rbignum.h
+init.o: $(hdrdir)/ruby/internal/core/rclass.h
+init.o: $(hdrdir)/ruby/internal/core/rdata.h
+init.o: $(hdrdir)/ruby/internal/core/rfile.h
+init.o: $(hdrdir)/ruby/internal/core/rhash.h
+init.o: $(hdrdir)/ruby/internal/core/robject.h
+init.o: $(hdrdir)/ruby/internal/core/rregexp.h
+init.o: $(hdrdir)/ruby/internal/core/rstring.h
+init.o: $(hdrdir)/ruby/internal/core/rstruct.h
+init.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+init.o: $(hdrdir)/ruby/internal/ctype.h
+init.o: $(hdrdir)/ruby/internal/dllexport.h
+init.o: $(hdrdir)/ruby/internal/dosish.h
+init.o: $(hdrdir)/ruby/internal/error.h
+init.o: $(hdrdir)/ruby/internal/eval.h
+init.o: $(hdrdir)/ruby/internal/event.h
+init.o: $(hdrdir)/ruby/internal/fl_type.h
+init.o: $(hdrdir)/ruby/internal/gc.h
+init.o: $(hdrdir)/ruby/internal/glob.h
+init.o: $(hdrdir)/ruby/internal/globals.h
+init.o: $(hdrdir)/ruby/internal/has/attribute.h
+init.o: $(hdrdir)/ruby/internal/has/builtin.h
+init.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/extension.h
+init.o: $(hdrdir)/ruby/internal/has/feature.h
+init.o: $(hdrdir)/ruby/internal/has/warning.h
+init.o: $(hdrdir)/ruby/internal/intern/array.h
+init.o: $(hdrdir)/ruby/internal/intern/bignum.h
+init.o: $(hdrdir)/ruby/internal/intern/class.h
+init.o: $(hdrdir)/ruby/internal/intern/compar.h
+init.o: $(hdrdir)/ruby/internal/intern/complex.h
+init.o: $(hdrdir)/ruby/internal/intern/cont.h
+init.o: $(hdrdir)/ruby/internal/intern/dir.h
+init.o: $(hdrdir)/ruby/internal/intern/enum.h
+init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+init.o: $(hdrdir)/ruby/internal/intern/error.h
+init.o: $(hdrdir)/ruby/internal/intern/eval.h
+init.o: $(hdrdir)/ruby/internal/intern/file.h
+init.o: $(hdrdir)/ruby/internal/intern/hash.h
+init.o: $(hdrdir)/ruby/internal/intern/io.h
+init.o: $(hdrdir)/ruby/internal/intern/load.h
+init.o: $(hdrdir)/ruby/internal/intern/marshal.h
+init.o: $(hdrdir)/ruby/internal/intern/numeric.h
+init.o: $(hdrdir)/ruby/internal/intern/object.h
+init.o: $(hdrdir)/ruby/internal/intern/parse.h
+init.o: $(hdrdir)/ruby/internal/intern/proc.h
+init.o: $(hdrdir)/ruby/internal/intern/process.h
+init.o: $(hdrdir)/ruby/internal/intern/random.h
+init.o: $(hdrdir)/ruby/internal/intern/range.h
+init.o: $(hdrdir)/ruby/internal/intern/rational.h
+init.o: $(hdrdir)/ruby/internal/intern/re.h
+init.o: $(hdrdir)/ruby/internal/intern/ruby.h
+init.o: $(hdrdir)/ruby/internal/intern/select.h
+init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
+init.o: $(hdrdir)/ruby/internal/intern/signal.h
+init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+init.o: $(hdrdir)/ruby/internal/intern/string.h
+init.o: $(hdrdir)/ruby/internal/intern/struct.h
+init.o: $(hdrdir)/ruby/internal/intern/thread.h
+init.o: $(hdrdir)/ruby/internal/intern/time.h
+init.o: $(hdrdir)/ruby/internal/intern/variable.h
+init.o: $(hdrdir)/ruby/internal/intern/vm.h
+init.o: $(hdrdir)/ruby/internal/interpreter.h
+init.o: $(hdrdir)/ruby/internal/iterator.h
+init.o: $(hdrdir)/ruby/internal/memory.h
+init.o: $(hdrdir)/ruby/internal/method.h
+init.o: $(hdrdir)/ruby/internal/module.h
+init.o: $(hdrdir)/ruby/internal/newobj.h
+init.o: $(hdrdir)/ruby/internal/scan_args.h
+init.o: $(hdrdir)/ruby/internal/special_consts.h
+init.o: $(hdrdir)/ruby/internal/static_assert.h
+init.o: $(hdrdir)/ruby/internal/stdalign.h
+init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
+init.o: $(hdrdir)/ruby/internal/symbol.h
+init.o: $(hdrdir)/ruby/internal/value.h
+init.o: $(hdrdir)/ruby/internal/value_type.h
+init.o: $(hdrdir)/ruby/internal/variable.h
+init.o: $(hdrdir)/ruby/internal/warning_push.h
+init.o: $(hdrdir)/ruby/internal/xmalloc.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: init.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/ensure_and_callcc/depend b/ext/-test-/ensure_and_callcc/depend
new file mode 100644
index 0000000000..54431847a6
--- /dev/null
+++ b/ext/-test-/ensure_and_callcc/depend
@@ -0,0 +1,163 @@
+# AUTOGENERATED DEPENDENCIES START
+ensure_and_callcc.o: $(RUBY_EXTCONF_H)
+ensure_and_callcc.o: $(arch_hdrdir)/ruby/config.h
+ensure_and_callcc.o: $(hdrdir)/ruby.h
+ensure_and_callcc.o: $(hdrdir)/ruby/assert.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/assume.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/attributes.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/bool.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/inttypes.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/limits.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/long_long.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/stdalign.h
+ensure_and_callcc.o: $(hdrdir)/ruby/backward/2/stdarg.h
+ensure_and_callcc.o: $(hdrdir)/ruby/defines.h
+ensure_and_callcc.o: $(hdrdir)/ruby/intern.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/abi.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/anyargs.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/assume.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/artificial.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/cold.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/const.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/error.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/format.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/noalias.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/noinline.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/pure.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/restrict.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/warning.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/attr/weakref.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/cast.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/compiler_since.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/config.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/constant_p.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rarray.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rbasic.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rbignum.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rclass.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rdata.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rfile.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rhash.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/robject.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rregexp.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rstring.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rstruct.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/ctype.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/dllexport.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/dosish.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/error.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/eval.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/event.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/fl_type.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/gc.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/glob.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/globals.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/attribute.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/builtin.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/extension.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/feature.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/has/warning.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/array.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/bignum.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/class.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/compar.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/complex.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/cont.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/dir.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/enum.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/error.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/eval.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/file.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/hash.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/io.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/load.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/marshal.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/numeric.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/object.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/parse.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/proc.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/process.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/random.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/range.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/rational.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/re.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/ruby.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/select.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/set.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/signal.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/string.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/struct.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/thread.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/time.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/variable.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/intern/vm.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/interpreter.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/iterator.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/memory.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/method.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/module.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/newobj.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/scan_args.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/special_consts.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/static_assert.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/stdalign.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/stdbool.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/stdckdint.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/symbol.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/value.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/value_type.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/variable.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/warning_push.h
+ensure_and_callcc.o: $(hdrdir)/ruby/internal/xmalloc.h
+ensure_and_callcc.o: $(hdrdir)/ruby/missing.h
+ensure_and_callcc.o: $(hdrdir)/ruby/ruby.h
+ensure_and_callcc.o: $(hdrdir)/ruby/st.h
+ensure_and_callcc.o: $(hdrdir)/ruby/subst.h
+ensure_and_callcc.o: ensure_and_callcc.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/ensure_and_callcc/ensure_and_callcc.c b/ext/-test-/ensure_and_callcc/ensure_and_callcc.c
new file mode 100644
index 0000000000..1a92de69c3
--- /dev/null
+++ b/ext/-test-/ensure_and_callcc/ensure_and_callcc.c
@@ -0,0 +1,58 @@
+#include "ruby.h"
+
+static VALUE rb_mEnsureAndCallcc;
+
+struct require_data {
+ VALUE obj;
+ VALUE fname;
+};
+
+static VALUE
+call_require(VALUE arg)
+{
+ struct require_data *data = (struct require_data *)arg;
+ rb_f_require(data->obj, data->fname);
+ return Qnil;
+}
+
+static VALUE
+call_ensure(VALUE _)
+{
+ VALUE v = rb_iv_get(rb_mEnsureAndCallcc, "@ensure_called");
+ int called = FIX2INT(v) + 1;
+ rb_iv_set(rb_mEnsureAndCallcc, "@ensure_called", INT2FIX(called));
+ return Qnil;
+}
+
+static VALUE
+require_with_ensure(VALUE self, VALUE fname)
+{
+ struct require_data data = {
+ .obj = self,
+ .fname = fname
+ };
+ return rb_ensure(call_require, (VALUE)&data, call_ensure, Qnil);
+}
+
+static VALUE
+ensure_called(VALUE self)
+{
+ return rb_iv_get(rb_mEnsureAndCallcc, "@ensure_called");
+}
+
+static VALUE
+reset(VALUE self)
+{
+ rb_iv_set(rb_mEnsureAndCallcc, "@ensure_called", INT2FIX(0));
+ return Qnil;
+}
+
+void
+Init_ensure_and_callcc(void)
+{
+ rb_mEnsureAndCallcc = rb_define_module("EnsureAndCallcc");
+ rb_iv_set(rb_mEnsureAndCallcc, "@ensure_called", INT2FIX(0));
+ rb_define_singleton_method(rb_mEnsureAndCallcc, "reset", reset, 0);
+ rb_define_singleton_method(rb_mEnsureAndCallcc, "ensure_called", ensure_called, 0);
+ rb_define_singleton_method(rb_mEnsureAndCallcc, "require_with_ensure", require_with_ensure, 1);
+}
diff --git a/ext/-test-/ensure_and_callcc/extconf.rb b/ext/-test-/ensure_and_callcc/extconf.rb
new file mode 100644
index 0000000000..123b80b8d0
--- /dev/null
+++ b/ext/-test-/ensure_and_callcc/extconf.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: false
+require "mkmf"
+
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/enumerator_kw/depend b/ext/-test-/enumerator_kw/depend
index 49ea495421..b6d2f0a998 100644
--- a/ext/-test-/enumerator_kw/depend
+++ b/ext/-test-/enumerator_kw/depend
@@ -128,6 +128,7 @@ enumerator_kw.o: $(hdrdir)/ruby/internal/intern/re.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/ruby.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/select.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+enumerator_kw.o: $(hdrdir)/ruby/internal/intern/set.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/signal.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/sprintf.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ enumerator_kw.o: $(hdrdir)/ruby/internal/special_consts.h
enumerator_kw.o: $(hdrdir)/ruby/internal/static_assert.h
enumerator_kw.o: $(hdrdir)/ruby/internal/stdalign.h
enumerator_kw.o: $(hdrdir)/ruby/internal/stdbool.h
+enumerator_kw.o: $(hdrdir)/ruby/internal/stdckdint.h
enumerator_kw.o: $(hdrdir)/ruby/internal/symbol.h
enumerator_kw.o: $(hdrdir)/ruby/internal/value.h
enumerator_kw.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/eval/depend b/ext/-test-/eval/depend
new file mode 100644
index 0000000000..03a1c7d7ef
--- /dev/null
+++ b/ext/-test-/eval/depend
@@ -0,0 +1,162 @@
+# AUTOGENERATED DEPENDENCIES START
+eval.o: $(RUBY_EXTCONF_H)
+eval.o: $(arch_hdrdir)/ruby/config.h
+eval.o: $(hdrdir)/ruby/assert.h
+eval.o: $(hdrdir)/ruby/backward.h
+eval.o: $(hdrdir)/ruby/backward/2/assume.h
+eval.o: $(hdrdir)/ruby/backward/2/attributes.h
+eval.o: $(hdrdir)/ruby/backward/2/bool.h
+eval.o: $(hdrdir)/ruby/backward/2/inttypes.h
+eval.o: $(hdrdir)/ruby/backward/2/limits.h
+eval.o: $(hdrdir)/ruby/backward/2/long_long.h
+eval.o: $(hdrdir)/ruby/backward/2/stdalign.h
+eval.o: $(hdrdir)/ruby/backward/2/stdarg.h
+eval.o: $(hdrdir)/ruby/defines.h
+eval.o: $(hdrdir)/ruby/intern.h
+eval.o: $(hdrdir)/ruby/internal/abi.h
+eval.o: $(hdrdir)/ruby/internal/anyargs.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+eval.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+eval.o: $(hdrdir)/ruby/internal/assume.h
+eval.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+eval.o: $(hdrdir)/ruby/internal/attr/artificial.h
+eval.o: $(hdrdir)/ruby/internal/attr/cold.h
+eval.o: $(hdrdir)/ruby/internal/attr/const.h
+eval.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+eval.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+eval.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+eval.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+eval.o: $(hdrdir)/ruby/internal/attr/error.h
+eval.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+eval.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+eval.o: $(hdrdir)/ruby/internal/attr/format.h
+eval.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+eval.o: $(hdrdir)/ruby/internal/attr/noalias.h
+eval.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+eval.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+eval.o: $(hdrdir)/ruby/internal/attr/noinline.h
+eval.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+eval.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+eval.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+eval.o: $(hdrdir)/ruby/internal/attr/pure.h
+eval.o: $(hdrdir)/ruby/internal/attr/restrict.h
+eval.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+eval.o: $(hdrdir)/ruby/internal/attr/warning.h
+eval.o: $(hdrdir)/ruby/internal/attr/weakref.h
+eval.o: $(hdrdir)/ruby/internal/cast.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+eval.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+eval.o: $(hdrdir)/ruby/internal/compiler_since.h
+eval.o: $(hdrdir)/ruby/internal/config.h
+eval.o: $(hdrdir)/ruby/internal/constant_p.h
+eval.o: $(hdrdir)/ruby/internal/core.h
+eval.o: $(hdrdir)/ruby/internal/core/rarray.h
+eval.o: $(hdrdir)/ruby/internal/core/rbasic.h
+eval.o: $(hdrdir)/ruby/internal/core/rbignum.h
+eval.o: $(hdrdir)/ruby/internal/core/rclass.h
+eval.o: $(hdrdir)/ruby/internal/core/rdata.h
+eval.o: $(hdrdir)/ruby/internal/core/rfile.h
+eval.o: $(hdrdir)/ruby/internal/core/rhash.h
+eval.o: $(hdrdir)/ruby/internal/core/robject.h
+eval.o: $(hdrdir)/ruby/internal/core/rregexp.h
+eval.o: $(hdrdir)/ruby/internal/core/rstring.h
+eval.o: $(hdrdir)/ruby/internal/core/rstruct.h
+eval.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+eval.o: $(hdrdir)/ruby/internal/ctype.h
+eval.o: $(hdrdir)/ruby/internal/dllexport.h
+eval.o: $(hdrdir)/ruby/internal/dosish.h
+eval.o: $(hdrdir)/ruby/internal/error.h
+eval.o: $(hdrdir)/ruby/internal/eval.h
+eval.o: $(hdrdir)/ruby/internal/event.h
+eval.o: $(hdrdir)/ruby/internal/fl_type.h
+eval.o: $(hdrdir)/ruby/internal/gc.h
+eval.o: $(hdrdir)/ruby/internal/glob.h
+eval.o: $(hdrdir)/ruby/internal/globals.h
+eval.o: $(hdrdir)/ruby/internal/has/attribute.h
+eval.o: $(hdrdir)/ruby/internal/has/builtin.h
+eval.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+eval.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+eval.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+eval.o: $(hdrdir)/ruby/internal/has/extension.h
+eval.o: $(hdrdir)/ruby/internal/has/feature.h
+eval.o: $(hdrdir)/ruby/internal/has/warning.h
+eval.o: $(hdrdir)/ruby/internal/intern/array.h
+eval.o: $(hdrdir)/ruby/internal/intern/bignum.h
+eval.o: $(hdrdir)/ruby/internal/intern/class.h
+eval.o: $(hdrdir)/ruby/internal/intern/compar.h
+eval.o: $(hdrdir)/ruby/internal/intern/complex.h
+eval.o: $(hdrdir)/ruby/internal/intern/cont.h
+eval.o: $(hdrdir)/ruby/internal/intern/dir.h
+eval.o: $(hdrdir)/ruby/internal/intern/enum.h
+eval.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+eval.o: $(hdrdir)/ruby/internal/intern/error.h
+eval.o: $(hdrdir)/ruby/internal/intern/eval.h
+eval.o: $(hdrdir)/ruby/internal/intern/file.h
+eval.o: $(hdrdir)/ruby/internal/intern/hash.h
+eval.o: $(hdrdir)/ruby/internal/intern/io.h
+eval.o: $(hdrdir)/ruby/internal/intern/load.h
+eval.o: $(hdrdir)/ruby/internal/intern/marshal.h
+eval.o: $(hdrdir)/ruby/internal/intern/numeric.h
+eval.o: $(hdrdir)/ruby/internal/intern/object.h
+eval.o: $(hdrdir)/ruby/internal/intern/parse.h
+eval.o: $(hdrdir)/ruby/internal/intern/proc.h
+eval.o: $(hdrdir)/ruby/internal/intern/process.h
+eval.o: $(hdrdir)/ruby/internal/intern/random.h
+eval.o: $(hdrdir)/ruby/internal/intern/range.h
+eval.o: $(hdrdir)/ruby/internal/intern/rational.h
+eval.o: $(hdrdir)/ruby/internal/intern/re.h
+eval.o: $(hdrdir)/ruby/internal/intern/ruby.h
+eval.o: $(hdrdir)/ruby/internal/intern/select.h
+eval.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+eval.o: $(hdrdir)/ruby/internal/intern/set.h
+eval.o: $(hdrdir)/ruby/internal/intern/signal.h
+eval.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+eval.o: $(hdrdir)/ruby/internal/intern/string.h
+eval.o: $(hdrdir)/ruby/internal/intern/struct.h
+eval.o: $(hdrdir)/ruby/internal/intern/thread.h
+eval.o: $(hdrdir)/ruby/internal/intern/time.h
+eval.o: $(hdrdir)/ruby/internal/intern/variable.h
+eval.o: $(hdrdir)/ruby/internal/intern/vm.h
+eval.o: $(hdrdir)/ruby/internal/interpreter.h
+eval.o: $(hdrdir)/ruby/internal/iterator.h
+eval.o: $(hdrdir)/ruby/internal/memory.h
+eval.o: $(hdrdir)/ruby/internal/method.h
+eval.o: $(hdrdir)/ruby/internal/module.h
+eval.o: $(hdrdir)/ruby/internal/newobj.h
+eval.o: $(hdrdir)/ruby/internal/scan_args.h
+eval.o: $(hdrdir)/ruby/internal/special_consts.h
+eval.o: $(hdrdir)/ruby/internal/static_assert.h
+eval.o: $(hdrdir)/ruby/internal/stdalign.h
+eval.o: $(hdrdir)/ruby/internal/stdbool.h
+eval.o: $(hdrdir)/ruby/internal/stdckdint.h
+eval.o: $(hdrdir)/ruby/internal/symbol.h
+eval.o: $(hdrdir)/ruby/internal/value.h
+eval.o: $(hdrdir)/ruby/internal/value_type.h
+eval.o: $(hdrdir)/ruby/internal/variable.h
+eval.o: $(hdrdir)/ruby/internal/warning_push.h
+eval.o: $(hdrdir)/ruby/internal/xmalloc.h
+eval.o: $(hdrdir)/ruby/missing.h
+eval.o: $(hdrdir)/ruby/ruby.h
+eval.o: $(hdrdir)/ruby/st.h
+eval.o: $(hdrdir)/ruby/subst.h
+eval.o: eval.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/exception/depend b/ext/-test-/exception/depend
index 818b4c79df..690e5ad377 100644
--- a/ext/-test-/exception/depend
+++ b/ext/-test-/exception/depend
@@ -127,6 +127,7 @@ dataerror.o: $(hdrdir)/ruby/internal/intern/re.h
dataerror.o: $(hdrdir)/ruby/internal/intern/ruby.h
dataerror.o: $(hdrdir)/ruby/internal/intern/select.h
dataerror.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+dataerror.o: $(hdrdir)/ruby/internal/intern/set.h
dataerror.o: $(hdrdir)/ruby/internal/intern/signal.h
dataerror.o: $(hdrdir)/ruby/internal/intern/sprintf.h
dataerror.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ dataerror.o: $(hdrdir)/ruby/internal/special_consts.h
dataerror.o: $(hdrdir)/ruby/internal/static_assert.h
dataerror.o: $(hdrdir)/ruby/internal/stdalign.h
dataerror.o: $(hdrdir)/ruby/internal/stdbool.h
+dataerror.o: $(hdrdir)/ruby/internal/stdckdint.h
dataerror.o: $(hdrdir)/ruby/internal/symbol.h
dataerror.o: $(hdrdir)/ruby/internal/value.h
dataerror.o: $(hdrdir)/ruby/internal/value_type.h
@@ -296,6 +298,7 @@ enc_raise.o: $(hdrdir)/ruby/internal/intern/re.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/ruby.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/select.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+enc_raise.o: $(hdrdir)/ruby/internal/intern/set.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/signal.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/sprintf.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -315,6 +318,7 @@ enc_raise.o: $(hdrdir)/ruby/internal/special_consts.h
enc_raise.o: $(hdrdir)/ruby/internal/static_assert.h
enc_raise.o: $(hdrdir)/ruby/internal/stdalign.h
enc_raise.o: $(hdrdir)/ruby/internal/stdbool.h
+enc_raise.o: $(hdrdir)/ruby/internal/stdckdint.h
enc_raise.o: $(hdrdir)/ruby/internal/symbol.h
enc_raise.o: $(hdrdir)/ruby/internal/value.h
enc_raise.o: $(hdrdir)/ruby/internal/value_type.h
@@ -457,6 +461,7 @@ ensured.o: $(hdrdir)/ruby/internal/intern/re.h
ensured.o: $(hdrdir)/ruby/internal/intern/ruby.h
ensured.o: $(hdrdir)/ruby/internal/intern/select.h
ensured.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ensured.o: $(hdrdir)/ruby/internal/intern/set.h
ensured.o: $(hdrdir)/ruby/internal/intern/signal.h
ensured.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ensured.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -476,6 +481,7 @@ ensured.o: $(hdrdir)/ruby/internal/special_consts.h
ensured.o: $(hdrdir)/ruby/internal/static_assert.h
ensured.o: $(hdrdir)/ruby/internal/stdalign.h
ensured.o: $(hdrdir)/ruby/internal/stdbool.h
+ensured.o: $(hdrdir)/ruby/internal/stdckdint.h
ensured.o: $(hdrdir)/ruby/internal/symbol.h
ensured.o: $(hdrdir)/ruby/internal/value.h
ensured.o: $(hdrdir)/ruby/internal/value_type.h
@@ -616,6 +622,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -635,6 +642,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/fatal/depend b/ext/-test-/fatal/depend
index 730a72e52a..306bc9099c 100644
--- a/ext/-test-/fatal/depend
+++ b/ext/-test-/fatal/depend
@@ -1,4 +1,327 @@
# AUTOGENERATED DEPENDENCIES START
+
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby.h
+init.o: $(hdrdir)/ruby/assert.h
+init.o: $(hdrdir)/ruby/backward.h
+init.o: $(hdrdir)/ruby/backward/2/assume.h
+init.o: $(hdrdir)/ruby/backward/2/attributes.h
+init.o: $(hdrdir)/ruby/backward/2/bool.h
+init.o: $(hdrdir)/ruby/backward/2/inttypes.h
+init.o: $(hdrdir)/ruby/backward/2/limits.h
+init.o: $(hdrdir)/ruby/backward/2/long_long.h
+init.o: $(hdrdir)/ruby/backward/2/stdalign.h
+init.o: $(hdrdir)/ruby/backward/2/stdarg.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/internal/abi.h
+init.o: $(hdrdir)/ruby/internal/anyargs.h
+init.o: $(hdrdir)/ruby/internal/arithmetic.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+init.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+init.o: $(hdrdir)/ruby/internal/assume.h
+init.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+init.o: $(hdrdir)/ruby/internal/attr/artificial.h
+init.o: $(hdrdir)/ruby/internal/attr/cold.h
+init.o: $(hdrdir)/ruby/internal/attr/const.h
+init.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+init.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+init.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+init.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+init.o: $(hdrdir)/ruby/internal/attr/error.h
+init.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+init.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+init.o: $(hdrdir)/ruby/internal/attr/format.h
+init.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+init.o: $(hdrdir)/ruby/internal/attr/noalias.h
+init.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+init.o: $(hdrdir)/ruby/internal/attr/noinline.h
+init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+init.o: $(hdrdir)/ruby/internal/attr/pure.h
+init.o: $(hdrdir)/ruby/internal/attr/restrict.h
+init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+init.o: $(hdrdir)/ruby/internal/attr/warning.h
+init.o: $(hdrdir)/ruby/internal/attr/weakref.h
+init.o: $(hdrdir)/ruby/internal/cast.h
+init.o: $(hdrdir)/ruby/internal/compiler_is.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+init.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+init.o: $(hdrdir)/ruby/internal/compiler_since.h
+init.o: $(hdrdir)/ruby/internal/config.h
+init.o: $(hdrdir)/ruby/internal/constant_p.h
+init.o: $(hdrdir)/ruby/internal/core.h
+init.o: $(hdrdir)/ruby/internal/core/rarray.h
+init.o: $(hdrdir)/ruby/internal/core/rbasic.h
+init.o: $(hdrdir)/ruby/internal/core/rbignum.h
+init.o: $(hdrdir)/ruby/internal/core/rclass.h
+init.o: $(hdrdir)/ruby/internal/core/rdata.h
+init.o: $(hdrdir)/ruby/internal/core/rfile.h
+init.o: $(hdrdir)/ruby/internal/core/rhash.h
+init.o: $(hdrdir)/ruby/internal/core/robject.h
+init.o: $(hdrdir)/ruby/internal/core/rregexp.h
+init.o: $(hdrdir)/ruby/internal/core/rstring.h
+init.o: $(hdrdir)/ruby/internal/core/rstruct.h
+init.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+init.o: $(hdrdir)/ruby/internal/ctype.h
+init.o: $(hdrdir)/ruby/internal/dllexport.h
+init.o: $(hdrdir)/ruby/internal/dosish.h
+init.o: $(hdrdir)/ruby/internal/error.h
+init.o: $(hdrdir)/ruby/internal/eval.h
+init.o: $(hdrdir)/ruby/internal/event.h
+init.o: $(hdrdir)/ruby/internal/fl_type.h
+init.o: $(hdrdir)/ruby/internal/gc.h
+init.o: $(hdrdir)/ruby/internal/glob.h
+init.o: $(hdrdir)/ruby/internal/globals.h
+init.o: $(hdrdir)/ruby/internal/has/attribute.h
+init.o: $(hdrdir)/ruby/internal/has/builtin.h
+init.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+init.o: $(hdrdir)/ruby/internal/has/extension.h
+init.o: $(hdrdir)/ruby/internal/has/feature.h
+init.o: $(hdrdir)/ruby/internal/has/warning.h
+init.o: $(hdrdir)/ruby/internal/intern/array.h
+init.o: $(hdrdir)/ruby/internal/intern/bignum.h
+init.o: $(hdrdir)/ruby/internal/intern/class.h
+init.o: $(hdrdir)/ruby/internal/intern/compar.h
+init.o: $(hdrdir)/ruby/internal/intern/complex.h
+init.o: $(hdrdir)/ruby/internal/intern/cont.h
+init.o: $(hdrdir)/ruby/internal/intern/dir.h
+init.o: $(hdrdir)/ruby/internal/intern/enum.h
+init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+init.o: $(hdrdir)/ruby/internal/intern/error.h
+init.o: $(hdrdir)/ruby/internal/intern/eval.h
+init.o: $(hdrdir)/ruby/internal/intern/file.h
+init.o: $(hdrdir)/ruby/internal/intern/hash.h
+init.o: $(hdrdir)/ruby/internal/intern/io.h
+init.o: $(hdrdir)/ruby/internal/intern/load.h
+init.o: $(hdrdir)/ruby/internal/intern/marshal.h
+init.o: $(hdrdir)/ruby/internal/intern/numeric.h
+init.o: $(hdrdir)/ruby/internal/intern/object.h
+init.o: $(hdrdir)/ruby/internal/intern/parse.h
+init.o: $(hdrdir)/ruby/internal/intern/proc.h
+init.o: $(hdrdir)/ruby/internal/intern/process.h
+init.o: $(hdrdir)/ruby/internal/intern/random.h
+init.o: $(hdrdir)/ruby/internal/intern/range.h
+init.o: $(hdrdir)/ruby/internal/intern/rational.h
+init.o: $(hdrdir)/ruby/internal/intern/re.h
+init.o: $(hdrdir)/ruby/internal/intern/ruby.h
+init.o: $(hdrdir)/ruby/internal/intern/select.h
+init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
+init.o: $(hdrdir)/ruby/internal/intern/signal.h
+init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+init.o: $(hdrdir)/ruby/internal/intern/string.h
+init.o: $(hdrdir)/ruby/internal/intern/struct.h
+init.o: $(hdrdir)/ruby/internal/intern/thread.h
+init.o: $(hdrdir)/ruby/internal/intern/time.h
+init.o: $(hdrdir)/ruby/internal/intern/variable.h
+init.o: $(hdrdir)/ruby/internal/intern/vm.h
+init.o: $(hdrdir)/ruby/internal/interpreter.h
+init.o: $(hdrdir)/ruby/internal/iterator.h
+init.o: $(hdrdir)/ruby/internal/memory.h
+init.o: $(hdrdir)/ruby/internal/method.h
+init.o: $(hdrdir)/ruby/internal/module.h
+init.o: $(hdrdir)/ruby/internal/newobj.h
+init.o: $(hdrdir)/ruby/internal/scan_args.h
+init.o: $(hdrdir)/ruby/internal/special_consts.h
+init.o: $(hdrdir)/ruby/internal/static_assert.h
+init.o: $(hdrdir)/ruby/internal/stdalign.h
+init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
+init.o: $(hdrdir)/ruby/internal/symbol.h
+init.o: $(hdrdir)/ruby/internal/value.h
+init.o: $(hdrdir)/ruby/internal/value_type.h
+init.o: $(hdrdir)/ruby/internal/variable.h
+init.o: $(hdrdir)/ruby/internal/warning_push.h
+init.o: $(hdrdir)/ruby/internal/xmalloc.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: init.c
+invalid.o: $(RUBY_EXTCONF_H)
+invalid.o: $(arch_hdrdir)/ruby/config.h
+invalid.o: $(hdrdir)/ruby.h
+invalid.o: $(hdrdir)/ruby/assert.h
+invalid.o: $(hdrdir)/ruby/backward.h
+invalid.o: $(hdrdir)/ruby/backward/2/assume.h
+invalid.o: $(hdrdir)/ruby/backward/2/attributes.h
+invalid.o: $(hdrdir)/ruby/backward/2/bool.h
+invalid.o: $(hdrdir)/ruby/backward/2/inttypes.h
+invalid.o: $(hdrdir)/ruby/backward/2/limits.h
+invalid.o: $(hdrdir)/ruby/backward/2/long_long.h
+invalid.o: $(hdrdir)/ruby/backward/2/stdalign.h
+invalid.o: $(hdrdir)/ruby/backward/2/stdarg.h
+invalid.o: $(hdrdir)/ruby/defines.h
+invalid.o: $(hdrdir)/ruby/intern.h
+invalid.o: $(hdrdir)/ruby/internal/abi.h
+invalid.o: $(hdrdir)/ruby/internal/anyargs.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+invalid.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+invalid.o: $(hdrdir)/ruby/internal/assume.h
+invalid.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+invalid.o: $(hdrdir)/ruby/internal/attr/artificial.h
+invalid.o: $(hdrdir)/ruby/internal/attr/cold.h
+invalid.o: $(hdrdir)/ruby/internal/attr/const.h
+invalid.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+invalid.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+invalid.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+invalid.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+invalid.o: $(hdrdir)/ruby/internal/attr/error.h
+invalid.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+invalid.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+invalid.o: $(hdrdir)/ruby/internal/attr/format.h
+invalid.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+invalid.o: $(hdrdir)/ruby/internal/attr/noalias.h
+invalid.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+invalid.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+invalid.o: $(hdrdir)/ruby/internal/attr/noinline.h
+invalid.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+invalid.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+invalid.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+invalid.o: $(hdrdir)/ruby/internal/attr/pure.h
+invalid.o: $(hdrdir)/ruby/internal/attr/restrict.h
+invalid.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+invalid.o: $(hdrdir)/ruby/internal/attr/warning.h
+invalid.o: $(hdrdir)/ruby/internal/attr/weakref.h
+invalid.o: $(hdrdir)/ruby/internal/cast.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+invalid.o: $(hdrdir)/ruby/internal/compiler_since.h
+invalid.o: $(hdrdir)/ruby/internal/config.h
+invalid.o: $(hdrdir)/ruby/internal/constant_p.h
+invalid.o: $(hdrdir)/ruby/internal/core.h
+invalid.o: $(hdrdir)/ruby/internal/core/rarray.h
+invalid.o: $(hdrdir)/ruby/internal/core/rbasic.h
+invalid.o: $(hdrdir)/ruby/internal/core/rbignum.h
+invalid.o: $(hdrdir)/ruby/internal/core/rclass.h
+invalid.o: $(hdrdir)/ruby/internal/core/rdata.h
+invalid.o: $(hdrdir)/ruby/internal/core/rfile.h
+invalid.o: $(hdrdir)/ruby/internal/core/rhash.h
+invalid.o: $(hdrdir)/ruby/internal/core/robject.h
+invalid.o: $(hdrdir)/ruby/internal/core/rregexp.h
+invalid.o: $(hdrdir)/ruby/internal/core/rstring.h
+invalid.o: $(hdrdir)/ruby/internal/core/rstruct.h
+invalid.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+invalid.o: $(hdrdir)/ruby/internal/ctype.h
+invalid.o: $(hdrdir)/ruby/internal/dllexport.h
+invalid.o: $(hdrdir)/ruby/internal/dosish.h
+invalid.o: $(hdrdir)/ruby/internal/error.h
+invalid.o: $(hdrdir)/ruby/internal/eval.h
+invalid.o: $(hdrdir)/ruby/internal/event.h
+invalid.o: $(hdrdir)/ruby/internal/fl_type.h
+invalid.o: $(hdrdir)/ruby/internal/gc.h
+invalid.o: $(hdrdir)/ruby/internal/glob.h
+invalid.o: $(hdrdir)/ruby/internal/globals.h
+invalid.o: $(hdrdir)/ruby/internal/has/attribute.h
+invalid.o: $(hdrdir)/ruby/internal/has/builtin.h
+invalid.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+invalid.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+invalid.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+invalid.o: $(hdrdir)/ruby/internal/has/extension.h
+invalid.o: $(hdrdir)/ruby/internal/has/feature.h
+invalid.o: $(hdrdir)/ruby/internal/has/warning.h
+invalid.o: $(hdrdir)/ruby/internal/intern/array.h
+invalid.o: $(hdrdir)/ruby/internal/intern/bignum.h
+invalid.o: $(hdrdir)/ruby/internal/intern/class.h
+invalid.o: $(hdrdir)/ruby/internal/intern/compar.h
+invalid.o: $(hdrdir)/ruby/internal/intern/complex.h
+invalid.o: $(hdrdir)/ruby/internal/intern/cont.h
+invalid.o: $(hdrdir)/ruby/internal/intern/dir.h
+invalid.o: $(hdrdir)/ruby/internal/intern/enum.h
+invalid.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+invalid.o: $(hdrdir)/ruby/internal/intern/error.h
+invalid.o: $(hdrdir)/ruby/internal/intern/eval.h
+invalid.o: $(hdrdir)/ruby/internal/intern/file.h
+invalid.o: $(hdrdir)/ruby/internal/intern/hash.h
+invalid.o: $(hdrdir)/ruby/internal/intern/io.h
+invalid.o: $(hdrdir)/ruby/internal/intern/load.h
+invalid.o: $(hdrdir)/ruby/internal/intern/marshal.h
+invalid.o: $(hdrdir)/ruby/internal/intern/numeric.h
+invalid.o: $(hdrdir)/ruby/internal/intern/object.h
+invalid.o: $(hdrdir)/ruby/internal/intern/parse.h
+invalid.o: $(hdrdir)/ruby/internal/intern/proc.h
+invalid.o: $(hdrdir)/ruby/internal/intern/process.h
+invalid.o: $(hdrdir)/ruby/internal/intern/random.h
+invalid.o: $(hdrdir)/ruby/internal/intern/range.h
+invalid.o: $(hdrdir)/ruby/internal/intern/rational.h
+invalid.o: $(hdrdir)/ruby/internal/intern/re.h
+invalid.o: $(hdrdir)/ruby/internal/intern/ruby.h
+invalid.o: $(hdrdir)/ruby/internal/intern/select.h
+invalid.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+invalid.o: $(hdrdir)/ruby/internal/intern/set.h
+invalid.o: $(hdrdir)/ruby/internal/intern/signal.h
+invalid.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+invalid.o: $(hdrdir)/ruby/internal/intern/string.h
+invalid.o: $(hdrdir)/ruby/internal/intern/struct.h
+invalid.o: $(hdrdir)/ruby/internal/intern/thread.h
+invalid.o: $(hdrdir)/ruby/internal/intern/time.h
+invalid.o: $(hdrdir)/ruby/internal/intern/variable.h
+invalid.o: $(hdrdir)/ruby/internal/intern/vm.h
+invalid.o: $(hdrdir)/ruby/internal/interpreter.h
+invalid.o: $(hdrdir)/ruby/internal/iterator.h
+invalid.o: $(hdrdir)/ruby/internal/memory.h
+invalid.o: $(hdrdir)/ruby/internal/method.h
+invalid.o: $(hdrdir)/ruby/internal/module.h
+invalid.o: $(hdrdir)/ruby/internal/newobj.h
+invalid.o: $(hdrdir)/ruby/internal/scan_args.h
+invalid.o: $(hdrdir)/ruby/internal/special_consts.h
+invalid.o: $(hdrdir)/ruby/internal/static_assert.h
+invalid.o: $(hdrdir)/ruby/internal/stdalign.h
+invalid.o: $(hdrdir)/ruby/internal/stdbool.h
+invalid.o: $(hdrdir)/ruby/internal/stdckdint.h
+invalid.o: $(hdrdir)/ruby/internal/symbol.h
+invalid.o: $(hdrdir)/ruby/internal/value.h
+invalid.o: $(hdrdir)/ruby/internal/value_type.h
+invalid.o: $(hdrdir)/ruby/internal/variable.h
+invalid.o: $(hdrdir)/ruby/internal/warning_push.h
+invalid.o: $(hdrdir)/ruby/internal/xmalloc.h
+invalid.o: $(hdrdir)/ruby/missing.h
+invalid.o: $(hdrdir)/ruby/ruby.h
+invalid.o: $(hdrdir)/ruby/st.h
+invalid.o: $(hdrdir)/ruby/subst.h
+invalid.o: invalid.c
rb_fatal.o: $(RUBY_EXTCONF_H)
rb_fatal.o: $(arch_hdrdir)/ruby/config.h
rb_fatal.o: $(hdrdir)/ruby.h
@@ -128,6 +451,7 @@ rb_fatal.o: $(hdrdir)/ruby/internal/intern/re.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/ruby.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/select.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rb_fatal.o: $(hdrdir)/ruby/internal/intern/set.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/signal.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +471,7 @@ rb_fatal.o: $(hdrdir)/ruby/internal/special_consts.h
rb_fatal.o: $(hdrdir)/ruby/internal/static_assert.h
rb_fatal.o: $(hdrdir)/ruby/internal/stdalign.h
rb_fatal.o: $(hdrdir)/ruby/internal/stdbool.h
+rb_fatal.o: $(hdrdir)/ruby/internal/stdckdint.h
rb_fatal.o: $(hdrdir)/ruby/internal/symbol.h
rb_fatal.o: $(hdrdir)/ruby/internal/value.h
rb_fatal.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/fatal/extconf.rb b/ext/-test-/fatal/extconf.rb
index d5849c0733..ca51178a18 100644
--- a/ext/-test-/fatal/extconf.rb
+++ b/ext/-test-/fatal/extconf.rb
@@ -1,2 +1,3 @@
# frozen_string_literal: false
-create_makefile("-test-/fatal/rb_fatal")
+require_relative "../auto_ext.rb"
+auto_ext
diff --git a/ext/-test-/fatal/init.c b/ext/-test-/fatal/init.c
new file mode 100644
index 0000000000..3b71708789
--- /dev/null
+++ b/ext/-test-/fatal/init.c
@@ -0,0 +1,10 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_fatal(void)
+{
+ VALUE klass = rb_define_module("Bug");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ext/-test-/fatal/invalid.c b/ext/-test-/fatal/invalid.c
new file mode 100644
index 0000000000..6fd970b181
--- /dev/null
+++ b/ext/-test-/fatal/invalid.c
@@ -0,0 +1,22 @@
+#include <ruby.h>
+
+static VALUE
+invalid_call(VALUE obj, VALUE address)
+{
+ typedef VALUE (*func_type)(VALUE);
+
+ return (*(func_type)NUM2PTR(address))(obj);
+}
+
+static VALUE
+invalid_access(VALUE obj, VALUE address)
+{
+ return *(VALUE *)NUM2PTR(address) == obj ? Qtrue : Qfalse;
+}
+
+void
+Init_invalid(VALUE mBug)
+{
+ rb_define_singleton_method(mBug, "invalid_call", invalid_call, 1);
+ rb_define_singleton_method(mBug, "invalid_access", invalid_access, 1);
+}
diff --git a/ext/-test-/fatal/rb_fatal.c b/ext/-test-/fatal/rb_fatal.c
index eedbc51f8b..6c7bb89628 100644
--- a/ext/-test-/fatal/rb_fatal.c
+++ b/ext/-test-/fatal/rb_fatal.c
@@ -13,8 +13,7 @@ ruby_fatal(VALUE obj, VALUE msg)
}
void
-Init_rb_fatal(void)
+Init_rb_fatal(VALUE mBug)
{
- VALUE mBug = rb_define_module("Bug");
rb_define_singleton_method(mBug, "rb_fatal", ruby_fatal, 1);
}
diff --git a/ext/-test-/file/depend b/ext/-test-/file/depend
index 662136f1ba..fe320f3d44 100644
--- a/ext/-test-/file/depend
+++ b/ext/-test-/file/depend
@@ -137,6 +137,7 @@ fs.o: $(hdrdir)/ruby/internal/intern/re.h
fs.o: $(hdrdir)/ruby/internal/intern/ruby.h
fs.o: $(hdrdir)/ruby/internal/intern/select.h
fs.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+fs.o: $(hdrdir)/ruby/internal/intern/set.h
fs.o: $(hdrdir)/ruby/internal/intern/signal.h
fs.o: $(hdrdir)/ruby/internal/intern/sprintf.h
fs.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -156,6 +157,7 @@ fs.o: $(hdrdir)/ruby/internal/special_consts.h
fs.o: $(hdrdir)/ruby/internal/static_assert.h
fs.o: $(hdrdir)/ruby/internal/stdalign.h
fs.o: $(hdrdir)/ruby/internal/stdbool.h
+fs.o: $(hdrdir)/ruby/internal/stdckdint.h
fs.o: $(hdrdir)/ruby/internal/symbol.h
fs.o: $(hdrdir)/ruby/internal/value.h
fs.o: $(hdrdir)/ruby/internal/value_type.h
@@ -299,6 +301,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -318,6 +321,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -329,6 +333,179 @@ init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
init.o: init.c
+newline_conv.o: $(RUBY_EXTCONF_H)
+newline_conv.o: $(arch_hdrdir)/ruby/config.h
+newline_conv.o: $(hdrdir)/ruby/assert.h
+newline_conv.o: $(hdrdir)/ruby/backward.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/assume.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/attributes.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/bool.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/inttypes.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/limits.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/long_long.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/stdalign.h
+newline_conv.o: $(hdrdir)/ruby/backward/2/stdarg.h
+newline_conv.o: $(hdrdir)/ruby/defines.h
+newline_conv.o: $(hdrdir)/ruby/encoding.h
+newline_conv.o: $(hdrdir)/ruby/intern.h
+newline_conv.o: $(hdrdir)/ruby/internal/abi.h
+newline_conv.o: $(hdrdir)/ruby/internal/anyargs.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+newline_conv.o: $(hdrdir)/ruby/internal/assume.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/artificial.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/cold.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/const.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/error.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/format.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/noalias.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/noinline.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/pure.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/restrict.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/warning.h
+newline_conv.o: $(hdrdir)/ruby/internal/attr/weakref.h
+newline_conv.o: $(hdrdir)/ruby/internal/cast.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+newline_conv.o: $(hdrdir)/ruby/internal/compiler_since.h
+newline_conv.o: $(hdrdir)/ruby/internal/config.h
+newline_conv.o: $(hdrdir)/ruby/internal/constant_p.h
+newline_conv.o: $(hdrdir)/ruby/internal/core.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rarray.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rbasic.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rbignum.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rclass.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rdata.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rfile.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rhash.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/robject.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rregexp.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rstring.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rstruct.h
+newline_conv.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+newline_conv.o: $(hdrdir)/ruby/internal/ctype.h
+newline_conv.o: $(hdrdir)/ruby/internal/dllexport.h
+newline_conv.o: $(hdrdir)/ruby/internal/dosish.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/re.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/string.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+newline_conv.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+newline_conv.o: $(hdrdir)/ruby/internal/error.h
+newline_conv.o: $(hdrdir)/ruby/internal/eval.h
+newline_conv.o: $(hdrdir)/ruby/internal/event.h
+newline_conv.o: $(hdrdir)/ruby/internal/fl_type.h
+newline_conv.o: $(hdrdir)/ruby/internal/gc.h
+newline_conv.o: $(hdrdir)/ruby/internal/glob.h
+newline_conv.o: $(hdrdir)/ruby/internal/globals.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/attribute.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/builtin.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/extension.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/feature.h
+newline_conv.o: $(hdrdir)/ruby/internal/has/warning.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/array.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/bignum.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/class.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/compar.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/complex.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/cont.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/dir.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/enum.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/error.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/eval.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/file.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/hash.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/io.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/load.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/marshal.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/numeric.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/object.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/parse.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/proc.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/process.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/random.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/range.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/rational.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/re.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/ruby.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/select.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/set.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/signal.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/string.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/struct.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/thread.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/time.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/variable.h
+newline_conv.o: $(hdrdir)/ruby/internal/intern/vm.h
+newline_conv.o: $(hdrdir)/ruby/internal/interpreter.h
+newline_conv.o: $(hdrdir)/ruby/internal/iterator.h
+newline_conv.o: $(hdrdir)/ruby/internal/memory.h
+newline_conv.o: $(hdrdir)/ruby/internal/method.h
+newline_conv.o: $(hdrdir)/ruby/internal/module.h
+newline_conv.o: $(hdrdir)/ruby/internal/newobj.h
+newline_conv.o: $(hdrdir)/ruby/internal/scan_args.h
+newline_conv.o: $(hdrdir)/ruby/internal/special_consts.h
+newline_conv.o: $(hdrdir)/ruby/internal/static_assert.h
+newline_conv.o: $(hdrdir)/ruby/internal/stdalign.h
+newline_conv.o: $(hdrdir)/ruby/internal/stdbool.h
+newline_conv.o: $(hdrdir)/ruby/internal/stdckdint.h
+newline_conv.o: $(hdrdir)/ruby/internal/symbol.h
+newline_conv.o: $(hdrdir)/ruby/internal/value.h
+newline_conv.o: $(hdrdir)/ruby/internal/value_type.h
+newline_conv.o: $(hdrdir)/ruby/internal/variable.h
+newline_conv.o: $(hdrdir)/ruby/internal/warning_push.h
+newline_conv.o: $(hdrdir)/ruby/internal/xmalloc.h
+newline_conv.o: $(hdrdir)/ruby/io.h
+newline_conv.o: $(hdrdir)/ruby/missing.h
+newline_conv.o: $(hdrdir)/ruby/onigmo.h
+newline_conv.o: $(hdrdir)/ruby/oniguruma.h
+newline_conv.o: $(hdrdir)/ruby/ruby.h
+newline_conv.o: $(hdrdir)/ruby/st.h
+newline_conv.o: $(hdrdir)/ruby/subst.h
+newline_conv.o: newline_conv.c
stat.o: $(RUBY_EXTCONF_H)
stat.o: $(arch_hdrdir)/ruby/config.h
stat.o: $(hdrdir)/ruby/assert.h
@@ -467,6 +644,7 @@ stat.o: $(hdrdir)/ruby/internal/intern/re.h
stat.o: $(hdrdir)/ruby/internal/intern/ruby.h
stat.o: $(hdrdir)/ruby/internal/intern/select.h
stat.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+stat.o: $(hdrdir)/ruby/internal/intern/set.h
stat.o: $(hdrdir)/ruby/internal/intern/signal.h
stat.o: $(hdrdir)/ruby/internal/intern/sprintf.h
stat.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -486,6 +664,7 @@ stat.o: $(hdrdir)/ruby/internal/special_consts.h
stat.o: $(hdrdir)/ruby/internal/static_assert.h
stat.o: $(hdrdir)/ruby/internal/stdalign.h
stat.o: $(hdrdir)/ruby/internal/stdbool.h
+stat.o: $(hdrdir)/ruby/internal/stdckdint.h
stat.o: $(hdrdir)/ruby/internal/symbol.h
stat.o: $(hdrdir)/ruby/internal/value.h
stat.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/file/newline_conv.c b/ext/-test-/file/newline_conv.c
new file mode 100644
index 0000000000..2ac5aef801
--- /dev/null
+++ b/ext/-test-/file/newline_conv.c
@@ -0,0 +1,73 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+#include <fcntl.h>
+
+static VALUE
+open_with_rb_file_open(VALUE self, VALUE filename, VALUE read_or_write, VALUE binary_or_text)
+{
+ char fmode[3] = { 0 };
+ if (rb_sym2id(read_or_write) == rb_intern("read")) {
+ fmode[0] = 'r';
+ }
+ else if (rb_sym2id(read_or_write) == rb_intern("write")) {
+ fmode[0] = 'w';
+ }
+ else {
+ rb_raise(rb_eArgError, "read_or_write param must be :read or :write");
+ }
+
+ if (rb_sym2id(binary_or_text) == rb_intern("binary")) {
+ fmode[1] = 'b';
+ }
+ else if (rb_sym2id(binary_or_text) == rb_intern("text")) {
+
+ }
+ else {
+ rb_raise(rb_eArgError, "binary_or_text param must be :binary or :text");
+ }
+
+ return rb_file_open(StringValueCStr(filename), fmode);
+}
+
+static VALUE
+open_with_rb_io_fdopen(VALUE self, VALUE filename, VALUE read_or_write, VALUE binary_or_text)
+{
+ int omode = 0;
+ if (rb_sym2id(read_or_write) == rb_intern("read")) {
+ omode |= O_RDONLY;
+ }
+ else if (rb_sym2id(read_or_write) == rb_intern("write")) {
+ omode |= O_WRONLY;
+ }
+ else {
+ rb_raise(rb_eArgError, "read_or_write param must be :read or :write");
+ }
+
+ if (rb_sym2id(binary_or_text) == rb_intern("binary")) {
+#ifdef O_BINARY
+ omode |= O_BINARY;
+#endif
+ }
+ else if (rb_sym2id(binary_or_text) == rb_intern("text")) {
+
+ }
+ else {
+ rb_raise(rb_eArgError, "binary_or_text param must be :binary or :text");
+ }
+
+ int fd = rb_cloexec_open(StringValueCStr(filename), omode, 0);
+ if (fd < 0) {
+ rb_raise(rb_eIOError, "failed to open the file");
+ }
+
+ rb_update_max_fd(fd);
+ return rb_io_fdopen(fd, omode, StringValueCStr(filename));
+}
+
+void
+Init_newline_conv(VALUE module)
+{
+ VALUE newline_conv = rb_define_module_under(module, "NewlineConv");
+ rb_define_module_function(newline_conv, "rb_file_open", open_with_rb_file_open, 3);
+ rb_define_module_function(newline_conv, "rb_io_fdopen", open_with_rb_io_fdopen, 3);
+}
diff --git a/ext/-test-/float/depend b/ext/-test-/float/depend
index 9580a0416c..334ed33c3b 100644
--- a/ext/-test-/float/depend
+++ b/ext/-test-/float/depend
@@ -131,6 +131,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -150,6 +151,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -290,6 +292,7 @@ nextafter.o: $(hdrdir)/ruby/internal/intern/re.h
nextafter.o: $(hdrdir)/ruby/internal/intern/ruby.h
nextafter.o: $(hdrdir)/ruby/internal/intern/select.h
nextafter.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+nextafter.o: $(hdrdir)/ruby/internal/intern/set.h
nextafter.o: $(hdrdir)/ruby/internal/intern/signal.h
nextafter.o: $(hdrdir)/ruby/internal/intern/sprintf.h
nextafter.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -309,6 +312,7 @@ nextafter.o: $(hdrdir)/ruby/internal/special_consts.h
nextafter.o: $(hdrdir)/ruby/internal/static_assert.h
nextafter.o: $(hdrdir)/ruby/internal/stdalign.h
nextafter.o: $(hdrdir)/ruby/internal/stdbool.h
+nextafter.o: $(hdrdir)/ruby/internal/stdckdint.h
nextafter.o: $(hdrdir)/ruby/internal/symbol.h
nextafter.o: $(hdrdir)/ruby/internal/value.h
nextafter.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/funcall/depend b/ext/-test-/funcall/depend
index 6719e4e676..e54370306f 100644
--- a/ext/-test-/funcall/depend
+++ b/ext/-test-/funcall/depend
@@ -128,6 +128,7 @@ funcall.o: $(hdrdir)/ruby/internal/intern/re.h
funcall.o: $(hdrdir)/ruby/internal/intern/ruby.h
funcall.o: $(hdrdir)/ruby/internal/intern/select.h
funcall.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+funcall.o: $(hdrdir)/ruby/internal/intern/set.h
funcall.o: $(hdrdir)/ruby/internal/intern/signal.h
funcall.o: $(hdrdir)/ruby/internal/intern/sprintf.h
funcall.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ funcall.o: $(hdrdir)/ruby/internal/special_consts.h
funcall.o: $(hdrdir)/ruby/internal/static_assert.h
funcall.o: $(hdrdir)/ruby/internal/stdalign.h
funcall.o: $(hdrdir)/ruby/internal/stdbool.h
+funcall.o: $(hdrdir)/ruby/internal/stdckdint.h
funcall.o: $(hdrdir)/ruby/internal/symbol.h
funcall.o: $(hdrdir)/ruby/internal/value.h
funcall.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/gvl/call_without_gvl/depend b/ext/-test-/gvl/call_without_gvl/depend
index a4987a65ca..236d1e1d3b 100644
--- a/ext/-test-/gvl/call_without_gvl/depend
+++ b/ext/-test-/gvl/call_without_gvl/depend
@@ -127,6 +127,7 @@ call_without_gvl.o: $(hdrdir)/ruby/internal/intern/re.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/ruby.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/select.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+call_without_gvl.o: $(hdrdir)/ruby/internal/intern/set.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/signal.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/sprintf.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ call_without_gvl.o: $(hdrdir)/ruby/internal/special_consts.h
call_without_gvl.o: $(hdrdir)/ruby/internal/static_assert.h
call_without_gvl.o: $(hdrdir)/ruby/internal/stdalign.h
call_without_gvl.o: $(hdrdir)/ruby/internal/stdbool.h
+call_without_gvl.o: $(hdrdir)/ruby/internal/stdckdint.h
call_without_gvl.o: $(hdrdir)/ruby/internal/symbol.h
call_without_gvl.o: $(hdrdir)/ruby/internal/value.h
call_without_gvl.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/hash/depend b/ext/-test-/hash/depend
index 58d9a6247e..416b93f9de 100644
--- a/ext/-test-/hash/depend
+++ b/ext/-test-/hash/depend
@@ -128,6 +128,7 @@ delete.o: $(hdrdir)/ruby/internal/intern/re.h
delete.o: $(hdrdir)/ruby/internal/intern/ruby.h
delete.o: $(hdrdir)/ruby/internal/intern/select.h
delete.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+delete.o: $(hdrdir)/ruby/internal/intern/set.h
delete.o: $(hdrdir)/ruby/internal/intern/signal.h
delete.o: $(hdrdir)/ruby/internal/intern/sprintf.h
delete.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ delete.o: $(hdrdir)/ruby/internal/special_consts.h
delete.o: $(hdrdir)/ruby/internal/static_assert.h
delete.o: $(hdrdir)/ruby/internal/stdalign.h
delete.o: $(hdrdir)/ruby/internal/stdbool.h
+delete.o: $(hdrdir)/ruby/internal/stdckdint.h
delete.o: $(hdrdir)/ruby/internal/symbol.h
delete.o: $(hdrdir)/ruby/internal/value.h
delete.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/integer/depend b/ext/-test-/integer/depend
index b68a68ce73..d0589b5e5d 100644
--- a/ext/-test-/integer/depend
+++ b/ext/-test-/integer/depend
@@ -128,6 +128,7 @@ core_ext.o: $(hdrdir)/ruby/internal/intern/re.h
core_ext.o: $(hdrdir)/ruby/internal/intern/ruby.h
core_ext.o: $(hdrdir)/ruby/internal/intern/select.h
core_ext.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+core_ext.o: $(hdrdir)/ruby/internal/intern/set.h
core_ext.o: $(hdrdir)/ruby/internal/intern/signal.h
core_ext.o: $(hdrdir)/ruby/internal/intern/sprintf.h
core_ext.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ core_ext.o: $(hdrdir)/ruby/internal/special_consts.h
core_ext.o: $(hdrdir)/ruby/internal/static_assert.h
core_ext.o: $(hdrdir)/ruby/internal/stdalign.h
core_ext.o: $(hdrdir)/ruby/internal/stdbool.h
+core_ext.o: $(hdrdir)/ruby/internal/stdckdint.h
core_ext.o: $(hdrdir)/ruby/internal/symbol.h
core_ext.o: $(hdrdir)/ruby/internal/value.h
core_ext.o: $(hdrdir)/ruby/internal/value_type.h
@@ -157,8 +159,11 @@ core_ext.o: $(hdrdir)/ruby/missing.h
core_ext.o: $(hdrdir)/ruby/ruby.h
core_ext.o: $(hdrdir)/ruby/st.h
core_ext.o: $(hdrdir)/ruby/subst.h
+core_ext.o: $(top_srcdir)/internal.h
+core_ext.o: $(top_srcdir)/internal/basic_operators.h
core_ext.o: $(top_srcdir)/internal/bignum.h
core_ext.o: $(top_srcdir)/internal/bits.h
+core_ext.o: $(top_srcdir)/internal/compar.h
core_ext.o: $(top_srcdir)/internal/compilers.h
core_ext.o: $(top_srcdir)/internal/fixnum.h
core_ext.o: $(top_srcdir)/internal/numeric.h
@@ -295,6 +300,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -314,6 +320,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -454,6 +461,7 @@ my_integer.o: $(hdrdir)/ruby/internal/intern/re.h
my_integer.o: $(hdrdir)/ruby/internal/intern/ruby.h
my_integer.o: $(hdrdir)/ruby/internal/intern/select.h
my_integer.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+my_integer.o: $(hdrdir)/ruby/internal/intern/set.h
my_integer.o: $(hdrdir)/ruby/internal/intern/signal.h
my_integer.o: $(hdrdir)/ruby/internal/intern/sprintf.h
my_integer.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -473,6 +481,7 @@ my_integer.o: $(hdrdir)/ruby/internal/special_consts.h
my_integer.o: $(hdrdir)/ruby/internal/static_assert.h
my_integer.o: $(hdrdir)/ruby/internal/stdalign.h
my_integer.o: $(hdrdir)/ruby/internal/stdbool.h
+my_integer.o: $(hdrdir)/ruby/internal/stdckdint.h
my_integer.o: $(hdrdir)/ruby/internal/symbol.h
my_integer.o: $(hdrdir)/ruby/internal/value.h
my_integer.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/integer/my_integer.c b/ext/-test-/integer/my_integer.c
index d86474bd7d..94f14d2765 100644
--- a/ext/-test-/integer/my_integer.c
+++ b/ext/-test-/integer/my_integer.c
@@ -1,9 +1,13 @@
#include "ruby.h"
+static const rb_data_type_t my_integer_type = {
+ "MyInteger", {0}, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
static VALUE
my_integer_s_new(VALUE klass)
{
- return Data_Wrap_Struct(klass, 0, 0, 0);
+ return TypedData_Wrap_Struct(klass, &my_integer_type, 0);
}
void
diff --git a/ext/-test-/iseq_load/depend b/ext/-test-/iseq_load/depend
index 30deb6e039..9361ddb938 100644
--- a/ext/-test-/iseq_load/depend
+++ b/ext/-test-/iseq_load/depend
@@ -128,6 +128,7 @@ iseq_load.o: $(hdrdir)/ruby/internal/intern/re.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/ruby.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/select.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+iseq_load.o: $(hdrdir)/ruby/internal/intern/set.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/signal.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/sprintf.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ iseq_load.o: $(hdrdir)/ruby/internal/special_consts.h
iseq_load.o: $(hdrdir)/ruby/internal/static_assert.h
iseq_load.o: $(hdrdir)/ruby/internal/stdalign.h
iseq_load.o: $(hdrdir)/ruby/internal/stdbool.h
+iseq_load.o: $(hdrdir)/ruby/internal/stdckdint.h
iseq_load.o: $(hdrdir)/ruby/internal/symbol.h
iseq_load.o: $(hdrdir)/ruby/internal/value.h
iseq_load.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/iter/depend b/ext/-test-/iter/depend
index 077a283532..161947382c 100644
--- a/ext/-test-/iter/depend
+++ b/ext/-test-/iter/depend
@@ -128,6 +128,7 @@ break.o: $(hdrdir)/ruby/internal/intern/re.h
break.o: $(hdrdir)/ruby/internal/intern/ruby.h
break.o: $(hdrdir)/ruby/internal/intern/select.h
break.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+break.o: $(hdrdir)/ruby/internal/intern/set.h
break.o: $(hdrdir)/ruby/internal/intern/signal.h
break.o: $(hdrdir)/ruby/internal/intern/sprintf.h
break.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ break.o: $(hdrdir)/ruby/internal/special_consts.h
break.o: $(hdrdir)/ruby/internal/static_assert.h
break.o: $(hdrdir)/ruby/internal/stdalign.h
break.o: $(hdrdir)/ruby/internal/stdbool.h
+break.o: $(hdrdir)/ruby/internal/stdckdint.h
break.o: $(hdrdir)/ruby/internal/symbol.h
break.o: $(hdrdir)/ruby/internal/value.h
break.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -446,6 +450,7 @@ yield.o: $(hdrdir)/ruby/internal/intern/re.h
yield.o: $(hdrdir)/ruby/internal/intern/ruby.h
yield.o: $(hdrdir)/ruby/internal/intern/select.h
yield.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+yield.o: $(hdrdir)/ruby/internal/intern/set.h
yield.o: $(hdrdir)/ruby/internal/intern/signal.h
yield.o: $(hdrdir)/ruby/internal/intern/sprintf.h
yield.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -465,6 +470,7 @@ yield.o: $(hdrdir)/ruby/internal/special_consts.h
yield.o: $(hdrdir)/ruby/internal/static_assert.h
yield.o: $(hdrdir)/ruby/internal/stdalign.h
yield.o: $(hdrdir)/ruby/internal/stdbool.h
+yield.o: $(hdrdir)/ruby/internal/stdckdint.h
yield.o: $(hdrdir)/ruby/internal/symbol.h
yield.o: $(hdrdir)/ruby/internal/value.h
yield.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/load/dot.dot/depend b/ext/-test-/load/dot.dot/depend
index be835d3ea5..339837d183 100644
--- a/ext/-test-/load/dot.dot/depend
+++ b/ext/-test-/load/dot.dot/depend
@@ -128,6 +128,7 @@ dot.dot.o: $(hdrdir)/ruby/internal/intern/re.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/ruby.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/select.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+dot.dot.o: $(hdrdir)/ruby/internal/intern/set.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/signal.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/sprintf.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ dot.dot.o: $(hdrdir)/ruby/internal/special_consts.h
dot.dot.o: $(hdrdir)/ruby/internal/static_assert.h
dot.dot.o: $(hdrdir)/ruby/internal/stdalign.h
dot.dot.o: $(hdrdir)/ruby/internal/stdbool.h
+dot.dot.o: $(hdrdir)/ruby/internal/stdckdint.h
dot.dot.o: $(hdrdir)/ruby/internal/symbol.h
dot.dot.o: $(hdrdir)/ruby/internal/value.h
dot.dot.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/load/protect/depend b/ext/-test-/load/protect/depend
index 57cf029901..c76c6f88ed 100644
--- a/ext/-test-/load/protect/depend
+++ b/ext/-test-/load/protect/depend
@@ -128,6 +128,7 @@ protect.o: $(hdrdir)/ruby/internal/intern/re.h
protect.o: $(hdrdir)/ruby/internal/intern/ruby.h
protect.o: $(hdrdir)/ruby/internal/intern/select.h
protect.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+protect.o: $(hdrdir)/ruby/internal/intern/set.h
protect.o: $(hdrdir)/ruby/internal/intern/signal.h
protect.o: $(hdrdir)/ruby/internal/intern/sprintf.h
protect.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ protect.o: $(hdrdir)/ruby/internal/special_consts.h
protect.o: $(hdrdir)/ruby/internal/static_assert.h
protect.o: $(hdrdir)/ruby/internal/stdalign.h
protect.o: $(hdrdir)/ruby/internal/stdbool.h
+protect.o: $(hdrdir)/ruby/internal/stdckdint.h
protect.o: $(hdrdir)/ruby/internal/symbol.h
protect.o: $(hdrdir)/ruby/internal/value.h
protect.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/load/resolve_symbol_resolver/depend b/ext/-test-/load/resolve_symbol_resolver/depend
new file mode 100644
index 0000000000..f422898b69
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_resolver/depend
@@ -0,0 +1,163 @@
+# AUTOGENERATED DEPENDENCIES START
+resolve_symbol_resolver.o: $(RUBY_EXTCONF_H)
+resolve_symbol_resolver.o: $(arch_hdrdir)/ruby/config.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/assert.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/assume.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/attributes.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/bool.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/inttypes.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/limits.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/long_long.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/stdalign.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/backward/2/stdarg.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/defines.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/intern.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/abi.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/anyargs.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/assume.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/artificial.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/cold.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/const.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/error.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/format.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/noalias.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/noinline.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/pure.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/restrict.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/warning.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/attr/weakref.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/cast.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/compiler_since.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/config.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/constant_p.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rarray.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rbasic.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rbignum.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rclass.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rdata.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rfile.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rhash.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/robject.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rregexp.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rstring.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rstruct.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/ctype.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/dllexport.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/dosish.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/error.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/eval.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/event.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/fl_type.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/gc.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/glob.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/globals.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/attribute.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/builtin.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/extension.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/feature.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/has/warning.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/array.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/bignum.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/class.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/compar.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/complex.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/cont.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/dir.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/enum.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/error.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/eval.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/file.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/hash.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/io.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/load.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/marshal.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/numeric.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/object.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/parse.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/proc.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/process.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/random.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/range.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/rational.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/re.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/ruby.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/select.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/set.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/signal.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/string.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/struct.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/thread.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/time.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/variable.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/intern/vm.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/interpreter.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/iterator.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/memory.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/method.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/module.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/newobj.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/scan_args.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/special_consts.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/static_assert.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/stdalign.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/stdbool.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/stdckdint.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/symbol.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/value.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/value_type.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/variable.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/warning_push.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/internal/xmalloc.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/missing.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/ruby.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/st.h
+resolve_symbol_resolver.o: $(hdrdir)/ruby/subst.h
+resolve_symbol_resolver.o: resolve_symbol_resolver.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/load/resolve_symbol_resolver/extconf.rb b/ext/-test-/load/resolve_symbol_resolver/extconf.rb
new file mode 100644
index 0000000000..2299efcfd3
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_resolver/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/resolve_symbol_resolver')
diff --git a/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c b/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c
new file mode 100644
index 0000000000..6cc07cc1f8
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c
@@ -0,0 +1,56 @@
+#include <ruby.h>
+#include "ruby/internal/intern/load.h"
+
+typedef VALUE(*target_func)(VALUE);
+
+static target_func rst_any_method;
+
+#define resolve_func(file, name) (target_func)(uintptr_t)rb_ext_resolve_symbol(file, name)
+VALUE
+rsr_any_method(VALUE klass)
+{
+ return rst_any_method((VALUE)NULL);
+}
+
+VALUE
+rsr_try_resolve_fname(VALUE klass)
+{
+ target_func rst_something_missing =
+ resolve_func("-test-/load/resolve_symbol_missing", "rst_any_method");
+ if (rst_something_missing == NULL) {
+ // This should be done in Init_*, so the error is LoadError
+ rb_raise(rb_eLoadError, "symbol not found: missing fname");
+ }
+ return Qtrue;
+}
+
+VALUE
+rsr_try_resolve_sname(VALUE klass)
+{
+ target_func rst_something_missing =
+ resolve_func("-test-/load/resolve_symbol_target", "rst_something_missing");
+ if (rst_something_missing == NULL) {
+ // This should be done in Init_*, so the error is LoadError
+ rb_raise(rb_eLoadError, "symbol not found: missing sname");
+ }
+ return Qtrue;
+}
+
+void
+Init_resolve_symbol_resolver(void)
+{
+ /*
+ * Resolving symbols at the head of Init_ because it raises LoadError (in cases).
+ * If the module and methods are defined before raising LoadError, retrying `require "this.so"` will
+ * cause re-defining those methods (and will be warned).
+ */
+ rst_any_method = resolve_func("-test-/load/resolve_symbol_target", "rst_any_method");
+ if (rst_any_method == NULL) {
+ rb_raise(rb_eLoadError, "resolve_symbol_target is not loaded");
+ }
+
+ VALUE mod = rb_define_module("ResolveSymbolResolver");
+ rb_define_singleton_method(mod, "any_method", rsr_any_method, 0);
+ rb_define_singleton_method(mod, "try_resolve_fname", rsr_try_resolve_fname, 0);
+ rb_define_singleton_method(mod, "try_resolve_sname", rsr_try_resolve_sname, 0);
+}
diff --git a/ext/-test-/load/resolve_symbol_target/depend b/ext/-test-/load/resolve_symbol_target/depend
new file mode 100644
index 0000000000..aa0b5327be
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/depend
@@ -0,0 +1,164 @@
+# AUTOGENERATED DEPENDENCIES START
+resolve_symbol_target.o: $(RUBY_EXTCONF_H)
+resolve_symbol_target.o: $(arch_hdrdir)/ruby/config.h
+resolve_symbol_target.o: $(hdrdir)/ruby.h
+resolve_symbol_target.o: $(hdrdir)/ruby/assert.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/assume.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/attributes.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/bool.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/inttypes.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/limits.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/long_long.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/stdalign.h
+resolve_symbol_target.o: $(hdrdir)/ruby/backward/2/stdarg.h
+resolve_symbol_target.o: $(hdrdir)/ruby/defines.h
+resolve_symbol_target.o: $(hdrdir)/ruby/intern.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/abi.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/anyargs.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/assume.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/artificial.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/cold.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/const.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/error.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/format.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/noalias.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/noinline.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/pure.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/restrict.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/warning.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/attr/weakref.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/cast.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/compiler_since.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/config.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/constant_p.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rarray.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rbasic.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rbignum.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rclass.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rdata.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rfile.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rhash.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/robject.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rregexp.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rstring.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rstruct.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/ctype.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/dllexport.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/dosish.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/error.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/eval.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/event.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/fl_type.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/gc.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/glob.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/globals.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/attribute.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/builtin.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/extension.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/feature.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/has/warning.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/array.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/bignum.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/class.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/compar.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/complex.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/cont.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/dir.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/enum.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/error.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/eval.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/file.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/hash.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/io.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/load.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/marshal.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/numeric.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/object.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/parse.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/proc.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/process.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/random.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/range.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/rational.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/re.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/ruby.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/select.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/set.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/signal.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/string.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/struct.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/thread.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/time.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/variable.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/intern/vm.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/interpreter.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/iterator.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/memory.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/method.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/module.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/newobj.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/scan_args.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/special_consts.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/static_assert.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/stdalign.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/stdbool.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/stdckdint.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/symbol.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/value.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/value_type.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/variable.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/warning_push.h
+resolve_symbol_target.o: $(hdrdir)/ruby/internal/xmalloc.h
+resolve_symbol_target.o: $(hdrdir)/ruby/missing.h
+resolve_symbol_target.o: $(hdrdir)/ruby/ruby.h
+resolve_symbol_target.o: $(hdrdir)/ruby/st.h
+resolve_symbol_target.o: $(hdrdir)/ruby/subst.h
+resolve_symbol_target.o: resolve_symbol_target.c
+resolve_symbol_target.o: resolve_symbol_target.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/load/resolve_symbol_target/extconf.rb b/ext/-test-/load/resolve_symbol_target/extconf.rb
new file mode 100644
index 0000000000..b5a99ca7f1
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/resolve_symbol_target')
diff --git a/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c
new file mode 100644
index 0000000000..b5bc9e8ee0
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include "resolve_symbol_target.h"
+
+VALUE
+rst_any_method(VALUE klass)
+{
+ return rb_str_new_cstr("from target");
+}
+
+void
+Init_resolve_symbol_target(void)
+{
+ VALUE mod = rb_define_module("ResolveSymbolTarget");
+ rb_define_singleton_method(mod, "any_method", rst_any_method, 0);
+}
diff --git a/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h
new file mode 100644
index 0000000000..847dcb7dd3
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_FUNC_EXPORTED VALUE rst_any_method(VALUE);
diff --git a/ext/-test-/load/stringify_symbols/depend b/ext/-test-/load/stringify_symbols/depend
new file mode 100644
index 0000000000..2d4d79a7b7
--- /dev/null
+++ b/ext/-test-/load/stringify_symbols/depend
@@ -0,0 +1,164 @@
+# AUTOGENERATED DEPENDENCIES START
+stringify_symbols.o: $(RUBY_EXTCONF_H)
+stringify_symbols.o: $(arch_hdrdir)/ruby/config.h
+stringify_symbols.o: $(hdrdir)/ruby.h
+stringify_symbols.o: $(hdrdir)/ruby/assert.h
+stringify_symbols.o: $(hdrdir)/ruby/backward.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/assume.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/attributes.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/bool.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/inttypes.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/limits.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/long_long.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/stdalign.h
+stringify_symbols.o: $(hdrdir)/ruby/backward/2/stdarg.h
+stringify_symbols.o: $(hdrdir)/ruby/defines.h
+stringify_symbols.o: $(hdrdir)/ruby/intern.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/abi.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/anyargs.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/assume.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/artificial.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/cold.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/const.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/error.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/format.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/noalias.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/noinline.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/pure.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/restrict.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/warning.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/attr/weakref.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/cast.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/compiler_since.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/config.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/constant_p.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rarray.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rbasic.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rbignum.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rclass.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rdata.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rfile.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rhash.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/robject.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rregexp.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rstring.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rstruct.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/ctype.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/dllexport.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/dosish.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/error.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/eval.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/event.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/fl_type.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/gc.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/glob.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/globals.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/attribute.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/builtin.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/extension.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/feature.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/has/warning.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/array.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/bignum.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/class.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/compar.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/complex.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/cont.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/dir.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/enum.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/error.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/eval.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/file.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/hash.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/io.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/load.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/marshal.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/numeric.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/object.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/parse.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/proc.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/process.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/random.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/range.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/rational.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/re.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/ruby.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/select.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/set.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/signal.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/string.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/struct.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/thread.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/time.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/variable.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/intern/vm.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/interpreter.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/iterator.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/memory.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/method.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/module.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/newobj.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/scan_args.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/special_consts.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/static_assert.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/stdalign.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/stdbool.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/stdckdint.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/symbol.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/value.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/value_type.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/variable.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/warning_push.h
+stringify_symbols.o: $(hdrdir)/ruby/internal/xmalloc.h
+stringify_symbols.o: $(hdrdir)/ruby/missing.h
+stringify_symbols.o: $(hdrdir)/ruby/ruby.h
+stringify_symbols.o: $(hdrdir)/ruby/st.h
+stringify_symbols.o: $(hdrdir)/ruby/subst.h
+stringify_symbols.o: $(hdrdir)/ruby/util.h
+stringify_symbols.o: stringify_symbols.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/load/stringify_symbols/extconf.rb b/ext/-test-/load/stringify_symbols/extconf.rb
new file mode 100644
index 0000000000..ac39c15f09
--- /dev/null
+++ b/ext/-test-/load/stringify_symbols/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/stringify_symbols')
diff --git a/ext/-test-/load/stringify_symbols/stringify_symbols.c b/ext/-test-/load/stringify_symbols/stringify_symbols.c
new file mode 100644
index 0000000000..11a5ee3bc5
--- /dev/null
+++ b/ext/-test-/load/stringify_symbols/stringify_symbols.c
@@ -0,0 +1,29 @@
+#include <ruby.h>
+#include "ruby/internal/intern/load.h"
+#include "ruby/util.h"
+
+#if SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
+# define UINTPTR2NUM ULL2NUM
+#elif SIZEOF_INTPTR_T == SIZEOF_LONG
+# define UINTPTR2NUM ULONG2NUM
+#else
+# define UINTPTR2NUM UINT2NUM
+#endif
+
+static VALUE
+stringify_symbol(VALUE klass, VALUE fname, VALUE sname)
+{
+ void *ptr = rb_ext_resolve_symbol(StringValueCStr(fname), StringValueCStr(sname));
+ if (ptr == NULL) {
+ return Qnil;
+ }
+ uintptr_t uintptr = (uintptr_t)ptr;
+ return UINTPTR2NUM(uintptr);
+}
+
+void
+Init_stringify_symbols(void)
+{
+ VALUE mod = rb_define_module("StringifySymbols");
+ rb_define_singleton_method(mod, "stringify_symbol", stringify_symbol, 2);
+}
diff --git a/ext/-test-/load/stringify_target/depend b/ext/-test-/load/stringify_target/depend
new file mode 100644
index 0000000000..c66575d4e4
--- /dev/null
+++ b/ext/-test-/load/stringify_target/depend
@@ -0,0 +1,164 @@
+# AUTOGENERATED DEPENDENCIES START
+stringify_target.o: $(RUBY_EXTCONF_H)
+stringify_target.o: $(arch_hdrdir)/ruby/config.h
+stringify_target.o: $(hdrdir)/ruby.h
+stringify_target.o: $(hdrdir)/ruby/assert.h
+stringify_target.o: $(hdrdir)/ruby/backward.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/assume.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/attributes.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/bool.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/inttypes.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/limits.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/long_long.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/stdalign.h
+stringify_target.o: $(hdrdir)/ruby/backward/2/stdarg.h
+stringify_target.o: $(hdrdir)/ruby/defines.h
+stringify_target.o: $(hdrdir)/ruby/intern.h
+stringify_target.o: $(hdrdir)/ruby/internal/abi.h
+stringify_target.o: $(hdrdir)/ruby/internal/anyargs.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+stringify_target.o: $(hdrdir)/ruby/internal/assume.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/artificial.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/cold.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/const.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/error.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/format.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/noalias.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/noinline.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/pure.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/restrict.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/warning.h
+stringify_target.o: $(hdrdir)/ruby/internal/attr/weakref.h
+stringify_target.o: $(hdrdir)/ruby/internal/cast.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+stringify_target.o: $(hdrdir)/ruby/internal/compiler_since.h
+stringify_target.o: $(hdrdir)/ruby/internal/config.h
+stringify_target.o: $(hdrdir)/ruby/internal/constant_p.h
+stringify_target.o: $(hdrdir)/ruby/internal/core.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rarray.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rbasic.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rbignum.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rclass.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rdata.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rfile.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rhash.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/robject.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rregexp.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rstring.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rstruct.h
+stringify_target.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+stringify_target.o: $(hdrdir)/ruby/internal/ctype.h
+stringify_target.o: $(hdrdir)/ruby/internal/dllexport.h
+stringify_target.o: $(hdrdir)/ruby/internal/dosish.h
+stringify_target.o: $(hdrdir)/ruby/internal/error.h
+stringify_target.o: $(hdrdir)/ruby/internal/eval.h
+stringify_target.o: $(hdrdir)/ruby/internal/event.h
+stringify_target.o: $(hdrdir)/ruby/internal/fl_type.h
+stringify_target.o: $(hdrdir)/ruby/internal/gc.h
+stringify_target.o: $(hdrdir)/ruby/internal/glob.h
+stringify_target.o: $(hdrdir)/ruby/internal/globals.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/attribute.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/builtin.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/extension.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/feature.h
+stringify_target.o: $(hdrdir)/ruby/internal/has/warning.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/array.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/bignum.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/class.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/compar.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/complex.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/cont.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/dir.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/enum.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/error.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/eval.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/file.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/hash.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/io.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/load.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/marshal.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/numeric.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/object.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/parse.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/proc.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/process.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/random.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/range.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/rational.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/re.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/ruby.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/select.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/set.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/signal.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/string.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/struct.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/thread.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/time.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/variable.h
+stringify_target.o: $(hdrdir)/ruby/internal/intern/vm.h
+stringify_target.o: $(hdrdir)/ruby/internal/interpreter.h
+stringify_target.o: $(hdrdir)/ruby/internal/iterator.h
+stringify_target.o: $(hdrdir)/ruby/internal/memory.h
+stringify_target.o: $(hdrdir)/ruby/internal/method.h
+stringify_target.o: $(hdrdir)/ruby/internal/module.h
+stringify_target.o: $(hdrdir)/ruby/internal/newobj.h
+stringify_target.o: $(hdrdir)/ruby/internal/scan_args.h
+stringify_target.o: $(hdrdir)/ruby/internal/special_consts.h
+stringify_target.o: $(hdrdir)/ruby/internal/static_assert.h
+stringify_target.o: $(hdrdir)/ruby/internal/stdalign.h
+stringify_target.o: $(hdrdir)/ruby/internal/stdbool.h
+stringify_target.o: $(hdrdir)/ruby/internal/stdckdint.h
+stringify_target.o: $(hdrdir)/ruby/internal/symbol.h
+stringify_target.o: $(hdrdir)/ruby/internal/value.h
+stringify_target.o: $(hdrdir)/ruby/internal/value_type.h
+stringify_target.o: $(hdrdir)/ruby/internal/variable.h
+stringify_target.o: $(hdrdir)/ruby/internal/warning_push.h
+stringify_target.o: $(hdrdir)/ruby/internal/xmalloc.h
+stringify_target.o: $(hdrdir)/ruby/missing.h
+stringify_target.o: $(hdrdir)/ruby/ruby.h
+stringify_target.o: $(hdrdir)/ruby/st.h
+stringify_target.o: $(hdrdir)/ruby/subst.h
+stringify_target.o: stringify_target.c
+stringify_target.o: stringify_target.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/load/stringify_target/extconf.rb b/ext/-test-/load/stringify_target/extconf.rb
new file mode 100644
index 0000000000..4aa201cb09
--- /dev/null
+++ b/ext/-test-/load/stringify_target/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/stringify_target')
diff --git a/ext/-test-/load/stringify_target/stringify_target.c b/ext/-test-/load/stringify_target/stringify_target.c
new file mode 100644
index 0000000000..ce09b8fd77
--- /dev/null
+++ b/ext/-test-/load/stringify_target/stringify_target.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include "stringify_target.h"
+
+VALUE
+stt_any_method(VALUE klass)
+{
+ return rb_str_new_cstr("from target");
+}
+
+void
+Init_stringify_target(void)
+{
+ VALUE mod = rb_define_module("StringifyTarget");
+ rb_define_singleton_method(mod, "any_method", stt_any_method, 0);
+}
diff --git a/ext/-test-/load/stringify_target/stringify_target.h b/ext/-test-/load/stringify_target/stringify_target.h
new file mode 100644
index 0000000000..d95fb65d7c
--- /dev/null
+++ b/ext/-test-/load/stringify_target/stringify_target.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_FUNC_EXPORTED VALUE stt_any_method(VALUE);
diff --git a/ext/-test-/marshal/compat/depend b/ext/-test-/marshal/compat/depend
index ff675ccabb..36b9235c23 100644
--- a/ext/-test-/marshal/compat/depend
+++ b/ext/-test-/marshal/compat/depend
@@ -128,6 +128,7 @@ usrcompat.o: $(hdrdir)/ruby/internal/intern/re.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/ruby.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/select.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+usrcompat.o: $(hdrdir)/ruby/internal/intern/set.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/signal.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/sprintf.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ usrcompat.o: $(hdrdir)/ruby/internal/special_consts.h
usrcompat.o: $(hdrdir)/ruby/internal/static_assert.h
usrcompat.o: $(hdrdir)/ruby/internal/stdalign.h
usrcompat.o: $(hdrdir)/ruby/internal/stdbool.h
+usrcompat.o: $(hdrdir)/ruby/internal/stdckdint.h
usrcompat.o: $(hdrdir)/ruby/internal/symbol.h
usrcompat.o: $(hdrdir)/ruby/internal/value.h
usrcompat.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/marshal/internal_ivar/depend b/ext/-test-/marshal/internal_ivar/depend
index 4fe36834d8..a2e093d809 100644
--- a/ext/-test-/marshal/internal_ivar/depend
+++ b/ext/-test-/marshal/internal_ivar/depend
@@ -128,6 +128,7 @@ internal_ivar.o: $(hdrdir)/ruby/internal/intern/re.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/ruby.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/select.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+internal_ivar.o: $(hdrdir)/ruby/internal/intern/set.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/signal.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/sprintf.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ internal_ivar.o: $(hdrdir)/ruby/internal/special_consts.h
internal_ivar.o: $(hdrdir)/ruby/internal/static_assert.h
internal_ivar.o: $(hdrdir)/ruby/internal/stdalign.h
internal_ivar.o: $(hdrdir)/ruby/internal/stdbool.h
+internal_ivar.o: $(hdrdir)/ruby/internal/stdckdint.h
internal_ivar.o: $(hdrdir)/ruby/internal/symbol.h
internal_ivar.o: $(hdrdir)/ruby/internal/value.h
internal_ivar.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/marshal/internal_ivar/internal_ivar.c b/ext/-test-/marshal/internal_ivar/internal_ivar.c
index b2188f737a..2e2f9cb235 100644
--- a/ext/-test-/marshal/internal_ivar/internal_ivar.c
+++ b/ext/-test-/marshal/internal_ivar/internal_ivar.c
@@ -1,13 +1,14 @@
#include <ruby.h>
-static ID id_normal_ivar, id_internal_ivar, id_encoding_short;
+static ID id_normal_ivar, id_internal_ivar, id_encoding_short, id_encoding_long;
static VALUE
-init(VALUE self, VALUE arg1, VALUE arg2, VALUE arg3)
+init(VALUE self, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4)
{
rb_ivar_set(self, id_normal_ivar, arg1);
rb_ivar_set(self, id_internal_ivar, arg2);
rb_ivar_set(self, id_encoding_short, arg3);
+ rb_ivar_set(self, id_encoding_long, arg4);
return self;
}
@@ -29,6 +30,12 @@ get_encoding_short(VALUE self)
return rb_attr_get(self, id_encoding_short);
}
+static VALUE
+get_encoding_long(VALUE self)
+{
+ return rb_attr_get(self, id_encoding_long);
+}
+
void
Init_internal_ivar(void)
{
@@ -38,8 +45,10 @@ Init_internal_ivar(void)
id_normal_ivar = rb_intern_const("normal");
id_internal_ivar = rb_intern_const("K");
id_encoding_short = rb_intern_const("E");
- rb_define_method(newclass, "initialize", init, 3);
+ id_encoding_long = rb_intern_const("encoding");
+ rb_define_method(newclass, "initialize", init, 4);
rb_define_method(newclass, "normal", get_normal, 0);
rb_define_method(newclass, "internal", get_internal, 0);
rb_define_method(newclass, "encoding_short", get_encoding_short, 0);
+ rb_define_method(newclass, "encoding_long", get_encoding_long, 0);
}
diff --git a/ext/-test-/marshal/usr/depend b/ext/-test-/marshal/usr/depend
index 1d56cc8202..5ffb8c58de 100644
--- a/ext/-test-/marshal/usr/depend
+++ b/ext/-test-/marshal/usr/depend
@@ -128,6 +128,7 @@ usrmarshal.o: $(hdrdir)/ruby/internal/intern/re.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/ruby.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/select.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+usrmarshal.o: $(hdrdir)/ruby/internal/intern/set.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/signal.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/sprintf.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ usrmarshal.o: $(hdrdir)/ruby/internal/special_consts.h
usrmarshal.o: $(hdrdir)/ruby/internal/static_assert.h
usrmarshal.o: $(hdrdir)/ruby/internal/stdalign.h
usrmarshal.o: $(hdrdir)/ruby/internal/stdbool.h
+usrmarshal.o: $(hdrdir)/ruby/internal/stdckdint.h
usrmarshal.o: $(hdrdir)/ruby/internal/symbol.h
usrmarshal.o: $(hdrdir)/ruby/internal/value.h
usrmarshal.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/memory_status/depend b/ext/-test-/memory_status/depend
index 52e2fe8e1f..4dd503e1bb 100644
--- a/ext/-test-/memory_status/depend
+++ b/ext/-test-/memory_status/depend
@@ -147,6 +147,7 @@ memory_status.o: $(hdrdir)/ruby/internal/special_consts.h
memory_status.o: $(hdrdir)/ruby/internal/static_assert.h
memory_status.o: $(hdrdir)/ruby/internal/stdalign.h
memory_status.o: $(hdrdir)/ruby/internal/stdbool.h
+memory_status.o: $(hdrdir)/ruby/internal/stdckdint.h
memory_status.o: $(hdrdir)/ruby/internal/symbol.h
memory_status.o: $(hdrdir)/ruby/internal/value.h
memory_status.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/memory_view/depend b/ext/-test-/memory_view/depend
index c9ef06a15c..a6ffd76f45 100644
--- a/ext/-test-/memory_view/depend
+++ b/ext/-test-/memory_view/depend
@@ -128,6 +128,7 @@ memory_view.o: $(hdrdir)/ruby/internal/intern/re.h
memory_view.o: $(hdrdir)/ruby/internal/intern/ruby.h
memory_view.o: $(hdrdir)/ruby/internal/intern/select.h
memory_view.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+memory_view.o: $(hdrdir)/ruby/internal/intern/set.h
memory_view.o: $(hdrdir)/ruby/internal/intern/signal.h
memory_view.o: $(hdrdir)/ruby/internal/intern/sprintf.h
memory_view.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ memory_view.o: $(hdrdir)/ruby/internal/special_consts.h
memory_view.o: $(hdrdir)/ruby/internal/static_assert.h
memory_view.o: $(hdrdir)/ruby/internal/stdalign.h
memory_view.o: $(hdrdir)/ruby/internal/stdbool.h
+memory_view.o: $(hdrdir)/ruby/internal/stdckdint.h
memory_view.o: $(hdrdir)/ruby/internal/symbol.h
memory_view.o: $(hdrdir)/ruby/internal/value.h
memory_view.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c
index c1df0353cf..63f0beb81e 100644
--- a/ext/-test-/memory_view/memory_view.c
+++ b/ext/-test-/memory_view/memory_view.c
@@ -313,8 +313,8 @@ mdview_get_memory_view(VALUE obj, rb_memory_view_t *view, int flags)
static bool
mdview_release_memory_view(VALUE obj, rb_memory_view_t *view)
{
- if (view->shape) xfree((void *)view->shape);
- if (view->strides) xfree((void *)view->strides);
+ xfree((void *)view->shape);
+ xfree((void *)view->strides);
return true;
}
diff --git a/ext/-test-/method/depend b/ext/-test-/method/depend
index dbf513f48f..95745b3dae 100644
--- a/ext/-test-/method/depend
+++ b/ext/-test-/method/depend
@@ -128,6 +128,7 @@ arity.o: $(hdrdir)/ruby/internal/intern/re.h
arity.o: $(hdrdir)/ruby/internal/intern/ruby.h
arity.o: $(hdrdir)/ruby/internal/intern/select.h
arity.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+arity.o: $(hdrdir)/ruby/internal/intern/set.h
arity.o: $(hdrdir)/ruby/internal/intern/signal.h
arity.o: $(hdrdir)/ruby/internal/intern/sprintf.h
arity.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ arity.o: $(hdrdir)/ruby/internal/special_consts.h
arity.o: $(hdrdir)/ruby/internal/static_assert.h
arity.o: $(hdrdir)/ruby/internal/stdalign.h
arity.o: $(hdrdir)/ruby/internal/stdbool.h
+arity.o: $(hdrdir)/ruby/internal/stdckdint.h
arity.o: $(hdrdir)/ruby/internal/symbol.h
arity.o: $(hdrdir)/ruby/internal/value.h
arity.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/notimplement/depend b/ext/-test-/notimplement/depend
index 9105093b0d..69c970b6f2 100644
--- a/ext/-test-/notimplement/depend
+++ b/ext/-test-/notimplement/depend
@@ -128,6 +128,7 @@ bug.o: $(hdrdir)/ruby/internal/intern/re.h
bug.o: $(hdrdir)/ruby/internal/intern/ruby.h
bug.o: $(hdrdir)/ruby/internal/intern/select.h
bug.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bug.o: $(hdrdir)/ruby/internal/intern/set.h
bug.o: $(hdrdir)/ruby/internal/intern/signal.h
bug.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bug.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
bug.o: $(hdrdir)/ruby/internal/stdalign.h
bug.o: $(hdrdir)/ruby/internal/stdbool.h
+bug.o: $(hdrdir)/ruby/internal/stdckdint.h
bug.o: $(hdrdir)/ruby/internal/symbol.h
bug.o: $(hdrdir)/ruby/internal/value.h
bug.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/num2int/depend b/ext/-test-/num2int/depend
index 4e05d1e8c1..75536363ac 100644
--- a/ext/-test-/num2int/depend
+++ b/ext/-test-/num2int/depend
@@ -128,6 +128,7 @@ num2int.o: $(hdrdir)/ruby/internal/intern/re.h
num2int.o: $(hdrdir)/ruby/internal/intern/ruby.h
num2int.o: $(hdrdir)/ruby/internal/intern/select.h
num2int.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+num2int.o: $(hdrdir)/ruby/internal/intern/set.h
num2int.o: $(hdrdir)/ruby/internal/intern/signal.h
num2int.o: $(hdrdir)/ruby/internal/intern/sprintf.h
num2int.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ num2int.o: $(hdrdir)/ruby/internal/special_consts.h
num2int.o: $(hdrdir)/ruby/internal/static_assert.h
num2int.o: $(hdrdir)/ruby/internal/stdalign.h
num2int.o: $(hdrdir)/ruby/internal/stdbool.h
+num2int.o: $(hdrdir)/ruby/internal/stdckdint.h
num2int.o: $(hdrdir)/ruby/internal/symbol.h
num2int.o: $(hdrdir)/ruby/internal/value.h
num2int.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/path_to_class/depend b/ext/-test-/path_to_class/depend
index 8fe6ee37c2..e535058e09 100644
--- a/ext/-test-/path_to_class/depend
+++ b/ext/-test-/path_to_class/depend
@@ -128,6 +128,7 @@ path_to_class.o: $(hdrdir)/ruby/internal/intern/re.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/ruby.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/select.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+path_to_class.o: $(hdrdir)/ruby/internal/intern/set.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/signal.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/sprintf.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ path_to_class.o: $(hdrdir)/ruby/internal/special_consts.h
path_to_class.o: $(hdrdir)/ruby/internal/static_assert.h
path_to_class.o: $(hdrdir)/ruby/internal/stdalign.h
path_to_class.o: $(hdrdir)/ruby/internal/stdbool.h
+path_to_class.o: $(hdrdir)/ruby/internal/stdckdint.h
path_to_class.o: $(hdrdir)/ruby/internal/symbol.h
path_to_class.o: $(hdrdir)/ruby/internal/value.h
path_to_class.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/popen_deadlock/depend b/ext/-test-/popen_deadlock/depend
index fb58ca30e9..0b8932e8b8 100644
--- a/ext/-test-/popen_deadlock/depend
+++ b/ext/-test-/popen_deadlock/depend
@@ -128,6 +128,7 @@ infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/re.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/ruby.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/select.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/set.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/signal.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/sprintf.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/special_consts.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/static_assert.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/stdalign.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/stdbool.h
+infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/stdckdint.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/symbol.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/value.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/postponed_job/depend b/ext/-test-/postponed_job/depend
index e44d9d51b7..ff567e3921 100644
--- a/ext/-test-/postponed_job/depend
+++ b/ext/-test-/postponed_job/depend
@@ -129,6 +129,7 @@ postponed_job.o: $(hdrdir)/ruby/internal/intern/re.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/ruby.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/select.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+postponed_job.o: $(hdrdir)/ruby/internal/intern/set.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/signal.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/sprintf.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -148,6 +149,7 @@ postponed_job.o: $(hdrdir)/ruby/internal/special_consts.h
postponed_job.o: $(hdrdir)/ruby/internal/static_assert.h
postponed_job.o: $(hdrdir)/ruby/internal/stdalign.h
postponed_job.o: $(hdrdir)/ruby/internal/stdbool.h
+postponed_job.o: $(hdrdir)/ruby/internal/stdckdint.h
postponed_job.o: $(hdrdir)/ruby/internal/symbol.h
postponed_job.o: $(hdrdir)/ruby/internal/value.h
postponed_job.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/postponed_job/postponed_job.c b/ext/-test-/postponed_job/postponed_job.c
index fa57bef6f5..4426fc3104 100644
--- a/ext/-test-/postponed_job/postponed_job.c
+++ b/ext/-test-/postponed_job/postponed_job.c
@@ -1,6 +1,29 @@
#include "ruby.h"
#include "ruby/debug.h"
+// We're testing deprecated things, don't print the compiler warnings
+#if 0
+
+#elif defined(_MSC_VER)
+#pragma warning(disable : 4996)
+
+#elif defined(__INTEL_COMPILER)
+#pragma warning(disable : 1786)
+
+#elif defined(__clang__)
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#elif defined(__SUNPRO_CC)
+#pragma error_messages (off,symdeprecated)
+
+#else
+// :FIXME: improve here for your compiler.
+
+#endif
+
static int counter;
static void
@@ -13,10 +36,10 @@ pjob_callback(void *data)
}
static VALUE
-pjob_register(VALUE self, VALUE obj)
+pjob_call_direct(VALUE self, VALUE obj)
{
counter = 0;
- rb_postponed_job_register(0, pjob_callback, (void *)obj);
+ pjob_callback((void *)obj);
rb_gc_start();
counter++;
rb_gc_start();
@@ -26,75 +49,103 @@ pjob_register(VALUE self, VALUE obj)
return self;
}
+static void pjob_noop_callback(void *data) { }
+
static void
-pjob_one_callback(void *data)
+pjob_preregistered_callback(void *data)
{
VALUE ary = (VALUE)data;
Check_Type(ary, T_ARRAY);
-
- rb_ary_push(ary, INT2FIX(1));
+ rb_ary_push(ary, INT2FIX(counter));
}
static VALUE
-pjob_register_one(VALUE self, VALUE obj)
+pjob_preregister_and_call_with_sleep(VALUE self, VALUE obj)
{
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ counter = 0;
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
return self;
}
static VALUE
-pjob_call_direct(VALUE self, VALUE obj)
+pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
{
counter = 0;
- pjob_callback((void *)obj);
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
- rb_gc_start();
- counter++;
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
+ counter = 3;
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_trigger(h);
return self;
}
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-
-static void *
-pjob_register_in_c_thread_i(void *obj)
+static VALUE
+pjob_preregister_multiple_times(VALUE self)
{
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
- rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
- return NULL;
+ int r1 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ int r2 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ int r3 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, INT2FIX(r1));
+ rb_ary_push(ary, INT2FIX(r2));
+ rb_ary_push(ary, INT2FIX(r3));
+ return ary;
+
+}
+
+struct pjob_append_data_args {
+ VALUE ary;
+ VALUE data;
+};
+
+static void
+pjob_append_data_callback(void *vctx) {
+ struct pjob_append_data_args *ctx = (struct pjob_append_data_args *)vctx;
+ Check_Type(ctx->ary, T_ARRAY);
+ rb_ary_push(ctx->ary, ctx->data);
}
static VALUE
-pjob_register_in_c_thread(VALUE self, VALUE obj)
+pjob_preregister_calls_with_last_argument(VALUE self)
{
- pthread_t thread;
- if (pthread_create(&thread, NULL, pjob_register_in_c_thread_i, (void *)obj)) {
- return Qfalse;
- }
+ VALUE ary = rb_ary_new();
- if (pthread_join(thread, NULL)) {
- return Qfalse;
- }
+ struct pjob_append_data_args arg1 = { .ary = ary, .data = INT2FIX(1) };
+ struct pjob_append_data_args arg2 = { .ary = ary, .data = INT2FIX(2) };
+ struct pjob_append_data_args arg3 = { .ary = ary, .data = INT2FIX(3) };
+ struct pjob_append_data_args arg4 = { .ary = ary, .data = INT2FIX(4) };
- return Qtrue;
+ rb_postponed_job_handle_t h;
+ h = rb_postponed_job_preregister(0, pjob_append_data_callback, &arg1);
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg2);
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg3);
+ rb_thread_sleep(0); // should execute with arg3
+
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg4);
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0); // should execute with arg4
+
+ return ary;
}
-#endif
void
Init_postponed_job(VALUE self)
{
VALUE mBug = rb_define_module("Bug");
- rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
- rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
-#ifdef HAVE_PTHREAD_H
- rb_define_module_function(mBug, "postponed_job_register_in_c_thread", pjob_register_in_c_thread, 1);
-#endif
+ rb_define_module_function(mBug, "postponed_job_preregister_and_call_with_sleep", pjob_preregister_and_call_with_sleep, 1);
+ rb_define_module_function(mBug, "postponed_job_preregister_and_call_without_sleep", pjob_preregister_and_call_without_sleep, 1);
+ rb_define_module_function(mBug, "postponed_job_preregister_multiple_times", pjob_preregister_multiple_times, 0);
+ rb_define_module_function(mBug, "postponed_job_preregister_calls_with_last_argument", pjob_preregister_calls_with_last_argument, 0);
}
diff --git a/ext/-test-/printf/depend b/ext/-test-/printf/depend
index b397041103..be895cf769 100644
--- a/ext/-test-/printf/depend
+++ b/ext/-test-/printf/depend
@@ -138,6 +138,7 @@ printf.o: $(hdrdir)/ruby/internal/intern/re.h
printf.o: $(hdrdir)/ruby/internal/intern/ruby.h
printf.o: $(hdrdir)/ruby/internal/intern/select.h
printf.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+printf.o: $(hdrdir)/ruby/internal/intern/set.h
printf.o: $(hdrdir)/ruby/internal/intern/signal.h
printf.o: $(hdrdir)/ruby/internal/intern/sprintf.h
printf.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ printf.o: $(hdrdir)/ruby/internal/special_consts.h
printf.o: $(hdrdir)/ruby/internal/static_assert.h
printf.o: $(hdrdir)/ruby/internal/stdalign.h
printf.o: $(hdrdir)/ruby/internal/stdbool.h
+printf.o: $(hdrdir)/ruby/internal/stdckdint.h
printf.o: $(hdrdir)/ruby/internal/symbol.h
printf.o: $(hdrdir)/ruby/internal/value.h
printf.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/proc/depend b/ext/-test-/proc/depend
index 7e78aa6f83..97834db0a2 100644
--- a/ext/-test-/proc/depend
+++ b/ext/-test-/proc/depend
@@ -128,6 +128,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ receiver.o: $(hdrdir)/ruby/internal/intern/re.h
receiver.o: $(hdrdir)/ruby/internal/intern/ruby.h
receiver.o: $(hdrdir)/ruby/internal/intern/select.h
receiver.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+receiver.o: $(hdrdir)/ruby/internal/intern/set.h
receiver.o: $(hdrdir)/ruby/internal/intern/signal.h
receiver.o: $(hdrdir)/ruby/internal/intern/sprintf.h
receiver.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ receiver.o: $(hdrdir)/ruby/internal/special_consts.h
receiver.o: $(hdrdir)/ruby/internal/static_assert.h
receiver.o: $(hdrdir)/ruby/internal/stdalign.h
receiver.o: $(hdrdir)/ruby/internal/stdbool.h
+receiver.o: $(hdrdir)/ruby/internal/stdckdint.h
receiver.o: $(hdrdir)/ruby/internal/symbol.h
receiver.o: $(hdrdir)/ruby/internal/value.h
receiver.o: $(hdrdir)/ruby/internal/value_type.h
@@ -446,6 +450,7 @@ super.o: $(hdrdir)/ruby/internal/intern/re.h
super.o: $(hdrdir)/ruby/internal/intern/ruby.h
super.o: $(hdrdir)/ruby/internal/intern/select.h
super.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+super.o: $(hdrdir)/ruby/internal/intern/set.h
super.o: $(hdrdir)/ruby/internal/intern/signal.h
super.o: $(hdrdir)/ruby/internal/intern/sprintf.h
super.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -465,6 +470,7 @@ super.o: $(hdrdir)/ruby/internal/special_consts.h
super.o: $(hdrdir)/ruby/internal/static_assert.h
super.o: $(hdrdir)/ruby/internal/stdalign.h
super.o: $(hdrdir)/ruby/internal/stdbool.h
+super.o: $(hdrdir)/ruby/internal/stdckdint.h
super.o: $(hdrdir)/ruby/internal/symbol.h
super.o: $(hdrdir)/ruby/internal/value.h
super.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/public_header_warnings/extconf.rb b/ext/-test-/public_header_warnings/extconf.rb
new file mode 100644
index 0000000000..4431e09da4
--- /dev/null
+++ b/ext/-test-/public_header_warnings/extconf.rb
@@ -0,0 +1,28 @@
+#
+# Under compilers with WERRORFLAG, MakeMakefile.try_compile treats warnings as errors, so we can
+# use append_cflags to test whether the public header files emit warnings with certain flags turned
+# on.
+#
+def check_append_cflags(flag, msg = nil)
+ msg ||= "flag #{flag} is not acceptable"
+ if $CFLAGS.include?(flag)
+ raise("flag #{flag} already present in $CFLAGS")
+ end
+ append_cflags(flag)
+ unless $CFLAGS.include?(flag)
+ system("cat mkmf.log")
+ raise(msg)
+ end
+end
+
+if %w[gcc clang].include?(RbConfig::CONFIG['CC'])
+ config_string("WERRORFLAG") or raise("expected WERRORFLAG to be defined")
+
+ # should be acceptable on all modern C compilers
+ check_append_cflags("-D_TEST_OK", "baseline compiler warning test failed")
+
+ # Feature #20507: Allow compilation of C extensions with -Wconversion
+ check_append_cflags("-Wconversion", "-Wconversion raising warnings in public headers")
+end
+
+create_makefile("-test-/public_header_warnings")
diff --git a/ext/-test-/random/depend b/ext/-test-/random/depend
index 3f9a52be44..380c30fbe4 100644
--- a/ext/-test-/random/depend
+++ b/ext/-test-/random/depend
@@ -127,6 +127,7 @@ bad_version.o: $(hdrdir)/ruby/internal/intern/re.h
bad_version.o: $(hdrdir)/ruby/internal/intern/ruby.h
bad_version.o: $(hdrdir)/ruby/internal/intern/select.h
bad_version.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bad_version.o: $(hdrdir)/ruby/internal/intern/set.h
bad_version.o: $(hdrdir)/ruby/internal/intern/signal.h
bad_version.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bad_version.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ bad_version.o: $(hdrdir)/ruby/internal/special_consts.h
bad_version.o: $(hdrdir)/ruby/internal/static_assert.h
bad_version.o: $(hdrdir)/ruby/internal/stdalign.h
bad_version.o: $(hdrdir)/ruby/internal/stdbool.h
+bad_version.o: $(hdrdir)/ruby/internal/stdckdint.h
bad_version.o: $(hdrdir)/ruby/internal/symbol.h
bad_version.o: $(hdrdir)/ruby/internal/value.h
bad_version.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -445,6 +449,7 @@ loop.o: $(hdrdir)/ruby/internal/intern/re.h
loop.o: $(hdrdir)/ruby/internal/intern/ruby.h
loop.o: $(hdrdir)/ruby/internal/intern/select.h
loop.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+loop.o: $(hdrdir)/ruby/internal/intern/set.h
loop.o: $(hdrdir)/ruby/internal/intern/signal.h
loop.o: $(hdrdir)/ruby/internal/intern/sprintf.h
loop.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -464,6 +469,7 @@ loop.o: $(hdrdir)/ruby/internal/special_consts.h
loop.o: $(hdrdir)/ruby/internal/static_assert.h
loop.o: $(hdrdir)/ruby/internal/stdalign.h
loop.o: $(hdrdir)/ruby/internal/stdbool.h
+loop.o: $(hdrdir)/ruby/internal/stdckdint.h
loop.o: $(hdrdir)/ruby/internal/symbol.h
loop.o: $(hdrdir)/ruby/internal/value.h
loop.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/random/loop.c b/ext/-test-/random/loop.c
index b789ab1d01..f79e5cfd83 100644
--- a/ext/-test-/random/loop.c
+++ b/ext/-test-/random/loop.c
@@ -13,6 +13,15 @@ static const rb_random_interface_t random_loop_if = {
RB_RANDOM_INTERFACE_DEFINE_WITH_REAL(loop)
};
+static void
+loop_free(void *ptr)
+{
+ rand_loop_t *r = ptr;
+
+ xfree(r->buf);
+ xfree(r);
+}
+
RB_RANDOM_DEFINE_INIT_INT32_FUNC(loop)
static size_t
random_loop_memsize(const void *ptr)
@@ -25,7 +34,7 @@ static rb_random_data_type_t random_loop_type = {
"random/loop",
{
rb_random_mark,
- RUBY_TYPED_DEFAULT_FREE,
+ loop_free,
random_loop_memsize,
},
RB_RANDOM_PARENT,
diff --git a/ext/-test-/rational/depend b/ext/-test-/rational/depend
index cff2eae38d..d949fca66b 100644
--- a/ext/-test-/rational/depend
+++ b/ext/-test-/rational/depend
@@ -132,6 +132,7 @@ rat.o: $(hdrdir)/ruby/internal/intern/re.h
rat.o: $(hdrdir)/ruby/internal/intern/ruby.h
rat.o: $(hdrdir)/ruby/internal/intern/select.h
rat.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rat.o: $(hdrdir)/ruby/internal/intern/set.h
rat.o: $(hdrdir)/ruby/internal/intern/signal.h
rat.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rat.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -151,6 +152,7 @@ rat.o: $(hdrdir)/ruby/internal/special_consts.h
rat.o: $(hdrdir)/ruby/internal/static_assert.h
rat.o: $(hdrdir)/ruby/internal/stdalign.h
rat.o: $(hdrdir)/ruby/internal/stdbool.h
+rat.o: $(hdrdir)/ruby/internal/stdckdint.h
rat.o: $(hdrdir)/ruby/internal/symbol.h
rat.o: $(hdrdir)/ruby/internal/value.h
rat.o: $(hdrdir)/ruby/internal/value_type.h
@@ -161,8 +163,11 @@ rat.o: $(hdrdir)/ruby/missing.h
rat.o: $(hdrdir)/ruby/ruby.h
rat.o: $(hdrdir)/ruby/st.h
rat.o: $(hdrdir)/ruby/subst.h
+rat.o: $(top_srcdir)/internal.h
+rat.o: $(top_srcdir)/internal/basic_operators.h
rat.o: $(top_srcdir)/internal/bignum.h
rat.o: $(top_srcdir)/internal/bits.h
+rat.o: $(top_srcdir)/internal/compar.h
rat.o: $(top_srcdir)/internal/compilers.h
rat.o: $(top_srcdir)/internal/fixnum.h
rat.o: $(top_srcdir)/internal/gc.h
diff --git a/ext/-test-/rb_call_super_kw/depend b/ext/-test-/rb_call_super_kw/depend
index a42ddc85ac..bf34323ca7 100644
--- a/ext/-test-/rb_call_super_kw/depend
+++ b/ext/-test-/rb_call_super_kw/depend
@@ -128,6 +128,7 @@ rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/re.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/ruby.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/select.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/set.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/signal.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ rb_call_super_kw.o: $(hdrdir)/ruby/internal/special_consts.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/static_assert.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/stdalign.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/stdbool.h
+rb_call_super_kw.o: $(hdrdir)/ruby/internal/stdckdint.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/symbol.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/value.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/recursion/depend b/ext/-test-/recursion/depend
index 49377250ef..b6487eb4df 100644
--- a/ext/-test-/recursion/depend
+++ b/ext/-test-/recursion/depend
@@ -128,6 +128,7 @@ recursion.o: $(hdrdir)/ruby/internal/intern/re.h
recursion.o: $(hdrdir)/ruby/internal/intern/ruby.h
recursion.o: $(hdrdir)/ruby/internal/intern/select.h
recursion.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+recursion.o: $(hdrdir)/ruby/internal/intern/set.h
recursion.o: $(hdrdir)/ruby/internal/intern/signal.h
recursion.o: $(hdrdir)/ruby/internal/intern/sprintf.h
recursion.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ recursion.o: $(hdrdir)/ruby/internal/special_consts.h
recursion.o: $(hdrdir)/ruby/internal/static_assert.h
recursion.o: $(hdrdir)/ruby/internal/stdalign.h
recursion.o: $(hdrdir)/ruby/internal/stdbool.h
+recursion.o: $(hdrdir)/ruby/internal/stdckdint.h
recursion.o: $(hdrdir)/ruby/internal/symbol.h
recursion.o: $(hdrdir)/ruby/internal/value.h
recursion.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/regexp/depend b/ext/-test-/regexp/depend
index 484f0320dd..5ba1b92f18 100644
--- a/ext/-test-/regexp/depend
+++ b/ext/-test-/regexp/depend
@@ -128,6 +128,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/re.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/ruby.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/select.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/set.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/signal.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/sprintf.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ parse_depth_limit.o: $(hdrdir)/ruby/internal/special_consts.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/static_assert.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/stdalign.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/stdbool.h
+parse_depth_limit.o: $(hdrdir)/ruby/internal/stdckdint.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/symbol.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/value.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/sanitizers/depend b/ext/-test-/sanitizers/depend
new file mode 100644
index 0000000000..0e6e632803
--- /dev/null
+++ b/ext/-test-/sanitizers/depend
@@ -0,0 +1,162 @@
+# AUTOGENERATED DEPENDENCIES START
+sanitizers.o: $(RUBY_EXTCONF_H)
+sanitizers.o: $(arch_hdrdir)/ruby/config.h
+sanitizers.o: $(hdrdir)/ruby/assert.h
+sanitizers.o: $(hdrdir)/ruby/backward.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/assume.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/attributes.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/bool.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/inttypes.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/limits.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/long_long.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/stdalign.h
+sanitizers.o: $(hdrdir)/ruby/backward/2/stdarg.h
+sanitizers.o: $(hdrdir)/ruby/defines.h
+sanitizers.o: $(hdrdir)/ruby/intern.h
+sanitizers.o: $(hdrdir)/ruby/internal/abi.h
+sanitizers.o: $(hdrdir)/ruby/internal/anyargs.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+sanitizers.o: $(hdrdir)/ruby/internal/assume.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/artificial.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/cold.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/const.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/error.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/format.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/noalias.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/noinline.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/pure.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/restrict.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/warning.h
+sanitizers.o: $(hdrdir)/ruby/internal/attr/weakref.h
+sanitizers.o: $(hdrdir)/ruby/internal/cast.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+sanitizers.o: $(hdrdir)/ruby/internal/compiler_since.h
+sanitizers.o: $(hdrdir)/ruby/internal/config.h
+sanitizers.o: $(hdrdir)/ruby/internal/constant_p.h
+sanitizers.o: $(hdrdir)/ruby/internal/core.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rarray.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rbasic.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rbignum.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rclass.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rdata.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rfile.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rhash.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/robject.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rregexp.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rstring.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rstruct.h
+sanitizers.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+sanitizers.o: $(hdrdir)/ruby/internal/ctype.h
+sanitizers.o: $(hdrdir)/ruby/internal/dllexport.h
+sanitizers.o: $(hdrdir)/ruby/internal/dosish.h
+sanitizers.o: $(hdrdir)/ruby/internal/error.h
+sanitizers.o: $(hdrdir)/ruby/internal/eval.h
+sanitizers.o: $(hdrdir)/ruby/internal/event.h
+sanitizers.o: $(hdrdir)/ruby/internal/fl_type.h
+sanitizers.o: $(hdrdir)/ruby/internal/gc.h
+sanitizers.o: $(hdrdir)/ruby/internal/glob.h
+sanitizers.o: $(hdrdir)/ruby/internal/globals.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/attribute.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/builtin.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/extension.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/feature.h
+sanitizers.o: $(hdrdir)/ruby/internal/has/warning.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/array.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/bignum.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/class.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/compar.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/complex.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/cont.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/dir.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/enum.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/error.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/eval.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/file.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/hash.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/io.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/load.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/marshal.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/numeric.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/object.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/parse.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/proc.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/process.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/random.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/range.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/rational.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/re.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/ruby.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/select.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/set.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/signal.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/string.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/struct.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/thread.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/time.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/variable.h
+sanitizers.o: $(hdrdir)/ruby/internal/intern/vm.h
+sanitizers.o: $(hdrdir)/ruby/internal/interpreter.h
+sanitizers.o: $(hdrdir)/ruby/internal/iterator.h
+sanitizers.o: $(hdrdir)/ruby/internal/memory.h
+sanitizers.o: $(hdrdir)/ruby/internal/method.h
+sanitizers.o: $(hdrdir)/ruby/internal/module.h
+sanitizers.o: $(hdrdir)/ruby/internal/newobj.h
+sanitizers.o: $(hdrdir)/ruby/internal/scan_args.h
+sanitizers.o: $(hdrdir)/ruby/internal/special_consts.h
+sanitizers.o: $(hdrdir)/ruby/internal/static_assert.h
+sanitizers.o: $(hdrdir)/ruby/internal/stdalign.h
+sanitizers.o: $(hdrdir)/ruby/internal/stdbool.h
+sanitizers.o: $(hdrdir)/ruby/internal/stdckdint.h
+sanitizers.o: $(hdrdir)/ruby/internal/symbol.h
+sanitizers.o: $(hdrdir)/ruby/internal/value.h
+sanitizers.o: $(hdrdir)/ruby/internal/value_type.h
+sanitizers.o: $(hdrdir)/ruby/internal/variable.h
+sanitizers.o: $(hdrdir)/ruby/internal/warning_push.h
+sanitizers.o: $(hdrdir)/ruby/internal/xmalloc.h
+sanitizers.o: $(hdrdir)/ruby/missing.h
+sanitizers.o: $(hdrdir)/ruby/ruby.h
+sanitizers.o: $(hdrdir)/ruby/st.h
+sanitizers.o: $(hdrdir)/ruby/subst.h
+sanitizers.o: sanitizers.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/sanitizers/extconf.rb b/ext/-test-/sanitizers/extconf.rb
new file mode 100644
index 0000000000..c94a96de6c
--- /dev/null
+++ b/ext/-test-/sanitizers/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('-test-/sanitizers')
diff --git a/ext/-test-/sanitizers/sanitizers.c b/ext/-test-/sanitizers/sanitizers.c
new file mode 100644
index 0000000000..97a85b26ef
--- /dev/null
+++ b/ext/-test-/sanitizers/sanitizers.c
@@ -0,0 +1,36 @@
+#include "ruby/ruby.h"
+
+static VALUE
+asan_enabled_p(VALUE self)
+{
+#if defined(__has_feature)
+ /* clang uses __has_feature for determining asan */
+ return __has_feature(address_sanitizer) ? Qtrue : Qfalse;
+#elif defined(__SANITIZE_ADDRESS__)
+ /* GCC sets __SANITIZE_ADDRESS__ for determining asan */
+ return Qtrue;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+lsan_enabled_p(VALUE self)
+{
+#if defined(__has_feature)
+ /* clang uses __has_feature for determining LSAN */
+ return __has_feature(leak_sanitizer) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+void
+Init_sanitizers(void)
+{
+ VALUE m = rb_define_module("Test");
+ VALUE c = rb_define_class_under(m, "Sanitizers", rb_cObject);
+ rb_define_singleton_method(c, "asan_enabled?", asan_enabled_p, 0);
+ rb_define_singleton_method(c, "lsan_enabled?", lsan_enabled_p, 0);
+}
+
diff --git a/ext/-test-/scan_args/depend b/ext/-test-/scan_args/depend
index 3bedc6a7cf..ca0fc19238 100644
--- a/ext/-test-/scan_args/depend
+++ b/ext/-test-/scan_args/depend
@@ -128,6 +128,7 @@ scan_args.o: $(hdrdir)/ruby/internal/intern/re.h
scan_args.o: $(hdrdir)/ruby/internal/intern/ruby.h
scan_args.o: $(hdrdir)/ruby/internal/intern/select.h
scan_args.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+scan_args.o: $(hdrdir)/ruby/internal/intern/set.h
scan_args.o: $(hdrdir)/ruby/internal/intern/signal.h
scan_args.o: $(hdrdir)/ruby/internal/intern/sprintf.h
scan_args.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ scan_args.o: $(hdrdir)/ruby/internal/special_consts.h
scan_args.o: $(hdrdir)/ruby/internal/static_assert.h
scan_args.o: $(hdrdir)/ruby/internal/stdalign.h
scan_args.o: $(hdrdir)/ruby/internal/stdbool.h
+scan_args.o: $(hdrdir)/ruby/internal/stdckdint.h
scan_args.o: $(hdrdir)/ruby/internal/symbol.h
scan_args.o: $(hdrdir)/ruby/internal/value.h
scan_args.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/scheduler/extconf.rb b/ext/-test-/scheduler/extconf.rb
new file mode 100644
index 0000000000..159699bd8e
--- /dev/null
+++ b/ext/-test-/scheduler/extconf.rb
@@ -0,0 +1,2 @@
+# frozen_string_literal: false
+create_makefile("-test-/scheduler")
diff --git a/ext/-test-/scheduler/scheduler.c b/ext/-test-/scheduler/scheduler.c
new file mode 100644
index 0000000000..b742a5573b
--- /dev/null
+++ b/ext/-test-/scheduler/scheduler.c
@@ -0,0 +1,92 @@
+#include "ruby/ruby.h"
+#include "ruby/thread.h"
+#include "ruby/io.h"
+#include "ruby/fiber/scheduler.h"
+
+/*
+ * Test extension for reproducing the gRPC interrupt handling bug.
+ *
+ * This reproduces the exact issue from grpc/grpc commit 69f229e (June 2025):
+ * https://github.com/grpc/grpc/commit/69f229edd1d79ab7a7dfda98e3aef6fd807adcad
+ *
+ * The bug occurs when:
+ * 1. A fiber scheduler uses Thread.handle_interrupt(::SignalException => :never)
+ * (like Async::Scheduler does)
+ * 2. Native code uses rb_thread_call_without_gvl in a retry loop that checks
+ * the interrupted flag and retries (like gRPC's completion queue)
+ * 3. A signal (SIGINT/SIGTERM) is sent
+ * 4. The unblock_func sets interrupted=1, but Thread.handle_interrupt defers the signal
+ * 5. The loop sees interrupted=1 and retries without yielding to the scheduler
+ * 6. The deferred interrupt never gets processed -> infinite hang
+ *
+ * The fix is in vm_check_ints_blocking() in thread.c, which should yield to
+ * the fiber scheduler when interrupts are pending, allowing the scheduler to
+ * detect Thread.pending_interrupt? and exit its run loop.
+ */
+
+struct blocking_state {
+ int notify_descriptor;
+ volatile int interrupted;
+};
+
+static void
+unblock_callback(void *argument)
+{
+ struct blocking_state *blocking_state = (struct blocking_state *)argument;
+ blocking_state->interrupted = 1;
+}
+
+static void *
+blocking_operation(void *argument)
+{
+ struct blocking_state *blocking_state = (struct blocking_state *)argument;
+
+ ssize_t ret = write(blocking_state->notify_descriptor, "x", 1);
+ (void)ret; // ignore the result for now
+
+ while (!blocking_state->interrupted) {
+ struct timeval tv = {1, 0}; // 1 second timeout.
+ int result = select(0, NULL, NULL, NULL, &tv);
+
+ if (result == -1 && errno == EINTR) {
+ blocking_state->interrupted = 1;
+ }
+
+ // Otherwise, timeout -> loop again.
+ }
+
+ return NULL;
+}
+
+static VALUE
+scheduler_blocking_loop(VALUE self, VALUE notify)
+{
+ struct blocking_state blocking_state = {
+ .notify_descriptor = rb_io_descriptor(notify),
+ .interrupted = 0,
+ };
+
+ while (true) {
+ blocking_state.interrupted = 0;
+
+ rb_thread_call_without_gvl(
+ blocking_operation, &blocking_state,
+ unblock_callback, &blocking_state
+ );
+
+ // The bug: When interrupted, loop retries without yielding to scheduler.
+ // With Thread.handle_interrupt(:never), this causes an infinite hang,
+ // because the deferred interrupt never gets a chance to be processed.
+ } while (blocking_state.interrupted);
+
+ return Qnil;
+}
+
+void
+Init_scheduler(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE mScheduler = rb_define_module_under(mBug, "Scheduler");
+
+ rb_define_module_function(mScheduler, "blocking_loop", scheduler_blocking_loop, 1);
+}
diff --git a/ext/-test-/st/foreach/depend b/ext/-test-/st/foreach/depend
index fdfe356805..29aab2bb29 100644
--- a/ext/-test-/st/foreach/depend
+++ b/ext/-test-/st/foreach/depend
@@ -128,6 +128,7 @@ foreach.o: $(hdrdir)/ruby/internal/intern/re.h
foreach.o: $(hdrdir)/ruby/internal/intern/ruby.h
foreach.o: $(hdrdir)/ruby/internal/intern/select.h
foreach.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+foreach.o: $(hdrdir)/ruby/internal/intern/set.h
foreach.o: $(hdrdir)/ruby/internal/intern/signal.h
foreach.o: $(hdrdir)/ruby/internal/intern/sprintf.h
foreach.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ foreach.o: $(hdrdir)/ruby/internal/special_consts.h
foreach.o: $(hdrdir)/ruby/internal/static_assert.h
foreach.o: $(hdrdir)/ruby/internal/stdalign.h
foreach.o: $(hdrdir)/ruby/internal/stdbool.h
+foreach.o: $(hdrdir)/ruby/internal/stdckdint.h
foreach.o: $(hdrdir)/ruby/internal/symbol.h
foreach.o: $(hdrdir)/ruby/internal/value.h
foreach.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/st/foreach/foreach.c b/ext/-test-/st/foreach/foreach.c
index cde49fb26d..5c1bfd1631 100644
--- a/ext/-test-/st/foreach/foreach.c
+++ b/ext/-test-/st/foreach/foreach.c
@@ -14,20 +14,16 @@ force_unpack_check(struct checker *c, st_data_t key, st_data_t val)
if (c->nr == 0) {
st_data_t i;
- if (c->tbl->bins != NULL) rb_bug("should be packed\n");
-
/* force unpacking during iteration: */
for (i = 1; i < expect_size; i++)
st_add_direct(c->tbl, i, i);
-
- if (c->tbl->bins == NULL) rb_bug("should be unpacked\n");
}
if (key != c->nr) {
- rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)key, (VALUE)c->nr);
+ rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)key, (VALUE)c->nr);
}
if (val != c->nr) {
- rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)val, (VALUE)c->nr);
+ rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)val, (VALUE)c->nr);
}
c->nr++;
@@ -60,7 +56,7 @@ unp_fec_i(st_data_t key, st_data_t val, st_data_t args, int error)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
- rb_bug("failed to delete\n");
+ rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
@@ -84,22 +80,18 @@ unp_fec(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
- if (tbl->bins != NULL) rb_bug("should still be packed\n");
-
st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);
if (c.test == ID2SYM(rb_intern("delete2"))) {
if (c.nr != 1) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n",
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")",
(VALUE)c.nr, (VALUE)expect_size);
}
- if (tbl->bins == NULL) rb_bug("should be unpacked\n");
-
st_free_table(tbl);
return Qnil;
@@ -120,14 +112,14 @@ unp_fe_i(st_data_t key, st_data_t val, st_data_t args)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
- rb_bug("failed to delete\n");
+ rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
}
return ST_CONTINUE;
}
- rb_bug("should never get here\n");
+ rb_bug("should never get here");
}
rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
@@ -145,22 +137,18 @@ unp_fe(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
- if (tbl->bins != NULL) rb_bug("should still be packed\n");
-
st_foreach(tbl, unp_fe_i, (st_data_t)&c);
if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
if (c.nr != 1) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n",
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)",
(VALUE)c.nr, (VALUE)expect_size);
}
- if (tbl->bins == NULL) rb_bug("should be unpacked\n");
-
st_free_table(tbl);
return Qnil;
diff --git a/ext/-test-/st/numhash/depend b/ext/-test-/st/numhash/depend
index ef28c892f3..18320d55f5 100644
--- a/ext/-test-/st/numhash/depend
+++ b/ext/-test-/st/numhash/depend
@@ -128,6 +128,7 @@ numhash.o: $(hdrdir)/ruby/internal/intern/re.h
numhash.o: $(hdrdir)/ruby/internal/intern/ruby.h
numhash.o: $(hdrdir)/ruby/internal/intern/select.h
numhash.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+numhash.o: $(hdrdir)/ruby/internal/intern/set.h
numhash.o: $(hdrdir)/ruby/internal/intern/signal.h
numhash.o: $(hdrdir)/ruby/internal/intern/sprintf.h
numhash.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ numhash.o: $(hdrdir)/ruby/internal/special_consts.h
numhash.o: $(hdrdir)/ruby/internal/static_assert.h
numhash.o: $(hdrdir)/ruby/internal/stdalign.h
numhash.o: $(hdrdir)/ruby/internal/stdbool.h
+numhash.o: $(hdrdir)/ruby/internal/stdckdint.h
numhash.o: $(hdrdir)/ruby/internal/symbol.h
numhash.o: $(hdrdir)/ruby/internal/value.h
numhash.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/st/update/depend b/ext/-test-/st/update/depend
index 2d5ff224a2..247f0efd6b 100644
--- a/ext/-test-/st/update/depend
+++ b/ext/-test-/st/update/depend
@@ -128,6 +128,7 @@ update.o: $(hdrdir)/ruby/internal/intern/re.h
update.o: $(hdrdir)/ruby/internal/intern/ruby.h
update.o: $(hdrdir)/ruby/internal/intern/select.h
update.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+update.o: $(hdrdir)/ruby/internal/intern/set.h
update.o: $(hdrdir)/ruby/internal/intern/signal.h
update.o: $(hdrdir)/ruby/internal/intern/sprintf.h
update.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ update.o: $(hdrdir)/ruby/internal/special_consts.h
update.o: $(hdrdir)/ruby/internal/static_assert.h
update.o: $(hdrdir)/ruby/internal/stdalign.h
update.o: $(hdrdir)/ruby/internal/stdbool.h
+update.o: $(hdrdir)/ruby/internal/stdckdint.h
update.o: $(hdrdir)/ruby/internal/symbol.h
update.o: $(hdrdir)/ruby/internal/value.h
update.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/stack/depend b/ext/-test-/stack/depend
new file mode 100644
index 0000000000..77e93bb201
--- /dev/null
+++ b/ext/-test-/stack/depend
@@ -0,0 +1,179 @@
+# AUTOGENERATED DEPENDENCIES START
+stack.o: $(RUBY_EXTCONF_H)
+stack.o: $(arch_hdrdir)/ruby/config.h
+stack.o: $(hdrdir)/ruby.h
+stack.o: $(hdrdir)/ruby/assert.h
+stack.o: $(hdrdir)/ruby/backward.h
+stack.o: $(hdrdir)/ruby/backward/2/assume.h
+stack.o: $(hdrdir)/ruby/backward/2/attributes.h
+stack.o: $(hdrdir)/ruby/backward/2/bool.h
+stack.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
+stack.o: $(hdrdir)/ruby/backward/2/inttypes.h
+stack.o: $(hdrdir)/ruby/backward/2/limits.h
+stack.o: $(hdrdir)/ruby/backward/2/long_long.h
+stack.o: $(hdrdir)/ruby/backward/2/stdalign.h
+stack.o: $(hdrdir)/ruby/backward/2/stdarg.h
+stack.o: $(hdrdir)/ruby/defines.h
+stack.o: $(hdrdir)/ruby/encoding.h
+stack.o: $(hdrdir)/ruby/intern.h
+stack.o: $(hdrdir)/ruby/internal/abi.h
+stack.o: $(hdrdir)/ruby/internal/anyargs.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+stack.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+stack.o: $(hdrdir)/ruby/internal/assume.h
+stack.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+stack.o: $(hdrdir)/ruby/internal/attr/artificial.h
+stack.o: $(hdrdir)/ruby/internal/attr/cold.h
+stack.o: $(hdrdir)/ruby/internal/attr/const.h
+stack.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+stack.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+stack.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+stack.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+stack.o: $(hdrdir)/ruby/internal/attr/error.h
+stack.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+stack.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+stack.o: $(hdrdir)/ruby/internal/attr/format.h
+stack.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+stack.o: $(hdrdir)/ruby/internal/attr/noalias.h
+stack.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+stack.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+stack.o: $(hdrdir)/ruby/internal/attr/noinline.h
+stack.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+stack.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+stack.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+stack.o: $(hdrdir)/ruby/internal/attr/pure.h
+stack.o: $(hdrdir)/ruby/internal/attr/restrict.h
+stack.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+stack.o: $(hdrdir)/ruby/internal/attr/warning.h
+stack.o: $(hdrdir)/ruby/internal/attr/weakref.h
+stack.o: $(hdrdir)/ruby/internal/cast.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+stack.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+stack.o: $(hdrdir)/ruby/internal/compiler_since.h
+stack.o: $(hdrdir)/ruby/internal/config.h
+stack.o: $(hdrdir)/ruby/internal/constant_p.h
+stack.o: $(hdrdir)/ruby/internal/core.h
+stack.o: $(hdrdir)/ruby/internal/core/rarray.h
+stack.o: $(hdrdir)/ruby/internal/core/rbasic.h
+stack.o: $(hdrdir)/ruby/internal/core/rbignum.h
+stack.o: $(hdrdir)/ruby/internal/core/rclass.h
+stack.o: $(hdrdir)/ruby/internal/core/rdata.h
+stack.o: $(hdrdir)/ruby/internal/core/rfile.h
+stack.o: $(hdrdir)/ruby/internal/core/rhash.h
+stack.o: $(hdrdir)/ruby/internal/core/robject.h
+stack.o: $(hdrdir)/ruby/internal/core/rregexp.h
+stack.o: $(hdrdir)/ruby/internal/core/rstring.h
+stack.o: $(hdrdir)/ruby/internal/core/rstruct.h
+stack.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+stack.o: $(hdrdir)/ruby/internal/ctype.h
+stack.o: $(hdrdir)/ruby/internal/dllexport.h
+stack.o: $(hdrdir)/ruby/internal/dosish.h
+stack.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+stack.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+stack.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+stack.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+stack.o: $(hdrdir)/ruby/internal/encoding/re.h
+stack.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+stack.o: $(hdrdir)/ruby/internal/encoding/string.h
+stack.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+stack.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+stack.o: $(hdrdir)/ruby/internal/error.h
+stack.o: $(hdrdir)/ruby/internal/eval.h
+stack.o: $(hdrdir)/ruby/internal/event.h
+stack.o: $(hdrdir)/ruby/internal/fl_type.h
+stack.o: $(hdrdir)/ruby/internal/gc.h
+stack.o: $(hdrdir)/ruby/internal/glob.h
+stack.o: $(hdrdir)/ruby/internal/globals.h
+stack.o: $(hdrdir)/ruby/internal/has/attribute.h
+stack.o: $(hdrdir)/ruby/internal/has/builtin.h
+stack.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+stack.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+stack.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+stack.o: $(hdrdir)/ruby/internal/has/extension.h
+stack.o: $(hdrdir)/ruby/internal/has/feature.h
+stack.o: $(hdrdir)/ruby/internal/has/warning.h
+stack.o: $(hdrdir)/ruby/internal/intern/array.h
+stack.o: $(hdrdir)/ruby/internal/intern/bignum.h
+stack.o: $(hdrdir)/ruby/internal/intern/class.h
+stack.o: $(hdrdir)/ruby/internal/intern/compar.h
+stack.o: $(hdrdir)/ruby/internal/intern/complex.h
+stack.o: $(hdrdir)/ruby/internal/intern/cont.h
+stack.o: $(hdrdir)/ruby/internal/intern/dir.h
+stack.o: $(hdrdir)/ruby/internal/intern/enum.h
+stack.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+stack.o: $(hdrdir)/ruby/internal/intern/error.h
+stack.o: $(hdrdir)/ruby/internal/intern/eval.h
+stack.o: $(hdrdir)/ruby/internal/intern/file.h
+stack.o: $(hdrdir)/ruby/internal/intern/hash.h
+stack.o: $(hdrdir)/ruby/internal/intern/io.h
+stack.o: $(hdrdir)/ruby/internal/intern/load.h
+stack.o: $(hdrdir)/ruby/internal/intern/marshal.h
+stack.o: $(hdrdir)/ruby/internal/intern/numeric.h
+stack.o: $(hdrdir)/ruby/internal/intern/object.h
+stack.o: $(hdrdir)/ruby/internal/intern/parse.h
+stack.o: $(hdrdir)/ruby/internal/intern/proc.h
+stack.o: $(hdrdir)/ruby/internal/intern/process.h
+stack.o: $(hdrdir)/ruby/internal/intern/random.h
+stack.o: $(hdrdir)/ruby/internal/intern/range.h
+stack.o: $(hdrdir)/ruby/internal/intern/rational.h
+stack.o: $(hdrdir)/ruby/internal/intern/re.h
+stack.o: $(hdrdir)/ruby/internal/intern/ruby.h
+stack.o: $(hdrdir)/ruby/internal/intern/select.h
+stack.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+stack.o: $(hdrdir)/ruby/internal/intern/set.h
+stack.o: $(hdrdir)/ruby/internal/intern/signal.h
+stack.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+stack.o: $(hdrdir)/ruby/internal/intern/string.h
+stack.o: $(hdrdir)/ruby/internal/intern/struct.h
+stack.o: $(hdrdir)/ruby/internal/intern/thread.h
+stack.o: $(hdrdir)/ruby/internal/intern/time.h
+stack.o: $(hdrdir)/ruby/internal/intern/variable.h
+stack.o: $(hdrdir)/ruby/internal/intern/vm.h
+stack.o: $(hdrdir)/ruby/internal/interpreter.h
+stack.o: $(hdrdir)/ruby/internal/iterator.h
+stack.o: $(hdrdir)/ruby/internal/memory.h
+stack.o: $(hdrdir)/ruby/internal/method.h
+stack.o: $(hdrdir)/ruby/internal/module.h
+stack.o: $(hdrdir)/ruby/internal/newobj.h
+stack.o: $(hdrdir)/ruby/internal/scan_args.h
+stack.o: $(hdrdir)/ruby/internal/special_consts.h
+stack.o: $(hdrdir)/ruby/internal/static_assert.h
+stack.o: $(hdrdir)/ruby/internal/stdalign.h
+stack.o: $(hdrdir)/ruby/internal/stdbool.h
+stack.o: $(hdrdir)/ruby/internal/stdckdint.h
+stack.o: $(hdrdir)/ruby/internal/symbol.h
+stack.o: $(hdrdir)/ruby/internal/value.h
+stack.o: $(hdrdir)/ruby/internal/value_type.h
+stack.o: $(hdrdir)/ruby/internal/variable.h
+stack.o: $(hdrdir)/ruby/internal/warning_push.h
+stack.o: $(hdrdir)/ruby/internal/xmalloc.h
+stack.o: $(hdrdir)/ruby/missing.h
+stack.o: $(hdrdir)/ruby/onigmo.h
+stack.o: $(hdrdir)/ruby/oniguruma.h
+stack.o: $(hdrdir)/ruby/ruby.h
+stack.o: $(hdrdir)/ruby/st.h
+stack.o: $(hdrdir)/ruby/subst.h
+stack.o: $(top_srcdir)/encindex.h
+stack.o: $(top_srcdir)/internal/compilers.h
+stack.o: $(top_srcdir)/internal/string.h
+stack.o: stack.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/stack/extconf.rb b/ext/-test-/stack/extconf.rb
new file mode 100644
index 0000000000..d786b15db9
--- /dev/null
+++ b/ext/-test-/stack/extconf.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: false
+require_relative "../auto_ext.rb"
+auto_ext(inc: true)
diff --git a/ext/-test-/stack/stack.c b/ext/-test-/stack/stack.c
new file mode 100644
index 0000000000..f0e65e74b2
--- /dev/null
+++ b/ext/-test-/stack/stack.c
@@ -0,0 +1,35 @@
+#include "ruby.h"
+#include "internal/string.h"
+
+static VALUE
+stack_overflow(VALUE self)
+{
+ size_t i = 0;
+
+ while (1) {
+ // Allocate and touch memory to force actual stack usage:
+ volatile char *stack = alloca(1024);
+ stack[0] = (char)i;
+ stack[1023] = (char)i;
+ i++;
+ }
+
+ return Qnil;
+}
+
+static VALUE
+asan_p(VALUE klass)
+{
+#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
+ return Qtrue;
+#else
+ return Qfalse;
+#endif
+}
+
+void
+Init_stack(VALUE klass)
+{
+ rb_define_singleton_method(rb_cThread, "stack_overflow", stack_overflow, 0);
+ rb_define_singleton_method(rb_cThread, "asan?", asan_p, 0);
+}
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c
index 468ee7a3b1..931220b46b 100644
--- a/ext/-test-/string/cstr.c
+++ b/ext/-test-/string/cstr.c
@@ -61,18 +61,12 @@ bug_str_unterminated_substring(VALUE str, VALUE vbeg, VALUE vlen)
if (RSTRING_LEN(str) < beg) rb_raise(rb_eIndexError, "beg: %ld", beg);
if (RSTRING_LEN(str) < beg + len) rb_raise(rb_eIndexError, "end: %ld", beg + len);
str = rb_str_new_shared(str);
+ RSTRING(str)->len = len;
if (STR_EMBED_P(str)) {
-#if USE_RVARGC
- RSTRING(str)->as.embed.len = (short)len;
-#else
- RSTRING(str)->basic.flags &= ~RSTRING_EMBED_LEN_MASK;
- RSTRING(str)->basic.flags |= len << RSTRING_EMBED_LEN_SHIFT;
-#endif
memmove(RSTRING(str)->as.embed.ary, RSTRING(str)->as.embed.ary + beg, len);
}
else {
RSTRING(str)->as.heap.ptr += beg;
- RSTRING(str)->as.heap.len = len;
}
return str;
}
@@ -116,14 +110,11 @@ bug_str_s_cstr_noembed(VALUE self, VALUE str)
Check_Type(str, T_STRING);
FL_SET((str2), STR_NOEMBED);
memcpy(buf, RSTRING_PTR(str), capacity);
-#if USE_RVARGC
RBASIC(str2)->flags &= ~(STR_SHARED | FL_USER5 | FL_USER6);
-#else
- RBASIC(str2)->flags &= ~RSTRING_EMBED_LEN_MASK;
-#endif
- RSTRING(str2)->as.heap.aux.capa = capacity;
+ RSTRING(str2)->as.heap.aux.capa = RSTRING_LEN(str);
RSTRING(str2)->as.heap.ptr = buf;
- RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
+ RSTRING(str2)->len = RSTRING_LEN(str);
+
TERM_FILL(RSTRING_END(str2), TERM_LEN(str));
return str2;
}
diff --git a/ext/-test-/string/depend b/ext/-test-/string/depend
index 26720282b2..478ae3b82b 100644
--- a/ext/-test-/string/depend
+++ b/ext/-test-/string/depend
@@ -139,6 +139,7 @@ capacity.o: $(hdrdir)/ruby/internal/intern/re.h
capacity.o: $(hdrdir)/ruby/internal/intern/ruby.h
capacity.o: $(hdrdir)/ruby/internal/intern/select.h
capacity.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+capacity.o: $(hdrdir)/ruby/internal/intern/set.h
capacity.o: $(hdrdir)/ruby/internal/intern/signal.h
capacity.o: $(hdrdir)/ruby/internal/intern/sprintf.h
capacity.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -158,6 +159,7 @@ capacity.o: $(hdrdir)/ruby/internal/special_consts.h
capacity.o: $(hdrdir)/ruby/internal/static_assert.h
capacity.o: $(hdrdir)/ruby/internal/stdalign.h
capacity.o: $(hdrdir)/ruby/internal/stdbool.h
+capacity.o: $(hdrdir)/ruby/internal/stdckdint.h
capacity.o: $(hdrdir)/ruby/internal/symbol.h
capacity.o: $(hdrdir)/ruby/internal/value.h
capacity.o: $(hdrdir)/ruby/internal/value_type.h
@@ -170,9 +172,170 @@ capacity.o: $(hdrdir)/ruby/oniguruma.h
capacity.o: $(hdrdir)/ruby/ruby.h
capacity.o: $(hdrdir)/ruby/st.h
capacity.o: $(hdrdir)/ruby/subst.h
+capacity.o: $(top_srcdir)/encindex.h
capacity.o: $(top_srcdir)/internal/compilers.h
capacity.o: $(top_srcdir)/internal/string.h
capacity.o: capacity.c
+chilled.o: $(RUBY_EXTCONF_H)
+chilled.o: $(arch_hdrdir)/ruby/config.h
+chilled.o: $(hdrdir)/ruby.h
+chilled.o: $(hdrdir)/ruby/assert.h
+chilled.o: $(hdrdir)/ruby/backward.h
+chilled.o: $(hdrdir)/ruby/backward/2/assume.h
+chilled.o: $(hdrdir)/ruby/backward/2/attributes.h
+chilled.o: $(hdrdir)/ruby/backward/2/bool.h
+chilled.o: $(hdrdir)/ruby/backward/2/inttypes.h
+chilled.o: $(hdrdir)/ruby/backward/2/limits.h
+chilled.o: $(hdrdir)/ruby/backward/2/long_long.h
+chilled.o: $(hdrdir)/ruby/backward/2/stdalign.h
+chilled.o: $(hdrdir)/ruby/backward/2/stdarg.h
+chilled.o: $(hdrdir)/ruby/defines.h
+chilled.o: $(hdrdir)/ruby/intern.h
+chilled.o: $(hdrdir)/ruby/internal/abi.h
+chilled.o: $(hdrdir)/ruby/internal/anyargs.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+chilled.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+chilled.o: $(hdrdir)/ruby/internal/assume.h
+chilled.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+chilled.o: $(hdrdir)/ruby/internal/attr/artificial.h
+chilled.o: $(hdrdir)/ruby/internal/attr/cold.h
+chilled.o: $(hdrdir)/ruby/internal/attr/const.h
+chilled.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+chilled.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+chilled.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+chilled.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+chilled.o: $(hdrdir)/ruby/internal/attr/error.h
+chilled.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+chilled.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+chilled.o: $(hdrdir)/ruby/internal/attr/format.h
+chilled.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+chilled.o: $(hdrdir)/ruby/internal/attr/noalias.h
+chilled.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+chilled.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+chilled.o: $(hdrdir)/ruby/internal/attr/noinline.h
+chilled.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+chilled.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+chilled.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+chilled.o: $(hdrdir)/ruby/internal/attr/pure.h
+chilled.o: $(hdrdir)/ruby/internal/attr/restrict.h
+chilled.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+chilled.o: $(hdrdir)/ruby/internal/attr/warning.h
+chilled.o: $(hdrdir)/ruby/internal/attr/weakref.h
+chilled.o: $(hdrdir)/ruby/internal/cast.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+chilled.o: $(hdrdir)/ruby/internal/compiler_since.h
+chilled.o: $(hdrdir)/ruby/internal/config.h
+chilled.o: $(hdrdir)/ruby/internal/constant_p.h
+chilled.o: $(hdrdir)/ruby/internal/core.h
+chilled.o: $(hdrdir)/ruby/internal/core/rarray.h
+chilled.o: $(hdrdir)/ruby/internal/core/rbasic.h
+chilled.o: $(hdrdir)/ruby/internal/core/rbignum.h
+chilled.o: $(hdrdir)/ruby/internal/core/rclass.h
+chilled.o: $(hdrdir)/ruby/internal/core/rdata.h
+chilled.o: $(hdrdir)/ruby/internal/core/rfile.h
+chilled.o: $(hdrdir)/ruby/internal/core/rhash.h
+chilled.o: $(hdrdir)/ruby/internal/core/robject.h
+chilled.o: $(hdrdir)/ruby/internal/core/rregexp.h
+chilled.o: $(hdrdir)/ruby/internal/core/rstring.h
+chilled.o: $(hdrdir)/ruby/internal/core/rstruct.h
+chilled.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+chilled.o: $(hdrdir)/ruby/internal/ctype.h
+chilled.o: $(hdrdir)/ruby/internal/dllexport.h
+chilled.o: $(hdrdir)/ruby/internal/dosish.h
+chilled.o: $(hdrdir)/ruby/internal/error.h
+chilled.o: $(hdrdir)/ruby/internal/eval.h
+chilled.o: $(hdrdir)/ruby/internal/event.h
+chilled.o: $(hdrdir)/ruby/internal/fl_type.h
+chilled.o: $(hdrdir)/ruby/internal/gc.h
+chilled.o: $(hdrdir)/ruby/internal/glob.h
+chilled.o: $(hdrdir)/ruby/internal/globals.h
+chilled.o: $(hdrdir)/ruby/internal/has/attribute.h
+chilled.o: $(hdrdir)/ruby/internal/has/builtin.h
+chilled.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+chilled.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+chilled.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+chilled.o: $(hdrdir)/ruby/internal/has/extension.h
+chilled.o: $(hdrdir)/ruby/internal/has/feature.h
+chilled.o: $(hdrdir)/ruby/internal/has/warning.h
+chilled.o: $(hdrdir)/ruby/internal/intern/array.h
+chilled.o: $(hdrdir)/ruby/internal/intern/bignum.h
+chilled.o: $(hdrdir)/ruby/internal/intern/class.h
+chilled.o: $(hdrdir)/ruby/internal/intern/compar.h
+chilled.o: $(hdrdir)/ruby/internal/intern/complex.h
+chilled.o: $(hdrdir)/ruby/internal/intern/cont.h
+chilled.o: $(hdrdir)/ruby/internal/intern/dir.h
+chilled.o: $(hdrdir)/ruby/internal/intern/enum.h
+chilled.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+chilled.o: $(hdrdir)/ruby/internal/intern/error.h
+chilled.o: $(hdrdir)/ruby/internal/intern/eval.h
+chilled.o: $(hdrdir)/ruby/internal/intern/file.h
+chilled.o: $(hdrdir)/ruby/internal/intern/hash.h
+chilled.o: $(hdrdir)/ruby/internal/intern/io.h
+chilled.o: $(hdrdir)/ruby/internal/intern/load.h
+chilled.o: $(hdrdir)/ruby/internal/intern/marshal.h
+chilled.o: $(hdrdir)/ruby/internal/intern/numeric.h
+chilled.o: $(hdrdir)/ruby/internal/intern/object.h
+chilled.o: $(hdrdir)/ruby/internal/intern/parse.h
+chilled.o: $(hdrdir)/ruby/internal/intern/proc.h
+chilled.o: $(hdrdir)/ruby/internal/intern/process.h
+chilled.o: $(hdrdir)/ruby/internal/intern/random.h
+chilled.o: $(hdrdir)/ruby/internal/intern/range.h
+chilled.o: $(hdrdir)/ruby/internal/intern/rational.h
+chilled.o: $(hdrdir)/ruby/internal/intern/re.h
+chilled.o: $(hdrdir)/ruby/internal/intern/ruby.h
+chilled.o: $(hdrdir)/ruby/internal/intern/select.h
+chilled.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+chilled.o: $(hdrdir)/ruby/internal/intern/signal.h
+chilled.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+chilled.o: $(hdrdir)/ruby/internal/intern/string.h
+chilled.o: $(hdrdir)/ruby/internal/intern/struct.h
+chilled.o: $(hdrdir)/ruby/internal/intern/thread.h
+chilled.o: $(hdrdir)/ruby/internal/intern/time.h
+chilled.o: $(hdrdir)/ruby/internal/intern/variable.h
+chilled.o: $(hdrdir)/ruby/internal/intern/vm.h
+chilled.o: $(hdrdir)/ruby/internal/interpreter.h
+chilled.o: $(hdrdir)/ruby/internal/iterator.h
+chilled.o: $(hdrdir)/ruby/internal/memory.h
+chilled.o: $(hdrdir)/ruby/internal/method.h
+chilled.o: $(hdrdir)/ruby/internal/module.h
+chilled.o: $(hdrdir)/ruby/internal/newobj.h
+chilled.o: $(hdrdir)/ruby/internal/scan_args.h
+chilled.o: $(hdrdir)/ruby/internal/special_consts.h
+chilled.o: $(hdrdir)/ruby/internal/static_assert.h
+chilled.o: $(hdrdir)/ruby/internal/stdalign.h
+chilled.o: $(hdrdir)/ruby/internal/stdbool.h
+chilled.o: $(hdrdir)/ruby/internal/stdckdint.h
+chilled.o: $(hdrdir)/ruby/internal/symbol.h
+chilled.o: $(hdrdir)/ruby/internal/value.h
+chilled.o: $(hdrdir)/ruby/internal/value_type.h
+chilled.o: $(hdrdir)/ruby/internal/variable.h
+chilled.o: $(hdrdir)/ruby/internal/warning_push.h
+chilled.o: $(hdrdir)/ruby/internal/xmalloc.h
+chilled.o: $(hdrdir)/ruby/missing.h
+chilled.o: $(hdrdir)/ruby/ruby.h
+chilled.o: $(hdrdir)/ruby/st.h
+chilled.o: $(hdrdir)/ruby/subst.h
+chilled.o: chilled.c
coderange.o: $(RUBY_EXTCONF_H)
coderange.o: $(arch_hdrdir)/ruby/config.h
coderange.o: $(hdrdir)/ruby/assert.h
@@ -311,6 +474,7 @@ coderange.o: $(hdrdir)/ruby/internal/intern/re.h
coderange.o: $(hdrdir)/ruby/internal/intern/ruby.h
coderange.o: $(hdrdir)/ruby/internal/intern/select.h
coderange.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+coderange.o: $(hdrdir)/ruby/internal/intern/set.h
coderange.o: $(hdrdir)/ruby/internal/intern/signal.h
coderange.o: $(hdrdir)/ruby/internal/intern/sprintf.h
coderange.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -330,6 +494,7 @@ coderange.o: $(hdrdir)/ruby/internal/special_consts.h
coderange.o: $(hdrdir)/ruby/internal/static_assert.h
coderange.o: $(hdrdir)/ruby/internal/stdalign.h
coderange.o: $(hdrdir)/ruby/internal/stdbool.h
+coderange.o: $(hdrdir)/ruby/internal/stdckdint.h
coderange.o: $(hdrdir)/ruby/internal/symbol.h
coderange.o: $(hdrdir)/ruby/internal/value.h
coderange.o: $(hdrdir)/ruby/internal/value_type.h
@@ -482,6 +647,7 @@ cstr.o: $(hdrdir)/ruby/internal/intern/re.h
cstr.o: $(hdrdir)/ruby/internal/intern/ruby.h
cstr.o: $(hdrdir)/ruby/internal/intern/select.h
cstr.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+cstr.o: $(hdrdir)/ruby/internal/intern/set.h
cstr.o: $(hdrdir)/ruby/internal/intern/signal.h
cstr.o: $(hdrdir)/ruby/internal/intern/sprintf.h
cstr.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -501,6 +667,7 @@ cstr.o: $(hdrdir)/ruby/internal/special_consts.h
cstr.o: $(hdrdir)/ruby/internal/static_assert.h
cstr.o: $(hdrdir)/ruby/internal/stdalign.h
cstr.o: $(hdrdir)/ruby/internal/stdbool.h
+cstr.o: $(hdrdir)/ruby/internal/stdckdint.h
cstr.o: $(hdrdir)/ruby/internal/symbol.h
cstr.o: $(hdrdir)/ruby/internal/value.h
cstr.o: $(hdrdir)/ruby/internal/value_type.h
@@ -513,6 +680,7 @@ cstr.o: $(hdrdir)/ruby/oniguruma.h
cstr.o: $(hdrdir)/ruby/ruby.h
cstr.o: $(hdrdir)/ruby/st.h
cstr.o: $(hdrdir)/ruby/subst.h
+cstr.o: $(top_srcdir)/encindex.h
cstr.o: $(top_srcdir)/internal.h
cstr.o: $(top_srcdir)/internal/compilers.h
cstr.o: $(top_srcdir)/internal/string.h
@@ -646,6 +814,7 @@ ellipsize.o: $(hdrdir)/ruby/internal/intern/re.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/ruby.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/select.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ellipsize.o: $(hdrdir)/ruby/internal/intern/set.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/signal.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -665,6 +834,7 @@ ellipsize.o: $(hdrdir)/ruby/internal/special_consts.h
ellipsize.o: $(hdrdir)/ruby/internal/static_assert.h
ellipsize.o: $(hdrdir)/ruby/internal/stdalign.h
ellipsize.o: $(hdrdir)/ruby/internal/stdbool.h
+ellipsize.o: $(hdrdir)/ruby/internal/stdckdint.h
ellipsize.o: $(hdrdir)/ruby/internal/symbol.h
ellipsize.o: $(hdrdir)/ruby/internal/value.h
ellipsize.o: $(hdrdir)/ruby/internal/value_type.h
@@ -815,6 +985,7 @@ enc_associate.o: $(hdrdir)/ruby/internal/intern/re.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/ruby.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/select.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+enc_associate.o: $(hdrdir)/ruby/internal/intern/set.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/signal.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/sprintf.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -834,6 +1005,7 @@ enc_associate.o: $(hdrdir)/ruby/internal/special_consts.h
enc_associate.o: $(hdrdir)/ruby/internal/static_assert.h
enc_associate.o: $(hdrdir)/ruby/internal/stdalign.h
enc_associate.o: $(hdrdir)/ruby/internal/stdbool.h
+enc_associate.o: $(hdrdir)/ruby/internal/stdckdint.h
enc_associate.o: $(hdrdir)/ruby/internal/symbol.h
enc_associate.o: $(hdrdir)/ruby/internal/value.h
enc_associate.o: $(hdrdir)/ruby/internal/value_type.h
@@ -986,6 +1158,7 @@ enc_dummy.o: $(hdrdir)/ruby/internal/intern/re.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/ruby.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/select.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+enc_dummy.o: $(hdrdir)/ruby/internal/intern/set.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/signal.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/sprintf.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1005,6 +1178,7 @@ enc_dummy.o: $(hdrdir)/ruby/internal/special_consts.h
enc_dummy.o: $(hdrdir)/ruby/internal/static_assert.h
enc_dummy.o: $(hdrdir)/ruby/internal/stdalign.h
enc_dummy.o: $(hdrdir)/ruby/internal/stdbool.h
+enc_dummy.o: $(hdrdir)/ruby/internal/stdckdint.h
enc_dummy.o: $(hdrdir)/ruby/internal/symbol.h
enc_dummy.o: $(hdrdir)/ruby/internal/value.h
enc_dummy.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1156,6 +1330,7 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/re.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/ruby.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/select.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/set.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/signal.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/sprintf.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1175,6 +1350,7 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/internal/special_consts.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/static_assert.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/stdalign.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/stdbool.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/internal/stdckdint.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/symbol.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/value.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1196,6 +1372,7 @@ fstring.o: $(hdrdir)/ruby/backward.h
fstring.o: $(hdrdir)/ruby/backward/2/assume.h
fstring.o: $(hdrdir)/ruby/backward/2/attributes.h
fstring.o: $(hdrdir)/ruby/backward/2/bool.h
+fstring.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
fstring.o: $(hdrdir)/ruby/backward/2/inttypes.h
fstring.o: $(hdrdir)/ruby/backward/2/limits.h
fstring.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -1327,6 +1504,7 @@ fstring.o: $(hdrdir)/ruby/internal/intern/re.h
fstring.o: $(hdrdir)/ruby/internal/intern/ruby.h
fstring.o: $(hdrdir)/ruby/internal/intern/select.h
fstring.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+fstring.o: $(hdrdir)/ruby/internal/intern/set.h
fstring.o: $(hdrdir)/ruby/internal/intern/signal.h
fstring.o: $(hdrdir)/ruby/internal/intern/sprintf.h
fstring.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1346,6 +1524,7 @@ fstring.o: $(hdrdir)/ruby/internal/special_consts.h
fstring.o: $(hdrdir)/ruby/internal/static_assert.h
fstring.o: $(hdrdir)/ruby/internal/stdalign.h
fstring.o: $(hdrdir)/ruby/internal/stdbool.h
+fstring.o: $(hdrdir)/ruby/internal/stdckdint.h
fstring.o: $(hdrdir)/ruby/internal/symbol.h
fstring.o: $(hdrdir)/ruby/internal/value.h
fstring.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1358,6 +1537,9 @@ fstring.o: $(hdrdir)/ruby/oniguruma.h
fstring.o: $(hdrdir)/ruby/ruby.h
fstring.o: $(hdrdir)/ruby/st.h
fstring.o: $(hdrdir)/ruby/subst.h
+fstring.o: $(top_srcdir)/encindex.h
+fstring.o: $(top_srcdir)/internal/compilers.h
+fstring.o: $(top_srcdir)/internal/string.h
fstring.o: fstring.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
@@ -1488,6 +1670,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1507,6 +1690,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1647,6 +1831,7 @@ modify.o: $(hdrdir)/ruby/internal/intern/re.h
modify.o: $(hdrdir)/ruby/internal/intern/ruby.h
modify.o: $(hdrdir)/ruby/internal/intern/select.h
modify.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+modify.o: $(hdrdir)/ruby/internal/intern/set.h
modify.o: $(hdrdir)/ruby/internal/intern/signal.h
modify.o: $(hdrdir)/ruby/internal/intern/sprintf.h
modify.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1666,6 +1851,7 @@ modify.o: $(hdrdir)/ruby/internal/special_consts.h
modify.o: $(hdrdir)/ruby/internal/static_assert.h
modify.o: $(hdrdir)/ruby/internal/stdalign.h
modify.o: $(hdrdir)/ruby/internal/stdbool.h
+modify.o: $(hdrdir)/ruby/internal/stdckdint.h
modify.o: $(hdrdir)/ruby/internal/symbol.h
modify.o: $(hdrdir)/ruby/internal/value.h
modify.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1816,6 +2002,7 @@ new.o: $(hdrdir)/ruby/internal/intern/re.h
new.o: $(hdrdir)/ruby/internal/intern/ruby.h
new.o: $(hdrdir)/ruby/internal/intern/select.h
new.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+new.o: $(hdrdir)/ruby/internal/intern/set.h
new.o: $(hdrdir)/ruby/internal/intern/signal.h
new.o: $(hdrdir)/ruby/internal/intern/sprintf.h
new.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1835,6 +2022,7 @@ new.o: $(hdrdir)/ruby/internal/special_consts.h
new.o: $(hdrdir)/ruby/internal/static_assert.h
new.o: $(hdrdir)/ruby/internal/stdalign.h
new.o: $(hdrdir)/ruby/internal/stdbool.h
+new.o: $(hdrdir)/ruby/internal/stdckdint.h
new.o: $(hdrdir)/ruby/internal/symbol.h
new.o: $(hdrdir)/ruby/internal/value.h
new.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1977,6 +2165,7 @@ nofree.o: $(hdrdir)/ruby/internal/intern/re.h
nofree.o: $(hdrdir)/ruby/internal/intern/ruby.h
nofree.o: $(hdrdir)/ruby/internal/intern/select.h
nofree.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+nofree.o: $(hdrdir)/ruby/internal/intern/set.h
nofree.o: $(hdrdir)/ruby/internal/intern/signal.h
nofree.o: $(hdrdir)/ruby/internal/intern/sprintf.h
nofree.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1996,6 +2185,7 @@ nofree.o: $(hdrdir)/ruby/internal/special_consts.h
nofree.o: $(hdrdir)/ruby/internal/static_assert.h
nofree.o: $(hdrdir)/ruby/internal/stdalign.h
nofree.o: $(hdrdir)/ruby/internal/stdbool.h
+nofree.o: $(hdrdir)/ruby/internal/stdckdint.h
nofree.o: $(hdrdir)/ruby/internal/symbol.h
nofree.o: $(hdrdir)/ruby/internal/value.h
nofree.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2145,6 +2335,7 @@ normalize.o: $(hdrdir)/ruby/internal/intern/re.h
normalize.o: $(hdrdir)/ruby/internal/intern/ruby.h
normalize.o: $(hdrdir)/ruby/internal/intern/select.h
normalize.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+normalize.o: $(hdrdir)/ruby/internal/intern/set.h
normalize.o: $(hdrdir)/ruby/internal/intern/signal.h
normalize.o: $(hdrdir)/ruby/internal/intern/sprintf.h
normalize.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2164,6 +2355,7 @@ normalize.o: $(hdrdir)/ruby/internal/special_consts.h
normalize.o: $(hdrdir)/ruby/internal/static_assert.h
normalize.o: $(hdrdir)/ruby/internal/stdalign.h
normalize.o: $(hdrdir)/ruby/internal/stdbool.h
+normalize.o: $(hdrdir)/ruby/internal/stdckdint.h
normalize.o: $(hdrdir)/ruby/internal/symbol.h
normalize.o: $(hdrdir)/ruby/internal/value.h
normalize.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2317,6 +2509,7 @@ qsort.o: $(hdrdir)/ruby/internal/intern/re.h
qsort.o: $(hdrdir)/ruby/internal/intern/ruby.h
qsort.o: $(hdrdir)/ruby/internal/intern/select.h
qsort.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+qsort.o: $(hdrdir)/ruby/internal/intern/set.h
qsort.o: $(hdrdir)/ruby/internal/intern/signal.h
qsort.o: $(hdrdir)/ruby/internal/intern/sprintf.h
qsort.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2336,6 +2529,7 @@ qsort.o: $(hdrdir)/ruby/internal/special_consts.h
qsort.o: $(hdrdir)/ruby/internal/static_assert.h
qsort.o: $(hdrdir)/ruby/internal/stdalign.h
qsort.o: $(hdrdir)/ruby/internal/stdbool.h
+qsort.o: $(hdrdir)/ruby/internal/stdckdint.h
qsort.o: $(hdrdir)/ruby/internal/symbol.h
qsort.o: $(hdrdir)/ruby/internal/value.h
qsort.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2479,6 +2673,7 @@ rb_interned_str.o: $(hdrdir)/ruby/internal/intern/re.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/ruby.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/select.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rb_interned_str.o: $(hdrdir)/ruby/internal/intern/set.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/signal.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2498,6 +2693,7 @@ rb_interned_str.o: $(hdrdir)/ruby/internal/special_consts.h
rb_interned_str.o: $(hdrdir)/ruby/internal/static_assert.h
rb_interned_str.o: $(hdrdir)/ruby/internal/stdalign.h
rb_interned_str.o: $(hdrdir)/ruby/internal/stdbool.h
+rb_interned_str.o: $(hdrdir)/ruby/internal/stdckdint.h
rb_interned_str.o: $(hdrdir)/ruby/internal/symbol.h
rb_interned_str.o: $(hdrdir)/ruby/internal/value.h
rb_interned_str.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2638,6 +2834,7 @@ rb_str_dup.o: $(hdrdir)/ruby/internal/intern/re.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/ruby.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/select.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rb_str_dup.o: $(hdrdir)/ruby/internal/intern/set.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/signal.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2657,6 +2854,7 @@ rb_str_dup.o: $(hdrdir)/ruby/internal/special_consts.h
rb_str_dup.o: $(hdrdir)/ruby/internal/static_assert.h
rb_str_dup.o: $(hdrdir)/ruby/internal/stdalign.h
rb_str_dup.o: $(hdrdir)/ruby/internal/stdbool.h
+rb_str_dup.o: $(hdrdir)/ruby/internal/stdckdint.h
rb_str_dup.o: $(hdrdir)/ruby/internal/symbol.h
rb_str_dup.o: $(hdrdir)/ruby/internal/value.h
rb_str_dup.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2797,6 +2995,7 @@ set_len.o: $(hdrdir)/ruby/internal/intern/re.h
set_len.o: $(hdrdir)/ruby/internal/intern/ruby.h
set_len.o: $(hdrdir)/ruby/internal/intern/select.h
set_len.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+set_len.o: $(hdrdir)/ruby/internal/intern/set.h
set_len.o: $(hdrdir)/ruby/internal/intern/signal.h
set_len.o: $(hdrdir)/ruby/internal/intern/sprintf.h
set_len.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2816,6 +3015,7 @@ set_len.o: $(hdrdir)/ruby/internal/special_consts.h
set_len.o: $(hdrdir)/ruby/internal/static_assert.h
set_len.o: $(hdrdir)/ruby/internal/stdalign.h
set_len.o: $(hdrdir)/ruby/internal/stdbool.h
+set_len.o: $(hdrdir)/ruby/internal/stdckdint.h
set_len.o: $(hdrdir)/ruby/internal/symbol.h
set_len.o: $(hdrdir)/ruby/internal/value.h
set_len.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/string/fstring.c b/ext/-test-/string/fstring.c
index 2374319fe3..0b5940f28c 100644
--- a/ext/-test-/string/fstring.c
+++ b/ext/-test-/string/fstring.c
@@ -1,30 +1,38 @@
#include "ruby.h"
#include "ruby/encoding.h"
-
-VALUE rb_fstring(VALUE str);
+#include "internal/string.h"
VALUE
bug_s_fstring(VALUE self, VALUE str)
{
- return rb_fstring(str);
+ return rb_str_to_interned_str(str);
+}
+
+VALUE
+bug_s_fstring_fake_str(VALUE self)
+{
+ static const char literal[] = "abcdefghijklmnopqrstuvwxyz";
+ struct RString fake_str = {RBASIC_INIT};
+ return rb_str_to_interned_str(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0));
}
VALUE
bug_s_rb_enc_interned_str(VALUE self, VALUE encoding)
{
- return rb_enc_interned_str("foo", 3, RDATA(encoding)->data);
+ return rb_enc_interned_str("foo", 3, NIL_P(encoding) ? NULL : RTYPEDDATA_GET_DATA(encoding));
}
VALUE
bug_s_rb_enc_str_new(VALUE self, VALUE encoding)
{
- return rb_enc_str_new("foo", 3, RDATA(encoding)->data);
+ return rb_enc_str_new("foo", 3, NIL_P(encoding) ? NULL : RTYPEDDATA_GET_DATA(encoding));
}
void
Init_string_fstring(VALUE klass)
{
rb_define_singleton_method(klass, "fstring", bug_s_fstring, 1);
+ rb_define_singleton_method(klass, "fstring_fake_str", bug_s_fstring_fake_str, 0);
rb_define_singleton_method(klass, "rb_enc_interned_str", bug_s_rb_enc_interned_str, 1);
rb_define_singleton_method(klass, "rb_enc_str_new", bug_s_rb_enc_str_new, 1);
}
diff --git a/ext/-test-/string/set_len.c b/ext/-test-/string/set_len.c
index 219cea404c..b55ef6f469 100644
--- a/ext/-test-/string/set_len.c
+++ b/ext/-test-/string/set_len.c
@@ -7,8 +7,26 @@ bug_str_set_len(VALUE str, VALUE len)
return str;
}
+static VALUE
+bug_str_append(VALUE str, VALUE addendum)
+{
+ StringValue(addendum);
+ rb_str_modify_expand(str, RSTRING_LEN(addendum));
+ memcpy(RSTRING_END(str), RSTRING_PTR(addendum), RSTRING_LEN(addendum));
+ return str;
+}
+
+static VALUE
+bug_str_resize(VALUE str, VALUE len)
+{
+ rb_str_resize(str, NUM2LONG(len));
+ return str;
+}
+
void
Init_string_set_len(VALUE klass)
{
rb_define_method(klass, "set_len", bug_str_set_len, 1);
+ rb_define_method(klass, "append", bug_str_append, 1);
+ rb_define_method(klass, "resize", bug_str_resize, 1);
}
diff --git a/ext/-test-/struct/data.c b/ext/-test-/struct/data.c
new file mode 100644
index 0000000000..5841c342e7
--- /dev/null
+++ b/ext/-test-/struct/data.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+static VALUE
+bug_data_new(VALUE self, VALUE super)
+{
+ return rb_data_define(super, "mem1", "mem2", NULL);
+}
+
+void
+Init_data(VALUE klass)
+{
+ rb_define_singleton_method(klass, "data_new", bug_data_new, 1);
+}
diff --git a/ext/-test-/struct/depend b/ext/-test-/struct/depend
index 191408cc90..e2638e4cdf 100644
--- a/ext/-test-/struct/depend
+++ b/ext/-test-/struct/depend
@@ -1,4 +1,165 @@
# AUTOGENERATED DEPENDENCIES START
+data.o: $(RUBY_EXTCONF_H)
+data.o: $(arch_hdrdir)/ruby/config.h
+data.o: $(hdrdir)/ruby.h
+data.o: $(hdrdir)/ruby/assert.h
+data.o: $(hdrdir)/ruby/backward.h
+data.o: $(hdrdir)/ruby/backward/2/assume.h
+data.o: $(hdrdir)/ruby/backward/2/attributes.h
+data.o: $(hdrdir)/ruby/backward/2/bool.h
+data.o: $(hdrdir)/ruby/backward/2/inttypes.h
+data.o: $(hdrdir)/ruby/backward/2/limits.h
+data.o: $(hdrdir)/ruby/backward/2/long_long.h
+data.o: $(hdrdir)/ruby/backward/2/stdalign.h
+data.o: $(hdrdir)/ruby/backward/2/stdarg.h
+data.o: $(hdrdir)/ruby/defines.h
+data.o: $(hdrdir)/ruby/intern.h
+data.o: $(hdrdir)/ruby/internal/abi.h
+data.o: $(hdrdir)/ruby/internal/anyargs.h
+data.o: $(hdrdir)/ruby/internal/arithmetic.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+data.o: $(hdrdir)/ruby/internal/assume.h
+data.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+data.o: $(hdrdir)/ruby/internal/attr/artificial.h
+data.o: $(hdrdir)/ruby/internal/attr/cold.h
+data.o: $(hdrdir)/ruby/internal/attr/const.h
+data.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+data.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+data.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+data.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+data.o: $(hdrdir)/ruby/internal/attr/error.h
+data.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+data.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+data.o: $(hdrdir)/ruby/internal/attr/format.h
+data.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+data.o: $(hdrdir)/ruby/internal/attr/noalias.h
+data.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+data.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+data.o: $(hdrdir)/ruby/internal/attr/noinline.h
+data.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+data.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+data.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+data.o: $(hdrdir)/ruby/internal/attr/pure.h
+data.o: $(hdrdir)/ruby/internal/attr/restrict.h
+data.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+data.o: $(hdrdir)/ruby/internal/attr/warning.h
+data.o: $(hdrdir)/ruby/internal/attr/weakref.h
+data.o: $(hdrdir)/ruby/internal/cast.h
+data.o: $(hdrdir)/ruby/internal/compiler_is.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+data.o: $(hdrdir)/ruby/internal/compiler_since.h
+data.o: $(hdrdir)/ruby/internal/config.h
+data.o: $(hdrdir)/ruby/internal/constant_p.h
+data.o: $(hdrdir)/ruby/internal/core.h
+data.o: $(hdrdir)/ruby/internal/core/rarray.h
+data.o: $(hdrdir)/ruby/internal/core/rbasic.h
+data.o: $(hdrdir)/ruby/internal/core/rbignum.h
+data.o: $(hdrdir)/ruby/internal/core/rclass.h
+data.o: $(hdrdir)/ruby/internal/core/rdata.h
+data.o: $(hdrdir)/ruby/internal/core/rfile.h
+data.o: $(hdrdir)/ruby/internal/core/rhash.h
+data.o: $(hdrdir)/ruby/internal/core/robject.h
+data.o: $(hdrdir)/ruby/internal/core/rregexp.h
+data.o: $(hdrdir)/ruby/internal/core/rstring.h
+data.o: $(hdrdir)/ruby/internal/core/rstruct.h
+data.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+data.o: $(hdrdir)/ruby/internal/ctype.h
+data.o: $(hdrdir)/ruby/internal/dllexport.h
+data.o: $(hdrdir)/ruby/internal/dosish.h
+data.o: $(hdrdir)/ruby/internal/error.h
+data.o: $(hdrdir)/ruby/internal/eval.h
+data.o: $(hdrdir)/ruby/internal/event.h
+data.o: $(hdrdir)/ruby/internal/fl_type.h
+data.o: $(hdrdir)/ruby/internal/gc.h
+data.o: $(hdrdir)/ruby/internal/glob.h
+data.o: $(hdrdir)/ruby/internal/globals.h
+data.o: $(hdrdir)/ruby/internal/has/attribute.h
+data.o: $(hdrdir)/ruby/internal/has/builtin.h
+data.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/extension.h
+data.o: $(hdrdir)/ruby/internal/has/feature.h
+data.o: $(hdrdir)/ruby/internal/has/warning.h
+data.o: $(hdrdir)/ruby/internal/intern/array.h
+data.o: $(hdrdir)/ruby/internal/intern/bignum.h
+data.o: $(hdrdir)/ruby/internal/intern/class.h
+data.o: $(hdrdir)/ruby/internal/intern/compar.h
+data.o: $(hdrdir)/ruby/internal/intern/complex.h
+data.o: $(hdrdir)/ruby/internal/intern/cont.h
+data.o: $(hdrdir)/ruby/internal/intern/dir.h
+data.o: $(hdrdir)/ruby/internal/intern/enum.h
+data.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+data.o: $(hdrdir)/ruby/internal/intern/error.h
+data.o: $(hdrdir)/ruby/internal/intern/eval.h
+data.o: $(hdrdir)/ruby/internal/intern/file.h
+data.o: $(hdrdir)/ruby/internal/intern/hash.h
+data.o: $(hdrdir)/ruby/internal/intern/io.h
+data.o: $(hdrdir)/ruby/internal/intern/load.h
+data.o: $(hdrdir)/ruby/internal/intern/marshal.h
+data.o: $(hdrdir)/ruby/internal/intern/numeric.h
+data.o: $(hdrdir)/ruby/internal/intern/object.h
+data.o: $(hdrdir)/ruby/internal/intern/parse.h
+data.o: $(hdrdir)/ruby/internal/intern/proc.h
+data.o: $(hdrdir)/ruby/internal/intern/process.h
+data.o: $(hdrdir)/ruby/internal/intern/random.h
+data.o: $(hdrdir)/ruby/internal/intern/range.h
+data.o: $(hdrdir)/ruby/internal/intern/rational.h
+data.o: $(hdrdir)/ruby/internal/intern/re.h
+data.o: $(hdrdir)/ruby/internal/intern/ruby.h
+data.o: $(hdrdir)/ruby/internal/intern/select.h
+data.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+data.o: $(hdrdir)/ruby/internal/intern/set.h
+data.o: $(hdrdir)/ruby/internal/intern/signal.h
+data.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+data.o: $(hdrdir)/ruby/internal/intern/string.h
+data.o: $(hdrdir)/ruby/internal/intern/struct.h
+data.o: $(hdrdir)/ruby/internal/intern/thread.h
+data.o: $(hdrdir)/ruby/internal/intern/time.h
+data.o: $(hdrdir)/ruby/internal/intern/variable.h
+data.o: $(hdrdir)/ruby/internal/intern/vm.h
+data.o: $(hdrdir)/ruby/internal/interpreter.h
+data.o: $(hdrdir)/ruby/internal/iterator.h
+data.o: $(hdrdir)/ruby/internal/memory.h
+data.o: $(hdrdir)/ruby/internal/method.h
+data.o: $(hdrdir)/ruby/internal/module.h
+data.o: $(hdrdir)/ruby/internal/newobj.h
+data.o: $(hdrdir)/ruby/internal/scan_args.h
+data.o: $(hdrdir)/ruby/internal/special_consts.h
+data.o: $(hdrdir)/ruby/internal/static_assert.h
+data.o: $(hdrdir)/ruby/internal/stdalign.h
+data.o: $(hdrdir)/ruby/internal/stdbool.h
+data.o: $(hdrdir)/ruby/internal/stdckdint.h
+data.o: $(hdrdir)/ruby/internal/symbol.h
+data.o: $(hdrdir)/ruby/internal/value.h
+data.o: $(hdrdir)/ruby/internal/value_type.h
+data.o: $(hdrdir)/ruby/internal/variable.h
+data.o: $(hdrdir)/ruby/internal/warning_push.h
+data.o: $(hdrdir)/ruby/internal/xmalloc.h
+data.o: $(hdrdir)/ruby/missing.h
+data.o: $(hdrdir)/ruby/ruby.h
+data.o: $(hdrdir)/ruby/st.h
+data.o: $(hdrdir)/ruby/subst.h
+data.o: data.c
duplicate.o: $(RUBY_EXTCONF_H)
duplicate.o: $(arch_hdrdir)/ruby/config.h
duplicate.o: $(hdrdir)/ruby.h
@@ -128,6 +289,7 @@ duplicate.o: $(hdrdir)/ruby/internal/intern/re.h
duplicate.o: $(hdrdir)/ruby/internal/intern/ruby.h
duplicate.o: $(hdrdir)/ruby/internal/intern/select.h
duplicate.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+duplicate.o: $(hdrdir)/ruby/internal/intern/set.h
duplicate.o: $(hdrdir)/ruby/internal/intern/signal.h
duplicate.o: $(hdrdir)/ruby/internal/intern/sprintf.h
duplicate.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +309,7 @@ duplicate.o: $(hdrdir)/ruby/internal/special_consts.h
duplicate.o: $(hdrdir)/ruby/internal/static_assert.h
duplicate.o: $(hdrdir)/ruby/internal/stdalign.h
duplicate.o: $(hdrdir)/ruby/internal/stdbool.h
+duplicate.o: $(hdrdir)/ruby/internal/stdckdint.h
duplicate.o: $(hdrdir)/ruby/internal/symbol.h
duplicate.o: $(hdrdir)/ruby/internal/value.h
duplicate.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +450,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +470,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -446,6 +611,7 @@ len.o: $(hdrdir)/ruby/internal/intern/re.h
len.o: $(hdrdir)/ruby/internal/intern/ruby.h
len.o: $(hdrdir)/ruby/internal/intern/select.h
len.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+len.o: $(hdrdir)/ruby/internal/intern/set.h
len.o: $(hdrdir)/ruby/internal/intern/signal.h
len.o: $(hdrdir)/ruby/internal/intern/sprintf.h
len.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -465,6 +631,7 @@ len.o: $(hdrdir)/ruby/internal/special_consts.h
len.o: $(hdrdir)/ruby/internal/static_assert.h
len.o: $(hdrdir)/ruby/internal/stdalign.h
len.o: $(hdrdir)/ruby/internal/stdbool.h
+len.o: $(hdrdir)/ruby/internal/stdckdint.h
len.o: $(hdrdir)/ruby/internal/symbol.h
len.o: $(hdrdir)/ruby/internal/value.h
len.o: $(hdrdir)/ruby/internal/value_type.h
@@ -605,6 +772,7 @@ member.o: $(hdrdir)/ruby/internal/intern/re.h
member.o: $(hdrdir)/ruby/internal/intern/ruby.h
member.o: $(hdrdir)/ruby/internal/intern/select.h
member.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+member.o: $(hdrdir)/ruby/internal/intern/set.h
member.o: $(hdrdir)/ruby/internal/intern/signal.h
member.o: $(hdrdir)/ruby/internal/intern/sprintf.h
member.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -624,6 +792,7 @@ member.o: $(hdrdir)/ruby/internal/special_consts.h
member.o: $(hdrdir)/ruby/internal/static_assert.h
member.o: $(hdrdir)/ruby/internal/stdalign.h
member.o: $(hdrdir)/ruby/internal/stdbool.h
+member.o: $(hdrdir)/ruby/internal/stdckdint.h
member.o: $(hdrdir)/ruby/internal/symbol.h
member.o: $(hdrdir)/ruby/internal/value.h
member.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/struct/member.c b/ext/-test-/struct/member.c
index f5400fe477..29ddff93e8 100644
--- a/ext/-test-/struct/member.c
+++ b/ext/-test-/struct/member.c
@@ -6,7 +6,7 @@ bug_struct_get(VALUE obj, VALUE name)
ID id = rb_check_id(&name);
if (!id) {
- rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name);
+ rb_name_error_str(name, "'%"PRIsVALUE"' is not a struct member", name);
}
return rb_struct_getmember(obj, id);
}
diff --git a/ext/-test-/symbol/depend b/ext/-test-/symbol/depend
index dd1b5c305f..b1d8e1aab6 100644
--- a/ext/-test-/symbol/depend
+++ b/ext/-test-/symbol/depend
@@ -128,6 +128,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ type.o: $(hdrdir)/ruby/internal/intern/re.h
type.o: $(hdrdir)/ruby/internal/intern/ruby.h
type.o: $(hdrdir)/ruby/internal/intern/select.h
type.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+type.o: $(hdrdir)/ruby/internal/intern/set.h
type.o: $(hdrdir)/ruby/internal/intern/signal.h
type.o: $(hdrdir)/ruby/internal/intern/sprintf.h
type.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ type.o: $(hdrdir)/ruby/internal/special_consts.h
type.o: $(hdrdir)/ruby/internal/static_assert.h
type.o: $(hdrdir)/ruby/internal/stdalign.h
type.o: $(hdrdir)/ruby/internal/stdbool.h
+type.o: $(hdrdir)/ruby/internal/stdckdint.h
type.o: $(hdrdir)/ruby/internal/symbol.h
type.o: $(hdrdir)/ruby/internal/value.h
type.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/thread/id/depend b/ext/-test-/thread/id/depend
new file mode 100644
index 0000000000..6b76b31ddc
--- /dev/null
+++ b/ext/-test-/thread/id/depend
@@ -0,0 +1,163 @@
+# AUTOGENERATED DEPENDENCIES START
+id.o: $(RUBY_EXTCONF_H)
+id.o: $(arch_hdrdir)/ruby/config.h
+id.o: $(hdrdir)/ruby.h
+id.o: $(hdrdir)/ruby/assert.h
+id.o: $(hdrdir)/ruby/backward.h
+id.o: $(hdrdir)/ruby/backward/2/assume.h
+id.o: $(hdrdir)/ruby/backward/2/attributes.h
+id.o: $(hdrdir)/ruby/backward/2/bool.h
+id.o: $(hdrdir)/ruby/backward/2/inttypes.h
+id.o: $(hdrdir)/ruby/backward/2/limits.h
+id.o: $(hdrdir)/ruby/backward/2/long_long.h
+id.o: $(hdrdir)/ruby/backward/2/stdalign.h
+id.o: $(hdrdir)/ruby/backward/2/stdarg.h
+id.o: $(hdrdir)/ruby/defines.h
+id.o: $(hdrdir)/ruby/intern.h
+id.o: $(hdrdir)/ruby/internal/abi.h
+id.o: $(hdrdir)/ruby/internal/anyargs.h
+id.o: $(hdrdir)/ruby/internal/arithmetic.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+id.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+id.o: $(hdrdir)/ruby/internal/assume.h
+id.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+id.o: $(hdrdir)/ruby/internal/attr/artificial.h
+id.o: $(hdrdir)/ruby/internal/attr/cold.h
+id.o: $(hdrdir)/ruby/internal/attr/const.h
+id.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+id.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+id.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+id.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+id.o: $(hdrdir)/ruby/internal/attr/error.h
+id.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+id.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+id.o: $(hdrdir)/ruby/internal/attr/format.h
+id.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+id.o: $(hdrdir)/ruby/internal/attr/noalias.h
+id.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+id.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+id.o: $(hdrdir)/ruby/internal/attr/noinline.h
+id.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+id.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+id.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+id.o: $(hdrdir)/ruby/internal/attr/pure.h
+id.o: $(hdrdir)/ruby/internal/attr/restrict.h
+id.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+id.o: $(hdrdir)/ruby/internal/attr/warning.h
+id.o: $(hdrdir)/ruby/internal/attr/weakref.h
+id.o: $(hdrdir)/ruby/internal/cast.h
+id.o: $(hdrdir)/ruby/internal/compiler_is.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+id.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+id.o: $(hdrdir)/ruby/internal/compiler_since.h
+id.o: $(hdrdir)/ruby/internal/config.h
+id.o: $(hdrdir)/ruby/internal/constant_p.h
+id.o: $(hdrdir)/ruby/internal/core.h
+id.o: $(hdrdir)/ruby/internal/core/rarray.h
+id.o: $(hdrdir)/ruby/internal/core/rbasic.h
+id.o: $(hdrdir)/ruby/internal/core/rbignum.h
+id.o: $(hdrdir)/ruby/internal/core/rclass.h
+id.o: $(hdrdir)/ruby/internal/core/rdata.h
+id.o: $(hdrdir)/ruby/internal/core/rfile.h
+id.o: $(hdrdir)/ruby/internal/core/rhash.h
+id.o: $(hdrdir)/ruby/internal/core/robject.h
+id.o: $(hdrdir)/ruby/internal/core/rregexp.h
+id.o: $(hdrdir)/ruby/internal/core/rstring.h
+id.o: $(hdrdir)/ruby/internal/core/rstruct.h
+id.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+id.o: $(hdrdir)/ruby/internal/ctype.h
+id.o: $(hdrdir)/ruby/internal/dllexport.h
+id.o: $(hdrdir)/ruby/internal/dosish.h
+id.o: $(hdrdir)/ruby/internal/error.h
+id.o: $(hdrdir)/ruby/internal/eval.h
+id.o: $(hdrdir)/ruby/internal/event.h
+id.o: $(hdrdir)/ruby/internal/fl_type.h
+id.o: $(hdrdir)/ruby/internal/gc.h
+id.o: $(hdrdir)/ruby/internal/glob.h
+id.o: $(hdrdir)/ruby/internal/globals.h
+id.o: $(hdrdir)/ruby/internal/has/attribute.h
+id.o: $(hdrdir)/ruby/internal/has/builtin.h
+id.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+id.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+id.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+id.o: $(hdrdir)/ruby/internal/has/extension.h
+id.o: $(hdrdir)/ruby/internal/has/feature.h
+id.o: $(hdrdir)/ruby/internal/has/warning.h
+id.o: $(hdrdir)/ruby/internal/intern/array.h
+id.o: $(hdrdir)/ruby/internal/intern/bignum.h
+id.o: $(hdrdir)/ruby/internal/intern/class.h
+id.o: $(hdrdir)/ruby/internal/intern/compar.h
+id.o: $(hdrdir)/ruby/internal/intern/complex.h
+id.o: $(hdrdir)/ruby/internal/intern/cont.h
+id.o: $(hdrdir)/ruby/internal/intern/dir.h
+id.o: $(hdrdir)/ruby/internal/intern/enum.h
+id.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+id.o: $(hdrdir)/ruby/internal/intern/error.h
+id.o: $(hdrdir)/ruby/internal/intern/eval.h
+id.o: $(hdrdir)/ruby/internal/intern/file.h
+id.o: $(hdrdir)/ruby/internal/intern/hash.h
+id.o: $(hdrdir)/ruby/internal/intern/io.h
+id.o: $(hdrdir)/ruby/internal/intern/load.h
+id.o: $(hdrdir)/ruby/internal/intern/marshal.h
+id.o: $(hdrdir)/ruby/internal/intern/numeric.h
+id.o: $(hdrdir)/ruby/internal/intern/object.h
+id.o: $(hdrdir)/ruby/internal/intern/parse.h
+id.o: $(hdrdir)/ruby/internal/intern/proc.h
+id.o: $(hdrdir)/ruby/internal/intern/process.h
+id.o: $(hdrdir)/ruby/internal/intern/random.h
+id.o: $(hdrdir)/ruby/internal/intern/range.h
+id.o: $(hdrdir)/ruby/internal/intern/rational.h
+id.o: $(hdrdir)/ruby/internal/intern/re.h
+id.o: $(hdrdir)/ruby/internal/intern/ruby.h
+id.o: $(hdrdir)/ruby/internal/intern/select.h
+id.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+id.o: $(hdrdir)/ruby/internal/intern/set.h
+id.o: $(hdrdir)/ruby/internal/intern/signal.h
+id.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+id.o: $(hdrdir)/ruby/internal/intern/string.h
+id.o: $(hdrdir)/ruby/internal/intern/struct.h
+id.o: $(hdrdir)/ruby/internal/intern/thread.h
+id.o: $(hdrdir)/ruby/internal/intern/time.h
+id.o: $(hdrdir)/ruby/internal/intern/variable.h
+id.o: $(hdrdir)/ruby/internal/intern/vm.h
+id.o: $(hdrdir)/ruby/internal/interpreter.h
+id.o: $(hdrdir)/ruby/internal/iterator.h
+id.o: $(hdrdir)/ruby/internal/memory.h
+id.o: $(hdrdir)/ruby/internal/method.h
+id.o: $(hdrdir)/ruby/internal/module.h
+id.o: $(hdrdir)/ruby/internal/newobj.h
+id.o: $(hdrdir)/ruby/internal/scan_args.h
+id.o: $(hdrdir)/ruby/internal/special_consts.h
+id.o: $(hdrdir)/ruby/internal/static_assert.h
+id.o: $(hdrdir)/ruby/internal/stdalign.h
+id.o: $(hdrdir)/ruby/internal/stdbool.h
+id.o: $(hdrdir)/ruby/internal/stdckdint.h
+id.o: $(hdrdir)/ruby/internal/symbol.h
+id.o: $(hdrdir)/ruby/internal/value.h
+id.o: $(hdrdir)/ruby/internal/value_type.h
+id.o: $(hdrdir)/ruby/internal/variable.h
+id.o: $(hdrdir)/ruby/internal/warning_push.h
+id.o: $(hdrdir)/ruby/internal/xmalloc.h
+id.o: $(hdrdir)/ruby/missing.h
+id.o: $(hdrdir)/ruby/ruby.h
+id.o: $(hdrdir)/ruby/st.h
+id.o: $(hdrdir)/ruby/subst.h
+id.o: id.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/thread/id/extconf.rb b/ext/-test-/thread/id/extconf.rb
new file mode 100644
index 0000000000..a0ae0eff15
--- /dev/null
+++ b/ext/-test-/thread/id/extconf.rb
@@ -0,0 +1,3 @@
+if have_func("gettid")
+ create_makefile("-test-/thread/id")
+end
diff --git a/ext/-test-/thread/id/id.c b/ext/-test-/thread/id/id.c
new file mode 100644
index 0000000000..b46a5955e2
--- /dev/null
+++ b/ext/-test-/thread/id/id.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+
+static VALUE
+bug_gettid(VALUE self)
+{
+ pid_t tid = gettid();
+ return PIDT2NUM(tid);
+}
+
+void
+Init_id(void)
+{
+ VALUE klass = rb_define_module_under(rb_define_module("Bug"), "ThreadID");
+ rb_define_module_function(klass, "gettid", bug_gettid, 0);
+}
diff --git a/ext/-test-/thread/instrumentation/depend b/ext/-test-/thread/instrumentation/depend
index b03f51870f..63e1c7e44f 100644
--- a/ext/-test-/thread/instrumentation/depend
+++ b/ext/-test-/thread/instrumentation/depend
@@ -128,6 +128,7 @@ instrumentation.o: $(hdrdir)/ruby/internal/intern/re.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/ruby.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/select.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+instrumentation.o: $(hdrdir)/ruby/internal/intern/set.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/signal.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/sprintf.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ instrumentation.o: $(hdrdir)/ruby/internal/special_consts.h
instrumentation.o: $(hdrdir)/ruby/internal/static_assert.h
instrumentation.o: $(hdrdir)/ruby/internal/stdalign.h
instrumentation.o: $(hdrdir)/ruby/internal/stdbool.h
+instrumentation.o: $(hdrdir)/ruby/internal/stdckdint.h
instrumentation.o: $(hdrdir)/ruby/internal/symbol.h
instrumentation.o: $(hdrdir)/ruby/internal/value.h
instrumentation.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/thread/instrumentation/instrumentation.c b/ext/-test-/thread/instrumentation/instrumentation.c
index d2a2c2740b..25e2902a78 100644
--- a/ext/-test-/thread/instrumentation/instrumentation.c
+++ b/ext/-test-/thread/instrumentation/instrumentation.c
@@ -2,90 +2,136 @@
#include "ruby/atomic.h"
#include "ruby/thread.h"
-static rb_atomic_t started_count = 0;
-static rb_atomic_t ready_count = 0;
-static rb_atomic_t resumed_count = 0;
-static rb_atomic_t suspended_count = 0;
-static rb_atomic_t exited_count = 0;
-
-#if __STDC_VERSION__ >= 201112
- #define RB_THREAD_LOCAL_SPECIFIER _Thread_local
-#elif defined(__GNUC__) && !defined(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)
- /* note that ICC (linux) and Clang are covered by __GNUC__ */
- #define RB_THREAD_LOCAL_SPECIFIER __thread
-#else
- #define RB_THREAD_LOCAL_SPECIFIER
+#ifndef RB_THREAD_LOCAL_SPECIFIER
+# define RB_THREAD_LOCAL_SPECIFIER
#endif
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_ready_count = 0;
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_resumed_count = 0;
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_suspended_count = 0;
+static VALUE timeline_value = Qnil;
+
+struct thread_event {
+ VALUE thread;
+ rb_event_flag_t event;
+};
+
+#define MAX_EVENTS 1024
+static struct thread_event event_timeline[MAX_EVENTS];
+static rb_atomic_t timeline_cursor;
static void
-ex_callback(rb_event_flag_t event, const rb_internal_thread_event_data_t *event_data, void *user_data)
+event_timeline_gc_mark(void *ptr) {
+ rb_atomic_t cursor;
+ for (cursor = 0; cursor < timeline_cursor; cursor++) {
+ rb_gc_mark(event_timeline[cursor].thread);
+ }
+}
+
+static const rb_data_type_t event_timeline_type = {
+ "TestThreadInstrumentation/event_timeline",
+ {event_timeline_gc_mark, NULL, NULL,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+reset_timeline(void)
+{
+ timeline_cursor = 0;
+ memset(event_timeline, 0, sizeof(struct thread_event) * MAX_EVENTS);
+}
+
+static rb_event_flag_t
+find_last_event(VALUE thread)
+{
+ rb_atomic_t cursor = timeline_cursor;
+ if (cursor) {
+ do {
+ if (event_timeline[cursor].thread == thread){
+ return event_timeline[cursor].event;
+ }
+ cursor--;
+ } while (cursor > 0);
+ }
+ return 0;
+}
+
+static const char *
+event_name(rb_event_flag_t event)
{
switch (event) {
case RUBY_INTERNAL_THREAD_EVENT_STARTED:
- RUBY_ATOMIC_INC(started_count);
- break;
+ return "started";
case RUBY_INTERNAL_THREAD_EVENT_READY:
- RUBY_ATOMIC_INC(ready_count);
- local_ready_count++;
- break;
+ return "ready";
case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
- RUBY_ATOMIC_INC(resumed_count);
- local_resumed_count++;
- break;
+ return "resumed";
case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
- RUBY_ATOMIC_INC(suspended_count);
- local_suspended_count++;
- break;
+ return "suspended";
case RUBY_INTERNAL_THREAD_EVENT_EXITED:
- RUBY_ATOMIC_INC(exited_count);
- break;
+ return "exited";
}
+ return "no-event";
}
-static rb_internal_thread_event_hook_t * single_hook = NULL;
-
-static VALUE
-thread_counters(VALUE thread)
+static void
+unexpected(bool strict, const char *format, VALUE thread, rb_event_flag_t last_event)
{
- VALUE array = rb_ary_new2(5);
- rb_ary_push(array, UINT2NUM(started_count));
- rb_ary_push(array, UINT2NUM(ready_count));
- rb_ary_push(array, UINT2NUM(resumed_count));
- rb_ary_push(array, UINT2NUM(suspended_count));
- rb_ary_push(array, UINT2NUM(exited_count));
- return array;
+ const char *last_event_name = event_name(last_event);
+ if (strict) {
+ rb_bug(format, thread, last_event_name);
+ }
+ else {
+ fprintf(stderr, format, thread, last_event_name);
+ fprintf(stderr, "\n");
+ }
}
-static VALUE
-thread_local_counters(VALUE thread)
+static void
+ex_callback(rb_event_flag_t event, const rb_internal_thread_event_data_t *event_data, void *user_data)
{
- VALUE array = rb_ary_new2(3);
- rb_ary_push(array, UINT2NUM(local_ready_count));
- rb_ary_push(array, UINT2NUM(local_resumed_count));
- rb_ary_push(array, UINT2NUM(local_suspended_count));
- return array;
-}
+ rb_event_flag_t last_event = find_last_event(event_data->thread);
+ bool strict = (bool)user_data;
-static VALUE
-thread_reset_counters(VALUE thread)
-{
- RUBY_ATOMIC_SET(started_count, 0);
- RUBY_ATOMIC_SET(ready_count, 0);
- RUBY_ATOMIC_SET(resumed_count, 0);
- RUBY_ATOMIC_SET(suspended_count, 0);
- RUBY_ATOMIC_SET(exited_count, 0);
- local_ready_count = 0;
- local_resumed_count = 0;
- local_suspended_count = 0;
- return Qtrue;
+ if (last_event != 0) {
+ switch (event) {
+ case RUBY_INTERNAL_THREAD_EVENT_STARTED:
+ unexpected(strict, "[thread=%"PRIxVALUE"] `started` event can't be preceded by `%s`", event_data->thread, last_event);
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_READY:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_STARTED && last_event != RUBY_INTERNAL_THREAD_EVENT_SUSPENDED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `ready` must be preceded by `started` or `suspended`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_READY) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `resumed` must be preceded by `ready`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_RESUMED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `suspended` must be preceded by `resumed`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_EXITED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_RESUMED && last_event != RUBY_INTERNAL_THREAD_EVENT_SUSPENDED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `exited` must be preceded by `resumed` or `suspended`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ }
+ }
+
+ rb_atomic_t cursor = RUBY_ATOMIC_FETCH_ADD(timeline_cursor, 1);
+ if (cursor >= MAX_EVENTS) {
+ rb_bug("TestThreadInstrumentation: ran out of event_timeline space");
+ }
+
+ event_timeline[cursor].thread = event_data->thread;
+ event_timeline[cursor].event = event;
}
+static rb_internal_thread_event_hook_t * single_hook = NULL;
+
static VALUE
-thread_register_callback(VALUE thread)
+thread_register_callback(VALUE thread, VALUE strict)
{
single_hook = rb_internal_thread_add_event_hook(
ex_callback,
@@ -94,13 +140,33 @@ thread_register_callback(VALUE thread)
RUBY_INTERNAL_THREAD_EVENT_RESUMED |
RUBY_INTERNAL_THREAD_EVENT_SUSPENDED |
RUBY_INTERNAL_THREAD_EVENT_EXITED,
- NULL
+ (void *)RTEST(strict)
);
return Qnil;
}
static VALUE
+event_symbol(rb_event_flag_t event)
+{
+ switch (event) {
+ case RUBY_INTERNAL_THREAD_EVENT_STARTED:
+ return rb_id2sym(rb_intern("started"));
+ case RUBY_INTERNAL_THREAD_EVENT_READY:
+ return rb_id2sym(rb_intern("ready"));
+ case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
+ return rb_id2sym(rb_intern("resumed"));
+ case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
+ return rb_id2sym(rb_intern("suspended"));
+ case RUBY_INTERNAL_THREAD_EVENT_EXITED:
+ return rb_id2sym(rb_intern("exited"));
+ default:
+ rb_bug("TestThreadInstrumentation: Unexpected event");
+ break;
+ }
+}
+
+static VALUE
thread_unregister_callback(VALUE thread)
{
if (single_hook) {
@@ -108,7 +174,18 @@ thread_unregister_callback(VALUE thread)
single_hook = NULL;
}
- return Qnil;
+ VALUE events = rb_ary_new_capa(timeline_cursor);
+ rb_atomic_t cursor;
+ for (cursor = 0; cursor < timeline_cursor; cursor++) {
+ VALUE pair = rb_ary_new_capa(2);
+ rb_ary_push(pair, event_timeline[cursor].thread);
+ rb_ary_push(pair, event_symbol(event_timeline[cursor].event));
+ rb_ary_push(events, pair);
+ }
+
+ reset_timeline();
+
+ return events;
}
static VALUE
@@ -132,10 +209,10 @@ Init_instrumentation(void)
{
VALUE mBug = rb_define_module("Bug");
VALUE klass = rb_define_module_under(mBug, "ThreadInstrumentation");
- rb_define_singleton_method(klass, "counters", thread_counters, 0);
- rb_define_singleton_method(klass, "local_counters", thread_local_counters, 0);
- rb_define_singleton_method(klass, "reset_counters", thread_reset_counters, 0);
- rb_define_singleton_method(klass, "register_callback", thread_register_callback, 0);
+ rb_global_variable(&timeline_value);
+ timeline_value = TypedData_Wrap_Struct(0, &event_timeline_type, (void *)1);
+
+ rb_define_singleton_method(klass, "register_callback", thread_register_callback, 1);
rb_define_singleton_method(klass, "unregister_callback", thread_unregister_callback, 0);
rb_define_singleton_method(klass, "register_and_unregister_callbacks", thread_register_and_unregister_callback, 0);
}
diff --git a/ext/-test-/thread/lock_native_thread/depend b/ext/-test-/thread/lock_native_thread/depend
new file mode 100644
index 0000000000..a32843e531
--- /dev/null
+++ b/ext/-test-/thread/lock_native_thread/depend
@@ -0,0 +1,163 @@
+# AUTOGENERATED DEPENDENCIES START
+lock_native_thread.o: $(RUBY_EXTCONF_H)
+lock_native_thread.o: $(arch_hdrdir)/ruby/config.h
+lock_native_thread.o: $(hdrdir)/ruby/assert.h
+lock_native_thread.o: $(hdrdir)/ruby/backward.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/assume.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/attributes.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/bool.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/inttypes.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/limits.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/long_long.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/stdalign.h
+lock_native_thread.o: $(hdrdir)/ruby/backward/2/stdarg.h
+lock_native_thread.o: $(hdrdir)/ruby/defines.h
+lock_native_thread.o: $(hdrdir)/ruby/intern.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/abi.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/anyargs.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/assume.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/artificial.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/cold.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/const.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/error.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/format.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/noalias.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/noinline.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/pure.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/restrict.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/warning.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/attr/weakref.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/cast.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/compiler_since.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/config.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/constant_p.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rarray.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rbasic.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rbignum.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rclass.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rdata.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rfile.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rhash.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/robject.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rregexp.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rstring.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rstruct.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/ctype.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/dllexport.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/dosish.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/error.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/eval.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/event.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/fl_type.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/gc.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/glob.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/globals.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/attribute.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/builtin.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/extension.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/feature.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/has/warning.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/array.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/bignum.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/class.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/compar.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/complex.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/cont.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/dir.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/enum.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/error.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/eval.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/file.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/hash.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/io.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/load.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/marshal.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/numeric.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/object.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/parse.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/proc.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/process.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/random.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/range.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/rational.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/re.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/ruby.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/select.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/set.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/signal.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/string.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/struct.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/thread.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/time.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/variable.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/intern/vm.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/interpreter.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/iterator.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/memory.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/method.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/module.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/newobj.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/scan_args.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/special_consts.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/static_assert.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/stdalign.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/stdbool.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/stdckdint.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/symbol.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/value.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/value_type.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/variable.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/warning_push.h
+lock_native_thread.o: $(hdrdir)/ruby/internal/xmalloc.h
+lock_native_thread.o: $(hdrdir)/ruby/missing.h
+lock_native_thread.o: $(hdrdir)/ruby/ruby.h
+lock_native_thread.o: $(hdrdir)/ruby/st.h
+lock_native_thread.o: $(hdrdir)/ruby/subst.h
+lock_native_thread.o: $(hdrdir)/ruby/thread.h
+lock_native_thread.o: lock_native_thread.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/thread/lock_native_thread/extconf.rb b/ext/-test-/thread/lock_native_thread/extconf.rb
new file mode 100644
index 0000000000..832bfde01a
--- /dev/null
+++ b/ext/-test-/thread/lock_native_thread/extconf.rb
@@ -0,0 +1,2 @@
+# frozen_string_literal: false
+create_makefile("-test-/thread/lock_native_thread")
diff --git a/ext/-test-/thread/lock_native_thread/lock_native_thread.c b/ext/-test-/thread/lock_native_thread/lock_native_thread.c
new file mode 100644
index 0000000000..2eb75809a9
--- /dev/null
+++ b/ext/-test-/thread/lock_native_thread/lock_native_thread.c
@@ -0,0 +1,50 @@
+
+#include "ruby/ruby.h"
+#include "ruby/thread.h"
+
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+
+static pthread_key_t tls_key;
+
+static VALUE
+get_tls(VALUE self)
+{
+ return (VALUE)pthread_getspecific(tls_key);
+}
+
+static VALUE
+set_tls(VALUE self, VALUE vn)
+{
+ pthread_setspecific(tls_key, (void *)vn);
+ return Qnil;
+}
+
+static VALUE
+lock_native_thread(VALUE self)
+{
+ return rb_thread_lock_native_thread() ? Qtrue : Qfalse;
+}
+
+void
+Init_lock_native_thread(void)
+{
+ int r;
+
+ if ((r = pthread_key_create(&tls_key, NULL)) != 0) {
+ rb_bug("pthread_key_create() returns %d", r);
+ }
+ pthread_setspecific(tls_key, NULL);
+
+ rb_define_method(rb_cThread, "lock_native_thread", lock_native_thread, 0);
+ rb_define_method(rb_cThread, "get_tls", get_tls, 0);
+ rb_define_method(rb_cThread, "set_tls", set_tls, 1);
+}
+
+#else // HAVE_PTHREAD_H
+void
+Init_lock_native_thread(void)
+{
+ // do nothing
+}
+#endif // HAVE_PTHREAD_H
diff --git a/ext/-test-/thread_fd/depend b/ext/-test-/thread_fd/depend
deleted file mode 100644
index d4cc772526..0000000000
--- a/ext/-test-/thread_fd/depend
+++ /dev/null
@@ -1,160 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-thread_fd.o: $(RUBY_EXTCONF_H)
-thread_fd.o: $(arch_hdrdir)/ruby/config.h
-thread_fd.o: $(hdrdir)/ruby/assert.h
-thread_fd.o: $(hdrdir)/ruby/backward.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/assume.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/attributes.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/bool.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/inttypes.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/limits.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/long_long.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/stdalign.h
-thread_fd.o: $(hdrdir)/ruby/backward/2/stdarg.h
-thread_fd.o: $(hdrdir)/ruby/defines.h
-thread_fd.o: $(hdrdir)/ruby/intern.h
-thread_fd.o: $(hdrdir)/ruby/internal/abi.h
-thread_fd.o: $(hdrdir)/ruby/internal/anyargs.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-thread_fd.o: $(hdrdir)/ruby/internal/assume.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/artificial.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/cold.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/const.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/error.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/format.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/noalias.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/noinline.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/pure.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/restrict.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/warning.h
-thread_fd.o: $(hdrdir)/ruby/internal/attr/weakref.h
-thread_fd.o: $(hdrdir)/ruby/internal/cast.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-thread_fd.o: $(hdrdir)/ruby/internal/compiler_since.h
-thread_fd.o: $(hdrdir)/ruby/internal/config.h
-thread_fd.o: $(hdrdir)/ruby/internal/constant_p.h
-thread_fd.o: $(hdrdir)/ruby/internal/core.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rarray.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rbasic.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rbignum.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rclass.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rdata.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rfile.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rhash.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/robject.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rregexp.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rstring.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rstruct.h
-thread_fd.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-thread_fd.o: $(hdrdir)/ruby/internal/ctype.h
-thread_fd.o: $(hdrdir)/ruby/internal/dllexport.h
-thread_fd.o: $(hdrdir)/ruby/internal/dosish.h
-thread_fd.o: $(hdrdir)/ruby/internal/error.h
-thread_fd.o: $(hdrdir)/ruby/internal/eval.h
-thread_fd.o: $(hdrdir)/ruby/internal/event.h
-thread_fd.o: $(hdrdir)/ruby/internal/fl_type.h
-thread_fd.o: $(hdrdir)/ruby/internal/gc.h
-thread_fd.o: $(hdrdir)/ruby/internal/glob.h
-thread_fd.o: $(hdrdir)/ruby/internal/globals.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/attribute.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/builtin.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/extension.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/feature.h
-thread_fd.o: $(hdrdir)/ruby/internal/has/warning.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/array.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/bignum.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/class.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/compar.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/complex.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/cont.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/dir.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/enum.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/error.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/eval.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/file.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/hash.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/io.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/load.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/marshal.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/numeric.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/object.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/parse.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/proc.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/process.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/random.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/range.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/rational.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/re.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/ruby.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/select.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/signal.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/string.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/struct.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/thread.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/time.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/variable.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/vm.h
-thread_fd.o: $(hdrdir)/ruby/internal/interpreter.h
-thread_fd.o: $(hdrdir)/ruby/internal/iterator.h
-thread_fd.o: $(hdrdir)/ruby/internal/memory.h
-thread_fd.o: $(hdrdir)/ruby/internal/method.h
-thread_fd.o: $(hdrdir)/ruby/internal/module.h
-thread_fd.o: $(hdrdir)/ruby/internal/newobj.h
-thread_fd.o: $(hdrdir)/ruby/internal/scan_args.h
-thread_fd.o: $(hdrdir)/ruby/internal/special_consts.h
-thread_fd.o: $(hdrdir)/ruby/internal/static_assert.h
-thread_fd.o: $(hdrdir)/ruby/internal/stdalign.h
-thread_fd.o: $(hdrdir)/ruby/internal/stdbool.h
-thread_fd.o: $(hdrdir)/ruby/internal/symbol.h
-thread_fd.o: $(hdrdir)/ruby/internal/value.h
-thread_fd.o: $(hdrdir)/ruby/internal/value_type.h
-thread_fd.o: $(hdrdir)/ruby/internal/variable.h
-thread_fd.o: $(hdrdir)/ruby/internal/warning_push.h
-thread_fd.o: $(hdrdir)/ruby/internal/xmalloc.h
-thread_fd.o: $(hdrdir)/ruby/missing.h
-thread_fd.o: $(hdrdir)/ruby/ruby.h
-thread_fd.o: $(hdrdir)/ruby/st.h
-thread_fd.o: $(hdrdir)/ruby/subst.h
-thread_fd.o: thread_fd.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/-test-/thread_fd/extconf.rb b/ext/-test-/thread_fd/extconf.rb
deleted file mode 100644
index a8bbe9d169..0000000000
--- a/ext/-test-/thread_fd/extconf.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# frozen_string_literal: true
-create_makefile('-test-/thread_fd')
diff --git a/ext/-test-/thread_fd/thread_fd.c b/ext/-test-/thread_fd/thread_fd.c
deleted file mode 100644
index 042b799dc8..0000000000
--- a/ext/-test-/thread_fd/thread_fd.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "ruby/ruby.h"
-
-static VALUE
-thread_fd_close(VALUE ign, VALUE fd)
-{
- rb_thread_fd_close(NUM2INT(fd));
- return Qnil;
-}
-
-static VALUE
-thread_fd_wait(VALUE ign, VALUE fd)
-{
- int ret = rb_thread_wait_fd(NUM2INT(fd));
- return INT2NUM(ret);
-}
-
-static VALUE
-thread_fd_writable(VALUE ign, VALUE fd)
-{
- int ret = rb_thread_fd_writable(NUM2INT(fd));
- return INT2NUM(ret);
-}
-
-void
-Init_thread_fd(void)
-{
- rb_define_singleton_method(rb_cIO, "thread_fd_close", thread_fd_close, 1);
- rb_define_singleton_method(rb_cIO, "thread_fd_wait", thread_fd_wait, 1);
- rb_define_singleton_method(rb_cIO, "thread_fd_writable", thread_fd_writable, 1);
-}
diff --git a/ext/-test-/time/depend b/ext/-test-/time/depend
index c015588b09..e5b05f3113 100644
--- a/ext/-test-/time/depend
+++ b/ext/-test-/time/depend
@@ -128,6 +128,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -288,6 +290,7 @@ leap_second.o: $(hdrdir)/ruby/internal/intern/re.h
leap_second.o: $(hdrdir)/ruby/internal/intern/ruby.h
leap_second.o: $(hdrdir)/ruby/internal/intern/select.h
leap_second.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+leap_second.o: $(hdrdir)/ruby/internal/intern/set.h
leap_second.o: $(hdrdir)/ruby/internal/intern/signal.h
leap_second.o: $(hdrdir)/ruby/internal/intern/sprintf.h
leap_second.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -307,6 +310,7 @@ leap_second.o: $(hdrdir)/ruby/internal/special_consts.h
leap_second.o: $(hdrdir)/ruby/internal/static_assert.h
leap_second.o: $(hdrdir)/ruby/internal/stdalign.h
leap_second.o: $(hdrdir)/ruby/internal/stdbool.h
+leap_second.o: $(hdrdir)/ruby/internal/stdckdint.h
leap_second.o: $(hdrdir)/ruby/internal/symbol.h
leap_second.o: $(hdrdir)/ruby/internal/value.h
leap_second.o: $(hdrdir)/ruby/internal/value_type.h
@@ -451,6 +455,7 @@ new.o: $(hdrdir)/ruby/internal/intern/re.h
new.o: $(hdrdir)/ruby/internal/intern/ruby.h
new.o: $(hdrdir)/ruby/internal/intern/select.h
new.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+new.o: $(hdrdir)/ruby/internal/intern/set.h
new.o: $(hdrdir)/ruby/internal/intern/signal.h
new.o: $(hdrdir)/ruby/internal/intern/sprintf.h
new.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -470,6 +475,7 @@ new.o: $(hdrdir)/ruby/internal/special_consts.h
new.o: $(hdrdir)/ruby/internal/static_assert.h
new.o: $(hdrdir)/ruby/internal/stdalign.h
new.o: $(hdrdir)/ruby/internal/stdbool.h
+new.o: $(hdrdir)/ruby/internal/stdckdint.h
new.o: $(hdrdir)/ruby/internal/symbol.h
new.o: $(hdrdir)/ruby/internal/value.h
new.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/time/leap_second.c b/ext/-test-/time/leap_second.c
deleted file mode 100644
index ee7011fa97..0000000000
--- a/ext/-test-/time/leap_second.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "ruby.h"
-#include "internal/time.h"
-
-static VALUE
-bug_time_s_reset_leap_second_info(VALUE klass)
-{
- ruby_reset_leap_second_info();
- return Qnil;
-}
-
-void
-Init_time_leap_second(VALUE klass)
-{
- rb_define_singleton_method(klass, "reset_leap_second_info", bug_time_s_reset_leap_second_info, 0);
-}
diff --git a/ext/-test-/tracepoint/depend b/ext/-test-/tracepoint/depend
index 396004926e..014ba83b16 100644
--- a/ext/-test-/tracepoint/depend
+++ b/ext/-test-/tracepoint/depend
@@ -128,6 +128,7 @@ gc_hook.o: $(hdrdir)/ruby/internal/intern/re.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/ruby.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/select.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+gc_hook.o: $(hdrdir)/ruby/internal/intern/set.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/signal.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/sprintf.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ gc_hook.o: $(hdrdir)/ruby/internal/special_consts.h
gc_hook.o: $(hdrdir)/ruby/internal/static_assert.h
gc_hook.o: $(hdrdir)/ruby/internal/stdalign.h
gc_hook.o: $(hdrdir)/ruby/internal/stdbool.h
+gc_hook.o: $(hdrdir)/ruby/internal/stdckdint.h
gc_hook.o: $(hdrdir)/ruby/internal/symbol.h
gc_hook.o: $(hdrdir)/ruby/internal/value.h
gc_hook.o: $(hdrdir)/ruby/internal/value_type.h
@@ -287,6 +289,7 @@ tracepoint.o: $(hdrdir)/ruby/internal/intern/re.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/ruby.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/select.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+tracepoint.o: $(hdrdir)/ruby/internal/intern/set.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/signal.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/sprintf.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -306,6 +309,7 @@ tracepoint.o: $(hdrdir)/ruby/internal/special_consts.h
tracepoint.o: $(hdrdir)/ruby/internal/static_assert.h
tracepoint.o: $(hdrdir)/ruby/internal/stdalign.h
tracepoint.o: $(hdrdir)/ruby/internal/stdbool.h
+tracepoint.o: $(hdrdir)/ruby/internal/stdckdint.h
tracepoint.o: $(hdrdir)/ruby/internal/symbol.h
tracepoint.o: $(hdrdir)/ruby/internal/value.h
tracepoint.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/tracepoint/gc_hook.c b/ext/-test-/tracepoint/gc_hook.c
index a3f4e7f68a..525be6da63 100644
--- a/ext/-test-/tracepoint/gc_hook.c
+++ b/ext/-test-/tracepoint/gc_hook.c
@@ -2,6 +2,7 @@
#include "ruby/debug.h"
static int invoking; /* TODO: should not be global variable */
+extern VALUE tp_mBug;
static VALUE
invoke_proc_ensure(VALUE _)
@@ -17,9 +18,9 @@ invoke_proc_begin(VALUE proc)
}
static void
-invoke_proc(void *data)
+invoke_proc(void *ivar_name)
{
- VALUE proc = (VALUE)data;
+ VALUE proc = rb_ivar_get(tp_mBug, rb_intern(ivar_name));
invoking += 1;
rb_ensure(invoke_proc_begin, proc, invoke_proc_ensure, 0);
}
@@ -33,21 +34,23 @@ gc_start_end_i(VALUE tpval, void *data)
}
if (invoking == 0) {
- rb_postponed_job_register(0, invoke_proc, data);
+ /* will overwrite the existing handle with new data on the second and subsequent call */
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, invoke_proc, data);
+ rb_postponed_job_trigger(h);
}
}
static VALUE
-set_gc_hook(VALUE module, VALUE proc, rb_event_flag_t event, const char *tp_str, const char *proc_str)
+set_gc_hook(VALUE proc, rb_event_flag_t event, const char *tp_str, const char *proc_str)
{
VALUE tpval;
ID tp_key = rb_intern(tp_str);
/* disable previous keys */
- if (rb_ivar_defined(module, tp_key) != 0 &&
- RTEST(tpval = rb_ivar_get(module, tp_key))) {
+ if (rb_ivar_defined(tp_mBug, tp_key) != 0 &&
+ RTEST(tpval = rb_ivar_get(tp_mBug, tp_key))) {
rb_tracepoint_disable(tpval);
- rb_ivar_set(module, tp_key, Qnil);
+ rb_ivar_set(tp_mBug, tp_key, Qnil);
}
if (RTEST(proc)) {
@@ -55,8 +58,9 @@ set_gc_hook(VALUE module, VALUE proc, rb_event_flag_t event, const char *tp_str,
rb_raise(rb_eTypeError, "trace_func needs to be Proc");
}
- tpval = rb_tracepoint_new(0, event, gc_start_end_i, (void *)proc);
- rb_ivar_set(module, tp_key, tpval);
+ rb_ivar_set(tp_mBug, rb_intern(proc_str), proc);
+ tpval = rb_tracepoint_new(0, event, gc_start_end_i, (void *)proc_str);
+ rb_ivar_set(tp_mBug, tp_key, tpval);
rb_tracepoint_enable(tpval);
}
@@ -64,16 +68,16 @@ set_gc_hook(VALUE module, VALUE proc, rb_event_flag_t event, const char *tp_str,
}
static VALUE
-set_after_gc_start(VALUE module, VALUE proc)
+set_after_gc_start(VALUE _self, VALUE proc)
{
- return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_START,
+ return set_gc_hook(proc, RUBY_INTERNAL_EVENT_GC_START,
"__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
}
static VALUE
-start_after_gc_exit(VALUE module, VALUE proc)
+start_after_gc_exit(VALUE _self, VALUE proc)
{
- return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_EXIT,
+ return set_gc_hook(proc, RUBY_INTERNAL_EVENT_GC_EXIT,
"__set_after_gc_exit_tpval__", "__set_after_gc_exit_proc__");
}
diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c
index 2826cc038c..001d9513b2 100644
--- a/ext/-test-/tracepoint/tracepoint.c
+++ b/ext/-test-/tracepoint/tracepoint.c
@@ -1,6 +1,8 @@
#include "ruby/ruby.h"
#include "ruby/debug.h"
+VALUE tp_mBug;
+
struct tracepoint_track {
size_t newobj_count;
size_t free_count;
@@ -89,8 +91,8 @@ void Init_gc_hook(VALUE);
void
Init_tracepoint(void)
{
- VALUE mBug = rb_define_module("Bug");
- Init_gc_hook(mBug);
- rb_define_module_function(mBug, "tracepoint_track_objspace_events", tracepoint_track_objspace_events, 0);
- rb_define_module_function(mBug, "tracepoint_specify_normal_and_internal_events", tracepoint_specify_normal_and_internal_events, 0);
+ tp_mBug = rb_define_module("Bug"); // GC root
+ Init_gc_hook(tp_mBug);
+ rb_define_module_function(tp_mBug, "tracepoint_track_objspace_events", tracepoint_track_objspace_events, 0);
+ rb_define_module_function(tp_mBug, "tracepoint_specify_normal_and_internal_events", tracepoint_specify_normal_and_internal_events, 0);
}
diff --git a/ext/-test-/typeddata/depend b/ext/-test-/typeddata/depend
index cbeafa8000..b9b4915eee 100644
--- a/ext/-test-/typeddata/depend
+++ b/ext/-test-/typeddata/depend
@@ -128,6 +128,7 @@ typeddata.o: $(hdrdir)/ruby/internal/intern/re.h
typeddata.o: $(hdrdir)/ruby/internal/intern/ruby.h
typeddata.o: $(hdrdir)/ruby/internal/intern/select.h
typeddata.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+typeddata.o: $(hdrdir)/ruby/internal/intern/set.h
typeddata.o: $(hdrdir)/ruby/internal/intern/signal.h
typeddata.o: $(hdrdir)/ruby/internal/intern/sprintf.h
typeddata.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ typeddata.o: $(hdrdir)/ruby/internal/special_consts.h
typeddata.o: $(hdrdir)/ruby/internal/static_assert.h
typeddata.o: $(hdrdir)/ruby/internal/stdalign.h
typeddata.o: $(hdrdir)/ruby/internal/stdbool.h
+typeddata.o: $(hdrdir)/ruby/internal/stdckdint.h
typeddata.o: $(hdrdir)/ruby/internal/symbol.h
typeddata.o: $(hdrdir)/ruby/internal/value.h
typeddata.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/vm/depend b/ext/-test-/vm/depend
index f0b3f3b1f4..9313f2ee36 100644
--- a/ext/-test-/vm/depend
+++ b/ext/-test-/vm/depend
@@ -127,6 +127,7 @@ at_exit.o: $(hdrdir)/ruby/internal/intern/re.h
at_exit.o: $(hdrdir)/ruby/internal/intern/ruby.h
at_exit.o: $(hdrdir)/ruby/internal/intern/select.h
at_exit.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+at_exit.o: $(hdrdir)/ruby/internal/intern/set.h
at_exit.o: $(hdrdir)/ruby/internal/intern/signal.h
at_exit.o: $(hdrdir)/ruby/internal/intern/sprintf.h
at_exit.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ at_exit.o: $(hdrdir)/ruby/internal/special_consts.h
at_exit.o: $(hdrdir)/ruby/internal/static_assert.h
at_exit.o: $(hdrdir)/ruby/internal/stdalign.h
at_exit.o: $(hdrdir)/ruby/internal/stdbool.h
+at_exit.o: $(hdrdir)/ruby/internal/stdckdint.h
at_exit.o: $(hdrdir)/ruby/internal/symbol.h
at_exit.o: $(hdrdir)/ruby/internal/value.h
at_exit.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/wait/depend b/ext/-test-/wait/depend
index 2e4887559c..f793d84831 100644
--- a/ext/-test-/wait/depend
+++ b/ext/-test-/wait/depend
@@ -137,6 +137,7 @@ wait.o: $(hdrdir)/ruby/internal/intern/re.h
wait.o: $(hdrdir)/ruby/internal/intern/ruby.h
wait.o: $(hdrdir)/ruby/internal/intern/select.h
wait.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+wait.o: $(hdrdir)/ruby/internal/intern/set.h
wait.o: $(hdrdir)/ruby/internal/intern/signal.h
wait.o: $(hdrdir)/ruby/internal/intern/sprintf.h
wait.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -156,6 +157,7 @@ wait.o: $(hdrdir)/ruby/internal/special_consts.h
wait.o: $(hdrdir)/ruby/internal/static_assert.h
wait.o: $(hdrdir)/ruby/internal/stdalign.h
wait.o: $(hdrdir)/ruby/internal/stdbool.h
+wait.o: $(hdrdir)/ruby/internal/stdckdint.h
wait.o: $(hdrdir)/ruby/internal/symbol.h
wait.o: $(hdrdir)/ruby/internal/value.h
wait.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/-test-/win32/dln/extconf.rb b/ext/-test-/win32/dln/extconf.rb
index d72b6a868c..bea52cfec3 100644
--- a/ext/-test-/win32/dln/extconf.rb
+++ b/ext/-test-/win32/dln/extconf.rb
@@ -7,6 +7,7 @@ if $mingw or $mswin
testdll = "dlntest.dll"
$cleanfiles << testdll
$cleanfiles << "dlntest.#{$LIBEXT}"
+ $cleanfiles << "libdlntest.#{$OBJEXT}"
config_string('cleanobjs') {|t| $cleanfiles.concat(t.gsub(/\$\*/, 'dlntest').split)}
create_makefile("-test-/win32/dln") do |m|
diff --git a/ext/.document b/ext/.document
index f2fa5b5ba2..d75c5c3d35 100644
--- a/ext/.document
+++ b/ext/.document
@@ -1,7 +1,5 @@
# Add files to this as they become documented
-bigdecimal/bigdecimal.c
-bigdecimal/lib
cgi/escape/escape.c
continuation/continuation.c
coverage/coverage.c
@@ -21,25 +19,12 @@ digest/sha2/sha2init.c
digest/sha2/lib
etc/etc.c
fcntl/fcntl.c
-fiddle/closure.c
-fiddle/conversions.c
-fiddle/fiddle.c
-fiddle/function.c
-fiddle/pinned.c
-fiddle/pointer.c
-fiddle/handle.c
-fiddle/lib
-io/console/console.c
-io/console/lib
+io/console/
io/nonblock/nonblock.c
io/wait/wait.c
json/generator/generator.c
json/lib
json/parser/parser.c
-monitor/lib
-monitor/monitor.c
-nkf/lib
-nkf/nkf.c
objspace/objspace.c
objspace/objspace_dump.c
objspace/object_tracing.c
@@ -77,8 +62,6 @@ openssl/ossl_x509name.c
openssl/ossl_x509req.c
openssl/ossl_x509revoked.c
openssl/ossl_x509store.c
-pathname/lib
-pathname/pathname.c
psych/lib
psych/psych.c
psych/psych_emitter.c
@@ -87,17 +70,12 @@ psych/psych_to_ruby.c
psych/psych_yaml_tree.c
pty/lib
pty/pty.c
-racc/cparse/cparse.c
rbconfig/sizeof/*.c
-readline/readline.c
ripper/lib
socket
stringio/stringio.c
+strscan/lib
strscan/strscan.c
-syslog/syslog.c
-syslog/lib
win32/lib
win32/resolv/*.c
-win32ole/lib
-win32ole/*.c
zlib/zlib.c
diff --git a/ext/Setup b/ext/Setup
index 9c3e2f48fe..5cd4e95e27 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -1,39 +1,34 @@
#option nodynamic
-#bigdecimal
#cgi/escape
#continuation
#coverage
#date
-#digest/bubblebabble
#digest
+#digest/bubblebabble
#digest/md5
#digest/rmd160
#digest/sha1
#digest/sha2
+#erb/escape
#etc
#fcntl
-#fiddle
#io/console
#io/nonblock
#io/wait
#json
#json/generator
#json/parser
-#nkf
#objspace
#openssl
-#pathname
#psych
#pty
-#racc/cparse
#rbconfig/sizeof
-#readline
#ripper
+#rubyvm
#socket
#stringio
#strscan
-#syslog
#win32
-#win32ole
+#win32/resolv
#zlib
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
index 6a8b9903af..73c8d5d5a8 100644
--- a/ext/Setup.atheos
+++ b/ext/Setup.atheos
@@ -1,24 +1,23 @@
option nodynamic
-bigdecimal
cgi/escape
-digest
-digest/md5
-digest/rmd160
-digest/sha1
-digest/sha2
+continuation
+coverage
+date
+digest/*
+erb/escape
etc
fcntl
-io/wait
-nkf
+io/*
+json
+json/*
+objspace
#openssl
pty
-racc/cparse
-readline
+rbconfig/sizeof
ripper
socket
stringio
strscan
syslog
-#win32ole
zlib
diff --git a/ext/Setup.nt b/ext/Setup.nt
index 067f153d36..a9e87249d3 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -1,25 +1,23 @@
#option platform cygwin|mingw|mswin
#option nodynamic
-bigdecimal
cgi/escape
-digest
-digest/md5
-digest/rmd160
-digest/sha1
-digest/sha2
+continuation
+coverage
+date
+digest/*
+erb/escape
etc
fcntl
-#io/wait
-nkf
+io/*
+json
+json/*
+objspace
#openssl
-#pty
-racc/cparse
-#readline
+rbconfig/sizeof
#ripper
socket
stringio
strscan
#syslog
-win32ole
#zlib
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
deleted file mode 100644
index 6eb14bcd0e..0000000000
--- a/ext/bigdecimal/bigdecimal.c
+++ /dev/null
@@ -1,7737 +0,0 @@
-/*
- *
- * Ruby BigDecimal(Variable decimal precision) extension library.
- *
- * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
- *
- */
-
-/* #define BIGDECIMAL_DEBUG 1 */
-
-#include "bigdecimal.h"
-#include "ruby/util.h"
-
-#ifndef BIGDECIMAL_DEBUG
-# undef NDEBUG
-# define NDEBUG
-#endif
-#include <assert.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-
-#ifdef HAVE_IEEEFP_H
-#include <ieeefp.h>
-#endif
-
-#include "bits.h"
-#include "static_assert.h"
-
-#define BIGDECIMAL_VERSION "3.1.4"
-
-/* #define ENABLE_NUMERIC_STRING */
-
-#define SIGNED_VALUE_MAX INTPTR_MAX
-#define SIGNED_VALUE_MIN INTPTR_MIN
-#define MUL_OVERFLOW_SIGNED_VALUE_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX)
-
-VALUE rb_cBigDecimal;
-VALUE rb_mBigMath;
-
-static ID id_BigDecimal_exception_mode;
-static ID id_BigDecimal_rounding_mode;
-static ID id_BigDecimal_precision_limit;
-
-static ID id_up;
-static ID id_down;
-static ID id_truncate;
-static ID id_half_up;
-static ID id_default;
-static ID id_half_down;
-static ID id_half_even;
-static ID id_banker;
-static ID id_ceiling;
-static ID id_ceil;
-static ID id_floor;
-static ID id_to_r;
-static ID id_eq;
-static ID id_half;
-
-#define RBD_NUM_ROUNDING_MODES 11
-
-static struct {
- ID id;
- uint8_t mode;
-} rbd_rounding_modes[RBD_NUM_ROUNDING_MODES];
-
-/* MACRO's to guard objects from GC by keeping them in stack */
-#ifdef RBIMPL_ATTR_MAYBE_UNUSED
-#define ENTER(n) RBIMPL_ATTR_MAYBE_UNUSED() volatile VALUE vStack[n];int iStack=0
-#else
-#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
-#endif
-#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
-#define SAVE(p) PUSH((p)->obj)
-#define GUARD_OBJ(p,y) ((p)=(y), SAVE(p))
-
-#define BASE_FIG BIGDECIMAL_COMPONENT_FIGURES
-#define BASE BIGDECIMAL_BASE
-
-#define HALF_BASE (BASE/2)
-#define BASE1 (BASE/10)
-
-#define LOG10_2 0.3010299956639812
-
-#ifndef RRATIONAL_ZERO_P
-# define RRATIONAL_ZERO_P(x) (FIXNUM_P(rb_rational_num(x)) && \
- FIX2LONG(rb_rational_num(x)) == 0)
-#endif
-
-#ifndef RRATIONAL_NEGATIVE_P
-# define RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))
-#endif
-
-#ifndef DECIMAL_SIZE_OF_BITS
-#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
-/* an approximation of ceil(n * log10(2)), upto 65536 at least */
-#endif
-
-#ifdef PRIsVALUE
-# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
-# define RB_OBJ_STRING(obj) (obj)
-#else
-# define PRIsVALUE "s"
-# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
-# define RB_OBJ_STRING(obj) StringValueCStr(obj)
-#endif
-
-#ifndef MAYBE_UNUSED
-# define MAYBE_UNUSED(x) x
-#endif
-
-#define BIGDECIMAL_POSITIVE_P(bd) ((bd)->sign > 0)
-#define BIGDECIMAL_NEGATIVE_P(bd) ((bd)->sign < 0)
-
-/*
- * ================== Memory allocation ============================
- */
-
-#ifdef BIGDECIMAL_DEBUG
-static size_t rbd_allocation_count = 0; /* Memory allocation counter */
-static inline void
-atomic_allocation_count_inc(void)
-{
- RUBY_ATOMIC_SIZE_INC(rbd_allocation_count);
-}
-static inline void
-atomic_allocation_count_dec_nounderflow(void)
-{
- if (rbd_allocation_count == 0) return;
- RUBY_ATOMIC_SIZE_DEC(rbd_allocation_count);
-}
-static void
-check_allocation_count_nonzero(void)
-{
- if (rbd_allocation_count != 0) return;
- rb_bug("[bigdecimal][rbd_free_struct] Too many memory free calls");
-}
-#else
-# define atomic_allocation_count_inc() /* nothing */
-# define atomic_allocation_count_dec_nounderflow() /* nothing */
-# define check_allocation_count_nonzero() /* nothing */
-#endif /* BIGDECIMAL_DEBUG */
-
-PUREFUNC(static inline size_t rbd_struct_size(size_t const));
-
-static inline size_t
-rbd_struct_size(size_t const internal_digits)
-{
- size_t const frac_len = (internal_digits == 0) ? 1 : internal_digits;
- return offsetof(Real, frac) + frac_len * sizeof(DECDIG);
-}
-
-static inline Real *
-rbd_allocate_struct(size_t const internal_digits)
-{
- size_t const size = rbd_struct_size(internal_digits);
- Real *real = ruby_xcalloc(1, size);
- atomic_allocation_count_inc();
- real->MaxPrec = internal_digits;
- return real;
-}
-
-static size_t
-rbd_calculate_internal_digits(size_t const digits, bool limit_precision)
-{
- size_t const len = roomof(digits, BASE_FIG);
- if (limit_precision) {
- size_t const prec_limit = VpGetPrecLimit();
- if (prec_limit > 0) {
- /* NOTE: 2 more digits for rounding and division */
- size_t const max_len = roomof(prec_limit, BASE_FIG) + 2;
- if (len > max_len)
- return max_len;
- }
- }
-
- return len;
-}
-
-static inline Real *
-rbd_allocate_struct_decimal_digits(size_t const decimal_digits, bool limit_precision)
-{
- size_t const internal_digits = rbd_calculate_internal_digits(decimal_digits, limit_precision);
- return rbd_allocate_struct(internal_digits);
-}
-
-static VALUE BigDecimal_wrap_struct(VALUE obj, Real *vp);
-
-static Real *
-rbd_reallocate_struct(Real *real, size_t const internal_digits)
-{
- size_t const size = rbd_struct_size(internal_digits);
- VALUE obj = real ? real->obj : 0;
- Real *new_real = (Real *)ruby_xrealloc(real, size);
- new_real->MaxPrec = internal_digits;
- if (obj) {
- new_real->obj = 0;
- BigDecimal_wrap_struct(obj, new_real);
- }
- return new_real;
-}
-
-static void
-rbd_free_struct(Real *real)
-{
- if (real != NULL) {
- check_allocation_count_nonzero();
- ruby_xfree(real);
- atomic_allocation_count_dec_nounderflow();
- }
-}
-
-#define NewZero rbd_allocate_struct_zero
-static Real *
-rbd_allocate_struct_zero(int sign, size_t const digits, bool limit_precision)
-{
- Real *real = rbd_allocate_struct_decimal_digits(digits, limit_precision);
- VpSetZero(real, sign);
- return real;
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_limited(int sign, size_t const digits));
-#define NewZeroLimited rbd_allocate_struct_zero_limited
-static inline Real *
-rbd_allocate_struct_zero_limited(int sign, size_t const digits)
-{
- return rbd_allocate_struct_zero(sign, digits, true);
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_nolimit(int sign, size_t const digits));
-#define NewZeroNolimit rbd_allocate_struct_zero_nolimit
-static inline Real *
-rbd_allocate_struct_zero_nolimit(int sign, size_t const digits)
-{
- return rbd_allocate_struct_zero(sign, digits, false);
-}
-
-#define NewOne rbd_allocate_struct_one
-static Real *
-rbd_allocate_struct_one(int sign, size_t const digits, bool limit_precision)
-{
- Real *real = rbd_allocate_struct_decimal_digits(digits, limit_precision);
- VpSetOne(real);
- if (sign < 0)
- VpSetSign(real, VP_SIGN_NEGATIVE_FINITE);
- return real;
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_limited(int sign, size_t const digits));
-#define NewOneLimited rbd_allocate_struct_one_limited
-static inline Real *
-rbd_allocate_struct_one_limited(int sign, size_t const digits)
-{
- return rbd_allocate_struct_one(sign, digits, true);
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_nolimit(int sign, size_t const digits));
-#define NewOneNolimit rbd_allocate_struct_one_nolimit
-static inline Real *
-rbd_allocate_struct_one_nolimit(int sign, size_t const digits)
-{
- return rbd_allocate_struct_one(sign, digits, false);
-}
-
-/*
- * ================== Ruby Interface part ==========================
- */
-#define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f)
-
-/*
- * VP routines used in BigDecimal part
- */
-static unsigned short VpGetException(void);
-static void VpSetException(unsigned short f);
-static void VpCheckException(Real *p, bool always);
-static VALUE VpCheckGetValue(Real *p);
-static void VpInternalRound(Real *c, size_t ixDigit, DECDIG vPrev, DECDIG v);
-static int VpLimitRound(Real *c, size_t ixDigit);
-static Real *VpCopy(Real *pv, Real const* const x);
-static int VPrint(FILE *fp,const char *cntl_chr,Real *a);
-
-/*
- * **** BigDecimal part ****
- */
-
-static VALUE BigDecimal_nan(void);
-static VALUE BigDecimal_positive_infinity(void);
-static VALUE BigDecimal_negative_infinity(void);
-static VALUE BigDecimal_positive_zero(void);
-static VALUE BigDecimal_negative_zero(void);
-
-static void
-BigDecimal_delete(void *pv)
-{
- rbd_free_struct(pv);
-}
-
-static size_t
-BigDecimal_memsize(const void *ptr)
-{
- const Real *pv = ptr;
- return (sizeof(*pv) + pv->MaxPrec * sizeof(DECDIG));
-}
-
-#ifndef HAVE_RB_EXT_RACTOR_SAFE
-# undef RUBY_TYPED_FROZEN_SHAREABLE
-# define RUBY_TYPED_FROZEN_SHAREABLE 0
-#endif
-
-static const rb_data_type_t BigDecimal_data_type = {
- "BigDecimal",
- { 0, BigDecimal_delete, BigDecimal_memsize, },
-#ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED
-#endif
-};
-
-static Real *
-rbd_allocate_struct_zero_wrap_klass(VALUE klass, int sign, size_t const digits, bool limit_precision)
-{
- Real *real = rbd_allocate_struct_zero(sign, digits, limit_precision);
- if (real != NULL) {
- VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0);
- BigDecimal_wrap_struct(obj, real);
- }
- return real;
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_limited_wrap(int sign, size_t const digits));
-#define NewZeroWrapLimited rbd_allocate_struct_zero_limited_wrap
-static inline Real *
-rbd_allocate_struct_zero_limited_wrap(int sign, size_t const digits)
-{
- return rbd_allocate_struct_zero_wrap_klass(rb_cBigDecimal, sign, digits, true);
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_zero_nolimit_wrap(int sign, size_t const digits));
-#define NewZeroWrapNolimit rbd_allocate_struct_zero_nolimit_wrap
-static inline Real *
-rbd_allocate_struct_zero_nolimit_wrap(int sign, size_t const digits)
-{
- return rbd_allocate_struct_zero_wrap_klass(rb_cBigDecimal, sign, digits, false);
-}
-
-static Real *
-rbd_allocate_struct_one_wrap_klass(VALUE klass, int sign, size_t const digits, bool limit_precision)
-{
- Real *real = rbd_allocate_struct_one(sign, digits, limit_precision);
- if (real != NULL) {
- VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0);
- BigDecimal_wrap_struct(obj, real);
- }
- return real;
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_limited_wrap(int sign, size_t const digits));
-#define NewOneWrapLimited rbd_allocate_struct_one_limited_wrap
-static inline Real *
-rbd_allocate_struct_one_limited_wrap(int sign, size_t const digits)
-{
- return rbd_allocate_struct_one_wrap_klass(rb_cBigDecimal, sign, digits, true);
-}
-
-MAYBE_UNUSED(static inline Real * rbd_allocate_struct_one_nolimit_wrap(int sign, size_t const digits));
-#define NewOneWrapNolimit rbd_allocate_struct_one_nolimit_wrap
-static inline Real *
-rbd_allocate_struct_one_nolimit_wrap(int sign, size_t const digits)
-{
- return rbd_allocate_struct_one_wrap_klass(rb_cBigDecimal, sign, digits, false);
-}
-
-static inline int
-is_kind_of_BigDecimal(VALUE const v)
-{
- return rb_typeddata_is_kind_of(v, &BigDecimal_data_type);
-}
-
-NORETURN(static void cannot_be_coerced_into_BigDecimal(VALUE, VALUE));
-
-static void
-cannot_be_coerced_into_BigDecimal(VALUE exc_class, VALUE v)
-{
- VALUE str;
-
- if (rb_special_const_p(v)) {
- str = rb_inspect(v);
- }
- else {
- str = rb_class_name(rb_obj_class(v));
- }
-
- str = rb_str_cat2(rb_str_dup(str), " can't be coerced into BigDecimal");
- rb_exc_raise(rb_exc_new3(exc_class, str));
-}
-
-static inline VALUE BigDecimal_div2(VALUE, VALUE, VALUE);
-static VALUE rb_inum_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception);
-static VALUE rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception);
-static VALUE rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception);
-static VALUE rb_cstr_convert_to_BigDecimal(const char *c_str, size_t digs, int raise_exception);
-static VALUE rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception);
-
-static Real*
-GetVpValueWithPrec(VALUE v, long prec, int must)
-{
- const size_t digs = prec < 0 ? SIZE_MAX : (size_t)prec;
-
- switch(TYPE(v)) {
- case T_FLOAT:
- v = rb_float_convert_to_BigDecimal(v, digs, must);
- break;
-
- case T_RATIONAL:
- v = rb_rational_convert_to_BigDecimal(v, digs, must);
- break;
-
- case T_DATA:
- if (!is_kind_of_BigDecimal(v)) {
- goto SomeOneMayDoIt;
- }
- break;
-
- case T_FIXNUM: {
- char szD[128];
- snprintf(szD, 128, "%ld", FIX2LONG(v));
- v = rb_cstr_convert_to_BigDecimal(szD, VpBaseFig() * 2 + 1, must);
- break;
- }
-
-#ifdef ENABLE_NUMERIC_STRING
- case T_STRING: {
- const char *c_str = StringValueCStr(v);
- v = rb_cstr_convert_to_BigDecimal(c_str, RSTRING_LEN(v) + VpBaseFig() + 1, must);
- break;
- }
-#endif /* ENABLE_NUMERIC_STRING */
-
- case T_BIGNUM: {
- VALUE bg = rb_big2str(v, 10);
- v = rb_cstr_convert_to_BigDecimal(RSTRING_PTR(bg), RSTRING_LEN(bg) + VpBaseFig() + 1, must);
- RB_GC_GUARD(bg);
- break;
- }
-
- default:
- goto SomeOneMayDoIt;
- }
-
- Real *vp;
- TypedData_Get_Struct(v, Real, &BigDecimal_data_type, vp);
- return vp;
-
-SomeOneMayDoIt:
- if (must) {
- cannot_be_coerced_into_BigDecimal(rb_eTypeError, v);
- }
- return NULL; /* NULL means to coerce */
-}
-
-static inline Real*
-GetVpValue(VALUE v, int must)
-{
- return GetVpValueWithPrec(v, -1, must);
-}
-
-/* call-seq:
- * BigDecimal.double_fig -> integer
- *
- * Returns the number of digits a Float object is allowed to have;
- * the result is system-dependent:
- *
- * BigDecimal.double_fig # => 16
- *
- */
-static inline VALUE
-BigDecimal_double_fig(VALUE self)
-{
- return INT2FIX(VpDblFig());
-}
-
-/* call-seq:
- * precs -> array
- *
- * Returns an Array of two Integer values that represent platform-dependent
- * internal storage properties.
- *
- * This method is deprecated and will be removed in the future.
- * Instead, use BigDecimal#n_significant_digits for obtaining the number of
- * significant digits in scientific notation, and BigDecimal#precision for
- * obtaining the number of digits in decimal notation.
- *
- */
-
-static VALUE
-BigDecimal_prec(VALUE self)
-{
- ENTER(1);
- Real *p;
- VALUE obj;
-
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
- "BigDecimal#precs is deprecated and will be removed in the future; "
- "use BigDecimal#precision instead.");
-
- GUARD_OBJ(p, GetVpValue(self, 1));
- obj = rb_assoc_new(SIZET2NUM(p->Prec*VpBaseFig()),
- SIZET2NUM(p->MaxPrec*VpBaseFig()));
- return obj;
-}
-
-static void
-BigDecimal_count_precision_and_scale(VALUE self, ssize_t *out_precision, ssize_t *out_scale)
-{
- ENTER(1);
-
- if (out_precision == NULL && out_scale == NULL)
- return;
-
- Real *p;
- GUARD_OBJ(p, GetVpValue(self, 1));
- if (VpIsZero(p) || !VpIsDef(p)) {
- zero:
- if (out_precision) *out_precision = 0;
- if (out_scale) *out_scale = 0;
- return;
- }
-
- DECDIG x;
-
- ssize_t n = p->Prec; /* The length of frac without zeros. */
- while (n > 0 && p->frac[n-1] == 0) --n;
- if (n == 0) goto zero;
-
- int nlz = BASE_FIG;
- for (x = p->frac[0]; x > 0; x /= 10) --nlz;
-
- int ntz = 0;
- for (x = p->frac[n-1]; x > 0 && x % 10 == 0; x /= 10) ++ntz;
-
- /*
- * Calculate the precision and the scale
- * -------------------------------------
- *
- * The most significant digit is frac[0], and the least significant digit
- * is frac[Prec-1]. When the exponent is zero, the decimal point is
- * located just before frac[0].
- *
- * When the exponent is negative, the decimal point moves to leftward.
- * In this case, the precision can be calculated by
- *
- * precision = BASE_FIG * (-exponent + n) - ntz,
- *
- * and the scale is the same as precision.
- *
- * 0 . 0000 0000 | frac[0] ... frac[n-1] |
- * |<----------| exponent == -2 |
- * |---------------------------------->| precision
- * |---------------------------------->| scale
- *
- *
- * Conversely, when the exponent is positive, the decimal point moves to
- * rightward. In this case, the scale equals to
- *
- * BASE_FIG * (n - exponent) - ntz.
- *
- * the precision equals to
- *
- * scale + BASE_FIG * exponent - nlz.
- *
- * | frac[0] frac[1] . frac[2] ... frac[n-1] |
- * |---------------->| exponent == 2 |
- * | |---------------------->| scale
- * |---------------------------------------->| precision
- */
-
- ssize_t ex = p->exponent;
-
- /* Count the number of decimal digits before frac[1]. */
- ssize_t n_digits_head = BASE_FIG;
- if (ex < 0) {
- n_digits_head += (-ex) * BASE_FIG; /* The number of leading zeros before frac[0]. */
- ex = 0;
- }
- else if (ex > 0) {
- /* Count the number of decimal digits without the leading zeros in
- * the most significant digit in the integral part.
- */
- n_digits_head -= nlz; /* Make the number of digits */
- }
-
- if (out_precision) {
- ssize_t precision = n_digits_head;
-
- /* Count the number of decimal digits after frac[0]. */
- if (ex > (ssize_t)n) {
- /* In this case the number is an integer with some trailing zeros. */
- precision += (ex - 1) * BASE_FIG;
- }
- else if (n > 0) {
- precision += (n - 1) * BASE_FIG;
-
- if (ex < (ssize_t)n) {
- precision -= ntz;
- }
- }
-
- *out_precision = precision;
- }
-
- if (out_scale) {
- ssize_t scale = 0;
-
- if (p->exponent < 0) {
- scale = n_digits_head + (n - 1) * BASE_FIG - ntz;
- }
- else if (n > p->exponent) {
- scale = (n - p->exponent) * BASE_FIG - ntz;
- }
-
- *out_scale = scale;
- }
-}
-
-/*
- * call-seq:
- * precision -> integer
- *
- * Returns the number of decimal digits in +self+:
- *
- * BigDecimal("0").precision # => 0
- * BigDecimal("1").precision # => 1
- * BigDecimal("1.1").precision # => 2
- * BigDecimal("3.1415").precision # => 5
- * BigDecimal("-1e20").precision # => 21
- * BigDecimal("1e-20").precision # => 20
- * BigDecimal("Infinity").precision # => 0
- * BigDecimal("-Infinity").precision # => 0
- * BigDecimal("NaN").precision # => 0
- *
- */
-static VALUE
-BigDecimal_precision(VALUE self)
-{
- ssize_t precision;
- BigDecimal_count_precision_and_scale(self, &precision, NULL);
- return SSIZET2NUM(precision);
-}
-
-/*
- * call-seq:
- * scale -> integer
- *
- * Returns the number of decimal digits following the decimal digits in +self+.
- *
- * BigDecimal("0").scale # => 0
- * BigDecimal("1").scale # => 1
- * BigDecimal("1.1").scale # => 1
- * BigDecimal("3.1415").scale # => 4
- * BigDecimal("-1e20").precision # => 0
- * BigDecimal("1e-20").precision # => 20
- * BigDecimal("Infinity").scale # => 0
- * BigDecimal("-Infinity").scale # => 0
- * BigDecimal("NaN").scale # => 0
- */
-static VALUE
-BigDecimal_scale(VALUE self)
-{
- ssize_t scale;
- BigDecimal_count_precision_and_scale(self, NULL, &scale);
- return SSIZET2NUM(scale);
-}
-
-/*
- * call-seq:
- * precision_scale -> [integer, integer]
- *
- * Returns a 2-length array; the first item is the result of
- * BigDecimal#precision and the second one is of BigDecimal#scale.
- *
- * See BigDecimal#precision.
- * See BigDecimal#scale.
- */
-static VALUE
-BigDecimal_precision_scale(VALUE self)
-{
- ssize_t precision, scale;
- BigDecimal_count_precision_and_scale(self, &precision, &scale);
- return rb_assoc_new(SSIZET2NUM(precision), SSIZET2NUM(scale));
-}
-
-/*
- * call-seq:
- * n_significant_digits -> integer
- *
- * Returns the number of decimal significant digits in +self+.
- *
- * BigDecimal("0").n_significant_digits # => 0
- * BigDecimal("1").n_significant_digits # => 1
- * BigDecimal("1.1").n_significant_digits # => 2
- * BigDecimal("3.1415").n_significant_digits # => 5
- * BigDecimal("-1e20").n_significant_digits # => 1
- * BigDecimal("1e-20").n_significant_digits # => 1
- * BigDecimal("Infinity").n_significant_digits # => 0
- * BigDecimal("-Infinity").n_significant_digits # => 0
- * BigDecimal("NaN").n_significant_digits # => 0
- */
-static VALUE
-BigDecimal_n_significant_digits(VALUE self)
-{
- ENTER(1);
-
- Real *p;
- GUARD_OBJ(p, GetVpValue(self, 1));
- if (VpIsZero(p) || !VpIsDef(p)) {
- return INT2FIX(0);
- }
-
- ssize_t n = p->Prec; /* The length of frac without trailing zeros. */
- for (n = p->Prec; n > 0 && p->frac[n-1] == 0; --n);
- if (n == 0) return INT2FIX(0);
-
- DECDIG x;
- int nlz = BASE_FIG;
- for (x = p->frac[0]; x > 0; x /= 10) --nlz;
-
- int ntz = 0;
- for (x = p->frac[n-1]; x > 0 && x % 10 == 0; x /= 10) ++ntz;
-
- ssize_t n_significant_digits = BASE_FIG*n - nlz - ntz;
- return SSIZET2NUM(n_significant_digits);
-}
-
-/*
- * call-seq:
- * hash -> integer
- *
- * Returns the integer hash value for +self+.
- *
- * Two instances of \BigDecimal have the same hash value if and only if
- * they have equal:
- *
- * - Sign.
- * - Fractional part.
- * - Exponent.
- *
- */
-static VALUE
-BigDecimal_hash(VALUE self)
-{
- ENTER(1);
- Real *p;
- st_index_t hash;
-
- GUARD_OBJ(p, GetVpValue(self, 1));
- hash = (st_index_t)p->sign;
- /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */
- if(hash == 2 || hash == (st_index_t)-2) {
- hash ^= rb_memhash(p->frac, sizeof(DECDIG)*p->Prec);
- hash += p->exponent;
- }
- return ST2FIX(hash);
-}
-
-/*
- * call-seq:
- * _dump -> string
- *
- * Returns a string representing the marshalling of +self+.
- * See module Marshal.
- *
- * inf = BigDecimal('Infinity') # => Infinity
- * dumped = inf._dump # => "9:Infinity"
- * BigDecimal._load(dumped) # => Infinity
- *
- */
-static VALUE
-BigDecimal_dump(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- Real *vp;
- char *psz;
- VALUE dummy;
- volatile VALUE dump;
- size_t len;
-
- rb_scan_args(argc, argv, "01", &dummy);
- GUARD_OBJ(vp,GetVpValue(self, 1));
- dump = rb_str_new(0, VpNumOfChars(vp, "E")+50);
- psz = RSTRING_PTR(dump);
- snprintf(psz, RSTRING_LEN(dump), "%"PRIuSIZE":", VpMaxPrec(vp)*VpBaseFig());
- len = strlen(psz);
- VpToString(vp, psz+len, RSTRING_LEN(dump)-len, 0, 0);
- rb_str_resize(dump, strlen(psz));
- return dump;
-}
-
-/*
- * Internal method used to provide marshalling support. See the Marshal module.
- */
-static VALUE
-BigDecimal_load(VALUE self, VALUE str)
-{
- ENTER(2);
- Real *pv;
- unsigned char *pch;
- unsigned char ch;
- unsigned long m=0;
-
- pch = (unsigned char *)StringValueCStr(str);
- /* First get max prec */
- while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
- if(!ISDIGIT(ch)) {
- rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string");
- }
- m = m*10 + (unsigned long)(ch-'0');
- }
- if (m > VpBaseFig()) m -= VpBaseFig();
- GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self, true, true));
- m /= VpBaseFig();
- if (m && pv->MaxPrec > m) {
- pv->MaxPrec = m+1;
- }
- return VpCheckGetValue(pv);
-}
-
-static unsigned short
-check_rounding_mode_option(VALUE const opts)
-{
- VALUE mode;
- char const *s;
- long l;
-
- assert(RB_TYPE_P(opts, T_HASH));
-
- if (NIL_P(opts))
- goto no_opt;
-
- mode = rb_hash_lookup2(opts, ID2SYM(id_half), Qundef);
- if (mode == Qundef || NIL_P(mode))
- goto no_opt;
-
- if (SYMBOL_P(mode))
- mode = rb_sym2str(mode);
- else if (!RB_TYPE_P(mode, T_STRING)) {
- VALUE str_mode = rb_check_string_type(mode);
- if (NIL_P(str_mode))
- goto invalid;
- mode = str_mode;
- }
- s = RSTRING_PTR(mode);
- l = RSTRING_LEN(mode);
- switch (l) {
- case 2:
- if (strncasecmp(s, "up", 2) == 0)
- return VP_ROUND_HALF_UP;
- break;
- case 4:
- if (strncasecmp(s, "even", 4) == 0)
- return VP_ROUND_HALF_EVEN;
- else if (strncasecmp(s, "down", 4) == 0)
- return VP_ROUND_HALF_DOWN;
- break;
- default:
- break;
- }
-
- invalid:
- rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", mode);
-
- no_opt:
- return VpGetRoundMode();
-}
-
-static unsigned short
-check_rounding_mode(VALUE const v)
-{
- unsigned short sw;
- ID id;
- if (RB_TYPE_P(v, T_SYMBOL)) {
- int i;
- id = SYM2ID(v);
- for (i = 0; i < RBD_NUM_ROUNDING_MODES; ++i) {
- if (rbd_rounding_modes[i].id == id) {
- return rbd_rounding_modes[i].mode;
- }
- }
- rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", v);
- }
- else {
- sw = NUM2USHORT(v);
- if (!VpIsRoundMode(sw)) {
- rb_raise(rb_eArgError, "invalid rounding mode (%"PRIsVALUE")", v);
- }
- return sw;
- }
-}
-
-/* call-seq:
- * BigDecimal.mode(mode, setting = nil) -> integer
- *
- * Returns an integer representing the mode settings
- * for exception handling and rounding.
- *
- * These modes control exception handling:
- *
- * - \BigDecimal::EXCEPTION_NaN.
- * - \BigDecimal::EXCEPTION_INFINITY.
- * - \BigDecimal::EXCEPTION_UNDERFLOW.
- * - \BigDecimal::EXCEPTION_OVERFLOW.
- * - \BigDecimal::EXCEPTION_ZERODIVIDE.
- * - \BigDecimal::EXCEPTION_ALL.
- *
- * Values for +setting+ for exception handling:
- *
- * - +true+: sets the given +mode+ to +true+.
- * - +false+: sets the given +mode+ to +false+.
- * - +nil+: does not modify the mode settings.
- *
- * You can use method BigDecimal.save_exception_mode
- * to temporarily change, and then automatically restore, exception modes.
- *
- * For clarity, some examples below begin by setting all
- * exception modes to +false+.
- *
- * This mode controls the way rounding is to be performed:
- *
- * - \BigDecimal::ROUND_MODE
- *
- * You can use method BigDecimal.save_rounding_mode
- * to temporarily change, and then automatically restore, the rounding mode.
- *
- * <b>NaNs</b>
- *
- * Mode \BigDecimal::EXCEPTION_NaN controls behavior
- * when a \BigDecimal NaN is created.
- *
- * Settings:
- *
- * - +false+ (default): Returns <tt>BigDecimal('NaN')</tt>.
- * - +true+: Raises FloatDomainError.
- *
- * Examples:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * BigDecimal('NaN') # => NaN
- * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) # => 2
- * BigDecimal('NaN') # Raises FloatDomainError
- *
- * <b>Infinities</b>
- *
- * Mode \BigDecimal::EXCEPTION_INFINITY controls behavior
- * when a \BigDecimal Infinity or -Infinity is created.
- * Settings:
- *
- * - +false+ (default): Returns <tt>BigDecimal('Infinity')</tt>
- * or <tt>BigDecimal('-Infinity')</tt>.
- * - +true+: Raises FloatDomainError.
- *
- * Examples:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * BigDecimal('Infinity') # => Infinity
- * BigDecimal('-Infinity') # => -Infinity
- * BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) # => 1
- * BigDecimal('Infinity') # Raises FloatDomainError
- * BigDecimal('-Infinity') # Raises FloatDomainError
- *
- * <b>Underflow</b>
- *
- * Mode \BigDecimal::EXCEPTION_UNDERFLOW controls behavior
- * when a \BigDecimal underflow occurs.
- * Settings:
- *
- * - +false+ (default): Returns <tt>BigDecimal('0')</tt>
- * or <tt>BigDecimal('-Infinity')</tt>.
- * - +true+: Raises FloatDomainError.
- *
- * Examples:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * def flow_under
- * x = BigDecimal('0.1')
- * 100.times { x *= x }
- * end
- * flow_under # => 100
- * BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) # => 4
- * flow_under # Raises FloatDomainError
- *
- * <b>Overflow</b>
- *
- * Mode \BigDecimal::EXCEPTION_OVERFLOW controls behavior
- * when a \BigDecimal overflow occurs.
- * Settings:
- *
- * - +false+ (default): Returns <tt>BigDecimal('Infinity')</tt>
- * or <tt>BigDecimal('-Infinity')</tt>.
- * - +true+: Raises FloatDomainError.
- *
- * Examples:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * def flow_over
- * x = BigDecimal('10')
- * 100.times { x *= x }
- * end
- * flow_over # => 100
- * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) # => 1
- * flow_over # Raises FloatDomainError
- *
- * <b>Zero Division</b>
- *
- * Mode \BigDecimal::EXCEPTION_ZERODIVIDE controls behavior
- * when a zero-division occurs.
- * Settings:
- *
- * - +false+ (default): Returns <tt>BigDecimal('Infinity')</tt>
- * or <tt>BigDecimal('-Infinity')</tt>.
- * - +true+: Raises FloatDomainError.
- *
- * Examples:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * one = BigDecimal('1')
- * zero = BigDecimal('0')
- * one / zero # => Infinity
- * BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) # => 16
- * one / zero # Raises FloatDomainError
- *
- * <b>All Exceptions</b>
- *
- * Mode \BigDecimal::EXCEPTION_ALL controls all of the above:
- *
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
- * BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) # => 23
- *
- * <b>Rounding</b>
- *
- * Mode \BigDecimal::ROUND_MODE controls the way rounding is to be performed;
- * its +setting+ values are:
- *
- * - +ROUND_UP+: Round away from zero.
- * Aliased as +:up+.
- * - +ROUND_DOWN+: Round toward zero.
- * Aliased as +:down+ and +:truncate+.
- * - +ROUND_HALF_UP+: Round toward the nearest neighbor;
- * if the neighbors are equidistant, round away from zero.
- * Aliased as +:half_up+ and +:default+.
- * - +ROUND_HALF_DOWN+: Round toward the nearest neighbor;
- * if the neighbors are equidistant, round toward zero.
- * Aliased as +:half_down+.
- * - +ROUND_HALF_EVEN+ (Banker's rounding): Round toward the nearest neighbor;
- * if the neighbors are equidistant, round toward the even neighbor.
- * Aliased as +:half_even+ and +:banker+.
- * - +ROUND_CEILING+: Round toward positive infinity.
- * Aliased as +:ceiling+ and +:ceil+.
- * - +ROUND_FLOOR+: Round toward negative infinity.
- * Aliased as +:floor:+.
- *
- */
-static VALUE
-BigDecimal_mode(int argc, VALUE *argv, VALUE self)
-{
- VALUE which;
- VALUE val;
- unsigned long f,fo;
-
- rb_scan_args(argc, argv, "11", &which, &val);
- f = (unsigned long)NUM2INT(which);
-
- if (f & VP_EXCEPTION_ALL) {
- /* Exception mode setting */
- fo = VpGetException();
- if (val == Qnil) return INT2FIX(fo);
- if (val != Qfalse && val!=Qtrue) {
- rb_raise(rb_eArgError, "second argument must be true or false");
- return Qnil; /* Not reached */
- }
- if (f & VP_EXCEPTION_INFINITY) {
- VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_INFINITY) :
- (fo & (~VP_EXCEPTION_INFINITY))));
- }
- fo = VpGetException();
- if (f & VP_EXCEPTION_NaN) {
- VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_NaN) :
- (fo & (~VP_EXCEPTION_NaN))));
- }
- fo = VpGetException();
- if (f & VP_EXCEPTION_UNDERFLOW) {
- VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_UNDERFLOW) :
- (fo & (~VP_EXCEPTION_UNDERFLOW))));
- }
- fo = VpGetException();
- if(f & VP_EXCEPTION_ZERODIVIDE) {
- VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_ZERODIVIDE) :
- (fo & (~VP_EXCEPTION_ZERODIVIDE))));
- }
- fo = VpGetException();
- return INT2FIX(fo);
- }
- if (VP_ROUND_MODE == f) {
- /* Rounding mode setting */
- unsigned short sw;
- fo = VpGetRoundMode();
- if (NIL_P(val)) return INT2FIX(fo);
- sw = check_rounding_mode(val);
- fo = VpSetRoundMode(sw);
- return INT2FIX(fo);
- }
- rb_raise(rb_eTypeError, "first argument for BigDecimal.mode invalid");
- return Qnil;
-}
-
-static size_t
-GetAddSubPrec(Real *a, Real *b)
-{
- size_t mxs;
- size_t mx = a->Prec;
- SIGNED_VALUE d;
-
- if (!VpIsDef(a) || !VpIsDef(b)) return (size_t)-1L;
- if (mx < b->Prec) mx = b->Prec;
- if (a->exponent != b->exponent) {
- mxs = mx;
- d = a->exponent - b->exponent;
- if (d < 0) d = -d;
- mx = mx + (size_t)d;
- if (mx < mxs) {
- return VpException(VP_EXCEPTION_INFINITY, "Exponent overflow", 0);
- }
- }
- return mx;
-}
-
-static inline SIGNED_VALUE
-check_int_precision(VALUE v)
-{
- SIGNED_VALUE n;
-#if SIZEOF_VALUE <= SIZEOF_LONG
- n = (SIGNED_VALUE)NUM2LONG(v);
-#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG
- n = (SIGNED_VALUE)NUM2LL(v);
-#else
-# error SIZEOF_VALUE is too large
-#endif
- if (n < 0) {
- rb_raise(rb_eArgError, "negative precision");
- }
- return n;
-}
-
-static VALUE
-BigDecimal_wrap_struct(VALUE obj, Real *vp)
-{
- assert(is_kind_of_BigDecimal(obj));
- assert(vp != NULL);
-
- if (vp->obj == obj && RTYPEDDATA_DATA(obj) == vp)
- return obj;
-
- assert(RTYPEDDATA_DATA(obj) == NULL);
- assert(vp->obj == 0);
-
- RTYPEDDATA_DATA(obj) = vp;
- vp->obj = obj;
- RB_OBJ_FREEZE(obj);
- return obj;
-}
-
-VP_EXPORT Real *
-VpNewRbClass(size_t mx, const char *str, VALUE klass, bool strict_p, bool raise_exception)
-{
- VALUE obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, 0);
- Real *pv = VpAlloc(mx, str, strict_p, raise_exception);
- if (!pv)
- return NULL;
- BigDecimal_wrap_struct(obj, pv);
- return pv;
-}
-
-VP_EXPORT Real *
-VpCreateRbObject(size_t mx, const char *str, bool raise_exception)
-{
- return VpNewRbClass(mx, str, rb_cBigDecimal, true, raise_exception);
-}
-
-static Real *
-VpCopy(Real *pv, Real const* const x)
-{
- assert(x != NULL);
-
- pv = rbd_reallocate_struct(pv, x->MaxPrec);
- pv->MaxPrec = x->MaxPrec;
- pv->Prec = x->Prec;
- pv->exponent = x->exponent;
- pv->sign = x->sign;
- pv->flag = x->flag;
- MEMCPY(pv->frac, x->frac, DECDIG, pv->MaxPrec);
-
- return pv;
-}
-
-/* Returns True if the value is Not a Number. */
-static VALUE
-BigDecimal_IsNaN(VALUE self)
-{
- Real *p = GetVpValue(self, 1);
- if (VpIsNaN(p)) return Qtrue;
- return Qfalse;
-}
-
-/* Returns nil, -1, or +1 depending on whether the value is finite,
- * -Infinity, or +Infinity.
- */
-static VALUE
-BigDecimal_IsInfinite(VALUE self)
-{
- Real *p = GetVpValue(self, 1);
- if (VpIsPosInf(p)) return INT2FIX(1);
- if (VpIsNegInf(p)) return INT2FIX(-1);
- return Qnil;
-}
-
-/* Returns True if the value is finite (not NaN or infinite). */
-static VALUE
-BigDecimal_IsFinite(VALUE self)
-{
- Real *p = GetVpValue(self, 1);
- if (VpIsNaN(p)) return Qfalse;
- if (VpIsInf(p)) return Qfalse;
- return Qtrue;
-}
-
-static void
-BigDecimal_check_num(Real *p)
-{
- VpCheckException(p, true);
-}
-
-static VALUE BigDecimal_split(VALUE self);
-
-/* Returns the value as an Integer.
- *
- * If the BigDecimal is infinity or NaN, raises FloatDomainError.
- */
-static VALUE
-BigDecimal_to_i(VALUE self)
-{
- ENTER(5);
- ssize_t e, nf;
- Real *p;
-
- GUARD_OBJ(p, GetVpValue(self, 1));
- BigDecimal_check_num(p);
-
- e = VpExponent10(p);
- if (e <= 0) return INT2FIX(0);
- nf = VpBaseFig();
- if (e <= nf) {
- return LONG2NUM((long)(VpGetSign(p) * (DECDIG_DBL_SIGNED)p->frac[0]));
- }
- else {
- VALUE a = BigDecimal_split(self);
- VALUE digits = RARRAY_AREF(a, 1);
- VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0);
- VALUE ret;
- ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits);
-
- if (BIGDECIMAL_NEGATIVE_P(p)) {
- numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1));
- }
- if (dpower < 0) {
- ret = rb_funcall(numerator, rb_intern("div"), 1,
- rb_funcall(INT2FIX(10), rb_intern("**"), 1,
- INT2FIX(-dpower)));
- }
- else {
- ret = rb_funcall(numerator, '*', 1,
- rb_funcall(INT2FIX(10), rb_intern("**"), 1,
- INT2FIX(dpower)));
- }
- if (RB_TYPE_P(ret, T_FLOAT)) {
- rb_raise(rb_eFloatDomainError, "Infinity");
- }
- return ret;
- }
-}
-
-/* Returns a new Float object having approximately the same value as the
- * BigDecimal number. Normal accuracy limits and built-in errors of binary
- * Float arithmetic apply.
- */
-static VALUE
-BigDecimal_to_f(VALUE self)
-{
- ENTER(1);
- Real *p;
- double d;
- SIGNED_VALUE e;
- char *buf;
- volatile VALUE str;
-
- GUARD_OBJ(p, GetVpValue(self, 1));
- if (VpVtoD(&d, &e, p) != 1)
- return rb_float_new(d);
- if (e > (SIGNED_VALUE)(DBL_MAX_10_EXP+BASE_FIG))
- goto overflow;
- if (e < (SIGNED_VALUE)(DBL_MIN_10_EXP-BASE_FIG))
- goto underflow;
-
- str = rb_str_new(0, VpNumOfChars(p, "E"));
- buf = RSTRING_PTR(str);
- VpToString(p, buf, RSTRING_LEN(str), 0, 0);
- errno = 0;
- d = strtod(buf, 0);
- if (errno == ERANGE) {
- if (d == 0.0) goto underflow;
- if (fabs(d) >= HUGE_VAL) goto overflow;
- }
- return rb_float_new(d);
-
-overflow:
- VpException(VP_EXCEPTION_OVERFLOW, "BigDecimal to Float conversion", 0);
- if (BIGDECIMAL_NEGATIVE_P(p))
- return rb_float_new(VpGetDoubleNegInf());
- else
- return rb_float_new(VpGetDoublePosInf());
-
-underflow:
- VpException(VP_EXCEPTION_UNDERFLOW, "BigDecimal to Float conversion", 0);
- if (BIGDECIMAL_NEGATIVE_P(p))
- return rb_float_new(-0.0);
- else
- return rb_float_new(0.0);
-}
-
-
-/* Converts a BigDecimal to a Rational.
- */
-static VALUE
-BigDecimal_to_r(VALUE self)
-{
- Real *p;
- ssize_t sign, power, denomi_power;
- VALUE a, digits, numerator;
-
- p = GetVpValue(self, 1);
- BigDecimal_check_num(p);
-
- sign = VpGetSign(p);
- power = VpExponent10(p);
- a = BigDecimal_split(self);
- digits = RARRAY_AREF(a, 1);
- denomi_power = power - RSTRING_LEN(digits);
- numerator = rb_funcall(digits, rb_intern("to_i"), 0);
-
- if (sign < 0) {
- numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1));
- }
- if (denomi_power < 0) {
- return rb_Rational(numerator,
- rb_funcall(INT2FIX(10), rb_intern("**"), 1,
- INT2FIX(-denomi_power)));
- }
- else {
- return rb_Rational1(rb_funcall(numerator, '*', 1,
- rb_funcall(INT2FIX(10), rb_intern("**"), 1,
- INT2FIX(denomi_power))));
- }
-}
-
-/* The coerce method provides support for Ruby type coercion. It is not
- * enabled by default.
- *
- * This means that binary operations like + * / or - can often be performed
- * on a BigDecimal and an object of another type, if the other object can
- * be coerced into a BigDecimal value.
- *
- * e.g.
- * a = BigDecimal("1.0")
- * b = a / 2.0 #=> 0.5
- *
- * Note that coercing a String to a BigDecimal is not supported by default;
- * it requires a special compile-time option when building Ruby.
- */
-static VALUE
-BigDecimal_coerce(VALUE self, VALUE other)
-{
- ENTER(2);
- VALUE obj;
- Real *b;
-
- if (RB_TYPE_P(other, T_FLOAT)) {
- GUARD_OBJ(b, GetVpValueWithPrec(other, 0, 1));
- obj = rb_assoc_new(VpCheckGetValue(b), self);
- }
- else {
- if (RB_TYPE_P(other, T_RATIONAL)) {
- Real* pv = DATA_PTR(self);
- GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1));
- }
- else {
- GUARD_OBJ(b, GetVpValue(other, 1));
- }
- obj = rb_assoc_new(b->obj, self);
- }
-
- return obj;
-}
-
-/*
- * call-seq:
- * +big_decimal -> self
- *
- * Returns +self+:
- *
- * +BigDecimal(5) # => 0.5e1
- * +BigDecimal(-5) # => -0.5e1
- *
- */
-
-static VALUE
-BigDecimal_uplus(VALUE self)
-{
- return self;
-}
-
- /*
- * call-seq:
- * self + value -> bigdecimal
- *
- * Returns the \BigDecimal sum of +self+ and +value+:
- *
- * b = BigDecimal('111111.111') # => 0.111111111e6
- * b + 2 # => 0.111113111e6
- * b + 2.0 # => 0.111113111e6
- * b + Rational(2, 1) # => 0.111113111e6
- * b + Complex(2, 0) # => (0.111113111e6+0i)
- *
- * See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision].
- *
- */
-
-static VALUE
-BigDecimal_add(VALUE self, VALUE r)
-{
- ENTER(5);
- Real *c, *a, *b;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- if (RB_TYPE_P(r, T_FLOAT)) {
- b = GetVpValueWithPrec(r, 0, 1);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
- }
- else {
- b = GetVpValue(r, 0);
- }
-
- if (!b) return DoSomeOne(self,r,'+');
- SAVE(b);
-
- if (VpIsNaN(b)) return b->obj;
- if (VpIsNaN(a)) return a->obj;
-
- mx = GetAddSubPrec(a, b);
- if (mx == (size_t)-1L) {
- GUARD_OBJ(c, NewZeroWrapLimited(1, VpBaseFig() + 1));
- VpAddSub(c, a, b, 1);
- }
- else {
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx * (VpBaseFig() + 1)));
- if (!mx) {
- VpSetInf(c, VpGetSign(a));
- }
- else {
- VpAddSub(c, a, b, 1);
- }
- }
- return VpCheckGetValue(c);
-}
-
- /* call-seq:
- * self - value -> bigdecimal
- *
- * Returns the \BigDecimal difference of +self+ and +value+:
- *
- * b = BigDecimal('333333.333') # => 0.333333333e6
- * b - 2 # => 0.333331333e6
- * b - 2.0 # => 0.333331333e6
- * b - Rational(2, 1) # => 0.333331333e6
- * b - Complex(2, 0) # => (0.333331333e6+0i)
- *
- * See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision].
- *
- */
-static VALUE
-BigDecimal_sub(VALUE self, VALUE r)
-{
- ENTER(5);
- Real *c, *a, *b;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self,1));
- if (RB_TYPE_P(r, T_FLOAT)) {
- b = GetVpValueWithPrec(r, 0, 1);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
- }
- else {
- b = GetVpValue(r,0);
- }
-
- if (!b) return DoSomeOne(self,r,'-');
- SAVE(b);
-
- if (VpIsNaN(b)) return b->obj;
- if (VpIsNaN(a)) return a->obj;
-
- mx = GetAddSubPrec(a,b);
- if (mx == (size_t)-1L) {
- GUARD_OBJ(c, NewZeroWrapLimited(1, VpBaseFig() + 1));
- VpAddSub(c, a, b, -1);
- }
- else {
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx *(VpBaseFig() + 1)));
- if (!mx) {
- VpSetInf(c,VpGetSign(a));
- }
- else {
- VpAddSub(c, a, b, -1);
- }
- }
- return VpCheckGetValue(c);
-}
-
-static VALUE
-BigDecimalCmp(VALUE self, VALUE r,char op)
-{
- ENTER(5);
- SIGNED_VALUE e;
- Real *a, *b=0;
- GUARD_OBJ(a, GetVpValue(self, 1));
- switch (TYPE(r)) {
- case T_DATA:
- if (!is_kind_of_BigDecimal(r)) break;
- /* fall through */
- case T_FIXNUM:
- /* fall through */
- case T_BIGNUM:
- GUARD_OBJ(b, GetVpValue(r, 0));
- break;
-
- case T_FLOAT:
- GUARD_OBJ(b, GetVpValueWithPrec(r, 0, 0));
- break;
-
- case T_RATIONAL:
- GUARD_OBJ(b, GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 0));
- break;
-
- default:
- break;
- }
- if (b == NULL) {
- ID f = 0;
-
- switch (op) {
- case '*':
- return rb_num_coerce_cmp(self, r, rb_intern("<=>"));
-
- case '=':
- return RTEST(rb_num_coerce_cmp(self, r, rb_intern("=="))) ? Qtrue : Qfalse;
-
- case 'G':
- f = rb_intern(">=");
- break;
-
- case 'L':
- f = rb_intern("<=");
- break;
-
- case '>':
- /* fall through */
- case '<':
- f = (ID)op;
- break;
-
- default:
- break;
- }
- return rb_num_coerce_relop(self, r, f);
- }
- SAVE(b);
- e = VpComp(a, b);
- if (e == 999)
- return (op == '*') ? Qnil : Qfalse;
- switch (op) {
- case '*':
- return INT2FIX(e); /* any op */
-
- case '=':
- if (e == 0) return Qtrue;
- return Qfalse;
-
- case 'G':
- if (e >= 0) return Qtrue;
- return Qfalse;
-
- case '>':
- if (e > 0) return Qtrue;
- return Qfalse;
-
- case 'L':
- if (e <= 0) return Qtrue;
- return Qfalse;
-
- case '<':
- if (e < 0) return Qtrue;
- return Qfalse;
-
- default:
- break;
- }
-
- rb_bug("Undefined operation in BigDecimalCmp()");
-
- UNREACHABLE;
-}
-
-/* Returns True if the value is zero. */
-static VALUE
-BigDecimal_zero(VALUE self)
-{
- Real *a = GetVpValue(self, 1);
- return VpIsZero(a) ? Qtrue : Qfalse;
-}
-
-/* Returns self if the value is non-zero, nil otherwise. */
-static VALUE
-BigDecimal_nonzero(VALUE self)
-{
- Real *a = GetVpValue(self, 1);
- return VpIsZero(a) ? Qnil : self;
-}
-
-/* The comparison operator.
- * a <=> b is 0 if a == b, 1 if a > b, -1 if a < b.
- */
-static VALUE
-BigDecimal_comp(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, '*');
-}
-
-/*
- * Tests for value equality; returns true if the values are equal.
- *
- * The == and === operators and the eql? method have the same implementation
- * for BigDecimal.
- *
- * Values may be coerced to perform the comparison:
- *
- * BigDecimal('1.0') == 1.0 #=> true
- */
-static VALUE
-BigDecimal_eq(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, '=');
-}
-
-/* call-seq:
- * self < other -> true or false
- *
- * Returns +true+ if +self+ is less than +other+, +false+ otherwise:
- *
- * b = BigDecimal('1.5') # => 0.15e1
- * b < 2 # => true
- * b < 2.0 # => true
- * b < Rational(2, 1) # => true
- * b < 1.5 # => false
- *
- * Raises an exception if the comparison cannot be made.
- *
- */
-static VALUE
-BigDecimal_lt(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, '<');
-}
-
-/* call-seq:
- * self <= other -> true or false
- *
- * Returns +true+ if +self+ is less or equal to than +other+, +false+ otherwise:
- *
- * b = BigDecimal('1.5') # => 0.15e1
- * b <= 2 # => true
- * b <= 2.0 # => true
- * b <= Rational(2, 1) # => true
- * b <= 1.5 # => true
- * b < 1 # => false
- *
- * Raises an exception if the comparison cannot be made.
- *
- */
-static VALUE
-BigDecimal_le(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, 'L');
-}
-
-/* call-seq:
- * self > other -> true or false
- *
- * Returns +true+ if +self+ is greater than +other+, +false+ otherwise:
- *
- * b = BigDecimal('1.5')
- * b > 1 # => true
- * b > 1.0 # => true
- * b > Rational(1, 1) # => true
- * b > 2 # => false
- *
- * Raises an exception if the comparison cannot be made.
- *
- */
-static VALUE
-BigDecimal_gt(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, '>');
-}
-
-/* call-seq:
- * self >= other -> true or false
- *
- * Returns +true+ if +self+ is greater than or equal to +other+, +false+ otherwise:
- *
- * b = BigDecimal('1.5')
- * b >= 1 # => true
- * b >= 1.0 # => true
- * b >= Rational(1, 1) # => true
- * b >= 1.5 # => true
- * b > 2 # => false
- *
- * Raises an exception if the comparison cannot be made.
- *
- */
-static VALUE
-BigDecimal_ge(VALUE self, VALUE r)
-{
- return BigDecimalCmp(self, r, 'G');
-}
-
-/*
- * call-seq:
- * -self -> bigdecimal
- *
- * Returns the \BigDecimal negation of self:
- *
- * b0 = BigDecimal('1.5')
- * b1 = -b0 # => -0.15e1
- * b2 = -b1 # => 0.15e1
- *
- */
-
-static VALUE
-BigDecimal_neg(VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- GUARD_OBJ(a, GetVpValue(self, 1));
- GUARD_OBJ(c, NewZeroWrapLimited(1, a->Prec *(VpBaseFig() + 1)));
- VpAsgn(c, a, -1);
- return VpCheckGetValue(c);
-}
-
-static VALUE
-BigDecimal_mult(VALUE self, VALUE r)
-{
- ENTER(5);
- Real *c, *a, *b;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- if (RB_TYPE_P(r, T_FLOAT)) {
- b = GetVpValueWithPrec(r, 0, 1);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
- }
- else {
- b = GetVpValue(r,0);
- }
-
- if (!b) return DoSomeOne(self, r, '*');
- SAVE(b);
-
- mx = a->Prec + b->Prec;
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx * (VpBaseFig() + 1)));
- VpMult(c, a, b);
- return VpCheckGetValue(c);
-}
-
-static VALUE
-BigDecimal_divide(VALUE self, VALUE r, Real **c, Real **res, Real **div)
-/* For c = self.div(r): with round operation */
-{
- ENTER(5);
- Real *a, *b;
- ssize_t a_prec, b_prec;
- size_t mx;
-
- TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a);
- SAVE(a);
-
- VALUE rr = r;
- if (is_kind_of_BigDecimal(rr)) {
- /* do nothing */
- }
- else if (RB_INTEGER_TYPE_P(r)) {
- rr = rb_inum_convert_to_BigDecimal(r, 0, true);
- }
- else if (RB_TYPE_P(r, T_FLOAT)) {
- rr = rb_float_convert_to_BigDecimal(r, 0, true);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true);
- }
-
- if (!is_kind_of_BigDecimal(rr)) {
- return DoSomeOne(self, r, '/');
- }
-
- TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b);
- SAVE(b);
- *div = b;
-
- BigDecimal_count_precision_and_scale(self, &a_prec, NULL);
- BigDecimal_count_precision_and_scale(rr, &b_prec, NULL);
- mx = (a_prec > b_prec) ? a_prec : b_prec;
- mx *= 2;
-
- if (2*BIGDECIMAL_DOUBLE_FIGURES > mx)
- mx = 2*BIGDECIMAL_DOUBLE_FIGURES;
-
- GUARD_OBJ((*c), NewZeroWrapNolimit(1, mx + 2*BASE_FIG));
- GUARD_OBJ((*res), NewZeroWrapNolimit(1, (mx + 1)*2 + 2*BASE_FIG));
- VpDivd(*c, *res, a, b);
-
- return Qnil;
-}
-
-static VALUE BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod);
-
-/* call-seq:
- * a / b -> bigdecimal
- *
- * Divide by the specified value.
- *
- * The result precision will be the precision of the larger operand,
- * but its minimum is 2*Float::DIG.
- *
- * See BigDecimal#div.
- * See BigDecimal#quo.
- */
-static VALUE
-BigDecimal_div(VALUE self, VALUE r)
-/* For c = self/r: with round operation */
-{
- ENTER(5);
- Real *c=NULL, *res=NULL, *div = NULL;
- r = BigDecimal_divide(self, r, &c, &res, &div);
- if (!NIL_P(r)) return r; /* coerced by other */
- SAVE(c); SAVE(res); SAVE(div);
- /* a/b = c + r/b */
- /* c xxxxx
- r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE
- */
- /* Round */
- if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
- VpInternalRound(c, 0, c->frac[c->Prec-1], (DECDIG)(VpBaseVal() * (DECDIG_DBL)res->frac[0] / div->frac[0]));
- }
- return VpCheckGetValue(c);
-}
-
-static VALUE BigDecimal_round(int argc, VALUE *argv, VALUE self);
-
-/* call-seq:
- * quo(value) -> bigdecimal
- * quo(value, digits) -> bigdecimal
- *
- * Divide by the specified value.
- *
- * digits:: If specified and less than the number of significant digits of
- * the result, the result is rounded to the given number of digits,
- * according to the rounding mode indicated by BigDecimal.mode.
- *
- * If digits is 0 or omitted, the result is the same as for the
- * / operator.
- *
- * See BigDecimal#/.
- * See BigDecimal#div.
- */
-static VALUE
-BigDecimal_quo(int argc, VALUE *argv, VALUE self)
-{
- VALUE value, digits, result;
- SIGNED_VALUE n = -1;
-
- argc = rb_scan_args(argc, argv, "11", &value, &digits);
- if (argc > 1) {
- n = check_int_precision(digits);
- }
-
- if (n > 0) {
- result = BigDecimal_div2(self, value, digits);
- }
- else {
- result = BigDecimal_div(self, value);
- }
-
- return result;
-}
-
-/*
- * %: mod = a%b = a - (a.to_f/b).floor * b
- * div = (a.to_f/b).floor
- */
-static VALUE
-BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
-{
- ENTER(8);
- Real *c=NULL, *d=NULL, *res=NULL;
- Real *a, *b;
- ssize_t a_prec, b_prec;
- size_t mx;
-
- TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a);
- SAVE(a);
-
- VALUE rr = r;
- if (is_kind_of_BigDecimal(rr)) {
- /* do nothing */
- }
- else if (RB_INTEGER_TYPE_P(r)) {
- rr = rb_inum_convert_to_BigDecimal(r, 0, true);
- }
- else if (RB_TYPE_P(r, T_FLOAT)) {
- rr = rb_float_convert_to_BigDecimal(r, 0, true);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true);
- }
-
- if (!is_kind_of_BigDecimal(rr)) {
- return Qfalse;
- }
-
- TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b);
- SAVE(b);
-
- if (VpIsNaN(a) || VpIsNaN(b)) goto NaN;
- if (VpIsInf(a) && VpIsInf(b)) goto NaN;
- if (VpIsZero(b)) {
- rb_raise(rb_eZeroDivError, "divided by 0");
- }
- if (VpIsInf(a)) {
- if (VpGetSign(a) == VpGetSign(b)) {
- VALUE inf = BigDecimal_positive_infinity();
- TypedData_Get_Struct(inf, Real, &BigDecimal_data_type, *div);
- }
- else {
- VALUE inf = BigDecimal_negative_infinity();
- TypedData_Get_Struct(inf, Real, &BigDecimal_data_type, *div);
- }
- VALUE nan = BigDecimal_nan();
- TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *mod);
- return Qtrue;
- }
- if (VpIsInf(b)) {
- VALUE zero = BigDecimal_positive_zero();
- TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *div);
- *mod = a;
- return Qtrue;
- }
- if (VpIsZero(a)) {
- VALUE zero = BigDecimal_positive_zero();
- TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *div);
- TypedData_Get_Struct(zero, Real, &BigDecimal_data_type, *mod);
- return Qtrue;
- }
-
- BigDecimal_count_precision_and_scale(self, &a_prec, NULL);
- BigDecimal_count_precision_and_scale(rr, &b_prec, NULL);
-
- mx = (a_prec > b_prec) ? a_prec : b_prec;
- mx *= 2;
-
- if (2*BIGDECIMAL_DOUBLE_FIGURES > mx)
- mx = 2*BIGDECIMAL_DOUBLE_FIGURES;
-
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx + 2*BASE_FIG));
- GUARD_OBJ(res, NewZeroWrapNolimit(1, mx*2 + 2*BASE_FIG));
- VpDivd(c, res, a, b);
-
- mx = c->Prec * BASE_FIG;
- GUARD_OBJ(d, NewZeroWrapLimited(1, mx));
- VpActiveRound(d, c, VP_ROUND_DOWN, 0);
-
- VpMult(res, d, b);
- VpAddSub(c, a, res, -1);
-
- if (!VpIsZero(c) && (VpGetSign(a) * VpGetSign(b) < 0)) {
- /* result adjustment for negative case */
- res = rbd_reallocate_struct(res, d->MaxPrec);
- res->MaxPrec = d->MaxPrec;
- VpAddSub(res, d, VpOne(), -1);
- GUARD_OBJ(d, NewZeroWrapLimited(1, GetAddSubPrec(c, b) * 2*BASE_FIG));
- VpAddSub(d, c, b, 1);
- *div = res;
- *mod = d;
- }
- else {
- *div = d;
- *mod = c;
- }
- return Qtrue;
-
- NaN:
- {
- VALUE nan = BigDecimal_nan();
- TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *div);
- TypedData_Get_Struct(nan, Real, &BigDecimal_data_type, *mod);
- }
- return Qtrue;
-}
-
-/* call-seq:
- * a % b
- * a.modulo(b)
- *
- * Returns the modulus from dividing by b.
- *
- * See BigDecimal#divmod.
- */
-static VALUE
-BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */
-{
- ENTER(3);
- Real *div = NULL, *mod = NULL;
-
- if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
- SAVE(div); SAVE(mod);
- return VpCheckGetValue(mod);
- }
- return DoSomeOne(self, r, '%');
-}
-
-static VALUE
-BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
-{
- ENTER(10);
- size_t mx;
- Real *a = NULL, *b = NULL, *c = NULL, *res = NULL, *d = NULL, *rr = NULL, *ff = NULL;
- Real *f = NULL;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- if (RB_TYPE_P(r, T_FLOAT)) {
- b = GetVpValueWithPrec(r, 0, 1);
- }
- else if (RB_TYPE_P(r, T_RATIONAL)) {
- b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
- }
- else {
- b = GetVpValue(r, 0);
- }
-
- if (!b) return DoSomeOne(self, r, rb_intern("remainder"));
- SAVE(b);
-
- if (VpIsPosInf(b) || VpIsNegInf(b)) {
- GUARD_OBJ(*dv, NewZeroWrapLimited(1, 1));
- VpSetZero(*dv, 1);
- *rv = a;
- return Qnil;
- }
-
- mx = (a->MaxPrec + b->MaxPrec) *VpBaseFig();
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1)));
- GUARD_OBJ(rr, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1)));
- GUARD_OBJ(ff, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1)));
-
- VpDivd(c, res, a, b);
-
- mx = c->Prec *(VpBaseFig() + 1);
-
- GUARD_OBJ(d, NewZeroWrapLimited(1, mx));
- GUARD_OBJ(f, NewZeroWrapLimited(1, mx));
-
- VpActiveRound(d, c, VP_ROUND_DOWN, 0); /* 0: round off */
-
- VpFrac(f, c);
- VpMult(rr, f, b);
- VpAddSub(ff, res, rr, 1);
-
- *dv = d;
- *rv = ff;
- return Qnil;
-}
-
-/* call-seq:
- * remainder(value)
- *
- * Returns the remainder from dividing by the value.
- *
- * x.remainder(y) means x-y*(x/y).truncate
- */
-static VALUE
-BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
-{
- VALUE f;
- Real *d, *rv = 0;
- f = BigDecimal_divremain(self, r, &d, &rv);
- if (!NIL_P(f)) return f;
- return VpCheckGetValue(rv);
-}
-
-/* call-seq:
- * divmod(value)
- *
- * Divides by the specified value, and returns the quotient and modulus
- * as BigDecimal numbers. The quotient is rounded towards negative infinity.
- *
- * For example:
- *
- * require 'bigdecimal'
- *
- * a = BigDecimal("42")
- * b = BigDecimal("9")
- *
- * q, m = a.divmod(b)
- *
- * c = q * b + m
- *
- * a == c #=> true
- *
- * The quotient q is (a/b).floor, and the modulus is the amount that must be
- * added to q * b to get a.
- */
-static VALUE
-BigDecimal_divmod(VALUE self, VALUE r)
-{
- ENTER(5);
- Real *div = NULL, *mod = NULL;
-
- if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
- SAVE(div); SAVE(mod);
- return rb_assoc_new(VpCheckGetValue(div), VpCheckGetValue(mod));
- }
- return DoSomeOne(self,r,rb_intern("divmod"));
-}
-
-/*
- * Do the same manner as Float#div when n is nil.
- * Do the same manner as BigDecimal#quo when n is 0.
- */
-static inline VALUE
-BigDecimal_div2(VALUE self, VALUE b, VALUE n)
-{
- ENTER(5);
- SIGNED_VALUE ix;
-
- if (NIL_P(n)) { /* div in Float sense */
- Real *div = NULL;
- Real *mod;
- if (BigDecimal_DoDivmod(self, b, &div, &mod)) {
- return BigDecimal_to_i(VpCheckGetValue(div));
- }
- return DoSomeOne(self, b, rb_intern("div"));
- }
-
- /* div in BigDecimal sense */
- ix = check_int_precision(n);
- if (ix == 0) {
- return BigDecimal_div(self, b);
- }
- else {
- Real *res = NULL;
- Real *av = NULL, *bv = NULL, *cv = NULL;
- size_t mx = ix + VpBaseFig()*2;
- size_t b_prec = ix;
- size_t pl = VpSetPrecLimit(0);
-
- GUARD_OBJ(cv, NewZeroWrapLimited(1, mx + VpBaseFig()));
- GUARD_OBJ(av, GetVpValue(self, 1));
- /* TODO: I want to refactor this precision control for a float value later
- * by introducing an implicit conversion function instead of
- * GetVpValueWithPrec. */
- if (RB_FLOAT_TYPE_P(b) && b_prec > BIGDECIMAL_DOUBLE_FIGURES) {
- b_prec = BIGDECIMAL_DOUBLE_FIGURES;
- }
- GUARD_OBJ(bv, GetVpValueWithPrec(b, b_prec, 1));
- mx = av->Prec + bv->Prec + 2;
- if (mx <= cv->MaxPrec) mx = cv->MaxPrec + 1;
- GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx * 2 + 2)*VpBaseFig()));
- VpDivd(cv, res, av, bv);
- VpSetPrecLimit(pl);
- VpLeftRound(cv, VpGetRoundMode(), ix);
- return VpCheckGetValue(cv);
- }
-}
-
- /*
- * Document-method: BigDecimal#div
- *
- * call-seq:
- * div(value) -> integer
- * div(value, digits) -> bigdecimal or integer
- *
- * Divide by the specified value.
- *
- * digits:: If specified and less than the number of significant digits of the
- * result, the result is rounded to that number of digits, according
- * to BigDecimal.mode.
- *
- * If digits is 0, the result is the same as for the / operator
- * or #quo.
- *
- * If digits is not specified, the result is an integer,
- * by analogy with Float#div; see also BigDecimal#divmod.
- *
- * See BigDecimal#/.
- * See BigDecimal#quo.
- *
- * Examples:
- *
- * a = BigDecimal("4")
- * b = BigDecimal("3")
- *
- * a.div(b, 3) # => 0.133e1
- *
- * a.div(b, 0) # => 0.1333333333333333333e1
- * a / b # => 0.1333333333333333333e1
- * a.quo(b) # => 0.1333333333333333333e1
- *
- * a.div(b) # => 1
- */
-static VALUE
-BigDecimal_div3(int argc, VALUE *argv, VALUE self)
-{
- VALUE b,n;
-
- rb_scan_args(argc, argv, "11", &b, &n);
-
- return BigDecimal_div2(self, b, n);
-}
-
- /*
- * call-seq:
- * add(value, ndigits) -> new_bigdecimal
- *
- * Returns the \BigDecimal sum of +self+ and +value+
- * with a precision of +ndigits+ decimal digits.
- *
- * When +ndigits+ is less than the number of significant digits
- * in the sum, the sum is rounded to that number of digits,
- * according to the current rounding mode; see BigDecimal.mode.
- *
- * Examples:
- *
- * # Set the rounding mode.
- * BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
- * b = BigDecimal('111111.111')
- * b.add(1, 0) # => 0.111112111e6
- * b.add(1, 3) # => 0.111e6
- * b.add(1, 6) # => 0.111112e6
- * b.add(1, 15) # => 0.111112111e6
- * b.add(1.0, 15) # => 0.111112111e6
- * b.add(Rational(1, 1), 15) # => 0.111112111e6
- *
- */
-
-static VALUE
-BigDecimal_add2(VALUE self, VALUE b, VALUE n)
-{
- ENTER(2);
- Real *cv;
- SIGNED_VALUE mx = check_int_precision(n);
- if (mx == 0) return BigDecimal_add(self, b);
- else {
- size_t pl = VpSetPrecLimit(0);
- VALUE c = BigDecimal_add(self, b);
- VpSetPrecLimit(pl);
- GUARD_OBJ(cv, GetVpValue(c, 1));
- VpLeftRound(cv, VpGetRoundMode(), mx);
- return VpCheckGetValue(cv);
- }
-}
-
-/* call-seq:
- * sub(value, digits) -> bigdecimal
- *
- * Subtract the specified value.
- *
- * e.g.
- * c = a.sub(b,n)
- *
- * digits:: If specified and less than the number of significant digits of the
- * result, the result is rounded to that number of digits, according
- * to BigDecimal.mode.
- *
- */
-static VALUE
-BigDecimal_sub2(VALUE self, VALUE b, VALUE n)
-{
- ENTER(2);
- Real *cv;
- SIGNED_VALUE mx = check_int_precision(n);
- if (mx == 0) return BigDecimal_sub(self, b);
- else {
- size_t pl = VpSetPrecLimit(0);
- VALUE c = BigDecimal_sub(self, b);
- VpSetPrecLimit(pl);
- GUARD_OBJ(cv, GetVpValue(c, 1));
- VpLeftRound(cv, VpGetRoundMode(), mx);
- return VpCheckGetValue(cv);
- }
-}
-
- /*
- * call-seq:
- * mult(other, ndigits) -> bigdecimal
- *
- * Returns the \BigDecimal product of +self+ and +value+
- * with a precision of +ndigits+ decimal digits.
- *
- * When +ndigits+ is less than the number of significant digits
- * in the sum, the sum is rounded to that number of digits,
- * according to the current rounding mode; see BigDecimal.mode.
- *
- * Examples:
- *
- * # Set the rounding mode.
- * BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
- * b = BigDecimal('555555.555')
- * b.mult(3, 0) # => 0.1666666665e7
- * b.mult(3, 3) # => 0.167e7
- * b.mult(3, 6) # => 0.166667e7
- * b.mult(3, 15) # => 0.1666666665e7
- * b.mult(3.0, 0) # => 0.1666666665e7
- * b.mult(Rational(3, 1), 0) # => 0.1666666665e7
- * b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i)
- *
- */
-
-static VALUE
-BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
-{
- ENTER(2);
- Real *cv;
- SIGNED_VALUE mx = check_int_precision(n);
- if (mx == 0) return BigDecimal_mult(self, b);
- else {
- size_t pl = VpSetPrecLimit(0);
- VALUE c = BigDecimal_mult(self, b);
- VpSetPrecLimit(pl);
- GUARD_OBJ(cv, GetVpValue(c, 1));
- VpLeftRound(cv, VpGetRoundMode(), mx);
- return VpCheckGetValue(cv);
- }
-}
-
-/*
- * call-seq:
- * abs -> bigdecimal
- *
- * Returns the \BigDecimal absolute value of +self+:
- *
- * BigDecimal('5').abs # => 0.5e1
- * BigDecimal('-3').abs # => 0.3e1
- *
- */
-
-static VALUE
-BigDecimal_abs(VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec *(VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpAsgn(c, a, 1);
- VpChangeSign(c, 1);
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * sqrt(n)
- *
- * Returns the square root of the value.
- *
- * Result has at least n significant digits.
- */
-static VALUE
-BigDecimal_sqrt(VALUE self, VALUE nFig)
-{
- ENTER(5);
- Real *c, *a;
- size_t mx, n;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
-
- n = check_int_precision(nFig);
- n += VpDblFig() + VpBaseFig();
- if (mx <= n) mx = n;
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpSqrt(c, a);
- return VpCheckGetValue(c);
-}
-
-/* Return the integer part of the number, as a BigDecimal.
- */
-static VALUE
-BigDecimal_fix(VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec *(VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * round(n, mode)
- *
- * Round to the nearest integer (by default), returning the result as a
- * BigDecimal if n is specified, or as an Integer if it isn't.
- *
- * BigDecimal('3.14159').round #=> 3
- * BigDecimal('8.7').round #=> 9
- * BigDecimal('-9.9').round #=> -10
- *
- * BigDecimal('3.14159').round(2).class.name #=> "BigDecimal"
- * BigDecimal('3.14159').round.class.name #=> "Integer"
- *
- * If n is specified and positive, the fractional part of the result has no
- * more than that many digits.
- *
- * If n is specified and negative, at least that many digits to the left of the
- * decimal point will be 0 in the result, and return value will be an Integer.
- *
- * BigDecimal('3.14159').round(3) #=> 3.142
- * BigDecimal('13345.234').round(-2) #=> 13300
- *
- * The value of the optional mode argument can be used to determine how
- * rounding is performed; see BigDecimal.mode.
- */
-static VALUE
-BigDecimal_round(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- int iLoc = 0;
- VALUE vLoc;
- VALUE vRound;
- int round_to_int = 0;
- size_t mx, pl;
-
- unsigned short sw = VpGetRoundMode();
-
- switch (rb_scan_args(argc, argv, "02", &vLoc, &vRound)) {
- case 0:
- iLoc = 0;
- round_to_int = 1;
- break;
- case 1:
- if (RB_TYPE_P(vLoc, T_HASH)) {
- sw = check_rounding_mode_option(vLoc);
- }
- else {
- iLoc = NUM2INT(vLoc);
- if (iLoc < 1) round_to_int = 1;
- }
- break;
- case 2:
- iLoc = NUM2INT(vLoc);
- if (RB_TYPE_P(vRound, T_HASH)) {
- sw = check_rounding_mode_option(vRound);
- }
- else {
- sw = check_rounding_mode(vRound);
- }
- break;
- default:
- break;
- }
-
- pl = VpSetPrecLimit(0);
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpSetPrecLimit(pl);
- VpActiveRound(c, a, sw, iLoc);
- if (round_to_int) {
- return BigDecimal_to_i(VpCheckGetValue(c));
- }
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * truncate(n)
- *
- * Truncate to the nearest integer (by default), returning the result as a
- * BigDecimal.
- *
- * BigDecimal('3.14159').truncate #=> 3
- * BigDecimal('8.7').truncate #=> 8
- * BigDecimal('-9.9').truncate #=> -9
- *
- * If n is specified and positive, the fractional part of the result has no
- * more than that many digits.
- *
- * If n is specified and negative, at least that many digits to the left of the
- * decimal point will be 0 in the result.
- *
- * BigDecimal('3.14159').truncate(3) #=> 3.141
- * BigDecimal('13345.234').truncate(-2) #=> 13300.0
- */
-static VALUE
-BigDecimal_truncate(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- int iLoc;
- VALUE vLoc;
- size_t mx, pl = VpSetPrecLimit(0);
-
- if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
- iLoc = 0;
- }
- else {
- iLoc = NUM2INT(vLoc);
- }
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpSetPrecLimit(pl);
- VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */
- if (argc == 0) {
- return BigDecimal_to_i(VpCheckGetValue(c));
- }
- return VpCheckGetValue(c);
-}
-
-/* Return the fractional part of the number, as a BigDecimal.
- */
-static VALUE
-BigDecimal_frac(VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- size_t mx;
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpFrac(c, a);
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * floor(n)
- *
- * Return the largest integer less than or equal to the value, as a BigDecimal.
- *
- * BigDecimal('3.14159').floor #=> 3
- * BigDecimal('-9.1').floor #=> -10
- *
- * If n is specified and positive, the fractional part of the result has no
- * more than that many digits.
- *
- * If n is specified and negative, at least that
- * many digits to the left of the decimal point will be 0 in the result.
- *
- * BigDecimal('3.14159').floor(3) #=> 3.141
- * BigDecimal('13345.234').floor(-2) #=> 13300.0
- */
-static VALUE
-BigDecimal_floor(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- int iLoc;
- VALUE vLoc;
- size_t mx, pl = VpSetPrecLimit(0);
-
- if (rb_scan_args(argc, argv, "01", &vLoc)==0) {
- iLoc = 0;
- }
- else {
- iLoc = NUM2INT(vLoc);
- }
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpSetPrecLimit(pl);
- VpActiveRound(c, a, VP_ROUND_FLOOR, iLoc);
-#ifdef BIGDECIMAL_DEBUG
- VPrint(stderr, "floor: c=%\n", c);
-#endif
- if (argc == 0) {
- return BigDecimal_to_i(VpCheckGetValue(c));
- }
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * ceil(n)
- *
- * Return the smallest integer greater than or equal to the value, as a BigDecimal.
- *
- * BigDecimal('3.14159').ceil #=> 4
- * BigDecimal('-9.1').ceil #=> -9
- *
- * If n is specified and positive, the fractional part of the result has no
- * more than that many digits.
- *
- * If n is specified and negative, at least that
- * many digits to the left of the decimal point will be 0 in the result.
- *
- * BigDecimal('3.14159').ceil(3) #=> 3.142
- * BigDecimal('13345.234').ceil(-2) #=> 13400.0
- */
-static VALUE
-BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- Real *c, *a;
- int iLoc;
- VALUE vLoc;
- size_t mx, pl = VpSetPrecLimit(0);
-
- if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
- iLoc = 0;
- } else {
- iLoc = NUM2INT(vLoc);
- }
-
- GUARD_OBJ(a, GetVpValue(self, 1));
- mx = a->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
- VpSetPrecLimit(pl);
- VpActiveRound(c, a, VP_ROUND_CEIL, iLoc);
- if (argc == 0) {
- return BigDecimal_to_i(VpCheckGetValue(c));
- }
- return VpCheckGetValue(c);
-}
-
-/* call-seq:
- * to_s(s)
- *
- * Converts the value to a string.
- *
- * The default format looks like 0.xxxxEnn.
- *
- * The optional parameter s consists of either an integer; or an optional '+'
- * or ' ', followed by an optional number, followed by an optional 'E' or 'F'.
- *
- * If there is a '+' at the start of s, positive values are returned with
- * a leading '+'.
- *
- * A space at the start of s returns positive values with a leading space.
- *
- * If s contains a number, a space is inserted after each group of that many
- * fractional digits.
- *
- * If s ends with an 'E', engineering notation (0.xxxxEnn) is used.
- *
- * If s ends with an 'F', conventional floating point notation is used.
- *
- * Examples:
- *
- * BigDecimal('-123.45678901234567890').to_s('5F')
- * #=> '-123.45678 90123 45678 9'
- *
- * BigDecimal('123.45678901234567890').to_s('+8F')
- * #=> '+123.45678901 23456789'
- *
- * BigDecimal('123.45678901234567890').to_s(' F')
- * #=> ' 123.4567890123456789'
- */
-static VALUE
-BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
-{
- ENTER(5);
- int fmt = 0; /* 0: E format, 1: F format */
- int fPlus = 0; /* 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
- Real *vp;
- volatile VALUE str;
- char *psz;
- char ch;
- size_t nc, mc = 0;
- SIGNED_VALUE m;
- VALUE f;
-
- GUARD_OBJ(vp, GetVpValue(self, 1));
-
- if (rb_scan_args(argc, argv, "01", &f) == 1) {
- if (RB_TYPE_P(f, T_STRING)) {
- psz = StringValueCStr(f);
- if (*psz == ' ') {
- fPlus = 1;
- psz++;
- }
- else if (*psz == '+') {
- fPlus = 2;
- psz++;
- }
- while ((ch = *psz++) != 0) {
- if (ISSPACE(ch)) {
- continue;
- }
- if (!ISDIGIT(ch)) {
- if (ch == 'F' || ch == 'f') {
- fmt = 1; /* F format */
- }
- break;
- }
- mc = mc*10 + ch - '0';
- }
- }
- else {
- m = NUM2INT(f);
- if (m <= 0) {
- rb_raise(rb_eArgError, "argument must be positive");
- }
- mc = (size_t)m;
- }
- }
- if (fmt) {
- nc = VpNumOfChars(vp, "F");
- }
- else {
- nc = VpNumOfChars(vp, "E");
- }
- if (mc > 0) {
- nc += (nc + mc - 1) / mc + 1;
- }
-
- str = rb_usascii_str_new(0, nc);
- psz = RSTRING_PTR(str);
-
- if (fmt) {
- VpToFString(vp, psz, RSTRING_LEN(str), mc, fPlus);
- }
- else {
- VpToString (vp, psz, RSTRING_LEN(str), mc, fPlus);
- }
- rb_str_resize(str, strlen(psz));
- return str;
-}
-
-/* Splits a BigDecimal number into four parts, returned as an array of values.
- *
- * The first value represents the sign of the BigDecimal, and is -1 or 1, or 0
- * if the BigDecimal is Not a Number.
- *
- * The second value is a string representing the significant digits of the
- * BigDecimal, with no leading zeros.
- *
- * The third value is the base used for arithmetic (currently always 10) as an
- * Integer.
- *
- * The fourth value is an Integer exponent.
- *
- * If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the
- * string of significant digits with no leading zeros, and n is the exponent.
- *
- * From these values, you can translate a BigDecimal to a float as follows:
- *
- * sign, significant_digits, base, exponent = a.split
- * f = sign * "0.#{significant_digits}".to_f * (base ** exponent)
- *
- * (Note that the to_f method is provided as a more convenient way to translate
- * a BigDecimal to a Float.)
- */
-static VALUE
-BigDecimal_split(VALUE self)
-{
- ENTER(5);
- Real *vp;
- VALUE obj,str;
- ssize_t e, s;
- char *psz1;
-
- GUARD_OBJ(vp, GetVpValue(self, 1));
- str = rb_str_new(0, VpNumOfChars(vp, "E"));
- psz1 = RSTRING_PTR(str);
- VpSzMantissa(vp, psz1, RSTRING_LEN(str));
- s = 1;
- if(psz1[0] == '-') {
- size_t len = strlen(psz1 + 1);
-
- memmove(psz1, psz1 + 1, len);
- psz1[len] = '\0';
- s = -1;
- }
- if (psz1[0] == 'N') s = 0; /* NaN */
- e = VpExponent10(vp);
- obj = rb_ary_new2(4);
- rb_ary_push(obj, INT2FIX(s));
- rb_ary_push(obj, str);
- rb_str_resize(str, strlen(psz1));
- rb_ary_push(obj, INT2FIX(10));
- rb_ary_push(obj, SSIZET2NUM(e));
- return obj;
-}
-
-/* Returns the exponent of the BigDecimal number, as an Integer.
- *
- * If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string
- * of digits with no leading zeros, then n is the exponent.
- */
-static VALUE
-BigDecimal_exponent(VALUE self)
-{
- ssize_t e = VpExponent10(GetVpValue(self, 1));
- return SSIZET2NUM(e);
-}
-
-/* Returns a string representation of self.
- *
- * BigDecimal("1234.5678").inspect
- * #=> "0.12345678e4"
- */
-static VALUE
-BigDecimal_inspect(VALUE self)
-{
- ENTER(5);
- Real *vp;
- volatile VALUE str;
- size_t nc;
-
- GUARD_OBJ(vp, GetVpValue(self, 1));
- nc = VpNumOfChars(vp, "E");
-
- str = rb_str_new(0, nc);
- VpToString(vp, RSTRING_PTR(str), RSTRING_LEN(str), 0, 0);
- rb_str_resize(str, strlen(RSTRING_PTR(str)));
- return str;
-}
-
-static VALUE BigMath_s_exp(VALUE, VALUE, VALUE);
-static VALUE BigMath_s_log(VALUE, VALUE, VALUE);
-
-#define BigMath_exp(x, n) BigMath_s_exp(rb_mBigMath, (x), (n))
-#define BigMath_log(x, n) BigMath_s_log(rb_mBigMath, (x), (n))
-
-inline static int
-is_integer(VALUE x)
-{
- return (RB_TYPE_P(x, T_FIXNUM) || RB_TYPE_P(x, T_BIGNUM));
-}
-
-inline static int
-is_negative(VALUE x)
-{
- if (FIXNUM_P(x)) {
- return FIX2LONG(x) < 0;
- }
- else if (RB_TYPE_P(x, T_BIGNUM)) {
- return FIX2INT(rb_big_cmp(x, INT2FIX(0))) < 0;
- }
- else if (RB_TYPE_P(x, T_FLOAT)) {
- return RFLOAT_VALUE(x) < 0.0;
- }
- return RTEST(rb_funcall(x, '<', 1, INT2FIX(0)));
-}
-
-#define is_positive(x) (!is_negative(x))
-
-inline static int
-is_zero(VALUE x)
-{
- VALUE num;
-
- switch (TYPE(x)) {
- case T_FIXNUM:
- return FIX2LONG(x) == 0;
-
- case T_BIGNUM:
- return Qfalse;
-
- case T_RATIONAL:
- num = rb_rational_num(x);
- return FIXNUM_P(num) && FIX2LONG(num) == 0;
-
- default:
- break;
- }
-
- return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(0)));
-}
-
-inline static int
-is_one(VALUE x)
-{
- VALUE num, den;
-
- switch (TYPE(x)) {
- case T_FIXNUM:
- return FIX2LONG(x) == 1;
-
- case T_BIGNUM:
- return Qfalse;
-
- case T_RATIONAL:
- num = rb_rational_num(x);
- den = rb_rational_den(x);
- return FIXNUM_P(den) && FIX2LONG(den) == 1 &&
- FIXNUM_P(num) && FIX2LONG(num) == 1;
-
- default:
- break;
- }
-
- return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(1)));
-}
-
-inline static int
-is_even(VALUE x)
-{
- switch (TYPE(x)) {
- case T_FIXNUM:
- return (FIX2LONG(x) % 2) == 0;
-
- case T_BIGNUM:
- {
- unsigned long l;
- rb_big_pack(x, &l, 1);
- return l % 2 == 0;
- }
-
- default:
- break;
- }
-
- return 0;
-}
-
-static VALUE
-bigdecimal_power_by_bigdecimal(Real const* x, Real const* exp, ssize_t const n)
-{
- VALUE log_x, multiplied, y;
- volatile VALUE obj = exp->obj;
-
- if (VpIsZero(exp)) {
- return VpCheckGetValue(NewOneWrapLimited(1, n));
- }
-
- log_x = BigMath_log(x->obj, SSIZET2NUM(n+1));
- multiplied = BigDecimal_mult2(exp->obj, log_x, SSIZET2NUM(n+1));
- y = BigMath_exp(multiplied, SSIZET2NUM(n));
- RB_GC_GUARD(obj);
-
- return y;
-}
-
-/* call-seq:
- * power(n)
- * power(n, prec)
- *
- * Returns the value raised to the power of n.
- *
- * Note that n must be an Integer.
- *
- * Also available as the operator **.
- */
-static VALUE
-BigDecimal_power(int argc, VALUE*argv, VALUE self)
-{
- ENTER(5);
- VALUE vexp, prec;
- Real* exp = NULL;
- Real *x, *y;
- ssize_t mp, ma, n;
- SIGNED_VALUE int_exp;
- double d;
-
- rb_scan_args(argc, argv, "11", &vexp, &prec);
-
- GUARD_OBJ(x, GetVpValue(self, 1));
- n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec);
-
- if (VpIsNaN(x)) {
- y = NewZeroWrapLimited(1, n);
- VpSetNaN(y);
- RB_GC_GUARD(y->obj);
- return VpCheckGetValue(y);
- }
-
- retry:
- switch (TYPE(vexp)) {
- case T_FIXNUM:
- break;
-
- case T_BIGNUM:
- break;
-
- case T_FLOAT:
- d = RFLOAT_VALUE(vexp);
- if (d == round(d)) {
- if (FIXABLE(d)) {
- vexp = LONG2FIX((long)d);
- }
- else {
- vexp = rb_dbl2big(d);
- }
- goto retry;
- }
- if (NIL_P(prec)) {
- n += BIGDECIMAL_DOUBLE_FIGURES;
- }
- exp = GetVpValueWithPrec(vexp, 0, 1);
- break;
-
- case T_RATIONAL:
- if (is_zero(rb_rational_num(vexp))) {
- if (is_positive(vexp)) {
- vexp = INT2FIX(0);
- goto retry;
- }
- }
- else if (is_one(rb_rational_den(vexp))) {
- vexp = rb_rational_num(vexp);
- goto retry;
- }
- exp = GetVpValueWithPrec(vexp, n, 1);
- if (NIL_P(prec)) {
- n += n;
- }
- break;
-
- case T_DATA:
- if (is_kind_of_BigDecimal(vexp)) {
- VALUE zero = INT2FIX(0);
- VALUE rounded = BigDecimal_round(1, &zero, vexp);
- if (RTEST(BigDecimal_eq(vexp, rounded))) {
- vexp = BigDecimal_to_i(vexp);
- goto retry;
- }
- if (NIL_P(prec)) {
- GUARD_OBJ(y, GetVpValue(vexp, 1));
- n += y->Prec*VpBaseFig();
- }
- exp = DATA_PTR(vexp);
- break;
- }
- /* fall through */
- default:
- rb_raise(rb_eTypeError,
- "wrong argument type %"PRIsVALUE" (expected scalar Numeric)",
- RB_OBJ_CLASSNAME(vexp));
- }
-
- if (VpIsZero(x)) {
- if (is_negative(vexp)) {
- y = NewZeroWrapNolimit(1, n);
- if (BIGDECIMAL_NEGATIVE_P(x)) {
- if (is_integer(vexp)) {
- if (is_even(vexp)) {
- /* (-0) ** (-even_integer) -> Infinity */
- VpSetPosInf(y);
- }
- else {
- /* (-0) ** (-odd_integer) -> -Infinity */
- VpSetNegInf(y);
- }
- }
- else {
- /* (-0) ** (-non_integer) -> Infinity */
- VpSetPosInf(y);
- }
- }
- else {
- /* (+0) ** (-num) -> Infinity */
- VpSetPosInf(y);
- }
- RB_GC_GUARD(y->obj);
- return VpCheckGetValue(y);
- }
- else if (is_zero(vexp)) {
- return VpCheckGetValue(NewOneWrapLimited(1, n));
- }
- else {
- return VpCheckGetValue(NewZeroWrapLimited(1, n));
- }
- }
-
- if (is_zero(vexp)) {
- return VpCheckGetValue(NewOneWrapLimited(1, n));
- }
- else if (is_one(vexp)) {
- return self;
- }
-
- if (VpIsInf(x)) {
- if (is_negative(vexp)) {
- if (BIGDECIMAL_NEGATIVE_P(x)) {
- if (is_integer(vexp)) {
- if (is_even(vexp)) {
- /* (-Infinity) ** (-even_integer) -> +0 */
- return VpCheckGetValue(NewZeroWrapLimited(1, n));
- }
- else {
- /* (-Infinity) ** (-odd_integer) -> -0 */
- return VpCheckGetValue(NewZeroWrapLimited(-1, n));
- }
- }
- else {
- /* (-Infinity) ** (-non_integer) -> -0 */
- return VpCheckGetValue(NewZeroWrapLimited(-1, n));
- }
- }
- else {
- return VpCheckGetValue(NewZeroWrapLimited(1, n));
- }
- }
- else {
- y = NewZeroWrapLimited(1, n);
- if (BIGDECIMAL_NEGATIVE_P(x)) {
- if (is_integer(vexp)) {
- if (is_even(vexp)) {
- VpSetPosInf(y);
- }
- else {
- VpSetNegInf(y);
- }
- }
- else {
- /* TODO: support complex */
- rb_raise(rb_eMathDomainError,
- "a non-integral exponent for a negative base");
- }
- }
- else {
- VpSetPosInf(y);
- }
- return VpCheckGetValue(y);
- }
- }
-
- if (exp != NULL) {
- return bigdecimal_power_by_bigdecimal(x, exp, n);
- }
- else if (RB_TYPE_P(vexp, T_BIGNUM)) {
- VALUE abs_value = BigDecimal_abs(self);
- if (is_one(abs_value)) {
- return VpCheckGetValue(NewOneWrapLimited(1, n));
- }
- else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) {
- if (is_negative(vexp)) {
- y = NewZeroWrapLimited(1, n);
- VpSetInf(y, (is_even(vexp) ? 1 : -1) * VpGetSign(x));
- return VpCheckGetValue(y);
- }
- else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) {
- return VpCheckGetValue(NewZeroWrapLimited(-1, n));
- }
- else {
- return VpCheckGetValue(NewZeroWrapLimited(1, n));
- }
- }
- else {
- if (is_positive(vexp)) {
- y = NewZeroWrapLimited(1, n);
- VpSetInf(y, (is_even(vexp) ? 1 : -1) * VpGetSign(x));
- return VpCheckGetValue(y);
- }
- else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) {
- return VpCheckGetValue(NewZeroWrapLimited(-1, n));
- }
- else {
- return VpCheckGetValue(NewZeroWrapLimited(1, n));
- }
- }
- }
-
- int_exp = FIX2LONG(vexp);
- ma = int_exp;
- if (ma < 0) ma = -ma;
- if (ma == 0) ma = 1;
-
- if (VpIsDef(x)) {
- mp = x->Prec * (VpBaseFig() + 1);
- GUARD_OBJ(y, NewZeroWrapLimited(1, mp * (ma + 1)));
- }
- else {
- GUARD_OBJ(y, NewZeroWrapLimited(1, 1));
- }
- VpPowerByInt(y, x, int_exp);
- if (!NIL_P(prec) && VpIsDef(y)) {
- VpMidRound(y, VpGetRoundMode(), n);
- }
- return VpCheckGetValue(y);
-}
-
-/* call-seq:
- * self ** other -> bigdecimal
- *
- * Returns the \BigDecimal value of +self+ raised to power +other+:
- *
- * b = BigDecimal('3.14')
- * b ** 2 # => 0.98596e1
- * b ** 2.0 # => 0.98596e1
- * b ** Rational(2, 1) # => 0.98596e1
- *
- * Related: BigDecimal#power.
- *
- */
-static VALUE
-BigDecimal_power_op(VALUE self, VALUE exp)
-{
- return BigDecimal_power(1, &exp, self);
-}
-
-/* :nodoc:
- *
- * private method for dup and clone the provided BigDecimal +other+
- */
-static VALUE
-BigDecimal_initialize_copy(VALUE self, VALUE other)
-{
- Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
- Real *x = rb_check_typeddata(other, &BigDecimal_data_type);
-
- if (self != other) {
- DATA_PTR(self) = VpCopy(pv, x);
- }
- return self;
-}
-
-static VALUE
-BigDecimal_clone(VALUE self)
-{
- return self;
-}
-
-#ifdef HAVE_RB_OPTS_EXCEPTION_P
-int rb_opts_exception_p(VALUE opts, int default_value);
-#define opts_exception_p(opts) rb_opts_exception_p((opts), 1)
-#else
-static int
-opts_exception_p(VALUE opts)
-{
- static ID kwds[1];
- VALUE exception;
- if (!kwds[0]) {
- kwds[0] = rb_intern_const("exception");
- }
- if (!rb_get_kwargs(opts, kwds, 0, 1, &exception)) return 1;
- switch (exception) {
- case Qtrue: case Qfalse:
- break;
- default:
- rb_raise(rb_eArgError, "true or false is expected as exception: %+"PRIsVALUE,
- exception);
- }
- return exception != Qfalse;
-}
-#endif
-
-static VALUE
-check_exception(VALUE bd)
-{
- assert(is_kind_of_BigDecimal(bd));
-
- Real *vp;
- TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp);
- VpCheckGetValue(vp); /* VpCheckGetValue performs exception check */
-
- return bd;
-}
-
-static VALUE
-rb_uint64_convert_to_BigDecimal(uint64_t uval, RB_UNUSED_VAR(size_t digs), int raise_exception)
-{
- VALUE obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
-
- Real *vp;
- if (uval == 0) {
- vp = rbd_allocate_struct(1);
- vp->MaxPrec = 1;
- vp->Prec = 1;
- vp->exponent = 1;
- VpSetZero(vp, 1);
- vp->frac[0] = 0;
- }
- else if (uval < BASE) {
- vp = rbd_allocate_struct(1);
- vp->MaxPrec = 1;
- vp->Prec = 1;
- vp->exponent = 1;
- VpSetSign(vp, 1);
- vp->frac[0] = (DECDIG)uval;
- }
- else {
- DECDIG buf[BIGDECIMAL_INT64_MAX_LENGTH] = {0,};
- DECDIG r = uval % BASE;
- size_t len = 0, ntz = 0;
- if (r == 0) {
- // Count and skip trailing zeros
- for (; r == 0 && uval > 0; ++ntz) {
- uval /= BASE;
- r = uval % BASE;
- }
- }
- for (; uval > 0; ++len) {
- // Store digits
- buf[BIGDECIMAL_INT64_MAX_LENGTH - len - 1] = r;
- uval /= BASE;
- r = uval % BASE;
- }
-
- const size_t exp = len + ntz;
- vp = rbd_allocate_struct(len);
- vp->MaxPrec = len;
- vp->Prec = len;
- vp->exponent = exp;
- VpSetSign(vp, 1);
- MEMCPY(vp->frac, buf + BIGDECIMAL_INT64_MAX_LENGTH - len, DECDIG, len);
- }
-
- return BigDecimal_wrap_struct(obj, vp);
-}
-
-static VALUE
-rb_int64_convert_to_BigDecimal(int64_t ival, size_t digs, int raise_exception)
-{
- const uint64_t uval = (ival < 0) ? (((uint64_t)-(ival+1))+1) : (uint64_t)ival;
- VALUE bd = rb_uint64_convert_to_BigDecimal(uval, digs, raise_exception);
- if (ival < 0) {
- Real *vp;
- TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp);
- VpSetSign(vp, -1);
- }
- return bd;
-}
-
-static VALUE
-rb_big_convert_to_BigDecimal(VALUE val, RB_UNUSED_VAR(size_t digs), int raise_exception)
-{
- assert(RB_TYPE_P(val, T_BIGNUM));
-
- int leading_zeros;
- size_t size = rb_absint_size(val, &leading_zeros);
- int sign = FIX2INT(rb_big_cmp(val, INT2FIX(0)));
- if (sign < 0 && leading_zeros == 0) {
- size += 1;
- }
- if (size <= sizeof(long)) {
- if (sign < 0) {
- return rb_int64_convert_to_BigDecimal(NUM2LONG(val), digs, raise_exception);
- }
- else {
- return rb_uint64_convert_to_BigDecimal(NUM2ULONG(val), digs, raise_exception);
- }
- }
-#if defined(SIZEOF_LONG_LONG) && SIZEOF_LONG < SIZEOF_LONG_LONG
- else if (size <= sizeof(LONG_LONG)) {
- if (sign < 0) {
- return rb_int64_convert_to_BigDecimal(NUM2LL(val), digs, raise_exception);
- }
- else {
- return rb_uint64_convert_to_BigDecimal(NUM2ULL(val), digs, raise_exception);
- }
- }
-#endif
- else {
- VALUE str = rb_big2str(val, 10);
- Real *vp = VpCreateRbObject(RSTRING_LEN(str) + BASE_FIG + 1,
- RSTRING_PTR(str), true);
- RB_GC_GUARD(str);
- return check_exception(vp->obj);
- }
-}
-
-static VALUE
-rb_inum_convert_to_BigDecimal(VALUE val, RB_UNUSED_VAR(size_t digs), int raise_exception)
-{
- assert(RB_INTEGER_TYPE_P(val));
- if (FIXNUM_P(val)) {
- return rb_int64_convert_to_BigDecimal(FIX2LONG(val), digs, raise_exception);
- }
- else {
- return rb_big_convert_to_BigDecimal(val, digs, raise_exception);
- }
-}
-
-static VALUE
-rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
-{
- assert(RB_FLOAT_TYPE_P(val));
-
- double d = RFLOAT_VALUE(val);
-
- if (isnan(d)) {
- VALUE obj = BigDecimal_nan();
- return check_exception(obj);
- }
- else if (isinf(d)) {
- VALUE obj;
- if (d > 0) {
- obj = BigDecimal_positive_infinity();
- }
- else {
- obj = BigDecimal_negative_infinity();
- }
- return check_exception(obj);
- }
- else if (d == 0.0) {
- if (1/d < 0.0) {
- return BigDecimal_negative_zero();
- }
- else {
- return BigDecimal_positive_zero();
- }
- }
-
- if (digs == SIZE_MAX) {
- if (!raise_exception)
- return Qnil;
- rb_raise(rb_eArgError,
- "can't omit precision for a %"PRIsVALUE".",
- CLASS_OF(val));
- }
- else if (digs > BIGDECIMAL_DOUBLE_FIGURES) {
- if (!raise_exception)
- return Qnil;
- rb_raise(rb_eArgError, "precision too large.");
- }
-
- /* Use the same logic in flo_to_s to convert a float to a decimal string */
- char buf[BIGDECIMAL_DOUBLE_FIGURES + BASE_FIG + 2 + 1]; /* sizeof(buf) == 28 in the typical case */
- int decpt, negative_p;
- char *e;
- const int mode = digs == 0 ? 0 : 2;
- char *p = BigDecimal_dtoa(d, mode, (int)digs, &decpt, &negative_p, &e);
- int len10 = (int)(e - p);
- if (len10 > BIGDECIMAL_DOUBLE_FIGURES) {
- /* TODO: Presumably, rounding should be done here. */
- len10 = BIGDECIMAL_DOUBLE_FIGURES;
- }
- memcpy(buf, p, len10);
- xfree(p);
-
- VALUE inum;
- size_t RB_UNUSED_VAR(prec) = 0;
- SIGNED_VALUE exp = 0;
- if (decpt > 0) {
- if (decpt < len10) {
- /*
- * len10 |---------------|
- * : |-------| frac_len10 = len10 - decpt
- * decpt |-------| |--| ntz10 = BASE_FIG - frac_len10 % BASE_FIG
- * : : :
- * 00 dd dddd.dddd dd 00
- * prec |-----.----.----.-----| prec = exp + roomof(frac_len, BASE_FIG)
- * exp |-----.----| exp = roomof(decpt, BASE_FIG)
- */
- const size_t frac_len10 = len10 - decpt;
- const size_t ntz10 = BASE_FIG - frac_len10 % BASE_FIG;
- memset(buf + len10, '0', ntz10);
- buf[len10 + ntz10] = '\0';
- inum = rb_cstr_to_inum(buf, 10, false);
-
- exp = roomof(decpt, BASE_FIG);
- prec = exp + roomof(frac_len10, BASE_FIG);
- }
- else {
- /*
- * decpt |-----------------------|
- * len10 |----------| :
- * : |------------| exp10
- * : : :
- * 00 dd dddd dd 00 0000 0000.0
- * : : : :
- * : |--| ntz10 = exp10 % BASE_FIG
- * prec |-----.----.-----| :
- * : |----.----| exp10 / BASE_FIG
- * exp |-----.----.-----.----.----|
- */
- const size_t exp10 = decpt - len10;
- const size_t ntz10 = exp10 % BASE_FIG;
-
- memset(buf + len10, '0', ntz10);
- buf[len10 + ntz10] = '\0';
- inum = rb_cstr_to_inum(buf, 10, false);
-
- prec = roomof(len10 + ntz10, BASE_FIG);
- exp = prec + exp10 / BASE_FIG;
- }
- }
- else if (decpt == 0) {
- /*
- * len10 |------------|
- * : :
- * 0.dddd dddd dd 00
- * : : :
- * : |--| ntz10 = prec * BASE_FIG - len10
- * prec |----.----.-----| roomof(len10, BASE_FIG)
- */
- prec = roomof(len10, BASE_FIG);
- const size_t ntz10 = prec * BASE_FIG - len10;
-
- memset(buf + len10, '0', ntz10);
- buf[len10 + ntz10] = '\0';
- inum = rb_cstr_to_inum(buf, 10, false);
- }
- else {
- /*
- * len10 |---------------|
- * : :
- * decpt |-------| |--| ntz10 = prec * BASE_FIG - nlz10 - len10
- * : : :
- * 0.0000 00 dd dddd dddd dd 00
- * : : :
- * nlz10 |--| : decpt % BASE_FIG
- * prec |-----.----.----.-----| roomof(decpt + len10, BASE_FIG) - exp
- * exp |----| decpt / BASE_FIG
- */
- decpt = -decpt;
-
- const size_t nlz10 = decpt % BASE_FIG;
- exp = decpt / BASE_FIG;
- prec = roomof(decpt + len10, BASE_FIG) - exp;
- const size_t ntz10 = prec * BASE_FIG - nlz10 - len10;
-
- if (nlz10 > 0) {
- memmove(buf + nlz10, buf, len10);
- memset(buf, '0', nlz10);
- }
- memset(buf + nlz10 + len10, '0', ntz10);
- buf[nlz10 + len10 + ntz10] = '\0';
- inum = rb_cstr_to_inum(buf, 10, false);
-
- exp = -exp;
- }
-
- VALUE bd = rb_inum_convert_to_BigDecimal(inum, SIZE_MAX, raise_exception);
- Real *vp;
- TypedData_Get_Struct(bd, Real, &BigDecimal_data_type, vp);
- assert(vp->Prec == prec);
- vp->exponent = exp;
-
- if (negative_p) VpSetSign(vp, -1);
- return bd;
-}
-
-static VALUE
-rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
-{
- assert(RB_TYPE_P(val, T_RATIONAL));
-
- if (digs == SIZE_MAX) {
- if (!raise_exception)
- return Qnil;
- rb_raise(rb_eArgError,
- "can't omit precision for a %"PRIsVALUE".",
- CLASS_OF(val));
- }
-
- VALUE num = rb_inum_convert_to_BigDecimal(rb_rational_num(val), 0, raise_exception);
- VALUE d = BigDecimal_div2(num, rb_rational_den(val), SIZET2NUM(digs));
- return d;
-}
-
-static VALUE
-rb_cstr_convert_to_BigDecimal(const char *c_str, size_t digs, int raise_exception)
-{
- if (digs == SIZE_MAX)
- digs = 0;
-
- Real *vp = VpCreateRbObject(digs, c_str, raise_exception);
- if (!vp)
- return Qnil;
- return VpCheckGetValue(vp);
-}
-
-static inline VALUE
-rb_str_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
-{
- const char *c_str = StringValueCStr(val);
- return rb_cstr_convert_to_BigDecimal(c_str, digs, raise_exception);
-}
-
-static VALUE
-rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
-{
- switch (val) {
- case Qnil:
- case Qtrue:
- case Qfalse:
- if (raise_exception) {
- const char *cname = NIL_P(val) ? "nil" :
- val == Qtrue ? "true" :
- val == Qfalse ? "false" :
- NULL;
- rb_raise(rb_eTypeError,
- "can't convert %s into BigDecimal", cname);
- }
- return Qnil;
-
- default:
- break;
- }
-
- if (is_kind_of_BigDecimal(val)) {
- if (digs == SIZE_MAX)
- return check_exception(val);
-
- Real *vp;
- TypedData_Get_Struct(val, Real, &BigDecimal_data_type, vp);
-
- VALUE copy = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
- vp = VpCopy(NULL, vp);
- /* TODO: rounding */
- BigDecimal_wrap_struct(copy, vp);
- return VpCheckGetValue(vp);
- }
- else if (RB_INTEGER_TYPE_P(val)) {
- return rb_inum_convert_to_BigDecimal(val, digs, raise_exception);
- }
- else if (RB_FLOAT_TYPE_P(val)) {
- return rb_float_convert_to_BigDecimal(val, digs, raise_exception);
- }
- else if (RB_TYPE_P(val, T_RATIONAL)) {
- return rb_rational_convert_to_BigDecimal(val, digs, raise_exception);
- }
- else if (RB_TYPE_P(val, T_COMPLEX)) {
- VALUE im = rb_complex_imag(val);
- if (!is_zero(im)) {
- /* TODO: handle raise_exception */
- rb_raise(rb_eArgError,
- "Unable to make a BigDecimal from non-zero imaginary number");
- }
- return rb_convert_to_BigDecimal(rb_complex_real(val), digs, raise_exception);
- }
- else if (RB_TYPE_P(val, T_STRING)) {
- return rb_str_convert_to_BigDecimal(val, digs, raise_exception);
- }
-
- /* TODO: chheck to_d */
- /* TODO: chheck to_int */
-
- VALUE str = rb_check_convert_type(val, T_STRING, "String", "to_str");
- if (!RB_TYPE_P(str, T_STRING)) {
- if (raise_exception) {
- rb_raise(rb_eTypeError,
- "can't convert %"PRIsVALUE" into BigDecimal", rb_obj_class(val));
- }
- return Qnil;
- }
- return rb_str_convert_to_BigDecimal(str, digs, raise_exception);
-}
-
-/* call-seq:
- * BigDecimal(value, exception: true) -> bigdecimal
- * BigDecimal(value, ndigits, exception: true) -> bigdecimal
- *
- * Returns the \BigDecimal converted from +value+
- * with a precision of +ndigits+ decimal digits.
- *
- * When +ndigits+ is less than the number of significant digits
- * in the value, the result is rounded to that number of digits,
- * according to the current rounding mode; see BigDecimal.mode.
- *
- * When +ndigits+ is 0, the number of digits to correctly represent a float number
- * is determined automatically.
- *
- * Returns +value+ converted to a \BigDecimal, depending on the type of +value+:
- *
- * - Integer, Float, Rational, Complex, or BigDecimal: converted directly:
- *
- * # Integer, Complex, or BigDecimal value does not require ndigits; ignored if given.
- * BigDecimal(2) # => 0.2e1
- * BigDecimal(Complex(2, 0)) # => 0.2e1
- * BigDecimal(BigDecimal(2)) # => 0.2e1
- * # Float or Rational value requires ndigits.
- * BigDecimal(2.0, 0) # => 0.2e1
- * BigDecimal(Rational(2, 1), 0) # => 0.2e1
- *
- * - String: converted by parsing if it contains an integer or floating-point literal;
- * leading and trailing whitespace is ignored:
- *
- * # String does not require ndigits; ignored if given.
- * BigDecimal('2') # => 0.2e1
- * BigDecimal('2.0') # => 0.2e1
- * BigDecimal('0.2e1') # => 0.2e1
- * BigDecimal(' 2.0 ') # => 0.2e1
- *
- * - Other type that responds to method <tt>:to_str</tt>:
- * first converted to a string, then converted to a \BigDecimal, as above.
- *
- * - Other type:
- *
- * - Raises an exception if keyword argument +exception+ is +true+.
- * - Returns +nil+ if keyword argument +exception+ is +true+.
- *
- * Raises an exception if +value+ evaluates to a Float
- * and +digits+ is larger than Float::DIG + 1.
- *
- */
-static VALUE
-f_BigDecimal(int argc, VALUE *argv, VALUE self)
-{
- VALUE val, digs_v, opts = Qnil;
- argc = rb_scan_args(argc, argv, "11:", &val, &digs_v, &opts);
- int exception = opts_exception_p(opts);
-
- size_t digs = SIZE_MAX; /* this means digs is omitted */
- if (argc > 1) {
- digs_v = rb_to_int(digs_v);
- if (FIXNUM_P(digs_v)) {
- long n = FIX2LONG(digs_v);
- if (n < 0)
- goto negative_digs;
- digs = (size_t)n;
- }
- else {
- if (RBIGNUM_NEGATIVE_P(digs_v)) {
- negative_digs:
- if (!exception)
- return Qnil;
- rb_raise(rb_eArgError, "negative precision");
- }
- digs = NUM2SIZET(digs_v);
- }
- }
-
- return rb_convert_to_BigDecimal(val, digs, exception);
-}
-
-static VALUE
-BigDecimal_s_interpret_loosely(VALUE klass, VALUE str)
-{
- char const *c_str = StringValueCStr(str);
- Real *vp = VpNewRbClass(0, c_str, klass, false, true);
- if (!vp)
- return Qnil;
- else
- return VpCheckGetValue(vp);
-}
-
- /* call-seq:
- * BigDecimal.limit(digits)
- *
- * Limit the number of significant digits in newly created BigDecimal
- * numbers to the specified value. Rounding is performed as necessary,
- * as specified by BigDecimal.mode.
- *
- * A limit of 0, the default, means no upper limit.
- *
- * The limit specified by this method takes less priority over any limit
- * specified to instance methods such as ceil, floor, truncate, or round.
- */
-static VALUE
-BigDecimal_limit(int argc, VALUE *argv, VALUE self)
-{
- VALUE nFig;
- VALUE nCur = SIZET2NUM(VpGetPrecLimit());
-
- if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
- int nf;
- if (NIL_P(nFig)) return nCur;
- nf = NUM2INT(nFig);
- if (nf < 0) {
- rb_raise(rb_eArgError, "argument must be positive");
- }
- VpSetPrecLimit(nf);
- }
- return nCur;
-}
-
-/* Returns the sign of the value.
- *
- * Returns a positive value if > 0, a negative value if < 0.
- * It behaves the same with zeros -
- * it returns a positive value for a positive zero (BigDecimal('0')) and
- * a negative value for a negative zero (BigDecimal('-0')).
- *
- * The specific value returned indicates the type and sign of the BigDecimal,
- * as follows:
- *
- * BigDecimal::SIGN_NaN:: value is Not a Number
- * BigDecimal::SIGN_POSITIVE_ZERO:: value is +0
- * BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0
- * BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity
- * BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity
- * BigDecimal::SIGN_POSITIVE_FINITE:: value is positive
- * BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative
- */
-static VALUE
-BigDecimal_sign(VALUE self)
-{ /* sign */
- int s = GetVpValue(self, 1)->sign;
- return INT2FIX(s);
-}
-
-/*
- * call-seq: BigDecimal.save_exception_mode { ... }
- *
- * Execute the provided block, but preserve the exception mode
- *
- * BigDecimal.save_exception_mode do
- * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
- * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
- *
- * BigDecimal(BigDecimal('Infinity'))
- * BigDecimal(BigDecimal('-Infinity'))
- * BigDecimal(BigDecimal('NaN'))
- * end
- *
- * For use with the BigDecimal::EXCEPTION_*
- *
- * See BigDecimal.mode
- */
-static VALUE
-BigDecimal_save_exception_mode(VALUE self)
-{
- unsigned short const exception_mode = VpGetException();
- int state;
- VALUE ret = rb_protect(rb_yield, Qnil, &state);
- VpSetException(exception_mode);
- if (state) rb_jump_tag(state);
- return ret;
-}
-
-/*
- * call-seq: BigDecimal.save_rounding_mode { ... }
- *
- * Execute the provided block, but preserve the rounding mode
- *
- * BigDecimal.save_rounding_mode do
- * BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
- * puts BigDecimal.mode(BigDecimal::ROUND_MODE)
- * end
- *
- * For use with the BigDecimal::ROUND_*
- *
- * See BigDecimal.mode
- */
-static VALUE
-BigDecimal_save_rounding_mode(VALUE self)
-{
- unsigned short const round_mode = VpGetRoundMode();
- int state;
- VALUE ret = rb_protect(rb_yield, Qnil, &state);
- VpSetRoundMode(round_mode);
- if (state) rb_jump_tag(state);
- return ret;
-}
-
-/*
- * call-seq: BigDecimal.save_limit { ... }
- *
- * Execute the provided block, but preserve the precision limit
- *
- * BigDecimal.limit(100)
- * puts BigDecimal.limit
- * BigDecimal.save_limit do
- * BigDecimal.limit(200)
- * puts BigDecimal.limit
- * end
- * puts BigDecimal.limit
- *
- */
-static VALUE
-BigDecimal_save_limit(VALUE self)
-{
- size_t const limit = VpGetPrecLimit();
- int state;
- VALUE ret = rb_protect(rb_yield, Qnil, &state);
- VpSetPrecLimit(limit);
- if (state) rb_jump_tag(state);
- return ret;
-}
-
-/* call-seq:
- * BigMath.exp(decimal, numeric) -> BigDecimal
- *
- * Computes the value of e (the base of natural logarithms) raised to the
- * power of +decimal+, to the specified number of digits of precision.
- *
- * If +decimal+ is infinity, returns Infinity.
- *
- * If +decimal+ is NaN, returns NaN.
- */
-static VALUE
-BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
-{
- ssize_t prec, n, i;
- Real* vx = NULL;
- VALUE one, d, y;
- int negative = 0;
- int infinite = 0;
- int nan = 0;
- double flo;
-
- prec = NUM2SSIZET(vprec);
- if (prec <= 0) {
- rb_raise(rb_eArgError, "Zero or negative precision for exp");
- }
-
- /* TODO: the following switch statement is almost same as one in the
- * BigDecimalCmp function. */
- switch (TYPE(x)) {
- case T_DATA:
- if (!is_kind_of_BigDecimal(x)) break;
- vx = DATA_PTR(x);
- negative = BIGDECIMAL_NEGATIVE_P(vx);
- infinite = VpIsPosInf(vx) || VpIsNegInf(vx);
- nan = VpIsNaN(vx);
- break;
-
- case T_FIXNUM:
- /* fall through */
- case T_BIGNUM:
- vx = GetVpValue(x, 0);
- break;
-
- case T_FLOAT:
- flo = RFLOAT_VALUE(x);
- negative = flo < 0;
- infinite = isinf(flo);
- nan = isnan(flo);
- if (!infinite && !nan) {
- vx = GetVpValueWithPrec(x, 0, 0);
- }
- break;
-
- case T_RATIONAL:
- vx = GetVpValueWithPrec(x, prec, 0);
- break;
-
- default:
- break;
- }
- if (infinite) {
- if (negative) {
- return VpCheckGetValue(GetVpValueWithPrec(INT2FIX(0), prec, 1));
- }
- else {
- Real* vy = NewZeroWrapNolimit(1, prec);
- VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE);
- RB_GC_GUARD(vy->obj);
- return VpCheckGetValue(vy);
- }
- }
- else if (nan) {
- Real* vy = NewZeroWrapNolimit(1, prec);
- VpSetNaN(vy);
- RB_GC_GUARD(vy->obj);
- return VpCheckGetValue(vy);
- }
- else if (vx == NULL) {
- cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
- }
- x = vx->obj;
-
- n = prec + BIGDECIMAL_DOUBLE_FIGURES;
- negative = BIGDECIMAL_NEGATIVE_P(vx);
- if (negative) {
- VALUE x_zero = INT2NUM(1);
- VALUE x_copy = f_BigDecimal(1, &x_zero, klass);
- x = BigDecimal_initialize_copy(x_copy, x);
- vx = DATA_PTR(x);
- VpSetSign(vx, 1);
- }
-
- one = VpCheckGetValue(NewOneWrapLimited(1, 1));
- y = one;
- d = y;
- i = 1;
-
- while (!VpIsZero((Real*)DATA_PTR(d))) {
- SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
- SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d));
- ssize_t m = n - vabs(ey - ed);
-
- rb_thread_check_ints();
-
- if (m <= 0) {
- break;
- }
- else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) {
- m = BIGDECIMAL_DOUBLE_FIGURES;
- }
-
- d = BigDecimal_mult(d, x); /* d <- d * x */
- d = BigDecimal_div2(d, SSIZET2NUM(i), SSIZET2NUM(m)); /* d <- d / i */
- y = BigDecimal_add(y, d); /* y <- y + d */
- ++i; /* i <- i + 1 */
- }
-
- if (negative) {
- return BigDecimal_div2(one, y, vprec);
- }
- else {
- vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y)));
- return BigDecimal_round(1, &vprec, y);
- }
-
- RB_GC_GUARD(one);
- RB_GC_GUARD(x);
- RB_GC_GUARD(y);
- RB_GC_GUARD(d);
-}
-
-/* call-seq:
- * BigMath.log(decimal, numeric) -> BigDecimal
- *
- * Computes the natural logarithm of +decimal+ to the specified number of
- * digits of precision, +numeric+.
- *
- * If +decimal+ is zero or negative, raises Math::DomainError.
- *
- * If +decimal+ is positive infinity, returns Infinity.
- *
- * If +decimal+ is NaN, returns NaN.
- */
-static VALUE
-BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
-{
- ssize_t prec, n, i;
- SIGNED_VALUE expo;
- Real* vx = NULL;
- VALUE vn, one, two, w, x2, y, d;
- int zero = 0;
- int negative = 0;
- int infinite = 0;
- int nan = 0;
- double flo;
- long fix;
-
- if (!is_integer(vprec)) {
- rb_raise(rb_eArgError, "precision must be an Integer");
- }
-
- prec = NUM2SSIZET(vprec);
- if (prec <= 0) {
- rb_raise(rb_eArgError, "Zero or negative precision for exp");
- }
-
- /* TODO: the following switch statement is almost same as one in the
- * BigDecimalCmp function. */
- switch (TYPE(x)) {
- case T_DATA:
- if (!is_kind_of_BigDecimal(x)) break;
- vx = DATA_PTR(x);
- zero = VpIsZero(vx);
- negative = BIGDECIMAL_NEGATIVE_P(vx);
- infinite = VpIsPosInf(vx) || VpIsNegInf(vx);
- nan = VpIsNaN(vx);
- break;
-
- case T_FIXNUM:
- fix = FIX2LONG(x);
- zero = fix == 0;
- negative = fix < 0;
- goto get_vp_value;
-
- case T_BIGNUM:
- i = FIX2INT(rb_big_cmp(x, INT2FIX(0)));
- zero = i == 0;
- negative = i < 0;
-get_vp_value:
- if (zero || negative) break;
- vx = GetVpValue(x, 0);
- break;
-
- case T_FLOAT:
- flo = RFLOAT_VALUE(x);
- zero = flo == 0;
- negative = flo < 0;
- infinite = isinf(flo);
- nan = isnan(flo);
- if (!zero && !negative && !infinite && !nan) {
- vx = GetVpValueWithPrec(x, 0, 1);
- }
- break;
-
- case T_RATIONAL:
- zero = RRATIONAL_ZERO_P(x);
- negative = RRATIONAL_NEGATIVE_P(x);
- if (zero || negative) break;
- vx = GetVpValueWithPrec(x, prec, 1);
- break;
-
- case T_COMPLEX:
- rb_raise(rb_eMathDomainError,
- "Complex argument for BigMath.log");
-
- default:
- break;
- }
- if (infinite && !negative) {
- Real *vy = NewZeroWrapNolimit(1, prec);
- RB_GC_GUARD(vy->obj);
- VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE);
- return VpCheckGetValue(vy);
- }
- else if (nan) {
- Real* vy = NewZeroWrapNolimit(1, prec);
- RB_GC_GUARD(vy->obj);
- VpSetNaN(vy);
- return VpCheckGetValue(vy);
- }
- else if (zero || negative) {
- rb_raise(rb_eMathDomainError,
- "Zero or negative argument for log");
- }
- else if (vx == NULL) {
- cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
- }
- x = VpCheckGetValue(vx);
-
- one = VpCheckGetValue(NewOneWrapLimited(1, 1));
- two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
-
- n = prec + BIGDECIMAL_DOUBLE_FIGURES;
- vn = SSIZET2NUM(n);
- expo = VpExponent10(vx);
- if (expo < 0 || expo >= 3) {
- char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
- snprintf(buf, sizeof(buf), "1E%"PRIdVALUE, -expo);
- x = BigDecimal_mult2(x, VpCheckGetValue(VpCreateRbObject(1, buf, true)), vn);
- }
- else {
- expo = 0;
- }
- w = BigDecimal_sub(x, one);
- x = BigDecimal_div2(w, BigDecimal_add(x, one), vn);
- x2 = BigDecimal_mult2(x, x, vn);
- y = x;
- d = y;
- i = 1;
- while (!VpIsZero((Real*)DATA_PTR(d))) {
- SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
- SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d));
- ssize_t m = n - vabs(ey - ed);
- if (m <= 0) {
- break;
- }
- else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) {
- m = BIGDECIMAL_DOUBLE_FIGURES;
- }
-
- x = BigDecimal_mult2(x2, x, vn);
- i += 2;
- d = BigDecimal_div2(x, SSIZET2NUM(i), SSIZET2NUM(m));
- y = BigDecimal_add(y, d);
- }
-
- y = BigDecimal_mult(y, two);
- if (expo != 0) {
- VALUE log10, vexpo, dy;
- log10 = BigMath_s_log(klass, INT2FIX(10), vprec);
- vexpo = VpCheckGetValue(GetVpValue(SSIZET2NUM(expo), 1));
- dy = BigDecimal_mult(log10, vexpo);
- y = BigDecimal_add(y, dy);
- }
-
- RB_GC_GUARD(one);
- RB_GC_GUARD(two);
- RB_GC_GUARD(vn);
- RB_GC_GUARD(x2);
- RB_GC_GUARD(y);
- RB_GC_GUARD(d);
-
- return y;
-}
-
-static VALUE BIGDECIMAL_NAN = Qnil;
-
-static VALUE
-BigDecimal_nan(void)
-{
- return BIGDECIMAL_NAN;
-}
-
-static VALUE BIGDECIMAL_POSITIVE_INFINITY = Qnil;
-
-static VALUE
-BigDecimal_positive_infinity(void)
-{
- return BIGDECIMAL_POSITIVE_INFINITY;
-}
-
-static VALUE BIGDECIMAL_NEGATIVE_INFINITY = Qnil;
-
-static VALUE
-BigDecimal_negative_infinity(void)
-{
- return BIGDECIMAL_NEGATIVE_INFINITY;
-}
-
-static VALUE BIGDECIMAL_POSITIVE_ZERO = Qnil;
-
-static VALUE
-BigDecimal_positive_zero(void)
-{
- return BIGDECIMAL_POSITIVE_ZERO;
-}
-
-static VALUE BIGDECIMAL_NEGATIVE_ZERO = Qnil;
-
-static VALUE
-BigDecimal_negative_zero(void)
-{
- return BIGDECIMAL_NEGATIVE_ZERO;
-}
-
-/* Document-class: BigDecimal
- * BigDecimal provides arbitrary-precision floating point decimal arithmetic.
- *
- * == Introduction
- *
- * Ruby provides built-in support for arbitrary precision integer arithmetic.
- *
- * For example:
- *
- * 42**13 #=> 1265437718438866624512
- *
- * BigDecimal provides similar support for very large or very accurate floating
- * point numbers.
- *
- * Decimal arithmetic is also useful for general calculation, because it
- * provides the correct answers people expect--whereas normal binary floating
- * point arithmetic often introduces subtle errors because of the conversion
- * between base 10 and base 2.
- *
- * For example, try:
- *
- * sum = 0
- * 10_000.times do
- * sum = sum + 0.0001
- * end
- * print sum #=> 0.9999999999999062
- *
- * and contrast with the output from:
- *
- * require 'bigdecimal'
- *
- * sum = BigDecimal("0")
- * 10_000.times do
- * sum = sum + BigDecimal("0.0001")
- * end
- * print sum #=> 0.1E1
- *
- * Similarly:
- *
- * (BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
- *
- * (1.2 - 1.0) == 0.2 #=> false
- *
- * == A Note About Precision
- *
- * For a calculation using a \BigDecimal and another +value+,
- * the precision of the result depends on the type of +value+:
- *
- * - If +value+ is a \Float,
- * the precision is Float::DIG + 1.
- * - If +value+ is a \Rational, the precision is larger than Float::DIG + 1.
- * - If +value+ is a \BigDecimal, the precision is +value+'s precision in the
- * internal representation, which is platform-dependent.
- * - If +value+ is other object, the precision is determined by the result of +BigDecimal(value)+.
- *
- * == Special features of accurate decimal arithmetic
- *
- * Because BigDecimal is more accurate than normal binary floating point
- * arithmetic, it requires some special values.
- *
- * === Infinity
- *
- * BigDecimal sometimes needs to return infinity, for example if you divide
- * a value by zero.
- *
- * BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity
- * BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
- *
- * You can represent infinite numbers to BigDecimal using the strings
- * <code>'Infinity'</code>, <code>'+Infinity'</code> and
- * <code>'-Infinity'</code> (case-sensitive)
- *
- * === Not a Number
- *
- * When a computation results in an undefined value, the special value +NaN+
- * (for 'not a number') is returned.
- *
- * Example:
- *
- * BigDecimal("0.0") / BigDecimal("0.0") #=> NaN
- *
- * You can also create undefined values.
- *
- * NaN is never considered to be the same as any other value, even NaN itself:
- *
- * n = BigDecimal('NaN')
- * n == 0.0 #=> false
- * n == n #=> false
- *
- * === Positive and negative zero
- *
- * If a computation results in a value which is too small to be represented as
- * a BigDecimal within the currently specified limits of precision, zero must
- * be returned.
- *
- * If the value which is too small to be represented is negative, a BigDecimal
- * value of negative zero is returned.
- *
- * BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0
- *
- * If the value is positive, a value of positive zero is returned.
- *
- * BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0
- *
- * (See BigDecimal.mode for how to specify limits of precision.)
- *
- * Note that +-0.0+ and +0.0+ are considered to be the same for the purposes of
- * comparison.
- *
- * Note also that in mathematics, there is no particular concept of negative
- * or positive zero; true mathematical zero has no sign.
- *
- * == bigdecimal/util
- *
- * When you require +bigdecimal/util+, the #to_d method will be
- * available on BigDecimal and the native Integer, Float, Rational,
- * and String classes:
- *
- * require 'bigdecimal/util'
- *
- * 42.to_d # => 0.42e2
- * 0.5.to_d # => 0.5e0
- * (2/3r).to_d(3) # => 0.667e0
- * "0.5".to_d # => 0.5e0
- *
- * == License
- *
- * Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
- *
- * BigDecimal is released under the Ruby and 2-clause BSD licenses.
- * See LICENSE.txt for details.
- *
- * Maintained by mrkn <mrkn@mrkn.jp> and ruby-core members.
- *
- * Documented by zzak <zachary@zacharyscott.net>, mathew <meta@pobox.com>, and
- * many other contributors.
- */
-void
-Init_bigdecimal(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
- VALUE arg;
-
- id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode");
- id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode");
- id_BigDecimal_precision_limit = rb_intern_const("BigDecimal.precision_limit");
-
- /* Initialize VP routines */
- VpInit(0UL);
-
- /* Class and method registration */
- rb_cBigDecimal = rb_define_class("BigDecimal", rb_cNumeric);
-
- /* Global function */
- rb_define_global_function("BigDecimal", f_BigDecimal, -1);
-
- /* Class methods */
- rb_undef_alloc_func(rb_cBigDecimal);
- rb_undef_method(CLASS_OF(rb_cBigDecimal), "new");
- rb_define_singleton_method(rb_cBigDecimal, "interpret_loosely", BigDecimal_s_interpret_loosely, 1);
- rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
- rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
- rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
- rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
-
- rb_define_singleton_method(rb_cBigDecimal, "save_exception_mode", BigDecimal_save_exception_mode, 0);
- rb_define_singleton_method(rb_cBigDecimal, "save_rounding_mode", BigDecimal_save_rounding_mode, 0);
- rb_define_singleton_method(rb_cBigDecimal, "save_limit", BigDecimal_save_limit, 0);
-
- /* Constants definition */
-
- /*
- * The version of bigdecimal library
- */
- rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(BIGDECIMAL_VERSION));
-
- /*
- * Base value used in internal calculations. On a 32 bit system, BASE
- * is 10000, indicating that calculation is done in groups of 4 digits.
- * (If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't
- * guarantee that two groups could always be multiplied together without
- * overflow.)
- */
- rb_define_const(rb_cBigDecimal, "BASE", INT2FIX((SIGNED_VALUE)VpBaseVal()));
-
- /* Exceptions */
-
- /*
- * 0xff: Determines whether overflow, underflow or zero divide result in
- * an exception being thrown. See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_ALL", INT2FIX(VP_EXCEPTION_ALL));
-
- /*
- * 0x02: Determines what happens when the result of a computation is not a
- * number (NaN). See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_NaN", INT2FIX(VP_EXCEPTION_NaN));
-
- /*
- * 0x01: Determines what happens when the result of a computation is
- * infinity. See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_INFINITY", INT2FIX(VP_EXCEPTION_INFINITY));
-
- /*
- * 0x04: Determines what happens when the result of a computation is an
- * underflow (a result too small to be represented). See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_UNDERFLOW", INT2FIX(VP_EXCEPTION_UNDERFLOW));
-
- /*
- * 0x01: Determines what happens when the result of a computation is an
- * overflow (a result too large to be represented). See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_OVERFLOW", INT2FIX(VP_EXCEPTION_OVERFLOW));
-
- /*
- * 0x10: Determines what happens when a division by zero is performed.
- * See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE", INT2FIX(VP_EXCEPTION_ZERODIVIDE));
-
- /*
- * 0x100: Determines what happens when a result must be rounded in order to
- * fit in the appropriate number of significant digits. See
- * BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "ROUND_MODE", INT2FIX(VP_ROUND_MODE));
-
- /* 1: Indicates that values should be rounded away from zero. See
- * BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "ROUND_UP", INT2FIX(VP_ROUND_UP));
-
- /* 2: Indicates that values should be rounded towards zero. See
- * BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "ROUND_DOWN", INT2FIX(VP_ROUND_DOWN));
-
- /* 3: Indicates that digits >= 5 should be rounded up, others rounded down.
- * See BigDecimal.mode. */
- rb_define_const(rb_cBigDecimal, "ROUND_HALF_UP", INT2FIX(VP_ROUND_HALF_UP));
-
- /* 4: Indicates that digits >= 6 should be rounded up, others rounded down.
- * See BigDecimal.mode.
- */
- rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN", INT2FIX(VP_ROUND_HALF_DOWN));
- /* 5: Round towards +Infinity. See BigDecimal.mode. */
- rb_define_const(rb_cBigDecimal, "ROUND_CEILING", INT2FIX(VP_ROUND_CEIL));
-
- /* 6: Round towards -Infinity. See BigDecimal.mode. */
- rb_define_const(rb_cBigDecimal, "ROUND_FLOOR", INT2FIX(VP_ROUND_FLOOR));
-
- /* 7: Round towards the even neighbor. See BigDecimal.mode. */
- rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN", INT2FIX(VP_ROUND_HALF_EVEN));
-
- /* 0: Indicates that a value is not a number. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_NaN", INT2FIX(VP_SIGN_NaN));
-
- /* 1: Indicates that a value is +0. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO", INT2FIX(VP_SIGN_POSITIVE_ZERO));
-
- /* -1: Indicates that a value is -0. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO", INT2FIX(VP_SIGN_NEGATIVE_ZERO));
-
- /* 2: Indicates that a value is positive and finite. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE", INT2FIX(VP_SIGN_POSITIVE_FINITE));
-
- /* -2: Indicates that a value is negative and finite. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE", INT2FIX(VP_SIGN_NEGATIVE_FINITE));
-
- /* 3: Indicates that a value is positive and infinite. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE", INT2FIX(VP_SIGN_POSITIVE_INFINITE));
-
- /* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */
- rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE", INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
-
- /* Positive zero value. */
- arg = rb_str_new2("+0");
- BIGDECIMAL_POSITIVE_ZERO = f_BigDecimal(1, &arg, rb_cBigDecimal);
- rb_gc_register_mark_object(BIGDECIMAL_POSITIVE_ZERO);
-
- /* Negative zero value. */
- arg = rb_str_new2("-0");
- BIGDECIMAL_NEGATIVE_ZERO = f_BigDecimal(1, &arg, rb_cBigDecimal);
- rb_gc_register_mark_object(BIGDECIMAL_NEGATIVE_ZERO);
-
- /* Positive infinity value. */
- arg = rb_str_new2("+Infinity");
- BIGDECIMAL_POSITIVE_INFINITY = f_BigDecimal(1, &arg, rb_cBigDecimal);
- rb_gc_register_mark_object(BIGDECIMAL_POSITIVE_INFINITY);
-
- /* Negative infinity value. */
- arg = rb_str_new2("-Infinity");
- BIGDECIMAL_NEGATIVE_INFINITY = f_BigDecimal(1, &arg, rb_cBigDecimal);
- rb_gc_register_mark_object(BIGDECIMAL_NEGATIVE_INFINITY);
-
- /* 'Not a Number' value. */
- arg = rb_str_new2("NaN");
- BIGDECIMAL_NAN = f_BigDecimal(1, &arg, rb_cBigDecimal);
- rb_gc_register_mark_object(BIGDECIMAL_NAN);
-
- /* Special value constants */
- rb_define_const(rb_cBigDecimal, "INFINITY", BIGDECIMAL_POSITIVE_INFINITY);
- rb_define_const(rb_cBigDecimal, "NAN", BIGDECIMAL_NAN);
-
- /* instance methods */
- rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
- rb_define_method(rb_cBigDecimal, "precision", BigDecimal_precision, 0);
- rb_define_method(rb_cBigDecimal, "scale", BigDecimal_scale, 0);
- rb_define_method(rb_cBigDecimal, "precision_scale", BigDecimal_precision_scale, 0);
- rb_define_method(rb_cBigDecimal, "n_significant_digits", BigDecimal_n_significant_digits, 0);
-
- rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2);
- rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2);
- rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2);
- rb_define_method(rb_cBigDecimal, "div", BigDecimal_div3, -1);
- rb_define_method(rb_cBigDecimal, "hash", BigDecimal_hash, 0);
- rb_define_method(rb_cBigDecimal, "to_s", BigDecimal_to_s, -1);
- rb_define_method(rb_cBigDecimal, "to_i", BigDecimal_to_i, 0);
- rb_define_method(rb_cBigDecimal, "to_int", BigDecimal_to_i, 0);
- rb_define_method(rb_cBigDecimal, "to_r", BigDecimal_to_r, 0);
- rb_define_method(rb_cBigDecimal, "split", BigDecimal_split, 0);
- rb_define_method(rb_cBigDecimal, "+", BigDecimal_add, 1);
- rb_define_method(rb_cBigDecimal, "-", BigDecimal_sub, 1);
- rb_define_method(rb_cBigDecimal, "+@", BigDecimal_uplus, 0);
- rb_define_method(rb_cBigDecimal, "-@", BigDecimal_neg, 0);
- rb_define_method(rb_cBigDecimal, "*", BigDecimal_mult, 1);
- rb_define_method(rb_cBigDecimal, "/", BigDecimal_div, 1);
- rb_define_method(rb_cBigDecimal, "quo", BigDecimal_quo, -1);
- rb_define_method(rb_cBigDecimal, "%", BigDecimal_mod, 1);
- rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1);
- rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1);
- rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1);
- rb_define_method(rb_cBigDecimal, "clone", BigDecimal_clone, 0);
- rb_define_method(rb_cBigDecimal, "dup", BigDecimal_clone, 0);
- rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0);
- rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0);
- rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1);
- rb_define_method(rb_cBigDecimal, "fix", BigDecimal_fix, 0);
- rb_define_method(rb_cBigDecimal, "round", BigDecimal_round, -1);
- rb_define_method(rb_cBigDecimal, "frac", BigDecimal_frac, 0);
- rb_define_method(rb_cBigDecimal, "floor", BigDecimal_floor, -1);
- rb_define_method(rb_cBigDecimal, "ceil", BigDecimal_ceil, -1);
- rb_define_method(rb_cBigDecimal, "power", BigDecimal_power, -1);
- rb_define_method(rb_cBigDecimal, "**", BigDecimal_power_op, 1);
- rb_define_method(rb_cBigDecimal, "<=>", BigDecimal_comp, 1);
- rb_define_method(rb_cBigDecimal, "==", BigDecimal_eq, 1);
- rb_define_method(rb_cBigDecimal, "===", BigDecimal_eq, 1);
- rb_define_method(rb_cBigDecimal, "eql?", BigDecimal_eq, 1);
- rb_define_method(rb_cBigDecimal, "<", BigDecimal_lt, 1);
- rb_define_method(rb_cBigDecimal, "<=", BigDecimal_le, 1);
- rb_define_method(rb_cBigDecimal, ">", BigDecimal_gt, 1);
- rb_define_method(rb_cBigDecimal, ">=", BigDecimal_ge, 1);
- rb_define_method(rb_cBigDecimal, "zero?", BigDecimal_zero, 0);
- rb_define_method(rb_cBigDecimal, "nonzero?", BigDecimal_nonzero, 0);
- rb_define_method(rb_cBigDecimal, "coerce", BigDecimal_coerce, 1);
- rb_define_method(rb_cBigDecimal, "inspect", BigDecimal_inspect, 0);
- rb_define_method(rb_cBigDecimal, "exponent", BigDecimal_exponent, 0);
- rb_define_method(rb_cBigDecimal, "sign", BigDecimal_sign, 0);
- rb_define_method(rb_cBigDecimal, "nan?", BigDecimal_IsNaN, 0);
- rb_define_method(rb_cBigDecimal, "infinite?", BigDecimal_IsInfinite, 0);
- rb_define_method(rb_cBigDecimal, "finite?", BigDecimal_IsFinite, 0);
- rb_define_method(rb_cBigDecimal, "truncate", BigDecimal_truncate, -1);
- rb_define_method(rb_cBigDecimal, "_dump", BigDecimal_dump, -1);
-
- rb_mBigMath = rb_define_module("BigMath");
- rb_define_singleton_method(rb_mBigMath, "exp", BigMath_s_exp, 2);
- rb_define_singleton_method(rb_mBigMath, "log", BigMath_s_log, 2);
-
-#define ROUNDING_MODE(i, name, value) \
- id_##name = rb_intern_const(#name); \
- rbd_rounding_modes[i].id = id_##name; \
- rbd_rounding_modes[i].mode = value;
-
- ROUNDING_MODE(0, up, RBD_ROUND_UP);
- ROUNDING_MODE(1, down, RBD_ROUND_DOWN);
- ROUNDING_MODE(2, half_up, RBD_ROUND_HALF_UP);
- ROUNDING_MODE(3, half_down, RBD_ROUND_HALF_DOWN);
- ROUNDING_MODE(4, ceil, RBD_ROUND_CEIL);
- ROUNDING_MODE(5, floor, RBD_ROUND_FLOOR);
- ROUNDING_MODE(6, half_even, RBD_ROUND_HALF_EVEN);
-
- ROUNDING_MODE(7, default, RBD_ROUND_DEFAULT);
- ROUNDING_MODE(8, truncate, RBD_ROUND_TRUNCATE);
- ROUNDING_MODE(9, banker, RBD_ROUND_BANKER);
- ROUNDING_MODE(10, ceiling, RBD_ROUND_CEILING);
-
-#undef ROUNDING_MODE
-
- id_to_r = rb_intern_const("to_r");
- id_eq = rb_intern_const("==");
- id_half = rb_intern_const("half");
-
- (void)VPrint; /* suppress unused warning */
-}
-
-/*
- *
- * ============================================================================
- *
- * vp_ routines begin from here.
- *
- * ============================================================================
- *
- */
-#ifdef BIGDECIMAL_DEBUG
-static int gfDebug = 1; /* Debug switch */
-#if 0
-static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
-#endif
-#endif /* BIGDECIMAL_DEBUG */
-
-static Real *VpConstOne; /* constant 1.0 */
-static Real *VpConstPt5; /* constant 0.5 */
-#define maxnr 100UL /* Maximum iterations for calculating sqrt. */
- /* used in VpSqrt() */
-
-/* ETC */
-#define MemCmp(x,y,z) memcmp(x,y,z)
-#define StrCmp(x,y) strcmp(x,y)
-
-enum op_sw {
- OP_SW_ADD = 1, /* + */
- OP_SW_SUB, /* - */
- OP_SW_MULT, /* * */
- OP_SW_DIV /* / */
-};
-
-static int VpIsDefOP(Real *c, Real *a, Real *b, enum op_sw sw);
-static int AddExponent(Real *a, SIGNED_VALUE n);
-static DECDIG VpAddAbs(Real *a,Real *b,Real *c);
-static DECDIG VpSubAbs(Real *a,Real *b,Real *c);
-static size_t VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv);
-static int VpNmlz(Real *a);
-static void VpFormatSt(char *psz, size_t fFmt);
-static int VpRdup(Real *m, size_t ind_m);
-
-#ifdef BIGDECIMAL_DEBUG
-# ifdef HAVE_RB_EXT_RACTOR_SAFE
-# error Need to make rewiting gnAlloc atomic
-# endif
-static int gnAlloc = 0; /* Memory allocation counter */
-#endif /* BIGDECIMAL_DEBUG */
-
-/*
- * EXCEPTION Handling.
- */
-
-#define bigdecimal_set_thread_local_exception_mode(mode) \
- rb_thread_local_aset( \
- rb_thread_current(), \
- id_BigDecimal_exception_mode, \
- INT2FIX((int)(mode)) \
- )
-
-static unsigned short
-VpGetException (void)
-{
- VALUE const vmode = rb_thread_local_aref(
- rb_thread_current(),
- id_BigDecimal_exception_mode
- );
-
- if (NIL_P(vmode)) {
- bigdecimal_set_thread_local_exception_mode(BIGDECIMAL_EXCEPTION_MODE_DEFAULT);
- return BIGDECIMAL_EXCEPTION_MODE_DEFAULT;
- }
-
- return NUM2USHORT(vmode);
-}
-
-static void
-VpSetException(unsigned short f)
-{
- bigdecimal_set_thread_local_exception_mode(f);
-}
-
-static void
-VpCheckException(Real *p, bool always)
-{
- if (VpIsNaN(p)) {
- VpException(VP_EXCEPTION_NaN, "Computation results in 'NaN' (Not a Number)", always);
- }
- else if (VpIsPosInf(p)) {
- VpException(VP_EXCEPTION_INFINITY, "Computation results in 'Infinity'", always);
- }
- else if (VpIsNegInf(p)) {
- VpException(VP_EXCEPTION_INFINITY, "Computation results in '-Infinity'", always);
- }
-}
-
-static VALUE
-VpCheckGetValue(Real *p)
-{
- VpCheckException(p, false);
- return p->obj;
-}
-
-/*
- * Precision limit.
- */
-
-#define bigdecimal_set_thread_local_precision_limit(limit) \
- rb_thread_local_aset( \
- rb_thread_current(), \
- id_BigDecimal_precision_limit, \
- SIZET2NUM(limit) \
- )
-#define BIGDECIMAL_PRECISION_LIMIT_DEFAULT ((size_t)0)
-
-/* These 2 functions added at v1.1.7 */
-VP_EXPORT size_t
-VpGetPrecLimit(void)
-{
- VALUE const vlimit = rb_thread_local_aref(
- rb_thread_current(),
- id_BigDecimal_precision_limit
- );
-
- if (NIL_P(vlimit)) {
- bigdecimal_set_thread_local_precision_limit(BIGDECIMAL_PRECISION_LIMIT_DEFAULT);
- return BIGDECIMAL_PRECISION_LIMIT_DEFAULT;
- }
-
- return NUM2SIZET(vlimit);
-}
-
-VP_EXPORT size_t
-VpSetPrecLimit(size_t n)
-{
- size_t const s = VpGetPrecLimit();
- bigdecimal_set_thread_local_precision_limit(n);
- return s;
-}
-
-/*
- * Rounding mode.
- */
-
-#define bigdecimal_set_thread_local_rounding_mode(mode) \
- rb_thread_local_aset( \
- rb_thread_current(), \
- id_BigDecimal_rounding_mode, \
- INT2FIX((int)(mode)) \
- )
-
-VP_EXPORT unsigned short
-VpGetRoundMode(void)
-{
- VALUE const vmode = rb_thread_local_aref(
- rb_thread_current(),
- id_BigDecimal_rounding_mode
- );
-
- if (NIL_P(vmode)) {
- bigdecimal_set_thread_local_rounding_mode(BIGDECIMAL_ROUNDING_MODE_DEFAULT);
- return BIGDECIMAL_ROUNDING_MODE_DEFAULT;
- }
-
- return NUM2USHORT(vmode);
-}
-
-VP_EXPORT int
-VpIsRoundMode(unsigned short n)
-{
- switch (n) {
- case VP_ROUND_UP:
- case VP_ROUND_DOWN:
- case VP_ROUND_HALF_UP:
- case VP_ROUND_HALF_DOWN:
- case VP_ROUND_CEIL:
- case VP_ROUND_FLOOR:
- case VP_ROUND_HALF_EVEN:
- return 1;
-
- default:
- return 0;
- }
-}
-
-VP_EXPORT unsigned short
-VpSetRoundMode(unsigned short n)
-{
- if (VpIsRoundMode(n)) {
- bigdecimal_set_thread_local_rounding_mode(n);
- return n;
- }
-
- return VpGetRoundMode();
-}
-
-/*
- * 0.0 & 1.0 generator
- * These gZero_..... and gOne_..... can be any name
- * referenced from nowhere except Zero() and One().
- * gZero_..... and gOne_..... must have global scope
- * (to let the compiler know they may be changed in outside
- * (... but not actually..)).
- */
-volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
-
-static double
-One(void)
-{
- return gOne_ABCED9B4_CE73__00400511F31D;
-}
-
-/*
- ----------------------------------------------------------------
- Value of sign in Real structure is reserved for future use.
- short sign;
- ==0 : NaN
- 1 : Positive zero
- -1 : Negative zero
- 2 : Positive number
- -2 : Negative number
- 3 : Positive infinite number
- -3 : Negative infinite number
- ----------------------------------------------------------------
-*/
-
-VP_EXPORT double
-VpGetDoubleNaN(void) /* Returns the value of NaN */
-{
- return nan("");
-}
-
-VP_EXPORT double
-VpGetDoublePosInf(void) /* Returns the value of +Infinity */
-{
- return HUGE_VAL;
-}
-
-VP_EXPORT double
-VpGetDoubleNegInf(void) /* Returns the value of -Infinity */
-{
- return -HUGE_VAL;
-}
-
-VP_EXPORT double
-VpGetDoubleNegZero(void) /* Returns the value of -0 */
-{
- static double nzero = 1000.0;
- if (nzero != 0.0) nzero = (One()/VpGetDoubleNegInf());
- return nzero;
-}
-
-#if 0 /* unused */
-VP_EXPORT int
-VpIsNegDoubleZero(double v)
-{
- double z = VpGetDoubleNegZero();
- return MemCmp(&v,&z,sizeof(v))==0;
-}
-#endif
-
-VP_EXPORT int
-VpException(unsigned short f, const char *str,int always)
-{
- unsigned short const exception_mode = VpGetException();
-
- if (f == VP_EXCEPTION_OP) always = 1;
-
- if (always || (exception_mode & f)) {
- switch(f) {
- /* case VP_EXCEPTION_OVERFLOW: */
- case VP_EXCEPTION_ZERODIVIDE:
- case VP_EXCEPTION_INFINITY:
- case VP_EXCEPTION_NaN:
- case VP_EXCEPTION_UNDERFLOW:
- case VP_EXCEPTION_OP:
- rb_raise(rb_eFloatDomainError, "%s", str);
- break;
- default:
- rb_fatal("%s", str);
- }
- }
- return 0; /* 0 Means VpException() raised no exception */
-}
-
-/* Throw exception or returns 0,when resulting c is Inf or NaN */
-/* sw=1:+ 2:- 3:* 4:/ */
-static int
-VpIsDefOP(Real *c, Real *a, Real *b, enum op_sw sw)
-{
- if (VpIsNaN(a) || VpIsNaN(b)) {
- /* at least a or b is NaN */
- VpSetNaN(c);
- goto NaN;
- }
-
- if (VpIsInf(a)) {
- if (VpIsInf(b)) {
- switch(sw) {
- case OP_SW_ADD: /* + */
- if (VpGetSign(a) == VpGetSign(b)) {
- VpSetInf(c, VpGetSign(a));
- goto Inf;
- }
- else {
- VpSetNaN(c);
- goto NaN;
- }
- case OP_SW_SUB: /* - */
- if (VpGetSign(a) != VpGetSign(b)) {
- VpSetInf(c, VpGetSign(a));
- goto Inf;
- }
- else {
- VpSetNaN(c);
- goto NaN;
- }
- case OP_SW_MULT: /* * */
- VpSetInf(c, VpGetSign(a)*VpGetSign(b));
- goto Inf;
- case OP_SW_DIV: /* / */
- VpSetNaN(c);
- goto NaN;
- }
- VpSetNaN(c);
- goto NaN;
- }
- /* Inf op Finite */
- switch(sw) {
- case OP_SW_ADD: /* + */
- case OP_SW_SUB: /* - */
- VpSetInf(c, VpGetSign(a));
- break;
- case OP_SW_MULT: /* * */
- if (VpIsZero(b)) {
- VpSetNaN(c);
- goto NaN;
- }
- VpSetInf(c, VpGetSign(a)*VpGetSign(b));
- break;
- case OP_SW_DIV: /* / */
- VpSetInf(c, VpGetSign(a)*VpGetSign(b));
- }
- goto Inf;
- }
-
- if (VpIsInf(b)) {
- switch(sw) {
- case OP_SW_ADD: /* + */
- VpSetInf(c, VpGetSign(b));
- break;
- case OP_SW_SUB: /* - */
- VpSetInf(c, -VpGetSign(b));
- break;
- case OP_SW_MULT: /* * */
- if (VpIsZero(a)) {
- VpSetNaN(c);
- goto NaN;
- }
- VpSetInf(c, VpGetSign(a)*VpGetSign(b));
- break;
- case OP_SW_DIV: /* / */
- VpSetZero(c, VpGetSign(a)*VpGetSign(b));
- }
- goto Inf;
- }
- return 1; /* Results OK */
-
-Inf:
- if (VpIsPosInf(c)) {
- return VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 0);
- }
- else {
- return VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 0);
- }
-
-NaN:
- return VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'", 0);
-}
-
-/*
- ----------------------------------------------------------------
-*/
-
-/*
- * returns number of chars needed to represent vp in specified format.
- */
-VP_EXPORT size_t
-VpNumOfChars(Real *vp,const char *pszFmt)
-{
- SIGNED_VALUE ex;
- size_t nc;
-
- if (vp == NULL) return BASE_FIG*2+6;
- if (!VpIsDef(vp)) return 32; /* not sure,may be OK */
-
- switch(*pszFmt) {
- case 'F':
- nc = BASE_FIG*(vp->Prec + 1)+2;
- ex = vp->exponent;
- if (ex < 0) {
- nc += BASE_FIG*(size_t)(-ex);
- }
- else {
- if ((size_t)ex > vp->Prec) {
- nc += BASE_FIG*((size_t)ex - vp->Prec);
- }
- }
- break;
- case 'E':
- /* fall through */
- default:
- nc = BASE_FIG*(vp->Prec + 2)+6; /* 3: sign + exponent chars */
- }
- return nc;
-}
-
-/*
- * Initializer for Vp routines and constants used.
- * [Input]
- * BaseVal: Base value(assigned to BASE) for Vp calculation.
- * It must be the form BaseVal=10**n.(n=1,2,3,...)
- * If Base <= 0L,then the BASE will be calculated so
- * that BASE is as large as possible satisfying the
- * relation MaxVal <= BASE*(BASE+1). Where the value
- * MaxVal is the largest value which can be represented
- * by one DECDIG word in the computer used.
- *
- * [Returns]
- * BIGDECIMAL_DOUBLE_FIGURES ... OK
- */
-VP_EXPORT size_t
-VpInit(DECDIG BaseVal)
-{
- /* Setup +/- Inf NaN -0 */
- VpGetDoubleNegZero();
-
- /* Const 1.0 */
- VpConstOne = NewOneNolimit(1, 1);
-
- /* Const 0.5 */
- VpConstPt5 = NewOneNolimit(1, 1);
- VpConstPt5->exponent = 0;
- VpConstPt5->frac[0] = 5*BASE1;
-
-#ifdef BIGDECIMAL_DEBUG
- gnAlloc = 0;
-#endif /* BIGDECIMAL_DEBUG */
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- printf("VpInit: BaseVal = %"PRIuDECDIG"\n", BaseVal);
- printf("\tBASE = %"PRIuDECDIG"\n", BASE);
- printf("\tHALF_BASE = %"PRIuDECDIG"\n", HALF_BASE);
- printf("\tBASE1 = %"PRIuDECDIG"\n", BASE1);
- printf("\tBASE_FIG = %u\n", BASE_FIG);
- printf("\tBIGDECIMAL_DOUBLE_FIGURES = %d\n", BIGDECIMAL_DOUBLE_FIGURES);
- }
-#endif /* BIGDECIMAL_DEBUG */
-
- return BIGDECIMAL_DOUBLE_FIGURES;
-}
-
-VP_EXPORT Real *
-VpOne(void)
-{
- return VpConstOne;
-}
-
-/* If exponent overflows,then raise exception or returns 0 */
-static int
-AddExponent(Real *a, SIGNED_VALUE n)
-{
- SIGNED_VALUE e = a->exponent;
- SIGNED_VALUE m = e+n;
- SIGNED_VALUE eb, mb;
- if (e > 0) {
- if (n > 0) {
- if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) ||
- MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
- goto overflow;
- mb = m*(SIGNED_VALUE)BASE_FIG;
- eb = e*(SIGNED_VALUE)BASE_FIG;
- if (eb - mb > 0) goto overflow;
- }
- }
- else if (n < 0) {
- if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) ||
- MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
- goto underflow;
- mb = m*(SIGNED_VALUE)BASE_FIG;
- eb = e*(SIGNED_VALUE)BASE_FIG;
- if (mb - eb > 0) goto underflow;
- }
- a->exponent = m;
- return 1;
-
-/* Overflow/Underflow ==> Raise exception or returns 0 */
-underflow:
- VpSetZero(a, VpGetSign(a));
- return VpException(VP_EXCEPTION_UNDERFLOW, "Exponent underflow", 0);
-
-overflow:
- VpSetInf(a, VpGetSign(a));
- return VpException(VP_EXCEPTION_OVERFLOW, "Exponent overflow", 0);
-}
-
-Real *
-bigdecimal_parse_special_string(const char *str)
-{
- static const struct {
- const char *str;
- size_t len;
- int sign;
- } table[] = {
- { SZ_INF, sizeof(SZ_INF) - 1, VP_SIGN_POSITIVE_INFINITE },
- { SZ_PINF, sizeof(SZ_PINF) - 1, VP_SIGN_POSITIVE_INFINITE },
- { SZ_NINF, sizeof(SZ_NINF) - 1, VP_SIGN_NEGATIVE_INFINITE },
- { SZ_NaN, sizeof(SZ_NaN) - 1, VP_SIGN_NaN }
- };
- static const size_t table_length = sizeof(table) / sizeof(table[0]);
- size_t i;
-
- for (i = 0; i < table_length; ++i) {
- const char *p;
- if (strncmp(str, table[i].str, table[i].len) != 0) {
- continue;
- }
-
- p = str + table[i].len;
- while (*p && ISSPACE(*p)) ++p;
- if (*p == '\0') {
- Real *vp = rbd_allocate_struct(1);
- vp->MaxPrec = 1;
- switch (table[i].sign) {
- default:
- UNREACHABLE; break;
- case VP_SIGN_POSITIVE_INFINITE:
- VpSetPosInf(vp);
- return vp;
- case VP_SIGN_NEGATIVE_INFINITE:
- VpSetNegInf(vp);
- return vp;
- case VP_SIGN_NaN:
- VpSetNaN(vp);
- return vp;
- }
- }
- }
-
- return NULL;
-}
-
-/*
- * Allocates variable.
- * [Input]
- * mx ... The number of decimal digits to be allocated, if zero then mx is determined by szVal.
- * The mx will be the number of significant digits can to be stored.
- * szVal ... The value assigned(char). If szVal==NULL, then zero is assumed.
- * If szVal[0]=='#' then MaxPrec is not affected by the precision limit
- * so that the full precision specified by szVal is allocated.
- *
- * [Returns]
- * Pointer to the newly allocated variable, or
- * NULL be returned if memory allocation is failed,or any error.
- */
-VP_EXPORT Real *
-VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
-{
- const char *orig_szVal = szVal;
- size_t i, j, ni, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
- size_t len;
- char v, *psz;
- int sign=1;
- Real *vp = NULL;
- VALUE buf;
-
- if (szVal == NULL) {
- return_zero:
- /* necessary to be able to store */
- /* at least mx digits. */
- /* szVal==NULL ==> allocate zero value. */
- vp = rbd_allocate_struct(mx);
- vp->MaxPrec = rbd_calculate_internal_digits(mx, false); /* Must false */
- VpSetZero(vp, 1); /* initialize vp to zero. */
- return vp;
- }
-
- /* Skipping leading spaces */
- while (ISSPACE(*szVal)) szVal++;
-
- /* Check on Inf & NaN */
- if ((vp = bigdecimal_parse_special_string(szVal)) != NULL) {
- return vp;
- }
-
- /* Processing the leading one `#` */
- if (*szVal != '#') {
- len = rbd_calculate_internal_digits(mx, true);
- }
- else {
- len = rbd_calculate_internal_digits(mx, false);
- ++szVal;
- }
-
- /* Scanning digits */
-
- /* A buffer for keeping scanned digits */
- buf = rb_str_tmp_new(strlen(szVal) + 1);
- psz = RSTRING_PTR(buf);
-
- /* cursor: i for psz, and j for szVal */
- i = j = 0;
-
- /* Scanning: sign part */
- v = psz[i] = szVal[j];
- if ((v == '-') || (v == '+')) {
- sign = -(v == '-');
- ++i;
- ++j;
- }
-
- /* Scanning: integer part */
- ni = 0; /* number of digits in the integer part */
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
- break;
- }
- if (v == '_') {
- if (ni > 0) {
- v = szVal[j+1];
- if (v == '\0' || ISSPACE(v) || ISDIGIT(v)) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- break;
- }
- }
- goto invalid_value;
- }
- if (!ISDIGIT(v)) {
- break;
- }
- ++ni;
- ++i;
- ++j;
- }
-
- /* Scanning: fractional part */
- nf = 0; /* number of digits in the fractional part */
- ne = 0; /* number of digits in the exponential part */
- ipf = 0; /* index of the beginning of the fractional part */
- ipe = 0; /* index of the beginning of the exponential part */
- dot_seen = 0;
- exp_seen = 0;
-
- if (v != '\0') {
- /* Scanning fractional part */
- if ((psz[i] = szVal[j]) == '.') {
- dot_seen = 1;
- ++i;
- ++j;
- ipf = i;
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
- break;
- }
- if (v == '_') {
- if (nf > 0 && ISDIGIT(szVal[j+1])) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- if (nf == 0) {
- dot_seen = 0;
- }
- break;
- }
- goto invalid_value;
- }
- if (!ISDIGIT(v)) break;
- ++i;
- ++j;
- ++nf;
- }
- }
-
- /* Scanning exponential part */
- if (v != '\0') {
- switch ((psz[i] = szVal[j])) {
- case '\0':
- break;
- case 'e': case 'E':
- case 'd': case 'D':
- exp_seen = 1;
- ++i;
- ++j;
- ipe = i;
- v = psz[i] = szVal[j];
- if ((v == '-') || (v == '+')) {
- ++i;
- ++j;
- }
- while ((v = psz[i] = szVal[j]) != '\0') {
- if (!strict_p && ISSPACE(v)) {
- v = psz[i] = '\0';
- break;
- }
- if (v == '_') {
- if (ne > 0 && ISDIGIT(szVal[j+1])) {
- ++j;
- continue;
- }
- if (!strict_p) {
- v = psz[i] = '\0';
- if (ne == 0) {
- exp_seen = 0;
- }
- break;
- }
- goto invalid_value;
- }
- if (!ISDIGIT(v)) break;
- ++i;
- ++j;
- ++ne;
- }
- break;
- default:
- break;
- }
- }
-
- if (v != '\0') {
- /* Scanning trailing spaces */
- while (ISSPACE(szVal[j])) ++j;
-
- /* Invalid character */
- if (szVal[j] && strict_p) {
- goto invalid_value;
- }
- }
- }
-
- psz[i] = '\0';
-
- if (strict_p && (((ni == 0 || dot_seen) && nf == 0) || (exp_seen && ne == 0))) {
- VALUE str;
- invalid_value:
- if (!strict_p) {
- goto return_zero;
- }
- if (!exc) {
- return NULL;
- }
- str = rb_str_new2(orig_szVal);
- rb_raise(rb_eArgError, "invalid value for BigDecimal(): \"%"PRIsVALUE"\"", str);
- }
-
- nalloc = (ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */
- /* units for szVal[] */
- if (len == 0) len = 1;
- nalloc = Max(nalloc, len);
- len = nalloc;
- vp = rbd_allocate_struct(len);
- vp->MaxPrec = len; /* set max precision */
- VpSetZero(vp, sign);
- VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne);
- rb_str_resize(buf, 0);
- return vp;
-}
-
-/*
- * Assignment(c=a).
- * [Input]
- * a ... RHSV
- * isw ... switch for assignment.
- * c = a when isw > 0
- * c = -a when isw < 0
- * if c->MaxPrec < a->Prec,then round operation
- * will be performed.
- * [Output]
- * c ... LHSV
- */
-VP_EXPORT size_t
-VpAsgn(Real *c, Real *a, int isw)
-{
- size_t n;
- if (VpIsNaN(a)) {
- VpSetNaN(c);
- return 0;
- }
- if (VpIsInf(a)) {
- VpSetInf(c, isw * VpGetSign(a));
- return 0;
- }
-
- /* check if the RHS is zero */
- if (!VpIsZero(a)) {
- c->exponent = a->exponent; /* store exponent */
- VpSetSign(c, isw * VpGetSign(a)); /* set sign */
- n = (a->Prec < c->MaxPrec) ? (a->Prec) : (c->MaxPrec);
- c->Prec = n;
- memcpy(c->frac, a->frac, n * sizeof(DECDIG));
- /* Needs round ? */
- if (isw != 10) {
- /* Not in ActiveRound */
- if(c->Prec < a->Prec) {
- VpInternalRound(c, n, (n>0) ? a->frac[n-1] : 0, a->frac[n]);
- }
- else {
- VpLimitRound(c,0);
- }
- }
- }
- else {
- /* The value of 'a' is zero. */
- VpSetZero(c, isw * VpGetSign(a));
- return 1;
- }
- return c->Prec * BASE_FIG;
-}
-
-/*
- * c = a + b when operation = 1 or 2
- * c = a - b when operation = -1 or -2.
- * Returns number of significant digits of c
- */
-VP_EXPORT size_t
-VpAddSub(Real *c, Real *a, Real *b, int operation)
-{
- short sw, isw;
- Real *a_ptr, *b_ptr;
- size_t n, na, nb, i;
- DECDIG mrv;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpAddSub(enter) a=% \n", a);
- VPrint(stdout, " b=% \n", b);
- printf(" operation=%d\n", operation);
- }
-#endif /* BIGDECIMAL_DEBUG */
-
- if (!VpIsDefOP(c, a, b, (operation > 0) ? OP_SW_ADD : OP_SW_SUB)) return 0; /* No significant digits */
-
- /* check if a or b is zero */
- if (VpIsZero(a)) {
- /* a is zero,then assign b to c */
- if (!VpIsZero(b)) {
- VpAsgn(c, b, operation);
- }
- else {
- /* Both a and b are zero. */
- if (VpGetSign(a) < 0 && operation * VpGetSign(b) < 0) {
- /* -0 -0 */
- VpSetZero(c, -1);
- }
- else {
- VpSetZero(c, 1);
- }
- return 1; /* 0: 1 significant digits */
- }
- return c->Prec * BASE_FIG;
- }
- if (VpIsZero(b)) {
- /* b is zero,then assign a to c. */
- VpAsgn(c, a, 1);
- return c->Prec*BASE_FIG;
- }
-
- if (operation < 0) sw = -1;
- else sw = 1;
-
- /* compare absolute value. As a result,|a_ptr|>=|b_ptr| */
- if (a->exponent > b->exponent) {
- a_ptr = a;
- b_ptr = b;
- } /* |a|>|b| */
- else if (a->exponent < b->exponent) {
- a_ptr = b;
- b_ptr = a;
- } /* |a|<|b| */
- else {
- /* Exponent part of a and b is the same,then compare fraction */
- /* part */
- na = a->Prec;
- nb = b->Prec;
- n = Min(na, nb);
- for (i=0; i < n; ++i) {
- if (a->frac[i] > b->frac[i]) {
- a_ptr = a;
- b_ptr = b;
- goto end_if;
- }
- else if (a->frac[i] < b->frac[i]) {
- a_ptr = b;
- b_ptr = a;
- goto end_if;
- }
- }
- if (na > nb) {
- a_ptr = a;
- b_ptr = b;
- goto end_if;
- }
- else if (na < nb) {
- a_ptr = b;
- b_ptr = a;
- goto end_if;
- }
- /* |a| == |b| */
- if (VpGetSign(a) + sw *VpGetSign(b) == 0) {
- VpSetZero(c, 1); /* abs(a)=abs(b) and operation = '-' */
- return c->Prec * BASE_FIG;
- }
- a_ptr = a;
- b_ptr = b;
- }
-
-end_if:
- isw = VpGetSign(a) + sw *VpGetSign(b);
- /*
- * isw = 0 ...( 1)+(-1),( 1)-( 1),(-1)+(1),(-1)-(-1)
- * = 2 ...( 1)+( 1),( 1)-(-1)
- * =-2 ...(-1)+(-1),(-1)-( 1)
- * If isw==0, then c =(Sign a_ptr)(|a_ptr|-|b_ptr|)
- * else c =(Sign ofisw)(|a_ptr|+|b_ptr|)
- */
- if (isw) { /* addition */
- VpSetSign(c, 1);
- mrv = VpAddAbs(a_ptr, b_ptr, c);
- VpSetSign(c, isw / 2);
- }
- else { /* subtraction */
- VpSetSign(c, 1);
- mrv = VpSubAbs(a_ptr, b_ptr, c);
- if (a_ptr == a) {
- VpSetSign(c,VpGetSign(a));
- }
- else {
- VpSetSign(c, VpGetSign(a_ptr) * sw);
- }
- }
- VpInternalRound(c, 0, (c->Prec > 0) ? c->frac[c->Prec-1] : 0, mrv);
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpAddSub(result) c=% \n", c);
- VPrint(stdout, " a=% \n", a);
- VPrint(stdout, " b=% \n", b);
- printf(" operation=%d\n", operation);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return c->Prec * BASE_FIG;
-}
-
-/*
- * Addition of two values with variable precision
- * a and b assuming abs(a)>abs(b).
- * c = abs(a) + abs(b) ; where |a|>=|b|
- */
-static DECDIG
-VpAddAbs(Real *a, Real *b, Real *c)
-{
- size_t word_shift;
- size_t ap;
- size_t bp;
- size_t cp;
- size_t a_pos;
- size_t b_pos, b_pos_with_word_shift;
- size_t c_pos;
- DECDIG av, bv, carry, mrv;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpAddAbs called: a = %\n", a);
- VPrint(stdout, " b = %\n", b);
- }
-#endif /* BIGDECIMAL_DEBUG */
-
- word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
- a_pos = ap;
- b_pos = bp;
- c_pos = cp;
-
- if (word_shift == (size_t)-1L) return 0; /* Overflow */
- if (b_pos == (size_t)-1L) goto Assign_a;
-
- mrv = av + bv; /* Most right val. Used for round. */
-
- /* Just assign the last few digits of b to c because a has no */
- /* corresponding digits to be added. */
- if (b_pos > 0) {
- while (b_pos > 0 && b_pos + word_shift > a_pos) {
- c->frac[--c_pos] = b->frac[--b_pos];
- }
- }
- if (b_pos == 0 && word_shift > a_pos) {
- while (word_shift-- > a_pos) {
- c->frac[--c_pos] = 0;
- }
- }
-
- /* Just assign the last few digits of a to c because b has no */
- /* corresponding digits to be added. */
- b_pos_with_word_shift = b_pos + word_shift;
- while (a_pos > b_pos_with_word_shift) {
- c->frac[--c_pos] = a->frac[--a_pos];
- }
- carry = 0; /* set first carry be zero */
-
- /* Now perform addition until every digits of b will be */
- /* exhausted. */
- while (b_pos > 0) {
- c->frac[--c_pos] = a->frac[--a_pos] + b->frac[--b_pos] + carry;
- if (c->frac[c_pos] >= BASE) {
- c->frac[c_pos] -= BASE;
- carry = 1;
- }
- else {
- carry = 0;
- }
- }
-
- /* Just assign the first few digits of a with considering */
- /* the carry obtained so far because b has been exhausted. */
- while (a_pos > 0) {
- c->frac[--c_pos] = a->frac[--a_pos] + carry;
- if (c->frac[c_pos] >= BASE) {
- c->frac[c_pos] -= BASE;
- carry = 1;
- }
- else {
- carry = 0;
- }
- }
- if (c_pos) c->frac[c_pos - 1] += carry;
- goto Exit;
-
-Assign_a:
- VpAsgn(c, a, 1);
- mrv = 0;
-
-Exit:
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpAddAbs exit: c=% \n", c);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return mrv;
-}
-
-/*
- * c = abs(a) - abs(b)
- */
-static DECDIG
-VpSubAbs(Real *a, Real *b, Real *c)
-{
- size_t word_shift;
- size_t ap;
- size_t bp;
- size_t cp;
- size_t a_pos;
- size_t b_pos, b_pos_with_word_shift;
- size_t c_pos;
- DECDIG av, bv, borrow, mrv;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpSubAbs called: a = %\n", a);
- VPrint(stdout, " b = %\n", b);
- }
-#endif /* BIGDECIMAL_DEBUG */
-
- word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
- a_pos = ap;
- b_pos = bp;
- c_pos = cp;
- if (word_shift == (size_t)-1L) return 0; /* Overflow */
- if (b_pos == (size_t)-1L) goto Assign_a;
-
- if (av >= bv) {
- mrv = av - bv;
- borrow = 0;
- }
- else {
- mrv = 0;
- borrow = 1;
- }
-
- /* Just assign the values which are the BASE subtracted by */
- /* each of the last few digits of the b because the a has no */
- /* corresponding digits to be subtracted. */
- if (b_pos + word_shift > a_pos) {
- while (b_pos > 0 && b_pos + word_shift > a_pos) {
- c->frac[--c_pos] = BASE - b->frac[--b_pos] - borrow;
- borrow = 1;
- }
- if (b_pos == 0) {
- while (word_shift > a_pos) {
- --word_shift;
- c->frac[--c_pos] = BASE - borrow;
- borrow = 1;
- }
- }
- }
- /* Just assign the last few digits of a to c because b has no */
- /* corresponding digits to subtract. */
-
- b_pos_with_word_shift = b_pos + word_shift;
- while (a_pos > b_pos_with_word_shift) {
- c->frac[--c_pos] = a->frac[--a_pos];
- }
-
- /* Now perform subtraction until every digits of b will be */
- /* exhausted. */
- while (b_pos > 0) {
- --c_pos;
- if (a->frac[--a_pos] < b->frac[--b_pos] + borrow) {
- c->frac[c_pos] = BASE + a->frac[a_pos] - b->frac[b_pos] - borrow;
- borrow = 1;
- }
- else {
- c->frac[c_pos] = a->frac[a_pos] - b->frac[b_pos] - borrow;
- borrow = 0;
- }
- }
-
- /* Just assign the first few digits of a with considering */
- /* the borrow obtained so far because b has been exhausted. */
- while (a_pos > 0) {
- --c_pos;
- if (a->frac[--a_pos] < borrow) {
- c->frac[c_pos] = BASE + a->frac[a_pos] - borrow;
- borrow = 1;
- }
- else {
- c->frac[c_pos] = a->frac[a_pos] - borrow;
- borrow = 0;
- }
- }
- if (c_pos) c->frac[c_pos - 1] -= borrow;
- goto Exit;
-
-Assign_a:
- VpAsgn(c, a, 1);
- mrv = 0;
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpSubAbs exit: c=% \n", c);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return mrv;
-}
-
-/*
- * Note: If(av+bv)>= HALF_BASE,then 1 will be added to the least significant
- * digit of c(In case of addition).
- * ------------------------- figure of output -----------------------------------
- * a = xxxxxxxxxxx
- * b = xxxxxxxxxx
- * c =xxxxxxxxxxxxxxx
- * word_shift = | |
- * right_word = | | (Total digits in RHSV)
- * left_word = | | (Total digits in LHSV)
- * a_pos = |
- * b_pos = |
- * c_pos = |
- */
-static size_t
-VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv)
-{
- size_t left_word, right_word, word_shift;
-
- size_t const round_limit = (VpGetPrecLimit() + BASE_FIG - 1) / BASE_FIG;
-
- assert(a->exponent >= b->exponent);
-
- c->frac[0] = 0;
- *av = *bv = 0;
-
- word_shift = (a->exponent - b->exponent);
- left_word = b->Prec + word_shift;
- right_word = Max(a->Prec, left_word);
- left_word = c->MaxPrec - 1; /* -1 ... prepare for round up */
-
- /*
- * check if 'round' is needed.
- */
- if (right_word > left_word) { /* round ? */
- /*---------------------------------
- * Actual size of a = xxxxxxAxx
- * Actual size of b = xxxBxxxxx
- * Max. size of c = xxxxxx
- * Round off = |-----|
- * c_pos = |
- * right_word = |
- * a_pos = |
- */
- *c_pos = right_word = left_word + 1; /* Set resulting precision */
- /* be equal to that of c */
- if (a->Prec >= c->MaxPrec) {
- /*
- * a = xxxxxxAxxx
- * c = xxxxxx
- * a_pos = |
- */
- *a_pos = left_word;
- if (*a_pos <= round_limit) {
- *av = a->frac[*a_pos]; /* av is 'A' shown in above. */
- }
- }
- else {
- /*
- * a = xxxxxxx
- * c = xxxxxxxxxx
- * a_pos = |
- */
- *a_pos = a->Prec;
- }
- if (b->Prec + word_shift >= c->MaxPrec) {
- /*
- * a = xxxxxxxxx
- * b = xxxxxxxBxxx
- * c = xxxxxxxxxxx
- * b_pos = |
- */
- if (c->MaxPrec >= word_shift + 1) {
- *b_pos = c->MaxPrec - word_shift - 1;
- if (*b_pos + word_shift <= round_limit) {
- *bv = b->frac[*b_pos];
- }
- }
- else {
- *b_pos = -1L;
- }
- }
- else {
- /*
- * a = xxxxxxxxxxxxxxxx
- * b = xxxxxx
- * c = xxxxxxxxxxxxx
- * b_pos = |
- */
- *b_pos = b->Prec;
- }
- }
- else { /* The MaxPrec of c - 1 > The Prec of a + b */
- /*
- * a = xxxxxxx
- * b = xxxxxx
- * c = xxxxxxxxxxx
- * c_pos = |
- */
- *b_pos = b->Prec;
- *a_pos = a->Prec;
- *c_pos = right_word + 1;
- }
- c->Prec = *c_pos;
- c->exponent = a->exponent;
- if (!AddExponent(c, 1)) return (size_t)-1L;
- return word_shift;
-}
-
-/*
- * Return number of significant digits
- * c = a * b , Where a = a0a1a2 ... an
- * b = b0b1b2 ... bm
- * c = c0c1c2 ... cl
- * a0 a1 ... an * bm
- * a0 a1 ... an * bm-1
- * . . .
- * . . .
- * a0 a1 .... an * b0
- * +_____________________________
- * c0 c1 c2 ...... cl
- * nc <---|
- * MaxAB |--------------------|
- */
-VP_EXPORT size_t
-VpMult(Real *c, Real *a, Real *b)
-{
- size_t MxIndA, MxIndB, MxIndAB, MxIndC;
- size_t ind_c, i, ii, nc;
- size_t ind_as, ind_ae, ind_bs;
- DECDIG carry;
- DECDIG_DBL s;
- Real *w;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpMult(Enter): a=% \n", a);
- VPrint(stdout, " b=% \n", b);
- }
-#endif /* BIGDECIMAL_DEBUG */
-
- if (!VpIsDefOP(c, a, b, OP_SW_MULT)) return 0; /* No significant digit */
-
- if (VpIsZero(a) || VpIsZero(b)) {
- /* at least a or b is zero */
- VpSetZero(c, VpGetSign(a) * VpGetSign(b));
- return 1; /* 0: 1 significant digit */
- }
-
- if (VpIsOne(a)) {
- VpAsgn(c, b, VpGetSign(a));
- goto Exit;
- }
- if (VpIsOne(b)) {
- VpAsgn(c, a, VpGetSign(b));
- goto Exit;
- }
- if (b->Prec > a->Prec) {
- /* Adjust so that digits(a)>digits(b) */
- w = a;
- a = b;
- b = w;
- }
- w = NULL;
- MxIndA = a->Prec - 1;
- MxIndB = b->Prec - 1;
- MxIndC = c->MaxPrec - 1;
- MxIndAB = a->Prec + b->Prec - 1;
-
- if (MxIndC < MxIndAB) { /* The Max. prec. of c < Prec(a)+Prec(b) */
- w = c;
- c = NewZeroNolimit(1, (size_t)((MxIndAB + 1) * BASE_FIG));
- MxIndC = MxIndAB;
- }
-
- /* set LHSV c info */
-
- c->exponent = a->exponent; /* set exponent */
- if (!AddExponent(c, b->exponent)) {
- if (w) rbd_free_struct(c);
- return 0;
- }
- VpSetSign(c, VpGetSign(a) * VpGetSign(b)); /* set sign */
- carry = 0;
- nc = ind_c = MxIndAB;
- memset(c->frac, 0, (nc + 1) * sizeof(DECDIG)); /* Initialize c */
- c->Prec = nc + 1; /* set precision */
- for (nc = 0; nc < MxIndAB; ++nc, --ind_c) {
- if (nc < MxIndB) { /* The left triangle of the Fig. */
- ind_as = MxIndA - nc;
- ind_ae = MxIndA;
- ind_bs = MxIndB;
- }
- else if (nc <= MxIndA) { /* The middle rectangular of the Fig. */
- ind_as = MxIndA - nc;
- ind_ae = MxIndA - (nc - MxIndB);
- ind_bs = MxIndB;
- }
- else /* if (nc > MxIndA) */ { /* The right triangle of the Fig. */
- ind_as = 0;
- ind_ae = MxIndAB - nc - 1;
- ind_bs = MxIndB - (nc - MxIndA);
- }
-
- for (i = ind_as; i <= ind_ae; ++i) {
- s = (DECDIG_DBL)a->frac[i] * b->frac[ind_bs--];
- carry = (DECDIG)(s / BASE);
- s -= (DECDIG_DBL)carry * BASE;
- c->frac[ind_c] += (DECDIG)s;
- if (c->frac[ind_c] >= BASE) {
- s = c->frac[ind_c] / BASE;
- carry += (DECDIG)s;
- c->frac[ind_c] -= (DECDIG)(s * BASE);
- }
- if (carry) {
- ii = ind_c;
- while (ii-- > 0) {
- c->frac[ii] += carry;
- if (c->frac[ii] >= BASE) {
- carry = c->frac[ii] / BASE;
- c->frac[ii] -= (carry * BASE);
- }
- else {
- break;
- }
- }
- }
- }
- }
- if (w != NULL) { /* free work variable */
- VpNmlz(c);
- VpAsgn(w, c, 1);
- rbd_free_struct(c);
- c = w;
- }
- else {
- VpLimitRound(c,0);
- }
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpMult(c=a*b): c=% \n", c);
- VPrint(stdout, " a=% \n", a);
- VPrint(stdout, " b=% \n", b);
- }
-#endif /*BIGDECIMAL_DEBUG */
- return c->Prec*BASE_FIG;
-}
-
-/*
- * c = a / b, remainder = r
- */
-VP_EXPORT size_t
-VpDivd(Real *c, Real *r, Real *a, Real *b)
-{
- size_t word_a, word_b, word_c, word_r;
- size_t i, n, ind_a, ind_b, ind_c, ind_r;
- size_t nLoop;
- DECDIG_DBL q, b1, b1p1, b1b2, b1b2p1, r1r2;
- DECDIG borrow, borrow1, borrow2;
- DECDIG_DBL qb;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, " VpDivd(c=a/b) a=% \n", a);
- VPrint(stdout, " b=% \n", b);
- }
-#endif /*BIGDECIMAL_DEBUG */
-
- VpSetNaN(r);
- if (!VpIsDefOP(c, a, b, OP_SW_DIV)) goto Exit;
- if (VpIsZero(a) && VpIsZero(b)) {
- VpSetNaN(c);
- return VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'", 0);
- }
- if (VpIsZero(b)) {
- VpSetInf(c, VpGetSign(a) * VpGetSign(b));
- return VpException(VP_EXCEPTION_ZERODIVIDE, "Divide by zero", 0);
- }
- if (VpIsZero(a)) {
- /* numerator a is zero */
- VpSetZero(c, VpGetSign(a) * VpGetSign(b));
- VpSetZero(r, VpGetSign(a) * VpGetSign(b));
- goto Exit;
- }
- if (VpIsOne(b)) {
- /* divide by one */
- VpAsgn(c, a, VpGetSign(b));
- VpSetZero(r, VpGetSign(a));
- goto Exit;
- }
-
- word_a = a->Prec;
- word_b = b->Prec;
- word_c = c->MaxPrec;
- word_r = r->MaxPrec;
-
- if (word_a >= word_r) goto space_error;
-
- ind_r = 1;
- r->frac[0] = 0;
- while (ind_r <= word_a) {
- r->frac[ind_r] = a->frac[ind_r - 1];
- ++ind_r;
- }
- while (ind_r < word_r) r->frac[ind_r++] = 0;
-
- ind_c = 0;
- while (ind_c < word_c) c->frac[ind_c++] = 0;
-
- /* initial procedure */
- b1 = b1p1 = b->frac[0];
- if (b->Prec <= 1) {
- b1b2p1 = b1b2 = b1p1 * BASE;
- }
- else {
- b1p1 = b1 + 1;
- b1b2p1 = b1b2 = b1 * BASE + b->frac[1];
- if (b->Prec > 2) ++b1b2p1;
- }
-
- /* */
- /* loop start */
- ind_c = word_r - 1;
- nLoop = Min(word_c,ind_c);
- ind_c = 1;
- while (ind_c < nLoop) {
- if (r->frac[ind_c] == 0) {
- ++ind_c;
- continue;
- }
- r1r2 = (DECDIG_DBL)r->frac[ind_c] * BASE + r->frac[ind_c + 1];
- if (r1r2 == b1b2) {
- /* The first two word digits is the same */
- ind_b = 2;
- ind_a = ind_c + 2;
- while (ind_b < word_b) {
- if (r->frac[ind_a] < b->frac[ind_b]) goto div_b1p1;
- if (r->frac[ind_a] > b->frac[ind_b]) break;
- ++ind_a;
- ++ind_b;
- }
- /* The first few word digits of r and b is the same and */
- /* the first different word digit of w is greater than that */
- /* of b, so quotient is 1 and just subtract b from r. */
- borrow = 0; /* quotient=1, then just r-b */
- ind_b = b->Prec - 1;
- ind_r = ind_c + ind_b;
- if (ind_r >= word_r) goto space_error;
- n = ind_b;
- for (i = 0; i <= n; ++i) {
- if (r->frac[ind_r] < b->frac[ind_b] + borrow) {
- r->frac[ind_r] += (BASE - (b->frac[ind_b] + borrow));
- borrow = 1;
- }
- else {
- r->frac[ind_r] = r->frac[ind_r] - b->frac[ind_b] - borrow;
- borrow = 0;
- }
- --ind_r;
- --ind_b;
- }
- ++c->frac[ind_c];
- goto carry;
- }
- /* The first two word digits is not the same, */
- /* then compare magnitude, and divide actually. */
- if (r1r2 >= b1b2p1) {
- q = r1r2 / b1b2p1; /* q == (DECDIG)q */
- c->frac[ind_c] += (DECDIG)q;
- ind_r = b->Prec + ind_c - 1;
- goto sub_mult;
- }
-
-div_b1p1:
- if (ind_c + 1 >= word_c) goto out_side;
- q = r1r2 / b1p1; /* q == (DECDIG)q */
- c->frac[ind_c + 1] += (DECDIG)q;
- ind_r = b->Prec + ind_c;
-
-sub_mult:
- borrow1 = borrow2 = 0;
- ind_b = word_b - 1;
- if (ind_r >= word_r) goto space_error;
- n = ind_b;
- for (i = 0; i <= n; ++i) {
- /* now, perform r = r - q * b */
- qb = q * b->frac[ind_b];
- if (qb < BASE) borrow1 = 0;
- else {
- borrow1 = (DECDIG)(qb / BASE);
- qb -= (DECDIG_DBL)borrow1 * BASE; /* get qb < BASE */
- }
- if(r->frac[ind_r] < qb) {
- r->frac[ind_r] += (DECDIG)(BASE - qb);
- borrow2 = borrow2 + borrow1 + 1;
- }
- else {
- r->frac[ind_r] -= (DECDIG)qb;
- borrow2 += borrow1;
- }
- if (borrow2) {
- if(r->frac[ind_r - 1] < borrow2) {
- r->frac[ind_r - 1] += (BASE - borrow2);
- borrow2 = 1;
- }
- else {
- r->frac[ind_r - 1] -= borrow2;
- borrow2 = 0;
- }
- }
- --ind_r;
- --ind_b;
- }
-
- r->frac[ind_r] -= borrow2;
-carry:
- ind_r = ind_c;
- while (c->frac[ind_r] >= BASE) {
- c->frac[ind_r] -= BASE;
- --ind_r;
- ++c->frac[ind_r];
- }
- }
- /* End of operation, now final arrangement */
-out_side:
- c->Prec = word_c;
- c->exponent = a->exponent;
- if (!AddExponent(c, 2)) return 0;
- if (!AddExponent(c, -(b->exponent))) return 0;
-
- VpSetSign(c, VpGetSign(a) * VpGetSign(b));
- VpNmlz(c); /* normalize c */
- r->Prec = word_r;
- r->exponent = a->exponent;
- if (!AddExponent(r, 1)) return 0;
- VpSetSign(r, VpGetSign(a));
- VpNmlz(r); /* normalize r(remainder) */
- goto Exit;
-
-space_error:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- printf(" word_a=%"PRIuSIZE"\n", word_a);
- printf(" word_b=%"PRIuSIZE"\n", word_b);
- printf(" word_c=%"PRIuSIZE"\n", word_c);
- printf(" word_r=%"PRIuSIZE"\n", word_r);
- printf(" ind_r =%"PRIuSIZE"\n", ind_r);
- }
-#endif /* BIGDECIMAL_DEBUG */
- rb_bug("ERROR(VpDivd): space for remainder too small.");
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, " VpDivd(c=a/b), c=% \n", c);
- VPrint(stdout, " r=% \n", r);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return c->Prec * BASE_FIG;
-}
-
-/*
- * Input a = 00000xxxxxxxx En(5 preceding zeros)
- * Output a = xxxxxxxx En-5
- */
-static int
-VpNmlz(Real *a)
-{
- size_t ind_a, i;
-
- if (!VpIsDef(a)) goto NoVal;
- if (VpIsZero(a)) goto NoVal;
-
- ind_a = a->Prec;
- while (ind_a--) {
- if (a->frac[ind_a]) {
- a->Prec = ind_a + 1;
- i = 0;
- while (a->frac[i] == 0) ++i; /* skip the first few zeros */
- if (i) {
- a->Prec -= i;
- if (!AddExponent(a, -(SIGNED_VALUE)i)) return 0;
- memmove(&a->frac[0], &a->frac[i], a->Prec*sizeof(DECDIG));
- }
- return 1;
- }
- }
- /* a is zero(no non-zero digit) */
- VpSetZero(a, VpGetSign(a));
- return 0;
-
-NoVal:
- a->frac[0] = 0;
- a->Prec = 1;
- return 0;
-}
-
-/*
- * VpComp = 0 ... if a=b,
- * Pos ... a>b,
- * Neg ... a<b.
- * 999 ... result undefined(NaN)
- */
-VP_EXPORT int
-VpComp(Real *a, Real *b)
-{
- int val;
- size_t mx, ind;
- int e;
- val = 0;
- if (VpIsNaN(a) || VpIsNaN(b)) return 999;
- if (!VpIsDef(a)) {
- if (!VpIsDef(b)) e = a->sign - b->sign;
- else e = a->sign;
-
- if (e > 0) return 1;
- else if (e < 0) return -1;
- else return 0;
- }
- if (!VpIsDef(b)) {
- e = -b->sign;
- if (e > 0) return 1;
- else return -1;
- }
- /* Zero check */
- if (VpIsZero(a)) {
- if (VpIsZero(b)) return 0; /* both zero */
- val = -VpGetSign(b);
- goto Exit;
- }
- if (VpIsZero(b)) {
- val = VpGetSign(a);
- goto Exit;
- }
-
- /* compare sign */
- if (VpGetSign(a) > VpGetSign(b)) {
- val = 1; /* a>b */
- goto Exit;
- }
- if (VpGetSign(a) < VpGetSign(b)) {
- val = -1; /* a<b */
- goto Exit;
- }
-
- /* a and b have same sign, && sign!=0,then compare exponent */
- if (a->exponent > b->exponent) {
- val = VpGetSign(a);
- goto Exit;
- }
- if (a->exponent < b->exponent) {
- val = -VpGetSign(b);
- goto Exit;
- }
-
- /* a and b have same exponent, then compare their significand. */
- mx = (a->Prec < b->Prec) ? a->Prec : b->Prec;
- ind = 0;
- while (ind < mx) {
- if (a->frac[ind] > b->frac[ind]) {
- val = VpGetSign(a);
- goto Exit;
- }
- if (a->frac[ind] < b->frac[ind]) {
- val = -VpGetSign(b);
- goto Exit;
- }
- ++ind;
- }
- if (a->Prec > b->Prec) {
- val = VpGetSign(a);
- }
- else if (a->Prec < b->Prec) {
- val = -VpGetSign(b);
- }
-
-Exit:
- if (val > 1) val = 1;
- else if (val < -1) val = -1;
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, " VpComp a=%\n", a);
- VPrint(stdout, " b=%\n", b);
- printf(" ans=%d\n", val);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return (int)val;
-}
-
-/*
- * cntl_chr ... ASCIIZ Character, print control characters
- * Available control codes:
- * % ... VP variable. To print '%', use '%%'.
- * \n ... new line
- * \b ... backspace
- * \t ... tab
- * Note: % must not appear more than once
- * a ... VP variable to be printed
- */
-static int
-VPrint(FILE *fp, const char *cntl_chr, Real *a)
-{
- size_t i, j, nc, nd, ZeroSup, sep = 10;
- DECDIG m, e, nn;
-
- j = 0;
- nd = nc = 0; /* nd : number of digits in fraction part(every 10 digits, */
- /* nd<=10). */
- /* nc : number of characters printed */
- ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
- while (*(cntl_chr + j)) {
- if (*(cntl_chr + j) == '%' && *(cntl_chr + j + 1) != '%') {
- nc = 0;
- if (VpIsNaN(a)) {
- fprintf(fp, SZ_NaN);
- nc += 8;
- }
- else if (VpIsPosInf(a)) {
- fprintf(fp, SZ_INF);
- nc += 8;
- }
- else if (VpIsNegInf(a)) {
- fprintf(fp, SZ_NINF);
- nc += 9;
- }
- else if (!VpIsZero(a)) {
- if (BIGDECIMAL_NEGATIVE_P(a)) {
- fprintf(fp, "-");
- ++nc;
- }
- nc += fprintf(fp, "0.");
- switch (*(cntl_chr + j + 1)) {
- default:
- break;
-
- case '0': case 'z':
- ZeroSup = 0;
- ++j;
- sep = cntl_chr[j] == 'z' ? BIGDECIMAL_COMPONENT_FIGURES : 10;
- break;
- }
- for (i = 0; i < a->Prec; ++i) {
- m = BASE1;
- e = a->frac[i];
- while (m) {
- nn = e / m;
- if (!ZeroSup || nn) {
- nc += fprintf(fp, "%lu", (unsigned long)nn); /* The leading zero(s) */
- /* as 0.00xx will not */
- /* be printed. */
- ++nd;
- ZeroSup = 0; /* Set to print succeeding zeros */
- }
- if (nd >= sep) { /* print ' ' after every 10 digits */
- nd = 0;
- nc += fprintf(fp, " ");
- }
- e = e - nn * m;
- m /= 10;
- }
- }
- nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
- nc += fprintf(fp, " (%"PRIdVALUE", %"PRIuSIZE", %"PRIuSIZE")", a->exponent, a->Prec, a->MaxPrec);
- }
- else {
- nc += fprintf(fp, "0.0");
- }
- }
- else {
- ++nc;
- if (*(cntl_chr + j) == '\\') {
- switch (*(cntl_chr + j + 1)) {
- case 'n':
- fprintf(fp, "\n");
- ++j;
- break;
- case 't':
- fprintf(fp, "\t");
- ++j;
- break;
- case 'b':
- fprintf(fp, "\n");
- ++j;
- break;
- default:
- fprintf(fp, "%c", *(cntl_chr + j));
- break;
- }
- }
- else {
- fprintf(fp, "%c", *(cntl_chr + j));
- if (*(cntl_chr + j) == '%') ++j;
- }
- }
- j++;
- }
-
- return (int)nc;
-}
-
-static void
-VpFormatSt(char *psz, size_t fFmt)
-{
- size_t ie, i, nf = 0;
- char ch;
-
- if (fFmt == 0) return;
-
- ie = strlen(psz);
- for (i = 0; i < ie; ++i) {
- ch = psz[i];
- if (!ch) break;
- if (ISSPACE(ch) || ch=='-' || ch=='+') continue;
- if (ch == '.') { nf = 0; continue; }
- if (ch == 'E' || ch == 'e') break;
-
- if (++nf > fFmt) {
- memmove(psz + i + 1, psz + i, ie - i + 1);
- ++ie;
- nf = 0;
- psz[i] = ' ';
- }
- }
-}
-
-VP_EXPORT ssize_t
-VpExponent10(Real *a)
-{
- ssize_t ex;
- size_t n;
-
- if (!VpHasVal(a)) return 0;
-
- ex = a->exponent * (ssize_t)BASE_FIG;
- n = BASE1;
- while ((a->frac[0] / n) == 0) {
- --ex;
- n /= 10;
- }
- return ex;
-}
-
-VP_EXPORT void
-VpSzMantissa(Real *a, char *buf, size_t buflen)
-{
- size_t i, n, ZeroSup;
- DECDIG_DBL m, e, nn;
-
- if (VpIsNaN(a)) {
- snprintf(buf, buflen, SZ_NaN);
- return;
- }
- if (VpIsPosInf(a)) {
- snprintf(buf, buflen, SZ_INF);
- return;
- }
- if (VpIsNegInf(a)) {
- snprintf(buf, buflen, SZ_NINF);
- return;
- }
-
- ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
- if (!VpIsZero(a)) {
- if (BIGDECIMAL_NEGATIVE_P(a)) *buf++ = '-';
- n = a->Prec;
- for (i = 0; i < n; ++i) {
- m = BASE1;
- e = a->frac[i];
- while (m) {
- nn = e / m;
- if (!ZeroSup || nn) {
- snprintf(buf, buflen, "%lu", (unsigned long)nn); /* The leading zero(s) */
- buf += strlen(buf);
- /* as 0.00xx will be ignored. */
- ZeroSup = 0; /* Set to print succeeding zeros */
- }
- e = e - nn * m;
- m /= 10;
- }
- }
- *buf = 0;
- while (buf[-1] == '0') *(--buf) = 0;
- }
- else {
- if (VpIsPosZero(a)) snprintf(buf, buflen, "0");
- else snprintf(buf, buflen, "-0");
- }
-}
-
-VP_EXPORT int
-VpToSpecialString(Real *a, char *buf, size_t buflen, int fPlus)
-/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
-{
- if (VpIsNaN(a)) {
- snprintf(buf, buflen, SZ_NaN);
- return 1;
- }
-
- if (VpIsPosInf(a)) {
- if (fPlus == 1) {
- *buf++ = ' ';
- }
- else if (fPlus == 2) {
- *buf++ = '+';
- }
- snprintf(buf, buflen, SZ_INF);
- return 1;
- }
- if (VpIsNegInf(a)) {
- snprintf(buf, buflen, SZ_NINF);
- return 1;
- }
- if (VpIsZero(a)) {
- if (VpIsPosZero(a)) {
- if (fPlus == 1) snprintf(buf, buflen, " 0.0");
- else if (fPlus == 2) snprintf(buf, buflen, "+0.0");
- else snprintf(buf, buflen, "0.0");
- }
- else snprintf(buf, buflen, "-0.0");
- return 1;
- }
- return 0;
-}
-
-VP_EXPORT void
-VpToString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus)
-/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
-{
- size_t i, n, ZeroSup;
- DECDIG shift, m, e, nn;
- char *p = buf;
- size_t plen = buflen;
- ssize_t ex;
-
- if (VpToSpecialString(a, buf, buflen, fPlus)) return;
-
- ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
-
-#define ADVANCE(n) do { \
- if (plen < n) goto overflow; \
- p += n; \
- plen -= n; \
-} while (0)
-
- if (BIGDECIMAL_NEGATIVE_P(a)) {
- *p = '-';
- ADVANCE(1);
- }
- else if (fPlus == 1) {
- *p = ' ';
- ADVANCE(1);
- }
- else if (fPlus == 2) {
- *p = '+';
- ADVANCE(1);
- }
-
- *p = '0'; ADVANCE(1);
- *p = '.'; ADVANCE(1);
-
- n = a->Prec;
- for (i = 0; i < n; ++i) {
- m = BASE1;
- e = a->frac[i];
- while (m) {
- nn = e / m;
- if (!ZeroSup || nn) {
- /* The reading zero(s) */
- size_t n = (size_t)snprintf(p, plen, "%lu", (unsigned long)nn);
- if (n > plen) goto overflow;
- ADVANCE(n);
- /* as 0.00xx will be ignored. */
- ZeroSup = 0; /* Set to print succeeding zeros */
- }
- e = e - nn * m;
- m /= 10;
- }
- }
-
- ex = a->exponent * (ssize_t)BASE_FIG;
- shift = BASE1;
- while (a->frac[0] / shift == 0) {
- --ex;
- shift /= 10;
- }
- while (p - 1 > buf && p[-1] == '0') {
- *(--p) = '\0';
- ++plen;
- }
- snprintf(p, plen, "e%"PRIdSIZE, ex);
- if (fFmt) VpFormatSt(buf, fFmt);
-
- overflow:
- return;
-#undef ADVANCE
-}
-
-VP_EXPORT void
-VpToFString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus)
-/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
-{
- size_t i, n;
- DECDIG m, e, nn;
- char *p = buf;
- size_t plen = buflen;
- ssize_t ex;
-
- if (VpToSpecialString(a, buf, buflen, fPlus)) return;
-
-#define ADVANCE(n) do { \
- if (plen < n) goto overflow; \
- p += n; \
- plen -= n; \
-} while (0)
-
-
- if (BIGDECIMAL_NEGATIVE_P(a)) {
- *p = '-';
- ADVANCE(1);
- }
- else if (fPlus == 1) {
- *p = ' ';
- ADVANCE(1);
- }
- else if (fPlus == 2) {
- *p = '+';
- ADVANCE(1);
- }
-
- n = a->Prec;
- ex = a->exponent;
- if (ex <= 0) {
- *p = '0'; ADVANCE(1);
- *p = '.'; ADVANCE(1);
- while (ex < 0) {
- for (i=0; i < BASE_FIG; ++i) {
- *p = '0'; ADVANCE(1);
- }
- ++ex;
- }
- ex = -1;
- }
-
- for (i = 0; i < n; ++i) {
- --ex;
- if (i == 0 && ex >= 0) {
- size_t n = snprintf(p, plen, "%lu", (unsigned long)a->frac[i]);
- if (n > plen) goto overflow;
- ADVANCE(n);
- }
- else {
- m = BASE1;
- e = a->frac[i];
- while (m) {
- nn = e / m;
- *p = (char)(nn + '0');
- ADVANCE(1);
- e = e - nn * m;
- m /= 10;
- }
- }
- if (ex == 0) {
- *p = '.';
- ADVANCE(1);
- }
- }
- while (--ex>=0) {
- m = BASE;
- while (m /= 10) {
- *p = '0';
- ADVANCE(1);
- }
- if (ex == 0) {
- *p = '.';
- ADVANCE(1);
- }
- }
-
- *p = '\0';
- while (p - 1 > buf && p[-1] == '0') {
- *(--p) = '\0';
- ++plen;
- }
- if (p - 1 > buf && p[-1] == '.') {
- snprintf(p, plen, "0");
- }
- if (fFmt) VpFormatSt(buf, fFmt);
-
- overflow:
- return;
-#undef ADVANCE
-}
-
-/*
- * [Output]
- * a[] ... variable to be assigned the value.
- * [Input]
- * int_chr[] ... integer part(may include '+/-').
- * ni ... number of characters in int_chr[],not including '+/-'.
- * frac[] ... fraction part.
- * nf ... number of characters in frac[].
- * exp_chr[] ... exponent part(including '+/-').
- * ne ... number of characters in exp_chr[],not including '+/-'.
- */
-VP_EXPORT int
-VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne)
-{
- size_t i, j, ind_a, ma, mi, me;
- SIGNED_VALUE e, es, eb, ef;
- int sign, signe, exponent_overflow;
-
- /* get exponent part */
- e = 0;
- ma = a->MaxPrec;
- mi = ni;
- me = ne;
- signe = 1;
- exponent_overflow = 0;
- memset(a->frac, 0, ma * sizeof(DECDIG));
- if (ne > 0) {
- i = 0;
- if (exp_chr[0] == '-') {
- signe = -1;
- ++i;
- ++me;
- }
- else if (exp_chr[0] == '+') {
- ++i;
- ++me;
- }
- while (i < me) {
- if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) {
- es = e;
- goto exp_overflow;
- }
- es = e * (SIGNED_VALUE)BASE_FIG;
- if (MUL_OVERFLOW_SIGNED_VALUE_P(e, 10) ||
- SIGNED_VALUE_MAX - (exp_chr[i] - '0') < e * 10)
- goto exp_overflow;
- e = e * 10 + exp_chr[i] - '0';
- if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
- goto exp_overflow;
- if (es > (SIGNED_VALUE)(e * BASE_FIG)) {
- exp_overflow:
- exponent_overflow = 1;
- e = es; /* keep sign */
- break;
- }
- ++i;
- }
- }
-
- /* get integer part */
- i = 0;
- sign = 1;
- if (1 /*ni >= 0*/) {
- if (int_chr[0] == '-') {
- sign = -1;
- ++i;
- ++mi;
- }
- else if (int_chr[0] == '+') {
- ++i;
- ++mi;
- }
- }
-
- e = signe * e; /* e: The value of exponent part. */
- e = e + ni; /* set actual exponent size. */
-
- if (e > 0) signe = 1;
- else signe = -1;
-
- /* Adjust the exponent so that it is the multiple of BASE_FIG. */
- j = 0;
- ef = 1;
- while (ef) {
- if (e >= 0) eb = e;
- else eb = -e;
- ef = eb / (SIGNED_VALUE)BASE_FIG;
- ef = eb - ef * (SIGNED_VALUE)BASE_FIG;
- if (ef) {
- ++j; /* Means to add one more preceding zero */
- ++e;
- }
- }
-
- eb = e / (SIGNED_VALUE)BASE_FIG;
-
- if (exponent_overflow) {
- int zero = 1;
- for ( ; i < mi && zero; i++) zero = int_chr[i] == '0';
- for (i = 0; i < nf && zero; i++) zero = frac[i] == '0';
- if (!zero && signe > 0) {
- VpSetInf(a, sign);
- VpException(VP_EXCEPTION_INFINITY, "exponent overflow",0);
- }
- else VpSetZero(a, sign);
- return 1;
- }
-
- ind_a = 0;
- while (i < mi) {
- a->frac[ind_a] = 0;
- while (j < BASE_FIG && i < mi) {
- a->frac[ind_a] = a->frac[ind_a] * 10 + int_chr[i] - '0';
- ++j;
- ++i;
- }
- if (i < mi) {
- ++ind_a;
- if (ind_a >= ma) goto over_flow;
- j = 0;
- }
- }
-
- /* get fraction part */
-
- i = 0;
- while (i < nf) {
- while (j < BASE_FIG && i < nf) {
- a->frac[ind_a] = a->frac[ind_a] * 10 + frac[i] - '0';
- ++j;
- ++i;
- }
- if (i < nf) {
- ++ind_a;
- if (ind_a >= ma) goto over_flow;
- j = 0;
- }
- }
- goto Final;
-
-over_flow:
- rb_warn("Conversion from String to BigDecimal overflow (last few digits discarded).");
-
-Final:
- if (ind_a >= ma) ind_a = ma - 1;
- while (j < BASE_FIG) {
- a->frac[ind_a] = a->frac[ind_a] * 10;
- ++j;
- }
- a->Prec = ind_a + 1;
- a->exponent = eb;
- VpSetSign(a, sign);
- VpNmlz(a);
- return 1;
-}
-
-/*
- * [Input]
- * *m ... Real
- * [Output]
- * *d ... fraction part of m(d = 0.xxxxxxx). where # of 'x's is fig.
- * *e ... exponent of m.
- * BIGDECIMAL_DOUBLE_FIGURES ... Number of digits in a double variable.
- *
- * m -> d*10**e, 0<d<BASE
- * [Returns]
- * 0 ... Zero
- * 1 ... Normal
- * 2 ... Infinity
- * -1 ... NaN
- */
-VP_EXPORT int
-VpVtoD(double *d, SIGNED_VALUE *e, Real *m)
-{
- size_t ind_m, mm, fig;
- double div;
- int f = 1;
-
- if (VpIsNaN(m)) {
- *d = VpGetDoubleNaN();
- *e = 0;
- f = -1; /* NaN */
- goto Exit;
- }
- else if (VpIsPosZero(m)) {
- *d = 0.0;
- *e = 0;
- f = 0;
- goto Exit;
- }
- else if (VpIsNegZero(m)) {
- *d = VpGetDoubleNegZero();
- *e = 0;
- f = 0;
- goto Exit;
- }
- else if (VpIsPosInf(m)) {
- *d = VpGetDoublePosInf();
- *e = 0;
- f = 2;
- goto Exit;
- }
- else if (VpIsNegInf(m)) {
- *d = VpGetDoubleNegInf();
- *e = 0;
- f = 2;
- goto Exit;
- }
- /* Normal number */
- fig = roomof(BIGDECIMAL_DOUBLE_FIGURES, BASE_FIG);
- ind_m = 0;
- mm = Min(fig, m->Prec);
- *d = 0.0;
- div = 1.;
- while (ind_m < mm) {
- div /= (double)BASE;
- *d = *d + (double)m->frac[ind_m++] * div;
- }
- *e = m->exponent * (SIGNED_VALUE)BASE_FIG;
- *d *= VpGetSign(m);
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, " VpVtoD: m=%\n", m);
- printf(" d=%e * 10 **%ld\n", *d, *e);
- printf(" BIGDECIMAL_DOUBLE_FIGURES = %d\n", BIGDECIMAL_DOUBLE_FIGURES);
- }
-#endif /*BIGDECIMAL_DEBUG */
- return f;
-}
-
-/*
- * m <- d
- */
-VP_EXPORT void
-VpDtoV(Real *m, double d)
-{
- size_t ind_m, mm;
- SIGNED_VALUE ne;
- DECDIG i;
- double val, val2;
-
- if (isnan(d)) {
- VpSetNaN(m);
- goto Exit;
- }
- if (isinf(d)) {
- if (d > 0.0) VpSetPosInf(m);
- else VpSetNegInf(m);
- goto Exit;
- }
-
- if (d == 0.0) {
- VpSetZero(m, 1);
- goto Exit;
- }
- val = (d > 0.) ? d : -d;
- ne = 0;
- if (val >= 1.0) {
- while (val >= 1.0) {
- val /= (double)BASE;
- ++ne;
- }
- }
- else {
- val2 = 1.0 / (double)BASE;
- while (val < val2) {
- val *= (double)BASE;
- --ne;
- }
- }
- /* Now val = 0.xxxxx*BASE**ne */
-
- mm = m->MaxPrec;
- memset(m->frac, 0, mm * sizeof(DECDIG));
- for (ind_m = 0; val > 0.0 && ind_m < mm; ind_m++) {
- val *= (double)BASE;
- i = (DECDIG)val;
- val -= (double)i;
- m->frac[ind_m] = i;
- }
- if (ind_m >= mm) ind_m = mm - 1;
- VpSetSign(m, (d > 0.0) ? 1 : -1);
- m->Prec = ind_m + 1;
- m->exponent = ne;
-
- VpInternalRound(m, 0, (m->Prec > 0) ? m->frac[m->Prec-1] : 0,
- (DECDIG)(val*(double)BASE));
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- printf("VpDtoV d=%30.30e\n", d);
- VPrint(stdout, " m=%\n", m);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return;
-}
-
-/*
- * m <- ival
- */
-#if 0 /* unused */
-VP_EXPORT void
-VpItoV(Real *m, SIGNED_VALUE ival)
-{
- size_t mm, ind_m;
- size_t val, v1, v2, v;
- int isign;
- SIGNED_VALUE ne;
-
- if (ival == 0) {
- VpSetZero(m, 1);
- goto Exit;
- }
- isign = 1;
- val = ival;
- if (ival < 0) {
- isign = -1;
- val =(size_t)(-ival);
- }
- ne = 0;
- ind_m = 0;
- mm = m->MaxPrec;
- while (ind_m < mm) {
- m->frac[ind_m] = 0;
- ++ind_m;
- }
- ind_m = 0;
- while (val > 0) {
- if (val) {
- v1 = val;
- v2 = 1;
- while (v1 >= BASE) {
- v1 /= BASE;
- v2 *= BASE;
- }
- val = val - v2 * v1;
- v = v1;
- }
- else {
- v = 0;
- }
- m->frac[ind_m] = v;
- ++ind_m;
- ++ne;
- }
- m->Prec = ind_m - 1;
- m->exponent = ne;
- VpSetSign(m, isign);
- VpNmlz(m);
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- printf(" VpItoV i=%d\n", ival);
- VPrint(stdout, " m=%\n", m);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return;
-}
-#endif
-
-/*
- * y = SQRT(x), y*y - x =>0
- */
-VP_EXPORT int
-VpSqrt(Real *y, Real *x)
-{
- Real *f = NULL;
- Real *r = NULL;
- size_t y_prec;
- SIGNED_VALUE n, e;
- SIGNED_VALUE prec;
- ssize_t nr;
- double val;
-
- /* Zero or +Infinity ? */
- if (VpIsZero(x) || VpIsPosInf(x)) {
- VpAsgn(y,x,1);
- goto Exit;
- }
-
- /* Negative ? */
- if (BIGDECIMAL_NEGATIVE_P(x)) {
- VpSetNaN(y);
- return VpException(VP_EXCEPTION_OP, "sqrt of negative value", 0);
- }
-
- /* NaN ? */
- if (VpIsNaN(x)) {
- VpSetNaN(y);
- return VpException(VP_EXCEPTION_OP, "sqrt of 'NaN'(Not a Number)", 0);
- }
-
- /* One ? */
- if (VpIsOne(x)) {
- VpSetOne(y);
- goto Exit;
- }
-
- n = (SIGNED_VALUE)y->MaxPrec;
- if (x->MaxPrec > (size_t)n) n = (ssize_t)x->MaxPrec;
-
- /* allocate temporally variables */
- /* TODO: reconsider MaxPrec of f and r */
- f = NewOneNolimit(1, y->MaxPrec * (BASE_FIG + 2));
- r = NewOneNolimit(1, (n + n) * (BASE_FIG + 2));
-
- nr = 0;
- y_prec = y->MaxPrec;
-
- prec = x->exponent - (ssize_t)y_prec;
- if (x->exponent > 0)
- ++prec;
- else
- --prec;
-
- VpVtoD(&val, &e, x); /* val <- x */
- e /= (SIGNED_VALUE)BASE_FIG;
- n = e / 2;
- if (e - n * 2 != 0) {
- val /= BASE;
- n = (e + 1) / 2;
- }
- VpDtoV(y, sqrt(val)); /* y <- sqrt(val) */
- y->exponent += n;
- n = (SIGNED_VALUE)roomof(BIGDECIMAL_DOUBLE_FIGURES, BASE_FIG);
- y->MaxPrec = Min((size_t)n , y_prec);
- f->MaxPrec = y->MaxPrec + 1;
- n = (SIGNED_VALUE)(y_prec * BASE_FIG);
- if (n < (SIGNED_VALUE)maxnr) n = (SIGNED_VALUE)maxnr;
-
- /*
- * Perform: y_{n+1} = (y_n - x/y_n) / 2
- */
- do {
- y->MaxPrec *= 2;
- if (y->MaxPrec > y_prec) y->MaxPrec = y_prec;
- f->MaxPrec = y->MaxPrec;
- VpDivd(f, r, x, y); /* f = x/y */
- VpAddSub(r, f, y, -1); /* r = f - y */
- VpMult(f, VpConstPt5, r); /* f = 0.5*r */
- if (VpIsZero(f))
- goto converge;
- VpAddSub(r, f, y, 1); /* r = y + f */
- VpAsgn(y, r, 1); /* y = r */
- } while (++nr < n);
-
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- printf("ERROR(VpSqrt): did not converge within %ld iterations.\n", nr);
- }
-#endif /* BIGDECIMAL_DEBUG */
- y->MaxPrec = y_prec;
-
-converge:
- VpChangeSign(y, 1);
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VpMult(r, y, y);
- VpAddSub(f, x, r, -1);
- printf("VpSqrt: iterations = %"PRIdSIZE"\n", nr);
- VPrint(stdout, " y =% \n", y);
- VPrint(stdout, " x =% \n", x);
- VPrint(stdout, " x-y*y = % \n", f);
- }
-#endif /* BIGDECIMAL_DEBUG */
- y->MaxPrec = y_prec;
-
-Exit:
- rbd_free_struct(f);
- rbd_free_struct(r);
- return 1;
-}
-
-/*
- * Round relatively from the decimal point.
- * f: rounding mode
- * nf: digit location to round from the decimal point.
- */
-VP_EXPORT int
-VpMidRound(Real *y, unsigned short f, ssize_t nf)
-{
- /* fracf: any positive digit under rounding position? */
- /* fracf_1further: any positive digits under one further than the rounding position? */
- /* exptoadd: number of digits needed to compensate negative nf */
- int fracf, fracf_1further;
- ssize_t n,i,ix,ioffset, exptoadd;
- DECDIG v, shifter;
- DECDIG div;
-
- nf += y->exponent * (ssize_t)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 = nf / (ssize_t)BASE_FIG;
- if ((size_t)ix >= y->Prec) return 0; /* rounding position too right(small). */
- v = y->frac[ix];
-
- ioffset = nf - ix*(ssize_t)BASE_FIG;
- n = (ssize_t)BASE_FIG - ioffset - 1;
- for (shifter = 1, i = 0; i < n; ++i) shifter *= 10;
-
- /* so the representation used (in y->frac) is an array of DECDIG, where
- each DECDIG contains a value between 0 and BASE-1, consisting of BASE_FIG
- decimal places.
-
- (that numbers of decimal places are typed as ssize_t is somewhat confusing)
-
- nf is now position (in decimal places) of the digit from the start of
- the array.
-
- ix is the position (in DECDIGs) of the DECDIG containing the decimal digit,
- from the start of the array.
-
- v is the value of this DECDIG
-
- ioffset is the number of extra decimal places along of this decimal digit
- within v.
-
- n is the number of decimal digits remaining within v after this decimal digit
- shifter is 10**n,
-
- v % shifter are the remaining digits within v
- v % (shifter * 10) are the digit together with the remaining digits within v
- v / shifter are the digit's predecessors together with the digit
- div = v / shifter / 10 is just the digit's precessors
- (v / shifter) - div*10 is just the digit, which is what v ends up being reassigned to.
- */
-
- fracf = (v % (shifter * 10) > 0);
- fracf_1further = ((v % shifter) > 0);
-
- v /= shifter;
- div = v / 10;
- v = v - div*10;
- /* now v is just the digit required.
- now fracf is whether the digit or any of the remaining digits within v are non-zero
- now fracf_1further is whether any of the remaining digits within v are non-zero
- */
-
- /* now check all the remaining DECDIGs for zero-ness a whole DECDIG at a time.
- if we spot any non-zeroness, that means that we found a positive digit under
- rounding position, and we also found a positive digit under one further than
- the rounding position, so both searches (to see if any such non-zero digit exists)
- can stop */
-
- for (i = ix + 1; (size_t)i < y->Prec; i++) {
- if (y->frac[i] % BASE) {
- fracf = fracf_1further = 1;
- break;
- }
- }
-
- /* now fracf = does any positive digit exist under the rounding position?
- now fracf_1further = does any positive digit exist under one further than the
- rounding position?
- now v = the first digit under the rounding position */
-
- /* drop digits after pointed digit */
- memset(y->frac + ix + 1, 0, (y->Prec - (ix + 1)) * sizeof(DECDIG));
-
- switch (f) {
- case VP_ROUND_DOWN: /* Truncate */
- break;
- case VP_ROUND_UP: /* Roundup */
- if (fracf) ++div;
- break;
- case VP_ROUND_HALF_UP:
- if (v>=5) ++div;
- break;
- case VP_ROUND_HALF_DOWN:
- if (v > 5 || (v == 5 && fracf_1further)) ++div;
- break;
- case VP_ROUND_CEIL:
- if (fracf && BIGDECIMAL_POSITIVE_P(y)) ++div;
- break;
- case VP_ROUND_FLOOR:
- if (fracf && BIGDECIMAL_NEGATIVE_P(y)) ++div;
- break;
- case VP_ROUND_HALF_EVEN: /* Banker's rounding */
- if (v > 5) ++div;
- else if (v == 5) {
- if (fracf_1further) {
- ++div;
- }
- else {
- if (ioffset == 0) {
- /* v is the first decimal digit of its DECDIG;
- need to grab the previous DECDIG if present
- to check for evenness of the previous decimal
- digit (which is same as that of the DECDIG since
- base 10 has a factor of 2) */
- if (ix && (y->frac[ix-1] % 2)) ++div;
- }
- else {
- if (div % 2) ++div;
- }
- }
- }
- break;
- }
- for (i = 0; i <= n; ++i) div *= 10;
- if (div >= BASE) {
- if (ix) {
- y->frac[ix] = 0;
- VpRdup(y, ix);
- }
- else {
- short s = VpGetSign(y);
- SIGNED_VALUE e = y->exponent;
- VpSetOne(y);
- VpSetSign(y, s);
- y->exponent = e + 1;
- }
- }
- else {
- y->frac[ix] = div;
- VpNmlz(y);
- }
- if (exptoadd > 0) {
- y->exponent += (SIGNED_VALUE)(exptoadd / BASE_FIG);
- exptoadd %= (ssize_t)BASE_FIG;
- for (i = 0; i < exptoadd; i++) {
- y->frac[0] *= 10;
- if (y->frac[0] >= BASE) {
- y->frac[0] /= BASE;
- y->exponent++;
- }
- }
- }
- return 1;
-}
-
-VP_EXPORT int
-VpLeftRound(Real *y, unsigned short f, ssize_t nf)
-/*
- * Round from the left hand side of the digits.
- */
-{
- DECDIG v;
- if (!VpHasVal(y)) return 0; /* Unable to round */
- v = y->frac[0];
- nf -= VpExponent(y) * (ssize_t)BASE_FIG;
- while ((v /= 10) != 0) nf--;
- nf += (ssize_t)BASE_FIG-1;
- return VpMidRound(y, f, nf);
-}
-
-VP_EXPORT int
-VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t nf)
-{
- /* First,assign whole value in truncation mode */
- if (VpAsgn(y, x, 10) <= 1) return 0; /* Zero,NaN,or Infinity */
- return VpMidRound(y, f, nf);
-}
-
-static int
-VpLimitRound(Real *c, size_t ixDigit)
-{
- size_t ix = VpGetPrecLimit();
- if (!VpNmlz(c)) return -1;
- if (!ix) return 0;
- if (!ixDigit) ixDigit = c->Prec-1;
- if ((ix + BASE_FIG - 1) / BASE_FIG > ixDigit + 1) return 0;
- return VpLeftRound(c, VpGetRoundMode(), (ssize_t)ix);
-}
-
-/* If I understand correctly, this is only ever used to round off the final decimal
- digit of precision */
-static void
-VpInternalRound(Real *c, size_t ixDigit, DECDIG vPrev, DECDIG v)
-{
- int f = 0;
-
- unsigned short const rounding_mode = VpGetRoundMode();
-
- if (VpLimitRound(c, ixDigit)) return;
- if (!v) return;
-
- v /= BASE1;
- switch (rounding_mode) {
- case VP_ROUND_DOWN:
- break;
- case VP_ROUND_UP:
- if (v) f = 1;
- break;
- case VP_ROUND_HALF_UP:
- if (v >= 5) f = 1;
- break;
- case VP_ROUND_HALF_DOWN:
- /* this is ok - because this is the last digit of precision,
- the case where v == 5 and some further digits are nonzero
- will never occur */
- if (v >= 6) f = 1;
- break;
- case VP_ROUND_CEIL:
- if (v && BIGDECIMAL_POSITIVE_P(c)) f = 1;
- break;
- case VP_ROUND_FLOOR:
- if (v && BIGDECIMAL_NEGATIVE_P(c)) f = 1;
- break;
- case VP_ROUND_HALF_EVEN: /* Banker's rounding */
- /* as per VP_ROUND_HALF_DOWN, because this is the last digit of precision,
- there is no case to worry about where v == 5 and some further digits are nonzero */
- if (v > 5) f = 1;
- else if (v == 5 && vPrev % 2) f = 1;
- break;
- }
- if (f) {
- VpRdup(c, ixDigit);
- VpNmlz(c);
- }
-}
-
-/*
- * Rounds up m(plus one to final digit of m).
- */
-static int
-VpRdup(Real *m, size_t ind_m)
-{
- DECDIG carry;
-
- if (!ind_m) ind_m = m->Prec;
-
- carry = 1;
- while (carry > 0 && ind_m--) {
- m->frac[ind_m] += carry;
- if (m->frac[ind_m] >= BASE) m->frac[ind_m] -= BASE;
- else carry = 0;
- }
- if (carry > 0) { /* Overflow,count exponent and set fraction part be 1 */
- if (!AddExponent(m, 1)) return 0;
- m->Prec = m->frac[0] = 1;
- }
- else {
- VpNmlz(m);
- }
- return 1;
-}
-
-/*
- * y = x - fix(x)
- */
-VP_EXPORT void
-VpFrac(Real *y, Real *x)
-{
- size_t my, ind_y, ind_x;
-
- if (!VpHasVal(x)) {
- VpAsgn(y, x, 1);
- goto Exit;
- }
-
- if (x->exponent > 0 && (size_t)x->exponent >= x->Prec) {
- VpSetZero(y, VpGetSign(x));
- goto Exit;
- }
- else if (x->exponent <= 0) {
- VpAsgn(y, x, 1);
- goto Exit;
- }
-
- /* satisfy: x->exponent > 0 */
-
- y->Prec = x->Prec - (size_t)x->exponent;
- y->Prec = Min(y->Prec, y->MaxPrec);
- y->exponent = 0;
- VpSetSign(y, VpGetSign(x));
- ind_y = 0;
- my = y->Prec;
- ind_x = x->exponent;
- while (ind_y < my) {
- y->frac[ind_y] = x->frac[ind_x];
- ++ind_y;
- ++ind_x;
- }
- VpNmlz(y);
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpFrac y=%\n", y);
- VPrint(stdout, " x=%\n", x);
- }
-#endif /* BIGDECIMAL_DEBUG */
- return;
-}
-
-/*
- * y = x ** n
- */
-VP_EXPORT int
-VpPowerByInt(Real *y, Real *x, SIGNED_VALUE n)
-{
- size_t s, ss;
- ssize_t sign;
- Real *w1 = NULL;
- Real *w2 = NULL;
-
- if (VpIsZero(x)) {
- if (n == 0) {
- VpSetOne(y);
- goto Exit;
- }
- sign = VpGetSign(x);
- if (n < 0) {
- n = -n;
- if (sign < 0) sign = (n % 2) ? -1 : 1;
- VpSetInf(y, sign);
- }
- else {
- if (sign < 0) sign = (n % 2) ? -1 : 1;
- VpSetZero(y,sign);
- }
- goto Exit;
- }
- if (VpIsNaN(x)) {
- VpSetNaN(y);
- goto Exit;
- }
- if (VpIsInf(x)) {
- if (n == 0) {
- VpSetOne(y);
- goto Exit;
- }
- if (n > 0) {
- VpSetInf(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1);
- goto Exit;
- }
- VpSetZero(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1);
- goto Exit;
- }
-
- if (x->exponent == 1 && x->Prec == 1 && x->frac[0] == 1) {
- /* abs(x) = 1 */
- VpSetOne(y);
- if (BIGDECIMAL_POSITIVE_P(x)) goto Exit;
- if ((n % 2) == 0) goto Exit;
- VpSetSign(y, -1);
- goto Exit;
- }
-
- if (n > 0) sign = 1;
- else if (n < 0) {
- sign = -1;
- n = -n;
- }
- else {
- VpSetOne(y);
- goto Exit;
- }
-
- /* Allocate working variables */
- /* TODO: reconsider MaxPrec of w1 and w2 */
- w1 = NewZeroNolimit(1, (y->MaxPrec + 2) * BASE_FIG);
- w2 = NewZeroNolimit(1, (w1->MaxPrec * 2 + 1) * BASE_FIG);
-
- /* calculation start */
-
- VpAsgn(y, x, 1);
- --n;
- while (n > 0) {
- VpAsgn(w1, x, 1);
- s = 1;
- while (ss = s, (s += s) <= (size_t)n) {
- VpMult(w2, w1, w1);
- VpAsgn(w1, w2, 1);
- }
- n -= (SIGNED_VALUE)ss;
- VpMult(w2, y, w1);
- VpAsgn(y, w2, 1);
- }
- if (sign < 0) {
- VpDivd(w1, w2, VpConstOne, y);
- VpAsgn(y, w1, 1);
- }
-
-Exit:
-#ifdef BIGDECIMAL_DEBUG
- if (gfDebug) {
- VPrint(stdout, "VpPowerByInt y=%\n", y);
- VPrint(stdout, "VpPowerByInt x=%\n", x);
- printf(" n=%"PRIdVALUE"\n", n);
- }
-#endif /* BIGDECIMAL_DEBUG */
- rbd_free_struct(w2);
- rbd_free_struct(w1);
- return 1;
-}
-
-#ifdef BIGDECIMAL_DEBUG
-int
-VpVarCheck(Real * v)
-/*
- * Checks the validity of the Real variable v.
- * [Input]
- * v ... Real *, variable to be checked.
- * [Returns]
- * 0 ... correct v.
- * other ... error
- */
-{
- size_t i;
-
- if (v->MaxPrec == 0) {
- printf("ERROR(VpVarCheck): Illegal Max. Precision(=%"PRIuSIZE")\n",
- v->MaxPrec);
- return 1;
- }
- if (v->Prec == 0 || v->Prec > v->MaxPrec) {
- printf("ERROR(VpVarCheck): Illegal Precision(=%"PRIuSIZE")\n", v->Prec);
- printf(" Max. Prec.=%"PRIuSIZE"\n", v->MaxPrec);
- return 2;
- }
- for (i = 0; i < v->Prec; ++i) {
- if (v->frac[i] >= BASE) {
- printf("ERROR(VpVarCheck): Illegal fraction\n");
- printf(" Frac[%"PRIuSIZE"]=%"PRIuDECDIG"\n", i, v->frac[i]);
- printf(" Prec. =%"PRIuSIZE"\n", v->Prec);
- printf(" Exp. =%"PRIdVALUE"\n", v->exponent);
- printf(" BASE =%"PRIuDECDIG"\n", BASE);
- return 3;
- }
- }
- return 0;
-}
-#endif /* BIGDECIMAL_DEBUG */
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
deleted file mode 100644
index f9f3b45616..0000000000
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ /dev/null
@@ -1,54 +0,0 @@
-# coding: utf-8
-
-name = File.basename(__FILE__, '.*')
-source_version = ["", "ext/#{name}/"].find do |dir|
- begin
- break File.foreach(File.join(__dir__, "#{dir}#{name}.c")) {|line|
- break $1.sub("-", ".") if /^#define\s+#{name.upcase}_VERSION\s+"(.+)"/o =~ line
- }
- rescue Errno::ENOENT
- end
-end or raise "can't find #{name.upcase}_VERSION"
-
-Gem::Specification.new do |s|
- s.name = name
- s.version = source_version
- s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
- s.email = ["mrkn@mrkn.jp"]
-
- s.summary = "Arbitrary-precision decimal floating-point number library."
- s.description = "This library provides arbitrary-precision decimal floating-point number class."
- s.homepage = "https://github.com/ruby/bigdecimal"
- s.licenses = ["Ruby", "BSD-2-Clause"]
-
- s.require_paths = %w[lib]
- s.files = %w[
- bigdecimal.gemspec
- lib/bigdecimal.rb
- lib/bigdecimal/jacobian.rb
- lib/bigdecimal/ludcmp.rb
- lib/bigdecimal/math.rb
- lib/bigdecimal/newton.rb
- lib/bigdecimal/util.rb
- sample/linear.rb
- sample/nlsolve.rb
- sample/pi.rb
- ]
- if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
- s.platform = 'java'
- else
- s.extensions = %w[ext/bigdecimal/extconf.rb]
- s.files += %w[
- ext/bigdecimal/bigdecimal.c
- ext/bigdecimal/bigdecimal.h
- ext/bigdecimal/bits.h
- ext/bigdecimal/feature.h
- ext/bigdecimal/missing.c
- ext/bigdecimal/missing.h
- ext/bigdecimal/missing/dtoa.c
- ext/bigdecimal/static_assert.h
- ]
- end
-
- s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
-end
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
deleted file mode 100644
index 54fed811fb..0000000000
--- a/ext/bigdecimal/bigdecimal.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- *
- * Ruby BigDecimal(Variable decimal precision) extension library.
- *
- * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
- *
- */
-
-#ifndef RUBY_BIG_DECIMAL_H
-#define RUBY_BIG_DECIMAL_H 1
-
-#define RUBY_NO_OLD_COMPATIBILITY
-#include "ruby/ruby.h"
-#include "missing.h"
-
-#ifdef HAVE_FLOAT_H
-# include <float.h>
-#endif
-
-#ifdef HAVE_INT64_T
-# define DECDIG uint32_t
-# define DECDIG_DBL uint64_t
-# define DECDIG_DBL_SIGNED int64_t
-# define SIZEOF_DECDIG 4
-# define PRI_DECDIG_PREFIX ""
-# ifdef PRI_LL_PREFIX
-# define PRI_DECDIG_DBL_PREFIX PRI_LL_PREFIX
-# else
-# define PRI_DECDIG_DBL_PREFIX "l"
-# endif
-#else
-# define DECDIG uint16_t
-# define DECDIG_DBL uint32_t
-# define DECDIG_DBL_SIGNED int32_t
-# define SIZEOF_DECDIG 2
-# define PRI_DECDIG_PREFIX "h"
-# define PRI_DECDIG_DBL_PREFIX ""
-#endif
-
-#define PRIdDECDIG PRI_DECDIG_PREFIX"d"
-#define PRIiDECDIG PRI_DECDIG_PREFIX"i"
-#define PRIoDECDIG PRI_DECDIG_PREFIX"o"
-#define PRIuDECDIG PRI_DECDIG_PREFIX"u"
-#define PRIxDECDIG PRI_DECDIG_PREFIX"x"
-#define PRIXDECDIG PRI_DECDIG_PREFIX"X"
-
-#define PRIdDECDIG_DBL PRI_DECDIG_DBL_PREFIX"d"
-#define PRIiDECDIG_DBL PRI_DECDIG_DBL_PREFIX"i"
-#define PRIoDECDIG_DBL PRI_DECDIG_DBL_PREFIX"o"
-#define PRIuDECDIG_DBL PRI_DECDIG_DBL_PREFIX"u"
-#define PRIxDECDIG_DBL PRI_DECDIG_DBL_PREFIX"x"
-#define PRIXDECDIG_DBL PRI_DECDIG_DBL_PREFIX"X"
-
-#if SIZEOF_DECDIG == 4
-# define BIGDECIMAL_BASE ((DECDIG)1000000000U)
-# define BIGDECIMAL_COMPONENT_FIGURES 9
-/*
- * The number of components required for a 64-bit integer.
- *
- * INT64_MAX: 9_223372036_854775807
- * UINT64_MAX: 18_446744073_709551615
- */
-# define BIGDECIMAL_INT64_MAX_LENGTH 3
-
-#elif SIZEOF_DECDIG == 2
-# define BIGDECIMAL_BASE ((DECDIG)10000U)
-# define BIGDECIMAL_COMPONENT_FIGURES 4
-/*
- * The number of components required for a 64-bit integer.
- *
- * INT64_MAX: 922_3372_0368_5477_5807
- * UINT64_MAX: 1844_6744_0737_0955_1615
- */
-# define BIGDECIMAL_INT64_MAX_LENGTH 5
-
-#else
-# error Unknown size of DECDIG
-#endif
-
-#define BIGDECIMAL_DOUBLE_FIGURES (1+DBL_DIG)
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-extern VALUE rb_cBigDecimal;
-
-/*
- * NaN & Infinity
- */
-#define SZ_NaN "NaN"
-#define SZ_INF "Infinity"
-#define SZ_PINF "+Infinity"
-#define SZ_NINF "-Infinity"
-
-/*
- * #define VP_EXPORT other than static to let VP_ routines
- * be called from outside of this module.
- */
-#define VP_EXPORT static
-
-/* Exception mode */
-#define VP_EXCEPTION_ALL ((unsigned short)0x00FF)
-#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001)
-#define VP_EXCEPTION_NaN ((unsigned short)0x0002)
-#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
-#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */
-#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010)
-
-/* Following 2 exceptions can't controlled by user */
-#define VP_EXCEPTION_OP ((unsigned short)0x0020)
-
-#define BIGDECIMAL_EXCEPTION_MODE_DEFAULT 0U
-
-/* This is used in BigDecimal#mode */
-#define VP_ROUND_MODE ((unsigned short)0x0100)
-
-/* Rounding mode */
-#define VP_ROUND_UP RBD_ROUND_UP
-#define VP_ROUND_DOWN RBD_ROUND_DOWN
-#define VP_ROUND_HALF_UP RBD_ROUND_HALF_UP
-#define VP_ROUND_HALF_DOWN RBD_ROUND_HALF_DOWN
-#define VP_ROUND_CEIL RBD_ROUND_CEIL
-#define VP_ROUND_FLOOR RBD_ROUND_FLOOR
-#define VP_ROUND_HALF_EVEN RBD_ROUND_HALF_EVEN
-
-enum rbd_rounding_mode {
- RBD_ROUND_UP = 1,
- RBD_ROUND_DOWN = 2,
- RBD_ROUND_HALF_UP = 3,
- RBD_ROUND_HALF_DOWN = 4,
- RBD_ROUND_CEIL = 5,
- RBD_ROUND_FLOOR = 6,
- RBD_ROUND_HALF_EVEN = 7,
-
- RBD_ROUND_DEFAULT = RBD_ROUND_HALF_UP,
- RBD_ROUND_TRUNCATE = RBD_ROUND_DOWN,
- RBD_ROUND_BANKER = RBD_ROUND_HALF_EVEN,
- RBD_ROUND_CEILING = RBD_ROUND_CEIL
-};
-
-#define BIGDECIMAL_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP
-
-/* Sign flag */
-#define VP_SIGN_NaN 0 /* NaN */
-#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */
-#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */
-#define VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */
-#define VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */
-#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */
-#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */
-
-/* The size of fraction part array */
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-#define FLEXIBLE_ARRAY_SIZE /* */
-#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define FLEXIBLE_ARRAY_SIZE 0
-#else
-#define FLEXIBLE_ARRAY_SIZE 1
-#endif
-
-/*
- * VP representation
- * r = 0.xxxxxxxxx *BASE**exponent
- */
-typedef struct {
- VALUE obj; /* Back pointer(VALUE) for Ruby object. */
- size_t MaxPrec; /* Maximum precision size */
- /* This is the actual size of frac[] */
- /*(frac[0] to frac[MaxPrec] are available). */
- size_t Prec; /* Current precision size. */
- /* This indicates how much the */
- /* array frac[] is actually used. */
- SIGNED_VALUE exponent; /* Exponent part. */
- short sign; /* Attributes of the value. */
- /*
- * ==0 : NaN
- * 1 : Positive zero
- * -1 : Negative zero
- * 2 : Positive number
- * -2 : Negative number
- * 3 : Positive infinite number
- * -3 : Negative infinite number
- */
- short flag; /* Not used in vp_routines,space for user. */
- DECDIG frac[FLEXIBLE_ARRAY_SIZE]; /* Array of fraction part. */
-} Real;
-
-/*
- * ------------------
- * EXPORTables.
- * ------------------
- */
-
-VP_EXPORT Real *VpNewRbClass(size_t mx, char const *str, VALUE klass, bool strict_p, bool raise_exception);
-
-VP_EXPORT Real *VpCreateRbObject(size_t mx, const char *str, bool raise_exception);
-
-#define VpBaseFig() BIGDECIMAL_COMPONENT_FIGURES
-#define VpDblFig() BIGDECIMAL_DOUBLE_FIGURES
-#define VpBaseVal() BIGDECIMAL_BASE
-
-/* Zero,Inf,NaN (isinf(),isnan() used to check) */
-VP_EXPORT double VpGetDoubleNaN(void);
-VP_EXPORT double VpGetDoublePosInf(void);
-VP_EXPORT double VpGetDoubleNegInf(void);
-VP_EXPORT double VpGetDoubleNegZero(void);
-
-/* These 2 functions added at v1.1.7 */
-VP_EXPORT size_t VpGetPrecLimit(void);
-VP_EXPORT size_t VpSetPrecLimit(size_t n);
-
-/* Round mode */
-VP_EXPORT int VpIsRoundMode(unsigned short n);
-VP_EXPORT unsigned short VpGetRoundMode(void);
-VP_EXPORT unsigned short VpSetRoundMode(unsigned short n);
-
-VP_EXPORT int VpException(unsigned short f,const char *str,int always);
-#if 0 /* unused */
-VP_EXPORT int VpIsNegDoubleZero(double v);
-#endif
-VP_EXPORT size_t VpNumOfChars(Real *vp,const char *pszFmt);
-VP_EXPORT size_t VpInit(DECDIG BaseVal);
-VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal, int strict_p, int exc);
-VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw);
-VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation);
-VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b);
-VP_EXPORT size_t VpDivd(Real *c,Real *r,Real *a,Real *b);
-VP_EXPORT int VpComp(Real *a,Real *b);
-VP_EXPORT ssize_t VpExponent10(Real *a);
-VP_EXPORT void VpSzMantissa(Real *a, char *buf, size_t bufsize);
-VP_EXPORT int VpToSpecialString(Real *a, char *buf, size_t bufsize, int fPlus);
-VP_EXPORT void VpToString(Real *a, char *buf, size_t bufsize, size_t fFmt, int fPlus);
-VP_EXPORT void VpToFString(Real *a, char *buf, size_t bufsize, size_t fFmt, int fPlus);
-VP_EXPORT int VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne);
-VP_EXPORT int VpVtoD(double *d, SIGNED_VALUE *e, Real *m);
-VP_EXPORT void VpDtoV(Real *m,double d);
-#if 0 /* unused */
-VP_EXPORT void VpItoV(Real *m,S_INT ival);
-#endif
-VP_EXPORT int VpSqrt(Real *y,Real *x);
-VP_EXPORT int VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t il);
-VP_EXPORT int VpMidRound(Real *y, unsigned short f, ssize_t nf);
-VP_EXPORT int VpLeftRound(Real *y, unsigned short f, ssize_t nf);
-VP_EXPORT void VpFrac(Real *y, Real *x);
-VP_EXPORT int VpPowerByInt(Real *y, Real *x, SIGNED_VALUE n);
-#define VpPower VpPowerByInt
-
-/* VP constants */
-VP_EXPORT Real *VpOne(void);
-
-/*
- * ------------------
- * MACRO definitions.
- * ------------------
- */
-#define Abs(a) (((a)>= 0)?(a):(-(a)))
-#define Max(a, b) (((a)>(b))?(a):(b))
-#define Min(a, b) (((a)>(b))?(b):(a))
-
-#define VpMaxPrec(a) ((a)->MaxPrec)
-#define VpPrec(a) ((a)->Prec)
-#define VpGetFlag(a) ((a)->flag)
-
-/* Sign */
-
-/* VpGetSign(a) returns 1,-1 if a>0,a<0 respectively */
-#define VpGetSign(a) (((a)->sign>0)?1:(-1))
-/* Change sign of a to a>0,a<0 if s = 1,-1 respectively */
-#define VpChangeSign(a,s) {if((s)>0) (a)->sign=(short)Abs((ssize_t)(a)->sign);else (a)->sign=-(short)Abs((ssize_t)(a)->sign);}
-/* Sets sign of a to a>0,a<0 if s = 1,-1 respectively */
-#define VpSetSign(a,s) {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;}
-
-/* 1 */
-#define VpSetOne(a) {(a)->Prec=(a)->exponent=(a)->frac[0]=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;}
-
-/* ZEROs */
-#define VpIsPosZero(a) ((a)->sign==VP_SIGN_POSITIVE_ZERO)
-#define VpIsNegZero(a) ((a)->sign==VP_SIGN_NEGATIVE_ZERO)
-#define VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a))
-#define VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)
-#define VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)
-#define VpSetZero(a,s) (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a))
-
-/* NaN */
-#define VpIsNaN(a) ((a)->sign==VP_SIGN_NaN)
-#define VpSetNaN(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN)
-
-/* Infinity */
-#define VpIsPosInf(a) ((a)->sign==VP_SIGN_POSITIVE_INFINITE)
-#define VpIsNegInf(a) ((a)->sign==VP_SIGN_NEGATIVE_INFINITE)
-#define VpIsInf(a) (VpIsPosInf(a) || VpIsNegInf(a))
-#define VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) )
-#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
-#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
-#define VpSetInf(a,s) (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a))
-#define VpHasVal(a) (a->frac[0])
-#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
-#define VpExponent(a) (a->exponent)
-#ifdef BIGDECIMAL_DEBUG
-int VpVarCheck(Real * v);
-#endif /* BIGDECIMAL_DEBUG */
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-#endif /* RUBY_BIG_DECIMAL_H */
diff --git a/ext/bigdecimal/bits.h b/ext/bigdecimal/bits.h
deleted file mode 100644
index 6e1e4776e3..0000000000
--- a/ext/bigdecimal/bits.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef BIGDECIMAL_BITS_H
-#define BIGDECIMAL_BITS_H
-
-#include "feature.h"
-#include "static_assert.h"
-
-#if defined(__x86_64__) && defined(HAVE_X86INTRIN_H)
-# include <x86intrin.h> /* for _lzcnt_u64, etc. */
-#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H)
-# include <intrin.h> /* for the following intrinsics */
-#endif
-
-#if defined(_MSC_VER) && defined(__AVX2__)
-# pragma intrinsic(__lzcnt)
-# pragma intrinsic(__lzcnt64)
-#endif
-
-#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
-#define roomof(x, y) (((x) + (y) - 1) / (y))
-#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
-
-#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
- (a) == 0 ? 0 : \
- (a) == -1 ? (b) < -(max) : \
- (a) > 0 ? \
- ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
- ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
-
-#ifdef HAVE_UINT128_T
-# define bit_length(x) \
- (unsigned int) \
- (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
- sizeof(x) <= sizeof(int64_t) ? 64 - nlz_int64((uint64_t)(x)) : \
- 128 - nlz_int128((uint128_t)(x)))
-#else
-# define bit_length(x) \
- (unsigned int) \
- (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
- 64 - nlz_int64((uint64_t)(x)))
-#endif
-
-static inline unsigned nlz_int32(uint32_t x);
-static inline unsigned nlz_int64(uint64_t x);
-#ifdef HAVE_UINT128_T
-static inline unsigned nlz_int128(uint128_t x);
-#endif
-
-static inline unsigned int
-nlz_int32(uint32_t x)
-{
-#if defined(_MSC_VER) && defined(__AVX2__) && defined(HAVE___LZCNT)
- /* Note: It seems there is no such thing like __LZCNT__ predefined in MSVC.
- * AMD CPUs have had this instruction for decades (since K10) but for
- * Intel, Haswell is the oldest one. We need to use __AVX2__ for maximum
- * safety. */
- return (unsigned int)__lzcnt(x);
-
-#elif defined(__x86_64__) && defined(__LZCNT__) && defined(HAVE__LZCNT_U32)
- return (unsigned int)_lzcnt_u32(x);
-
-#elif defined(_MSC_VER) && defined(HAVE__BITSCANREVERSE)
- unsigned long r;
- return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
-
-#elif __has_builtin(__builtin_clz)
- STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
- return x ? (unsigned int)__builtin_clz(x) : 32;
-
-#else
- uint32_t y;
- unsigned n = 32;
- y = x >> 16; if (y) {n -= 16; x = y;}
- y = x >> 8; if (y) {n -= 8; x = y;}
- y = x >> 4; if (y) {n -= 4; x = y;}
- y = x >> 2; if (y) {n -= 2; x = y;}
- y = x >> 1; if (y) {return n - 2;}
- return (unsigned int)(n - x);
-#endif
-}
-
-static inline unsigned int
-nlz_int64(uint64_t x)
-{
-#if defined(_MSC_VER) && defined(__AVX2__) && defined(HAVE___LZCNT64)
- return (unsigned int)__lzcnt64(x);
-
-#elif defined(__x86_64__) && defined(__LZCNT__) && defined(HAVE__LZCNT_U64)
- return (unsigned int)_lzcnt_u64(x);
-
-#elif defined(_WIN64) && defined(_MSC_VER) && defined(HAVE__BITSCANREVERSE64)
- unsigned long r;
- return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
-
-#elif __has_builtin(__builtin_clzl) && __has_builtin(__builtin_clzll) && !(defined(__sun) && defined(__sparc))
- if (x == 0) {
- return 64;
- }
- else if (sizeof(long) * CHAR_BIT == 64) {
- return (unsigned int)__builtin_clzl((unsigned long)x);
- }
- else if (sizeof(long long) * CHAR_BIT == 64) {
- return (unsigned int)__builtin_clzll((unsigned long long)x);
- }
- else {
- /* :FIXME: Is there a way to make this branch a compile-time error? */
- __builtin_unreachable();
- }
-
-#else
- uint64_t y;
- unsigned int n = 64;
- y = x >> 32; if (y) {n -= 32; x = y;}
- y = x >> 16; if (y) {n -= 16; x = y;}
- y = x >> 8; if (y) {n -= 8; x = y;}
- y = x >> 4; if (y) {n -= 4; x = y;}
- y = x >> 2; if (y) {n -= 2; x = y;}
- y = x >> 1; if (y) {return n - 2;}
- return (unsigned int)(n - x);
-
-#endif
-}
-
-#ifdef HAVE_UINT128_T
-static inline unsigned int
-nlz_int128(uint128_t x)
-{
- uint64_t y = (uint64_t)(x >> 64);
-
- if (x == 0) {
- return 128;
- }
- else if (y == 0) {
- return (unsigned int)nlz_int64(x) + 64;
- }
- else {
- return (unsigned int)nlz_int64(y);
- }
-}
-#endif
-
-#endif /* BIGDECIMAL_BITS_H */
diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend
deleted file mode 100644
index a2455ebbda..0000000000
--- a/ext/bigdecimal/depend
+++ /dev/null
@@ -1,327 +0,0 @@
-Makefile: $(BIGDECIMAL_RB)
-
-# AUTOGENERATED DEPENDENCIES START
-bigdecimal.o: $(RUBY_EXTCONF_H)
-bigdecimal.o: $(arch_hdrdir)/ruby/config.h
-bigdecimal.o: $(hdrdir)/ruby/assert.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/assume.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/attributes.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/bool.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/inttypes.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/limits.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/long_long.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/stdalign.h
-bigdecimal.o: $(hdrdir)/ruby/backward/2/stdarg.h
-bigdecimal.o: $(hdrdir)/ruby/defines.h
-bigdecimal.o: $(hdrdir)/ruby/intern.h
-bigdecimal.o: $(hdrdir)/ruby/internal/abi.h
-bigdecimal.o: $(hdrdir)/ruby/internal/anyargs.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-bigdecimal.o: $(hdrdir)/ruby/internal/assume.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/artificial.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/cold.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/const.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/error.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/format.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/noalias.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/noinline.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/pure.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/restrict.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/warning.h
-bigdecimal.o: $(hdrdir)/ruby/internal/attr/weakref.h
-bigdecimal.o: $(hdrdir)/ruby/internal/cast.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-bigdecimal.o: $(hdrdir)/ruby/internal/compiler_since.h
-bigdecimal.o: $(hdrdir)/ruby/internal/config.h
-bigdecimal.o: $(hdrdir)/ruby/internal/constant_p.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rarray.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rbasic.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rbignum.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rclass.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rdata.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rfile.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rhash.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/robject.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rregexp.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rstring.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rstruct.h
-bigdecimal.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-bigdecimal.o: $(hdrdir)/ruby/internal/ctype.h
-bigdecimal.o: $(hdrdir)/ruby/internal/dllexport.h
-bigdecimal.o: $(hdrdir)/ruby/internal/dosish.h
-bigdecimal.o: $(hdrdir)/ruby/internal/error.h
-bigdecimal.o: $(hdrdir)/ruby/internal/eval.h
-bigdecimal.o: $(hdrdir)/ruby/internal/event.h
-bigdecimal.o: $(hdrdir)/ruby/internal/fl_type.h
-bigdecimal.o: $(hdrdir)/ruby/internal/gc.h
-bigdecimal.o: $(hdrdir)/ruby/internal/glob.h
-bigdecimal.o: $(hdrdir)/ruby/internal/globals.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/attribute.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/builtin.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/extension.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/feature.h
-bigdecimal.o: $(hdrdir)/ruby/internal/has/warning.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/array.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/bignum.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/class.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/compar.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/complex.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/cont.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/dir.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/enum.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/error.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/eval.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/file.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/hash.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/io.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/load.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/marshal.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/numeric.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/object.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/parse.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/proc.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/process.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/random.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/range.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/rational.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/re.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/ruby.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/select.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/signal.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/string.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/struct.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/thread.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/time.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/variable.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/vm.h
-bigdecimal.o: $(hdrdir)/ruby/internal/interpreter.h
-bigdecimal.o: $(hdrdir)/ruby/internal/iterator.h
-bigdecimal.o: $(hdrdir)/ruby/internal/memory.h
-bigdecimal.o: $(hdrdir)/ruby/internal/method.h
-bigdecimal.o: $(hdrdir)/ruby/internal/module.h
-bigdecimal.o: $(hdrdir)/ruby/internal/newobj.h
-bigdecimal.o: $(hdrdir)/ruby/internal/scan_args.h
-bigdecimal.o: $(hdrdir)/ruby/internal/special_consts.h
-bigdecimal.o: $(hdrdir)/ruby/internal/static_assert.h
-bigdecimal.o: $(hdrdir)/ruby/internal/stdalign.h
-bigdecimal.o: $(hdrdir)/ruby/internal/stdbool.h
-bigdecimal.o: $(hdrdir)/ruby/internal/symbol.h
-bigdecimal.o: $(hdrdir)/ruby/internal/value.h
-bigdecimal.o: $(hdrdir)/ruby/internal/value_type.h
-bigdecimal.o: $(hdrdir)/ruby/internal/variable.h
-bigdecimal.o: $(hdrdir)/ruby/internal/warning_push.h
-bigdecimal.o: $(hdrdir)/ruby/internal/xmalloc.h
-bigdecimal.o: $(hdrdir)/ruby/missing.h
-bigdecimal.o: $(hdrdir)/ruby/ruby.h
-bigdecimal.o: $(hdrdir)/ruby/st.h
-bigdecimal.o: $(hdrdir)/ruby/subst.h
-bigdecimal.o: $(hdrdir)/ruby/util.h
-bigdecimal.o: bigdecimal.c
-bigdecimal.o: bigdecimal.h
-bigdecimal.o: bits.h
-bigdecimal.o: feature.h
-bigdecimal.o: missing.h
-bigdecimal.o: static_assert.h
-missing.o: $(RUBY_EXTCONF_H)
-missing.o: $(arch_hdrdir)/ruby/config.h
-missing.o: $(hdrdir)/ruby/assert.h
-missing.o: $(hdrdir)/ruby/atomic.h
-missing.o: $(hdrdir)/ruby/backward.h
-missing.o: $(hdrdir)/ruby/backward/2/assume.h
-missing.o: $(hdrdir)/ruby/backward/2/attributes.h
-missing.o: $(hdrdir)/ruby/backward/2/bool.h
-missing.o: $(hdrdir)/ruby/backward/2/inttypes.h
-missing.o: $(hdrdir)/ruby/backward/2/limits.h
-missing.o: $(hdrdir)/ruby/backward/2/long_long.h
-missing.o: $(hdrdir)/ruby/backward/2/stdalign.h
-missing.o: $(hdrdir)/ruby/backward/2/stdarg.h
-missing.o: $(hdrdir)/ruby/defines.h
-missing.o: $(hdrdir)/ruby/intern.h
-missing.o: $(hdrdir)/ruby/internal/abi.h
-missing.o: $(hdrdir)/ruby/internal/anyargs.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-missing.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-missing.o: $(hdrdir)/ruby/internal/assume.h
-missing.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-missing.o: $(hdrdir)/ruby/internal/attr/artificial.h
-missing.o: $(hdrdir)/ruby/internal/attr/cold.h
-missing.o: $(hdrdir)/ruby/internal/attr/const.h
-missing.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-missing.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-missing.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-missing.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-missing.o: $(hdrdir)/ruby/internal/attr/error.h
-missing.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-missing.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-missing.o: $(hdrdir)/ruby/internal/attr/format.h
-missing.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-missing.o: $(hdrdir)/ruby/internal/attr/noalias.h
-missing.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-missing.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-missing.o: $(hdrdir)/ruby/internal/attr/noinline.h
-missing.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-missing.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-missing.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-missing.o: $(hdrdir)/ruby/internal/attr/pure.h
-missing.o: $(hdrdir)/ruby/internal/attr/restrict.h
-missing.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-missing.o: $(hdrdir)/ruby/internal/attr/warning.h
-missing.o: $(hdrdir)/ruby/internal/attr/weakref.h
-missing.o: $(hdrdir)/ruby/internal/cast.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-missing.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-missing.o: $(hdrdir)/ruby/internal/compiler_since.h
-missing.o: $(hdrdir)/ruby/internal/config.h
-missing.o: $(hdrdir)/ruby/internal/constant_p.h
-missing.o: $(hdrdir)/ruby/internal/core.h
-missing.o: $(hdrdir)/ruby/internal/core/rarray.h
-missing.o: $(hdrdir)/ruby/internal/core/rbasic.h
-missing.o: $(hdrdir)/ruby/internal/core/rbignum.h
-missing.o: $(hdrdir)/ruby/internal/core/rclass.h
-missing.o: $(hdrdir)/ruby/internal/core/rdata.h
-missing.o: $(hdrdir)/ruby/internal/core/rfile.h
-missing.o: $(hdrdir)/ruby/internal/core/rhash.h
-missing.o: $(hdrdir)/ruby/internal/core/robject.h
-missing.o: $(hdrdir)/ruby/internal/core/rregexp.h
-missing.o: $(hdrdir)/ruby/internal/core/rstring.h
-missing.o: $(hdrdir)/ruby/internal/core/rstruct.h
-missing.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-missing.o: $(hdrdir)/ruby/internal/ctype.h
-missing.o: $(hdrdir)/ruby/internal/dllexport.h
-missing.o: $(hdrdir)/ruby/internal/dosish.h
-missing.o: $(hdrdir)/ruby/internal/error.h
-missing.o: $(hdrdir)/ruby/internal/eval.h
-missing.o: $(hdrdir)/ruby/internal/event.h
-missing.o: $(hdrdir)/ruby/internal/fl_type.h
-missing.o: $(hdrdir)/ruby/internal/gc.h
-missing.o: $(hdrdir)/ruby/internal/glob.h
-missing.o: $(hdrdir)/ruby/internal/globals.h
-missing.o: $(hdrdir)/ruby/internal/has/attribute.h
-missing.o: $(hdrdir)/ruby/internal/has/builtin.h
-missing.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-missing.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-missing.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-missing.o: $(hdrdir)/ruby/internal/has/extension.h
-missing.o: $(hdrdir)/ruby/internal/has/feature.h
-missing.o: $(hdrdir)/ruby/internal/has/warning.h
-missing.o: $(hdrdir)/ruby/internal/intern/array.h
-missing.o: $(hdrdir)/ruby/internal/intern/bignum.h
-missing.o: $(hdrdir)/ruby/internal/intern/class.h
-missing.o: $(hdrdir)/ruby/internal/intern/compar.h
-missing.o: $(hdrdir)/ruby/internal/intern/complex.h
-missing.o: $(hdrdir)/ruby/internal/intern/cont.h
-missing.o: $(hdrdir)/ruby/internal/intern/dir.h
-missing.o: $(hdrdir)/ruby/internal/intern/enum.h
-missing.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-missing.o: $(hdrdir)/ruby/internal/intern/error.h
-missing.o: $(hdrdir)/ruby/internal/intern/eval.h
-missing.o: $(hdrdir)/ruby/internal/intern/file.h
-missing.o: $(hdrdir)/ruby/internal/intern/hash.h
-missing.o: $(hdrdir)/ruby/internal/intern/io.h
-missing.o: $(hdrdir)/ruby/internal/intern/load.h
-missing.o: $(hdrdir)/ruby/internal/intern/marshal.h
-missing.o: $(hdrdir)/ruby/internal/intern/numeric.h
-missing.o: $(hdrdir)/ruby/internal/intern/object.h
-missing.o: $(hdrdir)/ruby/internal/intern/parse.h
-missing.o: $(hdrdir)/ruby/internal/intern/proc.h
-missing.o: $(hdrdir)/ruby/internal/intern/process.h
-missing.o: $(hdrdir)/ruby/internal/intern/random.h
-missing.o: $(hdrdir)/ruby/internal/intern/range.h
-missing.o: $(hdrdir)/ruby/internal/intern/rational.h
-missing.o: $(hdrdir)/ruby/internal/intern/re.h
-missing.o: $(hdrdir)/ruby/internal/intern/ruby.h
-missing.o: $(hdrdir)/ruby/internal/intern/select.h
-missing.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-missing.o: $(hdrdir)/ruby/internal/intern/signal.h
-missing.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-missing.o: $(hdrdir)/ruby/internal/intern/string.h
-missing.o: $(hdrdir)/ruby/internal/intern/struct.h
-missing.o: $(hdrdir)/ruby/internal/intern/thread.h
-missing.o: $(hdrdir)/ruby/internal/intern/time.h
-missing.o: $(hdrdir)/ruby/internal/intern/variable.h
-missing.o: $(hdrdir)/ruby/internal/intern/vm.h
-missing.o: $(hdrdir)/ruby/internal/interpreter.h
-missing.o: $(hdrdir)/ruby/internal/iterator.h
-missing.o: $(hdrdir)/ruby/internal/memory.h
-missing.o: $(hdrdir)/ruby/internal/method.h
-missing.o: $(hdrdir)/ruby/internal/module.h
-missing.o: $(hdrdir)/ruby/internal/newobj.h
-missing.o: $(hdrdir)/ruby/internal/scan_args.h
-missing.o: $(hdrdir)/ruby/internal/special_consts.h
-missing.o: $(hdrdir)/ruby/internal/static_assert.h
-missing.o: $(hdrdir)/ruby/internal/stdalign.h
-missing.o: $(hdrdir)/ruby/internal/stdbool.h
-missing.o: $(hdrdir)/ruby/internal/symbol.h
-missing.o: $(hdrdir)/ruby/internal/value.h
-missing.o: $(hdrdir)/ruby/internal/value_type.h
-missing.o: $(hdrdir)/ruby/internal/variable.h
-missing.o: $(hdrdir)/ruby/internal/warning_push.h
-missing.o: $(hdrdir)/ruby/internal/xmalloc.h
-missing.o: $(hdrdir)/ruby/missing.h
-missing.o: $(hdrdir)/ruby/ruby.h
-missing.o: $(hdrdir)/ruby/st.h
-missing.o: $(hdrdir)/ruby/subst.h
-missing.o: missing.c
-missing.o: missing/dtoa.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
deleted file mode 100644
index 23904ed60e..0000000000
--- a/ext/bigdecimal/extconf.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: false
-require 'mkmf'
-
-def have_builtin_func(name, check_expr, opt = "", &b)
- checking_for checking_message(name.funcall_style, nil, opt) do
- if try_compile(<<SRC, opt, &b)
-int foo;
-int main() { #{check_expr}; return 0; }
-SRC
- $defs.push(format("-DHAVE_BUILTIN_%s", name.tr_cpp))
- true
- else
- false
- end
- end
-end
-
-have_builtin_func("__builtin_clz", "__builtin_clz(0)")
-have_builtin_func("__builtin_clzl", "__builtin_clzl(0)")
-have_builtin_func("__builtin_clzll", "__builtin_clzll(0)")
-
-have_header("float.h")
-have_header("math.h")
-have_header("stdbool.h")
-have_header("stdlib.h")
-
-have_header("x86intrin.h")
-have_func("_lzcnt_u32", "x86intrin.h")
-have_func("_lzcnt_u64", "x86intrin.h")
-
-have_header("intrin.h")
-have_func("__lzcnt", "intrin.h")
-have_func("__lzcnt64", "intrin.h")
-have_func("_BitScanReverse", "intrin.h")
-have_func("_BitScanReverse64", "intrin.h")
-
-have_func("labs", "stdlib.h")
-have_func("llabs", "stdlib.h")
-have_func("finite", "math.h")
-have_func("isfinite", "math.h")
-
-have_header("ruby/atomic.h")
-have_header("ruby/internal/has/builtin.h")
-have_header("ruby/internal/static_assert.h")
-
-have_func("rb_rational_num", "ruby.h")
-have_func("rb_rational_den", "ruby.h")
-have_func("rb_complex_real", "ruby.h")
-have_func("rb_complex_imag", "ruby.h")
-have_func("rb_opts_exception_p", "ruby.h")
-have_func("rb_category_warn", "ruby.h")
-have_const("RB_WARN_CATEGORY_DEPRECATED", "ruby.h")
-
-if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__))
- bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb"
-else
- bigdecimal_rb = "$(srcdir)/../../lib/bigdecimal.rb"
-end
-
-create_makefile('bigdecimal') {|mf|
- mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
-}
diff --git a/ext/bigdecimal/feature.h b/ext/bigdecimal/feature.h
deleted file mode 100644
index f628514500..0000000000
--- a/ext/bigdecimal/feature.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef BIGDECIMAL_HAS_FEATURE_H
-#define BIGDECIMAL_HAS_FEATURE_H
-
-/* ======== __has_feature ======== */
-
-#ifndef __has_feature
-# define __has_feature(_) 0
-#endif
-
-/* ======== __has_extension ======== */
-
-#ifndef __has_extension
-# define __has_extension __has_feature
-#endif
-
-/* ======== __has_builtin ======== */
-
-#ifdef HAVE_RUBY_INTERNAL_HAS_BUILTIN_H
-# include <ruby/internal/has/builtin.h>
-#endif
-
-#ifdef RBIMPL_HAS_BUILTIN
-# define BIGDECIMAL_HAS_BUILTIN(...) RBIMPL_HAS_BUILTIN(__VA_ARGS__)
-
-#else
-# /* The following section is copied from CRuby's builtin.h */
-#
-# ifdef __has_builtin
-# if defined(__INTEL_COMPILER)
-# /* :TODO: Intel C Compiler has __has_builtin (since 19.1 maybe?), and is
-# * reportedly broken. We have to skip them. However the situation can
-# * change. They might improve someday. We need to revisit here later. */
-# elif defined(__GNUC__) && ! __has_builtin(__builtin_alloca)
-# /* FreeBSD's <sys/cdefs.h> defines its own *broken* version of
-# * __has_builtin. Cygwin copied that content to be a victim of the
-# * broken-ness. We don't take them into account. */
-# else
-# define HAVE___HAS_BUILTIN 1
-# endif
-# endif
-#
-# if defined(HAVE___HAS_BUILTIN)
-# define BIGDECIMAL_HAS_BUILTIN(_) __has_builtin(_)
-#
-# elif defined(__GNUC__)
-# define BIGDECIMAL_HAS_BUILTIN(_) BIGDECIMAL_HAS_BUILTIN_ ## _
-# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 6))
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clz 1
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl 1
-# else
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clz 0
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl 0
-# endif
-# elif defined(_MSC_VER)
-# define BIGDECIMAL_HAS_BUILTIN(_) 0
-#
-# else
-# define BIGDECIMAL_HAS_BUILTIN(_) BIGDECIMAL_HAS_BUILTIN_ ## _
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clz HAVE_BUILTIN___BUILTIN_CLZ
-# define BIGDECIMAL_HAS_BUILTIN___builtin_clzl HAVE_BUILTIN___BUILTIN_CLZL
-# endif
-#endif /* RBIMPL_HAS_BUILTIN */
-
-#ifndef __has_builtin
-# define __has_builtin(...) BIGDECIMAL_HAS_BUILTIN(__VA_ARGS__)
-#endif
-
-#endif /* BIGDECIMAL_HAS_FEATURE_H */
diff --git a/ext/bigdecimal/lib/bigdecimal.rb b/ext/bigdecimal/lib/bigdecimal.rb
deleted file mode 100644
index 82b3e1b7b9..0000000000
--- a/ext/bigdecimal/lib/bigdecimal.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-if RUBY_ENGINE == 'jruby'
- JRuby::Util.load_ext("org.jruby.ext.bigdecimal.BigDecimalLibrary")
-else
- require 'bigdecimal.so'
-end
diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
deleted file mode 100644
index 4448024c74..0000000000
--- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-# frozen_string_literal: false
-
-require 'bigdecimal'
-
-# require 'bigdecimal/jacobian'
-#
-# Provides methods to compute the Jacobian matrix of a set of equations at a
-# point x. In the methods below:
-#
-# f is an Object which is used to compute the Jacobian matrix of the equations.
-# It must provide the following methods:
-#
-# f.values(x):: returns the values of all functions at x
-#
-# f.zero:: returns 0.0
-# f.one:: returns 1.0
-# f.two:: returns 2.0
-# f.ten:: returns 10.0
-#
-# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal.
-#
-# x is the point at which to compute the Jacobian.
-#
-# fx is f.values(x).
-#
-module Jacobian
- module_function
-
- # Determines the equality of two numbers by comparing to zero, or using the epsilon value
- def isEqual(a,b,zero=0.0,e=1.0e-8)
- aa = a.abs
- bb = b.abs
- if aa == zero && bb == zero then
- true
- else
- if ((a-b)/(aa+bb)).abs < e then
- true
- else
- false
- end
- end
- end
-
-
- # Computes the derivative of +f[i]+ at +x[i]+.
- # +fx+ is the value of +f+ at +x+.
- def dfdxi(f,fx,x,i)
- nRetry = 0
- n = x.size
- xSave = x[i]
- ok = 0
- ratio = f.ten*f.ten*f.ten
- dx = x[i].abs/ratio
- dx = fx[i].abs/ratio if isEqual(dx,f.zero,f.zero,f.eps)
- dx = f.one/f.ten if isEqual(dx,f.zero,f.zero,f.eps)
- until ok>0 do
- deriv = []
- nRetry += 1
- if nRetry > 100
- raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]"
- end
- dx = dx*f.two
- x[i] += dx
- fxNew = f.values(x)
- for j in 0...n do
- if !isEqual(fxNew[j],fx[j],f.zero,f.eps) then
- ok += 1
- deriv <<= (fxNew[j]-fx[j])/dx
- else
- deriv <<= f.zero
- end
- end
- x[i] = xSave
- end
- deriv
- end
-
- # Computes the Jacobian of +f+ at +x+. +fx+ is the value of +f+ at +x+.
- def jacobian(f,fx,x)
- n = x.size
- dfdx = Array.new(n*n)
- for i in 0...n do
- df = dfdxi(f,fx,x,i)
- for j in 0...n do
- dfdx[j*n+i] = df[j]
- end
- end
- dfdx
- end
-end
diff --git a/ext/bigdecimal/lib/bigdecimal/ludcmp.rb b/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
deleted file mode 100644
index dd265e482a..0000000000
--- a/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: false
-require 'bigdecimal'
-
-#
-# Solves a*x = b for x, using LU decomposition.
-#
-module LUSolve
- module_function
-
- # Performs LU decomposition of the n by n matrix a.
- def ludecomp(a,n,zero=0,one=1)
- prec = BigDecimal.limit(nil)
- ps = []
- scales = []
- for i in 0...n do # pick up largest(abs. val.) element in each row.
- ps <<= i
- nrmrow = zero
- ixn = i*n
- for j in 0...n do
- biggst = a[ixn+j].abs
- nrmrow = biggst if biggst>nrmrow
- end
- if nrmrow>zero then
- scales <<= one.div(nrmrow,prec)
- else
- raise "Singular matrix"
- end
- end
- n1 = n - 1
- for k in 0...n1 do # Gaussian elimination with partial pivoting.
- biggst = zero;
- for i in k...n do
- size = a[ps[i]*n+k].abs*scales[ps[i]]
- if size>biggst then
- biggst = size
- pividx = i
- end
- end
- raise "Singular matrix" if biggst<=zero
- if pividx!=k then
- j = ps[k]
- ps[k] = ps[pividx]
- ps[pividx] = j
- end
- pivot = a[ps[k]*n+k]
- for i in (k+1)...n do
- psin = ps[i]*n
- a[psin+k] = mult = a[psin+k].div(pivot,prec)
- if mult!=zero then
- pskn = ps[k]*n
- for j in (k+1)...n do
- a[psin+j] -= mult.mult(a[pskn+j],prec)
- end
- end
- end
- end
- raise "Singular matrix" if a[ps[n1]*n+n1] == zero
- ps
- end
-
- # Solves a*x = b for x, using LU decomposition.
- #
- # a is a matrix, b is a constant vector, x is the solution vector.
- #
- # ps is the pivot, a vector which indicates the permutation of rows performed
- # during LU decomposition.
- def lusolve(a,b,ps,zero=0.0)
- prec = BigDecimal.limit(nil)
- n = ps.size
- x = []
- for i in 0...n do
- dot = zero
- psin = ps[i]*n
- for j in 0...i do
- dot = a[psin+j].mult(x[j],prec) + dot
- end
- x <<= b[ps[i]] - dot
- end
- (n-1).downto(0) do |i|
- dot = zero
- psin = ps[i]*n
- for j in (i+1)...n do
- dot = a[psin+j].mult(x[j],prec) + dot
- end
- x[i] = (x[i]-dot).div(a[psin+i],prec)
- end
- x
- end
-end
diff --git a/ext/bigdecimal/lib/bigdecimal/math.rb b/ext/bigdecimal/lib/bigdecimal/math.rb
deleted file mode 100644
index 0b9d0648bb..0000000000
--- a/ext/bigdecimal/lib/bigdecimal/math.rb
+++ /dev/null
@@ -1,232 +0,0 @@
-# frozen_string_literal: false
-require 'bigdecimal'
-
-#
-#--
-# Contents:
-# sqrt(x, prec)
-# sin (x, prec)
-# cos (x, prec)
-# atan(x, prec) Note: |x|<1, x=0.9999 may not converge.
-# PI (prec)
-# E (prec) == exp(1.0,prec)
-#
-# where:
-# x ... BigDecimal number to be computed.
-# |x| must be small enough to get convergence.
-# prec ... Number of digits to be obtained.
-#++
-#
-# Provides mathematical functions.
-#
-# Example:
-#
-# require "bigdecimal/math"
-#
-# include BigMath
-#
-# a = BigDecimal((PI(100)/2).to_s)
-# puts sin(a,100) # => 0.99999999999999999999......e0
-#
-module BigMath
- module_function
-
- # call-seq:
- # sqrt(decimal, numeric) -> BigDecimal
- #
- # Computes the square root of +decimal+ to the specified number of digits of
- # precision, +numeric+.
- #
- # BigMath.sqrt(BigDecimal('2'), 16).to_s
- # #=> "0.1414213562373095048801688724e1"
- #
- def sqrt(x, prec)
- x.sqrt(prec)
- end
-
- # call-seq:
- # sin(decimal, numeric) -> BigDecimal
- #
- # Computes the sine of +decimal+ to the specified number of digits of
- # precision, +numeric+.
- #
- # If +decimal+ is Infinity or NaN, returns NaN.
- #
- # BigMath.sin(BigMath.PI(5)/4, 5).to_s
- # #=> "0.70710678118654752440082036563292800375e0"
- #
- def sin(x, prec)
- raise ArgumentError, "Zero or negative precision for sin" if prec <= 0
- return BigDecimal("NaN") if x.infinite? || x.nan?
- n = prec + BigDecimal.double_fig
- one = BigDecimal("1")
- two = BigDecimal("2")
- x = -x if neg = x < 0
- if x > (twopi = two * BigMath.PI(prec))
- if x > 30
- x %= twopi
- else
- x -= twopi while x > twopi
- end
- end
- x1 = x
- x2 = x.mult(x,n)
- sign = 1
- y = x
- d = y
- i = one
- z = one
- while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
- m = BigDecimal.double_fig if m < BigDecimal.double_fig
- sign = -sign
- x1 = x2.mult(x1,n)
- i += two
- z *= (i-one) * i
- d = sign * x1.div(z,m)
- y += d
- end
- neg ? -y : y
- end
-
- # call-seq:
- # cos(decimal, numeric) -> BigDecimal
- #
- # Computes the cosine of +decimal+ to the specified number of digits of
- # precision, +numeric+.
- #
- # If +decimal+ is Infinity or NaN, returns NaN.
- #
- # BigMath.cos(BigMath.PI(4), 16).to_s
- # #=> "-0.999999999999999999999999999999856613163740061349e0"
- #
- def cos(x, prec)
- raise ArgumentError, "Zero or negative precision for cos" if prec <= 0
- return BigDecimal("NaN") if x.infinite? || x.nan?
- n = prec + BigDecimal.double_fig
- one = BigDecimal("1")
- two = BigDecimal("2")
- x = -x if x < 0
- if x > (twopi = two * BigMath.PI(prec))
- if x > 30
- x %= twopi
- else
- x -= twopi while x > twopi
- end
- end
- x1 = one
- x2 = x.mult(x,n)
- sign = 1
- y = one
- d = y
- i = BigDecimal("0")
- z = one
- while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
- m = BigDecimal.double_fig if m < BigDecimal.double_fig
- sign = -sign
- x1 = x2.mult(x1,n)
- i += two
- z *= (i-one) * i
- d = sign * x1.div(z,m)
- y += d
- end
- y
- end
-
- # call-seq:
- # atan(decimal, numeric) -> BigDecimal
- #
- # Computes the arctangent of +decimal+ to the specified number of digits of
- # precision, +numeric+.
- #
- # If +decimal+ is NaN, returns NaN.
- #
- # BigMath.atan(BigDecimal('-1'), 16).to_s
- # #=> "-0.785398163397448309615660845819878471907514682065e0"
- #
- def atan(x, prec)
- raise ArgumentError, "Zero or negative precision for atan" if prec <= 0
- return BigDecimal("NaN") if x.nan?
- pi = PI(prec)
- x = -x if neg = x < 0
- return pi.div(neg ? -2 : 2, prec) if x.infinite?
- return pi / (neg ? -4 : 4) if x.round(prec) == 1
- x = BigDecimal("1").div(x, prec) if inv = x > 1
- x = (-1 + sqrt(1 + x**2, prec))/x if dbl = x > 0.5
- n = prec + BigDecimal.double_fig
- y = x
- d = y
- t = x
- r = BigDecimal("3")
- x2 = x.mult(x,n)
- while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
- m = BigDecimal.double_fig if m < BigDecimal.double_fig
- t = -t.mult(x2,n)
- d = t.div(r,m)
- y += d
- r += 2
- end
- y *= 2 if dbl
- y = pi / 2 - y if inv
- y = -y if neg
- y
- end
-
- # call-seq:
- # PI(numeric) -> BigDecimal
- #
- # Computes the value of pi to the specified number of digits of precision,
- # +numeric+.
- #
- # BigMath.PI(10).to_s
- # #=> "0.3141592653589793238462643388813853786957412e1"
- #
- def PI(prec)
- raise ArgumentError, "Zero or negative precision for PI" if prec <= 0
- n = prec + BigDecimal.double_fig
- zero = BigDecimal("0")
- one = BigDecimal("1")
- two = BigDecimal("2")
-
- m25 = BigDecimal("-0.04")
- m57121 = BigDecimal("-57121")
-
- pi = zero
-
- d = one
- k = one
- t = BigDecimal("-80")
- while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
- m = BigDecimal.double_fig if m < BigDecimal.double_fig
- t = t*m25
- d = t.div(k,m)
- k = k+two
- pi = pi + d
- end
-
- d = one
- k = one
- t = BigDecimal("956")
- while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
- m = BigDecimal.double_fig if m < BigDecimal.double_fig
- t = t.div(m57121,n)
- d = t.div(k,m)
- pi = pi + d
- k = k+two
- end
- pi
- end
-
- # call-seq:
- # E(numeric) -> BigDecimal
- #
- # Computes e (the base of natural logarithms) to the specified number of
- # digits of precision, +numeric+.
- #
- # BigMath.E(10).to_s
- # #=> "0.271828182845904523536028752390026306410273e1"
- #
- def E(prec)
- raise ArgumentError, "Zero or negative precision for E" if prec <= 0
- BigMath.exp(1, prec)
- end
-end
diff --git a/ext/bigdecimal/lib/bigdecimal/newton.rb b/ext/bigdecimal/lib/bigdecimal/newton.rb
deleted file mode 100644
index 85bacb7f2e..0000000000
--- a/ext/bigdecimal/lib/bigdecimal/newton.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: false
-require "bigdecimal/ludcmp"
-require "bigdecimal/jacobian"
-
-#
-# newton.rb
-#
-# Solves the nonlinear algebraic equation system f = 0 by Newton's method.
-# This program is not dependent on BigDecimal.
-#
-# To call:
-# n = nlsolve(f,x)
-# where n is the number of iterations required,
-# x is the initial value vector
-# f is an Object which is used to compute the values of the equations to be solved.
-# It must provide the following methods:
-#
-# f.values(x):: returns the values of all functions at x
-#
-# f.zero:: returns 0.0
-# f.one:: returns 1.0
-# f.two:: returns 2.0
-# f.ten:: returns 10.0
-#
-# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal.
-#
-# On exit, x is the solution vector.
-#
-module Newton
- include LUSolve
- include Jacobian
- module_function
-
- def norm(fv,zero=0.0) # :nodoc:
- s = zero
- n = fv.size
- for i in 0...n do
- s += fv[i]*fv[i]
- end
- s
- end
-
- # See also Newton
- def nlsolve(f,x)
- nRetry = 0
- n = x.size
-
- f0 = f.values(x)
- zero = f.zero
- one = f.one
- two = f.two
- p5 = one/two
- d = norm(f0,zero)
- minfact = f.ten*f.ten*f.ten
- minfact = one/minfact
- e = f.eps
- while d >= e do
- nRetry += 1
- # Not yet converged. => Compute Jacobian matrix
- dfdx = jacobian(f,f0,x)
- # Solve dfdx*dx = -f0 to estimate dx
- dx = lusolve(dfdx,f0,ludecomp(dfdx,n,zero,one),zero)
- fact = two
- xs = x.dup
- begin
- fact *= p5
- if fact < minfact then
- raise "Failed to reduce function values."
- end
- for i in 0...n do
- x[i] = xs[i] - dx[i]*fact
- end
- f0 = f.values(x)
- dn = norm(f0,zero)
- end while(dn>=d)
- d = dn
- end
- nRetry
- end
-end
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
deleted file mode 100644
index ad92f7cfe6..0000000000
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ /dev/null
@@ -1,185 +0,0 @@
-# frozen_string_literal: false
-#
-#--
-# bigdecimal/util extends various native classes to provide the #to_d method,
-# and provides BigDecimal#to_d and BigDecimal#to_digits.
-#++
-
-require 'bigdecimal'
-
-class Integer < Numeric
- # call-seq:
- # int.to_d -> bigdecimal
- #
- # Returns the value of +int+ as a BigDecimal.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # 42.to_d # => 0.42e2
- #
- # See also BigDecimal::new.
- #
- def to_d
- BigDecimal(self)
- end
-end
-
-
-class Float < Numeric
- # call-seq:
- # float.to_d -> bigdecimal
- # float.to_d(precision) -> bigdecimal
- #
- # Returns the value of +float+ as a BigDecimal.
- # The +precision+ parameter is used to determine the number of
- # significant digits for the result. When +precision+ is set to +0+,
- # the number of digits to represent the float being converted is determined
- # automatically.
- # The default +precision+ is +0+.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # 0.5.to_d # => 0.5e0
- # 1.234.to_d # => 0.1234e1
- # 1.234.to_d(2) # => 0.12e1
- #
- # See also BigDecimal::new.
- #
- def to_d(precision=0)
- BigDecimal(self, precision)
- end
-end
-
-
-class String
- # call-seq:
- # str.to_d -> bigdecimal
- #
- # Returns the result of interpreting leading characters in +str+
- # as a BigDecimal.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # "0.5".to_d # => 0.5e0
- # "123.45e1".to_d # => 0.12345e4
- # "45.67 degrees".to_d # => 0.4567e2
- #
- # See also BigDecimal::new.
- #
- def to_d
- BigDecimal.interpret_loosely(self)
- end
-end
-
-
-class BigDecimal < Numeric
- # call-seq:
- # a.to_digits -> string
- #
- # Converts a BigDecimal to a String of the form "nnnnnn.mmm".
- # This method is deprecated; use BigDecimal#to_s("F") instead.
- #
- # require 'bigdecimal/util'
- #
- # d = BigDecimal("3.14")
- # d.to_digits # => "3.14"
- #
- def to_digits
- if self.nan? || self.infinite? || self.zero?
- self.to_s
- else
- i = self.to_i.to_s
- _,f,_,z = self.frac.split
- i + "." + ("0"*(-z)) + f
- end
- end
-
- # call-seq:
- # a.to_d -> bigdecimal
- #
- # Returns self.
- #
- # require 'bigdecimal/util'
- #
- # d = BigDecimal("3.14")
- # d.to_d # => 0.314e1
- #
- def to_d
- self
- end
-end
-
-
-class Rational < Numeric
- # call-seq:
- # rat.to_d(precision) -> bigdecimal
- #
- # Returns the value as a BigDecimal.
- #
- # The required +precision+ parameter is used to determine the number of
- # significant digits for the result.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # Rational(22, 7).to_d(3) # => 0.314e1
- #
- # See also BigDecimal::new.
- #
- def to_d(precision)
- BigDecimal(self, precision)
- end
-end
-
-
-class Complex < Numeric
- # call-seq:
- # cmp.to_d -> bigdecimal
- # cmp.to_d(precision) -> bigdecimal
- #
- # Returns the value as a BigDecimal.
- #
- # The +precision+ parameter is required for a rational complex number.
- # This parameter is used to determine the number of significant digits
- # for the result.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # Complex(0.1234567, 0).to_d(4) # => 0.1235e0
- # Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
- #
- # See also BigDecimal::new.
- #
- def to_d(*args)
- BigDecimal(self) unless self.imag.zero? # to raise eerror
-
- if args.length == 0
- case self.real
- when Rational
- BigDecimal(self.real) # to raise error
- end
- end
- self.real.to_d(*args)
- end
-end
-
-
-class NilClass
- # call-seq:
- # nil.to_d -> bigdecimal
- #
- # Returns nil represented as a BigDecimal.
- #
- # require 'bigdecimal'
- # require 'bigdecimal/util'
- #
- # nil.to_d # => 0.0
- #
- def to_d
- BigDecimal(0)
- end
-end
diff --git a/ext/bigdecimal/missing.c b/ext/bigdecimal/missing.c
deleted file mode 100644
index 703232d92f..0000000000
--- a/ext/bigdecimal/missing.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <ruby/ruby.h>
-
-#ifdef HAVE_RUBY_ATOMIC_H
-# include <ruby/atomic.h>
-#endif
-
-#ifdef RUBY_ATOMIC_PTR_CAS
-# define ATOMIC_PTR_CAS(var, old, new) RUBY_ATOMIC_PTR_CAS(var, old, new)
-#endif
-
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
-/* GCC warns about unknown sanitizer, which is annoying. */
-# undef NO_SANITIZE
-# define NO_SANITIZE(x, y) \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wattributes\"") \
- __attribute__((__no_sanitize__(x))) y; \
- _Pragma("GCC diagnostic pop")
-#endif
-
-#undef strtod
-#define strtod BigDecimal_strtod
-#undef dtoa
-#define dtoa BigDecimal_dtoa
-#undef hdtoa
-#define hdtoa BigDecimal_hdtoa
-#include "missing/dtoa.c"
diff --git a/ext/bigdecimal/missing.h b/ext/bigdecimal/missing.h
deleted file mode 100644
index 325554b5f5..0000000000
--- a/ext/bigdecimal/missing.h
+++ /dev/null
@@ -1,196 +0,0 @@
-#ifndef MISSING_H
-#define MISSING_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#ifdef HAVE_MATH_H
-# include <math.h>
-#endif
-
-#ifndef RB_UNUSED_VAR
-# if defined(_MSC_VER) && _MSC_VER >= 1911
-# define RB_UNUSED_VAR(x) x [[maybe_unused]]
-
-# elif defined(__has_cpp_attribute) && __has_cpp_attribute(maybe_unused)
-# define RB_UNUSED_VAR(x) x [[maybe_unused]]
-
-# elif defined(__has_c_attribute) && __has_c_attribute(maybe_unused)
-# define RB_UNUSED_VAR(x) x [[maybe_unused]]
-
-# elif defined(__GNUC__)
-# define RB_UNUSED_VAR(x) x __attribute__ ((unused))
-
-# else
-# define RB_UNUSED_VAR(x) x
-# endif
-#endif /* RB_UNUSED_VAR */
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310
-# define HAVE___ASSUME 1
-
-#elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1300
-# define HAVE___ASSUME 1
-#endif
-
-#ifndef UNREACHABLE
-# if __has_builtin(__builtin_unreachable)
-# define UNREACHABLE __builtin_unreachable()
-
-# elif defined(HAVE___ASSUME)
-# define UNREACHABLE __assume(0)
-
-# else
-# define UNREACHABLE /* unreachable */
-# endif
-#endif /* UNREACHABLE */
-
-/* bool */
-
-#if defined(__bool_true_false_are_defined)
-# /* Take that. */
-
-#elif defined(HAVE_STDBOOL_H)
-# include <stdbool.h>
-
-#else
-typedef unsigned char _Bool;
-# define bool _Bool
-# define true ((_Bool)+1)
-# define false ((_Bool)-1)
-# define __bool_true_false_are_defined
-#endif
-
-/* abs */
-
-#ifndef HAVE_LABS
-static inline long
-labs(long const x)
-{
- if (x < 0) return -x;
- return x;
-}
-#endif
-
-#ifndef HAVE_LLABS
-static inline LONG_LONG
-llabs(LONG_LONG const x)
-{
- if (x < 0) return -x;
- return x;
-}
-#endif
-
-#ifdef vabs
-# undef vabs
-#endif
-#if SIZEOF_VALUE <= SIZEOF_INT
-# define vabs abs
-#elif SIZEOF_VALUE <= SIZEOF_LONG
-# define vabs labs
-#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG
-# define vabs llabs
-#endif
-
-/* finite */
-
-#ifndef HAVE_FINITE
-static int
-finite(double)
-{
- return !isnan(n) && !isinf(n);
-}
-#endif
-
-#ifndef isfinite
-# ifndef HAVE_ISFINITE
-# define HAVE_ISFINITE 1
-# define isfinite(x) finite(x)
-# endif
-#endif
-
-/* dtoa */
-char *BigDecimal_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
-
-/* rational */
-
-#ifndef HAVE_RB_RATIONAL_NUM
-static inline VALUE
-rb_rational_num(VALUE rat)
-{
-#ifdef RRATIONAL
- return RRATIONAL(rat)->num;
-#else
- return rb_funcall(rat, rb_intern("numerator"), 0);
-#endif
-}
-#endif
-
-#ifndef HAVE_RB_RATIONAL_DEN
-static inline VALUE
-rb_rational_den(VALUE rat)
-{
-#ifdef RRATIONAL
- return RRATIONAL(rat)->den;
-#else
- return rb_funcall(rat, rb_intern("denominator"), 0);
-#endif
-}
-#endif
-
-/* complex */
-
-#ifndef HAVE_RB_COMPLEX_REAL
-static inline VALUE
-rb_complex_real(VALUE cmp)
-{
-#ifdef RCOMPLEX
- return RCOMPLEX(cmp)->real;
-#else
- return rb_funcall(cmp, rb_intern("real"), 0);
-#endif
-}
-#endif
-
-#ifndef HAVE_RB_COMPLEX_IMAG
-static inline VALUE
-rb_complex_imag(VALUE cmp)
-{
-# ifdef RCOMPLEX
- return RCOMPLEX(cmp)->imag;
-# else
- return rb_funcall(cmp, rb_intern("imag"), 0);
-# endif
-}
-#endif
-
-/* st */
-
-#ifndef ST2FIX
-# undef RB_ST2FIX
-# define RB_ST2FIX(h) LONG2FIX((long)(h))
-# define ST2FIX(h) RB_ST2FIX(h)
-#endif
-
-/* warning */
-
-#if !defined(HAVE_RB_CATEGORY_WARN) || !defined(HAVE_CONST_RB_WARN_CATEGORY_DEPRECATED)
-# define rb_category_warn(category, ...) rb_warn(__VA_ARGS__)
-#endif
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* MISSING_H */
diff --git a/ext/bigdecimal/missing/dtoa.c b/ext/bigdecimal/missing/dtoa.c
deleted file mode 100644
index 41b0a221d1..0000000000
--- a/ext/bigdecimal/missing/dtoa.c
+++ /dev/null
@@ -1,3462 +0,0 @@
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * 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.
- *
- ***************************************************************/
-
-/* Please send bug reports to David M. Gay (dmg at acm dot org,
- * with " at " changed at "@" and " dot " changed to "."). */
-
-/* On a machine with IEEE extended-precision registers, it is
- * necessary to specify double-precision (53-bit) rounding precision
- * before invoking strtod or dtoa. If the machine uses (the equivalent
- * of) Intel 80x87 arithmetic, the call
- * _control87(PC_53, MCW_PC);
- * does this with many compilers. Whether this or another call is
- * appropriate depends on the compiler; for this to work, it may be
- * necessary to #include "float.h" or another system-dependent header
- * file.
- */
-
-/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
- *
- * This strtod returns a nearest machine number to the input decimal
- * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
- * broken by the IEEE round-even rule. Otherwise ties are broken by
- * biased rounding (add half and chop).
- *
- * Inspired loosely by William D. Clinger's paper "How to Read Floating
- * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- *
- * 1. We only require IEEE, IBM, or VAX double-precision
- * arithmetic (not IEEE double-extended).
- * 2. We get by with floating-point arithmetic in a case that
- * Clinger missed -- when we're computing d * 10^n
- * for a small integer d and the integer n is not too
- * much larger than 22 (the maximum integer k for which
- * we can represent 10^k exactly), we may be able to
- * compute (d*10^k) * 10^(e-k) with just one roundoff.
- * 3. Rather than a bit-at-a-time adjustment of the binary
- * result in the hard case, we use floating-point
- * arithmetic to determine the adjustment to within
- * one bit; only in really hard cases do we need to
- * compute a second residual.
- * 4. Because of 3., we don't need a large table of powers of 10
- * for ten-to-e (just some small tables, e.g. of 10^k
- * for 0 <= k <= 22).
- */
-
-/*
- * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least
- * significant byte has the lowest address.
- * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most
- * significant byte has the lowest address.
- * #define Long int on machines with 32-bit ints and 64-bit longs.
- * #define IBM for IBM mainframe-style floating-point arithmetic.
- * #define VAX for VAX-style floating-point arithmetic (D_floating).
- * #define No_leftright to omit left-right logic in fast floating-point
- * computation of dtoa.
- * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
- * and strtod and dtoa should round accordingly.
- * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
- * and Honor_FLT_ROUNDS is not #defined.
- * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
- * that use extended-precision instructions to compute rounded
- * products and quotients) with IBM.
- * #define ROUND_BIASED for IEEE-format with biased rounding.
- * #define Inaccurate_Divide for IEEE-format with correctly rounded
- * products but inaccurate quotients, e.g., for Intel i860.
- * #define NO_LONG_LONG on machines that do not have a "long long"
- * integer type (of >= 64 bits). On such machines, you can
- * #define Just_16 to store 16 bits per 32-bit Long when doing
- * high-precision integer arithmetic. Whether this speeds things
- * up or slows things down depends on the machine and the number
- * being converted. If long long is available and the name is
- * something other than "long long", #define Llong to be the name,
- * and if "unsigned Llong" does not work as an unsigned version of
- * Llong, #define #ULLong to be the corresponding unsigned type.
- * #define KR_headers for old-style C function headers.
- * #define Bad_float_h if your system lacks a float.h or if it does not
- * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
- * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
- * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
- * if memory is available and otherwise does something you deem
- * appropriate. If MALLOC is undefined, malloc will be invoked
- * directly -- and assumed always to succeed.
- * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
- * memory allocations from a private pool of memory when possible.
- * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
- * unless #defined to be a different length. This default length
- * suffices to get rid of MALLOC calls except for unusual cases,
- * such as decimal-to-binary conversion of a very long string of
- * digits. The longest string dtoa can return is about 751 bytes
- * long. For conversions by strtod of strings of 800 digits and
- * all dtoa conversions in single-threaded executions with 8-byte
- * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
- * pointers, PRIVATE_MEM >= 7112 appears adequate.
- * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
- * Infinity and NaN (case insensitively). On some systems (e.g.,
- * some HP systems), it may be necessary to #define NAN_WORD0
- * appropriately -- to the most significant word of a quiet NaN.
- * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
- * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
- * strtod also accepts (case insensitively) strings of the form
- * NaN(x), where x is a string of hexadecimal digits and spaces;
- * if there is only one string of hexadecimal digits, it is taken
- * for the 52 fraction bits of the resulting NaN; if there are two
- * or more strings of hex digits, the first is for the high 20 bits,
- * the second and subsequent for the low 32 bits, with intervening
- * white space ignored; but if this results in none of the 52
- * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0
- * and NAN_WORD1 are used instead.
- * #define MULTIPLE_THREADS if the system offers preemptively scheduled
- * multiple threads. In this case, you must provide (or suitably
- * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
- * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
- * in pow5mult, ensures lazy evaluation of only one copy of high
- * powers of 5; omitting this lock would introduce a small
- * probability of wasting memory, but would otherwise be harmless.)
- * You must also invoke freedtoa(s) to free the value s returned by
- * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
- * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that
- * avoids underflows on inputs whose result does not underflow.
- * If you #define NO_IEEE_Scale on a machine that uses IEEE-format
- * floating-point numbers and flushes underflows to zero rather
- * than implementing gradual underflow, then you must also #define
- * Sudden_Underflow.
- * #define YES_ALIAS to permit aliasing certain double values with
- * arrays of ULongs. This leads to slightly better code with
- * some compilers and was always used prior to 19990916, but it
- * is not strictly legal and can cause trouble with aggressively
- * optimizing compilers (e.g., gcc 2.95.1 under -O2).
- * #define USE_LOCALE to use the current locale's decimal_point value.
- * #define SET_INEXACT if IEEE arithmetic is being used and extra
- * computation should be done to set the inexact flag when the
- * result is inexact and avoid setting inexact when the result
- * is exact. In this case, dtoa.c must be compiled in
- * an environment, perhaps provided by #include "dtoa.c" in a
- * suitable wrapper, that defines two functions,
- * int get_inexact(void);
- * void clear_inexact(void);
- * such that get_inexact() returns a nonzero value if the
- * inexact bit is already set, and clear_inexact() sets the
- * inexact bit to 0. When SET_INEXACT is #defined, strtod
- * also does extra computations to set the underflow and overflow
- * flags when appropriate (i.e., when the result is tiny and
- * inexact or when it is a numeric value rounded to +-infinity).
- * #define NO_ERRNO if strtod should not assign errno = ERANGE when
- * the result overflows to +-Infinity or underflows to 0.
- */
-
-#ifdef WORDS_BIGENDIAN
-#define IEEE_BIG_ENDIAN
-#else
-#define IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __vax__
-#define VAX
-#undef IEEE_BIG_ENDIAN
-#undef IEEE_LITTLE_ENDIAN
-#endif
-
-#if defined(__arm__) && !defined(__VFP_FP__)
-#define IEEE_BIG_ENDIAN
-#undef IEEE_LITTLE_ENDIAN
-#endif
-
-#undef Long
-#undef ULong
-
-#include <limits.h>
-
-#if (INT_MAX >> 30) && !(INT_MAX >> 31)
-#define Long int
-#define ULong unsigned int
-#elif (LONG_MAX >> 30) && !(LONG_MAX >> 31)
-#define Long long int
-#define ULong unsigned long int
-#else
-#error No 32bit integer
-#endif
-
-#if HAVE_LONG_LONG
-#define Llong LONG_LONG
-#else
-#define NO_LONG_LONG
-#endif
-
-#ifdef DEBUG
-#include <stdio.h>
-#define Bug(x) {fprintf(stderr, "%s\n", (x)); exit(EXIT_FAILURE);}
-#endif
-
-#ifndef ISDIGIT
-#include <ctype.h>
-#define ISDIGIT(c) isdigit(c)
-#endif
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef USE_LOCALE
-#include <locale.h>
-#endif
-
-#ifdef MALLOC
-extern void *MALLOC(size_t);
-#else
-#define MALLOC xmalloc
-#endif
-#ifdef FREE
-extern void FREE(void*);
-#else
-#define FREE xfree
-#endif
-#ifndef NO_SANITIZE
-#define NO_SANITIZE(x, y) y
-#endif
-
-#ifndef Omit_Private_Memory
-#ifndef PRIVATE_MEM
-#define PRIVATE_MEM 2304
-#endif
-#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
-static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
-#endif
-
-#undef IEEE_Arith
-#undef Avoid_Underflow
-#ifdef IEEE_BIG_ENDIAN
-#define IEEE_Arith
-#endif
-#ifdef IEEE_LITTLE_ENDIAN
-#define IEEE_Arith
-#endif
-
-#ifdef Bad_float_h
-
-#ifdef IEEE_Arith
-#define DBL_DIG 15
-#define DBL_MAX_10_EXP 308
-#define DBL_MAX_EXP 1024
-#define FLT_RADIX 2
-#endif /*IEEE_Arith*/
-
-#ifdef IBM
-#define DBL_DIG 16
-#define DBL_MAX_10_EXP 75
-#define DBL_MAX_EXP 63
-#define FLT_RADIX 16
-#define DBL_MAX 7.2370055773322621e+75
-#endif
-
-#ifdef VAX
-#define DBL_DIG 16
-#define DBL_MAX_10_EXP 38
-#define DBL_MAX_EXP 127
-#define FLT_RADIX 2
-#define DBL_MAX 1.7014118346046923e+38
-#endif
-
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647
-#endif
-
-#else /* ifndef Bad_float_h */
-#include <float.h>
-#endif /* Bad_float_h */
-
-#include <math.h>
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifndef hexdigit
-static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
-#endif
-
-#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
-Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.
-#endif
-
-typedef union { double d; ULong L[2]; } U;
-
-#ifdef YES_ALIAS
-typedef double double_u;
-# define dval(x) (x)
-# ifdef IEEE_LITTLE_ENDIAN
-# define word0(x) (((ULong *)&(x))[1])
-# define word1(x) (((ULong *)&(x))[0])
-# else
-# define word0(x) (((ULong *)&(x))[0])
-# define word1(x) (((ULong *)&(x))[1])
-# endif
-#else
-typedef U double_u;
-# ifdef IEEE_LITTLE_ENDIAN
-# define word0(x) ((x).L[1])
-# define word1(x) ((x).L[0])
-# else
-# define word0(x) ((x).L[0])
-# define word1(x) ((x).L[1])
-# endif
-# define dval(x) ((x).d)
-#endif
-
-/* The following definition of Storeinc is appropriate for MIPS processors.
- * An alternative that might be better on some machines is
- * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
- */
-#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm__)
-#define Storeinc(a,b,c) (((unsigned short *)(a))[1] = (unsigned short)(b), \
-((unsigned short *)(a))[0] = (unsigned short)(c), (a)++)
-#else
-#define Storeinc(a,b,c) (((unsigned short *)(a))[0] = (unsigned short)(b), \
-((unsigned short *)(a))[1] = (unsigned short)(c), (a)++)
-#endif
-
-/* #define P DBL_MANT_DIG */
-/* Ten_pmax = floor(P*log(2)/log(5)) */
-/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
-/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
-/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
-
-#ifdef IEEE_Arith
-#define Exp_shift 20
-#define Exp_shift1 20
-#define Exp_msk1 0x100000
-#define Exp_msk11 0x100000
-#define Exp_mask 0x7ff00000
-#define P 53
-#define Bias 1023
-#define Emin (-1022)
-#define Exp_1 0x3ff00000
-#define Exp_11 0x3ff00000
-#define Ebits 11
-#define Frac_mask 0xfffff
-#define Frac_mask1 0xfffff
-#define Ten_pmax 22
-#define Bletch 0x10
-#define Bndry_mask 0xfffff
-#define Bndry_mask1 0xfffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 1
-#define Tiny0 0
-#define Tiny1 1
-#define Quick_max 14
-#define Int_max 14
-#ifndef NO_IEEE_Scale
-#define Avoid_Underflow
-#ifdef Flush_Denorm /* debugging option */
-#undef Sudden_Underflow
-#endif
-#endif
-
-#ifndef Flt_Rounds
-#ifdef FLT_ROUNDS
-#define Flt_Rounds FLT_ROUNDS
-#else
-#define Flt_Rounds 1
-#endif
-#endif /*Flt_Rounds*/
-
-#ifdef Honor_FLT_ROUNDS
-#define Rounding rounding
-#undef Check_FLT_ROUNDS
-#define Check_FLT_ROUNDS
-#else
-#define Rounding Flt_Rounds
-#endif
-
-#else /* ifndef IEEE_Arith */
-#undef Check_FLT_ROUNDS
-#undef Honor_FLT_ROUNDS
-#undef SET_INEXACT
-#undef Sudden_Underflow
-#define Sudden_Underflow
-#ifdef IBM
-#undef Flt_Rounds
-#define Flt_Rounds 0
-#define Exp_shift 24
-#define Exp_shift1 24
-#define Exp_msk1 0x1000000
-#define Exp_msk11 0x1000000
-#define Exp_mask 0x7f000000
-#define P 14
-#define Bias 65
-#define Exp_1 0x41000000
-#define Exp_11 0x41000000
-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
-#define Frac_mask 0xffffff
-#define Frac_mask1 0xffffff
-#define Bletch 4
-#define Ten_pmax 22
-#define Bndry_mask 0xefffff
-#define Bndry_mask1 0xffffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 4
-#define Tiny0 0x100000
-#define Tiny1 0
-#define Quick_max 14
-#define Int_max 15
-#else /* VAX */
-#undef Flt_Rounds
-#define Flt_Rounds 1
-#define Exp_shift 23
-#define Exp_shift1 7
-#define Exp_msk1 0x80
-#define Exp_msk11 0x800000
-#define Exp_mask 0x7f80
-#define P 56
-#define Bias 129
-#define Exp_1 0x40800000
-#define Exp_11 0x4080
-#define Ebits 8
-#define Frac_mask 0x7fffff
-#define Frac_mask1 0xffff007f
-#define Ten_pmax 24
-#define Bletch 2
-#define Bndry_mask 0xffff007f
-#define Bndry_mask1 0xffff007f
-#define LSB 0x10000
-#define Sign_bit 0x8000
-#define Log2P 1
-#define Tiny0 0x80
-#define Tiny1 0
-#define Quick_max 15
-#define Int_max 15
-#endif /* IBM, VAX */
-#endif /* IEEE_Arith */
-
-#ifndef IEEE_Arith
-#define ROUND_BIASED
-#endif
-
-#ifdef RND_PRODQUOT
-#define rounded_product(a,b) ((a) = rnd_prod((a), (b)))
-#define rounded_quotient(a,b) ((a) = rnd_quot((a), (b)))
-extern double rnd_prod(double, double), rnd_quot(double, double);
-#else
-#define rounded_product(a,b) ((a) *= (b))
-#define rounded_quotient(a,b) ((a) /= (b))
-#endif
-
-#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
-#define Big1 0xffffffff
-
-#ifndef Pack_32
-#define Pack_32
-#endif
-
-#define FFFFFFFF 0xffffffffUL
-
-#ifdef NO_LONG_LONG
-#undef ULLong
-#ifdef Just_16
-#undef Pack_32
-/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
- * This makes some inner loops simpler and sometimes saves work
- * during multiplications, but it often seems to make things slightly
- * slower. Hence the default is now to store 32 bits per Long.
- */
-#endif
-#else /* long long available */
-#ifndef Llong
-#define Llong long long
-#endif
-#ifndef ULLong
-#define ULLong unsigned Llong
-#endif
-#endif /* NO_LONG_LONG */
-
-#define MULTIPLE_THREADS 1
-
-#ifndef MULTIPLE_THREADS
-#define ACQUIRE_DTOA_LOCK(n) /*nothing*/
-#define FREE_DTOA_LOCK(n) /*nothing*/
-#else
-#define ACQUIRE_DTOA_LOCK(n) /*unused right now*/
-#define FREE_DTOA_LOCK(n) /*unused right now*/
-#endif
-
-#ifndef ATOMIC_PTR_CAS
-#define ATOMIC_PTR_CAS(var, old, new) ((var) = (new), (old))
-#endif
-#ifndef LIKELY
-#define LIKELY(x) (x)
-#endif
-#ifndef UNLIKELY
-#define UNLIKELY(x) (x)
-#endif
-#ifndef ASSUME
-#define ASSUME(x) (void)(x)
-#endif
-
-#define Kmax 15
-
-struct Bigint {
- struct Bigint *next;
- int k, maxwds, sign, wds;
- ULong x[1];
-};
-
-typedef struct Bigint Bigint;
-
-static Bigint *freelist[Kmax+1];
-
-static Bigint *
-Balloc(int k)
-{
- int x;
- Bigint *rv;
-#ifndef Omit_Private_Memory
- size_t len;
-#endif
-
- rv = 0;
- ACQUIRE_DTOA_LOCK(0);
- if (k <= Kmax) {
- rv = freelist[k];
- while (rv) {
- Bigint *rvn = rv;
- rv = ATOMIC_PTR_CAS(freelist[k], rv, rv->next);
- if (LIKELY(rvn == rv)) {
- ASSUME(rv);
- break;
- }
- }
- }
- if (!rv) {
- x = 1 << k;
-#ifdef Omit_Private_Memory
- rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
-#else
- len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
- /sizeof(double);
- if (k <= Kmax) {
- double *pnext = pmem_next;
- while (pnext - private_mem + len <= PRIVATE_mem) {
- double *p = pnext;
- pnext = ATOMIC_PTR_CAS(pmem_next, pnext, pnext + len);
- if (LIKELY(p == pnext)) {
- rv = (Bigint*)pnext;
- ASSUME(rv);
- break;
- }
- }
- }
- if (!rv)
- rv = (Bigint*)MALLOC(len*sizeof(double));
-#endif
- rv->k = k;
- rv->maxwds = x;
- }
- FREE_DTOA_LOCK(0);
- rv->sign = rv->wds = 0;
- return rv;
-}
-
-static void
-Bfree(Bigint *v)
-{
- Bigint *vn;
- if (v) {
- if (v->k > Kmax) {
- FREE(v);
- return;
- }
- ACQUIRE_DTOA_LOCK(0);
- do {
- vn = v->next = freelist[v->k];
- } while (UNLIKELY(ATOMIC_PTR_CAS(freelist[v->k], vn, v) != vn));
- FREE_DTOA_LOCK(0);
- }
-}
-
-#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
-(y)->wds*sizeof(Long) + 2*sizeof(int))
-
-static Bigint *
-multadd(Bigint *b, int m, int a) /* multiply by m and add a */
-{
- int i, wds;
- ULong *x;
-#ifdef ULLong
- ULLong carry, y;
-#else
- ULong carry, y;
-#ifdef Pack_32
- ULong xi, z;
-#endif
-#endif
- Bigint *b1;
-
- wds = b->wds;
- x = b->x;
- i = 0;
- carry = a;
- do {
-#ifdef ULLong
- y = *x * (ULLong)m + carry;
- carry = y >> 32;
- *x++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- xi = *x;
- y = (xi & 0xffff) * m + carry;
- z = (xi >> 16) * m + (y >> 16);
- carry = z >> 16;
- *x++ = (z << 16) + (y & 0xffff);
-#else
- y = *x * m + carry;
- carry = y >> 16;
- *x++ = y & 0xffff;
-#endif
-#endif
- } while (++i < wds);
- if (carry) {
- if (wds >= b->maxwds) {
- b1 = Balloc(b->k+1);
- Bcopy(b1, b);
- Bfree(b);
- b = b1;
- }
- b->x[wds++] = (ULong)carry;
- b->wds = wds;
- }
- return b;
-}
-
-static Bigint *
-s2b(const char *s, int nd0, int nd, ULong y9)
-{
- Bigint *b;
- int i, k;
- Long x, y;
-
- x = (nd + 8) / 9;
- for (k = 0, y = 1; x > y; y <<= 1, k++) ;
-#ifdef Pack_32
- b = Balloc(k);
- b->x[0] = y9;
- b->wds = 1;
-#else
- b = Balloc(k+1);
- b->x[0] = y9 & 0xffff;
- b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
-#endif
-
- i = 9;
- if (9 < nd0) {
- s += 9;
- do {
- b = multadd(b, 10, *s++ - '0');
- } while (++i < nd0);
- s++;
- }
- else
- s += 10;
- for (; i < nd; i++)
- b = multadd(b, 10, *s++ - '0');
- return b;
-}
-
-static int
-hi0bits(register ULong x)
-{
- register int k = 0;
-
- if (!(x & 0xffff0000)) {
- k = 16;
- x <<= 16;
- }
- if (!(x & 0xff000000)) {
- k += 8;
- x <<= 8;
- }
- if (!(x & 0xf0000000)) {
- k += 4;
- x <<= 4;
- }
- if (!(x & 0xc0000000)) {
- k += 2;
- x <<= 2;
- }
- if (!(x & 0x80000000)) {
- k++;
- if (!(x & 0x40000000))
- return 32;
- }
- return k;
-}
-
-static int
-lo0bits(ULong *y)
-{
- register int k;
- register ULong x = *y;
-
- if (x & 7) {
- if (x & 1)
- return 0;
- if (x & 2) {
- *y = x >> 1;
- return 1;
- }
- *y = x >> 2;
- return 2;
- }
- k = 0;
- if (!(x & 0xffff)) {
- k = 16;
- x >>= 16;
- }
- if (!(x & 0xff)) {
- k += 8;
- x >>= 8;
- }
- if (!(x & 0xf)) {
- k += 4;
- x >>= 4;
- }
- if (!(x & 0x3)) {
- k += 2;
- x >>= 2;
- }
- if (!(x & 1)) {
- k++;
- x >>= 1;
- if (!x)
- return 32;
- }
- *y = x;
- return k;
-}
-
-static Bigint *
-i2b(int i)
-{
- Bigint *b;
-
- b = Balloc(1);
- b->x[0] = i;
- b->wds = 1;
- return b;
-}
-
-static Bigint *
-mult(Bigint *a, Bigint *b)
-{
- Bigint *c;
- int k, wa, wb, wc;
- ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
- ULong y;
-#ifdef ULLong
- ULLong carry, z;
-#else
- ULong carry, z;
-#ifdef Pack_32
- ULong z2;
-#endif
-#endif
-
- if (a->wds < b->wds) {
- c = a;
- a = b;
- b = c;
- }
- k = a->k;
- wa = a->wds;
- wb = b->wds;
- wc = wa + wb;
- if (wc > a->maxwds)
- k++;
- c = Balloc(k);
- for (x = c->x, xa = x + wc; x < xa; x++)
- *x = 0;
- xa = a->x;
- xae = xa + wa;
- xb = b->x;
- xbe = xb + wb;
- xc0 = c->x;
-#ifdef ULLong
- for (; xb < xbe; xc0++) {
- if ((y = *xb++) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = *x++ * (ULLong)y + *xc + carry;
- carry = z >> 32;
- *xc++ = (ULong)(z & FFFFFFFF);
- } while (x < xae);
- *xc = (ULong)carry;
- }
- }
-#else
-#ifdef Pack_32
- for (; xb < xbe; xb++, xc0++) {
- if ((y = *xb & 0xffff) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
- carry = z >> 16;
- z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
- carry = z2 >> 16;
- Storeinc(xc, z2, z);
- } while (x < xae);
- *xc = (ULong)carry;
- }
- if ((y = *xb >> 16) != 0) {
- x = xa;
- xc = xc0;
- carry = 0;
- z2 = *xc;
- do {
- z = (*x & 0xffff) * y + (*xc >> 16) + carry;
- carry = z >> 16;
- Storeinc(xc, z, z2);
- z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
- carry = z2 >> 16;
- } while (x < xae);
- *xc = z2;
- }
- }
-#else
- for (; xb < xbe; xc0++) {
- if (y = *xb++) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = *x++ * y + *xc + carry;
- carry = z >> 16;
- *xc++ = z & 0xffff;
- } while (x < xae);
- *xc = (ULong)carry;
- }
- }
-#endif
-#endif
- for (xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
- c->wds = wc;
- return c;
-}
-
-static Bigint *p5s;
-
-static Bigint *
-pow5mult(Bigint *b, int k)
-{
- Bigint *b1, *p5, *p51;
- Bigint *p5tmp;
- int i;
- static const int p05[3] = { 5, 25, 125 };
-
- if ((i = k & 3) != 0)
- b = multadd(b, p05[i-1], 0);
-
- if (!(k >>= 2))
- return b;
- if (!(p5 = p5s)) {
- /* first time */
- ACQUIRE_DTOA_LOCK(1);
- if (!(p5 = p5s)) {
- p5 = i2b(625);
- p5->next = 0;
- p5tmp = ATOMIC_PTR_CAS(p5s, NULL, p5);
- if (UNLIKELY(p5tmp)) {
- Bfree(p5);
- p5 = p5tmp;
- }
- }
- FREE_DTOA_LOCK(1);
- }
- for (;;) {
- if (k & 1) {
- b1 = mult(b, p5);
- Bfree(b);
- b = b1;
- }
- if (!(k >>= 1))
- break;
- if (!(p51 = p5->next)) {
- ACQUIRE_DTOA_LOCK(1);
- if (!(p51 = p5->next)) {
- p51 = mult(p5,p5);
- p51->next = 0;
- p5tmp = ATOMIC_PTR_CAS(p5->next, NULL, p51);
- if (UNLIKELY(p5tmp)) {
- Bfree(p51);
- p51 = p5tmp;
- }
- }
- FREE_DTOA_LOCK(1);
- }
- p5 = p51;
- }
- return b;
-}
-
-static Bigint *
-lshift(Bigint *b, int k)
-{
- int i, k1, n, n1;
- Bigint *b1;
- ULong *x, *x1, *xe, z;
-
-#ifdef Pack_32
- n = k >> 5;
-#else
- n = k >> 4;
-#endif
- k1 = b->k;
- n1 = n + b->wds + 1;
- for (i = b->maxwds; n1 > i; i <<= 1)
- k1++;
- b1 = Balloc(k1);
- x1 = b1->x;
- for (i = 0; i < n; i++)
- *x1++ = 0;
- x = b->x;
- xe = x + b->wds;
-#ifdef Pack_32
- if (k &= 0x1f) {
- k1 = 32 - k;
- z = 0;
- do {
- *x1++ = *x << k | z;
- z = *x++ >> k1;
- } while (x < xe);
- if ((*x1 = z) != 0)
- ++n1;
- }
-#else
- if (k &= 0xf) {
- k1 = 16 - k;
- z = 0;
- do {
- *x1++ = *x << k & 0xffff | z;
- z = *x++ >> k1;
- } while (x < xe);
- if (*x1 = z)
- ++n1;
- }
-#endif
- else
- do {
- *x1++ = *x++;
- } while (x < xe);
- b1->wds = n1 - 1;
- Bfree(b);
- return b1;
-}
-
-static int
-cmp(Bigint *a, Bigint *b)
-{
- ULong *xa, *xa0, *xb, *xb0;
- int i, j;
-
- i = a->wds;
- j = b->wds;
-#ifdef DEBUG
- if (i > 1 && !a->x[i-1])
- Bug("cmp called with a->x[a->wds-1] == 0");
- if (j > 1 && !b->x[j-1])
- Bug("cmp called with b->x[b->wds-1] == 0");
-#endif
- if (i -= j)
- return i;
- xa0 = a->x;
- xa = xa0 + j;
- xb0 = b->x;
- xb = xb0 + j;
- for (;;) {
- if (*--xa != *--xb)
- return *xa < *xb ? -1 : 1;
- if (xa <= xa0)
- break;
- }
- return 0;
-}
-
-NO_SANITIZE("unsigned-integer-overflow", static Bigint * diff(Bigint *a, Bigint *b));
-static Bigint *
-diff(Bigint *a, Bigint *b)
-{
- Bigint *c;
- int i, wa, wb;
- ULong *xa, *xae, *xb, *xbe, *xc;
-#ifdef ULLong
- ULLong borrow, y;
-#else
- ULong borrow, y;
-#ifdef Pack_32
- ULong z;
-#endif
-#endif
-
- i = cmp(a,b);
- if (!i) {
- c = Balloc(0);
- c->wds = 1;
- c->x[0] = 0;
- return c;
- }
- if (i < 0) {
- c = a;
- a = b;
- b = c;
- i = 1;
- }
- else
- i = 0;
- c = Balloc(a->k);
- c->sign = i;
- wa = a->wds;
- xa = a->x;
- xae = xa + wa;
- wb = b->wds;
- xb = b->x;
- xbe = xb + wb;
- xc = c->x;
- borrow = 0;
-#ifdef ULLong
- do {
- y = (ULLong)*xa++ - *xb++ - borrow;
- borrow = y >> 32 & (ULong)1;
- *xc++ = (ULong)(y & FFFFFFFF);
- } while (xb < xbe);
- while (xa < xae) {
- y = *xa++ - borrow;
- borrow = y >> 32 & (ULong)1;
- *xc++ = (ULong)(y & FFFFFFFF);
- }
-#else
-#ifdef Pack_32
- do {
- y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(xc, z, y);
- } while (xb < xbe);
- while (xa < xae) {
- y = (*xa & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*xa++ >> 16) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(xc, z, y);
- }
-#else
- do {
- y = *xa++ - *xb++ - borrow;
- borrow = (y & 0x10000) >> 16;
- *xc++ = y & 0xffff;
- } while (xb < xbe);
- while (xa < xae) {
- y = *xa++ - borrow;
- borrow = (y & 0x10000) >> 16;
- *xc++ = y & 0xffff;
- }
-#endif
-#endif
- while (!*--xc)
- wa--;
- c->wds = wa;
- return c;
-}
-
-static double
-ulp(double x_)
-{
- register Long L;
- double_u x, a;
- dval(x) = x_;
-
- L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
-#ifndef Avoid_Underflow
-#ifndef Sudden_Underflow
- if (L > 0) {
-#endif
-#endif
-#ifdef IBM
- L |= Exp_msk1 >> 4;
-#endif
- word0(a) = L;
- word1(a) = 0;
-#ifndef Avoid_Underflow
-#ifndef Sudden_Underflow
- }
- else {
- L = -L >> Exp_shift;
- if (L < Exp_shift) {
- word0(a) = 0x80000 >> L;
- word1(a) = 0;
- }
- else {
- word0(a) = 0;
- L -= Exp_shift;
- word1(a) = L >= 31 ? 1 : 1 << 31 - L;
- }
- }
-#endif
-#endif
- return dval(a);
-}
-
-static double
-b2d(Bigint *a, int *e)
-{
- ULong *xa, *xa0, w, y, z;
- int k;
- double_u d;
-#ifdef VAX
- ULong d0, d1;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
- xa0 = a->x;
- xa = xa0 + a->wds;
- y = *--xa;
-#ifdef DEBUG
- if (!y) Bug("zero y in b2d");
-#endif
- k = hi0bits(y);
- *e = 32 - k;
-#ifdef Pack_32
- if (k < Ebits) {
- d0 = Exp_1 | y >> (Ebits - k);
- w = xa > xa0 ? *--xa : 0;
- d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- if (k -= Ebits) {
- d0 = Exp_1 | y << k | z >> (32 - k);
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k | y >> (32 - k);
- }
- else {
- d0 = Exp_1 | y;
- d1 = z;
- }
-#else
- if (k < Ebits + 16) {
- z = xa > xa0 ? *--xa : 0;
- d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
- w = xa > xa0 ? *--xa : 0;
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- w = xa > xa0 ? *--xa : 0;
- k -= Ebits + 16;
- d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
- y = xa > xa0 ? *--xa : 0;
- d1 = w << k + 16 | y << k;
-#endif
-ret_d:
-#ifdef VAX
- word0(d) = d0 >> 16 | d0 << 16;
- word1(d) = d1 >> 16 | d1 << 16;
-#else
-#undef d0
-#undef d1
-#endif
- return dval(d);
-}
-
-static Bigint *
-d2b(double d_, int *e, int *bits)
-{
- double_u d;
- Bigint *b;
- int de, k;
- ULong *x, y, z;
-#ifndef Sudden_Underflow
- int i;
-#endif
-#ifdef VAX
- ULong d0, d1;
-#endif
- dval(d) = d_;
-#ifdef VAX
- d0 = word0(d) >> 16 | word0(d) << 16;
- d1 = word1(d) >> 16 | word1(d) << 16;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
-#ifdef Pack_32
- b = Balloc(1);
-#else
- b = Balloc(2);
-#endif
- x = b->x;
-
- z = d0 & Frac_mask;
- d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
-#ifdef Sudden_Underflow
- de = (int)(d0 >> Exp_shift);
-#ifndef IBM
- z |= Exp_msk11;
-#endif
-#else
- if ((de = (int)(d0 >> Exp_shift)) != 0)
- z |= Exp_msk1;
-#endif
-#ifdef Pack_32
- if ((y = d1) != 0) {
- if ((k = lo0bits(&y)) != 0) {
- x[0] = y | z << (32 - k);
- z >>= k;
- }
- else
- x[0] = y;
-#ifndef Sudden_Underflow
- i =
-#endif
- b->wds = (x[1] = z) ? 2 : 1;
- }
- else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
- k = lo0bits(&z);
- x[0] = z;
-#ifndef Sudden_Underflow
- i =
-#endif
- b->wds = 1;
- k += 32;
- }
-#else
- if (y = d1) {
- if (k = lo0bits(&y))
- if (k >= 16) {
- x[0] = y | z << 32 - k & 0xffff;
- x[1] = z >> k - 16 & 0xffff;
- x[2] = z >> k;
- i = 2;
- }
- else {
- x[0] = y & 0xffff;
- x[1] = y >> 16 | z << 16 - k & 0xffff;
- x[2] = z >> k & 0xffff;
- x[3] = z >> k+16;
- i = 3;
- }
- else {
- x[0] = y & 0xffff;
- x[1] = y >> 16;
- x[2] = z & 0xffff;
- x[3] = z >> 16;
- i = 3;
- }
- }
- else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
- k = lo0bits(&z);
- if (k >= 16) {
- x[0] = z;
- i = 0;
- }
- else {
- x[0] = z & 0xffff;
- x[1] = z >> 16;
- i = 1;
- }
- k += 32;
- }
- while (!x[i])
- --i;
- b->wds = i + 1;
-#endif
-#ifndef Sudden_Underflow
- if (de) {
-#endif
-#ifdef IBM
- *e = (de - Bias - (P-1) << 2) + k;
- *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
-#else
- *e = de - Bias - (P-1) + k;
- *bits = P - k;
-#endif
-#ifndef Sudden_Underflow
- }
- else {
- *e = de - Bias - (P-1) + 1 + k;
-#ifdef Pack_32
- *bits = 32*i - hi0bits(x[i-1]);
-#else
- *bits = (i+2)*16 - hi0bits(x[i]);
-#endif
- }
-#endif
- return b;
-}
-#undef d0
-#undef d1
-
-static double
-ratio(Bigint *a, Bigint *b)
-{
- double_u da, db;
- int k, ka, kb;
-
- dval(da) = b2d(a, &ka);
- dval(db) = b2d(b, &kb);
-#ifdef Pack_32
- k = ka - kb + 32*(a->wds - b->wds);
-#else
- k = ka - kb + 16*(a->wds - b->wds);
-#endif
-#ifdef IBM
- if (k > 0) {
- word0(da) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- dval(da) *= 1 << k;
- }
- else {
- k = -k;
- word0(db) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- dval(db) *= 1 << k;
- }
-#else
- if (k > 0)
- word0(da) += k*Exp_msk1;
- else {
- k = -k;
- word0(db) += k*Exp_msk1;
- }
-#endif
- return dval(da) / dval(db);
-}
-
-static const double
-tens[] = {
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22
-#ifdef VAX
- , 1e23, 1e24
-#endif
-};
-
-static const double
-#ifdef IEEE_Arith
-bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
-static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
-#ifdef Avoid_Underflow
- 9007199254740992.*9007199254740992.e-256
- /* = 2^106 * 1e-53 */
-#else
- 1e-256
-#endif
-};
-/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
-/* flag unnecessarily. It leads to a song and dance at the end of strtod. */
-#define Scale_Bit 0x10
-#define n_bigtens 5
-#else
-#ifdef IBM
-bigtens[] = { 1e16, 1e32, 1e64 };
-static const double tinytens[] = { 1e-16, 1e-32, 1e-64 };
-#define n_bigtens 3
-#else
-bigtens[] = { 1e16, 1e32 };
-static const double tinytens[] = { 1e-16, 1e-32 };
-#define n_bigtens 2
-#endif
-#endif
-
-#ifndef IEEE_Arith
-#undef INFNAN_CHECK
-#endif
-
-#ifdef INFNAN_CHECK
-
-#ifndef NAN_WORD0
-#define NAN_WORD0 0x7ff80000
-#endif
-
-#ifndef NAN_WORD1
-#define NAN_WORD1 0
-#endif
-
-static int
-match(const char **sp, char *t)
-{
- int c, d;
- const char *s = *sp;
-
- while (d = *t++) {
- if ((c = *++s) >= 'A' && c <= 'Z')
- c += 'a' - 'A';
- if (c != d)
- return 0;
- }
- *sp = s + 1;
- return 1;
-}
-
-#ifndef No_Hex_NaN
-static void
-hexnan(double *rvp, const char **sp)
-{
- ULong c, x[2];
- const char *s;
- int havedig, udx0, xshift;
-
- x[0] = x[1] = 0;
- havedig = xshift = 0;
- udx0 = 1;
- s = *sp;
- while (c = *(const unsigned char*)++s) {
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (c >= 'a' && c <= 'f')
- c += 10 - 'a';
- else if (c >= 'A' && c <= 'F')
- c += 10 - 'A';
- else if (c <= ' ') {
- if (udx0 && havedig) {
- udx0 = 0;
- xshift = 1;
- }
- continue;
- }
- else if (/*(*/ c == ')' && havedig) {
- *sp = s + 1;
- break;
- }
- else
- return; /* invalid form: don't change *sp */
- havedig = 1;
- if (xshift) {
- xshift = 0;
- x[0] = x[1];
- x[1] = 0;
- }
- if (udx0)
- x[0] = (x[0] << 4) | (x[1] >> 28);
- x[1] = (x[1] << 4) | c;
- }
- if ((x[0] &= 0xfffff) || x[1]) {
- word0(*rvp) = Exp_mask | x[0];
- word1(*rvp) = x[1];
- }
-}
-#endif /*No_Hex_NaN*/
-#endif /* INFNAN_CHECK */
-
-NO_SANITIZE("unsigned-integer-overflow", double strtod(const char *s00, char **se));
-double
-strtod(const char *s00, char **se)
-{
-#ifdef Avoid_Underflow
- int scale;
-#endif
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
- e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
- const char *s, *s0, *s1;
- double aadj, adj;
- double_u aadj1, rv, rv0;
- Long L;
- ULong y, z;
- Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
-#ifdef SET_INEXACT
- int inexact, oldinexact;
-#endif
-#ifdef Honor_FLT_ROUNDS
- int rounding;
-#endif
-#ifdef USE_LOCALE
- const char *s2;
-#endif
-
- errno = 0;
- sign = nz0 = nz = 0;
- dval(rv) = 0.;
- for (s = s00;;s++)
- switch (*s) {
- case '-':
- sign = 1;
- /* no break */
- case '+':
- if (*++s)
- goto break2;
- /* no break */
- case 0:
- goto ret0;
- case '\t':
- case '\n':
- case '\v':
- case '\f':
- case '\r':
- case ' ':
- continue;
- default:
- goto break2;
- }
-break2:
- if (*s == '0') {
- if (s[1] == 'x' || s[1] == 'X') {
- s0 = ++s;
- adj = 0;
- aadj = 1.0;
- nd0 = -4;
-
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
- if (*s == '0') {
- while (*++s == '0');
- s1 = strchr(hexdigit, *s);
- }
- if (s1 != NULL) {
- do {
- adj += aadj * ((s1 - hexdigit) & 15);
- nd0 += 4;
- aadj /= 16;
- } while (*++s && (s1 = strchr(hexdigit, *s)));
- }
-
- if (*s == '.') {
- dsign = 1;
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
- if (nd0 < 0) {
- while (*s == '0') {
- s++;
- nd0 -= 4;
- }
- }
- for (; *s && (s1 = strchr(hexdigit, *s)); ++s) {
- adj += aadj * ((s1 - hexdigit) & 15);
- if ((aadj /= 16) == 0.0) {
- while (strchr(hexdigit, *++s));
- break;
- }
- }
- }
- else {
- dsign = 0;
- }
-
- if (*s == 'P' || *s == 'p') {
- dsign = 0x2C - *++s; /* +: 2B, -: 2D */
- if (abs(dsign) == 1) s++;
- else dsign = 1;
-
- nd = 0;
- c = *s;
- if (c < '0' || '9' < c) goto ret0;
- do {
- nd *= 10;
- nd += c;
- nd -= '0';
- c = *++s;
- /* Float("0x0."+("0"*267)+"1fp2095") */
- if (nd + dsign * nd0 > 2095) {
- while ('0' <= c && c <= '9') c = *++s;
- break;
- }
- } while ('0' <= c && c <= '9');
- nd0 += nd * dsign;
- }
- else {
- if (dsign) goto ret0;
- }
- dval(rv) = ldexp(adj, nd0);
- goto ret;
- }
- nz0 = 1;
- while (*++s == '0') ;
- if (!*s)
- goto ret;
- }
- s0 = s;
- y = z = 0;
- for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
- if (nd < 9)
- y = 10*y + c - '0';
- else if (nd < DBL_DIG + 2)
- z = 10*z + c - '0';
- nd0 = nd;
-#ifdef USE_LOCALE
- s1 = localeconv()->decimal_point;
- if (c == *s1) {
- c = '.';
- if (*++s1) {
- s2 = s;
- for (;;) {
- if (*++s2 != *s1) {
- c = 0;
- break;
- }
- if (!*++s1) {
- s = s2;
- break;
- }
- }
- }
- }
-#endif
- if (c == '.') {
- if (!ISDIGIT(s[1]))
- goto dig_done;
- c = *++s;
- if (!nd) {
- for (; c == '0'; c = *++s)
- nz++;
- if (c > '0' && c <= '9') {
- s0 = s;
- nf += nz;
- nz = 0;
- goto have_dig;
- }
- goto dig_done;
- }
- for (; c >= '0' && c <= '9'; c = *++s) {
-have_dig:
- nz++;
- if (nd > DBL_DIG * 4) {
- continue;
- }
- if (c -= '0') {
- nf += nz;
- for (i = 1; i < nz; i++)
- if (nd++ < 9)
- y *= 10;
- else if (nd <= DBL_DIG + 2)
- z *= 10;
- if (nd++ < 9)
- y = 10*y + c;
- else if (nd <= DBL_DIG + 2)
- z = 10*z + c;
- nz = 0;
- }
- }
- }
-dig_done:
- e = 0;
- if (c == 'e' || c == 'E') {
- if (!nd && !nz && !nz0) {
- goto ret0;
- }
- s00 = s;
- esign = 0;
- switch (c = *++s) {
- case '-':
- esign = 1;
- case '+':
- c = *++s;
- }
- if (c >= '0' && c <= '9') {
- while (c == '0')
- c = *++s;
- if (c > '0' && c <= '9') {
- L = c - '0';
- s1 = s;
- while ((c = *++s) >= '0' && c <= '9')
- L = 10*L + c - '0';
- if (s - s1 > 8 || L > 19999)
- /* Avoid confusion from exponents
- * so large that e might overflow.
- */
- e = 19999; /* safe for 16 bit ints */
- else
- e = (int)L;
- if (esign)
- e = -e;
- }
- else
- e = 0;
- }
- else
- s = s00;
- }
- if (!nd) {
- if (!nz && !nz0) {
-#ifdef INFNAN_CHECK
- /* Check for Nan and Infinity */
- switch (c) {
- case 'i':
- case 'I':
- if (match(&s,"nf")) {
- --s;
- if (!match(&s,"inity"))
- ++s;
- word0(rv) = 0x7ff00000;
- word1(rv) = 0;
- goto ret;
- }
- break;
- case 'n':
- case 'N':
- if (match(&s, "an")) {
- word0(rv) = NAN_WORD0;
- word1(rv) = NAN_WORD1;
-#ifndef No_Hex_NaN
- if (*s == '(') /*)*/
- hexnan(&rv, &s);
-#endif
- goto ret;
- }
- }
-#endif /* INFNAN_CHECK */
-ret0:
- s = s00;
- sign = 0;
- }
- goto ret;
- }
- e1 = e -= nf;
-
- /* Now we have nd0 digits, starting at s0, followed by a
- * decimal point, followed by nd-nd0 digits. The number we're
- * after is the integer represented by those digits times
- * 10**e */
-
- if (!nd0)
- nd0 = nd;
- k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2;
- dval(rv) = y;
- if (k > 9) {
-#ifdef SET_INEXACT
- if (k > DBL_DIG)
- oldinexact = get_inexact();
-#endif
- dval(rv) = tens[k - 9] * dval(rv) + z;
- }
- bd0 = bb = bd = bs = delta = 0;
- if (nd <= DBL_DIG
-#ifndef RND_PRODQUOT
-#ifndef Honor_FLT_ROUNDS
- && Flt_Rounds == 1
-#endif
-#endif
- ) {
- if (!e)
- goto ret;
- if (e > 0) {
- if (e <= Ten_pmax) {
-#ifdef VAX
- goto vax_ovfl_check;
-#else
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- /* rv = */ rounded_product(dval(rv), tens[e]);
- goto ret;
-#endif
- }
- i = DBL_DIG - nd;
- if (e <= Ten_pmax + i) {
- /* A fancier test would sometimes let us do
- * this for larger i values.
- */
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- e -= i;
- dval(rv) *= tens[i];
-#ifdef VAX
- /* VAX exponent range is so narrow we must
- * worry about overflow here...
- */
-vax_ovfl_check:
- word0(rv) -= P*Exp_msk1;
- /* rv = */ rounded_product(dval(rv), tens[e]);
- if ((word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
- goto ovfl;
- word0(rv) += P*Exp_msk1;
-#else
- /* rv = */ rounded_product(dval(rv), tens[e]);
-#endif
- goto ret;
- }
- }
-#ifndef Inaccurate_Divide
- else if (e >= -Ten_pmax) {
-#ifdef Honor_FLT_ROUNDS
- /* round correctly FLT_ROUNDS = 2 or 3 */
- if (sign) {
- dval(rv) = -dval(rv);
- sign = 0;
- }
-#endif
- /* rv = */ rounded_quotient(dval(rv), tens[-e]);
- goto ret;
- }
-#endif
- }
- e1 += nd - k;
-
-#ifdef IEEE_Arith
-#ifdef SET_INEXACT
- inexact = 1;
- if (k <= DBL_DIG)
- oldinexact = get_inexact();
-#endif
-#ifdef Avoid_Underflow
- scale = 0;
-#endif
-#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
- if (sign)
- rounding = rounding == 2 ? 0 : 2;
- else
- if (rounding != 2)
- rounding = 0;
- }
-#endif
-#endif /*IEEE_Arith*/
-
- /* Get starting approximation = rv * 10**e1 */
-
- if (e1 > 0) {
- if ((i = e1 & 15) != 0)
- dval(rv) *= tens[i];
- if (e1 &= ~15) {
- if (e1 > DBL_MAX_10_EXP) {
-ovfl:
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
- /* Can't trust HUGE_VAL */
-#ifdef IEEE_Arith
-#ifdef Honor_FLT_ROUNDS
- switch (rounding) {
- case 0: /* toward 0 */
- case 3: /* toward -infinity */
- word0(rv) = Big0;
- word1(rv) = Big1;
- break;
- default:
- word0(rv) = Exp_mask;
- word1(rv) = 0;
- }
-#else /*Honor_FLT_ROUNDS*/
- word0(rv) = Exp_mask;
- word1(rv) = 0;
-#endif /*Honor_FLT_ROUNDS*/
-#ifdef SET_INEXACT
- /* set overflow bit */
- dval(rv0) = 1e300;
- dval(rv0) *= dval(rv0);
-#endif
-#else /*IEEE_Arith*/
- word0(rv) = Big0;
- word1(rv) = Big1;
-#endif /*IEEE_Arith*/
- if (bd0)
- goto retfree;
- goto ret;
- }
- e1 >>= 4;
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= bigtens[j];
- /* The last multiplication could overflow. */
- word0(rv) -= P*Exp_msk1;
- dval(rv) *= bigtens[j];
- if ((z = word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-P))
- goto ovfl;
- if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
- /* set to largest number */
- /* (Can't trust DBL_MAX) */
- word0(rv) = Big0;
- word1(rv) = Big1;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
- }
- else if (e1 < 0) {
- e1 = -e1;
- if ((i = e1 & 15) != 0)
- dval(rv) /= tens[i];
- if (e1 >>= 4) {
- if (e1 >= 1 << n_bigtens)
- goto undfl;
-#ifdef Avoid_Underflow
- if (e1 & Scale_Bit)
- scale = 2*P;
- for (j = 0; e1 > 0; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= tinytens[j];
- if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
- >> Exp_shift)) > 0) {
- /* scaled rv is denormal; zap j low bits */
- if (j >= 32) {
- word1(rv) = 0;
- if (j >= 53)
- word0(rv) = (P+2)*Exp_msk1;
- else
- word0(rv) &= 0xffffffff << (j-32);
- }
- else
- word1(rv) &= 0xffffffff << j;
- }
-#else
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- dval(rv) *= tinytens[j];
- /* The last multiplication could underflow. */
- dval(rv0) = dval(rv);
- dval(rv) *= tinytens[j];
- if (!dval(rv)) {
- dval(rv) = 2.*dval(rv0);
- dval(rv) *= tinytens[j];
-#endif
- if (!dval(rv)) {
-undfl:
- dval(rv) = 0.;
-#ifndef NO_ERRNO
- errno = ERANGE;
-#endif
- if (bd0)
- goto retfree;
- goto ret;
- }
-#ifndef Avoid_Underflow
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- /* The refinement below will clean
- * this approximation up.
- */
- }
-#endif
- }
- }
-
- /* Now the hard part -- adjusting rv to the correct value.*/
-
- /* Put digits into bd: true value = bd * 10^e */
-
- bd0 = s2b(s0, nd0, nd, y);
-
- for (;;) {
- bd = Balloc(bd0->k);
- Bcopy(bd, bd0);
- bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
- bs = i2b(1);
-
- if (e >= 0) {
- bb2 = bb5 = 0;
- bd2 = bd5 = e;
- }
- else {
- bb2 = bb5 = -e;
- bd2 = bd5 = 0;
- }
- if (bbe >= 0)
- bb2 += bbe;
- else
- bd2 -= bbe;
- bs2 = bb2;
-#ifdef Honor_FLT_ROUNDS
- if (rounding != 1)
- bs2++;
-#endif
-#ifdef Avoid_Underflow
- j = bbe - scale;
- i = j + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j += P - Emin;
- else
- j = P + 1 - bbbits;
-#else /*Avoid_Underflow*/
-#ifdef Sudden_Underflow
-#ifdef IBM
- j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
-#else
- j = P + 1 - bbbits;
-#endif
-#else /*Sudden_Underflow*/
- j = bbe;
- i = j + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j += P - Emin;
- else
- j = P + 1 - bbbits;
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- bb2 += j;
- bd2 += j;
-#ifdef Avoid_Underflow
- bd2 += scale;
-#endif
- i = bb2 < bd2 ? bb2 : bd2;
- if (i > bs2)
- i = bs2;
- if (i > 0) {
- bb2 -= i;
- bd2 -= i;
- bs2 -= i;
- }
- if (bb5 > 0) {
- bs = pow5mult(bs, bb5);
- bb1 = mult(bs, bb);
- Bfree(bb);
- bb = bb1;
- }
- if (bb2 > 0)
- bb = lshift(bb, bb2);
- if (bd5 > 0)
- bd = pow5mult(bd, bd5);
- if (bd2 > 0)
- bd = lshift(bd, bd2);
- if (bs2 > 0)
- bs = lshift(bs, bs2);
- delta = diff(bb, bd);
- dsign = delta->sign;
- delta->sign = 0;
- i = cmp(delta, bs);
-#ifdef Honor_FLT_ROUNDS
- if (rounding != 1) {
- if (i < 0) {
- /* Error is less than an ulp */
- if (!delta->x[0] && delta->wds <= 1) {
- /* exact */
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- if (rounding) {
- if (dsign) {
- adj = 1.;
- goto apply_adj;
- }
- }
- else if (!dsign) {
- adj = -1.;
- if (!word1(rv)
- && !(word0(rv) & Frac_mask)) {
- y = word0(rv) & Exp_mask;
-#ifdef Avoid_Underflow
- if (!scale || y > 2*P*Exp_msk1)
-#else
- if (y)
-#endif
- {
- delta = lshift(delta,Log2P);
- if (cmp(delta, bs) <= 0)
- adj = -0.5;
- }
- }
-apply_adj:
-#ifdef Avoid_Underflow
- if (scale && (y = word0(rv) & Exp_mask)
- <= 2*P*Exp_msk1)
- word0(adj) += (2*P+1)*Exp_msk1 - y;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <=
- P*Exp_msk1) {
- word0(rv) += P*Exp_msk1;
- dval(rv) += adj*ulp(dval(rv));
- word0(rv) -= P*Exp_msk1;
- }
- else
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- dval(rv) += adj*ulp(dval(rv));
- }
- break;
- }
- adj = ratio(delta, bs);
- if (adj < 1.)
- adj = 1.;
- if (adj <= 0x7ffffffe) {
- /* adj = rounding ? ceil(adj) : floor(adj); */
- y = adj;
- if (y != adj) {
- if (!((rounding>>1) ^ dsign))
- y++;
- adj = y;
- }
- }
-#ifdef Avoid_Underflow
- if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
- word0(adj) += (2*P+1)*Exp_msk1 - y;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
- word0(rv) += P*Exp_msk1;
- adj *= ulp(dval(rv));
- if (dsign)
- dval(rv) += adj;
- else
- dval(rv) -= adj;
- word0(rv) -= P*Exp_msk1;
- goto cont;
- }
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- adj *= ulp(dval(rv));
- if (dsign)
- dval(rv) += adj;
- else
- dval(rv) -= adj;
- goto cont;
- }
-#endif /*Honor_FLT_ROUNDS*/
-
- if (i < 0) {
- /* Error is less than half an ulp -- check for
- * special case of mantissa a power of two.
- */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask
-#ifdef IEEE_Arith
-#ifdef Avoid_Underflow
- || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
-#else
- || (word0(rv) & Exp_mask) <= Exp_msk1
-#endif
-#endif
- ) {
-#ifdef SET_INEXACT
- if (!delta->x[0] && delta->wds <= 1)
- inexact = 0;
-#endif
- break;
- }
- if (!delta->x[0] && delta->wds <= 1) {
- /* exact result */
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- delta = lshift(delta,Log2P);
- if (cmp(delta, bs) > 0)
- goto drop_down;
- break;
- }
- if (i == 0) {
- /* exactly half-way between */
- if (dsign) {
- if ((word0(rv) & Bndry_mask1) == Bndry_mask1
- && word1(rv) == (
-#ifdef Avoid_Underflow
- (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
- ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
-#endif
- 0xffffffff)) {
- /*boundary case -- increment exponent*/
- word0(rv) = (word0(rv) & Exp_mask)
- + Exp_msk1
-#ifdef IBM
- | Exp_msk1 >> 4
-#endif
- ;
- word1(rv) = 0;
-#ifdef Avoid_Underflow
- dsign = 0;
-#endif
- break;
- }
- }
- else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
-drop_down:
- /* boundary case -- decrement exponent */
-#ifdef Sudden_Underflow /*{{*/
- L = word0(rv) & Exp_mask;
-#ifdef IBM
- if (L < Exp_msk1)
-#else
-#ifdef Avoid_Underflow
- if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
-#else
- if (L <= Exp_msk1)
-#endif /*Avoid_Underflow*/
-#endif /*IBM*/
- goto undfl;
- L -= Exp_msk1;
-#else /*Sudden_Underflow}{*/
-#ifdef Avoid_Underflow
- if (scale) {
- L = word0(rv) & Exp_mask;
- if (L <= (2*P+1)*Exp_msk1) {
- if (L > (P+2)*Exp_msk1)
- /* round even ==> */
- /* accept rv */
- break;
- /* rv = smallest denormal */
- goto undfl;
- }
- }
-#endif /*Avoid_Underflow*/
- L = (word0(rv) & Exp_mask) - Exp_msk1;
-#endif /*Sudden_Underflow}}*/
- word0(rv) = L | Bndry_mask1;
- word1(rv) = 0xffffffff;
-#ifdef IBM
- goto cont;
-#else
- break;
-#endif
- }
-#ifndef ROUND_BIASED
- if (!(word1(rv) & LSB))
- break;
-#endif
- if (dsign)
- dval(rv) += ulp(dval(rv));
-#ifndef ROUND_BIASED
- else {
- dval(rv) -= ulp(dval(rv));
-#ifndef Sudden_Underflow
- if (!dval(rv))
- goto undfl;
-#endif
- }
-#ifdef Avoid_Underflow
- dsign = 1 - dsign;
-#endif
-#endif
- break;
- }
- if ((aadj = ratio(delta, bs)) <= 2.) {
- if (dsign)
- aadj = dval(aadj1) = 1.;
- else if (word1(rv) || word0(rv) & Bndry_mask) {
-#ifndef Sudden_Underflow
- if (word1(rv) == Tiny1 && !word0(rv))
- goto undfl;
-#endif
- aadj = 1.;
- dval(aadj1) = -1.;
- }
- else {
- /* special case -- power of FLT_RADIX to be */
- /* rounded down... */
-
- if (aadj < 2./FLT_RADIX)
- aadj = 1./FLT_RADIX;
- else
- aadj *= 0.5;
- dval(aadj1) = -aadj;
- }
- }
- else {
- aadj *= 0.5;
- dval(aadj1) = dsign ? aadj : -aadj;
-#ifdef Check_FLT_ROUNDS
- switch (Rounding) {
- case 2: /* towards +infinity */
- dval(aadj1) -= 0.5;
- break;
- case 0: /* towards 0 */
- case 3: /* towards -infinity */
- dval(aadj1) += 0.5;
- }
-#else
- if (Flt_Rounds == 0)
- dval(aadj1) += 0.5;
-#endif /*Check_FLT_ROUNDS*/
- }
- y = word0(rv) & Exp_mask;
-
- /* Check for overflow */
-
- if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
- dval(rv0) = dval(rv);
- word0(rv) -= P*Exp_msk1;
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
- if ((word0(rv) & Exp_mask) >=
- Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
- if (word0(rv0) == Big0 && word1(rv0) == Big1)
- goto ovfl;
- word0(rv) = Big0;
- word1(rv) = Big1;
- goto cont;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
- else {
-#ifdef Avoid_Underflow
- if (scale && y <= 2*P*Exp_msk1) {
- if (aadj <= 0x7fffffff) {
- if ((z = (int)aadj) <= 0)
- z = 1;
- aadj = z;
- dval(aadj1) = dsign ? aadj : -aadj;
- }
- word0(aadj1) += (2*P+1)*Exp_msk1 - y;
- }
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#else
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
- dval(rv0) = dval(rv);
- word0(rv) += P*Exp_msk1;
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#ifdef IBM
- if ((word0(rv) & Exp_mask) < P*Exp_msk1)
-#else
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
-#endif
- {
- if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1)
- goto undfl;
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- goto cont;
- }
- else
- word0(rv) -= P*Exp_msk1;
- }
- else {
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
- }
-#else /*Sudden_Underflow*/
- /* Compute adj so that the IEEE rounding rules will
- * correctly round rv + adj in some half-way cases.
- * If rv * ulp(rv) is denormalized (i.e.,
- * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
- * trouble from bits lost to denormalization;
- * example: 1.2e-307 .
- */
- if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
- dval(aadj1) = (double)(int)(aadj + 0.5);
- if (!dsign)
- dval(aadj1) = -dval(aadj1);
- }
- adj = dval(aadj1) * ulp(dval(rv));
- dval(rv) += adj;
-#endif /*Sudden_Underflow*/
-#endif /*Avoid_Underflow*/
- }
- z = word0(rv) & Exp_mask;
-#ifndef SET_INEXACT
-#ifdef Avoid_Underflow
- if (!scale)
-#endif
- if (y == z) {
- /* Can we stop now? */
- L = (Long)aadj;
- aadj -= L;
- /* The tolerances below are conservative. */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
- if (aadj < .4999999 || aadj > .5000001)
- break;
- }
- else if (aadj < .4999999/FLT_RADIX)
- break;
- }
-#endif
-cont:
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(delta);
- }
-#ifdef SET_INEXACT
- if (inexact) {
- if (!oldinexact) {
- word0(rv0) = Exp_1 + (70 << Exp_shift);
- word1(rv0) = 0;
- dval(rv0) += 1.;
- }
- }
- else if (!oldinexact)
- clear_inexact();
-#endif
-#ifdef Avoid_Underflow
- if (scale) {
- word0(rv0) = Exp_1 - 2*P*Exp_msk1;
- word1(rv0) = 0;
- dval(rv) *= dval(rv0);
-#ifndef NO_ERRNO
- /* try to avoid the bug of testing an 8087 register value */
- if (word0(rv) == 0 && word1(rv) == 0)
- errno = ERANGE;
-#endif
- }
-#endif /* Avoid_Underflow */
-#ifdef SET_INEXACT
- if (inexact && !(word0(rv) & Exp_mask)) {
- /* set underflow bit */
- dval(rv0) = 1e-300;
- dval(rv0) *= dval(rv0);
- }
-#endif
-retfree:
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(bd0);
- Bfree(delta);
-ret:
- if (se)
- *se = (char *)s;
- return sign ? -dval(rv) : dval(rv);
-}
-
-NO_SANITIZE("unsigned-integer-overflow", static int quorem(Bigint *b, Bigint *S));
-static int
-quorem(Bigint *b, Bigint *S)
-{
- int n;
- ULong *bx, *bxe, q, *sx, *sxe;
-#ifdef ULLong
- ULLong borrow, carry, y, ys;
-#else
- ULong borrow, carry, y, ys;
-#ifdef Pack_32
- ULong si, z, zs;
-#endif
-#endif
-
- n = S->wds;
-#ifdef DEBUG
- /*debug*/ if (b->wds > n)
- /*debug*/ Bug("oversize b in quorem");
-#endif
- if (b->wds < n)
- return 0;
- sx = S->x;
- sxe = sx + --n;
- bx = b->x;
- bxe = bx + n;
- q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
-#ifdef DEBUG
- /*debug*/ if (q > 9)
- /*debug*/ Bug("oversized quotient in quorem");
-#endif
- if (q) {
- borrow = 0;
- carry = 0;
- do {
-#ifdef ULLong
- ys = *sx++ * (ULLong)q + carry;
- carry = ys >> 32;
- y = *bx - (ys & FFFFFFFF) - borrow;
- borrow = y >> 32 & (ULong)1;
- *bx++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) * q + carry;
- zs = (si >> 16) * q + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(bx, z, y);
-#else
- ys = *sx++ * q + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- *bx++ = y & 0xffff;
-#endif
-#endif
- } while (sx <= sxe);
- if (!*bxe) {
- bx = b->x;
- while (--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- if (cmp(b, S) >= 0) {
- q++;
- borrow = 0;
- carry = 0;
- bx = b->x;
- sx = S->x;
- do {
-#ifdef ULLong
- ys = *sx++ + carry;
- carry = ys >> 32;
- y = *bx - (ys & FFFFFFFF) - borrow;
- borrow = y >> 32 & (ULong)1;
- *bx++ = (ULong)(y & FFFFFFFF);
-#else
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) + carry;
- zs = (si >> 16) + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- z = (*bx >> 16) - (zs & 0xffff) - borrow;
- borrow = (z & 0x10000) >> 16;
- Storeinc(bx, z, y);
-#else
- ys = *sx++ + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) - borrow;
- borrow = (y & 0x10000) >> 16;
- *bx++ = y & 0xffff;
-#endif
-#endif
- } while (sx <= sxe);
- bx = b->x;
- bxe = bx + n;
- if (!*bxe) {
- while (--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- return q;
-}
-
-#ifndef MULTIPLE_THREADS
-static char *dtoa_result;
-#endif
-
-#ifndef MULTIPLE_THREADS
-static char *
-rv_alloc(int i)
-{
- return dtoa_result = MALLOC(i);
-}
-#else
-#define rv_alloc(i) MALLOC(i)
-#endif
-
-static char *
-nrv_alloc(const char *s, char **rve, size_t n)
-{
- char *rv, *t;
-
- t = rv = rv_alloc(n);
- while ((*t = *s++) != 0) t++;
- if (rve)
- *rve = t;
- return rv;
-}
-
-#define rv_strdup(s, rve) nrv_alloc((s), (rve), strlen(s)+1)
-
-#ifndef MULTIPLE_THREADS
-/* freedtoa(s) must be used to free values s returned by dtoa
- * when MULTIPLE_THREADS is #defined. It should be used in all cases,
- * but for consistency with earlier versions of dtoa, it is optional
- * when MULTIPLE_THREADS is not defined.
- */
-
-static void
-freedtoa(char *s)
-{
- FREE(s);
-}
-#endif
-
-static const char INFSTR[] = "Infinity";
-static const char NANSTR[] = "NaN";
-static const char ZEROSTR[] = "0";
-
-/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
- *
- * Inspired by "How to Print Floating-Point Numbers Accurately" by
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
- *
- * Modifications:
- * 1. Rather than iterating, we use a simple numeric overestimate
- * to determine k = floor(log10(d)). We scale relevant
- * quantities using O(log2(k)) rather than O(k) multiplications.
- * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
- * try to generate digits strictly left to right. Instead, we
- * compute with fewer bits and propagate the carry if necessary
- * when rounding the final digit up. This is often faster.
- * 3. Under the assumption that input will be rounded nearest,
- * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
- * That is, we allow equality in stopping tests when the
- * round-nearest rule will give the same floating-point value
- * as would satisfaction of the stopping test with strict
- * inequality.
- * 4. We remove common factors of powers of 2 from relevant
- * quantities.
- * 5. When converting floating-point integers less than 1e16,
- * we use floating-point arithmetic rather than resorting
- * to multiple-precision integers.
- * 6. When asked to produce fewer than 15 digits, we first try
- * to get by with floating-point arithmetic; we resort to
- * multiple-precision integer arithmetic only if we cannot
- * guarantee that the floating-point calculation has given
- * the correctly rounded result. For k requested digits and
- * "uniformly" distributed input, the probability is
- * something like 10^(k-15) that we must resort to the Long
- * calculation.
- */
-
-char *
-dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
-{
- /* Arguments ndigits, decpt, sign are similar to those
- of ecvt and fcvt; trailing zeros are suppressed from
- the returned string. If not null, *rve is set to point
- to the end of the return value. If d is +-Infinity or NaN,
- then *decpt is set to 9999.
-
- mode:
- 0 ==> shortest string that yields d when read in
- and rounded to nearest.
- 1 ==> like 0, but with Steele & White stopping rule;
- e.g. with IEEE P754 arithmetic , mode 0 gives
- 1e23 whereas mode 1 gives 9.999999999999999e22.
- 2 ==> max(1,ndigits) significant digits. This gives a
- return value similar to that of ecvt, except
- that trailing zeros are suppressed.
- 3 ==> through ndigits past the decimal point. This
- gives a return value similar to that from fcvt,
- except that trailing zeros are suppressed, and
- ndigits can be negative.
- 4,5 ==> similar to 2 and 3, respectively, but (in
- round-nearest mode) with the tests of mode 0 to
- possibly return a shorter string that rounds to d.
- With IEEE arithmetic and compilation with
- -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
- as modes 2 and 3 when FLT_ROUNDS != 1.
- 6-9 ==> Debugging modes similar to mode - 4: don't try
- fast floating-point estimate (if applicable).
-
- Values of mode other than 0-9 are treated as mode 0.
-
- Sufficient space is allocated to the return value
- to hold the suppressed trailing zeros.
- */
-
- int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
- j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
- spec_case, try_quick, half = 0;
- Long L;
-#ifndef Sudden_Underflow
- int denorm;
- ULong x;
-#endif
- Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S;
- double ds;
- double_u d, d2, eps;
- char *s, *s0;
-#ifdef Honor_FLT_ROUNDS
- int rounding;
-#endif
-#ifdef SET_INEXACT
- int inexact, oldinexact;
-#endif
-
- dval(d) = d_;
-
-#ifndef MULTIPLE_THREADS
- if (dtoa_result) {
- freedtoa(dtoa_result);
- dtoa_result = 0;
- }
-#endif
-
- if (word0(d) & Sign_bit) {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0(d) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
-#if defined(IEEE_Arith) + defined(VAX)
-#ifdef IEEE_Arith
- if ((word0(d) & Exp_mask) == Exp_mask)
-#else
- if (word0(d) == 0x8000)
-#endif
- {
- /* Infinity or NaN */
- *decpt = 9999;
-#ifdef IEEE_Arith
- if (!word1(d) && !(word0(d) & 0xfffff))
- return rv_strdup(INFSTR, rve);
-#endif
- return rv_strdup(NANSTR, rve);
- }
-#endif
-#ifdef IBM
- dval(d) += 0; /* normalize */
-#endif
- if (!dval(d)) {
- *decpt = 1;
- return rv_strdup(ZEROSTR, rve);
- }
-
-#ifdef SET_INEXACT
- try_quick = oldinexact = get_inexact();
- inexact = 1;
-#endif
-#ifdef Honor_FLT_ROUNDS
- if ((rounding = Flt_Rounds) >= 2) {
- if (*sign)
- rounding = rounding == 2 ? 0 : 2;
- else
- if (rounding != 2)
- rounding = 0;
- }
-#endif
-
- b = d2b(dval(d), &be, &bbits);
-#ifdef Sudden_Underflow
- i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
-#else
- if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) {
-#endif
- dval(d2) = dval(d);
- word0(d2) &= Frac_mask1;
- word0(d2) |= Exp_11;
-#ifdef IBM
- if (j = 11 - hi0bits(word0(d2) & Frac_mask))
- dval(d2) /= 1 << j;
-#endif
-
- /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
- * log10(x) = log(x) / log(10)
- * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
- * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
- *
- * This suggests computing an approximation k to log10(d) by
- *
- * k = (i - Bias)*0.301029995663981
- * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
- *
- * We want k to be too large rather than too small.
- * The error in the first-order Taylor series approximation
- * is in our favor, so we just round up the constant enough
- * to compensate for any error in the multiplication of
- * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
- * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
- * adding 1e-13 to the constant term more than suffices.
- * Hence we adjust the constant term to 0.1760912590558.
- * (We could get a more accurate k by invoking log10,
- * but this is probably not worthwhile.)
- */
-
- i -= Bias;
-#ifdef IBM
- i <<= 2;
- i += j;
-#endif
-#ifndef Sudden_Underflow
- denorm = 0;
- }
- else {
- /* d is denormalized */
-
- i = bbits + be + (Bias + (P-1) - 1);
- x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
- : word1(d) << (32 - i);
- dval(d2) = x;
- word0(d2) -= 31*Exp_msk1; /* adjust exponent */
- i -= (Bias + (P-1) - 1) + 1;
- denorm = 1;
- }
-#endif
- ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
- k = (int)ds;
- if (ds < 0. && ds != k)
- k--; /* want k = floor(ds) */
- k_check = 1;
- if (k >= 0 && k <= Ten_pmax) {
- if (dval(d) < tens[k])
- k--;
- k_check = 0;
- }
- j = bbits - i - 1;
- if (j >= 0) {
- b2 = 0;
- s2 = j;
- }
- else {
- b2 = -j;
- s2 = 0;
- }
- if (k >= 0) {
- b5 = 0;
- s5 = k;
- s2 += k;
- }
- else {
- b2 -= k;
- b5 = -k;
- s5 = 0;
- }
- if (mode < 0 || mode > 9)
- mode = 0;
-
-#ifndef SET_INEXACT
-#ifdef Check_FLT_ROUNDS
- try_quick = Rounding == 1;
-#else
- try_quick = 1;
-#endif
-#endif /*SET_INEXACT*/
-
- if (mode > 5) {
- mode -= 4;
- try_quick = 0;
- }
- leftright = 1;
- ilim = ilim1 = -1;
- switch (mode) {
- case 0:
- case 1:
- i = 18;
- ndigits = 0;
- break;
- case 2:
- leftright = 0;
- /* no break */
- case 4:
- if (ndigits <= 0)
- ndigits = 1;
- ilim = ilim1 = i = ndigits;
- break;
- case 3:
- leftright = 0;
- /* no break */
- case 5:
- i = ndigits + k + 1;
- ilim = i;
- ilim1 = i - 1;
- if (i <= 0)
- i = 1;
- }
- s = s0 = rv_alloc(i+1);
-
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1 && rounding != 1)
- leftright = 0;
-#endif
-
- if (ilim >= 0 && ilim <= Quick_max && try_quick) {
-
- /* Try to get by with floating-point arithmetic. */
-
- i = 0;
- dval(d2) = dval(d);
- k0 = k;
- ilim0 = ilim;
- ieps = 2; /* conservative */
- if (k > 0) {
- ds = tens[k&0xf];
- j = k >> 4;
- if (j & Bletch) {
- /* prevent overflows */
- j &= Bletch - 1;
- dval(d) /= bigtens[n_bigtens-1];
- ieps++;
- }
- for (; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- ds *= bigtens[i];
- }
- dval(d) /= ds;
- }
- else if ((j1 = -k) != 0) {
- dval(d) *= tens[j1 & 0xf];
- for (j = j1 >> 4; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- dval(d) *= bigtens[i];
- }
- }
- if (k_check && dval(d) < 1. && ilim > 0) {
- if (ilim1 <= 0)
- goto fast_failed;
- ilim = ilim1;
- k--;
- dval(d) *= 10.;
- ieps++;
- }
- dval(eps) = ieps*dval(d) + 7.;
- word0(eps) -= (P-1)*Exp_msk1;
- if (ilim == 0) {
- S = mhi = 0;
- dval(d) -= 5.;
- if (dval(d) > dval(eps))
- goto one_digit;
- if (dval(d) < -dval(eps))
- goto no_digits;
- goto fast_failed;
- }
-#ifndef No_leftright
- if (leftright) {
- /* Use Steele & White method of only
- * generating digits needed.
- */
- dval(eps) = 0.5/tens[ilim-1] - dval(eps);
- for (i = 0;;) {
- L = (int)dval(d);
- dval(d) -= L;
- *s++ = '0' + (int)L;
- if (dval(d) < dval(eps))
- goto ret1;
- if (1. - dval(d) < dval(eps))
- goto bump_up;
- if (++i >= ilim)
- break;
- dval(eps) *= 10.;
- dval(d) *= 10.;
- }
- }
- else {
-#endif
- /* Generate ilim digits, then fix them up. */
- dval(eps) *= tens[ilim-1];
- for (i = 1;; i++, dval(d) *= 10.) {
- L = (Long)(dval(d));
- if (!(dval(d) -= L))
- ilim = i;
- *s++ = '0' + (int)L;
- if (i == ilim) {
- if (dval(d) > 0.5 + dval(eps))
- goto bump_up;
- else if (dval(d) < 0.5 - dval(eps)) {
- while (*--s == '0') ;
- s++;
- goto ret1;
- }
- half = 1;
- if ((*(s-1) - '0') & 1) {
- goto bump_up;
- }
- break;
- }
- }
-#ifndef No_leftright
- }
-#endif
-fast_failed:
- s = s0;
- dval(d) = dval(d2);
- k = k0;
- ilim = ilim0;
- }
-
- /* Do we have a "small" integer? */
-
- if (be >= 0 && k <= Int_max) {
- /* Yes. */
- ds = tens[k];
- if (ndigits < 0 && ilim <= 0) {
- S = mhi = 0;
- if (ilim < 0 || dval(d) <= 5*ds)
- goto no_digits;
- goto one_digit;
- }
- for (i = 1;; i++, dval(d) *= 10.) {
- L = (Long)(dval(d) / ds);
- dval(d) -= L*ds;
-#ifdef Check_FLT_ROUNDS
- /* If FLT_ROUNDS == 2, L will usually be high by 1 */
- if (dval(d) < 0) {
- L--;
- dval(d) += ds;
- }
-#endif
- *s++ = '0' + (int)L;
- if (!dval(d)) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- break;
- }
- if (i == ilim) {
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1)
- switch (rounding) {
- case 0: goto ret1;
- case 2: goto bump_up;
- }
-#endif
- dval(d) += dval(d);
- if (dval(d) > ds || (dval(d) == ds && (L & 1))) {
-bump_up:
- while (*--s == '9')
- if (s == s0) {
- k++;
- *s = '0';
- break;
- }
- ++*s++;
- }
- break;
- }
- }
- goto ret1;
- }
-
- m2 = b2;
- m5 = b5;
- if (leftright) {
- i =
-#ifndef Sudden_Underflow
- denorm ? be + (Bias + (P-1) - 1 + 1) :
-#endif
-#ifdef IBM
- 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
-#else
- 1 + P - bbits;
-#endif
- b2 += i;
- s2 += i;
- mhi = i2b(1);
- }
- if (m2 > 0 && s2 > 0) {
- i = m2 < s2 ? m2 : s2;
- b2 -= i;
- m2 -= i;
- s2 -= i;
- }
- if (b5 > 0) {
- if (leftright) {
- if (m5 > 0) {
- mhi = pow5mult(mhi, m5);
- b1 = mult(mhi, b);
- Bfree(b);
- b = b1;
- }
- if ((j = b5 - m5) != 0)
- b = pow5mult(b, j);
- }
- else
- b = pow5mult(b, b5);
- }
- S = i2b(1);
- if (s5 > 0)
- S = pow5mult(S, s5);
-
- /* Check for special case that d is a normalized power of 2. */
-
- spec_case = 0;
- if ((mode < 2 || leftright)
-#ifdef Honor_FLT_ROUNDS
- && rounding == 1
-#endif
- ) {
- if (!word1(d) && !(word0(d) & Bndry_mask)
-#ifndef Sudden_Underflow
- && word0(d) & (Exp_mask & ~Exp_msk1)
-#endif
- ) {
- /* The special case */
- b2 += Log2P;
- s2 += Log2P;
- spec_case = 1;
- }
- }
-
- /* Arrange for convenient computation of quotients:
- * shift left if necessary so divisor has 4 leading 0 bits.
- *
- * Perhaps we should just compute leading 28 bits of S once
- * and for all and pass them and a shift to quorem, so it
- * can do shifts and ors to compute the numerator for q.
- */
-#ifdef Pack_32
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0)
- i = 32 - i;
-#else
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) != 0)
- i = 16 - i;
-#endif
- if (i > 4) {
- i -= 4;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- else if (i < 4) {
- i += 28;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- if (b2 > 0)
- b = lshift(b, b2);
- if (s2 > 0)
- S = lshift(S, s2);
- if (k_check) {
- if (cmp(b,S) < 0) {
- k--;
- b = multadd(b, 10, 0); /* we botched the k estimate */
- if (leftright)
- mhi = multadd(mhi, 10, 0);
- ilim = ilim1;
- }
- }
- if (ilim <= 0 && (mode == 3 || mode == 5)) {
- if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
- /* no digits, fcvt style */
-no_digits:
- k = -1 - ndigits;
- goto ret;
- }
-one_digit:
- *s++ = '1';
- k++;
- goto ret;
- }
- if (leftright) {
- if (m2 > 0)
- mhi = lshift(mhi, m2);
-
- /* Compute mlo -- check for special case
- * that d is a normalized power of 2.
- */
-
- mlo = mhi;
- if (spec_case) {
- mhi = Balloc(mhi->k);
- Bcopy(mhi, mlo);
- mhi = lshift(mhi, Log2P);
- }
-
- for (i = 1;;i++) {
- dig = quorem(b,S) + '0';
- /* Do we yet have the shortest decimal string
- * that will round to d?
- */
- j = cmp(b, mlo);
- delta = diff(S, mhi);
- j1 = delta->sign ? 1 : cmp(b, delta);
- Bfree(delta);
-#ifndef ROUND_BIASED
- if (j1 == 0 && mode != 1 && !(word1(d) & 1)
-#ifdef Honor_FLT_ROUNDS
- && rounding >= 1
-#endif
- ) {
- if (dig == '9')
- goto round_9_up;
- if (j > 0)
- dig++;
-#ifdef SET_INEXACT
- else if (!b->x[0] && b->wds <= 1)
- inexact = 0;
-#endif
- *s++ = dig;
- goto ret;
- }
-#endif
- if (j < 0 || (j == 0 && mode != 1
-#ifndef ROUND_BIASED
- && !(word1(d) & 1)
-#endif
- )) {
- if (!b->x[0] && b->wds <= 1) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- goto accept_dig;
- }
-#ifdef Honor_FLT_ROUNDS
- if (mode > 1)
- switch (rounding) {
- case 0: goto accept_dig;
- case 2: goto keep_dig;
- }
-#endif /*Honor_FLT_ROUNDS*/
- if (j1 > 0) {
- b = lshift(b, 1);
- j1 = cmp(b, S);
- if ((j1 > 0 || (j1 == 0 && (dig & 1))) && dig++ == '9')
- goto round_9_up;
- }
-accept_dig:
- *s++ = dig;
- goto ret;
- }
- if (j1 > 0) {
-#ifdef Honor_FLT_ROUNDS
- if (!rounding)
- goto accept_dig;
-#endif
- if (dig == '9') { /* possible if i == 1 */
-round_9_up:
- *s++ = '9';
- goto roundoff;
- }
- *s++ = dig + 1;
- goto ret;
- }
-#ifdef Honor_FLT_ROUNDS
-keep_dig:
-#endif
- *s++ = dig;
- if (i == ilim)
- break;
- b = multadd(b, 10, 0);
- if (mlo == mhi)
- mlo = mhi = multadd(mhi, 10, 0);
- else {
- mlo = multadd(mlo, 10, 0);
- mhi = multadd(mhi, 10, 0);
- }
- }
- }
- else
- for (i = 1;; i++) {
- *s++ = dig = quorem(b,S) + '0';
- if (!b->x[0] && b->wds <= 1) {
-#ifdef SET_INEXACT
- inexact = 0;
-#endif
- goto ret;
- }
- if (i >= ilim)
- break;
- b = multadd(b, 10, 0);
- }
-
- /* Round off last digit */
-
-#ifdef Honor_FLT_ROUNDS
- switch (rounding) {
- case 0: goto trimzeros;
- case 2: goto roundoff;
- }
-#endif
- b = lshift(b, 1);
- j = cmp(b, S);
- if (j > 0 || (j == 0 && (dig & 1))) {
- roundoff:
- while (*--s == '9')
- if (s == s0) {
- k++;
- *s++ = '1';
- goto ret;
- }
- if (!half || (*s - '0') & 1)
- ++*s;
- }
- else {
- while (*--s == '0') ;
- }
- s++;
-ret:
- Bfree(S);
- if (mhi) {
- if (mlo && mlo != mhi)
- Bfree(mlo);
- Bfree(mhi);
- }
-ret1:
-#ifdef SET_INEXACT
- if (inexact) {
- if (!oldinexact) {
- word0(d) = Exp_1 + (70 << Exp_shift);
- word1(d) = 0;
- dval(d) += 1.;
- }
- }
- else if (!oldinexact)
- clear_inexact();
-#endif
- Bfree(b);
- *s = 0;
- *decpt = k + 1;
- if (rve)
- *rve = s;
- return s0;
-}
-
-/*-
- * Copyright (c) 2004-2008 David Schultz <das@FreeBSD.ORG>
- * 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.
- */
-
-#define DBL_MANH_SIZE 20
-#define DBL_MANL_SIZE 32
-#define DBL_ADJ (DBL_MAX_EXP - 2)
-#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1)
-#define dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
-#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))
-#define dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask))
-#define dmanl_get(u) ((uint32_t)word1(u))
-
-
-/*
- * This procedure converts a double-precision number in IEEE format
- * into a string of hexadecimal digits and an exponent of 2. Its
- * behavior is bug-for-bug compatible with dtoa() in mode 2, with the
- * following exceptions:
- *
- * - An ndigits < 0 causes it to use as many digits as necessary to
- * represent the number exactly.
- * - The additional xdigs argument should point to either the string
- * "0123456789ABCDEF" or the string "0123456789abcdef", depending on
- * which case is desired.
- * - This routine does not repeat dtoa's mistake of setting decpt
- * to 9999 in the case of an infinity or NaN. INT_MAX is used
- * for this purpose instead.
- *
- * Note that the C99 standard does not specify what the leading digit
- * should be for non-zero numbers. For instance, 0x1.3p3 is the same
- * as 0x2.6p2 is the same as 0x4.cp3. This implementation always makes
- * the leading digit a 1. This ensures that the exponent printed is the
- * actual base-2 exponent, i.e., ilogb(d).
- *
- * Inputs: d, xdigs, ndigits
- * Outputs: decpt, sign, rve
- */
-char *
-hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve)
-{
- U u;
- char *s, *s0;
- int bufsize;
- uint32_t manh, manl;
-
- u.d = d;
- if (word0(u) & Sign_bit) {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0(u) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
- if (isinf(d)) { /* FP_INFINITE */
- *decpt = INT_MAX;
- return rv_strdup(INFSTR, rve);
- }
- else if (isnan(d)) { /* FP_NAN */
- *decpt = INT_MAX;
- return rv_strdup(NANSTR, rve);
- }
- else if (d == 0.0) { /* FP_ZERO */
- *decpt = 1;
- return rv_strdup(ZEROSTR, rve);
- }
- else if (dexp_get(u)) { /* FP_NORMAL */
- *decpt = dexp_get(u) - DBL_ADJ;
- }
- else { /* FP_SUBNORMAL */
- u.d *= 5.363123171977039e+154 /* 0x1p514 */;
- *decpt = dexp_get(u) - (514 + DBL_ADJ);
- }
-
- if (ndigits == 0) /* dtoa() compatibility */
- ndigits = 1;
-
- /*
- * If ndigits < 0, we are expected to auto-size, so we allocate
- * enough space for all the digits.
- */
- bufsize = (ndigits > 0) ? ndigits : SIGFIGS;
- s0 = rv_alloc(bufsize+1);
-
- /* Round to the desired number of digits. */
- if (SIGFIGS > ndigits && ndigits > 0) {
- float redux = 1.0f;
- int offset = 4 * ndigits + DBL_MAX_EXP - 4 - DBL_MANT_DIG;
- dexp_set(u, offset);
- u.d += redux;
- u.d -= redux;
- *decpt += dexp_get(u) - offset;
- }
-
- manh = dmanh_get(u);
- manl = dmanl_get(u);
- *s0 = '1';
- for (s = s0 + 1; s < s0 + bufsize; s++) {
- *s = xdigs[(manh >> (DBL_MANH_SIZE - 4)) & 0xf];
- manh = (manh << 4) | (manl >> (DBL_MANL_SIZE - 4));
- manl <<= 4;
- }
-
- /* If ndigits < 0, we are expected to auto-size the precision. */
- if (ndigits < 0) {
- for (ndigits = SIGFIGS; s0[ndigits - 1] == '0'; ndigits--)
- ;
- }
-
- s = s0 + ndigits;
- *s = '\0';
- if (rve != NULL)
- *rve = s;
- return (s0);
-}
-
-#ifdef __cplusplus
-#if 0
-{ /* satisfy cc-mode */
-#endif
-}
-#endif
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb
deleted file mode 100644
index 516c2473be..0000000000
--- a/ext/bigdecimal/sample/linear.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/local/bin/ruby
-# frozen_string_literal: false
-
-#
-# linear.rb
-#
-# Solves linear equation system(A*x = b) by LU decomposition method.
-# where A is a coefficient matrix,x is an answer vector,b is a constant vector.
-#
-# USAGE:
-# ruby linear.rb [input file solved]
-#
-
-# :stopdoc:
-require "bigdecimal"
-require "bigdecimal/ludcmp"
-
-#
-# NOTE:
-# Change following BigDecimal.limit() if needed.
-BigDecimal.limit(100)
-#
-
-include LUSolve
-def rd_order(na)
- printf("Number of equations ?") if(na <= 0)
- n = ARGF.gets().to_i
-end
-
-na = ARGV.size
-zero = BigDecimal("0.0")
-one = BigDecimal("1.0")
-
-while (n=rd_order(na))>0
- a = []
- as= []
- b = []
- if na <= 0
- # Read data from console.
- printf("\nEnter coefficient matrix element A[i,j]\n")
- for i in 0...n do
- for j in 0...n do
- printf("A[%d,%d]? ",i,j); s = ARGF.gets
- a << BigDecimal(s)
- as << BigDecimal(s)
- end
- printf("Contatant vector element b[%d] ? ",i)
- b << BigDecimal(ARGF.gets)
- end
- else
- # Read data from specified file.
- printf("Coefficient matrix and constant vector.\n")
- for i in 0...n do
- s = ARGF.gets
- printf("%d) %s",i,s)
- s = s.split
- for j in 0...n do
- a << BigDecimal(s[j])
- as << BigDecimal(s[j])
- end
- b << BigDecimal(s[n])
- end
- end
- x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
- printf("Answer(x[i] & (A*x-b)[i]) follows\n")
- for i in 0...n do
- printf("x[%d]=%s ",i,x[i].to_s)
- s = zero
- for j in 0...n do
- s = s + as[i*n+j]*x[j]
- end
- printf(" & %s\n",(s-b[i]).to_s)
- end
-end
diff --git a/ext/bigdecimal/sample/nlsolve.rb b/ext/bigdecimal/sample/nlsolve.rb
deleted file mode 100644
index c2227dac73..0000000000
--- a/ext/bigdecimal/sample/nlsolve.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/local/bin/ruby
-# frozen_string_literal: false
-
-#
-# nlsolve.rb
-# An example for solving nonlinear algebraic equation system.
-#
-
-require "bigdecimal"
-require "bigdecimal/newton"
-include Newton
-
-class Function # :nodoc: all
- def initialize()
- @zero = BigDecimal("0.0")
- @one = BigDecimal("1.0")
- @two = BigDecimal("2.0")
- @ten = BigDecimal("10.0")
- @eps = BigDecimal("1.0e-16")
- end
- def zero;@zero;end
- def one ;@one ;end
- def two ;@two ;end
- def ten ;@ten ;end
- def eps ;@eps ;end
- def values(x) # <= defines functions solved
- f = []
- f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
- f2 = x[0] - x[1] # f2 = x - y => 0
- f <<= f1
- f <<= f2
- f
- end
-end
-
-f = BigDecimal.limit(100)
-f = Function.new
-x = [f.zero,f.zero] # Initial values
-n = nlsolve(f,x)
-p x
diff --git a/ext/bigdecimal/sample/pi.rb b/ext/bigdecimal/sample/pi.rb
deleted file mode 100644
index ea9663896c..0000000000
--- a/ext/bigdecimal/sample/pi.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/local/bin/ruby
-# frozen_string_literal: false
-
-#
-# pi.rb
-#
-# Calculates 3.1415.... (the number of times that a circle's diameter
-# will fit around the circle) using J. Machin's formula.
-#
-
-require "bigdecimal"
-require "bigdecimal/math.rb"
-
-include BigMath
-
-if ARGV.size == 1
- print "PI("+ARGV[0]+"):\n"
- p PI(ARGV[0].to_i)
-else
- print "TRY: ruby pi.rb 1000 \n"
-end
diff --git a/ext/bigdecimal/static_assert.h b/ext/bigdecimal/static_assert.h
deleted file mode 100644
index 9295729bf6..0000000000
--- a/ext/bigdecimal/static_assert.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef BIGDECIMAL_STATIC_ASSERT_H
-#define BIGDECIMAL_STATIC_ASSERT_H
-
-#include "feature.h"
-
-#ifdef HAVE_RUBY_INTERNAL_STATIC_ASSERT_H
-# include <ruby/internal/static_assert.h>
-#endif
-
-#ifdef RBIMPL_STATIC_ASSERT
-# define STATIC_ASSERT RBIMPL_STATIC_ASSERT
-#endif
-
-#ifndef STATIC_ASSERT
-# /* The following section is copied from CRuby's static_assert.h */
-
-# if defined(__cplusplus) && defined(__cpp_static_assert)
-# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
-# define BIGDECIMAL_STATIC_ASSERT0 static_assert
-
-# elif defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER >= 1600
-# define BIGDECIMAL_STATIC_ASSERT0 static_assert
-
-# elif defined(__INTEL_CXX11_MODE__)
-# define BIGDECIMAL_STATIC_ASSERT0 static_assert
-
-# elif defined(__cplusplus) && __cplusplus >= 201103L
-# define BIGDECIMAL_STATIC_ASSERT0 static_assert
-
-# elif defined(__cplusplus) && __has_extension(cxx_static_assert)
-# define BIGDECIMAL_STATIC_ASSERT0 __extension__ static_assert
-
-# elif defined(__STDC_VERSION__) && __has_extension(c_static_assert)
-# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert
-
-# elif defined(__STDC_VERSION__) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
-# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert
-#endif
-
-# if defined(__DOXYGEN__)
-# define STATIC_ASSERT static_assert
-
-# elif defined(BIGDECIMAL_STATIC_ASSERT0)
-# define STATIC_ASSERT(name, expr) \
- BIGDECIMAL_STATIC_ASSERT0(expr, #name ": " #expr)
-
-# else
-# define STATIC_ASSERT(name, expr) \
- typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
-# endif
-#endif /* STATIC_ASSERT */
-
-
-#endif /* BIGDECIMAL_STATIC_ASSERT_H */
diff --git a/ext/cgi/escape/depend b/ext/cgi/escape/depend
index 37304a24f4..05b59bfdea 100644
--- a/ext/cgi/escape/depend
+++ b/ext/cgi/escape/depend
@@ -138,6 +138,7 @@ escape.o: $(hdrdir)/ruby/internal/intern/re.h
escape.o: $(hdrdir)/ruby/internal/intern/ruby.h
escape.o: $(hdrdir)/ruby/internal/intern/select.h
escape.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+escape.o: $(hdrdir)/ruby/internal/intern/set.h
escape.o: $(hdrdir)/ruby/internal/intern/signal.h
escape.o: $(hdrdir)/ruby/internal/intern/sprintf.h
escape.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ escape.o: $(hdrdir)/ruby/internal/special_consts.h
escape.o: $(hdrdir)/ruby/internal/static_assert.h
escape.o: $(hdrdir)/ruby/internal/stdalign.h
escape.o: $(hdrdir)/ruby/internal/stdbool.h
+escape.o: $(hdrdir)/ruby/internal/stdckdint.h
escape.o: $(hdrdir)/ruby/internal/symbol.h
escape.o: $(hdrdir)/ruby/internal/value.h
escape.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/cgi/escape/escape.c b/ext/cgi/escape/escape.c
index c5b76de596..4773186603 100644
--- a/ext/cgi/escape/escape.c
+++ b/ext/cgi/escape/escape.c
@@ -8,7 +8,7 @@ RUBY_EXTERN const signed char ruby_digit36_to_number_table[];
#define upper_hexdigits (ruby_hexdigits+16)
#define char_to_number(c) ruby_digit36_to_number_table[(unsigned char)(c)]
-static VALUE rb_cCGI, rb_mUtil, rb_mEscape;
+static VALUE rb_cCGI, rb_mEscape, rb_mEscapeExt;
static ID id_accept_charset;
#define HTML_ESCAPE_MAX_LEN 6
@@ -45,6 +45,7 @@ escaped_length(VALUE str)
static VALUE
optimized_escape_html(VALUE str)
{
+ VALUE escaped;
VALUE vbuf;
char *buf = ALLOCV_N(char, vbuf, escaped_length(str));
const char *cstr = RSTRING_PTR(str);
@@ -63,7 +64,6 @@ optimized_escape_html(VALUE str)
}
}
- VALUE escaped;
if (RSTRING_LEN(str) < (dest - buf)) {
escaped = rb_str_new(buf, dest - buf);
preserve_original_state(str, escaped);
@@ -83,7 +83,7 @@ optimized_unescape_html(VALUE str)
unsigned long charlimit = (strcasecmp(rb_enc_name(enc), "UTF-8") == 0 ? UNICODE_MAX :
strcasecmp(rb_enc_name(enc), "ISO-8859-1") == 0 ? 256 :
128);
- long i, len, beg = 0;
+ long i, j, len, beg = 0;
size_t clen, plen;
int overflow;
const char *cstr;
@@ -100,6 +100,7 @@ optimized_unescape_html(VALUE str)
plen = i - beg;
if (++i >= len) break;
c = (unsigned char)cstr[i];
+ j = i;
#define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \
memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \
(i += rb_strlen_lit(s) - 1, 1))
@@ -112,28 +113,40 @@ optimized_unescape_html(VALUE str)
else if (MATCH("mp;")) {
c = '&';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'q':
++i;
if (MATCH("uot;")) {
c = '"';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'g':
++i;
if (MATCH("t;")) {
c = '>';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'l':
++i;
if (MATCH("t;")) {
c = '<';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case '#':
if (len - ++i >= 2 && ISDIGIT(cstr[i])) {
@@ -142,9 +155,15 @@ optimized_unescape_html(VALUE str)
else if ((cstr[i] == 'x' || cstr[i] == 'X') && len - ++i >= 2 && ISXDIGIT(cstr[i])) {
cc = ruby_scan_digits(&cstr[i], len-i, 16, &clen, &overflow);
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
i += clen;
- if (overflow || cc >= charlimit || cstr[i] != ';') continue;
+ if (overflow || cc >= charlimit || cstr[i] != ';') {
+ i = j;
+ continue;
+ }
if (!dest) {
dest = rb_str_buf_new(len);
}
@@ -452,15 +471,17 @@ Init_escape(void)
void
InitVM_escape(void)
{
- rb_cCGI = rb_define_class("CGI", rb_cObject);
- rb_mEscape = rb_define_module_under(rb_cCGI, "Escape");
- rb_mUtil = rb_define_module_under(rb_cCGI, "Util");
- rb_define_method(rb_mEscape, "escapeHTML", cgiesc_escape_html, 1);
- rb_define_method(rb_mEscape, "unescapeHTML", cgiesc_unescape_html, 1);
- rb_define_method(rb_mEscape, "escapeURIComponent", cgiesc_escape_uri_component, 1);
- rb_define_method(rb_mEscape, "unescapeURIComponent", cgiesc_unescape_uri_component, -1);
- rb_define_method(rb_mEscape, "escape", cgiesc_escape, 1);
- rb_define_method(rb_mEscape, "unescape", cgiesc_unescape, -1);
- rb_prepend_module(rb_mUtil, rb_mEscape);
- rb_extend_object(rb_cCGI, rb_mEscape);
+ rb_cCGI = rb_define_class("CGI", rb_cObject);
+ rb_mEscapeExt = rb_define_module_under(rb_cCGI, "EscapeExt");
+ rb_mEscape = rb_define_module_under(rb_cCGI, "Escape");
+ rb_define_method(rb_mEscapeExt, "escapeHTML", cgiesc_escape_html, 1);
+ rb_define_method(rb_mEscapeExt, "unescapeHTML", cgiesc_unescape_html, 1);
+ rb_define_method(rb_mEscapeExt, "escapeURIComponent", cgiesc_escape_uri_component, 1);
+ rb_define_alias(rb_mEscapeExt, "escape_uri_component", "escapeURIComponent");
+ rb_define_method(rb_mEscapeExt, "unescapeURIComponent", cgiesc_unescape_uri_component, -1);
+ rb_define_alias(rb_mEscapeExt, "unescape_uri_component", "unescapeURIComponent");
+ rb_define_method(rb_mEscapeExt, "escape", cgiesc_escape, 1);
+ rb_define_method(rb_mEscapeExt, "unescape", cgiesc_unescape, -1);
+ rb_prepend_module(rb_mEscape, rb_mEscapeExt);
+ rb_extend_object(rb_cCGI, rb_mEscapeExt);
}
diff --git a/ext/cgi/escape/extconf.rb b/ext/cgi/escape/extconf.rb
index 16e8ff224d..73acd89ca8 100644
--- a/ext/cgi/escape/extconf.rb
+++ b/ext/cgi/escape/extconf.rb
@@ -1,3 +1,7 @@
require 'mkmf'
-create_makefile 'cgi/escape'
+if RUBY_ENGINE == 'truffleruby'
+ File.write("Makefile", dummy_makefile($srcdir).join(""))
+else
+ create_makefile 'cgi/escape'
+end
diff --git a/ext/continuation/depend b/ext/continuation/depend
index f0333d7fe6..b395d3d4d7 100644
--- a/ext/continuation/depend
+++ b/ext/continuation/depend
@@ -127,6 +127,7 @@ continuation.o: $(hdrdir)/ruby/internal/intern/re.h
continuation.o: $(hdrdir)/ruby/internal/intern/ruby.h
continuation.o: $(hdrdir)/ruby/internal/intern/select.h
continuation.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+continuation.o: $(hdrdir)/ruby/internal/intern/set.h
continuation.o: $(hdrdir)/ruby/internal/intern/signal.h
continuation.o: $(hdrdir)/ruby/internal/intern/sprintf.h
continuation.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -146,6 +147,7 @@ continuation.o: $(hdrdir)/ruby/internal/special_consts.h
continuation.o: $(hdrdir)/ruby/internal/static_assert.h
continuation.o: $(hdrdir)/ruby/internal/stdalign.h
continuation.o: $(hdrdir)/ruby/internal/stdbool.h
+continuation.o: $(hdrdir)/ruby/internal/stdckdint.h
continuation.o: $(hdrdir)/ruby/internal/symbol.h
continuation.o: $(hdrdir)/ruby/internal/value.h
continuation.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index a3381901ee..1b0280b460 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -52,17 +52,29 @@ rb_coverage_supported(VALUE self, VALUE _mode)
/*
* call-seq:
- * Coverage.setup => nil
- * Coverage.setup(:all) => nil
- * Coverage.setup(lines: bool, branches: bool, methods: bool, eval: bool) => nil
- * Coverage.setup(oneshot_lines: true) => nil
+ * Coverage.setup -> nil
+ * Coverage.setup(type) -> nil
+ * Coverage.setup(lines: false, branches: false, methods: false, eval: false, oneshot_lines: false) -> nil
*
- * Set up the coverage measurement.
+ * Performs setup for coverage measurement, but does not start coverage measurement.
+ * To start coverage measurement, use Coverage.resume.
*
- * Note that this method does not start the measurement itself.
- * Use Coverage.resume to start the measurement.
+ * To perform both setup and start coverage measurement, Coverage.start can be used.
*
- * You may want to use Coverage.start to setup and then start the measurement.
+ * With argument +type+ given and +type+ is symbol +:all+, enables all types of coverage
+ * (lines, branches, methods, and eval).
+ *
+ * Keyword arguments or hash +type+ can be given with each of the following keys:
+ *
+ * - +lines+: Enables line coverage that records the number of times each line was executed.
+ * If +lines+ is enabled, +oneshot_lines+ cannot be enabled.
+ * See {Lines Coverage}[rdoc-ref:Coverage@Lines+Coverage].
+ * - +branches+: Enables branch coverage that records the number of times each
+ * branch in each conditional was executed. See {Branches Coverage}[rdoc-ref:Coverage@Branches+Coverage].
+ * - +methods+: Enables method coverage that records the number of times each method was exectued.
+ * See {Methods Coverage}[rdoc-ref:Coverage@Methods+Coverage].
+ * - +eval+: Enables coverage for evaluations (e.g. Kernel#eval, Module#class_eval).
+ * See {Eval Coverage}[rdoc-ref:Coverage@Eval+Coverage].
*/
static VALUE
rb_coverage_setup(int argc, VALUE *argv, VALUE klass)
@@ -152,14 +164,14 @@ rb_coverage_resume(VALUE klass)
/*
* call-seq:
- * Coverage.start => nil
- * Coverage.start(:all) => nil
- * Coverage.start(lines: bool, branches: bool, methods: bool, eval: bool) => nil
- * Coverage.start(oneshot_lines: true) => nil
- *
- * Enables the coverage measurement.
- * See the documentation of Coverage class in detail.
- * This is equivalent to Coverage.setup and Coverage.resume.
+ * Coverage.start -> nil
+ * Coverage.start(type) -> nil
+ * Coverage.start(lines: false, branches: false, methods: false, eval: false, oneshot_lines: false) -> nil
+ *
+ * Enables coverage measurement.
+ * This method is equivalent to calling Coverage.setup with the arguments provided,
+ * and then calling Coverage.resume. See their respective documentation for more
+ * details.
*/
static VALUE
rb_coverage_start(int argc, VALUE *argv, VALUE klass)
@@ -243,8 +255,8 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
VALUE ncoverages = *(VALUE*)data, v;
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
- void *poisoned = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *poisoned = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
if (RB_TYPE_P(v, T_IMEMO) && imemo_type(v) == imemo_ment) {
const rb_method_entry_t *me = (rb_method_entry_t *) v;
@@ -287,7 +299,7 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
}
if (poisoned) {
- asan_poison_object(v);
+ rb_asan_poison_object(v);
}
}
return 0;
@@ -337,7 +349,7 @@ coverage_peek_result_i(st_data_t key, st_data_t val, st_data_t h)
* Coverage.peek_result => hash
*
* Returns a hash that contains filename as key and coverage array as value.
- * This is the same as `Coverage.result(stop: false, clear: false)`.
+ * This is the same as <tt>Coverage.result(stop: false, clear: false)</tt>.
*
* {
* "file.rb" => [1, 2, nil],
@@ -352,8 +364,8 @@ rb_coverage_peek_result(VALUE klass)
if (!RTEST(coverages)) {
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
}
- OBJ_WB_UNPROTECT(coverages);
- st_foreach(RHASH_TBL_RAW(coverages), coverage_peek_result_i, ncoverages);
+
+ rb_hash_foreach(coverages, coverage_peek_result_i, ncoverages);
if (current_mode & COVERAGE_TARGET_METHODS) {
rb_objspace_each_objects(method_coverage_i, &ncoverages);
@@ -467,151 +479,217 @@ rb_coverage_running(VALUE klass)
return current_state == RUNNING ? Qtrue : Qfalse;
}
-/* Coverage provides coverage measurement feature for Ruby.
- * This feature is experimental, so these APIs may be changed in future.
+/* \Coverage provides coverage measurement feature for Ruby.
*
- * Caveat: Currently, only process-global coverage measurement is supported.
- * You cannot measure per-thread coverage.
+ * Only process-global coverage measurement is supported, meaning
+ * that coverage cannot be measure on a per-thread basis.
*
- * = Usage
+ * = Quick Start
*
- * 1. require "coverage"
- * 2. do Coverage.start
- * 3. require or load Ruby source file
- * 4. Coverage.result will return a hash that contains filename as key and
- * coverage array as value. A coverage array gives, for each line, the
- * number of line execution by the interpreter. A +nil+ value means
- * coverage is disabled for this line (lines like +else+ and +end+).
+ * 1. Load coverage using <tt>require "coverage"</tt>.
+ * 2. Call Coverage.start to set up and begin coverage measurement.
+ * 3. All Ruby code loaded following the call to Coverage.start will have
+ * coverage measurement.
+ * 4. Coverage results can be fetched by calling Coverage.result, which returns a
+ * hash that contains filenames as the keys and coverage arrays as the values.
+ * Each element of the coverage array gives the number of times each line was
+ * executed. A +nil+ value means coverage was disabled for that line (e.g.
+ * lines like +else+ and +end+).
*
* = Examples
*
- * [foo.rb]
- * s = 0
- * 10.times do |x|
- * s += x
- * end
+ * In file +fib.rb+:
*
- * if s == 45
- * p :ok
- * else
- * p :ng
+ * def fibonacci(n)
+ * if n == 0
+ * 0
+ * elsif n == 1
+ * 1
+ * else
+ * fibonacci(n - 1) + fibonacci(n - 2)
+ * end
* end
- * [EOF]
+ *
+ * puts fibonacci(10)
+ *
+ * In another file, coverage can be measured:
*
* require "coverage"
* Coverage.start
- * require "foo.rb"
- * p Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
+ * require "fib.rb"
+ * Coverage.result # => {"fib.rb" => [1, 177, 34, 143, 55, nil, 88, nil, nil, nil, 1]}
*
- * == Lines Coverage
+ * == Lines \Coverage
*
- * If a coverage mode is not explicitly specified when starting coverage, lines
- * coverage is what will run. It reports the number of line executions for each
- * line.
+ * Lines coverage reports the number of line executions for each line.
+ * If the coverage mode is not explicitly specified when starting coverage,
+ * lines coverage is used as the default.
*
* require "coverage"
* Coverage.start(lines: true)
- * require "foo.rb"
- * p Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}}
+ * require "fib"
+ * Coverage.result # => {"fib.rb" => {lines: [1, 177, 34, 143, 55, nil, 88, nil, nil, nil, 1]}}
+ *
+ * The returned hash differs depending on how Coverage.setup or Coverage.start
+ * was executed.
*
- * The value of the lines coverage result is an array containing how many times
- * each line was executed. Order in this array is important. For example, the
- * first item in this array, at index 0, reports how many times line 1 of this
- * file was executed while coverage was run (which, in this example, is one
- * time).
+ * If Coverage.start or Coverage.setup was called with no arguments, it returns a
+ * hash which contains filenames as the keys and coverage arrays as the values.
*
- * A +nil+ value means coverage is disabled for this line (lines like +else+
- * and +end+).
+ * If Coverage.start or Coverage.setup was called with <tt>line: true</tt>, it
+ * returns a hash which contains filenames as the keys and hashes as the values.
+ * The value hash has a key +:lines+ where the value is a coverage array.
*
- * == Oneshot Lines Coverage
+ * Each element of the coverage array gives the number of times the line was
+ * executed. A +nil+ value in the coverage array means coverage was disabled
+ * for that line (e.g. lines like +else+ and +end+).
*
- * Oneshot lines coverage tracks and reports on the executed lines while
- * coverage is running. It will not report how many times a line was executed,
- * only that it was executed.
+ * == Oneshot Lines \Coverage
+ *
+ * Oneshot lines coverage is similar to lines coverage, but instead of reporting
+ * the number of times a line was executed, it only reports the lines that were
+ * executed.
*
* require "coverage"
* Coverage.start(oneshot_lines: true)
- * require "foo.rb"
- * p Coverage.result #=> {"foo.rb"=>{:oneshot_lines=>[1, 2, 3, 6, 7]}}
+ * require "fib"
+ * Coverage.result # => {"fib.rb" => {oneshot_lines: [1, 11, 2, 4, 7, 5, 3]}}
*
* The value of the oneshot lines coverage result is an array containing the
* line numbers that were executed.
*
- * == Branches Coverage
+ * == Branches \Coverage
*
- * Branches coverage reports how many times each branch within each conditional
+ * Branches coverage reports the number of times each branch within each conditional
* was executed.
*
* require "coverage"
* Coverage.start(branches: true)
- * require "foo.rb"
- * p Coverage.result #=> {"foo.rb"=>{:branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}}}
+ * require "fib"
+ * Coverage.result
+ * # => {"fib.rb" => {
+ * # branches: {
+ * # [:if, 0, 2, 2, 8, 5] => {
+ * # [:then, 1, 3, 4, 3, 5] => 34,
+ * # [:else, 2, 4, 2, 8, 5] => 143},
+ * # [:if, 3, 4, 2, 8, 5] => {
+ * # [:then, 4, 5, 4, 5, 5] => 55,
+ * # [:else, 5, 7, 4, 7, 39] => 88}}}}
*
* Each entry within the branches hash is a conditional, the value of which is
- * another hash where each entry is a branch in that conditional. The values
- * are the number of times the method was executed, and the keys are identifying
- * information about the branch.
+ * another hash where each entry is a branch in that conditional. The keys are
+ * arrays containing information about the branch and the values are the number
+ * of times the branch was executed.
*
- * The information that makes up each key identifying branches or conditionals
- * is the following, from left to right:
+ * The information that makes up the array that are the keys for conditional or
+ * branches are the following, from left to right:
*
- * 1. A label for the type of branch or conditional.
+ * 1. A label for the type of branch or conditional (e.g. +:if+, +:then+, +:else+).
* 2. A unique identifier.
- * 3. The starting line number it appears on in the file.
- * 4. The starting column number it appears on in the file.
- * 5. The ending line number it appears on in the file.
- * 6. The ending column number it appears on in the file.
+ * 3. Starting line number.
+ * 4. Starting column number.
+ * 5. Ending line number.
+ * 6. Ending column number.
*
- * == Methods Coverage
+ * == Methods \Coverage
*
* Methods coverage reports how many times each method was executed.
*
- * [foo_method.rb]
- * class Greeter
- * def greet
- * "welcome!"
- * end
- * end
- *
- * def hello
- * "Hi"
- * end
- *
- * hello()
- * Greeter.new.greet()
- * [EOF]
- *
* require "coverage"
* Coverage.start(methods: true)
- * require "foo_method.rb"
- * p Coverage.result #=> {"foo_method.rb"=>{:methods=>{[Object, :hello, 7, 0, 9, 3]=>1, [Greeter, :greet, 2, 2, 4, 5]=>1}}}
+ * require "fib"
+ * p Coverage.result #=> {"fib.rb" => {methods: {[Object, :fibonacci, 1, 0, 9, 3] => 177}}}
*
- * Each entry within the methods hash represents a method. The values in this
- * hash are the number of times the method was executed, and the keys are
+ * Each entry within the methods hash represents a method. The keys are arrays
+ * containing hash are the number of times the method was executed, and the keys are
* identifying information about the method.
*
* The information that makes up each key identifying a method is the following,
* from left to right:
*
- * 1. The class.
- * 2. The method name.
- * 3. The starting line number the method appears on in the file.
- * 4. The starting column number the method appears on in the file.
- * 5. The ending line number the method appears on in the file.
- * 6. The ending column number the method appears on in the file.
+ * 1. Class that the method was defined in.
+ * 2. Method name as a Symbol.
+ * 3. Starting line number of the method.
+ * 4. Starting column number of the method.
+ * 5. Ending line number of the method.
+ * 6. Ending column number of the method.
*
- * == All Coverage Modes
+ * == Eval \Coverage
*
- * You can also run all modes of coverage simultaneously with this shortcut.
- * Note that running all coverage modes does not run both lines and oneshot
- * lines. Those modes cannot be run simultaneously. Lines coverage is run in
- * this case, because you can still use it to determine whether or not a line
- * was executed.
+ * Eval coverage can be combined with the coverage types above to track
+ * coverage for eval.
+ *
+ * require "coverage"
+ * Coverage.start(eval: true, lines: true)
+ *
+ * eval(<<~RUBY, nil, "eval 1")
+ * ary = []
+ * 10.times do |i|
+ * ary << "hello" * i
+ * end
+ * RUBY
+ *
+ * Coverage.result # => {"eval 1" => {lines: [1, 1, 10, nil]}}
+ *
+ * Note that the eval must have a filename assigned, otherwise coverage
+ * will not be measured.
+ *
+ * require "coverage"
+ * Coverage.start(eval: true, lines: true)
+ *
+ * eval(<<~RUBY)
+ * ary = []
+ * 10.times do |i|
+ * ary << "hello" * i
+ * end
+ * RUBY
+ *
+ * Coverage.result # => {"(eval)" => {lines: [nil, nil, nil, nil]}}
+ *
+ * Also note that if a line number is assigned to the eval and it is not 1,
+ * then the resulting coverage will be padded with +nil+ if the line number is
+ * greater than 1, and truncated if the line number is less than 1.
+ *
+ * require "coverage"
+ * Coverage.start(eval: true, lines: true)
+ *
+ * eval(<<~RUBY, nil, "eval 1", 3)
+ * ary = []
+ * 10.times do |i|
+ * ary << "hello" * i
+ * end
+ * RUBY
+ *
+ * eval(<<~RUBY, nil, "eval 2", -1)
+ * ary = []
+ * 10.times do |i|
+ * ary << "hello" * i
+ * end
+ * RUBY
+ *
+ * Coverage.result
+ * # => {"eval 1" => {lines: [nil, nil, 1, 1, 10, nil]}, "eval 2" => {lines: [10, nil]}}
+ *
+ * == All \Coverage Modes
+ *
+ * All modes of coverage can be enabled simultaneously using the Symbol +:all+.
+ * However, note that this mode runs lines coverage and not oneshot lines since
+ * they cannot be ran simultaneously.
*
* require "coverage"
* Coverage.start(:all)
- * require "foo.rb"
- * p Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil], :branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}, :methods=>{}}}
+ * require "fib"
+ * Coverage.result
+ * # => {"fib.rb" => {
+ * # lines: [1, 177, 34, 143, 55, nil, 88, nil, nil, nil, 1],
+ * # branches: {
+ * # [:if, 0, 2, 2, 8, 5] => {
+ * # [:then, 1, 3, 4, 3, 5] => 34,
+ * # [:else, 2, 4, 2, 8, 5] => 143},
+ * # [:if, 3, 4, 2, 8, 5] => {
+ * # [:then, 4, 5, 4, 5, 5] => 55,
+ * # [:else, 5, 7, 4, 7, 39] => 88}}}},
+ * # methods: {[Object, :fibonacci, 1, 0, 9, 3] => 177}}}
*/
void
Init_coverage(void)
diff --git a/ext/coverage/depend b/ext/coverage/depend
index cd7ef43a43..fb7f9a95af 100644
--- a/ext/coverage/depend
+++ b/ext/coverage/depend
@@ -15,6 +15,7 @@ coverage.o: $(hdrdir)/ruby/backward/2/long_long.h
coverage.o: $(hdrdir)/ruby/backward/2/stdalign.h
coverage.o: $(hdrdir)/ruby/backward/2/stdarg.h
coverage.o: $(hdrdir)/ruby/defines.h
+coverage.o: $(hdrdir)/ruby/encoding.h
coverage.o: $(hdrdir)/ruby/intern.h
coverage.o: $(hdrdir)/ruby/internal/abi.h
coverage.o: $(hdrdir)/ruby/internal/anyargs.h
@@ -87,6 +88,15 @@ coverage.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
coverage.o: $(hdrdir)/ruby/internal/ctype.h
coverage.o: $(hdrdir)/ruby/internal/dllexport.h
coverage.o: $(hdrdir)/ruby/internal/dosish.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/re.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/string.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/transcode.h
coverage.o: $(hdrdir)/ruby/internal/error.h
coverage.o: $(hdrdir)/ruby/internal/eval.h
coverage.o: $(hdrdir)/ruby/internal/event.h
@@ -130,6 +140,7 @@ coverage.o: $(hdrdir)/ruby/internal/intern/re.h
coverage.o: $(hdrdir)/ruby/internal/intern/ruby.h
coverage.o: $(hdrdir)/ruby/internal/intern/select.h
coverage.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+coverage.o: $(hdrdir)/ruby/internal/intern/set.h
coverage.o: $(hdrdir)/ruby/internal/intern/signal.h
coverage.o: $(hdrdir)/ruby/internal/intern/sprintf.h
coverage.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -149,6 +160,7 @@ coverage.o: $(hdrdir)/ruby/internal/special_consts.h
coverage.o: $(hdrdir)/ruby/internal/static_assert.h
coverage.o: $(hdrdir)/ruby/internal/stdalign.h
coverage.o: $(hdrdir)/ruby/internal/stdbool.h
+coverage.o: $(hdrdir)/ruby/internal/stdckdint.h
coverage.o: $(hdrdir)/ruby/internal/symbol.h
coverage.o: $(hdrdir)/ruby/internal/value.h
coverage.o: $(hdrdir)/ruby/internal/value_type.h
@@ -156,6 +168,8 @@ coverage.o: $(hdrdir)/ruby/internal/variable.h
coverage.o: $(hdrdir)/ruby/internal/warning_push.h
coverage.o: $(hdrdir)/ruby/internal/xmalloc.h
coverage.o: $(hdrdir)/ruby/missing.h
+coverage.o: $(hdrdir)/ruby/onigmo.h
+coverage.o: $(hdrdir)/ruby/oniguruma.h
coverage.o: $(hdrdir)/ruby/ruby.h
coverage.o: $(hdrdir)/ruby/st.h
coverage.o: $(hdrdir)/ruby/subst.h
@@ -169,12 +183,14 @@ coverage.o: $(top_srcdir)/id_table.h
coverage.o: $(top_srcdir)/internal.h
coverage.o: $(top_srcdir)/internal/array.h
coverage.o: $(top_srcdir)/internal/basic_operators.h
+coverage.o: $(top_srcdir)/internal/box.h
coverage.o: $(top_srcdir)/internal/compilers.h
coverage.o: $(top_srcdir)/internal/gc.h
coverage.o: $(top_srcdir)/internal/hash.h
coverage.o: $(top_srcdir)/internal/imemo.h
coverage.o: $(top_srcdir)/internal/sanitizers.h
coverage.o: $(top_srcdir)/internal/serial.h
+coverage.o: $(top_srcdir)/internal/set_table.h
coverage.o: $(top_srcdir)/internal/static_assert.h
coverage.o: $(top_srcdir)/internal/thread.h
coverage.o: $(top_srcdir)/internal/variable.h
@@ -184,6 +200,7 @@ coverage.o: $(top_srcdir)/method.h
coverage.o: $(top_srcdir)/node.h
coverage.o: $(top_srcdir)/ruby_assert.h
coverage.o: $(top_srcdir)/ruby_atomic.h
+coverage.o: $(top_srcdir)/rubyparser.h
coverage.o: $(top_srcdir)/shape.h
coverage.o: $(top_srcdir)/thread_pthread.h
coverage.o: $(top_srcdir)/vm_core.h
diff --git a/ext/coverage/lib/coverage.rb b/ext/coverage/lib/coverage.rb
index f1923ef366..4bd20e22cb 100644
--- a/ext/coverage/lib/coverage.rb
+++ b/ext/coverage/lib/coverage.rb
@@ -1,6 +1,11 @@
require "coverage.so"
module Coverage
+ # call-seq:
+ # line_stub(file) -> array
+ #
+ # A simple helper function that creates the "stub" of line coverage
+ # from a given source code.
def self.line_stub(file)
lines = File.foreach(file).map { nil }
iseqs = [RubyVM::InstructionSequence.compile_file(file)]
diff --git a/ext/date/date.gemspec b/ext/date/date.gemspec
index 660353ebc5..cb439bd0a5 100644
--- a/ext/date/date.gemspec
+++ b/ext/date/date.gemspec
@@ -7,8 +7,8 @@ end
Gem::Specification.new do |s|
s.name = "date"
s.version = version
- s.summary = "A subclass of Object includes Comparable module for handling dates."
- s.description = "A subclass of Object includes Comparable module for handling dates."
+ s.summary = "The official date library for Ruby."
+ s.description = "The official date library for Ruby."
if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
s.platform = 'java'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.require_path = %w{lib}
s.files = [
- "README.md",
+ "README.md", "COPYING", "BSDL",
"lib/date.rb", "ext/date/date_core.c", "ext/date/date_parse.c", "ext/date/date_strftime.c",
"ext/date/date_strptime.c", "ext/date/date_tmx.h", "ext/date/extconf.rb", "ext/date/prereq.mk",
"ext/date/zonetab.h", "ext/date/zonetab.list"
@@ -31,4 +31,6 @@ Gem::Specification.new do |s|
s.email = [nil]
s.homepage = "https://github.com/ruby/date"
s.licenses = ["Ruby", "BSD-2-Clause"]
+
+ s.metadata["changelog_uri"] = s.homepage + "/releases"
end
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index f2baf4fcea..72d697c8ea 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -27,7 +27,7 @@ static VALUE eDateError;
static VALUE half_days_in_day, day_in_nanoseconds;
static double positive_inf, negative_inf;
-// used by deconstruct_keys
+/* used by deconstruct_keys */
static VALUE sym_year, sym_month, sym_day, sym_yday, sym_wday;
static VALUE sym_hour, sym_min, sym_sec, sym_sec_fraction, sym_zone;
@@ -57,7 +57,7 @@ static VALUE sym_hour, sym_min, sym_sec, sym_sec_fraction, sym_zone;
#define f_add3(x,y,z) f_add(f_add(x, y), z)
#define f_sub3(x,y,z) f_sub(f_sub(x, y), z)
-#define f_frozen_ary(...) rb_obj_freeze(rb_ary_new3(__VA_ARGS__))
+#define f_frozen_ary(...) rb_ary_freeze(rb_ary_new3(__VA_ARGS__))
static VALUE date_initialize(int argc, VALUE *argv, VALUE self);
static VALUE datetime_initialize(int argc, VALUE *argv, VALUE self);
@@ -248,6 +248,11 @@ f_negative_p(VALUE x)
#define date_sg_t double
#endif
+#define JULIAN_EPOCH_DATE "-4712-01-01"
+#define JULIAN_EPOCH_DATETIME JULIAN_EPOCH_DATE "T00:00:00+00:00"
+#define JULIAN_EPOCH_DATETIME_RFC3339 "Mon, 1 Jan -4712 00:00:00 +0000"
+#define JULIAN_EPOCH_DATETIME_HTTPDATE "Mon, 01 Jan -4712 00:00:00 GMT"
+
/* A set of nth, jd, df and sf denote ajd + 1/2. Each ajd begin at
* noon of GMT (assume equal to UTC). However, this begins at
* midnight.
@@ -447,11 +452,43 @@ do {\
static int c_valid_civil_p(int, int, int, double,
int *, int *, int *, int *);
+/* Check if using pure Gregorian calendar (sg == -Infinity) */
+#define c_gregorian_only_p(sg) (isinf(sg) && (sg) < 0)
+
+/*
+ * Fast path macros for pure Gregorian calendar.
+ * Sets *rjd to the JD value, *ns to 1 (new style), and returns.
+ */
+#define GREGORIAN_JD_FAST_PATH_RET(sg, jd_expr, rjd, ns) \
+ if (c_gregorian_only_p(sg)) { \
+ *(rjd) = (jd_expr); \
+ *(ns) = 1; \
+ return 1; \
+ }
+
+#define GREGORIAN_JD_FAST_PATH(sg, jd_expr, rjd, ns) \
+ if (c_gregorian_only_p(sg)) { \
+ *(rjd) = (jd_expr); \
+ *(ns) = 1; \
+ return; \
+ }
+
+/* Forward declarations for Neri-Schneider optimized functions */
+static int c_gregorian_civil_to_jd(int y, int m, int d);
+static void c_gregorian_jd_to_civil(int jd, int *ry, int *rm, int *rd);
+static int c_gregorian_fdoy(int y);
+static int c_gregorian_ldoy(int y);
+static int c_gregorian_ldom_jd(int y, int m);
+static int ns_jd_in_range(int jd);
+
static int
c_find_fdoy(int y, double sg, int *rjd, int *ns)
{
int d, rm, rd;
+ GREGORIAN_JD_FAST_PATH_RET(sg, c_gregorian_fdoy(y), rjd, ns);
+
+ /* Keep existing loop for Julian/reform period */
for (d = 1; d < 31; d++)
if (c_valid_civil_p(y, 1, d, sg, &rm, &rd, rjd, ns))
return 1;
@@ -463,6 +500,9 @@ c_find_ldoy(int y, double sg, int *rjd, int *ns)
{
int i, rm, rd;
+ GREGORIAN_JD_FAST_PATH_RET(sg, c_gregorian_ldoy(y), rjd, ns);
+
+ /* Keep existing loop for Julian/reform period */
for (i = 0; i < 30; i++)
if (c_valid_civil_p(y, 12, 31 - i, sg, &rm, &rd, rjd, ns))
return 1;
@@ -488,6 +528,9 @@ c_find_ldom(int y, int m, double sg, int *rjd, int *ns)
{
int i, rm, rd;
+ GREGORIAN_JD_FAST_PATH_RET(sg, c_gregorian_ldom_jd(y, m), rjd, ns);
+
+ /* Keep existing loop for Julian/reform period */
for (i = 0; i < 30; i++)
if (c_valid_civil_p(y, m, 31 - i, sg, &rm, &rd, rjd, ns))
return 1;
@@ -497,55 +540,69 @@ c_find_ldom(int y, int m, double sg, int *rjd, int *ns)
static void
c_civil_to_jd(int y, int m, int d, double sg, int *rjd, int *ns)
{
- double a, b, jd;
+ int jd;
+
+ GREGORIAN_JD_FAST_PATH(sg, c_gregorian_civil_to_jd(y, m, d), rjd, ns);
+
+ /* Calculate Gregorian JD using optimized algorithm */
+ jd = c_gregorian_civil_to_jd(y, m, d);
- if (m <= 2) {
- y -= 1;
- m += 12;
- }
- a = floor(y / 100.0);
- b = 2 - a + floor(a / 4.0);
- jd = floor(365.25 * (y + 4716)) +
- floor(30.6001 * (m + 1)) +
- d + b - 1524;
if (jd < sg) {
- jd -= b;
+ /* Before Gregorian switchover - use Julian calendar */
+ int y2 = y, m2 = m;
+ if (m2 <= 2) {
+ y2 -= 1;
+ m2 += 12;
+ }
+ jd = (int)(floor(365.25 * (y2 + 4716)) +
+ floor(30.6001 * (m2 + 1)) +
+ d - 1524);
*ns = 0;
}
- else
+ else {
*ns = 1;
+ }
- *rjd = (int)jd;
+ *rjd = jd;
}
static void
c_jd_to_civil(int jd, double sg, int *ry, int *rm, int *rdom)
{
- double x, a, b, c, d, e, y, m, dom;
-
- if (jd < sg)
- a = jd;
- else {
- x = floor((jd - 1867216.25) / 36524.25);
- a = jd + 1 + x - floor(x / 4.0);
- }
- b = a + 1524;
- c = floor((b - 122.1) / 365.25);
- d = floor(365.25 * c);
- e = floor((b - d) / 30.6001);
- dom = b - d - floor(30.6001 * e);
- if (e <= 13) {
- m = e - 1;
- y = c - 4716;
- }
- else {
- m = e - 13;
- y = c - 4715;
+ /* Fast path: pure Gregorian or date after switchover, within safe range */
+ if ((c_gregorian_only_p(sg) || jd >= sg) && ns_jd_in_range(jd)) {
+ c_gregorian_jd_to_civil(jd, ry, rm, rdom);
+ return;
}
- *ry = (int)y;
- *rm = (int)m;
- *rdom = (int)dom;
+ /* Original algorithm for Julian calendar or extreme dates */
+ {
+ double x, a, b, c, d, e, y, m, dom;
+
+ if (jd < sg)
+ a = jd;
+ else {
+ x = floor((jd - 1867216.25) / 36524.25);
+ a = jd + 1 + x - floor(x / 4.0);
+ }
+ b = a + 1524;
+ c = floor((b - 122.1) / 365.25);
+ d = floor(365.25 * c);
+ e = floor((b - d) / 30.6001);
+ dom = b - d - floor(30.6001 * e);
+ if (e <= 13) {
+ m = e - 1;
+ y = c - 4716;
+ }
+ else {
+ m = e - 13;
+ y = c - 4715;
+ }
+
+ *ry = (int)y;
+ *rm = (int)m;
+ *rdom = (int)dom;
+ }
}
static void
@@ -720,6 +777,147 @@ c_gregorian_last_day_of_month(int y, int m)
return monthtab[c_gregorian_leap_p(y) ? 1 : 0][m];
}
+/*
+ * Neri-Schneider algorithm for optimized Gregorian date conversion.
+ * Reference: Neri & Schneider, "Euclidean Affine Functions and Applications
+ * to Calendar Algorithms", Software: Practice and Experience, 2023.
+ * https://arxiv.org/abs/2102.06959
+ *
+ * This algorithm provides ~2-3x speedup over traditional floating-point
+ * implementations by using pure integer arithmetic with multiplication
+ * and bit-shifts instead of expensive division operations.
+ */
+
+/* JDN of March 1, Year 0 in proleptic Gregorian calendar */
+#define NS_EPOCH 1721120
+
+/* Days in a 4-year cycle (3 normal years + 1 leap year) */
+#define NS_DAYS_IN_4_YEARS 1461
+
+/* Days in a 400-year Gregorian cycle (97 leap years in 400 years) */
+#define NS_DAYS_IN_400_YEARS 146097
+
+/* Years per century */
+#define NS_YEARS_PER_CENTURY 100
+
+/*
+ * Multiplier for extracting year within century using fixed-point arithmetic.
+ * This is ceil(2^32 / NS_DAYS_IN_4_YEARS) for the Euclidean affine function.
+ */
+#define NS_YEAR_MULTIPLIER 2939745
+
+/*
+ * Coefficients for month calculation from day-of-year.
+ * Maps day-of-year to month using: month = (NS_MONTH_COEFF * doy + NS_MONTH_OFFSET) >> 16
+ */
+#define NS_MONTH_COEFF 2141
+#define NS_MONTH_OFFSET 197913
+
+/*
+ * Coefficients for civil date to JDN month contribution.
+ * Maps month to accumulated days: days = (NS_CIVIL_MONTH_COEFF * m - NS_CIVIL_MONTH_OFFSET) / 32
+ */
+#define NS_CIVIL_MONTH_COEFF 979
+#define NS_CIVIL_MONTH_OFFSET 2919
+#define NS_CIVIL_MONTH_DIVISOR 32
+
+/* Days from March 1 to December 31 (for Jan/Feb year adjustment) */
+#define NS_DAYS_BEFORE_NEW_YEAR 306
+
+/*
+ * Safe bounds for Neri-Schneider algorithm to avoid integer overflow.
+ * These correspond to approximately years -1,000,000 to +1,000,000.
+ */
+#define NS_JD_MIN -364000000
+#define NS_JD_MAX 538000000
+
+inline static int
+ns_jd_in_range(int jd)
+{
+ return jd >= NS_JD_MIN && jd <= NS_JD_MAX;
+}
+
+/* Optimized: Gregorian date -> Julian Day Number */
+static int
+c_gregorian_civil_to_jd(int y, int m, int d)
+{
+ /* Shift epoch to March 1 of year 0 (Jan/Feb belong to previous year) */
+ int j = (m < 3) ? 1 : 0;
+ int y0 = y - j;
+ int m0 = j ? m + 12 : m;
+ int d0 = d - 1;
+
+ /* Calculate year contribution with leap year correction */
+ int q1 = DIV(y0, NS_YEARS_PER_CENTURY);
+ int yc = DIV(NS_DAYS_IN_4_YEARS * y0, 4) - q1 + DIV(q1, 4);
+
+ /* Calculate month contribution using integer arithmetic */
+ int mc = (NS_CIVIL_MONTH_COEFF * m0 - NS_CIVIL_MONTH_OFFSET) / NS_CIVIL_MONTH_DIVISOR;
+
+ /* Combine and add epoch offset to get JDN */
+ return yc + mc + d0 + NS_EPOCH;
+}
+
+/* Optimized: Julian Day Number -> Gregorian date */
+static void
+c_gregorian_jd_to_civil(int jd, int *ry, int *rm, int *rd)
+{
+ int r0, n1, q1, r1, n2, q2, r2, n3, q3, r3, y0, j;
+ uint64_t u2;
+
+ /* Convert JDN to rata die (March 1, Year 0 epoch) */
+ r0 = jd - NS_EPOCH;
+
+ /* Extract century and day within 400-year cycle */
+ /* Use Euclidean (floor) division for negative values */
+ n1 = 4 * r0 + 3;
+ q1 = DIV(n1, NS_DAYS_IN_400_YEARS);
+ r1 = MOD(n1, NS_DAYS_IN_400_YEARS) / 4;
+
+ /* Calculate year within century and day of year */
+ n2 = 4 * r1 + 3;
+ /* Use 64-bit arithmetic to avoid overflow */
+ u2 = (uint64_t)NS_YEAR_MULTIPLIER * (uint64_t)n2;
+ q2 = (int)(u2 >> 32);
+ r2 = (int)((uint32_t)u2 / NS_YEAR_MULTIPLIER / 4);
+
+ /* Calculate month and day using integer arithmetic */
+ n3 = NS_MONTH_COEFF * r2 + NS_MONTH_OFFSET;
+ q3 = n3 >> 16;
+ r3 = (n3 & 0xFFFF) / NS_MONTH_COEFF;
+
+ /* Combine century and year */
+ y0 = NS_YEARS_PER_CENTURY * q1 + q2;
+
+ /* Adjust for January/February (shift from fiscal year) */
+ j = (r2 >= NS_DAYS_BEFORE_NEW_YEAR) ? 1 : 0;
+
+ *ry = y0 + j;
+ *rm = j ? q3 - 12 : q3;
+ *rd = r3 + 1;
+}
+
+/* O(1) first day of year for Gregorian calendar */
+inline static int
+c_gregorian_fdoy(int y)
+{
+ return c_gregorian_civil_to_jd(y, 1, 1);
+}
+
+/* O(1) last day of year for Gregorian calendar */
+inline static int
+c_gregorian_ldoy(int y)
+{
+ return c_gregorian_civil_to_jd(y, 12, 31);
+}
+
+/* O(1) last day of month (JDN) for Gregorian calendar */
+inline static int
+c_gregorian_ldom_jd(int y, int m)
+{
+ return c_gregorian_civil_to_jd(y, m, c_gregorian_last_day_of_month(y, m));
+}
+
static int
c_valid_julian_p(int y, int m, int d, int *rm, int *rd)
{
@@ -1594,7 +1792,7 @@ m_ajd(union DateData *x)
if (simple_dat_p(x)) {
r = m_real_jd(x);
- if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2)) {
+ if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2) && FIX2LONG(r) >= (FIXNUM_MIN + 1) / 2) {
long ir = FIX2LONG(r);
ir = ir * 2 - 1;
return rb_rational_new2(LONG2FIX(ir), INT2FIX(2));
@@ -2493,7 +2691,7 @@ date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
*
* Date.valid_jd?(2451944) # => true
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd.
*/
@@ -2587,7 +2785,7 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_date?(2001, 2, 29) # => false
* Date.valid_date?(2001, 2, -1) # => true
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd, Date.new.
*/
@@ -2675,7 +2873,7 @@ date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_ordinal?(2001, 34) # => true
* Date.valid_ordinal?(2001, 366) # => false
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd, Date.ordinal.
*/
@@ -2765,7 +2963,7 @@ date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
*
* See Date.commercial.
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd, Date.commercial.
*/
@@ -3345,7 +3543,7 @@ static VALUE d_lite_plus(VALUE, VALUE);
*
* Date.jd(Date::ITALY - 1).julian? # => true
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.new.
*/
@@ -3410,7 +3608,7 @@ date_s_jd(int argc, VALUE *argv, VALUE klass)
*
* Raises an exception if +yday+ is zero or out of range.
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd, Date.new.
*/
@@ -3487,7 +3685,7 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
* where +n+ is the number of days in the month;
* when the argument is negative, counts backward from the end of the month.
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd.
*/
@@ -3593,7 +3791,7 @@ date_initialize(int argc, VALUE *argv, VALUE self)
* Date.commercial(2020, 1, 1).to_s # => "2019-12-30"
Date.commercial(2020, 1, 7).to_s # => "2020-01-05"
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* Related: Date.jd, Date.new, Date.ordinal.
*/
@@ -3778,7 +3976,7 @@ static void set_sg(union DateData *, double);
*
* Date.today.to_s # => "2022-07-06"
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
*/
static VALUE
@@ -3873,7 +4071,6 @@ static VALUE
rt_complete_frags(VALUE klass, VALUE hash)
{
static VALUE tab = Qnil;
- int g;
long e;
VALUE k, a, d;
@@ -3970,9 +4167,13 @@ rt_complete_frags(VALUE klass, VALUE hash)
rb_gc_register_mark_object(tab);
}
+ k = a = Qnil;
+
{
- long i, eno = 0, idx = 0;
+ long i, eno = 0;
+ VALUE t = Qnil;
+ e = 0;
for (i = 0; i < RARRAY_LEN(tab); i++) {
VALUE x, a;
@@ -3987,23 +4188,20 @@ rt_complete_frags(VALUE klass, VALUE hash)
n++;
if (n > eno) {
eno = n;
- idx = i;
+ t = x;
}
}
}
- if (eno == 0)
- g = 0;
- else {
- g = 1;
- k = RARRAY_AREF(RARRAY_AREF(tab, idx), 0);
- a = RARRAY_AREF(RARRAY_AREF(tab, idx), 1);
- e = eno;
+ if (eno > 0) {
+ k = RARRAY_AREF(t, 0);
+ a = RARRAY_AREF(t, 1);
}
+ e = eno;
}
d = Qnil;
- if (g && !NIL_P(k) && (RARRAY_LEN(a) - e)) {
+ if (!NIL_P(k) && (RARRAY_LEN(a) > e)) {
if (k == sym("ordinal")) {
if (NIL_P(ref_hash("year"))) {
if (NIL_P(d))
@@ -4090,7 +4288,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
}
}
- if (g && k == sym("time")) {
+ if (k == sym("time")) {
if (f_le_p(klass, cDateTime)) {
if (NIL_P(d))
d = date_s_today(0, (VALUE *)0, cDate);
@@ -4330,6 +4528,7 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
rb_scan_args(argc, argv, "11", &vstr, &vfmt);
StringValue(vstr);
+ if (argc > 1) StringValue(vfmt);
if (!rb_enc_str_asciicompat_p(vstr))
rb_raise(rb_eArgError,
"string should have ASCII compatible encoding");
@@ -4340,7 +4539,6 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
flen = strlen(default_fmt);
}
else {
- StringValue(vfmt);
if (!rb_enc_str_asciicompat_p(vfmt))
rb_raise(rb_eArgError,
"format should have ASCII compatible encoding");
@@ -4378,7 +4576,7 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
* Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}
*
* For other formats, see
- * {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc].
+ * {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc].
* (Unlike Date.strftime, does not support flags and width.)
*
* See also {strptime(3)}[https://man7.org/linux/man-pages/man3/strptime.3.html].
@@ -4407,10 +4605,10 @@ date_s__strptime(int argc, VALUE *argv, VALUE klass)
* Date.strptime('sat3feb01', '%a%d%b%y') # => #<Date: 2001-02-03>
*
* For other formats, see
- * {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc].
+ * {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc].
* (Unlike Date.strftime, does not support flags and width.)
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
* See also {strptime(3)}[https://man7.org/linux/man-pages/man3/strptime.3.html].
*
@@ -4425,7 +4623,7 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01");
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
case 1:
fmt = rb_str_new2("%F");
case 2:
@@ -4459,17 +4657,10 @@ get_limit(VALUE opt)
#define rb_category_warn(category, fmt) rb_warn(fmt)
#endif
-static void
+static VALUE
check_limit(VALUE str, VALUE opt)
{
size_t slen, limit;
- if (NIL_P(str)) return;
- if (SYMBOL_P(str)) {
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
- "The ability to parse Symbol is an unintentional bug and is deprecated");
- str = rb_sym2str(str);
- }
-
StringValue(str);
slen = RSTRING_LEN(str);
limit = get_limit(opt);
@@ -4477,6 +4668,7 @@ check_limit(VALUE str, VALUE opt)
rb_raise(rb_eArgError,
"string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
}
+ return str;
}
static VALUE
@@ -4484,10 +4676,8 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
{
VALUE vstr, vcomp, hash, opt;
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
- if (!NIL_P(opt)) argc--;
- check_limit(vstr, opt);
- StringValue(vstr);
+ argc = rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
+ vstr = check_limit(vstr, opt);
if (!rb_enc_str_asciicompat_p(vstr))
rb_raise(rb_eArgError,
"string should have ASCII compatible encoding");
@@ -4507,7 +4697,7 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
* This method recognizes many forms in +string+,
* but it is not a validator.
* For formats, see
- * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings]
+ * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings]
*
* If +string+ does not specify a valid date,
* the result is unpredictable;
@@ -4542,7 +4732,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
* This method recognizes many forms in +string+,
* but it is not a validator.
* For formats, see
- * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings]
+ * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings]
* If +string+ does not specify a valid date,
* the result is unpredictable;
* consider using Date._strptime instead.
@@ -4562,7 +4752,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._parse (returns a hash).
@@ -4572,12 +4762,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
{
VALUE str, comp, sg, opt;
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01");
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
case 1:
comp = Qtrue;
case 2:
@@ -4607,7 +4796,7 @@ VALUE date__jisx0301(VALUE);
* Date._iso8601(string, limit: 128) -> hash
*
* Returns a hash of values parsed from +string+, which should contain
- * an {ISO 8601 formatted date}[rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications]:
+ * an {ISO 8601 formatted date}[rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specifications]:
*
* d = Date.new(2001, 2, 3)
* s = d.iso8601 # => "2001-02-03"
@@ -4623,7 +4812,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__iso8601(str);
}
@@ -4634,7 +4823,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
*
* Returns a new \Date object with values parsed from +string+,
* which should contain
- * an {ISO 8601 formatted date}[rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications]:
+ * an {ISO 8601 formatted date}[rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specifications]:
*
* d = Date.new(2001, 2, 3)
* s = d.iso8601 # => "2001-02-03"
@@ -4642,7 +4831,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._iso8601 (returns a hash).
@@ -4652,12 +4841,11 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01");
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -4677,7 +4865,7 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
* Date._rfc3339(string, limit: 128) -> hash
*
* Returns a hash of values parsed from +string+, which should be a valid
- * {RFC 3339 format}[rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format]:
+ * {RFC 3339 format}[rdoc-ref:language/strftime_formatting.rdoc@RFC+3339+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
@@ -4694,7 +4882,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__rfc3339(str);
}
@@ -4705,7 +4893,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
*
* Returns a new \Date object with values parsed from +string+,
* which should be a valid
- * {RFC 3339 format}[rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format]:
+ * {RFC 3339 format}[rdoc-ref:language/strftime_formatting.rdoc@RFC+3339+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
@@ -4713,7 +4901,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._rfc3339 (returns a hash).
@@ -4723,12 +4911,11 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -4764,7 +4951,7 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__xmlschema(str);
}
@@ -4782,7 +4969,7 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._xmlschema (returns a hash).
@@ -4792,12 +4979,11 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01");
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -4817,7 +5003,7 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
* Date._rfc2822(string, limit: 128) -> hash
*
* Returns a hash of values parsed from +string+, which should be a valid
- * {RFC 2822 date format}[rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format]:
+ * {RFC 2822 date format}[rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
@@ -4834,7 +5020,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__rfc2822(str);
}
@@ -4845,7 +5031,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
*
* Returns a new \Date object with values parsed from +string+,
* which should be a valid
- * {RFC 2822 date format}[rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format]:
+ * {RFC 2822 date format}[rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
@@ -4853,7 +5039,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._rfc2822 (returns a hash).
@@ -4863,11 +5049,11 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -4887,7 +5073,7 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
* Date._httpdate(string, limit: 128) -> hash
*
* Returns a hash of values parsed from +string+, which should be a valid
- * {HTTP date format}[rdoc-ref:strftime_formatting.rdoc@HTTP+Format]:
+ * {HTTP date format}[rdoc-ref:language/strftime_formatting.rdoc@HTTP+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
@@ -4902,7 +5088,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__httpdate(str);
}
@@ -4913,7 +5099,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
*
* Returns a new \Date object with values parsed from +string+,
* which should be a valid
- * {HTTP date format}[rdoc-ref:strftime_formatting.rdoc@HTTP+Format]:
+ * {HTTP date format}[rdoc-ref:language/strftime_formatting.rdoc@HTTP+Format]:
*
* d = Date.new(2001, 2, 3)
s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
@@ -4921,7 +5107,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._httpdate (returns a hash).
@@ -4931,11 +5117,11 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -4955,7 +5141,7 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
* Date._jisx0301(string, limit: 128) -> hash
*
* Returns a hash of values parsed from +string+, which should be a valid
- * {JIS X 0301 date format}[rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format]:
+ * {JIS X 0301 date format}[rdoc-ref:language/strftime_formatting.rdoc@JIS+X+0301+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.jisx0301 # => "H13.02.03"
@@ -4971,7 +5157,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
VALUE str, opt;
rb_scan_args(argc, argv, "1:", &str, &opt);
- check_limit(str, opt);
+ if (!NIL_P(str)) str = check_limit(str, opt);
return date__jisx0301(str);
}
@@ -4981,7 +5167,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
* Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
*
* Returns a new \Date object with values parsed from +string+,
- * which should be a valid {JIS X 0301 format}[rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format]:
+ * which should be a valid {JIS X 0301 format}[rdoc-ref:language/strftime_formatting.rdoc@JIS+X+0301+Format]:
*
* d = Date.new(2001, 2, 3)
* s = d.jisx0301 # => "H13.02.03"
@@ -4993,7 +5179,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
*
* See:
*
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * - Argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
* Related: Date._jisx0301 (returns a hash).
@@ -5003,12 +5189,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01");
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -5752,7 +5937,7 @@ d_lite_leap_p(VALUE self)
* Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
* Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
*/
static VALUE
@@ -5818,7 +6003,7 @@ dup_obj_with_new_start(VALUE obj, double sg)
/*
* call-seq:
- * new_start(start = Date::ITALY]) -> new_date
+ * new_start(start = Date::ITALY) -> new_date
*
* Returns a copy of +self+ with the given +start+ value:
*
@@ -5827,7 +6012,7 @@ dup_obj_with_new_start(VALUE obj, double sg)
* d1 = d0.new_start(Date::JULIAN)
* d1.julian? # => true
*
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
+ * See argument {start}[rdoc-ref:language/calendars.rdoc@Argument+start].
*
*/
static VALUE
@@ -6332,9 +6517,11 @@ minus_dd(VALUE self, VALUE other)
* call-seq:
* d - other -> date or rational
*
- * Returns the difference between the two dates if the other is a date
- * object. If the other is a numeric value, returns a date object
- * pointing +other+ days before self. If the other is a fractional number,
+ * If the other is a date object, returns a Rational
+ * whose value is the difference between the two dates in days.
+ * If the other is a numeric value, returns a date object
+ * pointing +other+ days before self.
+ * If the other is a fractional number,
* assumes its precision is at most nanosecond.
*
* Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
@@ -6941,13 +7128,24 @@ d_lite_eql_p(VALUE self, VALUE other)
static VALUE
d_lite_hash(VALUE self)
{
- st_index_t v, h[4];
+ st_index_t v, h[5];
+ VALUE nth;
get_d1(self);
- h[0] = m_nth(dat);
- h[1] = m_jd(dat);
- h[2] = m_df(dat);
- h[3] = m_sf(dat);
+ nth = m_nth(dat);
+
+ if (FIXNUM_P(nth)) {
+ h[0] = 0;
+ h[1] = (st_index_t)nth;
+ } else {
+ h[0] = 1;
+ h[1] = (st_index_t)FIX2LONG(rb_hash(nth));
+ }
+
+ h[2] = m_jd(dat);
+ h[3] = m_df(dat);
+ h[4] = m_sf(dat);
+
v = rb_memhash(h, sizeof(h));
return ST2FIX(v);
}
@@ -6962,7 +7160,7 @@ static VALUE strftimev(const char *, VALUE,
* to_s -> string
*
* Returns a string representation of the date in +self+
- * in {ISO 8601 extended date format}[rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications]
+ * in {ISO 8601 extended date format}[rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specifications]
* (<tt>'%Y-%m-%d'</tt>):
*
* Date.new(2001, 2, 3).to_s # => "2001-02-03"
@@ -7243,7 +7441,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
* Date.new(2001, 2, 3).strftime # => "2001-02-03"
*
* For other formats, see
- * {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc].
+ * {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc].
*
*/
static VALUE
@@ -7275,12 +7473,12 @@ strftimev(const char *fmt, VALUE self,
* asctime -> string
*
* Equivalent to #strftime with argument <tt>'%a %b %e %T %Y'</tt>
- * (or its {shorthand form}[rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers]
+ * (or its {shorthand form}[rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifiers]
* <tt>'%c'</tt>):
*
* Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
*
- * See {asctime}[https://linux.die.net/man/3/asctime].
+ * See {asctime}[https://man7.org/linux/man-pages/man3/asctime.3p.html].
*
*/
static VALUE
@@ -7294,7 +7492,7 @@ d_lite_asctime(VALUE self)
* iso8601 -> string
*
* Equivalent to #strftime with argument <tt>'%Y-%m-%d'</tt>
- * (or its {shorthand form}[rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers]
+ * (or its {shorthand form}[rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifiers]
* <tt>'%F'</tt>);
*
* Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
@@ -7311,7 +7509,7 @@ d_lite_iso8601(VALUE self)
* rfc3339 -> string
*
* Equivalent to #strftime with argument <tt>'%FT%T%:z'</tt>;
- * see {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc]:
+ * see {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc]:
*
* Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
*
@@ -7327,7 +7525,7 @@ d_lite_rfc3339(VALUE self)
* rfc2822 -> string
*
* Equivalent to #strftime with argument <tt>'%a, %-d %b %Y %T %z'</tt>;
- * see {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc]:
+ * see {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc]:
*
* Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
*
@@ -7343,7 +7541,7 @@ d_lite_rfc2822(VALUE self)
* httpdate -> string
*
* Equivalent to #strftime with argument <tt>'%a, %d %b %Y %T GMT'</tt>;
- * see {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc]:
+ * see {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc]:
*
* Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
*
@@ -7522,10 +7720,7 @@ d_lite_marshal_dump_old(VALUE self)
m_of_in_day(dat),
DBL2NUM(m_sg(dat)));
- if (FL_TEST(self, FL_EXIVAR)) {
- rb_copy_generic_ivar(a, self);
- FL_SET(a, FL_EXIVAR);
- }
+ rb_copy_generic_ivar(a, self);
return a;
}
@@ -7547,10 +7742,8 @@ d_lite_marshal_dump(VALUE self)
INT2FIX(m_of(dat)),
DBL2NUM(m_sg(dat)));
- if (FL_TEST(self, FL_EXIVAR)) {
- rb_copy_generic_ivar(a, self);
- FL_SET(a, FL_EXIVAR);
- }
+
+ rb_copy_generic_ivar(a, self);
return a;
}
@@ -7623,10 +7816,7 @@ d_lite_marshal_load(VALUE self, VALUE a)
HAVE_JD | HAVE_DF);
}
- if (FL_TEST(a, FL_EXIVAR)) {
- rb_copy_generic_ivar(self, a);
- FL_SET(self, FL_EXIVAR);
- }
+ rb_copy_generic_ivar(self, a);
return self;
}
@@ -8379,7 +8569,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
fmt = rb_str_new2("%FT%T%z");
case 2:
@@ -8427,12 +8617,11 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
{
VALUE str, comp, sg, opt;
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
comp = Qtrue;
case 2:
@@ -8474,12 +8663,11 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8489,7 +8677,7 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
VALUE argv2[2], hash;
argv2[0] = str;
argv2[1] = opt;
- if (!NIL_P(opt)) argc2--;
+ if (!NIL_P(opt)) argc2++;
hash = date_s__iso8601(argc2, argv2, klass);
return dt_new_by_frags(klass, hash, sg);
}
@@ -8514,12 +8702,11 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8554,12 +8741,11 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8595,12 +8781,11 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8635,12 +8820,11 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8680,12 +8864,11 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg, opt;
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
- if (!NIL_P(opt)) argc--;
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
switch (argc) {
case 0:
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
case 1:
sg = INT2FIX(DEFAULT_SG);
}
@@ -8726,8 +8909,8 @@ dt_lite_to_s(VALUE self)
*
* DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
*
- * For other formats, see
- * {Formats for Dates and Times}[doc/strftime_formatting.rdoc].
+ * For other formats,
+ * see {Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc]:
*
*/
static VALUE
@@ -8961,18 +9144,23 @@ time_to_datetime(VALUE self)
static VALUE
date_to_time(VALUE self)
{
+ VALUE t;
+
get_d1a(self);
if (m_julian_p(adat)) {
- VALUE tmp = d_lite_gregorian(self);
- get_d1b(tmp);
+ VALUE g = d_lite_gregorian(self);
+ get_d1b(g);
adat = bdat;
+ self = g;
}
- return f_local3(rb_cTime,
+ t = f_local3(rb_cTime,
m_real_year(adat),
INT2FIX(m_mon(adat)),
INT2FIX(m_mday(adat)));
+ RB_GC_GUARD(self); /* may be the converted gregorian */
+ return t;
}
/*
@@ -9042,9 +9230,10 @@ datetime_to_time(VALUE self)
get_d1(self);
if (m_julian_p(dat)) {
- self = d_lite_gregorian(self);
- get_d1a(self);
+ VALUE g = d_lite_gregorian(self);
+ get_d1a(g);
dat = adat;
+ self = g;
}
{
@@ -9061,6 +9250,7 @@ datetime_to_time(VALUE self)
f_add(INT2FIX(m_sec(dat)),
m_sf_in_sec(dat)),
INT2FIX(m_of(dat)));
+ RB_GC_GUARD(self); /* may be the converted gregorian */
return t;
}
}
@@ -9465,7 +9655,7 @@ mk_ary_of_str(long len, const char *a[])
}
rb_ary_push(o, e);
}
- rb_obj_freeze(o);
+ rb_ary_freeze(o);
return o;
}
@@ -9499,6 +9689,7 @@ Init_date_core(void)
sym_zone = ID2SYM(rb_intern_const("zone"));
half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));
+ rb_gc_register_mark_object(half_days_in_day);
#if (LONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS
day_in_nanoseconds = LONG2NUM((long)DAY_IN_SECONDS *
@@ -9510,8 +9701,6 @@ Init_date_core(void)
day_in_nanoseconds = f_mul(INT2FIX(DAY_IN_SECONDS),
INT2FIX(SECOND_IN_NANOSECONDS));
#endif
-
- rb_gc_register_mark_object(half_days_in_day);
rb_gc_register_mark_object(day_in_nanoseconds);
positive_inf = +INFINITY;
@@ -9527,7 +9716,7 @@ Init_date_core(void)
*
* - You need both dates and times; \Date handles only dates.
* - You need only Gregorian dates (and not Julian dates);
- * see {Julian and Gregorian Calendars}[rdoc-ref:calendars.rdoc].
+ * see {Julian and Gregorian Calendars}[rdoc-ref:language/calendars.rdoc].
*
* A \Date object, once created, is immutable, and cannot be modified.
*
@@ -9574,7 +9763,7 @@ Init_date_core(void)
* Date.strptime('fri31dec99', '%a%d%b%y') # => #<Date: 1999-12-31>
*
* See also the specialized methods in
- * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings]
+ * {"Specialized Format Strings" in Formats for Dates and Times}[rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings]
*
* == Argument +limit+
*
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index c6f26ecb91..a1600e4708 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -7,6 +7,9 @@
#include "ruby/re.h"
#include <ctype.h>
+#undef strncasecmp
+#define strncasecmp STRNCASECMP
+
RUBY_EXTERN VALUE rb_int_positive_pow(long x, unsigned long y);
RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index f731629df1..1dde5fa3ec 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -7,6 +7,9 @@
#include "ruby/re.h"
#include <ctype.h>
+#undef strncasecmp
+#define strncasecmp STRNCASECMP
+
static const char *day_names[] = {
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
@@ -119,8 +122,9 @@ do { \
do { \
size_t l; \
l = read_digits(&str[si], slen - si, &n, w); \
- if (l == 0) \
+ if (l == 0) { \
fail(); \
+ } \
si += l; \
} while (0)
@@ -657,6 +661,9 @@ date__strptime(const char *str, size_t slen,
si = date__strptime_internal(str, slen, fmt, flen, hash);
+ if (fail_p())
+ return Qnil;
+
if (slen > si) {
VALUE s;
@@ -664,9 +671,6 @@ date__strptime(const char *str, size_t slen,
set_hash("leftover", s);
}
- if (fail_p())
- return Qnil;
-
cent = del_hash("_cent");
if (!NIL_P(cent)) {
VALUE year;
diff --git a/ext/date/depend b/ext/date/depend
index 82f85f7bf3..4fb78149a1 100644
--- a/ext/date/depend
+++ b/ext/date/depend
@@ -138,6 +138,7 @@ date_core.o: $(hdrdir)/ruby/internal/intern/re.h
date_core.o: $(hdrdir)/ruby/internal/intern/ruby.h
date_core.o: $(hdrdir)/ruby/internal/intern/select.h
date_core.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+date_core.o: $(hdrdir)/ruby/internal/intern/set.h
date_core.o: $(hdrdir)/ruby/internal/intern/signal.h
date_core.o: $(hdrdir)/ruby/internal/intern/sprintf.h
date_core.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ date_core.o: $(hdrdir)/ruby/internal/special_consts.h
date_core.o: $(hdrdir)/ruby/internal/static_assert.h
date_core.o: $(hdrdir)/ruby/internal/stdalign.h
date_core.o: $(hdrdir)/ruby/internal/stdbool.h
+date_core.o: $(hdrdir)/ruby/internal/stdckdint.h
date_core.o: $(hdrdir)/ruby/internal/symbol.h
date_core.o: $(hdrdir)/ruby/internal/value.h
date_core.o: $(hdrdir)/ruby/internal/value_type.h
@@ -312,6 +314,7 @@ date_parse.o: $(hdrdir)/ruby/internal/intern/re.h
date_parse.o: $(hdrdir)/ruby/internal/intern/ruby.h
date_parse.o: $(hdrdir)/ruby/internal/intern/select.h
date_parse.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+date_parse.o: $(hdrdir)/ruby/internal/intern/set.h
date_parse.o: $(hdrdir)/ruby/internal/intern/signal.h
date_parse.o: $(hdrdir)/ruby/internal/intern/sprintf.h
date_parse.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -331,6 +334,7 @@ date_parse.o: $(hdrdir)/ruby/internal/special_consts.h
date_parse.o: $(hdrdir)/ruby/internal/static_assert.h
date_parse.o: $(hdrdir)/ruby/internal/stdalign.h
date_parse.o: $(hdrdir)/ruby/internal/stdbool.h
+date_parse.o: $(hdrdir)/ruby/internal/stdckdint.h
date_parse.o: $(hdrdir)/ruby/internal/symbol.h
date_parse.o: $(hdrdir)/ruby/internal/value.h
date_parse.o: $(hdrdir)/ruby/internal/value_type.h
@@ -476,6 +480,7 @@ date_strftime.o: $(hdrdir)/ruby/internal/intern/re.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/ruby.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/select.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+date_strftime.o: $(hdrdir)/ruby/internal/intern/set.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/signal.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/sprintf.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -495,6 +500,7 @@ date_strftime.o: $(hdrdir)/ruby/internal/special_consts.h
date_strftime.o: $(hdrdir)/ruby/internal/static_assert.h
date_strftime.o: $(hdrdir)/ruby/internal/stdalign.h
date_strftime.o: $(hdrdir)/ruby/internal/stdbool.h
+date_strftime.o: $(hdrdir)/ruby/internal/stdckdint.h
date_strftime.o: $(hdrdir)/ruby/internal/symbol.h
date_strftime.o: $(hdrdir)/ruby/internal/value.h
date_strftime.o: $(hdrdir)/ruby/internal/value_type.h
@@ -647,6 +653,7 @@ date_strptime.o: $(hdrdir)/ruby/internal/intern/re.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/ruby.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/select.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+date_strptime.o: $(hdrdir)/ruby/internal/intern/set.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/signal.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/sprintf.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -666,6 +673,7 @@ date_strptime.o: $(hdrdir)/ruby/internal/special_consts.h
date_strptime.o: $(hdrdir)/ruby/internal/static_assert.h
date_strptime.o: $(hdrdir)/ruby/internal/stdalign.h
date_strptime.o: $(hdrdir)/ruby/internal/stdbool.h
+date_strptime.o: $(hdrdir)/ruby/internal/stdckdint.h
date_strptime.o: $(hdrdir)/ruby/internal/symbol.h
date_strptime.o: $(hdrdir)/ruby/internal/value.h
date_strptime.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/date/extconf.rb b/ext/date/extconf.rb
index 358f64173a..8a1467df09 100644
--- a/ext/date/extconf.rb
+++ b/ext/date/extconf.rb
@@ -3,6 +3,7 @@ require 'mkmf'
config_string("strict_warnflags") {|w| $warnflags += " #{w}"}
+append_cflags("-Wno-compound-token-split-by-macro") if RUBY_VERSION < "2.7."
have_func("rb_category_warn")
with_werror("", {:werror => true}) do |opt, |
have_var("timezone", "time.h", opt)
diff --git a/ext/date/lib/date.rb b/ext/date/lib/date.rb
index a9fe3ce4b0..0cb763017f 100644
--- a/ext/date/lib/date.rb
+++ b/ext/date/lib/date.rb
@@ -4,7 +4,7 @@
require 'date_core'
class Date
- VERSION = "3.3.3" # :nodoc:
+ VERSION = "3.5.1" # :nodoc:
# call-seq:
# infinite? -> false
diff --git a/ext/date/prereq.mk b/ext/date/prereq.mk
index cee7685975..b5d271a32c 100644
--- a/ext/date/prereq.mk
+++ b/ext/date/prereq.mk
@@ -1,7 +1,7 @@
.SUFFIXES: .list
.list.h:
- gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
+ gperf --ignore-case -L ANSI-C -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
| sed -f $(top_srcdir)/tool/gperf.sed \
> $(@F)
diff --git a/ext/date/zonetab.h b/ext/date/zonetab.h
index 7ced9e0308..2a2e8910c9 100644
--- a/ext/date/zonetab.h
+++ b/ext/date/zonetab.h
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */
+/* Command-line: gperf --ignore-case -L ANSI-C -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */
/* Computed positions: -k'1-4,9' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -29,15 +29,17 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
-#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "zonetab.list"
+#define GPERF_DOWNCASE 1
+#define GPERF_CASE_STRNCMP 1
+#define gperf_case_strncmp strncasecmp
struct zone {
int name;
int offset;
};
static const struct zone *zonetab(register const char *str, register size_t len);
-#line 9 "zonetab.list"
+#line 12 "zonetab.list"
struct zone;
#define TOTAL_KEYWORDS 316
@@ -49,7 +51,7 @@ struct zone;
#ifndef GPERF_DOWNCASE
#define GPERF_DOWNCASE 1
-static const unsigned char gperf_downcase[256] =
+static unsigned char gperf_downcase[256] =
{
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,
@@ -808,736 +810,736 @@ zonetab (register const char *str, register size_t len)
static const struct zone wordlist[] =
{
{-1}, {-1},
-#line 34 "zonetab.list"
- {gperf_offsetof(stringpool, 2), -2*3600},
-#line 43 "zonetab.list"
- {gperf_offsetof(stringpool, 3), -11*3600},
-#line 45 "zonetab.list"
- {gperf_offsetof(stringpool, 4), 0*3600},
-#line 36 "zonetab.list"
- {gperf_offsetof(stringpool, 5), -4*3600},
- {-1}, {-1},
-#line 269 "zonetab.list"
- {gperf_offsetof(stringpool, 8),21600},
-#line 268 "zonetab.list"
- {gperf_offsetof(stringpool, 9),25200},
-#line 35 "zonetab.list"
- {gperf_offsetof(stringpool, 10), -3*3600},
+#line 37 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2, -2*3600},
+#line 46 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3, -11*3600},
+#line 48 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str4, 0*3600},
+#line 39 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str5, -4*3600},
{-1}, {-1},
-#line 21 "zonetab.list"
- {gperf_offsetof(stringpool, 13), 1*3600},
-#line 25 "zonetab.list"
- {gperf_offsetof(stringpool, 14), 5*3600},
-#line 271 "zonetab.list"
- {gperf_offsetof(stringpool, 15),-18000},
-#line 279 "zonetab.list"
- {gperf_offsetof(stringpool, 16),-10800},
-#line 273 "zonetab.list"
- {gperf_offsetof(stringpool, 17),43200},
#line 272 "zonetab.list"
- {gperf_offsetof(stringpool, 18),43200},
-#line 80 "zonetab.list"
- {gperf_offsetof(stringpool, 19), 2*3600},
-#line 186 "zonetab.list"
- {gperf_offsetof(stringpool, 20),36000},
-#line 88 "zonetab.list"
- {gperf_offsetof(stringpool, 21), 3*3600},
-#line 87 "zonetab.list"
- {gperf_offsetof(stringpool, 22), 3*3600},
- {-1},
-#line 101 "zonetab.list"
- {gperf_offsetof(stringpool, 24),-6*3600},
-#line 217 "zonetab.list"
- {gperf_offsetof(stringpool, 25),-18000},
-#line 19 "zonetab.list"
- {gperf_offsetof(stringpool, 26), -8*3600},
-#line 133 "zonetab.list"
- {gperf_offsetof(stringpool, 27), -18000},
-#line 32 "zonetab.list"
- {gperf_offsetof(stringpool, 28), 12*3600},
-#line 56 "zonetab.list"
- {gperf_offsetof(stringpool, 29), -4*3600},
-#line 13 "zonetab.list"
- {gperf_offsetof(stringpool, 30), -5*3600},
-#line 23 "zonetab.list"
- {gperf_offsetof(stringpool, 31), 3*3600},
-#line 256 "zonetab.list"
- {gperf_offsetof(stringpool, 32),23400},
-#line 73 "zonetab.list"
- {gperf_offsetof(stringpool, 33), 1*3600},
- {-1},
-#line 82 "zonetab.list"
- {gperf_offsetof(stringpool, 35), 2*3600},
-#line 71 "zonetab.list"
- {gperf_offsetof(stringpool, 36), 1*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8,21600},
+#line 271 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9,25200},
+#line 38 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, -3*3600},
+ {-1}, {-1},
#line 24 "zonetab.list"
- {gperf_offsetof(stringpool, 37), 4*3600},
-#line 79 "zonetab.list"
- {gperf_offsetof(stringpool, 38), 2*3600},
-#line 65 "zonetab.list"
- {gperf_offsetof(stringpool, 39),2*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, 1*3600},
+#line 28 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, 5*3600},
+#line 274 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15,-18000},
+#line 282 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16,-10800},
+#line 276 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17,43200},
+#line 275 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18,43200},
+#line 83 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, 2*3600},
+#line 189 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20,36000},
+#line 91 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, 3*3600},
+#line 90 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, 3*3600},
{-1},
-#line 202 "zonetab.list"
- {gperf_offsetof(stringpool, 41),28800},
-#line 252 "zonetab.list"
- {gperf_offsetof(stringpool, 42),39600},
-#line 251 "zonetab.list"
- {gperf_offsetof(stringpool, 43),43200},
-#line 17 "zonetab.list"
- {gperf_offsetof(stringpool, 44), -7*3600},
-#line 89 "zonetab.list"
- {gperf_offsetof(stringpool, 45), 3*3600},
-#line 212 "zonetab.list"
- {gperf_offsetof(stringpool, 46),-18000},
-#line 15 "zonetab.list"
- {gperf_offsetof(stringpool, 47), -6*3600},
-#line 192 "zonetab.list"
- {gperf_offsetof(stringpool, 48),18000},
-#line 26 "zonetab.list"
- {gperf_offsetof(stringpool, 49), 6*3600},
- {-1}, {-1},
-#line 51 "zonetab.list"
- {gperf_offsetof(stringpool, 52), -3*3600},
-#line 226 "zonetab.list"
- {gperf_offsetof(stringpool, 53),-7200},
-#line 221 "zonetab.list"
- {gperf_offsetof(stringpool, 54),10800},
+#line 104 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24,-6*3600},
+#line 220 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25,-18000},
#line 22 "zonetab.list"
- {gperf_offsetof(stringpool, 55), 2*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, -8*3600},
+#line 136 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, -18000},
+#line 35 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, 12*3600},
+#line 59 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, -4*3600},
+#line 16 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, -5*3600},
+#line 26 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, 3*3600},
+#line 259 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32,23400},
+#line 76 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, 1*3600},
{-1},
-#line 190 "zonetab.list"
- {gperf_offsetof(stringpool, 57),43200},
-#line 189 "zonetab.list"
- {gperf_offsetof(stringpool, 58),43200},
-#line 199 "zonetab.list"
- {gperf_offsetof(stringpool, 59),28800},
-#line 29 "zonetab.list"
- {gperf_offsetof(stringpool, 60), 9*3600},
-#line 276 "zonetab.list"
- {gperf_offsetof(stringpool, 61),28800},
-#line 48 "zonetab.list"
- {gperf_offsetof(stringpool, 62), -2*3600},
-#line 94 "zonetab.list"
- {gperf_offsetof(stringpool, 63), 6*3600},
+#line 85 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, 2*3600},
#line 74 "zonetab.list"
- {gperf_offsetof(stringpool, 64), 1*3600},
-#line 81 "zonetab.list"
- {gperf_offsetof(stringpool, 65), 2*3600},
-#line 64 "zonetab.list"
- {gperf_offsetof(stringpool, 66),-10*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, 1*3600},
+#line 27 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, 4*3600},
+#line 82 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, 2*3600},
+#line 68 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39,2*3600},
+ {-1},
+#line 205 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41,28800},
+#line 255 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42,39600},
#line 254 "zonetab.list"
- {gperf_offsetof(stringpool, 67),18000},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43,43200},
+#line 20 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, -7*3600},
#line 92 "zonetab.list"
- {gperf_offsetof(stringpool, 68), 5*3600},
- {-1},
-#line 200 "zonetab.list"
- {gperf_offsetof(stringpool, 70),-14400},
-#line 70 "zonetab.list"
- {gperf_offsetof(stringpool, 71), 1*3600},
-#line 281 "zonetab.list"
- {gperf_offsetof(stringpool, 72),32400},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, 3*3600},
+#line 215 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46,-18000},
+#line 18 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, -6*3600},
+#line 195 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48,18000},
+#line 29 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, 6*3600},
+ {-1}, {-1},
+#line 54 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str52, -3*3600},
+#line 229 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str53,-7200},
+#line 224 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str54,10800},
+#line 25 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, 2*3600},
{-1},
-#line 280 "zonetab.list"
- {gperf_offsetof(stringpool, 74),39600},
-#line 238 "zonetab.list"
- {gperf_offsetof(stringpool, 75),21600},
-#line 93 "zonetab.list"
- {gperf_offsetof(stringpool, 76), (5*3600+1800)},
-#line 194 "zonetab.list"
- {gperf_offsetof(stringpool, 77),28800},
+#line 193 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str57,43200},
+#line 192 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str58,43200},
+#line 202 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str59,28800},
+#line 32 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str60, 9*3600},
+#line 279 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str61,28800},
+#line 51 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str62, -2*3600},
+#line 97 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str63, 6*3600},
+#line 77 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, 1*3600},
+#line 84 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str65, 2*3600},
+#line 67 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str66,-10*3600},
+#line 257 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str67,18000},
+#line 95 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str68, 5*3600},
{-1},
-#line 255 "zonetab.list"
- {gperf_offsetof(stringpool, 79),43200},
-#line 75 "zonetab.list"
- {gperf_offsetof(stringpool, 80), 1*3600},
-#line 270 "zonetab.list"
- {gperf_offsetof(stringpool, 81),18000},
-#line 83 "zonetab.list"
- {gperf_offsetof(stringpool, 82), 2*3600},
+#line 203 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str70,-14400},
+#line 73 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str71, 1*3600},
+#line 284 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str72,32400},
{-1},
-#line 207 "zonetab.list"
- {gperf_offsetof(stringpool, 84),36000},
-#line 278 "zonetab.list"
- {gperf_offsetof(stringpool, 85),-7200},
- {-1}, {-1},
-#line 126 "zonetab.list"
- {gperf_offsetof(stringpool, 88), -21600},
-#line 185 "zonetab.list"
- {gperf_offsetof(stringpool, 89),39600},
-#line 183 "zonetab.list"
- {gperf_offsetof(stringpool, 90),-18000},
-#line 218 "zonetab.list"
- {gperf_offsetof(stringpool, 91),-18000},
-#line 182 "zonetab.list"
- {gperf_offsetof(stringpool, 92),34200},
-#line 103 "zonetab.list"
- {gperf_offsetof(stringpool, 93),11*3600},
-#line 53 "zonetab.list"
- {gperf_offsetof(stringpool, 94), -3*3600},
-#line 208 "zonetab.list"
- {gperf_offsetof(stringpool, 95),36000},
-#line 49 "zonetab.list"
- {gperf_offsetof(stringpool, 96),-2*3600},
-#line 120 "zonetab.list"
- {gperf_offsetof(stringpool, 97), 34200},
- {-1}, {-1},
-#line 215 "zonetab.list"
- {gperf_offsetof(stringpool, 100),25200},
-#line 242 "zonetab.list"
- {gperf_offsetof(stringpool, 101),12600},
+#line 283 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str74,39600},
#line 241 "zonetab.list"
- {gperf_offsetof(stringpool, 102),28800},
-#line 240 "zonetab.list"
- {gperf_offsetof(stringpool, 103),32400},
-#line 86 "zonetab.list"
- {gperf_offsetof(stringpool, 104), 3*3600},
-#line 33 "zonetab.list"
- {gperf_offsetof(stringpool, 105), -1*3600},
-#line 201 "zonetab.list"
- {gperf_offsetof(stringpool, 106),21600},
-#line 148 "zonetab.list"
- {gperf_offsetof(stringpool, 107), -25200},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str75,21600},
#line 96 "zonetab.list"
- {gperf_offsetof(stringpool, 108), (6*3600+1800)},
-#line 42 "zonetab.list"
- {gperf_offsetof(stringpool, 109), -10*3600},
-#line 31 "zonetab.list"
- {gperf_offsetof(stringpool, 110), 11*3600},
-#line 72 "zonetab.list"
- {gperf_offsetof(stringpool, 111), 1*3600},
- {-1},
-#line 90 "zonetab.list"
- {gperf_offsetof(stringpool, 113), 4*3600},
-#line 47 "zonetab.list"
- {gperf_offsetof(stringpool, 114), 0*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, (5*3600+1800)},
+#line 197 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str77,28800},
{-1},
+#line 258 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79,43200},
#line 78 "zonetab.list"
- {gperf_offsetof(stringpool, 116), 1*3600},
-#line 77 "zonetab.list"
- {gperf_offsetof(stringpool, 117), 1*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str80, 1*3600},
+#line 273 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str81,18000},
+#line 86 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str82, 2*3600},
{-1},
-#line 95 "zonetab.list"
- {gperf_offsetof(stringpool, 119), 2*3600},
-#line 313 "zonetab.list"
- {gperf_offsetof(stringpool, 120),43200},
-#line 55 "zonetab.list"
- {gperf_offsetof(stringpool, 121), -(2*3600+1800)},
-#line 184 "zonetab.list"
- {gperf_offsetof(stringpool, 122),31500},
-#line 204 "zonetab.list"
- {gperf_offsetof(stringpool, 123),45900},
#line 210 "zonetab.list"
- {gperf_offsetof(stringpool, 124),-18000},
-#line 198 "zonetab.list"
- {gperf_offsetof(stringpool, 125),14400},
-#line 57 "zonetab.list"
- {gperf_offsetof(stringpool, 126), -4*3600},
-#line 197 "zonetab.list"
- {gperf_offsetof(stringpool, 127),18000},
-#line 54 "zonetab.list"
- {gperf_offsetof(stringpool, 128),-3*3600},
-#line 253 "zonetab.list"
- {gperf_offsetof(stringpool, 129),-30600},
-#line 91 "zonetab.list"
- {gperf_offsetof(stringpool, 130), 4*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84,36000},
+#line 281 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str85,-7200},
+ {-1}, {-1},
+#line 129 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str88, -21600},
+#line 188 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str89,39600},
+#line 186 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str90,-18000},
+#line 221 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str91,-18000},
+#line 185 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92,34200},
+#line 106 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str93,11*3600},
+#line 56 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str94, -3*3600},
+#line 211 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str95,36000},
+#line 52 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96,-2*3600},
+#line 123 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str97, 34200},
+ {-1}, {-1},
+#line 218 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str100,25200},
+#line 245 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str101,12600},
+#line 244 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str102,28800},
+#line 243 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str103,32400},
+#line 89 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str104, 3*3600},
+#line 36 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str105, -1*3600},
+#line 204 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106,21600},
+#line 151 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str107, -25200},
#line 99 "zonetab.list"
- {gperf_offsetof(stringpool, 131), 9*3600},
-#line 122 "zonetab.list"
- {gperf_offsetof(stringpool, 132), 21600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, (6*3600+1800)},
+#line 45 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str109, -10*3600},
+#line 34 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str110, 11*3600},
+#line 75 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, 1*3600},
+ {-1},
+#line 93 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str113, 4*3600},
+#line 50 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str114, 0*3600},
+ {-1},
+#line 81 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str116, 1*3600},
+#line 80 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str117, 1*3600},
+ {-1},
+#line 98 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str119, 2*3600},
+#line 316 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str120,43200},
+#line 58 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str121, -(2*3600+1800)},
#line 187 "zonetab.list"
- {gperf_offsetof(stringpool, 133),16200},
-#line 132 "zonetab.list"
- {gperf_offsetof(stringpool, 134), -10800},
-#line 121 "zonetab.list"
- {gperf_offsetof(stringpool, 135), -21600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str122,31500},
+#line 207 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str123,45900},
+#line 213 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124,-18000},
+#line 201 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125,14400},
+#line 60 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str126, -4*3600},
+#line 200 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127,18000},
+#line 57 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str128,-3*3600},
+#line 256 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str129,-30600},
+#line 94 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str130, 4*3600},
+#line 102 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, 9*3600},
+#line 125 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str132, 21600},
+#line 190 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str133,16200},
+#line 135 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str134, -10800},
+#line 124 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str135, -21600},
{-1},
-#line 236 "zonetab.list"
- {gperf_offsetof(stringpool, 137),25200},
+#line 239 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137,25200},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 274 "zonetab.list"
- {gperf_offsetof(stringpool, 143),36000},
-#line 266 "zonetab.list"
- {gperf_offsetof(stringpool, 144),43200},
-#line 146 "zonetab.list"
- {gperf_offsetof(stringpool, 145), -21600},
-#line 193 "zonetab.list"
- {gperf_offsetof(stringpool, 146),32400},
-#line 220 "zonetab.list"
- {gperf_offsetof(stringpool, 147),-3600},
-#line 214 "zonetab.list"
- {gperf_offsetof(stringpool, 148),25200},
-#line 219 "zonetab.list"
- {gperf_offsetof(stringpool, 149),0},
-#line 275 "zonetab.list"
- {gperf_offsetof(stringpool, 150),46800},
-#line 109 "zonetab.list"
- {gperf_offsetof(stringpool, 151), -32400},
+#line 277 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143,36000},
+#line 269 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144,43200},
+#line 149 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str145, -21600},
+#line 196 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str146,32400},
+#line 223 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str147,-3600},
+#line 217 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str148,25200},
+#line 222 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str149,0},
+#line 278 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150,46800},
+#line 112 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, -32400},
{-1}, {-1},
-#line 68 "zonetab.list"
- {gperf_offsetof(stringpool, 154), -11*3600},
+#line 71 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, -11*3600},
{-1}, {-1}, {-1},
-#line 321 "zonetab.list"
- {gperf_offsetof(stringpool, 158),0},
+#line 324 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158,0},
{-1},
-#line 178 "zonetab.list"
- {gperf_offsetof(stringpool, 160), 18000},
#line 181 "zonetab.list"
- {gperf_offsetof(stringpool, 161),37800},
-#line 265 "zonetab.list"
- {gperf_offsetof(stringpool, 162),20700},
-#line 249 "zonetab.list"
- {gperf_offsetof(stringpool, 163),37800},
-#line 108 "zonetab.list"
- {gperf_offsetof(stringpool, 164), 16200},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, 18000},
+#line 184 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161,37800},
+#line 268 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162,20700},
+#line 252 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163,37800},
+#line 111 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, 16200},
{-1}, {-1},
+#line 33 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, 10*3600},
+ {-1},
#line 30 "zonetab.list"
- {gperf_offsetof(stringpool, 167), 10*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str169, 7*3600},
+#line 242 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170,16200},
+#line 209 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171,28800},
+#line 208 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str172,32400},
+#line 15 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str173, 0*3600},
+#line 232 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str174,14400},
+#line 267 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str175,25200},
+#line 266 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176,25200},
+#line 226 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177,43200},
+#line 43 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, -8*3600},
+#line 225 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179,46800},
{-1},
-#line 27 "zonetab.list"
- {gperf_offsetof(stringpool, 169), 7*3600},
-#line 239 "zonetab.list"
- {gperf_offsetof(stringpool, 170),16200},
-#line 206 "zonetab.list"
- {gperf_offsetof(stringpool, 171),28800},
-#line 205 "zonetab.list"
- {gperf_offsetof(stringpool, 172),32400},
-#line 12 "zonetab.list"
- {gperf_offsetof(stringpool, 173), 0*3600},
-#line 229 "zonetab.list"
- {gperf_offsetof(stringpool, 174),14400},
-#line 264 "zonetab.list"
- {gperf_offsetof(stringpool, 175),25200},
+#line 285 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181,-10800},
#line 263 "zonetab.list"
- {gperf_offsetof(stringpool, 176),25200},
-#line 223 "zonetab.list"
- {gperf_offsetof(stringpool, 177),43200},
-#line 40 "zonetab.list"
- {gperf_offsetof(stringpool, 178), -8*3600},
-#line 222 "zonetab.list"
- {gperf_offsetof(stringpool, 179),46800},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str182,39600},
+#line 103 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str183, 9*3600},
+#line 247 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184,39600},
+#line 105 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, 10*3600},
+#line 146 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str186, 12600},
+#line 132 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str187, 10800},
+#line 101 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str188, 8*3600},
+#line 42 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, -7*3600},
+#line 133 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, 36000},
+#line 41 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str191, -6*3600},
+#line 206 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192,49500},
+#line 301 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str193,18000},
+#line 212 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str194,-14400},
+#line 194 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str195,-43200},
{-1},
-#line 282 "zonetab.list"
- {gperf_offsetof(stringpool, 181),-10800},
+#line 262 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197,28800},
+#line 182 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str198, 36000},
#line 260 "zonetab.list"
- {gperf_offsetof(stringpool, 182),39600},
-#line 100 "zonetab.list"
- {gperf_offsetof(stringpool, 183), 9*3600},
-#line 244 "zonetab.list"
- {gperf_offsetof(stringpool, 184),39600},
-#line 102 "zonetab.list"
- {gperf_offsetof(stringpool, 185), 10*3600},
-#line 143 "zonetab.list"
- {gperf_offsetof(stringpool, 186), 12600},
-#line 129 "zonetab.list"
- {gperf_offsetof(stringpool, 187), 10800},
-#line 98 "zonetab.list"
- {gperf_offsetof(stringpool, 188), 8*3600},
-#line 39 "zonetab.list"
- {gperf_offsetof(stringpool, 189), -7*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199,14400},
+#line 322 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str200,32400},
+#line 87 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str201, 2*3600},
+#line 289 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202,39600},
+#line 155 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, 43200},
+#line 303 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str204,46800},
#line 130 "zonetab.list"
- {gperf_offsetof(stringpool, 190), 36000},
-#line 38 "zonetab.list"
- {gperf_offsetof(stringpool, 191), -6*3600},
-#line 203 "zonetab.list"
- {gperf_offsetof(stringpool, 192),49500},
-#line 298 "zonetab.list"
- {gperf_offsetof(stringpool, 193),18000},
-#line 209 "zonetab.list"
- {gperf_offsetof(stringpool, 194),-14400},
-#line 191 "zonetab.list"
- {gperf_offsetof(stringpool, 195),-43200},
- {-1},
-#line 259 "zonetab.list"
- {gperf_offsetof(stringpool, 197),28800},
-#line 179 "zonetab.list"
- {gperf_offsetof(stringpool, 198), 36000},
-#line 257 "zonetab.list"
- {gperf_offsetof(stringpool, 199),14400},
-#line 319 "zonetab.list"
- {gperf_offsetof(stringpool, 200),32400},
-#line 84 "zonetab.list"
- {gperf_offsetof(stringpool, 201), 2*3600},
-#line 286 "zonetab.list"
- {gperf_offsetof(stringpool, 202),39600},
-#line 152 "zonetab.list"
- {gperf_offsetof(stringpool, 203), 43200},
-#line 300 "zonetab.list"
- {gperf_offsetof(stringpool, 204),46800},
-#line 127 "zonetab.list"
- {gperf_offsetof(stringpool, 205), 28800},
-#line 299 "zonetab.list"
- {gperf_offsetof(stringpool, 206),50400},
-#line 85 "zonetab.list"
- {gperf_offsetof(stringpool, 207), -11*3600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, 28800},
+#line 302 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206,50400},
+#line 88 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str207, -11*3600},
{-1},
-#line 142 "zonetab.list"
- {gperf_offsetof(stringpool, 209), 19800},
+#line 145 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, 19800},
{-1},
-#line 314 "zonetab.list"
- {gperf_offsetof(stringpool, 211),-10800},
-#line 288 "zonetab.list"
- {gperf_offsetof(stringpool, 212),39600},
+#line 317 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str211,-10800},
+#line 291 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212,39600},
{-1},
-#line 196 "zonetab.list"
- {gperf_offsetof(stringpool, 214),-3600},
-#line 195 "zonetab.list"
- {gperf_offsetof(stringpool, 215),0},
-#line 293 "zonetab.list"
- {gperf_offsetof(stringpool, 216),-36000},
-#line 106 "zonetab.list"
- {gperf_offsetof(stringpool, 217), 12*3600},
+#line 199 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214,-3600},
+#line 198 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215,0},
+#line 296 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216,-36000},
+#line 109 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, 12*3600},
+#line 131 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str218, -43200},
+#line 108 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str219,12*3600},
+#line 173 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, 32400},
#line 128 "zonetab.list"
- {gperf_offsetof(stringpool, 218), -43200},
-#line 105 "zonetab.list"
- {gperf_offsetof(stringpool, 219),12*3600},
-#line 170 "zonetab.list"
- {gperf_offsetof(stringpool, 220), 32400},
-#line 125 "zonetab.list"
- {gperf_offsetof(stringpool, 221), 39600},
- {-1},
-#line 283 "zonetab.list"
- {gperf_offsetof(stringpool, 223),21600},
-#line 113 "zonetab.list"
- {gperf_offsetof(stringpool, 224), -14400},
-#line 262 "zonetab.list"
- {gperf_offsetof(stringpool, 225),39600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str221, 39600},
{-1},
-#line 11 "zonetab.list"
- {gperf_offsetof(stringpool, 227), 0*3600},
-#line 301 "zonetab.list"
- {gperf_offsetof(stringpool, 228),10800},
-#line 315 "zonetab.list"
- {gperf_offsetof(stringpool, 229),43200},
-#line 291 "zonetab.list"
- {gperf_offsetof(stringpool, 230),-10800},
-#line 20 "zonetab.list"
- {gperf_offsetof(stringpool, 231), -7*3600},
-#line 248 "zonetab.list"
- {gperf_offsetof(stringpool, 232),39600},
+#line 286 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str223,21600},
+#line 116 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str224, -14400},
+#line 265 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225,39600},
{-1},
-#line 52 "zonetab.list"
- {gperf_offsetof(stringpool, 234), -3*3600},
#line 14 "zonetab.list"
- {gperf_offsetof(stringpool, 235), -4*3600},
- {-1}, {-1},
-#line 277 "zonetab.list"
- {gperf_offsetof(stringpool, 238),18000},
-#line 188 "zonetab.list"
- {gperf_offsetof(stringpool, 239),21600},
-#line 320 "zonetab.list"
- {gperf_offsetof(stringpool, 240),28800},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str227, 0*3600},
+#line 304 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str228,10800},
+#line 318 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str229,43200},
+#line 294 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str230,-10800},
+#line 23 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str231, -7*3600},
+#line 251 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232,39600},
{-1},
-#line 317 "zonetab.list"
- {gperf_offsetof(stringpool, 242),-10800},
-#line 60 "zonetab.list"
- {gperf_offsetof(stringpool, 243),-9*3600},
-#line 316 "zonetab.list"
- {gperf_offsetof(stringpool, 244),-7200},
+#line 55 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str234, -3*3600},
+#line 17 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str235, -4*3600},
+ {-1}, {-1},
+#line 280 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str238,18000},
+#line 191 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str239,21600},
+#line 323 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str240,28800},
{-1},
-#line 246 "zonetab.list"
- {gperf_offsetof(stringpool, 246),25200},
-#line 245 "zonetab.list"
- {gperf_offsetof(stringpool, 247),28800},
-#line 147 "zonetab.list"
- {gperf_offsetof(stringpool, 248), -7200},
-#line 18 "zonetab.list"
- {gperf_offsetof(stringpool, 249), -6*3600},
-#line 250 "zonetab.list"
- {gperf_offsetof(stringpool, 250),50400},
-#line 165 "zonetab.list"
- {gperf_offsetof(stringpool, 251), 28800},
-#line 16 "zonetab.list"
- {gperf_offsetof(stringpool, 252), -5*3600},
-#line 76 "zonetab.list"
- {gperf_offsetof(stringpool, 253), 1*3600},
+#line 320 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str242,-7200},
+#line 63 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243,-9*3600},
+#line 319 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244,-3600},
{-1},
-#line 164 "zonetab.list"
- {gperf_offsetof(stringpool, 255), 25200},
-#line 41 "zonetab.list"
- {gperf_offsetof(stringpool, 256), -9*3600},
+#line 249 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str246,25200},
+#line 248 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str247,28800},
+#line 150 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str248, -7200},
+#line 21 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, -6*3600},
+#line 253 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str250,50400},
+#line 168 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, 28800},
+#line 19 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str252, -5*3600},
+#line 79 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str253, 1*3600},
{-1},
-#line 171 "zonetab.list"
- {gperf_offsetof(stringpool, 258), 46800},
-#line 211 "zonetab.list"
- {gperf_offsetof(stringpool, 259),-36000},
+#line 167 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str255, 25200},
+#line 44 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, -9*3600},
{-1},
-#line 308 "zonetab.list"
- {gperf_offsetof(stringpool, 261),-14400},
-#line 119 "zonetab.list"
- {gperf_offsetof(stringpool, 262), 14400},
-#line 123 "zonetab.list"
- {gperf_offsetof(stringpool, 263), 3600},
-#line 28 "zonetab.list"
- {gperf_offsetof(stringpool, 264), 8*3600},
-#line 124 "zonetab.list"
- {gperf_offsetof(stringpool, 265), 3600},
-#line 153 "zonetab.list"
- {gperf_offsetof(stringpool, 266), -12600},
-#line 110 "zonetab.list"
- {gperf_offsetof(stringpool, 267), 10800},
-#line 289 "zonetab.list"
- {gperf_offsetof(stringpool, 268),14400},
-#line 112 "zonetab.list"
- {gperf_offsetof(stringpool, 269), 10800},
-#line 111 "zonetab.list"
- {gperf_offsetof(stringpool, 270), 14400},
-#line 216 "zonetab.list"
- {gperf_offsetof(stringpool, 271),36000},
+#line 174 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str258, 46800},
+#line 214 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str259,-36000},
{-1},
#line 311 "zonetab.list"
- {gperf_offsetof(stringpool, 273),21600},
-#line 66 "zonetab.list"
- {gperf_offsetof(stringpool, 274),-10*3600},
-#line 151 "zonetab.list"
- {gperf_offsetof(stringpool, 275), 20700},
-#line 267 "zonetab.list"
- {gperf_offsetof(stringpool, 276),-39600},
-#line 225 "zonetab.list"
- {gperf_offsetof(stringpool, 277),-14400},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str261,-14400},
+#line 122 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, 14400},
+#line 126 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str263, 3600},
+#line 31 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str264, 8*3600},
+#line 127 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, 3600},
+#line 156 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str266, -12600},
+#line 113 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str267, 10800},
+#line 292 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str268,14400},
+#line 115 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str269, 10800},
+#line 114 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str270, 14400},
+#line 219 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271,36000},
{-1},
-#line 224 "zonetab.list"
- {gperf_offsetof(stringpool, 279),-10800},
-#line 67 "zonetab.list"
- {gperf_offsetof(stringpool, 280),-10*3600},
-#line 237 "zonetab.list"
- {gperf_offsetof(stringpool, 281),10800},
+#line 314 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273,21600},
+#line 69 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str274,-10*3600},
+#line 154 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str275, 20700},
+#line 270 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str276,-39600},
+#line 228 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str277,-14400},
+ {-1},
+#line 227 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str279,-10800},
+#line 70 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280,-10*3600},
+#line 240 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str281,10800},
{-1}, {-1},
-#line 297 "zonetab.list"
- {gperf_offsetof(stringpool, 284),32400},
-#line 175 "zonetab.list"
- {gperf_offsetof(stringpool, 285), 28800},
-#line 134 "zonetab.list"
- {gperf_offsetof(stringpool, 286), 7200},
-#line 149 "zonetab.list"
- {gperf_offsetof(stringpool, 287), 23400},
-#line 107 "zonetab.list"
- {gperf_offsetof(stringpool, 288),13*3600},
-#line 230 "zonetab.list"
- {gperf_offsetof(stringpool, 289),-10800},
-#line 307 "zonetab.list"
- {gperf_offsetof(stringpool, 290),18000},
+#line 300 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str284,32400},
+#line 178 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str285, 28800},
+#line 137 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str286, 7200},
+#line 152 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str287, 23400},
+#line 110 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str288,13*3600},
+#line 233 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289,-10800},
+#line 310 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str290,18000},
{-1}, {-1},
-#line 155 "zonetab.list"
- {gperf_offsetof(stringpool, 293), 25200},
-#line 258 "zonetab.list"
- {gperf_offsetof(stringpool, 294),18000},
-#line 227 "zonetab.list"
- {gperf_offsetof(stringpool, 295),-21600},
+#line 158 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str293, 25200},
#line 261 "zonetab.list"
- {gperf_offsetof(stringpool, 296),43200},
-#line 213 "zonetab.list"
- {gperf_offsetof(stringpool, 297),-3600},
-#line 154 "zonetab.list"
- {gperf_offsetof(stringpool, 298), 28800},
- {-1},
-#line 243 "zonetab.list"
- {gperf_offsetof(stringpool, 300),21600},
-#line 114 "zonetab.list"
- {gperf_offsetof(stringpool, 301), 34200},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str294,18000},
+#line 230 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str295,-21600},
+#line 264 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296,43200},
+#line 216 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str297,-3600},
#line 157 "zonetab.list"
- {gperf_offsetof(stringpool, 302), -28800},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str298, 28800},
{-1},
+#line 246 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str300,21600},
#line 117 "zonetab.list"
- {gperf_offsetof(stringpool, 304), -21600},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str301, 34200},
+#line 160 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str302, -28800},
{-1},
-#line 156 "zonetab.list"
- {gperf_offsetof(stringpool, 306), -14400},
-#line 116 "zonetab.list"
- {gperf_offsetof(stringpool, 307), -3600},
-#line 228 "zonetab.list"
- {gperf_offsetof(stringpool, 308),-32400},
-#line 294 "zonetab.list"
- {gperf_offsetof(stringpool, 309),18000},
-#line 37 "zonetab.list"
- {gperf_offsetof(stringpool, 310), -5*3600},
-#line 137 "zonetab.list"
- {gperf_offsetof(stringpool, 311), 7200},
-#line 58 "zonetab.list"
- {gperf_offsetof(stringpool, 312),-8*3600},
-#line 304 "zonetab.list"
- {gperf_offsetof(stringpool, 313),28800},
-#line 303 "zonetab.list"
- {gperf_offsetof(stringpool, 314),32400},
-#line 284 "zonetab.list"
- {gperf_offsetof(stringpool, 315),14400},
+#line 120 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str304, -21600},
{-1},
-#line 295 "zonetab.list"
- {gperf_offsetof(stringpool, 317),18000},
+#line 159 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str306, -14400},
+#line 119 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str307, -3600},
+#line 231 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str308,-32400},
+#line 297 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str309,18000},
+#line 40 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str310, -5*3600},
+#line 140 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str311, 7200},
+#line 61 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str312,-8*3600},
+#line 307 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str313,28800},
+#line 306 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str314,32400},
+#line 287 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str315,14400},
{-1},
-#line 166 "zonetab.list"
- {gperf_offsetof(stringpool, 319), 7200},
+#line 298 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str317,18000},
+ {-1},
+#line 169 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str319, 7200},
{-1}, {-1}, {-1}, {-1},
-#line 97 "zonetab.list"
- {gperf_offsetof(stringpool, 324), 8*3600},
+#line 100 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, 8*3600},
{-1},
-#line 50 "zonetab.list"
- {gperf_offsetof(stringpool, 326), -(1*3600+1800)},
-#line 285 "zonetab.list"
- {gperf_offsetof(stringpool, 327),-10800},
+#line 53 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str326, -(1*3600+1800)},
+#line 288 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str327,-10800},
{-1}, {-1},
-#line 287 "zonetab.list"
- {gperf_offsetof(stringpool, 330),14400},
+#line 290 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str330,14400},
{-1},
-#line 169 "zonetab.list"
- {gperf_offsetof(stringpool, 332), 36000},
+#line 172 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str332, 36000},
{-1},
-#line 235 "zonetab.list"
- {gperf_offsetof(stringpool, 334),25200},
-#line 234 "zonetab.list"
- {gperf_offsetof(stringpool, 335),28800},
+#line 238 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str334,25200},
+#line 237 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str335,28800},
{-1}, {-1},
-#line 232 "zonetab.list"
- {gperf_offsetof(stringpool, 338),-14400},
+#line 235 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str338,-14400},
{-1}, {-1}, {-1},
-#line 44 "zonetab.list"
- {gperf_offsetof(stringpool, 342), -12*3600},
-#line 61 "zonetab.list"
- {gperf_offsetof(stringpool, 343),-9*3600},
-#line 162 "zonetab.list"
- {gperf_offsetof(stringpool, 344), -14400},
-#line 141 "zonetab.list"
- {gperf_offsetof(stringpool, 345), -36000},
+#line 47 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str342, -12*3600},
+#line 64 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str343,-9*3600},
+#line 165 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str344, -14400},
+#line 144 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str345, -36000},
{-1},
-#line 306 "zonetab.list"
- {gperf_offsetof(stringpool, 347),-10800},
+#line 309 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str347,-10800},
{-1},
-#line 305 "zonetab.list"
- {gperf_offsetof(stringpool, 349),-7200},
+#line 308 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str349,-7200},
+#line 329 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str350,18000},
+#line 328 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str351,21600},
+#line 250 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str352,14400},
#line 326 "zonetab.list"
- {gperf_offsetof(stringpool, 350),18000},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str353,32400},
#line 325 "zonetab.list"
- {gperf_offsetof(stringpool, 351),21600},
-#line 247 "zonetab.list"
- {gperf_offsetof(stringpool, 352),14400},
-#line 323 "zonetab.list"
- {gperf_offsetof(stringpool, 353),32400},
-#line 322 "zonetab.list"
- {gperf_offsetof(stringpool, 354),36000},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str354,36000},
{-1}, {-1}, {-1},
-#line 63 "zonetab.list"
- {gperf_offsetof(stringpool, 358), -9*3600},
-#line 144 "zonetab.list"
- {gperf_offsetof(stringpool, 359), 7200},
+#line 66 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str358, -9*3600},
+#line 147 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str359, 7200},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 167 "zonetab.list"
- {gperf_offsetof(stringpool, 365), 21600},
+#line 170 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str365, 21600},
{-1},
-#line 180 "zonetab.list"
- {gperf_offsetof(stringpool, 367), 32400},
+#line 183 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str367, 32400},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 318 "zonetab.list"
- {gperf_offsetof(stringpool, 375),25200},
+#line 321 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str375,25200},
{-1},
-#line 115 "zonetab.list"
- {gperf_offsetof(stringpool, 377), 36000},
-#line 231 "zonetab.list"
- {gperf_offsetof(stringpool, 378),43200},
+#line 118 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str377, 36000},
+#line 234 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str378,43200},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 173 "zonetab.list"
- {gperf_offsetof(stringpool, 387), -25200},
+#line 176 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str387, -25200},
{-1}, {-1}, {-1},
-#line 310 "zonetab.list"
- {gperf_offsetof(stringpool, 391),36000},
-#line 309 "zonetab.list"
- {gperf_offsetof(stringpool, 392),39600},
+#line 313 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str391,36000},
+#line 312 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str392,39600},
{-1}, {-1},
-#line 140 "zonetab.list"
- {gperf_offsetof(stringpool, 395), 7200},
+#line 143 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str395, 7200},
{-1}, {-1},
-#line 168 "zonetab.list"
- {gperf_offsetof(stringpool, 398), 28800},
-#line 290 "zonetab.list"
- {gperf_offsetof(stringpool, 399),39600},
+#line 171 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, 28800},
+#line 293 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str399,39600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 118 "zonetab.list"
- {gperf_offsetof(stringpool, 408), -3600},
+#line 121 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str408, -3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 296 "zonetab.list"
- {gperf_offsetof(stringpool, 417),46800},
-#line 163 "zonetab.list"
- {gperf_offsetof(stringpool, 418), -39600},
+#line 299 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str417,46800},
+#line 166 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str418, -39600},
{-1}, {-1},
-#line 161 "zonetab.list"
- {gperf_offsetof(stringpool, 421), -18000},
+#line 164 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, -18000},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 312 "zonetab.list"
- {gperf_offsetof(stringpool, 427),39600},
-#line 69 "zonetab.list"
- {gperf_offsetof(stringpool, 428),-12*3600},
+#line 315 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str427,39600},
+#line 72 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str428,-12*3600},
{-1}, {-1}, {-1},
-#line 136 "zonetab.list"
- {gperf_offsetof(stringpool, 432), 43200},
+#line 139 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str432, 43200},
{-1}, {-1},
-#line 46 "zonetab.list"
- {gperf_offsetof(stringpool, 435), 0*3600},
+#line 49 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str435, 0*3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 145 "zonetab.list"
- {gperf_offsetof(stringpool, 443), 32400},
+#line 148 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str443, 32400},
{-1},
-#line 131 "zonetab.list"
- {gperf_offsetof(stringpool, 445), 7200},
+#line 134 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str445, 7200},
{-1}, {-1}, {-1},
-#line 292 "zonetab.list"
- {gperf_offsetof(stringpool, 449),10800},
+#line 295 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str449,10800},
{-1}, {-1},
-#line 150 "zonetab.list"
- {gperf_offsetof(stringpool, 452), 21600},
+#line 153 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str452, 21600},
{-1}, {-1},
-#line 302 "zonetab.list"
- {gperf_offsetof(stringpool, 455),43200},
+#line 305 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str455,43200},
{-1}, {-1},
-#line 176 "zonetab.list"
- {gperf_offsetof(stringpool, 458), 3600},
+#line 179 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str458, 3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 135 "zonetab.list"
- {gperf_offsetof(stringpool, 466), 18000},
+#line 138 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str466, 18000},
{-1},
-#line 174 "zonetab.list"
- {gperf_offsetof(stringpool, 468), 36000},
+#line 177 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str468, 36000},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 324 "zonetab.list"
- {gperf_offsetof(stringpool, 476),36000},
-#line 172 "zonetab.list"
- {gperf_offsetof(stringpool, 477), -18000},
+#line 327 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str476,36000},
+#line 175 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str477, -18000},
{-1}, {-1}, {-1}, {-1},
-#line 160 "zonetab.list"
- {gperf_offsetof(stringpool, 482), -10800},
+#line 163 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str482, -10800},
{-1}, {-1},
-#line 62 "zonetab.list"
- {gperf_offsetof(stringpool, 485), -9*3600},
-#line 159 "zonetab.list"
- {gperf_offsetof(stringpool, 486), 10800},
+#line 65 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str485, -9*3600},
+#line 162 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str486, 10800},
{-1}, {-1}, {-1}, {-1}, {-1},
-#line 233 "zonetab.list"
- {gperf_offsetof(stringpool, 492),28800},
+#line 236 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str492,28800},
{-1}, {-1}, {-1}, {-1},
-#line 158 "zonetab.list"
- {gperf_offsetof(stringpool, 497), 3600},
+#line 161 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str497, 3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 177 "zonetab.list"
- {gperf_offsetof(stringpool, 540), 3600},
+#line 180 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str540, 3600},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1},
-#line 59 "zonetab.list"
- {gperf_offsetof(stringpool, 563), -8*3600},
+#line 62 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str563, -8*3600},
{-1}, {-1},
-#line 104 "zonetab.list"
- {gperf_offsetof(stringpool, 566),12*3600},
-#line 139 "zonetab.list"
- {gperf_offsetof(stringpool, 567), 0},
+#line 107 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str566,12*3600},
+#line 142 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str567, 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},
-#line 138 "zonetab.list"
- {gperf_offsetof(stringpool, 619), -10800}
+#line 141 "zonetab.list"
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str619, -10800}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -1558,5 +1560,5 @@ zonetab (register const char *str, register size_t len)
}
return 0;
}
-#line 327 "zonetab.list"
+#line 330 "zonetab.list"
diff --git a/ext/date/zonetab.list b/ext/date/zonetab.list
index 748aec1d8a..63b6873447 100644
--- a/ext/date/zonetab.list
+++ b/ext/date/zonetab.list
@@ -1,4 +1,7 @@
%{
+#define GPERF_DOWNCASE 1
+#define GPERF_CASE_STRNCMP 1
+#define gperf_case_strncmp strncasecmp
struct zone {
int name;
int offset;
@@ -313,8 +316,8 @@ vut,39600
wakt,43200
warst,-10800
wft,43200
-wgst,-7200
-wgt,-10800
+wgst,-3600
+wgt,-7200
wib,25200
wit,32400
wita,28800
diff --git a/ext/digest/.document b/ext/digest/.document
new file mode 100644
index 0000000000..beab275b5a
--- /dev/null
+++ b/ext/digest/.document
@@ -0,0 +1,3 @@
+digest.c
+bubblebabble/bubblebabble.c
+*/*init.c
diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c
index 358ab416b9..dac603c0d7 100644
--- a/ext/digest/bubblebabble/bubblebabble.c
+++ b/ext/digest/bubblebabble/bubblebabble.c
@@ -129,15 +129,14 @@ Init_bubblebabble(void)
rb_require("digest");
- rb_mDigest = rb_path2class("Digest");
- rb_mDigest_Instance = rb_path2class("Digest::Instance");
- rb_cDigest_Class = rb_path2class("Digest::Class");
-
#if 0
rb_mDigest = rb_define_module("Digest");
rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance");
rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject);
#endif
+ rb_mDigest = rb_digest_namespace();
+ rb_mDigest_Instance = rb_const_get(rb_mDigest, rb_intern_const("Instance"));
+ rb_cDigest_Class = rb_const_get(rb_mDigest, rb_intern_const("Class"));
rb_define_module_function(rb_mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
rb_define_singleton_method(rb_cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
diff --git a/ext/digest/bubblebabble/depend b/ext/digest/bubblebabble/depend
index 6f0003a66d..02d88e960c 100644
--- a/ext/digest/bubblebabble/depend
+++ b/ext/digest/bubblebabble/depend
@@ -128,6 +128,7 @@ bubblebabble.o: $(hdrdir)/ruby/internal/intern/re.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/ruby.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/select.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+bubblebabble.o: $(hdrdir)/ruby/internal/intern/set.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/signal.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/sprintf.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ bubblebabble.o: $(hdrdir)/ruby/internal/special_consts.h
bubblebabble.o: $(hdrdir)/ruby/internal/static_assert.h
bubblebabble.o: $(hdrdir)/ruby/internal/stdalign.h
bubblebabble.o: $(hdrdir)/ruby/internal/stdbool.h
+bubblebabble.o: $(hdrdir)/ruby/internal/stdckdint.h
bubblebabble.o: $(hdrdir)/ruby/internal/symbol.h
bubblebabble.o: $(hdrdir)/ruby/internal/value.h
bubblebabble.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/defs.h b/ext/digest/defs.h
index 77a134f364..9b11f4eca9 100644
--- a/ext/digest/defs.h
+++ b/ext/digest/defs.h
@@ -16,4 +16,26 @@
# define __END_DECLS
#endif
+#define RB_DIGEST_DIAGNOSTIC(compiler, op, flag) _Pragma(STRINGIZE(compiler diagnostic op flag))
+#ifdef RBIMPL_WARNING_IGNORED
+# define RB_DIGEST_WARNING_IGNORED(flag) RBIMPL_WARNING_IGNORED(flag)
+# define RB_DIGEST_WARNING_PUSH() RBIMPL_WARNING_PUSH()
+# define RB_DIGEST_WARNING_POP() RBIMPL_WARNING_POP()
+#elif defined(__clang__)
+# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(clang, ignored, #flag)
+# define RB_DIGEST_WARNING_PUSH() _Pragma("clang diagnostic push")
+# define RB_DIGEST_WARNING_POP() _Pragma("clang diagnostic pop")
+#else /* __GNUC__ */
+# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(GCC, ignored, #flag)
+# define RB_DIGEST_WARNING_PUSH() _Pragma("GCC diagnostic push")
+# define RB_DIGEST_WARNING_POP() _Pragma("GCC diagnostic pop")
+#endif
+#ifdef RBIMPL_HAS_WARNING
+# define RB_DIGEST_HAS_WARNING(_) RBIMPL_HAS_WARNING(_)
+#elif defined(__has_warning)
+# define RB_DIGEST_HAS_WARNING(_) __has_warning(_)
+#else
+# define RB_DIGEST_HAS_WARNING(_) 0
+#endif
+
#endif /* DEFS_H */
diff --git a/ext/digest/depend b/ext/digest/depend
index 6df940a679..3eabb1d1d6 100644
--- a/ext/digest/depend
+++ b/ext/digest/depend
@@ -128,6 +128,7 @@ digest.o: $(hdrdir)/ruby/internal/intern/re.h
digest.o: $(hdrdir)/ruby/internal/intern/ruby.h
digest.o: $(hdrdir)/ruby/internal/intern/select.h
digest.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+digest.o: $(hdrdir)/ruby/internal/intern/set.h
digest.o: $(hdrdir)/ruby/internal/intern/signal.h
digest.o: $(hdrdir)/ruby/internal/intern/sprintf.h
digest.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ digest.o: $(hdrdir)/ruby/internal/special_consts.h
digest.o: $(hdrdir)/ruby/internal/static_assert.h
digest.o: $(hdrdir)/ruby/internal/stdalign.h
digest.o: $(hdrdir)/ruby/internal/stdbool.h
+digest.o: $(hdrdir)/ruby/internal/stdckdint.h
digest.o: $(hdrdir)/ruby/internal/symbol.h
digest.o: $(hdrdir)/ruby/internal/value.h
digest.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 68837a674c..28f6022754 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -534,14 +534,44 @@ rb_digest_class_init(VALUE self)
*
*
* rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
- * Data_Wrap_Struct(0, 0, 0, (void *)&sha1));
+ * rb_digest_make_metadata(&sha1));
*/
+#ifdef DIGEST_USE_RB_EXT_RESOLVE_SYMBOL
+static const rb_data_type_t metadata_type = {
+ "digest/metadata",
+ {0},
+};
+
+RUBY_FUNC_EXPORTED VALUE
+rb_digest_wrap_metadata(const rb_digest_metadata_t *meta)
+{
+ return rb_obj_freeze(TypedData_Wrap_Struct(0, &metadata_type, (void *)meta));
+}
+#endif
+
+static rb_digest_metadata_t *
+get_metadata_ptr(VALUE obj)
+{
+ rb_digest_metadata_t *algo;
+
+#ifdef DIGEST_USE_RB_EXT_RESOLVE_SYMBOL
+ if (!rb_typeddata_is_kind_of(obj, &metadata_type)) return 0;
+ algo = RTYPEDDATA_DATA(obj);
+#else
+# undef RUBY_UNTYPED_DATA_WARNING
+# define RUBY_UNTYPED_DATA_WARNING 0
+ Data_Get_Struct(obj, rb_digest_metadata_t, algo);
+#endif
+
+ return algo;
+}
+
static rb_digest_metadata_t *
get_digest_base_metadata(VALUE klass)
{
VALUE p;
- VALUE obj;
+ VALUE obj = Qnil;
rb_digest_metadata_t *algo;
for (p = klass; !NIL_P(p); p = rb_class_superclass(p)) {
@@ -554,8 +584,8 @@ get_digest_base_metadata(VALUE klass)
if (NIL_P(p))
rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
- if (!RB_TYPE_P(obj, T_DATA) || RTYPEDDATA_P(obj)) {
- wrong:
+ algo = get_metadata_ptr(obj);
+ if (!algo) {
if (p == klass)
rb_raise(rb_eTypeError, "%"PRIsVALUE"::metadata is not initialized properly",
klass);
@@ -564,12 +594,6 @@ get_digest_base_metadata(VALUE klass)
klass, p);
}
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
- Data_Get_Struct(obj, rb_digest_metadata_t, algo);
-
- if (!algo) goto wrong;
-
switch (algo->api_version) {
case 3:
break;
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 8a4c5b7e4e..c5c37583a6 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -40,7 +40,8 @@ rb_digest_##name##_update(void *ctx, unsigned char *ptr, size_t size) \
for (; size > stride; size -= stride, ptr += stride) { \
name##_Update(ctx, ptr, stride); \
} \
- if (size > 0) name##_Update(ctx, ptr, size); \
+ /* Since size <= stride, size should fit into an unsigned int */ \
+ if (size > 0) name##_Update(ctx, ptr, (unsigned int)size); \
}
#define DEFINE_FINISH_FUNC_FROM_FINAL(name) \
@@ -63,10 +64,43 @@ rb_id_metadata(void)
return rb_intern_const("metadata");
}
+#if !defined(HAVE_RB_EXT_RESOLVE_SYMBOL)
+#elif !defined(RUBY_UNTYPED_DATA_WARNING)
+# error RUBY_UNTYPED_DATA_WARNING is not defined
+#elif RUBY_UNTYPED_DATA_WARNING
+/* rb_ext_resolve_symbol() has been defined since Ruby 3.3, but digest
+ * bundled with 3.3 didn't use it. */
+# define DIGEST_USE_RB_EXT_RESOLVE_SYMBOL 1
+#endif
+
static inline VALUE
rb_digest_make_metadata(const rb_digest_metadata_t *meta)
{
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
+#if defined(EXTSTATIC) && EXTSTATIC
+ /* The extension is built as a static library, so safe to refer to
+ * rb_digest_wrap_metadata directly. */
+ extern VALUE rb_digest_wrap_metadata(const rb_digest_metadata_t *meta);
+ return rb_digest_wrap_metadata(meta);
+#else
+ /* The extension is built as a shared library, so we can't refer
+ * to rb_digest_wrap_metadata directly. */
+# ifdef DIGEST_USE_RB_EXT_RESOLVE_SYMBOL
+ /* If rb_ext_resolve_symbol() is available, use it to get the address of
+ * rb_digest_wrap_metadata. */
+ typedef VALUE (*wrapper_func_type)(const rb_digest_metadata_t *meta);
+ static wrapper_func_type wrapper;
+ if (!wrapper) {
+ wrapper = (wrapper_func_type)(uintptr_t)
+ rb_ext_resolve_symbol("digest.so", "rb_digest_wrap_metadata");
+ if (!wrapper) rb_raise(rb_eLoadError, "rb_digest_wrap_metadata not found");
+ }
+ return wrapper(meta);
+# else
+ /* If rb_ext_resolve_symbol() is not available, keep using untyped
+ * data. */
+# undef RUBY_UNTYPED_DATA_WARNING
+# define RUBY_UNTYPED_DATA_WARNING 0
return rb_obj_freeze(Data_Wrap_Struct(0, 0, 0, (void *)meta));
+# endif
+#endif
}
diff --git a/ext/digest/digest_conf.rb b/ext/digest/digest_conf.rb
index 36a7d75289..099d20fcbe 100644
--- a/ext/digest/digest_conf.rb
+++ b/ext/digest/digest_conf.rb
@@ -2,14 +2,16 @@
def digest_conf(name)
unless with_config("bundled-#{name}")
- cc = with_config("common-digest")
- if cc != false or /\b#{name}\b/ =~ cc
- if File.exist?("#$srcdir/#{name}cc.h") and
- have_header("CommonCrypto/CommonDigest.h")
- $defs << "-D#{name.upcase}_USE_COMMONDIGEST"
- $headers << "#{name}cc.h"
- return :commondigest
- end
+ case cc = with_config("common-digest", true)
+ when true, false
+ else
+ cc = cc.split(/[\s,]++/).any? {|pat| File.fnmatch?(pat, name)}
+ end
+ if cc and File.exist?("#$srcdir/#{name}cc.h") and
+ have_header("CommonCrypto/CommonDigest.h")
+ $defs << "-D#{name.upcase}_USE_COMMONDIGEST"
+ $headers << "#{name}cc.h"
+ return :commondigest
end
end
$objs << "#{name}.#{$OBJEXT}"
diff --git a/ext/digest/lib/digest/version.rb b/ext/digest/lib/digest/version.rb
index 42fd7acf6e..a56e80c54e 100644
--- a/ext/digest/lib/digest/version.rb
+++ b/ext/digest/lib/digest/version.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
module Digest
- VERSION = "3.1.1"
+ # The version string
+ VERSION = "3.2.1"
end
diff --git a/ext/digest/md5/depend b/ext/digest/md5/depend
index da1b345999..d1c25c28c8 100644
--- a/ext/digest/md5/depend
+++ b/ext/digest/md5/depend
@@ -131,6 +131,7 @@ md5.o: $(hdrdir)/ruby/internal/intern/re.h
md5.o: $(hdrdir)/ruby/internal/intern/ruby.h
md5.o: $(hdrdir)/ruby/internal/intern/select.h
md5.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+md5.o: $(hdrdir)/ruby/internal/intern/set.h
md5.o: $(hdrdir)/ruby/internal/intern/signal.h
md5.o: $(hdrdir)/ruby/internal/intern/sprintf.h
md5.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -150,6 +151,7 @@ md5.o: $(hdrdir)/ruby/internal/special_consts.h
md5.o: $(hdrdir)/ruby/internal/static_assert.h
md5.o: $(hdrdir)/ruby/internal/stdalign.h
md5.o: $(hdrdir)/ruby/internal/stdbool.h
+md5.o: $(hdrdir)/ruby/internal/stdckdint.h
md5.o: $(hdrdir)/ruby/internal/symbol.h
md5.o: $(hdrdir)/ruby/internal/value.h
md5.o: $(hdrdir)/ruby/internal/value_type.h
@@ -292,6 +294,7 @@ md5init.o: $(hdrdir)/ruby/internal/intern/re.h
md5init.o: $(hdrdir)/ruby/internal/intern/ruby.h
md5init.o: $(hdrdir)/ruby/internal/intern/select.h
md5init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+md5init.o: $(hdrdir)/ruby/internal/intern/set.h
md5init.o: $(hdrdir)/ruby/internal/intern/signal.h
md5init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
md5init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -311,6 +314,7 @@ md5init.o: $(hdrdir)/ruby/internal/special_consts.h
md5init.o: $(hdrdir)/ruby/internal/static_assert.h
md5init.o: $(hdrdir)/ruby/internal/stdalign.h
md5init.o: $(hdrdir)/ruby/internal/stdbool.h
+md5init.o: $(hdrdir)/ruby/internal/stdckdint.h
md5init.o: $(hdrdir)/ruby/internal/symbol.h
md5init.o: $(hdrdir)/ruby/internal/value.h
md5init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/md5/md5cc.h b/ext/digest/md5/md5cc.h
index e34d7d5c11..a002c17604 100644
--- a/ext/digest/md5/md5cc.h
+++ b/ext/digest/md5/md5cc.h
@@ -1,8 +1,8 @@
#define COMMON_DIGEST_FOR_OPENSSL 1
#include <CommonCrypto/CommonDigest.h>
-#ifdef __clang__
-# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#ifdef __GNUC__
+RB_DIGEST_WARNING_IGNORED(-Wdeprecated-declarations)
/* Suppress deprecation warnings of MD5 from Xcode 11.1 */
/* Although we know MD5 is deprecated too, provide just for backward
* compatibility, as well as Apple does. */
@@ -17,3 +17,11 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(MD5)
#undef MD5_Finish
#define MD5_Update rb_digest_MD5_update
#define MD5_Finish rb_digest_MD5_finish
+
+/*
+ * Pre-10.6 defines are with args, which don't match the argless use in
+ * the function pointer inits. Thus, we redefine MD5_Init as well.
+ * This is a NOP on 10.6+.
+ */
+#undef MD5_Init
+#define MD5_Init CC_MD5_Init
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
index 52cba78bf1..c919060587 100644
--- a/ext/digest/md5/md5init.c
+++ b/ext/digest/md5/md5init.c
@@ -3,6 +3,7 @@
#include <ruby/ruby.h>
#include "../digest.h"
+#include "../defs.h"
#if defined(MD5_USE_COMMONDIGEST)
#include "md5cc.h"
#else
@@ -53,9 +54,8 @@ Init_md5(void)
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
mDigest = rb_digest_namespace();
- cDigest_Base = rb_path2class("Digest::Base");
+ cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
-
rb_iv_set(cDigest_MD5, "metadata", rb_digest_make_metadata(&md5));
}
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index abfa08b023..aec484f7b3 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -131,6 +131,7 @@ rmd160.o: $(hdrdir)/ruby/internal/intern/re.h
rmd160.o: $(hdrdir)/ruby/internal/intern/ruby.h
rmd160.o: $(hdrdir)/ruby/internal/intern/select.h
rmd160.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rmd160.o: $(hdrdir)/ruby/internal/intern/set.h
rmd160.o: $(hdrdir)/ruby/internal/intern/signal.h
rmd160.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rmd160.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -150,6 +151,7 @@ rmd160.o: $(hdrdir)/ruby/internal/special_consts.h
rmd160.o: $(hdrdir)/ruby/internal/static_assert.h
rmd160.o: $(hdrdir)/ruby/internal/stdalign.h
rmd160.o: $(hdrdir)/ruby/internal/stdbool.h
+rmd160.o: $(hdrdir)/ruby/internal/stdckdint.h
rmd160.o: $(hdrdir)/ruby/internal/symbol.h
rmd160.o: $(hdrdir)/ruby/internal/value.h
rmd160.o: $(hdrdir)/ruby/internal/value_type.h
@@ -292,6 +294,7 @@ rmd160init.o: $(hdrdir)/ruby/internal/intern/re.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/ruby.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/select.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+rmd160init.o: $(hdrdir)/ruby/internal/intern/set.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/signal.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -311,6 +314,7 @@ rmd160init.o: $(hdrdir)/ruby/internal/special_consts.h
rmd160init.o: $(hdrdir)/ruby/internal/static_assert.h
rmd160init.o: $(hdrdir)/ruby/internal/stdalign.h
rmd160init.o: $(hdrdir)/ruby/internal/stdbool.h
+rmd160init.o: $(hdrdir)/ruby/internal/stdckdint.h
rmd160init.o: $(hdrdir)/ruby/internal/symbol.h
rmd160init.o: $(hdrdir)/ruby/internal/value.h
rmd160init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/rmd160/rmd160init.c b/ext/digest/rmd160/rmd160init.c
index 2ae81ec4d6..e4b707ed9e 100644
--- a/ext/digest/rmd160/rmd160init.c
+++ b/ext/digest/rmd160/rmd160init.c
@@ -49,9 +49,8 @@ Init_rmd160(void)
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
mDigest = rb_digest_namespace();
- cDigest_Base = rb_path2class("Digest::Base");
+ cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
-
rb_iv_set(cDigest_RMD160, "metadata", rb_digest_make_metadata(&rmd160));
}
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
index d17338e92b..e6bd9d8f73 100644
--- a/ext/digest/sha1/depend
+++ b/ext/digest/sha1/depend
@@ -131,6 +131,7 @@ sha1.o: $(hdrdir)/ruby/internal/intern/re.h
sha1.o: $(hdrdir)/ruby/internal/intern/ruby.h
sha1.o: $(hdrdir)/ruby/internal/intern/select.h
sha1.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sha1.o: $(hdrdir)/ruby/internal/intern/set.h
sha1.o: $(hdrdir)/ruby/internal/intern/signal.h
sha1.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sha1.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -150,6 +151,7 @@ sha1.o: $(hdrdir)/ruby/internal/special_consts.h
sha1.o: $(hdrdir)/ruby/internal/static_assert.h
sha1.o: $(hdrdir)/ruby/internal/stdalign.h
sha1.o: $(hdrdir)/ruby/internal/stdbool.h
+sha1.o: $(hdrdir)/ruby/internal/stdckdint.h
sha1.o: $(hdrdir)/ruby/internal/symbol.h
sha1.o: $(hdrdir)/ruby/internal/value.h
sha1.o: $(hdrdir)/ruby/internal/value_type.h
@@ -292,6 +294,7 @@ sha1init.o: $(hdrdir)/ruby/internal/intern/re.h
sha1init.o: $(hdrdir)/ruby/internal/intern/ruby.h
sha1init.o: $(hdrdir)/ruby/internal/intern/select.h
sha1init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sha1init.o: $(hdrdir)/ruby/internal/intern/set.h
sha1init.o: $(hdrdir)/ruby/internal/intern/signal.h
sha1init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sha1init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -311,6 +314,7 @@ sha1init.o: $(hdrdir)/ruby/internal/special_consts.h
sha1init.o: $(hdrdir)/ruby/internal/static_assert.h
sha1init.o: $(hdrdir)/ruby/internal/stdalign.h
sha1init.o: $(hdrdir)/ruby/internal/stdbool.h
+sha1init.o: $(hdrdir)/ruby/internal/stdckdint.h
sha1init.o: $(hdrdir)/ruby/internal/symbol.h
sha1init.o: $(hdrdir)/ruby/internal/value.h
sha1init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/sha1/sha1.c b/ext/digest/sha1/sha1.c
index 5311227549..003c87d224 100644
--- a/ext/digest/sha1/sha1.c
+++ b/ext/digest/sha1/sha1.c
@@ -220,20 +220,28 @@ int SHA1_Init(SHA1_CTX *context)
*/
void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
{
- uint32_t i, j;
+ size_t i;
+ uint32_t j;
_DIAGASSERT(context != 0);
_DIAGASSERT(data != 0);
j = context->count[0];
if ((context->count[0] += len << 3) < j)
- context->count[1] += (len>>29)+1;
+ context->count[1]++;
+ context->count[1] += (uint32_t)(len >> 29);
j = (j >> 3) & 63;
if ((j + len) > 63) {
(void)memcpy(&context->buffer[j], data, (i = 64-j));
SHA1_Transform(context->state, context->buffer);
- for ( ; i + 63 < len; i += 64)
+ for ( ; i + 63 < len; i += 64) {
+ RB_DIGEST_WARNING_PUSH();
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 11
+ RB_DIGEST_WARNING_IGNORED(-Wstringop-overread);
+#endif
SHA1_Transform(context->state, &data[i]);
+ RB_DIGEST_WARNING_POP();
+ }
j = 0;
} else {
i = 0;
diff --git a/ext/digest/sha1/sha1cc.h b/ext/digest/sha1/sha1cc.h
index 2ed8d646ab..f39ecc6234 100644
--- a/ext/digest/sha1/sha1cc.h
+++ b/ext/digest/sha1/sha1cc.h
@@ -12,3 +12,11 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(SHA1)
#undef SHA1_Finish
#define SHA1_Update rb_digest_SHA1_update
#define SHA1_Finish rb_digest_SHA1_finish
+
+/*
+ * Pre-10.6 defines are with args, which don't match the argless use in
+ * the function pointer inits. Thus, we redefine SHA1_Init as well.
+ * This is a NOP on 10.6+.
+ */
+#undef SHA1_Init
+#define SHA1_Init CC_SHA1_Init
diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c
index f7047bc6d3..c39959f428 100644
--- a/ext/digest/sha1/sha1init.c
+++ b/ext/digest/sha1/sha1init.c
@@ -55,9 +55,8 @@ Init_sha1(void)
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
mDigest = rb_digest_namespace();
- cDigest_Base = rb_path2class("Digest::Base");
+ cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
-
rb_iv_set(cDigest_SHA1, "metadata", rb_digest_make_metadata(&sha1));
}
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
index 7b88b6411f..2b74776b3e 100644
--- a/ext/digest/sha2/depend
+++ b/ext/digest/sha2/depend
@@ -131,6 +131,7 @@ sha2.o: $(hdrdir)/ruby/internal/intern/re.h
sha2.o: $(hdrdir)/ruby/internal/intern/ruby.h
sha2.o: $(hdrdir)/ruby/internal/intern/select.h
sha2.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sha2.o: $(hdrdir)/ruby/internal/intern/set.h
sha2.o: $(hdrdir)/ruby/internal/intern/signal.h
sha2.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sha2.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -150,6 +151,7 @@ sha2.o: $(hdrdir)/ruby/internal/special_consts.h
sha2.o: $(hdrdir)/ruby/internal/static_assert.h
sha2.o: $(hdrdir)/ruby/internal/stdalign.h
sha2.o: $(hdrdir)/ruby/internal/stdbool.h
+sha2.o: $(hdrdir)/ruby/internal/stdckdint.h
sha2.o: $(hdrdir)/ruby/internal/symbol.h
sha2.o: $(hdrdir)/ruby/internal/value.h
sha2.o: $(hdrdir)/ruby/internal/value_type.h
@@ -292,6 +294,7 @@ sha2init.o: $(hdrdir)/ruby/internal/intern/re.h
sha2init.o: $(hdrdir)/ruby/internal/intern/ruby.h
sha2init.o: $(hdrdir)/ruby/internal/intern/select.h
sha2init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sha2init.o: $(hdrdir)/ruby/internal/intern/set.h
sha2init.o: $(hdrdir)/ruby/internal/intern/signal.h
sha2init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sha2init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -311,6 +314,7 @@ sha2init.o: $(hdrdir)/ruby/internal/special_consts.h
sha2init.o: $(hdrdir)/ruby/internal/static_assert.h
sha2init.o: $(hdrdir)/ruby/internal/stdalign.h
sha2init.o: $(hdrdir)/ruby/internal/stdbool.h
+sha2init.o: $(hdrdir)/ruby/internal/stdckdint.h
sha2init.o: $(hdrdir)/ruby/internal/symbol.h
sha2init.o: $(hdrdir)/ruby/internal/value.h
sha2init.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/digest/sha2/sha2cc.h b/ext/digest/sha2/sha2cc.h
index 3f99604465..1245a2e2c7 100644
--- a/ext/digest/sha2/sha2cc.h
+++ b/ext/digest/sha2/sha2cc.h
@@ -1,6 +1,33 @@
#define COMMON_DIGEST_FOR_OPENSSL 1
#include <CommonCrypto/CommonDigest.h>
+/*
+ * Prior to 10.5, OpenSSL-compatible definitions are missing for
+ * SHA2 macros, though the CC_ versions are present.
+ * Add the missing definitions we actually use here if needed.
+ * Note that the definitions are the argless 10.6+-style.
+ * The weird CTX mismatch is copied from the 10.6 header.
+ */
+#ifndef SHA256_DIGEST_LENGTH
+#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
+#define SHA256_CTX CC_SHA256_CTX
+#define SHA256_Update CC_SHA256_Update
+#define SHA256_Final CC_SHA256_Final
+#endif /* !defined SHA256_DIGEST_LENGTH */
+
+#ifndef SHA384_DIGEST_LENGTH
+#define SHA384_DIGEST_LENGTH CC_SHA384_DIGEST_LENGTH
+#define SHA512_CTX CC_SHA512_CTX
+#define SHA384_Update CC_SHA384_Update
+#define SHA384_Final CC_SHA384_Final
+#endif /* !defined SHA384_DIGEST_LENGTH */
+
+#ifndef SHA512_DIGEST_LENGTH
+#define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH
+#define SHA512_Update CC_SHA512_Update
+#define SHA512_Final CC_SHA512_Final
+#endif /* !defined SHA512_DIGEST_LENGTH */
+
#define SHA256_BLOCK_LENGTH CC_SHA256_BLOCK_BYTES
#define SHA384_BLOCK_LENGTH CC_SHA384_BLOCK_BYTES
#define SHA512_BLOCK_LENGTH CC_SHA512_BLOCK_BYTES
@@ -29,3 +56,15 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(SHA512)
#undef SHA512_Finish
#define SHA512_Update rb_digest_SHA512_update
#define SHA512_Finish rb_digest_SHA512_finish
+
+/*
+ * Pre-10.6 defines are with args, which don't match the argless use in
+ * the function pointer inits. Thus, we redefine SHA*_Init as well.
+ * This is a NOP on 10.6+.
+ */
+#undef SHA256_Init
+#define SHA256_Init CC_SHA256_Init
+#undef SHA384_Init
+#define SHA384_Init CC_SHA384_Init
+#undef SHA512_Init
+#define SHA512_Init CC_SHA512_Init
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
index 94cccf3feb..3923e3724c 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -25,29 +25,50 @@ static const rb_digest_metadata_t sha##bitlen = { \
FOREACH_BITLEN(DEFINE_ALGO_METADATA)
/*
+ * Document-class: Digest::SHA256 < Digest::Base
+ *
* Classes for calculating message digests using the SHA-256/384/512
* Secure Hash Algorithm(s) by NIST (the US' National Institute of
* Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
+ */
+/*
+ * Document-class: Digest::SHA384 < Digest::Base
+ *
+ * Classes for calculating message digests using the SHA-256/384/512
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
+ * Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
+ */
+/*
+ * Document-class: Digest::SHA512 < Digest::Base
+ *
+ * Classes for calculating message digests using the SHA-256/384/512
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
+ * Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
*/
void
Init_sha2(void)
{
- VALUE mDigest, cDigest_Base;
+ VALUE mDigest, cDigest_Base, cDigest_SHA2;
ID id_metadata = rb_id_metadata();
-#define DECLARE_ALGO_CLASS(bitlen) \
- VALUE cDigest_SHA##bitlen;
-
- FOREACH_BITLEN(DECLARE_ALGO_CLASS)
-
+#if 0
+ mDigest = rb_define_module("Digest"); /* let rdoc know */
+#endif
mDigest = rb_digest_namespace();
- cDigest_Base = rb_path2class("Digest::Base");
+ cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
+
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA256", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha256));
-#define DEFINE_ALGO_CLASS(bitlen) \
- cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
-\
- rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
- rb_digest_make_metadata(&sha##bitlen));
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA384", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha384));
- FOREACH_BITLEN(DEFINE_ALGO_CLASS)
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA512", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha512));
}
diff --git a/ext/digest/test.sh b/ext/digest/test.sh
deleted file mode 100644
index 328c7575e6..0000000000
--- a/ext/digest/test.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# $RoughId: test.sh,v 1.5 2001/07/13 15:38:27 knu Exp $
-# $Id$
-
-RUBY=${RUBY:=ruby}
-MAKE=${MAKE:=make}
-CFLAGS=${CFLAGS:=-Wall}
-
-${RUBY} extconf.rb --with-cflags="${CFLAGS}"
-${MAKE} clean
-${MAKE}
-
-for algo in md5 rmd160 sha1 sha2; do
- args=--with-cflags="${CFLAGS}"
-
- if [ $WITH_BUNDLED_ENGINES ]; then
- args="$args --with-bundled-$algo"
- fi
-
- (cd $algo &&
- ${RUBY} extconf.rb $args;
- ${MAKE} clean;
- ${MAKE})
- ln -sf ../../$algo/$algo.so lib/digest/
-done
-
-${RUBY} -I. -I./lib ../../test/digest/test_digest.rb
-
-rm lib/digest/*.so
diff --git a/ext/erb/escape/escape.c b/ext/erb/escape/escape.c
index 67b2d1ef34..1794fc30eb 100644
--- a/ext/erb/escape/escape.c
+++ b/ext/erb/escape/escape.c
@@ -39,35 +39,50 @@ static VALUE
optimized_escape_html(VALUE str)
{
VALUE vbuf;
- char *buf = ALLOCV_N(char, vbuf, escaped_length(str));
+ char *buf = NULL;
const char *cstr = RSTRING_PTR(str);
const char *end = cstr + RSTRING_LEN(str);
- char *dest = buf;
+ const char *segment_start = cstr;
+ char *dest = NULL;
while (cstr < end) {
const unsigned char c = *cstr++;
uint8_t len = html_escape_table[c].len;
if (len) {
+ size_t segment_len = cstr - segment_start - 1;
+ if (!buf) {
+ buf = ALLOCV_N(char, vbuf, escaped_length(str));
+ dest = buf;
+ }
+ if (segment_len) {
+ memcpy(dest, segment_start, segment_len);
+ dest += segment_len;
+ }
+ segment_start = cstr;
memcpy(dest, html_escape_table[c].str, len);
dest += len;
}
- else {
- *dest++ = c;
- }
}
-
VALUE escaped = str;
- if (RSTRING_LEN(str) < (dest - buf)) {
+ if (buf) {
+ size_t segment_len = cstr - segment_start;
+ if (segment_len) {
+ memcpy(dest, segment_start, segment_len);
+ dest += segment_len;
+ }
escaped = rb_str_new(buf, dest - buf);
preserve_original_state(str, escaped);
+ ALLOCV_END(vbuf);
}
- ALLOCV_END(vbuf);
return escaped;
}
-// ERB::Util.html_escape is different from CGI.escapeHTML in the following two parts:
-// * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
-// * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
+/*
+ * ERB::Util.html_escape is similar to CGI.escapeHTML but different in the following two parts:
+ *
+ * * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
+ * * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
+ */
static VALUE
erb_escape_html(VALUE self, VALUE str)
{
@@ -86,6 +101,10 @@ erb_escape_html(VALUE self, VALUE str)
void
Init_escape(void)
{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
rb_cERB = rb_define_class("ERB", rb_cObject);
rb_mEscape = rb_define_module_under(rb_cERB, "Escape");
rb_define_module_function(rb_mEscape, "html_escape", erb_escape_html, 1);
diff --git a/ext/erb/escape/extconf.rb b/ext/erb/escape/extconf.rb
index c1002548ad..b211a9783f 100644
--- a/ext/erb/escape/extconf.rb
+++ b/ext/erb/escape/extconf.rb
@@ -1,7 +1,9 @@
require 'mkmf'
-if RUBY_ENGINE == 'truffleruby'
+case RUBY_ENGINE
+when 'jruby', 'truffleruby'
File.write('Makefile', dummy_makefile($srcdir).join)
else
+ have_func("rb_ext_ractor_safe", "ruby.h")
create_makefile 'erb/escape'
end
diff --git a/ext/etc/.document b/ext/etc/.document
new file mode 100644
index 0000000000..9bbea23b92
--- /dev/null
+++ b/ext/etc/.document
@@ -0,0 +1,2 @@
+etc.c
+constdefs.h
diff --git a/ext/etc/depend b/ext/etc/depend
index 00787b6aaf..77fe56a6bf 100644
--- a/ext/etc/depend
+++ b/ext/etc/depend
@@ -143,6 +143,7 @@ etc.o: $(hdrdir)/ruby/internal/intern/re.h
etc.o: $(hdrdir)/ruby/internal/intern/ruby.h
etc.o: $(hdrdir)/ruby/internal/intern/select.h
etc.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+etc.o: $(hdrdir)/ruby/internal/intern/set.h
etc.o: $(hdrdir)/ruby/internal/intern/signal.h
etc.o: $(hdrdir)/ruby/internal/intern/sprintf.h
etc.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -162,6 +163,7 @@ etc.o: $(hdrdir)/ruby/internal/special_consts.h
etc.o: $(hdrdir)/ruby/internal/static_assert.h
etc.o: $(hdrdir)/ruby/internal/stdalign.h
etc.o: $(hdrdir)/ruby/internal/stdbool.h
+etc.o: $(hdrdir)/ruby/internal/stdckdint.h
etc.o: $(hdrdir)/ruby/internal/symbol.h
etc.o: $(hdrdir)/ruby/internal/value.h
etc.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 6c7145b40b..8d50a96a62 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -54,9 +54,11 @@ static VALUE sGroup;
# include <stdlib.h>
# endif
#endif
-char *getlogin();
+RUBY_EXTERN char *getlogin(void);
-#define RUBY_ETC_VERSION "1.4.2"
+#define RUBY_ETC_VERSION "1.4.6"
+
+#define SYMBOL_LIT(str) ID2SYM(rb_intern_const(str ""))
#ifdef HAVE_RB_DEPRECATE_CONSTANT
void rb_deprecate_constant(VALUE mod, const char *name);
@@ -66,6 +68,17 @@ void rb_deprecate_constant(VALUE mod, const char *name);
#include "constdefs.h"
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
#ifdef HAVE_RUBY_ATOMIC_H
# include "ruby/atomic.h"
#else
@@ -192,7 +205,7 @@ setup_passwd(struct passwd *pwd)
#endif
/* call-seq:
- * getpwuid(uid) -> Passwd
+ * getpwuid(uid) -> Etc::Passwd
*
* Returns the <tt>/etc/passwd</tt> information for the user with the given
* integer +uid+.
@@ -204,7 +217,7 @@ setup_passwd(struct passwd *pwd)
*
* See the unix manpage for <code>getpwuid(3)</code> for more detail.
*
- * === Example:
+ * *Example:*
*
* Etc.getpwuid(0)
* #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
@@ -232,7 +245,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
}
/* call-seq:
- * getpwnam(name) -> Passwd
+ * getpwnam(name) -> Etc::Passwd
*
* Returns the <tt>/etc/passwd</tt> information for the user with specified
* login +name+.
@@ -241,7 +254,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
*
* See the unix manpage for <code>getpwnam(3)</code> for more detail.
*
- * === Example:
+ * *Example:*
*
* Etc.getpwnam('root')
* #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
@@ -296,8 +309,8 @@ each_passwd(void)
#endif
/* call-seq:
- * Etc.passwd { |struct| block } -> Passwd
- * Etc.passwd -> Passwd
+ * passwd { |struct| block }
+ * passwd -> Etc::Passwd
*
* Provides a convenient Ruby iterator which executes a block for each entry
* in the <tt>/etc/passwd</tt> file.
@@ -306,7 +319,7 @@ each_passwd(void)
*
* See ::getpwent above for details.
*
- * Example:
+ * *Example:*
*
* require 'etc'
*
@@ -332,7 +345,7 @@ etc_passwd(VALUE obj)
}
/* call-seq:
- * Etc::Passwd.each { |struct| block } -> Passwd
+ * Etc::Passwd.each { |struct| block } -> Etc::Passwd
* Etc::Passwd.each -> Enumerator
*
* Iterates for each entry in the <tt>/etc/passwd</tt> file if a block is
@@ -344,7 +357,7 @@ etc_passwd(VALUE obj)
*
* See Etc.getpwent above for details.
*
- * Example:
+ * *Example:*
*
* require 'etc'
*
@@ -366,7 +379,10 @@ etc_each_passwd(VALUE obj)
return obj;
}
-/* Resets the process of reading the <tt>/etc/passwd</tt> file, so that the
+/* call-seq:
+ * setpwent
+ *
+ * Resets the process of reading the <tt>/etc/passwd</tt> file, so that the
* next call to ::getpwent will return the first entry again.
*/
static VALUE
@@ -378,7 +394,10 @@ etc_setpwent(VALUE obj)
return Qnil;
}
-/* Ends the process of scanning through the <tt>/etc/passwd</tt> file begun
+/* call-seq:
+ * endpwent
+ *
+ * Ends the process of scanning through the <tt>/etc/passwd</tt> file begun
* with ::getpwent, and closes the file.
*/
static VALUE
@@ -390,7 +409,10 @@ etc_endpwent(VALUE obj)
return Qnil;
}
-/* Returns an entry from the <tt>/etc/passwd</tt> file.
+/* call-seq:
+ * getpwent -> Etc::Passwd
+ *
+ * Returns an entry from the <tt>/etc/passwd</tt> file.
*
* The first time it is called it opens the file and returns the first entry;
* each successive call returns the next entry, or +nil+ if the end of the file
@@ -438,7 +460,7 @@ setup_group(struct group *grp)
#endif
/* call-seq:
- * getgrgid(group_id) -> Group
+ * getgrgid(group_id) -> Etc::Group
*
* Returns information about the group with specified integer +group_id+,
* as found in <tt>/etc/group</tt>.
@@ -447,7 +469,7 @@ setup_group(struct group *grp)
*
* See the unix manpage for <code>getgrgid(3)</code> for more detail.
*
- * === Example:
+ * *Example:*
*
* Etc.getgrgid(100)
* #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
@@ -476,7 +498,7 @@ etc_getgrgid(int argc, VALUE *argv, VALUE obj)
}
/* call-seq:
- * getgrnam(name) -> Group
+ * getgrnam(name) -> Etc::Group
*
* Returns information about the group with specified +name+, as found in
* <tt>/etc/group</tt>.
@@ -485,7 +507,7 @@ etc_getgrgid(int argc, VALUE *argv, VALUE obj)
*
* See the unix manpage for <code>getgrnam(3)</code> for more detail.
*
- * === Example:
+ * *Example:*
*
* Etc.getgrnam('users')
* #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
@@ -518,7 +540,6 @@ group_ensure(VALUE _)
return Qnil;
}
-
static VALUE
group_iterate(VALUE _)
{
@@ -541,14 +562,18 @@ each_group(void)
}
#endif
-/* Provides a convenient Ruby iterator which executes a block for each entry
+/* call-seq:
+ * group { |struct| block }
+ * group -> Etc::Group
+ *
+ * Provides a convenient Ruby iterator which executes a block for each entry
* in the <tt>/etc/group</tt> file.
*
* The code block is passed an Group struct.
*
* See ::getgrent above for details.
*
- * Example:
+ * *Example:*
*
* require 'etc'
*
@@ -575,7 +600,7 @@ etc_group(VALUE obj)
#ifdef HAVE_GETGRENT
/* call-seq:
- * Etc::Group.each { |group| block } -> obj
+ * Etc::Group.each { |group| block } -> Etc::Group
* Etc::Group.each -> Enumerator
*
* Iterates for each entry in the <tt>/etc/group</tt> file if a block is
@@ -585,7 +610,7 @@ etc_group(VALUE obj)
*
* The code block is passed a Group struct.
*
- * Example:
+ * *Example:*
*
* require 'etc'
*
@@ -606,7 +631,10 @@ etc_each_group(VALUE obj)
}
#endif
-/* Resets the process of reading the <tt>/etc/group</tt> file, so that the
+/* call-seq:
+ * setgrent
+ *
+ * Resets the process of reading the <tt>/etc/group</tt> file, so that the
* next call to ::getgrent will return the first entry again.
*/
static VALUE
@@ -618,7 +646,10 @@ etc_setgrent(VALUE obj)
return Qnil;
}
-/* Ends the process of scanning through the <tt>/etc/group</tt> file begun
+/* call-seq:
+ * endgrent
+ *
+ * Ends the process of scanning through the <tt>/etc/group</tt> file begun
* by ::getgrent, and closes the file.
*/
static VALUE
@@ -630,7 +661,10 @@ etc_endgrent(VALUE obj)
return Qnil;
}
-/* Returns an entry from the <tt>/etc/group</tt> file.
+/* call-seq:
+ * getgrent -> Etc::Group
+ *
+ * Returns an entry from the <tt>/etc/group</tt> file.
*
* The first time it is called it opens the file and returns the first entry;
* each successive call returns the next entry, or +nil+ if the end of the file
@@ -659,9 +693,21 @@ etc_getgrent(VALUE obj)
VALUE rb_w32_special_folder(int type);
UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
+#elif defined(LOAD_RELATIVE)
+static inline VALUE
+rbconfig(void)
+{
+ VALUE config;
+ rb_require("rbconfig");
+ config = rb_const_get(rb_path2class("RbConfig"), rb_intern_const("CONFIG"));
+ Check_Type(config, T_HASH);
+ return config;
+}
#endif
-/*
+/* call-seq:
+ * sysconfdir -> String
+ *
* Returns system configuration directory.
*
* This is typically <code>"/etc"</code>, but is modified by the prefix used
@@ -676,12 +722,16 @@ etc_sysconfdir(VALUE obj)
{
#ifdef _WIN32
return rb_w32_special_folder(CSIDL_COMMON_APPDATA);
+#elif defined(LOAD_RELATIVE)
+ return rb_hash_aref(rbconfig(), rb_str_new_lit("sysconfdir"));
#else
return rb_filesystem_str_new_cstr(SYSCONFDIR);
#endif
}
-/*
+/* call-seq:
+ * systmpdir -> String
+ *
* Returns system temporary directory; typically "/tmp".
*/
static VALUE
@@ -725,13 +775,15 @@ etc_systmpdir(VALUE _)
}
#ifdef HAVE_UNAME
-/*
+/* call-seq:
+ * uname -> hash
+ *
* Returns the system information obtained by uname system call.
*
* The return value is a hash which has 5 keys at least:
* :sysname, :nodename, :release, :version, :machine
*
- * Example:
+ * *Example:*
*
* require 'etc'
* require 'pp'
@@ -773,18 +825,14 @@ etc_uname(VALUE obj)
sysname = "Windows";
break;
}
- rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(sysname));
+ rb_hash_aset(result, SYMBOL_LIT("sysname"), rb_str_new_cstr(sysname));
release = rb_sprintf("%lu.%lu.%lu", v.dwMajorVersion, v.dwMinorVersion, v.dwBuildNumber);
- rb_hash_aset(result, ID2SYM(rb_intern("release")), release);
+ rb_hash_aset(result, SYMBOL_LIT("release"), release);
version = rb_sprintf("%s Version %"PRIsVALUE": %"PRIsVALUE, sysname, release,
rb_w32_conv_from_wchar(v.szCSDVersion, rb_utf8_encoding()));
- rb_hash_aset(result, ID2SYM(rb_intern("version")), version);
+ rb_hash_aset(result, SYMBOL_LIT("version"), version);
-# if defined _MSC_VER && _MSC_VER < 1300
-# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameW(ptr, plen)
-# else
# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameExW(ComputerNameDnsFullyQualified, ptr, plen)
-# endif
GET_COMPUTER_NAME(NULL, &len);
buf = ALLOCV_N(WCHAR, vbuf, len);
if (GET_COMPUTER_NAME(buf, &len)) {
@@ -792,7 +840,7 @@ etc_uname(VALUE obj)
}
ALLOCV_END(vbuf);
if (NIL_P(nodename)) nodename = rb_str_new(0, 0);
- rb_hash_aset(result, ID2SYM(rb_intern("nodename")), nodename);
+ rb_hash_aset(result, SYMBOL_LIT("nodename"), nodename);
# ifndef PROCESSOR_ARCHITECTURE_AMD64
# define PROCESSOR_ARCHITECTURE_AMD64 9
@@ -816,7 +864,7 @@ etc_uname(VALUE obj)
break;
}
- rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(mach));
+ rb_hash_aset(result, SYMBOL_LIT("machine"), rb_str_new_cstr(mach));
#else
struct utsname u;
int ret;
@@ -827,11 +875,11 @@ etc_uname(VALUE obj)
rb_sys_fail("uname");
result = rb_hash_new();
- rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(u.sysname));
- rb_hash_aset(result, ID2SYM(rb_intern("nodename")), rb_str_new_cstr(u.nodename));
- rb_hash_aset(result, ID2SYM(rb_intern("release")), rb_str_new_cstr(u.release));
- rb_hash_aset(result, ID2SYM(rb_intern("version")), rb_str_new_cstr(u.version));
- rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(u.machine));
+ rb_hash_aset(result, SYMBOL_LIT("sysname"), rb_str_new_cstr(u.sysname));
+ rb_hash_aset(result, SYMBOL_LIT("nodename"), rb_str_new_cstr(u.nodename));
+ rb_hash_aset(result, SYMBOL_LIT("release"), rb_str_new_cstr(u.release));
+ rb_hash_aset(result, SYMBOL_LIT("version"), rb_str_new_cstr(u.version));
+ rb_hash_aset(result, SYMBOL_LIT("machine"), rb_str_new_cstr(u.machine));
#endif
return result;
@@ -841,7 +889,9 @@ etc_uname(VALUE obj)
#endif
#ifdef HAVE_SYSCONF
-/*
+/* call-seq:
+ * sysconf(name) -> Integer
+ *
* Returns system configuration variable using sysconf().
*
* _name_ should be a constant under <code>Etc</code> which begins with <code>SC_</code>.
@@ -875,7 +925,9 @@ etc_sysconf(VALUE obj, VALUE arg)
#endif
#ifdef HAVE_CONFSTR
-/*
+/* call-seq:
+ * confstr(name) -> String
+ *
* Returns system configuration variable using confstr().
*
* _name_ should be a constant under <code>Etc</code> which begins with <code>CS_</code>.
@@ -922,7 +974,9 @@ etc_confstr(VALUE obj, VALUE arg)
#endif
#ifdef HAVE_FPATHCONF
-/*
+/* call-seq:
+ * pathconf(name) -> Integer
+ *
* Returns pathname configuration variable using fpathconf().
*
* _name_ should be a constant under <code>Etc</code> which begins with <code>PC_</code>.
@@ -941,14 +995,11 @@ io_pathconf(VALUE io, VALUE arg)
{
int name;
long ret;
- rb_io_t *fptr;
name = NUM2INT(arg);
- GetOpenFile(io, fptr);
-
errno = 0;
- ret = fpathconf(fptr->fd, name);
+ ret = fpathconf(rb_io_descriptor(io), name);
if (ret == -1) {
if (errno == 0) /* no limit */
return Qnil;
@@ -1017,7 +1068,9 @@ etc_nprocessors_affin(void)
}
#endif
-/*
+/* call-seq:
+ * nprocessors -> Integer
+ *
* Returns the number of online processors.
*
* The result is intended as the number of processes to
@@ -1027,7 +1080,7 @@ etc_nprocessors_affin(void)
* - sched_getaffinity(): Linux
* - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX
*
- * Example:
+ * *Example:*
*
* require 'etc'
* p Etc.nprocessors #=> 4
@@ -1036,7 +1089,7 @@ etc_nprocessors_affin(void)
* process is bound to specific cpus. This is intended for getting better
* parallel processing.
*
- * Example: (Linux)
+ * *Example:* (Linux)
*
* linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2
*
@@ -1086,7 +1139,7 @@ etc_nprocessors(VALUE obj)
* The Etc module provides a more reliable way to access information about
* the logged in user than environment variables such as +$USER+.
*
- * == Example:
+ * *Example:*
*
* require 'etc'
*
@@ -1106,13 +1159,26 @@ Init_etc(void)
{
VALUE mEtc;
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- RB_EXT_RACTOR_SAFE(true);
-#endif
mEtc = rb_define_module("Etc");
+ /* The version */
rb_define_const(mEtc, "VERSION", rb_str_new_cstr(RUBY_ETC_VERSION));
init_constants(mEtc);
+ /* Ractor-safe methods */
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ RB_EXT_RACTOR_SAFE(true);
+#endif
+ rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
+ rb_define_module_function(mEtc, "uname", etc_uname, 0);
+ rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
+ rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
+ rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
+ rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
+
+ /* Non-Ractor-safe methods, see https://bugs.ruby-lang.org/issues/21115 */
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ RB_EXT_RACTOR_SAFE(false);
+#endif
rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
@@ -1128,13 +1194,9 @@ Init_etc(void)
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);
+
+ /* Uses RbConfig::CONFIG so does not work in a Ractor */
rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0);
- rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
- rb_define_module_function(mEtc, "uname", etc_uname, 0);
- rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
- rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
- rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
- rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
sPasswd = rb_struct_define_under(mEtc, "Passwd",
"name",
@@ -1245,4 +1307,8 @@ Init_etc(void)
rb_extend_object(sGroup, rb_mEnumerable);
rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
#endif
+
+#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
+ (void)safe_setup_str;
+#endif
}
diff --git a/ext/etc/etc.gemspec b/ext/etc/etc.gemspec
index 98c6d66faa..0e9803dc62 100644
--- a/ext/etc/etc.gemspec
+++ b/ext/etc/etc.gemspec
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
changelogs = Dir.glob("logs/ChangeLog-[1-9]*[^~]", base: __dir__)
spec.files = %w[
- LICENSE.txt
+ BSDL
+ COPYING
README.md
ChangeLog
ext/etc/constdefs.h
@@ -39,5 +40,5 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.extensions = %w{ext/etc/extconf.rb}
- spec.required_ruby_version = ">= 2.6.0"
+ spec.required_ruby_version = ">= 2.7.0"
end
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 159b1614b7..497303a4fa 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -10,8 +10,30 @@ headers = []
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
have_func("uname((struct utsname *)NULL)", headers)
have_func("getlogin")
-have_func("getpwent")
-have_func("getgrent")
+if have_func("getpwent")
+ have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_change', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
+ if have_struct_member('struct passwd', 'pw_age', 'pwd.h')
+ case what_type?('struct passwd', 'pw_age', 'pwd.h')
+ when "string"
+ f = "safe_setup_str"
+ when "long long"
+ f = "LL2NUM"
+ else
+ f = "INT2NUM"
+ end
+ $defs.push("-DPW_AGE2VAL="+f)
+ end
+ have_struct_member('struct passwd', 'pw_class', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
+ have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
+end
+if have_func("getgrent")
+ have_struct_member('struct group', 'gr_passwd', 'grp.h')
+end
+
if (sysconfdir = RbConfig::CONFIG["sysconfdir"] and
!RbConfig.expand(sysconfdir.dup, "prefix"=>"", "DESTDIR"=>"").empty?)
$defs.push("-DSYSCONFDIR=#{Shellwords.escape(sysconfdir.dump)}")
@@ -21,35 +43,25 @@ have_func("sysconf")
have_func("confstr")
have_func("fpathconf")
-have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
-have_struct_member('struct passwd', 'pw_change', 'pwd.h')
-have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
-if have_struct_member('struct passwd', 'pw_age', 'pwd.h')
- case what_type?('struct passwd', 'pw_age', 'pwd.h')
- when "string"
- f = "safe_setup_str"
- when "long long"
- f = "LL2NUM"
- else
- f = "INT2NUM"
- end
- $defs.push("-DPW_AGE2VAL="+f)
-end
-have_struct_member('struct passwd', 'pw_class', 'pwd.h')
-have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
-have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
-have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
-have_struct_member('struct group', 'gr_passwd', 'grp.h')
-
# for https://github.com/ruby/etc
srcdir = File.expand_path("..", __FILE__)
-if !File.exist?("#{srcdir}/depend")
- %x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
+constdefs = "#{srcdir}/constdefs.h"
+if !File.exist?(constdefs)
+ ruby = RbConfig.ruby
+ if File.file?(ruby)
+ ruby = [ruby]
+ else
+ require "shellwords"
+ ruby = Shellwords.split(ruby)
+ end
+ system(*ruby, "#{srcdir}/mkconstants.rb", "-o", constdefs)
end
# TODO: remove when dropping 2.7 support, as exported since 3.0
have_func('rb_deprecate_constant(Qnil, "None")')
+have_func("rb_io_descriptor", "ruby/io.h")
+
$distcleanfiles << "constdefs.h"
create_makefile("etc")
diff --git a/ext/etc/mkconstants.rb b/ext/etc/mkconstants.rb
index a752d64519..a766560a8a 100644
--- a/ext/etc/mkconstants.rb
+++ b/ext/etc/mkconstants.rb
@@ -35,6 +35,12 @@ opt.def_option('-H FILE', 'specify output header file') {|filename|
opt.parse!
+CONST_PREFIXES = {
+ 'SC' => 'for Etc.sysconf; See <tt>man sysconf</tt>',
+ 'CS' => 'for Etc.confstr; See <tt>man constr</tt>',
+ 'PC' => 'for IO#pathconf; See <tt>man fpathconf</tt>',
+}
+
h = {}
COMMENTS = {}
@@ -49,6 +55,13 @@ DATA.each_line {|s|
next
end
h[name] = default_value
+ if additional = CONST_PREFIXES[name[/\A_([A-Z]+)_/, 1]]
+ if comment&.match(/\w\z/)
+ comment << " " << additional
+ else
+ (comment ||= String.new) << " " << additional.sub(/\A\w/) {$&.upcase}
+ end
+ end
COMMENTS[name] = comment if comment
}
DEFS = h.to_a
@@ -66,15 +79,11 @@ def each_name(pat)
}
end
-erb_new = lambda do |src, safe, trim|
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- ERB.new(src, trim_mode: trim)
- else
- ERB.new(src, safe, trim)
- end
+erb_new = lambda do |src, trim|
+ ERB.new(src, trim_mode: trim)
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_decls")
% each_const {|name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -88,7 +97,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs")
% each_const {|name, default_value|
#if defined(<%=name%>)
% if comment = COMMENTS[name]
@@ -99,13 +108,13 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% }
EOS
-header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
+header_result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
EOS
-result = erb_new.call(<<'EOS', nil, '%').result(binding)
+result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
#ifdef HAVE_LONG_LONG
@@ -123,6 +132,9 @@ result = erb_new.call(<<'EOS', nil, '%').result(binding)
static void
init_constants(VALUE mod)
{
+#if 0
+ mod = rb_define_module("Etc");
+#endif
<%= gen_const_defs %>
}
EOS
diff --git a/ext/extmk.rb b/ext/extmk.rb
index d6a4b80bf7..f5244f72c8 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -2,8 +2,12 @@
# -*- mode: ruby; coding: us-ascii -*-
# frozen_string_literal: false
-module Gem; end # only needs Gem::Platform
-require 'rubygems/platform'
+module Gem
+ # Used by Gem::Platform.local
+ def self.target_rbconfig
+ RbConfig::CONFIG
+ end
+end
# :stopdoc:
$extension = nil
@@ -30,24 +34,23 @@ DUMMY_SIGNATURE = "***DUMMY MAKEFILE***"
srcdir = File.dirname(File.dirname(__FILE__))
unless defined?(CROSS_COMPILING) and CROSS_COMPILING
- $:.replace([File.expand_path("lib", srcdir), Dir.pwd])
+ $:.replace([Dir.pwd, File.expand_path("lib", srcdir)])
end
-$:.unshift(srcdir)
require 'rbconfig'
+# only needs Gem::Platform
+require 'rubygems/platform'
+
$topdir = "."
$top_srcdir = srcdir
+$extmk = true
inplace = File.identical?($top_srcdir, $topdir)
$" << "mkmf.rb"
load File.expand_path("lib/mkmf.rb", srcdir)
require 'optparse/shellwords'
-if defined?(File::NULL)
- @null = File::NULL
-elsif !File.chardev?(@null = "/dev/null")
- @null = "nul"
-end
+@null = File::NULL
def verbose?
$mflags.defined?("V") == "1"
@@ -108,7 +111,7 @@ def extract_makefile(makefile, keep = true)
end
return false
end
- srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")].map {|fn| File.basename(fn)}.sort
+ srcs = Dir[*SRC_EXT.map {|e| "*.#{e}"}, base: $srcdir].map {|fn| File.basename(fn)}.sort
if !srcs.empty?
old_srcs = m[/^ORIG_SRCS[ \t]*=[ \t](.*)/, 1] or return false
(old_srcs.split - srcs).empty? or return false
@@ -163,8 +166,6 @@ def extmake(target, basedir = 'ext', maybestatic = true)
$mdir = target
$srcdir = File.join($top_srcdir, basedir, $mdir)
$preload = nil
- $objs = []
- $srcs = []
$extso = []
makefile = "./Makefile"
static = $static
@@ -198,7 +199,7 @@ def extmake(target, basedir = 'ext', maybestatic = true)
begin
$extconf_h = nil
ok &&= extract_makefile(makefile)
- old_objs = $objs
+ old_objs = $objs || []
old_cleanfiles = $distcleanfiles | $cleanfiles
conf = ["#{$srcdir}/makefile.rb", "#{$srcdir}/extconf.rb"].find {|f| File.exist?(f)}
if (!ok || ($extconf_h && !File.exist?($extconf_h)) ||
@@ -261,6 +262,8 @@ def extmake(target, basedir = 'ext', maybestatic = true)
unless $destdir.to_s.empty? or $mflags.defined?("DESTDIR")
args += ["DESTDIR=" + relative_from($destdir, "../"+prefix)]
end
+ $objs ||= []
+ $srcs ||= []
if $static and ok and !$objs.empty? and !noinstall
args += ["static"]
$extlist.push [(maybestatic ? $static : false), target, $target, $preload]
@@ -476,12 +479,13 @@ if exts = ARGV.shift
$extension = [exts] if exts
if ext_prefix.start_with?('.')
@gemname = exts
- elsif exts
- $static_ext.delete_if {|t, *| !File.fnmatch(t, exts)}
+ exts = []
+ else
+ exts &&= $static_ext.select {|t, *| File.fnmatch(t, exts)}
end
end
-ext_prefix = "#{$top_srcdir}/#{ext_prefix || 'ext'}"
-exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
+ext_prefix ||= 'ext'
+exts = (exts || $static_ext).sort_by {|t, i| i}.collect {|t, i| t}
default_exclude_exts =
case
when $cygwin
@@ -494,28 +498,30 @@ default_exclude_exts =
mandatory_exts = {}
withes, withouts = [["--with", nil], ["--without", default_exclude_exts]].collect {|w, d|
if !(w = %w[-extensions -ext].collect {|o|arg_config(w+o)}).any?
- d ? proc {|c1| d.any?(&c1)} : proc {true}
+ d ? proc {|&c1| d.any?(&c1)} : proc {true}
elsif (w = w.grep(String)).empty?
proc {true}
else
w = w.collect {|o| o.split(/,/)}.flatten
w.collect! {|o| o == '+' ? d : o}.flatten!
- proc {|c1| w.any?(&c1)}
+ proc {|&c1| w.any?(&c1)}
end
}
cond = proc {|ext, *|
- withes.call(proc {|n|
- !n or (mandatory_exts[ext] = true if File.fnmatch(n, ext))
- }) and
- !withouts.call(proc {|n| File.fnmatch(n, ext)})
+ withes.call {|n| !n or (mandatory_exts[ext] = true if File.fnmatch(n, ext))} and
+ !withouts.call {|n| File.fnmatch(n, ext)}
}
($extension || %w[*]).each do |e|
e = e.sub(/\A(?:\.\/)+/, '')
- incl, excl = Dir.glob("#{ext_prefix}/#{e}/**/extconf.rb").collect {|d|
- d = File.dirname(d)
- d.slice!(0, ext_prefix.length + 1)
- d
+ incl, excl = Dir.glob("#{e}/**/extconf.rb", base: "#$top_srcdir/#{ext_prefix}").collect {|d|
+ File.dirname(d)
}.partition {|ext|
+ if @gemname
+ ext = ext[%r[\A[^/]+]] # extract gem name
+ Dir.glob("*.gemspec", base: "#$top_srcdir/#{ext_prefix}/#{ext}") do |g|
+ break ext = g if ext.start_with?("#{g.chomp!(".gemspec")}-")
+ end
+ end
with_config(ext, &cond)
}
incl.sort!
@@ -526,7 +532,7 @@ cond = proc {|ext, *|
exts.delete_if {|d| File.fnmatch?("-*", d)}
end
end
-ext_prefix = ext_prefix[$top_srcdir.size+1..-2]
+ext_prefix.chomp!("/")
@ext_prefix = ext_prefix
@inplace = inplace
@@ -549,7 +555,14 @@ extend Module.new {
end
def create_makefile(*args, &block)
- return super unless @gemname
+ unless @gemname
+ if $static and (target = args.first).include?("/")
+ base = File.basename(target)
+ $defs << "-DInit_#{base}=Init_#{target.tr('/', '_')}"
+ $defs << "-DInitVM_#{base}=InitVM_#{target.tr('/', '_')}"
+ end
+ return super
+ end
super(*args) do |conf|
conf.find do |s|
s.sub!(%r(^(srcdir *= *)\$\(top_srcdir\)/\.bundle/gems/[^/]+(?=/))) {
@@ -565,7 +578,8 @@ extend Module.new {
}
end
- gemlib = File.directory?("#{$top_srcdir}/#{@ext_prefix}/#{@gemname}/lib")
+ conf = yield conf if block
+
if conf.any? {|s| /^TARGET *= *\S/ =~ s}
conf << %{
gem_platform = #{Gem::Platform.local}
@@ -578,6 +592,7 @@ gem = #{@gemname}
build_complete = $(TARGET_GEM_DIR)/gem.build_complete
install-so: build_complete
clean-so:: clean-build_complete
+$(build_complete) $(OBJS): $(TARGET_SO_DIR_TIMESTAMP)
build_complete: $(build_complete)
$(build_complete): $(TARGET_SO)
@@ -598,23 +613,25 @@ gemspec: $(gemspec)
clean-gemspec:
-$(Q)$(RM) $(gemspec)
-}
-
- if gemlib
- conf << %{
-install-rb: gemlib
-clean-rb:: clean-gemlib
LN_S = #{config_string('LN_S')}
CP_R = #{config_string('CP')} -r
-
-gemlib = $(TARGET_TOPDIR)/gems/$(gem)/lib
-gemlib:#{%{ $(gemlib)\n$(gemlib): $(gem_srcdir)/lib} if $nmake}
- $(Q) #{@inplace ? '$(NULLCMD) ' : ''}$(RUBY) $(top_srcdir)/tool/ln_sr.rb -q -f -T $(gem_srcdir)/lib $(gemlib)
-
-clean-gemlib:
- $(Q) $(#{@inplace ? 'NULLCMD' : 'RM_RF'}) $(gemlib)
}
+ unless @inplace
+ %w[bin lib].each do |d|
+ next unless File.directory?("#{$top_srcdir}/#{@ext_prefix}/#{@gemname}/#{d}")
+ conf << %{
+install-rb: gem#{d}
+clean-rb:: clean-gem#{d}
+
+gem#{d} = $(TARGET_TOPDIR)/gems/$(gem)/#{d}
+gem#{d}:#{%{ $(gem#{d})\n$(gem#{d}): $(gem_srcdir)/#{d}} if $nmake}
+ $(Q) $(RUBY) $(top_srcdir)/tool/ln_sr.rb -q -f -T $(gem_srcdir)/#{d} $(gem#{d})
+
+clean-gem#{d}:
+ $(Q) $(RM_RF) $(gem#{d})
+}
+ end
end
end
@@ -632,7 +649,9 @@ $hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include"
extso = []
fails = []
exts.each do |d|
- $static = $force_static ? true : $static_ext[d]
+ $static = $force_static ? true : $static_ext.fetch(d) do
+ $static_ext.any? {|t, | File.fnmatch?(t, d)}
+ end
if !$nodynamic or $static
result = extmake(d, ext_prefix, !@gemname) or abort
@@ -758,7 +777,6 @@ begin
end
submakeopts << 'EXTLDFLAGS="$(EXTLDFLAGS)"'
submakeopts << 'EXTINITS="$(EXTINITS)"'
- submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"'
submakeopts << 'SHOWFLAGS='
mf.macro "SUBMAKEOPTS", submakeopts
mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip]
@@ -797,9 +815,9 @@ begin
if $gnumake == "yes"
submake = "$(MAKE) -C $(@D)"
else
- submake = "cd $(@D) && "
- config_string("exec") {|str| submake << str << " "}
- submake << "$(MAKE)"
+ submake = ["cd", (sep ? "$(@D:/=#{sep})" : "$(@D)"), "&&"]
+ config_string("exec") {|str| submake << str}
+ submake = (submake << "$(MAKE)").join(" ")
end
targets.each do |tgt|
exts.each do |d|
@@ -814,7 +832,7 @@ begin
end
mf.puts "#{t}:#{pd}\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
if clean and clean.begin(1)
- mf.puts "\t$(Q)$(RM) $(ext_build_dir)/exts.mk\n\t$(Q)$(RMDIRS) -p $(@D)"
+ mf.puts "\t$(Q)$(RM) $(ext_build_dir)/exts.mk\n\t$(Q)$(RMDIRS) $(@D)"
end
end
end
diff --git a/ext/fcntl/depend b/ext/fcntl/depend
index 9ce9fa30ef..57ea0f2106 100644
--- a/ext/fcntl/depend
+++ b/ext/fcntl/depend
@@ -128,6 +128,7 @@ fcntl.o: $(hdrdir)/ruby/internal/intern/re.h
fcntl.o: $(hdrdir)/ruby/internal/intern/ruby.h
fcntl.o: $(hdrdir)/ruby/internal/intern/select.h
fcntl.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+fcntl.o: $(hdrdir)/ruby/internal/intern/set.h
fcntl.o: $(hdrdir)/ruby/internal/intern/signal.h
fcntl.o: $(hdrdir)/ruby/internal/intern/sprintf.h
fcntl.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -147,6 +148,7 @@ fcntl.o: $(hdrdir)/ruby/internal/special_consts.h
fcntl.o: $(hdrdir)/ruby/internal/static_assert.h
fcntl.o: $(hdrdir)/ruby/internal/stdalign.h
fcntl.o: $(hdrdir)/ruby/internal/stdbool.h
+fcntl.o: $(hdrdir)/ruby/internal/stdckdint.h
fcntl.o: $(hdrdir)/ruby/internal/symbol.h
fcntl.o: $(hdrdir)/ruby/internal/value.h
fcntl.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 3bccc41e4c..b987e237dd 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -28,7 +28,10 @@ pack up your own arguments to pass as args for locking functions, etc.
#include "ruby.h"
#include <fcntl.h>
-/* Fcntl loads the constants defined in the system's <fcntl.h> C header
+/*
+ * Document-module: Fcntl
+ *
+ * Fcntl loads the constants defined in the system's <fcntl.h> C header
* file, and used with both the fcntl(2) and open(2) POSIX system calls.
*
* To perform a fcntl(2) operation, use IO::fcntl.
@@ -61,13 +64,19 @@ pack up your own arguments to pass as args for locking functions, etc.
* f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
*
*/
+
+#define FCNTL_VERSION "1.3.0"
+
void
Init_fcntl(void)
{
VALUE mFcntl = rb_define_module("Fcntl");
+
+ /* The version string. */
+ rb_define_const(mFcntl, "VERSION", rb_str_new_cstr(FCNTL_VERSION));
+
#ifdef F_DUPFD
- /* Document-const: F_DUPFD
- *
+ /*
* Duplicate a file descriptor to the minimum unused file descriptor
* greater than or equal to the argument.
*
@@ -78,199 +87,214 @@ Init_fcntl(void)
rb_define_const(mFcntl, "F_DUPFD", INT2NUM(F_DUPFD));
#endif
#ifdef F_GETFD
- /* Document-const: F_GETFD
- *
+ /*
* Read the close-on-exec flag of a file descriptor.
*/
rb_define_const(mFcntl, "F_GETFD", INT2NUM(F_GETFD));
#endif
#ifdef F_GETLK
- /* Document-const: F_GETLK
- *
+ /*
* Determine whether a given region of a file is locked. This uses one of
* the F_*LK flags.
*/
rb_define_const(mFcntl, "F_GETLK", INT2NUM(F_GETLK));
#endif
#ifdef F_SETFD
- /* Document-const: F_SETFD
- *
+ /*
* Set the close-on-exec flag of a file descriptor.
*/
rb_define_const(mFcntl, "F_SETFD", INT2NUM(F_SETFD));
#endif
#ifdef F_GETFL
- /* Document-const: F_GETFL
- *
+ /*
* Get the file descriptor flags. This will be one or more of the O_*
* flags.
*/
rb_define_const(mFcntl, "F_GETFL", INT2NUM(F_GETFL));
#endif
#ifdef F_SETFL
- /* Document-const: F_SETFL
- *
+ /*
* Set the file descriptor flags. This will be one or more of the O_*
* flags.
*/
rb_define_const(mFcntl, "F_SETFL", INT2NUM(F_SETFL));
#endif
#ifdef F_SETLK
- /* Document-const: F_SETLK
- *
+ /*
* Acquire a lock on a region of a file. This uses one of the F_*LCK
* flags.
*/
rb_define_const(mFcntl, "F_SETLK", INT2NUM(F_SETLK));
#endif
#ifdef F_SETLKW
- /* Document-const: F_SETLKW
- *
+ /*
* Acquire a lock on a region of a file, waiting if necessary. This uses
* one of the F_*LCK flags
*/
rb_define_const(mFcntl, "F_SETLKW", INT2NUM(F_SETLKW));
#endif
#ifdef FD_CLOEXEC
- /* Document-const: FD_CLOEXEC
- *
+ /*
* the value of the close-on-exec flag.
*/
rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
#endif
#ifdef F_RDLCK
- /* Document-const: F_RDLCK
- *
+ /*
* Read lock for a region of a file
*/
rb_define_const(mFcntl, "F_RDLCK", INT2NUM(F_RDLCK));
#endif
#ifdef F_UNLCK
- /* Document-const: F_UNLCK
- *
+ /*
* Remove lock for a region of a file
*/
rb_define_const(mFcntl, "F_UNLCK", INT2NUM(F_UNLCK));
#endif
#ifdef F_WRLCK
- /* Document-const: F_WRLCK
- *
+ /*
* Write lock for a region of a file
*/
rb_define_const(mFcntl, "F_WRLCK", INT2NUM(F_WRLCK));
#endif
#ifdef F_SETPIPE_SZ
- /* Document-const: F_SETPIPE_SZ
- *
+ /*
* Change the capacity of the pipe referred to by fd to be at least arg bytes.
*/
rb_define_const(mFcntl, "F_SETPIPE_SZ", INT2NUM(F_SETPIPE_SZ));
#endif
#ifdef F_GETPIPE_SZ
- /* Document-const: F_GETPIPE_SZ
- *
+ /*
* Return (as the function result) the capacity of the pipe referred to by fd.
*/
rb_define_const(mFcntl, "F_GETPIPE_SZ", INT2NUM(F_GETPIPE_SZ));
#endif
#ifdef O_CREAT
- /* Document-const: O_CREAT
- *
+ /*
* Create the file if it doesn't exist
*/
rb_define_const(mFcntl, "O_CREAT", INT2NUM(O_CREAT));
#endif
#ifdef O_EXCL
- /* Document-const: O_EXCL
- *
+ /*
* Used with O_CREAT, fail if the file exists
*/
rb_define_const(mFcntl, "O_EXCL", INT2NUM(O_EXCL));
#endif
#ifdef O_NOCTTY
- /* Document-const: O_NOCTTY
- *
+ /*
* Open TTY without it becoming the controlling TTY
*/
rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(O_NOCTTY));
#endif
#ifdef O_TRUNC
- /* Document-const: O_TRUNC
- *
+ /*
* Truncate the file on open
*/
rb_define_const(mFcntl, "O_TRUNC", INT2NUM(O_TRUNC));
#endif
#ifdef O_APPEND
- /* Document-const: O_APPEND
- *
+ /*
* Open the file in append mode
*/
rb_define_const(mFcntl, "O_APPEND", INT2NUM(O_APPEND));
#endif
#ifdef O_NONBLOCK
- /* Document-const: O_NONBLOCK
- *
+ /*
* Open the file in non-blocking mode
*/
rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(O_NONBLOCK));
#endif
#ifdef O_NDELAY
- /* Document-const: O_NDELAY
- *
+ /*
* Open the file in non-blocking mode
*/
rb_define_const(mFcntl, "O_NDELAY", INT2NUM(O_NDELAY));
#endif
#ifdef O_RDONLY
- /* Document-const: O_RDONLY
- *
+ /*
* Open the file in read-only mode
*/
rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY));
#endif
#ifdef O_RDWR
- /* Document-const: O_RDWR
- *
+ /*
* Open the file in read-write mode
*/
rb_define_const(mFcntl, "O_RDWR", INT2NUM(O_RDWR));
#endif
#ifdef O_WRONLY
- /* Document-const: O_WRONLY
- *
+ /*
* Open the file in write-only mode.
*/
rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
#endif
-#ifdef O_ACCMODE
- /* Document-const: O_ACCMODE
- *
+#ifndef O_ACCMODE
+ int O_ACCMODE = (O_RDONLY | O_WRONLY | O_RDWR);
+#endif
+ /*
* Mask to extract the read/write flags
*/
rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_ACCMODE));
-#else
- /* Document-const: O_ACCMODE
- *
- * Mask to extract the read/write flags
- */
- rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_RDONLY | O_WRONLY | O_RDWR));
-#endif
#ifdef F_DUP2FD
- /* Document-const: F_DUP2FD
- *
+ /*
* It is a FreeBSD specific constant and equivalent
* to dup2 call.
*/
rb_define_const(mFcntl, "F_DUP2FD", INT2NUM(F_DUP2FD));
#endif
#ifdef F_DUP2FD_CLOEXEC
- /* Document-const: F_DUP2FD_CLOEXEC
- *
+ /*
* It is a FreeBSD specific constant and acts
* similarly as F_DUP2FD but set the FD_CLOEXEC
* flag in addition.
*/
rb_define_const(mFcntl, "F_DUP2FD_CLOEXEC", INT2NUM(F_DUP2FD_CLOEXEC));
#endif
+
+#ifdef F_PREALLOCATE
+ /*
+ * macOS specific flag used for preallocating file space.
+ */
+ rb_define_const(mFcntl, "F_PREALLOCATE", INT2NUM(F_PREALLOCATE));
+#endif
+
+#ifdef F_ALLOCATECONTIG
+ /*
+ * macOS specific flag used with F_PREALLOCATE for allocating contiguous
+ * space.
+ */
+ rb_define_const(mFcntl, "F_ALLOCATECONTIG", INT2NUM(F_ALLOCATECONTIG));
+#endif
+
+#ifdef F_ALLOCATEALL
+ /*
+ * macOS specific flag used with F_PREALLOCATE for allocating all contiguous
+ * space or no space.
+ */
+ rb_define_const(mFcntl, "F_ALLOCATEALL", INT2NUM(F_ALLOCATEALL));
+#endif
+
+#ifdef F_ALLOCATEPERSIST
+ /*
+ * macOS specific flag used with F_PREALLOCATE. Allocate space that is not
+ * freed when close is called.
+ */
+ rb_define_const(mFcntl, "F_ALLOCATEPERSIST", INT2NUM(F_ALLOCATEPERSIST));
+#endif
+
+#ifdef F_PEOFPOSMODE
+ /*
+ * macOS specific flag used with F_PREALLOCATE. Allocate from the physical
+ * end of file
+ */
+ rb_define_const(mFcntl, "F_PEOFPOSMODE", INT2NUM(F_PEOFPOSMODE));
+#endif
+
+#ifdef F_VOLPOSMODE
+ /*
+ * macOS specific flag used with F_PREALLOCATE. Allocate from the volume offset.
+ */
+ rb_define_const(mFcntl, "F_VOLPOSMODE", INT2NUM(F_VOLPOSMODE));
+#endif
}
diff --git a/ext/fcntl/fcntl.gemspec b/ext/fcntl/fcntl.gemspec
index 09d3fc2568..613a90d1ae 100644
--- a/ext/fcntl/fcntl.gemspec
+++ b/ext/fcntl/fcntl.gemspec
@@ -1,9 +1,19 @@
# coding: utf-8
# frozen_string_literal: true
+source_version = ["", "ext/fcntl/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}fcntl.c")) {|f|
+ f.gets("\n#define FCNTL_VERSION ")
+ f.gets[/\s*"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
+end
+
Gem::Specification.new do |spec|
spec.name = "fcntl"
- spec.version = "1.0.2"
+ spec.version = source_version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -13,9 +23,10 @@ Gem::Specification.new do |spec|
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.files = ["ext/fcntl/extconf.rb", "ext/fcntl/fcntl.c"]
+ spec.extra_rdoc_files = [".document", ".rdoc_options", "BSDL", "COPYING", "README.md"]
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.extensions = "ext/fcntl/extconf.rb"
- spec.required_ruby_version = ">= 2.3.0"
+ spec.required_ruby_version = ">= 2.5.0"
end
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
deleted file mode 100644
index 892f522a62..0000000000
--- a/ext/fiddle/closure.c
+++ /dev/null
@@ -1,433 +0,0 @@
-#include <fiddle.h>
-#include <ruby/thread.h>
-
-int ruby_thread_has_gvl_p(void); /* from internal.h */
-
-VALUE cFiddleClosure;
-
-typedef struct {
- void * code;
- ffi_closure *pcl;
- ffi_cif cif;
- int argc;
- ffi_type **argv;
-} fiddle_closure;
-
-#if defined(__OpenBSD__)
-# define USE_FFI_CLOSURE_ALLOC 0
-#endif
-
-#if defined(USE_FFI_CLOSURE_ALLOC)
-#elif !defined(HAVE_FFI_CLOSURE_ALLOC)
-# define USE_FFI_CLOSURE_ALLOC 0
-#else
-# define USE_FFI_CLOSURE_ALLOC 1
-#endif
-
-static void
-dealloc(void * ptr)
-{
- fiddle_closure * cls = (fiddle_closure *)ptr;
-#if USE_FFI_CLOSURE_ALLOC
- ffi_closure_free(cls->pcl);
-#else
- munmap(cls->pcl, sizeof(*cls->pcl));
-#endif
- if (cls->argv) xfree(cls->argv);
- xfree(cls);
-}
-
-static size_t
-closure_memsize(const void * ptr)
-{
- fiddle_closure * cls = (fiddle_closure *)ptr;
- size_t size = 0;
-
- size += sizeof(*cls);
-#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
- size += ffi_raw_size(&cls->cif);
-#endif
- size += sizeof(*cls->argv);
- size += sizeof(ffi_closure);
-
- return size;
-}
-
-const rb_data_type_t closure_data_type = {
- "fiddle/closure",
- {0, dealloc, closure_memsize,},
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
-};
-
-struct callback_args {
- ffi_cif *cif;
- void *resp;
- void **args;
- void *ctx;
-};
-
-static void *
-with_gvl_callback(void *ptr)
-{
- struct callback_args *x = ptr;
-
- VALUE self = (VALUE)x->ctx;
- VALUE rbargs = rb_iv_get(self, "@args");
- VALUE ctype = rb_iv_get(self, "@ctype");
- int argc = RARRAY_LENINT(rbargs);
- VALUE params = rb_ary_tmp_new(argc);
- VALUE ret;
- VALUE cPointer;
- int i, type;
-
- cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
-
- for (i = 0; i < argc; i++) {
- type = NUM2INT(RARRAY_AREF(rbargs, i));
- switch (type) {
- case TYPE_VOID:
- argc = 0;
- break;
- case TYPE_INT:
- rb_ary_push(params, INT2NUM(*(int *)x->args[i]));
- break;
- case TYPE_UINT:
- rb_ary_push(params, UINT2NUM(*(unsigned int *)x->args[i]));
- break;
- case TYPE_VOIDP:
- rb_ary_push(params,
- rb_funcall(cPointer, rb_intern("[]"), 1,
- PTR2NUM(*(void **)x->args[i])));
- break;
- case TYPE_LONG:
- rb_ary_push(params, LONG2NUM(*(long *)x->args[i]));
- break;
- case TYPE_ULONG:
- rb_ary_push(params, ULONG2NUM(*(unsigned long *)x->args[i]));
- break;
- case TYPE_CHAR:
- rb_ary_push(params, INT2NUM(*(signed char *)x->args[i]));
- break;
- case TYPE_UCHAR:
- rb_ary_push(params, UINT2NUM(*(unsigned char *)x->args[i]));
- break;
- case TYPE_SHORT:
- rb_ary_push(params, INT2NUM(*(signed short *)x->args[i]));
- break;
- case TYPE_USHORT:
- rb_ary_push(params, UINT2NUM(*(unsigned short *)x->args[i]));
- break;
- case TYPE_DOUBLE:
- rb_ary_push(params, rb_float_new(*(double *)x->args[i]));
- break;
- case TYPE_FLOAT:
- rb_ary_push(params, rb_float_new(*(float *)x->args[i]));
- break;
-#if HAVE_LONG_LONG
- case TYPE_LONG_LONG:
- rb_ary_push(params, LL2NUM(*(LONG_LONG *)x->args[i]));
- break;
- case TYPE_ULONG_LONG:
- rb_ary_push(params, ULL2NUM(*(unsigned LONG_LONG *)x->args[i]));
- break;
-#endif
- case TYPE_CONST_STRING:
- rb_ary_push(params,
- rb_str_new_cstr(*((const char **)(x->args[i]))));
- break;
- default:
- rb_raise(rb_eRuntimeError, "closure args: %d", type);
- }
- }
-
- ret = rb_funcall2(self, rb_intern("call"), argc, RARRAY_CONST_PTR(params));
- RB_GC_GUARD(params);
-
- type = NUM2INT(ctype);
- switch (type) {
- case TYPE_VOID:
- break;
- case TYPE_LONG:
- *(long *)x->resp = NUM2LONG(ret);
- break;
- case TYPE_ULONG:
- *(unsigned long *)x->resp = NUM2ULONG(ret);
- break;
- case TYPE_CHAR:
- case TYPE_SHORT:
- case TYPE_INT:
- *(ffi_sarg *)x->resp = NUM2INT(ret);
- break;
- case TYPE_UCHAR:
- case TYPE_USHORT:
- case TYPE_UINT:
- *(ffi_arg *)x->resp = NUM2UINT(ret);
- break;
- case TYPE_VOIDP:
- *(void **)x->resp = NUM2PTR(ret);
- break;
- case TYPE_DOUBLE:
- *(double *)x->resp = NUM2DBL(ret);
- break;
- case TYPE_FLOAT:
- *(float *)x->resp = (float)NUM2DBL(ret);
- break;
-#if HAVE_LONG_LONG
- case TYPE_LONG_LONG:
- *(LONG_LONG *)x->resp = NUM2LL(ret);
- break;
- case TYPE_ULONG_LONG:
- *(unsigned LONG_LONG *)x->resp = NUM2ULL(ret);
- break;
-#endif
- case TYPE_CONST_STRING:
- /* Dangerous. Callback must keep reference of the String. */
- *((const char **)(x->resp)) = StringValueCStr(ret);
- break;
- default:
- rb_raise(rb_eRuntimeError, "closure retval: %d", type);
- }
- return 0;
-}
-
-static void
-callback(ffi_cif *cif, void *resp, void **args, void *ctx)
-{
- struct callback_args x;
-
- x.cif = cif;
- x.resp = resp;
- x.args = args;
- x.ctx = ctx;
-
- if (ruby_thread_has_gvl_p()) {
- (void)with_gvl_callback(&x);
- } else {
- (void)rb_thread_call_with_gvl(with_gvl_callback, &x);
- }
-}
-
-static VALUE
-allocate(VALUE klass)
-{
- fiddle_closure * closure;
-
- VALUE i = TypedData_Make_Struct(klass, fiddle_closure,
- &closure_data_type, closure);
-
-#if USE_FFI_CLOSURE_ALLOC
- closure->pcl = ffi_closure_alloc(sizeof(ffi_closure), &closure->code);
-#else
- closure->pcl = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
- MAP_ANON | MAP_PRIVATE, -1, 0);
-#endif
-
- return i;
-}
-
-static fiddle_closure *
-get_raw(VALUE self)
-{
- fiddle_closure *closure;
- TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, closure);
- if (!closure) {
- rb_raise(rb_eArgError, "already freed: %+"PRIsVALUE, self);
- }
- return closure;
-}
-
-typedef struct {
- VALUE self;
- int argc;
- VALUE *argv;
-} initialize_data;
-
-static VALUE
-initialize_body(VALUE user_data)
-{
- initialize_data *data = (initialize_data *)user_data;
- VALUE ret;
- VALUE args;
- VALUE normalized_args;
- VALUE abi;
- fiddle_closure * cl;
- ffi_cif * cif;
- ffi_closure *pcl;
- ffi_status result;
- int i, argc;
-
- if (2 == rb_scan_args(data->argc, data->argv, "21", &ret, &args, &abi))
- abi = INT2NUM(FFI_DEFAULT_ABI);
-
- Check_Type(args, T_ARRAY);
-
- argc = RARRAY_LENINT(args);
-
- TypedData_Get_Struct(data->self, fiddle_closure, &closure_data_type, cl);
-
- cl->argv = (ffi_type **)xcalloc(argc + 1, sizeof(ffi_type *));
-
- normalized_args = rb_ary_new_capa(argc);
- for (i = 0; i < argc; i++) {
- VALUE arg = rb_fiddle_type_ensure(RARRAY_AREF(args, i));
- rb_ary_push(normalized_args, arg);
- cl->argv[i] = rb_fiddle_int_to_ffi_type(NUM2INT(arg));
- }
- cl->argv[argc] = NULL;
-
- ret = rb_fiddle_type_ensure(ret);
- rb_iv_set(data->self, "@ctype", ret);
- rb_iv_set(data->self, "@args", normalized_args);
-
- cif = &cl->cif;
- pcl = cl->pcl;
-
- result = ffi_prep_cif(cif,
- NUM2INT(abi),
- argc,
- rb_fiddle_int_to_ffi_type(NUM2INT(ret)),
- cl->argv);
-
- if (FFI_OK != result) {
- rb_raise(rb_eRuntimeError, "error prepping CIF %d", result);
- }
-
-#if USE_FFI_CLOSURE_ALLOC
- result = ffi_prep_closure_loc(pcl, cif, callback,
- (void *)(data->self), cl->code);
-#else
- result = ffi_prep_closure(pcl, cif, callback, (void *)(data->self));
- cl->code = (void *)pcl;
- i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
- if (i) {
- rb_sys_fail("mprotect");
- }
-#endif
-
- if (FFI_OK != result) {
- rb_raise(rb_eRuntimeError, "error prepping closure %d", result);
- }
-
- return data->self;
-}
-
-static VALUE
-initialize_rescue(VALUE user_data, VALUE exception)
-{
- initialize_data *data = (initialize_data *)user_data;
- dealloc(RTYPEDDATA_DATA(data->self));
- RTYPEDDATA_DATA(data->self) = NULL;
- rb_exc_raise(exception);
- return data->self;
-}
-
-static VALUE
-initialize(int argc, VALUE *argv, VALUE self)
-{
- initialize_data data;
- data.self = self;
- data.argc = argc;
- data.argv = argv;
- return rb_rescue(initialize_body, (VALUE)&data,
- initialize_rescue, (VALUE)&data);
-}
-
-static VALUE
-to_i(VALUE self)
-{
- fiddle_closure *closure = get_raw(self);
- return PTR2NUM(closure->code);
-}
-
-static VALUE
-closure_free(VALUE self)
-{
- fiddle_closure *closure;
- TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, closure);
- if (closure) {
- dealloc(closure);
- RTYPEDDATA_DATA(self) = NULL;
- }
- return RUBY_Qnil;
-}
-
-static VALUE
-closure_freed_p(VALUE self)
-{
- fiddle_closure *closure;
- TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, closure);
- return closure ? RUBY_Qfalse : RUBY_Qtrue;
-}
-
-void
-Init_fiddle_closure(void)
-{
-#if 0
- mFiddle = rb_define_module("Fiddle"); /* let rdoc know about mFiddle */
-#endif
-
- /*
- * Document-class: Fiddle::Closure
- *
- * == Description
- *
- * An FFI closure wrapper, for handling callbacks.
- *
- * == Example
- *
- * closure = Class.new(Fiddle::Closure) {
- * def call
- * 10
- * end
- * }.new(Fiddle::TYPE_INT, [])
- * #=> #<#<Class:0x0000000150d308>:0x0000000150d240>
- * func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT)
- * #=> #<Fiddle::Function:0x00000001516e58>
- * func.call
- * #=> 10
- */
- cFiddleClosure = rb_define_class_under(mFiddle, "Closure", rb_cObject);
-
- rb_define_alloc_func(cFiddleClosure, allocate);
-
- /*
- * Document-method: new
- *
- * call-seq: new(ret, args, abi = Fiddle::DEFAULT)
- *
- * Construct a new Closure object.
- *
- * * +ret+ is the C type to be returned
- * * +args+ is an Array of arguments, passed to the callback function
- * * +abi+ is the abi of the closure
- *
- * If there is an error in preparing the ffi_cif or ffi_prep_closure,
- * then a RuntimeError will be raised.
- */
- rb_define_method(cFiddleClosure, "initialize", initialize, -1);
-
- /*
- * Document-method: to_i
- *
- * Returns the memory address for this closure.
- */
- rb_define_method(cFiddleClosure, "to_i", to_i, 0);
-
- /*
- * Document-method: free
- *
- * Free this closure explicitly. You can't use this closure anymore.
- *
- * If this closure is already freed, this does nothing.
- */
- rb_define_method(cFiddleClosure, "free", closure_free, 0);
-
- /*
- * Document-method: freed?
- *
- * Whether this closure was freed explicitly.
- */
- rb_define_method(cFiddleClosure, "freed?", closure_freed_p, 0);
-}
-/* vim: set noet sw=4 sts=4 */
diff --git a/ext/fiddle/closure.h b/ext/fiddle/closure.h
deleted file mode 100644
index d0a8be6180..0000000000
--- a/ext/fiddle/closure.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef FIDDLE_CLOSURE_H
-#define FIDDLE_CLOSURE_H
-
-#include <fiddle.h>
-
-void Init_fiddle_closure(void);
-
-#endif
diff --git a/ext/fiddle/conversions.c b/ext/fiddle/conversions.c
deleted file mode 100644
index 3b70f7de4c..0000000000
--- a/ext/fiddle/conversions.c
+++ /dev/null
@@ -1,330 +0,0 @@
-#include <fiddle.h>
-
-VALUE
-rb_fiddle_type_ensure(VALUE type)
-{
- VALUE original_type = type;
-
- if (!RB_SYMBOL_P(type)) {
- VALUE type_string = rb_check_string_type(type);
- if (!NIL_P(type_string)) {
- type = rb_to_symbol(type_string);
- }
- }
-
- if (RB_SYMBOL_P(type)) {
- ID type_id = rb_sym2id(type);
- ID void_id;
- ID voidp_id;
- ID char_id;
- ID short_id;
- ID int_id;
- ID long_id;
-#ifdef TYPE_LONG_LONG
- ID long_long_id;
-#endif
-#ifdef TYPE_INT8_T
- ID int8_t_id;
-#endif
-#ifdef TYPE_INT16_T
- ID int16_t_id;
-#endif
-#ifdef TYPE_INT32_T
- ID int32_t_id;
-#endif
-#ifdef TYPE_INT64_T
- ID int64_t_id;
-#endif
- ID float_id;
- ID double_id;
- ID variadic_id;
- ID const_string_id;
- ID size_t_id;
- ID ssize_t_id;
- ID ptrdiff_t_id;
- ID intptr_t_id;
- ID uintptr_t_id;
- RUBY_CONST_ID(void_id, "void");
- RUBY_CONST_ID(voidp_id, "voidp");
- RUBY_CONST_ID(char_id, "char");
- RUBY_CONST_ID(short_id, "short");
- RUBY_CONST_ID(int_id, "int");
- RUBY_CONST_ID(long_id, "long");
-#ifdef TYPE_LONG_LONG
- RUBY_CONST_ID(long_long_id, "long_long");
-#endif
-#ifdef TYPE_INT8_T
- RUBY_CONST_ID(int8_t_id, "int8_t");
-#endif
-#ifdef TYPE_INT16_T
- RUBY_CONST_ID(int16_t_id, "int16_t");
-#endif
-#ifdef TYPE_INT32_T
- RUBY_CONST_ID(int32_t_id, "int32_t");
-#endif
-#ifdef TYPE_INT64_T
- RUBY_CONST_ID(int64_t_id, "int64_t");
-#endif
- RUBY_CONST_ID(float_id, "float");
- RUBY_CONST_ID(double_id, "double");
- RUBY_CONST_ID(variadic_id, "variadic");
- RUBY_CONST_ID(const_string_id, "const_string");
- RUBY_CONST_ID(size_t_id, "size_t");
- RUBY_CONST_ID(ssize_t_id, "ssize_t");
- RUBY_CONST_ID(ptrdiff_t_id, "ptrdiff_t");
- RUBY_CONST_ID(intptr_t_id, "intptr_t");
- RUBY_CONST_ID(uintptr_t_id, "uintptr_t");
- if (type_id == void_id) {
- return INT2NUM(TYPE_VOID);
- }
- else if (type_id == voidp_id) {
- return INT2NUM(TYPE_VOIDP);
- }
- else if (type_id == char_id) {
- return INT2NUM(TYPE_CHAR);
- }
- else if (type_id == short_id) {
- return INT2NUM(TYPE_SHORT);
- }
- else if (type_id == int_id) {
- return INT2NUM(TYPE_INT);
- }
- else if (type_id == long_id) {
- return INT2NUM(TYPE_LONG);
- }
-#ifdef TYPE_LONG_LONG
- else if (type_id == long_long_id) {
- return INT2NUM(TYPE_LONG_LONG);
- }
-#endif
-#ifdef TYPE_INT8_T
- else if (type_id == int8_t_id) {
- return INT2NUM(TYPE_INT8_T);
- }
-#endif
-#ifdef TYPE_INT16_T
- else if (type_id == int16_t_id) {
- return INT2NUM(TYPE_INT16_T);
- }
-#endif
-#ifdef TYPE_INT32_T
- else if (type_id == int32_t_id) {
- return INT2NUM(TYPE_INT32_T);
- }
-#endif
-#ifdef TYPE_INT64_T
- else if (type_id == int64_t_id) {
- return INT2NUM(TYPE_INT64_T);
- }
-#endif
- else if (type_id == float_id) {
- return INT2NUM(TYPE_FLOAT);
- }
- else if (type_id == double_id) {
- return INT2NUM(TYPE_DOUBLE);
- }
- else if (type_id == variadic_id) {
- return INT2NUM(TYPE_VARIADIC);
- }
- else if (type_id == const_string_id) {
- return INT2NUM(TYPE_CONST_STRING);
- }
- else if (type_id == size_t_id) {
- return INT2NUM(TYPE_SIZE_T);
- }
- else if (type_id == ssize_t_id) {
- return INT2NUM(TYPE_SSIZE_T);
- }
- else if (type_id == ptrdiff_t_id) {
- return INT2NUM(TYPE_PTRDIFF_T);
- }
- else if (type_id == intptr_t_id) {
- return INT2NUM(TYPE_INTPTR_T);
- }
- else if (type_id == uintptr_t_id) {
- return INT2NUM(TYPE_UINTPTR_T);
- }
- else {
- type = original_type;
- }
- }
-
- return rb_to_int(type);
-}
-
-ffi_type *
-rb_fiddle_int_to_ffi_type(int type)
-{
- int signed_p = 1;
-
- if (type < 0) {
- type = -1 * type;
- signed_p = 0;
- }
-
-#define rb_ffi_type_of(t) (signed_p ? &ffi_type_s##t : &ffi_type_u##t)
-
- switch (type) {
- case TYPE_VOID:
- return &ffi_type_void;
- case TYPE_VOIDP:
- return &ffi_type_pointer;
- case TYPE_CHAR:
- return rb_ffi_type_of(char);
- case TYPE_SHORT:
- return rb_ffi_type_of(short);
- case TYPE_INT:
- return rb_ffi_type_of(int);
- case TYPE_LONG:
- return rb_ffi_type_of(long);
-#if HAVE_LONG_LONG
- case TYPE_LONG_LONG:
- return rb_ffi_type_of(long_long);
-#endif
- case TYPE_FLOAT:
- return &ffi_type_float;
- case TYPE_DOUBLE:
- return &ffi_type_double;
- case TYPE_CONST_STRING:
- return &ffi_type_pointer;
- default:
- rb_raise(rb_eRuntimeError, "unknown type %d", type);
- }
- return &ffi_type_pointer;
-}
-
-ffi_type *
-int_to_ffi_type(int type)
-{
- return rb_fiddle_int_to_ffi_type(type);
-}
-
-void
-rb_fiddle_value_to_generic(int type, VALUE *src, fiddle_generic *dst)
-{
- switch (type) {
- case TYPE_VOID:
- break;
- case TYPE_VOIDP:
- dst->pointer = NUM2PTR(rb_Integer(*src));
- break;
- case TYPE_CHAR:
- dst->schar = (signed char)NUM2INT(*src);
- break;
- case TYPE_UCHAR:
- dst->uchar = (unsigned char)NUM2UINT(*src);
- break;
- case TYPE_SHORT:
- dst->sshort = (unsigned short)NUM2INT(*src);
- break;
- case TYPE_USHORT:
- dst->sshort = (signed short)NUM2UINT(*src);
- break;
- case TYPE_INT:
- dst->sint = NUM2INT(*src);
- break;
- case TYPE_UINT:
- dst->uint = NUM2UINT(*src);
- break;
- case TYPE_LONG:
- dst->slong = NUM2LONG(*src);
- break;
- case TYPE_ULONG:
- dst->ulong = NUM2ULONG(*src);
- break;
-#if HAVE_LONG_LONG
- case TYPE_LONG_LONG:
- dst->slong_long = NUM2LL(*src);
- break;
- case TYPE_ULONG_LONG:
- dst->ulong_long = NUM2ULL(*src);
- break;
-#endif
- case TYPE_FLOAT:
- dst->ffloat = (float)NUM2DBL(*src);
- break;
- case TYPE_DOUBLE:
- dst->ddouble = NUM2DBL(*src);
- break;
- case TYPE_CONST_STRING:
- if (NIL_P(*src)) {
- dst->pointer = NULL;
- }
- else {
- dst->pointer = rb_string_value_cstr(src);
- }
- break;
- default:
- rb_raise(rb_eRuntimeError, "unknown type %d", type);
- }
-}
-
-void
-value_to_generic(int type, VALUE src, fiddle_generic *dst)
-{
- /* src isn't safe from GC when type is TYPE_CONST_STRING and src
- * isn't String. */
- rb_fiddle_value_to_generic(type, &src, dst);
-}
-
-VALUE
-rb_fiddle_generic_to_value(VALUE rettype, fiddle_generic retval)
-{
- int type = NUM2INT(rettype);
- VALUE cPointer;
-
- cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
-
- switch (type) {
- case TYPE_VOID:
- return Qnil;
- case TYPE_VOIDP:
- return rb_funcall(cPointer, rb_intern("[]"), 1,
- PTR2NUM((void *)retval.pointer));
- case TYPE_CHAR:
- return INT2NUM((signed char)retval.fffi_sarg);
- case TYPE_UCHAR:
- return INT2NUM((unsigned char)retval.fffi_arg);
- case TYPE_SHORT:
- return INT2NUM((signed short)retval.fffi_sarg);
- case TYPE_USHORT:
- return INT2NUM((unsigned short)retval.fffi_arg);
- case TYPE_INT:
- return INT2NUM((signed int)retval.fffi_sarg);
- case TYPE_UINT:
- return UINT2NUM((unsigned int)retval.fffi_arg);
- case TYPE_LONG:
- return LONG2NUM(retval.slong);
- case TYPE_ULONG:
- return ULONG2NUM(retval.ulong);
-#if HAVE_LONG_LONG
- case TYPE_LONG_LONG:
- return LL2NUM(retval.slong_long);
- case TYPE_ULONG_LONG:
- return ULL2NUM(retval.ulong_long);
-#endif
- case TYPE_FLOAT:
- return rb_float_new(retval.ffloat);
- case TYPE_DOUBLE:
- return rb_float_new(retval.ddouble);
- case TYPE_CONST_STRING:
- if (retval.pointer) {
- return rb_str_new_cstr(retval.pointer);
- }
- else {
- return Qnil;
- }
- default:
- rb_raise(rb_eRuntimeError, "unknown type %d", type);
- }
-
- UNREACHABLE;
-}
-
-VALUE
-generic_to_value(VALUE rettype, fiddle_generic retval)
-{
- return rb_fiddle_generic_to_value(rettype, retval);
-}
-
-/* vim: set noet sw=4 sts=4 */
diff --git a/ext/fiddle/conversions.h b/ext/fiddle/conversions.h
deleted file mode 100644
index c7c12a9234..0000000000
--- a/ext/fiddle/conversions.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef FIDDLE_CONVERSIONS_H
-#define FIDDLE_CONVERSIONS_H
-
-#include <fiddle.h>
-
-typedef union
-{
- ffi_arg fffi_arg; /* rvalue smaller than unsigned long */
- ffi_sarg fffi_sarg; /* rvalue smaller than signed long */
- unsigned char uchar; /* ffi_type_uchar */
- signed char schar; /* ffi_type_schar */
- unsigned short ushort; /* ffi_type_sshort */
- signed short sshort; /* ffi_type_ushort */
- unsigned int uint; /* ffi_type_uint */
- signed int sint; /* ffi_type_sint */
- unsigned long ulong; /* ffi_type_ulong */
- signed long slong; /* ffi_type_slong */
- float ffloat; /* ffi_type_float */
- double ddouble; /* ffi_type_double */
-#if HAVE_LONG_LONG
- unsigned LONG_LONG ulong_long; /* ffi_type_ulong_long */
- signed LONG_LONG slong_long; /* ffi_type_ulong_long */
-#endif
- void * pointer; /* ffi_type_pointer */
-} fiddle_generic;
-
-VALUE rb_fiddle_type_ensure(VALUE type);
-ffi_type * rb_fiddle_int_to_ffi_type(int type);
-void rb_fiddle_value_to_generic(int type, VALUE *src, fiddle_generic *dst);
-VALUE rb_fiddle_generic_to_value(VALUE rettype, fiddle_generic retval);
-
-/* Deprecated. Use rb_fiddle_*() version. */
-ffi_type * int_to_ffi_type(int type);
-void value_to_generic(int type, VALUE src, fiddle_generic *dst);
-VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
-
-#define VALUE2GENERIC(_type, _src, _dst) \
- rb_fiddle_value_to_generic((_type), &(_src), (_dst))
-#define INT2FFI_TYPE(_type) \
- rb_fiddle_int_to_ffi_type(_type)
-#define GENERIC2VALUE(_type, _retval) \
- rb_fiddle_generic_to_value((_type), (_retval))
-
-#if SIZEOF_VOIDP == SIZEOF_LONG
-# define PTR2NUM(x) (LONG2NUM((long)(x)))
-# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
-#else
-/* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
-# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x)))
-# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
-#endif
-
-#endif
diff --git a/ext/fiddle/depend b/ext/fiddle/depend
deleted file mode 100644
index 561785275e..0000000000
--- a/ext/fiddle/depend
+++ /dev/null
@@ -1,1388 +0,0 @@
-PWD =
-
-CONFIGURE_LIBFFI = \
- $(LIBFFI_CONFIGURE) --disable-shared \
- --host=$(LIBFFI_ARCH) --enable-builddir=$(arch) \
- CC="$(CC)" CFLAGS="$(LIBFFI_CFLAGS)" \
- LD="$(LD)" LDFLAGS="$(LIBFFI_LDFLAGS)"
-
-$(STATIC_LIB) $(RUBYARCHDIR)/$(DLLIB) $(DLLIB): $(LIBFFI_A)
-
-$(OBJS): $(FFI_H)
-
-.PHONY: .FORCE hdr
-
-.FORCE:
-
-hdr: $(FFI_H)
-
-configure-libffi build-libffi: .FORCE
-configure-libffi \
-$(LIBFFI_DIR)/include/ffi.h \
-$(LIBFFI_DIR)/include/ffitarget.h \
-$(LIBFFI_DIR)/fficonfig.h \
-$(LIBFFI_DIR)/Makefile:
- $(Q) $(MAKEDIRS) $(LIBFFI_DIR)
- $(Q) $(CONFIGURE_LIBFFI)
-
-build-libffi $(LIBFFI_A):
- $(Q) $(SUBMAKE_PRE) $(MAKE) $(SUBMAKE_ARG)
-
-clean-none:
-clean-libffi:
- $(Q) $(SUBMAKE_PRE) $(MAKE) $(SUBMAKE_ARG) clean
-
-distclean-none:
-distclean-libffi:
- $(Q) $(SUBMAKE_PRE) $(MAKE) $(SUBMAKE_ARG) distclean
- $(Q) $(RM) $(LIBFFI_DIR)/local.exp
- $(Q) $(RUBY) -rfileutils -e "FileUtils.rmdir(Dir.glob(ARGV[0]+'/**/{,.*/}'), :parents=>true)" $(LIBFFI_DIR)
-
-realclean-none:
-realclean-libffi:
- $(Q) $(RMALL) $(LIBFFI_DIR)
-
-.PHONY: clean-libffi distclean-libffi realclean-libffi
-.PHONY: clean-none distclean-none realclean-none
-
-clean: clean-$(LIBFFI_CLEAN)
-distclean: distclean-$(LIBFFI_CLEAN)
-realclean: realclean-$(LIBFFI_CLEAN)
-
-.PHONY: configure configure-libffi
-
-# AUTOGENERATED DEPENDENCIES START
-closure.o: $(RUBY_EXTCONF_H)
-closure.o: $(arch_hdrdir)/ruby/config.h
-closure.o: $(hdrdir)/ruby.h
-closure.o: $(hdrdir)/ruby/assert.h
-closure.o: $(hdrdir)/ruby/backward.h
-closure.o: $(hdrdir)/ruby/backward/2/assume.h
-closure.o: $(hdrdir)/ruby/backward/2/attributes.h
-closure.o: $(hdrdir)/ruby/backward/2/bool.h
-closure.o: $(hdrdir)/ruby/backward/2/inttypes.h
-closure.o: $(hdrdir)/ruby/backward/2/limits.h
-closure.o: $(hdrdir)/ruby/backward/2/long_long.h
-closure.o: $(hdrdir)/ruby/backward/2/stdalign.h
-closure.o: $(hdrdir)/ruby/backward/2/stdarg.h
-closure.o: $(hdrdir)/ruby/defines.h
-closure.o: $(hdrdir)/ruby/intern.h
-closure.o: $(hdrdir)/ruby/internal/abi.h
-closure.o: $(hdrdir)/ruby/internal/anyargs.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-closure.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-closure.o: $(hdrdir)/ruby/internal/assume.h
-closure.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-closure.o: $(hdrdir)/ruby/internal/attr/artificial.h
-closure.o: $(hdrdir)/ruby/internal/attr/cold.h
-closure.o: $(hdrdir)/ruby/internal/attr/const.h
-closure.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-closure.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-closure.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-closure.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-closure.o: $(hdrdir)/ruby/internal/attr/error.h
-closure.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-closure.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-closure.o: $(hdrdir)/ruby/internal/attr/format.h
-closure.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-closure.o: $(hdrdir)/ruby/internal/attr/noalias.h
-closure.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-closure.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-closure.o: $(hdrdir)/ruby/internal/attr/noinline.h
-closure.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-closure.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-closure.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-closure.o: $(hdrdir)/ruby/internal/attr/pure.h
-closure.o: $(hdrdir)/ruby/internal/attr/restrict.h
-closure.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-closure.o: $(hdrdir)/ruby/internal/attr/warning.h
-closure.o: $(hdrdir)/ruby/internal/attr/weakref.h
-closure.o: $(hdrdir)/ruby/internal/cast.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-closure.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-closure.o: $(hdrdir)/ruby/internal/compiler_since.h
-closure.o: $(hdrdir)/ruby/internal/config.h
-closure.o: $(hdrdir)/ruby/internal/constant_p.h
-closure.o: $(hdrdir)/ruby/internal/core.h
-closure.o: $(hdrdir)/ruby/internal/core/rarray.h
-closure.o: $(hdrdir)/ruby/internal/core/rbasic.h
-closure.o: $(hdrdir)/ruby/internal/core/rbignum.h
-closure.o: $(hdrdir)/ruby/internal/core/rclass.h
-closure.o: $(hdrdir)/ruby/internal/core/rdata.h
-closure.o: $(hdrdir)/ruby/internal/core/rfile.h
-closure.o: $(hdrdir)/ruby/internal/core/rhash.h
-closure.o: $(hdrdir)/ruby/internal/core/robject.h
-closure.o: $(hdrdir)/ruby/internal/core/rregexp.h
-closure.o: $(hdrdir)/ruby/internal/core/rstring.h
-closure.o: $(hdrdir)/ruby/internal/core/rstruct.h
-closure.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-closure.o: $(hdrdir)/ruby/internal/ctype.h
-closure.o: $(hdrdir)/ruby/internal/dllexport.h
-closure.o: $(hdrdir)/ruby/internal/dosish.h
-closure.o: $(hdrdir)/ruby/internal/error.h
-closure.o: $(hdrdir)/ruby/internal/eval.h
-closure.o: $(hdrdir)/ruby/internal/event.h
-closure.o: $(hdrdir)/ruby/internal/fl_type.h
-closure.o: $(hdrdir)/ruby/internal/gc.h
-closure.o: $(hdrdir)/ruby/internal/glob.h
-closure.o: $(hdrdir)/ruby/internal/globals.h
-closure.o: $(hdrdir)/ruby/internal/has/attribute.h
-closure.o: $(hdrdir)/ruby/internal/has/builtin.h
-closure.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-closure.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-closure.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-closure.o: $(hdrdir)/ruby/internal/has/extension.h
-closure.o: $(hdrdir)/ruby/internal/has/feature.h
-closure.o: $(hdrdir)/ruby/internal/has/warning.h
-closure.o: $(hdrdir)/ruby/internal/intern/array.h
-closure.o: $(hdrdir)/ruby/internal/intern/bignum.h
-closure.o: $(hdrdir)/ruby/internal/intern/class.h
-closure.o: $(hdrdir)/ruby/internal/intern/compar.h
-closure.o: $(hdrdir)/ruby/internal/intern/complex.h
-closure.o: $(hdrdir)/ruby/internal/intern/cont.h
-closure.o: $(hdrdir)/ruby/internal/intern/dir.h
-closure.o: $(hdrdir)/ruby/internal/intern/enum.h
-closure.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-closure.o: $(hdrdir)/ruby/internal/intern/error.h
-closure.o: $(hdrdir)/ruby/internal/intern/eval.h
-closure.o: $(hdrdir)/ruby/internal/intern/file.h
-closure.o: $(hdrdir)/ruby/internal/intern/hash.h
-closure.o: $(hdrdir)/ruby/internal/intern/io.h
-closure.o: $(hdrdir)/ruby/internal/intern/load.h
-closure.o: $(hdrdir)/ruby/internal/intern/marshal.h
-closure.o: $(hdrdir)/ruby/internal/intern/numeric.h
-closure.o: $(hdrdir)/ruby/internal/intern/object.h
-closure.o: $(hdrdir)/ruby/internal/intern/parse.h
-closure.o: $(hdrdir)/ruby/internal/intern/proc.h
-closure.o: $(hdrdir)/ruby/internal/intern/process.h
-closure.o: $(hdrdir)/ruby/internal/intern/random.h
-closure.o: $(hdrdir)/ruby/internal/intern/range.h
-closure.o: $(hdrdir)/ruby/internal/intern/rational.h
-closure.o: $(hdrdir)/ruby/internal/intern/re.h
-closure.o: $(hdrdir)/ruby/internal/intern/ruby.h
-closure.o: $(hdrdir)/ruby/internal/intern/select.h
-closure.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-closure.o: $(hdrdir)/ruby/internal/intern/signal.h
-closure.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-closure.o: $(hdrdir)/ruby/internal/intern/string.h
-closure.o: $(hdrdir)/ruby/internal/intern/struct.h
-closure.o: $(hdrdir)/ruby/internal/intern/thread.h
-closure.o: $(hdrdir)/ruby/internal/intern/time.h
-closure.o: $(hdrdir)/ruby/internal/intern/variable.h
-closure.o: $(hdrdir)/ruby/internal/intern/vm.h
-closure.o: $(hdrdir)/ruby/internal/interpreter.h
-closure.o: $(hdrdir)/ruby/internal/iterator.h
-closure.o: $(hdrdir)/ruby/internal/memory.h
-closure.o: $(hdrdir)/ruby/internal/method.h
-closure.o: $(hdrdir)/ruby/internal/module.h
-closure.o: $(hdrdir)/ruby/internal/newobj.h
-closure.o: $(hdrdir)/ruby/internal/scan_args.h
-closure.o: $(hdrdir)/ruby/internal/special_consts.h
-closure.o: $(hdrdir)/ruby/internal/static_assert.h
-closure.o: $(hdrdir)/ruby/internal/stdalign.h
-closure.o: $(hdrdir)/ruby/internal/stdbool.h
-closure.o: $(hdrdir)/ruby/internal/symbol.h
-closure.o: $(hdrdir)/ruby/internal/value.h
-closure.o: $(hdrdir)/ruby/internal/value_type.h
-closure.o: $(hdrdir)/ruby/internal/variable.h
-closure.o: $(hdrdir)/ruby/internal/warning_push.h
-closure.o: $(hdrdir)/ruby/internal/xmalloc.h
-closure.o: $(hdrdir)/ruby/missing.h
-closure.o: $(hdrdir)/ruby/ruby.h
-closure.o: $(hdrdir)/ruby/st.h
-closure.o: $(hdrdir)/ruby/subst.h
-closure.o: $(hdrdir)/ruby/thread.h
-closure.o: closure.c
-closure.o: closure.h
-closure.o: conversions.h
-closure.o: fiddle.h
-closure.o: function.h
-conversions.o: $(RUBY_EXTCONF_H)
-conversions.o: $(arch_hdrdir)/ruby/config.h
-conversions.o: $(hdrdir)/ruby.h
-conversions.o: $(hdrdir)/ruby/assert.h
-conversions.o: $(hdrdir)/ruby/backward.h
-conversions.o: $(hdrdir)/ruby/backward/2/assume.h
-conversions.o: $(hdrdir)/ruby/backward/2/attributes.h
-conversions.o: $(hdrdir)/ruby/backward/2/bool.h
-conversions.o: $(hdrdir)/ruby/backward/2/inttypes.h
-conversions.o: $(hdrdir)/ruby/backward/2/limits.h
-conversions.o: $(hdrdir)/ruby/backward/2/long_long.h
-conversions.o: $(hdrdir)/ruby/backward/2/stdalign.h
-conversions.o: $(hdrdir)/ruby/backward/2/stdarg.h
-conversions.o: $(hdrdir)/ruby/defines.h
-conversions.o: $(hdrdir)/ruby/intern.h
-conversions.o: $(hdrdir)/ruby/internal/abi.h
-conversions.o: $(hdrdir)/ruby/internal/anyargs.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-conversions.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-conversions.o: $(hdrdir)/ruby/internal/assume.h
-conversions.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-conversions.o: $(hdrdir)/ruby/internal/attr/artificial.h
-conversions.o: $(hdrdir)/ruby/internal/attr/cold.h
-conversions.o: $(hdrdir)/ruby/internal/attr/const.h
-conversions.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-conversions.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-conversions.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-conversions.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-conversions.o: $(hdrdir)/ruby/internal/attr/error.h
-conversions.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-conversions.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-conversions.o: $(hdrdir)/ruby/internal/attr/format.h
-conversions.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-conversions.o: $(hdrdir)/ruby/internal/attr/noalias.h
-conversions.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-conversions.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-conversions.o: $(hdrdir)/ruby/internal/attr/noinline.h
-conversions.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-conversions.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-conversions.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-conversions.o: $(hdrdir)/ruby/internal/attr/pure.h
-conversions.o: $(hdrdir)/ruby/internal/attr/restrict.h
-conversions.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-conversions.o: $(hdrdir)/ruby/internal/attr/warning.h
-conversions.o: $(hdrdir)/ruby/internal/attr/weakref.h
-conversions.o: $(hdrdir)/ruby/internal/cast.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-conversions.o: $(hdrdir)/ruby/internal/compiler_since.h
-conversions.o: $(hdrdir)/ruby/internal/config.h
-conversions.o: $(hdrdir)/ruby/internal/constant_p.h
-conversions.o: $(hdrdir)/ruby/internal/core.h
-conversions.o: $(hdrdir)/ruby/internal/core/rarray.h
-conversions.o: $(hdrdir)/ruby/internal/core/rbasic.h
-conversions.o: $(hdrdir)/ruby/internal/core/rbignum.h
-conversions.o: $(hdrdir)/ruby/internal/core/rclass.h
-conversions.o: $(hdrdir)/ruby/internal/core/rdata.h
-conversions.o: $(hdrdir)/ruby/internal/core/rfile.h
-conversions.o: $(hdrdir)/ruby/internal/core/rhash.h
-conversions.o: $(hdrdir)/ruby/internal/core/robject.h
-conversions.o: $(hdrdir)/ruby/internal/core/rregexp.h
-conversions.o: $(hdrdir)/ruby/internal/core/rstring.h
-conversions.o: $(hdrdir)/ruby/internal/core/rstruct.h
-conversions.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-conversions.o: $(hdrdir)/ruby/internal/ctype.h
-conversions.o: $(hdrdir)/ruby/internal/dllexport.h
-conversions.o: $(hdrdir)/ruby/internal/dosish.h
-conversions.o: $(hdrdir)/ruby/internal/error.h
-conversions.o: $(hdrdir)/ruby/internal/eval.h
-conversions.o: $(hdrdir)/ruby/internal/event.h
-conversions.o: $(hdrdir)/ruby/internal/fl_type.h
-conversions.o: $(hdrdir)/ruby/internal/gc.h
-conversions.o: $(hdrdir)/ruby/internal/glob.h
-conversions.o: $(hdrdir)/ruby/internal/globals.h
-conversions.o: $(hdrdir)/ruby/internal/has/attribute.h
-conversions.o: $(hdrdir)/ruby/internal/has/builtin.h
-conversions.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-conversions.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-conversions.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-conversions.o: $(hdrdir)/ruby/internal/has/extension.h
-conversions.o: $(hdrdir)/ruby/internal/has/feature.h
-conversions.o: $(hdrdir)/ruby/internal/has/warning.h
-conversions.o: $(hdrdir)/ruby/internal/intern/array.h
-conversions.o: $(hdrdir)/ruby/internal/intern/bignum.h
-conversions.o: $(hdrdir)/ruby/internal/intern/class.h
-conversions.o: $(hdrdir)/ruby/internal/intern/compar.h
-conversions.o: $(hdrdir)/ruby/internal/intern/complex.h
-conversions.o: $(hdrdir)/ruby/internal/intern/cont.h
-conversions.o: $(hdrdir)/ruby/internal/intern/dir.h
-conversions.o: $(hdrdir)/ruby/internal/intern/enum.h
-conversions.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-conversions.o: $(hdrdir)/ruby/internal/intern/error.h
-conversions.o: $(hdrdir)/ruby/internal/intern/eval.h
-conversions.o: $(hdrdir)/ruby/internal/intern/file.h
-conversions.o: $(hdrdir)/ruby/internal/intern/hash.h
-conversions.o: $(hdrdir)/ruby/internal/intern/io.h
-conversions.o: $(hdrdir)/ruby/internal/intern/load.h
-conversions.o: $(hdrdir)/ruby/internal/intern/marshal.h
-conversions.o: $(hdrdir)/ruby/internal/intern/numeric.h
-conversions.o: $(hdrdir)/ruby/internal/intern/object.h
-conversions.o: $(hdrdir)/ruby/internal/intern/parse.h
-conversions.o: $(hdrdir)/ruby/internal/intern/proc.h
-conversions.o: $(hdrdir)/ruby/internal/intern/process.h
-conversions.o: $(hdrdir)/ruby/internal/intern/random.h
-conversions.o: $(hdrdir)/ruby/internal/intern/range.h
-conversions.o: $(hdrdir)/ruby/internal/intern/rational.h
-conversions.o: $(hdrdir)/ruby/internal/intern/re.h
-conversions.o: $(hdrdir)/ruby/internal/intern/ruby.h
-conversions.o: $(hdrdir)/ruby/internal/intern/select.h
-conversions.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-conversions.o: $(hdrdir)/ruby/internal/intern/signal.h
-conversions.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-conversions.o: $(hdrdir)/ruby/internal/intern/string.h
-conversions.o: $(hdrdir)/ruby/internal/intern/struct.h
-conversions.o: $(hdrdir)/ruby/internal/intern/thread.h
-conversions.o: $(hdrdir)/ruby/internal/intern/time.h
-conversions.o: $(hdrdir)/ruby/internal/intern/variable.h
-conversions.o: $(hdrdir)/ruby/internal/intern/vm.h
-conversions.o: $(hdrdir)/ruby/internal/interpreter.h
-conversions.o: $(hdrdir)/ruby/internal/iterator.h
-conversions.o: $(hdrdir)/ruby/internal/memory.h
-conversions.o: $(hdrdir)/ruby/internal/method.h
-conversions.o: $(hdrdir)/ruby/internal/module.h
-conversions.o: $(hdrdir)/ruby/internal/newobj.h
-conversions.o: $(hdrdir)/ruby/internal/scan_args.h
-conversions.o: $(hdrdir)/ruby/internal/special_consts.h
-conversions.o: $(hdrdir)/ruby/internal/static_assert.h
-conversions.o: $(hdrdir)/ruby/internal/stdalign.h
-conversions.o: $(hdrdir)/ruby/internal/stdbool.h
-conversions.o: $(hdrdir)/ruby/internal/symbol.h
-conversions.o: $(hdrdir)/ruby/internal/value.h
-conversions.o: $(hdrdir)/ruby/internal/value_type.h
-conversions.o: $(hdrdir)/ruby/internal/variable.h
-conversions.o: $(hdrdir)/ruby/internal/warning_push.h
-conversions.o: $(hdrdir)/ruby/internal/xmalloc.h
-conversions.o: $(hdrdir)/ruby/missing.h
-conversions.o: $(hdrdir)/ruby/ruby.h
-conversions.o: $(hdrdir)/ruby/st.h
-conversions.o: $(hdrdir)/ruby/subst.h
-conversions.o: closure.h
-conversions.o: conversions.c
-conversions.o: conversions.h
-conversions.o: fiddle.h
-conversions.o: function.h
-fiddle.o: $(RUBY_EXTCONF_H)
-fiddle.o: $(arch_hdrdir)/ruby/config.h
-fiddle.o: $(hdrdir)/ruby.h
-fiddle.o: $(hdrdir)/ruby/assert.h
-fiddle.o: $(hdrdir)/ruby/backward.h
-fiddle.o: $(hdrdir)/ruby/backward/2/assume.h
-fiddle.o: $(hdrdir)/ruby/backward/2/attributes.h
-fiddle.o: $(hdrdir)/ruby/backward/2/bool.h
-fiddle.o: $(hdrdir)/ruby/backward/2/inttypes.h
-fiddle.o: $(hdrdir)/ruby/backward/2/limits.h
-fiddle.o: $(hdrdir)/ruby/backward/2/long_long.h
-fiddle.o: $(hdrdir)/ruby/backward/2/stdalign.h
-fiddle.o: $(hdrdir)/ruby/backward/2/stdarg.h
-fiddle.o: $(hdrdir)/ruby/defines.h
-fiddle.o: $(hdrdir)/ruby/intern.h
-fiddle.o: $(hdrdir)/ruby/internal/abi.h
-fiddle.o: $(hdrdir)/ruby/internal/anyargs.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-fiddle.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-fiddle.o: $(hdrdir)/ruby/internal/assume.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/artificial.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/cold.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/const.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/error.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/format.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/noalias.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/noinline.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/pure.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/restrict.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/warning.h
-fiddle.o: $(hdrdir)/ruby/internal/attr/weakref.h
-fiddle.o: $(hdrdir)/ruby/internal/cast.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-fiddle.o: $(hdrdir)/ruby/internal/compiler_since.h
-fiddle.o: $(hdrdir)/ruby/internal/config.h
-fiddle.o: $(hdrdir)/ruby/internal/constant_p.h
-fiddle.o: $(hdrdir)/ruby/internal/core.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rarray.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rbasic.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rbignum.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rclass.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rdata.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rfile.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rhash.h
-fiddle.o: $(hdrdir)/ruby/internal/core/robject.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rregexp.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rstring.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rstruct.h
-fiddle.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-fiddle.o: $(hdrdir)/ruby/internal/ctype.h
-fiddle.o: $(hdrdir)/ruby/internal/dllexport.h
-fiddle.o: $(hdrdir)/ruby/internal/dosish.h
-fiddle.o: $(hdrdir)/ruby/internal/error.h
-fiddle.o: $(hdrdir)/ruby/internal/eval.h
-fiddle.o: $(hdrdir)/ruby/internal/event.h
-fiddle.o: $(hdrdir)/ruby/internal/fl_type.h
-fiddle.o: $(hdrdir)/ruby/internal/gc.h
-fiddle.o: $(hdrdir)/ruby/internal/glob.h
-fiddle.o: $(hdrdir)/ruby/internal/globals.h
-fiddle.o: $(hdrdir)/ruby/internal/has/attribute.h
-fiddle.o: $(hdrdir)/ruby/internal/has/builtin.h
-fiddle.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-fiddle.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-fiddle.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-fiddle.o: $(hdrdir)/ruby/internal/has/extension.h
-fiddle.o: $(hdrdir)/ruby/internal/has/feature.h
-fiddle.o: $(hdrdir)/ruby/internal/has/warning.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/array.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/bignum.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/class.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/compar.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/complex.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/cont.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/dir.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/enum.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/error.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/eval.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/file.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/hash.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/io.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/load.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/marshal.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/numeric.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/object.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/parse.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/proc.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/process.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/random.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/range.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/rational.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/re.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/ruby.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/select.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/signal.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/string.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/struct.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/thread.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/time.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/variable.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/vm.h
-fiddle.o: $(hdrdir)/ruby/internal/interpreter.h
-fiddle.o: $(hdrdir)/ruby/internal/iterator.h
-fiddle.o: $(hdrdir)/ruby/internal/memory.h
-fiddle.o: $(hdrdir)/ruby/internal/method.h
-fiddle.o: $(hdrdir)/ruby/internal/module.h
-fiddle.o: $(hdrdir)/ruby/internal/newobj.h
-fiddle.o: $(hdrdir)/ruby/internal/scan_args.h
-fiddle.o: $(hdrdir)/ruby/internal/special_consts.h
-fiddle.o: $(hdrdir)/ruby/internal/static_assert.h
-fiddle.o: $(hdrdir)/ruby/internal/stdalign.h
-fiddle.o: $(hdrdir)/ruby/internal/stdbool.h
-fiddle.o: $(hdrdir)/ruby/internal/symbol.h
-fiddle.o: $(hdrdir)/ruby/internal/value.h
-fiddle.o: $(hdrdir)/ruby/internal/value_type.h
-fiddle.o: $(hdrdir)/ruby/internal/variable.h
-fiddle.o: $(hdrdir)/ruby/internal/warning_push.h
-fiddle.o: $(hdrdir)/ruby/internal/xmalloc.h
-fiddle.o: $(hdrdir)/ruby/missing.h
-fiddle.o: $(hdrdir)/ruby/ruby.h
-fiddle.o: $(hdrdir)/ruby/st.h
-fiddle.o: $(hdrdir)/ruby/subst.h
-fiddle.o: closure.h
-fiddle.o: conversions.h
-fiddle.o: fiddle.c
-fiddle.o: fiddle.h
-fiddle.o: function.h
-function.o: $(RUBY_EXTCONF_H)
-function.o: $(arch_hdrdir)/ruby/config.h
-function.o: $(hdrdir)/ruby.h
-function.o: $(hdrdir)/ruby/assert.h
-function.o: $(hdrdir)/ruby/backward.h
-function.o: $(hdrdir)/ruby/backward/2/assume.h
-function.o: $(hdrdir)/ruby/backward/2/attributes.h
-function.o: $(hdrdir)/ruby/backward/2/bool.h
-function.o: $(hdrdir)/ruby/backward/2/inttypes.h
-function.o: $(hdrdir)/ruby/backward/2/limits.h
-function.o: $(hdrdir)/ruby/backward/2/long_long.h
-function.o: $(hdrdir)/ruby/backward/2/stdalign.h
-function.o: $(hdrdir)/ruby/backward/2/stdarg.h
-function.o: $(hdrdir)/ruby/defines.h
-function.o: $(hdrdir)/ruby/intern.h
-function.o: $(hdrdir)/ruby/internal/abi.h
-function.o: $(hdrdir)/ruby/internal/anyargs.h
-function.o: $(hdrdir)/ruby/internal/arithmetic.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-function.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-function.o: $(hdrdir)/ruby/internal/assume.h
-function.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-function.o: $(hdrdir)/ruby/internal/attr/artificial.h
-function.o: $(hdrdir)/ruby/internal/attr/cold.h
-function.o: $(hdrdir)/ruby/internal/attr/const.h
-function.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-function.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-function.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-function.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-function.o: $(hdrdir)/ruby/internal/attr/error.h
-function.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-function.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-function.o: $(hdrdir)/ruby/internal/attr/format.h
-function.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-function.o: $(hdrdir)/ruby/internal/attr/noalias.h
-function.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-function.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-function.o: $(hdrdir)/ruby/internal/attr/noinline.h
-function.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-function.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-function.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-function.o: $(hdrdir)/ruby/internal/attr/pure.h
-function.o: $(hdrdir)/ruby/internal/attr/restrict.h
-function.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-function.o: $(hdrdir)/ruby/internal/attr/warning.h
-function.o: $(hdrdir)/ruby/internal/attr/weakref.h
-function.o: $(hdrdir)/ruby/internal/cast.h
-function.o: $(hdrdir)/ruby/internal/compiler_is.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-function.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-function.o: $(hdrdir)/ruby/internal/compiler_since.h
-function.o: $(hdrdir)/ruby/internal/config.h
-function.o: $(hdrdir)/ruby/internal/constant_p.h
-function.o: $(hdrdir)/ruby/internal/core.h
-function.o: $(hdrdir)/ruby/internal/core/rarray.h
-function.o: $(hdrdir)/ruby/internal/core/rbasic.h
-function.o: $(hdrdir)/ruby/internal/core/rbignum.h
-function.o: $(hdrdir)/ruby/internal/core/rclass.h
-function.o: $(hdrdir)/ruby/internal/core/rdata.h
-function.o: $(hdrdir)/ruby/internal/core/rfile.h
-function.o: $(hdrdir)/ruby/internal/core/rhash.h
-function.o: $(hdrdir)/ruby/internal/core/robject.h
-function.o: $(hdrdir)/ruby/internal/core/rregexp.h
-function.o: $(hdrdir)/ruby/internal/core/rstring.h
-function.o: $(hdrdir)/ruby/internal/core/rstruct.h
-function.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-function.o: $(hdrdir)/ruby/internal/ctype.h
-function.o: $(hdrdir)/ruby/internal/dllexport.h
-function.o: $(hdrdir)/ruby/internal/dosish.h
-function.o: $(hdrdir)/ruby/internal/error.h
-function.o: $(hdrdir)/ruby/internal/eval.h
-function.o: $(hdrdir)/ruby/internal/event.h
-function.o: $(hdrdir)/ruby/internal/fl_type.h
-function.o: $(hdrdir)/ruby/internal/gc.h
-function.o: $(hdrdir)/ruby/internal/glob.h
-function.o: $(hdrdir)/ruby/internal/globals.h
-function.o: $(hdrdir)/ruby/internal/has/attribute.h
-function.o: $(hdrdir)/ruby/internal/has/builtin.h
-function.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-function.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-function.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-function.o: $(hdrdir)/ruby/internal/has/extension.h
-function.o: $(hdrdir)/ruby/internal/has/feature.h
-function.o: $(hdrdir)/ruby/internal/has/warning.h
-function.o: $(hdrdir)/ruby/internal/intern/array.h
-function.o: $(hdrdir)/ruby/internal/intern/bignum.h
-function.o: $(hdrdir)/ruby/internal/intern/class.h
-function.o: $(hdrdir)/ruby/internal/intern/compar.h
-function.o: $(hdrdir)/ruby/internal/intern/complex.h
-function.o: $(hdrdir)/ruby/internal/intern/cont.h
-function.o: $(hdrdir)/ruby/internal/intern/dir.h
-function.o: $(hdrdir)/ruby/internal/intern/enum.h
-function.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-function.o: $(hdrdir)/ruby/internal/intern/error.h
-function.o: $(hdrdir)/ruby/internal/intern/eval.h
-function.o: $(hdrdir)/ruby/internal/intern/file.h
-function.o: $(hdrdir)/ruby/internal/intern/hash.h
-function.o: $(hdrdir)/ruby/internal/intern/io.h
-function.o: $(hdrdir)/ruby/internal/intern/load.h
-function.o: $(hdrdir)/ruby/internal/intern/marshal.h
-function.o: $(hdrdir)/ruby/internal/intern/numeric.h
-function.o: $(hdrdir)/ruby/internal/intern/object.h
-function.o: $(hdrdir)/ruby/internal/intern/parse.h
-function.o: $(hdrdir)/ruby/internal/intern/proc.h
-function.o: $(hdrdir)/ruby/internal/intern/process.h
-function.o: $(hdrdir)/ruby/internal/intern/random.h
-function.o: $(hdrdir)/ruby/internal/intern/range.h
-function.o: $(hdrdir)/ruby/internal/intern/rational.h
-function.o: $(hdrdir)/ruby/internal/intern/re.h
-function.o: $(hdrdir)/ruby/internal/intern/ruby.h
-function.o: $(hdrdir)/ruby/internal/intern/select.h
-function.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-function.o: $(hdrdir)/ruby/internal/intern/signal.h
-function.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-function.o: $(hdrdir)/ruby/internal/intern/string.h
-function.o: $(hdrdir)/ruby/internal/intern/struct.h
-function.o: $(hdrdir)/ruby/internal/intern/thread.h
-function.o: $(hdrdir)/ruby/internal/intern/time.h
-function.o: $(hdrdir)/ruby/internal/intern/variable.h
-function.o: $(hdrdir)/ruby/internal/intern/vm.h
-function.o: $(hdrdir)/ruby/internal/interpreter.h
-function.o: $(hdrdir)/ruby/internal/iterator.h
-function.o: $(hdrdir)/ruby/internal/memory.h
-function.o: $(hdrdir)/ruby/internal/method.h
-function.o: $(hdrdir)/ruby/internal/module.h
-function.o: $(hdrdir)/ruby/internal/newobj.h
-function.o: $(hdrdir)/ruby/internal/scan_args.h
-function.o: $(hdrdir)/ruby/internal/special_consts.h
-function.o: $(hdrdir)/ruby/internal/static_assert.h
-function.o: $(hdrdir)/ruby/internal/stdalign.h
-function.o: $(hdrdir)/ruby/internal/stdbool.h
-function.o: $(hdrdir)/ruby/internal/symbol.h
-function.o: $(hdrdir)/ruby/internal/value.h
-function.o: $(hdrdir)/ruby/internal/value_type.h
-function.o: $(hdrdir)/ruby/internal/variable.h
-function.o: $(hdrdir)/ruby/internal/warning_push.h
-function.o: $(hdrdir)/ruby/internal/xmalloc.h
-function.o: $(hdrdir)/ruby/missing.h
-function.o: $(hdrdir)/ruby/ruby.h
-function.o: $(hdrdir)/ruby/st.h
-function.o: $(hdrdir)/ruby/subst.h
-function.o: $(hdrdir)/ruby/thread.h
-function.o: closure.h
-function.o: conversions.h
-function.o: fiddle.h
-function.o: function.c
-function.o: function.h
-handle.o: $(RUBY_EXTCONF_H)
-handle.o: $(arch_hdrdir)/ruby/config.h
-handle.o: $(hdrdir)/ruby.h
-handle.o: $(hdrdir)/ruby/assert.h
-handle.o: $(hdrdir)/ruby/backward.h
-handle.o: $(hdrdir)/ruby/backward/2/assume.h
-handle.o: $(hdrdir)/ruby/backward/2/attributes.h
-handle.o: $(hdrdir)/ruby/backward/2/bool.h
-handle.o: $(hdrdir)/ruby/backward/2/inttypes.h
-handle.o: $(hdrdir)/ruby/backward/2/limits.h
-handle.o: $(hdrdir)/ruby/backward/2/long_long.h
-handle.o: $(hdrdir)/ruby/backward/2/stdalign.h
-handle.o: $(hdrdir)/ruby/backward/2/stdarg.h
-handle.o: $(hdrdir)/ruby/defines.h
-handle.o: $(hdrdir)/ruby/intern.h
-handle.o: $(hdrdir)/ruby/internal/abi.h
-handle.o: $(hdrdir)/ruby/internal/anyargs.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-handle.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-handle.o: $(hdrdir)/ruby/internal/assume.h
-handle.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-handle.o: $(hdrdir)/ruby/internal/attr/artificial.h
-handle.o: $(hdrdir)/ruby/internal/attr/cold.h
-handle.o: $(hdrdir)/ruby/internal/attr/const.h
-handle.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-handle.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-handle.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-handle.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-handle.o: $(hdrdir)/ruby/internal/attr/error.h
-handle.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-handle.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-handle.o: $(hdrdir)/ruby/internal/attr/format.h
-handle.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-handle.o: $(hdrdir)/ruby/internal/attr/noalias.h
-handle.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-handle.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-handle.o: $(hdrdir)/ruby/internal/attr/noinline.h
-handle.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-handle.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-handle.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-handle.o: $(hdrdir)/ruby/internal/attr/pure.h
-handle.o: $(hdrdir)/ruby/internal/attr/restrict.h
-handle.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-handle.o: $(hdrdir)/ruby/internal/attr/warning.h
-handle.o: $(hdrdir)/ruby/internal/attr/weakref.h
-handle.o: $(hdrdir)/ruby/internal/cast.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-handle.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-handle.o: $(hdrdir)/ruby/internal/compiler_since.h
-handle.o: $(hdrdir)/ruby/internal/config.h
-handle.o: $(hdrdir)/ruby/internal/constant_p.h
-handle.o: $(hdrdir)/ruby/internal/core.h
-handle.o: $(hdrdir)/ruby/internal/core/rarray.h
-handle.o: $(hdrdir)/ruby/internal/core/rbasic.h
-handle.o: $(hdrdir)/ruby/internal/core/rbignum.h
-handle.o: $(hdrdir)/ruby/internal/core/rclass.h
-handle.o: $(hdrdir)/ruby/internal/core/rdata.h
-handle.o: $(hdrdir)/ruby/internal/core/rfile.h
-handle.o: $(hdrdir)/ruby/internal/core/rhash.h
-handle.o: $(hdrdir)/ruby/internal/core/robject.h
-handle.o: $(hdrdir)/ruby/internal/core/rregexp.h
-handle.o: $(hdrdir)/ruby/internal/core/rstring.h
-handle.o: $(hdrdir)/ruby/internal/core/rstruct.h
-handle.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-handle.o: $(hdrdir)/ruby/internal/ctype.h
-handle.o: $(hdrdir)/ruby/internal/dllexport.h
-handle.o: $(hdrdir)/ruby/internal/dosish.h
-handle.o: $(hdrdir)/ruby/internal/error.h
-handle.o: $(hdrdir)/ruby/internal/eval.h
-handle.o: $(hdrdir)/ruby/internal/event.h
-handle.o: $(hdrdir)/ruby/internal/fl_type.h
-handle.o: $(hdrdir)/ruby/internal/gc.h
-handle.o: $(hdrdir)/ruby/internal/glob.h
-handle.o: $(hdrdir)/ruby/internal/globals.h
-handle.o: $(hdrdir)/ruby/internal/has/attribute.h
-handle.o: $(hdrdir)/ruby/internal/has/builtin.h
-handle.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-handle.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-handle.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-handle.o: $(hdrdir)/ruby/internal/has/extension.h
-handle.o: $(hdrdir)/ruby/internal/has/feature.h
-handle.o: $(hdrdir)/ruby/internal/has/warning.h
-handle.o: $(hdrdir)/ruby/internal/intern/array.h
-handle.o: $(hdrdir)/ruby/internal/intern/bignum.h
-handle.o: $(hdrdir)/ruby/internal/intern/class.h
-handle.o: $(hdrdir)/ruby/internal/intern/compar.h
-handle.o: $(hdrdir)/ruby/internal/intern/complex.h
-handle.o: $(hdrdir)/ruby/internal/intern/cont.h
-handle.o: $(hdrdir)/ruby/internal/intern/dir.h
-handle.o: $(hdrdir)/ruby/internal/intern/enum.h
-handle.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-handle.o: $(hdrdir)/ruby/internal/intern/error.h
-handle.o: $(hdrdir)/ruby/internal/intern/eval.h
-handle.o: $(hdrdir)/ruby/internal/intern/file.h
-handle.o: $(hdrdir)/ruby/internal/intern/hash.h
-handle.o: $(hdrdir)/ruby/internal/intern/io.h
-handle.o: $(hdrdir)/ruby/internal/intern/load.h
-handle.o: $(hdrdir)/ruby/internal/intern/marshal.h
-handle.o: $(hdrdir)/ruby/internal/intern/numeric.h
-handle.o: $(hdrdir)/ruby/internal/intern/object.h
-handle.o: $(hdrdir)/ruby/internal/intern/parse.h
-handle.o: $(hdrdir)/ruby/internal/intern/proc.h
-handle.o: $(hdrdir)/ruby/internal/intern/process.h
-handle.o: $(hdrdir)/ruby/internal/intern/random.h
-handle.o: $(hdrdir)/ruby/internal/intern/range.h
-handle.o: $(hdrdir)/ruby/internal/intern/rational.h
-handle.o: $(hdrdir)/ruby/internal/intern/re.h
-handle.o: $(hdrdir)/ruby/internal/intern/ruby.h
-handle.o: $(hdrdir)/ruby/internal/intern/select.h
-handle.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-handle.o: $(hdrdir)/ruby/internal/intern/signal.h
-handle.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-handle.o: $(hdrdir)/ruby/internal/intern/string.h
-handle.o: $(hdrdir)/ruby/internal/intern/struct.h
-handle.o: $(hdrdir)/ruby/internal/intern/thread.h
-handle.o: $(hdrdir)/ruby/internal/intern/time.h
-handle.o: $(hdrdir)/ruby/internal/intern/variable.h
-handle.o: $(hdrdir)/ruby/internal/intern/vm.h
-handle.o: $(hdrdir)/ruby/internal/interpreter.h
-handle.o: $(hdrdir)/ruby/internal/iterator.h
-handle.o: $(hdrdir)/ruby/internal/memory.h
-handle.o: $(hdrdir)/ruby/internal/method.h
-handle.o: $(hdrdir)/ruby/internal/module.h
-handle.o: $(hdrdir)/ruby/internal/newobj.h
-handle.o: $(hdrdir)/ruby/internal/scan_args.h
-handle.o: $(hdrdir)/ruby/internal/special_consts.h
-handle.o: $(hdrdir)/ruby/internal/static_assert.h
-handle.o: $(hdrdir)/ruby/internal/stdalign.h
-handle.o: $(hdrdir)/ruby/internal/stdbool.h
-handle.o: $(hdrdir)/ruby/internal/symbol.h
-handle.o: $(hdrdir)/ruby/internal/value.h
-handle.o: $(hdrdir)/ruby/internal/value_type.h
-handle.o: $(hdrdir)/ruby/internal/variable.h
-handle.o: $(hdrdir)/ruby/internal/warning_push.h
-handle.o: $(hdrdir)/ruby/internal/xmalloc.h
-handle.o: $(hdrdir)/ruby/missing.h
-handle.o: $(hdrdir)/ruby/ruby.h
-handle.o: $(hdrdir)/ruby/st.h
-handle.o: $(hdrdir)/ruby/subst.h
-handle.o: closure.h
-handle.o: conversions.h
-handle.o: fiddle.h
-handle.o: function.h
-handle.o: handle.c
-memory_view.o: $(RUBY_EXTCONF_H)
-memory_view.o: $(arch_hdrdir)/ruby/config.h
-memory_view.o: $(hdrdir)/ruby.h
-memory_view.o: $(hdrdir)/ruby/assert.h
-memory_view.o: $(hdrdir)/ruby/backward.h
-memory_view.o: $(hdrdir)/ruby/backward/2/assume.h
-memory_view.o: $(hdrdir)/ruby/backward/2/attributes.h
-memory_view.o: $(hdrdir)/ruby/backward/2/bool.h
-memory_view.o: $(hdrdir)/ruby/backward/2/inttypes.h
-memory_view.o: $(hdrdir)/ruby/backward/2/limits.h
-memory_view.o: $(hdrdir)/ruby/backward/2/long_long.h
-memory_view.o: $(hdrdir)/ruby/backward/2/stdalign.h
-memory_view.o: $(hdrdir)/ruby/backward/2/stdarg.h
-memory_view.o: $(hdrdir)/ruby/defines.h
-memory_view.o: $(hdrdir)/ruby/encoding.h
-memory_view.o: $(hdrdir)/ruby/intern.h
-memory_view.o: $(hdrdir)/ruby/internal/abi.h
-memory_view.o: $(hdrdir)/ruby/internal/anyargs.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-memory_view.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-memory_view.o: $(hdrdir)/ruby/internal/assume.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/artificial.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/cold.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/const.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/error.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/format.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/noalias.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/noinline.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/pure.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/restrict.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/warning.h
-memory_view.o: $(hdrdir)/ruby/internal/attr/weakref.h
-memory_view.o: $(hdrdir)/ruby/internal/cast.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-memory_view.o: $(hdrdir)/ruby/internal/compiler_since.h
-memory_view.o: $(hdrdir)/ruby/internal/config.h
-memory_view.o: $(hdrdir)/ruby/internal/constant_p.h
-memory_view.o: $(hdrdir)/ruby/internal/core.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rarray.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rbasic.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rbignum.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rclass.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rdata.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rfile.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rhash.h
-memory_view.o: $(hdrdir)/ruby/internal/core/robject.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rregexp.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rstring.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rstruct.h
-memory_view.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-memory_view.o: $(hdrdir)/ruby/internal/ctype.h
-memory_view.o: $(hdrdir)/ruby/internal/dllexport.h
-memory_view.o: $(hdrdir)/ruby/internal/dosish.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/re.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/string.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-memory_view.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-memory_view.o: $(hdrdir)/ruby/internal/error.h
-memory_view.o: $(hdrdir)/ruby/internal/eval.h
-memory_view.o: $(hdrdir)/ruby/internal/event.h
-memory_view.o: $(hdrdir)/ruby/internal/fl_type.h
-memory_view.o: $(hdrdir)/ruby/internal/gc.h
-memory_view.o: $(hdrdir)/ruby/internal/glob.h
-memory_view.o: $(hdrdir)/ruby/internal/globals.h
-memory_view.o: $(hdrdir)/ruby/internal/has/attribute.h
-memory_view.o: $(hdrdir)/ruby/internal/has/builtin.h
-memory_view.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-memory_view.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-memory_view.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-memory_view.o: $(hdrdir)/ruby/internal/has/extension.h
-memory_view.o: $(hdrdir)/ruby/internal/has/feature.h
-memory_view.o: $(hdrdir)/ruby/internal/has/warning.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/array.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/bignum.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/class.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/compar.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/complex.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/cont.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/dir.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/enum.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/error.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/eval.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/file.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/hash.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/io.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/load.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/marshal.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/numeric.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/object.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/parse.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/proc.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/process.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/random.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/range.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/rational.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/re.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/ruby.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/select.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/signal.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/string.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/struct.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/thread.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/time.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/variable.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/vm.h
-memory_view.o: $(hdrdir)/ruby/internal/interpreter.h
-memory_view.o: $(hdrdir)/ruby/internal/iterator.h
-memory_view.o: $(hdrdir)/ruby/internal/memory.h
-memory_view.o: $(hdrdir)/ruby/internal/method.h
-memory_view.o: $(hdrdir)/ruby/internal/module.h
-memory_view.o: $(hdrdir)/ruby/internal/newobj.h
-memory_view.o: $(hdrdir)/ruby/internal/scan_args.h
-memory_view.o: $(hdrdir)/ruby/internal/special_consts.h
-memory_view.o: $(hdrdir)/ruby/internal/static_assert.h
-memory_view.o: $(hdrdir)/ruby/internal/stdalign.h
-memory_view.o: $(hdrdir)/ruby/internal/stdbool.h
-memory_view.o: $(hdrdir)/ruby/internal/symbol.h
-memory_view.o: $(hdrdir)/ruby/internal/value.h
-memory_view.o: $(hdrdir)/ruby/internal/value_type.h
-memory_view.o: $(hdrdir)/ruby/internal/variable.h
-memory_view.o: $(hdrdir)/ruby/internal/warning_push.h
-memory_view.o: $(hdrdir)/ruby/internal/xmalloc.h
-memory_view.o: $(hdrdir)/ruby/memory_view.h
-memory_view.o: $(hdrdir)/ruby/missing.h
-memory_view.o: $(hdrdir)/ruby/onigmo.h
-memory_view.o: $(hdrdir)/ruby/oniguruma.h
-memory_view.o: $(hdrdir)/ruby/ruby.h
-memory_view.o: $(hdrdir)/ruby/st.h
-memory_view.o: $(hdrdir)/ruby/subst.h
-memory_view.o: closure.h
-memory_view.o: conversions.h
-memory_view.o: fiddle.h
-memory_view.o: function.h
-memory_view.o: memory_view.c
-pinned.o: $(RUBY_EXTCONF_H)
-pinned.o: $(arch_hdrdir)/ruby/config.h
-pinned.o: $(hdrdir)/ruby.h
-pinned.o: $(hdrdir)/ruby/assert.h
-pinned.o: $(hdrdir)/ruby/backward.h
-pinned.o: $(hdrdir)/ruby/backward/2/assume.h
-pinned.o: $(hdrdir)/ruby/backward/2/attributes.h
-pinned.o: $(hdrdir)/ruby/backward/2/bool.h
-pinned.o: $(hdrdir)/ruby/backward/2/inttypes.h
-pinned.o: $(hdrdir)/ruby/backward/2/limits.h
-pinned.o: $(hdrdir)/ruby/backward/2/long_long.h
-pinned.o: $(hdrdir)/ruby/backward/2/stdalign.h
-pinned.o: $(hdrdir)/ruby/backward/2/stdarg.h
-pinned.o: $(hdrdir)/ruby/defines.h
-pinned.o: $(hdrdir)/ruby/intern.h
-pinned.o: $(hdrdir)/ruby/internal/abi.h
-pinned.o: $(hdrdir)/ruby/internal/anyargs.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-pinned.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-pinned.o: $(hdrdir)/ruby/internal/assume.h
-pinned.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-pinned.o: $(hdrdir)/ruby/internal/attr/artificial.h
-pinned.o: $(hdrdir)/ruby/internal/attr/cold.h
-pinned.o: $(hdrdir)/ruby/internal/attr/const.h
-pinned.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-pinned.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-pinned.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-pinned.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-pinned.o: $(hdrdir)/ruby/internal/attr/error.h
-pinned.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-pinned.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-pinned.o: $(hdrdir)/ruby/internal/attr/format.h
-pinned.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-pinned.o: $(hdrdir)/ruby/internal/attr/noalias.h
-pinned.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-pinned.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-pinned.o: $(hdrdir)/ruby/internal/attr/noinline.h
-pinned.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-pinned.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-pinned.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-pinned.o: $(hdrdir)/ruby/internal/attr/pure.h
-pinned.o: $(hdrdir)/ruby/internal/attr/restrict.h
-pinned.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-pinned.o: $(hdrdir)/ruby/internal/attr/warning.h
-pinned.o: $(hdrdir)/ruby/internal/attr/weakref.h
-pinned.o: $(hdrdir)/ruby/internal/cast.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-pinned.o: $(hdrdir)/ruby/internal/compiler_since.h
-pinned.o: $(hdrdir)/ruby/internal/config.h
-pinned.o: $(hdrdir)/ruby/internal/constant_p.h
-pinned.o: $(hdrdir)/ruby/internal/core.h
-pinned.o: $(hdrdir)/ruby/internal/core/rarray.h
-pinned.o: $(hdrdir)/ruby/internal/core/rbasic.h
-pinned.o: $(hdrdir)/ruby/internal/core/rbignum.h
-pinned.o: $(hdrdir)/ruby/internal/core/rclass.h
-pinned.o: $(hdrdir)/ruby/internal/core/rdata.h
-pinned.o: $(hdrdir)/ruby/internal/core/rfile.h
-pinned.o: $(hdrdir)/ruby/internal/core/rhash.h
-pinned.o: $(hdrdir)/ruby/internal/core/robject.h
-pinned.o: $(hdrdir)/ruby/internal/core/rregexp.h
-pinned.o: $(hdrdir)/ruby/internal/core/rstring.h
-pinned.o: $(hdrdir)/ruby/internal/core/rstruct.h
-pinned.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-pinned.o: $(hdrdir)/ruby/internal/ctype.h
-pinned.o: $(hdrdir)/ruby/internal/dllexport.h
-pinned.o: $(hdrdir)/ruby/internal/dosish.h
-pinned.o: $(hdrdir)/ruby/internal/error.h
-pinned.o: $(hdrdir)/ruby/internal/eval.h
-pinned.o: $(hdrdir)/ruby/internal/event.h
-pinned.o: $(hdrdir)/ruby/internal/fl_type.h
-pinned.o: $(hdrdir)/ruby/internal/gc.h
-pinned.o: $(hdrdir)/ruby/internal/glob.h
-pinned.o: $(hdrdir)/ruby/internal/globals.h
-pinned.o: $(hdrdir)/ruby/internal/has/attribute.h
-pinned.o: $(hdrdir)/ruby/internal/has/builtin.h
-pinned.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-pinned.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-pinned.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-pinned.o: $(hdrdir)/ruby/internal/has/extension.h
-pinned.o: $(hdrdir)/ruby/internal/has/feature.h
-pinned.o: $(hdrdir)/ruby/internal/has/warning.h
-pinned.o: $(hdrdir)/ruby/internal/intern/array.h
-pinned.o: $(hdrdir)/ruby/internal/intern/bignum.h
-pinned.o: $(hdrdir)/ruby/internal/intern/class.h
-pinned.o: $(hdrdir)/ruby/internal/intern/compar.h
-pinned.o: $(hdrdir)/ruby/internal/intern/complex.h
-pinned.o: $(hdrdir)/ruby/internal/intern/cont.h
-pinned.o: $(hdrdir)/ruby/internal/intern/dir.h
-pinned.o: $(hdrdir)/ruby/internal/intern/enum.h
-pinned.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-pinned.o: $(hdrdir)/ruby/internal/intern/error.h
-pinned.o: $(hdrdir)/ruby/internal/intern/eval.h
-pinned.o: $(hdrdir)/ruby/internal/intern/file.h
-pinned.o: $(hdrdir)/ruby/internal/intern/hash.h
-pinned.o: $(hdrdir)/ruby/internal/intern/io.h
-pinned.o: $(hdrdir)/ruby/internal/intern/load.h
-pinned.o: $(hdrdir)/ruby/internal/intern/marshal.h
-pinned.o: $(hdrdir)/ruby/internal/intern/numeric.h
-pinned.o: $(hdrdir)/ruby/internal/intern/object.h
-pinned.o: $(hdrdir)/ruby/internal/intern/parse.h
-pinned.o: $(hdrdir)/ruby/internal/intern/proc.h
-pinned.o: $(hdrdir)/ruby/internal/intern/process.h
-pinned.o: $(hdrdir)/ruby/internal/intern/random.h
-pinned.o: $(hdrdir)/ruby/internal/intern/range.h
-pinned.o: $(hdrdir)/ruby/internal/intern/rational.h
-pinned.o: $(hdrdir)/ruby/internal/intern/re.h
-pinned.o: $(hdrdir)/ruby/internal/intern/ruby.h
-pinned.o: $(hdrdir)/ruby/internal/intern/select.h
-pinned.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-pinned.o: $(hdrdir)/ruby/internal/intern/signal.h
-pinned.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-pinned.o: $(hdrdir)/ruby/internal/intern/string.h
-pinned.o: $(hdrdir)/ruby/internal/intern/struct.h
-pinned.o: $(hdrdir)/ruby/internal/intern/thread.h
-pinned.o: $(hdrdir)/ruby/internal/intern/time.h
-pinned.o: $(hdrdir)/ruby/internal/intern/variable.h
-pinned.o: $(hdrdir)/ruby/internal/intern/vm.h
-pinned.o: $(hdrdir)/ruby/internal/interpreter.h
-pinned.o: $(hdrdir)/ruby/internal/iterator.h
-pinned.o: $(hdrdir)/ruby/internal/memory.h
-pinned.o: $(hdrdir)/ruby/internal/method.h
-pinned.o: $(hdrdir)/ruby/internal/module.h
-pinned.o: $(hdrdir)/ruby/internal/newobj.h
-pinned.o: $(hdrdir)/ruby/internal/scan_args.h
-pinned.o: $(hdrdir)/ruby/internal/special_consts.h
-pinned.o: $(hdrdir)/ruby/internal/static_assert.h
-pinned.o: $(hdrdir)/ruby/internal/stdalign.h
-pinned.o: $(hdrdir)/ruby/internal/stdbool.h
-pinned.o: $(hdrdir)/ruby/internal/symbol.h
-pinned.o: $(hdrdir)/ruby/internal/value.h
-pinned.o: $(hdrdir)/ruby/internal/value_type.h
-pinned.o: $(hdrdir)/ruby/internal/variable.h
-pinned.o: $(hdrdir)/ruby/internal/warning_push.h
-pinned.o: $(hdrdir)/ruby/internal/xmalloc.h
-pinned.o: $(hdrdir)/ruby/missing.h
-pinned.o: $(hdrdir)/ruby/ruby.h
-pinned.o: $(hdrdir)/ruby/st.h
-pinned.o: $(hdrdir)/ruby/subst.h
-pinned.o: closure.h
-pinned.o: conversions.h
-pinned.o: fiddle.h
-pinned.o: function.h
-pinned.o: pinned.c
-pointer.o: $(RUBY_EXTCONF_H)
-pointer.o: $(arch_hdrdir)/ruby/config.h
-pointer.o: $(hdrdir)/ruby.h
-pointer.o: $(hdrdir)/ruby/assert.h
-pointer.o: $(hdrdir)/ruby/backward.h
-pointer.o: $(hdrdir)/ruby/backward/2/assume.h
-pointer.o: $(hdrdir)/ruby/backward/2/attributes.h
-pointer.o: $(hdrdir)/ruby/backward/2/bool.h
-pointer.o: $(hdrdir)/ruby/backward/2/inttypes.h
-pointer.o: $(hdrdir)/ruby/backward/2/limits.h
-pointer.o: $(hdrdir)/ruby/backward/2/long_long.h
-pointer.o: $(hdrdir)/ruby/backward/2/stdalign.h
-pointer.o: $(hdrdir)/ruby/backward/2/stdarg.h
-pointer.o: $(hdrdir)/ruby/defines.h
-pointer.o: $(hdrdir)/ruby/encoding.h
-pointer.o: $(hdrdir)/ruby/intern.h
-pointer.o: $(hdrdir)/ruby/internal/abi.h
-pointer.o: $(hdrdir)/ruby/internal/anyargs.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-pointer.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-pointer.o: $(hdrdir)/ruby/internal/assume.h
-pointer.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-pointer.o: $(hdrdir)/ruby/internal/attr/artificial.h
-pointer.o: $(hdrdir)/ruby/internal/attr/cold.h
-pointer.o: $(hdrdir)/ruby/internal/attr/const.h
-pointer.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-pointer.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-pointer.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-pointer.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-pointer.o: $(hdrdir)/ruby/internal/attr/error.h
-pointer.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-pointer.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-pointer.o: $(hdrdir)/ruby/internal/attr/format.h
-pointer.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-pointer.o: $(hdrdir)/ruby/internal/attr/noalias.h
-pointer.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-pointer.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-pointer.o: $(hdrdir)/ruby/internal/attr/noinline.h
-pointer.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-pointer.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-pointer.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-pointer.o: $(hdrdir)/ruby/internal/attr/pure.h
-pointer.o: $(hdrdir)/ruby/internal/attr/restrict.h
-pointer.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-pointer.o: $(hdrdir)/ruby/internal/attr/warning.h
-pointer.o: $(hdrdir)/ruby/internal/attr/weakref.h
-pointer.o: $(hdrdir)/ruby/internal/cast.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-pointer.o: $(hdrdir)/ruby/internal/compiler_since.h
-pointer.o: $(hdrdir)/ruby/internal/config.h
-pointer.o: $(hdrdir)/ruby/internal/constant_p.h
-pointer.o: $(hdrdir)/ruby/internal/core.h
-pointer.o: $(hdrdir)/ruby/internal/core/rarray.h
-pointer.o: $(hdrdir)/ruby/internal/core/rbasic.h
-pointer.o: $(hdrdir)/ruby/internal/core/rbignum.h
-pointer.o: $(hdrdir)/ruby/internal/core/rclass.h
-pointer.o: $(hdrdir)/ruby/internal/core/rdata.h
-pointer.o: $(hdrdir)/ruby/internal/core/rfile.h
-pointer.o: $(hdrdir)/ruby/internal/core/rhash.h
-pointer.o: $(hdrdir)/ruby/internal/core/robject.h
-pointer.o: $(hdrdir)/ruby/internal/core/rregexp.h
-pointer.o: $(hdrdir)/ruby/internal/core/rstring.h
-pointer.o: $(hdrdir)/ruby/internal/core/rstruct.h
-pointer.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-pointer.o: $(hdrdir)/ruby/internal/ctype.h
-pointer.o: $(hdrdir)/ruby/internal/dllexport.h
-pointer.o: $(hdrdir)/ruby/internal/dosish.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/re.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/string.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-pointer.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-pointer.o: $(hdrdir)/ruby/internal/error.h
-pointer.o: $(hdrdir)/ruby/internal/eval.h
-pointer.o: $(hdrdir)/ruby/internal/event.h
-pointer.o: $(hdrdir)/ruby/internal/fl_type.h
-pointer.o: $(hdrdir)/ruby/internal/gc.h
-pointer.o: $(hdrdir)/ruby/internal/glob.h
-pointer.o: $(hdrdir)/ruby/internal/globals.h
-pointer.o: $(hdrdir)/ruby/internal/has/attribute.h
-pointer.o: $(hdrdir)/ruby/internal/has/builtin.h
-pointer.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-pointer.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-pointer.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-pointer.o: $(hdrdir)/ruby/internal/has/extension.h
-pointer.o: $(hdrdir)/ruby/internal/has/feature.h
-pointer.o: $(hdrdir)/ruby/internal/has/warning.h
-pointer.o: $(hdrdir)/ruby/internal/intern/array.h
-pointer.o: $(hdrdir)/ruby/internal/intern/bignum.h
-pointer.o: $(hdrdir)/ruby/internal/intern/class.h
-pointer.o: $(hdrdir)/ruby/internal/intern/compar.h
-pointer.o: $(hdrdir)/ruby/internal/intern/complex.h
-pointer.o: $(hdrdir)/ruby/internal/intern/cont.h
-pointer.o: $(hdrdir)/ruby/internal/intern/dir.h
-pointer.o: $(hdrdir)/ruby/internal/intern/enum.h
-pointer.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-pointer.o: $(hdrdir)/ruby/internal/intern/error.h
-pointer.o: $(hdrdir)/ruby/internal/intern/eval.h
-pointer.o: $(hdrdir)/ruby/internal/intern/file.h
-pointer.o: $(hdrdir)/ruby/internal/intern/hash.h
-pointer.o: $(hdrdir)/ruby/internal/intern/io.h
-pointer.o: $(hdrdir)/ruby/internal/intern/load.h
-pointer.o: $(hdrdir)/ruby/internal/intern/marshal.h
-pointer.o: $(hdrdir)/ruby/internal/intern/numeric.h
-pointer.o: $(hdrdir)/ruby/internal/intern/object.h
-pointer.o: $(hdrdir)/ruby/internal/intern/parse.h
-pointer.o: $(hdrdir)/ruby/internal/intern/proc.h
-pointer.o: $(hdrdir)/ruby/internal/intern/process.h
-pointer.o: $(hdrdir)/ruby/internal/intern/random.h
-pointer.o: $(hdrdir)/ruby/internal/intern/range.h
-pointer.o: $(hdrdir)/ruby/internal/intern/rational.h
-pointer.o: $(hdrdir)/ruby/internal/intern/re.h
-pointer.o: $(hdrdir)/ruby/internal/intern/ruby.h
-pointer.o: $(hdrdir)/ruby/internal/intern/select.h
-pointer.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-pointer.o: $(hdrdir)/ruby/internal/intern/signal.h
-pointer.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-pointer.o: $(hdrdir)/ruby/internal/intern/string.h
-pointer.o: $(hdrdir)/ruby/internal/intern/struct.h
-pointer.o: $(hdrdir)/ruby/internal/intern/thread.h
-pointer.o: $(hdrdir)/ruby/internal/intern/time.h
-pointer.o: $(hdrdir)/ruby/internal/intern/variable.h
-pointer.o: $(hdrdir)/ruby/internal/intern/vm.h
-pointer.o: $(hdrdir)/ruby/internal/interpreter.h
-pointer.o: $(hdrdir)/ruby/internal/iterator.h
-pointer.o: $(hdrdir)/ruby/internal/memory.h
-pointer.o: $(hdrdir)/ruby/internal/method.h
-pointer.o: $(hdrdir)/ruby/internal/module.h
-pointer.o: $(hdrdir)/ruby/internal/newobj.h
-pointer.o: $(hdrdir)/ruby/internal/scan_args.h
-pointer.o: $(hdrdir)/ruby/internal/special_consts.h
-pointer.o: $(hdrdir)/ruby/internal/static_assert.h
-pointer.o: $(hdrdir)/ruby/internal/stdalign.h
-pointer.o: $(hdrdir)/ruby/internal/stdbool.h
-pointer.o: $(hdrdir)/ruby/internal/symbol.h
-pointer.o: $(hdrdir)/ruby/internal/value.h
-pointer.o: $(hdrdir)/ruby/internal/value_type.h
-pointer.o: $(hdrdir)/ruby/internal/variable.h
-pointer.o: $(hdrdir)/ruby/internal/warning_push.h
-pointer.o: $(hdrdir)/ruby/internal/xmalloc.h
-pointer.o: $(hdrdir)/ruby/io.h
-pointer.o: $(hdrdir)/ruby/memory_view.h
-pointer.o: $(hdrdir)/ruby/missing.h
-pointer.o: $(hdrdir)/ruby/onigmo.h
-pointer.o: $(hdrdir)/ruby/oniguruma.h
-pointer.o: $(hdrdir)/ruby/ruby.h
-pointer.o: $(hdrdir)/ruby/st.h
-pointer.o: $(hdrdir)/ruby/subst.h
-pointer.o: closure.h
-pointer.o: conversions.h
-pointer.o: fiddle.h
-pointer.o: function.h
-pointer.o: pointer.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
deleted file mode 100644
index cf8b5223bb..0000000000
--- a/ext/fiddle/extconf.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-# frozen_string_literal: true
-require 'mkmf'
-
-# :stopdoc:
-
-def gcc?
- RbConfig::CONFIG["GCC"] == "yes"
-end
-
-def disable_optimization_build_flag(flags)
- if gcc?
- expanded_flags = RbConfig.expand(flags.dup)
- optimization_option_pattern = /(^|\s)?-O\d(\s|$)?/
- if optimization_option_pattern.match?(expanded_flags)
- expanded_flags.gsub(optimization_option_pattern, '\\1-Og\\2')
- else
- flags + " -Og"
- end
- else
- flags
- end
-end
-
-def enable_debug_build_flag(flags)
- if gcc?
- expanded_flags = RbConfig.expand(flags.dup)
- debug_option_pattern = /(^|\s)-g(?:gdb)?\d?(\s|$)/
- if debug_option_pattern.match?(expanded_flags)
- expanded_flags.gsub(debug_option_pattern, '\\1-ggdb3\\2')
- else
- flags + " -ggdb3"
- end
- else
- flags
- end
-end
-
-checking_for(checking_message("--enable-debug-build option")) do
- enable_debug_build = enable_config("debug-build", false)
- if enable_debug_build
- $CFLAGS = disable_optimization_build_flag($CFLAGS)
- $CFLAGS = enable_debug_build_flag($CFLAGS)
- end
- enable_debug_build
-end
-
-libffi_version = nil
-have_libffi = false
-bundle = with_config("libffi-source-dir")
-unless bundle
- dir_config 'libffi'
-
- if pkg_config("libffi")
- libffi_version = pkg_config("libffi", "modversion")
- end
-
- have_ffi_header = false
- if have_header(ffi_header = 'ffi.h')
- have_ffi_header = true
- elsif have_header(ffi_header = 'ffi/ffi.h')
- $defs.push('-DUSE_HEADER_HACKS')
- have_ffi_header = true
- end
- if have_ffi_header && (have_library('ffi') || have_library('libffi'))
- have_libffi = true
- end
-end
-
-unless have_libffi
- if bundle
- libffi_srcdir = libffi_package_name = bundle
- else
- raise "missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location."
- end
- ffi_header = 'ffi.h'
- libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
- libffi.dir = libffi_package_name
- if $srcdir == "."
- libffi.builddir = libffi_package_name
- libffi.srcdir = "."
- else
- libffi.builddir = libffi.dir
- libffi.srcdir = relative_from(libffi_srcdir, "..")
- end
- libffi.include = "#{libffi.builddir}/include"
- libffi.lib = "#{libffi.builddir}/.libs"
- libffi.a = "#{libffi.lib}/libffi_convenience.#{$LIBEXT}"
- nowarn = CONFIG.merge("warnflags"=>"")
- libffi.cflags = RbConfig.expand("$(CFLAGS)".dup, nowarn)
- libffi_version = libffi_package_name[/libffi-(.*)/, 1]
-
- FileUtils.mkdir_p(libffi.dir)
- libffi.opt = CONFIG['configure_args'][/'(-C)'/, 1]
- libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}".dup)
- libffi.arch = RbConfig::CONFIG['host']
- if $mswin
- unless find_executable(as = /x64/ =~ libffi.arch ? "ml64" : "ml")
- raise "missing #{as} command."
- end
- $defs << "-DFFI_BUILDING"
- libffi_config = "#{relative_from($srcdir, '..')}/win32/libffi-config.rb"
- config = CONFIG.merge("top_srcdir" => $top_srcdir)
- args = $ruby.gsub(/:\/=\\/, '')
- args.gsub!(/\)\\/, ')/')
- args = args.shellsplit
- args.map! {|s| RbConfig.expand(s, config)}
- args << '-C' << libffi.dir << libffi_config
- opts = {}
- else
- args = %W[sh #{libffi.srcdir}/configure ]
- opts = {chdir: libffi.dir}
- end
- cc = RbConfig::CONFIG['CC']
- cxx = RbConfig::CONFIG['CXX']
- ld = RbConfig::CONFIG['LD']
- args.concat %W[
- --srcdir=#{libffi.srcdir}
- --host=#{libffi.arch}
- ]
- args << ($enable_shared || !$static ? '--enable-shared' : '--enable-static')
- args << libffi.opt if libffi.opt
- args.concat %W[
- CC=#{cc} CFLAGS=#{libffi.cflags}
- CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)".dup, nowarn)}
- LD=#{ld} LDFLAGS=#{libffi.ldflags}
- ]
-
- FileUtils.rm_f("#{libffi.include}/ffitarget.h")
- Logging::open do
- Logging.message("%p in %p\n", args, opts)
- unless system(*args, **opts)
- begin
- IO.copy_stream(libffi.dir + "/config.log", Logging.instance_variable_get(:@logfile))
- rescue SystemCallError => e
- Logging.message("%s\n", e.message)
- end
- raise "failed to configure libffi. Please install libffi."
- end
- end
- if $mswin && File.file?("#{libffi.include}/ffitarget.h")
- FileUtils.rm_f("#{libffi.include}/ffitarget.h")
- end
- unless File.file?("#{libffi.include}/ffitarget.h")
- FileUtils.cp("#{libffi_srcdir}/src/x86/ffitarget.h", libffi.include, preserve: true)
- end
- $INCFLAGS << " -I" << libffi.include
-end
-
-if libffi_version
- # If libffi_version contains rc version, just ignored.
- libffi_version = libffi_version.gsub(/-rc\d+/, '')
- libffi_version = (libffi_version.split('.').map(&:to_i) + [0,0])[0,3]
- $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % libffi_version }})
- warn "libffi_version: #{libffi_version.join('.')}"
-end
-
-case
-when $mswin, $mingw, (libffi_version && (libffi_version <=> [3, 2]) >= 0)
- $defs << "-DUSE_FFI_CLOSURE_ALLOC=1"
-when (libffi_version && (libffi_version <=> [3, 2]) < 0)
-else
- have_func('ffi_closure_alloc', ffi_header)
-end
-
-if libffi_version
- if (libffi_version <=> [3, 0, 11]) >= 0
- $defs << "-DHAVE_FFI_PREP_CIF_VAR"
- end
-else
- have_func('ffi_prep_cif_var', ffi_header)
-end
-
-have_header 'sys/mman.h'
-have_header 'link.h'
-
-if have_header "dlfcn.h"
- have_library "dl"
-
- %w{ dlopen dlclose dlsym }.each do |func|
- abort "missing function #{func}" unless have_func(func)
- end
-
- have_func "dlerror"
- have_func "dlinfo"
- have_const("RTLD_DI_LINKMAP", "dlfcn.h")
-elsif have_header "windows.h"
- %w{ LoadLibrary FreeLibrary GetProcAddress GetModuleFileName }.each do |func|
- abort "missing function #{func}" unless have_func(func)
- end
-
- have_library "ws2_32"
-end
-
-have_const('FFI_STDCALL', ffi_header)
-
-config = File.read(RbConfig.expand(File.join($arch_hdrdir, "ruby/config.h")))
-types = {"SIZE_T"=>"SSIZE_T", "PTRDIFF_T"=>nil, "INTPTR_T"=>nil}
-types.each do |type, signed|
- if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config
- if size = $2 and size != 'VOIDP'
- size = types.fetch(size) {size}
- $defs << "-DTYPE_#{signed||type}=TYPE_#{size}"
- end
- if signed
- check_signedness(type.downcase, "stddef.h")
- end
- else
- check_signedness(type.downcase, "stddef.h")
- end
-end
-
-if libffi
- $LOCAL_LIBS.prepend("#{libffi.a} ").strip! # to exts.mk
- $INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)')
-end
-create_makefile 'fiddle' do |conf|
- if !libffi
- next conf << "LIBFFI_CLEAN = none\n"
- elsif $gnumake && !$nmake
- submake_arg = "-C $(LIBFFI_DIR)\n"
- else
- submake_pre = "cd $(LIBFFI_DIR) && #{config_string("exec")}".strip
- end
- if $nmake
- cmd = "$(RUBY) -C $(LIBFFI_DIR) #{libffi_config} --srcdir=$(LIBFFI_SRCDIR)"
- else
- cmd = "cd $(LIBFFI_DIR) && #$exec $(LIBFFI_SRCDIR)/configure #{libffi.opt}"
- end
- sep = "/"
- seprpl = config_string('BUILD_FILE_SEPARATOR') {|s| sep = s; ":/=#{s}" if s != "/"} || ""
- conf << <<-MK.gsub(/^ +| +$/, '')
- PWD =
- LIBFFI_CONFIGURE = #{cmd}
- LIBFFI_ARCH = #{libffi.arch}
- LIBFFI_SRCDIR = #{libffi.srcdir.sub(libffi.dir, '$(LIBFFI_DIR)')}
- LIBFFI_DIR = #{libffi.dir}
- LIBFFI_A = #{libffi.a.sub(libffi.dir, '$(LIBFFI_DIR)')}
- LIBFFI_CFLAGS = #{libffi.cflags}
- LIBFFI_LDFLAGS = #{libffi.ldflags}
- FFI_H = $(LIBFFI_DIR)/include/ffi.h
- SUBMAKE_PRE = #{submake_pre}
- SUBMAKE_ARG = #{submake_arg}
- LIBFFI_CLEAN = libffi
- MK
-end
-
-if libffi
- $LIBPATH.pop
-end
-
-# :startdoc:
diff --git a/ext/fiddle/fiddle.c b/ext/fiddle/fiddle.c
deleted file mode 100644
index 9ab1283ba3..0000000000
--- a/ext/fiddle/fiddle.c
+++ /dev/null
@@ -1,692 +0,0 @@
-#include <fiddle.h>
-
-VALUE mFiddle;
-VALUE rb_eFiddleDLError;
-VALUE rb_eFiddleError;
-
-void Init_fiddle_pointer(void);
-void Init_fiddle_pinned(void);
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
-void Init_fiddle_memory_view(void);
-#endif
-
-/*
- * call-seq: Fiddle.malloc(size)
- *
- * Allocate +size+ bytes of memory and return the integer memory address
- * for the allocated memory.
- */
-static VALUE
-rb_fiddle_malloc(VALUE self, VALUE size)
-{
- void *ptr;
- ptr = (void*)ruby_xcalloc(1, NUM2SIZET(size));
- return PTR2NUM(ptr);
-}
-
-/*
- * call-seq: Fiddle.realloc(addr, size)
- *
- * Change the size of the memory allocated at the memory location +addr+ to
- * +size+ bytes. Returns the memory address of the reallocated memory, which
- * may be different than the address passed in.
- */
-static VALUE
-rb_fiddle_realloc(VALUE self, VALUE addr, VALUE size)
-{
- void *ptr = NUM2PTR(addr);
-
- ptr = (void*)ruby_xrealloc(ptr, NUM2SIZET(size));
- return PTR2NUM(ptr);
-}
-
-/*
- * call-seq: Fiddle.free(addr)
- *
- * Free the memory at address +addr+
- */
-VALUE
-rb_fiddle_free(VALUE self, VALUE addr)
-{
- void *ptr = NUM2PTR(addr);
-
- ruby_xfree(ptr);
- return Qnil;
-}
-
-/*
- * call-seq: Fiddle.dlunwrap(addr)
- *
- * Returns the Ruby object stored at the memory address +addr+
- *
- * Example:
- *
- * x = Object.new
- * # => #<Object:0x0000000107c7d870>
- * Fiddle.dlwrap(x)
- * # => 4425504880
- * Fiddle.dlunwrap(_)
- * # => #<Object:0x0000000107c7d870>
- */
-VALUE
-rb_fiddle_ptr2value(VALUE self, VALUE addr)
-{
- return (VALUE)NUM2PTR(addr);
-}
-
-/*
- * call-seq: Fiddle.dlwrap(val)
- *
- * Returns the memory address of the Ruby object stored at +val+
- *
- * Example:
- *
- * x = Object.new
- * # => #<Object:0x0000000107c7d870>
- * Fiddle.dlwrap(x)
- * # => 4425504880
- *
- * In the case +val+ is not a heap allocated object, this method will return
- * the tagged pointer value.
- *
- * Example:
- *
- * Fiddle.dlwrap(123)
- * # => 247
- */
-static VALUE
-rb_fiddle_value2ptr(VALUE self, VALUE val)
-{
- return PTR2NUM((void*)val);
-}
-
-void Init_fiddle_handle(void);
-
-void
-Init_fiddle(void)
-{
- /*
- * Document-module: Fiddle
- *
- * A libffi wrapper for Ruby.
- *
- * == Description
- *
- * Fiddle is an extension to translate a foreign function interface (FFI)
- * with ruby.
- *
- * It wraps {libffi}[http://sourceware.org/libffi/], a popular C library
- * which provides a portable interface that allows code written in one
- * language to call code written in another language.
- *
- * == Example
- *
- * Here we will use Fiddle::Function to wrap {floor(3) from
- * libm}[http://linux.die.net/man/3/floor]
- *
- * require 'fiddle'
- *
- * libm = Fiddle.dlopen('/lib/libm.so.6')
- *
- * floor = Fiddle::Function.new(
- * libm['floor'],
- * [Fiddle::TYPE_DOUBLE],
- * Fiddle::TYPE_DOUBLE
- * )
- *
- * puts floor.call(3.14159) #=> 3.0
- *
- *
- */
- mFiddle = rb_define_module("Fiddle");
-
- /*
- * Document-class: Fiddle::Error
- *
- * Generic error class for Fiddle
- */
- rb_eFiddleError = rb_define_class_under(mFiddle, "Error", rb_eStandardError);
-
- /*
- * Ruby installed by RubyInstaller for Windows always require
- * bundled Fiddle because ruby_installer/runtime/dll_directory.rb
- * requires Fiddle. It's used by
- * rubygems/defaults/operating_system.rb. It means that the
- * bundled Fiddle is always required on initialization.
- *
- * We just remove existing Fiddle::DLError here to override
- * the bundled Fiddle.
- */
- if (rb_const_defined(mFiddle, rb_intern("DLError"))) {
- rb_const_remove(mFiddle, rb_intern("DLError"));
- }
-
- /*
- * Document-class: Fiddle::DLError
- *
- * standard dynamic load exception
- */
- rb_eFiddleDLError = rb_define_class_under(mFiddle, "DLError", rb_eFiddleError);
-
- VALUE mFiddleTypes = rb_define_module_under(mFiddle, "Types");
-
- /* Document-const: Fiddle::Types::VOID
- *
- * C type - void
- */
- rb_define_const(mFiddleTypes, "VOID", INT2NUM(TYPE_VOID));
-
- /* Document-const: Fiddle::Types::VOIDP
- *
- * C type - void*
- */
- rb_define_const(mFiddleTypes, "VOIDP", INT2NUM(TYPE_VOIDP));
-
- /* Document-const: Fiddle::Types::CHAR
- *
- * C type - char
- */
- rb_define_const(mFiddleTypes, "CHAR", INT2NUM(TYPE_CHAR));
-
- /* Document-const: Fiddle::Types::UCHAR
- *
- * C type - unsigned char
- */
- rb_define_const(mFiddleTypes, "UCHAR", INT2NUM(TYPE_UCHAR));
-
- /* Document-const: Fiddle::Types::SHORT
- *
- * C type - short
- */
- rb_define_const(mFiddleTypes, "SHORT", INT2NUM(TYPE_SHORT));
-
- /* Document-const: Fiddle::Types::USHORT
- *
- * C type - unsigned short
- */
- rb_define_const(mFiddleTypes, "USHORT", INT2NUM(TYPE_USHORT));
-
- /* Document-const: Fiddle::Types::INT
- *
- * C type - int
- */
- rb_define_const(mFiddleTypes, "INT", INT2NUM(TYPE_INT));
-
- /* Document-const: Fiddle::Types::UINT
- *
- * C type - unsigned int
- */
- rb_define_const(mFiddleTypes, "UINT", INT2NUM(TYPE_UINT));
-
- /* Document-const: Fiddle::Types::LONG
- *
- * C type - long
- */
- rb_define_const(mFiddleTypes, "LONG", INT2NUM(TYPE_LONG));
-
- /* Document-const: Fiddle::Types::ULONG
- *
- * C type - long
- */
- rb_define_const(mFiddleTypes, "ULONG", INT2NUM(TYPE_ULONG));
-
-#if HAVE_LONG_LONG
- /* Document-const: Fiddle::Types::LONG_LONG
- *
- * C type - long long
- */
- rb_define_const(mFiddleTypes, "LONG_LONG", INT2NUM(TYPE_LONG_LONG));
-
- /* Document-const: Fiddle::Types::ULONG_LONG
- *
- * C type - long long
- */
- rb_define_const(mFiddleTypes, "ULONG_LONG", INT2NUM(TYPE_ULONG_LONG));
-#endif
-
-#ifdef TYPE_INT8_T
- /* Document-const: Fiddle::Types::INT8_T
- *
- * C type - int8_t
- */
- rb_define_const(mFiddleTypes, "INT8_T", INT2NUM(TYPE_INT8_T));
-
- /* Document-const: Fiddle::Types::UINT8_T
- *
- * C type - uint8_t
- */
- rb_define_const(mFiddleTypes, "UINT8_T", INT2NUM(TYPE_UINT8_T));
-#endif
-
-#ifdef TYPE_INT16_T
- /* Document-const: Fiddle::Types::INT16_T
- *
- * C type - int16_t
- */
- rb_define_const(mFiddleTypes, "INT16_T", INT2NUM(TYPE_INT16_T));
-
- /* Document-const: Fiddle::Types::UINT16_T
- *
- * C type - uint16_t
- */
- rb_define_const(mFiddleTypes, "UINT16_T", INT2NUM(TYPE_UINT16_T));
-#endif
-
-#ifdef TYPE_INT32_T
- /* Document-const: Fiddle::Types::INT32_T
- *
- * C type - int32_t
- */
- rb_define_const(mFiddleTypes, "INT32_T", INT2NUM(TYPE_INT32_T));
-
- /* Document-const: Fiddle::Types::UINT32_T
- *
- * C type - uint32_t
- */
- rb_define_const(mFiddleTypes, "UINT32_T", INT2NUM(TYPE_UINT32_T));
-#endif
-
-#ifdef TYPE_INT64_T
- /* Document-const: Fiddle::Types::INT64_T
- *
- * C type - int64_t
- */
- rb_define_const(mFiddleTypes, "INT64_T", INT2NUM(TYPE_INT64_T));
-
- /* Document-const: Fiddle::Types::UINT64_T
- *
- * C type - uint64_t
- */
- rb_define_const(mFiddleTypes, "UINT64_T", INT2NUM(TYPE_UINT64_T));
-#endif
-
- /* Document-const: Fiddle::Types::FLOAT
- *
- * C type - float
- */
- rb_define_const(mFiddleTypes, "FLOAT", INT2NUM(TYPE_FLOAT));
-
- /* Document-const: Fiddle::Types::DOUBLE
- *
- * C type - double
- */
- rb_define_const(mFiddleTypes, "DOUBLE", INT2NUM(TYPE_DOUBLE));
-
-#ifdef HAVE_FFI_PREP_CIF_VAR
- /* Document-const: Fiddle::Types::VARIADIC
- *
- * C type - ...
- */
- rb_define_const(mFiddleTypes, "VARIADIC", INT2NUM(TYPE_VARIADIC));
-#endif
-
- /* Document-const: Fiddle::Types::CONST_STRING
- *
- * C type - const char* ('\0' terminated const char*)
- */
- rb_define_const(mFiddleTypes, "CONST_STRING", INT2NUM(TYPE_CONST_STRING));
-
- /* Document-const: Fiddle::Types::SIZE_T
- *
- * C type - size_t
- */
- rb_define_const(mFiddleTypes, "SIZE_T", INT2NUM(TYPE_SIZE_T));
-
- /* Document-const: Fiddle::Types::SSIZE_T
- *
- * C type - ssize_t
- */
- rb_define_const(mFiddleTypes, "SSIZE_T", INT2NUM(TYPE_SSIZE_T));
-
- /* Document-const: Fiddle::Types::PTRDIFF_T
- *
- * C type - ptrdiff_t
- */
- rb_define_const(mFiddleTypes, "PTRDIFF_T", INT2NUM(TYPE_PTRDIFF_T));
-
- /* Document-const: Fiddle::Types::INTPTR_T
- *
- * C type - intptr_t
- */
- rb_define_const(mFiddleTypes, "INTPTR_T", INT2NUM(TYPE_INTPTR_T));
-
- /* Document-const: Fiddle::Types::UINTPTR_T
- *
- * C type - uintptr_t
- */
- rb_define_const(mFiddleTypes, "UINTPTR_T", INT2NUM(TYPE_UINTPTR_T));
-
- /* Document-const: ALIGN_VOIDP
- *
- * The alignment size of a void*
- */
- rb_define_const(mFiddle, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP));
-
- /* Document-const: ALIGN_CHAR
- *
- * The alignment size of a char
- */
- rb_define_const(mFiddle, "ALIGN_CHAR", INT2NUM(ALIGN_CHAR));
-
- /* Document-const: ALIGN_SHORT
- *
- * The alignment size of a short
- */
- rb_define_const(mFiddle, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT));
-
- /* Document-const: ALIGN_INT
- *
- * The alignment size of an int
- */
- rb_define_const(mFiddle, "ALIGN_INT", INT2NUM(ALIGN_INT));
-
- /* Document-const: ALIGN_LONG
- *
- * The alignment size of a long
- */
- rb_define_const(mFiddle, "ALIGN_LONG", INT2NUM(ALIGN_LONG));
-
-#if HAVE_LONG_LONG
- /* Document-const: ALIGN_LONG_LONG
- *
- * The alignment size of a long long
- */
- rb_define_const(mFiddle, "ALIGN_LONG_LONG", INT2NUM(ALIGN_LONG_LONG));
-#endif
-
- /* Document-const: ALIGN_INT8_T
- *
- * The alignment size of a int8_t
- */
- rb_define_const(mFiddle, "ALIGN_INT8_T", INT2NUM(ALIGN_INT8_T));
-
- /* Document-const: ALIGN_INT16_T
- *
- * The alignment size of a int16_t
- */
- rb_define_const(mFiddle, "ALIGN_INT16_T", INT2NUM(ALIGN_INT16_T));
-
- /* Document-const: ALIGN_INT32_T
- *
- * The alignment size of a int32_t
- */
- rb_define_const(mFiddle, "ALIGN_INT32_T", INT2NUM(ALIGN_INT32_T));
-
- /* Document-const: ALIGN_INT64_T
- *
- * The alignment size of a int64_t
- */
- rb_define_const(mFiddle, "ALIGN_INT64_T", INT2NUM(ALIGN_INT64_T));
-
- /* Document-const: ALIGN_FLOAT
- *
- * The alignment size of a float
- */
- rb_define_const(mFiddle, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT));
-
- /* Document-const: ALIGN_DOUBLE
- *
- * The alignment size of a double
- */
- rb_define_const(mFiddle, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE));
-
- /* Document-const: ALIGN_SIZE_T
- *
- * The alignment size of a size_t
- */
- rb_define_const(mFiddle, "ALIGN_SIZE_T", INT2NUM(ALIGN_OF(size_t)));
-
- /* Document-const: ALIGN_SSIZE_T
- *
- * The alignment size of a ssize_t
- */
- rb_define_const(mFiddle, "ALIGN_SSIZE_T", INT2NUM(ALIGN_OF(size_t))); /* same as size_t */
-
- /* Document-const: ALIGN_PTRDIFF_T
- *
- * The alignment size of a ptrdiff_t
- */
- rb_define_const(mFiddle, "ALIGN_PTRDIFF_T", INT2NUM(ALIGN_OF(ptrdiff_t)));
-
- /* Document-const: ALIGN_INTPTR_T
- *
- * The alignment size of a intptr_t
- */
- rb_define_const(mFiddle, "ALIGN_INTPTR_T", INT2NUM(ALIGN_OF(intptr_t)));
-
- /* Document-const: ALIGN_UINTPTR_T
- *
- * The alignment size of a uintptr_t
- */
- rb_define_const(mFiddle, "ALIGN_UINTPTR_T", INT2NUM(ALIGN_OF(uintptr_t)));
-
- /* Document-const: WINDOWS
- *
- * Returns a boolean regarding whether the host is WIN32
- */
-#if defined(_WIN32)
- rb_define_const(mFiddle, "WINDOWS", Qtrue);
-#else
- rb_define_const(mFiddle, "WINDOWS", Qfalse);
-#endif
-
- /* Document-const: SIZEOF_VOIDP
- *
- * size of a void*
- */
- rb_define_const(mFiddle, "SIZEOF_VOIDP", INT2NUM(sizeof(void*)));
-
- /* Document-const: SIZEOF_CHAR
- *
- * size of a char
- */
- rb_define_const(mFiddle, "SIZEOF_CHAR", INT2NUM(sizeof(char)));
-
- /* Document-const: SIZEOF_UCHAR
- *
- * size of a unsigned char
- */
- rb_define_const(mFiddle, "SIZEOF_UCHAR", INT2NUM(sizeof(unsigned char)));
-
- /* Document-const: SIZEOF_SHORT
- *
- * size of a short
- */
- rb_define_const(mFiddle, "SIZEOF_SHORT", INT2NUM(sizeof(short)));
-
- /* Document-const: SIZEOF_USHORT
- *
- * size of a unsigned short
- */
- rb_define_const(mFiddle, "SIZEOF_USHORT", INT2NUM(sizeof(unsigned short)));
-
- /* Document-const: SIZEOF_INT
- *
- * size of an int
- */
- rb_define_const(mFiddle, "SIZEOF_INT", INT2NUM(sizeof(int)));
-
- /* Document-const: SIZEOF_UINT
- *
- * size of an unsigned int
- */
- rb_define_const(mFiddle, "SIZEOF_UINT", INT2NUM(sizeof(unsigned int)));
-
- /* Document-const: SIZEOF_LONG
- *
- * size of a long
- */
- rb_define_const(mFiddle, "SIZEOF_LONG", INT2NUM(sizeof(long)));
-
- /* Document-const: SIZEOF_ULONG
- *
- * size of a unsigned long
- */
- rb_define_const(mFiddle, "SIZEOF_ULONG", INT2NUM(sizeof(unsigned long)));
-
-#if HAVE_LONG_LONG
- /* Document-const: SIZEOF_LONG_LONG
- *
- * size of a long long
- */
- rb_define_const(mFiddle, "SIZEOF_LONG_LONG", INT2NUM(sizeof(LONG_LONG)));
-
- /* Document-const: SIZEOF_ULONG_LONG
- *
- * size of a unsigned long long
- */
- rb_define_const(mFiddle, "SIZEOF_ULONG_LONG", INT2NUM(sizeof(unsigned LONG_LONG)));
-#endif
-
- /* Document-const: SIZEOF_INT8_T
- *
- * size of a int8_t
- */
- rb_define_const(mFiddle, "SIZEOF_INT8_T", INT2NUM(sizeof(int8_t)));
-
- /* Document-const: SIZEOF_UINT8_T
- *
- * size of a uint8_t
- */
- rb_define_const(mFiddle, "SIZEOF_UINT8_T", INT2NUM(sizeof(uint8_t)));
-
- /* Document-const: SIZEOF_INT16_T
- *
- * size of a int16_t
- */
- rb_define_const(mFiddle, "SIZEOF_INT16_T", INT2NUM(sizeof(int16_t)));
-
- /* Document-const: SIZEOF_UINT16_T
- *
- * size of a uint16_t
- */
- rb_define_const(mFiddle, "SIZEOF_UINT16_T", INT2NUM(sizeof(uint16_t)));
-
- /* Document-const: SIZEOF_INT32_T
- *
- * size of a int32_t
- */
- rb_define_const(mFiddle, "SIZEOF_INT32_T", INT2NUM(sizeof(int32_t)));
-
- /* Document-const: SIZEOF_UINT32_T
- *
- * size of a uint32_t
- */
- rb_define_const(mFiddle, "SIZEOF_UINT32_T", INT2NUM(sizeof(uint32_t)));
-
- /* Document-const: SIZEOF_INT64_T
- *
- * size of a int64_t
- */
- rb_define_const(mFiddle, "SIZEOF_INT64_T", INT2NUM(sizeof(int64_t)));
-
- /* Document-const: SIZEOF_UINT64_T
- *
- * size of a uint64_t
- */
- rb_define_const(mFiddle, "SIZEOF_UINT64_T", INT2NUM(sizeof(uint64_t)));
-
- /* Document-const: SIZEOF_FLOAT
- *
- * size of a float
- */
- rb_define_const(mFiddle, "SIZEOF_FLOAT", INT2NUM(sizeof(float)));
-
- /* Document-const: SIZEOF_DOUBLE
- *
- * size of a double
- */
- rb_define_const(mFiddle, "SIZEOF_DOUBLE",INT2NUM(sizeof(double)));
-
- /* Document-const: SIZEOF_SIZE_T
- *
- * size of a size_t
- */
- rb_define_const(mFiddle, "SIZEOF_SIZE_T", INT2NUM(sizeof(size_t)));
-
- /* Document-const: SIZEOF_SSIZE_T
- *
- * size of a ssize_t
- */
- rb_define_const(mFiddle, "SIZEOF_SSIZE_T", INT2NUM(sizeof(size_t))); /* same as size_t */
-
- /* Document-const: SIZEOF_PTRDIFF_T
- *
- * size of a ptrdiff_t
- */
- rb_define_const(mFiddle, "SIZEOF_PTRDIFF_T", INT2NUM(sizeof(ptrdiff_t)));
-
- /* Document-const: SIZEOF_INTPTR_T
- *
- * size of a intptr_t
- */
- rb_define_const(mFiddle, "SIZEOF_INTPTR_T", INT2NUM(sizeof(intptr_t)));
-
- /* Document-const: SIZEOF_UINTPTR_T
- *
- * size of a uintptr_t
- */
- rb_define_const(mFiddle, "SIZEOF_UINTPTR_T", INT2NUM(sizeof(uintptr_t)));
-
- /* Document-const: SIZEOF_CONST_STRING
- *
- * size of a const char*
- */
- rb_define_const(mFiddle, "SIZEOF_CONST_STRING", INT2NUM(sizeof(const char*)));
-
- /* Document-const: RUBY_FREE
- *
- * Address of the ruby_xfree() function
- */
- rb_define_const(mFiddle, "RUBY_FREE", PTR2NUM(ruby_xfree));
-
- /* Document-const: BUILD_RUBY_PLATFORM
- *
- * Platform built against (i.e. "x86_64-linux", etc.)
- *
- * See also RUBY_PLATFORM
- */
- rb_define_const(mFiddle, "BUILD_RUBY_PLATFORM", rb_str_new2(RUBY_PLATFORM));
-
- rb_define_module_function(mFiddle, "dlwrap", rb_fiddle_value2ptr, 1);
- rb_define_module_function(mFiddle, "dlunwrap", rb_fiddle_ptr2value, 1);
- rb_define_module_function(mFiddle, "malloc", rb_fiddle_malloc, 1);
- rb_define_module_function(mFiddle, "realloc", rb_fiddle_realloc, 2);
- rb_define_module_function(mFiddle, "free", rb_fiddle_free, 1);
-
- /* Document-const: Qtrue
- *
- * The value of Qtrue
- */
- rb_define_const(mFiddle, "Qtrue", INT2NUM(Qtrue));
-
- /* Document-const: Qfalse
- *
- * The value of Qfalse
- */
- rb_define_const(mFiddle, "Qfalse", INT2NUM(Qfalse));
-
- /* Document-const: Qnil
- *
- * The value of Qnil
- */
- rb_define_const(mFiddle, "Qnil", INT2NUM(Qnil));
-
- /* Document-const: Qundef
- *
- * The value of Qundef
- */
- rb_define_const(mFiddle, "Qundef", INT2NUM(Qundef));
-
- Init_fiddle_function();
- Init_fiddle_closure();
- Init_fiddle_handle();
- Init_fiddle_pointer();
- Init_fiddle_pinned();
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
- Init_fiddle_memory_view();
-#endif
-}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
deleted file mode 100644
index 878109395b..0000000000
--- a/ext/fiddle/fiddle.gemspec
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-version_module = Module.new do
- version_rb = File.join(__dir__, "lib/fiddle/version.rb")
- module_eval(File.read(version_rb), version_rb, __LINE__)
-end
-
-Gem::Specification.new do |spec|
- spec.name = "fiddle"
- spec.version = version_module::Fiddle::VERSION
- spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
- spec.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]
-
- spec.summary = %q{A libffi wrapper for Ruby.}
- spec.description = %q{A libffi wrapper for Ruby.}
- spec.homepage = "https://github.com/ruby/fiddle"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.files = [
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "ext/fiddle/closure.c",
- "ext/fiddle/closure.h",
- "ext/fiddle/conversions.c",
- "ext/fiddle/conversions.h",
- "ext/fiddle/depend",
- "ext/fiddle/extconf.rb",
- "ext/fiddle/fiddle.c",
- "ext/fiddle/fiddle.h",
- "ext/fiddle/function.c",
- "ext/fiddle/function.h",
- "ext/fiddle/handle.c",
- "ext/fiddle/memory_view.c",
- "ext/fiddle/pinned.c",
- "ext/fiddle/pointer.c",
- "ext/fiddle/win32/fficonfig.h",
- "ext/fiddle/win32/libffi-3.2.1-mswin.patch",
- "ext/fiddle/win32/libffi-config.rb",
- "ext/fiddle/win32/libffi.mk.tmpl",
- "fiddle.gemspec",
- "lib/fiddle.rb",
- "lib/fiddle/closure.rb",
- "lib/fiddle/cparser.rb",
- "lib/fiddle/function.rb",
- "lib/fiddle/import.rb",
- "lib/fiddle/pack.rb",
- "lib/fiddle/struct.rb",
- "lib/fiddle/types.rb",
- "lib/fiddle/value.rb",
- "lib/fiddle/version.rb",
- ]
- spec.require_paths = ["lib"]
- spec.extensions = ["ext/fiddle/extconf.rb"]
-
- spec.required_ruby_version = ">= 2.5.0"
-
- spec.metadata["msys2_mingw_dependencies"] = "libffi"
-end
diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h
deleted file mode 100644
index 684b943d30..0000000000
--- a/ext/fiddle/fiddle.h
+++ /dev/null
@@ -1,236 +0,0 @@
-#ifndef FIDDLE_H
-#define FIDDLE_H
-
-#include <ruby.h>
-#include <errno.h>
-
-#if defined(_WIN32)
-#include <windows.h>
-#endif
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#if defined(HAVE_LINK_H)
-# include <link.h>
-#endif
-
-#if defined(HAVE_DLFCN_H)
-# include <dlfcn.h>
-# /* some stranger systems may not define all of these */
-#ifndef RTLD_LAZY
-#define RTLD_LAZY 0
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-#ifndef RTLD_NOW
-#define RTLD_NOW 0
-#endif
-#else
-# if defined(_WIN32)
-# include <windows.h>
-# define dlopen(name,flag) ((void*)LoadLibrary(name))
-# define dlerror() strerror(rb_w32_map_errno(GetLastError()))
-# define dlsym(handle,name) ((void*)GetProcAddress((handle),(name)))
-# define RTLD_LAZY -1
-# define RTLD_NOW -1
-# define RTLD_GLOBAL -1
-# endif
-#endif
-
-#ifdef USE_HEADER_HACKS
-#include <ffi/ffi.h>
-#else
-#include <ffi.h>
-#endif
-
-#undef ffi_type_uchar
-#undef ffi_type_schar
-#undef ffi_type_ushort
-#undef ffi_type_sshort
-#undef ffi_type_uint
-#undef ffi_type_sint
-#undef ffi_type_ulong
-#undef ffi_type_slong
-
-#if CHAR_BIT == 8
-# define ffi_type_uchar ffi_type_uint8
-# define ffi_type_schar ffi_type_sint8
-#else
-# error "CHAR_BIT not supported"
-#endif
-
-#if SIZEOF_SHORT == 2
-# define ffi_type_ushort ffi_type_uint16
-# define ffi_type_sshort ffi_type_sint16
-#elif SIZEOF_SHORT == 4
-# define ffi_type_ushort ffi_type_uint32
-# define ffi_type_sshort ffi_type_sint32
-#else
-# error "short size not supported"
-#endif
-
-#if SIZEOF_INT == 2
-# define ffi_type_uint ffi_type_uint16
-# define ffi_type_sint ffi_type_sint16
-#elif SIZEOF_INT == 4
-# define ffi_type_uint ffi_type_uint32
-# define ffi_type_sint ffi_type_sint32
-#elif SIZEOF_INT == 8
-# define ffi_type_uint ffi_type_uint64
-# define ffi_type_sint ffi_type_sint64
-#else
-# error "int size not supported"
-#endif
-
-#if SIZEOF_LONG == 4
-# define ffi_type_ulong ffi_type_uint32
-# define ffi_type_slong ffi_type_sint32
-#elif SIZEOF_LONG == 8
-# define ffi_type_ulong ffi_type_uint64
-# define ffi_type_slong ffi_type_sint64
-#else
-# error "long size not supported"
-#endif
-
-#if HAVE_LONG_LONG
-# if SIZEOF_LONG_LONG == 8
-# define ffi_type_slong_long ffi_type_sint64
-# define ffi_type_ulong_long ffi_type_uint64
-# else
-# error "long long size not supported"
-# endif
-#endif
-
-#include <closure.h>
-#include <conversions.h>
-#include <function.h>
-
-#define TYPE_VOID 0
-#define TYPE_VOIDP 1
-#define TYPE_CHAR 2
-#define TYPE_UCHAR -TYPE_CHAR
-#define TYPE_SHORT 3
-#define TYPE_USHORT -TYPE_SHORT
-#define TYPE_INT 4
-#define TYPE_UINT -TYPE_INT
-#define TYPE_LONG 5
-#define TYPE_ULONG -TYPE_LONG
-#if HAVE_LONG_LONG
-#define TYPE_LONG_LONG 6
-#define TYPE_ULONG_LONG -TYPE_LONG_LONG
-#endif
-#define TYPE_FLOAT 7
-#define TYPE_DOUBLE 8
-#define TYPE_VARIADIC 9
-#define TYPE_CONST_STRING 10
-
-#define TYPE_INT8_T TYPE_CHAR
-#define TYPE_UINT8_T -TYPE_INT8_T
-
-#if SIZEOF_SHORT == 2
-# define TYPE_INT16_T TYPE_SHORT
-#elif SIZEOF_INT == 2
-# define TYPE_INT16_T TYPE_INT
-#endif
-
-#ifdef TYPE_INT16_T
-# define TYPE_UINT16_T -TYPE_INT16_T
-#endif
-
-#if SIZEOF_SHORT == 4
-# define TYPE_INT32_T TYPE_SHORT
-#elif SIZEOF_INT == 4
-# define TYPE_INT32_T TYPE_INT
-#elif SIZEOF_LONG == 4
-# define TYPE_INT32_T TYPE_LONG
-#endif
-
-#ifdef TYPE_INT32_T
-#define TYPE_UINT32_T -TYPE_INT32_T
-#endif
-
-#if SIZEOF_INT == 8
-# define TYPE_INT64_T TYPE_INT
-#elif SIZEOF_LONG == 8
-# define TYPE_INT64_T TYPE_LONG
-#elif defined(TYPE_LONG_LONG)
-# define TYPE_INT64_T TYPE_LONG_LONG
-#endif
-
-#ifdef TYPE_INT64_T
-#define TYPE_UINT64_T -TYPE_INT64_T
-#endif
-
-#ifndef TYPE_SSIZE_T
-# if SIZEOF_SIZE_T == SIZEOF_INT
-# define TYPE_SSIZE_T TYPE_INT
-# elif SIZEOF_SIZE_T == SIZEOF_LONG
-# define TYPE_SSIZE_T TYPE_LONG
-# elif defined HAVE_LONG_LONG && SIZEOF_SIZE_T == SIZEOF_LONG_LONG
-# define TYPE_SSIZE_T TYPE_LONG_LONG
-# endif
-#endif
-#define TYPE_SIZE_T (-1*SIGNEDNESS_OF_SIZE_T*TYPE_SSIZE_T)
-
-#ifndef TYPE_PTRDIFF_T
-# if SIZEOF_PTRDIFF_T == SIZEOF_INT
-# define TYPE_PTRDIFF_T TYPE_INT
-# elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
-# define TYPE_PTRDIFF_T TYPE_LONG
-# elif defined HAVE_LONG_LONG && SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
-# define TYPE_PTRDIFF_T TYPE_LONG_LONG
-# endif
-#endif
-
-#ifndef TYPE_INTPTR_T
-# if SIZEOF_INTPTR_T == SIZEOF_INT
-# define TYPE_INTPTR_T TYPE_INT
-# elif SIZEOF_INTPTR_T == SIZEOF_LONG
-# define TYPE_INTPTR_T TYPE_LONG
-# elif defined HAVE_LONG_LONG && SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
-# define TYPE_INTPTR_T TYPE_LONG_LONG
-# endif
-#endif
-#define TYPE_UINTPTR_T (-TYPE_INTPTR_T)
-
-/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
- <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
- clang versions < 8.0.0 have the same bug. */
-#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112 \
- || (defined(__GNUC__) && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
- && !defined(__clang__)) \
- || (defined(__clang__) && __clang_major__ < 8))
-# define ALIGN_OF(type) offsetof(struct {char align_c; type align_x;}, align_x)
-#else
-# define ALIGN_OF(type) _Alignof(type)
-#endif
-
-#define ALIGN_VOIDP ALIGN_OF(void*)
-#define ALIGN_CHAR ALIGN_OF(char)
-#define ALIGN_SHORT ALIGN_OF(short)
-#define ALIGN_INT ALIGN_OF(int)
-#define ALIGN_LONG ALIGN_OF(long)
-#if HAVE_LONG_LONG
-#define ALIGN_LONG_LONG ALIGN_OF(LONG_LONG)
-#endif
-#define ALIGN_FLOAT ALIGN_OF(float)
-#define ALIGN_DOUBLE ALIGN_OF(double)
-
-#define ALIGN_INT8_T ALIGN_OF(int8_t)
-#define ALIGN_INT16_T ALIGN_OF(int16_t)
-#define ALIGN_INT32_T ALIGN_OF(int32_t)
-#define ALIGN_INT64_T ALIGN_OF(int64_t)
-
-extern VALUE mFiddle;
-extern VALUE rb_eFiddleDLError;
-
-VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type);
-
-typedef void (*rb_fiddle_freefunc_t)(void*);
-VALUE rb_fiddle_ptr_new_wrap(void *ptr, long size, rb_fiddle_freefunc_t func, VALUE wrap0, VALUE wrap1);
-
-#endif
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
deleted file mode 100644
index 274d181d17..0000000000
--- a/ext/fiddle/function.c
+++ /dev/null
@@ -1,491 +0,0 @@
-#include <fiddle.h>
-#include <ruby/thread.h>
-
-#include <stdbool.h>
-
-#ifdef PRIsVALUE
-# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
-# define RB_OBJ_STRING(obj) (obj)
-#else
-# define PRIsVALUE "s"
-# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
-# define RB_OBJ_STRING(obj) StringValueCStr(obj)
-#endif
-
-VALUE cFiddleFunction;
-
-#define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
-
-#define Check_Max_Args(name, len) \
- Check_Max_Args_(name, len, "")
-#define Check_Max_Args_Long(name, len) \
- Check_Max_Args_(name, len, "l")
-#define Check_Max_Args_(name, len, fmt) \
- do { \
- if ((size_t)(len) >= MAX_ARGS) { \
- rb_raise(rb_eTypeError, \
- "%s is so large " \
- "that it can cause integer overflow (%"fmt"d)", \
- (name), (len)); \
- } \
- } while (0)
-
-static void
-deallocate(void *p)
-{
- ffi_cif *cif = p;
- if (cif->arg_types) xfree(cif->arg_types);
- xfree(cif);
-}
-
-static size_t
-function_memsize(const void *p)
-{
- /* const */ffi_cif *ptr = (ffi_cif *)p;
- size_t size = 0;
-
- size += sizeof(*ptr);
-#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
- size += ffi_raw_size(ptr);
-#endif
-
- return size;
-}
-
-const rb_data_type_t function_data_type = {
- "fiddle/function",
- {0, deallocate, function_memsize,},
-};
-
-static VALUE
-allocate(VALUE klass)
-{
- ffi_cif * cif;
-
- return TypedData_Make_Struct(klass, ffi_cif, &function_data_type, cif);
-}
-
-VALUE
-rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type)
-{
- VALUE argv[3];
-
- argv[0] = address;
- argv[1] = arg_types;
- argv[2] = ret_type;
-
- return rb_class_new_instance(3, argv, cFiddleFunction);
-}
-
-static VALUE
-normalize_argument_types(const char *name,
- VALUE arg_types,
- bool *is_variadic)
-{
- VALUE normalized_arg_types;
- int i;
- int n_arg_types;
- *is_variadic = false;
-
- Check_Type(arg_types, T_ARRAY);
- n_arg_types = RARRAY_LENINT(arg_types);
- Check_Max_Args(name, n_arg_types);
-
- normalized_arg_types = rb_ary_new_capa(n_arg_types);
- for (i = 0; i < n_arg_types; i++) {
- VALUE arg_type = RARRAY_AREF(arg_types, i);
- int c_arg_type;
- arg_type = rb_fiddle_type_ensure(arg_type);
- c_arg_type = NUM2INT(arg_type);
- if (c_arg_type == TYPE_VARIADIC) {
- if (i != n_arg_types - 1) {
- rb_raise(rb_eArgError,
- "Fiddle::TYPE_VARIADIC must be the last argument type: "
- "%"PRIsVALUE,
- arg_types);
- }
- *is_variadic = true;
- break;
- }
- else {
- (void)INT2FFI_TYPE(c_arg_type); /* raise */
- }
- rb_ary_push(normalized_arg_types, INT2FIX(c_arg_type));
- }
-
- /* freeze to prevent inconsistency at calling #to_int later */
- OBJ_FREEZE(normalized_arg_types);
- return normalized_arg_types;
-}
-
-static VALUE
-initialize(int argc, VALUE argv[], VALUE self)
-{
- ffi_cif * cif;
- VALUE ptr, arg_types, ret_type, abi, kwargs;
- VALUE name = Qnil;
- VALUE need_gvl = Qfalse;
- int c_ret_type;
- bool is_variadic = false;
- ffi_abi c_ffi_abi;
- void *cfunc;
-
- rb_scan_args(argc, argv, "31:", &ptr, &arg_types, &ret_type, &abi, &kwargs);
- rb_iv_set(self, "@closure", ptr);
-
- if (!NIL_P(kwargs)) {
- enum {
- kw_name,
- kw_need_gvl,
- kw_max_,
- };
- static ID kw[kw_max_];
- VALUE args[kw_max_];
- if (!kw[0]) {
- kw[kw_name] = rb_intern_const("name");
- kw[kw_need_gvl] = rb_intern_const("need_gvl");
- }
- rb_get_kwargs(kwargs, kw, 0, kw_max_, args);
- if (args[kw_name] != Qundef) {
- name = args[kw_name];
- }
- if (args[kw_need_gvl] != Qundef) {
- need_gvl = args[kw_need_gvl];
- }
- }
- rb_iv_set(self, "@name", name);
- rb_iv_set(self, "@need_gvl", need_gvl);
-
- ptr = rb_Integer(ptr);
- cfunc = NUM2PTR(ptr);
- PTR2NUM(cfunc);
- c_ffi_abi = NIL_P(abi) ? FFI_DEFAULT_ABI : NUM2INT(abi);
- abi = INT2FIX(c_ffi_abi);
- ret_type = rb_fiddle_type_ensure(ret_type);
- c_ret_type = NUM2INT(ret_type);
- (void)INT2FFI_TYPE(c_ret_type); /* raise */
- ret_type = INT2FIX(c_ret_type);
-
- arg_types = normalize_argument_types("argument types",
- arg_types,
- &is_variadic);
-#ifndef HAVE_FFI_PREP_CIF_VAR
- if (is_variadic) {
- rb_raise(rb_eNotImpError,
- "ffi_prep_cif_var() is required in libffi "
- "for variadic arguments");
- }
-#endif
-
- rb_iv_set(self, "@ptr", ptr);
- rb_iv_set(self, "@argument_types", arg_types);
- rb_iv_set(self, "@return_type", ret_type);
- rb_iv_set(self, "@abi", abi);
- rb_iv_set(self, "@is_variadic", is_variadic ? Qtrue : Qfalse);
-
- TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif);
- cif->arg_types = NULL;
-
- return self;
-}
-
-struct nogvl_ffi_call_args {
- ffi_cif *cif;
- void (*fn)(void);
- void **values;
- fiddle_generic retval;
-};
-
-static void *
-nogvl_ffi_call(void *ptr)
-{
- struct nogvl_ffi_call_args *args = ptr;
-
- ffi_call(args->cif, args->fn, &args->retval, args->values);
-
- return NULL;
-}
-
-static VALUE
-function_call(int argc, VALUE argv[], VALUE self)
-{
- struct nogvl_ffi_call_args args = { 0 };
- fiddle_generic *generic_args;
- VALUE cfunc;
- VALUE abi;
- VALUE arg_types;
- VALUE cPointer;
- VALUE is_variadic;
- VALUE need_gvl;
- int n_arg_types;
- int n_fixed_args = 0;
- int n_call_args = 0;
- int i;
- int i_call;
- VALUE converted_args = Qnil;
- VALUE alloc_buffer = 0;
-
- cfunc = rb_iv_get(self, "@ptr");
- abi = rb_iv_get(self, "@abi");
- arg_types = rb_iv_get(self, "@argument_types");
- cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
- is_variadic = rb_iv_get(self, "@is_variadic");
- need_gvl = rb_iv_get(self, "@need_gvl");
-
- n_arg_types = RARRAY_LENINT(arg_types);
- n_fixed_args = n_arg_types;
- if (RTEST(is_variadic)) {
- if (argc < n_arg_types) {
- rb_error_arity(argc, n_arg_types, UNLIMITED_ARGUMENTS);
- }
- if (((argc - n_arg_types) % 2) != 0) {
- rb_raise(rb_eArgError,
- "variadic arguments must be type and value pairs: "
- "%"PRIsVALUE,
- rb_ary_new_from_values(argc, argv));
- }
- n_call_args = n_arg_types + ((argc - n_arg_types) / 2);
- }
- else {
- if (argc != n_arg_types) {
- rb_error_arity(argc, n_arg_types, n_arg_types);
- }
- n_call_args = n_arg_types;
- }
- Check_Max_Args("the number of arguments", n_call_args);
-
- TypedData_Get_Struct(self, ffi_cif, &function_data_type, args.cif);
-
- if (is_variadic && args.cif->arg_types) {
- xfree(args.cif->arg_types);
- args.cif->arg_types = NULL;
- }
-
- if (!args.cif->arg_types) {
- VALUE fixed_arg_types = arg_types;
- VALUE return_type;
- int c_return_type;
- ffi_type *ffi_return_type;
- ffi_type **ffi_arg_types;
- ffi_status result;
-
- arg_types = rb_ary_dup(fixed_arg_types);
- for (i = n_fixed_args; i < argc; i += 2) {
- VALUE arg_type = argv[i];
- int c_arg_type;
- arg_type = rb_fiddle_type_ensure(arg_type);
- c_arg_type = NUM2INT(arg_type);
- (void)INT2FFI_TYPE(c_arg_type); /* raise */
- rb_ary_push(arg_types, INT2FIX(c_arg_type));
- }
-
- return_type = rb_iv_get(self, "@return_type");
- c_return_type = FIX2INT(return_type);
- ffi_return_type = INT2FFI_TYPE(c_return_type);
-
- ffi_arg_types = xcalloc(n_call_args + 1, sizeof(ffi_type *));
- for (i_call = 0; i_call < n_call_args; i_call++) {
- VALUE arg_type;
- int c_arg_type;
- arg_type = RARRAY_AREF(arg_types, i_call);
- c_arg_type = FIX2INT(arg_type);
- ffi_arg_types[i_call] = INT2FFI_TYPE(c_arg_type);
- }
- ffi_arg_types[i_call] = NULL;
-
- if (is_variadic) {
-#ifdef HAVE_FFI_PREP_CIF_VAR
- result = ffi_prep_cif_var(args.cif,
- FIX2INT(abi),
- n_fixed_args,
- n_call_args,
- ffi_return_type,
- ffi_arg_types);
-#else
- /* This code is never used because ffi_prep_cif_var()
- * availability check is done in #initialize. */
- result = FFI_BAD_TYPEDEF;
-#endif
- }
- else {
- result = ffi_prep_cif(args.cif,
- FIX2INT(abi),
- n_call_args,
- ffi_return_type,
- ffi_arg_types);
- }
- if (result != FFI_OK) {
- xfree(ffi_arg_types);
- args.cif->arg_types = NULL;
- rb_raise(rb_eRuntimeError, "error creating CIF %d", result);
- }
- }
-
- generic_args = ALLOCV(alloc_buffer,
- sizeof(fiddle_generic) * n_call_args +
- sizeof(void *) * (n_call_args + 1));
- args.values = (void **)((char *)generic_args +
- sizeof(fiddle_generic) * n_call_args);
-
- for (i = 0, i_call = 0;
- i < argc && i_call < n_call_args;
- i++, i_call++) {
- VALUE arg_type;
- int c_arg_type;
- VALUE original_src;
- VALUE src;
- arg_type = RARRAY_AREF(arg_types, i_call);
- c_arg_type = FIX2INT(arg_type);
- if (i >= n_fixed_args) {
- i++;
- }
- src = argv[i];
-
- if (c_arg_type == TYPE_VOIDP) {
- if (NIL_P(src)) {
- src = INT2FIX(0);
- }
- else if (cPointer != CLASS_OF(src)) {
- src = rb_funcall(cPointer, rb_intern("[]"), 1, src);
- if (NIL_P(converted_args)) {
- converted_args = rb_ary_new();
- }
- rb_ary_push(converted_args, src);
- }
- src = rb_Integer(src);
- }
-
- original_src = src;
- VALUE2GENERIC(c_arg_type, src, &generic_args[i_call]);
- if (src != original_src) {
- if (NIL_P(converted_args)) {
- converted_args = rb_ary_new();
- }
- rb_ary_push(converted_args, src);
- }
- args.values[i_call] = (void *)&generic_args[i_call];
- }
- args.values[i_call] = NULL;
- args.fn = (void(*)(void))NUM2PTR(cfunc);
-
- if (RTEST(need_gvl)) {
- ffi_call(args.cif, args.fn, &(args.retval), args.values);
- }
- else {
- (void)rb_thread_call_without_gvl(nogvl_ffi_call, &args, 0, 0);
- }
-
- {
- int errno_keep = errno;
-#if defined(_WIN32)
- DWORD error = WSAGetLastError();
- int socket_error = WSAGetLastError();
- rb_funcall(mFiddle, rb_intern("win32_last_error="), 1,
- ULONG2NUM(error));
- rb_funcall(mFiddle, rb_intern("win32_last_socket_error="), 1,
- INT2NUM(socket_error));
-#endif
- rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno_keep));
- }
-
- ALLOCV_END(alloc_buffer);
-
- return GENERIC2VALUE(rb_iv_get(self, "@return_type"), args.retval);
-}
-
-void
-Init_fiddle_function(void)
-{
- /*
- * Document-class: Fiddle::Function
- *
- * == Description
- *
- * A representation of a C function
- *
- * == Examples
- *
- * === 'strcpy'
- *
- * @libc = Fiddle.dlopen "/lib/libc.so.6"
- * #=> #<Fiddle::Handle:0x00000001d7a8d8>
- * f = Fiddle::Function.new(
- * @libc['strcpy'],
- * [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
- * Fiddle::TYPE_VOIDP)
- * #=> #<Fiddle::Function:0x00000001d8ee00>
- * buff = "000"
- * #=> "000"
- * str = f.call(buff, "123")
- * #=> #<Fiddle::Pointer:0x00000001d0c380 ptr=0x000000018a21b8 size=0 free=0x00000000000000>
- * str.to_s
- * => "123"
- *
- * === ABI check
- *
- * @libc = Fiddle.dlopen "/lib/libc.so.6"
- * #=> #<Fiddle::Handle:0x00000001d7a8d8>
- * f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
- * #=> #<Fiddle::Function:0x00000001d8ee00>
- * f.abi == Fiddle::Function::DEFAULT
- * #=> true
- */
- cFiddleFunction = rb_define_class_under(mFiddle, "Function", rb_cObject);
-
- /*
- * Document-const: DEFAULT
- *
- * Default ABI
- *
- */
- rb_define_const(cFiddleFunction, "DEFAULT", INT2NUM(FFI_DEFAULT_ABI));
-
-#ifdef HAVE_CONST_FFI_STDCALL
- /*
- * Document-const: STDCALL
- *
- * FFI implementation of WIN32 stdcall convention
- *
- */
- rb_define_const(cFiddleFunction, "STDCALL", INT2NUM(FFI_STDCALL));
-#endif
-
- rb_define_alloc_func(cFiddleFunction, allocate);
-
- /*
- * Document-method: call
- *
- * Calls the constructed Function, with +args+.
- * Caller must ensure the underlying function is called in a
- * thread-safe manner if running in a multi-threaded process.
- *
- * Note that it is not thread-safe to use this method to
- * directly or indirectly call many Ruby C-extension APIs unless
- * you don't pass +need_gvl: true+ to Fiddle::Function#new.
- *
- * For an example see Fiddle::Function
- *
- */
- rb_define_method(cFiddleFunction, "call", function_call, -1);
-
- /*
- * Document-method: new
- * call-seq: new(ptr,
- * args,
- * ret_type,
- * abi = DEFAULT,
- * name: nil,
- * need_gvl: false)
- *
- * Constructs a Function object.
- * * +ptr+ is a referenced function, of a Fiddle::Handle
- * * +args+ is an Array of arguments, passed to the +ptr+ function
- * * +ret_type+ is the return type of the function
- * * +abi+ is the ABI of the function
- * * +name+ is the name of the function
- * * +need_gvl+ is whether GVL is needed to call the function
- *
- */
- rb_define_method(cFiddleFunction, "initialize", initialize, -1);
-}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/fiddle/function.h b/ext/fiddle/function.h
deleted file mode 100644
index 829e592c8a..0000000000
--- a/ext/fiddle/function.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef FIDDLE_FUNCTION_H
-#define FIDDLE_FUNCTION_H
-
-#include <fiddle.h>
-
-void Init_fiddle_function(void);
-
-#endif
diff --git a/ext/fiddle/handle.c b/ext/fiddle/handle.c
deleted file mode 100644
index ae8cc3a581..0000000000
--- a/ext/fiddle/handle.c
+++ /dev/null
@@ -1,586 +0,0 @@
-#include <ruby.h>
-#include <fiddle.h>
-
-VALUE rb_cHandle;
-
-struct dl_handle {
- void *ptr;
- int open;
- int enable_close;
-};
-
-#ifdef _WIN32
-# ifndef _WIN32_WCE
-static void *
-w32_coredll(void)
-{
- MEMORY_BASIC_INFORMATION m;
- memset(&m, 0, sizeof(m));
- if( !VirtualQuery(_errno, &m, sizeof(m)) ) return NULL;
- return m.AllocationBase;
-}
-# endif
-
-static int
-w32_dlclose(void *ptr)
-{
-# ifndef _WIN32_WCE
- if( ptr == w32_coredll() ) return 0;
-# endif
- if( FreeLibrary((HMODULE)ptr) ) return 0;
- return errno = rb_w32_map_errno(GetLastError());
-}
-#define dlclose(ptr) w32_dlclose(ptr)
-#endif
-
-static void
-fiddle_handle_free(void *ptr)
-{
- struct dl_handle *fiddle_handle = ptr;
- if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){
- dlclose(fiddle_handle->ptr);
- }
- xfree(ptr);
-}
-
-static size_t
-fiddle_handle_memsize(const void *ptr)
-{
- return sizeof(struct dl_handle);
-}
-
-static const rb_data_type_t fiddle_handle_data_type = {
- "fiddle/handle",
- {0, fiddle_handle_free, fiddle_handle_memsize,},
-};
-
-/*
- * call-seq: close
- *
- * Close this handle.
- *
- * Calling close more than once will raise a Fiddle::DLError exception.
- */
-static VALUE
-rb_fiddle_handle_close(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- if(fiddle_handle->open) {
- int ret = dlclose(fiddle_handle->ptr);
- fiddle_handle->open = 0;
-
- /* Check dlclose for successful return value */
- if(ret) {
-#if defined(HAVE_DLERROR)
- rb_raise(rb_eFiddleDLError, "%s", dlerror());
-#else
- rb_raise(rb_eFiddleDLError, "could not close handle");
-#endif
- }
- return INT2NUM(ret);
- }
- rb_raise(rb_eFiddleDLError, "dlclose() called too many times");
-
- UNREACHABLE;
-}
-
-static VALUE
-rb_fiddle_handle_s_allocate(VALUE klass)
-{
- VALUE obj;
- struct dl_handle *fiddle_handle;
-
- obj = TypedData_Make_Struct(rb_cHandle, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- fiddle_handle->ptr = 0;
- fiddle_handle->open = 0;
- fiddle_handle->enable_close = 0;
-
- return obj;
-}
-
-static VALUE
-predefined_fiddle_handle(void *handle)
-{
- VALUE obj = rb_fiddle_handle_s_allocate(rb_cHandle);
- struct dl_handle *fiddle_handle = DATA_PTR(obj);
-
- fiddle_handle->ptr = handle;
- fiddle_handle->open = 1;
- OBJ_FREEZE(obj);
- return obj;
-}
-
-/*
- * call-seq:
- * new(library = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL)
- *
- * Create a new handler that opens +library+ with +flags+.
- *
- * If no +library+ is specified or +nil+ is given, DEFAULT is used, which is
- * the equivalent to RTLD_DEFAULT. See <code>man 3 dlopen</code> for more.
- *
- * lib = Fiddle::Handle.new
- *
- * The default is dependent on OS, and provide a handle for all libraries
- * already loaded. For example, in most cases you can use this to access +libc+
- * functions, or ruby functions like +rb_str_new+.
- */
-static VALUE
-rb_fiddle_handle_initialize(int argc, VALUE argv[], VALUE self)
-{
- void *ptr;
- struct dl_handle *fiddle_handle;
- VALUE lib, flag;
- char *clib;
- int cflag;
- const char *err;
-
- switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){
- case 0:
- clib = NULL;
- cflag = RTLD_LAZY | RTLD_GLOBAL;
- break;
- case 1:
- clib = NIL_P(lib) ? NULL : StringValueCStr(lib);
- cflag = RTLD_LAZY | RTLD_GLOBAL;
- break;
- case 2:
- clib = NIL_P(lib) ? NULL : StringValueCStr(lib);
- cflag = NUM2INT(flag);
- break;
- default:
- rb_bug("rb_fiddle_handle_new");
- }
-
-#if defined(_WIN32)
- if( !clib ){
- HANDLE rb_libruby_handle(void);
- ptr = rb_libruby_handle();
- }
- else if( STRCASECMP(clib, "libc") == 0
-# ifdef RUBY_COREDLL
- || STRCASECMP(clib, RUBY_COREDLL) == 0
- || STRCASECMP(clib, RUBY_COREDLL".dll") == 0
-# endif
- ){
-# ifdef _WIN32_WCE
- ptr = dlopen("coredll.dll", cflag);
-# else
- (void)cflag;
- ptr = w32_coredll();
-# endif
- }
- else
-#endif
- ptr = dlopen(clib, cflag);
-#if defined(HAVE_DLERROR)
- if( !ptr && (err = dlerror()) ){
- rb_raise(rb_eFiddleDLError, "%s", err);
- }
-#else
- if( !ptr ){
- err = dlerror();
- rb_raise(rb_eFiddleDLError, "%s", err);
- }
-#endif
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){
- dlclose(fiddle_handle->ptr);
- }
- fiddle_handle->ptr = ptr;
- fiddle_handle->open = 1;
- fiddle_handle->enable_close = 0;
-
- if( rb_block_given_p() ){
- rb_ensure(rb_yield, self, rb_fiddle_handle_close, self);
- }
-
- return Qnil;
-}
-
-/*
- * call-seq: enable_close
- *
- * Enable a call to dlclose() when this handle is garbage collected.
- */
-static VALUE
-rb_fiddle_handle_enable_close(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- fiddle_handle->enable_close = 1;
- return Qnil;
-}
-
-/*
- * call-seq: disable_close
- *
- * Disable a call to dlclose() when this handle is garbage collected.
- */
-static VALUE
-rb_fiddle_handle_disable_close(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- fiddle_handle->enable_close = 0;
- return Qnil;
-}
-
-/*
- * call-seq: close_enabled?
- *
- * Returns +true+ if dlclose() will be called when this handle is garbage collected.
- *
- * See man(3) dlclose() for more info.
- */
-static VALUE
-rb_fiddle_handle_close_enabled_p(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
-
- if(fiddle_handle->enable_close) return Qtrue;
- return Qfalse;
-}
-
-/*
- * call-seq: to_i
- *
- * Returns the memory address for this handle.
- */
-static VALUE
-rb_fiddle_handle_to_i(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- return PTR2NUM(fiddle_handle->ptr);
-}
-
-/*
- * call-seq: to_ptr
- *
- * Returns the Fiddle::Pointer of this handle.
- */
-static VALUE
-rb_fiddle_handle_to_ptr(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- return rb_fiddle_ptr_new_wrap(fiddle_handle->ptr, 0, 0, self, 0);
-}
-
-static VALUE fiddle_handle_sym(void *handle, VALUE symbol);
-
-/*
- * Document-method: sym
- *
- * call-seq: sym(name)
- *
- * Get the address as an Integer for the function named +name+.
- */
-static VALUE
-rb_fiddle_handle_sym(VALUE self, VALUE sym)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- if( ! fiddle_handle->open ){
- rb_raise(rb_eFiddleDLError, "closed handle");
- }
-
- return fiddle_handle_sym(fiddle_handle->ptr, sym);
-}
-
-#ifndef RTLD_NEXT
-#define RTLD_NEXT NULL
-#endif
-#ifndef RTLD_DEFAULT
-#define RTLD_DEFAULT NULL
-#endif
-
-/*
- * Document-method: sym
- *
- * call-seq: sym(name)
- *
- * Get the address as an Integer for the function named +name+. The function
- * is searched via dlsym on RTLD_NEXT.
- *
- * See man(3) dlsym() for more info.
- */
-static VALUE
-rb_fiddle_handle_s_sym(VALUE self, VALUE sym)
-{
- return fiddle_handle_sym(RTLD_NEXT, sym);
-}
-
-typedef void (*fiddle_void_func)(void);
-
-static fiddle_void_func
-fiddle_handle_find_func(void *handle, VALUE symbol)
-{
-#if defined(HAVE_DLERROR)
- const char *err;
-# define CHECK_DLERROR if ((err = dlerror()) != 0) { func = 0; }
-#else
-# define CHECK_DLERROR
-#endif
- fiddle_void_func func;
- const char *name = StringValueCStr(symbol);
-
-#ifdef HAVE_DLERROR
- dlerror();
-#endif
- func = (fiddle_void_func)(VALUE)dlsym(handle, name);
- CHECK_DLERROR;
-#if defined(FUNC_STDCALL)
- if( !func ){
- int i;
- int len = (int)strlen(name);
- char *name_n;
-#if defined(__CYGWIN__) || defined(_WIN32) || defined(__MINGW32__)
- {
- char *name_a = (char*)xmalloc(len+2);
- strcpy(name_a, name);
- name_n = name_a;
- name_a[len] = 'A';
- name_a[len+1] = '\0';
- func = dlsym(handle, name_a);
- CHECK_DLERROR;
- if( func ) goto found;
- name_n = xrealloc(name_a, len+6);
- }
-#else
- name_n = (char*)xmalloc(len+6);
-#endif
- memcpy(name_n, name, len);
- name_n[len++] = '@';
- for( i = 0; i < 256; i += 4 ){
- sprintf(name_n + len, "%d", i);
- func = dlsym(handle, name_n);
- CHECK_DLERROR;
- if( func ) break;
- }
- if( func ) goto found;
- name_n[len-1] = 'A';
- name_n[len++] = '@';
- for( i = 0; i < 256; i += 4 ){
- sprintf(name_n + len, "%d", i);
- func = dlsym(handle, name_n);
- CHECK_DLERROR;
- if( func ) break;
- }
- found:
- xfree(name_n);
- }
-#endif
-
- return func;
-}
-
-static VALUE
-rb_fiddle_handle_s_sym_defined(VALUE self, VALUE sym)
-{
- fiddle_void_func func;
-
- func = fiddle_handle_find_func(RTLD_NEXT, sym);
-
- if( func ) {
- return PTR2NUM(func);
- }
- else {
- return Qnil;
- }
-}
-
-static VALUE
-rb_fiddle_handle_sym_defined(VALUE self, VALUE sym)
-{
- struct dl_handle *fiddle_handle;
- fiddle_void_func func;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
- if( ! fiddle_handle->open ){
- rb_raise(rb_eFiddleDLError, "closed handle");
- }
-
- func = fiddle_handle_find_func(fiddle_handle->ptr, sym);
-
- if( func ) {
- return PTR2NUM(func);
- }
- else {
- return Qnil;
- }
-}
-
-static VALUE
-fiddle_handle_sym(void *handle, VALUE symbol)
-{
- fiddle_void_func func;
-
- func = fiddle_handle_find_func(handle, symbol);
-
- if( !func ){
- rb_raise(rb_eFiddleDLError, "unknown symbol \"%"PRIsVALUE"\"", symbol);
- }
-
- return PTR2NUM(func);
-}
-
-/*
- * call-seq: file_name
- *
- * Returns the file name of this handle.
- */
-static VALUE
-rb_fiddle_handle_file_name(VALUE self)
-{
- struct dl_handle *fiddle_handle;
-
- TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
-
-#if defined(HAVE_DLINFO) && defined(HAVE_CONST_RTLD_DI_LINKMAP)
- {
- struct link_map *lm = NULL;
- int res = dlinfo(fiddle_handle->ptr, RTLD_DI_LINKMAP, &lm);
- if (res == 0 && lm != NULL) {
- return rb_str_new_cstr(lm->l_name);
- }
- else {
-#if defined(HAVE_DLERROR)
- rb_raise(rb_eFiddleDLError, "could not get handle file name: %s", dlerror());
-#else
- rb_raise(rb_eFiddleDLError, "could not get handle file name");
-#endif
- }
- }
-#elif defined(HAVE_GETMODULEFILENAME)
- {
- char filename[MAX_PATH];
- DWORD res = GetModuleFileName(fiddle_handle->ptr, filename, MAX_PATH);
- if (res == 0) {
- rb_raise(rb_eFiddleDLError, "could not get handle file name: %s", dlerror());
- }
- return rb_str_new_cstr(filename);
- }
-#else
- (void)fiddle_handle;
- return Qnil;
-#endif
-}
-
-void
-Init_fiddle_handle(void)
-{
- /*
- * Document-class: Fiddle::Handle
- *
- * The Fiddle::Handle is the manner to access the dynamic library
- *
- * == Example
- *
- * === Setup
- *
- * libc_so = "/lib64/libc.so.6"
- * => "/lib64/libc.so.6"
- * @handle = Fiddle::Handle.new(libc_so)
- * => #<Fiddle::Handle:0x00000000d69ef8>
- *
- * === Setup, with flags
- *
- * libc_so = "/lib64/libc.so.6"
- * => "/lib64/libc.so.6"
- * @handle = Fiddle::Handle.new(libc_so, Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL)
- * => #<Fiddle::Handle:0x00000000d69ef8>
- *
- * See RTLD_LAZY and RTLD_GLOBAL
- *
- * === Addresses to symbols
- *
- * strcpy_addr = @handle['strcpy']
- * => 140062278451968
- *
- * or
- *
- * strcpy_addr = @handle.sym('strcpy')
- * => 140062278451968
- *
- */
- rb_cHandle = rb_define_class_under(mFiddle, "Handle", rb_cObject);
- rb_define_alloc_func(rb_cHandle, rb_fiddle_handle_s_allocate);
- rb_define_singleton_method(rb_cHandle, "sym", rb_fiddle_handle_s_sym, 1);
- rb_define_singleton_method(rb_cHandle, "sym_defined?", rb_fiddle_handle_s_sym_defined, 1);
- rb_define_singleton_method(rb_cHandle, "[]", rb_fiddle_handle_s_sym, 1);
-
- /* Document-const: NEXT
- *
- * A predefined pseudo-handle of RTLD_NEXT
- *
- * Which will find the next occurrence of a function in the search order
- * after the current library.
- */
- rb_define_const(rb_cHandle, "NEXT", predefined_fiddle_handle(RTLD_NEXT));
-
- /* Document-const: DEFAULT
- *
- * A predefined pseudo-handle of RTLD_DEFAULT
- *
- * Which will find the first occurrence of the desired symbol using the
- * default library search order
- */
- rb_define_const(rb_cHandle, "DEFAULT", predefined_fiddle_handle(RTLD_DEFAULT));
-
- /* Document-const: RTLD_GLOBAL
- *
- * rtld Fiddle::Handle flag.
- *
- * The symbols defined by this library will be made available for symbol
- * resolution of subsequently loaded libraries.
- */
- rb_define_const(rb_cHandle, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL));
-
- /* Document-const: RTLD_LAZY
- *
- * rtld Fiddle::Handle flag.
- *
- * Perform lazy binding. Only resolve symbols as the code that references
- * them is executed. If the symbol is never referenced, then it is never
- * resolved. (Lazy binding is only performed for function references;
- * references to variables are always immediately bound when the library
- * is loaded.)
- */
- rb_define_const(rb_cHandle, "RTLD_LAZY", INT2NUM(RTLD_LAZY));
-
- /* Document-const: RTLD_NOW
- *
- * rtld Fiddle::Handle flag.
- *
- * If this value is specified or the environment variable LD_BIND_NOW is
- * set to a nonempty string, all undefined symbols in the library are
- * resolved before Fiddle.dlopen returns. If this cannot be done an error
- * is returned.
- */
- rb_define_const(rb_cHandle, "RTLD_NOW", INT2NUM(RTLD_NOW));
-
- rb_define_method(rb_cHandle, "initialize", rb_fiddle_handle_initialize, -1);
- rb_define_method(rb_cHandle, "to_i", rb_fiddle_handle_to_i, 0);
- rb_define_method(rb_cHandle, "to_ptr", rb_fiddle_handle_to_ptr, 0);
- rb_define_method(rb_cHandle, "close", rb_fiddle_handle_close, 0);
- rb_define_method(rb_cHandle, "sym", rb_fiddle_handle_sym, 1);
- rb_define_method(rb_cHandle, "[]", rb_fiddle_handle_sym, 1);
- rb_define_method(rb_cHandle, "sym_defined?", rb_fiddle_handle_sym_defined, 1);
- rb_define_method(rb_cHandle, "file_name", rb_fiddle_handle_file_name, 0);
- rb_define_method(rb_cHandle, "disable_close", rb_fiddle_handle_disable_close, 0);
- rb_define_method(rb_cHandle, "enable_close", rb_fiddle_handle_enable_close, 0);
- rb_define_method(rb_cHandle, "close_enabled?", rb_fiddle_handle_close_enabled_p, 0);
-}
-
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/fiddle/lib/fiddle.rb b/ext/fiddle/lib/fiddle.rb
deleted file mode 100644
index 6137c487c6..0000000000
--- a/ext/fiddle/lib/fiddle.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-# frozen_string_literal: true
-
-require 'fiddle.so'
-require 'fiddle/closure'
-require 'fiddle/function'
-require 'fiddle/version'
-
-module Fiddle
- if WINDOWS
- # Returns the last win32 +Error+ of the current executing +Thread+ or nil
- # if none
- def self.win32_last_error
- Thread.current[:__FIDDLE_WIN32_LAST_ERROR__]
- end
-
- # Sets the last win32 +Error+ of the current executing +Thread+ to +error+
- def self.win32_last_error= error
- Thread.current[:__FIDDLE_WIN32_LAST_ERROR__] = error
- end
-
- # Returns the last win32 socket +Error+ of the current executing
- # +Thread+ or nil if none
- def self.win32_last_socket_error
- Thread.current[:__FIDDLE_WIN32_LAST_SOCKET_ERROR__]
- end
-
- # Sets the last win32 socket +Error+ of the current executing
- # +Thread+ to +error+
- def self.win32_last_socket_error= error
- Thread.current[:__FIDDLE_WIN32_LAST_SOCKET_ERROR__] = error
- end
- end
-
- # Returns the last +Error+ of the current executing +Thread+ or nil if none
- def self.last_error
- Thread.current[:__FIDDLE_LAST_ERROR__]
- end
-
- # Sets the last +Error+ of the current executing +Thread+ to +error+
- def self.last_error= error
- Thread.current[:__DL2_LAST_ERROR__] = error
- Thread.current[:__FIDDLE_LAST_ERROR__] = error
- end
-
- # call-seq: dlopen(library) => Fiddle::Handle
- #
- # Creates a new handler that opens +library+, and returns an instance of
- # Fiddle::Handle.
- #
- # If +nil+ is given for the +library+, Fiddle::Handle::DEFAULT is used, which
- # is the equivalent to RTLD_DEFAULT. See <code>man 3 dlopen</code> for more.
- #
- # lib = Fiddle.dlopen(nil)
- #
- # The default is dependent on OS, and provide a handle for all libraries
- # already loaded. For example, in most cases you can use this to access
- # +libc+ functions, or ruby functions like +rb_str_new+.
- #
- # See Fiddle::Handle.new for more.
- def dlopen library
- begin
- Fiddle::Handle.new(library)
- rescue DLError => error
- case RUBY_PLATFORM
- when /linux/
- case error.message
- when /\A(\/.+?): (?:invalid ELF header|file too short)/
- # This may be a linker script:
- # https://sourceware.org/binutils/docs/ld.html#Scripts
- path = $1
- else
- raise
- end
- else
- raise
- end
-
- File.open(path) do |input|
- input.each_line do |line|
- case line
- when /\A\s*(?:INPUT|GROUP)\s*\(\s*([^\s,\)]+)/
- # TODO: Should we support multiple files?
- return dlopen($1)
- end
- end
- end
-
- # Not found
- raise
- end
- end
- module_function :dlopen
-
- # Add constants for backwards compat
-
- RTLD_GLOBAL = Handle::RTLD_GLOBAL # :nodoc:
- RTLD_LAZY = Handle::RTLD_LAZY # :nodoc:
- RTLD_NOW = Handle::RTLD_NOW # :nodoc:
-
- Fiddle::Types.constants.each do |type|
- const_set "TYPE_#{type}", Fiddle::Types.const_get(type)
- end
-end
diff --git a/ext/fiddle/lib/fiddle/closure.rb b/ext/fiddle/lib/fiddle/closure.rb
deleted file mode 100644
index 7e0077ea52..0000000000
--- a/ext/fiddle/lib/fiddle/closure.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# frozen_string_literal: true
-module Fiddle
- class Closure
- class << self
- # Create a new closure. If a block is given, the created closure
- # is automatically freed after the given block is executed.
- #
- # The all given arguments are passed to Fiddle::Closure.new. So
- # using this method without block equals to Fiddle::Closure.new.
- #
- # == Example
- #
- # Fiddle::Closure.create(TYPE_INT, [TYPE_INT]) do |closure|
- # # closure is freed automatically when this block is finished.
- # end
- def create(*args)
- if block_given?
- closure = new(*args)
- begin
- yield(closure)
- ensure
- closure.free
- end
- else
- new(*args)
- end
- end
- end
-
- # the C type of the return of the FFI closure
- attr_reader :ctype
-
- # arguments of the FFI closure
- attr_reader :args
-
- # Extends Fiddle::Closure to allow for building the closure in a block
- class BlockCaller < Fiddle::Closure
-
- # == Description
- #
- # Construct a new BlockCaller object.
- #
- # * +ctype+ is the C type to be returned
- # * +args+ are passed the callback
- # * +abi+ is the abi of the closure
- #
- # If there is an error in preparing the +ffi_cif+ or +ffi_prep_closure+,
- # then a RuntimeError will be raised.
- #
- # == Example
- #
- # include Fiddle
- #
- # cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one|
- # one
- # end
- #
- # func = Function.new(cb, [TYPE_INT], TYPE_INT)
- #
- def initialize ctype, args, abi = Fiddle::Function::DEFAULT, &block
- super(ctype, args, abi)
- @block = block
- end
-
- # Calls the constructed BlockCaller, with +args+
- #
- # For an example see Fiddle::Closure::BlockCaller.new
- #
- def call *args
- @block.call(*args)
- end
- end
- end
-end
diff --git a/ext/fiddle/lib/fiddle/cparser.rb b/ext/fiddle/lib/fiddle/cparser.rb
deleted file mode 100644
index 9a70402953..0000000000
--- a/ext/fiddle/lib/fiddle/cparser.rb
+++ /dev/null
@@ -1,264 +0,0 @@
-# frozen_string_literal: true
-module Fiddle
- # A mixin that provides methods for parsing C struct and prototype signatures.
- #
- # == Example
- # require 'fiddle/import'
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_ctype('int')
- # #=> Fiddle::TYPE_INT
- #
- # parse_struct_signature(['int i', 'char c'])
- # #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]]
- #
- # parse_signature('double sum(double, double)')
- # #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]]
- #
- module CParser
- # Parses a C struct's members
- #
- # Example:
- # require 'fiddle/import'
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_struct_signature(['int i', 'char c'])
- # #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]]
- #
- # parse_struct_signature(['char buffer[80]'])
- # #=> [[[Fiddle::TYPE_CHAR, 80]], ["buffer"]]
- #
- def parse_struct_signature(signature, tymap=nil)
- if signature.is_a?(String)
- signature = split_arguments(signature, /[,;]/)
- elsif signature.is_a?(Hash)
- signature = [signature]
- end
- mems = []
- tys = []
- signature.each{|msig|
- msig = compact(msig) if msig.is_a?(String)
- case msig
- when Hash
- msig.each do |struct_name, struct_signature|
- struct_name = struct_name.to_s if struct_name.is_a?(Symbol)
- struct_name = compact(struct_name)
- struct_count = nil
- if struct_name =~ /^([\w\*\s]+)\[(\d+)\]$/
- struct_count = $2.to_i
- struct_name = $1
- end
- if struct_signature.respond_to?(:entity_class)
- struct_type = struct_signature
- else
- parsed_struct = parse_struct_signature(struct_signature, tymap)
- struct_type = CStructBuilder.create(CStruct, *parsed_struct)
- end
- if struct_count
- ty = [struct_type, struct_count]
- else
- ty = struct_type
- end
- mems.push([struct_name, struct_type.members])
- tys.push(ty)
- end
- when /^[\w\*\s]+[\*\s](\w+)$/
- mems.push($1)
- tys.push(parse_ctype(msig, tymap))
- when /^[\w\*\s]+\(\*(\w+)\)\(.*?\)$/
- mems.push($1)
- tys.push(parse_ctype(msig, tymap))
- when /^([\w\*\s]+[\*\s])(\w+)\[(\d+)\]$/
- mems.push($2)
- tys.push([parse_ctype($1.strip, tymap), $3.to_i])
- when /^([\w\*\s]+)\[(\d+)\](\w+)$/
- mems.push($3)
- tys.push([parse_ctype($1.strip, tymap), $2.to_i])
- else
- raise(RuntimeError,"can't parse the struct member: #{msig}")
- end
- }
- return tys, mems
- end
-
- # Parses a C prototype signature
- #
- # If Hash +tymap+ is provided, the return value and the arguments from the
- # +signature+ are expected to be keys, and the value will be the C type to
- # be looked up.
- #
- # Example:
- # require 'fiddle/import'
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_signature('double sum(double, double)')
- # #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]]
- #
- # parse_signature('void update(void (*cb)(int code))')
- # #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]]
- #
- # parse_signature('char (*getbuffer(void))[80]')
- # #=> ["getbuffer", Fiddle::TYPE_VOIDP, []]
- #
- def parse_signature(signature, tymap=nil)
- tymap ||= {}
- case compact(signature)
- when /^(?:[\w\*\s]+)\(\*(\w+)\((.*?)\)\)(?:\[\w*\]|\(.*?\));?$/
- func, args = $1, $2
- return [func, TYPE_VOIDP, split_arguments(args).collect {|arg| parse_ctype(arg, tymap)}]
- when /^([\w\*\s]+[\*\s])(\w+)\((.*?)\);?$/
- ret, func, args = $1.strip, $2, $3
- return [func, parse_ctype(ret, tymap), split_arguments(args).collect {|arg| parse_ctype(arg, tymap)}]
- else
- raise(RuntimeError,"can't parse the function prototype: #{signature}")
- end
- end
-
- # Given a String of C type +ty+, returns the corresponding Fiddle constant.
- #
- # +ty+ can also accept an Array of C type Strings, and will be returned in
- # a corresponding Array.
- #
- # If Hash +tymap+ is provided, +ty+ is expected to be the key, and the
- # value will be the C type to be looked up.
- #
- # Example:
- # require 'fiddle/import'
- #
- # include Fiddle::CParser
- # #=> Object
- #
- # parse_ctype('int')
- # #=> Fiddle::TYPE_INT
- #
- # parse_ctype('double diff')
- # #=> Fiddle::TYPE_DOUBLE
- #
- # parse_ctype('unsigned char byte')
- # #=> -Fiddle::TYPE_CHAR
- #
- # parse_ctype('const char* const argv[]')
- # #=> -Fiddle::TYPE_VOIDP
- #
- def parse_ctype(ty, tymap=nil)
- tymap ||= {}
- if ty.is_a?(Array)
- return [parse_ctype(ty[0], tymap), ty[1]]
- end
- ty = ty.gsub(/\Aconst\s+/, "")
- case ty
- when 'void'
- return TYPE_VOID
- when /\A(?:(?:signed\s+)?long\s+long(?:\s+int\s+)?|int64_t)(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_LONG_LONG)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_LONG_LONG
- when /\A(?:unsigned\s+long\s+long(?:\s+int\s+)?|uint64_t)(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_LONG_LONG)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_ULONG_LONG
- when /\A(?:signed\s+)?long(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_LONG
- when /\Aunsigned\s+long(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_ULONG
- when /\A(?:signed\s+)?int(?:\s+\w+)?\z/
- return TYPE_INT
- when /\A(?:unsigned\s+int|uint)(?:\s+\w+)?\z/
- return TYPE_UINT
- when /\A(?:signed\s+)?short(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_SHORT
- when /\Aunsigned\s+short(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_USHORT
- when /\A(?:signed\s+)?char(?:\s+\w+)?\z/
- return TYPE_CHAR
- when /\Aunsigned\s+char(?:\s+\w+)?\z/
- return TYPE_UCHAR
- when /\Aint8_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT8_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_INT8_T
- when /\Auint8_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT8_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_UINT8_T
- when /\Aint16_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT16_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_INT16_T
- when /\Auint16_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT16_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_UINT16_T
- when /\Aint32_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT32_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_INT32_T
- when /\Auint32_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT32_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_UINT32_T
- when /\Aint64_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT64_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_INT64_T
- when /\Auint64_t(?:\s+\w+)?\z/
- unless Fiddle.const_defined?(:TYPE_INT64_T)
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- return TYPE_UINT64_T
- when /\Afloat(?:\s+\w+)?\z/
- return TYPE_FLOAT
- when /\Adouble(?:\s+\w+)?\z/
- return TYPE_DOUBLE
- when /\Asize_t(?:\s+\w+)?\z/
- return TYPE_SIZE_T
- when /\Assize_t(?:\s+\w+)?\z/
- return TYPE_SSIZE_T
- when /\Aptrdiff_t(?:\s+\w+)?\z/
- return TYPE_PTRDIFF_T
- when /\Aintptr_t(?:\s+\w+)?\z/
- return TYPE_INTPTR_T
- when /\Auintptr_t(?:\s+\w+)?\z/
- return TYPE_UINTPTR_T
- when /\*/, /\[[\s\d]*\]/
- return TYPE_VOIDP
- when "..."
- return TYPE_VARIADIC
- else
- ty = ty.split(' ', 2)[0]
- if( tymap[ty] )
- return parse_ctype(tymap[ty], tymap)
- else
- raise(DLError, "unknown type: #{ty}")
- end
- end
- end
-
- private
-
- def split_arguments(arguments, sep=',')
- return [] if arguments.strip == 'void'
- arguments.scan(/([\w\*\s]+\(\*\w*\)\(.*?\)|[\w\*\s\[\]]+|\.\.\.)(?:#{sep}\s*|\z)/).collect {|m| m[0]}
- end
-
- def compact(signature)
- signature.gsub(/\s+/, ' ').gsub(/\s*([\(\)\[\]\*,;])\s*/, '\1').strip
- end
-
- end
-end
diff --git a/ext/fiddle/lib/fiddle/function.rb b/ext/fiddle/lib/fiddle/function.rb
deleted file mode 100644
index dc2e3e6bf5..0000000000
--- a/ext/fiddle/lib/fiddle/function.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-module Fiddle
- class Function
- # The ABI of the Function.
- attr_reader :abi
-
- # The address of this function
- attr_reader :ptr
-
- # The name of this function
- attr_reader :name
-
- # Whether GVL is needed to call this function
- def need_gvl?
- @need_gvl
- end
-
- # The integer memory location of this function
- def to_i
- ptr.to_i
- end
-
- # Turn this function in to a proc
- def to_proc
- this = self
- lambda { |*args| this.call(*args) }
- end
- end
-end
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
deleted file mode 100644
index 09ffcef544..0000000000
--- a/ext/fiddle/lib/fiddle/import.rb
+++ /dev/null
@@ -1,320 +0,0 @@
-# frozen_string_literal: true
-require 'fiddle'
-require 'fiddle/struct'
-require 'fiddle/cparser'
-
-module Fiddle
-
- # Used internally by Fiddle::Importer
- class CompositeHandler
- # Create a new handler with the open +handlers+
- #
- # Used internally by Fiddle::Importer.dlload
- def initialize(handlers)
- @handlers = handlers
- end
-
- # Array of the currently loaded libraries.
- def handlers()
- @handlers
- end
-
- # Returns the address as an Integer from any handlers with the function
- # named +symbol+.
- #
- # Raises a DLError if the handle is closed.
- def sym(symbol)
- @handlers.each{|handle|
- if( handle )
- begin
- addr = handle.sym(symbol)
- return addr
- rescue DLError
- end
- end
- }
- return nil
- end
-
- # See Fiddle::CompositeHandler.sym
- def [](symbol)
- sym(symbol)
- end
- end
-
- # A DSL that provides the means to dynamically load libraries and build
- # modules around them including calling extern functions within the C
- # library that has been loaded.
- #
- # == Example
- #
- # require 'fiddle'
- # require 'fiddle/import'
- #
- # module LibSum
- # extend Fiddle::Importer
- # dlload './libsum.so'
- # extern 'double sum(double*, int)'
- # extern 'double split(double)'
- # end
- #
- module Importer
- include Fiddle
- include CParser
- extend Importer
-
- attr_reader :type_alias
- private :type_alias
-
- # Creates an array of handlers for the given +libs+, can be an instance of
- # Fiddle::Handle, Fiddle::Importer, or will create a new instance of
- # Fiddle::Handle using Fiddle.dlopen
- #
- # Raises a DLError if the library cannot be loaded.
- #
- # See Fiddle.dlopen
- def dlload(*libs)
- handles = libs.collect{|lib|
- case lib
- when nil
- nil
- when Handle
- lib
- when Importer
- lib.handlers
- else
- Fiddle.dlopen(lib)
- end
- }.flatten()
- @handler = CompositeHandler.new(handles)
- @func_map = {}
- @type_alias = {}
- end
-
- # Sets the type alias for +alias_type+ as +orig_type+
- def typealias(alias_type, orig_type)
- @type_alias[alias_type] = orig_type
- end
-
- # Returns the sizeof +ty+, using Fiddle::Importer.parse_ctype to determine
- # the C type and the appropriate Fiddle constant.
- 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_FLOAT
- return SIZEOF_FLOAT
- when TYPE_DOUBLE
- return SIZEOF_DOUBLE
- when TYPE_VOIDP
- return SIZEOF_VOIDP
- when TYPE_CONST_STRING
- return SIZEOF_CONST_STRING
- else
- if defined?(TYPE_LONG_LONG) and
- ty == TYPE_LONG_LONG
- return SIZEOF_LONG_LONG
- else
- raise(DLError, "unknown type: #{ty}")
- end
- end
- when Class
- if( ty.instance_methods().include?(:to_ptr) )
- return ty.size()
- end
- end
- return Pointer[ty].size()
- end
-
- def parse_bind_options(opts)
- h = {}
- 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
- end
- h
- end
- private :parse_bind_options
-
- # :stopdoc:
- CALL_TYPE_TO_ABI = Hash.new { |h, k|
- raise RuntimeError, "unsupported call type: #{k}"
- }.merge({ :stdcall => Function.const_defined?(:STDCALL) ? Function::STDCALL :
- Function::DEFAULT,
- :cdecl => Function::DEFAULT,
- nil => Function::DEFAULT
- }).freeze
- private_constant :CALL_TYPE_TO_ABI
- # :startdoc:
-
- # Creates a global method from the given C +signature+.
- 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)}
- begin
- /^(.+?):(\d+)/ =~ caller.first
- file, line = $1, $2.to_i
- rescue
- file, line = __FILE__, __LINE__+3
- end
- module_eval(<<-EOS, file, line)
- def #{name}(*args, &block)
- @func_map['#{name}'].call(*args,&block)
- end
- EOS
- module_function(name)
- f
- end
-
- # Creates a global method from the given C +signature+ using the given
- # +opts+ as bind parameters with the given block.
- 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)
- else
- raise(RuntimeError, "unknown callback type: #{h[:callback_type]}")
- end
- @func_map[name] = f
- #define_method(name){|*args,&block| f.call(*args,&block)}
- begin
- /^(.+?):(\d+)/ =~ caller.first
- file, line = $1, $2.to_i
- rescue
- file, line = __FILE__, __LINE__+3
- end
- module_eval(<<-EOS, file, line)
- def #{name}(*args,&block)
- @func_map['#{name}'].call(*args,&block)
- end
- EOS
- module_function(name)
- f
- end
-
- # Creates a class to wrap the C struct described by +signature+.
- #
- # MyStruct = struct ['int i', 'char c']
- def struct(signature)
- tys, mems = parse_struct_signature(signature, type_alias)
- Fiddle::CStructBuilder.create(CStruct, tys, mems)
- end
-
- # Creates a class to wrap the C union described by +signature+.
- #
- # MyUnion = union ['int i', 'char c']
- def union(signature)
- tys, mems = parse_struct_signature(signature, type_alias)
- Fiddle::CStructBuilder.create(CUnion, tys, mems)
- end
-
- # Returns the function mapped to +name+, that was created by either
- # Fiddle::Importer.extern or Fiddle::Importer.bind
- def [](name)
- @func_map[name]
- end
-
- # Creates a class to wrap the C struct with the value +ty+
- #
- # See also Fiddle::Importer.struct
- def create_value(ty, val=nil)
- s = struct([ty + " value"])
- ptr = s.malloc()
- if( val )
- ptr.value = val
- end
- return ptr
- end
- alias value create_value
-
- # Returns a new instance of the C struct with the value +ty+ at the +addr+
- # address.
- def import_value(ty, addr)
- s = struct([ty + " value"])
- ptr = s.new(addr)
- return ptr
- end
-
-
- # The Fiddle::CompositeHandler instance
- #
- # Will raise an error if no handlers are open.
- def handler
- (@handler ||= nil) or raise "call dlload before importing symbols and functions"
- end
-
- # Returns a new Fiddle::Pointer instance at the memory address of the given
- # +name+ symbol.
- #
- # Raises a DLError if the +name+ doesn't exist.
- #
- # See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym
- def import_symbol(name)
- addr = handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the symbol: #{name}")
- end
- Pointer.new(addr)
- end
-
- # Returns a new Fiddle::Function instance at the memory address of the given
- # +name+ function.
- #
- # Raises a DLError if the +name+ doesn't exist.
- #
- # * +argtype+ is an Array of arguments, passed to the +name+ function.
- # * +ctype+ is the return type of the function
- # * +call_type+ is the ABI of the function
- #
- # See also Fiddle:Function.new
- #
- # See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym
- def import_function(name, ctype, argtype, call_type = nil)
- addr = handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the function: #{name}()")
- end
- Function.new(addr, argtype, ctype, CALL_TYPE_TO_ABI[call_type],
- name: name)
- end
-
- # Returns a new closure wrapper for the +name+ function.
- #
- # * +ctype+ is the return type of the function
- # * +argtype+ is an Array of arguments, passed to the callback function
- # * +call_type+ is the abi of the closure
- # * +block+ is passed to the callback
- #
- # See Fiddle::Closure
- def bind_function(name, ctype, argtype, call_type = nil, &block)
- abi = CALL_TYPE_TO_ABI[call_type]
- closure = Class.new(Fiddle::Closure) {
- define_method(:call, block)
- }.new(ctype, argtype, abi)
-
- Function.new(closure, argtype, ctype, abi, name: name)
- end
- end
-end
diff --git a/ext/fiddle/lib/fiddle/pack.rb b/ext/fiddle/lib/fiddle/pack.rb
deleted file mode 100644
index 545b985d50..0000000000
--- a/ext/fiddle/lib/fiddle/pack.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-# frozen_string_literal: true
-require 'fiddle'
-
-module Fiddle
- module PackInfo # :nodoc: all
- 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_UCHAR => ALIGN_CHAR,
- TYPE_USHORT => ALIGN_SHORT,
- TYPE_UINT => ALIGN_INT,
- TYPE_ULONG => ALIGN_LONG,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => "L!",
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- TYPE_UCHAR => "C",
- TYPE_USHORT => "S!",
- TYPE_UINT => "I!",
- TYPE_ULONG => "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_UCHAR => SIZEOF_CHAR,
- TYPE_USHORT => SIZEOF_SHORT,
- TYPE_UINT => SIZEOF_INT,
- TYPE_ULONG => SIZEOF_LONG,
- }
- if defined?(TYPE_LONG_LONG)
- ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[TYPE_ULONG_LONG] = ALIGN_LONG_LONG
- PACK_MAP[TYPE_LONG_LONG] = "q"
- PACK_MAP[TYPE_ULONG_LONG] = "Q"
- SIZE_MAP[TYPE_LONG_LONG] = SIZE_MAP[TYPE_ULONG_LONG] = SIZEOF_LONG_LONG
- PACK_MAP[TYPE_VOIDP] = "Q" if SIZEOF_LONG_LONG == SIZEOF_VOIDP
- end
-
- def align(addr, align)
- d = addr % align
- if( d == 0 )
- addr
- else
- addr + (align - d)
- end
- end
- module_function :align
- end
-
- class Packer # :nodoc: all
- include PackInfo
-
- def self.[](*types)
- 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)
- else
- if defined?(TYPE_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- ary.pack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
- end
-
- def unpack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.join().unpack(@template)
- else
- if defined?(TYPE_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- ary.join().unpack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
- end
-
- private
-
- def parse_types(types)
- @template = "".dup
- 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/fiddle/lib/fiddle/struct.rb b/ext/fiddle/lib/fiddle/struct.rb
deleted file mode 100644
index 6d05bbd742..0000000000
--- a/ext/fiddle/lib/fiddle/struct.rb
+++ /dev/null
@@ -1,539 +0,0 @@
-# frozen_string_literal: true
-require 'fiddle'
-require 'fiddle/value'
-require 'fiddle/pack'
-
-module Fiddle
- # A base class for objects representing a C structure
- class CStruct
- include Enumerable
-
- # accessor to Fiddle::CStructEntity
- def CStruct.entity_class
- CStructEntity
- end
-
- def self.offsetof(name, members, types) # :nodoc:
- offset = 0
- worklist = name.split('.')
- this_type = self
- while search_name = worklist.shift
- index = 0
- member_index = members.index(search_name)
-
- unless member_index
- # Possibly a sub-structure
- member_index = members.index { |member_name, _|
- member_name == search_name
- }
- return unless member_index
- end
-
- types.each { |type, count = 1|
- orig_offset = offset
- if type.respond_to?(:entity_class)
- align = type.alignment
- type_size = type.size
- else
- align = PackInfo::ALIGN_MAP[type]
- type_size = PackInfo::SIZE_MAP[type]
- end
-
- # Unions shouldn't advance the offset
- if this_type.entity_class == CUnionEntity
- type_size = 0
- end
-
- offset = PackInfo.align(orig_offset, align)
-
- if worklist.empty?
- return offset if index == member_index
- else
- if index == member_index
- subtype = types[member_index]
- members = subtype.members
- types = subtype.types
- this_type = subtype
- break
- end
- end
-
- offset += (type_size * count)
- index += 1
- }
- end
- nil
- end
-
- def each
- return enum_for(__function__) unless block_given?
-
- self.class.members.each do |name,|
- yield(self[name])
- end
- end
-
- def each_pair
- return enum_for(__function__) unless block_given?
-
- self.class.members.each do |name,|
- yield(name, self[name])
- end
- end
-
- def to_h
- hash = {}
- each_pair do |name, value|
- hash[name] = unstruct(value)
- end
- hash
- end
-
- def replace(another)
- if another.nil?
- self.class.members.each do |name,|
- self[name] = nil
- end
- elsif another.respond_to?(:each_pair)
- another.each_pair do |name, value|
- self[name] = value
- end
- else
- another.each do |name, value|
- self[name] = value
- end
- end
- self
- end
-
- private
- def unstruct(value)
- case value
- when CStruct
- value.to_h
- when Array
- value.collect do |v|
- unstruct(v)
- end
- else
- value
- end
- end
- end
-
- # A base class for objects representing a C union
- class CUnion
- # accessor to Fiddle::CUnionEntity
- def CUnion.entity_class
- CUnionEntity
- end
-
- def self.offsetof(name, members, types) # :nodoc:
- 0
- end
- end
-
- # Wrapper for arrays within a struct
- class StructArray < Array
- include ValueUtil
-
- def initialize(ptr, type, initial_values)
- @ptr = ptr
- @type = type
- @is_struct = @type.respond_to?(:entity_class)
- if @is_struct
- super(initial_values)
- else
- @size = Fiddle::PackInfo::SIZE_MAP[type]
- @pack_format = Fiddle::PackInfo::PACK_MAP[type]
- super(initial_values.collect { |v| unsigned_value(v, type) })
- end
- end
-
- def to_ptr
- @ptr
- end
-
- def []=(index, value)
- if index < 0 || index >= size
- raise IndexError, 'index %d outside of array bounds 0...%d' % [index, size]
- end
-
- if @is_struct
- self[index].replace(value)
- else
- to_ptr[index * @size, @size] = [value].pack(@pack_format)
- super(index, value)
- end
- end
- end
-
- # Used to construct C classes (CUnion, CStruct, etc)
- #
- # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
- # easy-to-use manner.
- module CStructBuilder
- # Construct a new class given a C:
- # * class +klass+ (CUnion, CStruct, or other that provide an
- # #entity_class)
- # * +types+ (Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types
- # constants)
- # * corresponding +members+
- #
- # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
- # easy-to-use manner.
- #
- # Examples:
- #
- # require 'fiddle/struct'
- # require 'fiddle/cparser'
- #
- # include Fiddle::CParser
- #
- # types, members = parse_struct_signature(['int i','char c'])
- #
- # MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members)
- #
- # MyStruct.malloc(Fiddle::RUBY_FREE) do |obj|
- # ...
- # end
- #
- # obj = MyStruct.malloc(Fiddle::RUBY_FREE)
- # begin
- # ...
- # ensure
- # obj.call_free
- # end
- #
- # obj = MyStruct.malloc
- # begin
- # ...
- # ensure
- # Fiddle.free obj.to_ptr
- # end
- #
- def create(klass, types, members)
- new_class = Class.new(klass){
- define_method(:initialize){|addr, func = nil|
- if addr.is_a?(self.class.entity_class)
- @entity = addr
- else
- @entity = self.class.entity_class.new(addr, types, func)
- end
- @entity.assign_names(members)
- }
- define_method(:[]) { |*args| @entity.send(:[], *args) }
- define_method(:[]=) { |*args| @entity.send(:[]=, *args) }
- define_method(:to_ptr){ @entity }
- define_method(:to_i){ @entity.to_i }
- define_singleton_method(:types) { types }
- define_singleton_method(:members) { members }
-
- # Return the offset of a struct member given its name.
- # For example:
- #
- # MyStruct = struct [
- # "int64_t i",
- # "char c",
- # ]
- #
- # MyStruct.offsetof("i") # => 0
- # MyStruct.offsetof("c") # => 8
- #
- define_singleton_method(:offsetof) { |name|
- klass.offsetof(name, members, types)
- }
- members.each{|name|
- name = name[0] if name.is_a?(Array) # name is a nested struct
- next if method_defined?(name)
- define_method(name){ @entity[name] }
- define_method(name + "="){|val| @entity[name] = val }
- }
- entity_class = klass.entity_class
- alignment = entity_class.alignment(types)
- size = entity_class.size(types)
- define_singleton_method(:alignment) { alignment }
- define_singleton_method(:size) { size }
- define_singleton_method(:malloc) do |func=nil, &block|
- if block
- entity_class.malloc(types, func, size) do |entity|
- block.call(new(entity))
- end
- else
- new(entity_class.malloc(types, func, size))
- end
- end
- }
- return new_class
- end
- module_function :create
- end
-
- # A pointer to a C structure
- class CStructEntity < Fiddle::Pointer
- include PackInfo
- include ValueUtil
-
- def CStructEntity.alignment(types)
- max = 1
- types.each do |type, count = 1|
- if type.respond_to?(:entity_class)
- n = type.alignment
- else
- n = ALIGN_MAP[type]
- end
- max = n if n > max
- end
- max
- end
-
- # Allocates a C struct with the +types+ provided.
- #
- # See Fiddle::Pointer.malloc for memory management issues.
- def CStructEntity.malloc(types, func = nil, size = size(types), &block)
- if block_given?
- super(size, func) do |struct|
- struct.set_ctypes types
- yield struct
- end
- else
- struct = super(size, func)
- struct.set_ctypes types
- struct
- end
- end
-
- # Returns the offset for the packed sizes for the given +types+.
- #
- # Fiddle::CStructEntity.size(
- # [ Fiddle::TYPE_DOUBLE,
- # Fiddle::TYPE_INT,
- # Fiddle::TYPE_CHAR,
- # Fiddle::TYPE_VOIDP ]) #=> 24
- def CStructEntity.size(types)
- offset = 0
-
- max_align = types.map { |type, count = 1|
- last_offset = offset
-
- if type.respond_to?(:entity_class)
- align = type.alignment
- type_size = type.size
- else
- align = PackInfo::ALIGN_MAP[type]
- type_size = PackInfo::SIZE_MAP[type]
- end
- offset = PackInfo.align(last_offset, align) +
- (type_size * count)
-
- align
- }.max
-
- PackInfo.align(offset, max_align)
- end
-
- # Wraps the C pointer +addr+ as a C struct with the given +types+.
- #
- # When the instance is garbage collected, the C function +func+ is called.
- #
- # See also Fiddle::Pointer.new
- def initialize(addr, types, func = nil)
- if func && addr.is_a?(Pointer) && addr.free
- raise ArgumentError, 'free function specified on both underlying struct Pointer and when creating a CStructEntity - who do you want to free this?'
- end
- set_ctypes(types)
- super(addr, @size, func)
- end
-
- # Set the names of the +members+ in this C struct
- def assign_names(members)
- @members = []
- @nested_structs = {}
- members.each_with_index do |member, index|
- if member.is_a?(Array) # nested struct
- member_name = member[0]
- struct_type, struct_count = @ctypes[index]
- if struct_count.nil?
- struct = struct_type.new(to_i + @offset[index])
- else
- structs = struct_count.times.map do |i|
- struct_type.new(to_i + @offset[index] + i * struct_type.size)
- end
- struct = StructArray.new(to_i + @offset[index],
- struct_type,
- structs)
- end
- @nested_structs[member_name] = struct
- else
- member_name = member
- end
- @members << member_name
- end
- end
-
- # Calculates the offsets and sizes for the given +types+ in the struct.
- def set_ctypes(types)
- @ctypes = types
- @offset = []
- offset = 0
-
- max_align = types.map { |type, count = 1|
- orig_offset = offset
- if type.respond_to?(:entity_class)
- align = type.alignment
- type_size = type.size
- else
- align = ALIGN_MAP[type]
- type_size = SIZE_MAP[type]
- end
- offset = PackInfo.align(orig_offset, align)
-
- @offset << offset
-
- offset += (type_size * count)
-
- align
- }.max
-
- @size = PackInfo.align(offset, max_align)
- end
-
- # Fetch struct member +name+ if only one argument is specified. If two
- # arguments are specified, the first is an offset and the second is a
- # length and this method returns the string of +length+ bytes beginning at
- # +offset+.
- #
- # Examples:
- #
- # my_struct = struct(['int id']).malloc
- # my_struct.id = 1
- # my_struct['id'] # => 1
- # my_struct[0, 4] # => "\x01\x00\x00\x00".b
- #
- def [](*args)
- return super(*args) if args.size > 1
- name = args[0]
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
- end
- ty = @ctypes[idx]
- if( ty.is_a?(Array) )
- if ty.first.respond_to?(:entity_class)
- return @nested_structs[name]
- else
- r = super(@offset[idx], SIZE_MAP[ty[0]] * ty[1])
- end
- elsif ty.respond_to?(:entity_class)
- return @nested_structs[name]
- 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| Pointer.new(v)}
- end
- when TYPE_VOIDP
- val = Pointer.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 StructArray.new(self + @offset[idx], ty[0], val)
- else
- return val
- end
- end
-
- # Set struct member +name+, to value +val+. If more arguments are
- # specified, writes the string of bytes to the memory at the given
- # +offset+ and +length+.
- #
- # Examples:
- #
- # my_struct = struct(['int id']).malloc
- # my_struct['id'] = 1
- # my_struct[0, 4] = "\x01\x00\x00\x00".b
- # my_struct.id # => 1
- #
- def []=(*args)
- return super(*args) if args.size > 2
- name, val = *args
- name = name.to_s if name.is_a?(Symbol)
- nested_struct = @nested_structs[name]
- if nested_struct
- if nested_struct.is_a?(StructArray)
- if val.nil?
- nested_struct.each do |s|
- s.replace(nil)
- end
- else
- val.each_with_index do |v, i|
- nested_struct[i] = v
- end
- end
- else
- nested_struct.replace(val)
- end
- return val
- end
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
- 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
- end
- end
-
- undef_method :size=
- def to_s() # :nodoc:
- super(@size)
- end
- end
-
- # A pointer to a C union
- class CUnionEntity < CStructEntity
- include PackInfo
-
- # Returns the size needed for the union with the given +types+.
- #
- # Fiddle::CUnionEntity.size(
- # [ Fiddle::TYPE_DOUBLE,
- # Fiddle::TYPE_INT,
- # Fiddle::TYPE_CHAR,
- # Fiddle::TYPE_VOIDP ]) #=> 8
- def CUnionEntity.size(types)
- types.map { |type, count = 1|
- if type.respond_to?(:entity_class)
- type.size * count
- else
- PackInfo::SIZE_MAP[type] * count
- end
- }.max
- end
-
- # Calculate the necessary offset and for each union member with the given
- # +types+
- def set_ctypes(types)
- @ctypes = types
- @offset = Array.new(types.length, 0)
- @size = self.class.size types
- end
- end
-end
diff --git a/ext/fiddle/lib/fiddle/types.rb b/ext/fiddle/lib/fiddle/types.rb
deleted file mode 100644
index 7baf31ec9e..0000000000
--- a/ext/fiddle/lib/fiddle/types.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-module Fiddle
- # Adds Windows type aliases to the including class for use with
- # Fiddle::Importer.
- #
- # The aliases added are:
- # * ATOM
- # * BOOL
- # * BYTE
- # * DWORD
- # * DWORD32
- # * DWORD64
- # * HANDLE
- # * HDC
- # * HINSTANCE
- # * HWND
- # * LPCSTR
- # * LPSTR
- # * PBYTE
- # * PDWORD
- # * PHANDLE
- # * PVOID
- # * PWORD
- # * UCHAR
- # * UINT
- # * ULONG
- # * WORD
- module Win32Types
- def included(m) # :nodoc:
- # https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types
- m.module_eval{
- typealias "ATOM", "WORD"
- typealias "BOOL", "int"
- typealias "BYTE", "unsigned char"
- typealias "DWORD", "unsigned long"
- typealias "DWORD32", "uint32_t"
- typealias "DWORD64", "uint64_t"
- typealias "HANDLE", "PVOID"
- typealias "HDC", "HANDLE"
- typealias "HINSTANCE", "HANDLE"
- typealias "HWND", "HANDLE"
- typealias "LPCSTR", "const char *"
- typealias "LPSTR", "char *"
- typealias "PBYTE", "BYTE *"
- typealias "PDWORD", "DWORD *"
- typealias "PHANDLE", "HANDLE *"
- typealias "PVOID", "void *"
- typealias "PWORD", "WORD *"
- typealias "UCHAR", "unsigned char"
- typealias "UINT", "unsigned int"
- typealias "ULONG", "unsigned long"
- typealias "WORD", "unsigned short"
- }
- end
- module_function :included
- end
-
- # Adds basic type aliases to the including class for use with Fiddle::Importer.
- #
- # The aliases added are +uint+ and +u_int+ (<tt>unsigned int</tt>) and
- # +ulong+ and +u_long+ (<tt>unsigned long</tt>)
- module BasicTypes
- def included(m) # :nodoc:
- m.module_eval{
- typealias "uint", "unsigned int"
- typealias "u_int", "unsigned int"
- typealias "ulong", "unsigned long"
- typealias "u_long", "unsigned long"
- }
- end
- module_function :included
- end
-end
diff --git a/ext/fiddle/lib/fiddle/value.rb b/ext/fiddle/lib/fiddle/value.rb
deleted file mode 100644
index 5f0b2e951e..0000000000
--- a/ext/fiddle/lib/fiddle/value.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-# frozen_string_literal: true
-require 'fiddle'
-
-module Fiddle
- module ValueUtil #:nodoc: all
- def unsigned_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("c").unpack1("C")
- when TYPE_SHORT
- [val].pack("s!").unpack1("S!")
- when TYPE_INT
- [val].pack("i!").unpack1("I!")
- when TYPE_LONG
- [val].pack("l!").unpack1("L!")
- else
- if defined?(TYPE_LONG_LONG) and
- ty.abs == TYPE_LONG_LONG
- [val].pack("q").unpack1("Q")
- else
- val
- end
- end
- end
-
- def signed_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("C").unpack1("c")
- when TYPE_SHORT
- [val].pack("S!").unpack1("s!")
- when TYPE_INT
- [val].pack("I!").unpack1("i!")
- when TYPE_LONG
- [val].pack("L!").unpack1("l!")
- else
- if defined?(TYPE_LONG_LONG) and
- ty.abs == TYPE_LONG_LONG
- [val].pack("Q").unpack1("q")
- else
- val
- end
- 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 nil
- return 0
- when Pointer
- return arg.to_i
- when IO
- case ty
- when TYPE_VOIDP
- return Pointer[arg].to_i
- else
- return arg.to_i
- end
- when Function
- if( block )
- arg.bind_at_call(&block)
- funcs.push(arg)
- elsif !arg.bound?
- raise(RuntimeError, "block must be given.")
- 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").unpack1("l!")
- else
- if defined?(SIZEOF_LONG_LONG) and
- SIZEOF_VOIDP == SIZEOF_LONG_LONG
- return [arg].pack("p").unpack1("q")
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- 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
- end
- return arg
- 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/fiddle/lib/fiddle/version.rb b/ext/fiddle/lib/fiddle/version.rb
deleted file mode 100644
index 706d98a7b5..0000000000
--- a/ext/fiddle/lib/fiddle/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Fiddle
- VERSION = "1.1.2"
-end
diff --git a/ext/fiddle/memory_view.c b/ext/fiddle/memory_view.c
deleted file mode 100644
index fa66fc2c7b..0000000000
--- a/ext/fiddle/memory_view.c
+++ /dev/null
@@ -1,321 +0,0 @@
-#include <fiddle.h>
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
-
-#include <stdbool.h>
-#include <ruby/ruby.h>
-#include <ruby/encoding.h>
-#include <ruby/memory_view.h>
-
-#if SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
-# define INTPTR2NUM LL2NUM
-# define UINTPTR2NUM ULL2NUM
-#elif SIZEOF_INTPTR_T == SIZEOF_LONG
-# define INTPTR2NUM LONG2NUM
-# define UINTPTR2NUM ULONG2NUM
-#else
-# define INTPTR2NUM INT2NUM
-# define UINTPTR2NUM UINT2NUM
-#endif
-
-VALUE rb_cMemoryView = Qnil;
-
-struct memview_data {
- rb_memory_view_t view;
- rb_memory_view_item_component_t *members;
- size_t n_members;
-};
-
-static void
-fiddle_memview_mark(void *ptr)
-{
- const struct memview_data *data = ptr;
- rb_gc_mark(data->view.obj);
-}
-
-static void
-fiddle_memview_release(struct memview_data *data)
-{
- if (NIL_P(data->view.obj)) return;
-
- rb_memory_view_release(&data->view);
- data->view.obj = Qnil;
- data->view.byte_size = 0;
- if (data->members) {
- xfree(data->members);
- data->members = NULL;
- data->n_members = 0;
- }
-}
-
-static void
-fiddle_memview_free(void *ptr)
-{
- struct memview_data *data = ptr;
- fiddle_memview_release(data);
- xfree(ptr);
-}
-
-static size_t
-fiddle_memview_memsize(const void *ptr)
-{
- const struct memview_data *data = ptr;
- return sizeof(*data) + sizeof(rb_memory_view_item_component_t)*data->n_members + (size_t)data->view.byte_size;
-}
-
-static const rb_data_type_t fiddle_memview_data_type = {
- "fiddle/memory_view",
- {fiddle_memview_mark, fiddle_memview_free, fiddle_memview_memsize,},
-};
-
-static VALUE
-rb_fiddle_memview_s_allocate(VALUE klass)
-{
- struct memview_data *data;
- VALUE obj = TypedData_Make_Struct(klass, struct memview_data, &fiddle_memview_data_type, data);
- data->view.obj = Qnil;
- data->view.byte_size = 0;
- data->members = NULL;
- data->n_members = 0;
- return obj;
-}
-
-static VALUE
-rb_fiddle_memview_release(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- fiddle_memview_release(data);
- return Qnil;
-}
-
-static VALUE
-rb_fiddle_memview_s_export(VALUE klass, VALUE target)
-{
- ID id_new;
- CONST_ID(id_new, "new");
- VALUE memview = rb_funcall(klass, id_new, 1, target);
- return rb_ensure(rb_yield, memview, rb_fiddle_memview_release, memview);
-}
-
-static VALUE
-rb_fiddle_memview_initialize(VALUE obj, VALUE target)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (!rb_memory_view_get(target, &data->view, 0)) {
- data->view.obj = Qnil;
- rb_raise(rb_eArgError, "Unable to get a memory view from %+"PRIsVALUE, target);
- }
-
- return Qnil;
-}
-
-static VALUE
-rb_fiddle_memview_get_obj(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- return data->view.obj;
-}
-
-static VALUE
-rb_fiddle_memview_get_byte_size(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- return SSIZET2NUM(data->view.byte_size);
-}
-
-static VALUE
-rb_fiddle_memview_get_readonly(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- return data->view.readonly ? Qtrue : Qfalse;
-}
-
-static VALUE
-rb_fiddle_memview_get_format(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- return data->view.format == NULL ? Qnil : rb_str_new_cstr(data->view.format);
-}
-
-static VALUE
-rb_fiddle_memview_get_item_size(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- return SSIZET2NUM(data->view.item_size);
-}
-
-static VALUE
-rb_fiddle_memview_get_ndim(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- return SSIZET2NUM(data->view.ndim);
-}
-
-static VALUE
-rb_fiddle_memview_get_shape(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- if (data->view.shape == NULL) return Qnil;
-
- const ssize_t ndim = data->view.ndim;
- VALUE shape = rb_ary_new_capa(ndim);
- ssize_t i;
- for (i = 0; i < ndim; ++i) {
- rb_ary_push(shape, SSIZET2NUM(data->view.shape[i]));
- }
- return shape;
-}
-
-static VALUE
-rb_fiddle_memview_get_strides(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- if (data->view.strides == NULL) return Qnil;
-
- const ssize_t ndim = data->view.ndim;
- VALUE strides = rb_ary_new_capa(ndim);
- ssize_t i;
- for (i = 0; i < ndim; ++i) {
- rb_ary_push(strides, SSIZET2NUM(data->view.strides[i]));
- }
- return strides;
-}
-
-static VALUE
-rb_fiddle_memview_get_sub_offsets(VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
- if (data->view.sub_offsets == NULL) return Qnil;
-
- const ssize_t ndim = data->view.ndim;
- VALUE sub_offsets = rb_ary_new_capa(ndim);
- ssize_t i;
- for (i = 0; i < ndim; ++i) {
- rb_ary_push(sub_offsets, SSIZET2NUM(data->view.sub_offsets[i]));
- }
- return sub_offsets;
-}
-
-static VALUE
-rb_fiddle_memview_aref(int argc, VALUE *argv, VALUE obj)
-{
- struct memview_data *data;
- TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data);
-
- if (NIL_P(data->view.obj)) return Qnil;
-
- const ssize_t ndim = data->view.ndim;
- if (argc != ndim) {
- rb_raise(rb_eIndexError, "wrong number of index (%d for %"PRIdSIZE")", argc, ndim);
- }
-
- VALUE indices_v = 0;
- ssize_t *indices = ALLOCV_N(ssize_t, indices_v, ndim);
-
- ssize_t i;
- for (i = 0; i < ndim; ++i) {
- ssize_t x = NUM2SSIZET(argv[i]);
- indices[i] = x;
- }
-
- uint8_t *ptr = rb_memory_view_get_item_pointer(&data->view, indices);
- ALLOCV_END(indices_v);
-
- if (data->view.format == NULL) {
- return INT2FIX(*ptr);
- }
-
- if (!data->members) {
- const char *err;
- if (rb_memory_view_parse_item_format(data->view.format, &data->members, &data->n_members, &err) < 0) {
- rb_raise(rb_eRuntimeError, "Unable to recognize item format at %"PRIdSIZE" in \"%s\"",
- err - data->view.format, data->view.format);
- }
- }
-
- return rb_memory_view_extract_item_members(ptr, data->members, data->n_members);
-}
-
-static VALUE
-rb_fiddle_memview_to_s(VALUE self)
-{
- struct memview_data *data;
- const char *raw_data;
- long byte_size;
- VALUE string;
-
- TypedData_Get_Struct(self,
- struct memview_data,
- &fiddle_memview_data_type,
- data);
-
- if (NIL_P(data->view.obj)) {
- raw_data = NULL;
- byte_size = 0;
- } else {
- raw_data = data->view.data;
- byte_size = data->view.byte_size;
- }
-
- string = rb_enc_str_new_static(raw_data, byte_size, rb_ascii8bit_encoding());
- {
- ID id_memory_view;
- CONST_ID(id_memory_view, "memory_view");
- rb_ivar_set(string, id_memory_view, self);
- }
- return rb_obj_freeze(string);
-}
-
-void
-Init_fiddle_memory_view(void)
-{
- rb_cMemoryView = rb_define_class_under(mFiddle, "MemoryView", rb_cObject);
- rb_define_alloc_func(rb_cMemoryView, rb_fiddle_memview_s_allocate);
- rb_define_singleton_method(rb_cMemoryView, "export", rb_fiddle_memview_s_export, 1);
- rb_define_method(rb_cMemoryView, "initialize", rb_fiddle_memview_initialize, 1);
- rb_define_method(rb_cMemoryView, "release", rb_fiddle_memview_release, 0);
- rb_define_method(rb_cMemoryView, "obj", rb_fiddle_memview_get_obj, 0);
- rb_define_method(rb_cMemoryView, "byte_size", rb_fiddle_memview_get_byte_size, 0);
- rb_define_method(rb_cMemoryView, "readonly?", rb_fiddle_memview_get_readonly, 0);
- rb_define_method(rb_cMemoryView, "format", rb_fiddle_memview_get_format, 0);
- rb_define_method(rb_cMemoryView, "item_size", rb_fiddle_memview_get_item_size, 0);
- rb_define_method(rb_cMemoryView, "ndim", rb_fiddle_memview_get_ndim, 0);
- rb_define_method(rb_cMemoryView, "shape", rb_fiddle_memview_get_shape, 0);
- rb_define_method(rb_cMemoryView, "strides", rb_fiddle_memview_get_strides, 0);
- rb_define_method(rb_cMemoryView, "sub_offsets", rb_fiddle_memview_get_sub_offsets, 0);
- rb_define_method(rb_cMemoryView, "[]", rb_fiddle_memview_aref, -1);
- rb_define_method(rb_cMemoryView, "to_s", rb_fiddle_memview_to_s, 0);
-}
-
-#endif /* HAVE_RUBY_MEMORY_VIEW_H */
diff --git a/ext/fiddle/pinned.c b/ext/fiddle/pinned.c
deleted file mode 100644
index 019a3020e2..0000000000
--- a/ext/fiddle/pinned.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include <fiddle.h>
-
-VALUE rb_cPinned;
-VALUE rb_eFiddleClearedReferenceError;
-
-struct pinned_data {
- VALUE ptr;
-};
-
-static void
-pinned_mark(void *ptr)
-{
- struct pinned_data *data = (struct pinned_data*)ptr;
- /* Ensure reference is pinned */
- if (data->ptr) {
- rb_gc_mark(data->ptr);
- }
-}
-
-static size_t
-pinned_memsize(const void *ptr)
-{
- return sizeof(struct pinned_data);
-}
-
-static const rb_data_type_t pinned_data_type = {
- "fiddle/pinned",
- {pinned_mark, xfree, pinned_memsize, },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
-};
-
-static VALUE
-allocate(VALUE klass)
-{
- struct pinned_data *data;
- VALUE obj = TypedData_Make_Struct(klass, struct pinned_data, &pinned_data_type, data);
- data->ptr = 0;
- return obj;
-}
-
-/*
- * call-seq:
- * Fiddle::Pinned.new(object) => pinned_object
- *
- * Create a new pinned object reference. The Fiddle::Pinned instance will
- * prevent the GC from moving +object+.
- */
-static VALUE
-initialize(VALUE self, VALUE ref)
-{
- struct pinned_data *data;
- TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
- RB_OBJ_WRITE(self, &data->ptr, ref);
- return self;
-}
-
-/*
- * call-seq: ref
- *
- * Return the object that this pinned instance references.
- */
-static VALUE
-ref(VALUE self)
-{
- struct pinned_data *data;
- TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
- if (data->ptr) {
- return data->ptr;
- } else {
- rb_raise(rb_eFiddleClearedReferenceError, "`ref` called on a cleared object");
- }
-}
-
-/*
- * call-seq: clear
- *
- * Clear the reference to the object this is pinning.
- */
-static VALUE
-clear(VALUE self)
-{
- struct pinned_data *data;
- TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
- data->ptr = 0;
- return self;
-}
-
-/*
- * call-seq: cleared?
- *
- * Returns true if the reference has been cleared, otherwise returns false.
- */
-static VALUE
-cleared_p(VALUE self)
-{
- struct pinned_data *data;
- TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data);
- if (data->ptr) {
- return Qfalse;
- } else {
- return Qtrue;
- }
-}
-
-extern VALUE rb_eFiddleError;
-
-void
-Init_fiddle_pinned(void)
-{
- rb_cPinned = rb_define_class_under(mFiddle, "Pinned", rb_cObject);
- rb_define_alloc_func(rb_cPinned, allocate);
- rb_define_method(rb_cPinned, "initialize", initialize, 1);
- rb_define_method(rb_cPinned, "ref", ref, 0);
- rb_define_method(rb_cPinned, "clear", clear, 0);
- rb_define_method(rb_cPinned, "cleared?", cleared_p, 0);
-
- /*
- * Document-class: Fiddle::ClearedReferenceError
- *
- * Cleared reference exception
- */
- rb_eFiddleClearedReferenceError = rb_define_class_under(mFiddle, "ClearedReferenceError", rb_eFiddleError);
-}
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
deleted file mode 100644
index 15107e3862..0000000000
--- a/ext/fiddle/pointer.c
+++ /dev/null
@@ -1,853 +0,0 @@
-/* -*- C -*-
- * $Id$
- */
-
-#include <stdbool.h>
-#include <ruby/ruby.h>
-#include <ruby/io.h>
-
-#include <ctype.h>
-#include <fiddle.h>
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
-# include <ruby/memory_view.h>
-#endif
-
-#ifdef PRIsVALUE
-# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
-# define RB_OBJ_STRING(obj) (obj)
-#else
-# define PRIsVALUE "s"
-# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
-# define RB_OBJ_STRING(obj) StringValueCStr(obj)
-#endif
-
-VALUE rb_cPointer;
-
-typedef rb_fiddle_freefunc_t freefunc_t;
-
-struct ptr_data {
- void *ptr;
- long size;
- freefunc_t free;
- bool freed;
- VALUE wrap[2];
-};
-
-#define RPTR_DATA(obj) ((struct ptr_data *)(DATA_PTR(obj)))
-
-static inline freefunc_t
-get_freefunc(VALUE func, volatile VALUE *wrap)
-{
- VALUE addrnum;
- if (NIL_P(func)) {
- *wrap = 0;
- return NULL;
- }
- addrnum = rb_Integer(func);
- *wrap = (addrnum != func) ? func : 0;
- return (freefunc_t)(VALUE)NUM2PTR(addrnum);
-}
-
-static ID id_to_ptr;
-
-static void
-fiddle_ptr_mark(void *ptr)
-{
- struct ptr_data *data = ptr;
- if (data->wrap[0]) {
- rb_gc_mark(data->wrap[0]);
- }
- if (data->wrap[1]) {
- rb_gc_mark(data->wrap[1]);
- }
-}
-
-static void
-fiddle_ptr_free_ptr(void *ptr)
-{
- struct ptr_data *data = ptr;
- if (data->ptr && data->free && !data->freed) {
- data->freed = true;
- (*(data->free))(data->ptr);
- }
-}
-
-static void
-fiddle_ptr_free(void *ptr)
-{
- fiddle_ptr_free_ptr(ptr);
- xfree(ptr);
-}
-
-static size_t
-fiddle_ptr_memsize(const void *ptr)
-{
- const struct ptr_data *data = ptr;
- return sizeof(*data) + data->size;
-}
-
-static const rb_data_type_t fiddle_ptr_data_type = {
- "fiddle/pointer",
- {fiddle_ptr_mark, fiddle_ptr_free, fiddle_ptr_memsize,},
-};
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
-static struct ptr_data *
-fiddle_ptr_check_memory_view(VALUE obj)
-{
- struct ptr_data *data;
- TypedData_Get_Struct(obj, struct ptr_data, &fiddle_ptr_data_type, data);
- if (data->ptr == NULL || data->size == 0) return NULL;
- return data;
-}
-
-static bool
-fiddle_ptr_memory_view_available_p(VALUE obj)
-{
- return fiddle_ptr_check_memory_view(obj) != NULL;
-}
-
-static bool
-fiddle_ptr_get_memory_view(VALUE obj, rb_memory_view_t *view, int flags)
-{
- struct ptr_data *data = fiddle_ptr_check_memory_view(obj);
- rb_memory_view_init_as_byte_array(view, obj, data->ptr, data->size, true);
-
- return true;
-}
-
-static const rb_memory_view_entry_t fiddle_ptr_memory_view_entry = {
- fiddle_ptr_get_memory_view,
- NULL,
- fiddle_ptr_memory_view_available_p
-};
-#endif
-
-static VALUE
-rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func, VALUE wrap0, VALUE wrap1)
-{
- struct ptr_data *data;
- VALUE val;
-
- val = TypedData_Make_Struct(klass, struct ptr_data, &fiddle_ptr_data_type, data);
- data->ptr = ptr;
- data->free = func;
- data->freed = false;
- data->size = size;
- data->wrap[0] = wrap0;
- data->wrap[1] = wrap1;
-
- return val;
-}
-
-VALUE
-rb_fiddle_ptr_new_wrap(void *ptr, long size, freefunc_t func, VALUE wrap0, VALUE wrap1)
-{
- return rb_fiddle_ptr_new2(rb_cPointer, ptr, size, func, wrap0, wrap1);
-}
-
-static VALUE
-rb_fiddle_ptr_new(void *ptr, long size, freefunc_t func)
-{
- return rb_fiddle_ptr_new2(rb_cPointer, ptr, size, func, 0, 0);
-}
-
-static VALUE
-rb_fiddle_ptr_malloc(VALUE klass, long size, freefunc_t func)
-{
- void *ptr;
-
- ptr = ruby_xmalloc((size_t)size);
- memset(ptr,0,(size_t)size);
- return rb_fiddle_ptr_new2(klass, ptr, size, func, 0, 0);
-}
-
-static void *
-rb_fiddle_ptr2cptr(VALUE val)
-{
- struct ptr_data *data;
- void *ptr;
-
- if (rb_obj_is_kind_of(val, rb_cPointer)) {
- TypedData_Get_Struct(val, struct ptr_data, &fiddle_ptr_data_type, data);
- ptr = data->ptr;
- }
- else if (val == Qnil) {
- ptr = NULL;
- }
- else{
- rb_raise(rb_eTypeError, "Fiddle::Pointer was expected");
- }
-
- return ptr;
-}
-
-static VALUE
-rb_fiddle_ptr_s_allocate(VALUE klass)
-{
- VALUE obj;
- struct ptr_data *data;
-
- obj = TypedData_Make_Struct(klass, struct ptr_data, &fiddle_ptr_data_type, data);
- data->ptr = 0;
- data->size = 0;
- data->free = 0;
- data->freed = false;
-
- return obj;
-}
-
-/*
- * call-seq:
- * Fiddle::Pointer.new(address) => fiddle_cptr
- * new(address, size) => fiddle_cptr
- * new(address, size, freefunc) => fiddle_cptr
- *
- * Create a new pointer to +address+ with an optional +size+ and +freefunc+.
- *
- * +freefunc+ will be called when the instance is garbage collected.
- */
-static VALUE
-rb_fiddle_ptr_initialize(int argc, VALUE argv[], VALUE self)
-{
- VALUE ptr, sym, size, wrap = 0, funcwrap = 0;
- struct ptr_data *data;
- void *p = NULL;
- freefunc_t f = NULL;
- long s = 0;
-
- if (rb_scan_args(argc, argv, "12", &ptr, &size, &sym) >= 1) {
- VALUE addrnum = rb_Integer(ptr);
- if (addrnum != ptr) wrap = ptr;
- p = NUM2PTR(addrnum);
- }
- if (argc >= 2) {
- s = NUM2LONG(size);
- }
- if (argc >= 3) {
- f = get_freefunc(sym, &funcwrap);
- }
-
- if (p) {
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- if (data->ptr && data->free) {
- /* Free previous memory. Use of inappropriate initialize may cause SEGV. */
- (*(data->free))(data->ptr);
- }
- data->wrap[0] = wrap;
- data->wrap[1] = funcwrap;
- data->ptr = p;
- data->size = s;
- data->free = f;
- }
-
- return Qnil;
-}
-
-static VALUE
-rb_fiddle_ptr_call_free(VALUE self);
-
-/*
- * call-seq:
- * Fiddle::Pointer.malloc(size, freefunc = nil) => fiddle pointer instance
- * Fiddle::Pointer.malloc(size, freefunc) { |pointer| ... } => ...
- *
- * == Examples
- *
- * # Automatically freeing the pointer when the block is exited - recommended
- * Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) do |pointer|
- * ...
- * end
- *
- * # Manually freeing but relying on the garbage collector otherwise
- * pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE)
- * ...
- * pointer.call_free
- *
- * # Relying on the garbage collector - may lead to unlimited memory allocated before freeing any, but safe
- * pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE)
- * ...
- *
- * # Only manually freeing
- * pointer = Fiddle::Pointer.malloc(size)
- * begin
- * ...
- * ensure
- * Fiddle.free pointer
- * end
- *
- * # No free function and no call to free - the native memory will leak if the pointer is garbage collected
- * pointer = Fiddle::Pointer.malloc(size)
- * ...
- *
- * Allocate +size+ bytes of memory and associate it with an optional
- * +freefunc+.
- *
- * If a block is supplied, the pointer will be yielded to the block instead of
- * being returned, and the return value of the block will be returned. A
- * +freefunc+ must be supplied if a block is.
- *
- * If a +freefunc+ is supplied it will be called once, when the pointer is
- * garbage collected or when the block is left if a block is supplied or
- * when the user calls +call_free+, whichever happens first. +freefunc+ must be
- * an address pointing to a function or an instance of +Fiddle::Function+.
- */
-static VALUE
-rb_fiddle_ptr_s_malloc(int argc, VALUE argv[], VALUE klass)
-{
- VALUE size, sym, obj, wrap = 0;
- long 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 = get_freefunc(sym, &wrap);
- break;
- default:
- rb_bug("rb_fiddle_ptr_s_malloc");
- }
-
- obj = rb_fiddle_ptr_malloc(klass, s,f);
- if (wrap) RPTR_DATA(obj)->wrap[1] = wrap;
-
- if (rb_block_given_p()) {
- if (!f) {
- rb_raise(rb_eArgError, "a free function must be supplied to Fiddle::Pointer.malloc when it is called with a block");
- }
- return rb_ensure(rb_yield, obj, rb_fiddle_ptr_call_free, obj);
- } else {
- return obj;
- }
-}
-
-/*
- * call-seq: to_i
- *
- * Returns the integer memory location of this pointer.
- */
-static VALUE
-rb_fiddle_ptr_to_i(VALUE self)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return PTR2NUM(data->ptr);
-}
-
-/*
- * call-seq: to_value
- *
- * Cast this pointer to a ruby object.
- */
-static VALUE
-rb_fiddle_ptr_to_value(VALUE self)
-{
- struct ptr_data *data;
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return (VALUE)(data->ptr);
-}
-
-/*
- * call-seq: ptr
- *
- * Returns a new Fiddle::Pointer instance that is a dereferenced pointer for
- * this pointer.
- *
- * Analogous to the star operator in C.
- */
-static VALUE
-rb_fiddle_ptr_ptr(VALUE self)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return rb_fiddle_ptr_new(*((void**)(data->ptr)),0,0);
-}
-
-/*
- * call-seq: ref
- *
- * Returns a new Fiddle::Pointer instance that is a reference pointer for this
- * pointer.
- *
- * Analogous to the ampersand operator in C.
- */
-static VALUE
-rb_fiddle_ptr_ref(VALUE self)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return rb_fiddle_ptr_new(&(data->ptr),0,0);
-}
-
-/*
- * call-seq: null?
- *
- * Returns +true+ if this is a null pointer.
- */
-static VALUE
-rb_fiddle_ptr_null_p(VALUE self)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return data->ptr ? Qfalse : Qtrue;
-}
-
-/*
- * call-seq: free=(function)
- *
- * Set the free function for this pointer to +function+ in the given
- * Fiddle::Function.
- */
-static VALUE
-rb_fiddle_ptr_free_set(VALUE self, VALUE val)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- data->free = get_freefunc(val, &data->wrap[1]);
-
- return Qnil;
-}
-
-/*
- * call-seq: free => Fiddle::Function
- *
- * Get the free function for this pointer.
- *
- * Returns a new instance of Fiddle::Function.
- *
- * See Fiddle::Function.new
- */
-static VALUE
-rb_fiddle_ptr_free_get(VALUE self)
-{
- struct ptr_data *pdata;
- VALUE address;
- VALUE arg_types;
- VALUE ret_type;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata);
-
- if (!pdata->free)
- return Qnil;
-
- address = PTR2NUM(pdata->free);
- ret_type = INT2NUM(TYPE_VOID);
- arg_types = rb_ary_new();
- rb_ary_push(arg_types, INT2NUM(TYPE_VOIDP));
-
- return rb_fiddle_new_function(address, arg_types, ret_type);
-}
-
-/*
- * call-seq: call_free => nil
- *
- * Call the free function for this pointer. Calling more than once will do
- * nothing. Does nothing if there is no free function attached.
- */
-static VALUE
-rb_fiddle_ptr_call_free(VALUE self)
-{
- struct ptr_data *pdata;
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata);
- fiddle_ptr_free_ptr(pdata);
- return Qnil;
-}
-
-/*
- * call-seq: freed? => bool
- *
- * Returns if the free function for this pointer has been called.
- */
-static VALUE
-rb_fiddle_ptr_freed_p(VALUE self)
-{
- struct ptr_data *pdata;
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata);
- return pdata->freed ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq:
- *
- * ptr.to_s => string
- * ptr.to_s(len) => string
- *
- * Returns the pointer contents as a string.
- *
- * When called with no arguments, this method will return the contents until
- * the first NULL byte.
- *
- * When called with +len+, a string of +len+ bytes will be returned.
- *
- * See to_str
- */
-static VALUE
-rb_fiddle_ptr_to_s(int argc, VALUE argv[], VALUE self)
-{
- struct ptr_data *data;
- VALUE arg1, val;
- int len;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- switch (rb_scan_args(argc, argv, "01", &arg1)) {
- case 0:
- val = rb_str_new2((char*)(data->ptr));
- break;
- case 1:
- len = NUM2INT(arg1);
- val = rb_str_new((char*)(data->ptr), len);
- break;
- default:
- rb_bug("rb_fiddle_ptr_to_s");
- }
-
- return val;
-}
-
-/*
- * call-seq:
- *
- * ptr.to_str => string
- * ptr.to_str(len) => string
- *
- * Returns the pointer contents as a string.
- *
- * When called with no arguments, this method will return the contents with the
- * length of this pointer's +size+.
- *
- * When called with +len+, a string of +len+ bytes will be returned.
- *
- * See to_s
- */
-static VALUE
-rb_fiddle_ptr_to_str(int argc, VALUE argv[], VALUE self)
-{
- struct ptr_data *data;
- VALUE arg1, val;
- int len;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- switch (rb_scan_args(argc, argv, "01", &arg1)) {
- case 0:
- val = rb_str_new((char*)(data->ptr),data->size);
- break;
- case 1:
- len = NUM2INT(arg1);
- val = rb_str_new((char*)(data->ptr), len);
- break;
- default:
- rb_bug("rb_fiddle_ptr_to_str");
- }
-
- return val;
-}
-
-/*
- * call-seq: inspect
- *
- * Returns a string formatted with an easily readable representation of the
- * internal state of the pointer.
- */
-static VALUE
-rb_fiddle_ptr_inspect(VALUE self)
-{
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
- RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free);
-}
-
-/*
- * call-seq:
- * ptr == other => true or false
- * ptr.eql?(other) => true or false
- *
- * Returns true if +other+ wraps the same pointer, otherwise returns
- * false.
- */
-static VALUE
-rb_fiddle_ptr_eql(VALUE self, VALUE other)
-{
- void *ptr1, *ptr2;
-
- if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qfalse;
-
- ptr1 = rb_fiddle_ptr2cptr(self);
- ptr2 = rb_fiddle_ptr2cptr(other);
-
- return ptr1 == ptr2 ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq:
- * ptr <=> other => -1, 0, 1, or nil
- *
- * Returns -1 if less than, 0 if equal to, 1 if greater than +other+.
- *
- * Returns nil if +ptr+ cannot be compared to +other+.
- */
-static VALUE
-rb_fiddle_ptr_cmp(VALUE self, VALUE other)
-{
- void *ptr1, *ptr2;
- SIGNED_VALUE diff;
-
- if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qnil;
-
- ptr1 = rb_fiddle_ptr2cptr(self);
- ptr2 = rb_fiddle_ptr2cptr(other);
- diff = (SIGNED_VALUE)ptr1 - (SIGNED_VALUE)ptr2;
- if (!diff) return INT2FIX(0);
- return diff > 0 ? INT2NUM(1) : INT2NUM(-1);
-}
-
-/*
- * call-seq:
- * ptr + n => new cptr
- *
- * Returns a new pointer instance that has been advanced +n+ bytes.
- */
-static VALUE
-rb_fiddle_ptr_plus(VALUE self, VALUE other)
-{
- void *ptr;
- long num, size;
-
- ptr = rb_fiddle_ptr2cptr(self);
- size = RPTR_DATA(self)->size;
- num = NUM2LONG(other);
- return rb_fiddle_ptr_new((char *)ptr + num, size - num, 0);
-}
-
-/*
- * call-seq:
- * ptr - n => new cptr
- *
- * Returns a new pointer instance that has been moved back +n+ bytes.
- */
-static VALUE
-rb_fiddle_ptr_minus(VALUE self, VALUE other)
-{
- void *ptr;
- long num, size;
-
- ptr = rb_fiddle_ptr2cptr(self);
- size = RPTR_DATA(self)->size;
- num = NUM2LONG(other);
- return rb_fiddle_ptr_new((char *)ptr - num, size + num, 0);
-}
-
-/*
- * call-seq:
- * ptr[index] -> an_integer
- * ptr[start, length] -> a_string
- *
- * Returns integer stored at _index_.
- *
- * If _start_ and _length_ are given, a string containing the bytes from
- * _start_ of _length_ will be returned.
- */
-static VALUE
-rb_fiddle_ptr_aref(int argc, VALUE argv[], VALUE self)
-{
- VALUE arg0, arg1;
- VALUE retval = Qnil;
- size_t offset, len;
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- if (!data->ptr) rb_raise(rb_eFiddleDLError, "NULL pointer dereference");
- switch( rb_scan_args(argc, argv, "11", &arg0, &arg1) ){
- case 1:
- offset = NUM2ULONG(arg0);
- retval = INT2NUM(*((char *)data->ptr + offset));
- break;
- case 2:
- offset = NUM2ULONG(arg0);
- len = NUM2ULONG(arg1);
- retval = rb_str_new((char *)data->ptr + offset, len);
- break;
- default:
- rb_bug("rb_fiddle_ptr_aref()");
- }
- return retval;
-}
-
-/*
- * call-seq:
- * ptr[index] = int -> int
- * ptr[start, length] = string or cptr or addr -> string or dl_cptr or addr
- *
- * Set the value at +index+ to +int+.
- *
- * Or, set the memory at +start+ until +length+ with the contents of +string+,
- * the memory from +dl_cptr+, or the memory pointed at by the memory address
- * +addr+.
- */
-static VALUE
-rb_fiddle_ptr_aset(int argc, VALUE argv[], VALUE self)
-{
- VALUE arg0, arg1, arg2;
- VALUE retval = Qnil;
- size_t offset, len;
- void *mem;
- struct ptr_data *data;
-
- TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
- if (!data->ptr) rb_raise(rb_eFiddleDLError, "NULL pointer dereference");
- switch( rb_scan_args(argc, argv, "21", &arg0, &arg1, &arg2) ){
- case 2:
- offset = NUM2ULONG(arg0);
- ((char*)data->ptr)[offset] = NUM2UINT(arg1);
- retval = arg1;
- break;
- case 3:
- offset = NUM2ULONG(arg0);
- len = NUM2ULONG(arg1);
- if (RB_TYPE_P(arg2, T_STRING)) {
- mem = StringValuePtr(arg2);
- }
- else if( rb_obj_is_kind_of(arg2, rb_cPointer) ){
- mem = rb_fiddle_ptr2cptr(arg2);
- }
- else{
- mem = NUM2PTR(arg2);
- }
- memcpy((char *)data->ptr + offset, mem, len);
- retval = arg2;
- break;
- default:
- rb_bug("rb_fiddle_ptr_aset()");
- }
- return retval;
-}
-
-/*
- * call-seq: size=(size)
- *
- * Set the size of this pointer to +size+
- */
-static VALUE
-rb_fiddle_ptr_size_set(VALUE self, VALUE size)
-{
- RPTR_DATA(self)->size = NUM2LONG(size);
- return size;
-}
-
-/*
- * call-seq: size
- *
- * Get the size of this pointer.
- */
-static VALUE
-rb_fiddle_ptr_size_get(VALUE self)
-{
- return LONG2NUM(RPTR_DATA(self)->size);
-}
-
-/*
- * call-seq:
- * Fiddle::Pointer[val] => cptr
- * to_ptr(val) => cptr
- *
- * Get the underlying pointer for ruby object +val+ and return it as a
- * Fiddle::Pointer object.
- */
-static VALUE
-rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
-{
- VALUE ptr, wrap = val, vptr;
-
- if (RTEST(rb_obj_is_kind_of(val, rb_cIO))){
- rb_io_t *fptr;
- FILE *fp;
- GetOpenFile(val, fptr);
- fp = rb_io_stdio_file(fptr);
- ptr = rb_fiddle_ptr_new(fp, 0, NULL);
- }
- else if (RTEST(rb_obj_is_kind_of(val, rb_cString))){
- char *str = StringValuePtr(val);
- wrap = val;
- ptr = rb_fiddle_ptr_new(str, RSTRING_LEN(val), NULL);
- }
- else if ((vptr = rb_check_funcall(val, id_to_ptr, 0, 0)) != Qundef){
- if (rb_obj_is_kind_of(vptr, rb_cPointer)){
- ptr = vptr;
- wrap = 0;
- }
- else{
- rb_raise(rb_eFiddleDLError, "to_ptr should return a Fiddle::Pointer object");
- }
- }
- else{
- VALUE num = rb_Integer(val);
- if (num == val) wrap = 0;
- ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL);
- }
- if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap;
- return ptr;
-}
-
-void
-Init_fiddle_pointer(void)
-{
-#undef rb_intern
- id_to_ptr = rb_intern("to_ptr");
-
- /* Document-class: Fiddle::Pointer
- *
- * Fiddle::Pointer is a class to handle C pointers
- *
- */
- rb_cPointer = rb_define_class_under(mFiddle, "Pointer", rb_cObject);
- rb_define_alloc_func(rb_cPointer, rb_fiddle_ptr_s_allocate);
- rb_define_singleton_method(rb_cPointer, "malloc", rb_fiddle_ptr_s_malloc, -1);
- rb_define_singleton_method(rb_cPointer, "to_ptr", rb_fiddle_ptr_s_to_ptr, 1);
- rb_define_singleton_method(rb_cPointer, "[]", rb_fiddle_ptr_s_to_ptr, 1);
- rb_define_method(rb_cPointer, "initialize", rb_fiddle_ptr_initialize, -1);
- rb_define_method(rb_cPointer, "free=", rb_fiddle_ptr_free_set, 1);
- rb_define_method(rb_cPointer, "free", rb_fiddle_ptr_free_get, 0);
- rb_define_method(rb_cPointer, "call_free", rb_fiddle_ptr_call_free, 0);
- rb_define_method(rb_cPointer, "freed?", rb_fiddle_ptr_freed_p, 0);
- rb_define_method(rb_cPointer, "to_i", rb_fiddle_ptr_to_i, 0);
- rb_define_method(rb_cPointer, "to_int", rb_fiddle_ptr_to_i, 0);
- rb_define_method(rb_cPointer, "to_value", rb_fiddle_ptr_to_value, 0);
- rb_define_method(rb_cPointer, "ptr", rb_fiddle_ptr_ptr, 0);
- rb_define_method(rb_cPointer, "+@", rb_fiddle_ptr_ptr, 0);
- rb_define_method(rb_cPointer, "ref", rb_fiddle_ptr_ref, 0);
- rb_define_method(rb_cPointer, "-@", rb_fiddle_ptr_ref, 0);
- rb_define_method(rb_cPointer, "null?", rb_fiddle_ptr_null_p, 0);
- rb_define_method(rb_cPointer, "to_s", rb_fiddle_ptr_to_s, -1);
- rb_define_method(rb_cPointer, "to_str", rb_fiddle_ptr_to_str, -1);
- rb_define_method(rb_cPointer, "inspect", rb_fiddle_ptr_inspect, 0);
- rb_define_method(rb_cPointer, "<=>", rb_fiddle_ptr_cmp, 1);
- rb_define_method(rb_cPointer, "==", rb_fiddle_ptr_eql, 1);
- rb_define_method(rb_cPointer, "eql?", rb_fiddle_ptr_eql, 1);
- rb_define_method(rb_cPointer, "+", rb_fiddle_ptr_plus, 1);
- rb_define_method(rb_cPointer, "-", rb_fiddle_ptr_minus, 1);
- rb_define_method(rb_cPointer, "[]", rb_fiddle_ptr_aref, -1);
- rb_define_method(rb_cPointer, "[]=", rb_fiddle_ptr_aset, -1);
- rb_define_method(rb_cPointer, "size", rb_fiddle_ptr_size_get, 0);
- rb_define_method(rb_cPointer, "size=", rb_fiddle_ptr_size_set, 1);
-
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
- rb_memory_view_register(rb_cPointer, &fiddle_ptr_memory_view_entry);
-#endif
-
- /* Document-const: NULL
- *
- * A NULL pointer
- */
- rb_define_const(mFiddle, "NULL", rb_fiddle_ptr_new(0, 0, 0));
-}
diff --git a/ext/fiddle/win32/fficonfig.h b/ext/fiddle/win32/fficonfig.h
deleted file mode 100644
index 776808159c..0000000000
--- a/ext/fiddle/win32/fficonfig.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#define HAVE_ALLOCA 1
-#define HAVE_MEMCPY 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
-#if _MSC_VER >= 1600
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#endif
-
-#define SIZEOF_DOUBLE 8
-#if defined(X86_WIN64)
-#define SIZEOF_SIZE_T 8
-#else
-#define SIZEOF_SIZE_T 4
-#endif
-
-#define STACK_DIRECTION -1
-
-#define STDC_HEADERS 1
-
-#ifdef LIBFFI_ASM
-#define FFI_HIDDEN(name)
-#else
-#define FFI_HIDDEN
-#endif
-
diff --git a/ext/fiddle/win32/libffi-3.2.1-mswin.patch b/ext/fiddle/win32/libffi-3.2.1-mswin.patch
deleted file mode 100644
index f9100e703d..0000000000
--- a/ext/fiddle/win32/libffi-3.2.1-mswin.patch
+++ /dev/null
@@ -1,191 +0,0 @@
-diff -ru libffi-3.2.1/src/x86/ffi.c libffi-3.2.1/src/x86/ffi.c
---- libffi-3.2.1/src/x86/ffi.c 2014-11-08 21:47:24.000000000 +0900
-+++ libffi-3.2.1/src/x86/ffi.c 2014-12-25 18:46:14.806761900 +0900
-@@ -99,11 +99,13 @@
- i != 0;
- i--, p_arg += dir, p_argv += dir)
- {
-+ size_t z;
-+
- /* Align if necessary */
- if ((sizeof(void*) - 1) & (size_t) argp)
- argp = (char *) ALIGN(argp, sizeof(void*));
-
-- size_t z = (*p_arg)->size;
-+ z = (*p_arg)->size;
-
- #ifdef X86_WIN64
- if (z > FFI_SIZEOF_ARG
-@@ -202,6 +204,7 @@
- on top of stack, so that those can be moved to registers by call-handler. */
- if (stack_args_count > 0)
- {
-+ int i;
- if (dir < 0 && stack_args_count > 1)
- {
- /* Reverse order if iterating arguments backwards */
-@@ -210,7 +213,6 @@
- *(ffi_arg*) p_stack_data[stack_args_count - 1] = tmp;
- }
-
-- int i;
- for (i = 0; i < stack_args_count; i++)
- {
- if (p_stack_data[i] != argp2)
-@@ -569,11 +571,12 @@
- i < cif->nargs && passed_regs < max_stack_count;
- i++, p_arg++)
- {
-+ size_t sz;
- if ((*p_arg)->type == FFI_TYPE_FLOAT
- || (*p_arg)->type == FFI_TYPE_STRUCT)
- continue;
-
-- size_t sz = (*p_arg)->size;
-+ sz = (*p_arg)->size;
- if(sz == 0 || sz > FFI_SIZEOF_ARG)
- continue;
-
-@@ -599,11 +602,13 @@
- i != 0;
- i--, p_arg += dir, p_argv += dir)
- {
-+ size_t z;
-+
- /* Align if necessary */
- if ((sizeof(void*) - 1) & (size_t) argp)
- argp = (char *) ALIGN(argp, sizeof(void*));
-
-- size_t z = (*p_arg)->size;
-+ z = (*p_arg)->size;
-
- #ifdef X86_WIN64
- if (z > FFI_SIZEOF_ARG
-@@ -642,7 +647,7 @@
- #endif
- }
-
-- return (size_t)argp - (size_t)stack;
-+ return (int)((size_t)argp - (size_t)stack);
- }
-
- #define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
-@@ -855,11 +860,12 @@
-
- for (i = 0; i < cif->nargs && passed_regs <= max_regs; i++)
- {
-+ size_t sz;
- if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
- || cif->arg_types[i]->type == FFI_TYPE_STRUCT)
- continue;
-
-- size_t sz = cif->arg_types[i]->size;
-+ sz = cif->arg_types[i]->size;
- if (sz == 0 || sz > FFI_SIZEOF_ARG)
- continue;
-
-diff -ru libffi-3.2.1/src/x86/ffitarget.h libffi-3.2.1/src/x86/ffitarget.h
---- libffi-3.2.1/src/x86/ffitarget.h 2014-11-08 21:47:24.000000000 +0900
-+++ libffi-3.2.1/src/x86/ffitarget.h 2014-12-22 15:45:54.000000000 +0900
-@@ -50,7 +50,9 @@
- #endif
-
- #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
-+#ifndef _MSC_VER
- #define FFI_TARGET_HAS_COMPLEX_TYPE
-+#endif
-
- /* ---- Generic type definitions ----------------------------------------- */
-
-diff -ru libffi-3.2.1/src/x86/win64.S libffi-3.2.1/src/x86/win64.S
---- libffi-3.2.1/src/x86/win64.S 2014-11-08 21:47:24.000000000 +0900
-+++ libffi-3.2.1/src/x86/win64.S 2014-12-22 16:14:40.000000000 +0900
-@@ -127,7 +127,7 @@
-
- mov rcx, QWORD PTR RVALUE[rbp]
- mov DWORD PTR [rcx], eax
-- jmp ret_void$
-+ jmp SHORT ret_void$
-
- ret_struct2b$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
-@@ -135,7 +135,7 @@
-
- mov rcx, QWORD PTR RVALUE[rbp]
- mov WORD PTR [rcx], ax
-- jmp ret_void$
-+ jmp SHORT ret_void$
-
- ret_struct1b$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
-@@ -143,7 +143,7 @@
-
- mov rcx, QWORD PTR RVALUE[rbp]
- mov BYTE PTR [rcx], al
-- jmp ret_void$
-+ jmp SHORT ret_void$
-
- ret_uint8$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
-@@ -152,7 +152,7 @@
- mov rcx, QWORD PTR RVALUE[rbp]
- movzx rax, al
- mov QWORD PTR [rcx], rax
-- jmp ret_void$
-+ jmp SHORT ret_void$
-
- ret_sint8$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
-@@ -161,7 +161,7 @@
- mov rcx, QWORD PTR RVALUE[rbp]
- movsx rax, al
- mov QWORD PTR [rcx], rax
-- jmp ret_void$
-+ jmp SHORT ret_void$
-
- ret_uint16$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
-@@ -188,7 +188,13 @@
- mov rcx, QWORD PTR RVALUE[rbp]
- mov eax, eax
- mov QWORD PTR [rcx], rax
-- jmp SHORT ret_void$
-+
-+ret_void$:
-+ xor rax, rax
-+
-+ lea rsp, QWORD PTR [rbp+16]
-+ pop rbp
-+ ret 0
-
- ret_sint32$:
- cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
-@@ -247,13 +253,6 @@
- cdqe
- mov QWORD PTR [rcx], rax
- jmp SHORT ret_void$
--
--ret_void$:
-- xor rax, rax
--
-- lea rsp, QWORD PTR [rbp+16]
-- pop rbp
-- ret 0
- ffi_call_win64 ENDP
- _TEXT ENDS
- END
-diff -ru libffi-3.2.1/include/ffi.h.in libffi-3.2.1/include/ffi.h.in
---- libffi-3.2.1/include/ffi.h.in 2014-11-08 21:47:24.000000000 +0900
-+++ libffi-3.2.1/include/ffi.h.in 2015-01-11 12:35:30.000000000 +0900
-@@ -103,6 +103,11 @@
- # undef FFI_64_BIT_MAX
- # define FFI_64_BIT_MAX 9223372036854775807LL
- # endif
-+# ifdef _MSC_VER
-+# define FFI_LONG_LONG_MAX _I64_MAX
-+# undef FFI_64_BIT_MAX
-+# define FFI_64_BIT_MAX 9223372036854775807I64
-+# endif
- # endif
- #endif
-
diff --git a/ext/fiddle/win32/libffi-config.rb b/ext/fiddle/win32/libffi-config.rb
deleted file mode 100755
index 8e8069a943..0000000000
--- a/ext/fiddle/win32/libffi-config.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/ruby
-# frozen_string_literal: true
-require 'fileutils'
-
-basedir = File.dirname(__FILE__)
-conf = {}
-enable = {}
-until ARGV.empty?
- arg = ARGV.shift
- case arg
- when '-C'
- # ignore
- when /\A--srcdir=(.*)/
- conf['SRCDIR'] = srcdir = $1
- when /\A(CC|CFLAGS|CXX|CXXFLAGS|LD|LDFLAGS)=(.*)/
- conf[$1] = $2
- when /\A--host=(.*)/
- host = $1
- when /\A--enable-([^=]+)(?:=(.*))?/
- enable[$1] = $2 || true
- when /\A--disable-([^=]+)/
- enable[$1] = false
- end
-end
-
-File.foreach("#{srcdir}/configure.ac") do |line|
- if /^AC_INIT\((.*)\)/ =~ line
- version = $1.split(/,\s*/)[1]
- version.gsub!(/\A\[|\]\z/, '')
- conf['VERSION'] = version
- break
- end
-end
-
-builddir = srcdir == "." ? (enable['builddir'] || ".") : "."
-conf['TARGET'] = /^x64/ =~ host ? "X86_WIN64" : "X86_WIN32"
-
-FileUtils.mkdir_p([builddir, "#{builddir}/include", "#{builddir}/src/x86"])
-FileUtils.cp("#{basedir}/fficonfig.h", ".", preserve: true)
-
-hdr = File.binread("#{srcdir}/include/ffi.h.in")
-hdr.gsub!(/@(\w+)@/) {conf[$1] || $&}
-hdr.gsub!(/^(#if\s+)@\w+@/, '\10')
-File.binwrite("#{builddir}/include/ffi.h", hdr)
-
-mk = File.binread("#{basedir}/libffi.mk.tmpl")
-mk.gsub!(/@(\w+)@/) {conf[$1] || $&}
-File.binwrite("Makefile", mk)
diff --git a/ext/fiddle/win32/libffi.mk.tmpl b/ext/fiddle/win32/libffi.mk.tmpl
deleted file mode 100644
index 2a16e8efec..0000000000
--- a/ext/fiddle/win32/libffi.mk.tmpl
+++ /dev/null
@@ -1,96 +0,0 @@
-# -*- makefile -*-
-# ====================================================================
-#
-# libffi Windows Makefile
-#
-#
-# ====================================================================
-#
-NAME = ffi
-TARGET = @TARGET@
-CC = cl
-!if "$(TARGET)" == "X86_WIN64"
-AS = ml64
-!else
-AS = ml
-!endif
-AR = link
-DLEXT = dll
-OBJEXT = obj
-LIBEXT = lib
-TOPDIR = @SRCDIR@
-CPP = $(CC) -EP
-CFLAGS = @CFLAGS@
-ARFLAGS = -lib
-ASFLAGS = -coff -W3 -Cx
-INCLUDES= -I. -I./include -I./src/x86 \
- -I$(TOPDIR)/include -I$(TOPDIR)/include/src/x86
-
-SRCDIR = $(TOPDIR)/src
-WORKDIR = ./.libs
-BUILDDIR= ./src
-LIBNAME = lib$(NAME)
-STATICLIB= $(WORKDIR)/$(LIBNAME)_convenience.$(LIBEXT)
-
-HEADERS = \
- ./fficonfig.h
-FFI_HEADERS = \
- ./include/ffi.h \
- ./include/ffitarget.h
-
-!if "$(TARGET)" == "X86_WIN32"
-OSSRC = win32
-!else if "$(TARGET)" == "X86_WIN64"
-OSSRC = win64
-!else
-! error unknown target: $(TARGET)
-!endif
-
-OBJECTS = \
- $(BUILDDIR)/closures.$(OBJEXT) \
- $(BUILDDIR)/debug.$(OBJEXT) \
- $(BUILDDIR)/java_raw_api.$(OBJEXT) \
- $(BUILDDIR)/prep_cif.$(OBJEXT) \
- $(BUILDDIR)/raw_api.$(OBJEXT) \
- $(BUILDDIR)/types.$(OBJEXT) \
- $(BUILDDIR)/x86/ffi.$(OBJEXT) \
- $(BUILDDIR)/x86/$(OSSRC).$(OBJEXT)
-ASMSRCS = \
- $(BUILDDIR)/x86/$(OSSRC).asm
-
-.SUFFIXES : .S .asm
-
-all: $(WORKDIR) $(STATICLIB)
-
-{$(SRCDIR)}.c{$(BUILDDIR)}.$(OBJEXT):
- $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)
-
-{$(SRCDIR)/x86}.c{$(BUILDDIR)/x86}.$(OBJEXT):
- $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)
-
-{$(SRCDIR)/x86}.S{$(BUILDDIR)/x86}.asm:
- $(CPP) $(CFLAGS) $(INCLUDES) $(<:\=/) >$(@:\=/)
-
-{$(BUILDDIR)/x86}.asm{$(BUILDDIR)/x86}.$(OBJEXT):
- cd $(@D) && $(AS) -c $(ASFLAGS) -Fo $(@F) $(<F)
-
-$(BUILDDIR)/x86/$(OSSRC).asm: $(SRCDIR)/x86/$(OSSRC).S
-
-$(OBJECTS): $(FFI_HEADERS) $(HEADERS)
-
-$(WORKDIR):
- -@if not exist "$(WORKDIR:/=\)\$(NULL)" mkdir $(WORKDIR:/=\)
-
-$(STATICLIB): $(WORKDIR) $(OBJECTS)
- $(AR) $(ARFLAGS) -out:$(STATICLIB) @<<
- $(OBJECTS)
-<<
-
-clean:
- -@del /Q $(OBJECTS:/=\) 2>NUL
- -@del /Q $(ASMSRCS:/=\) 2>NUL
- -@del /Q /S $(WORKDIR:/=\) 2>NUL
-
-distclean: clean
- -@del /Q $(HEADERS:/=\) $(FFI_HEADERS:/=\) 2>NUL
- -@del /Q Makefile 2>NUL
diff --git a/ext/io/console/.document b/ext/io/console/.document
new file mode 100644
index 0000000000..945a377256
--- /dev/null
+++ b/ext/io/console/.document
@@ -0,0 +1,2 @@
+console.c
+lib/size.rb
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 21454a73fa..5f3c9478f7 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -2,6 +2,10 @@
/*
* console IO module
*/
+
+static const char *const
+IO_CONSOLE_VERSION = "0.8.2";
+
#include "ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"
@@ -75,9 +79,14 @@ getattr(int fd, conmode *t)
#define SET_LAST_ERROR (0)
#endif
-static ID id_getc, id_console, id_close;
-#if ENABLE_IO_GETPASS
-static ID id_gets, id_chomp_bang;
+#define CSI "\x1b\x5b"
+
+static ID id_getc, id_close;
+static ID id_gets, id_flush, id_chomp_bang;
+
+#ifndef HAVE_RB_INTERNED_STR_CSTR
+# define rb_str_to_interned_str(str) rb_str_freeze(str)
+# define rb_interned_str_cstr(str) rb_str_freeze(rb_usascii_str_new_cstr(str))
#endif
#if defined HAVE_RUBY_FIBER_SCHEDULER_H
@@ -87,7 +96,48 @@ extern VALUE rb_scheduler_timeout(struct timeval *timeout);
# define rb_fiber_scheduler_make_timeout rb_scheduler_timeout
#endif
-#define sys_fail_fptr(fptr) rb_sys_fail_str((fptr)->pathv)
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
+#ifndef HAVE_RB_IO_PATH
+static VALUE
+io_path_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->pathv;
+}
+#define rb_io_path io_path_fallback
+#endif
+
+#ifndef HAVE_RB_IO_GET_WRITE_IO
+static VALUE
+io_get_write_io_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ VALUE wio = fptr->tied_io_for_writing;
+ return wio ? wio : io;
+}
+#define rb_io_get_write_io io_get_write_io_fallback
+#endif
+
+#ifndef DHAVE_RB_SYSERR_FAIL_STR
+# define rb_syserr_fail_str(e, mesg) rb_exc_raise(rb_syserr_new_str(e, mesg))
+#endif
+
+#define sys_fail(io) do { \
+ int err = errno; \
+ rb_syserr_fail_str(err, rb_io_path(io)); \
+} while (0)
#ifndef HAVE_RB_F_SEND
#ifndef RB_PASS_CALLED_KEYWORDS
@@ -293,33 +343,21 @@ set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
return setattr(fd, &r);
}
-#define GetReadFD(fptr) ((fptr)->fd)
-
-static inline int
-get_write_fd(const rb_io_t *fptr)
-{
- VALUE wio = fptr->tied_io_for_writing;
- rb_io_t *ofptr;
- if (!wio) return fptr->fd;
- GetOpenFile(wio, ofptr);
- return ofptr->fd;
-}
-#define GetWriteFD(fptr) get_write_fd(fptr)
+#define GetReadFD(io) rb_io_descriptor(io)
+#define GetWriteFD(io) rb_io_descriptor(rb_io_get_write_io(io))
#define FD_PER_IO 2
static VALUE
ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
{
- rb_io_t *fptr;
int status = -1;
int error = 0;
int fd[FD_PER_IO];
conmode t[FD_PER_IO];
VALUE result = Qnil;
- GetOpenFile(io, fptr);
- fd[0] = GetReadFD(fptr);
+ fd[0] = GetReadFD(io);
if (fd[0] != -1) {
if (set_ttymode(fd[0], t+0, setter, arg)) {
status = 0;
@@ -329,7 +367,7 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
fd[0] = -1;
}
}
- fd[1] = GetWriteFD(fptr);
+ fd[1] = GetWriteFD(io);
if (fd[1] != -1 && fd[1] != fd[0]) {
if (set_ttymode(fd[1], t+1, setter, arg)) {
status = 0;
@@ -342,14 +380,13 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
if (status == 0) {
result = rb_protect(func, farg, &status);
}
- GetOpenFile(io, fptr);
- if (fd[0] != -1 && fd[0] == GetReadFD(fptr)) {
+ if (fd[0] != -1 && fd[0] == GetReadFD(io)) {
if (!setattr(fd[0], t+0)) {
error = errno;
status = -1;
}
}
- if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(fptr)) {
+ if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(io)) {
if (!setattr(fd[1], t+1)) {
error = errno;
status = -1;
@@ -435,15 +472,11 @@ static VALUE
console_set_raw(int argc, VALUE *argv, VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (!getattr(fd, &t)) sys_fail(io);
set_rawmode(&t, optp);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!setattr(fd, &t)) sys_fail(io);
return io;
}
@@ -479,14 +512,10 @@ static VALUE
console_set_cooked(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (!getattr(fd, &t)) sys_fail(io);
set_cookedmode(&t, NULL);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!setattr(fd, &t)) sys_fail(io);
return io;
}
@@ -638,17 +667,17 @@ static VALUE
console_set_echo(VALUE io, VALUE f)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
+
+ if (!getattr(fd, &t)) sys_fail(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
if (RTEST(f))
- set_echo(&t, NULL);
+ set_echo(&t, NULL);
else
- set_noecho(&t, NULL);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ set_noecho(&t, NULL);
+
+ if (!setattr(fd, &t)) sys_fail(io);
+
return io;
}
@@ -664,12 +693,9 @@ static VALUE
console_echo_p(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!getattr(fd, &t)) sys_fail(io);
return echo_p(&t) ? Qtrue : Qfalse;
}
@@ -748,12 +774,9 @@ static VALUE
console_conmode_get(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!getattr(fd, &t)) sys_fail(io);
return conmode_new(cConmode, &t);
}
@@ -770,14 +793,12 @@ static VALUE
console_conmode_set(VALUE io, VALUE mode)
{
conmode *t, r;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
TypedData_Get_Struct(mode, conmode, &conmode_type, t);
r = *t;
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!setattr(fd, &r)) sys_fail_fptr(fptr);
+
+ if (!setattr(fd, &r)) sys_fail(io);
return mode;
}
@@ -813,16 +834,15 @@ typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t;
static VALUE
console_winsize(VALUE io)
{
- rb_io_t *fptr;
- int fd;
rb_console_size_t ws;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- if (!getwinsize(fd, &ws)) sys_fail_fptr(fptr);
+ int fd = GetWriteFD(io);
+ if (!getwinsize(fd, &ws)) sys_fail(io);
return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws)));
}
+static VALUE console_scroll(VALUE io, int line);
+static VALUE console_goto(VALUE io, VALUE y, VALUE x);
+
/*
* call-seq:
* io.winsize = [rows, columns]
@@ -835,29 +855,26 @@ console_winsize(VALUE io)
static VALUE
console_set_winsize(VALUE io, VALUE size)
{
- rb_io_t *fptr;
rb_console_size_t ws;
#if defined _WIN32
HANDLE wh;
int newrow, newcol;
- BOOL ret;
+ COORD oldsize;
+ SMALL_RECT oldwindow;
#endif
VALUE row, col, xpixel, ypixel;
const VALUE *sz;
- int fd;
long sizelen;
+ int fd;
- GetOpenFile(io, fptr);
size = rb_Array(size);
if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) {
- rb_raise(rb_eArgError,
- "wrong number of arguments (given %ld, expected 2 or 4)",
- sizelen);
+ rb_raise(rb_eArgError, "wrong number of arguments (given %ld, expected 2 or 4)", sizelen);
}
sz = RARRAY_CONST_PTR(size);
row = sz[0], col = sz[1], xpixel = ypixel = Qnil;
if (sizelen == 4) xpixel = sz[2], ypixel = sz[3];
- fd = GetWriteFD(fptr);
+ fd = GetWriteFD(io);
#if defined TIOCSWINSZ
ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
#define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
@@ -866,7 +883,7 @@ console_set_winsize(VALUE io, VALUE size)
SET(xpixel);
SET(ypixel);
#undef SET
- if (!setwinsize(fd, &ws)) sys_fail_fptr(fptr);
+ if (!setwinsize(fd, &ws)) sys_fail(io);
#elif defined _WIN32
wh = (HANDLE)rb_w32_get_osfhandle(fd);
#define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
@@ -878,18 +895,62 @@ console_set_winsize(VALUE io, VALUE size)
if (!GetConsoleScreenBufferInfo(wh, &ws)) {
rb_syserr_fail(LAST_ERROR, "GetConsoleScreenBufferInfo");
}
+ oldsize = ws.dwSize;
+ oldwindow = ws.srWindow;
+ if (ws.srWindow.Right + 1 < newcol) {
+ ws.dwSize.X = newcol;
+ }
+ if (ws.dwSize.Y < newrow) {
+ ws.dwSize.Y = newrow;
+ }
+ /* expand screen buffer first if needed */
+ if (!SetConsoleScreenBufferSize(wh, ws.dwSize)) {
+ rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo");
+ }
+ /* refresh ws for new dwMaximumWindowSize */
+ if (!GetConsoleScreenBufferInfo(wh, &ws)) {
+ rb_syserr_fail(LAST_ERROR, "GetConsoleScreenBufferInfo");
+ }
+ /* check new size before modifying buffer content */
+ if (newrow <= 0 || newcol <= 0 ||
+ newrow > ws.dwMaximumWindowSize.Y ||
+ newcol > ws.dwMaximumWindowSize.X) {
+ SetConsoleScreenBufferSize(wh, oldsize);
+ /* remove scrollbar if possible */
+ SetConsoleWindowInfo(wh, TRUE, &oldwindow);
+ rb_raise(rb_eArgError, "out of range winsize: [%d, %d]", newrow, newcol);
+ }
+ /* shrink screen buffer width */
ws.dwSize.X = newcol;
- ret = SetConsoleScreenBufferSize(wh, ws.dwSize);
+ /* shrink screen buffer height if window height were the same */
+ if (oldsize.Y == ws.srWindow.Bottom - ws.srWindow.Top + 1) {
+ ws.dwSize.Y = newrow;
+ }
ws.srWindow.Left = 0;
- ws.srWindow.Top = 0;
- ws.srWindow.Right = newcol-1;
- ws.srWindow.Bottom = newrow-1;
+ ws.srWindow.Right = newcol - 1;
+ ws.srWindow.Bottom = ws.srWindow.Top + newrow -1;
+ if (ws.dwCursorPosition.Y > ws.srWindow.Bottom) {
+ console_scroll(io, ws.dwCursorPosition.Y - ws.srWindow.Bottom);
+ ws.dwCursorPosition.Y = ws.srWindow.Bottom;
+ console_goto(io, INT2FIX(ws.dwCursorPosition.Y), INT2FIX(ws.dwCursorPosition.X));
+ }
+ if (ws.srWindow.Bottom > ws.dwSize.Y - 1) {
+ console_scroll(io, ws.srWindow.Bottom - (ws.dwSize.Y - 1));
+ ws.dwCursorPosition.Y -= ws.srWindow.Bottom - (ws.dwSize.Y - 1);
+ console_goto(io, INT2FIX(ws.dwCursorPosition.Y), INT2FIX(ws.dwCursorPosition.X));
+ ws.srWindow.Bottom = ws.dwSize.Y - 1;
+ }
+ ws.srWindow.Top = ws.srWindow.Bottom - (newrow - 1);
+ /* perform changes to winsize */
if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) {
- rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo");
+ int last_error = LAST_ERROR;
+ SetConsoleScreenBufferSize(wh, oldsize);
+ rb_syserr_fail(last_error, "SetConsoleWindowInfo");
}
- /* retry when shrinking buffer after shrunk window */
- if (!ret && !SetConsoleScreenBufferSize(wh, ws.dwSize)) {
- rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo");
+ /* perform screen buffer shrinking if necessary */
+ if ((ws.dwSize.Y < oldsize.Y || ws.dwSize.X < oldsize.X) &&
+ !SetConsoleScreenBufferSize(wh, ws.dwSize)) {
+ rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo");
}
/* remove scrollbar if possible */
if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) {
@@ -901,15 +962,23 @@ console_set_winsize(VALUE io, VALUE size)
#endif
#ifdef _WIN32
+/*
+ * call-seq:
+ * io.check_winsize_changed { ... } -> io
+ *
+ * Yields while console input events are queued.
+ *
+ * This method is Windows only.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_check_winsize_changed(VALUE io)
{
- rb_io_t *fptr;
HANDLE h;
DWORD num;
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr));
+ h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(io));
while (GetNumberOfConsoleInputEvents(h, &num) && num > 0) {
INPUT_RECORD rec;
if (ReadConsoleInput(h, &rec, 1, &num)) {
@@ -935,15 +1004,11 @@ console_check_winsize_changed(VALUE io)
static VALUE
console_iflush(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- if (tcflush(fd, TCIFLUSH)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (tcflush(fd, TCIFLUSH)) sys_fail(io);
#endif
- (void)fd;
+
return io;
}
@@ -958,13 +1023,9 @@ console_iflush(VALUE io)
static VALUE
console_oflush(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
+ int fd = GetWriteFD(io);
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- if (tcflush(fd, TCOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd, TCOFLUSH)) sys_fail(io);
#endif
(void)fd;
return io;
@@ -981,40 +1042,38 @@ console_oflush(VALUE io)
static VALUE
console_ioflush(VALUE io)
{
- rb_io_t *fptr;
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- int fd1, fd2;
-#endif
+ int fd1 = GetReadFD(io);
+ int fd2 = GetWriteFD(io);
- GetOpenFile(io, fptr);
-#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- fd1 = GetReadFD(fptr);
- fd2 = GetWriteFD(fptr);
if (fd2 != -1 && fd1 != fd2) {
- if (tcflush(fd1, TCIFLUSH)) sys_fail_fptr(fptr);
- if (tcflush(fd2, TCOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd1, TCIFLUSH)) sys_fail(io);
+ if (tcflush(fd2, TCOFLUSH)) sys_fail(io);
}
else {
- if (tcflush(fd1, TCIOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd1, TCIOFLUSH)) sys_fail(io);
}
#endif
+
return io;
}
+/*
+ * call-seq:
+ * io.beep
+ *
+ * Beeps on the output console.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_beep(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
#ifdef _WIN32
- (void)fd;
MessageBeep(0);
#else
- if (write(fd, "\a", 1) < 0)
- sys_fail_fptr(fptr);
+ int fd = GetWriteFD(io);
+ if (write(fd, "\a", 1) < 0) sys_fail(io);
#endif
return io;
}
@@ -1035,79 +1094,6 @@ mode_in_range(VALUE val, int high, const char *modename)
}
#if defined _WIN32
-static VALUE
-console_goto(VALUE io, VALUE y, VALUE x)
-{
- rb_io_t *fptr;
- int fd;
- COORD pos;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- pos.X = NUM2UINT(x);
- pos.Y = NUM2UINT(y);
- if (!SetConsoleCursorPosition((HANDLE)rb_w32_get_osfhandle(fd), pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static VALUE
-console_cursor_pos(VALUE io)
-{
- rb_io_t *fptr;
- int fd;
- rb_console_size_t ws;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y), UINT2NUM(ws.dwCursorPosition.X));
-}
-
-static VALUE
-console_move(VALUE io, int y, int x)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X += x;
- pos->Y += y;
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static VALUE
-console_goto_column(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X = NUM2INT(val);
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
static void
constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
{
@@ -1118,86 +1104,12 @@ constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
}
static VALUE
-console_erase_line(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 2, "line erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* after cursor */
- w -= pos->X;
- break;
- case 1: /* before *and* cursor */
- w = pos->X + 1;
- pos->X = 0;
- break;
- case 2: /* entire line */
- pos->X = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
-console_erase_screen(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 3, "screen erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* erase after cursor */
- w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
- break;
- case 1: /* erase before *and* cursor */
- w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 2: /* erase entire screen */
- w = (w * winsize_row(&ws));
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 3: /* erase entire screen */
- w = (w * ws.dwSize.Y);
- pos->X = 0;
- pos->Y = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
console_scroll(VALUE io, int line)
{
- rb_io_t *fptr;
HANDLE h;
rb_console_size_t ws;
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
if (!GetConsoleScreenBufferInfo(h, &ws)) {
rb_syserr_fail(LAST_ERROR, 0);
}
@@ -1219,8 +1131,22 @@ console_scroll(VALUE io, int line)
return io;
}
+#define GPERF_DOWNCASE 1
+#define GPERF_CASE_STRCMP 1
+#define gperf_case_strcmp STRCASECMP
#include "win32_vk.inc"
+/*
+ * call-seq:
+ * io.pressed?(key) -> bool
+ *
+ * Returns +true+ if +key+ is pressed. +key+ may be a virtual key
+ * code or its name (String or Symbol) with out "VK_" prefix.
+ *
+ * This method is Windows only.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_key_pressed_p(VALUE io, VALUE k)
{
@@ -1256,23 +1182,11 @@ static int
direct_query(VALUE io, const struct query_args *query)
{
if (RB_TYPE_P(io, T_FILE)) {
- rb_io_t *fptr;
- VALUE wio;
- GetOpenFile(io, fptr);
- wio = fptr->tied_io_for_writing;
- if (wio) {
- VALUE s = rb_str_new_cstr(query->qstr);
- rb_io_write(wio, s);
- rb_io_flush(wio);
- return 1;
- }
- if (write(fptr->fd, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
- if (fptr->fd == 0 &&
- write(1, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
+ VALUE wio = rb_io_get_write_io(io);
+ VALUE s = rb_str_new_cstr(query->qstr);
+ rb_io_write(wio, s);
+ rb_io_flush(wio);
+ return 1;
}
return 0;
}
@@ -1323,8 +1237,40 @@ console_vt_response(int argc, VALUE *argv, VALUE io, const struct query_args *qa
}
static VALUE
+console_scroll(VALUE io, int line)
+{
+ if (line) {
+ VALUE s = rb_sprintf(CSI "%d%c", line < 0 ? -line : line,
+ line < 0 ? 'T' : 'S');
+ rb_io_write(io, s);
+ }
+ return io;
+}
+
+# define console_key_pressed_p rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * io.cursor -> [row, column]
+ *
+ * Returns the current cursor position as a two-element array of integers (row, column)
+ *
+ * io.cursor # => [3, 5]
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
console_cursor_pos(VALUE io)
{
+#ifdef _WIN32
+ rb_console_size_t ws;
+ int fd = GetWriteFD(io);
+ if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y - ws.srWindow.Top), UINT2NUM(ws.dwCursorPosition.X));
+#else
static const struct query_args query = {"\033[6n", 0};
VALUE resp = console_vt_response(0, 0, io, &query);
VALUE row, column, term;
@@ -1341,64 +1287,211 @@ console_cursor_pos(VALUE io)
RARRAY_ASET(resp, 0, INT2NUM(r));
RARRAY_ASET(resp, 1, INT2NUM(c));
return resp;
+#endif
}
+/*
+ * call-seq:
+ * io.goto(line, column) -> io
+ *
+ * Set the cursor position at +line+ and +column+.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_goto(VALUE io, VALUE y, VALUE x)
{
- rb_io_write(io, rb_sprintf("\x1b[%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1));
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ pos->X = NUM2UINT(x);
+ pos->Y = ws.srWindow.Top + NUM2UINT(y);
+ if (!SetConsoleCursorPosition(h, *pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
+ rb_io_write(io, rb_sprintf(CSI "%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1));
+#endif
return io;
}
static VALUE
console_move(VALUE io, int y, int x)
{
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ pos->X += x;
+ pos->Y += y;
+ if (!SetConsoleCursorPosition(h, *pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
if (x || y) {
VALUE s = rb_str_new_cstr("");
- if (y) rb_str_catf(s, "\x1b[%d%c", y < 0 ? -y : y, y < 0 ? 'A' : 'B');
- if (x) rb_str_catf(s, "\x1b[%d%c", x < 0 ? -x : x, x < 0 ? 'D' : 'C');
+ if (y) rb_str_catf(s, CSI "%d%c", y < 0 ? -y : y, y < 0 ? 'A' : 'B');
+ if (x) rb_str_catf(s, CSI "%d%c", x < 0 ? -x : x, x < 0 ? 'D' : 'C');
rb_io_write(io, s);
rb_io_flush(io);
}
+#endif
return io;
}
+/*
+ * call-seq:
+ * io.goto_column(column) -> io
+ *
+ * Set the cursor position at +column+ in the same line of the current
+ * position.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_goto_column(VALUE io, VALUE val)
{
- rb_io_write(io, rb_sprintf("\x1b[%dG", NUM2UINT(val)+1));
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ pos->X = NUM2INT(val);
+ if (!SetConsoleCursorPosition(h, *pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
+ rb_io_write(io, rb_sprintf(CSI "%dG", NUM2UINT(val)+1));
+#endif
return io;
}
+/*
+ * call-seq:
+ * io.erase_line(mode) -> io
+ *
+ * Erases the line at the cursor corresponding to +mode+.
+ * +mode+ may be either:
+ * 0: after cursor
+ * 1: before and cursor
+ * 2: entire line
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_erase_line(VALUE io, VALUE val)
{
int mode = mode_in_range(val, 2, "line erase");
- rb_io_write(io, rb_sprintf("\x1b[%dK", mode));
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+ DWORD w;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ w = winsize_col(&ws);
+ switch (mode) {
+ case 0: /* after cursor */
+ w -= pos->X;
+ break;
+ case 1: /* before *and* cursor */
+ w = pos->X + 1;
+ pos->X = 0;
+ break;
+ case 2: /* entire line */
+ pos->X = 0;
+ break;
+ }
+ constat_clear(h, ws.wAttributes, w, *pos);
+ return io;
+#else
+ rb_io_write(io, rb_sprintf(CSI "%dK", mode));
+#endif
return io;
}
+/*
+ * call-seq:
+ * io.erase_screen(mode) -> io
+ *
+ * Erases the screen at the cursor corresponding to +mode+.
+ * +mode+ may be either:
+ * 0: after cursor
+ * 1: before and cursor
+ * 2: entire screen
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_erase_screen(VALUE io, VALUE val)
{
int mode = mode_in_range(val, 3, "screen erase");
- rb_io_write(io, rb_sprintf("\x1b[%dJ", mode));
- return io;
-}
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+ DWORD w;
-static VALUE
-console_scroll(VALUE io, int line)
-{
- if (line) {
- VALUE s = rb_sprintf("\x1b[%d%c", line < 0 ? -line : line,
- line < 0 ? 'T' : 'S');
- rb_io_write(io, s);
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
}
+ w = winsize_col(&ws);
+ switch (mode) {
+ case 0: /* erase after cursor */
+ w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
+ break;
+ case 1: /* erase before *and* cursor */
+ w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
+ pos->X = 0;
+ pos->Y = ws.srWindow.Top;
+ break;
+ case 2: /* erase entire screen */
+ w = (w * winsize_row(&ws));
+ pos->X = 0;
+ pos->Y = ws.srWindow.Top;
+ break;
+ case 3: /* erase entire screen */
+ w = (w * ws.dwSize.Y);
+ pos->X = 0;
+ pos->Y = 0;
+ break;
+ }
+ constat_clear(h, ws.wAttributes, w, *pos);
+#else
+ rb_io_write(io, rb_sprintf(CSI "%dJ", mode));
+#endif
return io;
}
-# define console_key_pressed_p rb_f_notimplement
-#endif
+/*
+ * call-seq:
+ * io.cursor = [line, column] -> io
+ *
+ * Same as <tt>io.goto(line, column)</tt>
+ *
+ * See IO#goto.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_cursor_set(VALUE io, VALUE cpos)
{
@@ -1407,42 +1500,98 @@ console_cursor_set(VALUE io, VALUE cpos)
return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
}
+/*
+ * call-seq:
+ * io.cursor_up(n) -> io
+ *
+ * Moves the cursor up +n+ lines.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_cursor_up(VALUE io, VALUE val)
{
return console_move(io, -NUM2INT(val), 0);
}
+/*
+ * call-seq:
+ * io.cursor_down(n) -> io
+ *
+ * Moves the cursor down +n+ lines.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_cursor_down(VALUE io, VALUE val)
{
return console_move(io, +NUM2INT(val), 0);
}
+/*
+ * call-seq:
+ * io.cursor_left(n) -> io
+ *
+ * Moves the cursor left +n+ columns.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_cursor_left(VALUE io, VALUE val)
{
return console_move(io, 0, -NUM2INT(val));
}
+/*
+ * call-seq:
+ * io.cursor_right(n) -> io
+ *
+ * Moves the cursor right +n+ columns.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_cursor_right(VALUE io, VALUE val)
{
return console_move(io, 0, +NUM2INT(val));
}
+/*
+ * call-seq:
+ * io.scroll_forward(n) -> io
+ *
+ * Scrolls the entire scrolls forward +n+ lines.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_scroll_forward(VALUE io, VALUE val)
{
return console_scroll(io, +NUM2INT(val));
}
+/*
+ * call-seq:
+ * io.scroll_backward(n) -> io
+ *
+ * Scrolls the entire scrolls backward +n+ lines.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_scroll_backward(VALUE io, VALUE val)
{
return console_scroll(io, -NUM2INT(val));
}
+/*
+ * call-seq:
+ * io.clear_screen -> io
+ *
+ * Clears the entire screen and moves the cursor top-left corner.
+ *
+ * You must require 'io/console' to use this method.
+ */
static VALUE
console_clear_screen(VALUE io)
{
@@ -1451,6 +1600,92 @@ console_clear_screen(VALUE io)
return io;
}
+#ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
+static VALUE
+io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding)
+{
+ VALUE arguments[2] = {
+ (rb_update_max_fd(descriptor), INT2NUM(descriptor)),
+ INT2FIX(mode),
+ };
+
+ VALUE self = rb_class_new_instance(2, arguments, klass);
+
+ rb_io_t *fptr;
+ GetOpenFile(self, fptr);
+ fptr->pathv = path;
+ fptr->mode |= mode;
+
+ return self;
+}
+#define rb_io_open_descriptor io_open_descriptor_fallback
+#endif
+
+#ifndef HAVE_RB_IO_CLOSED_P
+static VALUE
+rb_io_closed_p(VALUE io)
+{
+ rb_io_t *fptr = RFILE(io)->fptr;
+ return fptr->fd == -1 ? Qtrue : Qfalse;
+}
+#endif
+
+#if defined(RB_EXT_RACTOR_SAFE) && defined(HAVE_RB_RACTOR_LOCAL_STORAGE_VALUE_NEWKEY)
+# define USE_RACTOR_STORAGE 1
+#else
+# define USE_RACTOR_STORAGE 0
+#endif
+
+#if USE_RACTOR_STORAGE
+#include "ruby/ractor.h"
+static rb_ractor_local_key_t key_console_dev;
+
+static bool
+console_dev_get(VALUE klass, VALUE *dev)
+{
+ return rb_ractor_local_storage_value_lookup(key_console_dev, dev);
+}
+
+static void
+console_dev_set(VALUE klass, VALUE value)
+{
+ rb_ractor_local_storage_value_set(key_console_dev, value);
+}
+
+static void
+console_dev_remove(VALUE klass)
+{
+ console_dev_set(klass, Qnil);
+}
+
+#else
+
+static ID id_console;
+
+static int
+console_dev_get(VALUE klass, VALUE *dev)
+{
+ if (rb_const_defined(klass, id_console)) {
+ *dev = rb_const_get(klass, id_console);
+ return 1;
+ }
+ return 0;
+}
+
+static void
+console_dev_set(VALUE klass, VALUE value)
+{
+ rb_const_set(klass, id_console, value);
+}
+
+static void
+console_dev_remove(VALUE klass)
+{
+ rb_const_remove(klass, id_console);
+}
+
+#endif
+
/*
* call-seq:
* IO.console -> #<File:/dev/tty>
@@ -1468,34 +1703,34 @@ static VALUE
console_dev(int argc, VALUE *argv, VALUE klass)
{
VALUE con = 0;
- rb_io_t *fptr;
VALUE sym = 0;
- rb_check_arity(argc, 0, UNLIMITED_ARGUMENTS);
if (argc) {
- Check_Type(sym = argv[0], T_SYMBOL);
+ Check_Type(sym = argv[0], T_SYMBOL);
}
+
+ /* Force the class to be File. */
if (klass == rb_cIO) klass = rb_cFile;
- if (rb_const_defined(klass, id_console)) {
- con = rb_const_get(klass, id_console);
- if (!RB_TYPE_P(con, T_FILE) ||
- (!(fptr = RFILE(con)->fptr) || GetReadFD(fptr) == -1)) {
- rb_const_remove(klass, id_console);
- con = 0;
- }
+
+ if (console_dev_get(klass, &con)) {
+ if (!RB_TYPE_P(con, T_FILE) || RTEST(rb_io_closed_p(con))) {
+ console_dev_remove(klass);
+ con = 0;
+ }
}
+
if (sym) {
- if (sym == ID2SYM(id_close) && argc == 1) {
- if (con) {
- rb_io_close(con);
- rb_const_remove(klass, id_console);
- con = 0;
- }
- return Qnil;
- }
+ if (sym == ID2SYM(id_close) && argc == 1) {
+ if (con) {
+ rb_io_close(con);
+ console_dev_remove(klass);
+ con = 0;
+ }
+ return Qnil;
+ }
}
+
if (!con) {
- VALUE args[2];
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H || defined HAVE_SGTTY_H
# define CONSOLE_DEVICE "/dev/tty"
#elif defined _WIN32
@@ -1507,44 +1742,35 @@ console_dev(int argc, VALUE *argv, VALUE klass)
# define CONSOLE_DEVICE_FOR_READING CONSOLE_DEVICE
#endif
#ifdef CONSOLE_DEVICE_FOR_WRITING
- VALUE out;
- rb_io_t *ofptr;
+ VALUE out;
#endif
- int fd;
+ int fd;
+ VALUE path = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
#ifdef CONSOLE_DEVICE_FOR_WRITING
- fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
- if (fd < 0) return Qnil;
- rb_update_max_fd(fd);
- args[1] = INT2FIX(O_WRONLY);
- args[0] = INT2NUM(fd);
- out = rb_class_new_instance(2, args, klass);
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
+ if (fd < 0) return Qnil;
+ out = rb_io_open_descriptor(klass, fd, FMODE_WRITABLE | FMODE_SYNC, path, Qnil, NULL);
#endif
- fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
- if (fd < 0) {
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
+ if (fd < 0) {
#ifdef CONSOLE_DEVICE_FOR_WRITING
- rb_io_close(out);
+ rb_io_close(out);
#endif
- return Qnil;
- }
- rb_update_max_fd(fd);
- args[1] = INT2FIX(O_RDWR);
- args[0] = INT2NUM(fd);
- con = rb_class_new_instance(2, args, klass);
- GetOpenFile(con, fptr);
- fptr->pathv = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
+ return Qnil;
+ }
+
+ con = rb_io_open_descriptor(klass, fd, FMODE_READWRITE | FMODE_SYNC, path, Qnil, NULL);
#ifdef CONSOLE_DEVICE_FOR_WRITING
- GetOpenFile(out, ofptr);
- ofptr->pathv = fptr->pathv;
- fptr->tied_io_for_writing = out;
- ofptr->mode |= FMODE_SYNC;
+ rb_io_set_write_io(con, out);
#endif
- fptr->mode |= FMODE_SYNC;
- rb_const_set(klass, id_console, con);
+ console_dev_set(klass, con);
}
+
if (sym) {
- return rb_f_send(argc, argv, con);
+ return rb_f_send(argc, argv, con);
}
+
return con;
}
@@ -1560,7 +1786,6 @@ io_getch(int argc, VALUE *argv, VALUE io)
return rb_funcallv(io, id_getc, argc, argv);
}
-#if ENABLE_IO_GETPASS
static VALUE
puts_call(VALUE io)
{
@@ -1568,6 +1793,12 @@ puts_call(VALUE io)
}
static VALUE
+gets_call(VALUE io)
+{
+ return rb_funcallv(io, id_gets, 0, 0);
+}
+
+static VALUE
getpass_call(VALUE io)
{
return ttymode(io, rb_io_gets, io, set_noecho, NULL);
@@ -1587,7 +1818,8 @@ static VALUE
str_chomp(VALUE str)
{
if (!NIL_P(str)) {
- rb_funcallv(str, id_chomp_bang, 0, 0);
+ const VALUE rs = rb_default_rs; /* rvalue in TruffleRuby */
+ rb_funcallv(str, id_chomp_bang, 1, &rs);
}
return str;
}
@@ -1604,6 +1836,12 @@ str_chomp(VALUE str)
* see String#chomp!.
*
* You must require 'io/console' to use this method.
+ *
+ * require 'io/console'
+ * IO::console.getpass("Enter password:")
+ * Enter password:
+ * # => "mypassword"
+ *
*/
static VALUE
console_getpass(int argc, VALUE *argv, VALUE io)
@@ -1614,6 +1852,7 @@ console_getpass(int argc, VALUE *argv, VALUE io)
wio = rb_io_get_write_io(io);
if (wio == io && io == rb_stdin) wio = rb_stderr;
prompt(argc, argv, wio);
+ rb_io_flush(wio);
str = rb_ensure(getpass_call, io, puts_call, wio);
return str_chomp(str);
}
@@ -1631,10 +1870,64 @@ io_getpass(int argc, VALUE *argv, VALUE io)
rb_check_arity(argc, 0, 1);
prompt(argc, argv, io);
- str = str_chomp(rb_funcallv(io, id_gets, 0, 0));
- puts_call(io);
- return str;
+ rb_check_funcall(io, id_flush, 0, 0);
+ str = rb_ensure(gets_call, io, puts_call, io);
+ return str_chomp(str);
}
+
+#if defined(_WIN32) || defined(HAVE_TTYNAME_R) || defined(HAVE_TTYNAME)
+/*
+ * call-seq:
+ * io.ttyname -> string or nil
+ *
+ * Returns name of associated terminal (tty) if +io+ is not a tty.
+ * Returns +nil+ otherwise.
+ */
+static VALUE
+console_ttyname(VALUE io)
+{
+ int fd = rb_io_descriptor(io);
+ if (!isatty(fd)) return Qnil;
+# if defined _WIN32
+ return rb_usascii_str_new_lit("con");
+# elif defined HAVE_TTYNAME_R
+ {
+ char termname[1024], *tn = termname;
+ size_t size = sizeof(termname);
+ int e;
+ if (ttyname_r(fd, tn, size) == 0)
+ return rb_interned_str_cstr(tn);
+ if ((e = errno) == ERANGE) {
+ VALUE s = rb_str_new(0, size);
+ while (1) {
+ tn = RSTRING_PTR(s);
+ size = rb_str_capacity(s);
+ if (ttyname_r(fd, tn, size) == 0) {
+ return rb_str_to_interned_str(rb_str_resize(s, strlen(tn)));
+ }
+ if ((e = errno) != ERANGE) break;
+ if ((size *= 2) >= INT_MAX/2) break;
+ rb_str_resize(s, size);
+ }
+ }
+ rb_syserr_fail_str(e, rb_sprintf("ttyname_r(%d)", fd));
+ UNREACHABLE_RETURN(Qnil);
+ }
+# elif defined HAVE_TTYNAME
+ {
+ const char *tn = ttyname(fd);
+ if (!tn) {
+ int e = errno;
+ rb_syserr_fail_str(e, rb_sprintf("ttyname(%d)", fd));
+ }
+ return rb_interned_str_cstr(tn);
+ }
+# else
+# error No ttyname function
+# endif
+}
+#else
+# define console_ttyname rb_f_notimplement
#endif
/*
@@ -1643,13 +1936,20 @@ io_getpass(int argc, VALUE *argv, VALUE io)
void
Init_console(void)
{
+#if USE_RACTOR_STORAGE
+ RB_EXT_RACTOR_SAFE(true);
+#endif
+
#undef rb_intern
+#if USE_RACTOR_STORAGE
+ key_console_dev = rb_ractor_local_storage_value_newkey();
+#else
+ id_console = rb_intern("console");
+#endif
id_getc = rb_intern("getc");
-#if ENABLE_IO_GETPASS
id_gets = rb_intern("gets");
+ id_flush = rb_intern("flush");
id_chomp_bang = rb_intern("chomp!");
-#endif
- id_console = rb_intern("console");
id_close = rb_intern("close");
#define init_rawmode_opt_id(name) \
rawmode_opt_ids[kwd_##name] = rb_intern(#name)
@@ -1696,26 +1996,24 @@ InitVM_console(void)
rb_define_method(rb_cIO, "clear_screen", console_clear_screen, 0);
rb_define_method(rb_cIO, "pressed?", console_key_pressed_p, 1);
rb_define_method(rb_cIO, "check_winsize_changed", console_check_winsize_changed, 0);
-#if ENABLE_IO_GETPASS
rb_define_method(rb_cIO, "getpass", console_getpass, -1);
-#endif
+ rb_define_method(rb_cIO, "ttyname", console_ttyname, 0);
rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
{
+ /* :nodoc: */
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
rb_define_method(mReadable, "getch", io_getch, -1);
-#if ENABLE_IO_GETPASS
rb_define_method(mReadable, "getpass", io_getpass, -1);
-#endif
}
{
- /* :stopdoc: */
+ /* :nodoc: */
cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject);
+ rb_define_const(cConmode, "VERSION", rb_obj_freeze(rb_str_new_cstr(IO_CONSOLE_VERSION)));
rb_define_alloc_func(cConmode, conmode_alloc);
rb_undef_method(cConmode, "initialize");
rb_define_method(cConmode, "initialize_copy", conmode_init_copy, 1);
rb_define_method(cConmode, "echo=", conmode_set_echo, 1);
rb_define_method(cConmode, "raw!", conmode_set_raw, -1);
rb_define_method(cConmode, "raw", conmode_raw_new, -1);
- /* :startdoc: */
}
}
diff --git a/ext/io/console/depend b/ext/io/console/depend
index 59ca3442c2..150a138d4d 100644
--- a/ext/io/console/depend
+++ b/ext/io/console/depend
@@ -139,6 +139,7 @@ console.o: $(hdrdir)/ruby/internal/intern/re.h
console.o: $(hdrdir)/ruby/internal/intern/ruby.h
console.o: $(hdrdir)/ruby/internal/intern/select.h
console.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+console.o: $(hdrdir)/ruby/internal/intern/set.h
console.o: $(hdrdir)/ruby/internal/intern/signal.h
console.o: $(hdrdir)/ruby/internal/intern/sprintf.h
console.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -158,6 +159,7 @@ console.o: $(hdrdir)/ruby/internal/special_consts.h
console.o: $(hdrdir)/ruby/internal/static_assert.h
console.o: $(hdrdir)/ruby/internal/stdalign.h
console.o: $(hdrdir)/ruby/internal/stdbool.h
+console.o: $(hdrdir)/ruby/internal/stdckdint.h
console.o: $(hdrdir)/ruby/internal/symbol.h
console.o: $(hdrdir)/ruby/internal/value.h
console.o: $(hdrdir)/ruby/internal/value_type.h
@@ -168,6 +170,7 @@ console.o: $(hdrdir)/ruby/io.h
console.o: $(hdrdir)/ruby/missing.h
console.o: $(hdrdir)/ruby/onigmo.h
console.o: $(hdrdir)/ruby/oniguruma.h
+console.o: $(hdrdir)/ruby/ractor.h
console.o: $(hdrdir)/ruby/ruby.h
console.o: $(hdrdir)/ruby/st.h
console.o: $(hdrdir)/ruby/subst.h
@@ -184,7 +187,7 @@ win32_vk.inc: win32_vk.list
-e 'n=$$F[1] and (n.strip!; /\AVK_/=~n) and' \
-e 'puts(%[#ifndef #{n}\n# define #{n} UNDEFINED_VK\n#endif])' \
$< && \
- gperf --ignore-case -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* $< \
+ gperf --ignore-case -L ANSI-C -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* $< \
| sed -f $(top_srcdir)/tool/gperf.sed \
) > $(@F)
diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb
index e8c5923b18..dd3d221ae5 100644
--- a/ext/io/console/extconf.rb
+++ b/ext/io/console/extconf.rb
@@ -1,7 +1,30 @@
# frozen_string_literal: false
require 'mkmf'
-ok = true if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
+# `--target-rbconfig` compatibility for Ruby 3.3 or earlier
+# See https://bugs.ruby-lang.org/issues/20345
+MakeMakefile::RbConfig ||= ::RbConfig
+
+have_func("rb_syserr_fail_str(0, Qnil)") or
+have_func("rb_syserr_new_str(0, Qnil)") or
+ abort
+
+have_func("rb_interned_str_cstr")
+have_func("rb_io_path", "ruby/io.h")
+have_func("rb_io_descriptor", "ruby/io.h")
+have_func("rb_io_get_write_io", "ruby/io.h")
+have_func("rb_io_closed_p", "ruby/io.h")
+have_func("rb_io_open_descriptor", "ruby/io.h")
+have_func("rb_ractor_local_storage_value_newkey")
+
+is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"]
+# `ok` can be `true`, `false`, or `nil`:
+# * `true` : Required headers and functions available, proceed regular build.
+# * `false`: Required headers or functions not available, abort build.
+# * `nil` : Unsupported compilation target, generate dummy Makefile.
+#
+# Skip building io/console on WASI, as it does not support termios.h.
+ok = true if (RUBY_ENGINE == "ruby" && !is_wasi) || RUBY_ENGINE == "truffleruby"
hdr = nil
case
when macro_defined?("_WIN32", "")
@@ -29,7 +52,7 @@ when true
elsif have_func("rb_scheduler_timeout") # 3.0
have_func("rb_io_wait")
end
- $defs << "-D""ENABLE_IO_GETPASS=1"
+ have_func("ttyname_r") or have_func("ttyname")
create_makefile("io/console") {|conf|
conf << "\n""VK_HEADER = #{vk_header}\n"
}
diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec
index d26a757b01..0a19992734 100644
--- a/ext/io/console/io-console.gemspec
+++ b/ext/io/console/io-console.gemspec
@@ -1,5 +1,13 @@
# -*- ruby -*-
-_VERSION = "0.6.0"
+_VERSION = ["", "ext/io/console/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}console.c")) {|f|
+ f.gets("\nIO_CONSOLE_VERSION ")
+ f.gets[/"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
+end
Gem::Specification.new do |s|
s.name = "io-console"
@@ -10,10 +18,13 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.6.0"
s.homepage = "https://github.com/ruby/io-console"
s.metadata["source_code_url"] = s.homepage
+ s.metadata["changelog_uri"] = s.homepage + "/releases"
s.authors = ["Nobu Nakada"]
s.require_path = %[lib]
s.files = %w[
- LICENSE.txt
+ .document
+ BSDL
+ COPYING
README.md
ext/io/console/console.c
ext/io/console/extconf.rb
@@ -25,15 +36,16 @@ Gem::Specification.new do |s|
if Gem::Platform === s.platform and s.platform =~ 'java'
s.files.delete_if {|f| f.start_with?("ext/")}
s.extensions.clear
+ s.require_paths.unshift('lib/ffi')
s.files.concat(%w[
- lib/io/console.rb
- lib/io/console/ffi/bsd_console.rb
- lib/io/console/ffi/common.rb
- lib/io/console/ffi/console.rb
- lib/io/console/ffi/linux_console.rb
- lib/io/console/ffi/native_console.rb
- lib/io/console/ffi/stty_console.rb
- lib/io/console/ffi/stub_console.rb
+ lib/ffi/io/console.rb
+ lib/ffi/io/console/bsd_console.rb
+ lib/ffi/io/console/common.rb
+ lib/ffi/io/console/linux_console.rb
+ lib/ffi/io/console/native_console.rb
+ lib/ffi/io/console/stty_console.rb
+ lib/ffi/io/console/stub_console.rb
+ lib/ffi/io/console/version.rb
])
end
diff --git a/ext/io/console/win32_vk.inc b/ext/io/console/win32_vk.inc
index cbec7bef15..348e6be5ed 100644
--- a/ext/io/console/win32_vk.inc
+++ b/ext/io/console/win32_vk.inc
@@ -480,7 +480,7 @@
# define VK_OEM_CLEAR UNDEFINED_VK
#endif
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf --ignore-case -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k'*' win32_vk.list */
+/* Command-line: gperf --ignore-case -L ANSI-C -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k'*' win32_vk.list */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -509,11 +509,10 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
-#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "win32_vk.list"
struct vktable {short ofs; unsigned short vk;};
-static const struct vktable *console_win32_vk(/*const char *, unsigned int*/);
+static const struct vktable *console_win32_vk(const char *, size_t);
#line 5 "win32_vk.list"
struct vktable;
/* maximum key range = 245, duplicates = 0 */
@@ -1007,368 +1006,368 @@ console_win32_vk (register const char *str, register size_t len)
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1},
#line 40 "win32_vk.list"
- {gperf_offsetof(stringpool, 12), VK_UP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, VK_UP},
#line 52 "win32_vk.list"
- {gperf_offsetof(stringpool, 13), VK_APPS},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, VK_APPS},
#line 159 "win32_vk.list"
- {gperf_offsetof(stringpool, 14), VK_CRSEL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, VK_CRSEL},
#line 34 "win32_vk.list"
- {gperf_offsetof(stringpool, 15), VK_SPACE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, VK_SPACE},
#line 95 "win32_vk.list"
- {gperf_offsetof(stringpool, 16), VK_SCROLL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, VK_SCROLL},
#line 29 "win32_vk.list"
- {gperf_offsetof(stringpool, 17), VK_ESCAPE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, VK_ESCAPE},
#line 9 "win32_vk.list"
- {gperf_offsetof(stringpool, 18), VK_CANCEL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, VK_CANCEL},
#line 32 "win32_vk.list"
- {gperf_offsetof(stringpool, 19), VK_ACCEPT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, VK_ACCEPT},
#line 66 "win32_vk.list"
- {gperf_offsetof(stringpool, 20), VK_SEPARATOR},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, VK_SEPARATOR},
#line 43 "win32_vk.list"
- {gperf_offsetof(stringpool, 21), VK_SELECT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, VK_SELECT},
#line 18 "win32_vk.list"
- {gperf_offsetof(stringpool, 22), VK_CONTROL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, VK_CONTROL},
#line 166 "win32_vk.list"
- {gperf_offsetof(stringpool, 23), VK_OEM_CLEAR},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, VK_OEM_CLEAR},
#line 145 "win32_vk.list"
- {gperf_offsetof(stringpool, 24), VK_OEM_RESET},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, VK_OEM_RESET},
#line 155 "win32_vk.list"
- {gperf_offsetof(stringpool, 25), VK_OEM_AUTO},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, VK_OEM_AUTO},
#line 151 "win32_vk.list"
- {gperf_offsetof(stringpool, 26), VK_OEM_CUSEL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, VK_OEM_CUSEL},
{-1},
#line 22 "win32_vk.list"
- {gperf_offsetof(stringpool, 28), VK_KANA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, VK_KANA},
#line 127 "win32_vk.list"
- {gperf_offsetof(stringpool, 29), VK_OEM_PLUS},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, VK_OEM_PLUS},
#line 35 "win32_vk.list"
- {gperf_offsetof(stringpool, 30), VK_PRIOR},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, VK_PRIOR},
#line 152 "win32_vk.list"
- {gperf_offsetof(stringpool, 31), VK_OEM_ATTN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, VK_OEM_ATTN},
#line 20 "win32_vk.list"
- {gperf_offsetof(stringpool, 32), VK_PAUSE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, VK_PAUSE},
#line 13 "win32_vk.list"
- {gperf_offsetof(stringpool, 33), VK_BACK},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, VK_BACK},
#line 144 "win32_vk.list"
- {gperf_offsetof(stringpool, 34), VK_PACKET},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, VK_PACKET},
#line 105 "win32_vk.list"
- {gperf_offsetof(stringpool, 35), VK_RCONTROL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, VK_RCONTROL},
#line 104 "win32_vk.list"
- {gperf_offsetof(stringpool, 36), VK_LCONTROL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, VK_LCONTROL},
#line 37 "win32_vk.list"
- {gperf_offsetof(stringpool, 37), VK_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, VK_END},
#line 38 "win32_vk.list"
- {gperf_offsetof(stringpool, 38), VK_HOME},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, VK_HOME},
#line 44 "win32_vk.list"
- {gperf_offsetof(stringpool, 39), VK_PRINT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, VK_PRINT},
#line 94 "win32_vk.list"
- {gperf_offsetof(stringpool, 40), VK_NUMLOCK},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, VK_NUMLOCK},
#line 39 "win32_vk.list"
- {gperf_offsetof(stringpool, 41), VK_LEFT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, VK_LEFT},
#line 25 "win32_vk.list"
- {gperf_offsetof(stringpool, 42), VK_JUNJA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, VK_JUNJA},
#line 19 "win32_vk.list"
- {gperf_offsetof(stringpool, 43), VK_MENU},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, VK_MENU},
#line 150 "win32_vk.list"
- {gperf_offsetof(stringpool, 44), VK_OEM_WSCTRL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, VK_OEM_WSCTRL},
#line 156 "win32_vk.list"
- {gperf_offsetof(stringpool, 45), VK_OEM_ENLW},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, VK_OEM_ENLW},
#line 36 "win32_vk.list"
- {gperf_offsetof(stringpool, 46), VK_NEXT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, VK_NEXT},
#line 51 "win32_vk.list"
- {gperf_offsetof(stringpool, 47), VK_RWIN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, VK_RWIN},
#line 50 "win32_vk.list"
- {gperf_offsetof(stringpool, 48), VK_LWIN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, VK_LWIN},
#line 21 "win32_vk.list"
- {gperf_offsetof(stringpool, 49), VK_CAPITAL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, VK_CAPITAL},
#line 49 "win32_vk.list"
- {gperf_offsetof(stringpool, 50), VK_HELP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, VK_HELP},
#line 164 "win32_vk.list"
- {gperf_offsetof(stringpool, 51), VK_NONAME},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str51, VK_NONAME},
#line 8 "win32_vk.list"
- {gperf_offsetof(stringpool, 52), VK_RBUTTON},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str52, VK_RBUTTON},
#line 7 "win32_vk.list"
- {gperf_offsetof(stringpool, 53), VK_LBUTTON},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str53, VK_LBUTTON},
#line 96 "win32_vk.list"
- {gperf_offsetof(stringpool, 54), VK_OEM_NEC_EQUAL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str54, VK_OEM_NEC_EQUAL},
{-1},
#line 47 "win32_vk.list"
- {gperf_offsetof(stringpool, 56), VK_INSERT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str56, VK_INSERT},
#line 27 "win32_vk.list"
- {gperf_offsetof(stringpool, 57), VK_HANJA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str57, VK_HANJA},
{-1}, {-1},
#line 46 "win32_vk.list"
- {gperf_offsetof(stringpool, 60), VK_SNAPSHOT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str60, VK_SNAPSHOT},
#line 158 "win32_vk.list"
- {gperf_offsetof(stringpool, 61), VK_ATTN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str61, VK_ATTN},
#line 14 "win32_vk.list"
- {gperf_offsetof(stringpool, 62), VK_TAB},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str62, VK_TAB},
#line 157 "win32_vk.list"
- {gperf_offsetof(stringpool, 63), VK_OEM_BACKTAB},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str63, VK_OEM_BACKTAB},
#line 143 "win32_vk.list"
- {gperf_offsetof(stringpool, 64), VK_ICO_CLEAR},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, VK_ICO_CLEAR},
#line 30 "win32_vk.list"
- {gperf_offsetof(stringpool, 65), VK_CONVERT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str65, VK_CONVERT},
#line 16 "win32_vk.list"
- {gperf_offsetof(stringpool, 66), VK_RETURN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str66, VK_RETURN},
#line 146 "win32_vk.list"
- {gperf_offsetof(stringpool, 67), VK_OEM_JUMP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str67, VK_OEM_JUMP},
{-1}, {-1}, {-1},
#line 111 "win32_vk.list"
- {gperf_offsetof(stringpool, 71), VK_BROWSER_STOP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str71, VK_BROWSER_STOP},
#line 26 "win32_vk.list"
- {gperf_offsetof(stringpool, 72), VK_FINAL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str72, VK_FINAL},
#line 163 "win32_vk.list"
- {gperf_offsetof(stringpool, 73), VK_ZOOM},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str73, VK_ZOOM},
#line 28 "win32_vk.list"
- {gperf_offsetof(stringpool, 74), VK_KANJI},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str74, VK_KANJI},
#line 48 "win32_vk.list"
- {gperf_offsetof(stringpool, 75), VK_DELETE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str75, VK_DELETE},
#line 128 "win32_vk.list"
- {gperf_offsetof(stringpool, 76), VK_OEM_COMMA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, VK_OEM_COMMA},
#line 67 "win32_vk.list"
- {gperf_offsetof(stringpool, 77), VK_SUBTRACT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str77, VK_SUBTRACT},
{-1},
#line 10 "win32_vk.list"
- {gperf_offsetof(stringpool, 79), VK_MBUTTON},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79, VK_MBUTTON},
#line 78 "win32_vk.list"
- {gperf_offsetof(stringpool, 80), VK_F9},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str80, VK_F9},
#line 17 "win32_vk.list"
- {gperf_offsetof(stringpool, 81), VK_SHIFT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str81, VK_SHIFT},
#line 103 "win32_vk.list"
- {gperf_offsetof(stringpool, 82), VK_RSHIFT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str82, VK_RSHIFT},
#line 102 "win32_vk.list"
- {gperf_offsetof(stringpool, 83), VK_LSHIFT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str83, VK_LSHIFT},
#line 65 "win32_vk.list"
- {gperf_offsetof(stringpool, 84), VK_ADD},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84, VK_ADD},
#line 31 "win32_vk.list"
- {gperf_offsetof(stringpool, 85), VK_NONCONVERT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str85, VK_NONCONVERT},
#line 160 "win32_vk.list"
- {gperf_offsetof(stringpool, 86), VK_EXSEL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str86, VK_EXSEL},
#line 126 "win32_vk.list"
- {gperf_offsetof(stringpool, 87), VK_OEM_1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str87, VK_OEM_1},
#line 138 "win32_vk.list"
- {gperf_offsetof(stringpool, 88), VK_OEM_AX},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str88, VK_OEM_AX},
#line 108 "win32_vk.list"
- {gperf_offsetof(stringpool, 89), VK_BROWSER_BACK},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str89, VK_BROWSER_BACK},
#line 137 "win32_vk.list"
- {gperf_offsetof(stringpool, 90), VK_OEM_8},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str90, VK_OEM_8},
#line 129 "win32_vk.list"
- {gperf_offsetof(stringpool, 91), VK_OEM_MINUS},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str91, VK_OEM_MINUS},
#line 162 "win32_vk.list"
- {gperf_offsetof(stringpool, 92), VK_PLAY},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92, VK_PLAY},
#line 131 "win32_vk.list"
- {gperf_offsetof(stringpool, 93), VK_OEM_2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str93, VK_OEM_2},
#line 15 "win32_vk.list"
- {gperf_offsetof(stringpool, 94), VK_CLEAR},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str94, VK_CLEAR},
#line 99 "win32_vk.list"
- {gperf_offsetof(stringpool, 95), VK_OEM_FJ_TOUROKU},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str95, VK_OEM_FJ_TOUROKU},
#line 147 "win32_vk.list"
- {gperf_offsetof(stringpool, 96), VK_OEM_PA1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96, VK_OEM_PA1},
#line 140 "win32_vk.list"
- {gperf_offsetof(stringpool, 97), VK_ICO_HELP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str97, VK_ICO_HELP},
#line 112 "win32_vk.list"
- {gperf_offsetof(stringpool, 98), VK_BROWSER_SEARCH},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str98, VK_BROWSER_SEARCH},
#line 53 "win32_vk.list"
- {gperf_offsetof(stringpool, 99), VK_SLEEP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str99, VK_SLEEP},
{-1},
#line 70 "win32_vk.list"
- {gperf_offsetof(stringpool, 101), VK_F1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str101, VK_F1},
#line 148 "win32_vk.list"
- {gperf_offsetof(stringpool, 102), VK_OEM_PA2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str102, VK_OEM_PA2},
#line 154 "win32_vk.list"
- {gperf_offsetof(stringpool, 103), VK_OEM_COPY},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str103, VK_OEM_COPY},
#line 77 "win32_vk.list"
- {gperf_offsetof(stringpool, 104), VK_F8},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str104, VK_F8},
#line 88 "win32_vk.list"
- {gperf_offsetof(stringpool, 105), VK_F19},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str105, VK_F19},
#line 41 "win32_vk.list"
- {gperf_offsetof(stringpool, 106), VK_RIGHT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106, VK_RIGHT},
#line 71 "win32_vk.list"
- {gperf_offsetof(stringpool, 107), VK_F2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str107, VK_F2},
#line 135 "win32_vk.list"
- {gperf_offsetof(stringpool, 108), VK_OEM_6},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, VK_OEM_6},
#line 87 "win32_vk.list"
- {gperf_offsetof(stringpool, 109), VK_F18},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str109, VK_F18},
{-1},
#line 117 "win32_vk.list"
- {gperf_offsetof(stringpool, 111), VK_VOLUME_UP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, VK_VOLUME_UP},
{-1}, {-1},
#line 120 "win32_vk.list"
- {gperf_offsetof(stringpool, 114), VK_MEDIA_STOP},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str114, VK_MEDIA_STOP},
#line 130 "win32_vk.list"
- {gperf_offsetof(stringpool, 115), VK_OEM_PERIOD},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str115, VK_OEM_PERIOD},
{-1},
#line 161 "win32_vk.list"
- {gperf_offsetof(stringpool, 117), VK_EREOF},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str117, VK_EREOF},
{-1}, {-1}, {-1},
#line 114 "win32_vk.list"
- {gperf_offsetof(stringpool, 121), VK_BROWSER_HOME},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str121, VK_BROWSER_HOME},
#line 75 "win32_vk.list"
- {gperf_offsetof(stringpool, 122), VK_F6},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str122, VK_F6},
{-1},
#line 110 "win32_vk.list"
- {gperf_offsetof(stringpool, 124), VK_BROWSER_REFRESH},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124, VK_BROWSER_REFRESH},
{-1},
#line 165 "win32_vk.list"
- {gperf_offsetof(stringpool, 126), VK_PA1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str126, VK_PA1},
#line 142 "win32_vk.list"
- {gperf_offsetof(stringpool, 127), VK_PROCESSKEY},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127, VK_PROCESSKEY},
#line 68 "win32_vk.list"
- {gperf_offsetof(stringpool, 128), VK_DECIMAL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str128, VK_DECIMAL},
#line 132 "win32_vk.list"
- {gperf_offsetof(stringpool, 129), VK_OEM_3},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str129, VK_OEM_3},
#line 107 "win32_vk.list"
- {gperf_offsetof(stringpool, 130), VK_RMENU},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str130, VK_RMENU},
#line 106 "win32_vk.list"
- {gperf_offsetof(stringpool, 131), VK_LMENU},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, VK_LMENU},
#line 98 "win32_vk.list"
- {gperf_offsetof(stringpool, 132), VK_OEM_FJ_MASSHOU},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str132, VK_OEM_FJ_MASSHOU},
#line 54 "win32_vk.list"
- {gperf_offsetof(stringpool, 133), VK_NUMPAD0},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str133, VK_NUMPAD0},
#line 24 "win32_vk.list"
- {gperf_offsetof(stringpool, 134), VK_HANGUL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str134, VK_HANGUL},
#line 63 "win32_vk.list"
- {gperf_offsetof(stringpool, 135), VK_NUMPAD9},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str135, VK_NUMPAD9},
#line 23 "win32_vk.list"
- {gperf_offsetof(stringpool, 136), VK_HANGEUL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str136, VK_HANGEUL},
#line 134 "win32_vk.list"
- {gperf_offsetof(stringpool, 137), VK_OEM_5},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, VK_OEM_5},
#line 149 "win32_vk.list"
- {gperf_offsetof(stringpool, 138), VK_OEM_PA3},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str138, VK_OEM_PA3},
#line 115 "win32_vk.list"
- {gperf_offsetof(stringpool, 139), VK_VOLUME_MUTE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str139, VK_VOLUME_MUTE},
#line 133 "win32_vk.list"
- {gperf_offsetof(stringpool, 140), VK_OEM_4},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str140, VK_OEM_4},
#line 122 "win32_vk.list"
- {gperf_offsetof(stringpool, 141), VK_LAUNCH_MAIL},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str141, VK_LAUNCH_MAIL},
#line 97 "win32_vk.list"
- {gperf_offsetof(stringpool, 142), VK_OEM_FJ_JISHO},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str142, VK_OEM_FJ_JISHO},
#line 72 "win32_vk.list"
- {gperf_offsetof(stringpool, 143), VK_F3},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, VK_F3},
#line 101 "win32_vk.list"
- {gperf_offsetof(stringpool, 144), VK_OEM_FJ_ROYA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144, VK_OEM_FJ_ROYA},
#line 100 "win32_vk.list"
- {gperf_offsetof(stringpool, 145), VK_OEM_FJ_LOYA},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str145, VK_OEM_FJ_LOYA},
{-1},
#line 42 "win32_vk.list"
- {gperf_offsetof(stringpool, 147), VK_DOWN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str147, VK_DOWN},
{-1},
#line 153 "win32_vk.list"
- {gperf_offsetof(stringpool, 149), VK_OEM_FINISH},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str149, VK_OEM_FINISH},
{-1},
#line 74 "win32_vk.list"
- {gperf_offsetof(stringpool, 151), VK_F5},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, VK_F5},
{-1},
#line 136 "win32_vk.list"
- {gperf_offsetof(stringpool, 153), VK_OEM_7},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str153, VK_OEM_7},
#line 73 "win32_vk.list"
- {gperf_offsetof(stringpool, 154), VK_F4},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, VK_F4},
#line 86 "win32_vk.list"
- {gperf_offsetof(stringpool, 155), VK_F17},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, VK_F17},
#line 55 "win32_vk.list"
- {gperf_offsetof(stringpool, 156), VK_NUMPAD1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str156, VK_NUMPAD1},
#line 141 "win32_vk.list"
- {gperf_offsetof(stringpool, 157), VK_ICO_00},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str157, VK_ICO_00},
{-1},
#line 62 "win32_vk.list"
- {gperf_offsetof(stringpool, 159), VK_NUMPAD8},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str159, VK_NUMPAD8},
{-1}, {-1},
#line 56 "win32_vk.list"
- {gperf_offsetof(stringpool, 162), VK_NUMPAD2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, VK_NUMPAD2},
{-1},
#line 124 "win32_vk.list"
- {gperf_offsetof(stringpool, 164), VK_LAUNCH_APP1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, VK_LAUNCH_APP1},
#line 109 "win32_vk.list"
- {gperf_offsetof(stringpool, 165), VK_BROWSER_FORWARD},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str165, VK_BROWSER_FORWARD},
{-1},
#line 76 "win32_vk.list"
- {gperf_offsetof(stringpool, 167), VK_F7},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, VK_F7},
{-1}, {-1},
#line 125 "win32_vk.list"
- {gperf_offsetof(stringpool, 170), VK_LAUNCH_APP2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170, VK_LAUNCH_APP2},
#line 64 "win32_vk.list"
- {gperf_offsetof(stringpool, 171), VK_MULTIPLY},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, VK_MULTIPLY},
{-1}, {-1},
#line 45 "win32_vk.list"
- {gperf_offsetof(stringpool, 174), VK_EXECUTE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str174, VK_EXECUTE},
{-1},
#line 113 "win32_vk.list"
- {gperf_offsetof(stringpool, 176), VK_BROWSER_FAVORITES},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, VK_BROWSER_FAVORITES},
#line 60 "win32_vk.list"
- {gperf_offsetof(stringpool, 177), VK_NUMPAD6},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177, VK_NUMPAD6},
{-1},
#line 85 "win32_vk.list"
- {gperf_offsetof(stringpool, 179), VK_F16},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179, VK_F16},
{-1}, {-1},
#line 79 "win32_vk.list"
- {gperf_offsetof(stringpool, 182), VK_F10},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str182, VK_F10},
{-1}, {-1},
#line 116 "win32_vk.list"
- {gperf_offsetof(stringpool, 185), VK_VOLUME_DOWN},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, VK_VOLUME_DOWN},
{-1}, {-1},
#line 89 "win32_vk.list"
- {gperf_offsetof(stringpool, 188), VK_F20},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str188, VK_F20},
#line 119 "win32_vk.list"
- {gperf_offsetof(stringpool, 189), VK_MEDIA_PREV_TRACK},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, VK_MEDIA_PREV_TRACK},
{-1},
#line 33 "win32_vk.list"
- {gperf_offsetof(stringpool, 191), VK_MODECHANGE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str191, VK_MODECHANGE},
{-1}, {-1}, {-1}, {-1}, {-1},
#line 83 "win32_vk.list"
- {gperf_offsetof(stringpool, 197), VK_F14},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, VK_F14},
#line 57 "win32_vk.list"
- {gperf_offsetof(stringpool, 198), VK_NUMPAD3},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str198, VK_NUMPAD3},
#line 11 "win32_vk.list"
- {gperf_offsetof(stringpool, 199), VK_XBUTTON1},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, VK_XBUTTON1},
{-1}, {-1}, {-1},
#line 93 "win32_vk.list"
- {gperf_offsetof(stringpool, 203), VK_F24},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, VK_F24},
{-1},
#line 12 "win32_vk.list"
- {gperf_offsetof(stringpool, 205), VK_XBUTTON2},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, VK_XBUTTON2},
#line 59 "win32_vk.list"
- {gperf_offsetof(stringpool, 206), VK_NUMPAD5},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, VK_NUMPAD5},
{-1}, {-1},
#line 58 "win32_vk.list"
- {gperf_offsetof(stringpool, 209), VK_NUMPAD4},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, VK_NUMPAD4},
{-1}, {-1}, {-1}, {-1}, {-1},
#line 121 "win32_vk.list"
- {gperf_offsetof(stringpool, 215), VK_MEDIA_PLAY_PAUSE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, VK_MEDIA_PLAY_PAUSE},
{-1},
#line 123 "win32_vk.list"
- {gperf_offsetof(stringpool, 217), VK_LAUNCH_MEDIA_SELECT},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, VK_LAUNCH_MEDIA_SELECT},
#line 80 "win32_vk.list"
- {gperf_offsetof(stringpool, 218), VK_F11},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str218, VK_F11},
{-1},
#line 139 "win32_vk.list"
- {gperf_offsetof(stringpool, 220), VK_OEM_102},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, VK_OEM_102},
#line 118 "win32_vk.list"
- {gperf_offsetof(stringpool, 221), VK_MEDIA_NEXT_TRACK},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str221, VK_MEDIA_NEXT_TRACK},
#line 61 "win32_vk.list"
- {gperf_offsetof(stringpool, 222), VK_NUMPAD7},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str222, VK_NUMPAD7},
{-1},
#line 90 "win32_vk.list"
- {gperf_offsetof(stringpool, 224), VK_F21},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str224, VK_F21},
{-1},
#line 82 "win32_vk.list"
- {gperf_offsetof(stringpool, 226), VK_F13},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str226, VK_F13},
{-1}, {-1},
#line 81 "win32_vk.list"
- {gperf_offsetof(stringpool, 229), VK_F12},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str229, VK_F12},
{-1}, {-1},
#line 92 "win32_vk.list"
- {gperf_offsetof(stringpool, 232), VK_F23},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232, VK_F23},
{-1}, {-1},
#line 91 "win32_vk.list"
- {gperf_offsetof(stringpool, 235), VK_F22},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str235, VK_F22},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 84 "win32_vk.list"
- {gperf_offsetof(stringpool, 242), VK_F15},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str242, VK_F15},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
{-1}, {-1}, {-1}, {-1},
#line 69 "win32_vk.list"
- {gperf_offsetof(stringpool, 256), VK_DIVIDE}
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, VK_DIVIDE}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/ext/io/console/win32_vk.list b/ext/io/console/win32_vk.list
index 7909a4d1f0..5df3d6da57 100644
--- a/ext/io/console/win32_vk.list
+++ b/ext/io/console/win32_vk.list
@@ -1,6 +1,6 @@
%{
struct vktable {short ofs; unsigned short vk;};
-static const struct vktable *console_win32_vk(/*!ANSI{*/const char *, unsigned int/*}!ANSI*/);
+static const struct vktable *console_win32_vk(const char *, size_t);
%}
struct vktable
%%
diff --git a/ext/io/nonblock/depend b/ext/io/nonblock/depend
index 48384fca62..e78a05c316 100644
--- a/ext/io/nonblock/depend
+++ b/ext/io/nonblock/depend
@@ -138,6 +138,7 @@ nonblock.o: $(hdrdir)/ruby/internal/intern/re.h
nonblock.o: $(hdrdir)/ruby/internal/intern/ruby.h
nonblock.o: $(hdrdir)/ruby/internal/intern/select.h
nonblock.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+nonblock.o: $(hdrdir)/ruby/internal/intern/set.h
nonblock.o: $(hdrdir)/ruby/internal/intern/signal.h
nonblock.o: $(hdrdir)/ruby/internal/intern/sprintf.h
nonblock.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ nonblock.o: $(hdrdir)/ruby/internal/special_consts.h
nonblock.o: $(hdrdir)/ruby/internal/static_assert.h
nonblock.o: $(hdrdir)/ruby/internal/stdalign.h
nonblock.o: $(hdrdir)/ruby/internal/stdbool.h
+nonblock.o: $(hdrdir)/ruby/internal/stdckdint.h
nonblock.o: $(hdrdir)/ruby/internal/symbol.h
nonblock.o: $(hdrdir)/ruby/internal/value.h
nonblock.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/io/nonblock/extconf.rb b/ext/io/nonblock/extconf.rb
index d813a01e7c..505c9e6252 100644
--- a/ext/io/nonblock/extconf.rb
+++ b/ext/io/nonblock/extconf.rb
@@ -2,6 +2,13 @@
require 'mkmf'
target = "io/nonblock"
+unless RUBY_ENGINE == 'ruby'
+ File.write("Makefile", dummy_makefile($srcdir).join(""))
+ return
+end
+
+have_func("rb_io_descriptor", "ruby/io.h")
+
hdr = %w"fcntl.h"
if have_macro("O_NONBLOCK", hdr) and
(have_macro("F_GETFL", hdr) or have_macro("F_SETFL", hdr))
diff --git a/ext/io/nonblock/io-nonblock.gemspec b/ext/io/nonblock/io-nonblock.gemspec
index d6df21a84d..4f5b8cef6f 100644
--- a/ext/io/nonblock/io-nonblock.gemspec
+++ b/ext/io/nonblock/io-nonblock.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "io-nonblock"
- spec.version = "0.2.0"
+ spec.version = "0.3.2"
spec.authors = ["Nobu Nakada"]
spec.email = ["nobu@ruby-lang.org"]
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
spec.description = %q{Enables non-blocking mode with IO class}
spec.homepage = "https://github.com/ruby/io-nonblock"
spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0")
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
diff --git a/ext/io/nonblock/nonblock.c b/ext/io/nonblock/nonblock.c
index b8a40ff38e..cd40ea3335 100644
--- a/ext/io/nonblock/nonblock.c
+++ b/ext/io/nonblock/nonblock.c
@@ -17,6 +17,17 @@
#endif
#include <fcntl.h>
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
#ifdef F_GETFL
static int
get_fcntl_flags(int fd)
@@ -39,10 +50,8 @@ get_fcntl_flags(int fd)
static VALUE
rb_io_nonblock_p(VALUE io)
{
- rb_io_t *fptr;
- GetOpenFile(io, fptr);
- if (get_fcntl_flags(fptr->fd) & O_NONBLOCK)
- return Qtrue;
+ if (get_fcntl_flags(rb_io_descriptor(io)) & O_NONBLOCK)
+ return Qtrue;
return Qfalse;
}
#else
@@ -57,6 +66,8 @@ set_fcntl_flags(int fd, int f)
rb_sys_fail(0);
}
+#ifndef RUBY_IO_NONBLOCK_METHODS
+
static int
io_nonblock_set(int fd, int f, int nb)
{
@@ -122,17 +133,23 @@ io_nonblock_set(int fd, int f, int nb)
*
*/
static VALUE
-rb_io_nonblock_set(VALUE io, VALUE nb)
+rb_io_nonblock_set(VALUE self, VALUE value)
{
- rb_io_t *fptr;
- GetOpenFile(io, fptr);
- if (RTEST(nb))
- rb_io_set_nonblock(fptr);
- else
- io_nonblock_set(fptr->fd, get_fcntl_flags(fptr->fd), RTEST(nb));
- return io;
+ if (RTEST(value)) {
+ rb_io_t *fptr;
+ GetOpenFile(self, fptr);
+ rb_io_set_nonblock(fptr);
+ }
+ else {
+ int descriptor = rb_io_descriptor(self);
+ io_nonblock_set(descriptor, get_fcntl_flags(descriptor), RTEST(value));
+ }
+
+ return self;
}
+#endif /* RUBY_IO_NONBLOCK_METHODS */
+
static VALUE
io_nonblock_restore(VALUE arg)
{
@@ -152,24 +169,25 @@ io_nonblock_restore(VALUE arg)
* The original mode is restored after the block is executed.
*/
static VALUE
-rb_io_nonblock_block(int argc, VALUE *argv, VALUE io)
+rb_io_nonblock_block(int argc, VALUE *argv, VALUE self)
{
int nb = 1;
- rb_io_t *fptr;
- int f, restore[2];
- GetOpenFile(io, fptr);
+ int descriptor = rb_io_descriptor(self);
+
if (argc > 0) {
- VALUE v;
- rb_scan_args(argc, argv, "01", &v);
- nb = RTEST(v);
+ VALUE v;
+ rb_scan_args(argc, argv, "01", &v);
+ nb = RTEST(v);
}
- f = get_fcntl_flags(fptr->fd);
- restore[0] = fptr->fd;
- restore[1] = f;
- if (!io_nonblock_set(fptr->fd, f, nb))
- return rb_yield(io);
- return rb_ensure(rb_yield, io, io_nonblock_restore, (VALUE)restore);
+
+ int current_flags = get_fcntl_flags(descriptor);
+ int restore[2] = {descriptor, current_flags};
+
+ if (!io_nonblock_set(descriptor, current_flags, nb))
+ return rb_yield(self);
+
+ return rb_ensure(rb_yield, self, io_nonblock_restore, (VALUE)restore);
}
#else
#define rb_io_nonblock_set rb_f_notimplement
@@ -179,7 +197,14 @@ rb_io_nonblock_block(int argc, VALUE *argv, VALUE io)
void
Init_nonblock(void)
{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
+#ifndef RUBY_IO_NONBLOCK_METHODS
rb_define_method(rb_cIO, "nonblock?", rb_io_nonblock_p, 0);
rb_define_method(rb_cIO, "nonblock=", rb_io_nonblock_set, 1);
+#endif
+
rb_define_method(rb_cIO, "nonblock", rb_io_nonblock_block, -1);
}
diff --git a/ext/io/wait/depend b/ext/io/wait/depend
index 83cf8f94c8..41d53c1400 100644
--- a/ext/io/wait/depend
+++ b/ext/io/wait/depend
@@ -1,5 +1,4 @@
# AUTOGENERATED DEPENDENCIES START
-# wait.o: $(hdrdir)/ruby/assert.h # not in 2.6
wait.o: $(RUBY_EXTCONF_H)
wait.o: $(arch_hdrdir)/ruby/config.h
wait.o: $(hdrdir)/ruby.h
@@ -139,6 +138,7 @@ wait.o: $(hdrdir)/ruby/internal/intern/re.h
wait.o: $(hdrdir)/ruby/internal/intern/ruby.h
wait.o: $(hdrdir)/ruby/internal/intern/select.h
wait.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+wait.o: $(hdrdir)/ruby/internal/intern/set.h
wait.o: $(hdrdir)/ruby/internal/intern/signal.h
wait.o: $(hdrdir)/ruby/internal/intern/sprintf.h
wait.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -158,6 +158,7 @@ wait.o: $(hdrdir)/ruby/internal/special_consts.h
wait.o: $(hdrdir)/ruby/internal/static_assert.h
wait.o: $(hdrdir)/ruby/internal/stdalign.h
wait.o: $(hdrdir)/ruby/internal/stdbool.h
+wait.o: $(hdrdir)/ruby/internal/stdckdint.h
wait.o: $(hdrdir)/ruby/internal/symbol.h
wait.o: $(hdrdir)/ruby/internal/value.h
wait.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
index eecdcce99f..00c455a45c 100644
--- a/ext/io/wait/extconf.rb
+++ b/ext/io/wait/extconf.rb
@@ -1,24 +1,4 @@
# frozen_string_literal: false
require 'mkmf'
-if RUBY_VERSION < "2.6"
- File.write("Makefile", dummy_makefile($srcdir).join(""))
-else
- target = "io/wait"
- have_func("rb_io_wait")
- unless macro_defined?("DOSISH", "#include <ruby.h>")
- have_header(ioctl_h = "sys/ioctl.h") or ioctl_h = nil
- fionread = %w[sys/ioctl.h sys/filio.h sys/socket.h].find do |h|
- have_macro("FIONREAD", [h, ioctl_h].compact)
- end
- if fionread
- $defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
- create_makefile(target)
- end
- else
- if have_func("rb_w32_ioctlsocket", "ruby.h")
- have_func("rb_w32_is_socket", "ruby.h")
- create_makefile(target)
- end
- end
-end
+create_makefile("io/wait")
diff --git a/ext/io/wait/io-wait.gemspec b/ext/io/wait/io-wait.gemspec
index ebc1f6f5c7..c1c6172589 100644
--- a/ext/io/wait/io-wait.gemspec
+++ b/ext/io/wait/io-wait.gemspec
@@ -1,4 +1,4 @@
-_VERSION = "0.3.0"
+_VERSION = "0.4.0"
Gem::Specification.new do |spec|
spec.name = "io-wait"
@@ -10,24 +10,25 @@ Gem::Specification.new do |spec|
spec.description = %q{Waits until IO is readable or writable without blocking.}
spec.homepage = "https://github.com/ruby/io-wait"
spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.2")
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject do |f|
- File.identical?(f, __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|rakelib)/|\.(?:git|travis|circleci)|appveyor|Rakefile)})
- end
- end
+ jruby = true if Gem::Platform.new('java') =~ spec.platform or RUBY_ENGINE == 'jruby'
+ dir, gemspec = File.split(__FILE__)
+ excludes = [
+ *%w[:^/.git* :^/Gemfile* :^/Rakefile* :^/bin/ :^/test/ :^/rakelib/ :^*.java],
+ *(jruby ? %w[:^/ext/io] : %w[:^/ext/java]),
+ ":(exclude,literal,top)#{gemspec}"
+ ]
+ files = IO.popen(%w[git ls-files -z --] + excludes, chdir: dir, &:read).split("\x0")
+
+ spec.files = files
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
- jruby = true if Gem::Platform.new('java') =~ spec.platform or RUBY_ENGINE == 'jruby'
- spec.files.delete_if do |f|
- f.end_with?(".java") or
- f.start_with?("ext/") && (jruby ^ f.start_with?("ext/java/"))
- end
if jruby
spec.platform = 'java'
spec.files << "lib/io/wait.jar"
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index d74afb580b..f7575191fe 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -11,420 +11,13 @@
**********************************************************************/
-#include "ruby.h"
-#include "ruby/io.h"
-
-#include <sys/types.h>
-#if defined(HAVE_UNISTD_H) && (defined(__sun))
-#include <unistd.h>
-#endif
-#if defined(HAVE_SYS_IOCTL_H)
-#include <sys/ioctl.h>
-#endif
-#if defined(FIONREAD_HEADER)
-#include FIONREAD_HEADER
-#endif
-
-#ifdef HAVE_RB_W32_IOCTLSOCKET
-#define ioctl ioctlsocket
-#define ioctl_arg u_long
-#define ioctl_arg2num(i) ULONG2NUM(i)
-#else
-#define ioctl_arg int
-#define ioctl_arg2num(i) INT2NUM(i)
-#endif
-
-#ifdef HAVE_RB_W32_IS_SOCKET
-#define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fd)
-#else
-#define FIONREAD_POSSIBLE_P(fd) ((void)(fd),Qtrue)
-#endif
-
-#ifndef HAVE_RB_IO_WAIT
-static struct timeval *
-get_timeout(int argc, VALUE *argv, struct timeval *timerec)
-{
- VALUE timeout = Qnil;
- rb_check_arity(argc, 0, 1);
- if (!argc || NIL_P(timeout = argv[0])) {
- return NULL;
- }
- else {
- *timerec = rb_time_interval(timeout);
- return timerec;
- }
-}
-
-static int
-wait_for_single_fd(rb_io_t *fptr, int events, struct timeval *tv)
-{
- int i = rb_wait_for_single_fd(fptr->fd, events, tv);
- if (i < 0)
- rb_sys_fail(0);
- rb_io_check_closed(fptr);
- return (i & events);
-}
-#endif
-
-/*
- * call-seq:
- * io.nread -> int
- *
- * Returns number of bytes that can be read without blocking.
- * Returns zero if no information available.
- *
- * You must require 'io/wait' to use this method.
- */
-
-static VALUE
-io_nread(VALUE io)
-{
- rb_io_t *fptr;
- int len;
- ioctl_arg n;
-
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
- len = rb_io_read_pending(fptr);
- if (len > 0) return INT2FIX(len);
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
- if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
- if (n > 0) return ioctl_arg2num(n);
- return INT2FIX(0);
-}
-
-#ifdef HAVE_RB_IO_WAIT
-static VALUE
-io_wait_event(VALUE io, int event, VALUE timeout, int return_io)
-{
- VALUE result = rb_io_wait(io, RB_INT2NUM(event), timeout);
-
- if (!RB_TEST(result)) {
- return Qnil;
- }
-
- int mask = RB_NUM2INT(result);
-
- if (mask & event) {
- if (return_io)
- return io;
- else
- return result;
- }
- else {
- return Qfalse;
- }
-}
-#endif
-
-/*
- * call-seq:
- * io.ready? -> truthy or falsy
- *
- * Returns a truthy value if input available without blocking, or a
- * falsy value.
- *
- * You must require 'io/wait' to use this method.
- */
-
-static VALUE
-io_ready_p(VALUE io)
-{
- rb_io_t *fptr;
-#ifndef HAVE_RB_IO_WAIT
- struct timeval tv = {0, 0};
-#endif
-
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
- if (rb_io_read_pending(fptr)) return Qtrue;
-
-#ifndef HAVE_RB_IO_WAIT
- return wait_for_single_fd(fptr, RB_WAITFD_IN, &tv) ? Qtrue : Qfalse;
-#else
- return io_wait_event(io, RUBY_IO_READABLE, RB_INT2NUM(0), 1);
-#endif
-}
-
-/* Ruby 3.2+ can define these methods. This macro indicates that case. */
-#ifndef RUBY_IO_WAIT_METHODS
-
-/*
- * call-seq:
- * io.wait_readable -> truthy or falsy
- * io.wait_readable(timeout) -> truthy or falsy
- *
- * Waits until IO is readable and returns a truthy value, or a falsy
- * value when times out. Returns a truthy value immediately when
- * buffered data is available.
- *
- * You must require 'io/wait' to use this method.
- */
-
-static VALUE
-io_wait_readable(int argc, VALUE *argv, VALUE io)
-{
- rb_io_t *fptr;
-#ifndef HAVE_RB_IO_WAIT
- struct timeval timerec;
- struct timeval *tv;
-#endif
-
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
-
-#ifndef HAVE_RB_IO_WAIT
- tv = get_timeout(argc, argv, &timerec);
-#endif
- if (rb_io_read_pending(fptr)) return Qtrue;
-
-#ifndef HAVE_RB_IO_WAIT
- if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) {
- return io;
- }
- return Qnil;
-#else
- rb_check_arity(argc, 0, 1);
- VALUE timeout = (argc == 1 ? argv[0] : Qnil);
-
- return io_wait_event(io, RUBY_IO_READABLE, timeout, 1);
-#endif
-}
-
-/*
- * call-seq:
- * io.wait_writable -> truthy or falsy
- * io.wait_writable(timeout) -> truthy or falsy
- *
- * Waits until IO is writable and returns a truthy value or a falsy
- * value when times out.
- *
- * You must require 'io/wait' to use this method.
- */
-static VALUE
-io_wait_writable(int argc, VALUE *argv, VALUE io)
-{
- rb_io_t *fptr;
-#ifndef HAVE_RB_IO_WAIT
- struct timeval timerec;
- struct timeval *tv;
-#endif
-
- GetOpenFile(io, fptr);
- rb_io_check_writable(fptr);
-
-#ifndef HAVE_RB_IO_WAIT
- tv = get_timeout(argc, argv, &timerec);
- if (wait_for_single_fd(fptr, RB_WAITFD_OUT, tv)) {
- return io;
- }
- return Qnil;
-#else
- rb_check_arity(argc, 0, 1);
- VALUE timeout = (argc == 1 ? argv[0] : Qnil);
-
- return io_wait_event(io, RUBY_IO_WRITABLE, timeout, 1);
-#endif
-}
-
-#ifdef HAVE_RB_IO_WAIT
-/*
- * call-seq:
- * io.wait_priority -> truthy or falsy
- * io.wait_priority(timeout) -> truthy or falsy
- *
- * Waits until IO is priority and returns a truthy value or a falsy
- * value when times out. Priority data is sent and received using
- * the Socket::MSG_OOB flag and is typically limited to streams.
- *
- * You must require 'io/wait' to use this method.
- */
-static VALUE
-io_wait_priority(int argc, VALUE *argv, VALUE io)
-{
- rb_io_t *fptr = NULL;
-
- RB_IO_POINTER(io, fptr);
- rb_io_check_readable(fptr);
-
- if (rb_io_read_pending(fptr)) return Qtrue;
-
- rb_check_arity(argc, 0, 1);
- VALUE timeout = argc == 1 ? argv[0] : Qnil;
-
- return io_wait_event(io, RUBY_IO_PRIORITY, timeout, 1);
-}
-#endif
-
-static int
-wait_mode_sym(VALUE mode)
-{
- if (mode == ID2SYM(rb_intern("r"))) {
- return RB_WAITFD_IN;
- }
- if (mode == ID2SYM(rb_intern("read"))) {
- return RB_WAITFD_IN;
- }
- if (mode == ID2SYM(rb_intern("readable"))) {
- return RB_WAITFD_IN;
- }
- if (mode == ID2SYM(rb_intern("w"))) {
- return RB_WAITFD_OUT;
- }
- if (mode == ID2SYM(rb_intern("write"))) {
- return RB_WAITFD_OUT;
- }
- if (mode == ID2SYM(rb_intern("writable"))) {
- return RB_WAITFD_OUT;
- }
- if (mode == ID2SYM(rb_intern("rw"))) {
- return RB_WAITFD_IN|RB_WAITFD_OUT;
- }
- if (mode == ID2SYM(rb_intern("read_write"))) {
- return RB_WAITFD_IN|RB_WAITFD_OUT;
- }
- if (mode == ID2SYM(rb_intern("readable_writable"))) {
- return RB_WAITFD_IN|RB_WAITFD_OUT;
- }
- rb_raise(rb_eArgError, "unsupported mode: %"PRIsVALUE, mode);
- return 0;
-}
-
-#ifdef HAVE_RB_IO_WAIT
-static inline rb_io_event_t
-io_event_from_value(VALUE value)
-{
- int events = RB_NUM2INT(value);
-
- if (events <= 0) rb_raise(rb_eArgError, "Events must be positive integer!");
-
- return events;
-}
-#endif
+#include "ruby.h" /* abi_version */
/*
- * call-seq:
- * io.wait(events, timeout) -> event mask, false or nil
- * io.wait(timeout = nil, mode = :read) -> self, true, or false
- *
- * Waits until the IO becomes ready for the specified events and returns the
- * subset of events that become ready, or a falsy value when times out.
- *
- * The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or
- * +IO::PRIORITY+.
- *
- * Returns a truthy value immediately when buffered data is available.
- *
- * Optional parameter +mode+ is one of +:read+, +:write+, or
- * +:read_write+.
- *
- * You must require 'io/wait' to use this method.
- */
-
-static VALUE
-io_wait(int argc, VALUE *argv, VALUE io)
-{
-#ifndef HAVE_RB_IO_WAIT
- rb_io_t *fptr;
- struct timeval timerec;
- struct timeval *tv = NULL;
- int event = 0;
- int i;
-
- GetOpenFile(io, fptr);
- for (i = 0; i < argc; ++i) {
- if (SYMBOL_P(argv[i])) {
- event |= wait_mode_sym(argv[i]);
- }
- else {
- *(tv = &timerec) = rb_time_interval(argv[i]);
- }
- }
- /* rb_time_interval() and might_mode() might convert the argument */
- rb_io_check_closed(fptr);
- if (!event) event = RB_WAITFD_IN;
- if ((event & RB_WAITFD_IN) && rb_io_read_pending(fptr))
- return Qtrue;
- if (wait_for_single_fd(fptr, event, tv))
- return io;
- return Qnil;
-#else
- VALUE timeout = Qundef;
- rb_io_event_t events = 0;
- int i, return_io = 0;
-
- /* The documented signature for this method is actually incorrect.
- * A single timeout is allowed in any position, and multiple symbols can be given.
- * Whether this is intentional or not, I don't know, and as such I consider this to
- * be a legacy/slow path. */
- if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) {
- /* We'd prefer to return the actual mask, but this form would return the io itself: */
- return_io = 1;
-
- /* Slow/messy path: */
- for (i = 0; i < argc; i += 1) {
- if (RB_SYMBOL_P(argv[i])) {
- events |= wait_mode_sym(argv[i]);
- }
- else if (timeout == Qundef) {
- rb_time_interval(timeout = argv[i]);
- }
- else {
- rb_raise(rb_eArgError, "timeout given more than once");
- }
- }
-
- if (timeout == Qundef) timeout = Qnil;
-
- if (events == 0) {
- events = RUBY_IO_READABLE;
- }
- }
- else /* argc == 2 and neither are symbols */ {
- /* This is the fast path: */
- events = io_event_from_value(argv[0]);
- timeout = argv[1];
- }
-
- if (events & RUBY_IO_READABLE) {
- rb_io_t *fptr = NULL;
- RB_IO_POINTER(io, fptr);
-
- if (rb_io_read_pending(fptr)) {
- /* This was the original behaviour: */
- if (return_io) return Qtrue;
- /* New behaviour always returns an event mask: */
- else return RB_INT2NUM(RUBY_IO_READABLE);
- }
- }
-
- return io_wait_event(io, events, timeout, return_io);
-#endif
-}
-
-#endif /* RUBY_IO_WAIT_METHODS */
-
-/*
- * IO wait methods
+ * IO wait methods are built in ruby now, just for backward compatibility.
*/
void
Init_wait(void)
{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- RB_EXT_RACTOR_SAFE(true);
-#endif
-
- rb_define_method(rb_cIO, "nread", io_nread, 0);
- rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
-
-#ifndef RUBY_IO_WAIT_METHODS
- rb_define_method(rb_cIO, "wait", io_wait, -1);
-
- rb_define_method(rb_cIO, "wait_readable", io_wait_readable, -1);
- rb_define_method(rb_cIO, "wait_writable", io_wait_writable, -1);
-#ifdef HAVE_RB_IO_WAIT
- rb_define_method(rb_cIO, "wait_priority", io_wait_priority, -1);
-#endif
-#endif
}
diff --git a/ext/json/VERSION b/ext/json/VERSION
deleted file mode 100644
index ec1cf33c3f..0000000000
--- a/ext/json/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.6.3
diff --git a/ext/json/fbuffer/fbuffer.h b/ext/json/fbuffer/fbuffer.h
index dc8f406b5b..b84a073554 100644
--- a/ext/json/fbuffer/fbuffer.h
+++ b/ext/json/fbuffer/fbuffer.h
@@ -1,89 +1,71 @@
-
#ifndef _FBUFFER_H_
#define _FBUFFER_H_
-#include "ruby.h"
-
-#ifndef RHASH_SIZE
-#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
-#endif
-
-#ifndef RFLOAT_VALUE
-#define RFLOAT_VALUE(val) (RFLOAT(val)->value)
-#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
+#include "../json.h"
+#include "../vendor/jeaiii-ltoa.h"
-#ifdef PRIsVALUE
-# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
-# define RB_OBJ_STRING(obj) (obj)
-#else
-# define PRIsVALUE "s"
-# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
-# define RB_OBJ_STRING(obj) StringValueCStr(obj)
-#endif
-
-#ifdef HAVE_RUBY_ENCODING_H
-#include "ruby/encoding.h"
-#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
-#else
-#define FORCE_UTF8(obj)
-#endif
-
-/* We don't need to guard objects for rbx, so let's do nothing at all. */
-#ifndef RB_GC_GUARD
-#define RB_GC_GUARD(object)
-#endif
+enum fbuffer_type {
+ FBUFFER_HEAP_ALLOCATED = 0,
+ FBUFFER_STACK_ALLOCATED = 1,
+};
typedef struct FBufferStruct {
- unsigned long initial_length;
+ enum fbuffer_type type;
+ size_t initial_length;
+ size_t len;
+ size_t capa;
+#if JSON_DEBUG
+ size_t requested;
+#endif
char *ptr;
- unsigned long len;
- unsigned long capa;
+ VALUE io;
} FBuffer;
+#define FBUFFER_STACK_SIZE 512
+#define FBUFFER_IO_BUFFER_SIZE (16384 - 1)
#define FBUFFER_INITIAL_LENGTH_DEFAULT 1024
-#define FBUFFER_PTR(fb) (fb->ptr)
-#define FBUFFER_LEN(fb) (fb->len)
-#define FBUFFER_CAPA(fb) (fb->capa)
+#define FBUFFER_PTR(fb) ((fb)->ptr)
+#define FBUFFER_LEN(fb) ((fb)->len)
+#define FBUFFER_CAPA(fb) ((fb)->capa)
#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb)
-static FBuffer *fbuffer_alloc(unsigned long initial_length);
static void fbuffer_free(FBuffer *fb);
static void fbuffer_clear(FBuffer *fb);
-static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len);
-#ifdef JSON_GENERATOR
+static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len);
static void fbuffer_append_long(FBuffer *fb, long number);
+static inline void fbuffer_append_char(FBuffer *fb, char newchr);
+static VALUE fbuffer_finalize(FBuffer *fb);
+
+static void fbuffer_stack_init(FBuffer *fb, size_t initial_length, char *stack_buffer, size_t stack_buffer_size)
+{
+ fb->initial_length = (initial_length > 0) ? initial_length : FBUFFER_INITIAL_LENGTH_DEFAULT;
+ if (stack_buffer) {
+ fb->type = FBUFFER_STACK_ALLOCATED;
+ fb->ptr = stack_buffer;
+ fb->capa = stack_buffer_size;
+ }
+#if JSON_DEBUG
+ fb->requested = 0;
#endif
-static void fbuffer_append_char(FBuffer *fb, char newchr);
-#ifdef JSON_GENERATOR
-static FBuffer *fbuffer_dup(FBuffer *fb);
-static VALUE fbuffer_to_s(FBuffer *fb);
-#endif
+}
-static FBuffer *fbuffer_alloc(unsigned long initial_length)
+static inline void fbuffer_consumed(FBuffer *fb, size_t consumed)
{
- FBuffer *fb;
- if (initial_length <= 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
- fb = ALLOC(FBuffer);
- memset((void *) fb, 0, sizeof(FBuffer));
- fb->initial_length = initial_length;
- return fb;
+#if JSON_DEBUG
+ if (consumed > fb->requested) {
+ rb_bug("fbuffer: Out of bound write");
+ }
+ fb->requested = 0;
+#endif
+ fb->len += consumed;
}
static void fbuffer_free(FBuffer *fb)
{
- if (fb->ptr) ruby_xfree(fb->ptr);
- ruby_xfree(fb);
+ if (fb->ptr && fb->type == FBUFFER_HEAP_ALLOCATED) {
+ ruby_xfree(fb->ptr);
+ }
}
static void fbuffer_clear(FBuffer *fb)
@@ -91,97 +73,188 @@ static void fbuffer_clear(FBuffer *fb)
fb->len = 0;
}
-static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
+static void fbuffer_flush(FBuffer *fb)
{
- unsigned long required;
+ rb_io_write(fb->io, rb_utf8_str_new(fb->ptr, fb->len));
+ fbuffer_clear(fb);
+}
- if (!fb->ptr) {
+static void fbuffer_realloc(FBuffer *fb, size_t required)
+{
+ if (required > fb->capa) {
+ if (fb->type == FBUFFER_STACK_ALLOCATED) {
+ const char *old_buffer = fb->ptr;
+ fb->ptr = ALLOC_N(char, required);
+ fb->type = FBUFFER_HEAP_ALLOCATED;
+ MEMCPY(fb->ptr, old_buffer, char, fb->len);
+ } else {
+ REALLOC_N(fb->ptr, char, required);
+ }
+ fb->capa = required;
+ }
+}
+
+static void fbuffer_do_inc_capa(FBuffer *fb, size_t requested)
+{
+ if (RB_UNLIKELY(fb->io)) {
+ if (fb->capa < FBUFFER_IO_BUFFER_SIZE) {
+ fbuffer_realloc(fb, FBUFFER_IO_BUFFER_SIZE);
+ } else {
+ fbuffer_flush(fb);
+ }
+
+ if (RB_LIKELY(requested < fb->capa)) {
+ return;
+ }
+ }
+
+ size_t required;
+
+ if (RB_UNLIKELY(!fb->ptr)) {
fb->ptr = ALLOC_N(char, fb->initial_length);
fb->capa = fb->initial_length;
}
for (required = fb->capa; requested > required - fb->len; required <<= 1);
- if (required > fb->capa) {
- REALLOC_N(fb->ptr, char, required);
- fb->capa = required;
+ fbuffer_realloc(fb, required);
+}
+
+static inline void fbuffer_inc_capa(FBuffer *fb, size_t requested)
+{
+#if JSON_DEBUG
+ fb->requested = requested;
+#endif
+
+ if (RB_UNLIKELY(requested > fb->capa - fb->len)) {
+ fbuffer_do_inc_capa(fb, requested);
+ }
+}
+
+static inline size_t fbuffer_size_mul_or_raise(size_t a, size_t b)
+{
+ size_t result = a * b;
+ if (RB_UNLIKELY(a != 0 && (result / a) != b)) {
+ rb_raise(rb_eArgError, "Buffer overflow, the resulting document is too large to be generated");
}
+ return result;
}
-static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
+static inline void fbuffer_append_reserved(FBuffer *fb, const char *newstr, size_t len)
+{
+ MEMCPY(fb->ptr + fb->len, newstr, char, len);
+ fbuffer_consumed(fb, len);
+}
+
+static inline void fbuffer_append(FBuffer *fb, const char *newstr, size_t len)
{
if (len > 0) {
fbuffer_inc_capa(fb, len);
- MEMCPY(fb->ptr + fb->len, newstr, char, len);
- fb->len += len;
+ fbuffer_append_reserved(fb, newstr, len);
}
}
-#ifdef JSON_GENERATOR
+/* Appends a character into a buffer. The buffer needs to have sufficient capacity, via fbuffer_inc_capa(...). */
+static inline void fbuffer_append_reserved_char(FBuffer *fb, char chr)
+{
+#if JSON_DEBUG
+ if (fb->requested < 1) {
+ rb_bug("fbuffer: unreserved write");
+ }
+ fb->requested--;
+#endif
+
+ fb->ptr[fb->len] = chr;
+ fb->len++;
+}
+
static void fbuffer_append_str(FBuffer *fb, VALUE str)
{
- const char *newstr = StringValuePtr(str);
- unsigned long len = RSTRING_LEN(str);
+ const char *ptr;
+ size_t len;
+ RSTRING_GETMEM(str, ptr, len);
+ fbuffer_append(fb, ptr, len);
RB_GC_GUARD(str);
-
- fbuffer_append(fb, newstr, len);
}
+
+static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat)
+{
+ const char *ptr;
+ size_t len;
+ RSTRING_GETMEM(str, ptr, len);
+
+ fbuffer_inc_capa(fb, fbuffer_size_mul_or_raise(repeat, len));
+ while (repeat) {
+#if JSON_DEBUG
+ fb->requested = len;
#endif
+ fbuffer_append_reserved(fb, ptr, len);
+ repeat--;
+ }
+ RB_GC_GUARD(str);
+}
-static void fbuffer_append_char(FBuffer *fb, char newchr)
+static inline void fbuffer_append_char(FBuffer *fb, char newchr)
{
fbuffer_inc_capa(fb, 1);
*(fb->ptr + fb->len) = newchr;
- fb->len++;
+ fbuffer_consumed(fb, 1);
}
-#ifdef JSON_GENERATOR
-static void freverse(char *start, char *end)
+static inline char *fbuffer_cursor(FBuffer *fb)
{
- char c;
-
- while (end > start) {
- c = *end, *end-- = *start, *start++ = c;
- }
+ return fb->ptr + fb->len;
}
-static long fltoa(long number, char *buf)
+static inline void fbuffer_advance_to(FBuffer *fb, char *end)
{
- static char digits[] = "0123456789";
- long sign = number;
- char* tmp = buf;
-
- if (sign < 0) number = -number;
- do *tmp++ = digits[number % 10]; while (number /= 10);
- if (sign < 0) *tmp++ = '-';
- freverse(buf, tmp - 1);
- return tmp - buf;
+ fbuffer_consumed(fb, (end - fb->ptr) - fb->len);
}
+/*
+ * Appends the decimal string representation of \a number into the buffer.
+ */
static void fbuffer_append_long(FBuffer *fb, long number)
{
- char buf[20];
- unsigned long len = fltoa(number, buf);
- fbuffer_append(fb, buf, len);
-}
-
-static FBuffer *fbuffer_dup(FBuffer *fb)
-{
- unsigned long len = fb->len;
- FBuffer *result;
+ /*
+ * The jeaiii_ultoa() function produces digits left-to-right,
+ * allowing us to write directly into the buffer, but we don't know
+ * the number of resulting characters.
+ *
+ * We do know, however, that the `number` argument is always in the
+ * range 0xc000000000000000 to 0x3fffffffffffffff, or, in decimal,
+ * -4611686018427387904 to 4611686018427387903. The max number of chars
+ * generated is therefore 20 (including a potential sign character).
+ */
+
+ static const int MAX_CHARS_FOR_LONG = 20;
+
+ fbuffer_inc_capa(fb, MAX_CHARS_FOR_LONG);
+
+ if (number < 0) {
+ fbuffer_append_reserved_char(fb, '-');
+
+ /*
+ * Since number is always > LONG_MIN, `-number` will not overflow
+ * and is always the positive abs() value.
+ */
+ number = -number;
+ }
- result = fbuffer_alloc(len);
- fbuffer_append(result, FBUFFER_PAIR(fb));
- return result;
+ char *end = jeaiii_ultoa(fbuffer_cursor(fb), number);
+ fbuffer_advance_to(fb, end);
}
-static VALUE fbuffer_to_s(FBuffer *fb)
+static VALUE fbuffer_finalize(FBuffer *fb)
{
- VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));
- fbuffer_free(fb);
- FORCE_UTF8(result);
- return result;
+ if (fb->io) {
+ fbuffer_flush(fb);
+ rb_io_flush(fb->io);
+ return fb->io;
+ } else {
+ return rb_utf8_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));
+ }
}
-#endif
-#endif
+
+#endif // _FBUFFER_H_
diff --git a/ext/json/generator/depend b/ext/json/generator/depend
index 42752d1a35..3ba4acfdd2 100644
--- a/ext/json/generator/depend
+++ b/ext/json/generator/depend
@@ -1,5 +1,5 @@
$(OBJS): $(ruby_headers)
-generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
+generator.o: generator.c $(srcdir)/../fbuffer/fbuffer.h
# AUTOGENERATED DEPENDENCIES START
generator.o: $(RUBY_EXTCONF_H)
@@ -142,6 +142,7 @@ generator.o: $(hdrdir)/ruby/internal/intern/re.h
generator.o: $(hdrdir)/ruby/internal/intern/ruby.h
generator.o: $(hdrdir)/ruby/internal/intern/select.h
generator.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+generator.o: $(hdrdir)/ruby/internal/intern/set.h
generator.o: $(hdrdir)/ruby/internal/intern/signal.h
generator.o: $(hdrdir)/ruby/internal/intern/sprintf.h
generator.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -161,6 +162,7 @@ generator.o: $(hdrdir)/ruby/internal/special_consts.h
generator.o: $(hdrdir)/ruby/internal/static_assert.h
generator.o: $(hdrdir)/ruby/internal/stdalign.h
generator.o: $(hdrdir)/ruby/internal/stdbool.h
+generator.o: $(hdrdir)/ruby/internal/stdckdint.h
generator.o: $(hdrdir)/ruby/internal/symbol.h
generator.o: $(hdrdir)/ruby/internal/value.h
generator.o: $(hdrdir)/ruby/internal/value_type.h
@@ -176,6 +178,9 @@ generator.o: $(hdrdir)/ruby/ruby.h
generator.o: $(hdrdir)/ruby/st.h
generator.o: $(hdrdir)/ruby/subst.h
generator.o: $(srcdir)/../fbuffer/fbuffer.h
+generator.o: $(srcdir)/../json.h
+generator.o: $(srcdir)/../simd/simd.h
+generator.o: $(srcdir)/../vendor/fpconv.c
+generator.o: $(srcdir)/../vendor/jeaiii-ltoa.h
generator.o: generator.c
-generator.o: generator.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/json/generator/extconf.rb b/ext/json/generator/extconf.rb
index 8627c5f4bd..205a887e78 100644
--- a/ext/json/generator/extconf.rb
+++ b/ext/json/generator/extconf.rb
@@ -1,4 +1,18 @@
require 'mkmf'
-$defs << "-DJSON_GENERATOR"
-create_makefile 'json/ext/generator'
+if RUBY_ENGINE == 'truffleruby'
+ # The pure-Ruby generator is faster on TruffleRuby, so skip compiling the generator extension
+ File.write('Makefile', dummy_makefile("").join)
+else
+ append_cflags("-std=c99")
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
+
+ $defs << "-DJSON_GENERATOR"
+ $defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
+
+ if enable_config('generator-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
+ load __dir__ + "/../simd/conf.rb"
+ end
+
+ create_makefile 'json/ext/generator'
+end
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 98d0ea46c3..110b5f6b32 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -1,1126 +1,1353 @@
+#include "../json.h"
#include "../fbuffer/fbuffer.h"
-#include "generator.h"
+#include "../vendor/fpconv.c"
-static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
- mHash, mArray,
-#ifdef RUBY_INTEGER_UNIFICATION
- mInteger,
-#else
- mFixnum, mBignum,
-#endif
- mFloat, mString, mString_Extend,
- mTrueClass, mFalseClass, mNilClass, eGeneratorError,
- eNestingError;
+#include <math.h>
+#include <ctype.h>
-static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
- i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
- i_pack, i_unpack, i_create_id, i_extend, i_key_p,
- i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth,
- i_buffer_initial_length, i_dup, i_escape_slash;
+#include "../simd/simd.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.
- */
+/* ruby api and some helpers */
-/*
- * 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
+enum duplicate_key_action {
+ JSON_DEPRECATED = 0,
+ JSON_IGNORE,
+ JSON_RAISE,
};
-/*
- * 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 };
+typedef struct JSON_Generator_StateStruct {
+ VALUE indent;
+ VALUE space;
+ VALUE space_before;
+ VALUE object_nl;
+ VALUE array_nl;
+ VALUE as_json;
-/*
- * 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.
- */
-static unsigned char isLegalUTF8(const UTF8 *source, unsigned long 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;
- }
+ long max_nesting;
+ long depth;
+ long buffer_initial_length;
- case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
- }
- if (*source > 0xF4) return 0;
- return 1;
-}
+ enum duplicate_key_action on_duplicate_key;
-/* Escapes the UTF16 character and stores the result in the buffer buf. */
-static void unicode_escape(char *buf, UTF16 character)
-{
- const char *digits = "0123456789abcdef";
+ bool as_json_single_arg;
+ bool allow_nan;
+ bool ascii_only;
+ bool script_safe;
+ bool strict;
+} JSON_Generator_State;
- buf[2] = digits[character >> 12];
- buf[3] = digits[(character >> 8) & 0xf];
- buf[4] = digits[(character >> 4) & 0xf];
- buf[5] = digits[character & 0xf];
-}
+static VALUE mJSON, cState, cFragment, eGeneratorError, eNestingError, Encoding_UTF_8;
+
+static ID i_to_s, i_to_json, i_new, i_encode;
+static VALUE sym_indent, sym_space, sym_space_before, sym_object_nl, sym_array_nl, sym_max_nesting, sym_allow_nan, sym_allow_duplicate_key,
+ sym_ascii_only, sym_depth, sym_buffer_initial_length, sym_script_safe, sym_escape_slash, sym_strict, sym_as_json;
+
+
+#define GET_STATE_TO(self, state) \
+ TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
+
+#define GET_STATE(self) \
+ JSON_Generator_State *state; \
+ GET_STATE_TO(self, state)
+
+struct generate_json_data;
+
+typedef void (*generator_func)(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+
+struct generate_json_data {
+ FBuffer *buffer;
+ VALUE vstate;
+ JSON_Generator_State *state;
+ VALUE obj;
+ generator_func func;
+ long depth;
+};
+
+static SIMD_Implementation simd_impl;
+
+static VALUE cState_from_state_s(VALUE self, VALUE opts);
+static VALUE cState_partial_generate(VALUE self, VALUE obj, generator_func, VALUE io);
+static void generate_json(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_object(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_array(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_string(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_null(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_false(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_true(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_fixnum(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_bignum(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_float(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+static void generate_json_fragment(FBuffer *buffer, struct generate_json_data *data, VALUE obj);
+
+static int usascii_encindex, utf8_encindex, binary_encindex;
-/* Escapes the UTF16 character and stores the result in the buffer buf, then
- * the buffer buf is appended to the FBuffer buffer. */
-static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16
- character)
+NORETURN(static void) raise_generator_error_str(VALUE invalid_object, VALUE str)
{
- unicode_escape(buf, character);
- fbuffer_append(buffer, buf, 6);
+ rb_enc_associate_index(str, utf8_encindex);
+ VALUE exc = rb_exc_new_str(eGeneratorError, str);
+ rb_ivar_set(exc, rb_intern("@invalid_object"), invalid_object);
+ rb_exc_raise(exc);
}
-/* Converts string to a JSON string in FBuffer buffer, where all but the ASCII
- * and control characters are JSON escaped. */
-static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash)
+#ifdef RBIMPL_ATTR_FORMAT
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
+#endif
+NORETURN(static void) raise_generator_error(VALUE invalid_object, const char *fmt, ...)
{
- const UTF8 *source = (UTF8 *) RSTRING_PTR(string);
- const UTF8 *sourceEnd = source + RSTRING_LEN(string);
- char buf[6] = { '\\', 'u' };
+ va_list args;
+ va_start(args, fmt);
+ VALUE str = rb_vsprintf(fmt, args);
+ va_end(args);
+ raise_generator_error_str(invalid_object, str);
+}
- 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 utf-8");
- }
- /*
- * 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 UNI_STRICT_CONVERSION
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed utf-8");
-#else
- unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
-#endif
- } else {
- /* normal case */
- if (ch >= 0x20 && ch <= 0x7f) {
- switch (ch) {
- case '\\':
- fbuffer_append(buffer, "\\\\", 2);
- break;
- case '"':
- fbuffer_append(buffer, "\\\"", 2);
- break;
- case '/':
- if(escape_slash) {
- fbuffer_append(buffer, "\\/", 2);
- break;
- }
- default:
- fbuffer_append_char(buffer, (char)ch);
- break;
- }
- } else {
- switch (ch) {
- case '\n':
- fbuffer_append(buffer, "\\n", 2);
- break;
- case '\r':
- fbuffer_append(buffer, "\\r", 2);
- break;
- case '\t':
- fbuffer_append(buffer, "\\t", 2);
- break;
- case '\f':
- fbuffer_append(buffer, "\\f", 2);
- break;
- case '\b':
- fbuffer_append(buffer, "\\b", 2);
- break;
- default:
- unicode_escape_to_buffer(buffer, buf, (UTF16) ch);
- break;
- }
- }
- }
- } else if (ch > UNI_MAX_UTF16) {
-#if UNI_STRICT_CONVERSION
- source -= (extraBytesToRead+1); /* return to the start */
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed utf8");
+// 0 - single byte char that don't need to be escaped.
+// (x | 8) - char that needs to be escaped.
+static const unsigned char CHAR_LENGTH_MASK = 7;
+static const unsigned char ESCAPE_MASK = 8;
+
+typedef struct _search_state {
+ const char *ptr;
+ const char *end;
+ const char *cursor;
+ FBuffer *buffer;
+
+#ifdef HAVE_SIMD
+ const char *chunk_base;
+ const char *chunk_end;
+ bool has_matches;
+
+#if defined(HAVE_SIMD_NEON)
+ uint64_t matches_mask;
+#elif defined(HAVE_SIMD_SSE2)
+ int matches_mask;
#else
- unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
-#endif
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- ch -= halfBase;
- unicode_escape_to_buffer(buffer, buf, (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START));
- unicode_escape_to_buffer(buffer, buf, (UTF16)((ch & halfMask) + UNI_SUR_LOW_START));
- }
+#error "Unknown SIMD Implementation."
+#endif /* HAVE_SIMD_NEON */
+#endif /* HAVE_SIMD */
+} search_state;
+
+ALWAYS_INLINE(static) void search_flush(search_state *search)
+{
+ // Do not remove this conditional without profiling, specifically escape-heavy text.
+ // escape_UTF8_char_basic will advance search->ptr and search->cursor (effectively a search_flush).
+ // For back-to-back characters that need to be escaped, specifically for the SIMD code paths, this method
+ // will be called just before calling escape_UTF8_char_basic. There will be no characters to append for the
+ // consecutive characters that need to be escaped. While the fbuffer_append is a no-op if
+ // nothing needs to be flushed, we can save a few memory references with this conditional.
+ if (search->ptr > search->cursor) {
+ fbuffer_append(search->buffer, search->cursor, search->ptr - search->cursor);
+ search->cursor = search->ptr;
}
- RB_GC_GUARD(string);
-}
-
-/* Converts string to a JSON string in FBuffer buffer, where only the
- * characters required by the JSON standard are JSON escaped. The remaining
- * characters (should be UTF8) are just passed through and appended to the
- * result. */
-static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash)
-{
- const char *ptr = RSTRING_PTR(string), *p;
- unsigned long len = RSTRING_LEN(string), start = 0, end = 0;
- const char *escape = NULL;
- int escape_len;
- unsigned char c;
- char buf[6] = { '\\', 'u' };
- int ascii_only = rb_enc_str_asciionly_p(string);
-
- for (start = 0, end = 0; end < len;) {
- p = ptr + end;
- c = (unsigned char) *p;
- if (c < 0x20) {
- switch (c) {
- case '\n':
- escape = "\\n";
- escape_len = 2;
- break;
- case '\r':
- escape = "\\r";
- escape_len = 2;
- break;
- case '\t':
- escape = "\\t";
- escape_len = 2;
- break;
- case '\f':
- escape = "\\f";
- escape_len = 2;
- break;
- case '\b':
- escape = "\\b";
- escape_len = 2;
- break;
- default:
- unicode_escape(buf, (UTF16) *p);
- escape = buf;
- escape_len = 6;
- break;
- }
+}
+
+static const unsigned char escape_table_basic[256] = {
+ // ASCII Control Characters
+ 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,
+ // ASCII Characters
+ 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // '"'
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, // '\\'
+ 0, 0, 0, 0, 0, 0, 0, 0, 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 inline unsigned char search_escape_basic(search_state *search)
+{
+ while (search->ptr < search->end) {
+ if (RB_UNLIKELY(escape_table_basic[(const unsigned char)*search->ptr])) {
+ search_flush(search);
+ return 1;
} else {
- switch (c) {
- case '\\':
- escape = "\\\\";
- escape_len = 2;
- break;
- case '"':
- escape = "\\\"";
- escape_len = 2;
- break;
- case '/':
- if(escape_slash) {
- escape = "\\/";
- escape_len = 2;
- break;
- }
- default:
- {
- unsigned short clen = 1;
- if (!ascii_only) {
- clen += trailingBytesForUTF8[c];
- if (end + clen > len) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "partial character in source, but hit end");
- }
- if (!isLegalUTF8((UTF8 *) p, clen)) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed utf-8");
- }
- }
- end += clen;
- }
- continue;
- break;
- }
+ search->ptr++;
}
- fbuffer_append(buffer, ptr + start, end - start);
- fbuffer_append(buffer, escape, escape_len);
- start = ++end;
- escape = NULL;
}
- fbuffer_append(buffer, ptr + start, end - start);
+ search_flush(search);
+ return 0;
}
-static char *fstrndup(const char *ptr, unsigned long len) {
- char *result;
- if (len <= 0) return NULL;
- result = ALLOC_N(char, len);
- memcpy(result, ptr, len);
- return result;
+ALWAYS_INLINE(static) void escape_UTF8_char_basic(search_state *search)
+{
+ const unsigned char ch = (unsigned char)*search->ptr;
+ switch (ch) {
+ case '"': fbuffer_append(search->buffer, "\\\"", 2); break;
+ case '\\': fbuffer_append(search->buffer, "\\\\", 2); break;
+ case '/': fbuffer_append(search->buffer, "\\/", 2); break;
+ case '\b': fbuffer_append(search->buffer, "\\b", 2); break;
+ case '\f': fbuffer_append(search->buffer, "\\f", 2); break;
+ case '\n': fbuffer_append(search->buffer, "\\n", 2); break;
+ case '\r': fbuffer_append(search->buffer, "\\r", 2); break;
+ case '\t': fbuffer_append(search->buffer, "\\t", 2); break;
+ default: {
+ const char *hexdig = "0123456789abcdef";
+ char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
+ scratch[4] = hexdig[(ch >> 4) & 0xf];
+ scratch[5] = hexdig[ch & 0xf];
+ fbuffer_append(search->buffer, scratch, 6);
+ break;
+ }
+ }
+ search->ptr++;
+ search->cursor = search->ptr;
}
-/*
- * Document-module: JSON::Ext::Generator
+/* Converts in_string to a JSON string (without the wrapping '"'
+ * characters) in FBuffer out_buffer.
+ *
+ * Character are JSON-escaped according to:
*
- * This is the JSON generator implemented as a C extension. It can be
- * configured to be used by setting
+ * - Always: ASCII control characters (0x00-0x1F), dquote, and
+ * backslash.
*
- * JSON.generator = JSON::Ext::Generator
+ * - If out_ascii_only: non-ASCII characters (>0x7F)
*
- * with the method generator= in JSON.
+ * - If script_safe: forwardslash (/), line separator (U+2028), and
+ * paragraph separator (U+2029)
*
+ * Everything else (should be UTF-8) is just passed through and
+ * appended to the result.
*/
-/* Explanation of the following: that's the only way to not pollute
- * standard library's docs with GeneratorMethods::<ClassName> which
- * are uninformative and take a large place in a list of classes
- */
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods
- * :nodoc:
- */
+#if defined(HAVE_SIMD_NEON)
+static inline unsigned char search_escape_basic_neon(search_state *search);
+#elif defined(HAVE_SIMD_SSE2)
+static inline unsigned char search_escape_basic_sse2(search_state *search);
+#endif
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Array
- * :nodoc:
- */
+static inline unsigned char search_escape_basic(search_state *search);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Bignum
- * :nodoc:
- */
-
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::FalseClass
- * :nodoc:
- */
+static inline void convert_UTF8_to_JSON(search_state *search)
+{
+#ifdef HAVE_SIMD
+#if defined(HAVE_SIMD_NEON)
+ while (search_escape_basic_neon(search)) {
+ escape_UTF8_char_basic(search);
+ }
+#elif defined(HAVE_SIMD_SSE2)
+ if (simd_impl == SIMD_SSE2) {
+ while (search_escape_basic_sse2(search)) {
+ escape_UTF8_char_basic(search);
+ }
+ return;
+ }
+ while (search_escape_basic(search)) {
+ escape_UTF8_char_basic(search);
+ }
+#endif
+#else
+ while (search_escape_basic(search)) {
+ escape_UTF8_char_basic(search);
+ }
+#endif /* HAVE_SIMD */
+}
+
+static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
+{
+ const unsigned char ch = (unsigned char)*search->ptr;
+ switch (ch_len) {
+ case 1: {
+ switch (ch) {
+ case '"': fbuffer_append(search->buffer, "\\\"", 2); break;
+ case '\\': fbuffer_append(search->buffer, "\\\\", 2); break;
+ case '/': fbuffer_append(search->buffer, "\\/", 2); break;
+ case '\b': fbuffer_append(search->buffer, "\\b", 2); break;
+ case '\f': fbuffer_append(search->buffer, "\\f", 2); break;
+ case '\n': fbuffer_append(search->buffer, "\\n", 2); break;
+ case '\r': fbuffer_append(search->buffer, "\\r", 2); break;
+ case '\t': fbuffer_append(search->buffer, "\\t", 2); break;
+ default: {
+ const char *hexdig = "0123456789abcdef";
+ char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
+ scratch[4] = hexdig[(ch >> 4) & 0xf];
+ scratch[5] = hexdig[ch & 0xf];
+ fbuffer_append(search->buffer, scratch, 6);
+ break;
+ }
+ }
+ break;
+ }
+ case 3: {
+ if (search->ptr[2] & 1) {
+ fbuffer_append(search->buffer, "\\u2029", 6);
+ } else {
+ fbuffer_append(search->buffer, "\\u2028", 6);
+ }
+ break;
+ }
+ }
+ search->cursor = (search->ptr += ch_len);
+}
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Fixnum
- * :nodoc:
- */
+#ifdef HAVE_SIMD
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Float
- * :nodoc:
- */
+ALWAYS_INLINE(static) char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
+{
+ RBIMPL_ASSERT_OR_ASSUME(len < vec_len);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Hash
- * :nodoc:
- */
+ // Flush the buffer so everything up until the last 'len' characters are unflushed.
+ search_flush(search);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Integer
- * :nodoc:
- */
+ FBuffer *buf = search->buffer;
+ fbuffer_inc_capa(buf, vec_len);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::NilClass
- * :nodoc:
- */
+ char *s = (buf->ptr + buf->len);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::Object
- * :nodoc:
- */
+ // Pad the buffer with dummy characters that won't need escaping.
+ // This seem wasteful at first sight, but memset of vector length is very fast.
+ // This is a space as it can be directly represented as an immediate on AArch64.
+ memset(s, ' ', vec_len);
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::String
- * :nodoc:
- */
+ // Optimistically copy the remaining 'len' characters to the output FBuffer. If there are no characters
+ // to escape, then everything ends up in the correct spot. Otherwise it was convenient temporary storage.
+ if (vec_len == 16) {
+ RBIMPL_ASSERT_OR_ASSUME(len >= SIMD_MINIMUM_THRESHOLD);
+ json_fast_memcpy16(s, search->ptr, len);
+ } else {
+ MEMCPY(s, search->ptr, char, len);
+ }
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::String::Extend
- * :nodoc:
- */
+ return s;
+}
-/*
- * Document-module: JSON::Ext::Generator::GeneratorMethods::TrueClass
- * :nodoc:
- */
+#ifdef HAVE_SIMD_NEON
-/*
- * call-seq: to_json(state = nil)
- *
- * Returns a JSON string containing a JSON object, that is generated from
- * this Hash instance.
- * _state_ is a JSON::State object, that can also be used to configure the
- * produced JSON string output further.
- */
-static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
+ALWAYS_INLINE(static) unsigned char neon_next_match(search_state *search)
{
- GENERATE_JSON(object);
+ uint64_t mask = search->matches_mask;
+ uint32_t index = trailing_zeros64(mask) >> 2;
+
+ // It is assumed escape_UTF8_char_basic will only ever increase search->ptr by at most one character.
+ // If we want to use a similar approach for full escaping we'll need to ensure:
+ // search->chunk_base + index >= search->ptr
+ // However, since we know escape_UTF8_char_basic only increases search->ptr by one, if the next match
+ // is one byte after the previous match then:
+ // search->chunk_base + index == search->ptr
+ search->ptr = search->chunk_base + index;
+ mask &= mask - 1;
+ search->matches_mask = mask;
+ search_flush(search);
+ return 1;
}
-/*
- * call-seq: to_json(state = nil)
- *
- * Returns a JSON string containing a JSON array, that is generated from
- * this Array instance.
- * _state_ is a JSON::State object, that can also be used to configure the
- * produced JSON string output further.
- */
-static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
- GENERATE_JSON(array);
+static inline unsigned char search_escape_basic_neon(search_state *search)
+{
+ if (RB_UNLIKELY(search->has_matches)) {
+ // There are more matches if search->matches_mask > 0.
+ if (search->matches_mask > 0) {
+ return neon_next_match(search);
+ } else {
+ // neon_next_match will only advance search->ptr up to the last matching character.
+ // Skip over any characters in the last chunk that occur after the last match.
+ search->has_matches = false;
+ search->ptr = search->chunk_end;
+ }
+ }
+
+ /*
+ * The code below implements an SIMD-based algorithm to determine if N bytes at a time
+ * need to be escaped.
+ *
+ * Assume the ptr = "Te\sting!" (the double quotes are included in the string)
+ *
+ * The explanation will be limited to the first 8 bytes of the string for simplicity. However
+ * the vector insructions may work on larger vectors.
+ *
+ * First, we load three constants 'lower_bound', 'backslash' and 'dblquote" in vector registers.
+ *
+ * lower_bound: [20 20 20 20 20 20 20 20]
+ * backslash: [5C 5C 5C 5C 5C 5C 5C 5C]
+ * dblquote: [22 22 22 22 22 22 22 22]
+ *
+ * Next we load the first chunk of the ptr:
+ * [22 54 65 5C 73 74 69 6E] (" T e \ s t i n)
+ *
+ * First we check if any byte in chunk is less than 32 (0x20). This returns the following vector
+ * as no bytes are less than 32 (0x20):
+ * [0 0 0 0 0 0 0 0]
+ *
+ * Next, we check if any byte in chunk is equal to a backslash:
+ * [0 0 0 FF 0 0 0 0]
+ *
+ * Finally we check if any byte in chunk is equal to a double quote:
+ * [FF 0 0 0 0 0 0 0]
+ *
+ * Now we have three vectors where each byte indicates if the corresponding byte in chunk
+ * needs to be escaped. We combine these vectors with a series of logical OR instructions.
+ * This is the needs_escape vector and it is equal to:
+ * [FF 0 0 FF 0 0 0 0]
+ *
+ * Next we compute the bitwise AND between each byte and 0x1 and compute the horizontal sum of
+ * the values in the vector. This computes how many bytes need to be escaped within this chunk.
+ *
+ * Finally we compute a mask that indicates which bytes need to be escaped. If the mask is 0 then,
+ * no bytes need to be escaped and we can continue to the next chunk. If the mask is not 0 then we
+ * have at least one byte that needs to be escaped.
+ */
+
+ if (string_scan_simd_neon(&search->ptr, search->end, &search->matches_mask)) {
+ search->has_matches = true;
+ search->chunk_base = search->ptr;
+ search->chunk_end = search->ptr + sizeof(uint8x16_t);
+ return neon_next_match(search);
+ }
+
+ // There are fewer than 16 bytes left.
+ unsigned long remaining = (search->end - search->ptr);
+ if (remaining >= SIMD_MINIMUM_THRESHOLD) {
+ char *s = copy_remaining_bytes(search, sizeof(uint8x16_t), remaining);
+
+ uint64_t mask = compute_chunk_mask_neon(s);
+
+ if (!mask) {
+ // Nothing to escape, ensure search_flush doesn't do anything by setting
+ // search->cursor to search->ptr.
+ fbuffer_consumed(search->buffer, remaining);
+ search->ptr = search->end;
+ search->cursor = search->end;
+ return 0;
+ }
+
+ search->matches_mask = mask;
+ search->has_matches = true;
+ search->chunk_end = search->end;
+ search->chunk_base = search->ptr;
+ return neon_next_match(search);
+ }
+
+ if (search->ptr < search->end) {
+ return search_escape_basic(search);
+ }
+
+ search_flush(search);
+ return 0;
}
+#endif /* HAVE_SIMD_NEON */
-#ifdef RUBY_INTEGER_UNIFICATION
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Integer number.
- */
-static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self)
+#ifdef HAVE_SIMD_SSE2
+
+ALWAYS_INLINE(static) unsigned char sse2_next_match(search_state *search)
{
- GENERATE_JSON(integer);
+ int mask = search->matches_mask;
+ int index = trailing_zeros(mask);
+
+ // It is assumed escape_UTF8_char_basic will only ever increase search->ptr by at most one character.
+ // If we want to use a similar approach for full escaping we'll need to ensure:
+ // search->chunk_base + index >= search->ptr
+ // However, since we know escape_UTF8_char_basic only increases search->ptr by one, if the next match
+ // is one byte after the previous match then:
+ // search->chunk_base + index == search->ptr
+ search->ptr = search->chunk_base + index;
+ mask &= mask - 1;
+ search->matches_mask = mask;
+ search_flush(search);
+ return 1;
}
+#if defined(__clang__) || defined(__GNUC__)
+#define TARGET_SSE2 __attribute__((target("sse2")))
#else
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Integer number.
- */
-static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self)
+#define TARGET_SSE2
+#endif
+
+ALWAYS_INLINE(static) TARGET_SSE2 unsigned char search_escape_basic_sse2(search_state *search)
{
- GENERATE_JSON(fixnum);
+ if (RB_UNLIKELY(search->has_matches)) {
+ // There are more matches if search->matches_mask > 0.
+ if (search->matches_mask > 0) {
+ return sse2_next_match(search);
+ } else {
+ // sse2_next_match will only advance search->ptr up to the last matching character.
+ // Skip over any characters in the last chunk that occur after the last match.
+ search->has_matches = false;
+ if (RB_UNLIKELY(search->chunk_base + sizeof(__m128i) >= search->end)) {
+ search->ptr = search->end;
+ } else {
+ search->ptr = search->chunk_base + sizeof(__m128i);
+ }
+ }
+ }
+
+ if (string_scan_simd_sse2(&search->ptr, search->end, &search->matches_mask)) {
+ search->has_matches = true;
+ search->chunk_base = search->ptr;
+ search->chunk_end = search->ptr + sizeof(__m128i);
+ return sse2_next_match(search);
+ }
+
+ // There are fewer than 16 bytes left.
+ unsigned long remaining = (search->end - search->ptr);
+ if (remaining >= SIMD_MINIMUM_THRESHOLD) {
+ char *s = copy_remaining_bytes(search, sizeof(__m128i), remaining);
+
+ int needs_escape_mask = compute_chunk_mask_sse2(s);
+
+ if (needs_escape_mask == 0) {
+ // Nothing to escape, ensure search_flush doesn't do anything by setting
+ // search->cursor to search->ptr.
+ fbuffer_consumed(search->buffer, remaining);
+ search->ptr = search->end;
+ search->cursor = search->end;
+ return 0;
+ }
+
+ search->has_matches = true;
+ search->matches_mask = needs_escape_mask;
+ search->chunk_base = search->ptr;
+ return sse2_next_match(search);
+ }
+
+ if (search->ptr < search->end) {
+ return search_escape_basic(search);
+ }
+
+ search_flush(search);
+ return 0;
}
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Integer number.
- */
-static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self)
+#endif /* HAVE_SIMD_SSE2 */
+
+#endif /* HAVE_SIMD */
+
+static const unsigned char script_safe_escape_table[256] = {
+ // ASCII Control Characters
+ 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,
+ // ASCII Characters
+ 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, // '"' and '/'
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, // '\\'
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // Continuation byte
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ // First byte of a 2-byte code point
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ // First byte of a 3-byte code point
+ 3, 3,11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xE2 is the start of \u2028 and \u2029
+ //First byte of a 4+ byte code point
+ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 9, 9,
+};
+
+static inline unsigned char search_script_safe_escape(search_state *search)
{
- GENERATE_JSON(bignum);
+ while (search->ptr < search->end) {
+ unsigned char ch = (unsigned char)*search->ptr;
+ unsigned char ch_len = script_safe_escape_table[ch];
+
+ if (RB_UNLIKELY(ch_len)) {
+ if (ch_len & ESCAPE_MASK) {
+ if (RB_UNLIKELY(ch_len == 11)) {
+ const unsigned char *uptr = (const unsigned char *)search->ptr;
+ if (!(uptr[1] == 0x80 && (uptr[2] >> 1) == 0x54)) {
+ search->ptr += 3;
+ continue;
+ }
+ }
+ search_flush(search);
+ return ch_len & CHAR_LENGTH_MASK;
+ } else {
+ search->ptr += ch_len;
+ }
+ } else {
+ search->ptr++;
+ }
+ }
+ search_flush(search);
+ return 0;
}
-#endif
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Float number.
- */
-static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
+static void convert_UTF8_to_script_safe_JSON(search_state *search)
{
- GENERATE_JSON(float);
+ unsigned char ch_len;
+ while ((ch_len = search_script_safe_escape(search))) {
+ escape_UTF8_char(search, ch_len);
+ }
}
-/*
- * call-seq: String.included(modul)
- *
- * Extends _modul_ with the String::Extend module.
- */
-static VALUE mString_included_s(VALUE self, VALUE modul) {
- VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
- return result;
+static const unsigned char ascii_only_escape_table[256] = {
+ // ASCII Control Characters
+ 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,
+ // ASCII Characters
+ 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // '"'
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, // '\\'
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // Continuation byte
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ // First byte of a 2-byte code point
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ // First byte of a 3-byte code point
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ //First byte of a 4+ byte code point
+ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 9, 9,
+};
+
+static inline unsigned char search_ascii_only_escape(search_state *search, const unsigned char escape_table[256])
+{
+ while (search->ptr < search->end) {
+ unsigned char ch = (unsigned char)*search->ptr;
+ unsigned char ch_len = escape_table[ch];
+
+ if (RB_UNLIKELY(ch_len)) {
+ search_flush(search);
+ return ch_len & CHAR_LENGTH_MASK;
+ } else {
+ search->ptr++;
+ }
+ }
+ search_flush(search);
+ return 0;
}
-/*
- * 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)
+static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_len)
+{
+ const unsigned char ch = (unsigned char)*search->ptr;
+ switch (ch_len) {
+ case 1: {
+ switch (ch) {
+ case '"': fbuffer_append(search->buffer, "\\\"", 2); break;
+ case '\\': fbuffer_append(search->buffer, "\\\\", 2); break;
+ case '/': fbuffer_append(search->buffer, "\\/", 2); break;
+ case '\b': fbuffer_append(search->buffer, "\\b", 2); break;
+ case '\f': fbuffer_append(search->buffer, "\\f", 2); break;
+ case '\n': fbuffer_append(search->buffer, "\\n", 2); break;
+ case '\r': fbuffer_append(search->buffer, "\\r", 2); break;
+ case '\t': fbuffer_append(search->buffer, "\\t", 2); break;
+ default: {
+ const char *hexdig = "0123456789abcdef";
+ char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
+ scratch[4] = hexdig[(ch >> 4) & 0xf];
+ scratch[5] = hexdig[ch & 0xf];
+ fbuffer_append(search->buffer, scratch, 6);
+ break;
+ }
+ }
+ break;
+ }
+ default: {
+ const char *hexdig = "0123456789abcdef";
+ char scratch[12] = { '\\', 'u', 0, 0, 0, 0, '\\', 'u' };
+
+ uint32_t wchar = 0;
+
+ switch (ch_len) {
+ case 2:
+ wchar = ch & 0x1F;
+ break;
+ case 3:
+ wchar = ch & 0x0F;
+ break;
+ case 4:
+ wchar = ch & 0x07;
+ break;
+ }
+
+ for (short i = 1; i < ch_len; i++) {
+ wchar = (wchar << 6) | (search->ptr[i] & 0x3F);
+ }
+
+ if (wchar <= 0xFFFF) {
+ scratch[2] = hexdig[wchar >> 12];
+ scratch[3] = hexdig[(wchar >> 8) & 0xf];
+ scratch[4] = hexdig[(wchar >> 4) & 0xf];
+ scratch[5] = hexdig[wchar & 0xf];
+ fbuffer_append(search->buffer, scratch, 6);
+ } else {
+ uint16_t hi, lo;
+ wchar -= 0x10000;
+ hi = 0xD800 + (uint16_t)(wchar >> 10);
+ lo = 0xDC00 + (uint16_t)(wchar & 0x3FF);
+
+ scratch[2] = hexdig[hi >> 12];
+ scratch[3] = hexdig[(hi >> 8) & 0xf];
+ scratch[4] = hexdig[(hi >> 4) & 0xf];
+ scratch[5] = hexdig[hi & 0xf];
+
+ scratch[8] = hexdig[lo >> 12];
+ scratch[9] = hexdig[(lo >> 8) & 0xf];
+ scratch[10] = hexdig[(lo >> 4) & 0xf];
+ scratch[11] = hexdig[lo & 0xf];
+
+ fbuffer_append(search->buffer, scratch, 12);
+ }
+
+ break;
+ }
+ }
+ search->cursor = (search->ptr += ch_len);
+}
+
+static void convert_UTF8_to_ASCII_only_JSON(search_state *search, const unsigned char escape_table[256])
{
- GENERATE_JSON(string);
+ unsigned char ch_len;
+ while ((ch_len = search_ascii_only_escape(search, escape_table))) {
+ full_escape_UTF8_char(search, ch_len);
+ }
}
-/*
- * call-seq: to_json_raw_object()
- *
- * This method creates a raw object hash, that can be nested into
- * other data structures and will be generated 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)
+static void State_mark(void *ptr)
{
- 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;
+ JSON_Generator_State *state = ptr;
+ rb_gc_mark_movable(state->indent);
+ rb_gc_mark_movable(state->space);
+ rb_gc_mark_movable(state->space_before);
+ rb_gc_mark_movable(state->object_nl);
+ rb_gc_mark_movable(state->array_nl);
+ rb_gc_mark_movable(state->as_json);
}
-/*
- * 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)
+static void State_compact(void *ptr)
{
- VALUE obj = mString_to_json_raw_object(self);
- Check_Type(obj, T_HASH);
- return mHash_to_json(argc, argv, obj);
+ JSON_Generator_State *state = ptr;
+ state->indent = rb_gc_location(state->indent);
+ state->space = rb_gc_location(state->space);
+ state->space_before = rb_gc_location(state->space_before);
+ state->object_nl = rb_gc_location(state->object_nl);
+ state->array_nl = rb_gc_location(state->array_nl);
+ state->as_json = rb_gc_location(state->as_json);
}
-/*
- * 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)
+static size_t State_memsize(const void *ptr)
{
- 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*"));
+ return sizeof(JSON_Generator_State);
}
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string for true: 'true'.
- */
-static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
+static const rb_data_type_t JSON_Generator_State_type = {
+ .wrap_struct_name = "JSON/Generator/State",
+ .function = {
+ .dmark = State_mark,
+ .dfree = RUBY_DEFAULT_FREE,
+ .dsize = State_memsize,
+ .dcompact = State_compact,
+ },
+ .flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE,
+};
+
+static void state_init(JSON_Generator_State *state)
{
- GENERATE_JSON(true);
+ state->max_nesting = 100;
+ state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
}
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string for false: 'false'.
- */
-static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
+static VALUE cState_s_allocate(VALUE klass)
{
- GENERATE_JSON(false);
+ JSON_Generator_State *state;
+ VALUE obj = TypedData_Make_Struct(klass, JSON_Generator_State, &JSON_Generator_State_type, state);
+ state_init(state);
+ return obj;
}
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string for nil: 'null'.
- */
-static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
+static void vstate_spill(struct generate_json_data *data)
{
- GENERATE_JSON(null);
+ VALUE vstate = cState_s_allocate(cState);
+ GET_STATE(vstate);
+ MEMCPY(state, data->state, JSON_Generator_State, 1);
+ data->state = state;
+ data->vstate = vstate;
+ RB_OBJ_WRITTEN(vstate, Qundef, state->indent);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->space);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->space_before);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->object_nl);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->array_nl);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->as_json);
}
-/*
- * 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)
+static inline VALUE json_call_to_json(struct generate_json_data *data, VALUE obj)
{
- VALUE state;
- VALUE string = rb_funcall(self, i_to_s, 0);
- rb_scan_args(argc, argv, "01", &state);
- Check_Type(string, T_STRING);
- state = cState_from_state_s(cState, state);
- return cState_partial_generate(state, string);
+ if (RB_UNLIKELY(!data->vstate)) {
+ vstate_spill(data);
+ }
+ GET_STATE(data->vstate);
+ state->depth = data->depth;
+ VALUE tmp = rb_funcall(obj, i_to_json, 1, data->vstate);
+ // no need to restore state->depth, vstate is just a temporary State
+ return tmp;
}
-static void State_free(void *ptr)
+static VALUE
+json_call_as_json(JSON_Generator_State *state, VALUE object, VALUE is_key)
{
- JSON_Generator_State *state = ptr;
- if (state->indent) ruby_xfree(state->indent);
- if (state->space) ruby_xfree(state->space);
- if (state->space_before) ruby_xfree(state->space_before);
- if (state->object_nl) ruby_xfree(state->object_nl);
- if (state->array_nl) ruby_xfree(state->array_nl);
- if (state->array_delim) fbuffer_free(state->array_delim);
- if (state->object_delim) fbuffer_free(state->object_delim);
- if (state->object_delim2) fbuffer_free(state->object_delim2);
- ruby_xfree(state);
+ VALUE proc_args[2] = {object, is_key};
+ return rb_proc_call_with_block(state->as_json, 2, proc_args, Qnil);
}
-static size_t State_memsize(const void *ptr)
+static VALUE
+convert_string_subclass(VALUE key)
{
- const JSON_Generator_State *state = ptr;
- size_t size = sizeof(*state);
- if (state->indent) size += state->indent_len + 1;
- if (state->space) size += state->space_len + 1;
- if (state->space_before) size += state->space_before_len + 1;
- if (state->object_nl) size += state->object_nl_len + 1;
- if (state->array_nl) size += state->array_nl_len + 1;
- if (state->array_delim) size += FBUFFER_CAPA(state->array_delim);
- if (state->object_delim) size += FBUFFER_CAPA(state->object_delim);
- if (state->object_delim2) size += FBUFFER_CAPA(state->object_delim2);
- return size;
-}
-
-#ifndef HAVE_RB_EXT_RACTOR_SAFE
-# undef RUBY_TYPED_FROZEN_SHAREABLE
-# define RUBY_TYPED_FROZEN_SHAREABLE 0
-#endif
+ VALUE key_to_s = rb_funcall(key, i_to_s, 0);
-#ifdef NEW_TYPEDDATA_WRAPPER
-static const rb_data_type_t JSON_Generator_State_type = {
- "JSON/Generator/State",
- {NULL, State_free, State_memsize,},
-#ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
-#endif
-};
-#endif
+ if (RB_UNLIKELY(!RB_TYPE_P(key_to_s, T_STRING))) {
+ VALUE cname = rb_obj_class(key);
+ rb_raise(rb_eTypeError,
+ "can't convert %"PRIsVALUE" to %s (%"PRIsVALUE"#%s gives %"PRIsVALUE")",
+ cname, "String", cname, "to_s", rb_obj_class(key_to_s));
+ }
-static VALUE cState_s_allocate(VALUE klass)
+ return key_to_s;
+}
+
+static bool enc_utf8_compatible_p(int enc_idx)
{
- JSON_Generator_State *state;
- return TypedData_Make_Struct(klass, JSON_Generator_State,
- &JSON_Generator_State_type, state);
+ if (enc_idx == usascii_encindex) return true;
+ if (enc_idx == utf8_encindex) return true;
+ return false;
}
-/*
- * call-seq: configure(opts)
- *
- * Configure this State instance with the Hash _opts_, and return
- * itself.
- */
-static VALUE cState_configure(VALUE self, VALUE opts)
+static VALUE encode_json_string_try(VALUE str)
{
- VALUE tmp;
- GET_STATE(self);
- tmp = rb_check_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
- opts = tmp;
- tmp = rb_hash_aref(opts, ID2SYM(i_indent));
- if (RTEST(tmp)) {
- unsigned long len;
- Check_Type(tmp, T_STRING);
- len = RSTRING_LEN(tmp);
- state->indent = fstrndup(RSTRING_PTR(tmp), len + 1);
- state->indent_len = len;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_space));
- if (RTEST(tmp)) {
- unsigned long len;
- Check_Type(tmp, T_STRING);
- len = RSTRING_LEN(tmp);
- state->space = fstrndup(RSTRING_PTR(tmp), len + 1);
- state->space_len = len;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
- if (RTEST(tmp)) {
- unsigned long len;
- Check_Type(tmp, T_STRING);
- len = RSTRING_LEN(tmp);
- state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1);
- state->space_before_len = len;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
- if (RTEST(tmp)) {
- unsigned long len;
- Check_Type(tmp, T_STRING);
- len = RSTRING_LEN(tmp);
- state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
- state->array_nl_len = len;
+ return rb_funcall(str, i_encode, 1, Encoding_UTF_8);
+}
+
+static VALUE encode_json_string_rescue(VALUE str, VALUE exception)
+{
+ raise_generator_error_str(str, rb_funcall(exception, rb_intern("message"), 0));
+ return Qundef;
+}
+
+static inline int json_str_coderange(VALUE str) {
+ int coderange = RB_ENC_CODERANGE(str);
+ if (coderange == RUBY_ENC_CODERANGE_UNKNOWN) {
+ coderange = rb_enc_str_coderange(str);
}
- tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
- if (RTEST(tmp)) {
- unsigned long len;
- Check_Type(tmp, T_STRING);
- len = RSTRING_LEN(tmp);
- state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
- state->object_nl_len = len;
+ return coderange;
+}
+
+static inline bool valid_json_string_p(VALUE str)
+{
+ int coderange = json_str_coderange(str);
+
+ if (RB_LIKELY(coderange == ENC_CODERANGE_7BIT)) {
+ return true;
}
- tmp = ID2SYM(i_max_nesting);
- state->max_nesting = 100;
- if (option_given_p(opts, tmp)) {
- 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;
- }
+
+ if (RB_LIKELY(coderange == ENC_CODERANGE_VALID)) {
+ return enc_utf8_compatible_p(RB_ENCODING_GET_INLINED(str));
}
- tmp = ID2SYM(i_depth);
- state->depth = 0;
- if (option_given_p(opts, tmp)) {
- VALUE depth = rb_hash_aref(opts, tmp);
- if (RTEST(depth)) {
- Check_Type(depth, T_FIXNUM);
- state->depth = FIX2LONG(depth);
- } else {
- state->depth = 0;
+
+ return false;
+}
+
+NOINLINE(static) VALUE convert_invalid_encoding(struct generate_json_data *data, VALUE str, bool as_json_called, bool is_key)
+{
+ if (!as_json_called && data->state->strict && RTEST(data->state->as_json)) {
+ VALUE coerced_str = json_call_as_json(data->state, str, Qfalse);
+ if (coerced_str != str) {
+ if (RB_TYPE_P(coerced_str, T_STRING)) {
+ if (!valid_json_string_p(coerced_str)) {
+ raise_generator_error(str, "source sequence is illegal/malformed utf-8");
+ }
+ } else {
+ // as_json could return another type than T_STRING
+ if (is_key) {
+ raise_generator_error(coerced_str, "%"PRIsVALUE" not allowed as object key in JSON", CLASS_OF(coerced_str));
+ }
+ }
+
+ return coerced_str;
}
}
- tmp = ID2SYM(i_buffer_initial_length);
- if (option_given_p(opts, tmp)) {
- VALUE buffer_initial_length = rb_hash_aref(opts, tmp);
- if (RTEST(buffer_initial_length)) {
- long initial_length;
- Check_Type(buffer_initial_length, T_FIXNUM);
- initial_length = FIX2LONG(buffer_initial_length);
- if (initial_length > 0) state->buffer_initial_length = initial_length;
+
+ if (RB_ENCODING_GET_INLINED(str) == binary_encindex) {
+ VALUE utf8_string = rb_enc_associate_index(rb_str_dup(str), utf8_encindex);
+ switch (rb_enc_str_coderange(utf8_string)) {
+ case ENC_CODERANGE_7BIT:
+ return utf8_string;
+ case ENC_CODERANGE_VALID:
+ // For historical reason, we silently reinterpret binary strings as UTF-8 if it would work.
+ // TODO: Raise in 3.0.0
+ rb_warn("JSON.generate: UTF-8 string passed as BINARY, this will raise an encoding error in json 3.0");
+ return utf8_string;
+ break;
}
}
- tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
- state->allow_nan = RTEST(tmp);
- tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
- state->ascii_only = RTEST(tmp);
- tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash));
- state->escape_slash = RTEST(tmp);
- return self;
+
+ return rb_rescue(encode_json_string_try, str, encode_json_string_rescue, str);
}
-static void set_state_ivars(VALUE hash, VALUE state)
+ALWAYS_INLINE(static) VALUE ensure_valid_encoding(struct generate_json_data *data, VALUE str, bool as_json_called, bool is_key)
{
- VALUE ivars = rb_obj_instance_variables(state);
- int i = 0;
- for (i = 0; i < RARRAY_LEN(ivars); i++) {
- VALUE key = rb_funcall(rb_ary_entry(ivars, i), i_to_s, 0);
- long key_len = RSTRING_LEN(key);
- VALUE value = rb_iv_get(state, StringValueCStr(key));
- rb_hash_aset(hash, rb_str_intern(rb_str_substr(key, 1, key_len - 1)), value);
+ if (RB_LIKELY(valid_json_string_p(str))) {
+ return str;
+ }
+ else {
+ return convert_invalid_encoding(data, str, as_json_called, is_key);
}
}
-/*
- * 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)
+static void raw_generate_json_string(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- VALUE result = rb_hash_new();
- GET_STATE(self);
- set_state_ivars(result, self);
- rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len));
- rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len));
- rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len));
- rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len));
- rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len));
- rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
- rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
- rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
- rb_hash_aset(result, ID2SYM(i_escape_slash), state->escape_slash ? Qtrue : Qfalse);
- rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
- rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
- return result;
-}
+ fbuffer_append_char(buffer, '"');
-/*
-* call-seq: [](name)
-*
-* Returns the value returned by method +name+.
-*/
-static VALUE cState_aref(VALUE self, VALUE name)
-{
- name = rb_funcall(name, i_to_s, 0);
- if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
- return rb_funcall(self, i_send, 1, name);
- } else {
- return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
+ long len;
+ search_state search;
+ search.buffer = buffer;
+ RSTRING_GETMEM(obj, search.ptr, len);
+ search.cursor = search.ptr;
+ search.end = search.ptr + len;
+
+#ifdef HAVE_SIMD
+ search.matches_mask = 0;
+ search.has_matches = false;
+ search.chunk_base = NULL;
+ search.chunk_end = NULL;
+#endif /* HAVE_SIMD */
+
+ switch (json_str_coderange(obj)) {
+ case ENC_CODERANGE_7BIT:
+ case ENC_CODERANGE_VALID:
+ if (RB_UNLIKELY(data->state->ascii_only)) {
+ convert_UTF8_to_ASCII_only_JSON(&search, data->state->script_safe ? script_safe_escape_table : ascii_only_escape_table);
+ } else if (RB_UNLIKELY(data->state->script_safe)) {
+ convert_UTF8_to_script_safe_JSON(&search);
+ } else {
+ convert_UTF8_to_JSON(&search);
+ }
+ break;
+ default:
+ raise_generator_error(obj, "source sequence is illegal/malformed utf-8");
+ break;
}
+ fbuffer_append_char(buffer, '"');
}
-/*
-* call-seq: []=(name, value)
-*
-* Sets the attribute name to value.
-*/
-static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
+static void generate_json_string(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- VALUE name_writer;
-
- name = rb_funcall(name, i_to_s, 0);
- name_writer = rb_str_cat2(rb_str_dup(name), "=");
- if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) {
- return rb_funcall(self, i_send, 2, name_writer, value);
- } else {
- rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)), value);
- }
- return Qnil;
+ obj = ensure_valid_encoding(data, obj, false, false);
+ raw_generate_json_string(buffer, data, obj);
}
struct hash_foreach_arg {
- FBuffer *buffer;
- JSON_Generator_State *state;
- VALUE Vstate;
- int iter;
+ VALUE hash;
+ struct generate_json_data *data;
+ int first_key_type;
+ bool first;
+ bool mixed_keys_encountered;
};
+NOINLINE(static) void
+json_inspect_hash_with_mixed_keys(struct hash_foreach_arg *arg)
+{
+ if (arg->mixed_keys_encountered) {
+ return;
+ }
+ arg->mixed_keys_encountered = true;
+
+ JSON_Generator_State *state = arg->data->state;
+ if (state->on_duplicate_key != JSON_IGNORE) {
+ VALUE do_raise = state->on_duplicate_key == JSON_RAISE ? Qtrue : Qfalse;
+ rb_funcall(mJSON, rb_intern("on_mixed_keys_hash"), 2, arg->hash, do_raise);
+ }
+}
+
static int
json_object_i(VALUE key, VALUE val, VALUE _arg)
{
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)_arg;
- FBuffer *buffer = arg->buffer;
- JSON_Generator_State *state = arg->state;
- VALUE Vstate = arg->Vstate;
-
- char *object_nl = state->object_nl;
- long object_nl_len = state->object_nl_len;
- char *indent = state->indent;
- long indent_len = state->indent_len;
- char *delim = FBUFFER_PTR(state->object_delim);
- long delim_len = FBUFFER_LEN(state->object_delim);
- char *delim2 = FBUFFER_PTR(state->object_delim2);
- long delim2_len = FBUFFER_LEN(state->object_delim2);
- long depth = state->depth;
- int j;
- VALUE klass, key_to_s;
-
- if (arg->iter > 0) fbuffer_append(buffer, delim, delim_len);
- if (object_nl) {
- fbuffer_append(buffer, object_nl, object_nl_len);
+ struct generate_json_data *data = arg->data;
+
+ FBuffer *buffer = data->buffer;
+ JSON_Generator_State *state = data->state;
+
+ long depth = data->depth;
+ int key_type = rb_type(key);
+
+ if (arg->first) {
+ arg->first = false;
+ arg->first_key_type = key_type;
}
- if (indent) {
- for (j = 0; j < depth; j++) {
- fbuffer_append(buffer, indent, indent_len);
- }
+ else {
+ fbuffer_append_char(buffer, ',');
}
- klass = CLASS_OF(key);
- if (klass == rb_cString) {
- key_to_s = key;
- } else if (klass == rb_cSymbol) {
- key_to_s = rb_id2str(SYM2ID(key));
+ if (RB_UNLIKELY(data->state->object_nl)) {
+ fbuffer_append_str(buffer, data->state->object_nl);
+ }
+ if (RB_UNLIKELY(data->state->indent)) {
+ fbuffer_append_str_repeat(buffer, data->state->indent, depth);
+ }
+
+ VALUE key_to_s;
+ bool as_json_called = false;
+
+ start:
+ switch (key_type) {
+ case T_STRING:
+ if (RB_UNLIKELY(arg->first_key_type != T_STRING)) {
+ json_inspect_hash_with_mixed_keys(arg);
+ }
+
+ if (RB_LIKELY(RBASIC_CLASS(key) == rb_cString)) {
+ key_to_s = key;
+ } else {
+ key_to_s = convert_string_subclass(key);
+ }
+ break;
+ case T_SYMBOL:
+ if (RB_UNLIKELY(arg->first_key_type != T_SYMBOL)) {
+ json_inspect_hash_with_mixed_keys(arg);
+ }
+
+ key_to_s = rb_sym2str(key);
+ break;
+ default:
+ if (data->state->strict) {
+ if (RTEST(data->state->as_json) && !as_json_called) {
+ key = json_call_as_json(data->state, key, Qtrue);
+ key_type = rb_type(key);
+ as_json_called = true;
+ goto start;
+ } else {
+ raise_generator_error(key, "%"PRIsVALUE" not allowed as object key in JSON", CLASS_OF(key));
+ }
+ }
+ key_to_s = rb_convert_type(key, T_STRING, "String", "to_s");
+ break;
+ }
+
+ key_to_s = ensure_valid_encoding(data, key_to_s, as_json_called, true);
+
+ if (RB_LIKELY(RBASIC_CLASS(key_to_s) == rb_cString)) {
+ raw_generate_json_string(buffer, data, key_to_s);
} else {
- key_to_s = rb_funcall(key, i_to_s, 0);
+ generate_json(buffer, data, key_to_s);
}
- Check_Type(key_to_s, T_STRING);
- generate_json(buffer, Vstate, state, key_to_s);
- fbuffer_append(buffer, delim2, delim2_len);
- generate_json(buffer, Vstate, state, val);
+ if (RB_UNLIKELY(state->space_before)) fbuffer_append_str(buffer, data->state->space_before);
+ fbuffer_append_char(buffer, ':');
+ if (RB_UNLIKELY(state->space)) fbuffer_append_str(buffer, data->state->space);
+ generate_json(buffer, data, val);
- arg->iter++;
return ST_CONTINUE;
}
-static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static inline long increase_depth(struct generate_json_data *data)
+{
+ JSON_Generator_State *state = data->state;
+ long depth = ++data->depth;
+ if (RB_UNLIKELY(depth > state->max_nesting && state->max_nesting)) {
+ rb_raise(eNestingError, "nesting of %ld is too deep. Did you try to serialize objects with circular references?", --data->depth);
+ }
+ return depth;
+}
+
+static void generate_json_object(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- char *object_nl = state->object_nl;
- long object_nl_len = state->object_nl_len;
- char *indent = state->indent;
- long indent_len = state->indent_len;
- long max_nesting = state->max_nesting;
- long depth = ++state->depth;
- int j;
- struct hash_foreach_arg arg;
+ long depth = increase_depth(data);
- if (max_nesting != 0 && depth > max_nesting) {
- fbuffer_free(buffer);
- rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
+ if (RHASH_SIZE(obj) == 0) {
+ fbuffer_append(buffer, "{}", 2);
+ --data->depth;
+ return;
}
+
fbuffer_append_char(buffer, '{');
- arg.buffer = buffer;
- arg.state = state;
- arg.Vstate = Vstate;
- arg.iter = 0;
+ struct hash_foreach_arg arg = {
+ .hash = obj,
+ .data = data,
+ .first = true,
+ };
rb_hash_foreach(obj, json_object_i, (VALUE)&arg);
- depth = --state->depth;
- if (object_nl) {
- fbuffer_append(buffer, object_nl, object_nl_len);
- if (indent) {
- for (j = 0; j < depth; j++) {
- fbuffer_append(buffer, indent, indent_len);
- }
+ depth = --data->depth;
+ if (RB_UNLIKELY(data->state->object_nl)) {
+ fbuffer_append_str(buffer, data->state->object_nl);
+ if (RB_UNLIKELY(data->state->indent)) {
+ fbuffer_append_str_repeat(buffer, data->state->indent, depth);
}
}
fbuffer_append_char(buffer, '}');
}
-static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
-{
- char *array_nl = state->array_nl;
- long array_nl_len = state->array_nl_len;
- char *indent = state->indent;
- long indent_len = state->indent_len;
- long max_nesting = state->max_nesting;
- char *delim = FBUFFER_PTR(state->array_delim);
- long delim_len = FBUFFER_LEN(state->array_delim);
- long depth = ++state->depth;
- int i, j;
- if (max_nesting != 0 && depth > max_nesting) {
- fbuffer_free(buffer);
- rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
+static void generate_json_array(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
+{
+ long depth = increase_depth(data);
+
+ if (RARRAY_LEN(obj) == 0) {
+ fbuffer_append(buffer, "[]", 2);
+ --data->depth;
+ return;
}
+
fbuffer_append_char(buffer, '[');
- if (array_nl) fbuffer_append(buffer, array_nl, array_nl_len);
- for(i = 0; i < RARRAY_LEN(obj); i++) {
- if (i > 0) fbuffer_append(buffer, delim, delim_len);
- if (indent) {
- for (j = 0; j < depth; j++) {
- fbuffer_append(buffer, indent, indent_len);
- }
+ if (RB_UNLIKELY(data->state->array_nl)) fbuffer_append_str(buffer, data->state->array_nl);
+ for (int i = 0; i < RARRAY_LEN(obj); i++) {
+ if (i > 0) {
+ fbuffer_append_char(buffer, ',');
+ if (RB_UNLIKELY(data->state->array_nl)) fbuffer_append_str(buffer, data->state->array_nl);
+ }
+ if (RB_UNLIKELY(data->state->indent)) {
+ fbuffer_append_str_repeat(buffer, data->state->indent, depth);
}
- generate_json(buffer, Vstate, state, rb_ary_entry(obj, i));
+ generate_json(buffer, data, RARRAY_AREF(obj, i));
}
- state->depth = --depth;
- if (array_nl) {
- fbuffer_append(buffer, array_nl, array_nl_len);
- if (indent) {
- for (j = 0; j < depth; j++) {
- fbuffer_append(buffer, indent, indent_len);
- }
+ data->depth = --depth;
+ if (RB_UNLIKELY(data->state->array_nl)) {
+ fbuffer_append_str(buffer, data->state->array_nl);
+ if (RB_UNLIKELY(data->state->indent)) {
+ fbuffer_append_str_repeat(buffer, data->state->indent, depth);
}
}
fbuffer_append_char(buffer, ']');
}
-#ifdef HAVE_RUBY_ENCODING_H
-static int enc_utf8_compatible_p(rb_encoding *enc)
+static void generate_json_fallback(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- if (enc == rb_usascii_encoding()) return 1;
- if (enc == rb_utf8_encoding()) return 1;
- return 0;
+ VALUE tmp;
+ if (rb_respond_to(obj, i_to_json)) {
+ tmp = json_call_to_json(data, obj);
+ Check_Type(tmp, T_STRING);
+ fbuffer_append_str(buffer, tmp);
+ } else {
+ tmp = rb_funcall(obj, i_to_s, 0);
+ Check_Type(tmp, T_STRING);
+ generate_json_string(buffer, data, tmp);
+ }
}
-#endif
-static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static inline void generate_json_symbol(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- fbuffer_append_char(buffer, '"');
-#ifdef HAVE_RUBY_ENCODING_H
- if (!enc_utf8_compatible_p(rb_enc_get(obj))) {
- obj = rb_str_export_to_enc(obj, rb_utf8_encoding());
- }
-#endif
- if (state->ascii_only) {
- convert_UTF8_to_JSON_ASCII(buffer, obj, state->escape_slash);
+ if (data->state->strict) {
+ generate_json_string(buffer, data, rb_sym2str(obj));
} else {
- convert_UTF8_to_JSON(buffer, obj, state->escape_slash);
+ generate_json_fallback(buffer, data, obj);
}
- fbuffer_append_char(buffer, '"');
}
-static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_null(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
fbuffer_append(buffer, "null", 4);
}
-static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_false(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
fbuffer_append(buffer, "false", 5);
}
-static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_true(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
fbuffer_append(buffer, "true", 4);
}
-static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_fixnum(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
fbuffer_append_long(buffer, FIX2LONG(obj));
}
-static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_bignum(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
VALUE tmp = rb_funcall(obj, i_to_s, 0);
- fbuffer_append_str(buffer, tmp);
+ fbuffer_append_str(buffer, StringValue(tmp));
}
-#ifdef RUBY_INTEGER_UNIFICATION
-static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
-{
- if (FIXNUM_P(obj))
- generate_json_fixnum(buffer, Vstate, state, obj);
- else
- generate_json_bignum(buffer, Vstate, state, obj);
-}
-#endif
-static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_float(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
double value = RFLOAT_VALUE(obj);
- char allow_nan = state->allow_nan;
- VALUE tmp = rb_funcall(obj, i_to_s, 0);
- if (!allow_nan) {
- if (isinf(value)) {
- fbuffer_free(buffer);
- rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
- } else if (isnan(value)) {
- fbuffer_free(buffer);
- rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
+ char allow_nan = data->state->allow_nan;
+ if (isinf(value) || isnan(value)) {
+ /* for NaN and Infinity values we either raise an error or rely on Float#to_s. */
+ if (!allow_nan) {
+ if (data->state->strict && data->state->as_json) {
+ VALUE casted_obj = json_call_as_json(data->state, obj, Qfalse);
+ if (casted_obj != obj) {
+ increase_depth(data);
+ generate_json(buffer, data, casted_obj);
+ data->depth--;
+ return;
+ }
+ }
+ raise_generator_error(obj, "%"PRIsVALUE" not allowed in JSON", rb_funcall(obj, i_to_s, 0));
}
+
+ VALUE tmp = rb_funcall(obj, i_to_s, 0);
+ fbuffer_append_str(buffer, tmp);
+ return;
}
- fbuffer_append_str(buffer, tmp);
+
+ /* This implementation writes directly into the buffer. We reserve
+ * the 32 characters that fpconv_dtoa states as its maximum.
+ */
+ fbuffer_inc_capa(buffer, 32);
+ char* d = buffer->ptr + buffer->len;
+ int len = fpconv_dtoa(value, d);
+ /* fpconv_dtoa converts a float to its shortest string representation,
+ * but it adds a ".0" if this is a plain integer.
+ */
+ fbuffer_consumed(buffer, len);
}
-static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+static void generate_json_fragment(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- VALUE tmp;
- VALUE klass = CLASS_OF(obj);
- if (klass == rb_cHash) {
- generate_json_object(buffer, Vstate, state, obj);
- } else if (klass == rb_cArray) {
- generate_json_array(buffer, Vstate, state, obj);
- } else if (klass == rb_cString) {
- generate_json_string(buffer, Vstate, state, obj);
- } else if (obj == Qnil) {
- generate_json_null(buffer, Vstate, state, obj);
+ VALUE fragment = RSTRUCT_GET(obj, 0);
+ Check_Type(fragment, T_STRING);
+ fbuffer_append_str(buffer, fragment);
+}
+
+static inline void generate_json_general(FBuffer *buffer, struct generate_json_data *data, VALUE obj, bool fallback)
+{
+ bool as_json_called = false;
+start:
+ if (obj == Qnil) {
+ generate_json_null(buffer, data, obj);
} else if (obj == Qfalse) {
- generate_json_false(buffer, Vstate, state, obj);
+ generate_json_false(buffer, data, obj);
} else if (obj == Qtrue) {
- generate_json_true(buffer, Vstate, state, obj);
- } else if (FIXNUM_P(obj)) {
- generate_json_fixnum(buffer, Vstate, state, obj);
- } else if (RB_TYPE_P(obj, T_BIGNUM)) {
- generate_json_bignum(buffer, Vstate, state, obj);
- } else if (klass == rb_cFloat) {
- generate_json_float(buffer, Vstate, state, obj);
- } else if (rb_respond_to(obj, i_to_json)) {
- tmp = rb_funcall(obj, i_to_json, 1, Vstate);
- Check_Type(tmp, T_STRING);
- fbuffer_append_str(buffer, tmp);
+ generate_json_true(buffer, data, obj);
+ } else if (RB_SPECIAL_CONST_P(obj)) {
+ if (RB_FIXNUM_P(obj)) {
+ generate_json_fixnum(buffer, data, obj);
+ } else if (RB_FLONUM_P(obj)) {
+ generate_json_float(buffer, data, obj);
+ } else if (RB_STATIC_SYM_P(obj)) {
+ generate_json_symbol(buffer, data, obj);
+ } else {
+ goto general;
+ }
} else {
- tmp = rb_funcall(obj, i_to_s, 0);
- Check_Type(tmp, T_STRING);
- generate_json_string(buffer, Vstate, state, tmp);
+ VALUE klass = RBASIC_CLASS(obj);
+ switch (RB_BUILTIN_TYPE(obj)) {
+ case T_BIGNUM:
+ generate_json_bignum(buffer, data, obj);
+ break;
+ case T_HASH:
+ if (fallback && klass != rb_cHash) goto general;
+ generate_json_object(buffer, data, obj);
+ break;
+ case T_ARRAY:
+ if (fallback && klass != rb_cArray) goto general;
+ generate_json_array(buffer, data, obj);
+ break;
+ case T_STRING:
+ if (fallback && klass != rb_cString) goto general;
+
+ if (RB_LIKELY(valid_json_string_p(obj))) {
+ raw_generate_json_string(buffer, data, obj);
+ } else if (as_json_called) {
+ raise_generator_error(obj, "source sequence is illegal/malformed utf-8");
+ } else {
+ obj = ensure_valid_encoding(data, obj, false, false);
+ as_json_called = true;
+ goto start;
+ }
+ break;
+ case T_SYMBOL:
+ generate_json_symbol(buffer, data, obj);
+ break;
+ case T_FLOAT:
+ if (fallback && klass != rb_cFloat) goto general;
+ generate_json_float(buffer, data, obj);
+ break;
+ case T_STRUCT:
+ if (klass != cFragment) goto general;
+ generate_json_fragment(buffer, data, obj);
+ break;
+ default:
+ general:
+ if (data->state->strict) {
+ if (RTEST(data->state->as_json) && !as_json_called) {
+ obj = json_call_as_json(data->state, obj, Qfalse);
+ as_json_called = true;
+ goto start;
+ } else {
+ raise_generator_error(obj, "%"PRIsVALUE" not allowed in JSON", CLASS_OF(obj));
+ }
+ } else {
+ generate_json_fallback(buffer, data, obj);
+ }
+ }
}
}
-static FBuffer *cState_prepare_buffer(VALUE self)
+static void generate_json(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
{
- FBuffer *buffer;
- GET_STATE(self);
- buffer = fbuffer_alloc(state->buffer_initial_length);
+ generate_json_general(buffer, data, obj, true);
+}
- if (state->object_delim) {
- fbuffer_clear(state->object_delim);
- } else {
- state->object_delim = fbuffer_alloc(16);
- }
- fbuffer_append_char(state->object_delim, ',');
- if (state->object_delim2) {
- fbuffer_clear(state->object_delim2);
- } else {
- state->object_delim2 = fbuffer_alloc(16);
- }
- if (state->space_before) fbuffer_append(state->object_delim2, state->space_before, state->space_before_len);
- fbuffer_append_char(state->object_delim2, ':');
- if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len);
+static void generate_json_no_fallback(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
+{
+ generate_json_general(buffer, data, obj, false);
+}
- if (state->array_delim) {
- fbuffer_clear(state->array_delim);
- } else {
- state->array_delim = fbuffer_alloc(16);
- }
- fbuffer_append_char(state->array_delim, ',');
- if (state->array_nl) fbuffer_append(state->array_delim, state->array_nl, state->array_nl_len);
- return buffer;
+static VALUE generate_json_try(VALUE d)
+{
+ struct generate_json_data *data = (struct generate_json_data *)d;
+
+ data->func(data->buffer, data, data->obj);
+
+ return fbuffer_finalize(data->buffer);
}
-static VALUE cState_partial_generate(VALUE self, VALUE obj)
+static VALUE generate_json_ensure(VALUE d)
{
- FBuffer *buffer = cState_prepare_buffer(self);
- GET_STATE(self);
- generate_json(buffer, self, state, obj);
- return fbuffer_to_s(buffer);
+ struct generate_json_data *data = (struct generate_json_data *)d;
+ fbuffer_free(data->buffer);
+
+ return Qundef;
}
-/*
- * call-seq: generate(obj)
+static inline VALUE cState_partial_generate(VALUE self, VALUE obj, generator_func func, VALUE io)
+{
+ GET_STATE(self);
+
+ char stack_buffer[FBUFFER_STACK_SIZE];
+ FBuffer buffer = {
+ .io = RTEST(io) ? io : Qfalse,
+ };
+ fbuffer_stack_init(&buffer, state->buffer_initial_length, stack_buffer, FBUFFER_STACK_SIZE);
+
+ struct generate_json_data data = {
+ .buffer = &buffer,
+ .vstate = Qfalse, // don't use self as it may be frozen and its depth is mutated when calling to_json
+ .state = state,
+ .depth = state->depth,
+ .obj = obj,
+ .func = func
+ };
+ return rb_ensure(generate_json_try, (VALUE)&data, generate_json_ensure, (VALUE)&data);
+}
+
+/* call-seq:
+ * generate(obj) -> String
+ * generate(obj, anIO) -> anIO
*
* Generates a valid JSON document from object +obj+ and returns the
* result. If no valid JSON document can be created this method raises a
* GeneratorError exception.
*/
-static VALUE cState_generate(VALUE self, VALUE obj)
+static VALUE cState_generate(int argc, VALUE *argv, VALUE self)
{
- VALUE result = cState_partial_generate(self, obj);
- GET_STATE(self);
- (void)state;
- return result;
+ rb_check_arity(argc, 1, 2);
+ VALUE obj = argv[0];
+ VALUE io = argc > 1 ? argv[1] : Qnil;
+ return cState_partial_generate(self, obj, generate_json, io);
+}
+
+/* :nodoc: */
+static VALUE cState_generate_no_fallback(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 1, 2);
+ VALUE obj = argv[0];
+ VALUE io = argc > 1 ? argv[1] : Qnil;
+ return cState_partial_generate(self, obj, generate_json_no_fallback, io);
}
-/*
- * 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: ''),
- * * *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.
- * * *ascii_only*: true if only ASCII characters should be generated. This
- * option defaults to false.
- * * *buffer_initial_length*: sets the initial length of the generator's
- * internal buffer.
- */
static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
{
- VALUE opts;
- GET_STATE(self);
- state->max_nesting = 100;
- state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
- rb_scan_args(argc, argv, "01", &opts);
- if (!NIL_P(opts)) cState_configure(self, opts);
+ rb_warn("The json gem extension was loaded with the stdlib ruby code. You should upgrade rubygems with `gem update --system`");
return self;
}
@@ -1140,14 +1367,14 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
MEMCPY(objState, origState, JSON_Generator_State, 1);
- objState->indent = fstrndup(origState->indent, origState->indent_len);
- objState->space = fstrndup(origState->space, origState->space_len);
- objState->space_before = fstrndup(origState->space_before, origState->space_before_len);
- objState->object_nl = fstrndup(origState->object_nl, origState->object_nl_len);
- objState->array_nl = fstrndup(origState->array_nl, origState->array_nl_len);
- if (origState->array_delim) objState->array_delim = fbuffer_dup(origState->array_delim);
- if (origState->object_delim) objState->object_delim = fbuffer_dup(origState->object_delim);
- if (origState->object_delim2) objState->object_delim2 = fbuffer_dup(origState->object_delim2);
+
+ RB_OBJ_WRITTEN(obj, Qundef, objState->indent);
+ RB_OBJ_WRITTEN(obj, Qundef, objState->space);
+ RB_OBJ_WRITTEN(obj, Qundef, objState->space_before);
+ RB_OBJ_WRITTEN(obj, Qundef, objState->object_nl);
+ RB_OBJ_WRITTEN(obj, Qundef, objState->array_nl);
+ RB_OBJ_WRITTEN(obj, Qundef, objState->as_json);
+
return obj;
}
@@ -1177,7 +1404,18 @@ static VALUE cState_from_state_s(VALUE self, VALUE opts)
static VALUE cState_indent(VALUE self)
{
GET_STATE(self);
- return state->indent ? rb_str_new(state->indent, state->indent_len) : rb_str_new2("");
+ return state->indent ? state->indent : rb_str_freeze(rb_utf8_str_new("", 0));
+}
+
+static VALUE string_config(VALUE config)
+{
+ if (RTEST(config)) {
+ Check_Type(config, T_STRING);
+ if (RSTRING_LEN(config)) {
+ return rb_str_new_frozen(config);
+ }
+ }
+ return Qfalse;
}
/*
@@ -1187,21 +1425,9 @@ static VALUE cState_indent(VALUE self)
*/
static VALUE cState_indent_set(VALUE self, VALUE indent)
{
- unsigned long len;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(indent, T_STRING);
- len = RSTRING_LEN(indent);
- if (len == 0) {
- if (state->indent) {
- ruby_xfree(state->indent);
- state->indent = NULL;
- state->indent_len = 0;
- }
- } else {
- if (state->indent) ruby_xfree(state->indent);
- state->indent = fstrndup(RSTRING_PTR(indent), len);
- state->indent_len = len;
- }
+ RB_OBJ_WRITE(self, &state->indent, string_config(indent));
return Qnil;
}
@@ -1214,7 +1440,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent)
static VALUE cState_space(VALUE self)
{
GET_STATE(self);
- return state->space ? rb_str_new(state->space, state->space_len) : rb_str_new2("");
+ return state->space ? state->space : rb_str_freeze(rb_utf8_str_new("", 0));
}
/*
@@ -1225,21 +1451,9 @@ static VALUE cState_space(VALUE self)
*/
static VALUE cState_space_set(VALUE self, VALUE space)
{
- unsigned long len;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(space, T_STRING);
- len = RSTRING_LEN(space);
- if (len == 0) {
- if (state->space) {
- ruby_xfree(state->space);
- state->space = NULL;
- state->space_len = 0;
- }
- } else {
- if (state->space) ruby_xfree(state->space);
- state->space = fstrndup(RSTRING_PTR(space), len);
- state->space_len = len;
- }
+ RB_OBJ_WRITE(self, &state->space, string_config(space));
return Qnil;
}
@@ -1251,7 +1465,7 @@ static VALUE cState_space_set(VALUE self, VALUE space)
static VALUE cState_space_before(VALUE self)
{
GET_STATE(self);
- return state->space_before ? rb_str_new(state->space_before, state->space_before_len) : rb_str_new2("");
+ return state->space_before ? state->space_before : rb_str_freeze(rb_utf8_str_new("", 0));
}
/*
@@ -1261,21 +1475,9 @@ static VALUE cState_space_before(VALUE self)
*/
static VALUE cState_space_before_set(VALUE self, VALUE space_before)
{
- unsigned long len;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(space_before, T_STRING);
- len = RSTRING_LEN(space_before);
- if (len == 0) {
- if (state->space_before) {
- ruby_xfree(state->space_before);
- state->space_before = NULL;
- state->space_before_len = 0;
- }
- } else {
- if (state->space_before) ruby_xfree(state->space_before);
- state->space_before = fstrndup(RSTRING_PTR(space_before), len);
- state->space_before_len = len;
- }
+ RB_OBJ_WRITE(self, &state->space_before, string_config(space_before));
return Qnil;
}
@@ -1288,7 +1490,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before)
static VALUE cState_object_nl(VALUE self)
{
GET_STATE(self);
- return state->object_nl ? rb_str_new(state->object_nl, state->object_nl_len) : rb_str_new2("");
+ return state->object_nl ? state->object_nl : rb_str_freeze(rb_utf8_str_new("", 0));
}
/*
@@ -1299,20 +1501,9 @@ static VALUE cState_object_nl(VALUE self)
*/
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
{
- unsigned long len;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(object_nl, T_STRING);
- len = RSTRING_LEN(object_nl);
- if (len == 0) {
- if (state->object_nl) {
- ruby_xfree(state->object_nl);
- state->object_nl = NULL;
- }
- } else {
- if (state->object_nl) ruby_xfree(state->object_nl);
- state->object_nl = fstrndup(RSTRING_PTR(object_nl), len);
- state->object_nl_len = len;
- }
+ RB_OBJ_WRITE(self, &state->object_nl, string_config(object_nl));
return Qnil;
}
@@ -1324,7 +1515,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
static VALUE cState_array_nl(VALUE self)
{
GET_STATE(self);
- return state->array_nl ? rb_str_new(state->array_nl, state->array_nl_len) : rb_str_new2("");
+ return state->array_nl ? state->array_nl : rb_str_freeze(rb_utf8_str_new("", 0));
}
/*
@@ -1334,23 +1525,35 @@ static VALUE cState_array_nl(VALUE self)
*/
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
{
- unsigned long len;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(array_nl, T_STRING);
- len = RSTRING_LEN(array_nl);
- if (len == 0) {
- if (state->array_nl) {
- ruby_xfree(state->array_nl);
- state->array_nl = NULL;
- }
- } else {
- if (state->array_nl) ruby_xfree(state->array_nl);
- state->array_nl = fstrndup(RSTRING_PTR(array_nl), len);
- state->array_nl_len = len;
- }
+ RB_OBJ_WRITE(self, &state->array_nl, string_config(array_nl));
return Qnil;
}
+/*
+ * call-seq: as_json()
+ *
+ * This string is put at the end of a line that holds a JSON array.
+ */
+static VALUE cState_as_json(VALUE self)
+{
+ GET_STATE(self);
+ return state->as_json;
+}
+
+/*
+ * call-seq: as_json=(as_json)
+ *
+ * This string is put at the end of a line that holds a JSON array.
+ */
+static VALUE cState_as_json_set(VALUE self, VALUE as_json)
+{
+ rb_check_frozen(self);
+ GET_STATE(self);
+ RB_OBJ_WRITE(self, &state->as_json, rb_convert_type(as_json, T_DATA, "Proc", "to_proc"));
+ return Qnil;
+}
/*
* call-seq: check_circular?
@@ -1376,6 +1579,25 @@ static VALUE cState_max_nesting(VALUE self)
return LONG2FIX(state->max_nesting);
}
+static long long_config(VALUE num)
+{
+ return RTEST(num) ? NUM2LONG(num) : 0;
+}
+
+// depth must never be negative; reject early with a clear error.
+static long depth_config(VALUE num)
+{
+ if (!RTEST(num)) return 0;
+ long d = NUM2LONG(num);
+ if (RB_UNLIKELY(d < 0)) {
+ rb_raise(rb_eArgError, "depth must be >= 0 (got %ld)", d);
+ }
+ if (RB_UNLIKELY(d > INT_MAX)) {
+ rb_raise(rb_eArgError, "depth is too large (got %ld)", d);
+ }
+ return d;
+}
+
/*
* call-seq: max_nesting=(depth)
*
@@ -1384,33 +1606,67 @@ static VALUE cState_max_nesting(VALUE self)
*/
static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
{
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(depth, T_FIXNUM);
- return state->max_nesting = FIX2LONG(depth);
+ state->max_nesting = long_config(depth);
+ return Qnil;
}
/*
- * call-seq: escape_slash
+ * call-seq: script_safe
*
* If this boolean is true, the forward slashes will be escaped in
* the json output.
*/
-static VALUE cState_escape_slash(VALUE self)
+static VALUE cState_script_safe(VALUE self)
{
GET_STATE(self);
- return state->escape_slash ? Qtrue : Qfalse;
+ return state->script_safe ? Qtrue : Qfalse;
}
/*
- * call-seq: escape_slash=(depth)
+ * call-seq: script_safe=(enable)
*
* This sets whether or not the forward slashes will be escaped in
* the json output.
*/
-static VALUE cState_escape_slash_set(VALUE self, VALUE enable)
+static VALUE cState_script_safe_set(VALUE self, VALUE enable)
{
+ rb_check_frozen(self);
GET_STATE(self);
- state->escape_slash = RTEST(enable);
+ state->script_safe = RTEST(enable);
+ return Qnil;
+}
+
+/*
+ * call-seq: strict
+ *
+ * If this boolean is false, types unsupported by the JSON format will
+ * be serialized as strings.
+ * If this boolean is true, types unsupported by the JSON format will
+ * raise a JSON::GeneratorError.
+ */
+static VALUE cState_strict(VALUE self)
+{
+ GET_STATE(self);
+ return state->strict ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: strict=(enable)
+ *
+ * This sets whether or not to serialize types unsupported by the
+ * JSON format as strings.
+ * If this boolean is false, types unsupported by the JSON format will
+ * be serialized as strings.
+ * If this boolean is true, types unsupported by the JSON format will
+ * raise a JSON::GeneratorError.
+ */
+static VALUE cState_strict_set(VALUE self, VALUE enable)
+{
+ rb_check_frozen(self);
+ GET_STATE(self);
+ state->strict = RTEST(enable);
return Qnil;
}
@@ -1427,6 +1683,19 @@ static VALUE cState_allow_nan_p(VALUE self)
}
/*
+ * call-seq: allow_nan=(enable)
+ *
+ * This sets whether or not to serialize NaN, Infinity, and -Infinity
+ */
+static VALUE cState_allow_nan_set(VALUE self, VALUE enable)
+{
+ rb_check_frozen(self);
+ GET_STATE(self);
+ state->allow_nan = RTEST(enable);
+ return Qnil;
+}
+
+/*
* call-seq: ascii_only?
*
* Returns true, if only ASCII characters should be generated. Otherwise
@@ -1439,6 +1708,32 @@ static VALUE cState_ascii_only_p(VALUE self)
}
/*
+ * call-seq: ascii_only=(enable)
+ *
+ * This sets whether only ASCII characters should be generated.
+ */
+static VALUE cState_ascii_only_set(VALUE self, VALUE enable)
+{
+ rb_check_frozen(self);
+ GET_STATE(self);
+ state->ascii_only = RTEST(enable);
+ return Qnil;
+}
+
+static VALUE cState_allow_duplicate_key_p(VALUE self)
+{
+ GET_STATE(self);
+ switch (state->on_duplicate_key) {
+ case JSON_IGNORE:
+ return Qtrue;
+ case JSON_DEPRECATED:
+ return Qnil;
+ default:
+ return Qfalse;
+ }
+}
+
+/*
* call-seq: depth
*
* This integer returns the current depth of data structure nesting.
@@ -1457,9 +1752,9 @@ static VALUE cState_depth(VALUE self)
*/
static VALUE cState_depth_set(VALUE self, VALUE depth)
{
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(depth, T_FIXNUM);
- state->depth = FIX2LONG(depth);
+ state->depth = depth_config(depth);
return Qnil;
}
@@ -1474,6 +1769,15 @@ static VALUE cState_buffer_initial_length(VALUE self)
return LONG2FIX(state->buffer_initial_length);
}
+static void buffer_initial_length_set(JSON_Generator_State *state, VALUE buffer_initial_length)
+{
+ Check_Type(buffer_initial_length, T_FIXNUM);
+ long initial_length = FIX2LONG(buffer_initial_length);
+ if (initial_length > 0) {
+ state->buffer_initial_length = initial_length;
+ }
+}
+
/*
* call-seq: buffer_initial_length=(length)
*
@@ -1482,19 +1786,112 @@ static VALUE cState_buffer_initial_length(VALUE self)
*/
static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length)
{
- long initial_length;
+ rb_check_frozen(self);
GET_STATE(self);
- Check_Type(buffer_initial_length, T_FIXNUM);
- initial_length = FIX2LONG(buffer_initial_length);
- if (initial_length > 0) {
- state->buffer_initial_length = initial_length;
- }
+ buffer_initial_length_set(state, buffer_initial_length);
return Qnil;
}
-/*
- *
- */
+struct configure_state_data {
+ JSON_Generator_State *state;
+ VALUE vstate; // Ruby object that owns the state, or Qfalse if stack-allocated
+};
+
+static inline void state_write_value(struct configure_state_data *data, VALUE *field, VALUE value)
+{
+ if (RTEST(data->vstate)) {
+ RB_OBJ_WRITE(data->vstate, field, value);
+ } else {
+ *field = value;
+ }
+}
+
+static int configure_state_i(VALUE key, VALUE val, VALUE _arg)
+{
+ struct configure_state_data *data = (struct configure_state_data *)_arg;
+ JSON_Generator_State *state = data->state;
+
+ if (key == sym_indent) { state_write_value(data, &state->indent, string_config(val)); }
+ else if (key == sym_space) { state_write_value(data, &state->space, string_config(val)); }
+ else if (key == sym_space_before) { state_write_value(data, &state->space_before, string_config(val)); }
+ else if (key == sym_object_nl) { state_write_value(data, &state->object_nl, string_config(val)); }
+ else if (key == sym_array_nl) { state_write_value(data, &state->array_nl, string_config(val)); }
+ else if (key == sym_max_nesting) { state->max_nesting = long_config(val); }
+ else if (key == sym_allow_nan) { state->allow_nan = RTEST(val); }
+ else if (key == sym_ascii_only) { state->ascii_only = RTEST(val); }
+ else if (key == sym_depth) { state->depth = depth_config(val); }
+ else if (key == sym_buffer_initial_length) { buffer_initial_length_set(state, val); }
+ else if (key == sym_script_safe) { state->script_safe = RTEST(val); }
+ else if (key == sym_escape_slash) { state->script_safe = RTEST(val); }
+ else if (key == sym_strict) { state->strict = RTEST(val); }
+ else if (key == sym_allow_duplicate_key) { state->on_duplicate_key = RTEST(val) ? JSON_IGNORE : JSON_RAISE; }
+ else if (key == sym_as_json) {
+ VALUE proc = RTEST(val) ? rb_convert_type(val, T_DATA, "Proc", "to_proc") : Qfalse;
+ state->as_json_single_arg = proc && rb_proc_arity(proc) == 1;
+ state_write_value(data, &state->as_json, proc);
+ }
+ return ST_CONTINUE;
+}
+
+static void configure_state(JSON_Generator_State *state, VALUE vstate, VALUE config)
+{
+ if (!RTEST(config)) return;
+
+ Check_Type(config, T_HASH);
+
+ if (!RHASH_SIZE(config)) return;
+
+ struct configure_state_data data = {
+ .state = state,
+ .vstate = vstate
+ };
+
+ // We assume in most cases few keys are set so it's faster to go over
+ // the provided keys than to check all possible keys.
+ rb_hash_foreach(config, configure_state_i, (VALUE)&data);
+}
+
+static VALUE cState_configure(VALUE self, VALUE opts)
+{
+ rb_check_frozen(self);
+ GET_STATE(self);
+ configure_state(state, self, opts);
+ return self;
+}
+
+static VALUE cState_m_do_generate(VALUE klass, VALUE obj, VALUE opts, VALUE io, generator_func func)
+{
+ JSON_Generator_State state = {0};
+ state_init(&state);
+ configure_state(&state, Qfalse, opts);
+
+ char stack_buffer[FBUFFER_STACK_SIZE];
+ FBuffer buffer = {
+ .io = RTEST(io) ? io : Qfalse,
+ };
+ fbuffer_stack_init(&buffer, state.buffer_initial_length, stack_buffer, FBUFFER_STACK_SIZE);
+
+ struct generate_json_data data = {
+ .buffer = &buffer,
+ .vstate = Qfalse,
+ .state = &state,
+ .depth = state.depth,
+ .obj = obj,
+ .func = func,
+ };
+ return rb_ensure(generate_json_try, (VALUE)&data, generate_json_ensure, (VALUE)&data);
+}
+
+static VALUE cState_m_generate(VALUE klass, VALUE obj, VALUE opts, VALUE io)
+{
+ return cState_m_do_generate(klass, obj, opts, io, generate_json);
+}
+
+static VALUE cState_m_generate_no_fallback(VALUE klass, VALUE obj, VALUE opts, VALUE io)
+{
+ return cState_m_do_generate(klass, obj, opts, io, generate_json_no_fallback);
+}
+
void Init_generator(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
@@ -1505,18 +1902,26 @@ void Init_generator(void)
rb_require("json/common");
mJSON = rb_define_module("JSON");
- mExt = rb_define_module_under(mJSON, "Ext");
- mGenerator = rb_define_module_under(mExt, "Generator");
+ rb_global_variable(&cFragment);
+ cFragment = rb_const_get(mJSON, rb_intern("Fragment"));
+
+ VALUE mExt = rb_define_module_under(mJSON, "Ext");
+ VALUE mGenerator = rb_define_module_under(mExt, "Generator");
+
+ rb_global_variable(&eGeneratorError);
eGeneratorError = rb_path2class("JSON::GeneratorError");
+
+ rb_global_variable(&eNestingError);
eNestingError = rb_path2class("JSON::NestingError");
- rb_gc_register_mark_object(eGeneratorError);
- rb_gc_register_mark_object(eNestingError);
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_alias(cState, "initialize", "initialize"); // avoid method redefinition warnings
+ rb_define_private_method(cState, "_configure", cState_configure, 1);
+
rb_define_method(cState, "initialize_copy", cState_init_copy, 1);
rb_define_method(cState, "indent", cState_indent, 0);
rb_define_method(cState, "indent=", cState_indent_set, 1);
@@ -1528,81 +1933,65 @@ void Init_generator(void)
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, "as_json", cState_as_json, 0);
+ rb_define_method(cState, "as_json=", cState_as_json_set, 1);
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, "escape_slash", cState_escape_slash, 0);
- rb_define_method(cState, "escape_slash?", cState_escape_slash, 0);
- rb_define_method(cState, "escape_slash=", cState_escape_slash_set, 1);
+ rb_define_method(cState, "script_safe", cState_script_safe, 0);
+ rb_define_method(cState, "script_safe?", cState_script_safe, 0);
+ rb_define_method(cState, "script_safe=", cState_script_safe_set, 1);
+ rb_define_alias(cState, "escape_slash", "script_safe");
+ rb_define_alias(cState, "escape_slash?", "script_safe?");
+ rb_define_alias(cState, "escape_slash=", "script_safe=");
+ rb_define_method(cState, "strict", cState_strict, 0);
+ rb_define_method(cState, "strict?", cState_strict, 0);
+ rb_define_method(cState, "strict=", cState_strict_set, 1);
rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
+ rb_define_method(cState, "allow_nan=", cState_allow_nan_set, 1);
rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
+ rb_define_method(cState, "ascii_only=", cState_ascii_only_set, 1);
rb_define_method(cState, "depth", cState_depth, 0);
rb_define_method(cState, "depth=", cState_depth_set, 1);
rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1);
- rb_define_method(cState, "configure", cState_configure, 1);
- rb_define_alias(cState, "merge", "configure");
- rb_define_method(cState, "to_h", cState_to_h, 0);
- rb_define_alias(cState, "to_hash", "to_h");
- rb_define_method(cState, "[]", cState_aref, 1);
- rb_define_method(cState, "[]=", cState_aset, 2);
- rb_define_method(cState, "generate", cState_generate, 1);
-
- 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);
-#ifdef RUBY_INTEGER_UNIFICATION
- mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
- rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
-#else
- mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
- rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
- mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
- rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
-#endif
- 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);
+ rb_define_method(cState, "generate", cState_generate, -1);
+ rb_define_method(cState, "_generate_no_fallback", cState_generate_no_fallback, -1);
+
+ rb_define_private_method(cState, "allow_duplicate_key?", cState_allow_duplicate_key_p, 0);
+
+ rb_define_singleton_method(cState, "generate", cState_m_generate, 3);
+ rb_define_singleton_method(cState, "_generate_no_fallback", cState_m_generate_no_fallback, 3);
+
+ rb_global_variable(&Encoding_UTF_8);
+ Encoding_UTF_8 = rb_const_get(rb_path2class("Encoding"), rb_intern("UTF_8"));
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_max_nesting = rb_intern("max_nesting");
- i_escape_slash = rb_intern("escape_slash");
- i_allow_nan = rb_intern("allow_nan");
- i_ascii_only = rb_intern("ascii_only");
- i_depth = rb_intern("depth");
- i_buffer_initial_length = rb_intern("buffer_initial_length");
- i_pack = rb_intern("pack");
- i_unpack = rb_intern("unpack");
- i_create_id = rb_intern("create_id");
- i_extend = rb_intern("extend");
- i_key_p = rb_intern("key?");
- i_aref = rb_intern("[]");
- i_send = rb_intern("__send__");
- i_respond_to_p = rb_intern("respond_to?");
- i_match = rb_intern("match");
- i_keys = rb_intern("keys");
- i_dup = rb_intern("dup");
+ i_encode = rb_intern("encode");
+
+ sym_indent = ID2SYM(rb_intern("indent"));
+ sym_space = ID2SYM(rb_intern("space"));
+ sym_space_before = ID2SYM(rb_intern("space_before"));
+ sym_object_nl = ID2SYM(rb_intern("object_nl"));
+ sym_array_nl = ID2SYM(rb_intern("array_nl"));
+ sym_max_nesting = ID2SYM(rb_intern("max_nesting"));
+ sym_allow_nan = ID2SYM(rb_intern("allow_nan"));
+ sym_ascii_only = ID2SYM(rb_intern("ascii_only"));
+ sym_depth = ID2SYM(rb_intern("depth"));
+ sym_buffer_initial_length = ID2SYM(rb_intern("buffer_initial_length"));
+ sym_script_safe = ID2SYM(rb_intern("script_safe"));
+ sym_escape_slash = ID2SYM(rb_intern("escape_slash"));
+ sym_strict = ID2SYM(rb_intern("strict"));
+ sym_as_json = ID2SYM(rb_intern("as_json"));
+ sym_allow_duplicate_key = ID2SYM(rb_intern("allow_duplicate_key"));
+
+ usascii_encindex = rb_usascii_encindex();
+ utf8_encindex = rb_utf8_encindex();
+ binary_encindex = rb_ascii8bit_encindex();
+
+ rb_require("json/ext/generator/state");
+
+ simd_impl = find_simd_implementation();
}
diff --git a/ext/json/generator/generator.h b/ext/json/generator/generator.h
deleted file mode 100644
index 3ebd622554..0000000000
--- a/ext/json/generator/generator.h
+++ /dev/null
@@ -1,174 +0,0 @@
-#ifndef _GENERATOR_H_
-#define _GENERATOR_H_
-
-#include <math.h>
-#include <ctype.h>
-
-#include "ruby.h"
-
-#ifdef HAVE_RUBY_RE_H
-#include "ruby/re.h"
-#else
-#include "re.h"
-#endif
-
-#ifndef rb_intern_str
-#define rb_intern_str(string) SYM2ID(rb_str_intern(string))
-#endif
-
-#ifndef rb_obj_instance_variables
-#define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0)
-#endif
-
-#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
-
-/* unicode definitions */
-
-#define UNI_STRICT_CONVERSION 1
-
-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;
-
-static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
-static void unicode_escape(char *buf, UTF16 character);
-static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
-static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash);
-static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash);
-static char *fstrndup(const char *ptr, unsigned long len);
-
-/* ruby api and some helpers */
-
-typedef struct JSON_Generator_StateStruct {
- char *indent;
- long indent_len;
- char *space;
- long space_len;
- char *space_before;
- long space_before_len;
- char *object_nl;
- long object_nl_len;
- char *array_nl;
- long array_nl_len;
- FBuffer *array_delim;
- FBuffer *object_delim;
- FBuffer *object_delim2;
- long max_nesting;
- char allow_nan;
- char ascii_only;
- char escape_slash;
- long depth;
- long buffer_initial_length;
-} JSON_Generator_State;
-
-#define GET_STATE_TO(self, state) \
- TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
-
-#define GET_STATE(self) \
- JSON_Generator_State *state; \
- GET_STATE_TO(self, state)
-
-#define GENERATE_JSON(type) \
- FBuffer *buffer; \
- VALUE Vstate; \
- JSON_Generator_State *state; \
- \
- rb_scan_args(argc, argv, "01", &Vstate); \
- Vstate = cState_from_state_s(cState, Vstate); \
- TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
- buffer = cState_prepare_buffer(Vstate); \
- generate_json_##type(buffer, Vstate, state, self); \
- return fbuffer_to_s(buffer)
-
-static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self);
-#ifdef RUBY_INTEGER_UNIFICATION
-static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self);
-#else
-static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);
-#endif
-static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mString_included_s(VALUE self, VALUE modul);
-static VALUE mString_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mString_to_json_raw_object(VALUE self);
-static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);
-static VALUE mString_Extend_json_create(VALUE self, VALUE o);
-static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
-static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
-static void State_free(void *state);
-static VALUE cState_s_allocate(VALUE klass);
-static VALUE cState_configure(VALUE self, VALUE opts);
-static VALUE cState_to_h(VALUE self);
-static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-#ifdef RUBY_INTEGER_UNIFICATION
-static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-#endif
-static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
-static VALUE cState_partial_generate(VALUE self, VALUE obj);
-static VALUE cState_generate(VALUE self, VALUE obj);
-static VALUE cState_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE cState_from_state_s(VALUE self, VALUE opts);
-static VALUE cState_indent(VALUE self);
-static VALUE cState_indent_set(VALUE self, VALUE indent);
-static VALUE cState_space(VALUE self);
-static VALUE cState_space_set(VALUE self, VALUE space);
-static VALUE cState_space_before(VALUE self);
-static VALUE cState_space_before_set(VALUE self, VALUE space_before);
-static VALUE cState_object_nl(VALUE self);
-static VALUE cState_object_nl_set(VALUE self, VALUE object_nl);
-static VALUE cState_array_nl(VALUE self);
-static VALUE cState_array_nl_set(VALUE self, VALUE array_nl);
-static VALUE cState_max_nesting(VALUE self);
-static VALUE cState_max_nesting_set(VALUE self, VALUE depth);
-static VALUE cState_allow_nan_p(VALUE self);
-static VALUE cState_ascii_only_p(VALUE self);
-static VALUE cState_depth(VALUE self);
-static VALUE cState_depth_set(VALUE self, VALUE depth);
-static VALUE cState_escape_slash(VALUE self);
-static VALUE cState_escape_slash_set(VALUE self, VALUE depth);
-static FBuffer *cState_prepare_buffer(VALUE self);
-#ifndef ZALLOC
-#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
-static inline void *ruby_zalloc(size_t n)
-{
- void *p = ruby_xmalloc(n);
- memset(p, 0, n);
- return p;
-}
-#endif
-#ifdef TypedData_Make_Struct
-static const rb_data_type_t JSON_Generator_State_type;
-#define NEW_TYPEDDATA_WRAPPER 1
-#else
-#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, State_free, json)
-#define TypedData_Get_Struct(self, JSON_Generator_State, ignore, json) Data_Get_Struct(self, JSON_Generator_State, json)
-#endif
-
-#endif
diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec
index f4b2ae791d..5575731025 100644
--- a/ext/json/json.gemspec
+++ b/ext/json/json.gemspec
@@ -1,67 +1,62 @@
-# -*- encoding: utf-8 -*-
+# frozen_string_literal: true
+
+version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line|
+ /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1
+end rescue nil
+
+spec = Gem::Specification.new do |s|
+ java_ext = Gem::Platform === s.platform && s.platform =~ 'java' || RUBY_ENGINE == 'jruby'
-Gem::Specification.new do |s|
s.name = "json"
- s.version = File.read(File.expand_path('../VERSION', __FILE__)).chomp
+ s.version = version
s.summary = "JSON Implementation for Ruby"
- s.description = "This is a JSON implementation as a Ruby extension in C."
+ s.homepage = "https://github.com/ruby/json"
+ s.metadata = {
+ 'bug_tracker_uri' => 'https://github.com/ruby/json/issues',
+ 'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md',
+ 'documentation_uri' => 'https://docs.ruby-lang.org/en/master/JSON.html',
+ 'homepage_uri' => s.homepage,
+ 'source_code_uri' => 'https://github.com/ruby/json',
+ }
+
+ s.required_ruby_version = Gem::Requirement.new(">= 2.7")
+
+ if java_ext
+ s.description = "A JSON implementation as a JRuby extension."
+ s.author = "Daniel Luz"
+ s.email = "dev+ruby@mernen.com"
+ else
+ s.description = "This is a JSON implementation as a Ruby extension in C."
+ s.authors = ["Florian Frank"]
+ s.email = "flori@ping.de"
+ end
+
s.licenses = ["Ruby"]
- s.authors = ["Florian Frank"]
- s.email = "flori@ping.de"
- s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"]
s.extra_rdoc_files = ["README.md"]
s.rdoc_options = ["--title", "JSON implementation for Ruby", "--main", "README.md"]
+
s.files = [
"CHANGES.md",
- "LICENSE",
+ "COPYING",
+ "BSDL",
+ "LEGAL",
"README.md",
- "VERSION",
- "ext/json/ext/fbuffer/fbuffer.h",
- "ext/json/ext/generator/depend",
- "ext/json/ext/generator/extconf.rb",
- "ext/json/ext/generator/generator.c",
- "ext/json/ext/generator/generator.h",
- "ext/json/ext/parser/depend",
- "ext/json/ext/parser/extconf.rb",
- "ext/json/ext/parser/parser.c",
- "ext/json/ext/parser/parser.h",
- "ext/json/ext/parser/parser.rl",
- "ext/json/extconf.rb",
"json.gemspec",
- "lib/json.rb",
- "lib/json/add/bigdecimal.rb",
- "lib/json/add/complex.rb",
- "lib/json/add/core.rb",
- "lib/json/add/date.rb",
- "lib/json/add/date_time.rb",
- "lib/json/add/exception.rb",
- "lib/json/add/ostruct.rb",
- "lib/json/add/range.rb",
- "lib/json/add/rational.rb",
- "lib/json/add/regexp.rb",
- "lib/json/add/set.rb",
- "lib/json/add/struct.rb",
- "lib/json/add/symbol.rb",
- "lib/json/add/time.rb",
- "lib/json/common.rb",
- "lib/json/ext.rb",
- "lib/json/generic_object.rb",
- "lib/json/pure.rb",
- "lib/json/pure/generator.rb",
- "lib/json/pure/parser.rb",
- "lib/json/version.rb",
- ]
- s.homepage = "https://flori.github.io/json"
- s.metadata = {
- 'bug_tracker_uri' => 'https://github.com/flori/json/issues',
- 'changelog_uri' => 'https://github.com/flori/json/blob/master/CHANGES.md',
- 'documentation_uri' => 'https://flori.github.io/json/doc/index.html',
- 'homepage_uri' => s.homepage,
- 'source_code_uri' => 'https://github.com/flori/json',
- 'wiki_uri' => 'https://github.com/flori/json/wiki'
- }
+ ] + Dir.glob("lib/**/*.rb", base: File.expand_path("..", __FILE__))
+
+ if java_ext
+ s.platform = 'java'
+ s.files += Dir["lib/json/ext/**/*.jar"]
+ else
+ s.extensions = Dir["ext/json/**/extconf.rb"]
+ s.files += Dir["ext/json/**/*.{c,h,rb}"]
+ end
+end
- s.required_ruby_version = Gem::Requirement.new(">= 2.3")
+if RUBY_ENGINE == 'jruby' && $0 == __FILE__
+ Gem::Builder.new(spec).build
+else
+ spec
end
diff --git a/ext/json/json.h b/ext/json/json.h
new file mode 100644
index 0000000000..8737989a6c
--- /dev/null
+++ b/ext/json/json.h
@@ -0,0 +1,116 @@
+#ifndef _JSON_H_
+#define _JSON_H_
+
+#include "ruby.h"
+#include "ruby/encoding.h"
+#include <stdint.h>
+
+#ifndef RBIMPL_ASSERT_OR_ASSUME
+# define RBIMPL_ASSERT_OR_ASSUME(x)
+#endif
+
+#if defined(RUBY_DEBUG) && RUBY_DEBUG
+# define JSON_ASSERT RUBY_ASSERT
+#else
+# ifdef JSON_DEBUG
+# include <assert.h>
+# define JSON_ASSERT(x) assert(x)
+# else
+# define JSON_ASSERT(x)
+# endif
+#endif
+
+/* shims */
+
+#if SIZEOF_UINT64_T == SIZEOF_LONG_LONG
+# define INT64T2NUM(x) LL2NUM(x)
+# define UINT64T2NUM(x) ULL2NUM(x)
+#elif SIZEOF_UINT64_T == SIZEOF_LONG
+# define INT64T2NUM(x) LONG2NUM(x)
+# define UINT64T2NUM(x) ULONG2NUM(x)
+#else
+# error No uint64_t conversion
+#endif
+
+/* This is the fallback definition from Ruby 3.4 */
+#ifndef RBIMPL_STDBOOL_H
+#if defined(__cplusplus)
+# if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
+# include <cstdbool>
+# endif
+#elif defined(HAVE_STDBOOL_H)
+# include <stdbool.h>
+#elif !defined(HAVE__BOOL)
+typedef unsigned char _Bool;
+# define bool _Bool
+# define true ((_Bool)+1)
+# define false ((_Bool)+0)
+# define __bool_true_false_are_defined
+#endif
+#endif
+
+#ifndef HAVE_RB_EXT_RACTOR_SAFE
+# undef RUBY_TYPED_FROZEN_SHAREABLE
+# define RUBY_TYPED_FROZEN_SHAREABLE 0
+#endif
+
+#ifdef RUBY_TYPED_EMBEDDABLE
+# define HAVE_RUBY_TYPED_EMBEDDABLE 1
+#else
+# ifdef HAVE_CONST_RUBY_TYPED_EMBEDDABLE
+# define RUBY_TYPED_EMBEDDABLE RUBY_TYPED_EMBEDDABLE
+# define HAVE_RUBY_TYPED_EMBEDDABLE 1
+# else
+# define RUBY_TYPED_EMBEDDABLE 0
+# endif
+#endif
+
+#ifndef NORETURN
+#if defined(__has_attribute) && __has_attribute(noreturn)
+#define NORETURN(x) __attribute__((noreturn)) x
+#else
+#define NORETURN(x) x
+#endif
+#endif
+
+#ifndef NOINLINE
+#if defined(__has_attribute) && __has_attribute(noinline)
+#define NOINLINE(x) __attribute__((noinline)) x
+#else
+#define NOINLINE(x) x
+#endif
+#endif
+
+#ifndef ALWAYS_INLINE
+#if defined(__has_attribute) && __has_attribute(always_inline)
+#define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
+#else
+#define ALWAYS_INLINE(x) inline x
+#endif
+#endif
+
+#ifndef RB_UNLIKELY
+#define RB_UNLIKELY(expr) expr
+#endif
+
+#ifndef RB_LIKELY
+#define RB_LIKELY(expr) expr
+#endif
+
+#ifndef MAYBE_UNUSED
+# define MAYBE_UNUSED(x) x
+#endif
+
+#ifdef RUBY_DEBUG
+#ifndef JSON_DEBUG
+#define JSON_DEBUG RUBY_DEBUG
+#endif
+#endif
+
+#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
+#define JSON_CPU_LITTLE_ENDIAN_64BITS 1
+#else
+#define JSON_CPU_LITTLE_ENDIAN_64BITS 0
+#endif
+
+#endif // _JSON_H_
diff --git a/ext/json/lib/json.rb b/ext/json/lib/json.rb
index 1e64bfcb1a..26d601926f 100644
--- a/ext/json/lib/json.rb
+++ b/ext/json/lib/json.rb
@@ -1,4 +1,4 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
require 'json/common'
##
@@ -6,6 +6,15 @@ require 'json/common'
#
# \JSON is a lightweight data-interchange format.
#
+# \JSON is easy for us humans to read and write,
+# and equally simple for machines to read (parse) and write (generate).
+#
+# \JSON is language-independent, making it an ideal interchange format
+# for applications in differing programming languages
+# and on differing operating systems.
+#
+# == \JSON Values
+#
# A \JSON value is one of the following:
# - Double-quoted text: <tt>"foo"</tt>.
# - Number: +1+, +1.0+, +2.0e2+.
@@ -127,6 +136,24 @@ require 'json/common'
#
# ---
#
+# Option +allow_duplicate_key+ specifies whether duplicate keys in objects
+# should be ignored or cause an error to be raised:
+#
+# When not specified:
+# # The last value is used and a deprecation warning emitted.
+# JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
+# # warning: detected duplicate keys in JSON object.
+# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
+#
+# When set to `+true+`
+# # The last value is used.
+# JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
+#
+# When set to `+false+`, the future default:
+# JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
+#
+# ---
+#
# Option +allow_nan+ (boolean) specifies whether to allow
# NaN, Infinity, and MinusInfinity in +source+;
# defaults to +false+.
@@ -143,8 +170,47 @@ require 'json/common'
# ruby = JSON.parse(source, {allow_nan: true})
# ruby # => [NaN, Infinity, -Infinity]
#
+# ---
+#
+# Option +allow_trailing_comma+ (boolean) specifies whether to allow
+# trailing commas in objects and arrays;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
+#
+# ---
+#
+# Option +allow_control_characters+ (boolean) specifies whether to allow
+# unescaped ASCII control characters, such as newlines, in strings;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
+#
+# ---
+#
+# Option +allow_invalid_escape+ (boolean) specifies whether to ignore backslahes that are followed
+# by an invalid escape character in strings;
+# defaults to +false+.
+#
+# With the default, +false+:
+# JSON.parse('"Hell\o"') # invalid escape character in string (JSON::ParserError)
+#
+# When enabled:
+# JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello"
+#
# ====== Output Options
#
+# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
+# defaults to +false+.
+#
# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
# should be Symbols;
# defaults to +false+ (use Strings).
@@ -269,8 +335,27 @@ require 'json/common'
# JSON.generate(JSON::MinusInfinity)
#
# Allow:
-# ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
-# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
+# ruby = [Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity]
+# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,NaN,Infinity,-Infinity]'
+#
+# ---
+#
+# Option +allow_duplicate_key+ (boolean) specifies whether
+# hashes with duplicate keys should be allowed or produce an error.
+# defaults to emit a deprecation warning.
+#
+# With the default, (not set):
+# Warning[:deprecated] = true
+# JSON.generate({ foo: 1, "foo" => 2 })
+# # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
+# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
+# # => '{"foo":1,"foo":2}'
+#
+# With <tt>false</tt>
+# JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
+# # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
+#
+# In version 3.0, <tt>false</tt> will become the default.
#
# ---
#
@@ -285,6 +370,15 @@ require 'json/common'
# # Raises JSON::NestingError (nesting of 2 is too deep):
# JSON.generate(obj, max_nesting: 2)
#
+# ====== Escaping Options
+#
+# Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
+# and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
+# tags.
+#
+# Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
+# should be escaped.
+#
# ====== Output Options
#
# The default formatting options generate the most compact
@@ -342,6 +436,9 @@ require 'json/common'
#
# == \JSON Additions
#
+# Note that JSON Additions must only be used with trusted data, and is
+# deprecated.
+#
# When you "round trip" a non-\String object from Ruby to \JSON and back,
# you have a new \String, instead of the object you began with:
# ruby0 = Range.new(0, 2)
@@ -369,13 +466,13 @@ require 'json/common'
# json1 = JSON.generate(ruby)
# ruby1 = JSON.parse(json1, create_additions: true)
# # Make a nice display.
-# display = <<EOT
-# Generated JSON:
-# Without addition: #{json0} (#{json0.class})
-# With addition: #{json1} (#{json1.class})
-# Parsed JSON:
-# Without addition: #{ruby0.inspect} (#{ruby0.class})
-# With addition: #{ruby1.inspect} (#{ruby1.class})
+# display = <<~EOT
+# Generated JSON:
+# Without addition: #{json0} (#{json0.class})
+# With addition: #{json1} (#{json1.class})
+# Parsed JSON:
+# Without addition: #{ruby0.inspect} (#{ruby0.class})
+# With addition: #{ruby1.inspect} (#{ruby1.class})
# EOT
# puts display
#
@@ -553,13 +650,13 @@ require 'json/common'
# json1 = JSON.generate(foo1)
# obj1 = JSON.parse(json1, create_additions: true)
# # Make a nice display.
-# display = <<EOT
-# Generated JSON:
-# Without custom addition: #{json0} (#{json0.class})
-# With custom addition: #{json1} (#{json1.class})
-# Parsed JSON:
-# Without custom addition: #{obj0.inspect} (#{obj0.class})
-# With custom addition: #{obj1.inspect} (#{obj1.class})
+# display = <<~EOT
+# Generated JSON:
+# Without custom addition: #{json0} (#{json0.class})
+# With custom addition: #{json1} (#{json1.class})
+# Parsed JSON:
+# Without custom addition: #{obj0.inspect} (#{obj0.class})
+# With custom addition: #{obj1.inspect} (#{obj1.class})
# EOT
# puts display
#
@@ -574,10 +671,5 @@ require 'json/common'
#
module JSON
require 'json/version'
-
- begin
- require 'json/ext'
- rescue LoadError
- require 'json/pure'
- end
+ require 'json/ext'
end
diff --git a/ext/json/lib/json/add/bigdecimal.rb b/ext/json/lib/json/add/bigdecimal.rb
index c8b4f567cb..dc84572f31 100644
--- a/ext/json/lib/json/add/bigdecimal.rb
+++ b/ext/json/lib/json/add/bigdecimal.rb
@@ -1,29 +1,58 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
-defined?(::BigDecimal) or require 'bigdecimal'
+begin
+ require 'bigdecimal'
+rescue LoadError
+end
class BigDecimal
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
+
+ # See #as_json.
def self.json_create(object)
BigDecimal._load object['b']
end
- # Marshal the object to JSON.
+ # Methods <tt>BigDecimal#as_json</tt> and +BigDecimal.json_create+ may be used
+ # to serialize and deserialize a \BigDecimal object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>BigDecimal#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/bigdecimal'
+ # x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
+ # y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"}
+ # z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \BigDecimal object:
+ #
+ # BigDecimal.json_create(x) # => 0.2e1
+ # BigDecimal.json_create(y) # => 0.2e1
+ # BigDecimal.json_create(z) # => 0.2e1
#
- # method used for JSON marshalling support.
def as_json(*)
{
JSON.create_id => self.class.name,
- 'b' => _dump,
+ 'b' => _dump.force_encoding(Encoding::UTF_8),
}
end
- # return the JSON value
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/bigdecimal'
+ # puts BigDecimal(2).to_json
+ # puts BigDecimal(2.0, 4).to_json
+ # puts BigDecimal(Complex(2, 0)).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
+ # {"json_class":"BigDecimal","b":"36:0.2e1"}
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
+ #
def to_json(*args)
as_json.to_json(*args)
end
-end
+end if defined?(::BigDecimal)
diff --git a/ext/json/lib/json/add/complex.rb b/ext/json/lib/json/add/complex.rb
index e63e29fd22..9e3c6f2d0a 100644
--- a/ext/json/lib/json/add/complex.rb
+++ b/ext/json/lib/json/add/complex.rb
@@ -1,18 +1,31 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Complex
- # Deserializes JSON string by converting Real value <tt>r</tt>, imaginary
- # value <tt>i</tt>, to a Complex object.
+ # See #as_json.
def self.json_create(object)
Complex(object['r'], object['i'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Complex#as_json</tt> and +Complex.json_create+ may be used
+ # to serialize and deserialize a \Complex object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Complex#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/complex'
+ # x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0}
+ # y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Complex object:
+ #
+ # Complex.json_create(x) # => (2+0i)
+ # Complex.json_create(y) # => (2.0+4i)
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -21,7 +34,17 @@ class Complex
}
end
- # Stores class name (Complex) along with real value <tt>r</tt> and imaginary value <tt>i</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/complex'
+ # puts Complex(2).to_json
+ # puts Complex(2.0, 4).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Complex","r":2,"i":0}
+ # {"json_class":"Complex","r":2.0,"i":4}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/core.rb b/ext/json/lib/json/add/core.rb
index bfb017c460..61ff454212 100644
--- a/ext/json/lib/json/add/core.rb
+++ b/ext/json/lib/json/add/core.rb
@@ -1,4 +1,4 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
# This file requires the implementations of ruby core's custom objects for
# serialisation/deserialisation.
@@ -7,6 +7,7 @@ require 'json/add/date_time'
require 'json/add/exception'
require 'json/add/range'
require 'json/add/regexp'
+require 'json/add/string'
require 'json/add/struct'
require 'json/add/symbol'
require 'json/add/time'
diff --git a/ext/json/lib/json/add/date.rb b/ext/json/lib/json/add/date.rb
index 25523561a5..88a098b637 100644
--- a/ext/json/lib/json/add/date.rb
+++ b/ext/json/lib/json/add/date.rb
@@ -1,4 +1,4 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
@@ -6,16 +6,29 @@ require 'date'
class Date
- # Deserializes JSON string by converting Julian year <tt>y</tt>, month
- # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
+ # See #as_json.
def self.json_create(object)
civil(*object.values_at('y', 'm', 'd', 'sg'))
end
alias start sg unless method_defined?(:start)
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Date#as_json</tt> and +Date.json_create+ may be used
+ # to serialize and deserialize a \Date object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Date#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/date'
+ # x = Date.today.as_json
+ # # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Date object:
+ #
+ # Date.json_create(x)
+ # # => #<Date: 2023-11-21 ((2460270j,0s,0n),+0s,2299161j)>
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -26,8 +39,15 @@ class Date
}
end
- # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
- # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/date'
+ # puts Date.today.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/date_time.rb b/ext/json/lib/json/add/date_time.rb
index 38b0e86ab8..8b0bb5d181 100644
--- a/ext/json/lib/json/add/date_time.rb
+++ b/ext/json/lib/json/add/date_time.rb
@@ -1,4 +1,4 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
@@ -6,9 +6,7 @@ require 'date'
class DateTime
- # Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
- # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
- # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
+ # See #as_json.
def self.json_create(object)
args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
of_a, of_b = object['of'].split('/')
@@ -23,8 +21,21 @@ class DateTime
alias start sg unless method_defined?(:start)
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>DateTime#as_json</tt> and +DateTime.json_create+ may be used
+ # to serialize and deserialize a \DateTime object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>DateTime#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/datetime'
+ # x = DateTime.now.as_json
+ # # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \DateTime object:
+ #
+ # DateTime.json_create(x) # BUG? Raises Date::Error "invalid date"
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -39,9 +50,15 @@ class DateTime
}
end
- # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
- # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
- # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/datetime'
+ # puts DateTime.now.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/exception.rb b/ext/json/lib/json/add/exception.rb
index a107e5b3c4..e85d404982 100644
--- a/ext/json/lib/json/add/exception.rb
+++ b/ext/json/lib/json/add/exception.rb
@@ -1,20 +1,31 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Exception
- # Deserializes JSON string by constructing new Exception object with message
- # <tt>m</tt> and backtrace <tt>b</tt> serialized with <tt>to_json</tt>
+ # See #as_json.
def self.json_create(object)
result = new(object['m'])
result.set_backtrace object['b']
result
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Exception#as_json</tt> and +Exception.json_create+ may be used
+ # to serialize and deserialize a \Exception object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Exception#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/exception'
+ # x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Exception object:
+ #
+ # Exception.json_create(x) # => #<Exception: Foo>
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -23,8 +34,15 @@ class Exception
}
end
- # Stores class name (Exception) with message <tt>m</tt> and backtrace array
- # <tt>b</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/exception'
+ # puts Exception.new('Foo').to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Exception","m":"Foo","b":null}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/ostruct.rb b/ext/json/lib/json/add/ostruct.rb
index 686cf0025d..7750498144 100644
--- a/ext/json/lib/json/add/ostruct.rb
+++ b/ext/json/lib/json/add/ostruct.rb
@@ -1,19 +1,35 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
-require 'ostruct'
+begin
+ require 'ostruct'
+rescue LoadError
+end
class OpenStruct
- # Deserializes JSON string by constructing new Struct object with values
- # <tt>t</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(object['t'] || object[:t])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>OpenStruct#as_json</tt> and +OpenStruct.json_create+ may be used
+ # to serialize and deserialize a \OpenStruct object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>OpenStruct#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/ostruct'
+ # x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
+ # # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \OpenStruct object:
+ #
+ # OpenStruct.json_create(x)
+ # # => #<OpenStruct name='Rowdy', age=nil>
+ #
def as_json(*)
klass = self.class.name
klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
@@ -23,9 +39,16 @@ class OpenStruct
}
end
- # Stores class name (OpenStruct) with this struct's values <tt>t</tt> as a
- # JSON string.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/ostruct'
+ # puts OpenStruct.new('name' => 'Rowdy', :age => nil).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"OpenStruct","t":{'name':'Rowdy',"age":null}}
+ #
def to_json(*args)
as_json.to_json(*args)
end
-end
+end if defined?(::OpenStruct)
diff --git a/ext/json/lib/json/add/range.rb b/ext/json/lib/json/add/range.rb
index 93529fb1c4..408d2c32f6 100644
--- a/ext/json/lib/json/add/range.rb
+++ b/ext/json/lib/json/add/range.rb
@@ -1,18 +1,33 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Range
- # Deserializes JSON string by constructing new Range object with arguments
- # <tt>a</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(*object['a'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Range#as_json</tt> and +Range.json_create+ may be used
+ # to serialize and deserialize a \Range object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Range#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/range'
+ # x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]}
+ # y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]}
+ # z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Range object:
+ #
+ # Range.json_create(x) # => 1..4
+ # Range.json_create(y) # => 1...4
+ # Range.json_create(z) # => "a".."d"
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -20,9 +35,19 @@ class Range
}
end
- # Stores class name (Range) with JSON array of arguments <tt>a</tt> which
- # include <tt>first</tt> (integer), <tt>last</tt> (integer), and
- # <tt>exclude_end?</tt> (boolean) as JSON string.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/range'
+ # puts (1..4).to_json
+ # puts (1...4).to_json
+ # puts ('a'..'d').to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Range","a":[1,4,false]}
+ # {"json_class":"Range","a":[1,4,true]}
+ # {"json_class":"Range","a":["a","d",false]}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/rational.rb b/ext/json/lib/json/add/rational.rb
index f776226046..c95812ea8e 100644
--- a/ext/json/lib/json/add/rational.rb
+++ b/ext/json/lib/json/add/rational.rb
@@ -1,17 +1,31 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Rational
- # Deserializes JSON string by converting numerator value <tt>n</tt>,
- # denominator value <tt>d</tt>, to a Rational object.
+
+ # See #as_json.
def self.json_create(object)
Rational(object['n'], object['d'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Rational#as_json</tt> and +Rational.json_create+ may be used
+ # to serialize and deserialize a \Rational object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Rational#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/rational'
+ # x = Rational(2, 3).as_json
+ # # => {"json_class"=>"Rational", "n"=>2, "d"=>3}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Rational object:
+ #
+ # Rational.json_create(x)
+ # # => (2/3)
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -20,7 +34,15 @@ class Rational
}
end
- # Stores class name (Rational) along with numerator value <tt>n</tt> and denominator value <tt>d</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/rational'
+ # puts Rational(2, 3).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Rational","n":2,"d":3}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/regexp.rb b/ext/json/lib/json/add/regexp.rb
index 39d69fede7..aebfb2db5c 100644
--- a/ext/json/lib/json/add/regexp.rb
+++ b/ext/json/lib/json/add/regexp.rb
@@ -1,19 +1,30 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Regexp
- # Deserializes JSON string by constructing new Regexp object with source
- # <tt>s</tt> (Regexp or String) and options <tt>o</tt> serialized by
- # <tt>to_json</tt>
+ # See #as_json.
def self.json_create(object)
new(object['s'], object['o'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Regexp#as_json</tt> and +Regexp.json_create+ may be used
+ # to serialize and deserialize a \Regexp object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Regexp#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/regexp'
+ # x = /foo/.as_json
+ # # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Regexp object:
+ #
+ # Regexp.json_create(x) # => /foo/
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -22,8 +33,15 @@ class Regexp
}
end
- # Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
- # (Regexp or String) as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/regexp'
+ # puts /foo/.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Regexp","o":0,"s":"foo"}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/set.rb b/ext/json/lib/json/add/set.rb
index 71e2a0ac8b..1918353187 100644
--- a/ext/json/lib/json/add/set.rb
+++ b/ext/json/lib/json/add/set.rb
@@ -4,16 +4,27 @@ end
defined?(::Set) or require 'set'
class Set
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
+
+ # See #as_json.
def self.json_create(object)
new object['a']
end
- # Marshal the object to JSON.
+ # Methods <tt>Set#as_json</tt> and +Set.json_create+ may be used
+ # to serialize and deserialize a \Set object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Set#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/set'
+ # x = Set.new(%w/foo bar baz/).as_json
+ # # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Set object:
+ #
+ # Set.json_create(x) # => #<Set: {"foo", "bar", "baz"}>
#
- # method used for JSON marshalling support.
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -21,7 +32,15 @@ class Set
}
end
- # return the JSON value
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/set'
+ # puts Set.new(%w/foo bar baz/).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Set","a":["foo","bar","baz"]}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/string.rb b/ext/json/lib/json/add/string.rb
new file mode 100644
index 0000000000..9c3bde27fb
--- /dev/null
+++ b/ext/json/lib/json/add/string.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+class String
+ # 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 class method.
+ def self.json_create(object)
+ object["raw"].pack("C*")
+ end
+
+ # call-seq: to_json_raw_object()
+ #
+ # This method creates a raw object hash, that can be nested into
+ # other data structures and will be generated 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" => unpack("C*"),
+ }
+ end
+
+ # 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.
+ def to_json_raw(...)
+ to_json_raw_object.to_json(...)
+ end
+end
diff --git a/ext/json/lib/json/add/struct.rb b/ext/json/lib/json/add/struct.rb
index e8395ed42f..6760c3d86c 100644
--- a/ext/json/lib/json/add/struct.rb
+++ b/ext/json/lib/json/add/struct.rb
@@ -1,18 +1,32 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Struct
- # Deserializes JSON string by constructing new Struct object with values
- # <tt>v</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(*object['v'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Struct#as_json</tt> and +Struct.json_create+ may be used
+ # to serialize and deserialize a \Struct object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Struct#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/struct'
+ # Customer = Struct.new('Customer', :name, :address, :zip)
+ # x = Struct::Customer.new.as_json
+ # # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Struct object:
+ #
+ # Struct::Customer.json_create(x)
+ # # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
+ #
def as_json(*)
klass = self.class.name
klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
@@ -22,8 +36,16 @@ class Struct
}
end
- # Stores class name (Struct) with Struct values <tt>v</tt> as a JSON string.
- # Only named structs are supported.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/struct'
+ # Customer = Struct.new('Customer', :name, :address, :zip)
+ # puts Struct::Customer.new.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Struct","t":{'name':'Rowdy',"age":null}}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/symbol.rb b/ext/json/lib/json/add/symbol.rb
index 74b13a423f..806be4f025 100644
--- a/ext/json/lib/json/add/symbol.rb
+++ b/ext/json/lib/json/add/symbol.rb
@@ -1,11 +1,25 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Symbol
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+
+ # Methods <tt>Symbol#as_json</tt> and +Symbol.json_create+ may be used
+ # to serialize and deserialize a \Symbol object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Symbol#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/symbol'
+ # x = :foo.as_json
+ # # => {"json_class"=>"Symbol", "s"=>"foo"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Symbol object:
+ #
+ # Symbol.json_create(x) # => :foo
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -13,12 +27,25 @@ class Symbol
}
end
- # Stores class name (Symbol) with String representation of Symbol as a JSON string.
- def to_json(*a)
- as_json.to_json(*a)
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/symbol'
+ # puts :foo.to_json
+ #
+ # Output:
+ #
+ # # {"json_class":"Symbol","s":"foo"}
+ #
+ def to_json(state = nil, *a)
+ state = ::JSON::State.from_state(state)
+ if state.strict?
+ super
+ else
+ as_json.to_json(state, *a)
+ end
end
- # Deserializes JSON string by converting the <tt>string</tt> value stored in the object to a Symbol
+ # See #as_json.
def self.json_create(o)
o['s'].to_sym
end
diff --git a/ext/json/lib/json/add/time.rb b/ext/json/lib/json/add/time.rb
index b73acc4086..b03d4ff251 100644
--- a/ext/json/lib/json/add/time.rb
+++ b/ext/json/lib/json/add/time.rb
@@ -1,37 +1,51 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Time
- # Deserializes JSON string by converting time since epoch to Time
+ # See #as_json.
def self.json_create(object)
if usec = object.delete('u') # used to be tv_usec -> tv_nsec
object['n'] = usec * 1000
end
- if method_defined?(:tv_nsec)
- at(object['s'], Rational(object['n'], 1000))
- else
- at(object['s'], object['n'] / 1000)
- end
+ at(object['s'], Rational(object['n'], 1000))
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Time#as_json</tt> and +Time.json_create+ may be used
+ # to serialize and deserialize a \Time object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Time#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/time'
+ # x = Time.now.as_json
+ # # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Time object:
+ #
+ # Time.json_create(x)
+ # # => 2023-11-25 11:00:56.472846644 -0600
+ #
def as_json(*)
- nanoseconds = [ tv_usec * 1000 ]
- respond_to?(:tv_nsec) and nanoseconds << tv_nsec
- nanoseconds = nanoseconds.max
{
JSON.create_id => self.class.name,
's' => tv_sec,
- 'n' => nanoseconds,
+ 'n' => tv_nsec,
}
end
- # Stores class name (Time) with number of seconds since epoch and number of
- # microseconds for Time as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/time'
+ # puts Time.now.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Time","s":1700931678,"n":980650786}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index ea46896fcc..230bf08012 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -1,9 +1,123 @@
-#frozen_string_literal: false
+# frozen_string_literal: true
+
require 'json/version'
-require 'json/generic_object'
module JSON
+ autoload :GenericObject, 'json/generic_object'
+
+ module ParserOptions # :nodoc:
+ class << self
+ def prepare(opts)
+ if opts[:object_class] || opts[:array_class]
+ opts = opts.dup
+ on_load = opts[:on_load]
+
+ on_load = object_class_proc(opts[:object_class], on_load) if opts[:object_class]
+ on_load = array_class_proc(opts[:array_class], on_load) if opts[:array_class]
+ opts[:on_load] = on_load
+ end
+
+ if opts.fetch(:create_additions, false) != false
+ opts = create_additions_proc(opts)
+ end
+
+ opts
+ end
+
+ private
+
+ def object_class_proc(object_class, on_load)
+ ->(obj) do
+ if Hash === obj
+ object = object_class.new
+ obj.each { |k, v| object[k] = v }
+ obj = object
+ end
+ on_load.nil? ? obj : on_load.call(obj)
+ end
+ end
+
+ def array_class_proc(array_class, on_load)
+ ->(obj) do
+ if Array === obj
+ array = array_class.new
+ obj.each { |v| array << v }
+ obj = array
+ end
+ on_load.nil? ? obj : on_load.call(obj)
+ end
+ end
+
+ # TODO: extract :create_additions support to another gem for version 3.0
+ def create_additions_proc(opts)
+ if opts[:symbolize_names]
+ raise ArgumentError, "options :symbolize_names and :create_additions cannot be used in conjunction"
+ end
+
+ opts = opts.dup
+ create_additions = opts.fetch(:create_additions, false)
+ on_load = opts[:on_load]
+ object_class = opts[:object_class] || Hash
+
+ opts[:on_load] = ->(object) do
+ case object
+ when String
+ opts[:match_string]&.each do |pattern, klass|
+ if match = pattern.match(object)
+ create_additions_warning if create_additions.nil?
+ object = klass.json_create(object)
+ break
+ end
+ end
+ when object_class
+ if opts[:create_additions] != false
+ if class_path = object[JSON.create_id]
+ klass = begin
+ Object.const_get(class_path)
+ rescue NameError => e
+ raise ArgumentError, "can't get const #{class_path}: #{e}"
+ end
+
+ if klass.respond_to?(:json_creatable?) ? klass.json_creatable? : klass.respond_to?(:json_create)
+ create_additions_warning if create_additions.nil?
+ object = klass.json_create(object)
+ end
+ end
+ end
+ end
+
+ on_load.nil? ? object : on_load.call(object)
+ end
+
+ opts
+ end
+
+ def create_additions_warning
+ JSON.deprecation_warning "JSON.load implicit support for `create_additions: true` is deprecated " \
+ "and will be removed in 3.0, use JSON.unsafe_load or explicitly " \
+ "pass `create_additions: true`"
+ end
+ end
+ end
+
class << self
+ def deprecation_warning(message, uplevel = 3) # :nodoc:
+ gem_root = File.expand_path("..", __dir__) + "/"
+ caller_locations(uplevel, 10).each do |frame|
+ if frame.path.nil? || frame.path.start_with?(gem_root) || frame.path.end_with?("/truffle/cext_ruby.rb", ".c")
+ uplevel += 1
+ else
+ break
+ end
+ end
+
+ if RUBY_VERSION >= "3.0"
+ warn(message, uplevel: uplevel, category: :deprecated)
+ else
+ warn(message, uplevel: uplevel)
+ end
+ end
+
# :call-seq:
# JSON[object] -> new_array or new_string
#
@@ -15,17 +129,20 @@ module JSON
# Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
# ruby = [0, 1, nil]
# JSON[ruby] # => '[0,1,null]'
- def [](object, opts = {})
- if object.respond_to? :to_str
- JSON.parse(object.to_str, opts)
- else
- JSON.generate(object, opts)
+ def [](object, opts = nil)
+ if object.is_a?(String)
+ return JSON.parse(object, opts)
+ elsif object.respond_to?(:to_str)
+ str = object.to_str
+ if str.is_a?(String)
+ return JSON.parse(str, opts)
+ end
end
+
+ JSON.generate(object, opts)
end
- # Returns the JSON parser class that is used by JSON. This is either
- # JSON::Ext::Parser or JSON::Pure::Parser:
- # JSON.parser # => JSON::Ext::Parser
+ # Returns the JSON parser class that is used by JSON.
attr_reader :parser
# Set the JSON parser class _parser_ to be used by JSON.
@@ -35,132 +152,153 @@ module JSON
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.to_s.split(/::/).inject(Object) do |p, c|
- case
- when c.empty? then p
- when p.const_defined?(c, true) then p.const_get(c)
- else
- begin
- p.const_missing(c)
- rescue NameError => e
- raise ArgumentError, "can't get const #{path}: #{e}"
- end
- end
- end
- end
-
# Set the module _generator_ to be used by JSON.
def generator=(generator) # :nodoc:
old, $VERBOSE = $VERBOSE, nil
@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
+ if generator.const_defined?(:GeneratorMethods)
+ generator_methods = generator::GeneratorMethods
+ for const in generator_methods.constants
+ klass = 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
- include modul
end
end
self.state = generator::State
- const_set :State, self.state
- const_set :SAFE_STATE_PROTOTYPE, State.new # for JRuby
- const_set :FAST_STATE_PROTOTYPE, create_fast_state
- const_set :PRETTY_STATE_PROTOTYPE, create_pretty_state
+ const_set :State, state
ensure
$VERBOSE = old
end
- def create_fast_state
- State.new(
- :indent => '',
- :space => '',
- :object_nl => "",
- :array_nl => "",
- :max_nesting => false
- )
- end
-
- def create_pretty_state
- State.new(
- :indent => ' ',
- :space => ' ',
- :object_nl => "\n",
- :array_nl => "\n"
- )
- end
-
- # Returns the JSON generator module that is used by JSON. This is
- # either JSON::Ext::Generator or JSON::Pure::Generator:
- # JSON.generator # => JSON::Ext::Generator
+ # Returns the JSON generator module that is used by JSON.
attr_reader :generator
- # Sets or Returns the JSON generator state class that is used by JSON. This is
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
- # JSON.state # => JSON::Ext::Generator::State
+ # Sets or Returns the JSON generator state class that is used by JSON.
attr_accessor :state
- end
- DEFAULT_CREATE_ID = 'json_class'.freeze
- private_constant :DEFAULT_CREATE_ID
+ private
+
+ # Called from the extension when a hash has both string and symbol keys
+ def on_mixed_keys_hash(hash, do_raise)
+ set = {}
+ hash.each_key do |key|
+ key_str = key.to_s
+
+ if set[key_str]
+ message = "detected duplicate key #{key_str.inspect} in #{hash.inspect}"
+ if do_raise
+ raise GeneratorError, message
+ else
+ deprecation_warning("#{message}.\nThis will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`")
+ end
+ else
+ set[key_str] = true
+ end
+ end
+ end
- CREATE_ID_TLS_KEY = "JSON.create_id".freeze
- private_constant :CREATE_ID_TLS_KEY
+ def deprecated_singleton_attr_accessor(*attrs)
+ args = RUBY_VERSION >= "3.0" ? ", category: :deprecated" : ""
+ attrs.each do |attr|
+ singleton_class.class_eval <<~RUBY
+ def #{attr}
+ warn "JSON.#{attr} is deprecated and will be removed in json 3.0.0", uplevel: 1 #{args}
+ @#{attr}
+ end
+
+ def #{attr}=(val)
+ warn "JSON.#{attr}= is deprecated and will be removed in json 3.0.0", uplevel: 1 #{args}
+ @#{attr} = val
+ end
+
+ def _#{attr}
+ @#{attr}
+ end
+ RUBY
+ end
+ end
+ end
# Sets create identifier, which is used to decide if the _json_create_
# hook of a class should be called; initial value is +json_class+:
# JSON.create_id # => 'json_class'
def self.create_id=(new_value)
- Thread.current[CREATE_ID_TLS_KEY] = new_value.dup.freeze
+ Thread.current[:"JSON.create_id"] = new_value.dup.freeze
end
# Returns the current create identifier.
# See also JSON.create_id=.
def self.create_id
- Thread.current[CREATE_ID_TLS_KEY] || DEFAULT_CREATE_ID
+ Thread.current[:"JSON.create_id"] || 'json_class'
end
- NaN = 0.0/0
+ NaN = Float::NAN
- Infinity = 1.0/0
+ Infinity = Float::INFINITY
MinusInfinity = -Infinity
# The base exception for JSON errors.
- class JSONError < StandardError
- def self.wrap(exception)
- obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
- obj.set_backtrace exception.backtrace
- obj
- end
- end
+ class JSONError < StandardError; end
# This exception is raised if a parser error occurs.
- class ParserError < JSONError; end
+ class ParserError < JSONError
+ attr_reader :line, :column
+ end
# This exception is raised if the nesting of parsed data structures is too
# deep.
class NestingError < ParserError; end
- # :stopdoc:
- class CircularDatastructure < NestingError; end
- # :startdoc:
-
# This exception is raised if a generator or unparser error occurs.
- class GeneratorError < JSONError; end
- # For backwards compatibility
- UnparserError = GeneratorError # :nodoc:
+ class GeneratorError < JSONError
+ attr_reader :invalid_object
+
+ def initialize(message, invalid_object = nil)
+ super(message)
+ @invalid_object = invalid_object
+ end
+
+ def detailed_message(...)
+ # Exception#detailed_message doesn't exist until Ruby 3.2
+ super_message = defined?(super) ? super : message
- # 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
+ if @invalid_object.nil?
+ super_message
+ else
+ "#{super_message}\nInvalid object: #{@invalid_object.inspect}"
+ end
+ end
+ end
+
+ # Fragment of JSON document that is to be included as is:
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
+ # JSON.generate({ count: 3, items: fragments })
+ #
+ # This allows to easily assemble multiple JSON fragments that have
+ # been persisted somewhere without having to parse them nor resorting
+ # to string interpolation.
+ #
+ # Note: no validation is performed on the provided string. It is the
+ # responsibility of the caller to ensure the string contains valid JSON.
+ Fragment = Struct.new(:json) do
+ def initialize(json)
+ unless string = String.try_convert(json)
+ raise TypeError, " no implicit conversion of #{json.class} into String"
+ end
+
+ super(string)
+ end
+
+ def to_json(state = nil, *)
+ json
+ end
+ end
module_function
@@ -192,17 +330,17 @@ module JSON
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
#
# Parses nested JSON objects:
- # source = <<-EOT
- # {
- # "name": "Dave",
- # "age" :40,
- # "hats": [
- # "Cattleman's",
- # "Panama",
- # "Tophat"
- # ]
- # }
- # EOT
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
# ruby = JSON.parse(source)
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
#
@@ -212,10 +350,17 @@ module JSON
# # Raises JSON::ParserError (783: unexpected token at ''):
# JSON.parse('')
#
- def parse(source, opts = {})
- Parser.new(source, **(opts||{})).parse
+ def parse(source, opts = nil)
+ opts = ParserOptions.prepare(opts) unless opts.nil?
+ Parser.parse(source, opts)
end
+ PARSE_L_OPTIONS = {
+ max_nesting: false,
+ allow_nan: true,
+ }.freeze
+ private_constant :PARSE_L_OPTIONS
+
# :call-seq:
# JSON.parse!(source, opts) -> object
#
@@ -227,12 +372,12 @@ module JSON
# - Option +max_nesting+, if not provided, defaults to +false+,
# which disables checking for nesting depth.
# - Option +allow_nan+, if not provided, defaults to +true+.
- def parse!(source, opts = {})
- opts = {
- :max_nesting => false,
- :allow_nan => true
- }.merge(opts)
- Parser.new(source, **(opts||{})).parse
+ def parse!(source, opts = nil)
+ if opts.nil?
+ parse(source, PARSE_L_OPTIONS)
+ else
+ parse(source, PARSE_L_OPTIONS.merge(opts))
+ end
end
# :call-seq:
@@ -242,8 +387,8 @@ module JSON
# parse(File.read(path), opts)
#
# See method #parse.
- def load_file(filespec, opts = {})
- parse(File.read(filespec), opts)
+ def load_file(filespec, opts = nil)
+ parse(File.read(filespec, encoding: Encoding::UTF_8), opts)
end
# :call-seq:
@@ -253,8 +398,8 @@ module JSON
# JSON.parse!(File.read(path, opts))
#
# See method #parse!
- def load_file!(filespec, opts = {})
- parse!(File.read(filespec), opts)
+ def load_file!(filespec, opts = nil)
+ parse!(File.read(filespec, encoding: Encoding::UTF_8), opts)
end
# :call-seq:
@@ -262,7 +407,7 @@ module JSON
#
# Returns a \String containing the generated \JSON data.
#
- # See also JSON.fast_generate, JSON.pretty_generate.
+ # See also JSON.pretty_generate.
#
# Argument +obj+ is the Ruby object to be converted to \JSON.
#
@@ -295,30 +440,12 @@ module JSON
#
def generate(obj, opts = nil)
if State === opts
- state, opts = opts, nil
+ opts.generate(obj)
else
- state = State.new
- end
- 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 = state.configure(opts)
+ State.generate(obj, opts, nil)
end
- state.generate(obj)
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:
-
# :call-seq:
# JSON.fast_generate(obj, opts) -> new_string
#
@@ -333,29 +460,21 @@ module JSON
# # Raises SystemStackError (stack level too deep):
# JSON.fast_generate(a)
def fast_generate(obj, opts = nil)
- if State === opts
- state, opts = opts, nil
+ if RUBY_VERSION >= "3.0"
+ warn "JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
else
- state = JSON.create_fast_state
+ warn "JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
end
- 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
- state.generate(obj)
+ generate(obj, opts)
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:
+ PRETTY_GENERATE_OPTIONS = {
+ indent: ' ',
+ space: ' ',
+ object_nl: "\n",
+ array_nl: "\n",
+ }.freeze
+ private_constant :PRETTY_GENERATE_OPTIONS
# :call-seq:
# JSON.pretty_generate(obj, opts = nil) -> new_string
@@ -388,49 +507,60 @@ module JSON
# }
#
def pretty_generate(obj, opts = nil)
- if State === opts
- state, opts = opts, nil
- else
- state = JSON.create_pretty_state
- end
+ return opts.generate(obj) if State === opts
+
+ options = PRETTY_GENERATE_OPTIONS
+
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"
+ unless opts.is_a?(Hash)
+ 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
end
- state.configure(opts)
+ options = options.merge(opts)
end
- state.generate(obj)
+
+ State.generate(obj, options, nil)
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:
+ # Sets or returns default options for the JSON.unsafe_load method.
+ # Initially:
+ # opts = JSON.load_default_options
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
+ deprecated_singleton_attr_accessor :unsafe_load_default_options
- class << self
- # Sets or returns default options for the JSON.load method.
- # Initially:
- # opts = JSON.load_default_options
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
- attr_accessor :load_default_options
- end
- self.load_default_options = {
+ @unsafe_load_default_options = {
:max_nesting => false,
:allow_nan => true,
- :allow_blank => true,
+ :allow_blank => true,
:create_additions => true,
}
+ # Sets or returns default options for the JSON.load method.
+ # Initially:
+ # opts = JSON.load_default_options
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
+ deprecated_singleton_attr_accessor :load_default_options
+
+ @load_default_options = {
+ :allow_nan => true,
+ :allow_blank => true,
+ :create_additions => nil,
+ }
# :call-seq:
- # JSON.load(source, proc = nil, options = {}) -> object
+ # JSON.unsafe_load(source, options = {}) -> object
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
#
# Returns the Ruby objects created by parsing the given +source+.
#
+ # BEWARE: This method is meant to serialise data from trusted user input,
+ # like from your own database server or clients under your control, it could
+ # be dangerous to allow untrusted users to pass JSON sources into it.
+ #
# - Argument +source+ must be, or be convertible to, a \String:
# - If +source+ responds to instance method +to_str+,
# <tt>source.to_str</tt> becomes the source.
@@ -445,12 +575,9 @@ module JSON
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
# It will be called recursively with each result (depth-first order).
# See details below.
- # BEWARE: This method is meant to serialise data from trusted user input,
- # like from your own database server or clients under your control, it could
- # be dangerous to allow untrusted users to pass JSON sources into it.
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
- # The default options can be changed via method JSON.load_default_options=.
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
#
# ---
#
@@ -458,17 +585,188 @@ module JSON
# <tt>parse(source, opts)</tt>; see #parse.
#
# Source for following examples:
- # source = <<-EOT
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
+ #
+ # Load a \String:
+ # ruby = JSON.unsafe_load(source)
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load an \IO object:
+ # require 'stringio'
+ # object = JSON.unsafe_load(StringIO.new(source))
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # Load a \File object:
+ # path = 't.json'
+ # File.write(path, source)
+ # File.open(path) do |file|
+ # JSON.unsafe_load(file)
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
+ #
+ # ---
+ #
+ # When +proc+ is given:
+ # - Modifies +source+ as above.
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
+ # - Recursively calls <tt>proc(result)</tt>.
+ # - Returns the final result.
+ #
+ # Example:
+ # require 'json'
+ #
+ # # Some classes for the example.
+ # class Base
+ # def initialize(attributes)
+ # @attributes = attributes
+ # end
+ # end
+ # class User < Base; end
+ # class Account < Base; end
+ # class Admin < Base; end
+ # # The JSON source.
+ # json = <<-EOF
# {
- # "name": "Dave",
- # "age" :40,
- # "hats": [
- # "Cattleman's",
- # "Panama",
- # "Tophat"
- # ]
+ # "users": [
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
+ # {"type": "User", "username": "john", "email": "john@example.com"}
+ # ],
+ # "accounts": [
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
+ # ],
+ # "admins": {"type": "Admin", "password": "0wn3d"}
# }
- # EOT
+ # EOF
+ # # Deserializer method.
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
+ # type = obj.is_a?(Hash) && obj["type"]
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
+ # end
+ # # Call to JSON.unsafe_load
+ # ruby = JSON.unsafe_load(json, proc {|obj|
+ # case obj
+ # when Hash
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
+ # when Array
+ # obj.map! {|v| deserialize_obj v }
+ # end
+ # obj
+ # })
+ # pp ruby
+ # Output:
+ # {"users"=>
+ # [#<User:0x00000000064c4c98
+ # @attributes=
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
+ # #<User:0x00000000064c4bd0
+ # @attributes=
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
+ # "accounts"=>
+ # [{"account"=>
+ # #<Account:0x00000000064c4928
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
+ # {"account"=>
+ # #<Account:0x00000000064c4680
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
+ # "admins"=>
+ # #<Admin:0x00000000064c41f8
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
+ #
+ def unsafe_load(source, proc = nil, options = nil)
+ opts = if options.nil?
+ if proc && proc.is_a?(Hash)
+ options, proc = proc, nil
+ options
+ else
+ _unsafe_load_default_options
+ end
+ else
+ _unsafe_load_default_options.merge(options)
+ end
+
+ unless source.is_a?(String)
+ if source.respond_to? :to_str
+ source = source.to_str
+ elsif source.respond_to? :to_io
+ source = source.to_io.read
+ elsif source.respond_to?(:read)
+ source = source.read
+ end
+ end
+
+ if opts[:allow_blank] && (source.nil? || source.empty?)
+ source = 'null'
+ end
+
+ if proc
+ opts = opts.dup
+ opts[:on_load] = proc.to_proc
+ end
+
+ parse(source, opts)
+ end
+
+ # :call-seq:
+ # JSON.load(source, options = {}) -> object
+ # JSON.load(source, proc = nil, options = {}) -> object
+ #
+ # Returns the Ruby objects created by parsing the given +source+.
+ #
+ # BEWARE: This method is meant to serialise data from trusted user input,
+ # like from your own database server or clients under your control, it could
+ # be dangerous to allow untrusted users to pass JSON sources into it.
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
+ #
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
+ # non native type is deserialized, without `create_additions` being explicitly
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
+ # by default.
+ #
+ # - Argument +source+ must be, or be convertible to, a \String:
+ # - If +source+ responds to instance method +to_str+,
+ # <tt>source.to_str</tt> becomes the source.
+ # - If +source+ responds to instance method +to_io+,
+ # <tt>source.to_io.read</tt> becomes the source.
+ # - If +source+ responds to instance method +read+,
+ # <tt>source.read</tt> becomes the source.
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
+ # - Option +allow_blank+ specifies a truthy value.
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
+ # - Otherwise, +source+ remains the source.
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
+ # It will be called recursively with each result (depth-first order).
+ # See details below.
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
+ # The default options can be changed via method JSON.load_default_options=.
+ #
+ # ---
+ #
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
+ # <tt>parse(source, opts)</tt>; see #parse.
+ #
+ # Source for following examples:
+ # source = <<~JSON
+ # {
+ # "name": "Dave",
+ # "age" :40,
+ # "hats": [
+ # "Cattleman's",
+ # "Panama",
+ # "Tophat"
+ # ]
+ # }
+ # JSON
#
# Load a \String:
# ruby = JSON.load(source)
@@ -533,6 +831,7 @@ module JSON
# when Array
# obj.map! {|v| deserialize_obj v }
# end
+ # obj
# })
# pp ruby
# Output:
@@ -554,51 +853,53 @@ module JSON
# #<Admin:0x00000000064c41f8
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
#
- def load(source, proc = nil, options = {})
- opts = load_default_options.merge options
- if source.respond_to? :to_str
- source = source.to_str
- elsif source.respond_to? :to_io
- source = source.to_io.read
- elsif source.respond_to?(:read)
- source = source.read
+ def load(source, proc = nil, options = nil)
+ if proc && options.nil? && proc.is_a?(Hash)
+ options = proc
+ proc = nil
end
- if opts[:allow_blank] && (source.nil? || source.empty?)
- source = 'null'
- end
- result = parse(source, opts)
- recurse_proc(result, &proc) if proc
- result
- end
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
- def recurse_proc(result, &proc) # :nodoc:
- 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
+ opts = if options.nil?
+ if proc && proc.is_a?(Hash)
+ options, proc = proc, nil
+ options
+ else
+ _load_default_options
+ end
else
- proc.call result
+ _load_default_options.merge(options)
end
- end
- alias restore load
- module_function :restore
+ unless source.is_a?(String)
+ if source.respond_to? :to_str
+ source = source.to_str
+ elsif source.respond_to? :to_io
+ source = source.to_io.read
+ elsif source.respond_to?(:read)
+ source = source.read
+ end
+ end
- class << self
- # Sets or returns the default options for the JSON.dump method.
- # Initially:
- # opts = JSON.dump_default_options
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
- attr_accessor :dump_default_options
+ if opts[:allow_blank] && (source.nil? || (String === source && source.empty?))
+ source = 'null'
+ end
+
+ if proc
+ opts = opts.dup
+ opts[:on_load] = proc.to_proc
+ end
+
+ parse(source, opts)
end
- self.dump_default_options = {
+
+ # Sets or returns the default options for the JSON.dump method.
+ # Initially:
+ # opts = JSON.dump_default_options
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
+ deprecated_singleton_attr_accessor :dump_default_options
+ @dump_default_options = {
:max_nesting => false,
:allow_nan => true,
- :escape_slash => false,
}
# :call-seq:
@@ -628,30 +929,198 @@ module JSON
# puts File.read(path)
# Output:
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
- 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
+ def dump(obj, anIO = nil, limit = nil, kwargs = nil)
+ if kwargs.nil?
+ if limit.nil?
+ if anIO.is_a?(Hash)
+ kwargs = anIO
+ anIO = nil
+ end
+ elsif limit.is_a?(Hash)
+ kwargs = limit
+ limit = nil
+ end
+ end
+
+ unless anIO.nil?
+ if anIO.respond_to?(:to_io)
+ anIO = anIO.to_io
+ elsif limit.nil? && !anIO.respond_to?(:write)
+ anIO, limit = nil, anIO
end
end
- opts = JSON.dump_default_options
+
+ opts = JSON._dump_default_options
opts = opts.merge(:max_nesting => limit) if limit
- result = generate(obj, opts)
- if anIO
- anIO.write result
- anIO
+ opts = opts.merge(kwargs) if kwargs
+
+ begin
+ State.generate(obj, opts, anIO)
+ rescue JSON::NestingError
+ raise ArgumentError, "exceed depth limit"
+ end
+ end
+
+ # :stopdoc:
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
+ # so usage still exist in the wild.
+ def unparse(...)
+ if RUBY_VERSION >= "3.0"
+ warn "JSON.unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
+ else
+ warn "JSON.unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
+ end
+ generate(...)
+ end
+ module_function :unparse
+
+ def fast_unparse(...)
+ if RUBY_VERSION >= "3.0"
+ warn "JSON.fast_unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
+ else
+ warn "JSON.fast_unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
+ end
+ generate(...)
+ end
+ module_function :fast_unparse
+
+ def pretty_unparse(...)
+ if RUBY_VERSION >= "3.0"
+ warn "JSON.pretty_unparse is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1, category: :deprecated
+ else
+ warn "JSON.pretty_unparse is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1
+ end
+ pretty_generate(...)
+ end
+ module_function :fast_unparse
+
+ def restore(...)
+ if RUBY_VERSION >= "3.0"
+ warn "JSON.restore is deprecated and will be removed in json 3.0.0, just use JSON.load", uplevel: 1, category: :deprecated
else
- result
+ warn "JSON.restore is deprecated and will be removed in json 3.0.0, just use JSON.load", uplevel: 1
+ end
+ load(...)
+ end
+ module_function :restore
+
+ class << self
+ private
+
+ def const_missing(const_name)
+ case const_name
+ when :PRETTY_STATE_PROTOTYPE
+ if RUBY_VERSION >= "3.0"
+ warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1, category: :deprecated
+ else
+ warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1
+ end
+ state.new(PRETTY_GENERATE_OPTIONS)
+ else
+ super
+ end
+ end
+ end
+ # :startdoc:
+
+ # JSON::Coder holds a parser and generator configuration.
+ #
+ # module MyApp
+ # JSONC_CODER = JSON::Coder.new(
+ # allow_trailing_comma: true
+ # )
+ # end
+ #
+ # MyApp::JSONC_CODER.load(document)
+ #
+ class Coder
+ # :call-seq:
+ # JSON.new(options = nil, &block)
+ #
+ # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
+ # See {Parsing Options}[rdoc-ref:JSON@Parsing+Options],
+ # and {Generating Options}[rdoc-ref:JSON@Generating+Options].
+ #
+ # For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
+ # encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
+ # \JSON counterpart:
+ #
+ # module MyApp
+ # API_JSON_CODER = JSON::Coder.new do |object|
+ # case object
+ # when Time
+ # object.iso8601(3)
+ # else
+ # object # Unknown type, will raise
+ # end
+ # end
+ # end
+ #
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
+ #
+ def initialize(options = nil, &as_json)
+ if options.nil?
+ options = { strict: true }
+ else
+ options = options.dup
+ options[:strict] = true
+ end
+ options[:as_json] = as_json if as_json
+
+ @state = State.new(options).freeze
+ @parser_config = Ext::Parser::Config.new(ParserOptions.prepare(options)).freeze
+ end
+
+ # call-seq:
+ # dump(object) -> String
+ # dump(object, io) -> io
+ #
+ # Serialize the given object into a \JSON document.
+ def dump(object, io = nil)
+ @state.generate(object, io)
+ end
+ alias_method :generate, :dump
+
+ # call-seq:
+ # load(string) -> Object
+ #
+ # Parse the given \JSON document and return an equivalent Ruby object.
+ def load(source)
+ @parser_config.parse(source)
+ end
+ alias_method :parse, :load
+
+ # call-seq:
+ # load(path) -> Object
+ #
+ # Parse the given \JSON document and return an equivalent Ruby object.
+ def load_file(path)
+ load(File.read(path, encoding: Encoding::UTF_8))
end
- rescue JSON::NestingError
- raise ArgumentError, "exceed depth limit"
end
- # Encodes string using String.encode.
- def self.iconv(to, from, string)
- string.encode(to, from)
+ module GeneratorMethods
+ # call-seq: to_json(*)
+ #
+ # Converts this object into a JSON string.
+ # If this object doesn't directly maps to a JSON native type,
+ # first convert it to a string (calling #to_s), then 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(state = nil, *)
+ obj = case self
+ when nil, false, true, Integer, Float, Array, Hash
+ self
+ else
+ "#{self}"
+ end
+
+ if state.nil?
+ JSON::State._generate_no_fallback(obj, nil, nil)
+ else
+ JSON::State.from_state(state)._generate_no_fallback(obj)
+ end
+ end
end
end
@@ -661,8 +1130,14 @@ module ::Kernel
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
# one line.
def j(*objs)
+ if RUBY_VERSION >= "3.0"
+ warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
+ else
+ warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1
+ end
+
objs.each do |obj|
- puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
+ puts JSON.generate(obj, :allow_nan => true, :max_nesting => false)
end
nil
end
@@ -670,8 +1145,14 @@ module ::Kernel
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
# indentation and over many lines.
def jj(*objs)
+ if RUBY_VERSION >= "3.0"
+ warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
+ else
+ warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1
+ end
+
objs.each do |obj|
- puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
+ puts JSON.pretty_generate(obj, :allow_nan => true, :max_nesting => false)
end
nil
end
@@ -682,22 +1163,11 @@ module ::Kernel
#
# The _opts_ argument is passed through to generate/parse respectively. See
# generate and parse for their documentation.
- def JSON(object, *args)
- if object.respond_to? :to_str
- JSON.parse(object.to_str, args.first)
- else
- JSON.generate(object, args.first)
- end
+ def JSON(object, opts = nil)
+ JSON[object, opts]
end
end
-# Extends any Class to include _json_creatable?_ method.
-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. The hash
- # should include the required data.
- def json_creatable?
- respond_to?(:json_create)
- end
+class Object
+ include JSON::GeneratorMethods
end
diff --git a/ext/json/lib/json/ext.rb b/ext/json/lib/json/ext.rb
index 7264a857fa..5bacc5e371 100644
--- a/ext/json/lib/json/ext.rb
+++ b/ext/json/lib/json/ext.rb
@@ -1,15 +1,45 @@
+# frozen_string_literal: true
+
require 'json/common'
module JSON
# This module holds all the modules/classes that implement JSON's
# functionality as C extensions.
module Ext
+ class Parser
+ class << self
+ def parse(...)
+ new(...).parse
+ end
+ alias_method :parse, :parse # Allow redefinition by extensions
+ end
+
+ def initialize(source, opts = nil)
+ @source = source
+ @config = Config.new(opts)
+ end
+
+ def source
+ @source.dup
+ end
+
+ def parse
+ @config.parse(@source)
+ end
+ end
+
require 'json/ext/parser'
- require 'json/ext/generator'
- $DEBUG and warn "Using Ext extension for JSON."
- JSON.parser = Parser
- JSON.generator = Generator
+ Ext::Parser::Config = Ext::ParserConfig
+ JSON.parser = Ext::Parser
+
+ if RUBY_ENGINE == 'truffleruby'
+ require 'json/truffle_ruby/generator'
+ JSON.generator = JSON::TruffleRuby::Generator
+ else
+ require 'json/ext/generator'
+ JSON.generator = Generator
+ end
end
- JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
+ JSON_LOADED = true unless defined?(JSON::JSON_LOADED)
end
diff --git a/ext/json/lib/json/ext/generator/state.rb b/ext/json/lib/json/ext/generator/state.rb
new file mode 100644
index 0000000000..e4f425af6a
--- /dev/null
+++ b/ext/json/lib/json/ext/generator/state.rb
@@ -0,0 +1,103 @@
+# frozen_string_literal: true
+
+module JSON
+ module Ext
+ module Generator
+ class State
+ # call-seq: new(opts = {})
+ #
+ # Instantiates a new State object, configured by _opts_.
+ #
+ # Argument +opts+, if given, contains a \Hash of options for the generation.
+ # See {Generating Options}[rdoc-ref:JSON@Generating+Options].
+ def initialize(opts = nil)
+ if opts && !opts.empty?
+ configure(opts)
+ end
+ end
+
+ # call-seq: configure(opts)
+ #
+ # Configure this State instance with the Hash _opts_, and return
+ # itself.
+ def configure(opts)
+ unless opts.is_a?(Hash)
+ 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
+ end
+ _configure(opts)
+ end
+
+ alias_method :merge, :configure
+
+ # call-seq: to_h
+ #
+ # Returns the configuration instance variables as a hash, that can be
+ # passed to the configure method.
+ def to_h
+ result = {
+ indent: indent,
+ space: space,
+ space_before: space_before,
+ object_nl: object_nl,
+ array_nl: array_nl,
+ as_json: as_json,
+ allow_nan: allow_nan?,
+ ascii_only: ascii_only?,
+ max_nesting: max_nesting,
+ script_safe: script_safe?,
+ strict: strict?,
+ depth: depth,
+ buffer_initial_length: buffer_initial_length,
+ }
+
+ allow_duplicate_key = allow_duplicate_key?
+ unless allow_duplicate_key.nil?
+ result[:allow_duplicate_key] = allow_duplicate_key
+ end
+
+ instance_variables.each do |iv|
+ iv = iv.to_s[1..-1]
+ result[iv.to_sym] = self[iv]
+ end
+
+ result
+ end
+
+ alias_method :to_hash, :to_h
+
+ # call-seq: [](name)
+ #
+ # Returns the value returned by method +name+.
+ def [](name)
+ ::JSON.deprecation_warning("JSON::State#[] is deprecated and will be removed in json 3.0.0")
+
+ if respond_to?(name)
+ __send__(name)
+ else
+ instance_variable_get("@#{name}") if
+ instance_variables.include?("@#{name}".to_sym) # avoid warning
+ end
+ end
+
+ # call-seq: []=(name, value)
+ #
+ # Sets the attribute name to value.
+ def []=(name, value)
+ ::JSON.deprecation_warning("JSON::State#[]= is deprecated and will be removed in json 3.0.0")
+
+ if respond_to?(name_writer = "#{name}=")
+ __send__ name_writer, value
+ else
+ instance_variable_set "@#{name}", value
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/ext/json/lib/json/generic_object.rb b/ext/json/lib/json/generic_object.rb
index 108309db26..5c8ace354b 100644
--- a/ext/json/lib/json/generic_object.rb
+++ b/ext/json/lib/json/generic_object.rb
@@ -1,5 +1,9 @@
-#frozen_string_literal: false
-require 'ostruct'
+# frozen_string_literal: true
+begin
+ require 'ostruct'
+rescue LoadError
+ warn "JSON::GenericObject requires 'ostruct'. Please install it with `gem install ostruct`."
+end
module JSON
class GenericObject < OpenStruct
@@ -48,14 +52,6 @@ module JSON
table
end
- def [](name)
- __send__(name)
- end unless method_defined?(:[])
-
- def []=(name, value)
- __send__("#{name}=", value)
- end unless method_defined?(:[]=)
-
def |(other)
self.class[other.to_hash.merge(to_hash)]
end
@@ -67,5 +63,5 @@ module JSON
def to_json(*a)
as_json.to_json(*a)
end
- end
+ end if defined?(::OpenStruct)
end
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
index 3d4326d836..a69590ff9c 100644
--- a/ext/json/lib/json/version.rb
+++ b/ext/json/lib/json/version.rb
@@ -1,9 +1,5 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
+
module JSON
- # JSON version
- VERSION = '2.6.3'
- 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:
+ VERSION = '2.19.7'
end
diff --git a/ext/json/parser/depend b/ext/json/parser/depend
index cb6e547d29..d4737b1dfb 100644
--- a/ext/json/parser/depend
+++ b/ext/json/parser/depend
@@ -1,5 +1,5 @@
$(OBJS): $(ruby_headers)
-parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
+parser.o: parser.c $(srcdir)/../fbuffer/fbuffer.h
# AUTOGENERATED DEPENDENCIES START
parser.o: $(RUBY_EXTCONF_H)
@@ -141,6 +141,7 @@ parser.o: $(hdrdir)/ruby/internal/intern/re.h
parser.o: $(hdrdir)/ruby/internal/intern/ruby.h
parser.o: $(hdrdir)/ruby/internal/intern/select.h
parser.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+parser.o: $(hdrdir)/ruby/internal/intern/set.h
parser.o: $(hdrdir)/ruby/internal/intern/signal.h
parser.o: $(hdrdir)/ruby/internal/intern/sprintf.h
parser.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -160,6 +161,7 @@ parser.o: $(hdrdir)/ruby/internal/special_consts.h
parser.o: $(hdrdir)/ruby/internal/static_assert.h
parser.o: $(hdrdir)/ruby/internal/stdalign.h
parser.o: $(hdrdir)/ruby/internal/stdbool.h
+parser.o: $(hdrdir)/ruby/internal/stdckdint.h
parser.o: $(hdrdir)/ruby/internal/symbol.h
parser.o: $(hdrdir)/ruby/internal/value.h
parser.o: $(hdrdir)/ruby/internal/value_type.h
@@ -173,7 +175,8 @@ parser.o: $(hdrdir)/ruby/ruby.h
parser.o: $(hdrdir)/ruby/st.h
parser.o: $(hdrdir)/ruby/subst.h
parser.o: $(srcdir)/../fbuffer/fbuffer.h
+parser.o: $(srcdir)/../json.h
+parser.o: $(srcdir)/../simd/simd.h
+parser.o: $(srcdir)/../vendor/ryu.h
parser.o: parser.c
-parser.o: parser.h
-parser.o: parser.rl
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/json/parser/extconf.rb b/ext/json/parser/extconf.rb
index feb586e1b4..f12fc2dddc 100644
--- a/ext/json/parser/extconf.rb
+++ b/ext/json/parser/extconf.rb
@@ -1,32 +1,20 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'mkmf'
-have_func("rb_enc_raise", "ruby.h")
-have_func("rb_enc_interned_str", "ruby.h")
+$defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
+have_func("rb_enc_interned_str", "ruby/encoding.h") # RUBY_VERSION >= 3.0
+have_func("rb_str_to_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
+have_func("rb_hash_new_capa", "ruby.h") # RUBY_VERSION >= 3.2
+have_func("rb_hash_bulk_insert", "ruby.h") # Missing on TruffleRuby
-# checking if String#-@ (str_uminus) dedupes... '
-begin
- a = -(%w(t e s t).join)
- b = -(%w(t e s t).join)
- if a.equal?(b)
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
- else
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
- end
-rescue NoMethodError
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
+if RUBY_ENGINE == "ruby"
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
end
-# checking if String#-@ (str_uminus) directly interns frozen strings... '
-begin
- s = rand.to_s.freeze
- if (-s).equal?(s) && (-s.dup).equal?(s)
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
- else
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
- end
-rescue NoMethodError
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
+append_cflags("-std=c99")
+
+if enable_config('parser-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
+ load __dir__ + "/../simd/conf.rb"
end
create_makefile 'json/ext/parser'
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 9bd7f1971e..503bed1fd4 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -1,3347 +1,1757 @@
-/* This file is automatically generated from parser.rl by using ragel */
-#line 1 "parser.rl"
-#include "../fbuffer/fbuffer.h"
-#include "parser.h"
-
-#if defined HAVE_RUBY_ENCODING_H
-# define EXC_ENCODING rb_utf8_encoding(),
-# ifndef HAVE_RB_ENC_RAISE
+#include "../json.h"
+#include "../vendor/ryu.h"
+#include "../simd/simd.h"
+
+static VALUE mJSON, eNestingError, Encoding_UTF_8;
+static VALUE CNaN, CInfinity, CMinusInfinity;
+
+static ID i_new, i_try_convert, i_uminus, i_encode;
+
+static VALUE sym_max_nesting, sym_allow_nan, sym_allow_trailing_comma, sym_allow_control_characters,
+ sym_allow_invalid_escape, sym_symbolize_names, sym_freeze, sym_decimal_class, sym_on_load,
+ sym_allow_duplicate_key;
+
+static int binary_encindex;
+static int utf8_encindex;
+
+#ifndef HAVE_RB_HASH_BULK_INSERT
+// For TruffleRuby
static void
-enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
+rb_hash_bulk_insert(long count, const VALUE *pairs, VALUE hash)
{
- va_list args;
- VALUE mesg;
+ long index = 0;
+ while (index < count) {
+ VALUE name = pairs[index++];
+ VALUE value = pairs[index++];
+ rb_hash_aset(hash, name, value);
+ }
+ RB_GC_GUARD(hash);
+}
+#endif
- va_start(args, fmt);
- mesg = rb_enc_vsprintf(enc, fmt, args);
- va_end(args);
+#ifndef HAVE_RB_HASH_NEW_CAPA
+#define rb_hash_new_capa(n) rb_hash_new()
+#endif
- rb_exc_raise(rb_exc_new3(exc, mesg));
+#ifndef HAVE_RB_STR_TO_INTERNED_STR
+static VALUE rb_str_to_interned_str(VALUE str)
+{
+ return rb_funcall(rb_str_freeze(str), i_uminus, 0);
}
-# define rb_enc_raise enc_raise
+#endif
+
+/* name cache */
+
+#include <string.h>
+#include <ctype.h>
+
+// Object names are likely to be repeated, and are frozen.
+// As such we can re-use them if we keep a cache of the ones we've seen so far,
+// and save much more expensive lookups into the global fstring table.
+// This cache implementation is deliberately simple, as we're optimizing for compactness,
+// to be able to fit safely on the stack.
+// As such, binary search into a sorted array gives a good tradeoff between compactness and
+// performance.
+#define JSON_RVALUE_CACHE_CAPA 63
+typedef struct rvalue_cache_struct {
+ int length;
+ VALUE entries[JSON_RVALUE_CACHE_CAPA];
+} rvalue_cache;
+
+static rb_encoding *enc_utf8;
+
+#define JSON_RVALUE_CACHE_MAX_ENTRY_LENGTH 55
+
+static inline VALUE build_interned_string(const char *str, const long length)
+{
+# ifdef HAVE_RB_ENC_INTERNED_STR
+ return rb_enc_interned_str(str, length, enc_utf8);
+# else
+ VALUE rstring = rb_utf8_str_new(str, length);
+ return rb_funcall(rb_str_freeze(rstring), i_uminus, 0);
# endif
-#else
-# define EXC_ENCODING /* nothing */
-# define rb_enc_raise rb_raise
+}
+
+static inline VALUE build_symbol(const char *str, const long length)
+{
+ return rb_str_intern(build_interned_string(str, length));
+}
+
+static void rvalue_cache_insert_at(rvalue_cache *cache, int index, VALUE rstring)
+{
+ MEMMOVE(&cache->entries[index + 1], &cache->entries[index], VALUE, cache->length - index);
+ cache->length++;
+ cache->entries[index] = rstring;
+}
+
+#define rstring_cache_memcmp memcmp
+
+#if JSON_CPU_LITTLE_ENDIAN_64BITS
+#if __has_builtin(__builtin_bswap64)
+#undef rstring_cache_memcmp
+ALWAYS_INLINE(static) int rstring_cache_memcmp(const char *str, const char *rptr, const long length)
+{
+ // The libc memcmp has numerous complex optimizations, but in this particular case,
+ // we know the string is small (JSON_RVALUE_CACHE_MAX_ENTRY_LENGTH), so being able to
+ // inline a simpler memcmp outperforms calling the libc version.
+ long i = 0;
+
+ for (; i + 8 <= length; i += 8) {
+ uint64_t a, b;
+ memcpy(&a, str + i, 8);
+ memcpy(&b, rptr + i, 8);
+ if (a != b) {
+ a = __builtin_bswap64(a);
+ b = __builtin_bswap64(b);
+ return (a < b) ? -1 : 1;
+ }
+ }
+
+ for (; i < length; i++) {
+ if (str[i] != rptr[i]) {
+ return (str[i] < rptr[i]) ? -1 : 1;
+ }
+ }
+
+ return 0;
+}
+#endif
#endif
-/* unicode */
+ALWAYS_INLINE(static) int rstring_cache_cmp(const char *str, const long length, VALUE rstring)
+{
+ const char *rstring_ptr;
+ long rstring_length;
-static const signed char digit_values[256] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -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, 2, 3, 4, 5, 6, 7, 8, 9, -1,
- -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1
+ RSTRING_GETMEM(rstring, rstring_ptr, rstring_length);
+
+ if (length == rstring_length) {
+ return rstring_cache_memcmp(str, rstring_ptr, length);
+ } else {
+ return (int)(length - rstring_length);
+ }
+}
+
+ALWAYS_INLINE(static) VALUE rstring_cache_fetch(rvalue_cache *cache, const char *str, const long length)
+{
+ int low = 0;
+ int high = cache->length - 1;
+
+ while (low <= high) {
+ int mid = (high + low) >> 1;
+ VALUE entry = cache->entries[mid];
+ int cmp = rstring_cache_cmp(str, length, entry);
+
+ if (cmp == 0) {
+ return entry;
+ } else if (cmp > 0) {
+ low = mid + 1;
+ } else {
+ high = mid - 1;
+ }
+ }
+
+ VALUE rstring = build_interned_string(str, length);
+
+ if (cache->length < JSON_RVALUE_CACHE_CAPA) {
+ rvalue_cache_insert_at(cache, low, rstring);
+ }
+ return rstring;
+}
+
+static VALUE rsymbol_cache_fetch(rvalue_cache *cache, const char *str, const long length)
+{
+ int low = 0;
+ int high = cache->length - 1;
+
+ while (low <= high) {
+ int mid = (high + low) >> 1;
+ VALUE entry = cache->entries[mid];
+ int cmp = rstring_cache_cmp(str, length, rb_sym2str(entry));
+
+ if (cmp == 0) {
+ return entry;
+ } else if (cmp > 0) {
+ low = mid + 1;
+ } else {
+ high = mid - 1;
+ }
+ }
+
+ VALUE rsymbol = build_symbol(str, length);
+
+ if (cache->length < JSON_RVALUE_CACHE_CAPA) {
+ rvalue_cache_insert_at(cache, low, rsymbol);
+ }
+ return rsymbol;
+}
+
+/* rvalue stack */
+
+#define RVALUE_STACK_INITIAL_CAPA 128
+
+enum rvalue_stack_type {
+ RVALUE_STACK_HEAP_ALLOCATED = 0,
+ RVALUE_STACK_STACK_ALLOCATED = 1,
};
-static UTF32 unescape_unicode(const unsigned char *p)
-{
- signed char b;
- UTF32 result = 0;
- b = digit_values[p[0]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[1]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[2]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[3]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- return result;
-}
-
-static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
-{
- int len = 1;
- if (ch <= 0x7F) {
- buf[0] = (char) ch;
- } else if (ch <= 0x07FF) {
- buf[0] = (char) ((ch >> 6) | 0xC0);
- buf[1] = (char) ((ch & 0x3F) | 0x80);
- len++;
- } else if (ch <= 0xFFFF) {
- buf[0] = (char) ((ch >> 12) | 0xE0);
- buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
- buf[2] = (char) ((ch & 0x3F) | 0x80);
- len += 2;
- } else if (ch <= 0x1fffff) {
- buf[0] =(char) ((ch >> 18) | 0xF0);
- buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
- buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
- buf[3] =(char) ((ch & 0x3F) | 0x80);
- len += 3;
- } else {
- buf[0] = '?';
- }
- return len;
-}
-
-static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
-static VALUE CNaN, CInfinity, CMinusInfinity;
+typedef struct rvalue_stack_struct {
+ enum rvalue_stack_type type;
+ long capa;
+ long head;
+ VALUE *ptr;
+} rvalue_stack;
-static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
-i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
-i_object_class, i_array_class, i_decimal_class, i_key_p,
-i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
-i_leftshift, i_new, i_try_convert, i_freeze, i_uminus;
+static rvalue_stack *rvalue_stack_spill(rvalue_stack *old_stack, VALUE *handle, rvalue_stack **stack_ref);
+static rvalue_stack *rvalue_stack_grow(rvalue_stack *stack, VALUE *handle, rvalue_stack **stack_ref)
+{
+ long required = stack->capa * 2;
+
+ if (stack->type == RVALUE_STACK_STACK_ALLOCATED) {
+ stack = rvalue_stack_spill(stack, handle, stack_ref);
+ } else {
+ REALLOC_N(stack->ptr, VALUE, required);
+ stack->capa = required;
+ }
+ return stack;
+}
-#line 125 "parser.rl"
+static VALUE rvalue_stack_push(rvalue_stack *stack, VALUE value, VALUE *handle, rvalue_stack **stack_ref)
+{
+ if (RB_UNLIKELY(stack->head >= stack->capa)) {
+ stack = rvalue_stack_grow(stack, handle, stack_ref);
+ }
+ stack->ptr[stack->head] = value;
+ stack->head++;
+ return value;
+}
+static inline VALUE *rvalue_stack_peek(rvalue_stack *stack, long count)
+{
+ return stack->ptr + (stack->head - count);
+}
+static inline void rvalue_stack_pop(rvalue_stack *stack, long count)
+{
+ stack->head -= count;
+}
-enum {JSON_object_start = 1};
-enum {JSON_object_first_final = 27};
-enum {JSON_object_error = 0};
+static void rvalue_stack_mark(void *ptr)
+{
+ rvalue_stack *stack = (rvalue_stack *)ptr;
+ long index;
+ if (stack && stack->ptr) {
+ for (index = 0; index < stack->head; index++) {
+ rb_gc_mark(stack->ptr[index]);
+ }
+ }
+}
-enum {JSON_object_en_main = 1};
+static void rvalue_stack_free_buffer(rvalue_stack *stack)
+{
+ ruby_xfree(stack->ptr);
+ stack->ptr = NULL;
+}
-static const char MAYBE_UNUSED(_JSON_object_nfa_targs)[] = {
- 0, 0
-};
+static void rvalue_stack_free(void *ptr)
+{
+ rvalue_stack *stack = (rvalue_stack *)ptr;
+ if (stack) {
+ rvalue_stack_free_buffer(stack);
+#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
+ ruby_xfree(stack);
+#endif
+ }
+}
-static const char MAYBE_UNUSED(_JSON_object_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 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 size_t rvalue_stack_memsize(const void *ptr)
+{
+ const rvalue_stack *stack = (const rvalue_stack *)ptr;
+ return sizeof(rvalue_stack) + sizeof(VALUE) * stack->capa;
+}
-static const char MAYBE_UNUSED(_JSON_object_nfa_push_actions)[] = {
- 0, 0
+static const rb_data_type_t JSON_Parser_rvalue_stack_type = {
+ .wrap_struct_name = "JSON::Ext::Parser/rvalue_stack",
+ .function = {
+ .dmark = rvalue_stack_mark,
+ .dfree = rvalue_stack_free,
+ .dsize = rvalue_stack_memsize,
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE,
};
-static const char MAYBE_UNUSED(_JSON_object_nfa_pop_trans)[] = {
- 0, 0
-};
+static rvalue_stack *rvalue_stack_spill(rvalue_stack *old_stack, VALUE *handle, rvalue_stack **stack_ref)
+{
+ rvalue_stack *stack;
+ *handle = TypedData_Make_Struct(0, rvalue_stack, &JSON_Parser_rvalue_stack_type, stack);
+ *stack_ref = stack;
+ MEMCPY(stack, old_stack, rvalue_stack, 1);
+
+ stack->capa = old_stack->capa << 1;
+ stack->ptr = ALLOC_N(VALUE, stack->capa);
+ stack->type = RVALUE_STACK_HEAP_ALLOCATED;
+ MEMCPY(stack->ptr, old_stack->ptr, VALUE, old_stack->head);
+ return stack;
+}
+static void rvalue_stack_eagerly_release(VALUE handle)
+{
+ if (handle) {
+ rvalue_stack *stack;
+ TypedData_Get_Struct(handle, rvalue_stack, &JSON_Parser_rvalue_stack_type, stack);
+#ifdef HAVE_RUBY_TYPED_EMBEDDABLE
+ rvalue_stack_free_buffer(stack);
+#else
+ rvalue_stack_free(stack);
+ RTYPEDDATA_DATA(handle) = NULL;
+#endif
+ }
+}
-#line 167 "parser.rl"
-
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
-{
- int cs = EVIL;
- VALUE last_name = Qnil;
- VALUE object_class = json->object_class;
-
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
-
- *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
-
-
- {
- cs = (int)JSON_object_start;
- }
-
- #line 182 "parser.rl"
-
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- case 17:
- goto st_case_17;
- case 18:
- goto st_case_18;
- case 27:
- goto st_case_27;
- case 19:
- goto st_case_19;
- case 20:
- goto st_case_20;
- case 21:
- goto st_case_21;
- case 22:
- goto st_case_22;
- case 23:
- goto st_case_23;
- case 24:
- goto st_case_24;
- case 25:
- goto st_case_25;
- case 26:
- goto st_case_26;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 123 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 13: {
- goto st2;
- }
- case 32: {
- goto st2;
- }
- case 34: {
- goto ctr2;
- }
- case 47: {
- goto st23;
- }
- case 125: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st2;
- }
- {
- goto st0;
- }
- ctr2:
- {
- #line 149 "parser.rl"
-
- char *np;
- json->parsing_name = 1;
- np = JSON_parse_string(json, p, pe, &last_name);
- json->parsing_name = 0;
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 3; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st3;
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- 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:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st5;
- }
- case 47: {
- goto st7;
- }
- }
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 42 ) {
- goto st6;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st6;
- }
- case 47: {
- goto st3;
- }
- }
- {
- goto st5;
- }
- st7:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 10 ) {
- goto st3;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 13: {
- goto st8;
- }
- case 32: {
- goto st8;
- }
- case 34: {
- goto ctr11;
- }
- case 45: {
- goto ctr11;
- }
- case 47: {
- goto st19;
- }
- case 73: {
- goto ctr11;
- }
- case 78: {
- goto ctr11;
- }
- case 91: {
- goto ctr11;
- }
- case 102: {
- goto ctr11;
- }
- case 110: {
- goto ctr11;
- }
- case 116: {
- goto ctr11;
- }
- case 123: {
- goto ctr11;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr11;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st8;
- }
- {
- goto st0;
- }
- ctr11:
- {
- #line 133 "parser.rl"
-
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
- if (np == NULL) {
- {p = p - 1; } {p+= 1; cs = 9; goto _out;}
- } else {
- if (NIL_P(json->object_class)) {
- OBJ_FREEZE(last_name);
- rb_hash_aset(*result, last_name, v);
- } else {
- rb_funcall(*result, i_aset, 2, last_name, v);
- }
- {p = (( np))-1;}
-
- }
- }
-
- goto st9;
- st9:
- p+= 1;
- if ( p == pe )
- goto _test_eof9;
- st_case_9:
- switch( ( (*( p))) ) {
- case 13: {
- goto st9;
- }
- case 32: {
- goto st9;
- }
- case 44: {
- goto st10;
- }
- case 47: {
- goto st15;
- }
- case 125: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st9;
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
- goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 13: {
- goto st10;
- }
- case 32: {
- goto st10;
- }
- case 34: {
- goto ctr2;
- }
- case 47: {
- goto st11;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st11:
- p+= 1;
- if ( p == pe )
- goto _test_eof11;
- st_case_11:
- switch( ( (*( p))) ) {
- case 42: {
- goto st12;
- }
- case 47: {
- goto st14;
- }
- }
- {
- goto st0;
- }
- st12:
- p+= 1;
- if ( p == pe )
- goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 42 ) {
- goto st13;
- }
- {
- goto st12;
- }
- st13:
- p+= 1;
- if ( p == pe )
- goto _test_eof13;
- st_case_13:
- switch( ( (*( p))) ) {
- case 42: {
- goto st13;
- }
- case 47: {
- goto st10;
- }
- }
- {
- goto st12;
- }
- st14:
- p+= 1;
- if ( p == pe )
- goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 10 ) {
- goto st10;
- }
- {
- goto st14;
- }
- st15:
- p+= 1;
- if ( p == pe )
- goto _test_eof15;
- st_case_15:
- switch( ( (*( p))) ) {
- case 42: {
- goto st16;
- }
- case 47: {
- goto st18;
- }
- }
- {
- goto st0;
- }
- st16:
- p+= 1;
- if ( p == pe )
- goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 42 ) {
- goto st17;
- }
- {
- goto st16;
- }
- st17:
- p+= 1;
- if ( p == pe )
- goto _test_eof17;
- st_case_17:
- switch( ( (*( p))) ) {
- case 42: {
- goto st17;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st16;
- }
- st18:
- p+= 1;
- if ( p == pe )
- goto _test_eof18;
- st_case_18:
- if ( ( (*( p))) == 10 ) {
- goto st9;
- }
- {
- goto st18;
- }
- ctr4:
- {
- #line 157 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 27; goto _out;} }
-
- goto st27;
- st27:
- p+= 1;
- if ( p == pe )
- goto _test_eof27;
- st_case_27:
- {
- goto st0;
- }
- st19:
- p+= 1;
- if ( p == pe )
- goto _test_eof19;
- st_case_19:
- switch( ( (*( p))) ) {
- case 42: {
- goto st20;
- }
- case 47: {
- goto st22;
- }
- }
- {
- goto st0;
- }
- st20:
- p+= 1;
- if ( p == pe )
- goto _test_eof20;
- st_case_20:
- if ( ( (*( p))) == 42 ) {
- goto st21;
- }
- {
- goto st20;
- }
- st21:
- p+= 1;
- if ( p == pe )
- goto _test_eof21;
- st_case_21:
- switch( ( (*( p))) ) {
- case 42: {
- goto st21;
- }
- case 47: {
- goto st8;
- }
- }
- {
- goto st20;
- }
- st22:
- p+= 1;
- if ( p == pe )
- goto _test_eof22;
- st_case_22:
- if ( ( (*( p))) == 10 ) {
- goto st8;
- }
- {
- goto st22;
- }
- st23:
- p+= 1;
- if ( p == pe )
- goto _test_eof23;
- st_case_23:
- switch( ( (*( p))) ) {
- case 42: {
- goto st24;
- }
- case 47: {
- goto st26;
- }
- }
- {
- goto st0;
- }
- st24:
- p+= 1;
- if ( p == pe )
- goto _test_eof24;
- st_case_24:
- if ( ( (*( p))) == 42 ) {
- goto st25;
- }
- {
- goto st24;
- }
- st25:
- p+= 1;
- if ( p == pe )
- goto _test_eof25;
- st_case_25:
- switch( ( (*( p))) ) {
- case 42: {
- goto st25;
- }
- case 47: {
- goto st2;
- }
- }
- {
- goto st24;
- }
- st26:
- p+= 1;
- if ( p == pe )
- goto _test_eof26;
- st_case_26:
- if ( ( (*( p))) == 10 ) {
- goto st2;
- }
- {
- goto st26;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof18: cs = 18; goto _test_eof;
- _test_eof27: cs = 27; goto _test_eof;
- _test_eof19: cs = 19; goto _test_eof;
- _test_eof20: cs = 20; goto _test_eof;
- _test_eof21: cs = 21; goto _test_eof;
- _test_eof22: cs = 22; goto _test_eof;
- _test_eof23: cs = 23; goto _test_eof;
- _test_eof24: cs = 24; goto _test_eof;
- _test_eof25: cs = 25; goto _test_eof;
- _test_eof26: cs = 26; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 183 "parser.rl"
-
-
- if (cs >= JSON_object_first_final) {
- if (json->create_additions) {
- VALUE klassname;
- if (NIL_P(json->object_class)) {
- klassname = rb_hash_aref(*result, json->create_id);
- } else {
- klassname = rb_funcall(*result, i_aref, 1, json->create_id);
- }
- if (!NIL_P(klassname)) {
- VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, 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;
- }
-}
-
-
-
-enum {JSON_value_start = 1};
-enum {JSON_value_first_final = 29};
-enum {JSON_value_error = 0};
-
-enum {JSON_value_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_value_nfa_targs)[] = {
- 0, 0
-};
+static int convert_UTF32_to_UTF8(char *buf, uint32_t ch)
+{
+ int len = 1;
+ if (ch <= 0x7F) {
+ buf[0] = (char) ch;
+ } else if (ch <= 0x07FF) {
+ buf[0] = (char) ((ch >> 6) | 0xC0);
+ buf[1] = (char) ((ch & 0x3F) | 0x80);
+ len++;
+ } else if (ch <= 0xFFFF) {
+ buf[0] = (char) ((ch >> 12) | 0xE0);
+ buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[2] = (char) ((ch & 0x3F) | 0x80);
+ len += 2;
+ } else if (ch <= 0x1fffff) {
+ buf[0] =(char) ((ch >> 18) | 0xF0);
+ buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
+ buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[3] =(char) ((ch & 0x3F) | 0x80);
+ len += 3;
+ } else {
+ buf[0] = '?';
+ }
+ return len;
+}
-static const char MAYBE_UNUSED(_JSON_value_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
+enum duplicate_key_action {
+ JSON_DEPRECATED = 0,
+ JSON_IGNORE,
+ JSON_RAISE,
};
-static const char MAYBE_UNUSED(_JSON_value_nfa_push_actions)[] = {
- 0, 0
-};
+typedef struct JSON_ParserStruct {
+ VALUE on_load_proc;
+ VALUE decimal_class;
+ ID decimal_method_id;
+ enum duplicate_key_action on_duplicate_key;
+ int max_nesting;
+ bool allow_nan;
+ bool allow_trailing_comma;
+ bool allow_control_characters;
+ bool allow_invalid_escape;
+ bool symbolize_names;
+ bool freeze;
+} JSON_ParserConfig;
+
+typedef struct JSON_ParserStateStruct {
+ VALUE *stack_handle;
+ const char *start;
+ const char *cursor;
+ const char *end;
+ rvalue_stack *stack;
+ rvalue_cache name_cache;
+ int in_array;
+ int current_nesting;
+ unsigned int emitted_deprecations;
+} JSON_ParserState;
+
+static inline size_t rest(JSON_ParserState *state) {
+ return state->end - state->cursor;
+}
-static const char MAYBE_UNUSED(_JSON_value_nfa_pop_trans)[] = {
- 0, 0
-};
+static inline bool eos(JSON_ParserState *state) {
+ return state->cursor >= state->end;
+}
+static inline char peek(JSON_ParserState *state)
+{
+ if (RB_UNLIKELY(eos(state))) {
+ return 0;
+ }
+ return *state->cursor;
+}
-#line 283 "parser.rl"
-
-
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
-{
- int cs = EVIL;
-
-
- {
- cs = (int)JSON_value_start;
- }
-
- #line 290 "parser.rl"
-
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 29:
- goto st_case_29;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- case 17:
- goto st_case_17;
- case 18:
- goto st_case_18;
- case 19:
- goto st_case_19;
- case 20:
- goto st_case_20;
- case 21:
- goto st_case_21;
- case 22:
- goto st_case_22;
- case 23:
- goto st_case_23;
- case 24:
- goto st_case_24;
- case 25:
- goto st_case_25;
- case 26:
- goto st_case_26;
- case 27:
- goto st_case_27;
- case 28:
- goto st_case_28;
- }
- goto st_out;
- st1:
- p+= 1;
- if ( p == pe )
- goto _test_eof1;
- st_case_1:
- switch( ( (*( p))) ) {
- case 13: {
- goto st1;
- }
- case 32: {
- goto st1;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr3;
- }
- case 47: {
- goto st6;
- }
- case 73: {
- goto st10;
- }
- case 78: {
- goto st17;
- }
- case 91: {
- goto ctr7;
- }
- case 102: {
- goto st19;
- }
- case 110: {
- goto st23;
- }
- case 116: {
- goto st26;
- }
- case 123: {
- goto ctr11;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr3;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st1;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- ctr2:
- {
- #line 235 "parser.rl"
-
- char *np = JSON_parse_string(json, p, pe, result);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr3:
- {
- #line 240 "parser.rl"
-
- char *np;
- if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
- if (json->allow_nan) {
- *result = CMinusInfinity;
- {p = (( p + 10))-1;}
-
- {p = p - 1; } {p+= 1; cs = 29; goto _out;}
- } else {
- rb_enc_raise(EXC_ENCODING 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;}
-
- {p = p - 1; } {p+= 1; cs = 29; goto _out;}
- }
-
- goto st29;
- ctr7:
- {
- #line 258 "parser.rl"
-
- char *np;
- np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr11:
- {
- #line 264 "parser.rl"
-
- char *np;
- np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr25:
- {
- #line 228 "parser.rl"
-
- if (json->allow_nan) {
- *result = CInfinity;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
- }
- }
-
- goto st29;
- ctr27:
- {
- #line 221 "parser.rl"
-
- if (json->allow_nan) {
- *result = CNaN;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
- }
- }
-
- goto st29;
- ctr31:
- {
- #line 215 "parser.rl"
-
- *result = Qfalse;
- }
-
- goto st29;
- ctr34:
- {
- #line 212 "parser.rl"
-
- *result = Qnil;
- }
-
- goto st29;
- ctr37:
- {
- #line 218 "parser.rl"
-
- *result = Qtrue;
- }
-
- goto st29;
- st29:
- p+= 1;
- if ( p == pe )
- goto _test_eof29;
- st_case_29:
- {
- #line 270 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 29; goto _out;} }
- switch( ( (*( p))) ) {
- case 13: {
- goto st29;
- }
- case 32: {
- goto st29;
- }
- case 47: {
- goto st2;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st29;
- }
- {
- goto st0;
- }
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 42: {
- goto st3;
- }
- case 47: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 42 ) {
- goto st4;
- }
- {
- goto st3;
- }
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st4;
- }
- case 47: {
- goto st29;
- }
- }
- {
- goto st3;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 10 ) {
- goto st29;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st0;
- }
- st7:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 42 ) {
- goto st8;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 42: {
- goto st8;
- }
- case 47: {
- goto st1;
- }
- }
- {
- goto st7;
- }
- st9:
- p+= 1;
- if ( p == pe )
- goto _test_eof9;
- st_case_9:
- if ( ( (*( p))) == 10 ) {
- goto st1;
- }
- {
- goto st9;
- }
- st10:
- p+= 1;
- if ( p == pe )
- goto _test_eof10;
- st_case_10:
- if ( ( (*( p))) == 110 ) {
- goto st11;
- }
- {
- goto st0;
- }
- st11:
- p+= 1;
- if ( p == pe )
- goto _test_eof11;
- st_case_11:
- if ( ( (*( p))) == 102 ) {
- goto st12;
- }
- {
- goto st0;
- }
- st12:
- p+= 1;
- if ( p == pe )
- goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 105 ) {
- goto st13;
- }
- {
- goto st0;
- }
- st13:
- p+= 1;
- if ( p == pe )
- goto _test_eof13;
- st_case_13:
- if ( ( (*( p))) == 110 ) {
- goto st14;
- }
- {
- goto st0;
- }
- st14:
- p+= 1;
- if ( p == pe )
- goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 105 ) {
- goto st15;
- }
- {
- goto st0;
- }
- st15:
- p+= 1;
- if ( p == pe )
- goto _test_eof15;
- st_case_15:
- if ( ( (*( p))) == 116 ) {
- goto st16;
- }
- {
- goto st0;
- }
- st16:
- p+= 1;
- if ( p == pe )
- goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 121 ) {
- goto ctr25;
- }
- {
- goto st0;
- }
- st17:
- p+= 1;
- if ( p == pe )
- goto _test_eof17;
- st_case_17:
- if ( ( (*( p))) == 97 ) {
- goto st18;
- }
- {
- goto st0;
- }
- st18:
- p+= 1;
- if ( p == pe )
- goto _test_eof18;
- st_case_18:
- if ( ( (*( p))) == 78 ) {
- goto ctr27;
- }
- {
- goto st0;
- }
- st19:
- p+= 1;
- if ( p == pe )
- goto _test_eof19;
- st_case_19:
- if ( ( (*( p))) == 97 ) {
- goto st20;
- }
- {
- goto st0;
- }
- st20:
- p+= 1;
- if ( p == pe )
- goto _test_eof20;
- st_case_20:
- if ( ( (*( p))) == 108 ) {
- goto st21;
- }
- {
- goto st0;
- }
- st21:
- p+= 1;
- if ( p == pe )
- goto _test_eof21;
- st_case_21:
- if ( ( (*( p))) == 115 ) {
- goto st22;
- }
- {
- goto st0;
- }
- st22:
- p+= 1;
- if ( p == pe )
- goto _test_eof22;
- st_case_22:
- if ( ( (*( p))) == 101 ) {
- goto ctr31;
- }
- {
- goto st0;
- }
- st23:
- p+= 1;
- if ( p == pe )
- goto _test_eof23;
- st_case_23:
- if ( ( (*( p))) == 117 ) {
- goto st24;
- }
- {
- goto st0;
- }
- st24:
- p+= 1;
- if ( p == pe )
- goto _test_eof24;
- st_case_24:
- if ( ( (*( p))) == 108 ) {
- goto st25;
- }
- {
- goto st0;
- }
- st25:
- p+= 1;
- if ( p == pe )
- goto _test_eof25;
- st_case_25:
- if ( ( (*( p))) == 108 ) {
- goto ctr34;
- }
- {
- goto st0;
- }
- st26:
- p+= 1;
- if ( p == pe )
- goto _test_eof26;
- st_case_26:
- if ( ( (*( p))) == 114 ) {
- goto st27;
- }
- {
- goto st0;
- }
- st27:
- p+= 1;
- if ( p == pe )
- goto _test_eof27;
- st_case_27:
- if ( ( (*( p))) == 117 ) {
- goto st28;
- }
- {
- goto st0;
- }
- st28:
- p+= 1;
- if ( p == pe )
- goto _test_eof28;
- st_case_28:
- if ( ( (*( p))) == 101 ) {
- goto ctr37;
- }
- {
- goto st0;
- }
- st_out:
- _test_eof1: cs = 1; goto _test_eof;
- _test_eof29: cs = 29; goto _test_eof;
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof18: cs = 18; goto _test_eof;
- _test_eof19: cs = 19; goto _test_eof;
- _test_eof20: cs = 20; goto _test_eof;
- _test_eof21: cs = 21; goto _test_eof;
- _test_eof22: cs = 22; goto _test_eof;
- _test_eof23: cs = 23; goto _test_eof;
- _test_eof24: cs = 24; goto _test_eof;
- _test_eof25: cs = 25; goto _test_eof;
- _test_eof26: cs = 26; goto _test_eof;
- _test_eof27: cs = 27; goto _test_eof;
- _test_eof28: cs = 28; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 291 "parser.rl"
-
-
- if (json->freeze) {
- OBJ_FREEZE(*result);
- }
-
- if (cs >= JSON_value_first_final) {
- return p;
- } else {
- return NULL;
- }
-}
-
-
-enum {JSON_integer_start = 1};
-enum {JSON_integer_first_final = 3};
-enum {JSON_integer_error = 0};
-
-enum {JSON_integer_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_integer_nfa_targs)[] = {
- 0, 0
-};
+static void cursor_position(JSON_ParserState *state, long *line_out, long *column_out)
+{
+ JSON_ASSERT(state->cursor <= state->end);
+
+ // Redundant but helpful for hardening
+ if (RB_UNLIKELY(state->cursor > state->end)) {
+ state->cursor = state->end;
+ }
+
+ const char *cursor = state->cursor;
+ long column = 0;
+ long line = 1;
+
+ while (cursor >= state->start) {
+ if (*cursor-- == '\n') {
+ break;
+ }
+ column++;
+ }
+
+ while (cursor >= state->start) {
+ if (*cursor-- == '\n') {
+ line++;
+ }
+ }
+ *line_out = line;
+ *column_out = column;
+}
-static const char MAYBE_UNUSED(_JSON_integer_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
+static void emit_parse_warning(const char *message, JSON_ParserState *state)
+{
+ long line, column;
+ cursor_position(state, &line, &column);
-static const char MAYBE_UNUSED(_JSON_integer_nfa_push_actions)[] = {
- 0, 0
-};
+ VALUE warning = rb_sprintf("%s at line %ld column %ld", message, line, column);
+ rb_funcall(mJSON, rb_intern("deprecation_warning"), 1, warning);
+}
-static const char MAYBE_UNUSED(_JSON_integer_nfa_pop_trans)[] = {
- 0, 0
-};
+#define PARSE_ERROR_FRAGMENT_LEN 32
+static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
+{
+ unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
+
+ const char *ptr = "EOF";
+ if (state->cursor && state->cursor < state->end) {
+ ptr = state->cursor;
+ size_t len = 0;
+ while (len < PARSE_ERROR_FRAGMENT_LEN) {
+ char ch = ptr[len];
+ if (!ch || ch == '\n' || ch == ' ' || ch == '\t' || ch == '\r') {
+ break;
+ }
+ len++;
+ }
+
+ if (len) {
+ buffer[0] = '\'';
+ MEMCPY(buffer + 1, ptr, char, len);
+
+ while (buffer[len] >= 0x80 && buffer[len] < 0xC0) { // Is continuation byte
+ len--;
+ }
+
+ if (buffer[len] >= 0xC0) { // multibyte character start
+ len--;
+ }
+
+ buffer[len + 1] = '\'';
+ buffer[len + 2] = '\0';
+ ptr = (const char *)buffer;
+ }
+ }
+
+ VALUE message = rb_enc_sprintf(enc_utf8, format, ptr);
+ rb_str_catf(message, " at line %ld column %ld", line, column);
+ return message;
+}
-#line 311 "parser.rl"
-
-
-static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
-
- {
- cs = (int)JSON_integer_start;
- }
-
- #line 318 "parser.rl"
-
- json->memo = p;
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- }
- goto st_out;
- st_case_1:
- switch( ( (*( p))) ) {
- case 45: {
- goto st2;
- }
- case 48: {
- goto st3;
- }
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- if ( ( (*( p))) == 48 ) {
- goto st3;
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st0;
- }
- {
- goto ctr4;
- }
- ctr4:
- {
- #line 308 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 4; goto _out;} }
-
- goto st4;
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto ctr4;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 320 "parser.rl"
-
-
- if (cs >= JSON_integer_first_final) {
- long len = p - json->memo;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
- *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-enum {JSON_float_start = 1};
-enum {JSON_float_first_final = 8};
-enum {JSON_float_error = 0};
-
-enum {JSON_float_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_float_nfa_targs)[] = {
- 0, 0
-};
+static VALUE parse_error_new(VALUE message, long line, long column)
+{
+ VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
+ rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
+ rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
+ return exc;
+}
-static const char MAYBE_UNUSED(_JSON_float_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-};
+NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
+{
+ long line, column;
+ cursor_position(state, &line, &column);
+ VALUE message = build_parse_error_message(format, state, line, column);
+ rb_exc_raise(parse_error_new(message, line, column));
+}
-static const char MAYBE_UNUSED(_JSON_float_nfa_push_actions)[] = {
- 0, 0
-};
+NORETURN(static) void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
+{
+ state->cursor = at;
+ raise_parse_error(format, state);
+}
+
+/* unicode */
-static const char MAYBE_UNUSED(_JSON_float_nfa_pop_trans)[] = {
- 0, 0
+static const signed char digit_values[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -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, 2, 3, 4, 5, 6, 7, 8, 9, -1,
+ -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -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 uint32_t unescape_unicode(JSON_ParserState *state, const char *sp, const char *spe)
+{
+ if (RB_UNLIKELY(sp > spe - 4)) {
+ raise_parse_error_at("incomplete unicode character escape sequence at %s", state, sp - 2);
+ }
-#line 345 "parser.rl"
-
-
-static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
-
- {
- cs = (int)JSON_float_start;
- }
-
- #line 352 "parser.rl"
-
- json->memo = p;
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 10:
- goto st_case_10;
- case 7:
- goto st_case_7;
- }
- goto st_out;
- st_case_1:
- switch( ( (*( p))) ) {
- case 45: {
- goto st2;
- }
- case 48: {
- goto st3;
- }
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- if ( ( (*( p))) == 48 ) {
- goto st3;
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- switch( ( (*( p))) ) {
- case 46: {
- goto st4;
- }
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st8;
- }
- {
- goto st0;
- }
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- if ( ( (*( p))) > 46 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st8;
- }
- } else if ( ( (*( p))) >= 45 ) {
- goto st0;
- }
- {
- goto ctr9;
- }
- ctr9:
- {
- #line 339 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 9; goto _out;} }
-
- goto st9;
- st9:
- p+= 1;
- if ( p == pe )
- goto _test_eof9;
- st_case_9:
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- switch( ( (*( p))) ) {
- case 43: {
- goto st6;
- }
- case 45: {
- goto st6;
- }
- }
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st6:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_case_6:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
- goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 69: {
- goto st0;
- }
- case 101: {
- goto st0;
- }
- }
- if ( ( (*( p))) > 46 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- } else if ( ( (*( p))) >= 45 ) {
- goto st0;
- }
- {
- goto ctr9;
- }
- st7:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_case_7:
- switch( ( (*( p))) ) {
- case 46: {
- goto st4;
- }
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 354 "parser.rl"
-
-
- if (cs >= JSON_float_first_final) {
- VALUE mod = Qnil;
- ID method_id = 0;
- if (rb_respond_to(json->decimal_class, i_try_convert)) {
- mod = json->decimal_class;
- method_id = i_try_convert;
- } else if (rb_respond_to(json->decimal_class, i_new)) {
- mod = json->decimal_class;
- method_id = i_new;
- } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) {
- VALUE name = rb_class_name(json->decimal_class);
- const char *name_cstr = RSTRING_PTR(name);
- const char *last_colon = strrchr(name_cstr, ':');
- if (last_colon) {
- const char *mod_path_end = last_colon - 1;
- VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr);
- mod = rb_path_to_class(mod_path);
-
- const char *method_name_beg = last_colon + 1;
- long before_len = method_name_beg - name_cstr;
- long len = RSTRING_LEN(name) - before_len;
- VALUE method_name = rb_str_substr(name, before_len, len);
- method_id = SYM2ID(rb_str_intern(method_name));
- } else {
- mod = rb_mKernel;
- method_id = SYM2ID(rb_str_intern(name));
- }
- }
-
- long len = p - json->memo;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
-
- if (method_id) {
- VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
- *result = rb_funcallv(mod, method_id, 1, &text);
- } else {
- *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
- }
-
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-
-enum {JSON_array_start = 1};
-enum {JSON_array_first_final = 17};
-enum {JSON_array_error = 0};
-
-enum {JSON_array_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_array_nfa_targs)[] = {
- 0, 0
-};
+ const unsigned char *p = (const unsigned char *)sp;
-static const char MAYBE_UNUSED(_JSON_array_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0
-};
+ const signed char b0 = digit_values[p[0]];
+ const signed char b1 = digit_values[p[1]];
+ const signed char b2 = digit_values[p[2]];
+ const signed char b3 = digit_values[p[3]];
-static const char MAYBE_UNUSED(_JSON_array_nfa_push_actions)[] = {
- 0, 0
-};
+ if (RB_UNLIKELY((signed char)(b0 | b1 | b2 | b3) < 0)) {
+ raise_parse_error_at("incomplete unicode character escape sequence at %s", state, sp - 2);
+ }
-static const char MAYBE_UNUSED(_JSON_array_nfa_pop_trans)[] = {
- 0, 0
-};
+ return ((uint32_t)b0 << 12) | ((uint32_t)b1 << 8) | ((uint32_t)b2 << 4) | (uint32_t)b3;
+}
+#define GET_PARSER_CONFIG \
+ JSON_ParserConfig *config; \
+ TypedData_Get_Struct(self, JSON_ParserConfig, &JSON_ParserConfig_type, config)
-#line 432 "parser.rl"
-
-
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
-{
- int cs = EVIL;
- VALUE array_class = json->array_class;
-
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
- *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
-
-
- {
- cs = (int)JSON_array_start;
- }
-
- #line 445 "parser.rl"
-
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 17:
- goto st_case_17;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 91 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 13: {
- goto st2;
- }
- case 32: {
- goto st2;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st13;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 93: {
- goto ctr4;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st2;
- }
- {
- goto st0;
- }
- ctr2:
- {
- #line 409 "parser.rl"
-
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
- if (np == NULL) {
- {p = p - 1; } {p+= 1; cs = 3; goto _out;}
- } else {
- if (NIL_P(json->array_class)) {
- rb_ary_push(*result, v);
- } else {
- rb_funcall(*result, i_leftshift, 1, v);
- }
- {p = (( np))-1;}
-
- }
- }
-
- goto st3;
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- switch( ( (*( p))) ) {
- case 13: {
- goto st3;
- }
- case 32: {
- goto st3;
- }
- case 44: {
- goto st4;
- }
- case 47: {
- goto st9;
- }
- case 93: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st3;
- }
- {
- goto st0;
- }
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 13: {
- goto st4;
- }
- case 32: {
- goto st4;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st5;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st4;
- }
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- switch( ( (*( p))) ) {
- case 42: {
- goto st6;
- }
- case 47: {
- goto st8;
- }
- }
- {
- goto st0;
- }
- st6:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_case_6:
- if ( ( (*( p))) == 42 ) {
- goto st7;
- }
- {
- goto st6;
- }
- st7:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_case_7:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st4;
- }
- }
- {
- goto st6;
- }
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- if ( ( (*( p))) == 10 ) {
- goto st4;
- }
- {
- goto st8;
- }
- st9:
- p+= 1;
- if ( p == pe )
- goto _test_eof9;
- st_case_9:
- switch( ( (*( p))) ) {
- case 42: {
- goto st10;
- }
- case 47: {
- goto st12;
- }
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
- goto _test_eof10;
- st_case_10:
- if ( ( (*( p))) == 42 ) {
- goto st11;
- }
- {
- goto st10;
- }
- st11:
- p+= 1;
- if ( p == pe )
- goto _test_eof11;
- st_case_11:
- switch( ( (*( p))) ) {
- case 42: {
- goto st11;
- }
- case 47: {
- goto st3;
- }
- }
- {
- goto st10;
- }
- st12:
- p+= 1;
- if ( p == pe )
- goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 10 ) {
- goto st3;
- }
- {
- goto st12;
- }
- ctr4:
- {
- #line 424 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 17; goto _out;} }
-
- goto st17;
- st17:
- p+= 1;
- if ( p == pe )
- goto _test_eof17;
- st_case_17:
- {
- goto st0;
- }
- st13:
- p+= 1;
- if ( p == pe )
- goto _test_eof13;
- st_case_13:
- switch( ( (*( p))) ) {
- case 42: {
- goto st14;
- }
- case 47: {
- goto st16;
- }
- }
- {
- goto st0;
- }
- st14:
- p+= 1;
- if ( p == pe )
- goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 42 ) {
- goto st15;
- }
- {
- goto st14;
- }
- st15:
- p+= 1;
- if ( p == pe )
- goto _test_eof15;
- st_case_15:
- switch( ( (*( p))) ) {
- case 42: {
- goto st15;
- }
- case 47: {
- goto st2;
- }
- }
- {
- goto st14;
- }
- st16:
- p+= 1;
- if ( p == pe )
- goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 10 ) {
- goto st2;
- }
- {
- goto st16;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 446 "parser.rl"
-
-
- if(cs >= JSON_array_first_final) {
- return p + 1;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return NULL;
- }
-}
-
-static const size_t MAX_STACK_BUFFER_SIZE = 128;
-static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize)
-{
- VALUE result = Qnil;
- size_t bufferSize = stringEnd - string;
- char *p = string, *pe = string, *unescape, *bufferStart, *buffer;
- int unescape_len;
- char buf[4];
-
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
-# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1);
-# else
- bufferStart = buffer = ALLOC_N(char, bufferSize);
-# endif
- } else {
+static const rb_data_type_t JSON_ParserConfig_type;
+
+static void
+json_eat_comments(JSON_ParserState *state)
+{
+ const char *start = state->cursor;
+ state->cursor++;
+
+ switch (peek(state)) {
+ case '/': {
+ state->cursor = memchr(state->cursor, '\n', state->end - state->cursor);
+ if (!state->cursor) {
+ state->cursor = state->end;
+ } else {
+ state->cursor++;
+ }
+ break;
+ }
+ case '*': {
+ state->cursor++;
+
+ while (true) {
+ const char *next_match = memchr(state->cursor, '*', state->end - state->cursor);
+ if (!next_match) {
+ raise_parse_error_at("unterminated comment, expected closing '*/'", state, start);
+ }
+
+ state->cursor = next_match + 1;
+ if (peek(state) == '/') {
+ state->cursor++;
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ raise_parse_error_at("unexpected token %s", state, start);
+ break;
+ }
+}
+
+ALWAYS_INLINE(static) void
+json_eat_whitespace(JSON_ParserState *state)
+{
+ while (true) {
+ switch (peek(state)) {
+ case ' ':
+ state->cursor++;
+ break;
+ case '\n':
+ state->cursor++;
+
+ // Heuristic: if we see a newline, there is likely consecutive spaces after it.
+#if JSON_CPU_LITTLE_ENDIAN_64BITS
+ while (rest(state) > 8) {
+ uint64_t chunk;
+ memcpy(&chunk, state->cursor, sizeof(uint64_t));
+ if (chunk == 0x2020202020202020) {
+ state->cursor += 8;
+ continue;
+ }
+
+ uint32_t consecutive_spaces = trailing_zeros64(chunk ^ 0x2020202020202020) / CHAR_BIT;
+ state->cursor += consecutive_spaces;
+ break;
+ }
+#endif
+ break;
+ case '\t':
+ case '\r':
+ state->cursor++;
+ break;
+ case '/':
+ json_eat_comments(state);
+ break;
+
+ default:
+ return;
+ }
+ }
+}
+
+static inline VALUE build_string(const char *start, const char *end, bool intern, bool symbolize)
+{
+ if (symbolize) {
+ intern = true;
+ }
+ VALUE result;
# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1);
+ if (intern) {
+ result = rb_enc_interned_str(start, (long)(end - start), enc_utf8);
+ } else {
+ result = rb_utf8_str_new(start, (long)(end - start));
+ }
# else
- bufferStart = buffer = ALLOCA_N(char, bufferSize);
+ result = rb_utf8_str_new(start, (long)(end - start));
+ if (intern) {
+ result = rb_funcall(rb_str_freeze(result), i_uminus, 0);
+ }
# endif
- }
-
- while (pe < stringEnd) {
- if (*pe == '\\') {
- unescape = (char *) "?";
- unescape_len = 1;
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
- switch (*++pe) {
- case 'n':
- unescape = (char *) "\n";
- break;
- case 'r':
- unescape = (char *) "\r";
- break;
- case 't':
- unescape = (char *) "\t";
- break;
- case '"':
- unescape = (char *) "\"";
- break;
- case '\\':
- unescape = (char *) "\\";
- break;
- case 'b':
- unescape = (char *) "\b";
- break;
- case 'f':
- unescape = (char *) "\f";
- break;
- case 'u':
- if (pe > stringEnd - 4) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete unicode character escape sequence at '%s'", p
- );
- } else {
- UTF32 ch = unescape_unicode((unsigned char *) ++pe);
- pe += 3;
- if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
- pe++;
- if (pe > stringEnd - 6) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete surrogate pair at '%s'", p
- );
- }
- if (pe[0] == '\\' && pe[1] == 'u') {
- UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
- ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
- | (sur & 0x3FF));
- pe += 5;
- } else {
- unescape = (char *) "?";
- break;
- }
- }
- unescape_len = convert_UTF32_to_UTF8(buf, ch);
- unescape = buf;
- }
- break;
- default:
- p = pe;
- continue;
- }
- MEMCPY(buffer, unescape, char, unescape_len);
- buffer += unescape_len;
- p = ++pe;
- } else {
- pe++;
- }
- }
-
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
-
- # ifdef HAVE_RB_ENC_INTERNED_STR
- if (intern) {
- result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding());
- } else {
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
- }
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- # else
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
-
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
-
- if (intern) {
- # if STR_UMINUS_DEDUPE_FROZEN
- // Starting from MRI 2.8 it is preferable to freeze the string
- // before deduplication so that it can be interned directly
- // otherwise it would be duplicated first which is wasteful.
- result = rb_funcall(rb_str_freeze(result), i_uminus, 0);
- # elif STR_UMINUS_DEDUPE
- // MRI 2.5 and older do not deduplicate strings that are already
- // frozen.
- result = rb_funcall(result, i_uminus, 0);
- # else
- result = rb_str_freeze(result);
- # endif
- }
- # endif
-
- if (symbolize) {
- result = rb_str_intern(result);
- }
-
- return result;
-}
-
-
-enum {JSON_string_start = 1};
-enum {JSON_string_first_final = 8};
-enum {JSON_string_error = 0};
-
-enum {JSON_string_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_string_nfa_targs)[] = {
- 0, 0
-};
-static const char MAYBE_UNUSED(_JSON_string_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0
-};
+ if (symbolize) {
+ result = rb_str_intern(result);
+ }
-static const char MAYBE_UNUSED(_JSON_string_nfa_push_actions)[] = {
- 0, 0
-};
+ return result;
+}
-static const char MAYBE_UNUSED(_JSON_string_nfa_pop_trans)[] = {
- 0, 0
-};
+static inline bool json_string_cacheable_p(const char *string, size_t length)
+{
+ // We mostly want to cache strings that are likely to be repeated.
+ // Simple heuristics:
+ // - Common names aren't likely to be very long. So we just don't cache names above an arbitrary threshold.
+ // - If the first character isn't a letter, we're much less likely to see this string again.
+ return length <= JSON_RVALUE_CACHE_MAX_ENTRY_LENGTH && rb_isalpha(string[0]);
+}
+
+static inline VALUE json_string_fastpath(JSON_ParserState *state, JSON_ParserConfig *config, const char *string, const char *stringEnd, bool is_name)
+{
+ bool intern = is_name || config->freeze;
+ bool symbolize = is_name && config->symbolize_names;
+ size_t bufferSize = stringEnd - string;
+
+ if (is_name && state->in_array && RB_LIKELY(json_string_cacheable_p(string, bufferSize))) {
+ VALUE cached_key;
+ if (RB_UNLIKELY(symbolize)) {
+ cached_key = rsymbol_cache_fetch(&state->name_cache, string, bufferSize);
+ } else {
+ cached_key = rstring_cache_fetch(&state->name_cache, string, bufferSize);
+ }
+
+ if (RB_LIKELY(cached_key)) {
+ return cached_key;
+ }
+ }
+
+ return build_string(string, stringEnd, intern, symbolize);
+}
+#define JSON_MAX_UNESCAPE_POSITIONS 16
+typedef struct _json_unescape_positions {
+ long size;
+ const char **positions;
+ unsigned long additional_backslashes;
+} JSON_UnescapePositions;
-#line 612 "parser.rl"
-
-
-static int
-match_i(VALUE regexp, VALUE klass, VALUE memo)
-{
- if (regexp == Qundef) return ST_STOP;
- if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
- RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
- rb_ary_push(memo, klass);
- return ST_STOP;
- }
- return ST_CONTINUE;
-}
-
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
- VALUE match_string;
-
-
- {
- cs = (int)JSON_string_start;
- }
-
- #line 632 "parser.rl"
-
- json->memo = p;
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 8:
- goto st_case_8;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 34 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 34: {
- goto ctr2;
- }
- case 92: {
- goto st3;
- }
- }
- if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) {
- goto st0;
- }
- {
- goto st2;
- }
- ctr2:
- {
- #line 599 "parser.rl"
-
- *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
- if (NIL_P(*result)) {
- {p = p - 1; }
- {p+= 1; cs = 8; goto _out;}
- } else {
- {p = (( p + 1))-1;}
-
- }
- }
- {
- #line 609 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 8; goto _out;} }
-
- goto st8;
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 117 ) {
- goto st4;
- }
- if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) {
- goto st0;
- }
- {
- goto st2;
- }
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_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:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_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:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_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:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_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;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 634 "parser.rl"
-
-
- if (json->create_additions && RTEST(match_string = json->match_string)) {
- VALUE klass;
- VALUE memo = rb_ary_new2(2);
- rb_ary_push(memo, *result);
- rb_hash_foreach(match_string, match_i, memo);
- klass = rb_ary_entry(memo, 1);
- if (RTEST(klass)) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
-
- if (cs >= JSON_string_first_final) {
- return p + 1;
- } else {
- return NULL;
- }
+static inline const char *json_next_backslash(const char *pe, const char *stringEnd, JSON_UnescapePositions *positions)
+{
+ while (positions->size) {
+ positions->size--;
+ const char *next_position = positions->positions[0];
+ positions->positions++;
+ if (next_position >= pe) {
+ return next_position;
+ }
+ }
+
+ if (positions->additional_backslashes) {
+ positions->additional_backslashes--;
+ return memchr(pe, '\\', stringEnd - pe);
+ }
+
+ return NULL;
}
-/*
-* 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.
-*
-*/
+NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_ParserConfig *config, const char *string, const char *stringEnd, bool is_name, JSON_UnescapePositions *positions)
+{
+ bool intern = is_name || config->freeze;
+ bool symbolize = is_name && config->symbolize_names;
+ size_t bufferSize = stringEnd - string;
+ const char *p = string, *pe = string, *bufferStart;
+ char *buffer;
+
+ VALUE result = rb_str_buf_new(bufferSize);
+ rb_enc_associate_index(result, utf8_encindex);
+ buffer = RSTRING_PTR(result);
+ bufferStart = buffer;
+
+#define APPEND_CHAR(chr) *buffer++ = chr; p = ++pe;
+
+ while (pe < stringEnd && (pe = json_next_backslash(pe, stringEnd, positions))) {
+ if (pe > p) {
+ MEMCPY(buffer, p, char, pe - p);
+ buffer += pe - p;
+ }
+ switch (*++pe) {
+ case '"':
+ case '/':
+ p = pe; // nothing to unescape just need to skip the backslash
+ break;
+ case '\\':
+ APPEND_CHAR('\\');
+ break;
+ case 'n':
+ APPEND_CHAR('\n');
+ break;
+ case 'r':
+ APPEND_CHAR('\r');
+ break;
+ case 't':
+ APPEND_CHAR('\t');
+ break;
+ case 'b':
+ APPEND_CHAR('\b');
+ break;
+ case 'f':
+ APPEND_CHAR('\f');
+ break;
+ case 'u': {
+ uint32_t ch = unescape_unicode(state, ++pe, stringEnd);
+ pe += 3;
+ /* To handle values above U+FFFF, we take a sequence of
+ * \uXXXX escapes in the U+D800..U+DBFF then
+ * U+DC00..U+DFFF ranges, take the low 10 bits from each
+ * to make a 20-bit number, then add 0x10000 to get the
+ * final codepoint.
+ *
+ * See Unicode 15: 3.8 "Surrogates", 5.3 "Handling
+ * Surrogate Pairs in UTF-16", and 23.6 "Surrogates
+ * Area".
+ */
+ if ((ch & 0xFC00) == 0xD800) {
+ pe++;
+ if (RB_LIKELY((pe <= stringEnd - 6) && memcmp(pe, "\\u", 2) == 0)) {
+ uint32_t sur = unescape_unicode(state, pe + 2, stringEnd);
+
+ if (RB_UNLIKELY((sur & 0xFC00) != 0xDC00)) {
+ raise_parse_error_at("invalid surrogate pair at %s", state, p);
+ }
+
+ ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16) | (sur & 0x3FF));
+ pe += 5;
+ } else {
+ raise_parse_error_at("incomplete surrogate pair at %s", state, p);
+ break;
+ }
+ }
+
+ int unescape_len = convert_UTF32_to_UTF8(buffer, ch);
+ buffer += unescape_len;
+ p = ++pe;
+ break;
+ }
+ default:
+ if ((unsigned char)*pe < 0x20) {
+ if (!config->allow_control_characters) {
+ if (*pe == '\n') {
+ raise_parse_error_at("Invalid unescaped newline character (\\n) in string: %s", state, pe - 1);
+ }
+ raise_parse_error_at("invalid ASCII control character in string: %s", state, pe - 1);
+ }
+ }
+
+ if (config->allow_invalid_escape) {
+ APPEND_CHAR(*pe);
+ } else {
+ raise_parse_error_at("invalid escape character in string: %s", state, pe - 1);
+ }
+ break;
+ }
+ }
+#undef APPEND_CHAR
+
+ if (stringEnd > p) {
+ MEMCPY(buffer, p, char, stringEnd - p);
+ buffer += stringEnd - p;
+ }
+ rb_str_set_len(result, buffer - bufferStart);
+
+ if (symbolize) {
+ result = rb_str_intern(result);
+ } else if (intern) {
+ result = rb_str_to_interned_str(result);
+ }
+
+ return result;
+}
-static VALUE convert_encoding(VALUE source)
+#define MAX_FAST_INTEGER_SIZE 18
+#define MAX_NUMBER_STACK_BUFFER 128
+
+typedef VALUE (*json_number_decode_func_t)(const char *ptr);
+
+static inline VALUE json_decode_large_number(const char *start, long len, json_number_decode_func_t func)
{
- #ifdef HAVE_RUBY_ENCODING_H
- rb_encoding *enc = rb_enc_get(source);
- if (enc == rb_ascii8bit_encoding()) {
- if (OBJ_FROZEN(source)) {
- source = rb_str_dup(source);
- }
- FORCE_UTF8(source);
- } else {
- source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
- }
- #endif
- return source;
+ if (RB_LIKELY(len < MAX_NUMBER_STACK_BUFFER)) {
+ char buffer[MAX_NUMBER_STACK_BUFFER];
+ MEMCPY(buffer, start, char, len);
+ buffer[len] = '\0';
+ return func(buffer);
+ } else {
+ VALUE buffer_v = rb_str_tmp_new(len);
+ char *buffer = RSTRING_PTR(buffer_v);
+ MEMCPY(buffer, start, char, len);
+ buffer[len] = '\0';
+ VALUE number = func(buffer);
+ RB_GC_GUARD(buffer_v);
+ return number;
+ }
}
-/*
-* 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 100.
-* * *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.
-* * *symbolize_names*: If set to true, returns symbols for the names
-* (keys) in a JSON object. Otherwise strings are returned, which is
-* also the default. It's not possible to use this option in
-* conjunction with the *create_additions* option.
-* * *create_additions*: If set to false, the Parser doesn't create
-* additions even if a matching class and create_id was found. This option
-* defaults to false.
-* * *object_class*: Defaults to Hash
-* * *array_class*: Defaults to Array
-*/
-static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE source, opts;
- GET_PARSER_INIT;
-
- if (json->Vsource) {
- rb_raise(rb_eTypeError, "already initialized instance");
- }
- #ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- rb_scan_args(argc, argv, "1:", &source, &opts);
- #else
- rb_scan_args(argc, argv, "11", &source, &opts);
- #endif
- if (!NIL_P(opts)) {
- #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- 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 {
- #endif
- VALUE tmp = ID2SYM(i_max_nesting);
- if (option_given_p(opts, tmp)) {
- 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 = 100;
- }
- tmp = ID2SYM(i_allow_nan);
- if (option_given_p(opts, tmp)) {
- json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_symbolize_names);
- if (option_given_p(opts, tmp)) {
- json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->symbolize_names = 0;
- }
- tmp = ID2SYM(i_freeze);
- if (option_given_p(opts, tmp)) {
- json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->freeze = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (option_given_p(opts, tmp)) {
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
- } else {
- json->create_additions = 0;
- }
- if (json->symbolize_names && json->create_additions) {
- rb_raise(rb_eArgError,
- "options :symbolize_names and :create_additions cannot be "
- " used in conjunction");
- }
- tmp = ID2SYM(i_create_id);
- if (option_given_p(opts, tmp)) {
- json->create_id = rb_hash_aref(opts, tmp);
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- tmp = ID2SYM(i_object_class);
- if (option_given_p(opts, tmp)) {
- json->object_class = rb_hash_aref(opts, tmp);
- } else {
- json->object_class = Qnil;
- }
- tmp = ID2SYM(i_array_class);
- if (option_given_p(opts, tmp)) {
- json->array_class = rb_hash_aref(opts, tmp);
- } else {
- json->array_class = Qnil;
- }
- tmp = ID2SYM(i_decimal_class);
- if (option_given_p(opts, tmp)) {
- json->decimal_class = rb_hash_aref(opts, tmp);
- } else {
- json->decimal_class = Qnil;
- }
- tmp = ID2SYM(i_match_string);
- if (option_given_p(opts, tmp)) {
- VALUE match_string = rb_hash_aref(opts, tmp);
- json->match_string = RTEST(match_string) ? match_string : Qnil;
- } else {
- json->match_string = Qnil;
- }
- #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- }
- #endif
- } else {
- json->max_nesting = 100;
- json->allow_nan = 0;
- json->create_additions = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- json->object_class = Qnil;
- json->array_class = Qnil;
- json->decimal_class = Qnil;
- }
- source = convert_encoding(StringValue(source));
- StringValue(source);
- json->len = RSTRING_LEN(source);
- json->source = RSTRING_PTR(source);;
- json->Vsource = source;
- return self;
-}
-
-
-enum {JSON_start = 1};
-enum {JSON_first_final = 10};
-enum {JSON_error = 0};
-
-enum {JSON_en_main = 1};
-
-static const char MAYBE_UNUSED(_JSON_nfa_targs)[] = {
- 0, 0
-};
+static VALUE json_decode_inum(const char *buffer)
+{
+ return rb_cstr2inum(buffer, 10);
+}
-static const char MAYBE_UNUSED(_JSON_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-};
+NOINLINE(static) VALUE json_decode_large_integer(const char *start, long len)
+{
+ return json_decode_large_number(start, len, json_decode_inum);
+}
-static const char MAYBE_UNUSED(_JSON_nfa_push_actions)[] = {
- 0, 0
-};
+static inline VALUE json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const char *start, const char *end)
+{
+ if (RB_LIKELY(mantissa_digits < MAX_FAST_INTEGER_SIZE)) {
+ if (negative) {
+ return INT64T2NUM(-((int64_t)mantissa));
+ }
+ return UINT64T2NUM(mantissa);
+ }
+
+ return json_decode_large_integer(start, end - start);
+}
+
+static VALUE json_decode_dnum(const char *buffer)
+{
+ return DBL2NUM(rb_cstr_to_dbl(buffer, 1));
+}
+
+NOINLINE(static) VALUE json_decode_large_float(const char *start, long len)
+{
+ return json_decode_large_number(start, len, json_decode_dnum);
+}
+
+/* Ruby JSON optimized float decoder using vendored Ryu algorithm
+ * Accepts pre-extracted mantissa and exponent from first-pass validation
+ */
+static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantissa, int mantissa_digits, int64_t exponent, bool negative,
+ const char *start, const char *end)
+{
+ if (RB_UNLIKELY(config->decimal_class)) {
+ VALUE text = rb_str_new(start, end - start);
+ return rb_funcallv(config->decimal_class, config->decimal_method_id, 1, &text);
+ }
+
+ if (RB_UNLIKELY(exponent > INT32_MAX)) {
+ return negative ? CMinusInfinity : CInfinity;
+ }
+
+ if (RB_UNLIKELY(exponent < INT32_MIN)) {
+ return rb_float_new(negative ? -0.0 : 0.0);
+ }
+
+ // Fall back to rb_cstr_to_dbl for potential subnormals (rare edge case)
+ // Ryu has rounding issues with subnormals around 1e-310 (< 2.225e-308)
+ if (RB_UNLIKELY(mantissa_digits > 17 || mantissa_digits + exponent < -307)) {
+ return json_decode_large_float(start, end - start);
+ }
+
+ return DBL2NUM(ryu_s2d_from_parts(mantissa, mantissa_digits, (int32_t)exponent, negative));
+}
+
+static inline VALUE json_decode_array(JSON_ParserState *state, JSON_ParserConfig *config, long count)
+{
+ VALUE array = rb_ary_new_from_values(count, rvalue_stack_peek(state->stack, count));
+ rvalue_stack_pop(state->stack, count);
+
+ if (config->freeze) {
+ RB_OBJ_FREEZE(array);
+ }
+
+ return array;
+}
+
+static VALUE json_find_duplicated_key(size_t count, const VALUE *pairs)
+{
+ VALUE set = rb_hash_new_capa(count / 2);
+ for (size_t index = 0; index < count; index += 2) {
+ size_t before = RHASH_SIZE(set);
+ VALUE key = pairs[index];
+ rb_hash_aset(set, key, Qtrue);
+ if (RHASH_SIZE(set) == before) {
+ if (RB_SYMBOL_P(key)) {
+ return rb_sym2str(key);
+ }
+ return key;
+ }
+ }
+ return Qfalse;
+}
+
+NOINLINE(static) void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_key)
+{
+ VALUE message = rb_sprintf(
+ "detected duplicate key %"PRIsVALUE" in JSON object. This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`",
+ rb_inspect(duplicate_key)
+ );
+
+ emit_parse_warning(RSTRING_PTR(message), state);
+ RB_GC_GUARD(message);
+}
+
+NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_key)
+{
+ VALUE message = rb_sprintf(
+ "duplicate key %"PRIsVALUE,
+ rb_inspect(duplicate_key)
+ );
+
+ long line, column;
+ cursor_position(state, &line, &column);
+ rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
+ rb_exc_raise(parse_error_new(message, line, column));
+}
+
+static inline VALUE json_decode_object(JSON_ParserState *state, JSON_ParserConfig *config, size_t count)
+{
+ size_t entries_count = count / 2;
+ VALUE object = rb_hash_new_capa(entries_count);
+ const VALUE *pairs = rvalue_stack_peek(state->stack, count);
+ rb_hash_bulk_insert(count, pairs, object);
+
+ if (RB_UNLIKELY(RHASH_SIZE(object) < entries_count)) {
+ switch (config->on_duplicate_key) {
+ case JSON_IGNORE:
+ break;
+ case JSON_DEPRECATED:
+ // Only emit the first few deprecations to avoid spamming.
+ if (state->emitted_deprecations < 5) {
+ emit_duplicate_key_warning(state, json_find_duplicated_key(count, pairs));
+ state->emitted_deprecations++;
+ }
+
+ break;
+ case JSON_RAISE:
+ raise_duplicate_key_error(state, json_find_duplicated_key(count, pairs));
+ break;
+ }
+ }
+
+ rvalue_stack_pop(state->stack, count);
+
+ if (config->freeze) {
+ RB_OBJ_FREEZE(object);
+ }
+
+ return object;
+}
+
+static inline VALUE json_push_value(JSON_ParserState *state, JSON_ParserConfig *config, VALUE value)
+{
+ if (RB_UNLIKELY(config->on_load_proc)) {
+ value = rb_proc_call_with_block(config->on_load_proc, 1, &value, Qnil);
+ }
+ rvalue_stack_push(state->stack, value, state->stack_handle, &state->stack);
+ return value;
+}
-static const char MAYBE_UNUSED(_JSON_nfa_pop_trans)[] = {
- 0, 0
+static const bool string_scan_table[256] = {
+ // ASCII Control Characters
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ // ASCII Characters
+ 0, 0, 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, 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,
};
+#ifdef HAVE_SIMD
+static SIMD_Implementation simd_impl = SIMD_NONE;
+#endif /* HAVE_SIMD */
+
+ALWAYS_INLINE(static) bool string_scan(JSON_ParserState *state)
+{
+#ifdef HAVE_SIMD
+#if defined(HAVE_SIMD_NEON)
+
+ uint64_t mask = 0;
+ if (string_scan_simd_neon(&state->cursor, state->end, &mask)) {
+ state->cursor += trailing_zeros64(mask) >> 2;
+ return true;
+ }
+
+#elif defined(HAVE_SIMD_SSE2)
+ if (simd_impl == SIMD_SSE2) {
+ int mask = 0;
+ if (string_scan_simd_sse2(&state->cursor, state->end, &mask)) {
+ state->cursor += trailing_zeros(mask);
+ return true;
+ }
+ }
+#endif /* HAVE_SIMD_NEON or HAVE_SIMD_SSE2 */
+#endif /* HAVE_SIMD */
+
+ while (!eos(state)) {
+ if (RB_UNLIKELY(string_scan_table[(unsigned char)*state->cursor])) {
+ return true;
+ }
+ state->cursor++;
+ }
+
+ // If the string ended with an unterminated escape sequence, we might
+ // have gone past the end.
+ if (RB_UNLIKELY(state->cursor > state->end)) {
+ state->cursor = state->end;
+ }
+
+ return false;
+}
+
+static VALUE json_parse_escaped_string(JSON_ParserState *state, JSON_ParserConfig *config, bool is_name, const char *start)
+{
+ const char *backslashes[JSON_MAX_UNESCAPE_POSITIONS];
+ JSON_UnescapePositions positions = {
+ .size = 0,
+ .positions = backslashes,
+ .additional_backslashes = 0,
+ };
+
+ do {
+ switch (*state->cursor) {
+ case '"': {
+ VALUE string = json_string_unescape(state, config, start, state->cursor, is_name, &positions);
+ state->cursor++;
+ return json_push_value(state, config, string);
+ }
+ case '\\': {
+ if (RB_LIKELY(positions.size < JSON_MAX_UNESCAPE_POSITIONS)) {
+ backslashes[positions.size] = state->cursor;
+ positions.size++;
+ } else {
+ positions.additional_backslashes++;
+ }
+ state->cursor++;
+ break;
+ }
+ default:
+ if (!config->allow_control_characters) {
+ raise_parse_error("invalid ASCII control character in string: %s", state);
+ }
+ break;
+ }
+
+ state->cursor++;
+ } while (string_scan(state));
+
+ raise_parse_error("unexpected end of input, expected closing \"", state);
+ return Qfalse;
+}
+
+ALWAYS_INLINE(static) VALUE json_parse_string(JSON_ParserState *state, JSON_ParserConfig *config, bool is_name)
+{
+ state->cursor++;
+ const char *start = state->cursor;
+
+ if (RB_UNLIKELY(!string_scan(state))) {
+ raise_parse_error("unexpected end of input, expected closing \"", state);
+ }
+
+ if (RB_LIKELY(*state->cursor == '"')) {
+ VALUE string = json_string_fastpath(state, config, start, state->cursor, is_name);
+ state->cursor++;
+ return json_push_value(state, config, string);
+ }
+ return json_parse_escaped_string(state, config, is_name, start);
+}
+
+#if JSON_CPU_LITTLE_ENDIAN_64BITS
+// From: https://lemire.me/blog/2022/01/21/swar-explained-parsing-eight-digits/
+// Additional References:
+// https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
+// http://0x80.pl/notesen/2014-10-12-parsing-decimal-numbers-part-1-swar.html
+static inline uint64_t decode_8digits_unrolled(uint64_t val) {
+ const uint64_t mask = 0x000000FF000000FF;
+ const uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
+ const uint64_t mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
+ val -= 0x3030303030303030;
+ val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
+ val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
+ return val;
+}
+
+static inline uint64_t decode_4digits_unrolled(uint32_t val) {
+ const uint32_t mask = 0x000000FF;
+ const uint32_t mul1 = 100;
+ val -= 0x30303030;
+ val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
+ val = ((val & mask) * mul1) + (((val >> 16) & mask));
+ return val;
+}
+#endif
+
+static inline int json_parse_digits(JSON_ParserState *state, uint64_t *accumulator)
+{
+ const char *start = state->cursor;
+
+#if JSON_CPU_LITTLE_ENDIAN_64BITS
+ while (rest(state) >= sizeof(uint64_t)) {
+ uint64_t next_8bytes;
+ memcpy(&next_8bytes, state->cursor, sizeof(uint64_t));
+
+ // From: https://github.com/simdjson/simdjson/blob/32b301893c13d058095a07d9868edaaa42ee07aa/include/simdjson/generic/numberparsing.h#L333
+ // Branchless version of: http://0x80.pl/articles/swar-digits-validate.html
+ uint64_t match = (next_8bytes & 0xF0F0F0F0F0F0F0F0) | (((next_8bytes + 0x0606060606060606) & 0xF0F0F0F0F0F0F0F0) >> 4);
+
+ if (match == 0x3333333333333333) { // 8 consecutive digits
+ *accumulator = (*accumulator * 100000000) + decode_8digits_unrolled(next_8bytes);
+ state->cursor += 8;
+ continue;
+ }
+
+ uint32_t consecutive_digits = trailing_zeros64(match ^ 0x3333333333333333) / CHAR_BIT;
+
+ if (consecutive_digits >= 4) {
+ *accumulator = (*accumulator * 10000) + decode_4digits_unrolled((uint32_t)next_8bytes);
+ state->cursor += 4;
+ consecutive_digits -= 4;
+ }
+
+ while (consecutive_digits) {
+ *accumulator = *accumulator * 10 + (*state->cursor - '0');
+ consecutive_digits--;
+ state->cursor++;
+ }
+
+ return (int)(state->cursor - start);
+ }
+#endif
+
+ char next_char;
+ while (rb_isdigit(next_char = peek(state))) {
+ *accumulator = *accumulator * 10 + (next_char - '0');
+ state->cursor++;
+ }
+ return (int)(state->cursor - start);
+}
+
+static inline VALUE json_parse_number(JSON_ParserState *state, JSON_ParserConfig *config, bool negative, const char *start)
+{
+ bool integer = true;
+ const char first_digit = *state->cursor;
+
+ // Variables for Ryu optimization - extract digits during parsing
+ int64_t exponent = 0;
+ int decimal_point_pos = -1;
+ uint64_t mantissa = 0;
+
+ // Parse integer part and extract mantissa digits
+ int mantissa_digits = json_parse_digits(state, &mantissa);
+
+ if (RB_UNLIKELY((first_digit == '0' && mantissa_digits > 1) || (negative && mantissa_digits == 0))) {
+ raise_parse_error_at("invalid number: %s", state, start);
+ }
+
+ // Parse fractional part
+ if (peek(state) == '.') {
+ integer = false;
+ decimal_point_pos = mantissa_digits; // Remember position of decimal point
+ state->cursor++;
+
+ int fractional_digits = json_parse_digits(state, &mantissa);
+ mantissa_digits += fractional_digits;
+
+ if (RB_UNLIKELY(!fractional_digits)) {
+ raise_parse_error_at("invalid number: %s", state, start);
+ }
+ }
+
+ // Parse exponent
+ if (rb_tolower(peek(state)) == 'e') {
+ integer = false;
+ state->cursor++;
+
+ bool negative_exponent = false;
+ const char next_char = peek(state);
+ if (next_char == '-' || next_char == '+') {
+ negative_exponent = next_char == '-';
+ state->cursor++;
+ }
+
+ uint64_t abs_exponent = 0;
+ int exponent_digits = json_parse_digits(state, &abs_exponent);
+
+ if (RB_UNLIKELY(!exponent_digits)) {
+ raise_parse_error_at("invalid number: %s", state, start);
+ }
+
+ if (RB_UNLIKELY(exponent_digits >= 20 || abs_exponent > (uint64_t)INT64_MAX)) {
+ exponent = negative_exponent ? INT64_MIN : INT64_MAX;
+ } else {
+ exponent = negative_exponent ? -(int64_t)abs_exponent : (int64_t)abs_exponent;
+ }
+ }
+
+ if (integer) {
+ return json_decode_integer(mantissa, mantissa_digits, negative, start, state->cursor);
+ }
+
+ // Adjust exponent based on decimal point position
+ if (decimal_point_pos >= 0) {
+ exponent -= (mantissa_digits - decimal_point_pos);
+ }
+
+ return json_decode_float(config, mantissa, mantissa_digits, exponent, negative, start, state->cursor);
+}
+
+static inline VALUE json_parse_positive_number(JSON_ParserState *state, JSON_ParserConfig *config)
+{
+ return json_parse_number(state, config, false, state->cursor);
+}
+
+static inline VALUE json_parse_negative_number(JSON_ParserState *state, JSON_ParserConfig *config)
+{
+ const char *start = state->cursor;
+ state->cursor++;
+ return json_parse_number(state, config, true, start);
+}
-#line 835 "parser.rl"
+static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
+{
+ json_eat_whitespace(state);
+
+ switch (peek(state)) {
+ case 'n':
+ if (rest(state) >= 4 && (memcmp(state->cursor, "null", 4) == 0)) {
+ state->cursor += 4;
+ return json_push_value(state, config, Qnil);
+ }
+
+ raise_parse_error("unexpected token %s", state);
+ break;
+ case 't':
+ if (rest(state) >= 4 && (memcmp(state->cursor, "true", 4) == 0)) {
+ state->cursor += 4;
+ return json_push_value(state, config, Qtrue);
+ }
+
+ raise_parse_error("unexpected token %s", state);
+ break;
+ case 'f':
+ // Note: memcmp with a small power of two compile to an integer comparison
+ if (rest(state) >= 5 && (memcmp(state->cursor + 1, "alse", 4) == 0)) {
+ state->cursor += 5;
+ return json_push_value(state, config, Qfalse);
+ }
+
+ raise_parse_error("unexpected token %s", state);
+ break;
+ case 'N':
+ // Note: memcmp with a small power of two compile to an integer comparison
+ if (config->allow_nan && rest(state) >= 3 && (memcmp(state->cursor + 1, "aN", 2) == 0)) {
+ state->cursor += 3;
+ return json_push_value(state, config, CNaN);
+ }
+
+ raise_parse_error("unexpected token %s", state);
+ break;
+ case 'I':
+ if (config->allow_nan && rest(state) >= 8 && (memcmp(state->cursor, "Infinity", 8) == 0)) {
+ state->cursor += 8;
+ return json_push_value(state, config, CInfinity);
+ }
+
+ raise_parse_error("unexpected token %s", state);
+ break;
+ case '-': {
+ // Note: memcmp with a small power of two compile to an integer comparison
+ if (rest(state) >= 9 && (memcmp(state->cursor + 1, "Infinity", 8) == 0)) {
+ if (config->allow_nan) {
+ state->cursor += 9;
+ return json_push_value(state, config, CMinusInfinity);
+ } else {
+ raise_parse_error("unexpected token %s", state);
+ }
+ }
+ return json_push_value(state, config, json_parse_negative_number(state, config));
+ break;
+ }
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ return json_push_value(state, config, json_parse_positive_number(state, config));
+ break;
+ case '"': {
+ // %r{\A"[^"\\\t\n\x00]*(?:\\[bfnrtu\\/"][^"\\]*)*"}
+ return json_parse_string(state, config, false);
+ break;
+ }
+ case '[': {
+ state->cursor++;
+ json_eat_whitespace(state);
+ long stack_head = state->stack->head;
+
+ if (peek(state) == ']') {
+ state->cursor++;
+ return json_push_value(state, config, json_decode_array(state, config, 0));
+ } else {
+ state->current_nesting++;
+ if (RB_UNLIKELY(config->max_nesting && (config->max_nesting < state->current_nesting))) {
+ rb_raise(eNestingError, "nesting of %d is too deep", state->current_nesting);
+ }
+ state->in_array++;
+ json_parse_any(state, config);
+ }
+
+ while (true) {
+ json_eat_whitespace(state);
+
+ const char next_char = peek(state);
+
+ if (RB_LIKELY(next_char == ',')) {
+ state->cursor++;
+ if (config->allow_trailing_comma) {
+ json_eat_whitespace(state);
+ if (peek(state) == ']') {
+ continue;
+ }
+ }
+ json_parse_any(state, config);
+ continue;
+ }
+
+ if (next_char == ']') {
+ state->cursor++;
+ long count = state->stack->head - stack_head;
+ state->current_nesting--;
+ state->in_array--;
+ return json_push_value(state, config, json_decode_array(state, config, count));
+ }
+
+ raise_parse_error("expected ',' or ']' after array value", state);
+ }
+ break;
+ }
+ case '{': {
+ const char *object_start_cursor = state->cursor;
+
+ state->cursor++;
+ json_eat_whitespace(state);
+ long stack_head = state->stack->head;
+
+ if (peek(state) == '}') {
+ state->cursor++;
+ return json_push_value(state, config, json_decode_object(state, config, 0));
+ } else {
+ state->current_nesting++;
+ if (RB_UNLIKELY(config->max_nesting && (config->max_nesting < state->current_nesting))) {
+ rb_raise(eNestingError, "nesting of %d is too deep", state->current_nesting);
+ }
+
+ if (peek(state) != '"') {
+ raise_parse_error("expected object key, got %s", state);
+ }
+ json_parse_string(state, config, true);
+
+ json_eat_whitespace(state);
+ if (peek(state) != ':') {
+ raise_parse_error("expected ':' after object key", state);
+ }
+ state->cursor++;
+
+ json_parse_any(state, config);
+ }
+
+ while (true) {
+ json_eat_whitespace(state);
+
+ const char next_char = peek(state);
+ if (next_char == '}') {
+ state->cursor++;
+ state->current_nesting--;
+ size_t count = state->stack->head - stack_head;
+
+ // Temporary rewind cursor in case an error is raised
+ const char *final_cursor = state->cursor;
+ state->cursor = object_start_cursor;
+ VALUE object = json_decode_object(state, config, count);
+ state->cursor = final_cursor;
+
+ return json_push_value(state, config, object);
+ }
+
+ if (next_char == ',') {
+ state->cursor++;
+ json_eat_whitespace(state);
+
+ if (config->allow_trailing_comma) {
+ if (peek(state) == '}') {
+ continue;
+ }
+ }
+
+ if (RB_UNLIKELY(peek(state) != '"')) {
+ raise_parse_error("expected object key, got: %s", state);
+ }
+ json_parse_string(state, config, true);
+
+ json_eat_whitespace(state);
+ if (RB_UNLIKELY(peek(state) != ':')) {
+ raise_parse_error("expected ':' after object key, got: %s", state);
+ }
+ state->cursor++;
+
+ json_parse_any(state, config);
+
+ continue;
+ }
+
+ raise_parse_error("expected ',' or '}' after object value, got: %s", state);
+ }
+ break;
+ }
+
+ case 0:
+ raise_parse_error("unexpected end of input", state);
+ break;
+
+ default:
+ raise_parse_error("unexpected character: %s", state);
+ break;
+ }
+
+ raise_parse_error("unreachable: %s", state);
+ return Qundef;
+}
+static void json_ensure_eof(JSON_ParserState *state)
+{
+ json_eat_whitespace(state);
+ if (!eos(state)) {
+ raise_parse_error("unexpected token at end of stream %s", state);
+ }
+}
/*
-* call-seq: parse()
-*
-* Parses the current JSON text _source_ and returns the complete data
-* structure as a result.
-* It raises JSON::ParseError if fail to parse.
-*/
-static VALUE cParser_parse(VALUE self)
-{
- char *p, *pe;
- int cs = EVIL;
- VALUE result = Qnil;
- GET_PARSER;
-
-
- {
- cs = (int)JSON_start;
- }
-
- #line 851 "parser.rl"
-
- p = json->source;
- pe = p + json->len;
-
- {
- if ( p == pe )
- goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 10:
- goto st_case_10;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- }
- goto st_out;
- st1:
- p+= 1;
- if ( p == pe )
- goto _test_eof1;
- st_case_1:
- switch( ( (*( p))) ) {
- case 13: {
- goto st1;
- }
- case 32: {
- goto st1;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st6;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st1;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- ctr2:
- {
- #line 827 "parser.rl"
-
- char *np = JSON_parse_value(json, p, pe, &result, 0);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 10; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st10;
- st10:
- p+= 1;
- if ( p == pe )
- goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 13: {
- goto st10;
- }
- case 32: {
- goto st10;
- }
- case 47: {
- goto st2;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st2:
- p+= 1;
- if ( p == pe )
- goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 42: {
- goto st3;
- }
- case 47: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
- goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 42 ) {
- goto st4;
- }
- {
- goto st3;
- }
- st4:
- p+= 1;
- if ( p == pe )
- goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st4;
- }
- case 47: {
- goto st10;
- }
- }
- {
- goto st3;
- }
- st5:
- p+= 1;
- if ( p == pe )
- goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 10 ) {
- goto st10;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
- goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st0;
- }
- st7:
- p+= 1;
- if ( p == pe )
- goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 42 ) {
- goto st8;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
- goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 42: {
- goto st8;
- }
- case 47: {
- goto st1;
- }
- }
- {
- goto st7;
- }
- st9:
- p+= 1;
- if ( p == pe )
- goto _test_eof9;
- st_case_9:
- if ( ( (*( p))) == 10 ) {
- goto st1;
- }
- {
- goto st9;
- }
- st_out:
- _test_eof1: cs = 1; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 854 "parser.rl"
-
-
- if (cs >= JSON_first_final && p == pe) {
- return result;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return Qnil;
- }
-}
-
-static void JSON_mark(void *ptr)
-{
- JSON_Parser *json = ptr;
- rb_gc_mark_maybe(json->Vsource);
- rb_gc_mark_maybe(json->create_id);
- rb_gc_mark_maybe(json->object_class);
- rb_gc_mark_maybe(json->array_class);
- rb_gc_mark_maybe(json->decimal_class);
- rb_gc_mark_maybe(json->match_string);
-}
-
-static void JSON_free(void *ptr)
-{
- JSON_Parser *json = ptr;
- fbuffer_free(json->fbuffer);
- ruby_xfree(json);
-}
-
-static size_t JSON_memsize(const void *ptr)
-{
- const JSON_Parser *json = ptr;
- return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
-}
-
-#ifdef NEW_TYPEDDATA_WRAPPER
-static const rb_data_type_t JSON_Parser_type = {
- "JSON/Parser",
- {JSON_mark, JSON_free, JSON_memsize,},
- #ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
- #endif
+ * 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.
+ *
+ */
+
+static VALUE convert_encoding(VALUE source)
+{
+ StringValue(source);
+ int encindex = RB_ENCODING_GET(source);
+
+ if (RB_LIKELY(encindex == utf8_encindex)) {
+ return source;
+ }
+
+ if (encindex == binary_encindex) {
+ // For historical reason, we silently reinterpret binary strings as UTF-8
+ return rb_enc_associate_index(rb_str_dup(source), utf8_encindex);
+ }
+
+ source = rb_funcall(source, i_encode, 1, Encoding_UTF_8);
+ StringValue(source);
+ return source;
+}
+
+struct parser_config_init_args {
+ JSON_ParserConfig *config;
+ VALUE self;
};
-#endif
-static VALUE cJSON_parser_s_allocate(VALUE klass)
+static void parser_config_wb_write(VALUE self, VALUE *dest, VALUE val)
+{
+ *dest = val;
+ if (self) RB_OBJ_WRITTEN(self, Qundef, val);
+}
+
+static int parser_config_init_i(VALUE key, VALUE val, VALUE data)
+{
+ struct parser_config_init_args *args = (struct parser_config_init_args *)data;
+ JSON_ParserConfig *config = args->config;
+ VALUE self = args->self;
+
+ if (key == sym_max_nesting) { config->max_nesting = RTEST(val) ? FIX2INT(val) : 0; }
+ else if (key == sym_allow_nan) { config->allow_nan = RTEST(val); }
+ else if (key == sym_allow_trailing_comma) { config->allow_trailing_comma = RTEST(val); }
+ else if (key == sym_allow_control_characters) { config->allow_control_characters = RTEST(val); }
+ else if (key == sym_allow_invalid_escape) { config->allow_invalid_escape = RTEST(val); }
+ else if (key == sym_symbolize_names) { config->symbolize_names = RTEST(val); }
+ else if (key == sym_freeze) { config->freeze = RTEST(val); }
+ else if (key == sym_on_load) { parser_config_wb_write(self, &config->on_load_proc, RTEST(val) ? val : Qfalse); }
+ else if (key == sym_allow_duplicate_key) { config->on_duplicate_key = RTEST(val) ? JSON_IGNORE : JSON_RAISE; }
+ else if (key == sym_decimal_class) {
+ if (RTEST(val)) {
+ if (rb_respond_to(val, i_try_convert)) {
+ parser_config_wb_write(self, &config->decimal_class, val);
+ config->decimal_method_id = i_try_convert;
+ } else if (rb_respond_to(val, i_new)) {
+ parser_config_wb_write(self, &config->decimal_class, val);
+ config->decimal_method_id = i_new;
+ } else if (RB_TYPE_P(val, T_CLASS)) {
+ VALUE name = rb_class_name(val);
+ const char *name_cstr = RSTRING_PTR(name);
+ const char *last_colon = strrchr(name_cstr, ':');
+ if (last_colon) {
+ const char *mod_path_end = last_colon - 1;
+ VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr);
+ parser_config_wb_write(self, &config->decimal_class, rb_path_to_class(mod_path));
+
+ const char *method_name_beg = last_colon + 1;
+ long before_len = method_name_beg - name_cstr;
+ long len = RSTRING_LEN(name) - before_len;
+ VALUE method_name = rb_str_substr(name, before_len, len);
+ config->decimal_method_id = SYM2ID(rb_str_intern(method_name));
+ } else {
+ parser_config_wb_write(self, &config->decimal_class, rb_mKernel);
+ config->decimal_method_id = SYM2ID(rb_str_intern(name));
+ }
+ }
+ }
+ }
+
+ return ST_CONTINUE;
+}
+
+static void parser_config_init(JSON_ParserConfig *config, VALUE opts, VALUE self)
{
- JSON_Parser *json;
- VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json);
- json->fbuffer = fbuffer_alloc(0);
- return obj;
+ config->max_nesting = 100;
+
+ struct parser_config_init_args args = {
+ .config = config,
+ .self = self,
+ };
+
+ if (!NIL_P(opts)) {
+ Check_Type(opts, T_HASH);
+ if (RHASH_SIZE(opts) > 0) {
+ // We assume in most cases few keys are set so it's faster to go over
+ // the provided keys than to check all possible keys.
+ rb_hash_foreach(opts, parser_config_init_i, (VALUE)&args);
+ }
+
+ }
}
/*
-* call-seq: source()
-*
-* Returns a copy of the current _source_ string, that was used to construct
-* this Parser.
-*/
-static VALUE cParser_source(VALUE self)
+ * call-seq: new(opts => {})
+ *
+ * Creates a new JSON::Ext::ParserConfig instance.
+ *
+ * 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 100.
+ * * *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.
+ * * *symbolize_names*: If set to true, returns symbols for the names
+ * (keys) in a JSON object. Otherwise strings are returned, which is
+ * also the default. It's not possible to use this option in
+ * conjunction with the *create_additions* option.
+ * * *decimal_class*: Specifies which class to use instead of the default
+ * (Float) when parsing decimal numbers. This class must accept a single
+ * string argument in its constructor.
+ */
+static VALUE cParserConfig_initialize(VALUE self, VALUE opts)
{
- GET_PARSER;
- return rb_str_dup(json->Vsource);
+ rb_check_frozen(self);
+ GET_PARSER_CONFIG;
+
+ parser_config_init(config, opts, self);
+
+ return self;
}
-void Init_parser(void)
+static VALUE cParser_parse(JSON_ParserConfig *config, VALUE src)
{
- #ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
- #endif
-
- #undef rb_intern
- rb_require("json/common");
- 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_gc_register_mark_object(eParserError);
- rb_gc_register_mark_object(eNestingError);
- 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"));
- rb_gc_register_mark_object(CNaN);
-
- CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- rb_gc_register_mark_object(CInfinity);
-
- CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
- rb_gc_register_mark_object(CMinusInfinity);
-
- 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");
- i_symbolize_names = rb_intern("symbolize_names");
- i_object_class = rb_intern("object_class");
- i_array_class = rb_intern("array_class");
- i_decimal_class = rb_intern("decimal_class");
- i_match = rb_intern("match");
- i_match_string = rb_intern("match_string");
- i_key_p = rb_intern("key?");
- i_deep_const_get = rb_intern("deep_const_get");
- i_aset = rb_intern("[]=");
- i_aref = rb_intern("[]");
- i_leftshift = rb_intern("<<");
- i_new = rb_intern("new");
- i_try_convert = rb_intern("try_convert");
- i_freeze = rb_intern("freeze");
- i_uminus = rb_intern("-@");
+ VALUE Vsource = convert_encoding(src);
+
+ // Ensure the string isn't mutated under us.
+ // The classic API to use is `rb_str_locktmp`, but then we'd
+ // need to use `rb_protect` to make sure we always unlock.
+ if (Vsource == src) {
+ Vsource = rb_str_new_frozen(Vsource);
+ }
+
+ VALUE rvalue_stack_buffer[RVALUE_STACK_INITIAL_CAPA];
+ rvalue_stack stack = {
+ .type = RVALUE_STACK_STACK_ALLOCATED,
+ .ptr = rvalue_stack_buffer,
+ .capa = RVALUE_STACK_INITIAL_CAPA,
+ };
+
+ long len;
+ const char *start;
+
+ RSTRING_GETMEM(Vsource, start, len);
+
+ VALUE stack_handle = 0;
+ JSON_ParserState _state = {
+ .start = start,
+ .cursor = start,
+ .end = start + len,
+ .stack = &stack,
+ .stack_handle = &stack_handle,
+ };
+ JSON_ParserState *state = &_state;
+
+ VALUE result = json_parse_any(state, config);
+
+ // This may be skipped in case of exception, but
+ // it won't cause a leak.
+ rvalue_stack_eagerly_release(stack_handle);
+ RB_GC_GUARD(stack_handle);
+ RB_GC_GUARD(Vsource);
+ json_ensure_eof(state);
+
+ return result;
}
/*
-* Local variables:
-* mode: c
-* c-file-style: ruby
-* indent-tabs-mode: nil
-* End:
-*/
+ * call-seq: parse(source)
+ *
+ * Parses the current JSON text _source_ and returns the complete data
+ * structure as a result.
+ * It raises JSON::ParserError if fail to parse.
+ */
+static VALUE cParserConfig_parse(VALUE self, VALUE Vsource)
+{
+ GET_PARSER_CONFIG;
+ return cParser_parse(config, Vsource);
+}
+
+static VALUE cParser_m_parse(VALUE klass, VALUE Vsource, VALUE opts)
+{
+ JSON_ParserConfig _config = {0};
+ JSON_ParserConfig *config = &_config;
+ parser_config_init(config, opts, false);
+
+ return cParser_parse(config, Vsource);
+}
+
+static void JSON_ParserConfig_mark(void *ptr)
+{
+ JSON_ParserConfig *config = ptr;
+ rb_gc_mark(config->on_load_proc);
+ rb_gc_mark(config->decimal_class);
+}
+
+static size_t JSON_ParserConfig_memsize(const void *ptr)
+{
+ return sizeof(JSON_ParserConfig);
+}
+
+static const rb_data_type_t JSON_ParserConfig_type = {
+ .wrap_struct_name = "JSON::Ext::Parser/ParserConfig",
+ .function = {
+ JSON_ParserConfig_mark,
+ RUBY_DEFAULT_FREE,
+ JSON_ParserConfig_memsize,
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE,
+};
+
+static VALUE cJSON_parser_s_allocate(VALUE klass)
+{
+ JSON_ParserConfig *config;
+ return TypedData_Make_Struct(klass, JSON_ParserConfig, &JSON_ParserConfig_type, config);
+}
+
+void Init_parser(void)
+{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
+#undef rb_intern
+ rb_require("json/common");
+ mJSON = rb_define_module("JSON");
+ VALUE mExt = rb_define_module_under(mJSON, "Ext");
+ VALUE cParserConfig = rb_define_class_under(mExt, "ParserConfig", rb_cObject);
+ eNestingError = rb_path2class("JSON::NestingError");
+ rb_gc_register_mark_object(eNestingError);
+ rb_define_alloc_func(cParserConfig, cJSON_parser_s_allocate);
+ rb_define_method(cParserConfig, "initialize", cParserConfig_initialize, 1);
+ rb_define_method(cParserConfig, "parse", cParserConfig_parse, 1);
+
+ VALUE cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
+ rb_define_singleton_method(cParser, "parse", cParser_m_parse, 2);
+
+ CNaN = rb_const_get(mJSON, rb_intern("NaN"));
+ rb_gc_register_mark_object(CNaN);
+
+ CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
+ rb_gc_register_mark_object(CInfinity);
+
+ CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
+ rb_gc_register_mark_object(CMinusInfinity);
+
+ rb_global_variable(&Encoding_UTF_8);
+ Encoding_UTF_8 = rb_const_get(rb_path2class("Encoding"), rb_intern("UTF_8"));
+
+ sym_max_nesting = ID2SYM(rb_intern("max_nesting"));
+ sym_allow_nan = ID2SYM(rb_intern("allow_nan"));
+ sym_allow_trailing_comma = ID2SYM(rb_intern("allow_trailing_comma"));
+ sym_allow_control_characters = ID2SYM(rb_intern("allow_control_characters"));
+ sym_allow_invalid_escape = ID2SYM(rb_intern("allow_invalid_escape"));
+ sym_symbolize_names = ID2SYM(rb_intern("symbolize_names"));
+ sym_freeze = ID2SYM(rb_intern("freeze"));
+ sym_on_load = ID2SYM(rb_intern("on_load"));
+ sym_decimal_class = ID2SYM(rb_intern("decimal_class"));
+ sym_allow_duplicate_key = ID2SYM(rb_intern("allow_duplicate_key"));
+
+ i_new = rb_intern("new");
+ i_try_convert = rb_intern("try_convert");
+ i_uminus = rb_intern("-@");
+ i_encode = rb_intern("encode");
+
+ binary_encindex = rb_ascii8bit_encindex();
+ utf8_encindex = rb_utf8_encindex();
+ enc_utf8 = rb_utf8_encoding();
+
+#ifdef HAVE_SIMD
+ simd_impl = find_simd_implementation();
+#endif
+}
diff --git a/ext/json/parser/parser.h b/ext/json/parser/parser.h
deleted file mode 100644
index 92ed3fdc5d..0000000000
--- a/ext/json/parser/parser.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef _PARSER_H_
-#define _PARSER_H_
-
-#include "ruby.h"
-
-#ifndef HAVE_RUBY_RE_H
-#include "re.h"
-#endif
-
-#ifdef HAVE_RUBY_ST_H
-#include "ruby/st.h"
-#else
-#include "st.h"
-#endif
-
-#ifndef MAYBE_UNUSED
-# define MAYBE_UNUSED(x) x
-#endif
-
-#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
-
-/* unicode */
-
-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_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
-
-typedef struct JSON_ParserStruct {
- VALUE Vsource;
- char *source;
- long len;
- char *memo;
- VALUE create_id;
- int max_nesting;
- int allow_nan;
- int parsing_name;
- int symbolize_names;
- int freeze;
- VALUE object_class;
- VALUE array_class;
- VALUE decimal_class;
- int create_additions;
- VALUE match_string;
- FBuffer *fbuffer;
-} JSON_Parser;
-
-#define GET_PARSER \
- GET_PARSER_INIT; \
- if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
-#define GET_PARSER_INIT \
- JSON_Parser *json; \
- TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json)
-
-#define MinusInfinity "-Infinity"
-#define EVIL 0x666
-
-static UTF32 unescape_unicode(const unsigned char *p);
-static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
-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);
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
-static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize);
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static VALUE convert_encoding(VALUE source);
-static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE cParser_parse(VALUE self);
-static void JSON_mark(void *json);
-static void JSON_free(void *json);
-static VALUE cJSON_parser_s_allocate(VALUE klass);
-static VALUE cParser_source(VALUE self);
-#ifndef ZALLOC
-#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
-static inline void *ruby_zalloc(size_t n)
-{
- void *p = ruby_xmalloc(n);
- memset(p, 0, n);
- return p;
-}
-#endif
-#ifdef TypedData_Make_Struct
-static const rb_data_type_t JSON_Parser_type;
-#define NEW_TYPEDDATA_WRAPPER 1
-#else
-#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, JSON_free, json)
-#define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json)
-#endif
-
-#endif
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
deleted file mode 100644
index 2dbdc7ef24..0000000000
--- a/ext/json/parser/parser.rl
+++ /dev/null
@@ -1,986 +0,0 @@
-#include "../fbuffer/fbuffer.h"
-#include "parser.h"
-
-#if defined HAVE_RUBY_ENCODING_H
-# define EXC_ENCODING rb_utf8_encoding(),
-# ifndef HAVE_RB_ENC_RAISE
-static void
-enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
-{
- va_list args;
- VALUE mesg;
-
- va_start(args, fmt);
- mesg = rb_enc_vsprintf(enc, fmt, args);
- va_end(args);
-
- rb_exc_raise(rb_exc_new3(exc, mesg));
-}
-# define rb_enc_raise enc_raise
-# endif
-#else
-# define EXC_ENCODING /* nothing */
-# define rb_enc_raise rb_raise
-#endif
-
-/* unicode */
-
-static const signed char digit_values[256] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -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, 2, 3, 4, 5, 6, 7, 8, 9, -1,
- -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -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 UTF32 unescape_unicode(const unsigned char *p)
-{
- signed char b;
- UTF32 result = 0;
- b = digit_values[p[0]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[1]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[2]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[3]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- return result;
-}
-
-static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
-{
- int len = 1;
- if (ch <= 0x7F) {
- buf[0] = (char) ch;
- } else if (ch <= 0x07FF) {
- buf[0] = (char) ((ch >> 6) | 0xC0);
- buf[1] = (char) ((ch & 0x3F) | 0x80);
- len++;
- } else if (ch <= 0xFFFF) {
- buf[0] = (char) ((ch >> 12) | 0xE0);
- buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
- buf[2] = (char) ((ch & 0x3F) | 0x80);
- len += 2;
- } else if (ch <= 0x1fffff) {
- buf[0] =(char) ((ch >> 18) | 0xF0);
- buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
- buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
- buf[3] =(char) ((ch & 0x3F) | 0x80);
- len += 3;
- } else {
- buf[0] = '?';
- }
- return len;
-}
-
-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, i_symbolize_names,
- i_object_class, i_array_class, i_decimal_class, i_key_p,
- i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
- i_leftshift, i_new, i_try_convert, i_freeze, i_uminus;
-
-%%{
- 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, current_nesting);
- if (np == NULL) {
- fhold; fbreak;
- } else {
- if (NIL_P(json->object_class)) {
- OBJ_FREEZE(last_name);
- rb_hash_aset(*result, last_name, v);
- } else {
- rb_funcall(*result, i_aset, 2, last_name, v);
- }
- fexec np;
- }
- }
-
- action parse_name {
- char *np;
- json->parsing_name = 1;
- np = JSON_parse_string(json, fpc, pe, &last_name);
- json->parsing_name = 0;
- if (np == NULL) { fhold; fbreak; } else fexec np;
- }
-
- action exit { fhold; fbreak; }
-
- pair = ignore* begin_name >parse_name ignore* name_separator ignore* begin_value >parse_value;
- next_pair = ignore* value_separator pair;
-
- main := (
- begin_object
- (pair (next_pair)*)? ignore*
- end_object
- ) @exit;
-}%%
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
-{
- int cs = EVIL;
- VALUE last_name = Qnil;
- VALUE object_class = json->object_class;
-
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
-
- *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
-
- %% write init;
- %% write exec;
-
- if (cs >= JSON_object_first_final) {
- if (json->create_additions) {
- VALUE klassname;
- if (NIL_P(json->object_class)) {
- klassname = rb_hash_aref(*result, json->create_id);
- } else {
- klassname = rb_funcall(*result, i_aref, 1, json->create_id);
- }
- if (!NIL_P(klassname)) {
- VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, 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_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
- }
- }
- action parse_infinity {
- if (json->allow_nan) {
- *result = CInfinity;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
- }
- }
- action parse_string {
- char *np = JSON_parse_string(json, fpc, pe, result);
- if (np == NULL) { fhold; fbreak; } else fexec np;
- }
-
- action parse_number {
- char *np;
- if(pe > fpc + 8 && !strncmp(MinusInfinity, fpc, 9)) {
- if (json->allow_nan) {
- *result = CMinusInfinity;
- fexec p + 10;
- fhold; fbreak;
- } else {
- rb_enc_raise(EXC_ENCODING 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;
- fhold; fbreak;
- }
-
- action parse_array {
- char *np;
- np = JSON_parse_array(json, fpc, pe, result, current_nesting + 1);
- if (np == NULL) { fhold; fbreak; } else fexec np;
- }
-
- action parse_object {
- char *np;
- np = JSON_parse_object(json, fpc, pe, result, current_nesting + 1);
- if (np == NULL) { fhold; fbreak; } else fexec np;
- }
-
- action exit { fhold; fbreak; }
-
-main := ignore* (
- 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
- ) ignore* %*exit;
-}%%
-
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
-{
- int cs = EVIL;
-
- %% write init;
- %% write exec;
-
- if (json->freeze) {
- OBJ_FREEZE(*result);
- }
-
- if (cs >= JSON_value_first_final) {
- return p;
- } else {
- return NULL;
- }
-}
-
-%%{
- machine JSON_integer;
-
- write data;
-
- action exit { fhold; 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;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
- *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-%%{
- machine JSON_float;
- include JSON_common;
-
- write data;
-
- action exit { fhold; 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) {
- VALUE mod = Qnil;
- ID method_id = 0;
- if (rb_respond_to(json->decimal_class, i_try_convert)) {
- mod = json->decimal_class;
- method_id = i_try_convert;
- } else if (rb_respond_to(json->decimal_class, i_new)) {
- mod = json->decimal_class;
- method_id = i_new;
- } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) {
- VALUE name = rb_class_name(json->decimal_class);
- const char *name_cstr = RSTRING_PTR(name);
- const char *last_colon = strrchr(name_cstr, ':');
- if (last_colon) {
- const char *mod_path_end = last_colon - 1;
- VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr);
- mod = rb_path_to_class(mod_path);
-
- const char *method_name_beg = last_colon + 1;
- long before_len = method_name_beg - name_cstr;
- long len = RSTRING_LEN(name) - before_len;
- VALUE method_name = rb_str_substr(name, before_len, len);
- method_id = SYM2ID(rb_str_intern(method_name));
- } else {
- mod = rb_mKernel;
- method_id = SYM2ID(rb_str_intern(name));
- }
- }
-
- long len = p - json->memo;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
-
- if (method_id) {
- VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
- *result = rb_funcallv(mod, method_id, 1, &text);
- } else {
- *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
- }
-
- 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, current_nesting);
- if (np == NULL) {
- fhold; fbreak;
- } else {
- if (NIL_P(json->array_class)) {
- rb_ary_push(*result, v);
- } else {
- rb_funcall(*result, i_leftshift, 1, v);
- }
- fexec np;
- }
- }
-
- action exit { fhold; 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 current_nesting)
-{
- int cs = EVIL;
- VALUE array_class = json->array_class;
-
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
- *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
-
- %% write init;
- %% write exec;
-
- if(cs >= JSON_array_first_final) {
- return p + 1;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return NULL;
- }
-}
-
-static const size_t MAX_STACK_BUFFER_SIZE = 128;
-static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize)
-{
- VALUE result = Qnil;
- size_t bufferSize = stringEnd - string;
- char *p = string, *pe = string, *unescape, *bufferStart, *buffer;
- int unescape_len;
- char buf[4];
-
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
-# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1);
-# else
- bufferStart = buffer = ALLOC_N(char, bufferSize);
-# endif
- } else {
-# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1);
-# else
- bufferStart = buffer = ALLOCA_N(char, bufferSize);
-# endif
- }
-
- while (pe < stringEnd) {
- if (*pe == '\\') {
- unescape = (char *) "?";
- unescape_len = 1;
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
- switch (*++pe) {
- case 'n':
- unescape = (char *) "\n";
- break;
- case 'r':
- unescape = (char *) "\r";
- break;
- case 't':
- unescape = (char *) "\t";
- break;
- case '"':
- unescape = (char *) "\"";
- break;
- case '\\':
- unescape = (char *) "\\";
- break;
- case 'b':
- unescape = (char *) "\b";
- break;
- case 'f':
- unescape = (char *) "\f";
- break;
- case 'u':
- if (pe > stringEnd - 4) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete unicode character escape sequence at '%s'", p
- );
- } else {
- UTF32 ch = unescape_unicode((unsigned char *) ++pe);
- pe += 3;
- if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
- pe++;
- if (pe > stringEnd - 6) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete surrogate pair at '%s'", p
- );
- }
- if (pe[0] == '\\' && pe[1] == 'u') {
- UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
- ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
- | (sur & 0x3FF));
- pe += 5;
- } else {
- unescape = (char *) "?";
- break;
- }
- }
- unescape_len = convert_UTF32_to_UTF8(buf, ch);
- unescape = buf;
- }
- break;
- default:
- p = pe;
- continue;
- }
- MEMCPY(buffer, unescape, char, unescape_len);
- buffer += unescape_len;
- p = ++pe;
- } else {
- pe++;
- }
- }
-
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
-
-# ifdef HAVE_RB_ENC_INTERNED_STR
- if (intern) {
- result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding());
- } else {
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
- }
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
-# else
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
-
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
-
- if (intern) {
- # if STR_UMINUS_DEDUPE_FROZEN
- // Starting from MRI 2.8 it is preferable to freeze the string
- // before deduplication so that it can be interned directly
- // otherwise it would be duplicated first which is wasteful.
- result = rb_funcall(rb_str_freeze(result), i_uminus, 0);
- # elif STR_UMINUS_DEDUPE
- // MRI 2.5 and older do not deduplicate strings that are already
- // frozen.
- result = rb_funcall(result, i_uminus, 0);
- # else
- result = rb_str_freeze(result);
- # endif
- }
-# endif
-
- if (symbolize) {
- result = rb_str_intern(result);
- }
-
- return result;
-}
-
-%%{
- machine JSON_string;
- include JSON_common;
-
- write data;
-
- action parse_string {
- *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
- if (NIL_P(*result)) {
- fhold;
- fbreak;
- } else {
- fexec p + 1;
- }
- }
-
- action exit { fhold; fbreak; }
-
- main := '"' ((^([\"\\] | 0..0x1f) | '\\'[\"\\/bfnrt] | '\\u'[0-9a-fA-F]{4} | '\\'^([\"\\/bfnrtu]|0..0x1f))* %parse_string) '"' @exit;
-}%%
-
-static int
-match_i(VALUE regexp, VALUE klass, VALUE memo)
-{
- if (regexp == Qundef) return ST_STOP;
- if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
- RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
- rb_ary_push(memo, klass);
- return ST_STOP;
- }
- return ST_CONTINUE;
-}
-
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
- VALUE match_string;
-
- %% write init;
- json->memo = p;
- %% write exec;
-
- if (json->create_additions && RTEST(match_string = json->match_string)) {
- VALUE klass;
- VALUE memo = rb_ary_new2(2);
- rb_ary_push(memo, *result);
- rb_hash_foreach(match_string, match_i, memo);
- klass = rb_ary_entry(memo, 1);
- if (RTEST(klass)) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
-
- if (cs >= JSON_string_first_final) {
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-/*
- * 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.
- *
- */
-
-static VALUE convert_encoding(VALUE source)
-{
-#ifdef HAVE_RUBY_ENCODING_H
- rb_encoding *enc = rb_enc_get(source);
- if (enc == rb_ascii8bit_encoding()) {
- if (OBJ_FROZEN(source)) {
- source = rb_str_dup(source);
- }
- FORCE_UTF8(source);
- } else {
- source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
- }
-#endif
- return source;
-}
-
-/*
- * 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 100.
- * * *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.
- * * *symbolize_names*: If set to true, returns symbols for the names
- * (keys) in a JSON object. Otherwise strings are returned, which is
- * also the default. It's not possible to use this option in
- * conjunction with the *create_additions* option.
- * * *create_additions*: If set to false, the Parser doesn't create
- * additions even if a matching class and create_id was found. This option
- * defaults to false.
- * * *object_class*: Defaults to Hash
- * * *array_class*: Defaults to Array
- */
-static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE source, opts;
- GET_PARSER_INIT;
-
- if (json->Vsource) {
- rb_raise(rb_eTypeError, "already initialized instance");
- }
-#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- rb_scan_args(argc, argv, "1:", &source, &opts);
-#else
- rb_scan_args(argc, argv, "11", &source, &opts);
-#endif
- if (!NIL_P(opts)) {
-#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- 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 {
-#endif
- VALUE tmp = ID2SYM(i_max_nesting);
- if (option_given_p(opts, tmp)) {
- 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 = 100;
- }
- tmp = ID2SYM(i_allow_nan);
- if (option_given_p(opts, tmp)) {
- json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_symbolize_names);
- if (option_given_p(opts, tmp)) {
- json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->symbolize_names = 0;
- }
- tmp = ID2SYM(i_freeze);
- if (option_given_p(opts, tmp)) {
- json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->freeze = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (option_given_p(opts, tmp)) {
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
- } else {
- json->create_additions = 0;
- }
- if (json->symbolize_names && json->create_additions) {
- rb_raise(rb_eArgError,
- "options :symbolize_names and :create_additions cannot be "
- " used in conjunction");
- }
- tmp = ID2SYM(i_create_id);
- if (option_given_p(opts, tmp)) {
- json->create_id = rb_hash_aref(opts, tmp);
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- tmp = ID2SYM(i_object_class);
- if (option_given_p(opts, tmp)) {
- json->object_class = rb_hash_aref(opts, tmp);
- } else {
- json->object_class = Qnil;
- }
- tmp = ID2SYM(i_array_class);
- if (option_given_p(opts, tmp)) {
- json->array_class = rb_hash_aref(opts, tmp);
- } else {
- json->array_class = Qnil;
- }
- tmp = ID2SYM(i_decimal_class);
- if (option_given_p(opts, tmp)) {
- json->decimal_class = rb_hash_aref(opts, tmp);
- } else {
- json->decimal_class = Qnil;
- }
- tmp = ID2SYM(i_match_string);
- if (option_given_p(opts, tmp)) {
- VALUE match_string = rb_hash_aref(opts, tmp);
- json->match_string = RTEST(match_string) ? match_string : Qnil;
- } else {
- json->match_string = Qnil;
- }
-#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- }
-#endif
- } else {
- json->max_nesting = 100;
- json->allow_nan = 0;
- json->create_additions = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- json->object_class = Qnil;
- json->array_class = Qnil;
- json->decimal_class = Qnil;
- }
- source = convert_encoding(StringValue(source));
- StringValue(source);
- json->len = RSTRING_LEN(source);
- json->source = RSTRING_PTR(source);;
- json->Vsource = source;
- return self;
-}
-
-%%{
- machine JSON;
-
- write data;
-
- include JSON_common;
-
- action parse_value {
- char *np = JSON_parse_value(json, fpc, pe, &result, 0);
- if (np == NULL) { fhold; fbreak; } else fexec np;
- }
-
- main := ignore* (
- begin_value >parse_value
- ) ignore*;
-}%%
-
-/*
- * call-seq: parse()
- *
- * Parses the current JSON text _source_ and returns the complete data
- * structure as a result.
- * It raises JSON::ParseError if fail to parse.
- */
-static VALUE cParser_parse(VALUE self)
-{
- char *p, *pe;
- int cs = EVIL;
- VALUE result = Qnil;
- GET_PARSER;
-
- %% write init;
- p = json->source;
- pe = p + json->len;
- %% write exec;
-
- if (cs >= JSON_first_final && p == pe) {
- return result;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return Qnil;
- }
-}
-
-static void JSON_mark(void *ptr)
-{
- JSON_Parser *json = ptr;
- rb_gc_mark_maybe(json->Vsource);
- rb_gc_mark_maybe(json->create_id);
- rb_gc_mark_maybe(json->object_class);
- rb_gc_mark_maybe(json->array_class);
- rb_gc_mark_maybe(json->decimal_class);
- rb_gc_mark_maybe(json->match_string);
-}
-
-static void JSON_free(void *ptr)
-{
- JSON_Parser *json = ptr;
- fbuffer_free(json->fbuffer);
- ruby_xfree(json);
-}
-
-static size_t JSON_memsize(const void *ptr)
-{
- const JSON_Parser *json = ptr;
- return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
-}
-
-#ifdef NEW_TYPEDDATA_WRAPPER
-static const rb_data_type_t JSON_Parser_type = {
- "JSON/Parser",
- {JSON_mark, JSON_free, JSON_memsize,},
-#ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
-#endif
-};
-#endif
-
-static VALUE cJSON_parser_s_allocate(VALUE klass)
-{
- JSON_Parser *json;
- VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json);
- json->fbuffer = fbuffer_alloc(0);
- return obj;
-}
-
-/*
- * 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_PARSER;
- return rb_str_dup(json->Vsource);
-}
-
-void Init_parser(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
-
-#undef rb_intern
- rb_require("json/common");
- 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_gc_register_mark_object(eParserError);
- rb_gc_register_mark_object(eNestingError);
- 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"));
- rb_gc_register_mark_object(CNaN);
-
- CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- rb_gc_register_mark_object(CInfinity);
-
- CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
- rb_gc_register_mark_object(CMinusInfinity);
-
- 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");
- i_symbolize_names = rb_intern("symbolize_names");
- i_object_class = rb_intern("object_class");
- i_array_class = rb_intern("array_class");
- i_decimal_class = rb_intern("decimal_class");
- i_match = rb_intern("match");
- i_match_string = rb_intern("match_string");
- i_key_p = rb_intern("key?");
- i_deep_const_get = rb_intern("deep_const_get");
- i_aset = rb_intern("[]=");
- i_aref = rb_intern("[]");
- i_leftshift = rb_intern("<<");
- i_new = rb_intern("new");
- i_try_convert = rb_intern("try_convert");
- i_freeze = rb_intern("freeze");
- i_uminus = rb_intern("-@");
-}
-
-/*
- * Local variables:
- * mode: c
- * c-file-style: ruby
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/ext/json/parser/prereq.mk b/ext/json/parser/prereq.mk
deleted file mode 100644
index fc59169056..0000000000
--- a/ext/json/parser/prereq.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-RAGEL = ragel
-
-.SUFFIXES: .rl
-
-.rl.c:
- $(RAGEL) -G2 $<
- $(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \
- -e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' \
- -e '$$_.sub!(/^(static const char) (_JSON(?:_\w+)?_nfa_\w+)(?=\[\] =)/, "\\1 MAYBE_UNUSED(\\2)")' \
- -e '$$_.sub!(/0 <= ([\( ]+\*[\( ]*p\)+) && \1 <= 31/, "0 <= (signed char)(*(p)) && (*(p)) <= 31")' \
- -e '$$_ = "/* This file is automatically generated from parser.rl by using ragel */\n" + $$_ if $$. == 1' $@
-
-parser.c:
diff --git a/ext/json/simd/conf.rb b/ext/json/simd/conf.rb
new file mode 100644
index 0000000000..76f774bc97
--- /dev/null
+++ b/ext/json/simd/conf.rb
@@ -0,0 +1,24 @@
+case RbConfig::CONFIG['host_cpu']
+when /^(arm|aarch64)/
+ # Try to compile a small program using NEON instructions
+ header, type, init, extra = 'arm_neon.h', 'uint8x16_t', 'vdupq_n_u8(32)', nil
+when /^(x86_64|x64)/
+ header, type, init, extra = 'x86intrin.h', '__m128i', '_mm_set1_epi8(32)', 'if (__builtin_cpu_supports("sse2")) { printf("OK"); }'
+end
+if header
+ if have_header(header) && try_compile(<<~SRC, '-Werror=implicit-function-declaration')
+ #{cpp_include(header)}
+ int main(int argc, char **argv) {
+ #{type} test = #{init};
+ #{extra}
+ if (argc > 100000) printf("%p", &test);
+ return 0;
+ }
+ SRC
+ $defs.push("-DJSON_ENABLE_SIMD")
+ else
+ puts "Disable SIMD"
+ end
+end
+
+have_header('cpuid.h')
diff --git a/ext/json/simd/simd.h b/ext/json/simd/simd.h
new file mode 100644
index 0000000000..611b41b066
--- /dev/null
+++ b/ext/json/simd/simd.h
@@ -0,0 +1,208 @@
+#include "../json.h"
+
+typedef enum {
+ SIMD_NONE,
+ SIMD_NEON,
+ SIMD_SSE2
+} SIMD_Implementation;
+
+#ifndef __has_builtin // Optional of course.
+ #define __has_builtin(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+#ifdef __clang__
+# if __has_builtin(__builtin_ctzll)
+# define HAVE_BUILTIN_CTZLL 1
+# else
+# define HAVE_BUILTIN_CTZLL 0
+# endif
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define HAVE_BUILTIN_CTZLL 1
+#else
+# define HAVE_BUILTIN_CTZLL 0
+#endif
+
+static inline uint32_t trailing_zeros64(uint64_t input)
+{
+ JSON_ASSERT(input > 0); // __builtin_ctz(0) is undefined behavior
+
+#if HAVE_BUILTIN_CTZLL
+ return __builtin_ctzll(input);
+#else
+ uint32_t trailing_zeros = 0;
+ uint64_t temp = input;
+ while ((temp & 1) == 0 && temp > 0) {
+ trailing_zeros++;
+ temp >>= 1;
+ }
+ return trailing_zeros;
+#endif
+}
+
+static inline int trailing_zeros(int input)
+{
+ JSON_ASSERT(input > 0); // __builtin_ctz(0) is undefined behavior
+
+#if HAVE_BUILTIN_CTZLL
+ return __builtin_ctz(input);
+#else
+ int trailing_zeros = 0;
+ int temp = input;
+ while ((temp & 1) == 0 && temp > 0) {
+ trailing_zeros++;
+ temp >>= 1;
+ }
+ return trailing_zeros;
+#endif
+}
+
+#ifdef JSON_ENABLE_SIMD
+
+#define SIMD_MINIMUM_THRESHOLD 4
+
+ALWAYS_INLINE(static) void json_fast_memcpy16(char *dst, const char *src, size_t len)
+{
+ RBIMPL_ASSERT_OR_ASSUME(len < 16);
+ RBIMPL_ASSERT_OR_ASSUME(len >= SIMD_MINIMUM_THRESHOLD); // 4
+#if defined(__has_builtin) && __has_builtin(__builtin_memcpy)
+ // If __builtin_memcpy is available, use it to copy between SIMD_MINIMUM_THRESHOLD (4) and vec_len-1 (15) bytes.
+ // These copies overlap. The first copy will copy the first 8 (or 4) bytes. The second copy will copy
+ // the last 8 (or 4) bytes but overlap with the first copy. The overlapping bytes will be in the correct
+ // position in both copies.
+
+ // Please do not attempt to replace __builtin_memcpy with memcpy without profiling and/or looking at the
+ // generated assembly. On clang-specifically (tested on Apple clang version 17.0.0 (clang-1700.0.13.3)),
+ // when using memcpy, the compiler will notice the only difference is a 4 or 8 and generate a conditional
+ // select instruction instead of direct loads and stores with a branch. This ends up slower than the branch
+ // plus two loads and stores generated when using __builtin_memcpy.
+ if (len >= 8) {
+ __builtin_memcpy(dst, src, 8);
+ __builtin_memcpy(dst + len - 8, src + len - 8, 8);
+ } else {
+ __builtin_memcpy(dst, src, 4);
+ __builtin_memcpy(dst + len - 4, src + len - 4, 4);
+ }
+#else
+ MEMCPY(dst, src, char, len);
+#endif
+}
+
+#if defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__aarch64__) || defined(_M_ARM64)
+#include <arm_neon.h>
+
+#define FIND_SIMD_IMPLEMENTATION_DEFINED 1
+static inline SIMD_Implementation find_simd_implementation(void)
+{
+ return SIMD_NEON;
+}
+
+#define HAVE_SIMD 1
+#define HAVE_SIMD_NEON 1
+
+// See: https://community.arm.com/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/porting-x86-vector-bitmask-optimizations-to-arm-neon
+ALWAYS_INLINE(static) uint64_t neon_match_mask(uint8x16_t matches)
+{
+ const uint8x8_t res = vshrn_n_u16(vreinterpretq_u16_u8(matches), 4);
+ const uint64_t mask = vget_lane_u64(vreinterpret_u64_u8(res), 0);
+ return mask & 0x8888888888888888ull;
+}
+
+ALWAYS_INLINE(static) uint64_t compute_chunk_mask_neon(const char *ptr)
+{
+ uint8x16_t chunk = vld1q_u8((const unsigned char *)ptr);
+
+ // Trick: c < 32 || c == 34 can be factored as c ^ 2 < 33
+ // https://lemire.me/blog/2025/04/13/detect-control-characters-quotes-and-backslashes-efficiently-using-swar/
+ const uint8x16_t too_low_or_dbl_quote = vcltq_u8(veorq_u8(chunk, vdupq_n_u8(2)), vdupq_n_u8(33));
+
+ uint8x16_t has_backslash = vceqq_u8(chunk, vdupq_n_u8('\\'));
+ uint8x16_t needs_escape = vorrq_u8(too_low_or_dbl_quote, has_backslash);
+ return neon_match_mask(needs_escape);
+}
+
+ALWAYS_INLINE(static) int string_scan_simd_neon(const char **ptr, const char *end, uint64_t *mask)
+{
+ while (*ptr + sizeof(uint8x16_t) <= end) {
+ uint64_t chunk_mask = compute_chunk_mask_neon(*ptr);
+ if (chunk_mask) {
+ *mask = chunk_mask;
+ return 1;
+ }
+ *ptr += sizeof(uint8x16_t);
+ }
+ return 0;
+}
+
+#endif /* ARM Neon Support.*/
+
+#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
+
+#ifdef HAVE_X86INTRIN_H
+#include <x86intrin.h>
+
+#define HAVE_SIMD 1
+#define HAVE_SIMD_SSE2 1
+
+#ifdef HAVE_CPUID_H
+#define FIND_SIMD_IMPLEMENTATION_DEFINED 1
+
+#if defined(__clang__) || defined(__GNUC__)
+#define TARGET_SSE2 __attribute__((target("sse2")))
+#else
+#define TARGET_SSE2
+#endif
+
+#define _mm_cmpge_epu8(a, b) _mm_cmpeq_epi8(_mm_max_epu8(a, b), a)
+#define _mm_cmple_epu8(a, b) _mm_cmpge_epu8(b, a)
+#define _mm_cmpgt_epu8(a, b) _mm_xor_si128(_mm_cmple_epu8(a, b), _mm_set1_epi8(-1))
+#define _mm_cmplt_epu8(a, b) _mm_cmpgt_epu8(b, a)
+
+ALWAYS_INLINE(static) TARGET_SSE2 int compute_chunk_mask_sse2(const char *ptr)
+{
+ __m128i chunk = _mm_loadu_si128((__m128i const*)ptr);
+ // Trick: c < 32 || c == 34 can be factored as c ^ 2 < 33
+ // https://lemire.me/blog/2025/04/13/detect-control-characters-quotes-and-backslashes-efficiently-using-swar/
+ __m128i too_low_or_dbl_quote = _mm_cmplt_epu8(_mm_xor_si128(chunk, _mm_set1_epi8(2)), _mm_set1_epi8(33));
+ __m128i has_backslash = _mm_cmpeq_epi8(chunk, _mm_set1_epi8('\\'));
+ __m128i needs_escape = _mm_or_si128(too_low_or_dbl_quote, has_backslash);
+ return _mm_movemask_epi8(needs_escape);
+}
+
+ALWAYS_INLINE(static) TARGET_SSE2 int string_scan_simd_sse2(const char **ptr, const char *end, int *mask)
+{
+ while (*ptr + sizeof(__m128i) <= end) {
+ int chunk_mask = compute_chunk_mask_sse2(*ptr);
+ if (chunk_mask) {
+ *mask = chunk_mask;
+ return 1;
+ }
+ *ptr += sizeof(__m128i);
+ }
+
+ return 0;
+}
+
+#include <cpuid.h>
+#endif /* HAVE_CPUID_H */
+
+static inline SIMD_Implementation find_simd_implementation(void)
+{
+ // TODO Revisit. I think the SSE version now only uses SSE2 instructions.
+ if (__builtin_cpu_supports("sse2")) {
+ return SIMD_SSE2;
+ }
+
+ return SIMD_NONE;
+}
+
+#endif /* HAVE_X86INTRIN_H */
+#endif /* X86_64 Support */
+
+#endif /* JSON_ENABLE_SIMD */
+
+#ifndef FIND_SIMD_IMPLEMENTATION_DEFINED
+static inline SIMD_Implementation find_simd_implementation(void)
+{
+ return SIMD_NONE;
+}
+#endif
diff --git a/ext/json/vendor/fpconv.c b/ext/json/vendor/fpconv.c
new file mode 100644
index 0000000000..6c9bc2c103
--- /dev/null
+++ b/ext/json/vendor/fpconv.c
@@ -0,0 +1,480 @@
+// Boost Software License - Version 1.0 - August 17th, 2003
+//
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+//
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+//
+// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+// The contents of this file is extracted from https://github.com/night-shift/fpconv
+// It was slightly modified to append ".0" to plain floats, for use with the https://github.com/ruby/json package.
+
+#include <stdbool.h>
+#include <string.h>
+#include <stdint.h>
+
+#if JSON_DEBUG
+#include <assert.h>
+#endif
+
+#define npowers 87
+#define steppowers 8
+#define firstpower -348 /* 10 ^ -348 */
+
+#define expmax -32
+#define expmin -60
+
+typedef struct Fp {
+ uint64_t frac;
+ int exp;
+} Fp;
+
+static const Fp powers_ten[] = {
+ { 18054884314459144840U, -1220 }, { 13451937075301367670U, -1193 },
+ { 10022474136428063862U, -1166 }, { 14934650266808366570U, -1140 },
+ { 11127181549972568877U, -1113 }, { 16580792590934885855U, -1087 },
+ { 12353653155963782858U, -1060 }, { 18408377700990114895U, -1034 },
+ { 13715310171984221708U, -1007 }, { 10218702384817765436U, -980 },
+ { 15227053142812498563U, -954 }, { 11345038669416679861U, -927 },
+ { 16905424996341287883U, -901 }, { 12595523146049147757U, -874 },
+ { 9384396036005875287U, -847 }, { 13983839803942852151U, -821 },
+ { 10418772551374772303U, -794 }, { 15525180923007089351U, -768 },
+ { 11567161174868858868U, -741 }, { 17236413322193710309U, -715 },
+ { 12842128665889583758U, -688 }, { 9568131466127621947U, -661 },
+ { 14257626930069360058U, -635 }, { 10622759856335341974U, -608 },
+ { 15829145694278690180U, -582 }, { 11793632577567316726U, -555 },
+ { 17573882009934360870U, -529 }, { 13093562431584567480U, -502 },
+ { 9755464219737475723U, -475 }, { 14536774485912137811U, -449 },
+ { 10830740992659433045U, -422 }, { 16139061738043178685U, -396 },
+ { 12024538023802026127U, -369 }, { 17917957937422433684U, -343 },
+ { 13349918974505688015U, -316 }, { 9946464728195732843U, -289 },
+ { 14821387422376473014U, -263 }, { 11042794154864902060U, -236 },
+ { 16455045573212060422U, -210 }, { 12259964326927110867U, -183 },
+ { 18268770466636286478U, -157 }, { 13611294676837538539U, -130 },
+ { 10141204801825835212U, -103 }, { 15111572745182864684U, -77 },
+ { 11258999068426240000U, -50 }, { 16777216000000000000U, -24 },
+ { 12500000000000000000U, 3 }, { 9313225746154785156U, 30 },
+ { 13877787807814456755U, 56 }, { 10339757656912845936U, 83 },
+ { 15407439555097886824U, 109 }, { 11479437019748901445U, 136 },
+ { 17105694144590052135U, 162 }, { 12744735289059618216U, 189 },
+ { 9495567745759798747U, 216 }, { 14149498560666738074U, 242 },
+ { 10542197943230523224U, 269 }, { 15709099088952724970U, 295 },
+ { 11704190886730495818U, 322 }, { 17440603504673385349U, 348 },
+ { 12994262207056124023U, 375 }, { 9681479787123295682U, 402 },
+ { 14426529090290212157U, 428 }, { 10748601772107342003U, 455 },
+ { 16016664761464807395U, 481 }, { 11933345169920330789U, 508 },
+ { 17782069995880619868U, 534 }, { 13248674568444952270U, 561 },
+ { 9871031767461413346U, 588 }, { 14708983551653345445U, 614 },
+ { 10959046745042015199U, 641 }, { 16330252207878254650U, 667 },
+ { 12166986024289022870U, 694 }, { 18130221999122236476U, 720 },
+ { 13508068024458167312U, 747 }, { 10064294952495520794U, 774 },
+ { 14996968138956309548U, 800 }, { 11173611982879273257U, 827 },
+ { 16649979327439178909U, 853 }, { 12405201291620119593U, 880 },
+ { 9242595204427927429U, 907 }, { 13772540099066387757U, 933 },
+ { 10261342003245940623U, 960 }, { 15290591125556738113U, 986 },
+ { 11392378155556871081U, 1013 }, { 16975966327722178521U, 1039 },
+ { 12648080533535911531U, 1066 }
+};
+
+static Fp find_cachedpow10(int exp, int* k)
+{
+ const double one_log_ten = 0.30102999566398114;
+
+ int approx = (int)(-(exp + npowers) * one_log_ten);
+ int idx = (approx - firstpower) / steppowers;
+
+ while(1) {
+ int current = exp + powers_ten[idx].exp + 64;
+
+ if(current < expmin) {
+ idx++;
+ continue;
+ }
+
+ if(current > expmax) {
+ idx--;
+ continue;
+ }
+
+ *k = (firstpower + idx * steppowers);
+
+ return powers_ten[idx];
+ }
+}
+
+#define fracmask 0x000FFFFFFFFFFFFFU
+#define expmask 0x7FF0000000000000U
+#define hiddenbit 0x0010000000000000U
+#define signmask 0x8000000000000000U
+#define expbias (1023 + 52)
+
+#define absv(n) ((n) < 0 ? -(n) : (n))
+#define minv(a, b) ((a) < (b) ? (a) : (b))
+
+static const uint64_t tens[] = {
+ 10000000000000000000U, 1000000000000000000U, 100000000000000000U,
+ 10000000000000000U, 1000000000000000U, 100000000000000U,
+ 10000000000000U, 1000000000000U, 100000000000U,
+ 10000000000U, 1000000000U, 100000000U,
+ 10000000U, 1000000U, 100000U,
+ 10000U, 1000U, 100U,
+ 10U, 1U
+};
+
+static inline uint64_t get_dbits(double d)
+{
+ union {
+ double dbl;
+ uint64_t i;
+ } dbl_bits = { d };
+
+ return dbl_bits.i;
+}
+
+static Fp build_fp(double d)
+{
+ uint64_t bits = get_dbits(d);
+
+ Fp fp;
+ fp.frac = bits & fracmask;
+ fp.exp = (bits & expmask) >> 52;
+
+ if(fp.exp) {
+ fp.frac += hiddenbit;
+ fp.exp -= expbias;
+
+ } else {
+ fp.exp = -expbias + 1;
+ }
+
+ return fp;
+}
+
+static void normalize(Fp* fp)
+{
+ while ((fp->frac & hiddenbit) == 0) {
+ fp->frac <<= 1;
+ fp->exp--;
+ }
+
+ int shift = 64 - 52 - 1;
+ fp->frac <<= shift;
+ fp->exp -= shift;
+}
+
+static void get_normalized_boundaries(Fp* fp, Fp* lower, Fp* upper)
+{
+ upper->frac = (fp->frac << 1) + 1;
+ upper->exp = fp->exp - 1;
+
+ while ((upper->frac & (hiddenbit << 1)) == 0) {
+ upper->frac <<= 1;
+ upper->exp--;
+ }
+
+ int u_shift = 64 - 52 - 2;
+
+ upper->frac <<= u_shift;
+ upper->exp = upper->exp - u_shift;
+
+
+ int l_shift = fp->frac == hiddenbit ? 2 : 1;
+
+ lower->frac = (fp->frac << l_shift) - 1;
+ lower->exp = fp->exp - l_shift;
+
+
+ lower->frac <<= lower->exp - upper->exp;
+ lower->exp = upper->exp;
+}
+
+static Fp multiply(Fp* a, Fp* b)
+{
+ const uint64_t lomask = 0x00000000FFFFFFFF;
+
+ uint64_t ah_bl = (a->frac >> 32) * (b->frac & lomask);
+ uint64_t al_bh = (a->frac & lomask) * (b->frac >> 32);
+ uint64_t al_bl = (a->frac & lomask) * (b->frac & lomask);
+ uint64_t ah_bh = (a->frac >> 32) * (b->frac >> 32);
+
+ uint64_t tmp = (ah_bl & lomask) + (al_bh & lomask) + (al_bl >> 32);
+ /* round up */
+ tmp += 1U << 31;
+
+ Fp fp = {
+ ah_bh + (ah_bl >> 32) + (al_bh >> 32) + (tmp >> 32),
+ a->exp + b->exp + 64
+ };
+
+ return fp;
+}
+
+static void round_digit(char* digits, int ndigits, uint64_t delta, uint64_t rem, uint64_t kappa, uint64_t frac)
+{
+ while (rem < frac && delta - rem >= kappa &&
+ (rem + kappa < frac || frac - rem > rem + kappa - frac)) {
+
+ digits[ndigits - 1]--;
+ rem += kappa;
+ }
+}
+
+static int generate_digits(Fp* fp, Fp* upper, Fp* lower, char* digits, int* K)
+{
+ uint64_t wfrac = upper->frac - fp->frac;
+ uint64_t delta = upper->frac - lower->frac;
+
+ Fp one;
+ one.frac = 1ULL << -upper->exp;
+ one.exp = upper->exp;
+
+ uint64_t part1 = upper->frac >> -one.exp;
+ uint64_t part2 = upper->frac & (one.frac - 1);
+
+ int idx = 0, kappa = 10;
+ const uint64_t* divp;
+ /* 1000000000 */
+ for(divp = tens + 10; kappa > 0; divp++) {
+
+ uint64_t div = *divp;
+ unsigned digit = (unsigned) (part1 / div);
+
+ if (digit || idx) {
+ digits[idx++] = digit + '0';
+ }
+
+ part1 -= digit * div;
+ kappa--;
+
+ uint64_t tmp = (part1 <<-one.exp) + part2;
+ if (tmp <= delta) {
+ *K += kappa;
+ round_digit(digits, idx, delta, tmp, div << -one.exp, wfrac);
+
+ return idx;
+ }
+ }
+
+ /* 10 */
+ const uint64_t* unit = tens + 18;
+
+ while(true) {
+ part2 *= 10;
+ delta *= 10;
+ kappa--;
+
+ unsigned digit = (unsigned) (part2 >> -one.exp);
+ if (digit || idx) {
+ digits[idx++] = digit + '0';
+ }
+
+ part2 &= one.frac - 1;
+ if (part2 < delta) {
+ *K += kappa;
+ round_digit(digits, idx, delta, part2, one.frac, wfrac * *unit);
+
+ return idx;
+ }
+
+ unit--;
+ }
+}
+
+static int grisu2(double d, char* digits, int* K)
+{
+ Fp w = build_fp(d);
+
+ Fp lower, upper;
+ get_normalized_boundaries(&w, &lower, &upper);
+
+ normalize(&w);
+
+ int k;
+ Fp cp = find_cachedpow10(upper.exp, &k);
+
+ w = multiply(&w, &cp);
+ upper = multiply(&upper, &cp);
+ lower = multiply(&lower, &cp);
+
+ lower.frac++;
+ upper.frac--;
+
+ *K = -k;
+
+ return generate_digits(&w, &upper, &lower, digits, K);
+}
+
+static int emit_digits(char* digits, int ndigits, char* dest, int K, bool neg)
+{
+ int exp = absv(K + ndigits - 1);
+
+ if(K >= 0 && exp < 15) {
+ memcpy(dest, digits, ndigits);
+ memset(dest + ndigits, '0', K);
+
+ /* add a .0 to mark this as a float. */
+ dest[ndigits + K] = '.';
+ dest[ndigits + K + 1] = '0';
+
+ return ndigits + K + 2;
+ }
+
+ /* write decimal w/o scientific notation */
+ if(K < 0 && (K > -7 || exp < 10)) {
+ int offset = ndigits - absv(K);
+ /* fp < 1.0 -> write leading zero */
+ if(offset <= 0) {
+ offset = -offset;
+ dest[0] = '0';
+ dest[1] = '.';
+ memset(dest + 2, '0', offset);
+ memcpy(dest + offset + 2, digits, ndigits);
+
+ return ndigits + 2 + offset;
+
+ /* fp > 1.0 */
+ } else {
+ memcpy(dest, digits, offset);
+ dest[offset] = '.';
+ memcpy(dest + offset + 1, digits + offset, ndigits - offset);
+
+ return ndigits + 1;
+ }
+ }
+
+ /* write decimal w/ scientific notation */
+ ndigits = minv(ndigits, 18 - neg);
+
+ int idx = 0;
+ dest[idx++] = digits[0];
+
+ if(ndigits > 1) {
+ dest[idx++] = '.';
+ memcpy(dest + idx, digits + 1, ndigits - 1);
+ idx += ndigits - 1;
+ }
+
+ dest[idx++] = 'e';
+
+ char sign = K + ndigits - 1 < 0 ? '-' : '+';
+ dest[idx++] = sign;
+
+ int cent = 0;
+
+ if(exp > 99) {
+ cent = exp / 100;
+ dest[idx++] = cent + '0';
+ exp -= cent * 100;
+ }
+ if(exp > 9) {
+ int dec = exp / 10;
+ dest[idx++] = dec + '0';
+ exp -= dec * 10;
+
+ } else if(cent) {
+ dest[idx++] = '0';
+ }
+
+ dest[idx++] = exp % 10 + '0';
+
+ return idx;
+}
+
+static int filter_special(double fp, char* dest)
+{
+ if(fp == 0.0) {
+ dest[0] = '0';
+ dest[1] = '.';
+ dest[2] = '0';
+ return 3;
+ }
+
+ uint64_t bits = get_dbits(fp);
+
+ bool nan = (bits & expmask) == expmask;
+
+ if(!nan) {
+ return 0;
+ }
+
+ if(bits & fracmask) {
+ dest[0] = 'n'; dest[1] = 'a'; dest[2] = 'n';
+
+ } else {
+ dest[0] = 'i'; dest[1] = 'n'; dest[2] = 'f';
+ }
+
+ return 3;
+}
+
+/* Fast and accurate double to string conversion based on Florian Loitsch's
+ * Grisu-algorithm[1].
+ *
+ * Input:
+ * fp -> the double to convert, dest -> destination buffer.
+ * The generated string will never be longer than 32 characters.
+ * Make sure to pass a pointer to at least 32 bytes of memory.
+ * The emitted string will not be null terminated.
+ *
+ *
+ *
+ * Output:
+ * The number of written characters.
+ *
+ * Exemplary usage:
+ *
+ * void print(double d)
+ * {
+ * char buf[28 + 1] // plus null terminator
+ * int str_len = fpconv_dtoa(d, buf);
+ *
+ * buf[str_len] = '\0';
+ * printf("%s", buf);
+ * }
+ *
+ */
+static int fpconv_dtoa(double d, char dest[32])
+{
+ char digits[18];
+
+ int str_len = 0;
+ bool neg = false;
+
+ if(get_dbits(d) & signmask) {
+ dest[0] = '-';
+ str_len++;
+ neg = true;
+ }
+
+ int spec = filter_special(d, dest + str_len);
+
+ if(spec) {
+ return str_len + spec;
+ }
+
+ int K = 0;
+ int ndigits = grisu2(d, digits, &K);
+
+ str_len += emit_digits(digits, ndigits, dest + str_len, K, neg);
+#if JSON_DEBUG
+ assert(str_len <= 32);
+#endif
+
+ return str_len;
+}
diff --git a/ext/json/vendor/jeaiii-ltoa.h b/ext/json/vendor/jeaiii-ltoa.h
new file mode 100644
index 0000000000..ba4f497fc8
--- /dev/null
+++ b/ext/json/vendor/jeaiii-ltoa.h
@@ -0,0 +1,267 @@
+/*
+
+This file is released under the terms of the MIT License. It is based on the
+work of James Edward Anhalt III, with the original license listed below.
+
+MIT License
+
+Copyright (c) 2024,2025 Enrico Thierbach - https://github.com/radiospiel
+Copyright (c) 2022 James Edward Anhalt III - https://github.com/jeaiii/itoa
+
+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.
+*/
+
+#ifndef JEAIII_TO_TEXT_H_
+#define JEAIII_TO_TEXT_H_
+
+#include <stdint.h>
+
+typedef uint_fast32_t u32_t;
+typedef uint_fast64_t u64_t;
+
+#define u32(x) ((u32_t)(x))
+#define u64(x) ((u64_t)(x))
+
+struct digit_pair
+{
+ char dd[2];
+};
+
+static const struct digit_pair *digits_dd = (struct digit_pair *)(
+ "00" "01" "02" "03" "04" "05" "06" "07" "08" "09"
+ "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"
+);
+
+static const struct digit_pair *digits_fd = (struct digit_pair *)(
+ "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"
+);
+
+static const u64_t mask24 = (u64(1) << 24) - 1;
+static const u64_t mask32 = (u64(1) << 32) - 1;
+static const u64_t mask57 = (u64(1) << 57) - 1;
+
+#define COPY(buffer, digits) memcpy(buffer, &(digits), sizeof(struct digit_pair))
+
+static char *
+jeaiii_ultoa(char *b, u64_t n)
+{
+ if (n < u32(1e2)) {
+ COPY(b, digits_fd[n]);
+ return n < 10 ? b + 1 : b + 2;
+ }
+
+ if (n < u32(1e6)) {
+ if (n < u32(1e4)) {
+ u32_t f0 = u32((10 * (1 << 24) / 1e3 + 1) * n);
+ COPY(b, digits_fd[f0 >> 24]);
+
+ b -= n < u32(1e3);
+ u32_t f2 = (f0 & mask24) * 100;
+ COPY(b + 2, digits_dd[f2 >> 24]);
+
+ return b + 4;
+ }
+
+ u64_t f0 = u64(10 * (1ull << 32ull)/ 1e5 + 1) * n;
+ COPY(b, digits_fd[f0 >> 32]);
+
+ b -= n < u32(1e5);
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+ return b + 6;
+ }
+
+ if (n < u64(1ull << 32ull)) {
+ if (n < u32(1e8)) {
+ u64_t f0 = u64(10 * (1ull << 48ull) / 1e7 + 1) * n >> 16;
+ COPY(b, digits_fd[f0 >> 32]);
+
+ b -= n < u32(1e7);
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+
+ u64_t f6 = (f4 & mask32) * 100;
+ COPY(b + 6, digits_dd[f6 >> 32]);
+
+ return b + 8;
+ }
+
+ u64_t f0 = u64(10 * (1ull << 57ull) / 1e9 + 1) * n;
+ COPY(b, digits_fd[f0 >> 57]);
+
+ b -= n < u32(1e9);
+ u64_t f2 = (f0 & mask57) * 100;
+ COPY(b + 2, digits_dd[f2 >> 57]);
+
+ u64_t f4 = (f2 & mask57) * 100;
+ COPY(b + 4, digits_dd[f4 >> 57]);
+
+ u64_t f6 = (f4 & mask57) * 100;
+ COPY(b + 6, digits_dd[f6 >> 57]);
+
+ u64_t f8 = (f6 & mask57) * 100;
+ COPY(b + 8, digits_dd[f8 >> 57]);
+
+ return b + 10;
+ }
+
+ // if we get here U must be u64 but some compilers don't know that, so reassign n to a u64 to avoid warnings
+ u32_t z = n % u32(1e8);
+ u64_t u = n / u32(1e8);
+
+ if (u < u32(1e2)) {
+ // u can't be 1 digit (if u < 10 it would have been handled above as a 9 digit 32bit number)
+ COPY(b, digits_dd[u]);
+ b += 2;
+ }
+ else if (u < u32(1e6)) {
+ if (u < u32(1e4)) {
+ u32_t f0 = u32((10 * (1 << 24) / 1e3 + 1) * u);
+ COPY(b, digits_fd[f0 >> 24]);
+
+ b -= u < u32(1e3);
+ u32_t f2 = (f0 & mask24) * 100;
+ COPY(b + 2, digits_dd[f2 >> 24]);
+ b += 4;
+ }
+ else {
+ u64_t f0 = u64(10 * (1ull << 32ull) / 1e5 + 1) * u;
+ COPY(b, digits_fd[f0 >> 32]);
+
+ b -= u < u32(1e5);
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+ b += 6;
+ }
+ }
+ else if (u < u32(1e8)) {
+ u64_t f0 = u64(10 * (1ull << 48ull) / 1e7 + 1) * u >> 16;
+ COPY(b, digits_fd[f0 >> 32]);
+
+ b -= u < u32(1e7);
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+
+ u64_t f6 = (f4 & mask32) * 100;
+ COPY(b + 6, digits_dd[f6 >> 32]);
+
+ b += 8;
+ }
+ else if (u < u64(1ull << 32ull)) {
+ u64_t f0 = u64(10 * (1ull << 57ull) / 1e9 + 1) * u;
+ COPY(b, digits_fd[f0 >> 57]);
+
+ b -= u < u32(1e9);
+ u64_t f2 = (f0 & mask57) * 100;
+ COPY(b + 2, digits_dd[f2 >> 57]);
+
+ u64_t f4 = (f2 & mask57) * 100;
+ COPY(b + 4, digits_dd[f4 >> 57]);
+
+ u64_t f6 = (f4 & mask57) * 100;
+ COPY(b + 6, digits_dd[f6 >> 57]);
+
+ u64_t f8 = (f6 & mask57) * 100;
+ COPY(b + 8, digits_dd[f8 >> 57]);
+ b += 10;
+ }
+ else {
+ u32_t y = u % u32(1e8);
+ u /= u32(1e8);
+
+ // u is 2, 3, or 4 digits (if u < 10 it would have been handled above)
+ if (u < u32(1e2)) {
+ COPY(b, digits_dd[u]);
+ b += 2;
+ }
+ else {
+ u32_t f0 = u32((10 * (1 << 24) / 1e3 + 1) * u);
+ COPY(b, digits_fd[f0 >> 24]);
+
+ b -= u < u32(1e3);
+ u32_t f2 = (f0 & mask24) * 100;
+ COPY(b + 2, digits_dd[f2 >> 24]);
+
+ b += 4;
+ }
+ // do 8 digits
+ u64_t f0 = (u64((1ull << 48ull) / 1e6 + 1) * y >> 16) + 1;
+ COPY(b, digits_dd[f0 >> 32]);
+
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+
+ u64_t f6 = (f4 & mask32) * 100;
+ COPY(b + 6, digits_dd[f6 >> 32]);
+ b += 8;
+ }
+
+ // do 8 digits
+ u64_t f0 = (u64((1ull << 48ull) / 1e6 + 1) * z >> 16) + 1;
+ COPY(b, digits_dd[f0 >> 32]);
+
+ u64_t f2 = (f0 & mask32) * 100;
+ COPY(b + 2, digits_dd[f2 >> 32]);
+
+ u64_t f4 = (f2 & mask32) * 100;
+ COPY(b + 4, digits_dd[f4 >> 32]);
+
+ u64_t f6 = (f4 & mask32) * 100;
+ COPY(b + 6, digits_dd[f6 >> 32]);
+
+ return b + 8;
+}
+
+#undef u32
+#undef u64
+#undef COPY
+
+#endif // JEAIII_TO_TEXT_H_
diff --git a/ext/json/vendor/ryu.h b/ext/json/vendor/ryu.h
new file mode 100644
index 0000000000..f06ec814b4
--- /dev/null
+++ b/ext/json/vendor/ryu.h
@@ -0,0 +1,819 @@
+// Copyright 2018 Ulf Adams
+//
+// The contents of this file may be used under the terms of the Apache License,
+// Version 2.0.
+//
+// Alternatively, the contents of this file may be used under the terms of
+// the Boost Software License, Version 1.0.
+//
+// Unless required by applicable law or agreed to in writing, this software
+// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.
+//
+// ---
+//
+// Apache License
+// Version 2.0, January 2004
+// http://www.apache.org/licenses/
+//
+// TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+//
+// 1. Definitions.
+//
+// "License" shall mean the terms and conditions for use, reproduction,
+// and distribution as defined by Sections 1 through 9 of this document.
+//
+// "Licensor" shall mean the copyright owner or entity authorized by
+// the copyright owner that is granting the License.
+//
+// "Legal Entity" shall mean the union of the acting entity and all
+// other entities that control, are controlled by, or are under common
+// control with that entity. For the purposes of this definition,
+// "control" means (i) the power, direct or indirect, to cause the
+// direction or management of such entity, whether by contract or
+// otherwise, or (ii) ownership of fifty percent (50%) or more of the
+// outstanding shares, or (iii) beneficial ownership of such entity.
+//
+// "You" (or "Your") shall mean an individual or Legal Entity
+// exercising permissions granted by this License.
+//
+// "Source" form shall mean the preferred form for making modifications,
+// including but not limited to software source code, documentation
+// source, and configuration files.
+//
+// "Object" form shall mean any form resulting from mechanical
+// transformation or translation of a Source form, including but
+// not limited to compiled object code, generated documentation,
+// and conversions to other media types.
+//
+// "Work" shall mean the work of authorship, whether in Source or
+// Object form, made available under the License, as indicated by a
+// copyright notice that is included in or attached to the work
+// (an example is provided in the Appendix below).
+//
+// "Derivative Works" shall mean any work, whether in Source or Object
+// form, that is based on (or derived from) the Work and for which the
+// editorial revisions, annotations, elaborations, or other modifications
+// represent, as a whole, an original work of authorship. For the purposes
+// of this License, Derivative Works shall not include works that remain
+// separable from, or merely link (or bind by name) to the interfaces of,
+// the Work and Derivative Works thereof.
+//
+// "Contribution" shall mean any work of authorship, including
+// the original version of the Work and any modifications or additions
+// to that Work or Derivative Works thereof, that is intentionally
+// submitted to Licensor for inclusion in the Work by the copyright owner
+// or by an individual or Legal Entity authorized to submit on behalf of
+// the copyright owner. For the purposes of this definition, "submitted"
+// means any form of electronic, verbal, or written communication sent
+// to the Licensor or its representatives, including but not limited to
+// communication on electronic mailing lists, source code control systems,
+// and issue tracking systems that are managed by, or on behalf of, the
+// Licensor for the purpose of discussing and improving the Work, but
+// excluding communication that is conspicuously marked or otherwise
+// designated in writing by the copyright owner as "Not a Contribution."
+//
+// "Contributor" shall mean Licensor and any individual or Legal Entity
+// on behalf of whom a Contribution has been received by Licensor and
+// subsequently incorporated within the Work.
+//
+// 2. Grant of Copyright License. Subject to the terms and conditions of
+// this License, each Contributor hereby grants to You a perpetual,
+// worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+// copyright license to reproduce, prepare Derivative Works of,
+// publicly display, publicly perform, sublicense, and distribute the
+// Work and such Derivative Works in Source or Object form.
+//
+// 3. Grant of Patent License. Subject to the terms and conditions of
+// this License, each Contributor hereby grants to You a perpetual,
+// worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+// (except as stated in this section) patent license to make, have made,
+// use, offer to sell, sell, import, and otherwise transfer the Work,
+// where such license applies only to those patent claims licensable
+// by such Contributor that are necessarily infringed by their
+// Contribution(s) alone or by combination of their Contribution(s)
+// with the Work to which such Contribution(s) was submitted. If You
+// institute patent litigation against any entity (including a
+// cross-claim or counterclaim in a lawsuit) alleging that the Work
+// or a Contribution incorporated within the Work constitutes direct
+// or contributory patent infringement, then any patent licenses
+// granted to You under this License for that Work shall terminate
+// as of the date such litigation is filed.
+//
+// 4. Redistribution. You may reproduce and distribute copies of the
+// Work or Derivative Works thereof in any medium, with or without
+// modifications, and in Source or Object form, provided that You
+// meet the following conditions:
+//
+// (a) You must give any other recipients of the Work or
+// Derivative Works a copy of this License; and
+//
+// (b) You must cause any modified files to carry prominent notices
+// stating that You changed the files; and
+//
+// (c) You must retain, in the Source form of any Derivative Works
+// that You distribute, all copyright, patent, trademark, and
+// attribution notices from the Source form of the Work,
+// excluding those notices that do not pertain to any part of
+// the Derivative Works; and
+//
+// (d) If the Work includes a "NOTICE" text file as part of its
+// distribution, then any Derivative Works that You distribute must
+// include a readable copy of the attribution notices contained
+// within such NOTICE file, excluding those notices that do not
+// pertain to any part of the Derivative Works, in at least one
+// of the following places: within a NOTICE text file distributed
+// as part of the Derivative Works; within the Source form or
+// documentation, if provided along with the Derivative Works; or,
+// within a display generated by the Derivative Works, if and
+// wherever such third-party notices normally appear. The contents
+// of the NOTICE file are for informational purposes only and
+// do not modify the License. You may add Your own attribution
+// notices within Derivative Works that You distribute, alongside
+// or as an addendum to the NOTICE text from the Work, provided
+// that such additional attribution notices cannot be construed
+// as modifying the License.
+//
+// You may add Your own copyright statement to Your modifications and
+// may provide additional or different license terms and conditions
+// for use, reproduction, or distribution of Your modifications, or
+// for any such Derivative Works as a whole, provided Your use,
+// reproduction, and distribution of the Work otherwise complies with
+// the conditions stated in this License.
+//
+// 5. Submission of Contributions. Unless You explicitly state otherwise,
+// any Contribution intentionally submitted for inclusion in the Work
+// by You to the Licensor shall be under the terms and conditions of
+// this License, without any additional terms or conditions.
+// Notwithstanding the above, nothing herein shall supersede or modify
+// the terms of any separate license agreement you may have executed
+// with Licensor regarding such Contributions.
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor,
+// except as required for reasonable and customary use in describing the
+// origin of the Work and reproducing the content of the NOTICE file.
+//
+// 7. Disclaimer of Warranty. Unless required by applicable law or
+// agreed to in writing, Licensor provides the Work (and each
+// Contributor provides its Contributions) on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+// implied, including, without limitation, any warranties or conditions
+// of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+// PARTICULAR PURPOSE. You are solely responsible for determining the
+// appropriateness of using or redistributing the Work and assume any
+// risks associated with Your exercise of permissions under this License.
+//
+// 8. Limitation of Liability. In no event and under no legal theory,
+// whether in tort (including negligence), contract, or otherwise,
+// unless required by applicable law (such as deliberate and grossly
+// negligent acts) or agreed to in writing, shall any Contributor be
+// liable to You for damages, including any direct, indirect, special,
+// incidental, or consequential damages of any character arising as a
+// result of this License or out of the use or inability to use the
+// Work (including but not limited to damages for loss of goodwill,
+// work stoppage, computer failure or malfunction, or any and all
+// other commercial damages or losses), even if such Contributor
+// has been advised of the possibility of such damages.
+//
+// 9. Accepting Warranty or Additional Liability. While redistributing
+// the Work or Derivative Works thereof, You may choose to offer,
+// and charge a fee for, acceptance of support, warranty, indemnity,
+// or other liability obligations and/or rights consistent with this
+// License. However, in accepting such obligations, You may act only
+// on Your own behalf and on Your sole responsibility, not on behalf
+// of any other Contributor, and only if You agree to indemnify,
+// defend, and hold each Contributor harmless for any liability
+// incurred by, or claims asserted against, such Contributor by reason
+// of your accepting any such warranty or additional liability.
+//
+// END OF TERMS AND CONDITIONS
+//
+// APPENDIX: How to apply the Apache License to your work.
+//
+// To apply the Apache License to your work, attach the following
+// boilerplate notice, with the fields enclosed by brackets "[]"
+// replaced with your own identifying information. (Don't include
+// the brackets!) The text should be enclosed in the appropriate
+// comment syntax for the file format. We also recommend that a
+// file or class name and description of purpose be included on the
+// same "printed page" as the copyright notice for easier
+// identification within third-party archives.
+//
+// Copyright [yyyy] [name of copyright owner]
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// ---
+//
+// Boost Software License - Version 1.0 - August 17th, 2003
+//
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+//
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+//
+// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+// ---
+// Minimal Ryu implementation adapted for Ruby JSON gem by Josef Šimánek
+// Optimized for pre-extracted mantissa/exponent from JSON parsing
+// This is a stripped-down version containing only what's needed for
+// converting decimal mantissa+exponent to IEEE 754 double precision.
+
+#ifndef RYU_H
+#define RYU_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+
+// Detect __builtin_clzll availability (for floor_log2)
+// Note: MSVC doesn't have __builtin_clzll, so we provide a fallback
+#ifdef __clang__
+ #if __has_builtin(__builtin_clzll)
+ #define RYU_HAVE_BUILTIN_CLZLL 1
+ #else
+ #define RYU_HAVE_BUILTIN_CLZLL 0
+ #endif
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+ #define RYU_HAVE_BUILTIN_CLZLL 1
+#else
+ #define RYU_HAVE_BUILTIN_CLZLL 0
+#endif
+
+// Count leading zeros (for floor_log2)
+static inline uint32_t ryu_leading_zeros64(uint64_t input)
+{
+#if RYU_HAVE_BUILTIN_CLZLL
+ return __builtin_clzll(input);
+#else
+ // Fallback: binary search for the highest set bit
+ // This works on MSVC and other compilers without __builtin_clzll
+ if (input == 0) return 64;
+ uint32_t n = 0;
+ if (input <= 0x00000000FFFFFFFFULL) { n += 32; input <<= 32; }
+ if (input <= 0x0000FFFFFFFFFFFFULL) { n += 16; input <<= 16; }
+ if (input <= 0x00FFFFFFFFFFFFFFULL) { n += 8; input <<= 8; }
+ if (input <= 0x0FFFFFFFFFFFFFFFULL) { n += 4; input <<= 4; }
+ if (input <= 0x3FFFFFFFFFFFFFFFULL) { n += 2; input <<= 2; }
+ if (input <= 0x7FFFFFFFFFFFFFFFULL) { n += 1; }
+ return n;
+#endif
+}
+
+// These tables are generated by PrintDoubleLookupTable.
+#define DOUBLE_POW5_INV_BITCOUNT 125
+#define DOUBLE_POW5_BITCOUNT 125
+
+#define DOUBLE_POW5_INV_TABLE_SIZE 342
+#define DOUBLE_POW5_TABLE_SIZE 326
+
+static const uint64_t DOUBLE_POW5_INV_SPLIT[DOUBLE_POW5_INV_TABLE_SIZE][2] = {
+ { 1u, 2305843009213693952u }, { 11068046444225730970u, 1844674407370955161u },
+ { 5165088340638674453u, 1475739525896764129u }, { 7821419487252849886u, 1180591620717411303u },
+ { 8824922364862649494u, 1888946593147858085u }, { 7059937891890119595u, 1511157274518286468u },
+ { 13026647942995916322u, 1208925819614629174u }, { 9774590264567735146u, 1934281311383406679u },
+ { 11509021026396098440u, 1547425049106725343u }, { 16585914450600699399u, 1237940039285380274u },
+ { 15469416676735388068u, 1980704062856608439u }, { 16064882156130220778u, 1584563250285286751u },
+ { 9162556910162266299u, 1267650600228229401u }, { 7281393426775805432u, 2028240960365167042u },
+ { 16893161185646375315u, 1622592768292133633u }, { 2446482504291369283u, 1298074214633706907u },
+ { 7603720821608101175u, 2076918743413931051u }, { 2393627842544570617u, 1661534994731144841u },
+ { 16672297533003297786u, 1329227995784915872u }, { 11918280793837635165u, 2126764793255865396u },
+ { 5845275820328197809u, 1701411834604692317u }, { 15744267100488289217u, 1361129467683753853u },
+ { 3054734472329800808u, 2177807148294006166u }, { 17201182836831481939u, 1742245718635204932u },
+ { 6382248639981364905u, 1393796574908163946u }, { 2832900194486363201u, 2230074519853062314u },
+ { 5955668970331000884u, 1784059615882449851u }, { 1075186361522890384u, 1427247692705959881u },
+ { 12788344622662355584u, 2283596308329535809u }, { 13920024512871794791u, 1826877046663628647u },
+ { 3757321980813615186u, 1461501637330902918u }, { 10384555214134712795u, 1169201309864722334u },
+ { 5547241898389809503u, 1870722095783555735u }, { 4437793518711847602u, 1496577676626844588u },
+ { 10928932444453298728u, 1197262141301475670u }, { 17486291911125277965u, 1915619426082361072u },
+ { 6610335899416401726u, 1532495540865888858u }, { 12666966349016942027u, 1225996432692711086u },
+ { 12888448528943286597u, 1961594292308337738u }, { 17689456452638449924u, 1569275433846670190u },
+ { 14151565162110759939u, 1255420347077336152u }, { 7885109000409574610u, 2008672555323737844u },
+ { 9997436015069570011u, 1606938044258990275u }, { 7997948812055656009u, 1285550435407192220u },
+ { 12796718099289049614u, 2056880696651507552u }, { 2858676849947419045u, 1645504557321206042u },
+ { 13354987924183666206u, 1316403645856964833u }, { 17678631863951955605u, 2106245833371143733u },
+ { 3074859046935833515u, 1684996666696914987u }, { 13527933681774397782u, 1347997333357531989u },
+ { 10576647446613305481u, 2156795733372051183u }, { 15840015586774465031u, 1725436586697640946u },
+ { 8982663654677661702u, 1380349269358112757u }, { 18061610662226169046u, 2208558830972980411u },
+ { 10759939715039024913u, 1766847064778384329u }, { 12297300586773130254u, 1413477651822707463u },
+ { 15986332124095098083u, 2261564242916331941u }, { 9099716884534168143u, 1809251394333065553u },
+ { 14658471137111155161u, 1447401115466452442u }, { 4348079280205103483u, 1157920892373161954u },
+ { 14335624477811986218u, 1852673427797059126u }, { 7779150767507678651u, 1482138742237647301u },
+ { 2533971799264232598u, 1185710993790117841u }, { 15122401323048503126u, 1897137590064188545u },
+ { 12097921058438802501u, 1517710072051350836u }, { 5988988032009131678u, 1214168057641080669u },
+ { 16961078480698431330u, 1942668892225729070u }, { 13568862784558745064u, 1554135113780583256u },
+ { 7165741412905085728u, 1243308091024466605u }, { 11465186260648137165u, 1989292945639146568u },
+ { 16550846638002330379u, 1591434356511317254u }, { 16930026125143774626u, 1273147485209053803u },
+ { 4951948911778577463u, 2037035976334486086u }, { 272210314680951647u, 1629628781067588869u },
+ { 3907117066486671641u, 1303703024854071095u }, { 6251387306378674625u, 2085924839766513752u },
+ { 16069156289328670670u, 1668739871813211001u }, { 9165976216721026213u, 1334991897450568801u },
+ { 7286864317269821294u, 2135987035920910082u }, { 16897537898041588005u, 1708789628736728065u },
+ { 13518030318433270404u, 1367031702989382452u }, { 6871453250525591353u, 2187250724783011924u },
+ { 9186511415162383406u, 1749800579826409539u }, { 11038557946871817048u, 1399840463861127631u },
+ { 10282995085511086630u, 2239744742177804210u }, { 8226396068408869304u, 1791795793742243368u },
+ { 13959814484210916090u, 1433436634993794694u }, { 11267656730511734774u, 2293498615990071511u },
+ { 5324776569667477496u, 1834798892792057209u }, { 7949170070475892320u, 1467839114233645767u },
+ { 17427382500606444826u, 1174271291386916613u }, { 5747719112518849781u, 1878834066219066582u },
+ { 15666221734240810795u, 1503067252975253265u }, { 12532977387392648636u, 1202453802380202612u },
+ { 5295368560860596524u, 1923926083808324180u }, { 4236294848688477220u, 1539140867046659344u },
+ { 7078384693692692099u, 1231312693637327475u }, { 11325415509908307358u, 1970100309819723960u },
+ { 9060332407926645887u, 1576080247855779168u }, { 14626963555825137356u, 1260864198284623334u },
+ { 12335095245094488799u, 2017382717255397335u }, { 9868076196075591040u, 1613906173804317868u },
+ { 15273158586344293478u, 1291124939043454294u }, { 13369007293925138595u, 2065799902469526871u },
+ { 7005857020398200553u, 1652639921975621497u }, { 16672732060544291412u, 1322111937580497197u },
+ { 11918976037903224966u, 2115379100128795516u }, { 5845832015580669650u, 1692303280103036413u },
+ { 12055363241948356366u, 1353842624082429130u }, { 841837113407818570u, 2166148198531886609u },
+ { 4362818505468165179u, 1732918558825509287u }, { 14558301248600263113u, 1386334847060407429u },
+ { 12225235553534690011u, 2218135755296651887u }, { 2401490813343931363u, 1774508604237321510u },
+ { 1921192650675145090u, 1419606883389857208u }, { 17831303500047873437u, 2271371013423771532u },
+ { 6886345170554478103u, 1817096810739017226u }, { 1819727321701672159u, 1453677448591213781u },
+ { 16213177116328979020u, 1162941958872971024u }, { 14873036941900635463u, 1860707134196753639u },
+ { 15587778368262418694u, 1488565707357402911u }, { 8780873879868024632u, 1190852565885922329u },
+ { 2981351763563108441u, 1905364105417475727u }, { 13453127855076217722u, 1524291284333980581u },
+ { 7073153469319063855u, 1219433027467184465u }, { 11317045550910502167u, 1951092843947495144u },
+ { 12742985255470312057u, 1560874275157996115u }, { 10194388204376249646u, 1248699420126396892u },
+ { 1553625868034358140u, 1997919072202235028u }, { 8621598323911307159u, 1598335257761788022u },
+ { 17965325103354776697u, 1278668206209430417u }, { 13987124906400001422u, 2045869129935088668u },
+ { 121653480894270168u, 1636695303948070935u }, { 97322784715416134u, 1309356243158456748u },
+ { 14913111714512307107u, 2094969989053530796u }, { 8241140556867935363u, 1675975991242824637u },
+ { 17660958889720079260u, 1340780792994259709u }, { 17189487779326395846u, 2145249268790815535u },
+ { 13751590223461116677u, 1716199415032652428u }, { 18379969808252713988u, 1372959532026121942u },
+ { 14650556434236701088u, 2196735251241795108u }, { 652398703163629901u, 1757388200993436087u },
+ { 11589965406756634890u, 1405910560794748869u }, { 7475898206584884855u, 2249456897271598191u },
+ { 2291369750525997561u, 1799565517817278553u }, { 9211793429904618695u, 1439652414253822842u },
+ { 18428218302589300235u, 2303443862806116547u }, { 7363877012587619542u, 1842755090244893238u },
+ { 13269799239553916280u, 1474204072195914590u }, { 10615839391643133024u, 1179363257756731672u },
+ { 2227947767661371545u, 1886981212410770676u }, { 16539753473096738529u, 1509584969928616540u },
+ { 13231802778477390823u, 1207667975942893232u }, { 6413489186596184024u, 1932268761508629172u },
+ { 16198837793502678189u, 1545815009206903337u }, { 5580372605318321905u, 1236652007365522670u },
+ { 8928596168509315048u, 1978643211784836272u }, { 18210923379033183008u, 1582914569427869017u },
+ { 7190041073742725760u, 1266331655542295214u }, { 436019273762630246u, 2026130648867672343u },
+ { 7727513048493924843u, 1620904519094137874u }, { 9871359253537050198u, 1296723615275310299u },
+ { 4726128361433549347u, 2074757784440496479u }, { 7470251503888749801u, 1659806227552397183u },
+ { 13354898832594820487u, 1327844982041917746u }, { 13989140502667892133u, 2124551971267068394u },
+ { 14880661216876224029u, 1699641577013654715u }, { 11904528973500979224u, 1359713261610923772u },
+ { 4289851098633925465u, 2175541218577478036u }, { 18189276137874781665u, 1740432974861982428u },
+ { 3483374466074094362u, 1392346379889585943u }, { 1884050330976640656u, 2227754207823337509u },
+ { 5196589079523222848u, 1782203366258670007u }, { 15225317707844309248u, 1425762693006936005u },
+ { 5913764258841343181u, 2281220308811097609u }, { 8420360221814984868u, 1824976247048878087u },
+ { 17804334621677718864u, 1459980997639102469u }, { 17932816512084085415u, 1167984798111281975u },
+ { 10245762345624985047u, 1868775676978051161u }, { 4507261061758077715u, 1495020541582440929u },
+ { 7295157664148372495u, 1196016433265952743u }, { 7982903447895485668u, 1913626293225524389u },
+ { 10075671573058298858u, 1530901034580419511u }, { 4371188443704728763u, 1224720827664335609u },
+ { 14372599139411386667u, 1959553324262936974u }, { 15187428126271019657u, 1567642659410349579u },
+ { 15839291315758726049u, 1254114127528279663u }, { 3206773216762499739u, 2006582604045247462u },
+ { 13633465017635730761u, 1605266083236197969u }, { 14596120828850494932u, 1284212866588958375u },
+ { 4907049252451240275u, 2054740586542333401u }, { 236290587219081897u, 1643792469233866721u },
+ { 14946427728742906810u, 1315033975387093376u }, { 16535586736504830250u, 2104054360619349402u },
+ { 5849771759720043554u, 1683243488495479522u }, { 15747863852001765813u, 1346594790796383617u },
+ { 10439186904235184007u, 2154551665274213788u }, { 15730047152871967852u, 1723641332219371030u },
+ { 12584037722297574282u, 1378913065775496824u }, { 9066413911450387881u, 2206260905240794919u },
+ { 10942479943902220628u, 1765008724192635935u }, { 8753983955121776503u, 1412006979354108748u },
+ { 10317025513452932081u, 2259211166966573997u }, { 874922781278525018u, 1807368933573259198u },
+ { 8078635854506640661u, 1445895146858607358u }, { 13841606313089133175u, 1156716117486885886u },
+ { 14767872471458792434u, 1850745787979017418u }, { 746251532941302978u, 1480596630383213935u },
+ { 597001226353042382u, 1184477304306571148u }, { 15712597221132509104u, 1895163686890513836u },
+ { 8880728962164096960u, 1516130949512411069u }, { 10793931984473187891u, 1212904759609928855u },
+ { 17270291175157100626u, 1940647615375886168u }, { 2748186495899949531u, 1552518092300708935u },
+ { 2198549196719959625u, 1242014473840567148u }, { 18275073973719576693u, 1987223158144907436u },
+ { 10930710364233751031u, 1589778526515925949u }, { 12433917106128911148u, 1271822821212740759u },
+ { 8826220925580526867u, 2034916513940385215u }, { 7060976740464421494u, 1627933211152308172u },
+ { 16716827836597268165u, 1302346568921846537u }, { 11989529279587987770u, 2083754510274954460u },
+ { 9591623423670390216u, 1667003608219963568u }, { 15051996368420132820u, 1333602886575970854u },
+ { 13015147745246481542u, 2133764618521553367u }, { 3033420566713364587u, 1707011694817242694u },
+ { 6116085268112601993u, 1365609355853794155u }, { 9785736428980163188u, 2184974969366070648u },
+ { 15207286772667951197u, 1747979975492856518u }, { 1097782973908629988u, 1398383980394285215u },
+ { 1756452758253807981u, 2237414368630856344u }, { 5094511021344956708u, 1789931494904685075u },
+ { 4075608817075965366u, 1431945195923748060u }, { 6520974107321544586u, 2291112313477996896u },
+ { 1527430471115325346u, 1832889850782397517u }, { 12289990821117991246u, 1466311880625918013u },
+ { 17210690286378213644u, 1173049504500734410u }, { 9090360384495590213u, 1876879207201175057u },
+ { 18340334751822203140u, 1501503365760940045u }, { 14672267801457762512u, 1201202692608752036u },
+ { 16096930852848599373u, 1921924308174003258u }, { 1809498238053148529u, 1537539446539202607u },
+ { 12515645034668249793u, 1230031557231362085u }, { 1578287981759648052u, 1968050491570179337u },
+ { 12330676829633449412u, 1574440393256143469u }, { 13553890278448669853u, 1259552314604914775u },
+ { 3239480371808320148u, 2015283703367863641u }, { 17348979556414297411u, 1612226962694290912u },
+ { 6500486015647617283u, 1289781570155432730u }, { 10400777625036187652u, 2063650512248692368u },
+ { 15699319729512770768u, 1650920409798953894u }, { 16248804598352126938u, 1320736327839163115u },
+ { 7551343283653851484u, 2113178124542660985u }, { 6041074626923081187u, 1690542499634128788u },
+ { 12211557331022285596u, 1352433999707303030u }, { 1091747655926105338u, 2163894399531684849u },
+ { 4562746939482794594u, 1731115519625347879u }, { 7339546366328145998u, 1384892415700278303u },
+ { 8053925371383123274u, 2215827865120445285u }, { 6443140297106498619u, 1772662292096356228u },
+ { 12533209867169019542u, 1418129833677084982u }, { 5295740528502789974u, 2269007733883335972u },
+ { 15304638867027962949u, 1815206187106668777u }, { 4865013464138549713u, 1452164949685335022u },
+ { 14960057215536570740u, 1161731959748268017u }, { 9178696285890871890u, 1858771135597228828u },
+ { 14721654658196518159u, 1487016908477783062u }, { 4398626097073393881u, 1189613526782226450u },
+ { 7037801755317430209u, 1903381642851562320u }, { 5630241404253944167u, 1522705314281249856u },
+ { 814844308661245011u, 1218164251424999885u }, { 1303750893857992017u, 1949062802279999816u },
+ { 15800395974054034906u, 1559250241823999852u }, { 5261619149759407279u, 1247400193459199882u },
+ { 12107939454356961969u, 1995840309534719811u }, { 5997002748743659252u, 1596672247627775849u },
+ { 8486951013736837725u, 1277337798102220679u }, { 2511075177753209390u, 2043740476963553087u },
+ { 13076906586428298482u, 1634992381570842469u }, { 14150874083884549109u, 1307993905256673975u },
+ { 4194654460505726958u, 2092790248410678361u }, { 18113118827372222859u, 1674232198728542688u },
+ { 3422448617672047318u, 1339385758982834151u }, { 16543964232501006678u, 2143017214372534641u },
+ { 9545822571258895019u, 1714413771498027713u }, { 15015355686490936662u, 1371531017198422170u },
+ { 5577825024675947042u, 2194449627517475473u }, { 11840957649224578280u, 1755559702013980378u },
+ { 16851463748863483271u, 1404447761611184302u }, { 12204946739213931940u, 2247116418577894884u },
+ { 13453306206113055875u, 1797693134862315907u }, { 3383947335406624054u, 1438154507889852726u },
+ { 16482362180876329456u, 2301047212623764361u }, { 9496540929959153242u, 1840837770099011489u },
+ { 11286581558709232917u, 1472670216079209191u }, { 5339916432225476010u, 1178136172863367353u },
+ { 4854517476818851293u, 1885017876581387765u }, { 3883613981455081034u, 1508014301265110212u },
+ { 14174937629389795797u, 1206411441012088169u }, { 11611853762797942306u, 1930258305619341071u },
+ { 5600134195496443521u, 1544206644495472857u }, { 15548153800622885787u, 1235365315596378285u },
+ { 6430302007287065643u, 1976584504954205257u }, { 16212288050055383484u, 1581267603963364205u },
+ { 12969830440044306787u, 1265014083170691364u }, { 9683682259845159889u, 2024022533073106183u },
+ { 15125643437359948558u, 1619218026458484946u }, { 8411165935146048523u, 1295374421166787957u },
+ { 17147214310975587960u, 2072599073866860731u }, { 10028422634038560045u, 1658079259093488585u },
+ { 8022738107230848036u, 1326463407274790868u }, { 9147032156827446534u, 2122341451639665389u },
+ { 11006974540203867551u, 1697873161311732311u }, { 5116230817421183718u, 1358298529049385849u },
+ { 15564666937357714594u, 2173277646479017358u }, { 1383687105660440706u, 1738622117183213887u },
+ { 12174996128754083534u, 1390897693746571109u }, { 8411947361780802685u, 2225436309994513775u },
+ { 6729557889424642148u, 1780349047995611020u }, { 5383646311539713719u, 1424279238396488816u },
+ { 1235136468979721303u, 2278846781434382106u }, { 15745504434151418335u, 1823077425147505684u },
+ { 16285752362063044992u, 1458461940118004547u }, { 5649904260166615347u, 1166769552094403638u },
+ { 5350498001524674232u, 1866831283351045821u }, { 591049586477829062u, 1493465026680836657u },
+ { 11540886113407994219u, 1194772021344669325u }, { 18673707743239135u, 1911635234151470921u },
+ { 14772334225162232601u, 1529308187321176736u }, { 8128518565387875758u, 1223446549856941389u },
+ { 1937583260394870242u, 1957514479771106223u }, { 8928764237799716840u, 1566011583816884978u },
+ { 14521709019723594119u, 1252809267053507982u }, { 8477339172590109297u, 2004494827285612772u },
+ { 17849917782297818407u, 1603595861828490217u }, { 6901236596354434079u, 1282876689462792174u },
+ { 18420676183650915173u, 2052602703140467478u }, { 3668494502695001169u, 1642082162512373983u },
+ { 10313493231639821582u, 1313665730009899186u }, { 9122891541139893884u, 2101865168015838698u },
+ { 14677010862395735754u, 1681492134412670958u }, { 673562245690857633u, 1345193707530136767u }
+};
+
+static const uint64_t DOUBLE_POW5_SPLIT[DOUBLE_POW5_TABLE_SIZE][2] = {
+ { 0u, 1152921504606846976u }, { 0u, 1441151880758558720u },
+ { 0u, 1801439850948198400u }, { 0u, 2251799813685248000u },
+ { 0u, 1407374883553280000u }, { 0u, 1759218604441600000u },
+ { 0u, 2199023255552000000u }, { 0u, 1374389534720000000u },
+ { 0u, 1717986918400000000u }, { 0u, 2147483648000000000u },
+ { 0u, 1342177280000000000u }, { 0u, 1677721600000000000u },
+ { 0u, 2097152000000000000u }, { 0u, 1310720000000000000u },
+ { 0u, 1638400000000000000u }, { 0u, 2048000000000000000u },
+ { 0u, 1280000000000000000u }, { 0u, 1600000000000000000u },
+ { 0u, 2000000000000000000u }, { 0u, 1250000000000000000u },
+ { 0u, 1562500000000000000u }, { 0u, 1953125000000000000u },
+ { 0u, 1220703125000000000u }, { 0u, 1525878906250000000u },
+ { 0u, 1907348632812500000u }, { 0u, 1192092895507812500u },
+ { 0u, 1490116119384765625u }, { 4611686018427387904u, 1862645149230957031u },
+ { 9799832789158199296u, 1164153218269348144u }, { 12249790986447749120u, 1455191522836685180u },
+ { 15312238733059686400u, 1818989403545856475u }, { 14528612397897220096u, 2273736754432320594u },
+ { 13692068767113150464u, 1421085471520200371u }, { 12503399940464050176u, 1776356839400250464u },
+ { 15629249925580062720u, 2220446049250313080u }, { 9768281203487539200u, 1387778780781445675u },
+ { 7598665485932036096u, 1734723475976807094u }, { 274959820560269312u, 2168404344971008868u },
+ { 9395221924704944128u, 1355252715606880542u }, { 2520655369026404352u, 1694065894508600678u },
+ { 12374191248137781248u, 2117582368135750847u }, { 14651398557727195136u, 1323488980084844279u },
+ { 13702562178731606016u, 1654361225106055349u }, { 3293144668132343808u, 2067951531382569187u },
+ { 18199116482078572544u, 1292469707114105741u }, { 8913837547316051968u, 1615587133892632177u },
+ { 15753982952572452864u, 2019483917365790221u }, { 12152082354571476992u, 1262177448353618888u },
+ { 15190102943214346240u, 1577721810442023610u }, { 9764256642163156992u, 1972152263052529513u },
+ { 17631875447420442880u, 1232595164407830945u }, { 8204786253993389888u, 1540743955509788682u },
+ { 1032610780636961552u, 1925929944387235853u }, { 2951224747111794922u, 1203706215242022408u },
+ { 3689030933889743652u, 1504632769052528010u }, { 13834660704216955373u, 1880790961315660012u },
+ { 17870034976990372916u, 1175494350822287507u }, { 17725857702810578241u, 1469367938527859384u },
+ { 3710578054803671186u, 1836709923159824231u }, { 26536550077201078u, 2295887403949780289u },
+ { 11545800389866720434u, 1434929627468612680u }, { 14432250487333400542u, 1793662034335765850u },
+ { 8816941072311974870u, 2242077542919707313u }, { 17039803216263454053u, 1401298464324817070u },
+ { 12076381983474541759u, 1751623080406021338u }, { 5872105442488401391u, 2189528850507526673u },
+ { 15199280947623720629u, 1368455531567204170u }, { 9775729147674874978u, 1710569414459005213u },
+ { 16831347453020981627u, 2138211768073756516u }, { 1296220121283337709u, 1336382355046097823u },
+ { 15455333206886335848u, 1670477943807622278u }, { 10095794471753144002u, 2088097429759527848u },
+ { 6309871544845715001u, 1305060893599704905u }, { 12499025449484531656u, 1631326116999631131u },
+ { 11012095793428276666u, 2039157646249538914u }, { 11494245889320060820u, 1274473528905961821u },
+ { 532749306367912313u, 1593091911132452277u }, { 5277622651387278295u, 1991364888915565346u },
+ { 7910200175544436838u, 1244603055572228341u }, { 14499436237857933952u, 1555753819465285426u },
+ { 8900923260467641632u, 1944692274331606783u }, { 12480606065433357876u, 1215432671457254239u },
+ { 10989071563364309441u, 1519290839321567799u }, { 9124653435777998898u, 1899113549151959749u },
+ { 8008751406574943263u, 1186945968219974843u }, { 5399253239791291175u, 1483682460274968554u },
+ { 15972438586593889776u, 1854603075343710692u }, { 759402079766405302u, 1159126922089819183u },
+ { 14784310654990170340u, 1448908652612273978u }, { 9257016281882937117u, 1811135815765342473u },
+ { 16182956370781059300u, 2263919769706678091u }, { 7808504722524468110u, 1414949856066673807u },
+ { 5148944884728197234u, 1768687320083342259u }, { 1824495087482858639u, 2210859150104177824u },
+ { 1140309429676786649u, 1381786968815111140u }, { 1425386787095983311u, 1727233711018888925u },
+ { 6393419502297367043u, 2159042138773611156u }, { 13219259225790630210u, 1349401336733506972u },
+ { 16524074032238287762u, 1686751670916883715u }, { 16043406521870471799u, 2108439588646104644u },
+ { 803757039314269066u, 1317774742903815403u }, { 14839754354425000045u, 1647218428629769253u },
+ { 4714634887749086344u, 2059023035787211567u }, { 9864175832484260821u, 1286889397367007229u },
+ { 16941905809032713930u, 1608611746708759036u }, { 2730638187581340797u, 2010764683385948796u },
+ { 10930020904093113806u, 1256727927116217997u }, { 18274212148543780162u, 1570909908895272496u },
+ { 4396021111970173586u, 1963637386119090621u }, { 5053356204195052443u, 1227273366324431638u },
+ { 15540067292098591362u, 1534091707905539547u }, { 14813398096695851299u, 1917614634881924434u },
+ { 13870059828862294966u, 1198509146801202771u }, { 12725888767650480803u, 1498136433501503464u },
+ { 15907360959563101004u, 1872670541876879330u }, { 14553786618154326031u, 1170419088673049581u },
+ { 4357175217410743827u, 1463023860841311977u }, { 10058155040190817688u, 1828779826051639971u },
+ { 7961007781811134206u, 2285974782564549964u }, { 14199001900486734687u, 1428734239102843727u },
+ { 13137066357181030455u, 1785917798878554659u }, { 11809646928048900164u, 2232397248598193324u },
+ { 16604401366885338411u, 1395248280373870827u }, { 16143815690179285109u, 1744060350467338534u },
+ { 10956397575869330579u, 2180075438084173168u }, { 6847748484918331612u, 1362547148802608230u },
+ { 17783057643002690323u, 1703183936003260287u }, { 17617136035325974999u, 2128979920004075359u },
+ { 17928239049719816230u, 1330612450002547099u }, { 17798612793722382384u, 1663265562503183874u },
+ { 13024893955298202172u, 2079081953128979843u }, { 5834715712847682405u, 1299426220705612402u },
+ { 16516766677914378815u, 1624282775882015502u }, { 11422586310538197711u, 2030353469852519378u },
+ { 11750802462513761473u, 1268970918657824611u }, { 10076817059714813937u, 1586213648322280764u },
+ { 12596021324643517422u, 1982767060402850955u }, { 5566670318688504437u, 1239229412751781847u },
+ { 2346651879933242642u, 1549036765939727309u }, { 7545000868343941206u, 1936295957424659136u },
+ { 4715625542714963254u, 1210184973390411960u }, { 5894531928393704067u, 1512731216738014950u },
+ { 16591536947346905892u, 1890914020922518687u }, { 17287239619732898039u, 1181821263076574179u },
+ { 16997363506238734644u, 1477276578845717724u }, { 2799960309088866689u, 1846595723557147156u },
+ { 10973347230035317489u, 1154122327223216972u }, { 13716684037544146861u, 1442652909029021215u },
+ { 12534169028502795672u, 1803316136286276519u }, { 11056025267201106687u, 2254145170357845649u },
+ { 18439230838069161439u, 1408840731473653530u }, { 13825666510731675991u, 1761050914342066913u },
+ { 3447025083132431277u, 2201313642927583642u }, { 6766076695385157452u, 1375821026829739776u },
+ { 8457595869231446815u, 1719776283537174720u }, { 10571994836539308519u, 2149720354421468400u },
+ { 6607496772837067824u, 1343575221513417750u }, { 17482743002901110588u, 1679469026891772187u },
+ { 17241742735199000331u, 2099336283614715234u }, { 15387775227926763111u, 1312085177259197021u },
+ { 5399660979626290177u, 1640106471573996277u }, { 11361262242960250625u, 2050133089467495346u },
+ { 11712474920277544544u, 1281333180917184591u }, { 10028907631919542777u, 1601666476146480739u },
+ { 7924448521472040567u, 2002083095183100924u }, { 14176152362774801162u, 1251301934489438077u },
+ { 3885132398186337741u, 1564127418111797597u }, { 9468101516160310080u, 1955159272639746996u },
+ { 15140935484454969608u, 1221974545399841872u }, { 479425281859160394u, 1527468181749802341u },
+ { 5210967620751338397u, 1909335227187252926u }, { 17091912818251750210u, 1193334516992033078u },
+ { 12141518985959911954u, 1491668146240041348u }, { 15176898732449889943u, 1864585182800051685u },
+ { 11791404716994875166u, 1165365739250032303u }, { 10127569877816206054u, 1456707174062540379u },
+ { 8047776328842869663u, 1820883967578175474u }, { 836348374198811271u, 2276104959472719343u },
+ { 7440246761515338900u, 1422565599670449589u }, { 13911994470321561530u, 1778206999588061986u },
+ { 8166621051047176104u, 2222758749485077483u }, { 2798295147690791113u, 1389224218428173427u },
+ { 17332926989895652603u, 1736530273035216783u }, { 17054472718942177850u, 2170662841294020979u },
+ { 8353202440125167204u, 1356664275808763112u }, { 10441503050156459005u, 1695830344760953890u },
+ { 3828506775840797949u, 2119787930951192363u }, { 86973725686804766u, 1324867456844495227u },
+ { 13943775212390669669u, 1656084321055619033u }, { 3594660960206173375u, 2070105401319523792u },
+ { 2246663100128858359u, 1293815875824702370u }, { 12031700912015848757u, 1617269844780877962u },
+ { 5816254103165035138u, 2021587305976097453u }, { 5941001823691840913u, 1263492066235060908u },
+ { 7426252279614801142u, 1579365082793826135u }, { 4671129331091113523u, 1974206353492282669u },
+ { 5225298841145639904u, 1233878970932676668u }, { 6531623551432049880u, 1542348713665845835u },
+ { 3552843420862674446u, 1927935892082307294u }, { 16055585193321335241u, 1204959932551442058u },
+ { 10846109454796893243u, 1506199915689302573u }, { 18169322836923504458u, 1882749894611628216u },
+ { 11355826773077190286u, 1176718684132267635u }, { 9583097447919099954u, 1470898355165334544u },
+ { 11978871809898874942u, 1838622943956668180u }, { 14973589762373593678u, 2298278679945835225u },
+ { 2440964573842414192u, 1436424174966147016u }, { 3051205717303017741u, 1795530218707683770u },
+ { 13037379183483547984u, 2244412773384604712u }, { 8148361989677217490u, 1402757983365377945u },
+ { 14797138505523909766u, 1753447479206722431u }, { 13884737113477499304u, 2191809349008403039u },
+ { 15595489723564518921u, 1369880843130251899u }, { 14882676136028260747u, 1712351053912814874u },
+ { 9379973133180550126u, 2140438817391018593u }, { 17391698254306313589u, 1337774260869386620u },
+ { 3292878744173340370u, 1672217826086733276u }, { 4116098430216675462u, 2090272282608416595u },
+ { 266718509671728212u, 1306420176630260372u }, { 333398137089660265u, 1633025220787825465u },
+ { 5028433689789463235u, 2041281525984781831u }, { 10060300083759496378u, 1275800953740488644u },
+ { 12575375104699370472u, 1594751192175610805u }, { 1884160825592049379u, 1993438990219513507u },
+ { 17318501580490888525u, 1245899368887195941u }, { 7813068920331446945u, 1557374211108994927u },
+ { 5154650131986920777u, 1946717763886243659u }, { 915813323278131534u, 1216698602428902287u },
+ { 14979824709379828129u, 1520873253036127858u }, { 9501408849870009354u, 1901091566295159823u },
+ { 12855909558809837702u, 1188182228934474889u }, { 2234828893230133415u, 1485227786168093612u },
+ { 2793536116537666769u, 1856534732710117015u }, { 8663489100477123587u, 1160334207943823134u },
+ { 1605989338741628675u, 1450417759929778918u }, { 11230858710281811652u, 1813022199912223647u },
+ { 9426887369424876662u, 2266277749890279559u }, { 12809333633531629769u, 1416423593681424724u },
+ { 16011667041914537212u, 1770529492101780905u }, { 6179525747111007803u, 2213161865127226132u },
+ { 13085575628799155685u, 1383226165704516332u }, { 16356969535998944606u, 1729032707130645415u },
+ { 15834525901571292854u, 2161290883913306769u }, { 2979049660840976177u, 1350806802445816731u },
+ { 17558870131333383934u, 1688508503057270913u }, { 8113529608884566205u, 2110635628821588642u },
+ { 9682642023980241782u, 1319147268013492901u }, { 16714988548402690132u, 1648934085016866126u },
+ { 11670363648648586857u, 2061167606271082658u }, { 11905663298832754689u, 1288229753919426661u },
+ { 1047021068258779650u, 1610287192399283327u }, { 15143834390605638274u, 2012858990499104158u },
+ { 4853210475701136017u, 1258036869061940099u }, { 1454827076199032118u, 1572546086327425124u },
+ { 1818533845248790147u, 1965682607909281405u }, { 3442426662494187794u, 1228551629943300878u },
+ { 13526405364972510550u, 1535689537429126097u }, { 3072948650933474476u, 1919611921786407622u },
+ { 15755650962115585259u, 1199757451116504763u }, { 15082877684217093670u, 1499696813895630954u },
+ { 9630225068416591280u, 1874621017369538693u }, { 8324733676974063502u, 1171638135855961683u },
+ { 5794231077790191473u, 1464547669819952104u }, { 7242788847237739342u, 1830684587274940130u },
+ { 18276858095901949986u, 2288355734093675162u }, { 16034722328366106645u, 1430222333808546976u },
+ { 1596658836748081690u, 1787777917260683721u }, { 6607509564362490017u, 2234722396575854651u },
+ { 1823850468512862308u, 1396701497859909157u }, { 6891499104068465790u, 1745876872324886446u },
+ { 17837745916940358045u, 2182346090406108057u }, { 4231062170446641922u, 1363966306503817536u },
+ { 5288827713058302403u, 1704957883129771920u }, { 6611034641322878003u, 2131197353912214900u },
+ { 13355268687681574560u, 1331998346195134312u }, { 16694085859601968200u, 1664997932743917890u },
+ { 11644235287647684442u, 2081247415929897363u }, { 4971804045566108824u, 1300779634956185852u },
+ { 6214755056957636030u, 1625974543695232315u }, { 3156757802769657134u, 2032468179619040394u },
+ { 6584659645158423613u, 1270292612261900246u }, { 17454196593302805324u, 1587865765327375307u },
+ { 17206059723201118751u, 1984832206659219134u }, { 6142101308573311315u, 1240520129162011959u },
+ { 3065940617289251240u, 1550650161452514949u }, { 8444111790038951954u, 1938312701815643686u },
+ { 665883850346957067u, 1211445438634777304u }, { 832354812933696334u, 1514306798293471630u },
+ { 10263815553021896226u, 1892883497866839537u }, { 17944099766707154901u, 1183052186166774710u },
+ { 13206752671529167818u, 1478815232708468388u }, { 16508440839411459773u, 1848519040885585485u },
+ { 12623618533845856310u, 1155324400553490928u }, { 15779523167307320387u, 1444155500691863660u },
+ { 1277659885424598868u, 1805194375864829576u }, { 1597074856780748586u, 2256492969831036970u },
+ { 5609857803915355770u, 1410308106144398106u }, { 16235694291748970521u, 1762885132680497632u },
+ { 1847873790976661535u, 2203606415850622041u }, { 12684136165428883219u, 1377254009906638775u },
+ { 11243484188358716120u, 1721567512383298469u }, { 219297180166231438u, 2151959390479123087u },
+ { 7054589765244976505u, 1344974619049451929u }, { 13429923224983608535u, 1681218273811814911u },
+ { 12175718012802122765u, 2101522842264768639u }, { 14527352785642408584u, 1313451776415480399u },
+ { 13547504963625622826u, 1641814720519350499u }, { 12322695186104640628u, 2052268400649188124u },
+ { 16925056528170176201u, 1282667750405742577u }, { 7321262604930556539u, 1603334688007178222u },
+ { 18374950293017971482u, 2004168360008972777u }, { 4566814905495150320u, 1252605225005607986u },
+ { 14931890668723713708u, 1565756531257009982u }, { 9441491299049866327u, 1957195664071262478u },
+ { 1289246043478778550u, 1223247290044539049u }, { 6223243572775861092u, 1529059112555673811u },
+ { 3167368447542438461u, 1911323890694592264u }, { 1979605279714024038u, 1194577431684120165u },
+ { 7086192618069917952u, 1493221789605150206u }, { 18081112809442173248u, 1866527237006437757u },
+ { 13606538515115052232u, 1166579523129023598u }, { 7784801107039039482u, 1458224403911279498u },
+ { 507629346944023544u, 1822780504889099373u }, { 5246222702107417334u, 2278475631111374216u },
+ { 3278889188817135834u, 1424047269444608885u }, { 8710297504448807696u, 1780059086805761106u }
+};
+
+// IEEE 754 double precision constants
+#define DOUBLE_MANTISSA_BITS 52
+#define DOUBLE_EXPONENT_BITS 11
+#define DOUBLE_EXPONENT_BIAS 1023
+
+// Helper: floor(log2(value)) using ryu_leading_zeros64
+static inline uint32_t floor_log2(const uint64_t value) {
+ return 63 - ryu_leading_zeros64(value);
+}
+
+// Helper: log2(5^e) approximation
+static inline int32_t log2pow5(const int32_t e) {
+ return (int32_t) ((((uint32_t) e) * 1217359) >> 19);
+}
+
+// Helper: ceil(log2(5^e))
+static inline int32_t ceil_log2pow5(const int32_t e) {
+ return log2pow5(e) + 1;
+}
+
+// Helper: max of two int32
+static inline int32_t max32(int32_t a, int32_t b) {
+ return a < b ? b : a;
+}
+
+// Helper: convert uint64 bits to double
+static inline double int64Bits2Double(uint64_t bits) {
+ double f;
+ memcpy(&f, &bits, sizeof(double));
+ return f;
+}
+
+// Check if value is multiple of 2^p
+static inline bool multipleOfPowerOf2(const uint64_t value, const uint32_t p) {
+ return (value & ((1ull << p) - 1)) == 0;
+}
+
+// Count how many times value is divisible by 5
+// Uses modular inverse to avoid expensive division
+static inline uint32_t pow5Factor(uint64_t value) {
+ const uint64_t m_inv_5 = 14757395258967641293u; // 5 * m_inv_5 = 1 (mod 2^64)
+ const uint64_t n_div_5 = 3689348814741910323u; // 2^64 / 5
+ uint32_t count = 0;
+ for (;;) {
+ value *= m_inv_5;
+ if (value > n_div_5)
+ break;
+ ++count;
+ }
+ return count;
+}
+
+// Check if value is multiple of 5^p
+// Optimized: uses modular inverse instead of division
+static inline bool multipleOfPowerOf5(const uint64_t value, const uint32_t p) {
+ return pow5Factor(value) >= p;
+}
+
+// 128-bit multiplication with shift
+// This is the core operation for converting decimal to binary
+#if defined(__SIZEOF_INT128__)
+// Use native 128-bit integers if available (GCC/Clang)
+static inline uint64_t mulShift64(const uint64_t m, const uint64_t* const mul, const int32_t j) {
+ const unsigned __int128 b0 = ((unsigned __int128) m) * mul[0];
+ const unsigned __int128 b2 = ((unsigned __int128) m) * mul[1];
+ return (uint64_t) (((b0 >> 64) + b2) >> (j - 64));
+}
+#else
+// Fallback for systems without 128-bit integers
+static inline uint64_t umul128(const uint64_t a, const uint64_t b, uint64_t* const productHi) {
+ const uint32_t aLo = (uint32_t)a;
+ const uint32_t aHi = (uint32_t)(a >> 32);
+ const uint32_t bLo = (uint32_t)b;
+ const uint32_t bHi = (uint32_t)(b >> 32);
+
+ const uint64_t b00 = (uint64_t)aLo * bLo;
+ const uint64_t b01 = (uint64_t)aLo * bHi;
+ const uint64_t b10 = (uint64_t)aHi * bLo;
+ const uint64_t b11 = (uint64_t)aHi * bHi;
+
+ const uint32_t b00Lo = (uint32_t)b00;
+ const uint32_t b00Hi = (uint32_t)(b00 >> 32);
+
+ const uint64_t mid1 = b10 + b00Hi;
+ const uint32_t mid1Lo = (uint32_t)(mid1);
+ const uint32_t mid1Hi = (uint32_t)(mid1 >> 32);
+
+ const uint64_t mid2 = b01 + mid1Lo;
+ const uint32_t mid2Lo = (uint32_t)(mid2);
+ const uint32_t mid2Hi = (uint32_t)(mid2 >> 32);
+
+ const uint64_t pHi = b11 + mid1Hi + mid2Hi;
+ const uint64_t pLo = ((uint64_t)mid2Lo << 32) | b00Lo;
+
+ *productHi = pHi;
+ return pLo;
+}
+
+static inline uint64_t shiftright128(const uint64_t lo, const uint64_t hi, const uint32_t dist) {
+ return (hi << (64 - dist)) | (lo >> dist);
+}
+
+static inline uint64_t mulShift64(const uint64_t m, const uint64_t* const mul, const int32_t j) {
+ uint64_t high1;
+ const uint64_t low1 = umul128(m, mul[1], &high1);
+ uint64_t high0;
+ umul128(m, mul[0], &high0);
+ const uint64_t sum = high0 + low1;
+ if (sum < high0) {
+ ++high1;
+ }
+ return shiftright128(sum, high1, j - 64);
+}
+#endif
+
+// Main conversion function: decimal mantissa+exponent to IEEE 754 double
+// Optimized for JSON parsing with fast paths for edge cases
+static inline double ryu_s2d_from_parts(uint64_t m10, int m10digits, int32_t e10, bool signedM) {
+ // Fast path: handle zero explicitly (e.g., "0.0", "0e0")
+ if (m10 == 0) {
+ return int64Bits2Double(((uint64_t) signedM) << 63);
+ }
+
+ // Fast path: handle overflow/underflow early
+ if (m10digits + e10 <= -324) {
+ // Underflow to zero
+ return int64Bits2Double(((uint64_t) signedM) << 63);
+ }
+
+ if (m10digits + e10 >= 310) {
+ // Overflow to infinity
+ return int64Bits2Double((((uint64_t) signedM) << 63) | 0x7ff0000000000000ULL);
+ }
+
+ // Convert decimal to binary: m10 * 10^e10 = m2 * 2^e2
+ int32_t e2;
+ uint64_t m2;
+ bool trailingZeros;
+
+ if (e10 >= 0) {
+ // Positive exponent: multiply by 5^e10 and adjust binary exponent
+ e2 = floor_log2(m10) + e10 + log2pow5(e10) - (DOUBLE_MANTISSA_BITS + 1);
+ int j = e2 - e10 - ceil_log2pow5(e10) + DOUBLE_POW5_BITCOUNT;
+ m2 = mulShift64(m10, DOUBLE_POW5_SPLIT[e10], j);
+ trailingZeros = e2 < e10 || (e2 - e10 < 64 && multipleOfPowerOf2(m10, e2 - e10));
+ } else {
+ // Negative exponent: divide by 5^(-e10)
+ e2 = floor_log2(m10) + e10 - ceil_log2pow5(-e10) - (DOUBLE_MANTISSA_BITS + 1);
+ int j = e2 - e10 + ceil_log2pow5(-e10) - 1 + DOUBLE_POW5_INV_BITCOUNT;
+ m2 = mulShift64(m10, DOUBLE_POW5_INV_SPLIT[-e10], j);
+ trailingZeros = multipleOfPowerOf5(m10, -e10);
+ }
+
+ // Compute IEEE 754 exponent
+ uint32_t ieee_e2 = (uint32_t) max32(0, e2 + DOUBLE_EXPONENT_BIAS + floor_log2(m2));
+
+ if (ieee_e2 > 0x7fe) {
+ // Overflow to infinity
+ return int64Bits2Double((((uint64_t) signedM) << 63) | 0x7ff0000000000000ULL);
+ }
+
+ // Compute shift amount for rounding
+ int32_t shift = (ieee_e2 == 0 ? 1 : ieee_e2) - e2 - DOUBLE_EXPONENT_BIAS - DOUBLE_MANTISSA_BITS;
+
+ // IEEE 754 round-to-even (banker's rounding)
+ trailingZeros &= (m2 & ((1ull << (shift - 1)) - 1)) == 0;
+ uint64_t lastRemovedBit = (m2 >> (shift - 1)) & 1;
+ bool roundUp = (lastRemovedBit != 0) && (!trailingZeros || (((m2 >> shift) & 1) != 0));
+
+ uint64_t ieee_m2 = (m2 >> shift) + roundUp;
+ ieee_m2 &= (1ull << DOUBLE_MANTISSA_BITS) - 1;
+
+ if (ieee_m2 == 0 && roundUp) {
+ ieee_e2++;
+ }
+
+ // Pack sign, exponent, and mantissa into IEEE 754 format
+ // Match original Ryu: group sign+exponent, then shift and add mantissa
+ uint64_t ieee = (((((uint64_t) signedM) << DOUBLE_EXPONENT_BITS) | (uint64_t)ieee_e2) << DOUBLE_MANTISSA_BITS) | ieee_m2;
+ return int64Bits2Double(ieee);
+}
+
+#endif // RYU_H
diff --git a/ext/monitor/depend b/ext/monitor/depend
deleted file mode 100644
index 38e21b3f66..0000000000
--- a/ext/monitor/depend
+++ /dev/null
@@ -1,160 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-monitor.o: $(RUBY_EXTCONF_H)
-monitor.o: $(arch_hdrdir)/ruby/config.h
-monitor.o: $(hdrdir)/ruby/assert.h
-monitor.o: $(hdrdir)/ruby/backward.h
-monitor.o: $(hdrdir)/ruby/backward/2/assume.h
-monitor.o: $(hdrdir)/ruby/backward/2/attributes.h
-monitor.o: $(hdrdir)/ruby/backward/2/bool.h
-monitor.o: $(hdrdir)/ruby/backward/2/inttypes.h
-monitor.o: $(hdrdir)/ruby/backward/2/limits.h
-monitor.o: $(hdrdir)/ruby/backward/2/long_long.h
-monitor.o: $(hdrdir)/ruby/backward/2/stdalign.h
-monitor.o: $(hdrdir)/ruby/backward/2/stdarg.h
-monitor.o: $(hdrdir)/ruby/defines.h
-monitor.o: $(hdrdir)/ruby/intern.h
-monitor.o: $(hdrdir)/ruby/internal/abi.h
-monitor.o: $(hdrdir)/ruby/internal/anyargs.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-monitor.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-monitor.o: $(hdrdir)/ruby/internal/assume.h
-monitor.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-monitor.o: $(hdrdir)/ruby/internal/attr/artificial.h
-monitor.o: $(hdrdir)/ruby/internal/attr/cold.h
-monitor.o: $(hdrdir)/ruby/internal/attr/const.h
-monitor.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-monitor.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-monitor.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-monitor.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-monitor.o: $(hdrdir)/ruby/internal/attr/error.h
-monitor.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-monitor.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-monitor.o: $(hdrdir)/ruby/internal/attr/format.h
-monitor.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-monitor.o: $(hdrdir)/ruby/internal/attr/noalias.h
-monitor.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-monitor.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-monitor.o: $(hdrdir)/ruby/internal/attr/noinline.h
-monitor.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-monitor.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-monitor.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-monitor.o: $(hdrdir)/ruby/internal/attr/pure.h
-monitor.o: $(hdrdir)/ruby/internal/attr/restrict.h
-monitor.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-monitor.o: $(hdrdir)/ruby/internal/attr/warning.h
-monitor.o: $(hdrdir)/ruby/internal/attr/weakref.h
-monitor.o: $(hdrdir)/ruby/internal/cast.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-monitor.o: $(hdrdir)/ruby/internal/compiler_since.h
-monitor.o: $(hdrdir)/ruby/internal/config.h
-monitor.o: $(hdrdir)/ruby/internal/constant_p.h
-monitor.o: $(hdrdir)/ruby/internal/core.h
-monitor.o: $(hdrdir)/ruby/internal/core/rarray.h
-monitor.o: $(hdrdir)/ruby/internal/core/rbasic.h
-monitor.o: $(hdrdir)/ruby/internal/core/rbignum.h
-monitor.o: $(hdrdir)/ruby/internal/core/rclass.h
-monitor.o: $(hdrdir)/ruby/internal/core/rdata.h
-monitor.o: $(hdrdir)/ruby/internal/core/rfile.h
-monitor.o: $(hdrdir)/ruby/internal/core/rhash.h
-monitor.o: $(hdrdir)/ruby/internal/core/robject.h
-monitor.o: $(hdrdir)/ruby/internal/core/rregexp.h
-monitor.o: $(hdrdir)/ruby/internal/core/rstring.h
-monitor.o: $(hdrdir)/ruby/internal/core/rstruct.h
-monitor.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-monitor.o: $(hdrdir)/ruby/internal/ctype.h
-monitor.o: $(hdrdir)/ruby/internal/dllexport.h
-monitor.o: $(hdrdir)/ruby/internal/dosish.h
-monitor.o: $(hdrdir)/ruby/internal/error.h
-monitor.o: $(hdrdir)/ruby/internal/eval.h
-monitor.o: $(hdrdir)/ruby/internal/event.h
-monitor.o: $(hdrdir)/ruby/internal/fl_type.h
-monitor.o: $(hdrdir)/ruby/internal/gc.h
-monitor.o: $(hdrdir)/ruby/internal/glob.h
-monitor.o: $(hdrdir)/ruby/internal/globals.h
-monitor.o: $(hdrdir)/ruby/internal/has/attribute.h
-monitor.o: $(hdrdir)/ruby/internal/has/builtin.h
-monitor.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-monitor.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-monitor.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-monitor.o: $(hdrdir)/ruby/internal/has/extension.h
-monitor.o: $(hdrdir)/ruby/internal/has/feature.h
-monitor.o: $(hdrdir)/ruby/internal/has/warning.h
-monitor.o: $(hdrdir)/ruby/internal/intern/array.h
-monitor.o: $(hdrdir)/ruby/internal/intern/bignum.h
-monitor.o: $(hdrdir)/ruby/internal/intern/class.h
-monitor.o: $(hdrdir)/ruby/internal/intern/compar.h
-monitor.o: $(hdrdir)/ruby/internal/intern/complex.h
-monitor.o: $(hdrdir)/ruby/internal/intern/cont.h
-monitor.o: $(hdrdir)/ruby/internal/intern/dir.h
-monitor.o: $(hdrdir)/ruby/internal/intern/enum.h
-monitor.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-monitor.o: $(hdrdir)/ruby/internal/intern/error.h
-monitor.o: $(hdrdir)/ruby/internal/intern/eval.h
-monitor.o: $(hdrdir)/ruby/internal/intern/file.h
-monitor.o: $(hdrdir)/ruby/internal/intern/hash.h
-monitor.o: $(hdrdir)/ruby/internal/intern/io.h
-monitor.o: $(hdrdir)/ruby/internal/intern/load.h
-monitor.o: $(hdrdir)/ruby/internal/intern/marshal.h
-monitor.o: $(hdrdir)/ruby/internal/intern/numeric.h
-monitor.o: $(hdrdir)/ruby/internal/intern/object.h
-monitor.o: $(hdrdir)/ruby/internal/intern/parse.h
-monitor.o: $(hdrdir)/ruby/internal/intern/proc.h
-monitor.o: $(hdrdir)/ruby/internal/intern/process.h
-monitor.o: $(hdrdir)/ruby/internal/intern/random.h
-monitor.o: $(hdrdir)/ruby/internal/intern/range.h
-monitor.o: $(hdrdir)/ruby/internal/intern/rational.h
-monitor.o: $(hdrdir)/ruby/internal/intern/re.h
-monitor.o: $(hdrdir)/ruby/internal/intern/ruby.h
-monitor.o: $(hdrdir)/ruby/internal/intern/select.h
-monitor.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-monitor.o: $(hdrdir)/ruby/internal/intern/signal.h
-monitor.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-monitor.o: $(hdrdir)/ruby/internal/intern/string.h
-monitor.o: $(hdrdir)/ruby/internal/intern/struct.h
-monitor.o: $(hdrdir)/ruby/internal/intern/thread.h
-monitor.o: $(hdrdir)/ruby/internal/intern/time.h
-monitor.o: $(hdrdir)/ruby/internal/intern/variable.h
-monitor.o: $(hdrdir)/ruby/internal/intern/vm.h
-monitor.o: $(hdrdir)/ruby/internal/interpreter.h
-monitor.o: $(hdrdir)/ruby/internal/iterator.h
-monitor.o: $(hdrdir)/ruby/internal/memory.h
-monitor.o: $(hdrdir)/ruby/internal/method.h
-monitor.o: $(hdrdir)/ruby/internal/module.h
-monitor.o: $(hdrdir)/ruby/internal/newobj.h
-monitor.o: $(hdrdir)/ruby/internal/scan_args.h
-monitor.o: $(hdrdir)/ruby/internal/special_consts.h
-monitor.o: $(hdrdir)/ruby/internal/static_assert.h
-monitor.o: $(hdrdir)/ruby/internal/stdalign.h
-monitor.o: $(hdrdir)/ruby/internal/stdbool.h
-monitor.o: $(hdrdir)/ruby/internal/symbol.h
-monitor.o: $(hdrdir)/ruby/internal/value.h
-monitor.o: $(hdrdir)/ruby/internal/value_type.h
-monitor.o: $(hdrdir)/ruby/internal/variable.h
-monitor.o: $(hdrdir)/ruby/internal/warning_push.h
-monitor.o: $(hdrdir)/ruby/internal/xmalloc.h
-monitor.o: $(hdrdir)/ruby/missing.h
-monitor.o: $(hdrdir)/ruby/ruby.h
-monitor.o: $(hdrdir)/ruby/st.h
-monitor.o: $(hdrdir)/ruby/subst.h
-monitor.o: monitor.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/monitor/extconf.rb b/ext/monitor/extconf.rb
deleted file mode 100644
index 78c53fa0c5..0000000000
--- a/ext/monitor/extconf.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'mkmf'
-create_makefile('monitor')
diff --git a/ext/monitor/lib/monitor.rb b/ext/monitor/lib/monitor.rb
deleted file mode 100644
index 31d6d2b3c4..0000000000
--- a/ext/monitor/lib/monitor.rb
+++ /dev/null
@@ -1,283 +0,0 @@
-# frozen_string_literal: false
-# = monitor.rb
-#
-# Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
-#
-# This library is distributed under the terms of the Ruby license.
-# You can freely distribute/modify this library.
-#
-
-require 'monitor.so'
-
-#
-# In concurrent programming, a monitor is an object or module intended to be
-# used safely by more than one thread. The defining characteristic of a
-# monitor is that its methods are executed with mutual exclusion. That is, at
-# each point in time, at most one thread may be executing any of its methods.
-# This mutual exclusion greatly simplifies reasoning about the implementation
-# of monitors compared to reasoning about parallel code that updates a data
-# structure.
-#
-# You can read more about the general principles on the Wikipedia page for
-# Monitors[https://en.wikipedia.org/wiki/Monitor_%28synchronization%29].
-#
-# == Examples
-#
-# === Simple object.extend
-#
-# require 'monitor.rb'
-#
-# buf = []
-# buf.extend(MonitorMixin)
-# empty_cond = buf.new_cond
-#
-# # consumer
-# Thread.start do
-# loop do
-# buf.synchronize do
-# empty_cond.wait_while { buf.empty? }
-# print buf.shift
-# end
-# end
-# end
-#
-# # producer
-# while line = ARGF.gets
-# buf.synchronize do
-# buf.push(line)
-# empty_cond.signal
-# end
-# end
-#
-# The consumer thread waits for the producer thread to push a line to buf
-# while <tt>buf.empty?</tt>. The producer thread (main thread) reads a
-# line from ARGF and pushes it into buf then calls <tt>empty_cond.signal</tt>
-# to notify the consumer thread of new data.
-#
-# === Simple Class include
-#
-# require 'monitor'
-#
-# class SynchronizedArray < Array
-#
-# include MonitorMixin
-#
-# def initialize(*args)
-# super(*args)
-# end
-#
-# alias :old_shift :shift
-# alias :old_unshift :unshift
-#
-# def shift(n=1)
-# self.synchronize do
-# self.old_shift(n)
-# end
-# end
-#
-# def unshift(item)
-# self.synchronize do
-# self.old_unshift(item)
-# end
-# end
-#
-# # other methods ...
-# end
-#
-# +SynchronizedArray+ implements an Array with synchronized access to items.
-# This Class is implemented as subclass of Array which includes the
-# MonitorMixin module.
-#
-module MonitorMixin
- #
- # FIXME: This isn't documented in Nutshell.
- #
- # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
- # above calls while_wait and signal, this class should be documented.
- #
- class ConditionVariable
- #
- # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
- #
- # If +timeout+ is given, this method returns after +timeout+ seconds passed,
- # even if no other thread doesn't signal.
- #
- def wait(timeout = nil)
- @monitor.mon_check_owner
- @monitor.wait_for_cond(@cond, timeout)
- end
-
- #
- # Calls wait repeatedly while the given block yields a truthy value.
- #
- def wait_while
- while yield
- wait
- end
- end
-
- #
- # Calls wait repeatedly until the given block yields a truthy value.
- #
- def wait_until
- until yield
- wait
- end
- end
-
- #
- # Wakes up the first thread in line waiting for this lock.
- #
- def signal
- @monitor.mon_check_owner
- @cond.signal
- end
-
- #
- # Wakes up all threads waiting for this lock.
- #
- def broadcast
- @monitor.mon_check_owner
- @cond.broadcast
- end
-
- private
-
- def initialize(monitor)
- @monitor = monitor
- @cond = Thread::ConditionVariable.new
- end
- end
-
- def self.extend_object(obj)
- super(obj)
- obj.__send__(:mon_initialize)
- end
-
- #
- # Attempts to enter exclusive section. Returns +false+ if lock fails.
- #
- def mon_try_enter
- @mon_data.try_enter
- end
- # For backward compatibility
- alias try_mon_enter mon_try_enter
-
- #
- # Enters exclusive section.
- #
- def mon_enter
- @mon_data.enter
- end
-
- #
- # Leaves exclusive section.
- #
- def mon_exit
- mon_check_owner
- @mon_data.exit
- end
-
- #
- # Returns true if this monitor is locked by any thread
- #
- def mon_locked?
- @mon_data.mon_locked?
- end
-
- #
- # Returns true if this monitor is locked by current thread.
- #
- def mon_owned?
- @mon_data.mon_owned?
- end
-
- #
- # Enters exclusive section and executes the block. Leaves the exclusive
- # section automatically when the block exits. See example under
- # +MonitorMixin+.
- #
- def mon_synchronize(&b)
- @mon_data.synchronize(&b)
- end
- alias synchronize mon_synchronize
-
- #
- # Creates a new MonitorMixin::ConditionVariable associated with the
- # Monitor object.
- #
- def new_cond
- unless defined?(@mon_data)
- mon_initialize
- @mon_initialized_by_new_cond = true
- end
- return ConditionVariable.new(@mon_data)
- end
-
- private
-
- # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead
- # of this constructor. Have look at the examples above to understand how to
- # use this module.
- def initialize(...)
- super
- mon_initialize
- end
-
- # Initializes the MonitorMixin after being included in a class or when an
- # object has been extended with the MonitorMixin
- def mon_initialize
- if defined?(@mon_data)
- if defined?(@mon_initialized_by_new_cond)
- return # already initialized.
- elsif @mon_data_owner_object_id == self.object_id
- raise ThreadError, "already initialized"
- end
- end
- @mon_data = ::Monitor.new
- @mon_data_owner_object_id = self.object_id
- end
-
- def mon_check_owner
- @mon_data.mon_check_owner
- end
-end
-
-# Use the Monitor class when you want to have a lock object for blocks with
-# mutual exclusion.
-#
-# require 'monitor'
-#
-# lock = Monitor.new
-# lock.synchronize do
-# # exclusive access
-# end
-#
-class Monitor
- def new_cond
- ::MonitorMixin::ConditionVariable.new(self)
- end
-
- # for compatibility
- alias try_mon_enter try_enter
- alias mon_try_enter try_enter
- alias mon_enter enter
- alias mon_exit exit
- alias mon_synchronize synchronize
-end
-
-# Documentation comments:
-# - All documentation comes from Nutshell.
-# - MonitorMixin.new_cond appears in the example, but is not documented in
-# Nutshell.
-# - All the internals (internal modules Accessible and Initializable, class
-# ConditionVariable) appear in RDoc. It might be good to hide them, by
-# making them private, or marking them :nodoc:, etc.
-# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
-# not synchronize.
-# - mon_owner is in Nutshell, but appears as an accessor in a separate module
-# here, so is hard/impossible to RDoc. Some other useful accessors
-# (mon_count and some queue stuff) are also in this module, and don't appear
-# directly in the RDoc output.
-# - in short, it may be worth changing the code layout in this file to make the
-# documentation easier
diff --git a/ext/monitor/monitor.c b/ext/monitor/monitor.c
deleted file mode 100644
index 10209cf2aa..0000000000
--- a/ext/monitor/monitor.c
+++ /dev/null
@@ -1,225 +0,0 @@
-#include "ruby/ruby.h"
-
-/* Thread::Monitor */
-
-struct rb_monitor {
- long count;
- const VALUE owner;
- const VALUE mutex;
-};
-
-static void
-monitor_mark(void *ptr)
-{
- struct rb_monitor *mc = ptr;
- rb_gc_mark(mc->owner);
- rb_gc_mark(mc->mutex);
-}
-
-static size_t
-monitor_memsize(const void *ptr)
-{
- return sizeof(struct rb_monitor);
-}
-
-static const rb_data_type_t monitor_data_type = {
- "monitor",
- {monitor_mark, RUBY_TYPED_DEFAULT_FREE, monitor_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
-};
-
-static VALUE
-monitor_alloc(VALUE klass)
-{
- struct rb_monitor *mc;
- VALUE obj;
-
- obj = TypedData_Make_Struct(klass, struct rb_monitor, &monitor_data_type, mc);
- RB_OBJ_WRITE(obj, &mc->mutex, rb_mutex_new());
- RB_OBJ_WRITE(obj, &mc->owner, Qnil);
- mc->count = 0;
-
- return obj;
-}
-
-static struct rb_monitor *
-monitor_ptr(VALUE monitor)
-{
- struct rb_monitor *mc;
- TypedData_Get_Struct(monitor, struct rb_monitor, &monitor_data_type, mc);
- return mc;
-}
-
-static int
-mc_owner_p(struct rb_monitor *mc)
-{
- return mc->owner == rb_fiber_current();
-}
-
-static VALUE
-monitor_try_enter(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
-
- if (!mc_owner_p(mc)) {
- if (!rb_mutex_trylock(mc->mutex)) {
- return Qfalse;
- }
- RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current());
- mc->count = 0;
- }
- mc->count += 1;
- return Qtrue;
-}
-
-static VALUE
-monitor_enter(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- if (!mc_owner_p(mc)) {
- rb_mutex_lock(mc->mutex);
- RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current());
- mc->count = 0;
- }
- mc->count++;
- return Qnil;
-}
-
-static VALUE
-monitor_check_owner(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- if (!mc_owner_p(mc)) {
- rb_raise(rb_eThreadError, "current fiber not owner");
- }
- return Qnil;
-}
-
-static VALUE
-monitor_exit(VALUE monitor)
-{
- monitor_check_owner(monitor);
-
- struct rb_monitor *mc = monitor_ptr(monitor);
-
- if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count);
- mc->count--;
-
- if (mc->count == 0) {
- RB_OBJ_WRITE(monitor, &mc->owner, Qnil);
- rb_mutex_unlock(mc->mutex);
- }
- return Qnil;
-}
-
-static VALUE
-monitor_locked_p(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- return rb_mutex_locked_p(mc->mutex);
-}
-
-static VALUE
-monitor_owned_p(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- return (rb_mutex_locked_p(mc->mutex) && mc_owner_p(mc)) ? Qtrue : Qfalse;
-}
-
-static VALUE
-monitor_exit_for_cond(VALUE monitor)
-{
- struct rb_monitor *mc = monitor_ptr(monitor);
- long cnt = mc->count;
- RB_OBJ_WRITE(monitor, &mc->owner, Qnil);
- mc->count = 0;
- return LONG2NUM(cnt);
-}
-
-struct wait_for_cond_data {
- VALUE monitor;
- VALUE cond;
- VALUE timeout;
- VALUE count;
-};
-
-static VALUE
-monitor_wait_for_cond_body(VALUE v)
-{
- struct wait_for_cond_data *data = (struct wait_for_cond_data *)v;
- struct rb_monitor *mc = monitor_ptr(data->monitor);
- // cond.wait(monitor.mutex, timeout)
- VALUE signaled = rb_funcall(data->cond, rb_intern("wait"), 2, mc->mutex, data->timeout);
- return RTEST(signaled) ? Qtrue : Qfalse;
-}
-
-static VALUE
-monitor_enter_for_cond(VALUE v)
-{
- // assert(rb_mutex_owned_p(mc->mutex) == Qtrue)
- // but rb_mutex_owned_p is not exported...
-
- struct wait_for_cond_data *data = (struct wait_for_cond_data *)v;
- struct rb_monitor *mc = monitor_ptr(data->monitor);
- RB_OBJ_WRITE(data->monitor, &mc->owner, rb_fiber_current());
- mc->count = NUM2LONG(data->count);
- return Qnil;
-}
-
-static VALUE
-monitor_wait_for_cond(VALUE monitor, VALUE cond, VALUE timeout)
-{
- VALUE count = monitor_exit_for_cond(monitor);
- struct wait_for_cond_data data = {
- monitor,
- cond,
- timeout,
- count,
- };
-
- return rb_ensure(monitor_wait_for_cond_body, (VALUE)&data,
- monitor_enter_for_cond, (VALUE)&data);
-}
-
-static VALUE
-monitor_sync_body(VALUE monitor)
-{
- return rb_yield_values(0);
-}
-
-static VALUE
-monitor_sync_ensure(VALUE monitor)
-{
- return monitor_exit(monitor);
-}
-
-static VALUE
-monitor_synchronize(VALUE monitor)
-{
- monitor_enter(monitor);
- return rb_ensure(monitor_sync_body, monitor, monitor_sync_ensure, monitor);
-}
-
-void
-Init_monitor(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
-
- VALUE rb_cMonitor = rb_define_class("Monitor", rb_cObject);
- rb_define_alloc_func(rb_cMonitor, monitor_alloc);
-
- rb_define_method(rb_cMonitor, "try_enter", monitor_try_enter, 0);
- rb_define_method(rb_cMonitor, "enter", monitor_enter, 0);
- rb_define_method(rb_cMonitor, "exit", monitor_exit, 0);
- rb_define_method(rb_cMonitor, "synchronize", monitor_synchronize, 0);
-
- /* internal methods for MonitorMixin */
- rb_define_method(rb_cMonitor, "mon_locked?", monitor_locked_p, 0);
- rb_define_method(rb_cMonitor, "mon_check_owner", monitor_check_owner, 0);
- rb_define_method(rb_cMonitor, "mon_owned?", monitor_owned_p, 0);
-
- /* internal methods for MonitorMixin::ConditionVariable */
- rb_define_method(rb_cMonitor, "wait_for_cond", monitor_wait_for_cond, 2);
-}
diff --git a/ext/nkf/depend b/ext/nkf/depend
deleted file mode 100644
index 98afc5f201..0000000000
--- a/ext/nkf/depend
+++ /dev/null
@@ -1,181 +0,0 @@
-# BSD make needs "nkf.o: nkf.c" dependency BEFORE "nkf.o: nkf-utf8/nkf.c".
-# It seems BSD make searches the target for implicit rule in dependencies at first.
-nkf.o: nkf.c
-
-# AUTOGENERATED DEPENDENCIES START
-nkf.o: $(RUBY_EXTCONF_H)
-nkf.o: $(arch_hdrdir)/ruby/config.h
-nkf.o: $(hdrdir)/ruby/assert.h
-nkf.o: $(hdrdir)/ruby/backward.h
-nkf.o: $(hdrdir)/ruby/backward/2/assume.h
-nkf.o: $(hdrdir)/ruby/backward/2/attributes.h
-nkf.o: $(hdrdir)/ruby/backward/2/bool.h
-nkf.o: $(hdrdir)/ruby/backward/2/inttypes.h
-nkf.o: $(hdrdir)/ruby/backward/2/limits.h
-nkf.o: $(hdrdir)/ruby/backward/2/long_long.h
-nkf.o: $(hdrdir)/ruby/backward/2/stdalign.h
-nkf.o: $(hdrdir)/ruby/backward/2/stdarg.h
-nkf.o: $(hdrdir)/ruby/defines.h
-nkf.o: $(hdrdir)/ruby/encoding.h
-nkf.o: $(hdrdir)/ruby/intern.h
-nkf.o: $(hdrdir)/ruby/internal/abi.h
-nkf.o: $(hdrdir)/ruby/internal/anyargs.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-nkf.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-nkf.o: $(hdrdir)/ruby/internal/assume.h
-nkf.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-nkf.o: $(hdrdir)/ruby/internal/attr/artificial.h
-nkf.o: $(hdrdir)/ruby/internal/attr/cold.h
-nkf.o: $(hdrdir)/ruby/internal/attr/const.h
-nkf.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-nkf.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-nkf.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-nkf.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-nkf.o: $(hdrdir)/ruby/internal/attr/error.h
-nkf.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-nkf.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-nkf.o: $(hdrdir)/ruby/internal/attr/format.h
-nkf.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-nkf.o: $(hdrdir)/ruby/internal/attr/noalias.h
-nkf.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-nkf.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-nkf.o: $(hdrdir)/ruby/internal/attr/noinline.h
-nkf.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-nkf.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-nkf.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-nkf.o: $(hdrdir)/ruby/internal/attr/pure.h
-nkf.o: $(hdrdir)/ruby/internal/attr/restrict.h
-nkf.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-nkf.o: $(hdrdir)/ruby/internal/attr/warning.h
-nkf.o: $(hdrdir)/ruby/internal/attr/weakref.h
-nkf.o: $(hdrdir)/ruby/internal/cast.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-nkf.o: $(hdrdir)/ruby/internal/compiler_since.h
-nkf.o: $(hdrdir)/ruby/internal/config.h
-nkf.o: $(hdrdir)/ruby/internal/constant_p.h
-nkf.o: $(hdrdir)/ruby/internal/core.h
-nkf.o: $(hdrdir)/ruby/internal/core/rarray.h
-nkf.o: $(hdrdir)/ruby/internal/core/rbasic.h
-nkf.o: $(hdrdir)/ruby/internal/core/rbignum.h
-nkf.o: $(hdrdir)/ruby/internal/core/rclass.h
-nkf.o: $(hdrdir)/ruby/internal/core/rdata.h
-nkf.o: $(hdrdir)/ruby/internal/core/rfile.h
-nkf.o: $(hdrdir)/ruby/internal/core/rhash.h
-nkf.o: $(hdrdir)/ruby/internal/core/robject.h
-nkf.o: $(hdrdir)/ruby/internal/core/rregexp.h
-nkf.o: $(hdrdir)/ruby/internal/core/rstring.h
-nkf.o: $(hdrdir)/ruby/internal/core/rstruct.h
-nkf.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-nkf.o: $(hdrdir)/ruby/internal/ctype.h
-nkf.o: $(hdrdir)/ruby/internal/dllexport.h
-nkf.o: $(hdrdir)/ruby/internal/dosish.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/re.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/string.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-nkf.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-nkf.o: $(hdrdir)/ruby/internal/error.h
-nkf.o: $(hdrdir)/ruby/internal/eval.h
-nkf.o: $(hdrdir)/ruby/internal/event.h
-nkf.o: $(hdrdir)/ruby/internal/fl_type.h
-nkf.o: $(hdrdir)/ruby/internal/gc.h
-nkf.o: $(hdrdir)/ruby/internal/glob.h
-nkf.o: $(hdrdir)/ruby/internal/globals.h
-nkf.o: $(hdrdir)/ruby/internal/has/attribute.h
-nkf.o: $(hdrdir)/ruby/internal/has/builtin.h
-nkf.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-nkf.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-nkf.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-nkf.o: $(hdrdir)/ruby/internal/has/extension.h
-nkf.o: $(hdrdir)/ruby/internal/has/feature.h
-nkf.o: $(hdrdir)/ruby/internal/has/warning.h
-nkf.o: $(hdrdir)/ruby/internal/intern/array.h
-nkf.o: $(hdrdir)/ruby/internal/intern/bignum.h
-nkf.o: $(hdrdir)/ruby/internal/intern/class.h
-nkf.o: $(hdrdir)/ruby/internal/intern/compar.h
-nkf.o: $(hdrdir)/ruby/internal/intern/complex.h
-nkf.o: $(hdrdir)/ruby/internal/intern/cont.h
-nkf.o: $(hdrdir)/ruby/internal/intern/dir.h
-nkf.o: $(hdrdir)/ruby/internal/intern/enum.h
-nkf.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-nkf.o: $(hdrdir)/ruby/internal/intern/error.h
-nkf.o: $(hdrdir)/ruby/internal/intern/eval.h
-nkf.o: $(hdrdir)/ruby/internal/intern/file.h
-nkf.o: $(hdrdir)/ruby/internal/intern/hash.h
-nkf.o: $(hdrdir)/ruby/internal/intern/io.h
-nkf.o: $(hdrdir)/ruby/internal/intern/load.h
-nkf.o: $(hdrdir)/ruby/internal/intern/marshal.h
-nkf.o: $(hdrdir)/ruby/internal/intern/numeric.h
-nkf.o: $(hdrdir)/ruby/internal/intern/object.h
-nkf.o: $(hdrdir)/ruby/internal/intern/parse.h
-nkf.o: $(hdrdir)/ruby/internal/intern/proc.h
-nkf.o: $(hdrdir)/ruby/internal/intern/process.h
-nkf.o: $(hdrdir)/ruby/internal/intern/random.h
-nkf.o: $(hdrdir)/ruby/internal/intern/range.h
-nkf.o: $(hdrdir)/ruby/internal/intern/rational.h
-nkf.o: $(hdrdir)/ruby/internal/intern/re.h
-nkf.o: $(hdrdir)/ruby/internal/intern/ruby.h
-nkf.o: $(hdrdir)/ruby/internal/intern/select.h
-nkf.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-nkf.o: $(hdrdir)/ruby/internal/intern/signal.h
-nkf.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-nkf.o: $(hdrdir)/ruby/internal/intern/string.h
-nkf.o: $(hdrdir)/ruby/internal/intern/struct.h
-nkf.o: $(hdrdir)/ruby/internal/intern/thread.h
-nkf.o: $(hdrdir)/ruby/internal/intern/time.h
-nkf.o: $(hdrdir)/ruby/internal/intern/variable.h
-nkf.o: $(hdrdir)/ruby/internal/intern/vm.h
-nkf.o: $(hdrdir)/ruby/internal/interpreter.h
-nkf.o: $(hdrdir)/ruby/internal/iterator.h
-nkf.o: $(hdrdir)/ruby/internal/memory.h
-nkf.o: $(hdrdir)/ruby/internal/method.h
-nkf.o: $(hdrdir)/ruby/internal/module.h
-nkf.o: $(hdrdir)/ruby/internal/newobj.h
-nkf.o: $(hdrdir)/ruby/internal/scan_args.h
-nkf.o: $(hdrdir)/ruby/internal/special_consts.h
-nkf.o: $(hdrdir)/ruby/internal/static_assert.h
-nkf.o: $(hdrdir)/ruby/internal/stdalign.h
-nkf.o: $(hdrdir)/ruby/internal/stdbool.h
-nkf.o: $(hdrdir)/ruby/internal/symbol.h
-nkf.o: $(hdrdir)/ruby/internal/value.h
-nkf.o: $(hdrdir)/ruby/internal/value_type.h
-nkf.o: $(hdrdir)/ruby/internal/variable.h
-nkf.o: $(hdrdir)/ruby/internal/warning_push.h
-nkf.o: $(hdrdir)/ruby/internal/xmalloc.h
-nkf.o: $(hdrdir)/ruby/missing.h
-nkf.o: $(hdrdir)/ruby/onigmo.h
-nkf.o: $(hdrdir)/ruby/oniguruma.h
-nkf.o: $(hdrdir)/ruby/ruby.h
-nkf.o: $(hdrdir)/ruby/st.h
-nkf.o: $(hdrdir)/ruby/subst.h
-nkf.o: nkf-utf8/config.h
-nkf.o: nkf-utf8/nkf.c
-nkf.o: nkf-utf8/nkf.h
-nkf.o: nkf-utf8/utf8tbl.c
-nkf.o: nkf-utf8/utf8tbl.h
-nkf.o: nkf.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/nkf/extconf.rb b/ext/nkf/extconf.rb
deleted file mode 100644
index f41f6b11dc..0000000000
--- a/ext/nkf/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: false
-require 'mkmf'
-create_makefile('nkf')
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
deleted file mode 100644
index f52b755288..0000000000
--- a/ext/nkf/lib/kconv.rb
+++ /dev/null
@@ -1,283 +0,0 @@
-# frozen_string_literal: false
-#
-# kconv.rb - Kanji Converter.
-#
-# $Id$
-#
-# ----
-#
-# kconv.rb implements the Kconv class for Kanji Converter. Additionally,
-# some methods in String classes are added to allow easy conversion.
-#
-
-require 'nkf'
-
-#
-# Kanji Converter for Ruby.
-#
-module Kconv
- #
- # Public Constants
- #
-
- #Constant of Encoding
-
- # Auto-Detect
- AUTO = NKF::AUTO
- # ISO-2022-JP
- JIS = NKF::JIS
- # EUC-JP
- EUC = NKF::EUC
- # Shift_JIS
- SJIS = NKF::SJIS
- # BINARY
- BINARY = NKF::BINARY
- # NOCONV
- NOCONV = NKF::NOCONV
- # ASCII
- ASCII = NKF::ASCII
- # UTF-8
- UTF8 = NKF::UTF8
- # UTF-16
- UTF16 = NKF::UTF16
- # UTF-32
- UTF32 = NKF::UTF32
- # UNKNOWN
- UNKNOWN = NKF::UNKNOWN
-
- #
- # Public Methods
- #
-
- # call-seq:
- # Kconv.kconv(str, to_enc, from_enc=nil)
- #
- # Convert <code>str</code> to <code>to_enc</code>.
- # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
- 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
-
- ::NKF::nkf(opt, str)
- end
- module_function :kconv
-
- #
- # Encode to
- #
-
- # call-seq:
- # Kconv.tojis(str) => string
- #
- # Convert <code>str</code> to ISO-2022-JP
- def tojis(str)
- kconv(str, JIS)
- end
- module_function :tojis
-
- # call-seq:
- # Kconv.toeuc(str) => string
- #
- # Convert <code>str</code> to EUC-JP
- def toeuc(str)
- kconv(str, EUC)
- end
- module_function :toeuc
-
- # call-seq:
- # Kconv.tosjis(str) => string
- #
- # Convert <code>str</code> to Shift_JIS
- def tosjis(str)
- kconv(str, SJIS)
- end
- module_function :tosjis
-
- # call-seq:
- # Kconv.toutf8(str) => string
- #
- # Convert <code>str</code> to UTF-8
- def toutf8(str)
- kconv(str, UTF8)
- end
- module_function :toutf8
-
- # call-seq:
- # Kconv.toutf16(str) => string
- #
- # Convert <code>str</code> to UTF-16
- def toutf16(str)
- kconv(str, UTF16)
- 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
-
- # call-seq:
- # Kconv.tolocale => string
- #
- # Convert <code>self</code> to locale encoding
- def tolocale(str)
- kconv(str, Encoding.locale_charmap)
- end
- module_function :tolocale
-
- #
- # guess
- #
-
- # call-seq:
- # Kconv.guess(str) => encoding
- #
- # Guess input encoding by NKF.guess
- def guess(str)
- ::NKF::guess(str)
- end
- module_function :guess
-
- #
- # isEncoding
- #
-
- # call-seq:
- # Kconv.iseuc(str) => true or false
- #
- # Returns whether input encoding is EUC-JP or not.
- #
- # *Note* don't expect this return value is MatchData.
- def iseuc(str)
- str.dup.force_encoding(EUC).valid_encoding?
- end
- module_function :iseuc
-
- # call-seq:
- # Kconv.issjis(str) => true or false
- #
- # Returns whether input encoding is Shift_JIS or not.
- def issjis(str)
- str.dup.force_encoding(SJIS).valid_encoding?
- end
- module_function :issjis
-
- # call-seq:
- # Kconv.isjis(str) => true or false
- #
- # Returns whether input encoding is ISO-2022-JP or not.
- def isjis(str)
- /\A [\t\n\r\x20-\x7E]*
- (?:
- (?:\x1b \x28 I [\x21-\x7E]*
- |\x1b \x28 J [\x21-\x7E]*
- |\x1b \x24 @ (?:[\x21-\x7E]{2})*
- |\x1b \x24 B (?:[\x21-\x7E]{2})*
- |\x1b \x24 \x28 D (?:[\x21-\x7E]{2})*
- )*
- \x1b \x28 B [\t\n\r\x20-\x7E]*
- )*
- \z/nox =~ str.dup.force_encoding('BINARY') ? true : false
- end
- module_function :isjis
-
- # call-seq:
- # Kconv.isutf8(str) => true or false
- #
- # Returns whether input encoding is UTF-8 or not.
- def isutf8(str)
- str.dup.force_encoding(UTF8).valid_encoding?
- end
- module_function :isutf8
-end
-
-class String
- # call-seq:
- # String#kconv(to_enc, from_enc)
- #
- # Convert <code>self</code> to <code>to_enc</code>.
- # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
- def kconv(to_enc, from_enc=nil)
- from_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0]
- Kconv::kconv(self, to_enc, from_enc)
- end
-
- #
- # to Encoding
- #
-
- # call-seq:
- # String#tojis => string
- #
- # Convert <code>self</code> to ISO-2022-JP
- def tojis; Kconv.tojis(self) end
-
- # call-seq:
- # String#toeuc => string
- #
- # Convert <code>self</code> to EUC-JP
- def toeuc; Kconv.toeuc(self) end
-
- # call-seq:
- # String#tosjis => string
- #
- # Convert <code>self</code> to Shift_JIS
- def tosjis; Kconv.tosjis(self) end
-
- # call-seq:
- # String#toutf8 => string
- #
- # Convert <code>self</code> to UTF-8
- 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
-
- # call-seq:
- # String#tolocale => string
- #
- # Convert <code>self</code> to locale encoding
- def tolocale; Kconv.tolocale(self) end
-
- #
- # is Encoding
- #
-
- # call-seq:
- # String#iseuc => true or false
- #
- # Returns whether <code>self</code>'s encoding is EUC-JP or not.
- def iseuc; Kconv.iseuc(self) end
-
- # call-seq:
- # String#issjis => true or false
- #
- # Returns whether <code>self</code>'s encoding is Shift_JIS or not.
- def issjis; Kconv.issjis(self) end
-
- # call-seq:
- # String#isjis => true or false
- #
- # Returns whether <code>self</code>'s encoding is ISO-2022-JP or not.
- def isjis; Kconv.isjis(self) end
-
- # call-seq:
- # String#isutf8 => true or false
- #
- # Returns whether <code>self</code>'s encoding is UTF-8 or not.
- def isutf8; Kconv.isutf8(self) end
-end
diff --git a/ext/nkf/nkf-utf8/config.h b/ext/nkf/nkf-utf8/config.h
deleted file mode 100644
index 36898c0b4b..0000000000
--- a/ext/nkf/nkf-utf8/config.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
-/* UTF8 input and output */
-#define UTF8_INPUT_ENABLE
-#define UTF8_OUTPUT_ENABLE
-
-/* invert characters invalid in Shift_JIS to CP932 */
-#define SHIFTJIS_CP932
-
-/* fix input encoding when given by option */
-#define INPUT_CODE_FIX
-
-/* --overwrite option */
-/* by Satoru Takabayashi <ccsatoru@vega.aichi-u.ac.jp> */
-#define OVERWRITE
-
-/* --cap-input, --url-input option */
-#define INPUT_OPTION
-
-/* --numchar-input option */
-#define NUMCHAR_OPTION
-
-/* --debug, --no-output option */
-#define CHECK_OPTION
-
-/* JIS X0212 */
-#define X0212_ENABLE
-
-/* --exec-in, --exec-out option
- * require pipe, fork, execvp and so on.
- * please undef this on MS-DOS, MinGW
- * this is still buggy around child process
- */
-/* #define EXEC_IO */
-
-/* Unicode Normalization */
-#define UNICODE_NORMALIZATION
-
-/*
- * Select Default Output Encoding
- *
- */
-
-/* #define DEFAULT_CODE_JIS */
-/* #define DEFAULT_CODE_SJIS */
-/* #define DEFAULT_CODE_WINDOWS_31J */
-/* #define DEFAULT_CODE_EUC */
-/* #define DEFAULT_CODE_UTF8 */
-
-#endif /* _CONFIG_H_ */
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
deleted file mode 100644
index 6888a43918..0000000000
--- a/ext/nkf/nkf-utf8/nkf.c
+++ /dev/null
@@ -1,7205 +0,0 @@
-/*
- * Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
- * Copyright (c) 1996-2018, The nkf Project.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source distribution.
- */
-#define NKF_VERSION "2.1.5"
-#define NKF_RELEASE_DATE "2018-12-15"
-#define COPY_RIGHT \
- "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
- "Copyright (C) 1996-2018, The nkf Project."
-
-#include "config.h"
-#include "nkf.h"
-#include "utf8tbl.h"
-#ifdef __WIN32__
-#include <windows.h>
-#include <locale.h>
-#endif
-#if defined(__OS2__)
-# define INCL_DOS
-# define INCL_DOSERRORS
-# include <os2.h>
-#endif
-#include <assert.h>
-
-
-/* state of output_mode and input_mode
-
- c2 0 means ASCII
- JIS_X_0201_1976_K
- ISO_8859_1
- JIS_X_0208
- EOF all termination
- c1 32bit data
-
- */
-
-/* MIME ENCODE */
-
-#define FIXED_MIME 7
-#define STRICT_MIME 8
-
-/* byte order */
-enum byte_order {
- ENDIAN_BIG = 1,
- ENDIAN_LITTLE = 2,
- ENDIAN_2143 = 3,
- ENDIAN_3412 = 4
-};
-
-/* ASCII CODE */
-
-#define BS 0x08
-#define TAB 0x09
-#define LF 0x0a
-#define CR 0x0d
-#define ESC 0x1b
-#define SP 0x20
-#define DEL 0x7f
-#define SI 0x0f
-#define SO 0x0e
-#define SS2 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,
- ISO_2022_JP_2004,
- SHIFT_JIS,
- WINDOWS_31J,
- CP10001,
- EUC_JP,
- EUCJP_NKF,
- 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,
- BINARY,
- NKF_ENCODING_TABLE_SIZE,
- JIS_X_0201_1976_K = 0x1013, /* I */ /* JIS C 6220-1969 */
- /* JIS_X_0201_1976_R = 0x1014, */ /* J */ /* JIS C 6220-1969 */
- /* JIS_X_0208_1978 = 0x1040, */ /* @ */ /* JIS C 6226-1978 */
- /* JIS_X_0208_1983 = 0x1087, */ /* B */ /* JIS C 6226-1983 */
- JIS_X_0208 = 0x1168, /* @B */
- JIS_X_0212 = 0x1159, /* D */
- /* JIS_X_0213_2000_1 = 0x1228, */ /* O */
- JIS_X_0213_2 = 0x1229, /* P */
- JIS_X_0213_1 = 0x1233 /* Q */
-};
-
-static nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
-static nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
-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 void j_oconv(nkf_char c2, nkf_char c1);
-static void s_oconv(nkf_char c2, nkf_char c1);
-static void e_oconv(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);
-
-typedef const struct {
- const char *name;
- nkf_char (*iconv)(nkf_char c2, nkf_char c1, nkf_char c0);
- void (*oconv)(nkf_char c2, nkf_char c1);
-} nkf_native_encoding;
-
-nkf_native_encoding NkfEncodingASCII = { "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 const struct {
- int id;
- const char *name;
- nkf_native_encoding *base_encoding;
-} nkf_encoding;
-
-nkf_encoding nkf_encoding_table[] = {
- {ASCII, "US-ASCII", &NkfEncodingASCII},
- {ISO_8859_1, "ISO-8859-1", &NkfEncodingASCII},
- {ISO_2022_JP, "ISO-2022-JP", &NkfEncodingISO_2022_JP},
- {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},
- {ISO_2022_JP_2004, "ISO-2022-JP-2004", &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},
- {EUCJP_NKF, "eucJP-nkf", &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}
-};
-
-static const struct {
- const char *name;
- int id;
-} encoding_name_to_id_table[] = {
- {"US-ASCII", ASCII},
- {"ASCII", ASCII},
- {"646", ASCII},
- {"ROMAN8", ASCII},
- {"ISO-2022-JP", ISO_2022_JP},
- {"ISO2022JP-CP932", CP50220},
- {"CP50220", CP50220},
- {"CP50221", CP50221},
- {"CSISO2022JP", CP50221},
- {"CP50222", CP50222},
- {"ISO-2022-JP-1", ISO_2022_JP_1},
- {"ISO-2022-JP-3", ISO_2022_JP_3},
- {"ISO-2022-JP-2004", ISO_2022_JP_2004},
- {"SHIFT_JIS", SHIFT_JIS},
- {"SJIS", SHIFT_JIS},
- {"MS_Kanji", SHIFT_JIS},
- {"PCK", SHIFT_JIS},
- {"WINDOWS-31J", WINDOWS_31J},
- {"CSWINDOWS31J", WINDOWS_31J},
- {"CP932", WINDOWS_31J},
- {"MS932", WINDOWS_31J},
- {"CP10001", CP10001},
- {"EUCJP", EUC_JP},
- {"EUC-JP", EUC_JP},
- {"EUCJP-NKF", EUCJP_NKF},
- {"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_ENCIDX ISO_2022_JP
-#elif defined(DEFAULT_CODE_SJIS)
-#define DEFAULT_ENCIDX SHIFT_JIS
-#elif defined(DEFAULT_CODE_WINDOWS_31J)
-#define DEFAULT_ENCIDX WINDOWS_31J
-#elif defined(DEFAULT_CODE_EUC)
-#define DEFAULT_ENCIDX EUC_JP
-#elif defined(DEFAULT_CODE_UTF8)
-#define DEFAULT_ENCIDX UTF_8
-#endif
-
-
-#define is_alnum(c) \
- (('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
-
-/* I don't trust portablity of toupper */
-#define nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
-#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_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_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])
-#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 is_ibmext_in_sjis(c2) (CP932_TABLE_BEGIN <= c2 && c2 <= CP932_TABLE_END)
-#define nkf_byte_jisx0201_katakana_p(c) (SP <= c && c <= 0x5F)
-
-#define HOLD_SIZE 1024
-#if defined(INT_IS_SHORT)
-#define IOBUF_SIZE 2048
-#else
-#define IOBUF_SIZE 16384
-#endif
-
-#define DEFAULT_J 'B'
-#define DEFAULT_R 'B'
-
-
-#define GETA1 0x22
-#define GETA2 0x2e
-
-
-/* MIME preprocessor */
-
-#ifdef EASYWIN /*Easy Win */
-extern POINT _BufferSize;
-#endif
-
-struct input_code{
- const char *name;
- nkf_char stat;
- nkf_char score;
- nkf_char index;
- nkf_char buf[3];
- void (*status_func)(struct input_code *, nkf_char);
- nkf_char (*iconv_func)(nkf_char c2, nkf_char c1, nkf_char c0);
- int _file_stat;
-};
-
-static const char *input_codename = NULL; /* NULL: unestablished, "": BINARY */
-static nkf_encoding *input_encoding = NULL;
-static nkf_encoding *output_encoding = NULL;
-
-#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
-static int ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
-#ifdef UTF8_INPUT_ENABLE
-/* no NEC special, NEC-selected IBM extended and IBM extended characters */
-static int no_cp932ext_f = FALSE;
-/* ignore ZERO WIDTH NO-BREAK SPACE */
-static int no_best_fit_chars_f = FALSE;
-static int input_endian = ENDIAN_BIG;
-static int input_bom_f = FALSE;
-static nkf_char unicode_subchar = '?'; /* the regular substitution character */
-static void (*encode_fallback)(nkf_char c) = NULL;
-static void w_status(struct input_code *, nkf_char);
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
-static int output_bom_f = FALSE;
-static int output_endian = ENDIAN_BIG;
-#endif
-
-static void std_putc(nkf_char c);
-static nkf_char std_getc(FILE *f);
-static nkf_char std_ungetc(nkf_char c,FILE *f);
-
-static nkf_char broken_getc(FILE *f);
-static nkf_char broken_ungetc(nkf_char c,FILE *f);
-
-static nkf_char mime_getc(FILE *f);
-
-static void mime_putc(nkf_char c);
-
-/* buffers */
-
-#if !defined(PERL_XS) && !defined(WIN32DLL)
-static unsigned char stdibuf[IOBUF_SIZE];
-static unsigned char stdobuf[IOBUF_SIZE];
-#endif
-
-#define NKF_UNSPECIFIED (-TRUE)
-
-/* flags */
-static int unbuf_f = FALSE;
-static int estab_f = FALSE;
-static int nop_f = FALSE;
-static int binmode_f = TRUE; /* binary mode */
-static int rot_f = FALSE; /* rot14/43 mode */
-static int hira_f = FALSE; /* hira/kata henkan */
-static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
-static int mime_f = MIME_DECODE_DEFAULT; /* 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 = NKF_UNSPECIFIED; /* convert JIS X 0201 */
-static int iso2022jp_f = FALSE; /* replace non ISO-2022-JP with GETA */
-
-#ifdef UNICODE_NORMALIZATION
-static int nfc_f = FALSE;
-static nkf_char (*i_nfc_getc)(FILE *) = std_getc; /* input of ugetc */
-static nkf_char (*i_nfc_ungetc)(nkf_char c ,FILE *f) = std_ungetc;
-#endif
-
-#ifdef INPUT_OPTION
-static int cap_f = FALSE;
-static nkf_char (*i_cgetc)(FILE *) = std_getc; /* input of cgetc */
-static nkf_char (*i_cungetc)(nkf_char c ,FILE *f) = std_ungetc;
-
-static int url_f = FALSE;
-static nkf_char (*i_ugetc)(FILE *) = std_getc; /* input of ugetc */
-static nkf_char (*i_uungetc)(nkf_char c ,FILE *f) = std_ungetc;
-#endif
-
-#define PREFIX_EUCG3 NKF_INT32_C(0x8F00)
-#define CLASS_MASK NKF_INT32_C(0xFF000000)
-#define CLASS_UNICODE NKF_INT32_C(0x01000000)
-#define VALUE_MASK NKF_INT32_C(0x00FFFFFF)
-#define UNICODE_BMP_MAX NKF_INT32_C(0x0000FFFF)
-#define UNICODE_MAX NKF_INT32_C(0x0010FFFF)
-#define nkf_char_euc3_new(c) ((c) | PREFIX_EUCG3)
-#define nkf_char_unicode_new(c) ((c) | CLASS_UNICODE)
-#define nkf_char_unicode_p(c) ((c & CLASS_MASK) == CLASS_UNICODE)
-#define nkf_char_unicode_bmp_p(c) ((c & VALUE_MASK) <= UNICODE_BMP_MAX)
-#define nkf_char_unicode_value_p(c) ((c & VALUE_MASK) <= UNICODE_MAX)
-
-#define UTF16_TO_UTF32(lead, trail) (((lead) << 10) + (trail) - NKF_INT32_C(0x35FDC00))
-
-#ifdef NUMCHAR_OPTION
-static int numchar_f = FALSE;
-static nkf_char (*i_ngetc)(FILE *) = std_getc; /* input of ugetc */
-static nkf_char (*i_nungetc)(nkf_char c ,FILE *f) = std_ungetc;
-#endif
-
-#ifdef CHECK_OPTION
-static int noout_f = FALSE;
-static void no_putc(nkf_char c);
-static int 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 void set_input_codename(const char *codename);
-
-#ifdef EXEC_IO
-static int exec_f = 0;
-#endif
-
-#ifdef SHIFTJIS_CP932
-/* invert IBM extended characters to others */
-static int cp51932_f = FALSE;
-
-/* invert NEC-selected IBM extended characters to IBM extended characters */
-static int cp932inv_f = TRUE;
-
-/* static nkf_char cp932_conv(nkf_char c2, nkf_char c1); */
-#endif /* SHIFTJIS_CP932 */
-
-static int x0212_f = FALSE;
-static int x0213_f = FALSE;
-
-static unsigned char prefix_table[256];
-
-static void e_status(struct input_code *, nkf_char);
-static void s_status(struct input_code *, nkf_char);
-
-struct input_code input_code_list[] = {
- {"EUC-JP", 0, 0, 0, {0, 0, 0}, e_status, e_iconv, 0},
- {"Shift_JIS", 0, 0, 0, {0, 0, 0}, s_status, s_iconv, 0},
-#ifdef UTF8_INPUT_ENABLE
- {"UTF-8", 0, 0, 0, {0, 0, 0}, w_status, w_iconv, 0},
- {"UTF-16", 0, 0, 0, {0, 0, 0}, NULL, w_iconv16, 0},
- {"UTF-32", 0, 0, 0, {0, 0, 0}, NULL, w_iconv32, 0},
-#endif
- {NULL, 0, 0, 0, {0, 0, 0}, NULL, NULL, 0}
-};
-
-static int mimeout_mode = 0; /* 0, -1, 'Q', 'B', 1, 2 */
-static int base64_count = 0;
-
-/* X0208 -> ASCII converter */
-
-/* fold parameter */
-static int f_line = 0; /* chars in line */
-static int f_prev = 0;
-static int fold_preserve_f = FALSE; /* preserve new lines */
-static int fold_f = FALSE;
-static int fold_len = 0;
-
-/* options */
-static unsigned char kanji_intro = DEFAULT_J;
-static unsigned char ascii_intro = DEFAULT_R;
-
-/* Folding */
-
-#define FOLD_MARGIN 10
-#define DEFAULT_FOLD 60
-
-static int fold_margin = FOLD_MARGIN;
-
-/* process default */
-
-static nkf_char
-no_connection2(ARG_UNUSED nkf_char c2, ARG_UNUSED nkf_char c1, ARG_UNUSED nkf_char c0)
-{
- fprintf(stderr,"nkf internal module connection failure.\n");
- exit(EXIT_FAILURE);
- return 0; /* LINT */
-}
-
-static void
-no_connection(nkf_char c2, nkf_char c1)
-{
- no_connection2(c2,c1,0);
-}
-
-static nkf_char (*iconv)(nkf_char c2,nkf_char c1,nkf_char c0) = no_connection2;
-static void (*oconv)(nkf_char c2,nkf_char c1) = no_connection;
-
-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_eol_conv)(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;
-static void (*o_iso2022jp_check_conv)(nkf_char c2,nkf_char c1) = no_connection;
-
-/* static redirections */
-
-static void (*o_putc)(nkf_char c) = std_putc;
-
-static nkf_char (*i_getc)(FILE *f) = std_getc; /* general input */
-static nkf_char (*i_ungetc)(nkf_char c,FILE *f) =std_ungetc;
-
-static nkf_char (*i_bgetc)(FILE *) = std_getc; /* input of mgetc */
-static nkf_char (*i_bungetc)(nkf_char c ,FILE *f) = std_ungetc;
-
-static void (*o_mputc)(nkf_char c) = std_putc ; /* output of mputc */
-
-static nkf_char (*i_mgetc)(FILE *) = std_getc; /* input of mgetc */
-static nkf_char (*i_mungetc)(nkf_char c ,FILE *f) = std_ungetc;
-
-/* for strict mime */
-static nkf_char (*i_mgetc_buf)(FILE *) = std_getc; /* input of mgetc_buf */
-static nkf_char (*i_mungetc_buf)(nkf_char c,FILE *f) = std_ungetc;
-
-/* Global states */
-static int output_mode = ASCII; /* output kanji mode */
-static int input_mode = ASCII; /* input kanji mode */
-static int mime_decode_mode = FALSE; /* MIME mode B base64, Q hex */
-
-/* X0201 / X0208 conversion tables */
-
-/* X0201 kana conversion table */
-/* 90-9F A0-DF */
-static 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,
- 0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43,
- 0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26,
- 0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d,
- 0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35,
- 0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d,
- 0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46,
- 0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c,
- 0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52,
- 0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e,
- 0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62,
- 0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69,
- 0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d,
- 0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c,
- 0x00,0x00};
-
-
-/* X0201 kana conversion table for dakuten */
-/* 90-9F A0-DF */
-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,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x74,
- 0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e,
- 0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36,
- 0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e,
- 0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47,
- 0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53,
- 0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00};
-
-/* X0201 kana conversion table for han-dakuten */
-/* 90-9F A0-DF */
-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,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54,
- 0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00};
-
-/* X0201 kana to X0213 conversion table for han-dakuten */
-/* 90-9F A0-DF */
-static const unsigned char ev_x0213[]= {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x25,0x77,0x25,0x78,
- 0x25,0x79,0x25,0x7a,0x25,0x7b,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x25,0x7c,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x25,0x7d,0x00,0x00,
- 0x25,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00};
-
-
-/* X0208 kigou conversion table */
-/* 0x8140 - 0x819e */
-static const unsigned char fv[] = {
-
- 0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
- 0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
- 0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f,
- 0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27,
- 0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,
- 0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,
- 0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-} ;
-
-
-
-static int option_mode = 0;
-static int file_out_f = FALSE;
-#ifdef OVERWRITE
-static int overwrite_f = FALSE;
-static int preserve_time_f = FALSE;
-static int backup_f = FALSE;
-static char *backup_suffix = "";
-#endif
-
-static int eolmode_f = 0; /* CR, LF, CRLF */
-static int input_eol = 0; /* 0: unestablished, EOF: MIXED */
-static nkf_char prev_cr = 0; /* CR or 0 */
-#ifdef EASYWIN /*Easy Win */
-static int end_check;
-#endif /*Easy Win */
-
-static void *
-nkf_xmalloc(size_t size)
-{
- void *ptr;
-
- if (size == 0) size = 1;
-
- ptr = malloc(size);
- if (ptr == NULL) {
- perror("can't malloc");
- exit(EXIT_FAILURE);
- }
-
- return ptr;
-}
-
-static void *
-nkf_xrealloc(void *ptr, size_t size)
-{
- if (size == 0) size = 1;
-
- ptr = realloc(ptr, size);
- if (ptr == NULL) {
- perror("can't realloc");
- exit(EXIT_FAILURE);
- }
-
- return ptr;
-}
-
-#define nkf_xfree(ptr) free(ptr)
-
-static int
-nkf_str_caseeql(const char *src, const char *target)
-{
- int i;
- for (i = 0; src[i] && target[i]; i++) {
- if (nkf_toupper(src[i]) != nkf_toupper(target[i])) return FALSE;
- }
- if (src[i] || target[i]) return FALSE;
- else return TRUE;
-}
-
-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;
- if (name[0] == 'X' && *(name+1) == '-') name += 2;
- for (i = 0; encoding_name_to_id_table[i].id >= 0; i++) {
- if (nkf_str_caseeql(encoding_name_to_id_table[i].name, name)) {
- return encoding_name_to_id_table[i].id;
- }
- }
- return -1;
-}
-
-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)->base_encoding
-#define nkf_enc_to_iconv(enc) nkf_enc_to_base_encoding(enc)->iconv
-#define nkf_enc_to_oconv(enc) nkf_enc_to_base_encoding(enc)->oconv
-#define nkf_enc_asciicompat(enc) (\
- nkf_enc_to_base_encoding(enc) == &NkfEncodingASCII ||\
- nkf_enc_to_base_encoding(enc) == &NkfEncodingISO_2022_JP)
-#define nkf_enc_unicode_p(enc) (\
- nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_8 ||\
- nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_16 ||\
- nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_32)
-#define nkf_enc_cp5022x_p(enc) (\
- nkf_enc_to_index(enc) == CP50220 ||\
- nkf_enc_to_index(enc) == CP50221 ||\
- nkf_enc_to_index(enc) == CP50222)
-
-#ifdef DEFAULT_CODE_LOCALE
-static const char*
-nkf_locale_charmap(void)
-{
-#ifdef HAVE_LANGINFO_H
- return nl_langinfo(CODESET);
-#elif defined(__WIN32__)
- static char buf[16];
- sprintf(buf, "CP%d", GetACP());
- return buf;
-#elif defined(__OS2__)
-# if defined(INT_IS_SHORT)
- /* OS/2 1.x */
- return NULL;
-# else
- /* OS/2 32bit */
- static char buf[16];
- ULONG ulCP[1], ulncp;
- DosQueryCp(sizeof(ulCP), ulCP, &ulncp);
- if (ulCP[0] == 932 || ulCP[0] == 943)
- strcpy(buf, "Shift_JIS");
- else
- sprintf(buf, "CP%lu", ulCP[0]);
- return buf;
-# endif
-#endif
- return NULL;
-}
-
-static nkf_encoding*
-nkf_locale_encoding(void)
-{
- nkf_encoding *enc = 0;
- const char *encname = nkf_locale_charmap();
- if (encname)
- enc = nkf_enc_find(encname);
- return enc;
-}
-#endif /* DEFAULT_CODE_LOCALE */
-
-static nkf_encoding*
-nkf_utf8_encoding(void)
-{
- return &nkf_encoding_table[UTF_8];
-}
-
-static nkf_encoding*
-nkf_default_encoding(void)
-{
- nkf_encoding *enc = 0;
-#ifdef DEFAULT_CODE_LOCALE
- enc = nkf_locale_encoding();
-#elif defined(DEFAULT_ENCIDX)
- enc = nkf_enc_from_index(DEFAULT_ENCIDX);
-#endif
- if (!enc) enc = nkf_utf8_encoding();
- return enc;
-}
-
-typedef struct {
- long capa;
- long len;
- nkf_char *ptr;
-} nkf_buf_t;
-
-static nkf_buf_t *
-nkf_buf_new(int length)
-{
- nkf_buf_t *buf = nkf_xmalloc(sizeof(nkf_buf_t));
- buf->ptr = nkf_xmalloc(sizeof(nkf_char) * length);
- buf->capa = length;
- buf->len = 0;
- return buf;
-}
-
-#if 0
-static void
-nkf_buf_dispose(nkf_buf_t *buf)
-{
- nkf_xfree(buf->ptr);
- nkf_xfree(buf);
-}
-#endif
-
-#define nkf_buf_length(buf) ((buf)->len)
-#define nkf_buf_empty_p(buf) ((buf)->len == 0)
-
-static nkf_char
-nkf_buf_at(nkf_buf_t *buf, int index)
-{
- assert(index <= buf->len);
- return buf->ptr[index];
-}
-
-static void
-nkf_buf_clear(nkf_buf_t *buf)
-{
- buf->len = 0;
-}
-
-static void
-nkf_buf_push(nkf_buf_t *buf, nkf_char c)
-{
- if (buf->capa <= buf->len) {
- exit(EXIT_FAILURE);
- }
- buf->ptr[buf->len++] = c;
-}
-
-static nkf_char
-nkf_buf_pop(nkf_buf_t *buf)
-{
- assert(!nkf_buf_empty_p(buf));
- return buf->ptr[--buf->len];
-}
-
-/* Normalization Form C */
-#ifndef PERL_XS
-#ifdef WIN32DLL
-#define fprintf dllprintf
-#endif
-
-static void
-version(void)
-{
- fprintf(HELP_OUTPUT,"Network Kanji Filter Version " NKF_VERSION " (" NKF_RELEASE_DATE ") \n" COPY_RIGHT "\n");
-}
-
-static void
-usage(void)
-{
- fprintf(HELP_OUTPUT,
- "Usage: nkf -[flags] [--] [in file] .. [out file for -O flag]\n"
-#ifdef UTF8_OUTPUT_ENABLE
- " j/s/e/w Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
- " UTF options is -w[8[0],{16,32}[{B,L}[0]]]\n"
-#else
-#endif
-#ifdef UTF8_INPUT_ENABLE
- " J/S/E/W Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
- " UTF option is -W[8,[16,32][B,L]]\n"
-#else
- " J/S/E Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
-#endif
- );
- fprintf(HELP_OUTPUT,
- " m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:nonstrict,0:no decode]\n"
- " M[BQ] MIME encode [B:base64 Q:quoted]\n"
- " 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"
- " 1: Kankaku to one space 2: to two spaces 3: HTML Entity\n"
- " 4: JISX0208 Katakana to JISX0201 Katakana\n"
- " X,x Convert Halfwidth Katakana to Fullwidth or preserve it\n"
- );
- fprintf(HELP_OUTPUT,
- " O Output to File (DEFAULT 'nkf.out')\n"
- " L[uwm] Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n"
- );
- fprintf(HELP_OUTPUT,
- " --ic=<encoding> Specify the input encoding\n"
- " --oc=<encoding> Specify the output encoding\n"
- " --hiragana --katakana Hiragana/Katakana Conversion\n"
- " --katakana-hiragana Converts each other\n"
- );
- fprintf(HELP_OUTPUT,
-#ifdef INPUT_OPTION
- " --{cap, url}-input Convert hex after ':' or '%%'\n"
-#endif
-#ifdef NUMCHAR_OPTION
- " --numchar-input Convert Unicode Character Reference\n"
-#endif
-#ifdef UTF8_INPUT_ENABLE
- " --fb-{skip, html, xml, perl, java, subchar}\n"
- " Specify unassigned character's replacement\n"
-#endif
- );
- fprintf(HELP_OUTPUT,
-#ifdef OVERWRITE
- " --in-place[=SUF] Overwrite original files\n"
- " --overwrite[=SUF] Preserve timestamp of original files\n"
-#endif
- " -g --guess Guess the input code\n"
- " -v --version Print the version\n"
- " --help/-V Print this help / configuration\n"
- );
- version();
-}
-
-static void
-show_configuration(void)
-{
- fprintf(HELP_OUTPUT,
- "Summary of my nkf " NKF_VERSION " (" NKF_RELEASE_DATE ") configuration:\n"
- " Compile-time options:\n"
- " Compiled at: " __DATE__ " " __TIME__ "\n"
- );
- fprintf(HELP_OUTPUT,
- " Default output encoding: "
-#ifdef DEFAULT_CODE_LOCALE
- "LOCALE (%s)\n", nkf_enc_name(nkf_default_encoding())
-#elif defined(DEFAULT_ENCIDX)
- "CONFIG (%s)\n", nkf_enc_name(nkf_default_encoding())
-#else
- "NONE\n"
-#endif
- );
- fprintf(HELP_OUTPUT,
- " Default output end of line: "
-#if DEFAULT_NEWLINE == CR
- "CR"
-#elif DEFAULT_NEWLINE == CRLF
- "CRLF"
-#else
- "LF"
-#endif
- "\n"
- " Decode MIME encoded string: "
-#if MIME_DECODE_DEFAULT
- "ON"
-#else
- "OFF"
-#endif
- "\n"
- " Convert JIS X 0201 Katakana: "
-#if X0201_DEFAULT
- "ON"
-#else
- "OFF"
-#endif
- "\n"
- " --help, --version output: "
-#if HELP_OUTPUT_HELP_OUTPUT
- "HELP_OUTPUT"
-#else
- "STDOUT"
-#endif
- "\n");
-}
-#endif /*PERL_XS*/
-
-#ifdef OVERWRITE
-static char*
-get_backup_filename(const char *suffix, const char *filename)
-{
- char *backup_filename;
- int asterisk_count = 0;
- int i, j;
- int filename_length = strlen(filename);
-
- for(i = 0; suffix[i]; i++){
- if(suffix[i] == '*') asterisk_count++;
- }
-
- if(asterisk_count){
- backup_filename = nkf_xmalloc(strlen(suffix) + (asterisk_count * (filename_length - 1)) + 1);
- for(i = 0, j = 0; suffix[i];){
- if(suffix[i] == '*'){
- backup_filename[j] = '\0';
- strncat(backup_filename, filename, filename_length);
- i++;
- j += filename_length;
- }else{
- backup_filename[j++] = suffix[i++];
- }
- }
- backup_filename[j] = '\0';
- }else{
- j = filename_length + strlen(suffix);
- backup_filename = nkf_xmalloc(j + 1);
- strcpy(backup_filename, filename);
- strcat(backup_filename, suffix);
- backup_filename[j] = '\0';
- }
- return backup_filename;
-}
-#endif
-
-#ifdef UTF8_INPUT_ENABLE
-static void
-nkf_each_char_to_hex(void (*f)(nkf_char c2,nkf_char c1), nkf_char c)
-{
- int shift = 20;
- c &= VALUE_MASK;
- while(shift >= 0){
- if(c >= NKF_INT32_C(1)<<shift){
- while(shift >= 0){
- (*f)(0, bin2hex(c>>shift));
- shift -= 4;
- }
- }else{
- shift -= 4;
- }
- }
- return;
-}
-
-static void
-encode_fallback_html(nkf_char c)
-{
- (*oconv)(0, '&');
- (*oconv)(0, '#');
- c &= VALUE_MASK;
- if(c >= NKF_INT32_C(1000000))
- (*oconv)(0, 0x30+(c/NKF_INT32_C(1000000))%10);
- if(c >= NKF_INT32_C(100000))
- (*oconv)(0, 0x30+(c/NKF_INT32_C(100000) )%10);
- if(c >= 10000)
- (*oconv)(0, 0x30+(c/10000 )%10);
- if(c >= 1000)
- (*oconv)(0, 0x30+(c/1000 )%10);
- if(c >= 100)
- (*oconv)(0, 0x30+(c/100 )%10);
- if(c >= 10)
- (*oconv)(0, 0x30+(c/10 )%10);
- if(c >= 0)
- (*oconv)(0, 0x30+ c %10);
- (*oconv)(0, ';');
- return;
-}
-
-static void
-encode_fallback_xml(nkf_char c)
-{
- (*oconv)(0, '&');
- (*oconv)(0, '#');
- (*oconv)(0, 'x');
- nkf_each_char_to_hex(oconv, c);
- (*oconv)(0, ';');
- return;
-}
-
-static void
-encode_fallback_java(nkf_char c)
-{
- (*oconv)(0, '\\');
- c &= VALUE_MASK;
- if(!nkf_char_unicode_bmp_p(c)){
- int high = (c >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
- int low = (c & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
- (*oconv)(0, 'u');
- (*oconv)(0, bin2hex(high>>12));
- (*oconv)(0, bin2hex(high>> 8));
- (*oconv)(0, bin2hex(high>> 4));
- (*oconv)(0, bin2hex(high ));
- (*oconv)(0, '\\');
- (*oconv)(0, 'u');
- (*oconv)(0, bin2hex(low>>12));
- (*oconv)(0, bin2hex(low>> 8));
- (*oconv)(0, bin2hex(low>> 4));
- (*oconv)(0, bin2hex(low ));
- }else{
- (*oconv)(0, 'u');
- (*oconv)(0, bin2hex(c>>12));
- (*oconv)(0, bin2hex(c>> 8));
- (*oconv)(0, bin2hex(c>> 4));
- (*oconv)(0, bin2hex(c ));
- }
- return;
-}
-
-static void
-encode_fallback_perl(nkf_char c)
-{
- (*oconv)(0, '\\');
- (*oconv)(0, 'x');
- (*oconv)(0, '{');
- nkf_each_char_to_hex(oconv, c);
- (*oconv)(0, '}');
- return;
-}
-
-static void
-encode_fallback_subchar(nkf_char c)
-{
- c = unicode_subchar;
- (*oconv)((c>>8)&0xFF, c&0xFF);
- return;
-}
-#endif
-
-static const struct {
- const char *name;
- const char *alias;
-} long_option[] = {
- {"ic=", ""},
- {"oc=", ""},
- {"base64","jMB"},
- {"euc","e"},
- {"euc-input","E"},
- {"fj","jm"},
- {"help",""},
- {"jis","j"},
- {"jis-input","J"},
- {"mac","sLm"},
- {"mime","jM"},
- {"mime-input","m"},
- {"msdos","sLw"},
- {"sjis","s"},
- {"sjis-input","S"},
- {"unix","eLu"},
- {"version","v"},
- {"windows","sLw"},
- {"hiragana","h1"},
- {"katakana","h2"},
- {"katakana-hiragana","h3"},
- {"guess=", ""},
- {"guess", "g2"},
- {"cp932", ""},
- {"no-cp932", ""},
-#ifdef X0212_ENABLE
- {"x0212", ""},
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- {"utf8", "w"},
- {"utf16", "w16"},
- {"ms-ucs-map", ""},
- {"fb-skip", ""},
- {"fb-html", ""},
- {"fb-xml", ""},
- {"fb-perl", ""},
- {"fb-java", ""},
- {"fb-subchar", ""},
- {"fb-subchar=", ""},
-#endif
-#ifdef UTF8_INPUT_ENABLE
- {"utf8-input", "W"},
- {"utf16-input", "W16"},
- {"no-cp932ext", ""},
- {"no-best-fit-chars",""},
-#endif
-#ifdef UNICODE_NORMALIZATION
- {"utf8mac-input", ""},
-#endif
-#ifdef OVERWRITE
- {"overwrite", ""},
- {"overwrite=", ""},
- {"in-place", ""},
- {"in-place=", ""},
-#endif
-#ifdef INPUT_OPTION
- {"cap-input", ""},
- {"url-input", ""},
-#endif
-#ifdef NUMCHAR_OPTION
- {"numchar-input", ""},
-#endif
-#ifdef CHECK_OPTION
- {"no-output", ""},
- {"debug", ""},
-#endif
-#ifdef SHIFTJIS_CP932
- {"cp932inv", ""},
-#endif
-#ifdef EXEC_IO
- {"exec-in", ""},
- {"exec-out", ""},
-#endif
- {"prefix=", ""},
-};
-
-static void
-set_input_encoding(nkf_encoding *enc)
-{
- switch (nkf_enc_to_index(enc)) {
- case ISO_8859_1:
- iso8859_f = TRUE;
- break;
- case CP50221:
- case CP50222:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
- case CP50220:
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case ISO_2022_JP_1:
- x0212_f = TRUE;
- break;
- case ISO_2022_JP_3:
- x0212_f = TRUE;
- x0213_f = TRUE;
- break;
- case ISO_2022_JP_2004:
- x0212_f = TRUE;
- x0213_f = TRUE;
- break;
- case SHIFT_JIS:
- break;
- case WINDOWS_31J:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- break;
- case CP10001:
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP10001;
-#endif
- break;
- case EUC_JP:
- break;
- case EUCJP_NKF:
- break;
- case CP51932:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case EUCJP_MS:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_MS;
-#endif
- break;
- case EUCJP_ASCII:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
- break;
- case SHIFT_JISX0213:
- case SHIFT_JIS_2004:
- x0213_f = TRUE;
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
- case EUC_JISX0213:
- case EUC_JIS_2004:
- x0213_f = TRUE;
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
-#endif
- break;
-#ifdef UTF8_INPUT_ENABLE
-#ifdef UNICODE_NORMALIZATION
- case UTF8_MAC:
- nfc_f = TRUE;
- break;
-#endif
- case UTF_16:
- case UTF_16BE:
- case UTF_16BE_BOM:
- input_endian = ENDIAN_BIG;
- break;
- case UTF_16LE:
- case UTF_16LE_BOM:
- input_endian = ENDIAN_LITTLE;
- break;
- case UTF_32:
- case UTF_32BE:
- case UTF_32BE_BOM:
- input_endian = ENDIAN_BIG;
- break;
- case UTF_32LE:
- case UTF_32LE_BOM:
- input_endian = ENDIAN_LITTLE;
- break;
-#endif
- }
-}
-
-static void
-set_output_encoding(nkf_encoding *enc)
-{
- switch (nkf_enc_to_index(enc)) {
- case CP50220:
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case CP50221:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case ISO_2022_JP:
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
- case ISO_2022_JP_1:
- x0212_f = TRUE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
- case ISO_2022_JP_3:
- case ISO_2022_JP_2004:
- x0212_f = TRUE;
- x0213_f = TRUE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
- case SHIFT_JIS:
- break;
- case WINDOWS_31J:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case CP10001:
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP10001;
-#endif
- break;
- case EUC_JP:
- x0212_f = TRUE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
- break;
- case EUCJP_NKF:
- x0212_f = FALSE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
- break;
- case CP51932:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- break;
- case EUCJP_MS:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
- x0212_f = TRUE;
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_MS;
-#endif
- break;
- case EUCJP_ASCII:
- if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
- x0212_f = TRUE;
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
- break;
- case SHIFT_JISX0213:
- case SHIFT_JIS_2004:
- x0213_f = TRUE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
- case EUC_JISX0213:
- case EUC_JIS_2004:
- x0212_f = TRUE;
- x0213_f = TRUE;
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f == TRUE) cp932inv_f = FALSE;
-#endif
- break;
-#ifdef UTF8_OUTPUT_ENABLE
- case UTF_8_BOM:
- output_bom_f = TRUE;
- break;
- case UTF_16:
- case UTF_16BE_BOM:
- output_bom_f = TRUE;
- break;
- case UTF_16LE:
- output_endian = ENDIAN_LITTLE;
- output_bom_f = FALSE;
- break;
- case UTF_16LE_BOM:
- output_endian = ENDIAN_LITTLE;
- output_bom_f = TRUE;
- break;
- case UTF_32:
- case UTF_32BE_BOM:
- output_bom_f = TRUE;
- break;
- case UTF_32LE:
- output_endian = ENDIAN_LITTLE;
- output_bom_f = FALSE;
- break;
- case UTF_32LE_BOM:
- output_endian = ENDIAN_LITTLE;
- output_bom_f = TRUE;
- break;
-#endif
- }
-}
-
-static struct input_code*
-find_inputcode_byfunc(nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0))
-{
- if (iconv_func){
- struct input_code *p = input_code_list;
- while (p->name){
- if (iconv_func == p->iconv_func){
- return p;
- }
- p++;
- }
- }
- return 0;
-}
-
-static void
-set_iconv(nkf_char f, nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0))
-{
-#ifdef INPUT_CODE_FIX
- if (f || !input_encoding)
-#endif
- if (estab_f != f){
- estab_f = f;
- }
-
- if (iconv_func
-#ifdef INPUT_CODE_FIX
- && (f == -TRUE || !input_encoding) /* -TRUE means "FORCE" */
-#endif
- ){
- iconv = iconv_func;
- }
-#ifdef CHECK_OPTION
- if (estab_f && iconv_for_check != iconv){
- struct input_code *p = find_inputcode_byfunc(iconv);
- if (p){
- set_input_codename(p->name);
- debug(p->name);
- }
- iconv_for_check = iconv;
- }
-#endif
-}
-
-#ifdef X0212_ENABLE
-static nkf_char
-x0212_shift(nkf_char c)
-{
- nkf_char ret = c;
- c &= 0x7f;
- if (is_eucg3(ret)){
- if (0x75 <= c && c <= 0x7f){
- ret = c + (0x109 - 0x75);
- }
- }else{
- if (0x75 <= c && c <= 0x7f){
- ret = c + (0x113 - 0x75);
- }
- }
- return ret;
-}
-
-
-static nkf_char
-x0212_unshift(nkf_char c)
-{
- nkf_char ret = c;
- if (0x7f <= c && c <= 0x88){
- ret = c + (0x75 - 0x7f);
- }else if (0x89 <= c && c <= 0x92){
- ret = PREFIX_EUCG3 | 0x80 | (c + (0x75 - 0x89));
- }
- return ret;
-}
-#endif /* X0212_ENABLE */
-
-static int
-is_x0213_2_in_x0212(nkf_char c1)
-{
- static const char x0213_2_table[] =
- {0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1};
- int ku = c1 - 0x20;
- if (ku <= 15)
- return x0213_2_table[ku]; /* 1, 3-5, 8, 12-15 */
- if (78 <= ku && ku <= 94)
- return 1;
- return 0;
-}
-
-static nkf_char
-e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
-{
- nkf_char ndx;
- if (is_eucg3(c2)){
- ndx = c2 & 0x7f;
- if (x0213_f && is_x0213_2_in_x0212(ndx)){
- if((0x21 <= ndx && ndx <= 0x2F)){
- if (p2) *p2 = ((ndx - 1) >> 1) + 0xec - ndx / 8 * 3;
- if (p1) *p1 = c1 + ((ndx & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
- return 0;
- }else if(0x6E <= ndx && ndx <= 0x7E){
- if (p2) *p2 = ((ndx - 1) >> 1) + 0xbe;
- if (p1) *p1 = c1 + ((ndx & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
- return 0;
- }
- return 1;
- }
-#ifdef X0212_ENABLE
- else if(nkf_isgraph(ndx)){
- nkf_char val = 0;
- const unsigned short *ptr;
- ptr = x0212_shiftjis[ndx - 0x21];
- if (ptr){
- val = ptr[(c1 & 0x7f) - 0x21];
- }
- if (val){
- c2 = val >> 8;
- c1 = val & 0xff;
- if (p2) *p2 = c2;
- if (p1) *p1 = c1;
- return 0;
- }
- c2 = x0212_shift(c2);
- }
-#endif /* X0212_ENABLE */
- }
- if(0x7F < c2) return 1;
- if (p2) *p2 = ((c2 - 1) >> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1);
- if (p1) *p1 = c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
- return 0;
-}
-
-static 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} };
- if (0xFC < c1) return 1;
-#ifdef SHIFTJIS_CP932
- if (!cp932inv_f && !x0213_f && is_ibmext_in_sjis(c2)){
- val = shiftjis_cp932[c2 - CP932_TABLE_BEGIN][c1 - 0x40];
- if (val){
- c2 = val >> 8;
- c1 = val & 0xff;
- }
- }
- if (cp932inv_f
- && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
- val = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
- if (val){
- c2 = val >> 8;
- c1 = val & 0xff;
- }
- }
-#endif /* SHIFTJIS_CP932 */
-#ifdef X0212_ENABLE
- if (!x0213_f && is_ibmext_in_sjis(c2)){
- val = shiftjis_x0212[c2 - 0xfa][c1 - 0x40];
- if (val){
- if (val > 0x7FFF){
- c2 = PREFIX_EUCG3 | ((val >> 8) & 0x7f);
- c1 = val & 0xff;
- }else{
- c2 = val >> 8;
- c1 = val & 0xff;
- }
- if (p2) *p2 = c2;
- if (p1) *p1 = c1;
- return 0;
- }
- }
-#endif
- if(c2 >= 0x80){
- if(x0213_f && c2 >= 0xF0){
- if(c2 <= 0xF3 || (c2 == 0xF4 && c1 < 0x9F)){ /* k=1, 3<=k<=5, k=8, 12<=k<=15 */
- c2 = PREFIX_EUCG3 | 0x20 | shift_jisx0213_s1a3_table[c2 - 0xF0][0x9E < c1];
- }else{ /* 78<=k<=94 */
- c2 = PREFIX_EUCG3 | (c2 * 2 - 0x17B);
- if (0x9E < c1) c2++;
- }
- }else{
-#define SJ0162 0x00e1 /* 01 - 62 ku offset */
-#define SJ6394 0x0161 /* 63 - 94 ku offset */
- c2 = c2 + c2 - ((c2 <= 0x9F) ? SJ0162 : SJ6394);
- if (0x9E < c1) c2++;
- }
- if (c1 < 0x9F)
- c1 = c1 - ((c1 > DEL) ? SP : 0x1F);
- else {
- c1 = c1 - 0x7E;
- }
- }
-
-#ifdef X0212_ENABLE
- c2 = x0212_unshift(c2);
-#endif
- if (p2) *p2 = c2;
- if (p1) *p1 = c1;
- return 0;
-}
-
-#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
-static void
-nkf_unicode_to_utf8(nkf_char val, nkf_char *p1, nkf_char *p2, nkf_char *p3, nkf_char *p4)
-{
- val &= VALUE_MASK;
- if (val < 0x80){
- *p1 = val;
- *p2 = 0;
- *p3 = 0;
- *p4 = 0;
- }else if (val < 0x800){
- *p1 = 0xc0 | (val >> 6);
- *p2 = 0x80 | (val & 0x3f);
- *p3 = 0;
- *p4 = 0;
- } else if (nkf_char_unicode_bmp_p(val)) {
- *p1 = 0xe0 | (val >> 12);
- *p2 = 0x80 | ((val >> 6) & 0x3f);
- *p3 = 0x80 | ( val & 0x3f);
- *p4 = 0;
- } else if (nkf_char_unicode_value_p(val)) {
- *p1 = 0xf0 | (val >> 18);
- *p2 = 0x80 | ((val >> 12) & 0x3f);
- *p3 = 0x80 | ((val >> 6) & 0x3f);
- *p4 = 0x80 | ( val & 0x3f);
- } else {
- *p1 = 0;
- *p2 = 0;
- *p3 = 0;
- *p4 = 0;
- }
-}
-
-static nkf_char
-nkf_utf8_to_unicode(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc;
- if (c1 <= 0x7F) {
- /* single byte */
- wc = c1;
- }
- else if (c1 <= 0xC1) {
- /* trail byte or invalid */
- return -1;
- }
- else if (c1 <= 0xDF) {
- /* 2 bytes */
- wc = (c1 & 0x1F) << 6;
- wc |= (c2 & 0x3F);
- }
- else if (c1 <= 0xEF) {
- /* 3 bytes */
- wc = (c1 & 0x0F) << 12;
- wc |= (c2 & 0x3F) << 6;
- wc |= (c3 & 0x3F);
- }
- else if (c2 <= 0xF4) {
- /* 4 bytes */
- wc = (c1 & 0x0F) << 18;
- wc |= (c2 & 0x3F) << 12;
- wc |= (c3 & 0x3F) << 6;
- wc |= (c4 & 0x3F);
- }
- else {
- return -1;
- }
- return wc;
-}
-#endif
-
-#ifdef UTF8_INPUT_ENABLE
-static int
-unicode_to_jis_common2(nkf_char c1, nkf_char c0,
- const unsigned short *const *pp, nkf_char psize,
- nkf_char *p2, nkf_char *p1)
-{
- nkf_char c2;
- const unsigned short *p;
- unsigned short val;
-
- if (pp == 0) return 1;
-
- c1 -= 0x80;
- if (c1 < 0 || psize <= c1) return 1;
- p = pp[c1];
- if (p == 0) return 1;
-
- c0 -= 0x80;
- if (c0 < 0 || sizeof_utf8_to_euc_C2 <= c0) return 1;
- val = p[c0];
- if (val == 0) return 1;
- if (no_cp932ext_f && (
- (val>>8) == 0x2D || /* NEC special characters */
- val > NKF_INT32_C(0xF300) /* IBM extended characters */
- )) return 1;
-
- c2 = val >> 8;
- if (val > 0x7FFF){
- c2 &= 0x7f;
- c2 |= PREFIX_EUCG3;
- }
- if (c2 == SO) c2 = JIS_X_0201_1976_K;
- c1 = val & 0xFF;
- if (p2) *p2 = c2;
- if (p1) *p1 = c1;
- return 0;
-}
-
-static int
-unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
-{
- const unsigned short *const *pp;
- const unsigned short *const *const *ppp;
- static const char 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[] =
- {1, 1, 1, 1, 1, 1, 1, 1, 1, 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[] =
- {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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[] =
- {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, 0, 1, 1, 1, 1, 1, 1, 1, 1};
- nkf_char ret = 0;
-
- if(c2 < 0x80){
- *p2 = 0;
- *p1 = c2;
- }else if(c2 < 0xe0){
- if(no_best_fit_chars_f){
- if(ms_ucs_map_f == UCS_MAP_CP932){
- switch(c2){
- case 0xC2:
- if(no_best_fit_chars_table_932_C2[c1&0x3F]) return 1;
- break;
- case 0xC3:
- if(no_best_fit_chars_table_932_C3[c1&0x3F]) return 1;
- break;
- }
- }else if(!cp932inv_f){
- switch(c2){
- case 0xC2:
- if(no_best_fit_chars_table_C2[c1&0x3F]) return 1;
- break;
- case 0xC3:
- if(no_best_fit_chars_table_932_C3[c1&0x3F]) return 1;
- break;
- }
- }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 :
- x0213_f ? utf8_to_euc_2bytes_x0213 :
- utf8_to_euc_2bytes;
- ret = unicode_to_jis_common2(c2, c1, pp, sizeof_utf8_to_euc_2bytes, p2, p1);
- }else if(c0 < 0xF0){
- if(no_best_fit_chars_f){
- if(ms_ucs_map_f == UCS_MAP_CP932){
- if(c2 == 0xE3 && c1 == 0x82 && c0 == 0x94) return 1;
- }else if(ms_ucs_map_f == UCS_MAP_MS){
- switch(c2){
- case 0xE2:
- switch(c1){
- case 0x80:
- if(c0 == 0x94 || c0 == 0x96 || c0 == 0xBE) return 1;
- break;
- case 0x88:
- if(c0 == 0x92) return 1;
- break;
- }
- break;
- case 0xE3:
- 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:
- switch(c1){
- case 0x80:
- if(c0 == 0x95) return 1;
- break;
- case 0x88:
- if(c0 == 0xA5) return 1;
- break;
- }
- break;
- case 0xEF:
- switch(c1){
- case 0xBC:
- if(c0 == 0x8D) return 1;
- break;
- case 0xBD:
- if(c0 == 0x9E && !cp932inv_f) return 1;
- break;
- case 0xBF:
- if(0xA0 <= c0 && c0 <= 0xA5) return 1;
- break;
- }
- break;
- }
- }
- }
- 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 :
- x0213_f ? utf8_to_euc_3bytes_x0213 :
- utf8_to_euc_3bytes;
- ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
- }else return -1;
-#ifdef SHIFTJIS_CP932
- if (!ret&& is_eucg3(*p2)) {
- if (cp932inv_f) {
- if (encode_fallback) ret = 1;
- }
- else {
- nkf_char s2, s1;
- if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
- s2e_conv(s2, s1, p2, p1);
- }else{
- ret = 1;
- }
- }
- }
-#endif
- return ret;
-}
-
-#ifdef UTF8_OUTPUT_ENABLE
-#define X0213_SURROGATE_FIND(tbl, size, euc) do { \
- int i; \
- for (i = 0; i < size; i++) \
- if (tbl[i][0] == euc) { \
- low = tbl[i][2]; \
- break; \
- } \
- } while (0)
-
-static nkf_char
-e2w_conv(nkf_char c2, nkf_char c1)
-{
- const unsigned short *p;
-
- if (c2 == JIS_X_0201_1976_K) {
- if (ms_ucs_map_f == UCS_MAP_CP10001) {
- switch (c1) {
- case 0x20:
- return 0xA0;
- case 0x7D:
- return 0xA9;
- }
- }
- p = euc_to_utf8_1byte;
-#ifdef X0212_ENABLE
- } else if (is_eucg3(c2)){
- if(ms_ucs_map_f == UCS_MAP_ASCII&& c2 == NKF_INT32_C(0x8F22) && c1 == 0x43){
- return 0xA6;
- }
- c2 = (c2&0x7f) - 0x21;
- if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
- p =
- x0213_f ? x0212_to_utf8_2bytes_x0213[c2] :
- x0212_to_utf8_2bytes[c2];
- else
- return 0;
-#endif
- } else {
- c2 &= 0x7f;
- c2 = (c2&0x7f) - 0x21;
- if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
- p =
- x0213_f ? euc_to_utf8_2bytes_x0213[c2] :
- 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];
- else
- return 0;
- }
- if (!p) return 0;
- c1 = (c1 & 0x7f) - 0x21;
- if (0<=c1 && c1<sizeof_euc_to_utf8_1byte) {
- nkf_char val = p[c1];
- if (x0213_f && 0xD800<=val && val<=0xDBFF) {
- nkf_char euc = (c2+0x21)<<8 | (c1+0x21);
- nkf_char low = 0;
- if (p==x0212_to_utf8_2bytes_x0213[c2]) {
- X0213_SURROGATE_FIND(x0213_2_surrogate_table, sizeof_x0213_2_surrogate_table, euc);
- } else {
- X0213_SURROGATE_FIND(x0213_1_surrogate_table, sizeof_x0213_1_surrogate_table, euc);
- }
- if (!low) return 0;
- return UTF16_TO_UTF32(val, low);
- } else {
- return val;
- }
- }
- return 0;
-}
-
-static nkf_char
-e2w_combining(nkf_char comb, nkf_char c2, nkf_char c1)
-{
- nkf_char euc;
- int i;
- for (i = 0; i < sizeof_x0213_combining_chars; i++)
- if (x0213_combining_chars[i] == comb)
- break;
- if (i >= sizeof_x0213_combining_chars)
- return 0;
- euc = (c2&0x7f)<<8 | (c1&0x7f);
- for (i = 0; i < sizeof_x0213_combining_table; i++)
- if (x0213_combining_table[i][0] == euc)
- return x0213_combining_table[i][1];
- return 0;
-}
-#endif
-
-static nkf_char
-w2e_conv(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
-{
- nkf_char ret = 0;
-
- if (!c1){
- *p2 = 0;
- *p1 = c2;
- }else if (0xc0 <= c2 && c2 <= 0xef) {
- ret = unicode_to_jis_common(c2, c1, c0, p2, p1);
-#ifdef NUMCHAR_OPTION
- if (ret > 0){
- if (p2) *p2 = 0;
- if (p1) *p1 = nkf_char_unicode_new(nkf_utf8_to_unicode(c2, c1, c0, 0));
- ret = 0;
- }
-#endif
- }
- return ret;
-}
-
-#ifdef UTF8_INPUT_ENABLE
-static nkf_char
-w16e_conv(nkf_char val, nkf_char *p2, nkf_char *p1)
-{
- nkf_char c1, c2, c3, c4;
- nkf_char ret = 0;
- val &= VALUE_MASK;
- if (val < 0x80) {
- *p2 = 0;
- *p1 = val;
- }
- else if (nkf_char_unicode_bmp_p(val)){
- nkf_unicode_to_utf8(val, &c1, &c2, &c3, &c4);
- ret = unicode_to_jis_common(c1, c2, c3, p2, p1);
- if (ret > 0){
- *p2 = 0;
- *p1 = nkf_char_unicode_new(val);
- ret = 0;
- }
- }
- else {
- int i;
- if (x0213_f) {
- c1 = (val >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
- c2 = (val & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
- for (i = 0; i < sizeof_x0213_1_surrogate_table; i++)
- if (x0213_1_surrogate_table[i][1] == c1 && x0213_1_surrogate_table[i][2] == c2) {
- val = x0213_1_surrogate_table[i][0];
- *p2 = val >> 8;
- *p1 = val & 0xFF;
- return 0;
- }
- for (i = 0; i < sizeof_x0213_2_surrogate_table; i++)
- if (x0213_2_surrogate_table[i][1] == c1 && x0213_2_surrogate_table[i][2] == c2) {
- val = x0213_2_surrogate_table[i][0];
- *p2 = PREFIX_EUCG3 | (val >> 8);
- *p1 = val & 0xFF;
- return 0;
- }
- }
- *p2 = 0;
- *p1 = nkf_char_unicode_new(val);
- }
- return ret;
-}
-#endif
-
-static nkf_char
-e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
-{
- if (c2 == JIS_X_0201_1976_K || c2 == SS2){
- if (iso2022jp_f && !x0201_f) {
- c2 = GETA1; c1 = GETA2;
- } else {
- c2 = JIS_X_0201_1976_K;
- c1 &= 0x7f;
- }
-#ifdef X0212_ENABLE
- }else if (c2 == 0x8f){
- if (c0 == 0){
- return -1;
- }
- if (!cp51932_f && !x0213_f && 0xF5 <= c1 && c1 <= 0xFE && 0xA1 <= c0 && c0 <= 0xFE) {
- /* encoding is eucJP-ms, so invert to Unicode Private User Area */
- c1 = nkf_char_unicode_new((c1 - 0xF5) * 94 + c0 - 0xA1 + 0xE3AC);
- c2 = 0;
- } else {
- c2 = (c2 << 8) | (c1 & 0x7f);
- c1 = c0 & 0x7f;
-#ifdef SHIFTJIS_CP932
- if (cp51932_f){
- nkf_char s2, s1;
- if (e2s_conv(c2, c1, &s2, &s1) == 0){
- s2e_conv(s2, s1, &c2, &c1);
- if (c2 < 0x100){
- c1 &= 0x7f;
- c2 &= 0x7f;
- }
- }
- }
-#endif /* SHIFTJIS_CP932 */
- }
-#endif /* X0212_ENABLE */
- } else if ((c2 == EOF) || (c2 == 0) || c2 < SP || c2 == ISO_8859_1) {
- /* NOP */
- } else {
- if (!cp51932_f && ms_ucs_map_f && 0xF5 <= c2 && c2 <= 0xFE && 0xA1 <= c1 && c1 <= 0xFE) {
- /* encoding is eucJP-ms, so invert to Unicode Private User Area */
- c1 = nkf_char_unicode_new((c2 - 0xF5) * 94 + c1 - 0xA1 + 0xE000);
- c2 = 0;
- } else {
- c1 &= 0x7f;
- c2 &= 0x7f;
-#ifdef SHIFTJIS_CP932
- if (cp51932_f && 0x79 <= c2 && c2 <= 0x7c){
- nkf_char s2, s1;
- if (e2s_conv(c2, c1, &s2, &s1) == 0){
- s2e_conv(s2, s1, &c2, &c1);
- if (c2 < 0x100){
- c1 &= 0x7f;
- c2 &= 0x7f;
- }
- }
- }
-#endif /* SHIFTJIS_CP932 */
- }
- }
- (*oconv)(c2, c1);
- return 0;
-}
-
-static nkf_char
-s_iconv(ARG_UNUSED nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
-{
- if (c2 == JIS_X_0201_1976_K || (0xA1 <= c2 && c2 <= 0xDF)) {
- if (iso2022jp_f && !x0201_f) {
- c2 = GETA1; c1 = GETA2;
- } else {
- c1 &= 0x7f;
- }
- } else if ((c2 == EOF) || (c2 == 0) || c2 < SP) {
- /* NOP */
- } else if (!x0213_f && 0xF0 <= c2 && c2 <= 0xF9 && 0x40 <= c1 && c1 <= 0xFC) {
- /* CP932 UDC */
- if(c1 == 0x7F) return 0;
- c1 = nkf_char_unicode_new((c2 - 0xF0) * 188 + (c1 - 0x40 - (0x7E < c1)) + 0xE000);
- c2 = 0;
- } else {
- nkf_char ret = s2e_conv(c2, c1, &c2, &c1);
- if (ret) return ret;
- }
- (*oconv)(c2, c1);
- return 0;
-}
-
-static int
-x0213_wait_combining_p(nkf_char wc)
-{
- int i;
- for (i = 0; i < sizeof_x0213_combining_table; i++) {
- if (x0213_combining_table[i][1] == wc) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static int
-x0213_combining_p(nkf_char wc)
-{
- int i;
- for (i = 0; i < sizeof_x0213_combining_chars; i++) {
- if (x0213_combining_chars[i] == wc) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static nkf_char
-w_iconv(nkf_char c1, nkf_char c2, nkf_char c3)
-{
- nkf_char ret = 0, c4 = 0;
- static const char 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 (c3 > 0xFF) {
- c4 = c3 & 0xFF;
- c3 >>= 8;
- }
-
- if (c1 < 0 || 0xff < c1) {
- }else if (c1 == 0) { /* 0 : 1 byte*/
- c3 = 0;
- } else if ((c1 & 0xC0) == 0x80) { /* 0x80-0xbf : trail byte */
- return 0;
- } else{
- switch (w_iconv_utf8_1st_byte[c1 - 0xC0]) {
- case 21:
- if (c2 < 0x80 || 0xBF < c2) return 0;
- break;
- case 30:
- if (c3 == 0) return -1;
- if (c2 < 0xA0 || 0xBF < c2 || (c3 & 0xC0) != 0x80)
- return 0;
- break;
- case 31:
- case 33:
- if (c3 == 0) return -1;
- if ((c2 & 0xC0) != 0x80 || (c3 & 0xC0) != 0x80)
- return 0;
- break;
- case 32:
- if (c3 == 0) return -1;
- if (c2 < 0x80 || 0x9F < c2 || (c3 & 0xC0) != 0x80)
- return 0;
- break;
- case 40:
- if (c3 == 0) return -2;
- if (c2 < 0x90 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
- return 0;
- break;
- case 41:
- if (c3 == 0) return -2;
- if (c2 < 0x80 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
- return 0;
- break;
- case 42:
- if (c3 == 0) return -2;
- if (c2 < 0x80 || 0x8F < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
- return 0;
- break;
- default:
- return 0;
- break;
- }
- }
- if (c1 == 0 || c1 == EOF){
- } else if ((c1 & 0xf8) == 0xf0) { /* 4 bytes */
- c2 = nkf_char_unicode_new(nkf_utf8_to_unicode(c1, c2, c3, c4));
- c1 = 0;
- } else {
- if (x0213_f && x0213_wait_combining_p(nkf_utf8_to_unicode(c1, c2, c3, c4)))
- return -3;
- ret = w2e_conv(c1, c2, c3, &c1, &c2);
- }
- if (ret == 0){
- (*oconv)(c1, c2);
- }
- return ret;
-}
-
-static nkf_char
-w_iconv_nocombine(nkf_char c1, nkf_char c2, nkf_char c3)
-{
- /* continue from the line below 'return -3;' in w_iconv() */
- nkf_char ret = w2e_conv(c1, c2, c3, &c1, &c2);
- if (ret == 0){
- (*oconv)(c1, c2);
- }
- return ret;
-}
-
-#define NKF_ICONV_INVALID_CODE_RANGE -13
-#define NKF_ICONV_WAIT_COMBINING_CHAR -14
-#define NKF_ICONV_NOT_COMBINED -15
-static size_t
-unicode_iconv(nkf_char wc, int nocombine)
-{
- nkf_char c1, c2;
- int ret = 0;
-
- if (wc < 0x80) {
- c2 = 0;
- c1 = wc;
- }else if ((wc>>11) == 27) {
- /* unpaired surrogate */
- return NKF_ICONV_INVALID_CODE_RANGE;
- }else if (wc < 0xFFFF) {
- if (!nocombine && x0213_f && x0213_wait_combining_p(wc))
- return NKF_ICONV_WAIT_COMBINING_CHAR;
- ret = w16e_conv(wc, &c2, &c1);
- if (ret) return ret;
- }else if (wc < 0x10FFFF) {
- c2 = 0;
- c1 = nkf_char_unicode_new(wc);
- } else {
- return NKF_ICONV_INVALID_CODE_RANGE;
- }
- (*oconv)(c2, c1);
- return 0;
-}
-
-static nkf_char
-unicode_iconv_combine(nkf_char wc, nkf_char wc2)
-{
- nkf_char c1, c2;
- int i;
-
- if (wc2 < 0x80) {
- return NKF_ICONV_NOT_COMBINED;
- }else if ((wc2>>11) == 27) {
- /* unpaired surrogate */
- return NKF_ICONV_INVALID_CODE_RANGE;
- }else if (wc2 < 0xFFFF) {
- if (!x0213_combining_p(wc2))
- return NKF_ICONV_NOT_COMBINED;
- for (i = 0; i < sizeof_x0213_combining_table; i++) {
- if (x0213_combining_table[i][1] == wc &&
- x0213_combining_table[i][2] == wc2) {
- c2 = x0213_combining_table[i][0] >> 8;
- c1 = x0213_combining_table[i][0] & 0x7f;
- (*oconv)(c2, c1);
- return 0;
- }
- }
- }else if (wc2 < 0x10FFFF) {
- return NKF_ICONV_NOT_COMBINED;
- } else {
- return NKF_ICONV_INVALID_CODE_RANGE;
- }
- return NKF_ICONV_NOT_COMBINED;
-}
-
-static nkf_char
-w_iconv_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4, nkf_char c5, nkf_char c6)
-{
- nkf_char wc, wc2;
- wc = nkf_utf8_to_unicode(c1, c2, c3, 0);
- wc2 = nkf_utf8_to_unicode(c4, c5, c6, 0);
- if (wc2 < 0)
- return wc2;
- return unicode_iconv_combine(wc, wc2);
-}
-
-#define NKF_ICONV_NEED_ONE_MORE_BYTE (size_t)-1
-#define NKF_ICONV_NEED_TWO_MORE_BYTES (size_t)-2
-static size_t
-nkf_iconv_utf_16(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc;
-
- if (c1 == EOF) {
- (*oconv)(EOF, 0);
- return 0;
- }
-
- if (input_endian == ENDIAN_BIG) {
- if (0xD8 <= c1 && c1 <= 0xDB) {
- if (0xDC <= c3 && c3 <= 0xDF) {
- wc = UTF16_TO_UTF32(c1 << 8 | c2, c3 << 8 | c4);
- } else return NKF_ICONV_NEED_TWO_MORE_BYTES;
- } else {
- wc = c1 << 8 | c2;
- }
- } else {
- if (0xD8 <= c2 && c2 <= 0xDB) {
- if (0xDC <= c4 && c4 <= 0xDF) {
- wc = UTF16_TO_UTF32(c2 << 8 | c1, c4 << 8 | c3);
- } else return NKF_ICONV_NEED_TWO_MORE_BYTES;
- } else {
- wc = c2 << 8 | c1;
- }
- }
-
- return (*unicode_iconv)(wc, FALSE);
-}
-
-static size_t
-nkf_iconv_utf_16_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc, wc2;
-
- if (input_endian == ENDIAN_BIG) {
- if (0xD8 <= c3 && c3 <= 0xDB) {
- return NKF_ICONV_NOT_COMBINED;
- } else {
- wc = c1 << 8 | c2;
- wc2 = c3 << 8 | c4;
- }
- } else {
- if (0xD8 <= c2 && c2 <= 0xDB) {
- return NKF_ICONV_NOT_COMBINED;
- } else {
- wc = c2 << 8 | c1;
- wc2 = c4 << 8 | c3;
- }
- }
-
- return unicode_iconv_combine(wc, wc2);
-}
-
-static size_t
-nkf_iconv_utf_16_nocombine(nkf_char c1, nkf_char c2)
-{
- nkf_char wc;
- if (input_endian == ENDIAN_BIG)
- wc = c1 << 8 | c2;
- else
- wc = c2 << 8 | c1;
- return (*unicode_iconv)(wc, TRUE);
-}
-
-static nkf_char
-w_iconv16(nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
-{
- (*oconv)(c2, c1);
- return 16; /* different from w_iconv32 */
-}
-
-static nkf_char
-w_iconv32(nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
-{
- (*oconv)(c2, c1);
- return 32; /* different from w_iconv16 */
-}
-
-static nkf_char
-utf32_to_nkf_char(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc;
-
- switch(input_endian){
- case ENDIAN_BIG:
- wc = c2 << 16 | c3 << 8 | c4;
- break;
- case ENDIAN_LITTLE:
- wc = c3 << 16 | c2 << 8 | c1;
- break;
- case ENDIAN_2143:
- wc = c1 << 16 | c4 << 8 | c3;
- break;
- case ENDIAN_3412:
- wc = c4 << 16 | c1 << 8 | c2;
- break;
- default:
- return NKF_ICONV_INVALID_CODE_RANGE;
- }
- return wc;
-}
-
-static size_t
-nkf_iconv_utf_32(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc;
-
- if (c1 == EOF) {
- (*oconv)(EOF, 0);
- return 0;
- }
-
- wc = utf32_to_nkf_char(c1, c2, c3, c4);
- if (wc < 0)
- return wc;
-
- return (*unicode_iconv)(wc, FALSE);
-}
-
-static nkf_char
-nkf_iconv_utf_32_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4, nkf_char c5, nkf_char c6, nkf_char c7, nkf_char c8)
-{
- nkf_char wc, wc2;
-
- wc = utf32_to_nkf_char(c1, c2, c3, c4);
- if (wc < 0)
- return wc;
- wc2 = utf32_to_nkf_char(c5, c6, c7, c8);
- if (wc2 < 0)
- return wc2;
-
- return unicode_iconv_combine(wc, wc2);
-}
-
-static size_t
-nkf_iconv_utf_32_nocombine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
-{
- nkf_char wc;
-
- wc = utf32_to_nkf_char(c1, c2, c3, c4);
- return (*unicode_iconv)(wc, TRUE);
-}
-#endif
-
-#define output_ascii_escape_sequence(mode) do { \
- if (output_mode != ASCII && output_mode != ISO_8859_1) { \
- (*o_putc)(ESC); \
- (*o_putc)('('); \
- (*o_putc)(ascii_intro); \
- output_mode = mode; \
- } \
- } while (0)
-
-static void
-output_escape_sequence(int mode)
-{
- if (output_mode == mode)
- return;
- switch(mode) {
- case ISO_8859_1:
- (*o_putc)(ESC);
- (*o_putc)('.');
- (*o_putc)('A');
- break;
- case JIS_X_0201_1976_K:
- (*o_putc)(ESC);
- (*o_putc)('(');
- (*o_putc)('I');
- break;
- case JIS_X_0208:
- (*o_putc)(ESC);
- (*o_putc)('$');
- (*o_putc)(kanji_intro);
- break;
- case JIS_X_0212:
- (*o_putc)(ESC);
- (*o_putc)('$');
- (*o_putc)('(');
- (*o_putc)('D');
- break;
- case JIS_X_0213_1:
- (*o_putc)(ESC);
- (*o_putc)('$');
- (*o_putc)('(');
- (*o_putc)('Q');
- break;
- case JIS_X_0213_2:
- (*o_putc)(ESC);
- (*o_putc)('$');
- (*o_putc)('(');
- (*o_putc)('P');
- break;
- }
- output_mode = mode;
-}
-
-static void
-j_oconv(nkf_char c2, nkf_char c1)
-{
-#ifdef NUMCHAR_OPTION
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- w16e_conv(c1, &c2, &c1);
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- c2 = c1 & VALUE_MASK;
- if (ms_ucs_map_f && 0xE000 <= c2 && c2 <= 0xE757) {
- /* CP5022x UDC */
- c1 &= 0xFFF;
- c2 = 0x7F + c1 / 94;
- c1 = 0x21 + c1 % 94;
- } else {
- if (encode_fallback) (*encode_fallback)(c1);
- return;
- }
- }
- }
-#endif
- if (c2 == 0) {
- output_ascii_escape_sequence(ASCII);
- (*o_putc)(c1);
- }
- else if (c2 == EOF) {
- output_ascii_escape_sequence(ASCII);
- (*o_putc)(EOF);
- }
- else if (c2 == ISO_8859_1) {
- output_ascii_escape_sequence(ISO_8859_1);
- (*o_putc)(c1|0x80);
- }
- else if (c2 == JIS_X_0201_1976_K) {
- output_escape_sequence(JIS_X_0201_1976_K);
- (*o_putc)(c1);
-#ifdef X0212_ENABLE
- } else if (is_eucg3(c2)){
- output_escape_sequence(x0213_f ? JIS_X_0213_2 : JIS_X_0212);
- (*o_putc)(c2 & 0x7f);
- (*o_putc)(c1);
-#endif
- } else {
- if(ms_ucs_map_f
- ? c2<0x20 || 0x92<c2 || c1<0x20 || 0x7e<c1
- : c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
- output_escape_sequence(x0213_f ? JIS_X_0213_1 : JIS_X_0208);
- (*o_putc)(c2);
- (*o_putc)(c1);
- }
-}
-
-static void
-e_oconv(nkf_char c2, nkf_char c1)
-{
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- w16e_conv(c1, &c2, &c1);
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- c2 = c1 & VALUE_MASK;
- if (x0212_f && 0xE000 <= c2 && c2 <= 0xE757) {
- /* eucJP-ms UDC */
- c1 &= 0xFFF;
- c2 = c1 / 94;
- c2 += c2 < 10 ? 0x75 : 0x8FEB;
- c1 = 0x21 + c1 % 94;
- if (is_eucg3(c2)){
- (*o_putc)(0x8f);
- (*o_putc)((c2 & 0x7f) | 0x080);
- (*o_putc)(c1 | 0x080);
- }else{
- (*o_putc)((c2 & 0x7f) | 0x080);
- (*o_putc)(c1 | 0x080);
- }
- return;
- } else {
- if (encode_fallback) (*encode_fallback)(c1);
- return;
- }
- }
- }
-
- if (c2 == EOF) {
- (*o_putc)(EOF);
- } else if (c2 == 0) {
- output_mode = ASCII;
- (*o_putc)(c1);
- } else if (c2 == JIS_X_0201_1976_K) {
- output_mode = EUC_JP;
- (*o_putc)(SS2); (*o_putc)(c1|0x80);
- } else if (c2 == ISO_8859_1) {
- output_mode = ISO_8859_1;
- (*o_putc)(c1 | 0x080);
-#ifdef X0212_ENABLE
- } else if (is_eucg3(c2)){
- output_mode = EUC_JP;
-#ifdef SHIFTJIS_CP932
- if (!cp932inv_f){
- nkf_char s2, s1;
- if (e2s_conv(c2, c1, &s2, &s1) == 0){
- s2e_conv(s2, s1, &c2, &c1);
- }
- }
-#endif
- if (c2 == 0) {
- output_mode = ASCII;
- (*o_putc)(c1);
- }else if (is_eucg3(c2)){
- if (x0212_f){
- (*o_putc)(0x8f);
- (*o_putc)((c2 & 0x7f) | 0x080);
- (*o_putc)(c1 | 0x080);
- }
- }else{
- (*o_putc)((c2 & 0x7f) | 0x080);
- (*o_putc)(c1 | 0x080);
- }
-#endif
- } else {
- if (!nkf_isgraph(c1) || !nkf_isgraph(c2)) {
- set_iconv(FALSE, 0);
- return; /* too late to rescue this char */
- }
- output_mode = EUC_JP;
- (*o_putc)(c2 | 0x080);
- (*o_putc)(c1 | 0x080);
- }
-}
-
-static void
-s_oconv(nkf_char c2, nkf_char c1)
-{
-#ifdef NUMCHAR_OPTION
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- w16e_conv(c1, &c2, &c1);
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- c2 = c1 & VALUE_MASK;
- if (!x0213_f && 0xE000 <= c2 && c2 <= 0xE757) {
- /* CP932 UDC */
- c1 &= 0xFFF;
- c2 = c1 / 188 + (cp932inv_f ? 0xF0 : 0xEB);
- c1 = c1 % 188;
- c1 += 0x40 + (c1 > 0x3e);
- (*o_putc)(c2);
- (*o_putc)(c1);
- return;
- } else {
- if(encode_fallback)(*encode_fallback)(c1);
- return;
- }
- }
- }
-#endif
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- } else if (c2 == 0) {
- output_mode = ASCII;
- (*o_putc)(c1);
- } else if (c2 == JIS_X_0201_1976_K) {
- output_mode = SHIFT_JIS;
- (*o_putc)(c1|0x80);
- } else if (c2 == ISO_8859_1) {
- output_mode = ISO_8859_1;
- (*o_putc)(c1 | 0x080);
-#ifdef X0212_ENABLE
- } else if (is_eucg3(c2)){
- output_mode = SHIFT_JIS;
- if (e2s_conv(c2, c1, &c2, &c1) == 0){
- (*o_putc)(c2);
- (*o_putc)(c1);
- }
-#endif
- } else {
- if (!nkf_isprint(c1) || !nkf_isprint(c2)) {
- set_iconv(FALSE, 0);
- return; /* too late to rescue this char */
- }
- output_mode = SHIFT_JIS;
- e2s_conv(c2, c1, &c2, &c1);
-
-#ifdef SHIFTJIS_CP932
- if (cp932inv_f
- && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
- nkf_char c = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
- if (c){
- c2 = c >> 8;
- c1 = c & 0xff;
- }
- }
-#endif /* SHIFTJIS_CP932 */
-
- (*o_putc)(c2);
- if (prefix_table[(unsigned char)c1]){
- (*o_putc)(prefix_table[(unsigned char)c1]);
- }
- (*o_putc)(c1);
- }
-}
-
-#ifdef UTF8_OUTPUT_ENABLE
-#define OUTPUT_UTF8(val) do { \
- nkf_unicode_to_utf8(val, &c1, &c2, &c3, &c4); \
- (*o_putc)(c1); \
- if (c2) (*o_putc)(c2); \
- if (c3) (*o_putc)(c3); \
- if (c4) (*o_putc)(c4); \
- } while (0)
-
-static void
-w_oconv(nkf_char c2, nkf_char c1)
-{
- nkf_char c3, c4;
- nkf_char val, val2;
-
- if (output_bom_f) {
- output_bom_f = FALSE;
- (*o_putc)('\357');
- (*o_putc)('\273');
- (*o_putc)('\277');
- }
-
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- }
-
- if (c2 == 0 && nkf_char_unicode_p(c1)){
- val = c1 & VALUE_MASK;
- OUTPUT_UTF8(val);
- return;
- }
-
- if (c2 == 0) {
- (*o_putc)(c1);
- } else {
- val = e2w_conv(c2, c1);
- if (val){
- val2 = e2w_combining(val, c2, c1);
- if (val2)
- OUTPUT_UTF8(val2);
- OUTPUT_UTF8(val);
- }
- }
-}
-
-#define OUTPUT_UTF16_BYTES(c1, c2) do { \
- if (output_endian == ENDIAN_LITTLE){ \
- (*o_putc)(c1); \
- (*o_putc)(c2); \
- }else{ \
- (*o_putc)(c2); \
- (*o_putc)(c1); \
- } \
- } while (0)
-
-#define OUTPUT_UTF16(val) do { \
- if (nkf_char_unicode_bmp_p(val)) { \
- c2 = (val >> 8) & 0xff; \
- c1 = val & 0xff; \
- OUTPUT_UTF16_BYTES(c1, c2); \
- } else { \
- val &= VALUE_MASK; \
- if (val <= UNICODE_MAX) { \
- c2 = (val >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */ \
- c1 = (val & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */ \
- OUTPUT_UTF16_BYTES(c2 & 0xff, (c2 >> 8) & 0xff); \
- OUTPUT_UTF16_BYTES(c1 & 0xff, (c1 >> 8) & 0xff); \
- } \
- } \
- } while (0)
-
-static void
-w_oconv16(nkf_char c2, nkf_char c1)
-{
- if (output_bom_f) {
- output_bom_f = FALSE;
- OUTPUT_UTF16_BYTES(0xFF, 0xFE);
- }
-
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- }
-
- if (c2 == 0 && nkf_char_unicode_p(c1)) {
- OUTPUT_UTF16(c1);
- } else if (c2) {
- nkf_char val, val2;
- val = e2w_conv(c2, c1);
- if (!val) return;
- val2 = e2w_combining(val, c2, c1);
- if (val2)
- OUTPUT_UTF16(val2);
- OUTPUT_UTF16(val);
- } else {
- OUTPUT_UTF16_BYTES(c1, c2);
- }
-}
-
-#define OUTPUT_UTF32(c) do { \
- if (output_endian == ENDIAN_LITTLE){ \
- (*o_putc)( (c) & 0xFF); \
- (*o_putc)(((c) >> 8) & 0xFF); \
- (*o_putc)(((c) >> 16) & 0xFF); \
- (*o_putc)(0); \
- }else{ \
- (*o_putc)(0); \
- (*o_putc)(((c) >> 16) & 0xFF); \
- (*o_putc)(((c) >> 8) & 0xFF); \
- (*o_putc)( (c) & 0xFF); \
- } \
- } while (0)
-
-static void
-w_oconv32(nkf_char c2, nkf_char c1)
-{
- if (output_bom_f) {
- output_bom_f = FALSE;
- if (output_endian == ENDIAN_LITTLE){
- (*o_putc)(0xFF);
- (*o_putc)(0xFE);
- (*o_putc)(0);
- (*o_putc)(0);
- }else{
- (*o_putc)(0);
- (*o_putc)(0);
- (*o_putc)(0xFE);
- (*o_putc)(0xFF);
- }
- }
-
- if (c2 == EOF) {
- (*o_putc)(EOF);
- return;
- }
-
- if (c2 == ISO_8859_1) {
- c1 |= 0x80;
- } else if (c2 == 0 && nkf_char_unicode_p(c1)) {
- c1 &= VALUE_MASK;
- } else if (c2) {
- nkf_char val, val2;
- val = e2w_conv(c2, c1);
- if (!val) return;
- val2 = e2w_combining(val, c2, c1);
- if (val2)
- OUTPUT_UTF32(val2);
- c1 = val;
- }
- OUTPUT_UTF32(c1);
-}
-#endif
-
-#define SCORE_L2 (1) /* Kanji Level 2 */
-#define SCORE_KANA (SCORE_L2 << 1) /* Halfwidth Katakana */
-#define SCORE_DEPEND (SCORE_KANA << 1) /* MD Characters */
-#define SCORE_CP932 (SCORE_DEPEND << 1) /* IBM extended characters */
-#define SCORE_X0212 (SCORE_CP932 << 1) /* JIS X 0212 */
-#define SCORE_X0213 (SCORE_X0212 << 1) /* JIS X 0213 */
-#define SCORE_NO_EXIST (SCORE_X0213 << 1) /* Undefined Characters */
-#define SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME selected */
-#define SCORE_ERROR (SCORE_iMIME << 1) /* Error */
-
-#define SCORE_INIT (SCORE_iMIME)
-
-static 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_X0213,
-};
-
-static const nkf_char score_table_F0[] = {
- SCORE_L2, SCORE_L2, SCORE_L2, SCORE_L2,
- SCORE_L2, SCORE_DEPEND, SCORE_X0213, SCORE_X0213,
- SCORE_DEPEND, SCORE_DEPEND, SCORE_CP932, SCORE_CP932,
- SCORE_CP932, SCORE_X0213, SCORE_X0213, SCORE_ERROR,
-};
-
-static const nkf_char score_table_8FA0[] = {
- 0, SCORE_X0213, SCORE_X0212, SCORE_X0213,
- SCORE_X0213, SCORE_X0213, SCORE_X0212, SCORE_X0212,
- SCORE_X0213, SCORE_X0212, SCORE_X0212, SCORE_X0212,
- SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
-};
-
-static const nkf_char score_table_8FE0[] = {
- SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
- SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
- SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
- SCORE_X0212, SCORE_X0212, SCORE_X0213, SCORE_X0213,
-};
-
-static const nkf_char score_table_8FF0[] = {
- SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0212,
- SCORE_X0212, SCORE_X0213, SCORE_X0213, SCORE_X0213,
- SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
- SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
-};
-
-static void
-set_code_score(struct input_code *ptr, nkf_char score)
-{
- if (ptr){
- ptr->score |= score;
- }
-}
-
-static void
-clr_code_score(struct input_code *ptr, nkf_char score)
-{
- if (ptr){
- ptr->score &= ~score;
- }
-}
-
-static void
-code_score(struct input_code *ptr)
-{
- nkf_char c2 = ptr->buf[0];
- nkf_char c1 = ptr->buf[1];
- if (c2 < 0){
- set_code_score(ptr, SCORE_ERROR);
- }else if (c2 == SS2){
- set_code_score(ptr, SCORE_KANA);
- }else if (c2 == 0x8f){
- if ((c1 & 0x70) == 0x20){
- set_code_score(ptr, score_table_8FA0[c1 & 0x0f]);
- }else if ((c1 & 0x70) == 0x60){
- set_code_score(ptr, score_table_8FE0[c1 & 0x0f]);
- }else if ((c1 & 0x70) == 0x70){
- set_code_score(ptr, score_table_8FF0[c1 & 0x0f]);
- }else{
- set_code_score(ptr, SCORE_X0212);
- }
-#ifdef UTF8_OUTPUT_ENABLE
- }else if (!e2w_conv(c2, c1)){
- set_code_score(ptr, SCORE_NO_EXIST);
-#endif
- }else if ((c2 & 0x70) == 0x20){
- set_code_score(ptr, score_table_A0[c2 & 0x0f]);
- }else if ((c2 & 0x70) == 0x70){
- set_code_score(ptr, score_table_F0[c2 & 0x0f]);
- }else if ((c2 & 0x70) >= 0x50){
- set_code_score(ptr, SCORE_L2);
- }
-}
-
-static void
-status_disable(struct input_code *ptr)
-{
- ptr->stat = -1;
- ptr->buf[0] = -1;
- code_score(ptr);
- if (iconv == ptr->iconv_func) set_iconv(FALSE, 0);
-}
-
-static void
-status_push_ch(struct input_code *ptr, nkf_char c)
-{
- ptr->buf[ptr->index++] = c;
-}
-
-static void
-status_clear(struct input_code *ptr)
-{
- ptr->stat = 0;
- ptr->index = 0;
-}
-
-static void
-status_reset(struct input_code *ptr)
-{
- status_clear(ptr);
- ptr->score = SCORE_INIT;
-}
-
-static void
-status_reinit(struct input_code *ptr)
-{
- status_reset(ptr);
- ptr->_file_stat = 0;
-}
-
-static void
-status_check(struct input_code *ptr, nkf_char c)
-{
- if (c <= DEL && estab_f){
- status_reset(ptr);
- }
-}
-
-static void
-s_status(struct input_code *ptr, nkf_char c)
-{
- switch(ptr->stat){
- case -1:
- status_check(ptr, c);
- break;
- case 0:
- if (c <= DEL){
- break;
- }else if (nkf_char_unicode_p(c)){
- break;
- }else if (0xa1 <= c && c <= 0xdf){
- status_push_ch(ptr, SS2);
- status_push_ch(ptr, c);
- code_score(ptr);
- status_clear(ptr);
- }else if ((0x81 <= c && c < 0xa0) || (0xe0 <= c && c <= 0xea)){
- 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)){
- ptr->stat = 2;
- status_push_ch(ptr, c);
-#endif /* SHIFTJIS_CP932 */
-#ifdef X0212_ENABLE
- }else if (0xf0 <= c && c <= 0xfc){
- ptr->stat = 1;
- status_push_ch(ptr, c);
-#endif /* X0212_ENABLE */
- }else{
- status_disable(ptr);
- }
- break;
- case 1:
- if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
- status_push_ch(ptr, c);
- s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]);
- code_score(ptr);
- status_clear(ptr);
- }else{
- status_disable(ptr);
- }
- break;
- 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);
- }
- break;
- }
-}
-
-static void
-e_status(struct input_code *ptr, nkf_char c)
-{
- switch (ptr->stat){
- case -1:
- status_check(ptr, c);
- break;
- case 0:
- if (c <= DEL){
- break;
- }else if (nkf_char_unicode_p(c)){
- break;
- }else if (SS2 == c || (0xa1 <= c && c <= 0xfe)){
- ptr->stat = 1;
- status_push_ch(ptr, c);
-#ifdef X0212_ENABLE
- }else if (0x8f == c){
- ptr->stat = 2;
- status_push_ch(ptr, c);
-#endif /* X0212_ENABLE */
- }else{
- status_disable(ptr);
- }
- break;
- case 1:
- if (0xa1 <= c && c <= 0xfe){
- status_push_ch(ptr, c);
- code_score(ptr);
- status_clear(ptr);
- }else{
- status_disable(ptr);
- }
- break;
-#ifdef X0212_ENABLE
- case 2:
- if (0xa1 <= c && c <= 0xfe){
- ptr->stat = 1;
- status_push_ch(ptr, c);
- }else{
- status_disable(ptr);
- }
-#endif /* X0212_ENABLE */
- }
-}
-
-#ifdef UTF8_INPUT_ENABLE
-static void
-w_status(struct input_code *ptr, nkf_char c)
-{
- switch (ptr->stat){
- case -1:
- status_check(ptr, c);
- break;
- case 0:
- if (c <= DEL){
- break;
- }else if (nkf_char_unicode_p(c)){
- break;
- }else if (0xc0 <= c && c <= 0xdf){
- ptr->stat = 1;
- status_push_ch(ptr, c);
- }else if (0xe0 <= c && c <= 0xef){
- ptr->stat = 2;
- status_push_ch(ptr, c);
- }else if (0xf0 <= c && c <= 0xf4){
- ptr->stat = 3;
- status_push_ch(ptr, c);
- }else{
- status_disable(ptr);
- }
- break;
- case 1:
- case 2:
- if (0x80 <= c && c <= 0xbf){
- status_push_ch(ptr, c);
- if (ptr->index > ptr->stat){
- int bom = (ptr->buf[0] == 0xef && ptr->buf[1] == 0xbb
- && ptr->buf[2] == 0xbf);
- w2e_conv(ptr->buf[0], ptr->buf[1], ptr->buf[2],
- &ptr->buf[0], &ptr->buf[1]);
- if (!bom){
- code_score(ptr);
- }
- status_clear(ptr);
- }
- }else{
- status_disable(ptr);
- }
- break;
- case 3:
- if (0x80 <= c && c <= 0xbf){
- if (ptr->index < ptr->stat){
- status_push_ch(ptr, c);
- } else {
- status_clear(ptr);
- }
- }else{
- status_disable(ptr);
- }
- break;
- }
-}
-#endif
-
-static void
-code_status(nkf_char c)
-{
- int action_flag = 1;
- struct input_code *result = 0;
- struct input_code *p = input_code_list;
- while (p->name){
- if (!p->status_func) {
- ++p;
- continue;
- }
- if (!p->status_func)
- continue;
- (p->status_func)(p, c);
- if (p->stat > 0){
- action_flag = 0;
- }else if(p->stat == 0){
- if (result){
- action_flag = 0;
- }else{
- result = p;
- }
- }
- ++p;
- }
-
- if (action_flag){
- if (result && !estab_f){
- set_iconv(TRUE, result->iconv_func);
- }else if (c <= DEL){
- struct input_code *ptr = input_code_list;
- while (ptr->name){
- status_reset(ptr);
- ++ptr;
- }
- }
- }
-}
-
-typedef struct {
- nkf_buf_t *std_gc_buf;
- nkf_char broken_state;
- nkf_buf_t *broken_buf;
- nkf_char mimeout_state;
- nkf_buf_t *nfc_buf;
-} nkf_state_t;
-
-static nkf_state_t *nkf_state = NULL;
-
-#define STD_GC_BUFSIZE (256)
-
-static void
-nkf_state_init(void)
-{
- if (nkf_state) {
- nkf_buf_clear(nkf_state->std_gc_buf);
- nkf_buf_clear(nkf_state->broken_buf);
- nkf_buf_clear(nkf_state->nfc_buf);
- }
- else {
- nkf_state = nkf_xmalloc(sizeof(nkf_state_t));
- nkf_state->std_gc_buf = nkf_buf_new(STD_GC_BUFSIZE);
- nkf_state->broken_buf = nkf_buf_new(3);
- nkf_state->nfc_buf = nkf_buf_new(9);
- }
- nkf_state->broken_state = 0;
- nkf_state->mimeout_state = 0;
-}
-
-#ifndef WIN32DLL
-static nkf_char
-std_getc(FILE *f)
-{
- if (!nkf_buf_empty_p(nkf_state->std_gc_buf)){
- return nkf_buf_pop(nkf_state->std_gc_buf);
- }
- return getc(f);
-}
-#endif /*WIN32DLL*/
-
-static nkf_char
-std_ungetc(nkf_char c, ARG_UNUSED FILE *f)
-{
- nkf_buf_push(nkf_state->std_gc_buf, c);
- return c;
-}
-
-#ifndef WIN32DLL
-static void
-std_putc(nkf_char c)
-{
- if(c!=EOF)
- putchar(c);
-}
-#endif /*WIN32DLL*/
-
-static nkf_char hold_buf[HOLD_SIZE*2];
-static int hold_count = 0;
-static nkf_char
-push_hold_buf(nkf_char c2)
-{
- if (hold_count >= HOLD_SIZE*2)
- return (EOF);
- hold_buf[hold_count++] = c2;
- return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count);
-}
-
-static int
-h_conv(FILE *f, nkf_char c1, nkf_char c2)
-{
- int ret;
- int hold_index;
- int fromhold_count;
- nkf_char c3, c4;
-
- /** it must NOT be in the kanji shifte sequence */
- /** it must NOT be written in JIS7 */
- /** and it must be after 2 byte 8bit code */
-
- hold_count = 0;
- push_hold_buf(c1);
- push_hold_buf(c2);
-
- while ((c2 = (*i_getc)(f)) != EOF) {
- if (c2 == ESC){
- (*i_ungetc)(c2,f);
- break;
- }
- code_status(c2);
- if (push_hold_buf(c2) == EOF || estab_f) {
- break;
- }
- }
-
- if (!estab_f) {
- struct input_code *p = input_code_list;
- struct input_code *result = p;
- if (c2 == EOF) {
- code_status(c2);
- }
- while (p->name) {
- if (p->status_func && p->score < result->score) {
- result = p;
- }
- p++;
- }
- set_iconv(TRUE, result->iconv_func);
- }
-
-
- /** now,
- ** 1) EOF is detected, or
- ** 2) Code is established, or
- ** 3) Buffer is FULL (but last word is pushed)
- **
- ** in 1) and 3) cases, we continue to use
- ** Kanji codes by oconv and leave estab_f unchanged.
- **/
-
- ret = c2;
- hold_index = 0;
- while (hold_index < hold_count){
- c1 = hold_buf[hold_index++];
- if (nkf_char_unicode_p(c1)) {
- (*oconv)(0, c1);
- continue;
- }
- else if (c1 <= DEL){
- (*iconv)(0, c1, 0);
- continue;
- }else if (iconv == s_iconv && 0xa1 <= c1 && c1 <= 0xdf){
- (*iconv)(JIS_X_0201_1976_K, c1, 0);
- continue;
- }
- fromhold_count = 1;
- if (hold_index < hold_count){
- c2 = hold_buf[hold_index++];
- fromhold_count++;
- }else{
- c2 = (*i_getc)(f);
- if (c2 == EOF){
- c4 = EOF;
- break;
- }
- code_status(c2);
- }
- c3 = 0;
- switch ((*iconv)(c1, c2, 0)) { /* can be EUC/SJIS/UTF-8 */
- case -2:
- /* 4 bytes UTF-8 */
- if (hold_index < hold_count){
- c3 = hold_buf[hold_index++];
- } else if ((c3 = (*i_getc)(f)) == EOF) {
- ret = EOF;
- break;
- }
- code_status(c3);
- if (hold_index < hold_count){
- c4 = hold_buf[hold_index++];
- } else if ((c4 = (*i_getc)(f)) == EOF) {
- c3 = ret = EOF;
- break;
- }
- code_status(c4);
- (*iconv)(c1, c2, (c3<<8)|c4);
- break;
- case -3:
- /* 4 bytes UTF-8 (check combining character) */
- if (hold_index < hold_count){
- c3 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c3 = (*i_getc)(f)) == EOF) {
- w_iconv_nocombine(c1, c2, 0);
- break;
- }
- if (hold_index < hold_count){
- c4 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c4 = (*i_getc)(f)) == EOF) {
- w_iconv_nocombine(c1, c2, 0);
- if (fromhold_count <= 2)
- (*i_ungetc)(c3,f);
- else
- hold_index--;
- continue;
- }
- if (w_iconv_combine(c1, c2, 0, c3, c4, 0)) {
- w_iconv_nocombine(c1, c2, 0);
- if (fromhold_count <= 2) {
- (*i_ungetc)(c4,f);
- (*i_ungetc)(c3,f);
- } else if (fromhold_count == 3) {
- (*i_ungetc)(c4,f);
- hold_index--;
- } else {
- hold_index -= 2;
- }
- }
- break;
- case -1:
- /* 3 bytes EUC or UTF-8 */
- if (hold_index < hold_count){
- c3 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c3 = (*i_getc)(f)) == EOF) {
- ret = EOF;
- break;
- } else {
- code_status(c3);
- }
- if ((*iconv)(c1, c2, c3) == -3) {
- /* 6 bytes UTF-8 (check combining character) */
- nkf_char c5, c6;
- if (hold_index < hold_count){
- c4 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c4 = (*i_getc)(f)) == EOF) {
- w_iconv_nocombine(c1, c2, c3);
- continue;
- }
- if (hold_index < hold_count){
- c5 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c5 = (*i_getc)(f)) == EOF) {
- w_iconv_nocombine(c1, c2, c3);
- if (fromhold_count == 4)
- hold_index--;
- else
- (*i_ungetc)(c4,f);
- continue;
- }
- if (hold_index < hold_count){
- c6 = hold_buf[hold_index++];
- fromhold_count++;
- } else if ((c6 = (*i_getc)(f)) == EOF) {
- w_iconv_nocombine(c1, c2, c3);
- if (fromhold_count == 5) {
- hold_index -= 2;
- } else if (fromhold_count == 4) {
- hold_index--;
- (*i_ungetc)(c5,f);
- } else {
- (*i_ungetc)(c5,f);
- (*i_ungetc)(c4,f);
- }
- continue;
- }
- if (w_iconv_combine(c1, c2, c3, c4, c5, c6)) {
- w_iconv_nocombine(c1, c2, c3);
- if (fromhold_count == 6) {
- hold_index -= 3;
- } else if (fromhold_count == 5) {
- hold_index -= 2;
- (*i_ungetc)(c6,f);
- } else if (fromhold_count == 4) {
- hold_index--;
- (*i_ungetc)(c6,f);
- (*i_ungetc)(c5,f);
- } else {
- (*i_ungetc)(c6,f);
- (*i_ungetc)(c5,f);
- (*i_ungetc)(c4,f);
- }
- }
- }
- break;
- }
- if (c3 == EOF) break;
- }
- return ret;
-}
-
-/*
- * Check and Ignore BOM
- */
-static void
-check_bom(FILE *f)
-{
- int c2;
- input_bom_f = FALSE;
- switch(c2 = (*i_getc)(f)){
- case 0x00:
- if((c2 = (*i_getc)(f)) == 0x00){
- if((c2 = (*i_getc)(f)) == 0xFE){
- if((c2 = (*i_getc)(f)) == 0xFF){
- if(!input_encoding){
- set_iconv(TRUE, w_iconv32);
- }
- if (iconv == w_iconv32) {
- input_bom_f = TRUE;
- input_endian = ENDIAN_BIG;
- return;
- }
- (*i_ungetc)(0xFF,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xFE,f);
- }else if(c2 == 0xFF){
- if((c2 = (*i_getc)(f)) == 0xFE){
- if(!input_encoding){
- set_iconv(TRUE, w_iconv32);
- }
- if (iconv == w_iconv32) {
- input_endian = ENDIAN_2143;
- return;
- }
- (*i_ungetc)(0xFF,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xFF,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0x00,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0x00,f);
- break;
- case 0xEF:
- if((c2 = (*i_getc)(f)) == 0xBB){
- if((c2 = (*i_getc)(f)) == 0xBF){
- if(!input_encoding){
- set_iconv(TRUE, w_iconv);
- }
- if (iconv == w_iconv) {
- input_bom_f = TRUE;
- return;
- }
- (*i_ungetc)(0xBF,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xBB,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xEF,f);
- break;
- case 0xFE:
- if((c2 = (*i_getc)(f)) == 0xFF){
- if((c2 = (*i_getc)(f)) == 0x00){
- if((c2 = (*i_getc)(f)) == 0x00){
- if(!input_encoding){
- set_iconv(TRUE, w_iconv32);
- }
- if (iconv == w_iconv32) {
- input_endian = ENDIAN_3412;
- return;
- }
- (*i_ungetc)(0x00,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0x00,f);
- }else (*i_ungetc)(c2,f);
- if(!input_encoding){
- set_iconv(TRUE, w_iconv16);
- }
- if (iconv == w_iconv16) {
- input_endian = ENDIAN_BIG;
- input_bom_f = TRUE;
- return;
- }
- (*i_ungetc)(0xFF,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xFE,f);
- break;
- case 0xFF:
- if((c2 = (*i_getc)(f)) == 0xFE){
- if((c2 = (*i_getc)(f)) == 0x00){
- if((c2 = (*i_getc)(f)) == 0x00){
- if(!input_encoding){
- set_iconv(TRUE, w_iconv32);
- }
- if (iconv == w_iconv32) {
- input_endian = ENDIAN_LITTLE;
- input_bom_f = TRUE;
- return;
- }
- (*i_ungetc)(0x00,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0x00,f);
- }else (*i_ungetc)(c2,f);
- if(!input_encoding){
- set_iconv(TRUE, w_iconv16);
- }
- if (iconv == w_iconv16) {
- input_endian = ENDIAN_LITTLE;
- input_bom_f = TRUE;
- return;
- }
- (*i_ungetc)(0xFE,f);
- }else (*i_ungetc)(c2,f);
- (*i_ungetc)(0xFF,f);
- break;
- default:
- (*i_ungetc)(c2,f);
- break;
- }
-}
-
-static nkf_char
-broken_getc(FILE *f)
-{
- nkf_char c, c1;
-
- if (!nkf_buf_empty_p(nkf_state->broken_buf)) {
- return nkf_buf_pop(nkf_state->broken_buf);
- }
- c = (*i_bgetc)(f);
- if (c=='$' && nkf_state->broken_state != ESC
- && (input_mode == ASCII || input_mode == JIS_X_0201_1976_K)) {
- c1= (*i_bgetc)(f);
- nkf_state->broken_state = 0;
- if (c1=='@'|| c1=='B') {
- nkf_buf_push(nkf_state->broken_buf, c1);
- nkf_buf_push(nkf_state->broken_buf, c);
- return ESC;
- } else {
- (*i_bungetc)(c1,f);
- return c;
- }
- } else if (c=='(' && nkf_state->broken_state != ESC
- && (input_mode == JIS_X_0208 || input_mode == JIS_X_0201_1976_K)) {
- c1= (*i_bgetc)(f);
- nkf_state->broken_state = 0;
- if (c1=='J'|| c1=='B') {
- nkf_buf_push(nkf_state->broken_buf, c1);
- nkf_buf_push(nkf_state->broken_buf, c);
- return ESC;
- } else {
- (*i_bungetc)(c1,f);
- return c;
- }
- } else {
- nkf_state->broken_state = c;
- return c;
- }
-}
-
-static nkf_char
-broken_ungetc(nkf_char c, ARG_UNUSED FILE *f)
-{
- if (nkf_buf_length(nkf_state->broken_buf) < 2)
- nkf_buf_push(nkf_state->broken_buf, c);
- return c;
-}
-
-static void
-eol_conv(nkf_char c2, nkf_char c1)
-{
- if (guess_f && input_eol != EOF) {
- if (c2 == 0 && c1 == LF) {
- if (!input_eol) input_eol = prev_cr ? CRLF : LF;
- else if (input_eol != (prev_cr ? CRLF : LF)) input_eol = EOF;
- } else if (c2 == 0 && c1 == CR && input_eol == LF) input_eol = EOF;
- else if (!prev_cr);
- else if (!input_eol) input_eol = CR;
- else if (input_eol != CR) input_eol = EOF;
- }
- if (prev_cr || (c2 == 0 && c1 == LF)) {
- prev_cr = 0;
- if (eolmode_f != LF) (*o_eol_conv)(0, CR);
- if (eolmode_f != CR) (*o_eol_conv)(0, LF);
- }
- if (c2 == 0 && c1 == CR) prev_cr = CR;
- else if (c2 != 0 || c1 != LF) (*o_eol_conv)(c2, c1);
-}
-
-static void
-put_newline(void (*func)(nkf_char))
-{
- switch (eolmode_f ? eolmode_f : DEFAULT_NEWLINE) {
- case CRLF:
- (*func)(0x0D);
- (*func)(0x0A);
- break;
- case CR:
- (*func)(0x0D);
- break;
- case LF:
- (*func)(0x0A);
- break;
- }
-}
-
-static void
-oconv_newline(void (*func)(nkf_char, nkf_char))
-{
- switch (eolmode_f ? eolmode_f : DEFAULT_NEWLINE) {
- case CRLF:
- (*func)(0, 0x0D);
- (*func)(0, 0x0A);
- break;
- case CR:
- (*func)(0, 0x0D);
- break;
- case LF:
- (*func)(0, 0x0A);
- break;
- }
-}
-
-/*
- 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
-
- fold state in prev (previous character)
-
- >0x80 Japanese (X0208/X0201)
- <0x80 ASCII
- LF new line
- SP space
-
- This fold algorithm does not preserve heading space in a line.
- This is the main difference from fmt.
- */
-
-#define char_size(c2,c1) (c2?2:1)
-
-static void
-fold_conv(nkf_char c2, nkf_char c1)
-{
- nkf_char prev0;
- nkf_char fold_state;
-
- if (c1== CR && !fold_preserve_f) {
- fold_state=0; /* ignore cr */
- }else if (c1== LF&&f_prev==CR && fold_preserve_f) {
- f_prev = LF;
- 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_preserve_f)) {
- /* new line */
- if (fold_preserve_f) {
- f_prev = c1;
- f_line = 0;
- fold_state = CR;
- } else if ((f_prev == c1)
- || (f_prev == LF)
- ) { /* duplicate newline */
- if (f_line) {
- f_line = 0;
- fold_state = LF; /* output two newline */
- } else {
- f_line = 0;
- fold_state = 1;
- }
- } else {
- if (f_prev&0x80) { /* Japanese? */
- f_prev = c1;
- fold_state = 0; /* ignore given single newline */
- } else if (f_prev==SP) {
- fold_state = 0;
- } else {
- f_prev = c1;
- if (++f_line<=fold_len)
- fold_state = SP;
- else {
- f_line = 0;
- fold_state = CR; /* fold and output nothing */
- }
- }
- }
- } else if (c1=='\f') {
- f_prev = LF;
- f_line = 0;
- fold_state = LF; /* output newline and clear */
- } else if ((c2==0 && nkf_isblank(c1)) || (c2 == '!' && c1 == '!')) {
- /* X0208 kankaku or ascii space */
- if (f_prev == SP) {
- fold_state = 0; /* remove duplicate spaces */
- } else {
- f_prev = SP;
- if (++f_line<=fold_len)
- fold_state = SP; /* output ASCII space only */
- else {
- f_prev = SP; f_line = 0;
- fold_state = CR; /* 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_1976_K)
- f_prev |= 0x80; /* this is Japanese */
- f_line += c2 == JIS_X_0201_1976_K ? 1: char_size(c2,c1);
- if (f_line<=fold_len) { /* normal case */
- fold_state = 1;
- } 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_1976_K) {
- /* simple kinsoku rules return 1 means no folding */
- if (c1==(0xde&0x7f)) fold_state = 1; /* $B!+(B*/
- else if (c1==(0xdf&0x7f)) fold_state = 1; /* $B!,(B*/
- else if (c1==(0xa4&0x7f)) fold_state = 1; /* $B!#(B*/
- else if (c1==(0xa3&0x7f)) fold_state = 1; /* $B!$(B*/
- else if (c1==(0xa1&0x7f)) fold_state = 1; /* $B!W(B*/
- else if (c1==(0xb0&0x7f)) fold_state = 1; /* - */
- else if (SP<=c1 && c1<=(0xdf&0x7f)) { /* X0201 */
- f_line = 1;
- fold_state = LF;/* add one new f_line before this character */
- } else {
- f_line = 1;
- fold_state = LF;/* add one new f_line before this character */
- }
- } else if (c2==0) {
- /* kinsoku point in ASCII */
- if ( c1==')'|| /* { [ ( */
- c1==']'||
- c1=='}'||
- c1=='.'||
- c1==','||
- c1=='!'||
- c1=='?'||
- c1=='/'||
- c1==':'||
- c1==';') {
- fold_state = 1;
- /* just after special */
- } else if (!is_alnum(prev0)) {
- f_line = char_size(c2,c1);
- fold_state = LF;
- } else if ((prev0==SP) || /* ignored new f_line */
- (prev0==LF)|| /* 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 */
- } else {
- fold_state = 1; /* default no fold in ASCII */
- }
- } else {
- if (c2=='!') {
- if (c1=='"') fold_state = 1; /* $B!"(B */
- else if (c1=='#') fold_state = 1; /* $B!#(B */
- else if (c1=='W') fold_state = 1; /* $B!W(B */
- else if (c1=='K') fold_state = 1; /* $B!K(B */
- else if (c1=='$') fold_state = 1; /* $B!$(B */
- else if (c1=='%') fold_state = 1; /* $B!%(B */
- else if (c1=='\'') fold_state = 1; /* $B!\(B */
- else if (c1=='(') fold_state = 1; /* $B!((B */
- else if (c1==')') fold_state = 1; /* $B!)(B */
- else if (c1=='*') fold_state = 1; /* $B!*(B */
- else if (c1=='+') fold_state = 1; /* $B!+(B */
- else if (c1==',') fold_state = 1; /* $B!,(B */
- /* default no fold in kinsoku */
- else {
- fold_state = LF;
- f_line = char_size(c2,c1);
- /* add one new f_line before this character */
- }
- } else {
- f_line = char_size(c2,c1);
- fold_state = LF;
- /* add one new f_line before this character */
- }
- }
- }
- }
- /* terminator process */
- switch(fold_state) {
- case LF:
- oconv_newline(o_fconv);
- (*o_fconv)(c2,c1);
- break;
- case 0:
- return;
- case CR:
- oconv_newline(o_fconv);
- break;
- case TAB:
- case SP:
- (*o_fconv)(0,SP);
- break;
- default:
- (*o_fconv)(c2,c1);
- }
-}
-
-static nkf_char z_prev2=0,z_prev1=0;
-
-static void
-z_conv(nkf_char c2, nkf_char c1)
-{
-
- /* if (c2) c1 &= 0x7f; assertion */
-
- if (c2 == JIS_X_0201_1976_K && (c1 == 0x20 || c1 == 0x7D || c1 == 0x7E)) {
- (*o_zconv)(c2,c1);
- return;
- }
-
- if (x0201_f) {
- if (z_prev2 == JIS_X_0201_1976_K) {
- if (c2 == JIS_X_0201_1976_K) {
- 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;
- } else if (x0213_f && c1 == (0xdf&0x7f) && ev_x0213[(z_prev1-SP)*2]) { /* $BH>ByE@(B */
- z_prev2 = 0;
- (*o_zconv)(ev_x0213[(z_prev1-SP)*2], ev_x0213[(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_1976_K) {
- if (dv[(c1-SP)*2] || ev[(c1-SP)*2] || (x0213_f && ev_x0213[(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 (alpha_f&1 && c2 == 0x23) {
- /* JISX0208 Alphabet */
- c2 = 0;
- } else if (c2 == 0x21) {
- /* JISX0208 Kigou */
- if (0x21==c1) {
- if (alpha_f&2) {
- c2 = 0;
- c1 = SP;
- } else if (alpha_f&4) {
- (*o_zconv)(0, SP);
- (*o_zconv)(0, SP);
- return;
- }
- } else if (alpha_f&1 && 0x20<c1 && c1<0x7f && fv[c1-0x20]) {
- c2 = 0;
- c1 = fv[c1-0x20];
- }
- }
-
- if (alpha_f&8 && c2 == 0) {
- /* HTML Entity */
- const 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) {
- nkf_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_1976_K, 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, 0x365F,
- 0x375F, 0x385F, 0x395F, 0x3A5F, 0x3E5F, 0x425F, 0x445F, 0x0000
- };
- if (fullwidth_to_halfwidth[c1-0x20]){
- c2 = fullwidth_to_halfwidth[c1-0x20];
- (*o_zconv)(JIS_X_0201_1976_K, c2>>8);
- if (c2 & 0xFF) {
- (*o_zconv)(JIS_X_0201_1976_K, c2&0xFF);
- }
- return;
- }
- } else if (c2 == 0 && nkf_char_unicode_p(c1) &&
- ((c1&VALUE_MASK) == 0x3099 || (c1&VALUE_MASK) == 0x309A)) { /* $B9g@.MQByE@!&H>ByE@(B */
- (*o_zconv)(JIS_X_0201_1976_K, 0x5E + (c1&VALUE_MASK) - 0x3099);
- return;
- }
- }
- (*o_zconv)(c2,c1);
-}
-
-
-#define rot13(c) ( \
- ( c < 'A') ? c: \
- (c <= 'M') ? (c + 13): \
- (c <= 'Z') ? (c - 13): \
- (c < 'a') ? (c): \
- (c <= 'm') ? (c + 13): \
- (c <= 'z') ? (c - 13): \
- (c) \
- )
-
-#define rot47(c) ( \
- ( c < '!') ? c: \
- ( c <= 'O') ? (c + 47) : \
- ( c <= '~') ? (c - 47) : \
- c \
- )
-
-static void
-rot_conv(nkf_char c2, nkf_char c1)
-{
- if (c2 == 0 || c2 == JIS_X_0201_1976_K || c2 == ISO_8859_1) {
- c1 = rot13(c1);
- } else if (c2) {
- c1 = rot47(c1);
- c2 = rot47(c2);
- }
- (*o_rot_conv)(c2,c1);
-}
-
-static void
-hira_conv(nkf_char c2, nkf_char c1)
-{
- if (hira_f & 1) {
- if (c2 == 0x25) {
- if (0x20 < c1 && c1 < 0x74) {
- c2 = 0x24;
- (*o_hira_conv)(c2,c1);
- return;
- } else if (c1 == 0x74 && nkf_enc_unicode_p(output_encoding)) {
- c2 = 0;
- c1 = nkf_char_unicode_new(0x3094);
- (*o_hira_conv)(c2,c1);
- return;
- }
- } else if (c2 == 0x21 && (c1 == 0x33 || c1 == 0x34)) {
- c1 += 2;
- (*o_hira_conv)(c2,c1);
- return;
- }
- }
- if (hira_f & 2) {
- if (c2 == 0 && c1 == nkf_char_unicode_new(0x3094)) {
- c2 = 0x25;
- c1 = 0x74;
- } else if (c2 == 0x24 && 0x20 < c1 && c1 < 0x74) {
- c2 = 0x25;
- } else if (c2 == 0x21 && (c1 == 0x35 || c1 == 0x36)) {
- c1 -= 2;
- }
- }
- (*o_hira_conv)(c2,c1);
-}
-
-
-static void
-iso2022jp_check_conv(nkf_char c2, nkf_char c1)
-{
-#define RANGE_NUM_MAX 18
- static const nkf_char range[RANGE_NUM_MAX][2] = {
- {0x222f, 0x2239,},
- {0x2242, 0x2249,},
- {0x2251, 0x225b,},
- {0x226b, 0x2271,},
- {0x227a, 0x227d,},
- {0x2321, 0x232f,},
- {0x233a, 0x2340,},
- {0x235b, 0x2360,},
- {0x237b, 0x237e,},
- {0x2474, 0x247e,},
- {0x2577, 0x257e,},
- {0x2639, 0x2640,},
- {0x2659, 0x267e,},
- {0x2742, 0x2750,},
- {0x2772, 0x277e,},
- {0x2841, 0x287e,},
- {0x4f54, 0x4f7e,},
- {0x7425, 0x747e},
- };
- nkf_char i;
- nkf_char start, end, c;
-
- if(c2 >= 0x00 && c2 <= 0x20 && c1 >= 0x7f && c1 <= 0xff) {
- c2 = GETA1;
- c1 = GETA2;
- }
- if((c2 >= 0x29 && c2 <= 0x2f) || (c2 >= 0x75 && c2 <= 0x7e)) {
- c2 = GETA1;
- c1 = GETA2;
- }
-
- for (i = 0; i < RANGE_NUM_MAX; i++) {
- start = range[i][0];
- end = range[i][1];
- c = (c2 << 8) + c1;
- if (c >= start && c <= end) {
- c2 = GETA1;
- c1 = GETA2;
- }
- }
- (*o_iso2022jp_check_conv)(c2,c1);
-}
-
-
-/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
-
-static 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?",
- (const unsigned char *)"\075?ISO-8859-1?B?",
- (const unsigned char *)"\075?ISO-2022-JP?B?",
- (const unsigned char *)"\075?ISO-2022-JP?B?",
- (const unsigned char *)"\075?ISO-2022-JP?Q?",
-#if defined(UTF8_INPUT_ENABLE)
- (const unsigned char *)"\075?UTF-8?B?",
- (const unsigned char *)"\075?UTF-8?Q?",
-#endif
- (const unsigned char *)"\075?US-ASCII?Q?",
- NULL
-};
-
-
-/* $B3:Ev$9$k%3!<%I$NM%@hEY$r>e$2$k$?$a$NL\0u(B */
-static nkf_char (*const mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) = {
- e_iconv, s_iconv, 0, 0, 0, 0, 0,
-#if defined(UTF8_INPUT_ENABLE)
- w_iconv, w_iconv,
-#endif
- 0,
-};
-
-static const nkf_char mime_encode[] = {
- EUC_JP, SHIFT_JIS, ISO_8859_1, ISO_8859_1, JIS_X_0208, JIS_X_0201_1976_K, JIS_X_0201_1976_K,
-#if defined(UTF8_INPUT_ENABLE)
- UTF_8, UTF_8,
-#endif
- ASCII,
- 0
-};
-
-static const nkf_char mime_encode_method[] = {
- 'B', 'B','Q', 'B', 'B', 'B', 'Q',
-#if defined(UTF8_INPUT_ENABLE)
- 'B', 'Q',
-#endif
- 'Q',
- 0
-};
-
-
-/* MIME preprocessor fifo */
-
-#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */
-#define MIME_BUF_MASK (MIME_BUF_SIZE-1)
-#define mime_input_buf(n) mime_input_state.buf[(n)&MIME_BUF_MASK]
-static struct {
- unsigned char buf[MIME_BUF_SIZE];
- unsigned int top;
- unsigned int last; /* decoded */
- unsigned int input; /* undecoded */
-} mime_input_state;
-static nkf_char (*mime_iconv_back)(nkf_char c2,nkf_char c1,nkf_char c0) = NULL;
-
-#define MAXRECOVER 20
-
-static void
-mime_input_buf_unshift(nkf_char c)
-{
- mime_input_buf(--mime_input_state.top) = (unsigned char)c;
-}
-
-static nkf_char
-mime_ungetc(nkf_char c, ARG_UNUSED FILE *f)
-{
- mime_input_buf_unshift(c);
- return c;
-}
-
-static nkf_char
-mime_ungetc_buf(nkf_char c, FILE *f)
-{
- if (mimebuf_f)
- (*i_mungetc_buf)(c,f);
- else
- mime_input_buf(--mime_input_state.input) = (unsigned char)c;
- return c;
-}
-
-static nkf_char
-mime_getc_buf(FILE *f)
-{
- /* we don't keep eof of mime_input_buf, because it contains ?= as
- a terminator. It was checked in mime_integrity. */
- return ((mimebuf_f)?
- (*i_mgetc_buf)(f):mime_input_buf(mime_input_state.input++));
-}
-
-static void
-switch_mime_getc(void)
-{
- if (i_getc!=mime_getc) {
- i_mgetc = i_getc; i_getc = mime_getc;
- i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
- if(mime_f==STRICT_MIME) {
- i_mgetc_buf = i_mgetc; i_mgetc = mime_getc_buf;
- i_mungetc_buf = i_mungetc; i_mungetc = mime_ungetc_buf;
- }
- }
-}
-
-static void
-unswitch_mime_getc(void)
-{
- if(mime_f==STRICT_MIME) {
- i_mgetc = i_mgetc_buf;
- i_mungetc = i_mungetc_buf;
- }
- i_getc = i_mgetc;
- i_ungetc = i_mungetc;
- if(mime_iconv_back)set_iconv(FALSE, mime_iconv_back);
- mime_iconv_back = NULL;
-}
-
-static nkf_char
-mime_integrity(FILE *f, const unsigned char *p)
-{
- nkf_char c,d;
- unsigned int q;
- /* In buffered mode, read until =? or NL or buffer full
- */
- mime_input_state.input = mime_input_state.top;
- mime_input_state.last = mime_input_state.top;
-
- while(*p) mime_input_buf(mime_input_state.input++) = *p++;
- d = 0;
- q = mime_input_state.input;
- while((c=(*i_getc)(f))!=EOF) {
- if (((mime_input_state.input-mime_input_state.top)&MIME_BUF_MASK)==0) {
- break; /* buffer full */
- }
- if (c=='=' && d=='?') {
- /* checked. skip header, start decode */
- mime_input_buf(mime_input_state.input++) = (unsigned char)c;
- /* mime_last_input = mime_input_state.input; */
- mime_input_state.input = q;
- switch_mime_getc();
- return 1;
- }
- if (!( (c=='+'||c=='/'|| c=='=' || c=='?' || is_alnum(c))))
- break;
- /* Should we check length mod 4? */
- mime_input_buf(mime_input_state.input++) = (unsigned char)c;
- d=c;
- }
- /* In case of Incomplete MIME, no MIME decode */
- mime_input_buf(mime_input_state.input++) = (unsigned char)c;
- mime_input_state.last = mime_input_state.input; /* point undecoded buffer */
- mime_decode_mode = 1; /* no decode on mime_input_buf last in mime_getc */
- switch_mime_getc(); /* anyway we need buffered getc */
- return 1;
-}
-
-static nkf_char
-mime_begin_strict(FILE *f)
-{
- nkf_char c1 = 0;
- int i,j,k;
- const unsigned char *p,*q;
- nkf_char r[MAXRECOVER]; /* recovery buffer, max mime pattern length */
-
- mime_decode_mode = FALSE;
- /* =? has been checked */
- j = 0;
- 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]) {
- /* pattern fails, try next one */
- q = p;
- while (mime_pattern[++j]) {
- p = mime_pattern[j];
- for(k=2;k<i;k++) /* assume length(p) > i */
- if (p[k]!=q[k]) break;
- if (k==i && nkf_toupper(c1)==p[k]) break;
- }
- p = mime_pattern[j];
- if (p) continue; /* found next one, continue */
- /* all fails, output from recovery buffer */
- (*i_ungetc)(c1,f);
- for(j=0;j<i;j++) {
- (*oconv)(0,r[j]);
- }
- return c1;
- }
- }
- mime_decode_mode = p[i-2];
-
- mime_iconv_back = iconv;
- set_iconv(FALSE, mime_priority_func[j]);
- clr_code_score(find_inputcode_byfunc(mime_priority_func[j]), SCORE_iMIME);
-
- if (mime_decode_mode=='B') {
- mimebuf_f = unbuf_f;
- if (!unbuf_f) {
- /* do MIME integrity check */
- return mime_integrity(f,mime_pattern[j]);
- }
- }
- switch_mime_getc();
- mimebuf_f = TRUE;
- return c1;
-}
-
-static nkf_char
-mime_begin(FILE *f)
-{
- nkf_char c1 = 0;
- int i,k;
-
- /* In NONSTRICT mode, only =? is checked. In case of failure, we */
- /* re-read and convert again from mime_buffer. */
-
- /* =? has been checked */
- k = mime_input_state.last;
- mime_input_buf(mime_input_state.last++)='='; mime_input_buf(mime_input_state.last++)='?';
- for(i=2;i<MAXRECOVER;i++) { /* start at =? */
- /* We accept any character type even if it is breaked by new lines */
- c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
- if (c1==LF||c1==SP||c1==CR||
- c1=='-'||c1=='_'||is_alnum(c1)) continue;
- if (c1=='=') {
- /* Failed. But this could be another MIME preemble */
- (*i_ungetc)(c1,f);
- mime_input_state.last--;
- break;
- }
- if (c1!='?') break;
- else {
- /* c1=='?' */
- c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
- if (!(++i<MAXRECOVER) || c1==EOF) break;
- if (c1=='b'||c1=='B') {
- mime_decode_mode = 'B';
- } else if (c1=='q'||c1=='Q') {
- mime_decode_mode = 'Q';
- } else {
- break;
- }
- c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
- if (!(++i<MAXRECOVER) || c1==EOF) break;
- if (c1!='?') {
- mime_decode_mode = FALSE;
- }
- break;
- }
- }
- switch_mime_getc();
- if (!mime_decode_mode) {
- /* false MIME premble, restart from mime_buffer */
- mime_decode_mode = 1; /* no decode, but read from the mime_buffer */
- /* Since we are in MIME mode until buffer becomes empty, */
- /* we never go into mime_begin again for a while. */
- return c1;
- }
- /* discard mime preemble, and goto MIME mode */
- mime_input_state.last = k;
- /* do no MIME integrity check */
- return c1; /* used only for checking EOF */
-}
-
-#ifdef CHECK_OPTION
-static void
-no_putc(ARG_UNUSED nkf_char c)
-{
- ;
-}
-
-static void
-debug(const char *str)
-{
- if (debug_f){
- fprintf(stderr, "%s\n", str ? str : "NULL");
- }
-}
-#endif
-
-static void
-set_input_codename(const char *codename)
-{
- if (!input_codename) {
- input_codename = codename;
- } else if (strcmp(codename, input_codename) != 0) {
- input_codename = "";
- }
-}
-
-static const 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_X0213)
- input_codename = "EUC-JIS-2004";
- else 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";
- }
- }
- return input_codename;
-}
-
-#if !defined(PERL_XS) && !defined(WIN32DLL)
-static 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%s%s\n",
- input_codename,
- iconv != w_iconv16 && iconv != w_iconv32 ? "" :
- input_endian == ENDIAN_LITTLE ? " LE" :
- input_endian == ENDIAN_BIG ? " BE" :
- "[BUG]",
- input_bom_f ? " (BOM)" : "",
- input_eol == CR ? " (CR)" :
- input_eol == LF ? " (LF)" :
- input_eol == CRLF ? " (CRLF)" :
- input_eol == EOF ? " (MIXED NL)" :
- "");
- }
- }
-}
-#endif /*WIN32DLL*/
-
-#ifdef INPUT_OPTION
-
-static nkf_char
-hex_getc(nkf_char ch, FILE *f, nkf_char (*g)(FILE *f), nkf_char (*u)(nkf_char c, FILE *f))
-{
- nkf_char c1, c2, c3;
- c1 = (*g)(f);
- if (c1 != ch){
- return c1;
- }
- c2 = (*g)(f);
- if (!nkf_isxdigit(c2)){
- (*u)(c2, f);
- return c1;
- }
- c3 = (*g)(f);
- if (!nkf_isxdigit(c3)){
- (*u)(c2, f);
- (*u)(c3, f);
- return c1;
- }
- return (hex2bin(c2) << 4) | hex2bin(c3);
-}
-
-static nkf_char
-cap_getc(FILE *f)
-{
- return hex_getc(':', f, i_cgetc, i_cungetc);
-}
-
-static nkf_char
-cap_ungetc(nkf_char c, FILE *f)
-{
- return (*i_cungetc)(c, f);
-}
-
-static nkf_char
-url_getc(FILE *f)
-{
- return hex_getc('%', f, i_ugetc, i_uungetc);
-}
-
-static nkf_char
-url_ungetc(nkf_char c, FILE *f)
-{
- return (*i_uungetc)(c, f);
-}
-#endif
-
-#ifdef NUMCHAR_OPTION
-static nkf_char
-numchar_getc(FILE *f)
-{
- nkf_char (*g)(FILE *) = i_ngetc;
- nkf_char (*u)(nkf_char c ,FILE *f) = i_nungetc;
- int i = 0, j;
- nkf_char buf[12];
- nkf_char c = -1;
-
- buf[i] = (*g)(f);
- if (buf[i] == '&'){
- buf[++i] = (*g)(f);
- if (buf[i] == '#'){
- c = 0;
- buf[++i] = (*g)(f);
- if (buf[i] == 'x' || buf[i] == 'X'){
- for (j = 0; j < 7; j++){
- buf[++i] = (*g)(f);
- if (!nkf_isxdigit(buf[i])){
- if (buf[i] != ';'){
- c = -1;
- }
- break;
- }
- c <<= 4;
- c |= hex2bin(buf[i]);
- }
- }else{
- for (j = 0; j < 8; j++){
- if (j){
- buf[++i] = (*g)(f);
- }
- if (!nkf_isdigit(buf[i])){
- if (buf[i] != ';'){
- c = -1;
- }
- break;
- }
- c *= 10;
- c += hex2bin(buf[i]);
- }
- }
- }
- }
- if (c != -1){
- return nkf_char_unicode_new(c);
- }
- while (i > 0){
- (*u)(buf[i], f);
- --i;
- }
- return buf[0];
-}
-
-static nkf_char
-numchar_ungetc(nkf_char c, FILE *f)
-{
- return (*i_nungetc)(c, f);
-}
-#endif
-
-#ifdef UNICODE_NORMALIZATION
-
-static nkf_char
-nfc_getc(FILE *f)
-{
- nkf_char (*g)(FILE *f) = i_nfc_getc;
- nkf_char (*u)(nkf_char c ,FILE *f) = i_nfc_ungetc;
- nkf_buf_t *buf = nkf_state->nfc_buf;
- const unsigned char *array;
- int lower=0, upper=NORMALIZATION_TABLE_LENGTH-1;
- nkf_char c = (*g)(f);
-
- if (c == EOF || c > 0xFF || (c & 0xc0) == 0x80) return c;
-
- nkf_buf_push(buf, c);
- do {
- while (lower <= upper) {
- int mid = (lower+upper) / 2;
- int len;
- array = normalization_table[mid].nfd;
- for (len=0; len < NORMALIZATION_TABLE_NFD_LENGTH && array[len]; len++) {
- if (len >= nkf_buf_length(buf)) {
- c = (*g)(f);
- if (c == EOF) {
- len = 0;
- lower = 1, upper = 0;
- break;
- }
- nkf_buf_push(buf, c);
- }
- if (array[len] != nkf_buf_at(buf, len)) {
- if (array[len] < nkf_buf_at(buf, len)) lower = mid + 1;
- else upper = mid - 1;
- len = 0;
- break;
- }
- }
- if (len > 0) {
- int i;
- array = normalization_table[mid].nfc;
- nkf_buf_clear(buf);
- for (i=0; i < NORMALIZATION_TABLE_NFC_LENGTH && array[i]; i++)
- nkf_buf_push(buf, array[i]);
- break;
- }
- }
- } while (lower <= upper);
-
- while (nkf_buf_length(buf) > 1) (*u)(nkf_buf_pop(buf), f);
- c = nkf_buf_pop(buf);
-
- return c;
-}
-
-static nkf_char
-nfc_ungetc(nkf_char c, FILE *f)
-{
- return (*i_nfc_ungetc)(c, f);
-}
-#endif /* UNICODE_NORMALIZATION */
-
-
-static nkf_char
-base64decode(nkf_char c)
-{
- int i;
- 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 {
- i = '?' /* 63 */ ; /* / 63 */
- }
- return (i);
-}
-
-static nkf_char
-mime_getc(FILE *f)
-{
- nkf_char c1, c2, c3, c4, cc;
- nkf_char t1, t2, t3, t4, mode, exit_mode;
- nkf_char lwsp_count;
- char *lwsp_buf;
- char *lwsp_buf_new;
- nkf_char lwsp_size = 128;
-
- if (mime_input_state.top != mime_input_state.last) { /* Something is in FIFO */
- return mime_input_buf(mime_input_state.top++);
- }
- if (mime_decode_mode==1 ||mime_decode_mode==FALSE) {
- mime_decode_mode=FALSE;
- unswitch_mime_getc();
- return (*i_getc)(f);
- }
-
- if (mimebuf_f == FIXED_MIME)
- exit_mode = mime_decode_mode;
- else
- exit_mode = FALSE;
- if (mime_decode_mode == 'Q') {
- if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
- restart_mime_q:
- if (c1=='_' && mimebuf_f != FIXED_MIME) return SP;
- if (c1<=SP || 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) {
- /* end Q encoding */
- input_mode = exit_mode;
- lwsp_count = 0;
- lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
- while ((c1=(*i_getc)(f))!=EOF) {
- switch (c1) {
- case LF:
- case CR:
- if (c1==LF) {
- if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = LF;
- } else {
- if ((c1=(*i_getc)(f))!=EOF && c1 == LF) {
- if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(LF,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- }
- break;
- case SP:
- case TAB:
- lwsp_buf[lwsp_count] = (unsigned char)c1;
- if (lwsp_count++>lwsp_size){
- lwsp_size <<= 1;
- lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
- lwsp_buf = lwsp_buf_new;
- }
- continue;
- }
- break;
- }
- if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && 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);
- c1 = lwsp_buf[0];
- }
- nkf_xfree(lwsp_buf);
- return c1;
- }
- if (c1=='='&&c2<SP) { /* this is soft wrap */
- while((c1 = (*i_mgetc)(f)) <=SP) {
- if (c1 == EOF) return (EOF);
- }
- mime_decode_mode = 'Q'; /* still in MIME */
- goto restart_mime_q;
- }
- if (c1=='?') {
- mime_decode_mode = 'Q'; /* still in MIME */
- (*i_mungetc)(c2,f);
- return c1;
- }
- if ((c3 = (*i_mgetc)(f)) == EOF) return (EOF);
- if (c2<=SP) return c2;
- mime_decode_mode = 'Q'; /* still in MIME */
- return ((hex2bin(c2)<<4) + hex2bin(c3));
- }
-
- if (mime_decode_mode != 'B') {
- mime_decode_mode = FALSE;
- return (*i_mgetc)(f);
- }
-
-
- /* Base64 encoding */
- /*
- MIME allows line break in the middle of
- Base64, but we are very pessimistic in decoding
- in unbuf mode because MIME encoded code may broken by
- less or editor's control sequence (such as ESC-[-K in unbuffered
- mode. ignore incomplete MIME.
- */
- mode = mime_decode_mode;
- mime_decode_mode = exit_mode; /* prepare for quit */
-
- while ((c1 = (*i_mgetc)(f))<=SP) {
- if (c1==EOF)
- return (EOF);
- }
- mime_c2_retry:
- if ((c2 = (*i_mgetc)(f))<=SP) {
- if (c2==EOF)
- return (EOF);
- if (mime_f != STRICT_MIME) goto mime_c2_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
- return c2;
- }
- if ((c1 == '?') && (c2 == '=')) {
- input_mode = ASCII;
- lwsp_count = 0;
- lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
- while ((c1=(*i_getc)(f))!=EOF) {
- switch (c1) {
- case LF:
- case CR:
- if (c1==LF) {
- if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = LF;
- } else {
- if ((c1=(*i_getc)(f))!=EOF) {
- if (c1==SP) {
- i_ungetc(SP,f);
- continue;
- } else if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(LF,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- }
- break;
- case SP:
- case TAB:
- lwsp_buf[lwsp_count] = (unsigned char)c1;
- if (lwsp_count++>lwsp_size){
- lwsp_size <<= 1;
- lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
- lwsp_buf = lwsp_buf_new;
- }
- continue;
- }
- break;
- }
- if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && 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);
- c1 = lwsp_buf[0];
- }
- nkf_xfree(lwsp_buf);
- return c1;
- }
- mime_c3_retry:
- if ((c3 = (*i_mgetc)(f))<=SP) {
- if (c3==EOF)
- return (EOF);
- if (mime_f != STRICT_MIME) goto mime_c3_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
- return c3;
- }
- mime_c4_retry:
- if ((c4 = (*i_mgetc)(f))<=SP) {
- if (c4==EOF)
- return (EOF);
- if (mime_f != STRICT_MIME) goto mime_c4_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
- return c4;
- }
-
- mime_decode_mode = mode; /* still in MIME sigh... */
-
- /* BASE 64 decoding */
-
- t1 = 0x3f & base64decode(c1);
- t2 = 0x3f & base64decode(c2);
- t3 = 0x3f & base64decode(c3);
- t4 = 0x3f & base64decode(c4);
- cc = ((t1 << 2) & 0x0fc) | ((t2 >> 4) & 0x03);
- if (c2 != '=') {
- mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
- cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f);
- if (c3 != '=') {
- mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
- cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f);
- if (c4 != '=')
- mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
- }
- } else {
- return c1;
- }
- return mime_input_buf(mime_input_state.top++);
-}
-
-static const char basis_64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-#define MIMEOUT_BUF_LENGTH 74
-static struct {
- unsigned char buf[MIMEOUT_BUF_LENGTH+1];
- int count;
-} mimeout_state;
-
-/*nkf_char mime_lastchar2, mime_lastchar1;*/
-
-static void
-open_mime(nkf_char mode)
-{
- const unsigned char *p;
- int i;
- int j;
- p = mime_pattern[0];
- for(i=0;mime_pattern[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_state.count>0 && nkf_isblank(mimeout_state.buf[i])){
- (*o_mputc)(mimeout_state.buf[i]);
- i++;
- }
- put_newline(o_mputc);
- (*o_mputc)(SP);
- base64_count = 1;
- if (mimeout_state.count>0 && nkf_isspace(mimeout_state.buf[i])) {
- i++;
- }
- }
- for (;i<mimeout_state.count;i++) {
- if (nkf_isspace(mimeout_state.buf[i])) {
- (*o_mputc)(mimeout_state.buf[i]);
- base64_count ++;
- } else {
- break;
- }
- }
- while(*p) {
- (*o_mputc)(*p++);
- base64_count ++;
- }
- j = mimeout_state.count;
- mimeout_state.count = 0;
- for (;i<j;i++) {
- mime_putc(mimeout_state.buf[i]);
- }
-}
-
-static void
-mime_prechar(nkf_char c2, nkf_char c1)
-{
- if (mimeout_mode > 0){
- if (c2 == EOF){
- if (base64_count + mimeout_state.count/3*4> 73){
- (*o_base64conv)(EOF,0);
- oconv_newline(o_base64conv);
- (*o_base64conv)(0,SP);
- base64_count = 1;
- }
- } else {
- if ((c2 != 0 || c1 > DEL) && base64_count + mimeout_state.count/3*4> 66) {
- (*o_base64conv)(EOF,0);
- oconv_newline(o_base64conv);
- (*o_base64conv)(0,SP);
- base64_count = 1;
- mimeout_mode = -1;
- }
- }
- } else if (c2) {
- if (c2 != EOF && base64_count + mimeout_state.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;
- }
- }
-}
-
-static void
-close_mime(void)
-{
- (*o_mputc)('?');
- (*o_mputc)('=');
- base64_count += 2;
- mimeout_mode = 0;
-}
-
-static void
-eof_mime(void)
-{
- switch(mimeout_mode) {
- case 'Q':
- case 'B':
- break;
- case 2:
- (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0x3)<< 4)]);
- (*o_mputc)('=');
- (*o_mputc)('=');
- base64_count += 3;
- break;
- case 1:
- (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0xF) << 2)]);
- (*o_mputc)('=');
- base64_count += 2;
- break;
- }
- if (mimeout_mode > 0) {
- if (mimeout_f!=FIXED_MIME) {
- close_mime();
- } else if (mimeout_mode != 'Q')
- mimeout_mode = 'B';
- }
-}
-
-static void
-mimeout_addchar(nkf_char c)
-{
- switch(mimeout_mode) {
- case 'Q':
- if (c==CR||c==LF) {
- (*o_mputc)(c);
- base64_count = 0;
- } else if(!nkf_isalnum(c)) {
- (*o_mputc)('=');
- (*o_mputc)(bin2hex(((c>>4)&0xf)));
- (*o_mputc)(bin2hex((c&0xf)));
- base64_count += 3;
- } else {
- (*o_mputc)(c);
- base64_count++;
- }
- break;
- case 'B':
- nkf_state->mimeout_state=c;
- (*o_mputc)(basis_64[c>>2]);
- mimeout_mode=2;
- base64_count ++;
- break;
- case 2:
- (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0x3)<< 4) | ((c & 0xF0) >> 4)]);
- nkf_state->mimeout_state=c;
- mimeout_mode=1;
- base64_count ++;
- break;
- case 1:
- (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0xF) << 2) | ((c & 0xC0) >>6)]);
- (*o_mputc)(basis_64[c & 0x3F]);
- mimeout_mode='B';
- base64_count += 2;
- break;
- default:
- (*o_mputc)(c);
- base64_count++;
- break;
- }
-}
-
-static void
-mime_putc(nkf_char c)
-{
- int i, j;
- nkf_char lastchar;
-
- if (mimeout_f == FIXED_MIME){
- if (mimeout_mode == 'Q'){
- if (base64_count > 71){
- if (c!=CR && c!=LF) {
- (*o_mputc)('=');
- put_newline(o_mputc);
- }
- base64_count = 0;
- }
- }else{
- if (base64_count > 71){
- eof_mime();
- put_newline(o_mputc);
- base64_count = 0;
- }
- if (c == EOF) { /* c==EOF */
- eof_mime();
- }
- }
- if (c != EOF) { /* c==EOF */
- mimeout_addchar(c);
- }
- return;
- }
-
- /* mimeout_f != FIXED_MIME */
-
- if (c == EOF) { /* c==EOF */
- if (mimeout_mode == -1 && mimeout_state.count > 1) open_mime(output_mode);
- j = mimeout_state.count;
- mimeout_state.count = 0;
- i = 0;
- if (mimeout_mode > 0) {
- if (!nkf_isblank(mimeout_state.buf[j-1])) {
- for (;i<j;i++) {
- if (nkf_isspace(mimeout_state.buf[i]) && base64_count < 71){
- break;
- }
- mimeout_addchar(mimeout_state.buf[i]);
- }
- eof_mime();
- for (;i<j;i++) {
- mimeout_addchar(mimeout_state.buf[i]);
- }
- } else {
- for (;i<j;i++) {
- mimeout_addchar(mimeout_state.buf[i]);
- }
- eof_mime();
- }
- } else {
- for (;i<j;i++) {
- mimeout_addchar(mimeout_state.buf[i]);
- }
- }
- return;
- }
-
- if (mimeout_state.count > 0){
- lastchar = mimeout_state.buf[mimeout_state.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) {
- 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;
- }
- }
- if (c != 0x1B) {
- (*o_mputc)(c);
- base64_count++;
- return;
- }
- }
- }
-
- if (mimeout_mode <= 0) {
- if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
- output_mode == UTF_8)) {
- 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;
- }
- }
- for (i=0;i<mimeout_state.count;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- if (mimeout_state.buf[i] == CR || mimeout_state.buf[i] == LF){
- base64_count = 0;
- }else{
- base64_count++;
- }
- }
- if (flag) {
- eof_mime();
- base64_count = 0;
- mimeout_mode = 0;
- }
- mimeout_state.buf[0] = (char)c;
- mimeout_state.count = 1;
- }else{
- if (base64_count > 1
- && base64_count + mimeout_state.count > 76
- && mimeout_state.buf[0] != CR && mimeout_state.buf[0] != LF){
- static const char *str = "boundary=\"";
- static int len = 10;
- i = 0;
-
- for (; i < mimeout_state.count - len; ++i) {
- if (!strncmp((char *)(mimeout_state.buf+i), str, len)) {
- i += len - 2;
- break;
- }
- }
-
- if (i == 0 || i == mimeout_state.count - len) {
- put_newline(o_mputc);
- base64_count = 0;
- if (!nkf_isspace(mimeout_state.buf[0])){
- (*o_mputc)(SP);
- base64_count++;
- }
- }
- else {
- int j;
- for (j = 0; j <= i; ++j) {
- (*o_mputc)(mimeout_state.buf[j]);
- }
- put_newline(o_mputc);
- base64_count = 1;
- for (; j <= mimeout_state.count; ++j) {
- mimeout_state.buf[j - i] = mimeout_state.buf[j];
- }
- mimeout_state.count -= i;
- }
- }
- mimeout_state.buf[mimeout_state.count++] = (char)c;
- if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
- open_mime(output_mode);
- }
- }
- return;
- }else{
- if (lastchar==CR || lastchar == LF){
- for (i=0;i<mimeout_state.count;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- }
- base64_count = 0;
- mimeout_state.count = 0;
- }
- if (lastchar==SP) {
- for (i=0;i<mimeout_state.count-1;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- base64_count++;
- }
- mimeout_state.buf[0] = SP;
- mimeout_state.count = 1;
- }
- open_mime(output_mode);
- }
- }else{
- /* mimeout_mode == 'B', 1, 2 */
- if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
- output_mode == UTF_8)) {
- if (lastchar == CR || lastchar == LF){
- if (nkf_isblank(c)) {
- for (i=0;i<mimeout_state.count;i++) {
- mimeout_addchar(mimeout_state.buf[i]);
- }
- mimeout_state.count = 0;
- } else {
- eof_mime();
- for (i=0;i<mimeout_state.count;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- }
- base64_count = 0;
- mimeout_state.count = 0;
- }
- mimeout_state.buf[mimeout_state.count++] = (char)c;
- return;
- }
- if (nkf_isspace(c)) {
- for (i=0;i<mimeout_state.count;i++) {
- if (SP<mimeout_state.buf[i] && mimeout_state.buf[i]<DEL) {
- eof_mime();
- for (i=0;i<mimeout_state.count;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- base64_count++;
- }
- mimeout_state.count = 0;
- }
- }
- mimeout_state.buf[mimeout_state.count++] = (char)c;
- if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
- eof_mime();
- for (j=0;j<mimeout_state.count;j++) {
- (*o_mputc)(mimeout_state.buf[j]);
- base64_count++;
- }
- mimeout_state.count = 0;
- }
- return;
- }
- if (mimeout_state.count>0 && SP<c && c!='=') {
- mimeout_state.buf[mimeout_state.count++] = (char)c;
- if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
- j = mimeout_state.count;
- mimeout_state.count = 0;
- for (i=0;i<j;i++) {
- mimeout_addchar(mimeout_state.buf[i]);
- }
- }
- return;
- }
- }
- }
- if (mimeout_state.count>0) {
- j = mimeout_state.count;
- mimeout_state.count = 0;
- for (i=0;i<j;i++) {
- if (mimeout_state.buf[i]==CR || mimeout_state.buf[i]==LF)
- break;
- mimeout_addchar(mimeout_state.buf[i]);
- }
- if (i<j) {
- eof_mime();
- base64_count=0;
- for (;i<j;i++) {
- (*o_mputc)(mimeout_state.buf[i]);
- }
- open_mime(output_mode);
- }
- }
- mimeout_addchar(c);
-}
-
-static void
-base64_conv(nkf_char c2, nkf_char c1)
-{
- mime_prechar(c2, c1);
- (*o_base64conv)(c2,c1);
-}
-
-#ifdef HAVE_ICONV_H
-typedef struct nkf_iconv_t {
- iconv_t cd;
- char *input_buffer;
- size_t input_buffer_size;
- char *output_buffer;
- size_t output_buffer_size;
-};
-
-static nkf_iconv_t
-nkf_iconv_new(char *tocode, char *fromcode)
-{
- nkf_iconv_t converter;
-
- converter->input_buffer_size = IOBUF_SIZE;
- converter->input_buffer = nkf_xmalloc(converter->input_buffer_size);
- converter->output_buffer_size = IOBUF_SIZE * 2;
- converter->output_buffer = nkf_xmalloc(converter->output_buffer_size);
- converter->cd = iconv_open(tocode, fromcode);
- if (converter->cd == (iconv_t)-1)
- {
- switch (errno) {
- case EINVAL:
- perror(fprintf("iconv doesn't support %s to %s conversion.", fromcode, tocode));
- return -1;
- default:
- perror("can't iconv_open");
- }
- }
-}
-
-static size_t
-nkf_iconv_convert(nkf_iconv_t *converter, FILE *input)
-{
- size_t invalid = (size_t)0;
- char *input_buffer = converter->input_buffer;
- size_t input_length = (size_t)0;
- char *output_buffer = converter->output_buffer;
- size_t output_length = converter->output_buffer_size;
- int c;
-
- do {
- if (c != EOF) {
- while ((c = (*i_getc)(f)) != EOF) {
- input_buffer[input_length++] = c;
- if (input_length < converter->input_buffer_size) break;
- }
- }
-
- size_t ret = iconv(converter->cd, &input_buffer, &input_length, &output_buffer, &output_length);
- while (output_length-- > 0) {
- (*o_putc)(output_buffer[converter->output_buffer_size-output_length]);
- }
- if (ret == (size_t) - 1) {
- switch (errno) {
- case EINVAL:
- if (input_buffer != converter->input_buffer)
- memmove(converter->input_buffer, input_buffer, input_length);
- break;
- case E2BIG:
- converter->output_buffer_size *= 2;
- output_buffer = realloc(converter->outbuf, converter->output_buffer_size);
- if (output_buffer == NULL) {
- perror("can't realloc");
- return -1;
- }
- converter->output_buffer = output_buffer;
- break;
- default:
- perror("can't iconv");
- return -1;
- }
- } else {
- invalid += ret;
- }
- } while (1);
-
- return invalid;
-}
-
-
-static void
-nkf_iconv_close(nkf_iconv_t *convert)
-{
- nkf_xfree(converter->inbuf);
- nkf_xfree(converter->outbuf);
- iconv_close(converter->cd);
-}
-#endif
-
-
-static void
-reinit(void)
-{
- {
- struct input_code *p = input_code_list;
- while (p->name){
- status_reinit(p++);
- }
- }
- unbuf_f = FALSE;
- estab_f = FALSE;
- nop_f = FALSE;
- binmode_f = TRUE;
- rot_f = FALSE;
- hira_f = FALSE;
- alpha_f = FALSE;
- mime_f = MIME_DECODE_DEFAULT;
- mime_decode_f = FALSE;
- mimebuf_f = FALSE;
- broken_f = FALSE;
- iso8859_f = FALSE;
- mimeout_f = FALSE;
- x0201_f = NKF_UNSPECIFIED;
- iso2022jp_f = FALSE;
-#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
-#ifdef UTF8_INPUT_ENABLE
- no_cp932ext_f = FALSE;
- no_best_fit_chars_f = FALSE;
- encode_fallback = NULL;
- unicode_subchar = '?';
- input_endian = ENDIAN_BIG;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- output_bom_f = FALSE;
- output_endian = ENDIAN_BIG;
-#endif
-#ifdef UNICODE_NORMALIZATION
- nfc_f = FALSE;
-#endif
-#ifdef INPUT_OPTION
- cap_f = FALSE;
- url_f = FALSE;
- numchar_f = FALSE;
-#endif
-#ifdef CHECK_OPTION
- noout_f = FALSE;
- debug_f = FALSE;
-#endif
- guess_f = 0;
-#ifdef EXEC_IO
- exec_f = 0;
-#endif
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
- cp932inv_f = TRUE;
-#endif
-#ifdef X0212_ENABLE
- x0212_f = FALSE;
- x0213_f = FALSE;
-#endif
- {
- int i;
- for (i = 0; i < 256; i++){
- prefix_table[i] = 0;
- }
- }
- hold_count = 0;
- mimeout_state.count = 0;
- mimeout_mode = 0;
- base64_count = 0;
- f_line = 0;
- f_prev = 0;
- fold_preserve_f = FALSE;
- fold_f = FALSE;
- fold_len = 0;
- kanji_intro = DEFAULT_J;
- ascii_intro = DEFAULT_R;
- fold_margin = FOLD_MARGIN;
- o_zconv = no_connection;
- o_fconv = no_connection;
- o_eol_conv = no_connection;
- o_rot_conv = no_connection;
- o_hira_conv = no_connection;
- o_base64conv = no_connection;
- o_iso2022jp_check_conv = no_connection;
- o_putc = std_putc;
- i_getc = std_getc;
- i_ungetc = std_ungetc;
- i_bgetc = std_getc;
- i_bungetc = std_ungetc;
- o_mputc = std_putc;
- i_mgetc = std_getc;
- i_mungetc = std_ungetc;
- i_mgetc_buf = std_getc;
- i_mungetc_buf = std_ungetc;
- output_mode = ASCII;
- input_mode = ASCII;
- mime_decode_mode = FALSE;
- file_out_f = FALSE;
- eolmode_f = 0;
- input_eol = 0;
- prev_cr = 0;
- option_mode = 0;
- z_prev2=0,z_prev1=0;
-#ifdef CHECK_OPTION
- iconv_for_check = 0;
-#endif
- input_codename = NULL;
- input_encoding = NULL;
- output_encoding = NULL;
- nkf_state_init();
-#ifdef WIN32DLL
- reinitdll();
-#endif /*WIN32DLL*/
-}
-
-static int
-module_connection(void)
-{
- if (input_encoding) set_input_encoding(input_encoding);
- if (!output_encoding) {
- output_encoding = nkf_default_encoding();
- }
- if (!output_encoding) {
- if (noout_f || guess_f) output_encoding = nkf_enc_from_index(ISO_2022_JP);
- else return -1;
- }
- set_output_encoding(output_encoding);
- oconv = nkf_enc_to_oconv(output_encoding);
- o_putc = std_putc;
- if (nkf_enc_unicode_p(output_encoding))
- output_mode = UTF_8;
-
- if (x0201_f == NKF_UNSPECIFIED) {
- x0201_f = X0201_DEFAULT;
- }
-
- /* replace continuation module, from output side */
-
- /* output redirection */
-#ifdef CHECK_OPTION
- if (noout_f || guess_f){
- o_putc = no_putc;
- }
-#endif
- if (mimeout_f) {
- o_mputc = o_putc;
- o_putc = mime_putc;
- if (mimeout_f == TRUE) {
- o_base64conv = oconv; oconv = base64_conv;
- }
- /* base64_count = 0; */
- }
-
- if (eolmode_f || guess_f) {
- o_eol_conv = oconv; oconv = eol_conv;
- }
- if (rot_f) {
- o_rot_conv = oconv; oconv = rot_conv;
- }
- if (iso2022jp_f) {
- o_iso2022jp_check_conv = oconv; oconv = iso2022jp_check_conv;
- }
- if (hira_f) {
- o_hira_conv = oconv; oconv = hira_conv;
- }
- if (fold_f) {
- o_fconv = oconv; oconv = fold_conv;
- f_line = 0;
- }
- if (alpha_f || x0201_f) {
- o_zconv = oconv; oconv = z_conv;
- }
-
- i_getc = std_getc;
- i_ungetc = std_ungetc;
- /* input redirection */
-#ifdef INPUT_OPTION
- if (cap_f){
- i_cgetc = i_getc; i_getc = cap_getc;
- i_cungetc = i_ungetc; i_ungetc= cap_ungetc;
- }
- if (url_f){
- i_ugetc = i_getc; i_getc = url_getc;
- i_uungetc = i_ungetc; i_ungetc= url_ungetc;
- }
-#endif
-#ifdef NUMCHAR_OPTION
- if (numchar_f){
- i_ngetc = i_getc; i_getc = numchar_getc;
- i_nungetc = i_ungetc; i_ungetc= numchar_ungetc;
- }
-#endif
-#ifdef UNICODE_NORMALIZATION
- if (nfc_f){
- i_nfc_getc = i_getc; i_getc = nfc_getc;
- i_nfc_ungetc = i_ungetc; i_ungetc= nfc_ungetc;
- }
-#endif
- if (mime_f && mimebuf_f==FIXED_MIME) {
- i_mgetc = i_getc; i_getc = mime_getc;
- i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
- }
- if (broken_f & 1) {
- i_bgetc = i_getc; i_getc = broken_getc;
- i_bungetc = i_ungetc; i_ungetc = broken_ungetc;
- }
- if (input_encoding) {
- set_iconv(-TRUE, nkf_enc_to_iconv(input_encoding));
- } else {
- set_iconv(FALSE, e_iconv);
- }
-
- {
- struct input_code *p = input_code_list;
- while (p->name){
- status_reinit(p++);
- }
- }
- return 0;
-}
-
-/*
- Conversion main loop. Code detection only.
- */
-
-#if !defined(PERL_XS) && !defined(WIN32DLL)
-static nkf_char
-noconvert(FILE *f)
-{
- nkf_char c;
-
- if (nop_f == 2)
- module_connection();
- while ((c = (*i_getc)(f)) != EOF)
- (*o_putc)(c);
- (*o_putc)(EOF);
- return 1;
-}
-#endif
-
-#define NEXT continue /* no output, get next */
-#define SKIP c2=0;continue /* no output, get next */
-#define MORE c2=c1;continue /* need one more byte */
-#define SEND (void)0 /* output c1 and c2, get next */
-#define LAST break /* end of loop, go closing */
-#define set_input_mode(mode) do { \
- input_mode = mode; \
- shift_mode = 0; \
- set_input_codename("ISO-2022-JP"); \
- debug("ISO-2022-JP"); \
-} while (0)
-
-static int
-kanji_convert(FILE *f)
-{
- nkf_char c1=0, c2=0, c3=0, c4=0;
- int shift_mode = 0; /* 0, 1, 2, 3 */
- int g2 = 0;
- int is_8bit = FALSE;
-
- if (input_encoding && !nkf_enc_asciicompat(input_encoding)) {
- is_8bit = TRUE;
- }
-
- input_mode = ASCII;
- output_mode = ASCII;
-
- if (module_connection() < 0) {
-#if !defined(PERL_XS) && !defined(WIN32DLL)
- fprintf(stderr, "no output encoding given\n");
-#endif
- return -1;
- }
- check_bom(f);
-
-#ifdef UTF8_INPUT_ENABLE
- if(iconv == w_iconv32){
- while ((c1 = (*i_getc)(f)) != EOF &&
- (c2 = (*i_getc)(f)) != EOF &&
- (c3 = (*i_getc)(f)) != EOF &&
- (c4 = (*i_getc)(f)) != EOF) {
- nkf_char c5, c6, c7, c8;
- if (nkf_iconv_utf_32(c1, c2, c3, c4) == (size_t)NKF_ICONV_WAIT_COMBINING_CHAR) {
- if ((c5 = (*i_getc)(f)) != EOF &&
- (c6 = (*i_getc)(f)) != EOF &&
- (c7 = (*i_getc)(f)) != EOF &&
- (c8 = (*i_getc)(f)) != EOF) {
- if (nkf_iconv_utf_32_combine(c1, c2, c3, c4, c5, c6, c7, c8)) {
- (*i_ungetc)(c8, f);
- (*i_ungetc)(c7, f);
- (*i_ungetc)(c6, f);
- (*i_ungetc)(c5, f);
- nkf_iconv_utf_32_nocombine(c1, c2, c3, c4);
- }
- } else {
- nkf_iconv_utf_32_nocombine(c1, c2, c3, c4);
- }
- }
- }
- goto finished;
- }
- else if (iconv == w_iconv16) {
- while ((c1 = (*i_getc)(f)) != EOF &&
- (c2 = (*i_getc)(f)) != EOF) {
- size_t ret = nkf_iconv_utf_16(c1, c2, 0, 0);
- if (ret == NKF_ICONV_NEED_TWO_MORE_BYTES &&
- (c3 = (*i_getc)(f)) != EOF &&
- (c4 = (*i_getc)(f)) != EOF) {
- nkf_iconv_utf_16(c1, c2, c3, c4);
- } else if (ret == (size_t)NKF_ICONV_WAIT_COMBINING_CHAR) {
- if ((c3 = (*i_getc)(f)) != EOF &&
- (c4 = (*i_getc)(f)) != EOF) {
- if (nkf_iconv_utf_16_combine(c1, c2, c3, c4)) {
- (*i_ungetc)(c4, f);
- (*i_ungetc)(c3, f);
- nkf_iconv_utf_16_nocombine(c1, c2);
- }
- } else {
- nkf_iconv_utf_16_nocombine(c1, c2);
- }
- }
- }
- goto finished;
- }
-#endif
-
- while ((c1 = (*i_getc)(f)) != EOF) {
-#ifdef INPUT_CODE_FIX
- if (!input_encoding)
-#endif
- code_status(c1);
- if (c2) {
- /* second byte */
- if (c2 > ((input_encoding && nkf_enc_cp5022x_p(input_encoding)) ? 0x92 : DEL)) {
- /* in case of 8th bit is on */
- if (!estab_f&&!mime_decode_mode) {
- /* in case of not established yet */
- /* It is still ambiguous */
- if (h_conv(f, c2, c1)==EOF) {
- LAST;
- }
- else {
- SKIP;
- }
- }
- else {
- /* in case of already established */
- if (c1 < 0x40) {
- /* ignore bogus code */
- SKIP;
- } else {
- SEND;
- }
- }
- }
- else {
- /* 2nd byte of 7 bit code or SJIS */
- SEND;
- }
- }
- else if (nkf_char_unicode_p(c1)) {
- (*oconv)(0, c1);
- NEXT;
- }
- else {
- /* first byte */
- if (input_mode == JIS_X_0208 && DEL <= c1 && c1 < 0x92) {
- /* CP5022x */
- MORE;
- }else if (input_codename && input_codename[0] == 'I' &&
- 0xA1 <= c1 && c1 <= 0xDF) {
- /* JIS X 0201 Katakana in 8bit JIS */
- c2 = JIS_X_0201_1976_K;
- c1 &= 0x7f;
- SEND;
- } else if (c1 > DEL) {
- /* 8 bit code */
- if (!estab_f && !iso8859_f) {
- /* not established yet */
- MORE;
- } else { /* estab_f==TRUE */
- if (iso8859_f) {
- c2 = ISO_8859_1;
- c1 &= 0x7f;
- SEND;
- }
- else if ((iconv == s_iconv && 0xA0 <= c1 && c1 <= 0xDF) ||
- (ms_ucs_map_f == UCS_MAP_CP10001 && (c1 == 0xFD || c1 == 0xFE))) {
- /* JIS X 0201 */
- c2 = JIS_X_0201_1976_K;
- c1 &= 0x7f;
- SEND;
- }
- else {
- /* already established */
- MORE;
- }
- }
- } else if (SP < c1 && c1 < DEL) {
- /* in case of Roman characters */
- if (shift_mode) {
- /* output 1 shifted byte */
- if (iso8859_f) {
- c2 = ISO_8859_1;
- SEND;
- } else if (nkf_byte_jisx0201_katakana_p(c1)){
- /* output 1 shifted byte */
- c2 = JIS_X_0201_1976_K;
- SEND;
- } else {
- /* look like bogus code */
- SKIP;
- }
- } else if (input_mode == JIS_X_0208 || input_mode == JIS_X_0212 ||
- input_mode == JIS_X_0213_1 || input_mode == JIS_X_0213_2) {
- /* in case of Kanji shifted */
- MORE;
- } else if (c1 == '=' && mime_f && !mime_decode_mode) {
- /* Check MIME code */
- if ((c1 = (*i_getc)(f)) == EOF) {
- (*oconv)(0, '=');
- LAST;
- } else if (c1 == '?') {
- /* =? is mime conversion start sequence */
- if(mime_f == STRICT_MIME) {
- /* check in real detail */
- if (mime_begin_strict(f) == EOF)
- LAST;
- SKIP;
- } else if (mime_begin(f) == EOF)
- LAST;
- SKIP;
- } else {
- (*oconv)(0, '=');
- (*i_ungetc)(c1,f);
- SKIP;
- }
- } else {
- /* normal ASCII code */
- SEND;
- }
- } else if (c1 == SI && (!is_8bit || mime_decode_mode)) {
- shift_mode = 0;
- SKIP;
- } else if (c1 == SO && (!is_8bit || mime_decode_mode)) {
- shift_mode = 1;
- SKIP;
- } else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
- if ((c1 = (*i_getc)(f)) == EOF) {
- (*oconv)(0, ESC);
- LAST;
- }
- else if (c1 == '&') {
- /* IRR */
- if ((c1 = (*i_getc)(f)) == EOF) {
- LAST;
- } else {
- SKIP;
- }
- }
- else if (c1 == '$') {
- /* GZDMx */
- if ((c1 = (*i_getc)(f)) == EOF) {
- /* don't send bogus code
- (*oconv)(0, ESC);
- (*oconv)(0, '$'); */
- LAST;
- } else if (c1 == '@' || c1 == 'B') {
- /* JIS X 0208 */
- set_input_mode(JIS_X_0208);
- SKIP;
- } else if (c1 == '(') {
- /* GZDM4 */
- if ((c1 = (*i_getc)(f)) == EOF) {
- /* don't send bogus code
- (*oconv)(0, ESC);
- (*oconv)(0, '$');
- (*oconv)(0, '(');
- */
- LAST;
- } else if (c1 == '@'|| c1 == 'B') {
- /* JIS X 0208 */
- set_input_mode(JIS_X_0208);
- SKIP;
-#ifdef X0212_ENABLE
- } else if (c1 == 'D'){
- set_input_mode(JIS_X_0212);
- SKIP;
-#endif /* X0212_ENABLE */
- } else if (c1 == 'O' || c1 == 'Q'){
- set_input_mode(JIS_X_0213_1);
- SKIP;
- } else if (c1 == 'P'){
- set_input_mode(JIS_X_0213_2);
- SKIP;
- } else {
- /* could be some special code */
- (*oconv)(0, ESC);
- (*oconv)(0, '$');
- (*oconv)(0, '(');
- (*oconv)(0, c1);
- SKIP;
- }
- } else if (broken_f&0x2) {
- /* accept any ESC-(-x as broken code ... */
- input_mode = JIS_X_0208;
- shift_mode = 0;
- SKIP;
- } else {
- (*oconv)(0, ESC);
- (*oconv)(0, '$');
- (*oconv)(0, c1);
- SKIP;
- }
- } else if (c1 == '(') {
- /* GZD4 */
- if ((c1 = (*i_getc)(f)) == EOF) {
- /* don't send bogus code
- (*oconv)(0, ESC);
- (*oconv)(0, '('); */
- LAST;
- }
- else if (c1 == 'I') {
- /* JIS X 0201 Katakana */
- set_input_mode(JIS_X_0201_1976_K);
- shift_mode = 1;
- SKIP;
- }
- else if (c1 == 'B' || c1 == 'J' || c1 == 'H') {
- /* ISO-646IRV:1983 or JIS X 0201 Roman or JUNET */
- set_input_mode(ASCII);
- SKIP;
- }
- else if (broken_f&0x2) {
- set_input_mode(ASCII);
- SKIP;
- }
- else {
- (*oconv)(0, ESC);
- (*oconv)(0, '(');
- SEND;
- }
- }
- else if (c1 == '.') {
- /* G2D6 */
- if ((c1 = (*i_getc)(f)) == EOF) {
- LAST;
- }
- else if (c1 == 'A') {
- /* ISO-8859-1 */
- g2 = ISO_8859_1;
- SKIP;
- }
- else {
- (*oconv)(0, ESC);
- (*oconv)(0, '.');
- SEND;
- }
- }
- else if (c1 == 'N') {
- /* SS2 */
- c1 = (*i_getc)(f);
- if (g2 == ISO_8859_1) {
- c2 = ISO_8859_1;
- SEND;
- }else{
- (*i_ungetc)(c1, f);
- /* lonely ESC */
- (*oconv)(0, ESC);
- SEND;
- }
- }
- else {
- i_ungetc(c1,f);
- /* lonely ESC */
- (*oconv)(0, ESC);
- SKIP;
- }
- } else if (c1 == ESC && iconv == s_iconv) {
- /* ESC in Shift_JIS */
- if ((c1 = (*i_getc)(f)) == EOF) {
- (*oconv)(0, ESC);
- LAST;
- } else if (c1 == '$') {
- /* J-PHONE emoji */
- if ((c1 = (*i_getc)(f)) == EOF) {
- LAST;
- } else if (('E' <= c1 && c1 <= 'G') ||
- ('O' <= c1 && c1 <= 'Q')) {
- /*
- NUM : 0 1 2 3 4 5
- BYTE: G E F O P Q
- C%7 : 1 6 0 2 3 4
- C%7 : 0 1 2 3 4 5 6
- NUM : 2 0 3 4 5 X 1
- */
- static const nkf_char jphone_emoji_first_table[7] =
- {0xE1E0, 0xDFE0, 0xE2E0, 0xE3E0, 0xE4E0, 0xDFE0, 0xE0E0};
- c3 = nkf_char_unicode_new(jphone_emoji_first_table[c1 % 7]);
- if ((c1 = (*i_getc)(f)) == EOF) LAST;
- while (SP <= c1 && c1 <= 'z') {
- (*oconv)(0, c1 + c3);
- if ((c1 = (*i_getc)(f)) == EOF) LAST;
- }
- SKIP;
- }
- else {
- (*oconv)(0, ESC);
- (*oconv)(0, '$');
- SEND;
- }
- }
- else {
- i_ungetc(c1,f);
- /* lonely ESC */
- (*oconv)(0, ESC);
- SKIP;
- }
- } 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
- SEND;
- }
- /* send: */
- switch(input_mode){
- case ASCII:
- switch ((*iconv)(c2, c1, 0)) { /* can be EUC / SJIS / UTF-8 */
- case -2:
- /* 4 bytes UTF-8 */
- if ((c3 = (*i_getc)(f)) != EOF) {
- code_status(c3);
- c3 <<= 8;
- if ((c4 = (*i_getc)(f)) != EOF) {
- code_status(c4);
- (*iconv)(c2, c1, c3|c4);
- }
- }
- break;
- case -3:
- /* 4 bytes UTF-8 (check combining character) */
- if ((c3 = (*i_getc)(f)) != EOF) {
- if ((c4 = (*i_getc)(f)) != EOF) {
- if (w_iconv_combine(c2, c1, 0, c3, c4, 0)) {
- (*i_ungetc)(c4, f);
- (*i_ungetc)(c3, f);
- w_iconv_nocombine(c2, c1, 0);
- }
- } else {
- (*i_ungetc)(c3, f);
- w_iconv_nocombine(c2, c1, 0);
- }
- } else {
- w_iconv_nocombine(c2, c1, 0);
- }
- break;
- case -1:
- /* 3 bytes EUC or UTF-8 */
- if ((c3 = (*i_getc)(f)) != EOF) {
- code_status(c3);
- if ((*iconv)(c2, c1, c3) == -3) {
- /* 6 bytes UTF-8 (check combining character) */
- nkf_char c5, c6;
- if ((c4 = (*i_getc)(f)) != EOF) {
- if ((c5 = (*i_getc)(f)) != EOF) {
- if ((c6 = (*i_getc)(f)) != EOF) {
- if (w_iconv_combine(c2, c1, c3, c4, c5, c6)) {
- (*i_ungetc)(c6, f);
- (*i_ungetc)(c5, f);
- (*i_ungetc)(c4, f);
- w_iconv_nocombine(c2, c1, c3);
- }
- } else {
- (*i_ungetc)(c5, f);
- (*i_ungetc)(c4, f);
- w_iconv_nocombine(c2, c1, c3);
- }
- } else {
- (*i_ungetc)(c4, f);
- w_iconv_nocombine(c2, c1, c3);
- }
- } else {
- w_iconv_nocombine(c2, c1, c3);
- }
- }
- }
- break;
- }
- break;
- case JIS_X_0208:
- case JIS_X_0213_1:
- if (ms_ucs_map_f &&
- 0x7F <= c2 && c2 <= 0x92 &&
- 0x21 <= c1 && c1 <= 0x7E) {
- /* CP932 UDC */
- c1 = nkf_char_unicode_new((c2 - 0x7F) * 94 + c1 - 0x21 + 0xE000);
- c2 = 0;
- }
- (*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
- break;
-#ifdef X0212_ENABLE
- case JIS_X_0212:
- (*oconv)(PREFIX_EUCG3 | c2, c1);
- break;
-#endif /* X0212_ENABLE */
- case JIS_X_0213_2:
- (*oconv)(PREFIX_EUCG3 | c2, c1);
- break;
- default:
- (*oconv)(input_mode, c1); /* other special case */
- }
-
- c2 = 0;
- c3 = 0;
- continue;
- /* goto next_word */
- }
-
-finished:
- /* epilogue */
- (*iconv)(EOF, 0, 0);
- if (!input_codename)
- {
- if (is_8bit) {
- struct input_code *p = input_code_list;
- struct input_code *result = p;
- while (p->name){
- if (p->score < result->score) result = p;
- ++p;
- }
- set_input_codename(result->name);
-#ifdef CHECK_OPTION
- debug(result->name);
-#endif
- }
- }
- return 0;
-}
-
-/*
- * int options(unsigned char *cp)
- *
- * return values:
- * 0: success
- * -1: ArgumentError
- */
-static int
-options(unsigned char *cp)
-{
- nkf_char i, j;
- unsigned char *p;
- unsigned char *cp_back = NULL;
- nkf_encoding *enc;
-
- if (option_mode==1)
- return 0;
- while(*cp && *cp++!='-');
- while (*cp || cp_back) {
- if(!*cp){
- cp = cp_back;
- cp_back = NULL;
- continue;
- }
- p = 0;
- switch (*cp++) {
- case '-': /* literal options */
- if (!*cp || *cp == SP) { /* ignore the rest of arguments */
- option_mode = 1;
- return 0;
- }
- for (i=0;i<(int)(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){
- p = &cp[j] + 1;
- break;
- }
- p = 0;
- }
- if (p == 0) {
-#if !defined(PERL_XS) && !defined(WIN32DLL)
- fprintf(stderr, "unknown long option: --%s\n", cp);
-#endif
- return -1;
- }
- while(*cp && *cp != SP && cp++);
- if (long_option[i].alias[0]){
- cp_back = cp;
- cp = (unsigned char *)long_option[i].alias;
- }else{
-#ifndef PERL_XS
- if (strcmp(long_option[i].name, "help") == 0){
- usage();
- exit(EXIT_SUCCESS);
- }
-#endif
- if (strcmp(long_option[i].name, "ic=") == 0){
- enc = nkf_enc_find((char *)p);
- if (!enc) continue;
- input_encoding = enc;
- continue;
- }
- if (strcmp(long_option[i].name, "oc=") == 0){
- enc = nkf_enc_find((char *)p);
- /* if (enc <= 0) continue; */
- if (!enc) continue;
- output_encoding = enc;
- continue;
- }
- if (strcmp(long_option[i].name, "guess=") == 0){
- if (p[0] == '0' || p[0] == '1') {
- guess_f = 1;
- } else {
- guess_f = 2;
- }
- continue;
- }
-#ifdef OVERWRITE
- if (strcmp(long_option[i].name, "overwrite") == 0){
- file_out_f = TRUE;
- overwrite_f = TRUE;
- preserve_time_f = TRUE;
- continue;
- }
- if (strcmp(long_option[i].name, "overwrite=") == 0){
- file_out_f = TRUE;
- overwrite_f = TRUE;
- preserve_time_f = TRUE;
- backup_f = TRUE;
- backup_suffix = (char *)p;
- continue;
- }
- if (strcmp(long_option[i].name, "in-place") == 0){
- file_out_f = TRUE;
- overwrite_f = TRUE;
- preserve_time_f = FALSE;
- continue;
- }
- if (strcmp(long_option[i].name, "in-place=") == 0){
- file_out_f = TRUE;
- overwrite_f = TRUE;
- preserve_time_f = FALSE;
- backup_f = TRUE;
- backup_suffix = (char *)p;
- continue;
- }
-#endif
-#ifdef INPUT_OPTION
- if (strcmp(long_option[i].name, "cap-input") == 0){
- cap_f = TRUE;
- continue;
- }
- if (strcmp(long_option[i].name, "url-input") == 0){
- url_f = TRUE;
- continue;
- }
-#endif
-#ifdef NUMCHAR_OPTION
- if (strcmp(long_option[i].name, "numchar-input") == 0){
- numchar_f = TRUE;
- continue;
- }
-#endif
-#ifdef CHECK_OPTION
- if (strcmp(long_option[i].name, "no-output") == 0){
- noout_f = TRUE;
- continue;
- }
- if (strcmp(long_option[i].name, "debug") == 0){
- debug_f = TRUE;
- continue;
- }
-#endif
- if (strcmp(long_option[i].name, "cp932") == 0){
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
- cp932inv_f = -TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
-#endif
- continue;
- }
- if (strcmp(long_option[i].name, "no-cp932") == 0){
-#ifdef SHIFTJIS_CP932
- cp51932_f = FALSE;
- cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_ASCII;
-#endif
- continue;
- }
-#ifdef SHIFTJIS_CP932
- if (strcmp(long_option[i].name, "cp932inv") == 0){
- cp932inv_f = -TRUE;
- continue;
- }
-#endif
-
-#ifdef X0212_ENABLE
- if (strcmp(long_option[i].name, "x0212") == 0){
- x0212_f = TRUE;
- continue;
- }
-#endif
-
-#ifdef EXEC_IO
- if (strcmp(long_option[i].name, "exec-in") == 0){
- exec_f = 1;
- return 0;
- }
- if (strcmp(long_option[i].name, "exec-out") == 0){
- exec_f = -1;
- return 0;
- }
-#endif
-#if defined(UTF8_OUTPUT_ENABLE) && defined(UTF8_INPUT_ENABLE)
- if (strcmp(long_option[i].name, "no-cp932ext") == 0){
- no_cp932ext_f = TRUE;
- continue;
- }
- if (strcmp(long_option[i].name, "no-best-fit-chars") == 0){
- no_best_fit_chars_f = TRUE;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-skip") == 0){
- encode_fallback = NULL;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-html") == 0){
- encode_fallback = encode_fallback_html;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-xml") == 0){
- encode_fallback = encode_fallback_xml;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-java") == 0){
- encode_fallback = encode_fallback_java;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-perl") == 0){
- encode_fallback = encode_fallback_perl;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-subchar") == 0){
- encode_fallback = encode_fallback_subchar;
- continue;
- }
- if (strcmp(long_option[i].name, "fb-subchar=") == 0){
- encode_fallback = encode_fallback_subchar;
- unicode_subchar = 0;
- if (p[0] != '0'){
- /* decimal number */
- for (i = 0; i < 7 && nkf_isdigit(p[i]); i++){
- unicode_subchar *= 10;
- unicode_subchar += hex2bin(p[i]);
- }
- }else if(p[1] == 'x' || p[1] == 'X'){
- /* hexadecimal number */
- for (i = 2; i < 8 && nkf_isxdigit(p[i]); i++){
- unicode_subchar <<= 4;
- unicode_subchar |= hex2bin(p[i]);
- }
- }else{
- /* octal number */
- for (i = 1; i < 8 && nkf_isoctal(p[i]); i++){
- unicode_subchar *= 8;
- unicode_subchar += hex2bin(p[i]);
- }
- }
- w16e_conv(unicode_subchar, &i, &j);
- unicode_subchar = i<<8 | j;
- continue;
- }
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- if (strcmp(long_option[i].name, "ms-ucs-map") == 0){
- ms_ucs_map_f = UCS_MAP_MS;
- continue;
- }
-#endif
-#ifdef UNICODE_NORMALIZATION
- if (strcmp(long_option[i].name, "utf8mac-input") == 0){
- nfc_f = TRUE;
- continue;
- }
-#endif
- if (strcmp(long_option[i].name, "prefix=") == 0){
- if (nkf_isgraph(p[0])){
- for (i = 1; nkf_isgraph(p[i]); i++){
- prefix_table[p[i]] = p[0];
- }
- }
- continue;
- }
-#if !defined(PERL_XS) && !defined(WIN32DLL)
- fprintf(stderr, "unsupported long option: --%s\n", long_option[i].name);
-#endif
- return -1;
- }
- continue;
- case 'b': /* buffered mode */
- unbuf_f = FALSE;
- continue;
- case 'u': /* non bufferd mode */
- unbuf_f = TRUE;
- continue;
- case 't': /* transparent mode */
- if (*cp=='1') {
- /* alias of -t */
- cp++;
- nop_f = TRUE;
- } else if (*cp=='2') {
- /*
- * -t with put/get
- *
- * nkf -t2MB hoge.bin | nkf -t2mB | diff -s - hoge.bin
- *
- */
- cp++;
- nop_f = 2;
- } else
- nop_f = TRUE;
- continue;
- case 'j': /* JIS output */
- case 'n':
- output_encoding = nkf_enc_from_index(ISO_2022_JP);
- continue;
- case 'e': /* AT&T EUC output */
- output_encoding = nkf_enc_from_index(EUCJP_NKF);
- continue;
- case 's': /* SJIS output */
- 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_encoding = nkf_enc_from_index(ISO_8859_1);
- continue;
- case 'i': /* Kanji IN ESC-$-@/B */
- if (*cp=='@'||*cp=='B')
- kanji_intro = *cp++;
- continue;
- case 'o': /* ASCII IN ESC-(-J/B/H */
- /* ESC ( H was used in initial JUNET messages */
- 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')
- hira_f |= (*cp++ -'0');
- else
- hira_f |= 1;
- continue;
- case 'r':
- rot_f = TRUE;
- continue;
-#if defined(MSDOS) || defined(__OS2__)
- case 'T':
- binmode_f = FALSE;
- continue;
-#endif
-#ifndef PERL_XS
- case 'V':
- show_configuration();
- exit(EXIT_SUCCESS);
- break;
- case 'v':
- version();
- exit(EXIT_SUCCESS);
- break;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- case 'w': /* UTF-{8,16,32} output */
- if (cp[0] == '8') {
- 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]) {
- cp += 2;
- enc_idx = UTF_16;
- } else if ('3'== cp[0] && '2'==cp[1]) {
- cp += 2;
- enc_idx = UTF_32;
- } else {
- output_encoding = nkf_enc_from_index(UTF_8);
- continue;
- }
- if (cp[0]=='L') {
- cp++;
- output_endian = ENDIAN_LITTLE;
- output_bom_f = TRUE;
- } else if (cp[0] == 'B') {
- cp++;
- output_bom_f = TRUE;
- }
- if (cp[0] == '0'){
- output_bom_f = FALSE;
- cp++;
- enc_idx = enc_idx == UTF_16
- ? (output_endian == ENDIAN_LITTLE ? UTF_16LE : UTF_16BE)
- : (output_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE);
- } else {
- 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
-#ifdef UTF8_INPUT_ENABLE
- case 'W': /* UTF input */
- if (cp[0] == '8') {
- cp++;
- input_encoding = nkf_enc_from_index(UTF_8);
- }else{
- int enc_idx;
- if ('1'== cp[0] && '6'==cp[1]) {
- cp += 2;
- input_endian = ENDIAN_BIG;
- enc_idx = UTF_16;
- } else if ('3'== cp[0] && '2'==cp[1]) {
- cp += 2;
- input_endian = ENDIAN_BIG;
- enc_idx = UTF_32;
- } else {
- input_encoding = nkf_enc_from_index(UTF_8);
- continue;
- }
- if (cp[0]=='L') {
- cp++;
- input_endian = ENDIAN_LITTLE;
- } else if (cp[0] == 'B') {
- cp++;
- input_endian = ENDIAN_BIG;
- }
- enc_idx = (enc_idx == UTF_16
- ? (input_endian == ENDIAN_LITTLE ? UTF_16LE : UTF_16BE)
- : (input_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE));
- input_encoding = nkf_enc_from_index(enc_idx);
- }
- continue;
-#endif
- /* Input code assumption */
- case 'J': /* ISO-2022-JP input */
- input_encoding = nkf_enc_from_index(ISO_2022_JP);
- continue;
- case 'E': /* EUC-JP input */
- input_encoding = nkf_enc_from_index(EUCJP_NKF);
- continue;
- case 'S': /* Shift_JIS input */
- input_encoding = nkf_enc_from_index(SHIFT_JIS);
- continue;
- case 'Z': /* Convert X0208 alphabet to ascii */
- /* 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
- */
- while ('0'<= *cp && *cp <='4') {
- alpha_f |= 1 << (*cp++ - '0');
- }
- alpha_f |= 1;
- continue;
- case 'x': /* Convert X0201 kana to X0208 or X0201 Conversion */
- x0201_f = FALSE; /* No X0201->X0208 conversion */
- /* accept X0201
- ESC-(-I in JIS, EUC, MS Kanji
- SI/SO in JIS, EUC, MS Kanji
- SS2 in EUC, JIS, not in MS Kanji
- MS Kanji (0xa0-0xdf)
- output X0201
- ESC-(-I in JIS (0x20-0x5f)
- SS2 in EUC (0xa0-0xdf)
- 0xa0-0xd in MS Kanji (0xa0-0xdf)
- */
- continue;
- case 'X': /* Convert X0201 kana to X0208 */
- x0201_f = TRUE;
- continue;
- case 'F': /* prserve new lines */
- fold_preserve_f = TRUE;
- case 'f': /* folding -f60 or -f */
- fold_f = TRUE;
- fold_len = 0;
- while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
- fold_len *= 10;
- fold_len += *cp++ - '0';
- }
- if (!(0<fold_len && fold_len<BUFSIZ))
- fold_len = DEFAULT_FOLD;
- if (*cp=='-') {
- fold_margin = 0;
- cp++;
- while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
- fold_margin *= 10;
- fold_margin += *cp++ - '0';
- }
- }
- continue;
- case 'm': /* MIME support */
- /* mime_decode_f = TRUE; */ /* this has too large side effects... */
- if (*cp=='B'||*cp=='Q') {
- mime_decode_mode = *cp++;
- mimebuf_f = FIXED_MIME;
- } else if (*cp=='N') {
- mime_f = TRUE; cp++;
- } else if (*cp=='S') {
- mime_f = STRICT_MIME; cp++;
- } else if (*cp=='0') {
- mime_decode_f = FALSE;
- mime_f = FALSE; cp++;
- } else {
- mime_f = STRICT_MIME;
- }
- continue;
- case 'M': /* MIME output */
- if (*cp=='B') {
- mimeout_mode = 'B';
- mimeout_f = FIXED_MIME; cp++;
- } else if (*cp=='Q') {
- mimeout_mode = 'Q';
- mimeout_f = FIXED_MIME; cp++;
- } else {
- mimeout_f = TRUE;
- }
- continue;
- case 'B': /* Broken JIS support */
- /* bit:0 no ESC JIS
- bit:1 allow any x on ESC-(-x or ESC-$-x
- bit:2 reset to ascii on NL
- */
- if ('9'>= *cp && *cp>='0')
- broken_f |= 1<<(*cp++ -'0');
- else
- broken_f |= TRUE;
- continue;
-#ifndef PERL_XS
- case 'O':/* for Output file */
- file_out_f = TRUE;
- continue;
-#endif
- case 'c':/* add cr code */
- eolmode_f = CRLF;
- continue;
- case 'd':/* delete cr code */
- eolmode_f = LF;
- continue;
- case 'I': /* ISO-2022-JP output */
- iso2022jp_f = TRUE;
- continue;
- case 'L': /* line mode */
- if (*cp=='u') { /* unix */
- eolmode_f = LF; cp++;
- } else if (*cp=='m') { /* mac */
- eolmode_f = CR; cp++;
- } else if (*cp=='w') { /* windows */
- eolmode_f = CRLF; cp++;
- } else if (*cp=='0') { /* no conversion */
- eolmode_f = 0; cp++;
- }
- continue;
-#ifndef PERL_XS
- case 'g':
- if ('2' <= *cp && *cp <= '9') {
- guess_f = 2;
- cp++;
- } else if (*cp == '0' || *cp == '1') {
- guess_f = 1;
- cp++;
- } else {
- guess_f = 1;
- }
- continue;
-#endif
- case SP:
- /* module multiple options in a string are allowed for Perl module */
- while(*cp && *cp++!='-');
- continue;
- default:
-#if !defined(PERL_XS) && !defined(WIN32DLL)
- fprintf(stderr, "unknown option: -%c\n", *(cp-1));
-#endif
- /* bogus option but ignored */
- return -1;
- }
- }
- return 0;
-}
-
-#ifdef WIN32DLL
-#include "nkf32dll.c"
-#elif defined(PERL_XS)
-#else /* WIN32DLL */
-int
-main(int argc, char **argv)
-{
- FILE *fin;
- unsigned char *cp;
-
- char *outfname = NULL;
- char *origfname;
-
-#ifdef EASYWIN /*Easy Win */
- _BufferSize.y = 400;/*Set Scroll Buffer Size*/
-#endif
-#ifdef DEFAULT_CODE_LOCALE
- setlocale(LC_CTYPE, "");
-#endif
- nkf_state_init();
-
- for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) {
- cp = (unsigned char *)*argv;
- options(cp);
-#ifdef EXEC_IO
- if (exec_f){
- int fds[2], pid;
- if (pipe(fds) < 0 || (pid = fork()) < 0){
- abort();
- }
- if (pid == 0){
- if (exec_f > 0){
- close(fds[0]);
- dup2(fds[1], 1);
- }else{
- close(fds[1]);
- dup2(fds[0], 0);
- }
- execvp(argv[1], &argv[1]);
- }
- if (exec_f > 0){
- close(fds[1]);
- dup2(fds[0], 0);
- }else{
- close(fds[0]);
- dup2(fds[1], 1);
- }
- argc = 0;
- break;
- }
-#endif
- }
-
- if (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
- x0212_f = x0212_f_back;
- x0213_f = x0213_f_back;
- }
-
- if (binmode_f == TRUE)
-#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","wb",stdout) == NULL)
- return (-1);
-#else
- setbinmode(stdout);
-#endif
-
- if (unbuf_f)
- setbuf(stdout, (char *) NULL);
- else
- setvbuffer(stdout, (char *) stdobuf, IOBUF_SIZE);
-
- if (argc == 0) {
- if (binmode_f == TRUE)
-#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","rb",stdin) == NULL) return (-1);
-#else
- setbinmode(stdin);
-#endif
- setvbuffer(stdin, (char *) stdibuf, IOBUF_SIZE);
- if (nop_f)
- noconvert(stdin);
- else {
- kanji_convert(stdin);
- if (guess_f) print_guessed_code(NULL);
- }
- } else {
- int nfiles = argc;
- int is_argument_error = FALSE;
- while (argc--) {
- input_codename = NULL;
- input_eol = 0;
-#ifdef CHECK_OPTION
- iconv_for_check = 0;
-#endif
- if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
- perror(*(argv-1));
- is_argument_error = TRUE;
- continue;
- } else {
-#ifdef OVERWRITE
- int fd = 0;
- int fd_backup = 0;
-#endif
-
- /* reopen file for stdout */
- if (file_out_f == TRUE) {
-#ifdef OVERWRITE
- if (overwrite_f){
- outfname = nkf_xmalloc(strlen(origfname)
- + strlen(".nkftmpXXXXXX")
- + 1);
- strcpy(outfname, origfname);
-#ifdef MSDOS
- {
- int i;
- for (i = strlen(outfname); i; --i){
- if (outfname[i - 1] == '/'
- || outfname[i - 1] == '\\'){
- break;
- }
- }
- outfname[i] = '\0';
- }
- strcat(outfname, "ntXXXXXX");
- mktemp(outfname);
- fd = open(outfname, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
- S_IREAD | S_IWRITE);
-#else
- strcat(outfname, ".nkftmpXXXXXX");
- fd = mkstemp(outfname);
-#endif
- if (fd < 0
- || (fd_backup = dup(fileno(stdout))) < 0
- || dup2(fd, fileno(stdout)) < 0
- ){
- perror(origfname);
- return -1;
- }
- }else
-#endif
- if(argc == 1) {
- outfname = *argv++;
- argc--;
- } else {
- outfname = "nkf.out";
- }
-
- if(freopen(outfname, "w", stdout) == NULL) {
- perror (outfname);
- return (-1);
- }
- if (binmode_f == TRUE) {
-#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","wb",stdout) == NULL)
- return (-1);
-#else
- setbinmode(stdout);
-#endif
- }
- }
- if (binmode_f == TRUE)
-#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","rb",fin) == NULL)
- return (-1);
-#else
- setbinmode(fin);
-#endif
- setvbuffer(fin, (char *) stdibuf, IOBUF_SIZE);
- if (nop_f)
- noconvert(fin);
- else {
- char *filename = NULL;
- kanji_convert(fin);
- if (nfiles > 1) filename = origfname;
- if (guess_f) print_guessed_code(filename);
- }
- fclose(fin);
-#ifdef OVERWRITE
- if (overwrite_f) {
- struct stat sb;
-#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__) && !defined(__WATCOMC__) && !defined(__EMX__) && !defined(__OS2__) && !defined(__DJGPP__)
- time_t tb[2];
-#else
- struct utimbuf tb;
-#endif
-
- fflush(stdout);
- close(fd);
- if (dup2(fd_backup, fileno(stdout)) < 0){
- perror("dup2");
- }
- if (stat(origfname, &sb)) {
- fprintf(stderr, "Can't stat %s\n", origfname);
- }
- /* $B%Q!<%_%C%7%g%s$rI|85(B */
- if (chmod(outfname, sb.st_mode)) {
- fprintf(stderr, "Can't set permission %s\n", outfname);
- }
-
- /* $B%?%$%`%9%?%s%W$rI|85(B */
- if(preserve_time_f){
-#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__) && !defined(__WATCOMC__) && !defined(__EMX__) && !defined(__OS2__) && !defined(__DJGPP__)
- tb[0] = tb[1] = sb.st_mtime;
- if (utime(outfname, tb)) {
- fprintf(stderr, "Can't set timestamp %s\n", outfname);
- }
-#else
- tb.actime = sb.st_atime;
- tb.modtime = sb.st_mtime;
- if (utime(outfname, &tb)) {
- fprintf(stderr, "Can't set timestamp %s\n", outfname);
- }
-#endif
- }
- if(backup_f){
- char *backup_filename = get_backup_filename(backup_suffix, origfname);
-#ifdef MSDOS
- unlink(backup_filename);
-#endif
- if (rename(origfname, backup_filename)) {
- perror(backup_filename);
- fprintf(stderr, "Can't rename %s to %s\n",
- origfname, backup_filename);
- }
- nkf_xfree(backup_filename);
- }else{
-#ifdef MSDOS
- if (unlink(origfname)){
- perror(origfname);
- }
-#endif
- }
- if (rename(outfname, origfname)) {
- perror(origfname);
- fprintf(stderr, "Can't rename %s to %s\n",
- outfname, origfname);
- }
- nkf_xfree(outfname);
- }
-#endif
- }
- }
- if (is_argument_error)
- return(-1);
- }
-#ifdef EASYWIN /*Easy Win */
- if (file_out_f == FALSE)
- scanf("%d",&end_check);
- else
- fclose(stdout);
-#else /* for Other OS */
- if (file_out_f == TRUE)
- fclose(stdout);
-#endif /*Easy Win */
- return (0);
-}
-#endif /* WIN32DLL */
diff --git a/ext/nkf/nkf-utf8/nkf.h b/ext/nkf/nkf-utf8/nkf.h
deleted file mode 100644
index b3a520da54..0000000000
--- a/ext/nkf/nkf-utf8/nkf.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- *
- * nkf.h - Header file for nkf
- *
- */
-
-#ifndef NKF_H
-#define NKF_H
-
-/* Wrapper of configurations */
-
-#ifndef MIME_DECODE_DEFAULT
-#define MIME_DECODE_DEFAULT STRICT_MIME
-#endif
-#ifndef X0201_DEFAULT
-#define X0201_DEFAULT TRUE
-#endif
-
-#if defined(DEFAULT_NEWLINE) && DEFAULT_NEWLINE == 0x0D0A
-#elif defined(DEFAULT_NEWLINE) && DEFAULT_NEWLINE == 0x0D
-#else
-#define DEFAULT_NEWLINE 0x0A
-#endif
-#ifdef HELP_OUTPUT_STDERR
-#define HELP_OUTPUT stderr
-#else
-#define HELP_OUTPUT stdout
-#endif
-
-
-/* Compatibility definitions */
-
-#ifdef nkf_char
-#elif defined(INT_IS_SHORT)
-typedef long nkf_char;
-#define NKF_INT32_C(n) (n##L)
-#else
-typedef int nkf_char;
-#define NKF_INT32_C(n) (n)
-#endif
-
-#if (defined(__TURBOC__) || defined(_MSC_VER) || defined(LSI_C) || (defined(__WATCOMC__) && defined(__386__) && !defined(__LINUX__)) || defined(__MINGW32__) || defined(__EMX__) || defined(__MSDOS__) || defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)) && !defined(MSDOS)
-#define MSDOS
-#if (defined(__Win32__) || defined(_WIN32)) && !defined(__WIN32__)
-#define __WIN32__
-#endif
-#endif
-
-#ifdef PERL_XS
-#undef OVERWRITE
-#endif
-
-#ifndef PERL_XS
-#include <stdio.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(MSDOS) || defined(__OS2__)
-#include <fcntl.h>
-#include <io.h>
-#if defined(_MSC_VER) || defined(__WATCOMC__)
-#define mktemp _mktemp
-#endif
-#endif
-
-#ifdef MSDOS
-#ifdef LSI_C
-#define setbinmode(fp) fsetbin(fp)
-#elif defined(__DJGPP__)
-#include <libc/dosio.h>
-void setbinmode(FILE *fp)
-{
- /* we do not use libc's setmode(), which changes COOKED/RAW mode in device. */
- int fd, m;
- fd = fileno(fp);
- m = (__file_handle_modes[fd] & (~O_TEXT)) | O_BINARY;
- __file_handle_set(fd, m);
-}
-#else /* Microsoft C, Turbo C */
-#define setbinmode(fp) setmode(fileno(fp), O_BINARY)
-#endif
-#else /* UNIX */
-#define setbinmode(fp) (void)(fp)
-#endif
-
-#ifdef _IOFBF /* SysV and MSDOS, Windows */
-#define setvbuffer(fp, buf, size) setvbuf(fp, buf, _IOFBF, size)
-#else /* BSD */
-#define setvbuffer(fp, buf, size) setbuffer(fp, buf, size)
-#endif
-
-/*Borland C++ 4.5 EasyWin*/
-#if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */
-#define EASYWIN
-#ifndef __WIN16__
-#define __WIN16__
-#endif
-#include <windows.h>
-#endif
-
-#ifdef OVERWRITE
-/* added by satoru@isoternet.org */
-#if defined(__EMX__)
-#include <sys/types.h>
-#endif
-#include <sys/stat.h>
-#if !defined(MSDOS) || defined(__DJGPP__) /* UNIX, djgpp */
-#include <unistd.h>
-#if defined(__WATCOMC__)
-#include <sys/utime.h>
-#else
-#include <utime.h>
-#endif
-#else /* defined(MSDOS) */
-#ifdef __WIN32__
-#ifdef __BORLANDC__ /* BCC32 */
-#include <utime.h>
-#else /* !defined(__BORLANDC__) */
-#include <sys/utime.h>
-#endif /* (__BORLANDC__) */
-#else /* !defined(__WIN32__) */
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__OS2__) || defined(__EMX__) || defined(__IBMC__) || defined(__IBMCPP__) /* VC++, MinGW, Watcom, emx+gcc, IBM VAC++ */
-#include <sys/utime.h>
-#elif defined(__TURBOC__) /* BCC */
-#include <utime.h>
-#elif defined(LSI_C) /* LSI C */
-#endif /* (__WIN32__) */
-#endif
-#endif
-#endif
-
-#if !defined(DEFAULT_CODE_JIS) && !defined(DEFAULT_CODE_SJIS) && \
- !defined(DEFAULT_CODE_WINDOWS_31J) && !defined(DEFAULT_CODE_EUC) && \
- !defined(DEFAULT_CODE_UTF8) && !defined(DEFAULT_CODE_LOCALE)
-#define DEFAULT_CODE_LOCALE
-#endif
-
-#ifdef DEFAULT_CODE_LOCALE
-
-#if defined(__WIN32__) /* not win32 should be posix */
-# ifndef HAVE_LOCALE_H
-# define HAVE_LOCALE_H
-# endif
-#elif defined(__OS2__)
-# undef HAVE_LANGINFO_H /* We do not use kLIBC's langinfo. */
-# ifndef HAVE_LOCALE_H
-# define HAVE_LOCALE_H
-# endif
-#elif defined(MSDOS)
-# ifndef HAVE_LOCALE_H
-# define HAVE_LOCALE_H
-# endif
-#elif defined(__BIONIC__) /* bionic doesn't have locale */
-#else
-# ifndef HAVE_LANGINFO_H
-# define HAVE_LANGINFO_H
-# endif
-# ifndef HAVE_LOCALE_H
-# define HAVE_LOCALE_H
-# endif
-#endif
-
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif
-
-#endif /* DEFAULT_CODE_LOCALE */
-
-#define FALSE 0
-#define TRUE 1
-
-#ifndef ARG_UNUSED
-#if defined(__GNUC__)
-# define ARG_UNUSED __attribute__ ((unused))
-#else
-# define ARG_UNUSED
-#endif
-#endif
-
-#ifdef WIN32DLL
-#include "nkf32.h"
-#endif
-
-#endif /* NKF_H */
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
deleted file mode 100644
index a31e4e7805..0000000000
--- a/ext/nkf/nkf-utf8/utf8tbl.c
+++ /dev/null
@@ -1,14638 +0,0 @@
-/*
- * utf8tbl.c - Conversion Table for nkf
- *
- */
-
-#include "config.h"
-#include "utf8tbl.h"
-
-#ifdef UTF8_OUTPUT_ENABLE
-static const unsigned short euc_to_utf8_A1[] = {
- 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
- 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
- 0xFF3E, 0x203E, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
- 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2014, 0x2010, 0xFF0F,
- 0xFF3C, 0x301C, 0x2016, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
- 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
- 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
- 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0x2212, 0x00B1, 0x00D7,
- 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
- 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0x00A5,
- 0xFF04, 0x00A2, 0x00A3, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
- 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
-};
-
-/* Microsoft UCS Mapping Compatible */
-static const unsigned short euc_to_utf8_A1_ms[] = {
- 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
- 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
- 0xFF3E, 0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
- 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2015, 0x2010, 0xFF0F,
- 0xFF3C, 0xFF5E, 0x2225, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
- 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
- 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
- 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0xFF0D, 0x00B1, 0x00D7,
- 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
- 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0xFFE5,
- 0xFF04, 0xFFE0, 0xFFE1, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
- 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
-};
-static const unsigned short euc_to_utf8_A2[] = {
- 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
- 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
- 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2227, 0x2228, 0x00AC, 0x21D2, 0x21D4, 0x2200,
- 0x2203, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
- 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
- 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
- 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
- 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
-};
-
-/* Microsoft UCS Mapping Compatible */
-static const unsigned short euc_to_utf8_A2_ms[] = {
- 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
- 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
- 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2227, 0x2228, 0xFFE2, 0x21D2, 0x21D4, 0x2200,
- 0x2203, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
- 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
- 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
- 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
- 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
-};
-static const unsigned short euc_to_utf8_A2_x0213[] = {
- 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
- 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0xFF07,
- 0xFF02, 0xFF0D, 0xFF5E, 0x3033, 0x3034, 0x3035, 0x303B, 0x303C,
- 0x30FF, 0x309F, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
- 0x222A, 0x2229, 0x2284, 0x2285, 0x228A, 0x228B, 0x2209, 0x2205,
- 0x2305, 0x2306, 0x2227, 0x2228, 0x00AC, 0x21D2, 0x21D4, 0x2200,
- 0x2203, 0x2295, 0x2296, 0x2297, 0x2225, 0x2226, 0xFF5F, 0xFF60,
- 0x3018, 0x3019, 0x3016, 0x3017, 0x2220, 0x22A5, 0x2312, 0x2202,
- 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
- 0x2235, 0x222B, 0x222C, 0x2262, 0x2243, 0x2245, 0x2248, 0x2276,
- 0x2277, 0x2194, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
- 0x2021, 0x00B6, 0x266E, 0x266B, 0x266C, 0x2669, 0x25EF,
-};
-static const unsigned short euc_to_utf8_A3[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
- 0xFF18, 0xFF19, 0, 0, 0, 0, 0, 0,
- 0, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27,
- 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F,
- 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37,
- 0xFF38, 0xFF39, 0xFF3A, 0, 0, 0, 0, 0,
- 0, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
- 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
- 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
- 0xFF58, 0xFF59, 0xFF5A, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A3_x0213[] = {
- 0x25B7, 0x25B6, 0x25C1, 0x25C0, 0x2197, 0x2198, 0x2196,
- 0x2199, 0x21C4, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0x2934, 0x2935,
- 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
- 0xFF18, 0xFF19, 0x29BF, 0x25C9, 0x303D, 0xFE46, 0xFE45, 0x25E6,
- 0x2022, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27,
- 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F,
- 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37,
- 0xFF38, 0xFF39, 0xFF3A, 0x2213, 0x2135, 0x210F, 0x33CB, 0x2113,
- 0x2127, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
- 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
- 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
- 0xFF58, 0xFF59, 0xFF5A, 0x30A0, 0x2013, 0x29FA, 0x29FB,
-};
-static const unsigned short euc_to_utf8_A4[] = {
- 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047,
- 0x3048, 0x3049, 0x304A, 0x304B, 0x304C, 0x304D, 0x304E, 0x304F,
- 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057,
- 0x3058, 0x3059, 0x305A, 0x305B, 0x305C, 0x305D, 0x305E, 0x305F,
- 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
- 0x3068, 0x3069, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F,
- 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077,
- 0x3078, 0x3079, 0x307A, 0x307B, 0x307C, 0x307D, 0x307E, 0x307F,
- 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087,
- 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308E, 0x308F,
- 0x3090, 0x3091, 0x3092, 0x3093, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A4_x0213[] = {
- 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047,
- 0x3048, 0x3049, 0x304A, 0x304B, 0x304C, 0x304D, 0x304E, 0x304F,
- 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057,
- 0x3058, 0x3059, 0x305A, 0x305B, 0x305C, 0x305D, 0x305E, 0x305F,
- 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
- 0x3068, 0x3069, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F,
- 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077,
- 0x3078, 0x3079, 0x307A, 0x307B, 0x307C, 0x307D, 0x307E, 0x307F,
- 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087,
- 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308E, 0x308F,
- 0x3090, 0x3091, 0x3092, 0x3093, 0x3094, 0x3095, 0x3096, /*0x304B*/ 0x309A,
- /*0x304D*/ 0x309A, /*0x304F*/ 0x309A, /*0x3051*/ 0x309A, /*0x3053*/ 0x309A, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A5[] = {
- 0x30A1, 0x30A2, 0x30A3, 0x30A4, 0x30A5, 0x30A6, 0x30A7,
- 0x30A8, 0x30A9, 0x30AA, 0x30AB, 0x30AC, 0x30AD, 0x30AE, 0x30AF,
- 0x30B0, 0x30B1, 0x30B2, 0x30B3, 0x30B4, 0x30B5, 0x30B6, 0x30B7,
- 0x30B8, 0x30B9, 0x30BA, 0x30BB, 0x30BC, 0x30BD, 0x30BE, 0x30BF,
- 0x30C0, 0x30C1, 0x30C2, 0x30C3, 0x30C4, 0x30C5, 0x30C6, 0x30C7,
- 0x30C8, 0x30C9, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF,
- 0x30D0, 0x30D1, 0x30D2, 0x30D3, 0x30D4, 0x30D5, 0x30D6, 0x30D7,
- 0x30D8, 0x30D9, 0x30DA, 0x30DB, 0x30DC, 0x30DD, 0x30DE, 0x30DF,
- 0x30E0, 0x30E1, 0x30E2, 0x30E3, 0x30E4, 0x30E5, 0x30E6, 0x30E7,
- 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EE, 0x30EF,
- 0x30F0, 0x30F1, 0x30F2, 0x30F3, 0x30F4, 0x30F5, 0x30F6, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A5_x0213[] = {
- 0x30A1, 0x30A2, 0x30A3, 0x30A4, 0x30A5, 0x30A6, 0x30A7,
- 0x30A8, 0x30A9, 0x30AA, 0x30AB, 0x30AC, 0x30AD, 0x30AE, 0x30AF,
- 0x30B0, 0x30B1, 0x30B2, 0x30B3, 0x30B4, 0x30B5, 0x30B6, 0x30B7,
- 0x30B8, 0x30B9, 0x30BA, 0x30BB, 0x30BC, 0x30BD, 0x30BE, 0x30BF,
- 0x30C0, 0x30C1, 0x30C2, 0x30C3, 0x30C4, 0x30C5, 0x30C6, 0x30C7,
- 0x30C8, 0x30C9, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF,
- 0x30D0, 0x30D1, 0x30D2, 0x30D3, 0x30D4, 0x30D5, 0x30D6, 0x30D7,
- 0x30D8, 0x30D9, 0x30DA, 0x30DB, 0x30DC, 0x30DD, 0x30DE, 0x30DF,
- 0x30E0, 0x30E1, 0x30E2, 0x30E3, 0x30E4, 0x30E5, 0x30E6, 0x30E7,
- 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EE, 0x30EF,
- 0x30F0, 0x30F1, 0x30F2, 0x30F3, 0x30F4, 0x30F5, 0x30F6, /*0x30AB*/ 0x309A,
- /*0x30AD*/ 0x309A, /*0x30AF*/ 0x309A, /*0x30B1*/ 0x309A, /*0x30B3*/ 0x309A, /*0x30BB*/ 0x309A, /*0x30C4*/ 0x309A, /*0x30C8*/ 0x309A,
-};
-static const unsigned short euc_to_utf8_A6[] = {
- 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
- 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
- 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8,
- 0x03A9, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
- 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
- 0x03C9, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A6_x0213[] = {
- 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
- 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
- 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8,
- 0x03A9, 0x2664, 0x2660, 0x2662, 0x2666, 0x2661, 0x2665, 0x2667,
- 0x2663, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
- 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
- 0x03C9, 0x03C2, 0x24F5, 0x24F6, 0x24F7, 0x24F8, 0x24F9, 0x24FA,
- 0x24FB, 0x24FC, 0x24FD, 0x24FE, 0x2616, 0x2617, 0x3020, 0x260E,
- 0x2600, 0x2601, 0x2602, 0x2603, 0x2668, 0x25B1, 0x31F0, 0x31F1,
- 0x31F2, 0x31F3, 0x31F4, 0x31F5, 0x31F6, 0x31F7, 0x31F8, 0x31F9,
- /*0x31F7*/ 0x309A, 0x31FA, 0x31FB, 0x31FC, 0x31FD, 0x31FE, 0x31FF,
-};
-static const unsigned short euc_to_utf8_A7[] = {
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401,
- 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D,
- 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
- 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D,
- 0x042E, 0x042F, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451,
- 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D,
- 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
- 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
- 0x044E, 0x044F, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A7_x0213[] = {
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401,
- 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D,
- 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
- 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D,
- 0x042E, 0x042F, 0x23BE, 0x23BF, 0x23C0, 0x23C1, 0x23C2, 0x23C3,
- 0x23C4, 0x23C5, 0x23C6, 0x23C7, 0x23C8, 0x23C9, 0x23CA, 0x23CB,
- 0x23CC, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451,
- 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D,
- 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
- 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
- 0x044E, 0x044F, 0x30F7, 0x30F8, 0x30F9, 0x30FA, 0x22DA, 0x22DB,
- 0x2153, 0x2154, 0x2155, 0x2713, 0x2318, 0x2423, 0x23CE,
-};
-static const unsigned short euc_to_utf8_A8[] = {
- 0x2500, 0x2502, 0x250C, 0x2510, 0x2518, 0x2514, 0x251C,
- 0x252C, 0x2524, 0x2534, 0x253C, 0x2501, 0x2503, 0x250F, 0x2513,
- 0x251B, 0x2517, 0x2523, 0x2533, 0x252B, 0x253B, 0x254B, 0x2520,
- 0x252F, 0x2528, 0x2537, 0x253F, 0x251D, 0x2530, 0x2525, 0x2538,
- 0x2542, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A8_x0213[] = {
- 0x2500, 0x2502, 0x250C, 0x2510, 0x2518, 0x2514, 0x251C,
- 0x252C, 0x2524, 0x2534, 0x253C, 0x2501, 0x2503, 0x250F, 0x2513,
- 0x251B, 0x2517, 0x2523, 0x2533, 0x252B, 0x253B, 0x254B, 0x2520,
- 0x252F, 0x2528, 0x2537, 0x253F, 0x251D, 0x2530, 0x2525, 0x2538,
- 0x2542, 0x3251, 0x3252, 0x3253, 0x3254, 0x3255, 0x3256, 0x3257,
- 0x3258, 0x3259, 0x325A, 0x325B, 0x325C, 0x325D, 0x325E, 0x325F,
- 0x32B1, 0x32B2, 0x32B3, 0x32B4, 0x32B5, 0x32B6, 0x32B7, 0x32B8,
- 0x32B9, 0x32BA, 0x32BB, 0x32BC, 0x32BD, 0x32BE, 0x32BF, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x25D0,
- 0x25D1, 0x25D2, 0x25D3, 0x203C, 0x2047, 0x2048, 0x2049, 0x01CD,
- 0x01CE, 0x01D0, 0x1E3E, 0x1E3F, 0x01F8, 0x01F9, 0x01D1, 0x01D2,
- 0x01D4, 0x01D6, 0x01D8, 0x01DA, 0x01DC, 0, 0,
-};
-static const unsigned short euc_to_utf8_A9[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
- 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
- 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2474,
- 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247A, 0x247B, 0x247C,
- 0x247D, 0x247E, 0x247F, 0x2480, 0x2481, 0x2482, 0x2483, 0x2484,
- 0x2485, 0x2486, 0x2487, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2776, 0x2777, 0x2778,
- 0x2779, 0x277A, 0x277B, 0x277C, 0x277D, 0x277E, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2488, 0x2489, 0x248A, 0x248B, 0x248C, 0x248D,
- 0x248E, 0x248F, 0x2490, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_A9_x0213[] = {
- 0x20AC, 0x00A0, 0x00A1, 0x00A4, 0x00A6, 0x00A9, 0x00AA,
- 0x00AB, 0x00AD, 0x00AE, 0x00AF, 0x00B2, 0x00B3, 0x00B7, 0x00B8,
- 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0,
- 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8,
- 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0,
- 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D8, 0x00D9,
- 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1,
- 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9,
- 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1,
- 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F8, 0x00F9, 0x00FA,
- 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x012A, 0x016A,
- 0x0112, 0x014C, 0x0101, 0x012B, 0x016B, 0x0113, 0x014D,
-};
-static const unsigned short euc_to_utf8_AA[] = {
- 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166,
- 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2170, 0x2171, 0x2172,
- 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A,
- 0x217B, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x249C, 0x249D, 0x249E,
- 0x249F, 0x24A0, 0x24A1, 0x24A2, 0x24A3, 0x24A4, 0x24A5, 0x24A6,
- 0x24A7, 0x24A8, 0x24A9, 0x24AA, 0x24AB, 0x24AC, 0x24AD, 0x24AE,
- 0x24AF, 0x24B0, 0x24B1, 0x24B2, 0x24B3, 0x24B4, 0x24B5, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_AA_x0213[] = {
- 0x0104, 0x02D8, 0x0141, 0x013D, 0x015A, 0x0160, 0x015E,
- 0x0164, 0x0179, 0x017D, 0x017B, 0x0105, 0x02DB, 0x0142, 0x013E,
- 0x015B, 0x02C7, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E,
- 0x017C, 0x0154, 0x0102, 0x0139, 0x0106, 0x010C, 0x0118, 0x011A,
- 0x010E, 0x0143, 0x0147, 0x0150, 0x0158, 0x016E, 0x0170, 0x0162,
- 0x0155, 0x0103, 0x013A, 0x0107, 0x010D, 0x0119, 0x011B, 0x010F,
- 0x0111, 0x0144, 0x0148, 0x0151, 0x0159, 0x016F, 0x0171, 0x0163,
- 0x02D9, 0x0108, 0x011C, 0x0124, 0x0134, 0x015C, 0x016C, 0x0109,
- 0x011D, 0x0125, 0x0135, 0x015D, 0x016D, 0x0271, 0x028B, 0x027E,
- 0x0283, 0x0292, 0x026C, 0x026E, 0x0279, 0x0288, 0x0256, 0x0273,
- 0x027D, 0x0282, 0x0290, 0x027B, 0x026D, 0x025F, 0x0272, 0x029D,
- 0x028E, 0x0261, 0x014B, 0x0270, 0x0281, 0x0127, 0x0295,
-};
-static const unsigned short euc_to_utf8_AB[] = {
- 0x339C, 0x339F, 0x339D, 0x33A0, 0x33A4, 0, 0x33A1,
- 0x33A5, 0x339E, 0x33A2, 0x338E, 0, 0x338F, 0x33C4, 0x3396,
- 0x3397, 0x2113, 0x3398, 0x33B3, 0x33B2, 0x33B1, 0x33B0, 0x2109,
- 0x33D4, 0x33CB, 0x3390, 0x3385, 0x3386, 0x3387, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2116, 0x33CD, 0x2121, 0,
-};
-static const unsigned short euc_to_utf8_AB_x0213[] = {
- 0x0294, 0x0266, 0x0298, 0x01C2, 0x0253, 0x0257, 0x0284,
- 0x0260, 0x0193, 0x0153, 0x0152, 0x0268, 0x0289, 0x0258, 0x0275,
- 0x0259, 0x025C, 0x025E, 0x0250, 0x026F, 0x028A, 0x0264, 0x028C,
- 0x0254, 0x0251, 0x0252, 0x028D, 0x0265, 0x02A2, 0x02A1, 0x0255,
- 0x0291, 0x027A, 0x0267, 0x025A, /*0x00E6*/ 0x0300, 0x01FD, 0x1F70, 0x1F71,
- /*0x0254*/ 0x0300, /*0x0254*/ 0x0301, /*0x028C*/ 0x0300, /*0x028C*/ 0x0301, /*0x0259*/ 0x0300, /*0x0259*/ 0x0301, /*0x025A*/ 0x0300, /*0x025A*/ 0x0301,
- 0x1F72, 0x1F73, 0x0361, 0x02C8, 0x02CC, 0x02D0, 0x02D1, 0x0306,
- 0x203F, 0x030B, /*0*/ 0x0301, 0x0304, /*0*/ 0x0300, 0x030F, 0x030C, 0x0302,
- /*0*/ 0x02E5, 0x02E6, 0x02E7, 0x02E8, /*0*/ 0x02E9, /*0x02E9*/ 0x02E5, /*0x02E5*/ 0x02E9, 0x0325,
- 0x032C, 0x0339, 0x031C, 0x031F, 0x0320, 0x0308, 0x033D, 0x0329,
- 0x032F, 0x02DE, 0x0324, 0x0330, 0x033C, 0x0334, 0x031D, 0x031E,
- 0x0318, 0x0319, 0x032A, 0x033A, 0x033B, 0x0303, 0x031A,
-};
-static const unsigned short euc_to_utf8_AC[] = {
- 0x2664, 0x2667, 0x2661, 0x2662, 0x2660, 0x2663, 0x2665,
- 0x2666, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x3020, 0x260E, 0x3004,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x261E, 0x261C, 0x261D, 0x261F, 0x21C6, 0x21C4, 0x21C5,
- 0, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short euc_to_utf8_AC_x0213[] = {
- 0x2776, 0x2777, 0x2778, 0x2779, 0x277A, 0x277B, 0x277C,
- 0x277D, 0x277E, 0x277F, 0x24EB, 0x24EC, 0x24ED, 0x24EE, 0x24EF,
- 0x24F0, 0x24F1, 0x24F2, 0x24F3, 0x24F4, 0x2170, 0x2171, 0x2172,
- 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A,
- 0x217B, 0x24D0, 0x24D1, 0x24D2, 0x24D3, 0x24D4, 0x24D5, 0x24D6,
- 0x24D7, 0x24D8, 0x24D9, 0x24DA, 0x24DB, 0x24DC, 0x24DD, 0x24DE,
- 0x24DF, 0x24E0, 0x24E1, 0x24E2, 0x24E3, 0x24E4, 0x24E5, 0x24E6,
- 0x24E7, 0x24E8, 0x24E9, 0x32D0, 0x32D1, 0x32D2, 0x32D3, 0x32D4,
- 0x32D5, 0x32D6, 0x32D7, 0x32D8, 0x32D9, 0x32DA, 0x32DB, 0x32DC,
- 0x32DD, 0x32DE, 0x32DF, 0x32E0, 0x32E1, 0x32E2, 0x32E3, 0x32FA,
- 0x32E9, 0x32E5, 0x32ED, 0x32EC, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2051, 0x2042,
-};
-static const unsigned short euc_to_utf8_AD[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
- 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
- 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
- 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0,
- 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
- 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
- 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x337B,
- 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
- 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
- 0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
- 0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0, 0x3299,
-};
-static 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,
-};
-static const unsigned short euc_to_utf8_AD_x0213[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
- 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
- 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
- 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A,
- 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
- 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
- 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0x216B,
- 0, 0, 0, 0, 0, 0, 0, 0x337B,
- 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
- 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
- 0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
- 0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0x2756, 0x261E,
-};
-static const unsigned short euc_to_utf8_AE[] = {
- 0x3349, 0x3322, 0x334D, 0x3314, 0x3316, 0x3305, 0x3333,
- 0x334E, 0x3303, 0x3336, 0x3318, 0x3315, 0x3327, 0x3351, 0x334A,
- 0x3339, 0x3357, 0x330D, 0x3342, 0x3323, 0x3326, 0x333B, 0x332B,
- 0, 0, 0, 0, 0, 0, 0, 0x3300,
- 0x331E, 0x332A, 0x3331, 0x3347, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x337E,
- 0x337D, 0x337C, 0x337B, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x337F, 0, 0,
-};
-static const unsigned short euc_to_utf8_AE_x0213[] = {
- 0x4FF1, 0xD840 /*0xDC0B*/, 0x3402, 0x4E28, 0x4E2F, 0x4E30, 0x4E8D,
- 0x4EE1, 0x4EFD, 0x4EFF, 0x4F03, 0x4F0B, 0x4F60, 0x4F48, 0x4F49,
- 0x4F56, 0x4F5F, 0x4F6A, 0x4F6C, 0x4F7E, 0x4F8A, 0x4F94, 0x4F97,
- 0xFA30, 0x4FC9, 0x4FE0, 0x5001, 0x5002, 0x500E, 0x5018, 0x5027,
- 0x502E, 0x5040, 0x503B, 0x5041, 0x5094, 0x50CC, 0x50F2, 0x50D0,
- 0x50E6, 0xFA31, 0x5106, 0x5103, 0x510B, 0x511E, 0x5135, 0x514A,
- 0xFA32, 0x5155, 0x5157, 0x34B5, 0x519D, 0x51C3, 0x51CA, 0x51DE,
- 0x51E2, 0x51EE, 0x5201, 0x34DB, 0x5213, 0x5215, 0x5249, 0x5257,
- 0x5261, 0x5293, 0x52C8, 0xFA33, 0x52CC, 0x52D0, 0x52D6, 0x52DB,
- 0xFA34, 0x52F0, 0x52FB, 0x5300, 0x5307, 0x531C, 0xFA35, 0x5361,
- 0x5363, 0x537D, 0x5393, 0x539D, 0x53B2, 0x5412, 0x5427, 0x544D,
- 0x549C, 0x546B, 0x5474, 0x547F, 0x5488, 0x5496, 0x54A1,
-};
-static const unsigned short euc_to_utf8_AF[] = {
- 0x222E, 0x221F, 0x22BF, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x301D, 0x301F, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x3094, 0, 0x30F7, 0x30F8, 0x30F9, 0x30FA, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_AF_x0213[] = {
- 0x54A9, 0x54C6, 0x54FF, 0x550E, 0x552B, 0x5535, 0x5550,
- 0x555E, 0x5581, 0x5586, 0x558E, 0xFA36, 0x55AD, 0x55CE, 0xFA37,
- 0x5608, 0x560E, 0x563B, 0x5649, 0x5676, 0x5666, 0xFA38, 0x566F,
- 0x5671, 0x5672, 0x5699, 0x569E, 0x56A9, 0x56AC, 0x56B3, 0x56C9,
- 0x56CA, 0x570A, 0xD844 /*0xDE3D*/, 0x5721, 0x572F, 0x5733, 0x5734, 0x5770,
- 0x5777, 0x577C, 0x579C, 0xFA0F, 0xD844 /*0xDF1B*/, 0x57B8, 0x57C7, 0x57C8,
- 0x57CF, 0x57E4, 0x57ED, 0x57F5, 0x57F6, 0x57FF, 0x5809, 0xFA10,
- 0x5861, 0x5864, 0xFA39, 0x587C, 0x5889, 0x589E, 0xFA3A, 0x58A9,
- 0xD845 /*0xDC6E*/, 0x58D2, 0x58CE, 0x58D4, 0x58DA, 0x58E0, 0x58E9, 0x590C,
- 0x8641, 0x595D, 0x596D, 0x598B, 0x5992, 0x59A4, 0x59C3, 0x59D2,
- 0x59DD, 0x5A13, 0x5A23, 0x5A67, 0x5A6D, 0x5A77, 0x5A7E, 0x5A84,
- 0x5A9E, 0x5AA7, 0x5AC4, 0xD846 /*0xDCBD*/, 0x5B19, 0x5B25, 0x525D,
-};
-static const unsigned short euc_to_utf8_B0[] = {
- 0x4E9C, 0x5516, 0x5A03, 0x963F, 0x54C0, 0x611B, 0x6328,
- 0x59F6, 0x9022, 0x8475, 0x831C, 0x7A50, 0x60AA, 0x63E1, 0x6E25,
- 0x65ED, 0x8466, 0x82A6, 0x9BF5, 0x6893, 0x5727, 0x65A1, 0x6271,
- 0x5B9B, 0x59D0, 0x867B, 0x98F4, 0x7D62, 0x7DBE, 0x9B8E, 0x6216,
- 0x7C9F, 0x88B7, 0x5B89, 0x5EB5, 0x6309, 0x6697, 0x6848, 0x95C7,
- 0x978D, 0x674F, 0x4EE5, 0x4F0A, 0x4F4D, 0x4F9D, 0x5049, 0x56F2,
- 0x5937, 0x59D4, 0x5A01, 0x5C09, 0x60DF, 0x610F, 0x6170, 0x6613,
- 0x6905, 0x70BA, 0x754F, 0x7570, 0x79FB, 0x7DAD, 0x7DEF, 0x80C3,
- 0x840E, 0x8863, 0x8B02, 0x9055, 0x907A, 0x533B, 0x4E95, 0x4EA5,
- 0x57DF, 0x80B2, 0x90C1, 0x78EF, 0x4E00, 0x58F1, 0x6EA2, 0x9038,
- 0x7A32, 0x8328, 0x828B, 0x9C2F, 0x5141, 0x5370, 0x54BD, 0x54E1,
- 0x56E0, 0x59FB, 0x5F15, 0x98F2, 0x6DEB, 0x80E4, 0x852D,
-};
-static const unsigned short euc_to_utf8_B1[] = {
- 0x9662, 0x9670, 0x96A0, 0x97FB, 0x540B, 0x53F3, 0x5B87,
- 0x70CF, 0x7FBD, 0x8FC2, 0x96E8, 0x536F, 0x9D5C, 0x7ABA, 0x4E11,
- 0x7893, 0x81FC, 0x6E26, 0x5618, 0x5504, 0x6B1D, 0x851A, 0x9C3B,
- 0x59E5, 0x53A9, 0x6D66, 0x74DC, 0x958F, 0x5642, 0x4E91, 0x904B,
- 0x96F2, 0x834F, 0x990C, 0x53E1, 0x55B6, 0x5B30, 0x5F71, 0x6620,
- 0x66F3, 0x6804, 0x6C38, 0x6CF3, 0x6D29, 0x745B, 0x76C8, 0x7A4E,
- 0x9834, 0x82F1, 0x885B, 0x8A60, 0x92ED, 0x6DB2, 0x75AB, 0x76CA,
- 0x99C5, 0x60A6, 0x8B01, 0x8D8A, 0x95B2, 0x698E, 0x53AD, 0x5186,
- 0x5712, 0x5830, 0x5944, 0x5BB4, 0x5EF6, 0x6028, 0x63A9, 0x63F4,
- 0x6CBF, 0x6F14, 0x708E, 0x7114, 0x7159, 0x71D5, 0x733F, 0x7E01,
- 0x8276, 0x82D1, 0x8597, 0x9060, 0x925B, 0x9D1B, 0x5869, 0x65BC,
- 0x6C5A, 0x7525, 0x51F9, 0x592E, 0x5965, 0x5F80, 0x5FDC,
-};
-static const unsigned short euc_to_utf8_B2[] = {
- 0x62BC, 0x65FA, 0x6A2A, 0x6B27, 0x6BB4, 0x738B, 0x7FC1,
- 0x8956, 0x9D2C, 0x9D0E, 0x9EC4, 0x5CA1, 0x6C96, 0x837B, 0x5104,
- 0x5C4B, 0x61B6, 0x81C6, 0x6876, 0x7261, 0x4E59, 0x4FFA, 0x5378,
- 0x6069, 0x6E29, 0x7A4F, 0x97F3, 0x4E0B, 0x5316, 0x4EEE, 0x4F55,
- 0x4F3D, 0x4FA1, 0x4F73, 0x52A0, 0x53EF, 0x5609, 0x590F, 0x5AC1,
- 0x5BB6, 0x5BE1, 0x79D1, 0x6687, 0x679C, 0x67B6, 0x6B4C, 0x6CB3,
- 0x706B, 0x73C2, 0x798D, 0x79BE, 0x7A3C, 0x7B87, 0x82B1, 0x82DB,
- 0x8304, 0x8377, 0x83EF, 0x83D3, 0x8766, 0x8AB2, 0x5629, 0x8CA8,
- 0x8FE6, 0x904E, 0x971E, 0x868A, 0x4FC4, 0x5CE8, 0x6211, 0x7259,
- 0x753B, 0x81E5, 0x82BD, 0x86FE, 0x8CC0, 0x96C5, 0x9913, 0x99D5,
- 0x4ECB, 0x4F1A, 0x89E3, 0x56DE, 0x584A, 0x58CA, 0x5EFB, 0x5FEB,
- 0x602A, 0x6094, 0x6062, 0x61D0, 0x6212, 0x62D0, 0x6539,
-};
-static const unsigned short euc_to_utf8_B3[] = {
- 0x9B41, 0x6666, 0x68B0, 0x6D77, 0x7070, 0x754C, 0x7686,
- 0x7D75, 0x82A5, 0x87F9, 0x958B, 0x968E, 0x8C9D, 0x51F1, 0x52BE,
- 0x5916, 0x54B3, 0x5BB3, 0x5D16, 0x6168, 0x6982, 0x6DAF, 0x788D,
- 0x84CB, 0x8857, 0x8A72, 0x93A7, 0x9AB8, 0x6D6C, 0x99A8, 0x86D9,
- 0x57A3, 0x67FF, 0x86CE, 0x920E, 0x5283, 0x5687, 0x5404, 0x5ED3,
- 0x62E1, 0x64B9, 0x683C, 0x6838, 0x6BBB, 0x7372, 0x78BA, 0x7A6B,
- 0x899A, 0x89D2, 0x8D6B, 0x8F03, 0x90ED, 0x95A3, 0x9694, 0x9769,
- 0x5B66, 0x5CB3, 0x697D, 0x984D, 0x984E, 0x639B, 0x7B20, 0x6A2B,
- 0x6A7F, 0x68B6, 0x9C0D, 0x6F5F, 0x5272, 0x559D, 0x6070, 0x62EC,
- 0x6D3B, 0x6E07, 0x6ED1, 0x845B, 0x8910, 0x8F44, 0x4E14, 0x9C39,
- 0x53F6, 0x691B, 0x6A3A, 0x9784, 0x682A, 0x515C, 0x7AC3, 0x84B2,
- 0x91DC, 0x938C, 0x565B, 0x9D28, 0x6822, 0x8305, 0x8431,
-};
-static const unsigned short euc_to_utf8_B4[] = {
- 0x7CA5, 0x5208, 0x82C5, 0x74E6, 0x4E7E, 0x4F83, 0x51A0,
- 0x5BD2, 0x520A, 0x52D8, 0x52E7, 0x5DFB, 0x559A, 0x582A, 0x59E6,
- 0x5B8C, 0x5B98, 0x5BDB, 0x5E72, 0x5E79, 0x60A3, 0x611F, 0x6163,
- 0x61BE, 0x63DB, 0x6562, 0x67D1, 0x6853, 0x68FA, 0x6B3E, 0x6B53,
- 0x6C57, 0x6F22, 0x6F97, 0x6F45, 0x74B0, 0x7518, 0x76E3, 0x770B,
- 0x7AFF, 0x7BA1, 0x7C21, 0x7DE9, 0x7F36, 0x7FF0, 0x809D, 0x8266,
- 0x839E, 0x89B3, 0x8ACC, 0x8CAB, 0x9084, 0x9451, 0x9593, 0x9591,
- 0x95A2, 0x9665, 0x97D3, 0x9928, 0x8218, 0x4E38, 0x542B, 0x5CB8,
- 0x5DCC, 0x73A9, 0x764C, 0x773C, 0x5CA9, 0x7FEB, 0x8D0B, 0x96C1,
- 0x9811, 0x9854, 0x9858, 0x4F01, 0x4F0E, 0x5371, 0x559C, 0x5668,
- 0x57FA, 0x5947, 0x5B09, 0x5BC4, 0x5C90, 0x5E0C, 0x5E7E, 0x5FCC,
- 0x63EE, 0x673A, 0x65D7, 0x65E2, 0x671F, 0x68CB, 0x68C4,
-};
-static const unsigned short euc_to_utf8_B5[] = {
- 0x6A5F, 0x5E30, 0x6BC5, 0x6C17, 0x6C7D, 0x757F, 0x7948,
- 0x5B63, 0x7A00, 0x7D00, 0x5FBD, 0x898F, 0x8A18, 0x8CB4, 0x8D77,
- 0x8ECC, 0x8F1D, 0x98E2, 0x9A0E, 0x9B3C, 0x4E80, 0x507D, 0x5100,
- 0x5993, 0x5B9C, 0x622F, 0x6280, 0x64EC, 0x6B3A, 0x72A0, 0x7591,
- 0x7947, 0x7FA9, 0x87FB, 0x8ABC, 0x8B70, 0x63AC, 0x83CA, 0x97A0,
- 0x5409, 0x5403, 0x55AB, 0x6854, 0x6A58, 0x8A70, 0x7827, 0x6775,
- 0x9ECD, 0x5374, 0x5BA2, 0x811A, 0x8650, 0x9006, 0x4E18, 0x4E45,
- 0x4EC7, 0x4F11, 0x53CA, 0x5438, 0x5BAE, 0x5F13, 0x6025, 0x6551,
- 0x673D, 0x6C42, 0x6C72, 0x6CE3, 0x7078, 0x7403, 0x7A76, 0x7AAE,
- 0x7B08, 0x7D1A, 0x7CFE, 0x7D66, 0x65E7, 0x725B, 0x53BB, 0x5C45,
- 0x5DE8, 0x62D2, 0x62E0, 0x6319, 0x6E20, 0x865A, 0x8A31, 0x8DDD,
- 0x92F8, 0x6F01, 0x79A6, 0x9B5A, 0x4EA8, 0x4EAB, 0x4EAC,
-};
-static const unsigned short euc_to_utf8_B6[] = {
- 0x4F9B, 0x4FA0, 0x50D1, 0x5147, 0x7AF6, 0x5171, 0x51F6,
- 0x5354, 0x5321, 0x537F, 0x53EB, 0x55AC, 0x5883, 0x5CE1, 0x5F37,
- 0x5F4A, 0x602F, 0x6050, 0x606D, 0x631F, 0x6559, 0x6A4B, 0x6CC1,
- 0x72C2, 0x72ED, 0x77EF, 0x80F8, 0x8105, 0x8208, 0x854E, 0x90F7,
- 0x93E1, 0x97FF, 0x9957, 0x9A5A, 0x4EF0, 0x51DD, 0x5C2D, 0x6681,
- 0x696D, 0x5C40, 0x66F2, 0x6975, 0x7389, 0x6850, 0x7C81, 0x50C5,
- 0x52E4, 0x5747, 0x5DFE, 0x9326, 0x65A4, 0x6B23, 0x6B3D, 0x7434,
- 0x7981, 0x79BD, 0x7B4B, 0x7DCA, 0x82B9, 0x83CC, 0x887F, 0x895F,
- 0x8B39, 0x8FD1, 0x91D1, 0x541F, 0x9280, 0x4E5D, 0x5036, 0x53E5,
- 0x533A, 0x72D7, 0x7396, 0x77E9, 0x82E6, 0x8EAF, 0x99C6, 0x99C8,
- 0x99D2, 0x5177, 0x611A, 0x865E, 0x55B0, 0x7A7A, 0x5076, 0x5BD3,
- 0x9047, 0x9685, 0x4E32, 0x6ADB, 0x91E7, 0x5C51, 0x5C48,
-};
-static const unsigned short euc_to_utf8_B7[] = {
- 0x6398, 0x7A9F, 0x6C93, 0x9774, 0x8F61, 0x7AAA, 0x718A,
- 0x9688, 0x7C82, 0x6817, 0x7E70, 0x6851, 0x936C, 0x52F2, 0x541B,
- 0x85AB, 0x8A13, 0x7FA4, 0x8ECD, 0x90E1, 0x5366, 0x8888, 0x7941,
- 0x4FC2, 0x50BE, 0x5211, 0x5144, 0x5553, 0x572D, 0x73EA, 0x578B,
- 0x5951, 0x5F62, 0x5F84, 0x6075, 0x6176, 0x6167, 0x61A9, 0x63B2,
- 0x643A, 0x656C, 0x666F, 0x6842, 0x6E13, 0x7566, 0x7A3D, 0x7CFB,
- 0x7D4C, 0x7D99, 0x7E4B, 0x7F6B, 0x830E, 0x834A, 0x86CD, 0x8A08,
- 0x8A63, 0x8B66, 0x8EFD, 0x981A, 0x9D8F, 0x82B8, 0x8FCE, 0x9BE8,
- 0x5287, 0x621F, 0x6483, 0x6FC0, 0x9699, 0x6841, 0x5091, 0x6B20,
- 0x6C7A, 0x6F54, 0x7A74, 0x7D50, 0x8840, 0x8A23, 0x6708, 0x4EF6,
- 0x5039, 0x5026, 0x5065, 0x517C, 0x5238, 0x5263, 0x55A7, 0x570F,
- 0x5805, 0x5ACC, 0x5EFA, 0x61B2, 0x61F8, 0x62F3, 0x6372,
-};
-static const unsigned short euc_to_utf8_B8[] = {
- 0x691C, 0x6A29, 0x727D, 0x72AC, 0x732E, 0x7814, 0x786F,
- 0x7D79, 0x770C, 0x80A9, 0x898B, 0x8B19, 0x8CE2, 0x8ED2, 0x9063,
- 0x9375, 0x967A, 0x9855, 0x9A13, 0x9E78, 0x5143, 0x539F, 0x53B3,
- 0x5E7B, 0x5F26, 0x6E1B, 0x6E90, 0x7384, 0x73FE, 0x7D43, 0x8237,
- 0x8A00, 0x8AFA, 0x9650, 0x4E4E, 0x500B, 0x53E4, 0x547C, 0x56FA,
- 0x59D1, 0x5B64, 0x5DF1, 0x5EAB, 0x5F27, 0x6238, 0x6545, 0x67AF,
- 0x6E56, 0x72D0, 0x7CCA, 0x88B4, 0x80A1, 0x80E1, 0x83F0, 0x864E,
- 0x8A87, 0x8DE8, 0x9237, 0x96C7, 0x9867, 0x9F13, 0x4E94, 0x4E92,
- 0x4F0D, 0x5348, 0x5449, 0x543E, 0x5A2F, 0x5F8C, 0x5FA1, 0x609F,
- 0x68A7, 0x6A8E, 0x745A, 0x7881, 0x8A9E, 0x8AA4, 0x8B77, 0x9190,
- 0x4E5E, 0x9BC9, 0x4EA4, 0x4F7C, 0x4FAF, 0x5019, 0x5016, 0x5149,
- 0x516C, 0x529F, 0x52B9, 0x52FE, 0x539A, 0x53E3, 0x5411,
-};
-static const unsigned short euc_to_utf8_B9[] = {
- 0x540E, 0x5589, 0x5751, 0x57A2, 0x597D, 0x5B54, 0x5B5D,
- 0x5B8F, 0x5DE5, 0x5DE7, 0x5DF7, 0x5E78, 0x5E83, 0x5E9A, 0x5EB7,
- 0x5F18, 0x6052, 0x614C, 0x6297, 0x62D8, 0x63A7, 0x653B, 0x6602,
- 0x6643, 0x66F4, 0x676D, 0x6821, 0x6897, 0x69CB, 0x6C5F, 0x6D2A,
- 0x6D69, 0x6E2F, 0x6E9D, 0x7532, 0x7687, 0x786C, 0x7A3F, 0x7CE0,
- 0x7D05, 0x7D18, 0x7D5E, 0x7DB1, 0x8015, 0x8003, 0x80AF, 0x80B1,
- 0x8154, 0x818F, 0x822A, 0x8352, 0x884C, 0x8861, 0x8B1B, 0x8CA2,
- 0x8CFC, 0x90CA, 0x9175, 0x9271, 0x783F, 0x92FC, 0x95A4, 0x964D,
- 0x9805, 0x9999, 0x9AD8, 0x9D3B, 0x525B, 0x52AB, 0x53F7, 0x5408,
- 0x58D5, 0x62F7, 0x6FE0, 0x8C6A, 0x8F5F, 0x9EB9, 0x514B, 0x523B,
- 0x544A, 0x56FD, 0x7A40, 0x9177, 0x9D60, 0x9ED2, 0x7344, 0x6F09,
- 0x8170, 0x7511, 0x5FFD, 0x60DA, 0x9AA8, 0x72DB, 0x8FBC,
-};
-static const unsigned short euc_to_utf8_BA[] = {
- 0x6B64, 0x9803, 0x4ECA, 0x56F0, 0x5764, 0x58BE, 0x5A5A,
- 0x6068, 0x61C7, 0x660F, 0x6606, 0x6839, 0x68B1, 0x6DF7, 0x75D5,
- 0x7D3A, 0x826E, 0x9B42, 0x4E9B, 0x4F50, 0x53C9, 0x5506, 0x5D6F,
- 0x5DE6, 0x5DEE, 0x67FB, 0x6C99, 0x7473, 0x7802, 0x8A50, 0x9396,
- 0x88DF, 0x5750, 0x5EA7, 0x632B, 0x50B5, 0x50AC, 0x518D, 0x6700,
- 0x54C9, 0x585E, 0x59BB, 0x5BB0, 0x5F69, 0x624D, 0x63A1, 0x683D,
- 0x6B73, 0x6E08, 0x707D, 0x91C7, 0x7280, 0x7815, 0x7826, 0x796D,
- 0x658E, 0x7D30, 0x83DC, 0x88C1, 0x8F09, 0x969B, 0x5264, 0x5728,
- 0x6750, 0x7F6A, 0x8CA1, 0x51B4, 0x5742, 0x962A, 0x583A, 0x698A,
- 0x80B4, 0x54B2, 0x5D0E, 0x57FC, 0x7895, 0x9DFA, 0x4F5C, 0x524A,
- 0x548B, 0x643E, 0x6628, 0x6714, 0x67F5, 0x7A84, 0x7B56, 0x7D22,
- 0x932F, 0x685C, 0x9BAD, 0x7B39, 0x5319, 0x518A, 0x5237,
-};
-static const unsigned short euc_to_utf8_BB[] = {
- 0x5BDF, 0x62F6, 0x64AE, 0x64E6, 0x672D, 0x6BBA, 0x85A9,
- 0x96D1, 0x7690, 0x9BD6, 0x634C, 0x9306, 0x9BAB, 0x76BF, 0x6652,
- 0x4E09, 0x5098, 0x53C2, 0x5C71, 0x60E8, 0x6492, 0x6563, 0x685F,
- 0x71E6, 0x73CA, 0x7523, 0x7B97, 0x7E82, 0x8695, 0x8B83, 0x8CDB,
- 0x9178, 0x9910, 0x65AC, 0x66AB, 0x6B8B, 0x4ED5, 0x4ED4, 0x4F3A,
- 0x4F7F, 0x523A, 0x53F8, 0x53F2, 0x55E3, 0x56DB, 0x58EB, 0x59CB,
- 0x59C9, 0x59FF, 0x5B50, 0x5C4D, 0x5E02, 0x5E2B, 0x5FD7, 0x601D,
- 0x6307, 0x652F, 0x5B5C, 0x65AF, 0x65BD, 0x65E8, 0x679D, 0x6B62,
- 0x6B7B, 0x6C0F, 0x7345, 0x7949, 0x79C1, 0x7CF8, 0x7D19, 0x7D2B,
- 0x80A2, 0x8102, 0x81F3, 0x8996, 0x8A5E, 0x8A69, 0x8A66, 0x8A8C,
- 0x8AEE, 0x8CC7, 0x8CDC, 0x96CC, 0x98FC, 0x6B6F, 0x4E8B, 0x4F3C,
- 0x4F8D, 0x5150, 0x5B57, 0x5BFA, 0x6148, 0x6301, 0x6642,
-};
-static const unsigned short euc_to_utf8_BC[] = {
- 0x6B21, 0x6ECB, 0x6CBB, 0x723E, 0x74BD, 0x75D4, 0x78C1,
- 0x793A, 0x800C, 0x8033, 0x81EA, 0x8494, 0x8F9E, 0x6C50, 0x9E7F,
- 0x5F0F, 0x8B58, 0x9D2B, 0x7AFA, 0x8EF8, 0x5B8D, 0x96EB, 0x4E03,
- 0x53F1, 0x57F7, 0x5931, 0x5AC9, 0x5BA4, 0x6089, 0x6E7F, 0x6F06,
- 0x75BE, 0x8CEA, 0x5B9F, 0x8500, 0x7BE0, 0x5072, 0x67F4, 0x829D,
- 0x5C61, 0x854A, 0x7E1E, 0x820E, 0x5199, 0x5C04, 0x6368, 0x8D66,
- 0x659C, 0x716E, 0x793E, 0x7D17, 0x8005, 0x8B1D, 0x8ECA, 0x906E,
- 0x86C7, 0x90AA, 0x501F, 0x52FA, 0x5C3A, 0x6753, 0x707C, 0x7235,
- 0x914C, 0x91C8, 0x932B, 0x82E5, 0x5BC2, 0x5F31, 0x60F9, 0x4E3B,
- 0x53D6, 0x5B88, 0x624B, 0x6731, 0x6B8A, 0x72E9, 0x73E0, 0x7A2E,
- 0x816B, 0x8DA3, 0x9152, 0x9996, 0x5112, 0x53D7, 0x546A, 0x5BFF,
- 0x6388, 0x6A39, 0x7DAC, 0x9700, 0x56DA, 0x53CE, 0x5468,
-};
-static const unsigned short euc_to_utf8_BD[] = {
- 0x5B97, 0x5C31, 0x5DDE, 0x4FEE, 0x6101, 0x62FE, 0x6D32,
- 0x79C0, 0x79CB, 0x7D42, 0x7E4D, 0x7FD2, 0x81ED, 0x821F, 0x8490,
- 0x8846, 0x8972, 0x8B90, 0x8E74, 0x8F2F, 0x9031, 0x914B, 0x916C,
- 0x96C6, 0x919C, 0x4EC0, 0x4F4F, 0x5145, 0x5341, 0x5F93, 0x620E,
- 0x67D4, 0x6C41, 0x6E0B, 0x7363, 0x7E26, 0x91CD, 0x9283, 0x53D4,
- 0x5919, 0x5BBF, 0x6DD1, 0x795D, 0x7E2E, 0x7C9B, 0x587E, 0x719F,
- 0x51FA, 0x8853, 0x8FF0, 0x4FCA, 0x5CFB, 0x6625, 0x77AC, 0x7AE3,
- 0x821C, 0x99FF, 0x51C6, 0x5FAA, 0x65EC, 0x696F, 0x6B89, 0x6DF3,
- 0x6E96, 0x6F64, 0x76FE, 0x7D14, 0x5DE1, 0x9075, 0x9187, 0x9806,
- 0x51E6, 0x521D, 0x6240, 0x6691, 0x66D9, 0x6E1A, 0x5EB6, 0x7DD2,
- 0x7F72, 0x66F8, 0x85AF, 0x85F7, 0x8AF8, 0x52A9, 0x53D9, 0x5973,
- 0x5E8F, 0x5F90, 0x6055, 0x92E4, 0x9664, 0x50B7, 0x511F,
-};
-static const unsigned short euc_to_utf8_BE[] = {
- 0x52DD, 0x5320, 0x5347, 0x53EC, 0x54E8, 0x5546, 0x5531,
- 0x5617, 0x5968, 0x59BE, 0x5A3C, 0x5BB5, 0x5C06, 0x5C0F, 0x5C11,
- 0x5C1A, 0x5E84, 0x5E8A, 0x5EE0, 0x5F70, 0x627F, 0x6284, 0x62DB,
- 0x638C, 0x6377, 0x6607, 0x660C, 0x662D, 0x6676, 0x677E, 0x68A2,
- 0x6A1F, 0x6A35, 0x6CBC, 0x6D88, 0x6E09, 0x6E58, 0x713C, 0x7126,
- 0x7167, 0x75C7, 0x7701, 0x785D, 0x7901, 0x7965, 0x79F0, 0x7AE0,
- 0x7B11, 0x7CA7, 0x7D39, 0x8096, 0x83D6, 0x848B, 0x8549, 0x885D,
- 0x88F3, 0x8A1F, 0x8A3C, 0x8A54, 0x8A73, 0x8C61, 0x8CDE, 0x91A4,
- 0x9266, 0x937E, 0x9418, 0x969C, 0x9798, 0x4E0A, 0x4E08, 0x4E1E,
- 0x4E57, 0x5197, 0x5270, 0x57CE, 0x5834, 0x58CC, 0x5B22, 0x5E38,
- 0x60C5, 0x64FE, 0x6761, 0x6756, 0x6D44, 0x72B6, 0x7573, 0x7A63,
- 0x84B8, 0x8B72, 0x91B8, 0x9320, 0x5631, 0x57F4, 0x98FE,
-};
-static const unsigned short euc_to_utf8_BF[] = {
- 0x62ED, 0x690D, 0x6B96, 0x71ED, 0x7E54, 0x8077, 0x8272,
- 0x89E6, 0x98DF, 0x8755, 0x8FB1, 0x5C3B, 0x4F38, 0x4FE1, 0x4FB5,
- 0x5507, 0x5A20, 0x5BDD, 0x5BE9, 0x5FC3, 0x614E, 0x632F, 0x65B0,
- 0x664B, 0x68EE, 0x699B, 0x6D78, 0x6DF1, 0x7533, 0x75B9, 0x771F,
- 0x795E, 0x79E6, 0x7D33, 0x81E3, 0x82AF, 0x85AA, 0x89AA, 0x8A3A,
- 0x8EAB, 0x8F9B, 0x9032, 0x91DD, 0x9707, 0x4EBA, 0x4EC1, 0x5203,
- 0x5875, 0x58EC, 0x5C0B, 0x751A, 0x5C3D, 0x814E, 0x8A0A, 0x8FC5,
- 0x9663, 0x976D, 0x7B25, 0x8ACF, 0x9808, 0x9162, 0x56F3, 0x53A8,
- 0x9017, 0x5439, 0x5782, 0x5E25, 0x63A8, 0x6C34, 0x708A, 0x7761,
- 0x7C8B, 0x7FE0, 0x8870, 0x9042, 0x9154, 0x9310, 0x9318, 0x968F,
- 0x745E, 0x9AC4, 0x5D07, 0x5D69, 0x6570, 0x67A2, 0x8DA8, 0x96DB,
- 0x636E, 0x6749, 0x6919, 0x83C5, 0x9817, 0x96C0, 0x88FE,
-};
-static const unsigned short euc_to_utf8_C0[] = {
- 0x6F84, 0x647A, 0x5BF8, 0x4E16, 0x702C, 0x755D, 0x662F,
- 0x51C4, 0x5236, 0x52E2, 0x59D3, 0x5F81, 0x6027, 0x6210, 0x653F,
- 0x6574, 0x661F, 0x6674, 0x68F2, 0x6816, 0x6B63, 0x6E05, 0x7272,
- 0x751F, 0x76DB, 0x7CBE, 0x8056, 0x58F0, 0x88FD, 0x897F, 0x8AA0,
- 0x8A93, 0x8ACB, 0x901D, 0x9192, 0x9752, 0x9759, 0x6589, 0x7A0E,
- 0x8106, 0x96BB, 0x5E2D, 0x60DC, 0x621A, 0x65A5, 0x6614, 0x6790,
- 0x77F3, 0x7A4D, 0x7C4D, 0x7E3E, 0x810A, 0x8CAC, 0x8D64, 0x8DE1,
- 0x8E5F, 0x78A9, 0x5207, 0x62D9, 0x63A5, 0x6442, 0x6298, 0x8A2D,
- 0x7A83, 0x7BC0, 0x8AAC, 0x96EA, 0x7D76, 0x820C, 0x8749, 0x4ED9,
- 0x5148, 0x5343, 0x5360, 0x5BA3, 0x5C02, 0x5C16, 0x5DDD, 0x6226,
- 0x6247, 0x64B0, 0x6813, 0x6834, 0x6CC9, 0x6D45, 0x6D17, 0x67D3,
- 0x6F5C, 0x714E, 0x717D, 0x65CB, 0x7A7F, 0x7BAD, 0x7DDA,
-};
-static const unsigned short euc_to_utf8_C1[] = {
- 0x7E4A, 0x7FA8, 0x817A, 0x821B, 0x8239, 0x85A6, 0x8A6E,
- 0x8CCE, 0x8DF5, 0x9078, 0x9077, 0x92AD, 0x9291, 0x9583, 0x9BAE,
- 0x524D, 0x5584, 0x6F38, 0x7136, 0x5168, 0x7985, 0x7E55, 0x81B3,
- 0x7CCE, 0x564C, 0x5851, 0x5CA8, 0x63AA, 0x66FE, 0x66FD, 0x695A,
- 0x72D9, 0x758F, 0x758E, 0x790E, 0x7956, 0x79DF, 0x7C97, 0x7D20,
- 0x7D44, 0x8607, 0x8A34, 0x963B, 0x9061, 0x9F20, 0x50E7, 0x5275,
- 0x53CC, 0x53E2, 0x5009, 0x55AA, 0x58EE, 0x594F, 0x723D, 0x5B8B,
- 0x5C64, 0x531D, 0x60E3, 0x60F3, 0x635C, 0x6383, 0x633F, 0x63BB,
- 0x64CD, 0x65E9, 0x66F9, 0x5DE3, 0x69CD, 0x69FD, 0x6F15, 0x71E5,
- 0x4E89, 0x75E9, 0x76F8, 0x7A93, 0x7CDF, 0x7DCF, 0x7D9C, 0x8061,
- 0x8349, 0x8358, 0x846C, 0x84BC, 0x85FB, 0x88C5, 0x8D70, 0x9001,
- 0x906D, 0x9397, 0x971C, 0x9A12, 0x50CF, 0x5897, 0x618E,
-};
-static const unsigned short euc_to_utf8_C2[] = {
- 0x81D3, 0x8535, 0x8D08, 0x9020, 0x4FC3, 0x5074, 0x5247,
- 0x5373, 0x606F, 0x6349, 0x675F, 0x6E2C, 0x8DB3, 0x901F, 0x4FD7,
- 0x5C5E, 0x8CCA, 0x65CF, 0x7D9A, 0x5352, 0x8896, 0x5176, 0x63C3,
- 0x5B58, 0x5B6B, 0x5C0A, 0x640D, 0x6751, 0x905C, 0x4ED6, 0x591A,
- 0x592A, 0x6C70, 0x8A51, 0x553E, 0x5815, 0x59A5, 0x60F0, 0x6253,
- 0x67C1, 0x8235, 0x6955, 0x9640, 0x99C4, 0x9A28, 0x4F53, 0x5806,
- 0x5BFE, 0x8010, 0x5CB1, 0x5E2F, 0x5F85, 0x6020, 0x614B, 0x6234,
- 0x66FF, 0x6CF0, 0x6EDE, 0x80CE, 0x817F, 0x82D4, 0x888B, 0x8CB8,
- 0x9000, 0x902E, 0x968A, 0x9EDB, 0x9BDB, 0x4EE3, 0x53F0, 0x5927,
- 0x7B2C, 0x918D, 0x984C, 0x9DF9, 0x6EDD, 0x7027, 0x5353, 0x5544,
- 0x5B85, 0x6258, 0x629E, 0x62D3, 0x6CA2, 0x6FEF, 0x7422, 0x8A17,
- 0x9438, 0x6FC1, 0x8AFE, 0x8338, 0x51E7, 0x86F8, 0x53EA,
-};
-static const unsigned short euc_to_utf8_C3[] = {
- 0x53E9, 0x4F46, 0x9054, 0x8FB0, 0x596A, 0x8131, 0x5DFD,
- 0x7AEA, 0x8FBF, 0x68DA, 0x8C37, 0x72F8, 0x9C48, 0x6A3D, 0x8AB0,
- 0x4E39, 0x5358, 0x5606, 0x5766, 0x62C5, 0x63A2, 0x65E6, 0x6B4E,
- 0x6DE1, 0x6E5B, 0x70AD, 0x77ED, 0x7AEF, 0x7BAA, 0x7DBB, 0x803D,
- 0x80C6, 0x86CB, 0x8A95, 0x935B, 0x56E3, 0x58C7, 0x5F3E, 0x65AD,
- 0x6696, 0x6A80, 0x6BB5, 0x7537, 0x8AC7, 0x5024, 0x77E5, 0x5730,
- 0x5F1B, 0x6065, 0x667A, 0x6C60, 0x75F4, 0x7A1A, 0x7F6E, 0x81F4,
- 0x8718, 0x9045, 0x99B3, 0x7BC9, 0x755C, 0x7AF9, 0x7B51, 0x84C4,
- 0x9010, 0x79E9, 0x7A92, 0x8336, 0x5AE1, 0x7740, 0x4E2D, 0x4EF2,
- 0x5B99, 0x5FE0, 0x62BD, 0x663C, 0x67F1, 0x6CE8, 0x866B, 0x8877,
- 0x8A3B, 0x914E, 0x92F3, 0x99D0, 0x6A17, 0x7026, 0x732A, 0x82E7,
- 0x8457, 0x8CAF, 0x4E01, 0x5146, 0x51CB, 0x558B, 0x5BF5,
-};
-static const unsigned short euc_to_utf8_C4[] = {
- 0x5E16, 0x5E33, 0x5E81, 0x5F14, 0x5F35, 0x5F6B, 0x5FB4,
- 0x61F2, 0x6311, 0x66A2, 0x671D, 0x6F6E, 0x7252, 0x753A, 0x773A,
- 0x8074, 0x8139, 0x8178, 0x8776, 0x8ABF, 0x8ADC, 0x8D85, 0x8DF3,
- 0x929A, 0x9577, 0x9802, 0x9CE5, 0x52C5, 0x6357, 0x76F4, 0x6715,
- 0x6C88, 0x73CD, 0x8CC3, 0x93AE, 0x9673, 0x6D25, 0x589C, 0x690E,
- 0x69CC, 0x8FFD, 0x939A, 0x75DB, 0x901A, 0x585A, 0x6802, 0x63B4,
- 0x69FB, 0x4F43, 0x6F2C, 0x67D8, 0x8FBB, 0x8526, 0x7DB4, 0x9354,
- 0x693F, 0x6F70, 0x576A, 0x58F7, 0x5B2C, 0x7D2C, 0x722A, 0x540A,
- 0x91E3, 0x9DB4, 0x4EAD, 0x4F4E, 0x505C, 0x5075, 0x5243, 0x8C9E,
- 0x5448, 0x5824, 0x5B9A, 0x5E1D, 0x5E95, 0x5EAD, 0x5EF7, 0x5F1F,
- 0x608C, 0x62B5, 0x633A, 0x63D0, 0x68AF, 0x6C40, 0x7887, 0x798E,
- 0x7A0B, 0x7DE0, 0x8247, 0x8A02, 0x8AE6, 0x8E44, 0x9013,
-};
-static const unsigned short euc_to_utf8_C5[] = {
- 0x90B8, 0x912D, 0x91D8, 0x9F0E, 0x6CE5, 0x6458, 0x64E2,
- 0x6575, 0x6EF4, 0x7684, 0x7B1B, 0x9069, 0x93D1, 0x6EBA, 0x54F2,
- 0x5FB9, 0x64A4, 0x8F4D, 0x8FED, 0x9244, 0x5178, 0x586B, 0x5929,
- 0x5C55, 0x5E97, 0x6DFB, 0x7E8F, 0x751C, 0x8CBC, 0x8EE2, 0x985B,
- 0x70B9, 0x4F1D, 0x6BBF, 0x6FB1, 0x7530, 0x96FB, 0x514E, 0x5410,
- 0x5835, 0x5857, 0x59AC, 0x5C60, 0x5F92, 0x6597, 0x675C, 0x6E21,
- 0x767B, 0x83DF, 0x8CED, 0x9014, 0x90FD, 0x934D, 0x7825, 0x783A,
- 0x52AA, 0x5EA6, 0x571F, 0x5974, 0x6012, 0x5012, 0x515A, 0x51AC,
- 0x51CD, 0x5200, 0x5510, 0x5854, 0x5858, 0x5957, 0x5B95, 0x5CF6,
- 0x5D8B, 0x60BC, 0x6295, 0x642D, 0x6771, 0x6843, 0x68BC, 0x68DF,
- 0x76D7, 0x6DD8, 0x6E6F, 0x6D9B, 0x706F, 0x71C8, 0x5F53, 0x75D8,
- 0x7977, 0x7B49, 0x7B54, 0x7B52, 0x7CD6, 0x7D71, 0x5230,
-};
-static const unsigned short euc_to_utf8_C6[] = {
- 0x8463, 0x8569, 0x85E4, 0x8A0E, 0x8B04, 0x8C46, 0x8E0F,
- 0x9003, 0x900F, 0x9419, 0x9676, 0x982D, 0x9A30, 0x95D8, 0x50CD,
- 0x52D5, 0x540C, 0x5802, 0x5C0E, 0x61A7, 0x649E, 0x6D1E, 0x77B3,
- 0x7AE5, 0x80F4, 0x8404, 0x9053, 0x9285, 0x5CE0, 0x9D07, 0x533F,
- 0x5F97, 0x5FB3, 0x6D9C, 0x7279, 0x7763, 0x79BF, 0x7BE4, 0x6BD2,
- 0x72EC, 0x8AAD, 0x6803, 0x6A61, 0x51F8, 0x7A81, 0x6934, 0x5C4A,
- 0x9CF6, 0x82EB, 0x5BC5, 0x9149, 0x701E, 0x5678, 0x5C6F, 0x60C7,
- 0x6566, 0x6C8C, 0x8C5A, 0x9041, 0x9813, 0x5451, 0x66C7, 0x920D,
- 0x5948, 0x90A3, 0x5185, 0x4E4D, 0x51EA, 0x8599, 0x8B0E, 0x7058,
- 0x637A, 0x934B, 0x6962, 0x99B4, 0x7E04, 0x7577, 0x5357, 0x6960,
- 0x8EDF, 0x96E3, 0x6C5D, 0x4E8C, 0x5C3C, 0x5F10, 0x8FE9, 0x5302,
- 0x8CD1, 0x8089, 0x8679, 0x5EFF, 0x65E5, 0x4E73, 0x5165,
-};
-static const unsigned short euc_to_utf8_C7[] = {
- 0x5982, 0x5C3F, 0x97EE, 0x4EFB, 0x598A, 0x5FCD, 0x8A8D,
- 0x6FE1, 0x79B0, 0x7962, 0x5BE7, 0x8471, 0x732B, 0x71B1, 0x5E74,
- 0x5FF5, 0x637B, 0x649A, 0x71C3, 0x7C98, 0x4E43, 0x5EFC, 0x4E4B,
- 0x57DC, 0x56A2, 0x60A9, 0x6FC3, 0x7D0D, 0x80FD, 0x8133, 0x81BF,
- 0x8FB2, 0x8997, 0x86A4, 0x5DF4, 0x628A, 0x64AD, 0x8987, 0x6777,
- 0x6CE2, 0x6D3E, 0x7436, 0x7834, 0x5A46, 0x7F75, 0x82AD, 0x99AC,
- 0x4FF3, 0x5EC3, 0x62DD, 0x6392, 0x6557, 0x676F, 0x76C3, 0x724C,
- 0x80CC, 0x80BA, 0x8F29, 0x914D, 0x500D, 0x57F9, 0x5A92, 0x6885,
- 0x6973, 0x7164, 0x72FD, 0x8CB7, 0x58F2, 0x8CE0, 0x966A, 0x9019,
- 0x877F, 0x79E4, 0x77E7, 0x8429, 0x4F2F, 0x5265, 0x535A, 0x62CD,
- 0x67CF, 0x6CCA, 0x767D, 0x7B94, 0x7C95, 0x8236, 0x8584, 0x8FEB,
- 0x66DD, 0x6F20, 0x7206, 0x7E1B, 0x83AB, 0x99C1, 0x9EA6,
-};
-static const unsigned short euc_to_utf8_C8[] = {
- 0x51FD, 0x7BB1, 0x7872, 0x7BB8, 0x8087, 0x7B48, 0x6AE8,
- 0x5E61, 0x808C, 0x7551, 0x7560, 0x516B, 0x9262, 0x6E8C, 0x767A,
- 0x9197, 0x9AEA, 0x4F10, 0x7F70, 0x629C, 0x7B4F, 0x95A5, 0x9CE9,
- 0x567A, 0x5859, 0x86E4, 0x96BC, 0x4F34, 0x5224, 0x534A, 0x53CD,
- 0x53DB, 0x5E06, 0x642C, 0x6591, 0x677F, 0x6C3E, 0x6C4E, 0x7248,
- 0x72AF, 0x73ED, 0x7554, 0x7E41, 0x822C, 0x85E9, 0x8CA9, 0x7BC4,
- 0x91C6, 0x7169, 0x9812, 0x98EF, 0x633D, 0x6669, 0x756A, 0x76E4,
- 0x78D0, 0x8543, 0x86EE, 0x532A, 0x5351, 0x5426, 0x5983, 0x5E87,
- 0x5F7C, 0x60B2, 0x6249, 0x6279, 0x62AB, 0x6590, 0x6BD4, 0x6CCC,
- 0x75B2, 0x76AE, 0x7891, 0x79D8, 0x7DCB, 0x7F77, 0x80A5, 0x88AB,
- 0x8AB9, 0x8CBB, 0x907F, 0x975E, 0x98DB, 0x6A0B, 0x7C38, 0x5099,
- 0x5C3E, 0x5FAE, 0x6787, 0x6BD8, 0x7435, 0x7709, 0x7F8E,
-};
-static const unsigned short euc_to_utf8_C9[] = {
- 0x9F3B, 0x67CA, 0x7A17, 0x5339, 0x758B, 0x9AED, 0x5F66,
- 0x819D, 0x83F1, 0x8098, 0x5F3C, 0x5FC5, 0x7562, 0x7B46, 0x903C,
- 0x6867, 0x59EB, 0x5A9B, 0x7D10, 0x767E, 0x8B2C, 0x4FF5, 0x5F6A,
- 0x6A19, 0x6C37, 0x6F02, 0x74E2, 0x7968, 0x8868, 0x8A55, 0x8C79,
- 0x5EDF, 0x63CF, 0x75C5, 0x79D2, 0x82D7, 0x9328, 0x92F2, 0x849C,
- 0x86ED, 0x9C2D, 0x54C1, 0x5F6C, 0x658C, 0x6D5C, 0x7015, 0x8CA7,
- 0x8CD3, 0x983B, 0x654F, 0x74F6, 0x4E0D, 0x4ED8, 0x57E0, 0x592B,
- 0x5A66, 0x5BCC, 0x51A8, 0x5E03, 0x5E9C, 0x6016, 0x6276, 0x6577,
- 0x65A7, 0x666E, 0x6D6E, 0x7236, 0x7B26, 0x8150, 0x819A, 0x8299,
- 0x8B5C, 0x8CA0, 0x8CE6, 0x8D74, 0x961C, 0x9644, 0x4FAE, 0x64AB,
- 0x6B66, 0x821E, 0x8461, 0x856A, 0x90E8, 0x5C01, 0x6953, 0x98A8,
- 0x847A, 0x8557, 0x4F0F, 0x526F, 0x5FA9, 0x5E45, 0x670D,
-};
-static const unsigned short euc_to_utf8_CA[] = {
- 0x798F, 0x8179, 0x8907, 0x8986, 0x6DF5, 0x5F17, 0x6255,
- 0x6CB8, 0x4ECF, 0x7269, 0x9B92, 0x5206, 0x543B, 0x5674, 0x58B3,
- 0x61A4, 0x626E, 0x711A, 0x596E, 0x7C89, 0x7CDE, 0x7D1B, 0x96F0,
- 0x6587, 0x805E, 0x4E19, 0x4F75, 0x5175, 0x5840, 0x5E63, 0x5E73,
- 0x5F0A, 0x67C4, 0x4E26, 0x853D, 0x9589, 0x965B, 0x7C73, 0x9801,
- 0x50FB, 0x58C1, 0x7656, 0x78A7, 0x5225, 0x77A5, 0x8511, 0x7B86,
- 0x504F, 0x5909, 0x7247, 0x7BC7, 0x7DE8, 0x8FBA, 0x8FD4, 0x904D,
- 0x4FBF, 0x52C9, 0x5A29, 0x5F01, 0x97AD, 0x4FDD, 0x8217, 0x92EA,
- 0x5703, 0x6355, 0x6B69, 0x752B, 0x88DC, 0x8F14, 0x7A42, 0x52DF,
- 0x5893, 0x6155, 0x620A, 0x66AE, 0x6BCD, 0x7C3F, 0x83E9, 0x5023,
- 0x4FF8, 0x5305, 0x5446, 0x5831, 0x5949, 0x5B9D, 0x5CF0, 0x5CEF,
- 0x5D29, 0x5E96, 0x62B1, 0x6367, 0x653E, 0x65B9, 0x670B,
-};
-static const unsigned short euc_to_utf8_CB[] = {
- 0x6CD5, 0x6CE1, 0x70F9, 0x7832, 0x7E2B, 0x80DE, 0x82B3,
- 0x840C, 0x84EC, 0x8702, 0x8912, 0x8A2A, 0x8C4A, 0x90A6, 0x92D2,
- 0x98FD, 0x9CF3, 0x9D6C, 0x4E4F, 0x4EA1, 0x508D, 0x5256, 0x574A,
- 0x59A8, 0x5E3D, 0x5FD8, 0x5FD9, 0x623F, 0x66B4, 0x671B, 0x67D0,
- 0x68D2, 0x5192, 0x7D21, 0x80AA, 0x81A8, 0x8B00, 0x8C8C, 0x8CBF,
- 0x927E, 0x9632, 0x5420, 0x982C, 0x5317, 0x50D5, 0x535C, 0x58A8,
- 0x64B2, 0x6734, 0x7267, 0x7766, 0x7A46, 0x91E6, 0x52C3, 0x6CA1,
- 0x6B86, 0x5800, 0x5E4C, 0x5954, 0x672C, 0x7FFB, 0x51E1, 0x76C6,
- 0x6469, 0x78E8, 0x9B54, 0x9EBB, 0x57CB, 0x59B9, 0x6627, 0x679A,
- 0x6BCE, 0x54E9, 0x69D9, 0x5E55, 0x819C, 0x6795, 0x9BAA, 0x67FE,
- 0x9C52, 0x685D, 0x4EA6, 0x4FE3, 0x53C8, 0x62B9, 0x672B, 0x6CAB,
- 0x8FC4, 0x4FAD, 0x7E6D, 0x9EBF, 0x4E07, 0x6162, 0x6E80,
-};
-static const unsigned short euc_to_utf8_CC[] = {
- 0x6F2B, 0x8513, 0x5473, 0x672A, 0x9B45, 0x5DF3, 0x7B95,
- 0x5CAC, 0x5BC6, 0x871C, 0x6E4A, 0x84D1, 0x7A14, 0x8108, 0x5999,
- 0x7C8D, 0x6C11, 0x7720, 0x52D9, 0x5922, 0x7121, 0x725F, 0x77DB,
- 0x9727, 0x9D61, 0x690B, 0x5A7F, 0x5A18, 0x51A5, 0x540D, 0x547D,
- 0x660E, 0x76DF, 0x8FF7, 0x9298, 0x9CF4, 0x59EA, 0x725D, 0x6EC5,
- 0x514D, 0x68C9, 0x7DBF, 0x7DEC, 0x9762, 0x9EBA, 0x6478, 0x6A21,
- 0x8302, 0x5984, 0x5B5F, 0x6BDB, 0x731B, 0x76F2, 0x7DB2, 0x8017,
- 0x8499, 0x5132, 0x6728, 0x9ED9, 0x76EE, 0x6762, 0x52FF, 0x9905,
- 0x5C24, 0x623B, 0x7C7E, 0x8CB0, 0x554F, 0x60B6, 0x7D0B, 0x9580,
- 0x5301, 0x4E5F, 0x51B6, 0x591C, 0x723A, 0x8036, 0x91CE, 0x5F25,
- 0x77E2, 0x5384, 0x5F79, 0x7D04, 0x85AC, 0x8A33, 0x8E8D, 0x9756,
- 0x67F3, 0x85AE, 0x9453, 0x6109, 0x6108, 0x6CB9, 0x7652,
-};
-static const unsigned short euc_to_utf8_CD[] = {
- 0x8AED, 0x8F38, 0x552F, 0x4F51, 0x512A, 0x52C7, 0x53CB,
- 0x5BA5, 0x5E7D, 0x60A0, 0x6182, 0x63D6, 0x6709, 0x67DA, 0x6E67,
- 0x6D8C, 0x7336, 0x7337, 0x7531, 0x7950, 0x88D5, 0x8A98, 0x904A,
- 0x9091, 0x90F5, 0x96C4, 0x878D, 0x5915, 0x4E88, 0x4F59, 0x4E0E,
- 0x8A89, 0x8F3F, 0x9810, 0x50AD, 0x5E7C, 0x5996, 0x5BB9, 0x5EB8,
- 0x63DA, 0x63FA, 0x64C1, 0x66DC, 0x694A, 0x69D8, 0x6D0B, 0x6EB6,
- 0x7194, 0x7528, 0x7AAF, 0x7F8A, 0x8000, 0x8449, 0x84C9, 0x8981,
- 0x8B21, 0x8E0A, 0x9065, 0x967D, 0x990A, 0x617E, 0x6291, 0x6B32,
- 0x6C83, 0x6D74, 0x7FCC, 0x7FFC, 0x6DC0, 0x7F85, 0x87BA, 0x88F8,
- 0x6765, 0x83B1, 0x983C, 0x96F7, 0x6D1B, 0x7D61, 0x843D, 0x916A,
- 0x4E71, 0x5375, 0x5D50, 0x6B04, 0x6FEB, 0x85CD, 0x862D, 0x89A7,
- 0x5229, 0x540F, 0x5C65, 0x674E, 0x68A8, 0x7406, 0x7483,
-};
-static const unsigned short euc_to_utf8_CE[] = {
- 0x75E2, 0x88CF, 0x88E1, 0x91CC, 0x96E2, 0x9678, 0x5F8B,
- 0x7387, 0x7ACB, 0x844E, 0x63A0, 0x7565, 0x5289, 0x6D41, 0x6E9C,
- 0x7409, 0x7559, 0x786B, 0x7C92, 0x9686, 0x7ADC, 0x9F8D, 0x4FB6,
- 0x616E, 0x65C5, 0x865C, 0x4E86, 0x4EAE, 0x50DA, 0x4E21, 0x51CC,
- 0x5BEE, 0x6599, 0x6881, 0x6DBC, 0x731F, 0x7642, 0x77AD, 0x7A1C,
- 0x7CE7, 0x826F, 0x8AD2, 0x907C, 0x91CF, 0x9675, 0x9818, 0x529B,
- 0x7DD1, 0x502B, 0x5398, 0x6797, 0x6DCB, 0x71D0, 0x7433, 0x81E8,
- 0x8F2A, 0x96A3, 0x9C57, 0x9E9F, 0x7460, 0x5841, 0x6D99, 0x7D2F,
- 0x985E, 0x4EE4, 0x4F36, 0x4F8B, 0x51B7, 0x52B1, 0x5DBA, 0x601C,
- 0x73B2, 0x793C, 0x82D3, 0x9234, 0x96B7, 0x96F6, 0x970A, 0x9E97,
- 0x9F62, 0x66A6, 0x6B74, 0x5217, 0x52A3, 0x70C8, 0x88C2, 0x5EC9,
- 0x604B, 0x6190, 0x6F23, 0x7149, 0x7C3E, 0x7DF4, 0x806F,
-};
-static const unsigned short euc_to_utf8_CF[] = {
- 0x84EE, 0x9023, 0x932C, 0x5442, 0x9B6F, 0x6AD3, 0x7089,
- 0x8CC2, 0x8DEF, 0x9732, 0x52B4, 0x5A41, 0x5ECA, 0x5F04, 0x6717,
- 0x697C, 0x6994, 0x6D6A, 0x6F0F, 0x7262, 0x72FC, 0x7BED, 0x8001,
- 0x807E, 0x874B, 0x90CE, 0x516D, 0x9E93, 0x7984, 0x808B, 0x9332,
- 0x8AD6, 0x502D, 0x548C, 0x8A71, 0x6B6A, 0x8CC4, 0x8107, 0x60D1,
- 0x67A0, 0x9DF2, 0x4E99, 0x4E98, 0x9C10, 0x8A6B, 0x85C1, 0x8568,
- 0x6900, 0x6E7E, 0x7897, 0x8155, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_CF_x0213[] = {
- 0x84EE, 0x9023, 0x932C, 0x5442, 0x9B6F, 0x6AD3, 0x7089,
- 0x8CC2, 0x8DEF, 0x9732, 0x52B4, 0x5A41, 0x5ECA, 0x5F04, 0x6717,
- 0x697C, 0x6994, 0x6D6A, 0x6F0F, 0x7262, 0x72FC, 0x7BED, 0x8001,
- 0x807E, 0x874B, 0x90CE, 0x516D, 0x9E93, 0x7984, 0x808B, 0x9332,
- 0x8AD6, 0x502D, 0x548C, 0x8A71, 0x6B6A, 0x8CC4, 0x8107, 0x60D1,
- 0x67A0, 0x9DF2, 0x4E99, 0x4E98, 0x9C10, 0x8A6B, 0x85C1, 0x8568,
- 0x6900, 0x6E7E, 0x7897, 0x8155, 0xD842 /*0xDF9F*/, 0x5B41, 0x5B56, 0x5B7D,
- 0x5B93, 0x5BD8, 0x5BEC, 0x5C12, 0x5C1E, 0x5C23, 0x5C2B, 0x378D,
- 0x5C62, 0xFA3B, 0xFA3C, 0xD845 /*0xDEB4*/, 0x5C7A, 0x5C8F, 0x5C9F, 0x5CA3,
- 0x5CAA, 0x5CBA, 0x5CCB, 0x5CD0, 0x5CD2, 0x5CF4, 0xD847 /*0xDE34*/, 0x37E2,
- 0x5D0D, 0x5D27, 0xFA11, 0x5D46, 0x5D47, 0x5D53, 0x5D4A, 0x5D6D,
- 0x5D81, 0x5DA0, 0x5DA4, 0x5DA7, 0x5DB8, 0x5DCB, 0x541E,
-};
-static const unsigned short euc_to_utf8_D0[] = {
- 0x5F0C, 0x4E10, 0x4E15, 0x4E2A, 0x4E31, 0x4E36, 0x4E3C,
- 0x4E3F, 0x4E42, 0x4E56, 0x4E58, 0x4E82, 0x4E85, 0x8C6B, 0x4E8A,
- 0x8212, 0x5F0D, 0x4E8E, 0x4E9E, 0x4E9F, 0x4EA0, 0x4EA2, 0x4EB0,
- 0x4EB3, 0x4EB6, 0x4ECE, 0x4ECD, 0x4EC4, 0x4EC6, 0x4EC2, 0x4ED7,
- 0x4EDE, 0x4EED, 0x4EDF, 0x4EF7, 0x4F09, 0x4F5A, 0x4F30, 0x4F5B,
- 0x4F5D, 0x4F57, 0x4F47, 0x4F76, 0x4F88, 0x4F8F, 0x4F98, 0x4F7B,
- 0x4F69, 0x4F70, 0x4F91, 0x4F6F, 0x4F86, 0x4F96, 0x5118, 0x4FD4,
- 0x4FDF, 0x4FCE, 0x4FD8, 0x4FDB, 0x4FD1, 0x4FDA, 0x4FD0, 0x4FE4,
- 0x4FE5, 0x501A, 0x5028, 0x5014, 0x502A, 0x5025, 0x5005, 0x4F1C,
- 0x4FF6, 0x5021, 0x5029, 0x502C, 0x4FFE, 0x4FEF, 0x5011, 0x5006,
- 0x5043, 0x5047, 0x6703, 0x5055, 0x5050, 0x5048, 0x505A, 0x5056,
- 0x506C, 0x5078, 0x5080, 0x509A, 0x5085, 0x50B4, 0x50B2,
-};
-static const unsigned short euc_to_utf8_D1[] = {
- 0x50C9, 0x50CA, 0x50B3, 0x50C2, 0x50D6, 0x50DE, 0x50E5,
- 0x50ED, 0x50E3, 0x50EE, 0x50F9, 0x50F5, 0x5109, 0x5101, 0x5102,
- 0x5116, 0x5115, 0x5114, 0x511A, 0x5121, 0x513A, 0x5137, 0x513C,
- 0x513B, 0x513F, 0x5140, 0x5152, 0x514C, 0x5154, 0x5162, 0x7AF8,
- 0x5169, 0x516A, 0x516E, 0x5180, 0x5182, 0x56D8, 0x518C, 0x5189,
- 0x518F, 0x5191, 0x5193, 0x5195, 0x5196, 0x51A4, 0x51A6, 0x51A2,
- 0x51A9, 0x51AA, 0x51AB, 0x51B3, 0x51B1, 0x51B2, 0x51B0, 0x51B5,
- 0x51BD, 0x51C5, 0x51C9, 0x51DB, 0x51E0, 0x8655, 0x51E9, 0x51ED,
- 0x51F0, 0x51F5, 0x51FE, 0x5204, 0x520B, 0x5214, 0x520E, 0x5227,
- 0x522A, 0x522E, 0x5233, 0x5239, 0x524F, 0x5244, 0x524B, 0x524C,
- 0x525E, 0x5254, 0x526A, 0x5274, 0x5269, 0x5273, 0x527F, 0x527D,
- 0x528D, 0x5294, 0x5292, 0x5271, 0x5288, 0x5291, 0x8FA8,
-};
-static const unsigned short euc_to_utf8_D2[] = {
- 0x8FA7, 0x52AC, 0x52AD, 0x52BC, 0x52B5, 0x52C1, 0x52CD,
- 0x52D7, 0x52DE, 0x52E3, 0x52E6, 0x98ED, 0x52E0, 0x52F3, 0x52F5,
- 0x52F8, 0x52F9, 0x5306, 0x5308, 0x7538, 0x530D, 0x5310, 0x530F,
- 0x5315, 0x531A, 0x5323, 0x532F, 0x5331, 0x5333, 0x5338, 0x5340,
- 0x5346, 0x5345, 0x4E17, 0x5349, 0x534D, 0x51D6, 0x535E, 0x5369,
- 0x536E, 0x5918, 0x537B, 0x5377, 0x5382, 0x5396, 0x53A0, 0x53A6,
- 0x53A5, 0x53AE, 0x53B0, 0x53B6, 0x53C3, 0x7C12, 0x96D9, 0x53DF,
- 0x66FC, 0x71EE, 0x53EE, 0x53E8, 0x53ED, 0x53FA, 0x5401, 0x543D,
- 0x5440, 0x542C, 0x542D, 0x543C, 0x542E, 0x5436, 0x5429, 0x541D,
- 0x544E, 0x548F, 0x5475, 0x548E, 0x545F, 0x5471, 0x5477, 0x5470,
- 0x5492, 0x547B, 0x5480, 0x5476, 0x5484, 0x5490, 0x5486, 0x54C7,
- 0x54A2, 0x54B8, 0x54A5, 0x54AC, 0x54C4, 0x54C8, 0x54A8,
-};
-static const unsigned short euc_to_utf8_D3[] = {
- 0x54AB, 0x54C2, 0x54A4, 0x54BE, 0x54BC, 0x54D8, 0x54E5,
- 0x54E6, 0x550F, 0x5514, 0x54FD, 0x54EE, 0x54ED, 0x54FA, 0x54E2,
- 0x5539, 0x5540, 0x5563, 0x554C, 0x552E, 0x555C, 0x5545, 0x5556,
- 0x5557, 0x5538, 0x5533, 0x555D, 0x5599, 0x5580, 0x54AF, 0x558A,
- 0x559F, 0x557B, 0x557E, 0x5598, 0x559E, 0x55AE, 0x557C, 0x5583,
- 0x55A9, 0x5587, 0x55A8, 0x55DA, 0x55C5, 0x55DF, 0x55C4, 0x55DC,
- 0x55E4, 0x55D4, 0x5614, 0x55F7, 0x5616, 0x55FE, 0x55FD, 0x561B,
- 0x55F9, 0x564E, 0x5650, 0x71DF, 0x5634, 0x5636, 0x5632, 0x5638,
- 0x566B, 0x5664, 0x562F, 0x566C, 0x566A, 0x5686, 0x5680, 0x568A,
- 0x56A0, 0x5694, 0x568F, 0x56A5, 0x56AE, 0x56B6, 0x56B4, 0x56C2,
- 0x56BC, 0x56C1, 0x56C3, 0x56C0, 0x56C8, 0x56CE, 0x56D1, 0x56D3,
- 0x56D7, 0x56EE, 0x56F9, 0x5700, 0x56FF, 0x5704, 0x5709,
-};
-static const unsigned short euc_to_utf8_D4[] = {
- 0x5708, 0x570B, 0x570D, 0x5713, 0x5718, 0x5716, 0x55C7,
- 0x571C, 0x5726, 0x5737, 0x5738, 0x574E, 0x573B, 0x5740, 0x574F,
- 0x5769, 0x57C0, 0x5788, 0x5761, 0x577F, 0x5789, 0x5793, 0x57A0,
- 0x57B3, 0x57A4, 0x57AA, 0x57B0, 0x57C3, 0x57C6, 0x57D4, 0x57D2,
- 0x57D3, 0x580A, 0x57D6, 0x57E3, 0x580B, 0x5819, 0x581D, 0x5872,
- 0x5821, 0x5862, 0x584B, 0x5870, 0x6BC0, 0x5852, 0x583D, 0x5879,
- 0x5885, 0x58B9, 0x589F, 0x58AB, 0x58BA, 0x58DE, 0x58BB, 0x58B8,
- 0x58AE, 0x58C5, 0x58D3, 0x58D1, 0x58D7, 0x58D9, 0x58D8, 0x58E5,
- 0x58DC, 0x58E4, 0x58DF, 0x58EF, 0x58FA, 0x58F9, 0x58FB, 0x58FC,
- 0x58FD, 0x5902, 0x590A, 0x5910, 0x591B, 0x68A6, 0x5925, 0x592C,
- 0x592D, 0x5932, 0x5938, 0x593E, 0x7AD2, 0x5955, 0x5950, 0x594E,
- 0x595A, 0x5958, 0x5962, 0x5960, 0x5967, 0x596C, 0x5969,
-};
-static const unsigned short euc_to_utf8_D5[] = {
- 0x5978, 0x5981, 0x599D, 0x4F5E, 0x4FAB, 0x59A3, 0x59B2,
- 0x59C6, 0x59E8, 0x59DC, 0x598D, 0x59D9, 0x59DA, 0x5A25, 0x5A1F,
- 0x5A11, 0x5A1C, 0x5A09, 0x5A1A, 0x5A40, 0x5A6C, 0x5A49, 0x5A35,
- 0x5A36, 0x5A62, 0x5A6A, 0x5A9A, 0x5ABC, 0x5ABE, 0x5ACB, 0x5AC2,
- 0x5ABD, 0x5AE3, 0x5AD7, 0x5AE6, 0x5AE9, 0x5AD6, 0x5AFA, 0x5AFB,
- 0x5B0C, 0x5B0B, 0x5B16, 0x5B32, 0x5AD0, 0x5B2A, 0x5B36, 0x5B3E,
- 0x5B43, 0x5B45, 0x5B40, 0x5B51, 0x5B55, 0x5B5A, 0x5B5B, 0x5B65,
- 0x5B69, 0x5B70, 0x5B73, 0x5B75, 0x5B78, 0x6588, 0x5B7A, 0x5B80,
- 0x5B83, 0x5BA6, 0x5BB8, 0x5BC3, 0x5BC7, 0x5BC9, 0x5BD4, 0x5BD0,
- 0x5BE4, 0x5BE6, 0x5BE2, 0x5BDE, 0x5BE5, 0x5BEB, 0x5BF0, 0x5BF6,
- 0x5BF3, 0x5C05, 0x5C07, 0x5C08, 0x5C0D, 0x5C13, 0x5C20, 0x5C22,
- 0x5C28, 0x5C38, 0x5C39, 0x5C41, 0x5C46, 0x5C4E, 0x5C53,
-};
-static const unsigned short euc_to_utf8_D6[] = {
- 0x5C50, 0x5C4F, 0x5B71, 0x5C6C, 0x5C6E, 0x4E62, 0x5C76,
- 0x5C79, 0x5C8C, 0x5C91, 0x5C94, 0x599B, 0x5CAB, 0x5CBB, 0x5CB6,
- 0x5CBC, 0x5CB7, 0x5CC5, 0x5CBE, 0x5CC7, 0x5CD9, 0x5CE9, 0x5CFD,
- 0x5CFA, 0x5CED, 0x5D8C, 0x5CEA, 0x5D0B, 0x5D15, 0x5D17, 0x5D5C,
- 0x5D1F, 0x5D1B, 0x5D11, 0x5D14, 0x5D22, 0x5D1A, 0x5D19, 0x5D18,
- 0x5D4C, 0x5D52, 0x5D4E, 0x5D4B, 0x5D6C, 0x5D73, 0x5D76, 0x5D87,
- 0x5D84, 0x5D82, 0x5DA2, 0x5D9D, 0x5DAC, 0x5DAE, 0x5DBD, 0x5D90,
- 0x5DB7, 0x5DBC, 0x5DC9, 0x5DCD, 0x5DD3, 0x5DD2, 0x5DD6, 0x5DDB,
- 0x5DEB, 0x5DF2, 0x5DF5, 0x5E0B, 0x5E1A, 0x5E19, 0x5E11, 0x5E1B,
- 0x5E36, 0x5E37, 0x5E44, 0x5E43, 0x5E40, 0x5E4E, 0x5E57, 0x5E54,
- 0x5E5F, 0x5E62, 0x5E64, 0x5E47, 0x5E75, 0x5E76, 0x5E7A, 0x9EBC,
- 0x5E7F, 0x5EA0, 0x5EC1, 0x5EC2, 0x5EC8, 0x5ED0, 0x5ECF,
-};
-static const unsigned short euc_to_utf8_D7[] = {
- 0x5ED6, 0x5EE3, 0x5EDD, 0x5EDA, 0x5EDB, 0x5EE2, 0x5EE1,
- 0x5EE8, 0x5EE9, 0x5EEC, 0x5EF1, 0x5EF3, 0x5EF0, 0x5EF4, 0x5EF8,
- 0x5EFE, 0x5F03, 0x5F09, 0x5F5D, 0x5F5C, 0x5F0B, 0x5F11, 0x5F16,
- 0x5F29, 0x5F2D, 0x5F38, 0x5F41, 0x5F48, 0x5F4C, 0x5F4E, 0x5F2F,
- 0x5F51, 0x5F56, 0x5F57, 0x5F59, 0x5F61, 0x5F6D, 0x5F73, 0x5F77,
- 0x5F83, 0x5F82, 0x5F7F, 0x5F8A, 0x5F88, 0x5F91, 0x5F87, 0x5F9E,
- 0x5F99, 0x5F98, 0x5FA0, 0x5FA8, 0x5FAD, 0x5FBC, 0x5FD6, 0x5FFB,
- 0x5FE4, 0x5FF8, 0x5FF1, 0x5FDD, 0x60B3, 0x5FFF, 0x6021, 0x6060,
- 0x6019, 0x6010, 0x6029, 0x600E, 0x6031, 0x601B, 0x6015, 0x602B,
- 0x6026, 0x600F, 0x603A, 0x605A, 0x6041, 0x606A, 0x6077, 0x605F,
- 0x604A, 0x6046, 0x604D, 0x6063, 0x6043, 0x6064, 0x6042, 0x606C,
- 0x606B, 0x6059, 0x6081, 0x608D, 0x60E7, 0x6083, 0x609A,
-};
-static const unsigned short euc_to_utf8_D8[] = {
- 0x6084, 0x609B, 0x6096, 0x6097, 0x6092, 0x60A7, 0x608B,
- 0x60E1, 0x60B8, 0x60E0, 0x60D3, 0x60B4, 0x5FF0, 0x60BD, 0x60C6,
- 0x60B5, 0x60D8, 0x614D, 0x6115, 0x6106, 0x60F6, 0x60F7, 0x6100,
- 0x60F4, 0x60FA, 0x6103, 0x6121, 0x60FB, 0x60F1, 0x610D, 0x610E,
- 0x6147, 0x613E, 0x6128, 0x6127, 0x614A, 0x613F, 0x613C, 0x612C,
- 0x6134, 0x613D, 0x6142, 0x6144, 0x6173, 0x6177, 0x6158, 0x6159,
- 0x615A, 0x616B, 0x6174, 0x616F, 0x6165, 0x6171, 0x615F, 0x615D,
- 0x6153, 0x6175, 0x6199, 0x6196, 0x6187, 0x61AC, 0x6194, 0x619A,
- 0x618A, 0x6191, 0x61AB, 0x61AE, 0x61CC, 0x61CA, 0x61C9, 0x61F7,
- 0x61C8, 0x61C3, 0x61C6, 0x61BA, 0x61CB, 0x7F79, 0x61CD, 0x61E6,
- 0x61E3, 0x61F6, 0x61FA, 0x61F4, 0x61FF, 0x61FD, 0x61FC, 0x61FE,
- 0x6200, 0x6208, 0x6209, 0x620D, 0x620C, 0x6214, 0x621B,
-};
-static const unsigned short euc_to_utf8_D9[] = {
- 0x621E, 0x6221, 0x622A, 0x622E, 0x6230, 0x6232, 0x6233,
- 0x6241, 0x624E, 0x625E, 0x6263, 0x625B, 0x6260, 0x6268, 0x627C,
- 0x6282, 0x6289, 0x627E, 0x6292, 0x6293, 0x6296, 0x62D4, 0x6283,
- 0x6294, 0x62D7, 0x62D1, 0x62BB, 0x62CF, 0x62FF, 0x62C6, 0x64D4,
- 0x62C8, 0x62DC, 0x62CC, 0x62CA, 0x62C2, 0x62C7, 0x629B, 0x62C9,
- 0x630C, 0x62EE, 0x62F1, 0x6327, 0x6302, 0x6308, 0x62EF, 0x62F5,
- 0x6350, 0x633E, 0x634D, 0x641C, 0x634F, 0x6396, 0x638E, 0x6380,
- 0x63AB, 0x6376, 0x63A3, 0x638F, 0x6389, 0x639F, 0x63B5, 0x636B,
- 0x6369, 0x63BE, 0x63E9, 0x63C0, 0x63C6, 0x63E3, 0x63C9, 0x63D2,
- 0x63F6, 0x63C4, 0x6416, 0x6434, 0x6406, 0x6413, 0x6426, 0x6436,
- 0x651D, 0x6417, 0x6428, 0x640F, 0x6467, 0x646F, 0x6476, 0x644E,
- 0x652A, 0x6495, 0x6493, 0x64A5, 0x64A9, 0x6488, 0x64BC,
-};
-static const unsigned short euc_to_utf8_DA[] = {
- 0x64DA, 0x64D2, 0x64C5, 0x64C7, 0x64BB, 0x64D8, 0x64C2,
- 0x64F1, 0x64E7, 0x8209, 0x64E0, 0x64E1, 0x62AC, 0x64E3, 0x64EF,
- 0x652C, 0x64F6, 0x64F4, 0x64F2, 0x64FA, 0x6500, 0x64FD, 0x6518,
- 0x651C, 0x6505, 0x6524, 0x6523, 0x652B, 0x6534, 0x6535, 0x6537,
- 0x6536, 0x6538, 0x754B, 0x6548, 0x6556, 0x6555, 0x654D, 0x6558,
- 0x655E, 0x655D, 0x6572, 0x6578, 0x6582, 0x6583, 0x8B8A, 0x659B,
- 0x659F, 0x65AB, 0x65B7, 0x65C3, 0x65C6, 0x65C1, 0x65C4, 0x65CC,
- 0x65D2, 0x65DB, 0x65D9, 0x65E0, 0x65E1, 0x65F1, 0x6772, 0x660A,
- 0x6603, 0x65FB, 0x6773, 0x6635, 0x6636, 0x6634, 0x661C, 0x664F,
- 0x6644, 0x6649, 0x6641, 0x665E, 0x665D, 0x6664, 0x6667, 0x6668,
- 0x665F, 0x6662, 0x6670, 0x6683, 0x6688, 0x668E, 0x6689, 0x6684,
- 0x6698, 0x669D, 0x66C1, 0x66B9, 0x66C9, 0x66BE, 0x66BC,
-};
-static const unsigned short euc_to_utf8_DB[] = {
- 0x66C4, 0x66B8, 0x66D6, 0x66DA, 0x66E0, 0x663F, 0x66E6,
- 0x66E9, 0x66F0, 0x66F5, 0x66F7, 0x670F, 0x6716, 0x671E, 0x6726,
- 0x6727, 0x9738, 0x672E, 0x673F, 0x6736, 0x6741, 0x6738, 0x6737,
- 0x6746, 0x675E, 0x6760, 0x6759, 0x6763, 0x6764, 0x6789, 0x6770,
- 0x67A9, 0x677C, 0x676A, 0x678C, 0x678B, 0x67A6, 0x67A1, 0x6785,
- 0x67B7, 0x67EF, 0x67B4, 0x67EC, 0x67B3, 0x67E9, 0x67B8, 0x67E4,
- 0x67DE, 0x67DD, 0x67E2, 0x67EE, 0x67B9, 0x67CE, 0x67C6, 0x67E7,
- 0x6A9C, 0x681E, 0x6846, 0x6829, 0x6840, 0x684D, 0x6832, 0x684E,
- 0x68B3, 0x682B, 0x6859, 0x6863, 0x6877, 0x687F, 0x689F, 0x688F,
- 0x68AD, 0x6894, 0x689D, 0x689B, 0x6883, 0x6AAE, 0x68B9, 0x6874,
- 0x68B5, 0x68A0, 0x68BA, 0x690F, 0x688D, 0x687E, 0x6901, 0x68CA,
- 0x6908, 0x68D8, 0x6922, 0x6926, 0x68E1, 0x690C, 0x68CD,
-};
-static const unsigned short euc_to_utf8_DC[] = {
- 0x68D4, 0x68E7, 0x68D5, 0x6936, 0x6912, 0x6904, 0x68D7,
- 0x68E3, 0x6925, 0x68F9, 0x68E0, 0x68EF, 0x6928, 0x692A, 0x691A,
- 0x6923, 0x6921, 0x68C6, 0x6979, 0x6977, 0x695C, 0x6978, 0x696B,
- 0x6954, 0x697E, 0x696E, 0x6939, 0x6974, 0x693D, 0x6959, 0x6930,
- 0x6961, 0x695E, 0x695D, 0x6981, 0x696A, 0x69B2, 0x69AE, 0x69D0,
- 0x69BF, 0x69C1, 0x69D3, 0x69BE, 0x69CE, 0x5BE8, 0x69CA, 0x69DD,
- 0x69BB, 0x69C3, 0x69A7, 0x6A2E, 0x6991, 0x69A0, 0x699C, 0x6995,
- 0x69B4, 0x69DE, 0x69E8, 0x6A02, 0x6A1B, 0x69FF, 0x6B0A, 0x69F9,
- 0x69F2, 0x69E7, 0x6A05, 0x69B1, 0x6A1E, 0x69ED, 0x6A14, 0x69EB,
- 0x6A0A, 0x6A12, 0x6AC1, 0x6A23, 0x6A13, 0x6A44, 0x6A0C, 0x6A72,
- 0x6A36, 0x6A78, 0x6A47, 0x6A62, 0x6A59, 0x6A66, 0x6A48, 0x6A38,
- 0x6A22, 0x6A90, 0x6A8D, 0x6AA0, 0x6A84, 0x6AA2, 0x6AA3,
-};
-static const unsigned short euc_to_utf8_DD[] = {
- 0x6A97, 0x8617, 0x6ABB, 0x6AC3, 0x6AC2, 0x6AB8, 0x6AB3,
- 0x6AAC, 0x6ADE, 0x6AD1, 0x6ADF, 0x6AAA, 0x6ADA, 0x6AEA, 0x6AFB,
- 0x6B05, 0x8616, 0x6AFA, 0x6B12, 0x6B16, 0x9B31, 0x6B1F, 0x6B38,
- 0x6B37, 0x76DC, 0x6B39, 0x98EE, 0x6B47, 0x6B43, 0x6B49, 0x6B50,
- 0x6B59, 0x6B54, 0x6B5B, 0x6B5F, 0x6B61, 0x6B78, 0x6B79, 0x6B7F,
- 0x6B80, 0x6B84, 0x6B83, 0x6B8D, 0x6B98, 0x6B95, 0x6B9E, 0x6BA4,
- 0x6BAA, 0x6BAB, 0x6BAF, 0x6BB2, 0x6BB1, 0x6BB3, 0x6BB7, 0x6BBC,
- 0x6BC6, 0x6BCB, 0x6BD3, 0x6BDF, 0x6BEC, 0x6BEB, 0x6BF3, 0x6BEF,
- 0x9EBE, 0x6C08, 0x6C13, 0x6C14, 0x6C1B, 0x6C24, 0x6C23, 0x6C5E,
- 0x6C55, 0x6C62, 0x6C6A, 0x6C82, 0x6C8D, 0x6C9A, 0x6C81, 0x6C9B,
- 0x6C7E, 0x6C68, 0x6C73, 0x6C92, 0x6C90, 0x6CC4, 0x6CF1, 0x6CD3,
- 0x6CBD, 0x6CD7, 0x6CC5, 0x6CDD, 0x6CAE, 0x6CB1, 0x6CBE,
-};
-static const unsigned short euc_to_utf8_DE[] = {
- 0x6CBA, 0x6CDB, 0x6CEF, 0x6CD9, 0x6CEA, 0x6D1F, 0x884D,
- 0x6D36, 0x6D2B, 0x6D3D, 0x6D38, 0x6D19, 0x6D35, 0x6D33, 0x6D12,
- 0x6D0C, 0x6D63, 0x6D93, 0x6D64, 0x6D5A, 0x6D79, 0x6D59, 0x6D8E,
- 0x6D95, 0x6FE4, 0x6D85, 0x6DF9, 0x6E15, 0x6E0A, 0x6DB5, 0x6DC7,
- 0x6DE6, 0x6DB8, 0x6DC6, 0x6DEC, 0x6DDE, 0x6DCC, 0x6DE8, 0x6DD2,
- 0x6DC5, 0x6DFA, 0x6DD9, 0x6DE4, 0x6DD5, 0x6DEA, 0x6DEE, 0x6E2D,
- 0x6E6E, 0x6E2E, 0x6E19, 0x6E72, 0x6E5F, 0x6E3E, 0x6E23, 0x6E6B,
- 0x6E2B, 0x6E76, 0x6E4D, 0x6E1F, 0x6E43, 0x6E3A, 0x6E4E, 0x6E24,
- 0x6EFF, 0x6E1D, 0x6E38, 0x6E82, 0x6EAA, 0x6E98, 0x6EC9, 0x6EB7,
- 0x6ED3, 0x6EBD, 0x6EAF, 0x6EC4, 0x6EB2, 0x6ED4, 0x6ED5, 0x6E8F,
- 0x6EA5, 0x6EC2, 0x6E9F, 0x6F41, 0x6F11, 0x704C, 0x6EEC, 0x6EF8,
- 0x6EFE, 0x6F3F, 0x6EF2, 0x6F31, 0x6EEF, 0x6F32, 0x6ECC,
-};
-static const unsigned short euc_to_utf8_DF[] = {
- 0x6F3E, 0x6F13, 0x6EF7, 0x6F86, 0x6F7A, 0x6F78, 0x6F81,
- 0x6F80, 0x6F6F, 0x6F5B, 0x6FF3, 0x6F6D, 0x6F82, 0x6F7C, 0x6F58,
- 0x6F8E, 0x6F91, 0x6FC2, 0x6F66, 0x6FB3, 0x6FA3, 0x6FA1, 0x6FA4,
- 0x6FB9, 0x6FC6, 0x6FAA, 0x6FDF, 0x6FD5, 0x6FEC, 0x6FD4, 0x6FD8,
- 0x6FF1, 0x6FEE, 0x6FDB, 0x7009, 0x700B, 0x6FFA, 0x7011, 0x7001,
- 0x700F, 0x6FFE, 0x701B, 0x701A, 0x6F74, 0x701D, 0x7018, 0x701F,
- 0x7030, 0x703E, 0x7032, 0x7051, 0x7063, 0x7099, 0x7092, 0x70AF,
- 0x70F1, 0x70AC, 0x70B8, 0x70B3, 0x70AE, 0x70DF, 0x70CB, 0x70DD,
- 0x70D9, 0x7109, 0x70FD, 0x711C, 0x7119, 0x7165, 0x7155, 0x7188,
- 0x7166, 0x7162, 0x714C, 0x7156, 0x716C, 0x718F, 0x71FB, 0x7184,
- 0x7195, 0x71A8, 0x71AC, 0x71D7, 0x71B9, 0x71BE, 0x71D2, 0x71C9,
- 0x71D4, 0x71CE, 0x71E0, 0x71EC, 0x71E7, 0x71F5, 0x71FC,
-};
-static const unsigned short euc_to_utf8_E0[] = {
- 0x71F9, 0x71FF, 0x720D, 0x7210, 0x721B, 0x7228, 0x722D,
- 0x722C, 0x7230, 0x7232, 0x723B, 0x723C, 0x723F, 0x7240, 0x7246,
- 0x724B, 0x7258, 0x7274, 0x727E, 0x7282, 0x7281, 0x7287, 0x7292,
- 0x7296, 0x72A2, 0x72A7, 0x72B9, 0x72B2, 0x72C3, 0x72C6, 0x72C4,
- 0x72CE, 0x72D2, 0x72E2, 0x72E0, 0x72E1, 0x72F9, 0x72F7, 0x500F,
- 0x7317, 0x730A, 0x731C, 0x7316, 0x731D, 0x7334, 0x732F, 0x7329,
- 0x7325, 0x733E, 0x734E, 0x734F, 0x9ED8, 0x7357, 0x736A, 0x7368,
- 0x7370, 0x7378, 0x7375, 0x737B, 0x737A, 0x73C8, 0x73B3, 0x73CE,
- 0x73BB, 0x73C0, 0x73E5, 0x73EE, 0x73DE, 0x74A2, 0x7405, 0x746F,
- 0x7425, 0x73F8, 0x7432, 0x743A, 0x7455, 0x743F, 0x745F, 0x7459,
- 0x7441, 0x745C, 0x7469, 0x7470, 0x7463, 0x746A, 0x7476, 0x747E,
- 0x748B, 0x749E, 0x74A7, 0x74CA, 0x74CF, 0x74D4, 0x73F1,
-};
-static const unsigned short euc_to_utf8_E1[] = {
- 0x74E0, 0x74E3, 0x74E7, 0x74E9, 0x74EE, 0x74F2, 0x74F0,
- 0x74F1, 0x74F8, 0x74F7, 0x7504, 0x7503, 0x7505, 0x750C, 0x750E,
- 0x750D, 0x7515, 0x7513, 0x751E, 0x7526, 0x752C, 0x753C, 0x7544,
- 0x754D, 0x754A, 0x7549, 0x755B, 0x7546, 0x755A, 0x7569, 0x7564,
- 0x7567, 0x756B, 0x756D, 0x7578, 0x7576, 0x7586, 0x7587, 0x7574,
- 0x758A, 0x7589, 0x7582, 0x7594, 0x759A, 0x759D, 0x75A5, 0x75A3,
- 0x75C2, 0x75B3, 0x75C3, 0x75B5, 0x75BD, 0x75B8, 0x75BC, 0x75B1,
- 0x75CD, 0x75CA, 0x75D2, 0x75D9, 0x75E3, 0x75DE, 0x75FE, 0x75FF,
- 0x75FC, 0x7601, 0x75F0, 0x75FA, 0x75F2, 0x75F3, 0x760B, 0x760D,
- 0x7609, 0x761F, 0x7627, 0x7620, 0x7621, 0x7622, 0x7624, 0x7634,
- 0x7630, 0x763B, 0x7647, 0x7648, 0x7646, 0x765C, 0x7658, 0x7661,
- 0x7662, 0x7668, 0x7669, 0x766A, 0x7667, 0x766C, 0x7670,
-};
-static const unsigned short euc_to_utf8_E2[] = {
- 0x7672, 0x7676, 0x7678, 0x767C, 0x7680, 0x7683, 0x7688,
- 0x768B, 0x768E, 0x7696, 0x7693, 0x7699, 0x769A, 0x76B0, 0x76B4,
- 0x76B8, 0x76B9, 0x76BA, 0x76C2, 0x76CD, 0x76D6, 0x76D2, 0x76DE,
- 0x76E1, 0x76E5, 0x76E7, 0x76EA, 0x862F, 0x76FB, 0x7708, 0x7707,
- 0x7704, 0x7729, 0x7724, 0x771E, 0x7725, 0x7726, 0x771B, 0x7737,
- 0x7738, 0x7747, 0x775A, 0x7768, 0x776B, 0x775B, 0x7765, 0x777F,
- 0x777E, 0x7779, 0x778E, 0x778B, 0x7791, 0x77A0, 0x779E, 0x77B0,
- 0x77B6, 0x77B9, 0x77BF, 0x77BC, 0x77BD, 0x77BB, 0x77C7, 0x77CD,
- 0x77D7, 0x77DA, 0x77DC, 0x77E3, 0x77EE, 0x77FC, 0x780C, 0x7812,
- 0x7926, 0x7820, 0x792A, 0x7845, 0x788E, 0x7874, 0x7886, 0x787C,
- 0x789A, 0x788C, 0x78A3, 0x78B5, 0x78AA, 0x78AF, 0x78D1, 0x78C6,
- 0x78CB, 0x78D4, 0x78BE, 0x78BC, 0x78C5, 0x78CA, 0x78EC,
-};
-static const unsigned short euc_to_utf8_E3[] = {
- 0x78E7, 0x78DA, 0x78FD, 0x78F4, 0x7907, 0x7912, 0x7911,
- 0x7919, 0x792C, 0x792B, 0x7940, 0x7960, 0x7957, 0x795F, 0x795A,
- 0x7955, 0x7953, 0x797A, 0x797F, 0x798A, 0x799D, 0x79A7, 0x9F4B,
- 0x79AA, 0x79AE, 0x79B3, 0x79B9, 0x79BA, 0x79C9, 0x79D5, 0x79E7,
- 0x79EC, 0x79E1, 0x79E3, 0x7A08, 0x7A0D, 0x7A18, 0x7A19, 0x7A20,
- 0x7A1F, 0x7980, 0x7A31, 0x7A3B, 0x7A3E, 0x7A37, 0x7A43, 0x7A57,
- 0x7A49, 0x7A61, 0x7A62, 0x7A69, 0x9F9D, 0x7A70, 0x7A79, 0x7A7D,
- 0x7A88, 0x7A97, 0x7A95, 0x7A98, 0x7A96, 0x7AA9, 0x7AC8, 0x7AB0,
- 0x7AB6, 0x7AC5, 0x7AC4, 0x7ABF, 0x9083, 0x7AC7, 0x7ACA, 0x7ACD,
- 0x7ACF, 0x7AD5, 0x7AD3, 0x7AD9, 0x7ADA, 0x7ADD, 0x7AE1, 0x7AE2,
- 0x7AE6, 0x7AED, 0x7AF0, 0x7B02, 0x7B0F, 0x7B0A, 0x7B06, 0x7B33,
- 0x7B18, 0x7B19, 0x7B1E, 0x7B35, 0x7B28, 0x7B36, 0x7B50,
-};
-static const unsigned short euc_to_utf8_E4[] = {
- 0x7B7A, 0x7B04, 0x7B4D, 0x7B0B, 0x7B4C, 0x7B45, 0x7B75,
- 0x7B65, 0x7B74, 0x7B67, 0x7B70, 0x7B71, 0x7B6C, 0x7B6E, 0x7B9D,
- 0x7B98, 0x7B9F, 0x7B8D, 0x7B9C, 0x7B9A, 0x7B8B, 0x7B92, 0x7B8F,
- 0x7B5D, 0x7B99, 0x7BCB, 0x7BC1, 0x7BCC, 0x7BCF, 0x7BB4, 0x7BC6,
- 0x7BDD, 0x7BE9, 0x7C11, 0x7C14, 0x7BE6, 0x7BE5, 0x7C60, 0x7C00,
- 0x7C07, 0x7C13, 0x7BF3, 0x7BF7, 0x7C17, 0x7C0D, 0x7BF6, 0x7C23,
- 0x7C27, 0x7C2A, 0x7C1F, 0x7C37, 0x7C2B, 0x7C3D, 0x7C4C, 0x7C43,
- 0x7C54, 0x7C4F, 0x7C40, 0x7C50, 0x7C58, 0x7C5F, 0x7C64, 0x7C56,
- 0x7C65, 0x7C6C, 0x7C75, 0x7C83, 0x7C90, 0x7CA4, 0x7CAD, 0x7CA2,
- 0x7CAB, 0x7CA1, 0x7CA8, 0x7CB3, 0x7CB2, 0x7CB1, 0x7CAE, 0x7CB9,
- 0x7CBD, 0x7CC0, 0x7CC5, 0x7CC2, 0x7CD8, 0x7CD2, 0x7CDC, 0x7CE2,
- 0x9B3B, 0x7CEF, 0x7CF2, 0x7CF4, 0x7CF6, 0x7CFA, 0x7D06,
-};
-static const unsigned short euc_to_utf8_E5[] = {
- 0x7D02, 0x7D1C, 0x7D15, 0x7D0A, 0x7D45, 0x7D4B, 0x7D2E,
- 0x7D32, 0x7D3F, 0x7D35, 0x7D46, 0x7D73, 0x7D56, 0x7D4E, 0x7D72,
- 0x7D68, 0x7D6E, 0x7D4F, 0x7D63, 0x7D93, 0x7D89, 0x7D5B, 0x7D8F,
- 0x7D7D, 0x7D9B, 0x7DBA, 0x7DAE, 0x7DA3, 0x7DB5, 0x7DC7, 0x7DBD,
- 0x7DAB, 0x7E3D, 0x7DA2, 0x7DAF, 0x7DDC, 0x7DB8, 0x7D9F, 0x7DB0,
- 0x7DD8, 0x7DDD, 0x7DE4, 0x7DDE, 0x7DFB, 0x7DF2, 0x7DE1, 0x7E05,
- 0x7E0A, 0x7E23, 0x7E21, 0x7E12, 0x7E31, 0x7E1F, 0x7E09, 0x7E0B,
- 0x7E22, 0x7E46, 0x7E66, 0x7E3B, 0x7E35, 0x7E39, 0x7E43, 0x7E37,
- 0x7E32, 0x7E3A, 0x7E67, 0x7E5D, 0x7E56, 0x7E5E, 0x7E59, 0x7E5A,
- 0x7E79, 0x7E6A, 0x7E69, 0x7E7C, 0x7E7B, 0x7E83, 0x7DD5, 0x7E7D,
- 0x8FAE, 0x7E7F, 0x7E88, 0x7E89, 0x7E8C, 0x7E92, 0x7E90, 0x7E93,
- 0x7E94, 0x7E96, 0x7E8E, 0x7E9B, 0x7E9C, 0x7F38, 0x7F3A,
-};
-static const unsigned short euc_to_utf8_E6[] = {
- 0x7F45, 0x7F4C, 0x7F4D, 0x7F4E, 0x7F50, 0x7F51, 0x7F55,
- 0x7F54, 0x7F58, 0x7F5F, 0x7F60, 0x7F68, 0x7F69, 0x7F67, 0x7F78,
- 0x7F82, 0x7F86, 0x7F83, 0x7F88, 0x7F87, 0x7F8C, 0x7F94, 0x7F9E,
- 0x7F9D, 0x7F9A, 0x7FA3, 0x7FAF, 0x7FB2, 0x7FB9, 0x7FAE, 0x7FB6,
- 0x7FB8, 0x8B71, 0x7FC5, 0x7FC6, 0x7FCA, 0x7FD5, 0x7FD4, 0x7FE1,
- 0x7FE6, 0x7FE9, 0x7FF3, 0x7FF9, 0x98DC, 0x8006, 0x8004, 0x800B,
- 0x8012, 0x8018, 0x8019, 0x801C, 0x8021, 0x8028, 0x803F, 0x803B,
- 0x804A, 0x8046, 0x8052, 0x8058, 0x805A, 0x805F, 0x8062, 0x8068,
- 0x8073, 0x8072, 0x8070, 0x8076, 0x8079, 0x807D, 0x807F, 0x8084,
- 0x8086, 0x8085, 0x809B, 0x8093, 0x809A, 0x80AD, 0x5190, 0x80AC,
- 0x80DB, 0x80E5, 0x80D9, 0x80DD, 0x80C4, 0x80DA, 0x80D6, 0x8109,
- 0x80EF, 0x80F1, 0x811B, 0x8129, 0x8123, 0x812F, 0x814B,
-};
-static const unsigned short euc_to_utf8_E7[] = {
- 0x968B, 0x8146, 0x813E, 0x8153, 0x8151, 0x80FC, 0x8171,
- 0x816E, 0x8165, 0x8166, 0x8174, 0x8183, 0x8188, 0x818A, 0x8180,
- 0x8182, 0x81A0, 0x8195, 0x81A4, 0x81A3, 0x815F, 0x8193, 0x81A9,
- 0x81B0, 0x81B5, 0x81BE, 0x81B8, 0x81BD, 0x81C0, 0x81C2, 0x81BA,
- 0x81C9, 0x81CD, 0x81D1, 0x81D9, 0x81D8, 0x81C8, 0x81DA, 0x81DF,
- 0x81E0, 0x81E7, 0x81FA, 0x81FB, 0x81FE, 0x8201, 0x8202, 0x8205,
- 0x8207, 0x820A, 0x820D, 0x8210, 0x8216, 0x8229, 0x822B, 0x8238,
- 0x8233, 0x8240, 0x8259, 0x8258, 0x825D, 0x825A, 0x825F, 0x8264,
- 0x8262, 0x8268, 0x826A, 0x826B, 0x822E, 0x8271, 0x8277, 0x8278,
- 0x827E, 0x828D, 0x8292, 0x82AB, 0x829F, 0x82BB, 0x82AC, 0x82E1,
- 0x82E3, 0x82DF, 0x82D2, 0x82F4, 0x82F3, 0x82FA, 0x8393, 0x8303,
- 0x82FB, 0x82F9, 0x82DE, 0x8306, 0x82DC, 0x8309, 0x82D9,
-};
-static const unsigned short euc_to_utf8_E8[] = {
- 0x8335, 0x8334, 0x8316, 0x8332, 0x8331, 0x8340, 0x8339,
- 0x8350, 0x8345, 0x832F, 0x832B, 0x8317, 0x8318, 0x8385, 0x839A,
- 0x83AA, 0x839F, 0x83A2, 0x8396, 0x8323, 0x838E, 0x8387, 0x838A,
- 0x837C, 0x83B5, 0x8373, 0x8375, 0x83A0, 0x8389, 0x83A8, 0x83F4,
- 0x8413, 0x83EB, 0x83CE, 0x83FD, 0x8403, 0x83D8, 0x840B, 0x83C1,
- 0x83F7, 0x8407, 0x83E0, 0x83F2, 0x840D, 0x8422, 0x8420, 0x83BD,
- 0x8438, 0x8506, 0x83FB, 0x846D, 0x842A, 0x843C, 0x855A, 0x8484,
- 0x8477, 0x846B, 0x84AD, 0x846E, 0x8482, 0x8469, 0x8446, 0x842C,
- 0x846F, 0x8479, 0x8435, 0x84CA, 0x8462, 0x84B9, 0x84BF, 0x849F,
- 0x84D9, 0x84CD, 0x84BB, 0x84DA, 0x84D0, 0x84C1, 0x84C6, 0x84D6,
- 0x84A1, 0x8521, 0x84FF, 0x84F4, 0x8517, 0x8518, 0x852C, 0x851F,
- 0x8515, 0x8514, 0x84FC, 0x8540, 0x8563, 0x8558, 0x8548,
-};
-static const unsigned short euc_to_utf8_E9[] = {
- 0x8541, 0x8602, 0x854B, 0x8555, 0x8580, 0x85A4, 0x8588,
- 0x8591, 0x858A, 0x85A8, 0x856D, 0x8594, 0x859B, 0x85EA, 0x8587,
- 0x859C, 0x8577, 0x857E, 0x8590, 0x85C9, 0x85BA, 0x85CF, 0x85B9,
- 0x85D0, 0x85D5, 0x85DD, 0x85E5, 0x85DC, 0x85F9, 0x860A, 0x8613,
- 0x860B, 0x85FE, 0x85FA, 0x8606, 0x8622, 0x861A, 0x8630, 0x863F,
- 0x864D, 0x4E55, 0x8654, 0x865F, 0x8667, 0x8671, 0x8693, 0x86A3,
- 0x86A9, 0x86AA, 0x868B, 0x868C, 0x86B6, 0x86AF, 0x86C4, 0x86C6,
- 0x86B0, 0x86C9, 0x8823, 0x86AB, 0x86D4, 0x86DE, 0x86E9, 0x86EC,
- 0x86DF, 0x86DB, 0x86EF, 0x8712, 0x8706, 0x8708, 0x8700, 0x8703,
- 0x86FB, 0x8711, 0x8709, 0x870D, 0x86F9, 0x870A, 0x8734, 0x873F,
- 0x8737, 0x873B, 0x8725, 0x8729, 0x871A, 0x8760, 0x875F, 0x8778,
- 0x874C, 0x874E, 0x8774, 0x8757, 0x8768, 0x876E, 0x8759,
-};
-static const unsigned short euc_to_utf8_EA[] = {
- 0x8753, 0x8763, 0x876A, 0x8805, 0x87A2, 0x879F, 0x8782,
- 0x87AF, 0x87CB, 0x87BD, 0x87C0, 0x87D0, 0x96D6, 0x87AB, 0x87C4,
- 0x87B3, 0x87C7, 0x87C6, 0x87BB, 0x87EF, 0x87F2, 0x87E0, 0x880F,
- 0x880D, 0x87FE, 0x87F6, 0x87F7, 0x880E, 0x87D2, 0x8811, 0x8816,
- 0x8815, 0x8822, 0x8821, 0x8831, 0x8836, 0x8839, 0x8827, 0x883B,
- 0x8844, 0x8842, 0x8852, 0x8859, 0x885E, 0x8862, 0x886B, 0x8881,
- 0x887E, 0x889E, 0x8875, 0x887D, 0x88B5, 0x8872, 0x8882, 0x8897,
- 0x8892, 0x88AE, 0x8899, 0x88A2, 0x888D, 0x88A4, 0x88B0, 0x88BF,
- 0x88B1, 0x88C3, 0x88C4, 0x88D4, 0x88D8, 0x88D9, 0x88DD, 0x88F9,
- 0x8902, 0x88FC, 0x88F4, 0x88E8, 0x88F2, 0x8904, 0x890C, 0x890A,
- 0x8913, 0x8943, 0x891E, 0x8925, 0x892A, 0x892B, 0x8941, 0x8944,
- 0x893B, 0x8936, 0x8938, 0x894C, 0x891D, 0x8960, 0x895E,
-};
-static const unsigned short euc_to_utf8_EB[] = {
- 0x8966, 0x8964, 0x896D, 0x896A, 0x896F, 0x8974, 0x8977,
- 0x897E, 0x8983, 0x8988, 0x898A, 0x8993, 0x8998, 0x89A1, 0x89A9,
- 0x89A6, 0x89AC, 0x89AF, 0x89B2, 0x89BA, 0x89BD, 0x89BF, 0x89C0,
- 0x89DA, 0x89DC, 0x89DD, 0x89E7, 0x89F4, 0x89F8, 0x8A03, 0x8A16,
- 0x8A10, 0x8A0C, 0x8A1B, 0x8A1D, 0x8A25, 0x8A36, 0x8A41, 0x8A5B,
- 0x8A52, 0x8A46, 0x8A48, 0x8A7C, 0x8A6D, 0x8A6C, 0x8A62, 0x8A85,
- 0x8A82, 0x8A84, 0x8AA8, 0x8AA1, 0x8A91, 0x8AA5, 0x8AA6, 0x8A9A,
- 0x8AA3, 0x8AC4, 0x8ACD, 0x8AC2, 0x8ADA, 0x8AEB, 0x8AF3, 0x8AE7,
- 0x8AE4, 0x8AF1, 0x8B14, 0x8AE0, 0x8AE2, 0x8AF7, 0x8ADE, 0x8ADB,
- 0x8B0C, 0x8B07, 0x8B1A, 0x8AE1, 0x8B16, 0x8B10, 0x8B17, 0x8B20,
- 0x8B33, 0x97AB, 0x8B26, 0x8B2B, 0x8B3E, 0x8B28, 0x8B41, 0x8B4C,
- 0x8B4F, 0x8B4E, 0x8B49, 0x8B56, 0x8B5B, 0x8B5A, 0x8B6B,
-};
-static const unsigned short euc_to_utf8_EC[] = {
- 0x8B5F, 0x8B6C, 0x8B6F, 0x8B74, 0x8B7D, 0x8B80, 0x8B8C,
- 0x8B8E, 0x8B92, 0x8B93, 0x8B96, 0x8B99, 0x8B9A, 0x8C3A, 0x8C41,
- 0x8C3F, 0x8C48, 0x8C4C, 0x8C4E, 0x8C50, 0x8C55, 0x8C62, 0x8C6C,
- 0x8C78, 0x8C7A, 0x8C82, 0x8C89, 0x8C85, 0x8C8A, 0x8C8D, 0x8C8E,
- 0x8C94, 0x8C7C, 0x8C98, 0x621D, 0x8CAD, 0x8CAA, 0x8CBD, 0x8CB2,
- 0x8CB3, 0x8CAE, 0x8CB6, 0x8CC8, 0x8CC1, 0x8CE4, 0x8CE3, 0x8CDA,
- 0x8CFD, 0x8CFA, 0x8CFB, 0x8D04, 0x8D05, 0x8D0A, 0x8D07, 0x8D0F,
- 0x8D0D, 0x8D10, 0x9F4E, 0x8D13, 0x8CCD, 0x8D14, 0x8D16, 0x8D67,
- 0x8D6D, 0x8D71, 0x8D73, 0x8D81, 0x8D99, 0x8DC2, 0x8DBE, 0x8DBA,
- 0x8DCF, 0x8DDA, 0x8DD6, 0x8DCC, 0x8DDB, 0x8DCB, 0x8DEA, 0x8DEB,
- 0x8DDF, 0x8DE3, 0x8DFC, 0x8E08, 0x8E09, 0x8DFF, 0x8E1D, 0x8E1E,
- 0x8E10, 0x8E1F, 0x8E42, 0x8E35, 0x8E30, 0x8E34, 0x8E4A,
-};
-static const unsigned short euc_to_utf8_ED[] = {
- 0x8E47, 0x8E49, 0x8E4C, 0x8E50, 0x8E48, 0x8E59, 0x8E64,
- 0x8E60, 0x8E2A, 0x8E63, 0x8E55, 0x8E76, 0x8E72, 0x8E7C, 0x8E81,
- 0x8E87, 0x8E85, 0x8E84, 0x8E8B, 0x8E8A, 0x8E93, 0x8E91, 0x8E94,
- 0x8E99, 0x8EAA, 0x8EA1, 0x8EAC, 0x8EB0, 0x8EC6, 0x8EB1, 0x8EBE,
- 0x8EC5, 0x8EC8, 0x8ECB, 0x8EDB, 0x8EE3, 0x8EFC, 0x8EFB, 0x8EEB,
- 0x8EFE, 0x8F0A, 0x8F05, 0x8F15, 0x8F12, 0x8F19, 0x8F13, 0x8F1C,
- 0x8F1F, 0x8F1B, 0x8F0C, 0x8F26, 0x8F33, 0x8F3B, 0x8F39, 0x8F45,
- 0x8F42, 0x8F3E, 0x8F4C, 0x8F49, 0x8F46, 0x8F4E, 0x8F57, 0x8F5C,
- 0x8F62, 0x8F63, 0x8F64, 0x8F9C, 0x8F9F, 0x8FA3, 0x8FAD, 0x8FAF,
- 0x8FB7, 0x8FDA, 0x8FE5, 0x8FE2, 0x8FEA, 0x8FEF, 0x9087, 0x8FF4,
- 0x9005, 0x8FF9, 0x8FFA, 0x9011, 0x9015, 0x9021, 0x900D, 0x901E,
- 0x9016, 0x900B, 0x9027, 0x9036, 0x9035, 0x9039, 0x8FF8,
-};
-static const unsigned short euc_to_utf8_EE[] = {
- 0x904F, 0x9050, 0x9051, 0x9052, 0x900E, 0x9049, 0x903E,
- 0x9056, 0x9058, 0x905E, 0x9068, 0x906F, 0x9076, 0x96A8, 0x9072,
- 0x9082, 0x907D, 0x9081, 0x9080, 0x908A, 0x9089, 0x908F, 0x90A8,
- 0x90AF, 0x90B1, 0x90B5, 0x90E2, 0x90E4, 0x6248, 0x90DB, 0x9102,
- 0x9112, 0x9119, 0x9132, 0x9130, 0x914A, 0x9156, 0x9158, 0x9163,
- 0x9165, 0x9169, 0x9173, 0x9172, 0x918B, 0x9189, 0x9182, 0x91A2,
- 0x91AB, 0x91AF, 0x91AA, 0x91B5, 0x91B4, 0x91BA, 0x91C0, 0x91C1,
- 0x91C9, 0x91CB, 0x91D0, 0x91D6, 0x91DF, 0x91E1, 0x91DB, 0x91FC,
- 0x91F5, 0x91F6, 0x921E, 0x91FF, 0x9214, 0x922C, 0x9215, 0x9211,
- 0x925E, 0x9257, 0x9245, 0x9249, 0x9264, 0x9248, 0x9295, 0x923F,
- 0x924B, 0x9250, 0x929C, 0x9296, 0x9293, 0x929B, 0x925A, 0x92CF,
- 0x92B9, 0x92B7, 0x92E9, 0x930F, 0x92FA, 0x9344, 0x932E,
-};
-static const unsigned short euc_to_utf8_EF[] = {
- 0x9319, 0x9322, 0x931A, 0x9323, 0x933A, 0x9335, 0x933B,
- 0x935C, 0x9360, 0x937C, 0x936E, 0x9356, 0x93B0, 0x93AC, 0x93AD,
- 0x9394, 0x93B9, 0x93D6, 0x93D7, 0x93E8, 0x93E5, 0x93D8, 0x93C3,
- 0x93DD, 0x93D0, 0x93C8, 0x93E4, 0x941A, 0x9414, 0x9413, 0x9403,
- 0x9407, 0x9410, 0x9436, 0x942B, 0x9435, 0x9421, 0x943A, 0x9441,
- 0x9452, 0x9444, 0x945B, 0x9460, 0x9462, 0x945E, 0x946A, 0x9229,
- 0x9470, 0x9475, 0x9477, 0x947D, 0x945A, 0x947C, 0x947E, 0x9481,
- 0x947F, 0x9582, 0x9587, 0x958A, 0x9594, 0x9596, 0x9598, 0x9599,
- 0x95A0, 0x95A8, 0x95A7, 0x95AD, 0x95BC, 0x95BB, 0x95B9, 0x95BE,
- 0x95CA, 0x6FF6, 0x95C3, 0x95CD, 0x95CC, 0x95D5, 0x95D4, 0x95D6,
- 0x95DC, 0x95E1, 0x95E5, 0x95E2, 0x9621, 0x9628, 0x962E, 0x962F,
- 0x9642, 0x964C, 0x964F, 0x964B, 0x9677, 0x965C, 0x965E,
-};
-static const unsigned short euc_to_utf8_F0[] = {
- 0x965D, 0x965F, 0x9666, 0x9672, 0x966C, 0x968D, 0x9698,
- 0x9695, 0x9697, 0x96AA, 0x96A7, 0x96B1, 0x96B2, 0x96B0, 0x96B4,
- 0x96B6, 0x96B8, 0x96B9, 0x96CE, 0x96CB, 0x96C9, 0x96CD, 0x894D,
- 0x96DC, 0x970D, 0x96D5, 0x96F9, 0x9704, 0x9706, 0x9708, 0x9713,
- 0x970E, 0x9711, 0x970F, 0x9716, 0x9719, 0x9724, 0x972A, 0x9730,
- 0x9739, 0x973D, 0x973E, 0x9744, 0x9746, 0x9748, 0x9742, 0x9749,
- 0x975C, 0x9760, 0x9764, 0x9766, 0x9768, 0x52D2, 0x976B, 0x9771,
- 0x9779, 0x9785, 0x977C, 0x9781, 0x977A, 0x9786, 0x978B, 0x978F,
- 0x9790, 0x979C, 0x97A8, 0x97A6, 0x97A3, 0x97B3, 0x97B4, 0x97C3,
- 0x97C6, 0x97C8, 0x97CB, 0x97DC, 0x97ED, 0x9F4F, 0x97F2, 0x7ADF,
- 0x97F6, 0x97F5, 0x980F, 0x980C, 0x9838, 0x9824, 0x9821, 0x9837,
- 0x983D, 0x9846, 0x984F, 0x984B, 0x986B, 0x986F, 0x9870,
-};
-static const unsigned short euc_to_utf8_F1[] = {
- 0x9871, 0x9874, 0x9873, 0x98AA, 0x98AF, 0x98B1, 0x98B6,
- 0x98C4, 0x98C3, 0x98C6, 0x98E9, 0x98EB, 0x9903, 0x9909, 0x9912,
- 0x9914, 0x9918, 0x9921, 0x991D, 0x991E, 0x9924, 0x9920, 0x992C,
- 0x992E, 0x993D, 0x993E, 0x9942, 0x9949, 0x9945, 0x9950, 0x994B,
- 0x9951, 0x9952, 0x994C, 0x9955, 0x9997, 0x9998, 0x99A5, 0x99AD,
- 0x99AE, 0x99BC, 0x99DF, 0x99DB, 0x99DD, 0x99D8, 0x99D1, 0x99ED,
- 0x99EE, 0x99F1, 0x99F2, 0x99FB, 0x99F8, 0x9A01, 0x9A0F, 0x9A05,
- 0x99E2, 0x9A19, 0x9A2B, 0x9A37, 0x9A45, 0x9A42, 0x9A40, 0x9A43,
- 0x9A3E, 0x9A55, 0x9A4D, 0x9A5B, 0x9A57, 0x9A5F, 0x9A62, 0x9A65,
- 0x9A64, 0x9A69, 0x9A6B, 0x9A6A, 0x9AAD, 0x9AB0, 0x9ABC, 0x9AC0,
- 0x9ACF, 0x9AD1, 0x9AD3, 0x9AD4, 0x9ADE, 0x9ADF, 0x9AE2, 0x9AE3,
- 0x9AE6, 0x9AEF, 0x9AEB, 0x9AEE, 0x9AF4, 0x9AF1, 0x9AF7,
-};
-static const unsigned short euc_to_utf8_F2[] = {
- 0x9AFB, 0x9B06, 0x9B18, 0x9B1A, 0x9B1F, 0x9B22, 0x9B23,
- 0x9B25, 0x9B27, 0x9B28, 0x9B29, 0x9B2A, 0x9B2E, 0x9B2F, 0x9B32,
- 0x9B44, 0x9B43, 0x9B4F, 0x9B4D, 0x9B4E, 0x9B51, 0x9B58, 0x9B74,
- 0x9B93, 0x9B83, 0x9B91, 0x9B96, 0x9B97, 0x9B9F, 0x9BA0, 0x9BA8,
- 0x9BB4, 0x9BC0, 0x9BCA, 0x9BB9, 0x9BC6, 0x9BCF, 0x9BD1, 0x9BD2,
- 0x9BE3, 0x9BE2, 0x9BE4, 0x9BD4, 0x9BE1, 0x9C3A, 0x9BF2, 0x9BF1,
- 0x9BF0, 0x9C15, 0x9C14, 0x9C09, 0x9C13, 0x9C0C, 0x9C06, 0x9C08,
- 0x9C12, 0x9C0A, 0x9C04, 0x9C2E, 0x9C1B, 0x9C25, 0x9C24, 0x9C21,
- 0x9C30, 0x9C47, 0x9C32, 0x9C46, 0x9C3E, 0x9C5A, 0x9C60, 0x9C67,
- 0x9C76, 0x9C78, 0x9CE7, 0x9CEC, 0x9CF0, 0x9D09, 0x9D08, 0x9CEB,
- 0x9D03, 0x9D06, 0x9D2A, 0x9D26, 0x9DAF, 0x9D23, 0x9D1F, 0x9D44,
- 0x9D15, 0x9D12, 0x9D41, 0x9D3F, 0x9D3E, 0x9D46, 0x9D48,
-};
-static const unsigned short euc_to_utf8_F3[] = {
- 0x9D5D, 0x9D5E, 0x9D64, 0x9D51, 0x9D50, 0x9D59, 0x9D72,
- 0x9D89, 0x9D87, 0x9DAB, 0x9D6F, 0x9D7A, 0x9D9A, 0x9DA4, 0x9DA9,
- 0x9DB2, 0x9DC4, 0x9DC1, 0x9DBB, 0x9DB8, 0x9DBA, 0x9DC6, 0x9DCF,
- 0x9DC2, 0x9DD9, 0x9DD3, 0x9DF8, 0x9DE6, 0x9DED, 0x9DEF, 0x9DFD,
- 0x9E1A, 0x9E1B, 0x9E1E, 0x9E75, 0x9E79, 0x9E7D, 0x9E81, 0x9E88,
- 0x9E8B, 0x9E8C, 0x9E92, 0x9E95, 0x9E91, 0x9E9D, 0x9EA5, 0x9EA9,
- 0x9EB8, 0x9EAA, 0x9EAD, 0x9761, 0x9ECC, 0x9ECE, 0x9ECF, 0x9ED0,
- 0x9ED4, 0x9EDC, 0x9EDE, 0x9EDD, 0x9EE0, 0x9EE5, 0x9EE8, 0x9EEF,
- 0x9EF4, 0x9EF6, 0x9EF7, 0x9EF9, 0x9EFB, 0x9EFC, 0x9EFD, 0x9F07,
- 0x9F08, 0x76B7, 0x9F15, 0x9F21, 0x9F2C, 0x9F3E, 0x9F4A, 0x9F52,
- 0x9F54, 0x9F63, 0x9F5F, 0x9F60, 0x9F61, 0x9F66, 0x9F67, 0x9F6C,
- 0x9F6A, 0x9F77, 0x9F72, 0x9F76, 0x9F95, 0x9F9C, 0x9FA0,
-};
-static const unsigned short euc_to_utf8_F4[] = {
- 0x582F, 0x69C7, 0x9059, 0x7464, 0x51DC, 0x7199, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_F4_x0213[] = {
- 0x582F, 0x69C7, 0x9059, 0x7464, 0x51DC, 0x7199, 0x5653,
- 0x5DE2, 0x5E14, 0x5E18, 0x5E58, 0x5E5E, 0x5EBE, 0xF928, 0x5ECB,
- 0x5EF9, 0x5F00, 0x5F02, 0x5F07, 0x5F1D, 0x5F23, 0x5F34, 0x5F36,
- 0x5F3D, 0x5F40, 0x5F45, 0x5F54, 0x5F58, 0x5F64, 0x5F67, 0x5F7D,
- 0x5F89, 0x5F9C, 0x5FA7, 0x5FAF, 0x5FB5, 0x5FB7, 0x5FC9, 0x5FDE,
- 0x5FE1, 0x5FE9, 0x600D, 0x6014, 0x6018, 0x6033, 0x6035, 0x6047,
- 0xFA3D, 0x609D, 0x609E, 0x60CB, 0x60D4, 0x60D5, 0x60DD, 0x60F8,
- 0x611C, 0x612B, 0x6130, 0x6137, 0xFA3E, 0x618D, 0xFA3F, 0x61BC,
- 0x61B9, 0xFA40, 0x6222, 0x623E, 0x6243, 0x6256, 0x625A, 0x626F,
- 0x6285, 0x62C4, 0x62D6, 0x62FC, 0x630A, 0x6318, 0x6339, 0x6343,
- 0x6365, 0x637C, 0x63E5, 0x63ED, 0x63F5, 0x6410, 0x6414, 0x6422,
- 0x6479, 0x6451, 0x6460, 0x646D, 0x64CE, 0x64BE, 0x64BF,
-};
-static const unsigned short euc_to_utf8_F5[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFE33, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFE31, 0, 0,
- 0, 0, 0, 0, 0, 0xFE30, 0, 0,
- 0, 0, 0xFE35, 0xFE36, 0xFE39, 0xFE3A, 0, 0,
- 0xFE37, 0xFE38, 0xFE3F, 0xFE40, 0xFE3D, 0xFE3E, 0xFE41, 0xFE42,
- 0xFE43, 0xFE44, 0xFE3B, 0xFE3C, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_F5_x0213[] = {
- 0x64C4, 0x64CA, 0x64D0, 0x64F7, 0x64FB, 0x6522, 0x6529,
- 0xFA41, 0x6567, 0x659D, 0xFA42, 0x6600, 0x6609, 0x6615, 0x661E,
- 0x663A, 0x6622, 0x6624, 0x662B, 0x6630, 0x6631, 0x6633, 0x66FB,
- 0x6648, 0x664C, 0xD84C /*0xDDC4*/, 0x6659, 0x665A, 0x6661, 0x6665, 0x6673,
- 0x6677, 0x6678, 0x668D, 0xFA43, 0x66A0, 0x66B2, 0x66BB, 0x66C6,
- 0x66C8, 0x3B22, 0x66DB, 0x66E8, 0x66FA, 0x6713, 0xF929, 0x6733,
- 0x6766, 0x6747, 0x6748, 0x677B, 0x6781, 0x6793, 0x6798, 0x679B,
- 0x67BB, 0x67F9, 0x67C0, 0x67D7, 0x67FC, 0x6801, 0x6852, 0x681D,
- 0x682C, 0x6831, 0x685B, 0x6872, 0x6875, 0xFA44, 0x68A3, 0x68A5,
- 0x68B2, 0x68C8, 0x68D0, 0x68E8, 0x68ED, 0x68F0, 0x68F1, 0x68FC,
- 0x690A, 0x6949, 0xD84D /*0xDDC4*/, 0x6935, 0x6942, 0x6957, 0x6963, 0x6964,
- 0x6968, 0x6980, 0xFA14, 0x69A5, 0x69AD, 0x69CF, 0x3BB6,
-};
-static const unsigned short euc_to_utf8_F6_x0213[] = {
- 0x3BC3, 0x69E2, 0x69E9, 0x69EA, 0x69F5, 0x69F6, 0x6A0F,
- 0x6A15, 0xD84D /*0xDF3F*/, 0x6A3B, 0x6A3E, 0x6A45, 0x6A50, 0x6A56, 0x6A5B,
- 0x6A6B, 0x6A73, 0xD84D /*0xDF63*/, 0x6A89, 0x6A94, 0x6A9D, 0x6A9E, 0x6AA5,
- 0x6AE4, 0x6AE7, 0x3C0F, 0xF91D, 0x6B1B, 0x6B1E, 0x6B2C, 0x6B35,
- 0x6B46, 0x6B56, 0x6B60, 0x6B65, 0x6B67, 0x6B77, 0x6B82, 0x6BA9,
- 0x6BAD, 0xF970, 0x6BCF, 0x6BD6, 0x6BD7, 0x6BFF, 0x6C05, 0x6C10,
- 0x6C33, 0x6C59, 0x6C5C, 0x6CAA, 0x6C74, 0x6C76, 0x6C85, 0x6C86,
- 0x6C98, 0x6C9C, 0x6CFB, 0x6CC6, 0x6CD4, 0x6CE0, 0x6CEB, 0x6CEE,
- 0xD84F /*0xDCFE*/, 0x6D04, 0x6D0E, 0x6D2E, 0x6D31, 0x6D39, 0x6D3F, 0x6D58,
- 0x6D65, 0xFA45, 0x6D82, 0x6D87, 0x6D89, 0x6D94, 0x6DAA, 0x6DAC,
- 0x6DBF, 0x6DC4, 0x6DD6, 0x6DDA, 0x6DDB, 0x6DDD, 0x6DFC, 0xFA46,
- 0x6E34, 0x6E44, 0x6E5C, 0x6E5E, 0x6EAB, 0x6EB1, 0x6EC1,
-};
-static const unsigned short euc_to_utf8_F7_x0213[] = {
- 0x6EC7, 0x6ECE, 0x6F10, 0x6F1A, 0xFA47, 0x6F2A, 0x6F2F,
- 0x6F33, 0x6F51, 0x6F59, 0x6F5E, 0x6F61, 0x6F62, 0x6F7E, 0x6F88,
- 0x6F8C, 0x6F8D, 0x6F94, 0x6FA0, 0x6FA7, 0x6FB6, 0x6FBC, 0x6FC7,
- 0x6FCA, 0x6FF9, 0x6FF0, 0x6FF5, 0x7005, 0x7006, 0x7028, 0x704A,
- 0x705D, 0x705E, 0x704E, 0x7064, 0x7075, 0x7085, 0x70A4, 0x70AB,
- 0x70B7, 0x70D4, 0x70D8, 0x70E4, 0x710F, 0x712B, 0x711E, 0x7120,
- 0x712E, 0x7130, 0x7146, 0x7147, 0x7151, 0xFA48, 0x7152, 0x715C,
- 0x7160, 0x7168, 0xFA15, 0x7185, 0x7187, 0x7192, 0x71C1, 0x71BA,
- 0x71C4, 0x71FE, 0x7200, 0x7215, 0x7255, 0x7256, 0x3E3F, 0x728D,
- 0x729B, 0x72BE, 0x72C0, 0x72FB, 0xD851 /*0xDFF1*/, 0x7327, 0x7328, 0xFA16,
- 0x7350, 0x7366, 0x737C, 0x7395, 0x739F, 0x73A0, 0x73A2, 0x73A6,
- 0x73AB, 0x73C9, 0x73CF, 0x73D6, 0x73D9, 0x73E3, 0x73E9,
-};
-static const unsigned short euc_to_utf8_F8_x0213[] = {
- 0x7407, 0x740A, 0x741A, 0x741B, 0xFA4A, 0x7426, 0x7428,
- 0x742A, 0x742B, 0x742C, 0x742E, 0x742F, 0x7430, 0x7444, 0x7446,
- 0x7447, 0x744B, 0x7457, 0x7462, 0x746B, 0x746D, 0x7486, 0x7487,
- 0x7489, 0x7498, 0x749C, 0x749F, 0x74A3, 0x7490, 0x74A6, 0x74A8,
- 0x74A9, 0x74B5, 0x74BF, 0x74C8, 0x74C9, 0x74DA, 0x74FF, 0x7501,
- 0x7517, 0x752F, 0x756F, 0x7579, 0x7592, 0x3F72, 0x75CE, 0x75E4,
- 0x7600, 0x7602, 0x7608, 0x7615, 0x7616, 0x7619, 0x761E, 0x762D,
- 0x7635, 0x7643, 0x764B, 0x7664, 0x7665, 0x766D, 0x766F, 0x7671,
- 0x7681, 0x769B, 0x769D, 0x769E, 0x76A6, 0x76AA, 0x76B6, 0x76C5,
- 0x76CC, 0x76CE, 0x76D4, 0x76E6, 0x76F1, 0x76FC, 0x770A, 0x7719,
- 0x7734, 0x7736, 0x7746, 0x774D, 0x774E, 0x775C, 0x775F, 0x7762,
- 0x777A, 0x7780, 0x7794, 0x77AA, 0x77E0, 0x782D, 0xD855 /*0xDC8E*/,
-};
-static const unsigned short euc_to_utf8_F9[] = {
- 0x7E8A, 0x891C, 0x9348, 0x9288, 0x84DC, 0x4FC9, 0x70BB,
- 0x6631, 0x68C8, 0x92F9, 0x66FB, 0x5F45, 0x4E28, 0x4EE1, 0x4EFC,
- 0x4F00, 0x4F03, 0x4F39, 0x4F56, 0x4F92, 0x4F8A, 0x4F9A, 0x4F94,
- 0x4FCD, 0x5040, 0x5022, 0x4FFF, 0x501E, 0x5046, 0x5070, 0x5042,
- 0x5094, 0x50F4, 0x50D8, 0x514A, 0x5164, 0x519D, 0x51BE, 0x51EC,
- 0x5215, 0x529C, 0x52A6, 0x52C0, 0x52DB, 0x5300, 0x5307, 0x5324,
- 0x5372, 0x5393, 0x53B2, 0x53DD, 0xFA0E, 0x549C, 0x548A, 0x54A9,
- 0x54FF, 0x5586, 0x5759, 0x5765, 0x57AC, 0x57C8, 0x57C7, 0xFA0F,
- 0xFA10, 0x589E, 0x58B2, 0x590B, 0x5953, 0x595B, 0x595D, 0x5963,
- 0x59A4, 0x59BA, 0x5B56, 0x5BC0, 0x752F, 0x5BD8, 0x5BEC, 0x5C1E,
- 0x5CA6, 0x5CBA, 0x5CF5, 0x5D27, 0x5D53, 0xFA11, 0x5D42, 0x5D6D,
- 0x5DB8, 0x5DB9, 0x5DD0, 0x5F21, 0x5F34, 0x5F67, 0x5FB7,
-};
-static const unsigned short euc_to_utf8_F9_x0213[] = {
- 0x7843, 0x784E, 0x784F, 0x7851, 0x7868, 0x786E, 0xFA4B,
- 0x78B0, 0xD855 /*0xDD0E*/, 0x78AD, 0x78E4, 0x78F2, 0x7900, 0x78F7, 0x791C,
- 0x792E, 0x7931, 0x7934, 0xFA4C, 0xFA4D, 0x7945, 0x7946, 0xFA4E,
- 0xFA4F, 0xFA50, 0x795C, 0xFA51, 0xFA19, 0xFA1A, 0x7979, 0xFA52,
- 0xFA53, 0xFA1B, 0x7998, 0x79B1, 0x79B8, 0x79C8, 0x79CA, 0xD855 /*0xDF71*/,
- 0x79D4, 0x79DE, 0x79EB, 0x79ED, 0x7A03, 0xFA54, 0x7A39, 0x7A5D,
- 0x7A6D, 0xFA55, 0x7A85, 0x7AA0, 0xD856 /*0xDDC4*/, 0x7AB3, 0x7ABB, 0x7ACE,
- 0x7AEB, 0x7AFD, 0x7B12, 0x7B2D, 0x7B3B, 0x7B47, 0x7B4E, 0x7B60,
- 0x7B6D, 0x7B6F, 0x7B72, 0x7B9E, 0xFA56, 0x7BD7, 0x7BD9, 0x7C01,
- 0x7C31, 0x7C1E, 0x7C20, 0x7C33, 0x7C36, 0x4264, 0xD857 /*0xDDA1*/, 0x7C59,
- 0x7C6D, 0x7C79, 0x7C8F, 0x7C94, 0x7CA0, 0x7CBC, 0x7CD5, 0x7CD9,
- 0x7CDD, 0x7D07, 0x7D08, 0x7D13, 0x7D1D, 0x7D23, 0x7D31,
-};
-static const unsigned short euc_to_utf8_FA[] = {
- 0x5FDE, 0x605D, 0x6085, 0x608A, 0x60DE, 0x60D5, 0x6120,
- 0x60F2, 0x6111, 0x6137, 0x6130, 0x6198, 0x6213, 0x62A6, 0x63F5,
- 0x6460, 0x649D, 0x64CE, 0x654E, 0x6600, 0x6615, 0x663B, 0x6609,
- 0x662E, 0x661E, 0x6624, 0x6665, 0x6657, 0x6659, 0xFA12, 0x6673,
- 0x6699, 0x66A0, 0x66B2, 0x66BF, 0x66FA, 0x670E, 0xF929, 0x6766,
- 0x67BB, 0x6852, 0x67C0, 0x6801, 0x6844, 0x68CF, 0xFA13, 0x6968,
- 0xFA14, 0x6998, 0x69E2, 0x6A30, 0x6A6B, 0x6A46, 0x6A73, 0x6A7E,
- 0x6AE2, 0x6AE4, 0x6BD6, 0x6C3F, 0x6C5C, 0x6C86, 0x6C6F, 0x6CDA,
- 0x6D04, 0x6D87, 0x6D6F, 0x6D96, 0x6DAC, 0x6DCF, 0x6DF8, 0x6DF2,
- 0x6DFC, 0x6E39, 0x6E5C, 0x6E27, 0x6E3C, 0x6EBF, 0x6F88, 0x6FB5,
- 0x6FF5, 0x7005, 0x7007, 0x7028, 0x7085, 0x70AB, 0x710F, 0x7104,
- 0x715C, 0x7146, 0x7147, 0xFA15, 0x71C1, 0x71FE, 0x72B1,
-};
-static const unsigned short euc_to_utf8_FA_x0213[] = {
- 0x7D41, 0x7D48, 0x7D53, 0x7D5C, 0x7D7A, 0x7D83, 0x7D8B,
- 0x7DA0, 0x7DA6, 0x7DC2, 0x7DCC, 0x7DD6, 0x7DE3, 0xFA57, 0x7E28,
- 0x7E08, 0x7E11, 0x7E15, 0xFA59, 0x7E47, 0x7E52, 0x7E61, 0x7E8A,
- 0x7E8D, 0x7F47, 0xFA5A, 0x7F91, 0x7F97, 0x7FBF, 0x7FCE, 0x7FDB,
- 0x7FDF, 0x7FEC, 0x7FEE, 0x7FFA, 0xFA5B, 0x8014, 0x8026, 0x8035,
- 0x8037, 0x803C, 0x80CA, 0x80D7, 0x80E0, 0x80F3, 0x8118, 0x814A,
- 0x8160, 0x8167, 0x8168, 0x816D, 0x81BB, 0x81CA, 0x81CF, 0x81D7,
- 0xFA5C, 0x4453, 0x445B, 0x8260, 0x8274, 0xD85A /*0xDEFF*/, 0x828E, 0x82A1,
- 0x82A3, 0x82A4, 0x82A9, 0x82AE, 0x82B7, 0x82BE, 0x82BF, 0x82C6,
- 0x82D5, 0x82FD, 0x82FE, 0x8300, 0x8301, 0x8362, 0x8322, 0x832D,
- 0x833A, 0x8343, 0x8347, 0x8351, 0x8355, 0x837D, 0x8386, 0x8392,
- 0x8398, 0x83A7, 0x83A9, 0x83BF, 0x83C0, 0x83C7, 0x83CF,
-};
-static const unsigned short euc_to_utf8_FB[] = {
- 0x72BE, 0x7324, 0xFA16, 0x7377, 0x73BD, 0x73C9, 0x73D6,
- 0x73E3, 0x73D2, 0x7407, 0x73F5, 0x7426, 0x742A, 0x7429, 0x742E,
- 0x7462, 0x7489, 0x749F, 0x7501, 0x756F, 0x7682, 0x769C, 0x769E,
- 0x769B, 0x76A6, 0xFA17, 0x7746, 0x52AF, 0x7821, 0x784E, 0x7864,
- 0x787A, 0x7930, 0xFA18, 0xFA19, 0xFA1A, 0x7994, 0xFA1B, 0x799B,
- 0x7AD1, 0x7AE7, 0xFA1C, 0x7AEB, 0x7B9E, 0xFA1D, 0x7D48, 0x7D5C,
- 0x7DB7, 0x7DA0, 0x7DD6, 0x7E52, 0x7F47, 0x7FA1, 0xFA1E, 0x8301,
- 0x8362, 0x837F, 0x83C7, 0x83F6, 0x8448, 0x84B4, 0x8553, 0x8559,
- 0x856B, 0xFA1F, 0x85B0, 0xFA20, 0xFA21, 0x8807, 0x88F5, 0x8A12,
- 0x8A37, 0x8A79, 0x8AA7, 0x8ABE, 0x8ADF, 0xFA22, 0x8AF6, 0x8B53,
- 0x8B7F, 0x8CF0, 0x8CF4, 0x8D12, 0x8D76, 0xFA23, 0x8ECF, 0xFA24,
- 0xFA25, 0x9067, 0x90DE, 0xFA26, 0x9115, 0x9127, 0x91DA,
-};
-static const unsigned short euc_to_utf8_FB_x0213[] = {
- 0x83D1, 0x83E1, 0x83EA, 0x8401, 0x8406, 0x840A, 0xFA5F,
- 0x8448, 0x845F, 0x8470, 0x8473, 0x8485, 0x849E, 0x84AF, 0x84B4,
- 0x84BA, 0x84C0, 0x84C2, 0xD85B /*0xDE40*/, 0x8532, 0x851E, 0x8523, 0x852F,
- 0x8559, 0x8564, 0xFA1F, 0x85AD, 0x857A, 0x858C, 0x858F, 0x85A2,
- 0x85B0, 0x85CB, 0x85CE, 0x85ED, 0x8612, 0x85FF, 0x8604, 0x8605,
- 0x8610, 0xD85C /*0xDCF4*/, 0x8618, 0x8629, 0x8638, 0x8657, 0x865B, 0xF936,
- 0x8662, 0x459D, 0x866C, 0x8675, 0x8698, 0x86B8, 0x86FA, 0x86FC,
- 0x86FD, 0x870B, 0x8771, 0x8787, 0x8788, 0x87AC, 0x87AD, 0x87B5,
- 0x45EA, 0x87D6, 0x87EC, 0x8806, 0x880A, 0x8810, 0x8814, 0x881F,
- 0x8898, 0x88AA, 0x88CA, 0x88CE, 0xD85D /*0xDE84*/, 0x88F5, 0x891C, 0xFA60,
- 0x8918, 0x8919, 0x891A, 0x8927, 0x8930, 0x8932, 0x8939, 0x8940,
- 0x8994, 0xFA61, 0x89D4, 0x89E5, 0x89F6, 0x8A12, 0x8A15,
-};
-static const unsigned short euc_to_utf8_FC[] = {
- 0x91D7, 0x91DE, 0x91ED, 0x91EE, 0x91E4, 0x91E5, 0x9206,
- 0x9210, 0x920A, 0x923A, 0x9240, 0x923C, 0x924E, 0x9259, 0x9251,
- 0x9239, 0x9267, 0x92A7, 0x9277, 0x9278, 0x92E7, 0x92D7, 0x92D9,
- 0x92D0, 0xFA27, 0x92D5, 0x92E0, 0x92D3, 0x9325, 0x9321, 0x92FB,
- 0xFA28, 0x931E, 0x92FF, 0x931D, 0x9302, 0x9370, 0x9357, 0x93A4,
- 0x93C6, 0x93DE, 0x93F8, 0x9431, 0x9445, 0x9448, 0x9592, 0xF9DC,
- 0xFA29, 0x969D, 0x96AF, 0x9733, 0x973B, 0x9743, 0x974D, 0x974F,
- 0x9751, 0x9755, 0x9857, 0x9865, 0xFA2A, 0xFA2B, 0x9927, 0xFA2C,
- 0x999E, 0x9A4E, 0x9AD9, 0x9ADC, 0x9B75, 0x9B72, 0x9B8F, 0x9BB1,
- 0x9BBB, 0x9C00, 0x9D70, 0x9D6B, 0xFA2D, 0x9E19, 0x9ED1, 0,
- 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
- 0x2177, 0x2178, 0x2179, 0xFFE2, 0x00A6, 0xFF07, 0xFF02,
-};
-
-/* Microsoft UCS Mapping Compatible */
-static const unsigned short euc_to_utf8_FC_ms[] = {
- 0x91D7, 0x91DE, 0x91ED, 0x91EE, 0x91E4, 0x91E5, 0x9206,
- 0x9210, 0x920A, 0x923A, 0x9240, 0x923C, 0x924E, 0x9259, 0x9251,
- 0x9239, 0x9267, 0x92A7, 0x9277, 0x9278, 0x92E7, 0x92D7, 0x92D9,
- 0x92D0, 0xFA27, 0x92D5, 0x92E0, 0x92D3, 0x9325, 0x9321, 0x92FB,
- 0xFA28, 0x931E, 0x92FF, 0x931D, 0x9302, 0x9370, 0x9357, 0x93A4,
- 0x93C6, 0x93DE, 0x93F8, 0x9431, 0x9445, 0x9448, 0x9592, 0xF9DC,
- 0xFA29, 0x969D, 0x96AF, 0x9733, 0x973B, 0x9743, 0x974D, 0x974F,
- 0x9751, 0x9755, 0x9857, 0x9865, 0xFA2A, 0xFA2B, 0x9927, 0xFA2C,
- 0x999E, 0x9A4E, 0x9AD9, 0x9ADC, 0x9B75, 0x9B72, 0x9B8F, 0x9BB1,
- 0x9BBB, 0x9C00, 0x9D70, 0x9D6B, 0xFA2D, 0x9E19, 0x9ED1, 0,
- 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
- 0x2177, 0x2178, 0x2179, 0xFFE2, 0xFFE4, 0xFF07, 0xFF02,
-};
-static const unsigned short euc_to_utf8_FC_x0213[] = {
- 0x8A22, 0x8A37, 0x8A47, 0x8A4E, 0x8A5D, 0x8A61, 0x8A75,
- 0x8A79, 0x8AA7, 0x8AD0, 0x8ADF, 0x8AF4, 0x8AF6, 0xFA22, 0xFA62,
- 0xFA63, 0x8B46, 0x8B54, 0x8B59, 0x8B69, 0x8B9D, 0x8C49, 0x8C68,
- 0xFA64, 0x8CE1, 0x8CF4, 0x8CF8, 0x8CFE, 0xFA65, 0x8D12, 0x8D1B,
- 0x8DAF, 0x8DCE, 0x8DD1, 0x8DD7, 0x8E20, 0x8E23, 0x8E3D, 0x8E70,
- 0x8E7B, 0xD860 /*0xDE77*/, 0x8EC0, 0x4844, 0x8EFA, 0x8F1E, 0x8F2D, 0x8F36,
- 0x8F54, 0xD860 /*0xDFCD*/, 0x8FA6, 0x8FB5, 0x8FE4, 0x8FE8, 0x8FEE, 0x9008,
- 0x902D, 0xFA67, 0x9088, 0x9095, 0x9097, 0x9099, 0x909B, 0x90A2,
- 0x90B3, 0x90BE, 0x90C4, 0x90C5, 0x90C7, 0x90D7, 0x90DD, 0x90DE,
- 0x90EF, 0x90F4, 0xFA26, 0x9114, 0x9115, 0x9116, 0x9122, 0x9123,
- 0x9127, 0x912F, 0x9131, 0x9134, 0x913D, 0x9148, 0x915B, 0x9183,
- 0x919E, 0x91AC, 0x91B1, 0x91BC, 0x91D7, 0x91FB, 0x91E4,
-};
-static const unsigned short euc_to_utf8_FD_x0213[] = {
- 0x91E5, 0x91ED, 0x91F1, 0x9207, 0x9210, 0x9238, 0x9239,
- 0x923A, 0x923C, 0x9240, 0x9243, 0x924F, 0x9278, 0x9288, 0x92C2,
- 0x92CB, 0x92CC, 0x92D3, 0x92E0, 0x92FF, 0x9304, 0x931F, 0x9321,
- 0x9325, 0x9348, 0x9349, 0x934A, 0x9364, 0x9365, 0x936A, 0x9370,
- 0x939B, 0x93A3, 0x93BA, 0x93C6, 0x93DE, 0x93DF, 0x9404, 0x93FD,
- 0x9433, 0x944A, 0x9463, 0x946B, 0x9471, 0x9472, 0x958E, 0x959F,
- 0x95A6, 0x95A9, 0x95AC, 0x95B6, 0x95BD, 0x95CB, 0x95D0, 0x95D3,
- 0x49B0, 0x95DA, 0x95DE, 0x9658, 0x9684, 0xF9DC, 0x969D, 0x96A4,
- 0x96A5, 0x96D2, 0x96DE, 0xFA68, 0x96E9, 0x96EF, 0x9733, 0x973B,
- 0x974D, 0x974E, 0x974F, 0x975A, 0x976E, 0x9773, 0x9795, 0x97AE,
- 0x97BA, 0x97C1, 0x97C9, 0x97DE, 0x97DB, 0x97F4, 0xFA69, 0x980A,
- 0x981E, 0x982B, 0x9830, 0xFA6A, 0x9852, 0x9853, 0x9856,
-};
-static const unsigned short euc_to_utf8_FE_x0213[] = {
- 0x9857, 0x9859, 0x985A, 0xF9D0, 0x9865, 0x986C, 0x98BA,
- 0x98C8, 0x98E7, 0x9958, 0x999E, 0x9A02, 0x9A03, 0x9A24, 0x9A2D,
- 0x9A2E, 0x9A38, 0x9A4A, 0x9A4E, 0x9A52, 0x9AB6, 0x9AC1, 0x9AC3,
- 0x9ACE, 0x9AD6, 0x9AF9, 0x9B02, 0x9B08, 0x9B20, 0x4C17, 0x9B2D,
- 0x9B5E, 0x9B79, 0x9B66, 0x9B72, 0x9B75, 0x9B84, 0x9B8A, 0x9B8F,
- 0x9B9E, 0x9BA7, 0x9BC1, 0x9BCE, 0x9BE5, 0x9BF8, 0x9BFD, 0x9C00,
- 0x9C23, 0x9C41, 0x9C4F, 0x9C50, 0x9C53, 0x9C63, 0x9C65, 0x9C77,
- 0x9D1D, 0x9D1E, 0x9D43, 0x9D47, 0x9D52, 0x9D63, 0x9D70, 0x9D7C,
- 0x9D8A, 0x9D96, 0x9DC0, 0x9DAC, 0x9DBC, 0x9DD7, 0xD868 /*0xDD90*/, 0x9DE7,
- 0x9E07, 0x9E15, 0x9E7C, 0x9E9E, 0x9EA4, 0x9EAC, 0x9EAF, 0x9EB4,
- 0x9EB5, 0x9EC3, 0x9ED1, 0x9F10, 0x9F39, 0x9F57, 0x9F90, 0x9F94,
- 0x9F97, 0x9FA2, 0x59F8, 0x5C5B, 0x5E77, 0x7626, 0x7E6B,
-};
-
-static const unsigned short euc_to_utf8_8FA1_x0213[] = {
- 0xD840 /*0xDC89*/, 0x4E02, 0x4E0F, 0x4E12, 0x4E29, 0x4E2B, 0x4E2E,
- 0x4E40, 0x4E47, 0x4E48, 0xD840 /*0xDCA2*/, 0x4E51, 0x3406, 0xD840 /*0xDCA4*/, 0x4E5A,
- 0x4E69, 0x4E9D, 0x342C, 0x342E, 0x4EB9, 0x4EBB, 0xD840 /*0xDDA2*/, 0x4EBC,
- 0x4EC3, 0x4EC8, 0x4ED0, 0x4EEB, 0x4EDA, 0x4EF1, 0x4EF5, 0x4F00,
- 0x4F16, 0x4F64, 0x4F37, 0x4F3E, 0x4F54, 0x4F58, 0xD840 /*0xDE13*/, 0x4F77,
- 0x4F78, 0x4F7A, 0x4F7D, 0x4F82, 0x4F85, 0x4F92, 0x4F9A, 0x4FE6,
- 0x4FB2, 0x4FBE, 0x4FC5, 0x4FCB, 0x4FCF, 0x4FD2, 0x346A, 0x4FF2,
- 0x5000, 0x5010, 0x5013, 0x501C, 0x501E, 0x5022, 0x3468, 0x5042,
- 0x5046, 0x504E, 0x5053, 0x5057, 0x5063, 0x5066, 0x506A, 0x5070,
- 0x50A3, 0x5088, 0x5092, 0x5093, 0x5095, 0x5096, 0x509C, 0x50AA,
- 0xD840 /*0xDF2B*/, 0x50B1, 0x50BA, 0x50BB, 0x50C4, 0x50C7, 0x50F3, 0xD840 /*0xDF81*/,
- 0x50CE, 0xD840 /*0xDF71*/, 0x50D4, 0x50D9, 0x50E1, 0x50E9, 0x3492,
-};
-static const unsigned short euc_to_utf8_8FA3_x0213[] = {
- 0x5108, 0xD840 /*0xDFF9*/, 0x5117, 0x511B, 0xD841 /*0xDC4A*/, 0x5160, 0xD841 /*0xDD09*/,
- 0x5173, 0x5183, 0x518B, 0x34BC, 0x5198, 0x51A3, 0x51AD, 0x34C7,
- 0x51BC, 0xD841 /*0xDDD6*/, 0xD841 /*0xDE28*/, 0x51F3, 0x51F4, 0x5202, 0x5212, 0x5216,
- 0xD841 /*0xDF4F*/, 0x5255, 0x525C, 0x526C, 0x5277, 0x5284, 0x5282, 0xD842 /*0xDC07*/,
- 0x5298, 0xD842 /*0xDC3A*/, 0x52A4, 0x52A6, 0x52AF, 0x52BA, 0x52BB, 0x52CA,
- 0x351F, 0x52D1, 0xD842 /*0xDCB9*/, 0x52F7, 0x530A, 0x530B, 0x5324, 0x5335,
- 0x533E, 0x5342, 0xD842 /*0xDD7C*/, 0xD842 /*0xDD9D*/, 0x5367, 0x536C, 0x537A, 0x53A4,
- 0x53B4, 0xD842 /*0xDED3*/, 0x53B7, 0x53C0, 0xD842 /*0xDF1D*/, 0x355D, 0x355E, 0x53D5,
- 0x53DA, 0x3563, 0x53F4, 0x53F5, 0x5455, 0x5424, 0x5428, 0x356E,
- 0x5443, 0x5462, 0x5466, 0x546C, 0x548A, 0x548D, 0x5495, 0x54A0,
- 0x54A6, 0x54AD, 0x54AE, 0x54B7, 0x54BA, 0x54BF, 0x54C3, 0xD843 /*0xDD45*/,
- 0x54EC, 0x54EF, 0x54F1, 0x54F3, 0x5500, 0x5501, 0x5509,
-};
-static const unsigned short euc_to_utf8_8FA4_x0213[] = {
- 0x553C, 0x5541, 0x35A6, 0x5547, 0x554A, 0x35A8, 0x5560,
- 0x5561, 0x5564, 0xD843 /*0xDDE1*/, 0x557D, 0x5582, 0x5588, 0x5591, 0x35C5,
- 0x55D2, 0xD843 /*0xDE95*/, 0xD843 /*0xDE6D*/, 0x55BF, 0x55C9, 0x55CC, 0x55D1, 0x55DD,
- 0x35DA, 0x55E2, 0xD843 /*0xDE64*/, 0x55E9, 0x5628, 0xD843 /*0xDF5F*/, 0x5607, 0x5610,
- 0x5630, 0x5637, 0x35F4, 0x563D, 0x563F, 0x5640, 0x5647, 0x565E,
- 0x5660, 0x566D, 0x3605, 0x5688, 0x568C, 0x5695, 0x569A, 0x569D,
- 0x56A8, 0x56AD, 0x56B2, 0x56C5, 0x56CD, 0x56DF, 0x56E8, 0x56F6,
- 0x56F7, 0xD844 /*0xDE01*/, 0x5715, 0x5723, 0xD844 /*0xDE55*/, 0x5729, 0xD844 /*0xDE7B*/, 0x5745,
- 0x5746, 0x574C, 0x574D, 0xD844 /*0xDE74*/, 0x5768, 0x576F, 0x5773, 0x5774,
- 0x5775, 0x577B, 0xD844 /*0xDEE4*/, 0xD844 /*0xDED7*/, 0x57AC, 0x579A, 0x579D, 0x579E,
- 0x57A8, 0x57D7, 0xD844 /*0xDEFD*/, 0x57CC, 0xD844 /*0xDF36*/, 0xD844 /*0xDF44*/, 0x57DE, 0x57E6,
- 0x57F0, 0x364A, 0x57F8, 0x57FB, 0x57FD, 0x5804, 0x581E,
-};
-static const unsigned short euc_to_utf8_8FA5_x0213[] = {
- 0x5820, 0x5827, 0x5832, 0x5839, 0xD844 /*0xDFC4*/, 0x5849, 0x584C,
- 0x5867, 0x588A, 0x588B, 0x588D, 0x588F, 0x5890, 0x5894, 0x589D,
- 0x58AA, 0x58B1, 0xD845 /*0xDC6D*/, 0x58C3, 0x58CD, 0x58E2, 0x58F3, 0x58F4,
- 0x5905, 0x5906, 0x590B, 0x590D, 0x5914, 0x5924, 0xD845 /*0xDDD7*/, 0x3691,
- 0x593D, 0x3699, 0x5946, 0x3696, 0xD85B /*0xDC29*/, 0x595B, 0x595F, 0xD845 /*0xDE47*/,
- 0x5975, 0x5976, 0x597C, 0x599F, 0x59AE, 0x59BC, 0x59C8, 0x59CD,
- 0x59DE, 0x59E3, 0x59E4, 0x59E7, 0x59EE, 0xD845 /*0xDF06*/, 0xD845 /*0xDF42*/, 0x36CF,
- 0x5A0C, 0x5A0D, 0x5A17, 0x5A27, 0x5A2D, 0x5A55, 0x5A65, 0x5A7A,
- 0x5A8B, 0x5A9C, 0x5A9F, 0x5AA0, 0x5AA2, 0x5AB1, 0x5AB3, 0x5AB5,
- 0x5ABA, 0x5ABF, 0x5ADA, 0x5ADC, 0x5AE0, 0x5AE5, 0x5AF0, 0x5AEE,
- 0x5AF5, 0x5B00, 0x5B08, 0x5B17, 0x5B34, 0x5B2D, 0x5B4C, 0x5B52,
- 0x5B68, 0x5B6F, 0x5B7C, 0x5B7F, 0x5B81, 0x5B84, 0xD846 /*0xDDC3*/,
-};
-static const unsigned short euc_to_utf8_8FA8_x0213[] = {
- 0x5B96, 0x5BAC, 0x3761, 0x5BC0, 0x3762, 0x5BCE, 0x5BD6,
- 0x376C, 0x376B, 0x5BF1, 0x5BFD, 0x3775, 0x5C03, 0x5C29, 0x5C30,
- 0xD847 /*0xDC56*/, 0x5C5F, 0x5C63, 0x5C67, 0x5C68, 0x5C69, 0x5C70, 0xD847 /*0xDD2D*/,
- 0xD847 /*0xDD45*/, 0x5C7C, 0xD847 /*0xDD78*/, 0xD847 /*0xDD62*/, 0x5C88, 0x5C8A, 0x37C1, 0xD847 /*0xDDA1*/,
- 0xD847 /*0xDD9C*/, 0x5CA0, 0x5CA2, 0x5CA6, 0x5CA7, 0xD847 /*0xDD92*/, 0x5CAD, 0x5CB5,
- 0xD847 /*0xDDB7*/, 0x5CC9, 0xD847 /*0xDDE0*/, 0xD847 /*0xDE33*/, 0x5D06, 0x5D10, 0x5D2B, 0x5D1D,
- 0x5D20, 0x5D24, 0x5D26, 0x5D31, 0x5D39, 0x5D42, 0x37E8, 0x5D61,
- 0x5D6A, 0x37F4, 0x5D70, 0xD847 /*0xDF1E*/, 0x37FD, 0x5D88, 0x3800, 0x5D92,
- 0x5D94, 0x5D97, 0x5D99, 0x5DB0, 0x5DB2, 0x5DB4, 0xD847 /*0xDF76*/, 0x5DB9,
- 0x5DD1, 0x5DD7, 0x5DD8, 0x5DE0, 0xD847 /*0xDFFA*/, 0x5DE4, 0x5DE9, 0x382F,
- 0x5E00, 0x3836, 0x5E12, 0x5E15, 0x3840, 0x5E1F, 0x5E2E, 0x5E3E,
- 0x5E49, 0x385C, 0x5E56, 0x3861, 0x5E6B, 0x5E6C, 0x5E6D,
-};
-static const unsigned short euc_to_utf8_8FAC_x0213[] = {
- 0x5E6E, 0xD848 /*0xDD7B*/, 0x5EA5, 0x5EAA, 0x5EAC, 0x5EB9, 0x5EBF,
- 0x5EC6, 0x5ED2, 0x5ED9, 0xD848 /*0xDF1E*/, 0x5EFD, 0x5F08, 0x5F0E, 0x5F1C,
- 0xD848 /*0xDFAD*/, 0x5F1E, 0x5F47, 0x5F63, 0x5F72, 0x5F7E, 0x5F8F, 0x5FA2,
- 0x5FA4, 0x5FB8, 0x5FC4, 0x38FA, 0x5FC7, 0x5FCB, 0x5FD2, 0x5FD3,
- 0x5FD4, 0x5FE2, 0x5FEE, 0x5FEF, 0x5FF3, 0x5FFC, 0x3917, 0x6017,
- 0x6022, 0x6024, 0x391A, 0x604C, 0x607F, 0x608A, 0x6095, 0x60A8,
- 0xD849 /*0xDEF3*/, 0x60B0, 0x60B1, 0x60BE, 0x60C8, 0x60D9, 0x60DB, 0x60EE,
- 0x60F2, 0x60F5, 0x6110, 0x6112, 0x6113, 0x6119, 0x611E, 0x613A,
- 0x396F, 0x6141, 0x6146, 0x6160, 0x617C, 0xD84A /*0xDC5B*/, 0x6192, 0x6193,
- 0x6197, 0x6198, 0x61A5, 0x61A8, 0x61AD, 0xD84A /*0xDCAB*/, 0x61D5, 0x61DD,
- 0x61DF, 0x61F5, 0xD84A /*0xDD8F*/, 0x6215, 0x6223, 0x6229, 0x6246, 0x624C,
- 0x6251, 0x6252, 0x6261, 0x6264, 0x627B, 0x626D, 0x6273,
-};
-static const unsigned short euc_to_utf8_8FAD_x0213[] = {
- 0x6299, 0x62A6, 0x62D5, 0xD84A /*0xDEB8*/, 0x62FD, 0x6303, 0x630D,
- 0x6310, 0xD84A /*0xDF4F*/, 0xD84A /*0xDF50*/, 0x6332, 0x6335, 0x633B, 0x633C, 0x6341,
- 0x6344, 0x634E, 0xD84A /*0xDF46*/, 0x6359, 0xD84B /*0xDC1D*/, 0xD84A /*0xDFA6*/, 0x636C, 0x6384,
- 0x6399, 0xD84B /*0xDC24*/, 0x6394, 0x63BD, 0x63F7, 0x63D4, 0x63D5, 0x63DC,
- 0x63E0, 0x63EB, 0x63EC, 0x63F2, 0x6409, 0x641E, 0x6425, 0x6429,
- 0x642F, 0x645A, 0x645B, 0x645D, 0x6473, 0x647D, 0x6487, 0x6491,
- 0x649D, 0x649F, 0x64CB, 0x64CC, 0x64D5, 0x64D7, 0xD84B /*0xDDE1*/, 0x64E4,
- 0x64E5, 0x64FF, 0x6504, 0x3A6E, 0x650F, 0x6514, 0x6516, 0x3A73,
- 0x651E, 0x6532, 0x6544, 0x6554, 0x656B, 0x657A, 0x6581, 0x6584,
- 0x6585, 0x658A, 0x65B2, 0x65B5, 0x65B8, 0x65BF, 0x65C2, 0x65C9,
- 0x65D4, 0x3AD6, 0x65F2, 0x65F9, 0x65FC, 0x6604, 0x6608, 0x6621,
- 0x662A, 0x6645, 0x6651, 0x664E, 0x3AEA, 0xD84C /*0xDDC3*/, 0x6657,
-};
-static const unsigned short euc_to_utf8_8FAE_x0213[] = {
- 0x665B, 0x6663, 0xD84C /*0xDDF5*/, 0xD84C /*0xDDB6*/, 0x666A, 0x666B, 0x666C,
- 0x666D, 0x667B, 0x6680, 0x6690, 0x6692, 0x6699, 0x3B0E, 0x66AD,
- 0x66B1, 0x66B5, 0x3B1A, 0x66BF, 0x3B1C, 0x66EC, 0x3AD7, 0x6701,
- 0x6705, 0x6712, 0xD84C /*0xDF72*/, 0x6719, 0xD84C /*0xDFD3*/, 0xD84C /*0xDFD2*/, 0x674C, 0x674D,
- 0x6754, 0x675D, 0xD84C /*0xDFD0*/, 0xD84C /*0xDFE4*/, 0xD84C /*0xDFD5*/, 0x6774, 0x6776, 0xD84C /*0xDFDA*/,
- 0x6792, 0xD84C /*0xDFDF*/, 0x8363, 0x6810, 0x67B0, 0x67B2, 0x67C3, 0x67C8,
- 0x67D2, 0x67D9, 0x67DB, 0x67F0, 0x67F7, 0xD84D /*0xDC4A*/, 0xD84D /*0xDC51*/, 0xD84D /*0xDC4B*/,
- 0x6818, 0x681F, 0x682D, 0xD84D /*0xDC65*/, 0x6833, 0x683B, 0x683E, 0x6844,
- 0x6845, 0x6849, 0x684C, 0x6855, 0x6857, 0x3B77, 0x686B, 0x686E,
- 0x687A, 0x687C, 0x6882, 0x6890, 0x6896, 0x3B6D, 0x6898, 0x6899,
- 0x689A, 0x689C, 0x68AA, 0x68AB, 0x68B4, 0x68BB, 0x68FB, 0xD84D /*0xDCE4*/,
- 0xD84D /*0xDD5A*/, 0xFA13, 0x68C3, 0x68C5, 0x68CC, 0x68CF, 0x68D6,
-};
-static const unsigned short euc_to_utf8_8FAF_x0213[] = {
- 0x68D9, 0x68E4, 0x68E5, 0x68EC, 0x68F7, 0x6903, 0x6907,
- 0x3B87, 0x3B88, 0xD84D /*0xDD94*/, 0x693B, 0x3B8D, 0x6946, 0x6969, 0x696C,
- 0x6972, 0x697A, 0x697F, 0x6992, 0x3BA4, 0x6996, 0x6998, 0x69A6,
- 0x69B0, 0x69B7, 0x69BA, 0x69BC, 0x69C0, 0x69D1, 0x69D6, 0xD84D /*0xDE39*/,
- 0xD84D /*0xDE47*/, 0x6A30, 0xD84D /*0xDE38*/, 0xD84D /*0xDE3A*/, 0x69E3, 0x69EE, 0x69EF, 0x69F3,
- 0x3BCD, 0x69F4, 0x69FE, 0x6A11, 0x6A1A, 0x6A1D, 0xD84D /*0xDF1C*/, 0x6A32,
- 0x6A33, 0x6A34, 0x6A3F, 0x6A46, 0x6A49, 0x6A7A, 0x6A4E, 0x6A52,
- 0x6A64, 0xD84D /*0xDF0C*/, 0x6A7E, 0x6A83, 0x6A8B, 0x3BF0, 0x6A91, 0x6A9F,
- 0x6AA1, 0xD84D /*0xDF64*/, 0x6AAB, 0x6ABD, 0x6AC6, 0x6AD4, 0x6AD0, 0x6ADC,
- 0x6ADD, 0xD84D /*0xDFFF*/, 0xD84D /*0xDFE7*/, 0x6AEC, 0x6AF1, 0x6AF2, 0x6AF3, 0x6AFD,
- 0xD84E /*0xDC24*/, 0x6B0B, 0x6B0F, 0x6B10, 0x6B11, 0xD84E /*0xDC3D*/, 0x6B17, 0x3C26,
- 0x6B2F, 0x6B4A, 0x6B58, 0x6B6C, 0x6B75, 0x6B7A, 0x6B81,
-};
-static const unsigned short euc_to_utf8_8FEE_x0213[] = {
- 0x6B9B, 0x6BAE, 0xD84E /*0xDE98*/, 0x6BBD, 0x6BBE, 0x6BC7, 0x6BC8,
- 0x6BC9, 0x6BDA, 0x6BE6, 0x6BE7, 0x6BEE, 0x6BF1, 0x6C02, 0x6C0A,
- 0x6C0E, 0x6C35, 0x6C36, 0x6C3A, 0xD84F /*0xDC7F*/, 0x6C3F, 0x6C4D, 0x6C5B,
- 0x6C6D, 0x6C84, 0x6C89, 0x3CC3, 0x6C94, 0x6C95, 0x6C97, 0x6CAD,
- 0x6CC2, 0x6CD0, 0x3CD2, 0x6CD6, 0x6CDA, 0x6CDC, 0x6CE9, 0x6CEC,
- 0x6CED, 0xD84F /*0xDD00*/, 0x6D00, 0x6D0A, 0x6D24, 0x6D26, 0x6D27, 0x6C67,
- 0x6D2F, 0x6D3C, 0x6D5B, 0x6D5E, 0x6D60, 0x6D70, 0x6D80, 0x6D81,
- 0x6D8A, 0x6D8D, 0x6D91, 0x6D98, 0xD84F /*0xDD40*/, 0x6E17, 0xD84F /*0xDDFA*/, 0xD84F /*0xDDF9*/,
- 0xD84F /*0xDDD3*/, 0x6DAB, 0x6DAE, 0x6DB4, 0x6DC2, 0x6D34, 0x6DC8, 0x6DCE,
- 0x6DCF, 0x6DD0, 0x6DDF, 0x6DE9, 0x6DF6, 0x6E36, 0x6E1E, 0x6E22,
- 0x6E27, 0x3D11, 0x6E32, 0x6E3C, 0x6E48, 0x6E49, 0x6E4B, 0x6E4C,
- 0x6E4F, 0x6E51, 0x6E53, 0x6E54, 0x6E57, 0x6E63, 0x3D1E,
-};
-static const unsigned short euc_to_utf8_8FEF_x0213[] = {
- 0x6E93, 0x6EA7, 0x6EB4, 0x6EBF, 0x6EC3, 0x6ECA, 0x6ED9,
- 0x6F35, 0x6EEB, 0x6EF9, 0x6EFB, 0x6F0A, 0x6F0C, 0x6F18, 0x6F25,
- 0x6F36, 0x6F3C, 0xD84F /*0xDF7E*/, 0x6F52, 0x6F57, 0x6F5A, 0x6F60, 0x6F68,
- 0x6F98, 0x6F7D, 0x6F90, 0x6F96, 0x6FBE, 0x6F9F, 0x6FA5, 0x6FAF,
- 0x3D64, 0x6FB5, 0x6FC8, 0x6FC9, 0x6FDA, 0x6FDE, 0x6FE9, 0xD850 /*0xDC96*/,
- 0x6FFC, 0x7000, 0x7007, 0x700A, 0x7023, 0xD850 /*0xDD03*/, 0x7039, 0x703A,
- 0x703C, 0x7043, 0x7047, 0x704B, 0x3D9A, 0x7054, 0x7065, 0x7069,
- 0x706C, 0x706E, 0x7076, 0x707E, 0x7081, 0x7086, 0x7095, 0x7097,
- 0x70BB, 0xD850 /*0xDDC6*/, 0x709F, 0x70B1, 0xD850 /*0xDDFE*/, 0x70EC, 0x70CA, 0x70D1,
- 0x70D3, 0x70DC, 0x7103, 0x7104, 0x7106, 0x7107, 0x7108, 0x710C,
- 0x3DC0, 0x712F, 0x7131, 0x7150, 0x714A, 0x7153, 0x715E, 0x3DD4,
- 0x7196, 0x7180, 0x719B, 0x71A0, 0x71A2, 0x71AE, 0x71AF,
-};
-static const unsigned short euc_to_utf8_8FF0_x0213[] = {
- 0x71B3, 0xD850 /*0xDFBC*/, 0x71CB, 0x71D3, 0x71D9, 0x71DC, 0x7207,
- 0x3E05, 0xFA49, 0x722B, 0x7234, 0x7238, 0x7239, 0x4E2C, 0x7242,
- 0x7253, 0x7257, 0x7263, 0xD851 /*0xDE29*/, 0x726E, 0x726F, 0x7278, 0x727F,
- 0x728E, 0xD851 /*0xDEA5*/, 0x72AD, 0x72AE, 0x72B0, 0x72B1, 0x72C1, 0x3E60,
- 0x72CC, 0x3E66, 0x3E68, 0x72F3, 0x72FA, 0x7307, 0x7312, 0x7318,
- 0x7319, 0x3E83, 0x7339, 0x732C, 0x7331, 0x7333, 0x733D, 0x7352,
- 0x3E94, 0x736B, 0x736C, 0xD852 /*0xDC96*/, 0x736E, 0x736F, 0x7371, 0x7377,
- 0x7381, 0x7385, 0x738A, 0x7394, 0x7398, 0x739C, 0x739E, 0x73A5,
- 0x73A8, 0x73B5, 0x73B7, 0x73B9, 0x73BC, 0x73BF, 0x73C5, 0x73CB,
- 0x73E1, 0x73E7, 0x73F9, 0x7413, 0x73FA, 0x7401, 0x7424, 0x7431,
- 0x7439, 0x7453, 0x7440, 0x7443, 0x744D, 0x7452, 0x745D, 0x7471,
- 0x7481, 0x7485, 0x7488, 0xD852 /*0xDE4D*/, 0x7492, 0x7497, 0x7499,
-};
-static const unsigned short euc_to_utf8_8FF1_x0213[] = {
- 0x74A0, 0x74A1, 0x74A5, 0x74AA, 0x74AB, 0x74B9, 0x74BB,
- 0x74BA, 0x74D6, 0x74D8, 0x74DE, 0x74EF, 0x74EB, 0xD852 /*0xDF56*/, 0x74FA,
- 0xD852 /*0xDF6F*/, 0x7520, 0x7524, 0x752A, 0x3F57, 0xD853 /*0xDC16*/, 0x753D, 0x753E,
- 0x7540, 0x7548, 0x754E, 0x7550, 0x7552, 0x756C, 0x7572, 0x7571,
- 0x757A, 0x757D, 0x757E, 0x7581, 0xD853 /*0xDD14*/, 0x758C, 0x3F75, 0x75A2,
- 0x3F77, 0x75B0, 0x75B7, 0x75BF, 0x75C0, 0x75C6, 0x75CF, 0x75D3,
- 0x75DD, 0x75DF, 0x75E0, 0x75E7, 0x75EC, 0x75EE, 0x75F1, 0x75F9,
- 0x7603, 0x7618, 0x7607, 0x760F, 0x3FAE, 0xD853 /*0xDE0E*/, 0x7613, 0x761B,
- 0x761C, 0xD853 /*0xDE37*/, 0x7625, 0x7628, 0x763C, 0x7633, 0xD853 /*0xDE6A*/, 0x3FC9,
- 0x7641, 0xD853 /*0xDE8B*/, 0x7649, 0x7655, 0x3FD7, 0x766E, 0x7695, 0x769C,
- 0x76A1, 0x76A0, 0x76A7, 0x76A8, 0x76AF, 0xD854 /*0xDC4A*/, 0x76C9, 0xD854 /*0xDC55*/,
- 0x76E8, 0x76EC, 0xD854 /*0xDD22*/, 0x7717, 0x771A, 0x772D, 0x7735,
-};
-static const unsigned short euc_to_utf8_8FF2_x0213[] = {
- 0xD854 /*0xDDA9*/, 0x4039, 0xD854 /*0xDDE5*/, 0xD854 /*0xDDCD*/, 0x7758, 0x7760, 0x776A,
- 0xD854 /*0xDE1E*/, 0x7772, 0x777C, 0x777D, 0xD854 /*0xDE4C*/, 0x4058, 0x779A, 0x779F,
- 0x77A2, 0x77A4, 0x77A9, 0x77DE, 0x77DF, 0x77E4, 0x77E6, 0x77EA,
- 0x77EC, 0x4093, 0x77F0, 0x77F4, 0x77FB, 0xD855 /*0xDC2E*/, 0x7805, 0x7806,
- 0x7809, 0x780D, 0x7819, 0x7821, 0x782C, 0x7847, 0x7864, 0x786A,
- 0xD855 /*0xDCD9*/, 0x788A, 0x7894, 0x78A4, 0x789D, 0x789E, 0x789F, 0x78BB,
- 0x78C8, 0x78CC, 0x78CE, 0x78D5, 0x78E0, 0x78E1, 0x78E6, 0x78F9,
- 0x78FA, 0x78FB, 0x78FE, 0xD855 /*0xDDA7*/, 0x7910, 0x791B, 0x7930, 0x7925,
- 0x793B, 0x794A, 0x7958, 0x795B, 0x4105, 0x7967, 0x7972, 0x7994,
- 0x7995, 0x7996, 0x799B, 0x79A1, 0x79A9, 0x79B4, 0x79BB, 0x79C2,
- 0x79C7, 0x79CC, 0x79CD, 0x79D6, 0x4148, 0xD855 /*0xDFA9*/, 0xD855 /*0xDFB4*/, 0x414F,
- 0x7A0A, 0x7A11, 0x7A15, 0x7A1B, 0x7A1E, 0x4163, 0x7A2D,
-};
-static const unsigned short euc_to_utf8_8FF3_x0213[] = {
- 0x7A38, 0x7A47, 0x7A4C, 0x7A56, 0x7A59, 0x7A5C, 0x7A5F,
- 0x7A60, 0x7A67, 0x7A6A, 0x7A75, 0x7A78, 0x7A82, 0x7A8A, 0x7A90,
- 0x7AA3, 0x7AAC, 0xD856 /*0xDDD4*/, 0x41B4, 0x7AB9, 0x7ABC, 0x7ABE, 0x41BF,
- 0x7ACC, 0x7AD1, 0x7AE7, 0x7AE8, 0x7AF4, 0xD856 /*0xDEE4*/, 0xD856 /*0xDEE3*/, 0x7B07,
- 0xD856 /*0xDEF1*/, 0x7B3D, 0x7B27, 0x7B2A, 0x7B2E, 0x7B2F, 0x7B31, 0x41E6,
- 0x41F3, 0x7B7F, 0x7B41, 0x41EE, 0x7B55, 0x7B79, 0x7B64, 0x7B66,
- 0x7B69, 0x7B73, 0xD856 /*0xDFB2*/, 0x4207, 0x7B90, 0x7B91, 0x7B9B, 0x420E,
- 0x7BAF, 0x7BB5, 0x7BBC, 0x7BC5, 0x7BCA, 0xD857 /*0xDC4B*/, 0xD857 /*0xDC64*/, 0x7BD4,
- 0x7BD6, 0x7BDA, 0x7BEA, 0x7BF0, 0x7C03, 0x7C0B, 0x7C0E, 0x7C0F,
- 0x7C26, 0x7C45, 0x7C4A, 0x7C51, 0x7C57, 0x7C5E, 0x7C61, 0x7C69,
- 0x7C6E, 0x7C6F, 0x7C70, 0xD857 /*0xDE2E*/, 0xD857 /*0xDE56*/, 0xD857 /*0xDE65*/, 0x7CA6, 0xD857 /*0xDE62*/,
- 0x7CB6, 0x7CB7, 0x7CBF, 0xD857 /*0xDED8*/, 0x7CC4, 0xD857 /*0xDEC2*/, 0x7CC8,
-};
-static const unsigned short euc_to_utf8_8FF4_x0213[] = {
- 0x7CCD, 0xD857 /*0xDEE8*/, 0x7CD7, 0xD857 /*0xDF23*/, 0x7CE6, 0x7CEB, 0xD857 /*0xDF5C*/,
- 0x7CF5, 0x7D03, 0x7D09, 0x42C6, 0x7D12, 0x7D1E, 0xD857 /*0xDFE0*/, 0xD857 /*0xDFD4*/,
- 0x7D3D, 0x7D3E, 0x7D40, 0x7D47, 0xD858 /*0xDC0C*/, 0xD857 /*0xDFFB*/, 0x42D6, 0x7D59,
- 0x7D5A, 0x7D6A, 0x7D70, 0x42DD, 0x7D7F, 0xD858 /*0xDC17*/, 0x7D86, 0x7D88,
- 0x7D8C, 0x7D97, 0xD858 /*0xDC60*/, 0x7D9D, 0x7DA7, 0x7DAA, 0x7DB6, 0x7DB7,
- 0x7DC0, 0x7DD7, 0x7DD9, 0x7DE6, 0x7DF1, 0x7DF9, 0x4302, 0xD858 /*0xDCED*/,
- 0xFA58, 0x7E10, 0x7E17, 0x7E1D, 0x7E20, 0x7E27, 0x7E2C, 0x7E45,
- 0x7E73, 0x7E75, 0x7E7E, 0x7E86, 0x7E87, 0x432B, 0x7E91, 0x7E98,
- 0x7E9A, 0x4343, 0x7F3C, 0x7F3B, 0x7F3E, 0x7F43, 0x7F44, 0x7F4F,
- 0x34C1, 0xD858 /*0xDE70*/, 0x7F52, 0xD858 /*0xDE86*/, 0x7F61, 0x7F63, 0x7F64, 0x7F6D,
- 0x7F7D, 0x7F7E, 0xD858 /*0xDF4C*/, 0x7F90, 0x517B, 0xD84F /*0xDD0E*/, 0x7F96, 0x7F9C,
- 0x7FAD, 0xD859 /*0xDC02*/, 0x7FC3, 0x7FCF, 0x7FE3, 0x7FE5, 0x7FEF,
-};
-static const unsigned short euc_to_utf8_8FF5_x0213[] = {
- 0x7FF2, 0x8002, 0x800A, 0x8008, 0x800E, 0x8011, 0x8016,
- 0x8024, 0x802C, 0x8030, 0x8043, 0x8066, 0x8071, 0x8075, 0x807B,
- 0x8099, 0x809C, 0x80A4, 0x80A7, 0x80B8, 0xD859 /*0xDE7E*/, 0x80C5, 0x80D5,
- 0x80D8, 0x80E6, 0xD859 /*0xDEB0*/, 0x810D, 0x80F5, 0x80FB, 0x43EE, 0x8135,
- 0x8116, 0x811E, 0x43F0, 0x8124, 0x8127, 0x812C, 0xD859 /*0xDF1D*/, 0x813D,
- 0x4408, 0x8169, 0x4417, 0x8181, 0x441C, 0x8184, 0x8185, 0x4422,
- 0x8198, 0x81B2, 0x81C1, 0x81C3, 0x81D6, 0x81DB, 0xD85A /*0xDCDD*/, 0x81E4,
- 0xD85A /*0xDCEA*/, 0x81EC, 0xD85A /*0xDD51*/, 0x81FD, 0x81FF, 0xD85A /*0xDD6F*/, 0x8204, 0xD85A /*0xDDDD*/,
- 0x8219, 0x8221, 0x8222, 0xD85A /*0xDE1E*/, 0x8232, 0x8234, 0x823C, 0x8246,
- 0x8249, 0x8245, 0xD85A /*0xDE58*/, 0x824B, 0x4476, 0x824F, 0x447A, 0x8257,
- 0xD85A /*0xDE8C*/, 0x825C, 0x8263, 0xD85A /*0xDEB7*/, 0xFA5D, 0xFA5E, 0x8279, 0x4491,
- 0x827D, 0x827F, 0x8283, 0x828A, 0x8293, 0x82A7, 0x82A8,
-};
-static const unsigned short euc_to_utf8_8FF6_x0213[] = {
- 0x82B2, 0x82B4, 0x82BA, 0x82BC, 0x82E2, 0x82E8, 0x82F7,
- 0x8307, 0x8308, 0x830C, 0x8354, 0x831B, 0x831D, 0x8330, 0x833C,
- 0x8344, 0x8357, 0x44BE, 0x837F, 0x44D4, 0x44B3, 0x838D, 0x8394,
- 0x8395, 0x839B, 0x839D, 0x83C9, 0x83D0, 0x83D4, 0x83DD, 0x83E5,
- 0x83F9, 0x840F, 0x8411, 0x8415, 0xD85B /*0xDC73*/, 0x8417, 0x8439, 0x844A,
- 0x844F, 0x8451, 0x8452, 0x8459, 0x845A, 0x845C, 0xD85B /*0xDCDD*/, 0x8465,
- 0x8476, 0x8478, 0x847C, 0x8481, 0x450D, 0x84DC, 0x8497, 0x84A6,
- 0x84BE, 0x4508, 0x84CE, 0x84CF, 0x84D3, 0xD85B /*0xDE65*/, 0x84E7, 0x84EA,
- 0x84EF, 0x84F0, 0x84F1, 0x84FA, 0x84FD, 0x850C, 0x851B, 0x8524,
- 0x8525, 0x852B, 0x8534, 0x854F, 0x856F, 0x4525, 0x4543, 0x853E,
- 0x8551, 0x8553, 0x855E, 0x8561, 0x8562, 0xD85B /*0xDF94*/, 0x857B, 0x857D,
- 0x857F, 0x8581, 0x8586, 0x8593, 0x859D, 0x859F, 0xD85B /*0xDFF8*/,
-};
-static const unsigned short euc_to_utf8_8FF7_x0213[] = {
- 0xD85B /*0xDFF6*/, 0xD85B /*0xDFF7*/, 0x85B7, 0x85BC, 0x85C7, 0x85CA, 0x85D8,
- 0x85D9, 0x85DF, 0x85E1, 0x85E6, 0x85F6, 0x8600, 0x8611, 0x861E,
- 0x8621, 0x8624, 0x8627, 0xD85C /*0xDD0D*/, 0x8639, 0x863C, 0xD85C /*0xDD39*/, 0x8640,
- 0xFA20, 0x8653, 0x8656, 0x866F, 0x8677, 0x867A, 0x8687, 0x8689,
- 0x868D, 0x8691, 0x869C, 0x869D, 0x86A8, 0xFA21, 0x86B1, 0x86B3,
- 0x86C1, 0x86C3, 0x86D1, 0x86D5, 0x86D7, 0x86E3, 0x86E6, 0x45B8,
- 0x8705, 0x8707, 0x870E, 0x8710, 0x8713, 0x8719, 0x871F, 0x8721,
- 0x8723, 0x8731, 0x873A, 0x873E, 0x8740, 0x8743, 0x8751, 0x8758,
- 0x8764, 0x8765, 0x8772, 0x877C, 0xD85C /*0xDFDB*/, 0xD85C /*0xDFDA*/, 0x87A7, 0x8789,
- 0x878B, 0x8793, 0x87A0, 0xD85C /*0xDFFE*/, 0x45E5, 0x87BE, 0xD85D /*0xDC10*/, 0x87C1,
- 0x87CE, 0x87F5, 0x87DF, 0xD85D /*0xDC49*/, 0x87E3, 0x87E5, 0x87E6, 0x87EA,
- 0x87EB, 0x87ED, 0x8801, 0x8803, 0x880B, 0x8813, 0x8828,
-};
-static const unsigned short euc_to_utf8_8FF8_x0213[] = {
- 0x882E, 0x8832, 0x883C, 0x460F, 0x884A, 0x8858, 0x885F,
- 0x8864, 0xD85D /*0xDE15*/, 0xD85D /*0xDE14*/, 0x8869, 0xD85D /*0xDE31*/, 0x886F, 0x88A0, 0x88BC,
- 0x88BD, 0x88BE, 0x88C0, 0x88D2, 0xD85D /*0xDE93*/, 0x88D1, 0x88D3, 0x88DB,
- 0x88F0, 0x88F1, 0x4641, 0x8901, 0xD85D /*0xDF0E*/, 0x8937, 0xD85D /*0xDF23*/, 0x8942,
- 0x8945, 0x8949, 0xD85D /*0xDF52*/, 0x4665, 0x8962, 0x8980, 0x8989, 0x8990,
- 0x899F, 0x89B0, 0x89B7, 0x89D6, 0x89D8, 0x89EB, 0x46A1, 0x89F1,
- 0x89F3, 0x89FD, 0x89FF, 0x46AF, 0x8A11, 0x8A14, 0xD85E /*0xDD85*/, 0x8A21,
- 0x8A35, 0x8A3E, 0x8A45, 0x8A4D, 0x8A58, 0x8AAE, 0x8A90, 0x8AB7,
- 0x8ABE, 0x8AD7, 0x8AFC, 0xD85E /*0xDE84*/, 0x8B0A, 0x8B05, 0x8B0D, 0x8B1C,
- 0x8B1F, 0x8B2D, 0x8B43, 0x470C, 0x8B51, 0x8B5E, 0x8B76, 0x8B7F,
- 0x8B81, 0x8B8B, 0x8B94, 0x8B95, 0x8B9C, 0x8B9E, 0x8C39, 0xD85E /*0xDFB3*/,
- 0x8C3D, 0xD85E /*0xDFBE*/, 0xD85E /*0xDFC7*/, 0x8C45, 0x8C47, 0x8C4F, 0x8C54,
-};
-static const unsigned short euc_to_utf8_8FF9_x0213[] = {
- 0x8C57, 0x8C69, 0x8C6D, 0x8C73, 0xD85F /*0xDCB8*/, 0x8C93, 0x8C92,
- 0x8C99, 0x4764, 0x8C9B, 0x8CA4, 0x8CD6, 0x8CD5, 0x8CD9, 0xD85F /*0xDDA0*/,
- 0x8CF0, 0x8CF1, 0xD85F /*0xDE10*/, 0x8D09, 0x8D0E, 0x8D6C, 0x8D84, 0x8D95,
- 0x8DA6, 0xD85F /*0xDFB7*/, 0x8DC6, 0x8DC8, 0x8DD9, 0x8DEC, 0x8E0C, 0x47FD,
- 0x8DFD, 0x8E06, 0xD860 /*0xDC8A*/, 0x8E14, 0x8E16, 0x8E21, 0x8E22, 0x8E27,
- 0xD860 /*0xDCBB*/, 0x4816, 0x8E36, 0x8E39, 0x8E4B, 0x8E54, 0x8E62, 0x8E6C,
- 0x8E6D, 0x8E6F, 0x8E98, 0x8E9E, 0x8EAE, 0x8EB3, 0x8EB5, 0x8EB6,
- 0x8EBB, 0xD860 /*0xDE82*/, 0x8ED1, 0x8ED4, 0x484E, 0x8EF9, 0xD860 /*0xDEF3*/, 0x8F00,
- 0x8F08, 0x8F17, 0x8F2B, 0x8F40, 0x8F4A, 0x8F58, 0xD861 /*0xDC0C*/, 0x8FA4,
- 0x8FB4, 0xFA66, 0x8FB6, 0xD861 /*0xDC55*/, 0x8FC1, 0x8FC6, 0xFA24, 0x8FCA,
- 0x8FCD, 0x8FD3, 0x8FD5, 0x8FE0, 0x8FF1, 0x8FF5, 0x8FFB, 0x9002,
- 0x900C, 0x9037, 0xD861 /*0xDD6B*/, 0x9043, 0x9044, 0x905D, 0xD861 /*0xDDC8*/,
-};
-static const unsigned short euc_to_utf8_8FFA_x0213[] = {
- 0xD861 /*0xDDC9*/, 0x9085, 0x908C, 0x9090, 0x961D, 0x90A1, 0x48B5,
- 0x90B0, 0x90B6, 0x90C3, 0x90C8, 0xD861 /*0xDED7*/, 0x90DC, 0x90DF, 0xD861 /*0xDEFA*/,
- 0x90F6, 0x90F2, 0x9100, 0x90EB, 0x90FE, 0x90FF, 0x9104, 0x9106,
- 0x9118, 0x911C, 0x911E, 0x9137, 0x9139, 0x913A, 0x9146, 0x9147,
- 0x9157, 0x9159, 0x9161, 0x9164, 0x9174, 0x9179, 0x9185, 0x918E,
- 0x91A8, 0x91AE, 0x91B3, 0x91B6, 0x91C3, 0x91C4, 0x91DA, 0xD862 /*0xDD49*/,
- 0xD862 /*0xDD46*/, 0x91EC, 0x91EE, 0x9201, 0x920A, 0x9216, 0x9217, 0xD862 /*0xDD6B*/,
- 0x9233, 0x9242, 0x9247, 0x924A, 0x924E, 0x9251, 0x9256, 0x9259,
- 0x9260, 0x9261, 0x9265, 0x9267, 0x9268, 0xD862 /*0xDD87*/, 0xD862 /*0xDD88*/, 0x927C,
- 0x927D, 0x927F, 0x9289, 0x928D, 0x9297, 0x9299, 0x929F, 0x92A7,
- 0x92AB, 0xD862 /*0xDDBA*/, 0xD862 /*0xDDBB*/, 0x92B2, 0x92BF, 0x92C0, 0x92C6, 0x92CE,
- 0x92D0, 0x92D7, 0x92D9, 0x92E5, 0x92E7, 0x9311, 0xD862 /*0xDE1E*/,
-};
-static const unsigned short euc_to_utf8_8FFB_x0213[] = {
- 0xD862 /*0xDE29*/, 0x92F7, 0x92F9, 0x92FB, 0x9302, 0x930D, 0x9315,
- 0x931D, 0x931E, 0x9327, 0x9329, 0xD862 /*0xDE71*/, 0xD862 /*0xDE43*/, 0x9347, 0x9351,
- 0x9357, 0x935A, 0x936B, 0x9371, 0x9373, 0x93A1, 0xD862 /*0xDE99*/, 0xD862 /*0xDECD*/,
- 0x9388, 0x938B, 0x938F, 0x939E, 0x93F5, 0xD862 /*0xDEE4*/, 0xD862 /*0xDEDD*/, 0x93F1,
- 0x93C1, 0x93C7, 0x93DC, 0x93E2, 0x93E7, 0x9409, 0x940F, 0x9416,
- 0x9417, 0x93FB, 0x9432, 0x9434, 0x943B, 0x9445, 0xD862 /*0xDFC1*/, 0xD862 /*0xDFEF*/,
- 0x946D, 0x946F, 0x9578, 0x9579, 0x9586, 0x958C, 0x958D, 0xD863 /*0xDD10*/,
- 0x95AB, 0x95B4, 0xD863 /*0xDD71*/, 0x95C8, 0xD863 /*0xDDFB*/, 0xD863 /*0xDE1F*/, 0x962C, 0x9633,
- 0x9634, 0xD863 /*0xDE36*/, 0x963C, 0x9641, 0x9661, 0xD863 /*0xDE89*/, 0x9682, 0xD863 /*0xDEEB*/,
- 0x969A, 0xD863 /*0xDF32*/, 0x49E7, 0x96A9, 0x96AF, 0x96B3, 0x96BA, 0x96BD,
- 0x49FA, 0xD863 /*0xDFF8*/, 0x96D8, 0x96DA, 0x96DD, 0x4A04, 0x9714, 0x9723,
- 0x4A29, 0x9736, 0x9741, 0x9747, 0x9755, 0x9757, 0x975B,
-};
-static const unsigned short euc_to_utf8_8FFC_x0213[] = {
- 0x976A, 0xD864 /*0xDEA0*/, 0xD864 /*0xDEB1*/, 0x9796, 0x979A, 0x979E, 0x97A2,
- 0x97B1, 0x97B2, 0x97BE, 0x97CC, 0x97D1, 0x97D4, 0x97D8, 0x97D9,
- 0x97E1, 0x97F1, 0x9804, 0x980D, 0x980E, 0x9814, 0x9816, 0x4ABC,
- 0xD865 /*0xDC90*/, 0x9823, 0x9832, 0x9833, 0x9825, 0x9847, 0x9866, 0x98AB,
- 0x98AD, 0x98B0, 0xD865 /*0xDDCF*/, 0x98B7, 0x98B8, 0x98BB, 0x98BC, 0x98BF,
- 0x98C2, 0x98C7, 0x98CB, 0x98E0, 0xD865 /*0xDE7F*/, 0x98E1, 0x98E3, 0x98E5,
- 0x98EA, 0x98F0, 0x98F1, 0x98F3, 0x9908, 0x4B3B, 0xD865 /*0xDEF0*/, 0x9916,
- 0x9917, 0xD865 /*0xDF19*/, 0x991A, 0x991B, 0x991C, 0xD865 /*0xDF50*/, 0x9931, 0x9932,
- 0x9933, 0x993A, 0x993B, 0x993C, 0x9940, 0x9941, 0x9946, 0x994D,
- 0x994E, 0x995C, 0x995F, 0x9960, 0x99A3, 0x99A6, 0x99B9, 0x99BD,
- 0x99BF, 0x99C3, 0x99C9, 0x99D4, 0x99D9, 0x99DE, 0xD866 /*0xDCC6*/, 0x99F0,
- 0x99F9, 0x99FC, 0x9A0A, 0x9A11, 0x9A16, 0x9A1A, 0x9A20,
-};
-static const unsigned short euc_to_utf8_8FFD_x0213[] = {
- 0x9A31, 0x9A36, 0x9A44, 0x9A4C, 0x9A58, 0x4BC2, 0x9AAF,
- 0x4BCA, 0x9AB7, 0x4BD2, 0x9AB9, 0xD866 /*0xDE72*/, 0x9AC6, 0x9AD0, 0x9AD2,
- 0x9AD5, 0x4BE8, 0x9ADC, 0x9AE0, 0x9AE5, 0x9AE9, 0x9B03, 0x9B0C,
- 0x9B10, 0x9B12, 0x9B16, 0x9B1C, 0x9B2B, 0x9B33, 0x9B3D, 0x4C20,
- 0x9B4B, 0x9B63, 0x9B65, 0x9B6B, 0x9B6C, 0x9B73, 0x9B76, 0x9B77,
- 0x9BA6, 0x9BAC, 0x9BB1, 0xD867 /*0xDDDB*/, 0xD867 /*0xDE3D*/, 0x9BB2, 0x9BB8, 0x9BBE,
- 0x9BC7, 0x9BF3, 0x9BD8, 0x9BDD, 0x9BE7, 0x9BEA, 0x9BEB, 0x9BEF,
- 0x9BEE, 0xD867 /*0xDE15*/, 0x9BFA, 0xD867 /*0xDE8A*/, 0x9BF7, 0xD867 /*0xDE49*/, 0x9C16, 0x9C18,
- 0x9C19, 0x9C1A, 0x9C1D, 0x9C22, 0x9C27, 0x9C29, 0x9C2A, 0xD867 /*0xDEC4*/,
- 0x9C31, 0x9C36, 0x9C37, 0x9C45, 0x9C5C, 0xD867 /*0xDEE9*/, 0x9C49, 0x9C4A,
- 0xD867 /*0xDEDB*/, 0x9C54, 0x9C58, 0x9C5B, 0x9C5D, 0x9C5F, 0x9C69, 0x9C6A,
- 0x9C6B, 0x9C6D, 0x9C6E, 0x9C70, 0x9C72, 0x9C75, 0x9C7A,
-};
-static const unsigned short euc_to_utf8_8FFE_x0213[] = {
- 0x9CE6, 0x9CF2, 0x9D0B, 0x9D02, 0xD867 /*0xDFCE*/, 0x9D11, 0x9D17,
- 0x9D18, 0xD868 /*0xDC2F*/, 0x4CC4, 0xD868 /*0xDC1A*/, 0x9D32, 0x4CD1, 0x9D42, 0x9D4A,
- 0x9D5F, 0x9D62, 0xD868 /*0xDCF9*/, 0x9D69, 0x9D6B, 0xD868 /*0xDC82*/, 0x9D73, 0x9D76,
- 0x9D77, 0x9D7E, 0x9D84, 0x9D8D, 0x9D99, 0x9DA1, 0x9DBF, 0x9DB5,
- 0x9DB9, 0x9DBD, 0x9DC3, 0x9DC7, 0x9DC9, 0x9DD6, 0x9DDA, 0x9DDF,
- 0x9DE0, 0x9DE3, 0x9DF4, 0x4D07, 0x9E0A, 0x9E02, 0x9E0D, 0x9E19,
- 0x9E1C, 0x9E1D, 0x9E7B, 0xD848 /*0xDE18*/, 0x9E80, 0x9E85, 0x9E9B, 0x9EA8,
- 0xD868 /*0xDF8C*/, 0x9EBD, 0xD869 /*0xDC37*/, 0x9EDF, 0x9EE7, 0x9EEE, 0x9EFF, 0x9F02,
- 0x4D77, 0x9F03, 0x9F17, 0x9F19, 0x9F2F, 0x9F37, 0x9F3A, 0x9F3D,
- 0x9F41, 0x9F45, 0x9F46, 0x9F53, 0x9F55, 0x9F58, 0xD869 /*0xDDF1*/, 0x9F5D,
- 0xD869 /*0xDE02*/, 0x9F69, 0xD869 /*0xDE1A*/, 0x9F6D, 0x9F70, 0x9F75, 0xD869 /*0xDEB2*/, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-
-#ifdef X0212_ENABLE
-static const unsigned short euc_to_utf8_8FA2[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x02D8,
- 0x02C7, 0x00B8, 0x02D9, 0x02DD, 0x00AF, 0x02DB, 0x02DA, 0xFF5E,
- 0x0384, 0x0385, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x00A1, 0xFFE4, 0x00BF, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x00BA, 0x00AA, 0x00A9, 0x00AE, 0x2122,
- 0x00A4, 0x2116, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_8FA6[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x0386, 0x0388, 0x0389, 0x038A, 0x03AA, 0, 0x038C,
- 0, 0x038E, 0x03AB, 0, 0x038F, 0, 0, 0,
- 0, 0x03AC, 0x03AD, 0x03AE, 0x03AF, 0x03CA, 0x0390, 0x03CC,
- 0x03C2, 0x03CD, 0x03CB, 0x03B0, 0x03CE, 0, 0,
-};
-static const unsigned short euc_to_utf8_8FA7[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x040E, 0x040F, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x045E, 0x045F,
-};
-static const unsigned short euc_to_utf8_8FA9[] = {
- 0x00C6, 0x0110, 0, 0x0126, 0, 0x0132, 0,
- 0x0141, 0x013F, 0, 0x014A, 0x00D8, 0x0152, 0, 0x0166,
- 0x00DE, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x00E6, 0x0111, 0x00F0, 0x0127, 0x0131, 0x0133, 0x0138,
- 0x0142, 0x0140, 0x0149, 0x014B, 0x00F8, 0x0153, 0x00DF, 0x0167,
- 0x00FE, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short euc_to_utf8_8FAA[] = {
- 0x00C1, 0x00C0, 0x00C4, 0x00C2, 0x0102, 0x01CD, 0x0100,
- 0x0104, 0x00C5, 0x00C3, 0x0106, 0x0108, 0x010C, 0x00C7, 0x010A,
- 0x010E, 0x00C9, 0x00C8, 0x00CB, 0x00CA, 0x011A, 0x0116, 0x0112,
- 0x0118, 0, 0x011C, 0x011E, 0x0122, 0x0120, 0x0124, 0x00CD,
- 0x00CC, 0x00CF, 0x00CE, 0x01CF, 0x0130, 0x012A, 0x012E, 0x0128,
- 0x0134, 0x0136, 0x0139, 0x013D, 0x013B, 0x0143, 0x0147, 0x0145,
- 0x00D1, 0x00D3, 0x00D2, 0x00D6, 0x00D4, 0x01D1, 0x0150, 0x014C,
- 0x00D5, 0x0154, 0x0158, 0x0156, 0x015A, 0x015C, 0x0160, 0x015E,
- 0x0164, 0x0162, 0x00DA, 0x00D9, 0x00DC, 0x00DB, 0x016C, 0x01D3,
- 0x0170, 0x016A, 0x0172, 0x016E, 0x0168, 0x01D7, 0x01DB, 0x01D9,
- 0x01D5, 0x0174, 0x00DD, 0x0178, 0x0176, 0x0179, 0x017D, 0x017B,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_8FAB[] = {
- 0x00E1, 0x00E0, 0x00E4, 0x00E2, 0x0103, 0x01CE, 0x0101,
- 0x0105, 0x00E5, 0x00E3, 0x0107, 0x0109, 0x010D, 0x00E7, 0x010B,
- 0x010F, 0x00E9, 0x00E8, 0x00EB, 0x00EA, 0x011B, 0x0117, 0x0113,
- 0x0119, 0x01F5, 0x011D, 0x011F, 0, 0x0121, 0x0125, 0x00ED,
- 0x00EC, 0x00EF, 0x00EE, 0x01D0, 0, 0x012B, 0x012F, 0x0129,
- 0x0135, 0x0137, 0x013A, 0x013E, 0x013C, 0x0144, 0x0148, 0x0146,
- 0x00F1, 0x00F3, 0x00F2, 0x00F6, 0x00F4, 0x01D2, 0x0151, 0x014D,
- 0x00F5, 0x0155, 0x0159, 0x0157, 0x015B, 0x015D, 0x0161, 0x015F,
- 0x0165, 0x0163, 0x00FA, 0x00F9, 0x00FC, 0x00FB, 0x016D, 0x01D4,
- 0x0171, 0x016B, 0x0173, 0x016F, 0x0169, 0x01D8, 0x01DC, 0x01DA,
- 0x01D6, 0x0175, 0x00FD, 0x00FF, 0x0177, 0x017A, 0x017E, 0x017C,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short euc_to_utf8_8FB0[] = {
- 0x4E02, 0x4E04, 0x4E05, 0x4E0C, 0x4E12, 0x4E1F, 0x4E23,
- 0x4E24, 0x4E28, 0x4E2B, 0x4E2E, 0x4E2F, 0x4E30, 0x4E35, 0x4E40,
- 0x4E41, 0x4E44, 0x4E47, 0x4E51, 0x4E5A, 0x4E5C, 0x4E63, 0x4E68,
- 0x4E69, 0x4E74, 0x4E75, 0x4E79, 0x4E7F, 0x4E8D, 0x4E96, 0x4E97,
- 0x4E9D, 0x4EAF, 0x4EB9, 0x4EC3, 0x4ED0, 0x4EDA, 0x4EDB, 0x4EE0,
- 0x4EE1, 0x4EE2, 0x4EE8, 0x4EEF, 0x4EF1, 0x4EF3, 0x4EF5, 0x4EFD,
- 0x4EFE, 0x4EFF, 0x4F00, 0x4F02, 0x4F03, 0x4F08, 0x4F0B, 0x4F0C,
- 0x4F12, 0x4F15, 0x4F16, 0x4F17, 0x4F19, 0x4F2E, 0x4F31, 0x4F60,
- 0x4F33, 0x4F35, 0x4F37, 0x4F39, 0x4F3B, 0x4F3E, 0x4F40, 0x4F42,
- 0x4F48, 0x4F49, 0x4F4B, 0x4F4C, 0x4F52, 0x4F54, 0x4F56, 0x4F58,
- 0x4F5F, 0x4F63, 0x4F6A, 0x4F6C, 0x4F6E, 0x4F71, 0x4F77, 0x4F78,
- 0x4F79, 0x4F7A, 0x4F7D, 0x4F7E, 0x4F81, 0x4F82, 0x4F84,
-};
-static const unsigned short euc_to_utf8_8FB1[] = {
- 0x4F85, 0x4F89, 0x4F8A, 0x4F8C, 0x4F8E, 0x4F90, 0x4F92,
- 0x4F93, 0x4F94, 0x4F97, 0x4F99, 0x4F9A, 0x4F9E, 0x4F9F, 0x4FB2,
- 0x4FB7, 0x4FB9, 0x4FBB, 0x4FBC, 0x4FBD, 0x4FBE, 0x4FC0, 0x4FC1,
- 0x4FC5, 0x4FC6, 0x4FC8, 0x4FC9, 0x4FCB, 0x4FCC, 0x4FCD, 0x4FCF,
- 0x4FD2, 0x4FDC, 0x4FE0, 0x4FE2, 0x4FF0, 0x4FF2, 0x4FFC, 0x4FFD,
- 0x4FFF, 0x5000, 0x5001, 0x5004, 0x5007, 0x500A, 0x500C, 0x500E,
- 0x5010, 0x5013, 0x5017, 0x5018, 0x501B, 0x501C, 0x501D, 0x501E,
- 0x5022, 0x5027, 0x502E, 0x5030, 0x5032, 0x5033, 0x5035, 0x5040,
- 0x5041, 0x5042, 0x5045, 0x5046, 0x504A, 0x504C, 0x504E, 0x5051,
- 0x5052, 0x5053, 0x5057, 0x5059, 0x505F, 0x5060, 0x5062, 0x5063,
- 0x5066, 0x5067, 0x506A, 0x506D, 0x5070, 0x5071, 0x503B, 0x5081,
- 0x5083, 0x5084, 0x5086, 0x508A, 0x508E, 0x508F, 0x5090,
-};
-static const unsigned short euc_to_utf8_8FB2[] = {
- 0x5092, 0x5093, 0x5094, 0x5096, 0x509B, 0x509C, 0x509E,
- 0x509F, 0x50A0, 0x50A1, 0x50A2, 0x50AA, 0x50AF, 0x50B0, 0x50B9,
- 0x50BA, 0x50BD, 0x50C0, 0x50C3, 0x50C4, 0x50C7, 0x50CC, 0x50CE,
- 0x50D0, 0x50D3, 0x50D4, 0x50D8, 0x50DC, 0x50DD, 0x50DF, 0x50E2,
- 0x50E4, 0x50E6, 0x50E8, 0x50E9, 0x50EF, 0x50F1, 0x50F6, 0x50FA,
- 0x50FE, 0x5103, 0x5106, 0x5107, 0x5108, 0x510B, 0x510C, 0x510D,
- 0x510E, 0x50F2, 0x5110, 0x5117, 0x5119, 0x511B, 0x511C, 0x511D,
- 0x511E, 0x5123, 0x5127, 0x5128, 0x512C, 0x512D, 0x512F, 0x5131,
- 0x5133, 0x5134, 0x5135, 0x5138, 0x5139, 0x5142, 0x514A, 0x514F,
- 0x5153, 0x5155, 0x5157, 0x5158, 0x515F, 0x5164, 0x5166, 0x517E,
- 0x5183, 0x5184, 0x518B, 0x518E, 0x5198, 0x519D, 0x51A1, 0x51A3,
- 0x51AD, 0x51B8, 0x51BA, 0x51BC, 0x51BE, 0x51BF, 0x51C2,
-};
-static const unsigned short euc_to_utf8_8FB3[] = {
- 0x51C8, 0x51CF, 0x51D1, 0x51D2, 0x51D3, 0x51D5, 0x51D8,
- 0x51DE, 0x51E2, 0x51E5, 0x51EE, 0x51F2, 0x51F3, 0x51F4, 0x51F7,
- 0x5201, 0x5202, 0x5205, 0x5212, 0x5213, 0x5215, 0x5216, 0x5218,
- 0x5222, 0x5228, 0x5231, 0x5232, 0x5235, 0x523C, 0x5245, 0x5249,
- 0x5255, 0x5257, 0x5258, 0x525A, 0x525C, 0x525F, 0x5260, 0x5261,
- 0x5266, 0x526E, 0x5277, 0x5278, 0x5279, 0x5280, 0x5282, 0x5285,
- 0x528A, 0x528C, 0x5293, 0x5295, 0x5296, 0x5297, 0x5298, 0x529A,
- 0x529C, 0x52A4, 0x52A5, 0x52A6, 0x52A7, 0x52AF, 0x52B0, 0x52B6,
- 0x52B7, 0x52B8, 0x52BA, 0x52BB, 0x52BD, 0x52C0, 0x52C4, 0x52C6,
- 0x52C8, 0x52CC, 0x52CF, 0x52D1, 0x52D4, 0x52D6, 0x52DB, 0x52DC,
- 0x52E1, 0x52E5, 0x52E8, 0x52E9, 0x52EA, 0x52EC, 0x52F0, 0x52F1,
- 0x52F4, 0x52F6, 0x52F7, 0x5300, 0x5303, 0x530A, 0x530B,
-};
-static const unsigned short euc_to_utf8_8FB4[] = {
- 0x530C, 0x5311, 0x5313, 0x5318, 0x531B, 0x531C, 0x531E,
- 0x531F, 0x5325, 0x5327, 0x5328, 0x5329, 0x532B, 0x532C, 0x532D,
- 0x5330, 0x5332, 0x5335, 0x533C, 0x533D, 0x533E, 0x5342, 0x534C,
- 0x534B, 0x5359, 0x535B, 0x5361, 0x5363, 0x5365, 0x536C, 0x536D,
- 0x5372, 0x5379, 0x537E, 0x5383, 0x5387, 0x5388, 0x538E, 0x5393,
- 0x5394, 0x5399, 0x539D, 0x53A1, 0x53A4, 0x53AA, 0x53AB, 0x53AF,
- 0x53B2, 0x53B4, 0x53B5, 0x53B7, 0x53B8, 0x53BA, 0x53BD, 0x53C0,
- 0x53C5, 0x53CF, 0x53D2, 0x53D3, 0x53D5, 0x53DA, 0x53DD, 0x53DE,
- 0x53E0, 0x53E6, 0x53E7, 0x53F5, 0x5402, 0x5413, 0x541A, 0x5421,
- 0x5427, 0x5428, 0x542A, 0x542F, 0x5431, 0x5434, 0x5435, 0x5443,
- 0x5444, 0x5447, 0x544D, 0x544F, 0x545E, 0x5462, 0x5464, 0x5466,
- 0x5467, 0x5469, 0x546B, 0x546D, 0x546E, 0x5474, 0x547F,
-};
-static const unsigned short euc_to_utf8_8FB5[] = {
- 0x5481, 0x5483, 0x5485, 0x5488, 0x5489, 0x548D, 0x5491,
- 0x5495, 0x5496, 0x549C, 0x549F, 0x54A1, 0x54A6, 0x54A7, 0x54A9,
- 0x54AA, 0x54AD, 0x54AE, 0x54B1, 0x54B7, 0x54B9, 0x54BA, 0x54BB,
- 0x54BF, 0x54C6, 0x54CA, 0x54CD, 0x54CE, 0x54E0, 0x54EA, 0x54EC,
- 0x54EF, 0x54F6, 0x54FC, 0x54FE, 0x54FF, 0x5500, 0x5501, 0x5505,
- 0x5508, 0x5509, 0x550C, 0x550D, 0x550E, 0x5515, 0x552A, 0x552B,
- 0x5532, 0x5535, 0x5536, 0x553B, 0x553C, 0x553D, 0x5541, 0x5547,
- 0x5549, 0x554A, 0x554D, 0x5550, 0x5551, 0x5558, 0x555A, 0x555B,
- 0x555E, 0x5560, 0x5561, 0x5564, 0x5566, 0x557F, 0x5581, 0x5582,
- 0x5586, 0x5588, 0x558E, 0x558F, 0x5591, 0x5592, 0x5593, 0x5594,
- 0x5597, 0x55A3, 0x55A4, 0x55AD, 0x55B2, 0x55BF, 0x55C1, 0x55C3,
- 0x55C6, 0x55C9, 0x55CB, 0x55CC, 0x55CE, 0x55D1, 0x55D2,
-};
-static const unsigned short euc_to_utf8_8FB6[] = {
- 0x55D3, 0x55D7, 0x55D8, 0x55DB, 0x55DE, 0x55E2, 0x55E9,
- 0x55F6, 0x55FF, 0x5605, 0x5608, 0x560A, 0x560D, 0x560E, 0x560F,
- 0x5610, 0x5611, 0x5612, 0x5619, 0x562C, 0x5630, 0x5633, 0x5635,
- 0x5637, 0x5639, 0x563B, 0x563C, 0x563D, 0x563F, 0x5640, 0x5641,
- 0x5643, 0x5644, 0x5646, 0x5649, 0x564B, 0x564D, 0x564F, 0x5654,
- 0x565E, 0x5660, 0x5661, 0x5662, 0x5663, 0x5666, 0x5669, 0x566D,
- 0x566F, 0x5671, 0x5672, 0x5675, 0x5684, 0x5685, 0x5688, 0x568B,
- 0x568C, 0x5695, 0x5699, 0x569A, 0x569D, 0x569E, 0x569F, 0x56A6,
- 0x56A7, 0x56A8, 0x56A9, 0x56AB, 0x56AC, 0x56AD, 0x56B1, 0x56B3,
- 0x56B7, 0x56BE, 0x56C5, 0x56C9, 0x56CA, 0x56CB, 0x56CF, 0x56D0,
- 0x56CC, 0x56CD, 0x56D9, 0x56DC, 0x56DD, 0x56DF, 0x56E1, 0x56E4,
- 0x56E5, 0x56E6, 0x56E7, 0x56E8, 0x56F1, 0x56EB, 0x56ED,
-};
-static const unsigned short euc_to_utf8_8FB7[] = {
- 0x56F6, 0x56F7, 0x5701, 0x5702, 0x5707, 0x570A, 0x570C,
- 0x5711, 0x5715, 0x571A, 0x571B, 0x571D, 0x5720, 0x5722, 0x5723,
- 0x5724, 0x5725, 0x5729, 0x572A, 0x572C, 0x572E, 0x572F, 0x5733,
- 0x5734, 0x573D, 0x573E, 0x573F, 0x5745, 0x5746, 0x574C, 0x574D,
- 0x5752, 0x5762, 0x5765, 0x5767, 0x5768, 0x576B, 0x576D, 0x576E,
- 0x576F, 0x5770, 0x5771, 0x5773, 0x5774, 0x5775, 0x5777, 0x5779,
- 0x577A, 0x577B, 0x577C, 0x577E, 0x5781, 0x5783, 0x578C, 0x5794,
- 0x5797, 0x5799, 0x579A, 0x579C, 0x579D, 0x579E, 0x579F, 0x57A1,
- 0x5795, 0x57A7, 0x57A8, 0x57A9, 0x57AC, 0x57B8, 0x57BD, 0x57C7,
- 0x57C8, 0x57CC, 0x57CF, 0x57D5, 0x57DD, 0x57DE, 0x57E4, 0x57E6,
- 0x57E7, 0x57E9, 0x57ED, 0x57F0, 0x57F5, 0x57F6, 0x57F8, 0x57FD,
- 0x57FE, 0x57FF, 0x5803, 0x5804, 0x5808, 0x5809, 0x57E1,
-};
-static const unsigned short euc_to_utf8_8FB8[] = {
- 0x580C, 0x580D, 0x581B, 0x581E, 0x581F, 0x5820, 0x5826,
- 0x5827, 0x582D, 0x5832, 0x5839, 0x583F, 0x5849, 0x584C, 0x584D,
- 0x584F, 0x5850, 0x5855, 0x585F, 0x5861, 0x5864, 0x5867, 0x5868,
- 0x5878, 0x587C, 0x587F, 0x5880, 0x5881, 0x5887, 0x5888, 0x5889,
- 0x588A, 0x588C, 0x588D, 0x588F, 0x5890, 0x5894, 0x5896, 0x589D,
- 0x58A0, 0x58A1, 0x58A2, 0x58A6, 0x58A9, 0x58B1, 0x58B2, 0x58C4,
- 0x58BC, 0x58C2, 0x58C8, 0x58CD, 0x58CE, 0x58D0, 0x58D2, 0x58D4,
- 0x58D6, 0x58DA, 0x58DD, 0x58E1, 0x58E2, 0x58E9, 0x58F3, 0x5905,
- 0x5906, 0x590B, 0x590C, 0x5912, 0x5913, 0x5914, 0x8641, 0x591D,
- 0x5921, 0x5923, 0x5924, 0x5928, 0x592F, 0x5930, 0x5933, 0x5935,
- 0x5936, 0x593F, 0x5943, 0x5946, 0x5952, 0x5953, 0x5959, 0x595B,
- 0x595D, 0x595E, 0x595F, 0x5961, 0x5963, 0x596B, 0x596D,
-};
-static const unsigned short euc_to_utf8_8FB9[] = {
- 0x596F, 0x5972, 0x5975, 0x5976, 0x5979, 0x597B, 0x597C,
- 0x598B, 0x598C, 0x598E, 0x5992, 0x5995, 0x5997, 0x599F, 0x59A4,
- 0x59A7, 0x59AD, 0x59AE, 0x59AF, 0x59B0, 0x59B3, 0x59B7, 0x59BA,
- 0x59BC, 0x59C1, 0x59C3, 0x59C4, 0x59C8, 0x59CA, 0x59CD, 0x59D2,
- 0x59DD, 0x59DE, 0x59DF, 0x59E3, 0x59E4, 0x59E7, 0x59EE, 0x59EF,
- 0x59F1, 0x59F2, 0x59F4, 0x59F7, 0x5A00, 0x5A04, 0x5A0C, 0x5A0D,
- 0x5A0E, 0x5A12, 0x5A13, 0x5A1E, 0x5A23, 0x5A24, 0x5A27, 0x5A28,
- 0x5A2A, 0x5A2D, 0x5A30, 0x5A44, 0x5A45, 0x5A47, 0x5A48, 0x5A4C,
- 0x5A50, 0x5A55, 0x5A5E, 0x5A63, 0x5A65, 0x5A67, 0x5A6D, 0x5A77,
- 0x5A7A, 0x5A7B, 0x5A7E, 0x5A8B, 0x5A90, 0x5A93, 0x5A96, 0x5A99,
- 0x5A9C, 0x5A9E, 0x5A9F, 0x5AA0, 0x5AA2, 0x5AA7, 0x5AAC, 0x5AB1,
- 0x5AB2, 0x5AB3, 0x5AB5, 0x5AB8, 0x5ABA, 0x5ABB, 0x5ABF,
-};
-static const unsigned short euc_to_utf8_8FBA[] = {
- 0x5AC4, 0x5AC6, 0x5AC8, 0x5ACF, 0x5ADA, 0x5ADC, 0x5AE0,
- 0x5AE5, 0x5AEA, 0x5AEE, 0x5AF5, 0x5AF6, 0x5AFD, 0x5B00, 0x5B01,
- 0x5B08, 0x5B17, 0x5B34, 0x5B19, 0x5B1B, 0x5B1D, 0x5B21, 0x5B25,
- 0x5B2D, 0x5B38, 0x5B41, 0x5B4B, 0x5B4C, 0x5B52, 0x5B56, 0x5B5E,
- 0x5B68, 0x5B6E, 0x5B6F, 0x5B7C, 0x5B7D, 0x5B7E, 0x5B7F, 0x5B81,
- 0x5B84, 0x5B86, 0x5B8A, 0x5B8E, 0x5B90, 0x5B91, 0x5B93, 0x5B94,
- 0x5B96, 0x5BA8, 0x5BA9, 0x5BAC, 0x5BAD, 0x5BAF, 0x5BB1, 0x5BB2,
- 0x5BB7, 0x5BBA, 0x5BBC, 0x5BC0, 0x5BC1, 0x5BCD, 0x5BCF, 0x5BD6,
- 0x5BD7, 0x5BD8, 0x5BD9, 0x5BDA, 0x5BE0, 0x5BEF, 0x5BF1, 0x5BF4,
- 0x5BFD, 0x5C0C, 0x5C17, 0x5C1E, 0x5C1F, 0x5C23, 0x5C26, 0x5C29,
- 0x5C2B, 0x5C2C, 0x5C2E, 0x5C30, 0x5C32, 0x5C35, 0x5C36, 0x5C59,
- 0x5C5A, 0x5C5C, 0x5C62, 0x5C63, 0x5C67, 0x5C68, 0x5C69,
-};
-static const unsigned short euc_to_utf8_8FBB[] = {
- 0x5C6D, 0x5C70, 0x5C74, 0x5C75, 0x5C7A, 0x5C7B, 0x5C7C,
- 0x5C7D, 0x5C87, 0x5C88, 0x5C8A, 0x5C8F, 0x5C92, 0x5C9D, 0x5C9F,
- 0x5CA0, 0x5CA2, 0x5CA3, 0x5CA6, 0x5CAA, 0x5CB2, 0x5CB4, 0x5CB5,
- 0x5CBA, 0x5CC9, 0x5CCB, 0x5CD2, 0x5CDD, 0x5CD7, 0x5CEE, 0x5CF1,
- 0x5CF2, 0x5CF4, 0x5D01, 0x5D06, 0x5D0D, 0x5D12, 0x5D2B, 0x5D23,
- 0x5D24, 0x5D26, 0x5D27, 0x5D31, 0x5D34, 0x5D39, 0x5D3D, 0x5D3F,
- 0x5D42, 0x5D43, 0x5D46, 0x5D48, 0x5D55, 0x5D51, 0x5D59, 0x5D4A,
- 0x5D5F, 0x5D60, 0x5D61, 0x5D62, 0x5D64, 0x5D6A, 0x5D6D, 0x5D70,
- 0x5D79, 0x5D7A, 0x5D7E, 0x5D7F, 0x5D81, 0x5D83, 0x5D88, 0x5D8A,
- 0x5D92, 0x5D93, 0x5D94, 0x5D95, 0x5D99, 0x5D9B, 0x5D9F, 0x5DA0,
- 0x5DA7, 0x5DAB, 0x5DB0, 0x5DB4, 0x5DB8, 0x5DB9, 0x5DC3, 0x5DC7,
- 0x5DCB, 0x5DD0, 0x5DCE, 0x5DD8, 0x5DD9, 0x5DE0, 0x5DE4,
-};
-static const unsigned short euc_to_utf8_8FBC[] = {
- 0x5DE9, 0x5DF8, 0x5DF9, 0x5E00, 0x5E07, 0x5E0D, 0x5E12,
- 0x5E14, 0x5E15, 0x5E18, 0x5E1F, 0x5E20, 0x5E2E, 0x5E28, 0x5E32,
- 0x5E35, 0x5E3E, 0x5E4B, 0x5E50, 0x5E49, 0x5E51, 0x5E56, 0x5E58,
- 0x5E5B, 0x5E5C, 0x5E5E, 0x5E68, 0x5E6A, 0x5E6B, 0x5E6C, 0x5E6D,
- 0x5E6E, 0x5E70, 0x5E80, 0x5E8B, 0x5E8E, 0x5EA2, 0x5EA4, 0x5EA5,
- 0x5EA8, 0x5EAA, 0x5EAC, 0x5EB1, 0x5EB3, 0x5EBD, 0x5EBE, 0x5EBF,
- 0x5EC6, 0x5ECC, 0x5ECB, 0x5ECE, 0x5ED1, 0x5ED2, 0x5ED4, 0x5ED5,
- 0x5EDC, 0x5EDE, 0x5EE5, 0x5EEB, 0x5F02, 0x5F06, 0x5F07, 0x5F08,
- 0x5F0E, 0x5F19, 0x5F1C, 0x5F1D, 0x5F21, 0x5F22, 0x5F23, 0x5F24,
- 0x5F28, 0x5F2B, 0x5F2C, 0x5F2E, 0x5F30, 0x5F34, 0x5F36, 0x5F3B,
- 0x5F3D, 0x5F3F, 0x5F40, 0x5F44, 0x5F45, 0x5F47, 0x5F4D, 0x5F50,
- 0x5F54, 0x5F58, 0x5F5B, 0x5F60, 0x5F63, 0x5F64, 0x5F67,
-};
-static const unsigned short euc_to_utf8_8FBD[] = {
- 0x5F6F, 0x5F72, 0x5F74, 0x5F75, 0x5F78, 0x5F7A, 0x5F7D,
- 0x5F7E, 0x5F89, 0x5F8D, 0x5F8F, 0x5F96, 0x5F9C, 0x5F9D, 0x5FA2,
- 0x5FA7, 0x5FAB, 0x5FA4, 0x5FAC, 0x5FAF, 0x5FB0, 0x5FB1, 0x5FB8,
- 0x5FC4, 0x5FC7, 0x5FC8, 0x5FC9, 0x5FCB, 0x5FD0, 0x5FD1, 0x5FD2,
- 0x5FD3, 0x5FD4, 0x5FDE, 0x5FE1, 0x5FE2, 0x5FE8, 0x5FE9, 0x5FEA,
- 0x5FEC, 0x5FED, 0x5FEE, 0x5FEF, 0x5FF2, 0x5FF3, 0x5FF6, 0x5FFA,
- 0x5FFC, 0x6007, 0x600A, 0x600D, 0x6013, 0x6014, 0x6017, 0x6018,
- 0x601A, 0x601F, 0x6024, 0x602D, 0x6033, 0x6035, 0x6040, 0x6047,
- 0x6048, 0x6049, 0x604C, 0x6051, 0x6054, 0x6056, 0x6057, 0x605D,
- 0x6061, 0x6067, 0x6071, 0x607E, 0x607F, 0x6082, 0x6086, 0x6088,
- 0x608A, 0x608E, 0x6091, 0x6093, 0x6095, 0x6098, 0x609D, 0x609E,
- 0x60A2, 0x60A4, 0x60A5, 0x60A8, 0x60B0, 0x60B1, 0x60B7,
-};
-static const unsigned short euc_to_utf8_8FBE[] = {
- 0x60BB, 0x60BE, 0x60C2, 0x60C4, 0x60C8, 0x60C9, 0x60CA,
- 0x60CB, 0x60CE, 0x60CF, 0x60D4, 0x60D5, 0x60D9, 0x60DB, 0x60DD,
- 0x60DE, 0x60E2, 0x60E5, 0x60F2, 0x60F5, 0x60F8, 0x60FC, 0x60FD,
- 0x6102, 0x6107, 0x610A, 0x610C, 0x6110, 0x6111, 0x6112, 0x6113,
- 0x6114, 0x6116, 0x6117, 0x6119, 0x611C, 0x611E, 0x6122, 0x612A,
- 0x612B, 0x6130, 0x6131, 0x6135, 0x6136, 0x6137, 0x6139, 0x6141,
- 0x6145, 0x6146, 0x6149, 0x615E, 0x6160, 0x616C, 0x6172, 0x6178,
- 0x617B, 0x617C, 0x617F, 0x6180, 0x6181, 0x6183, 0x6184, 0x618B,
- 0x618D, 0x6192, 0x6193, 0x6197, 0x6198, 0x619C, 0x619D, 0x619F,
- 0x61A0, 0x61A5, 0x61A8, 0x61AA, 0x61AD, 0x61B8, 0x61B9, 0x61BC,
- 0x61C0, 0x61C1, 0x61C2, 0x61CE, 0x61CF, 0x61D5, 0x61DC, 0x61DD,
- 0x61DE, 0x61DF, 0x61E1, 0x61E2, 0x61E7, 0x61E9, 0x61E5,
-};
-static const unsigned short euc_to_utf8_8FBF[] = {
- 0x61EC, 0x61ED, 0x61EF, 0x6201, 0x6203, 0x6204, 0x6207,
- 0x6213, 0x6215, 0x621C, 0x6220, 0x6222, 0x6223, 0x6227, 0x6229,
- 0x622B, 0x6239, 0x623D, 0x6242, 0x6243, 0x6244, 0x6246, 0x624C,
- 0x6250, 0x6251, 0x6252, 0x6254, 0x6256, 0x625A, 0x625C, 0x6264,
- 0x626D, 0x626F, 0x6273, 0x627A, 0x627D, 0x628D, 0x628E, 0x628F,
- 0x6290, 0x62A6, 0x62A8, 0x62B3, 0x62B6, 0x62B7, 0x62BA, 0x62BE,
- 0x62BF, 0x62C4, 0x62CE, 0x62D5, 0x62D6, 0x62DA, 0x62EA, 0x62F2,
- 0x62F4, 0x62FC, 0x62FD, 0x6303, 0x6304, 0x630A, 0x630B, 0x630D,
- 0x6310, 0x6313, 0x6316, 0x6318, 0x6329, 0x632A, 0x632D, 0x6335,
- 0x6336, 0x6339, 0x633C, 0x6341, 0x6342, 0x6343, 0x6344, 0x6346,
- 0x634A, 0x634B, 0x634E, 0x6352, 0x6353, 0x6354, 0x6358, 0x635B,
- 0x6365, 0x6366, 0x636C, 0x636D, 0x6371, 0x6374, 0x6375,
-};
-static const unsigned short euc_to_utf8_8FC0[] = {
- 0x6378, 0x637C, 0x637D, 0x637F, 0x6382, 0x6384, 0x6387,
- 0x638A, 0x6390, 0x6394, 0x6395, 0x6399, 0x639A, 0x639E, 0x63A4,
- 0x63A6, 0x63AD, 0x63AE, 0x63AF, 0x63BD, 0x63C1, 0x63C5, 0x63C8,
- 0x63CE, 0x63D1, 0x63D3, 0x63D4, 0x63D5, 0x63DC, 0x63E0, 0x63E5,
- 0x63EA, 0x63EC, 0x63F2, 0x63F3, 0x63F5, 0x63F8, 0x63F9, 0x6409,
- 0x640A, 0x6410, 0x6412, 0x6414, 0x6418, 0x641E, 0x6420, 0x6422,
- 0x6424, 0x6425, 0x6429, 0x642A, 0x642F, 0x6430, 0x6435, 0x643D,
- 0x643F, 0x644B, 0x644F, 0x6451, 0x6452, 0x6453, 0x6454, 0x645A,
- 0x645B, 0x645C, 0x645D, 0x645F, 0x6460, 0x6461, 0x6463, 0x646D,
- 0x6473, 0x6474, 0x647B, 0x647D, 0x6485, 0x6487, 0x648F, 0x6490,
- 0x6491, 0x6498, 0x6499, 0x649B, 0x649D, 0x649F, 0x64A1, 0x64A3,
- 0x64A6, 0x64A8, 0x64AC, 0x64B3, 0x64BD, 0x64BE, 0x64BF,
-};
-static const unsigned short euc_to_utf8_8FC1[] = {
- 0x64C4, 0x64C9, 0x64CA, 0x64CB, 0x64CC, 0x64CE, 0x64D0,
- 0x64D1, 0x64D5, 0x64D7, 0x64E4, 0x64E5, 0x64E9, 0x64EA, 0x64ED,
- 0x64F0, 0x64F5, 0x64F7, 0x64FB, 0x64FF, 0x6501, 0x6504, 0x6508,
- 0x6509, 0x650A, 0x650F, 0x6513, 0x6514, 0x6516, 0x6519, 0x651B,
- 0x651E, 0x651F, 0x6522, 0x6526, 0x6529, 0x652E, 0x6531, 0x653A,
- 0x653C, 0x653D, 0x6543, 0x6547, 0x6549, 0x6550, 0x6552, 0x6554,
- 0x655F, 0x6560, 0x6567, 0x656B, 0x657A, 0x657D, 0x6581, 0x6585,
- 0x658A, 0x6592, 0x6595, 0x6598, 0x659D, 0x65A0, 0x65A3, 0x65A6,
- 0x65AE, 0x65B2, 0x65B3, 0x65B4, 0x65BF, 0x65C2, 0x65C8, 0x65C9,
- 0x65CE, 0x65D0, 0x65D4, 0x65D6, 0x65D8, 0x65DF, 0x65F0, 0x65F2,
- 0x65F4, 0x65F5, 0x65F9, 0x65FE, 0x65FF, 0x6600, 0x6604, 0x6608,
- 0x6609, 0x660D, 0x6611, 0x6612, 0x6615, 0x6616, 0x661D,
-};
-static const unsigned short euc_to_utf8_8FC2[] = {
- 0x661E, 0x6621, 0x6622, 0x6623, 0x6624, 0x6626, 0x6629,
- 0x662A, 0x662B, 0x662C, 0x662E, 0x6630, 0x6631, 0x6633, 0x6639,
- 0x6637, 0x6640, 0x6645, 0x6646, 0x664A, 0x664C, 0x6651, 0x664E,
- 0x6657, 0x6658, 0x6659, 0x665B, 0x665C, 0x6660, 0x6661, 0x66FB,
- 0x666A, 0x666B, 0x666C, 0x667E, 0x6673, 0x6675, 0x667F, 0x6677,
- 0x6678, 0x6679, 0x667B, 0x6680, 0x667C, 0x668B, 0x668C, 0x668D,
- 0x6690, 0x6692, 0x6699, 0x669A, 0x669B, 0x669C, 0x669F, 0x66A0,
- 0x66A4, 0x66AD, 0x66B1, 0x66B2, 0x66B5, 0x66BB, 0x66BF, 0x66C0,
- 0x66C2, 0x66C3, 0x66C8, 0x66CC, 0x66CE, 0x66CF, 0x66D4, 0x66DB,
- 0x66DF, 0x66E8, 0x66EB, 0x66EC, 0x66EE, 0x66FA, 0x6705, 0x6707,
- 0x670E, 0x6713, 0x6719, 0x671C, 0x6720, 0x6722, 0x6733, 0x673E,
- 0x6745, 0x6747, 0x6748, 0x674C, 0x6754, 0x6755, 0x675D,
-};
-static const unsigned short euc_to_utf8_8FC3[] = {
- 0x6766, 0x676C, 0x676E, 0x6774, 0x6776, 0x677B, 0x6781,
- 0x6784, 0x678E, 0x678F, 0x6791, 0x6793, 0x6796, 0x6798, 0x6799,
- 0x679B, 0x67B0, 0x67B1, 0x67B2, 0x67B5, 0x67BB, 0x67BC, 0x67BD,
- 0x67F9, 0x67C0, 0x67C2, 0x67C3, 0x67C5, 0x67C8, 0x67C9, 0x67D2,
- 0x67D7, 0x67D9, 0x67DC, 0x67E1, 0x67E6, 0x67F0, 0x67F2, 0x67F6,
- 0x67F7, 0x6852, 0x6814, 0x6819, 0x681D, 0x681F, 0x6828, 0x6827,
- 0x682C, 0x682D, 0x682F, 0x6830, 0x6831, 0x6833, 0x683B, 0x683F,
- 0x6844, 0x6845, 0x684A, 0x684C, 0x6855, 0x6857, 0x6858, 0x685B,
- 0x686B, 0x686E, 0x686F, 0x6870, 0x6871, 0x6872, 0x6875, 0x6879,
- 0x687A, 0x687B, 0x687C, 0x6882, 0x6884, 0x6886, 0x6888, 0x6896,
- 0x6898, 0x689A, 0x689C, 0x68A1, 0x68A3, 0x68A5, 0x68A9, 0x68AA,
- 0x68AE, 0x68B2, 0x68BB, 0x68C5, 0x68C8, 0x68CC, 0x68CF,
-};
-static const unsigned short euc_to_utf8_8FC4[] = {
- 0x68D0, 0x68D1, 0x68D3, 0x68D6, 0x68D9, 0x68DC, 0x68DD,
- 0x68E5, 0x68E8, 0x68EA, 0x68EB, 0x68EC, 0x68ED, 0x68F0, 0x68F1,
- 0x68F5, 0x68F6, 0x68FB, 0x68FC, 0x68FD, 0x6906, 0x6909, 0x690A,
- 0x6910, 0x6911, 0x6913, 0x6916, 0x6917, 0x6931, 0x6933, 0x6935,
- 0x6938, 0x693B, 0x6942, 0x6945, 0x6949, 0x694E, 0x6957, 0x695B,
- 0x6963, 0x6964, 0x6965, 0x6966, 0x6968, 0x6969, 0x696C, 0x6970,
- 0x6971, 0x6972, 0x697A, 0x697B, 0x697F, 0x6980, 0x698D, 0x6992,
- 0x6996, 0x6998, 0x69A1, 0x69A5, 0x69A6, 0x69A8, 0x69AB, 0x69AD,
- 0x69AF, 0x69B7, 0x69B8, 0x69BA, 0x69BC, 0x69C5, 0x69C8, 0x69D1,
- 0x69D6, 0x69D7, 0x69E2, 0x69E5, 0x69EE, 0x69EF, 0x69F1, 0x69F3,
- 0x69F5, 0x69FE, 0x6A00, 0x6A01, 0x6A03, 0x6A0F, 0x6A11, 0x6A15,
- 0x6A1A, 0x6A1D, 0x6A20, 0x6A24, 0x6A28, 0x6A30, 0x6A32,
-};
-static const unsigned short euc_to_utf8_8FC5[] = {
- 0x6A34, 0x6A37, 0x6A3B, 0x6A3E, 0x6A3F, 0x6A45, 0x6A46,
- 0x6A49, 0x6A4A, 0x6A4E, 0x6A50, 0x6A51, 0x6A52, 0x6A55, 0x6A56,
- 0x6A5B, 0x6A64, 0x6A67, 0x6A6A, 0x6A71, 0x6A73, 0x6A7E, 0x6A81,
- 0x6A83, 0x6A86, 0x6A87, 0x6A89, 0x6A8B, 0x6A91, 0x6A9B, 0x6A9D,
- 0x6A9E, 0x6A9F, 0x6AA5, 0x6AAB, 0x6AAF, 0x6AB0, 0x6AB1, 0x6AB4,
- 0x6ABD, 0x6ABE, 0x6ABF, 0x6AC6, 0x6AC9, 0x6AC8, 0x6ACC, 0x6AD0,
- 0x6AD4, 0x6AD5, 0x6AD6, 0x6ADC, 0x6ADD, 0x6AE4, 0x6AE7, 0x6AEC,
- 0x6AF0, 0x6AF1, 0x6AF2, 0x6AFC, 0x6AFD, 0x6B02, 0x6B03, 0x6B06,
- 0x6B07, 0x6B09, 0x6B0F, 0x6B10, 0x6B11, 0x6B17, 0x6B1B, 0x6B1E,
- 0x6B24, 0x6B28, 0x6B2B, 0x6B2C, 0x6B2F, 0x6B35, 0x6B36, 0x6B3B,
- 0x6B3F, 0x6B46, 0x6B4A, 0x6B4D, 0x6B52, 0x6B56, 0x6B58, 0x6B5D,
- 0x6B60, 0x6B67, 0x6B6B, 0x6B6E, 0x6B70, 0x6B75, 0x6B7D,
-};
-static const unsigned short euc_to_utf8_8FC6[] = {
- 0x6B7E, 0x6B82, 0x6B85, 0x6B97, 0x6B9B, 0x6B9F, 0x6BA0,
- 0x6BA2, 0x6BA3, 0x6BA8, 0x6BA9, 0x6BAC, 0x6BAD, 0x6BAE, 0x6BB0,
- 0x6BB8, 0x6BB9, 0x6BBD, 0x6BBE, 0x6BC3, 0x6BC4, 0x6BC9, 0x6BCC,
- 0x6BD6, 0x6BDA, 0x6BE1, 0x6BE3, 0x6BE6, 0x6BE7, 0x6BEE, 0x6BF1,
- 0x6BF7, 0x6BF9, 0x6BFF, 0x6C02, 0x6C04, 0x6C05, 0x6C09, 0x6C0D,
- 0x6C0E, 0x6C10, 0x6C12, 0x6C19, 0x6C1F, 0x6C26, 0x6C27, 0x6C28,
- 0x6C2C, 0x6C2E, 0x6C33, 0x6C35, 0x6C36, 0x6C3A, 0x6C3B, 0x6C3F,
- 0x6C4A, 0x6C4B, 0x6C4D, 0x6C4F, 0x6C52, 0x6C54, 0x6C59, 0x6C5B,
- 0x6C5C, 0x6C6B, 0x6C6D, 0x6C6F, 0x6C74, 0x6C76, 0x6C78, 0x6C79,
- 0x6C7B, 0x6C85, 0x6C86, 0x6C87, 0x6C89, 0x6C94, 0x6C95, 0x6C97,
- 0x6C98, 0x6C9C, 0x6C9F, 0x6CB0, 0x6CB2, 0x6CB4, 0x6CC2, 0x6CC6,
- 0x6CCD, 0x6CCF, 0x6CD0, 0x6CD1, 0x6CD2, 0x6CD4, 0x6CD6,
-};
-static const unsigned short euc_to_utf8_8FC7[] = {
- 0x6CDA, 0x6CDC, 0x6CE0, 0x6CE7, 0x6CE9, 0x6CEB, 0x6CEC,
- 0x6CEE, 0x6CF2, 0x6CF4, 0x6D04, 0x6D07, 0x6D0A, 0x6D0E, 0x6D0F,
- 0x6D11, 0x6D13, 0x6D1A, 0x6D26, 0x6D27, 0x6D28, 0x6C67, 0x6D2E,
- 0x6D2F, 0x6D31, 0x6D39, 0x6D3C, 0x6D3F, 0x6D57, 0x6D5E, 0x6D5F,
- 0x6D61, 0x6D65, 0x6D67, 0x6D6F, 0x6D70, 0x6D7C, 0x6D82, 0x6D87,
- 0x6D91, 0x6D92, 0x6D94, 0x6D96, 0x6D97, 0x6D98, 0x6DAA, 0x6DAC,
- 0x6DB4, 0x6DB7, 0x6DB9, 0x6DBD, 0x6DBF, 0x6DC4, 0x6DC8, 0x6DCA,
- 0x6DCE, 0x6DCF, 0x6DD6, 0x6DDB, 0x6DDD, 0x6DDF, 0x6DE0, 0x6DE2,
- 0x6DE5, 0x6DE9, 0x6DEF, 0x6DF0, 0x6DF4, 0x6DF6, 0x6DFC, 0x6E00,
- 0x6E04, 0x6E1E, 0x6E22, 0x6E27, 0x6E32, 0x6E36, 0x6E39, 0x6E3B,
- 0x6E3C, 0x6E44, 0x6E45, 0x6E48, 0x6E49, 0x6E4B, 0x6E4F, 0x6E51,
- 0x6E52, 0x6E53, 0x6E54, 0x6E57, 0x6E5C, 0x6E5D, 0x6E5E,
-};
-static const unsigned short euc_to_utf8_8FC8[] = {
- 0x6E62, 0x6E63, 0x6E68, 0x6E73, 0x6E7B, 0x6E7D, 0x6E8D,
- 0x6E93, 0x6E99, 0x6EA0, 0x6EA7, 0x6EAD, 0x6EAE, 0x6EB1, 0x6EB3,
- 0x6EBB, 0x6EBF, 0x6EC0, 0x6EC1, 0x6EC3, 0x6EC7, 0x6EC8, 0x6ECA,
- 0x6ECD, 0x6ECE, 0x6ECF, 0x6EEB, 0x6EED, 0x6EEE, 0x6EF9, 0x6EFB,
- 0x6EFD, 0x6F04, 0x6F08, 0x6F0A, 0x6F0C, 0x6F0D, 0x6F16, 0x6F18,
- 0x6F1A, 0x6F1B, 0x6F26, 0x6F29, 0x6F2A, 0x6F2F, 0x6F30, 0x6F33,
- 0x6F36, 0x6F3B, 0x6F3C, 0x6F2D, 0x6F4F, 0x6F51, 0x6F52, 0x6F53,
- 0x6F57, 0x6F59, 0x6F5A, 0x6F5D, 0x6F5E, 0x6F61, 0x6F62, 0x6F68,
- 0x6F6C, 0x6F7D, 0x6F7E, 0x6F83, 0x6F87, 0x6F88, 0x6F8B, 0x6F8C,
- 0x6F8D, 0x6F90, 0x6F92, 0x6F93, 0x6F94, 0x6F96, 0x6F9A, 0x6F9F,
- 0x6FA0, 0x6FA5, 0x6FA6, 0x6FA7, 0x6FA8, 0x6FAE, 0x6FAF, 0x6FB0,
- 0x6FB5, 0x6FB6, 0x6FBC, 0x6FC5, 0x6FC7, 0x6FC8, 0x6FCA,
-};
-static const unsigned short euc_to_utf8_8FC9[] = {
- 0x6FDA, 0x6FDE, 0x6FE8, 0x6FE9, 0x6FF0, 0x6FF5, 0x6FF9,
- 0x6FFC, 0x6FFD, 0x7000, 0x7005, 0x7006, 0x7007, 0x700D, 0x7017,
- 0x7020, 0x7023, 0x702F, 0x7034, 0x7037, 0x7039, 0x703C, 0x7043,
- 0x7044, 0x7048, 0x7049, 0x704A, 0x704B, 0x7054, 0x7055, 0x705D,
- 0x705E, 0x704E, 0x7064, 0x7065, 0x706C, 0x706E, 0x7075, 0x7076,
- 0x707E, 0x7081, 0x7085, 0x7086, 0x7094, 0x7095, 0x7096, 0x7097,
- 0x7098, 0x709B, 0x70A4, 0x70AB, 0x70B0, 0x70B1, 0x70B4, 0x70B7,
- 0x70CA, 0x70D1, 0x70D3, 0x70D4, 0x70D5, 0x70D6, 0x70D8, 0x70DC,
- 0x70E4, 0x70FA, 0x7103, 0x7104, 0x7105, 0x7106, 0x7107, 0x710B,
- 0x710C, 0x710F, 0x711E, 0x7120, 0x712B, 0x712D, 0x712F, 0x7130,
- 0x7131, 0x7138, 0x7141, 0x7145, 0x7146, 0x7147, 0x714A, 0x714B,
- 0x7150, 0x7152, 0x7157, 0x715A, 0x715C, 0x715E, 0x7160,
-};
-static const unsigned short euc_to_utf8_8FCA[] = {
- 0x7168, 0x7179, 0x7180, 0x7185, 0x7187, 0x718C, 0x7192,
- 0x719A, 0x719B, 0x71A0, 0x71A2, 0x71AF, 0x71B0, 0x71B2, 0x71B3,
- 0x71BA, 0x71BF, 0x71C0, 0x71C1, 0x71C4, 0x71CB, 0x71CC, 0x71D3,
- 0x71D6, 0x71D9, 0x71DA, 0x71DC, 0x71F8, 0x71FE, 0x7200, 0x7207,
- 0x7208, 0x7209, 0x7213, 0x7217, 0x721A, 0x721D, 0x721F, 0x7224,
- 0x722B, 0x722F, 0x7234, 0x7238, 0x7239, 0x7241, 0x7242, 0x7243,
- 0x7245, 0x724E, 0x724F, 0x7250, 0x7253, 0x7255, 0x7256, 0x725A,
- 0x725C, 0x725E, 0x7260, 0x7263, 0x7268, 0x726B, 0x726E, 0x726F,
- 0x7271, 0x7277, 0x7278, 0x727B, 0x727C, 0x727F, 0x7284, 0x7289,
- 0x728D, 0x728E, 0x7293, 0x729B, 0x72A8, 0x72AD, 0x72AE, 0x72B1,
- 0x72B4, 0x72BE, 0x72C1, 0x72C7, 0x72C9, 0x72CC, 0x72D5, 0x72D6,
- 0x72D8, 0x72DF, 0x72E5, 0x72F3, 0x72F4, 0x72FA, 0x72FB,
-};
-static const unsigned short euc_to_utf8_8FCB[] = {
- 0x72FE, 0x7302, 0x7304, 0x7305, 0x7307, 0x730B, 0x730D,
- 0x7312, 0x7313, 0x7318, 0x7319, 0x731E, 0x7322, 0x7324, 0x7327,
- 0x7328, 0x732C, 0x7331, 0x7332, 0x7335, 0x733A, 0x733B, 0x733D,
- 0x7343, 0x734D, 0x7350, 0x7352, 0x7356, 0x7358, 0x735D, 0x735E,
- 0x735F, 0x7360, 0x7366, 0x7367, 0x7369, 0x736B, 0x736C, 0x736E,
- 0x736F, 0x7371, 0x7377, 0x7379, 0x737C, 0x7380, 0x7381, 0x7383,
- 0x7385, 0x7386, 0x738E, 0x7390, 0x7393, 0x7395, 0x7397, 0x7398,
- 0x739C, 0x739E, 0x739F, 0x73A0, 0x73A2, 0x73A5, 0x73A6, 0x73AA,
- 0x73AB, 0x73AD, 0x73B5, 0x73B7, 0x73B9, 0x73BC, 0x73BD, 0x73BF,
- 0x73C5, 0x73C6, 0x73C9, 0x73CB, 0x73CC, 0x73CF, 0x73D2, 0x73D3,
- 0x73D6, 0x73D9, 0x73DD, 0x73E1, 0x73E3, 0x73E6, 0x73E7, 0x73E9,
- 0x73F4, 0x73F5, 0x73F7, 0x73F9, 0x73FA, 0x73FB, 0x73FD,
-};
-static const unsigned short euc_to_utf8_8FCC[] = {
- 0x73FF, 0x7400, 0x7401, 0x7404, 0x7407, 0x740A, 0x7411,
- 0x741A, 0x741B, 0x7424, 0x7426, 0x7428, 0x7429, 0x742A, 0x742B,
- 0x742C, 0x742D, 0x742E, 0x742F, 0x7430, 0x7431, 0x7439, 0x7440,
- 0x7443, 0x7444, 0x7446, 0x7447, 0x744B, 0x744D, 0x7451, 0x7452,
- 0x7457, 0x745D, 0x7462, 0x7466, 0x7467, 0x7468, 0x746B, 0x746D,
- 0x746E, 0x7471, 0x7472, 0x7480, 0x7481, 0x7485, 0x7486, 0x7487,
- 0x7489, 0x748F, 0x7490, 0x7491, 0x7492, 0x7498, 0x7499, 0x749A,
- 0x749C, 0x749F, 0x74A0, 0x74A1, 0x74A3, 0x74A6, 0x74A8, 0x74A9,
- 0x74AA, 0x74AB, 0x74AE, 0x74AF, 0x74B1, 0x74B2, 0x74B5, 0x74B9,
- 0x74BB, 0x74BF, 0x74C8, 0x74C9, 0x74CC, 0x74D0, 0x74D3, 0x74D8,
- 0x74DA, 0x74DB, 0x74DE, 0x74DF, 0x74E4, 0x74E8, 0x74EA, 0x74EB,
- 0x74EF, 0x74F4, 0x74FA, 0x74FB, 0x74FC, 0x74FF, 0x7506,
-};
-static const unsigned short euc_to_utf8_8FCD[] = {
- 0x7512, 0x7516, 0x7517, 0x7520, 0x7521, 0x7524, 0x7527,
- 0x7529, 0x752A, 0x752F, 0x7536, 0x7539, 0x753D, 0x753E, 0x753F,
- 0x7540, 0x7543, 0x7547, 0x7548, 0x754E, 0x7550, 0x7552, 0x7557,
- 0x755E, 0x755F, 0x7561, 0x756F, 0x7571, 0x7579, 0x757A, 0x757B,
- 0x757C, 0x757D, 0x757E, 0x7581, 0x7585, 0x7590, 0x7592, 0x7593,
- 0x7595, 0x7599, 0x759C, 0x75A2, 0x75A4, 0x75B4, 0x75BA, 0x75BF,
- 0x75C0, 0x75C1, 0x75C4, 0x75C6, 0x75CC, 0x75CE, 0x75CF, 0x75D7,
- 0x75DC, 0x75DF, 0x75E0, 0x75E1, 0x75E4, 0x75E7, 0x75EC, 0x75EE,
- 0x75EF, 0x75F1, 0x75F9, 0x7600, 0x7602, 0x7603, 0x7604, 0x7607,
- 0x7608, 0x760A, 0x760C, 0x760F, 0x7612, 0x7613, 0x7615, 0x7616,
- 0x7619, 0x761B, 0x761C, 0x761D, 0x761E, 0x7623, 0x7625, 0x7626,
- 0x7629, 0x762D, 0x7632, 0x7633, 0x7635, 0x7638, 0x7639,
-};
-static const unsigned short euc_to_utf8_8FCE[] = {
- 0x763A, 0x763C, 0x764A, 0x7640, 0x7641, 0x7643, 0x7644,
- 0x7645, 0x7649, 0x764B, 0x7655, 0x7659, 0x765F, 0x7664, 0x7665,
- 0x766D, 0x766E, 0x766F, 0x7671, 0x7674, 0x7681, 0x7685, 0x768C,
- 0x768D, 0x7695, 0x769B, 0x769C, 0x769D, 0x769F, 0x76A0, 0x76A2,
- 0x76A3, 0x76A4, 0x76A5, 0x76A6, 0x76A7, 0x76A8, 0x76AA, 0x76AD,
- 0x76BD, 0x76C1, 0x76C5, 0x76C9, 0x76CB, 0x76CC, 0x76CE, 0x76D4,
- 0x76D9, 0x76E0, 0x76E6, 0x76E8, 0x76EC, 0x76F0, 0x76F1, 0x76F6,
- 0x76F9, 0x76FC, 0x7700, 0x7706, 0x770A, 0x770E, 0x7712, 0x7714,
- 0x7715, 0x7717, 0x7719, 0x771A, 0x771C, 0x7722, 0x7728, 0x772D,
- 0x772E, 0x772F, 0x7734, 0x7735, 0x7736, 0x7739, 0x773D, 0x773E,
- 0x7742, 0x7745, 0x7746, 0x774A, 0x774D, 0x774E, 0x774F, 0x7752,
- 0x7756, 0x7757, 0x775C, 0x775E, 0x775F, 0x7760, 0x7762,
-};
-static const unsigned short euc_to_utf8_8FCF[] = {
- 0x7764, 0x7767, 0x776A, 0x776C, 0x7770, 0x7772, 0x7773,
- 0x7774, 0x777A, 0x777D, 0x7780, 0x7784, 0x778C, 0x778D, 0x7794,
- 0x7795, 0x7796, 0x779A, 0x779F, 0x77A2, 0x77A7, 0x77AA, 0x77AE,
- 0x77AF, 0x77B1, 0x77B5, 0x77BE, 0x77C3, 0x77C9, 0x77D1, 0x77D2,
- 0x77D5, 0x77D9, 0x77DE, 0x77DF, 0x77E0, 0x77E4, 0x77E6, 0x77EA,
- 0x77EC, 0x77F0, 0x77F1, 0x77F4, 0x77F8, 0x77FB, 0x7805, 0x7806,
- 0x7809, 0x780D, 0x780E, 0x7811, 0x781D, 0x7821, 0x7822, 0x7823,
- 0x782D, 0x782E, 0x7830, 0x7835, 0x7837, 0x7843, 0x7844, 0x7847,
- 0x7848, 0x784C, 0x784E, 0x7852, 0x785C, 0x785E, 0x7860, 0x7861,
- 0x7863, 0x7864, 0x7868, 0x786A, 0x786E, 0x787A, 0x787E, 0x788A,
- 0x788F, 0x7894, 0x7898, 0x78A1, 0x789D, 0x789E, 0x789F, 0x78A4,
- 0x78A8, 0x78AC, 0x78AD, 0x78B0, 0x78B1, 0x78B2, 0x78B3,
-};
-static const unsigned short euc_to_utf8_8FD0[] = {
- 0x78BB, 0x78BD, 0x78BF, 0x78C7, 0x78C8, 0x78C9, 0x78CC,
- 0x78CE, 0x78D2, 0x78D3, 0x78D5, 0x78D6, 0x78E4, 0x78DB, 0x78DF,
- 0x78E0, 0x78E1, 0x78E6, 0x78EA, 0x78F2, 0x78F3, 0x7900, 0x78F6,
- 0x78F7, 0x78FA, 0x78FB, 0x78FF, 0x7906, 0x790C, 0x7910, 0x791A,
- 0x791C, 0x791E, 0x791F, 0x7920, 0x7925, 0x7927, 0x7929, 0x792D,
- 0x7931, 0x7934, 0x7935, 0x793B, 0x793D, 0x793F, 0x7944, 0x7945,
- 0x7946, 0x794A, 0x794B, 0x794F, 0x7951, 0x7954, 0x7958, 0x795B,
- 0x795C, 0x7967, 0x7969, 0x796B, 0x7972, 0x7979, 0x797B, 0x797C,
- 0x797E, 0x798B, 0x798C, 0x7991, 0x7993, 0x7994, 0x7995, 0x7996,
- 0x7998, 0x799B, 0x799C, 0x79A1, 0x79A8, 0x79A9, 0x79AB, 0x79AF,
- 0x79B1, 0x79B4, 0x79B8, 0x79BB, 0x79C2, 0x79C4, 0x79C7, 0x79C8,
- 0x79CA, 0x79CF, 0x79D4, 0x79D6, 0x79DA, 0x79DD, 0x79DE,
-};
-static const unsigned short euc_to_utf8_8FD1[] = {
- 0x79E0, 0x79E2, 0x79E5, 0x79EA, 0x79EB, 0x79ED, 0x79F1,
- 0x79F8, 0x79FC, 0x7A02, 0x7A03, 0x7A07, 0x7A09, 0x7A0A, 0x7A0C,
- 0x7A11, 0x7A15, 0x7A1B, 0x7A1E, 0x7A21, 0x7A27, 0x7A2B, 0x7A2D,
- 0x7A2F, 0x7A30, 0x7A34, 0x7A35, 0x7A38, 0x7A39, 0x7A3A, 0x7A44,
- 0x7A45, 0x7A47, 0x7A48, 0x7A4C, 0x7A55, 0x7A56, 0x7A59, 0x7A5C,
- 0x7A5D, 0x7A5F, 0x7A60, 0x7A65, 0x7A67, 0x7A6A, 0x7A6D, 0x7A75,
- 0x7A78, 0x7A7E, 0x7A80, 0x7A82, 0x7A85, 0x7A86, 0x7A8A, 0x7A8B,
- 0x7A90, 0x7A91, 0x7A94, 0x7A9E, 0x7AA0, 0x7AA3, 0x7AAC, 0x7AB3,
- 0x7AB5, 0x7AB9, 0x7ABB, 0x7ABC, 0x7AC6, 0x7AC9, 0x7ACC, 0x7ACE,
- 0x7AD1, 0x7ADB, 0x7AE8, 0x7AE9, 0x7AEB, 0x7AEC, 0x7AF1, 0x7AF4,
- 0x7AFB, 0x7AFD, 0x7AFE, 0x7B07, 0x7B14, 0x7B1F, 0x7B23, 0x7B27,
- 0x7B29, 0x7B2A, 0x7B2B, 0x7B2D, 0x7B2E, 0x7B2F, 0x7B30,
-};
-static const unsigned short euc_to_utf8_8FD2[] = {
- 0x7B31, 0x7B34, 0x7B3D, 0x7B3F, 0x7B40, 0x7B41, 0x7B47,
- 0x7B4E, 0x7B55, 0x7B60, 0x7B64, 0x7B66, 0x7B69, 0x7B6A, 0x7B6D,
- 0x7B6F, 0x7B72, 0x7B73, 0x7B77, 0x7B84, 0x7B89, 0x7B8E, 0x7B90,
- 0x7B91, 0x7B96, 0x7B9B, 0x7B9E, 0x7BA0, 0x7BA5, 0x7BAC, 0x7BAF,
- 0x7BB0, 0x7BB2, 0x7BB5, 0x7BB6, 0x7BBA, 0x7BBB, 0x7BBC, 0x7BBD,
- 0x7BC2, 0x7BC5, 0x7BC8, 0x7BCA, 0x7BD4, 0x7BD6, 0x7BD7, 0x7BD9,
- 0x7BDA, 0x7BDB, 0x7BE8, 0x7BEA, 0x7BF2, 0x7BF4, 0x7BF5, 0x7BF8,
- 0x7BF9, 0x7BFA, 0x7BFC, 0x7BFE, 0x7C01, 0x7C02, 0x7C03, 0x7C04,
- 0x7C06, 0x7C09, 0x7C0B, 0x7C0C, 0x7C0E, 0x7C0F, 0x7C19, 0x7C1B,
- 0x7C20, 0x7C25, 0x7C26, 0x7C28, 0x7C2C, 0x7C31, 0x7C33, 0x7C34,
- 0x7C36, 0x7C39, 0x7C3A, 0x7C46, 0x7C4A, 0x7C55, 0x7C51, 0x7C52,
- 0x7C53, 0x7C59, 0x7C5A, 0x7C5B, 0x7C5C, 0x7C5D, 0x7C5E,
-};
-static const unsigned short euc_to_utf8_8FD3[] = {
- 0x7C61, 0x7C63, 0x7C67, 0x7C69, 0x7C6D, 0x7C6E, 0x7C70,
- 0x7C72, 0x7C79, 0x7C7C, 0x7C7D, 0x7C86, 0x7C87, 0x7C8F, 0x7C94,
- 0x7C9E, 0x7CA0, 0x7CA6, 0x7CB0, 0x7CB6, 0x7CB7, 0x7CBA, 0x7CBB,
- 0x7CBC, 0x7CBF, 0x7CC4, 0x7CC7, 0x7CC8, 0x7CC9, 0x7CCD, 0x7CCF,
- 0x7CD3, 0x7CD4, 0x7CD5, 0x7CD7, 0x7CD9, 0x7CDA, 0x7CDD, 0x7CE6,
- 0x7CE9, 0x7CEB, 0x7CF5, 0x7D03, 0x7D07, 0x7D08, 0x7D09, 0x7D0F,
- 0x7D11, 0x7D12, 0x7D13, 0x7D16, 0x7D1D, 0x7D1E, 0x7D23, 0x7D26,
- 0x7D2A, 0x7D2D, 0x7D31, 0x7D3C, 0x7D3D, 0x7D3E, 0x7D40, 0x7D41,
- 0x7D47, 0x7D48, 0x7D4D, 0x7D51, 0x7D53, 0x7D57, 0x7D59, 0x7D5A,
- 0x7D5C, 0x7D5D, 0x7D65, 0x7D67, 0x7D6A, 0x7D70, 0x7D78, 0x7D7A,
- 0x7D7B, 0x7D7F, 0x7D81, 0x7D82, 0x7D83, 0x7D85, 0x7D86, 0x7D88,
- 0x7D8B, 0x7D8C, 0x7D8D, 0x7D91, 0x7D96, 0x7D97, 0x7D9D,
-};
-static const unsigned short euc_to_utf8_8FD4[] = {
- 0x7D9E, 0x7DA6, 0x7DA7, 0x7DAA, 0x7DB3, 0x7DB6, 0x7DB7,
- 0x7DB9, 0x7DC2, 0x7DC3, 0x7DC4, 0x7DC5, 0x7DC6, 0x7DCC, 0x7DCD,
- 0x7DCE, 0x7DD7, 0x7DD9, 0x7E00, 0x7DE2, 0x7DE5, 0x7DE6, 0x7DEA,
- 0x7DEB, 0x7DED, 0x7DF1, 0x7DF5, 0x7DF6, 0x7DF9, 0x7DFA, 0x7E08,
- 0x7E10, 0x7E11, 0x7E15, 0x7E17, 0x7E1C, 0x7E1D, 0x7E20, 0x7E27,
- 0x7E28, 0x7E2C, 0x7E2D, 0x7E2F, 0x7E33, 0x7E36, 0x7E3F, 0x7E44,
- 0x7E45, 0x7E47, 0x7E4E, 0x7E50, 0x7E52, 0x7E58, 0x7E5F, 0x7E61,
- 0x7E62, 0x7E65, 0x7E6B, 0x7E6E, 0x7E6F, 0x7E73, 0x7E78, 0x7E7E,
- 0x7E81, 0x7E86, 0x7E87, 0x7E8A, 0x7E8D, 0x7E91, 0x7E95, 0x7E98,
- 0x7E9A, 0x7E9D, 0x7E9E, 0x7F3C, 0x7F3B, 0x7F3D, 0x7F3E, 0x7F3F,
- 0x7F43, 0x7F44, 0x7F47, 0x7F4F, 0x7F52, 0x7F53, 0x7F5B, 0x7F5C,
- 0x7F5D, 0x7F61, 0x7F63, 0x7F64, 0x7F65, 0x7F66, 0x7F6D,
-};
-static const unsigned short euc_to_utf8_8FD5[] = {
- 0x7F71, 0x7F7D, 0x7F7E, 0x7F7F, 0x7F80, 0x7F8B, 0x7F8D,
- 0x7F8F, 0x7F90, 0x7F91, 0x7F96, 0x7F97, 0x7F9C, 0x7FA1, 0x7FA2,
- 0x7FA6, 0x7FAA, 0x7FAD, 0x7FB4, 0x7FBC, 0x7FBF, 0x7FC0, 0x7FC3,
- 0x7FC8, 0x7FCE, 0x7FCF, 0x7FDB, 0x7FDF, 0x7FE3, 0x7FE5, 0x7FE8,
- 0x7FEC, 0x7FEE, 0x7FEF, 0x7FF2, 0x7FFA, 0x7FFD, 0x7FFE, 0x7FFF,
- 0x8007, 0x8008, 0x800A, 0x800D, 0x800E, 0x800F, 0x8011, 0x8013,
- 0x8014, 0x8016, 0x801D, 0x801E, 0x801F, 0x8020, 0x8024, 0x8026,
- 0x802C, 0x802E, 0x8030, 0x8034, 0x8035, 0x8037, 0x8039, 0x803A,
- 0x803C, 0x803E, 0x8040, 0x8044, 0x8060, 0x8064, 0x8066, 0x806D,
- 0x8071, 0x8075, 0x8081, 0x8088, 0x808E, 0x809C, 0x809E, 0x80A6,
- 0x80A7, 0x80AB, 0x80B8, 0x80B9, 0x80C8, 0x80CD, 0x80CF, 0x80D2,
- 0x80D4, 0x80D5, 0x80D7, 0x80D8, 0x80E0, 0x80ED, 0x80EE,
-};
-static const unsigned short euc_to_utf8_8FD6[] = {
- 0x80F0, 0x80F2, 0x80F3, 0x80F6, 0x80F9, 0x80FA, 0x80FE,
- 0x8103, 0x810B, 0x8116, 0x8117, 0x8118, 0x811C, 0x811E, 0x8120,
- 0x8124, 0x8127, 0x812C, 0x8130, 0x8135, 0x813A, 0x813C, 0x8145,
- 0x8147, 0x814A, 0x814C, 0x8152, 0x8157, 0x8160, 0x8161, 0x8167,
- 0x8168, 0x8169, 0x816D, 0x816F, 0x8177, 0x8181, 0x8190, 0x8184,
- 0x8185, 0x8186, 0x818B, 0x818E, 0x8196, 0x8198, 0x819B, 0x819E,
- 0x81A2, 0x81AE, 0x81B2, 0x81B4, 0x81BB, 0x81CB, 0x81C3, 0x81C5,
- 0x81CA, 0x81CE, 0x81CF, 0x81D5, 0x81D7, 0x81DB, 0x81DD, 0x81DE,
- 0x81E1, 0x81E4, 0x81EB, 0x81EC, 0x81F0, 0x81F1, 0x81F2, 0x81F5,
- 0x81F6, 0x81F8, 0x81F9, 0x81FD, 0x81FF, 0x8200, 0x8203, 0x820F,
- 0x8213, 0x8214, 0x8219, 0x821A, 0x821D, 0x8221, 0x8222, 0x8228,
- 0x8232, 0x8234, 0x823A, 0x8243, 0x8244, 0x8245, 0x8246,
-};
-static const unsigned short euc_to_utf8_8FD7[] = {
- 0x824B, 0x824E, 0x824F, 0x8251, 0x8256, 0x825C, 0x8260,
- 0x8263, 0x8267, 0x826D, 0x8274, 0x827B, 0x827D, 0x827F, 0x8280,
- 0x8281, 0x8283, 0x8284, 0x8287, 0x8289, 0x828A, 0x828E, 0x8291,
- 0x8294, 0x8296, 0x8298, 0x829A, 0x829B, 0x82A0, 0x82A1, 0x82A3,
- 0x82A4, 0x82A7, 0x82A8, 0x82A9, 0x82AA, 0x82AE, 0x82B0, 0x82B2,
- 0x82B4, 0x82B7, 0x82BA, 0x82BC, 0x82BE, 0x82BF, 0x82C6, 0x82D0,
- 0x82D5, 0x82DA, 0x82E0, 0x82E2, 0x82E4, 0x82E8, 0x82EA, 0x82ED,
- 0x82EF, 0x82F6, 0x82F7, 0x82FD, 0x82FE, 0x8300, 0x8301, 0x8307,
- 0x8308, 0x830A, 0x830B, 0x8354, 0x831B, 0x831D, 0x831E, 0x831F,
- 0x8321, 0x8322, 0x832C, 0x832D, 0x832E, 0x8330, 0x8333, 0x8337,
- 0x833A, 0x833C, 0x833D, 0x8342, 0x8343, 0x8344, 0x8347, 0x834D,
- 0x834E, 0x8351, 0x8355, 0x8356, 0x8357, 0x8370, 0x8378,
-};
-static const unsigned short euc_to_utf8_8FD8[] = {
- 0x837D, 0x837F, 0x8380, 0x8382, 0x8384, 0x8386, 0x838D,
- 0x8392, 0x8394, 0x8395, 0x8398, 0x8399, 0x839B, 0x839C, 0x839D,
- 0x83A6, 0x83A7, 0x83A9, 0x83AC, 0x83BE, 0x83BF, 0x83C0, 0x83C7,
- 0x83C9, 0x83CF, 0x83D0, 0x83D1, 0x83D4, 0x83DD, 0x8353, 0x83E8,
- 0x83EA, 0x83F6, 0x83F8, 0x83F9, 0x83FC, 0x8401, 0x8406, 0x840A,
- 0x840F, 0x8411, 0x8415, 0x8419, 0x83AD, 0x842F, 0x8439, 0x8445,
- 0x8447, 0x8448, 0x844A, 0x844D, 0x844F, 0x8451, 0x8452, 0x8456,
- 0x8458, 0x8459, 0x845A, 0x845C, 0x8460, 0x8464, 0x8465, 0x8467,
- 0x846A, 0x8470, 0x8473, 0x8474, 0x8476, 0x8478, 0x847C, 0x847D,
- 0x8481, 0x8485, 0x8492, 0x8493, 0x8495, 0x849E, 0x84A6, 0x84A8,
- 0x84A9, 0x84AA, 0x84AF, 0x84B1, 0x84B4, 0x84BA, 0x84BD, 0x84BE,
- 0x84C0, 0x84C2, 0x84C7, 0x84C8, 0x84CC, 0x84CF, 0x84D3,
-};
-static const unsigned short euc_to_utf8_8FD9[] = {
- 0x84DC, 0x84E7, 0x84EA, 0x84EF, 0x84F0, 0x84F1, 0x84F2,
- 0x84F7, 0x8532, 0x84FA, 0x84FB, 0x84FD, 0x8502, 0x8503, 0x8507,
- 0x850C, 0x850E, 0x8510, 0x851C, 0x851E, 0x8522, 0x8523, 0x8524,
- 0x8525, 0x8527, 0x852A, 0x852B, 0x852F, 0x8533, 0x8534, 0x8536,
- 0x853F, 0x8546, 0x854F, 0x8550, 0x8551, 0x8552, 0x8553, 0x8556,
- 0x8559, 0x855C, 0x855D, 0x855E, 0x855F, 0x8560, 0x8561, 0x8562,
- 0x8564, 0x856B, 0x856F, 0x8579, 0x857A, 0x857B, 0x857D, 0x857F,
- 0x8581, 0x8585, 0x8586, 0x8589, 0x858B, 0x858C, 0x858F, 0x8593,
- 0x8598, 0x859D, 0x859F, 0x85A0, 0x85A2, 0x85A5, 0x85A7, 0x85B4,
- 0x85B6, 0x85B7, 0x85B8, 0x85BC, 0x85BD, 0x85BE, 0x85BF, 0x85C2,
- 0x85C7, 0x85CA, 0x85CB, 0x85CE, 0x85AD, 0x85D8, 0x85DA, 0x85DF,
- 0x85E0, 0x85E6, 0x85E8, 0x85ED, 0x85F3, 0x85F6, 0x85FC,
-};
-static const unsigned short euc_to_utf8_8FDA[] = {
- 0x85FF, 0x8600, 0x8604, 0x8605, 0x860D, 0x860E, 0x8610,
- 0x8611, 0x8612, 0x8618, 0x8619, 0x861B, 0x861E, 0x8621, 0x8627,
- 0x8629, 0x8636, 0x8638, 0x863A, 0x863C, 0x863D, 0x8640, 0x8642,
- 0x8646, 0x8652, 0x8653, 0x8656, 0x8657, 0x8658, 0x8659, 0x865D,
- 0x8660, 0x8661, 0x8662, 0x8663, 0x8664, 0x8669, 0x866C, 0x866F,
- 0x8675, 0x8676, 0x8677, 0x867A, 0x868D, 0x8691, 0x8696, 0x8698,
- 0x869A, 0x869C, 0x86A1, 0x86A6, 0x86A7, 0x86A8, 0x86AD, 0x86B1,
- 0x86B3, 0x86B4, 0x86B5, 0x86B7, 0x86B8, 0x86B9, 0x86BF, 0x86C0,
- 0x86C1, 0x86C3, 0x86C5, 0x86D1, 0x86D2, 0x86D5, 0x86D7, 0x86DA,
- 0x86DC, 0x86E0, 0x86E3, 0x86E5, 0x86E7, 0x8688, 0x86FA, 0x86FC,
- 0x86FD, 0x8704, 0x8705, 0x8707, 0x870B, 0x870E, 0x870F, 0x8710,
- 0x8713, 0x8714, 0x8719, 0x871E, 0x871F, 0x8721, 0x8723,
-};
-static const unsigned short euc_to_utf8_8FDB[] = {
- 0x8728, 0x872E, 0x872F, 0x8731, 0x8732, 0x8739, 0x873A,
- 0x873C, 0x873D, 0x873E, 0x8740, 0x8743, 0x8745, 0x874D, 0x8758,
- 0x875D, 0x8761, 0x8764, 0x8765, 0x876F, 0x8771, 0x8772, 0x877B,
- 0x8783, 0x8784, 0x8785, 0x8786, 0x8787, 0x8788, 0x8789, 0x878B,
- 0x878C, 0x8790, 0x8793, 0x8795, 0x8797, 0x8798, 0x8799, 0x879E,
- 0x87A0, 0x87A3, 0x87A7, 0x87AC, 0x87AD, 0x87AE, 0x87B1, 0x87B5,
- 0x87BE, 0x87BF, 0x87C1, 0x87C8, 0x87C9, 0x87CA, 0x87CE, 0x87D5,
- 0x87D6, 0x87D9, 0x87DA, 0x87DC, 0x87DF, 0x87E2, 0x87E3, 0x87E4,
- 0x87EA, 0x87EB, 0x87ED, 0x87F1, 0x87F3, 0x87F8, 0x87FA, 0x87FF,
- 0x8801, 0x8803, 0x8806, 0x8809, 0x880A, 0x880B, 0x8810, 0x8819,
- 0x8812, 0x8813, 0x8814, 0x8818, 0x881A, 0x881B, 0x881C, 0x881E,
- 0x881F, 0x8828, 0x882D, 0x882E, 0x8830, 0x8832, 0x8835,
-};
-static const unsigned short euc_to_utf8_8FDC[] = {
- 0x883A, 0x883C, 0x8841, 0x8843, 0x8845, 0x8848, 0x8849,
- 0x884A, 0x884B, 0x884E, 0x8851, 0x8855, 0x8856, 0x8858, 0x885A,
- 0x885C, 0x885F, 0x8860, 0x8864, 0x8869, 0x8871, 0x8879, 0x887B,
- 0x8880, 0x8898, 0x889A, 0x889B, 0x889C, 0x889F, 0x88A0, 0x88A8,
- 0x88AA, 0x88BA, 0x88BD, 0x88BE, 0x88C0, 0x88CA, 0x88CB, 0x88CC,
- 0x88CD, 0x88CE, 0x88D1, 0x88D2, 0x88D3, 0x88DB, 0x88DE, 0x88E7,
- 0x88EF, 0x88F0, 0x88F1, 0x88F5, 0x88F7, 0x8901, 0x8906, 0x890D,
- 0x890E, 0x890F, 0x8915, 0x8916, 0x8918, 0x8919, 0x891A, 0x891C,
- 0x8920, 0x8926, 0x8927, 0x8928, 0x8930, 0x8931, 0x8932, 0x8935,
- 0x8939, 0x893A, 0x893E, 0x8940, 0x8942, 0x8945, 0x8946, 0x8949,
- 0x894F, 0x8952, 0x8957, 0x895A, 0x895B, 0x895C, 0x8961, 0x8962,
- 0x8963, 0x896B, 0x896E, 0x8970, 0x8973, 0x8975, 0x897A,
-};
-static const unsigned short euc_to_utf8_8FDD[] = {
- 0x897B, 0x897C, 0x897D, 0x8989, 0x898D, 0x8990, 0x8994,
- 0x8995, 0x899B, 0x899C, 0x899F, 0x89A0, 0x89A5, 0x89B0, 0x89B4,
- 0x89B5, 0x89B6, 0x89B7, 0x89BC, 0x89D4, 0x89D5, 0x89D6, 0x89D7,
- 0x89D8, 0x89E5, 0x89E9, 0x89EB, 0x89ED, 0x89F1, 0x89F3, 0x89F6,
- 0x89F9, 0x89FD, 0x89FF, 0x8A04, 0x8A05, 0x8A07, 0x8A0F, 0x8A11,
- 0x8A12, 0x8A14, 0x8A15, 0x8A1E, 0x8A20, 0x8A22, 0x8A24, 0x8A26,
- 0x8A2B, 0x8A2C, 0x8A2F, 0x8A35, 0x8A37, 0x8A3D, 0x8A3E, 0x8A40,
- 0x8A43, 0x8A45, 0x8A47, 0x8A49, 0x8A4D, 0x8A4E, 0x8A53, 0x8A56,
- 0x8A57, 0x8A58, 0x8A5C, 0x8A5D, 0x8A61, 0x8A65, 0x8A67, 0x8A75,
- 0x8A76, 0x8A77, 0x8A79, 0x8A7A, 0x8A7B, 0x8A7E, 0x8A7F, 0x8A80,
- 0x8A83, 0x8A86, 0x8A8B, 0x8A8F, 0x8A90, 0x8A92, 0x8A96, 0x8A97,
- 0x8A99, 0x8A9F, 0x8AA7, 0x8AA9, 0x8AAE, 0x8AAF, 0x8AB3,
-};
-static const unsigned short euc_to_utf8_8FDE[] = {
- 0x8AB6, 0x8AB7, 0x8ABB, 0x8ABE, 0x8AC3, 0x8AC6, 0x8AC8,
- 0x8AC9, 0x8ACA, 0x8AD1, 0x8AD3, 0x8AD4, 0x8AD5, 0x8AD7, 0x8ADD,
- 0x8ADF, 0x8AEC, 0x8AF0, 0x8AF4, 0x8AF5, 0x8AF6, 0x8AFC, 0x8AFF,
- 0x8B05, 0x8B06, 0x8B0B, 0x8B11, 0x8B1C, 0x8B1E, 0x8B1F, 0x8B0A,
- 0x8B2D, 0x8B30, 0x8B37, 0x8B3C, 0x8B42, 0x8B43, 0x8B44, 0x8B45,
- 0x8B46, 0x8B48, 0x8B52, 0x8B53, 0x8B54, 0x8B59, 0x8B4D, 0x8B5E,
- 0x8B63, 0x8B6D, 0x8B76, 0x8B78, 0x8B79, 0x8B7C, 0x8B7E, 0x8B81,
- 0x8B84, 0x8B85, 0x8B8B, 0x8B8D, 0x8B8F, 0x8B94, 0x8B95, 0x8B9C,
- 0x8B9E, 0x8B9F, 0x8C38, 0x8C39, 0x8C3D, 0x8C3E, 0x8C45, 0x8C47,
- 0x8C49, 0x8C4B, 0x8C4F, 0x8C51, 0x8C53, 0x8C54, 0x8C57, 0x8C58,
- 0x8C5B, 0x8C5D, 0x8C59, 0x8C63, 0x8C64, 0x8C66, 0x8C68, 0x8C69,
- 0x8C6D, 0x8C73, 0x8C75, 0x8C76, 0x8C7B, 0x8C7E, 0x8C86,
-};
-static const unsigned short euc_to_utf8_8FDF[] = {
- 0x8C87, 0x8C8B, 0x8C90, 0x8C92, 0x8C93, 0x8C99, 0x8C9B,
- 0x8C9C, 0x8CA4, 0x8CB9, 0x8CBA, 0x8CC5, 0x8CC6, 0x8CC9, 0x8CCB,
- 0x8CCF, 0x8CD6, 0x8CD5, 0x8CD9, 0x8CDD, 0x8CE1, 0x8CE8, 0x8CEC,
- 0x8CEF, 0x8CF0, 0x8CF2, 0x8CF5, 0x8CF7, 0x8CF8, 0x8CFE, 0x8CFF,
- 0x8D01, 0x8D03, 0x8D09, 0x8D12, 0x8D17, 0x8D1B, 0x8D65, 0x8D69,
- 0x8D6C, 0x8D6E, 0x8D7F, 0x8D82, 0x8D84, 0x8D88, 0x8D8D, 0x8D90,
- 0x8D91, 0x8D95, 0x8D9E, 0x8D9F, 0x8DA0, 0x8DA6, 0x8DAB, 0x8DAC,
- 0x8DAF, 0x8DB2, 0x8DB5, 0x8DB7, 0x8DB9, 0x8DBB, 0x8DC0, 0x8DC5,
- 0x8DC6, 0x8DC7, 0x8DC8, 0x8DCA, 0x8DCE, 0x8DD1, 0x8DD4, 0x8DD5,
- 0x8DD7, 0x8DD9, 0x8DE4, 0x8DE5, 0x8DE7, 0x8DEC, 0x8DF0, 0x8DBC,
- 0x8DF1, 0x8DF2, 0x8DF4, 0x8DFD, 0x8E01, 0x8E04, 0x8E05, 0x8E06,
- 0x8E0B, 0x8E11, 0x8E14, 0x8E16, 0x8E20, 0x8E21, 0x8E22,
-};
-static const unsigned short euc_to_utf8_8FE0[] = {
- 0x8E23, 0x8E26, 0x8E27, 0x8E31, 0x8E33, 0x8E36, 0x8E37,
- 0x8E38, 0x8E39, 0x8E3D, 0x8E40, 0x8E41, 0x8E4B, 0x8E4D, 0x8E4E,
- 0x8E4F, 0x8E54, 0x8E5B, 0x8E5C, 0x8E5D, 0x8E5E, 0x8E61, 0x8E62,
- 0x8E69, 0x8E6C, 0x8E6D, 0x8E6F, 0x8E70, 0x8E71, 0x8E79, 0x8E7A,
- 0x8E7B, 0x8E82, 0x8E83, 0x8E89, 0x8E90, 0x8E92, 0x8E95, 0x8E9A,
- 0x8E9B, 0x8E9D, 0x8E9E, 0x8EA2, 0x8EA7, 0x8EA9, 0x8EAD, 0x8EAE,
- 0x8EB3, 0x8EB5, 0x8EBA, 0x8EBB, 0x8EC0, 0x8EC1, 0x8EC3, 0x8EC4,
- 0x8EC7, 0x8ECF, 0x8ED1, 0x8ED4, 0x8EDC, 0x8EE8, 0x8EEE, 0x8EF0,
- 0x8EF1, 0x8EF7, 0x8EF9, 0x8EFA, 0x8EED, 0x8F00, 0x8F02, 0x8F07,
- 0x8F08, 0x8F0F, 0x8F10, 0x8F16, 0x8F17, 0x8F18, 0x8F1E, 0x8F20,
- 0x8F21, 0x8F23, 0x8F25, 0x8F27, 0x8F28, 0x8F2C, 0x8F2D, 0x8F2E,
- 0x8F34, 0x8F35, 0x8F36, 0x8F37, 0x8F3A, 0x8F40, 0x8F41,
-};
-static const unsigned short euc_to_utf8_8FE1[] = {
- 0x8F43, 0x8F47, 0x8F4F, 0x8F51, 0x8F52, 0x8F53, 0x8F54,
- 0x8F55, 0x8F58, 0x8F5D, 0x8F5E, 0x8F65, 0x8F9D, 0x8FA0, 0x8FA1,
- 0x8FA4, 0x8FA5, 0x8FA6, 0x8FB5, 0x8FB6, 0x8FB8, 0x8FBE, 0x8FC0,
- 0x8FC1, 0x8FC6, 0x8FCA, 0x8FCB, 0x8FCD, 0x8FD0, 0x8FD2, 0x8FD3,
- 0x8FD5, 0x8FE0, 0x8FE3, 0x8FE4, 0x8FE8, 0x8FEE, 0x8FF1, 0x8FF5,
- 0x8FF6, 0x8FFB, 0x8FFE, 0x9002, 0x9004, 0x9008, 0x900C, 0x9018,
- 0x901B, 0x9028, 0x9029, 0x902F, 0x902A, 0x902C, 0x902D, 0x9033,
- 0x9034, 0x9037, 0x903F, 0x9043, 0x9044, 0x904C, 0x905B, 0x905D,
- 0x9062, 0x9066, 0x9067, 0x906C, 0x9070, 0x9074, 0x9079, 0x9085,
- 0x9088, 0x908B, 0x908C, 0x908E, 0x9090, 0x9095, 0x9097, 0x9098,
- 0x9099, 0x909B, 0x90A0, 0x90A1, 0x90A2, 0x90A5, 0x90B0, 0x90B2,
- 0x90B3, 0x90B4, 0x90B6, 0x90BD, 0x90CC, 0x90BE, 0x90C3,
-};
-static const unsigned short euc_to_utf8_8FE2[] = {
- 0x90C4, 0x90C5, 0x90C7, 0x90C8, 0x90D5, 0x90D7, 0x90D8,
- 0x90D9, 0x90DC, 0x90DD, 0x90DF, 0x90E5, 0x90D2, 0x90F6, 0x90EB,
- 0x90EF, 0x90F0, 0x90F4, 0x90FE, 0x90FF, 0x9100, 0x9104, 0x9105,
- 0x9106, 0x9108, 0x910D, 0x9110, 0x9114, 0x9116, 0x9117, 0x9118,
- 0x911A, 0x911C, 0x911E, 0x9120, 0x9125, 0x9122, 0x9123, 0x9127,
- 0x9129, 0x912E, 0x912F, 0x9131, 0x9134, 0x9136, 0x9137, 0x9139,
- 0x913A, 0x913C, 0x913D, 0x9143, 0x9147, 0x9148, 0x914F, 0x9153,
- 0x9157, 0x9159, 0x915A, 0x915B, 0x9161, 0x9164, 0x9167, 0x916D,
- 0x9174, 0x9179, 0x917A, 0x917B, 0x9181, 0x9183, 0x9185, 0x9186,
- 0x918A, 0x918E, 0x9191, 0x9193, 0x9194, 0x9195, 0x9198, 0x919E,
- 0x91A1, 0x91A6, 0x91A8, 0x91AC, 0x91AD, 0x91AE, 0x91B0, 0x91B1,
- 0x91B2, 0x91B3, 0x91B6, 0x91BB, 0x91BC, 0x91BD, 0x91BF,
-};
-static const unsigned short euc_to_utf8_8FE3[] = {
- 0x91C2, 0x91C3, 0x91C5, 0x91D3, 0x91D4, 0x91D7, 0x91D9,
- 0x91DA, 0x91DE, 0x91E4, 0x91E5, 0x91E9, 0x91EA, 0x91EC, 0x91ED,
- 0x91EE, 0x91EF, 0x91F0, 0x91F1, 0x91F7, 0x91F9, 0x91FB, 0x91FD,
- 0x9200, 0x9201, 0x9204, 0x9205, 0x9206, 0x9207, 0x9209, 0x920A,
- 0x920C, 0x9210, 0x9212, 0x9213, 0x9216, 0x9218, 0x921C, 0x921D,
- 0x9223, 0x9224, 0x9225, 0x9226, 0x9228, 0x922E, 0x922F, 0x9230,
- 0x9233, 0x9235, 0x9236, 0x9238, 0x9239, 0x923A, 0x923C, 0x923E,
- 0x9240, 0x9242, 0x9243, 0x9246, 0x9247, 0x924A, 0x924D, 0x924E,
- 0x924F, 0x9251, 0x9258, 0x9259, 0x925C, 0x925D, 0x9260, 0x9261,
- 0x9265, 0x9267, 0x9268, 0x9269, 0x926E, 0x926F, 0x9270, 0x9275,
- 0x9276, 0x9277, 0x9278, 0x9279, 0x927B, 0x927C, 0x927D, 0x927F,
- 0x9288, 0x9289, 0x928A, 0x928D, 0x928E, 0x9292, 0x9297,
-};
-static const unsigned short euc_to_utf8_8FE4[] = {
- 0x9299, 0x929F, 0x92A0, 0x92A4, 0x92A5, 0x92A7, 0x92A8,
- 0x92AB, 0x92AF, 0x92B2, 0x92B6, 0x92B8, 0x92BA, 0x92BB, 0x92BC,
- 0x92BD, 0x92BF, 0x92C0, 0x92C1, 0x92C2, 0x92C3, 0x92C5, 0x92C6,
- 0x92C7, 0x92C8, 0x92CB, 0x92CC, 0x92CD, 0x92CE, 0x92D0, 0x92D3,
- 0x92D5, 0x92D7, 0x92D8, 0x92D9, 0x92DC, 0x92DD, 0x92DF, 0x92E0,
- 0x92E1, 0x92E3, 0x92E5, 0x92E7, 0x92E8, 0x92EC, 0x92EE, 0x92F0,
- 0x92F9, 0x92FB, 0x92FF, 0x9300, 0x9302, 0x9308, 0x930D, 0x9311,
- 0x9314, 0x9315, 0x931C, 0x931D, 0x931E, 0x931F, 0x9321, 0x9324,
- 0x9325, 0x9327, 0x9329, 0x932A, 0x9333, 0x9334, 0x9336, 0x9337,
- 0x9347, 0x9348, 0x9349, 0x9350, 0x9351, 0x9352, 0x9355, 0x9357,
- 0x9358, 0x935A, 0x935E, 0x9364, 0x9365, 0x9367, 0x9369, 0x936A,
- 0x936D, 0x936F, 0x9370, 0x9371, 0x9373, 0x9374, 0x9376,
-};
-static const unsigned short euc_to_utf8_8FE5[] = {
- 0x937A, 0x937D, 0x937F, 0x9380, 0x9381, 0x9382, 0x9388,
- 0x938A, 0x938B, 0x938D, 0x938F, 0x9392, 0x9395, 0x9398, 0x939B,
- 0x939E, 0x93A1, 0x93A3, 0x93A4, 0x93A6, 0x93A8, 0x93AB, 0x93B4,
- 0x93B5, 0x93B6, 0x93BA, 0x93A9, 0x93C1, 0x93C4, 0x93C5, 0x93C6,
- 0x93C7, 0x93C9, 0x93CA, 0x93CB, 0x93CC, 0x93CD, 0x93D3, 0x93D9,
- 0x93DC, 0x93DE, 0x93DF, 0x93E2, 0x93E6, 0x93E7, 0x93F9, 0x93F7,
- 0x93F8, 0x93FA, 0x93FB, 0x93FD, 0x9401, 0x9402, 0x9404, 0x9408,
- 0x9409, 0x940D, 0x940E, 0x940F, 0x9415, 0x9416, 0x9417, 0x941F,
- 0x942E, 0x942F, 0x9431, 0x9432, 0x9433, 0x9434, 0x943B, 0x943F,
- 0x943D, 0x9443, 0x9445, 0x9448, 0x944A, 0x944C, 0x9455, 0x9459,
- 0x945C, 0x945F, 0x9461, 0x9463, 0x9468, 0x946B, 0x946D, 0x946E,
- 0x946F, 0x9471, 0x9472, 0x9484, 0x9483, 0x9578, 0x9579,
-};
-static const unsigned short euc_to_utf8_8FE6[] = {
- 0x957E, 0x9584, 0x9588, 0x958C, 0x958D, 0x958E, 0x959D,
- 0x959E, 0x959F, 0x95A1, 0x95A6, 0x95A9, 0x95AB, 0x95AC, 0x95B4,
- 0x95B6, 0x95BA, 0x95BD, 0x95BF, 0x95C6, 0x95C8, 0x95C9, 0x95CB,
- 0x95D0, 0x95D1, 0x95D2, 0x95D3, 0x95D9, 0x95DA, 0x95DD, 0x95DE,
- 0x95DF, 0x95E0, 0x95E4, 0x95E6, 0x961D, 0x961E, 0x9622, 0x9624,
- 0x9625, 0x9626, 0x962C, 0x9631, 0x9633, 0x9637, 0x9638, 0x9639,
- 0x963A, 0x963C, 0x963D, 0x9641, 0x9652, 0x9654, 0x9656, 0x9657,
- 0x9658, 0x9661, 0x966E, 0x9674, 0x967B, 0x967C, 0x967E, 0x967F,
- 0x9681, 0x9682, 0x9683, 0x9684, 0x9689, 0x9691, 0x9696, 0x969A,
- 0x969D, 0x969F, 0x96A4, 0x96A5, 0x96A6, 0x96A9, 0x96AE, 0x96AF,
- 0x96B3, 0x96BA, 0x96CA, 0x96D2, 0x5DB2, 0x96D8, 0x96DA, 0x96DD,
- 0x96DE, 0x96DF, 0x96E9, 0x96EF, 0x96F1, 0x96FA, 0x9702,
-};
-static const unsigned short euc_to_utf8_8FE7[] = {
- 0x9703, 0x9705, 0x9709, 0x971A, 0x971B, 0x971D, 0x9721,
- 0x9722, 0x9723, 0x9728, 0x9731, 0x9733, 0x9741, 0x9743, 0x974A,
- 0x974E, 0x974F, 0x9755, 0x9757, 0x9758, 0x975A, 0x975B, 0x9763,
- 0x9767, 0x976A, 0x976E, 0x9773, 0x9776, 0x9777, 0x9778, 0x977B,
- 0x977D, 0x977F, 0x9780, 0x9789, 0x9795, 0x9796, 0x9797, 0x9799,
- 0x979A, 0x979E, 0x979F, 0x97A2, 0x97AC, 0x97AE, 0x97B1, 0x97B2,
- 0x97B5, 0x97B6, 0x97B8, 0x97B9, 0x97BA, 0x97BC, 0x97BE, 0x97BF,
- 0x97C1, 0x97C4, 0x97C5, 0x97C7, 0x97C9, 0x97CA, 0x97CC, 0x97CD,
- 0x97CE, 0x97D0, 0x97D1, 0x97D4, 0x97D7, 0x97D8, 0x97D9, 0x97DD,
- 0x97DE, 0x97E0, 0x97DB, 0x97E1, 0x97E4, 0x97EF, 0x97F1, 0x97F4,
- 0x97F7, 0x97F8, 0x97FA, 0x9807, 0x980A, 0x9819, 0x980D, 0x980E,
- 0x9814, 0x9816, 0x981C, 0x981E, 0x9820, 0x9823, 0x9826,
-};
-static const unsigned short euc_to_utf8_8FE8[] = {
- 0x982B, 0x982E, 0x982F, 0x9830, 0x9832, 0x9833, 0x9835,
- 0x9825, 0x983E, 0x9844, 0x9847, 0x984A, 0x9851, 0x9852, 0x9853,
- 0x9856, 0x9857, 0x9859, 0x985A, 0x9862, 0x9863, 0x9865, 0x9866,
- 0x986A, 0x986C, 0x98AB, 0x98AD, 0x98AE, 0x98B0, 0x98B4, 0x98B7,
- 0x98B8, 0x98BA, 0x98BB, 0x98BF, 0x98C2, 0x98C5, 0x98C8, 0x98CC,
- 0x98E1, 0x98E3, 0x98E5, 0x98E6, 0x98E7, 0x98EA, 0x98F3, 0x98F6,
- 0x9902, 0x9907, 0x9908, 0x9911, 0x9915, 0x9916, 0x9917, 0x991A,
- 0x991B, 0x991C, 0x991F, 0x9922, 0x9926, 0x9927, 0x992B, 0x9931,
- 0x9932, 0x9933, 0x9934, 0x9935, 0x9939, 0x993A, 0x993B, 0x993C,
- 0x9940, 0x9941, 0x9946, 0x9947, 0x9948, 0x994D, 0x994E, 0x9954,
- 0x9958, 0x9959, 0x995B, 0x995C, 0x995E, 0x995F, 0x9960, 0x999B,
- 0x999D, 0x999F, 0x99A6, 0x99B0, 0x99B1, 0x99B2, 0x99B5,
-};
-static const unsigned short euc_to_utf8_8FE9[] = {
- 0x99B9, 0x99BA, 0x99BD, 0x99BF, 0x99C3, 0x99C9, 0x99D3,
- 0x99D4, 0x99D9, 0x99DA, 0x99DC, 0x99DE, 0x99E7, 0x99EA, 0x99EB,
- 0x99EC, 0x99F0, 0x99F4, 0x99F5, 0x99F9, 0x99FD, 0x99FE, 0x9A02,
- 0x9A03, 0x9A04, 0x9A0B, 0x9A0C, 0x9A10, 0x9A11, 0x9A16, 0x9A1E,
- 0x9A20, 0x9A22, 0x9A23, 0x9A24, 0x9A27, 0x9A2D, 0x9A2E, 0x9A33,
- 0x9A35, 0x9A36, 0x9A38, 0x9A47, 0x9A41, 0x9A44, 0x9A4A, 0x9A4B,
- 0x9A4C, 0x9A4E, 0x9A51, 0x9A54, 0x9A56, 0x9A5D, 0x9AAA, 0x9AAC,
- 0x9AAE, 0x9AAF, 0x9AB2, 0x9AB4, 0x9AB5, 0x9AB6, 0x9AB9, 0x9ABB,
- 0x9ABE, 0x9ABF, 0x9AC1, 0x9AC3, 0x9AC6, 0x9AC8, 0x9ACE, 0x9AD0,
- 0x9AD2, 0x9AD5, 0x9AD6, 0x9AD7, 0x9ADB, 0x9ADC, 0x9AE0, 0x9AE4,
- 0x9AE5, 0x9AE7, 0x9AE9, 0x9AEC, 0x9AF2, 0x9AF3, 0x9AF5, 0x9AF9,
- 0x9AFA, 0x9AFD, 0x9AFF, 0x9B00, 0x9B01, 0x9B02, 0x9B03,
-};
-static const unsigned short euc_to_utf8_8FEA[] = {
- 0x9B04, 0x9B05, 0x9B08, 0x9B09, 0x9B0B, 0x9B0C, 0x9B0D,
- 0x9B0E, 0x9B10, 0x9B12, 0x9B16, 0x9B19, 0x9B1B, 0x9B1C, 0x9B20,
- 0x9B26, 0x9B2B, 0x9B2D, 0x9B33, 0x9B34, 0x9B35, 0x9B37, 0x9B39,
- 0x9B3A, 0x9B3D, 0x9B48, 0x9B4B, 0x9B4C, 0x9B55, 0x9B56, 0x9B57,
- 0x9B5B, 0x9B5E, 0x9B61, 0x9B63, 0x9B65, 0x9B66, 0x9B68, 0x9B6A,
- 0x9B6B, 0x9B6C, 0x9B6D, 0x9B6E, 0x9B73, 0x9B75, 0x9B77, 0x9B78,
- 0x9B79, 0x9B7F, 0x9B80, 0x9B84, 0x9B85, 0x9B86, 0x9B87, 0x9B89,
- 0x9B8A, 0x9B8B, 0x9B8D, 0x9B8F, 0x9B90, 0x9B94, 0x9B9A, 0x9B9D,
- 0x9B9E, 0x9BA6, 0x9BA7, 0x9BA9, 0x9BAC, 0x9BB0, 0x9BB1, 0x9BB2,
- 0x9BB7, 0x9BB8, 0x9BBB, 0x9BBC, 0x9BBE, 0x9BBF, 0x9BC1, 0x9BC7,
- 0x9BC8, 0x9BCE, 0x9BD0, 0x9BD7, 0x9BD8, 0x9BDD, 0x9BDF, 0x9BE5,
- 0x9BE7, 0x9BEA, 0x9BEB, 0x9BEF, 0x9BF3, 0x9BF7, 0x9BF8,
-};
-static const unsigned short euc_to_utf8_8FEB[] = {
- 0x9BF9, 0x9BFA, 0x9BFD, 0x9BFF, 0x9C00, 0x9C02, 0x9C0B,
- 0x9C0F, 0x9C11, 0x9C16, 0x9C18, 0x9C19, 0x9C1A, 0x9C1C, 0x9C1E,
- 0x9C22, 0x9C23, 0x9C26, 0x9C27, 0x9C28, 0x9C29, 0x9C2A, 0x9C31,
- 0x9C35, 0x9C36, 0x9C37, 0x9C3D, 0x9C41, 0x9C43, 0x9C44, 0x9C45,
- 0x9C49, 0x9C4A, 0x9C4E, 0x9C4F, 0x9C50, 0x9C53, 0x9C54, 0x9C56,
- 0x9C58, 0x9C5B, 0x9C5D, 0x9C5E, 0x9C5F, 0x9C63, 0x9C69, 0x9C6A,
- 0x9C5C, 0x9C6B, 0x9C68, 0x9C6E, 0x9C70, 0x9C72, 0x9C75, 0x9C77,
- 0x9C7B, 0x9CE6, 0x9CF2, 0x9CF7, 0x9CF9, 0x9D0B, 0x9D02, 0x9D11,
- 0x9D17, 0x9D18, 0x9D1C, 0x9D1D, 0x9D1E, 0x9D2F, 0x9D30, 0x9D32,
- 0x9D33, 0x9D34, 0x9D3A, 0x9D3C, 0x9D45, 0x9D3D, 0x9D42, 0x9D43,
- 0x9D47, 0x9D4A, 0x9D53, 0x9D54, 0x9D5F, 0x9D63, 0x9D62, 0x9D65,
- 0x9D69, 0x9D6A, 0x9D6B, 0x9D70, 0x9D76, 0x9D77, 0x9D7B,
-};
-static const unsigned short euc_to_utf8_8FEC[] = {
- 0x9D7C, 0x9D7E, 0x9D83, 0x9D84, 0x9D86, 0x9D8A, 0x9D8D,
- 0x9D8E, 0x9D92, 0x9D93, 0x9D95, 0x9D96, 0x9D97, 0x9D98, 0x9DA1,
- 0x9DAA, 0x9DAC, 0x9DAE, 0x9DB1, 0x9DB5, 0x9DB9, 0x9DBC, 0x9DBF,
- 0x9DC3, 0x9DC7, 0x9DC9, 0x9DCA, 0x9DD4, 0x9DD5, 0x9DD6, 0x9DD7,
- 0x9DDA, 0x9DDE, 0x9DDF, 0x9DE0, 0x9DE5, 0x9DE7, 0x9DE9, 0x9DEB,
- 0x9DEE, 0x9DF0, 0x9DF3, 0x9DF4, 0x9DFE, 0x9E0A, 0x9E02, 0x9E07,
- 0x9E0E, 0x9E10, 0x9E11, 0x9E12, 0x9E15, 0x9E16, 0x9E19, 0x9E1C,
- 0x9E1D, 0x9E7A, 0x9E7B, 0x9E7C, 0x9E80, 0x9E82, 0x9E83, 0x9E84,
- 0x9E85, 0x9E87, 0x9E8E, 0x9E8F, 0x9E96, 0x9E98, 0x9E9B, 0x9E9E,
- 0x9EA4, 0x9EA8, 0x9EAC, 0x9EAE, 0x9EAF, 0x9EB0, 0x9EB3, 0x9EB4,
- 0x9EB5, 0x9EC6, 0x9EC8, 0x9ECB, 0x9ED5, 0x9EDF, 0x9EE4, 0x9EE7,
- 0x9EEC, 0x9EED, 0x9EEE, 0x9EF0, 0x9EF1, 0x9EF2, 0x9EF5,
-};
-static const unsigned short euc_to_utf8_8FED[] = {
- 0x9EF8, 0x9EFF, 0x9F02, 0x9F03, 0x9F09, 0x9F0F, 0x9F10,
- 0x9F11, 0x9F12, 0x9F14, 0x9F16, 0x9F17, 0x9F19, 0x9F1A, 0x9F1B,
- 0x9F1F, 0x9F22, 0x9F26, 0x9F2A, 0x9F2B, 0x9F2F, 0x9F31, 0x9F32,
- 0x9F34, 0x9F37, 0x9F39, 0x9F3A, 0x9F3C, 0x9F3D, 0x9F3F, 0x9F41,
- 0x9F43, 0x9F44, 0x9F45, 0x9F46, 0x9F47, 0x9F53, 0x9F55, 0x9F56,
- 0x9F57, 0x9F58, 0x9F5A, 0x9F5D, 0x9F5E, 0x9F68, 0x9F69, 0x9F6D,
- 0x9F6E, 0x9F6F, 0x9F70, 0x9F71, 0x9F73, 0x9F75, 0x9F7A, 0x9F7D,
- 0x9F8F, 0x9F90, 0x9F91, 0x9F92, 0x9F94, 0x9F96, 0x9F97, 0x9F9E,
- 0x9FA1, 0x9FA2, 0x9FA3, 0x9FA5, 0, 0, 0, 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 short euc_to_utf8_8FF3[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174,
- 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x2160, 0x2161,
-};
-static const unsigned short euc_to_utf8_8FF4[] = {
- 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
- 0x2169, 0xff07, 0xff02, 0x3231, 0x2116, 0x2121, 0x70bb, 0x4efc,
- 0x50f4, 0x51ec, 0x5307, 0x5324, 0xfa0e, 0x548a, 0x5759, 0xfa0f,
- 0xfa10, 0x589e, 0x5bec, 0x5cf5, 0x5d53, 0xfa11, 0x5fb7, 0x6085,
- 0x6120, 0x654e, 0x663b, 0x6665, 0xfa12, 0xf929, 0x6801, 0xfa13,
- 0xfa14, 0x6a6b, 0x6ae2, 0x6df8, 0x6df2, 0x7028, 0xfa15, 0xfa16,
- 0x7501, 0x7682, 0x769e, 0xfa17, 0x7930, 0xfa18, 0xfa19, 0xfa1a,
- 0xfa1b, 0x7ae7, 0xfa1c, 0xfa1d, 0x7da0, 0x7dd6, 0xfa1e, 0x8362,
- 0xfa1f, 0x85b0, 0xfa20, 0xfa21, 0x8807, 0xfa22, 0x8b7f, 0x8cf4,
- 0x8d76, 0xfa23, 0xfa24, 0xfa25, 0x90de, 0xfa26, 0x9115, 0xfa27,
- 0xfa28, 0x9592, 0xf9dc, 0xfa29, 0x973b, 0x974d, 0x9751, 0xfa2a,
- 0xfa2b, 0xfa2c, 0x999e, 0x9ad9, 0x9b72, 0xfa2d, 0x9ed1,
-};
-#endif /* X0212_ENABLE */
-
-const unsigned short euc_to_utf8_1byte[] = {
- 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
- 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
- 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
- 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
- 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
- 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
- 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
- 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x00A9, 0x2122,
-};
-const unsigned short *const euc_to_utf8_2bytes[] = {
- euc_to_utf8_A1, euc_to_utf8_A2, euc_to_utf8_A3,
- euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
- euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
- euc_to_utf8_AC, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
- euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
- euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
- euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
- euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
- euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
- euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
- euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
- euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
- euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
- euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
- euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
- euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
- euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
- euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
- euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
- euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
- euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
- euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
- 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
- euc_to_utf8_FC, 0, 0,
-};
-/* Microsoft UCS Mapping Compatible */
-const unsigned short *const euc_to_utf8_2bytes_ms[] = {
- 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, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
- euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
- euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
- euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
- euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
- euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
- euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
- euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
- euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
- euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
- euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
- euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
- euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
- euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
- euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
- euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
- euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
- euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
- euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
- 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
- euc_to_utf8_FC_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,
-};
-const unsigned short *const euc_to_utf8_2bytes_x0213[] = {
- euc_to_utf8_A1, euc_to_utf8_A2_x0213, euc_to_utf8_A3_x0213,
- euc_to_utf8_A4_x0213, euc_to_utf8_A5_x0213, euc_to_utf8_A6_x0213, euc_to_utf8_A7_x0213,
- euc_to_utf8_A8_x0213, euc_to_utf8_A9_x0213, euc_to_utf8_AA_x0213, euc_to_utf8_AB_x0213,
- euc_to_utf8_AC_x0213, euc_to_utf8_AD_x0213, euc_to_utf8_AE_x0213, euc_to_utf8_AF_x0213,
- 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_x0213,
- 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_x0213, euc_to_utf8_F5_x0213, euc_to_utf8_F6_x0213, euc_to_utf8_F7_x0213,
- euc_to_utf8_F8_x0213, euc_to_utf8_F9_x0213, euc_to_utf8_FA_x0213, euc_to_utf8_FB_x0213,
- euc_to_utf8_FC_x0213, euc_to_utf8_FD_x0213, euc_to_utf8_FE_x0213,
-};
-
-#ifdef X0212_ENABLE
-const unsigned short *const x0212_to_utf8_2bytes[] = {
- 0, euc_to_utf8_8FA2, 0,
- 0, 0, euc_to_utf8_8FA6, euc_to_utf8_8FA7,
- 0, euc_to_utf8_8FA9, euc_to_utf8_8FAA, euc_to_utf8_8FAB,
- 0, 0, 0, 0,
- euc_to_utf8_8FB0, euc_to_utf8_8FB1, euc_to_utf8_8FB2, euc_to_utf8_8FB3,
- euc_to_utf8_8FB4, euc_to_utf8_8FB5, euc_to_utf8_8FB6, euc_to_utf8_8FB7,
- euc_to_utf8_8FB8, euc_to_utf8_8FB9, euc_to_utf8_8FBA, euc_to_utf8_8FBB,
- euc_to_utf8_8FBC, euc_to_utf8_8FBD, euc_to_utf8_8FBE, euc_to_utf8_8FBF,
- euc_to_utf8_8FC0, euc_to_utf8_8FC1, euc_to_utf8_8FC2, euc_to_utf8_8FC3,
- euc_to_utf8_8FC4, euc_to_utf8_8FC5, euc_to_utf8_8FC6, euc_to_utf8_8FC7,
- euc_to_utf8_8FC8, euc_to_utf8_8FC9, euc_to_utf8_8FCA, euc_to_utf8_8FCB,
- euc_to_utf8_8FCC, euc_to_utf8_8FCD, euc_to_utf8_8FCE, euc_to_utf8_8FCF,
- euc_to_utf8_8FD0, euc_to_utf8_8FD1, euc_to_utf8_8FD2, euc_to_utf8_8FD3,
- euc_to_utf8_8FD4, euc_to_utf8_8FD5, euc_to_utf8_8FD6, euc_to_utf8_8FD7,
- euc_to_utf8_8FD8, euc_to_utf8_8FD9, euc_to_utf8_8FDA, euc_to_utf8_8FDB,
- euc_to_utf8_8FDC, euc_to_utf8_8FDD, euc_to_utf8_8FDE, euc_to_utf8_8FDF,
- euc_to_utf8_8FE0, euc_to_utf8_8FE1, euc_to_utf8_8FE2, euc_to_utf8_8FE3,
- euc_to_utf8_8FE4, euc_to_utf8_8FE5, euc_to_utf8_8FE6, euc_to_utf8_8FE7,
- euc_to_utf8_8FE8, euc_to_utf8_8FE9, euc_to_utf8_8FEA, euc_to_utf8_8FEB,
- euc_to_utf8_8FEC, euc_to_utf8_8FED, 0, 0,
- 0, 0, 0, euc_to_utf8_8FF3,
- euc_to_utf8_8FF4, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0,};
-
-const unsigned short *const x0212_to_utf8_2bytes_x0213[] = {
- euc_to_utf8_8FA1_x0213, euc_to_utf8_8FA2, euc_to_utf8_8FA3_x0213,
- euc_to_utf8_8FA4_x0213, euc_to_utf8_8FA5_x0213, euc_to_utf8_8FA6, euc_to_utf8_8FA7,
- euc_to_utf8_8FA8_x0213, euc_to_utf8_8FA9, euc_to_utf8_8FAA, euc_to_utf8_8FAB,
- euc_to_utf8_8FAC_x0213, euc_to_utf8_8FAD_x0213, euc_to_utf8_8FAE_x0213, euc_to_utf8_8FAF_x0213,
- euc_to_utf8_8FB0, euc_to_utf8_8FB1, euc_to_utf8_8FB2, euc_to_utf8_8FB3,
- euc_to_utf8_8FB4, euc_to_utf8_8FB5, euc_to_utf8_8FB6, euc_to_utf8_8FB7,
- euc_to_utf8_8FB8, euc_to_utf8_8FB9, euc_to_utf8_8FBA, euc_to_utf8_8FBB,
- euc_to_utf8_8FBC, euc_to_utf8_8FBD, euc_to_utf8_8FBE, euc_to_utf8_8FBF,
- euc_to_utf8_8FC0, euc_to_utf8_8FC1, euc_to_utf8_8FC2, euc_to_utf8_8FC3,
- euc_to_utf8_8FC4, euc_to_utf8_8FC5, euc_to_utf8_8FC6, euc_to_utf8_8FC7,
- euc_to_utf8_8FC8, euc_to_utf8_8FC9, euc_to_utf8_8FCA, euc_to_utf8_8FCB,
- euc_to_utf8_8FCC, euc_to_utf8_8FCD, euc_to_utf8_8FCE, euc_to_utf8_8FCF,
- euc_to_utf8_8FD0, euc_to_utf8_8FD1, euc_to_utf8_8FD2, euc_to_utf8_8FD3,
- euc_to_utf8_8FD4, euc_to_utf8_8FD5, euc_to_utf8_8FD6, euc_to_utf8_8FD7,
- euc_to_utf8_8FD8, euc_to_utf8_8FD9, euc_to_utf8_8FDA, euc_to_utf8_8FDB,
- euc_to_utf8_8FDC, euc_to_utf8_8FDD, euc_to_utf8_8FDE, euc_to_utf8_8FDF,
- euc_to_utf8_8FE0, euc_to_utf8_8FE1, euc_to_utf8_8FE2, euc_to_utf8_8FE3,
- euc_to_utf8_8FE4, euc_to_utf8_8FE5, euc_to_utf8_8FE6, euc_to_utf8_8FE7,
- euc_to_utf8_8FE8, euc_to_utf8_8FE9, euc_to_utf8_8FEA, euc_to_utf8_8FEB,
- euc_to_utf8_8FEC, euc_to_utf8_8FED, euc_to_utf8_8FEE_x0213, euc_to_utf8_8FEF_x0213,
- euc_to_utf8_8FF0_x0213, euc_to_utf8_8FF1_x0213, euc_to_utf8_8FF2_x0213, euc_to_utf8_8FF3_x0213,
- euc_to_utf8_8FF4_x0213, euc_to_utf8_8FF5_x0213, euc_to_utf8_8FF6_x0213, euc_to_utf8_8FF7_x0213,
- euc_to_utf8_8FF8_x0213, euc_to_utf8_8FF9_x0213, euc_to_utf8_8FFA_x0213, euc_to_utf8_8FFB_x0213,
- euc_to_utf8_8FFC_x0213, euc_to_utf8_8FFD_x0213, euc_to_utf8_8FFE_x0213,};
-#endif /* X0212_ENABLE */
-
-const unsigned short x0213_combining_chars[sizeof_x0213_combining_chars] = {
- 0x309A, 0x0300, 0x0301, 0x02E5, 0x02E9,
-};
-const unsigned short x0213_combining_table[sizeof_x0213_combining_table][3] = {
- {0x2477, 0x304B, 0x309A},
- {0x2478, 0x304D, 0x309A},
- {0x2479, 0x304F, 0x309A},
- {0x247A, 0x3051, 0x309A},
- {0x247B, 0x3053, 0x309A},
- {0x2577, 0x30AB, 0x309A},
- {0x2578, 0x30AD, 0x309A},
- {0x2579, 0x30AF, 0x309A},
- {0x257A, 0x30B1, 0x309A},
- {0x257B, 0x30B3, 0x309A},
- {0x257C, 0x30BB, 0x309A},
- {0x257D, 0x30C4, 0x309A},
- {0x257E, 0x30C8, 0x309A},
- {0x2678, 0x31F7, 0x309A},
- {0x2B44, 0x00E6, 0x0300},
- {0x2B48, 0x0254, 0x0300},
- {0x2B49, 0x0254, 0x0301},
- {0x2B4A, 0x028C, 0x0300},
- {0x2B4B, 0x028C, 0x0301},
- {0x2B4C, 0x0259, 0x0300},
- {0x2B4D, 0x0259, 0x0301},
- {0x2B4E, 0x025A, 0x0300},
- {0x2B4F, 0x025A, 0x0301},
- {0x2B65, 0x02E9, 0x02E5},
- {0x2B66, 0x02E5, 0x02E9},
-};
-const unsigned short x0213_1_surrogate_table[sizeof_x0213_1_surrogate_table][3] = {
- {0x2E22, 0xD840, 0xDC0B},
- {0x2F42, 0xD844, 0xDE3D},
- {0x2F4C, 0xD844, 0xDF1B},
- {0x2F60, 0xD845, 0xDC6E},
- {0x2F7B, 0xD846, 0xDCBD},
- {0x4F54, 0xD842, 0xDF9F},
- {0x4F63, 0xD845, 0xDEB4},
- {0x4F6E, 0xD847, 0xDE34},
- {0x753A, 0xD84C, 0xDDC4},
- {0x7572, 0xD84D, 0xDDC4},
- {0x7629, 0xD84D, 0xDF3F},
- {0x7632, 0xD84D, 0xDF63},
- {0x7660, 0xD84F, 0xDCFE},
- {0x776C, 0xD851, 0xDFF1},
- {0x787E, 0xD855, 0xDC8E},
- {0x7929, 0xD855, 0xDD0E},
- {0x7947, 0xD855, 0xDF71},
- {0x7954, 0xD856, 0xDDC4},
- {0x796E, 0xD857, 0xDDA1},
- {0x7A5D, 0xD85A, 0xDEFF},
- {0x7B33, 0xD85B, 0xDE40},
- {0x7B49, 0xD85C, 0xDCF4},
- {0x7B6C, 0xD85D, 0xDE84},
- {0x7C49, 0xD860, 0xDE77},
- {0x7C51, 0xD860, 0xDFCD},
- {0x7E66, 0xD868, 0xDD90},
-};
-const unsigned short x0213_2_surrogate_table[sizeof_x0213_2_surrogate_table][3] = {
- {0x2121, 0xD840, 0xDC89},
- {0x212B, 0xD840, 0xDCA2},
- {0x212E, 0xD840, 0xDCA4},
- {0x2136, 0xD840, 0xDDA2},
- {0x2146, 0xD840, 0xDE13},
- {0x2170, 0xD840, 0xDF2B},
- {0x2177, 0xD840, 0xDF81},
- {0x2179, 0xD840, 0xDF71},
- {0x2322, 0xD840, 0xDFF9},
- {0x2325, 0xD841, 0xDC4A},
- {0x2327, 0xD841, 0xDD09},
- {0x2331, 0xD841, 0xDDD6},
- {0x2332, 0xD841, 0xDE28},
- {0x2338, 0xD841, 0xDF4F},
- {0x233F, 0xD842, 0xDC07},
- {0x2341, 0xD842, 0xDC3A},
- {0x234A, 0xD842, 0xDCB9},
- {0x2352, 0xD842, 0xDD7C},
- {0x2353, 0xD842, 0xDD9D},
- {0x2359, 0xD842, 0xDED3},
- {0x235C, 0xD842, 0xDF1D},
- {0x2377, 0xD843, 0xDD45},
- {0x242A, 0xD843, 0xDDE1},
- {0x2431, 0xD843, 0xDE95},
- {0x2432, 0xD843, 0xDE6D},
- {0x243A, 0xD843, 0xDE64},
- {0x243D, 0xD843, 0xDF5F},
- {0x2459, 0xD844, 0xDE01},
- {0x245C, 0xD844, 0xDE55},
- {0x245E, 0xD844, 0xDE7B},
- {0x2463, 0xD844, 0xDE74},
- {0x246A, 0xD844, 0xDEE4},
- {0x246B, 0xD844, 0xDED7},
- {0x2472, 0xD844, 0xDEFD},
- {0x2474, 0xD844, 0xDF36},
- {0x2475, 0xD844, 0xDF44},
- {0x2525, 0xD844, 0xDFC4},
- {0x2532, 0xD845, 0xDC6D},
- {0x253E, 0xD845, 0xDDD7},
- {0x2544, 0xD85B, 0xDC29},
- {0x2547, 0xD845, 0xDE47},
- {0x2555, 0xD845, 0xDF06},
- {0x2556, 0xD845, 0xDF42},
- {0x257E, 0xD846, 0xDDC3},
- {0x2830, 0xD847, 0xDC56},
- {0x2837, 0xD847, 0xDD2D},
- {0x2838, 0xD847, 0xDD45},
- {0x283A, 0xD847, 0xDD78},
- {0x283B, 0xD847, 0xDD62},
- {0x283F, 0xD847, 0xDDA1},
- {0x2840, 0xD847, 0xDD9C},
- {0x2845, 0xD847, 0xDD92},
- {0x2848, 0xD847, 0xDDB7},
- {0x284A, 0xD847, 0xDDE0},
- {0x284B, 0xD847, 0xDE33},
- {0x285B, 0xD847, 0xDF1E},
- {0x2866, 0xD847, 0xDF76},
- {0x286C, 0xD847, 0xDFFA},
- {0x2C22, 0xD848, 0xDD7B},
- {0x2C2B, 0xD848, 0xDF1E},
- {0x2C30, 0xD848, 0xDFAD},
- {0x2C50, 0xD849, 0xDEF3},
- {0x2C65, 0xD84A, 0xDC5B},
- {0x2C6D, 0xD84A, 0xDCAB},
- {0x2C72, 0xD84A, 0xDD8F},
- {0x2D24, 0xD84A, 0xDEB8},
- {0x2D29, 0xD84A, 0xDF4F},
- {0x2D2A, 0xD84A, 0xDF50},
- {0x2D32, 0xD84A, 0xDF46},
- {0x2D34, 0xD84B, 0xDC1D},
- {0x2D35, 0xD84A, 0xDFA6},
- {0x2D39, 0xD84B, 0xDC24},
- {0x2D56, 0xD84B, 0xDDE1},
- {0x2D7D, 0xD84C, 0xDDC3},
- {0x2E23, 0xD84C, 0xDDF5},
- {0x2E24, 0xD84C, 0xDDB6},
- {0x2E3A, 0xD84C, 0xDF72},
- {0x2E3C, 0xD84C, 0xDFD3},
- {0x2E3D, 0xD84C, 0xDFD2},
- {0x2E42, 0xD84C, 0xDFD0},
- {0x2E43, 0xD84C, 0xDFE4},
- {0x2E44, 0xD84C, 0xDFD5},
- {0x2E47, 0xD84C, 0xDFDA},
- {0x2E49, 0xD84C, 0xDFDF},
- {0x2E55, 0xD84D, 0xDC4A},
- {0x2E56, 0xD84D, 0xDC51},
- {0x2E57, 0xD84D, 0xDC4B},
- {0x2E5B, 0xD84D, 0xDC65},
- {0x2E77, 0xD84D, 0xDCE4},
- {0x2E78, 0xD84D, 0xDD5A},
- {0x2F2A, 0xD84D, 0xDD94},
- {0x2F3F, 0xD84D, 0xDE39},
- {0x2F40, 0xD84D, 0xDE47},
- {0x2F42, 0xD84D, 0xDE38},
- {0x2F43, 0xD84D, 0xDE3A},
- {0x2F4E, 0xD84D, 0xDF1C},
- {0x2F59, 0xD84D, 0xDF0C},
- {0x2F61, 0xD84D, 0xDF64},
- {0x2F69, 0xD84D, 0xDFFF},
- {0x2F6A, 0xD84D, 0xDFE7},
- {0x2F70, 0xD84E, 0xDC24},
- {0x2F75, 0xD84E, 0xDC3D},
- {0x6E23, 0xD84E, 0xDE98},
- {0x6E34, 0xD84F, 0xDC7F},
- {0x6E49, 0xD84F, 0xDD00},
- {0x6E5C, 0xD84F, 0xDD40},
- {0x6E5E, 0xD84F, 0xDDFA},
- {0x6E5F, 0xD84F, 0xDDF9},
- {0x6E60, 0xD84F, 0xDDD3},
- {0x6F32, 0xD84F, 0xDF7E},
- {0x6F47, 0xD850, 0xDC96},
- {0x6F4D, 0xD850, 0xDD03},
- {0x6F61, 0xD850, 0xDDC6},
- {0x6F64, 0xD850, 0xDDFE},
- {0x7022, 0xD850, 0xDFBC},
- {0x7033, 0xD851, 0xDE29},
- {0x7039, 0xD851, 0xDEA5},
- {0x7053, 0xD852, 0xDC96},
- {0x707B, 0xD852, 0xDE4D},
- {0x712E, 0xD852, 0xDF56},
- {0x7130, 0xD852, 0xDF6F},
- {0x7135, 0xD853, 0xDC16},
- {0x7144, 0xD853, 0xDD14},
- {0x715D, 0xD853, 0xDE0E},
- {0x7161, 0xD853, 0xDE37},
- {0x7166, 0xD853, 0xDE6A},
- {0x7169, 0xD853, 0xDE8B},
- {0x7175, 0xD854, 0xDC4A},
- {0x7177, 0xD854, 0xDC55},
- {0x717A, 0xD854, 0xDD22},
- {0x7221, 0xD854, 0xDDA9},
- {0x7223, 0xD854, 0xDDE5},
- {0x7224, 0xD854, 0xDDCD},
- {0x7228, 0xD854, 0xDE1E},
- {0x722C, 0xD854, 0xDE4C},
- {0x723D, 0xD855, 0xDC2E},
- {0x7248, 0xD855, 0xDCD9},
- {0x725B, 0xD855, 0xDDA7},
- {0x7275, 0xD855, 0xDFA9},
- {0x7276, 0xD855, 0xDFB4},
- {0x7332, 0xD856, 0xDDD4},
- {0x733D, 0xD856, 0xDEE4},
- {0x733E, 0xD856, 0xDEE3},
- {0x7340, 0xD856, 0xDEF1},
- {0x7352, 0xD856, 0xDFB2},
- {0x735D, 0xD857, 0xDC4B},
- {0x735E, 0xD857, 0xDC64},
- {0x7373, 0xD857, 0xDE2E},
- {0x7374, 0xD857, 0xDE56},
- {0x7375, 0xD857, 0xDE65},
- {0x7377, 0xD857, 0xDE62},
- {0x737B, 0xD857, 0xDED8},
- {0x737D, 0xD857, 0xDEC2},
- {0x7422, 0xD857, 0xDEE8},
- {0x7424, 0xD857, 0xDF23},
- {0x7427, 0xD857, 0xDF5C},
- {0x742E, 0xD857, 0xDFE0},
- {0x742F, 0xD857, 0xDFD4},
- {0x7434, 0xD858, 0xDC0C},
- {0x7435, 0xD857, 0xDFFB},
- {0x743D, 0xD858, 0xDC17},
- {0x7442, 0xD858, 0xDC60},
- {0x744F, 0xD858, 0xDCED},
- {0x7469, 0xD858, 0xDE70},
- {0x746B, 0xD858, 0xDE86},
- {0x7472, 0xD858, 0xDF4C},
- {0x7475, 0xD84F, 0xDD0E},
- {0x7479, 0xD859, 0xDC02},
- {0x7535, 0xD859, 0xDE7E},
- {0x753A, 0xD859, 0xDEB0},
- {0x7546, 0xD859, 0xDF1D},
- {0x7556, 0xD85A, 0xDCDD},
- {0x7558, 0xD85A, 0xDCEA},
- {0x755A, 0xD85A, 0xDD51},
- {0x755D, 0xD85A, 0xDD6F},
- {0x755F, 0xD85A, 0xDDDD},
- {0x7563, 0xD85A, 0xDE1E},
- {0x756A, 0xD85A, 0xDE58},
- {0x7570, 0xD85A, 0xDE8C},
- {0x7573, 0xD85A, 0xDEB7},
- {0x7644, 0xD85B, 0xDC73},
- {0x764E, 0xD85B, 0xDCDD},
- {0x765D, 0xD85B, 0xDE65},
- {0x7675, 0xD85B, 0xDF94},
- {0x767E, 0xD85B, 0xDFF8},
- {0x7721, 0xD85B, 0xDFF6},
- {0x7722, 0xD85B, 0xDFF7},
- {0x7733, 0xD85C, 0xDD0D},
- {0x7736, 0xD85C, 0xDD39},
- {0x7764, 0xD85C, 0xDFDB},
- {0x7765, 0xD85C, 0xDFDA},
- {0x776B, 0xD85C, 0xDFFE},
- {0x776E, 0xD85D, 0xDC10},
- {0x7773, 0xD85D, 0xDC49},
- {0x7829, 0xD85D, 0xDE15},
- {0x782A, 0xD85D, 0xDE14},
- {0x782C, 0xD85D, 0xDE31},
- {0x7834, 0xD85D, 0xDE93},
- {0x783C, 0xD85D, 0xDF0E},
- {0x783E, 0xD85D, 0xDF23},
- {0x7842, 0xD85D, 0xDF52},
- {0x7856, 0xD85E, 0xDD85},
- {0x7863, 0xD85E, 0xDE84},
- {0x7877, 0xD85E, 0xDFB3},
- {0x7879, 0xD85E, 0xDFBE},
- {0x787A, 0xD85E, 0xDFC7},
- {0x7925, 0xD85F, 0xDCB8},
- {0x792F, 0xD85F, 0xDDA0},
- {0x7932, 0xD85F, 0xDE10},
- {0x7939, 0xD85F, 0xDFB7},
- {0x7942, 0xD860, 0xDC8A},
- {0x7948, 0xD860, 0xDCBB},
- {0x7959, 0xD860, 0xDE82},
- {0x795E, 0xD860, 0xDEF3},
- {0x7966, 0xD861, 0xDC0C},
- {0x796B, 0xD861, 0xDC55},
- {0x797A, 0xD861, 0xDD6B},
- {0x797E, 0xD861, 0xDDC8},
- {0x7A21, 0xD861, 0xDDC9},
- {0x7A2C, 0xD861, 0xDED7},
- {0x7A2F, 0xD861, 0xDEFA},
- {0x7A4F, 0xD862, 0xDD49},
- {0x7A50, 0xD862, 0xDD46},
- {0x7A57, 0xD862, 0xDD6B},
- {0x7A65, 0xD862, 0xDD87},
- {0x7A66, 0xD862, 0xDD88},
- {0x7A71, 0xD862, 0xDDBA},
- {0x7A72, 0xD862, 0xDDBB},
- {0x7A7E, 0xD862, 0xDE1E},
- {0x7B21, 0xD862, 0xDE29},
- {0x7B2C, 0xD862, 0xDE71},
- {0x7B2D, 0xD862, 0xDE43},
- {0x7B36, 0xD862, 0xDE99},
- {0x7B37, 0xD862, 0xDECD},
- {0x7B3D, 0xD862, 0xDEE4},
- {0x7B3E, 0xD862, 0xDEDD},
- {0x7B4E, 0xD862, 0xDFC1},
- {0x7B4F, 0xD862, 0xDFEF},
- {0x7B57, 0xD863, 0xDD10},
- {0x7B5A, 0xD863, 0xDD71},
- {0x7B5C, 0xD863, 0xDDFB},
- {0x7B5D, 0xD863, 0xDE1F},
- {0x7B61, 0xD863, 0xDE36},
- {0x7B65, 0xD863, 0xDE89},
- {0x7B67, 0xD863, 0xDEEB},
- {0x7B69, 0xD863, 0xDF32},
- {0x7B71, 0xD863, 0xDFF8},
- {0x7C22, 0xD864, 0xDEA0},
- {0x7C23, 0xD864, 0xDEB1},
- {0x7C38, 0xD865, 0xDC90},
- {0x7C42, 0xD865, 0xDDCF},
- {0x7C4C, 0xD865, 0xDE7F},
- {0x7C56, 0xD865, 0xDEF0},
- {0x7C59, 0xD865, 0xDF19},
- {0x7C5D, 0xD865, 0xDF50},
- {0x7C76, 0xD866, 0xDCC6},
- {0x7D2C, 0xD866, 0xDE72},
- {0x7D4B, 0xD867, 0xDDDB},
- {0x7D4C, 0xD867, 0xDE3D},
- {0x7D59, 0xD867, 0xDE15},
- {0x7D5B, 0xD867, 0xDE8A},
- {0x7D5D, 0xD867, 0xDE49},
- {0x7D67, 0xD867, 0xDEC4},
- {0x7D6D, 0xD867, 0xDEE9},
- {0x7D70, 0xD867, 0xDEDB},
- {0x7E25, 0xD867, 0xDFCE},
- {0x7E29, 0xD868, 0xDC2F},
- {0x7E2B, 0xD868, 0xDC1A},
- {0x7E32, 0xD868, 0xDCF9},
- {0x7E35, 0xD868, 0xDC82},
- {0x7E53, 0xD848, 0xDE18},
- {0x7E58, 0xD868, 0xDF8C},
- {0x7E5A, 0xD869, 0xDC37},
- {0x7E6E, 0xD869, 0xDDF1},
- {0x7E70, 0xD869, 0xDE02},
- {0x7E72, 0xD869, 0xDE1A},
- {0x7E76, 0xD869, 0xDEB2},
-};
-#endif /* UTF8_OUTPUT_ENABLE */
-
-#ifdef UTF8_INPUT_ENABLE
-static const unsigned short utf8_to_euc_C2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xA242, 0x2171, 0x2172, 0xA270, 0x216F, 0xA243, 0x2178,
- 0x212F, 0xA26D, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
- 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
- 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
-};
-static const unsigned short utf8_to_euc_C2_ms[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xA242, 0x2171, 0x2172, 0xA270, 0x5C, 0xA243, 0x2178,
- 0x212F, 0xA26D, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
- 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
- 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
-};
-static 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,
- 0x00A0, 0xA242, 0x2171, 0x2172, 0xA270, 0x5C, 0xA243, 0x2178,
- 0x212F, 0x00FD, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
- 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
- 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
-};
-static const unsigned short utf8_to_euc_C2_932[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x21, 0x2171, 0x2172, 0, 0x5C, 0x7C, 0x2178,
- 0x212F, 0x63, 0x61, 0x2263, 0x224C, 0x2D, 0x52, 0x2131,
- 0x216B, 0x215E, 0x32, 0x33, 0x212D, 0x264C, 0x2279, 0x2126,
- 0x2124, 0x31, 0x6F, 0x2264, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_C2_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2922, 0x2923, 0x2171, 0x2172, 0x2924, 0x216F, 0x2925, 0x2178,
- 0x212F, 0x2926, 0x2927, 0x2928, 0x224C, 0x2929, 0x292A, 0x292B,
- 0x216B, 0x215E, 0x292C, 0x292D, 0x212D, 0, 0x2279, 0x292E,
- 0x292F, 0x2930, 0x2931, 0x2932, 0x2933, 0x2934, 0x2935, 0x2936,
-};
-static const unsigned short utf8_to_euc_C3[] = {
- 0xAA22, 0xAA21, 0xAA24, 0xAA2A, 0xAA23, 0xAA29, 0xA921, 0xAA2E,
- 0xAA32, 0xAA31, 0xAA34, 0xAA33, 0xAA40, 0xAA3F, 0xAA42, 0xAA41,
- 0, 0xAA50, 0xAA52, 0xAA51, 0xAA54, 0xAA58, 0xAA53, 0x215F,
- 0xA92C, 0xAA63, 0xAA62, 0xAA65, 0xAA64, 0xAA72, 0xA930, 0xA94E,
- 0xAB22, 0xAB21, 0xAB24, 0xAB2A, 0xAB23, 0xAB29, 0xA941, 0xAB2E,
- 0xAB32, 0xAB31, 0xAB34, 0xAB33, 0xAB40, 0xAB3F, 0xAB42, 0xAB41,
- 0xA943, 0xAB50, 0xAB52, 0xAB51, 0xAB54, 0xAB58, 0xAB53, 0x2160,
- 0xA94C, 0xAB63, 0xAB62, 0xAB65, 0xAB64, 0xAB72, 0xA950, 0xAB73,
-};
-static const unsigned short utf8_to_euc_C3_932[] = {
- 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43,
- 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
- 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x215F,
- 0x4F, 0x55, 0x55, 0x55, 0x55, 0x59, 0x54, 0x73,
- 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x63,
- 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69,
- 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x2160,
- 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0x74, 0x79,
-};
-static const unsigned short utf8_to_euc_C3_x0213[] = {
- 0x2937, 0x2938, 0x2939, 0x293A, 0x293B, 0x293C, 0x293D, 0x293E,
- 0x293F, 0x2940, 0x2941, 0x2942, 0x2943, 0x2944, 0x2945, 0x2946,
- 0x2947, 0x2948, 0x2949, 0x294A, 0x294B, 0x294C, 0x294D, 0x215F,
- 0x294E, 0x294F, 0x2950, 0x2951, 0x2952, 0x2953, 0x2954, 0x2955,
- 0x2956, 0x2957, 0x2958, 0x2959, 0x295A, 0x295B, 0x295C, 0x295D,
- 0x295E, 0x295F, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964, 0x2965,
- 0x2966, 0x2967, 0x2968, 0x2969, 0x296A, 0x296B, 0x296C, 0x2160,
- 0x296D, 0x296E, 0x296F, 0x2970, 0x2971, 0x2972, 0x2973, 0x2974,
-};
-static const unsigned short utf8_to_euc_C4[] = {
- 0xAA27, 0xAB27, 0xAA25, 0xAB25, 0xAA28, 0xAB28, 0xAA2B, 0xAB2B,
- 0xAA2C, 0xAB2C, 0xAA2F, 0xAB2F, 0xAA2D, 0xAB2D, 0xAA30, 0xAB30,
- 0xA922, 0xA942, 0xAA37, 0xAB37, 0, 0, 0xAA36, 0xAB36,
- 0xAA38, 0xAB38, 0xAA35, 0xAB35, 0xAA3A, 0xAB3A, 0xAA3B, 0xAB3B,
- 0xAA3D, 0xAB3D, 0xAA3C, 0, 0xAA3E, 0xAB3E, 0xA924, 0xA944,
- 0xAA47, 0xAB47, 0xAA45, 0xAB45, 0, 0, 0xAA46, 0xAB46,
- 0xAA44, 0xA945, 0xA926, 0xA946, 0xAA48, 0xAB48, 0xAA49, 0xAB49,
- 0xA947, 0xAA4A, 0xAB4A, 0xAA4C, 0xAB4C, 0xAA4B, 0xAB4B, 0xA929,
-};
-static const unsigned short utf8_to_euc_C4_x0213[] = {
- 0x2975, 0x297A, 0x2A3A, 0x2A49, 0x2A21, 0x2A2C, 0x2A3C, 0x2A4B,
- 0x2A59, 0x2A5F, 0xAA2F, 0xAB2F, 0x2A3D, 0x2A4C, 0x2A40, 0x2A4F,
- 0xA922, 0x2A50, 0x2978, 0x297D, 0, 0, 0xAA36, 0xAB36,
- 0x2A3E, 0x2A4D, 0x2A3F, 0x2A4E, 0x2A5A, 0x2A60, 0xAA3B, 0xAB3B,
- 0xAA3D, 0xAB3D, 0xAA3C, 0, 0x2A5B, 0x2A61, 0xA924, 0x2A7D,
- 0xAA47, 0xAB47, 0x2976, 0x297B, 0, 0, 0xAA46, 0xAB46,
- 0xAA44, 0xA945, 0xA926, 0xA946, 0x2A5C, 0x2A62, 0xAA49, 0xAB49,
- 0xA947, 0x2A3B, 0x2A4A, 0xAA4C, 0xAB4C, 0x2A24, 0x2A2F, 0xA929,
-};
-static const unsigned short utf8_to_euc_C5[] = {
- 0xA949, 0xA928, 0xA948, 0xAA4D, 0xAB4D, 0xAA4F, 0xAB4F, 0xAA4E,
- 0xAB4E, 0xA94A, 0xA92B, 0xA94B, 0xAA57, 0xAB57, 0, 0,
- 0xAA56, 0xAB56, 0xA92D, 0xA94D, 0xAA59, 0xAB59, 0xAA5B, 0xAB5B,
- 0xAA5A, 0xAB5A, 0xAA5C, 0xAB5C, 0xAA5D, 0xAB5D, 0xAA5F, 0xAB5F,
- 0xAA5E, 0xAB5E, 0xAA61, 0xAB61, 0xAA60, 0xAB60, 0xA92F, 0xA94F,
- 0xAA6C, 0xAB6C, 0xAA69, 0xAB69, 0xAA66, 0xAB66, 0xAA6B, 0xAB6B,
- 0xAA68, 0xAB68, 0xAA6A, 0xAB6A, 0xAA71, 0xAB71, 0xAA74, 0xAB74,
- 0xAA73, 0xAA75, 0xAB75, 0xAA77, 0xAB77, 0xAA76, 0xAB76, 0,
-};
-static const unsigned short utf8_to_euc_C5_x0213[] = {
- 0xA949, 0x2A23, 0x2A2E, 0x2A41, 0x2A51, 0xAA4F, 0xAB4F, 0x2A42,
- 0x2A52, 0xA94A, 0xA92B, 0x2A7A, 0x2979, 0x297E, 0, 0,
- 0x2A43, 0x2A53, 0x2B2B, 0x2B2A, 0x2A39, 0x2A48, 0xAA5B, 0xAB5B,
- 0x2A44, 0x2A54, 0x2A25, 0x2A30, 0x2A5D, 0x2A63, 0x2A27, 0x2A33,
- 0x2A26, 0x2A32, 0x2A47, 0x2A57, 0x2A28, 0x2A34, 0xA92F, 0xA94F,
- 0xAA6C, 0xAB6C, 0x2977, 0x297C, 0x2A5E, 0x2A64, 0x2A45, 0x2A55,
- 0x2A46, 0x2A56, 0xAA6A, 0xAB6A, 0xAA71, 0xAB71, 0xAA74, 0xAB74,
- 0xAA73, 0x2A29, 0x2A35, 0x2A2B, 0x2A38, 0x2A2A, 0x2A37, 0,
-};
-static const unsigned short utf8_to_euc_C6_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2B29, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_C7[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xAA26, 0xAB26, 0xAA43,
- 0xAB43, 0xAA55, 0xAB55, 0xAA67, 0xAB67, 0xAA70, 0xAB70, 0xAA6D,
- 0xAB6D, 0xAA6F, 0xAB6F, 0xAA6E, 0xAB6E, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xAB39, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_C7_x0213[] = {
- 0, 0, 0x2B24, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x286F, 0x2870, 0xAA43,
- 0x2871, 0x2876, 0x2877, 0xAA67, 0x2878, 0xAA70, 0x2879, 0xAA6D,
- 0x287A, 0xAA6F, 0x287B, 0xAA6E, 0x287C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xAB39, 0, 0,
- 0x2874, 0x2875, 0, 0, 0, 0x2B45, 0, 0,
-};
-static const unsigned short utf8_to_euc_C9_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2B33, 0x2B39, 0x2B3A, 0x2B25, 0x2B38, 0x2B3F, 0x2A6E, 0x2B26,
- 0x2B2E, 0x2B30, 0x2B43, 0, 0x2B31, 0, 0x2B32, 0x2A75,
- 0x2B28, 0x2A79, 0, 0, 0x2B36, 0x2B3C, 0x2B22, 0x2B42,
- 0x2B2C, 0, 0, 0, 0x2A6A, 0x2A74, 0x2A6B, 0x2B34,
- 0x2A7B, 0x2A65, 0x2A76, 0x2A6F, 0, 0x2B2F, 0, 0,
- 0, 0x2A6C, 0x2B41, 0x2A73, 0, 0x2A70, 0x2A67, 0,
-};
-static const unsigned short utf8_to_euc_CA_x0213[] = {
- 0, 0x2A7C, 0x2A71, 0x2A68, 0x2B27, 0, 0, 0,
- 0x2A6D, 0x2B2D, 0x2B35, 0x2A66, 0x2B37, 0x2B3B, 0x2A78, 0,
- 0x2A72, 0x2B40, 0x2A69, 0, 0x2B21, 0x2A7E, 0, 0,
- 0x2B23, 0, 0, 0, 0, 0x2A77, 0, 0,
- 0, 0x2B3E, 0x2B3D, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_CB[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xA230,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xA22F, 0xA232, 0xA236, 0xA235, 0, 0xA233, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_CB_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0x2A31,
- 0x2B53, 0, 0, 0, 0x2B54, 0, 0, 0,
- 0x2B55, 0x2B56, 0, 0, 0, 0, 0, 0,
- 0x2A22, 0x2A58, 0xA236, 0x2A2D, 0, 0x2A36, 0x2B71, 0,
- 0, 0, 0, 0, 0, 0x2B60, 0x2B61, 0x2B62,
- 0x2B63, 0x2B64, 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 short utf8_to_euc_CC_x0213[] = {
- 0x2B5C, 0x2B5A, 0x2B5F, 0x2B7D, 0x2B5B, 0, 0x2B57, 0,
- 0x2B6D, 0, 0, 0x2B59, 0x2B5E, 0, 0, 0x2B5D,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2B78, 0x2B79, 0x2B7E, 0, 0x2B6A, 0x2B76, 0x2B77, 0x2B6B,
- 0x2B6C, 0, 0, 0, 0x2B72, 0x2B67, 0, 0,
- 0, 0x2B6F, 0x2B7A, 0, 0x2B68, 0, 0, 0x2B70,
- 0x2B73, 0, 0, 0, 0x2B75, 0, 0, 0,
- 0, 0x2B69, 0x2B7B, 0x2B7C, 0x2B74, 0x2B6E, 0, 0,
-};
-static const unsigned short utf8_to_euc_CD_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2B52, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_CE[] = {
- 0, 0, 0, 0, 0xA238, 0xA239, 0xA661, 0,
- 0xA662, 0xA663, 0xA664, 0, 0xA667, 0, 0xA669, 0xA66C,
- 0xA676, 0x2621, 0x2622, 0x2623, 0x2624, 0x2625, 0x2626, 0x2627,
- 0x2628, 0x2629, 0x262A, 0x262B, 0x262C, 0x262D, 0x262E, 0x262F,
- 0x2630, 0x2631, 0, 0x2632, 0x2633, 0x2634, 0x2635, 0x2636,
- 0x2637, 0x2638, 0xA665, 0xA66A, 0xA671, 0xA672, 0xA673, 0xA674,
- 0xA67B, 0x2641, 0x2642, 0x2643, 0x2644, 0x2645, 0x2646, 0x2647,
- 0x2648, 0x2649, 0x264A, 0x264B, 0x264C, 0x264D, 0x264E, 0x264F,
-};
-static const unsigned short utf8_to_euc_CF[] = {
- 0x2650, 0x2651, 0xA678, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656,
- 0x2657, 0x2658, 0xA675, 0xA67A, 0xA677, 0xA679, 0xA67C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_CF_x0213[] = {
- 0x2650, 0x2651, 0x2659, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656,
- 0x2657, 0x2658, 0xA675, 0xA67A, 0xA677, 0xA679, 0xA67C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_D0[] = {
- 0, 0x2727, 0xA742, 0xA743, 0xA744, 0xA745, 0xA746, 0xA747,
- 0xA748, 0xA749, 0xA74A, 0xA74B, 0xA74C, 0, 0xA74D, 0xA74E,
- 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2728, 0x2729,
- 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0x2730, 0x2731,
- 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, 0x2739,
- 0x273A, 0x273B, 0x273C, 0x273D, 0x273E, 0x273F, 0x2740, 0x2741,
- 0x2751, 0x2752, 0x2753, 0x2754, 0x2755, 0x2756, 0x2758, 0x2759,
- 0x275A, 0x275B, 0x275C, 0x275D, 0x275E, 0x275F, 0x2760, 0x2761,
-};
-static const unsigned short utf8_to_euc_D1[] = {
- 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x2768, 0x2769,
- 0x276A, 0x276B, 0x276C, 0x276D, 0x276E, 0x276F, 0x2770, 0x2771,
- 0, 0x2757, 0xA772, 0xA773, 0xA774, 0xA775, 0xA776, 0xA777,
- 0xA778, 0xA779, 0xA77A, 0xA77B, 0xA77C, 0, 0xA77D, 0xA77E,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E1B8_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2872, 0x2873,
-};
-static const unsigned short utf8_to_euc_E1BD_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2B46, 0x2B47, 0x2B50, 0x2B51, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E280[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x213E, 0, 0, 0, 0x213D, 0x213D, 0x2142, 0,
- 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
- 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
- 0, 0, 0, 0x2228, 0, 0, 0x2131, 0,
-};
-static const unsigned short utf8_to_euc_E280_ms[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x213E, 0, 0, 0, 0x213D, 0x213D, 0x2142, 0,
- 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
- 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
- 0, 0, 0, 0x2228, 0, 0, 0x7E, 0,
-};
-static const unsigned short utf8_to_euc_E280_932[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x213E, 0, 0, 0, 0, 0x213D, 0, 0,
- 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
- 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
- 0, 0, 0, 0x2228, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E280_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x213E, 0, 0, 0x237C, 0x213D, 0x213D, 0x2142, 0,
- 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
- 0x2277, 0x2278, 0x2340, 0, 0, 0x2145, 0x2144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
- 0, 0, 0, 0x2228, 0x286B, 0, 0x2131, 0x2B58,
-};
-static const unsigned short utf8_to_euc_E281_x0213[] = {
- 0, 0, 0x2C7E, 0, 0, 0, 0, 0x286C,
- 0x286D, 0x286E, 0, 0, 0, 0, 0, 0,
- 0, 0x2C7D, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E282_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 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, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E284[] = {
- 0, 0, 0, 0x216E, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2D62, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2D64, 0xA26F, 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,
-};
-static 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, 0x00FE, 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,
-};
-static const unsigned short utf8_to_euc_E284_x0213[] = {
- 0, 0, 0, 0x216E, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x235D,
- 0, 0, 0, 0x235F, 0, 0, 0x2D62, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2D64, 0xA26F, 0, 0, 0, 0, 0x2360,
- 0, 0, 0, 0x2272, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x235C, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E285[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2D35, 0x2D36, 0x2D37, 0x2D38, 0x2D39, 0x2D3A, 0x2D3B, 0x2D3C,
- 0x2D3D, 0x2D3E, 0, 0, 0, 0, 0, 0,
- 0xF373, 0xF374, 0xF375, 0xF376, 0xF377, 0xF378, 0xF379, 0xF37A,
- 0xF37B, 0xF37C, 0, 0, 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E285_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2778, 0x2779, 0x277A, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2D35, 0x2D36, 0x2D37, 0x2D38, 0x2D39, 0x2D3A, 0x2D3B, 0x2D3C,
- 0x2D3D, 0x2D3E, 0x2D3F, 0x2D57, 0, 0, 0, 0,
- 0x2C35, 0x2C36, 0x2C37, 0x2C38, 0x2C39, 0x2C3A, 0x2C3B, 0x2C3C,
- 0x2C3D, 0x2C3E, 0x2C3F, 0x2C40, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E286[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x222B, 0x222C, 0x222A, 0x222D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E286_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x222B, 0x222C, 0x222A, 0x222D, 0x2271, 0, 0x2327, 0x2325,
- 0x2326, 0x2328, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E287[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x224D, 0, 0x224E, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E287_x0213[] = {
- 0, 0, 0, 0, 0x2329, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x224D, 0, 0x224E, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x232B, 0x232C,
- 0x232A, 0x232D, 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 short utf8_to_euc_E288[] = {
- 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
- 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
- 0, 0x2D74, 0x215D, 0, 0, 0, 0, 0,
- 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
- 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
- 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
- 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
- 0, 0, 0, 0, 0, 0x2266, 0, 0,
-};
-static const unsigned short utf8_to_euc_E288_932[] = {
- 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
- 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
- 0, 0x2D74, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
- 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
- 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
- 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
- 0, 0, 0, 0, 0, 0x2266, 0, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E288_x0213[] = {
- 0x224F, 0, 0x225F, 0x2250, 0, 0x2247, 0, 0x2260,
- 0x223A, 0x2246, 0, 0x223B, 0, 0, 0, 0,
- 0, 0x2D74, 0x215D, 0x235B, 0, 0, 0, 0,
- 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
- 0x225C, 0, 0, 0, 0, 0x2254, 0x2255, 0x224A,
- 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
- 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
- 0, 0, 0, 0, 0, 0x2266, 0, 0,
-};
-static const unsigned short utf8_to_euc_E289[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2262, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2162, 0x2261, 0, 0, 0, 0, 0x2165, 0x2166,
- 0, 0, 0x2263, 0x2264, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E289_x0213[] = {
- 0, 0, 0, 0x226C, 0, 0x226D, 0, 0,
- 0x226E, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2262, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2162, 0x2261, 0x226B, 0, 0, 0, 0x2165, 0x2166,
- 0, 0, 0x2263, 0x2264, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x226F, 0x2270,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E28A[] = {
- 0, 0, 0x223E, 0x223F, 0, 0, 0x223C, 0x223D,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x225D, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2D79,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E28A_x0213[] = {
- 0, 0, 0x223E, 0x223F, 0x2242, 0x2243, 0x223C, 0x223D,
- 0, 0, 0x2244, 0x2245, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2251, 0x2252, 0x2253,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x225D, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2D79,
-};
-static const unsigned short utf8_to_euc_E28B_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2776, 0x2777, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E28C[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x225E, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E28C_x0213[] = {
- 0, 0, 0, 0, 0, 0x2248, 0x2249, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x225E, 0, 0, 0, 0, 0,
- 0x277C, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E28E_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2742, 0x2743,
-};
-static const unsigned short utf8_to_euc_E28F_x0213[] = {
- 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274A, 0x274B,
- 0x274C, 0x274D, 0x274E, 0x274F, 0x2750, 0, 0x277E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E290_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x277D, 0, 0, 0, 0,
- 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 short utf8_to_euc_E291[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2D21, 0x2D22, 0x2D23, 0x2D24, 0x2D25, 0x2D26, 0x2D27, 0x2D28,
- 0x2D29, 0x2D2A, 0x2D2B, 0x2D2C, 0x2D2D, 0x2D2E, 0x2D2F, 0x2D30,
- 0x2D31, 0x2D32, 0x2D33, 0x2D34, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E293_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2C41, 0x2C42, 0x2C43, 0x2C44, 0x2C45, 0x2C46, 0x2C47, 0x2C48,
- 0x2C49, 0x2C4A, 0x2C4B, 0x2C4C, 0x2C4D, 0x2C4E, 0x2C4F, 0x2C50,
- 0x2C51, 0x2C52, 0x2C53, 0x2C54, 0x2C55, 0x2C56, 0x2C57, 0x2C58,
- 0x2C59, 0x2C5A, 0, 0x2C2B, 0x2C2C, 0x2C2D, 0x2C2E, 0x2C2F,
- 0x2C30, 0x2C31, 0x2C32, 0x2C33, 0x2C34, 0x265A, 0x265B, 0x265C,
- 0x265D, 0x265E, 0x265F, 0x2660, 0x2661, 0x2662, 0x2663, 0,
-};
-static const unsigned short utf8_to_euc_E294[] = {
- 0x2821, 0x282C, 0x2822, 0x282D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2823, 0, 0, 0x282E,
- 0x2824, 0, 0, 0x282F, 0x2826, 0, 0, 0x2831,
- 0x2825, 0, 0, 0x2830, 0x2827, 0x283C, 0, 0,
- 0x2837, 0, 0, 0x2832, 0x2829, 0x283E, 0, 0,
- 0x2839, 0, 0, 0x2834, 0x2828, 0, 0, 0x2838,
- 0x283D, 0, 0, 0x2833, 0x282A, 0, 0, 0x283A,
- 0x283F, 0, 0, 0x2835, 0x282B, 0, 0, 0x283B,
-};
-static const unsigned short utf8_to_euc_E295[] = {
- 0, 0, 0x2840, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2836, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E296[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2223, 0x2222, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2225, 0x2224, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2227, 0x2226, 0, 0,
-};
-static const unsigned short utf8_to_euc_E296_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2223, 0x2222, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x266D, 0x2225, 0x2224, 0, 0, 0x2322, 0x2321,
- 0, 0, 0, 0, 0x2227, 0x2226, 0, 0,
-};
-static const unsigned short utf8_to_euc_E297[] = {
- 0, 0, 0, 0, 0, 0, 0x2221, 0x217E,
- 0, 0, 0, 0x217B, 0, 0, 0x217D, 0x217C,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x227E,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E297_x0213[] = {
- 0x2324, 0x2323, 0, 0, 0, 0, 0x2221, 0x217E,
- 0, 0x233B, 0, 0x217B, 0, 0, 0x217D, 0x217C,
- 0x2867, 0x2868, 0x2869, 0x286A, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x233F, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x227E,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E298[] = {
- 0, 0, 0, 0, 0, 0x217A, 0x2179, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E298_x0213[] = {
- 0x2668, 0x2669, 0x266A, 0x266B, 0, 0x217A, 0x2179, 0,
- 0, 0, 0, 0, 0, 0, 0x2667, 0,
- 0, 0, 0, 0, 0, 0, 0x2664, 0x2665,
- 0, 0, 0, 0, 0, 0, 0x2D7E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E299[] = {
- 0x216A, 0, 0x2169, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2276, 0, 0, 0x2275, 0, 0x2274,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E299_x0213[] = {
- 0x216A, 0, 0x2169, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x263A, 0x263D, 0x263B, 0x2640, 0x2639, 0x263E, 0x263C, 0x263F,
- 0x266C, 0x227D, 0x2276, 0x227B, 0x227C, 0x2275, 0x227A, 0x2274,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E29C_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x277B, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E29D_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2D7D, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2C21, 0x2C22,
- 0x2C23, 0x2C24, 0x2C25, 0x2C26, 0x2C27, 0x2C28, 0x2C29, 0x2C2A,
-};
-static const unsigned short utf8_to_euc_E2A4_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x232E, 0x232F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E2A6_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x233A,
-};
-static const unsigned short utf8_to_euc_E2A7_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x237D, 0x237E, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E380[] = {
- 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
- 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
- 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0, 0,
- 0, 0, 0, 0, 0x2141, 0x2D60, 0, 0x2D61,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E380_932[] = {
- 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
- 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
- 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0, 0,
- 0, 0, 0, 0, 0, 0x2D60, 0, 0x2D61,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E380_x0213[] = {
- 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
- 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
- 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0x225A, 0x225B,
- 0x2258, 0x2259, 0, 0, 0x2141, 0x2D60, 0, 0x2D61,
- 0x2666, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2233, 0x2234, 0x2235, 0, 0,
- 0, 0, 0, 0x2236, 0x2237, 0x233C, 0, 0,
-};
-static const unsigned short utf8_to_euc_E381[] = {
- 0, 0x2421, 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427,
- 0x2428, 0x2429, 0x242A, 0x242B, 0x242C, 0x242D, 0x242E, 0x242F,
- 0x2430, 0x2431, 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437,
- 0x2438, 0x2439, 0x243A, 0x243B, 0x243C, 0x243D, 0x243E, 0x243F,
- 0x2440, 0x2441, 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447,
- 0x2448, 0x2449, 0x244A, 0x244B, 0x244C, 0x244D, 0x244E, 0x244F,
- 0x2450, 0x2451, 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457,
- 0x2458, 0x2459, 0x245A, 0x245B, 0x245C, 0x245D, 0x245E, 0x245F,
-};
-static const unsigned short utf8_to_euc_E382[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
- 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
- 0x2470, 0x2471, 0x2472, 0x2473, 0, 0, 0, 0,
- 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0,
- 0, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
- 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
- 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
- 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
-};
-static const unsigned short utf8_to_euc_E382_932[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
- 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
- 0x2470, 0x2471, 0x2472, 0x2473, 0x2574, 0, 0, 0,
- 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0,
- 0, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
- 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
- 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
- 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
-};
-static const unsigned short utf8_to_euc_E382_x0213[] = {
- 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
- 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
- 0x2470, 0x2471, 0x2472, 0x2473, 0x2474, 0x2475, 0x2476, 0,
- 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0x2239,
- 0x237B, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
- 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
- 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
- 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
-};
-static const unsigned short utf8_to_euc_E383[] = {
- 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
- 0x2548, 0x2549, 0x254A, 0x254B, 0x254C, 0x254D, 0x254E, 0x254F,
- 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557,
- 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F,
- 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
- 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x256D, 0x256E, 0x256F,
- 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0,
- 0, 0, 0, 0x2126, 0x213C, 0x2133, 0x2134, 0,
-};
-static const unsigned short utf8_to_euc_E383_x0213[] = {
- 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
- 0x2548, 0x2549, 0x254A, 0x254B, 0x254C, 0x254D, 0x254E, 0x254F,
- 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557,
- 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F,
- 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
- 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x256D, 0x256E, 0x256F,
- 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0x2772,
- 0x2773, 0x2774, 0x2775, 0x2126, 0x213C, 0x2133, 0x2134, 0x2238,
-};
-static const unsigned short utf8_to_euc_E387_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x266E, 0x266F, 0x2670, 0x2671, 0x2672, 0x2673, 0x2674, 0x2675,
- 0x2676, 0x2677, 0x2679, 0x267A, 0x267B, 0x267C, 0x267D, 0x267E,
-};
-static const unsigned short utf8_to_euc_E388[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2D6A, 0x2D6B, 0, 0, 0, 0, 0,
- 0, 0x2D6C, 0, 0, 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E389_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2841, 0x2842, 0x2843, 0x2844, 0x2845, 0x2846, 0x2847,
- 0x2848, 0x2849, 0x284A, 0x284B, 0x284C, 0x284D, 0x284E, 0x284F,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E38A[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2D65, 0x2D66, 0x2D67, 0x2D68,
- 0x2D69, 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 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,
-};
-static const unsigned short utf8_to_euc_E38A_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2D65, 0x2D66, 0x2D67, 0x2D68,
- 0x2D69, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2850, 0x2851, 0x2852, 0x2853, 0x2854, 0x2855, 0x2856,
- 0x2857, 0x2858, 0x2859, 0x285A, 0x285B, 0x285C, 0x285D, 0x285E,
-};
-static const unsigned short utf8_to_euc_E38B_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2C5B, 0x2C5C, 0x2C5D, 0x2C5E, 0x2C5F, 0x2C60, 0x2C61, 0x2C62,
- 0x2C63, 0x2C64, 0x2C65, 0x2C66, 0x2C67, 0x2C68, 0x2C69, 0x2C6A,
- 0x2C6B, 0x2C6C, 0x2C6D, 0x2C6E, 0, 0x2C71, 0, 0,
- 0, 0x2C70, 0, 0, 0x2C73, 0x2C72, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2C6F, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E38C[] = {
- 0, 0, 0, 0x2D46, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2D4A, 0, 0,
- 0, 0, 0, 0, 0x2D41, 0, 0, 0,
- 0x2D44, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2D42, 0x2D4C, 0, 0, 0x2D4B, 0x2D45,
- 0, 0, 0, 0x2D4D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2D47, 0,
- 0, 0, 0, 0x2D4F, 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E38D[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2D40, 0x2D4E, 0, 0, 0x2D43, 0, 0,
- 0, 0x2D48, 0, 0, 0, 0, 0, 0x2D49,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2D5F, 0x2D6F, 0x2D6E, 0x2D6D, 0,
-};
-static 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,
-};
-static const unsigned short utf8_to_euc_E38E[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2D53, 0x2D54,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2D50, 0x2D51, 0x2D52, 0,
- 0, 0x2D56, 0, 0, 0, 0, 0, 0,
- 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 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,
-};
-static const unsigned short utf8_to_euc_E38F[] = {
- 0, 0, 0, 0, 0x2D55, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2D63, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 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,
-};
-static const unsigned short utf8_to_euc_E38F_x0213[] = {
- 0, 0, 0, 0, 0x2D55, 0, 0, 0,
- 0, 0, 0, 0x235E, 0, 0x2D63, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E390_x0213[] = {
- 0, 0, 0x2E23, 0, 0, 0, 0xA12D, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xA132, 0, 0xA133, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E391_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xA15E, 0, 0xA156, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E392_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xA17E, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2E53, 0, 0,
- 0, 0, 0, 0, 0xA32B, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E393_x0213[] = {
- 0, 0xF468, 0, 0, 0, 0, 0, 0xA32F,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2E5B, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E394_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xA348,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E395_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xA35D, 0xA35E, 0,
- 0, 0, 0, 0xA361, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xA367, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E396_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xA423, 0,
- 0xA426, 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 short utf8_to_euc_E397_x0213[] = {
- 0, 0, 0, 0, 0, 0xA42F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xA438, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xA442, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E398_x0213[] = {
- 0, 0, 0, 0, 0, 0xA44A, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E399_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xA479, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E39A_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xA53F, 0, 0, 0, 0, 0xA543, 0,
- 0, 0xA541, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E39B_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xA557,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E39D_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xA823, 0xA825, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xA829, 0xA828, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xA82C, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E39E_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x4F5F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E39F_x0213[] = {
- 0, 0xA83E, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x4F6F, 0, 0, 0, 0, 0,
- 0xA856, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xA859, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xA85C, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3A0_x0213[] = {
- 0xA85E, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xA86F,
- 0, 0, 0, 0, 0, 0, 0xA871, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3A1_x0213[] = {
- 0xA874, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xA879, 0, 0, 0,
- 0, 0xA87B, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3A3_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xAC3B, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3A4_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xAC46,
- 0, 0, 0xAC4A, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3A5_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xAC60,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3A9_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xAD5B, 0,
- 0, 0, 0, 0xAD5F, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3AB_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xAD71, 0xAE36,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xAD7C, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3AC_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xAE2E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xAE32, 0, 0xAE34, 0, 0, 0,
- 0, 0, 0x7549, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3AD_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xAE6D, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xAE65,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3AE_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xAF28,
- 0xAF29, 0, 0, 0, 0, 0xAF2C, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xAF34, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x757E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3AF_x0213[] = {
- 0, 0, 0, 0x7621, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xAF48, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xAF5D, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3B0_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x763A,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xAF77, 0,
- 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 short utf8_to_euc_E3B3_x0213[] = {
- 0, 0, 0, 0xEE3B, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xEE42, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3B4_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xEE71, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xEE7E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3B5_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xEF40, 0, 0, 0,
- 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 short utf8_to_euc_E3B6_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xEF54, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3B7_x0213[] = {
- 0xEF70, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xEF77, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3B8_x0213[] = {
- 0, 0, 0, 0, 0, 0xF028, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x7766,
-};
-static const unsigned short utf8_to_euc_E3B9_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF03F, 0, 0, 0, 0, 0, 0xF041, 0,
- 0xF042, 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 short utf8_to_euc_E3BA_x0213[] = {
- 0, 0, 0, 0xF049, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF050, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E3BD_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF134,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x784D, 0, 0, 0xF146, 0, 0xF148,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3BE_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF15C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E3BF_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xF167, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF16C,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E480_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xF222, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E481_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF22D, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E482_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xF239, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E484_x0213[] = {
- 0, 0, 0, 0, 0, 0xF264, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E485_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF274, 0, 0, 0, 0, 0, 0, 0xF277,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xF27D, 0, 0, 0, 0,
- 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 short utf8_to_euc_E486_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF333, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF337,
-};
-static const unsigned short utf8_to_euc_E487_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF347, 0,
- 0, 0, 0, 0, 0, 0, 0xF34B, 0,
- 0, 0, 0, 0xF348, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E488_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xF353,
- 0, 0, 0, 0, 0, 0, 0xF357, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E489_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x796D, 0, 0, 0,
- 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 short utf8_to_euc_E48B_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0xF42B, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF436, 0,
- 0, 0, 0, 0, 0, 0xF43B, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E48C_x0213[] = {
- 0, 0, 0xF44E, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xF45D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E48D_x0213[] = {
- 0, 0, 0, 0xF461, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E48F_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF53E, 0,
- 0xF542, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E490_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF548, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF54A,
- 0, 0, 0, 0, 0xF54C, 0, 0, 0,
- 0, 0, 0xF54F, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E491_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x7A59, 0, 0, 0, 0,
- 0, 0, 0, 0x7A5A, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF56C, 0,
- 0, 0, 0xF56E, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E492_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xF577, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xF635, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF632, 0,
-};
-static const unsigned short utf8_to_euc_E493_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF634, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E494_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF659, 0, 0, 0, 0, 0xF654, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xF66D, 0, 0,
- 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 short utf8_to_euc_E495_x0213[] = {
- 0, 0, 0, 0xF66E, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E496_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x7B51, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xF74F, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E497_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xF76C, 0, 0,
- 0, 0, 0x7B60, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E498_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF824,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E499_x0213[] = {
- 0, 0xF83A, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xF843, 0, 0,
- 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 short utf8_to_euc_E49A_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xF84E, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF853,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E49C_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF86B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E49D_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF929, 0, 0, 0,
- 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 short utf8_to_euc_E49F_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xF93F, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4A0_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF949, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E4A1_x0213[] = {
- 0, 0, 0, 0, 0x7C4B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF95C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E4A2_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFA27, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4A6_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x7D58, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4A7_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFB6A,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB70, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4A8_x0213[] = {
- 0, 0, 0, 0, 0xFB75, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB78, 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 short utf8_to_euc_E4AA_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFC37, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4AC_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFC55, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4AF_x0213[] = {
- 0, 0, 0xFD26, 0, 0, 0, 0, 0,
- 0, 0, 0xFD28, 0, 0, 0, 0, 0,
- 0, 0, 0xFD2A, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFD31, 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 short utf8_to_euc_E4B0_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x7E3E,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFD3F, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E4B3_x0213[] = {
- 0, 0, 0, 0, 0xFE2A, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFE2D, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E4B4_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xFE4B,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E4B5_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFE60,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4B8[] = {
- 0x306C, 0x437A, 0xB021, 0x3C37, 0xB022, 0xB023, 0, 0x4B7C,
- 0x3E66, 0x3B30, 0x3E65, 0x323C, 0xB024, 0x4954, 0x4D3F, 0,
- 0x5022, 0x312F, 0xB025, 0, 0x336E, 0x5023, 0x4024, 0x5242,
- 0x3556, 0x4A3A, 0, 0, 0, 0, 0x3E67, 0xB026,
- 0, 0x4E3E, 0, 0xB027, 0xB028, 0, 0x4A42, 0,
- 0xB029, 0, 0x5024, 0xB02A, 0, 0x4366, 0xB02B, 0xB02C,
- 0xB02D, 0x5025, 0x367A, 0, 0, 0xB02E, 0x5026, 0,
- 0x345D, 0x4330, 0, 0x3C67, 0x5027, 0, 0, 0x5028,
-};
-static const unsigned short utf8_to_euc_E4B8_x0213[] = {
- 0x306C, 0x437A, 0xA122, 0x3C37, 0xB022, 0xB023, 0, 0x4B7C,
- 0x3E66, 0x3B30, 0x3E65, 0x323C, 0xB024, 0x4954, 0x4D3F, 0xA123,
- 0x5022, 0x312F, 0xA124, 0, 0x336E, 0x5023, 0x4024, 0x5242,
- 0x3556, 0x4A3A, 0, 0, 0, 0, 0x3E67, 0xB026,
- 0, 0x4E3E, 0, 0xB027, 0xB028, 0, 0x4A42, 0,
- 0x2E24, 0xA125, 0x5024, 0xA126, 0xF02E, 0x4366, 0xA127, 0x2E25,
- 0x2E26, 0x5025, 0x367A, 0, 0, 0xB02E, 0x5026, 0,
- 0x345D, 0x4330, 0, 0x3C67, 0x5027, 0, 0, 0x5028,
-};
-static const unsigned short utf8_to_euc_E4B9[] = {
- 0xB02F, 0xB030, 0x5029, 0x4735, 0xB031, 0x3557, 0, 0xB032,
- 0, 0, 0, 0x4737, 0, 0x4663, 0x3843, 0x4B33,
- 0, 0xB033, 0, 0, 0, 0x6949, 0x502A, 0x3E68,
- 0x502B, 0x3235, 0xB034, 0, 0xB035, 0x3665, 0x3870, 0x4C69,
- 0, 0, 0x5626, 0xB036, 0, 0, 0, 0,
- 0xB037, 0xB038, 0, 0, 0, 0, 0, 0,
- 0, 0x4D70, 0, 0x467D, 0xB039, 0xB03A, 0, 0,
- 0, 0xB03B, 0, 0, 0, 0, 0x3425, 0xB03C,
-};
-static const unsigned short utf8_to_euc_E4B9_x0213[] = {
- 0xA128, 0xB030, 0x5029, 0x4735, 0xB031, 0x3557, 0, 0xA129,
- 0xA12A, 0, 0, 0x4737, 0, 0x4663, 0x3843, 0x4B33,
- 0, 0xA12C, 0, 0, 0, 0x6949, 0x502A, 0x3E68,
- 0x502B, 0x3235, 0xA12F, 0, 0xB035, 0x3665, 0x3870, 0x4C69,
- 0, 0, 0x5626, 0xB036, 0, 0, 0, 0,
- 0xB037, 0xA130, 0, 0, 0, 0, 0, 0,
- 0, 0x4D70, 0, 0x467D, 0xB039, 0xB03A, 0, 0,
- 0, 0xB03B, 0, 0, 0, 0, 0x3425, 0xB03C,
-};
-static const unsigned short utf8_to_euc_E4BA[] = {
- 0x3535, 0, 0x502C, 0, 0, 0x502D, 0x4E3B, 0,
- 0x4D3D, 0x4168, 0x502F, 0x3B76, 0x4673, 0xB03D, 0x5032, 0,
- 0, 0x313E, 0x385F, 0, 0x385E, 0x3066, 0xB03E, 0xB03F,
- 0x4F4B, 0x4F4A, 0, 0x3A33, 0x3021, 0xB040, 0x5033, 0x5034,
- 0x5035, 0x4B34, 0x5036, 0, 0x3872, 0x3067, 0x4B72, 0,
- 0x357C, 0, 0, 0x357D, 0x357E, 0x4462, 0x4E3C, 0xB041,
- 0x5037, 0, 0, 0x5038, 0, 0, 0x5039, 0,
- 0, 0xB042, 0x3F4D, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4BA_x0213[] = {
- 0x3535, 0, 0x502C, 0, 0, 0x502D, 0x4E3B, 0,
- 0x4D3D, 0x4168, 0x502F, 0x3B76, 0x4673, 0x2E27, 0x5032, 0,
- 0, 0x313E, 0x385F, 0, 0x385E, 0x3066, 0xB03E, 0xB03F,
- 0x4F4B, 0x4F4A, 0, 0x3A33, 0x3021, 0xA131, 0x5033, 0x5034,
- 0x5035, 0x4B34, 0x5036, 0, 0x3872, 0x3067, 0x4B72, 0,
- 0x357C, 0, 0, 0x357D, 0x357E, 0x4462, 0x4E3C, 0xB041,
- 0x5037, 0, 0, 0x5038, 0, 0, 0x5039, 0,
- 0, 0xA134, 0x3F4D, 0xA135, 0xA137, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E4BB[] = {
- 0x3D3A, 0x3F4E, 0x503E, 0xB043, 0x503C, 0, 0x503D, 0x3558,
- 0, 0, 0x3A23, 0x3270, 0, 0x503B, 0x503A, 0x4A29,
- 0xB044, 0, 0, 0, 0x3B46, 0x3B45, 0x423E, 0x503F,
- 0x4955, 0x4067, 0xB045, 0xB046, 0, 0x2138, 0x5040, 0x5042,
- 0xB047, 0xB048, 0xB049, 0x4265, 0x4E61, 0x304A, 0, 0,
- 0xB04A, 0, 0, 0, 0, 0x5041, 0x323E, 0xB04B,
- 0x3644, 0xB04C, 0x4367, 0xB04D, 0, 0xB04E, 0x376F, 0x5043,
- 0, 0, 0, 0x4724, 0xF42F, 0xB04F, 0xB050, 0xB051,
-};
-static const unsigned short utf8_to_euc_E4BB_x0213[] = {
- 0x3D3A, 0x3F4E, 0x503E, 0xA138, 0x503C, 0, 0x503D, 0x3558,
- 0xA139, 0, 0x3A23, 0x3270, 0, 0x503B, 0x503A, 0x4A29,
- 0xA13A, 0, 0, 0, 0x3B46, 0x3B45, 0x423E, 0x503F,
- 0x4955, 0x4067, 0xA13C, 0xB046, 0, 0x2138, 0x5040, 0x5042,
- 0xB047, 0x2E28, 0xB049, 0x4265, 0x4E61, 0x304A, 0, 0,
- 0xB04A, 0, 0, 0xA13B, 0, 0x5041, 0x323E, 0xB04B,
- 0x3644, 0xA13D, 0x4367, 0xB04D, 0, 0xA13E, 0x376F, 0x5043,
- 0, 0, 0, 0x4724, 0, 0x2E29, 0xB050, 0x2E2A,
-};
-static const unsigned short utf8_to_euc_E4BC[] = {
- 0xB052, 0x346B, 0xB053, 0xB054, 0, 0, 0, 0,
- 0xB055, 0x5044, 0x304B, 0xB056, 0xB057, 0x3860, 0x346C, 0x497A,
- 0x4832, 0x3559, 0xB058, 0, 0, 0xB059, 0xB05A, 0xB05B,
- 0, 0xB05C, 0x3271, 0, 0x5067, 0x4541, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB05D, 0x476C,
- 0x5046, 0xB05E, 0, 0xB060, 0x483C, 0xB061, 0x4E62, 0xB062,
- 0x3F2D, 0xB063, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xB065, 0,
-};
-static const unsigned short utf8_to_euc_E4BC_x0213[] = {
- 0xA13F, 0x346B, 0xB053, 0x2E2B, 0, 0, 0, 0,
- 0xB055, 0x5044, 0x304B, 0x2E2C, 0xB057, 0x3860, 0x346C, 0x497A,
- 0x4832, 0x3559, 0xB058, 0, 0, 0xB059, 0xA140, 0xB05B,
- 0, 0xB05C, 0x3271, 0, 0x5067, 0x4541, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB05D, 0x476C,
- 0x5046, 0xB05E, 0, 0xB060, 0x483C, 0xB061, 0x4E62, 0xA142,
- 0x3F2D, 0, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xA143, 0,
-};
-static const unsigned short utf8_to_euc_E4BD[] = {
- 0xB066, 0, 0xB067, 0x4451, 0, 0, 0x4322, 0x504A,
- 0xB068, 0xB069, 0, 0xB06A, 0xB06B, 0x304C, 0x4463, 0x3D3B,
- 0x3A34, 0x4D24, 0xB06C, 0x424E, 0xB06D, 0x323F, 0xB06E, 0x5049,
- 0xB06F, 0x4D3E, 0x5045, 0x5047, 0x3A6E, 0x5048, 0x5524, 0xB070,
- 0xB05F, 0, 0, 0xB071, 0, 0, 0, 0,
- 0, 0x5050, 0xB072, 0, 0xB073, 0, 0xB074, 0x5053,
- 0x5051, 0xB075, 0, 0x3242, 0, 0x4A3B, 0x504B, 0xB076,
- 0xB077, 0xB078, 0xB079, 0x504F, 0x3873, 0xB07A, 0xB07B, 0x3B48,
-};
-static const unsigned short utf8_to_euc_E4BD_x0213[] = {
- 0xB066, 0, 0xB067, 0x4451, 0, 0, 0x4322, 0x504A,
- 0x2E2E, 0x2E2F, 0, 0xB06A, 0xB06B, 0x304C, 0x4463, 0x3D3B,
- 0x3A34, 0x4D24, 0xB06C, 0x424E, 0xA144, 0x323F, 0x2E30, 0x5049,
- 0xA145, 0x4D3E, 0x5045, 0x5047, 0x3A6E, 0x5048, 0x5524, 0x2E31,
- 0x2E2D, 0, 0, 0xB071, 0xA141, 0, 0, 0,
- 0, 0x5050, 0x2E32, 0, 0x2E33, 0, 0xB074, 0x5053,
- 0x5051, 0xB075, 0, 0x3242, 0, 0x4A3B, 0x504B, 0xA147,
- 0xA148, 0xB078, 0xA149, 0x504F, 0x3873, 0xA14A, 0x2E34, 0x3B48,
-};
-static const unsigned short utf8_to_euc_E4BE[] = {
- 0, 0xB07C, 0xB07D, 0x3426, 0xB07E, 0xB121, 0x5054, 0,
- 0x504C, 0xB122, 0xB123, 0x4E63, 0xB124, 0x3B78, 0xB125, 0x504D,
- 0xB126, 0x5052, 0xB127, 0xB128, 0xB129, 0, 0x5055, 0xB12A,
- 0x504E, 0xB12B, 0xB12C, 0x3621, 0, 0x304D, 0xB12D, 0xB12E,
- 0x3622, 0x3241, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x5525, 0, 0x4B79, 0x496E, 0x3874,
- 0, 0, 0xB12F, 0, 0, 0x3F2F, 0x4E37, 0xB130,
- 0, 0xB131, 0, 0xB132, 0xB133, 0xB134, 0xB135, 0x4A58,
-};
-static const unsigned short utf8_to_euc_E4BE_x0213[] = {
- 0, 0xB07C, 0xA14B, 0x3426, 0xB07E, 0xA14C, 0x5054, 0,
- 0x504C, 0xB122, 0x2E35, 0x4E63, 0xB124, 0x3B78, 0xB125, 0x504D,
- 0xB126, 0x5052, 0xA14D, 0xB128, 0x2E36, 0, 0x5055, 0x2E37,
- 0x504E, 0xB12B, 0xA14E, 0x3621, 0, 0x304D, 0xB12D, 0xB12E,
- 0x3622, 0x3241, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x5525, 0, 0x4B79, 0x496E, 0x3874,
- 0, 0, 0xA150, 0, 0, 0x3F2F, 0x4E37, 0xB130,
- 0, 0xB131, 0, 0xB132, 0xB133, 0xB134, 0xA151, 0x4A58,
-};
-static const unsigned short utf8_to_euc_E4BF[] = {
- 0xB136, 0xB137, 0x3738, 0x4225, 0x3264, 0xB138, 0xB139, 0,
- 0xB13A, 0xB13B, 0x3D53, 0xB13C, 0xB13D, 0xB13E, 0x5059, 0xB13F,
- 0x505E, 0x505C, 0xB140, 0, 0x5057, 0, 0, 0x422F,
- 0x505A, 0, 0x505D, 0x505B, 0xB141, 0x4A5D, 0, 0x5058,
- 0xB142, 0x3F2E, 0xB143, 0x4B73, 0x505F, 0x5060, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
- 0xB144, 0, 0xB145, 0x4750, 0, 0x4936, 0x5068, 0,
- 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0xB148,
-};
-static const unsigned short utf8_to_euc_E4BF_x0213[] = {
- 0xB136, 0xB137, 0x3738, 0x4225, 0x3264, 0xA152, 0xB139, 0,
- 0xB13A, 0x2E39, 0x3D53, 0xA153, 0xB13D, 0, 0x5059, 0xA154,
- 0x505E, 0x505C, 0xA155, 0, 0x5057, 0, 0, 0x422F,
- 0x505A, 0, 0x505D, 0x505B, 0xB141, 0x4A5D, 0, 0x5058,
- 0x2E3A, 0x3F2E, 0xB143, 0x4B73, 0x505F, 0x5060, 0xA14F, 0,
- 0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
- 0xB144, 0x2E21, 0xA157, 0x4750, 0, 0x4936, 0x5068, 0,
- 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0,
-};
-static const unsigned short utf8_to_euc_E580[] = {
- 0xB149, 0xB14A, 0, 0, 0xB14B, 0x5066, 0x506F, 0xB14C,
- 0, 0x4152, 0xB14D, 0x3844, 0xB14E, 0x475C, 0xB14F, 0x6047,
- 0xB150, 0x506E, 0x455D, 0xB151, 0x5063, 0, 0x3876, 0xB152,
- 0xB153, 0x3875, 0x5061, 0xB154, 0xB155, 0xB156, 0xB157, 0x3C5A,
- 0, 0x5069, 0xB158, 0x4A6F, 0x434D, 0x5065, 0x3771, 0xB159,
- 0x5062, 0x506A, 0x5064, 0x4E51, 0x506B, 0x4F41, 0xB15A, 0,
- 0xB15B, 0, 0xB15C, 0xB15D, 0, 0xB15E, 0x3666, 0,
- 0, 0x3770, 0, 0xB176, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E580_x0213[] = {
- 0xA158, 0x2E3B, 0x2E3C, 0, 0xB14B, 0x5066, 0x506F, 0xB14C,
- 0, 0x4152, 0xB14D, 0x3844, 0xB14E, 0x475C, 0x2E3D, 0x6047,
- 0xA159, 0x506E, 0x455D, 0xA15A, 0x5063, 0, 0x3876, 0xB152,
- 0x2E3E, 0x3875, 0x5061, 0xB154, 0xA15B, 0xB156, 0xA15C, 0x3C5A,
- 0, 0x5069, 0xA15D, 0x4A6F, 0x434D, 0x5065, 0x3771, 0x2E3F,
- 0x5062, 0x506A, 0x5064, 0x4E51, 0x506B, 0x4F41, 0x2E40, 0,
- 0xB15B, 0, 0xB15C, 0xB15D, 0, 0xB15E, 0x3666, 0,
- 0, 0x3770, 0, 0x2E42, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E581[] = {
- 0xB15F, 0xB160, 0xB161, 0x5070, 0, 0xB162, 0xB163, 0x5071,
- 0x5075, 0x304E, 0xB164, 0, 0xB165, 0, 0xB166, 0x4A50,
- 0x5074, 0xB167, 0xB168, 0xB169, 0, 0x5073, 0x5077, 0xB16A,
- 0, 0xB16B, 0x5076, 0, 0x4464, 0, 0, 0xB16C,
- 0xB16D, 0, 0xB16E, 0xB16F, 0, 0x3772, 0xB170, 0xB171,
- 0, 0, 0xB172, 0, 0x5078, 0xB173, 0, 0,
- 0xB174, 0xB175, 0x3C45, 0, 0x4226, 0x4465, 0x3676, 0,
- 0x5079, 0, 0, 0, 0, 0x3536, 0, 0,
-};
-static const unsigned short utf8_to_euc_E581_x0213[] = {
- 0x2E41, 0x2E43, 0xA15F, 0x5070, 0, 0xB162, 0xA160, 0x5071,
- 0x5075, 0x304E, 0xB164, 0, 0xB165, 0, 0xA161, 0x4A50,
- 0x5074, 0xB167, 0xB168, 0xA162, 0, 0x5073, 0x5077, 0xA163,
- 0, 0xB16B, 0x5076, 0, 0x4464, 0, 0, 0xB16C,
- 0xB16D, 0, 0xB16E, 0xA164, 0, 0x3772, 0xA165, 0xB171,
- 0, 0, 0xA166, 0, 0x5078, 0xB173, 0, 0,
- 0xA167, 0xB175, 0x3C45, 0, 0x4226, 0x4465, 0x3676, 0,
- 0x5079, 0, 0, 0, 0, 0x3536, 0, 0,
-};
-static const unsigned short utf8_to_euc_E582[] = {
- 0x507A, 0xB177, 0, 0xB178, 0xB179, 0x507C, 0xB17A, 0,
- 0, 0, 0xB17B, 0, 0, 0x4B35, 0xB17C, 0xB17D,
- 0xB17E, 0x3766, 0xB221, 0xB222, 0xB223, 0, 0xB224, 0,
- 0x3B31, 0x4877, 0x507B, 0xB225, 0xB226, 0, 0xB227, 0xB228,
- 0xB229, 0xB22A, 0xB22B, 0, 0, 0, 0, 0,
- 0, 0, 0xB22C, 0, 0x3A45, 0x4D43, 0, 0xB22D,
- 0xB22E, 0, 0x507E, 0x5123, 0x507D, 0x3A44, 0, 0x3D7D,
- 0, 0xB22F, 0xB230, 0, 0, 0xB231, 0x3739, 0,
-};
-static const unsigned short utf8_to_euc_E582_x0213[] = {
- 0x507A, 0xB177, 0, 0xB178, 0xB179, 0x507C, 0xB17A, 0,
- 0xA169, 0, 0xB17B, 0, 0, 0x4B35, 0xB17C, 0xB17D,
- 0xB17E, 0x3766, 0xA16A, 0xA16B, 0x2E44, 0xA16C, 0xA16D, 0,
- 0x3B31, 0x4877, 0x507B, 0xB225, 0xA16E, 0, 0xB227, 0xB228,
- 0xB229, 0xB22A, 0xB22B, 0xA168, 0, 0, 0, 0,
- 0, 0, 0xA16F, 0, 0x3A45, 0x4D43, 0, 0xB22D,
- 0xB22E, 0xA171, 0x507E, 0x5123, 0x507D, 0x3A44, 0, 0x3D7D,
- 0, 0xB22F, 0xA172, 0xA173, 0, 0xB231, 0x3739, 0,
-};
-static const unsigned short utf8_to_euc_E583[] = {
- 0xB232, 0, 0x5124, 0xB233, 0xB234, 0x364F, 0, 0xB235,
- 0, 0x5121, 0x5122, 0, 0xB236, 0x462F, 0xB237, 0x417C,
- 0xB238, 0x3623, 0, 0xB239, 0xB23A, 0x4B4D, 0x5125, 0,
- 0xB23B, 0, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
- 0, 0, 0xB23F, 0x5129, 0xB240, 0x5127, 0xB241, 0x414E,
- 0xB242, 0xB243, 0, 0, 0, 0x5128, 0x512A, 0xB244,
- 0, 0xB245, 0xB251, 0, 0xF430, 0x512C, 0xB246, 0,
- 0, 0x512B, 0xB247, 0x4A48, 0, 0, 0xB248, 0,
-};
-static const unsigned short utf8_to_euc_E583_x0213[] = {
- 0xB232, 0, 0x5124, 0xB233, 0xA174, 0x364F, 0, 0xA175,
- 0, 0x5121, 0x5122, 0, 0x2E45, 0x462F, 0xA178, 0x417C,
- 0x2E47, 0x3623, 0, 0xB239, 0xA17A, 0x4B4D, 0x5125, 0,
- 0, 0xA17B, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
- 0, 0xA17C, 0xB23F, 0x5129, 0xB240, 0x5127, 0x2E48, 0x414E,
- 0xB242, 0xA17D, 0, 0, 0, 0x5128, 0x512A, 0xB244,
- 0, 0xB245, 0x2E46, 0xA176, 0, 0x512C, 0xB246, 0,
- 0, 0x512B, 0xB247, 0x4A48, 0, 0, 0xB248, 0,
-};
-static const unsigned short utf8_to_euc_E584[] = {
- 0x3537, 0x512E, 0x512F, 0xB249, 0x322F, 0, 0xB24A, 0xB24B,
- 0xB24C, 0x512D, 0, 0xB24D, 0xB24E, 0xB24F, 0xB250, 0,
- 0xB252, 0, 0x3C74, 0, 0x5132, 0x5131, 0x5130, 0xB253,
- 0x5056, 0xB254, 0x5133, 0xB255, 0xB256, 0xB257, 0xB258, 0x3D7E,
- 0, 0x5134, 0, 0xB259, 0, 0, 0, 0xB25A,
- 0xB25B, 0, 0x4D25, 0, 0xB25C, 0xB25D, 0, 0xB25E,
- 0, 0xB25F, 0x4C59, 0xB260, 0xB261, 0xB262, 0, 0x5136,
- 0xB263, 0xB264, 0x5135, 0x5138, 0x5137, 0, 0, 0x5139,
-};
-static const unsigned short utf8_to_euc_E584_x0213[] = {
- 0x3537, 0x512E, 0x512F, 0x2E4B, 0x322F, 0, 0x2E4A, 0xB24B,
- 0xA321, 0x512D, 0, 0x2E4C, 0xB24E, 0xB24F, 0xB250, 0,
- 0xB252, 0, 0x3C74, 0, 0x5132, 0x5131, 0x5130, 0xA323,
- 0x5056, 0xB254, 0x5133, 0xA324, 0xB256, 0xB257, 0x2E4D, 0x3D7E,
- 0, 0x5134, 0, 0xB259, 0, 0, 0, 0xB25A,
- 0xB25B, 0, 0x4D25, 0, 0xB25C, 0xB25D, 0, 0xB25E,
- 0, 0xB25F, 0x4C59, 0xB260, 0xB261, 0x2E4E, 0, 0x5136,
- 0xB263, 0xB264, 0x5135, 0x5138, 0x5137, 0, 0, 0x5139,
-};
-static const unsigned short utf8_to_euc_E585[] = {
- 0x513A, 0x3074, 0xB265, 0x3835, 0x373B, 0x3D3C, 0x437B, 0x3624,
- 0x4068, 0x3877, 0xB266, 0x396E, 0x513C, 0x4C48, 0x4546, 0xB267,
- 0x3B79, 0, 0x513B, 0xB268, 0x513D, 0xB269, 0, 0xB26A,
- 0xB26B, 0, 0x455E, 0, 0x3375, 0, 0, 0xB26C,
- 0, 0, 0x513E, 0, 0xB26D, 0x467E, 0xB26E, 0,
- 0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
- 0, 0x3626, 0, 0, 0, 0x4A3C, 0x4236, 0x3671,
- 0x4535, 0, 0, 0, 0x3773, 0, 0xB26F, 0,
-};
-static const unsigned short utf8_to_euc_E585_x0213[] = {
- 0x513A, 0x3074, 0xB265, 0x3835, 0x373B, 0x3D3C, 0x437B, 0x3624,
- 0x4068, 0x3877, 0x2E4F, 0x396E, 0x513C, 0x4C48, 0x4546, 0xB267,
- 0x3B79, 0, 0x513B, 0xB268, 0x513D, 0x2E51, 0, 0x2E52,
- 0xB26B, 0, 0x455E, 0, 0x3375, 0, 0, 0xB26C,
- 0xA326, 0, 0x513E, 0, 0, 0x467E, 0xB26E, 0,
- 0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
- 0, 0x3626, 0, 0xA328, 0, 0x4A3C, 0x4236, 0x3671,
- 0x4535, 0, 0, 0xF474, 0x3773, 0, 0xB26F, 0,
-};
-static const unsigned short utf8_to_euc_E586[] = {
- 0x5143, 0, 0x5144, 0xB270, 0xB271, 0x4662, 0x315F, 0,
- 0, 0x5147, 0x3A7D, 0xB272, 0x5146, 0x3A46, 0xB273, 0x5148,
- 0x666E, 0x5149, 0x4B41, 0x514A, 0, 0x514B, 0x514C, 0x3E69,
- 0xB274, 0x3C4C, 0, 0, 0, 0xB275, 0, 0,
- 0x3427, 0xB276, 0x514F, 0xB277, 0x514D, 0x4C3D, 0x514E, 0,
- 0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0xB278, 0, 0,
- 0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
- 0xB279, 0, 0xB27A, 0, 0xB27B, 0x5158, 0xB27C, 0xB27D,
-};
-static const unsigned short utf8_to_euc_E586_x0213[] = {
- 0x5143, 0, 0x5144, 0xA329, 0xB271, 0x4662, 0x315F, 0,
- 0, 0x5147, 0x3A7D, 0xA32A, 0x5146, 0x3A46, 0xB273, 0x5148,
- 0x666E, 0x5149, 0x4B41, 0x514A, 0, 0x514B, 0x514C, 0x3E69,
- 0xA32C, 0x3C4C, 0, 0, 0, 0x2E54, 0, 0,
- 0x3427, 0xB276, 0x514F, 0xA32D, 0x514D, 0x4C3D, 0x514E, 0,
- 0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0xA32E, 0, 0,
- 0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
- 0xB279, 0, 0xB27A, 0, 0xA330, 0x5158, 0, 0xB27D,
-};
-static const unsigned short utf8_to_euc_E587[] = {
- 0, 0, 0xB27E, 0, 0x4028, 0x5159, 0x3D5A, 0,
- 0xB321, 0x515A, 0, 0x437C, 0x4E3F, 0x4560, 0, 0xB322,
- 0, 0xB323, 0xB324, 0xB325, 0, 0xB326, 0x5245, 0,
- 0xB327, 0, 0, 0x515B, 0x7425, 0x3645, 0xB328, 0,
- 0x515C, 0x4B5E, 0xB329, 0, 0, 0xB32A, 0x3D68, 0x427C,
- 0, 0x515E, 0x4664, 0, 0xF431, 0x515F, 0xB32B, 0,
- 0x5160, 0x332E, 0xB32C, 0xB32D, 0xB32E, 0x5161, 0x3627, 0xB32F,
- 0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
-};
-static const unsigned short utf8_to_euc_E587_x0213[] = {
- 0, 0, 0xB27E, 0x2E55, 0x4028, 0x5159, 0x3D5A, 0,
- 0xB321, 0x515A, 0x2E56, 0x437C, 0x4E3F, 0x4560, 0, 0xB322,
- 0, 0xB323, 0xB324, 0xB325, 0, 0xB326, 0x5245, 0,
- 0xB327, 0, 0, 0x515B, 0x7425, 0x3645, 0x2E57, 0,
- 0x515C, 0x4B5E, 0x2E58, 0, 0, 0xB32A, 0x3D68, 0x427C,
- 0, 0x515E, 0x4664, 0, 0, 0x515F, 0x2E59, 0,
- 0x5160, 0x332E, 0xB32C, 0xA333, 0xA334, 0x5161, 0x3627, 0xB32F,
- 0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
-};
-static const unsigned short utf8_to_euc_E588[] = {
- 0x4561, 0xB330, 0xB331, 0x3F4F, 0x5163, 0xB332, 0x4A2C, 0x405A,
- 0x3422, 0, 0x3429, 0x5164, 0, 0, 0x5166, 0,
- 0, 0x373A, 0xB333, 0xB334, 0x5165, 0xB335, 0xB336, 0x4E73,
- 0xB337, 0, 0, 0, 0, 0x3D69, 0, 0,
- 0, 0, 0xB338, 0, 0x483D, 0x4A4C, 0, 0x5167,
- 0xB339, 0x4D78, 0x5168, 0, 0, 0, 0x5169, 0,
- 0x457E, 0xB33A, 0xB33B, 0x516A, 0, 0xB33C, 0x4029, 0x3A7E,
- 0x3774, 0x516B, 0x3B49, 0x396F, 0xB33D, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E588_x0213[] = {
- 0x4561, 0x2E5A, 0xA335, 0x3F4F, 0x5163, 0xB332, 0x4A2C, 0x405A,
- 0x3422, 0, 0x3429, 0x5164, 0, 0, 0x5166, 0,
- 0, 0x373A, 0xA336, 0x2E5C, 0x5165, 0x2E5D, 0xA337, 0x4E73,
- 0xB337, 0, 0, 0, 0, 0x3D69, 0, 0,
- 0, 0, 0xB338, 0, 0x483D, 0x4A4C, 0, 0x5167,
- 0xB339, 0x4D78, 0x5168, 0, 0, 0, 0x5169, 0,
- 0x457E, 0xB33A, 0xB33B, 0x516A, 0, 0xB33C, 0x4029, 0x3A7E,
- 0x3774, 0x516B, 0x3B49, 0x396F, 0xB33D, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E589[] = {
- 0, 0, 0, 0x4466, 0x516D, 0xB33E, 0, 0x4227,
- 0, 0xB33F, 0x3A6F, 0x516E, 0x516F, 0x4130, 0, 0x516C,
- 0, 0, 0, 0, 0x5171, 0xB340, 0x4B36, 0xB341,
- 0xB342, 0, 0xB343, 0x3964, 0xB344, 0, 0x5170, 0xB345,
- 0xB346, 0xB347, 0, 0x3775, 0x3A5E, 0x476D, 0xB348, 0,
- 0, 0x5174, 0x5172, 0, 0, 0, 0xB349, 0x497B,
- 0x3E6A, 0x517B, 0x3364, 0x5175, 0x5173, 0x414F, 0, 0xB34A,
- 0xB34B, 0xB34C, 0, 0, 0, 0x5177, 0, 0x5176,
-};
-static const unsigned short utf8_to_euc_E589_x0213[] = {
- 0, 0, 0, 0x4466, 0x516D, 0xB33E, 0, 0x4227,
- 0, 0x2E5E, 0x3A6F, 0x516E, 0x516F, 0x4130, 0, 0x516C,
- 0, 0, 0, 0, 0x5171, 0xA339, 0x4B36, 0x2E5F,
- 0xB342, 0, 0xB343, 0x3964, 0xA33A, 0x2F7E, 0x5170, 0xB345,
- 0xB346, 0x2E60, 0, 0x3775, 0x3A5E, 0x476D, 0xB348, 0,
- 0, 0x5174, 0x5172, 0, 0xA33B, 0, 0xB349, 0x497B,
- 0x3E6A, 0x517B, 0x3364, 0x5175, 0x5173, 0x414F, 0, 0xA33C,
- 0xB34B, 0xB34C, 0, 0, 0, 0x5177, 0, 0x5176,
-};
-static const unsigned short utf8_to_euc_E58A[] = {
- 0xB34D, 0, 0xB34E, 0x3344, 0, 0xB34F, 0, 0x3760,
- 0x517C, 0x4E2D, 0xB350, 0, 0xB351, 0x5178, 0, 0,
- 0, 0x517D, 0x517A, 0xB352, 0x5179, 0xB353, 0xB354, 0xB355,
- 0xB356, 0, 0xB357, 0x4E4F, 0xB358, 0, 0, 0x3879,
- 0x3243, 0, 0, 0x4E74, 0xB359, 0xB35A, 0xB35B, 0xB35C,
- 0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0xB35D,
- 0xB35E, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0xB35F, 0xB360,
- 0xB361, 0x387A, 0xB362, 0xB363, 0x5224, 0xB364, 0x332F, 0,
-};
-static const unsigned short utf8_to_euc_E58A_x0213[] = {
- 0xB34D, 0, 0xA33E, 0x3344, 0xA33D, 0xB34F, 0, 0x3760,
- 0x517C, 0x4E2D, 0xB350, 0, 0xB351, 0x5178, 0, 0,
- 0, 0x517D, 0x517A, 0x2E61, 0x5179, 0xB353, 0xB354, 0xB355,
- 0xA340, 0, 0xB357, 0x4E4F, 0, 0, 0, 0x3879,
- 0x3243, 0, 0, 0x4E74, 0xA342, 0xB35A, 0xA343, 0xB35C,
- 0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0xA344,
- 0xB35E, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0xB35F, 0xB360,
- 0xB361, 0x387A, 0xA345, 0xA346, 0x5224, 0xB364, 0x332F, 0,
-};
-static const unsigned short utf8_to_euc_E58B[] = {
- 0xB365, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
- 0xB368, 0x4A59, 0, 0, 0xB369, 0x5227, 0, 0xB36A,
- 0, 0xB36B, 0x7055, 0, 0xB36C, 0x4630, 0xB36D, 0x5228,
- 0x342A, 0x4C33, 0, 0xB36E, 0xB36F, 0x3E21, 0x5229, 0x4A67,
- 0x522D, 0xB370, 0x402A, 0x522A, 0x3650, 0xB371, 0x522B, 0x342B,
- 0xB372, 0xB373, 0xB374, 0, 0xB375, 0, 0, 0,
- 0xB376, 0xB377, 0x372E, 0x522E, 0xB378, 0x522F, 0xB379, 0xB37A,
- 0x5230, 0x5231, 0x3C5B, 0, 0, 0, 0x387B, 0x4C5E,
-};
-static const unsigned short utf8_to_euc_E58B_x0213[] = {
- 0, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
- 0x2E62, 0x4A59, 0xA347, 0, 0x2E64, 0x5227, 0, 0xB36A,
- 0x2E65, 0xA349, 0x7055, 0, 0xB36C, 0x4630, 0x2E66, 0x5228,
- 0x342A, 0x4C33, 0, 0x2E67, 0xB36F, 0x3E21, 0x5229, 0x4A67,
- 0x522D, 0xB370, 0x402A, 0x522A, 0x3650, 0xB371, 0x522B, 0x342B,
- 0xB372, 0xB373, 0xB374, 0, 0xB375, 0, 0, 0,
- 0x2E69, 0xB377, 0x372E, 0x522E, 0xB378, 0x522F, 0xB379, 0xA34B,
- 0x5230, 0x5231, 0x3C5B, 0x2E6A, 0, 0, 0x387B, 0x4C5E,
-};
-static const unsigned short utf8_to_euc_E58C[] = {
- 0xB37B, 0x4C68, 0x4677, 0xB37C, 0, 0x4A71, 0x5232, 0xF432,
- 0x5233, 0, 0xB37D, 0xB37E, 0xB421, 0x5235, 0, 0x5237,
- 0x5236, 0xB422, 0, 0xB423, 0, 0x5238, 0x323D, 0x4B4C,
- 0xB424, 0x3A7C, 0x5239, 0xB425, 0xB426, 0x4159, 0xB427, 0xB428,
- 0x3E22, 0x3629, 0, 0x523A, 0xF433, 0xB429, 0, 0xB42A,
- 0xB42B, 0xB42C, 0x485B, 0xB42D, 0xB42E, 0xB42F, 0, 0x523B,
- 0xB430, 0x523C, 0xB431, 0x523D, 0, 0xB432, 0, 0,
- 0x523E, 0x4924, 0x3668, 0x3065, 0xB433, 0xB434, 0xB435, 0x463F,
-};
-static const unsigned short utf8_to_euc_E58C_x0213[] = {
- 0x2E6B, 0x4C68, 0x4677, 0xB37C, 0, 0x4A71, 0x5232, 0x2E6C,
- 0x5233, 0, 0xA34C, 0xA34D, 0xB421, 0x5235, 0, 0x5237,
- 0x5236, 0xB422, 0, 0xB423, 0, 0x5238, 0x323D, 0x4B4C,
- 0xB424, 0x3A7C, 0x5239, 0xB425, 0x2E6D, 0x4159, 0xB427, 0xB428,
- 0x3E22, 0x3629, 0, 0x523A, 0xA34E, 0xB429, 0, 0xB42A,
- 0xB42B, 0xB42C, 0x485B, 0xB42D, 0xB42E, 0xB42F, 0, 0x523B,
- 0xB430, 0x523C, 0xB431, 0x523D, 0, 0xA34F, 0, 0,
- 0x523E, 0x4924, 0x3668, 0x3065, 0xB433, 0xB434, 0xA350, 0x463F,
-};
-static const unsigned short utf8_to_euc_E58D[] = {
- 0x523F, 0x3D3D, 0xB436, 0x4069, 0, 0x5241, 0x5240, 0x3E23,
- 0x3861, 0x5243, 0x483E, 0xB438, 0xB437, 0x5244, 0, 0,
- 0, 0x485C, 0x4234, 0x426E, 0x3628, 0, 0, 0x466E,
- 0x4331, 0xB439, 0x476E, 0xB43A, 0x4B4E, 0, 0x5246, 0,
- 0x406A, 0xB43B, 0, 0xB43C, 0, 0xB43D, 0x3735, 0,
- 0, 0x5247, 0, 0, 0xB43E, 0xB43F, 0x5248, 0x312C,
- 0x3075, 0x346D, 0xB440, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
- 0x3237, 0xB441, 0, 0x524A, 0, 0, 0xB442, 0x362A,
-};
-static const unsigned short utf8_to_euc_E58D_x0213[] = {
- 0x523F, 0x3D3D, 0xA351, 0x4069, 0, 0x5241, 0x5240, 0x3E23,
- 0x3861, 0x5243, 0x483E, 0xB438, 0xB437, 0x5244, 0, 0,
- 0, 0x485C, 0x4234, 0x426E, 0x3628, 0, 0, 0x466E,
- 0x4331, 0xB439, 0x476E, 0xB43A, 0x4B4E, 0, 0x5246, 0,
- 0x406A, 0x2E6F, 0, 0x2E70, 0, 0xB43D, 0x3735, 0xA354,
- 0, 0x5247, 0, 0, 0xA355, 0xB43F, 0x5248, 0x312C,
- 0x3075, 0x346D, 0, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
- 0x3237, 0xB441, 0xA356, 0x524A, 0, 0x2E71, 0xB442, 0x362A,
-};
-static const unsigned short utf8_to_euc_E58E[] = {
- 0, 0, 0x524C, 0xB443, 0x4C71, 0, 0, 0xB444,
- 0xB445, 0, 0, 0, 0, 0, 0xB446, 0,
- 0, 0, 0, 0xB447, 0xB448, 0, 0x524D, 0,
- 0x4E52, 0xB449, 0x387C, 0, 0, 0xB44A, 0, 0x3836,
- 0x524E, 0xB44B, 0, 0, 0xB44C, 0x5250, 0x524F, 0,
- 0x3F5F, 0x3139, 0xB44D, 0xB44E, 0, 0x315E, 0x5251, 0xB44F,
- 0x5252, 0, 0xB450, 0x3837, 0xB451, 0xB452, 0x5253, 0xB453,
- 0xB454, 0, 0xB455, 0x356E, 0, 0xB456, 0, 0,
-};
-static const unsigned short utf8_to_euc_E58E_x0213[] = {
- 0, 0, 0x524C, 0xB443, 0x4C71, 0, 0, 0xB444,
- 0xB445, 0, 0, 0, 0, 0, 0xB446, 0,
- 0, 0, 0, 0x2E72, 0xB448, 0, 0x524D, 0,
- 0x4E52, 0xB449, 0x387C, 0, 0, 0x2E73, 0, 0x3836,
- 0x524E, 0xB44B, 0, 0, 0xA357, 0x5250, 0x524F, 0,
- 0x3F5F, 0x3139, 0xB44D, 0xB44E, 0, 0x315E, 0x5251, 0xB44F,
- 0x5252, 0, 0x2E74, 0x3837, 0xA358, 0xB452, 0x5253, 0xA35A,
- 0xB454, 0, 0xB455, 0x356E, 0, 0xB456, 0, 0,
-};
-static const unsigned short utf8_to_euc_E58F[] = {
- 0xB457, 0, 0x3B32, 0x5254, 0, 0xB458, 0, 0,
- 0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0xB459,
- 0, 0, 0xB45A, 0xB45B, 0x3D47, 0xB45C, 0x3C68, 0x3C75,
- 0, 0x3D76, 0xB45D, 0x4840, 0, 0xB45E, 0xB45F, 0x5257,
- 0xB460, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0xB461, 0xB462,
- 0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
- 0x4266, 0x3C38, 0x3B4B, 0x3126, 0, 0xB463, 0x3370, 0x3966,
- 0x3B4A, 0, 0x525D, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E58F_x0213[] = {
- 0xA35B, 0, 0x3B32, 0x5254, 0, 0xB458, 0, 0,
- 0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0xB459,
- 0, 0, 0xB45A, 0xB45B, 0x3D47, 0xA35F, 0x3C68, 0x3C75,
- 0, 0x3D76, 0xA360, 0x4840, 0, 0, 0xB45F, 0x5257,
- 0xB460, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0xB461, 0xB462,
- 0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
- 0x4266, 0x3C38, 0x3B4B, 0x3126, 0xA362, 0xA363, 0x3370, 0x3966,
- 0x3B4A, 0, 0x525D, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E590[] = {
- 0, 0x525E, 0xB464, 0x3549, 0x3346, 0, 0, 0,
- 0x3967, 0x3548, 0x445F, 0x3125, 0x4631, 0x4C3E, 0x3921, 0x4D79,
- 0x4547, 0x387E, 0, 0xB465, 0, 0, 0, 0,
- 0, 0, 0xB466, 0x372F, 0, 0x5267, 0, 0x3663,
- 0x4B4A, 0xB467, 0, 0, 0, 0, 0x485D, 0xB468,
- 0xB469, 0x5266, 0xB46A, 0x345E, 0x5261, 0x5262, 0x5264, 0xB46B,
- 0, 0xB46C, 0, 0, 0xB46D, 0xB46E, 0x5265, 0,
- 0x355B, 0x3F61, 0, 0x4A2D, 0x5263, 0x525F, 0x3863, 0,
-};
-static const unsigned short utf8_to_euc_E590_x0213[] = {
- 0, 0x525E, 0xB464, 0x3549, 0x3346, 0, 0, 0,
- 0x3967, 0x3548, 0x445F, 0x3125, 0x4631, 0x4C3E, 0x3921, 0x4D79,
- 0x4547, 0x387E, 0x2E75, 0xB465, 0, 0, 0, 0,
- 0, 0, 0xB466, 0x372F, 0, 0x5267, 0x4F7E, 0x3663,
- 0x4B4A, 0xB467, 0, 0, 0xA365, 0, 0x485D, 0x2E76,
- 0xA366, 0x5266, 0xB46A, 0x345E, 0x5261, 0x5262, 0x5264, 0xB46B,
- 0, 0xB46C, 0, 0, 0xB46D, 0xB46E, 0x5265, 0,
- 0x355B, 0x3F61, 0, 0x4A2D, 0x5263, 0x525F, 0x3863, 0,
-};
-static const unsigned short utf8_to_euc_E591[] = {
- 0x5260, 0, 0x4F24, 0xB46F, 0xB470, 0, 0x4A72, 0xB471,
- 0x4468, 0x3862, 0x3970, 0, 0, 0xB472, 0x5268, 0xB473,
- 0, 0x465D, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB474, 0x526C,
- 0, 0, 0xB475, 0, 0xB476, 0, 0xB477, 0xB478,
- 0x3C7E, 0xB479, 0x3C76, 0xB47A, 0, 0xB47B, 0xB47C, 0,
- 0x526F, 0x526D, 0, 0x4C23, 0xB47D, 0x526A, 0x5273, 0x526E,
- 0, 0, 0, 0x5271, 0x3846, 0x4C3F, 0, 0xB47E,
-};
-static const unsigned short utf8_to_euc_E591_x0213[] = {
- 0x5260, 0, 0x4F24, 0xA368, 0xB470, 0, 0x4A72, 0xB471,
- 0x4468, 0x3862, 0x3970, 0, 0, 0x2E77, 0x5268, 0xB473,
- 0, 0x465D, 0, 0, 0, 0xA364, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB474, 0x526C,
- 0, 0, 0xA369, 0, 0xB476, 0, 0xA36A, 0xB478,
- 0x3C7E, 0xB479, 0x3C76, 0x2E79, 0xA36B, 0xB47B, 0xB47C, 0,
- 0x526F, 0x526D, 0, 0x4C23, 0x2E7A, 0x526A, 0x5273, 0x526E,
- 0, 0, 0, 0x5271, 0x3846, 0x4C3F, 0, 0x2E7B,
-};
-static const unsigned short utf8_to_euc_E592[] = {
- 0x5272, 0xB521, 0, 0xB522, 0x5274, 0xB523, 0x5276, 0,
- 0xB524, 0xB525, 0xF435, 0x3A70, 0x4F42, 0xB526, 0x526B, 0x5269,
- 0x5275, 0xB527, 0x5270, 0, 0, 0xB528, 0xB529, 0,
- 0, 0, 0, 0, 0xB52A, 0, 0, 0xB52B,
- 0, 0xB52C, 0x5278, 0, 0x5323, 0x527A, 0xB52D, 0xB52E,
- 0x527E, 0xB52F, 0xB530, 0x5321, 0x527B, 0xB531, 0xB532, 0x533E,
- 0, 0xB533, 0x3A69, 0x3331, 0, 0, 0, 0xB534,
- 0x5279, 0xB535, 0xB536, 0xB537, 0x5325, 0x3076, 0x5324, 0xB538,
-};
-static const unsigned short utf8_to_euc_E592_x0213[] = {
- 0x5272, 0xB521, 0, 0xB522, 0x5274, 0xB523, 0x5276, 0,
- 0x2E7C, 0xB525, 0xA36C, 0x3A70, 0x4F42, 0xA36D, 0x526B, 0x5269,
- 0x5275, 0xB527, 0x5270, 0, 0, 0xA36E, 0x2E7D, 0,
- 0, 0, 0, 0, 0x2E78, 0, 0, 0xB52B,
- 0xA36F, 0x2E7E, 0x5278, 0, 0x5323, 0x527A, 0xA370, 0xB52E,
- 0x527E, 0x2F21, 0xB530, 0x5321, 0x527B, 0xA371, 0xA372, 0x533E,
- 0, 0xB533, 0x3A69, 0x3331, 0, 0, 0, 0xA373,
- 0x5279, 0xB535, 0xA374, 0xB537, 0x5325, 0x3076, 0x5324, 0xA375,
-};
-static const unsigned short utf8_to_euc_E593[] = {
- 0x3025, 0x494A, 0x5322, 0, 0x527C, 0, 0xB539, 0x5277,
- 0x527D, 0x3A48, 0xB53A, 0, 0, 0xB53B, 0xB53C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x5326, 0, 0, 0, 0, 0, 0, 0,
- 0xB53D, 0x3077, 0x532F, 0, 0, 0x5327, 0x5328, 0,
- 0x3E25, 0x4B69, 0xB53E, 0, 0xB53F, 0x532D, 0x532C, 0xB540,
- 0, 0, 0x452F, 0, 0, 0, 0xB541, 0,
- 0, 0, 0x532E, 0, 0xB542, 0x532B, 0xB543, 0xB544,
-};
-static const unsigned short utf8_to_euc_E593_x0213[] = {
- 0x3025, 0x494A, 0x5322, 0xA376, 0x527C, 0, 0x2F22, 0x5277,
- 0x527D, 0x3A48, 0xB53A, 0, 0, 0xB53B, 0xB53C, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x5326, 0, 0, 0, 0, 0, 0, 0,
- 0xB53D, 0x3077, 0x532F, 0, 0, 0x5327, 0x5328, 0,
- 0x3E25, 0x4B69, 0xB53E, 0, 0xA378, 0x532D, 0x532C, 0xA379,
- 0, 0xA37A, 0x452F, 0xA37B, 0, 0, 0xB541, 0,
- 0, 0, 0x532E, 0, 0xB542, 0x532B, 0xB543, 0x2F23,
-};
-static const unsigned short utf8_to_euc_E594[] = {
- 0xB545, 0xB546, 0, 0, 0x3134, 0xB547, 0x3A36, 0x3F30,
- 0xB548, 0xB549, 0, 0, 0xB54A, 0xB54B, 0xB54C, 0x5329,
- 0x4562, 0, 0, 0, 0x532A, 0xB54D, 0x3022, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xB54E, 0xB54F, 0, 0, 0x5334, 0x4D23,
- 0, 0x3E27, 0xB550, 0x533A, 0, 0xB551, 0xB552, 0,
- 0x5339, 0x5330, 0, 0xB553, 0xB554, 0xB555, 0x4243, 0,
-};
-static const unsigned short utf8_to_euc_E594_x0213[] = {
- 0xA37C, 0xA37D, 0, 0, 0x3134, 0xB547, 0x3A36, 0x3F30,
- 0xB548, 0xA37E, 0, 0, 0xB54A, 0xB54B, 0x2F24, 0x5329,
- 0x4562, 0, 0, 0, 0x532A, 0xB54D, 0x3022, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xB54E, 0x2F25, 0, 0, 0x5334, 0x4D23,
- 0, 0x3E27, 0xB550, 0x533A, 0, 0x2F26, 0xB552, 0,
- 0x5339, 0x5330, 0, 0xB553, 0xA421, 0xB555, 0x4243, 0,
-};
-static const unsigned short utf8_to_euc_E595[] = {
- 0x5331, 0xB556, 0, 0, 0x426F, 0x5336, 0x3E26, 0xB557,
- 0, 0xB558, 0xB559, 0, 0x5333, 0xB55A, 0, 0x4C64,
- 0xB55B, 0xB55C, 0, 0x373C, 0, 0, 0x5337, 0x5338,
- 0xB55D, 0, 0xB55E, 0xB55F, 0x5335, 0x533B, 0xB560, 0,
- 0xB561, 0xB562, 0, 0x5332, 0xB563, 0, 0xB564, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x5341, 0x5346, 0, 0x5342, 0xB565,
-};
-static const unsigned short utf8_to_euc_E595_x0213[] = {
- 0x5331, 0xA422, 0, 0, 0x426F, 0x5336, 0x3E26, 0xA424,
- 0, 0xB558, 0xA425, 0, 0x5333, 0xB55A, 0, 0x4C64,
- 0x2F27, 0xB55C, 0, 0x373C, 0, 0, 0x5337, 0x5338,
- 0xB55D, 0, 0xB55E, 0xB55F, 0x5335, 0x533B, 0x2F28, 0,
- 0xA427, 0xA428, 0, 0x5332, 0xA429, 0, 0xB564, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x5341, 0x5346, 0xA42B, 0x5342, 0xB565,
-};
-static const unsigned short utf8_to_euc_E596[] = {
- 0x533D, 0xB566, 0xB567, 0x5347, 0x4131, 0, 0xB568, 0x5349,
- 0xB569, 0x3922, 0x533F, 0x437D, 0, 0, 0xB56A, 0xB56B,
- 0, 0xB56C, 0xB56D, 0xB56E, 0xB56F, 0, 0, 0xB570,
- 0x5343, 0x533C, 0x342D, 0, 0x346E, 0x3365, 0x5344, 0x5340,
- 0, 0, 0, 0xB571, 0xB572, 0, 0, 0x3776,
- 0x534A, 0x5348, 0x4153, 0x354A, 0x362C, 0xB573, 0x5345, 0,
- 0x3674, 0, 0xB574, 0, 0, 0, 0x3144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xB575,
-};
-static const unsigned short utf8_to_euc_E596_x0213[] = {
- 0x533D, 0x2F29, 0xA42C, 0x5347, 0x4131, 0, 0x2F2A, 0x5349,
- 0xA42D, 0x3922, 0x533F, 0x437D, 0, 0, 0x2F2B, 0xB56B,
- 0, 0xA42E, 0xB56D, 0xB56E, 0xB56F, 0, 0, 0xB570,
- 0x5343, 0x533C, 0x342D, 0, 0x346E, 0x3365, 0x5344, 0x5340,
- 0, 0, 0, 0xB571, 0xB572, 0, 0, 0x3776,
- 0x534A, 0x5348, 0x4153, 0x354A, 0x362C, 0x2F2D, 0x5345, 0,
- 0x3674, 0, 0xB574, 0, 0, 0, 0x3144, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xA433,
-};
-static const unsigned short utf8_to_euc_E597[] = {
- 0, 0xB576, 0, 0xB577, 0x534E, 0x534C, 0xB578, 0x5427,
- 0, 0xB579, 0, 0xB57A, 0xB57B, 0, 0xB57C, 0,
- 0, 0xB57D, 0xB57E, 0xB621, 0x5351, 0, 0, 0xB622,
- 0xB623, 0, 0x534B, 0xB624, 0x534F, 0, 0xB625, 0x534D,
- 0, 0, 0xB626, 0x3B4C, 0x5350, 0, 0, 0,
- 0, 0xB627, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB628, 0x5353,
- 0, 0x5358, 0, 0, 0, 0x5356, 0x5355, 0xB629,
-};
-static const unsigned short utf8_to_euc_E597_x0213[] = {
- 0, 0xB576, 0, 0xB577, 0x534E, 0x534C, 0xB578, 0x5427,
- 0, 0xA434, 0, 0xB57A, 0xA435, 0, 0x2F2E, 0,
- 0, 0xA436, 0xA430, 0xB621, 0x5351, 0, 0, 0xB622,
- 0xB623, 0, 0x534B, 0xB624, 0x534F, 0xA437, 0xB625, 0x534D,
- 0, 0, 0xA439, 0x3B4C, 0x5350, 0, 0, 0,
- 0, 0xA43B, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xB628, 0x5353,
- 0, 0x5358, 0, 0, 0, 0x5356, 0x5355, 0xB629,
-};
-static const unsigned short utf8_to_euc_E598[] = {
- 0, 0, 0, 0, 0, 0xB62A, 0x4332, 0,
- 0xB62B, 0x3245, 0xB62C, 0, 0, 0xB62D, 0xB62E, 0xB62F,
- 0xB630, 0xB631, 0xB632, 0, 0x5352, 0, 0x5354, 0x3E28,
- 0x3133, 0xB633, 0, 0x5357, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x325E, 0, 0, 0xB634, 0, 0, 0x5362,
- 0xB635, 0x3E7C, 0x535E, 0xB636, 0x535C, 0xB637, 0x535D, 0xB638,
- 0x535F, 0xB639, 0, 0xB63A, 0xB63B, 0xB63C, 0, 0xB63D,
-};
-static const unsigned short utf8_to_euc_E598_x0213[] = {
- 0, 0, 0, 0, 0, 0xB62A, 0x4332, 0xA43E,
- 0x2F30, 0x3245, 0xB62C, 0, 0, 0xB62D, 0x2F31, 0xB62F,
- 0xA43F, 0xB631, 0xB632, 0, 0x5352, 0, 0x5354, 0x3E28,
- 0x3133, 0xB633, 0, 0x5357, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xA43C, 0x325E, 0, 0, 0xB634, 0, 0, 0x5362,
- 0xA440, 0x3E7C, 0x535E, 0xB636, 0x535C, 0xB637, 0x535D, 0xA441,
- 0x535F, 0xB639, 0, 0x2F32, 0xB63B, 0xA443, 0, 0xA444,
-};
-static const unsigned short utf8_to_euc_E599[] = {
- 0xB63E, 0xB63F, 0x313D, 0xB640, 0xB641, 0, 0xB642, 0,
- 0, 0xB643, 0, 0xB644, 0x4139, 0xB645, 0x5359, 0xB646,
- 0x535A, 0, 0, 0, 0xB647, 0, 0, 0,
- 0, 0, 0, 0x337A, 0, 0, 0xB648, 0,
- 0xB649, 0xB64A, 0xB64B, 0xB64C, 0x5361, 0, 0xB64D, 0,
- 0x346F, 0xB64E, 0x5364, 0x5360, 0x5363, 0xB64F, 0, 0xB650,
- 0, 0xB651, 0xB652, 0, 0x4A2E, 0xB653, 0, 0,
- 0x4655, 0, 0x4838, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E599_x0213[] = {
- 0xA445, 0xB63F, 0x313D, 0xB640, 0xB641, 0, 0xB642, 0xA446,
- 0, 0x2F33, 0, 0xB644, 0x4139, 0xB645, 0x5359, 0xB646,
- 0x535A, 0, 0, 0x7427, 0xB647, 0, 0, 0,
- 0, 0, 0, 0x337A, 0, 0, 0xA447, 0,
- 0xA448, 0xB64A, 0xB64B, 0xB64C, 0x5361, 0, 0x2F35, 0,
- 0x346F, 0xB64E, 0x5364, 0x5360, 0x5363, 0xA449, 0, 0x2F37,
- 0, 0x2F38, 0x2F39, 0, 0x4A2E, 0xB653, 0x2F34, 0,
- 0x4655, 0, 0x4838, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E59A[] = {
- 0x5366, 0, 0, 0, 0xB654, 0xB655, 0x5365, 0x3345,
- 0xB656, 0, 0x5367, 0xB657, 0xB658, 0, 0, 0x536A,
- 0, 0, 0, 0, 0x5369, 0xB659, 0, 0,
- 0, 0xB65A, 0xB65B, 0, 0, 0xB65C, 0xB65D, 0xB65E,
- 0x5368, 0, 0x4739, 0, 0, 0x536B, 0xB65F, 0xB660,
- 0xB661, 0xB662, 0, 0xB663, 0xB664, 0xB665, 0x536C, 0,
- 0, 0xB666, 0, 0xB667, 0x536E, 0, 0x536D, 0xB668,
- 0, 0, 0, 0, 0x5370, 0, 0xB669, 0,
-};
-static const unsigned short utf8_to_euc_E59A_x0213[] = {
- 0x5366, 0, 0, 0, 0xB654, 0xB655, 0x5365, 0x3345,
- 0xA44B, 0, 0x5367, 0xB657, 0xA44C, 0, 0, 0x536A,
- 0, 0, 0, 0, 0x5369, 0xA44D, 0, 0,
- 0, 0x2F3A, 0xA44E, 0, 0, 0xA44F, 0x2F3B, 0xB65E,
- 0x5368, 0, 0x4739, 0, 0, 0x536B, 0xB65F, 0xB660,
- 0xA450, 0x2F3C, 0, 0xB663, 0x2F3D, 0xA451, 0x536C, 0,
- 0, 0xB666, 0xA452, 0x2F3E, 0x536E, 0, 0x536D, 0xB668,
- 0, 0, 0, 0, 0x5370, 0, 0xB669, 0,
-};
-static const unsigned short utf8_to_euc_E59B[] = {
- 0x5373, 0x5371, 0x536F, 0x5372, 0, 0xB66A, 0, 0,
- 0x5374, 0xB66B, 0xB66C, 0xB66D, 0xB670, 0xB671, 0x5375, 0xB66E,
- 0xB66F, 0x5376, 0, 0x5377, 0, 0, 0, 0x5378,
- 0x5145, 0xB672, 0x3C7C, 0x3B4D, 0xB673, 0xB674, 0x3273, 0xB675,
- 0x3078, 0xB676, 0, 0x4344, 0xB677, 0xB678, 0xB679, 0xB67A,
- 0xB67B, 0, 0, 0xB67D, 0, 0xB67E, 0x5379, 0,
- 0x3A24, 0xB67C, 0x304F, 0x3F5E, 0, 0, 0xB721, 0xB722,
- 0, 0x537A, 0x3847, 0, 0, 0x3971, 0, 0x537C,
-};
-static const unsigned short utf8_to_euc_E59B_x0213[] = {
- 0x5373, 0x5371, 0x536F, 0x5372, 0, 0xA453, 0, 0,
- 0x5374, 0x2F3F, 0x2F40, 0xB66D, 0xB670, 0xA454, 0x5375, 0xB66E,
- 0xB66F, 0x5376, 0, 0x5377, 0, 0, 0, 0x5378,
- 0x5145, 0xB672, 0x3C7C, 0x3B4D, 0xB673, 0xB674, 0x3273, 0xA455,
- 0x3078, 0xB676, 0, 0x4344, 0xB677, 0xB678, 0xB679, 0xB67A,
- 0xA456, 0, 0, 0xB67D, 0, 0xB67E, 0x5379, 0,
- 0x3A24, 0xB67C, 0x304F, 0x3F5E, 0, 0, 0xA457, 0xA458,
- 0, 0x537A, 0x3847, 0, 0, 0x3971, 0, 0x537C,
-};
-static const unsigned short utf8_to_euc_E59C[] = {
- 0x537B, 0xB723, 0xB724, 0x4A60, 0x537D, 0, 0, 0xB725,
- 0x5421, 0x537E, 0xB726, 0x5422, 0xB727, 0x5423, 0, 0x3777,
- 0, 0xB728, 0x3160, 0x5424, 0, 0xB729, 0x5426, 0,
- 0x5425, 0, 0xB72A, 0xB72B, 0x5428, 0xB72C, 0, 0x455A,
- 0xB72D, 0, 0xB72E, 0xB72F, 0xB730, 0xB731, 0x5429, 0x3035,
- 0x3A5F, 0xB732, 0xB733, 0, 0xB734, 0x373D, 0xB735, 0xB736,
- 0x434F, 0, 0, 0xB737, 0xB738, 0, 0, 0x542A,
- 0x542B, 0, 0, 0x542D, 0, 0xB739, 0xB73A, 0xB73B,
-};
-static const unsigned short utf8_to_euc_E59C_x0213[] = {
- 0x537B, 0xB723, 0xB724, 0x4A60, 0x537D, 0, 0, 0xB725,
- 0x5421, 0x537E, 0x2F41, 0x5422, 0xB727, 0x5423, 0, 0x3777,
- 0, 0xB728, 0x3160, 0x5424, 0, 0xA45A, 0x5426, 0,
- 0x5425, 0, 0xB72A, 0xB72B, 0x5428, 0xB72C, 0, 0x455A,
- 0xB72D, 0x2F43, 0xB72E, 0xA45B, 0xB730, 0xB731, 0x5429, 0x3035,
- 0x3A5F, 0xA45D, 0xB733, 0, 0xB734, 0x373D, 0xB735, 0x2F44,
- 0x434F, 0, 0, 0x2F45, 0x2F46, 0, 0, 0x542A,
- 0x542B, 0, 0, 0x542D, 0, 0xB739, 0xB73A, 0xB73B,
-};
-static const unsigned short utf8_to_euc_E59D[] = {
- 0x542E, 0, 0x3A64, 0, 0, 0xB73C, 0xB73D, 0x3651,
- 0, 0, 0x4B37, 0, 0xB73E, 0xB73F, 0x542C, 0x542F,
- 0x3A41, 0x3923, 0xB740, 0, 0, 0, 0, 0,
- 0, 0xF436, 0, 0, 0, 0, 0, 0,
- 0, 0x5433, 0xB741, 0, 0x3A25, 0xB742, 0x4333, 0xB743,
- 0xB744, 0x5430, 0x445A, 0xB745, 0, 0xB746, 0xB747, 0xB748,
- 0xB749, 0xB74A, 0, 0xB74B, 0xB74C, 0xB74D, 0, 0xB74E,
- 0, 0xB74F, 0xB750, 0xB751, 0xB752, 0, 0xB753, 0x5434,
-};
-static const unsigned short utf8_to_euc_E59D_x0213[] = {
- 0x542E, 0, 0x3A64, 0, 0, 0xA45F, 0xA460, 0x3651,
- 0, 0, 0x4B37, 0, 0xA461, 0xA462, 0x542C, 0x542F,
- 0x3A41, 0x3923, 0xB740, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x5433, 0xB741, 0, 0x3A25, 0, 0x4333, 0xB743,
- 0xA464, 0x5430, 0x445A, 0xB745, 0, 0xB746, 0xB747, 0xA465,
- 0x2F47, 0xB74A, 0, 0xA466, 0xA467, 0xA468, 0, 0x2F48,
- 0, 0xB74F, 0xB750, 0xA469, 0x2F49, 0, 0xB753, 0x5434,
-};
-static const unsigned short utf8_to_euc_E59E[] = {
- 0, 0xB754, 0x3F62, 0xB755, 0, 0, 0, 0,
- 0x5432, 0x5435, 0, 0x373F, 0xB756, 0, 0, 0,
- 0, 0, 0, 0x5436, 0xB757, 0xB760, 0, 0xB758,
- 0, 0xB759, 0xB75A, 0, 0xB75B, 0xB75C, 0xB75D, 0xB75E,
- 0x5437, 0xB75F, 0x3924, 0x3340, 0x5439, 0, 0, 0xB761,
- 0xB762, 0xB763, 0x543A, 0, 0xB764, 0, 0, 0,
- 0x543B, 0, 0, 0x5438, 0, 0, 0, 0,
- 0xB765, 0, 0, 0, 0, 0xB766, 0, 0,
-};
-static const unsigned short utf8_to_euc_E59E_x0213[] = {
- 0, 0xB754, 0x3F62, 0xB755, 0, 0, 0, 0,
- 0x5432, 0x5435, 0, 0x373F, 0xB756, 0, 0, 0,
- 0, 0, 0, 0x5436, 0xB757, 0xB760, 0, 0xB758,
- 0, 0xB759, 0xA46D, 0, 0x2F4A, 0xA46E, 0xA46F, 0xB75E,
- 0x5437, 0xB75F, 0x3924, 0x3340, 0x5439, 0, 0, 0xB761,
- 0xA470, 0xB763, 0x543A, 0, 0xA46C, 0, 0, 0,
- 0x543B, 0, 0, 0x5438, 0, 0, 0, 0,
- 0x2F4D, 0, 0, 0, 0, 0xB766, 0, 0,
-};
-static const unsigned short utf8_to_euc_E59F[] = {
- 0x5431, 0, 0, 0x543C, 0, 0, 0x543D, 0xB767,
- 0xB768, 0, 0, 0x4B64, 0xB769, 0, 0x3E6B, 0xB76A,
- 0, 0, 0x543F, 0x5440, 0x543E, 0xB76B, 0x5442, 0,
- 0, 0, 0, 0, 0x4738, 0xB76C, 0xB76D, 0x3068,
- 0x4956, 0xB77E, 0, 0x5443, 0xB76E, 0, 0xB76F, 0xB770,
- 0, 0xB771, 0, 0, 0, 0xB772, 0, 0,
- 0xB773, 0, 0, 0, 0x3E7D, 0xB774, 0xB775, 0x3C39,
- 0xB776, 0x475D, 0x3470, 0, 0x3A6B, 0xB777, 0xB778, 0xB779,
-};
-static const unsigned short utf8_to_euc_E59F_x0213[] = {
- 0x5431, 0, 0, 0x543C, 0, 0, 0x543D, 0x2F4E,
- 0x2F4F, 0, 0, 0x4B64, 0xA473, 0, 0x3E6B, 0x2F50,
- 0, 0, 0x543F, 0x5440, 0x543E, 0xB76B, 0x5442, 0xA471,
- 0, 0, 0, 0, 0x4738, 0xB76C, 0xA476, 0x3068,
- 0x4956, 0xB77E, 0, 0x5443, 0x2F51, 0, 0xA477, 0xB770,
- 0, 0xB771, 0, 0, 0, 0x2F52, 0, 0,
- 0xA478, 0, 0, 0, 0x3E7D, 0x2F53, 0x2F54, 0x3C39,
- 0xA47A, 0x475D, 0x3470, 0xA47B, 0x3A6B, 0xA47C, 0xB778, 0x2F55,
-};
-static const unsigned short utf8_to_euc_E5A0[] = {
- 0x4B59, 0, 0x4632, 0xB77A, 0xB77B, 0x3778, 0x424F, 0,
- 0xB77C, 0xB77D, 0x5441, 0x5444, 0xB821, 0xB822, 0, 0,
- 0, 0, 0, 0, 0, 0x4244, 0, 0,
- 0, 0x5445, 0, 0xB823, 0, 0x5446, 0xB824, 0xB825,
- 0xB826, 0x5448, 0, 0, 0x4469, 0, 0xB827, 0xB828,
- 0, 0, 0x342E, 0, 0, 0xB829, 0, 0x7421,
- 0x3161, 0x4A73, 0xB82A, 0, 0x3E6C, 0x4548, 0, 0,
- 0, 0xB82B, 0x3A66, 0, 0, 0x544E, 0, 0xB82C,
-};
-static const unsigned short utf8_to_euc_E5A0_x0213[] = {
- 0x4B59, 0, 0x4632, 0xB77A, 0xA47D, 0x3778, 0x424F, 0,
- 0xB77C, 0x2F56, 0x5441, 0x5444, 0xB821, 0xB822, 0, 0,
- 0, 0, 0, 0, 0, 0x4244, 0, 0,
- 0, 0x5445, 0, 0xB823, 0, 0x5446, 0xA47E, 0xB825,
- 0xA521, 0x5448, 0, 0, 0x4469, 0, 0xB827, 0xA522,
- 0, 0, 0x342E, 0, 0, 0xB829, 0, 0x7421,
- 0x3161, 0x4A73, 0xA523, 0, 0x3E6C, 0x4548, 0, 0,
- 0, 0xA524, 0x3A66, 0, 0, 0x544E, 0, 0xB82C,
-};
-static const unsigned short utf8_to_euc_E5A1[] = {
- 0x4A3D, 0x4E5D, 0, 0, 0, 0, 0, 0,
- 0, 0xB82D, 0x3274, 0x544A, 0xB82E, 0xB82F, 0, 0xB830,
- 0xB831, 0x413A, 0x544D, 0, 0x4563, 0xB832, 0, 0x4549,
- 0x4564, 0x4839, 0x444D, 0, 0, 0, 0x3A49, 0xB833,
- 0, 0xB834, 0x5449, 0, 0xB835, 0, 0, 0xB836,
- 0xB837, 0x3176, 0, 0x4536, 0, 0, 0, 0,
- 0x544B, 0, 0x5447, 0, 0, 0x3F50, 0, 0,
- 0xB838, 0x544F, 0, 0, 0xB839, 0, 0x3D4E, 0xB83A,
-};
-static const unsigned short utf8_to_euc_E5A1_x0213[] = {
- 0x4A3D, 0x4E5D, 0, 0, 0, 0, 0, 0,
- 0, 0xA526, 0x3274, 0x544A, 0xA527, 0xB82F, 0, 0xB830,
- 0xB831, 0x413A, 0x544D, 0, 0x4563, 0xB832, 0, 0x4549,
- 0x4564, 0x4839, 0x444D, 0, 0, 0, 0x3A49, 0xB833,
- 0, 0x2F58, 0x5449, 0, 0x2F59, 0, 0, 0xA528,
- 0xB837, 0x3176, 0, 0x4536, 0, 0, 0, 0,
- 0x544B, 0, 0x5447, 0, 0, 0x3F50, 0, 0,
- 0xB838, 0x544F, 0, 0, 0x2F5B, 0, 0x3D4E, 0xB83A,
-};
-static const unsigned short utf8_to_euc_E5A2[] = {
- 0xB83B, 0xB83C, 0, 0x362D, 0, 0x5450, 0, 0xB83D,
- 0xB83E, 0xB83F, 0xB840, 0, 0xB841, 0xB842, 0, 0xB843,
- 0xB844, 0, 0, 0x4A68, 0xB845, 0, 0xB846, 0x417D,
- 0, 0, 0, 0, 0x4446, 0xB847, 0xF439, 0x5452,
- 0xB848, 0xB849, 0xB84A, 0, 0, 0, 0xB84B, 0,
- 0x4B4F, 0xB84C, 0, 0x5453, 0, 0, 0x5458, 0,
- 0, 0xB84D, 0xB84E, 0x4A2F, 0, 0, 0, 0,
- 0x5457, 0x5451, 0x5454, 0x5456, 0xB850, 0, 0x3A26, 0,
-};
-static const unsigned short utf8_to_euc_E5A2_x0213[] = {
- 0xB83B, 0xB83C, 0, 0x362D, 0, 0x5450, 0, 0xB83D,
- 0xB83E, 0x2F5C, 0xA529, 0xA52A, 0xB841, 0xA52B, 0, 0xA52C,
- 0xA52D, 0, 0, 0x4A68, 0xA52E, 0, 0xB846, 0x417D,
- 0, 0, 0, 0, 0x4446, 0xA52F, 0x2F5D, 0x5452,
- 0xB848, 0xB849, 0xB84A, 0, 0, 0, 0xB84B, 0,
- 0x4B4F, 0x2F5F, 0xA530, 0x5453, 0, 0, 0x5458, 0,
- 0, 0xA531, 0, 0x4A2F, 0, 0, 0, 0,
- 0x5457, 0x5451, 0x5454, 0x5456, 0xB850, 0, 0x3A26, 0,
-};
-static const unsigned short utf8_to_euc_E5A3[] = {
- 0, 0x4A49, 0xB851, 0, 0xB84F, 0x5459, 0, 0x4345,
- 0xB852, 0, 0x3275, 0, 0x3E6D, 0xB853, 0xB854, 0,
- 0xB855, 0x545B, 0xB856, 0x545A, 0xB857, 0x3968, 0xB858, 0x545C,
- 0x545E, 0x545D, 0xB859, 0, 0x5460, 0xB85A, 0x5455, 0x5462,
- 0, 0xB85B, 0xB85C, 0, 0x5461, 0x545F, 0, 0,
- 0, 0xB85D, 0, 0x3B4E, 0x3F51, 0, 0x4154, 0x5463,
- 0x403C, 0x306D, 0x4764, 0xB85E, 0, 0, 0, 0x445B,
- 0, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A3_x0213[] = {
- 0, 0x4A49, 0xB851, 0xA533, 0xB84F, 0x5459, 0, 0x4345,
- 0xB852, 0, 0x3275, 0, 0x3E6D, 0xA534, 0x2F62, 0,
- 0xB855, 0x545B, 0x2F61, 0x545A, 0x2F63, 0x3968, 0xB858, 0x545C,
- 0x545E, 0x545D, 0x2F64, 0, 0x5460, 0xB85A, 0x5455, 0x5462,
- 0x2F65, 0xB85B, 0xA535, 0, 0x5461, 0x545F, 0, 0,
- 0, 0x2F66, 0, 0x3B4E, 0x3F51, 0, 0x4154, 0x5463,
- 0x403C, 0x306D, 0x4764, 0xA536, 0xA537, 0, 0, 0x445B,
- 0, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A4[] = {
- 0, 0, 0x5469, 0, 0, 0xB85F, 0xB860, 0,
- 0, 0x4A51, 0x546A, 0xB861, 0xB862, 0, 0, 0x3246,
- 0x546B, 0, 0xB863, 0xB864, 0xB865, 0x4D3C, 0x3330, 0,
- 0x5249, 0x3D48, 0x423F, 0x546C, 0x4C6B, 0xB867, 0, 0,
- 0, 0xB868, 0x4C34, 0xB869, 0xB86A, 0x546E, 0, 0x4267,
- 0xB86B, 0x4537, 0x4240, 0x4957, 0x546F, 0x5470, 0x317B, 0xB86C,
- 0xB86D, 0x3C3A, 0x5471, 0xB86E, 0, 0xB86F, 0xB870, 0x3050,
- 0x5472, 0, 0, 0, 0, 0, 0x5473, 0xB871,
-};
-static const unsigned short utf8_to_euc_E5A4_x0213[] = {
- 0, 0, 0x5469, 0, 0, 0xA538, 0xA539, 0,
- 0, 0x4A51, 0x546A, 0xA53A, 0x2F67, 0xA53B, 0, 0x3246,
- 0x546B, 0, 0xB863, 0xB864, 0xA53C, 0x4D3C, 0x3330, 0,
- 0x5249, 0x3D48, 0x423F, 0x546C, 0x4C6B, 0xB867, 0, 0,
- 0, 0xB868, 0x4C34, 0xB869, 0xA53D, 0x546E, 0, 0x4267,
- 0xB86B, 0x4537, 0x4240, 0x4957, 0x546F, 0x5470, 0x317B, 0xB86C,
- 0xB86D, 0x3C3A, 0x5471, 0xB86E, 0, 0xB86F, 0xB870, 0x3050,
- 0x5472, 0, 0, 0, 0, 0xA540, 0x5473, 0xB871,
-};
-static const unsigned short utf8_to_euc_E5A5[] = {
- 0, 0, 0, 0xB872, 0x3162, 0, 0xB873, 0x3471,
- 0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
- 0x5476, 0x3740, 0xB874, 0xB875, 0x4B5B, 0x5475, 0, 0x4565,
- 0x5479, 0xB876, 0x5478, 0xB877, 0, 0xB878, 0xB879, 0xB87A,
- 0x547B, 0xB87B, 0x547A, 0xB87C, 0, 0x317C, 0, 0x547C,
- 0x3E29, 0x547E, 0x4325, 0xB87D, 0x547D, 0xB87E, 0x4A33, 0xB921,
- 0, 0, 0xB922, 0x3D77, 0x455B, 0xB923, 0xB924, 0,
- 0x5521, 0xB925, 0, 0xB926, 0xB927, 0x3925, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A5_x0213[] = {
- 0, 0, 0, 0xB872, 0x3162, 0, 0xA542, 0x3471,
- 0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
- 0x5476, 0x3740, 0xB874, 0, 0x4B5B, 0x5475, 0, 0x4565,
- 0x5479, 0xB876, 0x5478, 0xA545, 0, 0x2F69, 0xB879, 0xA546,
- 0x547B, 0xB87B, 0x547A, 0, 0, 0x317C, 0, 0x547C,
- 0x3E29, 0x547E, 0x4325, 0xB87D, 0x547D, 0x2F6A, 0x4A33, 0xB921,
- 0, 0, 0xB922, 0x3D77, 0x455B, 0xA548, 0xA549, 0,
- 0x5521, 0xB925, 0, 0xB926, 0xA54A, 0x3925, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A6[] = {
- 0, 0x5522, 0x4721, 0x485E, 0x4C51, 0, 0, 0,
- 0, 0, 0x4725, 0xB928, 0xB929, 0x552B, 0xB92A, 0,
- 0, 0, 0xB92B, 0x3538, 0, 0xB92C, 0x4D45, 0xB92D,
- 0, 0x4C2F, 0, 0x562C, 0, 0x5523, 0, 0xB92E,
- 0, 0, 0, 0x5526, 0xB92F, 0x4245, 0, 0xB930,
- 0x4B38, 0, 0, 0, 0x454A, 0xB931, 0xB932, 0xB933,
- 0xB934, 0, 0x5527, 0xB935, 0, 0, 0, 0xB936,
- 0, 0x4B65, 0xB937, 0x3A4A, 0xB938, 0, 0x3E2A, 0,
-};
-static const unsigned short utf8_to_euc_E5A6_x0213[] = {
- 0, 0x5522, 0x4721, 0x485E, 0x4C51, 0, 0, 0,
- 0, 0, 0x4725, 0x2F6B, 0xB929, 0x552B, 0xB92A, 0,
- 0, 0, 0x2F6C, 0x3538, 0, 0xB92C, 0x4D45, 0xB92D,
- 0, 0x4C2F, 0, 0x562C, 0, 0x5523, 0, 0xA54B,
- 0, 0, 0, 0x5526, 0x2F6D, 0x4245, 0, 0xB930,
- 0x4B38, 0, 0, 0, 0x454A, 0xB931, 0xA54C, 0xB933,
- 0xB934, 0, 0x5527, 0xB935, 0, 0, 0, 0xB936,
- 0, 0x4B65, 0, 0x3A4A, 0xA54D, 0, 0x3E2A, 0,
-};
-static const unsigned short utf8_to_euc_E5A7[] = {
- 0, 0xB939, 0, 0xB93A, 0xB93B, 0, 0x5528, 0,
- 0xB93C, 0x3B50, 0xB93D, 0x3B4F, 0, 0xB93E, 0, 0,
- 0x3039, 0x3848, 0xB93F, 0x402B, 0x3051, 0, 0, 0,
- 0, 0x552C, 0x552D, 0, 0x552A, 0xB940, 0xB941, 0xB942,
- 0, 0, 0, 0xB943, 0xB944, 0x3138, 0x342F, 0xB945,
- 0x5529, 0, 0x4C45, 0x4931, 0, 0, 0xB946, 0xB947,
- 0, 0xB948, 0xB949, 0, 0xB94A, 0, 0x3028, 0xB94B,
- 0, 0, 0, 0x3079, 0, 0, 0, 0x3B51,
-};
-static const unsigned short utf8_to_euc_E5A7_x0213[] = {
- 0, 0xB939, 0, 0x2F6E, 0xB93B, 0, 0x5528, 0,
- 0xA54E, 0x3B50, 0xB93D, 0x3B4F, 0, 0xA54F, 0, 0,
- 0x3039, 0x3848, 0x2F6F, 0x402B, 0x3051, 0, 0, 0,
- 0, 0x552C, 0x552D, 0, 0x552A, 0x2F70, 0xA550, 0xB942,
- 0, 0, 0, 0xA551, 0xA552, 0x3138, 0x342F, 0xA553,
- 0x5529, 0, 0x4C45, 0x4931, 0, 0, 0xA554, 0xB947,
- 0, 0xB948, 0xB949, 0, 0xB94A, 0, 0x3028, 0xB94B,
- 0x7E7A, 0, 0, 0x3079, 0, 0, 0, 0x3B51,
-};
-static const unsigned short utf8_to_euc_E5A8[] = {
- 0xB94C, 0x3052, 0, 0x3023, 0xB94D, 0, 0, 0,
- 0, 0x5532, 0, 0, 0xB94E, 0xB94F, 0xB950, 0,
- 0, 0x5530, 0xB951, 0xB952, 0, 0, 0, 0,
- 0x4C3C, 0, 0x5533, 0, 0x5531, 0, 0xB953, 0x552F,
- 0x3F31, 0, 0, 0xB954, 0xB955, 0x552E, 0, 0xB956,
- 0xB957, 0x4A5A, 0xB958, 0, 0, 0xB959, 0, 0x3864,
- 0xB95A, 0, 0, 0, 0, 0x5537, 0x5538, 0,
- 0, 0, 0, 0, 0x3E2B, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A8_x0213[] = {
- 0xB94C, 0x3052, 0, 0x3023, 0xB94D, 0, 0, 0,
- 0, 0x5532, 0, 0, 0xA558, 0xA559, 0xB950, 0,
- 0, 0x5530, 0xB951, 0x2F71, 0, 0, 0, 0xA55A,
- 0x4C3C, 0, 0x5533, 0, 0x5531, 0, 0xB953, 0x552F,
- 0x3F31, 0, 0, 0x2F72, 0xB955, 0x552E, 0, 0xA55B,
- 0xB957, 0x4A5A, 0xB958, 0, 0, 0xA55C, 0, 0x3864,
- 0xB95A, 0, 0, 0, 0, 0x5537, 0x5538, 0,
- 0, 0, 0, 0, 0x3E2B, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5A9[] = {
- 0x5534, 0x4F2C, 0, 0, 0xB95B, 0xB95C, 0x474C, 0xB95D,
- 0xB95E, 0x5536, 0, 0, 0xB95F, 0, 0, 0,
- 0xB960, 0, 0, 0, 0, 0xB961, 0, 0,
- 0, 0, 0x3A27, 0, 0, 0, 0xB962, 0,
- 0, 0, 0x5539, 0xB963, 0, 0xB964, 0x4958, 0xB965,
- 0, 0, 0x553A, 0, 0x5535, 0xB966, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xB967,
- 0, 0, 0xB968, 0xB969, 0, 0, 0xB96A, 0x4C3B,
-};
-static const unsigned short utf8_to_euc_E5A9_x0213[] = {
- 0x5534, 0x4F2C, 0, 0, 0xB95B, 0xB95C, 0x474C, 0xB95D,
- 0xB95E, 0x5536, 0, 0, 0xB95F, 0, 0, 0,
- 0xB960, 0, 0, 0, 0, 0xA55D, 0, 0,
- 0, 0, 0x3A27, 0, 0, 0, 0xB962, 0,
- 0, 0, 0x5539, 0xB963, 0, 0xA55E, 0x4958, 0x2F73,
- 0, 0, 0x553A, 0, 0x5535, 0x2F74, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2F75,
- 0, 0, 0xA55F, 0xB969, 0, 0, 0x2F76, 0x4C3B,
-};
-static const unsigned short utf8_to_euc_E5AA[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xB96B, 0, 0, 0, 0,
- 0xB96C, 0, 0x475E, 0xB96D, 0, 0, 0xB96E, 0,
- 0, 0xB96F, 0x553B, 0x4932, 0xB970, 0, 0xB971, 0xB972,
- 0xB973, 0, 0xB974, 0, 0, 0, 0, 0xB975,
- 0, 0, 0, 0, 0xB976, 0, 0, 0,
- 0, 0xB977, 0xB978, 0xB979, 0, 0xB97A, 0, 0,
- 0xB97B, 0, 0xB97C, 0xB97D, 0x553C, 0x5540, 0x553D, 0xB97E,
-};
-static const unsigned short utf8_to_euc_E5AA_x0213[] = {
- 0, 0, 0, 0, 0x2F77, 0, 0, 0,
- 0, 0, 0, 0xA560, 0, 0, 0, 0,
- 0xB96C, 0, 0x475E, 0xB96D, 0, 0, 0xB96E, 0,
- 0, 0xB96F, 0x553B, 0x4932, 0xA561, 0, 0x2F78, 0xA562,
- 0xA563, 0, 0xA564, 0, 0, 0, 0, 0x2F79,
- 0, 0, 0, 0, 0xB976, 0, 0, 0,
- 0, 0xA565, 0xB978, 0xA566, 0, 0xA567, 0, 0,
- 0xB97B, 0, 0xA568, 0xB97D, 0x553C, 0x5540, 0x553D, 0xA569,
-};
-static const unsigned short utf8_to_euc_E5AB[] = {
- 0, 0x3247, 0x553F, 0, 0xBA21, 0, 0xBA22, 0,
- 0xBA23, 0x3C3B, 0, 0x553E, 0x3779, 0, 0, 0xBA24,
- 0x554C, 0, 0, 0, 0, 0, 0x5545, 0x5542,
- 0, 0, 0xBA25, 0, 0xBA26, 0, 0, 0,
- 0xBA27, 0x4364, 0, 0x5541, 0, 0xBA28, 0x5543, 0,
- 0, 0x5544, 0xBA29, 0, 0, 0, 0xBA2A, 0,
- 0, 0, 0, 0, 0, 0xBA2B, 0xBA2C, 0,
- 0, 0, 0x5546, 0x5547, 0, 0xBA2D, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5AB_x0213[] = {
- 0, 0x3247, 0x553F, 0, 0x2F7A, 0, 0xBA22, 0,
- 0xBA23, 0x3C3B, 0, 0x553E, 0x3779, 0, 0, 0xBA24,
- 0x554C, 0, 0, 0, 0, 0, 0x5545, 0x5542,
- 0, 0, 0xA56A, 0, 0xA56B, 0, 0, 0,
- 0xA56C, 0x4364, 0, 0x5541, 0, 0xA56D, 0x5543, 0,
- 0, 0x5544, 0xBA29, 0, 0, 0, 0xA56F, 0,
- 0xA56E, 0, 0, 0, 0, 0xA570, 0xBA2C, 0,
- 0, 0, 0x5546, 0x5547, 0, 0xBA2D, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5AC[] = {
- 0xBA2E, 0xBA2F, 0, 0, 0, 0, 0, 0,
- 0xBA30, 0x3472, 0, 0x5549, 0x5548, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x554A, 0xBA31,
- 0, 0xBA33, 0, 0xBA34, 0, 0xBA35, 0, 0,
- 0, 0xBA36, 0x3E6E, 0, 0, 0xBA37, 0, 0,
- 0, 0, 0x554D, 0, 0x445C, 0xBA38, 0, 0,
- 0x3145, 0, 0x554B, 0, 0xBA32, 0, 0x554E, 0,
- 0xBA39, 0, 0, 0, 0, 0, 0x554F, 0,
-};
-static const unsigned short utf8_to_euc_E5AC_x0213[] = {
- 0xA571, 0xBA2F, 0, 0, 0, 0, 0, 0,
- 0xA572, 0x3472, 0, 0x5549, 0x5548, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x554A, 0xA573,
- 0, 0x2F7C, 0, 0xBA34, 0, 0xBA35, 0, 0,
- 0, 0xBA36, 0x3E6E, 0, 0, 0x2F7D, 0, 0,
- 0, 0, 0x554D, 0, 0x445C, 0xA575, 0, 0,
- 0x3145, 0, 0x554B, 0, 0xA574, 0, 0x554E, 0,
- 0xBA39, 0, 0, 0, 0, 0, 0x554F, 0,
-};
-static const unsigned short utf8_to_euc_E5AD[] = {
- 0x5552, 0xBA3A, 0, 0x5550, 0, 0x5551, 0, 0,
- 0, 0, 0, 0xBA3B, 0xBA3C, 0, 0, 0,
- 0x3B52, 0x5553, 0xBA3D, 0, 0x3926, 0x5554, 0xBA3E, 0x3B7A,
- 0x4238, 0, 0x5555, 0x5556, 0x3B5A, 0x3927, 0xBA3F, 0x4C52,
- 0, 0, 0, 0x3528, 0x3849, 0x5557, 0x3358, 0,
- 0xBA40, 0x5558, 0, 0x4239, 0, 0, 0xBA41, 0xBA42,
- 0x5559, 0x5623, 0, 0x555A, 0, 0x555B, 0, 0,
- 0x555C, 0, 0x555E, 0, 0xBA43, 0xBA44, 0xBA45, 0xBA46,
-};
-static const unsigned short utf8_to_euc_E5AD_x0213[] = {
- 0x5552, 0x4F55, 0, 0x5550, 0, 0x5551, 0, 0,
- 0, 0, 0, 0xBA3B, 0xA576, 0, 0, 0,
- 0x3B52, 0x5553, 0xA577, 0, 0x3926, 0x5554, 0x4F56, 0x3B7A,
- 0x4238, 0, 0x5555, 0x5556, 0x3B5A, 0x3927, 0xBA3F, 0x4C52,
- 0, 0, 0, 0x3528, 0x3849, 0x5557, 0x3358, 0,
- 0xA578, 0x5558, 0, 0x4239, 0, 0, 0xBA41, 0xA579,
- 0x5559, 0x5623, 0, 0x555A, 0, 0x555B, 0, 0,
- 0x555C, 0, 0x555E, 0, 0xA57A, 0x4F57, 0xBA45, 0xA57B,
-};
-static const unsigned short utf8_to_euc_E5AE[] = {
- 0x555F, 0xBA47, 0, 0x5560, 0xBA48, 0x4270, 0xBA49, 0x3127,
- 0x3C69, 0x3042, 0xBA4A, 0x4157, 0x3430, 0x3C35, 0xBA4B, 0x3928,
- 0xBA4C, 0xBA4D, 0, 0xBA4E, 0xBA4F, 0x4566, 0xBA50, 0x3D21,
- 0x3431, 0x4368, 0x446A, 0x3038, 0x3539, 0x4A75, 0, 0x3C42,
- 0, 0, 0x3552, 0x406B, 0x3C3C, 0x4D28, 0x5561, 0,
- 0xBA51, 0xBA52, 0, 0, 0xBA53, 0xBA54, 0x355C, 0xBA55,
- 0x3A4B, 0xBA56, 0xBA57, 0x3332, 0x3163, 0x3E2C, 0x3248, 0xBA58,
- 0x5562, 0x4D46, 0xBA59, 0, 0xBA5A, 0, 0, 0x3D49,
-};
-static const unsigned short utf8_to_euc_E5AE_x0213[] = {
- 0x555F, 0xA57C, 0, 0x5560, 0xA57D, 0x4270, 0xBA49, 0x3127,
- 0x3C69, 0x3042, 0xBA4A, 0x4157, 0x3430, 0x3C35, 0xBA4B, 0x3928,
- 0xBA4C, 0xBA4D, 0, 0x4F58, 0xBA4F, 0x4566, 0xA821, 0x3D21,
- 0x3431, 0x4368, 0x446A, 0x3038, 0x3539, 0x4A75, 0, 0x3C42,
- 0, 0, 0x3552, 0x406B, 0x3C3C, 0x4D28, 0x5561, 0,
- 0xBA51, 0xBA52, 0, 0, 0xA822, 0xBA54, 0x355C, 0xBA55,
- 0x3A4B, 0xBA56, 0xBA57, 0x3332, 0x3163, 0x3E2C, 0x3248, 0xBA58,
- 0x5562, 0x4D46, 0xBA59, 0, 0xBA5A, 0, 0, 0x3D49,
-};
-static const unsigned short utf8_to_euc_E5AF[] = {
- 0xBA5B, 0xBA5C, 0x3C64, 0x5563, 0x3473, 0x4652, 0x4C29, 0x5564,
- 0, 0x5565, 0, 0, 0x4959, 0xBA5D, 0, 0xBA5E,
- 0x5567, 0, 0x3428, 0x3677, 0x5566, 0, 0xBA5F, 0xBA60,
- 0xBA61, 0xBA62, 0xBA63, 0x3432, 0, 0x3F32, 0x556B, 0x3B21,
- 0xBA64, 0x3249, 0x556A, 0, 0x5568, 0x556C, 0x5569, 0x472B,
- 0x5C4D, 0x3F33, 0, 0x556D, 0xF43A, 0, 0x4E40, 0xBA65,
- 0x556E, 0xBA66, 0, 0x5570, 0xBA67, 0x437E, 0x556F, 0,
- 0x4023, 0, 0x3B7B, 0, 0, 0xBA68, 0x4250, 0x3C77,
-};
-static const unsigned short utf8_to_euc_E5AF_x0213[] = {
- 0xA824, 0xBA5C, 0x3C64, 0x5563, 0x3473, 0x4652, 0x4C29, 0x5564,
- 0, 0x5565, 0, 0, 0x4959, 0xBA5D, 0xA826, 0xBA5E,
- 0x5567, 0, 0x3428, 0x3677, 0x5566, 0, 0xA827, 0xBA60,
- 0x4F59, 0xBA62, 0xBA63, 0x3432, 0, 0x3F32, 0x556B, 0x3B21,
- 0xBA64, 0x3249, 0x556A, 0, 0x5568, 0x556C, 0x5569, 0x472B,
- 0x5C4D, 0x3F33, 0, 0x556D, 0x4F5A, 0, 0x4E40, 0xBA65,
- 0x556E, 0xA82A, 0, 0x5570, 0xBA67, 0x437E, 0x556F, 0,
- 0x4023, 0, 0x3B7B, 0, 0, 0xA82B, 0x4250, 0x3C77,
-};
-static const unsigned short utf8_to_euc_E5B0[] = {
- 0, 0x4975, 0x406C, 0, 0x3C4D, 0x5571, 0x3E2D, 0x5572,
- 0x5573, 0x3053, 0x423A, 0x3F52, 0xBA69, 0x5574, 0x4633, 0x3E2E,
- 0, 0x3E2F, 0, 0x5575, 0, 0, 0x406D, 0xBA6A,
- 0, 0, 0x3E30, 0, 0, 0, 0xBA6B, 0xBA6C,
- 0x5576, 0, 0x5577, 0xBA6D, 0x4C60, 0, 0xBA6E, 0,
- 0x5578, 0xBA6F, 0, 0xBA70, 0xBA71, 0x3646, 0xBA72, 0,
- 0xBA73, 0x3D22, 0xBA74, 0, 0, 0xBA75, 0xBA76, 0,
- 0x5579, 0x557A, 0x3C5C, 0x3F2C, 0x4674, 0x3F54, 0x4878, 0x4722,
-};
-static const unsigned short utf8_to_euc_E5B0_x0213[] = {
- 0, 0x4975, 0x406C, 0xA82D, 0x3C4D, 0x5571, 0x3E2D, 0x5572,
- 0x5573, 0x3053, 0x423A, 0x3F52, 0xBA69, 0x5574, 0x4633, 0x3E2E,
- 0, 0x3E2F, 0x4F5B, 0x5575, 0, 0, 0x406D, 0xBA6A,
- 0, 0, 0x3E30, 0, 0, 0, 0x4F5C, 0xBA6C,
- 0x5576, 0, 0x5577, 0x4F5D, 0x4C60, 0, 0xBA6E, 0,
- 0x5578, 0xA82E, 0, 0x4F5E, 0xBA71, 0x3646, 0xBA72, 0,
- 0xA82F, 0x3D22, 0xBA74, 0, 0, 0xBA75, 0xBA76, 0,
- 0x5579, 0x557A, 0x3C5C, 0x3F2C, 0x4674, 0x3F54, 0x4878, 0x4722,
-};
-static const unsigned short utf8_to_euc_E5B1[] = {
- 0x3649, 0x557B, 0, 0, 0, 0x356F, 0x557C, 0,
- 0x367E, 0, 0x464F, 0x3230, 0, 0x3B53, 0x557D, 0x5622,
- 0x5621, 0x367D, 0, 0x557E, 0, 0x4538, 0, 0,
- 0, 0xBA77, 0xBA78, 0, 0xBA79, 0, 0x4230, 0,
- 0x454B, 0x3C48, 0xBA7A, 0xBA7B, 0x4158, 0x4D7A, 0, 0xBA7C,
- 0xBA7D, 0xBA7E, 0, 0, 0x5624, 0xBB21, 0x5625, 0x4656,
- 0xBB22, 0x3B33, 0, 0, 0xBB23, 0xBB24, 0x5627, 0,
- 0, 0x5628, 0xBB25, 0xBB26, 0xBB27, 0xBB28, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B1_x0213[] = {
- 0x3649, 0x557B, 0, 0, 0, 0x356F, 0x557C, 0,
- 0x367E, 0, 0x464F, 0x3230, 0, 0x3B53, 0x557D, 0x5622,
- 0x5621, 0x367D, 0, 0x557E, 0, 0x4538, 0, 0,
- 0, 0xBA77, 0xBA78, 0x7E7B, 0xBA79, 0, 0x4230, 0xA831,
- 0x454B, 0x3C48, 0x4F60, 0xA832, 0x4158, 0x4D7A, 0, 0xA833,
- 0xA834, 0xA835, 0, 0, 0x5624, 0xBB21, 0x5625, 0x4656,
- 0xA836, 0x3B33, 0, 0, 0xBB23, 0xBB24, 0x5627, 0,
- 0, 0x5628, 0x4F64, 0xBB26, 0xA839, 0xBB28, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xBB29,
- 0xBB2A, 0, 0xBB2B, 0, 0x5629, 0, 0, 0xBB2C,
- 0x3474, 0x562A, 0xBB2D, 0, 0x562B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xBB2E, 0, 0xBB2F,
- 0xBB30, 0x322C, 0xBB31, 0xBB32, 0, 0, 0xBB33, 0,
- 0x413B, 0x3464, 0xBB34, 0x562D, 0x4C28, 0, 0, 0,
- 0, 0x4252, 0xBB35, 0x3359, 0xBB36, 0xBB37, 0x562F, 0x5631,
- 0x345F, 0, 0xBB38, 0x562E, 0x5630, 0, 0x5633, 0,
-};
-static const unsigned short utf8_to_euc_E5B2_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xBB29,
- 0xA83C, 0, 0xA83D, 0, 0x5629, 0, 0, 0x4F65,
- 0x3474, 0x562A, 0xBB2D, 0, 0x562B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xBB2E, 0, 0x4F66,
- 0xA841, 0x322C, 0xA842, 0x4F67, 0, 0, 0xA843, 0xA844,
- 0x413B, 0x3464, 0x4F68, 0x562D, 0x4C28, 0xA846, 0, 0,
- 0, 0x4252, 0xBB35, 0x3359, 0xBB36, 0xA847, 0x562F, 0x5631,
- 0x345F, 0, 0x4F69, 0x562E, 0x5630, 0, 0x5633, 0,
-};
-static const unsigned short utf8_to_euc_E5B3[] = {
- 0, 0, 0, 0, 0, 0x5632, 0, 0x5634,
- 0, 0xBB39, 0, 0xBB3A, 0, 0, 0, 0,
- 0, 0, 0xBB3B, 0, 0, 0, 0, 0xBB3D,
- 0, 0x5635, 0, 0, 0, 0xBB3C, 0, 0,
- 0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
- 0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0xBB3E, 0x4A77,
- 0x4A76, 0xBB3F, 0xBB40, 0, 0xBB41, 0xF43B, 0x4567, 0,
- 0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B3_x0213[] = {
- 0, 0, 0, 0, 0, 0x5632, 0, 0x5634,
- 0, 0xA849, 0, 0x4F6A, 0, 0, 0, 0,
- 0x4F6B, 0, 0x4F6C, 0, 0, 0, 0, 0xBB3D,
- 0, 0x5635, 0, 0, 0, 0xBB3C, 0, 0,
- 0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
- 0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0xBB3E, 0x4A77,
- 0x4A76, 0xBB3F, 0xBB40, 0, 0x4F6D, 0, 0x4567, 0,
- 0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B4[] = {
- 0, 0xBB42, 0, 0, 0, 0, 0xBB43, 0x3F72,
- 0, 0, 0, 0x563C, 0, 0xBB44, 0x3A6A, 0,
- 0, 0x5642, 0xBB45, 0, 0x5643, 0x563D, 0x3333, 0x563E,
- 0x5647, 0x5646, 0x5645, 0x5641, 0, 0, 0, 0x5640,
- 0, 0, 0x5644, 0xBB47, 0xBB48, 0, 0xBB49, 0xBB4A,
- 0, 0x4A78, 0, 0xBB46, 0, 0, 0, 0,
- 0, 0xBB4B, 0, 0, 0xBB4C, 0, 0, 0,
- 0, 0xBB4D, 0, 0, 0, 0xBB4E, 0, 0xBB4F,
-};
-static const unsigned short utf8_to_euc_E5B4_x0213[] = {
- 0, 0xBB42, 0, 0, 0, 0, 0xA84C, 0x3F72,
- 0, 0, 0, 0x563C, 0, 0x4F70, 0x3A6A, 0,
- 0xA84D, 0x5642, 0xBB45, 0, 0x5643, 0x563D, 0x3333, 0x563E,
- 0x5647, 0x5646, 0x5645, 0x5641, 0, 0xA84F, 0, 0x5640,
- 0xA850, 0, 0x5644, 0xBB47, 0xA851, 0, 0xA852, 0x4F71,
- 0, 0x4A78, 0, 0xA84E, 0, 0, 0, 0,
- 0, 0xA853, 0, 0, 0xBB4C, 0, 0, 0,
- 0, 0xA854, 0, 0, 0, 0xBB4E, 0, 0xBB4F,
-};
-static const unsigned short utf8_to_euc_E5B5[] = {
- 0, 0, 0xBB50, 0xBB51, 0, 0, 0xBB52, 0,
- 0xBB53, 0, 0xBB57, 0x564B, 0x5648, 0, 0x564A, 0,
- 0x4D72, 0xBB55, 0x5649, 0xF43C, 0, 0xBB54, 0, 0,
- 0, 0xBB56, 0, 0, 0x563F, 0, 0, 0xBB58,
- 0xBB59, 0xBB5A, 0xBB5B, 0, 0xBB5C, 0, 0, 0,
- 0, 0x3F73, 0xBB5D, 0, 0x564C, 0xBB5E, 0, 0x3A37,
- 0xBB5F, 0, 0, 0x564D, 0, 0, 0x564E, 0,
- 0, 0xBB60, 0xBB61, 0, 0, 0, 0xBB62, 0xBB63,
-};
-static const unsigned short utf8_to_euc_E5B5_x0213[] = {
- 0, 0, 0xA855, 0xBB51, 0, 0, 0x4F73, 0x4F74,
- 0xBB53, 0, 0x4F76, 0x564B, 0x5648, 0, 0x564A, 0,
- 0x4D72, 0xBB55, 0x5649, 0x4F75, 0, 0xBB54, 0, 0,
- 0, 0xBB56, 0, 0, 0x563F, 0, 0, 0xBB58,
- 0xBB59, 0xA857, 0xBB5B, 0, 0xBB5C, 0, 0, 0,
- 0, 0x3F73, 0xA858, 0, 0x564C, 0x4F77, 0, 0x3A37,
- 0xA85A, 0, 0, 0x564D, 0, 0, 0x564E, 0,
- 0, 0xBB60, 0xBB61, 0, 0, 0, 0xBB62, 0xBB63,
-};
-static const unsigned short utf8_to_euc_E5B6[] = {
- 0, 0xBB64, 0x5651, 0xBB65, 0x5650, 0, 0, 0x564F,
- 0xBB66, 0, 0xBB67, 0x4568, 0x563A, 0, 0, 0,
- 0x5657, 0, 0xBB68, 0xBB69, 0xBB6A, 0xBB6B, 0, 0,
- 0, 0xBB6C, 0, 0xBB6D, 0, 0x5653, 0, 0xBB6E,
- 0xBB6F, 0, 0x5652, 0, 0, 0, 0, 0xBB70,
- 0, 0, 0, 0xBB71, 0x5654, 0, 0x5655, 0,
- 0xBB72, 0, 0xE674, 0, 0xBB73, 0, 0, 0x5658,
- 0xBB74, 0xBB75, 0x4E66, 0, 0x5659, 0x5656, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B6_x0213[] = {
- 0, 0x4F78, 0x5651, 0xBB65, 0x5650, 0, 0, 0x564F,
- 0xA85D, 0, 0xBB67, 0x4568, 0x563A, 0, 0, 0,
- 0x5657, 0, 0xA85F, 0xBB69, 0xA860, 0xBB6B, 0, 0xA861,
- 0, 0xA862, 0, 0xBB6D, 0, 0x5653, 0, 0xBB6E,
- 0x4F79, 0, 0x5652, 0, 0x4F7A, 0, 0, 0x4F7B,
- 0, 0, 0, 0xBB71, 0x5654, 0, 0x5655, 0,
- 0xA863, 0, 0xA864, 0, 0xA865, 0, 0, 0x5658,
- 0x4F7C, 0xA867, 0x4E66, 0, 0x5659, 0x5656, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5B7[] = {
- 0, 0, 0, 0xBB76, 0, 0, 0, 0xBB77,
- 0, 0x565A, 0, 0xBB78, 0x3460, 0x565B, 0xBB7A, 0,
- 0xBB79, 0, 0x565D, 0x565C, 0, 0, 0x565E, 0,
- 0xBB7B, 0xBB7C, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
- 0xBB7D, 0x3D64, 0, 0x4163, 0xBB7E, 0x3929, 0x3A38, 0x392A,
- 0x3570, 0xBC21, 0, 0x5660, 0, 0, 0x3A39, 0,
- 0, 0x384A, 0x5661, 0x4C26, 0x4743, 0x5662, 0, 0x392B,
- 0xBC22, 0xBC23, 0, 0x342C, 0, 0x4327, 0x3652, 0,
-};
-static const unsigned short utf8_to_euc_E5B7_x0213[] = {
- 0, 0, 0, 0xBB76, 0, 0, 0, 0xBB77,
- 0, 0x565A, 0, 0x4F7D, 0x3460, 0x565B, 0xBB7A, 0,
- 0, 0xA868, 0x565D, 0x565C, 0, 0, 0x565E, 0xA869,
- 0xA86A, 0xBB7C, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
- 0xA86B, 0x3D64, 0x7428, 0x4163, 0xA86D, 0x3929, 0x3A38, 0x392A,
- 0x3570, 0xA86E, 0, 0x5660, 0, 0, 0x3A39, 0,
- 0, 0x384A, 0x5661, 0x4C26, 0x4743, 0x5662, 0, 0x392B,
- 0xBC22, 0xBC23, 0, 0x342C, 0, 0x4327, 0x3652, 0,
-};
-static const unsigned short utf8_to_euc_E5B8[] = {
- 0xBC24, 0, 0x3B54, 0x495B, 0, 0, 0x4841, 0xBC25,
- 0, 0, 0, 0x5663, 0x3475, 0xBC26, 0, 0,
- 0, 0x5666, 0xBC27, 0, 0xBC28, 0xBC29, 0x4421, 0,
- 0xBC2A, 0x5665, 0x5664, 0x5667, 0, 0x446B, 0, 0xBC2B,
- 0xBC2C, 0, 0, 0, 0, 0x3F63, 0, 0,
- 0xBC2E, 0, 0, 0x3B55, 0, 0x404A, 0xBC2D, 0x4253,
- 0x3522, 0, 0xBC2F, 0x4422, 0, 0xBC30, 0x5668, 0x5669,
- 0x3E6F, 0, 0, 0, 0, 0x4B39, 0xBC31, 0,
-};
-static const unsigned short utf8_to_euc_E5B8_x0213[] = {
- 0xA870, 0, 0x3B54, 0x495B, 0, 0, 0x4841, 0xBC25,
- 0, 0, 0, 0x5663, 0x3475, 0xBC26, 0, 0,
- 0, 0x5666, 0xA872, 0, 0x7429, 0xA873, 0x4421, 0,
- 0x742A, 0x5665, 0x5664, 0x5667, 0, 0x446B, 0, 0xA875,
- 0xBC2C, 0, 0, 0, 0, 0x3F63, 0, 0,
- 0xBC2E, 0, 0, 0x3B55, 0, 0x404A, 0xA876, 0x4253,
- 0x3522, 0, 0xBC2F, 0x4422, 0, 0xBC30, 0x5668, 0x5669,
- 0x3E6F, 0, 0, 0, 0, 0x4B39, 0xA877, 0,
-};
-static const unsigned short utf8_to_euc_E5B9[] = {
- 0x566C, 0, 0, 0x566B, 0x566A, 0x497D, 0, 0x5673,
- 0, 0xBC34, 0, 0xBC32, 0x4B5A, 0, 0x566D, 0,
- 0xBC33, 0xBC35, 0, 0, 0x566F, 0x4B6B, 0xBC36, 0x566E,
- 0xBC37, 0, 0, 0xBC38, 0xBC39, 0, 0xBC3A, 0x5670,
- 0, 0x4828, 0x5671, 0x4A3E, 0x5672, 0, 0, 0,
- 0xBC3B, 0, 0xBC3C, 0xBC3D, 0xBC3E, 0xBC3F, 0xBC40, 0,
- 0xBC41, 0, 0x3433, 0x4A3F, 0x472F, 0x5674, 0x5675, 0,
- 0x392C, 0x3434, 0x5676, 0x3838, 0x4D44, 0x4D29, 0x3476, 0x5678,
-};
-static const unsigned short utf8_to_euc_E5B9_x0213[] = {
- 0x566C, 0, 0, 0x566B, 0x566A, 0x497D, 0, 0x5673,
- 0, 0xA878, 0, 0xBC32, 0x4B5A, 0, 0x566D, 0,
- 0xBC33, 0xBC35, 0, 0, 0x566F, 0x4B6B, 0xA87A, 0x566E,
- 0x742B, 0, 0, 0xBC38, 0xBC39, 0, 0x742C, 0x5670,
- 0, 0x4828, 0x5671, 0x4A3E, 0x5672, 0, 0, 0,
- 0xBC3B, 0, 0xBC3C, 0xA87C, 0xA87D, 0xA87E, 0xAC21, 0,
- 0xBC41, 0, 0x3433, 0x4A3F, 0x472F, 0x5674, 0x5675, 0x7E7C,
- 0x392C, 0x3434, 0x5676, 0x3838, 0x4D44, 0x4D29, 0x3476, 0x5678,
-};
-static const unsigned short utf8_to_euc_E5BA[] = {
- 0xBC42, 0x4423, 0, 0x392D, 0x3E31, 0, 0, 0x485F,
- 0, 0, 0x3E32, 0xBC43, 0, 0, 0xBC44, 0x3D78,
- 0, 0, 0, 0, 0, 0x446C, 0x4A79, 0x4539,
- 0, 0, 0x392E, 0, 0x495C, 0, 0, 0,
- 0x5679, 0, 0xBC45, 0, 0xBC46, 0xBC47, 0x4559, 0x3A42,
- 0xBC48, 0, 0xBC49, 0x384B, 0xBC4A, 0x446D, 0, 0,
- 0, 0xBC4B, 0, 0xBC4C, 0, 0x3043, 0x3D6E, 0x392F,
- 0x4D47, 0, 0, 0, 0, 0xBC4D, 0xBC4E, 0xBC4F,
-};
-static const unsigned short utf8_to_euc_E5BA_x0213[] = {
- 0xBC42, 0x4423, 0, 0x392D, 0x3E31, 0, 0, 0x485F,
- 0, 0, 0x3E32, 0xBC43, 0, 0, 0xBC44, 0x3D78,
- 0, 0, 0, 0, 0, 0x446C, 0x4A79, 0x4539,
- 0, 0, 0x392E, 0, 0x495C, 0, 0, 0,
- 0x5679, 0, 0xBC45, 0, 0xBC46, 0xAC23, 0x4559, 0x3A42,
- 0xBC48, 0, 0xAC24, 0x384B, 0xAC25, 0x446D, 0, 0,
- 0, 0xBC4B, 0, 0xBC4C, 0, 0x3043, 0x3D6E, 0x392F,
- 0x4D47, 0xAC26, 0, 0, 0, 0xBC4D, 0x742D, 0xAC27,
-};
-static const unsigned short utf8_to_euc_E5BB[] = {
- 0, 0x567A, 0x567B, 0x4751, 0, 0, 0xBC50, 0,
- 0x567C, 0x4E77, 0x4F2D, 0xBC52, 0xBC51, 0, 0xBC53, 0x567E,
- 0x567D, 0xBC54, 0xBC55, 0x3347, 0xBC56, 0xBC57, 0x5721, 0,
- 0, 0, 0x5724, 0x5725, 0xBC58, 0x5723, 0xBC59, 0x4940,
- 0x3E33, 0x5727, 0x5726, 0x5722, 0, 0xBC5A, 0, 0,
- 0x5728, 0x5729, 0, 0xBC5B, 0x572A, 0, 0, 0,
- 0x572D, 0x572B, 0, 0x572C, 0x572E, 0, 0x3164, 0x446E,
- 0x572F, 0, 0x377A, 0x3276, 0x4736, 0, 0x5730, 0x467B,
-};
-static const unsigned short utf8_to_euc_E5BB_x0213[] = {
- 0, 0x567A, 0x567B, 0x4751, 0, 0, 0xAC28, 0,
- 0x567C, 0x4E77, 0x4F2D, 0x742F, 0xBC51, 0, 0xBC53, 0x567E,
- 0x567D, 0xBC54, 0xAC29, 0x3347, 0xBC56, 0xBC57, 0x5721, 0,
- 0, 0xAC2A, 0x5724, 0x5725, 0xBC58, 0x5723, 0xBC59, 0x4940,
- 0x3E33, 0x5727, 0x5726, 0x5722, 0, 0xBC5A, 0, 0,
- 0x5728, 0x5729, 0, 0xBC5B, 0x572A, 0, 0, 0,
- 0x572D, 0x572B, 0, 0x572C, 0x572E, 0, 0x3164, 0x446E,
- 0x572F, 0x7430, 0x377A, 0x3276, 0x4736, 0xAC2C, 0x5730, 0x467B,
-};
-static const unsigned short utf8_to_euc_E5BC[] = {
- 0, 0x4A5B, 0xBC5C, 0x5731, 0x4F2E, 0, 0xBC5D, 0xBC5E,
- 0xBC5F, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0xBC60, 0x3C30,
- 0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
- 0x3930, 0xBC61, 0, 0x4350, 0xBC62, 0xBC63, 0, 0x446F,
- 0, 0xBC64, 0xBC65, 0xBC66, 0xBC67, 0x4C6F, 0x3839, 0x384C,
- 0xBC68, 0x5738, 0, 0xBC69, 0xBC6A, 0x5739, 0xBC6B, 0x573F,
- 0xBC6C, 0x3C65, 0, 0, 0xBC6D, 0x4425, 0xBC6E, 0x362F,
- 0x573A, 0, 0, 0xBC6F, 0x492B, 0xBC70, 0x4346, 0xBC71,
-};
-static const unsigned short utf8_to_euc_E5BC_x0213[] = {
- 0x7431, 0x4A5B, 0x7432, 0x5731, 0x4F2E, 0, 0xBC5D, 0x7433,
- 0xAC2D, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0xAC2E, 0x3C30,
- 0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
- 0x3930, 0xBC61, 0, 0x4350, 0xAC2F, 0x7434, 0xAC31, 0x446F,
- 0, 0, 0xBC65, 0x7435, 0xBC67, 0x4C6F, 0x3839, 0x384C,
- 0xBC68, 0x5738, 0, 0xBC69, 0xBC6A, 0x5739, 0xBC6B, 0x573F,
- 0xBC6C, 0x3C65, 0, 0, 0x7436, 0x4425, 0x7437, 0x362F,
- 0x573A, 0, 0, 0xBC6F, 0x492B, 0x7438, 0x4346, 0xBC71,
-};
-static const unsigned short utf8_to_euc_E5BD[] = {
- 0xBC72, 0x573B, 0, 0, 0xBC73, 0xBC74, 0, 0xBC75,
- 0x573C, 0, 0x3630, 0, 0x573D, 0xBC76, 0x573E, 0,
- 0xBC77, 0x5740, 0, 0x4576, 0xBC78, 0, 0x5741, 0x5742,
- 0xBC79, 0x5743, 0, 0xBC7A, 0x5734, 0x5733, 0, 0,
- 0xBC7B, 0x5744, 0x3741, 0xBC7C, 0xBC7D, 0, 0x4927, 0xBC7E,
- 0, 0x3A4C, 0x4937, 0x4426, 0x494B, 0x5745, 0, 0xBD21,
- 0x3E34, 0x3146, 0xBD22, 0x5746, 0xBD23, 0xBD24, 0, 0x5747,
- 0xBD25, 0x4C72, 0xBD26, 0, 0x4860, 0xBD27, 0xBD28, 0x574A,
-};
-static const unsigned short utf8_to_euc_E5BD_x0213[] = {
- 0x7439, 0x573B, 0, 0, 0xBC73, 0x743A, 0, 0xAC32,
- 0x573C, 0, 0x3630, 0, 0x573D, 0xBC76, 0x573E, 0,
- 0xBC77, 0x5740, 0, 0x4576, 0x743B, 0, 0x5741, 0x5742,
- 0x743C, 0x5743, 0, 0xBC7A, 0x5734, 0x5733, 0, 0,
- 0xBC7B, 0x5744, 0x3741, 0xAC33, 0x743D, 0, 0x4927, 0x743E,
- 0, 0x3A4C, 0x4937, 0x4426, 0x494B, 0x5745, 0, 0xBD21,
- 0x3E34, 0x3146, 0xAC34, 0x5746, 0xBD23, 0xBD24, 0, 0x5747,
- 0xBD25, 0x4C72, 0xBD26, 0, 0x4860, 0x743F, 0xAC35, 0x574A,
-};
-static const unsigned short utf8_to_euc_E5BE[] = {
- 0x317D, 0x402C, 0x5749, 0x5748, 0x3742, 0x4254, 0, 0x574E,
- 0x574C, 0xBD29, 0x574B, 0x4E27, 0x3865, 0xBD2A, 0, 0xBD2B,
- 0x3D79, 0x574D, 0x454C, 0x3D3E, 0, 0, 0xBD2C, 0x4640,
- 0x5751, 0x5750, 0, 0, 0xBD2D, 0xBD2E, 0x574F, 0,
- 0x5752, 0x3866, 0xBD2F, 0, 0xBD32, 0, 0, 0xBD30,
- 0x5753, 0x497C, 0x3D5B, 0xBD31, 0xBD33, 0x5754, 0x4879, 0xBD34,
- 0xBD35, 0xBD36, 0, 0x4641, 0x4427, 0, 0, 0xF43E,
- 0xBD37, 0x4530, 0, 0, 0x5755, 0x352B, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5BE_x0213[] = {
- 0x317D, 0x402C, 0x5749, 0x5748, 0x3742, 0x4254, 0, 0x574E,
- 0x574C, 0x7440, 0x574B, 0x4E27, 0x3865, 0xBD2A, 0, 0xAC36,
- 0x3D79, 0x574D, 0x454C, 0x3D3E, 0, 0, 0xBD2C, 0x4640,
- 0x5751, 0x5750, 0, 0, 0x7441, 0xBD2E, 0x574F, 0,
- 0x5752, 0x3866, 0xAC37, 0, 0xAC38, 0, 0, 0x7442,
- 0x5753, 0x497C, 0x3D5B, 0xBD31, 0xBD33, 0x5754, 0x4879, 0x7443,
- 0xBD35, 0xBD36, 0, 0x4641, 0x4427, 0x7444, 0, 0x7445,
- 0xAC39, 0x4530, 0, 0, 0x5755, 0x352B, 0, 0,
-};
-static const unsigned short utf8_to_euc_E5BF[] = {
- 0, 0, 0, 0x3F34, 0xBD38, 0x492C, 0, 0xBD39,
- 0xBD3A, 0xBD3B, 0, 0xBD3C, 0x3477, 0x4726, 0, 0,
- 0xBD3D, 0xBD3E, 0xBD3F, 0xBD40, 0xBD41, 0, 0x5756, 0x3B56,
- 0x4B3A, 0x4B3B, 0, 0, 0x317E, 0x575B, 0xBD42, 0,
- 0x4369, 0xBD43, 0xBD44, 0, 0x5758, 0, 0, 0,
- 0xBD45, 0xBD46, 0xBD47, 0x3277, 0xBD48, 0xBD49, 0xBD4A, 0xBD4B,
- 0x582D, 0x575A, 0xBD4C, 0xBD4D, 0, 0x4730, 0xBD4E, 0,
- 0x5759, 0, 0xBD4F, 0x5757, 0xBD50, 0x397A, 0, 0x575D,
-};
-static const unsigned short utf8_to_euc_E5BF_x0213[] = {
- 0, 0, 0, 0x3F34, 0xAC3A, 0x492C, 0, 0xAC3C,
- 0xBD3A, 0x7446, 0, 0xAC3D, 0x3477, 0x4726, 0, 0,
- 0xBD3D, 0xBD3E, 0xAC3E, 0xAC3F, 0xAC40, 0, 0x5756, 0x3B56,
- 0x4B3A, 0x4B3B, 0, 0, 0x317E, 0x575B, 0x7447, 0,
- 0x4369, 0x7448, 0xAC41, 0, 0x5758, 0, 0, 0,
- 0xBD45, 0x7449, 0xBD47, 0x3277, 0xBD48, 0xBD49, 0xAC42, 0xAC43,
- 0x582D, 0x575A, 0xBD4C, 0xAC44, 0, 0x4730, 0xBD4E, 0,
- 0x5759, 0, 0xBD4F, 0x5757, 0xAC45, 0x397A, 0, 0x575D,
-};
-static const unsigned short utf8_to_euc_E680[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xBD51,
- 0, 0, 0xBD52, 0, 0, 0xBD53, 0x5763, 0x5769,
- 0x5761, 0, 0x455C, 0xBD54, 0xBD55, 0x5766, 0x495D, 0xBD56,
- 0xBD57, 0x5760, 0xBD58, 0x5765, 0x4E67, 0x3B57, 0, 0xBD59,
- 0x4255, 0x575E, 0, 0, 0xBD5A, 0x355E, 0x5768, 0x402D,
- 0x3165, 0x5762, 0x3278, 0x5767, 0, 0xBD5B, 0, 0x3631,
- 0, 0x5764, 0, 0xBD5C, 0, 0xBD5D, 0, 0,
- 0, 0, 0x576A, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E680_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xBD51,
- 0, 0, 0xBD52, 0, 0, 0x744A, 0x5763, 0x5769,
- 0x5761, 0, 0x455C, 0xBD54, 0x744B, 0x5766, 0x495D, 0xAC47,
- 0x744C, 0x5760, 0xBD58, 0x5765, 0x4E67, 0x3B57, 0, 0xBD59,
- 0x4255, 0x575E, 0xAC48, 0, 0xAC49, 0x355E, 0x5768, 0x402D,
- 0x3165, 0x5762, 0x3278, 0x5767, 0, 0xBD5B, 0, 0x3631,
- 0, 0x5764, 0, 0x744D, 0, 0x744E, 0, 0,
- 0, 0, 0x576A, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E681[] = {
- 0xBD5E, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0xBD5F,
- 0xBD60, 0xBD61, 0x5770, 0x4E78, 0xBD62, 0x5772, 0, 0,
- 0x3632, 0xBD63, 0x3931, 0, 0xBD64, 0x3D7A, 0xBD65, 0xBD66,
- 0, 0x5779, 0x576B, 0, 0, 0xBD67, 0, 0x576F,
- 0x575F, 0xBD68, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0xBD69,
- 0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
- 0x3366, 0xBD6A, 0, 0, 0, 0x3743, 0, 0x576E,
- 0, 0, 0, 0, 0, 0, 0xBD6B, 0xBD6C,
-};
-static const unsigned short utf8_to_euc_E681_x0213[] = {
- 0xBD5E, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0x744F,
- 0xBD60, 0xBD61, 0x5770, 0x4E78, 0xAC4B, 0x5772, 0, 0,
- 0x3632, 0xBD63, 0x3931, 0, 0xBD64, 0x3D7A, 0xBD65, 0xBD66,
- 0, 0x5779, 0x576B, 0, 0, 0, 0, 0x576F,
- 0x575F, 0xBD68, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0xBD69,
- 0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
- 0x3366, 0xBD6A, 0, 0, 0, 0x3743, 0, 0x576E,
- 0, 0, 0, 0, 0, 0, 0xBD6B, 0xAC4C,
-};
-static const unsigned short utf8_to_euc_E682[] = {
- 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0xF43F, 0xBD6E, 0,
- 0xBD6F, 0x3C3D, 0xBD70, 0x5827, 0x4470, 0x577B, 0xBD71, 0,
- 0, 0xBD72, 0x5825, 0xBD73, 0x3279, 0xBD74, 0x5823, 0x5824,
- 0xBD75, 0, 0x577E, 0x5822, 0, 0xBD76, 0xBD77, 0x3867,
- 0x4D2A, 0, 0xBD78, 0x3435, 0xBD79, 0xBD7A, 0x3159, 0x5826,
- 0xBD7B, 0x473A, 0x302D, 0, 0, 0, 0, 0,
- 0xBD7C, 0xBD7D, 0x4861, 0x575C, 0x582C, 0x5830, 0x4C65, 0xBD7E,
- 0x5829, 0, 0, 0xBE21, 0x4569, 0x582E, 0xBE22, 0,
-};
-static const unsigned short utf8_to_euc_E682_x0213[] = {
- 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0, 0xBD6E, 0,
- 0xBD6F, 0x3C3D, 0xAC4D, 0x5827, 0x4470, 0x577B, 0xBD71, 0,
- 0, 0xBD72, 0x5825, 0xBD73, 0x3279, 0xAC4E, 0x5823, 0x5824,
- 0xBD75, 0, 0x577E, 0x5822, 0, 0x7451, 0x7452, 0x3867,
- 0x4D2A, 0, 0xBD78, 0x3435, 0xBD79, 0xBD7A, 0x3159, 0x5826,
- 0xAC4F, 0x473A, 0x302D, 0, 0, 0, 0, 0,
- 0xAC51, 0xAC52, 0x4861, 0x575C, 0x582C, 0x5830, 0x4C65, 0xBD7E,
- 0x5829, 0, 0, 0xBE21, 0x4569, 0x582E, 0xAC53, 0,
-};
-static const unsigned short utf8_to_euc_E683[] = {
- 0, 0, 0xBE23, 0, 0xBE24, 0x3E70, 0x582F, 0x4657,
- 0xBE25, 0xBE26, 0xBE27, 0xBE28, 0, 0, 0xBE29, 0xBE2A,
- 0, 0x4F47, 0, 0x582B, 0xBE2B, 0xBE2C, 0, 0,
- 0x5831, 0xBE2D, 0x397B, 0xBE2E, 0x404B, 0xBE2F, 0xBE30, 0x3054,
- 0x582A, 0x5828, 0xBE31, 0x415A, 0, 0xBE32, 0, 0x577C,
- 0x3B34, 0, 0, 0, 0, 0, 0, 0,
- 0x4246, 0x583D, 0xBE33, 0x415B, 0x5838, 0xBE34, 0x5835, 0x5836,
- 0xBE35, 0x3C66, 0x5839, 0x583C, 0xBE36, 0xBE37, 0, 0,
-};
-static const unsigned short utf8_to_euc_E683_x0213[] = {
- 0, 0, 0xBE23, 0, 0xBE24, 0x3E70, 0x582F, 0x4657,
- 0xAC54, 0xBE26, 0xBE27, 0x7453, 0, 0, 0xBE29, 0xBE2A,
- 0, 0x4F47, 0, 0x582B, 0x7454, 0x7455, 0, 0,
- 0x5831, 0xAC55, 0x397B, 0xAC56, 0x404B, 0x7456, 0, 0x3054,
- 0x582A, 0x5828, 0xBE31, 0x415A, 0, 0xBE32, 0, 0x577C,
- 0x3B34, 0, 0, 0, 0, 0, 0xAC57, 0,
- 0x4246, 0x583D, 0xAC58, 0x415B, 0x5838, 0xAC59, 0x5835, 0x5836,
- 0x7457, 0x3C66, 0x5839, 0x583C, 0xBE36, 0xBE37, 0, 0,
-};
-static const unsigned short utf8_to_euc_E684[] = {
- 0x5837, 0x3D25, 0xBE38, 0x583A, 0, 0, 0x5834, 0xBE39,
- 0x4C7C, 0x4C7B, 0xBE3A, 0, 0xBE3B, 0x583E, 0x583F, 0x3055,
- 0xBE3C, 0xBE3D, 0xBE3E, 0xBE3F, 0xBE40, 0x5833, 0xBE41, 0xBE42,
- 0, 0xBE43, 0x3672, 0x3026, 0xBE44, 0, 0xBE45, 0x3436,
- 0xF440, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
- 0x5842, 0, 0xBE47, 0xBE48, 0x5847, 0, 0, 0,
- 0xBE49, 0xBE4A, 0, 0, 0x5848, 0xBE4B, 0xBE4C, 0xBE4D,
- 0, 0xBE4E, 0, 0, 0x5846, 0x5849, 0x5841, 0x5845,
-};
-static const unsigned short utf8_to_euc_E684_x0213[] = {
- 0x5837, 0x3D25, 0xBE38, 0x583A, 0, 0, 0x5834, 0xBE39,
- 0x4C7C, 0x4C7B, 0xBE3A, 0, 0xBE3B, 0x583E, 0x583F, 0x3055,
- 0xAC5A, 0, 0xAC5B, 0xAC5C, 0xBE40, 0x5833, 0xBE41, 0xBE42,
- 0, 0xAC5D, 0x3672, 0x3026, 0x7458, 0, 0xAC5E, 0x3436,
- 0, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
- 0x5842, 0, 0xBE47, 0x7459, 0x5847, 0, 0, 0,
- 0x745A, 0xBE4A, 0, 0, 0x5848, 0xBE4B, 0xBE4C, 0x745B,
- 0, 0xBE4E, 0xAC5F, 0, 0x5846, 0x5849, 0x5841, 0x5845,
-};
-static const unsigned short utf8_to_euc_E685[] = {
- 0, 0xBE4F, 0x584A, 0, 0x584B, 0xBE50, 0xBE51, 0x5840,
- 0x3B7C, 0xBE52, 0x5844, 0x4256, 0x3932, 0x5832, 0x3F35, 0,
- 0, 0, 0, 0x5858, 0, 0x4A69, 0, 0,
- 0x584E, 0x584F, 0x5850, 0, 0, 0x5857, 0xBE53, 0x5856,
- 0xBE54, 0, 0x4B7D, 0x3437, 0, 0x5854, 0, 0x3745,
- 0x3334, 0, 0, 0x5851, 0xBE55, 0, 0x4E38, 0x5853,
- 0x3056, 0x5855, 0xBE56, 0x584C, 0x5852, 0x5859, 0x3744, 0x584D,
- 0xBE57, 0, 0, 0xBE58, 0xBE59, 0, 0x4D5D, 0xBE5A,
-};
-static const unsigned short utf8_to_euc_E685_x0213[] = {
- 0, 0xAC61, 0x584A, 0, 0x584B, 0xBE50, 0xAC62, 0x5840,
- 0x3B7C, 0xBE52, 0x5844, 0x4256, 0x3932, 0x5832, 0x3F35, 0,
- 0, 0, 0, 0x5858, 0, 0x4A69, 0, 0,
- 0x584E, 0x584F, 0x5850, 0, 0, 0x5857, 0xBE53, 0x5856,
- 0xAC63, 0, 0x4B7D, 0x3437, 0, 0x5854, 0, 0x3745,
- 0x3334, 0, 0, 0x5851, 0xBE55, 0, 0x4E38, 0x5853,
- 0x3056, 0x5855, 0xBE56, 0x584C, 0x5852, 0x5859, 0x3744, 0x584D,
- 0xBE57, 0, 0, 0xBE58, 0xAC64, 0, 0x4D5D, 0xBE5A,
-};
-static const unsigned short utf8_to_euc_E686[] = {
- 0xBE5B, 0xBE5C, 0x4D2B, 0xBE5D, 0xBE5E, 0, 0, 0x585C,
- 0, 0, 0x5860, 0xBE5F, 0, 0xBE60, 0x417E, 0,
- 0x4E79, 0x5861, 0xBE61, 0xBE62, 0x585E, 0, 0x585B, 0xBE63,
- 0xBE64, 0x585A, 0x585F, 0, 0xBE65, 0xBE66, 0, 0xBE67,
- 0xBE68, 0, 0, 0, 0x4A30, 0xBE69, 0, 0x4634,
- 0xBE6A, 0x3746, 0xBE6B, 0x5862, 0x585D, 0xBE6C, 0x5863, 0,
- 0, 0, 0x377B, 0, 0, 0, 0x3231, 0,
- 0xBE6D, 0xBE6E, 0x586B, 0, 0xBE6F, 0, 0x3438, 0,
-};
-static const unsigned short utf8_to_euc_E686_x0213[] = {
- 0xBE5B, 0xBE5C, 0x4D2B, 0xBE5D, 0xBE5E, 0, 0, 0x585C,
- 0, 0, 0x5860, 0xBE5F, 0, 0x745D, 0x417E, 0,
- 0x4E79, 0x5861, 0xAC66, 0xAC67, 0x585E, 0, 0x585B, 0xAC68,
- 0xAC69, 0x585A, 0x585F, 0, 0xBE65, 0xBE66, 0, 0xBE67,
- 0xBE68, 0, 0, 0, 0x4A30, 0xAC6A, 0, 0x4634,
- 0xAC6B, 0x3746, 0xBE6B, 0x5862, 0x585D, 0xAC6C, 0x5863, 0,
- 0, 0, 0x377B, 0, 0, 0, 0x3231, 0,
- 0xBE6D, 0x7460, 0x586B, 0, 0x745F, 0, 0x3438, 0,
-};
-static const unsigned short utf8_to_euc_E687[] = {
- 0xBE70, 0xBE71, 0xBE72, 0x5869, 0, 0, 0x586A, 0x3A29,
- 0x5868, 0x5866, 0x5865, 0x586C, 0x5864, 0x586E, 0xBE73, 0xBE74,
- 0x327B, 0, 0, 0, 0, 0xBE75, 0, 0,
- 0, 0, 0, 0, 0xBE76, 0xBE77, 0xBE78, 0xBE79,
- 0, 0xBE7A, 0xBE7B, 0x5870, 0, 0xBE7E, 0x586F, 0xBE7C,
- 0, 0xBE7D, 0, 0, 0xBF21, 0xBF22, 0, 0xBF23,
- 0, 0, 0x4428, 0, 0x5873, 0, 0x5871, 0x5867,
- 0x377C, 0, 0x5872, 0, 0x5876, 0x5875, 0x5877, 0x5874,
-};
-static const unsigned short utf8_to_euc_E687_x0213[] = {
- 0xBE70, 0xBE71, 0xBE72, 0x5869, 0, 0, 0x586A, 0x3A29,
- 0x5868, 0x5866, 0x5865, 0x586C, 0x5864, 0x586E, 0xBE73, 0xBE74,
- 0x327B, 0, 0, 0, 0, 0xAC6E, 0, 0,
- 0, 0, 0, 0, 0xBE76, 0xAC6F, 0xBE78, 0xAC70,
- 0, 0xBE7A, 0xBE7B, 0x5870, 0, 0xBE7E, 0x586F, 0xBE7C,
- 0, 0xBE7D, 0, 0, 0xBF21, 0xBF22, 0, 0xBF23,
- 0, 0, 0x4428, 0, 0x5873, 0xAC71, 0x5871, 0x5867,
- 0x377C, 0, 0x5872, 0, 0x5876, 0x5875, 0x5877, 0x5874,
-};
-static const unsigned short utf8_to_euc_E688[] = {
- 0x5878, 0xBF24, 0, 0xBF25, 0xBF26, 0, 0, 0xBF27,
- 0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
- 0x402E, 0x3266, 0x327C, 0xBF28, 0x587D, 0xBF29, 0x303F, 0,
- 0, 0, 0x404C, 0x587E, 0xBF2A, 0x6C43, 0x5921, 0x3761,
- 0xBF2B, 0x5922, 0xBF2C, 0xBF2D, 0, 0, 0x406F, 0xBF2E,
- 0, 0xBF2F, 0x5923, 0xBF30, 0, 0, 0x5924, 0x353A,
- 0x5925, 0, 0x5926, 0x5927, 0x4257, 0, 0, 0,
- 0x384D, 0xBF31, 0, 0x4C61, 0, 0xBF32, 0, 0x4B3C,
-};
-static const unsigned short utf8_to_euc_E688_x0213[] = {
- 0x5878, 0xBF24, 0, 0xBF25, 0xBF26, 0, 0, 0xBF27,
- 0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
- 0x402E, 0x3266, 0x327C, 0, 0x587D, 0xAC73, 0x303F, 0,
- 0, 0, 0x404C, 0x587E, 0xBF2A, 0x6C43, 0x5921, 0x3761,
- 0xBF2B, 0x5922, 0x7462, 0xAC74, 0, 0, 0x406F, 0xBF2E,
- 0, 0xAC75, 0x5923, 0xBF30, 0, 0, 0x5924, 0x353A,
- 0x5925, 0, 0x5926, 0x5927, 0x4257, 0, 0, 0,
- 0x384D, 0xBF31, 0, 0x4C61, 0, 0xBF32, 0x7463, 0x4B3C,
-};
-static const unsigned short utf8_to_euc_E689[] = {
- 0x3D6A, 0x5928, 0xBF33, 0xBF34, 0xBF35, 0, 0xBF36, 0x4070,
- 0x6E3D, 0x4862, 0, 0x3C6A, 0xBF37, 0x3A4D, 0x5929, 0,
- 0xBF38, 0xBF39, 0xBF3A, 0x4247, 0xBF3B, 0x4A27, 0xBF3C, 0,
- 0x4271, 0, 0xBF3D, 0x592C, 0xBF3E, 0, 0x592A, 0,
- 0x592D, 0, 0, 0x592B, 0xBF3F, 0, 0, 0,
- 0x592E, 0, 0, 0, 0, 0xBF40, 0x4A31, 0xBF41,
- 0, 0x3037, 0, 0xBF42, 0, 0, 0x495E, 0,
- 0, 0x4863, 0xBF43, 0, 0x592F, 0xBF44, 0x5932, 0x3E35,
-};
-static const unsigned short utf8_to_euc_E689_x0213[] = {
- 0x3D6A, 0x5928, 0xBF33, 0x7464, 0xBF35, 0, 0xAC76, 0x4070,
- 0x6E3D, 0x4862, 0, 0x3C6A, 0xAC77, 0x3A4D, 0x5929, 0,
- 0xBF38, 0xAC78, 0xAC79, 0x4247, 0xBF3B, 0x4A27, 0x7465, 0,
- 0x4271, 0, 0x7466, 0x592C, 0xBF3E, 0, 0x592A, 0,
- 0x592D, 0xAC7A, 0, 0x592B, 0xAC7B, 0, 0, 0,
- 0x592E, 0, 0, 0, 0, 0xAC7D, 0x4A31, 0x7467,
- 0, 0x3037, 0, 0xAC7E, 0, 0, 0x495E, 0,
- 0, 0x4863, 0xBF43, 0xAC7C, 0x592F, 0xBF44, 0x5932, 0x3E35,
-};
-static const unsigned short utf8_to_euc_E68A[] = {
- 0x353B, 0, 0x5930, 0x5937, 0x3E36, 0, 0, 0,
- 0, 0x5931, 0x4744, 0, 0, 0xBF45, 0xBF46, 0xBF47,
- 0xBF48, 0x4D5E, 0x5933, 0x5934, 0x5938, 0x456A, 0x5935, 0x3933,
- 0x405E, 0, 0, 0x5946, 0x4834, 0, 0x4272, 0,
- 0, 0, 0, 0, 0, 0, 0xBF49, 0,
- 0xBF4A, 0, 0, 0x4864, 0x5A2D, 0, 0, 0,
- 0, 0x4A7A, 0, 0xBF4B, 0, 0x4471, 0xBF4C, 0xBF4D,
- 0, 0x4B75, 0xBF4E, 0x593B, 0x3221, 0x436A, 0xBF4F, 0xBF50,
-};
-static const unsigned short utf8_to_euc_E68A_x0213[] = {
- 0x353B, 0, 0x5930, 0x5937, 0x3E36, 0x7468, 0, 0,
- 0, 0x5931, 0x4744, 0, 0, 0xBF45, 0xBF46, 0xBF47,
- 0xBF48, 0x4D5E, 0x5933, 0x5934, 0x5938, 0x456A, 0x5935, 0x3933,
- 0x405E, 0xAD21, 0, 0x5946, 0x4834, 0, 0x4272, 0,
- 0, 0, 0, 0, 0, 0, 0xAD22, 0,
- 0xBF4A, 0, 0, 0x4864, 0x5A2D, 0, 0, 0,
- 0, 0x4A7A, 0, 0xBF4B, 0, 0x4471, 0xBF4C, 0xBF4D,
- 0, 0x4B75, 0xBF4E, 0x593B, 0x3221, 0x436A, 0xBF4F, 0xBF50,
-};
-static const unsigned short utf8_to_euc_E68B[] = {
- 0, 0, 0x5944, 0, 0xBF51, 0x4334, 0x593E, 0x5945,
- 0x5940, 0x5947, 0x5943, 0, 0x5942, 0x476F, 0xBF52, 0x593C,
- 0x327D, 0x593A, 0x3571, 0x4273, 0x5936, 0xBF53, 0xBF54, 0x5939,
- 0x3934, 0x405B, 0xBF55, 0x3E37, 0x5941, 0x4752, 0, 0,
- 0x3572, 0x3348, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xBF56, 0, 0x3367, 0x3F21, 0x5949, 0x594E,
- 0, 0x594A, 0xBF57, 0x377D, 0xBF58, 0x594F, 0x3B22, 0x3969,
- 0, 0, 0, 0, 0xBF59, 0xBF5A, 0x3D26, 0x593D,
-};
-static const unsigned short utf8_to_euc_E68B_x0213[] = {
- 0, 0, 0x5944, 0, 0x7469, 0x4334, 0x593E, 0x5945,
- 0x5940, 0x5947, 0x5943, 0, 0x5942, 0x476F, 0xBF52, 0x593C,
- 0x327D, 0x593A, 0x3571, 0x4273, 0x5936, 0xAD23, 0x746A, 0x5939,
- 0x3934, 0x405B, 0xBF55, 0x3E37, 0x5941, 0x4752, 0, 0,
- 0x3572, 0x3348, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xBF56, 0, 0x3367, 0x3F21, 0x5949, 0x594E,
- 0, 0x594A, 0xBF57, 0x377D, 0xBF58, 0x594F, 0x3B22, 0x3969,
- 0, 0, 0, 0, 0x746B, 0xAD25, 0x3D26, 0x593D,
-};
-static const unsigned short utf8_to_euc_E68C[] = {
- 0, 0x3B7D, 0x594C, 0xBF5B, 0xBF5C, 0, 0, 0x3B58,
- 0x594D, 0x3044, 0xBF5D, 0xBF5E, 0x5948, 0xBF5F, 0, 0,
- 0xBF60, 0x4429, 0, 0xBF61, 0, 0, 0xBF62, 0,
- 0xBF63, 0x3573, 0, 0, 0, 0, 0, 0x3634,
- 0, 0, 0, 0, 0, 0, 0, 0x594B,
- 0x3027, 0xBF64, 0xBF65, 0x3A43, 0, 0xBF66, 0, 0x3F36,
- 0, 0, 0, 0, 0, 0xBF67, 0xBF68, 0,
- 0, 0xBF69, 0x4472, 0, 0xBF6A, 0x4854, 0x5951, 0x415E,
-};
-static const unsigned short utf8_to_euc_E68C_x0213[] = {
- 0, 0x3B7D, 0x594C, 0xAD26, 0xBF5C, 0, 0, 0x3B58,
- 0x594D, 0x3044, 0x746C, 0xBF5E, 0x5948, 0xAD27, 0, 0,
- 0xAD28, 0x4429, 0, 0xBF61, 0, 0, 0xBF62, 0,
- 0x746D, 0x3573, 0, 0, 0, 0, 0, 0x3634,
- 0, 0, 0, 0, 0, 0, 0, 0x594B,
- 0x3027, 0xBF64, 0xBF65, 0x3A43, 0, 0xBF66, 0, 0x3F36,
- 0, 0, 0xAD2B, 0, 0, 0xAD2C, 0xBF68, 0,
- 0, 0x746E, 0x4472, 0xAD2D, 0xAD2E, 0x4854, 0x5951, 0x415E,
-};
-static const unsigned short utf8_to_euc_E68D[] = {
- 0, 0xBF6B, 0xBF6C, 0xBF6D, 0xBF6E, 0, 0xBF6F, 0,
- 0, 0x422A, 0xBF70, 0xBF71, 0x3B2B, 0x5952, 0xBF72, 0x5954,
- 0x5950, 0, 0xBF73, 0xBF74, 0xBF75, 0x4A61, 0, 0x443D,
- 0xBF76, 0, 0, 0xBF77, 0x415C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xBF78, 0xBF79, 0x4A7B,
- 0x3C4E, 0x5960, 0, 0x595F, 0xBF7A, 0xBF7B, 0x3F78, 0,
- 0, 0xBF7C, 0x377E, 0, 0xBF7D, 0xBF7E, 0x5959, 0x3E39,
- 0xC021, 0, 0x4668, 0x4731, 0xC022, 0xC023, 0, 0xC024,
-};
-static const unsigned short utf8_to_euc_E68D_x0213[] = {
- 0, 0xAD2F, 0xBF6C, 0x746F, 0xAD30, 0, 0xBF6F, 0,
- 0, 0x422A, 0xBF70, 0xBF71, 0x3B2B, 0x5952, 0xAD31, 0x5954,
- 0x5950, 0, 0xBF73, 0xBF74, 0xBF75, 0x4A61, 0, 0x443D,
- 0xBF76, 0xAD33, 0, 0xBF77, 0x415C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x7470, 0xBF79, 0x4A7B,
- 0x3C4E, 0x5960, 0, 0x595F, 0xAD36, 0xBF7B, 0x3F78, 0,
- 0, 0xBF7C, 0x377E, 0, 0xBF7D, 0xBF7E, 0x5959, 0x3E39,
- 0xC021, 0, 0x4668, 0x4731, 0x7471, 0xC023, 0, 0xC024,
-};
-static const unsigned short utf8_to_euc_E68E[] = {
- 0x5957, 0, 0xC025, 0x415D, 0xC026, 0, 0, 0xC027,
- 0x3C78, 0x595C, 0xC028, 0, 0x3E38, 0, 0x5956, 0x595B,
- 0xC029, 0, 0x4753, 0, 0xC02A, 0xC02B, 0x5955, 0,
- 0x3721, 0xC02C, 0xC02D, 0x335D, 0, 0, 0xC02E, 0x595D,
- 0x4E2B, 0x3A4E, 0x4335, 0x595A, 0xC02F, 0x405C, 0xC030, 0x3935,
- 0x3F64, 0x3166, 0x413C, 0x5958, 0x3545, 0xC031, 0xC032, 0xC033,
- 0, 0, 0x3747, 0, 0x444F, 0x595E, 0, 0,
- 0, 0, 0, 0x415F, 0, 0xC034, 0x5961, 0,
-};
-static const unsigned short utf8_to_euc_E68E_x0213[] = {
- 0x5957, 0, 0xC025, 0x415D, 0xAD37, 0, 0, 0xC027,
- 0x3C78, 0x595C, 0xC028, 0, 0x3E38, 0, 0x5956, 0x595B,
- 0xC029, 0, 0x4753, 0, 0xAD3A, 0xC02B, 0x5955, 0,
- 0x3721, 0xAD38, 0xC02D, 0x335D, 0, 0, 0xC02E, 0x595D,
- 0x4E2B, 0x3A4E, 0x4335, 0x595A, 0xC02F, 0x405C, 0xC030, 0x3935,
- 0x3F64, 0x3166, 0x413C, 0x5958, 0x3545, 0xC031, 0xC032, 0xC033,
- 0, 0, 0x3747, 0, 0x444F, 0x595E, 0, 0,
- 0, 0, 0, 0x415F, 0, 0xAD3B, 0x5961, 0,
-};
-static const unsigned short utf8_to_euc_E68F[] = {
- 0x5963, 0xC035, 0, 0x4237, 0x5969, 0xC036, 0x5964, 0,
- 0xC037, 0x5966, 0, 0, 0, 0, 0xC038, 0x4941,
- 0x4473, 0xC039, 0x5967, 0xC03A, 0xC03B, 0xC03C, 0x4D2C, 0,
- 0, 0, 0x4D48, 0x3439, 0xC03D, 0, 0, 0,
- 0xC03E, 0x302E, 0, 0x5965, 0, 0xC03F, 0, 0,
- 0, 0x5962, 0xC040, 0, 0xC041, 0, 0x3478, 0,
- 0, 0, 0xC042, 0xC043, 0x3167, 0xC044, 0x5968, 0,
- 0xC045, 0xC046, 0x4D49, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E68F_x0213[] = {
- 0x5963, 0xC035, 0, 0x4237, 0x5969, 0xC036, 0x5964, 0,
- 0xC037, 0x5966, 0, 0, 0, 0, 0xC038, 0x4941,
- 0x4473, 0xC039, 0x5967, 0xC03A, 0xAD3D, 0xAD3E, 0x4D2C, 0,
- 0, 0, 0x4D48, 0x3439, 0xAD3F, 0, 0, 0,
- 0xAD40, 0x302E, 0, 0x5965, 0, 0x7472, 0, 0,
- 0, 0x5962, 0xC040, 0xAD41, 0xAD42, 0x7473, 0x3478, 0,
- 0, 0, 0xAD43, 0xC043, 0x3167, 0x7474, 0x5968, 0xAD3C,
- 0xC045, 0xC046, 0x4D49, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E690[] = {
- 0, 0, 0, 0, 0, 0, 0x596C, 0,
- 0, 0xC047, 0xC048, 0, 0, 0x423B, 0, 0x5973,
- 0xC049, 0, 0xC04A, 0x596D, 0xC04B, 0, 0x596A, 0x5971,
- 0xC04C, 0, 0, 0, 0x5953, 0, 0xC04D, 0,
- 0xC04E, 0, 0xC04F, 0, 0xC050, 0xC051, 0x596E, 0,
- 0x5972, 0xC052, 0xC053, 0, 0x4842, 0x456B, 0, 0xC054,
- 0xC055, 0, 0, 0, 0x596B, 0xC056, 0x596F, 0,
- 0, 0, 0x3748, 0, 0, 0xC057, 0x3A71, 0xC058,
-};
-static const unsigned short utf8_to_euc_E690_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0x596C, 0,
- 0, 0xAD44, 0xC048, 0, 0, 0x423B, 0, 0x5973,
- 0x7475, 0, 0xC04A, 0x596D, 0x7476, 0, 0x596A, 0x5971,
- 0xC04C, 0, 0, 0, 0x5953, 0, 0xAD45, 0,
- 0xC04E, 0, 0x7477, 0, 0xC050, 0xAD46, 0x596E, 0,
- 0x5972, 0xAD47, 0xC053, 0, 0x4842, 0x456B, 0, 0xAD48,
- 0xC055, 0, 0, 0, 0x596B, 0xC056, 0x596F, 0,
- 0, 0, 0x3748, 0, 0, 0xC057, 0x3A71, 0xC058,
-};
-static const unsigned short utf8_to_euc_E691[] = {
- 0, 0, 0x405D, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xC059, 0, 0, 0x5977, 0xC05A,
- 0, 0xC05B, 0xC05C, 0xC05D, 0xC05E, 0, 0, 0,
- 0x4526, 0, 0xC05F, 0xC060, 0xC061, 0xC062, 0, 0xC063,
- 0xC064, 0xC065, 0, 0xC066, 0, 0, 0, 0x5974,
- 0, 0x4B60, 0, 0, 0, 0xC067, 0, 0x5975,
- 0, 0, 0, 0xC068, 0xC069, 0, 0x5976, 0,
- 0x4C4E, 0, 0x4022, 0xC06A, 0, 0xC06B, 0, 0,
-};
-static const unsigned short utf8_to_euc_E691_x0213[] = {
- 0, 0, 0x405D, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xC059, 0, 0, 0x5977, 0xC05A,
- 0, 0x7479, 0xC05C, 0xC05D, 0xC05E, 0, 0, 0,
- 0x4526, 0, 0xAD49, 0xAD4A, 0xC061, 0xAD4B, 0, 0xC063,
- 0x747A, 0xC065, 0, 0xC066, 0, 0, 0, 0x5974,
- 0, 0x4B60, 0, 0, 0, 0x747B, 0, 0x5975,
- 0, 0, 0, 0xAD4C, 0xC069, 0, 0x5976, 0,
- 0x4C4E, 0x7478, 0x4022, 0xC06A, 0, 0xAD4D, 0, 0,
-};
-static const unsigned short utf8_to_euc_E692[] = {
- 0, 0, 0, 0x3762, 0, 0xC06C, 0, 0xC06D,
- 0x597D, 0, 0, 0, 0, 0, 0, 0xC06E,
- 0xC06F, 0xC070, 0x3B35, 0x597A, 0, 0x5979, 0, 0,
- 0xC071, 0xC072, 0x4732, 0xC073, 0, 0xC074, 0x4635, 0xC075,
- 0, 0xC076, 0, 0xC077, 0x4531, 0x597B, 0xC078, 0,
- 0xC079, 0x597C, 0, 0x496F, 0xC07A, 0x4745, 0x3B23, 0,
- 0x4071, 0, 0x4B50, 0xC07B, 0, 0, 0, 0,
- 0, 0x3349, 0, 0x5A25, 0x597E, 0xC07C, 0xC07D, 0xC07E,
-};
-static const unsigned short utf8_to_euc_E692_x0213[] = {
- 0, 0, 0, 0x3762, 0, 0xC06C, 0, 0xAD4E,
- 0x597D, 0, 0, 0, 0, 0, 0, 0xC06E,
- 0xC06F, 0xAD4F, 0x3B35, 0x597A, 0, 0x5979, 0, 0,
- 0xC071, 0xC072, 0x4732, 0xC073, 0, 0xAD50, 0x4635, 0xAD51,
- 0, 0xC076, 0, 0xC077, 0x4531, 0x597B, 0xC078, 0,
- 0xC079, 0x597C, 0, 0x496F, 0xC07A, 0x4745, 0x3B23, 0,
- 0x4071, 0, 0x4B50, 0xC07B, 0, 0, 0, 0,
- 0, 0x3349, 0, 0x5A25, 0x597E, 0xC07C, 0x747D, 0x747E,
-};
-static const unsigned short utf8_to_euc_E693[] = {
- 0, 0x4D4A, 0x5A27, 0, 0xC121, 0x5A23, 0, 0x5A24,
- 0, 0xC122, 0xC123, 0xC124, 0xC125, 0x4160, 0xC126, 0,
- 0xC127, 0xC128, 0x5A22, 0, 0x593F, 0xC129, 0, 0xC12A,
- 0x5A26, 0, 0x5A21, 0, 0, 0, 0, 0,
- 0x5A2B, 0x5A2C, 0x4527, 0x5A2E, 0xC12B, 0xC12C, 0x3B24, 0x5A29,
- 0, 0xC12D, 0xC12E, 0, 0x353C, 0xC12F, 0, 0x5A2F,
- 0xC130, 0x5A28, 0x5A33, 0, 0x5A32, 0xC131, 0x5A31, 0xC132,
- 0, 0, 0x5A34, 0xC133, 0, 0x5A36, 0x3E71, 0xC134,
-};
-static const unsigned short utf8_to_euc_E693_x0213[] = {
- 0, 0x4D4A, 0x5A27, 0, 0x7521, 0x5A23, 0, 0x5A24,
- 0, 0xC122, 0x7522, 0xAD52, 0xAD53, 0x4160, 0x747C, 0,
- 0x7523, 0xC128, 0x5A22, 0, 0x593F, 0xAD54, 0, 0xAD55,
- 0x5A26, 0, 0x5A21, 0, 0, 0, 0, 0,
- 0x5A2B, 0x5A2C, 0x4527, 0x5A2E, 0xAD57, 0xAD58, 0x3B24, 0x5A29,
- 0, 0xC12D, 0xC12E, 0, 0x353C, 0xC12F, 0, 0x5A2F,
- 0xC130, 0x5A28, 0x5A33, 0, 0x5A32, 0xC131, 0x5A31, 0x7524,
- 0, 0, 0x5A34, 0x7525, 0, 0x5A36, 0x3E71, 0xAD59,
-};
-static const unsigned short utf8_to_euc_E694[] = {
- 0x5A35, 0xC135, 0, 0, 0xC136, 0x5A39, 0, 0,
- 0xC137, 0xC138, 0xC139, 0, 0, 0, 0, 0xC13A,
- 0, 0, 0, 0xC13B, 0xC13C, 0, 0xC13D, 0,
- 0x5A37, 0xC13E, 0, 0xC13F, 0x5A38, 0x5970, 0xC140, 0xC141,
- 0, 0, 0xC142, 0x5A3B, 0x5A3A, 0, 0xC143, 0,
- 0, 0xC144, 0x5978, 0x5A3C, 0x5A30, 0, 0xC145, 0x3B59,
- 0, 0xC146, 0, 0, 0x5A3D, 0x5A3E, 0x5A40, 0x5A3F,
- 0x5A41, 0x327E, 0xC147, 0x3936, 0xC148, 0xC149, 0x4A7C, 0x402F,
-};
-static const unsigned short utf8_to_euc_E694_x0213[] = {
- 0x5A35, 0xC135, 0, 0, 0xAD5A, 0x5A39, 0, 0,
- 0xC137, 0xC138, 0xC139, 0, 0, 0, 0, 0xAD5C,
- 0, 0, 0, 0xC13B, 0xAD5D, 0, 0xAD5E, 0,
- 0x5A37, 0xC13E, 0, 0xC13F, 0x5A38, 0x5970, 0xAD60, 0xC141,
- 0, 0, 0x7526, 0x5A3B, 0x5A3A, 0, 0xC143, 0,
- 0, 0x7527, 0x5978, 0x5A3C, 0x5A30, 0, 0xC145, 0x3B59,
- 0, 0xC146, 0xAD61, 0, 0x5A3D, 0x5A3E, 0x5A40, 0x5A3F,
- 0x5A41, 0x327E, 0xC147, 0x3936, 0xC148, 0xC149, 0x4A7C, 0x402F,
-};
-static const unsigned short utf8_to_euc_E695[] = {
- 0, 0, 0, 0xC14A, 0, 0x384E, 0, 0xC14B,
- 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0xF441, 0x4952,
- 0xC14D, 0x355F, 0xC14E, 0, 0xC14F, 0x5A45, 0x5A44, 0x4754,
- 0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0xC150,
- 0xC151, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0xC152,
- 0, 0, 0, 0xC153, 0x3749, 0, 0, 0,
- 0x3F74, 0, 0x5A4A, 0, 0x4030, 0x4528, 0, 0x495F,
- 0x5A4B, 0, 0xC154, 0, 0, 0xC155, 0, 0,
-};
-static const unsigned short utf8_to_euc_E695_x0213[] = {
- 0, 0, 0, 0xC14A, 0xAD62, 0x384E, 0, 0xC14B,
- 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0, 0x4952,
- 0xC14D, 0x355F, 0xC14E, 0, 0xAD63, 0x5A45, 0x5A44, 0x4754,
- 0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0xC150,
- 0xC151, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0x7529,
- 0, 0, 0, 0xAD64, 0x3749, 0, 0, 0,
- 0x3F74, 0, 0x5A4A, 0, 0x4030, 0x4528, 0, 0x495F,
- 0x5A4B, 0, 0xAD65, 0, 0, 0xC155, 0, 0,
-};
-static const unsigned short utf8_to_euc_E696[] = {
- 0, 0xC156, 0x5A4C, 0x5A4D, 0, 0xC157, 0, 0x4A38,
- 0x555D, 0x4046, 0xC158, 0, 0x494C, 0, 0x3A58, 0,
- 0x4865, 0x4843, 0xC159, 0, 0, 0xC15A, 0, 0x454D,
- 0xC15B, 0x4E41, 0, 0x5A4F, 0x3C50, 0xC15C, 0, 0x5A50,
- 0xC15D, 0x3036, 0, 0xC15E, 0x3654, 0x404D, 0xC15F, 0x4960,
- 0, 0, 0, 0x5A51, 0x3B42, 0x4347, 0xC160, 0x3B5B,
- 0x3F37, 0, 0xC161, 0xC162, 0xC163, 0, 0, 0x5A52,
- 0, 0x4A7D, 0, 0, 0x3177, 0x3B5C, 0, 0xC164,
-};
-static const unsigned short utf8_to_euc_E696_x0213[] = {
- 0, 0xAD66, 0x5A4C, 0x5A4D, 0xAD67, 0xAD68, 0, 0x4A38,
- 0x555D, 0x4046, 0xAD69, 0, 0x494C, 0, 0x3A58, 0,
- 0x4865, 0x4843, 0xC159, 0, 0, 0xC15A, 0, 0x454D,
- 0xC15B, 0x4E41, 0, 0x5A4F, 0x3C50, 0x752A, 0, 0x5A50,
- 0xC15D, 0x3036, 0, 0xC15E, 0x3654, 0x404D, 0xC15F, 0x4960,
- 0, 0, 0, 0x5A51, 0x3B42, 0x4347, 0xC160, 0x3B5B,
- 0x3F37, 0, 0xAD6A, 0xC162, 0xC163, 0xAD6B, 0, 0x5A52,
- 0xAD6C, 0x4A7D, 0, 0, 0x3177, 0x3B5C, 0, 0xAD6D,
-};
-static const unsigned short utf8_to_euc_E697[] = {
- 0, 0x5A55, 0xC165, 0x5A53, 0x5A56, 0x4E39, 0x5A54, 0,
- 0xC166, 0xC167, 0, 0x407B, 0x5A57, 0, 0xC168, 0x4232,
- 0xC169, 0, 0x5A58, 0, 0xC16A, 0, 0xC16B, 0x347A,
- 0xC16C, 0x5A5A, 0, 0x5A59, 0, 0, 0, 0xC16D,
- 0x5A5B, 0x5A5C, 0x347B, 0, 0, 0x467C, 0x4336, 0x356C,
- 0x3B5D, 0x4161, 0, 0, 0x3D5C, 0x3030, 0, 0,
- 0xC16E, 0x5A5D, 0xC16F, 0, 0xC170, 0xC171, 0, 0,
- 0, 0xC172, 0x3222, 0x5A61, 0, 0, 0xC173, 0xC174,
-};
-static const unsigned short utf8_to_euc_E697_x0213[] = {
- 0, 0x5A55, 0xAD6E, 0x5A53, 0x5A56, 0x4E39, 0x5A54, 0,
- 0xC166, 0xAD6F, 0, 0x407B, 0x5A57, 0, 0xC168, 0x4232,
- 0xC169, 0, 0x5A58, 0, 0xAD70, 0, 0xC16B, 0x347A,
- 0xC16C, 0x5A5A, 0, 0x5A59, 0, 0, 0, 0xC16D,
- 0x5A5B, 0x5A5C, 0x347B, 0, 0, 0x467C, 0x4336, 0x356C,
- 0x3B5D, 0x4161, 0, 0, 0x3D5C, 0x3030, 0, 0,
- 0xC16E, 0x5A5D, 0xAD72, 0, 0xC170, 0xC171, 0, 0,
- 0, 0xAD73, 0x3222, 0x5A61, 0xAD74, 0, 0xC173, 0xC174,
-};
-static const unsigned short utf8_to_euc_E698[] = {
- 0xC175, 0, 0x3937, 0x5A60, 0xC176, 0, 0x3A2B, 0x3E3A,
- 0xC177, 0xC178, 0x5A5F, 0, 0x3E3B, 0xC179, 0x4C40, 0x3A2A,
- 0, 0xC17A, 0xC17B, 0x3057, 0x404E, 0xC17C, 0xC17D, 0,
- 0, 0, 0, 0, 0x5A66, 0xC17E, 0xC221, 0x4031,
- 0x3147, 0xC222, 0xC223, 0xC224, 0xC225, 0x3D55, 0xC226, 0x4B66,
- 0x3A72, 0xC227, 0xC228, 0xC229, 0xC22A, 0x3E3C, 0xC22B, 0x4027,
- 0xC22C, 0xC22D, 0, 0xC22E, 0x5A65, 0x5A63, 0x5A64, 0xC230,
- 0, 0xC22F, 0, 0xF442, 0x436B, 0, 0, 0x5B26,
-};
-static const unsigned short utf8_to_euc_E698_x0213[] = {
- 0x752C, 0, 0x3937, 0x5A60, 0xAD75, 0, 0x3A2B, 0x3E3A,
- 0xAD76, 0x752D, 0x5A5F, 0, 0x3E3B, 0xC179, 0x4C40, 0x3A2A,
- 0, 0xC17A, 0xC17B, 0x3057, 0x404E, 0x752E, 0xC17D, 0,
- 0, 0, 0, 0, 0x5A66, 0xC17E, 0x752F, 0x4031,
- 0x3147, 0xAD77, 0x7531, 0xC224, 0x7532, 0x3D55, 0xC226, 0x4B66,
- 0x3A72, 0xC227, 0xAD78, 0x7533, 0xC22A, 0x3E3C, 0, 0x4027,
- 0x7534, 0x7535, 0, 0x7536, 0x5A65, 0x5A63, 0x5A64, 0xC230,
- 0, 0xC22F, 0x7530, 0, 0x436B, 0, 0, 0x5B26,
-};
-static const unsigned short utf8_to_euc_E699[] = {
- 0xC231, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0xC232, 0xC233, 0,
- 0, 0x5A69, 0xC234, 0x3F38, 0xC235, 0, 0xC237, 0x5A67,
- 0, 0xC236, 0x3B2F, 0, 0, 0, 0, 0xC238,
- 0xC239, 0xC23A, 0, 0xC23B, 0xC23C, 0x5A6C, 0x5A6B, 0x5A70,
- 0xC23D, 0xC23E, 0x5A71, 0, 0x5A6D, 0xF443, 0x3322, 0x5A6E,
- 0x5A6F, 0x4855, 0xC240, 0xC241, 0xC242, 0, 0x4961, 0x374A,
- 0x5A72, 0, 0, 0xC244, 0x4032, 0xC245, 0x3E3D, 0xC247,
- 0xC248, 0xC249, 0x4352, 0xC24A, 0xC24C, 0, 0xC243, 0xC246,
-};
-static const unsigned short utf8_to_euc_E699_x0213[] = {
- 0xC231, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0xAD79, 0xC233, 0,
- 0x7538, 0x5A69, 0xC234, 0x3F38, 0x7539, 0, 0xAD7B, 0x5A67,
- 0, 0xAD7A, 0x3B2F, 0, 0, 0, 0, 0xAD7E,
- 0xC239, 0x753B, 0x753C, 0xAE21, 0xC23C, 0x5A6C, 0x5A6B, 0x5A70,
- 0xC23D, 0x753D, 0x5A71, 0xAE22, 0x5A6D, 0x753E, 0x3322, 0x5A6E,
- 0x5A6F, 0x4855, 0xAE25, 0xAE26, 0xAE27, 0xAE28, 0x4961, 0x374A,
- 0x5A72, 0, 0, 0x753F, 0x4032, 0xC245, 0x3E3D, 0x7540,
- 0x7541, 0xC249, 0x4352, 0xAE29, 0xC24C, 0, 0xC243, 0xC246,
-};
-static const unsigned short utf8_to_euc_E69A[] = {
- 0xC24B, 0x3647, 0, 0x5A73, 0x5A77, 0, 0, 0x324B,
- 0x5A74, 0x5A76, 0, 0xC24D, 0xC24E, 0xC24F, 0x5A75, 0,
- 0xC250, 0x3D6B, 0xC251, 0, 0, 0, 0x4348, 0x3045,
- 0x5A78, 0xC252, 0xC253, 0xC254, 0xC255, 0x5A79, 0, 0xC256,
- 0xC257, 0, 0x442A, 0, 0xC258, 0, 0x4E71, 0,
- 0, 0, 0, 0x3B43, 0, 0xC259, 0x4A6B, 0,
- 0, 0xC25A, 0xC25B, 0, 0x4B3D, 0xC25C, 0, 0,
- 0x5B22, 0x5A7B, 0, 0xC25D, 0x5A7E, 0, 0x5A7D, 0xC25E,
-};
-static const unsigned short utf8_to_euc_E69A_x0213[] = {
- 0xAE2A, 0x3647, 0, 0x5A73, 0x5A77, 0, 0, 0x324B,
- 0x5A74, 0x5A76, 0, 0xC24D, 0xC24E, 0x7542, 0x5A75, 0,
- 0xAE2B, 0x3D6B, 0xAE2C, 0, 0, 0, 0x4348, 0x3045,
- 0x5A78, 0xAE2D, 0xC253, 0xC254, 0xC255, 0x5A79, 0, 0xC256,
- 0x7544, 0, 0x442A, 0, 0xC258, 0, 0x4E71, 0,
- 0, 0, 0, 0x3B43, 0, 0xAE2F, 0x4A6B, 0,
- 0, 0xAE30, 0x7545, 0, 0x4B3D, 0xAE31, 0, 0,
- 0x5B22, 0x5A7B, 0, 0x7546, 0x5A7E, 0, 0x5A7D, 0xAE33,
-};
-static const unsigned short utf8_to_euc_E69B[] = {
- 0xC25F, 0x5A7A, 0xC260, 0xC261, 0x5B21, 0, 0, 0x465E,
- 0xC262, 0x5A7C, 0, 0, 0xC263, 0, 0xC264, 0xC265,
- 0, 0, 0, 0, 0xC266, 0, 0x5B23, 0,
- 0, 0x3D6C, 0x5B24, 0xC267, 0x4D4B, 0x4778, 0, 0xC268,
- 0x5B25, 0, 0, 0, 0, 0, 0x5B27, 0,
- 0xC269, 0x5B28, 0, 0xC26A, 0xC26B, 0, 0xC26C, 0,
- 0x5B29, 0, 0x364A, 0x3148, 0x3939, 0x5B2A, 0, 0x5B2B,
- 0x3D71, 0x4162, 0xC26D, 0xC23F, 0x5258, 0x413E, 0x413D, 0x4258,
-};
-static const unsigned short utf8_to_euc_E69B_x0213[] = {
- 0xC25F, 0x5A7A, 0xC260, 0xC261, 0x5B21, 0, 0x7547, 0x465E,
- 0x7548, 0x5A7C, 0, 0, 0xC263, 0, 0xC264, 0xC265,
- 0, 0, 0, 0, 0xC266, 0, 0x5B23, 0,
- 0, 0x3D6C, 0x5B24, 0x754A, 0x4D4B, 0x4778, 0, 0xC268,
- 0x5B25, 0, 0, 0, 0, 0, 0x5B27, 0,
- 0x754B, 0x5B28, 0, 0xC26A, 0xAE35, 0, 0xC26C, 0,
- 0x5B29, 0, 0x364A, 0x3148, 0x3939, 0x5B2A, 0, 0x5B2B,
- 0x3D71, 0x4162, 0x754C, 0x7537, 0x5258, 0x413E, 0x413D, 0x4258,
-};
-static const unsigned short utf8_to_euc_E69C[] = {
- 0x3A47, 0, 0, 0x5072, 0, 0xC26E, 0, 0xC26F,
- 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0xC270, 0x5B2C,
- 0, 0, 0, 0xC271, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
- 0, 0xC272, 0, 0x4B3E, 0xC273, 0x442B, 0x5B2E, 0x347C,
- 0xC274, 0, 0xC275, 0, 0, 0, 0x5B2F, 0x5B30,
- 0x4C5A, 0, 0x4C24, 0x4B76, 0x4B5C, 0x3B25, 0x5B32, 0,
- 0, 0x3C6B, 0, 0xC276, 0x4B51, 0, 0x5B34, 0x5B37,
- 0x5B36, 0, 0x3479, 0, 0, 0x3560, 0xC277, 0x5B33,
-};
-static const unsigned short utf8_to_euc_E69C_x0213[] = {
- 0x3A47, 0xAE37, 0, 0x5072, 0, 0xAE38, 0, 0xC26F,
- 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0, 0x5B2C,
- 0, 0, 0xAE39, 0x754D, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
- 0, 0xAE3B, 0, 0x4B3E, 0xC273, 0x442B, 0x5B2E, 0x347C,
- 0xC274, 0, 0xC275, 0, 0, 0, 0x5B2F, 0x5B30,
- 0x4C5A, 0, 0x4C24, 0x4B76, 0x4B5C, 0x3B25, 0x5B32, 0,
- 0, 0x3C6B, 0, 0x754F, 0x4B51, 0, 0x5B34, 0x5B37,
- 0x5B36, 0, 0x3479, 0, 0, 0x3560, 0xC277, 0x5B33,
-};
-static const unsigned short utf8_to_euc_E69D[] = {
- 0, 0x5B35, 0, 0, 0, 0xC278, 0x5B38, 0xC279,
- 0xC27A, 0x3F79, 0, 0, 0xC27B, 0, 0x4D7B, 0x3049,
- 0x3A60, 0x423C, 0, 0x3C5D, 0xC27C, 0xC27D, 0x3E73, 0,
- 0, 0x5B3B, 0, 0, 0x454E, 0xC27E, 0x5B39, 0x422B,
- 0x5B3A, 0x3E72, 0x4C5D, 0x5B3C, 0x5B3D, 0x4D68, 0xC321, 0,
- 0, 0, 0x5B42, 0, 0xC322, 0x393A, 0xC323, 0x4755,
- 0x5B3F, 0x456C, 0x5A5E, 0x5A62, 0xC324, 0x354F, 0xC325, 0x4747,
- 0, 0, 0, 0xC326, 0x5B41, 0, 0x3E3E, 0x4844,
-};
-static const unsigned short utf8_to_euc_E69D_x0213[] = {
- 0, 0x5B35, 0, 0, 0, 0xC278, 0x5B38, 0x7551,
- 0x7552, 0x3F79, 0, 0, 0xAE3E, 0xAE3F, 0x4D7B, 0x3049,
- 0x3A60, 0x423C, 0, 0x3C5D, 0xAE40, 0xC27D, 0x3E73, 0,
- 0, 0x5B3B, 0, 0, 0x454E, 0xAE41, 0x5B39, 0x422B,
- 0x5B3A, 0x3E72, 0x4C5D, 0x5B3C, 0x5B3D, 0x4D68, 0x7550, 0,
- 0, 0, 0x5B42, 0, 0xC322, 0x393A, 0xC323, 0x4755,
- 0x5B3F, 0x456C, 0x5A5E, 0x5A62, 0xAE45, 0x354F, 0xAE46, 0x4747,
- 0, 0, 0, 0x7553, 0x5B41, 0, 0x3E3E, 0x4844,
-};
-static const unsigned short utf8_to_euc_E69E[] = {
- 0, 0xC327, 0, 0, 0xC328, 0x5B47, 0, 0x487A,
- 0, 0x5B3E, 0, 0x5B44, 0x5B43, 0, 0xC329, 0xC32A,
- 0x404F, 0xC32B, 0, 0xC32C, 0, 0x4B6D, 0xC32D, 0x4E53,
- 0xC32E, 0xC32F, 0x4B67, 0xC330, 0x324C, 0x3B5E, 0, 0,
- 0x4F48, 0x5B46, 0x3F75, 0, 0, 0, 0x5B45, 0,
- 0, 0x5B40, 0, 0, 0, 0, 0, 0x384F,
- 0xC331, 0xC332, 0xC333, 0x5B4C, 0x5B4A, 0xC334, 0x324D, 0x5B48,
- 0x5B4E, 0x5B54, 0, 0xC335, 0xC336, 0xC337, 0, 0,
-};
-static const unsigned short utf8_to_euc_E69E_x0213[] = {
- 0, 0x7554, 0, 0, 0xC328, 0x5B47, 0, 0x487A,
- 0, 0x5B3E, 0, 0x5B44, 0x5B43, 0, 0xC329, 0xC32A,
- 0x404F, 0xC32B, 0xAE48, 0x7555, 0, 0x4B6D, 0xC32D, 0x4E53,
- 0x7556, 0xC32F, 0x4B67, 0x7557, 0x324C, 0x3B5E, 0, 0,
- 0x4F48, 0x5B46, 0x3F75, 0, 0, 0, 0x5B45, 0,
- 0, 0x5B40, 0, 0, 0, 0, 0, 0x384F,
- 0xAE4C, 0xC332, 0xAE4D, 0x5B4C, 0x5B4A, 0xC334, 0x324D, 0x5B48,
- 0x5B4E, 0x5B54, 0, 0x7558, 0xC336, 0xC337, 0, 0,
-};
-static const unsigned short utf8_to_euc_E69F[] = {
- 0xC339, 0x4248, 0xC33A, 0xC33B, 0x4A41, 0xC33C, 0x5B56, 0,
- 0xC33D, 0xC33E, 0x4922, 0, 0, 0, 0x5B55, 0x4770,
- 0x4B3F, 0x343B, 0xC33F, 0x4077, 0x3D40, 0, 0, 0xC340,
- 0x4453, 0xC341, 0x4D2E, 0, 0xC342, 0x5B51, 0x5B50, 0,
- 0, 0xC343, 0x5B52, 0, 0x5B4F, 0, 0xC344, 0x5B57,
- 0, 0x5B4D, 0, 0, 0x5B4B, 0, 0x5B53, 0x5B49,
- 0xC345, 0x436C, 0xC346, 0x4C78, 0x3C46, 0x3A74, 0xC347, 0xC348,
- 0, 0xC338, 0, 0x3A3A, 0, 0, 0x4B6F, 0x3341,
-};
-static const unsigned short utf8_to_euc_E69F_x0213[] = {
- 0x755A, 0x4248, 0xC33A, 0xAE4E, 0x4A41, 0xC33C, 0x5B56, 0,
- 0xAE4F, 0xC33E, 0x4922, 0, 0, 0, 0x5B55, 0x4770,
- 0x4B3F, 0x343B, 0xAE50, 0x4077, 0x3D40, 0, 0, 0x755B,
- 0x4453, 0xAE51, 0x4D2E, 0xAE52, 0xC342, 0x5B51, 0x5B50, 0,
- 0, 0xC343, 0x5B52, 0, 0x5B4F, 0, 0xC344, 0x5B57,
- 0, 0x5B4D, 0, 0, 0x5B4B, 0, 0x5B53, 0x5B49,
- 0xAE53, 0x436C, 0xC346, 0x4C78, 0x3C46, 0x3A74, 0xC347, 0xAE54,
- 0, 0x7559, 0, 0x3A3A, 0x755C, 0, 0x4B6F, 0x3341,
-};
-static const unsigned short utf8_to_euc_E6A0[] = {
- 0, 0xF446, 0x444E, 0x464A, 0x3149, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x4072, 0xC34A, 0, 0x4034, 0x372A,
- 0, 0xC34B, 0, 0, 0, 0xC34C, 0x5B59, 0xC34D,
- 0, 0x393B, 0x337C, 0, 0, 0, 0, 0xC34F,
- 0xC34E, 0x5B5B, 0x3374, 0x5B61, 0xC350, 0xC351, 0, 0xC352,
- 0xC353, 0xC354, 0x5B5E, 0xC355, 0x4073, 0, 0, 0,
- 0x334B, 0x3A2C, 0, 0xC356, 0x334A, 0x3A4F, 0, 0xC357,
-};
-static const unsigned short utf8_to_euc_E6A0_x0213[] = {
- 0, 0x755D, 0x444E, 0x464A, 0x3149, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xAE4B, 0, 0, 0x4072, 0xC34A, 0, 0x4034, 0x372A,
- 0xAE58, 0xC34B, 0, 0, 0, 0x755F, 0x5B59, 0xAE59,
- 0, 0x393B, 0x337C, 0, 0, 0, 0, 0xC34F,
- 0xC34E, 0x5B5B, 0x3374, 0x5B61, 0x7560, 0xAE5A, 0, 0xC352,
- 0xC353, 0x7561, 0x5B5E, 0xAE5C, 0x4073, 0, 0, 0,
- 0x334B, 0x3A2C, 0, 0xAE5D, 0x334A, 0x3A4F, 0xAE5E, 0xC357,
-};
-static const unsigned short utf8_to_euc_E6A1[] = {
- 0x5B5C, 0x3765, 0x374B, 0x456D, 0xC358, 0xC359, 0x5B5A, 0,
- 0x3046, 0, 0xC35A, 0, 0xC35B, 0x5B5D, 0x5B5F, 0,
- 0x364D, 0x372C, 0xC349, 0x343C, 0x354B, 0xC35C, 0, 0xC35D,
- 0xC35E, 0x5B62, 0, 0xC35F, 0x3A79, 0x4B71, 0, 0x3B37,
- 0, 0, 0, 0x5B63, 0, 0, 0, 0x4930,
- 0, 0, 0, 0xC360, 0, 0, 0xC361, 0xC362,
- 0xC363, 0xC364, 0xC365, 0, 0x5B6F, 0xC366, 0x3233, 0x5B64,
- 0, 0xC367, 0xC368, 0xC369, 0xC36A, 0, 0x5B75, 0x5B65,
-};
-static const unsigned short utf8_to_euc_E6A1_x0213[] = {
- 0x5B5C, 0x3765, 0x374B, 0x456D, 0xAE5F, 0xAE60, 0x5B5A, 0,
- 0x3046, 0xAE61, 0xC35A, 0, 0xAE62, 0x5B5D, 0x5B5F, 0,
- 0x364D, 0x372C, 0x755E, 0x343C, 0x354B, 0xAE63, 0, 0xAE64,
- 0xC35E, 0x5B62, 0, 0x7562, 0x3A79, 0x4B71, 0, 0x3B37,
- 0, 0, 0, 0x5B63, 0, 0, 0, 0x4930,
- 0, 0, 0, 0xAE66, 0, 0, 0xAE67, 0xC362,
- 0xC363, 0xC364, 0x7563, 0, 0x5B6F, 0x7564, 0x3233, 0x5B64,
- 0, 0xC367, 0xAE68, 0xC369, 0xAE69, 0, 0x5B75, 0x5B65,
-};
-static const unsigned short utf8_to_euc_E6A2[] = {
- 0, 0x4E42, 0xC36B, 0x5B6C, 0xC36C, 0x475F, 0xC36D, 0,
- 0xC36E, 0, 0, 0, 0, 0x5B74, 0, 0x5B67,
- 0, 0, 0, 0x3034, 0x5B69, 0, 0xC36F, 0x393C,
- 0xC370, 0, 0xC371, 0x5B6B, 0xC372, 0x5B6A, 0, 0x5B66,
- 0x5B71, 0xC373, 0x3E3F, 0xC374, 0, 0xC375, 0x546D, 0x3868,
- 0x4D7C, 0xC376, 0xC377, 0, 0, 0x5B68, 0xC378, 0x4474,
- 0x3323, 0x3A2D, 0xC379, 0x5B60, 0, 0x5B70, 0x3361, 0,
- 0, 0x5B6E, 0x5B72, 0xC37A, 0x456E, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6A2_x0213[] = {
- 0, 0x4E42, 0xAE6A, 0x5B6C, 0xC36C, 0x475F, 0xC36D, 0,
- 0xC36E, 0, 0, 0, 0, 0x5B74, 0, 0x5B67,
- 0xAE6B, 0, 0, 0x3034, 0x5B69, 0, 0xAE6C, 0x393C,
- 0xAE6E, 0xAE6F, 0xAE70, 0x5B6B, 0xAE71, 0x5B6A, 0, 0x5B66,
- 0x5B71, 0xC373, 0x3E3F, 0x7566, 0, 0x7567, 0x546D, 0x3868,
- 0x4D7C, 0xC376, 0xAE72, 0xAE73, 0, 0x5B68, 0xC378, 0x4474,
- 0x3323, 0x3A2D, 0x7568, 0x5B60, 0xAE74, 0x5B70, 0x3361, 0,
- 0, 0x5B6E, 0x5B72, 0xAE75, 0x456E, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6A3[] = {
- 0, 0, 0, 0, 0x347E, 0xC37B, 0x5C32, 0,
- 0xC37C, 0x4C49, 0x5B77, 0x347D, 0xC37D, 0x5B7E, 0, 0xC37E,
- 0xC421, 0xC422, 0x4B40, 0xC423, 0x5C21, 0x5C23, 0xC424, 0x5C27,
- 0x5B79, 0xC425, 0x432A, 0, 0xC426, 0xC427, 0, 0x456F,
- 0x5C2B, 0x5B7C, 0, 0x5C28, 0, 0xC428, 0, 0x5C22,
- 0xC429, 0, 0xC42A, 0xC42B, 0xC42C, 0xC42D, 0x3F39, 0x5C2C,
- 0xC42E, 0xC42F, 0x4033, 0, 0, 0xC430, 0xC431, 0,
- 0, 0x5C2A, 0x343D, 0xC432, 0xC433, 0xC434, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6A3_x0213[] = {
- 0, 0, 0, 0xAE7A, 0x347E, 0xAE7B, 0x5C32, 0,
- 0x7569, 0x4C49, 0x5B77, 0x347D, 0xAE7C, 0x5B7E, 0, 0xAE7D,
- 0x756A, 0xC422, 0x4B40, 0xC423, 0x5C21, 0x5C23, 0xAE7E, 0x5C27,
- 0x5B79, 0xAF21, 0x432A, 0, 0xC426, 0xC427, 0, 0x456F,
- 0x5C2B, 0x5B7C, 0, 0x5C28, 0xAF22, 0xAF23, 0, 0x5C22,
- 0x756B, 0, 0xC42A, 0xC42B, 0xAF24, 0x756C, 0x3F39, 0x5C2C,
- 0x756D, 0x756E, 0x4033, 0, 0, 0xC430, 0xC431, 0xAF25,
- 0, 0x5C2A, 0x343D, 0xAE76, 0x756F, 0xC434, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6A4[] = {
- 0x4F50, 0x5B76, 0, 0, 0x5C26, 0x3058, 0xC435, 0,
- 0x5B78, 0xC436, 0xC437, 0x4C3A, 0x5B7D, 0x3F22, 0x4447, 0x5B73,
- 0xC438, 0xC439, 0x5C25, 0xC43A, 0, 0, 0xC43B, 0xC43C,
- 0, 0x3F7A, 0x5C2F, 0x3371, 0x3821, 0, 0, 0,
- 0, 0x5C31, 0x5B7A, 0x5C30, 0, 0x5C29, 0x5B7B, 0,
- 0x5C2D, 0, 0x5C2E, 0, 0, 0, 0, 0,
- 0x5C3F, 0xC43D, 0, 0xC43E, 0x464E, 0xC43F, 0x5C24, 0,
- 0xC440, 0x5C3B, 0, 0xC441, 0, 0x5C3D, 0, 0x4458,
-};
-static const unsigned short utf8_to_euc_E6A4_x0213[] = {
- 0x4F50, 0x5B76, 0, 0xAF26, 0x5C26, 0x3058, 0xC435, 0xAF27,
- 0x5B78, 0xC436, 0x7570, 0x4C3A, 0x5B7D, 0x3F22, 0x4447, 0x5B73,
- 0xC438, 0xC439, 0x5C25, 0xC43A, 0, 0, 0xC43B, 0xC43C,
- 0, 0x3F7A, 0x5C2F, 0x3371, 0x3821, 0, 0, 0,
- 0, 0x5C31, 0x5B7A, 0x5C30, 0, 0x5C29, 0x5B7B, 0,
- 0x5C2D, 0, 0x5C2E, 0, 0, 0, 0, 0,
- 0x5C3F, 0xC43D, 0, 0xC43E, 0x464E, 0x7573, 0x5C24, 0,
- 0xC440, 0x5C3B, 0, 0xAF2B, 0, 0x5C3D, 0, 0x4458,
-};
-static const unsigned short utf8_to_euc_E6A5[] = {
- 0, 0, 0xC442, 0, 0, 0xC443, 0, 0,
- 0, 0xC444, 0x4D4C, 0, 0, 0, 0xC445, 0,
- 0, 0, 0, 0x4976, 0x5C38, 0x424A, 0, 0xC446,
- 0, 0x5C3E, 0x413F, 0xC447, 0x5C35, 0x5C42, 0x5C41, 0,
- 0x466F, 0x5C40, 0x466A, 0xC448, 0xC449, 0xC44A, 0xC44B, 0,
- 0xC44C, 0xC44D, 0x5C44, 0x5C37, 0xC44E, 0x3648, 0x5C3A, 0x3D5D,
- 0xC44F, 0xC450, 0xC451, 0x4760, 0x5C3C, 0x364B, 0, 0x5C34,
- 0x5C36, 0x5C33, 0xC452, 0xC453, 0x4F30, 0x335A, 0x5C39, 0xC454,
-};
-static const unsigned short utf8_to_euc_E6A5_x0213[] = {
- 0, 0, 0x7574, 0, 0, 0xC443, 0xAF2D, 0,
- 0, 0x7571, 0x4D4C, 0, 0, 0, 0xC445, 0,
- 0, 0, 0, 0x4976, 0x5C38, 0x424A, 0, 0x7575,
- 0, 0x5C3E, 0x413F, 0xC447, 0x5C35, 0x5C42, 0x5C41, 0,
- 0x466F, 0x5C40, 0x466A, 0x7576, 0x7577, 0xC44A, 0xC44B, 0,
- 0x7578, 0xAF2E, 0x5C44, 0x5C37, 0xAF2F, 0x3648, 0x5C3A, 0x3D5D,
- 0xC44F, 0xC450, 0xAF30, 0x4760, 0x5C3C, 0x364B, 0, 0x5C34,
- 0x5C36, 0x5C33, 0xAF31, 0xC453, 0x4F30, 0x335A, 0x5C39, 0xAF32,
-};
-static const unsigned short utf8_to_euc_E6A6[] = {
- 0xC455, 0x5C43, 0x3335, 0, 0, 0, 0, 0,
- 0, 0, 0x3A67, 0, 0, 0xC456, 0x315D, 0,
- 0, 0x5C54, 0xC457, 0, 0x4F31, 0x5C57, 0xC458, 0,
- 0xC459, 0, 0, 0x3F3A, 0x5C56, 0, 0, 0,
- 0x5C55, 0xC45A, 0, 0, 0, 0xC45B, 0xC45C, 0x5C52,
- 0xC45D, 0, 0, 0xC45E, 0, 0xC45F, 0x5C46, 0xC460,
- 0, 0x5C63, 0x5C45, 0, 0x5C58, 0, 0, 0xC461,
- 0xC462, 0, 0xC463, 0x5C50, 0xC464, 0, 0x5C4B, 0x5C48,
-};
-static const unsigned short utf8_to_euc_E6A6_x0213[] = {
- 0x7579, 0x5C43, 0x3335, 0, 0, 0, 0, 0,
- 0, 0, 0x3A67, 0, 0, 0xC456, 0x315D, 0,
- 0, 0x5C54, 0xAF33, 0, 0x4F31, 0x5C57, 0xAF35, 0,
- 0xAF36, 0, 0, 0x3F3A, 0x5C56, 0, 0, 0,
- 0x5C55, 0xC45A, 0, 0, 0, 0x757B, 0xAF37, 0x5C52,
- 0xC45D, 0, 0, 0xC45E, 0, 0x757C, 0x5C46, 0xC460,
- 0xAF38, 0x5C63, 0x5C45, 0, 0x5C58, 0, 0, 0xAF39,
- 0xC462, 0, 0xAF3A, 0x5C50, 0xAF3B, 0, 0x5C4B, 0x5C48,
-};
-static const unsigned short utf8_to_euc_E6A7[] = {
- 0, 0x5C49, 0, 0x5C51, 0, 0xC465, 0, 0x7422,
- 0xC466, 0, 0x5C4E, 0x393D, 0x4448, 0x4164, 0x5C4C, 0,
- 0x5C47, 0xC467, 0, 0x5C4A, 0, 0, 0xC468, 0xC469,
- 0x4D4D, 0x4B6A, 0, 0, 0, 0x5C4F, 0x5C59, 0,
- 0, 0, 0xC46A, 0, 0, 0xC46B, 0, 0x5C61,
- 0x5C5A, 0, 0, 0x5C67, 0, 0x5C65, 0xC46C, 0xC46D,
- 0, 0xC46E, 0x5C60, 0xC46F, 0, 0xC470, 0, 0,
- 0, 0x5C5F, 0, 0x4450, 0, 0x4165, 0xC471, 0x5C5D,
-};
-static const unsigned short utf8_to_euc_E6A7_x0213[] = {
- 0xAF3C, 0x5C49, 0, 0x5C51, 0, 0xC465, 0, 0x7422,
- 0xC466, 0, 0x5C4E, 0x393D, 0x4448, 0x4164, 0x5C4C, 0x757D,
- 0x5C47, 0xAF3D, 0, 0x5C4A, 0, 0, 0xAF3E, 0xC469,
- 0x4D4D, 0x4B6A, 0, 0, 0, 0x5C4F, 0x5C59, 0,
- 0, 0, 0x7622, 0xAF44, 0, 0xC46B, 0, 0x5C61,
- 0x5C5A, 0x7623, 0x7624, 0x5C67, 0, 0x5C65, 0xAF45, 0xAF46,
- 0, 0xC46E, 0x5C60, 0xAF47, 0xAF49, 0x7625, 0x7626, 0,
- 0, 0x5C5F, 0, 0x4450, 0, 0x4165, 0xAF4A, 0x5C5D,
-};
-static const unsigned short utf8_to_euc_E6A8[] = {
- 0xC472, 0xC473, 0x5C5B, 0xC474, 0, 0x5C62, 0, 0,
- 0, 0, 0x5C68, 0x4875, 0x5C6E, 0, 0, 0xC475,
- 0, 0xC476, 0x5C69, 0x5C6C, 0x5C66, 0xC477, 0, 0x4374,
- 0, 0x4938, 0xC478, 0x5C5C, 0, 0xC479, 0x5C64, 0x3E40,
- 0xC47A, 0x4C4F, 0x5C78, 0x5C6B, 0xC47B, 0, 0, 0,
- 0xC47C, 0x3822, 0x3223, 0x335F, 0, 0, 0x5C53, 0,
- 0xC47D, 0, 0xC47E, 0, 0xC521, 0x3E41, 0x5C70, 0xC522,
- 0x5C77, 0x3C79, 0x3372, 0xC523, 0, 0x432E, 0xC524, 0xC525,
-};
-static const unsigned short utf8_to_euc_E6A8_x0213[] = {
- 0xC472, 0xC473, 0x5C5B, 0xC474, 0, 0x5C62, 0, 0,
- 0, 0, 0x5C68, 0x4875, 0x5C6E, 0, 0, 0x7627,
- 0, 0xAF4B, 0x5C69, 0x5C6C, 0x5C66, 0x7628, 0, 0x4374,
- 0, 0x4938, 0xAF4C, 0x5C5C, 0, 0xAF4D, 0x5C64, 0x3E40,
- 0xC47A, 0x4C4F, 0x5C78, 0x5C6B, 0xC47B, 0, 0, 0,
- 0xC47C, 0x3822, 0x3223, 0x335F, 0, 0, 0x5C53, 0,
- 0xAF41, 0, 0xAF4F, 0xAF50, 0xAF51, 0x3E41, 0x5C70, 0xC522,
- 0x5C77, 0x3C79, 0x3372, 0x762A, 0, 0x432E, 0x762B, 0xAF52,
-};
-static const unsigned short utf8_to_euc_E6A9[] = {
- 0, 0, 0, 0, 0x5C6D, 0xC526, 0xC527, 0x5C72,
- 0x5C76, 0xC528, 0xC529, 0x3636, 0, 0, 0xC52A, 0,
- 0xC52B, 0xC52C, 0xC52D, 0, 0, 0xC52E, 0xC52F, 0,
- 0x354C, 0x5C74, 0, 0xC530, 0, 0, 0, 0x3521,
- 0, 0x464B, 0x5C73, 0, 0xC531, 0, 0x5C75, 0xC532,
- 0, 0, 0xC533, 0xF449, 0, 0, 0, 0,
- 0, 0xC534, 0x5C6F, 0xC535, 0, 0, 0, 0,
- 0x5C71, 0, 0, 0, 0, 0, 0xC536, 0x3360,
-};
-static const unsigned short utf8_to_euc_E6A9_x0213[] = {
- 0, 0, 0, 0, 0x5C6D, 0x762C, 0xAF53, 0x5C72,
- 0x5C76, 0xAF54, 0xC529, 0x3636, 0, 0, 0xAF56, 0,
- 0x762D, 0xC52C, 0xAF57, 0, 0, 0xC52E, 0x762E, 0,
- 0x354C, 0x5C74, 0, 0x762F, 0, 0, 0, 0x3521,
- 0, 0x464B, 0x5C73, 0, 0xAF58, 0, 0x5C75, 0xC532,
- 0, 0, 0xC533, 0x7630, 0, 0, 0, 0,
- 0, 0xC534, 0x5C6F, 0x7631, 0, 0, 0, 0,
- 0x5C71, 0, 0xAF55, 0, 0, 0, 0xAF5A, 0x3360,
-};
-static const unsigned short utf8_to_euc_E6AA[] = {
- 0x4349, 0xC537, 0, 0xC538, 0x5C7C, 0, 0xC539, 0xC53A,
- 0, 0xC53B, 0, 0xC53C, 0, 0x5C7A, 0x3869, 0,
- 0x5C79, 0xC53D, 0, 0, 0, 0, 0, 0x5D21,
- 0, 0, 0, 0xC53E, 0x5B58, 0xC53F, 0xC540, 0xC541,
- 0x5C7B, 0, 0x5C7D, 0x5C7E, 0, 0xC542, 0, 0,
- 0, 0, 0x5D2C, 0xC543, 0x5D28, 0, 0x5B6D, 0xC544,
- 0xC545, 0xC546, 0, 0x5D27, 0xC547, 0, 0, 0,
- 0x5D26, 0, 0, 0x5D23, 0, 0xC548, 0xC549, 0xC54A,
-};
-static const unsigned short utf8_to_euc_E6AA_x0213[] = {
- 0x4349, 0xC537, 0, 0xAF5B, 0x5C7C, 0, 0xC539, 0xC53A,
- 0, 0x7633, 0, 0xAF5C, 0, 0x5C7A, 0x3869, 0,
- 0x5C79, 0xAF5E, 0, 0, 0x7634, 0, 0, 0x5D21,
- 0, 0, 0, 0xC53E, 0x5B58, 0x7635, 0x7636, 0xAF5F,
- 0x5C7B, 0xAF60, 0x5C7D, 0x5C7E, 0, 0x7637, 0, 0,
- 0, 0, 0x5D2C, 0xAF62, 0x5D28, 0, 0x5B6D, 0xC544,
- 0xC545, 0xC546, 0, 0x5D27, 0xC547, 0, 0, 0,
- 0x5D26, 0, 0, 0x5D23, 0, 0xAF63, 0xC549, 0xC54A,
-};
-static const unsigned short utf8_to_euc_E6AB[] = {
- 0, 0x5C6A, 0x5D25, 0x5D24, 0, 0, 0xC54B, 0,
- 0xC54D, 0xC54C, 0, 0, 0xC54E, 0, 0, 0,
- 0xC54F, 0x5D2A, 0, 0x4F26, 0xC550, 0xC551, 0xC552, 0,
- 0, 0, 0x5D2D, 0x367B, 0xC553, 0xC554, 0x5D29, 0x5D2B,
- 0, 0, 0xF44A, 0, 0xC555, 0, 0, 0xC556,
- 0x4827, 0, 0x5D2E, 0, 0xC557, 0, 0, 0,
- 0xC558, 0xC559, 0xC55A, 0, 0, 0, 0, 0,
- 0, 0, 0x5D32, 0x5D2F, 0xC55B, 0xC55C, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6AB_x0213[] = {
- 0, 0x5C6A, 0x5D25, 0x5D24, 0, 0, 0xAF64, 0,
- 0xC54D, 0xC54C, 0, 0, 0xC54E, 0, 0, 0,
- 0xAF66, 0x5D2A, 0, 0x4F26, 0xAF65, 0xC551, 0xC552, 0,
- 0, 0, 0x5D2D, 0x367B, 0xAF67, 0xAF68, 0x5D29, 0x5D2B,
- 0, 0, 0, 0, 0x7638, 0, 0, 0x7639,
- 0x4827, 0, 0x5D2E, 0, 0xAF6B, 0, 0, 0,
- 0xC558, 0xAF6C, 0xAF6D, 0xAF6E, 0, 0, 0, 0,
- 0, 0, 0x5D32, 0x5D2F, 0xC55B, 0xAF6F, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6AC[] = {
- 0, 0, 0xC55D, 0xC55E, 0x4D73, 0x5D30, 0xC55F, 0xC560,
- 0, 0xC561, 0x5C5E, 0, 0, 0, 0, 0xC562,
- 0xC563, 0xC564, 0x5D33, 0, 0, 0, 0x5D34, 0xC565,
- 0, 0, 0, 0xC566, 0, 0x3135, 0xC567, 0x5D36,
- 0x3767, 0x3C21, 0, 0x3655, 0xC568, 0, 0, 0x3224,
- 0xC569, 0, 0, 0xC56A, 0xC56B, 0, 0, 0xC56C,
- 0, 0, 0x4D5F, 0, 0, 0xC56D, 0xC56E, 0x5D38,
- 0x5D37, 0x5D3A, 0x353D, 0xC56F, 0, 0x3656, 0x343E, 0xC570,
-};
-static const unsigned short utf8_to_euc_E6AC_x0213[] = {
- 0, 0, 0xC55D, 0xC55E, 0x4D73, 0x5D30, 0xC55F, 0xC560,
- 0, 0xC561, 0x5C5E, 0xAF71, 0, 0, 0, 0xAF72,
- 0xAF73, 0xAF74, 0x5D33, 0, 0, 0, 0x5D34, 0xAF76,
- 0, 0, 0, 0x763C, 0, 0x3135, 0x763D, 0x5D36,
- 0x3767, 0x3C21, 0, 0x3655, 0xC568, 0, 0, 0x3224,
- 0xC569, 0, 0, 0xC56A, 0x763E, 0, 0, 0xAF78,
- 0, 0, 0x4D5F, 0, 0, 0x763F, 0xC56E, 0x5D38,
- 0x5D37, 0x5D3A, 0x353D, 0xC56F, 0, 0x3656, 0x343E, 0xC570,
-};
-static const unsigned short utf8_to_euc_E6AD[] = {
- 0, 0, 0, 0x5D3D, 0, 0, 0xC571, 0x5D3C,
- 0, 0x5D3E, 0xC572, 0, 0x324E, 0xC573, 0x4337, 0,
- 0x5D3F, 0, 0xC574, 0x343F, 0x5D41, 0, 0xC575, 0,
- 0xC576, 0x5D40, 0, 0x5D42, 0, 0xC577, 0, 0x5D43,
- 0xC578, 0x5D44, 0x3B5F, 0x4035, 0x3A21, 0, 0x4970, 0xC579,
- 0, 0x4A62, 0x4F44, 0xC57A, 0, 0, 0xC57B, 0x3B75,
- 0xC57C, 0, 0, 0x3A50, 0x4E72, 0xC57D, 0, 0,
- 0x5D45, 0x5D46, 0, 0x3B60, 0, 0xC57E, 0xC621, 0x5D47,
-};
-static const unsigned short utf8_to_euc_E6AD_x0213[] = {
- 0, 0, 0, 0x5D3D, 0, 0, 0x7640, 0x5D3C,
- 0, 0x5D3E, 0xAF79, 0, 0x324E, 0xC573, 0x4337, 0,
- 0x5D3F, 0, 0xC574, 0x343F, 0x5D41, 0, 0x7641, 0,
- 0xAF7A, 0x5D40, 0, 0x5D42, 0, 0xC577, 0, 0x5D43,
- 0x7642, 0x5D44, 0x3B5F, 0x4035, 0x3A21, 0x7643, 0x4970, 0x7644,
- 0, 0x4A62, 0x4F44, 0xC57A, 0xAF7B, 0, 0xC57B, 0x3B75,
- 0xC57C, 0, 0, 0x3A50, 0x4E72, 0xAF7C, 0, 0x7645,
- 0x5D45, 0x5D46, 0xAF7D, 0x3B60, 0, 0xC57E, 0xC621, 0x5D47,
-};
-static const unsigned short utf8_to_euc_E6AE[] = {
- 0x5D48, 0, 0xC622, 0x5D4A, 0x5D49, 0xC623, 0x4B58, 0,
- 0, 0x3D5E, 0x3C6C, 0x3B44, 0, 0x5D4B, 0, 0,
- 0, 0, 0, 0, 0, 0x5D4D, 0x3F23, 0xC624,
- 0x5D4C, 0, 0, 0xC625, 0, 0, 0x5D4E, 0xC626,
- 0xC627, 0, 0xC628, 0xC629, 0x5D4F, 0, 0, 0,
- 0xC62A, 0xC62B, 0x5D50, 0x5D51, 0xC62C, 0xC62D, 0xC62E, 0x5D52,
- 0xC62F, 0x5D54, 0x5D53, 0x5D55, 0x3225, 0x434A, 0, 0x5D56,
- 0xC630, 0xC631, 0x3B26, 0x334C, 0x5D57, 0xC632, 0xC633, 0x4542,
-};
-static const unsigned short utf8_to_euc_E6AE_x0213[] = {
- 0x5D48, 0xAF7E, 0x7646, 0x5D4A, 0x5D49, 0xC623, 0x4B58, 0,
- 0, 0x3D5E, 0x3C6C, 0x3B44, 0, 0x5D4B, 0, 0,
- 0, 0, 0, 0, 0, 0x5D4D, 0x3F23, 0xC624,
- 0x5D4C, 0, 0, 0xEE21, 0, 0, 0x5D4E, 0xC626,
- 0xC627, 0, 0xC628, 0xC629, 0x5D4F, 0, 0, 0,
- 0xC62A, 0x7647, 0x5D50, 0x5D51, 0xC62C, 0x7648, 0xEE22, 0x5D52,
- 0xC62F, 0x5D54, 0x5D53, 0x5D55, 0x3225, 0x434A, 0, 0x5D56,
- 0xC630, 0xC631, 0x3B26, 0x334C, 0x5D57, 0xEE24, 0xEE25, 0x4542,
-};
-static const unsigned short utf8_to_euc_E6AF[] = {
- 0x544C, 0, 0, 0xC634, 0xC635, 0x3523, 0x5D58, 0,
- 0, 0xC636, 0, 0x5D59, 0xC637, 0x4A6C, 0x4B68, 0,
- 0, 0, 0x4647, 0x5D5A, 0x4866, 0, 0xC638, 0,
- 0x487B, 0, 0xC639, 0x4C53, 0, 0, 0, 0x5D5B,
- 0, 0xC63A, 0, 0xC63B, 0, 0, 0xC63C, 0xC63D,
- 0, 0, 0, 0x5D5D, 0x5D5C, 0, 0xC63E, 0x5D5F,
- 0, 0xC63F, 0, 0x5D5E, 0, 0, 0, 0xC640,
- 0, 0xC641, 0, 0, 0, 0, 0, 0xC642,
-};
-static const unsigned short utf8_to_euc_E6AF_x0213[] = {
- 0x544C, 0, 0, 0xC634, 0xC635, 0x3523, 0x5D58, 0xEE26,
- 0xEE27, 0xEE28, 0, 0x5D59, 0xC637, 0x4A6C, 0x4B68, 0x764A,
- 0, 0, 0x4647, 0x5D5A, 0x4866, 0, 0x764B, 0x764C,
- 0x487B, 0, 0xEE29, 0x4C53, 0, 0, 0, 0x5D5B,
- 0, 0xC63A, 0, 0xC63B, 0, 0, 0xEE2A, 0xEE2B,
- 0, 0, 0, 0x5D5D, 0x5D5C, 0, 0xEE2C, 0x5D5F,
- 0, 0xEE2D, 0, 0x5D5E, 0, 0, 0, 0xC640,
- 0, 0xC641, 0, 0, 0, 0, 0, 0x764D,
-};
-static const unsigned short utf8_to_euc_E6B0[] = {
- 0, 0, 0xC643, 0, 0xC644, 0xC645, 0, 0,
- 0x5D61, 0xC646, 0, 0, 0, 0xC647, 0xC648, 0x3B61,
- 0xC649, 0x4C31, 0xC64A, 0x5D62, 0x5D63, 0, 0, 0x3524,
- 0, 0xC64B, 0, 0x5D64, 0, 0, 0, 0xC64C,
- 0, 0, 0, 0x5D66, 0x5D65, 0, 0xC64D, 0xC64E,
- 0xC64F, 0, 0, 0, 0xC650, 0, 0xC651, 0,
- 0, 0, 0, 0xC652, 0x3F65, 0xC653, 0xC654, 0x4939,
- 0x314A, 0, 0xC655, 0xC656, 0, 0, 0x4845, 0xC657,
-};
-static const unsigned short utf8_to_euc_E6B0_x0213[] = {
- 0, 0, 0xEE2E, 0, 0xC644, 0x764E, 0, 0,
- 0x5D61, 0xC646, 0xEE2F, 0, 0, 0xC647, 0xEE30, 0x3B61,
- 0x764F, 0x4C31, 0xC64A, 0x5D62, 0x5D63, 0, 0, 0x3524,
- 0, 0xC64B, 0, 0x5D64, 0, 0, 0, 0xC64C,
- 0, 0, 0, 0x5D66, 0x5D65, 0, 0xC64D, 0xC64E,
- 0xC64F, 0, 0, 0, 0xC650, 0, 0xC651, 0,
- 0, 0, 0, 0x7650, 0x3F65, 0xEE31, 0xEE32, 0x4939,
- 0x314A, 0, 0xEE33, 0xC656, 0, 0, 0x4845, 0xEE35,
-};
-static const unsigned short utf8_to_euc_E6B1[] = {
- 0x4475, 0x3D41, 0x3561, 0, 0, 0, 0, 0,
- 0, 0, 0xC658, 0xC659, 0, 0xC65A, 0x4846, 0xC65B,
- 0x3C2E, 0, 0xC65C, 0, 0xC65D, 0x5D68, 0, 0x3440,
- 0, 0xC65E, 0x3178, 0xC65F, 0xC660, 0x4672, 0x5D67, 0x393E,
- 0x4353, 0, 0x5D69, 0, 0, 0, 0, 0xC736,
- 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xC662, 0, 0xC663,
- 0x4241, 0, 0x3562, 0x5D72, 0xC664, 0, 0xC665, 0,
- 0xC666, 0xC667, 0x3768, 0xC668, 0, 0x3525, 0x5D70, 0,
-};
-static const unsigned short utf8_to_euc_E6B1_x0213[] = {
- 0x4475, 0x3D41, 0x3561, 0, 0, 0, 0, 0,
- 0, 0, 0xC658, 0xC659, 0, 0xEE36, 0x4846, 0xC65B,
- 0x3C2E, 0, 0xC65C, 0, 0xC65D, 0x5D68, 0, 0x3440,
- 0, 0x7651, 0x3178, 0xEE37, 0x7652, 0x4672, 0x5D67, 0x393E,
- 0x4353, 0, 0x5D69, 0, 0, 0, 0, 0xEE4F,
- 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xEE38, 0, 0,
- 0x4241, 0, 0x3562, 0x5D72, 0x7654, 0, 0x7655, 0,
- 0xC666, 0xC667, 0x3768, 0xC668, 0, 0x3525, 0x5D70, 0,
-};
-static const unsigned short utf8_to_euc_E6B2[] = {
- 0, 0x5D6E, 0x5D6B, 0x4D60, 0, 0xC669, 0xC66A, 0xC66B,
- 0x4440, 0xC66C, 0, 0, 0x4659, 0x5D6C, 0, 0,
- 0x5D74, 0, 0x5D73, 0x3723, 0xC66D, 0xC66E, 0x322D, 0xC66F,
- 0xC670, 0x3A3B, 0x5D6D, 0x5D6F, 0xC671, 0, 0, 0xC672,
- 0, 0x4B57, 0x4274, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x4B77, 0, 0, 0x5D7C, 0,
- 0xC673, 0x5D7D, 0xC674, 0x324F, 0xC675, 0, 0, 0,
- 0x4A28, 0x4C7D, 0x5E21, 0x3C23, 0x3E42, 0x5D78, 0x5D7E, 0x3168,
-};
-static const unsigned short utf8_to_euc_E6B2_x0213[] = {
- 0, 0x5D6E, 0x5D6B, 0x4D60, 0xEE39, 0x7656, 0x7657, 0xC66B,
- 0x4440, 0xEE3A, 0, 0, 0x4659, 0x5D6C, 0, 0,
- 0x5D74, 0, 0x5D73, 0x3723, 0xEE3C, 0xEE3D, 0x322D, 0xEE3E,
- 0x7658, 0x3A3B, 0x5D6D, 0x5D6F, 0x7659, 0, 0, 0xC672,
- 0, 0x4B57, 0x4274, 0, 0, 0, 0, 0,
- 0, 0, 0x7653, 0x4B77, 0, 0xEE3F, 0x5D7C, 0,
- 0xC673, 0x5D7D, 0xC674, 0x324F, 0xC675, 0, 0, 0,
- 0x4A28, 0x4C7D, 0x5E21, 0x3C23, 0x3E42, 0x5D78, 0x5D7E, 0x3168,
-};
-static const unsigned short utf8_to_euc_E6B3[] = {
- 0, 0x3637, 0xC676, 0, 0x5D75, 0x5D7A, 0xC677, 0,
- 0, 0x4074, 0x4771, 0, 0x4867, 0xC678, 0, 0xC679,
- 0xC67A, 0xC67B, 0xC67C, 0x5D77, 0xC67D, 0x4B21, 0xC67E, 0x5D79,
- 0, 0x5E24, 0xC721, 0x5E22, 0xC722, 0x5D7B, 0, 0,
- 0xC723, 0x4B22, 0x4748, 0x3563, 0, 0x4525, 0, 0xC724,
- 0x436D, 0xC725, 0x5E25, 0xC726, 0xC727, 0, 0xC728, 0x5E23,
- 0x4259, 0x5D76, 0xC729, 0x314B, 0xC72A, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B3_x0213[] = {
- 0, 0x3637, 0xEE40, 0, 0x5D75, 0x5D7A, 0x765B, 0,
- 0, 0x4074, 0x4771, 0, 0x4867, 0xC678, 0, 0xC679,
- 0xEE41, 0xC67B, 0xC67C, 0x5D77, 0x765C, 0x4B21, 0xEE43, 0x5D79,
- 0, 0x5E24, 0xEE44, 0x5E22, 0xEE45, 0x5D7B, 0, 0,
- 0x765D, 0x4B22, 0x4748, 0x3563, 0, 0x4525, 0, 0xC724,
- 0x436D, 0xEE46, 0x5E25, 0x765E, 0xEE47, 0xEE48, 0x765F, 0x5E23,
- 0x4259, 0x5D76, 0xC729, 0x314B, 0xC72A, 0, 0, 0,
- 0, 0, 0, 0x765A, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B4[] = {
- 0, 0, 0, 0, 0xC72B, 0, 0, 0xC72C,
- 0, 0, 0xC72D, 0x4D4E, 0x5E30, 0, 0xC72E, 0xC72F,
- 0, 0xC730, 0x5E2F, 0xC731, 0, 0, 0, 0x4076,
- 0, 0x5E2C, 0xC732, 0x4D6C, 0, 0, 0x4636, 0x5E26,
- 0, 0, 0, 0, 0, 0x4445, 0xC733, 0xC734,
- 0xC735, 0x314C, 0x393F, 0x5E29, 0, 0, 0xC737, 0xC738,
- 0, 0xC739, 0x3D27, 0x5E2E, 0, 0x5E2D, 0x5E28, 0,
- 0x5E2B, 0xC73A, 0, 0x3368, 0xC73B, 0x5E2A, 0x4749, 0xC73C,
-};
-static const unsigned short utf8_to_euc_E6B4_x0213[] = {
- 0xEE4A, 0, 0, 0, 0x7661, 0, 0, 0xC72C,
- 0, 0, 0xEE4B, 0x4D4E, 0x5E30, 0, 0x7662, 0xC72F,
- 0, 0xC730, 0x5E2F, 0xC731, 0, 0, 0, 0x4076,
- 0, 0x5E2C, 0xC732, 0x4D6C, 0, 0, 0x4636, 0x5E26,
- 0, 0, 0, 0, 0xEE4C, 0x4445, 0xEE4D, 0xEE4E,
- 0xC735, 0x314C, 0x393F, 0x5E29, 0, 0, 0x7663, 0xEE50,
- 0, 0x7664, 0x3D27, 0x5E2E, 0xEE65, 0x5E2D, 0x5E28, 0,
- 0x5E2B, 0x7665, 0, 0x3368, 0xEE51, 0x5E2A, 0x4749, 0x7666,
-};
-static const unsigned short utf8_to_euc_E6B5[] = {
- 0, 0x4E2E, 0, 0, 0x3E74, 0x4075, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xC73D,
- 0, 0x5E36, 0x5E34, 0, 0x494D, 0, 0xC73E, 0xC73F,
- 0, 0xC740, 0, 0x5E31, 0x5E33, 0xC741, 0x313A, 0xC742,
- 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0xC743,
- 0xC744, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
- 0x3F3B, 0x5E35, 0, 0, 0xC745, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B5_x0213[] = {
- 0, 0x4E2E, 0, 0, 0x3E74, 0x4075, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xC73D,
- 0x7667, 0x5E36, 0x5E34, 0xEE52, 0x494D, 0, 0xEE53, 0xC73F,
- 0xEE54, 0xC740, 0, 0x5E31, 0x5E33, 0x7668, 0x313A, 0xC742,
- 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0,
- 0xEE55, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
- 0x3F3B, 0x5E35, 0, 0, 0xC745, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B6[] = {
- 0, 0, 0xC746, 0, 0, 0x5E3A, 0, 0xC747,
- 0x3E43, 0, 0, 0, 0x4D30, 0, 0x5E37, 0,
- 0, 0xC748, 0xC749, 0x5E32, 0xC74A, 0x5E38, 0xC74B, 0xC74C,
- 0xC74D, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xC74E, 0, 0xC74F, 0, 0, 0x3336,
- 0, 0, 0x3155, 0, 0xC750, 0x5E3E, 0, 0xC751,
- 0x5E41, 0xC752, 0, 0, 0x4E43, 0xC753, 0, 0xC754,
-};
-static const unsigned short utf8_to_euc_E6B6_x0213[] = {
- 0xEE56, 0xEE57, 0x766A, 0, 0, 0x5E3A, 0, 0x766B,
- 0x3E43, 0x766C, 0xEE58, 0, 0x4D30, 0xEE59, 0x5E37, 0,
- 0, 0xEE5A, 0xC749, 0x5E32, 0x766D, 0x5E38, 0, 0xC74C,
- 0xEE5B, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x766E, 0xEE61, 0x766F, 0, 0xEE62, 0x3336,
- 0, 0, 0x3155, 0, 0xEE63, 0x5E3E, 0, 0xC751,
- 0x5E41, 0xC752, 0, 0, 0x4E43, 0xC753, 0, 0x7670,
-};
-static const unsigned short utf8_to_euc_E6B7[] = {
- 0x4D64, 0, 0, 0, 0xC755, 0x5E48, 0x5E42, 0x5E3F,
- 0xC756, 0, 0xC757, 0x4E54, 0x5E45, 0, 0xC758, 0xC759,
- 0, 0x3D4A, 0x5E47, 0, 0, 0x5E4C, 0xC75A, 0,
- 0x4571, 0x5E4A, 0, 0xC75B, 0, 0xC75C, 0x5E44, 0xC75D,
- 0xC75E, 0x4338, 0xC75F, 0, 0x5E4B, 0xC760, 0x5E40, 0,
- 0x5E46, 0xC761, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0xC762,
- 0xC763, 0x3F3C, 0xF44C, 0x3D5F, 0xC764, 0x4A25, 0xC765, 0x3A2E,
- 0xF44B, 0x5E3B, 0x5E49, 0x453A, 0xC766, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B7_x0213[] = {
- 0x4D64, 0, 0xEE64, 0, 0x7671, 0x5E48, 0x5E42, 0x5E3F,
- 0xEE66, 0, 0xC757, 0x4E54, 0x5E45, 0, 0xEE67, 0xEE68,
- 0xEE69, 0x3D4A, 0x5E47, 0, 0, 0x5E4C, 0x7672, 0,
- 0x4571, 0x5E4A, 0x7673, 0x7674, 0, 0x7675, 0x5E44, 0xEE6A,
- 0xC75E, 0x4338, 0xC75F, 0, 0x5E4B, 0xC760, 0x5E40, 0,
- 0x5E46, 0xEE6B, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0xC762,
- 0xC763, 0x3F3C, 0, 0x3D5F, 0xC764, 0x4A25, 0xEE6C, 0x3A2E,
- 0, 0x5E3B, 0x5E49, 0x453A, 0x7676, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6B8[] = {
- 0xC767, 0, 0, 0, 0xC768, 0x4036, 0, 0x3369,
- 0x3A51, 0x3E44, 0x5E3D, 0x3D42, 0, 0, 0, 0,
- 0, 0, 0, 0x374C, 0, 0x5E3C, 0, 0,
- 0, 0x5E52, 0x3D6D, 0x383A, 0, 0x5E61, 0xC769, 0x5E5B,
- 0x3574, 0x454F, 0xC76A, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0xC76B,
- 0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
- 0, 0, 0xC76C, 0, 0, 0, 0xC76D, 0,
- 0x5E62, 0xC76E, 0x5E5D, 0xC76F, 0xC770, 0, 0x5E55, 0,
-};
-static const unsigned short utf8_to_euc_E6B8_x0213[] = {
- 0xC767, 0, 0, 0, 0xC768, 0x4036, 0, 0x3369,
- 0x3A51, 0x3E44, 0x5E3D, 0x3D42, 0, 0, 0, 0,
- 0, 0, 0, 0x374C, 0, 0x5E3C, 0, 0xEE5D,
- 0, 0x5E52, 0x3D6D, 0x383A, 0, 0x5E61, 0xEE6E, 0x5E5B,
- 0x3574, 0x454F, 0xEE6F, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0xEE70,
- 0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
- 0, 0, 0xEE72, 0, 0x7678, 0, 0xEE6D, 0,
- 0x5E62, 0, 0x5E5D, 0xC76F, 0xEE73, 0, 0x5E55, 0,
-};
-static const unsigned short utf8_to_euc_E6B9[] = {
- 0, 0, 0, 0x5E5C, 0xC771, 0xC772, 0, 0,
- 0xC773, 0xC774, 0x4C2B, 0xC775, 0, 0x5E5A, 0x5E5E, 0xC776,
- 0, 0xC777, 0xC778, 0xC779, 0xC77A, 0, 0x3850, 0xC77B,
- 0x3E45, 0, 0, 0x4339, 0xC77C, 0xC77D, 0xC77E, 0x5E54,
- 0, 0, 0xC821, 0xC822, 0, 0, 0, 0x4D2F,
- 0xC823, 0, 0, 0x5E57, 0, 0, 0x5E50, 0x4572,
- 0, 0, 0x5E53, 0xC824, 0, 0, 0x5E59, 0,
- 0, 0, 0, 0xC825, 0, 0xC826, 0x4F51, 0x3C3E,
-};
-static const unsigned short utf8_to_euc_E6B9_x0213[] = {
- 0, 0, 0, 0x5E5C, 0x7679, 0xC772, 0, 0,
- 0xEE74, 0xEE75, 0x4C2B, 0xEE76, 0xEE77, 0x5E5A, 0x5E5E, 0xEE78,
- 0, 0xEE79, 0xC778, 0xEE7A, 0xEE7B, 0, 0x3850, 0xEE7C,
- 0x3E45, 0, 0, 0x4339, 0x767A, 0xC77D, 0x767B, 0x5E54,
- 0, 0, 0xC821, 0xEE7D, 0, 0, 0, 0x4D2F,
- 0xC823, 0, 0, 0x5E57, 0, 0, 0x5E50, 0x4572,
- 0, 0, 0x5E53, 0xC824, 0, 0, 0x5E59, 0,
- 0, 0, 0, 0xC825, 0, 0xC826, 0x4F51, 0x3C3E,
-};
-static const unsigned short utf8_to_euc_E6BA[] = {
- 0x4B7E, 0, 0x5E63, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x482E, 0xC827, 0, 0x5E6F,
- 0x383B, 0, 0, 0xC828, 0, 0, 0x3D60, 0,
- 0x5E65, 0xC829, 0, 0, 0x4E2F, 0x3942, 0, 0x5E72,
- 0xC82A, 0, 0x306E, 0, 0, 0x5E70, 0, 0xC82B,
- 0, 0, 0x5E64, 0, 0, 0xC82C, 0xC82D, 0x5E6A,
- 0, 0xC82E, 0x5E6C, 0xC82F, 0, 0, 0x4D4F, 0x5E67,
- 0, 0, 0x452E, 0xC830, 0, 0x5E69, 0, 0xC831,
-};
-static const unsigned short utf8_to_euc_E6BA_x0213[] = {
- 0x4B7E, 0, 0x5E63, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x482E, 0xC827, 0, 0x5E6F,
- 0x383B, 0, 0, 0xEF21, 0, 0, 0x3D60, 0,
- 0x5E65, 0xC829, 0, 0, 0x4E2F, 0x3942, 0, 0x5E72,
- 0xC82A, 0, 0x306E, 0, 0, 0x5E70, 0, 0xEF22,
- 0, 0, 0x5E64, 0x767C, 0, 0xC82C, 0xC82D, 0x5E6A,
- 0, 0x767D, 0x5E6C, 0xC82F, 0xEF23, 0, 0x4D4F, 0x5E67,
- 0, 0, 0x452E, 0xC830, 0, 0x5E69, 0, 0xEF24,
-};
-static const unsigned short utf8_to_euc_E6BB[] = {
- 0xC832, 0xC833, 0x5E71, 0xC834, 0x5E6B, 0x4C47, 0, 0xC835,
- 0xC836, 0x5E66, 0xC837, 0x3C22, 0x5E7E, 0xC838, 0xC839, 0xC83A,
- 0, 0x336A, 0, 0x5E68, 0x5E6D, 0x5E6E, 0, 0,
- 0, 0, 0, 0, 0, 0x426C, 0x425A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xC83B, 0x5E76, 0xC83C, 0xC83D, 0x5E7C,
- 0, 0, 0x5E7A, 0, 0x4529, 0, 0, 0x5F23,
- 0x5E77, 0xC83E, 0, 0xC83F, 0, 0xC840, 0x5E78, 0x5E60,
-};
-static const unsigned short utf8_to_euc_E6BB_x0213[] = {
- 0xC832, 0x767E, 0x5E71, 0xEF25, 0x5E6B, 0x4C47, 0, 0x7721,
- 0xC836, 0x5E66, 0xEF26, 0x3C22, 0x5E7E, 0xC838, 0x7722, 0xC83A,
- 0, 0x336A, 0, 0x5E68, 0x5E6D, 0x5E6E, 0, 0,
- 0, 0xEF27, 0, 0, 0, 0x426C, 0x425A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xEF29, 0x5E76, 0xC83C, 0xC83D, 0x5E7C,
- 0, 0, 0x5E7A, 0, 0x4529, 0, 0, 0x5F23,
- 0x5E77, 0xEF2A, 0, 0xEF2B, 0, 0xC840, 0x5E78, 0x5E60,
-};
-static const unsigned short utf8_to_euc_E6BC[] = {
- 0, 0x3579, 0x493A, 0, 0xC841, 0, 0x3C3F, 0,
- 0xC842, 0x3977, 0xC843, 0, 0xC844, 0xC845, 0, 0x4F33,
- 0, 0x5E74, 0, 0x5F22, 0x3169, 0x4166, 0xC846, 0,
- 0xC847, 0, 0xC848, 0xC849, 0, 0, 0, 0,
- 0x4779, 0, 0x3441, 0x4E7A, 0, 0, 0xC84A, 0,
- 0, 0xC84B, 0xC84C, 0x4C21, 0x4452, 0xC853, 0, 0xC84D,
- 0xC84E, 0x5E7B, 0x5E7D, 0xC84F, 0, 0, 0xC850, 0,
- 0x4132, 0, 0, 0xC851, 0xC852, 0, 0x5F21, 0x5E79,
-};
-static const unsigned short utf8_to_euc_E6BC_x0213[] = {
- 0, 0x3579, 0x493A, 0, 0xC841, 0, 0x3C3F, 0,
- 0xC842, 0x3977, 0xEF2C, 0, 0xEF2D, 0xC845, 0, 0x4F33,
- 0x7723, 0x5E74, 0, 0x5F22, 0x3169, 0x4166, 0xC846, 0,
- 0xEF2E, 0, 0x7724, 0xC849, 0, 0, 0, 0,
- 0x4779, 0, 0x3441, 0x4E7A, 0, 0xEF2F, 0xC84A, 0,
- 0, 0xC84B, 0x7726, 0x4C21, 0x4452, 0xC853, 0, 0x7727,
- 0xC84E, 0x5E7B, 0x5E7D, 0x7728, 0, 0xEF28, 0xEF30, 0,
- 0x4132, 0, 0, 0xC851, 0xEF31, 0, 0x5F21, 0x5E79,
-};
-static const unsigned short utf8_to_euc_E6BD[] = {
- 0, 0x5E73, 0, 0, 0, 0x3443, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xC854,
- 0, 0xC855, 0xC856, 0xC857, 0x3769, 0, 0, 0xC858,
- 0x5F2F, 0xC859, 0xC85A, 0x5F2A, 0x4078, 0xC85B, 0xC85C, 0x3363,
- 0, 0xC85D, 0xC85E, 0, 0x3D61, 0, 0x5F33, 0,
- 0xC85F, 0, 0, 0, 0xC860, 0x5F2C, 0x442C, 0x5F29,
- 0x4459, 0, 0, 0, 0x5F4C, 0, 0, 0,
- 0x5F26, 0, 0x5F25, 0, 0x5F2E, 0xC861, 0xC862, 0,
-};
-static const unsigned short utf8_to_euc_E6BD_x0213[] = {
- 0, 0x5E73, 0, 0, 0, 0x3443, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xC854,
- 0, 0x7729, 0xEF33, 0xC857, 0x3769, 0, 0, 0xEF34,
- 0x5F2F, 0x772A, 0xEF35, 0x5F2A, 0x4078, 0xC85B, 0x772B, 0x3363,
- 0xEF36, 0x772C, 0x772D, 0, 0x3D61, 0, 0x5F33, 0,
- 0xEF37, 0, 0, 0, 0xC860, 0x5F2C, 0x442C, 0x5F29,
- 0x4459, 0, 0, 0, 0x5F4C, 0, 0, 0,
- 0x5F26, 0, 0x5F25, 0, 0x5F2E, 0xEF39, 0x772E, 0,
-};
-static const unsigned short utf8_to_euc_E6BE[] = {
- 0x5F28, 0x5F27, 0x5F2D, 0xC863, 0x4021, 0, 0x5F24, 0xC864,
- 0xC865, 0, 0, 0xC866, 0xC867, 0xC868, 0x5F30, 0,
- 0xC869, 0x5F31, 0xC86A, 0xC86B, 0xC86C, 0, 0xC86D, 0x3442,
- 0, 0, 0xC86E, 0, 0, 0, 0, 0xC86F,
- 0xC870, 0x5F36, 0, 0x5F35, 0x5F37, 0xC871, 0xC872, 0xC873,
- 0xC874, 0, 0x5F3A, 0, 0, 0, 0xC875, 0xC876,
- 0xC877, 0x4543, 0, 0x5F34, 0, 0xC878, 0xC879, 0,
- 0, 0x5F38, 0, 0, 0xC87A, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E6BE_x0213[] = {
- 0x5F28, 0x5F27, 0x5F2D, 0xC863, 0x4021, 0, 0x5F24, 0xC864,
- 0x772F, 0, 0, 0xC866, 0x7730, 0x7731, 0x5F30, 0,
- 0xEF3A, 0x5F31, 0xC86A, 0xC86B, 0x7732, 0, 0xEF3B, 0x3442,
- 0xEF38, 0, 0xC86E, 0, 0, 0, 0, 0xEF3D,
- 0x7733, 0x5F36, 0, 0x5F35, 0x5F37, 0xEF3E, 0xC872, 0x7734,
- 0xC874, 0, 0x5F3A, 0, 0, 0, 0xC875, 0xEF3F,
- 0xC877, 0x4543, 0, 0x5F34, 0, 0xEF41, 0x7735, 0,
- 0, 0x5F38, 0, 0, 0x7736, 0, 0xEF3C, 0,
-};
-static const unsigned short utf8_to_euc_E6BF[] = {
- 0x3763, 0x4279, 0x5F32, 0x473B, 0, 0xC87B, 0x5F39, 0xC87C,
- 0xC87D, 0, 0xC87E, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x5F3E, 0x5F3C, 0, 0,
- 0x5F3F, 0, 0xC921, 0x5F42, 0, 0, 0xC922, 0x5F3B,
- 0x396A, 0x4728, 0, 0, 0x5E39, 0, 0, 0,
- 0xC923, 0xC924, 0, 0x4D74, 0x5F3D, 0, 0x5F41, 0x4275,
- 0xC925, 0x5F40, 0, 0x5F2B, 0, 0xC926, 0x6F69, 0,
- 0, 0xC927, 0x5F45, 0, 0xC928, 0xC929, 0x5F49, 0,
-};
-static const unsigned short utf8_to_euc_E6BF_x0213[] = {
- 0x3763, 0x4279, 0x5F32, 0x473B, 0, 0xC87B, 0x5F39, 0x7737,
- 0xEF42, 0xEF43, 0x7738, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x5F3E, 0x5F3C, 0, 0,
- 0x5F3F, 0, 0xEF44, 0x5F42, 0, 0, 0xEF45, 0x5F3B,
- 0x396A, 0x4728, 0, 0, 0x5E39, 0, 0, 0,
- 0xC923, 0xEF46, 0, 0x4D74, 0x5F3D, 0, 0x5F41, 0x4275,
- 0x773A, 0x5F40, 0, 0x5F2B, 0, 0x773B, 0x6F69, 0,
- 0, 0x7739, 0x5F45, 0, 0xEF48, 0xC929, 0x5F49, 0,
-};
-static const unsigned short utf8_to_euc_E780[] = {
- 0xC92A, 0x5F47, 0, 0, 0, 0xC92B, 0xC92C, 0xC92D,
- 0, 0x5F43, 0, 0x5F44, 0, 0xC92E, 0, 0x5F48,
- 0, 0x5F46, 0, 0, 0, 0x494E, 0, 0xC92F,
- 0x5F4E, 0, 0x5F4B, 0x5F4A, 0, 0x5F4D, 0x4654, 0x5F4F,
- 0xC930, 0, 0, 0xC931, 0, 0, 0x4375, 0x426D,
- 0xF44D, 0, 0, 0, 0x4025, 0, 0, 0xC932,
- 0x5F50, 0, 0x5F52, 0, 0xC933, 0, 0, 0xC934,
- 0, 0xC935, 0, 0, 0xC936, 0, 0x5F51, 0,
-};
-static const unsigned short utf8_to_euc_E780_x0213[] = {
- 0xEF49, 0x5F47, 0, 0, 0, 0x773C, 0x773D, 0xEF4A,
- 0, 0x5F43, 0xEF4B, 0x5F44, 0, 0xC92E, 0, 0x5F48,
- 0, 0x5F46, 0, 0, 0, 0x494E, 0, 0xC92F,
- 0x5F4E, 0, 0x5F4B, 0x5F4A, 0, 0x5F4D, 0x4654, 0x5F4F,
- 0xC930, 0, 0, 0xEF4C, 0, 0, 0x4375, 0x426D,
- 0x773E, 0, 0, 0, 0x4025, 0, 0, 0xC932,
- 0x5F50, 0, 0x5F52, 0, 0xC933, 0, 0, 0xC934,
- 0, 0xEF4E, 0xEF4F, 0, 0xEF50, 0, 0x5F51, 0,
-};
-static const unsigned short utf8_to_euc_E781[] = {
- 0, 0, 0, 0xC937, 0xC938, 0, 0, 0,
- 0xC939, 0xC93A, 0xC93B, 0xC93C, 0x5E75, 0, 0xC941, 0,
- 0, 0x5F53, 0, 0, 0xC93D, 0xC93E, 0, 0,
- 0x4667, 0, 0, 0, 0, 0xC93F, 0xC940, 0,
- 0, 0, 0, 0x5F54, 0xC942, 0xC943, 0, 0,
- 0, 0, 0, 0x3250, 0xC944, 0, 0xC945, 0x4574,
- 0x3325, 0, 0, 0, 0, 0xC946, 0xC947, 0,
- 0x3564, 0, 0, 0, 0x3C5E, 0x3A52, 0xC948, 0,
-};
-static const unsigned short utf8_to_euc_E781_x0213[] = {
- 0, 0, 0, 0xEF51, 0xC938, 0, 0, 0xEF52,
- 0xC939, 0xC93A, 0x773F, 0xEF53, 0x5E75, 0, 0x7742, 0,
- 0, 0x5F53, 0, 0, 0xEF55, 0xC93E, 0, 0,
- 0x4667, 0, 0, 0, 0, 0x7740, 0x7741, 0,
- 0, 0, 0, 0x5F54, 0x7743, 0xEF56, 0, 0,
- 0, 0xEF57, 0, 0x3250, 0xEF58, 0, 0xEF59, 0x4574,
- 0x3325, 0, 0, 0, 0, 0x7744, 0xEF5A, 0,
- 0x3564, 0, 0, 0, 0x3C5E, 0x3A52, 0xEF5B, 0,
-};
-static const unsigned short utf8_to_euc_E782[] = {
- 0, 0xC949, 0, 0, 0, 0xC94A, 0xC94B, 0,
- 0, 0x4F27, 0x3F66, 0, 0, 0, 0x316A, 0,
- 0, 0, 0x5F56, 0, 0xC94C, 0xC94D, 0xC94E, 0xC94F,
- 0xC950, 0x5F55, 0, 0xC951, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xC952, 0, 0, 0,
- 0, 0, 0, 0xC953, 0x5F59, 0x433A, 0x5F5C, 0x5F57,
- 0xC954, 0xC955, 0, 0x5F5B, 0xC956, 0, 0, 0xC957,
- 0x5F5A, 0x4540, 0x3059, 0xF42E, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E782_x0213[] = {
- 0, 0xEF5C, 0, 0, 0, 0x7745, 0xEF5D, 0,
- 0, 0x4F27, 0x3F66, 0, 0, 0, 0x316A, 0,
- 0, 0, 0x5F56, 0, 0xC94C, 0xEF5E, 0xC94E, 0xEF5F,
- 0xC950, 0x5F55, 0, 0xC951, 0, 0, 0, 0xEF62,
- 0, 0, 0, 0, 0x7746, 0, 0, 0,
- 0, 0, 0, 0x7747, 0x5F59, 0x433A, 0x5F5C, 0x5F57,
- 0xC954, 0xEF63, 0, 0x5F5B, 0xC956, 0, 0, 0x7748,
- 0x5F5A, 0x4540, 0x3059, 0xEF60, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E783[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x4E75, 0, 0xC958, 0x5F5E, 0, 0, 0, 0x3128,
- 0, 0xC959, 0, 0xC95A, 0xC95B, 0xC95C, 0xC95D, 0,
- 0xC95E, 0x5F60, 0, 0, 0xC95F, 0x5F5F, 0, 0x5F5D,
- 0, 0, 0, 0, 0xC960, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x5F58, 0, 0, 0, 0, 0, 0,
- 0, 0x4B23, 0xC961, 0, 0, 0x5F62, 0, 0,
-};
-static const unsigned short utf8_to_euc_E783_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x4E75, 0, 0xEF66, 0x5F5E, 0, 0, 0, 0x3128,
- 0, 0xEF67, 0, 0xEF68, 0x7749, 0xC95C, 0xC95D, 0,
- 0x774A, 0x5F60, 0, 0, 0xEF69, 0x5F5F, 0, 0x5F5D,
- 0, 0, 0, 0, 0x774B, 0, 0, 0,
- 0, 0, 0, 0, 0xEF65, 0, 0, 0,
- 0, 0x5F58, 0, 0, 0, 0, 0, 0,
- 0, 0x4B23, 0xC961, 0, 0, 0x5F62, 0, 0,
-};
-static const unsigned short utf8_to_euc_E784[] = {
- 0, 0, 0, 0xC962, 0xC963, 0xC964, 0xC965, 0xC966,
- 0, 0x5F61, 0, 0xC967, 0xC968, 0, 0, 0xC969,
- 0, 0, 0, 0, 0x316B, 0, 0, 0,
- 0, 0x5F64, 0x4A32, 0, 0x5F63, 0, 0xC96A, 0,
- 0xC96B, 0x4C35, 0, 0, 0, 0, 0x3E47, 0,
- 0, 0, 0, 0xC96C, 0, 0xC96D, 0, 0xC96E,
- 0xC96F, 0xC970, 0, 0, 0, 0, 0x4133, 0,
- 0xC971, 0, 0, 0, 0x3E46, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E784_x0213[] = {
- 0, 0, 0, 0xEF6A, 0xEF6B, 0xC964, 0xEF6C, 0xEF6D,
- 0xEF6E, 0x5F61, 0, 0xC967, 0xEF6F, 0, 0, 0x774C,
- 0, 0, 0, 0, 0x316B, 0, 0, 0,
- 0, 0x5F64, 0x4A32, 0, 0x5F63, 0, 0x774E, 0,
- 0x774F, 0x4C35, 0, 0, 0, 0, 0x3E47, 0,
- 0, 0, 0, 0x774D, 0, 0xC96D, 0x7750, 0xEF71,
- 0x7751, 0xEF72, 0, 0, 0, 0, 0x4133, 0,
- 0xC971, 0, 0, 0, 0x3E46, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E785[] = {
- 0, 0xC972, 0, 0, 0, 0xC973, 0xC974, 0xC975,
- 0, 0x4E7B, 0xC976, 0xC977, 0x5F6A, 0, 0x4079, 0,
- 0xC978, 0, 0xC979, 0, 0, 0x5F66, 0x5F6B, 0xC97A,
- 0, 0x316C, 0xC97B, 0, 0xC97C, 0, 0xC97D, 0,
- 0xC97E, 0, 0x5F69, 0, 0x4761, 0x5F65, 0x5F68, 0x3E48,
- 0xCA21, 0x4851, 0, 0, 0x5F6C, 0, 0x3C51, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xCA22, 0, 0, 0, 0x407A, 0, 0,
-};
-static const unsigned short utf8_to_euc_E785_x0213[] = {
- 0, 0xC972, 0, 0, 0, 0xC973, 0x7752, 0x7753,
- 0, 0x4E7B, 0xEF74, 0xC977, 0x5F6A, 0, 0x4079, 0,
- 0xEF73, 0x7754, 0x7756, 0xEF75, 0, 0x5F66, 0x5F6B, 0xC97A,
- 0, 0x316C, 0xC97B, 0, 0x7757, 0, 0xEF76, 0,
- 0x7758, 0, 0x5F69, 0, 0x4761, 0x5F65, 0x5F68, 0x3E48,
- 0x7759, 0x4851, 0, 0, 0x5F6C, 0, 0x3C51, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xCA22, 0, 0, 0, 0x407A, 0, 0,
-};
-static const unsigned short utf8_to_euc_E786[] = {
- 0xCA23, 0, 0, 0, 0x5F6F, 0xCA24, 0, 0xCA25,
- 0x5F67, 0, 0x3727, 0, 0xCA26, 0, 0, 0x5F6D,
- 0, 0, 0xCA27, 0, 0x4D50, 0x5F70, 0, 0,
- 0, 0x7426, 0xCA28, 0xCA29, 0, 0, 0, 0x3D4F,
- 0xCA2A, 0, 0xCA2B, 0, 0, 0, 0, 0,
- 0x5F71, 0, 0, 0, 0x5F72, 0, 0, 0xCA2C,
- 0xCA2D, 0x472E, 0xCA2E, 0xCA2F, 0, 0, 0, 0,
- 0, 0x5F74, 0xCA30, 0, 0, 0, 0x5F75, 0xCA31,
-};
-static const unsigned short utf8_to_euc_E786_x0213[] = {
- 0xEF79, 0, 0, 0, 0x5F6F, 0x775B, 0, 0x775C,
- 0x5F67, 0, 0x3727, 0, 0xCA26, 0, 0, 0x5F6D,
- 0, 0, 0x775D, 0, 0x4D50, 0x5F70, 0xEF78, 0,
- 0, 0x7426, 0xCA28, 0xEF7A, 0, 0, 0, 0x3D4F,
- 0xEF7B, 0, 0xEF7C, 0, 0, 0, 0, 0,
- 0x5F71, 0, 0, 0, 0x5F72, 0, 0xEF7D, 0xEF7E,
- 0xCA2D, 0x472E, 0xCA2E, 0xF021, 0, 0, 0, 0,
- 0, 0x5F74, 0x775F, 0, 0, 0, 0x5F75, 0xCA31,
-};
-static const unsigned short utf8_to_euc_E787[] = {
- 0xCA32, 0xCA33, 0, 0x4733, 0xCA34, 0, 0, 0,
- 0x4575, 0x5F77, 0, 0xCA35, 0xCA36, 0, 0x5F79, 0,
- 0x4E55, 0, 0x5F76, 0xCA37, 0x5F78, 0x316D, 0xCA38, 0x5F73,
- 0, 0xCA39, 0xCA3A, 0, 0xCA3B, 0, 0, 0x535B,
- 0x5F7A, 0, 0, 0, 0, 0x4167, 0x3B38, 0x5F7C,
- 0, 0, 0, 0, 0x5F7B, 0x3F24, 0x5259, 0,
- 0, 0, 0, 0, 0, 0x5F7D, 0, 0,
- 0xCA3C, 0x6021, 0, 0x5F6E, 0x5F7E, 0, 0xCA3D, 0x6022,
-};
-static const unsigned short utf8_to_euc_E787_x0213[] = {
- 0xCA32, 0x775E, 0, 0x4733, 0x7760, 0, 0, 0,
- 0x4575, 0x5F77, 0, 0xF023, 0xCA36, 0, 0x5F79, 0,
- 0x4E55, 0, 0x5F76, 0xF024, 0x5F78, 0x316D, 0xCA38, 0x5F73,
- 0, 0xF025, 0xCA3A, 0, 0xF026, 0, 0, 0x535B,
- 0x5F7A, 0, 0, 0, 0, 0x4167, 0x3B38, 0x5F7C,
- 0, 0, 0, 0, 0x5F7B, 0x3F24, 0x5259, 0,
- 0, 0, 0, 0, 0, 0x5F7D, 0, 0,
- 0xCA3C, 0x6021, 0, 0x5F6E, 0x5F7E, 0, 0x7761, 0x6022,
-};
-static const unsigned short utf8_to_euc_E788[] = {
- 0xCA3E, 0, 0, 0, 0, 0, 0x477A, 0xCA3F,
- 0xCA40, 0xCA41, 0, 0, 0, 0x6023, 0, 0,
- 0x6024, 0, 0, 0xCA42, 0, 0, 0, 0xCA43,
- 0, 0, 0xCA44, 0x6025, 0, 0xCA45, 0, 0xCA46,
- 0, 0, 0, 0, 0xCA47, 0, 0, 0,
- 0x6026, 0, 0x445E, 0xCA48, 0x6028, 0x6027, 0, 0xCA49,
- 0x6029, 0, 0x602A, 0, 0xCA4A, 0x3C5F, 0x4963, 0,
- 0xCA4B, 0xCA4C, 0x4C6C, 0x602B, 0x602C, 0x4156, 0x3C24, 0x602D,
-};
-static const unsigned short utf8_to_euc_E788_x0213[] = {
- 0x7762, 0, 0, 0, 0, 0, 0x477A, 0xF027,
- 0xCA40, 0xCA41, 0, 0, 0, 0x6023, 0, 0,
- 0x6024, 0, 0, 0xCA42, 0, 0x7763, 0, 0xCA43,
- 0, 0, 0xCA44, 0x6025, 0, 0xCA45, 0, 0xCA46,
- 0, 0, 0, 0, 0xCA47, 0, 0, 0,
- 0x6026, 0, 0x445E, 0xF02A, 0x6028, 0x6027, 0, 0xCA49,
- 0x6029, 0, 0x602A, 0, 0xF02B, 0x3C5F, 0x4963, 0,
- 0xF02C, 0xF02D, 0x4C6C, 0x602B, 0x602C, 0x4156, 0x3C24, 0x602D,
-};
-static const unsigned short utf8_to_euc_E789[] = {
- 0x602E, 0xCA4D, 0xCA4E, 0xCA4F, 0, 0xCA50, 0x602F, 0x4A52,
- 0x4847, 0, 0, 0x6030, 0x4757, 0, 0xCA51, 0xCA52,
- 0xCA53, 0, 0x442D, 0xCA54, 0, 0xCA55, 0xCA56, 0,
- 0x6031, 0x3267, 0xCA57, 0x356D, 0xCA58, 0x4C46, 0xCA59, 0x4C36,
- 0xCA5A, 0x3234, 0x4F34, 0xCA5B, 0, 0, 0, 0x4B52,
- 0xCA5C, 0x4A2A, 0, 0xCA5D, 0, 0, 0xCA5E, 0xCA5F,
- 0, 0xCA60, 0x4037, 0, 0x6032, 0, 0, 0xCA61,
- 0xCA62, 0x4643, 0, 0xCA63, 0xCA64, 0x3823, 0x6033, 0xCA65,
-};
-static const unsigned short utf8_to_euc_E789_x0213[] = {
- 0x602E, 0xCA4D, 0xF02F, 0xCA4F, 0, 0xCA50, 0x602F, 0x4A52,
- 0x4847, 0, 0, 0x6030, 0x4757, 0, 0xCA51, 0xCA52,
- 0xCA53, 0, 0x442D, 0xF030, 0, 0x7764, 0x7765, 0xF031,
- 0x6031, 0x3267, 0xCA57, 0x356D, 0xCA58, 0x4C46, 0xCA59, 0x4C36,
- 0xCA5A, 0x3234, 0x4F34, 0xF032, 0, 0, 0, 0x4B52,
- 0xCA5C, 0x4A2A, 0, 0xCA5D, 0, 0, 0xF034, 0xF035,
- 0, 0xCA60, 0x4037, 0, 0x6032, 0, 0, 0xCA61,
- 0xF036, 0x4643, 0, 0xCA63, 0xCA64, 0x3823, 0x6033, 0xF037,
-};
-static const unsigned short utf8_to_euc_E78A[] = {
- 0x3A54, 0x6035, 0x6034, 0, 0xCA66, 0, 0, 0x6036,
- 0, 0xCA67, 0, 0, 0, 0xCA68, 0xCA69, 0,
- 0, 0, 0x6037, 0xCA6A, 0, 0, 0x6038, 0,
- 0, 0, 0, 0xCA6B, 0, 0, 0, 0,
- 0x353E, 0, 0x6039, 0, 0, 0, 0, 0x603A,
- 0xCA6C, 0, 0, 0, 0x3824, 0xCA6D, 0xCA6E, 0x4848,
- 0, 0xCA6F, 0x603C, 0, 0xCA70, 0, 0x3E75, 0,
- 0, 0x603B, 0, 0, 0, 0, 0xCA71, 0,
-};
-static const unsigned short utf8_to_euc_E78A_x0213[] = {
- 0x3A54, 0x6035, 0x6034, 0, 0xCA66, 0, 0, 0x6036,
- 0, 0xCA67, 0, 0, 0, 0x7767, 0xF038, 0,
- 0, 0, 0x6037, 0xCA6A, 0, 0, 0x6038, 0,
- 0, 0, 0, 0x7768, 0, 0, 0, 0,
- 0x353E, 0, 0x6039, 0, 0, 0, 0, 0x603A,
- 0xCA6C, 0, 0, 0, 0x3824, 0xF03A, 0xF03B, 0x4848,
- 0xF03C, 0xF03D, 0x603C, 0, 0xCA70, 0, 0x3E75, 0,
- 0, 0x603B, 0, 0, 0, 0, 0x7769, 0,
-};
-static const unsigned short utf8_to_euc_E78B[] = {
- 0, 0xCA72, 0x3638, 0x603D, 0x603F, 0, 0x603E, 0xCA73,
- 0, 0xCA74, 0, 0, 0xCA75, 0, 0x6040, 0,
- 0x3851, 0, 0x6041, 0, 0, 0xCA76, 0xCA77, 0x3669,
- 0xCA78, 0x4140, 0, 0x397D, 0, 0, 0, 0xCA79,
- 0x6043, 0x6044, 0x6042, 0, 0, 0xCA7A, 0, 0,
- 0, 0x3C6D, 0, 0, 0x4648, 0x3639, 0, 0,
- 0, 0, 0, 0xCA7B, 0xCA7C, 0, 0, 0x6046,
- 0x432C, 0x6045, 0xCA7D, 0xCA7E, 0x4F35, 0x4762, 0xCB21, 0,
-};
-static const unsigned short utf8_to_euc_E78B_x0213[] = {
- 0x776A, 0xF03E, 0x3638, 0x603D, 0x603F, 0, 0x603E, 0xCA73,
- 0, 0xCA74, 0, 0, 0xF040, 0, 0x6040, 0,
- 0x3851, 0, 0x6041, 0, 0, 0xCA76, 0xCA77, 0x3669,
- 0xCA78, 0x4140, 0, 0x397D, 0, 0, 0, 0xCA79,
- 0x6043, 0x6044, 0x6042, 0, 0, 0xCA7A, 0, 0,
- 0, 0x3C6D, 0, 0, 0x4648, 0x3639, 0, 0,
- 0, 0, 0, 0xF043, 0xCA7C, 0, 0, 0x6046,
- 0x432C, 0x6045, 0xF044, 0x776B, 0x4F35, 0x4762, 0xCB21, 0,
-};
-static const unsigned short utf8_to_euc_E78C[] = {
- 0, 0, 0xCB22, 0, 0xCB23, 0xCB24, 0, 0xCB25,
- 0, 0, 0x6049, 0xCB26, 0, 0xCB27, 0, 0,
- 0, 0, 0xCB28, 0xCB29, 0, 0, 0x604B, 0x6048,
- 0xCB2A, 0xCB2B, 0, 0x4C54, 0x604A, 0x604C, 0xCB2C, 0x4E44,
- 0, 0, 0xCB2D, 0, 0xCB2E, 0x6050, 0, 0xCB2F,
- 0xCB30, 0x604F, 0x4376, 0x472D, 0xCB31, 0, 0x3825, 0x604E,
- 0, 0xCB32, 0xCB33, 0, 0x604D, 0xCB34, 0x4D31, 0x4D32,
- 0, 0, 0xCB35, 0xCB36, 0, 0xCB37, 0x6051, 0x316E,
-};
-static const unsigned short utf8_to_euc_E78C_x0213[] = {
- 0, 0, 0xCB22, 0, 0xCB23, 0xCB24, 0, 0xF045,
- 0, 0, 0x6049, 0xCB26, 0, 0xCB27, 0, 0,
- 0, 0, 0xF046, 0xCB29, 0, 0, 0x604B, 0x6048,
- 0xF047, 0xF048, 0, 0x4C54, 0x604A, 0x604C, 0xCB2C, 0x4E44,
- 0, 0, 0xCB2D, 0, 0, 0x6050, 0, 0x776D,
- 0x776E, 0x604F, 0x4376, 0x472D, 0xF04B, 0, 0x3825, 0x604E,
- 0, 0xF04C, 0xCB33, 0xF04D, 0x604D, 0xCB34, 0x4D31, 0x4D32,
- 0, 0xF04A, 0xCB35, 0xCB36, 0, 0xF04E, 0x6051, 0x316E,
-};
-static const unsigned short utf8_to_euc_E78D[] = {
- 0, 0, 0, 0xCB38, 0x3976, 0x3B62, 0, 0,
- 0, 0, 0, 0, 0, 0xCB39, 0x6052, 0x6053,
- 0xCB3A, 0, 0xCB3B, 0, 0, 0, 0xCB3C, 0x6055,
- 0xCB3D, 0, 0, 0, 0, 0xCB3E, 0xCB3F, 0xCB40,
- 0xCB41, 0, 0, 0x3D43, 0, 0, 0xCB42, 0xCB43,
- 0x6057, 0xCB44, 0x6056, 0xCB45, 0xCB46, 0, 0xCB47, 0xCB48,
- 0x6058, 0xCB49, 0x334D, 0, 0, 0x605A, 0, 0xCB4A,
- 0x6059, 0xCB4B, 0x605C, 0x605B, 0xCB4C, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E78D_x0213[] = {
- 0, 0, 0, 0xCB38, 0x3976, 0x3B62, 0, 0,
- 0, 0, 0, 0, 0, 0xCB39, 0x6052, 0x6053,
- 0x7770, 0, 0xF04F, 0, 0, 0, 0xCB3C, 0x6055,
- 0xCB3D, 0, 0, 0, 0, 0xCB3E, 0xCB3F, 0xCB40,
- 0xCB41, 0, 0, 0x3D43, 0, 0, 0x7771, 0xCB43,
- 0x6057, 0xCB44, 0x6056, 0xF051, 0xF052, 0, 0xF054, 0xF055,
- 0x6058, 0xF056, 0x334D, 0, 0, 0x605A, 0, 0xF057,
- 0x6059, 0xCB4B, 0x605C, 0x605B, 0x7772, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E78E[] = {
- 0xCB4D, 0xCB4E, 0, 0xCB4F, 0x383C, 0xCB50, 0xCB51, 0x4E28,
- 0, 0x364C, 0, 0x3226, 0, 0, 0xCB52, 0,
- 0xCB53, 0, 0, 0xCB54, 0, 0xCB55, 0x366A, 0xCB56,
- 0xCB57, 0, 0, 0, 0xCB58, 0, 0xCB59, 0xCB5A,
- 0xCB5B, 0, 0xCB5C, 0, 0, 0xCB5D, 0xCB5E, 0,
- 0, 0x3461, 0xCB5F, 0xCB60, 0, 0xCB61, 0, 0,
- 0, 0, 0x4E68, 0x605E, 0, 0xCB62, 0, 0xCB63,
- 0, 0xCB64, 0, 0x6060, 0xCB65, 0xCB66, 0, 0xCB67,
-};
-static const unsigned short utf8_to_euc_E78E_x0213[] = {
- 0xCB4D, 0xF058, 0, 0xCB4F, 0x383C, 0xF059, 0xCB51, 0x4E28,
- 0, 0x364C, 0xF05A, 0x3226, 0, 0, 0xCB52, 0,
- 0xCB53, 0, 0, 0xCB54, 0xF05B, 0x7773, 0x366A, 0xCB56,
- 0xF05C, 0, 0, 0, 0xF05D, 0, 0xF05E, 0x7774,
- 0x7775, 0, 0x7776, 0, 0, 0xF05F, 0x7777, 0,
- 0xF060, 0x3461, 0xCB5F, 0x7778, 0, 0xCB61, 0, 0,
- 0, 0, 0x4E68, 0x605E, 0, 0xF061, 0, 0xF062,
- 0, 0xF063, 0, 0x6060, 0xF064, 0, 0, 0xF065,
-};
-static const unsigned short utf8_to_euc_E78F[] = {
- 0x6061, 0, 0x3251, 0, 0, 0xCB68, 0xCB69, 0,
- 0x605D, 0xCB6A, 0x3B39, 0xCB6B, 0xCB6C, 0x4441, 0x605F, 0xCB6D,
- 0, 0, 0xCB6E, 0xCB6F, 0, 0, 0xCB70, 0,
- 0, 0xCB71, 0, 0, 0, 0xCB72, 0x6064, 0,
- 0x3C6E, 0xCB73, 0, 0xCB74, 0, 0x6062, 0xCB75, 0xCB76,
- 0, 0xCB77, 0x373E, 0, 0, 0x4849, 0x6063, 0,
- 0, 0x607E, 0, 0, 0xCB78, 0xCB79, 0, 0xCB7A,
- 0x6069, 0xCB7B, 0xCB7C, 0xCB7D, 0, 0xCB7E, 0x383D, 0xCC21,
-};
-static const unsigned short utf8_to_euc_E78F_x0213[] = {
- 0x6061, 0, 0x3251, 0, 0, 0xF066, 0xCB69, 0,
- 0x605D, 0x7779, 0x3B39, 0xF067, 0xCB6C, 0x4441, 0x605F, 0x777A,
- 0, 0, 0, 0xCB6F, 0, 0, 0x777B, 0,
- 0, 0x777C, 0, 0, 0, 0xCB72, 0x6064, 0,
- 0x3C6E, 0xF068, 0, 0x777D, 0, 0x6062, 0xCB75, 0xF069,
- 0, 0x777E, 0x373E, 0, 0, 0x4849, 0x6063, 0,
- 0, 0x607E, 0, 0, 0xCB78, 0, 0, 0xCB7A,
- 0x6069, 0xF06A, 0xF06C, 0xCB7D, 0, 0xCB7E, 0x383D, 0xCC21,
-};
-static const unsigned short utf8_to_euc_E790[] = {
- 0xCC22, 0xCC23, 0, 0x3565, 0xCC24, 0x6066, 0x4D7D, 0xCC25,
- 0, 0x4E30, 0xCC26, 0, 0, 0, 0, 0,
- 0, 0xCC27, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xCC28, 0xCC29, 0, 0, 0, 0,
- 0, 0, 0x4276, 0, 0xCC2A, 0x6068, 0xCC2B, 0,
- 0xCC2C, 0xCC2D, 0xCC2E, 0xCC2F, 0xCC30, 0xCC31, 0xCC32, 0xCC33,
- 0xCC34, 0xCC35, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
- 0, 0xCC36, 0x606B, 0, 0, 0, 0, 0x606D,
-};
-static const unsigned short utf8_to_euc_E790_x0213[] = {
- 0xCC22, 0xF06D, 0, 0x3565, 0xCC24, 0x6066, 0x4D7D, 0x7821,
- 0, 0x4E30, 0x7822, 0, 0, 0, 0, 0,
- 0, 0xCC27, 0, 0xF06B, 0, 0, 0, 0,
- 0, 0, 0x7823, 0x7824, 0, 0, 0, 0,
- 0, 0, 0x4276, 0, 0xF06E, 0x6068, 0x7826, 0,
- 0x7827, 0, 0x7828, 0x7829, 0x782A, 0xCC31, 0x782B, 0x782C,
- 0x782D, 0xF06F, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
- 0, 0xF070, 0x606B, 0, 0, 0, 0, 0x606D,
-};
-static const unsigned short utf8_to_euc_E791[] = {
- 0xCC37, 0x6070, 0, 0xCC38, 0xCC39, 0, 0xCC3A, 0xCC3B,
- 0, 0, 0, 0xCC3C, 0, 0xCC3D, 0, 0,
- 0, 0xCC3E, 0xCC3F, 0, 0, 0x606C, 0, 0xCC40,
- 0, 0x606F, 0x386A, 0x314D, 0x6071, 0xCC41, 0x3F70, 0x606E,
- 0x4E5C, 0, 0xCC42, 0x6074, 0x7424, 0, 0xCC43, 0xCC44,
- 0xCC45, 0x6072, 0x6075, 0xCC46, 0, 0xCC47, 0xCC48, 0x6067,
- 0x6073, 0xCC49, 0xCC4A, 0x3A3C, 0, 0, 0x6076, 0,
- 0, 0, 0, 0, 0, 0, 0x6077, 0,
-};
-static const unsigned short utf8_to_euc_E791_x0213[] = {
- 0xF072, 0x6070, 0, 0xF073, 0x782E, 0, 0x782F, 0x7830,
- 0, 0, 0, 0x7831, 0, 0xF074, 0, 0,
- 0, 0xCC3E, 0xF075, 0xF071, 0, 0x606C, 0, 0x7832,
- 0, 0x606F, 0x386A, 0x314D, 0x6071, 0xF076, 0x3F70, 0x606E,
- 0x4E5C, 0, 0x7833, 0x6074, 0x7424, 0, 0xCC43, 0xCC44,
- 0xCC45, 0x6072, 0x6075, 0x7834, 0, 0x7835, 0xCC48, 0x6067,
- 0x6073, 0xF077, 0xCC4A, 0x3A3C, 0, 0, 0x6076, 0,
- 0, 0, 0, 0, 0, 0, 0x6077, 0,
-};
-static const unsigned short utf8_to_euc_E792[] = {
- 0xCC4B, 0xCC4C, 0, 0x4D7E, 0, 0xCC4D, 0xCC4E, 0xCC4F,
- 0, 0xCC50, 0, 0x6078, 0, 0, 0, 0xCC51,
- 0xCC52, 0xCC53, 0xCC54, 0, 0, 0, 0, 0,
- 0xCC55, 0xCC56, 0xCC57, 0, 0xCC58, 0, 0x6079, 0xCC59,
- 0xCC5A, 0xCC5B, 0x6065, 0xCC5C, 0, 0, 0xCC5D, 0x607A,
- 0xCC5E, 0xCC5F, 0xCC60, 0xCC61, 0, 0, 0xCC62, 0xCC63,
- 0x3444, 0xCC64, 0xCC65, 0, 0, 0xCC66, 0, 0,
- 0, 0xCC67, 0, 0xCC68, 0, 0x3C25, 0, 0xCC69,
-};
-static const unsigned short utf8_to_euc_E792_x0213[] = {
- 0xCC4B, 0xF078, 0, 0x4D7E, 0, 0xF079, 0x7836, 0x7837,
- 0xF07A, 0x7838, 0, 0x6078, 0, 0, 0, 0xCC51,
- 0x783D, 0xCC53, 0xF07C, 0, 0, 0, 0, 0xF07D,
- 0x7839, 0xF07E, 0xCC57, 0, 0x783A, 0, 0x6079, 0x783B,
- 0xF121, 0xF122, 0x6065, 0x783C, 0, 0xF123, 0x783E, 0x607A,
- 0x783F, 0x7840, 0xF124, 0xF125, 0, 0, 0xCC62, 0xCC63,
- 0x3444, 0xCC64, 0xCC65, 0, 0, 0x7841, 0, 0,
- 0, 0xF126, 0xF128, 0xF127, 0, 0x3C25, 0, 0x7842,
-};
-static const unsigned short utf8_to_euc_E793[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xCC6A, 0xCC6B, 0x607B, 0, 0xCC6C, 0, 0, 0x607C,
- 0xCC6D, 0, 0, 0xCC6E, 0x607D, 0, 0, 0,
- 0xCC6F, 0, 0xCC70, 0xCC71, 0x313B, 0, 0xCC72, 0xCC73,
- 0x6121, 0, 0x493B, 0x6122, 0xCC74, 0, 0x3424, 0x6123,
- 0xCC75, 0x6124, 0xCC76, 0xCC77, 0, 0, 0x6125, 0xCC78,
- 0x6127, 0x6128, 0x6126, 0, 0xCC79, 0, 0x4953, 0x612A,
- 0x6129, 0, 0xCC7A, 0xCC7B, 0xCC7C, 0, 0, 0xCC7D,
-};
-static const unsigned short utf8_to_euc_E793_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x7843, 0x7844, 0x607B, 0, 0xCC6C, 0, 0, 0x607C,
- 0xCC6D, 0, 0, 0xCC6E, 0x607D, 0, 0xF129, 0,
- 0xF12A, 0, 0x7845, 0xCC71, 0x313B, 0, 0xF12B, 0xCC73,
- 0x6121, 0, 0x493B, 0x6122, 0xCC74, 0, 0x3424, 0x6123,
- 0xCC75, 0x6124, 0xCC76, 0xF12D, 0, 0, 0x6125, 0xF12C,
- 0x6127, 0x6128, 0x6126, 0, 0xCC79, 0, 0x4953, 0x612A,
- 0x6129, 0, 0xF12F, 0xCC7B, 0xCC7C, 0, 0, 0x7846,
-};
-static const unsigned short utf8_to_euc_E794[] = {
- 0, 0xF450, 0, 0x612C, 0x612B, 0x612D, 0xCC7E, 0,
- 0, 0, 0, 0, 0x612E, 0x6130, 0x612F, 0,
- 0, 0x3979, 0xCD21, 0x6132, 0, 0x6131, 0xCD22, 0xCD23,
- 0x3445, 0, 0x3F53, 0, 0x453C, 0, 0x6133, 0x4038,
- 0xCD24, 0xCD25, 0, 0x3B3A, 0xCD26, 0x3179, 0x6134, 0xCD27,
- 0x4D51, 0xCD28, 0xCD29, 0x4A63, 0x6135, 0, 0, 0xCD2A,
- 0x4544, 0x4D33, 0x3943, 0x3F3D, 0, 0, 0xCD2B, 0x434B,
- 0x5234, 0xCD2C, 0x442E, 0x3268, 0x6136, 0xCD2D, 0xCD2E, 0xCD2F,
-};
-static const unsigned short utf8_to_euc_E794_x0213[] = {
- 0, 0x7847, 0, 0x612C, 0x612B, 0x612D, 0xCC7E, 0,
- 0, 0, 0, 0, 0x612E, 0x6130, 0x612F, 0,
- 0, 0x3979, 0xCD21, 0x6132, 0, 0x6131, 0xCD22, 0x7848,
- 0x3445, 0, 0x3F53, 0, 0x453C, 0, 0x6133, 0x4038,
- 0xF131, 0xCD25, 0, 0x3B3A, 0xF132, 0x3179, 0x6134, 0xCD27,
- 0x4D51, 0xCD28, 0xF133, 0x4A63, 0x6135, 0, 0, 0x7849,
- 0x4544, 0x4D33, 0x3943, 0x3F3D, 0, 0, 0xCD2B, 0x434B,
- 0x5234, 0xCD2C, 0x442E, 0x3268, 0x6136, 0xF136, 0xF137, 0xCD2F,
-};
-static const unsigned short utf8_to_euc_E795[] = {
- 0xCD30, 0, 0, 0xCD31, 0x6137, 0, 0x613C, 0xCD32,
- 0xCD33, 0x613A, 0x6139, 0x5A42, 0x3326, 0x6138, 0xCD34, 0x305A,
- 0xCD35, 0x482A, 0xCD36, 0, 0x484A, 0, 0, 0xCD37,
- 0, 0x4E31, 0x613D, 0x613B, 0x435C, 0x4026, 0xCD38, 0xCD39,
- 0x482B, 0xCD3A, 0x492D, 0, 0x613F, 0x4E2C, 0x374D, 0x6140,
- 0, 0x613E, 0x4856, 0x6141, 0, 0x6142, 0, 0xCD3B,
- 0x305B, 0xCD3C, 0, 0x3E76, 0x6147, 0, 0x6144, 0x466D,
- 0x6143, 0xCD3D, 0xCD3E, 0xCD3F, 0xCD40, 0xCD41, 0xCD42, 0x3526,
-};
-static const unsigned short utf8_to_euc_E795_x0213[] = {
- 0xF138, 0, 0, 0xCD31, 0x6137, 0, 0x613C, 0xCD32,
- 0xF139, 0x613A, 0x6139, 0x5A42, 0x3326, 0x6138, 0xF13A, 0x305A,
- 0xF13B, 0x482A, 0xF13C, 0, 0x484A, 0, 0, 0xCD37,
- 0, 0x4E31, 0x613D, 0x613B, 0x435C, 0x4026, 0xCD38, 0xCD39,
- 0x482B, 0xCD3A, 0x492D, 0, 0x613F, 0x4E2C, 0x374D, 0x6140,
- 0, 0x613E, 0x4856, 0x6141, 0xF13D, 0x6142, 0, 0x784A,
- 0x305B, 0xF13F, 0xF13E, 0x3E76, 0x6147, 0, 0x6144, 0x466D,
- 0x6143, 0x784B, 0xF140, 0xCD3F, 0xCD40, 0xF141, 0xF142, 0x3526,
-};
-static const unsigned short utf8_to_euc_E796[] = {
- 0, 0xCD43, 0x614A, 0, 0, 0xCD44, 0x6145, 0x6146,
- 0, 0x6149, 0x6148, 0x4925, 0, 0, 0x4142, 0x4141,
- 0xCD45, 0x353F, 0xCD46, 0xCD47, 0x614B, 0xCD48, 0, 0,
- 0, 0xCD49, 0x614C, 0, 0xCD4A, 0x614D, 0, 0,
- 0, 0, 0xCD4B, 0x614F, 0xCD4C, 0x614E, 0, 0,
- 0, 0, 0, 0x3156, 0, 0, 0, 0,
- 0, 0x6157, 0x4868, 0x6151, 0xCD4D, 0x6153, 0, 0,
- 0x6155, 0x3F3E, 0xCD4E, 0, 0x6156, 0x6154, 0x3C40, 0xCD4F,
-};
-static const unsigned short utf8_to_euc_E796_x0213[] = {
- 0, 0xF143, 0x614A, 0, 0, 0xCD44, 0x6145, 0x6146,
- 0, 0x6149, 0x6148, 0x4925, 0xF145, 0, 0x4142, 0x4141,
- 0xCD45, 0x353F, 0x784C, 0xCD47, 0x614B, 0xCD48, 0, 0,
- 0, 0xCD49, 0x614C, 0, 0xCD4A, 0x614D, 0, 0,
- 0, 0, 0xF147, 0x614F, 0xCD4C, 0x614E, 0, 0,
- 0, 0, 0, 0x3156, 0, 0, 0, 0,
- 0xF149, 0x6157, 0x4868, 0x6151, 0xCD4D, 0x6153, 0, 0xF14A,
- 0x6155, 0x3F3E, 0xCD4E, 0, 0x6156, 0x6154, 0x3C40, 0xF14B,
-};
-static const unsigned short utf8_to_euc_E797[] = {
- 0xCD50, 0xCD51, 0x6150, 0x6152, 0xCD52, 0x4942, 0xCD53, 0x3E49,
- 0, 0, 0x6159, 0, 0xCD54, 0x6158, 0xCD55, 0xCD56,
- 0, 0, 0x615A, 0, 0x3C26, 0x3A2F, 0, 0xCD57,
- 0x4577, 0x615B, 0, 0x444B, 0xCD58, 0, 0x615D, 0xCD59,
- 0xCD5A, 0xCD5B, 0x4E21, 0x615C, 0xCD5C, 0, 0, 0xCD5D,
- 0, 0x4169, 0, 0, 0xCD5E, 0, 0xCD5F, 0xCD60,
- 0x6162, 0xCD61, 0x6164, 0x6165, 0x4354, 0, 0, 0,
- 0, 0xCD62, 0x6163, 0, 0x6160, 0, 0x615E, 0x615F,
-};
-static const unsigned short utf8_to_euc_E797_x0213[] = {
- 0xF14C, 0xCD51, 0x6150, 0x6152, 0xCD52, 0x4942, 0xF14D, 0x3E49,
- 0, 0, 0x6159, 0, 0xCD54, 0x6158, 0x784E, 0xF14E,
- 0, 0, 0x615A, 0xF14F, 0x3C26, 0x3A2F, 0, 0xCD57,
- 0x4577, 0x615B, 0, 0x444B, 0xCD58, 0xF150, 0x615D, 0xF151,
- 0xF152, 0xCD5B, 0x4E21, 0x615C, 0x784F, 0, 0, 0xF153,
- 0, 0x4169, 0, 0, 0xF154, 0, 0xF155, 0xCD60,
- 0x6162, 0xF156, 0x6164, 0x6165, 0x4354, 0, 0, 0,
- 0, 0xF157, 0x6163, 0, 0x6160, 0, 0x615E, 0x615F,
-};
-static const unsigned short utf8_to_euc_E798[] = {
- 0xCD63, 0x6161, 0xCD64, 0xCD65, 0xCD66, 0, 0, 0xCD67,
- 0xCD68, 0x6168, 0xCD69, 0x6166, 0xCD6A, 0x6167, 0, 0xCD6B,
- 0, 0, 0xCD6C, 0xCD6D, 0, 0xCD6E, 0xCD6F, 0,
- 0, 0xCD70, 0, 0xCD71, 0xCD72, 0xCD73, 0xCD74, 0x6169,
- 0x616B, 0x616C, 0x616D, 0xCD75, 0x616E, 0xCD76, 0xCD77, 0x616A,
- 0, 0xCD78, 0, 0, 0, 0xCD79, 0, 0,
- 0x6170, 0, 0xCD7A, 0xCD7B, 0x616F, 0xCD7C, 0, 0,
- 0xCD7D, 0xCD7E, 0xCE21, 0x6171, 0xCE22, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E798_x0213[] = {
- 0x7850, 0x6161, 0x7851, 0xF158, 0xCD66, 0, 0, 0xF15A,
- 0x7852, 0x6168, 0xCD69, 0x6166, 0xCD6A, 0x6167, 0, 0xF15B,
- 0, 0, 0xCD6C, 0xF15E, 0, 0x7853, 0x7854, 0,
- 0xF159, 0x7855, 0, 0xF15F, 0xF160, 0xCD73, 0x7856, 0x6169,
- 0x616B, 0x616C, 0x616D, 0xCD75, 0x616E, 0xF162, 0x7E7D, 0x616A,
- 0xF163, 0xCD78, 0, 0, 0, 0x7857, 0, 0,
- 0x6170, 0, 0xCD7A, 0xF165, 0x616F, 0x7858, 0, 0,
- 0xCD7D, 0xCD7E, 0xCE21, 0x6171, 0xF164, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E799[] = {
- 0xCE24, 0xCE25, 0x4E45, 0xCE26, 0xCE27, 0xCE28, 0x6174, 0x6172,
- 0x6173, 0xCE29, 0xCE23, 0xCE2A, 0x3462, 0, 0, 0,
- 0, 0, 0x4C7E, 0, 0, 0xCE2B, 0x4A4A, 0,
- 0x6176, 0xCE2C, 0, 0, 0x6175, 0, 0, 0xCE2D,
- 0, 0x6177, 0x6178, 0, 0xCE2E, 0xCE2F, 0, 0x617C,
- 0x6179, 0x617A, 0x617B, 0, 0x617D, 0xCE30, 0xCE31, 0xCE32,
- 0x617E, 0xCE33, 0x6221, 0, 0xCE34, 0, 0x6222, 0,
- 0x6223, 0, 0x482F, 0x4550, 0x6224, 0x4772, 0x4934, 0,
-};
-static const unsigned short utf8_to_euc_E799_x0213[] = {
- 0xCE24, 0xF168, 0x4E45, 0x7859, 0xCE27, 0xCE28, 0x6174, 0x6172,
- 0x6173, 0xF16A, 0xCE23, 0x785A, 0x3462, 0, 0, 0,
- 0, 0, 0x4C7E, 0, 0, 0xF16B, 0x4A4A, 0,
- 0x6176, 0xCE2C, 0, 0, 0x6175, 0, 0, 0xCE2D,
- 0, 0x6177, 0x6178, 0, 0x785B, 0x785C, 0, 0x617C,
- 0x6179, 0x617A, 0x617B, 0, 0x617D, 0x785D, 0xF16D, 0x785E,
- 0x617E, 0x785F, 0x6221, 0, 0xCE34, 0, 0x6222, 0,
- 0x6223, 0, 0x482F, 0x4550, 0x6224, 0x4772, 0x4934, 0,
-};
-static const unsigned short utf8_to_euc_E79A[] = {
- 0x6225, 0xCE35, 0xF451, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
- 0x6227, 0, 0, 0x6228, 0xCE37, 0xCE38, 0x6229, 0,
- 0x3B29, 0, 0, 0x622B, 0, 0xCE39, 0x622A, 0,
- 0, 0x622C, 0x622D, 0xCE3A, 0xCE3B, 0xCE3C, 0xF452, 0xCE3D,
- 0xCE3E, 0, 0xCE3F, 0xCE40, 0xCE41, 0xCE42, 0xCE43, 0xCE44,
- 0xCE45, 0, 0xCE46, 0, 0, 0xCE47, 0x4869, 0,
- 0x622E, 0, 0, 0, 0x622F, 0, 0, 0x7369,
- 0x6230, 0x6231, 0x6232, 0, 0, 0xCE48, 0, 0x3B2E,
-};
-static const unsigned short utf8_to_euc_E79A_x0213[] = {
- 0x6225, 0x7860, 0, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
- 0x6227, 0, 0, 0x6228, 0xCE37, 0xCE38, 0x6229, 0,
- 0x3B29, 0, 0, 0x622B, 0, 0xF16E, 0x622A, 0,
- 0, 0x622C, 0x622D, 0x7861, 0xF16F, 0x7862, 0x7863, 0xCE3D,
- 0xF171, 0xF170, 0xCE3F, 0xCE40, 0xCE41, 0xCE42, 0x7864, 0xF172,
- 0xF173, 0, 0x7865, 0, 0, 0xCE47, 0x4869, 0xF174,
- 0x622E, 0, 0, 0, 0x622F, 0, 0x7866, 0x7369,
- 0x6230, 0x6231, 0x6232, 0, 0, 0xCE48, 0, 0x3B2E,
-};
-static const unsigned short utf8_to_euc_E79B[] = {
- 0, 0xCE49, 0x6233, 0x4756, 0, 0xCE4A, 0x4B5F, 0,
- 0x314E, 0xCE4B, 0x3157, 0xCE4C, 0xCE4D, 0x6234, 0xCE4E, 0,
- 0, 0, 0x6236, 0, 0xCE4F, 0, 0x6235, 0x4570,
- 0, 0xCE50, 0, 0x4039, 0x5D39, 0, 0x6237, 0x4C41,
- 0xCE51, 0x6238, 0, 0x3446, 0x4857, 0x6239, 0xCE52, 0x623A,
- 0xCE53, 0, 0x623B, 0, 0xCE54, 0, 0x4C5C, 0,
- 0xCE55, 0xCE56, 0x4C55, 0, 0x443E, 0, 0xCE57, 0,
- 0x416A, 0xCE58, 0, 0x623D, 0xCE59, 0, 0x3D62, 0,
-};
-static const unsigned short utf8_to_euc_E79B_x0213[] = {
- 0, 0xCE49, 0x6233, 0x4756, 0, 0x7867, 0x4B5F, 0,
- 0x314E, 0xF176, 0x3157, 0xCE4C, 0x7868, 0x6234, 0x7869, 0,
- 0, 0, 0x6236, 0, 0x786A, 0, 0x6235, 0x4570,
- 0, 0xCE50, 0, 0x4039, 0x5D39, 0, 0x6237, 0x4C41,
- 0xCE51, 0x6238, 0, 0x3446, 0x4857, 0x6239, 0x786B, 0x623A,
- 0xF178, 0, 0x623B, 0, 0xF179, 0, 0x4C5C, 0,
- 0xCE55, 0x786C, 0x4C55, 0, 0x443E, 0, 0xCE57, 0,
- 0x416A, 0xCE58, 0, 0x623D, 0x786D, 0, 0x3D62, 0,
-};
-static const unsigned short utf8_to_euc_E79C[] = {
- 0xCE5A, 0x3E4A, 0, 0, 0x6240, 0, 0xCE5B, 0x623F,
- 0x623E, 0x487D, 0xCE5C, 0x3447, 0x3829, 0, 0xCE5D, 0,
- 0, 0, 0xCE5E, 0, 0xCE5F, 0xCE60, 0, 0xCE61,
- 0, 0xCE62, 0xCE63, 0x6246, 0xCE64, 0, 0x6243, 0x3F3F,
- 0x4C32, 0, 0xCE65, 0, 0x6242, 0x6244, 0x6245, 0,
- 0xCE66, 0x6241, 0, 0, 0, 0xCE67, 0xCE68, 0xCE69,
- 0, 0, 0, 0, 0xCE6A, 0xCE6B, 0xCE6C, 0x6247,
- 0x6248, 0xCE6D, 0x442F, 0, 0x3463, 0xCE6E, 0xCE6F, 0,
-};
-static const unsigned short utf8_to_euc_E79C_x0213[] = {
- 0xCE5A, 0x3E4A, 0, 0, 0x6240, 0, 0xCE5B, 0x623F,
- 0x623E, 0x487D, 0x786E, 0x3447, 0x3829, 0, 0xCE5D, 0,
- 0, 0, 0xCE5E, 0, 0xCE5F, 0xCE60, 0, 0xF17B,
- 0, 0x786F, 0xF17C, 0x6246, 0xCE64, 0, 0x6243, 0x3F3F,
- 0x4C32, 0, 0xCE65, 0, 0x6242, 0x6244, 0x6245, 0,
- 0xCE66, 0x6241, 0, 0, 0, 0xF17D, 0xCE68, 0xCE69,
- 0, 0, 0, 0, 0x7870, 0xF17E, 0x7871, 0x6247,
- 0x6248, 0xCE6D, 0x442F, 0, 0x3463, 0xCE6E, 0xCE6F, 0,
-};
-static const unsigned short utf8_to_euc_E79D[] = {
- 0x4365, 0, 0xCE70, 0, 0, 0xCE71, 0xCE72, 0x6249,
- 0, 0, 0xCE73, 0, 0, 0xCE74, 0xCE75, 0xCE76,
- 0, 0, 0xCE77, 0, 0, 0, 0xCE78, 0xCE79,
- 0, 0, 0x624A, 0x624D, 0xCE7A, 0, 0xCE7B, 0xCE7C,
- 0xCE7D, 0x3F67, 0xCE7E, 0x4644, 0xCF21, 0x624E, 0x4B53, 0xCF22,
- 0x624B, 0, 0xCF23, 0x624C, 0xCF24, 0, 0, 0,
- 0xCF25, 0, 0xCF26, 0xCF27, 0xCF28, 0, 0, 0,
- 0, 0x6251, 0xCF29, 0, 0, 0xCF2A, 0x6250, 0x624F,
-};
-static const unsigned short utf8_to_euc_E79D_x0213[] = {
- 0x4365, 0, 0xCE70, 0, 0, 0xCE71, 0x7872, 0x6249,
- 0, 0, 0xCE73, 0, 0, 0x7873, 0x7874, 0xCE76,
- 0, 0, 0xCE77, 0, 0, 0, 0xCE78, 0xCE79,
- 0xF225, 0, 0x624A, 0x624D, 0x7875, 0, 0xCE7B, 0x7876,
- 0xF226, 0x3F67, 0x7877, 0x4644, 0xCF21, 0x624E, 0x4B53, 0xCF22,
- 0x624B, 0, 0xF227, 0x624C, 0xCF24, 0, 0, 0,
- 0xCF25, 0, 0xF229, 0xCF27, 0xCF28, 0, 0, 0,
- 0, 0x6251, 0x7878, 0, 0xF22A, 0xF22B, 0x6250, 0x624F,
-};
-static const unsigned short utf8_to_euc_E79E[] = {
- 0xCF2B, 0, 0, 0, 0xCF2C, 0, 0, 0,
- 0, 0, 0, 0x6253, 0xCF2D, 0xCF2E, 0x6252, 0,
- 0, 0x6254, 0, 0, 0xCF2F, 0xCF30, 0xCF31, 0,
- 0, 0, 0xCF32, 0, 0, 0, 0x6256, 0xCF33,
- 0x6255, 0, 0xCF34, 0, 0, 0x4A4D, 0, 0xCF35,
- 0, 0, 0xCF36, 0, 0x3D56, 0x4E46, 0xCF37, 0xCF38,
- 0x6257, 0xCF39, 0, 0x4637, 0, 0xCF3A, 0x6258, 0,
- 0, 0x6259, 0, 0x625D, 0x625B, 0x625C, 0xCF3B, 0x625A,
-};
-static const unsigned short utf8_to_euc_E79E_x0213[] = {
- 0x7879, 0, 0, 0, 0xCF2C, 0, 0, 0,
- 0, 0, 0, 0x6253, 0xCF2D, 0xCF2E, 0x6252, 0,
- 0, 0x6254, 0, 0, 0x787A, 0xCF30, 0xCF31, 0,
- 0, 0, 0xF22E, 0, 0, 0, 0x6256, 0xF22F,
- 0x6255, 0, 0xF230, 0, 0xF231, 0x4A4D, 0, 0xCF35,
- 0, 0xF232, 0x787B, 0, 0x3D56, 0x4E46, 0xCF37, 0xCF38,
- 0x6257, 0xCF39, 0, 0x4637, 0, 0xCF3A, 0x6258, 0,
- 0, 0x6259, 0, 0x625D, 0x625B, 0x625C, 0xCF3B, 0x625A,
-};
-static const unsigned short utf8_to_euc_E79F[] = {
- 0, 0, 0, 0xCF3C, 0, 0, 0, 0x625E,
- 0, 0xCF3D, 0, 0, 0, 0x625F, 0, 0,
- 0, 0xCF3E, 0xCF3F, 0, 0, 0xCF40, 0, 0x6260,
- 0, 0xCF41, 0x6261, 0x4C37, 0x6262, 0, 0xCF42, 0xCF43,
- 0xCF44, 0, 0x4C70, 0x6263, 0xCF45, 0x434E, 0xCF46, 0x476A,
- 0, 0x366B, 0xCF47, 0, 0xCF48, 0x433B, 0x6264, 0x363A,
- 0xCF49, 0xCF4A, 0, 0x4050, 0xCF4B, 0, 0, 0,
- 0xCF4C, 0, 0, 0xCF4D, 0x6265, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E79F_x0213[] = {
- 0, 0, 0, 0xCF3C, 0, 0, 0, 0x625E,
- 0, 0xCF3D, 0, 0, 0, 0x625F, 0, 0,
- 0, 0xCF3E, 0xCF3F, 0, 0, 0xCF40, 0, 0x6260,
- 0, 0xCF41, 0x6261, 0x4C37, 0x6262, 0, 0xF233, 0xF234,
- 0x787C, 0, 0x4C70, 0x6263, 0xF235, 0x434E, 0xF236, 0x476A,
- 0, 0x366B, 0xF237, 0, 0xF238, 0x433B, 0x6264, 0x363A,
- 0xF23A, 0xCF4A, 0, 0x4050, 0xF23B, 0, 0, 0,
- 0xCF4C, 0, 0, 0xF23C, 0x6265, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7A0[] = {
- 0, 0, 0x3A3D, 0, 0, 0xCF4E, 0xCF4F, 0,
- 0, 0xCF50, 0, 0, 0x6266, 0xCF51, 0xCF52, 0,
- 0, 0xCF53, 0x6267, 0, 0x3826, 0x3A55, 0, 0,
- 0, 0, 0, 0, 0, 0xCF54, 0, 0,
- 0x6269, 0xCF55, 0xCF56, 0xCF57, 0, 0x4556, 0x3A56, 0x354E,
- 0, 0, 0, 0, 0, 0xCF58, 0xCF59, 0,
- 0xCF5A, 0, 0x4B24, 0, 0x474B, 0xCF5B, 0, 0xCF5C,
- 0, 0, 0x4557, 0, 0, 0, 0, 0x395C,
-};
-static const unsigned short utf8_to_euc_E7A0_x0213[] = {
- 0, 0, 0x3A3D, 0, 0, 0xF23E, 0xF23F, 0,
- 0, 0xF240, 0, 0, 0x6266, 0xF241, 0xCF52, 0,
- 0, 0xCF53, 0x6267, 0, 0x3826, 0x3A55, 0, 0,
- 0, 0xF242, 0, 0, 0, 0xCF54, 0, 0,
- 0x6269, 0xF243, 0xCF56, 0xCF57, 0, 0x4556, 0x3A56, 0x354E,
- 0, 0, 0, 0, 0xF244, 0x787D, 0xCF59, 0,
- 0xCF5A, 0, 0x4B24, 0, 0x474B, 0xCF5B, 0, 0xCF5C,
- 0, 0, 0x4557, 0, 0, 0, 0, 0x395C,
-};
-static const unsigned short utf8_to_euc_E7A1[] = {
- 0, 0, 0, 0xCF5D, 0xCF5E, 0x626B, 0, 0xCF5F,
- 0xCF60, 0, 0, 0, 0xCF61, 0, 0xCF62, 0,
- 0, 0, 0xCF63, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xCF64, 0x3E4B, 0xCF65, 0,
- 0xCF66, 0xCF67, 0, 0xCF68, 0xCF69, 0, 0, 0,
- 0xCF6A, 0, 0xCF6B, 0x4E32, 0x3945, 0, 0xCF6C, 0x3827,
- 0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
- 0, 0, 0xCF6D, 0, 0x626F, 0, 0xCF6E, 0,
-};
-static const unsigned short utf8_to_euc_E7A1_x0213[] = {
- 0, 0, 0, 0x7921, 0xCF5E, 0x626B, 0, 0xF245,
- 0xCF60, 0, 0, 0, 0xCF61, 0, 0x7922, 0x7923,
- 0, 0x7924, 0xCF63, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xCF64, 0x3E4B, 0xCF65, 0,
- 0xCF66, 0xCF67, 0, 0xCF68, 0xF246, 0, 0, 0,
- 0x7925, 0, 0xF247, 0x4E32, 0x3945, 0, 0x7926, 0x3827,
- 0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
- 0, 0, 0, 0, 0x626F, 0, 0xCF6E, 0,
-};
-static const unsigned short utf8_to_euc_E7A2[] = {
- 0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
- 0, 0, 0xCF6F, 0, 0x6271, 0x3337, 0x626C, 0xCF70,
- 0, 0x486A, 0, 0x3130, 0xCF71, 0x3A6C, 0, 0x4F52,
- 0xCF72, 0, 0x6270, 0, 0, 0xCF74, 0xCF75, 0xCF76,
- 0, 0xCF73, 0, 0x6272, 0xCF77, 0, 0, 0x4A4B,
- 0xCF78, 0x4059, 0x6274, 0, 0xCF79, 0xCF7A, 0, 0x6275,
- 0xCF7B, 0xCF7C, 0xCF7D, 0xCF7E, 0, 0x6273, 0, 0,
- 0, 0, 0x334E, 0xD021, 0x627B, 0xD022, 0x627A, 0xD023,
-};
-static const unsigned short utf8_to_euc_E7A2_x0213[] = {
- 0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
- 0, 0, 0xF249, 0, 0x6271, 0x3337, 0x626C, 0xCF70,
- 0, 0x486A, 0, 0x3130, 0xF24A, 0x3A6C, 0, 0x4F52,
- 0xCF72, 0, 0x6270, 0, 0, 0xF24C, 0xF24D, 0xF24E,
- 0, 0xCF73, 0, 0x6272, 0xF24B, 0, 0, 0x4A4B,
- 0xCF78, 0x4059, 0x6274, 0, 0xCF79, 0x792A, 0, 0x6275,
- 0x7928, 0xCF7C, 0xCF7D, 0xCF7E, 0, 0x6273, 0, 0,
- 0, 0, 0x334E, 0xF24F, 0x627B, 0xD022, 0x627A, 0xD023,
-};
-static const unsigned short utf8_to_euc_E7A3[] = {
- 0, 0x3C27, 0, 0, 0, 0x627C, 0x6277, 0xD024,
- 0xD025, 0xD026, 0x627D, 0x6278, 0xD027, 0, 0xD028, 0,
- 0x4858, 0x6276, 0xD029, 0xD02A, 0x6279, 0xD02B, 0xD02C, 0,
- 0, 0, 0x6322, 0xD02E, 0, 0, 0, 0xD02F,
- 0xD030, 0xD031, 0, 0, 0xD02D, 0, 0xD032, 0x6321,
- 0x4B61, 0, 0xD033, 0, 0x627E, 0, 0, 0x306B,
- 0, 0, 0xD034, 0xD035, 0x6324, 0, 0xD037, 0xD038,
- 0, 0, 0xD039, 0xD03A, 0, 0x6323, 0, 0xD03B,
-};
-static const unsigned short utf8_to_euc_E7A3_x0213[] = {
- 0, 0x3C27, 0, 0, 0, 0x627C, 0x6277, 0xD024,
- 0xF250, 0xD026, 0x627D, 0x6278, 0xF251, 0, 0xF252, 0,
- 0x4858, 0x6276, 0xD029, 0xD02A, 0x6279, 0xF253, 0xD02C, 0,
- 0, 0, 0x6322, 0xD02E, 0, 0, 0, 0xD02F,
- 0xF254, 0xF255, 0, 0, 0x792B, 0, 0xF256, 0x6321,
- 0x4B61, 0, 0xD033, 0, 0x627E, 0, 0, 0x306B,
- 0, 0, 0x792C, 0xD035, 0x6324, 0, 0xD037, 0x792E,
- 0, 0xF257, 0xF258, 0xF259, 0, 0x6323, 0xF25A, 0xD03B,
-};
-static const unsigned short utf8_to_euc_E7A4[] = {
- 0xD036, 0x3E4C, 0, 0, 0, 0, 0xD03C, 0x6325,
- 0, 0, 0, 0, 0xD03D, 0, 0x4143, 0,
- 0xD03E, 0x6327, 0x6326, 0, 0, 0, 0, 0,
- 0, 0x6328, 0xD03F, 0, 0xD040, 0, 0xD041, 0xD042,
- 0xD043, 0, 0, 0, 0, 0xD044, 0x6268, 0xD045,
- 0, 0xD046, 0x626A, 0x632A, 0x6329, 0xD047, 0, 0,
- 0xF454, 0xD048, 0, 0, 0xD049, 0xD04A, 0, 0,
- 0, 0, 0x3C28, 0xD04B, 0x4E69, 0xD04C, 0x3C52, 0xD04D,
-};
-static const unsigned short utf8_to_euc_E7A4_x0213[] = {
- 0x792D, 0x3E4C, 0, 0, 0, 0, 0xD03C, 0x6325,
- 0, 0, 0, 0, 0xD03D, 0, 0x4143, 0,
- 0xF25C, 0x6327, 0x6326, 0, 0, 0, 0, 0,
- 0, 0x6328, 0xD03F, 0xF25D, 0x792F, 0, 0xD041, 0xD042,
- 0xD043, 0, 0, 0, 0, 0xF25F, 0x6268, 0xD045,
- 0, 0xD046, 0x626A, 0x632A, 0x6329, 0xD047, 0x7930, 0,
- 0xF25E, 0x7931, 0, 0, 0x7932, 0xD04A, 0, 0,
- 0, 0, 0x3C28, 0xF260, 0x4E69, 0xD04C, 0x3C52, 0xD04D,
-};
-static const unsigned short utf8_to_euc_E7A5[] = {
- 0x632B, 0x3737, 0, 0, 0xD04E, 0xD04F, 0xD050, 0x3540,
- 0x3527, 0x3B63, 0xD051, 0xD052, 0, 0, 0, 0xD053,
- 0x4D34, 0xD054, 0, 0x6331, 0xD055, 0x6330, 0x4144, 0x632D,
- 0xD056, 0, 0x632F, 0xD057, 0xD058, 0x3D4B, 0x3F40, 0x632E,
- 0x632C, 0, 0x472A, 0, 0, 0x3E4D, 0, 0xD059,
- 0x493C, 0xD05A, 0, 0xD05B, 0, 0x3A57, 0, 0,
- 0, 0, 0xD05C, 0, 0, 0, 0, 0x4578,
- 0, 0xD05D, 0x6332, 0xD05E, 0xD05F, 0, 0xD060, 0x6333,
-};
-static const unsigned short utf8_to_euc_E7A5_x0213[] = {
- 0x632B, 0x3737, 0, 0, 0xD04E, 0x7935, 0x7936, 0x3540,
- 0x3527, 0x3B63, 0xF261, 0xD052, 0, 0, 0, 0xD053,
- 0x4D34, 0xD054, 0, 0x6331, 0xD055, 0x6330, 0x4144, 0x632D,
- 0xF262, 0, 0x632F, 0xF263, 0x793A, 0x3D4B, 0x3F40, 0x632E,
- 0x632C, 0, 0x472A, 0, 0, 0x3E4D, 0, 0xF265,
- 0x493C, 0xD05A, 0, 0xD05B, 0, 0x3A57, 0, 0,
- 0, 0, 0xF266, 0, 0, 0, 0, 0x4578,
- 0, 0x793E, 0x6332, 0xD05E, 0xD05F, 0, 0xD060, 0x6333,
-};
-static const unsigned short utf8_to_euc_E7A6[] = {
- 0x6349, 0x3658, 0, 0, 0x4F3D, 0x4135, 0, 0,
- 0, 0, 0x6334, 0xD061, 0xD062, 0x3252, 0x4477, 0x4A21,
- 0, 0xD063, 0, 0xD064, 0xD065, 0xD066, 0xD067, 0,
- 0xD068, 0, 0, 0xD069, 0xD06A, 0x6335, 0, 0,
- 0, 0xD06B, 0, 0, 0, 0, 0x357A, 0x6336,
- 0xD06C, 0xD06D, 0x6338, 0xD06E, 0, 0, 0x6339, 0xD06F,
- 0x4729, 0xD070, 0, 0x633A, 0xD071, 0, 0, 0,
- 0xD072, 0x633B, 0x633C, 0xD073, 0, 0x3659, 0x3253, 0x4645,
-};
-static const unsigned short utf8_to_euc_E7A6_x0213[] = {
- 0x6349, 0x3658, 0, 0, 0x4F3D, 0x4135, 0, 0,
- 0, 0, 0x6334, 0xD061, 0xD062, 0x3252, 0x4477, 0x4A21,
- 0, 0xD063, 0, 0xD064, 0xF267, 0xF268, 0xF269, 0,
- 0x7942, 0, 0, 0xF26A, 0xD06A, 0x6335, 0, 0,
- 0, 0xF26B, 0, 0, 0, 0, 0x357A, 0x6336,
- 0xD06C, 0xF26C, 0x6338, 0xD06E, 0, 0, 0x6339, 0xD06F,
- 0x4729, 0x7943, 0, 0x633A, 0xF26D, 0, 0, 0,
- 0x7944, 0x633B, 0x633C, 0xF26E, 0, 0x3659, 0x3253, 0x4645,
-};
-static const unsigned short utf8_to_euc_E7A7[] = {
- 0x3D28, 0x3B64, 0xD074, 0, 0xD075, 0, 0, 0xD076,
- 0xD077, 0x633D, 0xD078, 0x3D29, 0, 0, 0, 0xD079,
- 0, 0x324A, 0x4943, 0, 0xD07A, 0x633E, 0xD07B, 0,
- 0x486B, 0, 0xD07C, 0, 0, 0xD07D, 0xD07E, 0x4145,
- 0xD121, 0x6341, 0xD122, 0x6342, 0x4769, 0xD123, 0x3F41, 0x633F,
- 0, 0x4361, 0xD124, 0xD125, 0x6340, 0xD126, 0, 0,
- 0x3E4E, 0xD127, 0, 0, 0, 0, 0, 0,
- 0xD128, 0, 0, 0x305C, 0xD129, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7A7_x0213[] = {
- 0x3D28, 0x3B64, 0xF26F, 0, 0xD075, 0, 0, 0xF270,
- 0x7945, 0x633D, 0x7946, 0x3D29, 0xF271, 0xF272, 0, 0xD079,
- 0, 0x324A, 0x4943, 0, 0x7948, 0x633E, 0xF273, 0,
- 0x486B, 0, 0xD07C, 0, 0, 0xD07D, 0x7949, 0x4145,
- 0xD121, 0x6341, 0xD122, 0x6342, 0x4769, 0xD123, 0x3F41, 0x633F,
- 0, 0x4361, 0xD124, 0x794A, 0x6340, 0x794B, 0, 0,
- 0x3E4E, 0xD127, 0, 0, 0, 0, 0, 0,
- 0xD128, 0, 0, 0x305C, 0xD129, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7A8[] = {
- 0x3529, 0, 0xD12A, 0xD12B, 0, 0, 0, 0xD12C,
- 0x6343, 0xD12D, 0xD12E, 0x4478, 0xD12F, 0x6344, 0x4047, 0,
- 0, 0xD130, 0, 0, 0x4C2D, 0xD131, 0, 0x4923,
- 0x6345, 0x6346, 0x4355, 0xD132, 0x4E47, 0, 0xD133, 0x6348,
- 0x6347, 0xD134, 0, 0, 0, 0, 0, 0xD135,
- 0, 0, 0, 0xD136, 0, 0xD137, 0x3C6F, 0xD138,
- 0xD139, 0x634A, 0x3070, 0, 0xD13A, 0xD13B, 0, 0x634D,
- 0xD13C, 0xD13D, 0xD13E, 0x634B, 0x3254, 0x374E, 0x634C, 0x3946,
-};
-static const unsigned short utf8_to_euc_E7A8_x0213[] = {
- 0x3529, 0, 0xD12A, 0x794C, 0, 0, 0, 0xD12C,
- 0x6343, 0xD12D, 0xF278, 0x4478, 0xD12F, 0x6344, 0x4047, 0,
- 0, 0xF279, 0, 0, 0x4C2D, 0xF27A, 0, 0x4923,
- 0x6345, 0x6346, 0x4355, 0xF27B, 0x4E47, 0, 0xF27C, 0x6348,
- 0x6347, 0xD134, 0, 0, 0, 0, 0, 0xD135,
- 0, 0, 0, 0xD136, 0, 0xF27E, 0x3C6F, 0xD138,
- 0xD139, 0x634A, 0x3070, 0, 0xD13A, 0xD13B, 0, 0x634D,
- 0xF321, 0x794E, 0xD13E, 0x634B, 0x3254, 0x374E, 0x634C, 0x3946,
-};
-static const unsigned short utf8_to_euc_E7A9[] = {
- 0x3972, 0, 0x4A66, 0x634E, 0xD13F, 0xD140, 0x4B54, 0xD141,
- 0xD142, 0x6350, 0, 0, 0xD143, 0x4051, 0x314F, 0x323A,
- 0x302C, 0, 0, 0, 0, 0xD144, 0xD145, 0x634F,
- 0, 0xD146, 0, 0, 0xD147, 0xD148, 0, 0xD149,
- 0xD14A, 0x6351, 0x6352, 0x3E77, 0, 0xD14B, 0, 0xD14C,
- 0, 0x6353, 0xD14D, 0x334F, 0, 0xD14E, 0, 0,
- 0x6355, 0, 0, 0, 0x376A, 0xD14F, 0x3566, 0,
- 0xD150, 0x6356, 0x3675, 0, 0, 0x6357, 0xD151, 0x407C,
-};
-static const unsigned short utf8_to_euc_E7A9_x0213[] = {
- 0x3972, 0, 0x4A66, 0x634E, 0xD13F, 0xD140, 0x4B54, 0xF322,
- 0xD142, 0x6350, 0, 0, 0xF323, 0x4051, 0x314F, 0x323A,
- 0x302C, 0, 0, 0, 0, 0xD144, 0xF324, 0x634F,
- 0, 0xF325, 0, 0, 0xF326, 0x794F, 0, 0xF327,
- 0xF328, 0x6351, 0x6352, 0x3E77, 0, 0xD14B, 0, 0xF329,
- 0, 0x6353, 0xF32A, 0x334F, 0, 0x7950, 0, 0,
- 0x6355, 0, 0, 0, 0x376A, 0xF32B, 0x3566, 0,
- 0xF32C, 0x6356, 0x3675, 0, 0, 0x6357, 0xD151, 0x407C,
-};
-static const unsigned short utf8_to_euc_E7AA[] = {
- 0xD152, 0x464D, 0xD153, 0x4060, 0x3A75, 0xD154, 0xD155, 0,
- 0x6358, 0, 0xD156, 0xD157, 0, 0, 0, 0,
- 0xD158, 0xD159, 0x4362, 0x416B, 0xD15A, 0x635A, 0x635C, 0x6359,
- 0x635B, 0, 0, 0, 0, 0, 0xD15B, 0x3722,
- 0xD15C, 0, 0, 0xD15D, 0, 0, 0, 0,
- 0, 0x635D, 0x3726, 0, 0xD15E, 0, 0x3567, 0x4D52,
- 0x635F, 0, 0, 0xD15F, 0, 0xD160, 0x6360, 0,
- 0, 0xD161, 0x312E, 0xD162, 0xD163, 0, 0, 0x6363,
-};
-static const unsigned short utf8_to_euc_E7AA_x0213[] = {
- 0xD152, 0x464D, 0xF32D, 0x4060, 0x3A75, 0x7952, 0xD155, 0,
- 0x6358, 0, 0xF32E, 0xD157, 0, 0, 0, 0,
- 0xF32F, 0xD159, 0x4362, 0x416B, 0xD15A, 0x635A, 0x635C, 0x6359,
- 0x635B, 0, 0, 0, 0, 0, 0xD15B, 0x3722,
- 0x7953, 0, 0, 0xF330, 0, 0, 0, 0,
- 0, 0x635D, 0x3726, 0, 0xF331, 0, 0x3567, 0x4D52,
- 0x635F, 0, 0, 0x7955, 0, 0xD160, 0x6360, 0,
- 0, 0xF334, 0x312E, 0x7956, 0xF335, 0, 0xF336, 0x6363,
-};
-static const unsigned short utf8_to_euc_E7AB[] = {
- 0, 0, 0, 0x3376, 0x6362, 0x6361, 0xD164, 0x6365,
- 0x635E, 0xD165, 0x6366, 0x4E29, 0xD166, 0x6367, 0xD167, 0x6368,
- 0, 0xD168, 0x5474, 0x636A, 0, 0x6369, 0, 0,
- 0, 0x636B, 0x636C, 0xD169, 0x4E35, 0x636D, 0, 0x706F,
- 0x3E4F, 0x636E, 0x636F, 0x3D57, 0, 0x4638, 0x6370, 0xF459,
- 0xD16A, 0xD16B, 0x4328, 0xD16C, 0xD16D, 0x6371, 0, 0x433C,
- 0x6372, 0xD16E, 0, 0, 0xD16F, 0, 0x3625, 0,
- 0x513F, 0x435D, 0x3C33, 0xD170, 0, 0xD171, 0xD172, 0x3448,
-};
-static const unsigned short utf8_to_euc_E7AB_x0213[] = {
- 0, 0, 0, 0x3376, 0x6362, 0x6361, 0xD164, 0x6365,
- 0x635E, 0xD165, 0x6366, 0x4E29, 0xF338, 0x6367, 0x7957, 0x6368,
- 0, 0xF339, 0x5474, 0x636A, 0, 0x6369, 0, 0,
- 0, 0x636B, 0x636C, 0xD169, 0x4E35, 0x636D, 0, 0x706F,
- 0x3E4F, 0x636E, 0x636F, 0x3D57, 0, 0x4638, 0x6370, 0xF33A,
- 0xF33B, 0xD16B, 0x4328, 0x7958, 0xD16D, 0x6371, 0, 0x433C,
- 0x6372, 0xD16E, 0, 0, 0xF33C, 0, 0x3625, 0,
- 0x513F, 0x435D, 0x3C33, 0xD170, 0, 0x7959, 0xD172, 0x3448,
-};
-static const unsigned short utf8_to_euc_E7AC[] = {
- 0, 0, 0x6373, 0, 0x6422, 0, 0x6376, 0xD173,
- 0x3568, 0, 0x6375, 0x6424, 0, 0, 0, 0x6374,
- 0, 0x3E50, 0, 0, 0xD174, 0, 0, 0,
- 0x6378, 0x6379, 0, 0x452B, 0, 0, 0x637A, 0xD175,
- 0x335E, 0, 0, 0xD176, 0, 0x3F5A, 0x4964, 0xD177,
- 0x637C, 0xD178, 0xD179, 0xD17A, 0x4268, 0xD17B, 0xD17C, 0xD17D,
- 0xD17E, 0xD221, 0, 0x6377, 0xD222, 0x637B, 0x637D, 0,
- 0, 0x3A7B, 0, 0, 0, 0xD223, 0, 0xD224,
-};
-static const unsigned short utf8_to_euc_E7AC_x0213[] = {
- 0, 0, 0x6373, 0, 0x6422, 0, 0x6376, 0xF33F,
- 0x3568, 0, 0x6375, 0x6424, 0, 0, 0, 0x6374,
- 0, 0x3E50, 0x795A, 0, 0xD174, 0, 0, 0,
- 0x6378, 0x6379, 0, 0x452B, 0, 0, 0x637A, 0xD175,
- 0x335E, 0, 0, 0xD176, 0, 0x3F5A, 0x4964, 0xF342,
- 0x637C, 0xD178, 0xF343, 0xD17A, 0x4268, 0x795B, 0xF344, 0xF345,
- 0xD17E, 0xF346, 0, 0x6377, 0xD222, 0x637B, 0x637D, 0,
- 0, 0x3A7B, 0, 0x795C, 0, 0xF341, 0, 0xD224,
-};
-static const unsigned short utf8_to_euc_E7AD[] = {
- 0xD225, 0xD226, 0, 0, 0, 0x6426, 0x492E, 0xD227,
- 0x4826, 0x4579, 0, 0x365A, 0x6425, 0x6423, 0xD228, 0x4835,
- 0x637E, 0x435E, 0x457B, 0, 0x457A, 0xD229, 0x3A76, 0,
- 0, 0, 0, 0, 0, 0x6438, 0, 0,
- 0xD22A, 0, 0, 0, 0xD22B, 0x6428, 0xD22C, 0x642A,
- 0, 0xD22D, 0xD22E, 0, 0x642D, 0xD22F, 0x642E, 0xD230,
- 0x642B, 0x642C, 0xD231, 0xD232, 0x6429, 0x6427, 0, 0xD233,
- 0, 0, 0x6421, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7AD_x0213[] = {
- 0xD225, 0xF34A, 0, 0, 0, 0x6426, 0x492E, 0x795D,
- 0x4826, 0x4579, 0, 0x365A, 0x6425, 0x6423, 0x795E, 0x4835,
- 0x637E, 0x435E, 0x457B, 0, 0x457A, 0xF34C, 0x3A76, 0,
- 0, 0, 0, 0, 0, 0x6438, 0, 0,
- 0x795F, 0, 0, 0, 0xF34E, 0x6428, 0xF34F, 0x642A,
- 0, 0xF350, 0xD22E, 0, 0x642D, 0x7960, 0x642E, 0x7961,
- 0x642B, 0x642C, 0x7962, 0xF351, 0x6429, 0x6427, 0, 0xD233,
- 0, 0xF34D, 0x6421, 0, 0, 0, 0, 0xF349,
-};
-static const unsigned short utf8_to_euc_E7AE[] = {
- 0, 0, 0, 0, 0xD234, 0, 0x4A4F, 0x3255,
- 0, 0xD235, 0, 0x6435, 0, 0x6432, 0xD236, 0x6437,
- 0xD237, 0xD238, 0x6436, 0, 0x4773, 0x4C27, 0xD239, 0x3B3B,
- 0x6430, 0x6439, 0x6434, 0xD23A, 0x6433, 0x642F, 0xD23B, 0x6431,
- 0xD23C, 0x3449, 0, 0, 0, 0xD23D, 0, 0,
- 0, 0, 0x433D, 0, 0xD23E, 0x407D, 0, 0xD23F,
- 0xD240, 0x4822, 0xD241, 0, 0x643E, 0xD242, 0xD243, 0,
- 0x4824, 0, 0xD244, 0xD245, 0xD246, 0xD247, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7AE_x0213[] = {
- 0, 0, 0, 0, 0xD234, 0, 0x4A4F, 0x3255,
- 0, 0xD235, 0, 0x6435, 0, 0x6432, 0xD236, 0x6437,
- 0xF354, 0xF355, 0x6436, 0, 0x4773, 0x4C27, 0xD239, 0x3B3B,
- 0x6430, 0x6439, 0x6434, 0xF356, 0x6433, 0x642F, 0x7963, 0x6431,
- 0xD23C, 0x3449, 0, 0, 0, 0xD23D, 0, 0,
- 0, 0, 0x433D, 0, 0xD23E, 0x407D, 0, 0xF358,
- 0xD240, 0x4822, 0xD241, 0, 0x643E, 0xF359, 0xD243, 0,
- 0x4824, 0, 0xD244, 0xD245, 0xF35A, 0xD247, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7AF[] = {
- 0x4061, 0x643B, 0xD248, 0, 0x484F, 0xD249, 0x643F, 0x4A53,
- 0xD24A, 0x435B, 0xD24B, 0x643A, 0x643C, 0, 0, 0x643D,
- 0, 0, 0, 0, 0xD24C, 0, 0xD24D, 0xD24E,
- 0, 0xD24F, 0xD250, 0xD251, 0, 0x6440, 0, 0,
- 0x3C44, 0, 0, 0, 0x4646, 0x6445, 0x6444, 0,
- 0xD252, 0x6441, 0xD253, 0, 0, 0x4F36, 0, 0,
- 0, 0, 0xD254, 0x644A, 0xD255, 0xD256, 0x644E, 0x644B,
- 0xD257, 0xD258, 0xD259, 0, 0xD25A, 0, 0xD25B, 0,
-};
-static const unsigned short utf8_to_euc_E7AF_x0213[] = {
- 0x4061, 0x643B, 0xD248, 0, 0x484F, 0xF35B, 0x643F, 0x4A53,
- 0xD24A, 0x435B, 0xF35C, 0x643A, 0x643C, 0, 0, 0x643D,
- 0, 0, 0, 0, 0xF35F, 0, 0xF360, 0x7965,
- 0, 0x7966, 0xF361, 0xD251, 0, 0x6440, 0, 0,
- 0x3C44, 0, 0, 0, 0x4646, 0x6445, 0x6444, 0,
- 0xD252, 0x6441, 0xF362, 0, 0, 0x4F36, 0, 0,
- 0xF363, 0, 0xD254, 0x644A, 0xD255, 0xD256, 0x644E, 0x644B,
- 0xD257, 0xD258, 0xD259, 0, 0xD25A, 0, 0xD25B, 0,
-};
-static const unsigned short utf8_to_euc_E7B0[] = {
- 0x6447, 0xD25C, 0xD25D, 0xD25E, 0xD25F, 0, 0xD260, 0x6448,
- 0, 0xD261, 0, 0xD262, 0xD263, 0x644D, 0xD264, 0xD265,
- 0, 0x6442, 0x5255, 0x6449, 0x6443, 0, 0, 0x644C,
- 0, 0xD266, 0, 0xD267, 0, 0, 0, 0x6452,
- 0xD268, 0x344A, 0, 0x644F, 0, 0xD269, 0xD26A, 0x6450,
- 0xD26B, 0, 0x6451, 0x6454, 0xD26C, 0, 0, 0,
- 0, 0xD26D, 0, 0xD26E, 0xD26F, 0, 0xD270, 0x6453,
- 0x4876, 0xD271, 0xD272, 0, 0, 0x6455, 0x4E7C, 0x4A6D,
-};
-static const unsigned short utf8_to_euc_E7B0_x0213[] = {
- 0x6447, 0x7967, 0xD25D, 0xF364, 0xD25F, 0, 0xD260, 0x6448,
- 0, 0xD261, 0, 0xF365, 0xD263, 0x644D, 0xF366, 0xF367,
- 0, 0x6442, 0x5255, 0x6449, 0x6443, 0, 0, 0x644C,
- 0, 0xD266, 0, 0xD267, 0, 0, 0x7969, 0x6452,
- 0x796A, 0x344A, 0, 0x644F, 0, 0xD269, 0xF368, 0x6450,
- 0xD26B, 0, 0x6451, 0x6454, 0xD26C, 0, 0, 0,
- 0, 0x7968, 0, 0x796B, 0xD26F, 0, 0x796C, 0x6453,
- 0x4876, 0xD271, 0xD272, 0, 0, 0x6455, 0x4E7C, 0x4A6D,
-};
-static const unsigned short utf8_to_euc_E7B1[] = {
- 0x645A, 0, 0, 0x6457, 0, 0, 0xD273, 0,
- 0, 0, 0xD274, 0, 0x6456, 0x4052, 0, 0x6459,
- 0x645B, 0xD276, 0xD277, 0xD278, 0x6458, 0xD275, 0x645F, 0,
- 0x645C, 0xD279, 0xD27A, 0xD27B, 0xD27C, 0xD27D, 0xD27E, 0x645D,
- 0x6446, 0xD321, 0, 0xD322, 0x645E, 0x6460, 0, 0xD323,
- 0, 0xD324, 0, 0, 0x6461, 0xD325, 0xD326, 0,
- 0xD327, 0, 0xD328, 0x4A46, 0, 0x6462, 0, 0,
- 0, 0xD329, 0, 0, 0xD32A, 0xD32B, 0x4C62, 0,
-};
-static const unsigned short utf8_to_euc_E7B1_x0213[] = {
- 0x645A, 0, 0, 0x6457, 0, 0xF369, 0xD273, 0,
- 0, 0, 0xF36A, 0, 0x6456, 0x4052, 0, 0x6459,
- 0x645B, 0xF36B, 0xD277, 0xD278, 0x6458, 0xD275, 0x645F, 0xF36C,
- 0x645C, 0x796F, 0xD27A, 0xD27B, 0xD27C, 0xD27D, 0xF36D, 0x645D,
- 0x6446, 0xF36E, 0, 0xD322, 0x645E, 0x6460, 0, 0xD323,
- 0, 0xF36F, 0, 0, 0x6461, 0x7970, 0xF370, 0xF371,
- 0xF372, 0, 0xD328, 0x4A46, 0, 0x6462, 0, 0,
- 0, 0x7971, 0, 0, 0xD32A, 0xD32B, 0x4C62, 0,
-};
-static const unsigned short utf8_to_euc_E7B2[] = {
- 0, 0x364E, 0x3729, 0x6463, 0, 0, 0xD32C, 0xD32D,
- 0, 0x4A34, 0, 0x3F68, 0, 0x4C30, 0, 0xD32E,
- 0x6464, 0, 0x4E33, 0, 0xD32F, 0x4774, 0, 0x4146,
- 0x4734, 0, 0, 0x3D4D, 0, 0, 0xD330, 0x3040,
- 0xD331, 0x6469, 0x6467, 0, 0x6465, 0x3421, 0xD332, 0x3E51,
- 0x646A, 0, 0, 0x6468, 0, 0x6466, 0x646E, 0,
- 0xD333, 0x646D, 0x646C, 0x646B, 0, 0, 0xD334, 0xD335,
- 0, 0x646F, 0xD336, 0xD337, 0xD338, 0x6470, 0x403A, 0xD339,
-};
-static const unsigned short utf8_to_euc_E7B2_x0213[] = {
- 0, 0x364E, 0x3729, 0x6463, 0, 0, 0xD32C, 0xD32D,
- 0, 0x4A34, 0, 0x3F68, 0, 0x4C30, 0, 0x7972,
- 0x6464, 0, 0x4E33, 0, 0x7973, 0x4774, 0, 0x4146,
- 0x4734, 0, 0, 0x3D4D, 0, 0, 0xD330, 0x3040,
- 0x7974, 0x6469, 0x6467, 0, 0x6465, 0x3421, 0xF376, 0x3E51,
- 0x646A, 0, 0, 0x6468, 0, 0x6466, 0x646E, 0,
- 0xD333, 0x646D, 0x646C, 0x646B, 0, 0, 0xF378, 0xF379,
- 0, 0x646F, 0xD336, 0xD337, 0x7975, 0x6470, 0x403A, 0xF37A,
-};
-static const unsigned short utf8_to_euc_E7B3[] = {
- 0x6471, 0, 0x6473, 0, 0xD33A, 0x6472, 0, 0xD33B,
- 0xD33C, 0xD33D, 0x3852, 0, 0, 0xD33E, 0x4138, 0xD33F,
- 0, 0, 0x6475, 0xD340, 0xD341, 0xD342, 0x457C, 0xD343,
- 0x6474, 0xD344, 0xD345, 0, 0x6476, 0xD346, 0x4A35, 0x416C,
- 0x3947, 0, 0x6477, 0, 0, 0, 0xD347, 0x4E48,
- 0, 0xD348, 0, 0xD349, 0, 0, 0, 0x6479,
- 0, 0, 0x647A, 0, 0x647B, 0xD34A, 0x647C, 0,
- 0x3B65, 0, 0x647D, 0x374F, 0, 0, 0x356A, 0,
-};
-static const unsigned short utf8_to_euc_E7B3_x0213[] = {
- 0x6471, 0, 0x6473, 0, 0xF37C, 0x6472, 0, 0xD33B,
- 0xF37E, 0xD33D, 0x3852, 0, 0, 0xF421, 0x4138, 0xD33F,
- 0, 0, 0x6475, 0xD340, 0xD341, 0x7976, 0x457C, 0xF423,
- 0x6474, 0x7977, 0xD345, 0, 0x6476, 0x7978, 0x4A35, 0x416C,
- 0x3947, 0, 0x6477, 0, 0, 0, 0xF425, 0x4E48,
- 0, 0xD348, 0, 0xF426, 0, 0, 0, 0x6479,
- 0, 0, 0x647A, 0, 0x647B, 0xF428, 0x647C, 0,
- 0x3B65, 0, 0x647D, 0x374F, 0, 0, 0x356A, 0,
-};
-static const unsigned short utf8_to_euc_E7B4[] = {
- 0x352A, 0, 0x6521, 0xD34B, 0x4C73, 0x3948, 0x647E, 0xD34C,
- 0xD34D, 0xD34E, 0x6524, 0x4C66, 0, 0x473C, 0, 0xD34F,
- 0x4933, 0xD350, 0xD351, 0xD352, 0x3D63, 0x6523, 0xD353, 0x3C53,
- 0x3949, 0x3B66, 0x3569, 0x4A36, 0x6522, 0xD354, 0xD355, 0,
- 0x4147, 0x4B42, 0x3A77, 0xD356, 0, 0, 0xD357, 0,
- 0, 0, 0xD358, 0x3B67, 0x445D, 0xD359, 0x6527, 0x4E5F,
- 0x3A59, 0xD35A, 0x6528, 0x3F42, 0, 0x652A, 0, 0,
- 0, 0x3E52, 0x3A30, 0, 0xD35B, 0xD35C, 0xD35D, 0x6529,
-};
-static const unsigned short utf8_to_euc_E7B4_x0213[] = {
- 0x352A, 0, 0x6521, 0xF429, 0x4C73, 0x3948, 0x647E, 0x7979,
- 0x797A, 0xF42A, 0x6524, 0x4C66, 0, 0x473C, 0, 0xD34F,
- 0x4933, 0xD350, 0xF42C, 0x797B, 0x3D63, 0x6523, 0xD353, 0x3C53,
- 0x3949, 0x3B66, 0x3569, 0x4A36, 0x6522, 0x797C, 0xF42D, 0,
- 0x4147, 0x4B42, 0x3A77, 0x797D, 0, 0, 0xD357, 0,
- 0, 0, 0xD358, 0x3B67, 0x445D, 0xD359, 0x6527, 0x4E5F,
- 0x3A59, 0x797E, 0x6528, 0x3F42, 0, 0x652A, 0, 0,
- 0, 0x3E52, 0x3A30, 0, 0xD35B, 0xF430, 0xF431, 0x6529,
-};
-static const unsigned short utf8_to_euc_E7B5[] = {
- 0xD35E, 0xD35F, 0x3D2A, 0x383E, 0x4148, 0x6525, 0x652B, 0xD360,
- 0xD361, 0, 0, 0x6526, 0x3750, 0xD362, 0x652E, 0x6532,
- 0x376B, 0xD363, 0, 0xD364, 0, 0, 0x652D, 0xD365,
- 0, 0xD366, 0xD367, 0x6536, 0xD368, 0xD369, 0x394A, 0,
- 0, 0x4D6D, 0x303C, 0x6533, 0, 0xD36A, 0x356B, 0xD36B,
- 0x6530, 0, 0xD36C, 0, 0, 0, 0x6531, 0,
- 0xD36D, 0x457D, 0x652F, 0x652C, 0, 0x3328, 0x4064, 0,
- 0xD36E, 0x3828, 0xD36F, 0xD370, 0, 0x6538, 0, 0xD371,
-};
-static const unsigned short utf8_to_euc_E7B5_x0213[] = {
- 0xF432, 0x7A21, 0x3D2A, 0x383E, 0x4148, 0x6525, 0x652B, 0xF433,
- 0x7A22, 0, 0, 0x6526, 0x3750, 0xD362, 0x652E, 0x6532,
- 0x376B, 0xD363, 0, 0x7A23, 0, 0, 0x652D, 0xD365,
- 0, 0xF437, 0xF438, 0x6536, 0x7A24, 0xD369, 0x394A, 0,
- 0, 0x4D6D, 0x303C, 0x6533, 0, 0xD36A, 0x356B, 0xD36B,
- 0x6530, 0, 0xF439, 0, 0, 0, 0x6531, 0,
- 0xF43A, 0x457D, 0x652F, 0x652C, 0, 0x3328, 0x4064, 0,
- 0xD36E, 0x3828, 0x7A25, 0xD370, 0, 0x6538, 0, 0xF43C,
-};
-static const unsigned short utf8_to_euc_E7B6[] = {
- 0, 0xD372, 0xD373, 0xD374, 0, 0xD375, 0xD376, 0,
- 0xD377, 0x6535, 0, 0xD378, 0xD379, 0xD37A, 0, 0x6537,
- 0, 0xD37B, 0, 0x6534, 0, 0, 0xD37C, 0xD37D,
- 0, 0x3751, 0x4233, 0x6539, 0x416E, 0xD37E, 0xD421, 0x6546,
- 0xF45C, 0, 0x6542, 0x653C, 0, 0, 0xD422, 0xD423,
- 0, 0, 0xD424, 0x6540, 0x3C7A, 0x305D, 0x653B, 0x6543,
- 0x6547, 0x394B, 0x4C56, 0xD425, 0x4456, 0x653D, 0xD426, 0xD427,
- 0x6545, 0xD428, 0x653A, 0x433E, 0, 0x653F, 0x303D, 0x4C4A,
-};
-static const unsigned short utf8_to_euc_E7B6_x0213[] = {
- 0, 0xD372, 0xD373, 0x7A26, 0, 0xD375, 0xF43E, 0,
- 0xF43F, 0x6535, 0, 0x7A27, 0xF440, 0xD37A, 0, 0x6537,
- 0, 0xD37B, 0, 0x6534, 0, 0, 0xD37C, 0xF441,
- 0, 0x3751, 0x4233, 0x6539, 0x416E, 0xF443, 0xD421, 0x6546,
- 0x7A28, 0, 0x6542, 0x653C, 0, 0, 0x7A29, 0xF444,
- 0, 0, 0xF445, 0x6540, 0x3C7A, 0x305D, 0x653B, 0x6543,
- 0x6547, 0x394B, 0x4C56, 0xD425, 0x4456, 0x653D, 0xF446, 0xF447,
- 0x6545, 0xD428, 0x653A, 0x433E, 0, 0x653F, 0x303D, 0x4C4A,
-};
-static const unsigned short utf8_to_euc_E7B7[] = {
- 0, 0, 0xD429, 0xD42A, 0xD42B, 0xD42C, 0xD42D, 0x653E,
- 0, 0, 0x365B, 0x486C, 0xD42E, 0xD42F, 0xD430, 0x416D,
- 0, 0x4E50, 0x3D6F, 0, 0, 0x656E, 0xF45D, 0xD431,
- 0x6548, 0xD432, 0x407E, 0, 0x6544, 0x6549, 0x654B, 0,
- 0x4479, 0x654E, 0xD434, 0, 0x654A, 0xD435, 0xD436, 0,
- 0x4A54, 0x344B, 0xD437, 0xD438, 0x4C4B, 0xD439, 0, 0x305E,
- 0, 0xD43A, 0x654D, 0, 0x4E7D, 0xD43B, 0xD43C, 0,
- 0, 0xD43D, 0xD43E, 0x654C, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7B7_x0213[] = {
- 0xF448, 0, 0x7A2A, 0xD42A, 0xD42B, 0xD42C, 0xD42D, 0x653E,
- 0, 0, 0x365B, 0x486C, 0x7A2B, 0xD42F, 0xD430, 0x416D,
- 0, 0x4E50, 0x3D6F, 0, 0, 0x656E, 0x7A2C, 0xF449,
- 0x6548, 0xF44A, 0x407E, 0, 0x6544, 0x6549, 0x654B, 0,
- 0x4479, 0x654E, 0xD434, 0x7A2D, 0x654A, 0xD435, 0xF44B, 0,
- 0x4A54, 0x344B, 0xD437, 0xD438, 0x4C4B, 0xD439, 0, 0x305E,
- 0, 0xF44C, 0x654D, 0, 0x4E7D, 0xD43B, 0xD43C, 0,
- 0, 0xF44D, 0xD43E, 0x654C, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E7B8[] = {
- 0xD433, 0x316F, 0, 0, 0x466C, 0x654F, 0, 0,
- 0xD43F, 0x6556, 0x6550, 0x6557, 0, 0, 0, 0,
- 0xD440, 0xD441, 0x6553, 0, 0, 0xD442, 0, 0xD443,
- 0, 0, 0, 0x477B, 0xD444, 0xD445, 0x3C4A, 0x6555,
- 0xD446, 0x6552, 0x6558, 0x6551, 0, 0, 0x3D44, 0xD447,
- 0xD448, 0, 0, 0x4B25, 0xD449, 0xD44A, 0x3D4C, 0xD44B,
- 0, 0x6554, 0x6560, 0xD44C, 0, 0x655C, 0xD44D, 0x655F,
- 0, 0x655D, 0x6561, 0x655B, 0, 0x6541, 0x4053, 0xD44E,
-};
-static const unsigned short utf8_to_euc_E7B8_x0213[] = {
- 0xD433, 0x316F, 0, 0, 0x466C, 0x654F, 0, 0,
- 0x7A30, 0x6556, 0x6550, 0x6557, 0, 0, 0, 0,
- 0xF451, 0x7A31, 0x6553, 0, 0, 0x7A32, 0, 0xF452,
- 0, 0, 0, 0x477B, 0xD444, 0xF453, 0x3C4A, 0x6555,
- 0xF454, 0x6552, 0x6558, 0x6551, 0, 0, 0x3D44, 0xF455,
- 0x7A2F, 0, 0, 0x4B25, 0xF456, 0xD44A, 0x3D4C, 0xD44B,
- 0, 0x6554, 0x6560, 0xD44C, 0, 0x655C, 0xD44D, 0x655F,
- 0, 0x655D, 0x6561, 0x655B, 0, 0x6541, 0x4053, 0xD44E,
-};
-static const unsigned short utf8_to_euc_E7B9[] = {
- 0, 0x484B, 0, 0x655E, 0xD44F, 0xD450, 0x6559, 0xD451,
- 0, 0, 0x4121, 0x3752, 0, 0x3D2B, 0xD452, 0,
- 0xD453, 0, 0xD454, 0, 0x3F25, 0x4136, 0x6564, 0,
- 0xD455, 0x6566, 0x6567, 0, 0, 0x6563, 0x6565, 0xD456,
- 0, 0xD457, 0xD458, 0, 0, 0xD459, 0x655A, 0x6562,
- 0, 0x656A, 0x6569, 0xD45A, 0, 0x4B7A, 0xD45B, 0xD45C,
- 0x372B, 0, 0, 0xD45D, 0, 0, 0, 0,
- 0xD45E, 0x6568, 0, 0x656C, 0x656B, 0x656F, 0xD45F, 0x6571,
-};
-static const unsigned short utf8_to_euc_E7B9_x0213[] = {
- 0, 0x484B, 0, 0x655E, 0xD44F, 0xF457, 0x6559, 0x7A34,
- 0, 0, 0x4121, 0x3752, 0, 0x3D2B, 0xD452, 0,
- 0xD453, 0, 0x7A35, 0, 0x3F25, 0x4136, 0x6564, 0,
- 0xD455, 0x6566, 0x6567, 0, 0, 0x6563, 0x6565, 0xD456,
- 0, 0x7A36, 0xD458, 0, 0, 0xD459, 0x655A, 0x6562,
- 0, 0x656A, 0x6569, 0x7E7E, 0, 0x4B7A, 0xD45B, 0xD45C,
- 0x372B, 0, 0, 0xF458, 0, 0xF459, 0, 0,
- 0xD45E, 0x6568, 0, 0x656C, 0x656B, 0x656F, 0xF45A, 0x6571,
-};
-static const unsigned short utf8_to_euc_E7BA[] = {
- 0, 0xD460, 0x3B3C, 0x656D, 0, 0, 0xD461, 0xD462,
- 0x6572, 0x6573, 0xD463, 0, 0x6574, 0xD464, 0x657A, 0x453B,
- 0x6576, 0xD465, 0x6575, 0x6577, 0x6578, 0xD466, 0x6579, 0,
- 0xD467, 0, 0xD468, 0x657B, 0x657C, 0xD469, 0xD46A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E7BA_x0213[] = {
- 0, 0xD460, 0x3B3C, 0x656D, 0, 0, 0xF45B, 0xF45C,
- 0x6572, 0x6573, 0x7A37, 0, 0x6574, 0x7A38, 0x657A, 0x453B,
- 0x6576, 0xF45E, 0x6575, 0x6577, 0x6578, 0xD466, 0x6579, 0,
- 0xF45F, 0, 0xF460, 0x657B, 0x657C, 0xD469, 0xD46A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E7BC[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x344C, 0,
- 0x657D, 0, 0x657E, 0xD46C, 0xD46B, 0xD46D, 0xD46E, 0xD46F,
-};
-static const unsigned short utf8_to_euc_E7BC_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x344C, 0,
- 0x657D, 0, 0x657E, 0xF463, 0xF462, 0xD46D, 0xF464, 0xD46F,
-};
-static const unsigned short utf8_to_euc_E7BD[] = {
- 0, 0, 0, 0xD470, 0xD471, 0x6621, 0, 0xD472,
- 0, 0, 0, 0, 0x6622, 0x6623, 0x6624, 0xD473,
- 0x6625, 0x6626, 0xD474, 0xD475, 0x6628, 0x6627, 0, 0,
- 0x6629, 0, 0, 0xD476, 0xD477, 0xD478, 0, 0x662A,
- 0x662B, 0xD479, 0, 0xD47A, 0xD47B, 0xD47C, 0xD47D, 0x662E,
- 0x662C, 0x662D, 0x3A61, 0x3753, 0, 0xD47E, 0x4356, 0,
- 0x4833, 0xD521, 0x3D70, 0, 0, 0x474D, 0, 0x486D,
- 0x662F, 0x586D, 0, 0, 0, 0xD522, 0xD523, 0xD524,
-};
-static const unsigned short utf8_to_euc_E7BD_x0213[] = {
- 0, 0, 0, 0xF465, 0xF466, 0x6621, 0, 0x7A39,
- 0, 0, 0, 0, 0x6622, 0x6623, 0x6624, 0xF467,
- 0x6625, 0x6626, 0xF46A, 0xD475, 0x6628, 0x6627, 0, 0,
- 0x6629, 0, 0, 0xD476, 0xD477, 0xD478, 0, 0x662A,
- 0x662B, 0xF46C, 0, 0xF46D, 0xF46E, 0xD47C, 0xD47D, 0x662E,
- 0x662C, 0x662D, 0x3A61, 0x3753, 0, 0xF46F, 0x4356, 0,
- 0x4833, 0xD521, 0x3D70, 0, 0, 0x474D, 0, 0x486D,
- 0x662F, 0x586D, 0, 0, 0, 0xF470, 0xF471, 0xD524,
-};
-static const unsigned short utf8_to_euc_E7BE[] = {
- 0xD525, 0, 0x6630, 0x6632, 0, 0x4D65, 0x6631, 0x6634,
- 0x6633, 0, 0x4D53, 0xD526, 0x6635, 0xD527, 0x487E, 0xD528,
- 0xD529, 0xD52A, 0, 0, 0x6636, 0, 0xD52B, 0xD52C,
- 0, 0, 0x6639, 0, 0xD52D, 0x6638, 0x6637, 0,
- 0, 0xD52E, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
- 0x4122, 0x3541, 0xD531, 0, 0, 0xD532, 0x663E, 0x663B,
- 0, 0, 0x663C, 0, 0xD533, 0, 0x663F, 0,
- 0x6640, 0x663D, 0, 0, 0xD534, 0x3129, 0, 0xD535,
-};
-static const unsigned short utf8_to_euc_E7BE_x0213[] = {
- 0xD525, 0, 0x6630, 0x6632, 0, 0x4D65, 0x6631, 0x6634,
- 0x6633, 0, 0x4D53, 0xD526, 0x6635, 0xD527, 0x487E, 0xD528,
- 0xF473, 0x7A3B, 0, 0, 0x6636, 0, 0xF476, 0x7A3C,
- 0, 0, 0x6639, 0, 0xF477, 0x6638, 0x6637, 0,
- 0, 0, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
- 0x4122, 0x3541, 0xD531, 0, 0, 0xF478, 0x663E, 0x663B,
- 0, 0, 0x663C, 0, 0xD533, 0, 0x663F, 0,
- 0x6640, 0x663D, 0, 0, 0xD534, 0x3129, 0, 0x7A3D,
-};
-static const unsigned short utf8_to_euc_E7BF[] = {
- 0xD536, 0x3227, 0, 0xD537, 0, 0x6642, 0x6643, 0,
- 0xD538, 0, 0x6644, 0, 0x4D62, 0, 0xD539, 0xD53A,
- 0, 0, 0x3D2C, 0, 0x6646, 0x6645, 0, 0,
- 0, 0, 0, 0xD53B, 0, 0, 0, 0xD53C,
- 0x3F69, 0x6647, 0, 0xD53D, 0, 0xD53E, 0x6648, 0,
- 0xD53F, 0x6649, 0, 0x3465, 0xD540, 0, 0xD541, 0xD542,
- 0x344D, 0, 0xD543, 0x664A, 0, 0, 0, 0,
- 0, 0x664B, 0xD544, 0x4B5D, 0x4D63, 0xD545, 0xD546, 0xD547,
-};
-static const unsigned short utf8_to_euc_E7BF_x0213[] = {
- 0xD536, 0x3227, 0, 0xF47A, 0, 0x6642, 0x6643, 0,
- 0xD538, 0, 0x6644, 0, 0x4D62, 0, 0x7A3E, 0xF47B,
- 0, 0, 0x3D2C, 0, 0x6646, 0x6645, 0, 0,
- 0, 0, 0, 0x7A3F, 0, 0, 0, 0x7A40,
- 0x3F69, 0x6647, 0, 0xF47C, 0, 0xF47D, 0x6648, 0,
- 0xD53F, 0x6649, 0, 0x3465, 0x7A41, 0, 0x7A42, 0xF47E,
- 0x344D, 0, 0xF521, 0x664A, 0, 0, 0, 0,
- 0, 0x664B, 0x7A43, 0x4B5D, 0x4D63, 0xD545, 0xD546, 0xD547,
-};
-static const unsigned short utf8_to_euc_E880[] = {
- 0x4D54, 0x4F37, 0, 0x394D, 0x664E, 0x3C54, 0x664D, 0xD548,
- 0xD549, 0, 0xD54A, 0x664F, 0x3C29, 0xD54B, 0xD54C, 0xD54D,
- 0x4251, 0xD54E, 0x6650, 0xD54F, 0xD550, 0x394C, 0xD551, 0x4C57,
- 0x6651, 0x6652, 0, 0, 0x6653, 0xD552, 0xD553, 0xD554,
- 0xD555, 0x6654, 0, 0, 0xD556, 0, 0xD557, 0,
- 0x6655, 0, 0, 0, 0xD558, 0, 0xD559, 0,
- 0xD55A, 0, 0, 0x3C2A, 0xD55B, 0xD55C, 0x4C6D, 0xD55D,
- 0, 0xD55E, 0xD55F, 0x6657, 0xD560, 0x433F, 0xD561, 0x6656,
-};
-static const unsigned short utf8_to_euc_E880_x0213[] = {
- 0x4D54, 0x4F37, 0xF522, 0x394D, 0x664E, 0x3C54, 0x664D, 0xD548,
- 0xF524, 0, 0xF523, 0x664F, 0x3C29, 0xD54B, 0xF525, 0xD54D,
- 0x4251, 0xF526, 0x6650, 0xD54F, 0x7A45, 0x394C, 0xF527, 0x4C57,
- 0x6651, 0x6652, 0, 0, 0x6653, 0xD552, 0xD553, 0xD554,
- 0xD555, 0x6654, 0, 0, 0xF528, 0, 0x7A46, 0,
- 0x6655, 0, 0, 0, 0xF529, 0, 0xD559, 0,
- 0xF52A, 0, 0, 0x3C2A, 0xD55B, 0x7A47, 0x4C6D, 0x7A48,
- 0, 0xD55E, 0xD55F, 0x6657, 0x7A49, 0x433F, 0xD561, 0x6656,
-};
-static const unsigned short utf8_to_euc_E881[] = {
- 0xD562, 0, 0, 0, 0xD563, 0, 0x6659, 0,
- 0, 0, 0x6658, 0, 0, 0, 0, 0,
- 0, 0, 0x665A, 0, 0, 0, 0x403B, 0,
- 0x665B, 0, 0x665C, 0, 0, 0, 0x4A39, 0x665D,
- 0xD564, 0x416F, 0x665E, 0, 0xD565, 0, 0xD566, 0,
- 0x665F, 0, 0, 0, 0, 0xD567, 0, 0x4E7E,
- 0x6662, 0xD568, 0x6661, 0x6660, 0x4430, 0xD569, 0x6663, 0x3F26,
- 0, 0x6664, 0, 0, 0, 0x6665, 0x4F38, 0x6666,
-};
-static const unsigned short utf8_to_euc_E881_x0213[] = {
- 0xD562, 0, 0, 0xF52B, 0xD563, 0, 0x6659, 0,
- 0, 0, 0x6658, 0, 0, 0, 0, 0,
- 0, 0, 0x665A, 0, 0, 0, 0x403B, 0,
- 0x665B, 0, 0x665C, 0, 0, 0, 0x4A39, 0x665D,
- 0xD564, 0x416F, 0x665E, 0, 0xD565, 0, 0xF52C, 0,
- 0x665F, 0, 0, 0, 0, 0xD567, 0, 0x4E7E,
- 0x6662, 0xF52D, 0x6661, 0x6660, 0x4430, 0xF52E, 0x6663, 0x3F26,
- 0, 0x6664, 0, 0xF52F, 0, 0x6665, 0x4F38, 0x6666,
-};
-static const unsigned short utf8_to_euc_E882[] = {
- 0, 0xD56A, 0, 0, 0x6667, 0x6669, 0x6668, 0x4825,
- 0xD56B, 0x4679, 0, 0x4F3E, 0x4829, 0, 0xD56C, 0,
- 0, 0, 0, 0x666B, 0, 0, 0x3E53, 0,
- 0x492A, 0, 0x666C, 0x666A, 0xD56D, 0x344E, 0xD56E, 0,
- 0, 0x3854, 0x3B68, 0, 0, 0x486E, 0xD56F, 0xD570,
- 0, 0x382A, 0x4B43, 0xD571, 0x666F, 0x666D, 0, 0x394E,
- 0, 0x394F, 0x3069, 0, 0x3A68, 0, 0, 0,
- 0xD572, 0xD573, 0x4759, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E882_x0213[] = {
- 0, 0xD56A, 0, 0, 0x6667, 0x6669, 0x6668, 0x4825,
- 0xD56B, 0x4679, 0, 0x4F3E, 0x4829, 0, 0xD56C, 0,
- 0, 0, 0, 0x666B, 0, 0, 0x3E53, 0,
- 0x492A, 0xF530, 0x666C, 0x666A, 0xF531, 0x344E, 0xD56E, 0,
- 0, 0x3854, 0x3B68, 0, 0xF532, 0x486E, 0xD56F, 0xF533,
- 0, 0x382A, 0x4B43, 0xD571, 0x666F, 0x666D, 0, 0x394E,
- 0, 0x394F, 0x3069, 0, 0x3A68, 0, 0, 0,
- 0xF534, 0xD573, 0x4759, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E883[] = {
- 0, 0, 0, 0x305F, 0x6674, 0, 0x4340, 0,
- 0xD574, 0, 0, 0, 0x4758, 0xD575, 0x425B, 0xD576,
- 0, 0, 0xD577, 0, 0xD578, 0xD579, 0x6676, 0xD57A,
- 0xD57B, 0x6672, 0x6675, 0x6670, 0, 0x6673, 0x4B26, 0,
- 0xD57C, 0x3855, 0, 0, 0x307D, 0x6671, 0, 0,
- 0, 0, 0, 0, 0, 0xD57D, 0xD57E, 0x6678,
- 0xD621, 0x6679, 0xD622, 0xD623, 0x4639, 0, 0xD624, 0,
- 0x363B, 0xD625, 0xD626, 0, 0x6726, 0x473D, 0xD627, 0,
-};
-static const unsigned short utf8_to_euc_E883_x0213[] = {
- 0, 0, 0, 0x305F, 0x6674, 0xF536, 0x4340, 0,
- 0xD574, 0, 0x7A4A, 0, 0x4758, 0xD575, 0x425B, 0xD576,
- 0, 0, 0xD577, 0, 0xD578, 0xF537, 0x6676, 0x7A4B,
- 0xF538, 0x6672, 0x6675, 0x6670, 0, 0x6673, 0x4B26, 0,
- 0x7A4C, 0x3855, 0, 0, 0x307D, 0x6671, 0xF539, 0,
- 0, 0, 0, 0, 0, 0xD57D, 0xD57E, 0x6678,
- 0xD621, 0x6679, 0xD622, 0x7A4D, 0x4639, 0xF53C, 0xD624, 0,
- 0x363B, 0xD625, 0xD626, 0xF53D, 0x6726, 0x473D, 0xD627, 0,
-};
-static const unsigned short utf8_to_euc_E884[] = {
- 0, 0, 0x3B69, 0xD628, 0, 0x363C, 0x4048, 0x4F46,
- 0x4C2E, 0x6677, 0x4054, 0xD629, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xD62A, 0xD62B,
- 0xD62C, 0, 0x3553, 0x667A, 0xD62D, 0, 0xD62E, 0,
- 0xD62F, 0, 0, 0x667C, 0xD630, 0, 0, 0xD631,
- 0, 0x667B, 0, 0, 0xD632, 0, 0, 0x667D,
- 0xD633, 0x4326, 0, 0x473E, 0, 0xD634, 0, 0,
- 0, 0x4431, 0xD635, 0, 0xD636, 0, 0x6723, 0,
-};
-static const unsigned short utf8_to_euc_E884_x0213[] = {
- 0, 0, 0x3B69, 0xD628, 0, 0x363C, 0x4048, 0x4F46,
- 0x4C2E, 0x6677, 0x4054, 0xD629, 0, 0xF53B, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF540, 0xD62B,
- 0x7A4E, 0, 0x3553, 0x667A, 0xD62D, 0, 0xF541, 0,
- 0xD62F, 0, 0, 0x667C, 0xF543, 0, 0, 0xF544,
- 0, 0x667B, 0, 0, 0xF545, 0, 0, 0x667D,
- 0xD633, 0x4326, 0, 0x473E, 0, 0xF53F, 0, 0,
- 0, 0x4431, 0xD635, 0, 0xD636, 0xF547, 0x6723, 0,
-};
-static const unsigned short utf8_to_euc_E885[] = {
- 0, 0, 0, 0, 0, 0xD637, 0x6722, 0xD638,
- 0, 0, 0xD639, 0x667E, 0xD63A, 0, 0x3F55, 0,
- 0x4965, 0x6725, 0xD63B, 0x6724, 0x3950, 0x4F53, 0, 0xD63C,
- 0, 0, 0, 0, 0, 0, 0, 0x6735,
- 0xD63D, 0xD63E, 0, 0, 0, 0x6729, 0x672A, 0xD63F,
- 0xD640, 0xD641, 0, 0x3C70, 0, 0xD642, 0x6728, 0xD643,
- 0x3978, 0x6727, 0, 0, 0x672B, 0, 0, 0xD644,
- 0x4432, 0x4A22, 0x4123, 0, 0, 0, 0, 0x425C,
-};
-static const unsigned short utf8_to_euc_E885_x0213[] = {
- 0, 0, 0, 0, 0, 0xD637, 0x6722, 0xD638,
- 0, 0, 0x7A4F, 0x667E, 0xD63A, 0, 0x3F55, 0,
- 0x4965, 0x6725, 0xD63B, 0x6724, 0x3950, 0x4F53, 0, 0xD63C,
- 0, 0, 0, 0, 0, 0, 0, 0x6735,
- 0x7A50, 0xD63E, 0, 0, 0, 0x6729, 0x672A, 0x7A51,
- 0x7A52, 0xF549, 0, 0x3C70, 0, 0x7A53, 0x6728, 0xD643,
- 0x3978, 0x6727, 0, 0, 0x672B, 0, 0, 0xD644,
- 0x4432, 0x4A22, 0x4123, 0, 0, 0, 0, 0x425C,
-};
-static const unsigned short utf8_to_euc_E886[] = {
- 0x672F, 0xD645, 0x6730, 0x672C, 0xD647, 0xD648, 0xD649, 0,
- 0x672D, 0, 0x672E, 0xD64A, 0, 0, 0xD64B, 0x3951,
- 0xD646, 0, 0, 0x6736, 0, 0x6732, 0xD64C, 0,
- 0xD64D, 0, 0x4966, 0xD64E, 0x4B6C, 0x4928, 0xD64F, 0,
- 0x6731, 0, 0xD650, 0x6734, 0x6733, 0, 0, 0,
- 0x4B44, 0x6737, 0, 0, 0, 0, 0xD651, 0,
- 0x6738, 0, 0xD652, 0x4137, 0xD653, 0x6739, 0, 0,
- 0x673B, 0, 0x673F, 0xD654, 0, 0x673C, 0x673A, 0x473F,
-};
-static const unsigned short utf8_to_euc_E886_x0213[] = {
- 0x672F, 0xF54B, 0x6730, 0x672C, 0xF54D, 0xF54E, 0xD649, 0,
- 0x672D, 0, 0x672E, 0xD64A, 0, 0, 0xD64B, 0x3951,
- 0xD646, 0, 0, 0x6736, 0, 0x6732, 0xD64C, 0,
- 0xF550, 0, 0x4966, 0xD64E, 0x4B6C, 0x4928, 0xD64F, 0,
- 0x6731, 0, 0xD650, 0x6734, 0x6733, 0, 0, 0,
- 0x4B44, 0x6737, 0, 0, 0, 0, 0xD651, 0,
- 0x6738, 0, 0xF551, 0x4137, 0xD653, 0x6739, 0, 0,
- 0x673B, 0, 0x673F, 0x7A54, 0, 0x673C, 0x673A, 0x473F,
-};
-static const unsigned short utf8_to_euc_E887[] = {
- 0x673D, 0, 0x673E, 0xD656, 0, 0xD657, 0x3232, 0,
- 0x6745, 0x6740, 0xD658, 0xD655, 0, 0x6741, 0xD659, 0xD65A,
- 0, 0x6742, 0, 0x4221, 0, 0xD65B, 0, 0xD65C,
- 0x6744, 0x6743, 0x6746, 0xD65D, 0, 0xD65E, 0xD65F, 0x6747,
- 0x6748, 0xD660, 0, 0x3F43, 0xD661, 0x3269, 0, 0x6749,
- 0x4E57, 0, 0x3C2B, 0xD662, 0xD663, 0x3D2D, 0, 0,
- 0xD664, 0xD665, 0xD666, 0x3B6A, 0x4357, 0xD667, 0xD668, 0,
- 0xD669, 0xD66A, 0x674A, 0x674B, 0x3131, 0xD66B, 0x674C, 0xD66C,
-};
-static const unsigned short utf8_to_euc_E887_x0213[] = {
- 0x673D, 0xF552, 0x673E, 0xF553, 0, 0xD657, 0x3232, 0,
- 0x6745, 0x6740, 0x7A55, 0xD655, 0, 0x6741, 0xD659, 0x7A56,
- 0, 0x6742, 0, 0x4221, 0, 0xD65B, 0xF554, 0x7A57,
- 0x6744, 0x6743, 0x6746, 0xF555, 0, 0xD65E, 0xD65F, 0x6747,
- 0x6748, 0xD660, 0, 0x3F43, 0xF557, 0x3269, 0, 0x6749,
- 0x4E57, 0, 0x3C2B, 0xD662, 0xF559, 0x3D2D, 0, 0,
- 0xD664, 0xD665, 0xD666, 0x3B6A, 0x4357, 0xD667, 0xD668, 0,
- 0xD669, 0xD66A, 0x674A, 0x674B, 0x3131, 0xF55B, 0x674C, 0xF55C,
-};
-static const unsigned short utf8_to_euc_E888[] = {
- 0xD66D, 0x674D, 0x674E, 0xD66E, 0, 0x674F, 0, 0x6750,
- 0x363D, 0x5A2A, 0x6751, 0, 0x4065, 0x6752, 0x3C4B, 0xD66F,
- 0x6753, 0, 0x5030, 0xD670, 0xD671, 0, 0x6754, 0x4A5E,
- 0x345C, 0xD672, 0xD673, 0x4124, 0x3D58, 0xD674, 0x4971, 0x3D2E,
- 0, 0xD675, 0xD676, 0, 0, 0, 0, 0,
- 0xD677, 0x6755, 0x3952, 0x6756, 0x484C, 0, 0x6764, 0,
- 0, 0, 0xD678, 0x6758, 0xD679, 0x4249, 0x4775, 0x383F,
- 0x6757, 0x4125, 0xD67A, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E888_x0213[] = {
- 0xD66D, 0x674D, 0x674E, 0xD66E, 0xF55E, 0x674F, 0, 0x6750,
- 0x363D, 0x5A2A, 0x6751, 0, 0x4065, 0x6752, 0x3C4B, 0xD66F,
- 0x6753, 0, 0x5030, 0xD670, 0xD671, 0, 0x6754, 0x4A5E,
- 0x345C, 0xF560, 0xD673, 0x4124, 0x3D58, 0xD674, 0x4971, 0x3D2E,
- 0, 0xF561, 0xF562, 0, 0, 0, 0, 0,
- 0xD677, 0x6755, 0x3952, 0x6756, 0x484C, 0, 0x6764, 0,
- 0, 0, 0xF564, 0x6758, 0xF565, 0x4249, 0x4775, 0x383F,
- 0x6757, 0x4125, 0xD67A, 0, 0xF566, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E889[] = {
- 0x6759, 0, 0, 0xD67B, 0xD67C, 0xD67D, 0xD67E, 0x447A,
- 0, 0, 0, 0xD721, 0, 0, 0xD722, 0xD723,
- 0, 0xD724, 0, 0, 0, 0, 0xD725, 0,
- 0x675B, 0x675A, 0x675D, 0, 0xD726, 0x675C, 0, 0x675E,
- 0xD727, 0, 0x6760, 0xD728, 0x675F, 0, 0x344F, 0xD729,
- 0x6761, 0, 0x6762, 0x6763, 0, 0xD72A, 0x3A31, 0x4E49,
- 0, 0x6765, 0x3F27, 0, 0xD72B, 0, 0x3170, 0x6766,
- 0x6767, 0, 0, 0xD72C, 0, 0xD72D, 0x6768, 0xD72E,
-};
-static const unsigned short utf8_to_euc_E889_x0213[] = {
- 0x6759, 0, 0, 0xD67B, 0xD67C, 0xF569, 0xF567, 0x447A,
- 0, 0xF568, 0, 0xF56B, 0, 0, 0xD722, 0xF56D,
- 0, 0xD724, 0, 0, 0, 0, 0xD725, 0xF56F,
- 0x675B, 0x675A, 0x675D, 0, 0xF571, 0x675C, 0, 0x675E,
- 0x7A5B, 0, 0x6760, 0xF572, 0x675F, 0, 0x344F, 0xD729,
- 0x6761, 0, 0x6762, 0x6763, 0, 0xD72A, 0x3A31, 0x4E49,
- 0, 0x6765, 0x3F27, 0, 0x7A5C, 0, 0x3170, 0x6766,
- 0x6767, 0xF576, 0, 0xD72C, 0, 0xF578, 0x6768, 0xF579,
-};
-static const unsigned short utf8_to_euc_E88A[] = {
- 0xD72F, 0xD730, 0, 0xD731, 0xD732, 0, 0, 0xD733,
- 0, 0xD734, 0xD735, 0x3072, 0, 0x6769, 0xD736, 0,
- 0, 0xD737, 0x676A, 0, 0xD738, 0, 0xD739, 0,
- 0xD73A, 0x4967, 0xD73B, 0xD73C, 0, 0x3C47, 0, 0x676C,
- 0xD73D, 0xD73E, 0, 0xD73F, 0xD740, 0x3329, 0x3032, 0xD741,
- 0xD742, 0xD743, 0xD744, 0x676B, 0x676E, 0x474E, 0xD745, 0x3F44,
- 0xD746, 0x3256, 0xD747, 0x4B27, 0xD748, 0, 0, 0xD749,
- 0x375D, 0x365C, 0xD74A, 0x676D, 0xD74B, 0x326A, 0xD74C, 0xD74D,
-};
-static const unsigned short utf8_to_euc_E88A_x0213[] = {
- 0xD72F, 0xD730, 0, 0xF57A, 0xD732, 0, 0, 0xD733,
- 0, 0xD734, 0xF57B, 0x3072, 0, 0x6769, 0x7A5E, 0,
- 0, 0xD737, 0x676A, 0xF57C, 0xD738, 0, 0xD739, 0,
- 0xD73A, 0x4967, 0xD73B, 0xD73C, 0, 0x3C47, 0, 0x676C,
- 0xD73D, 0x7A5F, 0, 0x7A60, 0x7A61, 0x3329, 0x3032, 0xF57D,
- 0xF57E, 0x7A62, 0xD744, 0x676B, 0x676E, 0x474E, 0x7A63, 0x3F44,
- 0xD746, 0x3256, 0xF621, 0x4B27, 0xF622, 0, 0, 0x7A64,
- 0x375D, 0x365C, 0xF623, 0x676D, 0xF624, 0x326A, 0x7A65, 0x7A66,
-};
-static const unsigned short utf8_to_euc_E88B[] = {
- 0, 0, 0, 0, 0, 0x3423, 0xD74E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xD74F, 0x3171, 0x6772, 0x4E6A, 0x425D, 0xD750, 0, 0x4944,
- 0, 0x677E, 0xD751, 0x3257, 0x677C, 0, 0x677A, 0x6771,
- 0xD752, 0x676F, 0xD753, 0x6770, 0xD754, 0x3C63, 0x366C, 0x4377,
- 0xD755, 0, 0xD756, 0x4651, 0, 0xD757, 0, 0xD758,
- 0, 0x3151, 0, 0x6774, 0x6773, 0, 0xD759, 0xD75A,
- 0, 0x6779, 0x6775, 0x6778, 0, 0xD75B, 0xD75C, 0,
-};
-static const unsigned short utf8_to_euc_E88B_x0213[] = {
- 0, 0, 0, 0, 0, 0x3423, 0x7A67, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xD74F, 0x3171, 0x6772, 0x4E6A, 0x425D, 0x7A68, 0, 0x4944,
- 0, 0x677E, 0xD751, 0x3257, 0x677C, 0, 0x677A, 0x6771,
- 0xD752, 0x676F, 0xF625, 0x6770, 0xD754, 0x3C63, 0x366C, 0x4377,
- 0xF626, 0, 0xD756, 0x4651, 0, 0xD757, 0, 0xD758,
- 0, 0x3151, 0, 0x6774, 0x6773, 0, 0xD759, 0xF627,
- 0, 0x6779, 0x6775, 0x6778, 0, 0x7A69, 0x7A6A, 0,
-};
-static const unsigned short utf8_to_euc_E88C[] = {
- 0xD75D, 0xD75E, 0x4C50, 0x6777, 0x3258, 0x337D, 0x677B, 0xD75F,
- 0xD760, 0x677D, 0xD761, 0xD762, 0, 0, 0x3754, 0,
- 0, 0, 0, 0, 0, 0, 0x6823, 0x682C,
- 0x682D, 0, 0, 0xD764, 0x302B, 0xD765, 0xD766, 0xD767,
- 0, 0xD768, 0xD769, 0x6834, 0, 0, 0, 0,
- 0x3071, 0, 0, 0x682B, 0xD76A, 0xD76B, 0xD76C, 0x682A,
- 0xD76D, 0x6825, 0x6824, 0xD76E, 0x6822, 0x6821, 0x4363, 0xD76F,
- 0x427B, 0x6827, 0xD770, 0, 0xD771, 0xD772, 0, 0,
-};
-static const unsigned short utf8_to_euc_E88C_x0213[] = {
- 0x7A6B, 0x7A6C, 0x4C50, 0x6777, 0x3258, 0x337D, 0x677B, 0xF628,
- 0xF629, 0x677D, 0xD761, 0xD762, 0xF62A, 0, 0x3754, 0,
- 0, 0, 0, 0, 0, 0, 0x6823, 0x682C,
- 0x682D, 0, 0, 0xF62C, 0x302B, 0xF62D, 0xD766, 0xD767,
- 0, 0xD768, 0x7A6E, 0x6834, 0, 0, 0, 0,
- 0x3071, 0, 0, 0x682B, 0xD76A, 0x7A6F, 0xD76C, 0x682A,
- 0xF62E, 0x6825, 0x6824, 0xD76E, 0x6822, 0x6821, 0x4363, 0xD76F,
- 0x427B, 0x6827, 0x7A70, 0, 0xF62F, 0xD772, 0, 0,
-};
-static const unsigned short utf8_to_euc_E88D[] = {
- 0x6826, 0, 0xD773, 0xD774, 0xD775, 0x6829, 0, 0xD776,
- 0, 0x4170, 0x3755, 0, 0, 0xD777, 0xD778, 0x3141,
- 0x6828, 0xD779, 0x3953, 0xD83E, 0xD763, 0xD77A, 0xD77B, 0xD77C,
- 0x4171, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xF45F, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xD77D, 0, 0, 0x683A, 0, 0x683B, 0, 0x3259,
- 0xD77E, 0, 0, 0x322E, 0x6838, 0xD821, 0, 0xD822,
-};
-static const unsigned short utf8_to_euc_E88D_x0213[] = {
- 0x6826, 0, 0xD773, 0x7A71, 0xF630, 0x6829, 0, 0x7A72,
- 0, 0x4170, 0x3755, 0, 0, 0xD777, 0xD778, 0x3141,
- 0x6828, 0x7A73, 0x3953, 0xD83E, 0xF62B, 0x7A74, 0xD77B, 0xF631,
- 0x4171, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x7A6D, 0xAE4A, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xD77D, 0, 0, 0x683A, 0, 0x683B, 0, 0x3259,
- 0xD77E, 0, 0, 0x322E, 0x6838, 0x7A75, 0, 0xF633,
-};
-static const unsigned short utf8_to_euc_E88E[] = {
- 0xD823, 0, 0xD824, 0, 0xD825, 0x682E, 0xD826, 0x6836,
- 0, 0x683D, 0x6837, 0, 0, 0xD827, 0x6835, 0,
- 0, 0, 0xD828, 0x6776, 0xD829, 0xD82A, 0x6833, 0,
- 0xD82B, 0xD82C, 0x682F, 0xD82D, 0xD82E, 0xD82F, 0x3450, 0x6831,
- 0x683C, 0, 0x6832, 0, 0, 0, 0xD830, 0xD831,
- 0x683E, 0xD832, 0x6830, 0x477C, 0xD833, 0xD84C, 0, 0,
- 0, 0x4D69, 0, 0, 0, 0x6839, 0, 0,
- 0, 0, 0, 0, 0, 0x684F, 0xD834, 0xD835,
-};
-static const unsigned short utf8_to_euc_E88E_x0213[] = {
- 0xD823, 0, 0xD824, 0, 0xD825, 0x682E, 0x7A76, 0x6836,
- 0, 0x683D, 0x6837, 0, 0, 0xF636, 0x6835, 0,
- 0, 0, 0x7A77, 0x6776, 0xF637, 0xF638, 0x6833, 0,
- 0x7A78, 0xD82C, 0x682F, 0xF639, 0xD82E, 0xF63A, 0x3450, 0x6831,
- 0x683C, 0, 0x6832, 0, 0, 0, 0xD830, 0x7A79,
- 0x683E, 0x7A7A, 0x6830, 0x477C, 0xD833, 0xD84C, 0, 0,
- 0, 0x4D69, 0, 0, 0, 0x6839, 0, 0,
- 0, 0, 0, 0, 0, 0x684F, 0xD834, 0x7A7B,
-};
-static const unsigned short utf8_to_euc_E88F[] = {
- 0xD836, 0x6847, 0, 0, 0, 0x3F7B, 0, 0xD837,
- 0, 0xD838, 0x3546, 0, 0x365D, 0, 0x6842, 0xD839,
- 0xD83A, 0xD83B, 0, 0x325B, 0xD83C, 0, 0x3E54, 0,
- 0x6845, 0, 0, 0, 0x3A5A, 0xD83D, 0, 0x4551,
- 0x684A, 0, 0, 0, 0, 0, 0, 0,
- 0xD83F, 0x4A6E, 0xD840, 0x6841, 0, 0, 0, 0x325A,
- 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0xD841, 0x6848,
- 0xD842, 0xD843, 0, 0x6852, 0xD844, 0x6843, 0, 0,
-};
-static const unsigned short utf8_to_euc_E88F_x0213[] = {
- 0x7A7C, 0x6847, 0, 0, 0, 0x3F7B, 0, 0x7A7D,
- 0, 0xF63B, 0x3546, 0, 0x365D, 0, 0x6842, 0x7A7E,
- 0xF63C, 0x7B21, 0, 0x325B, 0xF63D, 0, 0x3E54, 0,
- 0x6845, 0, 0, 0, 0x3A5A, 0xF63E, 0, 0x4551,
- 0x684A, 0x7B22, 0, 0, 0, 0xF63F, 0, 0,
- 0xD83F, 0x4A6E, 0x7B23, 0x6841, 0, 0, 0, 0x325A,
- 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0, 0x6848,
- 0xD842, 0xF640, 0, 0x6852, 0xD844, 0x6843, 0, 0,
-};
-static const unsigned short utf8_to_euc_E890[] = {
- 0, 0xD845, 0, 0x6844, 0x463A, 0, 0xD846, 0x6849,
- 0, 0, 0xD847, 0x6846, 0x4B28, 0x684C, 0x3060, 0xD848,
- 0, 0xD849, 0, 0x6840, 0, 0xD84A, 0, 0,
- 0, 0xD84B, 0, 0, 0, 0, 0, 0,
- 0x684E, 0, 0x684D, 0, 0, 0, 0, 0,
- 0, 0x476B, 0x6854, 0, 0x685F, 0, 0, 0xD84D,
- 0, 0x337E, 0, 0, 0, 0x6862, 0, 0,
- 0x6850, 0xD84E, 0, 0, 0x6855, 0x4D6E, 0, 0,
-};
-static const unsigned short utf8_to_euc_E890_x0213[] = {
- 0, 0x7B24, 0, 0x6844, 0x463A, 0, 0x7B25, 0x6849,
- 0, 0, 0x7B26, 0x6846, 0x4B28, 0x684C, 0x3060, 0xF641,
- 0, 0xF642, 0, 0x6840, 0, 0xF643, 0, 0xF645,
- 0, 0xD84B, 0, 0, 0, 0, 0, 0,
- 0x684E, 0, 0x684D, 0, 0, 0, 0, 0,
- 0, 0x476B, 0x6854, 0, 0x685F, 0, 0, 0xD84D,
- 0, 0x337E, 0, 0, 0, 0x6862, 0, 0,
- 0x6850, 0xF646, 0, 0, 0x6855, 0x4D6E, 0, 0,
-};
-static const unsigned short utf8_to_euc_E891[] = {
- 0, 0, 0, 0, 0, 0xD84F, 0x685E, 0xD850,
- 0xD851, 0x4D55, 0xD852, 0, 0, 0xD853, 0x4E2A, 0xD854,
- 0, 0xD855, 0xD856, 0, 0, 0, 0xD857, 0x4378,
- 0xD858, 0xD859, 0xD85A, 0x336B, 0xD85B, 0, 0, 0,
- 0xD85C, 0x4972, 0x6864, 0x4621, 0xD85D, 0xD85E, 0x3031, 0xD85F,
- 0, 0x685D, 0xD860, 0x6859, 0x4172, 0x6853, 0x685B, 0x6860,
- 0xD861, 0x472C, 0, 0xD862, 0xD863, 0x302A, 0xD864, 0x6858,
- 0xD865, 0x6861, 0x4978, 0, 0xD866, 0xD867, 0, 0,
-};
-static const unsigned short utf8_to_euc_E891_x0213[] = {
- 0, 0, 0, 0, 0, 0xD84F, 0x685E, 0xD850,
- 0x7B28, 0x4D55, 0xF647, 0, 0, 0xD853, 0x4E2A, 0xF648,
- 0, 0xF649, 0xF64A, 0, 0, 0, 0xD857, 0x4378,
- 0xD858, 0xF64B, 0xF64C, 0x336B, 0xF64D, 0, 0, 0x7B29,
- 0xD85C, 0x4972, 0x6864, 0x4621, 0xD85D, 0xF64F, 0x3031, 0xD85F,
- 0, 0x685D, 0xD860, 0x6859, 0x4172, 0x6853, 0x685B, 0x6860,
- 0x7B2A, 0x472C, 0, 0x7B2B, 0xD863, 0x302A, 0xF650, 0x6858,
- 0xF651, 0x6861, 0x4978, 0, 0xF652, 0xD867, 0, 0,
-};
-static const unsigned short utf8_to_euc_E892[] = {
- 0, 0xD868, 0x685C, 0, 0x6857, 0xD869, 0, 0,
- 0, 0, 0, 0x3E55, 0, 0, 0, 0,
- 0x3D2F, 0, 0xD86A, 0xD86B, 0x3C2C, 0xD86C, 0, 0,
- 0, 0x4C58, 0, 0, 0x4947, 0, 0xD86D, 0x6867,
- 0, 0x6870, 0, 0, 0, 0, 0xD86E, 0,
- 0xD86F, 0xD870, 0xD871, 0, 0, 0x685A, 0, 0xD872,
- 0, 0xD873, 0x3377, 0, 0xD874, 0, 0, 0,
- 0x3E78, 0x6865, 0xD875, 0x686A, 0x4173, 0xD876, 0xD877, 0x6866,
-};
-static const unsigned short utf8_to_euc_E892_x0213[] = {
- 0, 0xF653, 0x685C, 0, 0x6857, 0x7B2C, 0, 0,
- 0, 0, 0, 0x3E55, 0, 0, 0, 0,
- 0x3D2F, 0, 0xD86A, 0xD86B, 0x3C2C, 0xD86C, 0, 0xF656,
- 0, 0x4C58, 0, 0, 0x4947, 0, 0x7B2D, 0x6867,
- 0, 0x6870, 0, 0, 0, 0, 0xF657, 0,
- 0xD86F, 0xD870, 0xD871, 0, 0, 0x685A, 0, 0x7B2E,
- 0, 0xD873, 0x3377, 0, 0x7B2F, 0, 0, 0,
- 0x3E78, 0x6865, 0x7B30, 0x686A, 0x4173, 0xD876, 0xF658, 0x6866,
-};
-static const unsigned short utf8_to_euc_E893[] = {
- 0xD878, 0x686D, 0xD879, 0, 0x435F, 0, 0x686E, 0xD87A,
- 0xD87B, 0x4D56, 0x6863, 0x3338, 0xD87C, 0x6869, 0, 0xD87D,
- 0x686C, 0x4C2C, 0, 0xD87E, 0, 0, 0x686F, 0,
- 0, 0x6868, 0x686B, 0, 0xD921, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xD922,
- 0, 0, 0xD923, 0, 0x4B29, 0, 0x4F21, 0xD924,
- 0xD925, 0xD926, 0xD927, 0, 0x6873, 0, 0, 0xD928,
- 0, 0, 0xD92A, 0xD92B, 0x687A, 0xD92C, 0, 0x6872,
-};
-static const unsigned short utf8_to_euc_E893_x0213[] = {
- 0x7B31, 0x686D, 0x7B32, 0, 0x435F, 0, 0x686E, 0xD87A,
- 0xD87B, 0x4D56, 0x6863, 0x3338, 0xD87C, 0x6869, 0xF65A, 0xF65B,
- 0x686C, 0x4C2C, 0, 0xF65C, 0, 0, 0x686F, 0,
- 0, 0x6868, 0x686B, 0, 0xF655, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xF65E,
- 0, 0, 0xF65F, 0, 0x4B29, 0, 0x4F21, 0xF660,
- 0xF661, 0xF662, 0xD927, 0, 0x6873, 0, 0, 0xD928,
- 0, 0, 0xF663, 0xD92B, 0x687A, 0xF664, 0, 0x6872,
-};
-static const unsigned short utf8_to_euc_E894[] = {
- 0x3C43, 0, 0xD92D, 0xD92E, 0, 0, 0x6851, 0xD92F,
- 0, 0, 0, 0, 0xD930, 0, 0xD931, 0,
- 0xD932, 0x4A4E, 0, 0x4C22, 0x6879, 0x6878, 0, 0x6874,
- 0x6875, 0, 0x3136, 0, 0xD933, 0, 0xD934, 0x6877,
- 0, 0x6871, 0xD935, 0xD936, 0xD937, 0xD938, 0x4455, 0xD939,
- 0, 0, 0xD93A, 0xD93B, 0x6876, 0x307E, 0, 0xD93C,
- 0, 0, 0xD929, 0xD93D, 0xD93E, 0x4222, 0xD93F, 0,
- 0, 0, 0, 0, 0, 0x4A43, 0, 0xD940,
-};
-static const unsigned short utf8_to_euc_E894_x0213[] = {
- 0x3C43, 0, 0xD92D, 0xD92E, 0, 0, 0x6851, 0xD92F,
- 0, 0, 0, 0, 0xF665, 0, 0xD931, 0,
- 0xD932, 0x4A4E, 0, 0x4C22, 0x6879, 0x6878, 0, 0x6874,
- 0x6875, 0, 0x3136, 0xF666, 0xD933, 0, 0x7B35, 0x6877,
- 0, 0x6871, 0xD935, 0x7B36, 0xF667, 0xF668, 0x4455, 0xD939,
- 0, 0, 0xD93A, 0xF669, 0x6876, 0x307E, 0, 0x7B37,
- 0, 0, 0x7B34, 0xD93D, 0xF66A, 0x4222, 0xD93F, 0,
- 0, 0, 0, 0, 0, 0x4A43, 0xF66F, 0xD940,
-};
-static const unsigned short utf8_to_euc_E895[] = {
- 0x687B, 0x6921, 0, 0x4859, 0, 0, 0xD941, 0,
- 0x687E, 0x3E56, 0x3C49, 0x6923, 0, 0, 0x363E, 0xD942,
- 0xD943, 0xD944, 0xD945, 0xD946, 0, 0x6924, 0xD947, 0x4979,
- 0x687D, 0xD948, 0x6856, 0, 0xD949, 0xD94A, 0xD94B, 0xD94C,
- 0xD94D, 0xD94E, 0xD94F, 0x687C, 0xD950, 0, 0, 0,
- 0x4F4F, 0x4622, 0x4973, 0xD951, 0, 0x692B, 0, 0xD952,
- 0, 0, 0, 0, 0, 0, 0, 0x6931,
- 0, 0xD953, 0xD954, 0xD955, 0, 0xD956, 0x6932, 0xD957,
-};
-static const unsigned short utf8_to_euc_E895_x0213[] = {
- 0x687B, 0x6921, 0, 0x4859, 0, 0, 0xD941, 0,
- 0x687E, 0x3E56, 0x3C49, 0x6923, 0, 0, 0x363E, 0xF66B,
- 0xD943, 0xF670, 0xD945, 0xF671, 0, 0x6924, 0xD947, 0x4979,
- 0x687D, 0x7B38, 0x6856, 0, 0xD949, 0xD94A, 0xF672, 0xD94C,
- 0xD94D, 0xF673, 0xF674, 0x687C, 0x7B39, 0, 0, 0,
- 0x4F4F, 0x4622, 0x4973, 0, 0, 0x692B, 0, 0xF66C,
- 0, 0, 0, 0, 0, 0, 0, 0x6931,
- 0, 0xD953, 0x7B3C, 0xF676, 0, 0xF677, 0x6932, 0xF678,
-};
-static const unsigned short utf8_to_euc_E896[] = {
- 0x6925, 0xD958, 0, 0, 0x4776, 0xD959, 0xD95A, 0x692F,
- 0x6927, 0xD95B, 0x6929, 0xD95C, 0xD95D, 0, 0, 0xD95E,
- 0x6933, 0x6928, 0, 0xD95F, 0x692C, 0, 0, 0x3172,
- 0xD960, 0x4665, 0, 0x692D, 0x6930, 0xD961, 0, 0xD962,
- 0xD963, 0, 0xD964, 0, 0x6926, 0xD965, 0x4126, 0xD966,
- 0x692A, 0x3B27, 0x3F45, 0x3730, 0x4C74, 0xD974, 0x4C79, 0x3D72,
- 0xF461, 0, 0, 0, 0xD967, 0, 0xD968, 0xD969,
- 0xD96A, 0x6937, 0x6935, 0, 0xD96B, 0xD96C, 0xD96D, 0xD96E,
-};
-static const unsigned short utf8_to_euc_E896_x0213[] = {
- 0x6925, 0xF679, 0, 0, 0x4776, 0xD959, 0xF67A, 0x692F,
- 0x6927, 0xD95B, 0x6929, 0xD95C, 0x7B3D, 0, 0, 0x7B3E,
- 0x6933, 0x6928, 0, 0xF67B, 0x692C, 0, 0, 0x3172,
- 0xD960, 0x4665, 0, 0x692D, 0x6930, 0xF67C, 0, 0xF67D,
- 0xD963, 0, 0x7B3F, 0, 0x6926, 0xD965, 0x4126, 0xD966,
- 0x692A, 0x3B27, 0x3F45, 0x3730, 0x4C74, 0x7B3B, 0x4C79, 0x3D72,
- 0x7B40, 0, 0, 0, 0xD967, 0, 0xD968, 0xF723,
- 0xD96A, 0x6937, 0x6935, 0, 0xF724, 0xD96C, 0xD96D, 0xD96E,
-};
-static const unsigned short utf8_to_euc_E897[] = {
- 0, 0x4F4E, 0xD96F, 0, 0, 0, 0, 0xD970,
- 0, 0x6934, 0xD971, 0xD972, 0, 0x4D75, 0xD973, 0x6936,
- 0x6938, 0, 0, 0, 0, 0x6939, 0, 0,
- 0xD975, 0, 0xD976, 0, 0x693C, 0x693A, 0, 0xD977,
- 0xD978, 0, 0, 0, 0x4623, 0x693B, 0xD979, 0,
- 0xD97A, 0x484D, 0x692E, 0, 0, 0xD97B, 0, 0,
- 0, 0, 0, 0xD97C, 0, 0, 0xD97D, 0x3D73,
- 0, 0x693D, 0x6942, 0x4174, 0xD97E, 0, 0x6941, 0xDA21,
-};
-static const unsigned short utf8_to_euc_E897_x0213[] = {
- 0, 0x4F4E, 0xD96F, 0, 0, 0, 0, 0xF725,
- 0, 0x6934, 0xF726, 0x7B41, 0, 0x4D75, 0x7B42, 0x6936,
- 0x6938, 0, 0, 0, 0, 0x6939, 0, 0,
- 0xF727, 0xF728, 0xD976, 0, 0x693C, 0x693A, 0, 0xF729,
- 0xD978, 0xF72A, 0, 0, 0x4623, 0x693B, 0xF72B, 0,
- 0xD97A, 0x484D, 0x692E, 0, 0, 0x7B43, 0, 0,
- 0, 0, 0, 0xD97C, 0, 0, 0xF72C, 0x3D73,
- 0, 0x693D, 0x6942, 0x4174, 0xD97E, 0, 0x6941, 0x7B45,
-};
-static const unsigned short utf8_to_euc_E898[] = {
- 0xDA22, 0, 0x6922, 0, 0xDA23, 0xDA24, 0x6943, 0x4149,
- 0, 0, 0x693E, 0x6940, 0, 0xDA25, 0xDA26, 0,
- 0xDA27, 0xDA28, 0xDA29, 0x693F, 0, 0, 0x5D31, 0x5D22,
- 0xDA2A, 0xDA2B, 0x6945, 0xDA2C, 0, 0, 0xDA2D, 0,
- 0, 0xDA2E, 0x6944, 0, 0, 0, 0, 0xDA2F,
- 0, 0xDA30, 0, 0, 0, 0x4D76, 0, 0x623C,
- 0x6946, 0, 0, 0, 0, 0, 0xDA31, 0,
- 0xDA32, 0, 0xDA33, 0, 0xDA34, 0xDA35, 0, 0x6947,
-};
-static const unsigned short utf8_to_euc_E898_x0213[] = {
- 0xF72D, 0, 0x6922, 0, 0x7B46, 0x7B47, 0x6943, 0x4149,
- 0, 0, 0x693E, 0x6940, 0, 0xDA25, 0xDA26, 0,
- 0x7B48, 0xF72E, 0x7B44, 0x693F, 0, 0, 0x5D31, 0x5D22,
- 0x7B4A, 0xDA2B, 0x6945, 0xDA2C, 0, 0, 0xF72F, 0,
- 0, 0xF730, 0x6944, 0, 0xF731, 0, 0, 0xF732,
- 0, 0x7B4B, 0, 0, 0, 0x4D76, 0, 0x623C,
- 0x6946, 0, 0, 0, 0, 0, 0xDA31, 0,
- 0x7B4C, 0xF734, 0xDA33, 0, 0xF735, 0xDA35, 0, 0x6947,
-};
-static const unsigned short utf8_to_euc_E899[] = {
- 0xDA36, 0xB866, 0xDA37, 0, 0, 0, 0xDA38, 0,
- 0, 0, 0, 0, 0, 0x6948, 0x3857, 0,
- 0x3554, 0, 0xDA39, 0xDA3A, 0x694A, 0x515D, 0xDA3B, 0xDA3C,
- 0xDA3D, 0xDA3E, 0x3575, 0, 0x4E3A, 0xDA3F, 0x3673, 0x694B,
- 0xDA40, 0xDA41, 0xDA42, 0xDA43, 0xDA44, 0, 0, 0x694C,
- 0, 0xDA45, 0, 0x436E, 0xDA46, 0, 0, 0xDA47,
- 0, 0x694D, 0, 0, 0, 0xDA48, 0xDA49, 0xDA4A,
- 0, 0x467A, 0xDA4B, 0x303A, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E899_x0213[] = {
- 0xF737, 0x2F68, 0xDA37, 0, 0, 0, 0xDA38, 0,
- 0, 0, 0, 0, 0, 0x6948, 0x3857, 0,
- 0x3554, 0, 0xDA39, 0xF739, 0x694A, 0x515D, 0xF73A, 0x7B4D,
- 0xDA3D, 0xDA3E, 0x3575, 0x7B4E, 0x4E3A, 0xDA3F, 0x3673, 0x694B,
- 0xDA40, 0xDA41, 0x7B50, 0xDA43, 0xDA44, 0, 0, 0x694C,
- 0, 0xDA45, 0, 0x436E, 0x7B52, 0, 0, 0xF73B,
- 0, 0x694D, 0, 0, 0, 0x7B53, 0xDA49, 0xF73C,
- 0, 0x467A, 0xF73D, 0x303A, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E89A[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xDA6D, 0, 0x3263, 0x6952, 0x6953, 0xDA4C, 0, 0,
- 0, 0xDA4D, 0, 0x694E, 0, 0x3B3D, 0xDA4E, 0,
- 0xDA4F, 0, 0xDA50, 0, 0xDA51, 0, 0, 0,
- 0, 0xDA52, 0, 0x694F, 0x4742, 0, 0xDA53, 0xDA54,
- 0xDA55, 0x6950, 0x6951, 0x695B, 0, 0xDA56, 0, 0x6955,
- 0x6958, 0xDA57, 0, 0xDA58, 0xDA59, 0xDA5A, 0x6954, 0xDA5B,
- 0xDA5C, 0xDA5D, 0, 0, 0, 0, 0, 0xDA5E,
-};
-static const unsigned short utf8_to_euc_E89A_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0xF73E,
- 0xDA6D, 0xF73F, 0x3263, 0x6952, 0x6953, 0xF740, 0, 0,
- 0, 0xF741, 0, 0x694E, 0, 0x3B3D, 0xDA4E, 0,
- 0x7B54, 0, 0xDA50, 0, 0xF742, 0xF743, 0, 0,
- 0, 0xDA52, 0, 0x694F, 0x4742, 0, 0xDA53, 0xDA54,
- 0xF744, 0x6950, 0x6951, 0x695B, 0, 0xDA56, 0, 0x6955,
- 0x6958, 0xF746, 0, 0xF747, 0xDA59, 0xDA5A, 0x6954, 0xDA5B,
- 0x7B55, 0xDA5D, 0, 0, 0, 0, 0, 0xDA5E,
-};
-static const unsigned short utf8_to_euc_E89B[] = {
- 0xDA5F, 0xDA60, 0, 0xDA61, 0x6956, 0xDA62, 0x6957, 0x3C58,
- 0, 0x6959, 0, 0x4341, 0, 0x3756, 0x3342, 0,
- 0, 0xDA63, 0xDA64, 0, 0x695C, 0xDA65, 0, 0xDA66,
- 0, 0x333F, 0xDA67, 0x6961, 0xDA68, 0, 0x695D, 0x6960,
- 0xDA69, 0, 0, 0xDA6A, 0x483A, 0xDA6B, 0, 0xDA6C,
- 0, 0x695E, 0, 0, 0x695F, 0x4948, 0x485A, 0x6962,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x427D, 0x696C, 0xDA6E, 0x6968, 0xDA6F, 0xDA70, 0x326B, 0,
-};
-static const unsigned short utf8_to_euc_E89B_x0213[] = {
- 0xDA5F, 0xF748, 0, 0xF749, 0x6956, 0xDA62, 0x6957, 0x3C58,
- 0, 0x6959, 0, 0x4341, 0, 0x3756, 0x3342, 0,
- 0, 0xF74A, 0xDA64, 0, 0x695C, 0xF74B, 0, 0xF74C,
- 0, 0x333F, 0xDA67, 0x6961, 0xDA68, 0, 0x695D, 0x6960,
- 0xDA69, 0, 0, 0xF74D, 0x483A, 0xDA6B, 0xF74E, 0xDA6C,
- 0, 0x695E, 0, 0, 0x695F, 0x4948, 0x485A, 0x6962,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x427D, 0x696C, 0x7B56, 0x6968, 0x7B57, 0x7B58, 0x326B, 0,
-};
-static const unsigned short utf8_to_euc_E89C[] = {
- 0x6966, 0, 0x4B2A, 0x6967, 0xDA71, 0xDA72, 0x6964, 0xDA73,
- 0x6965, 0x696A, 0x696D, 0xDA74, 0, 0x696B, 0xDA75, 0xDA76,
- 0xDA77, 0x6969, 0x6963, 0xDA78, 0xDA79, 0, 0, 0,
- 0x4358, 0xDA7A, 0x6974, 0, 0x4C2A, 0, 0xDA7B, 0xDA7C,
- 0, 0xDA7D, 0, 0xDA7E, 0, 0x6972, 0, 0,
- 0xDB21, 0x6973, 0, 0, 0, 0, 0xDB22, 0xDB23,
- 0, 0xDB24, 0xDB25, 0, 0x696E, 0, 0, 0x6970,
- 0, 0xDB26, 0xDB27, 0x6971, 0xDB28, 0xDB29, 0xDB2A, 0x696F,
-};
-static const unsigned short utf8_to_euc_E89C_x0213[] = {
- 0x6966, 0, 0x4B2A, 0x6967, 0xDA71, 0xF750, 0x6964, 0xF751,
- 0x6965, 0x696A, 0x696D, 0x7B59, 0, 0x696B, 0xF752, 0xDA76,
- 0xF753, 0x6969, 0x6963, 0xF754, 0xDA79, 0, 0, 0,
- 0x4358, 0xF755, 0x6974, 0, 0x4C2A, 0, 0xDA7B, 0xF756,
- 0, 0xF757, 0, 0xF758, 0, 0x6972, 0, 0,
- 0xDB21, 0x6973, 0, 0, 0, 0, 0xDB22, 0xDB23,
- 0, 0xF759, 0xDB25, 0, 0x696E, 0, 0, 0x6970,
- 0, 0xDB26, 0xF75A, 0x6971, 0xDB28, 0xDB29, 0xF75B, 0x696F,
-};
-static const unsigned short utf8_to_euc_E89D[] = {
- 0xDB2B, 0, 0, 0xDB2C, 0, 0xDB2D, 0, 0,
- 0, 0x4066, 0, 0x4F39, 0x6978, 0xDB2E, 0x6979, 0,
- 0, 0, 0, 0x6A21, 0, 0x3F2A, 0, 0x697B,
- 0xDB2F, 0x697E, 0, 0, 0, 0xDB30, 0, 0x6976,
- 0x6975, 0xDB31, 0, 0x6A22, 0xDB32, 0xDB33, 0x325C, 0,
- 0x697C, 0, 0x6A23, 0, 0, 0, 0x697D, 0xDB34,
- 0, 0xDB35, 0xDB36, 0, 0x697A, 0, 0x4433, 0,
- 0x6977, 0, 0, 0xDB37, 0, 0, 0, 0x4768,
-};
-static const unsigned short utf8_to_euc_E89D_x0213[] = {
- 0xF75C, 0, 0, 0xF75D, 0, 0xDB2D, 0, 0,
- 0, 0x4066, 0, 0x4F39, 0x6978, 0xDB2E, 0x6979, 0,
- 0, 0xF75E, 0, 0x6A21, 0, 0x3F2A, 0, 0x697B,
- 0xF75F, 0x697E, 0, 0, 0, 0xDB30, 0, 0x6976,
- 0x6975, 0xDB31, 0, 0x6A22, 0xF760, 0xF761, 0x325C, 0,
- 0x697C, 0, 0x6A23, 0, 0, 0, 0x697D, 0xDB34,
- 0, 0x7B5A, 0xF762, 0, 0x697A, 0, 0x4433, 0,
- 0x6977, 0, 0, 0xDB37, 0xF763, 0, 0, 0x4768,
-};
-static const unsigned short utf8_to_euc_E89E[] = {
- 0, 0, 0x6A27, 0xDB38, 0xDB39, 0xDB3A, 0xDB3B, 0xDB3C,
- 0xDB3D, 0xDB3E, 0, 0xDB3F, 0xDB40, 0x4D3B, 0, 0,
- 0xDB41, 0, 0, 0xDB42, 0, 0xDB43, 0, 0xDB44,
- 0xDB45, 0xDB46, 0, 0, 0, 0, 0xDB47, 0x6A26,
- 0xDB48, 0, 0x6A25, 0xDB49, 0, 0, 0, 0xDB4A,
- 0, 0, 0, 0x6A2E, 0xDB4B, 0xDB4C, 0xDB4D, 0x6A28,
- 0, 0xDB4E, 0, 0x6A30, 0, 0xDB4F, 0, 0,
- 0, 0, 0x4D66, 0x6A33, 0, 0x6A2A, 0xDB50, 0xDB51,
-};
-static const unsigned short utf8_to_euc_E89E_x0213[] = {
- 0, 0, 0x6A27, 0xDB38, 0xDB39, 0xDB3A, 0xDB3B, 0x7B5B,
- 0x7B5C, 0xF767, 0, 0xF768, 0xDB40, 0x4D3B, 0, 0,
- 0xDB41, 0, 0, 0xF769, 0, 0xDB43, 0, 0xDB44,
- 0xDB45, 0xDB46, 0, 0, 0, 0, 0xDB47, 0x6A26,
- 0xF76A, 0, 0x6A25, 0xDB49, 0, 0, 0, 0xF766,
- 0, 0, 0, 0x6A2E, 0x7B5D, 0x7B5E, 0xDB4D, 0x6A28,
- 0, 0xDB4E, 0, 0x6A30, 0, 0x7B5F, 0, 0,
- 0, 0, 0x4D66, 0x6A33, 0, 0x6A2A, 0xF76D, 0xDB51,
-};
-static const unsigned short utf8_to_euc_E89F[] = {
- 0x6A2B, 0xDB52, 0, 0, 0x6A2F, 0, 0x6A32, 0x6A31,
- 0xDB53, 0xDB54, 0xDB55, 0x6A29, 0, 0, 0xDB56, 0,
- 0x6A2C, 0, 0x6A3D, 0, 0, 0xDB57, 0xDB58, 0,
- 0, 0xDB59, 0xDB5A, 0, 0xDB5B, 0, 0, 0xDB5C,
- 0x6A36, 0, 0xDB5D, 0xDB5E, 0xDB5F, 0, 0, 0,
- 0, 0, 0xDB60, 0xDB61, 0, 0xDB62, 0, 0x6A34,
- 0, 0xDB63, 0x6A35, 0xDB64, 0, 0, 0x6A3A, 0x6A3B,
- 0xDB65, 0x332A, 0xDB66, 0x3542, 0, 0, 0x6A39, 0xDB67,
-};
-static const unsigned short utf8_to_euc_E89F_x0213[] = {
- 0x6A2B, 0xF76F, 0, 0, 0x6A2F, 0, 0x6A32, 0x6A31,
- 0xDB53, 0xDB54, 0xDB55, 0x6A29, 0, 0, 0xF770, 0,
- 0x6A2C, 0, 0x6A3D, 0, 0, 0xDB57, 0x7B61, 0,
- 0, 0xDB59, 0xDB5A, 0, 0xDB5B, 0, 0, 0xF772,
- 0x6A36, 0, 0xDB5D, 0xF774, 0xDB5F, 0xF775, 0xF776, 0,
- 0, 0, 0xF777, 0xF778, 0x7B62, 0xF779, 0, 0x6A34,
- 0, 0xDB63, 0x6A35, 0xDB64, 0, 0xF771, 0x6A3A, 0x6A3B,
- 0xDB65, 0x332A, 0xDB66, 0x3542, 0, 0, 0x6A39, 0xDB67,
-};
-static const unsigned short utf8_to_euc_E8A0[] = {
- 0, 0xDB68, 0, 0xDB69, 0, 0x6A24, 0xDB6A, 0xF464,
- 0, 0xDB6B, 0xDB6C, 0xDB6D, 0, 0x6A38, 0x6A3C, 0x6A37,
- 0xDB6E, 0x6A3E, 0xDB70, 0xDB71, 0xDB72, 0x6A40, 0x6A3F, 0,
- 0xDB73, 0xDB6F, 0xDB74, 0xDB75, 0xDB76, 0, 0xDB77, 0xDB78,
- 0, 0x6A42, 0x6A41, 0x695A, 0, 0, 0, 0x6A46,
- 0xDB79, 0, 0, 0, 0, 0xDB7A, 0xDB7B, 0,
- 0xDB7C, 0x6A43, 0xDB7D, 0, 0, 0xDB7E, 0x6A44, 0,
- 0, 0x6A45, 0xDC21, 0x6A47, 0xDC22, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8A0_x0213[] = {
- 0, 0xF77A, 0, 0xF77B, 0, 0x6A24, 0x7B63, 0,
- 0, 0xDB6B, 0x7B64, 0xF77C, 0, 0x6A38, 0x6A3C, 0x6A37,
- 0x7B65, 0x6A3E, 0xDB70, 0xF77D, 0x7B66, 0x6A40, 0x6A3F, 0,
- 0xDB73, 0xDB6F, 0xDB74, 0xDB75, 0xDB76, 0, 0xDB77, 0x7B67,
- 0, 0x6A42, 0x6A41, 0x695A, 0, 0, 0, 0x6A46,
- 0xF77E, 0, 0, 0, 0, 0xDB7A, 0xF821, 0,
- 0xDB7C, 0x6A43, 0xF822, 0, 0, 0xDB7E, 0x6A44, 0,
- 0, 0x6A45, 0xDC21, 0x6A47, 0xF823, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8A1[] = {
- 0x376C, 0xDC23, 0x6A49, 0xDC24, 0x6A48, 0xDC25, 0x3D30, 0,
- 0xDC26, 0xDC27, 0xDC28, 0xDC29, 0x3954, 0x5E27, 0xDC2A, 0,
- 0, 0xDC2B, 0x6A4A, 0x3D51, 0, 0xDC2C, 0xDC2D, 0x3339,
- 0xDC2E, 0x6A4B, 0xDC2F, 0x3152, 0xDC30, 0x3E57, 0x6A4C, 0xDC31,
- 0xDC32, 0x3955, 0x6A4D, 0x3061, 0xDC33, 0, 0, 0,
- 0x493D, 0xDC34, 0, 0x6A4E, 0, 0, 0, 0,
- 0x3F6A, 0xDC35, 0x6A55, 0, 0, 0x6A52, 0, 0x436F,
- 0, 0xDC36, 0, 0xDC37, 0, 0x6A53, 0x6A50, 0x365E,
-};
-static const unsigned short utf8_to_euc_E8A1_x0213[] = {
- 0x376C, 0xDC23, 0x6A49, 0xDC24, 0x6A48, 0xDC25, 0x3D30, 0,
- 0xDC26, 0xDC27, 0xF825, 0xDC29, 0x3954, 0x5E27, 0xDC2A, 0,
- 0, 0xDC2B, 0x6A4A, 0x3D51, 0, 0xDC2C, 0xDC2D, 0x3339,
- 0xF826, 0x6A4B, 0xDC2F, 0x3152, 0xDC30, 0x3E57, 0x6A4C, 0xF827,
- 0xDC32, 0x3955, 0x6A4D, 0x3061, 0xF828, 0, 0, 0,
- 0x493D, 0xF82B, 0, 0x6A4E, 0, 0, 0, 0xF82D,
- 0x3F6A, 0xDC35, 0x6A55, 0, 0, 0x6A52, 0, 0x436F,
- 0, 0xDC36, 0, 0xDC37, 0, 0x6A53, 0x6A50, 0x365E,
-};
-static const unsigned short utf8_to_euc_E8A2[] = {
- 0xDC38, 0x6A4F, 0x6A56, 0, 0, 0, 0, 0,
- 0x3736, 0, 0, 0x425E, 0, 0x6A5C, 0, 0,
- 0, 0, 0x6A58, 0, 0, 0, 0x4235, 0x6A57,
- 0xDC39, 0x6A5A, 0xDC3A, 0xDC3B, 0xDC3C, 0, 0x6A51, 0xDC3D,
- 0xDC3E, 0, 0x6A5B, 0, 0x6A5D, 0, 0, 0,
- 0xDC3F, 0, 0xDC40, 0x486F, 0, 0, 0x6A59, 0,
- 0x6A5E, 0x6A60, 0, 0, 0x3853, 0x6A54, 0, 0x3041,
- 0, 0, 0xDC41, 0, 0, 0xDC42, 0xDC43, 0x6A5F,
-};
-static const unsigned short utf8_to_euc_E8A2_x0213[] = {
- 0xDC38, 0x6A4F, 0x6A56, 0, 0, 0, 0, 0,
- 0x3736, 0, 0, 0x425E, 0, 0x6A5C, 0, 0,
- 0, 0, 0x6A58, 0, 0, 0, 0x4235, 0x6A57,
- 0x7B68, 0x6A5A, 0xDC3A, 0xDC3B, 0xDC3C, 0, 0x6A51, 0xDC3D,
- 0xF82E, 0, 0x6A5B, 0, 0x6A5D, 0, 0, 0,
- 0xDC3F, 0, 0x7B69, 0x486F, 0, 0, 0x6A59, 0,
- 0x6A5E, 0x6A60, 0, 0, 0x3853, 0x6A54, 0, 0x3041,
- 0, 0, 0xDC41, 0, 0xF82F, 0xF830, 0xF831, 0x6A5F,
-};
-static const unsigned short utf8_to_euc_E8A3[] = {
- 0xDC44, 0x3A5B, 0x4E76, 0x6A61, 0x6A62, 0x4175, 0, 0,
- 0, 0, 0xDC45, 0xDC46, 0xDC47, 0xDC48, 0xDC49, 0x4E22,
- 0, 0xDC4A, 0xDC4B, 0xDC4C, 0x6A63, 0x4D35, 0, 0,
- 0x6A64, 0x6A65, 0, 0xDC4D, 0x4A64, 0x6A66, 0xDC4E, 0x3A40,
- 0, 0x4E23, 0, 0, 0, 0, 0, 0xDC4F,
- 0x6A6B, 0, 0, 0, 0, 0, 0, 0xDC50,
- 0xDC51, 0xDC52, 0x6A6C, 0x3E58, 0x6A6A, 0xDC53, 0, 0xDC54,
- 0x4D67, 0x6A67, 0, 0, 0x6A69, 0x403D, 0x3F7E, 0,
-};
-static const unsigned short utf8_to_euc_E8A3_x0213[] = {
- 0xF832, 0x3A5B, 0x4E76, 0x6A61, 0x6A62, 0x4175, 0, 0,
- 0, 0, 0x7B6A, 0xDC46, 0xDC47, 0xDC48, 0x7B6B, 0x4E22,
- 0, 0xF835, 0xF833, 0xF836, 0x6A63, 0x4D35, 0, 0,
- 0x6A64, 0x6A65, 0, 0xF837, 0x4A64, 0x6A66, 0xDC4E, 0x3A40,
- 0, 0x4E23, 0, 0, 0, 0, 0, 0xDC4F,
- 0x6A6B, 0, 0, 0, 0, 0, 0, 0xDC50,
- 0xF838, 0xF839, 0x6A6C, 0x3E58, 0x6A6A, 0x7B6D, 0, 0xDC54,
- 0x4D67, 0x6A67, 0, 0, 0x6A69, 0x403D, 0x3F7E, 0,
-};
-static const unsigned short utf8_to_euc_E8A4[] = {
- 0, 0xDC55, 0x6A68, 0, 0x6A6D, 0, 0xDC56, 0x4A23,
- 0, 0, 0x6A6F, 0, 0x6A6E, 0xDC57, 0xDC58, 0xDC59,
- 0x336C, 0, 0x4B2B, 0x6A70, 0, 0xDC5A, 0xDC5B, 0,
- 0xDC5C, 0xDC5D, 0xDC5E, 0, 0xDC5F, 0x6A7C, 0x6A72, 0,
- 0xDC60, 0, 0, 0, 0, 0x6A73, 0xDC61, 0xDC62,
- 0xDC63, 0, 0x6A74, 0x6A75, 0, 0, 0, 0,
- 0xDC64, 0xDC65, 0xDC66, 0, 0, 0xDC67, 0x6A79, 0,
- 0x6A7A, 0xDC68, 0xDC69, 0x6A78, 0, 0, 0xDC6A, 0,
-};
-static const unsigned short utf8_to_euc_E8A4_x0213[] = {
- 0, 0xF83B, 0x6A68, 0, 0x6A6D, 0, 0xDC56, 0x4A23,
- 0, 0, 0x6A6F, 0, 0x6A6E, 0xDC57, 0xDC58, 0xDC59,
- 0x336C, 0, 0x4B2B, 0x6A70, 0, 0xDC5A, 0xDC5B, 0,
- 0x7B70, 0x7B71, 0x7B72, 0, 0x7B6E, 0x6A7C, 0x6A72, 0,
- 0xDC60, 0, 0, 0, 0, 0x6A73, 0xDC61, 0x7B73,
- 0xDC63, 0, 0x6A74, 0x6A75, 0, 0, 0, 0,
- 0x7B74, 0xDC65, 0x7B75, 0, 0, 0xDC67, 0x6A79, 0xF83D,
- 0x6A7A, 0x7B76, 0xDC69, 0x6A78, 0, 0, 0xDC6A, 0,
-};
-static const unsigned short utf8_to_euc_E8A5[] = {
- 0xDC6B, 0x6A76, 0xDC6C, 0x6A71, 0x6A77, 0xDC6D, 0xDC6E, 0,
- 0, 0xDC6F, 0, 0, 0x6A7B, 0x7037, 0, 0xDC70,
- 0, 0, 0xDC71, 0, 0, 0, 0x3228, 0xDC72,
- 0, 0, 0xDC73, 0xDC74, 0xDC75, 0, 0x6A7E, 0x365F,
- 0x6A7D, 0xDC76, 0xDC77, 0xDC78, 0x6B22, 0, 0x6B21, 0,
- 0, 0, 0x6B24, 0xDC79, 0, 0x6B23, 0xDC7A, 0x6B25,
- 0xDC7B, 0, 0x3D31, 0xDC7C, 0x6B26, 0xDC7D, 0, 0x6B27,
- 0, 0, 0xDC7E, 0xDD21, 0xDD22, 0xDD23, 0x6B28, 0x403E,
-};
-static const unsigned short utf8_to_euc_E8A5_x0213[] = {
- 0x7B77, 0x6A76, 0xF83F, 0x6A71, 0x6A77, 0xF840, 0xDC6E, 0,
- 0, 0xF841, 0, 0, 0x6A7B, 0x7037, 0, 0xDC70,
- 0, 0, 0xDC71, 0, 0, 0, 0x3228, 0xDC72,
- 0, 0, 0xDC73, 0xDC74, 0xDC75, 0, 0x6A7E, 0x365F,
- 0x6A7D, 0xDC76, 0xF844, 0xDC78, 0x6B22, 0, 0x6B21, 0,
- 0, 0, 0x6B24, 0xDC79, 0, 0x6B23, 0xDC7A, 0x6B25,
- 0xDC7B, 0, 0x3D31, 0xDC7C, 0x6B26, 0xDC7D, 0, 0x6B27,
- 0, 0, 0xDC7E, 0xDD21, 0xDD22, 0xDD23, 0x6B28, 0x403E,
-};
-static const unsigned short utf8_to_euc_E8A6[] = {
- 0, 0x4D57, 0, 0x6B29, 0, 0, 0x4A24, 0x4746,
- 0x6B2A, 0xDD24, 0x6B2B, 0x382B, 0, 0xDD25, 0, 0x352C,
- 0xDD26, 0, 0, 0x6B2C, 0xDD27, 0xDD28, 0x3B6B, 0x4741,
- 0x6B2D, 0, 0x3350, 0xDD29, 0xDD2A, 0, 0, 0xDD2B,
- 0xDD2C, 0x6B2E, 0, 0, 0, 0xDD2D, 0x6B30, 0x4D77,
- 0, 0x6B2F, 0x3F46, 0, 0x6B31, 0, 0, 0x6B32,
- 0xDD2E, 0, 0x6B33, 0x3451, 0xDD2F, 0xDD30, 0xDD31, 0xDD32,
- 0, 0, 0x6B34, 0, 0xDD33, 0x6B35, 0, 0x6B36,
-};
-static const unsigned short utf8_to_euc_E8A6_x0213[] = {
- 0xF845, 0x4D57, 0, 0x6B29, 0, 0, 0x4A24, 0x4746,
- 0x6B2A, 0xF846, 0x6B2B, 0x382B, 0, 0xDD25, 0, 0x352C,
- 0xF847, 0, 0, 0x6B2C, 0x7B78, 0xDD28, 0x3B6B, 0x4741,
- 0x6B2D, 0, 0x3350, 0xDD29, 0xDD2A, 0, 0, 0xF848,
- 0xDD2C, 0x6B2E, 0, 0, 0, 0xDD2D, 0x6B30, 0x4D77,
- 0, 0x6B2F, 0x3F46, 0, 0x6B31, 0, 0, 0x6B32,
- 0xF849, 0, 0x6B33, 0x3451, 0xDD2F, 0xDD30, 0xDD31, 0xF84A,
- 0, 0, 0x6B34, 0, 0xDD33, 0x6B35, 0, 0x6B36,
-};
-static const unsigned short utf8_to_euc_E8A7[] = {
- 0x6B37, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x3351, 0, 0xDD34, 0xDD35, 0xDD36, 0xDD37,
- 0xDD38, 0, 0x6B38, 0, 0x6B39, 0x6B3A, 0, 0,
- 0, 0, 0, 0x3272, 0, 0xDD39, 0x3F28, 0x6B3B,
- 0, 0xDD3A, 0, 0xDD3B, 0, 0xDD3C, 0, 0,
- 0, 0xDD3D, 0, 0xDD3E, 0x6B3C, 0, 0xDD3F, 0,
- 0x6B3D, 0xDD40, 0, 0, 0, 0xDD41, 0, 0xDD42,
-};
-static const unsigned short utf8_to_euc_E8A7_x0213[] = {
- 0x6B37, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x3351, 0, 0x7B7A, 0xDD35, 0xF84B, 0xDD37,
- 0xF84C, 0, 0x6B38, 0, 0x6B39, 0x6B3A, 0, 0,
- 0, 0, 0, 0x3272, 0, 0x7B7B, 0x3F28, 0x6B3B,
- 0, 0xDD3A, 0, 0xF84D, 0, 0xDD3C, 0, 0,
- 0, 0xF84F, 0, 0xF850, 0x6B3C, 0, 0x7B7C, 0,
- 0x6B3D, 0xDD40, 0, 0, 0, 0xF851, 0, 0xF852,
-};
-static const unsigned short utf8_to_euc_E8A8[] = {
- 0x3840, 0, 0x447B, 0x6B3E, 0xDD43, 0xDD44, 0, 0xDD45,
- 0x3757, 0, 0x3F56, 0, 0x6B41, 0, 0x4624, 0xDD46,
- 0x6B40, 0xDD47, 0xDD48, 0x3731, 0xDD49, 0xDD4A, 0x6B3F, 0x4277,
- 0x352D, 0, 0, 0x6B42, 0, 0x6B43, 0xDD4B, 0x3E59,
- 0xDD4C, 0, 0xDD4D, 0x376D, 0xDD4E, 0x6B44, 0xDD4F, 0,
- 0, 0, 0x4B2C, 0xDD50, 0xDD51, 0x405F, 0, 0xDD52,
- 0, 0x3576, 0, 0x4C75, 0x414A, 0xDD53, 0x6B45, 0xDD54,
- 0, 0, 0x3F47, 0x4370, 0x3E5A, 0xDD55, 0xDD56, 0,
-};
-static const unsigned short utf8_to_euc_E8A8_x0213[] = {
- 0x3840, 0, 0x447B, 0x6B3E, 0xDD43, 0xDD44, 0, 0xDD45,
- 0x3757, 0, 0x3F56, 0, 0x6B41, 0, 0x4624, 0xDD46,
- 0x6B40, 0xF854, 0x7B7D, 0x3731, 0xF855, 0x7B7E, 0x6B3F, 0x4277,
- 0x352D, 0, 0, 0x6B42, 0, 0x6B43, 0xDD4B, 0x3E59,
- 0xDD4C, 0xF857, 0x7C21, 0x376D, 0xDD4E, 0x6B44, 0xDD4F, 0,
- 0, 0, 0x4B2C, 0xDD50, 0xDD51, 0x405F, 0, 0xDD52,
- 0, 0x3576, 0, 0x4C75, 0x414A, 0xF858, 0x6B45, 0x7C22,
- 0, 0, 0x3F47, 0x4370, 0x3E5A, 0xDD55, 0xF859, 0,
-};
-static const unsigned short utf8_to_euc_E8A9[] = {
- 0xDD57, 0x6B46, 0, 0xDD58, 0, 0xDD59, 0x6B49, 0xDD5A,
- 0x6B4A, 0xDD5B, 0, 0, 0, 0xDD5C, 0xDD5D, 0,
- 0x3A3E, 0x4242, 0x6B48, 0xDD5E, 0x3E5B, 0x493E, 0xDD5F, 0xDD60,
- 0xDD61, 0, 0, 0x6B47, 0xDD62, 0xDD63, 0x3B6C, 0,
- 0x3153, 0xDD64, 0x6B4E, 0x3758, 0, 0xDD65, 0x3B6E, 0xDD66,
- 0, 0x3B6D, 0, 0x4F4D, 0x6B4D, 0x6B4C, 0x4127, 0,
- 0x354D, 0x4F43, 0x333A, 0x3E5C, 0, 0xDD67, 0xDD68, 0xDD69,
- 0, 0xDD6A, 0xDD6B, 0xDD6C, 0x6B4B, 0, 0xDD6D, 0xDD6E,
-};
-static const unsigned short utf8_to_euc_E8A9_x0213[] = {
- 0xDD57, 0x6B46, 0, 0xDD58, 0, 0xF85A, 0x6B49, 0x7C23,
- 0x6B4A, 0xDD5B, 0, 0, 0, 0xF85B, 0x7C24, 0,
- 0x3A3E, 0x4242, 0x6B48, 0xDD5E, 0x3E5B, 0x493E, 0xDD5F, 0xDD60,
- 0xF85C, 0, 0, 0x6B47, 0xDD62, 0x7C25, 0x3B6C, 0,
- 0x3153, 0x7C26, 0x6B4E, 0x3758, 0, 0xDD65, 0x3B6E, 0xDD66,
- 0, 0x3B6D, 0, 0x4F4D, 0x6B4D, 0x6B4C, 0x4127, 0,
- 0x354D, 0x4F43, 0x333A, 0x3E5C, 0, 0x7C27, 0xDD68, 0xDD69,
- 0, 0x7C28, 0xDD6B, 0xDD6C, 0x6B4B, 0, 0xDD6D, 0xDD6E,
-};
-static const unsigned short utf8_to_euc_E8AA[] = {
- 0xDD6F, 0, 0x6B50, 0xDD70, 0x6B51, 0x6B4F, 0xDD71, 0x3858,
- 0, 0x4D40, 0, 0xDD72, 0x3B6F, 0x4727, 0, 0xDD73,
- 0xDD74, 0x6B54, 0xDD75, 0x4040, 0, 0x4342, 0xDD76, 0xDD77,
- 0x4D36, 0xDD78, 0x6B57, 0, 0, 0, 0x386C, 0xDD79,
- 0x403F, 0x6B53, 0, 0x6B58, 0x386D, 0x6B55, 0x6B56, 0xDD7A,
- 0x6B52, 0xDD7B, 0, 0, 0x4062, 0x4649, 0xDD7C, 0xDD7D,
- 0x432F, 0, 0x325D, 0xDD7E, 0, 0, 0xDE21, 0xDE22,
- 0, 0x4870, 0, 0xDE23, 0x3543, 0, 0xDE24, 0x4434,
-};
-static const unsigned short utf8_to_euc_E8AA_x0213[] = {
- 0xDD6F, 0, 0x6B50, 0xDD70, 0x6B51, 0x6B4F, 0xDD71, 0x3858,
- 0, 0x4D40, 0, 0xDD72, 0x3B6F, 0x4727, 0, 0xDD73,
- 0xF85E, 0x6B54, 0xDD75, 0x4040, 0, 0x4342, 0xDD76, 0xDD77,
- 0x4D36, 0xDD78, 0x6B57, 0, 0, 0, 0x386C, 0xDD79,
- 0x403F, 0x6B53, 0, 0x6B58, 0x386D, 0x6B55, 0x6B56, 0x7C29,
- 0x6B52, 0xDD7B, 0, 0, 0x4062, 0x4649, 0xF85D, 0xDD7D,
- 0x432F, 0, 0x325D, 0xDD7E, 0, 0, 0xDE21, 0xF85F,
- 0, 0x4870, 0, 0xDE23, 0x3543, 0, 0xF860, 0x4434,
-};
-static const unsigned short utf8_to_euc_E8AB[] = {
- 0, 0, 0x6B5B, 0xDE25, 0x6B59, 0, 0xDE26, 0x434C,
- 0xDE27, 0xDE28, 0xDE29, 0x4041, 0x3452, 0x6B5A, 0, 0x3F5B,
- 0, 0xDE2A, 0x4E4A, 0xDE2B, 0xDE2C, 0xDE2D, 0x4F40, 0xDE2E,
- 0, 0, 0x6B5C, 0x6B67, 0x4435, 0xDE2F, 0x6B66, 0xDE30,
- 0x6B63, 0x6B6B, 0x6B64, 0, 0x6B60, 0, 0x447C, 0x6B5F,
- 0, 0, 0, 0x6B5D, 0xDE31, 0x4D21, 0x3B70, 0,
- 0xDE32, 0x6B61, 0, 0x6B5E, 0xDE33, 0xDE34, 0xDE35, 0x6B65,
- 0x3D74, 0, 0x3841, 0, 0xDE36, 0, 0x427A, 0xDE37,
-};
-static const unsigned short utf8_to_euc_E8AB_x0213[] = {
- 0, 0, 0x6B5B, 0xDE25, 0x6B59, 0, 0xDE26, 0x434C,
- 0xDE27, 0xDE28, 0xDE29, 0x4041, 0x3452, 0x6B5A, 0, 0x3F5B,
- 0x7C2A, 0xDE2A, 0x4E4A, 0xDE2B, 0xDE2C, 0xDE2D, 0x4F40, 0xF861,
- 0, 0, 0x6B5C, 0x6B67, 0x4435, 0xDE2F, 0x6B66, 0x7C2B,
- 0x6B63, 0x6B6B, 0x6B64, 0, 0x6B60, 0, 0x447C, 0x6B5F,
- 0, 0, 0, 0x6B5D, 0xDE31, 0x4D21, 0x3B70, 0,
- 0xDE32, 0x6B61, 0, 0x6B5E, 0x7C2C, 0xDE34, 0x7C2D, 0x6B65,
- 0x3D74, 0, 0x3841, 0, 0xF862, 0, 0x427A, 0xDE37,
-};
-static const unsigned short utf8_to_euc_E8AC[] = {
- 0x4B45, 0x315A, 0x3062, 0, 0x4625, 0xDE38, 0xDE39, 0x6B69,
- 0, 0, 0xDE3F, 0xDE3A, 0x6B68, 0, 0x4666, 0,
- 0x6B6D, 0xDE3B, 0, 0, 0x6B62, 0, 0x6B6C, 0x6B6E,
- 0, 0x382C, 0x6B6A, 0x3956, 0xDE3C, 0x3C55, 0xDE3D, 0xDE3E,
- 0x6B6F, 0x4D58, 0, 0, 0, 0, 0x6B72, 0,
- 0x6B75, 0, 0, 0x6B73, 0x4935, 0xDE40, 0, 0,
- 0xDE41, 0, 0, 0x6B70, 0, 0, 0, 0xDE42,
- 0, 0x3660, 0, 0, 0xDE43, 0, 0x6B74, 0,
-};
-static const unsigned short utf8_to_euc_E8AC_x0213[] = {
- 0x4B45, 0x315A, 0x3062, 0, 0x4625, 0xF865, 0xDE39, 0x6B69,
- 0, 0, 0xF864, 0xDE3A, 0x6B68, 0xF866, 0x4666, 0,
- 0x6B6D, 0xDE3B, 0, 0, 0x6B62, 0, 0x6B6C, 0x6B6E,
- 0, 0x382C, 0x6B6A, 0x3956, 0xF867, 0x3C55, 0xDE3D, 0xF868,
- 0x6B6F, 0x4D58, 0, 0, 0, 0, 0x6B72, 0,
- 0x6B75, 0, 0, 0x6B73, 0x4935, 0xF869, 0, 0,
- 0xDE41, 0, 0, 0x6B70, 0, 0, 0, 0xDE42,
- 0, 0x3660, 0, 0, 0xDE43, 0, 0x6B74, 0,
-};
-static const unsigned short utf8_to_euc_E8AD[] = {
- 0, 0x6B76, 0xDE44, 0xDE45, 0xDE46, 0xDE47, 0xDE48, 0,
- 0xDE49, 0x6B7A, 0, 0, 0x6B77, 0xDE4E, 0x6B79, 0x6B78,
- 0, 0, 0xDE4A, 0xDE4B, 0xDE4C, 0, 0x6B7B, 0,
- 0x3C31, 0xDE4D, 0x6B7D, 0x6B7C, 0x4968, 0, 0xDE4F, 0x6C21,
- 0, 0, 0, 0xDE50, 0, 0, 0x3759, 0,
- 0, 0, 0, 0x6B7E, 0x6C22, 0xDE51, 0, 0x6C23,
- 0x3544, 0x6641, 0x3E79, 0, 0x6C24, 0, 0xDE52, 0x386E,
- 0xDE53, 0xDE54, 0, 0, 0xDE55, 0x6C25, 0xDE56, 0xF466,
-};
-static const unsigned short utf8_to_euc_E8AD_x0213[] = {
- 0, 0x6B76, 0xDE44, 0xF86A, 0xDE46, 0xDE47, 0x7C31, 0,
- 0xDE49, 0x6B7A, 0, 0, 0x6B77, 0xDE4E, 0x6B79, 0x6B78,
- 0, 0xF86C, 0xDE4A, 0, 0x7C32, 0, 0x6B7B, 0,
- 0x3C31, 0x7C33, 0x6B7D, 0x6B7C, 0x4968, 0, 0xF86D, 0x6C21,
- 0, 0, 0, 0xDE50, 0, 0, 0x3759, 0,
- 0, 0x7C34, 0, 0x6B7E, 0x6C22, 0xDE51, 0, 0x6C23,
- 0x3544, 0x6641, 0x3E79, 0, 0x6C24, 0, 0xF86E, 0x386E,
- 0xDE53, 0xDE54, 0, 0, 0xDE55, 0x6C25, 0xDE56, 0xF86F,
-};
-static const unsigned short utf8_to_euc_E8AE[] = {
- 0x6C26, 0xDE57, 0, 0x3B3E, 0xDE58, 0xDE59, 0, 0,
- 0, 0, 0x5A4E, 0xDE5A, 0x6C27, 0xDE5B, 0x6C28, 0xDE5C,
- 0x3D32, 0, 0x6C29, 0x6C2A, 0xDE5D, 0xDE5E, 0x6C2B, 0,
- 0, 0x6C2C, 0x6C2D, 0, 0xDE5F, 0, 0xDE60, 0xDE61,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E8AE_x0213[] = {
- 0x6C26, 0xF870, 0, 0x3B3E, 0xDE58, 0xDE59, 0, 0,
- 0, 0, 0x5A4E, 0xF871, 0x6C27, 0xDE5B, 0x6C28, 0xDE5C,
- 0x3D32, 0, 0x6C29, 0x6C2A, 0xF872, 0xF873, 0x6C2B, 0,
- 0, 0x6C2C, 0x6C2D, 0, 0xF874, 0x7C35, 0xF875, 0xDE61,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E8B0[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x432B,
- 0xDE62, 0xDE63, 0x6C2E, 0, 0, 0xDE64, 0xDE65, 0x6C30,
-};
-static const unsigned short utf8_to_euc_E8B0_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x432B,
- 0xDE62, 0xF876, 0x6C2E, 0, 0, 0xF878, 0xDE65, 0x6C30,
-};
-static const unsigned short utf8_to_euc_E8B1[] = {
- 0, 0x6C2F, 0, 0, 0, 0xDE66, 0x4626, 0xDE67,
- 0x6C31, 0xDE68, 0x4B2D, 0xDE69, 0x6C32, 0, 0x6C33, 0xDE6A,
- 0x6C34, 0xDE6B, 0, 0xDE6C, 0xDE6D, 0x6C35, 0, 0xDE6E,
- 0xDE6F, 0xDE72, 0x465A, 0xDE70, 0, 0xDE71, 0, 0,
- 0, 0x3E5D, 0x6C36, 0xDE73, 0xDE74, 0, 0xDE75, 0,
- 0xDE76, 0xDE77, 0x396B, 0x502E, 0x6C37, 0xDE78, 0, 0,
- 0, 0, 0, 0xDE79, 0, 0xDE7A, 0xDE7B, 0,
- 0x6C38, 0x493F, 0x6C39, 0xDE7C, 0x6C41, 0, 0xDE7D, 0,
-};
-static const unsigned short utf8_to_euc_E8B1_x0213[] = {
- 0, 0x6C2F, 0, 0, 0, 0xF87B, 0x4626, 0xF87C,
- 0x6C31, 0x7C36, 0x4B2D, 0xDE69, 0x6C32, 0, 0x6C33, 0xF87D,
- 0x6C34, 0xDE6B, 0, 0xDE6C, 0xF87E, 0x6C35, 0, 0xF921,
- 0xDE6F, 0xDE72, 0x465A, 0xDE70, 0, 0xDE71, 0, 0,
- 0, 0x3E5D, 0x6C36, 0xDE73, 0xDE74, 0, 0xDE75, 0,
- 0x7C37, 0xF922, 0x396B, 0x502E, 0x6C37, 0xF923, 0, 0,
- 0, 0, 0, 0xF924, 0, 0xDE7A, 0xDE7B, 0,
- 0x6C38, 0x493F, 0x6C39, 0xDE7C, 0x6C41, 0, 0xDE7D, 0,
-};
-static const unsigned short utf8_to_euc_E8B2[] = {
- 0, 0, 0x6C3A, 0, 0, 0x6C3C, 0xDE7E, 0xDF21,
- 0, 0x6C3B, 0x6C3D, 0xDF22, 0x4B46, 0x6C3E, 0x6C3F, 0,
- 0xDF23, 0, 0xDF24, 0xDF25, 0x6C40, 0, 0, 0,
- 0x6C42, 0xDF26, 0, 0xDF27, 0xDF28, 0x332D, 0x4467, 0,
- 0x4969, 0x3A62, 0x3957, 0, 0xDF29, 0, 0, 0x494F,
- 0x325F, 0x484E, 0x6C45, 0x3453, 0x4055, 0x6C44, 0x6C49, 0x4379,
- 0x4C63, 0, 0x6C47, 0x6C48, 0x352E, 0, 0x6C4A, 0x4763,
- 0x425F, 0xDF2A, 0xDF2B, 0x4871, 0x453D, 0x6C46, 0, 0x4B47,
-};
-static const unsigned short utf8_to_euc_E8B2_x0213[] = {
- 0, 0, 0x6C3A, 0, 0, 0x6C3C, 0xDE7E, 0xDF21,
- 0, 0x6C3B, 0x6C3D, 0xDF22, 0x4B46, 0x6C3E, 0x6C3F, 0,
- 0xDF23, 0, 0xF927, 0xF926, 0x6C40, 0, 0, 0,
- 0x6C42, 0xF928, 0, 0xF92A, 0xDF28, 0x332D, 0x4467, 0,
- 0x4969, 0x3A62, 0x3957, 0, 0xF92B, 0, 0, 0x494F,
- 0x325F, 0x484E, 0x6C45, 0x3453, 0x4055, 0x6C44, 0x6C49, 0x4379,
- 0x4C63, 0, 0x6C47, 0x6C48, 0x352E, 0, 0x6C4A, 0x4763,
- 0x425F, 0xDF2A, 0xDF2B, 0x4871, 0x453D, 0x6C46, 0, 0x4B47,
-};
-static const unsigned short utf8_to_euc_E8B3[] = {
- 0x326C, 0x6C4C, 0x4F28, 0x4442, 0x4F45, 0xDF2C, 0xDF2D, 0x3B71,
- 0x6C4B, 0xDF2E, 0x4231, 0xDF2F, 0, 0x6C5C, 0x4128, 0xDF30,
- 0, 0x4678, 0, 0x4950, 0, 0xDF32, 0xDF31, 0,
- 0, 0xDF33, 0x6C4F, 0x3B3F, 0x3B72, 0xDF34, 0x3E5E, 0,
- 0x4765, 0xDF35, 0x382D, 0x6C4E, 0x6C4D, 0, 0x496A, 0,
- 0xDF36, 0, 0x3C41, 0, 0xDF37, 0x4552, 0, 0xDF38,
- 0xDF39, 0, 0xDF3A, 0, 0xF467, 0xDF3B, 0, 0xDF3C,
- 0xDF3D, 0, 0x6C51, 0x6C52, 0x3958, 0x6C50, 0xDF3E, 0xDF3F,
-};
-static const unsigned short utf8_to_euc_E8B3_x0213[] = {
- 0x326C, 0x6C4C, 0x4F28, 0x4442, 0x4F45, 0xDF2C, 0xDF2D, 0x3B71,
- 0x6C4B, 0xDF2E, 0x4231, 0xDF2F, 0, 0x6C5C, 0x4128, 0xDF30,
- 0, 0x4678, 0, 0x4950, 0, 0xF92D, 0xF92C, 0,
- 0, 0xF92E, 0x6C4F, 0x3B3F, 0x3B72, 0xDF34, 0x3E5E, 0,
- 0x4765, 0x7C39, 0x382D, 0x6C4E, 0x6C4D, 0, 0x496A, 0,
- 0xDF36, 0, 0x3C41, 0, 0xDF37, 0x4552, 0, 0xDF38,
- 0xF930, 0xF931, 0xDF3A, 0, 0x7C3A, 0xDF3B, 0, 0xDF3C,
- 0x7C3B, 0, 0x6C51, 0x6C52, 0x3958, 0x6C50, 0x7C3C, 0xDF3F,
-};
-static const unsigned short utf8_to_euc_E8B4[] = {
- 0, 0xDF40, 0, 0xDF41, 0x6C53, 0x6C54, 0, 0x6C56,
- 0x4223, 0xDF42, 0x6C55, 0x3466, 0, 0x6C58, 0, 0x6C57,
- 0x6C59, 0, 0xDF43, 0x6C5B, 0x6C5D, 0, 0x6C5E, 0xDF44,
- 0, 0, 0, 0xDF45, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E8B4_x0213[] = {
- 0, 0xDF40, 0, 0xDF41, 0x6C53, 0x6C54, 0, 0x6C56,
- 0x4223, 0xF933, 0x6C55, 0x3466, 0, 0x6C58, 0xF934, 0x6C57,
- 0x6C59, 0, 0x7C3E, 0x6C5B, 0x6C5D, 0, 0x6C5E, 0xDF44,
- 0, 0, 0, 0x7C3F, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E8B5[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x4056, 0xDF46, 0x3C4F, 0x6C5F,
- 0, 0xDF47, 0, 0x3352, 0xDF48, 0x6C60, 0xDF49, 0,
- 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0xF468, 0x352F,
- 0, 0, 0, 0, 0, 0, 0, 0xDF4A,
-};
-static const unsigned short utf8_to_euc_E8B5_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x4056, 0xDF46, 0x3C4F, 0x6C5F,
- 0, 0xDF47, 0, 0x3352, 0xF935, 0x6C60, 0xDF49, 0,
- 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0, 0x352F,
- 0, 0, 0, 0, 0, 0, 0, 0xDF4A,
-};
-static const unsigned short utf8_to_euc_E8B6[] = {
- 0, 0x6C63, 0xDF4B, 0, 0xDF4C, 0x4436, 0, 0,
- 0xDF4D, 0, 0x315B, 0, 0, 0xDF4E, 0, 0,
- 0xDF4F, 0xDF50, 0, 0, 0, 0xDF51, 0, 0,
- 0, 0x6C64, 0, 0, 0, 0, 0xDF52, 0xDF53,
- 0xDF54, 0, 0, 0x3C71, 0, 0, 0xDF55, 0,
- 0x3F76, 0, 0, 0xDF56, 0xDF57, 0, 0, 0xDF58,
- 0, 0, 0xDF59, 0x422D, 0, 0xDF5A, 0, 0xDF5B,
- 0, 0xDF5C, 0x6C67, 0xDF5D, 0xDF6F, 0, 0x6C66, 0,
-};
-static const unsigned short utf8_to_euc_E8B6_x0213[] = {
- 0, 0x6C63, 0xDF4B, 0, 0xF936, 0x4436, 0, 0,
- 0xDF4D, 0, 0x315B, 0, 0, 0xDF4E, 0, 0,
- 0xDF4F, 0xDF50, 0, 0, 0, 0xF937, 0, 0,
- 0, 0x6C64, 0, 0, 0, 0, 0xDF52, 0xDF53,
- 0xDF54, 0, 0, 0x3C71, 0, 0, 0xF938, 0,
- 0x3F76, 0, 0, 0xDF56, 0xDF57, 0, 0, 0x7C40,
- 0, 0, 0xDF59, 0x422D, 0, 0xDF5A, 0, 0xDF5B,
- 0, 0xDF5C, 0x6C67, 0xDF5D, 0xDF6F, 0, 0x6C66, 0,
-};
-static const unsigned short utf8_to_euc_E8B7[] = {
- 0xDF5E, 0, 0x6C65, 0, 0, 0xDF5F, 0xDF60, 0xDF61,
- 0xDF62, 0, 0xDF63, 0x6C6D, 0x6C6B, 0, 0xDF64, 0x6C68,
- 0, 0xDF65, 0, 0, 0xDF66, 0xDF67, 0x6C6A, 0xDF68,
- 0, 0xDF69, 0x6C69, 0x6C6C, 0, 0x3577, 0, 0x6C70,
- 0, 0x4057, 0, 0x6C71, 0xDF6A, 0xDF6B, 0, 0xDF6C,
- 0x3859, 0, 0x6C6E, 0x6C6F, 0xDF6D, 0, 0, 0x4F29,
- 0xDF6E, 0xDF70, 0xDF71, 0x4437, 0xDF72, 0x4129, 0, 0,
- 0, 0, 0, 0, 0x6C72, 0xDF73, 0, 0x6C75,
-};
-static const unsigned short utf8_to_euc_E8B7_x0213[] = {
- 0xDF5E, 0, 0x6C65, 0, 0, 0xDF5F, 0xF93A, 0xDF61,
- 0xF93B, 0, 0xDF63, 0x6C6D, 0x6C6B, 0, 0x7C41, 0x6C68,
- 0, 0x7C42, 0, 0, 0xDF66, 0xDF67, 0x6C6A, 0x7C43,
- 0, 0xF93C, 0x6C69, 0x6C6C, 0, 0x3577, 0, 0x6C70,
- 0, 0x4057, 0, 0x6C71, 0xDF6A, 0xDF6B, 0, 0xDF6C,
- 0x3859, 0, 0x6C6E, 0x6C6F, 0xF93D, 0, 0, 0x4F29,
- 0xDF6E, 0xDF70, 0xDF71, 0x4437, 0xDF72, 0x4129, 0, 0,
- 0, 0, 0, 0, 0x6C72, 0xF940, 0, 0x6C75,
-};
-static const unsigned short utf8_to_euc_E8B8[] = {
- 0, 0xDF74, 0, 0, 0xDF75, 0xDF76, 0xDF77, 0,
- 0x6C73, 0x6C74, 0x4D59, 0xDF78, 0, 0, 0, 0x4627,
- 0x6C78, 0xDF79, 0, 0, 0xDF7A, 0, 0xDF7B, 0,
- 0, 0, 0, 0, 0, 0x6C76, 0x6C77, 0x6C79,
- 0xDF7C, 0xDF7D, 0xDF7E, 0xE021, 0, 0, 0xE022, 0xE023,
- 0, 0, 0x6D29, 0, 0, 0, 0, 0,
- 0x6C7C, 0xE024, 0, 0xE025, 0x6C7D, 0x6C7B, 0xE026, 0xE027,
- 0xE028, 0xE029, 0, 0, 0, 0xE02A, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8B8_x0213[] = {
- 0, 0xDF74, 0, 0, 0xDF75, 0xDF76, 0xF941, 0,
- 0x6C73, 0x6C74, 0x4D59, 0xDF78, 0xF93E, 0, 0, 0x4627,
- 0x6C78, 0xDF79, 0, 0, 0xF943, 0, 0xF944, 0,
- 0, 0, 0, 0, 0, 0x6C76, 0x6C77, 0x6C79,
- 0x7C44, 0xF945, 0xF946, 0x7C45, 0, 0, 0xE022, 0xF947,
- 0, 0, 0x6D29, 0, 0, 0, 0, 0,
- 0x6C7C, 0xE024, 0, 0xE025, 0x6C7D, 0x6C7B, 0xF94A, 0xE027,
- 0xE028, 0xF94B, 0, 0, 0, 0x7C46, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8B9[] = {
- 0xE02B, 0xE02C, 0x6C7A, 0, 0x447D, 0, 0, 0x6D21,
- 0x6D25, 0x6D22, 0x6C7E, 0xE02D, 0x6D23, 0xE02E, 0xE02F, 0xE030,
- 0x6D24, 0, 0, 0, 0xE031, 0x6D2B, 0, 0,
- 0, 0x6D26, 0, 0xE032, 0xE033, 0xE034, 0xE035, 0x4058,
- 0x6D28, 0xE036, 0xE037, 0x6D2A, 0x6D27, 0, 0, 0,
- 0, 0xE038, 0, 0, 0xE039, 0xE03A, 0, 0xE03B,
- 0xE03C, 0xE03D, 0x6D2D, 0, 0x3D33, 0, 0x6D2C, 0,
- 0, 0xE03E, 0xE03F, 0xE040, 0x6D2E, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8B9_x0213[] = {
- 0xE02B, 0xE02C, 0x6C7A, 0, 0x447D, 0, 0, 0x6D21,
- 0x6D25, 0x6D22, 0x6C7E, 0xF94C, 0x6D23, 0xE02E, 0xE02F, 0xE030,
- 0x6D24, 0, 0, 0, 0xF94D, 0x6D2B, 0, 0,
- 0, 0x6D26, 0, 0xE032, 0xE033, 0xE034, 0xE035, 0x4058,
- 0x6D28, 0xE036, 0xF94E, 0x6D2A, 0x6D27, 0, 0, 0,
- 0, 0xE038, 0, 0, 0xF94F, 0xF950, 0, 0xF951,
- 0x7C47, 0xE03D, 0x6D2D, 0, 0x3D33, 0, 0x6D2C, 0,
- 0, 0xE03E, 0xE03F, 0x7C48, 0x6D2E, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E8BA[] = {
- 0, 0x6D2F, 0xE041, 0xE042, 0x6D32, 0x6D31, 0, 0x6D30,
- 0, 0xE043, 0x6D34, 0x6D33, 0, 0x4C76, 0, 0,
- 0xE044, 0x6D36, 0xE045, 0x6D35, 0x6D37, 0xE046, 0, 0,
- 0, 0x6D38, 0xE047, 0xE048, 0, 0xE049, 0xE04A, 0,
- 0, 0x6D3A, 0xE04B, 0, 0, 0, 0, 0xE04C,
- 0, 0xE04D, 0x6D39, 0x3F48, 0x6D3B, 0xE04E, 0xE04F, 0x366D,
- 0x6D3C, 0x6D3E, 0, 0xE050, 0, 0xE051, 0, 0,
- 0, 0, 0xE052, 0xE053, 0, 0, 0x6D3F, 0,
-};
-static const unsigned short utf8_to_euc_E8BA_x0213[] = {
- 0, 0x6D2F, 0xE041, 0xE042, 0x6D32, 0x6D31, 0, 0x6D30,
- 0, 0xE043, 0x6D34, 0x6D33, 0, 0x4C76, 0, 0,
- 0xE044, 0x6D36, 0xE045, 0x6D35, 0x6D37, 0xE046, 0, 0,
- 0xF952, 0x6D38, 0xE047, 0xE048, 0, 0xE049, 0xF953, 0,
- 0, 0x6D3A, 0xE04B, 0, 0, 0, 0, 0xE04C,
- 0, 0xE04D, 0x6D39, 0x3F48, 0x6D3B, 0xE04E, 0xF954, 0x366D,
- 0x6D3C, 0x6D3E, 0, 0xF955, 0, 0xF956, 0xF957, 0,
- 0, 0, 0xE052, 0xF958, 0, 0, 0x6D3F, 0,
-};
-static const unsigned short utf8_to_euc_E8BB[] = {
- 0xE054, 0xE055, 0, 0xE056, 0xE057, 0x6D40, 0x6D3D, 0xE058,
- 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0xE059,
- 0, 0xE05A, 0x382E, 0, 0xE05B, 0, 0, 0,
- 0, 0, 0, 0x6D43, 0xE05C, 0, 0, 0x4670,
- 0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
- 0xE05D, 0, 0, 0x6D47, 0, 0xE064, 0xE05E, 0,
- 0xE05F, 0xE060, 0, 0, 0, 0, 0, 0xE061,
- 0x3C34, 0xE062, 0xE063, 0x6D46, 0x6D45, 0x375A, 0x6D48, 0,
-};
-static const unsigned short utf8_to_euc_E8BB_x0213[] = {
- 0x7C4A, 0xE055, 0, 0xE056, 0xE057, 0x6D40, 0x6D3D, 0xE058,
- 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0,
- 0, 0xF95A, 0x382E, 0, 0xF95B, 0, 0, 0,
- 0, 0, 0, 0x6D43, 0xE05C, 0, 0, 0x4670,
- 0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
- 0xE05D, 0, 0, 0x6D47, 0, 0xE064, 0xE05E, 0,
- 0xE05F, 0xE060, 0, 0, 0, 0, 0, 0xE061,
- 0x3C34, 0xF95D, 0x7C4C, 0x6D46, 0x6D45, 0x375A, 0x6D48, 0,
-};
-static const unsigned short utf8_to_euc_E8BC[] = {
- 0xE065, 0, 0xE066, 0x3353, 0, 0x6D4A, 0, 0xE067,
- 0xE068, 0x3A5C, 0x6D49, 0, 0x6D52, 0, 0, 0xE069,
- 0xE06A, 0, 0x6D4C, 0x6D4E, 0x4A65, 0x6D4B, 0xE06B, 0xE06C,
- 0xE06D, 0x6D4D, 0, 0x6D51, 0x6D4F, 0x3531, 0xE06E, 0x6D50,
- 0xE06F, 0xE070, 0, 0xE071, 0, 0xE072, 0x6D53, 0xE073,
- 0xE074, 0x475A, 0x4E58, 0, 0xE075, 0xE076, 0xE077, 0x3D34,
- 0, 0, 0, 0x6D54, 0xE078, 0xE079, 0xE07A, 0xE07B,
- 0x4D22, 0x6D56, 0xE07C, 0x6D55, 0, 0, 0x6D59, 0x4D41,
-};
-static const unsigned short utf8_to_euc_E8BC_x0213[] = {
- 0xF95F, 0, 0xE066, 0x3353, 0, 0x6D4A, 0, 0xE067,
- 0xF960, 0x3A5C, 0x6D49, 0, 0x6D52, 0, 0, 0xE069,
- 0xE06A, 0, 0x6D4C, 0x6D4E, 0x4A65, 0x6D4B, 0xE06B, 0xF961,
- 0xE06D, 0x6D4D, 0, 0x6D51, 0x6D4F, 0x3531, 0x7C4D, 0x6D50,
- 0xE06F, 0xE070, 0, 0xE071, 0, 0xE072, 0x6D53, 0xE073,
- 0xE074, 0x475A, 0x4E58, 0xF962, 0xE075, 0x7C4E, 0xE077, 0x3D34,
- 0, 0, 0, 0x6D54, 0xE078, 0xE079, 0x7C4F, 0xE07B,
- 0x4D22, 0x6D56, 0xE07C, 0x6D55, 0, 0, 0x6D59, 0x4D41,
-};
-static const unsigned short utf8_to_euc_E8BD[] = {
- 0xE07D, 0xE07E, 0x6D58, 0xE121, 0x336D, 0x6D57, 0x6D5C, 0xE122,
- 0, 0x6D5B, 0, 0, 0x6D5A, 0x4532, 0x6D5D, 0xE123,
- 0, 0xE124, 0xE125, 0xE126, 0xE127, 0xE128, 0, 0x6D5E,
- 0xE129, 0, 0, 0, 0x6D5F, 0xE12A, 0xE12B, 0x396C,
- 0, 0x3725, 0x6D60, 0x6D61, 0x6D62, 0xE12C, 0, 0,
- 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 short utf8_to_euc_E8BD_x0213[] = {
- 0xF963, 0xE07E, 0x6D58, 0xE121, 0x336D, 0x6D57, 0x6D5C, 0xE122,
- 0, 0x6D5B, 0xF964, 0, 0x6D5A, 0x4532, 0x6D5D, 0xE123,
- 0, 0xE124, 0xE125, 0xE126, 0x7C50, 0xE128, 0, 0x6D5E,
- 0xF965, 0, 0, 0, 0x6D5F, 0xE12A, 0xE12B, 0x396C,
- 0, 0x3725, 0x6D60, 0x6D61, 0x6D62, 0xE12C, 0, 0,
- 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 short utf8_to_euc_E8BE[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x3F49, 0x6D63, 0xE12D, 0x3C2D, 0x6D64,
- 0xE12E, 0xE12F, 0, 0x6D65, 0xE130, 0xE131, 0xE132, 0x5221,
- 0x517E, 0, 0, 0, 0, 0x6D66, 0x6570, 0x6D67,
- 0x4324, 0x3F2B, 0x4740, 0, 0, 0xE133, 0xE134, 0x6D68,
- 0xE135, 0, 0x4A55, 0x4454, 0x397E, 0, 0xE136, 0x4329,
-};
-static const unsigned short utf8_to_euc_E8BE_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x3F49, 0x6D63, 0xE12D, 0x3C2D, 0x6D64,
- 0xE12E, 0xE12F, 0, 0x6D65, 0xF967, 0xE131, 0x7C52, 0x5221,
- 0x517E, 0, 0, 0, 0, 0x6D66, 0x6570, 0x6D67,
- 0x4324, 0x3F2B, 0x4740, 0, 0xF968, 0x7C53, 0xF96A, 0x6D68,
- 0xE135, 0, 0x4A55, 0x4454, 0x397E, 0, 0xE136, 0x4329,
-};
-static const unsigned short utf8_to_euc_E8BF[] = {
- 0xE137, 0xE138, 0x312A, 0, 0x4B78, 0x3F57, 0xE139, 0,
- 0, 0, 0xE13A, 0xE13B, 0, 0xE13C, 0x375E, 0,
- 0xE13D, 0x3661, 0xE13E, 0xE13F, 0x4A56, 0xE140, 0, 0,
- 0, 0, 0x6D69, 0, 0, 0, 0, 0,
- 0xE141, 0, 0x6D6B, 0xE142, 0xE143, 0x6D6A, 0x3260, 0,
- 0xE144, 0x4676, 0x6D6C, 0x4777, 0, 0x4533, 0xE145, 0x6D6D,
- 0x3D52, 0xE146, 0, 0, 0x6D6F, 0xE147, 0xE148, 0x4C42,
- 0x6D7E, 0x6D71, 0x6D72, 0xE149, 0, 0x4449, 0xE14A, 0,
-};
-static const unsigned short utf8_to_euc_E8BF_x0213[] = {
- 0xE137, 0xF96C, 0x312A, 0, 0x4B78, 0x3F57, 0xF96D, 0,
- 0, 0, 0xF96F, 0xE13B, 0, 0xF970, 0x375E, 0,
- 0xE13D, 0x3661, 0xE13E, 0xF971, 0x4A56, 0xF972, 0, 0,
- 0, 0, 0x6D69, 0, 0, 0, 0, 0,
- 0xF973, 0, 0x6D6B, 0xE142, 0x7C54, 0x6D6A, 0x3260, 0,
- 0x7C55, 0x4676, 0x6D6C, 0x4777, 0, 0x4533, 0x7C56, 0x6D6D,
- 0x3D52, 0xF974, 0, 0, 0x6D6F, 0xF975, 0xE148, 0x4C42,
- 0x6D7E, 0x6D71, 0x6D72, 0xF976, 0, 0x4449, 0xE14A, 0,
-};
-static const unsigned short utf8_to_euc_E980[] = {
- 0x4260, 0x4177, 0xE14B, 0x4628, 0xE14C, 0x6D70, 0x3555, 0,
- 0xE14D, 0, 0, 0x6D79, 0xE14E, 0x6D76, 0x6E25, 0x4629,
- 0x4360, 0x6D73, 0, 0x447E, 0x4553, 0x6D74, 0x6D78, 0x3F60,
- 0xE14F, 0x4767, 0x444C, 0xE150, 0, 0x4042, 0x6D77, 0x422E,
- 0x4224, 0x6D75, 0x3029, 0x4F22, 0, 0, 0, 0x6D7A,
- 0xE151, 0xE152, 0xE154, 0, 0xE155, 0xE156, 0x4261, 0xE153,
- 0, 0x3D35, 0x3F4A, 0xE157, 0xE158, 0x6D7C, 0x6D7B, 0xE159,
- 0x306F, 0x6D7D, 0, 0, 0x492F, 0, 0x6E27, 0xE15A,
-};
-static const unsigned short utf8_to_euc_E980_x0213[] = {
- 0x4260, 0x4177, 0xF977, 0x4628, 0xE14C, 0x6D70, 0x3555, 0,
- 0x7C57, 0, 0, 0x6D79, 0xF978, 0x6D76, 0x6E25, 0x4629,
- 0x4360, 0x6D73, 0, 0x447E, 0x4553, 0x6D74, 0x6D78, 0x3F60,
- 0xE14F, 0x4767, 0x444C, 0xE150, 0, 0x4042, 0x6D77, 0x422E,
- 0x4224, 0x6D75, 0x3029, 0x4F22, 0, 0, 0, 0x6D7A,
- 0xE151, 0xE152, 0xE154, 0, 0xE155, 0x7C58, 0x4261, 0xE153,
- 0, 0x3D35, 0x3F4A, 0xE157, 0xE158, 0x6D7C, 0x6D7B, 0xF979,
- 0x306F, 0x6D7D, 0, 0, 0x492F, 0, 0x6E27, 0xE15A,
-};
-static const unsigned short utf8_to_euc_E981[] = {
- 0, 0x465B, 0x3F6B, 0xE15B, 0xE15C, 0x4359, 0, 0x3678,
- 0, 0x6E26, 0x4D37, 0x313F, 0xE15D, 0x4A57, 0x3261, 0x6E21,
- 0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
- 0x6E29, 0x7423, 0, 0xE15E, 0x423D, 0xE15F, 0x6E2A, 0,
- 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0xE162,
- 0x6E2B, 0x452C, 0, 0, 0xE163, 0x4178, 0x3C57, 0x6E2C,
- 0xE164, 0, 0x6E2F, 0, 0xE165, 0x3D65, 0x6E2D, 0x412B,
- 0x412A, 0xE166, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
-};
-static const unsigned short utf8_to_euc_E981_x0213[] = {
- 0, 0x465B, 0x3F6B, 0xF97B, 0xF97C, 0x4359, 0, 0x3678,
- 0, 0x6E26, 0x4D37, 0x313F, 0xE15D, 0x4A57, 0x3261, 0x6E21,
- 0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
- 0x6E29, 0x7423, 0, 0xE15E, 0x423D, 0xF97D, 0x6E2A, 0,
- 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0,
- 0x6E2B, 0x452C, 0, 0, 0xE163, 0x4178, 0x3C57, 0x6E2C,
- 0xE164, 0, 0x6E2F, 0, 0xE165, 0x3D65, 0x6E2D, 0x412B,
- 0x412A, 0xE166, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
-};
-static const unsigned short utf8_to_euc_E982[] = {
- 0x6E33, 0x6E32, 0x6E30, 0x6364, 0x3454, 0xE167, 0, 0x6D6E,
- 0xE168, 0x6E35, 0x6E34, 0xE169, 0xE16A, 0, 0xE16B, 0x6E36,
- 0xE16C, 0x4D38, 0, 0, 0, 0xE16D, 0, 0xE16E,
- 0xE16F, 0xE170, 0, 0xE171, 0, 0, 0, 0,
- 0xE172, 0xE173, 0xE174, 0x4661, 0, 0xE175, 0x4B2E, 0,
- 0x6E37, 0, 0x3C59, 0, 0, 0, 0, 0x6E38,
- 0xE176, 0x6E39, 0xE177, 0xE178, 0xE179, 0x6E3A, 0xE17A, 0,
- 0x4521, 0, 0, 0, 0, 0xE17B, 0xE17D, 0,
-};
-static const unsigned short utf8_to_euc_E982_x0213[] = {
- 0x6E33, 0x6E32, 0x6E30, 0x6364, 0x3454, 0xFA22, 0, 0x6D6E,
- 0x7C5A, 0x6E35, 0x6E34, 0xE169, 0xFA23, 0, 0xE16B, 0x6E36,
- 0xFA24, 0x4D38, 0, 0, 0, 0x7C5B, 0, 0x7C5C,
- 0xE16F, 0x7C5D, 0, 0x7C5E, 0, 0, 0, 0,
- 0xE172, 0xFA26, 0x7C5F, 0x4661, 0, 0xE175, 0x4B2E, 0,
- 0x6E37, 0, 0x3C59, 0, 0, 0, 0, 0x6E38,
- 0xFA28, 0x6E39, 0xE177, 0x7C60, 0xE179, 0x6E3A, 0xFA29, 0,
- 0x4521, 0, 0, 0, 0, 0xE17B, 0x7C61, 0,
-};
-static const unsigned short utf8_to_euc_E983[] = {
- 0, 0x306A, 0, 0xE17E, 0xE221, 0xE222, 0, 0xE223,
- 0xE224, 0, 0x3959, 0, 0xE17C, 0, 0x4F3A, 0,
- 0, 0, 0xE22D, 0, 0, 0xE225, 0, 0xE226,
- 0xE227, 0xE228, 0, 0x6E3E, 0xE229, 0xE22A, 0xF46C, 0xE22B,
- 0, 0x3734, 0x6E3B, 0, 0x6E3C, 0xE22C, 0, 0,
- 0x4974, 0, 0, 0xE22F, 0, 0x3354, 0, 0xE230,
- 0xE231, 0, 0, 0, 0xE232, 0x4D39, 0xE22E, 0x363F,
- 0, 0, 0, 0, 0, 0x4554, 0xE233, 0xE234,
-};
-static const unsigned short utf8_to_euc_E983_x0213[] = {
- 0, 0x306A, 0, 0xFA2A, 0x7C62, 0x7C63, 0, 0x7C64,
- 0xFA2B, 0, 0x3959, 0, 0xE17C, 0, 0x4F3A, 0,
- 0, 0, 0xE22D, 0, 0, 0xE225, 0, 0x7C65,
- 0xE227, 0xE228, 0, 0x6E3E, 0xFA2D, 0x7C66, 0x7C67, 0xFA2E,
- 0, 0x3734, 0x6E3B, 0, 0x6E3C, 0xE22C, 0, 0,
- 0x4974, 0, 0, 0xFA33, 0, 0x3354, 0, 0x7C68,
- 0xE231, 0, 0xFA31, 0, 0x7C69, 0x4D39, 0xFA30, 0x363F,
- 0, 0, 0, 0, 0, 0x4554, 0xFA34, 0xFA35,
-};
-static const unsigned short utf8_to_euc_E984[] = {
- 0xE235, 0, 0x6E3F, 0, 0xE236, 0xE237, 0xE238, 0,
- 0xE239, 0, 0, 0, 0, 0xE23A, 0, 0,
- 0xE23B, 0, 0x6E40, 0, 0xE23C, 0xF46E, 0xE23D, 0xE23E,
- 0xE23F, 0x6E41, 0xE240, 0, 0xE241, 0, 0xE242, 0,
- 0xE243, 0, 0xE245, 0xE246, 0, 0xE244, 0, 0xE247,
- 0, 0xE248, 0, 0, 0, 0x4522, 0xE249, 0xE24A,
- 0x6E43, 0xE24B, 0x6E42, 0, 0xE24C, 0, 0xE24D, 0xE24E,
- 0, 0xE24F, 0xE250, 0, 0xE251, 0xE252, 0, 0,
-};
-static const unsigned short utf8_to_euc_E984_x0213[] = {
- 0xFA32, 0, 0x6E3F, 0, 0xFA36, 0xE237, 0xFA37, 0,
- 0xE239, 0, 0, 0, 0, 0xE23A, 0, 0,
- 0xE23B, 0, 0x6E40, 0, 0x7C6B, 0x7C6C, 0x7C6D, 0xE23E,
- 0xFA38, 0x6E41, 0xE240, 0, 0xFA39, 0, 0xFA3A, 0,
- 0xE243, 0, 0x7C6E, 0x7C6F, 0, 0xE244, 0, 0x7C70,
- 0, 0xE248, 0, 0, 0, 0x4522, 0xE249, 0x7C71,
- 0x6E43, 0x7C72, 0x6E42, 0, 0x7C73, 0, 0xE24D, 0xFA3B,
- 0, 0xFA3C, 0xFA3D, 0, 0xE251, 0x7C74, 0, 0,
-};
-static const unsigned short utf8_to_euc_E985[] = {
- 0, 0, 0, 0xE253, 0, 0, 0, 0xE254,
- 0xE255, 0x4653, 0x6E44, 0x3D36, 0x3C60, 0x475B, 0x4371, 0xE256,
- 0, 0, 0x3C72, 0xE257, 0x3F6C, 0, 0x6E45, 0xE258,
- 0x6E46, 0xE259, 0xE25A, 0xE25B, 0, 0, 0, 0,
- 0, 0xE25C, 0x3F5D, 0x6E47, 0xE25D, 0x6E48, 0, 0xE25E,
- 0, 0x6E49, 0x4D6F, 0, 0x3D37, 0xE25F, 0, 0,
- 0, 0, 0x6E4B, 0x6E4A, 0xE260, 0x395A, 0, 0x3973,
- 0x3B40, 0xE261, 0xE262, 0xE263, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E985_x0213[] = {
- 0, 0, 0, 0xE253, 0, 0, 0xFA3E, 0xFA3F,
- 0x7C75, 0x4653, 0x6E44, 0x3D36, 0x3C60, 0x475B, 0x4371, 0xE256,
- 0, 0, 0x3C72, 0xE257, 0x3F6C, 0, 0x6E45, 0xFA40,
- 0x6E46, 0xFA41, 0xE25A, 0x7C76, 0, 0, 0, 0,
- 0, 0xFA42, 0x3F5D, 0x6E47, 0xFA43, 0x6E48, 0, 0xE25E,
- 0, 0x6E49, 0x4D6F, 0, 0x3D37, 0xE25F, 0, 0,
- 0, 0, 0x6E4B, 0x6E4A, 0xFA44, 0x395A, 0, 0x3973,
- 0x3B40, 0xFA45, 0xE262, 0xE263, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E986[] = {
- 0, 0xE264, 0x6E4E, 0xE265, 0, 0xE266, 0xE267, 0x3D66,
- 0, 0x6E4D, 0xE268, 0x6E4C, 0, 0x4269, 0xE269, 0,
- 0x386F, 0xE26A, 0x4043, 0xE26B, 0xE26C, 0xE26D, 0, 0x4830,
- 0xE26E, 0, 0, 0, 0x3D39, 0, 0xE26F, 0,
- 0, 0xE270, 0x6E4F, 0, 0x3E5F, 0, 0xE271, 0,
- 0xE272, 0, 0x6E52, 0x6E50, 0xE273, 0xE274, 0xE275, 0x6E51,
- 0xE276, 0xE277, 0xE278, 0xE279, 0x6E54, 0x6E53, 0xE27A, 0,
- 0x3E7A, 0, 0x6E55, 0xE27B, 0xE27C, 0xE27D, 0, 0xE27E,
-};
-static const unsigned short utf8_to_euc_E986_x0213[] = {
- 0, 0xE264, 0x6E4E, 0x7C77, 0, 0xFA46, 0xE267, 0x3D66,
- 0, 0x6E4D, 0xE268, 0x6E4C, 0, 0x4269, 0xFA47, 0,
- 0x386F, 0xE26A, 0x4043, 0xE26B, 0xE26C, 0xE26D, 0, 0x4830,
- 0xE26E, 0, 0, 0, 0x3D39, 0, 0x7C78, 0,
- 0, 0xE270, 0x6E4F, 0, 0x3E5F, 0, 0xE271, 0,
- 0xFA48, 0, 0x6E52, 0x6E50, 0x7C79, 0xE274, 0xFA49, 0x6E51,
- 0xE276, 0x7C7A, 0xE278, 0xFA4A, 0x6E54, 0x6E53, 0xFA4B, 0,
- 0x3E7A, 0, 0x6E55, 0xE27B, 0x7C7B, 0xE27D, 0, 0xE27E,
-};
-static const unsigned short utf8_to_euc_E987[] = {
- 0x6E56, 0x6E57, 0xE321, 0xE322, 0, 0xE323, 0x4850, 0x3A53,
- 0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
- 0x6E5A, 0x3662, 0, 0xE324, 0xE325, 0, 0x6E5B, 0xE326,
- 0x4523, 0xE327, 0xE328, 0x6E5E, 0x3378, 0x3F4B, 0xE329, 0x6E5C,
- 0, 0x6E5D, 0, 0x4460, 0xE32A, 0xE32B, 0x4B55, 0x367C,
- 0, 0xE32C, 0xE32D, 0, 0xE32E, 0xE32F, 0xE330, 0xE331,
- 0xE332, 0xE333, 0, 0, 0, 0x6E60, 0x6E61, 0xE334,
- 0, 0xE335, 0, 0xE336, 0x6E5F, 0xE337, 0, 0x6E63,
-};
-static const unsigned short utf8_to_euc_E987_x0213[] = {
- 0x6E56, 0x6E57, 0xE321, 0xFA4C, 0xFA4D, 0xE323, 0x4850, 0x3A53,
- 0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
- 0x6E5A, 0x3662, 0, 0xE324, 0xE325, 0, 0x6E5B, 0x7C7C,
- 0x4523, 0xE327, 0xFA4E, 0x6E5E, 0x3378, 0x3F4B, 0, 0x6E5C,
- 0, 0x6E5D, 0, 0x4460, 0x7C7E, 0x7D21, 0x4B55, 0x367C,
- 0, 0xE32C, 0xE32D, 0, 0xFA51, 0x7D22, 0xFA52, 0xE331,
- 0xE332, 0x7D23, 0, 0, 0, 0x6E60, 0x6E61, 0xE334,
- 0, 0xE335, 0, 0x7C7D, 0x6E5F, 0xE337, 0, 0x6E63,
-};
-static const unsigned short utf8_to_euc_E988[] = {
- 0xE338, 0xE339, 0, 0, 0xE33A, 0xE33B, 0xE33C, 0xE33D,
- 0, 0xE33E, 0xE33F, 0, 0xE340, 0x465F, 0x3343, 0,
- 0xE341, 0x6E67, 0xE342, 0xE343, 0x6E64, 0x6E66, 0xE344, 0,
- 0xE345, 0, 0, 0, 0xE346, 0xE347, 0x6E62, 0,
- 0, 0, 0, 0xE348, 0xE349, 0xE34A, 0xE34B, 0,
- 0xE34C, 0x6F4F, 0, 0, 0x6E65, 0, 0xE34D, 0xE34E,
- 0xE34F, 0, 0, 0xE350, 0x4E6B, 0xE351, 0xE352, 0x385A,
- 0xE353, 0xE354, 0xE355, 0, 0xE356, 0, 0xE357, 0x6E6F,
-};
-static const unsigned short utf8_to_euc_E988_x0213[] = {
- 0xE338, 0xFA53, 0, 0, 0xE33A, 0xE33B, 0, 0x7D24,
- 0, 0xE33E, 0xFA54, 0, 0xE340, 0x465F, 0x3343, 0,
- 0x7D25, 0x6E67, 0xE342, 0xE343, 0x6E64, 0x6E66, 0xFA55, 0xFA56,
- 0xE345, 0, 0, 0, 0xE346, 0xE347, 0x6E62, 0,
- 0, 0, 0, 0xE348, 0xE349, 0xE34A, 0xE34B, 0,
- 0xE34C, 0x6F4F, 0, 0, 0x6E65, 0, 0xE34D, 0xE34E,
- 0xE34F, 0, 0, 0xFA58, 0x4E6B, 0xE351, 0xE352, 0x385A,
- 0x7D26, 0x7D27, 0x7D28, 0, 0x7D29, 0, 0xE357, 0x6E6F,
-};
-static const unsigned short utf8_to_euc_E989[] = {
- 0xE358, 0, 0xE359, 0xE35A, 0x4534, 0x6E6A, 0xE35B, 0xE35C,
- 0x6E6D, 0x6E6B, 0xE35D, 0x6E70, 0, 0xE35E, 0xE35F, 0xE360,
- 0x6E71, 0xE361, 0, 0, 0, 0, 0, 0x6E69,
- 0xE362, 0xE363, 0x6E76, 0x3174, 0xE364, 0xE365, 0x6E68, 0,
- 0xE366, 0xE367, 0x482D, 0, 0x6E6C, 0xE368, 0x3E60, 0xE369,
- 0xE36A, 0xE36B, 0, 0, 0, 0, 0xE36C, 0xE36D,
- 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0xE371,
- 0xE372, 0xE373, 0, 0xE374, 0xE375, 0xE376, 0x4B48, 0xE377,
-};
-static const unsigned short utf8_to_euc_E989_x0213[] = {
- 0x7D2A, 0, 0xFA59, 0x7D2B, 0x4534, 0x6E6A, 0xE35B, 0xFA5A,
- 0x6E6D, 0x6E6B, 0xFA5B, 0x6E70, 0, 0xE35E, 0xFA5C, 0x7D2C,
- 0x6E71, 0xFA5D, 0, 0, 0, 0, 0xFA5E, 0x6E69,
- 0xE362, 0xFA5F, 0x6E76, 0x3174, 0xE364, 0xE365, 0x6E68, 0,
- 0xFA60, 0xFA61, 0x482D, 0, 0x6E6C, 0xFA62, 0x3E60, 0xFA63,
- 0xFA64, 0xE36B, 0, 0, 0, 0, 0xE36C, 0xE36D,
- 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0,
- 0x7D2D, 0xE373, 0, 0xE374, 0xFA67, 0xFA68, 0x4B48, 0xFA69,
-};
-static const unsigned short utf8_to_euc_E98A[] = {
- 0x3664, 0, 0, 0x3D46, 0, 0x463C, 0, 0,
- 0xE378, 0xE379, 0xE37A, 0, 0, 0xE37B, 0xE37C, 0,
- 0, 0x412D, 0xE37D, 0x6E74, 0, 0x6E6E, 0x6E73, 0xE37E,
- 0x4C43, 0xE421, 0x4438, 0x6E75, 0x6E72, 0, 0, 0xE422,
- 0xE423, 0, 0, 0, 0xE424, 0xE425, 0, 0xE426,
- 0xE427, 0, 0, 0xE428, 0, 0x412C, 0, 0xE429,
- 0, 0, 0xE42A, 0, 0, 0, 0xE42B, 0x6E79,
- 0xE42C, 0x6E78, 0xE42D, 0xE42E, 0xE42F, 0xE430, 0, 0xE431,
-};
-static const unsigned short utf8_to_euc_E98A_x0213[] = {
- 0x3664, 0, 0, 0x3D46, 0, 0x463C, 0, 0,
- 0x7D2E, 0xFA6A, 0xE37A, 0, 0, 0xFA6B, 0xE37C, 0,
- 0, 0x412D, 0xE37D, 0x6E74, 0, 0x6E6E, 0x6E73, 0xFA6C,
- 0x4C43, 0xFA6D, 0x4438, 0x6E75, 0x6E72, 0, 0, 0xFA6E,
- 0xE423, 0, 0, 0, 0xE424, 0xE425, 0, 0xFA6F,
- 0xE427, 0, 0, 0xFA70, 0, 0x412C, 0, 0xE429,
- 0, 0, 0xFA73, 0, 0, 0, 0xE42B, 0x6E79,
- 0xE42C, 0x6E78, 0xE42D, 0xE42E, 0xE42F, 0xE430, 0, 0xFA74,
-};
-static const unsigned short utf8_to_euc_E98B[] = {
- 0xE432, 0xE433, 0xE434, 0xE435, 0, 0xE436, 0xE437, 0xE438,
- 0xE439, 0, 0, 0xE43A, 0xE43B, 0xE43C, 0xE43D, 0x6E77,
- 0xE43E, 0, 0x4B2F, 0xE43F, 0, 0xE440, 0, 0xE441,
- 0xE442, 0xE443, 0, 0, 0xE444, 0xE445, 0, 0xE446,
- 0xE447, 0xE448, 0, 0xE449, 0x3D7B, 0xE44A, 0, 0xE44B,
- 0xE44C, 0x6E7A, 0x4A5F, 0, 0xE44D, 0x3154, 0xE44E, 0,
- 0xE44F, 0, 0x4946, 0x4372, 0, 0, 0, 0,
- 0x3578, 0xE450, 0x6E7C, 0xE451, 0x395D, 0, 0, 0xE452,
-};
-static const unsigned short utf8_to_euc_E98B_x0213[] = {
- 0xFA75, 0xE433, 0x7D2F, 0xE435, 0, 0xE436, 0xFA76, 0xE438,
- 0xE439, 0, 0, 0x7D30, 0x7D31, 0xE43C, 0xFA77, 0x6E77,
- 0xFA78, 0, 0x4B2F, 0x7D32, 0, 0, 0, 0xFA79,
- 0xE442, 0xFA7A, 0, 0, 0xE444, 0xE445, 0, 0xE446,
- 0x7D33, 0xE448, 0, 0xE449, 0x3D7B, 0xFA7B, 0, 0xFA7C,
- 0xE44C, 0x6E7A, 0x4A5F, 0, 0xE44D, 0x3154, 0xE44E, 0,
- 0xE44F, 0, 0x4946, 0x4372, 0, 0, 0, 0xFB22,
- 0x3578, 0xFB23, 0x6E7C, 0xFB24, 0x395D, 0, 0, 0x7D34,
-};
-static const unsigned short utf8_to_euc_E98C[] = {
- 0xE453, 0, 0xE454, 0, 0, 0, 0x3B2C, 0,
- 0xE455, 0, 0, 0, 0, 0xE456, 0, 0x6E7B,
- 0x3F6D, 0xE457, 0, 0, 0xE458, 0xE459, 0, 0,
- 0x3F6E, 0x6F21, 0x6F23, 0, 0xE45A, 0xE45B, 0xE45C, 0xE45D,
- 0x3E7B, 0xE45E, 0x6F22, 0x6F24, 0xE45F, 0xE460, 0x3653, 0xE461,
- 0x4945, 0xE462, 0xE463, 0x3C62, 0x4F23, 0, 0x6E7E, 0x3A78,
- 0, 0, 0x4F3F, 0xE464, 0xE465, 0x6F26, 0xE466, 0xE467,
- 0, 0, 0x6F25, 0x6F27, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E98C_x0213[] = {
- 0xE453, 0, 0xFB25, 0, 0x7D35, 0, 0x3B2C, 0,
- 0xE455, 0, 0, 0, 0, 0xFB26, 0, 0x6E7B,
- 0x3F6D, 0xFA7D, 0, 0, 0xE458, 0xFB27, 0, 0,
- 0x3F6E, 0x6F21, 0x6F23, 0, 0xE45A, 0xFB28, 0xFB29, 0x7D36,
- 0x3E7B, 0x7D37, 0x6F22, 0x6F24, 0xE45F, 0x7D38, 0x3653, 0xFB2A,
- 0x4945, 0xFB2B, 0xE463, 0x3C62, 0x4F23, 0, 0x6E7E, 0x3A78,
- 0, 0, 0x4F3F, 0xE464, 0xE465, 0x6F26, 0xE466, 0xE467,
- 0, 0, 0x6F25, 0x6F27, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E98D[] = {
- 0, 0, 0, 0, 0x6E7D, 0, 0, 0xE468,
- 0xE469, 0xE46A, 0, 0x4669, 0, 0x4555, 0, 0,
- 0xE46B, 0xE46C, 0xE46D, 0, 0x4457, 0xE46E, 0x6F2C, 0xE46F,
- 0xE470, 0, 0xE471, 0x4343, 0x6F28, 0, 0xE472, 0,
- 0x6F29, 0, 0, 0, 0xE473, 0xE474, 0, 0xE475,
- 0, 0xE476, 0xE477, 0, 0x372D, 0xE478, 0x6F2B, 0xE479,
- 0xE47A, 0xE47B, 0, 0xE47C, 0xE47D, 0x3830, 0xE47E, 0,
- 0, 0, 0xE521, 0, 0x6F2A, 0xE522, 0x3E61, 0xE523,
-};
-static const unsigned short utf8_to_euc_E98D_x0213[] = {
- 0, 0, 0, 0, 0x6E7D, 0, 0, 0xFB2E,
- 0x7D39, 0x7D3A, 0x7D3B, 0x4669, 0, 0x4555, 0, 0,
- 0xE46B, 0xFB2F, 0xE46D, 0, 0x4457, 0xE46E, 0x6F2C, 0xFB30,
- 0xE470, 0, 0xFB31, 0x4343, 0x6F28, 0, 0xE472, 0,
- 0x6F29, 0, 0, 0, 0x7D3C, 0x7D3D, 0, 0xE475,
- 0, 0xE476, 0x7D3E, 0xFB32, 0x372D, 0xE478, 0x6F2B, 0xE479,
- 0x7D3F, 0xFB33, 0, 0xFB34, 0xE47D, 0x3830, 0xE47E, 0,
- 0, 0, 0xE521, 0, 0x6F2A, 0xE522, 0x3E61, 0xE523,
-};
-static const unsigned short utf8_to_euc_E98E[] = {
- 0xE524, 0xE525, 0xE526, 0, 0, 0, 0, 0,
- 0xE527, 0, 0xE528, 0xE529, 0x3379, 0xE52A, 0, 0xE52B,
- 0, 0, 0xE52C, 0, 0x6F30, 0xE52D, 0x3A3F, 0x4179,
- 0xE52E, 0, 0x444A, 0xE52F, 0, 0, 0xE530, 0,
- 0, 0xE531, 0, 0xE532, 0xE533, 0, 0xE534, 0x333B,
- 0xE535, 0xE53B, 0, 0xE536, 0x6F2E, 0x6F2F, 0x4443, 0,
- 0x6F2D, 0, 0, 0, 0xE537, 0xE538, 0xE539, 0,
- 0, 0x6F31, 0xE53A, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E98E_x0213[] = {
- 0xE524, 0xE525, 0xE526, 0, 0, 0, 0, 0,
- 0xFB38, 0, 0xE528, 0xFB39, 0x3379, 0xE52A, 0, 0xFB3A,
- 0, 0, 0xE52C, 0, 0x6F30, 0xE52D, 0x3A3F, 0x4179,
- 0xE52E, 0, 0x444A, 0x7D40, 0, 0, 0xFB3B, 0,
- 0, 0xFB35, 0, 0x7D41, 0, 0, 0xE534, 0x333B,
- 0xE535, 0xE53B, 0, 0xE536, 0x6F2E, 0x6F2F, 0x4443, 0,
- 0x6F2D, 0, 0, 0, 0xE537, 0xE538, 0xE539, 0,
- 0, 0x6F31, 0x7D42, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E98F[] = {
- 0, 0xE53C, 0, 0x6F37, 0xE53D, 0xE53E, 0xE53F, 0xE540,
- 0x6F3A, 0xE541, 0xE542, 0xE543, 0xE544, 0xE545, 0, 0,
- 0x6F39, 0x452D, 0, 0xE546, 0, 0, 0x6F32, 0x6F33,
- 0x6F36, 0xE547, 0, 0, 0xE548, 0x6F38, 0xE549, 0xE54A,
- 0, 0x3640, 0xE54B, 0, 0x6F3B, 0x6F35, 0xE54C, 0xE54D,
- 0x6F34, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xE54F,
- 0xE550, 0xE54E, 0xE551, 0xE552, 0, 0xE553, 0, 0,
-};
-static const unsigned short utf8_to_euc_E98F_x0213[] = {
- 0, 0xFB40, 0, 0x6F37, 0xE53D, 0xE53E, 0x7D43, 0xFB41,
- 0x6F3A, 0xE541, 0xE542, 0xE543, 0xE544, 0xE545, 0, 0,
- 0x6F39, 0x452D, 0, 0xE546, 0, 0, 0x6F32, 0x6F33,
- 0x6F36, 0xE547, 0, 0, 0xFB42, 0x6F38, 0x7D44, 0x7D45,
- 0, 0x3640, 0xFB43, 0, 0x6F3B, 0x6F35, 0xE54C, 0xFB44,
- 0x6F34, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB3F, 0, 0, 0, 0xFB3C, 0, 0xE54F,
- 0, 0xE54E, 0xE551, 0xFB49, 0, 0x7D47, 0, 0,
-};
-static const unsigned short utf8_to_euc_E990[] = {
- 0, 0xE554, 0xE555, 0x6F3F, 0xE556, 0, 0, 0x6F40,
- 0xE557, 0xE558, 0, 0, 0, 0xE559, 0xE55A, 0xE55B,
- 0x6F41, 0, 0, 0x6F3E, 0x6F3D, 0xE55C, 0xE55D, 0xE55E,
- 0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0xE55F,
- 0, 0x6F45, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x6F43, 0, 0, 0xE560, 0xE561,
- 0, 0xE562, 0xE563, 0xE564, 0xE565, 0x6F44, 0x6F42, 0,
- 0x4278, 0, 0x6F46, 0xE566, 0, 0xE568, 0, 0xE567,
-};
-static const unsigned short utf8_to_euc_E990_x0213[] = {
- 0, 0xE554, 0xE555, 0x6F3F, 0x7D46, 0, 0, 0x6F40,
- 0xE557, 0xFB45, 0, 0, 0, 0xE559, 0xE55A, 0xFB46,
- 0x6F41, 0, 0, 0x6F3E, 0x6F3D, 0xE55C, 0xFB47, 0xFB48,
- 0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0xE55F,
- 0, 0x6F45, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x6F43, 0, 0, 0xE560, 0xE561,
- 0, 0, 0xFB4A, 0x7D48, 0xFB4B, 0x6F44, 0x6F42, 0,
- 0x4278, 0, 0x6F46, 0xFB4C, 0, 0xE568, 0, 0xE567,
-};
-static const unsigned short utf8_to_euc_E991[] = {
- 0, 0x6F47, 0, 0xE569, 0x6F49, 0xE56A, 0, 0,
- 0xE56B, 0, 0xE56C, 0, 0xE56D, 0, 0, 0,
- 0, 0x3455, 0x6F48, 0x4C7A, 0, 0xE56E, 0, 0,
- 0, 0xE56F, 0x6F54, 0x6F4A, 0xE570, 0, 0x6F4D, 0xE571,
- 0x6F4B, 0xE572, 0x6F4C, 0xE573, 0, 0, 0, 0,
- 0xE574, 0, 0x6F4E, 0xE575, 0, 0xE576, 0xE577, 0xE578,
- 0x6F50, 0xE579, 0xE57A, 0, 0, 0x6F51, 0, 0x6F52,
- 0, 0, 0, 0, 0x6F55, 0x6F53, 0x6F56, 0x6F58,
-};
-static const unsigned short utf8_to_euc_E991_x0213[] = {
- 0, 0x6F47, 0, 0xE569, 0x6F49, 0xFB4D, 0, 0,
- 0, 0, 0x7D49, 0, 0xE56D, 0, 0, 0,
- 0, 0x3455, 0x6F48, 0x4C7A, 0, 0xE56E, 0, 0,
- 0, 0xE56F, 0x6F54, 0x6F4A, 0xE570, 0, 0x6F4D, 0xE571,
- 0x6F4B, 0xE572, 0x6F4C, 0x7D4A, 0, 0, 0, 0,
- 0xE574, 0, 0x6F4E, 0x7D4B, 0, 0xFB50, 0xE577, 0xFB51,
- 0x6F50, 0x7D4C, 0x7D4D, 0, 0, 0x6F51, 0, 0x6F52,
- 0, 0, 0, 0, 0x6F55, 0x6F53, 0x6F56, 0x6F58,
-};
-static const unsigned short utf8_to_euc_E992[] = {
- 0, 0x6F57, 0, 0xE57C, 0xE57B, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E995[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x4439,
- 0xE57D, 0xE57E, 0, 0, 0, 0, 0xE621, 0,
-};
-static const unsigned short utf8_to_euc_E995_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x4439,
- 0xFB52, 0xFB53, 0, 0, 0, 0, 0xE621, 0,
-};
-static const unsigned short utf8_to_euc_E996[] = {
- 0x4C67, 0, 0x6F59, 0x412E, 0xE622, 0, 0, 0x6F5A,
- 0xE623, 0x4A44, 0x6F5B, 0x332B, 0xE624, 0xE625, 0xE626, 0x313C,
- 0, 0x3457, 0xF471, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
- 0x6F5E, 0x6F5F, 0, 0, 0, 0xE627, 0xE628, 0xE629,
- 0x6F60, 0xE62A, 0x3458, 0x3355, 0x395E, 0x4836, 0xE62B, 0x6F62,
- 0x6F61, 0xE62C, 0, 0xE62D, 0xE62E, 0x6F63, 0, 0,
- 0, 0, 0x315C, 0, 0xE62F, 0, 0xE630, 0,
- 0, 0x6F66, 0xE631, 0x6F65, 0x6F64, 0xE632, 0x6F67, 0xE633,
-};
-static const unsigned short utf8_to_euc_E996_x0213[] = {
- 0x4C67, 0, 0x6F59, 0x412E, 0xE622, 0, 0xFB54, 0x6F5A,
- 0xE623, 0x4A44, 0x6F5B, 0x332B, 0xFB55, 0xFB56, 0x7D4E, 0x313C,
- 0, 0x3457, 0, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
- 0x6F5E, 0x6F5F, 0, 0, 0, 0xE627, 0xE628, 0x7D4F,
- 0x6F60, 0xE62A, 0x3458, 0x3355, 0x395E, 0x4836, 0x7D50, 0x6F62,
- 0x6F61, 0x7D51, 0, 0xFB58, 0x7D52, 0x6F63, 0, 0,
- 0, 0, 0x315C, 0, 0xFB59, 0, 0x7D53, 0,
- 0, 0x6F66, 0xE631, 0x6F65, 0x6F64, 0x7D54, 0x6F67, 0xE633,
-};
-static const unsigned short utf8_to_euc_E997[] = {
- 0, 0, 0, 0x6F6A, 0, 0, 0xE634, 0x3047,
- 0xE635, 0xE636, 0x6F68, 0xE637, 0x6F6C, 0x6F6B, 0, 0,
- 0xE638, 0xE639, 0xE63A, 0xE63B, 0x6F6E, 0x6F6D, 0x6F6F, 0,
- 0x462E, 0xE63C, 0xE63D, 0, 0x6F70, 0xE63E, 0xE63F, 0xE640,
- 0xE641, 0x6F71, 0x6F73, 0, 0xE642, 0x6F72, 0xE643, 0,
- 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 short utf8_to_euc_E997_x0213[] = {
- 0, 0, 0, 0x6F6A, 0, 0, 0xE634, 0x3047,
- 0xFB5B, 0xE636, 0x6F68, 0x7D55, 0x6F6C, 0x6F6B, 0, 0,
- 0x7D56, 0xE639, 0xE63A, 0x7D57, 0x6F6E, 0x6F6D, 0x6F6F, 0,
- 0x462E, 0xE63C, 0x7D59, 0, 0x6F70, 0xE63E, 0x7D5A, 0xE640,
- 0xE641, 0x6F71, 0x6F73, 0, 0xE642, 0x6F72, 0xE643, 0,
- 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 short utf8_to_euc_E998[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x496C, 0xE644, 0xE645, 0,
- 0, 0x6F74, 0xE646, 0, 0xE647, 0xE648, 0xE649, 0,
- 0x6F75, 0, 0x3A65, 0, 0xE64A, 0, 0x6F76, 0x6F77,
- 0, 0xE64B, 0x4B49, 0xE64C, 0, 0, 0, 0xE64D,
- 0xE64E, 0xE64F, 0xE650, 0x414B, 0xE651, 0xE652, 0, 0x3024,
-};
-static const unsigned short utf8_to_euc_E998_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x496C, 0xFA25, 0xE645, 0,
- 0, 0x6F74, 0xE646, 0, 0xE647, 0xE648, 0xE649, 0,
- 0x6F75, 0, 0x3A65, 0, 0xFB5E, 0, 0x6F76, 0x6F77,
- 0, 0xE64B, 0x4B49, 0xFB5F, 0xFB60, 0, 0, 0xE64D,
- 0xE64E, 0xE64F, 0xE650, 0x414B, 0xFB62, 0xE652, 0, 0x3024,
-};
-static const unsigned short utf8_to_euc_E999[] = {
- 0x424B, 0xE653, 0x6F78, 0, 0x496D, 0, 0, 0,
- 0, 0, 0, 0x6F7B, 0x6F79, 0x395F, 0, 0x6F7A,
- 0x3842, 0, 0xE654, 0, 0xE655, 0, 0xE656, 0xE657,
- 0xE658, 0, 0, 0x4A45, 0x6F7D, 0x7021, 0x6F7E, 0x7022,
- 0, 0xE659, 0x3121, 0x3F58, 0x3D7C, 0x3459, 0x7023, 0,
- 0, 0, 0x4766, 0, 0x7025, 0, 0xE65A, 0,
- 0x3122, 0, 0x7024, 0x4444, 0xE65B, 0x4E4D, 0x462B, 0x6F7C,
- 0x4E26, 0, 0x3831, 0xE65C, 0xE65D, 0x4D5B, 0xE65E, 0xE65F,
-};
-static const unsigned short utf8_to_euc_E999_x0213[] = {
- 0x424B, 0xFB63, 0x6F78, 0, 0x496D, 0, 0, 0,
- 0, 0, 0, 0x6F7B, 0x6F79, 0x395F, 0, 0x6F7A,
- 0x3842, 0, 0xE654, 0, 0xE655, 0, 0xE656, 0xE657,
- 0x7D5B, 0, 0, 0x4A45, 0x6F7D, 0x7021, 0x6F7E, 0x7022,
- 0, 0xFB64, 0x3121, 0x3F58, 0x3D7C, 0x3459, 0x7023, 0,
- 0, 0, 0x4766, 0, 0x7025, 0, 0xE65A, 0,
- 0x3122, 0, 0x7024, 0x4444, 0xE65B, 0x4E4D, 0x462B, 0x6F7C,
- 0x4E26, 0, 0x3831, 0xE65C, 0xE65D, 0x4D5B, 0xE65E, 0xE65F,
-};
-static const unsigned short utf8_to_euc_E99A[] = {
- 0, 0xE660, 0xE661, 0xE662, 0xE663, 0x3679, 0x4E34, 0,
- 0x3728, 0xE664, 0x4262, 0x6721, 0, 0x7026, 0x332C, 0x3F6F,
- 0, 0xE665, 0, 0, 0x3356, 0x7028, 0xE666, 0x7029,
- 0x7027, 0x3764, 0xE667, 0x3A5D, 0x3E63, 0xE668, 0, 0xE669,
- 0x3123, 0, 0, 0x4E59, 0xE66A, 0xE66B, 0xE66C, 0x702B,
- 0x6E2E, 0xE66D, 0x702A, 0, 0, 0, 0xE66E, 0xE66F,
- 0x702E, 0x702C, 0x702D, 0xE670, 0x702F, 0, 0x7030, 0x4E6C,
- 0x7031, 0x7032, 0xE671, 0x4049, 0x483B, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E99A_x0213[] = {
- 0, 0xE660, 0xFB66, 0xE662, 0x7D5C, 0x3679, 0x4E34, 0,
- 0x3728, 0xE664, 0x4262, 0x6721, 0, 0x7026, 0x332C, 0x3F6F,
- 0, 0xE665, 0, 0, 0x3356, 0x7028, 0xE666, 0x7029,
- 0x7027, 0x3764, 0xFB68, 0x3A5D, 0x3E63, 0x7D5E, 0, 0xE669,
- 0x3123, 0, 0, 0x4E59, 0x7D5F, 0x7D60, 0xE66C, 0x702B,
- 0x6E2E, 0xFB6B, 0x702A, 0, 0, 0, 0xE66E, 0xFB6C,
- 0x702E, 0x702C, 0x702D, 0xFB6D, 0x702F, 0, 0x7030, 0x4E6C,
- 0x7031, 0x7032, 0xFB6E, 0x4049, 0x483B, 0xFB6F, 0, 0,
-};
-static const unsigned short utf8_to_euc_E99B[] = {
- 0x3F7D, 0x3467, 0, 0, 0x4D3A, 0x326D, 0x3D38, 0x385B,
- 0, 0x7035, 0xE672, 0x7034, 0x3B73, 0x7036, 0x7033, 0,
- 0, 0x3B28, 0xE673, 0, 0, 0x703A, 0x6A2D, 0,
- 0xE675, 0x5256, 0xE676, 0x3F77, 0x7038, 0xE677, 0xE678, 0xE679,
- 0, 0, 0x4E25, 0x4671, 0, 0, 0, 0,
- 0x312B, 0xE67A, 0x4063, 0x3C36, 0, 0, 0, 0xE67B,
- 0x4A37, 0xE67C, 0x3140, 0, 0, 0, 0x4E6D, 0x4D6B,
- 0, 0x703B, 0xE67D, 0x4545, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E99B_x0213[] = {
- 0x3F7D, 0x3467, 0, 0, 0x4D3A, 0x326D, 0x3D38, 0x385B,
- 0, 0x7035, 0xE672, 0x7034, 0x3B73, 0x7036, 0x7033, 0,
- 0, 0x3B28, 0x7D61, 0, 0, 0x703A, 0x6A2D, 0,
- 0xFB72, 0x5256, 0xFB73, 0x3F77, 0x7038, 0xFB74, 0x7D62, 0xE679,
- 0, 0, 0x4E25, 0x4671, 0, 0, 0, 0,
- 0x312B, 0x7D64, 0x4063, 0x3C36, 0, 0, 0, 0x7D65,
- 0x4A37, 0xE67C, 0x3140, 0, 0, 0, 0x4E6D, 0x4D6B,
- 0, 0x703B, 0xE67D, 0x4545, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E99C[] = {
- 0x3C7B, 0, 0xE67E, 0xE721, 0x703C, 0xE722, 0x703D, 0x3F4C,
- 0x703E, 0xE723, 0x4E6E, 0, 0, 0x7039, 0x7040, 0x7042,
- 0, 0x7041, 0, 0x703F, 0, 0, 0x7043, 0,
- 0, 0x7044, 0xE724, 0xE725, 0x417A, 0xE726, 0x3262, 0,
- 0, 0xE727, 0xE728, 0xE729, 0x7045, 0, 0, 0x4C38,
- 0xE72A, 0, 0x7046, 0, 0, 0, 0, 0,
- 0x7047, 0xE72B, 0x4F2A, 0xE72C, 0, 0, 0, 0,
- 0x5B31, 0x7048, 0, 0xF474, 0, 0x7049, 0x704A, 0,
-};
-static const unsigned short utf8_to_euc_E99C_x0213[] = {
- 0x3C7B, 0, 0xE67E, 0xE721, 0x703C, 0xE722, 0x703D, 0x3F4C,
- 0x703E, 0xE723, 0x4E6E, 0, 0, 0x7039, 0x7040, 0x7042,
- 0, 0x7041, 0, 0x703F, 0xFB76, 0, 0x7043, 0,
- 0, 0x7044, 0xE724, 0xE725, 0x417A, 0xE726, 0x3262, 0,
- 0, 0xE727, 0xE728, 0xFB77, 0x7045, 0, 0, 0x4C38,
- 0xE72A, 0, 0x7046, 0, 0, 0, 0, 0,
- 0x7047, 0xE72B, 0x4F2A, 0x7D66, 0, 0, 0xFB79, 0,
- 0x5B31, 0x7048, 0, 0x7D67, 0, 0x7049, 0x704A, 0,
-};
-static const unsigned short utf8_to_euc_E99D[] = {
- 0, 0xE72D, 0x704E, 0xE72E, 0x704B, 0, 0x704C, 0,
- 0x704D, 0x704F, 0xE72F, 0, 0, 0xF475, 0xE730, 0xE731,
- 0, 0xF476, 0x4044, 0, 0, 0xE732, 0x4C77, 0xE733,
- 0xE734, 0x4045, 0xE735, 0xE736, 0x7050, 0, 0x4873, 0,
- 0x7051, 0x7353, 0x4C4C, 0xE737, 0x7052, 0, 0x7053, 0xE738,
- 0x7054, 0x3357, 0xE739, 0x7056, 0, 0x3F59, 0xE73A, 0,
- 0, 0x7057, 0, 0xE73B, 0x3724, 0, 0xE73C, 0xE73D,
- 0xE73E, 0x7058, 0x705C, 0xE73F, 0x705A, 0xE740, 0, 0xE741,
-};
-static const unsigned short utf8_to_euc_E99D_x0213[] = {
- 0, 0xFB7A, 0x704E, 0, 0x704B, 0, 0x704C, 0xFB7B,
- 0x704D, 0x704F, 0xE72F, 0, 0, 0x7D68, 0x7D69, 0x7D6A,
- 0, 0, 0x4044, 0, 0, 0xFB7C, 0x4C77, 0xFB7D,
- 0xE734, 0x4045, 0x7D6B, 0xFB7E, 0x7050, 0, 0x4873, 0,
- 0x7051, 0x7353, 0x4C4C, 0xE737, 0x7052, 0, 0x7053, 0xE738,
- 0x7054, 0x3357, 0xFC21, 0x7056, 0, 0x3F59, 0x7D6C, 0,
- 0, 0x7057, 0, 0x7D6D, 0x3724, 0, 0xE73C, 0xE73D,
- 0xE73E, 0x7058, 0x705C, 0xE73F, 0x705A, 0xE740, 0, 0xE741,
-};
-static const unsigned short utf8_to_euc_E99E[] = {
- 0xE742, 0x705B, 0, 0, 0x3373, 0x7059, 0x705D, 0,
- 0, 0xE743, 0, 0x705E, 0, 0x3048, 0, 0x705F,
- 0x7060, 0, 0, 0, 0, 0xE744, 0xE745, 0xE746,
- 0x3E64, 0xE747, 0xE748, 0, 0x7061, 0, 0xE749, 0xE74A,
- 0x3547, 0, 0xE74B, 0x7064, 0, 0, 0x7063, 0,
- 0x7062, 0, 0, 0x6B71, 0xE74C, 0x4A5C, 0xE74D, 0,
- 0, 0xE74E, 0xE74F, 0x7065, 0x7066, 0xE750, 0xE751, 0,
- 0xE752, 0xE753, 0xE754, 0, 0xE755, 0, 0xE756, 0xE757,
-};
-static const unsigned short utf8_to_euc_E99E_x0213[] = {
- 0xE742, 0x705B, 0, 0, 0x3373, 0x7059, 0x705D, 0,
- 0, 0xE743, 0, 0x705E, 0, 0x3048, 0, 0x705F,
- 0x7060, 0, 0, 0, 0, 0x7D6E, 0xFC24, 0xE746,
- 0x3E64, 0xE747, 0xFC25, 0, 0x7061, 0, 0xFC26, 0xE74A,
- 0x3547, 0, 0xFC27, 0x7064, 0, 0, 0x7063, 0,
- 0x7062, 0, 0, 0x6B71, 0xE74C, 0x4A5C, 0x7D6F, 0,
- 0, 0xFC28, 0xFC29, 0x7065, 0x7066, 0xE750, 0xE751, 0,
- 0xE752, 0xE753, 0x7D70, 0, 0xE755, 0, 0xFC2A, 0xE757,
-};
-static const unsigned short utf8_to_euc_E99F[] = {
- 0, 0xE758, 0, 0x7067, 0xE759, 0xE75A, 0x7068, 0xE75B,
- 0x7069, 0xE75C, 0xE75D, 0x706A, 0xE75E, 0xE75F, 0xE760, 0,
- 0xE761, 0xE762, 0, 0x345A, 0xE763, 0, 0, 0xE764,
- 0xE765, 0xE766, 0, 0xE76A, 0x706B, 0xE767, 0xE768, 0,
- 0xE769, 0xE76B, 0, 0, 0xE76C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x706C, 0x4723, 0xE76D,
- 0, 0xE76E, 0x706E, 0x323B, 0xE76F, 0x7071, 0x7070, 0xE770,
- 0xE771, 0, 0xE772, 0x3124, 0, 0, 0, 0x3641,
-};
-static const unsigned short utf8_to_euc_E99F_x0213[] = {
- 0, 0x7D71, 0, 0x7067, 0xE759, 0xE75A, 0x7068, 0xE75B,
- 0x7069, 0x7D72, 0xE75D, 0x706A, 0xFC2B, 0xE75F, 0xE760, 0,
- 0xE761, 0xFC2C, 0, 0x345A, 0xFC2D, 0, 0, 0xE764,
- 0xFC2E, 0xFC2F, 0, 0x7D74, 0x706B, 0xE767, 0x7D73, 0,
- 0xE769, 0xFC30, 0, 0, 0xE76C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x706C, 0x4723, 0xE76D,
- 0, 0xFC31, 0x706E, 0x323B, 0x7D75, 0x7071, 0x7070, 0xE770,
- 0xE771, 0, 0xE772, 0x3124, 0, 0, 0, 0x3641,
-};
-static const unsigned short utf8_to_euc_E9A0[] = {
- 0, 0x4A47, 0x443A, 0x3A22, 0, 0x3960, 0x3D67, 0xE773,
- 0x3F5C, 0, 0xE774, 0, 0x7073, 0xE776, 0xE777, 0x7072,
- 0x4D42, 0x3468, 0x4852, 0x465C, 0xE778, 0, 0xE779, 0x3F7C,
- 0x4E4E, 0xE775, 0x375B, 0, 0xE77A, 0, 0xE77B, 0,
- 0xE77C, 0x7076, 0, 0xE77D, 0x7075, 0xE828, 0xE77E, 0,
- 0, 0, 0, 0xE821, 0x4B4B, 0x462C, 0xE822, 0xE823,
- 0xE824, 0, 0xE825, 0xE826, 0x3150, 0xE827, 0, 0x7077,
- 0x7074, 0, 0, 0x4951, 0x4D6A, 0x7078, 0xE829, 0,
-};
-static const unsigned short utf8_to_euc_E9A0_x0213[] = {
- 0, 0x4A47, 0x443A, 0x3A22, 0xFC32, 0x3960, 0x3D67, 0xE773,
- 0x3F5C, 0, 0x7D77, 0, 0x7073, 0xFC33, 0xFC34, 0x7072,
- 0x4D42, 0x3468, 0x4852, 0x465C, 0xFC35, 0, 0xFC36, 0x3F7C,
- 0x4E4E, 0xE775, 0x375B, 0, 0xE77A, 0, 0x7D78, 0,
- 0xE77C, 0x7076, 0, 0xFC39, 0x7075, 0xFC3C, 0xE77E, 0,
- 0, 0, 0, 0x7D79, 0x4B4B, 0x462C, 0xE822, 0xE823,
- 0x7D7A, 0, 0xFC3A, 0xFC3B, 0x3150, 0xE827, 0, 0x7077,
- 0x7074, 0, 0, 0x4951, 0x4D6A, 0x7078, 0xE829, 0,
-};
-static const unsigned short utf8_to_euc_E9A1[] = {
- 0, 0, 0, 0, 0xE82A, 0, 0x7079, 0xE82B,
- 0, 0, 0xE82C, 0x707B, 0x426A, 0x335B, 0x335C, 0x707A,
- 0, 0xE82D, 0xE82E, 0xE82F, 0x3469, 0x3832, 0xE830, 0xE831,
- 0x346A, 0xE832, 0xE833, 0x453F, 0, 0, 0x4E60, 0,
- 0, 0, 0xE834, 0xE835, 0, 0xE836, 0xE837, 0x385C,
- 0, 0, 0xE838, 0x707C, 0xE839, 0, 0, 0x707D,
- 0x707E, 0x7121, 0, 0x7123, 0x7122, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9A1_x0213[] = {
- 0, 0, 0, 0, 0xE82A, 0, 0x7079, 0xFC3D,
- 0, 0, 0xE82C, 0x707B, 0x426A, 0x335B, 0x335C, 0x707A,
- 0, 0xE82D, 0x7D7C, 0x7D7D, 0x3469, 0x3832, 0x7D7E, 0x7E21,
- 0x346A, 0x7E22, 0x7E23, 0x453F, 0, 0, 0x4E60, 0,
- 0, 0, 0xE834, 0xE835, 0, 0x7E25, 0xFC3E, 0x385C,
- 0, 0, 0xE838, 0x707C, 0x7E26, 0, 0, 0x707D,
- 0x707E, 0x7121, 0, 0x7123, 0x7122, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9A2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x4977, 0, 0x7124, 0xE83A, 0, 0xE83B, 0xE83C, 0x7125,
- 0xE83D, 0x7126, 0, 0, 0xE83E, 0, 0x7127, 0xE83F,
- 0xE840, 0, 0xE841, 0xE842, 0, 0, 0, 0xE843,
-};
-static const unsigned short utf8_to_euc_E9A2_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x4977, 0, 0x7124, 0xFC3F, 0, 0xFC40, 0xE83C, 0x7125,
- 0xFC41, 0x7126, 0, 0, 0xE83E, 0, 0x7127, 0xFC43,
- 0xFC44, 0, 0x7E27, 0xFC45, 0xFC46, 0, 0, 0xFC47,
-};
-static const unsigned short utf8_to_euc_E9A3[] = {
- 0, 0, 0xE844, 0x7129, 0x7128, 0xE845, 0x712A, 0,
- 0xE846, 0, 0, 0, 0xE847, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x4874, 0x664C, 0, 0, 0x3F29,
- 0, 0xE848, 0x3532, 0xE849, 0, 0xE84A, 0xE84B, 0xE84C,
- 0, 0x712B, 0xE84D, 0x712C, 0, 0x522C, 0x5D3B, 0x4853,
- 0, 0, 0x307B, 0xE84E, 0x303B, 0, 0xE84F, 0,
- 0, 0, 0, 0, 0x3B74, 0x4B30, 0x3E7E, 0,
-};
-static const unsigned short utf8_to_euc_E9A3_x0213[] = {
- 0, 0, 0xFC48, 0x7129, 0x7128, 0xE845, 0x712A, 0xFC49,
- 0x7E28, 0, 0, 0xFC4A, 0xE847, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x4874, 0x664C, 0, 0, 0x3F29,
- 0xFC4B, 0xFC4D, 0x3532, 0xFC4E, 0, 0xFC4F, 0xE84B, 0x7E29,
- 0, 0x712B, 0xFC50, 0x712C, 0, 0x522C, 0x5D3B, 0x4853,
- 0xFC51, 0xFC52, 0x307B, 0xFC53, 0x303B, 0, 0xE84F, 0,
- 0, 0, 0, 0, 0x3B74, 0x4B30, 0x3E7E, 0,
-};
-static const unsigned short utf8_to_euc_E9A4[] = {
- 0, 0, 0xE850, 0x712D, 0, 0x4C5F, 0, 0xE851,
- 0xE852, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
- 0x3B41, 0xE853, 0x712F, 0x326E, 0x7130, 0xE854, 0xE855, 0xE856,
- 0x7131, 0, 0xE857, 0xE858, 0xE859, 0x7133, 0x7134, 0xE85A,
- 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0xE85D,
- 0x345B, 0, 0, 0xE85E, 0x7137, 0, 0x7138, 0,
- 0, 0xE85F, 0xE860, 0xE861, 0xE862, 0xE863, 0, 0,
- 0, 0xE864, 0xE865, 0xE866, 0xE867, 0x7139, 0x713A, 0,
-};
-static const unsigned short utf8_to_euc_E9A4_x0213[] = {
- 0, 0, 0xE850, 0x712D, 0, 0x4C5F, 0, 0xE851,
- 0xFC54, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
- 0x3B41, 0xE853, 0x712F, 0x326E, 0x7130, 0xE854, 0xFC57, 0xFC58,
- 0x7131, 0, 0xFC5A, 0xFC5B, 0xFC5C, 0x7133, 0x7134, 0xE85A,
- 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0,
- 0x345B, 0, 0, 0xE85E, 0x7137, 0, 0x7138, 0,
- 0, 0xFC5E, 0xFC5F, 0xFC60, 0xE862, 0xE863, 0, 0,
- 0, 0xE864, 0xFC61, 0xFC62, 0xFC63, 0x7139, 0x713A, 0,
-};
-static const unsigned short utf8_to_euc_E9A5[] = {
- 0xE868, 0xE869, 0x713B, 0, 0, 0x713D, 0xE86A, 0xE86B,
- 0xE86C, 0x713C, 0, 0x713F, 0x7142, 0xE86D, 0xE86E, 0,
- 0x713E, 0x7140, 0x7141, 0, 0xE86F, 0x7143, 0, 0x3642,
- 0xE870, 0xE871, 0, 0xE872, 0xE873, 0, 0xE874, 0xE875,
- 0xE876, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E9A5_x0213[] = {
- 0xFC64, 0xFC65, 0x713B, 0, 0, 0x713D, 0xFC66, 0xE86B,
- 0xE86C, 0x713C, 0, 0x713F, 0x7142, 0xFC67, 0xFC68, 0,
- 0x713E, 0x7140, 0x7141, 0, 0xE86F, 0x7143, 0, 0x3642,
- 0x7E2A, 0xE871, 0, 0xE872, 0xFC69, 0, 0xE874, 0xFC6A,
- 0xFC6B, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_E9A6[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x3C73, 0x7144,
- 0x7145, 0x3961, 0, 0xE877, 0, 0xE878, 0xF47A, 0xE879,
- 0, 0, 0, 0, 0, 0x7146, 0xE87A, 0,
- 0x333E, 0, 0, 0, 0x474F, 0x7147, 0x7148, 0,
- 0xE87B, 0xE87C, 0xE87D, 0x435A, 0x466B, 0xE87E, 0, 0,
- 0, 0xE921, 0xE922, 0, 0x7149, 0xE923, 0, 0xE924,
-};
-static const unsigned short utf8_to_euc_E9A6_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x3C73, 0x7144,
- 0x7145, 0x3961, 0, 0xE877, 0, 0xE878, 0x7E2B, 0xE879,
- 0, 0, 0, 0xFC6C, 0, 0x7146, 0xFC6D, 0,
- 0x333E, 0, 0, 0, 0x474F, 0x7147, 0x7148, 0,
- 0xE87B, 0xE87C, 0xE87D, 0x435A, 0x466B, 0xE87E, 0, 0,
- 0, 0xFC6E, 0xE922, 0, 0x7149, 0xFC6F, 0, 0xFC70,
-};
-static const unsigned short utf8_to_euc_E9A7[] = {
- 0, 0x477D, 0, 0xE925, 0x424C, 0x3158, 0x366E, 0,
- 0x366F, 0xE926, 0, 0, 0, 0, 0, 0,
- 0x4373, 0x714E, 0x3670, 0xE927, 0xE928, 0x326F, 0, 0,
- 0x714D, 0xE929, 0xE92A, 0x714B, 0xE92B, 0x714C, 0xE92C, 0x714A,
- 0, 0, 0x7158, 0, 0, 0, 0, 0xE92D,
- 0, 0, 0xE92E, 0xE92F, 0xE930, 0x714F, 0x7150, 0,
- 0xE931, 0x7151, 0x7152, 0, 0xE932, 0xE933, 0, 0,
- 0x7154, 0xE934, 0, 0x7153, 0, 0xE935, 0xE936, 0x3D59,
-};
-static const unsigned short utf8_to_euc_E9A7_x0213[] = {
- 0, 0x477D, 0, 0xFC71, 0x424C, 0x3158, 0x366E, 0,
- 0x366F, 0xFC72, 0, 0, 0, 0, 0, 0,
- 0x4373, 0x714E, 0x3670, 0xE927, 0xFC73, 0x326F, 0, 0,
- 0x714D, 0xFC74, 0xE92A, 0x714B, 0xE92B, 0x714C, 0xFC75, 0x714A,
- 0, 0, 0x7158, 0, 0, 0, 0, 0xE92D,
- 0, 0, 0xE92E, 0xE92F, 0xE930, 0x714F, 0x7150, 0,
- 0xFC77, 0x7151, 0x7152, 0, 0xE932, 0xE933, 0, 0,
- 0x7154, 0xFC78, 0, 0x7153, 0xFC79, 0xE935, 0xE936, 0x3D59,
-};
-static const unsigned short utf8_to_euc_E9A8[] = {
- 0, 0x7155, 0xE937, 0xE938, 0xE939, 0x7157, 0, 0,
- 0, 0, 0, 0xE93A, 0xE93B, 0, 0x3533, 0x7156,
- 0xE93C, 0xE93D, 0x417B, 0x3833, 0, 0, 0xE93E, 0,
- 0, 0x7159, 0, 0, 0, 0, 0xE93F, 0,
- 0xE940, 0, 0xE941, 0xE942, 0xE943, 0, 0, 0xE944,
- 0x424D, 0, 0, 0x715A, 0, 0xE945, 0xE946, 0,
- 0x462D, 0, 0, 0xE947, 0, 0xE948, 0xE949, 0x715B,
- 0xE94A, 0, 0, 0, 0, 0, 0x7160, 0,
-};
-static const unsigned short utf8_to_euc_E9A8_x0213[] = {
- 0, 0x7155, 0x7E2C, 0x7E2D, 0xE939, 0x7157, 0, 0,
- 0, 0, 0xFC7A, 0xE93A, 0xE93B, 0, 0x3533, 0x7156,
- 0xE93C, 0xFC7B, 0x417B, 0x3833, 0, 0, 0xFC7C, 0,
- 0, 0x7159, 0xFC7D, 0, 0, 0, 0xE93F, 0,
- 0xFC7E, 0, 0xE941, 0xE942, 0x7E2E, 0, 0, 0xE944,
- 0x424D, 0, 0, 0x715A, 0, 0x7E2F, 0x7E30, 0,
- 0x462D, 0xFD21, 0, 0xE947, 0, 0xE948, 0xFD22, 0x715B,
- 0x7E31, 0, 0, 0, 0, 0, 0x7160, 0,
-};
-static const unsigned short utf8_to_euc_E9A9[] = {
- 0x715E, 0xE94C, 0x715D, 0x715F, 0xE94D, 0x715C, 0, 0xE94B,
- 0, 0, 0xE94E, 0xE94F, 0xE950, 0x7162, 0xE951, 0,
- 0, 0xE952, 0, 0, 0xE953, 0x7161, 0xE954, 0x7164,
- 0, 0, 0x3643, 0x7163, 0, 0xE955, 0, 0x7165,
- 0, 0, 0x7166, 0, 0x7168, 0x7167, 0, 0,
- 0, 0x7169, 0x716B, 0x716A, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9A9_x0213[] = {
- 0x715E, 0xE94C, 0x715D, 0x715F, 0xFD23, 0x715C, 0, 0xE94B,
- 0, 0, 0x7E32, 0xE94F, 0xFD24, 0x7162, 0x7E33, 0,
- 0, 0xE952, 0x7E34, 0, 0xE953, 0x7161, 0xE954, 0x7164,
- 0xFD25, 0, 0x3643, 0x7163, 0, 0xE955, 0, 0x7165,
- 0, 0, 0x7166, 0, 0x7168, 0x7167, 0, 0,
- 0, 0x7169, 0x716B, 0x716A, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9AA[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x397C, 0, 0xE956, 0, 0xE957, 0x716C, 0xE958, 0xE959,
- 0x716D, 0, 0xE95A, 0, 0xE95B, 0xE95C, 0xE95D, 0,
- 0x333C, 0xE95E, 0, 0xE95F, 0x716E, 0, 0xE960, 0xE961,
-};
-static const unsigned short utf8_to_euc_E9AA_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x397C, 0, 0xE956, 0, 0xE957, 0x716C, 0xE958, 0xFD27,
- 0x716D, 0, 0xE95A, 0, 0xE95B, 0xE95C, 0x7E35, 0xFD29,
- 0x333C, 0xFD2B, 0, 0xE95F, 0x716E, 0, 0xE960, 0xE961,
-};
-static const unsigned short utf8_to_euc_E9AB[] = {
- 0x716F, 0xE962, 0, 0xE963, 0x3F71, 0, 0xE964, 0,
- 0xE965, 0, 0, 0, 0, 0, 0xE966, 0x7170,
- 0xE967, 0x7171, 0xE968, 0x7172, 0x7173, 0xE969, 0xE96A, 0xE96B,
- 0x3962, 0xF47B, 0, 0xE96C, 0xE96D, 0, 0x7174, 0x7175,
- 0xE96E, 0, 0x7176, 0x7177, 0xE96F, 0xE970, 0x7178, 0xE971,
- 0, 0xE972, 0x4831, 0x717A, 0xE973, 0x4926, 0x717B, 0x7179,
- 0, 0x717D, 0xE974, 0xE975, 0x717C, 0xE976, 0, 0x717E,
- 0, 0xE977, 0xE978, 0x7221, 0, 0xE979, 0, 0xE97A,
-};
-static const unsigned short utf8_to_euc_E9AB_x0213[] = {
- 0x716F, 0x7E36, 0, 0x7E37, 0x3F71, 0, 0xFD2D, 0,
- 0xE965, 0, 0, 0, 0, 0, 0x7E38, 0x7170,
- 0xFD2E, 0x7171, 0xFD2F, 0x7172, 0x7173, 0xFD30, 0x7E39, 0xE96B,
- 0x3962, 0, 0, 0xE96C, 0xFD32, 0, 0x7174, 0x7175,
- 0xFD33, 0, 0x7176, 0x7177, 0xE96F, 0xFD34, 0x7178, 0xE971,
- 0, 0xFD35, 0x4831, 0x717A, 0xE973, 0x4926, 0x717B, 0x7179,
- 0, 0x717D, 0xE974, 0xE975, 0x717C, 0xE976, 0, 0x717E,
- 0, 0x7E3A, 0xE978, 0x7221, 0, 0xE979, 0, 0xE97A,
-};
-static const unsigned short utf8_to_euc_E9AC[] = {
- 0xE97B, 0xE97C, 0xE97D, 0xE97E, 0xEA21, 0xEA22, 0x7222, 0,
- 0xEA23, 0xEA24, 0, 0xEA25, 0xEA26, 0xEA27, 0xEA28, 0,
- 0xEA29, 0, 0xEA2A, 0, 0, 0, 0xEA2B, 0,
- 0x7223, 0xEA2C, 0x7224, 0xEA2D, 0xEA2E, 0, 0, 0x7225,
- 0xEA2F, 0, 0x7226, 0x7227, 0, 0x7228, 0xEA30, 0x7229,
- 0x722A, 0x722B, 0x722C, 0xEA31, 0, 0xEA32, 0x722D, 0x722E,
- 0, 0x5D35, 0x722F, 0xEA33, 0xEA34, 0xEA35, 0, 0xEA36,
- 0, 0xEA37, 0xEA38, 0x6478, 0x3534, 0xEA39, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9AC_x0213[] = {
- 0xE97B, 0xE97C, 0x7E3B, 0xFD36, 0xEA21, 0xEA22, 0x7222, 0,
- 0x7E3C, 0xEA24, 0, 0xEA25, 0xFD37, 0xEA27, 0xEA28, 0,
- 0xFD38, 0, 0xFD39, 0, 0, 0, 0xFD3A, 0,
- 0x7223, 0xEA2C, 0x7224, 0xEA2D, 0xFD3B, 0, 0, 0x7225,
- 0x7E3D, 0, 0x7226, 0x7227, 0, 0x7228, 0xEA30, 0x7229,
- 0x722A, 0x722B, 0x722C, 0xFD3C, 0, 0x7E3F, 0x722D, 0x722E,
- 0, 0x5D35, 0x722F, 0xFD3D, 0xEA34, 0xEA35, 0, 0xEA36,
- 0, 0xEA37, 0xEA38, 0x6478, 0x3534, 0xFD3E, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9AD[] = {
- 0, 0x3321, 0x3A32, 0x7231, 0x7230, 0x4C25, 0, 0,
- 0xEA3A, 0, 0, 0xEA3B, 0xEA3C, 0x7233, 0x7234, 0x7232,
- 0, 0x7235, 0, 0, 0x4B62, 0xEA3D, 0xEA3E, 0xEA3F,
- 0x7236, 0, 0x357B, 0xEA40, 0, 0, 0xEA41, 0,
- 0, 0xEA42, 0, 0xEA43, 0, 0xEA44, 0xEA45, 0,
- 0xEA46, 0, 0xEA47, 0xEA48, 0xEA49, 0xEA4A, 0xEA4B, 0x4F25,
- 0, 0, 0xF47C, 0xEA4C, 0x7237, 0xEA4D, 0, 0xEA4E,
- 0xEA4F, 0xEA50, 0, 0, 0, 0, 0, 0xEA51,
-};
-static const unsigned short utf8_to_euc_E9AD_x0213[] = {
- 0, 0x3321, 0x3A32, 0x7231, 0x7230, 0x4C25, 0, 0,
- 0xEA3A, 0, 0, 0xFD40, 0xEA3C, 0x7233, 0x7234, 0x7232,
- 0, 0x7235, 0, 0, 0x4B62, 0xEA3D, 0xEA3E, 0xEA3F,
- 0x7236, 0, 0x357B, 0xEA40, 0, 0, 0x7E40, 0,
- 0, 0xEA42, 0, 0xFD41, 0, 0xFD42, 0x7E42, 0,
- 0xEA46, 0, 0xEA47, 0xFD43, 0xFD44, 0xEA4A, 0xEA4B, 0x4F25,
- 0, 0, 0x7E43, 0xFD45, 0x7237, 0x7E44, 0xFD46, 0xFD47,
- 0xEA4F, 0x7E41, 0, 0, 0, 0, 0, 0xEA51,
-};
-static const unsigned short utf8_to_euc_E9AE[] = {
- 0xEA52, 0, 0, 0x7239, 0xEA53, 0xEA54, 0xEA55, 0xEA56,
- 0, 0xEA57, 0xEA58, 0xEA59, 0, 0xEA5A, 0x303E, 0xEA5B,
- 0xEA5C, 0x723A, 0x4A2B, 0x7238, 0xEA5D, 0, 0x723B, 0x723C,
- 0, 0, 0xEA5E, 0, 0, 0xEA5F, 0xEA60, 0x723D,
- 0x723E, 0, 0, 0, 0, 0, 0xEA61, 0xEA62,
- 0x723F, 0xEA63, 0x4B6E, 0x3B2D, 0xEA64, 0x3A7A, 0x412F, 0,
- 0xEA65, 0xEA66, 0xEA67, 0, 0x7240, 0, 0, 0xEA68,
- 0xEA69, 0x7243, 0, 0xEA6A, 0xEA6B, 0, 0xEA6C, 0xEA6D,
-};
-static const unsigned short utf8_to_euc_E9AE_x0213[] = {
- 0xEA52, 0, 0, 0x7239, 0x7E45, 0xEA54, 0xEA55, 0xEA56,
- 0, 0xEA57, 0x7E46, 0xEA59, 0, 0xEA5A, 0x303E, 0x7E47,
- 0xEA5C, 0x723A, 0x4A2B, 0x7238, 0xEA5D, 0, 0x723B, 0x723C,
- 0, 0, 0xEA5E, 0, 0, 0xEA5F, 0x7E48, 0x723D,
- 0x723E, 0, 0, 0, 0, 0, 0xFD48, 0x7E49,
- 0x723F, 0xEA63, 0x4B6E, 0x3B2D, 0xFD49, 0x3A7A, 0x412F, 0,
- 0xEA65, 0xFD4A, 0xFD4D, 0, 0x7240, 0, 0, 0xEA68,
- 0xFD4E, 0x7243, 0, 0, 0xEA6B, 0, 0xFD4F, 0xEA6D,
-};
-static const unsigned short utf8_to_euc_E9AF[] = {
- 0x7241, 0xEA6E, 0, 0, 0, 0, 0x7244, 0xEA6F,
- 0xEA70, 0x3871, 0x7242, 0, 0, 0, 0xEA71, 0x7245,
- 0xEA72, 0x7246, 0x7247, 0, 0x724B, 0, 0x3B2A, 0xEA73,
- 0xEA74, 0, 0, 0x4264, 0, 0xEA75, 0, 0xEA76,
- 0, 0x724C, 0x7249, 0x7248, 0x724A, 0xEA77, 0, 0xEA78,
- 0x375F, 0, 0xEA79, 0xEA7A, 0, 0, 0, 0xEA7B,
- 0x7250, 0x724F, 0x724E, 0xEA7C, 0, 0x3033, 0, 0xEA7D,
- 0xEA7E, 0xEB21, 0xEB22, 0, 0, 0xEB23, 0, 0xEB24,
-};
-static const unsigned short utf8_to_euc_E9AF_x0213[] = {
- 0x7241, 0x7E4A, 0, 0, 0, 0, 0x7244, 0xFD50,
- 0xEA70, 0x3871, 0x7242, 0, 0, 0, 0x7E4B, 0x7245,
- 0xEA72, 0x7246, 0x7247, 0, 0x724B, 0, 0x3B2A, 0xEA73,
- 0xFD52, 0, 0, 0x4264, 0, 0xFD53, 0, 0xEA76,
- 0, 0x724C, 0x7249, 0x7248, 0x724A, 0x7E4C, 0, 0xFD54,
- 0x375F, 0, 0xFD55, 0xFD56, 0, 0, 0xFD58, 0xFD57,
- 0x7250, 0x724F, 0x724E, 0xFD51, 0, 0x3033, 0, 0xFD5C,
- 0x7E4D, 0xEB21, 0xFD5A, 0, 0, 0x7E4E, 0, 0xEB24,
-};
-static const unsigned short utf8_to_euc_E9B0[] = {
- 0xEB25, 0, 0xEB26, 0, 0x725A, 0, 0x7256, 0,
- 0x7257, 0x7253, 0x7259, 0xEB27, 0x7255, 0x3362, 0, 0xEB28,
- 0x4F4C, 0xEB29, 0x7258, 0x7254, 0x7252, 0x7251, 0xEB2A, 0,
- 0xEB2B, 0xEB2C, 0xEB2D, 0x725C, 0xEB2E, 0, 0xEB2F, 0,
- 0, 0x725F, 0xEB30, 0xEB31, 0x725E, 0x725D, 0xEB32, 0xEB33,
- 0xEB34, 0xEB35, 0xEB36, 0, 0, 0x4949, 0x725B, 0x3073,
- 0x7260, 0xEB37, 0x7262, 0, 0, 0xEB38, 0xEB39, 0xEB3A,
- 0, 0x336F, 0x724D, 0x3137, 0, 0xEB3B, 0x7264, 0,
-};
-static const unsigned short utf8_to_euc_E9B0_x0213[] = {
- 0x7E4F, 0, 0xEB26, 0, 0x725A, 0, 0x7256, 0,
- 0x7257, 0x7253, 0x7259, 0xEB27, 0x7255, 0x3362, 0, 0xEB28,
- 0x4F4C, 0xEB29, 0x7258, 0x7254, 0x7252, 0x7251, 0xFD5E, 0,
- 0xFD5F, 0xFD60, 0xFD61, 0x725C, 0xEB2E, 0xFD62, 0xEB2F, 0,
- 0, 0x725F, 0xFD63, 0x7E50, 0x725E, 0x725D, 0xEB32, 0xFD64,
- 0xEB34, 0xFD65, 0xFD66, 0, 0, 0x4949, 0x725B, 0x3073,
- 0x7260, 0xFD68, 0x7262, 0, 0, 0xEB38, 0xFD69, 0xFD6A,
- 0, 0x336F, 0x724D, 0x3137, 0, 0xEB3B, 0x7264, 0,
-};
-static const unsigned short utf8_to_euc_E9B1[] = {
- 0, 0xEB3C, 0, 0xEB3D, 0xEB3E, 0xEB3F, 0x7263, 0x7261,
- 0x432D, 0xEB40, 0xEB41, 0, 0, 0, 0xEB42, 0xEB43,
- 0xEB44, 0, 0x4B70, 0xEB45, 0xEB46, 0, 0xEB47, 0x4E5A,
- 0xEB48, 0, 0x7265, 0xEB49, 0xEB50, 0xEB4A, 0xEB4B, 0xEB4C,
- 0x7266, 0, 0, 0xEB4D, 0, 0, 0, 0x7267,
- 0xEB52, 0xEB4E, 0xEB4F, 0xEB51, 0, 0, 0xEB53, 0,
- 0xEB54, 0, 0xEB55, 0, 0, 0xEB56, 0x7268, 0xEB57,
- 0x7269, 0, 0, 0xEB58, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B1_x0213[] = {
- 0, 0x7E51, 0, 0xEB3D, 0xEB3E, 0xFD6B, 0x7263, 0x7261,
- 0x432D, 0xFD6E, 0xFD6F, 0, 0, 0, 0xEB42, 0x7E52,
- 0x7E53, 0, 0x4B70, 0x7E54, 0xFD71, 0, 0xEB47, 0x4E5A,
- 0xFD72, 0, 0x7265, 0xFD73, 0xFD6C, 0xFD74, 0xEB4B, 0xFD75,
- 0x7266, 0, 0, 0x7E55, 0, 0x7E56, 0, 0x7267,
- 0xEB52, 0xFD76, 0xFD77, 0xFD78, 0, 0xFD79, 0xFD7A, 0,
- 0xFD7B, 0, 0xFD7C, 0, 0, 0xFD7D, 0x7268, 0x7E57,
- 0x7269, 0, 0xFD7E, 0xEB58, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B3[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x443B, 0xEB59, 0x726A,
- 0, 0x4837, 0, 0x726F, 0x726B, 0, 0, 0,
- 0x726C, 0, 0xEB5A, 0x4B31, 0x4C44, 0, 0x4650, 0xEB5B,
- 0, 0xEB5C, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B3_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x443B, 0xFE21, 0x726A,
- 0, 0x4837, 0, 0x726F, 0x726B, 0, 0, 0,
- 0x726C, 0, 0xFE22, 0x4B31, 0x4C44, 0, 0x4650, 0xEB5B,
- 0, 0xEB5C, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B4[] = {
- 0, 0, 0xEB5E, 0x7270, 0, 0, 0x7271, 0x463E,
- 0x726E, 0x726D, 0, 0xEB5D, 0, 0, 0x322A, 0,
- 0, 0xEB5F, 0x7279, 0, 0, 0x7278, 0, 0xEB60,
- 0xEB61, 0, 0, 0x3175, 0xEB62, 0xEB63, 0xEB64, 0x7276,
- 0, 0, 0, 0x7275, 0, 0, 0x7273, 0,
- 0x337B, 0, 0x7272, 0x3C32, 0x3229, 0, 0, 0xEB65,
- 0xEB66, 0, 0xEB67, 0xEB68, 0xEB69, 0, 0, 0,
- 0, 0, 0xEB6A, 0x3963, 0xEB6B, 0xEB6D, 0x727C, 0x727B,
-};
-static const unsigned short utf8_to_euc_E9B4_x0213[] = {
- 0, 0, 0xFE24, 0x7270, 0, 0, 0x7271, 0x463E,
- 0x726E, 0x726D, 0, 0xFE23, 0, 0, 0x322A, 0,
- 0, 0xFE26, 0x7279, 0, 0, 0x7278, 0, 0xFE27,
- 0xFE28, 0, 0, 0x3175, 0xEB62, 0x7E58, 0x7E59, 0x7276,
- 0, 0, 0, 0x7275, 0, 0, 0x7273, 0,
- 0x337B, 0, 0x7272, 0x3C32, 0x3229, 0, 0, 0xEB65,
- 0xEB66, 0, 0xFE2C, 0xEB68, 0xEB69, 0, 0, 0,
- 0, 0, 0xEB6A, 0x3963, 0xEB6B, 0xEB6D, 0x727C, 0x727B,
-};
-static const unsigned short utf8_to_euc_E9B5[] = {
- 0, 0x727A, 0xEB6E, 0xEB6F, 0x7277, 0xEB6C, 0x727D, 0xEB70,
- 0x727E, 0, 0xEB71, 0, 0, 0, 0, 0,
- 0x7325, 0x7324, 0, 0xEB72, 0xEB73, 0, 0, 0,
- 0, 0x7326, 0, 0, 0x312D, 0x7321, 0x7322, 0xEB74,
- 0x3974, 0x4C39, 0xEB76, 0xEB75, 0x7323, 0xEB77, 0, 0,
- 0, 0xEB78, 0xEB79, 0xEB7A, 0x4B32, 0, 0, 0x732B,
- 0xEB7B, 0, 0x7327, 0, 0, 0, 0xEB7C, 0xEB7D,
- 0, 0, 0x732C, 0xEB7E, 0xEC21, 0, 0xEC22, 0,
-};
-static const unsigned short utf8_to_euc_E9B5_x0213[] = {
- 0, 0x727A, 0xFE2E, 0x7E5A, 0x7277, 0xEB6C, 0x727D, 0x7E5B,
- 0x727E, 0, 0xFE2F, 0, 0, 0, 0, 0,
- 0x7325, 0x7324, 0x7E5C, 0xEB72, 0xEB73, 0, 0, 0,
- 0, 0x7326, 0, 0, 0x312D, 0x7321, 0x7322, 0xFE30,
- 0x3974, 0x4C39, 0xFE31, 0x7E5D, 0x7323, 0xEB77, 0, 0,
- 0, 0xFE33, 0xEB79, 0xFE34, 0x4B32, 0, 0, 0x732B,
- 0x7E5E, 0, 0x7327, 0xFE36, 0, 0, 0xFE37, 0xFE38,
- 0, 0, 0x732C, 0xEB7E, 0x7E5F, 0, 0xFE39, 0,
-};
-static const unsigned short utf8_to_euc_E9B6[] = {
- 0, 0, 0, 0xEC23, 0xEC24, 0, 0xEC25, 0x7329,
- 0, 0x7328, 0xEC26, 0, 0, 0xEC27, 0xEC28, 0x375C,
- 0, 0, 0xEC29, 0xEC2A, 0, 0xEC2B, 0xEC2C, 0xEC2D,
- 0xEC2E, 0, 0x732D, 0, 0, 0, 0, 0,
- 0, 0xEC2F, 0, 0, 0x732E, 0, 0, 0,
- 0, 0x732F, 0xEC30, 0x732A, 0xEC31, 0, 0xEC32, 0x7274,
- 0, 0xEC33, 0x7330, 0, 0x4461, 0xEC34, 0, 0,
- 0x7334, 0xEC35, 0x7335, 0x7333, 0xEC36, 0, 0, 0xEC37,
-};
-static const unsigned short utf8_to_euc_E9B6_x0213[] = {
- 0, 0, 0, 0xEC23, 0xFE3A, 0, 0xEC25, 0x7329,
- 0, 0x7328, 0x7E60, 0, 0, 0xFE3B, 0xEC28, 0x375C,
- 0, 0, 0xEC29, 0xEC2A, 0, 0xEC2B, 0x7E61, 0xEC2D,
- 0xEC2E, 0xFE3C, 0x732D, 0, 0, 0, 0, 0,
- 0, 0xFE3D, 0, 0, 0x732E, 0, 0, 0,
- 0, 0x732F, 0xEC30, 0x732A, 0x7E63, 0, 0xEC32, 0x7274,
- 0, 0xEC33, 0x7330, 0, 0x4461, 0xFE3F, 0, 0,
- 0x7334, 0xFE40, 0x7335, 0x7333, 0x7E64, 0xFE41, 0, 0xFE3E,
-};
-static const unsigned short utf8_to_euc_E9B7[] = {
- 0, 0x7332, 0x7338, 0xEC38, 0x7331, 0, 0x7336, 0xEC39,
- 0, 0xEC3A, 0xEC3B, 0, 0, 0, 0, 0x7337,
- 0, 0, 0, 0x733A, 0xEC3C, 0xEC3D, 0xEC3E, 0xEC3F,
- 0, 0x7339, 0xEC40, 0, 0, 0, 0xEC41, 0xEC42,
- 0xEC43, 0, 0, 0, 0, 0xEC44, 0x733C, 0xEC45,
- 0, 0xEC46, 0, 0xEC47, 0, 0x733D, 0xEC48, 0x733E,
- 0xEC49, 0, 0x4F49, 0xEC4A, 0xEC4B, 0, 0, 0,
- 0x733B, 0x426B, 0x3A6D, 0, 0, 0x733F, 0xEC4C, 0,
-};
-static const unsigned short utf8_to_euc_E9B7_x0213[] = {
- 0x7E62, 0x7332, 0x7338, 0xFE42, 0x7331, 0, 0x7336, 0xFE43,
- 0, 0xFE44, 0xEC3B, 0, 0, 0, 0, 0x7337,
- 0, 0, 0, 0x733A, 0xEC3C, 0xEC3D, 0xFE45, 0x7E65,
- 0, 0x7339, 0xFE46, 0, 0, 0, 0xEC41, 0xFE47,
- 0xFE48, 0, 0, 0xFE49, 0, 0xEC44, 0x733C, 0x7E67,
- 0, 0xEC46, 0, 0xEC47, 0, 0x733D, 0xEC48, 0x733E,
- 0xEC49, 0, 0x4F49, 0xEC4A, 0xFE4A, 0, 0, 0,
- 0x733B, 0x426B, 0x3A6D, 0, 0, 0x733F, 0xEC4C, 0,
-};
-static const unsigned short utf8_to_euc_E9B8[] = {
- 0, 0, 0xEC4E, 0, 0, 0, 0, 0xEC4F,
- 0, 0, 0xEC4D, 0, 0, 0, 0xEC50, 0,
- 0xEC51, 0xEC52, 0xEC53, 0, 0, 0xEC54, 0xEC55, 0,
- 0, 0xEC56, 0x7340, 0x7341, 0xEC57, 0xEC58, 0x7342, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B8_x0213[] = {
- 0, 0, 0xFE4D, 0, 0, 0, 0, 0x7E68,
- 0, 0, 0xFE4C, 0, 0, 0xFE4E, 0xEC50, 0,
- 0xEC51, 0xEC52, 0xEC53, 0, 0, 0x7E69, 0xEC55, 0,
- 0, 0xFE4F, 0x7340, 0x7341, 0xFE50, 0xFE51, 0x7342, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9B9[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x7343, 0, 0,
- 0x3834, 0x7344, 0xEC59, 0xEC5A, 0xEC5B, 0x7345, 0, 0x3C2F,
-};
-static const unsigned short utf8_to_euc_E9B9_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x7343, 0, 0,
- 0x3834, 0x7344, 0xEC59, 0xFE52, 0x7E6A, 0x7345, 0, 0x3C2F,
-};
-static const unsigned short utf8_to_euc_E9BA[] = {
- 0xEC5C, 0x7346, 0xEC5D, 0xEC5E, 0xEC5F, 0xEC60, 0, 0xEC61,
- 0x7347, 0, 0, 0x7348, 0x7349, 0, 0xEC62, 0xEC63,
- 0, 0x734C, 0x734A, 0x4F3C, 0, 0x734B, 0xEC64, 0x4E6F,
- 0xEC65, 0, 0, 0xEC66, 0, 0x734D, 0xEC67, 0x4E5B,
- 0, 0, 0, 0, 0xEC68, 0x734E, 0x477E, 0,
- 0xEC69, 0x734F, 0x7351, 0, 0xEC6A, 0x7352, 0xEC6B, 0xEC6C,
- 0xEC6D, 0, 0, 0xEC6E, 0xEC6F, 0xEC70, 0, 0,
- 0x7350, 0x396D, 0x4C4D, 0x4B63, 0x5677, 0, 0x5D60, 0x4B7B,
-};
-static const unsigned short utf8_to_euc_E9BA_x0213[] = {
- 0xFE54, 0x7346, 0xEC5D, 0xEC5E, 0xEC5F, 0xFE55, 0, 0xEC61,
- 0x7347, 0, 0, 0x7348, 0x7349, 0, 0xEC62, 0xEC63,
- 0, 0x734C, 0x734A, 0x4F3C, 0, 0x734B, 0xEC64, 0x4E6F,
- 0xEC65, 0, 0, 0xFE56, 0, 0x734D, 0x7E6B, 0x4E5B,
- 0, 0, 0, 0, 0x7E6C, 0x734E, 0x477E, 0,
- 0xFE57, 0x734F, 0x7351, 0, 0x7E6D, 0x7352, 0xEC6B, 0x7E6E,
- 0xEC6D, 0, 0, 0xEC6E, 0x7E6F, 0x7E70, 0, 0,
- 0x7350, 0x396D, 0x4C4D, 0x4B63, 0x5677, 0xFE59, 0x5D60, 0x4B7B,
-};
-static const unsigned short utf8_to_euc_E9BB[] = {
- 0, 0, 0, 0, 0x322B, 0, 0xEC71, 0,
- 0xEC72, 0, 0, 0xEC73, 0x7354, 0x3550, 0x7355, 0x7356,
- 0x7357, 0xF47E, 0x3975, 0, 0x7358, 0xEC74, 0, 0,
- 0x6054, 0x4C5B, 0, 0x4263, 0x7359, 0x735B, 0x735A, 0xEC75,
- 0x735C, 0, 0, 0, 0xEC76, 0x735D, 0, 0xEC77,
- 0x735E, 0, 0, 0, 0xEC78, 0xEC79, 0xEC7A, 0x735F,
- 0xEC7B, 0xEC7C, 0xEC7D, 0, 0x7360, 0xEC7E, 0x7361, 0x7362,
- 0xED21, 0x7363, 0, 0x7364, 0x7365, 0x7366, 0, 0xED22,
-};
-static const unsigned short utf8_to_euc_E9BB_x0213[] = {
- 0, 0, 0, 0x7E71, 0x322B, 0, 0xEC71, 0,
- 0xEC72, 0, 0, 0xEC73, 0x7354, 0x3550, 0x7355, 0x7356,
- 0x7357, 0x7E72, 0x3975, 0, 0x7358, 0xEC74, 0, 0,
- 0x6054, 0x4C5B, 0, 0x4263, 0x7359, 0x735B, 0x735A, 0xFE5B,
- 0x735C, 0, 0, 0, 0xEC76, 0x735D, 0, 0xFE5C,
- 0x735E, 0, 0, 0, 0xEC78, 0xEC79, 0xFE5D, 0x735F,
- 0xEC7B, 0xEC7C, 0xEC7D, 0, 0x7360, 0xEC7E, 0x7361, 0x7362,
- 0xED21, 0x7363, 0, 0x7364, 0x7365, 0x7366, 0, 0xFE5E,
-};
-static const unsigned short utf8_to_euc_E9BC[] = {
- 0, 0, 0xED23, 0xED24, 0, 0, 0, 0x7367,
- 0x7368, 0xED25, 0, 0, 0, 0, 0x4524, 0xED26,
- 0xED27, 0xED28, 0xED29, 0x385D, 0xED2A, 0x736A, 0xED2B, 0xED2C,
- 0, 0xED2D, 0xED2E, 0xED2F, 0, 0, 0, 0xED30,
- 0x414D, 0x736B, 0xED31, 0, 0, 0, 0xED32, 0,
- 0, 0, 0xED33, 0xED34, 0x736C, 0, 0, 0xED35,
- 0, 0xED36, 0xED37, 0, 0xED38, 0, 0, 0xED39,
- 0, 0xED3A, 0xED3B, 0x4921, 0xED3C, 0xED3D, 0x736D, 0xED3E,
-};
-static const unsigned short utf8_to_euc_E9BC_x0213[] = {
- 0, 0, 0xFE5F, 0xFE61, 0, 0, 0, 0x7367,
- 0x7368, 0xED25, 0, 0, 0, 0, 0x4524, 0xED26,
- 0x7E73, 0xED28, 0xED29, 0x385D, 0xED2A, 0x736A, 0xED2B, 0xFE62,
- 0, 0xFE63, 0xED2E, 0xED2F, 0, 0, 0, 0xED30,
- 0x414D, 0x736B, 0xED31, 0, 0, 0, 0xED32, 0,
- 0, 0, 0xED33, 0xED34, 0x736C, 0, 0, 0xFE64,
- 0, 0xED36, 0xED37, 0, 0xED38, 0, 0, 0xFE65,
- 0, 0x7E74, 0xFE66, 0x4921, 0xED3C, 0xFE67, 0x736D, 0xED3E,
-};
-static const unsigned short utf8_to_euc_E9BD[] = {
- 0, 0xED3F, 0, 0xED40, 0xED41, 0xED42, 0xED43, 0xED44,
- 0, 0, 0x736E, 0x6337, 0, 0, 0x6C5A, 0x706D,
- 0, 0, 0x736F, 0xED45, 0x7370, 0xED46, 0xED47, 0xED48,
- 0xED49, 0, 0xED4A, 0, 0, 0xED4B, 0xED4C, 0x7372,
- 0x7373, 0x7374, 0x4E70, 0x7371, 0, 0, 0x7375, 0x7376,
- 0xED4D, 0xED4E, 0x7378, 0, 0x7377, 0xED4F, 0xED50, 0xED51,
- 0xED52, 0xED53, 0x737A, 0xED54, 0, 0xED55, 0x737B, 0x7379,
- 0, 0, 0xED56, 0, 0, 0xED57, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9BD_x0213[] = {
- 0, 0xFE68, 0, 0xED40, 0xED41, 0xFE69, 0xFE6A, 0xED44,
- 0, 0, 0x736E, 0x6337, 0, 0, 0x6C5A, 0x706D,
- 0, 0, 0x736F, 0xFE6B, 0x7370, 0xFE6C, 0xED47, 0x7E75,
- 0xFE6D, 0, 0xED4A, 0, 0, 0xFE6F, 0xED4C, 0x7372,
- 0x7373, 0x7374, 0x4E70, 0x7371, 0, 0, 0x7375, 0x7376,
- 0xED4D, 0xFE71, 0x7378, 0, 0x7377, 0xFE73, 0xED50, 0xED51,
- 0xFE74, 0xED53, 0x737A, 0xED54, 0, 0xFE75, 0x737B, 0x7379,
- 0, 0, 0xED56, 0, 0, 0xED57, 0, 0,
-};
-static const unsigned short utf8_to_euc_E9BE[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x4E36, 0, 0xED58,
- 0xED59, 0xED5A, 0xED5B, 0, 0xED5C, 0x737C, 0xED5D, 0xED5E,
- 0, 0, 0, 0, 0x737D, 0x6354, 0xED5F, 0,
- 0x737E, 0xED60, 0xED61, 0xED62, 0, 0xED63, 0, 0,
- 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 short utf8_to_euc_E9BE_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x4E36, 0, 0xED58,
- 0x7E76, 0xED5A, 0xED5B, 0, 0x7E77, 0x737C, 0xED5D, 0x7E78,
- 0, 0, 0, 0, 0x737D, 0x6354, 0xED5F, 0,
- 0x737E, 0xED60, 0x7E79, 0xED62, 0, 0xED63, 0, 0,
- 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 short utf8_to_euc_EFA4[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xF445, 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 short utf8_to_euc_EFA4_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x763B, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x742E, 0x754E, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x7B4F, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFA5_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x7649, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFA7[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xF472, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_EFA7_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x7E24, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x7D5D, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_EFA8[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xF434, 0xF437,
- 0xF438, 0xF43D, 0xF444, 0xF447, 0xF448, 0xF44E, 0xF44F, 0xF453,
- 0xF455, 0xF456, 0xF457, 0xF458, 0xF45A, 0xF45B, 0xF45E, 0xF460,
- 0xF462, 0xF463, 0xF465, 0xF469, 0xF46A, 0xF46B, 0xF46D, 0xF46F,
- 0xF470, 0xF473, 0xF477, 0xF478, 0xF479, 0xF47D, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFA8_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2F4B,
- 0x2F57, 0x4F72, 0, 0xAE79, 0x757A, 0x775A, 0x776F, 0,
- 0, 0x793C, 0x793D, 0x7941, 0, 0, 0, 0x7B3A,
- 0xF738, 0xF745, 0x7C2E, 0, 0xF96E, 0, 0x7C6A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2E38, 0x2E49, 0x2E50, 0x2E63, 0x2E68, 0x2E6E, 0x2F2C, 0x2F2F,
- 0x2F36, 0x2F5A, 0x2F5E, 0x4F61, 0x4F62, 0x7450, 0x745C, 0x745E,
-};
-static const unsigned short utf8_to_euc_EFA9_x0213[] = {
- 0x7461, 0x7528, 0x752B, 0x7543, 0x7565, 0x7669, 0x7677, 0x7725,
- 0x7755, 0xF029, 0x7825, 0x7927, 0x7933, 0x7934, 0x7937, 0x7938,
- 0x7939, 0x793B, 0x793F, 0x7940, 0x794D, 0x7951, 0x7964, 0x7A2E,
- 0xF450, 0x7A33, 0x7A3A, 0x7A44, 0x7A58, 0xF574, 0xF575, 0x7B27,
- 0x7B6F, 0x7B79, 0x7C2F, 0x7C30, 0x7C38, 0x7C3D, 0xF969, 0x7C59,
- 0x7D63, 0x7D76, 0x7D7B, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFB9_x0213[] = {
- 0, 0, 0, 0, 0, 0x233E, 0x233D, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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 short utf8_to_euc_EFBC[] = {
- 0, 0x212A, 0xF42A, 0x2174, 0x2170, 0x2173, 0x2175, 0xF429,
- 0x214A, 0x214B, 0x2176, 0x215C, 0x2124, 0x215D, 0x2125, 0x213F,
- 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
- 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
- 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
- 0x2348, 0x2349, 0x234A, 0x234B, 0x234C, 0x234D, 0x234E, 0x234F,
- 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
- 0x2358, 0x2359, 0x235A, 0x214E, 0x2140, 0x214F, 0x2130, 0x2132,
-};
-static const unsigned short utf8_to_euc_EFBC_x0213[] = {
- 0, 0x212A, 0x2230, 0x2174, 0x2170, 0x2173, 0x2175, 0x222F,
- 0x214A, 0x214B, 0x2176, 0x215C, 0x2124, 0x2231, 0x2125, 0x213F,
- 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
- 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
- 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
- 0x2348, 0x2349, 0x234A, 0x234B, 0x234C, 0x234D, 0x234E, 0x234F,
- 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
- 0x2358, 0x2359, 0x235A, 0x214E, 0x2140, 0x214F, 0x2130, 0x2132,
-};
-static const unsigned short utf8_to_euc_EFBD[] = {
- 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
- 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
- 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
- 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0xA237, 0,
- 0, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
- 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
- 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
- 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
-};
-static const unsigned short utf8_to_euc_EFBD_ms[] = {
- 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
- 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
- 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
- 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0x2141, 0,
- 0, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
- 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
- 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
- 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
-};
-static const unsigned short utf8_to_euc_EFBD_x0213[] = {
- 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
- 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
- 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
- 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0x2232, 0x2256,
- 0x2257, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
- 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
- 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
- 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
-};
-static const unsigned short utf8_to_euc_EFBE[] = {
- 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
- 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
- 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
- 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0E5C, 0x0E5D, 0x0E5E, 0x0E5F,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFBF[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2171, 0x2172, 0x224C, 0x2131, 0xA243, 0x216F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short utf8_to_euc_EFBF_x0213[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2131, 0, 0x216F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short *const utf8_to_euc_E1_x0213[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 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_E1B8_x0213, 0, 0, 0,
- 0, utf8_to_euc_E1BD_x0213, 0, 0,
-};
-static const unsigned short *const utf8_to_euc_E2[] = {
- utf8_to_euc_E280, 0, 0, 0,
- utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
- utf8_to_euc_E288, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
- utf8_to_euc_E28C, 0, 0, 0,
- 0, utf8_to_euc_E291, 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,
-};
-static const unsigned short *const utf8_to_euc_E2_ms[] = {
- utf8_to_euc_E280_ms, 0, 0, 0,
- utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
- utf8_to_euc_E288, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
- utf8_to_euc_E28C, 0, 0, 0,
- 0, utf8_to_euc_E291, 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,
-};
-static const unsigned short *const utf8_to_euc_E2_932[] = {
- utf8_to_euc_E280_932, 0, 0, 0,
- utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
- utf8_to_euc_E288_932, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
- utf8_to_euc_E28C, 0, 0, 0,
- 0, utf8_to_euc_E291, 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,
-};
-static 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,
-};
-static const unsigned short *const utf8_to_euc_E2_x0213[] = {
- utf8_to_euc_E280_x0213, utf8_to_euc_E281_x0213, utf8_to_euc_E282_x0213, 0,
- utf8_to_euc_E284_x0213, utf8_to_euc_E285_x0213, utf8_to_euc_E286_x0213, utf8_to_euc_E287_x0213,
- utf8_to_euc_E288_x0213, utf8_to_euc_E289_x0213, utf8_to_euc_E28A_x0213, utf8_to_euc_E28B_x0213,
- utf8_to_euc_E28C_x0213, 0, utf8_to_euc_E28E_x0213, utf8_to_euc_E28F_x0213,
- utf8_to_euc_E290_x0213, utf8_to_euc_E291, 0, utf8_to_euc_E293_x0213,
- utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296_x0213, utf8_to_euc_E297_x0213,
- utf8_to_euc_E298_x0213, utf8_to_euc_E299_x0213, 0, 0,
- utf8_to_euc_E29C_x0213, utf8_to_euc_E29D_x0213, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_E2A4_x0213, 0, utf8_to_euc_E2A6_x0213, utf8_to_euc_E2A7_x0213,
- 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 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,
- utf8_to_euc_E388, 0, utf8_to_euc_E38A, 0,
- utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
-static const unsigned short *const utf8_to_euc_E3_932[] = {
- 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, 0, utf8_to_euc_E38A, 0,
- utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
-static 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,
-};
-static const unsigned short *const utf8_to_euc_E3_x0213[] = {
- utf8_to_euc_E380_x0213, utf8_to_euc_E381, utf8_to_euc_E382_x0213, utf8_to_euc_E383_x0213,
- 0, 0, 0, utf8_to_euc_E387_x0213,
- utf8_to_euc_E388, utf8_to_euc_E389_x0213, utf8_to_euc_E38A_x0213, utf8_to_euc_E38B_x0213,
- utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F_x0213,
- utf8_to_euc_E390_x0213, utf8_to_euc_E391_x0213, utf8_to_euc_E392_x0213, utf8_to_euc_E393_x0213,
- utf8_to_euc_E394_x0213, utf8_to_euc_E395_x0213, utf8_to_euc_E396_x0213, utf8_to_euc_E397_x0213,
- utf8_to_euc_E398_x0213, utf8_to_euc_E399_x0213, utf8_to_euc_E39A_x0213, utf8_to_euc_E39B_x0213,
- 0, utf8_to_euc_E39D_x0213, utf8_to_euc_E39E_x0213, utf8_to_euc_E39F_x0213,
- utf8_to_euc_E3A0_x0213, utf8_to_euc_E3A1_x0213, 0, utf8_to_euc_E3A3_x0213,
- utf8_to_euc_E3A4_x0213, utf8_to_euc_E3A5_x0213, 0, 0,
- 0, utf8_to_euc_E3A9_x0213, 0, utf8_to_euc_E3AB_x0213,
- utf8_to_euc_E3AC_x0213, utf8_to_euc_E3AD_x0213, utf8_to_euc_E3AE_x0213, utf8_to_euc_E3AF_x0213,
- utf8_to_euc_E3B0_x0213, 0, 0, utf8_to_euc_E3B3_x0213,
- utf8_to_euc_E3B4_x0213, utf8_to_euc_E3B5_x0213, utf8_to_euc_E3B6_x0213, utf8_to_euc_E3B7_x0213,
- utf8_to_euc_E3B8_x0213, utf8_to_euc_E3B9_x0213, utf8_to_euc_E3BA_x0213, 0,
- 0, utf8_to_euc_E3BD_x0213, utf8_to_euc_E3BE_x0213, utf8_to_euc_E3BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E4[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_E4B8, utf8_to_euc_E4B9, utf8_to_euc_E4BA, utf8_to_euc_E4BB,
- utf8_to_euc_E4BC, utf8_to_euc_E4BD, utf8_to_euc_E4BE, utf8_to_euc_E4BF,
-};
-static const unsigned short *const utf8_to_euc_E4_x0213[] = {
- utf8_to_euc_E480_x0213, utf8_to_euc_E481_x0213, utf8_to_euc_E482_x0213, 0,
- utf8_to_euc_E484_x0213, utf8_to_euc_E485_x0213, utf8_to_euc_E486_x0213, utf8_to_euc_E487_x0213,
- utf8_to_euc_E488_x0213, utf8_to_euc_E489_x0213, 0, utf8_to_euc_E48B_x0213,
- utf8_to_euc_E48C_x0213, utf8_to_euc_E48D_x0213, 0, utf8_to_euc_E48F_x0213,
- utf8_to_euc_E490_x0213, utf8_to_euc_E491_x0213, utf8_to_euc_E492_x0213, utf8_to_euc_E493_x0213,
- utf8_to_euc_E494_x0213, utf8_to_euc_E495_x0213, utf8_to_euc_E496_x0213, utf8_to_euc_E497_x0213,
- utf8_to_euc_E498_x0213, utf8_to_euc_E499_x0213, utf8_to_euc_E49A_x0213, 0,
- utf8_to_euc_E49C_x0213, utf8_to_euc_E49D_x0213, 0, utf8_to_euc_E49F_x0213,
- utf8_to_euc_E4A0_x0213, utf8_to_euc_E4A1_x0213, utf8_to_euc_E4A2_x0213, 0,
- 0, 0, utf8_to_euc_E4A6_x0213, utf8_to_euc_E4A7_x0213,
- utf8_to_euc_E4A8_x0213, 0, utf8_to_euc_E4AA_x0213, 0,
- utf8_to_euc_E4AC_x0213, 0, 0, utf8_to_euc_E4AF_x0213,
- utf8_to_euc_E4B0_x0213, 0, 0, utf8_to_euc_E4B3_x0213,
- utf8_to_euc_E4B4_x0213, utf8_to_euc_E4B5_x0213, 0, 0,
- utf8_to_euc_E4B8_x0213, utf8_to_euc_E4B9_x0213, utf8_to_euc_E4BA_x0213, utf8_to_euc_E4BB_x0213,
- utf8_to_euc_E4BC_x0213, utf8_to_euc_E4BD_x0213, utf8_to_euc_E4BE_x0213, utf8_to_euc_E4BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E5[] = {
- utf8_to_euc_E580, utf8_to_euc_E581, utf8_to_euc_E582, utf8_to_euc_E583,
- utf8_to_euc_E584, utf8_to_euc_E585, utf8_to_euc_E586, utf8_to_euc_E587,
- utf8_to_euc_E588, utf8_to_euc_E589, utf8_to_euc_E58A, utf8_to_euc_E58B,
- utf8_to_euc_E58C, utf8_to_euc_E58D, utf8_to_euc_E58E, utf8_to_euc_E58F,
- utf8_to_euc_E590, utf8_to_euc_E591, utf8_to_euc_E592, utf8_to_euc_E593,
- utf8_to_euc_E594, utf8_to_euc_E595, utf8_to_euc_E596, utf8_to_euc_E597,
- utf8_to_euc_E598, utf8_to_euc_E599, utf8_to_euc_E59A, utf8_to_euc_E59B,
- utf8_to_euc_E59C, utf8_to_euc_E59D, utf8_to_euc_E59E, utf8_to_euc_E59F,
- utf8_to_euc_E5A0, utf8_to_euc_E5A1, utf8_to_euc_E5A2, utf8_to_euc_E5A3,
- utf8_to_euc_E5A4, utf8_to_euc_E5A5, utf8_to_euc_E5A6, utf8_to_euc_E5A7,
- utf8_to_euc_E5A8, utf8_to_euc_E5A9, utf8_to_euc_E5AA, utf8_to_euc_E5AB,
- utf8_to_euc_E5AC, utf8_to_euc_E5AD, utf8_to_euc_E5AE, utf8_to_euc_E5AF,
- utf8_to_euc_E5B0, utf8_to_euc_E5B1, utf8_to_euc_E5B2, utf8_to_euc_E5B3,
- utf8_to_euc_E5B4, utf8_to_euc_E5B5, utf8_to_euc_E5B6, utf8_to_euc_E5B7,
- utf8_to_euc_E5B8, utf8_to_euc_E5B9, utf8_to_euc_E5BA, utf8_to_euc_E5BB,
- utf8_to_euc_E5BC, utf8_to_euc_E5BD, utf8_to_euc_E5BE, utf8_to_euc_E5BF,
-};
-static const unsigned short *const utf8_to_euc_E5_x0213[] = {
- utf8_to_euc_E580_x0213, utf8_to_euc_E581_x0213, utf8_to_euc_E582_x0213, utf8_to_euc_E583_x0213,
- utf8_to_euc_E584_x0213, utf8_to_euc_E585_x0213, utf8_to_euc_E586_x0213, utf8_to_euc_E587_x0213,
- utf8_to_euc_E588_x0213, utf8_to_euc_E589_x0213, utf8_to_euc_E58A_x0213, utf8_to_euc_E58B_x0213,
- utf8_to_euc_E58C_x0213, utf8_to_euc_E58D_x0213, utf8_to_euc_E58E_x0213, utf8_to_euc_E58F_x0213,
- utf8_to_euc_E590_x0213, utf8_to_euc_E591_x0213, utf8_to_euc_E592_x0213, utf8_to_euc_E593_x0213,
- utf8_to_euc_E594_x0213, utf8_to_euc_E595_x0213, utf8_to_euc_E596_x0213, utf8_to_euc_E597_x0213,
- utf8_to_euc_E598_x0213, utf8_to_euc_E599_x0213, utf8_to_euc_E59A_x0213, utf8_to_euc_E59B_x0213,
- utf8_to_euc_E59C_x0213, utf8_to_euc_E59D_x0213, utf8_to_euc_E59E_x0213, utf8_to_euc_E59F_x0213,
- utf8_to_euc_E5A0_x0213, utf8_to_euc_E5A1_x0213, utf8_to_euc_E5A2_x0213, utf8_to_euc_E5A3_x0213,
- utf8_to_euc_E5A4_x0213, utf8_to_euc_E5A5_x0213, utf8_to_euc_E5A6_x0213, utf8_to_euc_E5A7_x0213,
- utf8_to_euc_E5A8_x0213, utf8_to_euc_E5A9_x0213, utf8_to_euc_E5AA_x0213, utf8_to_euc_E5AB_x0213,
- utf8_to_euc_E5AC_x0213, utf8_to_euc_E5AD_x0213, utf8_to_euc_E5AE_x0213, utf8_to_euc_E5AF_x0213,
- utf8_to_euc_E5B0_x0213, utf8_to_euc_E5B1_x0213, utf8_to_euc_E5B2_x0213, utf8_to_euc_E5B3_x0213,
- utf8_to_euc_E5B4_x0213, utf8_to_euc_E5B5_x0213, utf8_to_euc_E5B6_x0213, utf8_to_euc_E5B7_x0213,
- utf8_to_euc_E5B8_x0213, utf8_to_euc_E5B9_x0213, utf8_to_euc_E5BA_x0213, utf8_to_euc_E5BB_x0213,
- utf8_to_euc_E5BC_x0213, utf8_to_euc_E5BD_x0213, utf8_to_euc_E5BE_x0213, utf8_to_euc_E5BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E6[] = {
- utf8_to_euc_E680, utf8_to_euc_E681, utf8_to_euc_E682, utf8_to_euc_E683,
- utf8_to_euc_E684, utf8_to_euc_E685, utf8_to_euc_E686, utf8_to_euc_E687,
- utf8_to_euc_E688, utf8_to_euc_E689, utf8_to_euc_E68A, utf8_to_euc_E68B,
- utf8_to_euc_E68C, utf8_to_euc_E68D, utf8_to_euc_E68E, utf8_to_euc_E68F,
- utf8_to_euc_E690, utf8_to_euc_E691, utf8_to_euc_E692, utf8_to_euc_E693,
- utf8_to_euc_E694, utf8_to_euc_E695, utf8_to_euc_E696, utf8_to_euc_E697,
- utf8_to_euc_E698, utf8_to_euc_E699, utf8_to_euc_E69A, utf8_to_euc_E69B,
- utf8_to_euc_E69C, utf8_to_euc_E69D, utf8_to_euc_E69E, utf8_to_euc_E69F,
- utf8_to_euc_E6A0, utf8_to_euc_E6A1, utf8_to_euc_E6A2, utf8_to_euc_E6A3,
- utf8_to_euc_E6A4, utf8_to_euc_E6A5, utf8_to_euc_E6A6, utf8_to_euc_E6A7,
- utf8_to_euc_E6A8, utf8_to_euc_E6A9, utf8_to_euc_E6AA, utf8_to_euc_E6AB,
- utf8_to_euc_E6AC, utf8_to_euc_E6AD, utf8_to_euc_E6AE, utf8_to_euc_E6AF,
- utf8_to_euc_E6B0, utf8_to_euc_E6B1, utf8_to_euc_E6B2, utf8_to_euc_E6B3,
- utf8_to_euc_E6B4, utf8_to_euc_E6B5, utf8_to_euc_E6B6, utf8_to_euc_E6B7,
- utf8_to_euc_E6B8, utf8_to_euc_E6B9, utf8_to_euc_E6BA, utf8_to_euc_E6BB,
- utf8_to_euc_E6BC, utf8_to_euc_E6BD, utf8_to_euc_E6BE, utf8_to_euc_E6BF,
-};
-static const unsigned short *const utf8_to_euc_E6_x0213[] = {
- utf8_to_euc_E680_x0213, utf8_to_euc_E681_x0213, utf8_to_euc_E682_x0213, utf8_to_euc_E683_x0213,
- utf8_to_euc_E684_x0213, utf8_to_euc_E685_x0213, utf8_to_euc_E686_x0213, utf8_to_euc_E687_x0213,
- utf8_to_euc_E688_x0213, utf8_to_euc_E689_x0213, utf8_to_euc_E68A_x0213, utf8_to_euc_E68B_x0213,
- utf8_to_euc_E68C_x0213, utf8_to_euc_E68D_x0213, utf8_to_euc_E68E_x0213, utf8_to_euc_E68F_x0213,
- utf8_to_euc_E690_x0213, utf8_to_euc_E691_x0213, utf8_to_euc_E692_x0213, utf8_to_euc_E693_x0213,
- utf8_to_euc_E694_x0213, utf8_to_euc_E695_x0213, utf8_to_euc_E696_x0213, utf8_to_euc_E697_x0213,
- utf8_to_euc_E698_x0213, utf8_to_euc_E699_x0213, utf8_to_euc_E69A_x0213, utf8_to_euc_E69B_x0213,
- utf8_to_euc_E69C_x0213, utf8_to_euc_E69D_x0213, utf8_to_euc_E69E_x0213, utf8_to_euc_E69F_x0213,
- utf8_to_euc_E6A0_x0213, utf8_to_euc_E6A1_x0213, utf8_to_euc_E6A2_x0213, utf8_to_euc_E6A3_x0213,
- utf8_to_euc_E6A4_x0213, utf8_to_euc_E6A5_x0213, utf8_to_euc_E6A6_x0213, utf8_to_euc_E6A7_x0213,
- utf8_to_euc_E6A8_x0213, utf8_to_euc_E6A9_x0213, utf8_to_euc_E6AA_x0213, utf8_to_euc_E6AB_x0213,
- utf8_to_euc_E6AC_x0213, utf8_to_euc_E6AD_x0213, utf8_to_euc_E6AE_x0213, utf8_to_euc_E6AF_x0213,
- utf8_to_euc_E6B0_x0213, utf8_to_euc_E6B1_x0213, utf8_to_euc_E6B2_x0213, utf8_to_euc_E6B3_x0213,
- utf8_to_euc_E6B4_x0213, utf8_to_euc_E6B5_x0213, utf8_to_euc_E6B6_x0213, utf8_to_euc_E6B7_x0213,
- utf8_to_euc_E6B8_x0213, utf8_to_euc_E6B9_x0213, utf8_to_euc_E6BA_x0213, utf8_to_euc_E6BB_x0213,
- utf8_to_euc_E6BC_x0213, utf8_to_euc_E6BD_x0213, utf8_to_euc_E6BE_x0213, utf8_to_euc_E6BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E7[] = {
- utf8_to_euc_E780, utf8_to_euc_E781, utf8_to_euc_E782, utf8_to_euc_E783,
- utf8_to_euc_E784, utf8_to_euc_E785, utf8_to_euc_E786, utf8_to_euc_E787,
- utf8_to_euc_E788, utf8_to_euc_E789, utf8_to_euc_E78A, utf8_to_euc_E78B,
- utf8_to_euc_E78C, utf8_to_euc_E78D, utf8_to_euc_E78E, utf8_to_euc_E78F,
- utf8_to_euc_E790, utf8_to_euc_E791, utf8_to_euc_E792, utf8_to_euc_E793,
- utf8_to_euc_E794, utf8_to_euc_E795, utf8_to_euc_E796, utf8_to_euc_E797,
- utf8_to_euc_E798, utf8_to_euc_E799, utf8_to_euc_E79A, utf8_to_euc_E79B,
- utf8_to_euc_E79C, utf8_to_euc_E79D, utf8_to_euc_E79E, utf8_to_euc_E79F,
- utf8_to_euc_E7A0, utf8_to_euc_E7A1, utf8_to_euc_E7A2, utf8_to_euc_E7A3,
- utf8_to_euc_E7A4, utf8_to_euc_E7A5, utf8_to_euc_E7A6, utf8_to_euc_E7A7,
- utf8_to_euc_E7A8, utf8_to_euc_E7A9, utf8_to_euc_E7AA, utf8_to_euc_E7AB,
- utf8_to_euc_E7AC, utf8_to_euc_E7AD, utf8_to_euc_E7AE, utf8_to_euc_E7AF,
- utf8_to_euc_E7B0, utf8_to_euc_E7B1, utf8_to_euc_E7B2, utf8_to_euc_E7B3,
- utf8_to_euc_E7B4, utf8_to_euc_E7B5, utf8_to_euc_E7B6, utf8_to_euc_E7B7,
- utf8_to_euc_E7B8, utf8_to_euc_E7B9, utf8_to_euc_E7BA, 0,
- utf8_to_euc_E7BC, utf8_to_euc_E7BD, utf8_to_euc_E7BE, utf8_to_euc_E7BF,
-};
-static const unsigned short *const utf8_to_euc_E7_x0213[] = {
- utf8_to_euc_E780_x0213, utf8_to_euc_E781_x0213, utf8_to_euc_E782_x0213, utf8_to_euc_E783_x0213,
- utf8_to_euc_E784_x0213, utf8_to_euc_E785_x0213, utf8_to_euc_E786_x0213, utf8_to_euc_E787_x0213,
- utf8_to_euc_E788_x0213, utf8_to_euc_E789_x0213, utf8_to_euc_E78A_x0213, utf8_to_euc_E78B_x0213,
- utf8_to_euc_E78C_x0213, utf8_to_euc_E78D_x0213, utf8_to_euc_E78E_x0213, utf8_to_euc_E78F_x0213,
- utf8_to_euc_E790_x0213, utf8_to_euc_E791_x0213, utf8_to_euc_E792_x0213, utf8_to_euc_E793_x0213,
- utf8_to_euc_E794_x0213, utf8_to_euc_E795_x0213, utf8_to_euc_E796_x0213, utf8_to_euc_E797_x0213,
- utf8_to_euc_E798_x0213, utf8_to_euc_E799_x0213, utf8_to_euc_E79A_x0213, utf8_to_euc_E79B_x0213,
- utf8_to_euc_E79C_x0213, utf8_to_euc_E79D_x0213, utf8_to_euc_E79E_x0213, utf8_to_euc_E79F_x0213,
- utf8_to_euc_E7A0_x0213, utf8_to_euc_E7A1_x0213, utf8_to_euc_E7A2_x0213, utf8_to_euc_E7A3_x0213,
- utf8_to_euc_E7A4_x0213, utf8_to_euc_E7A5_x0213, utf8_to_euc_E7A6_x0213, utf8_to_euc_E7A7_x0213,
- utf8_to_euc_E7A8_x0213, utf8_to_euc_E7A9_x0213, utf8_to_euc_E7AA_x0213, utf8_to_euc_E7AB_x0213,
- utf8_to_euc_E7AC_x0213, utf8_to_euc_E7AD_x0213, utf8_to_euc_E7AE_x0213, utf8_to_euc_E7AF_x0213,
- utf8_to_euc_E7B0_x0213, utf8_to_euc_E7B1_x0213, utf8_to_euc_E7B2_x0213, utf8_to_euc_E7B3_x0213,
- utf8_to_euc_E7B4_x0213, utf8_to_euc_E7B5_x0213, utf8_to_euc_E7B6_x0213, utf8_to_euc_E7B7_x0213,
- utf8_to_euc_E7B8_x0213, utf8_to_euc_E7B9_x0213, utf8_to_euc_E7BA_x0213, 0,
- utf8_to_euc_E7BC_x0213, utf8_to_euc_E7BD_x0213, utf8_to_euc_E7BE_x0213, utf8_to_euc_E7BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E8[] = {
- utf8_to_euc_E880, utf8_to_euc_E881, utf8_to_euc_E882, utf8_to_euc_E883,
- utf8_to_euc_E884, utf8_to_euc_E885, utf8_to_euc_E886, utf8_to_euc_E887,
- utf8_to_euc_E888, utf8_to_euc_E889, utf8_to_euc_E88A, utf8_to_euc_E88B,
- utf8_to_euc_E88C, utf8_to_euc_E88D, utf8_to_euc_E88E, utf8_to_euc_E88F,
- utf8_to_euc_E890, utf8_to_euc_E891, utf8_to_euc_E892, utf8_to_euc_E893,
- utf8_to_euc_E894, utf8_to_euc_E895, utf8_to_euc_E896, utf8_to_euc_E897,
- utf8_to_euc_E898, utf8_to_euc_E899, utf8_to_euc_E89A, utf8_to_euc_E89B,
- utf8_to_euc_E89C, utf8_to_euc_E89D, utf8_to_euc_E89E, utf8_to_euc_E89F,
- utf8_to_euc_E8A0, utf8_to_euc_E8A1, utf8_to_euc_E8A2, utf8_to_euc_E8A3,
- utf8_to_euc_E8A4, utf8_to_euc_E8A5, utf8_to_euc_E8A6, utf8_to_euc_E8A7,
- utf8_to_euc_E8A8, utf8_to_euc_E8A9, utf8_to_euc_E8AA, utf8_to_euc_E8AB,
- utf8_to_euc_E8AC, utf8_to_euc_E8AD, utf8_to_euc_E8AE, 0,
- utf8_to_euc_E8B0, utf8_to_euc_E8B1, utf8_to_euc_E8B2, utf8_to_euc_E8B3,
- utf8_to_euc_E8B4, utf8_to_euc_E8B5, utf8_to_euc_E8B6, utf8_to_euc_E8B7,
- utf8_to_euc_E8B8, utf8_to_euc_E8B9, utf8_to_euc_E8BA, utf8_to_euc_E8BB,
- utf8_to_euc_E8BC, utf8_to_euc_E8BD, utf8_to_euc_E8BE, utf8_to_euc_E8BF,
-};
-static const unsigned short *const utf8_to_euc_E8_x0213[] = {
- utf8_to_euc_E880_x0213, utf8_to_euc_E881_x0213, utf8_to_euc_E882_x0213, utf8_to_euc_E883_x0213,
- utf8_to_euc_E884_x0213, utf8_to_euc_E885_x0213, utf8_to_euc_E886_x0213, utf8_to_euc_E887_x0213,
- utf8_to_euc_E888_x0213, utf8_to_euc_E889_x0213, utf8_to_euc_E88A_x0213, utf8_to_euc_E88B_x0213,
- utf8_to_euc_E88C_x0213, utf8_to_euc_E88D_x0213, utf8_to_euc_E88E_x0213, utf8_to_euc_E88F_x0213,
- utf8_to_euc_E890_x0213, utf8_to_euc_E891_x0213, utf8_to_euc_E892_x0213, utf8_to_euc_E893_x0213,
- utf8_to_euc_E894_x0213, utf8_to_euc_E895_x0213, utf8_to_euc_E896_x0213, utf8_to_euc_E897_x0213,
- utf8_to_euc_E898_x0213, utf8_to_euc_E899_x0213, utf8_to_euc_E89A_x0213, utf8_to_euc_E89B_x0213,
- utf8_to_euc_E89C_x0213, utf8_to_euc_E89D_x0213, utf8_to_euc_E89E_x0213, utf8_to_euc_E89F_x0213,
- utf8_to_euc_E8A0_x0213, utf8_to_euc_E8A1_x0213, utf8_to_euc_E8A2_x0213, utf8_to_euc_E8A3_x0213,
- utf8_to_euc_E8A4_x0213, utf8_to_euc_E8A5_x0213, utf8_to_euc_E8A6_x0213, utf8_to_euc_E8A7_x0213,
- utf8_to_euc_E8A8_x0213, utf8_to_euc_E8A9_x0213, utf8_to_euc_E8AA_x0213, utf8_to_euc_E8AB_x0213,
- utf8_to_euc_E8AC_x0213, utf8_to_euc_E8AD_x0213, utf8_to_euc_E8AE_x0213, 0,
- utf8_to_euc_E8B0_x0213, utf8_to_euc_E8B1_x0213, utf8_to_euc_E8B2_x0213, utf8_to_euc_E8B3_x0213,
- utf8_to_euc_E8B4_x0213, utf8_to_euc_E8B5_x0213, utf8_to_euc_E8B6_x0213, utf8_to_euc_E8B7_x0213,
- utf8_to_euc_E8B8_x0213, utf8_to_euc_E8B9_x0213, utf8_to_euc_E8BA_x0213, utf8_to_euc_E8BB_x0213,
- utf8_to_euc_E8BC_x0213, utf8_to_euc_E8BD_x0213, utf8_to_euc_E8BE_x0213, utf8_to_euc_E8BF_x0213,
-};
-static const unsigned short *const utf8_to_euc_E9[] = {
- utf8_to_euc_E980, utf8_to_euc_E981, utf8_to_euc_E982, utf8_to_euc_E983,
- utf8_to_euc_E984, utf8_to_euc_E985, utf8_to_euc_E986, utf8_to_euc_E987,
- utf8_to_euc_E988, utf8_to_euc_E989, utf8_to_euc_E98A, utf8_to_euc_E98B,
- utf8_to_euc_E98C, utf8_to_euc_E98D, utf8_to_euc_E98E, utf8_to_euc_E98F,
- utf8_to_euc_E990, utf8_to_euc_E991, utf8_to_euc_E992, 0,
- 0, utf8_to_euc_E995, utf8_to_euc_E996, utf8_to_euc_E997,
- utf8_to_euc_E998, utf8_to_euc_E999, utf8_to_euc_E99A, utf8_to_euc_E99B,
- utf8_to_euc_E99C, utf8_to_euc_E99D, utf8_to_euc_E99E, utf8_to_euc_E99F,
- utf8_to_euc_E9A0, utf8_to_euc_E9A1, utf8_to_euc_E9A2, utf8_to_euc_E9A3,
- utf8_to_euc_E9A4, utf8_to_euc_E9A5, utf8_to_euc_E9A6, utf8_to_euc_E9A7,
- utf8_to_euc_E9A8, utf8_to_euc_E9A9, utf8_to_euc_E9AA, utf8_to_euc_E9AB,
- utf8_to_euc_E9AC, utf8_to_euc_E9AD, utf8_to_euc_E9AE, utf8_to_euc_E9AF,
- utf8_to_euc_E9B0, utf8_to_euc_E9B1, 0, utf8_to_euc_E9B3,
- utf8_to_euc_E9B4, utf8_to_euc_E9B5, utf8_to_euc_E9B6, utf8_to_euc_E9B7,
- utf8_to_euc_E9B8, utf8_to_euc_E9B9, utf8_to_euc_E9BA, utf8_to_euc_E9BB,
- utf8_to_euc_E9BC, utf8_to_euc_E9BD, utf8_to_euc_E9BE, 0,
-};
-static const unsigned short *const utf8_to_euc_E9_x0213[] = {
- utf8_to_euc_E980_x0213, utf8_to_euc_E981_x0213, utf8_to_euc_E982_x0213, utf8_to_euc_E983_x0213,
- utf8_to_euc_E984_x0213, utf8_to_euc_E985_x0213, utf8_to_euc_E986_x0213, utf8_to_euc_E987_x0213,
- utf8_to_euc_E988_x0213, utf8_to_euc_E989_x0213, utf8_to_euc_E98A_x0213, utf8_to_euc_E98B_x0213,
- utf8_to_euc_E98C_x0213, utf8_to_euc_E98D_x0213, utf8_to_euc_E98E_x0213, utf8_to_euc_E98F_x0213,
- utf8_to_euc_E990_x0213, utf8_to_euc_E991_x0213, utf8_to_euc_E992, 0,
- 0, utf8_to_euc_E995_x0213, utf8_to_euc_E996_x0213, utf8_to_euc_E997_x0213,
- utf8_to_euc_E998_x0213, utf8_to_euc_E999_x0213, utf8_to_euc_E99A_x0213, utf8_to_euc_E99B_x0213,
- utf8_to_euc_E99C_x0213, utf8_to_euc_E99D_x0213, utf8_to_euc_E99E_x0213, utf8_to_euc_E99F_x0213,
- utf8_to_euc_E9A0_x0213, utf8_to_euc_E9A1_x0213, utf8_to_euc_E9A2_x0213, utf8_to_euc_E9A3_x0213,
- utf8_to_euc_E9A4_x0213, utf8_to_euc_E9A5_x0213, utf8_to_euc_E9A6_x0213, utf8_to_euc_E9A7_x0213,
- utf8_to_euc_E9A8_x0213, utf8_to_euc_E9A9_x0213, utf8_to_euc_E9AA_x0213, utf8_to_euc_E9AB_x0213,
- utf8_to_euc_E9AC_x0213, utf8_to_euc_E9AD_x0213, utf8_to_euc_E9AE_x0213, utf8_to_euc_E9AF_x0213,
- utf8_to_euc_E9B0_x0213, utf8_to_euc_E9B1_x0213, 0, utf8_to_euc_E9B3_x0213,
- utf8_to_euc_E9B4_x0213, utf8_to_euc_E9B5_x0213, utf8_to_euc_E9B6_x0213, utf8_to_euc_E9B7_x0213,
- utf8_to_euc_E9B8_x0213, utf8_to_euc_E9B9_x0213, utf8_to_euc_E9BA_x0213, utf8_to_euc_E9BB_x0213,
- utf8_to_euc_E9BC_x0213, utf8_to_euc_E9BD_x0213, utf8_to_euc_E9BE_x0213, 0,
-};
-static const unsigned short *const utf8_to_euc_EF[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_EFA4, 0, 0, utf8_to_euc_EFA7,
- utf8_to_euc_EFA8, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_EFBC, utf8_to_euc_EFBD, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
-};
-static const unsigned short *const utf8_to_euc_EF_ms[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_EFA4, 0, 0, utf8_to_euc_EFA7,
- utf8_to_euc_EFA8, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_EFBC, utf8_to_euc_EFBD_ms, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
-};
-static const unsigned short *const utf8_to_euc_EF_x0213[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- utf8_to_euc_EFA4_x0213, utf8_to_euc_EFA5_x0213, 0, utf8_to_euc_EFA7_x0213,
- utf8_to_euc_EFA8_x0213, utf8_to_euc_EFA9_x0213, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, utf8_to_euc_EFB9_x0213, 0, 0,
- utf8_to_euc_EFBC_x0213, utf8_to_euc_EFBD_x0213, utf8_to_euc_EFBE, utf8_to_euc_EFBF_x0213,
-};
-const unsigned short *const utf8_to_euc_2bytes[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, utf8_to_euc_C2, utf8_to_euc_C3,
- 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 utf8_to_euc_2bytes_ms[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 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_ms, 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 utf8_to_euc_2bytes_932[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 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_932, utf8_to_euc_C3_932,
- 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 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 utf8_to_euc_2bytes_x0213[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 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_x0213, utf8_to_euc_C3_x0213,
- utf8_to_euc_C4_x0213, utf8_to_euc_C5_x0213, utf8_to_euc_C6_x0213, utf8_to_euc_C7_x0213,
- 0, utf8_to_euc_C9_x0213, utf8_to_euc_CA_x0213, utf8_to_euc_CB_x0213,
- utf8_to_euc_CC_x0213, utf8_to_euc_CD_x0213, utf8_to_euc_CE, utf8_to_euc_CF_x0213,
- 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,
- utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
- 0, 0, 0, utf8_to_euc_EF,
-};
-const unsigned short *const *const utf8_to_euc_3bytes_ms[] = {
- 0, 0, utf8_to_euc_E2_ms, utf8_to_euc_E3,
- utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
- utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
- 0, 0, 0, utf8_to_euc_EF_ms,
-};
-const unsigned short *const *const utf8_to_euc_3bytes_932[] = {
- 0, 0, utf8_to_euc_E2_932, utf8_to_euc_E3_932,
- 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,
-};
-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,
-};
-const unsigned short *const *const utf8_to_euc_3bytes_x0213[] = {
- 0, utf8_to_euc_E1_x0213, utf8_to_euc_E2_x0213, utf8_to_euc_E3_x0213,
- utf8_to_euc_E4_x0213, utf8_to_euc_E5_x0213, utf8_to_euc_E6_x0213, utf8_to_euc_E7_x0213,
- utf8_to_euc_E8_x0213, utf8_to_euc_E9_x0213, 0, 0,
- 0, 0, 0, utf8_to_euc_EF_x0213,
-};
-
-#ifdef UNICODE_NORMALIZATION
-
-/* Normalization Table by Apple */
-/* http://developer.apple.com/technotes/tn/tn1150table.html */
-
-const struct normalization_pair normalization_table[] = {
- {{0xcd,0xbe}, {0x3b}},
- {{0xc3,0x80}, {0x41,0xcc,0x80,0x00}},
- {{0xc3,0x81}, {0x41,0xcc,0x81}},
- {{0xc3,0x82}, {0x41,0xcc,0x82}},
- {{0xe1,0xba,0xa6}, {0x41,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xba,0xa4}, {0x41,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xba,0xaa}, {0x41,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xba,0xa8}, {0x41,0xcc,0x82,0xcc,0x89}},
- {{0xc3,0x83}, {0x41,0xcc,0x83}},
- {{0xc4,0x80}, {0x41,0xcc,0x84}},
- {{0xc4,0x82}, {0x41,0xcc,0x86}},
- {{0xe1,0xba,0xb0}, {0x41,0xcc,0x86,0xcc,0x80}},
- {{0xe1,0xba,0xae}, {0x41,0xcc,0x86,0xcc,0x81}},
- {{0xe1,0xba,0xb4}, {0x41,0xcc,0x86,0xcc,0x83}},
- {{0xe1,0xba,0xb2}, {0x41,0xcc,0x86,0xcc,0x89}},
- {{0xc7,0xa0}, {0x41,0xcc,0x87,0xcc,0x84}},
- {{0xc3,0x84}, {0x41,0xcc,0x88}},
- {{0xc7,0x9e}, {0x41,0xcc,0x88,0xcc,0x84}},
- {{0xe1,0xba,0xa2}, {0x41,0xcc,0x89}},
- {{0xc3,0x85}, {0x41,0xcc,0x8a}},
- {{0xc7,0xba}, {0x41,0xcc,0x8a,0xcc,0x81}},
- {{0xc7,0x8d}, {0x41,0xcc,0x8c}},
- {{0xc8,0x80}, {0x41,0xcc,0x8f}},
- {{0xc8,0x82}, {0x41,0xcc,0x91}},
- {{0xe1,0xba,0xa0}, {0x41,0xcc,0xa3}},
- {{0xe1,0xba,0xac}, {0x41,0xcc,0xa3,0xcc,0x82}},
- {{0xe1,0xba,0xb6}, {0x41,0xcc,0xa3,0xcc,0x86}},
- {{0xe1,0xb8,0x80}, {0x41,0xcc,0xa5}},
- {{0xc4,0x84}, {0x41,0xcc,0xa8}},
- {{0xe1,0xb8,0x82}, {0x42,0xcc,0x87}},
- {{0xe1,0xb8,0x84}, {0x42,0xcc,0xa3}},
- {{0xe1,0xb8,0x86}, {0x42,0xcc,0xb1}},
- {{0xc4,0x86}, {0x43,0xcc,0x81}},
- {{0xc4,0x88}, {0x43,0xcc,0x82}},
- {{0xc4,0x8a}, {0x43,0xcc,0x87}},
- {{0xc4,0x8c}, {0x43,0xcc,0x8c}},
- {{0xc3,0x87}, {0x43,0xcc,0xa7}},
- {{0xe1,0xb8,0x88}, {0x43,0xcc,0xa7,0xcc,0x81}},
- {{0xe1,0xb8,0x8a}, {0x44,0xcc,0x87}},
- {{0xc4,0x8e}, {0x44,0xcc,0x8c}},
- {{0xe1,0xb8,0x8c}, {0x44,0xcc,0xa3}},
- {{0xe1,0xb8,0x90}, {0x44,0xcc,0xa7}},
- {{0xe1,0xb8,0x92}, {0x44,0xcc,0xad}},
- {{0xe1,0xb8,0x8e}, {0x44,0xcc,0xb1}},
- {{0xc3,0x88}, {0x45,0xcc,0x80}},
- {{0xc3,0x89}, {0x45,0xcc,0x81}},
- {{0xc3,0x8a}, {0x45,0xcc,0x82}},
- {{0xe1,0xbb,0x80}, {0x45,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xba,0xbe}, {0x45,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xbb,0x84}, {0x45,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xbb,0x82}, {0x45,0xcc,0x82,0xcc,0x89}},
- {{0xe1,0xba,0xbc}, {0x45,0xcc,0x83}},
- {{0xc4,0x92}, {0x45,0xcc,0x84}},
- {{0xe1,0xb8,0x94}, {0x45,0xcc,0x84,0xcc,0x80}},
- {{0xe1,0xb8,0x96}, {0x45,0xcc,0x84,0xcc,0x81}},
- {{0xc4,0x94}, {0x45,0xcc,0x86}},
- {{0xc4,0x96}, {0x45,0xcc,0x87}},
- {{0xc3,0x8b}, {0x45,0xcc,0x88}},
- {{0xe1,0xba,0xba}, {0x45,0xcc,0x89}},
- {{0xc4,0x9a}, {0x45,0xcc,0x8c}},
- {{0xc8,0x84}, {0x45,0xcc,0x8f}},
- {{0xc8,0x86}, {0x45,0xcc,0x91}},
- {{0xe1,0xba,0xb8}, {0x45,0xcc,0xa3}},
- {{0xe1,0xbb,0x86}, {0x45,0xcc,0xa3,0xcc,0x82}},
- {{0xe1,0xb8,0x9c}, {0x45,0xcc,0xa7,0xcc,0x86}},
- {{0xc4,0x98}, {0x45,0xcc,0xa8}},
- {{0xe1,0xb8,0x98}, {0x45,0xcc,0xad}},
- {{0xe1,0xb8,0x9a}, {0x45,0xcc,0xb0}},
- {{0xe1,0xb8,0x9e}, {0x46,0xcc,0x87}},
- {{0xc7,0xb4}, {0x47,0xcc,0x81}},
- {{0xc4,0x9c}, {0x47,0xcc,0x82}},
- {{0xe1,0xb8,0xa0}, {0x47,0xcc,0x84}},
- {{0xc4,0x9e}, {0x47,0xcc,0x86}},
- {{0xc4,0xa0}, {0x47,0xcc,0x87}},
- {{0xc7,0xa6}, {0x47,0xcc,0x8c}},
- {{0xc4,0xa2}, {0x47,0xcc,0xa7}},
- {{0xc4,0xa4}, {0x48,0xcc,0x82}},
- {{0xe1,0xb8,0xa2}, {0x48,0xcc,0x87}},
- {{0xe1,0xb8,0xa6}, {0x48,0xcc,0x88}},
- {{0xe1,0xb8,0xa4}, {0x48,0xcc,0xa3}},
- {{0xe1,0xb8,0xa8}, {0x48,0xcc,0xa7}},
- {{0xe1,0xb8,0xaa}, {0x48,0xcc,0xae}},
- {{0xc3,0x8c}, {0x49,0xcc,0x80}},
- {{0xc3,0x8d}, {0x49,0xcc,0x81}},
- {{0xc3,0x8e}, {0x49,0xcc,0x82}},
- {{0xc4,0xa8}, {0x49,0xcc,0x83}},
- {{0xc4,0xaa}, {0x49,0xcc,0x84}},
- {{0xc4,0xac}, {0x49,0xcc,0x86}},
- {{0xc4,0xb0}, {0x49,0xcc,0x87}},
- {{0xc3,0x8f}, {0x49,0xcc,0x88}},
- {{0xe1,0xb8,0xae}, {0x49,0xcc,0x88,0xcc,0x81}},
- {{0xe1,0xbb,0x88}, {0x49,0xcc,0x89}},
- {{0xc7,0x8f}, {0x49,0xcc,0x8c}},
- {{0xc8,0x88}, {0x49,0xcc,0x8f}},
- {{0xc8,0x8a}, {0x49,0xcc,0x91}},
- {{0xe1,0xbb,0x8a}, {0x49,0xcc,0xa3}},
- {{0xc4,0xae}, {0x49,0xcc,0xa8}},
- {{0xe1,0xb8,0xac}, {0x49,0xcc,0xb0}},
- {{0xc4,0xb4}, {0x4a,0xcc,0x82}},
- {{0xe1,0xb8,0xb0}, {0x4b,0xcc,0x81}},
- {{0xc7,0xa8}, {0x4b,0xcc,0x8c}},
- {{0xe1,0xb8,0xb2}, {0x4b,0xcc,0xa3}},
- {{0xc4,0xb6}, {0x4b,0xcc,0xa7}},
- {{0xe1,0xb8,0xb4}, {0x4b,0xcc,0xb1}},
- {{0xc4,0xb9}, {0x4c,0xcc,0x81}},
- {{0xc4,0xbd}, {0x4c,0xcc,0x8c}},
- {{0xe1,0xb8,0xb6}, {0x4c,0xcc,0xa3}},
- {{0xe1,0xb8,0xb8}, {0x4c,0xcc,0xa3,0xcc,0x84}},
- {{0xc4,0xbb}, {0x4c,0xcc,0xa7}},
- {{0xe1,0xb8,0xbc}, {0x4c,0xcc,0xad}},
- {{0xe1,0xb8,0xba}, {0x4c,0xcc,0xb1}},
- {{0xe1,0xb8,0xbe}, {0x4d,0xcc,0x81}},
- {{0xe1,0xb9,0x80}, {0x4d,0xcc,0x87}},
- {{0xe1,0xb9,0x82}, {0x4d,0xcc,0xa3}},
- {{0xc5,0x83}, {0x4e,0xcc,0x81}},
- {{0xc3,0x91}, {0x4e,0xcc,0x83}},
- {{0xe1,0xb9,0x84}, {0x4e,0xcc,0x87}},
- {{0xc5,0x87}, {0x4e,0xcc,0x8c}},
- {{0xe1,0xb9,0x86}, {0x4e,0xcc,0xa3}},
- {{0xc5,0x85}, {0x4e,0xcc,0xa7}},
- {{0xe1,0xb9,0x8a}, {0x4e,0xcc,0xad}},
- {{0xe1,0xb9,0x88}, {0x4e,0xcc,0xb1}},
- {{0xc3,0x92}, {0x4f,0xcc,0x80}},
- {{0xc3,0x93}, {0x4f,0xcc,0x81}},
- {{0xc3,0x94}, {0x4f,0xcc,0x82}},
- {{0xe1,0xbb,0x92}, {0x4f,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xbb,0x90}, {0x4f,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xbb,0x96}, {0x4f,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xbb,0x94}, {0x4f,0xcc,0x82,0xcc,0x89}},
- {{0xc3,0x95}, {0x4f,0xcc,0x83}},
- {{0xe1,0xb9,0x8c}, {0x4f,0xcc,0x83,0xcc,0x81}},
- {{0xe1,0xb9,0x8e}, {0x4f,0xcc,0x83,0xcc,0x88}},
- {{0xc5,0x8c}, {0x4f,0xcc,0x84}},
- {{0xe1,0xb9,0x90}, {0x4f,0xcc,0x84,0xcc,0x80}},
- {{0xe1,0xb9,0x92}, {0x4f,0xcc,0x84,0xcc,0x81}},
- {{0xc5,0x8e}, {0x4f,0xcc,0x86}},
- {{0xc3,0x96}, {0x4f,0xcc,0x88}},
- {{0xe1,0xbb,0x8e}, {0x4f,0xcc,0x89}},
- {{0xc5,0x90}, {0x4f,0xcc,0x8b}},
- {{0xc7,0x91}, {0x4f,0xcc,0x8c}},
- {{0xc8,0x8c}, {0x4f,0xcc,0x8f}},
- {{0xc8,0x8e}, {0x4f,0xcc,0x91}},
- {{0xc6,0xa0}, {0x4f,0xcc,0x9b}},
- {{0xe1,0xbb,0x9c}, {0x4f,0xcc,0x9b,0xcc,0x80}},
- {{0xe1,0xbb,0x9a}, {0x4f,0xcc,0x9b,0xcc,0x81}},
- {{0xe1,0xbb,0xa0}, {0x4f,0xcc,0x9b,0xcc,0x83}},
- {{0xe1,0xbb,0x9e}, {0x4f,0xcc,0x9b,0xcc,0x89}},
- {{0xe1,0xbb,0xa2}, {0x4f,0xcc,0x9b,0xcc,0xa3}},
- {{0xe1,0xbb,0x8c}, {0x4f,0xcc,0xa3}},
- {{0xe1,0xbb,0x98}, {0x4f,0xcc,0xa3,0xcc,0x82}},
- {{0xc7,0xaa}, {0x4f,0xcc,0xa8}},
- {{0xc7,0xac}, {0x4f,0xcc,0xa8,0xcc,0x84}},
- {{0xe1,0xb9,0x94}, {0x50,0xcc,0x81}},
- {{0xe1,0xb9,0x96}, {0x50,0xcc,0x87}},
- {{0xc5,0x94}, {0x52,0xcc,0x81}},
- {{0xe1,0xb9,0x98}, {0x52,0xcc,0x87}},
- {{0xc5,0x98}, {0x52,0xcc,0x8c}},
- {{0xc8,0x90}, {0x52,0xcc,0x8f}},
- {{0xc8,0x92}, {0x52,0xcc,0x91}},
- {{0xe1,0xb9,0x9a}, {0x52,0xcc,0xa3}},
- {{0xe1,0xb9,0x9c}, {0x52,0xcc,0xa3,0xcc,0x84}},
- {{0xc5,0x96}, {0x52,0xcc,0xa7}},
- {{0xe1,0xb9,0x9e}, {0x52,0xcc,0xb1}},
- {{0xc5,0x9a}, {0x53,0xcc,0x81}},
- {{0xe1,0xb9,0xa4}, {0x53,0xcc,0x81,0xcc,0x87}},
- {{0xc5,0x9c}, {0x53,0xcc,0x82}},
- {{0xe1,0xb9,0xa0}, {0x53,0xcc,0x87}},
- {{0xc5,0xa0}, {0x53,0xcc,0x8c}},
- {{0xe1,0xb9,0xa6}, {0x53,0xcc,0x8c,0xcc,0x87}},
- {{0xe1,0xb9,0xa2}, {0x53,0xcc,0xa3}},
- {{0xe1,0xb9,0xa8}, {0x53,0xcc,0xa3,0xcc,0x87}},
- {{0xc5,0x9e}, {0x53,0xcc,0xa7}},
- {{0xe1,0xb9,0xaa}, {0x54,0xcc,0x87}},
- {{0xc5,0xa4}, {0x54,0xcc,0x8c}},
- {{0xe1,0xb9,0xac}, {0x54,0xcc,0xa3}},
- {{0xc5,0xa2}, {0x54,0xcc,0xa7}},
- {{0xe1,0xb9,0xb0}, {0x54,0xcc,0xad}},
- {{0xe1,0xb9,0xae}, {0x54,0xcc,0xb1}},
- {{0xc3,0x99}, {0x55,0xcc,0x80}},
- {{0xc3,0x9a}, {0x55,0xcc,0x81}},
- {{0xc3,0x9b}, {0x55,0xcc,0x82}},
- {{0xc5,0xa8}, {0x55,0xcc,0x83}},
- {{0xe1,0xb9,0xb8}, {0x55,0xcc,0x83,0xcc,0x81}},
- {{0xc5,0xaa}, {0x55,0xcc,0x84}},
- {{0xe1,0xb9,0xba}, {0x55,0xcc,0x84,0xcc,0x88}},
- {{0xc5,0xac}, {0x55,0xcc,0x86}},
- {{0xc3,0x9c}, {0x55,0xcc,0x88}},
- {{0xc7,0x9b}, {0x55,0xcc,0x88,0xcc,0x80}},
- {{0xc7,0x97}, {0x55,0xcc,0x88,0xcc,0x81}},
- {{0xc7,0x95}, {0x55,0xcc,0x88,0xcc,0x84}},
- {{0xc7,0x99}, {0x55,0xcc,0x88,0xcc,0x8c}},
- {{0xe1,0xbb,0xa6}, {0x55,0xcc,0x89}},
- {{0xc5,0xae}, {0x55,0xcc,0x8a}},
- {{0xc5,0xb0}, {0x55,0xcc,0x8b}},
- {{0xc7,0x93}, {0x55,0xcc,0x8c}},
- {{0xc8,0x94}, {0x55,0xcc,0x8f}},
- {{0xc8,0x96}, {0x55,0xcc,0x91}},
- {{0xc6,0xaf}, {0x55,0xcc,0x9b}},
- {{0xe1,0xbb,0xaa}, {0x55,0xcc,0x9b,0xcc,0x80}},
- {{0xe1,0xbb,0xa8}, {0x55,0xcc,0x9b,0xcc,0x81}},
- {{0xe1,0xbb,0xae}, {0x55,0xcc,0x9b,0xcc,0x83}},
- {{0xe1,0xbb,0xac}, {0x55,0xcc,0x9b,0xcc,0x89}},
- {{0xe1,0xbb,0xb0}, {0x55,0xcc,0x9b,0xcc,0xa3}},
- {{0xe1,0xbb,0xa4}, {0x55,0xcc,0xa3}},
- {{0xe1,0xb9,0xb2}, {0x55,0xcc,0xa4}},
- {{0xc5,0xb2}, {0x55,0xcc,0xa8}},
- {{0xe1,0xb9,0xb6}, {0x55,0xcc,0xad}},
- {{0xe1,0xb9,0xb4}, {0x55,0xcc,0xb0}},
- {{0xe1,0xb9,0xbc}, {0x56,0xcc,0x83}},
- {{0xe1,0xb9,0xbe}, {0x56,0xcc,0xa3}},
- {{0xe1,0xba,0x80}, {0x57,0xcc,0x80}},
- {{0xe1,0xba,0x82}, {0x57,0xcc,0x81}},
- {{0xc5,0xb4}, {0x57,0xcc,0x82}},
- {{0xe1,0xba,0x86}, {0x57,0xcc,0x87}},
- {{0xe1,0xba,0x84}, {0x57,0xcc,0x88}},
- {{0xe1,0xba,0x88}, {0x57,0xcc,0xa3}},
- {{0xe1,0xba,0x8a}, {0x58,0xcc,0x87}},
- {{0xe1,0xba,0x8c}, {0x58,0xcc,0x88}},
- {{0xe1,0xbb,0xb2}, {0x59,0xcc,0x80}},
- {{0xc3,0x9d}, {0x59,0xcc,0x81}},
- {{0xc5,0xb6}, {0x59,0xcc,0x82}},
- {{0xe1,0xbb,0xb8}, {0x59,0xcc,0x83}},
- {{0xe1,0xba,0x8e}, {0x59,0xcc,0x87}},
- {{0xc5,0xb8}, {0x59,0xcc,0x88}},
- {{0xe1,0xbb,0xb6}, {0x59,0xcc,0x89}},
- {{0xe1,0xbb,0xb4}, {0x59,0xcc,0xa3}},
- {{0xc5,0xb9}, {0x5a,0xcc,0x81}},
- {{0xe1,0xba,0x90}, {0x5a,0xcc,0x82}},
- {{0xc5,0xbb}, {0x5a,0xcc,0x87}},
- {{0xc5,0xbd}, {0x5a,0xcc,0x8c}},
- {{0xe1,0xba,0x92}, {0x5a,0xcc,0xa3}},
- {{0xe1,0xba,0x94}, {0x5a,0xcc,0xb1}},
- {{0xe1,0xbf,0xaf}, {0x60}},
- {{0xc3,0xa0}, {0x61,0xcc,0x80}},
- {{0xc3,0xa1}, {0x61,0xcc,0x81}},
- {{0xc3,0xa2}, {0x61,0xcc,0x82}},
- {{0xe1,0xba,0xa7}, {0x61,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xba,0xa5}, {0x61,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xba,0xab}, {0x61,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xba,0xa9}, {0x61,0xcc,0x82,0xcc,0x89}},
- {{0xc3,0xa3}, {0x61,0xcc,0x83}},
- {{0xc4,0x81}, {0x61,0xcc,0x84}},
- {{0xc4,0x83}, {0x61,0xcc,0x86}},
- {{0xe1,0xba,0xb1}, {0x61,0xcc,0x86,0xcc,0x80}},
- {{0xe1,0xba,0xaf}, {0x61,0xcc,0x86,0xcc,0x81}},
- {{0xe1,0xba,0xb5}, {0x61,0xcc,0x86,0xcc,0x83}},
- {{0xe1,0xba,0xb3}, {0x61,0xcc,0x86,0xcc,0x89}},
- {{0xc7,0xa1}, {0x61,0xcc,0x87,0xcc,0x84}},
- {{0xc3,0xa4}, {0x61,0xcc,0x88}},
- {{0xc7,0x9f}, {0x61,0xcc,0x88,0xcc,0x84}},
- {{0xe1,0xba,0xa3}, {0x61,0xcc,0x89}},
- {{0xc3,0xa5}, {0x61,0xcc,0x8a}},
- {{0xc7,0xbb}, {0x61,0xcc,0x8a,0xcc,0x81}},
- {{0xc7,0x8e}, {0x61,0xcc,0x8c}},
- {{0xc8,0x81}, {0x61,0xcc,0x8f}},
- {{0xc8,0x83}, {0x61,0xcc,0x91}},
- {{0xe1,0xba,0xa1}, {0x61,0xcc,0xa3}},
- {{0xe1,0xba,0xad}, {0x61,0xcc,0xa3,0xcc,0x82}},
- {{0xe1,0xba,0xb7}, {0x61,0xcc,0xa3,0xcc,0x86}},
- {{0xe1,0xb8,0x81}, {0x61,0xcc,0xa5}},
- {{0xc4,0x85}, {0x61,0xcc,0xa8}},
- {{0xe1,0xb8,0x83}, {0x62,0xcc,0x87}},
- {{0xe1,0xb8,0x85}, {0x62,0xcc,0xa3}},
- {{0xe1,0xb8,0x87}, {0x62,0xcc,0xb1}},
- {{0xc4,0x87}, {0x63,0xcc,0x81}},
- {{0xc4,0x89}, {0x63,0xcc,0x82}},
- {{0xc4,0x8b}, {0x63,0xcc,0x87}},
- {{0xc4,0x8d}, {0x63,0xcc,0x8c}},
- {{0xc3,0xa7}, {0x63,0xcc,0xa7}},
- {{0xe1,0xb8,0x89}, {0x63,0xcc,0xa7,0xcc,0x81}},
- {{0xe1,0xb8,0x8b}, {0x64,0xcc,0x87}},
- {{0xc4,0x8f}, {0x64,0xcc,0x8c}},
- {{0xe1,0xb8,0x8d}, {0x64,0xcc,0xa3}},
- {{0xe1,0xb8,0x91}, {0x64,0xcc,0xa7}},
- {{0xe1,0xb8,0x93}, {0x64,0xcc,0xad}},
- {{0xe1,0xb8,0x8f}, {0x64,0xcc,0xb1}},
- {{0xc3,0xa8}, {0x65,0xcc,0x80}},
- {{0xc3,0xa9}, {0x65,0xcc,0x81}},
- {{0xc3,0xaa}, {0x65,0xcc,0x82}},
- {{0xe1,0xbb,0x81}, {0x65,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xba,0xbf}, {0x65,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xbb,0x85}, {0x65,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xbb,0x83}, {0x65,0xcc,0x82,0xcc,0x89}},
- {{0xe1,0xba,0xbd}, {0x65,0xcc,0x83}},
- {{0xc4,0x93}, {0x65,0xcc,0x84}},
- {{0xe1,0xb8,0x95}, {0x65,0xcc,0x84,0xcc,0x80}},
- {{0xe1,0xb8,0x97}, {0x65,0xcc,0x84,0xcc,0x81}},
- {{0xc4,0x95}, {0x65,0xcc,0x86}},
- {{0xc4,0x97}, {0x65,0xcc,0x87}},
- {{0xc3,0xab}, {0x65,0xcc,0x88}},
- {{0xe1,0xba,0xbb}, {0x65,0xcc,0x89}},
- {{0xc4,0x9b}, {0x65,0xcc,0x8c}},
- {{0xc8,0x85}, {0x65,0xcc,0x8f}},
- {{0xc8,0x87}, {0x65,0xcc,0x91}},
- {{0xe1,0xba,0xb9}, {0x65,0xcc,0xa3}},
- {{0xe1,0xbb,0x87}, {0x65,0xcc,0xa3,0xcc,0x82}},
- {{0xe1,0xb8,0x9d}, {0x65,0xcc,0xa7,0xcc,0x86}},
- {{0xc4,0x99}, {0x65,0xcc,0xa8}},
- {{0xe1,0xb8,0x99}, {0x65,0xcc,0xad}},
- {{0xe1,0xb8,0x9b}, {0x65,0xcc,0xb0}},
- {{0xe1,0xb8,0x9f}, {0x66,0xcc,0x87}},
- {{0xc7,0xb5}, {0x67,0xcc,0x81}},
- {{0xc4,0x9d}, {0x67,0xcc,0x82}},
- {{0xe1,0xb8,0xa1}, {0x67,0xcc,0x84}},
- {{0xc4,0x9f}, {0x67,0xcc,0x86}},
- {{0xc4,0xa1}, {0x67,0xcc,0x87}},
- {{0xc7,0xa7}, {0x67,0xcc,0x8c}},
- {{0xc4,0xa3}, {0x67,0xcc,0xa7}},
- {{0xc4,0xa5}, {0x68,0xcc,0x82}},
- {{0xe1,0xb8,0xa3}, {0x68,0xcc,0x87}},
- {{0xe1,0xb8,0xa7}, {0x68,0xcc,0x88}},
- {{0xe1,0xb8,0xa5}, {0x68,0xcc,0xa3}},
- {{0xe1,0xb8,0xa9}, {0x68,0xcc,0xa7}},
- {{0xe1,0xb8,0xab}, {0x68,0xcc,0xae}},
- {{0xe1,0xba,0x96}, {0x68,0xcc,0xb1}},
- {{0xc3,0xac}, {0x69,0xcc,0x80}},
- {{0xc3,0xad}, {0x69,0xcc,0x81}},
- {{0xc3,0xae}, {0x69,0xcc,0x82}},
- {{0xc4,0xa9}, {0x69,0xcc,0x83}},
- {{0xc4,0xab}, {0x69,0xcc,0x84}},
- {{0xc4,0xad}, {0x69,0xcc,0x86}},
- {{0xc3,0xaf}, {0x69,0xcc,0x88}},
- {{0xe1,0xb8,0xaf}, {0x69,0xcc,0x88,0xcc,0x81}},
- {{0xe1,0xbb,0x89}, {0x69,0xcc,0x89}},
- {{0xc7,0x90}, {0x69,0xcc,0x8c}},
- {{0xc8,0x89}, {0x69,0xcc,0x8f}},
- {{0xc8,0x8b}, {0x69,0xcc,0x91}},
- {{0xe1,0xbb,0x8b}, {0x69,0xcc,0xa3}},
- {{0xc4,0xaf}, {0x69,0xcc,0xa8}},
- {{0xe1,0xb8,0xad}, {0x69,0xcc,0xb0}},
- {{0xc4,0xb5}, {0x6a,0xcc,0x82}},
- {{0xc7,0xb0}, {0x6a,0xcc,0x8c}},
- {{0xe1,0xb8,0xb1}, {0x6b,0xcc,0x81}},
- {{0xc7,0xa9}, {0x6b,0xcc,0x8c}},
- {{0xe1,0xb8,0xb3}, {0x6b,0xcc,0xa3}},
- {{0xc4,0xb7}, {0x6b,0xcc,0xa7}},
- {{0xe1,0xb8,0xb5}, {0x6b,0xcc,0xb1}},
- {{0xc4,0xba}, {0x6c,0xcc,0x81}},
- {{0xc4,0xbe}, {0x6c,0xcc,0x8c}},
- {{0xe1,0xb8,0xb7}, {0x6c,0xcc,0xa3}},
- {{0xe1,0xb8,0xb9}, {0x6c,0xcc,0xa3,0xcc,0x84}},
- {{0xc4,0xbc}, {0x6c,0xcc,0xa7}},
- {{0xe1,0xb8,0xbd}, {0x6c,0xcc,0xad}},
- {{0xe1,0xb8,0xbb}, {0x6c,0xcc,0xb1}},
- {{0xe1,0xb8,0xbf}, {0x6d,0xcc,0x81}},
- {{0xe1,0xb9,0x81}, {0x6d,0xcc,0x87}},
- {{0xe1,0xb9,0x83}, {0x6d,0xcc,0xa3}},
- {{0xc5,0x84}, {0x6e,0xcc,0x81}},
- {{0xc3,0xb1}, {0x6e,0xcc,0x83}},
- {{0xe1,0xb9,0x85}, {0x6e,0xcc,0x87}},
- {{0xc5,0x88}, {0x6e,0xcc,0x8c}},
- {{0xe1,0xb9,0x87}, {0x6e,0xcc,0xa3}},
- {{0xc5,0x86}, {0x6e,0xcc,0xa7}},
- {{0xe1,0xb9,0x8b}, {0x6e,0xcc,0xad}},
- {{0xe1,0xb9,0x89}, {0x6e,0xcc,0xb1}},
- {{0xc3,0xb2}, {0x6f,0xcc,0x80}},
- {{0xc3,0xb3}, {0x6f,0xcc,0x81}},
- {{0xc3,0xb4}, {0x6f,0xcc,0x82}},
- {{0xe1,0xbb,0x93}, {0x6f,0xcc,0x82,0xcc,0x80}},
- {{0xe1,0xbb,0x91}, {0x6f,0xcc,0x82,0xcc,0x81}},
- {{0xe1,0xbb,0x97}, {0x6f,0xcc,0x82,0xcc,0x83}},
- {{0xe1,0xbb,0x95}, {0x6f,0xcc,0x82,0xcc,0x89}},
- {{0xc3,0xb5}, {0x6f,0xcc,0x83}},
- {{0xe1,0xb9,0x8d}, {0x6f,0xcc,0x83,0xcc,0x81}},
- {{0xe1,0xb9,0x8f}, {0x6f,0xcc,0x83,0xcc,0x88}},
- {{0xc5,0x8d}, {0x6f,0xcc,0x84}},
- {{0xe1,0xb9,0x91}, {0x6f,0xcc,0x84,0xcc,0x80}},
- {{0xe1,0xb9,0x93}, {0x6f,0xcc,0x84,0xcc,0x81}},
- {{0xc5,0x8f}, {0x6f,0xcc,0x86}},
- {{0xc3,0xb6}, {0x6f,0xcc,0x88}},
- {{0xe1,0xbb,0x8f}, {0x6f,0xcc,0x89}},
- {{0xc5,0x91}, {0x6f,0xcc,0x8b}},
- {{0xc7,0x92}, {0x6f,0xcc,0x8c}},
- {{0xc8,0x8d}, {0x6f,0xcc,0x8f}},
- {{0xc8,0x8f}, {0x6f,0xcc,0x91}},
- {{0xc6,0xa1}, {0x6f,0xcc,0x9b}},
- {{0xe1,0xbb,0x9d}, {0x6f,0xcc,0x9b,0xcc,0x80}},
- {{0xe1,0xbb,0x9b}, {0x6f,0xcc,0x9b,0xcc,0x81}},
- {{0xe1,0xbb,0xa1}, {0x6f,0xcc,0x9b,0xcc,0x83}},
- {{0xe1,0xbb,0x9f}, {0x6f,0xcc,0x9b,0xcc,0x89}},
- {{0xe1,0xbb,0xa3}, {0x6f,0xcc,0x9b,0xcc,0xa3}},
- {{0xe1,0xbb,0x8d}, {0x6f,0xcc,0xa3}},
- {{0xe1,0xbb,0x99}, {0x6f,0xcc,0xa3,0xcc,0x82}},
- {{0xc7,0xab}, {0x6f,0xcc,0xa8}},
- {{0xc7,0xad}, {0x6f,0xcc,0xa8,0xcc,0x84}},
- {{0xe1,0xb9,0x95}, {0x70,0xcc,0x81}},
- {{0xe1,0xb9,0x97}, {0x70,0xcc,0x87}},
- {{0xc5,0x95}, {0x72,0xcc,0x81}},
- {{0xe1,0xb9,0x99}, {0x72,0xcc,0x87}},
- {{0xc5,0x99}, {0x72,0xcc,0x8c}},
- {{0xc8,0x91}, {0x72,0xcc,0x8f}},
- {{0xc8,0x93}, {0x72,0xcc,0x91}},
- {{0xe1,0xb9,0x9b}, {0x72,0xcc,0xa3}},
- {{0xe1,0xb9,0x9d}, {0x72,0xcc,0xa3,0xcc,0x84}},
- {{0xc5,0x97}, {0x72,0xcc,0xa7}},
- {{0xe1,0xb9,0x9f}, {0x72,0xcc,0xb1}},
- {{0xc5,0x9b}, {0x73,0xcc,0x81}},
- {{0xe1,0xb9,0xa5}, {0x73,0xcc,0x81,0xcc,0x87}},
- {{0xc5,0x9d}, {0x73,0xcc,0x82}},
- {{0xe1,0xb9,0xa1}, {0x73,0xcc,0x87}},
- {{0xc5,0xa1}, {0x73,0xcc,0x8c}},
- {{0xe1,0xb9,0xa7}, {0x73,0xcc,0x8c,0xcc,0x87}},
- {{0xe1,0xb9,0xa3}, {0x73,0xcc,0xa3}},
- {{0xe1,0xb9,0xa9}, {0x73,0xcc,0xa3,0xcc,0x87}},
- {{0xc5,0x9f}, {0x73,0xcc,0xa7}},
- {{0xe1,0xb9,0xab}, {0x74,0xcc,0x87}},
- {{0xe1,0xba,0x97}, {0x74,0xcc,0x88}},
- {{0xc5,0xa5}, {0x74,0xcc,0x8c}},
- {{0xe1,0xb9,0xad}, {0x74,0xcc,0xa3}},
- {{0xc5,0xa3}, {0x74,0xcc,0xa7}},
- {{0xe1,0xb9,0xb1}, {0x74,0xcc,0xad}},
- {{0xe1,0xb9,0xaf}, {0x74,0xcc,0xb1}},
- {{0xc3,0xb9}, {0x75,0xcc,0x80}},
- {{0xc3,0xba}, {0x75,0xcc,0x81}},
- {{0xc3,0xbb}, {0x75,0xcc,0x82}},
- {{0xc5,0xa9}, {0x75,0xcc,0x83}},
- {{0xe1,0xb9,0xb9}, {0x75,0xcc,0x83,0xcc,0x81}},
- {{0xc5,0xab}, {0x75,0xcc,0x84}},
- {{0xe1,0xb9,0xbb}, {0x75,0xcc,0x84,0xcc,0x88}},
- {{0xc5,0xad}, {0x75,0xcc,0x86}},
- {{0xc3,0xbc}, {0x75,0xcc,0x88}},
- {{0xc7,0x9c}, {0x75,0xcc,0x88,0xcc,0x80}},
- {{0xc7,0x98}, {0x75,0xcc,0x88,0xcc,0x81}},
- {{0xc7,0x96}, {0x75,0xcc,0x88,0xcc,0x84}},
- {{0xc7,0x9a}, {0x75,0xcc,0x88,0xcc,0x8c}},
- {{0xe1,0xbb,0xa7}, {0x75,0xcc,0x89}},
- {{0xc5,0xaf}, {0x75,0xcc,0x8a}},
- {{0xc5,0xb1}, {0x75,0xcc,0x8b}},
- {{0xc7,0x94}, {0x75,0xcc,0x8c}},
- {{0xc8,0x95}, {0x75,0xcc,0x8f}},
- {{0xc8,0x97}, {0x75,0xcc,0x91}},
- {{0xc6,0xb0}, {0x75,0xcc,0x9b}},
- {{0xe1,0xbb,0xab}, {0x75,0xcc,0x9b,0xcc,0x80}},
- {{0xe1,0xbb,0xa9}, {0x75,0xcc,0x9b,0xcc,0x81}},
- {{0xe1,0xbb,0xaf}, {0x75,0xcc,0x9b,0xcc,0x83}},
- {{0xe1,0xbb,0xad}, {0x75,0xcc,0x9b,0xcc,0x89}},
- {{0xe1,0xbb,0xb1}, {0x75,0xcc,0x9b,0xcc,0xa3}},
- {{0xe1,0xbb,0xa5}, {0x75,0xcc,0xa3}},
- {{0xe1,0xb9,0xb3}, {0x75,0xcc,0xa4}},
- {{0xc5,0xb3}, {0x75,0xcc,0xa8}},
- {{0xe1,0xb9,0xb7}, {0x75,0xcc,0xad}},
- {{0xe1,0xb9,0xb5}, {0x75,0xcc,0xb0}},
- {{0xe1,0xb9,0xbd}, {0x76,0xcc,0x83}},
- {{0xe1,0xb9,0xbf}, {0x76,0xcc,0xa3}},
- {{0xe1,0xba,0x81}, {0x77,0xcc,0x80}},
- {{0xe1,0xba,0x83}, {0x77,0xcc,0x81}},
- {{0xc5,0xb5}, {0x77,0xcc,0x82}},
- {{0xe1,0xba,0x87}, {0x77,0xcc,0x87}},
- {{0xe1,0xba,0x85}, {0x77,0xcc,0x88}},
- {{0xe1,0xba,0x98}, {0x77,0xcc,0x8a}},
- {{0xe1,0xba,0x89}, {0x77,0xcc,0xa3}},
- {{0xe1,0xba,0x8b}, {0x78,0xcc,0x87}},
- {{0xe1,0xba,0x8d}, {0x78,0xcc,0x88}},
- {{0xe1,0xbb,0xb3}, {0x79,0xcc,0x80}},
- {{0xc3,0xbd}, {0x79,0xcc,0x81}},
- {{0xc5,0xb7}, {0x79,0xcc,0x82}},
- {{0xe1,0xbb,0xb9}, {0x79,0xcc,0x83}},
- {{0xe1,0xba,0x8f}, {0x79,0xcc,0x87}},
- {{0xc3,0xbf}, {0x79,0xcc,0x88}},
- {{0xe1,0xbb,0xb7}, {0x79,0xcc,0x89}},
- {{0xe1,0xba,0x99}, {0x79,0xcc,0x8a}},
- {{0xe1,0xbb,0xb5}, {0x79,0xcc,0xa3}},
- {{0xc5,0xba}, {0x7a,0xcc,0x81}},
- {{0xe1,0xba,0x91}, {0x7a,0xcc,0x82}},
- {{0xc5,0xbc}, {0x7a,0xcc,0x87}},
- {{0xc5,0xbe}, {0x7a,0xcc,0x8c}},
- {{0xe1,0xba,0x93}, {0x7a,0xcc,0xa3}},
- {{0xe1,0xba,0x95}, {0x7a,0xcc,0xb1}},
- {{0xe1,0xbf,0xad}, {0xc2,0xa8,0xcc,0x80}},
- {{0xe1,0xbf,0xae}, {0xc2,0xa8,0xcc,0x81}},
- {{0xce,0x85}, {0xc2,0xa8,0xcc,0x8d}},
- {{0xe1,0xbf,0x81}, {0xc2,0xa8,0xcd,0x82}},
- {{0xe1,0xbf,0xbd}, {0xc2,0xb4}},
- {{0xce,0x87}, {0xc2,0xb7}},
- {{0xd3,0x94}, {0xc3,0x86}},
- {{0xc7,0xbc}, {0xc3,0x86,0xcc,0x81}},
- {{0xc7,0xa2}, {0xc3,0x86,0xcc,0x84}},
- {{0xc7,0xbe}, {0xc3,0x98,0xcc,0x81}},
- {{0xd3,0x95}, {0xc3,0xa6}},
- {{0xc7,0xbd}, {0xc3,0xa6,0xcc,0x81}},
- {{0xc7,0xa3}, {0xc3,0xa6,0xcc,0x84}},
- {{0xc7,0xbf}, {0xc3,0xb8,0xcc,0x81}},
- {{0xe1,0xba,0x9b}, {0xc5,0xbf,0xcc,0x87}},
- {{0xd3,0x98}, {0xc6,0x8f}},
- {{0xd3,0x9a}, {0xc6,0x8f,0xcc,0x88}},
- {{0xd3,0xa8}, {0xc6,0x9f}},
- {{0xd3,0xaa}, {0xc6,0x9f,0xcc,0x88}},
- {{0xd3,0xa0}, {0xc6,0xb7}},
- {{0xc7,0xae}, {0xc6,0xb7,0xcc,0x8c}},
- {{0xd3,0x99}, {0xc9,0x99}},
- {{0xd3,0x9b}, {0xc9,0x99,0xcc,0x88}},
- {{0xd3,0xa9}, {0xc9,0xb5}},
- {{0xd3,0xab}, {0xc9,0xb5,0xcc,0x88}},
- {{0xd3,0xa1}, {0xca,0x92}},
- {{0xc7,0xaf}, {0xca,0x92,0xcc,0x8c}},
- {{0xcd,0xb4}, {0xca,0xb9}},
- {{0xcd,0x80}, {0xcc,0x80}},
- {{0xcd,0x81}, {0xcc,0x81}},
- {{0xcc,0x90}, {0xcc,0x86,0xcc,0x87}},
- {{0xcd,0x84}, {0xcc,0x88,0xcc,0x8d}},
- {{0xcd,0x83}, {0xcc,0x93}},
- {{0xe1,0xbe,0xba}, {0xce,0x91,0xcc,0x80}},
- {{0xe1,0xbe,0xbb}, {0xce,0x91,0xcc,0x81}},
- {{0xe1,0xbe,0xb9}, {0xce,0x91,0xcc,0x84}},
- {{0xe1,0xbe,0xb8}, {0xce,0x91,0xcc,0x86}},
- {{0xce,0x86}, {0xce,0x91,0xcc,0x8d}},
- {{0xe1,0xbc,0x88}, {0xce,0x91,0xcc,0x93}},
- {{0xe1,0xbc,0x8a}, {0xce,0x91,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0x8c}, {0xce,0x91,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0x8e}, {0xce,0x91,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0x89}, {0xce,0x91,0xcc,0x94}},
- {{0xe1,0xbc,0x8b}, {0xce,0x91,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0x8d}, {0xce,0x91,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0x8f}, {0xce,0x91,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbe,0xbc}, {0xce,0x91,0xcd,0x85}},
- {{0xe1,0xbe,0x88}, {0xce,0x91,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0x8a}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0x8c}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0x8e}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0x89}, {0xce,0x91,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0x8b}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0x8d}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0x8f}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x88}, {0xce,0x95,0xcc,0x80}},
- {{0xe1,0xbf,0x89}, {0xce,0x95,0xcc,0x81}},
- {{0xce,0x88}, {0xce,0x95,0xcc,0x8d}},
- {{0xe1,0xbc,0x98}, {0xce,0x95,0xcc,0x93}},
- {{0xe1,0xbc,0x9a}, {0xce,0x95,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0x9c}, {0xce,0x95,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0x99}, {0xce,0x95,0xcc,0x94}},
- {{0xe1,0xbc,0x9b}, {0xce,0x95,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0x9d}, {0xce,0x95,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbf,0x8a}, {0xce,0x97,0xcc,0x80}},
- {{0xe1,0xbf,0x8b}, {0xce,0x97,0xcc,0x81}},
- {{0xce,0x89}, {0xce,0x97,0xcc,0x8d}},
- {{0xe1,0xbc,0xa8}, {0xce,0x97,0xcc,0x93}},
- {{0xe1,0xbc,0xaa}, {0xce,0x97,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0xac}, {0xce,0x97,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0xae}, {0xce,0x97,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0xa9}, {0xce,0x97,0xcc,0x94}},
- {{0xe1,0xbc,0xab}, {0xce,0x97,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0xad}, {0xce,0x97,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0xaf}, {0xce,0x97,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x8c}, {0xce,0x97,0xcd,0x85}},
- {{0xe1,0xbe,0x98}, {0xce,0x97,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0x9a}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0x9c}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0x9e}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0x99}, {0xce,0x97,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0x9b}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0x9d}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0x9f}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x9a}, {0xce,0x99,0xcc,0x80}},
- {{0xe1,0xbf,0x9b}, {0xce,0x99,0xcc,0x81}},
- {{0xe1,0xbf,0x99}, {0xce,0x99,0xcc,0x84}},
- {{0xe1,0xbf,0x98}, {0xce,0x99,0xcc,0x86}},
- {{0xce,0xaa}, {0xce,0x99,0xcc,0x88}},
- {{0xce,0x8a}, {0xce,0x99,0xcc,0x8d}},
- {{0xe1,0xbc,0xb8}, {0xce,0x99,0xcc,0x93}},
- {{0xe1,0xbc,0xba}, {0xce,0x99,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0xbc}, {0xce,0x99,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0xbe}, {0xce,0x99,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0xb9}, {0xce,0x99,0xcc,0x94}},
- {{0xe1,0xbc,0xbb}, {0xce,0x99,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0xbd}, {0xce,0x99,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0xbf}, {0xce,0x99,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xb8}, {0xce,0x9f,0xcc,0x80}},
- {{0xe1,0xbf,0xb9}, {0xce,0x9f,0xcc,0x81}},
- {{0xce,0x8c}, {0xce,0x9f,0xcc,0x8d}},
- {{0xe1,0xbd,0x88}, {0xce,0x9f,0xcc,0x93}},
- {{0xe1,0xbd,0x8a}, {0xce,0x9f,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbd,0x8c}, {0xce,0x9f,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbd,0x89}, {0xce,0x9f,0xcc,0x94}},
- {{0xe1,0xbd,0x8b}, {0xce,0x9f,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0x8d}, {0xce,0x9f,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbf,0xac}, {0xce,0xa1,0xcc,0x94}},
- {{0xe1,0xbf,0xaa}, {0xce,0xa5,0xcc,0x80}},
- {{0xe1,0xbf,0xab}, {0xce,0xa5,0xcc,0x81}},
- {{0xe1,0xbf,0xa9}, {0xce,0xa5,0xcc,0x84}},
- {{0xe1,0xbf,0xa8}, {0xce,0xa5,0xcc,0x86}},
- {{0xce,0xab}, {0xce,0xa5,0xcc,0x88}},
- {{0xce,0x8e}, {0xce,0xa5,0xcc,0x8d}},
- {{0xe1,0xbd,0x99}, {0xce,0xa5,0xcc,0x94}},
- {{0xe1,0xbd,0x9b}, {0xce,0xa5,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0x9d}, {0xce,0xa5,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbd,0x9f}, {0xce,0xa5,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xba}, {0xce,0xa9,0xcc,0x80}},
- {{0xe1,0xbf,0xbb}, {0xce,0xa9,0xcc,0x81}},
- {{0xce,0x8f}, {0xce,0xa9,0xcc,0x8d}},
- {{0xe1,0xbd,0xa8}, {0xce,0xa9,0xcc,0x93}},
- {{0xe1,0xbd,0xaa}, {0xce,0xa9,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbd,0xac}, {0xce,0xa9,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbd,0xae}, {0xce,0xa9,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbd,0xa9}, {0xce,0xa9,0xcc,0x94}},
- {{0xe1,0xbd,0xab}, {0xce,0xa9,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0xad}, {0xce,0xa9,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbd,0xaf}, {0xce,0xa9,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xbc}, {0xce,0xa9,0xcd,0x85}},
- {{0xe1,0xbe,0xa8}, {0xce,0xa9,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0xaa}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0xac}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0xae}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0xa9}, {0xce,0xa9,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0xab}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0xad}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0xaf}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbd,0xb0}, {0xce,0xb1,0xcc,0x80}},
- {{0xe1,0xbd,0xb1}, {0xce,0xb1,0xcc,0x81}},
- {{0xe1,0xbe,0xb1}, {0xce,0xb1,0xcc,0x84}},
- {{0xe1,0xbe,0xb0}, {0xce,0xb1,0xcc,0x86}},
- {{0xce,0xac}, {0xce,0xb1,0xcc,0x8d}},
- {{0xe1,0xbc,0x80}, {0xce,0xb1,0xcc,0x93}},
- {{0xe1,0xbc,0x82}, {0xce,0xb1,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0x84}, {0xce,0xb1,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0x86}, {0xce,0xb1,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0x81}, {0xce,0xb1,0xcc,0x94}},
- {{0xe1,0xbc,0x83}, {0xce,0xb1,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0x85}, {0xce,0xb1,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0x87}, {0xce,0xb1,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbe,0xb6}, {0xce,0xb1,0xcd,0x82}},
- {{0xe1,0xbe,0xb3}, {0xce,0xb1,0xcd,0x85}},
- {{0xe1,0xbe,0xb2}, {0xce,0xb1,0xcd,0x85,0xcc,0x80}},
- {{0xe1,0xbe,0xb4}, {0xce,0xb1,0xcd,0x85,0xcc,0x81}},
- {{0xe1,0xbe,0x80}, {0xce,0xb1,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0x82}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0x84}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0x86}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0x81}, {0xce,0xb1,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0x83}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0x85}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0x87}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbe,0xb7}, {0xce,0xb1,0xcd,0x85,0xcd,0x82}},
- {{0xe1,0xbd,0xb2}, {0xce,0xb5,0xcc,0x80}},
- {{0xe1,0xbd,0xb3}, {0xce,0xb5,0xcc,0x81}},
- {{0xce,0xad}, {0xce,0xb5,0xcc,0x8d}},
- {{0xe1,0xbc,0x90}, {0xce,0xb5,0xcc,0x93}},
- {{0xe1,0xbc,0x92}, {0xce,0xb5,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0x94}, {0xce,0xb5,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0x91}, {0xce,0xb5,0xcc,0x94}},
- {{0xe1,0xbc,0x93}, {0xce,0xb5,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0x95}, {0xce,0xb5,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbd,0xb4}, {0xce,0xb7,0xcc,0x80}},
- {{0xe1,0xbd,0xb5}, {0xce,0xb7,0xcc,0x81}},
- {{0xce,0xae}, {0xce,0xb7,0xcc,0x8d}},
- {{0xe1,0xbc,0xa0}, {0xce,0xb7,0xcc,0x93}},
- {{0xe1,0xbc,0xa2}, {0xce,0xb7,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0xa4}, {0xce,0xb7,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0xa6}, {0xce,0xb7,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0xa1}, {0xce,0xb7,0xcc,0x94}},
- {{0xe1,0xbc,0xa3}, {0xce,0xb7,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0xa5}, {0xce,0xb7,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0xa7}, {0xce,0xb7,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x86}, {0xce,0xb7,0xcd,0x82}},
- {{0xe1,0xbf,0x83}, {0xce,0xb7,0xcd,0x85}},
- {{0xe1,0xbf,0x82}, {0xce,0xb7,0xcd,0x85,0xcc,0x80}},
- {{0xe1,0xbf,0x84}, {0xce,0xb7,0xcd,0x85,0xcc,0x81}},
- {{0xe1,0xbe,0x90}, {0xce,0xb7,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0x92}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0x94}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0x96}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0x91}, {0xce,0xb7,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0x93}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0x95}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0x97}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x87}, {0xce,0xb7,0xcd,0x85,0xcd,0x82}},
- {{0xe1,0xbe,0xbe}, {0xce,0xb9}},
- {{0xe1,0xbd,0xb6}, {0xce,0xb9,0xcc,0x80}},
- {{0xe1,0xbd,0xb7}, {0xce,0xb9,0xcc,0x81}},
- {{0xe1,0xbf,0x91}, {0xce,0xb9,0xcc,0x84}},
- {{0xe1,0xbf,0x90}, {0xce,0xb9,0xcc,0x86}},
- {{0xcf,0x8a}, {0xce,0xb9,0xcc,0x88}},
- {{0xe1,0xbf,0x92}, {0xce,0xb9,0xcc,0x88,0xcc,0x80}},
- {{0xe1,0xbf,0x93}, {0xce,0xb9,0xcc,0x88,0xcc,0x81}},
- {{0xce,0x90}, {0xce,0xb9,0xcc,0x88,0xcc,0x8d}},
- {{0xe1,0xbf,0x97}, {0xce,0xb9,0xcc,0x88,0xcd,0x82}},
- {{0xce,0xaf}, {0xce,0xb9,0xcc,0x8d}},
- {{0xe1,0xbc,0xb0}, {0xce,0xb9,0xcc,0x93}},
- {{0xe1,0xbc,0xb2}, {0xce,0xb9,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbc,0xb4}, {0xce,0xb9,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbc,0xb6}, {0xce,0xb9,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbc,0xb1}, {0xce,0xb9,0xcc,0x94}},
- {{0xe1,0xbc,0xb3}, {0xce,0xb9,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbc,0xb5}, {0xce,0xb9,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbc,0xb7}, {0xce,0xb9,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0x96}, {0xce,0xb9,0xcd,0x82}},
- {{0xe1,0xbd,0xb8}, {0xce,0xbf,0xcc,0x80}},
- {{0xe1,0xbd,0xb9}, {0xce,0xbf,0xcc,0x81}},
- {{0xcf,0x8c}, {0xce,0xbf,0xcc,0x8d}},
- {{0xe1,0xbd,0x80}, {0xce,0xbf,0xcc,0x93}},
- {{0xe1,0xbd,0x82}, {0xce,0xbf,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbd,0x84}, {0xce,0xbf,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbd,0x81}, {0xce,0xbf,0xcc,0x94}},
- {{0xe1,0xbd,0x83}, {0xce,0xbf,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0x85}, {0xce,0xbf,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbf,0xb4}, {0xce,0xbf,0xcd,0x85,0xcc,0x81}},
- {{0xe1,0xbf,0xa4}, {0xcf,0x81,0xcc,0x93}},
- {{0xe1,0xbf,0xa5}, {0xcf,0x81,0xcc,0x94}},
- {{0xe1,0xbd,0xba}, {0xcf,0x85,0xcc,0x80}},
- {{0xe1,0xbd,0xbb}, {0xcf,0x85,0xcc,0x81}},
- {{0xe1,0xbf,0xa1}, {0xcf,0x85,0xcc,0x84}},
- {{0xe1,0xbf,0xa0}, {0xcf,0x85,0xcc,0x86}},
- {{0xcf,0x8b}, {0xcf,0x85,0xcc,0x88}},
- {{0xe1,0xbf,0xa2}, {0xcf,0x85,0xcc,0x88,0xcc,0x80}},
- {{0xe1,0xbf,0xa3}, {0xcf,0x85,0xcc,0x88,0xcc,0x81}},
- {{0xce,0xb0}, {0xcf,0x85,0xcc,0x88,0xcc,0x8d}},
- {{0xe1,0xbf,0xa7}, {0xcf,0x85,0xcc,0x88,0xcd,0x82}},
- {{0xcf,0x8d}, {0xcf,0x85,0xcc,0x8d}},
- {{0xe1,0xbd,0x90}, {0xcf,0x85,0xcc,0x93}},
- {{0xe1,0xbd,0x92}, {0xcf,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbd,0x94}, {0xcf,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbd,0x96}, {0xcf,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbd,0x91}, {0xcf,0x85,0xcc,0x94}},
- {{0xe1,0xbd,0x93}, {0xcf,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0x95}, {0xcf,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbd,0x97}, {0xcf,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xa6}, {0xcf,0x85,0xcd,0x82}},
- {{0xe1,0xbd,0xbc}, {0xcf,0x89,0xcc,0x80}},
- {{0xe1,0xbd,0xbd}, {0xcf,0x89,0xcc,0x81}},
- {{0xcf,0x8e}, {0xcf,0x89,0xcc,0x8d}},
- {{0xe1,0xbd,0xa0}, {0xcf,0x89,0xcc,0x93}},
- {{0xe1,0xbd,0xa2}, {0xcf,0x89,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbd,0xa4}, {0xcf,0x89,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbd,0xa6}, {0xcf,0x89,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbd,0xa1}, {0xcf,0x89,0xcc,0x94}},
- {{0xe1,0xbd,0xa3}, {0xcf,0x89,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbd,0xa5}, {0xcf,0x89,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbd,0xa7}, {0xcf,0x89,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xb6}, {0xcf,0x89,0xcd,0x82}},
- {{0xe1,0xbf,0xb3}, {0xcf,0x89,0xcd,0x85}},
- {{0xe1,0xbf,0xb2}, {0xcf,0x89,0xcd,0x85,0xcc,0x80}},
- {{0xe1,0xbe,0xa0}, {0xcf,0x89,0xcd,0x85,0xcc,0x93}},
- {{0xe1,0xbe,0xa2}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
- {{0xe1,0xbe,0xa4}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
- {{0xe1,0xbe,0xa6}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
- {{0xe1,0xbe,0xa1}, {0xcf,0x89,0xcd,0x85,0xcc,0x94}},
- {{0xe1,0xbe,0xa3}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
- {{0xe1,0xbe,0xa5}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
- {{0xe1,0xbe,0xa7}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
- {{0xe1,0xbf,0xb7}, {0xcf,0x89,0xcd,0x85,0xcd,0x82}},
- {{0xcf,0x94}, {0xcf,0x92,0xcc,0x88}},
- {{0xcf,0x93}, {0xcf,0x92,0xcc,0x8d}},
- {{0xd0,0x87}, {0xd0,0x86,0xcc,0x88}},
- {{0xd3,0x90}, {0xd0,0x90,0xcc,0x86}},
- {{0xd3,0x92}, {0xd0,0x90,0xcc,0x88}},
- {{0xd0,0x83}, {0xd0,0x93,0xcc,0x81}},
- {{0xd3,0x96}, {0xd0,0x95,0xcc,0x86}},
- {{0xd0,0x81}, {0xd0,0x95,0xcc,0x88}},
- {{0xd3,0x81}, {0xd0,0x96,0xcc,0x86}},
- {{0xd3,0x9c}, {0xd0,0x96,0xcc,0x88}},
- {{0xd3,0x9e}, {0xd0,0x97,0xcc,0x88}},
- {{0xd3,0xa2}, {0xd0,0x98,0xcc,0x84}},
- {{0xd0,0x99}, {0xd0,0x98,0xcc,0x86}},
- {{0xd3,0xa4}, {0xd0,0x98,0xcc,0x88}},
- {{0xd0,0x8c}, {0xd0,0x9a,0xcc,0x81}},
- {{0xd3,0xa6}, {0xd0,0x9e,0xcc,0x88}},
- {{0xd3,0xae}, {0xd0,0xa3,0xcc,0x84}},
- {{0xd0,0x8e}, {0xd0,0xa3,0xcc,0x86}},
- {{0xd3,0xb0}, {0xd0,0xa3,0xcc,0x88}},
- {{0xd3,0xb2}, {0xd0,0xa3,0xcc,0x8b}},
- {{0xd3,0xb4}, {0xd0,0xa7,0xcc,0x88}},
- {{0xd3,0xb8}, {0xd0,0xab,0xcc,0x88}},
- {{0xd3,0x91}, {0xd0,0xb0,0xcc,0x86}},
- {{0xd3,0x93}, {0xd0,0xb0,0xcc,0x88}},
- {{0xd1,0x93}, {0xd0,0xb3,0xcc,0x81}},
- {{0xd3,0x97}, {0xd0,0xb5,0xcc,0x86}},
- {{0xd1,0x91}, {0xd0,0xb5,0xcc,0x88}},
- {{0xd3,0x82}, {0xd0,0xb6,0xcc,0x86}},
- {{0xd3,0x9d}, {0xd0,0xb6,0xcc,0x88}},
- {{0xd3,0x9f}, {0xd0,0xb7,0xcc,0x88}},
- {{0xd3,0xa3}, {0xd0,0xb8,0xcc,0x84}},
- {{0xd0,0xb9}, {0xd0,0xb8,0xcc,0x86}},
- {{0xd3,0xa5}, {0xd0,0xb8,0xcc,0x88}},
- {{0xd1,0x9c}, {0xd0,0xba,0xcc,0x81}},
- {{0xd3,0xa7}, {0xd0,0xbe,0xcc,0x88}},
- {{0xd3,0xaf}, {0xd1,0x83,0xcc,0x84}},
- {{0xd1,0x9e}, {0xd1,0x83,0xcc,0x86}},
- {{0xd3,0xb1}, {0xd1,0x83,0xcc,0x88}},
- {{0xd3,0xb3}, {0xd1,0x83,0xcc,0x8b}},
- {{0xd3,0xb5}, {0xd1,0x87,0xcc,0x88}},
- {{0xd3,0xb9}, {0xd1,0x8b,0xcc,0x88}},
- {{0xd1,0x97}, {0xd1,0x96,0xcc,0x88}},
- {{0xd1,0xb6}, {0xd1,0xb4,0xcc,0x8f}},
- {{0xd1,0xb7}, {0xd1,0xb5,0xcc,0x8f}},
- {{0xef,0xac,0xae}, {0xd7,0x90,0xd6,0xb7}},
- {{0xef,0xac,0xaf}, {0xd7,0x90,0xd6,0xb8}},
- {{0xef,0xac,0xb0}, {0xd7,0x90,0xd6,0xbc}},
- {{0xef,0xac,0xb1}, {0xd7,0x91,0xd6,0xbc}},
- {{0xef,0xad,0x8c}, {0xd7,0x91,0xd6,0xbf}},
- {{0xef,0xac,0xb2}, {0xd7,0x92,0xd6,0xbc}},
- {{0xef,0xac,0xb3}, {0xd7,0x93,0xd6,0xbc}},
- {{0xef,0xac,0xb4}, {0xd7,0x94,0xd6,0xbc}},
- {{0xef,0xad,0x8b}, {0xd7,0x95,0xd6,0xb9}},
- {{0xef,0xac,0xb5}, {0xd7,0x95,0xd6,0xbc}},
- {{0xef,0xac,0xb6}, {0xd7,0x96,0xd6,0xbc}},
- {{0xef,0xac,0xb8}, {0xd7,0x98,0xd6,0xbc}},
- {{0xef,0xac,0xb9}, {0xd7,0x99,0xd6,0xbc}},
- {{0xef,0xac,0xba}, {0xd7,0x9a,0xd6,0xbc}},
- {{0xef,0xac,0xbb}, {0xd7,0x9b,0xd6,0xbc}},
- {{0xef,0xad,0x8d}, {0xd7,0x9b,0xd6,0xbf}},
- {{0xef,0xac,0xbc}, {0xd7,0x9c,0xd6,0xbc}},
- {{0xef,0xac,0xbe}, {0xd7,0x9e,0xd6,0xbc}},
- {{0xef,0xad,0x80}, {0xd7,0xa0,0xd6,0xbc}},
- {{0xef,0xad,0x81}, {0xd7,0xa1,0xd6,0xbc}},
- {{0xef,0xad,0x83}, {0xd7,0xa3,0xd6,0xbc}},
- {{0xef,0xad,0x84}, {0xd7,0xa4,0xd6,0xbc}},
- {{0xef,0xad,0x8e}, {0xd7,0xa4,0xd6,0xbf}},
- {{0xef,0xad,0x86}, {0xd7,0xa6,0xd6,0xbc}},
- {{0xef,0xad,0x87}, {0xd7,0xa7,0xd6,0xbc}},
- {{0xef,0xad,0x88}, {0xd7,0xa8,0xd6,0xbc}},
- {{0xef,0xad,0x89}, {0xd7,0xa9,0xd6,0xbc}},
- {{0xef,0xac,0xac}, {0xd7,0xa9,0xd6,0xbc,0xd7,0x81}},
- {{0xef,0xac,0xad}, {0xd7,0xa9,0xd6,0xbc,0xd7,0x82}},
- {{0xef,0xac,0xaa}, {0xd7,0xa9,0xd7,0x81}},
- {{0xef,0xac,0xab}, {0xd7,0xa9,0xd7,0x82}},
- {{0xef,0xad,0x8a}, {0xd7,0xaa,0xd6,0xbc}},
- {{0xef,0xac,0x9f}, {0xd7,0xb2,0xd6,0xb7}},
- {{0xe0,0xa5,0x98}, {0xe0,0xa4,0x95,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x99}, {0xe0,0xa4,0x96,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9a}, {0xe0,0xa4,0x97,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9b}, {0xe0,0xa4,0x9c,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9c}, {0xe0,0xa4,0xa1,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9d}, {0xe0,0xa4,0xa2,0xe0,0xa4,0xbc}},
- {{0xe0,0xa4,0xa9}, {0xe0,0xa4,0xa8,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9e}, {0xe0,0xa4,0xab,0xe0,0xa4,0xbc}},
- {{0xe0,0xa5,0x9f}, {0xe0,0xa4,0xaf,0xe0,0xa4,0xbc}},
- {{0xe0,0xa4,0xb1}, {0xe0,0xa4,0xb0,0xe0,0xa4,0xbc}},
- {{0xe0,0xa4,0xb4}, {0xe0,0xa4,0xb3,0xe0,0xa4,0xbc}},
- {{0xe0,0xa7,0x9c}, {0xe0,0xa6,0xa1,0xe0,0xa6,0xbc}},
- {{0xe0,0xa7,0x9d}, {0xe0,0xa6,0xa2,0xe0,0xa6,0xbc}},
- {{0xe0,0xa6,0xb0}, {0xe0,0xa6,0xac,0xe0,0xa6,0xbc}},
- {{0xe0,0xa7,0x9f}, {0xe0,0xa6,0xaf,0xe0,0xa6,0xbc}},
- {{0xe0,0xa7,0x8b}, {0xe0,0xa7,0x87,0xe0,0xa6,0xbe}},
- {{0xe0,0xa7,0x8c}, {0xe0,0xa7,0x87,0xe0,0xa7,0x97}},
- {{0xe0,0xa9,0x99}, {0xe0,0xa8,0x96,0xe0,0xa8,0xbc}},
- {{0xe0,0xa9,0x9a}, {0xe0,0xa8,0x97,0xe0,0xa8,0xbc}},
- {{0xe0,0xa9,0x9b}, {0xe0,0xa8,0x9c,0xe0,0xa8,0xbc}},
- {{0xe0,0xa9,0x9c}, {0xe0,0xa8,0xa1,0xe0,0xa8,0xbc}},
- {{0xe0,0xa9,0x9e}, {0xe0,0xa8,0xab,0xe0,0xa8,0xbc}},
- {{0xe0,0xad,0x9c}, {0xe0,0xac,0xa1,0xe0,0xac,0xbc}},
- {{0xe0,0xad,0x9d}, {0xe0,0xac,0xa2,0xe0,0xac,0xbc}},
- {{0xe0,0xad,0x9f}, {0xe0,0xac,0xaf,0xe0,0xac,0xbc}},
- {{0xe0,0xad,0x8b}, {0xe0,0xad,0x87,0xe0,0xac,0xbe}},
- {{0xe0,0xad,0x88}, {0xe0,0xad,0x87,0xe0,0xad,0x96}},
- {{0xe0,0xad,0x8c}, {0xe0,0xad,0x87,0xe0,0xad,0x97}},
- {{0xe0,0xae,0x94}, {0xe0,0xae,0x92,0xe0,0xaf,0x97}},
- {{0xe0,0xaf,0x8a}, {0xe0,0xaf,0x86,0xe0,0xae,0xbe}},
- {{0xe0,0xaf,0x8c}, {0xe0,0xaf,0x86,0xe0,0xaf,0x97}},
- {{0xe0,0xaf,0x8b}, {0xe0,0xaf,0x87,0xe0,0xae,0xbe}},
- {{0xe0,0xb1,0x88}, {0xe0,0xb1,0x86,0xe0,0xb1,0x96}},
- {{0xe0,0xb3,0x80}, {0xe0,0xb2,0xbf,0xe0,0xb3,0x95}},
- {{0xe0,0xb3,0x8a}, {0xe0,0xb3,0x86,0xe0,0xb3,0x82}},
- {{0xe0,0xb3,0x8b}, {0xe0,0xb3,0x86,0xe0,0xb3,0x82,0xe0,0xb3,0x95}},
- {{0xe0,0xb3,0x87}, {0xe0,0xb3,0x86,0xe0,0xb3,0x95}},
- {{0xe0,0xb3,0x88}, {0xe0,0xb3,0x86,0xe0,0xb3,0x96}},
- {{0xe0,0xb5,0x8a}, {0xe0,0xb5,0x86,0xe0,0xb4,0xbe}},
- {{0xe0,0xb5,0x8c}, {0xe0,0xb5,0x86,0xe0,0xb5,0x97}},
- {{0xe0,0xb5,0x8b}, {0xe0,0xb5,0x87,0xe0,0xb4,0xbe}},
- {{0xe0,0xb8,0xb3}, {0xe0,0xb9,0x8d,0xe0,0xb8,0xb2}},
- {{0xe0,0xba,0xb3}, {0xe0,0xbb,0x8d,0xe0,0xba,0xb2}},
- {{0xe0,0xbd,0xa9}, {0xe0,0xbd,0x80,0xe0,0xbe,0xb5}},
- {{0xe0,0xbd,0x83}, {0xe0,0xbd,0x82,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0x8d}, {0xe0,0xbd,0x8c,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0x92}, {0xe0,0xbd,0x91,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0x97}, {0xe0,0xbd,0x96,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0x9c}, {0xe0,0xbd,0x9b,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0xb3}, {0xe0,0xbd,0xb2,0xe0,0xbd,0xb1}},
- {{0xe0,0xbd,0xb5}, {0xe0,0xbd,0xb4,0xe0,0xbd,0xb1}},
- {{0xe0,0xbe,0x81}, {0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
- {{0xe0,0xbe,0xb9}, {0xe0,0xbe,0x90,0xe0,0xbe,0xb5}},
- {{0xe0,0xbe,0x93}, {0xe0,0xbe,0x92,0xe0,0xbe,0xb7}},
- {{0xe0,0xbe,0x9d}, {0xe0,0xbe,0x9c,0xe0,0xbe,0xb7}},
- {{0xe0,0xbe,0xa2}, {0xe0,0xbe,0xa1,0xe0,0xbe,0xb7}},
- {{0xe0,0xbe,0xa7}, {0xe0,0xbe,0xa6,0xe0,0xbe,0xb7}},
- {{0xe0,0xbe,0xac}, {0xe0,0xbe,0xab,0xe0,0xbe,0xb7}},
- {{0xe0,0xbd,0xb6}, {0xe0,0xbe,0xb2,0xe0,0xbe,0x80}},
- {{0xe0,0xbd,0xb7}, {0xe0,0xbe,0xb2,0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
- {{0xe0,0xbd,0xb8}, {0xe0,0xbe,0xb3,0xe0,0xbe,0x80}},
- {{0xe0,0xbd,0xb9}, {0xe0,0xbe,0xb3,0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
- {{0xe1,0xbf,0x8d}, {0xe1,0xbe,0xbf,0xcc,0x80}},
- {{0xe1,0xbf,0x8e}, {0xe1,0xbe,0xbf,0xcc,0x81}},
- {{0xe1,0xbf,0x8f}, {0xe1,0xbe,0xbf,0xcd,0x82}},
- {{0xe1,0xbf,0x9d}, {0xe1,0xbf,0xbe,0xcc,0x80}},
- {{0xe1,0xbf,0x9e}, {0xe1,0xbf,0xbe,0xcc,0x81}},
- {{0xe1,0xbf,0x9f}, {0xe1,0xbf,0xbe,0xcd,0x82}},
- {{0xe3,0x82,0x94}, {0xe3,0x81,0x86,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x8c}, {0xe3,0x81,0x8b,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x8e}, {0xe3,0x81,0x8d,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x90}, {0xe3,0x81,0x8f,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x92}, {0xe3,0x81,0x91,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x94}, {0xe3,0x81,0x93,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x96}, {0xe3,0x81,0x95,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x98}, {0xe3,0x81,0x97,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x9a}, {0xe3,0x81,0x99,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x9c}, {0xe3,0x81,0x9b,0xe3,0x82,0x99}},
- {{0xe3,0x81,0x9e}, {0xe3,0x81,0x9d,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xa0}, {0xe3,0x81,0x9f,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xa2}, {0xe3,0x81,0xa1,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xa5}, {0xe3,0x81,0xa4,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xa7}, {0xe3,0x81,0xa6,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xa9}, {0xe3,0x81,0xa8,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xb0}, {0xe3,0x81,0xaf,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xb1}, {0xe3,0x81,0xaf,0xe3,0x82,0x9a}},
- {{0xe3,0x81,0xb3}, {0xe3,0x81,0xb2,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xb4}, {0xe3,0x81,0xb2,0xe3,0x82,0x9a}},
- {{0xe3,0x81,0xb6}, {0xe3,0x81,0xb5,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xb7}, {0xe3,0x81,0xb5,0xe3,0x82,0x9a}},
- {{0xe3,0x81,0xb9}, {0xe3,0x81,0xb8,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xba}, {0xe3,0x81,0xb8,0xe3,0x82,0x9a}},
- {{0xe3,0x81,0xbc}, {0xe3,0x81,0xbb,0xe3,0x82,0x99}},
- {{0xe3,0x81,0xbd}, {0xe3,0x81,0xbb,0xe3,0x82,0x9a}},
- {{0xe3,0x82,0x9e}, {0xe3,0x82,0x9d,0xe3,0x82,0x99}},
- {{0xe3,0x83,0xb4}, {0xe3,0x82,0xa6,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xac}, {0xe3,0x82,0xab,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xae}, {0xe3,0x82,0xad,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xb0}, {0xe3,0x82,0xaf,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xb2}, {0xe3,0x82,0xb1,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xb4}, {0xe3,0x82,0xb3,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xb6}, {0xe3,0x82,0xb5,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xb8}, {0xe3,0x82,0xb7,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xba}, {0xe3,0x82,0xb9,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xbc}, {0xe3,0x82,0xbb,0xe3,0x82,0x99}},
- {{0xe3,0x82,0xbe}, {0xe3,0x82,0xbd,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x80}, {0xe3,0x82,0xbf,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x82}, {0xe3,0x83,0x81,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x85}, {0xe3,0x83,0x84,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x87}, {0xe3,0x83,0x86,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x89}, {0xe3,0x83,0x88,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x90}, {0xe3,0x83,0x8f,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x91}, {0xe3,0x83,0x8f,0xe3,0x82,0x9a}},
- {{0xe3,0x83,0x93}, {0xe3,0x83,0x92,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x94}, {0xe3,0x83,0x92,0xe3,0x82,0x9a}},
- {{0xe3,0x83,0x96}, {0xe3,0x83,0x95,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x97}, {0xe3,0x83,0x95,0xe3,0x82,0x9a}},
- {{0xe3,0x83,0x99}, {0xe3,0x83,0x98,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x9a}, {0xe3,0x83,0x98,0xe3,0x82,0x9a}},
- {{0xe3,0x83,0x9c}, {0xe3,0x83,0x9b,0xe3,0x82,0x99}},
- {{0xe3,0x83,0x9d}, {0xe3,0x83,0x9b,0xe3,0x82,0x9a}},
- {{0xe3,0x83,0xb7}, {0xe3,0x83,0xaf,0xe3,0x82,0x99}},
- {{0xe3,0x83,0xb8}, {0xe3,0x83,0xb0,0xe3,0x82,0x99}},
- {{0xe3,0x83,0xb9}, {0xe3,0x83,0xb1,0xe3,0x82,0x99}},
- {{0xe3,0x83,0xba}, {0xe3,0x83,0xb2,0xe3,0x82,0x99}},
- {{0xe3,0x83,0xbe}, {0xe3,0x83,0xbd,0xe3,0x82,0x99}},
-};
-#endif /* UNICODE_NORMALIZATION */
-#endif /* UTF8_INPUT_ENABLE */
-
-#ifdef SHIFTJIS_CP932
-const unsigned short shiftjis_cp932[3][189] = {
- {
- 0xEEEF, 0xEEF0, 0xEEF1, 0xEEF2, 0xEEF3, 0xEEF4, 0xEEF5, 0xEEF6,
- 0xEEF7, 0xEEF8, 0x8754, 0x8755, 0x8756, 0x8757, 0x8758, 0x8759,
- 0x875A, 0x875B, 0x875C, 0x875D, 0x81CA, 0xEEFA, 0xEEFB, 0xEEFC,
- 0x878A, 0x8782, 0x8784, 0x81E6, 0xED40, 0xED41, 0xED42, 0xED43,
- 0xED44, 0xED45, 0xED46, 0xED47, 0xED48, 0xED49, 0xED4A, 0xED4B,
- 0xED4C, 0xED4D, 0xED4E, 0xED4F, 0xED50, 0xED51, 0xED52, 0xED53,
- 0xED54, 0xED55, 0xED56, 0xED57, 0xED58, 0xED59, 0xED5A, 0xED5B,
- 0xED5C, 0xED5D, 0xED5E, 0xED5F, 0xED60, 0xED61, 0xED62, 0,
- 0xED63, 0xED64, 0xED65, 0xED66, 0xED67, 0xED68, 0xED69, 0xED6A,
- 0xED6B, 0xED6C, 0xED6D, 0xED6E, 0xED6F, 0xED70, 0xED71, 0xED72,
- 0xED73, 0xED74, 0xED75, 0xED76, 0xED77, 0xED78, 0xED79, 0xED7A,
- 0xED7B, 0xED7C, 0xED7D, 0xED7E, 0xED80, 0xED81, 0xED82, 0xED83,
- 0xED84, 0xED85, 0xED86, 0xED87, 0xED88, 0xED89, 0xED8A, 0xED8B,
- 0xED8C, 0xED8D, 0xED8E, 0xED8F, 0xED90, 0xED91, 0xED92, 0xED93,
- 0xED94, 0xED95, 0xED96, 0xED97, 0xED98, 0xED99, 0xED9A, 0xED9B,
- 0xED9C, 0xED9D, 0xED9E, 0xED9F, 0xEDA0, 0xEDA1, 0xEDA2, 0xEDA3,
- 0xEDA4, 0xEDA5, 0xEDA6, 0xEDA7, 0xEDA8, 0xEDA9, 0xEDAA, 0xEDAB,
- 0xEDAC, 0xEDAD, 0xEDAE, 0xEDAF, 0xEDB0, 0xEDB1, 0xEDB2, 0xEDB3,
- 0xEDB4, 0xEDB5, 0xEDB6, 0xEDB7, 0xEDB8, 0xEDB9, 0xEDBA, 0xEDBB,
- 0xEDBC, 0xEDBD, 0xEDBE, 0xEDBF, 0xEDC0, 0xEDC1, 0xEDC2, 0xEDC3,
- 0xEDC4, 0xEDC5, 0xEDC6, 0xEDC7, 0xEDC8, 0xEDC9, 0xEDCA, 0xEDCB,
- 0xEDCC, 0xEDCD, 0xEDCE, 0xEDCF, 0xEDD0, 0xEDD1, 0xEDD2, 0xEDD3,
- 0xEDD4, 0xEDD5, 0xEDD6, 0xEDD7, 0xEDD8, 0xEDD9, 0xEDDA, 0xEDDB,
- 0xEDDC, 0xEDDD, 0xEDDE, 0xEDDF, 0xEDE0,
- },
- {
- 0xEDE1, 0xEDE2, 0xEDE3, 0xEDE4, 0xEDE5, 0xEDE6, 0xEDE7, 0xEDE8,
- 0xEDE9, 0xEDEA, 0xEDEB, 0xEDEC, 0xEDED, 0xEDEE, 0xEDEF, 0xEDF0,
- 0xEDF1, 0xEDF2, 0xEDF3, 0xEDF4, 0xEDF5, 0xEDF6, 0xEDF7, 0xEDF8,
- 0xEDF9, 0xEDFA, 0xEDFB, 0xEDFC, 0xEE40, 0xEE41, 0xEE42, 0xEE43,
- 0xEE44, 0xEE45, 0xEE46, 0xEE47, 0xEE48, 0xEE49, 0xEE4A, 0xEE4B,
- 0xEE4C, 0xEE4D, 0xEE4E, 0xEE4F, 0xEE50, 0xEE51, 0xEE52, 0xEE53,
- 0xEE54, 0xEE55, 0xEE56, 0xEE57, 0xEE58, 0xEE59, 0xEE5A, 0xEE5B,
- 0xEE5C, 0xEE5D, 0xEE5E, 0xEE5F, 0xEE60, 0xEE61, 0xEE62, 0,
- 0xEE63, 0xEE64, 0xEE65, 0xEE66, 0xEE67, 0xEE68, 0xEE69, 0xEE6A,
- 0xEE6B, 0xEE6C, 0xEE6D, 0xEE6E, 0xEE6F, 0xEE70, 0xEE71, 0xEE72,
- 0xEE73, 0xEE74, 0xEE75, 0xEE76, 0xEE77, 0xEE78, 0xEE79, 0xEE7A,
- 0xEE7B, 0xEE7C, 0xEE7D, 0xEE7E, 0xEE80, 0xEE81, 0xEE82, 0xEE83,
- 0xEE84, 0xEE85, 0xEE86, 0xEE87, 0xEE88, 0xEE89, 0xEE8A, 0xEE8B,
- 0xEE8C, 0xEE8D, 0xEE8E, 0xEE8F, 0xEE90, 0xEE91, 0xEE92, 0xEE93,
- 0xEE94, 0xEE95, 0xEE96, 0xEE97, 0xEE98, 0xEE99, 0xEE9A, 0xEE9B,
- 0xEE9C, 0xEE9D, 0xEE9E, 0xEE9F, 0xEEA0, 0xEEA1, 0xEEA2, 0xEEA3,
- 0xEEA4, 0xEEA5, 0xEEA6, 0xEEA7, 0xEEA8, 0xEEA9, 0xEEAA, 0xEEAB,
- 0xEEAC, 0xEEAD, 0xEEAE, 0xEEAF, 0xEEB0, 0xEEB1, 0xEEB2, 0xEEB3,
- 0xEEB4, 0xEEB5, 0xEEB6, 0xEEB7, 0xEEB8, 0xEEB9, 0xEEBA, 0xEEBB,
- 0xEEBC, 0xEEBD, 0xEEBE, 0xEEBF, 0xEEC0, 0xEEC1, 0xEEC2, 0xEEC3,
- 0xEEC4, 0xEEC5, 0xEEC6, 0xEEC7, 0xEEC8, 0xEEC9, 0xEECA, 0xEECB,
- 0xEECC, 0xEECD, 0xEECE, 0xEECF, 0xEED0, 0xEED1, 0xEED2, 0xEED3,
- 0xEED4, 0xEED5, 0xEED6, 0xEED7, 0xEED8, 0xEED9, 0xEEDA, 0xEEDB,
- 0xEEDC, 0xEEDD, 0xEEDE, 0xEEDF, 0xEEE0,
- },
- {
- 0xEEE1, 0xEEE2, 0xEEE3, 0xEEE4, 0xEEE5, 0xEEE6, 0xEEE7, 0xEEE8,
- 0xEEE9, 0xEEEA, 0xEEEB, 0xEEEC, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- },
-};
-const unsigned short cp932inv[2][189] = {
- {
- 0xFA5C, 0xFA5D, 0xFA5E, 0xFA5F, 0xFA60, 0xFA61, 0xFA62, 0xFA63,
- 0xFA64, 0xFA65, 0xFA66, 0xFA67, 0xFA68, 0xFA69, 0xFA6A, 0xFA6B,
- 0xFA6C, 0xFA6D, 0xFA6E, 0xFA6F, 0xFA70, 0xFA71, 0xFA72, 0xFA73,
- 0xFA74, 0xFA75, 0xFA76, 0xFA77, 0xFA78, 0xFA79, 0xFA7A, 0xFA7B,
- 0xFA7C, 0xFA7D, 0xFA7E, 0xFA80, 0xFA81, 0xFA82, 0xFA83, 0xFA84,
- 0xFA85, 0xFA86, 0xFA87, 0xFA88, 0xFA89, 0xFA8A, 0xFA8B, 0xFA8C,
- 0xFA8D, 0xFA8E, 0xFA8F, 0xFA90, 0xFA91, 0xFA92, 0xFA93, 0xFA94,
- 0xFA95, 0xFA96, 0xFA97, 0xFA98, 0xFA99, 0xFA9A, 0xFA9B, 0,
- 0xFA9C, 0xFA9D, 0xFA9E, 0xFA9F, 0xFAA0, 0xFAA1, 0xFAA2, 0xFAA3,
- 0xFAA4, 0xFAA5, 0xFAA6, 0xFAA7, 0xFAA8, 0xFAA9, 0xFAAA, 0xFAAB,
- 0xFAAC, 0xFAAD, 0xFAAE, 0xFAAF, 0xFAB0, 0xFAB1, 0xFAB2, 0xFAB3,
- 0xFAB4, 0xFAB5, 0xFAB6, 0xFAB7, 0xFAB8, 0xFAB9, 0xFABA, 0xFABB,
- 0xFABC, 0xFABD, 0xFABE, 0xFABF, 0xFAC0, 0xFAC1, 0xFAC2, 0xFAC3,
- 0xFAC4, 0xFAC5, 0xFAC6, 0xFAC7, 0xFAC8, 0xFAC9, 0xFACA, 0xFACB,
- 0xFACC, 0xFACD, 0xFACE, 0xFACF, 0xFAD0, 0xFAD1, 0xFAD2, 0xFAD3,
- 0xFAD4, 0xFAD5, 0xFAD6, 0xFAD7, 0xFAD8, 0xFAD9, 0xFADA, 0xFADB,
- 0xFADC, 0xFADD, 0xFADE, 0xFADF, 0xFAE0, 0xFAE1, 0xFAE2, 0xFAE3,
- 0xFAE4, 0xFAE5, 0xFAE6, 0xFAE7, 0xFAE8, 0xFAE9, 0xFAEA, 0xFAEB,
- 0xFAEC, 0xFAED, 0xFAEE, 0xFAEF, 0xFAF0, 0xFAF1, 0xFAF2, 0xFAF3,
- 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9, 0xFAFA, 0xFAFB,
- 0xFAFC, 0xFB40, 0xFB41, 0xFB42, 0xFB43, 0xFB44, 0xFB45, 0xFB46,
- 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C, 0xFB4D, 0xFB4E,
- 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55, 0xFB56,
- 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B,
- },
- {
- 0xFB5C, 0xFB5D, 0xFB5E, 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63,
- 0xFB64, 0xFB65, 0xFB66, 0xFB67, 0xFB68, 0xFB69, 0xFB6A, 0xFB6B,
- 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70, 0xFB71, 0xFB72, 0xFB73,
- 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79, 0xFB7A, 0xFB7B,
- 0xFB7C, 0xFB7D, 0xFB7E, 0xFB80, 0xFB81, 0xFB82, 0xFB83, 0xFB84,
- 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B, 0xFB8C,
- 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
- 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0,
- 0xFB9C, 0xFB9D, 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3,
- 0xFBA4, 0xFBA5, 0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB,
- 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF, 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3,
- 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8, 0xFBB9, 0xFBBA, 0xFBBB,
- 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1, 0xFBC2, 0xFBC3,
- 0xFBC4, 0xFBC5, 0xFBC6, 0xFBC7, 0xFBC8, 0xFBC9, 0xFBCA, 0xFBCB,
- 0xFBCC, 0xFBCD, 0xFBCE, 0xFBCF, 0xFBD0, 0xFBD1, 0xFBD2, 0xFBD3,
- 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
- 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3,
- 0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB,
- 0xFBEC, 0xFBED, 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3,
- 0xFBF4, 0xFBF5, 0xFBF6, 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB,
- 0xFBFC, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46,
- 0xFC47, 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0, 0, 0xFA40,
- 0xFA41, 0xFA42, 0xFA43, 0xFA44, 0xFA45, 0xFA46, 0xFA47, 0xFA48,
- 0xFA49, 0x81CA, 0xFA55, 0xFA56, 0xFA57,
- },
-};
-#endif /* SHIFTJIS_CP932 */
-
-#ifdef X0212_ENABLE
-const unsigned short shiftjis_x0212[3][189] = {
- {
- 0xF373, 0xF374, 0xF375, 0xF376, 0xF377, 0xF378, 0xF379, 0xF37A,
- 0xF37B, 0xF37C, 0xF37D, 0xF37E, 0xF421, 0xF422, 0xF423, 0xF424,
- 0xF425, 0xF426, 0xF427, 0xF428, 0x224C, 0xA243, 0xF429, 0xF42A,
- 0xF42B, 0xF42C, 0xF42D, 0x2268, 0xD463, 0xDC5F, 0xE469, 0xE378,
- 0xD921, 0xB13B, 0xF42E, 0xC22D, 0xC37C, 0xE450, 0xC23F, 0xBC74,
- 0xB029, 0xB048, 0xF42F, 0xB052, 0xB054, 0xB063, 0xB06E, 0xB127,
- 0xB123, 0xB12C, 0xB129, 0xB13E, 0xB15F, 0xB158, 0xB148, 0xB157,
- 0xB163, 0xB174, 0xB161, 0xB223, 0xF430, 0xB23B, 0xB266, 0,
- 0xB26D, 0xB275, 0xB27C, 0xF431, 0xB335, 0xB358, 0xB35B, 0xB365,
- 0xB36E, 0xB37B, 0xF432, 0xF433, 0xB440, 0xB447, 0xB450, 0xB45E,
- 0xF434, 0xB52A, 0xF435, 0xB52F, 0xB544, 0xB568, 0xF436, 0xB742,
- 0xB764, 0xB768, 0xB767, 0xF437, 0xF438, 0xF439, 0xB84E, 0xB861,
- 0xB875, 0xB877, 0xB878, 0xB87C, 0xB92F, 0xB937, 0xBA3E, 0xBA5B,
- 0xCD2A, 0xBA61, 0xF43A, 0xBA6B, 0xBB33, 0xBB38, 0xF43B, 0xBB4A,
- 0xF43C, 0xF43D, 0xBB50, 0xBB5E, 0xBB74, 0xBB75, 0xBB79, 0xBC64,
- 0xBC6D, 0xBC7E, 0xF43E, 0xBD42, 0xBD67, 0xF43F, 0xBD70, 0xBE30,
- 0xBE2C, 0xF440, 0xBE33, 0xBE3D, 0xBE4D, 0xBE49, 0xBE64, 0xBF28,
- 0xBF49, 0xC044, 0xC064, 0xC074, 0xC126, 0xF441, 0xC175, 0xC17C,
- 0xF442, 0xC178, 0xC22B, 0xC221, 0xC225, 0xF443, 0xC238, 0xC23A,
- 0xF444, 0xC244, 0xC252, 0xC257, 0xC25B, 0xC25E, 0xC26D, 0xC270,
- 0xF445, 0xC321, 0xC335, 0xC349, 0xC339, 0xF446, 0xC358, 0xC37E,
- 0xF447, 0xC44C, 0xF448, 0xC459, 0xC46A, 0xC47D, 0xF449, 0xC527,
- 0xC535, 0xC536, 0xF44A, 0xC555, 0xC638, 0xC657, 0xC660, 0xC66A,
- 0xC663, 0xC721, 0xC72B, 0xC747, 0xC743,
- },
- {
- 0xC74B, 0xC74F, 0xC759, 0xF44B, 0xF44C, 0xC766, 0xC76E, 0xC77C,
- 0xC76B, 0xC770, 0xC831, 0xC865, 0xC878, 0xC926, 0xC92B, 0xC92D,
- 0xF44D, 0xC94A, 0xC953, 0xC969, 0xC963, 0xC97C, 0xC974, 0xC975,
- 0xF44E, 0xCA33, 0xCA3D, 0xCA6F, 0xCA71, 0xCB2E, 0xF44F, 0xCB4A,
- 0xCB66, 0xCB6A, 0xCB70, 0xCB74, 0xCB6E, 0xCC25, 0xCB79, 0xCC2B,
- 0xCC2E, 0xCC2D, 0xCC32, 0xCC42, 0xCC50, 0xCC59, 0xF450, 0xCD3B,
- 0xF451, 0xCE3B, 0xF452, 0xCE3A, 0xCE43, 0xF453, 0xCE72, 0xB35D,
- 0xCF55, 0xCF62, 0xCF69, 0xCF6D, 0xF454, 0xF455, 0xF456, 0,
- 0xF457, 0xD065, 0xF458, 0xD069, 0xD168, 0xF459, 0xF45A, 0xD16C,
- 0xD23B, 0xF45B, 0xD361, 0xD368, 0xD427, 0xF45C, 0xF45D, 0xD454,
- 0xD472, 0xD52E, 0xF45E, 0xD75E, 0xF45F, 0xD822, 0xD837, 0xD841,
- 0xD851, 0xD874, 0xD946, 0xD948, 0xD951, 0xF460, 0xF461, 0xF462,
- 0xF463, 0xF464, 0xDC53, 0xDD48, 0xDD54, 0xDD6A, 0xDD7A, 0xDE24,
- 0xDE30, 0xF465, 0xDE35, 0xDE4B, 0xF466, 0xDF39, 0xF467, 0xDF43,
- 0xF468, 0xF469, 0xE059, 0xF46A, 0xF46B, 0xE162, 0xF46C, 0xF46D,
- 0xF46E, 0xE247, 0xE328, 0xE326, 0xE329, 0xE32F, 0xE330, 0xE32A,
- 0xE32B, 0xE33C, 0xE341, 0xE33F, 0xE355, 0xE358, 0xE356, 0xE35F,
- 0xE363, 0xE361, 0xE354, 0xE369, 0xE426, 0xE371, 0xE372, 0xE44B,
- 0xE441, 0xE443, 0xE43E, 0xF46F, 0xE440, 0xE447, 0xE43F, 0xE460,
- 0xE45E, 0xE451, 0xF470, 0xE45C, 0xE452, 0xE45B, 0xE454, 0xE47A,
- 0xE46F, 0xE533, 0xE53F, 0xE549, 0xE550, 0xE562, 0xE56A, 0xE56B,
- 0xF471, 0xF472, 0xF473, 0xE668, 0xE66F, 0xE72C, 0xF474, 0xE72E,
- 0xF475, 0xE731, 0xF476, 0xE732, 0xE831, 0xE836, 0xF477, 0xF478,
- 0xE85D, 0xF479, 0xF47A, 0xE951, 0xF47B,
- },
- {
- 0xE96D, 0xEA4D, 0xF47C, 0xEA5B, 0xEA66, 0xEA6A, 0xEB25, 0xEB7B,
- 0xEB7A, 0xF47D, 0xEC56, 0xF47E, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 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 short x0212_shiftjis_A2[] = {
- 0x819F, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x8143, 0, 0, 0x8150, 0, 0, 0x8160,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA55, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_B0[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFA68, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA69, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFA6B, 0, 0xFA6C, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA6D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFA6E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_B1[] = {
- 0, 0, 0xFA70, 0, 0, 0, 0xFA6F,
- 0, 0xFA72, 0, 0, 0xFA71, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA61, 0, 0, 0xFA73, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA76, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFA77,
- 0xFA75, 0, 0, 0, 0, 0, 0, 0xFA74,
- 0, 0xFA7A, 0, 0xFA78, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFA79, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_B2[] = {
- 0, 0, 0xFA7B, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA7D, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFA7E, 0,
- 0, 0, 0, 0, 0, 0xFA80, 0, 0,
- 0, 0, 0, 0, 0, 0xFA81, 0, 0,
- 0, 0, 0, 0, 0xFA82, 0, 0,
-};
-static const unsigned short x0212_shiftjis_B3[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFA84, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA85, 0, 0, 0xFA86, 0, 0xFB77, 0, 0,
- 0, 0, 0, 0, 0, 0xFA87, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFA88, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA89, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_B4[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA8C, 0, 0, 0, 0, 0, 0, 0xFA8D,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA8E, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFA8F, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_B5[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFA91, 0, 0, 0, 0, 0xFA93,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFA94, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFA95, 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 short x0212_shiftjis_B7[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFA97, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFA98, 0, 0, 0xFA9A,
- 0xFA99, 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 short x0212_shiftjis_B8[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFA9E, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFA9F, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAA0, 0, 0xFAA1,
- 0xFAA2, 0, 0, 0, 0xFAA3, 0, 0,
-};
-static const unsigned short x0212_shiftjis_B9[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFAA4,
- 0, 0, 0, 0, 0, 0, 0, 0xFAA5,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_BA[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFAA6, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFAA7, 0, 0, 0, 0,
- 0, 0xFAA9, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFAAB, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_BB[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFAAC, 0, 0, 0, 0,
- 0xFAAD, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFAAF, 0, 0, 0, 0, 0,
- 0xFAB2, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFAB3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAB4, 0xFAB5, 0, 0,
- 0, 0xFAB6, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_BC[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAB7, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAB8, 0, 0,
- 0, 0, 0, 0, 0xFA67, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFAB9,
-};
-static const unsigned short x0212_shiftjis_BD[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFABB, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFABC,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFABE, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_BE[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAC0, 0, 0, 0,
- 0xFABF, 0, 0, 0xFAC2, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAC3, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFAC5, 0, 0, 0, 0xFAC4, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAC6, 0, 0, 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 short x0212_shiftjis_BF[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0xFAC7, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFAC8, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_C0[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAC9, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFACA, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFACB, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C1[] = {
- 0, 0, 0, 0, 0, 0xFACC, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFACE, 0, 0,
- 0xFAD1, 0, 0, 0, 0xFACF, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C2[] = {
- 0xFAD3, 0, 0, 0, 0xFAD4, 0, 0,
- 0, 0, 0, 0xFAD2, 0, 0xFA63, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFAD6, 0, 0xFAD7, 0, 0, 0, 0, 0xFA66,
- 0, 0, 0, 0, 0xFAD9, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFADA, 0, 0, 0, 0, 0xFADB,
- 0, 0, 0, 0xFADC, 0, 0, 0xFADD, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFADE, 0, 0,
- 0xFADF, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C3[] = {
- 0xFAE1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAE2, 0, 0,
- 0, 0xFAE4, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFAE3, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFAE6, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFA64, 0, 0xFAE7,
-};
-static const unsigned short x0212_shiftjis_C4[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFAE9, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFAEB, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFAEC, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAED, 0,
-};
-static const unsigned short x0212_shiftjis_C5[] = {
- 0, 0, 0, 0, 0, 0, 0xFAEF,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAF0, 0xFAF1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFAF3, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_C6[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFAF4, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFAF5,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFAF6, 0, 0, 0xFAF8, 0, 0, 0, 0,
- 0, 0, 0xFAF7, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C7[] = {
- 0xFAF9, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFAFA, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFAFC, 0, 0, 0, 0xFAFB,
- 0, 0, 0, 0xFB40, 0, 0, 0, 0xFB41,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB42, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB45, 0,
- 0, 0, 0, 0xFB48, 0, 0, 0xFB46, 0,
- 0xFB49, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFB47, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C8[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB4A, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFB4B, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFB4C, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_C9[] = {
- 0, 0, 0, 0, 0, 0xFB4D, 0,
- 0, 0, 0, 0xFB4E, 0, 0xFB4F, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFB52, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFB54, 0, 0, 0, 0,
- 0, 0xFB53, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFB56, 0xFB57, 0, 0,
- 0, 0, 0, 0, 0xFB55, 0, 0,
-};
-static const unsigned short x0212_shiftjis_CA[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFB59, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFB5A, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFB5B,
- 0, 0xFB5C, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_CB[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB5D, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB5F, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB60, 0,
- 0, 0, 0xFB61, 0, 0, 0, 0xFB64, 0,
- 0xFB62, 0, 0, 0, 0xFB63, 0, 0, 0,
- 0, 0xFB66, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_CC[] = {
- 0, 0, 0, 0, 0xFB65, 0, 0,
- 0, 0, 0, 0xFB67, 0, 0xFB69, 0xFB68, 0,
- 0, 0, 0xFB6A, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB6B, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFB6C, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB6D, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_CD[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFAA8, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFB6F, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_CE[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB73, 0xFB71, 0, 0, 0, 0,
- 0, 0, 0, 0xFB74, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB76, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_CF[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFB78, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB79, 0, 0, 0, 0, 0,
- 0, 0xFB7A, 0, 0, 0, 0xFB7B, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_D0[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFB81, 0, 0,
- 0, 0xFB83, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_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, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFB84, 0, 0, 0, 0xFB87, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_D2[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFB88, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_D3[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB8A, 0, 0, 0, 0, 0, 0,
- 0xFB8B, 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 short x0212_shiftjis_D4[] = {
- 0, 0, 0, 0, 0, 0, 0xFB8C,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFB8F, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA5C, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFB90, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_D5[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB91, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_D7[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB93, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_D8[] = {
- 0, 0xFB95, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFB96,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB97, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB98, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFB99, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_D9[] = {
- 0xFA60, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFB9A, 0,
- 0xFB9B, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFB9C, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_DC[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFBA2, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFA5D,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_DD[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFBA3, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFBA4, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFBA5, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFBA6, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_DE[] = {
- 0, 0, 0, 0xFBA7, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFBA8, 0, 0, 0, 0, 0xFBAA, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFBAB, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_DF[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFBAD, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFBAF, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_E0[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFBB2, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_E1[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFBB5, 0, 0, 0, 0, 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 short x0212_shiftjis_E2[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFBB9,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_E3[] = {
- 0, 0, 0, 0, 0, 0xFBBB, 0,
- 0xFBBA, 0xFBBC, 0xFBBF, 0xFBC0, 0, 0, 0, 0xFBBD,
- 0xFBBE, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFBC1, 0, 0, 0xFBC3,
- 0, 0xFBC2, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFBCA, 0xFBC4, 0xFBC6, 0,
- 0xFBC5, 0, 0, 0, 0, 0, 0, 0xFBC7,
- 0, 0xFBC9, 0, 0xFBC8, 0, 0, 0, 0,
- 0, 0xFBCB, 0, 0, 0, 0, 0, 0,
- 0, 0xFBCD, 0xFBCE, 0, 0, 0, 0, 0,
- 0xFA5F, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_E4[] = {
- 0, 0, 0, 0, 0, 0xFBCC, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFBD2, 0xFBD6,
- 0xFBD4, 0xFBD0, 0, 0xFBD1, 0, 0, 0, 0xFBD5,
- 0, 0, 0, 0xFBCF, 0, 0, 0, 0,
- 0xFA65, 0xFBD9, 0xFBDC, 0, 0xFBDE, 0, 0, 0,
- 0, 0, 0, 0xFBDD, 0xFBDB, 0, 0xFBD8, 0,
- 0xFBD7, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFA5E, 0, 0, 0, 0, 0, 0xFBE0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFBDF, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_E5[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFBE1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0xFBE2,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFBE3, 0, 0, 0, 0, 0, 0,
- 0xFBE4, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFBE5, 0, 0, 0, 0, 0,
- 0, 0, 0xFBE6, 0xFBE7, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_E6[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0xFBEB, 0, 0, 0, 0, 0, 0, 0xFBEC,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_E7[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0xFBED, 0, 0xFBEF, 0,
- 0, 0xFBF1, 0xFBF3, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_E8[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFBF4, 0, 0, 0, 0, 0xFBF5, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFBF8, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_E9[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0xFBFB, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFC40, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_EA[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0xFC41, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFC43, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFC44, 0,
- 0, 0, 0xFC45, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_EB[] = {
- 0, 0, 0, 0, 0xFC46, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xFC48, 0xFC47, 0, 0, 0,
-};
-static const unsigned short x0212_shiftjis_EC[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xFC4A, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 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 short x0212_shiftjis_F3[] = {
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFA40, 0xFA41, 0xFA42, 0xFA43, 0xFA44,
- 0xFA45, 0xFA46, 0xFA47, 0xFA48, 0xFA49, 0xFA4A, 0xFA4B,
-};
-static const unsigned short x0212_shiftjis_F4[] = {
- 0xFA4C, 0xFA4D, 0xFA4E, 0xFA4F, 0xFA50, 0xFA51, 0xFA52,
- 0xFA53, 0xFA56, 0xFA57, 0xFA58, 0xFA59, 0xFA5A, 0xFA62, 0xFA6A,
- 0xFA7C, 0xFA83, 0xFA8A, 0xFA8B, 0xFA90, 0xFA92, 0xFA96, 0xFA9B,
- 0xFA9C, 0xFA9D, 0xFAAA, 0xFAAE, 0xFAB0, 0xFAB1, 0xFABA, 0xFABD,
- 0xFAC1, 0xFACD, 0xFAD0, 0xFAD5, 0xFAD8, 0xFAE0, 0xFAE5, 0xFAE8,
- 0xFAEA, 0xFAEE, 0xFAF2, 0xFB43, 0xFB44, 0xFB50, 0xFB58, 0xFB5E,
- 0xFB6E, 0xFB70, 0xFB72, 0xFB75, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB80,
- 0xFB82, 0xFB85, 0xFB86, 0xFB89, 0xFB8D, 0xFB8E, 0xFB92, 0xFB94,
- 0xFB9D, 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA9, 0xFBAC, 0xFBAE,
- 0xFBB0, 0xFBB1, 0xFBB3, 0xFBB4, 0xFBB6, 0xFBB7, 0xFBB8, 0xFBD3,
- 0xFBDA, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEE, 0xFBF0, 0xFBF2, 0xFBF6,
- 0xFBF7, 0xFBF9, 0xFBFA, 0xFBFC, 0xFC42, 0xFC49, 0xFC4B,
-};
-const unsigned short *const x0212_shiftjis[] = {
- 0, x0212_shiftjis_A2, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- x0212_shiftjis_B0, x0212_shiftjis_B1, x0212_shiftjis_B2, x0212_shiftjis_B3,
- x0212_shiftjis_B4, x0212_shiftjis_B5, 0, x0212_shiftjis_B7,
- x0212_shiftjis_B8, x0212_shiftjis_B9, x0212_shiftjis_BA, x0212_shiftjis_BB,
- x0212_shiftjis_BC, x0212_shiftjis_BD, x0212_shiftjis_BE, x0212_shiftjis_BF,
- x0212_shiftjis_C0, x0212_shiftjis_C1, x0212_shiftjis_C2, x0212_shiftjis_C3,
- x0212_shiftjis_C4, x0212_shiftjis_C5, x0212_shiftjis_C6, x0212_shiftjis_C7,
- x0212_shiftjis_C8, x0212_shiftjis_C9, x0212_shiftjis_CA, x0212_shiftjis_CB,
- x0212_shiftjis_CC, x0212_shiftjis_CD, x0212_shiftjis_CE, x0212_shiftjis_CF,
- x0212_shiftjis_D0, x0212_shiftjis_D1, x0212_shiftjis_D2, x0212_shiftjis_D3,
- x0212_shiftjis_D4, x0212_shiftjis_D5, 0, x0212_shiftjis_D7,
- x0212_shiftjis_D8, x0212_shiftjis_D9, 0, 0,
- x0212_shiftjis_DC, x0212_shiftjis_DD, x0212_shiftjis_DE, x0212_shiftjis_DF,
- x0212_shiftjis_E0, x0212_shiftjis_E1, x0212_shiftjis_E2, x0212_shiftjis_E3,
- x0212_shiftjis_E4, x0212_shiftjis_E5, x0212_shiftjis_E6, x0212_shiftjis_E7,
- x0212_shiftjis_E8, x0212_shiftjis_E9, x0212_shiftjis_EA, x0212_shiftjis_EB,
- x0212_shiftjis_EC, 0, 0, 0,
- 0, 0, 0, x0212_shiftjis_F3,
- x0212_shiftjis_F4, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0,
-};
-#endif /* X0212_ENABLE */
diff --git a/ext/nkf/nkf-utf8/utf8tbl.h b/ext/nkf/nkf-utf8/utf8tbl.h
deleted file mode 100644
index 54a34271dd..0000000000
--- a/ext/nkf/nkf-utf8/utf8tbl.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * utf8tbl.h - Header file for Conversion Table
- *
- */
-
-#ifndef _UTF8TBL_H_
-#define _UTF8TBL_H_
-
-#ifdef UTF8_OUTPUT_ENABLE
-#define sizeof_euc_to_utf8_1byte 94
-#define sizeof_euc_to_utf8_2bytes 94
-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 euc_to_utf8_2bytes_x0213[];
-extern const unsigned short *const x0212_to_utf8_2bytes[];
-extern const unsigned short *const x0212_to_utf8_2bytes_x0213[];
-#define sizeof_x0213_combining_chars 5
-#define sizeof_x0213_combining_table 25
-#define sizeof_x0213_1_surrogate_table 26
-#define sizeof_x0213_2_surrogate_table 277
-extern const unsigned short x0213_combining_chars[sizeof_x0213_combining_chars];
-extern const unsigned short x0213_combining_table[sizeof_x0213_combining_table][3];
-extern const unsigned short x0213_1_surrogate_table[sizeof_x0213_1_surrogate_table][3];
-extern const unsigned short x0213_2_surrogate_table[sizeof_x0213_2_surrogate_table][3];
-#endif /* UTF8_OUTPUT_ENABLE */
-
-#ifdef UTF8_INPUT_ENABLE
-#define sizeof_utf8_to_euc_C2 64
-#define sizeof_utf8_to_euc_E5B8 64
-#define sizeof_utf8_to_euc_2bytes 112
-#define sizeof_utf8_to_euc_3bytes 16
-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 utf8_to_euc_2bytes_x0213[];
-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[];
-extern const unsigned short *const *const utf8_to_euc_3bytes_x0213[];
-#endif /* UTF8_INPUT_ENABLE */
-
-#ifdef UNICODE_NORMALIZATION
-
-#define NORMALIZATION_TABLE_LENGTH 942
-#define NORMALIZATION_TABLE_NFC_LENGTH 3
-#define NORMALIZATION_TABLE_NFD_LENGTH 9
-struct normalization_pair {
- const unsigned char nfc[NORMALIZATION_TABLE_NFC_LENGTH];
- const unsigned char nfd[NORMALIZATION_TABLE_NFD_LENGTH];
-};
-extern const struct normalization_pair normalization_table[];
-#endif
-
-#ifdef SHIFTJIS_CP932
-#define CP932_TABLE_BEGIN 0xFA
-#define CP932_TABLE_END 0xFC
-extern const unsigned short shiftjis_cp932[3][189];
-#define CP932INV_TABLE_BEGIN 0xED
-#define CP932INV_TABLE_END 0xEE
-extern const unsigned short cp932inv[2][189];
-#endif /* SHIFTJIS_CP932 */
-
-#ifdef X0212_ENABLE
-extern const unsigned short shiftjis_x0212[3][189];
-extern const unsigned short *const x0212_shiftjis[];
-#endif /* X0212_ENABLE */
-
-#endif
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
deleted file mode 100644
index c6ddee1976..0000000000
--- a/ext/nkf/nkf.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * NKF - Ruby extension for Network Kanji Filter
- *
- * original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
- *
- * $Id$
- *
- */
-
-#define RUBY_NKF_REVISION "$Revision$"
-#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
-
-#include "ruby/ruby.h"
-#include "ruby/encoding.h"
-
-/* Replace nkf's getchar/putchar for variable modification */
-/* we never use getc, ungetc */
-
-#undef getc
-#undef ungetc
-#define getc(f) (input_ctr>=i_len?-1:input[input_ctr++])
-#define ungetc(c,f) input_ctr--
-
-#define INCSIZE 32
-#undef putchar
-#undef TRUE
-#undef FALSE
-#define putchar(c) rb_nkf_putchar(c)
-
-/* Input/Output pointers */
-
-static unsigned char *output;
-static unsigned char *input;
-static int input_ctr;
-static int i_len;
-static int output_ctr;
-static int o_len;
-static int incsize;
-
-static VALUE result;
-
-static int
-rb_nkf_putchar(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[output_ctr++] = c;
-
- return c;
-}
-
-/* Include kanji filter main part */
-/* getchar and putchar will be replaced during inclusion */
-
-#define PERL_XS 1
-#include "nkf-utf8/config.h"
-#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);
- idx = rb_enc_find_index(nkf_enc_name(nkf_enc_to_base_encoding(nkf_enc)));
- if (idx < 0) {
- idx = rb_define_dummy_encoding(name);
- }
- }
- return rb_enc_from_index(idx);
-}
-
-int nkf_split_options(const char *arg)
-{
- int count = 0;
- unsigned char option[256];
- int i = 0, j = 0;
- int is_escaped = FALSE;
- int is_single_quoted = FALSE;
- int is_double_quoted = FALSE;
- for(i = 0; arg[i]; i++){
- if(j == 255){
- return -1;
- }else if(is_single_quoted){
- if(arg[i] == '\''){
- is_single_quoted = FALSE;
- }else{
- option[j++] = arg[i];
- }
- }else if(is_escaped){
- is_escaped = FALSE;
- option[j++] = arg[i];
- }else if(arg[i] == '\\'){
- is_escaped = TRUE;
- }else if(is_double_quoted){
- if(arg[i] == '"'){
- is_double_quoted = FALSE;
- }else{
- option[j++] = arg[i];
- }
- }else if(arg[i] == '\''){
- is_single_quoted = TRUE;
- }else if(arg[i] == '"'){
- is_double_quoted = TRUE;
- }else if(arg[i] == ' '){
- option[j] = '\0';
- options(option);
- j = 0;
- }else{
- option[j++] = arg[i];
- }
- }
- if(j){
- option[j] = '\0';
- options(option);
- }
- return count;
-}
-
-/*
- * call-seq:
- * NKF.nkf(opt, str) => string
- *
- * Convert _str_ and return converted result.
- * Conversion details are specified by _opt_ as String.
- *
- * require 'nkf'
- * output = NKF.nkf("-s", input)
- */
-
-static VALUE
-rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
-{
- VALUE tmp;
- reinit();
- nkf_split_options(StringValueCStr(opt));
- if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given");
-
- switch (nkf_enc_to_index(output_encoding)) {
- case UTF_8_BOM: output_encoding = nkf_enc_from_index(UTF_8); break;
- case UTF_16BE_BOM: output_encoding = nkf_enc_from_index(UTF_16BE); break;
- case UTF_16LE_BOM: output_encoding = nkf_enc_from_index(UTF_16LE); break;
- case UTF_32BE_BOM: output_encoding = nkf_enc_from_index(UTF_32BE); break;
- case UTF_32LE_BOM: output_encoding = nkf_enc_from_index(UTF_32LE); break;
- }
- output_bom_f = FALSE;
-
- incsize = INCSIZE;
-
- input_ctr = 0;
- input = (unsigned char *)StringValuePtr(src);
- i_len = RSTRING_LENINT(src);
- tmp = rb_str_new(0, i_len*3 + 10);
-
- output_ctr = 0;
- output = (unsigned char *)RSTRING_PTR(tmp);
- o_len = RSTRING_LENINT(tmp);
- *output = '\0';
-
- /* use _result_ begin*/
- result = tmp;
- kanji_convert(NULL);
- result = Qnil;
- /* use _result_ end */
-
- rb_str_set_len(tmp, output_ctr);
-
- if (mimeout_f)
- rb_enc_associate(tmp, rb_usascii_encoding());
- else
- rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
-
- return tmp;
-}
-
-
-/*
- * call-seq:
- * NKF.guess(str) => encoding
- *
- * Returns guessed encoding of _str_ by nkf routine.
- *
- */
-
-static VALUE
-rb_nkf_guess(VALUE obj, VALUE src)
-{
- reinit();
-
- input_ctr = 0;
- input = (unsigned char *)StringValuePtr(src);
- i_len = RSTRING_LENINT(src);
-
- guess_f = TRUE;
- kanji_convert( NULL );
- guess_f = FALSE;
-
- return rb_enc_from_encoding(rb_nkf_enc_get(get_guessed_code()));
-}
-
-
-/*
- * NKF - Ruby extension for Network Kanji Filter
- *
- * == Description
- *
- * This is a Ruby Extension version of nkf (Network Kanji Filter).
- * It converts the first argument and returns 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.
- * It converts input kanji code to designated kanji code
- * such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 or UTF-16.
- *
- * One of the most unique faculty of *nkf* is the guess of the input kanji encodings.
- * It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 and UTF-16.
- * So users needn't set the input kanji code explicitly.
- *
- * By default, X0201 kana is converted into X0208 kana.
- * For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
- * For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
- * To accept X0201 in Shift_JIS, use <b>-X</b>, <b>-x</b> or <b>-S</b>.
- *
- * == Flags
- *
- * === -b -u
- *
- * Output is buffered (DEFAULT), Output is unbuffered.
- *
- * === -j -s -e -w -w16 -w32
- *
- * Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
- * UTF-8N, UTF-16BE, UTF-32BE.
- * Without this option and compile option, ISO-2022-JP is assumed.
- *
- * === -J -S -E -W -W16 -W32
- *
- * Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
- * UTF-8, UTF-16, UTF-32.
- *
- * ==== -J
- *
- * Assume JIS input. It also accepts EUC-JP.
- * This is the default. This flag does not exclude Shift_JIS.
- *
- * ==== -S
- *
- * Assume Shift_JIS and X0201 kana input. It also accepts JIS.
- * EUC-JP is recognized as X0201 kana. Without <b>-x</b> flag,
- * X0201 kana (halfwidth kana) is converted into X0208.
- *
- * ==== -E
- *
- * Assume EUC-JP input. It also accepts JIS.
- * Same as -J.
- *
- * === -t
- *
- * No conversion.
- *
- * === -i_
- *
- * Output sequence to designate JIS-kanji. (DEFAULT B)
- *
- * === -o_
- *
- * Output sequence to designate ASCII. (DEFAULT B)
- *
- * === -r
- *
- * {de/en}crypt ROT13/47
- *
- * === \-h[123] --hiragana --katakana --katakana-hiragana
- *
- * [-h1 --hiragana] Katakana to Hiragana conversion.
- *
- * [-h2 --katakana] Hiragana to Katakana conversion.
- *
- * [-h3 --katakana-hiragana] Katakana to Hiragana and Hiragana to Katakana conversion.
- *
- * === -T
- *
- * Text mode output (MS-DOS)
- *
- * === -l
- *
- * ISO8859-1 (Latin-1) support
- *
- * === -f[<code>m</code> [- <code>n</code>]]
- *
- * Folding on <code>m</code> length with <code>n</code> margin in a line.
- * Without this option, fold length is 60 and fold margin is 10.
- *
- * === -F
- *
- * New line preserving line folding.
- *
- * === \-Z[0-3]
- *
- * Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
- *
- * [-Z -Z0] Convert X0208 alphabet to ASCII.
- *
- * [-Z1] Converts X0208 kankaku to single ASCII space.
- *
- * [-Z2] Converts X0208 kankaku to double ASCII spaces.
- *
- * [-Z3] Replacing Fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
- *
- * === -X -x
- *
- * Assume X0201 kana in MS-Kanji.
- * With <b>-X</b> or without this option, X0201 is converted into X0208 Kana.
- * With <b>-x</b>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
- * In JIS output, ESC-(-I is used. In EUC output, SSO is used.
- *
- * === \-B[0-2]
- *
- * Assume broken JIS-Kanji input, which lost ESC.
- * Useful when your site is using old B-News Nihongo patch.
- *
- * [-B1] allows any char after ESC-( or ESC-$.
- *
- * [-B2] forces ASCII after NL.
- *
- * === -I
- *
- * Replacing non iso-2022-jp char into a geta character
- * (substitute character in Japanese).
- *
- * === -d -c
- *
- * Delete \r in line feed, Add \r in line feed.
- *
- * === \-m[BQN0]
- *
- * MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
- * To see ISO8859-1 (Latin-1) -l is necessary.
- *
- * [-mB] Decode MIME base64 encoded stream. Remove header or other part before
- * conversion.
- *
- * [-mQ] Decode MIME quoted stream. '_' in quoted stream is converted to space.
- *
- * [-mN] Non-strict decoding.
- * It allows line break in the middle of the base64 encoding.
- *
- * [-m0] No MIME decode.
- *
- * === -M
- *
- * MIME encode. Header style. All ASCII code and control characters are intact.
- * Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
- *
- * [-MB] MIME encode Base64 stream.
- *
- * [-MQ] Perform quoted encoding.
- *
- * === -l
- *
- * Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
- * <b>-s</b>, <b>-e</b> and <b>-x</b> are not compatible with this option.
- *
- * === \-L[uwm]
- *
- * new line mode
- * Without this option, nkf doesn't convert line breaks.
- *
- * [-Lu] unix (LF)
- *
- * [-Lw] windows (CRLF)
- *
- * [-Lm] mac (CR)
- *
- * === --fj --unix --mac --msdos --windows
- *
- * convert for these system
- *
- * === --jis --euc --sjis --mime --base64
- *
- * convert for named code
- *
- * === --jis-input --euc-input --sjis-input --mime-input --base64-input
- *
- * assume input system
- *
- * === --ic=<code>input codeset</code> --oc=<code>output codeset</code>
- *
- * Set the input or output codeset.
- * NKF supports following codesets and those codeset name are case insensitive.
- *
- * [ISO-2022-JP] a.k.a. RFC1468, 7bit JIS, JUNET
- *
- * [EUC-JP (eucJP-nkf)] a.k.a. AT&T JIS, Japanese EUC, UJIS
- *
- * [eucJP-ascii] a.k.a. x-eucjp-open-19970715-ascii
- *
- * [eucJP-ms] a.k.a. x-eucjp-open-19970715-ms
- *
- * [CP51932] Microsoft Version of EUC-JP.
- *
- * [Shift_JIS] SJIS, MS-Kanji
- *
- * [Windows-31J] a.k.a. CP932
- *
- * [UTF-8] same as UTF-8N
- *
- * [UTF-8N] UTF-8 without BOM
- *
- * [UTF-8-BOM] UTF-8 with BOM
- *
- * [UTF-16] same as UTF-16BE
- *
- * [UTF-16BE] UTF-16 Big Endian without BOM
- *
- * [UTF-16BE-BOM] UTF-16 Big Endian with BOM
- *
- * [UTF-16LE] UTF-16 Little Endian without BOM
- *
- * [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}
- *
- * Specify the way that nkf handles unassigned characters.
- * Without this option, --fb-skip is assumed.
- *
- * === --prefix= <code>escape character</code> <code>target character</code> ..
- *
- * When nkf converts to Shift_JIS,
- * 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
- *
- * 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 option.
- *
- * === --cap-input
- *
- * Decode hex encoded characters.
- *
- * === --url-input
- *
- * Unescape percent escaped characters.
- *
- * === --
- *
- * Ignore rest of -option.
- */
-
-void
-Init_nkf(void)
-{
- VALUE mNKF = rb_define_module("NKF");
-
- 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("US-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-16BE")));
- rb_define_const(mNKF, "UTF32", rb_enc_from_encoding(rb_nkf_enc_get("UTF-32BE")));
-
- /* Full version string of nkf */
- rb_define_const(mNKF, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
- /* Version of nkf */
- rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION));
- /* Release date of nkf */
- rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
-}
diff --git a/ext/nkf/nkf.gemspec b/ext/nkf/nkf.gemspec
deleted file mode 100644
index 7f3bd4a4b1..0000000000
--- a/ext/nkf/nkf.gemspec
+++ /dev/null
@@ -1,24 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "nkf"
- spec.version = "0.1.2"
- spec.authors = ["NARUSE Yui"]
- spec.email = ["naruse@airemix.jp"]
-
- spec.summary = %q{Ruby extension for Network Kanji Filter}
- spec.description = %q{Ruby extension for Network Kanji Filter}
- spec.homepage = "https://github.com/ruby/nkf"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/ext/objspace/depend b/ext/objspace/depend
index 6738ea0924..d9dfc0c42b 100644
--- a/ext/objspace/depend
+++ b/ext/objspace/depend
@@ -2,6 +2,7 @@
object_tracing.o: $(RUBY_EXTCONF_H)
object_tracing.o: $(arch_hdrdir)/ruby/config.h
object_tracing.o: $(hdrdir)/ruby/assert.h
+object_tracing.o: $(hdrdir)/ruby/atomic.h
object_tracing.o: $(hdrdir)/ruby/backward.h
object_tracing.o: $(hdrdir)/ruby/backward/2/assume.h
object_tracing.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -14,6 +15,7 @@ object_tracing.o: $(hdrdir)/ruby/backward/2/stdalign.h
object_tracing.o: $(hdrdir)/ruby/backward/2/stdarg.h
object_tracing.o: $(hdrdir)/ruby/debug.h
object_tracing.o: $(hdrdir)/ruby/defines.h
+object_tracing.o: $(hdrdir)/ruby/encoding.h
object_tracing.o: $(hdrdir)/ruby/intern.h
object_tracing.o: $(hdrdir)/ruby/internal/abi.h
object_tracing.o: $(hdrdir)/ruby/internal/anyargs.h
@@ -86,6 +88,15 @@ object_tracing.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
object_tracing.o: $(hdrdir)/ruby/internal/ctype.h
object_tracing.o: $(hdrdir)/ruby/internal/dllexport.h
object_tracing.o: $(hdrdir)/ruby/internal/dosish.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/re.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/string.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/transcode.h
object_tracing.o: $(hdrdir)/ruby/internal/error.h
object_tracing.o: $(hdrdir)/ruby/internal/eval.h
object_tracing.o: $(hdrdir)/ruby/internal/event.h
@@ -129,6 +140,7 @@ object_tracing.o: $(hdrdir)/ruby/internal/intern/re.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/ruby.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/select.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+object_tracing.o: $(hdrdir)/ruby/internal/intern/set.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/signal.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/sprintf.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -148,6 +160,7 @@ object_tracing.o: $(hdrdir)/ruby/internal/special_consts.h
object_tracing.o: $(hdrdir)/ruby/internal/static_assert.h
object_tracing.o: $(hdrdir)/ruby/internal/stdalign.h
object_tracing.o: $(hdrdir)/ruby/internal/stdbool.h
+object_tracing.o: $(hdrdir)/ruby/internal/stdckdint.h
object_tracing.o: $(hdrdir)/ruby/internal/symbol.h
object_tracing.o: $(hdrdir)/ruby/internal/value.h
object_tracing.o: $(hdrdir)/ruby/internal/value_type.h
@@ -155,18 +168,45 @@ object_tracing.o: $(hdrdir)/ruby/internal/variable.h
object_tracing.o: $(hdrdir)/ruby/internal/warning_push.h
object_tracing.o: $(hdrdir)/ruby/internal/xmalloc.h
object_tracing.o: $(hdrdir)/ruby/missing.h
+object_tracing.o: $(hdrdir)/ruby/onigmo.h
+object_tracing.o: $(hdrdir)/ruby/oniguruma.h
object_tracing.o: $(hdrdir)/ruby/ruby.h
object_tracing.o: $(hdrdir)/ruby/st.h
object_tracing.o: $(hdrdir)/ruby/subst.h
+object_tracing.o: $(hdrdir)/ruby/thread_native.h
+object_tracing.o: $(top_srcdir)/ccan/check_type/check_type.h
+object_tracing.o: $(top_srcdir)/ccan/container_of/container_of.h
+object_tracing.o: $(top_srcdir)/ccan/list/list.h
+object_tracing.o: $(top_srcdir)/ccan/str/str.h
+object_tracing.o: $(top_srcdir)/id_table.h
object_tracing.o: $(top_srcdir)/internal.h
+object_tracing.o: $(top_srcdir)/internal/array.h
+object_tracing.o: $(top_srcdir)/internal/basic_operators.h
+object_tracing.o: $(top_srcdir)/internal/box.h
object_tracing.o: $(top_srcdir)/internal/compilers.h
object_tracing.o: $(top_srcdir)/internal/gc.h
+object_tracing.o: $(top_srcdir)/internal/imemo.h
+object_tracing.o: $(top_srcdir)/internal/sanitizers.h
+object_tracing.o: $(top_srcdir)/internal/serial.h
+object_tracing.o: $(top_srcdir)/internal/set_table.h
+object_tracing.o: $(top_srcdir)/internal/static_assert.h
+object_tracing.o: $(top_srcdir)/internal/vm.h
object_tracing.o: $(top_srcdir)/internal/warnings.h
+object_tracing.o: $(top_srcdir)/method.h
+object_tracing.o: $(top_srcdir)/node.h
+object_tracing.o: $(top_srcdir)/ruby_assert.h
+object_tracing.o: $(top_srcdir)/ruby_atomic.h
+object_tracing.o: $(top_srcdir)/rubyparser.h
+object_tracing.o: $(top_srcdir)/thread_pthread.h
+object_tracing.o: $(top_srcdir)/vm_core.h
+object_tracing.o: $(top_srcdir)/vm_opts.h
object_tracing.o: object_tracing.c
object_tracing.o: objspace.h
+object_tracing.o: {$(VPATH)}id.h
objspace.o: $(RUBY_EXTCONF_H)
objspace.o: $(arch_hdrdir)/ruby/config.h
objspace.o: $(hdrdir)/ruby/assert.h
+objspace.o: $(hdrdir)/ruby/atomic.h
objspace.o: $(hdrdir)/ruby/backward.h
objspace.o: $(hdrdir)/ruby/backward/2/assume.h
objspace.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -304,6 +344,7 @@ objspace.o: $(hdrdir)/ruby/internal/intern/re.h
objspace.o: $(hdrdir)/ruby/internal/intern/ruby.h
objspace.o: $(hdrdir)/ruby/internal/intern/select.h
objspace.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+objspace.o: $(hdrdir)/ruby/internal/intern/set.h
objspace.o: $(hdrdir)/ruby/internal/intern/signal.h
objspace.o: $(hdrdir)/ruby/internal/intern/sprintf.h
objspace.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -323,6 +364,7 @@ objspace.o: $(hdrdir)/ruby/internal/special_consts.h
objspace.o: $(hdrdir)/ruby/internal/static_assert.h
objspace.o: $(hdrdir)/ruby/internal/stdalign.h
objspace.o: $(hdrdir)/ruby/internal/stdbool.h
+objspace.o: $(hdrdir)/ruby/internal/stdckdint.h
objspace.o: $(hdrdir)/ruby/internal/symbol.h
objspace.o: $(hdrdir)/ruby/internal/value.h
objspace.o: $(hdrdir)/ruby/internal/value_type.h
@@ -338,10 +380,18 @@ objspace.o: $(hdrdir)/ruby/regex.h
objspace.o: $(hdrdir)/ruby/ruby.h
objspace.o: $(hdrdir)/ruby/st.h
objspace.o: $(hdrdir)/ruby/subst.h
+objspace.o: $(hdrdir)/ruby/thread_native.h
+objspace.o: $(top_srcdir)/ccan/check_type/check_type.h
+objspace.o: $(top_srcdir)/ccan/container_of/container_of.h
+objspace.o: $(top_srcdir)/ccan/list/list.h
+objspace.o: $(top_srcdir)/ccan/str/str.h
objspace.o: $(top_srcdir)/constant.h
+objspace.o: $(top_srcdir)/debug_counter.h
objspace.o: $(top_srcdir)/id_table.h
objspace.o: $(top_srcdir)/internal.h
objspace.o: $(top_srcdir)/internal/array.h
+objspace.o: $(top_srcdir)/internal/basic_operators.h
+objspace.o: $(top_srcdir)/internal/box.h
objspace.o: $(top_srcdir)/internal/class.h
objspace.o: $(top_srcdir)/internal/compilers.h
objspace.o: $(top_srcdir)/internal/gc.h
@@ -349,12 +399,24 @@ objspace.o: $(top_srcdir)/internal/hash.h
objspace.o: $(top_srcdir)/internal/imemo.h
objspace.o: $(top_srcdir)/internal/sanitizers.h
objspace.o: $(top_srcdir)/internal/serial.h
+objspace.o: $(top_srcdir)/internal/set_table.h
objspace.o: $(top_srcdir)/internal/static_assert.h
+objspace.o: $(top_srcdir)/internal/struct.h
objspace.o: $(top_srcdir)/internal/variable.h
+objspace.o: $(top_srcdir)/internal/vm.h
objspace.o: $(top_srcdir)/internal/warnings.h
+objspace.o: $(top_srcdir)/method.h
objspace.o: $(top_srcdir)/node.h
+objspace.o: $(top_srcdir)/ruby_assert.h
+objspace.o: $(top_srcdir)/ruby_atomic.h
+objspace.o: $(top_srcdir)/rubyparser.h
objspace.o: $(top_srcdir)/shape.h
objspace.o: $(top_srcdir)/symbol.h
+objspace.o: $(top_srcdir)/thread_pthread.h
+objspace.o: $(top_srcdir)/vm_core.h
+objspace.o: $(top_srcdir)/vm_debug.h
+objspace.o: $(top_srcdir)/vm_opts.h
+objspace.o: $(top_srcdir)/vm_sync.h
objspace.o: objspace.c
objspace.o: {$(VPATH)}id.h
objspace_dump.o: $(RUBY_EXTCONF_H)
@@ -498,6 +560,7 @@ objspace_dump.o: $(hdrdir)/ruby/internal/intern/re.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/ruby.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/select.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+objspace_dump.o: $(hdrdir)/ruby/internal/intern/set.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/signal.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/sprintf.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -517,6 +580,7 @@ objspace_dump.o: $(hdrdir)/ruby/internal/special_consts.h
objspace_dump.o: $(hdrdir)/ruby/internal/static_assert.h
objspace_dump.o: $(hdrdir)/ruby/internal/stdalign.h
objspace_dump.o: $(hdrdir)/ruby/internal/stdbool.h
+objspace_dump.o: $(hdrdir)/ruby/internal/stdckdint.h
objspace_dump.o: $(hdrdir)/ruby/internal/symbol.h
objspace_dump.o: $(hdrdir)/ruby/internal/value.h
objspace_dump.o: $(hdrdir)/ruby/internal/value_type.h
@@ -537,19 +601,25 @@ objspace_dump.o: $(top_srcdir)/ccan/container_of/container_of.h
objspace_dump.o: $(top_srcdir)/ccan/list/list.h
objspace_dump.o: $(top_srcdir)/ccan/str/str.h
objspace_dump.o: $(top_srcdir)/constant.h
+objspace_dump.o: $(top_srcdir)/debug_counter.h
+objspace_dump.o: $(top_srcdir)/encindex.h
objspace_dump.o: $(top_srcdir)/id_table.h
objspace_dump.o: $(top_srcdir)/internal.h
objspace_dump.o: $(top_srcdir)/internal/array.h
objspace_dump.o: $(top_srcdir)/internal/basic_operators.h
+objspace_dump.o: $(top_srcdir)/internal/box.h
objspace_dump.o: $(top_srcdir)/internal/class.h
objspace_dump.o: $(top_srcdir)/internal/compilers.h
objspace_dump.o: $(top_srcdir)/internal/gc.h
objspace_dump.o: $(top_srcdir)/internal/hash.h
objspace_dump.o: $(top_srcdir)/internal/imemo.h
+objspace_dump.o: $(top_srcdir)/internal/io.h
objspace_dump.o: $(top_srcdir)/internal/sanitizers.h
objspace_dump.o: $(top_srcdir)/internal/serial.h
+objspace_dump.o: $(top_srcdir)/internal/set_table.h
objspace_dump.o: $(top_srcdir)/internal/static_assert.h
objspace_dump.o: $(top_srcdir)/internal/string.h
+objspace_dump.o: $(top_srcdir)/internal/struct.h
objspace_dump.o: $(top_srcdir)/internal/variable.h
objspace_dump.o: $(top_srcdir)/internal/vm.h
objspace_dump.o: $(top_srcdir)/internal/warnings.h
@@ -557,11 +627,15 @@ objspace_dump.o: $(top_srcdir)/method.h
objspace_dump.o: $(top_srcdir)/node.h
objspace_dump.o: $(top_srcdir)/ruby_assert.h
objspace_dump.o: $(top_srcdir)/ruby_atomic.h
+objspace_dump.o: $(top_srcdir)/rubyparser.h
objspace_dump.o: $(top_srcdir)/shape.h
objspace_dump.o: $(top_srcdir)/symbol.h
objspace_dump.o: $(top_srcdir)/thread_pthread.h
+objspace_dump.o: $(top_srcdir)/vm_callinfo.h
objspace_dump.o: $(top_srcdir)/vm_core.h
+objspace_dump.o: $(top_srcdir)/vm_debug.h
objspace_dump.o: $(top_srcdir)/vm_opts.h
+objspace_dump.o: $(top_srcdir)/vm_sync.h
objspace_dump.o: objspace.h
objspace_dump.o: objspace_dump.c
objspace_dump.o: {$(VPATH)}id.h
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c
index c1c93c51f5..1c18bf02ee 100644
--- a/ext/objspace/object_tracing.c
+++ b/ext/objspace/object_tracing.c
@@ -53,6 +53,14 @@ make_unique_str(st_table *tbl, const char *str, long len)
}
}
+static int
+delete_unique_str_dec(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+ assert(existing);
+ *value = arg;
+ return ST_CONTINUE;
+}
+
static void
delete_unique_str(st_table *tbl, const char *str)
{
@@ -66,7 +74,7 @@ delete_unique_str(st_table *tbl, const char *str)
ruby_xfree((char *)n);
}
else {
- st_insert(tbl, (st_data_t)str, n-1);
+ st_update(tbl, (st_data_t)str, delete_unique_str_dec, (st_data_t)(n-1));
}
}
}
@@ -83,7 +91,7 @@ newobj_i(VALUE tpval, void *data)
VALUE klass = rb_tracearg_defined_class(tparg);
struct allocation_info *info;
const char *path_cstr = RTEST(path) ? make_unique_str(arg->str_table, RSTRING_PTR(path), RSTRING_LEN(path)) : 0;
- VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_class_path_cached(klass) : Qnil;
+ VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_mod_name(klass) : Qnil;
const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0;
st_data_t v;
@@ -190,22 +198,25 @@ allocation_info_tracer_memsize(const void *ptr)
}
static int
-hash_foreach_should_replace_key(st_data_t key, st_data_t value, st_data_t argp, int error)
+allocation_info_tracer_compact_update_object_table_i(st_data_t key, st_data_t value, st_data_t data)
{
- VALUE allocated_object;
+ st_table *table = (st_table *)data;
- allocated_object = (VALUE)value;
- if (allocated_object != rb_gc_location(allocated_object)) {
- return ST_REPLACE;
+ if (!rb_gc_pointer_to_heap_p(key)) {
+ struct allocation_info *info = (struct allocation_info *)value;
+ xfree(info);
+ return ST_DELETE;
}
- return ST_CONTINUE;
-}
+ if (key != rb_gc_location(key)) {
+ DURING_GC_COULD_MALLOC_REGION_START();
+ {
+ st_insert(table, rb_gc_location(key), value);
+ }
+ DURING_GC_COULD_MALLOC_REGION_END();
-static int
-hash_replace_key(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- *key = rb_gc_location((VALUE)*key);
+ return ST_DELETE;
+ }
return ST_CONTINUE;
}
@@ -216,7 +227,10 @@ allocation_info_tracer_compact(void *ptr)
struct traceobj_arg *trace_arg = (struct traceobj_arg *)ptr;
if (trace_arg->object_table &&
- st_foreach_with_replace(trace_arg->object_table, hash_foreach_should_replace_key, hash_replace_key, 0)) {
+ st_foreach(
+ trace_arg->object_table,
+ allocation_info_tracer_compact_update_object_table_i,
+ (st_data_t)trace_arg->object_table)) {
rb_raise(rb_eRuntimeError, "hash modified during iteration");
}
}
@@ -399,6 +413,13 @@ object_allocations_reporter(FILE *out, void *ptr)
fprintf(out, "== object_allocations_reporter: END\n");
}
+/*
+ * call-seq: trace_object_allocations_debug_start
+ *
+ * Starts tracing object allocations for GC debugging.
+ * If you encounter the BUG "... is T_NONE" (and so on) on your
+ * application, please try this method at the beginning of your app.
+ */
static VALUE
trace_object_allocations_debug_start(VALUE self)
{
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index e8762d1be6..38bffb07f7 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -19,7 +19,6 @@
#include "internal/hash.h"
#include "internal/imemo.h"
#include "internal/sanitizers.h"
-#include "node.h"
#include "ruby/io.h"
#include "ruby/re.h"
#include "ruby/st.h"
@@ -39,10 +38,11 @@
* information as only a *HINT*. Especially, the size of +T_DATA+ may not be
* correct.
*
- * This method is only expected to work with C Ruby.
+ * This method is only expected to work with CRuby.
*
- * From Ruby 2.2, memsize_of(obj) returns a memory size includes
- * sizeof(RVALUE).
+ * From Ruby 3.2 with Variable Width Allocation, it returns the actual slot
+ * size used plus any additional memory allocated outside the slot (such
+ * as external strings, arrays, or hash tables).
*/
static VALUE
@@ -82,15 +82,15 @@ heap_iter(void *vstart, void *vend, size_t stride, void *ptr)
VALUE v;
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
- void *poisoned = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *poisoned = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
if (RBASIC(v)->flags) {
(*ctx->cb)(v, ctx->data);
}
if (poisoned) {
- asan_poison_object(v);
+ rb_asan_poison_object(v);
}
}
@@ -108,28 +108,24 @@ each_object_with_flags(each_obj_with_flags cb, void *ctx)
/*
* call-seq:
- * ObjectSpace.memsize_of_all([klass]) -> Integer
- *
- * Return consuming memory size of all living objects in bytes.
+ * ObjectSpace.memsize_of_all(klass = nil) -> integer
*
- * If +klass+ (should be Class object) is given, return the total memory size
- * of instances of the given class.
+ * Returns the total memory size of all living objects in bytes.
*
- * Note that the returned size is incomplete. You need to deal with this
- * information as only a *HINT*. Especially, the size of +T_DATA+ may not be
- * correct.
+ * ObjectSpace.memsize_of_all # => 12502001
*
- * Note that this method does *NOT* return total malloc'ed memory size.
+ * If +klass+ is given (which must be a Class or Module), returns the total
+ * memory size of objects whose class is, or is a subclass, of +klass+.
*
- * This method can be defined by the following Ruby code:
+ * class MyClass; end
+ * ObjectSpace.memsize_of_all(MyClass) # => 0
+ * o = MyClass.new
+ * ObjectSpace.memsize_of_all(MyClass) # => 40
*
- * def memsize_of_all klass = false
- * total = 0
- * ObjectSpace.each_object{|e|
- * total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass)
- * }
- * total
- * end
+ * Note that the value returned may be an underestimate of the actual amount
+ * of memory used. Therefore, the value returned should only be used as a hint,
+ * rather than a source of truth. In particular, the size of +T_DATA+ objects may
+ * not be correct.
*
* This method is only expected to work with C Ruby.
*/
@@ -141,6 +137,7 @@ memsize_of_all_m(int argc, VALUE *argv, VALUE self)
if (argc > 0) {
rb_scan_args(argc, argv, "01", &data.klass);
+ if (!NIL_P(data.klass)) rb_obj_is_kind_of(Qnil, data.klass);
}
each_object_with_flags(total_i, &data);
@@ -170,8 +167,7 @@ setup_hash(int argc, VALUE *argv)
hash = rb_hash_new();
}
else if (!RHASH_EMPTY_P(hash)) {
- /* WB: no new reference */
- st_foreach(RHASH_TBL_RAW(hash), set_zero_i, hash);
+ rb_hash_foreach(hash, set_zero_i, (st_data_t)hash);
}
return hash;
@@ -225,23 +221,26 @@ type2sym(enum ruby_value_type i)
/*
* call-seq:
- * ObjectSpace.count_objects_size([result_hash]) -> hash
+ * ObjectSpace.count_objects_size(result_hash = {}) -> result_hash
*
* Counts objects size (in bytes) for each type.
*
- * Note that this information is incomplete. You need to deal with
- * this information as only a *HINT*. Especially, total size of
- * T_DATA may be wrong.
+ * Note that the returned size may not be accurate, so it should only
+ * be used as a hint. Specifically, the size for +T_DATA+ may be
+ * inaccurate because these are custom objects defined in Ruby and
+ * native extensions and so they may not accurately report their
+ * memory size.
*
- * It returns a hash as:
- * {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...}
+ * It returns a hash that looks like:
*
- * If the optional argument, result_hash, is given,
- * it is overwritten and returned.
- * This is intended to avoid probe effect.
+ * {TOTAL: 1461154, T_CLASS: 158280, T_MODULE: 20672, T_STRING: 527249, ...}
+ *
+ * The contents of the returned hash are implementation specific and
+ * may be changed in future versions without notice.
*
- * The contents of the returned hash is implementation defined.
- * It may be changed in future.
+ * If the optional argument, +result_hash+, is given,
+ * it is overwritten and returned.
+ * This is intended to avoid the probe effect.
*
* This method is only expected to work with C Ruby.
*/
@@ -296,28 +295,27 @@ size_t rb_sym_immortal_count(void);
/*
* call-seq:
- * ObjectSpace.count_symbols([result_hash]) -> hash
+ * ObjectSpace.count_symbols(result_hash = nil) -> hash
*
- * Counts symbols for each Symbol type.
+ * Returns a hash containing the number of objects for each Symbol type.
*
- * This method is only for MRI developers interested in performance and memory
- * usage of Ruby programs.
+ * The types of Symbols are the following:
*
- * If the optional argument, result_hash, is given, it is overwritten and
- * returned. This is intended to avoid probe effect.
+ * - +mortal_dynamic_symbol+: Symbols that are garbage collectable.
+ * - +immortal_dynamic_symbol+: Symbols that are objects allocated from the
+ * garbage collector, but are not garbage collectable.
+ * - +immortal_static_symbol+: Symbols that are not allocated from the
+ * garbage collector, and are thus not garbage collectable.
+ * - +immortal_symbol+: the sum of +immortal_dynamic_symbol+ and +immortal_static_symbol+.
*
- * Note:
- * The contents of the returned hash is implementation defined.
- * It may be changed in future.
+ * If the optional argument +result_hash+ is given, it is overwritten and
+ * returned. This is intended to avoid the probe effect.
*
- * This method is only expected to work with C Ruby.
- *
- * On this version of MRI, they have 3 types of Symbols (and 1 total counts).
+ * This method is intended for developers interested in performance and memory
+ * usage of Ruby programs. The contents of the returned hash is implementation
+ * specific and may change in the future.
*
- * * mortal_dynamic_symbol: GC target symbols (collected by GC)
- * * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC)
- * * immortal_static_symbol: Immortal symbols (do not collected by GC)
- * * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol)
+ * This method is only expected to work with C Ruby.
*/
static VALUE
@@ -338,174 +336,6 @@ count_symbols(int argc, VALUE *argv, VALUE os)
}
static void
-cn_i(VALUE v, void *n)
-{
- size_t *nodes = (size_t *)n;
-
- if (BUILTIN_TYPE(v) == T_NODE) {
- size_t s = nd_type((NODE *)v);
- nodes[s]++;
- }
-}
-
-/*
- * call-seq:
- * ObjectSpace.count_nodes([result_hash]) -> hash
- *
- * Counts nodes for each node type.
- *
- * This method is only for MRI developers interested in performance and memory
- * usage of Ruby programs.
- *
- * It returns a hash as:
- *
- * {:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...}
- *
- * If the optional argument, result_hash, is given, it is overwritten and
- * returned. This is intended to avoid probe effect.
- *
- * Note:
- * The contents of the returned hash is implementation defined.
- * It may be changed in future.
- *
- * This method is only expected to work with C Ruby.
- */
-
-static VALUE
-count_nodes(int argc, VALUE *argv, VALUE os)
-{
- size_t nodes[NODE_LAST+1];
- enum node_type i;
- VALUE hash = setup_hash(argc, argv);
-
- for (i = 0; i <= NODE_LAST; i++) {
- nodes[i] = 0;
- }
-
- each_object_with_flags(cn_i, &nodes[0]);
-
- for (i=0; i<NODE_LAST; i++) {
- if (nodes[i] != 0) {
- VALUE node;
- switch (i) {
-#define COUNT_NODE(n) case n: node = ID2SYM(rb_intern(#n)); goto set
- COUNT_NODE(NODE_SCOPE);
- COUNT_NODE(NODE_BLOCK);
- COUNT_NODE(NODE_IF);
- COUNT_NODE(NODE_UNLESS);
- COUNT_NODE(NODE_CASE);
- COUNT_NODE(NODE_CASE2);
- COUNT_NODE(NODE_CASE3);
- COUNT_NODE(NODE_WHEN);
- COUNT_NODE(NODE_IN);
- COUNT_NODE(NODE_WHILE);
- COUNT_NODE(NODE_UNTIL);
- COUNT_NODE(NODE_ITER);
- COUNT_NODE(NODE_FOR);
- COUNT_NODE(NODE_FOR_MASGN);
- COUNT_NODE(NODE_BREAK);
- COUNT_NODE(NODE_NEXT);
- COUNT_NODE(NODE_REDO);
- COUNT_NODE(NODE_RETRY);
- COUNT_NODE(NODE_BEGIN);
- COUNT_NODE(NODE_RESCUE);
- COUNT_NODE(NODE_RESBODY);
- COUNT_NODE(NODE_ENSURE);
- COUNT_NODE(NODE_AND);
- COUNT_NODE(NODE_OR);
- COUNT_NODE(NODE_MASGN);
- COUNT_NODE(NODE_LASGN);
- COUNT_NODE(NODE_DASGN);
- COUNT_NODE(NODE_GASGN);
- COUNT_NODE(NODE_IASGN);
- COUNT_NODE(NODE_CDECL);
- COUNT_NODE(NODE_CVASGN);
- COUNT_NODE(NODE_OP_ASGN1);
- COUNT_NODE(NODE_OP_ASGN2);
- COUNT_NODE(NODE_OP_ASGN_AND);
- COUNT_NODE(NODE_OP_ASGN_OR);
- COUNT_NODE(NODE_OP_CDECL);
- COUNT_NODE(NODE_CALL);
- COUNT_NODE(NODE_OPCALL);
- COUNT_NODE(NODE_FCALL);
- COUNT_NODE(NODE_VCALL);
- COUNT_NODE(NODE_QCALL);
- COUNT_NODE(NODE_SUPER);
- COUNT_NODE(NODE_ZSUPER);
- COUNT_NODE(NODE_LIST);
- COUNT_NODE(NODE_ZLIST);
- COUNT_NODE(NODE_VALUES);
- COUNT_NODE(NODE_HASH);
- COUNT_NODE(NODE_RETURN);
- COUNT_NODE(NODE_YIELD);
- COUNT_NODE(NODE_LVAR);
- COUNT_NODE(NODE_DVAR);
- COUNT_NODE(NODE_GVAR);
- COUNT_NODE(NODE_IVAR);
- COUNT_NODE(NODE_CONST);
- COUNT_NODE(NODE_CVAR);
- COUNT_NODE(NODE_NTH_REF);
- COUNT_NODE(NODE_BACK_REF);
- COUNT_NODE(NODE_MATCH);
- COUNT_NODE(NODE_MATCH2);
- COUNT_NODE(NODE_MATCH3);
- COUNT_NODE(NODE_LIT);
- COUNT_NODE(NODE_STR);
- COUNT_NODE(NODE_DSTR);
- COUNT_NODE(NODE_XSTR);
- COUNT_NODE(NODE_DXSTR);
- COUNT_NODE(NODE_EVSTR);
- COUNT_NODE(NODE_DREGX);
- COUNT_NODE(NODE_ONCE);
- COUNT_NODE(NODE_ARGS);
- COUNT_NODE(NODE_ARGS_AUX);
- COUNT_NODE(NODE_OPT_ARG);
- COUNT_NODE(NODE_KW_ARG);
- COUNT_NODE(NODE_POSTARG);
- COUNT_NODE(NODE_ARGSCAT);
- COUNT_NODE(NODE_ARGSPUSH);
- COUNT_NODE(NODE_SPLAT);
- COUNT_NODE(NODE_BLOCK_PASS);
- COUNT_NODE(NODE_DEFN);
- COUNT_NODE(NODE_DEFS);
- COUNT_NODE(NODE_ALIAS);
- COUNT_NODE(NODE_VALIAS);
- COUNT_NODE(NODE_UNDEF);
- COUNT_NODE(NODE_CLASS);
- COUNT_NODE(NODE_MODULE);
- COUNT_NODE(NODE_SCLASS);
- COUNT_NODE(NODE_COLON2);
- COUNT_NODE(NODE_COLON3);
- COUNT_NODE(NODE_DOT2);
- COUNT_NODE(NODE_DOT3);
- COUNT_NODE(NODE_FLIP2);
- COUNT_NODE(NODE_FLIP3);
- COUNT_NODE(NODE_SELF);
- COUNT_NODE(NODE_NIL);
- COUNT_NODE(NODE_TRUE);
- COUNT_NODE(NODE_FALSE);
- COUNT_NODE(NODE_ERRINFO);
- COUNT_NODE(NODE_DEFINED);
- COUNT_NODE(NODE_POSTEXE);
- COUNT_NODE(NODE_DSYM);
- COUNT_NODE(NODE_ATTRASGN);
- COUNT_NODE(NODE_LAMBDA);
- COUNT_NODE(NODE_ARYPTN);
- COUNT_NODE(NODE_FNDPTN);
- COUNT_NODE(NODE_HSHPTN);
- COUNT_NODE(NODE_ERROR);
-#undef COUNT_NODE
- case NODE_LAST: break;
- }
- UNREACHABLE;
- set:
- rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
- }
- }
- return hash;
-}
-
-static void
cto_i(VALUE v, void *data)
{
VALUE hash = (VALUE)data;
@@ -534,32 +364,22 @@ cto_i(VALUE v, void *data)
/*
* call-seq:
- * ObjectSpace.count_tdata_objects([result_hash]) -> hash
- *
- * Counts objects for each +T_DATA+ type.
- *
- * This method is only for MRI developers interested in performance and memory
- * usage of Ruby programs.
+ * ObjectSpace.count_tdata_objects(result_hash = nil) -> hash
*
- * It returns a hash as:
+ * Returns a hash containing the number of objects for each +T_DATA+ type.
+ * The keys are Class objects when the +T_DATA+ object has an associated class,
+ * or Symbol objects of the name defined in the +rb_data_type_struct+ for internal
+ * +T_DATA+ objects.
*
- * {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6,
- * :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99,
- * ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1,
- * Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2}
- * # T_DATA objects existing at startup on r32276.
+ * ObjectSpace.count_tdata_objects
+ * # => {RBS::Location => 39255, marshal_compat_table: 1, Encoding => 103, mutex: 1, ... }
*
- * If the optional argument, result_hash, is given, it is overwritten and
- * returned. This is intended to avoid probe effect.
+ * If the optional argument +result_hash+ is given, it is overwritten and
+ * returned. This is intended to avoid the probe effect.
*
- * The contents of the returned hash is implementation specific and may change
- * in the future.
- *
- * In this version, keys are Class object or Symbol object.
- *
- * If object is kind of normal (accessible) object, the key is Class object.
- * If object is not a kind of normal (internal) object, the key is symbol
- * name, registered by rb_data_type_struct.
+ * This method is intended for developers interested in performance and memory
+ * usage of Ruby programs. The contents of the returned hash is implementation
+ * specific and may change in the future.
*
* This method is only expected to work with C Ruby.
*/
@@ -598,28 +418,22 @@ count_imemo_objects_i(VALUE v, void *data)
/*
* call-seq:
- * ObjectSpace.count_imemo_objects([result_hash]) -> hash
- *
- * Counts objects for each +T_IMEMO+ type.
+ * ObjectSpace.count_imemo_objects(result_hash = nil) -> hash
*
- * This method is only for MRI developers interested in performance and memory
- * usage of Ruby programs.
+ * Returns a hash containing the number of objects for each +T_IMEMO+ type.
+ * The keys are Symbol objects of the +T_IMEMO+ type name.
+ * +T_IMEMO+ objects are Ruby internal objects that are not visible to Ruby
+ * programs.
*
- * It returns a hash as:
+ * ObjectSpace.count_imemo_objects
+ * # => {imemo_callcache: 5482, imemo_constcache: 1258, imemo_ment: 13906, ... }
*
- * {:imemo_ifunc=>8,
- * :imemo_svar=>7,
- * :imemo_cref=>509,
- * :imemo_memo=>1,
- * :imemo_throw_data=>1}
+ * If the optional argument +result_hash+ is given, it is overwritten and
+ * returned. This is intended to avoid the probe effect.
*
- * 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 specific and may change
- * in the future.
- *
- * In this version, keys are symbol objects.
+ * This method is intended for developers interested in performance and memory
+ * usage of Ruby programs. The contents of the returned hash is implementation
+ * specific and may change in the future.
*
* This method is only expected to work with C Ruby.
*/
@@ -640,11 +454,13 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
INIT_IMEMO_TYPE_ID(imemo_ment);
INIT_IMEMO_TYPE_ID(imemo_iseq);
INIT_IMEMO_TYPE_ID(imemo_tmpbuf);
- INIT_IMEMO_TYPE_ID(imemo_ast);
- INIT_IMEMO_TYPE_ID(imemo_parser_strterm);
+ INIT_IMEMO_TYPE_ID(imemo_cvar_entry);
INIT_IMEMO_TYPE_ID(imemo_callinfo);
INIT_IMEMO_TYPE_ID(imemo_callcache);
INIT_IMEMO_TYPE_ID(imemo_constcache);
+ INIT_IMEMO_TYPE_ID(imemo_fields);
+ INIT_IMEMO_TYPE_ID(imemo_subclasses);
+ INIT_IMEMO_TYPE_ID(imemo_cdhash);
#undef INIT_IMEMO_TYPE_ID
}
@@ -718,7 +534,7 @@ reachable_object_from_i(VALUE obj, void *data_ptr)
VALUE key = obj;
VALUE val = obj;
- if (rb_objspace_markable_object_p(obj)) {
+ if (!rb_objspace_garbage_object_p(obj)) {
if (NIL_P(rb_hash_lookup(data->refs, key))) {
rb_hash_aset(data->refs, key, Qtrue);
@@ -743,48 +559,43 @@ collect_values(st_data_t key, st_data_t value, st_data_t data)
* call-seq:
* ObjectSpace.reachable_objects_from(obj) -> array or nil
*
- * [MRI specific feature] Return all reachable objects from `obj'.
- *
- * This method returns all reachable objects from `obj'.
+ * Returns all reachable objects from +obj+ as an array:
*
- * If `obj' has two or more references to the same object `x', then returned
- * array only includes one `x' object.
+ * ObjectSpace.reachable_objects_from(['a', 'b', 'c'])
+ * #=> [Array, 'a', 'b', 'c']
*
- * If `obj' is a non-markable (non-heap management) object such as true,
- * false, nil, symbols and Fixnums (and Flonum) then it simply returns nil.
+ * The returned array is deduplicated, meaning that if +obj+ refers
+ * to another object more than once, it will only be added to the array
+ * once:
*
- * If `obj' has references to an internal object, then it returns instances of
- * ObjectSpace::InternalObjectWrapper class. This object contains a reference
- * to an internal object and you can check the type of internal object with
- * `type' method.
+ * ObjectSpace.reachable_objects_from([v = 'a', v, v])
+ * #=> [Array, 'a']
*
- * If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this
- * method returns all reachable object from an internal object, which is
- * pointed by `obj'.
+ * Returns +nil+ if +obj+ is not a markable object (i.e. non-heap
+ * managed) object. Non-markable objects include +true+, +false+,
+ * +nil+, certain symbols, small integers, and floats:
*
- * With this method, you can find memory leaks.
+ * ObjectSpace.reachable_objects_from(1)
+ * #=> nil
*
- * This method is only expected to work except with C Ruby.
+ * All references to internal objects in the returned array are wrapped
+ * using ObjectSpace::InternalObjectWrapper objects. This object contains
+ * a reference to the internal object and the type of the object can
+ * be accessed using the ObjectSpace::InternalObjectWrapper#type method.
*
- * Example:
- * ObjectSpace.reachable_objects_from(['a', 'b', 'c'])
- * #=> [Array, 'a', 'b', 'c']
+ * If +obj+ is instance of ObjectSpace::InternalObjectWrapper, then this
+ * method returns all reachable object from the internal object.
*
- * ObjectSpace.reachable_objects_from(['a', 'a', 'a'])
- * #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id
- *
- * ObjectSpace.reachable_objects_from([v = 'a', v, v])
- * #=> [Array, 'a']
- *
- * ObjectSpace.reachable_objects_from(1)
- * #=> nil # 1 is not markable (heap managed) object
+ * This method is useful for debugging purposes, such as finding
+ * memory leaks.
*
+ * This method is only expected to work with C Ruby.
*/
static VALUE
reachable_objects_from(VALUE self, VALUE obj)
{
- if (rb_objspace_markable_object_p(obj)) {
+ if (!RB_SPECIAL_CONST_P(obj)) {
struct rof_data data;
if (rb_typeddata_is_kind_of(obj, &iow_data_type)) {
@@ -831,7 +642,7 @@ reachable_object_from_root_i(const char *category, VALUE obj, void *ptr)
rb_hash_aset(data->categories, category_str, category_objects);
}
- if (rb_objspace_markable_object_p(obj) &&
+ if (!rb_objspace_garbage_object_p(obj) &&
obj != data->categories &&
obj != data->last_category_objects) {
if (rb_objspace_internal_object_p(obj)) {
@@ -933,7 +744,7 @@ objspace_internal_super_of(VALUE self, VALUE obj)
case T_MODULE:
case T_CLASS:
case T_ICLASS:
- super = RCLASS_SUPER(obj);
+ super = rb_class_super_of(obj);
break;
default:
rb_raise(rb_eArgError, "class or module is expected");
@@ -975,7 +786,6 @@ Init_objspace(void)
rb_define_module_function(rb_mObjSpace, "count_objects_size", count_objects_size, -1);
rb_define_module_function(rb_mObjSpace, "count_symbols", count_symbols, -1);
- rb_define_module_function(rb_mObjSpace, "count_nodes", count_nodes, -1);
rb_define_module_function(rb_mObjSpace, "count_tdata_objects", count_tdata_objects, -1);
rb_define_module_function(rb_mObjSpace, "count_imemo_objects", count_imemo_objects, -1);
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index d8a11083d6..68ada01af3 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -18,6 +18,7 @@
#include "internal/class.h"
#include "internal/gc.h"
#include "internal/hash.h"
+#include "internal/io.h"
#include "internal/string.h"
#include "internal/sanitizers.h"
#include "symbol.h"
@@ -27,16 +28,18 @@
#include "ruby/debug.h"
#include "ruby/util.h"
#include "ruby/io.h"
-#include "vm_core.h"
+#include "vm_callinfo.h"
+#include "vm_sync.h"
RUBY_EXTERN const char ruby_hexdigits[];
#define BUFFER_CAPACITY 4096
struct dump_config {
- VALUE type;
- VALUE stream;
+ VALUE given_output;
+ VALUE output_io;
VALUE string;
+ FILE *stream;
const char *root_category;
VALUE cur_obj;
VALUE cur_obj_klass;
@@ -56,7 +59,7 @@ dump_flush(struct dump_config *dc)
{
if (dc->buffer_len) {
if (dc->stream) {
- size_t written = rb_io_bufwrite(dc->stream, dc->buffer, dc->buffer_len);
+ size_t written = fwrite(dc->buffer, sizeof(dc->buffer[0]), dc->buffer_len, dc->stream);
if (written < dc->buffer_len) {
MEMMOVE(dc->buffer, dc->buffer + written, char, dc->buffer_len - written);
dc->buffer_len -= written;
@@ -166,10 +169,8 @@ dump_append_c(struct dump_config *dc, unsigned char c)
}
static void
-dump_append_ref(struct dump_config *dc, VALUE ref)
+dump_append_ptr(struct dump_config *dc, VALUE ref)
{
- RUBY_ASSERT(ref > 0);
-
char buffer[roomof(sizeof(VALUE) * CHAR_BIT, 4) + rb_strlen_lit("\"0x\"")];
char *buffer_start, *buffer_end;
@@ -186,6 +187,14 @@ dump_append_ref(struct dump_config *dc, VALUE ref)
}
static void
+dump_append_ref(struct dump_config *dc, VALUE ref)
+{
+ RUBY_ASSERT(ref > 0);
+ dump_append_ptr(dc, ref);
+}
+
+
+static void
dump_append_string_value(struct dump_config *dc, VALUE obj)
{
long i;
@@ -358,8 +367,9 @@ dump_append_string_content(struct dump_config *dc, VALUE obj)
static inline void
dump_append_id(struct dump_config *dc, ID id)
{
- if (is_instance_id(id)) {
- dump_append_string_value(dc, rb_sym2str(ID2SYM(id)));
+ VALUE str = rb_sym2str(ID2SYM(id));
+ if (RTEST(str)) {
+ dump_append_string_value(dc, str);
}
else {
dump_append(dc, "\"ID_INTERNAL(");
@@ -375,8 +385,7 @@ dump_object(VALUE obj, struct dump_config *dc)
size_t memsize;
struct allocation_info *ainfo = objspace_lookup_allocation_info(obj);
rb_io_t *fptr;
- ID flags[RB_OBJ_GC_FLAGS_MAX];
- size_t n, i;
+ ID mid;
if (SPECIAL_CONST_P(obj)) {
dump_append_special_const(dc, obj);
@@ -385,9 +394,10 @@ dump_object(VALUE obj, struct dump_config *dc)
dc->cur_obj = obj;
dc->cur_obj_references = 0;
- if (BUILTIN_TYPE(obj) == T_NODE || BUILTIN_TYPE(obj) == T_IMEMO) {
+ if (BUILTIN_TYPE(obj) == T_NODE || (BUILTIN_TYPE(obj) == T_IMEMO && !IMEMO_TYPE_P(obj, imemo_fields))) {
dc->cur_obj_klass = 0;
- } else {
+ }
+ else {
dc->cur_obj_klass = RBASIC_CLASS(obj);
}
@@ -405,9 +415,11 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, obj_type(obj));
dump_append(dc, "\"");
- size_t shape_id = rb_shape_get_shape_id(obj);
- dump_append(dc, ", \"shape_id\":");
- dump_append_sizet(dc, shape_id);
+ if (BUILTIN_TYPE(obj) != T_IMEMO || IMEMO_TYPE_P(obj, imemo_fields)) {
+ size_t shape_id = rb_obj_shape_id(obj) & SHAPE_ID_OFFSET_MASK;
+ dump_append(dc, ", \"shape_id\":");
+ dump_append_sizet(dc, shape_id);
+ }
dump_append(dc, ", \"slot_size\":");
dump_append_sizet(dc, dc->cur_page_slot_size);
@@ -428,6 +440,36 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, ", \"imemo_type\":\"");
dump_append(dc, rb_imemo_name(imemo_type(obj)));
dump_append(dc, "\"");
+
+ switch (imemo_type(obj)) {
+ case imemo_callinfo:
+ mid = vm_ci_mid((const struct rb_callinfo *)obj);
+ if (mid != 0) {
+ dump_append(dc, ", \"mid\":");
+ dump_append_id(dc, mid);
+ }
+ break;
+
+ case imemo_callcache:
+ {
+ VALUE klass = ((const struct rb_callcache *)obj)->klass;
+ if (klass != Qundef) {
+ mid = vm_cc_cme((const struct rb_callcache *)obj)->called_id;
+ if (mid != 0) {
+ dump_append(dc, ", \"called_id\":");
+ dump_append_id(dc, mid);
+
+ }
+
+ dump_append(dc, ", \"receiver_class\":");
+ dump_append_ref(dc, klass);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
break;
case T_SYMBOL:
@@ -439,6 +481,8 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, ", \"embedded\":true");
if (FL_TEST(obj, RSTRING_FSTR))
dump_append(dc, ", \"fstring\":true");
+ if (CHILLED_STRING_P(obj))
+ dump_append(dc, ", \"chilled\":true");
if (STR_SHARED_P(obj))
dump_append(dc, ", \"shared\":true");
else
@@ -499,7 +543,7 @@ dump_object(VALUE obj, struct dump_config *dc)
case T_CLASS:
dump_append(dc, ", \"variation_count\":");
- dump_append_d(dc, RCLASS_EXT(obj)->variation_count);
+ dump_append_d(dc, rb_class_variation_count(obj));
case T_MODULE:
if (rb_class_get_superclass(obj)) {
@@ -510,9 +554,8 @@ dump_object(VALUE obj, struct dump_config *dc)
if (dc->cur_obj_klass) {
VALUE mod_name = rb_mod_name(obj);
if (!NIL_P(mod_name)) {
- dump_append(dc, ", \"name\":\"");
- dump_append(dc, RSTRING_PTR(mod_name));
- dump_append(dc, "\"");
+ dump_append(dc, ", \"name\":");
+ dump_append_string_value(dc, mod_name);
}
else {
VALUE real_mod_name = rb_mod_name(rb_class_real(obj));
@@ -523,17 +566,22 @@ dump_object(VALUE obj, struct dump_config *dc)
}
}
- if (FL_TEST(obj, FL_SINGLETON)) {
+ if (rb_class_singleton_p(obj)) {
dump_append(dc, ", \"singleton\":true");
}
}
break;
case T_DATA:
- if (RTYPEDDATA_P(obj)) {
+ {
+ const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
dump_append(dc, ", \"struct\":\"");
- dump_append(dc, RTYPEDDATA_TYPE(obj)->wrap_struct_name);
+ dump_append(dc, type->wrap_struct_name);
dump_append(dc, "\"");
+ if (!(type->flags & RUBY_TYPED_FREE_IMMEDIATELY) &&
+ type->function.dfree != RUBY_DEFAULT_FREE) {
+ dump_append(dc, ", \"free_immediately\":false");
+ }
}
break;
@@ -544,14 +592,14 @@ dump_object(VALUE obj, struct dump_config *dc)
break;
case T_OBJECT:
- if (FL_TEST(obj, ROBJECT_EMBED)) {
+ if (!FL_TEST_RAW(obj, ROBJECT_HEAP)) {
dump_append(dc, ", \"embedded\":true");
}
dump_append(dc, ", \"ivars\":");
- dump_append_lu(dc, ROBJECT_IV_COUNT(obj));
- if (rb_shape_obj_too_complex(obj)) {
- dump_append(dc, ", \"too_complex_shape\":true");
+ dump_append_lu(dc, ROBJECT_FIELDS_COUNT(obj));
+ if (rb_obj_shape_complex_p(obj)) {
+ dump_append(dc, ", \"complex_shape\":true");
}
break;
@@ -599,14 +647,24 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append_sizet(dc, memsize);
}
- if ((n = rb_obj_gc_flags(obj, flags, sizeof(flags))) > 0) {
- dump_append(dc, ", \"flags\":{");
- for (i=0; i<n; i++) {
- dump_append(dc, "\"");
- dump_append(dc, rb_id2name(flags[i]));
- dump_append(dc, "\":true");
- if (i != n-1) dump_append(dc, ", ");
+ struct rb_gc_object_metadata_entry *gc_metadata = rb_gc_object_metadata(obj);
+ for (int i = 0; gc_metadata[i].name != 0; i++) {
+ if (i == 0) {
+ dump_append(dc, ", \"flags\":{");
+ }
+ else {
+ dump_append(dc, ", ");
}
+
+ dump_append(dc, "\"");
+ dump_append(dc, rb_id2name(gc_metadata[i].name));
+ dump_append(dc, "\":");
+ dump_append_special_const(dc, gc_metadata[i].val);
+ }
+
+ /* If rb_gc_object_metadata had any entries, we need to close the opening
+ * `"flags":{`. */
+ if (gc_metadata[0].name != 0) {
dump_append(dc, "}");
}
@@ -619,15 +677,15 @@ heap_i(void *vstart, void *vend, size_t stride, void *data)
struct dump_config *dc = (struct dump_config *)data;
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
dc->cur_page_slot_size = stride;
if (dc->full_heap || RBASIC(v)->flags)
dump_object(v, dc);
if (ptr) {
- asan_poison_object(v);
+ rb_asan_poison_object(v);
}
}
return 0;
@@ -658,16 +716,34 @@ root_obj_i(const char *category, VALUE obj, void *data)
static void
dump_output(struct dump_config *dc, VALUE output, VALUE full, VALUE since, VALUE shapes)
{
-
+ dc->given_output = output;
dc->full_heap = 0;
dc->buffer_len = 0;
if (TYPE(output) == T_STRING) {
- dc->stream = Qfalse;
+ dc->stream = NULL;
dc->string = output;
}
else {
- dc->stream = output;
+ rb_io_t *fptr;
+ // Output should be an IO, typecheck and get a FILE* for writing.
+ // We cannot write with the usual IO code here because writes
+ // interleave with calls to rb_gc_mark(). The usual IO code can
+ // cause a thread switch, raise exceptions, and even run arbitrary
+ // ruby code through the fiber scheduler.
+ //
+ // Mark functions generally can't handle these possibilities so
+ // the usual IO code is unsafe in this context. (For example,
+ // there are many ways to crash when ruby code runs and mutates
+ // the execution context while rb_execution_context_mark() is in
+ // progress.)
+ //
+ // Using FILE* isn't perfect, but it avoids the most acute problems.
+ output = rb_io_get_io(output);
+ dc->output_io = rb_io_get_write_io(output);
+ rb_io_flush(dc->output_io);
+ GetOpenFile(dc->output_io, fptr);
+ dc->stream = rb_io_stdio_file(fptr);
dc->string = Qfalse;
}
@@ -691,24 +767,25 @@ dump_result(struct dump_config *dc)
{
dump_flush(dc);
+ if (dc->stream) {
+ fflush(dc->stream);
+ }
if (dc->string) {
return dc->string;
}
- else {
- rb_io_flush(dc->stream);
- return dc->stream;
- }
+ return dc->given_output;
}
-/* :nodoc: */
static VALUE
-objspace_dump(VALUE os, VALUE obj, VALUE output)
+dump_locked(void *args_p)
{
struct dump_config dc = {0,};
+ VALUE obj = ((VALUE*)args_p)[0];
+ VALUE output = ((VALUE*)args_p)[1];
+
if (!RB_SPECIAL_CONST_P(obj)) {
dc.cur_page_slot_size = rb_gc_obj_slot_size(obj);
}
-
dump_output(&dc, output, Qnil, Qnil, Qnil);
dump_object(obj, &dc);
@@ -716,79 +793,73 @@ objspace_dump(VALUE os, VALUE obj, VALUE output)
return dump_result(&dc);
}
+/* :nodoc: */
+static VALUE
+objspace_dump(VALUE os, VALUE obj, VALUE output)
+{
+ VALUE args[2];
+ args[0] = obj;
+ args[1] = output;
+ return rb_vm_lock_with_barrier(dump_locked, (void*)args);
+}
+
static void
-shape_i(rb_shape_t *shape, void *data)
+shape_id_i(shape_id_t shape_id, void *data)
{
struct dump_config *dc = (struct dump_config *)data;
- size_t shape_id = rb_shape_id(shape);
if (shape_id < dc->shapes_since) {
return;
}
dump_append(dc, "{\"address\":");
- dump_append_ref(dc, (VALUE)shape);
+ dump_append_ref(dc, (VALUE)RSHAPE(shape_id));
dump_append(dc, ", \"type\":\"SHAPE\", \"id\":");
dump_append_sizet(dc, shape_id);
- if (shape->type != SHAPE_ROOT) {
+ if (RSHAPE_TYPE(shape_id) != SHAPE_ROOT) {
dump_append(dc, ", \"parent_id\":");
- dump_append_lu(dc, shape->parent_id);
+ dump_append_lu(dc, RSHAPE_PARENT_OFFSET(shape_id));
}
dump_append(dc, ", \"depth\":");
- dump_append_sizet(dc, rb_shape_depth(shape));
+ dump_append_sizet(dc, rb_shape_depth(shape_id));
- dump_append(dc, ", \"shape_type\":");
- switch((enum shape_type)shape->type) {
+ switch (RSHAPE_TYPE(shape_id)) {
case SHAPE_ROOT:
- dump_append(dc, "\"ROOT\"");
+ dump_append(dc, ", \"shape_type\":\"ROOT\"");
break;
case SHAPE_IVAR:
- dump_append(dc, "\"IVAR\"");
+ dump_append(dc, ", \"shape_type\":\"IVAR\"");
dump_append(dc, ",\"edge_name\":");
- dump_append_id(dc, shape->edge_name);
+ dump_append_id(dc, RSHAPE_EDGE_NAME(shape_id));
break;
- case SHAPE_FROZEN:
- dump_append(dc, "\"FROZEN\"");
+ case SHAPE_OBJ_ID:
+ dump_append(dc, ", \"shape_type\":\"OBJ_ID\"");
break;
- case SHAPE_CAPACITY_CHANGE:
- dump_append(dc, "\"CAPACITY_CHANGE\"");
- dump_append(dc, ", \"capacity\":");
- dump_append_sizet(dc, shape->capacity);
- break;
- case SHAPE_INITIAL_CAPACITY:
- dump_append(dc, "\"INITIAL_CAPACITY\"");
- dump_append(dc, ", \"capacity\":");
- dump_append_sizet(dc, shape->capacity);
- break;
- case SHAPE_T_OBJECT:
- dump_append(dc, "\"T_OBJECT\"");
- break;
- case SHAPE_OBJ_TOO_COMPLEX:
- dump_append(dc, "\"OBJ_TOO_COMPLEX\"");
- break;
- default:
- rb_bug("[objspace] unexpected shape type");
}
dump_append(dc, ", \"edges\":");
- dump_append_sizet(dc, rb_shape_edges_count(shape));
+ dump_append_sizet(dc, rb_shape_edges_count(shape_id));
dump_append(dc, ", \"memsize\":");
- dump_append_sizet(dc, rb_shape_memsize(shape));
+ dump_append_sizet(dc, rb_shape_memsize(shape_id));
dump_append(dc, "}\n");
}
-/* :nodoc: */
static VALUE
-objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
+dump_all_locked(void *args_p)
{
struct dump_config dc = {0,};
+ VALUE output = ((VALUE*)args_p)[0];
+ VALUE full = ((VALUE*)args_p)[1];
+ VALUE since = ((VALUE*)args_p)[2];
+ VALUE shapes = ((VALUE*)args_p)[3];
+
dump_output(&dc, output, full, since, shapes);
if (!dc.partial_dump || dc.since == 0) {
@@ -798,7 +869,7 @@ objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
}
if (RTEST(shapes)) {
- rb_shape_each_shape(shape_i, &dc);
+ rb_shape_each_shape_id(shape_id_i, &dc);
}
/* dump all objects */
@@ -809,17 +880,41 @@ objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
/* :nodoc: */
static VALUE
-objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
+objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
+{
+ VALUE args[4];
+ args[0] = output;
+ args[1] = full;
+ args[2] = since;
+ args[3] = shapes;
+ return rb_vm_lock_with_barrier(dump_all_locked, (void*)args);
+}
+
+static VALUE
+dump_shapes_locked(void *args_p)
{
struct dump_config dc = {0,};
+ VALUE output = ((VALUE*)args_p)[0];
+ VALUE shapes = ((VALUE*)args_p)[1];
+
dump_output(&dc, output, Qfalse, Qnil, shapes);
if (RTEST(shapes)) {
- rb_shape_each_shape(shape_i, &dc);
+ rb_shape_each_shape_id(shape_id_i, &dc);
}
return dump_result(&dc);
}
+/* :nodoc: */
+static VALUE
+objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
+{
+ VALUE args[2];
+ args[0] = output;
+ args[1] = shapes;
+ return rb_vm_lock_with_barrier(dump_shapes_locked, (void*)args);
+}
+
void
Init_objspace_dump(VALUE rb_mObjSpace)
{
@@ -827,11 +922,11 @@ Init_objspace_dump(VALUE rb_mObjSpace)
#if 0
rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
#endif
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ RB_EXT_RACTOR_SAFE(true);
+#endif
rb_define_module_function(rb_mObjSpace, "_dump", objspace_dump, 2);
rb_define_module_function(rb_mObjSpace, "_dump_all", objspace_dump_all, 4);
rb_define_module_function(rb_mObjSpace, "_dump_shapes", objspace_dump_shapes, 2);
-
- /* force create static IDs */
- rb_obj_gc_flags(rb_mObjSpace, 0, 0);
}
diff --git a/ext/openssl/History.md b/ext/openssl/History.md
index 1e0df7dd87..ce01b3e0f2 100644
--- a/ext/openssl/History.md
+++ b/ext/openssl/History.md
@@ -1,3 +1,309 @@
+Version 4.0.2
+=============
+
+Merged changes in 3.2.4 and 3.3.3.
+
+
+Version 4.0.1
+=============
+
+Notable changes
+---------------
+
+* Add `sync_close` keyword argument to `OpenSSL::SSL::SSLSocket.new` as a
+ short-hand for setting `sync_close` attribute on the created `SSLSocket`
+ instance.
+ [[GitHub #955]](https://github.com/ruby/openssl/issues/955)
+ [[GitHub #996]](https://github.com/ruby/openssl/pull/996)
+
+
+Bug fixes
+---------
+
+* Fix uninitialized variables in `OpenSSL::OCSP::BasicResponse#status`.
+ [[GitHub #1004]](https://github.com/ruby/openssl/pull/1004)
+
+
+Version 4.0.0
+=============
+
+Compatibility
+-------------
+
+* Ruby >= 2.7
+* OpenSSL >= 1.1.1, LibreSSL >= 3.9, and AWS-LC 1.66.0
+ - Removed support for OpenSSL 1.0.2-1.1.0 and LibreSSL 3.1-3.8.
+ [[GitHub #835]](https://github.com/ruby/openssl/issues/835)
+ - Added support for AWS-LC.
+ [[GitHub #833]](https://github.com/ruby/openssl/issues/833)
+
+
+Notable changes
+---------------
+
+* `OpenSSL::SSL`
+ - Reduce overhead when writing to `OpenSSL::SSL::SSLSocket`. `#syswrite` no
+ longer creates a temporary String object.
+ [[GitHub #831]](https://github.com/ruby/openssl/pull/831)
+ - Make `OpenSSL::SSL::SSLContext#min_version=` and `#max_version=` wrap the
+ corresponding OpenSSL APIs directly, and remove the fallback to SSL options.
+ [[GitHub #849]](https://github.com/ruby/openssl/pull/849)
+ - Add `OpenSSL::SSL::SSLContext#sigalgs=` and `#client_sigalgs=` for
+ specifying signature algorithms to use for connections.
+ [[GitHub #895]](https://github.com/ruby/openssl/pull/895)
+ - Rename `OpenSSL::SSL::SSLContext#ecdh_curves=` to `#groups=` following
+ the underlying OpenSSL API rename. This method is no longer specific to
+ ECDHE. The old method remains as an alias.
+ [[GitHub #900]](https://github.com/ruby/openssl/pull/900)
+ - Add `OpenSSL::SSL::SSLSocket#sigalg`, `#peer_sigalg`, and `#group` for
+ getting the signature algorithm and the key agreement group used in the
+ current connection.
+ [[GitHub #908]](https://github.com/ruby/openssl/pull/908)
+ - Enable `SSL_CTX_set_dh_auto()` for servers by default.
+ [[GitHub #924]](https://github.com/ruby/openssl/pull/924)
+ - Improve Ractor compatibility. Note that the internal-use constant
+ `OpenSSL::SSL::SSLContext::DEFAULT_PARAMS` is now frozen.
+ [[GitHub #925]](https://github.com/ruby/openssl/pull/925)
+* `OpenSSL::PKey`
+ - Remove `OpenSSL::PKey::EC::Point#mul` support with array arguments. The
+ underlying OpenSSL API has been removed, and the method has been deprecated
+ since ruby/openssl v3.0.0.
+ [[GitHub #843]](https://github.com/ruby/openssl/pull/843)
+ - `OpenSSL::PKey::{RSA,DSA,DH}#params` uses `nil` to indicate missing fields
+ instead of the number `0`.
+ [[GitHub #774]](https://github.com/ruby/openssl/pull/774)
+ - Unify `OpenSSL::PKey::PKeyError` classes. The former subclasses
+ `OpenSSL::PKey::DHError`, `OpenSSL::PKey::DSAError`,
+ `OpenSSL::PKey::ECError`, and `OpenSSL::PKey::RSAError` have been merged
+ into a single class.
+ [[GitHub #929]](https://github.com/ruby/openssl/pull/929)
+* `OpenSSL::Cipher`
+ - `OpenSSL::Cipher#encrypt` and `#decrypt` no longer accept arguments.
+ Passing passwords has been deprecated since Ruby 1.8.2 (released in 2004).
+ [[GitHub #887]](https://github.com/ruby/openssl/pull/887)
+ - `OpenSSL::Cipher#final` raises `OpenSSL::Cipher::AuthTagError` when the
+ integrity check fails for AEAD ciphers. `OpenSSL::Cipher::AuthTagError` is a
+ new subclass of `OpenSSL::Cipher::CipherError`, which was previously raised.
+ [[GitHub #939]](https://github.com/ruby/openssl/pull/939)
+ - `OpenSSL::Cipher.new` now raises `OpenSSL::Cipher::CipherError` instead of
+ `RuntimeError` when OpenSSL does not recognize the algorithm.
+ [[GitHub #958]](https://github.com/ruby/openssl/pull/958)
+ - Add support for "fetched" cipher algorithms with OpenSSL 3.0 or later.
+ [[GitHub #958]](https://github.com/ruby/openssl/pull/958)
+* `OpenSSL::Digest`
+ - `OpenSSL::Digest.new` now raises `OpenSSL::Digest::DigestError` instead of
+ `RuntimeError` when OpenSSL does not recognize the algorithm.
+ [[GitHub #958]](https://github.com/ruby/openssl/pull/958)
+ - Add support for "fetched" digest algorithms with OpenSSL 3.0 or later.
+ [[GitHub #958]](https://github.com/ruby/openssl/pull/958)
+* `OpenSSL::ASN1.decode` now assumes a 1950-2049 year range for `UTCTime`
+ according to RFC 5280. It previously used a 1969-2068 range. The encoder
+ has always used the 1950-2049 range.
+ [[GitHub #909]](https://github.com/ruby/openssl/pull/909)
+* `OpenSSL::OpenSSLError`, the base class for all ruby/openssl errors, carry
+ an additional attribute `#errors` to keep the content of OpenSSL's error
+ queue. Also, add `#detailed_message` for Ruby 3.2 or later.
+ [[GitHub #976]](https://github.com/ruby/openssl/pull/976)
+* `OpenSSL::PKCS7.new` raises `OpenSSL::PKCS7::PKCS7Error` instead of
+ `ArgumentError` on error to be consistent with other constructors.
+ [[GitHub #983]](https://github.com/ruby/openssl/pull/983)
+
+
+Version 3.3.3
+=============
+
+Merged changes in 3.2.4.
+
+
+Version 3.3.2
+=============
+
+Merged changes in 3.1.3 and 3.2.3.
+
+
+Version 3.3.1
+=============
+
+Merged changes in 3.1.2 and 3.2.2.
+
+
+Version 3.3.0
+=============
+
+Compatibility
+-------------
+
+* Ruby version: 2.7 or later
+* OpenSSL version: OpenSSL 1.0.2 or later, and LibreSSL 3.1 or later
+
+Notable changes
+---------------
+
+* `OpenSSL::SSL`
+ - `OpenSSL::SSL::SSLSocket#set_params` no longer sets `#min_version=` to TLS
+ 1.0 except when OpenSSL 1.0.2 is used. This has been done to disable
+ SSL 3.0, which is not supported by default in OpenSSL 1.1.0 or later, or in
+ LibreSSL. This lets it respect the system default if the system-wide
+ configuration file specifies a higher minimum protocol version.
+ [[GitHub #710]](https://github.com/ruby/openssl/pull/710)
+ - `OpenSSL::SSL::SSLSocket.new` no longer enables the `OpenSSL::SSL::OP_ALL`
+ SSL options by default and follows the system default.
+ [[GitHub #767]](https://github.com/ruby/openssl/pull/767)
+ - Add the following IO methods to `OpenSSL::SSL::SSLSocket`, which will pass
+ along to the underlying socket: `#local_address`, `#remote_address`,
+ `#close_on_exec=`, `#close_on_exec?`, `#wait`, `#wait_readable`, and
+ `#wait_writable`.
+ [[GitHub #708]](https://github.com/ruby/openssl/pull/708)
+ - Update `OpenSSL::SSL::SSLSocket#gets` to take the `chomp` keyword argument.
+ [[GitHub #708]](https://github.com/ruby/openssl/pull/708)
+ - Make `OpenSSL::SSL::SSLSocket` respect the `IO#timeout` value of the
+ underlying socket on Ruby 3.2 or later. `#timeout` and `#timeout=` methods
+ are also added.
+ [[GitHub #714]](https://github.com/ruby/openssl/pull/714)
+ - Add `OpenSSL::SSL::SSLSocket#close_read` and `#close_write`.
+ [[GitHub #743]](https://github.com/ruby/openssl/pull/743)
+ - Add `OpenSSL::Digest.digests` to get a list of all available digest
+ algorithms.
+ [[GitHub #726]](https://github.com/ruby/openssl/pull/726)
+ - Fix `OpenSSL::SSL::SSLSocket#read_nonblock` clearing the passed String
+ buffer when nothing can be read from the connection.
+ [[GitHub #739]](https://github.com/ruby/openssl/pull/739)
+* Add `#to_text` methods to `OpenSSL::Timestamp::Response`,
+ `OpenSSL::Timestamp::Request`, `OpenSSL::Timestamp::TokenInfo`, and
+ `OpenSSL::PKCS7` to get a human-readable representation of the object.
+ [[GitHub #756]](https://github.com/ruby/openssl/pull/756)
+* Add `OpenSSL::X509::Certificate#tbs_bytes` to get the DER encoding of the
+ TBSCertificate.
+ [[GitHub #753]](https://github.com/ruby/openssl/pull/753)
+* Allow passing `nil` as the digest algorithm to `#sign` methods on
+ `OpenSSL::X509::Certificate`, `OpenSSL::X509::Request`, and
+ `OpenSSL::X509::CRL`. This adds supports for signing with EdDSA keys.
+ [[GitHub #761]](https://github.com/ruby/openssl/pull/761)
+ [[GitHub #804]](https://github.com/ruby/openssl/pull/804)
+* Add `OpenSSL::SSL::SSLSocket#readbyte`.
+ [[GitHub #771]](https://github.com/ruby/openssl/pull/771)
+* Change `OpenSSL::X509::Store#time=` to set the time to the `X509_VERIFY_PARAM`
+ in the `X509_STORE`. This allows `OpenSSL::Timestamp::Response#verify` to
+ verify a signature with the specified timestamp.
+ [[GitHub #770]](https://github.com/ruby/openssl/pull/770)
+* Make `OpenSSL::PKCS7.encrypt`'s third parameter `cipher` mandatory. It had
+ an undocumented default value "RC2-40-CBC", which is not only insecure, but
+ also not supported in OpenSSL 3.0 or later.
+ [[GitHub #796]](https://github.com/ruby/openssl/pull/796)
+* Make `OpenSSL::BN` shareable between ractors when frozen.
+ [[GitHub #808]](https://github.com/ruby/openssl/pull/808)
+* Make `OpenSSL::Config` instances frozen by default, and make it shareable
+ between ractors. `OpenSSL::Config::DEFAULT_CONFIG_FILE` is also frozen.
+ [[GitHub #809]](https://github.com/ruby/openssl/pull/809)
+* Add `OpenSSL::PKCS12#set_mac` to configure the MAC parameters and recalculate
+ a MAC for the content.
+ [[GitHub #788]](https://github.com/ruby/openssl/pull/788)
+
+And various non-user-visible changes and bug fixes. Please see the commit
+history for more details.
+
+
+Version 3.2.4
+=============
+
+Notable changes
+---------------
+
+* Add support for OpenSSL 4.0.
+ [[GitHub #1051]](https://github.com/ruby/openssl/pull/1051)
+
+
+Version 3.2.3
+=============
+
+Merged changes in 3.1.3.
+
+
+Version 3.2.2
+=============
+
+Merged changes in 3.1.2.
+
+
+Version 3.2.1
+=============
+
+Merged changes in 3.0.3.
+
+
+Version 3.2.0
+=============
+
+Compatibility
+-------------
+
+* Ruby >= 2.7
+ - Support for Ruby 2.6 has been removed. Note that Ruby 2.6 reached the
+ end-of-life in 2022-04.
+ [[GitHub #639]](https://github.com/ruby/openssl/pull/639)
+* OpenSSL >= 1.0.2 or LibreSSL >= 3.1
+
+Notable changes
+---------------
+
+* Add a stub gemspec for JRuby, which depends on the `jruby-openssl` gem.
+ [[GitHub #598]](https://github.com/ruby/openssl/pull/598)
+* Add support for the FIPS module in OpenSSL 3.0/3.1.
+ [[GitHub #608]](https://github.com/ruby/openssl/pull/608)
+* Rework `OpenSSL::PKey` routines for loading DER or PEM encoded keys for better
+ compatibility with OpenSSL 3.0/3.1 with the FIPS module.
+ [[GitHub #615]](https://github.com/ruby/openssl/pull/615)
+ [[GitHub #669]](https://github.com/ruby/openssl/pull/669)
+* Add `OpenSSL::Provider` module for loading and unloading OpenSSL 3 providers.
+ [[GitHub #635]](https://github.com/ruby/openssl/pull/635)
+* Add `OpenSSL::PKey.new_raw_private_key`, `.new_raw_public_key`,
+ `OpenSSL::PKey::PKey#raw_private_key`, and `#raw_public_key` for public key
+ algorithms that use "raw private/public key", such as X25519 and Ed25519.
+ [[GitHub #646]](https://github.com/ruby/openssl/pull/646)
+* Improve OpenSSL error messages to include additional information when
+ it is available in OpenSSL's error queue.
+ [[GitHub #648]](https://github.com/ruby/openssl/pull/648)
+* Change `OpenSSL::SSL::SSLContext#ca_file=` and `#ca_path=` to raise
+ `OpenSSL::SSL::SSLError` instead of printing a warning message.
+ [[GitHub #659]](https://github.com/ruby/openssl/pull/659)
+* Allow `OpenSSL::X509::ExtensionFactory#create_extension` to take OIDs in the
+ dotted-decimal notation.
+ [[GitHub #141]](https://github.com/ruby/openssl/pull/141)
+
+
+Version 3.1.3
+=============
+
+Bug fixes
+---------
+
+* Fix missing NULL check for `EVP_PKEY_get0()` functions with OpenSSL 3.x.
+ [[GitHub #957]](https://github.com/ruby/openssl/pull/957)
+
+
+Version 3.1.2
+=============
+
+Bug fixes
+---------
+
+* Fix crash when attempting to export an incomplete `OpenSSL::PKey::DSA` key.
+ [[GitHub #845]](https://github.com/ruby/openssl/issues/845)
+ [[GitHub #847]](https://github.com/ruby/openssl/pull/847)
+* Remove the `OpenSSL::X509::V_FLAG_CRL_CHECK_ALL` flag from the default store
+ used by `OpenSSL::SSL::SSLContext#set_params`. It causes certificate
+ verification to fail with OpenSSL 3.6.0. It has no effect with any other
+ OpenSSL versions.
+ [[GitHub #949]](https://github.com/ruby/openssl/issues/949)
+ [[GitHub #950]](https://github.com/ruby/openssl/pull/950)
+
+
+Version 3.1.1
+=============
+
+Merged changes in 3.0.3.
+
+
Version 3.1.0
=============
@@ -34,6 +340,31 @@ Notable changes
LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
+Version 3.0.3
+=============
+
+Bug fixes
+---------
+
+* Fix a performance regression introduced in v2.1.3 on a buffered write to
+ `SSLSocket`.
+ [[GitHub #706]](https://github.com/ruby/openssl/pull/706)
+* Fix `OpenSSL::PKCS7` to handle PKCS#7 structures without content.
+ [[GitHub #690]](https://github.com/ruby/openssl/pull/690)
+ [[GitHub #752]](https://github.com/ruby/openssl/pull/752)
+* Fix `OpenSSL::ASN1::ObjectId#==` with OIDs without a known name.
+ [[GitHub #791]](https://github.com/ruby/openssl/issues/791)
+ [[GitHub #792]](https://github.com/ruby/openssl/pull/792)
+* Fix `OpenSSL::X509::Certificate#crl_uris` to handle CDP with multiple CRL
+ URIs.
+ [[GitHub #775]](https://github.com/ruby/openssl/issues/775)
+ [[GitHub #776]](https://github.com/ruby/openssl/pull/776)
+* Fix `OpenSSL::Cipher#update` to always make the output buffer `String`
+ independent.
+ [[Bug #20937]](https://bugs.ruby-lang.org/issues/20937)
+ [[GitHub #824]](https://github.com/ruby/openssl/pull/824)
+
+
Version 3.0.2
=============
@@ -417,7 +748,7 @@ Security fixes
Bug fixes
---------
-* Fixed OpenSSL::PKey::*.{new,generate} immediately aborting if the thread is
+* Fixed OpenSSL::PKey::\*.{new,generate} immediately aborting if the thread is
interrupted.
[[Bug #14882]](https://bugs.ruby-lang.org/issues/14882)
[[GitHub #205]](https://github.com/ruby/openssl/pull/205)
diff --git a/ext/openssl/depend b/ext/openssl/depend
index e156edf38a..435f4a1c68 100644
--- a/ext/openssl/depend
+++ b/ext/openssl/depend
@@ -142,6 +142,7 @@ ossl.o: $(hdrdir)/ruby/internal/intern/re.h
ossl.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl.o: $(hdrdir)/ruby/internal/intern/select.h
ossl.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl.o: $(hdrdir)/ruby/internal/intern/set.h
ossl.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -161,6 +162,7 @@ ossl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl.o: $(hdrdir)/ruby/internal/static_assert.h
ossl.o: $(hdrdir)/ruby/internal/stdalign.h
ossl.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl.o: $(hdrdir)/ruby/internal/symbol.h
ossl.o: $(hdrdir)/ruby/internal/value.h
ossl.o: $(hdrdir)/ruby/internal/value_type.h
@@ -171,6 +173,7 @@ ossl.o: $(hdrdir)/ruby/io.h
ossl.o: $(hdrdir)/ruby/missing.h
ossl.o: $(hdrdir)/ruby/onigmo.h
ossl.o: $(hdrdir)/ruby/oniguruma.h
+ossl.o: $(hdrdir)/ruby/ractor.h
ossl.o: $(hdrdir)/ruby/ruby.h
ossl.o: $(hdrdir)/ruby/st.h
ossl.o: $(hdrdir)/ruby/subst.h
@@ -192,6 +195,7 @@ ossl.o: ossl_ocsp.h
ossl.o: ossl_pkcs12.h
ossl.o: ossl_pkcs7.h
ossl.o: ossl_pkey.h
+ossl.o: ossl_provider.h
ossl.o: ossl_rand.h
ossl.o: ossl_ssl.h
ossl.o: ossl_ts.h
@@ -335,6 +339,7 @@ ossl_asn1.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_asn1.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -354,6 +359,7 @@ ossl_asn1.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_asn1.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_asn1.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_asn1.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_asn1.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_asn1.o: $(hdrdir)/ruby/internal/symbol.h
ossl_asn1.o: $(hdrdir)/ruby/internal/value.h
ossl_asn1.o: $(hdrdir)/ruby/internal/value_type.h
@@ -364,6 +370,7 @@ ossl_asn1.o: $(hdrdir)/ruby/io.h
ossl_asn1.o: $(hdrdir)/ruby/missing.h
ossl_asn1.o: $(hdrdir)/ruby/onigmo.h
ossl_asn1.o: $(hdrdir)/ruby/oniguruma.h
+ossl_asn1.o: $(hdrdir)/ruby/ractor.h
ossl_asn1.o: $(hdrdir)/ruby/ruby.h
ossl_asn1.o: $(hdrdir)/ruby/st.h
ossl_asn1.o: $(hdrdir)/ruby/subst.h
@@ -385,6 +392,7 @@ ossl_asn1.o: ossl_ocsp.h
ossl_asn1.o: ossl_pkcs12.h
ossl_asn1.o: ossl_pkcs7.h
ossl_asn1.o: ossl_pkey.h
+ossl_asn1.o: ossl_provider.h
ossl_asn1.o: ossl_rand.h
ossl_asn1.o: ossl_ssl.h
ossl_asn1.o: ossl_ts.h
@@ -528,6 +536,7 @@ ossl_bio.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_bio.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -547,6 +556,7 @@ ossl_bio.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_bio.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_bio.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_bio.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_bio.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_bio.o: $(hdrdir)/ruby/internal/symbol.h
ossl_bio.o: $(hdrdir)/ruby/internal/value.h
ossl_bio.o: $(hdrdir)/ruby/internal/value_type.h
@@ -557,6 +567,7 @@ ossl_bio.o: $(hdrdir)/ruby/io.h
ossl_bio.o: $(hdrdir)/ruby/missing.h
ossl_bio.o: $(hdrdir)/ruby/onigmo.h
ossl_bio.o: $(hdrdir)/ruby/oniguruma.h
+ossl_bio.o: $(hdrdir)/ruby/ractor.h
ossl_bio.o: $(hdrdir)/ruby/ruby.h
ossl_bio.o: $(hdrdir)/ruby/st.h
ossl_bio.o: $(hdrdir)/ruby/subst.h
@@ -578,6 +589,7 @@ ossl_bio.o: ossl_ocsp.h
ossl_bio.o: ossl_pkcs12.h
ossl_bio.o: ossl_pkcs7.h
ossl_bio.o: ossl_pkey.h
+ossl_bio.o: ossl_provider.h
ossl_bio.o: ossl_rand.h
ossl_bio.o: ossl_ssl.h
ossl_bio.o: ossl_ts.h
@@ -721,6 +733,7 @@ ossl_bn.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_bn.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -740,6 +753,7 @@ ossl_bn.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_bn.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_bn.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_bn.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_bn.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_bn.o: $(hdrdir)/ruby/internal/symbol.h
ossl_bn.o: $(hdrdir)/ruby/internal/value.h
ossl_bn.o: $(hdrdir)/ruby/internal/value_type.h
@@ -772,6 +786,7 @@ ossl_bn.o: ossl_ocsp.h
ossl_bn.o: ossl_pkcs12.h
ossl_bn.o: ossl_pkcs7.h
ossl_bn.o: ossl_pkey.h
+ossl_bn.o: ossl_provider.h
ossl_bn.o: ossl_rand.h
ossl_bn.o: ossl_ssl.h
ossl_bn.o: ossl_ts.h
@@ -915,6 +930,7 @@ ossl_cipher.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_cipher.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -934,6 +950,7 @@ ossl_cipher.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_cipher.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_cipher.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_cipher.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_cipher.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_cipher.o: $(hdrdir)/ruby/internal/symbol.h
ossl_cipher.o: $(hdrdir)/ruby/internal/value.h
ossl_cipher.o: $(hdrdir)/ruby/internal/value_type.h
@@ -944,6 +961,7 @@ ossl_cipher.o: $(hdrdir)/ruby/io.h
ossl_cipher.o: $(hdrdir)/ruby/missing.h
ossl_cipher.o: $(hdrdir)/ruby/onigmo.h
ossl_cipher.o: $(hdrdir)/ruby/oniguruma.h
+ossl_cipher.o: $(hdrdir)/ruby/ractor.h
ossl_cipher.o: $(hdrdir)/ruby/ruby.h
ossl_cipher.o: $(hdrdir)/ruby/st.h
ossl_cipher.o: $(hdrdir)/ruby/subst.h
@@ -965,6 +983,7 @@ ossl_cipher.o: ossl_ocsp.h
ossl_cipher.o: ossl_pkcs12.h
ossl_cipher.o: ossl_pkcs7.h
ossl_cipher.o: ossl_pkey.h
+ossl_cipher.o: ossl_provider.h
ossl_cipher.o: ossl_rand.h
ossl_cipher.o: ossl_ssl.h
ossl_cipher.o: ossl_ts.h
@@ -1108,6 +1127,7 @@ ossl_config.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_config.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1127,6 +1147,7 @@ ossl_config.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_config.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_config.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_config.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_config.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_config.o: $(hdrdir)/ruby/internal/symbol.h
ossl_config.o: $(hdrdir)/ruby/internal/value.h
ossl_config.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1137,6 +1158,7 @@ ossl_config.o: $(hdrdir)/ruby/io.h
ossl_config.o: $(hdrdir)/ruby/missing.h
ossl_config.o: $(hdrdir)/ruby/onigmo.h
ossl_config.o: $(hdrdir)/ruby/oniguruma.h
+ossl_config.o: $(hdrdir)/ruby/ractor.h
ossl_config.o: $(hdrdir)/ruby/ruby.h
ossl_config.o: $(hdrdir)/ruby/st.h
ossl_config.o: $(hdrdir)/ruby/subst.h
@@ -1158,6 +1180,7 @@ ossl_config.o: ossl_ocsp.h
ossl_config.o: ossl_pkcs12.h
ossl_config.o: ossl_pkcs7.h
ossl_config.o: ossl_pkey.h
+ossl_config.o: ossl_provider.h
ossl_config.o: ossl_rand.h
ossl_config.o: ossl_ssl.h
ossl_config.o: ossl_ts.h
@@ -1301,6 +1324,7 @@ ossl_digest.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_digest.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1320,6 +1344,7 @@ ossl_digest.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_digest.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_digest.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_digest.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_digest.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_digest.o: $(hdrdir)/ruby/internal/symbol.h
ossl_digest.o: $(hdrdir)/ruby/internal/value.h
ossl_digest.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1330,6 +1355,7 @@ ossl_digest.o: $(hdrdir)/ruby/io.h
ossl_digest.o: $(hdrdir)/ruby/missing.h
ossl_digest.o: $(hdrdir)/ruby/onigmo.h
ossl_digest.o: $(hdrdir)/ruby/oniguruma.h
+ossl_digest.o: $(hdrdir)/ruby/ractor.h
ossl_digest.o: $(hdrdir)/ruby/ruby.h
ossl_digest.o: $(hdrdir)/ruby/st.h
ossl_digest.o: $(hdrdir)/ruby/subst.h
@@ -1351,6 +1377,7 @@ ossl_digest.o: ossl_ocsp.h
ossl_digest.o: ossl_pkcs12.h
ossl_digest.o: ossl_pkcs7.h
ossl_digest.o: ossl_pkey.h
+ossl_digest.o: ossl_provider.h
ossl_digest.o: ossl_rand.h
ossl_digest.o: ossl_ssl.h
ossl_digest.o: ossl_ts.h
@@ -1494,6 +1521,7 @@ ossl_engine.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_engine.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1513,6 +1541,7 @@ ossl_engine.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_engine.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_engine.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_engine.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_engine.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_engine.o: $(hdrdir)/ruby/internal/symbol.h
ossl_engine.o: $(hdrdir)/ruby/internal/value.h
ossl_engine.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1523,6 +1552,7 @@ ossl_engine.o: $(hdrdir)/ruby/io.h
ossl_engine.o: $(hdrdir)/ruby/missing.h
ossl_engine.o: $(hdrdir)/ruby/onigmo.h
ossl_engine.o: $(hdrdir)/ruby/oniguruma.h
+ossl_engine.o: $(hdrdir)/ruby/ractor.h
ossl_engine.o: $(hdrdir)/ruby/ruby.h
ossl_engine.o: $(hdrdir)/ruby/st.h
ossl_engine.o: $(hdrdir)/ruby/subst.h
@@ -1544,6 +1574,7 @@ ossl_engine.o: ossl_ocsp.h
ossl_engine.o: ossl_pkcs12.h
ossl_engine.o: ossl_pkcs7.h
ossl_engine.o: ossl_pkey.h
+ossl_engine.o: ossl_provider.h
ossl_engine.o: ossl_rand.h
ossl_engine.o: ossl_ssl.h
ossl_engine.o: ossl_ts.h
@@ -1687,6 +1718,7 @@ ossl_hmac.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_hmac.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1706,6 +1738,7 @@ ossl_hmac.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_hmac.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_hmac.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_hmac.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_hmac.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_hmac.o: $(hdrdir)/ruby/internal/symbol.h
ossl_hmac.o: $(hdrdir)/ruby/internal/value.h
ossl_hmac.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1716,6 +1749,7 @@ ossl_hmac.o: $(hdrdir)/ruby/io.h
ossl_hmac.o: $(hdrdir)/ruby/missing.h
ossl_hmac.o: $(hdrdir)/ruby/onigmo.h
ossl_hmac.o: $(hdrdir)/ruby/oniguruma.h
+ossl_hmac.o: $(hdrdir)/ruby/ractor.h
ossl_hmac.o: $(hdrdir)/ruby/ruby.h
ossl_hmac.o: $(hdrdir)/ruby/st.h
ossl_hmac.o: $(hdrdir)/ruby/subst.h
@@ -1737,6 +1771,7 @@ ossl_hmac.o: ossl_ocsp.h
ossl_hmac.o: ossl_pkcs12.h
ossl_hmac.o: ossl_pkcs7.h
ossl_hmac.o: ossl_pkey.h
+ossl_hmac.o: ossl_provider.h
ossl_hmac.o: ossl_rand.h
ossl_hmac.o: ossl_ssl.h
ossl_hmac.o: ossl_ts.h
@@ -1880,6 +1915,7 @@ ossl_kdf.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_kdf.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1899,6 +1935,7 @@ ossl_kdf.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_kdf.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_kdf.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_kdf.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_kdf.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_kdf.o: $(hdrdir)/ruby/internal/symbol.h
ossl_kdf.o: $(hdrdir)/ruby/internal/value.h
ossl_kdf.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1909,6 +1946,7 @@ ossl_kdf.o: $(hdrdir)/ruby/io.h
ossl_kdf.o: $(hdrdir)/ruby/missing.h
ossl_kdf.o: $(hdrdir)/ruby/onigmo.h
ossl_kdf.o: $(hdrdir)/ruby/oniguruma.h
+ossl_kdf.o: $(hdrdir)/ruby/ractor.h
ossl_kdf.o: $(hdrdir)/ruby/ruby.h
ossl_kdf.o: $(hdrdir)/ruby/st.h
ossl_kdf.o: $(hdrdir)/ruby/subst.h
@@ -1930,6 +1968,7 @@ ossl_kdf.o: ossl_ocsp.h
ossl_kdf.o: ossl_pkcs12.h
ossl_kdf.o: ossl_pkcs7.h
ossl_kdf.o: ossl_pkey.h
+ossl_kdf.o: ossl_provider.h
ossl_kdf.o: ossl_rand.h
ossl_kdf.o: ossl_ssl.h
ossl_kdf.o: ossl_ts.h
@@ -2073,6 +2112,7 @@ ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2092,6 +2132,7 @@ ossl_ns_spki.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_ns_spki.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/symbol.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/value.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2102,6 +2143,7 @@ ossl_ns_spki.o: $(hdrdir)/ruby/io.h
ossl_ns_spki.o: $(hdrdir)/ruby/missing.h
ossl_ns_spki.o: $(hdrdir)/ruby/onigmo.h
ossl_ns_spki.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ns_spki.o: $(hdrdir)/ruby/ractor.h
ossl_ns_spki.o: $(hdrdir)/ruby/ruby.h
ossl_ns_spki.o: $(hdrdir)/ruby/st.h
ossl_ns_spki.o: $(hdrdir)/ruby/subst.h
@@ -2123,6 +2165,7 @@ ossl_ns_spki.o: ossl_ocsp.h
ossl_ns_spki.o: ossl_pkcs12.h
ossl_ns_spki.o: ossl_pkcs7.h
ossl_ns_spki.o: ossl_pkey.h
+ossl_ns_spki.o: ossl_provider.h
ossl_ns_spki.o: ossl_rand.h
ossl_ns_spki.o: ossl_ssl.h
ossl_ns_spki.o: ossl_ts.h
@@ -2266,6 +2309,7 @@ ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2285,6 +2329,7 @@ ossl_ocsp.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_ocsp.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/symbol.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/value.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2295,6 +2340,7 @@ ossl_ocsp.o: $(hdrdir)/ruby/io.h
ossl_ocsp.o: $(hdrdir)/ruby/missing.h
ossl_ocsp.o: $(hdrdir)/ruby/onigmo.h
ossl_ocsp.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ocsp.o: $(hdrdir)/ruby/ractor.h
ossl_ocsp.o: $(hdrdir)/ruby/ruby.h
ossl_ocsp.o: $(hdrdir)/ruby/st.h
ossl_ocsp.o: $(hdrdir)/ruby/subst.h
@@ -2316,6 +2362,7 @@ ossl_ocsp.o: ossl_ocsp.h
ossl_ocsp.o: ossl_pkcs12.h
ossl_ocsp.o: ossl_pkcs7.h
ossl_ocsp.o: ossl_pkey.h
+ossl_ocsp.o: ossl_provider.h
ossl_ocsp.o: ossl_rand.h
ossl_ocsp.o: ossl_ssl.h
ossl_ocsp.o: ossl_ts.h
@@ -2459,6 +2506,7 @@ ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2478,6 +2526,7 @@ ossl_pkcs12.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkcs12.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/value.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2488,6 +2537,7 @@ ossl_pkcs12.o: $(hdrdir)/ruby/io.h
ossl_pkcs12.o: $(hdrdir)/ruby/missing.h
ossl_pkcs12.o: $(hdrdir)/ruby/onigmo.h
ossl_pkcs12.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs12.o: $(hdrdir)/ruby/ractor.h
ossl_pkcs12.o: $(hdrdir)/ruby/ruby.h
ossl_pkcs12.o: $(hdrdir)/ruby/st.h
ossl_pkcs12.o: $(hdrdir)/ruby/subst.h
@@ -2509,6 +2559,7 @@ ossl_pkcs12.o: ossl_pkcs12.c
ossl_pkcs12.o: ossl_pkcs12.h
ossl_pkcs12.o: ossl_pkcs7.h
ossl_pkcs12.o: ossl_pkey.h
+ossl_pkcs12.o: ossl_provider.h
ossl_pkcs12.o: ossl_rand.h
ossl_pkcs12.o: ossl_ssl.h
ossl_pkcs12.o: ossl_ts.h
@@ -2652,6 +2703,7 @@ ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2671,6 +2723,7 @@ ossl_pkcs7.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkcs7.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/value.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2681,6 +2734,7 @@ ossl_pkcs7.o: $(hdrdir)/ruby/io.h
ossl_pkcs7.o: $(hdrdir)/ruby/missing.h
ossl_pkcs7.o: $(hdrdir)/ruby/onigmo.h
ossl_pkcs7.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs7.o: $(hdrdir)/ruby/ractor.h
ossl_pkcs7.o: $(hdrdir)/ruby/ruby.h
ossl_pkcs7.o: $(hdrdir)/ruby/st.h
ossl_pkcs7.o: $(hdrdir)/ruby/subst.h
@@ -2702,6 +2756,7 @@ ossl_pkcs7.o: ossl_pkcs12.h
ossl_pkcs7.o: ossl_pkcs7.c
ossl_pkcs7.o: ossl_pkcs7.h
ossl_pkcs7.o: ossl_pkey.h
+ossl_pkcs7.o: ossl_provider.h
ossl_pkcs7.o: ossl_rand.h
ossl_pkcs7.o: ossl_ssl.h
ossl_pkcs7.o: ossl_ts.h
@@ -2845,6 +2900,7 @@ ossl_pkey.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkey.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2864,6 +2920,7 @@ ossl_pkey.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkey.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkey.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkey.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkey.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkey.o: $(hdrdir)/ruby/internal/value.h
ossl_pkey.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2874,6 +2931,7 @@ ossl_pkey.o: $(hdrdir)/ruby/io.h
ossl_pkey.o: $(hdrdir)/ruby/missing.h
ossl_pkey.o: $(hdrdir)/ruby/onigmo.h
ossl_pkey.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey.o: $(hdrdir)/ruby/ractor.h
ossl_pkey.o: $(hdrdir)/ruby/ruby.h
ossl_pkey.o: $(hdrdir)/ruby/st.h
ossl_pkey.o: $(hdrdir)/ruby/subst.h
@@ -2895,6 +2953,7 @@ ossl_pkey.o: ossl_pkcs12.h
ossl_pkey.o: ossl_pkcs7.h
ossl_pkey.o: ossl_pkey.c
ossl_pkey.o: ossl_pkey.h
+ossl_pkey.o: ossl_provider.h
ossl_pkey.o: ossl_rand.h
ossl_pkey.o: ossl_ssl.h
ossl_pkey.o: ossl_ts.h
@@ -3038,6 +3097,7 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -3057,6 +3117,7 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/value.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/value_type.h
@@ -3067,6 +3128,7 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/io.h
ossl_pkey_dh.o: $(hdrdir)/ruby/missing.h
ossl_pkey_dh.o: $(hdrdir)/ruby/onigmo.h
ossl_pkey_dh.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/ractor.h
ossl_pkey_dh.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_dh.o: $(hdrdir)/ruby/st.h
ossl_pkey_dh.o: $(hdrdir)/ruby/subst.h
@@ -3088,6 +3150,7 @@ ossl_pkey_dh.o: ossl_pkcs12.h
ossl_pkey_dh.o: ossl_pkcs7.h
ossl_pkey_dh.o: ossl_pkey.h
ossl_pkey_dh.o: ossl_pkey_dh.c
+ossl_pkey_dh.o: ossl_provider.h
ossl_pkey_dh.o: ossl_rand.h
ossl_pkey_dh.o: ossl_ssl.h
ossl_pkey_dh.o: ossl_ts.h
@@ -3231,6 +3294,7 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -3250,6 +3314,7 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/value.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/value_type.h
@@ -3260,6 +3325,7 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/io.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/missing.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/onigmo.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/ractor.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/st.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/subst.h
@@ -3281,6 +3347,7 @@ ossl_pkey_dsa.o: ossl_pkcs12.h
ossl_pkey_dsa.o: ossl_pkcs7.h
ossl_pkey_dsa.o: ossl_pkey.h
ossl_pkey_dsa.o: ossl_pkey_dsa.c
+ossl_pkey_dsa.o: ossl_provider.h
ossl_pkey_dsa.o: ossl_rand.h
ossl_pkey_dsa.o: ossl_ssl.h
ossl_pkey_dsa.o: ossl_ts.h
@@ -3424,6 +3491,7 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -3443,6 +3511,7 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/value.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/value_type.h
@@ -3453,6 +3522,7 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/io.h
ossl_pkey_ec.o: $(hdrdir)/ruby/missing.h
ossl_pkey_ec.o: $(hdrdir)/ruby/onigmo.h
ossl_pkey_ec.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/ractor.h
ossl_pkey_ec.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_ec.o: $(hdrdir)/ruby/st.h
ossl_pkey_ec.o: $(hdrdir)/ruby/subst.h
@@ -3474,6 +3544,7 @@ ossl_pkey_ec.o: ossl_pkcs12.h
ossl_pkey_ec.o: ossl_pkcs7.h
ossl_pkey_ec.o: ossl_pkey.h
ossl_pkey_ec.o: ossl_pkey_ec.c
+ossl_pkey_ec.o: ossl_provider.h
ossl_pkey_ec.o: ossl_rand.h
ossl_pkey_ec.o: ossl_ssl.h
ossl_pkey_ec.o: ossl_ts.h
@@ -3617,6 +3688,7 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -3636,6 +3708,7 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/symbol.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/value.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/value_type.h
@@ -3646,6 +3719,7 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/io.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/missing.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/onigmo.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/ractor.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/ruby.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/st.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/subst.h
@@ -3667,10 +3741,208 @@ ossl_pkey_rsa.o: ossl_pkcs12.h
ossl_pkey_rsa.o: ossl_pkcs7.h
ossl_pkey_rsa.o: ossl_pkey.h
ossl_pkey_rsa.o: ossl_pkey_rsa.c
+ossl_pkey_rsa.o: ossl_provider.h
ossl_pkey_rsa.o: ossl_rand.h
ossl_pkey_rsa.o: ossl_ssl.h
ossl_pkey_rsa.o: ossl_ts.h
ossl_pkey_rsa.o: ossl_x509.h
+ossl_provider.o: $(RUBY_EXTCONF_H)
+ossl_provider.o: $(arch_hdrdir)/ruby/config.h
+ossl_provider.o: $(hdrdir)/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/assert.h
+ossl_provider.o: $(hdrdir)/ruby/backward.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/assume.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/attributes.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/bool.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/inttypes.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/limits.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/long_long.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/stdalign.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/stdarg.h
+ossl_provider.o: $(hdrdir)/ruby/defines.h
+ossl_provider.o: $(hdrdir)/ruby/encoding.h
+ossl_provider.o: $(hdrdir)/ruby/intern.h
+ossl_provider.o: $(hdrdir)/ruby/internal/abi.h
+ossl_provider.o: $(hdrdir)/ruby/internal/anyargs.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/assume.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/artificial.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/cold.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/const.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/format.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noalias.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noinline.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/pure.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/restrict.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/warning.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/weakref.h
+ossl_provider.o: $(hdrdir)/ruby/internal/cast.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_since.h
+ossl_provider.o: $(hdrdir)/ruby/internal/config.h
+ossl_provider.o: $(hdrdir)/ruby/internal/constant_p.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rarray.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rbasic.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rbignum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rclass.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rdata.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rfile.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rhash.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/robject.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rregexp.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rstring.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rstruct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+ossl_provider.o: $(hdrdir)/ruby/internal/ctype.h
+ossl_provider.o: $(hdrdir)/ruby/internal/dllexport.h
+ossl_provider.o: $(hdrdir)/ruby/internal/dosish.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/re.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/string.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+ossl_provider.o: $(hdrdir)/ruby/internal/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/eval.h
+ossl_provider.o: $(hdrdir)/ruby/internal/event.h
+ossl_provider.o: $(hdrdir)/ruby/internal/fl_type.h
+ossl_provider.o: $(hdrdir)/ruby/internal/gc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/glob.h
+ossl_provider.o: $(hdrdir)/ruby/internal/globals.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/builtin.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/extension.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/feature.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/warning.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/array.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/bignum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/class.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/compar.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/complex.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/cont.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/dir.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/enum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/eval.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/file.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/hash.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/io.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/load.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/marshal.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/numeric.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/object.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/parse.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/proc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/process.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/random.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/range.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/rational.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/re.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/select.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/set.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/signal.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/string.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/struct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/thread.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/time.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/variable.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/vm.h
+ossl_provider.o: $(hdrdir)/ruby/internal/interpreter.h
+ossl_provider.o: $(hdrdir)/ruby/internal/iterator.h
+ossl_provider.o: $(hdrdir)/ruby/internal/memory.h
+ossl_provider.o: $(hdrdir)/ruby/internal/method.h
+ossl_provider.o: $(hdrdir)/ruby/internal/module.h
+ossl_provider.o: $(hdrdir)/ruby/internal/newobj.h
+ossl_provider.o: $(hdrdir)/ruby/internal/scan_args.h
+ossl_provider.o: $(hdrdir)/ruby/internal/special_consts.h
+ossl_provider.o: $(hdrdir)/ruby/internal/static_assert.h
+ossl_provider.o: $(hdrdir)/ruby/internal/stdalign.h
+ossl_provider.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_provider.o: $(hdrdir)/ruby/internal/stdckdint.h
+ossl_provider.o: $(hdrdir)/ruby/internal/symbol.h
+ossl_provider.o: $(hdrdir)/ruby/internal/value.h
+ossl_provider.o: $(hdrdir)/ruby/internal/value_type.h
+ossl_provider.o: $(hdrdir)/ruby/internal/variable.h
+ossl_provider.o: $(hdrdir)/ruby/internal/warning_push.h
+ossl_provider.o: $(hdrdir)/ruby/internal/xmalloc.h
+ossl_provider.o: $(hdrdir)/ruby/io.h
+ossl_provider.o: $(hdrdir)/ruby/missing.h
+ossl_provider.o: $(hdrdir)/ruby/onigmo.h
+ossl_provider.o: $(hdrdir)/ruby/oniguruma.h
+ossl_provider.o: $(hdrdir)/ruby/ractor.h
+ossl_provider.o: $(hdrdir)/ruby/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/st.h
+ossl_provider.o: $(hdrdir)/ruby/subst.h
+ossl_provider.o: $(hdrdir)/ruby/thread.h
+ossl_provider.o: openssl_missing.h
+ossl_provider.o: ossl.h
+ossl_provider.o: ossl_asn1.h
+ossl_provider.o: ossl_bio.h
+ossl_provider.o: ossl_bn.h
+ossl_provider.o: ossl_cipher.h
+ossl_provider.o: ossl_config.h
+ossl_provider.o: ossl_digest.h
+ossl_provider.o: ossl_engine.h
+ossl_provider.o: ossl_hmac.h
+ossl_provider.o: ossl_kdf.h
+ossl_provider.o: ossl_ns_spki.h
+ossl_provider.o: ossl_ocsp.h
+ossl_provider.o: ossl_pkcs12.h
+ossl_provider.o: ossl_pkcs7.h
+ossl_provider.o: ossl_pkey.h
+ossl_provider.o: ossl_provider.c
+ossl_provider.o: ossl_provider.h
+ossl_provider.o: ossl_rand.h
+ossl_provider.o: ossl_ssl.h
+ossl_provider.o: ossl_ts.h
+ossl_provider.o: ossl_x509.h
ossl_rand.o: $(RUBY_EXTCONF_H)
ossl_rand.o: $(arch_hdrdir)/ruby/config.h
ossl_rand.o: $(hdrdir)/ruby.h
@@ -3810,6 +4082,7 @@ ossl_rand.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_rand.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -3829,6 +4102,7 @@ ossl_rand.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_rand.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_rand.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_rand.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_rand.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_rand.o: $(hdrdir)/ruby/internal/symbol.h
ossl_rand.o: $(hdrdir)/ruby/internal/value.h
ossl_rand.o: $(hdrdir)/ruby/internal/value_type.h
@@ -3839,6 +4113,7 @@ ossl_rand.o: $(hdrdir)/ruby/io.h
ossl_rand.o: $(hdrdir)/ruby/missing.h
ossl_rand.o: $(hdrdir)/ruby/onigmo.h
ossl_rand.o: $(hdrdir)/ruby/oniguruma.h
+ossl_rand.o: $(hdrdir)/ruby/ractor.h
ossl_rand.o: $(hdrdir)/ruby/ruby.h
ossl_rand.o: $(hdrdir)/ruby/st.h
ossl_rand.o: $(hdrdir)/ruby/subst.h
@@ -3859,6 +4134,7 @@ ossl_rand.o: ossl_ocsp.h
ossl_rand.o: ossl_pkcs12.h
ossl_rand.o: ossl_pkcs7.h
ossl_rand.o: ossl_pkey.h
+ossl_rand.o: ossl_provider.h
ossl_rand.o: ossl_rand.c
ossl_rand.o: ossl_rand.h
ossl_rand.o: ossl_ssl.h
@@ -4003,6 +4279,7 @@ ossl_ssl.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_ssl.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4022,6 +4299,7 @@ ossl_ssl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ssl.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_ssl.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_ssl.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_ssl.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_ssl.o: $(hdrdir)/ruby/internal/symbol.h
ossl_ssl.o: $(hdrdir)/ruby/internal/value.h
ossl_ssl.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4032,6 +4310,7 @@ ossl_ssl.o: $(hdrdir)/ruby/io.h
ossl_ssl.o: $(hdrdir)/ruby/missing.h
ossl_ssl.o: $(hdrdir)/ruby/onigmo.h
ossl_ssl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl.o: $(hdrdir)/ruby/ractor.h
ossl_ssl.o: $(hdrdir)/ruby/ruby.h
ossl_ssl.o: $(hdrdir)/ruby/st.h
ossl_ssl.o: $(hdrdir)/ruby/subst.h
@@ -4052,6 +4331,7 @@ ossl_ssl.o: ossl_ocsp.h
ossl_ssl.o: ossl_pkcs12.h
ossl_ssl.o: ossl_pkcs7.h
ossl_ssl.o: ossl_pkey.h
+ossl_ssl.o: ossl_provider.h
ossl_ssl.o: ossl_rand.h
ossl_ssl.o: ossl_ssl.c
ossl_ssl.o: ossl_ssl.h
@@ -4196,6 +4476,7 @@ ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4215,6 +4496,7 @@ ossl_ssl_session.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_ssl_session.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/symbol.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/value.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4225,6 +4507,7 @@ ossl_ssl_session.o: $(hdrdir)/ruby/io.h
ossl_ssl_session.o: $(hdrdir)/ruby/missing.h
ossl_ssl_session.o: $(hdrdir)/ruby/onigmo.h
ossl_ssl_session.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl_session.o: $(hdrdir)/ruby/ractor.h
ossl_ssl_session.o: $(hdrdir)/ruby/ruby.h
ossl_ssl_session.o: $(hdrdir)/ruby/st.h
ossl_ssl_session.o: $(hdrdir)/ruby/subst.h
@@ -4245,6 +4528,7 @@ ossl_ssl_session.o: ossl_ocsp.h
ossl_ssl_session.o: ossl_pkcs12.h
ossl_ssl_session.o: ossl_pkcs7.h
ossl_ssl_session.o: ossl_pkey.h
+ossl_ssl_session.o: ossl_provider.h
ossl_ssl_session.o: ossl_rand.h
ossl_ssl_session.o: ossl_ssl.h
ossl_ssl_session.o: ossl_ssl_session.c
@@ -4389,6 +4673,7 @@ ossl_ts.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_ts.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4408,6 +4693,7 @@ ossl_ts.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ts.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_ts.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_ts.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_ts.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_ts.o: $(hdrdir)/ruby/internal/symbol.h
ossl_ts.o: $(hdrdir)/ruby/internal/value.h
ossl_ts.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4418,6 +4704,7 @@ ossl_ts.o: $(hdrdir)/ruby/io.h
ossl_ts.o: $(hdrdir)/ruby/missing.h
ossl_ts.o: $(hdrdir)/ruby/onigmo.h
ossl_ts.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ts.o: $(hdrdir)/ruby/ractor.h
ossl_ts.o: $(hdrdir)/ruby/ruby.h
ossl_ts.o: $(hdrdir)/ruby/st.h
ossl_ts.o: $(hdrdir)/ruby/subst.h
@@ -4438,6 +4725,7 @@ ossl_ts.o: ossl_ocsp.h
ossl_ts.o: ossl_pkcs12.h
ossl_ts.o: ossl_pkcs7.h
ossl_ts.o: ossl_pkey.h
+ossl_ts.o: ossl_provider.h
ossl_ts.o: ossl_rand.h
ossl_ts.o: ossl_ssl.h
ossl_ts.o: ossl_ts.c
@@ -4582,6 +4870,7 @@ ossl_x509.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4601,6 +4890,7 @@ ossl_x509.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509.o: $(hdrdir)/ruby/internal/value.h
ossl_x509.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4611,6 +4901,7 @@ ossl_x509.o: $(hdrdir)/ruby/io.h
ossl_x509.o: $(hdrdir)/ruby/missing.h
ossl_x509.o: $(hdrdir)/ruby/onigmo.h
ossl_x509.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509.o: $(hdrdir)/ruby/ractor.h
ossl_x509.o: $(hdrdir)/ruby/ruby.h
ossl_x509.o: $(hdrdir)/ruby/st.h
ossl_x509.o: $(hdrdir)/ruby/subst.h
@@ -4631,6 +4922,7 @@ ossl_x509.o: ossl_ocsp.h
ossl_x509.o: ossl_pkcs12.h
ossl_x509.o: ossl_pkcs7.h
ossl_x509.o: ossl_pkey.h
+ossl_x509.o: ossl_provider.h
ossl_x509.o: ossl_rand.h
ossl_x509.o: ossl_ssl.h
ossl_x509.o: ossl_ts.h
@@ -4775,6 +5067,7 @@ ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4794,6 +5087,7 @@ ossl_x509attr.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509attr.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/value.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4804,6 +5098,7 @@ ossl_x509attr.o: $(hdrdir)/ruby/io.h
ossl_x509attr.o: $(hdrdir)/ruby/missing.h
ossl_x509attr.o: $(hdrdir)/ruby/onigmo.h
ossl_x509attr.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509attr.o: $(hdrdir)/ruby/ractor.h
ossl_x509attr.o: $(hdrdir)/ruby/ruby.h
ossl_x509attr.o: $(hdrdir)/ruby/st.h
ossl_x509attr.o: $(hdrdir)/ruby/subst.h
@@ -4824,6 +5119,7 @@ ossl_x509attr.o: ossl_ocsp.h
ossl_x509attr.o: ossl_pkcs12.h
ossl_x509attr.o: ossl_pkcs7.h
ossl_x509attr.o: ossl_pkey.h
+ossl_x509attr.o: ossl_provider.h
ossl_x509attr.o: ossl_rand.h
ossl_x509attr.o: ossl_ssl.h
ossl_x509attr.o: ossl_ts.h
@@ -4968,6 +5264,7 @@ ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -4987,6 +5284,7 @@ ossl_x509cert.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509cert.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/value.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/value_type.h
@@ -4997,6 +5295,7 @@ ossl_x509cert.o: $(hdrdir)/ruby/io.h
ossl_x509cert.o: $(hdrdir)/ruby/missing.h
ossl_x509cert.o: $(hdrdir)/ruby/onigmo.h
ossl_x509cert.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509cert.o: $(hdrdir)/ruby/ractor.h
ossl_x509cert.o: $(hdrdir)/ruby/ruby.h
ossl_x509cert.o: $(hdrdir)/ruby/st.h
ossl_x509cert.o: $(hdrdir)/ruby/subst.h
@@ -5017,6 +5316,7 @@ ossl_x509cert.o: ossl_ocsp.h
ossl_x509cert.o: ossl_pkcs12.h
ossl_x509cert.o: ossl_pkcs7.h
ossl_x509cert.o: ossl_pkey.h
+ossl_x509cert.o: ossl_provider.h
ossl_x509cert.o: ossl_rand.h
ossl_x509cert.o: ossl_ssl.h
ossl_x509cert.o: ossl_ts.h
@@ -5161,6 +5461,7 @@ ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -5180,6 +5481,7 @@ ossl_x509crl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509crl.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/value.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/value_type.h
@@ -5190,6 +5492,7 @@ ossl_x509crl.o: $(hdrdir)/ruby/io.h
ossl_x509crl.o: $(hdrdir)/ruby/missing.h
ossl_x509crl.o: $(hdrdir)/ruby/onigmo.h
ossl_x509crl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509crl.o: $(hdrdir)/ruby/ractor.h
ossl_x509crl.o: $(hdrdir)/ruby/ruby.h
ossl_x509crl.o: $(hdrdir)/ruby/st.h
ossl_x509crl.o: $(hdrdir)/ruby/subst.h
@@ -5210,6 +5513,7 @@ ossl_x509crl.o: ossl_ocsp.h
ossl_x509crl.o: ossl_pkcs12.h
ossl_x509crl.o: ossl_pkcs7.h
ossl_x509crl.o: ossl_pkey.h
+ossl_x509crl.o: ossl_provider.h
ossl_x509crl.o: ossl_rand.h
ossl_x509crl.o: ossl_ssl.h
ossl_x509crl.o: ossl_ts.h
@@ -5354,6 +5658,7 @@ ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -5373,6 +5678,7 @@ ossl_x509ext.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509ext.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/value.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/value_type.h
@@ -5383,6 +5689,7 @@ ossl_x509ext.o: $(hdrdir)/ruby/io.h
ossl_x509ext.o: $(hdrdir)/ruby/missing.h
ossl_x509ext.o: $(hdrdir)/ruby/onigmo.h
ossl_x509ext.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509ext.o: $(hdrdir)/ruby/ractor.h
ossl_x509ext.o: $(hdrdir)/ruby/ruby.h
ossl_x509ext.o: $(hdrdir)/ruby/st.h
ossl_x509ext.o: $(hdrdir)/ruby/subst.h
@@ -5403,6 +5710,7 @@ ossl_x509ext.o: ossl_ocsp.h
ossl_x509ext.o: ossl_pkcs12.h
ossl_x509ext.o: ossl_pkcs7.h
ossl_x509ext.o: ossl_pkey.h
+ossl_x509ext.o: ossl_provider.h
ossl_x509ext.o: ossl_rand.h
ossl_x509ext.o: ossl_ssl.h
ossl_x509ext.o: ossl_ts.h
@@ -5547,6 +5855,7 @@ ossl_x509name.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509name.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -5566,6 +5875,7 @@ ossl_x509name.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509name.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509name.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509name.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509name.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509name.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509name.o: $(hdrdir)/ruby/internal/value.h
ossl_x509name.o: $(hdrdir)/ruby/internal/value_type.h
@@ -5576,6 +5886,7 @@ ossl_x509name.o: $(hdrdir)/ruby/io.h
ossl_x509name.o: $(hdrdir)/ruby/missing.h
ossl_x509name.o: $(hdrdir)/ruby/onigmo.h
ossl_x509name.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509name.o: $(hdrdir)/ruby/ractor.h
ossl_x509name.o: $(hdrdir)/ruby/ruby.h
ossl_x509name.o: $(hdrdir)/ruby/st.h
ossl_x509name.o: $(hdrdir)/ruby/subst.h
@@ -5596,6 +5907,7 @@ ossl_x509name.o: ossl_ocsp.h
ossl_x509name.o: ossl_pkcs12.h
ossl_x509name.o: ossl_pkcs7.h
ossl_x509name.o: ossl_pkey.h
+ossl_x509name.o: ossl_provider.h
ossl_x509name.o: ossl_rand.h
ossl_x509name.o: ossl_ssl.h
ossl_x509name.o: ossl_ts.h
@@ -5740,6 +6052,7 @@ ossl_x509req.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509req.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -5759,6 +6072,7 @@ ossl_x509req.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509req.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509req.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509req.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509req.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509req.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509req.o: $(hdrdir)/ruby/internal/value.h
ossl_x509req.o: $(hdrdir)/ruby/internal/value_type.h
@@ -5769,6 +6083,7 @@ ossl_x509req.o: $(hdrdir)/ruby/io.h
ossl_x509req.o: $(hdrdir)/ruby/missing.h
ossl_x509req.o: $(hdrdir)/ruby/onigmo.h
ossl_x509req.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509req.o: $(hdrdir)/ruby/ractor.h
ossl_x509req.o: $(hdrdir)/ruby/ruby.h
ossl_x509req.o: $(hdrdir)/ruby/st.h
ossl_x509req.o: $(hdrdir)/ruby/subst.h
@@ -5789,6 +6104,7 @@ ossl_x509req.o: ossl_ocsp.h
ossl_x509req.o: ossl_pkcs12.h
ossl_x509req.o: ossl_pkcs7.h
ossl_x509req.o: ossl_pkey.h
+ossl_x509req.o: ossl_provider.h
ossl_x509req.o: ossl_rand.h
ossl_x509req.o: ossl_ssl.h
ossl_x509req.o: ossl_ts.h
@@ -5933,6 +6249,7 @@ ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -5952,6 +6269,7 @@ ossl_x509revoked.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509revoked.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/value.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/value_type.h
@@ -5962,6 +6280,7 @@ ossl_x509revoked.o: $(hdrdir)/ruby/io.h
ossl_x509revoked.o: $(hdrdir)/ruby/missing.h
ossl_x509revoked.o: $(hdrdir)/ruby/onigmo.h
ossl_x509revoked.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509revoked.o: $(hdrdir)/ruby/ractor.h
ossl_x509revoked.o: $(hdrdir)/ruby/ruby.h
ossl_x509revoked.o: $(hdrdir)/ruby/st.h
ossl_x509revoked.o: $(hdrdir)/ruby/subst.h
@@ -5982,6 +6301,7 @@ ossl_x509revoked.o: ossl_ocsp.h
ossl_x509revoked.o: ossl_pkcs12.h
ossl_x509revoked.o: ossl_pkcs7.h
ossl_x509revoked.o: ossl_pkey.h
+ossl_x509revoked.o: ossl_provider.h
ossl_x509revoked.o: ossl_rand.h
ossl_x509revoked.o: ossl_ssl.h
ossl_x509revoked.o: ossl_ts.h
@@ -6126,6 +6446,7 @@ ossl_x509store.o: $(hdrdir)/ruby/internal/intern/re.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/ruby.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/select.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_x509store.o: $(hdrdir)/ruby/internal/intern/set.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/signal.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -6145,6 +6466,7 @@ ossl_x509store.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509store.o: $(hdrdir)/ruby/internal/static_assert.h
ossl_x509store.o: $(hdrdir)/ruby/internal/stdalign.h
ossl_x509store.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_x509store.o: $(hdrdir)/ruby/internal/stdckdint.h
ossl_x509store.o: $(hdrdir)/ruby/internal/symbol.h
ossl_x509store.o: $(hdrdir)/ruby/internal/value.h
ossl_x509store.o: $(hdrdir)/ruby/internal/value_type.h
@@ -6155,6 +6477,7 @@ ossl_x509store.o: $(hdrdir)/ruby/io.h
ossl_x509store.o: $(hdrdir)/ruby/missing.h
ossl_x509store.o: $(hdrdir)/ruby/onigmo.h
ossl_x509store.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509store.o: $(hdrdir)/ruby/ractor.h
ossl_x509store.o: $(hdrdir)/ruby/ruby.h
ossl_x509store.o: $(hdrdir)/ruby/st.h
ossl_x509store.o: $(hdrdir)/ruby/subst.h
@@ -6175,6 +6498,7 @@ ossl_x509store.o: ossl_ocsp.h
ossl_x509store.o: ossl_pkcs12.h
ossl_x509store.o: ossl_pkcs7.h
ossl_x509store.o: ossl_pkey.h
+ossl_x509store.o: ossl_provider.h
ossl_x509store.o: ossl_rand.h
ossl_x509store.o: ossl_ssl.h
ossl_x509store.o: ossl_ts.h
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index bc3e4d3a21..1f32980940 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -8,26 +8,43 @@
= Licence
This program is licensed under the same licence as Ruby.
- (See the file 'LICENCE'.)
+ (See the file 'COPYING'.)
=end
require "mkmf"
-dir_config_given = dir_config("openssl").any?
-dir_config("kerberos")
+ssl_dirs = dir_config("openssl")
+dir_config_given = ssl_dirs.any?
+
+_, ssl_ldir = ssl_dirs
+if ssl_ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
+ # According to the `mkmf.rb#dir_config`, the `--with-openssl-dir=<dir>` uses
+ # the value of the `File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])` as a
+ # loaded library directory name.
+ ruby_ldir_name = File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])
+
+ raise "OpenSSL library directory could not be found in '#{ssl_ldir}'. " \
+ "You might want to fix this error in one of the following ways.\n" \
+ " * Recompile OpenSSL by configuring it with --libdir=#{ruby_ldir_name} " \
+ " to specify the OpenSSL library directory.\n" \
+ " * Recompile Ruby by configuring it with --libdir=<dir> to specify the " \
+ "Ruby library directory.\n" \
+ " * Compile this openssl gem with --with-openssl-include=<dir> and " \
+ "--with-openssl-lib=<dir> options to specify the OpenSSL include and " \
+ "library directories."
+end
Logging::message "=== OpenSSL for Ruby configurator ===\n"
-##
-# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
-# To turn it on, use: --with-debug or --enable-debug
-#
-if with_config("debug") or enable_config("debug")
- $defs.push("-DOSSL_DEBUG")
-end
$defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")
-have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h") # Ruby 3.1
+# Missing in TruffleRuby
+have_func("rb_call_super_kw(0, NULL, 0)", "ruby.h")
+# Ruby 3.1
+have_func("rb_io_descriptor", "ruby/io.h")
+have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h")
+# Ruby 3.2
+have_func("rb_io_timeout", "ruby/io.h")
Logging::message "=== Checking for system dependent stuff... ===\n"
have_library("nsl", "t_open")
@@ -45,7 +62,6 @@ end
def find_openssl_library
if $mswin || $mingw
# required for static OpenSSL libraries
- have_library("gdi32") # OpenSSL <= 1.0.2 (for RAND_screen())
have_library("crypt32")
end
@@ -62,12 +78,6 @@ def find_openssl_library
return true
end
- # OpenSSL <= 1.0.2: libeay32.lib and ssleay32.lib.
- if have_library("libeay32", "CRYPTO_malloc") &&
- have_library("ssleay32", "SSL_new")
- return true
- end
-
# LibreSSL: libcrypto-##.lib and libssl-##.lib, where ## is the ABI version
# number. We have to find the version number out by scanning libpath.
libpath = $LIBPATH.dup
@@ -105,14 +115,15 @@ end
version_ok = if have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
is_libressl = true
- checking_for("LibreSSL version >= 3.1.0") {
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30100000L", "openssl/opensslv.h") }
+ checking_for("LibreSSL version >= 3.9.0") {
+ try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30900000L", "openssl/opensslv.h") }
else
- checking_for("OpenSSL version >= 1.0.2") {
- try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10002000L", "openssl/opensslv.h") }
+ is_openssl = true
+ checking_for("OpenSSL version >= 1.1.1") {
+ try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10101000L", "openssl/opensslv.h") }
end
unless version_ok
- raise "OpenSSL >= 1.0.2 or LibreSSL >= 3.1.0 is required"
+ raise "OpenSSL >= 1.1.1 or LibreSSL >= 3.9.0 is required"
end
# Prevent wincrypt.h from being included, which defines conflicting macro with openssl/x509.h
@@ -122,66 +133,30 @@ end
Logging::message "=== Checking for OpenSSL features... ===\n"
evp_h = "openssl/evp.h".freeze
-x509_h = "openssl/x509.h".freeze
ts_h = "openssl/ts.h".freeze
ssl_h = "openssl/ssl.h".freeze
+stack_h = "openssl/stack.h".freeze
# compile options
have_func("RAND_egd()", "openssl/rand.h")
-engines = %w{dynamic 4758cca aep atalla chil
- cswift nuron sureware ubsec padlock capi gmp gost cryptodev}
-engines.each { |name|
- have_func("ENGINE_load_#{name}()", "openssl/engine.h")
-}
-
-# added in 1.1.0
-if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
- $defs.push("-DHAVE_OPAQUE_OPENSSL")
-end
-have_func("EVP_MD_CTX_new()", evp_h)
-have_func("EVP_MD_CTX_free(NULL)", evp_h)
-have_func("EVP_MD_CTX_pkey_ctx(NULL)", evp_h)
-have_func("X509_STORE_get_ex_data(NULL, 0)", x509_h)
-have_func("X509_STORE_set_ex_data(NULL, 0, NULL)", x509_h)
-have_func("X509_STORE_get_ex_new_index(0, NULL, NULL, NULL, NULL)", x509_h)
-have_func("X509_CRL_get0_signature(NULL, NULL, NULL)", x509_h)
-have_func("X509_REQ_get0_signature(NULL, NULL, NULL)", x509_h)
-have_func("X509_REVOKED_get0_serialNumber(NULL)", x509_h)
-have_func("X509_REVOKED_get0_revocationDate(NULL)", x509_h)
-have_func("X509_get0_tbs_sigalg(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_untrusted(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_cert(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_chain(NULL)", x509_h)
-have_func("OCSP_SINGLERESP_get0_id(NULL)", "openssl/ocsp.h")
-have_func("SSL_CTX_get_ciphers(NULL)", ssl_h)
-have_func("X509_up_ref(NULL)", x509_h)
-have_func("X509_CRL_up_ref(NULL)", x509_h)
-have_func("X509_STORE_up_ref(NULL)", x509_h)
-have_func("SSL_SESSION_up_ref(NULL)", ssl_h)
-have_func("EVP_PKEY_up_ref(NULL)", evp_h)
-have_func("SSL_CTX_set_min_proto_version(NULL, 0)", ssl_h)
-have_func("SSL_CTX_get_security_level(NULL)", ssl_h)
-have_func("X509_get0_notBefore(NULL)", x509_h)
-have_func("SSL_SESSION_get_protocol_version(NULL)", ssl_h)
-have_func("TS_STATUS_INFO_get0_status(NULL)", ts_h)
-have_func("TS_STATUS_INFO_get0_text(NULL)", ts_h)
-have_func("TS_STATUS_INFO_get0_failure_info(NULL)", ts_h)
-have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", ts_h)
-have_func("TS_VERIFY_CTX_set_store(NULL, NULL)", ts_h)
-have_func("TS_VERIFY_CTX_add_flags(NULL, 0)", ts_h)
-have_func("TS_RESP_CTX_set_time_cb(NULL, NULL, NULL)", ts_h)
+
+# added in OpenSSL 1.0.2, not in LibreSSL yet
+have_func("SSL_CTX_set1_sigalgs_list(NULL, NULL)", ssl_h)
+# added in OpenSSL 1.0.2, not in LibreSSL or AWS-LC yet
+have_func("SSL_CTX_set1_client_sigalgs_list(NULL, NULL)", ssl_h)
+
+# added in 1.1.0, currently not in LibreSSL
have_func("EVP_PBE_scrypt(\"\", 0, (unsigned char *)\"\", 0, 0, 0, 0, 0, NULL, 0)", evp_h)
-have_func("SSL_CTX_set_post_handshake_auth(NULL, 0)", ssl_h)
-# added in 1.1.1
+# added in OpenSSL 1.1.1 and LibreSSL 3.5.0, then removed in LibreSSL 4.0.0
have_func("EVP_PKEY_check(NULL)", evp_h)
-have_func("EVP_PKEY_new_raw_private_key(0, NULL, (unsigned char *)\"\", 0)", evp_h)
-have_func("SSL_CTX_set_ciphersuites(NULL, \"\")", ssl_h)
+
+# added in OpenSSL 1.1.1, currently not in LibreSSL
+have_func("OPENSSL_sk_new_reserve(NULL, 0)", stack_h)
# added in 3.0.0
-have_func("SSL_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
+have_func("SSL_CTX_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
have_func("ERR_get_error_all(NULL, NULL, NULL, NULL, NULL)", "openssl/err.h")
-have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", ts_h)
have_func("SSL_CTX_load_verify_file(NULL, \"\")", ssl_h)
have_func("BN_check_prime(NULL, NULL, NULL)", "openssl/bn.h")
have_func("EVP_MD_CTX_get0_md(NULL)", evp_h)
@@ -189,8 +164,26 @@ have_func("EVP_MD_CTX_get_pkey_ctx(NULL)", evp_h)
have_func("EVP_PKEY_eq(NULL, NULL)", evp_h)
have_func("EVP_PKEY_dup(NULL)", evp_h)
+# added in 3.2.0
+have_func("SSL_get0_group_name(NULL)", ssl_h)
+
+# added in 3.4.0
+have_func("TS_VERIFY_CTX_set0_certs(NULL, NULL)", ts_h)
+
+# added in 3.5.0
+have_func("SSL_get0_peer_signature_name(NULL, NULL)", ssl_h)
+
+# added in 4.0.0
+have_func("ASN1_BIT_STRING_set1(NULL, NULL, 0, 0)", "openssl/asn1.h")
+
Logging::message "=== Checking done. ===\n"
+# Append flags from environment variables.
+extcflags = ENV["RUBY_OPENSSL_EXTCFLAGS"]
+append_cflags(extcflags.split) if extcflags
+extldflags = ENV["RUBY_OPENSSL_EXTLDFLAGS"]
+append_ldflags(extldflags.split) if extldflags
+
create_header
create_makefile("openssl")
Logging::message "Done.\n"
diff --git a/ext/openssl/lib/openssl.rb b/ext/openssl/lib/openssl.rb
index 8a342f15b6..98fa8d39f2 100644
--- a/ext/openssl/lib/openssl.rb
+++ b/ext/openssl/lib/openssl.rb
@@ -7,28 +7,32 @@
= Licence
This program is licensed under the same licence as Ruby.
- (See the file 'LICENCE'.)
+ (See the file 'COPYING'.)
=end
require 'openssl.so'
require_relative 'openssl/bn'
-require_relative 'openssl/pkey'
require_relative 'openssl/cipher'
require_relative 'openssl/digest'
require_relative 'openssl/hmac'
-require_relative 'openssl/x509'
-require_relative 'openssl/ssl'
require_relative 'openssl/pkcs5'
+require_relative 'openssl/pkey'
+require_relative 'openssl/ssl'
require_relative 'openssl/version'
+require_relative 'openssl/x509'
module OpenSSL
- # call-seq:
- # OpenSSL.secure_compare(string, string) -> boolean
+ # :call-seq:
+ # OpenSSL.secure_compare(string, string) -> true or false
#
# Constant time memory comparison. Inputs are hashed using SHA-256 to mask
# the length of the secret. Returns +true+ if the strings are identical,
# +false+ otherwise.
+ #
+ # This method is expensive due to the SHA-256 hashing. In most cases, where
+ # the input lengths are known to be equal or are not sensitive,
+ # OpenSSL.fixed_length_secure_compare should be used instead.
def self.secure_compare(a, b)
hashed_a = OpenSSL::Digest.digest('SHA256', a)
hashed_b = OpenSSL::Digest.digest('SHA256', b)
diff --git a/ext/openssl/lib/openssl/bn.rb b/ext/openssl/lib/openssl/bn.rb
index 0a5e11b4c2..e4889a140c 100644
--- a/ext/openssl/lib/openssl/bn.rb
+++ b/ext/openssl/lib/openssl/bn.rb
@@ -10,7 +10,7 @@
#
# = Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
module OpenSSL
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index d47e1082ef..1464a4292d 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -8,7 +8,7 @@
#
#= Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
##
@@ -24,25 +24,21 @@ module OpenSSL::Buffering
# A buffer which will retain binary encoding.
class Buffer < String
- BINARY = Encoding::BINARY
-
- def initialize
- super
-
- force_encoding(BINARY)
- end
+ unless String.method_defined?(:append_as_bytes)
+ alias_method :_append, :<<
+ def append_as_bytes(string)
+ if string.encoding == Encoding::BINARY
+ _append(string)
+ else
+ _append(string.b)
+ end
- def << string
- if string.encoding == BINARY
- super(string)
- else
- super(string.b)
+ self
end
-
- return self
end
- alias concat <<
+ undef_method :concat
+ undef_method :<<
end
##
@@ -77,7 +73,7 @@ module OpenSSL::Buffering
def fill_rbuff
begin
- @rbuffer << self.sysread(BLOCK_SIZE)
+ @rbuffer.append_as_bytes(self.sysread(BLOCK_SIZE))
rescue Errno::EAGAIN
retry
rescue EOFError
@@ -93,9 +89,7 @@ module OpenSSL::Buffering
nil
else
size = @rbuffer.size unless size
- ret = @rbuffer[0, size]
- @rbuffer[0, size] = ""
- ret
+ @rbuffer.slice!(0, size)
end
end
@@ -106,8 +100,13 @@ module OpenSSL::Buffering
#
# Get the next 8bit byte from `ssl`. Returns `nil` on EOF
def getbyte
- byte = read(1)
- byte && byte.unpack1("C")
+ read(1)&.ord
+ end
+
+ # Get the next 8bit byte. Raises EOFError on EOF
+ def readbyte
+ raise EOFError if eof?
+ getbyte
end
##
@@ -232,7 +231,7 @@ module OpenSSL::Buffering
#
# Unlike IO#gets the separator must be provided if a limit is provided.
- def gets(eol=$/, limit=nil)
+ def gets(eol=$/, limit=nil, chomp: false)
idx = @rbuffer.index(eol)
until @eof
break if idx
@@ -247,7 +246,11 @@ module OpenSSL::Buffering
if size && limit && limit >= 0
size = [size, limit].min
end
- consume_rbuff(size)
+ line = consume_rbuff(size)
+ if chomp && line
+ line.chomp!(eol)
+ end
+ line
end
##
@@ -345,17 +348,32 @@ module OpenSSL::Buffering
def do_write(s)
@wbuffer = Buffer.new unless defined? @wbuffer
- @wbuffer << s
- @wbuffer.force_encoding(Encoding::BINARY)
+ @wbuffer.append_as_bytes(s)
+
@sync ||= false
- if @sync or @wbuffer.size > BLOCK_SIZE
- until @wbuffer.empty?
- begin
- nwrote = syswrite(@wbuffer)
- rescue Errno::EAGAIN
- retry
+ buffer_size = @wbuffer.bytesize
+ if @sync or buffer_size > BLOCK_SIZE
+ nwrote = 0
+ begin
+ while nwrote < buffer_size do
+ begin
+ chunk = if nwrote > 0
+ @wbuffer.byteslice(nwrote, @wbuffer.bytesize)
+ else
+ @wbuffer
+ end
+
+ nwrote += syswrite(chunk)
+ rescue Errno::EAGAIN
+ retry
+ end
+ end
+ ensure
+ if nwrote < @wbuffer.bytesize
+ @wbuffer[0, nwrote] = ""
+ else
+ @wbuffer.clear
end
- @wbuffer[0, nwrote] = ""
end
end
end
@@ -432,10 +450,10 @@ module OpenSSL::Buffering
def puts(*args)
s = Buffer.new
if args.empty?
- s << "\n"
+ s.append_as_bytes("\n")
end
args.each{|arg|
- s << arg.to_s
+ s.append_as_bytes(arg.to_s)
s.sub!(/(?<!\n)\z/, "\n")
}
do_write(s)
@@ -449,7 +467,7 @@ module OpenSSL::Buffering
def print(*args)
s = Buffer.new
- args.each{ |arg| s << arg.to_s }
+ args.each{ |arg| s.append_as_bytes(arg.to_s) }
do_write(s)
nil
end
diff --git a/ext/openssl/lib/openssl/cipher.rb b/ext/openssl/lib/openssl/cipher.rb
index 8ad8c35dd3..ab75ac8e1a 100644
--- a/ext/openssl/lib/openssl/cipher.rb
+++ b/ext/openssl/lib/openssl/cipher.rb
@@ -9,7 +9,7 @@
#
# = Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
module OpenSSL
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
index 0f35ddadd3..4e6dea8d03 100644
--- a/ext/openssl/lib/openssl/digest.rb
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -9,7 +9,7 @@
#
# = Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
module OpenSSL
@@ -27,17 +27,21 @@ module OpenSSL
end
%w(MD4 MD5 RIPEMD160 SHA1 SHA224 SHA256 SHA384 SHA512).each do |name|
- klass = Class.new(self) {
- define_method(:initialize, ->(data = nil) {super(name, data)})
- }
-
- singleton = (class << klass; self; end)
-
- singleton.class_eval{
- define_method(:digest) {|data| new.digest(data)}
- define_method(:hexdigest) {|data| new.hexdigest(data)}
- }
+ klass = Class.new(self)
+ klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def initialize(data = nil)
+ super("#{name}", data)
+ end
+ RUBY
+ klass.singleton_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def digest(data)
+ new.digest(data)
+ end
+ def hexdigest(data)
+ new.hexdigest(data)
+ end
+ RUBY
const_set(name.tr('-', '_'), klass)
end
@@ -57,7 +61,7 @@ module OpenSSL
# OpenSSL::Digest("MD5")
# # => OpenSSL::Digest::MD5
#
- # Digest("Foo")
+ # OpenSSL::Digest("Foo")
# # => NameError: wrong constant name Foo
def Digest(name)
diff --git a/ext/openssl/lib/openssl/marshal.rb b/ext/openssl/lib/openssl/marshal.rb
index af5647192a..eb8eda4748 100644
--- a/ext/openssl/lib/openssl/marshal.rb
+++ b/ext/openssl/lib/openssl/marshal.rb
@@ -9,7 +9,7 @@
#
# = Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
module OpenSSL
module Marshal
diff --git a/ext/openssl/lib/openssl/pkey.rb b/ext/openssl/lib/openssl/pkey.rb
index 0414658a10..39871e15dd 100644
--- a/ext/openssl/lib/openssl/pkey.rb
+++ b/ext/openssl/lib/openssl/pkey.rb
@@ -7,6 +7,9 @@
require_relative 'marshal'
module OpenSSL::PKey
+ # Alias of PKeyError. Before version 4.0.0, this was a subclass of PKeyError.
+ DHError = PKeyError
+
class DH
include OpenSSL::Marshal
@@ -35,6 +38,18 @@ module OpenSSL::PKey
end
# :call-seq:
+ # dh.params -> hash
+ #
+ # Stores all parameters of key to a Hash.
+ #
+ # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
+ def params
+ %w{p q g pub_key priv_key}.map { |name|
+ [name, send(name)]
+ }.to_h
+ end
+
+ # :call-seq:
# dh.compute_key(pub_bn) -> string
#
# Returns a String containing a shared secret computed from the other
@@ -90,7 +105,7 @@ module OpenSSL::PKey
# puts dh0.pub_key == dh.pub_key #=> false
def generate_key!
if OpenSSL::OPENSSL_VERSION_NUMBER >= 0x30000000
- raise DHError, "OpenSSL::PKey::DH is immutable on OpenSSL 3.0; " \
+ raise PKeyError, "OpenSSL::PKey::DH is immutable on OpenSSL 3.0; " \
"use OpenSSL::PKey.generate_key instead"
end
@@ -135,6 +150,9 @@ module OpenSSL::PKey
end
end
+ # Alias of PKeyError. Before version 4.0.0, this was a subclass of PKeyError.
+ DSAError = PKeyError
+
class DSA
include OpenSSL::Marshal
@@ -154,6 +172,18 @@ module OpenSSL::PKey
OpenSSL::PKey.read(public_to_der)
end
+ # :call-seq:
+ # dsa.params -> hash
+ #
+ # Stores all parameters of key to a Hash.
+ #
+ # The hash has keys 'p', 'q', 'g', 'pub_key', and 'priv_key'.
+ def params
+ %w{p q g pub_key priv_key}.map { |name|
+ [name, send(name)]
+ }.to_h
+ end
+
class << self
# :call-seq:
# DSA.generate(size) -> dsa
@@ -218,13 +248,9 @@ module OpenSSL::PKey
# sig = dsa.sign_raw(nil, digest)
# p dsa.verify_raw(nil, sig, digest) #=> true
def syssign(string)
- q or raise OpenSSL::PKey::DSAError, "incomplete DSA"
- private? or raise OpenSSL::PKey::DSAError, "Private DSA key needed!"
- begin
- sign_raw(nil, string)
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::DSAError, $!.message
- end
+ q or raise PKeyError, "incomplete DSA"
+ private? or raise PKeyError, "Private DSA key needed!"
+ sign_raw(nil, string)
end
# :call-seq:
@@ -242,12 +268,13 @@ module OpenSSL::PKey
# A \DSA signature value.
def sysverify(digest, sig)
verify_raw(nil, sig, digest)
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::DSAError, $!.message
end
end
if defined?(EC)
+ # Alias of PKeyError. Before version 4.0.0, this was a subclass of PKeyError.
+ ECError = PKeyError
+
class EC
include OpenSSL::Marshal
@@ -258,8 +285,6 @@ module OpenSSL::PKey
# Consider using PKey::PKey#sign_raw and PKey::PKey#verify_raw instead.
def dsa_sign_asn1(data)
sign_raw(nil, data)
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::ECError, $!.message
end
# :call-seq:
@@ -269,8 +294,6 @@ module OpenSSL::PKey
# Consider using PKey::PKey#sign_raw and PKey::PKey#verify_raw instead.
def dsa_verify_asn1(data, sig)
verify_raw(nil, sig, data)
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::ECError, $!.message
end
# :call-seq:
@@ -310,6 +333,9 @@ module OpenSSL::PKey
end
end
+ # Alias of PKeyError. Before version 4.0.0, this was a subclass of PKeyError.
+ RSAError = PKeyError
+
class RSA
include OpenSSL::Marshal
@@ -328,6 +354,18 @@ module OpenSSL::PKey
OpenSSL::PKey.read(public_to_der)
end
+ # :call-seq:
+ # rsa.params -> hash
+ #
+ # Stores all parameters of key to a Hash.
+ #
+ # The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', and 'iqmp'.
+ def params
+ %w{n e d p q dmp1 dmq1 iqmp}.map { |name|
+ [name, send(name)]
+ }.to_h
+ end
+
class << self
# :call-seq:
# RSA.generate(size, exponent = 65537) -> RSA
@@ -371,15 +409,11 @@ module OpenSSL::PKey
# Consider using PKey::PKey#sign_raw and PKey::PKey#verify_raw, and
# PKey::PKey#verify_recover instead.
def private_encrypt(string, padding = PKCS1_PADDING)
- n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
- private? or raise OpenSSL::PKey::RSAError, "private key needed."
- begin
- sign_raw(nil, string, {
- "rsa_padding_mode" => translate_padding_mode(padding),
- })
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::RSAError, $!.message
- end
+ n or raise PKeyError, "incomplete RSA"
+ private? or raise PKeyError, "private key needed."
+ sign_raw(nil, string, {
+ "rsa_padding_mode" => translate_padding_mode(padding),
+ })
end
# :call-seq:
@@ -394,14 +428,10 @@ module OpenSSL::PKey
# Consider using PKey::PKey#sign_raw and PKey::PKey#verify_raw, and
# PKey::PKey#verify_recover instead.
def public_decrypt(string, padding = PKCS1_PADDING)
- n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
- begin
- verify_recover(nil, string, {
- "rsa_padding_mode" => translate_padding_mode(padding),
- })
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::RSAError, $!.message
- end
+ n or raise PKeyError, "incomplete RSA"
+ verify_recover(nil, string, {
+ "rsa_padding_mode" => translate_padding_mode(padding),
+ })
end
# :call-seq:
@@ -416,14 +446,10 @@ module OpenSSL::PKey
# <b>Deprecated in version 3.0</b>.
# Consider using PKey::PKey#encrypt and PKey::PKey#decrypt instead.
def public_encrypt(data, padding = PKCS1_PADDING)
- n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
- begin
- encrypt(data, {
- "rsa_padding_mode" => translate_padding_mode(padding),
- })
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::RSAError, $!.message
- end
+ n or raise PKeyError, "incomplete RSA"
+ encrypt(data, {
+ "rsa_padding_mode" => translate_padding_mode(padding),
+ })
end
# :call-seq:
@@ -437,15 +463,11 @@ module OpenSSL::PKey
# <b>Deprecated in version 3.0</b>.
# Consider using PKey::PKey#encrypt and PKey::PKey#decrypt instead.
def private_decrypt(data, padding = PKCS1_PADDING)
- n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
- private? or raise OpenSSL::PKey::RSAError, "private key needed."
- begin
- decrypt(data, {
- "rsa_padding_mode" => translate_padding_mode(padding),
- })
- rescue OpenSSL::PKey::PKeyError
- raise OpenSSL::PKey::RSAError, $!.message
- end
+ n or raise PKeyError, "incomplete RSA"
+ private? or raise PKeyError, "private key needed."
+ decrypt(data, {
+ "rsa_padding_mode" => translate_padding_mode(padding),
+ })
end
PKCS1_PADDING = 1
@@ -464,7 +486,7 @@ module OpenSSL::PKey
when PKCS1_OAEP_PADDING
"oaep"
else
- raise OpenSSL::PKey::PKeyError, "unsupported padding mode"
+ raise PKeyError, "unsupported padding mode"
end
end
end
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index ea8bb2a18e..3268c126b9 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -7,7 +7,7 @@
= Licence
This program is licensed under the same licence as Ruby.
- (See the file 'LICENCE'.)
+ (See the file 'COPYING'.)
=end
require "openssl/buffering"
@@ -22,7 +22,6 @@ module OpenSSL
module SSL
class SSLContext
DEFAULT_PARAMS = { # :nodoc:
- :min_version => OpenSSL::SSL::TLS1_VERSION,
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
:verify_hostname => true,
:options => -> {
@@ -33,28 +32,9 @@ module OpenSSL
}.call
}
- if defined?(OpenSSL::PKey::DH)
- DEFAULT_2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
------BEGIN DH PARAMETERS-----
-MIIBCAKCAQEA7E6kBrYiyvmKAMzQ7i8WvwVk9Y/+f8S7sCTN712KkK3cqd1jhJDY
-JbrYeNV3kUIKhPxWHhObHKpD1R84UpL+s2b55+iMd6GmL7OYmNIT/FccKhTcveab
-VBmZT86BZKYyf45hUF9FOuUM9xPzuK3Vd8oJQvfYMCd7LPC0taAEljQLR4Edf8E6
-YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
-1bNveX5wInh5GDx1FGhKBZ+s1H+aedudCm7sCgRwv8lKWYGiHzObSma8A86KG+MD
-7Lo5JquQ3DlBodj3IDyPrxIv96lvRPFtAwIBAg==
------END DH PARAMETERS-----
- _end_of_pem_
- private_constant :DEFAULT_2048
-
- DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen| # :nodoc:
- warn "using default DH parameters." if $VERBOSE
- DEFAULT_2048
- }
- end
-
- if !(OpenSSL::OPENSSL_VERSION.start_with?("OpenSSL") &&
- OpenSSL::OPENSSL_VERSION_NUMBER >= 0x10100000)
+ if !OpenSSL::OPENSSL_VERSION.start_with?("OpenSSL")
DEFAULT_PARAMS.merge!(
+ min_version: OpenSSL::SSL::TLS1_VERSION,
ciphers: %w{
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-RSA-AES128-GCM-SHA256
@@ -86,26 +66,13 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
AES256-SHA256
AES128-SHA
AES256-SHA
- }.join(":"),
+ }.join(":").freeze,
)
end
+ DEFAULT_PARAMS.freeze
DEFAULT_CERT_STORE = OpenSSL::X509::Store.new # :nodoc:
DEFAULT_CERT_STORE.set_default_paths
- DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
-
- # A callback invoked when DH parameters are required for ephemeral DH key
- # exchange.
- #
- # The callback is invoked with the SSLSocket, a
- # flag indicating the use of an export cipher and the keylength
- # required.
- #
- # The callback must return an OpenSSL::PKey::DH instance of the correct
- # key length.
- #
- # <b>Deprecated in version 3.0.</b> Use #tmp_dh= instead.
- attr_accessor :tmp_dh_callback
# A callback invoked at connect time to distinguish between multiple
# server names.
@@ -125,7 +92,6 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
# that this form is deprecated. New applications should use #min_version=
# and #max_version= as necessary.
def initialize(version = nil)
- self.options |= OpenSSL::SSL::OP_ALL
self.ssl_version = version if version
self.verify_mode = OpenSSL::SSL::VERIFY_NONE
self.verify_hostname = false
@@ -145,54 +111,24 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
# used.
def set_params(params={})
params = DEFAULT_PARAMS.merge(params)
- self.options = params.delete(:options) # set before min_version/max_version
+ self.options |= params.delete(:options) # set before min_version/max_version
params.each{|name, value| self.__send__("#{name}=", value) }
if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
unless self.ca_file or self.ca_path or self.cert_store
- self.cert_store = DEFAULT_CERT_STORE
+ if not defined?(Ractor) or Ractor.current == Ractor.main
+ self.cert_store = DEFAULT_CERT_STORE
+ else
+ self.cert_store = Ractor.current[:__openssl_default_store__] ||=
+ OpenSSL::X509::Store.new.tap { |store|
+ store.set_default_paths
+ }
+ end
end
end
return params
end
# call-seq:
- # ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION
- # ctx.min_version = :TLS1_2
- # ctx.min_version = nil
- #
- # Sets the lower bound on the supported SSL/TLS protocol version. The
- # version may be specified by an integer constant named
- # OpenSSL::SSL::*_VERSION, a Symbol, or +nil+ which means "any version".
- #
- # Be careful that you don't overwrite OpenSSL::SSL::OP_NO_{SSL,TLS}v*
- # options by #options= once you have called #min_version= or
- # #max_version=.
- #
- # === Example
- # ctx = OpenSSL::SSL::SSLContext.new
- # ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
- # ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
- #
- # sock = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx)
- # sock.connect # Initiates a connection using either TLS 1.1 or TLS 1.2
- def min_version=(version)
- set_minmax_proto_version(version, @max_proto_version ||= nil)
- @min_proto_version = version
- end
-
- # call-seq:
- # ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
- # ctx.max_version = :TLS1_2
- # ctx.max_version = nil
- #
- # Sets the upper bound of the supported SSL/TLS protocol version. See
- # #min_version= for the possible values.
- def max_version=(version)
- set_minmax_proto_version(@min_proto_version ||= nil, version)
- @max_proto_version = version
- end
-
- # call-seq:
# ctx.ssl_version = :TLSv1
# ctx.ssl_version = "SSLv23"
#
@@ -216,8 +152,7 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
end
version = METHODS_MAP[meth.intern] or
raise ArgumentError, "unknown SSL method `%s'" % meth
- set_minmax_proto_version(version, version)
- @min_proto_version = @max_proto_version = version
+ self.min_version = self.max_version = version
end
METHODS_MAP = {
@@ -252,6 +187,14 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
to_io.peeraddr
end
+ def local_address
+ to_io.local_address
+ end
+
+ def remote_address
+ to_io.remote_address
+ end
+
def setsockopt(level, optname, optval)
to_io.setsockopt(level, optname, optval)
end
@@ -271,6 +214,36 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
def do_not_reverse_lookup=(flag)
to_io.do_not_reverse_lookup = flag
end
+
+ def close_on_exec=(value)
+ to_io.close_on_exec = value
+ end
+
+ def close_on_exec?
+ to_io.close_on_exec?
+ end
+
+ def wait(*args)
+ to_io.wait(*args)
+ end
+
+ def wait_readable(*args)
+ to_io.wait_readable(*args)
+ end
+
+ def wait_writable(*args)
+ to_io.wait_writable(*args)
+ end
+
+ if IO.method_defined?(:timeout)
+ def timeout
+ to_io.timeout
+ end
+
+ def timeout=(value)
+ to_io.timeout=(value)
+ end
+ end
end
def verify_certificate_identity(cert, hostname)
@@ -421,6 +394,32 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
nil
end
+ # Close the stream for reading.
+ # This method is ignored by OpenSSL as there is no reasonable way to
+ # implement it, but exists for compatibility with IO.
+ def close_read
+ # Unsupported and ignored.
+ # Just don't read any more.
+ end
+
+ # Closes the stream for writing. The behavior of this method depends on
+ # the version of OpenSSL and the TLS protocol in use.
+ #
+ # - Sends a 'close_notify' alert to the peer.
+ # - Does not wait for the peer's 'close_notify' alert in response.
+ #
+ # In TLS 1.2 and earlier:
+ # - On receipt of a 'close_notify' alert, responds with a 'close_notify'
+ # alert of its own and close down the connection immediately,
+ # discarding any pending writes.
+ #
+ # Therefore, on TLS 1.2, this method will cause the connection to be
+ # completely shut down. On TLS 1.3, the connection will remain open for
+ # reading only.
+ def close_write
+ stop
+ end
+
private
def using_anon_cipher?
@@ -433,10 +432,6 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
@context.client_cert_cb
end
- def tmp_dh_callback
- @context.tmp_dh_callback || OpenSSL::SSL::SSLContext::DEFAULT_TMP_DH_CALLBACK
- end
-
def session_new_cb
@context.session_new_cb
end
@@ -494,7 +489,7 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
unless ctx.session_id_context
# see #6137 - session id may not exceed 32 bytes
prng = ::Random.new($0.hash)
- session_id = prng.bytes(16).unpack('H*')[0]
+ session_id = prng.bytes(16).unpack1('H*')
@ctx.session_id_context = session_id
end
@start_immediately = true
diff --git a/ext/openssl/lib/openssl/version.rb b/ext/openssl/lib/openssl/version.rb
index 4163f55064..395a720a31 100644
--- a/ext/openssl/lib/openssl/version.rb
+++ b/ext/openssl/lib/openssl/version.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
module OpenSSL
- VERSION = "3.1.0"
+ # The version string of Ruby/OpenSSL.
+ VERSION = "4.0.2"
end
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index f973f4f4dc..66765ffeab 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -9,7 +9,7 @@
#
# = Licence
# This program is licensed under the same licence as Ruby.
-# (See the file 'LICENCE'.)
+# (See the file 'COPYING'.)
#++
require_relative 'marshal'
@@ -122,8 +122,8 @@ module OpenSSL
include Helpers
# Get the distributionPoint fullName URI from the certificate's CRL
- # distribution points extension, as described in RFC5280 Section
- # 4.2.1.13
+ # distribution points extension, as described in RFC 5280 Section
+ # 4.2.1.13.
#
# Returns an array of strings or nil or raises ASN1::ASN1Error.
def crl_uris
@@ -135,19 +135,19 @@ module OpenSSL
raise ASN1::ASN1Error, "invalid extension"
end
- crl_uris = cdp_asn1.map do |crl_distribution_point|
+ crl_uris = cdp_asn1.flat_map do |crl_distribution_point|
distribution_point = crl_distribution_point.value.find do |v|
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
end
full_name = distribution_point&.value&.find do |v|
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
end
- full_name&.value&.find do |v|
+ full_name&.value&.select do |v|
v.tag_class == :CONTEXT_SPECIFIC && v.tag == 6 # uniformResourceIdentifier
end
end
- crl_uris&.map(&:value)
+ crl_uris.empty? ? nil : crl_uris.map(&:value)
end
end
@@ -346,6 +346,15 @@ module OpenSSL
include Extension::CRLDistributionPoints
include Extension::AuthorityInfoAccess
+ def inspect
+ "#<#{self.class}: " \
+ "subject=#{subject.inspect}, " \
+ "issuer=#{issuer.inspect}, " \
+ "serial=#{serial.inspect}, " \
+ "not_before=#{not_before.inspect rescue "(error)"}, " \
+ "not_after=#{not_after.inspect rescue "(error)"}>"
+ end
+
def pretty_print(q)
q.object_group(self) {
q.breakable
diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec
index 3a2f64f676..af1775e3b0 100644
--- a/ext/openssl/openssl.gemspec
+++ b/ext/openssl/openssl.gemspec
@@ -1,19 +1,20 @@
Gem::Specification.new do |spec|
spec.name = "openssl"
- spec.version = "3.1.0"
+ spec.version = "4.0.2"
spec.authors = ["Martin Bosslet", "SHIBATA Hiroshi", "Zachary Scott", "Kazuki Yamaguchi"]
spec.email = ["ruby-core@ruby-lang.org"]
- spec.summary = %q{OpenSSL provides SSL, TLS and general purpose cryptography.}
- spec.description = %q{It wraps the OpenSSL library.}
+ spec.summary = %q{SSL/TLS and general-purpose cryptography for Ruby}
+ spec.description = %q{OpenSSL for Ruby provides access to SSL/TLS and general-purpose cryptography based on the OpenSSL library.}
spec.homepage = "https://github.com/ruby/openssl"
- spec.license = "Ruby"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
spec.platform = "java"
spec.files = []
spec.add_runtime_dependency('jruby-openssl', '~> 0.14')
else
- spec.files = Dir["lib/**/*.rb", "ext/**/*.{c,h,rb}", "*.md", "BSDL", "LICENSE.txt"]
+ spec.files = Dir.glob(["lib/**/*.rb", "ext/**/*.{c,h,rb}", "*.md"], base: File.expand_path("..", __FILE__)) +
+ ["BSDL", "COPYING"]
spec.require_paths = ["lib"]
spec.extensions = ["ext/openssl/extconf.rb"]
end
@@ -21,7 +22,7 @@ Gem::Specification.new do |spec|
spec.extra_rdoc_files = Dir["*.md"]
spec.rdoc_options = ["--main", "README.md"]
- spec.required_ruby_version = ">= 2.6.0"
+ spec.required_ruby_version = ">= 2.7.0"
spec.metadata["msys2_mingw_dependencies"] = "openssl"
end
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
deleted file mode 100644
index 4415703db4..0000000000
--- a/ext/openssl/openssl_missing.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 'OpenSSL for Ruby' project
- * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
- * All rights reserved.
- */
-/*
- * This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
- */
-#include RUBY_EXTCONF_H
-
-#include <string.h> /* memcpy() */
-#include <openssl/x509_vfy.h>
-
-#include "openssl_missing.h"
-
-/*** added in 1.1.0 ***/
-#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
-void
-ossl_X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
- const X509_ALGOR **palg)
-{
- if (psig != NULL)
- *psig = crl->signature;
- if (palg != NULL)
- *palg = crl->sig_alg;
-}
-#endif
-
-#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
-void
-ossl_X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
- const X509_ALGOR **palg)
-{
- if (psig != NULL)
- *psig = req->signature;
- if (palg != NULL)
- *palg = req->sig_alg;
-}
-#endif
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
index 8629bfe505..ed3b5b7c0f 100644
--- a/ext/openssl/openssl_missing.h
+++ b/ext/openssl/openssl_missing.h
@@ -5,216 +5,14 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_OPENSSL_MISSING_H_)
#define _OSSL_OPENSSL_MISSING_H_
#include "ruby/config.h"
-/* added in 1.1.0 */
-#if !defined(HAVE_EVP_MD_CTX_NEW)
-# define EVP_MD_CTX_new EVP_MD_CTX_create
-#endif
-
-#if !defined(HAVE_EVP_MD_CTX_FREE)
-# define EVP_MD_CTX_free EVP_MD_CTX_destroy
-#endif
-
-#if !defined(HAVE_X509_STORE_GET_EX_DATA)
-# define X509_STORE_get_ex_data(x, idx) \
- CRYPTO_get_ex_data(&(x)->ex_data, (idx))
-#endif
-
-#if !defined(HAVE_X509_STORE_SET_EX_DATA)
-# define X509_STORE_set_ex_data(x, idx, data) \
- CRYPTO_set_ex_data(&(x)->ex_data, (idx), (data))
-#endif
-
-#if !defined(HAVE_X509_STORE_GET_EX_NEW_INDEX) && !defined(X509_STORE_get_ex_new_index)
-# define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
- CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, (l), (p), \
- (newf), (dupf), (freef))
-#endif
-
-#if !defined(HAVE_X509_CRL_GET0_SIGNATURE)
-void ossl_X509_CRL_get0_signature(const X509_CRL *, const ASN1_BIT_STRING **, const X509_ALGOR **);
-# define X509_CRL_get0_signature ossl_X509_CRL_get0_signature
-#endif
-
-#if !defined(HAVE_X509_REQ_GET0_SIGNATURE)
-void ossl_X509_REQ_get0_signature(const X509_REQ *, const ASN1_BIT_STRING **, const X509_ALGOR **);
-# define X509_REQ_get0_signature ossl_X509_REQ_get0_signature
-#endif
-
-#if !defined(HAVE_X509_REVOKED_GET0_SERIALNUMBER)
-# define X509_REVOKED_get0_serialNumber(x) ((x)->serialNumber)
-#endif
-
-#if !defined(HAVE_X509_REVOKED_GET0_REVOCATIONDATE)
-# define X509_REVOKED_get0_revocationDate(x) ((x)->revocationDate)
-#endif
-
-#if !defined(HAVE_X509_GET0_TBS_SIGALG)
-# define X509_get0_tbs_sigalg(x) ((x)->cert_info->signature)
-#endif
-
-#if !defined(HAVE_X509_STORE_CTX_GET0_UNTRUSTED)
-# define X509_STORE_CTX_get0_untrusted(x) ((x)->untrusted)
-#endif
-
-#if !defined(HAVE_X509_STORE_CTX_GET0_CERT)
-# define X509_STORE_CTX_get0_cert(x) ((x)->cert)
-#endif
-
-#if !defined(HAVE_X509_STORE_CTX_GET0_CHAIN)
-# define X509_STORE_CTX_get0_chain(ctx) X509_STORE_CTX_get_chain(ctx)
-#endif
-
-#if !defined(HAVE_OCSP_SINGLERESP_GET0_ID)
-# define OCSP_SINGLERESP_get0_id(s) ((s)->certId)
-#endif
-
-#if !defined(HAVE_SSL_CTX_GET_CIPHERS)
-# define SSL_CTX_get_ciphers(ctx) ((ctx)->cipher_list)
-#endif
-
-#if !defined(HAVE_X509_UP_REF)
-# define X509_up_ref(x) \
- CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509)
-#endif
-
-#if !defined(HAVE_X509_CRL_UP_REF)
-# define X509_CRL_up_ref(x) \
- CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_CRL);
-#endif
-
-#if !defined(HAVE_X509_STORE_UP_REF)
-# define X509_STORE_up_ref(x) \
- CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_X509_STORE);
-#endif
-
-#if !defined(HAVE_SSL_SESSION_UP_REF)
-# define SSL_SESSION_up_ref(x) \
- CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_SSL_SESSION);
-#endif
-
-#if !defined(HAVE_EVP_PKEY_UP_REF)
-# define EVP_PKEY_up_ref(x) \
- CRYPTO_add(&(x)->references, 1, CRYPTO_LOCK_EVP_PKEY);
-#endif
-
-#if !defined(HAVE_OPAQUE_OPENSSL)
-#define IMPL_PKEY_GETTER(_type, _name) \
-static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \
- return pkey->pkey._name; }
-#define IMPL_KEY_ACCESSOR2(_type, _group, a1, a2, _fail_cond) \
-static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2) { \
- if (a1) *a1 = obj->a1; \
- if (a2) *a2 = obj->a2; } \
-static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2) { \
- if (_fail_cond) return 0; \
- BN_clear_free(obj->a1); obj->a1 = a1; \
- BN_clear_free(obj->a2); obj->a2 = a2; \
- return 1; }
-#define IMPL_KEY_ACCESSOR3(_type, _group, a1, a2, a3, _fail_cond) \
-static inline void _type##_get0_##_group(const _type *obj, const BIGNUM **a1, const BIGNUM **a2, const BIGNUM **a3) { \
- if (a1) *a1 = obj->a1; \
- if (a2) *a2 = obj->a2; \
- if (a3) *a3 = obj->a3; } \
-static inline int _type##_set0_##_group(_type *obj, BIGNUM *a1, BIGNUM *a2, BIGNUM *a3) { \
- if (_fail_cond) return 0; \
- BN_clear_free(obj->a1); obj->a1 = a1; \
- BN_clear_free(obj->a2); obj->a2 = a2; \
- BN_clear_free(obj->a3); obj->a3 = a3; \
- return 1; }
-
-#if !defined(OPENSSL_NO_RSA)
-IMPL_PKEY_GETTER(RSA, rsa)
-IMPL_KEY_ACCESSOR3(RSA, key, n, e, d, (n == obj->n || e == obj->e || (obj->d && d == obj->d)))
-IMPL_KEY_ACCESSOR2(RSA, factors, p, q, (p == obj->p || q == obj->q))
-IMPL_KEY_ACCESSOR3(RSA, crt_params, dmp1, dmq1, iqmp, (dmp1 == obj->dmp1 || dmq1 == obj->dmq1 || iqmp == obj->iqmp))
-#endif
-
-#if !defined(OPENSSL_NO_DSA)
-IMPL_PKEY_GETTER(DSA, dsa)
-IMPL_KEY_ACCESSOR2(DSA, key, pub_key, priv_key, (pub_key == obj->pub_key || (obj->priv_key && priv_key == obj->priv_key)))
-IMPL_KEY_ACCESSOR3(DSA, pqg, p, q, g, (p == obj->p || q == obj->q || g == obj->g))
-#endif
-
-#if !defined(OPENSSL_NO_DH)
-IMPL_PKEY_GETTER(DH, dh)
-IMPL_KEY_ACCESSOR2(DH, key, pub_key, priv_key, (pub_key == obj->pub_key || (obj->priv_key && priv_key == obj->priv_key)))
-IMPL_KEY_ACCESSOR3(DH, pqg, p, q, g, (p == obj->p || (obj->q && q == obj->q) || g == obj->g))
-static inline ENGINE *DH_get0_engine(DH *dh) { return dh->engine; }
-#endif
-
-#if !defined(OPENSSL_NO_EC)
-IMPL_PKEY_GETTER(EC_KEY, ec)
-#endif
-
-#undef IMPL_PKEY_GETTER
-#undef IMPL_KEY_ACCESSOR2
-#undef IMPL_KEY_ACCESSOR3
-#endif /* HAVE_OPAQUE_OPENSSL */
-
-#if !defined(EVP_CTRL_AEAD_GET_TAG)
-# define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
-# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
-# define EVP_CTRL_AEAD_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN
-#endif
-
-#if !defined(HAVE_X509_GET0_NOTBEFORE)
-# define X509_get0_notBefore(x) X509_get_notBefore(x)
-# define X509_get0_notAfter(x) X509_get_notAfter(x)
-# define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x)
-# define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x)
-# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t)
-# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t)
-# define X509_CRL_set1_lastUpdate(x, t) X509_CRL_set_lastUpdate(x, t)
-# define X509_CRL_set1_nextUpdate(x, t) X509_CRL_set_nextUpdate(x, t)
-#endif
-
-#if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION)
-# define SSL_SESSION_get_protocol_version(s) ((s)->ssl_version)
-#endif
-
-#if !defined(HAVE_TS_STATUS_INFO_GET0_STATUS)
-# define TS_STATUS_INFO_get0_status(a) ((a)->status)
-#endif
-
-#if !defined(HAVE_TS_STATUS_INFO_GET0_TEXT)
-# define TS_STATUS_INFO_get0_text(a) ((a)->text)
-#endif
-
-#if !defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO)
-# define TS_STATUS_INFO_get0_failure_info(a) ((a)->failure_info)
-#endif
-
-#if !defined(HAVE_TS_VERIFY_CTS_SET_CERTS)
-# define TS_VERIFY_CTS_set_certs(ctx, crts) ((ctx)->certs=(crts))
-#endif
-
-#if !defined(HAVE_TS_VERIFY_CTX_SET_STORE)
-# define TS_VERIFY_CTX_set_store(ctx, str) ((ctx)->store=(str))
-#endif
-
-#if !defined(HAVE_TS_VERIFY_CTX_ADD_FLAGS)
-# define TS_VERIFY_CTX_add_flags(ctx, f) ((ctx)->flags |= (f))
-#endif
-
-#if !defined(HAVE_TS_RESP_CTX_SET_TIME_CB)
-# define TS_RESP_CTX_set_time_cb(ctx, callback, dta) do { \
- (ctx)->time_cb = (callback); \
- (ctx)->time_cb_data = (dta); \
- } while (0)
-#endif
-
/* added in 3.0.0 */
-#if !defined(HAVE_TS_VERIFY_CTX_SET_CERTS)
-# define TS_VERIFY_CTX_set_certs(ctx, crts) TS_VERIFY_CTS_set_certs(ctx, crts)
-#endif
-
#ifndef HAVE_EVP_MD_CTX_GET0_MD
# define EVP_MD_CTX_get0_md(ctx) EVP_MD_CTX_md(ctx)
#endif
@@ -224,15 +22,34 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
* EVP_MD_CTX_get_pkey_ctx(x) in OpenSSL 3.0.
*/
#ifndef HAVE_EVP_MD_CTX_GET_PKEY_CTX
-# ifdef HAVE_EVP_MD_CTX_PKEY_CTX
# define EVP_MD_CTX_get_pkey_ctx(x) EVP_MD_CTX_pkey_ctx(x)
-# else
-# define EVP_MD_CTX_get_pkey_ctx(x) (x)->pctx
-# endif
#endif
#ifndef HAVE_EVP_PKEY_EQ
# define EVP_PKEY_eq(a, b) EVP_PKEY_cmp(a, b)
#endif
+/* added in 4.0.0 */
+#ifndef HAVE_ASN1_BIT_STRING_SET1
+static inline int
+ASN1_BIT_STRING_set1(ASN1_BIT_STRING *bitstr, const uint8_t *data,
+ size_t length, int unused_bits)
+{
+ if (length > INT_MAX || !ASN1_STRING_set(bitstr, data, (int)length))
+ return 0;
+ bitstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
+ bitstr->flags |= ASN1_STRING_FLAG_BITS_LEFT | unused_bits;
+ return 1;
+}
+
+static inline int
+ASN1_BIT_STRING_get_length(const ASN1_BIT_STRING *bitstr, size_t *length,
+ int *unused_bits)
+{
+ *length = bitstr->length;
+ *unused_bits = bitstr->flags & 0x07;
+ return 1;
+}
+#endif
+
#endif /* _OSSL_OPENSSL_MISSING_H_ */
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 6c532aca94..5716e6f100 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -5,93 +5,83 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
#include <stdarg.h> /* for ossl_raise */
-/* OpenSSL >= 1.1.0 and LibreSSL >= 2.9.0 */
-#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER >= 0x10100000
-# define HAVE_OPENSSL_110_THREADING_API
-#else
-# include <ruby/thread_native.h>
-#endif
-
/*
* Data Conversion
*/
-#define OSSL_IMPL_ARY2SK(name, type, expected_class, dup) \
-VALUE \
-ossl_##name##_ary2sk0(VALUE ary) \
-{ \
- STACK_OF(type) *sk; \
- VALUE val; \
- type *x; \
- int i; \
- \
- Check_Type(ary, T_ARRAY); \
- sk = sk_##type##_new_null(); \
- if (!sk) ossl_raise(eOSSLError, NULL); \
- \
- for (i = 0; i < RARRAY_LEN(ary); i++) { \
- val = rb_ary_entry(ary, i); \
- if (!rb_obj_is_kind_of(val, expected_class)) { \
- sk_##type##_pop_free(sk, type##_free); \
- ossl_raise(eOSSLError, "object in array not" \
- " of class ##type##"); \
- } \
- x = dup(val); /* NEED TO DUP */ \
- sk_##type##_push(sk, x); \
- } \
- return (VALUE)sk; \
-} \
- \
-STACK_OF(type) * \
-ossl_protect_##name##_ary2sk(VALUE ary, int *status) \
-{ \
- return (STACK_OF(type)*)rb_protect( \
- (VALUE (*)(VALUE))ossl_##name##_ary2sk0, \
- ary, \
- status); \
-} \
- \
-STACK_OF(type) * \
-ossl_##name##_ary2sk(VALUE ary) \
-{ \
- STACK_OF(type) *sk; \
- int status = 0; \
- \
- sk = ossl_protect_##name##_ary2sk(ary, &status); \
- if (status) rb_jump_tag(status); \
- \
- return sk; \
+#define OSSL_IMPL_ARY2SK(name, type, expected_class, dup) \
+VALUE \
+ossl_##name##_ary2sk0(VALUE ary) \
+{ \
+ STACK_OF(type) *sk; \
+ VALUE val; \
+ type *x; \
+ int i; \
+ \
+ Check_Type(ary, T_ARRAY); \
+ sk = sk_##type##_new_null(); \
+ if (!sk) ossl_raise(eOSSLError, NULL); \
+ \
+ for (i = 0; i < RARRAY_LEN(ary); i++) { \
+ val = rb_ary_entry(ary, i); \
+ if (!rb_obj_is_kind_of(val, expected_class)) { \
+ sk_##type##_pop_free(sk, type##_free); \
+ ossl_raise(eOSSLError, "object in array not" \
+ " of class ##type##"); \
+ } \
+ x = dup(val); /* NEED TO DUP */ \
+ if (!sk_##type##_push(sk, x)) { \
+ type##_free(x); \
+ sk_##type##_pop_free(sk, type##_free); \
+ ossl_raise(eOSSLError, NULL); \
+ } \
+ } \
+ return (VALUE)sk; \
+} \
+ \
+STACK_OF(type) * \
+ossl_protect_##name##_ary2sk(VALUE ary, int *status) \
+{ \
+ return (STACK_OF(type)*)rb_protect( \
+ (VALUE (*)(VALUE))ossl_##name##_ary2sk0, \
+ ary, \
+ status); \
+} \
+ \
+STACK_OF(type) * \
+ossl_##name##_ary2sk(VALUE ary) \
+{ \
+ STACK_OF(type) *sk; \
+ int status = 0; \
+ \
+ sk = ossl_protect_##name##_ary2sk(ary, &status); \
+ if (status) rb_jump_tag(status); \
+ \
+ return sk; \
}
OSSL_IMPL_ARY2SK(x509, X509, cX509Cert, DupX509CertPtr)
-#define OSSL_IMPL_SK2ARY(name, type) \
-VALUE \
-ossl_##name##_sk2ary(const STACK_OF(type) *sk) \
-{ \
- type *t; \
- int i, num; \
- VALUE ary; \
- \
- if (!sk) { \
- OSSL_Debug("empty sk!"); \
- return Qnil; \
- } \
- num = sk_##type##_num(sk); \
- if (num < 0) { \
- OSSL_Debug("items in sk < -1???"); \
- return rb_ary_new(); \
- } \
- ary = rb_ary_new2(num); \
- \
- for (i=0; i<num; i++) { \
- t = sk_##type##_value(sk, i); \
- rb_ary_push(ary, ossl_##name##_new(t)); \
- } \
- return ary; \
+#define OSSL_IMPL_SK2ARY(name, type) \
+VALUE \
+ossl_##name##_sk2ary(const STACK_OF(type) *sk) \
+{ \
+ type *t; \
+ int i, num; \
+ VALUE ary; \
+ \
+ RUBY_ASSERT(sk != NULL); \
+ num = sk_##type##_num(sk); \
+ ary = rb_ary_new_capa(num); \
+ \
+ for (i=0; i<num; i++) { \
+ t = sk_##type##_value(sk, i); \
+ rb_ary_push(ary, ossl_##name##_new(t)); \
+ } \
+ return ary; \
}
OSSL_IMPL_SK2ARY(x509, X509)
OSSL_IMPL_SK2ARY(x509crl, X509_CRL)
@@ -111,14 +101,14 @@ ossl_str_new(const char *ptr, long len, int *pstate)
str = rb_protect(ossl_str_new_i, len, &state);
if (pstate)
- *pstate = state;
+ *pstate = state;
if (state) {
- if (!pstate)
- rb_set_errinfo(Qnil);
- return Qnil;
+ if (!pstate)
+ rb_set_errinfo(Qnil);
+ return Qnil;
}
if (ptr)
- memcpy(RSTRING_PTR(str), ptr, len);
+ memcpy(RSTRING_PTR(str), ptr, len);
return str;
}
@@ -131,22 +121,22 @@ ossl_buf2str(char *buf, int len)
str = ossl_str_new(buf, len, &state);
OPENSSL_free(buf);
if (state)
- rb_jump_tag(state);
+ rb_jump_tag(state);
return str;
}
void
-ossl_bin2hex(unsigned char *in, char *out, size_t inlen)
+ossl_bin2hex(const unsigned char *in, char *out, size_t inlen)
{
const char *hex = "0123456789abcdef";
size_t i;
assert(inlen <= LONG_MAX / 2);
for (i = 0; i < inlen; i++) {
- unsigned char p = in[i];
+ unsigned char p = in[i];
- out[i * 2 + 0] = hex[p >> 4];
- out[i * 2 + 1] = hex[p & 0x0f];
+ out[i * 2 + 0] = hex[p >> 4];
+ out[i * 2 + 1] = hex[p & 0x0f];
}
}
@@ -157,14 +147,14 @@ VALUE
ossl_pem_passwd_value(VALUE pass)
{
if (NIL_P(pass))
- return Qnil;
+ return Qnil;
StringValue(pass);
/* PEM_BUFSIZE is currently used as the second argument of pem_password_cb,
* that is +max_len+ of ossl_pem_passwd_cb() */
if (RSTRING_LEN(pass) > PEM_BUFSIZE)
- ossl_raise(eOSSLError, "password must not be longer than %d bytes", PEM_BUFSIZE);
+ ossl_raise(eOSSLError, "password must not be longer than %d bytes", PEM_BUFSIZE);
return pass;
}
@@ -174,7 +164,7 @@ ossl_pem_passwd_cb0(VALUE flag)
{
VALUE pass = rb_yield(flag);
if (NIL_P(pass))
- return Qnil;
+ return Qnil;
StringValue(pass);
return pass;
}
@@ -187,46 +177,46 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
VALUE rflag, pass = (VALUE)pwd_;
if (RTEST(pass)) {
- /* PEM_def_callback(buf, max_len, flag, StringValueCStr(pass)) does not
- * work because it does not allow NUL characters and truncates to 1024
- * bytes silently if the input is over 1024 bytes */
- if (RB_TYPE_P(pass, T_STRING)) {
- len = RSTRING_LEN(pass);
- if (len <= max_len) {
- memcpy(buf, RSTRING_PTR(pass), len);
- return (int)len;
- }
- }
- OSSL_Debug("passed data is not valid String???");
- return -1;
+ /* PEM_def_callback(buf, max_len, flag, StringValueCStr(pass)) does not
+ * work because it does not allow NUL characters and truncates to 1024
+ * bytes silently if the input is over 1024 bytes */
+ if (RB_TYPE_P(pass, T_STRING)) {
+ len = RSTRING_LEN(pass);
+ if (len <= max_len) {
+ memcpy(buf, RSTRING_PTR(pass), len);
+ return (int)len;
+ }
+ }
+ OSSL_Debug("passed data is not valid String???");
+ return -1;
}
if (!rb_block_given_p()) {
- return PEM_def_callback(buf, max_len, flag, NULL);
+ return PEM_def_callback(buf, max_len, flag, NULL);
}
while (1) {
- /*
- * when the flag is nonzero, this passphrase
- * will be used to perform encryption; otherwise it will
- * be used to perform decryption.
- */
- rflag = flag ? Qtrue : Qfalse;
- pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
- if (status) {
- /* ignore an exception raised. */
- rb_set_errinfo(Qnil);
- return -1;
- }
- if (NIL_P(pass))
- return -1;
- len = RSTRING_LEN(pass);
- if (len > max_len) {
- rb_warning("password must not be longer than %d bytes", max_len);
- continue;
- }
- memcpy(buf, RSTRING_PTR(pass), len);
- break;
+ /*
+ * when the flag is nonzero, this password
+ * will be used to perform encryption; otherwise it will
+ * be used to perform decryption.
+ */
+ rflag = flag ? Qtrue : Qfalse;
+ pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
+ if (status) {
+ /* ignore an exception raised. */
+ rb_set_errinfo(Qnil);
+ return -1;
+ }
+ if (NIL_P(pass))
+ return -1;
+ len = RSTRING_LEN(pass);
+ if (len > max_len) {
+ rb_warning("password must not be longer than %d bytes", max_len);
+ continue;
+ }
+ memcpy(buf, RSTRING_PTR(pass), len);
+ break;
}
return (int)len;
}
@@ -261,34 +251,46 @@ VALUE
ossl_to_der_if_possible(VALUE obj)
{
if(rb_respond_to(obj, ossl_s_to_der))
- return ossl_to_der(obj);
+ return ossl_to_der(obj);
return obj;
}
/*
* Errors
*/
+static ID id_i_errors;
+
+static void collect_errors_into(VALUE ary);
+
VALUE
ossl_make_error(VALUE exc, VALUE str)
{
unsigned long e;
+ const char *data;
+ int flags;
+ VALUE errors = rb_ary_new();
- e = ERR_peek_last_error();
+ if (NIL_P(str))
+ str = rb_str_new(NULL, 0);
+
+#ifdef HAVE_ERR_GET_ERROR_ALL
+ e = ERR_peek_last_error_all(NULL, NULL, NULL, &data, &flags);
+#else
+ e = ERR_peek_last_error_line_data(NULL, NULL, &data, &flags);
+#endif
if (e) {
- const char *msg = ERR_reason_error_string(e);
-
- if (NIL_P(str)) {
- if (msg) str = rb_str_new_cstr(msg);
- }
- else {
- if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
- rb_str_cat2(str, msg ? msg : "(null)");
- }
- ossl_clear_error();
+ const char *msg = ERR_reason_error_string(e);
+
+ if (RSTRING_LEN(str)) rb_str_cat_cstr(str, ": ");
+ rb_str_cat_cstr(str, msg ? msg : "(null)");
+ if (flags & ERR_TXT_STRING && data)
+ rb_str_catf(str, " (%s)", data);
+ collect_errors_into(errors);
}
- if (NIL_P(str)) str = rb_str_new(0, 0);
- return rb_exc_new3(exc, str);
+ VALUE obj = rb_exc_new_str(exc, str);
+ rb_ivar_set(obj, id_i_errors, errors);
+ return obj;
}
void
@@ -298,24 +300,23 @@ ossl_raise(VALUE exc, const char *fmt, ...)
VALUE err;
if (fmt) {
- va_start(args, fmt);
- err = rb_vsprintf(fmt, args);
- va_end(args);
+ va_start(args, fmt);
+ err = rb_vsprintf(fmt, args);
+ va_end(args);
}
else {
- err = Qnil;
+ err = Qnil;
}
rb_exc_raise(ossl_make_error(exc, err));
}
-void
-ossl_clear_error(void)
+static void
+collect_errors_into(VALUE ary)
{
- if (dOSSL == Qtrue) {
+ if (dOSSL == Qtrue || !NIL_P(ary)) {
unsigned long e;
const char *file, *data, *func, *lib, *reason;
- char append[256] = "";
int line, flags;
#ifdef HAVE_ERR_GET_ERROR_ALL
@@ -327,13 +328,18 @@ ossl_clear_error(void)
lib = ERR_lib_error_string(e);
reason = ERR_reason_error_string(e);
+ VALUE str = rb_sprintf("error:%08lX:%s:%s:%s", e, lib ? lib : "",
+ func ? func : "", reason ? reason : "");
if (flags & ERR_TXT_STRING) {
if (!data)
data = "(null)";
- snprintf(append, sizeof(append), " (%s)", data);
+ rb_str_catf(str, " (%s)", data);
}
- rb_warn("error on stack: error:%08lX:%s:%s:%s%s", e, lib ? lib : "",
- func ? func : "", reason ? reason : "", append);
+
+ if (dOSSL == Qtrue)
+ rb_warn("error on stack: %"PRIsVALUE, str);
+ if (!NIL_P(ary))
+ rb_ary_push(ary, str);
}
}
else {
@@ -341,16 +347,61 @@ ossl_clear_error(void)
}
}
+void
+ossl_clear_error(void)
+{
+ collect_errors_into(Qnil);
+}
+
+/*
+ * call-seq:
+ * ossl_error.detailed_message(**) -> string
+ *
+ * Returns the exception message decorated with the captured \OpenSSL error
+ * queue entries.
+ */
+static VALUE
+osslerror_detailed_message(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str;
+#ifdef HAVE_RB_CALL_SUPER_KW
+ // Ruby >= 3.2
+ if (RTEST(rb_funcall(rb_eException, rb_intern("method_defined?"), 1,
+ ID2SYM(rb_intern("detailed_message")))))
+ str = rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
+ else
+#endif
+ str = rb_funcall(self, rb_intern("message"), 0);
+ VALUE errors = rb_attr_get(self, id_i_errors);
+
+ // OpenSSLError was not created by ossl_make_error()
+ if (!RB_TYPE_P(errors, T_ARRAY))
+ return str;
+
+ str = rb_str_resurrect(str);
+ rb_str_catf(str, "\nOpenSSL error queue reported %ld errors:",
+ RARRAY_LEN(errors));
+ for (long i = 0; i < RARRAY_LEN(errors); i++) {
+ VALUE err = RARRAY_AREF(errors, i);
+ rb_str_catf(str, "\n%"PRIsVALUE, err);
+ }
+ return str;
+}
+
/*
* call-seq:
* OpenSSL.errors -> [String...]
*
- * See any remaining errors held in queue.
+ * Returns any remaining errors held in the \OpenSSL thread-local error queue
+ * and clears the queue. This should normally return an empty array.
+ *
+ * This is intended for debugging Ruby/OpenSSL. If you see any errors here,
+ * it likely indicates a bug in the extension. Please file an issue at
+ * https://github.com/ruby/openssl.
*
- * Any errors you see here are probably due to a bug in Ruby's OpenSSL
- * implementation.
+ * For debugging your program, OpenSSL.debug= may be useful.
*/
-VALUE
+static VALUE
ossl_get_errors(VALUE _)
{
VALUE ary;
@@ -369,25 +420,11 @@ ossl_get_errors(VALUE _)
*/
VALUE dOSSL;
-#if !defined(HAVE_VA_ARGS_MACRO)
-void
-ossl_debug(const char *fmt, ...)
-{
- va_list args;
-
- if (dOSSL == Qtrue) {
- fprintf(stderr, "OSSL_DEBUG: ");
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- fprintf(stderr, " [CONTEXT N/A]\n");
- }
-}
-#endif
-
/*
* call-seq:
* OpenSSL.debug -> true | false
+ *
+ * Returns whether Ruby/OpenSSL's debug mode is currently enabled.
*/
static VALUE
ossl_debug_get(VALUE self)
@@ -397,9 +434,9 @@ ossl_debug_get(VALUE self)
/*
* call-seq:
- * OpenSSL.debug = boolean -> boolean
+ * OpenSSL.debug = boolean
*
- * Turns on or off debug mode. With debug mode, all errors added to the OpenSSL
+ * Turns on or off debug mode. With debug mode, all errors added to the \OpenSSL
* error queue will be printed to stderr.
*/
static VALUE
@@ -413,12 +450,18 @@ ossl_debug_set(VALUE self, VALUE val)
/*
* call-seq:
* OpenSSL.fips_mode -> true | false
+ *
+ * Returns whether the FIPS mode is currently enabled.
*/
static VALUE
ossl_fips_mode_get(VALUE self)
{
-#ifdef OPENSSL_FIPS
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ VALUE enabled;
+ enabled = EVP_default_properties_is_fips_enabled(NULL) ? Qtrue : Qfalse;
+ return enabled;
+#elif defined(OPENSSL_FIPS) || defined(OPENSSL_IS_AWSLC)
VALUE enabled;
enabled = FIPS_mode() ? Qtrue : Qfalse;
return enabled;
@@ -429,10 +472,10 @@ ossl_fips_mode_get(VALUE self)
/*
* call-seq:
- * OpenSSL.fips_mode = boolean -> boolean
+ * OpenSSL.fips_mode = boolean
*
* Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an
- * effect for FIPS-capable installations of the OpenSSL library. Trying to do
+ * effect for FIPS-capable installations of the \OpenSSL library. Trying to do
* so otherwise will result in an error.
*
* === Examples
@@ -442,215 +485,73 @@ ossl_fips_mode_get(VALUE self)
static VALUE
ossl_fips_mode_set(VALUE self, VALUE enabled)
{
-
-#ifdef OPENSSL_FIPS
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ if (RTEST(enabled)) {
+ if (!EVP_default_properties_enable_fips(NULL, 1)) {
+ ossl_raise(eOSSLError, "Turning on FIPS mode failed");
+ }
+ } else {
+ if (!EVP_default_properties_enable_fips(NULL, 0)) {
+ ossl_raise(eOSSLError, "Turning off FIPS mode failed");
+ }
+ }
+ return enabled;
+#elif defined(OPENSSL_FIPS) || defined(OPENSSL_IS_AWSLC)
if (RTEST(enabled)) {
- int mode = FIPS_mode();
- if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
- ossl_raise(eOSSLError, "Turning on FIPS mode failed");
+ int mode = FIPS_mode();
+ if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
+ ossl_raise(eOSSLError, "Turning on FIPS mode failed");
} else {
- if(!FIPS_mode_set(0)) /* turning off twice is OK */
- ossl_raise(eOSSLError, "Turning off FIPS mode failed");
+ if(!FIPS_mode_set(0)) /* turning off twice is OK */
+ ossl_raise(eOSSLError, "Turning off FIPS mode failed");
}
return enabled;
#else
if (RTEST(enabled))
- ossl_raise(eOSSLError, "This version of OpenSSL does not support FIPS mode");
+ ossl_raise(eOSSLError, "This version of OpenSSL does not support FIPS mode");
return enabled;
#endif
}
-#if defined(OSSL_DEBUG)
-#if !defined(LIBRESSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(OPENSSL_NO_CRYPTO_MDEBUG) || \
- defined(CRYPTO_malloc_debug_init))
-/*
- * call-seq:
- * OpenSSL.mem_check_start -> nil
- *
- * Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory
- * allocations. See also OpenSSL.print_mem_leaks.
- *
- * This is available only when built with a capable OpenSSL and --enable-debug
- * configure option.
- */
-static VALUE
-mem_check_start(VALUE self)
-{
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- return Qnil;
-}
-
/*
* call-seq:
- * OpenSSL.print_mem_leaks -> true | false
- *
- * For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr).
- * Prints detected memory leaks to standard error. This cleans the global state
- * up thus you cannot use any methods of the library after calling this.
- *
- * Returns +true+ if leaks detected, +false+ otherwise.
- *
- * This is available only when built with a capable OpenSSL and --enable-debug
- * configure option.
- *
- * === Example
- * OpenSSL.mem_check_start
- * NOT_GCED = OpenSSL::PKey::RSA.new(256)
- *
- * END {
- * GC.start
- * OpenSSL.print_mem_leaks # will print the leakage
- * }
- */
-static VALUE
-print_mem_leaks(VALUE self)
-{
-#if OPENSSL_VERSION_NUMBER >= 0x10100000
- int ret;
-#endif
-
-#ifndef HAVE_RB_EXT_RACTOR_SAFE
- // for Ruby 2.x
- void ossl_bn_ctx_free(void); // ossl_bn.c
- ossl_bn_ctx_free();
-#endif
-
-#if OPENSSL_VERSION_NUMBER >= 0x10100000
- ret = CRYPTO_mem_leaks_fp(stderr);
- if (ret < 0)
- ossl_raise(eOSSLError, "CRYPTO_mem_leaks_fp");
- return ret ? Qfalse : Qtrue;
-#else
- CRYPTO_mem_leaks_fp(stderr);
- return Qnil;
-#endif
-}
-#endif
-#endif
-
-#if !defined(HAVE_OPENSSL_110_THREADING_API)
-/**
- * Stores locks needed for OpenSSL thread safety
- */
-struct CRYPTO_dynlock_value {
- rb_nativethread_lock_t lock;
- rb_nativethread_id_t owner;
- size_t count;
-};
-
-static void
-ossl_lock_init(struct CRYPTO_dynlock_value *l)
-{
- rb_nativethread_lock_initialize(&l->lock);
- l->count = 0;
-}
-
-static void
-ossl_lock_unlock(int mode, struct CRYPTO_dynlock_value *l)
-{
- if (mode & CRYPTO_LOCK) {
- /* TODO: rb_nativethread_id_t is not necessarily compared with ==. */
- rb_nativethread_id_t tid = rb_nativethread_self();
- if (l->count && l->owner == tid) {
- l->count++;
- return;
- }
- rb_nativethread_lock_lock(&l->lock);
- l->owner = tid;
- l->count = 1;
- } else {
- if (!--l->count)
- rb_nativethread_lock_unlock(&l->lock);
- }
-}
-
-static struct CRYPTO_dynlock_value *
-ossl_dyn_create_callback(const char *file, int line)
-{
- /* Do not use xmalloc() here, since it may raise NoMemoryError */
- struct CRYPTO_dynlock_value *dynlock =
- OPENSSL_malloc(sizeof(struct CRYPTO_dynlock_value));
- if (dynlock)
- ossl_lock_init(dynlock);
- return dynlock;
-}
-
-static void
-ossl_dyn_lock_callback(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
-{
- ossl_lock_unlock(mode, l);
-}
-
-static void
-ossl_dyn_destroy_callback(struct CRYPTO_dynlock_value *l, const char *file, int line)
-{
- rb_nativethread_lock_destroy(&l->lock);
- OPENSSL_free(l);
-}
-
-static void ossl_threadid_func(CRYPTO_THREADID *id)
-{
- /* register native thread id */
- CRYPTO_THREADID_set_pointer(id, (void *)rb_nativethread_self());
-}
-
-static struct CRYPTO_dynlock_value *ossl_locks;
-
-static void
-ossl_lock_callback(int mode, int type, const char *file, int line)
-{
- ossl_lock_unlock(mode, &ossl_locks[type]);
-}
-
-static void Init_ossl_locks(void)
-{
- int i;
- int num_locks = CRYPTO_num_locks();
-
- ossl_locks = ALLOC_N(struct CRYPTO_dynlock_value, num_locks);
- for (i = 0; i < num_locks; i++)
- ossl_lock_init(&ossl_locks[i]);
-
- CRYPTO_THREADID_set_callback(ossl_threadid_func);
- CRYPTO_set_locking_callback(ossl_lock_callback);
- CRYPTO_set_dynlock_create_callback(ossl_dyn_create_callback);
- CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback);
- CRYPTO_set_dynlock_destroy_callback(ossl_dyn_destroy_callback);
-}
-#endif /* !HAVE_OPENSSL_110_THREADING_API */
-
-/*
- * call-seq:
- * OpenSSL.fixed_length_secure_compare(string, string) -> boolean
+ * OpenSSL.fixed_length_secure_compare(string, string) -> true or false
*
* Constant time memory comparison for fixed length strings, such as results
- * of HMAC calculations.
+ * of \HMAC calculations.
*
* Returns +true+ if the strings are identical, +false+ if they are of the same
- * length but not identical. If the length is different, +ArgumentError+ is
+ * length but not identical. If the length is different, ArgumentError is
* raised.
*/
static VALUE
ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
{
- const unsigned char *p1 = (const unsigned char *)StringValuePtr(str1);
- const unsigned char *p2 = (const unsigned char *)StringValuePtr(str2);
- long len1 = RSTRING_LEN(str1);
- long len2 = RSTRING_LEN(str2);
+ const unsigned char *p1;
+ const unsigned char *p2;
+ long len1;
+ long len2;
+
+ StringValue(str1);
+ StringValue(str2);
+
+ p1 = (const unsigned char *)RSTRING_PTR(str1);
+ p2 = (const unsigned char *)RSTRING_PTR(str2);
+ len1 = RSTRING_LEN(str1);
+ len2 = RSTRING_LEN(str2);
if (len1 != len2) {
ossl_raise(rb_eArgError, "inputs must be of equal length");
}
switch (CRYPTO_memcmp(p1, p2, len1)) {
- case 0: return Qtrue;
- default: return Qfalse;
+ case 0: return Qtrue;
+ default: return Qfalse;
}
}
/*
- * OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the
+ * OpenSSL provides \SSL, TLS and general purpose cryptography. It wraps the
* OpenSSL[https://www.openssl.org/] library.
*
* = Examples
@@ -671,23 +572,21 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* key = OpenSSL::PKey::RSA.new 2048
*
- * open 'private_key.pem', 'w' do |io| io.write key.to_pem end
- * open 'public_key.pem', 'w' do |io| io.write key.public_key.to_pem end
+ * File.write 'private_key.pem', key.private_to_pem
+ * File.write 'public_key.pem', key.public_to_pem
*
* === Exporting a Key
*
* Keys saved to disk without encryption are not secure as anyone who gets
* ahold of the key may use it unless it is encrypted. In order to securely
- * export a key you may export it with a pass phrase.
+ * export a key you may export it with a password.
*
* cipher = OpenSSL::Cipher.new 'aes-256-cbc'
- * pass_phrase = 'my secure pass phrase goes here'
+ * password = 'my secure password goes here'
*
- * key_secure = key.export cipher, pass_phrase
+ * key_secure = key.private_to_pem cipher, password
*
- * open 'private.secure.pem', 'w' do |io|
- * io.write key_secure
- * end
+ * File.write 'private.secure.pem', key_secure
*
* OpenSSL::Cipher.ciphers returns a list of available ciphers.
*
@@ -707,13 +606,13 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* === Loading an Encrypted Key
*
- * OpenSSL will prompt you for your pass phrase when loading an encrypted key.
- * If you will not be able to type in the pass phrase you may provide it when
+ * \OpenSSL will prompt you for your password when loading an encrypted key.
+ * If you will not be able to type in the password you may provide it when
* loading the key:
*
* key4_pem = File.read 'private.secure.pem'
- * pass_phrase = 'my secure pass phrase goes here'
- * key4 = OpenSSL::PKey.read key4_pem, pass_phrase
+ * password = 'my secure password goes here'
+ * key4 = OpenSSL::PKey.read key4_pem, password
*
* == RSA Encryption
*
@@ -770,7 +669,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* == PBKDF2 Password-based Encryption
*
- * If supported by the underlying OpenSSL version used, Password-based
+ * If supported by the underlying \OpenSSL version used, Password-based
* Encryption should use the features of PKCS5. If not supported or if
* required by legacy applications, the older, less secure methods specified
* in RFC 2898 are also supported (see below).
@@ -829,46 +728,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* decrypted = cipher.update encrypted
* decrypted << cipher.final
*
- * == PKCS #5 Password-based Encryption
- *
- * PKCS #5 is a password-based encryption standard documented at
- * RFC2898[http://www.ietf.org/rfc/rfc2898.txt]. It allows a short password or
- * passphrase to be used to create a secure encryption key. If possible, PBKDF2
- * as described above should be used if the circumstances allow it.
- *
- * PKCS #5 uses a Cipher, a pass phrase and a salt to generate an encryption
- * key.
- *
- * pass_phrase = 'my secure pass phrase goes here'
- * salt = '8 octets'
- *
- * === Encryption
- *
- * First set up the cipher for encryption
- *
- * encryptor = OpenSSL::Cipher.new 'aes-256-cbc'
- * encryptor.encrypt
- * encryptor.pkcs5_keyivgen pass_phrase, salt
- *
- * Then pass the data you want to encrypt through
- *
- * encrypted = encryptor.update 'top secret document'
- * encrypted << encryptor.final
- *
- * === Decryption
- *
- * Use a new Cipher instance set up for decryption
- *
- * decryptor = OpenSSL::Cipher.new 'aes-256-cbc'
- * decryptor.decrypt
- * decryptor.pkcs5_keyivgen pass_phrase, salt
- *
- * Then pass the data you want to decrypt through
- *
- * plain = decryptor.update encrypted
- * plain << decryptor.final
- *
- * == X509 Certificates
+ * == \X509 Certificates
*
* === Creating a Certificate
*
@@ -905,7 +765,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* extension_factory.create_extension('subjectKeyIdentifier', 'hash')
*
* The list of supported extensions (and in some cases their possible values)
- * can be derived from the "objects.h" file in the OpenSSL source code.
+ * can be derived from the "objects.h" file in the \OpenSSL source code.
*
* === Signing a Certificate
*
@@ -945,12 +805,12 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* not readable by other users.
*
* ca_key = OpenSSL::PKey::RSA.new 2048
- * pass_phrase = 'my secure pass phrase goes here'
+ * password = 'my secure password goes here'
*
- * cipher = OpenSSL::Cipher.new 'aes-256-cbc'
+ * cipher = 'aes-256-cbc'
*
* open 'ca_key.pem', 'w', 0400 do |io|
- * io.write ca_key.export(cipher, pass_phrase)
+ * io.write ca_key.private_to_pem(cipher, password)
* end
*
* === CA Certificate
@@ -1059,23 +919,23 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* io.write csr_cert.to_pem
* end
*
- * == SSL and TLS Connections
+ * == \SSL and TLS Connections
*
- * Using our created key and certificate we can create an SSL or TLS connection.
- * An SSLContext is used to set up an SSL session.
+ * Using our created key and certificate we can create an \SSL or TLS
+ * connection. An OpenSSL::SSL::SSLContext is used to set up an \SSL session.
*
* context = OpenSSL::SSL::SSLContext.new
*
- * === SSL Server
+ * === \SSL Server
*
- * An SSL server requires the certificate and private key to communicate
+ * An \SSL server requires the certificate and private key to communicate
* securely with its clients:
*
* context.cert = cert
* context.key = key
*
- * Then create an SSLServer with a TCP server socket and the context. Use the
- * SSLServer like an ordinary TCP server.
+ * Then create an OpenSSL::SSL::SSLServer with a TCP server socket and the
+ * context. Use the SSLServer like an ordinary TCP server.
*
* require 'socket'
*
@@ -1094,14 +954,15 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* ssl_connection.close
* end
*
- * === SSL client
+ * === \SSL client
*
- * An SSL client is created with a TCP socket and the context.
- * SSLSocket#connect must be called to initiate the SSL handshake and start
- * encryption. A key and certificate are not required for the client socket.
+ * An \SSL client is created with a TCP socket and the context.
+ * OpenSSL::SSL::SSLSocket#connect must be called to initiate the \SSL handshake
+ * and start encryption. A key and certificate are not required for the client
+ * socket.
*
- * Note that SSLSocket#close doesn't close the underlying socket by default. Set
- * SSLSocket#sync_close to true if you want.
+ * Note that OpenSSL::SSL::SSLSocket#close doesn't close the underlying socket
+ * by default. Set OpenSSL::SSL::SSLSocket#sync_close to true if you want.
*
* require 'socket'
*
@@ -1117,7 +978,7 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* === Peer Verification
*
- * An unverified SSL connection does not provide much security. For enhanced
+ * An unverified \SSL connection does not provide much security. For enhanced
* security the client or server can verify the certificate of its peer.
*
* The client can be modified to verify the server's certificate against the
@@ -1157,63 +1018,109 @@ Init_openssl(void)
/*
* Init all digests, ciphers
*/
-#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
if (!OPENSSL_init_ssl(0, NULL))
rb_raise(rb_eRuntimeError, "OPENSSL_init_ssl");
-#else
- OpenSSL_add_ssl_algorithms();
- OpenSSL_add_all_algorithms();
- ERR_load_crypto_strings();
- SSL_load_error_strings();
-#endif
/*
* Init main module
*/
- mOSSL = rb_define_module("OpenSSL");
rb_global_variable(&mOSSL);
+ mOSSL = rb_define_module("OpenSSL");
rb_define_singleton_method(mOSSL, "fixed_length_secure_compare", ossl_crypto_fixed_length_secure_compare, 2);
/*
- * Version of OpenSSL the ruby OpenSSL extension was built with
+ * \OpenSSL library version string used to compile the Ruby/OpenSSL
+ * extension. This may differ from the version used at runtime.
*/
- rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
+ rb_define_const(mOSSL, "OPENSSL_VERSION",
+ rb_obj_freeze(rb_str_new_cstr(OPENSSL_VERSION_TEXT)));
/*
- * Version of OpenSSL the ruby OpenSSL extension is running with
+ * \OpenSSL library version string currently used at runtime.
*/
-#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
- rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
-#else
- rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
-#endif
+ rb_define_const(
+ mOSSL,
+ "OPENSSL_LIBRARY_VERSION",
+ rb_obj_freeze(rb_str_new_cstr(OpenSSL_version(OPENSSL_VERSION)))
+ );
/*
- * Version number of OpenSSL the ruby OpenSSL extension was built with
- * (base 16)
+ * \OpenSSL library version number used to compile the Ruby/OpenSSL
+ * extension. This may differ from the version used at runtime.
+ *
+ * The version number is encoded into a single integer value. The number
+ * follows the format:
+ *
+ * [\OpenSSL 3.0.0 or later]
+ * <tt>0xMNN00PP0</tt> (major minor 00 patch 0)
+ * [\OpenSSL 1.1.1 or earlier]
+ * <tt>0xMNNFFPPS</tt> (major minor fix patch status)
+ * [LibreSSL]
+ * <tt>0x20000000</tt> (a fixed value)
+ *
+ * See also the man page OPENSSL_VERSION_NUMBER(3).
*/
rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER));
+#if defined(LIBRESSL_VERSION_NUMBER)
/*
- * Boolean indicating whether OpenSSL is FIPS-capable or not
+ * LibreSSL library version number used to compile the Ruby/OpenSSL
+ * extension. This may differ from the version used at runtime.
+ *
+ * This constant is only defined if the extension was compiled against
+ * LibreSSL. The number follows the format:
+ * <tt>0xMNNFF00f</tt> (major minor fix 00 status).
+ *
+ * See also the man page LIBRESSL_VERSION_NUMBER(3).
+ */
+ rb_define_const(mOSSL, "LIBRESSL_VERSION_NUMBER", INT2NUM(LIBRESSL_VERSION_NUMBER));
+#endif
+
+ /*
+ * Boolean indicating whether the \OpenSSL library is FIPS-capable or not.
+ * Always <tt>true</tt> for \OpenSSL 3.0 and later.
+ *
+ * This is obsolete and will be removed in the future.
+ * See also OpenSSL.fips_mode.
*/
rb_define_const(mOSSL, "OPENSSL_FIPS",
-#ifdef OPENSSL_FIPS
- Qtrue
+/* OpenSSL 3 is FIPS-capable even when it is installed without fips option */
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ Qtrue
+#elif defined(OPENSSL_FIPS)
+ Qtrue
+#elif defined(OPENSSL_IS_AWSLC) // AWS-LC FIPS can only be enabled during compile time.
+ FIPS_mode() ? Qtrue : Qfalse
#else
- Qfalse
+ Qfalse
#endif
- );
+ );
rb_define_module_function(mOSSL, "fips_mode", ossl_fips_mode_get, 0);
rb_define_module_function(mOSSL, "fips_mode=", ossl_fips_mode_set, 1);
+ rb_global_variable(&eOSSLError);
/*
- * Generic error,
- * common for all classes under OpenSSL module
+ * Generic error class for OpenSSL. All error classes in this library
+ * inherit from this class.
+ *
+ * This class indicates that an error was reported by the underlying
+ * \OpenSSL library.
*/
- eOSSLError = rb_define_class_under(mOSSL,"OpenSSLError",rb_eStandardError);
- rb_global_variable(&eOSSLError);
+ eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
+ /*
+ * \OpenSSL error queue entries captured at the time the exception was
+ * raised. The same information is printed to stderr if OpenSSL.debug is
+ * set to +true+.
+ *
+ * This is an array of zero or more strings, ordered from the oldest to the
+ * newest. The format of the strings is not stable and may vary across
+ * versions of \OpenSSL or versions of this Ruby extension.
+ *
+ * See also the man page ERR_get_error(3).
+ */
+ rb_attr(eOSSLError, rb_intern_const("errors"), 1, 0, 0);
+ rb_define_method(eOSSLError, "detailed_message", osslerror_detailed_message, -1);
/*
* Init debug core
@@ -1229,67 +1136,27 @@ Init_openssl(void)
* Get ID of to_der
*/
ossl_s_to_der = rb_intern("to_der");
-
-#if !defined(HAVE_OPENSSL_110_THREADING_API)
- Init_ossl_locks();
-#endif
+ id_i_errors = rb_intern("@errors");
/*
* Init components
*/
+ Init_ossl_asn1();
Init_ossl_bn();
Init_ossl_cipher();
Init_ossl_config();
Init_ossl_digest();
+ Init_ossl_engine();
Init_ossl_hmac();
+ Init_ossl_kdf();
Init_ossl_ns_spki();
+ Init_ossl_ocsp();
Init_ossl_pkcs12();
Init_ossl_pkcs7();
Init_ossl_pkey();
+ Init_ossl_provider();
Init_ossl_rand();
Init_ossl_ssl();
-#ifndef OPENSSL_NO_TS
Init_ossl_ts();
-#endif
Init_ossl_x509();
- Init_ossl_ocsp();
- Init_ossl_engine();
- Init_ossl_asn1();
- Init_ossl_kdf();
-
-#if defined(OSSL_DEBUG)
- /*
- * For debugging Ruby/OpenSSL. Enable only when built with --enable-debug
- */
-#if !defined(LIBRESSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(OPENSSL_NO_CRYPTO_MDEBUG) || \
- defined(CRYPTO_malloc_debug_init))
- rb_define_module_function(mOSSL, "mem_check_start", mem_check_start, 0);
- rb_define_module_function(mOSSL, "print_mem_leaks", print_mem_leaks, 0);
-
-#if defined(CRYPTO_malloc_debug_init) /* <= 1.0.2 */
- CRYPTO_malloc_debug_init();
-#endif
-
-#if defined(V_CRYPTO_MDEBUG_ALL) /* <= 1.0.2 */
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
-#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x10100000 /* <= 1.0.2 */
- {
- int i;
- /*
- * See crypto/ex_data.c; call def_get_class() immediately to avoid
- * allocations. 15 is the maximum number that is used as the class index
- * in OpenSSL 1.0.2.
- */
- for (i = 0; i <= 15; i++) {
- if (CRYPTO_get_ex_new_index(i, 0, (void *)"ossl-mdebug-dummy", 0, 0, 0) < 0)
- rb_raise(rb_eRuntimeError, "CRYPTO_get_ex_new_index for "
- "class index %d failed", i);
- }
- }
-#endif
-#endif
-#endif
}
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index facb80aa73..0b479a7200 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_H_)
#define _OSSL_H_
@@ -17,6 +17,12 @@
#include <errno.h>
#include <ruby/io.h>
#include <ruby/thread.h>
+#ifdef HAVE_RUBY_RACTOR_H
+#include <ruby/ractor.h>
+#else
+#define RUBY_TYPED_FROZEN_SHAREABLE 0
+#endif
+
#include <openssl/opensslv.h>
#include <openssl/err.h>
@@ -39,6 +45,7 @@
#include <openssl/dsa.h>
#include <openssl/evp.h>
#include <openssl/dh.h>
+#include "openssl_missing.h"
#ifndef LIBRESSL_VERSION_NUMBER
# define OSSL_IS_LIBRESSL 0
@@ -62,6 +69,15 @@
# define OSSL_USE_ENGINE
#endif
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+# define OSSL_USE_PROVIDER
+# include <openssl/provider.h>
+#endif
+
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+# define OSSL_HAVE_IMMUTABLE_PKEY
+#endif
+
/*
* Common Module
*/
@@ -76,10 +92,10 @@ extern VALUE eOSSLError;
* CheckTypes
*/
#define OSSL_Check_Kind(obj, klass) do {\
- if (!rb_obj_is_kind_of((obj), (klass))) {\
- ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
- rb_obj_class(obj), (klass));\
- }\
+ if (!rb_obj_is_kind_of((obj), (klass))) {\
+ ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
+ rb_obj_class(obj), (klass));\
+ }\
} while (0)
/*
@@ -115,7 +131,7 @@ do{\
* Convert binary string to hex string. The caller is responsible for
* ensuring out has (2 * len) bytes of capacity.
*/
-void ossl_bin2hex(unsigned char *in, char *out, size_t len);
+void ossl_bin2hex(const unsigned char *in, char *out, size_t len);
/*
* Our default PEM callback
@@ -157,44 +173,36 @@ VALUE ossl_to_der_if_possible(VALUE);
*/
extern VALUE dOSSL;
-#if defined(HAVE_VA_ARGS_MACRO)
#define OSSL_Debug(...) do { \
- if (dOSSL == Qtrue) { \
- fprintf(stderr, "OSSL_DEBUG: "); \
- fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
- } \
+ if (dOSSL == Qtrue) { \
+ fprintf(stderr, "OSSL_DEBUG: "); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
+ } \
} while (0)
-#else
-void ossl_debug(const char *, ...);
-#define OSSL_Debug ossl_debug
-#endif
-
/*
* Include all parts
*/
-#include "openssl_missing.h"
#include "ossl_asn1.h"
#include "ossl_bio.h"
#include "ossl_bn.h"
#include "ossl_cipher.h"
#include "ossl_config.h"
#include "ossl_digest.h"
+#include "ossl_engine.h"
#include "ossl_hmac.h"
+#include "ossl_kdf.h"
#include "ossl_ns_spki.h"
#include "ossl_ocsp.h"
#include "ossl_pkcs12.h"
#include "ossl_pkcs7.h"
#include "ossl_pkey.h"
+#include "ossl_provider.h"
#include "ossl_rand.h"
#include "ossl_ssl.h"
-#ifndef OPENSSL_NO_TS
- #include "ossl_ts.h"
-#endif
+#include "ossl_ts.h"
#include "ossl_x509.h"
-#include "ossl_engine.h"
-#include "ossl_kdf.h"
void Init_openssl(void);
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 71c452c88a..517212b4d5 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -5,68 +5,85 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
-static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset,
- int depth, int yield, long *num_read);
-static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self);
+/********/
+/*
+ * ASN1 module
+ */
+#define ossl_asn1_get_value(o) rb_attr_get((o),sivVALUE)
+#define ossl_asn1_get_tag(o) rb_attr_get((o),sivTAG)
+#define ossl_asn1_get_tagging(o) rb_attr_get((o),sivTAGGING)
+#define ossl_asn1_get_tag_class(o) rb_attr_get((o),sivTAG_CLASS)
+#define ossl_asn1_get_indefinite_length(o) rb_attr_get((o),sivINDEFINITE_LENGTH)
+
+#define ossl_asn1_set_value(o,v) rb_ivar_set((o),sivVALUE,(v))
+#define ossl_asn1_set_tag(o,v) rb_ivar_set((o),sivTAG,(v))
+#define ossl_asn1_set_tagging(o,v) rb_ivar_set((o),sivTAGGING,(v))
+#define ossl_asn1_set_tag_class(o,v) rb_ivar_set((o),sivTAG_CLASS,(v))
+#define ossl_asn1_set_indefinite_length(o,v) rb_ivar_set((o),sivINDEFINITE_LENGTH,(v))
+
+VALUE mASN1;
+static VALUE eASN1Error;
+
+VALUE cASN1Data;
+static VALUE cASN1Primitive;
+static VALUE cASN1Constructive;
+
+static VALUE cASN1EndOfContent;
+static VALUE cASN1Boolean; /* BOOLEAN */
+static VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
+static VALUE cASN1BitString; /* BIT STRING */
+static VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
+static VALUE cASN1NumericString, cASN1PrintableString;
+static VALUE cASN1T61String, cASN1VideotexString;
+static VALUE cASN1IA5String, cASN1GraphicString;
+static VALUE cASN1ISO64String, cASN1GeneralString;
+static VALUE cASN1UniversalString, cASN1BMPString;
+static VALUE cASN1Null; /* NULL */
+static VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
+static VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
+static VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+
+static VALUE sym_IMPLICIT, sym_EXPLICIT;
+static VALUE sym_UNIVERSAL, sym_APPLICATION, sym_CONTEXT_SPECIFIC, sym_PRIVATE;
+static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINDEFINITE_LENGTH, sivUNUSED_BITS;
+static ID id_each;
/*
* DATE conversion
*/
+static VALUE
+time_utc_new(VALUE args)
+{
+ return rb_funcallv(rb_cTime, rb_intern("utc"), 6, (VALUE *)args);
+}
+
+static VALUE
+time_utc_new_rescue(VALUE args, VALUE exc)
+{
+ rb_raise(eASN1Error, "invalid time");
+}
+
VALUE
asn1time_to_time(const ASN1_TIME *time)
{
struct tm tm;
- VALUE argv[6];
- int count;
-
- memset(&tm, 0, sizeof(struct tm));
-
- switch (time->type) {
- case V_ASN1_UTCTIME:
- count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
- &tm.tm_sec);
-
- if (count == 5) {
- tm.tm_sec = 0;
- } else if (count != 6) {
- ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
- time->data);
- }
- if (tm.tm_year < 69) {
- tm.tm_year += 2000;
- } else {
- tm.tm_year += 1900;
- }
- break;
- case V_ASN1_GENERALIZEDTIME:
- count = sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
- &tm.tm_sec);
- if (count == 5) {
- tm.tm_sec = 0;
- }
- else if (count != 6) {
- ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format: \"%s\"",
- time->data);
- }
- break;
- default:
- rb_warning("unknown time format");
- return Qnil;
- }
- argv[0] = INT2NUM(tm.tm_year);
- argv[1] = INT2NUM(tm.tm_mon);
- argv[2] = INT2NUM(tm.tm_mday);
- argv[3] = INT2NUM(tm.tm_hour);
- argv[4] = INT2NUM(tm.tm_min);
- argv[5] = INT2NUM(tm.tm_sec);
-
- return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
+ if (!ASN1_TIME_to_tm(time, &tm))
+ ossl_raise(eASN1Error, "ASN1_TIME_to_tm");
+
+ VALUE args[] = {
+ INT2NUM(tm.tm_year + 1900),
+ INT2NUM(tm.tm_mon + 1),
+ INT2NUM(tm.tm_mday),
+ INT2NUM(tm.tm_hour),
+ INT2NUM(tm.tm_min),
+ INT2NUM(tm.tm_sec),
+ };
+ return rb_rescue2(time_utc_new, (VALUE)args, time_utc_new_rescue, Qnil,
+ rb_eArgError, 0);
}
static VALUE
@@ -81,13 +98,13 @@ ossl_time_split(VALUE time, time_t *sec, int *days)
VALUE num = rb_Integer(time);
if (FIXNUM_P(num)) {
- time_t t = FIX2LONG(num);
- *sec = t % 86400;
- *days = rb_long2int(t / 86400);
+ time_t t = FIX2LONG(num);
+ *sec = t % 86400;
+ *days = rb_long2int(t / 86400);
}
else {
- *days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400)));
- *sec = NUM2TIMET(rb_funcall(num, rb_intern("%"), 1, INT2FIX(86400)));
+ *days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400)));
+ *sec = NUM2TIMET(rb_funcall(num, rb_intern("%"), 1, INT2FIX(86400)));
}
}
@@ -97,7 +114,8 @@ ossl_time_split(VALUE time, time_t *sec, int *days)
VALUE
asn1str_to_str(const ASN1_STRING *str)
{
- return rb_str_new((const char *)str->data, str->length);
+ return rb_str_new((const char *)ASN1_STRING_get0_data(str),
+ ASN1_STRING_length(str));
}
/*
@@ -110,18 +128,19 @@ asn1integer_to_num(const ASN1_INTEGER *ai)
VALUE num;
if (!ai) {
- ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
+ ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
}
- if (ai->type == V_ASN1_ENUMERATED)
- /* const_cast: workaround for old OpenSSL */
- bn = ASN1_ENUMERATED_to_BN((ASN1_ENUMERATED *)ai, NULL);
+
+ num = ossl_bn_new(BN_value_one());
+ bn = GetBNPtr(num);
+
+ if (ASN1_STRING_type(ai) == V_ASN1_ENUMERATED)
+ bn = ASN1_ENUMERATED_to_BN(ai, bn);
else
- bn = ASN1_INTEGER_to_BN(ai, NULL);
+ bn = ASN1_INTEGER_to_BN(ai, bn);
if (!bn)
- ossl_raise(eOSSLError, NULL);
- num = ossl_bn_new(bn);
- BN_free(bn);
+ ossl_raise(eOSSLError, NULL);
return num;
}
@@ -132,12 +151,12 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
BIGNUM *bn;
if (NIL_P(obj))
- ossl_raise(rb_eTypeError, "Can't convert nil into Integer");
+ ossl_raise(rb_eTypeError, "Can't convert nil into Integer");
bn = GetBNPtr(obj);
if (!(ai = BN_to_ASN1_INTEGER(bn, ai)))
- ossl_raise(eOSSLError, NULL);
+ ossl_raise(eOSSLError, NULL);
return ai;
}
@@ -148,48 +167,47 @@ asn1integer_to_num_i(VALUE arg)
return asn1integer_to_num((ASN1_INTEGER *)arg);
}
-/********/
/*
- * ASN1 module
+ * ASN1_OBJECT conversions
*/
-#define ossl_asn1_get_value(o) rb_attr_get((o),sivVALUE)
-#define ossl_asn1_get_tag(o) rb_attr_get((o),sivTAG)
-#define ossl_asn1_get_tagging(o) rb_attr_get((o),sivTAGGING)
-#define ossl_asn1_get_tag_class(o) rb_attr_get((o),sivTAG_CLASS)
-#define ossl_asn1_get_indefinite_length(o) rb_attr_get((o),sivINDEFINITE_LENGTH)
-
-#define ossl_asn1_set_value(o,v) rb_ivar_set((o),sivVALUE,(v))
-#define ossl_asn1_set_tag(o,v) rb_ivar_set((o),sivTAG,(v))
-#define ossl_asn1_set_tagging(o,v) rb_ivar_set((o),sivTAGGING,(v))
-#define ossl_asn1_set_tag_class(o,v) rb_ivar_set((o),sivTAG_CLASS,(v))
-#define ossl_asn1_set_indefinite_length(o,v) rb_ivar_set((o),sivINDEFINITE_LENGTH,(v))
+VALUE
+ossl_asn1obj_to_string_oid(const ASN1_OBJECT *a1obj)
+{
+ VALUE str;
+ int len;
-VALUE mASN1;
-VALUE eASN1Error;
+ str = rb_usascii_str_new(NULL, 127);
+ len = OBJ_obj2txt(RSTRING_PTR(str), RSTRING_LENINT(str), a1obj, 1);
+ if (len <= 0 || len == INT_MAX)
+ ossl_raise(eOSSLError, "OBJ_obj2txt");
+ if (len > RSTRING_LEN(str)) {
+ /* +1 is for the \0 terminator added by OBJ_obj2txt() */
+ rb_str_resize(str, len + 1);
+ len = OBJ_obj2txt(RSTRING_PTR(str), len + 1, a1obj, 1);
+ if (len <= 0)
+ ossl_raise(eOSSLError, "OBJ_obj2txt");
+ }
+ rb_str_set_len(str, len);
+ return str;
+}
-VALUE cASN1Data;
-VALUE cASN1Primitive;
-VALUE cASN1Constructive;
-
-VALUE cASN1EndOfContent;
-VALUE cASN1Boolean; /* BOOLEAN */
-VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
-VALUE cASN1BitString; /* BIT STRING */
-VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
-VALUE cASN1NumericString, cASN1PrintableString;
-VALUE cASN1T61String, cASN1VideotexString;
-VALUE cASN1IA5String, cASN1GraphicString;
-VALUE cASN1ISO64String, cASN1GeneralString;
-VALUE cASN1UniversalString, cASN1BMPString;
-VALUE cASN1Null; /* NULL */
-VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
-VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
-VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+VALUE
+ossl_asn1obj_to_string(const ASN1_OBJECT *obj)
+{
+ int nid = OBJ_obj2nid(obj);
+ if (nid != NID_undef)
+ return rb_str_new_cstr(OBJ_nid2sn(nid));
+ return ossl_asn1obj_to_string_oid(obj);
+}
-static VALUE sym_IMPLICIT, sym_EXPLICIT;
-static VALUE sym_UNIVERSAL, sym_APPLICATION, sym_CONTEXT_SPECIFIC, sym_PRIVATE;
-static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINDEFINITE_LENGTH, sivUNUSED_BITS;
-static ID id_each;
+VALUE
+ossl_asn1obj_to_string_long_name(const ASN1_OBJECT *obj)
+{
+ int nid = OBJ_obj2nid(obj);
+ if (nid != NID_undef)
+ return rb_str_new_cstr(OBJ_nid2ln(nid));
+ return ossl_asn1obj_to_string_oid(obj);
+}
/*
* Ruby to ASN1 converters
@@ -198,9 +216,9 @@ static ASN1_BOOLEAN
obj_to_asn1bool(VALUE obj)
{
if (NIL_P(obj))
- ossl_raise(rb_eTypeError, "Can't convert nil into Boolean");
+ ossl_raise(rb_eTypeError, "Can't convert nil into Boolean");
- return RTEST(obj) ? 0xff : 0x0;
+ return RTEST(obj) ? 0xff : 0x0;
}
static ASN1_INTEGER*
@@ -210,19 +228,19 @@ obj_to_asn1int(VALUE obj)
}
static ASN1_BIT_STRING*
-obj_to_asn1bstr(VALUE obj, long unused_bits)
+obj_to_asn1bstr(VALUE obj, int unused_bits)
{
ASN1_BIT_STRING *bstr;
if (unused_bits < 0 || unused_bits > 7)
- ossl_raise(eASN1Error, "unused_bits for a bitstring value must be in "\
- "the range 0 to 7");
+ ossl_raise(eASN1Error, "unused_bits for a bitstring value must be in "\
+ "the range 0 to 7");
StringValue(obj);
- if(!(bstr = ASN1_BIT_STRING_new()))
- ossl_raise(eASN1Error, NULL);
- ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LENINT(obj));
- bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
- bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT | unused_bits;
+ if (!(bstr = ASN1_BIT_STRING_new()))
+ ossl_raise(eASN1Error, "ASN1_BIT_STRING_new");
+ if (!ASN1_BIT_STRING_set1(bstr, (uint8_t *)RSTRING_PTR(obj),
+ RSTRING_LEN(obj), unused_bits))
+ ossl_raise(eASN1Error, "ASN1_BIT_STRING_set1");
return bstr;
}
@@ -234,8 +252,11 @@ obj_to_asn1str(VALUE obj)
StringValue(obj);
if(!(str = ASN1_STRING_new()))
- ossl_raise(eASN1Error, NULL);
- ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));
+ ossl_raise(eASN1Error, NULL);
+ if(!ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj))) {
+ ASN1_STRING_free(str);
+ ossl_raise(eASN1Error, NULL);
+ }
return str;
}
@@ -246,15 +267,15 @@ obj_to_asn1null(VALUE obj)
ASN1_NULL *null;
if(!NIL_P(obj))
- ossl_raise(eASN1Error, "nil expected");
+ ossl_raise(eASN1Error, "nil expected");
if(!(null = ASN1_NULL_new()))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
return null;
}
-static ASN1_OBJECT*
-obj_to_asn1obj(VALUE obj)
+ASN1_OBJECT *
+ossl_to_asn1obj(VALUE obj)
{
ASN1_OBJECT *a1obj;
@@ -276,7 +297,7 @@ obj_to_asn1utime(VALUE time)
ossl_time_split(time, &sec, &off_days);
if (!(t = ASN1_UTCTIME_adj(NULL, sec, off_days, 0)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
return t;
}
@@ -291,7 +312,7 @@ obj_to_asn1gtime(VALUE time)
ossl_time_split(time, &sec, &off_days);
if (!(t = ASN1_GENERALIZEDTIME_adj(NULL, sec, off_days, 0)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
return t;
}
@@ -304,8 +325,11 @@ obj_to_asn1derstr(VALUE obj)
str = ossl_to_der(obj);
if(!(a1str = ASN1_STRING_new()))
- ossl_raise(eASN1Error, NULL);
- ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str));
+ ossl_raise(eASN1Error, NULL);
+ if(!ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str))) {
+ ASN1_STRING_free(a1str);
+ ossl_raise(eASN1Error, NULL);
+ }
return a1str;
}
@@ -319,9 +343,9 @@ decode_bool(unsigned char* der, long length)
const unsigned char *p = der;
if (length != 3)
- ossl_raise(eASN1Error, "invalid length for BOOLEAN");
+ ossl_raise(eASN1Error, "invalid length for BOOLEAN");
if (p[0] != 1 || p[1] != 1)
- ossl_raise(eASN1Error, "invalid BOOLEAN");
+ ossl_raise(eASN1Error, "invalid BOOLEAN");
return p[2] ? Qtrue : Qfalse;
}
@@ -336,9 +360,9 @@ decode_int(unsigned char* der, long length)
p = der;
if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
ret = rb_protect(asn1integer_to_num_i,
- (VALUE)ai, &status);
+ (VALUE)ai, &status);
ASN1_INTEGER_free(ai);
if(status) rb_jump_tag(status);
@@ -346,22 +370,25 @@ decode_int(unsigned char* der, long length)
}
static VALUE
-decode_bstr(unsigned char* der, long length, long *unused_bits)
+decode_bstr(unsigned char* der, long length, int *unused_bits)
{
ASN1_BIT_STRING *bstr;
const unsigned char *p;
- long len;
+ size_t len;
VALUE ret;
+ int state;
p = der;
- if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
- len = bstr->length;
- *unused_bits = 0;
- if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT)
- *unused_bits = bstr->flags & 0x07;
- ret = rb_str_new((const char *)bstr->data, len);
+ if (!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
+ ossl_raise(eASN1Error, "d2i_ASN1_BIT_STRING");
+ if (!ASN1_BIT_STRING_get_length(bstr, &len, unused_bits)) {
+ ASN1_BIT_STRING_free(bstr);
+ ossl_raise(eASN1Error, "ASN1_BIT_STRING_get_length");
+ }
+ ret = ossl_str_new((const char *)ASN1_STRING_get0_data(bstr), len, &state);
ASN1_BIT_STRING_free(bstr);
+ if (state)
+ rb_jump_tag(state);
return ret;
}
@@ -376,9 +403,9 @@ decode_enum(unsigned char* der, long length)
p = der;
if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
ret = rb_protect(asn1integer_to_num_i,
- (VALUE)ai, &status);
+ (VALUE)ai, &status);
ASN1_ENUMERATED_free(ai);
if(status) rb_jump_tag(status);
@@ -393,38 +420,33 @@ decode_null(unsigned char* der, long length)
p = der;
if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
ASN1_NULL_free(null);
return Qnil;
}
+VALUE
+asn1obj_to_string_i(VALUE arg)
+{
+ return ossl_asn1obj_to_string((const ASN1_OBJECT *)arg);
+}
+
static VALUE
decode_obj(unsigned char* der, long length)
{
ASN1_OBJECT *obj;
const unsigned char *p;
VALUE ret;
- int nid;
- BIO *bio;
+ int state;
p = der;
- if(!(obj = d2i_ASN1_OBJECT(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
- if((nid = OBJ_obj2nid(obj)) != NID_undef){
- ASN1_OBJECT_free(obj);
- ret = rb_str_new2(OBJ_nid2sn(nid));
- }
- else{
- if(!(bio = BIO_new(BIO_s_mem()))){
- ASN1_OBJECT_free(obj);
- ossl_raise(eASN1Error, NULL);
- }
- i2a_ASN1_OBJECT(bio, obj);
- ASN1_OBJECT_free(obj);
- ret = ossl_membio2str(bio);
- }
-
+ if (!(obj = d2i_ASN1_OBJECT(NULL, &p, length)))
+ ossl_raise(eASN1Error, "d2i_ASN1_OBJECT");
+ ret = rb_protect(asn1obj_to_string_i, (VALUE)obj, &state);
+ ASN1_OBJECT_free(obj);
+ if (state)
+ rb_jump_tag(state);
return ret;
}
@@ -438,9 +460,9 @@ decode_time(unsigned char* der, long length)
p = der;
if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
ret = rb_protect(asn1time_to_time_i,
- (VALUE)time, &status);
+ (VALUE)time, &status);
ASN1_TIME_free(time);
if(status) rb_jump_tag(status);
@@ -451,7 +473,7 @@ static VALUE
decode_eoc(unsigned char *der, long length)
{
if (length != 2 || !(der[0] == 0x00 && der[1] == 0x00))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
return rb_str_new("", 0);
}
@@ -503,7 +525,7 @@ static VALUE class_tag_map;
static int ossl_asn1_default_tag(VALUE obj);
-ASN1_TYPE*
+static ASN1_TYPE *
ossl_asn1_get_asn1type(VALUE obj)
{
ASN1_TYPE *ret;
@@ -516,62 +538,62 @@ ossl_asn1_get_asn1type(VALUE obj)
tag = ossl_asn1_default_tag(obj);
value = ossl_asn1_get_value(obj);
switch(tag){
- case V_ASN1_BOOLEAN:
- ptr = (void*)(VALUE)obj_to_asn1bool(value);
- free_func = NULL;
- break;
- case V_ASN1_INTEGER: /* FALLTHROUGH */
- case V_ASN1_ENUMERATED:
- ptr = obj_to_asn1int(value);
- free_func = (free_func_type *)ASN1_INTEGER_free;
- break;
- case V_ASN1_BIT_STRING:
+ case V_ASN1_BOOLEAN:
+ ptr = (void*)(VALUE)obj_to_asn1bool(value);
+ free_func = NULL;
+ break;
+ case V_ASN1_INTEGER: /* FALLTHROUGH */
+ case V_ASN1_ENUMERATED:
+ ptr = obj_to_asn1int(value);
+ free_func = (free_func_type *)ASN1_INTEGER_free;
+ break;
+ case V_ASN1_BIT_STRING:
rflag = rb_attr_get(obj, sivUNUSED_BITS);
- ptr = obj_to_asn1bstr(value, NUM2INT(rflag));
- free_func = (free_func_type *)ASN1_BIT_STRING_free;
- break;
- case V_ASN1_NULL:
- ptr = obj_to_asn1null(value);
- free_func = (free_func_type *)ASN1_NULL_free;
- break;
- case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
- case V_ASN1_UTF8STRING: /* FALLTHROUGH */
- case V_ASN1_NUMERICSTRING: /* FALLTHROUGH */
- case V_ASN1_PRINTABLESTRING: /* FALLTHROUGH */
- case V_ASN1_T61STRING: /* FALLTHROUGH */
- case V_ASN1_VIDEOTEXSTRING: /* FALLTHROUGH */
- case V_ASN1_IA5STRING: /* FALLTHROUGH */
- case V_ASN1_GRAPHICSTRING: /* FALLTHROUGH */
- case V_ASN1_ISO64STRING: /* FALLTHROUGH */
- case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
- case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
- case V_ASN1_BMPSTRING:
- ptr = obj_to_asn1str(value);
- free_func = (free_func_type *)ASN1_STRING_free;
- break;
- case V_ASN1_OBJECT:
- ptr = obj_to_asn1obj(value);
- free_func = (free_func_type *)ASN1_OBJECT_free;
- break;
- case V_ASN1_UTCTIME:
- ptr = obj_to_asn1utime(value);
- free_func = (free_func_type *)ASN1_TIME_free;
- break;
- case V_ASN1_GENERALIZEDTIME:
- ptr = obj_to_asn1gtime(value);
- free_func = (free_func_type *)ASN1_TIME_free;
- break;
- case V_ASN1_SET: /* FALLTHROUGH */
- case V_ASN1_SEQUENCE:
- ptr = obj_to_asn1derstr(obj);
- free_func = (free_func_type *)ASN1_STRING_free;
- break;
- default:
- ossl_raise(eASN1Error, "unsupported ASN.1 type");
+ ptr = obj_to_asn1bstr(value, NUM2INT(rflag));
+ free_func = (free_func_type *)ASN1_BIT_STRING_free;
+ break;
+ case V_ASN1_NULL:
+ ptr = obj_to_asn1null(value);
+ free_func = (free_func_type *)ASN1_NULL_free;
+ break;
+ case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
+ case V_ASN1_UTF8STRING: /* FALLTHROUGH */
+ case V_ASN1_NUMERICSTRING: /* FALLTHROUGH */
+ case V_ASN1_PRINTABLESTRING: /* FALLTHROUGH */
+ case V_ASN1_T61STRING: /* FALLTHROUGH */
+ case V_ASN1_VIDEOTEXSTRING: /* FALLTHROUGH */
+ case V_ASN1_IA5STRING: /* FALLTHROUGH */
+ case V_ASN1_GRAPHICSTRING: /* FALLTHROUGH */
+ case V_ASN1_ISO64STRING: /* FALLTHROUGH */
+ case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
+ case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
+ case V_ASN1_BMPSTRING:
+ ptr = obj_to_asn1str(value);
+ free_func = (free_func_type *)ASN1_STRING_free;
+ break;
+ case V_ASN1_OBJECT:
+ ptr = ossl_to_asn1obj(value);
+ free_func = (free_func_type *)ASN1_OBJECT_free;
+ break;
+ case V_ASN1_UTCTIME:
+ ptr = obj_to_asn1utime(value);
+ free_func = (free_func_type *)ASN1_TIME_free;
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ ptr = obj_to_asn1gtime(value);
+ free_func = (free_func_type *)ASN1_TIME_free;
+ break;
+ case V_ASN1_SET: /* FALLTHROUGH */
+ case V_ASN1_SEQUENCE:
+ ptr = obj_to_asn1derstr(obj);
+ free_func = (free_func_type *)ASN1_STRING_free;
+ break;
+ default:
+ ossl_raise(eASN1Error, "unsupported ASN.1 type");
}
if(!(ret = OPENSSL_malloc(sizeof(ASN1_TYPE)))){
- if(free_func) free_func(ptr);
- ossl_raise(eASN1Error, "ASN1_TYPE alloc failure");
+ if(free_func) free_func(ptr);
+ ossl_raise(eASN1Error, "ASN1_TYPE alloc failure");
}
memset(ret, 0, sizeof(ASN1_TYPE));
ASN1_TYPE_set(ret, tag, ptr);
@@ -586,10 +608,10 @@ ossl_asn1_default_tag(VALUE obj)
tmp_class = CLASS_OF(obj);
while (!NIL_P(tmp_class)) {
- tag = rb_hash_lookup(class_tag_map, tmp_class);
- if (tag != Qnil)
- return NUM2INT(tag);
- tmp_class = rb_class_superclass(tmp_class);
+ tag = rb_hash_lookup(class_tag_map, tmp_class);
+ if (tag != Qnil)
+ return NUM2INT(tag);
+ tmp_class = rb_class_superclass(tmp_class);
}
return -1;
@@ -602,7 +624,7 @@ ossl_asn1_tag(VALUE obj)
tag = ossl_asn1_get_tag(obj);
if(NIL_P(tag))
- ossl_raise(eASN1Error, "tag number not specified");
+ ossl_raise(eASN1Error, "tag number not specified");
return NUM2INT(tag);
}
@@ -614,28 +636,28 @@ ossl_asn1_tag_class(VALUE obj)
s = ossl_asn1_get_tag_class(obj);
if (NIL_P(s) || s == sym_UNIVERSAL)
- return V_ASN1_UNIVERSAL;
+ return V_ASN1_UNIVERSAL;
else if (s == sym_APPLICATION)
- return V_ASN1_APPLICATION;
+ return V_ASN1_APPLICATION;
else if (s == sym_CONTEXT_SPECIFIC)
- return V_ASN1_CONTEXT_SPECIFIC;
+ return V_ASN1_CONTEXT_SPECIFIC;
else if (s == sym_PRIVATE)
- return V_ASN1_PRIVATE;
+ return V_ASN1_PRIVATE;
else
- ossl_raise(eASN1Error, "invalid tag class");
+ ossl_raise(eASN1Error, "invalid tag class");
}
static VALUE
ossl_asn1_class2sym(int tc)
{
if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
- return sym_PRIVATE;
+ return sym_PRIVATE;
else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
- return sym_CONTEXT_SPECIFIC;
+ return sym_CONTEXT_SPECIFIC;
else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
- return sym_APPLICATION;
+ return sym_APPLICATION;
else
- return sym_UNIVERSAL;
+ return sym_UNIVERSAL;
}
/*
@@ -658,7 +680,7 @@ static VALUE
ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
{
if(!SYMBOL_P(tag_class))
- ossl_raise(eASN1Error, "invalid tag class");
+ ossl_raise(eASN1Error, "invalid tag class");
ossl_asn1_set_tag(self, tag);
ossl_asn1_set_value(self, value);
ossl_asn1_set_tag_class(self, tag_class);
@@ -680,35 +702,35 @@ to_der_internal(VALUE self, int constructed, int indef_len, VALUE body)
body_length = RSTRING_LENINT(body);
if (ossl_asn1_get_tagging(self) == sym_EXPLICIT) {
- int inner_length, e_encoding = indef_len ? 2 : 1;
-
- if (default_tag_number == -1)
- ossl_raise(eASN1Error, "explicit tagging of unknown tag");
-
- inner_length = ASN1_object_size(encoding, body_length, default_tag_number);
- total_length = ASN1_object_size(e_encoding, inner_length, tag_number);
- str = rb_str_new(NULL, total_length);
- p = (unsigned char *)RSTRING_PTR(str);
- /* Put explicit tag */
- ASN1_put_object(&p, e_encoding, inner_length, tag_number, tag_class);
- /* Append inner object */
- ASN1_put_object(&p, encoding, body_length, default_tag_number, V_ASN1_UNIVERSAL);
- memcpy(p, RSTRING_PTR(body), body_length);
- p += body_length;
- if (indef_len) {
- ASN1_put_eoc(&p); /* For inner object */
- ASN1_put_eoc(&p); /* For wrapper object */
- }
+ int inner_length, e_encoding = indef_len ? 2 : 1;
+
+ if (default_tag_number == -1)
+ ossl_raise(eASN1Error, "explicit tagging of unknown tag");
+
+ inner_length = ASN1_object_size(encoding, body_length, default_tag_number);
+ total_length = ASN1_object_size(e_encoding, inner_length, tag_number);
+ str = rb_str_new(NULL, total_length);
+ p = (unsigned char *)RSTRING_PTR(str);
+ /* Put explicit tag */
+ ASN1_put_object(&p, e_encoding, inner_length, tag_number, tag_class);
+ /* Append inner object */
+ ASN1_put_object(&p, encoding, body_length, default_tag_number, V_ASN1_UNIVERSAL);
+ memcpy(p, RSTRING_PTR(body), body_length);
+ p += body_length;
+ if (indef_len) {
+ ASN1_put_eoc(&p); /* For inner object */
+ ASN1_put_eoc(&p); /* For wrapper object */
+ }
}
else {
- total_length = ASN1_object_size(encoding, body_length, tag_number);
- str = rb_str_new(NULL, total_length);
- p = (unsigned char *)RSTRING_PTR(str);
- ASN1_put_object(&p, encoding, body_length, tag_number, tag_class);
- memcpy(p, RSTRING_PTR(body), body_length);
- p += body_length;
- if (indef_len)
- ASN1_put_eoc(&p);
+ total_length = ASN1_object_size(encoding, body_length, tag_number);
+ str = rb_str_new(NULL, total_length);
+ p = (unsigned char *)RSTRING_PTR(str);
+ ASN1_put_object(&p, encoding, body_length, tag_number, tag_class);
+ memcpy(p, RSTRING_PTR(body), body_length);
+ p += body_length;
+ if (indef_len)
+ ASN1_put_eoc(&p);
}
assert(p - (unsigned char *)RSTRING_PTR(str) == total_length);
return str;
@@ -731,84 +753,88 @@ ossl_asn1data_to_der(VALUE self)
VALUE value = ossl_asn1_get_value(self);
if (rb_obj_is_kind_of(value, rb_cArray))
- return ossl_asn1cons_to_der(self);
+ return ossl_asn1cons_to_der(self);
else {
- if (RTEST(ossl_asn1_get_indefinite_length(self)))
- ossl_raise(eASN1Error, "indefinite length form cannot be used " \
- "with primitive encoding");
- return ossl_asn1prim_to_der(self);
+ if (RTEST(ossl_asn1_get_indefinite_length(self)))
+ ossl_raise(eASN1Error, "indefinite length form cannot be used " \
+ "with primitive encoding");
+ return ossl_asn1prim_to_der(self);
}
}
+static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self);
+static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset,
+ int depth, int yield, long *num_read);
+
static VALUE
int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
- VALUE tc, long *num_read)
+ VALUE tc, long *num_read)
{
VALUE value, asn1data;
unsigned char *p;
- long flag = 0;
+ int flag = 0;
p = *pp;
if(tc == sym_UNIVERSAL && tag < ossl_asn1_info_size) {
- switch(tag){
- case V_ASN1_EOC:
- value = decode_eoc(p, hlen+length);
- break;
- case V_ASN1_BOOLEAN:
- value = decode_bool(p, hlen+length);
- break;
- case V_ASN1_INTEGER:
- value = decode_int(p, hlen+length);
- break;
- case V_ASN1_BIT_STRING:
- value = decode_bstr(p, hlen+length, &flag);
- break;
- case V_ASN1_NULL:
- value = decode_null(p, hlen+length);
- break;
- case V_ASN1_ENUMERATED:
- value = decode_enum(p, hlen+length);
- break;
- case V_ASN1_OBJECT:
- value = decode_obj(p, hlen+length);
- break;
- case V_ASN1_UTCTIME: /* FALLTHROUGH */
- case V_ASN1_GENERALIZEDTIME:
- value = decode_time(p, hlen+length);
- break;
- default:
- /* use original value */
- p += hlen;
- value = rb_str_new((const char *)p, length);
- break;
- }
+ switch(tag){
+ case V_ASN1_EOC:
+ value = decode_eoc(p, hlen+length);
+ break;
+ case V_ASN1_BOOLEAN:
+ value = decode_bool(p, hlen+length);
+ break;
+ case V_ASN1_INTEGER:
+ value = decode_int(p, hlen+length);
+ break;
+ case V_ASN1_BIT_STRING:
+ value = decode_bstr(p, hlen+length, &flag);
+ break;
+ case V_ASN1_NULL:
+ value = decode_null(p, hlen+length);
+ break;
+ case V_ASN1_ENUMERATED:
+ value = decode_enum(p, hlen+length);
+ break;
+ case V_ASN1_OBJECT:
+ value = decode_obj(p, hlen+length);
+ break;
+ case V_ASN1_UTCTIME: /* FALLTHROUGH */
+ case V_ASN1_GENERALIZEDTIME:
+ value = decode_time(p, hlen+length);
+ break;
+ default:
+ /* use original value */
+ p += hlen;
+ value = rb_str_new((const char *)p, length);
+ break;
+ }
}
else {
- p += hlen;
- value = rb_str_new((const char *)p, length);
+ p += hlen;
+ value = rb_str_new((const char *)p, length);
}
*pp += hlen + length;
*num_read = hlen + length;
if (tc == sym_UNIVERSAL &&
- tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
- VALUE klass = *ossl_asn1_info[tag].klass;
- VALUE args[4];
- args[0] = value;
- args[1] = INT2NUM(tag);
- args[2] = Qnil;
- args[3] = tc;
- asn1data = rb_obj_alloc(klass);
- ossl_asn1_initialize(4, args, asn1data);
- if(tag == V_ASN1_BIT_STRING){
- rb_ivar_set(asn1data, sivUNUSED_BITS, LONG2NUM(flag));
- }
+ tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
+ VALUE klass = *ossl_asn1_info[tag].klass;
+ VALUE args[4];
+ args[0] = value;
+ args[1] = INT2NUM(tag);
+ args[2] = Qnil;
+ args[3] = tc;
+ asn1data = rb_obj_alloc(klass);
+ ossl_asn1_initialize(4, args, asn1data);
+ if(tag == V_ASN1_BIT_STRING){
+ rb_ivar_set(asn1data, sivUNUSED_BITS, INT2NUM(flag));
+ }
}
else {
- asn1data = rb_obj_alloc(cASN1Data);
- ossl_asn1data_initialize(asn1data, value, INT2NUM(tag), tc);
+ asn1data = rb_obj_alloc(cASN1Data);
+ ossl_asn1data_initialize(asn1data, value, INT2NUM(tag), tc);
}
return asn1data;
@@ -816,8 +842,8 @@ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
static VALUE
int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
- long *offset, int depth, int yield, int j,
- int tag, VALUE tc, long *num_read)
+ long *offset, int depth, int yield, int j,
+ int tag, VALUE tc, long *num_read)
{
VALUE value, asn1data, ary;
int indefinite;
@@ -828,48 +854,52 @@ int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
available_len = indefinite ? max_len : length;
while (available_len > 0) {
- long inner_read = 0;
- value = ossl_asn1_decode0(pp, available_len, &off, depth + 1, yield, &inner_read);
- *num_read += inner_read;
- available_len -= inner_read;
-
- if (indefinite &&
- ossl_asn1_tag(value) == V_ASN1_EOC &&
- ossl_asn1_get_tag_class(value) == sym_UNIVERSAL) {
- break;
- }
- rb_ary_push(ary, value);
+ long inner_read = 0;
+ value = ossl_asn1_decode0(pp, available_len, &off, depth + 1, yield, &inner_read);
+ *num_read += inner_read;
+ available_len -= inner_read;
+
+ if (indefinite) {
+ if (ossl_asn1_tag(value) == V_ASN1_EOC &&
+ ossl_asn1_get_tag_class(value) == sym_UNIVERSAL)
+ break;
+ if (available_len == 0)
+ ossl_raise(eASN1Error, "EOC missing in indefinite length encoding");
+ }
+ rb_ary_push(ary, value);
}
if (tc == sym_UNIVERSAL) {
- VALUE args[4];
- if (tag == V_ASN1_SEQUENCE || tag == V_ASN1_SET)
- asn1data = rb_obj_alloc(*ossl_asn1_info[tag].klass);
- else
- asn1data = rb_obj_alloc(cASN1Constructive);
- args[0] = ary;
- args[1] = INT2NUM(tag);
- args[2] = Qnil;
- args[3] = tc;
- ossl_asn1_initialize(4, args, asn1data);
+ VALUE args[4];
+ if (tag == V_ASN1_SEQUENCE || tag == V_ASN1_SET)
+ asn1data = rb_obj_alloc(*ossl_asn1_info[tag].klass);
+ else
+ asn1data = rb_obj_alloc(cASN1Constructive);
+ args[0] = ary;
+ args[1] = INT2NUM(tag);
+ args[2] = Qnil;
+ args[3] = tc;
+ ossl_asn1_initialize(4, args, asn1data);
}
else {
- asn1data = rb_obj_alloc(cASN1Data);
- ossl_asn1data_initialize(asn1data, ary, INT2NUM(tag), tc);
+ asn1data = rb_obj_alloc(cASN1Data);
+ ossl_asn1data_initialize(asn1data, ary, INT2NUM(tag), tc);
}
if (indefinite)
- ossl_asn1_set_indefinite_length(asn1data, Qtrue);
+ ossl_asn1_set_indefinite_length(asn1data, Qtrue);
else
- ossl_asn1_set_indefinite_length(asn1data, Qfalse);
+ ossl_asn1_set_indefinite_length(asn1data, Qfalse);
*offset = off;
return asn1data;
}
+#define MAX_NESTING_DEPTH 200
+
static VALUE
ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
- int yield, long *num_read)
+ int yield, long *num_read)
{
unsigned char *start, *p;
const unsigned char *p0;
@@ -877,6 +907,10 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
int tag, tc, j;
VALUE asn1data, tag_class;
+ if (depth > MAX_NESTING_DEPTH) {
+ ossl_raise(eASN1Error, "nesting depth %d exceeds limit", depth);
+ }
+
p = *pp;
start = p;
p0 = p;
@@ -885,46 +919,46 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
if(j & 0x80) ossl_raise(eASN1Error, NULL);
if(len > length) ossl_raise(eASN1Error, "value is too short");
if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
- tag_class = sym_PRIVATE;
+ tag_class = sym_PRIVATE;
else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
- tag_class = sym_CONTEXT_SPECIFIC;
+ tag_class = sym_CONTEXT_SPECIFIC;
else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
- tag_class = sym_APPLICATION;
+ tag_class = sym_APPLICATION;
else
- tag_class = sym_UNIVERSAL;
+ tag_class = sym_UNIVERSAL;
hlen = p - start;
if(yield) {
- VALUE arg = rb_ary_new();
- rb_ary_push(arg, LONG2NUM(depth));
- rb_ary_push(arg, LONG2NUM(*offset));
- rb_ary_push(arg, LONG2NUM(hlen));
- rb_ary_push(arg, LONG2NUM(len));
- rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
- rb_ary_push(arg, ossl_asn1_class2sym(tc));
- rb_ary_push(arg, INT2NUM(tag));
- rb_yield(arg);
+ VALUE arg = rb_ary_new();
+ rb_ary_push(arg, LONG2NUM(depth));
+ rb_ary_push(arg, LONG2NUM(*offset));
+ rb_ary_push(arg, LONG2NUM(hlen));
+ rb_ary_push(arg, LONG2NUM(len));
+ rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
+ rb_ary_push(arg, ossl_asn1_class2sym(tc));
+ rb_ary_push(arg, INT2NUM(tag));
+ rb_yield(arg);
}
if(j & V_ASN1_CONSTRUCTED) {
- *pp += hlen;
- off += hlen;
- asn1data = int_ossl_asn1_decode0_cons(pp, length - hlen, len, &off, depth, yield, j, tag, tag_class, &inner_read);
- inner_read += hlen;
+ *pp += hlen;
+ off += hlen;
+ asn1data = int_ossl_asn1_decode0_cons(pp, length - hlen, len, &off, depth, yield, j, tag, tag_class, &inner_read);
+ inner_read += hlen;
}
else {
- if ((j & 0x01) && (len == 0))
- ossl_raise(eASN1Error, "indefinite length for primitive value");
- asn1data = int_ossl_asn1_decode0_prim(pp, len, hlen, tag, tag_class, &inner_read);
- off += hlen + len;
+ if ((j & 0x01) && (len == 0))
+ ossl_raise(eASN1Error, "indefinite length for primitive value");
+ asn1data = int_ossl_asn1_decode0_prim(pp, len, hlen, tag, tag_class, &inner_read);
+ off += hlen + len;
}
if (num_read)
- *num_read = inner_read;
+ *num_read = inner_read;
if (len != 0 && inner_read != hlen + len) {
- ossl_raise(eASN1Error,
- "Type mismatch. Bytes read: %ld Bytes available: %ld",
- inner_read, hlen + len);
+ ossl_raise(eASN1Error,
+ "Type mismatch. Bytes read: %ld Bytes available: %ld",
+ inner_read, hlen + len);
}
*offset = off;
@@ -935,9 +969,9 @@ static void
int_ossl_decode_sanity_check(long len, long read, long offset)
{
if (len != 0 && (read != len || offset != len)) {
- ossl_raise(eASN1Error,
- "Type mismatch. Total bytes read: %ld Bytes available: %ld Offset: %ld",
- read, len, offset);
+ ossl_raise(eASN1Error,
+ "Type mismatch. Total bytes read: %ld Bytes available: %ld Offset: %ld",
+ read, len, offset);
}
}
@@ -1037,11 +1071,11 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
tmp_len = len;
ary = rb_ary_new();
while (tmp_len > 0) {
- long tmp_read = 0;
- val = ossl_asn1_decode0(&p, tmp_len, &offset, 0, 0, &tmp_read);
- rb_ary_push(ary, val);
- read += tmp_read;
- tmp_len -= tmp_read;
+ long tmp_read = 0;
+ val = ossl_asn1_decode0(&p, tmp_len, &offset, 0, 0, &tmp_read);
+ rb_ary_push(ary, val);
+ read += tmp_read;
+ tmp_len -= tmp_read;
}
RB_GC_GUARD(tmp);
int_ossl_decode_sanity_check(len, read, offset);
@@ -1081,23 +1115,23 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
default_tag = ossl_asn1_default_tag(self);
if (default_tag == -1 || argc > 1) {
- if(NIL_P(tag))
- ossl_raise(eASN1Error, "must specify tag number");
- if(!NIL_P(tagging) && !SYMBOL_P(tagging))
- ossl_raise(eASN1Error, "invalid tagging method");
- if(NIL_P(tag_class)) {
- if (NIL_P(tagging))
- tag_class = sym_UNIVERSAL;
- else
- tag_class = sym_CONTEXT_SPECIFIC;
- }
- if(!SYMBOL_P(tag_class))
- ossl_raise(eASN1Error, "invalid tag class");
+ if(NIL_P(tag))
+ ossl_raise(eASN1Error, "must specify tag number");
+ if(!NIL_P(tagging) && !SYMBOL_P(tagging))
+ ossl_raise(eASN1Error, "invalid tagging method");
+ if(NIL_P(tag_class)) {
+ if (NIL_P(tagging))
+ tag_class = sym_UNIVERSAL;
+ else
+ tag_class = sym_CONTEXT_SPECIFIC;
+ }
+ if(!SYMBOL_P(tag_class))
+ ossl_raise(eASN1Error, "invalid tag class");
}
else{
- tag = INT2NUM(default_tag);
- tagging = Qnil;
- tag_class = sym_UNIVERSAL;
+ tag = INT2NUM(default_tag);
+ tagging = Qnil;
+ tag_class = sym_UNIVERSAL;
}
ossl_asn1_set_tag(self, tag);
ossl_asn1_set_value(self, value);
@@ -1105,7 +1139,7 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
ossl_asn1_set_tag_class(self, tag_class);
ossl_asn1_set_indefinite_length(self, Qfalse);
if (default_tag == V_ASN1_BIT_STRING)
- rb_ivar_set(self, sivUNUSED_BITS, INT2FIX(0));
+ rb_ivar_set(self, sivUNUSED_BITS, INT2FIX(0));
return self;
}
@@ -1147,30 +1181,33 @@ ossl_asn1prim_to_der(VALUE self)
VALUE str;
if (ossl_asn1_default_tag(self) == -1) {
- str = ossl_asn1_get_value(self);
- return to_der_internal(self, 0, 0, StringValue(str));
+ str = ossl_asn1_get_value(self);
+ return to_der_internal(self, 0, 0, StringValue(str));
}
asn1 = ossl_asn1_get_asn1type(self);
alllen = i2d_ASN1_TYPE(asn1, NULL);
if (alllen < 0) {
- ASN1_TYPE_free(asn1);
- ossl_raise(eASN1Error, "i2d_ASN1_TYPE");
+ ASN1_TYPE_free(asn1);
+ ossl_raise(eASN1Error, "i2d_ASN1_TYPE");
}
str = ossl_str_new(NULL, alllen, &state);
if (state) {
- ASN1_TYPE_free(asn1);
- rb_jump_tag(state);
+ ASN1_TYPE_free(asn1);
+ rb_jump_tag(state);
}
p0 = p1 = (unsigned char *)RSTRING_PTR(str);
- i2d_ASN1_TYPE(asn1, &p0);
+ if (i2d_ASN1_TYPE(asn1, &p0) < 0) {
+ ASN1_TYPE_free(asn1);
+ ossl_raise(eASN1Error, "i2d_ASN1_TYPE");
+ }
ASN1_TYPE_free(asn1);
- assert(p0 - p1 == alllen);
+ ossl_str_adjust(str, p0);
/* Strip header since to_der_internal() wants only the payload */
j = ASN1_get_object((const unsigned char **)&p1, &bodylen, &tag, &tc, alllen);
if (j & 0x80)
- ossl_raise(eASN1Error, "ASN1_get_object"); /* should not happen */
+ ossl_raise(eASN1Error, "ASN1_get_object"); /* should not happen */
return to_der_internal(self, 0, 0, rb_str_drop_bytes(str, alllen - bodylen));
}
@@ -1192,22 +1229,22 @@ ossl_asn1cons_to_der(VALUE self)
ary = rb_convert_type(ossl_asn1_get_value(self), T_ARRAY, "Array", "to_a");
str = rb_str_new(NULL, 0);
for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE item = RARRAY_AREF(ary, i);
-
- if (indef_len && rb_obj_is_kind_of(item, cASN1EndOfContent)) {
- if (i != RARRAY_LEN(ary) - 1)
- ossl_raise(eASN1Error, "illegal EOC octets in value");
-
- /*
- * EOC is not really part of the content, but we required to add one
- * at the end in the past.
- */
- break;
- }
-
- item = ossl_to_der_if_possible(item);
- StringValue(item);
- rb_str_append(str, item);
+ VALUE item = RARRAY_AREF(ary, i);
+
+ if (indef_len && rb_obj_is_kind_of(item, cASN1EndOfContent)) {
+ if (i != RARRAY_LEN(ary) - 1)
+ ossl_raise(eASN1Error, "illegal EOC octets in value");
+
+ /*
+ * EOC is not really part of the content, but we required to add one
+ * at the end in the past.
+ */
+ break;
+ }
+
+ item = ossl_to_der_if_possible(item);
+ StringValue(item);
+ rb_str_append(str, item);
}
return to_der_internal(self, 1, indef_len, str);
@@ -1253,7 +1290,7 @@ ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
StringValueCStr(ln);
if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
- ossl_raise(eASN1Error, NULL);
+ ossl_raise(eASN1Error, NULL);
return Qtrue;
}
@@ -1273,7 +1310,7 @@ ossl_asn1obj_get_sn(VALUE self)
val = ossl_asn1_get_value(self);
if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
- ret = rb_str_new2(OBJ_nid2sn(nid));
+ ret = rb_str_new2(OBJ_nid2sn(nid));
return ret;
}
@@ -1293,55 +1330,15 @@ ossl_asn1obj_get_ln(VALUE self)
val = ossl_asn1_get_value(self);
if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
- ret = rb_str_new2(OBJ_nid2ln(nid));
+ ret = rb_str_new2(OBJ_nid2ln(nid));
return ret;
}
-/*
- * call-seq:
- * oid == other_oid => true or false
- *
- * Returns +true+ if _other_oid_ is the same as _oid_
- */
-static VALUE
-ossl_asn1obj_eq(VALUE self, VALUE other)
-{
- VALUE valSelf, valOther;
- int nidSelf, nidOther;
-
- valSelf = ossl_asn1_get_value(self);
- valOther = ossl_asn1_get_value(other);
-
- if ((nidSelf = OBJ_txt2nid(StringValueCStr(valSelf))) == NID_undef)
- ossl_raise(eASN1Error, "OBJ_txt2nid");
-
- if ((nidOther = OBJ_txt2nid(StringValueCStr(valOther))) == NID_undef)
- ossl_raise(eASN1Error, "OBJ_txt2nid");
-
- return nidSelf == nidOther ? Qtrue : Qfalse;
-}
-
static VALUE
asn1obj_get_oid_i(VALUE vobj)
{
- ASN1_OBJECT *a1obj = (void *)vobj;
- VALUE str;
- int len;
-
- str = rb_usascii_str_new(NULL, 127);
- len = OBJ_obj2txt(RSTRING_PTR(str), RSTRING_LENINT(str), a1obj, 1);
- if (len <= 0 || len == INT_MAX)
- ossl_raise(eASN1Error, "OBJ_obj2txt");
- if (len > RSTRING_LEN(str)) {
- /* +1 is for the \0 terminator added by OBJ_obj2txt() */
- rb_str_resize(str, len + 1);
- len = OBJ_obj2txt(RSTRING_PTR(str), len + 1, a1obj, 1);
- if (len <= 0)
- ossl_raise(eASN1Error, "OBJ_obj2txt");
- }
- rb_str_set_len(str, len);
- return str;
+ return ossl_asn1obj_to_string_oid((const ASN1_OBJECT *)vobj);
}
/*
@@ -1358,14 +1355,33 @@ ossl_asn1obj_get_oid(VALUE self)
ASN1_OBJECT *a1obj;
int state;
- a1obj = obj_to_asn1obj(ossl_asn1_get_value(self));
+ a1obj = ossl_to_asn1obj(ossl_asn1_get_value(self));
str = rb_protect(asn1obj_get_oid_i, (VALUE)a1obj, &state);
ASN1_OBJECT_free(a1obj);
if (state)
- rb_jump_tag(state);
+ rb_jump_tag(state);
return str;
}
+/*
+ * call-seq:
+ * oid == other_oid => true or false
+ *
+ * Returns +true+ if _other_oid_ is the same as _oid_.
+ */
+static VALUE
+ossl_asn1obj_eq(VALUE self, VALUE other)
+{
+ VALUE oid1, oid2;
+
+ if (!rb_obj_is_kind_of(other, cASN1ObjectId))
+ return Qfalse;
+
+ oid1 = ossl_asn1obj_get_oid(self);
+ oid2 = ossl_asn1obj_get_oid(other);
+ return rb_str_equal(oid1, oid2);
+}
+
#define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
{ return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
@@ -1398,13 +1414,6 @@ void
Init_ossl_asn1(void)
{
#undef rb_intern
- VALUE ary;
- int i;
-
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
sym_UNIVERSAL = ID2SYM(rb_intern_const("UNIVERSAL"));
sym_CONTEXT_SPECIFIC = ID2SYM(rb_intern_const("CONTEXT_SPECIFIC"));
@@ -1554,17 +1563,20 @@ Init_ossl_asn1(void)
rb_define_module_function(mASN1, "traverse", ossl_asn1_traverse, 1);
rb_define_module_function(mASN1, "decode", ossl_asn1_decode, 1);
rb_define_module_function(mASN1, "decode_all", ossl_asn1_decode_all, 1);
- ary = rb_ary_new();
+ VALUE ary = rb_ary_new_capa(ossl_asn1_info_size);
+ for (int i = 0; i < ossl_asn1_info_size; i++) {
+ const char *name = ossl_asn1_info[i].name;
+ if (name[0] == '[')
+ continue;
+ rb_define_const(mASN1, name, INT2NUM(i));
+ rb_ary_store(ary, i, rb_obj_freeze(rb_str_new_cstr(name)));
+ }
+ rb_obj_freeze(ary);
/*
* Array storing tag names at the tag's index.
*/
rb_define_const(mASN1, "UNIVERSAL_TAG_NAME", ary);
- for(i = 0; i < ossl_asn1_info_size; i++){
- if(ossl_asn1_info[i].name[0] == '[') continue;
- rb_define_const(mASN1, ossl_asn1_info[i].name, INT2NUM(i));
- rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info[i].name));
- }
/* Document-class: OpenSSL::ASN1::ASN1Data
*
@@ -1886,6 +1898,7 @@ do{\
rb_hash_aset(class_tag_map, cASN1GeneralString, INT2NUM(V_ASN1_GENERALSTRING));
rb_hash_aset(class_tag_map, cASN1UniversalString, INT2NUM(V_ASN1_UNIVERSALSTRING));
rb_hash_aset(class_tag_map, cASN1BMPString, INT2NUM(V_ASN1_BMPSTRING));
+ rb_obj_freeze(class_tag_map);
id_each = rb_intern_const("each");
}
diff --git a/ext/openssl/ossl_asn1.h b/ext/openssl/ossl_asn1.h
index 939a96ce74..b605df8f3f 100644
--- a/ext/openssl/ossl_asn1.h
+++ b/ext/openssl/ossl_asn1.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_ASN1_H_)
#define _OSSL_ASN1_H_
@@ -32,30 +32,26 @@ VALUE asn1integer_to_num(const ASN1_INTEGER *);
ASN1_INTEGER *num_to_asn1integer(VALUE, ASN1_INTEGER *);
/*
+ * ASN1_OBJECT conversions
+ */
+ASN1_OBJECT *ossl_to_asn1obj(VALUE obj);
+/*
+ * Returns the short name if available, the dotted decimal notation otherwise.
+ * This is the most common way to return ASN1_OBJECT to Ruby.
+ */
+VALUE ossl_asn1obj_to_string(const ASN1_OBJECT *a1obj);
+/*
+ * However, some places use long names instead. This is likely unintentional,
+ * but we keep the current behavior in existing methods.
+ */
+VALUE ossl_asn1obj_to_string_long_name(const ASN1_OBJECT *a1obj);
+
+/*
* ASN1 module
*/
extern VALUE mASN1;
-extern VALUE eASN1Error;
extern VALUE cASN1Data;
-extern VALUE cASN1Primitive;
-extern VALUE cASN1Constructive;
-
-extern VALUE cASN1Boolean; /* BOOLEAN */
-extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
-extern VALUE cASN1BitString; /* BIT STRING */
-extern VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
-extern VALUE cASN1NumericString, cASN1PrintableString;
-extern VALUE cASN1T61String, cASN1VideotexString;
-extern VALUE cASN1IA5String, cASN1GraphicString;
-extern VALUE cASN1ISO64String, cASN1GeneralString;
-extern VALUE cASN1UniversalString, cASN1BMPString;
-extern VALUE cASN1Null; /* NULL */
-extern VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
-extern VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
-extern VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
-
-ASN1_TYPE *ossl_asn1_get_asn1type(VALUE);
void Init_ossl_asn1(void);
diff --git a/ext/openssl/ossl_bio.c b/ext/openssl/ossl_bio.c
index 42833d901a..cc03c5d5f7 100644
--- a/ext/openssl/ossl_bio.c
+++ b/ext/openssl/ossl_bio.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -16,11 +16,11 @@ ossl_obj2bio(volatile VALUE *pobj)
BIO *bio;
if (RB_TYPE_P(obj, T_FILE))
- obj = rb_funcallv(obj, rb_intern("read"), 0, NULL);
+ obj = rb_funcallv(obj, rb_intern("read"), 0, NULL);
StringValue(obj);
bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LENINT(obj));
if (!bio)
- ossl_raise(eOSSLError, "BIO_new_mem_buf");
+ ossl_raise(eOSSLError, "BIO_new_mem_buf");
*pobj = obj;
return bio;
}
@@ -32,11 +32,15 @@ ossl_membio2str(BIO *bio)
int state;
BUF_MEM *buf;
- BIO_get_mem_ptr(bio, &buf);
+ if (BIO_get_mem_ptr(bio, &buf) <= 0) {
+ BIO_free(bio);
+ ossl_raise(eOSSLError, "BIO_get_mem_ptr");
+ }
+
ret = ossl_str_new(buf->data, buf->length, &state);
BIO_free(bio);
if (state)
- rb_jump_tag(state);
+ rb_jump_tag(state);
return ret;
}
diff --git a/ext/openssl/ossl_bio.h b/ext/openssl/ossl_bio.h
index da68c5e5a2..1b871f1cd7 100644
--- a/ext/openssl/ossl_bio.h
+++ b/ext/openssl/ossl_bio.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_BIO_H_)
#define _OSSL_BIO_H_
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index bf2bac3679..9014f2df2b 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -5,29 +5,25 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
#include "ossl.h"
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
-#include <ruby/ractor.h>
-#endif
-
#define NewBN(klass) \
- TypedData_Wrap_Struct((klass), &ossl_bn_type, 0)
+ TypedData_Wrap_Struct((klass), &ossl_bn_type, 0)
#define SetBN(obj, bn) do { \
- if (!(bn)) { \
- ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
- } \
- RTYPEDDATA_DATA(obj) = (bn); \
+ if (!(bn)) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
+ RTYPEDDATA_DATA(obj) = (bn); \
} while (0)
#define GetBN(obj, bn) do { \
- TypedData_Get_Struct((obj), BIGNUM, &ossl_bn_type, (bn)); \
- if (!(bn)) { \
- ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
- } \
+ TypedData_Get_Struct((obj), BIGNUM, &ossl_bn_type, (bn)); \
+ if (!(bn)) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
} while (0)
static void
@@ -39,9 +35,9 @@ ossl_bn_free(void *ptr)
static const rb_data_type_t ossl_bn_type = {
"OpenSSL/BN",
{
- 0, ossl_bn_free,
+ 0, ossl_bn_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
};
/*
@@ -53,7 +49,7 @@ VALUE cBN;
*
* Generic Error for all of OpenSSL::BN (big num)
*/
-VALUE eBNError;
+static VALUE eBNError;
/*
* Public
@@ -65,10 +61,9 @@ ossl_bn_new(const BIGNUM *bn)
VALUE obj;
obj = NewBN(cBN);
- newbn = bn ? BN_dup(bn) : BN_new();
- if (!newbn) {
- ossl_raise(eBNError, NULL);
- }
+ newbn = BN_dup(bn);
+ if (!newbn)
+ ossl_raise(eBNError, "BN_dup");
SetBN(obj, newbn);
return obj;
@@ -80,40 +75,40 @@ integer_to_bnptr(VALUE obj, BIGNUM *orig)
BIGNUM *bn;
if (FIXNUM_P(obj)) {
- long i;
- unsigned char bin[sizeof(long)];
- long n = FIX2LONG(obj);
- unsigned long un = labs(n);
-
- for (i = sizeof(long) - 1; 0 <= i; i--) {
- bin[i] = un & 0xff;
- un >>= 8;
- }
-
- bn = BN_bin2bn(bin, sizeof(bin), orig);
- if (!bn)
- ossl_raise(eBNError, "BN_bin2bn");
- if (n < 0)
- BN_set_negative(bn, 1);
+ long i;
+ unsigned char bin[sizeof(long)];
+ long n = FIX2LONG(obj);
+ unsigned long un = labs(n);
+
+ for (i = sizeof(long) - 1; 0 <= i; i--) {
+ bin[i] = un & 0xff;
+ un >>= 8;
+ }
+
+ bn = BN_bin2bn(bin, sizeof(bin), orig);
+ if (!bn)
+ ossl_raise(eBNError, "BN_bin2bn");
+ if (n < 0)
+ BN_set_negative(bn, 1);
}
else { /* assuming Bignum */
- size_t len = rb_absint_size(obj, NULL);
- unsigned char *bin;
- VALUE buf;
- int sign;
-
- if (INT_MAX < len) {
- rb_raise(eBNError, "bignum too long");
- }
- bin = (unsigned char*)ALLOCV_N(unsigned char, buf, len);
- sign = rb_integer_pack(obj, bin, len, 1, 0, INTEGER_PACK_BIG_ENDIAN);
-
- bn = BN_bin2bn(bin, (int)len, orig);
- ALLOCV_END(buf);
- if (!bn)
- ossl_raise(eBNError, "BN_bin2bn");
- if (sign < 0)
- BN_set_negative(bn, 1);
+ size_t len = rb_absint_size(obj, NULL);
+ unsigned char *bin;
+ VALUE buf;
+ int sign;
+
+ if (INT_MAX < len) {
+ rb_raise(eBNError, "bignum too long");
+ }
+ bin = (unsigned char*)ALLOCV_N(unsigned char, buf, len);
+ sign = rb_integer_pack(obj, bin, len, 1, 0, INTEGER_PACK_BIG_ENDIAN);
+
+ bn = BN_bin2bn(bin, (int)len, orig);
+ ALLOCV_END(buf);
+ if (!bn)
+ ossl_raise(eBNError, "BN_bin2bn");
+ if (sign < 0)
+ BN_set_negative(bn, 1);
}
return bn;
@@ -126,11 +121,11 @@ try_convert_to_bn(VALUE obj)
VALUE newobj = Qnil;
if (rb_obj_is_kind_of(obj, cBN))
- return obj;
+ return obj;
if (RB_INTEGER_TYPE_P(obj)) {
- newobj = NewBN(cBN); /* Handle potential mem leaks */
- bn = integer_to_bnptr(obj, NULL);
- SetBN(newobj, bn);
+ newobj = NewBN(cBN); /* Handle potential mem leaks */
+ bn = integer_to_bnptr(obj, NULL);
+ SetBN(newobj, bn);
}
return newobj;
@@ -144,7 +139,7 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
tmp = try_convert_to_bn(*ptr);
if (NIL_P(tmp))
- ossl_raise(rb_eTypeError, "Cannot convert into OpenSSL::BN");
+ ossl_raise(rb_eTypeError, "Cannot convert into OpenSSL::BN");
GetBN(tmp, bn);
*ptr = tmp;
@@ -156,19 +151,19 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
*/
#ifdef HAVE_RB_EXT_RACTOR_SAFE
-void
+static void
ossl_bn_ctx_free(void *ptr)
{
BN_CTX *ctx = (BN_CTX *)ptr;
BN_CTX_free(ctx);
}
-struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
+static struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
NULL, // mark
ossl_bn_ctx_free,
};
-rb_ractor_local_key_t ossl_bn_ctx_key;
+static rb_ractor_local_key_t ossl_bn_ctx_key;
BN_CTX *
ossl_bn_ctx_get(void)
@@ -214,7 +209,7 @@ ossl_bn_alloc(VALUE klass)
VALUE obj = NewBN(klass);
if (!(bn = BN_new())) {
- ossl_raise(eBNError, NULL);
+ ossl_raise(eBNError, NULL);
}
SetBN(obj, bn);
@@ -244,7 +239,7 @@ ossl_bn_alloc(VALUE klass)
* number.
* - +10+ - Decimal number representation, with a leading '-' for a negative
* number.
- * - +16+ - Hexadeciaml number representation, with a leading '-' for a
+ * - +16+ - Hexadecimal number representation, with a leading '-' for a
* negative number.
*/
static VALUE
@@ -256,57 +251,58 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
char *ptr;
if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
- base = NUM2INT(bs);
+ base = NUM2INT(bs);
}
if (NIL_P(str)) {
ossl_raise(rb_eArgError, "invalid argument");
}
+ rb_check_frozen(self);
if (RB_INTEGER_TYPE_P(str)) {
- GetBN(self, bn);
- integer_to_bnptr(str, bn);
+ GetBN(self, bn);
+ integer_to_bnptr(str, bn);
- return self;
+ return self;
}
if (RTEST(rb_obj_is_kind_of(str, cBN))) {
- BIGNUM *other;
-
- GetBN(self, bn);
- GetBN(str, other); /* Safe - we checked kind_of? above */
- if (!BN_copy(bn, other)) {
- ossl_raise(eBNError, NULL);
- }
- return self;
+ BIGNUM *other;
+
+ GetBN(self, bn);
+ GetBN(str, other); /* Safe - we checked kind_of? above */
+ if (!BN_copy(bn, other)) {
+ ossl_raise(eBNError, NULL);
+ }
+ return self;
}
GetBN(self, bn);
switch (base) {
- case 0:
+ case 0:
ptr = StringValuePtr(str);
if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
- ossl_raise(eBNError, NULL);
- }
- break;
- case 2:
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 2:
ptr = StringValuePtr(str);
if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) {
- ossl_raise(eBNError, NULL);
- }
- break;
- case 10:
- if (!BN_dec2bn(&bn, StringValueCStr(str))) {
- ossl_raise(eBNError, NULL);
- }
- break;
- case 16:
- if (!BN_hex2bn(&bn, StringValueCStr(str))) {
- ossl_raise(eBNError, NULL);
- }
- break;
- default:
- ossl_raise(rb_eArgError, "invalid radix %d", base);
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 10:
+ if (!BN_dec2bn(&bn, StringValueCStr(str))) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 16:
+ if (!BN_hex2bn(&bn, StringValueCStr(str))) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ default:
+ ossl_raise(rb_eArgError, "invalid radix %d", base);
}
return self;
}
@@ -326,7 +322,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
* the bignum is ignored.
* - +10+ - Decimal number representation, with a leading '-' for a negative
* bignum.
- * - +16+ - Hexadeciaml number representation, with a leading '-' for a
+ * - +16+ - Hexadecimal number representation, with a leading '-' for a
* negative bignum.
*/
static VALUE
@@ -338,32 +334,32 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
char *buf;
if (rb_scan_args(argc, argv, "01", &bs) == 1) {
- base = NUM2INT(bs);
+ base = NUM2INT(bs);
}
GetBN(self, bn);
switch (base) {
- case 0:
- len = BN_bn2mpi(bn, NULL);
+ case 0:
+ len = BN_bn2mpi(bn, NULL);
str = rb_str_new(0, len);
- if (BN_bn2mpi(bn, (unsigned char *)RSTRING_PTR(str)) != len)
- ossl_raise(eBNError, NULL);
- break;
- case 2:
- len = BN_num_bytes(bn);
+ if (BN_bn2mpi(bn, (unsigned char *)RSTRING_PTR(str)) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 2:
+ len = BN_num_bytes(bn);
str = rb_str_new(0, len);
- if (BN_bn2bin(bn, (unsigned char *)RSTRING_PTR(str)) != len)
- ossl_raise(eBNError, NULL);
- break;
- case 10:
- if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
- str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
- break;
- case 16:
- if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
- str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
- break;
- default:
- ossl_raise(rb_eArgError, "invalid radix %d", base);
+ if (BN_bn2bin(bn, (unsigned char *)RSTRING_PTR(str)) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 10:
+ if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
+ break;
+ case 16:
+ if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
+ break;
+ default:
+ ossl_raise(rb_eArgError, "invalid radix %d", base);
}
return str;
@@ -383,7 +379,7 @@ ossl_bn_to_i(VALUE self)
GetBN(self, bn);
if (!(txt = BN_bn2hex(bn))) {
- ossl_raise(eBNError, NULL);
+ ossl_raise(eBNError, NULL);
}
num = rb_cstr_to_inum(txt, 16, Qtrue);
OPENSSL_free(txt);
@@ -401,31 +397,31 @@ static VALUE
ossl_bn_coerce(VALUE self, VALUE other)
{
switch(TYPE(other)) {
- case T_STRING:
- self = ossl_bn_to_s(0, NULL, self);
- break;
- case T_FIXNUM:
- case T_BIGNUM:
- self = ossl_bn_to_i(self);
- break;
- default:
- if (!RTEST(rb_obj_is_kind_of(other, cBN))) {
- ossl_raise(rb_eTypeError, "Don't know how to coerce");
- }
+ case T_STRING:
+ self = ossl_bn_to_s(0, NULL, self);
+ break;
+ case T_FIXNUM:
+ case T_BIGNUM:
+ self = ossl_bn_to_i(self);
+ break;
+ default:
+ if (!RTEST(rb_obj_is_kind_of(other, cBN))) {
+ ossl_raise(rb_eTypeError, "Don't know how to coerce");
+ }
}
return rb_assoc_new(other, self);
}
-#define BIGNUM_BOOL1(func) \
- static VALUE \
- ossl_bn_##func(VALUE self) \
- { \
- BIGNUM *bn; \
- GetBN(self, bn); \
- if (BN_##func(bn)) { \
- return Qtrue; \
- } \
- return Qfalse; \
+#define BIGNUM_BOOL1(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ if (BN_##func(bn)) { \
+ return Qtrue; \
+ } \
+ return Qfalse; \
}
/*
@@ -460,27 +456,27 @@ ossl_bn_is_negative(VALUE self)
GetBN(self, bn);
if (BN_is_zero(bn))
- return Qfalse;
+ return Qfalse;
return BN_is_negative(bn) ? Qtrue : Qfalse;
}
-#define BIGNUM_1c(func) \
- static VALUE \
- ossl_bn_##func(VALUE self) \
- { \
- BIGNUM *bn, *result; \
- VALUE obj; \
- GetBN(self, bn); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_new())) { \
- ossl_raise(eBNError, NULL); \
- } \
- if (BN_##func(result, bn, ossl_bn_ctx) <= 0) { \
- BN_free(result); \
- ossl_raise(eBNError, NULL); \
- } \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_1c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn, *result; \
+ VALUE obj; \
+ GetBN(self, bn); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (BN_##func(result, bn, ossl_bn_ctx) <= 0) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -490,23 +486,23 @@ ossl_bn_is_negative(VALUE self)
*/
BIGNUM_1c(sqr)
-#define BIGNUM_2(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE other) \
- { \
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
- VALUE obj; \
- GetBN(self, bn1); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_new())) { \
- ossl_raise(eBNError, NULL); \
- } \
- if (BN_##func(result, bn1, bn2) <= 0) { \
- BN_free(result); \
- ossl_raise(eBNError, NULL); \
- } \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_2(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (BN_##func(result, bn1, bn2) <= 0) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -523,23 +519,23 @@ BIGNUM_2(add)
*/
BIGNUM_2(sub)
-#define BIGNUM_2c(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE other) \
- { \
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
- VALUE obj; \
- GetBN(self, bn1); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_new())) { \
- ossl_raise(eBNError, NULL); \
- } \
- if (BN_##func(result, bn1, bn2, ossl_bn_ctx) <= 0) { \
- BN_free(result); \
- ossl_raise(eBNError, NULL); \
- } \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_2c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (BN_##func(result, bn1, bn2, ossl_bn_ctx) <= 0) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -577,18 +573,18 @@ BIGNUM_2c(gcd)
*/
BIGNUM_2c(mod_sqr)
-#define BIGNUM_2cr(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE other) \
- { \
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
- VALUE obj; \
- GetBN(self, bn1); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_##func(NULL, bn1, bn2, ossl_bn_ctx))) \
- ossl_raise(eBNError, NULL); \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_2cr(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_##func(NULL, bn1, bn2, ossl_bn_ctx))) \
+ ossl_raise(eBNError, NULL); \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -623,16 +619,16 @@ ossl_bn_div(VALUE self, VALUE other)
obj1 = NewBN(klass);
obj2 = NewBN(klass);
if (!(r1 = BN_new())) {
- ossl_raise(eBNError, NULL);
+ ossl_raise(eBNError, NULL);
}
if (!(r2 = BN_new())) {
- BN_free(r1);
- ossl_raise(eBNError, NULL);
+ BN_free(r1);
+ ossl_raise(eBNError, NULL);
}
if (!BN_div(r1, r2, bn1, bn2, ossl_bn_ctx)) {
- BN_free(r1);
- BN_free(r2);
- ossl_raise(eBNError, NULL);
+ BN_free(r1);
+ BN_free(r2);
+ ossl_raise(eBNError, NULL);
}
SetBN(obj1, r1);
SetBN(obj2, r2);
@@ -640,24 +636,24 @@ ossl_bn_div(VALUE self, VALUE other)
return rb_ary_new3(2, obj1, obj2);
}
-#define BIGNUM_3c(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE other1, VALUE other2) \
- { \
- BIGNUM *bn1, *bn2 = GetBNPtr(other1); \
- BIGNUM *bn3 = GetBNPtr(other2), *result; \
- VALUE obj; \
- GetBN(self, bn1); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_new())) { \
- ossl_raise(eBNError, NULL); \
- } \
- if (BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx) <= 0) { \
- BN_free(result); \
- ossl_raise(eBNError, NULL); \
- } \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_3c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other1, VALUE other2) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other1); \
+ BIGNUM *bn3 = GetBNPtr(other2), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx) <= 0) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -688,16 +684,17 @@ BIGNUM_3c(mod_mul)
*/
BIGNUM_3c(mod_exp)
-#define BIGNUM_BIT(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE bit) \
- { \
- BIGNUM *bn; \
- GetBN(self, bn); \
- if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
- ossl_raise(eBNError, NULL); \
- } \
- return self; \
+#define BIGNUM_BIT(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bit) \
+ { \
+ BIGNUM *bn; \
+ rb_check_frozen(self); \
+ GetBN(self, bn); \
+ if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ return self; \
}
/*
@@ -736,30 +733,30 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
b = NUM2INT(bit);
GetBN(self, bn);
if (BN_is_bit_set(bn, b)) {
- return Qtrue;
+ return Qtrue;
}
return Qfalse;
}
-#define BIGNUM_SHIFT(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE bits) \
- { \
- BIGNUM *bn, *result; \
- int b; \
- VALUE obj; \
- b = NUM2INT(bits); \
- GetBN(self, bn); \
- obj = NewBN(rb_obj_class(self)); \
- if (!(result = BN_new())) { \
- ossl_raise(eBNError, NULL); \
- } \
- if (BN_##func(result, bn, b) <= 0) { \
- BN_free(result); \
- ossl_raise(eBNError, NULL); \
- } \
- SetBN(obj, result); \
- return obj; \
+#define BIGNUM_SHIFT(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bits) \
+ { \
+ BIGNUM *bn, *result; \
+ int b; \
+ VALUE obj; \
+ b = NUM2INT(bits); \
+ GetBN(self, bn); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (BN_##func(result, bn, b) <= 0) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ SetBN(obj, result); \
+ return obj; \
}
/*
@@ -776,17 +773,18 @@ BIGNUM_SHIFT(lshift)
*/
BIGNUM_SHIFT(rshift)
-#define BIGNUM_SELF_SHIFT(func) \
- static VALUE \
- ossl_bn_self_##func(VALUE self, VALUE bits) \
- { \
- BIGNUM *bn; \
- int b; \
- b = NUM2INT(bits); \
- GetBN(self, bn); \
- if (BN_##func(bn, bn, b) <= 0) \
- ossl_raise(eBNError, NULL); \
- return self; \
+#define BIGNUM_SELF_SHIFT(func) \
+ static VALUE \
+ ossl_bn_self_##func(VALUE self, VALUE bits) \
+ { \
+ BIGNUM *bn; \
+ int b; \
+ rb_check_frozen(self); \
+ b = NUM2INT(bits); \
+ GetBN(self, bn); \
+ if (BN_##func(bn, bn, b) <= 0) \
+ ossl_raise(eBNError, NULL); \
+ return self; \
}
/*
@@ -888,32 +886,32 @@ ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
num = NUM2INT(vnum);
if (vsafe == Qfalse) {
- safe = 0;
+ safe = 0;
}
if (!NIL_P(vadd)) {
- add = GetBNPtr(vadd);
- rem = NIL_P(vrem) ? NULL : GetBNPtr(vrem);
+ add = GetBNPtr(vadd);
+ rem = NIL_P(vrem) ? NULL : GetBNPtr(vrem);
}
obj = NewBN(klass);
if (!(result = BN_new())) {
- ossl_raise(eBNError, NULL);
+ ossl_raise(eBNError, NULL);
}
if (!BN_generate_prime_ex(result, num, safe, add, rem, NULL)) {
- BN_free(result);
- ossl_raise(eBNError, NULL);
+ BN_free(result);
+ ossl_raise(eBNError, NULL);
}
SetBN(obj, result);
return obj;
}
-#define BIGNUM_NUM(func) \
- static VALUE \
- ossl_bn_##func(VALUE self) \
- { \
- BIGNUM *bn; \
- GetBN(self, bn); \
- return INT2NUM(BN_##func(bn)); \
+#define BIGNUM_NUM(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ return INT2NUM(BN_##func(bn)); \
}
/*
@@ -930,6 +928,7 @@ BIGNUM_NUM(num_bytes)
*/
BIGNUM_NUM(num_bits)
+/* :nodoc: */
static VALUE
ossl_bn_copy(VALUE self, VALUE other)
{
@@ -943,7 +942,7 @@ ossl_bn_copy(VALUE self, VALUE other)
bn2 = GetBNPtr(other);
if (!BN_copy(bn1, bn2)) {
- ossl_raise(eBNError, NULL);
+ ossl_raise(eBNError, NULL);
}
return self;
}
@@ -962,7 +961,7 @@ ossl_bn_uplus(VALUE self)
obj = NewBN(cBN);
bn2 = BN_dup(bn1);
if (!bn2)
- ossl_raise(eBNError, "BN_dup");
+ ossl_raise(eBNError, "BN_dup");
SetBN(obj, bn2);
return obj;
@@ -982,7 +981,7 @@ ossl_bn_uminus(VALUE self)
obj = NewBN(cBN);
bn2 = BN_dup(bn1);
if (!bn2)
- ossl_raise(eBNError, "BN_dup");
+ ossl_raise(eBNError, "BN_dup");
SetBN(obj, bn2);
BN_set_negative(bn2, !BN_is_negative(bn2));
@@ -1007,13 +1006,13 @@ ossl_bn_abs(VALUE self)
}
}
-#define BIGNUM_CMP(func) \
- static VALUE \
- ossl_bn_##func(VALUE self, VALUE other) \
- { \
- BIGNUM *bn1, *bn2 = GetBNPtr(other); \
- GetBN(self, bn1); \
- return INT2NUM(BN_##func(bn1, bn2)); \
+#define BIGNUM_CMP(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other); \
+ GetBN(self, bn1); \
+ return INT2NUM(BN_##func(bn1, bn2)); \
}
/*
@@ -1050,11 +1049,11 @@ ossl_bn_eq(VALUE self, VALUE other)
GetBN(self, bn1);
other = try_convert_to_bn(other);
if (NIL_P(other))
- return Qfalse;
+ return Qfalse;
GetBN(other, bn2);
if (!BN_cmp(bn1, bn2)) {
- return Qtrue;
+ return Qtrue;
}
return Qfalse;
}
@@ -1073,7 +1072,7 @@ ossl_bn_eql(VALUE self, VALUE other)
BIGNUM *bn1, *bn2;
if (!rb_obj_is_kind_of(other, cBN))
- return Qfalse;
+ return Qfalse;
GetBN(self, bn1);
GetBN(other, bn2);
@@ -1100,8 +1099,8 @@ ossl_bn_hash(VALUE self)
len = BN_num_bytes(bn);
buf = ALLOCV(tmp, len);
if (BN_bn2bin(bn, buf) != len) {
- ALLOCV_END(tmp);
- ossl_raise(eBNError, "BN_bn2bin");
+ ALLOCV_END(tmp);
+ ossl_raise(eBNError, "BN_bn2bin");
}
hash = ST2FIX(rb_memhash(buf, len));
@@ -1191,6 +1190,7 @@ ossl_bn_set_flags(VALUE self, VALUE arg)
BIGNUM *bn;
GetBN(self, bn);
+ rb_check_frozen(self);
BN_set_flags(bn, NUM2INT(arg));
return Qnil;
}
@@ -1202,11 +1202,6 @@ ossl_bn_set_flags(VALUE self, VALUE arg)
void
Init_ossl_bn(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
#ifdef HAVE_RB_EXT_RACTOR_SAFE
ossl_bn_ctx_key = rb_ractor_local_storage_ptr_newkey(&ossl_bn_ctx_key_type);
#else
diff --git a/ext/openssl/ossl_bn.h b/ext/openssl/ossl_bn.h
index 1cc041fc22..0c186bd1c5 100644
--- a/ext/openssl/ossl_bn.h
+++ b/ext/openssl/ossl_bn.h
@@ -5,13 +5,12 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_BN_H_)
#define _OSSL_BN_H_
extern VALUE cBN;
-extern VALUE eBNError;
BN_CTX *ossl_bn_ctx_get(void);
#define ossl_bn_ctx ossl_bn_ctx_get()
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index cb8fbc3ca2..e9dcd943e3 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -14,7 +14,7 @@
#define AllocCipher(obj, ctx) do { \
(ctx) = EVP_CIPHER_CTX_new(); \
if (!(ctx)) \
- ossl_raise(rb_eRuntimeError, NULL); \
+ ossl_raise(rb_eRuntimeError, NULL); \
RTYPEDDATA_DATA(obj) = (ctx); \
} while (0)
#define GetCipherInit(obj, ctx) do { \
@@ -23,16 +23,17 @@
#define GetCipher(obj, ctx) do { \
GetCipherInit((obj), (ctx)); \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "Cipher not initialized!"); \
+ ossl_raise(rb_eRuntimeError, "Cipher not initialized!"); \
} \
} while (0)
/*
* Classes
*/
-VALUE cCipher;
-VALUE eCipherError;
-static ID id_auth_tag_len, id_key_set;
+static VALUE cCipher;
+static VALUE eCipherError;
+static VALUE eAuthTagError;
+static ID id_auth_tag_len, id_key_set, id_cipher_holder;
static VALUE ossl_cipher_alloc(VALUE klass);
static void ossl_cipher_free(void *ptr);
@@ -40,35 +41,63 @@ static void ossl_cipher_free(void *ptr);
static const rb_data_type_t ossl_cipher_type = {
"OpenSSL/Cipher",
{
- 0, ossl_cipher_free,
+ 0, ossl_cipher_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
+#ifdef OSSL_USE_PROVIDER
+static void
+ossl_evp_cipher_free(void *ptr)
+{
+ // This is safe to call against const EVP_CIPHER * returned by
+ // EVP_get_cipherbyname()
+ EVP_CIPHER_free(ptr);
+}
+
+static const rb_data_type_t ossl_evp_cipher_holder_type = {
+ "OpenSSL/EVP_CIPHER",
+ {
+ .dfree = ossl_evp_cipher_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+#endif
+
/*
* PUBLIC
*/
const EVP_CIPHER *
-ossl_evp_get_cipherbyname(VALUE obj)
+ossl_evp_cipher_fetch(VALUE obj, volatile VALUE *holder)
{
+ *holder = Qnil;
if (rb_obj_is_kind_of(obj, cCipher)) {
- EVP_CIPHER_CTX *ctx;
-
- GetCipher(obj, ctx);
-
- return EVP_CIPHER_CTX_cipher(ctx);
+ EVP_CIPHER_CTX *ctx;
+ GetCipher(obj, ctx);
+ EVP_CIPHER *cipher = (EVP_CIPHER *)EVP_CIPHER_CTX_cipher(ctx);
+#ifdef OSSL_USE_PROVIDER
+ *holder = TypedData_Wrap_Struct(0, &ossl_evp_cipher_holder_type, NULL);
+ if (!EVP_CIPHER_up_ref(cipher))
+ ossl_raise(eCipherError, "EVP_CIPHER_up_ref");
+ RTYPEDDATA_DATA(*holder) = cipher;
+#endif
+ return cipher;
}
- else {
- const EVP_CIPHER *cipher;
-
- StringValueCStr(obj);
- cipher = EVP_get_cipherbyname(RSTRING_PTR(obj));
- if (!cipher)
- ossl_raise(rb_eArgError,
- "unsupported cipher algorithm: %"PRIsVALUE, obj);
- return cipher;
+ const char *name = StringValueCStr(obj);
+ EVP_CIPHER *cipher = (EVP_CIPHER *)EVP_get_cipherbyname(name);
+#ifdef OSSL_USE_PROVIDER
+ if (!cipher) {
+ ossl_clear_error();
+ *holder = TypedData_Wrap_Struct(0, &ossl_evp_cipher_holder_type, NULL);
+ cipher = EVP_CIPHER_fetch(NULL, name, NULL);
+ RTYPEDDATA_DATA(*holder) = cipher;
}
+#endif
+ if (!cipher)
+ ossl_raise(eCipherError, "unsupported cipher algorithm: %"PRIsVALUE,
+ obj);
+ return cipher;
}
VALUE
@@ -77,10 +106,13 @@ ossl_cipher_new(const EVP_CIPHER *cipher)
VALUE ret;
EVP_CIPHER_CTX *ctx;
+ // NOTE: This does not set id_cipher_holder because this function should
+ // only be called from ossl_engine.c, which will not use any
+ // reference-counted ciphers.
ret = ossl_cipher_alloc(cCipher);
AllocCipher(ret, ctx);
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
return ret;
}
@@ -113,23 +145,22 @@ ossl_cipher_initialize(VALUE self, VALUE str)
{
EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *cipher;
- char *name;
+ VALUE cipher_holder;
- name = StringValueCStr(str);
GetCipherInit(self, ctx);
if (ctx) {
- ossl_raise(rb_eRuntimeError, "Cipher already initialized!");
+ ossl_raise(rb_eRuntimeError, "Cipher already initialized!");
}
+ cipher = ossl_evp_cipher_fetch(str, &cipher_holder);
AllocCipher(self, ctx);
- if (!(cipher = EVP_get_cipherbyname(name))) {
- ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%"PRIsVALUE")", str);
- }
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, "EVP_CipherInit_ex");
+ rb_ivar_set(self, id_cipher_holder, cipher_holder);
return self;
}
+/* :nodoc: */
static VALUE
ossl_cipher_copy(VALUE self, VALUE other)
{
@@ -140,11 +171,11 @@ ossl_cipher_copy(VALUE self, VALUE other)
GetCipherInit(self, ctx1);
if (!ctx1) {
- AllocCipher(self, ctx1);
+ AllocCipher(self, ctx1);
}
GetCipher(other, ctx2);
if (EVP_CIPHER_CTX_copy(ctx1, ctx2) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
return self;
}
@@ -169,8 +200,8 @@ ossl_s_ciphers(VALUE self)
ary = rb_ary_new();
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
- add_cipher_name_to_ary,
- (void*)ary);
+ add_cipher_name_to_ary,
+ (void*)ary);
return ary;
}
@@ -191,53 +222,22 @@ ossl_cipher_reset(VALUE self)
GetCipher(self, ctx);
if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
return self;
}
static VALUE
-ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
+ossl_cipher_init(VALUE self, int enc)
{
EVP_CIPHER_CTX *ctx;
- unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
- unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
- VALUE pass, init_v;
-
- if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
- /*
- * oops. this code mistakes salt for IV.
- * We deprecated the arguments for this method, but we decided
- * keeping this behaviour for backward compatibility.
- */
- VALUE cname = rb_class_path(rb_obj_class(self));
- rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; "
- "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV",
- cname, cname, cname);
- StringValue(pass);
- GetCipher(self, ctx);
- if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
- else{
- StringValue(init_v);
- if (EVP_MAX_IV_LENGTH > RSTRING_LEN(init_v)) {
- memset(iv, 0, EVP_MAX_IV_LENGTH);
- memcpy(iv, RSTRING_PTR(init_v), RSTRING_LEN(init_v));
- }
- else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
- }
- EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
- (unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
- p_key = key;
- p_iv = iv;
- }
- else {
- GetCipher(self, ctx);
- }
- if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
- ossl_raise(eCipherError, NULL);
+
+ GetCipher(self, ctx);
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, enc) != 1) {
+ ossl_raise(eCipherError, "EVP_CipherInit_ex");
}
- rb_ivar_set(self, id_key_set, p_key ? Qtrue : Qfalse);
+ rb_ivar_set(self, id_key_set, Qfalse);
return self;
}
@@ -248,16 +248,15 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
*
* Initializes the Cipher for encryption.
*
- * Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
- * following methods:
- * * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen]
+ * Make sure to call either #encrypt or #decrypt before using the Cipher for
+ * any operation or setting any parameters.
*
* Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
*/
static VALUE
-ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
+ossl_cipher_encrypt(VALUE self)
{
- return ossl_cipher_init(argc, argv, self, 1);
+ return ossl_cipher_init(self, 1);
}
/*
@@ -266,16 +265,15 @@ ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
*
* Initializes the Cipher for decryption.
*
- * Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
- * following methods:
- * * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen]
+ * Make sure to call either #encrypt or #decrypt before using the Cipher for
+ * any operation or setting any parameters.
*
* Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
*/
static VALUE
-ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
+ossl_cipher_decrypt(VALUE self)
{
- return ossl_cipher_init(argc, argv, self, 0);
+ return ossl_cipher_init(self, 0);
}
/*
@@ -284,46 +282,42 @@ ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
*
* Generates and sets the key/IV based on a password.
*
- * *WARNING*: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40,
- * or DES with MD5 or SHA1. Using anything else (like AES) will generate the
- * key/iv using an OpenSSL specific method. This method is deprecated and
- * should no longer be used. Use a PKCS5 v2 key generation method from
- * OpenSSL::PKCS5 instead.
+ * *WARNING*: This method is deprecated and should not be used. This method
+ * corresponds to EVP_BytesToKey(), a non-standard OpenSSL extension of the
+ * legacy PKCS #5 v1.5 key derivation function. See OpenSSL::KDF for other
+ * options to derive keys from passwords.
*
* === Parameters
* * _salt_ must be an 8 byte string if provided.
* * _iterations_ is an integer with a default of 2048.
* * _digest_ is a Digest object that defaults to 'MD5'
- *
- * A minimum of 1000 iterations is recommended.
- *
*/
static VALUE
ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
{
EVP_CIPHER_CTX *ctx;
const EVP_MD *digest;
- VALUE vpass, vsalt, viter, vdigest;
+ VALUE vpass, vsalt, viter, vdigest, md_holder;
unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH], *salt = NULL;
int iter;
rb_scan_args(argc, argv, "13", &vpass, &vsalt, &viter, &vdigest);
StringValue(vpass);
if(!NIL_P(vsalt)){
- StringValue(vsalt);
- if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN)
- ossl_raise(eCipherError, "salt must be an 8-octet string");
- salt = (unsigned char *)RSTRING_PTR(vsalt);
+ StringValue(vsalt);
+ if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN)
+ ossl_raise(eCipherError, "salt must be an 8-octet string");
+ salt = (unsigned char *)RSTRING_PTR(vsalt);
}
iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
if (iter <= 0)
- rb_raise(rb_eArgError, "iterations must be a positive integer");
- digest = NIL_P(vdigest) ? EVP_md5() : ossl_evp_get_digestbyname(vdigest);
+ rb_raise(rb_eArgError, "iterations must be a positive integer");
+ digest = NIL_P(vdigest) ? EVP_md5() : ossl_evp_md_fetch(vdigest, &md_holder);
GetCipher(self, ctx);
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
- (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
+ (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
OPENSSL_cleanse(key, sizeof key);
OPENSSL_cleanse(iv, sizeof iv);
@@ -334,25 +328,25 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
static int
ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr,
- const unsigned char *in, long in_len)
+ const unsigned char *in, long in_len)
{
int out_part_len;
int limit = INT_MAX / 2 + 1;
long out_len = 0;
do {
- int in_part_len = in_len > limit ? limit : (int)in_len;
+ int in_part_len = in_len > limit ? limit : (int)in_len;
- if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
- &out_part_len, in, in_part_len))
- return 0;
+ if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
+ &out_part_len, in, in_part_len))
+ return 0;
- out_len += out_part_len;
- in += in_part_len;
+ out_len += out_part_len;
+ in += in_part_len;
} while ((in_len -= limit) > 0);
if (out_len_ptr)
- *out_len_ptr = out_len;
+ *out_len_ptr = out_len;
return 1;
}
@@ -368,6 +362,9 @@ ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_p
*
* If _buffer_ is given, the encryption/decryption result will be written to
* it. _buffer_ will be resized automatically.
+ *
+ * *NOTE*: When decrypting using an AEAD cipher, the integrity of the output
+ * is not verified until #final has been called.
*/
static VALUE
ossl_cipher_update(int argc, VALUE *argv, VALUE self)
@@ -380,28 +377,43 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "11", &data, &str);
if (!RTEST(rb_attr_get(self, id_key_set)))
- ossl_raise(eCipherError, "key not set");
+ ossl_raise(eCipherError, "key not set");
StringValue(data);
in = (unsigned char *)RSTRING_PTR(data);
in_len = RSTRING_LEN(data);
GetCipher(self, ctx);
- out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
- if (out_len <= 0) {
- ossl_raise(rb_eRangeError,
- "data too big to make output buffer: %ld bytes", in_len);
+
+ /*
+ * As of OpenSSL 3.2, there is no reliable way to determine the required
+ * output buffer size for arbitrary cipher modes.
+ * https://github.com/openssl/openssl/issues/22628
+ *
+ * in_len+block_size is usually sufficient, but AES key wrap with padding
+ * ciphers require in_len+15 even though they have a block size of 8 bytes.
+ *
+ * Using EVP_MAX_BLOCK_LENGTH (32) as a safe upper bound for ciphers
+ * currently implemented in OpenSSL, but this can change in the future.
+ */
+ if (in_len > LONG_MAX - EVP_MAX_BLOCK_LENGTH) {
+ ossl_raise(rb_eRangeError,
+ "data too big to make output buffer: %ld bytes", in_len);
}
+ out_len = in_len + EVP_MAX_BLOCK_LENGTH;
- if (NIL_P(str)) {
- str = rb_str_new(0, out_len);
- } else {
+ if (NIL_P(str))
+ str = rb_str_buf_new(out_len);
+ else {
StringValue(str);
- rb_str_resize(str, out_len);
+ if ((long)rb_str_capacity(str) >= out_len)
+ rb_str_modify(str);
+ else
+ rb_str_modify_expand(str, out_len - RSTRING_LEN(str));
}
- if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
- ossl_raise(eCipherError, NULL);
- assert(out_len < RSTRING_LEN(str));
+ if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str),
+ &out_len, in, in_len))
+ ossl_raise(eCipherError, "EVP_CipherUpdate");
rb_str_set_len(str, out_len);
return str;
@@ -412,14 +424,17 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
* cipher.final -> string
*
* Returns the remaining data held in the cipher object. Further calls to
- * Cipher#update or Cipher#final will return garbage. This call should always
+ * Cipher#update or Cipher#final are invalid. This call should always
* be made as the last call of an encryption or decryption operation, after
* having fed the entire plaintext or ciphertext to the Cipher instance.
*
- * If an authenticated cipher was used, a CipherError is raised if the tag
- * could not be authenticated successfully. Only call this method after
- * setting the authentication tag and passing the entire contents of the
- * ciphertext into the cipher.
+ * When encrypting using an AEAD cipher, the authentication tag can be
+ * retrieved by #auth_tag after #final has been called.
+ *
+ * When decrypting using an AEAD cipher, this method will verify the integrity
+ * of the ciphertext and the associated data with the authentication tag,
+ * which must be set by #auth_tag= prior to calling this method.
+ * If the verification fails, CipherError will be raised.
*/
static VALUE
ossl_cipher_final(VALUE self)
@@ -430,9 +445,17 @@ ossl_cipher_final(VALUE self)
GetCipher(self, ctx);
str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
- if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len))
- ossl_raise(eCipherError, NULL);
- assert(out_len <= RSTRING_LEN(str));
+ if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len)) {
+ /* For AEAD ciphers, this is likely an authentication failure */
+ if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) {
+ /* For AEAD ciphers, EVP_CipherFinal_ex failures are authentication tag verification failures */
+ ossl_raise(eAuthTagError, "AEAD authentication tag verification failed");
+ }
+ else {
+ /* For non-AEAD ciphers */
+ ossl_raise(eCipherError, "cipher final failed");
+ }
+ }
rb_str_set_len(str, out_len);
return str;
@@ -442,8 +465,8 @@ ossl_cipher_final(VALUE self)
* call-seq:
* cipher.name -> string
*
- * Returns the name of the cipher which may differ slightly from the original
- * name provided.
+ * Returns the short name of the cipher which may differ slightly from the
+ * original name provided.
*/
static VALUE
ossl_cipher_name(VALUE self)
@@ -457,7 +480,7 @@ ossl_cipher_name(VALUE self)
/*
* call-seq:
- * cipher.key = string -> string
+ * cipher.key = string
*
* Sets the cipher key. To generate a key, you should either use a secure
* random byte string or, if the key is to be derived from a password, you
@@ -465,6 +488,8 @@ ossl_cipher_name(VALUE self)
* generate a secure random-based key, Cipher#random_key may be used.
*
* Only call this method after calling Cipher#encrypt or Cipher#decrypt.
+ *
+ * See also the man page EVP_CipherInit_ex(3).
*/
static VALUE
ossl_cipher_set_key(VALUE self, VALUE key)
@@ -477,10 +502,10 @@ ossl_cipher_set_key(VALUE self, VALUE key)
key_len = EVP_CIPHER_CTX_key_length(ctx);
if (RSTRING_LEN(key) != key_len)
- ossl_raise(rb_eArgError, "key must be %d bytes", key_len);
+ ossl_raise(rb_eArgError, "key must be %d bytes", key_len);
if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
rb_ivar_set(self, id_key_set, Qtrue);
@@ -489,15 +514,21 @@ ossl_cipher_set_key(VALUE self, VALUE key)
/*
* call-seq:
- * cipher.iv = string -> string
+ * cipher.iv = string
*
* Sets the cipher IV. Please note that since you should never be using ECB
* mode, an IV is always explicitly required and should be set prior to
- * encryption. The IV itself can be safely transmitted in public, but it
- * should be unpredictable to prevent certain kinds of attacks. You may use
- * Cipher#random_iv to create a secure random IV.
+ * encryption. The IV itself can be safely transmitted in public.
*
- * Only call this method after calling Cipher#encrypt or Cipher#decrypt.
+ * This method expects the String to have the length equal to #iv_len. To use
+ * a different IV length with an AEAD cipher, #iv_len= must be set prior to
+ * calling this method.
+ *
+ * *NOTE*: In OpenSSL API conventions, the IV value may correspond to the
+ * "nonce" instead in some cipher modes. Refer to the OpenSSL man pages for
+ * details.
+ *
+ * See also the man page EVP_CipherInit_ex(3).
*/
static VALUE
ossl_cipher_set_iv(VALUE self, VALUE iv)
@@ -509,14 +540,14 @@ ossl_cipher_set_iv(VALUE self, VALUE iv)
GetCipher(self, ctx);
if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)
- iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
+ iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
if (!iv_len)
- iv_len = EVP_CIPHER_CTX_iv_length(ctx);
+ iv_len = EVP_CIPHER_CTX_iv_length(ctx);
if (RSTRING_LEN(iv) != iv_len)
- ossl_raise(rb_eArgError, "iv must be %d bytes", iv_len);
+ ossl_raise(rb_eArgError, "iv must be %d bytes", iv_len);
if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
return iv;
}
@@ -525,8 +556,7 @@ ossl_cipher_set_iv(VALUE self, VALUE iv)
* call-seq:
* cipher.authenticated? -> true | false
*
- * Indicated whether this Cipher instance uses an Authenticated Encryption
- * mode.
+ * Indicates whether this Cipher instance uses an AEAD mode.
*/
static VALUE
ossl_cipher_is_authenticated(VALUE self)
@@ -540,21 +570,23 @@ ossl_cipher_is_authenticated(VALUE self)
/*
* call-seq:
- * cipher.auth_data = string -> string
+ * cipher.auth_data = string
+ *
+ * Sets additional authenticated data (AAD), also called associated data, for
+ * this Cipher. This method is available for AEAD ciphers.
*
- * Sets the cipher's additional authenticated data. This field must be
- * set when using AEAD cipher modes such as GCM or CCM. If no associated
- * data shall be used, this method must *still* be called with a value of "".
* The contents of this field should be non-sensitive data which will be
* added to the ciphertext to generate the authentication tag which validates
* the contents of the ciphertext.
*
- * The AAD must be set prior to encryption or decryption. In encryption mode,
- * it must be set after calling Cipher#encrypt and setting Cipher#key= and
- * Cipher#iv=. When decrypting, the authenticated data must be set after key,
- * iv and especially *after* the authentication tag has been set. I.e. set it
- * only after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and
- * Cipher#auth_tag= first.
+ * This method must be called after #key= and #iv= have been set, but before
+ * starting actual encryption or decryption with #update. In some cipher modes,
+ * #auth_tag_len= and #ccm_data_len= may also need to be called before this
+ * method.
+ *
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
+ * This method internally calls EVP_CipherUpdate() with the output buffer
+ * set to NULL.
*/
static VALUE
ossl_cipher_set_auth_data(VALUE self, VALUE data)
@@ -570,7 +602,7 @@ ossl_cipher_set_auth_data(VALUE self, VALUE data)
GetCipher(self, ctx);
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
- ossl_raise(eCipherError, "AEAD not supported by this cipher");
+ ossl_raise(eCipherError, "AEAD not supported by this cipher");
if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len))
ossl_raise(eCipherError, "couldn't set additional authenticated data");
@@ -582,16 +614,17 @@ ossl_cipher_set_auth_data(VALUE self, VALUE data)
* call-seq:
* cipher.auth_tag(tag_len = 16) -> String
*
- * Gets the authentication tag generated by Authenticated Encryption Cipher
- * modes (GCM for example). This tag may be stored along with the ciphertext,
- * then set on the decryption cipher to authenticate the contents of the
- * ciphertext against changes. If the optional integer parameter _tag_len_ is
- * given, the returned tag will be _tag_len_ bytes long. If the parameter is
- * omitted, the default length of 16 bytes or the length previously set by
- * #auth_tag_len= will be used. For maximum security, the longest possible
- * should be chosen.
+ * Gets the generated authentication tag. This method is available for AEAD
+ * ciphers, and should be called after encryption has been finalized by calling
+ * #final.
*
- * The tag may only be retrieved after calling Cipher#final.
+ * The returned tag will be _tag_len_ bytes long. Some cipher modes require
+ * the desired length in advance using a separate call to #auth_tag_len=,
+ * before starting encryption.
+ *
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
+ * This method internally calls EVP_CIPHER_CTX_ctrl() with
+ * EVP_CTRL_AEAD_GET_TAG.
*/
static VALUE
ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self)
@@ -602,34 +635,42 @@ ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &vtag_len);
if (NIL_P(vtag_len))
- vtag_len = rb_attr_get(self, id_auth_tag_len);
+ vtag_len = rb_attr_get(self, id_auth_tag_len);
if (!NIL_P(vtag_len))
- tag_len = NUM2INT(vtag_len);
+ tag_len = NUM2INT(vtag_len);
GetCipher(self, ctx);
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
- ossl_raise(eCipherError, "authentication tag not supported by this cipher");
+ ossl_raise(eCipherError, "authentication tag not supported by this cipher");
ret = rb_str_new(NULL, tag_len);
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, tag_len, RSTRING_PTR(ret)))
- ossl_raise(eCipherError, "retrieving the authentication tag failed");
+ if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, tag_len, RSTRING_PTR(ret)) <= 0)
+ ossl_raise(eCipherError, "retrieving the authentication tag failed");
return ret;
}
/*
* call-seq:
- * cipher.auth_tag = string -> string
+ * cipher.auth_tag = string
*
* Sets the authentication tag to verify the integrity of the ciphertext.
- * This can be called only when the cipher supports AE. The tag must be set
- * after calling Cipher#decrypt, Cipher#key= and Cipher#iv=, but before
- * calling Cipher#final. After all decryption is performed, the tag is
- * verified automatically in the call to Cipher#final.
*
- * For OCB mode, the tag length must be supplied with #auth_tag_len=
- * beforehand.
+ * The authentication tag must be set before #final is called. The tag is
+ * verified during the #final call.
+ *
+ * Note that, for CCM mode and OCB mode, the expected length of the tag must
+ * be set before starting decryption by a separate call to #auth_tag_len=.
+ * The content of the tag can be provided at any time before #final is called.
+ *
+ * *NOTE*: The caller must ensure that the String passed to this method has
+ * the desired length. Some cipher modes support variable tag lengths, and
+ * this method may accept a truncated tag without raising an exception.
+ *
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
+ * This method internally calls EVP_CIPHER_CTX_ctrl() with
+ * EVP_CTRL_AEAD_SET_TAG.
*/
static VALUE
ossl_cipher_set_auth_tag(VALUE self, VALUE vtag)
@@ -644,24 +685,27 @@ ossl_cipher_set_auth_tag(VALUE self, VALUE vtag)
GetCipher(self, ctx);
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
- ossl_raise(eCipherError, "authentication tag not supported by this cipher");
+ ossl_raise(eCipherError, "authentication tag not supported by this cipher");
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag))
- ossl_raise(eCipherError, "unable to set AEAD tag");
+ if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag) <= 0)
+ ossl_raise(eCipherError, "unable to set AEAD tag");
return vtag;
}
/*
* call-seq:
- * cipher.auth_tag_len = Integer -> Integer
+ * cipher.auth_tag_len = integer
*
- * Sets the length of the authentication tag to be generated or to be given for
- * AEAD ciphers that requires it as in input parameter. Note that not all AEAD
- * ciphers support this method.
+ * Sets the length of the expected authentication tag for this Cipher. This
+ * method is available for some of AEAD ciphers that require the length to be
+ * set before starting encryption or decryption, such as CCM mode or OCB mode.
*
- * In OCB mode, the length must be supplied both when encrypting and when
- * decrypting, and must be before specifying an IV.
+ * For CCM mode and OCB mode, the tag length must be set before #iv= is set.
+ *
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
+ * This method internally calls EVP_CIPHER_CTX_ctrl() with
+ * EVP_CTRL_AEAD_SET_TAG and a NULL buffer.
*/
static VALUE
ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen)
@@ -671,10 +715,10 @@ ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen)
GetCipher(self, ctx);
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
- ossl_raise(eCipherError, "AEAD not supported by this cipher");
+ ossl_raise(eCipherError, "AEAD not supported by this cipher");
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL))
- ossl_raise(eCipherError, "unable to set authentication tag length");
+ if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL) <= 0)
+ ossl_raise(eCipherError, "unable to set authentication tag length");
/* for #auth_tag */
rb_ivar_set(self, id_auth_tag_len, INT2NUM(tag_len));
@@ -684,11 +728,16 @@ ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen)
/*
* call-seq:
- * cipher.iv_len = integer -> integer
+ * cipher.iv_len = integer
+ *
+ * Sets the IV/nonce length for this Cipher. This method is available for AEAD
+ * ciphers that support variable IV lengths. This method can be called if a
+ * different IV length than OpenSSL's default is desired, prior to calling
+ * #iv=.
*
- * Sets the IV/nonce length of the Cipher. Normally block ciphers don't allow
- * changing the IV length, but some make use of IV for 'nonce'. You may need
- * this for interoperability with other applications.
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
+ * This method internally calls EVP_CIPHER_CTX_ctrl() with
+ * EVP_CTRL_AEAD_SET_IVLEN.
*/
static VALUE
ossl_cipher_set_iv_length(VALUE self, VALUE iv_length)
@@ -698,10 +747,10 @@ ossl_cipher_set_iv_length(VALUE self, VALUE iv_length)
GetCipher(self, ctx);
if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
- ossl_raise(eCipherError, "cipher does not support AEAD");
+ ossl_raise(eCipherError, "cipher does not support AEAD");
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL))
- ossl_raise(eCipherError, "unable to set IV length");
+ if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL) <= 0)
+ ossl_raise(eCipherError, "unable to set IV length");
/*
* EVP_CIPHER_CTX_iv_length() returns the default length. So we need to save
@@ -714,13 +763,14 @@ ossl_cipher_set_iv_length(VALUE self, VALUE iv_length)
/*
* call-seq:
- * cipher.key_len = integer -> integer
+ * cipher.key_len = integer
*
* Sets the key length of the cipher. If the cipher is a fixed length cipher
* then attempting to set the key length to any value other than the fixed
* value is an error.
*
- * Under normal circumstances you do not need to call this method (and probably shouldn't).
+ * Under normal circumstances you do not need to call this method (and
+ * probably shouldn't).
*
* See EVP_CIPHER_CTX_set_key_length for further information.
*/
@@ -737,13 +787,16 @@ ossl_cipher_set_key_length(VALUE self, VALUE key_length)
return key_length;
}
+// TODO: Should #padding= take a boolean value instead?
/*
* call-seq:
- * cipher.padding = integer -> integer
+ * cipher.padding = 1 or 0
*
- * Enables or disables padding. By default encryption operations are padded using standard block padding and the
- * padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the
- * total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur.
+ * Enables or disables padding. By default encryption operations are padded
+ * using standard block padding and the padding is checked and removed when
+ * decrypting. If the pad parameter is zero then no padding is performed, the
+ * total amount of data encrypted or decrypted must then be a multiple of the
+ * block size or an error will occur.
*
* See EVP_CIPHER_CTX_set_padding for further information.
*/
@@ -755,7 +808,7 @@ ossl_cipher_set_padding(VALUE self, VALUE padding)
GetCipher(self, ctx);
if (EVP_CIPHER_CTX_set_padding(ctx, pad) != 1)
- ossl_raise(eCipherError, NULL);
+ ossl_raise(eCipherError, NULL);
return padding;
}
@@ -789,9 +842,9 @@ ossl_cipher_iv_length(VALUE self)
GetCipher(self, ctx);
if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)
- len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
+ len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
if (!len)
- len = EVP_CIPHER_CTX_iv_length(ctx);
+ len = EVP_CIPHER_CTX_iv_length(ctx);
return INT2NUM(len);
}
@@ -814,13 +867,17 @@ ossl_cipher_block_size(VALUE self)
/*
* call-seq:
- * cipher.ccm_data_len = integer -> integer
+ * cipher.ccm_data_len = integer
*
- * Sets the length of the plaintext / ciphertext message that will be
- * processed in CCM mode. Make sure to call this method after #key= and
- * #iv= have been set, and before #auth_data=.
+ * Sets the total length of the plaintext / ciphertext message that will be
+ * processed by #update in CCM mode.
*
- * Only call this method after calling Cipher#encrypt or Cipher#decrypt.
+ * Make sure to call this method after #key= and #iv= have been set, and
+ * before #auth_data= or #update are called.
+ *
+ * This method is only available for CCM mode ciphers.
+ *
+ * See also the "AEAD Interface" section of the man page EVP_EncryptInit(3).
*/
static VALUE
ossl_cipher_set_ccm_data_len(VALUE self, VALUE data_len)
@@ -843,11 +900,6 @@ ossl_cipher_set_ccm_data_len(VALUE self, VALUE data_len)
void
Init_ossl_cipher(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/* Document-class: OpenSSL::Cipher
*
* Provides symmetric algorithms for encryption and decryption. The
@@ -1003,24 +1055,28 @@ Init_ossl_cipher(void)
* could otherwise be exploited to modify ciphertexts in ways beneficial to
* potential attackers.
*
- * An associated data is used where there is additional information, such as
+ * Associated data, also called additional authenticated data (AAD), is
+ * optionally used where there is additional information, such as
* headers or some metadata, that must be also authenticated but not
- * necessarily need to be encrypted. If no associated data is needed for
- * encryption and later decryption, the OpenSSL library still requires a
- * value to be set - "" may be used in case none is available.
+ * necessarily need to be encrypted.
*
* An example using the GCM (Galois/Counter Mode). You have 16 bytes _key_,
* 12 bytes (96 bits) _nonce_ and the associated data _auth_data_. Be sure
* not to reuse the _key_ and _nonce_ pair. Reusing an nonce ruins the
* security guarantees of GCM mode.
*
+ * key = OpenSSL::Random.random_bytes(16)
+ * nonce = OpenSSL::Random.random_bytes(12)
+ * auth_data = "authenticated but unencrypted data"
+ * data = "encrypted data"
+ *
* cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt
* cipher.key = key
* cipher.iv = nonce
* cipher.auth_data = auth_data
*
* encrypted = cipher.update(data) + cipher.final
- * tag = cipher.auth_tag # produces 16 bytes tag by default
+ * tag = cipher.auth_tag(16)
*
* Now you are the receiver. You know the _key_ and have received _nonce_,
* _auth_data_, _encrypted_ and _tag_ through an untrusted network. Note
@@ -1033,23 +1089,29 @@ Init_ossl_cipher(void)
* decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt
* decipher.key = key
* decipher.iv = nonce
- * decipher.auth_tag = tag
+ * decipher.auth_tag = tag # could be called at any time before #final
* decipher.auth_data = auth_data
*
* decrypted = decipher.update(encrypted) + decipher.final
*
* puts data == decrypted #=> true
+ *
+ * Note that other AEAD ciphers may require additional steps, such as
+ * setting the expected tag length (#auth_tag_len=) or the total data
+ * length (#ccm_data_len=) in advance. Make sure to read the relevant man
+ * page for details.
*/
cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);
+ eAuthTagError = rb_define_class_under(cCipher, "AuthTagError", eCipherError);
rb_define_alloc_func(cCipher, ossl_cipher_alloc);
rb_define_method(cCipher, "initialize_copy", ossl_cipher_copy, 1);
rb_define_module_function(cCipher, "ciphers", ossl_s_ciphers, 0);
rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
- rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
- rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
+ rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, 0);
+ rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, 0);
rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
rb_define_method(cCipher, "update", ossl_cipher_update, -1);
rb_define_method(cCipher, "final", ossl_cipher_final, 0);
@@ -1071,4 +1133,5 @@ Init_ossl_cipher(void)
id_auth_tag_len = rb_intern_const("auth_tag_len");
id_key_set = rb_intern_const("key_set");
+ id_cipher_holder = rb_intern_const("EVP_CIPHER_holder");
}
diff --git a/ext/openssl/ossl_cipher.h b/ext/openssl/ossl_cipher.h
index 2392d41c6a..fba63a140f 100644
--- a/ext/openssl/ossl_cipher.h
+++ b/ext/openssl/ossl_cipher.h
@@ -5,15 +5,21 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_CIPHER_H_)
#define _OSSL_CIPHER_H_
-extern VALUE cCipher;
-extern VALUE eCipherError;
-
-const EVP_CIPHER *ossl_evp_get_cipherbyname(VALUE);
+/*
+ * Gets EVP_CIPHER from a String or an OpenSSL::Digest instance (discouraged,
+ * but still supported for compatibility). A holder object is created if the
+ * EVP_CIPHER is a "fetched" algorithm.
+ */
+const EVP_CIPHER *ossl_evp_cipher_fetch(VALUE obj, volatile VALUE *holder);
+/*
+ * This is meant for OpenSSL::Engine#cipher. EVP_CIPHER must not be a fetched
+ * one.
+ */
VALUE ossl_cipher_new(const EVP_CIPHER *);
void Init_ossl_cipher(void);
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
index 0bac027487..274875a978 100644
--- a/ext/openssl/ossl_config.c
+++ b/ext/openssl/ossl_config.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -22,7 +22,7 @@ static const rb_data_type_t ossl_config_type = {
{
0, nconf_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
};
CONF *
@@ -87,6 +87,7 @@ config_s_parse(VALUE klass, VALUE str)
bio = ossl_obj2bio(&str);
config_load_bio(conf, bio); /* Consumes BIO */
+ rb_obj_freeze(obj);
return obj;
}
@@ -144,6 +145,7 @@ config_initialize(int argc, VALUE *argv, VALUE self)
ossl_raise(eConfigError, "BIO_new_file");
config_load_bio(conf, bio); /* Consumes BIO */
}
+ rb_obj_freeze(self);
return self;
}
@@ -158,6 +160,7 @@ config_initialize_copy(VALUE self, VALUE other)
rb_check_frozen(self);
bio = ossl_obj2bio(&str);
config_load_bio(conf, bio); /* Consumes BIO */
+ rb_obj_freeze(self);
return self;
}
@@ -305,18 +308,16 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE, VALUE)
*
* Gets the parsable form of the current configuration.
*
- * Given the following configuration being created:
+ * Given the following configuration file being loaded:
*
- * config = OpenSSL::Config.new
- * #=> #<OpenSSL::Config sections=[]>
- * config['default'] = {"foo"=>"bar","baz"=>"buz"}
- * #=> {"foo"=>"bar", "baz"=>"buz"}
+ * config = OpenSSL::Config.load('baz.cnf')
+ * #=> #<OpenSSL::Config sections=["default"]>
* puts config.to_s
* #=> [ default ]
* # foo=bar
* # baz=buz
*
- * You can parse get the serialized configuration using #to_s and then parse
+ * You can get the serialized configuration using #to_s and then parse
* it later:
*
* serialized_config = config.to_s
@@ -412,11 +413,6 @@ Init_ossl_config(void)
char *path;
VALUE path_str;
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/* Document-class: OpenSSL::Config
*
* Configuration for the openssl library.
@@ -425,7 +421,7 @@ Init_ossl_config(void)
* configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for
* the location of the file for your host.
*
- * See also http://www.openssl.org/docs/apps/config.html
+ * See also https://docs.openssl.org/master/man5/config/
*/
cConfig = rb_define_class_under(mOSSL, "Config", rb_cObject);
@@ -455,6 +451,6 @@ Init_ossl_config(void)
* The default system configuration file for OpenSSL.
*/
path = CONF_get1_default_config_file();
- path_str = ossl_buf2str(path, rb_long2int(strlen(path)));
+ path_str = rb_obj_freeze(ossl_buf2str(path, rb_long2int(strlen(path))));
rb_define_const(cConfig, "DEFAULT_CONFIG_FILE", path_str);
}
diff --git a/ext/openssl/ossl_config.h b/ext/openssl/ossl_config.h
index 4e604f1aed..a254360c2c 100644
--- a/ext/openssl/ossl_config.h
+++ b/ext/openssl/ossl_config.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#ifndef OSSL_CONFIG_H
#define OSSL_CONFIG_H
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index fc326ec14a..e23968b1e3 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -5,22 +5,23 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
#define GetDigest(obj, ctx) do { \
TypedData_Get_Struct((obj), EVP_MD_CTX, &ossl_digest_type, (ctx)); \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "Digest CTX wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "Digest CTX wasn't initialized!"); \
} \
} while (0)
/*
* Classes
*/
-VALUE cDigest;
-VALUE eDigestError;
+static VALUE cDigest;
+static VALUE eDigestError;
+static ID id_md_holder;
static VALUE ossl_digest_alloc(VALUE klass);
@@ -33,39 +34,67 @@ ossl_digest_free(void *ctx)
static const rb_data_type_t ossl_digest_type = {
"OpenSSL/Digest",
{
- 0, ossl_digest_free,
+ 0, ossl_digest_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
+#ifdef OSSL_USE_PROVIDER
+static void
+ossl_evp_md_free(void *ptr)
+{
+ // This is safe to call against const EVP_MD * returned by
+ // EVP_get_digestbyname()
+ EVP_MD_free(ptr);
+}
+
+static const rb_data_type_t ossl_evp_md_holder_type = {
+ "OpenSSL/EVP_MD",
+ {
+ .dfree = ossl_evp_md_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+#endif
+
/*
* Public
*/
const EVP_MD *
-ossl_evp_get_digestbyname(VALUE obj)
+ossl_evp_md_fetch(VALUE obj, volatile VALUE *holder)
{
- const EVP_MD *md;
- ASN1_OBJECT *oid = NULL;
-
- if (RB_TYPE_P(obj, T_STRING)) {
- const char *name = StringValueCStr(obj);
-
- md = EVP_get_digestbyname(name);
- if (!md) {
- oid = OBJ_txt2obj(name, 0);
- md = EVP_get_digestbyobj(oid);
- ASN1_OBJECT_free(oid);
- }
- if(!md)
- ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%"PRIsVALUE").", obj);
- } else {
+ *holder = Qnil;
+ if (rb_obj_is_kind_of(obj, cDigest)) {
EVP_MD_CTX *ctx;
-
GetDigest(obj, ctx);
-
- md = EVP_MD_CTX_get0_md(ctx);
+ EVP_MD *md = (EVP_MD *)EVP_MD_CTX_get0_md(ctx);
+#ifdef OSSL_USE_PROVIDER
+ *holder = TypedData_Wrap_Struct(0, &ossl_evp_md_holder_type, NULL);
+ if (!EVP_MD_up_ref(md))
+ ossl_raise(eDigestError, "EVP_MD_up_ref");
+ RTYPEDDATA_DATA(*holder) = md;
+#endif
+ return md;
}
+ const char *name = StringValueCStr(obj);
+ EVP_MD *md = (EVP_MD *)EVP_get_digestbyname(name);
+ if (!md) {
+ ASN1_OBJECT *oid = OBJ_txt2obj(name, 0);
+ md = (EVP_MD *)EVP_get_digestbyobj(oid);
+ ASN1_OBJECT_free(oid);
+ }
+#ifdef OSSL_USE_PROVIDER
+ if (!md) {
+ ossl_clear_error();
+ *holder = TypedData_Wrap_Struct(0, &ossl_evp_md_holder_type, NULL);
+ md = EVP_MD_fetch(NULL, name, NULL);
+ RTYPEDDATA_DATA(*holder) = md;
+ }
+#endif
+ if (!md)
+ ossl_raise(eDigestError, "unsupported digest algorithm: %"PRIsVALUE,
+ obj);
return md;
}
@@ -75,14 +104,17 @@ ossl_digest_new(const EVP_MD *md)
VALUE ret;
EVP_MD_CTX *ctx;
+ // NOTE: This does not set id_md_holder because this function should
+ // only be called from ossl_engine.c, which will not use any
+ // reference-counted digests.
ret = ossl_digest_alloc(cDigest);
ctx = EVP_MD_CTX_new();
if (!ctx)
- ossl_raise(eDigestError, "EVP_MD_CTX_new");
+ ossl_raise(eDigestError, "EVP_MD_CTX_new");
RTYPEDDATA_DATA(ret) = ctx;
if (!EVP_DigestInit_ex(ctx, md, NULL))
- ossl_raise(eDigestError, "Digest initialization failed");
+ ossl_raise(eDigestError, "Digest initialization failed");
return ret;
}
@@ -96,14 +128,15 @@ ossl_digest_alloc(VALUE klass)
return TypedData_Wrap_Struct(klass, &ossl_digest_type, 0);
}
-VALUE ossl_digest_update(VALUE, VALUE);
+static VALUE ossl_digest_update(VALUE, VALUE);
/*
* call-seq:
* Digest.new(string [, data]) -> Digest
*
* Creates a Digest instance based on _string_, which is either the ln
- * (long name) or sn (short name) of a supported digest algorithm.
+ * (long name) or sn (short name) of a supported digest algorithm. A list of
+ * supported algorithms can be obtained by calling OpenSSL::Digest.digests.
*
* If _data_ (a String) is given, it is used as the initial input to the
* Digest instance, i.e.
@@ -120,26 +153,28 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
{
EVP_MD_CTX *ctx;
const EVP_MD *md;
- VALUE type, data;
+ VALUE type, data, md_holder;
rb_scan_args(argc, argv, "11", &type, &data);
- md = ossl_evp_get_digestbyname(type);
+ md = ossl_evp_md_fetch(type, &md_holder);
if (!NIL_P(data)) StringValue(data);
TypedData_Get_Struct(self, EVP_MD_CTX, &ossl_digest_type, ctx);
if (!ctx) {
- RTYPEDDATA_DATA(self) = ctx = EVP_MD_CTX_new();
- if (!ctx)
- ossl_raise(eDigestError, "EVP_MD_CTX_new");
+ RTYPEDDATA_DATA(self) = ctx = EVP_MD_CTX_new();
+ if (!ctx)
+ ossl_raise(eDigestError, "EVP_MD_CTX_new");
}
if (!EVP_DigestInit_ex(ctx, md, NULL))
- ossl_raise(eDigestError, "Digest initialization failed");
+ ossl_raise(eDigestError, "Digest initialization failed");
+ rb_ivar_set(self, id_md_holder, md_holder);
if (!NIL_P(data)) return ossl_digest_update(self, data);
return self;
}
+/* :nodoc: */
static VALUE
ossl_digest_copy(VALUE self, VALUE other)
{
@@ -150,18 +185,44 @@ ossl_digest_copy(VALUE self, VALUE other)
TypedData_Get_Struct(self, EVP_MD_CTX, &ossl_digest_type, ctx1);
if (!ctx1) {
- RTYPEDDATA_DATA(self) = ctx1 = EVP_MD_CTX_new();
- if (!ctx1)
- ossl_raise(eDigestError, "EVP_MD_CTX_new");
+ RTYPEDDATA_DATA(self) = ctx1 = EVP_MD_CTX_new();
+ if (!ctx1)
+ ossl_raise(eDigestError, "EVP_MD_CTX_new");
}
GetDigest(other, ctx2);
if (!EVP_MD_CTX_copy(ctx1, ctx2)) {
- ossl_raise(eDigestError, NULL);
+ ossl_raise(eDigestError, NULL);
}
return self;
}
+static void
+add_digest_name_to_ary(const OBJ_NAME *name, void *arg)
+{
+ VALUE ary = (VALUE)arg;
+ rb_ary_push(ary, rb_str_new2(name->name));
+}
+
+/*
+ * call-seq:
+ * OpenSSL::Digest.digests -> array[string...]
+ *
+ * Returns the names of all available digests in an array.
+ */
+static VALUE
+ossl_s_digests(VALUE self)
+{
+ VALUE ary;
+
+ ary = rb_ary_new();
+ OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH,
+ add_digest_name_to_ary,
+ (void*)ary);
+
+ return ary;
+}
+
/*
* call-seq:
* digest.reset -> self
@@ -177,7 +238,7 @@ ossl_digest_reset(VALUE self)
GetDigest(self, ctx);
if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_get0_md(ctx), NULL) != 1) {
- ossl_raise(eDigestError, "Digest initialization failed.");
+ ossl_raise(eDigestError, "Digest initialization failed.");
}
return self;
@@ -198,7 +259,7 @@ ossl_digest_reset(VALUE self)
* result = digest.digest
*
*/
-VALUE
+static VALUE
ossl_digest_update(VALUE self, VALUE data)
{
EVP_MD_CTX *ctx;
@@ -207,7 +268,7 @@ ossl_digest_update(VALUE self, VALUE data)
GetDigest(self, ctx);
if (!EVP_DigestUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data)))
- ossl_raise(eDigestError, "EVP_DigestUpdate");
+ ossl_raise(eDigestError, "EVP_DigestUpdate");
return self;
}
@@ -218,25 +279,15 @@ ossl_digest_update(VALUE self, VALUE data)
*
*/
static VALUE
-ossl_digest_finish(int argc, VALUE *argv, VALUE self)
+ossl_digest_finish(VALUE self)
{
EVP_MD_CTX *ctx;
VALUE str;
- int out_len;
GetDigest(self, ctx);
- rb_scan_args(argc, argv, "01", &str);
- out_len = EVP_MD_CTX_size(ctx);
-
- if (NIL_P(str)) {
- str = rb_str_new(NULL, out_len);
- } else {
- StringValue(str);
- rb_str_resize(str, out_len);
- }
-
+ str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
if (!EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL))
- ossl_raise(eDigestError, "EVP_DigestFinal_ex");
+ ossl_raise(eDigestError, "EVP_DigestFinal_ex");
return str;
}
@@ -245,7 +296,8 @@ ossl_digest_finish(int argc, VALUE *argv, VALUE self)
* call-seq:
* digest.name -> string
*
- * Returns the sn of this Digest algorithm.
+ * Returns the short name of this Digest algorithm which may differ slightly
+ * from the original name provided.
*
* === Example
* digest = OpenSSL::Digest.new('SHA512')
@@ -313,11 +365,6 @@ ossl_digest_block_length(VALUE self)
void
Init_ossl_digest(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/* Document-class: OpenSSL::Digest
*
* OpenSSL::Digest allows you to compute message digests (sometimes
@@ -412,14 +459,17 @@ Init_ossl_digest(void)
rb_define_alloc_func(cDigest, ossl_digest_alloc);
+ rb_define_module_function(cDigest, "digests", ossl_s_digests, 0);
rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
rb_define_method(cDigest, "initialize_copy", ossl_digest_copy, 1);
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_private_method(cDigest, "finish", ossl_digest_finish, -1);
+ rb_define_private_method(cDigest, "finish", ossl_digest_finish, 0);
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);
+
+ id_md_holder = rb_intern_const("EVP_MD_holder");
}
diff --git a/ext/openssl/ossl_digest.h b/ext/openssl/ossl_digest.h
index 50bf5666a3..9c3bb2b149 100644
--- a/ext/openssl/ossl_digest.h
+++ b/ext/openssl/ossl_digest.h
@@ -5,15 +5,20 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_DIGEST_H_)
#define _OSSL_DIGEST_H_
-extern VALUE cDigest;
-extern VALUE eDigestError;
-
-const EVP_MD *ossl_evp_get_digestbyname(VALUE);
+/*
+ * Gets EVP_MD from a String or an OpenSSL::Digest instance (discouraged, but
+ * still supported for compatibility). A holder object is created if the EVP_MD
+ * is a "fetched" algorithm.
+ */
+const EVP_MD *ossl_evp_md_fetch(VALUE obj, volatile VALUE *holder);
+/*
+ * This is meant for OpenSSL::Engine#digest. EVP_MD must not be a fetched one.
+ */
VALUE ossl_digest_new(const EVP_MD *);
void Init_ossl_digest(void);
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index 1abde7f766..a2bcb07ea4 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -16,7 +16,7 @@
TypedData_Wrap_Struct((klass), &ossl_engine_type, 0)
#define SetEngine(obj, engine) do { \
if (!(engine)) { \
- ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (engine); \
} while(0)
@@ -37,35 +37,25 @@
*
* See also, https://www.openssl.org/docs/crypto/engine.html
*/
-VALUE cEngine;
+static VALUE cEngine;
/* Document-class: OpenSSL::Engine::EngineError
*
* This is the generic exception for OpenSSL::Engine related errors
*/
-VALUE eEngineError;
+static VALUE eEngineError;
/*
* Private
*/
-#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
do{\
- if(!strcmp(#engine_name, RSTRING_PTR(name))){\
- if (OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_##x, NULL))\
- return Qtrue;\
- else\
- ossl_raise(eEngineError, "OPENSSL_init_crypto"); \
- }\
-}while(0)
-#else
-#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
-do{\
- if(!strcmp(#engine_name, RSTRING_PTR(name))){\
- ENGINE_load_##engine_name();\
- return Qtrue;\
- }\
+ if(!strcmp(#engine_name, RSTRING_PTR(name))){\
+ if (OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_##x, NULL))\
+ return Qtrue;\
+ else\
+ ossl_raise(eEngineError, "OPENSSL_init_crypto"); \
+ }\
}while(0)
-#endif
static void
ossl_engine_free(void *engine)
@@ -76,9 +66,9 @@ ossl_engine_free(void *engine)
static const rb_data_type_t ossl_engine_type = {
"OpenSSL/Engine",
{
- 0, ossl_engine_free,
+ 0, ossl_engine_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -102,50 +92,10 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
return Qtrue;
}
StringValueCStr(name);
-#ifdef HAVE_ENGINE_LOAD_DYNAMIC
OSSL_ENGINE_LOAD_IF_MATCH(dynamic, DYNAMIC);
-#endif
-#ifndef OPENSSL_NO_STATIC_ENGINE
-#ifdef HAVE_ENGINE_LOAD_4758CCA
- OSSL_ENGINE_LOAD_IF_MATCH(4758cca, 4758CCA);
-#endif
-#ifdef HAVE_ENGINE_LOAD_AEP
- OSSL_ENGINE_LOAD_IF_MATCH(aep, AEP);
-#endif
-#ifdef HAVE_ENGINE_LOAD_ATALLA
- OSSL_ENGINE_LOAD_IF_MATCH(atalla, ATALLA);
-#endif
-#ifdef HAVE_ENGINE_LOAD_CHIL
- OSSL_ENGINE_LOAD_IF_MATCH(chil, CHIL);
-#endif
-#ifdef HAVE_ENGINE_LOAD_CSWIFT
- OSSL_ENGINE_LOAD_IF_MATCH(cswift, CSWIFT);
-#endif
-#ifdef HAVE_ENGINE_LOAD_NURON
- OSSL_ENGINE_LOAD_IF_MATCH(nuron, NURON);
-#endif
-#ifdef HAVE_ENGINE_LOAD_SUREWARE
- OSSL_ENGINE_LOAD_IF_MATCH(sureware, SUREWARE);
-#endif
-#ifdef HAVE_ENGINE_LOAD_UBSEC
- OSSL_ENGINE_LOAD_IF_MATCH(ubsec, UBSEC);
-#endif
-#ifdef HAVE_ENGINE_LOAD_PADLOCK
OSSL_ENGINE_LOAD_IF_MATCH(padlock, PADLOCK);
-#endif
-#ifdef HAVE_ENGINE_LOAD_CAPI
OSSL_ENGINE_LOAD_IF_MATCH(capi, CAPI);
-#endif
-#ifdef HAVE_ENGINE_LOAD_GMP
- OSSL_ENGINE_LOAD_IF_MATCH(gmp, GMP);
-#endif
-#ifdef HAVE_ENGINE_LOAD_GOST
- OSSL_ENGINE_LOAD_IF_MATCH(gost, GOST);
-#endif
-#endif
-#ifdef HAVE_ENGINE_LOAD_CRYPTODEV
OSSL_ENGINE_LOAD_IF_MATCH(cryptodev, CRYPTODEV);
-#endif
OSSL_ENGINE_LOAD_IF_MATCH(openssl, OPENSSL);
rb_warning("no such builtin loader for `%"PRIsVALUE"'", name);
return Qnil;
@@ -163,9 +113,6 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
static VALUE
ossl_engine_s_cleanup(VALUE self)
{
-#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000
- ENGINE_cleanup();
-#endif
return Qnil;
}
@@ -183,12 +130,12 @@ ossl_engine_s_engines(VALUE klass)
ary = rb_ary_new();
for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
- obj = NewEngine(klass);
- /* Need a ref count of two here because of ENGINE_free being
- * called internally by OpenSSL when moving to the next ENGINE
- * and by us when releasing the ENGINE reference */
- ENGINE_up_ref(e);
- SetEngine(obj, e);
+ obj = NewEngine(klass);
+ /* Need a ref count of two here because of ENGINE_free being
+ * called internally by OpenSSL when moving to the next ENGINE
+ * and by us when releasing the ENGINE reference */
+ ENGINE_up_ref(e);
+ SetEngine(obj, e);
rb_ary_push(ary, obj);
}
@@ -216,13 +163,13 @@ ossl_engine_s_by_id(VALUE klass, VALUE id)
ossl_engine_s_load(1, &id, klass);
obj = NewEngine(klass);
if(!(e = ENGINE_by_id(RSTRING_PTR(id))))
- ossl_raise(eEngineError, NULL);
+ ossl_raise(eEngineError, NULL);
SetEngine(obj, e);
if(rb_block_given_p()) rb_yield(obj);
if(!ENGINE_init(e))
- ossl_raise(eEngineError, NULL);
+ ossl_raise(eEngineError, NULL);
ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK,
- 0, NULL, (void(*)(void))ossl_pem_passwd_cb);
+ 0, NULL, (void(*)(void))ossl_pem_passwd_cb);
ossl_clear_error();
return obj;
@@ -237,7 +184,7 @@ ossl_engine_s_by_id(VALUE klass, VALUE id)
* OpenSSL::Engine.load
* OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
* OpenSSL::Engine.engines.first.id
- * #=> "rsax"
+ * #=> "rsax"
*/
static VALUE
ossl_engine_get_id(VALUE self)
@@ -256,7 +203,7 @@ ossl_engine_get_id(VALUE self)
* OpenSSL::Engine.load
* OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
* OpenSSL::Engine.engines.first.name
- * #=> "RSAX engine support"
+ * #=> "RSAX engine support"
*
*/
static VALUE
@@ -327,11 +274,11 @@ ossl_engine_get_cipher(VALUE self, VALUE name)
* Will raise an EngineError if the digest is unavailable.
*
* e = OpenSSL::Engine.by_id("openssl")
- * #=> #<OpenSSL::Engine id="openssl" name="Software engine support">
+ * #=> #<OpenSSL::Engine id="openssl" name="Software engine support">
* e.digest("SHA1")
- * #=> #<OpenSSL::Digest: da39a3ee5e6b4b0d3255bfef95601890afd80709>
+ * #=> #<OpenSSL::Digest: da39a3ee5e6b4b0d3255bfef95601890afd80709>
* e.digest("zomg")
- * #=> OpenSSL::Engine::EngineError: no such digest `zomg'
+ * #=> OpenSSL::Engine::EngineError: no such digest `zomg'
*/
static VALUE
ossl_engine_get_digest(VALUE self, VALUE name)
@@ -373,7 +320,7 @@ ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self)
GetEngine(self, e);
pkey = ENGINE_load_private_key(e, sid, NULL, sdata);
if (!pkey) ossl_raise(eEngineError, NULL);
- obj = ossl_pkey_new(pkey);
+ obj = ossl_pkey_wrap(pkey);
OSSL_PKEY_SET_PRIVATE(obj);
return obj;
@@ -403,7 +350,7 @@ ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
pkey = ENGINE_load_public_key(e, sid, NULL, sdata);
if (!pkey) ossl_raise(eEngineError, NULL);
- return ossl_pkey_new(pkey);
+ return ossl_pkey_wrap(pkey);
}
/*
@@ -418,7 +365,7 @@ ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
* your OS.
*
* [All flags] 0xFFFF
- * [No flags] 0x0000
+ * [No flags] 0x0000
*
* See also <openssl/engine.h>
*/
@@ -452,7 +399,7 @@ ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self)
GetEngine(self, e);
rb_scan_args(argc, argv, "11", &cmd, &val);
ret = ENGINE_ctrl_cmd_string(e, StringValueCStr(cmd),
- NIL_P(val) ? NULL : StringValueCStr(val), 0);
+ NIL_P(val) ? NULL : StringValueCStr(val), 0);
if (!ret) ossl_raise(eEngineError, NULL);
return self;
@@ -462,11 +409,11 @@ static VALUE
ossl_engine_cmd_flag_to_name(int flag)
{
switch(flag){
- case ENGINE_CMD_FLAG_NUMERIC: return rb_str_new2("NUMERIC");
- case ENGINE_CMD_FLAG_STRING: return rb_str_new2("STRING");
- case ENGINE_CMD_FLAG_NO_INPUT: return rb_str_new2("NO_INPUT");
- case ENGINE_CMD_FLAG_INTERNAL: return rb_str_new2("INTERNAL");
- default: return rb_str_new2("UNKNOWN");
+ case ENGINE_CMD_FLAG_NUMERIC: return rb_str_new2("NUMERIC");
+ case ENGINE_CMD_FLAG_STRING: return rb_str_new2("STRING");
+ case ENGINE_CMD_FLAG_NO_INPUT: return rb_str_new2("NO_INPUT");
+ case ENGINE_CMD_FLAG_INTERNAL: return rb_str_new2("INTERNAL");
+ default: return rb_str_new2("UNKNOWN");
}
}
@@ -486,13 +433,13 @@ ossl_engine_get_cmds(VALUE self)
GetEngine(self, e);
ary = rb_ary_new();
if ((defn = ENGINE_get_cmd_defns(e)) != NULL){
- for (p = defn; p->cmd_num > 0; p++){
- tmp = rb_ary_new();
- rb_ary_push(tmp, rb_str_new2(p->cmd_name));
- rb_ary_push(tmp, rb_str_new2(p->cmd_desc));
- rb_ary_push(tmp, ossl_engine_cmd_flag_to_name(p->cmd_flags));
- rb_ary_push(ary, tmp);
- }
+ for (p = defn; p->cmd_num > 0; p++){
+ tmp = rb_ary_new();
+ rb_ary_push(tmp, rb_str_new2(p->cmd_name));
+ rb_ary_push(tmp, rb_str_new2(p->cmd_desc));
+ rb_ary_push(tmp, ossl_engine_cmd_flag_to_name(p->cmd_flags));
+ rb_ary_push(ary, tmp);
+ }
}
return ary;
@@ -511,7 +458,7 @@ ossl_engine_inspect(VALUE self)
GetEngine(self, e);
return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">",
- rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e));
+ rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e));
}
#define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x))
@@ -519,11 +466,6 @@ ossl_engine_inspect(VALUE self)
void
Init_ossl_engine(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);
@@ -549,12 +491,6 @@ Init_ossl_engine(void)
DefEngineConst(METHOD_DSA);
DefEngineConst(METHOD_DH);
DefEngineConst(METHOD_RAND);
-#ifdef ENGINE_METHOD_BN_MOD_EXP
- DefEngineConst(METHOD_BN_MOD_EXP);
-#endif
-#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
- DefEngineConst(METHOD_BN_MOD_EXP_CRT);
-#endif
DefEngineConst(METHOD_CIPHERS);
DefEngineConst(METHOD_DIGESTS);
DefEngineConst(METHOD_ALL);
diff --git a/ext/openssl/ossl_engine.h b/ext/openssl/ossl_engine.h
index cd548beea3..cedcebb772 100644
--- a/ext/openssl/ossl_engine.h
+++ b/ext/openssl/ossl_engine.h
@@ -6,14 +6,11 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(OSSL_ENGINE_H)
#define OSSL_ENGINE_H
-extern VALUE cEngine;
-extern VALUE eEngineError;
-
void Init_ossl_engine(void);
#endif /* OSSL_ENGINE_H */
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index 1a5f471a27..ddcc6a5f8d 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -14,15 +14,16 @@
#define GetHMAC(obj, ctx) do { \
TypedData_Get_Struct((obj), EVP_MD_CTX, &ossl_hmac_type, (ctx)); \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
+ ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
} \
} while (0)
/*
* Classes
*/
-VALUE cHMAC;
-VALUE eHMACError;
+static VALUE cHMAC;
+static VALUE eHMACError;
+static ID id_md_holder;
/*
* Public
@@ -40,9 +41,9 @@ ossl_hmac_free(void *ctx)
static const rb_data_type_t ossl_hmac_type = {
"OpenSSL/HMAC",
{
- 0, ossl_hmac_free,
+ 0, ossl_hmac_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -73,17 +74,17 @@ ossl_hmac_alloc(VALUE klass)
*
* === Example
*
- * key = 'key'
- * instance = OpenSSL::HMAC.new(key, 'SHA1')
- * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
- * instance.class
- * #=> OpenSSL::HMAC
+ * key = 'key'
+ * instance = OpenSSL::HMAC.new(key, 'SHA1')
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance.class
+ * #=> OpenSSL::HMAC
*
* === A note about comparisons
*
* Two instances can be securely compared with #== in constant time:
*
- * other_instance = OpenSSL::HMAC.new('key', 'SHA1')
+ * other_instance = OpenSSL::HMAC.new('key', 'SHA1')
* #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
* instance == other_instance
* #=> true
@@ -94,33 +95,29 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
{
EVP_MD_CTX *ctx;
EVP_PKEY *pkey;
+ const EVP_MD *md;
+ VALUE md_holder;
GetHMAC(self, ctx);
StringValue(key);
-#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+ md = ossl_evp_md_fetch(digest, &md_holder);
pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL,
(unsigned char *)RSTRING_PTR(key),
RSTRING_LENINT(key));
if (!pkey)
ossl_raise(eHMACError, "EVP_PKEY_new_raw_private_key");
-#else
- pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL,
- (unsigned char *)RSTRING_PTR(key),
- RSTRING_LENINT(key));
- if (!pkey)
- ossl_raise(eHMACError, "EVP_PKEY_new_mac_key");
-#endif
- if (EVP_DigestSignInit(ctx, NULL, ossl_evp_get_digestbyname(digest),
- NULL, pkey) != 1) {
+ if (EVP_DigestSignInit(ctx, NULL, md, NULL, pkey) != 1) {
EVP_PKEY_free(pkey);
ossl_raise(eHMACError, "EVP_DigestSignInit");
}
+ rb_ivar_set(self, id_md_holder, md_holder);
/* Decrement reference counter; EVP_MD_CTX still keeps it */
EVP_PKEY_free(pkey);
return self;
}
+/* :nodoc: */
static VALUE
ossl_hmac_copy(VALUE self, VALUE other)
{
@@ -145,13 +142,13 @@ ossl_hmac_copy(VALUE self, VALUE other)
*
* === Example
*
- * first_chunk = 'The quick brown fox jumps '
- * second_chunk = 'over the lazy dog'
+ * first_chunk = 'The quick brown fox jumps '
+ * second_chunk = 'over the lazy dog'
*
- * instance.update(first_chunk)
- * #=> 5b9a8038a65d571076d97fe783989e52278a492a
- * instance.update(second_chunk)
- * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
+ * instance.update(first_chunk)
+ * #=> 5b9a8038a65d571076d97fe783989e52278a492a
+ * instance.update(second_chunk)
+ * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
*
*/
static VALUE
@@ -229,14 +226,14 @@ ossl_hmac_hexdigest(VALUE self)
*
* === Example
*
- * data = "The quick brown fox jumps over the lazy dog"
- * instance = OpenSSL::HMAC.new('key', 'SHA1')
- * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * data = "The quick brown fox jumps over the lazy dog"
+ * instance = OpenSSL::HMAC.new('key', 'SHA1')
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
*
- * instance.update(data)
- * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
- * instance.reset
- * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance.update(data)
+ * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
+ * instance.reset
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
*
*/
static VALUE
@@ -259,11 +256,6 @@ ossl_hmac_reset(VALUE self)
void
Init_ossl_hmac(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/*
* Document-class: OpenSSL::HMAC
*
@@ -307,4 +299,6 @@ Init_ossl_hmac(void)
rb_define_method(cHMAC, "hexdigest", ossl_hmac_hexdigest, 0);
rb_define_alias(cHMAC, "inspect", "hexdigest");
rb_define_alias(cHMAC, "to_s", "hexdigest");
+
+ id_md_holder = rb_intern_const("EVP_MD_holder");
}
diff --git a/ext/openssl/ossl_hmac.h b/ext/openssl/ossl_hmac.h
index 7c51f4722d..e5bed37c9f 100644
--- a/ext/openssl/ossl_hmac.h
+++ b/ext/openssl/ossl_hmac.h
@@ -5,14 +5,11 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_HMAC_H_)
#define _OSSL_HMAC_H_
-extern VALUE cHMAC;
-extern VALUE eHMACError;
-
void Init_ossl_hmac(void);
#endif /* _OSSL_HMAC_H_ */
diff --git a/ext/openssl/ossl_kdf.c b/ext/openssl/ossl_kdf.c
index 0d25a7304b..99a3589b39 100644
--- a/ext/openssl/ossl_kdf.c
+++ b/ext/openssl/ossl_kdf.c
@@ -3,12 +3,31 @@
* Copyright (C) 2007, 2017 Ruby/OpenSSL Project Authors
*/
#include "ossl.h"
-#if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
-# include <openssl/kdf.h>
-#endif
+#include <openssl/kdf.h>
static VALUE mKDF, eKDF;
+struct pbkdf2_hmac_args {
+ char *pass;
+ int passlen;
+ unsigned char *salt;
+ int saltlen;
+ int iters;
+ const EVP_MD *md;
+ int len;
+ unsigned char *out;
+};
+
+static void *
+pbkdf2_hmac_nogvl(void *args_)
+{
+ struct pbkdf2_hmac_args *args = (struct pbkdf2_hmac_args *)args_;
+ int ret = PKCS5_PBKDF2_HMAC(args->pass, args->passlen, args->salt,
+ args->saltlen, args->iters, args->md,
+ args->len, args->out);
+ return (void *)(uintptr_t)ret;
+}
+
/*
* call-seq:
* KDF.pbkdf2_hmac(pass, salt:, iterations:, length:, hash:) -> aString
@@ -18,10 +37,14 @@ static VALUE mKDF, eKDF;
* of _length_ bytes.
*
* For more information about PBKDF2, see RFC 2898 Section 5.2
- * (https://tools.ietf.org/html/rfc2898#section-5.2).
+ * (https://www.rfc-editor.org/rfc/rfc2898#section-5.2).
+ *
+ * *NOTE*: This method cannot be interrupted by Timeout.timeout from the
+ * "timeout" library. Do not take parameters from untrusted sources without
+ * enforcing reasonable limits.
*
* === Parameters
- * pass :: The passphrase.
+ * pass :: The password.
* salt :: The salt. Salts prevent attacks based on dictionaries of common
* passwords and attacks based on rainbow tables. It is a public
* value that can be safely stored along with the password (e.g.
@@ -37,16 +60,16 @@ static VALUE mKDF, eKDF;
static VALUE
kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
{
- VALUE pass, salt, opts, kwargs[4], str;
+ VALUE pass, salt, opts, kwargs[4], str, md_holder, pass_tmp, salt_tmp;
static ID kwargs_ids[4];
- int iters, len;
+ int passlen, saltlen, iters, len;
const EVP_MD *md;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("salt");
- kwargs_ids[1] = rb_intern_const("iterations");
- kwargs_ids[2] = rb_intern_const("length");
- kwargs_ids[3] = rb_intern_const("hash");
+ kwargs_ids[0] = rb_intern_const("salt");
+ kwargs_ids[1] = rb_intern_const("iterations");
+ kwargs_ids[2] = rb_intern_const("length");
+ kwargs_ids[3] = rb_intern_const("hash");
}
rb_scan_args(argc, argv, "1:", &pass, &opts);
rb_get_kwargs(opts, kwargs_ids, 4, 0, kwargs);
@@ -55,19 +78,57 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
salt = StringValue(kwargs[0]);
iters = NUM2INT(kwargs[1]);
len = NUM2INT(kwargs[2]);
- md = ossl_evp_get_digestbyname(kwargs[3]);
-
- str = rb_str_new(0, len);
- if (!PKCS5_PBKDF2_HMAC(RSTRING_PTR(pass), RSTRING_LENINT(pass),
- (unsigned char *)RSTRING_PTR(salt),
- RSTRING_LENINT(salt), iters, md, len,
- (unsigned char *)RSTRING_PTR(str)))
- ossl_raise(eKDF, "PKCS5_PBKDF2_HMAC");
-
+ md = ossl_evp_md_fetch(kwargs[3], &md_holder);
+ passlen = RSTRING_LENINT(pass);
+ saltlen = RSTRING_LENINT(salt);
+ str = rb_str_new(NULL, len);
+ struct pbkdf2_hmac_args args = {
+ .pass = ALLOCV(pass_tmp, passlen),
+ .passlen = passlen,
+ .salt = ALLOCV(salt_tmp, saltlen),
+ .saltlen = saltlen,
+ .iters = iters,
+ .md = md,
+ .len = len,
+ .out = (unsigned char *)RSTRING_PTR(str),
+ };
+ memcpy(args.pass, RSTRING_PTR(pass), passlen);
+ memcpy(args.salt, RSTRING_PTR(salt), saltlen);
+ if (!rb_thread_call_without_gvl(pbkdf2_hmac_nogvl, &args, NULL, NULL))
+ ossl_raise(eKDF, "PKCS5_PBKDF2_HMAC");
+ OPENSSL_cleanse(args.pass, passlen);
+ ALLOCV_END(pass_tmp);
+ ALLOCV_END(salt_tmp);
return str;
}
#if defined(HAVE_EVP_PBE_SCRYPT)
+struct scrypt_args {
+ char *pass;
+ size_t passlen;
+ unsigned char *salt;
+ size_t saltlen;
+ uint64_t N, r, p;
+ size_t len;
+ unsigned char *out;
+};
+
+static void *
+scrypt_nogvl(void *args_)
+{
+ struct scrypt_args *args = (struct scrypt_args *)args_;
+ /*
+ * OpenSSL uses 32MB by default (if zero is specified), which is too
+ * small. Let's not limit memory consumption but just let malloc() fail
+ * inside OpenSSL. The amount is controllable by other parameters.
+ */
+ uint64_t maxmem = UINT64_MAX;
+ int ret = EVP_PBE_scrypt(args->pass, args->passlen,
+ args->salt, args->saltlen, args->N, args->r,
+ args->p, maxmem, args->out, args->len);
+ return (void *)(uintptr_t)ret;
+}
+
/*
* call-seq:
* KDF.scrypt(pass, salt:, N:, r:, p:, length:) -> aString
@@ -81,10 +142,14 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
* bcrypt.
*
* The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914
- * (published on 2016-08, https://tools.ietf.org/html/rfc7914#section-2) states
+ * (published on 2016-08, https://www.rfc-editor.org/rfc/rfc7914#section-2) states
* that using values r=8 and p=1 appears to yield good results.
*
- * See RFC 7914 (https://tools.ietf.org/html/rfc7914) for more information.
+ * See RFC 7914 (https://www.rfc-editor.org/rfc/rfc7914) for more information.
+ *
+ * *NOTE*: This method cannot be interrupted by Timeout.timeout from the
+ * "timeout" library. Do not take parameters from untrusted sources without
+ * enforcing reasonable limits.
*
* === Parameters
* pass :: Passphrase.
@@ -103,17 +168,18 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
static VALUE
kdf_scrypt(int argc, VALUE *argv, VALUE self)
{
- VALUE pass, salt, opts, kwargs[5], str;
+ VALUE pass, salt, opts, kwargs[5], str, pass_tmp, salt_tmp;
static ID kwargs_ids[5];
- size_t len;
- uint64_t N, r, p, maxmem;
+ size_t passlen, saltlen;
+ long len;
+ uint64_t N, r, p;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("salt");
- kwargs_ids[1] = rb_intern_const("N");
- kwargs_ids[2] = rb_intern_const("r");
- kwargs_ids[3] = rb_intern_const("p");
- kwargs_ids[4] = rb_intern_const("length");
+ kwargs_ids[0] = rb_intern_const("salt");
+ kwargs_ids[1] = rb_intern_const("N");
+ kwargs_ids[2] = rb_intern_const("r");
+ kwargs_ids[3] = rb_intern_const("p");
+ kwargs_ids[4] = rb_intern_const("length");
}
rb_scan_args(argc, argv, "1:", &pass, &opts);
rb_get_kwargs(opts, kwargs_ids, 5, 0, kwargs);
@@ -124,30 +190,37 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
r = NUM2UINT64T(kwargs[2]);
p = NUM2UINT64T(kwargs[3]);
len = NUM2LONG(kwargs[4]);
- /*
- * OpenSSL uses 32MB by default (if zero is specified), which is too small.
- * Let's not limit memory consumption but just let malloc() fail inside
- * OpenSSL. The amount is controllable by other parameters.
- */
- maxmem = SIZE_MAX;
-
- str = rb_str_new(0, len);
- if (!EVP_PBE_scrypt(RSTRING_PTR(pass), RSTRING_LEN(pass),
- (unsigned char *)RSTRING_PTR(salt), RSTRING_LEN(salt),
- N, r, p, maxmem, (unsigned char *)RSTRING_PTR(str), len))
- ossl_raise(eKDF, "EVP_PBE_scrypt");
-
+ passlen = RSTRING_LEN(pass);
+ saltlen = RSTRING_LEN(salt);
+ str = rb_str_new(NULL, len);
+ struct scrypt_args args = {
+ .pass = ALLOCV(pass_tmp, passlen),
+ .passlen = passlen,
+ .salt = ALLOCV(salt_tmp, saltlen),
+ .saltlen = saltlen,
+ .N = N,
+ .r = r,
+ .p = p,
+ .len = len,
+ .out = (unsigned char *)RSTRING_PTR(str),
+ };
+ memcpy(args.pass, RSTRING_PTR(pass), passlen);
+ memcpy(args.salt, RSTRING_PTR(salt), saltlen);
+ if (!rb_thread_call_without_gvl(scrypt_nogvl, &args, NULL, NULL))
+ ossl_raise(eKDF, "EVP_PBE_scrypt");
+ OPENSSL_cleanse(args.pass, passlen);
+ ALLOCV_END(pass_tmp);
+ ALLOCV_END(salt_tmp);
return str;
}
#endif
-#if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
/*
* call-seq:
* KDF.hkdf(ikm, salt:, info:, length:, hash:) -> String
*
* HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in
- * {RFC 5869}[https://tools.ietf.org/html/rfc5869].
+ * {RFC 5869}[https://www.rfc-editor.org/rfc/rfc5869].
*
* New in OpenSSL 1.1.0.
*
@@ -165,7 +238,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
* The hash function.
*
* === Example
- * # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1
+ * # The values from https://www.rfc-editor.org/rfc/rfc5869#appendix-A.1
* ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*")
* salt = ["000102030405060708090a0b0c"].pack("H*")
* info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*")
@@ -175,7 +248,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self)
static VALUE
kdf_hkdf(int argc, VALUE *argv, VALUE self)
{
- VALUE ikm, salt, info, opts, kwargs[4], str;
+ VALUE ikm, salt, info, opts, kwargs[4], str, md_holder;
static ID kwargs_ids[4];
int saltlen, ikmlen, infolen;
size_t len;
@@ -183,10 +256,10 @@ kdf_hkdf(int argc, VALUE *argv, VALUE self)
EVP_PKEY_CTX *pctx;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("salt");
- kwargs_ids[1] = rb_intern_const("info");
- kwargs_ids[2] = rb_intern_const("length");
- kwargs_ids[3] = rb_intern_const("hash");
+ kwargs_ids[0] = rb_intern_const("salt");
+ kwargs_ids[1] = rb_intern_const("info");
+ kwargs_ids[2] = rb_intern_const("length");
+ kwargs_ids[3] = rb_intern_const("hash");
}
rb_scan_args(argc, argv, "1:", &ikm, &opts);
rb_get_kwargs(opts, kwargs_ids, 4, 0, kwargs);
@@ -199,55 +272,49 @@ kdf_hkdf(int argc, VALUE *argv, VALUE self)
infolen = RSTRING_LENINT(info);
len = (size_t)NUM2LONG(kwargs[2]);
if (len > LONG_MAX)
- rb_raise(rb_eArgError, "length must be non-negative");
- md = ossl_evp_get_digestbyname(kwargs[3]);
+ rb_raise(rb_eArgError, "length must be non-negative");
+ md = ossl_evp_md_fetch(kwargs[3], &md_holder);
str = rb_str_new(NULL, (long)len);
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
if (!pctx)
- ossl_raise(eKDF, "EVP_PKEY_CTX_new_id");
+ ossl_raise(eKDF, "EVP_PKEY_CTX_new_id");
if (EVP_PKEY_derive_init(pctx) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_derive_init");
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_derive_init");
}
if (EVP_PKEY_CTX_set_hkdf_md(pctx, md) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_md");
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_md");
}
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, (unsigned char *)RSTRING_PTR(salt),
- saltlen) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_salt");
+ saltlen) <= 0) {
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_salt");
}
if (EVP_PKEY_CTX_set1_hkdf_key(pctx, (unsigned char *)RSTRING_PTR(ikm),
- ikmlen) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_key");
+ ikmlen) <= 0) {
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_key");
}
if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (unsigned char *)RSTRING_PTR(info),
- infolen) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_info");
+ infolen) <= 0) {
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_info");
}
if (EVP_PKEY_derive(pctx, (unsigned char *)RSTRING_PTR(str), &len) <= 0) {
- EVP_PKEY_CTX_free(pctx);
- ossl_raise(eKDF, "EVP_PKEY_derive");
+ EVP_PKEY_CTX_free(pctx);
+ ossl_raise(eKDF, "EVP_PKEY_derive");
}
rb_str_set_len(str, (long)len);
EVP_PKEY_CTX_free(pctx);
return str;
}
-#endif
void
Init_ossl_kdf(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/*
* Document-module: OpenSSL::KDF
*
@@ -305,7 +372,5 @@ Init_ossl_kdf(void)
#if defined(HAVE_EVP_PBE_SCRYPT)
rb_define_module_function(mKDF, "scrypt", kdf_scrypt, -1);
#endif
-#if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 6, 0)
rb_define_module_function(mKDF, "hkdf", kdf_hkdf, -1);
-#endif
}
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
index 9b1147367a..8440c2ee82 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,23 +13,23 @@
TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, 0)
#define SetSPKI(obj, spki) do { \
if (!(spki)) { \
- ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (spki); \
} while (0)
#define GetSPKI(obj, spki) do { \
TypedData_Get_Struct((obj), NETSCAPE_SPKI, &ossl_netscape_spki_type, (spki)); \
if (!(spki)) { \
- ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
} \
} while (0)
/*
* Classes
*/
-VALUE mNetscape;
-VALUE cSPKI;
-VALUE eSPKIError;
+static VALUE mNetscape;
+static VALUE cSPKI;
+static VALUE eSPKIError;
/*
* Public functions
@@ -48,9 +48,9 @@ ossl_netscape_spki_free(void *spki)
static const rb_data_type_t ossl_netscape_spki_type = {
"OpenSSL/NETSCAPE_SPKI",
{
- 0, ossl_netscape_spki_free,
+ 0, ossl_netscape_spki_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -61,7 +61,7 @@ ossl_spki_alloc(VALUE klass)
obj = NewSPKI(klass);
if (!(spki = NETSCAPE_SPKI_new())) {
- ossl_raise(eSPKIError, NULL);
+ ossl_raise(eSPKIError, NULL);
}
SetSPKI(obj, spki);
@@ -83,15 +83,15 @@ ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
const unsigned char *p;
if (rb_scan_args(argc, argv, "01", &buffer) == 0) {
- return self;
+ return self;
}
StringValue(buffer);
if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING_PTR(buffer), RSTRING_LENINT(buffer)))) {
- ossl_clear_error();
- p = (unsigned char *)RSTRING_PTR(buffer);
- if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING_LEN(buffer)))) {
- ossl_raise(eSPKIError, NULL);
- }
+ ossl_clear_error();
+ p = (unsigned char *)RSTRING_PTR(buffer);
+ if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING_LEN(buffer)))) {
+ ossl_raise(eSPKIError, NULL);
+ }
}
NETSCAPE_SPKI_free(DATA_PTR(self));
SetSPKI(self, spki);
@@ -115,11 +115,11 @@ ossl_spki_to_der(VALUE self)
GetSPKI(self, spki);
if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
ossl_str_adjust(str, p);
return str;
@@ -140,7 +140,7 @@ ossl_spki_to_pem(VALUE self)
GetSPKI(self, spki);
if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
- ossl_raise(eSPKIError, NULL);
+ ossl_raise(eSPKIError, NULL);
}
str = ossl_buf2str(data, rb_long2int(strlen(data)));
@@ -162,11 +162,11 @@ ossl_spki_print(VALUE self)
GetSPKI(self, spki);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eSPKIError, NULL);
+ ossl_raise(eSPKIError, NULL);
}
if (!NETSCAPE_SPKI_print(out, spki)) {
- BIO_free(out);
- ossl_raise(eSPKIError, NULL);
+ BIO_free(out);
+ ossl_raise(eSPKIError, NULL);
}
return ossl_membio2str(out);
@@ -187,10 +187,10 @@ ossl_spki_get_public_key(VALUE self)
GetSPKI(self, spki);
if (!(pkey = NETSCAPE_SPKI_get_pubkey(spki))) { /* adds an reference */
- ossl_raise(eSPKIError, NULL);
+ ossl_raise(eSPKIError, NULL);
}
- return ossl_pkey_new(pkey); /* NO DUP - OK */
+ return ossl_pkey_wrap(pkey);
}
/*
@@ -214,7 +214,7 @@ ossl_spki_set_public_key(VALUE self, VALUE key)
pkey = GetPKeyPtr(key);
ossl_pkey_check_public_key(pkey);
if (!NETSCAPE_SPKI_set_pubkey(spki, pkey))
- ossl_raise(eSPKIError, "NETSCAPE_SPKI_set_pubkey");
+ ossl_raise(eSPKIError, "NETSCAPE_SPKI_set_pubkey");
return key;
}
@@ -230,13 +230,12 @@ ossl_spki_get_challenge(VALUE self)
NETSCAPE_SPKI *spki;
GetSPKI(self, spki);
- if (spki->spkac->challenge->length <= 0) {
- OSSL_Debug("Challenge.length <= 0?");
- return rb_str_new(0, 0);
+ if (ASN1_STRING_length(spki->spkac->challenge) <= 0) {
+ OSSL_Debug("Challenge.length <= 0?");
+ return rb_str_new(0, 0);
}
- return rb_str_new((const char *)spki->spkac->challenge->data,
- spki->spkac->challenge->length);
+ return asn1str_to_str(spki->spkac->challenge);
}
/*
@@ -257,8 +256,8 @@ ossl_spki_set_challenge(VALUE self, VALUE str)
StringValue(str);
GetSPKI(self, spki);
if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str),
- RSTRING_LENINT(str))) {
- ossl_raise(eSPKIError, NULL);
+ RSTRING_LENINT(str))) {
+ ossl_raise(eSPKIError, NULL);
}
return str;
@@ -283,13 +282,13 @@ ossl_spki_sign(VALUE self, VALUE key, VALUE digest)
NETSCAPE_SPKI *spki;
EVP_PKEY *pkey;
const EVP_MD *md;
+ VALUE md_holder;
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
GetSPKI(self, spki);
- if (!NETSCAPE_SPKI_sign(spki, pkey, md)) {
- ossl_raise(eSPKIError, NULL);
- }
+ if (!NETSCAPE_SPKI_sign(spki, pkey, md))
+ ossl_raise(eSPKIError, "NETSCAPE_SPKI_sign");
return self;
}
@@ -315,12 +314,12 @@ ossl_spki_verify(VALUE self, VALUE key)
ossl_pkey_check_public_key(pkey);
switch (NETSCAPE_SPKI_verify(spki, pkey)) {
case 0:
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
case 1:
- return Qtrue;
+ return Qtrue;
default:
- ossl_raise(eSPKIError, "NETSCAPE_SPKI_verify");
+ ossl_raise(eSPKIError, "NETSCAPE_SPKI_verify");
}
}
@@ -365,8 +364,8 @@ ossl_spki_verify(VALUE self, VALUE key)
*
* OpenSSL::Netscape is a namespace for SPKI (Simple Public Key
* Infrastructure) which implements Signed Public Key and Challenge.
- * See {RFC 2692}[http://tools.ietf.org/html/rfc2692] and {RFC
- * 2693}[http://tools.ietf.org/html/rfc2692] for details.
+ * See {RFC 2692}[https://www.rfc-editor.org/rfc/rfc2692] and {RFC
+ * 2693}[https://www.rfc-editor.org/rfc/rfc2692] for details.
*/
/* Document-class: OpenSSL::Netscape::SPKIError
@@ -378,11 +377,6 @@ ossl_spki_verify(VALUE self, VALUE key)
void
Init_ossl_ns_spki(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
mNetscape = rb_define_module_under(mOSSL, "Netscape");
eSPKIError = rb_define_class_under(mNetscape, "SPKIError", eOSSLError);
diff --git a/ext/openssl/ossl_ns_spki.h b/ext/openssl/ossl_ns_spki.h
index 62ba8cb163..043b6cdb66 100644
--- a/ext/openssl/ossl_ns_spki.h
+++ b/ext/openssl/ossl_ns_spki.h
@@ -5,15 +5,11 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_NS_SPKI_H_)
#define _OSSL_NS_SPKI_H_
-extern VALUE mNetscape;
-extern VALUE cSPKI;
-extern VALUE eSPKIError;
-
void Init_ossl_ns_spki(void);
#endif /* _OSSL_NS_SPKI_H_ */
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c
index 9c8d768d87..9dd4b466d2 100644
--- a/ext/openssl/ossl_ocsp.c
+++ b/ext/openssl/ossl_ocsp.c
@@ -6,7 +6,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -67,13 +67,13 @@
if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
} while (0)
-VALUE mOCSP;
-VALUE eOCSPError;
-VALUE cOCSPReq;
-VALUE cOCSPRes;
-VALUE cOCSPBasicRes;
-VALUE cOCSPSingleRes;
-VALUE cOCSPCertId;
+static VALUE mOCSP;
+static VALUE eOCSPError;
+static VALUE cOCSPReq;
+static VALUE cOCSPRes;
+static VALUE cOCSPBasicRes;
+static VALUE cOCSPSingleRes;
+static VALUE cOCSPCertId;
static void
ossl_ocsp_request_free(void *ptr)
@@ -84,9 +84,9 @@ ossl_ocsp_request_free(void *ptr)
static const rb_data_type_t ossl_ocsp_request_type = {
"OpenSSL/OCSP/REQUEST",
{
- 0, ossl_ocsp_request_free,
+ 0, ossl_ocsp_request_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -98,9 +98,9 @@ ossl_ocsp_response_free(void *ptr)
static const rb_data_type_t ossl_ocsp_response_type = {
"OpenSSL/OCSP/RESPONSE",
{
- 0, ossl_ocsp_response_free,
+ 0, ossl_ocsp_response_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -112,9 +112,9 @@ ossl_ocsp_basicresp_free(void *ptr)
static const rb_data_type_t ossl_ocsp_basicresp_type = {
"OpenSSL/OCSP/BASICRESP",
{
- 0, ossl_ocsp_basicresp_free,
+ 0, ossl_ocsp_basicresp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -126,9 +126,9 @@ ossl_ocsp_singleresp_free(void *ptr)
static const rb_data_type_t ossl_ocsp_singleresp_type = {
"OpenSSL/OCSP/SINGLERESP",
{
- 0, ossl_ocsp_singleresp_free,
+ 0, ossl_ocsp_singleresp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -140,19 +140,23 @@ ossl_ocsp_certid_free(void *ptr)
static const rb_data_type_t ossl_ocsp_certid_type = {
"OpenSSL/OCSP/CERTID",
{
- 0, ossl_ocsp_certid_free,
+ 0, ossl_ocsp_certid_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* Public
*/
static VALUE
-ossl_ocspcertid_new(OCSP_CERTID *cid)
+ossl_ocspcid_new(const OCSP_CERTID *cid)
{
VALUE obj = NewOCSPCertId(cOCSPCertId);
- SetOCSPCertId(obj, cid);
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ OCSP_CERTID *cid_new = OCSP_CERTID_dup((OCSP_CERTID *)cid);
+ if (!cid_new)
+ ossl_raise(eOCSPError, "OCSP_CERTID_dup");
+ SetOCSPCertId(obj, cid_new);
return obj;
}
@@ -167,12 +171,13 @@ ossl_ocspreq_alloc(VALUE klass)
obj = NewOCSPReq(klass);
if (!(req = OCSP_REQUEST_new()))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPReq(obj, req);
return obj;
}
+/* :nodoc: */
static VALUE
ossl_ocspreq_initialize_copy(VALUE self, VALUE other)
{
@@ -184,7 +189,7 @@ ossl_ocspreq_initialize_copy(VALUE self, VALUE other)
req_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_REQUEST), req);
if (!req_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
+ ossl_raise(eOCSPError, "ASN1_item_dup");
SetOCSPReq(self, req_new);
OCSP_REQUEST_free(req_old);
@@ -210,15 +215,15 @@ ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &arg);
if(!NIL_P(arg)){
- GetOCSPReq(self, req);
- arg = ossl_to_der_if_possible(arg);
- StringValue(arg);
- p = (unsigned char *)RSTRING_PTR(arg);
- req_new = d2i_OCSP_REQUEST(NULL, &p, RSTRING_LEN(arg));
- if (!req_new)
- ossl_raise(eOCSPError, "d2i_OCSP_REQUEST");
- SetOCSPReq(self, req_new);
- OCSP_REQUEST_free(req);
+ GetOCSPReq(self, req);
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char *)RSTRING_PTR(arg);
+ req_new = d2i_OCSP_REQUEST(NULL, &p, RSTRING_LEN(arg));
+ if (!req_new)
+ ossl_raise(eOCSPError, "d2i_OCSP_REQUEST");
+ SetOCSPReq(self, req_new);
+ OCSP_REQUEST_free(req);
}
return self;
@@ -244,13 +249,13 @@ ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &val);
if(NIL_P(val)) {
- GetOCSPReq(self, req);
- ret = OCSP_request_add1_nonce(req, NULL, -1);
+ GetOCSPReq(self, req);
+ ret = OCSP_request_add1_nonce(req, NULL, -1);
}
else{
- StringValue(val);
- GetOCSPReq(self, req);
- ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
+ StringValue(val);
+ GetOCSPReq(self, req);
+ ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
}
if(!ret) ossl_raise(eOCSPError, NULL);
@@ -307,10 +312,10 @@ ossl_ocspreq_add_certid(VALUE self, VALUE certid)
GetOCSPCertId(certid, id);
if (!(id_new = OCSP_CERTID_dup(id)))
- ossl_raise(eOCSPError, "OCSP_CERTID_dup");
+ ossl_raise(eOCSPError, "OCSP_CERTID_dup");
if (!OCSP_request_add0_id(req, id_new)) {
- OCSP_CERTID_free(id_new);
- ossl_raise(eOCSPError, "OCSP_request_add0_id");
+ OCSP_CERTID_free(id_new);
+ ossl_raise(eOCSPError, "OCSP_request_add0_id");
}
return self;
@@ -327,21 +332,19 @@ static VALUE
ossl_ocspreq_get_certid(VALUE self)
{
OCSP_REQUEST *req;
- OCSP_ONEREQ *one;
- OCSP_CERTID *id;
- VALUE ary, tmp;
- int i, count;
GetOCSPReq(self, req);
- count = OCSP_request_onereq_count(req);
- ary = (count > 0) ? rb_ary_new() : Qnil;
- for(i = 0; i < count; i++){
- one = OCSP_request_onereq_get0(req, i);
- tmp = NewOCSPCertId(cOCSPCertId);
- if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one))))
- ossl_raise(eOCSPError, NULL);
- SetOCSPCertId(tmp, id);
- rb_ary_push(ary, tmp);
+ int count = OCSP_request_onereq_count(req);
+ if (count < 0)
+ ossl_raise(eOCSPError, "OCSP_request_onereq_count");
+ if (count == 0)
+ return Qnil;
+
+ VALUE ary = rb_ary_new_capa(count);
+ for (int i = 0; i < count; i++) {
+ OCSP_ONEREQ *one = OCSP_request_onereq_get0(req, i);
+ OCSP_CERTID *cid = OCSP_onereq_get0_id(one);
+ rb_ary_push(ary, ossl_ocspcid_new(cid));
}
return ary;
@@ -366,7 +369,7 @@ ossl_ocspreq_get_certid(VALUE self)
static VALUE
ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
{
- VALUE signer_cert, signer_key, certs, flags, digest;
+ VALUE signer_cert, signer_key, certs, flags, digest, md_holder;
OCSP_REQUEST *req;
X509 *signer;
EVP_PKEY *key;
@@ -380,19 +383,17 @@ ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
signer = GetX509CertPtr(signer_cert);
key = GetPrivPKeyPtr(signer_key);
if (!NIL_P(flags))
- flg = NUM2INT(flags);
- if (NIL_P(digest))
- md = NULL;
- else
- md = ossl_evp_get_digestbyname(digest);
+ flg = NUM2INT(flags);
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
if (NIL_P(certs))
- flg |= OCSP_NOCERTS;
+ flg |= OCSP_NOCERTS;
else
- x509s = ossl_x509_ary2sk(certs);
+ x509s = ossl_x509_ary2sk(certs);
ret = OCSP_request_sign(req, signer, key, md, x509s, flg);
sk_X509_pop_free(x509s, X509_free);
- if (!ret) ossl_raise(eOCSPError, NULL);
+ if (!ret)
+ ossl_raise(eOCSPError, "OCSP_request_sign");
return self;
}
@@ -426,7 +427,7 @@ ossl_ocspreq_verify(int argc, VALUE *argv, VALUE self)
result = OCSP_request_verify(req, x509s, x509st, flg);
sk_X509_pop_free(x509s, X509_free);
if (result <= 0)
- ossl_clear_error();
+ ossl_clear_error();
return result > 0 ? Qtrue : Qfalse;
}
@@ -445,11 +446,11 @@ ossl_ocspreq_to_der(VALUE self)
GetOCSPReq(self, req);
if((len = i2d_OCSP_REQUEST(req, NULL)) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_OCSP_REQUEST(req, &p) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -493,7 +494,7 @@ ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp)
else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */
obj = NewOCSPRes(klass);
if(!(res = OCSP_response_create(st, bs)))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPRes(obj, res);
return obj;
@@ -507,12 +508,13 @@ ossl_ocspres_alloc(VALUE klass)
obj = NewOCSPRes(klass);
if(!(res = OCSP_RESPONSE_new()))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPRes(obj, res);
return obj;
}
+/* :nodoc: */
static VALUE
ossl_ocspres_initialize_copy(VALUE self, VALUE other)
{
@@ -524,7 +526,7 @@ ossl_ocspres_initialize_copy(VALUE self, VALUE other)
res_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_RESPONSE), res);
if (!res_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
+ ossl_raise(eOCSPError, "ASN1_item_dup");
SetOCSPRes(self, res_new);
OCSP_RESPONSE_free(res_old);
@@ -550,15 +552,15 @@ ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &arg);
if(!NIL_P(arg)){
- GetOCSPRes(self, res);
- arg = ossl_to_der_if_possible(arg);
- StringValue(arg);
- p = (unsigned char *)RSTRING_PTR(arg);
- res_new = d2i_OCSP_RESPONSE(NULL, &p, RSTRING_LEN(arg));
- if (!res_new)
- ossl_raise(eOCSPError, "d2i_OCSP_RESPONSE");
- SetOCSPRes(self, res_new);
- OCSP_RESPONSE_free(res);
+ GetOCSPRes(self, res);
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char *)RSTRING_PTR(arg);
+ res_new = d2i_OCSP_RESPONSE(NULL, &p, RSTRING_LEN(arg));
+ if (!res_new)
+ ossl_raise(eOCSPError, "d2i_OCSP_RESPONSE");
+ SetOCSPRes(self, res_new);
+ OCSP_RESPONSE_free(res);
}
return self;
@@ -619,7 +621,7 @@ ossl_ocspres_get_basic(VALUE self)
GetOCSPRes(self, res);
ret = NewOCSPBasicRes(cOCSPBasicRes);
if(!(bs = OCSP_response_get1_basic(res)))
- return Qnil;
+ return Qnil;
SetOCSPBasicRes(ret, bs);
return ret;
@@ -642,11 +644,11 @@ ossl_ocspres_to_der(VALUE self)
GetOCSPRes(self, res);
if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_OCSP_RESPONSE(res, &p) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -663,12 +665,13 @@ ossl_ocspbres_alloc(VALUE klass)
obj = NewOCSPBasicRes(klass);
if(!(bs = OCSP_BASICRESP_new()))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPBasicRes(obj, bs);
return obj;
}
+/* :nodoc: */
static VALUE
ossl_ocspbres_initialize_copy(VALUE self, VALUE other)
{
@@ -680,7 +683,7 @@ ossl_ocspbres_initialize_copy(VALUE self, VALUE other)
bs_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_BASICRESP), bs);
if (!bs_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
+ ossl_raise(eOCSPError, "ASN1_item_dup");
SetOCSPBasicRes(self, bs_new);
OCSP_BASICRESP_free(bs_old);
@@ -705,15 +708,15 @@ ossl_ocspbres_initialize(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &arg);
if (!NIL_P(arg)) {
- GetOCSPBasicRes(self, res);
- arg = ossl_to_der_if_possible(arg);
- StringValue(arg);
- p = (unsigned char *)RSTRING_PTR(arg);
- res_new = d2i_OCSP_BASICRESP(NULL, &p, RSTRING_LEN(arg));
- if (!res_new)
- ossl_raise(eOCSPError, "d2i_OCSP_BASICRESP");
- SetOCSPBasicRes(self, res_new);
- OCSP_BASICRESP_free(res);
+ GetOCSPBasicRes(self, res);
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char *)RSTRING_PTR(arg);
+ res_new = d2i_OCSP_BASICRESP(NULL, &p, RSTRING_LEN(arg));
+ if (!res_new)
+ ossl_raise(eOCSPError, "d2i_OCSP_BASICRESP");
+ SetOCSPBasicRes(self, res_new);
+ OCSP_BASICRESP_free(res);
}
return self;
@@ -758,13 +761,13 @@ ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "01", &val);
if(NIL_P(val)) {
- GetOCSPBasicRes(self, bs);
- ret = OCSP_basic_add1_nonce(bs, NULL, -1);
+ GetOCSPBasicRes(self, bs);
+ ret = OCSP_basic_add1_nonce(bs, NULL, -1);
}
else{
- StringValue(val);
- GetOCSPBasicRes(self, bs);
- ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
+ StringValue(val);
+ GetOCSPBasicRes(self, bs);
+ ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
}
if(!ret) ossl_raise(eOCSPError, NULL);
@@ -777,12 +780,12 @@ add_status_convert_time(VALUE obj)
ASN1_TIME *time;
if (RB_INTEGER_TYPE_P(obj))
- time = X509_gmtime_adj(NULL, NUM2INT(obj));
+ time = X509_gmtime_adj(NULL, NUM2INT(obj));
else
- time = ossl_x509_time_adjust(NULL, obj);
+ time = ossl_x509_time_adjust(NULL, obj);
if (!time)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
return (VALUE)time;
}
@@ -816,8 +819,8 @@ add_status_convert_time(VALUE obj)
*/
static VALUE
ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
- VALUE reason, VALUE revtime,
- VALUE thisupd, VALUE nextupd, VALUE ext)
+ VALUE reason, VALUE revtime,
+ VALUE thisupd, VALUE nextupd, VALUE ext)
{
OCSP_BASICRESP *bs;
OCSP_SINGLERESP *single;
@@ -831,16 +834,16 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
GetOCSPCertId(cid, id);
st = NUM2INT(status);
if (!NIL_P(ext)) { /* All ext's members must be X509::Extension */
- ext = rb_check_array_type(ext);
- for (i = 0; i < RARRAY_LEN(ext); i++)
- OSSL_Check_Kind(RARRAY_AREF(ext, i), cX509Ext);
+ ext = rb_check_array_type(ext);
+ for (i = 0; i < RARRAY_LEN(ext); i++)
+ OSSL_Check_Kind(RARRAY_AREF(ext, i), cX509Ext);
}
if (st == V_OCSP_CERTSTATUS_REVOKED) {
- rsn = NUM2INT(reason);
- tmp = rb_protect(add_status_convert_time, revtime, &rstatus);
- if (rstatus) goto err;
- rev = (ASN1_TIME *)tmp;
+ rsn = NUM2INT(reason);
+ tmp = rb_protect(add_status_convert_time, revtime, &rstatus);
+ if (rstatus) goto err;
+ rev = (ASN1_TIME *)tmp;
}
tmp = rb_protect(add_status_convert_time, thisupd, &rstatus);
@@ -848,29 +851,29 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
ths = (ASN1_TIME *)tmp;
if (!NIL_P(nextupd)) {
- tmp = rb_protect(add_status_convert_time, nextupd, &rstatus);
- if (rstatus) goto err;
- nxt = (ASN1_TIME *)tmp;
+ tmp = rb_protect(add_status_convert_time, nextupd, &rstatus);
+ if (rstatus) goto err;
+ nxt = (ASN1_TIME *)tmp;
}
if(!(single = OCSP_basic_add1_status(bs, id, st, rsn, rev, ths, nxt))){
- error = 1;
- goto err;
+ error = 1;
+ goto err;
}
if(!NIL_P(ext)){
- X509_EXTENSION *x509ext;
-
- for(i = 0; i < RARRAY_LEN(ext); i++){
- x509ext = GetX509ExtPtr(RARRAY_AREF(ext, i));
- if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
- error = 1;
- goto err;
- }
- }
+ X509_EXTENSION *x509ext;
+
+ for(i = 0; i < RARRAY_LEN(ext); i++){
+ x509ext = GetX509ExtPtr(RARRAY_AREF(ext, i));
+ if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
+ error = 1;
+ goto err;
+ }
+ }
}
- err:
+ err:
ASN1_TIME_free(ths);
ASN1_TIME_free(nxt);
ASN1_TIME_free(rev);
@@ -896,48 +899,40 @@ static VALUE
ossl_ocspbres_get_status(VALUE self)
{
OCSP_BASICRESP *bs;
- OCSP_SINGLERESP *single;
- OCSP_CERTID *cid;
- ASN1_TIME *revtime, *thisupd, *nextupd;
- int status, reason;
- X509_EXTENSION *x509ext;
- VALUE ret, ary, ext;
- int count, ext_count, i, j;
GetOCSPBasicRes(self, bs);
- ret = rb_ary_new();
- count = OCSP_resp_count(bs);
- for(i = 0; i < count; i++){
- single = OCSP_resp_get0(bs, i);
- if(!single) continue;
-
- revtime = thisupd = nextupd = NULL;
- status = OCSP_single_get0_status(single, &reason, &revtime,
- &thisupd, &nextupd);
- if(status < 0) continue;
- if(!(cid = OCSP_CERTID_dup((OCSP_CERTID *)OCSP_SINGLERESP_get0_id(single)))) /* FIXME */
- ossl_raise(eOCSPError, NULL);
- ary = rb_ary_new();
- rb_ary_push(ary, ossl_ocspcertid_new(cid));
- rb_ary_push(ary, INT2NUM(status));
- rb_ary_push(ary, INT2NUM(reason));
- rb_ary_push(ary, revtime ? asn1time_to_time(revtime) : Qnil);
- rb_ary_push(ary, thisupd ? asn1time_to_time(thisupd) : Qnil);
- rb_ary_push(ary, nextupd ? asn1time_to_time(nextupd) : Qnil);
- ext = rb_ary_new();
- ext_count = OCSP_SINGLERESP_get_ext_count(single);
- for(j = 0; j < ext_count; j++){
- x509ext = OCSP_SINGLERESP_get_ext(single, j);
- rb_ary_push(ext, ossl_x509ext_new(x509ext));
- }
- rb_ary_push(ary, ext);
- rb_ary_push(ret, ary);
+ VALUE ret = rb_ary_new();
+ int count = OCSP_resp_count(bs);
+ for (int i = 0; i < count; i++) {
+ OCSP_SINGLERESP *single = OCSP_resp_get0(bs, i);
+ ASN1_TIME *revtime = NULL, *thisupd = NULL, *nextupd = NULL;
+ int reason = -1;
+
+ int status = OCSP_single_get0_status(single, &reason, &revtime, &thisupd, &nextupd);
+ if (status < 0)
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
+
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, ossl_ocspcid_new(OCSP_SINGLERESP_get0_id(single)));
+ rb_ary_push(ary, INT2NUM(status));
+ rb_ary_push(ary, INT2NUM(reason));
+ rb_ary_push(ary, revtime ? asn1time_to_time(revtime) : Qnil);
+ rb_ary_push(ary, thisupd ? asn1time_to_time(thisupd) : Qnil);
+ rb_ary_push(ary, nextupd ? asn1time_to_time(nextupd) : Qnil);
+ VALUE ext = rb_ary_new();
+ int ext_count = OCSP_SINGLERESP_get_ext_count(single);
+ for (int j = 0; j < ext_count; j++) {
+ const X509_EXTENSION *x509ext = OCSP_SINGLERESP_get_ext(single, j);
+ rb_ary_push(ext, ossl_x509ext_new(x509ext));
+ }
+ rb_ary_push(ary, ext);
+ rb_ary_push(ret, ary);
}
return ret;
}
-static VALUE ossl_ocspsres_new(OCSP_SINGLERESP *);
+static VALUE ossl_ocspsres_new(const OCSP_SINGLERESP *);
/*
* call-seq:
@@ -955,17 +950,10 @@ ossl_ocspbres_get_responses(VALUE self)
GetOCSPBasicRes(self, bs);
count = OCSP_resp_count(bs);
- ret = rb_ary_new2(count);
+ ret = rb_ary_new_capa(count);
for (i = 0; i < count; i++) {
- OCSP_SINGLERESP *sres, *sres_new;
-
- sres = OCSP_resp_get0(bs, i);
- sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres);
- if (!sres_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
-
- rb_ary_push(ret, ossl_ocspsres_new(sres_new));
+ rb_ary_push(ret, ossl_ocspsres_new(OCSP_resp_get0(bs, i)));
}
return ret;
@@ -983,7 +971,6 @@ static VALUE
ossl_ocspbres_find_response(VALUE self, VALUE target)
{
OCSP_BASICRESP *bs;
- OCSP_SINGLERESP *sres, *sres_new;
OCSP_CERTID *id;
int n;
@@ -991,14 +978,8 @@ ossl_ocspbres_find_response(VALUE self, VALUE target)
GetOCSPBasicRes(self, bs);
if ((n = OCSP_resp_find(bs, id, -1)) == -1)
- return Qnil;
-
- sres = OCSP_resp_get0(bs, n);
- sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres);
- if (!sres_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
-
- return ossl_ocspsres_new(sres_new);
+ return Qnil;
+ return ossl_ocspsres_new(OCSP_resp_get0(bs, n));
}
/*
@@ -1017,7 +998,7 @@ ossl_ocspbres_find_response(VALUE self, VALUE target)
static VALUE
ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
{
- VALUE signer_cert, signer_key, certs, flags, digest;
+ VALUE signer_cert, signer_key, certs, flags, digest, md_holder;
OCSP_BASICRESP *bs;
X509 *signer;
EVP_PKEY *key;
@@ -1031,19 +1012,17 @@ ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
signer = GetX509CertPtr(signer_cert);
key = GetPrivPKeyPtr(signer_key);
if (!NIL_P(flags))
- flg = NUM2INT(flags);
- if (NIL_P(digest))
- md = NULL;
- else
- md = ossl_evp_get_digestbyname(digest);
+ flg = NUM2INT(flags);
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
if (NIL_P(certs))
- flg |= OCSP_NOCERTS;
+ flg |= OCSP_NOCERTS;
else
- x509s = ossl_x509_ary2sk(certs);
+ x509s = ossl_x509_ary2sk(certs);
ret = OCSP_basic_sign(bs, signer, key, md, x509s, flg);
sk_X509_pop_free(x509s, X509_free);
- if (!ret) ossl_raise(eOCSPError, NULL);
+ if (!ret)
+ ossl_raise(eOCSPError, "OCSP_basic_sign");
return self;
}
@@ -1072,7 +1051,7 @@ ossl_ocspbres_verify(int argc, VALUE *argv, VALUE self)
result = OCSP_basic_verify(bs, x509s, x509st, flg);
sk_X509_pop_free(x509s, X509_free);
if (result <= 0)
- ossl_clear_error();
+ ossl_clear_error();
return result > 0 ? Qtrue : Qfalse;
}
@@ -1093,11 +1072,11 @@ ossl_ocspbres_to_der(VALUE self)
GetOCSPBasicRes(self, res);
if ((len = i2d_OCSP_BASICRESP(res, NULL)) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_OCSP_BASICRESP(res, &p) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -1107,12 +1086,18 @@ ossl_ocspbres_to_der(VALUE self)
* OCSP::SingleResponse
*/
static VALUE
-ossl_ocspsres_new(OCSP_SINGLERESP *sres)
+ossl_ocspsres_new(const OCSP_SINGLERESP *sres)
{
VALUE obj;
+ OCSP_SINGLERESP *sres_new;
obj = NewOCSPSingleRes(cOCSPSingleRes);
- SetOCSPSingleRes(obj, sres);
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP),
+ (OCSP_SINGLERESP *)sres);
+ if (!sres_new)
+ ossl_raise(eOCSPError, "ASN1_item_dup");
+ SetOCSPSingleRes(obj, sres_new);
return obj;
}
@@ -1125,7 +1110,7 @@ ossl_ocspsres_alloc(VALUE klass)
obj = NewOCSPSingleRes(klass);
if (!(sres = OCSP_SINGLERESP_new()))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPSingleRes(obj, sres);
return obj;
@@ -1150,13 +1135,14 @@ ossl_ocspsres_initialize(VALUE self, VALUE arg)
p = (unsigned char*)RSTRING_PTR(arg);
res_new = d2i_OCSP_SINGLERESP(NULL, &p, RSTRING_LEN(arg));
if (!res_new)
- ossl_raise(eOCSPError, "d2i_OCSP_SINGLERESP");
+ ossl_raise(eOCSPError, "d2i_OCSP_SINGLERESP");
SetOCSPSingleRes(self, res_new);
OCSP_SINGLERESP_free(res);
return self;
}
+/* :nodoc: */
static VALUE
ossl_ocspsres_initialize_copy(VALUE self, VALUE other)
{
@@ -1168,7 +1154,7 @@ ossl_ocspsres_initialize_copy(VALUE self, VALUE other)
sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres);
if (!sres_new)
- ossl_raise(eOCSPError, "ASN1_item_dup");
+ ossl_raise(eOCSPError, "ASN1_item_dup");
SetOCSPSingleRes(self, sres_new);
OCSP_SINGLERESP_free(sres_old);
@@ -1207,15 +1193,15 @@ ossl_ocspsres_check_validity(int argc, VALUE *argv, VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, NULL, NULL, &this_update, &next_update);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
ret = OCSP_check_validity(this_update, next_update, nsec, maxsec);
if (ret)
- return Qtrue;
+ return Qtrue;
else {
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
}
}
@@ -1229,12 +1215,9 @@ static VALUE
ossl_ocspsres_get_certid(VALUE self)
{
OCSP_SINGLERESP *sres;
- OCSP_CERTID *id;
GetOCSPSingleRes(self, sres);
- id = OCSP_CERTID_dup((OCSP_CERTID *)OCSP_SINGLERESP_get0_id(sres)); /* FIXME */
-
- return ossl_ocspcertid_new(id);
+ return ossl_ocspcid_new(OCSP_SINGLERESP_get0_id(sres));
}
/*
@@ -1260,7 +1243,7 @@ ossl_ocspsres_get_cert_status(VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, NULL, NULL, NULL, NULL);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
return INT2NUM(status);
}
@@ -1279,9 +1262,9 @@ ossl_ocspsres_get_this_update(VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, NULL, NULL, &time, NULL);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -1300,9 +1283,9 @@ ossl_ocspsres_get_next_update(VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, NULL, NULL, NULL, &time);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -1321,11 +1304,11 @@ ossl_ocspsres_get_revocation_time(VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, NULL, &time, NULL, NULL);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
if (status != V_OCSP_CERTSTATUS_REVOKED)
- ossl_raise(eOCSPError, "certificate is not revoked");
+ ossl_raise(eOCSPError, "certificate is not revoked");
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -1343,9 +1326,9 @@ ossl_ocspsres_get_revocation_reason(VALUE self)
GetOCSPSingleRes(self, sres);
status = OCSP_single_get0_status(sres, &reason, NULL, NULL, NULL);
if (status < 0)
- ossl_raise(eOCSPError, "OCSP_single_get0_status");
+ ossl_raise(eOCSPError, "OCSP_single_get0_status");
if (status != V_OCSP_CERTSTATUS_REVOKED)
- ossl_raise(eOCSPError, "certificate is not revoked");
+ ossl_raise(eOCSPError, "certificate is not revoked");
return INT2NUM(reason);
}
@@ -1358,7 +1341,6 @@ static VALUE
ossl_ocspsres_get_extensions(VALUE self)
{
OCSP_SINGLERESP *sres;
- X509_EXTENSION *ext;
int count, i;
VALUE ary;
@@ -1367,8 +1349,8 @@ ossl_ocspsres_get_extensions(VALUE self)
count = OCSP_SINGLERESP_get_ext_count(sres);
ary = rb_ary_new2(count);
for (i = 0; i < count; i++) {
- ext = OCSP_SINGLERESP_get_ext(sres, i);
- rb_ary_push(ary, ossl_x509ext_new(ext)); /* will dup */
+ const X509_EXTENSION *ext = OCSP_SINGLERESP_get_ext(sres, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext)); /* will dup */
}
return ary;
@@ -1390,11 +1372,11 @@ ossl_ocspsres_to_der(VALUE self)
GetOCSPSingleRes(self, sres);
if ((len = i2d_OCSP_SINGLERESP(sres, NULL)) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_OCSP_SINGLERESP(sres, &p) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -1412,12 +1394,13 @@ ossl_ocspcid_alloc(VALUE klass)
obj = NewOCSPCertId(klass);
if(!(id = OCSP_CERTID_new()))
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
SetOCSPCertId(obj, id);
return obj;
}
+/* :nodoc: */
static VALUE
ossl_ocspcid_initialize_copy(VALUE self, VALUE other)
{
@@ -1429,7 +1412,7 @@ ossl_ocspcid_initialize_copy(VALUE self, VALUE other)
cid_new = OCSP_CERTID_dup(cid);
if (!cid_new)
- ossl_raise(eOCSPError, "OCSP_CERTID_dup");
+ ossl_raise(eOCSPError, "OCSP_CERTID_dup");
SetOCSPCertId(self, cid_new);
OCSP_CERTID_free(cid_old);
@@ -1459,27 +1442,28 @@ ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self)
GetOCSPCertId(self, id);
if (rb_scan_args(argc, argv, "12", &subject, &issuer, &digest) == 1) {
- VALUE arg;
- const unsigned char *p;
-
- arg = ossl_to_der_if_possible(subject);
- StringValue(arg);
- p = (unsigned char *)RSTRING_PTR(arg);
- newid = d2i_OCSP_CERTID(NULL, &p, RSTRING_LEN(arg));
- if (!newid)
- ossl_raise(eOCSPError, "d2i_OCSP_CERTID");
+ VALUE arg;
+ const unsigned char *p;
+
+ arg = ossl_to_der_if_possible(subject);
+ StringValue(arg);
+ p = (unsigned char *)RSTRING_PTR(arg);
+ newid = d2i_OCSP_CERTID(NULL, &p, RSTRING_LEN(arg));
+ if (!newid)
+ ossl_raise(eOCSPError, "d2i_OCSP_CERTID");
}
else {
- X509 *x509s, *x509i;
- const EVP_MD *md;
+ X509 *x509s, *x509i;
+ const EVP_MD *md;
+ VALUE md_holder;
- x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
- x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */
- md = !NIL_P(digest) ? ossl_evp_get_digestbyname(digest) : NULL;
+ x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
+ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
- newid = OCSP_cert_to_id(md, x509s, x509i);
- if (!newid)
- ossl_raise(eOCSPError, "OCSP_cert_to_id");
+ newid = OCSP_cert_to_id(md, x509s, x509i);
+ if (!newid)
+ ossl_raise(eOCSPError, "OCSP_cert_to_id");
}
SetOCSPCertId(self, newid);
@@ -1565,8 +1549,9 @@ ossl_ocspcid_get_issuer_name_hash(VALUE self)
GetOCSPCertId(self, id);
OCSP_id_get0_info(&name_hash, NULL, NULL, NULL, id);
- ret = rb_str_new(NULL, name_hash->length * 2);
- ossl_bin2hex(name_hash->data, RSTRING_PTR(ret), name_hash->length);
+ ret = rb_str_new(NULL, ASN1_STRING_length(name_hash) * 2);
+ ossl_bin2hex(ASN1_STRING_get0_data(name_hash), RSTRING_PTR(ret),
+ ASN1_STRING_length(name_hash));
return ret;
}
@@ -1588,8 +1573,9 @@ ossl_ocspcid_get_issuer_key_hash(VALUE self)
GetOCSPCertId(self, id);
OCSP_id_get0_info(NULL, NULL, &key_hash, NULL, id);
- ret = rb_str_new(NULL, key_hash->length * 2);
- ossl_bin2hex(key_hash->data, RSTRING_PTR(ret), key_hash->length);
+ ret = rb_str_new(NULL, ASN1_STRING_length(key_hash) * 2);
+ ossl_bin2hex(ASN1_STRING_get0_data(key_hash), RSTRING_PTR(ret),
+ ASN1_STRING_length(key_hash));
return ret;
}
@@ -1606,19 +1592,10 @@ ossl_ocspcid_get_hash_algorithm(VALUE self)
{
OCSP_CERTID *id;
ASN1_OBJECT *oid;
- BIO *out;
GetOCSPCertId(self, id);
OCSP_id_get0_info(NULL, &oid, NULL, NULL, id);
-
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eOCSPError, "BIO_new");
-
- if (!i2a_ASN1_OBJECT(out, oid)) {
- BIO_free(out);
- ossl_raise(eOCSPError, "i2a_ASN1_OBJECT");
- }
- return ossl_membio2str(out);
+ return ossl_asn1obj_to_string_long_name(oid);
}
/*
@@ -1637,11 +1614,11 @@ ossl_ocspcid_to_der(VALUE self)
GetOCSPCertId(self, id);
if ((len = i2d_OCSP_CERTID(id, NULL)) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_OCSP_CERTID(id, &p) <= 0)
- ossl_raise(eOCSPError, NULL);
+ ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -1650,11 +1627,6 @@ ossl_ocspcid_to_der(VALUE self)
void
Init_ossl_ocsp(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/*
* OpenSSL::OCSP implements Online Certificate Status Protocol requests
* and responses.
@@ -1701,7 +1673,7 @@ Init_ossl_ocsp(void)
* require 'net/http'
*
* http_response =
- * Net::HTTP.start ocsp_uri.hostname, ocsp.port do |http|
+ * Net::HTTP.start ocsp_uri.hostname, ocsp_uri.port do |http|
* http.post ocsp_uri.path, request.to_der,
* 'content-type' => 'application/ocsp-request'
* end
diff --git a/ext/openssl/ossl_ocsp.h b/ext/openssl/ossl_ocsp.h
index 6d2aac8657..becd70ffed 100644
--- a/ext/openssl/ossl_ocsp.h
+++ b/ext/openssl/ossl_ocsp.h
@@ -6,18 +6,11 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_OCSP_H_)
#define _OSSL_OCSP_H_
-#if !defined(OPENSSL_NO_OCSP)
-extern VALUE mOCSP;
-extern VALUE cOCSPReq;
-extern VALUE cOCSPRes;
-extern VALUE cOCSPBasicRes;
-#endif
-
void Init_ossl_ocsp(void);
#endif /* _OSSL_OCSP_H_ */
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
index fb947df1d0..a47c81354c 100644
--- a/ext/openssl/ossl_pkcs12.c
+++ b/ext/openssl/ossl_pkcs12.c
@@ -1,6 +1,6 @@
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -27,8 +27,8 @@
/*
* Classes
*/
-VALUE cPKCS12;
-VALUE ePKCS12Error;
+static VALUE cPKCS12;
+static VALUE ePKCS12Error;
/*
* Private
@@ -42,9 +42,9 @@ ossl_pkcs12_free(void *ptr)
static const rb_data_type_t ossl_pkcs12_type = {
"OpenSSL/PKCS12",
{
- 0, ossl_pkcs12_free,
+ 0, ossl_pkcs12_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -60,6 +60,7 @@ ossl_pkcs12_s_allocate(VALUE klass)
return obj;
}
+/* :nodoc: */
static VALUE
ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
{
@@ -71,7 +72,7 @@ ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (char *)p12);
if (!p12_new)
- ossl_raise(ePKCS12Error, "ASN1_dup");
+ ossl_raise(ePKCS12Error, "ASN1_dup");
SetPKCS12(self, p12_new);
PKCS12_free(p12_old);
@@ -121,11 +122,11 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
/* TODO: make a VALUE to nid function */
if (!NIL_P(key_nid)) {
if ((nkey = OBJ_txt2nid(StringValueCStr(key_nid))) == NID_undef)
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid);
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid);
}
if (!NIL_P(cert_nid)) {
if ((ncert = OBJ_txt2nid(StringValueCStr(cert_nid))) == NID_undef)
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid);
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid);
}
if (!NIL_P(key_iter))
kiter = NUM2INT(key_iter);
@@ -134,6 +135,16 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
if (!NIL_P(keytype))
ktype = NUM2INT(keytype);
+#if defined(OPENSSL_IS_AWSLC)
+ if (ktype != 0) {
+ ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
+ }
+#else
+ if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
+ ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
+ }
+#endif
+
obj = NewPKCS12(cPKCS12);
x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
@@ -150,9 +161,9 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
}
static VALUE
-ossl_pkey_new_i(VALUE arg)
+ossl_pkey_wrap_i(VALUE arg)
{
- return ossl_pkey_new((EVP_PKEY *)arg);
+ return ossl_pkey_wrap((EVP_PKEY *)arg);
}
static VALUE
@@ -180,6 +191,7 @@ ossl_x509_sk2ary_i(VALUE arg)
static VALUE
ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
{
+ PKCS12 *p12, *p12_orig = DATA_PTR(self);
BIO *in;
VALUE arg, pass, pkey, cert, ca;
char *passphrase;
@@ -187,33 +199,31 @@ ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
X509 *x509;
STACK_OF(X509) *x509s = NULL;
int st = 0;
- PKCS12 *pkcs = DATA_PTR(self);
if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) return self;
passphrase = NIL_P(pass) ? NULL : StringValueCStr(pass);
in = ossl_obj2bio(&arg);
- d2i_PKCS12_bio(in, &pkcs);
- DATA_PTR(self) = pkcs;
+ p12 = d2i_PKCS12_bio(in, NULL);
BIO_free(in);
+ if (!p12)
+ ossl_raise(ePKCS12Error, "d2i_PKCS12_bio");
+ PKCS12_free(p12_orig);
+ RTYPEDDATA_DATA(self) = p12;
pkey = cert = ca = Qnil;
- /* OpenSSL's bug; PKCS12_parse() puts errors even if it succeeds.
- * Fixed in OpenSSL 1.0.0t, 1.0.1p, 1.0.2d */
- ERR_set_mark();
- if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s))
- ossl_raise(ePKCS12Error, "PKCS12_parse");
- ERR_pop_to_mark();
+ if (!PKCS12_parse(p12, passphrase, &key, &x509, &x509s))
+ ossl_raise(ePKCS12Error, "PKCS12_parse");
if (key) {
- pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st);
- if (st) goto err;
+ pkey = rb_protect(ossl_pkey_wrap_i, (VALUE)key, &st);
+ if (st) goto err;
}
if (x509) {
- cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
- if (st) goto err;
+ cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
+ if (st) goto err;
}
if (x509s) {
- ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
- if (st) goto err;
+ ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
+ if (st) goto err;
}
err:
@@ -237,25 +247,62 @@ ossl_pkcs12_to_der(VALUE self)
GetPKCS12(self, p12);
if((len = i2d_PKCS12(p12, NULL)) <= 0)
- ossl_raise(ePKCS12Error, NULL);
+ ossl_raise(ePKCS12Error, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_PKCS12(p12, &p) <= 0)
- ossl_raise(ePKCS12Error, NULL);
+ ossl_raise(ePKCS12Error, NULL);
ossl_str_adjust(str, p);
return str;
}
+/*
+ * call-seq:
+ * pkcs12.set_mac(pass, salt = nil, iter = nil, md_type = nil)
+ *
+ * Sets MAC parameters and generates MAC over the PKCS #12 structure.
+ *
+ * This method uses HMAC and the PKCS #12 specific password-based KDF as
+ * specified in the original PKCS #12.
+ *
+ * See also the man page PKCS12_set_mac(3).
+ *
+ * Added in version 3.3.0.
+ */
+static VALUE
+pkcs12_set_mac(int argc, VALUE *argv, VALUE self)
+{
+ PKCS12 *p12;
+ VALUE pass, salt, iter, md_name, md_holder = Qnil;
+ int iter_i = 0;
+ const EVP_MD *md_type = NULL;
+
+ rb_scan_args(argc, argv, "13", &pass, &salt, &iter, &md_name);
+ rb_check_frozen(self);
+ GetPKCS12(self, p12);
+
+ StringValue(pass);
+ if (!NIL_P(salt))
+ StringValue(salt);
+ if (!NIL_P(iter))
+ iter_i = NUM2INT(iter);
+ if (!NIL_P(md_name))
+ md_type = ossl_evp_md_fetch(md_name, &md_holder);
+
+ if (!PKCS12_set_mac(p12, RSTRING_PTR(pass), RSTRING_LENINT(pass),
+ !NIL_P(salt) ? (unsigned char *)RSTRING_PTR(salt) : NULL,
+ !NIL_P(salt) ? RSTRING_LENINT(salt) : 0,
+ iter_i, md_type))
+ ossl_raise(ePKCS12Error, "PKCS12_set_mac");
+
+ return Qnil;
+}
+
void
Init_ossl_pkcs12(void)
{
#undef rb_intern
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/*
* Defines a file format commonly used to store private keys with
* accompanying public key certificates, protected with a password-based
@@ -272,4 +319,11 @@ Init_ossl_pkcs12(void)
rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
+ rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
+
+#if !defined(OPENSSL_IS_AWSLC)
+ /* MSIE specific PKCS12 key usage extensions */
+ rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
+ rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
+#endif
}
diff --git a/ext/openssl/ossl_pkcs12.h b/ext/openssl/ossl_pkcs12.h
index fe4f15ef60..6d2cd901cb 100644
--- a/ext/openssl/ossl_pkcs12.h
+++ b/ext/openssl/ossl_pkcs12.h
@@ -1,13 +1,10 @@
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_PKCS12_H_)
#define _OSSL_PKCS12_H_
-extern VALUE cPKCS12;
-extern VALUE ePKCS12Error;
-
void Init_ossl_pkcs12(void);
#endif /* _OSSL_PKCS12_H_ */
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index dbe5347639..44e8cb305b 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -5,22 +5,37 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
+#define NewPKCS7(klass) \
+ TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, 0)
+#define SetPKCS7(obj, pkcs7) do { \
+ if (!(pkcs7)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+ RTYPEDDATA_DATA(obj) = (pkcs7); \
+} while (0)
+#define GetPKCS7(obj, pkcs7) do { \
+ TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \
+ if (!(pkcs7)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+} while (0)
+
#define NewPKCS7si(klass) \
TypedData_Wrap_Struct((klass), &ossl_pkcs7_signer_info_type, 0)
#define SetPKCS7si(obj, p7si) do { \
if (!(p7si)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (p7si); \
} while (0)
#define GetPKCS7si(obj, p7si) do { \
TypedData_Get_Struct((obj), PKCS7_SIGNER_INFO, &ossl_pkcs7_signer_info_type, (p7si)); \
if (!(p7si)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
} \
} while (0)
@@ -28,14 +43,14 @@
TypedData_Wrap_Struct((klass), &ossl_pkcs7_recip_info_type, 0)
#define SetPKCS7ri(obj, p7ri) do { \
if (!(p7ri)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (p7ri); \
} while (0)
#define GetPKCS7ri(obj, p7ri) do { \
TypedData_Get_Struct((obj), PKCS7_RECIP_INFO, &ossl_pkcs7_recip_info_type, (p7ri)); \
if (!(p7ri)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
} \
} while (0)
@@ -49,10 +64,11 @@
/*
* Classes
*/
-VALUE cPKCS7;
-VALUE cPKCS7Signer;
-VALUE cPKCS7Recipient;
-VALUE ePKCS7Error;
+static VALUE cPKCS7;
+static VALUE cPKCS7Signer;
+static VALUE cPKCS7Recipient;
+static VALUE ePKCS7Error;
+static ID id_md_holder, id_cipher_holder;
static void
ossl_pkcs7_free(void *ptr)
@@ -60,14 +76,28 @@ ossl_pkcs7_free(void *ptr)
PKCS7_free(ptr);
}
-const rb_data_type_t ossl_pkcs7_type = {
+static const rb_data_type_t ossl_pkcs7_type = {
"OpenSSL/PKCS7",
{
- 0, ossl_pkcs7_free,
+ 0, ossl_pkcs7_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
+VALUE
+ossl_pkcs7_new(PKCS7 *p7)
+{
+ PKCS7 *new;
+ VALUE obj = NewPKCS7(cPKCS7);
+
+ new = PKCS7_dup(p7);
+ if (!new)
+ ossl_raise(ePKCS7Error, "PKCS7_dup");
+ SetPKCS7(obj, new);
+
+ return obj;
+}
+
static void
ossl_pkcs7_signer_info_free(void *ptr)
{
@@ -77,9 +107,9 @@ ossl_pkcs7_signer_info_free(void *ptr)
static const rb_data_type_t ossl_pkcs7_signer_info_type = {
"OpenSSL/PKCS7/SIGNER_INFO",
{
- 0, ossl_pkcs7_signer_info_free,
+ 0, ossl_pkcs7_signer_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -91,9 +121,9 @@ ossl_pkcs7_recip_info_free(void *ptr)
static const rb_data_type_t ossl_pkcs7_recip_info_type = {
"OpenSSL/PKCS7/RECIP_INFO",
{
- 0, ossl_pkcs7_recip_info_free,
+ 0, ossl_pkcs7_recip_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -114,23 +144,32 @@ ossl_PKCS7_SIGNER_INFO_dup(PKCS7_SIGNER_INFO *si)
}
static PKCS7_RECIP_INFO *
-ossl_PKCS7_RECIP_INFO_dup(PKCS7_RECIP_INFO *si)
+ossl_PKCS7_RECIP_INFO_dup(PKCS7_RECIP_INFO *ri)
{
- return ASN1_dup((i2d_of_void *)i2d_PKCS7_RECIP_INFO,
- (d2i_of_void *)d2i_PKCS7_RECIP_INFO,
- si);
+ PKCS7_RECIP_INFO *ri_new = ASN1_dup((i2d_of_void *)i2d_PKCS7_RECIP_INFO,
+ (d2i_of_void *)d2i_PKCS7_RECIP_INFO,
+ ri);
+ if (ri_new && ri->cert) {
+ if (!X509_up_ref(ri->cert)) {
+ PKCS7_RECIP_INFO_free(ri_new);
+ return NULL;
+ }
+ ri_new->cert = ri->cert;
+ }
+ return ri_new;
}
static VALUE
ossl_pkcs7si_new(PKCS7_SIGNER_INFO *p7si)
{
- PKCS7_SIGNER_INFO *pkcs7;
+ PKCS7_SIGNER_INFO *p7si_new;
VALUE obj;
obj = NewPKCS7si(cPKCS7Signer);
- pkcs7 = p7si ? ossl_PKCS7_SIGNER_INFO_dup(p7si) : PKCS7_SIGNER_INFO_new();
- if (!pkcs7) ossl_raise(ePKCS7Error, NULL);
- SetPKCS7si(obj, pkcs7);
+ p7si_new = ossl_PKCS7_SIGNER_INFO_dup(p7si);
+ if (!p7si_new)
+ ossl_raise(ePKCS7Error, "ASN1_dup");
+ SetPKCS7si(obj, p7si_new);
return obj;
}
@@ -138,13 +177,14 @@ ossl_pkcs7si_new(PKCS7_SIGNER_INFO *p7si)
static VALUE
ossl_pkcs7ri_new(PKCS7_RECIP_INFO *p7ri)
{
- PKCS7_RECIP_INFO *pkcs7;
+ PKCS7_RECIP_INFO *p7ri_new;
VALUE obj;
obj = NewPKCS7ri(cPKCS7Recipient);
- pkcs7 = p7ri ? ossl_PKCS7_RECIP_INFO_dup(p7ri) : PKCS7_RECIP_INFO_new();
- if (!pkcs7) ossl_raise(ePKCS7Error, NULL);
- SetPKCS7ri(obj, pkcs7);
+ p7ri_new = ossl_PKCS7_RECIP_INFO_dup(p7ri);
+ if (!p7ri_new)
+ ossl_raise(ePKCS7Error,"ASN1_dup");
+ SetPKCS7ri(obj, p7ri_new);
return obj;
}
@@ -165,7 +205,13 @@ ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
out = NULL;
pkcs7 = SMIME_read_PKCS7(in, &out);
BIO_free(in);
- if(!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ if (!pkcs7)
+ ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
+ if (!pkcs7->d.ptr) {
+ PKCS7_free(pkcs7);
+ ossl_raise(ePKCS7Error, "No content in PKCS7");
+ }
+
data = out ? ossl_membio2str(out) : Qnil;
SetPKCS7(ret, pkcs7);
ossl_pkcs7_set_data(ret, data);
@@ -192,7 +238,7 @@ ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
if(NIL_P(data)) data = ossl_pkcs7_get_data(pkcs7);
GetPKCS7(pkcs7, p7);
if(!NIL_P(data) && PKCS7_is_detached(p7))
- flg |= PKCS7_DETACHED;
+ flg |= PKCS7_DETACHED;
in = NIL_P(data) ? NULL : ossl_obj2bio(&data);
if(!(out = BIO_new(BIO_s_mem()))){
BIO_free(in);
@@ -233,16 +279,16 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
in = ossl_obj2bio(&data);
if(NIL_P(certs)) x509s = NULL;
else{
- x509s = ossl_protect_x509_ary2sk(certs, &status);
- if(status){
- BIO_free(in);
- rb_jump_tag(status);
- }
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
}
if(!(pkcs7 = PKCS7_sign(x509, pkey, x509s, in, flg))){
- BIO_free(in);
- sk_X509_pop_free(x509s, X509_free);
- ossl_raise(ePKCS7Error, NULL);
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
}
SetPKCS7(ret, pkcs7);
ossl_pkcs7_set_data(ret, data);
@@ -255,12 +301,19 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * PKCS7.encrypt(certs, data, [, cipher [, flags]]) => pkcs7
+ * PKCS7.encrypt(certs, data, cipher, flags = 0) => pkcs7
+ *
+ * Creates a PKCS #7 enveloped-data structure.
+ *
+ * Before version 3.3.0, +cipher+ was optional and defaulted to
+ * <tt>"RC2-40-CBC"</tt>.
+ *
+ * See also the man page PKCS7_encrypt(3).
*/
static VALUE
ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
{
- VALUE certs, data, cipher, flags;
+ VALUE certs, data, cipher, flags, cipher_holder;
STACK_OF(X509) *x509s;
BIO *in;
const EVP_CIPHER *ciph;
@@ -269,37 +322,29 @@ ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
PKCS7 *p7;
rb_scan_args(argc, argv, "22", &certs, &data, &cipher, &flags);
- if(NIL_P(cipher)){
-#if !defined(OPENSSL_NO_RC2)
- ciph = EVP_rc2_40_cbc();
-#elif !defined(OPENSSL_NO_DES)
- ciph = EVP_des_ede3_cbc();
-#elif !defined(OPENSSL_NO_RC2)
- ciph = EVP_rc2_40_cbc();
-#elif !defined(OPENSSL_NO_AES)
- ciph = EVP_EVP_aes_128_cbc();
-#else
- ossl_raise(ePKCS7Error, "Must specify cipher");
-#endif
-
+ if (NIL_P(cipher)) {
+ rb_raise(rb_eArgError,
+ "cipher must be specified. Before version 3.3, " \
+ "the default cipher was RC2-40-CBC.");
}
- else ciph = ossl_evp_get_cipherbyname(cipher);
+ ciph = ossl_evp_cipher_fetch(cipher, &cipher_holder);
flg = NIL_P(flags) ? 0 : NUM2INT(flags);
ret = NewPKCS7(cPKCS7);
in = ossl_obj2bio(&data);
x509s = ossl_protect_x509_ary2sk(certs, &status);
if(status){
- BIO_free(in);
- rb_jump_tag(status);
+ BIO_free(in);
+ rb_jump_tag(status);
}
- if(!(p7 = PKCS7_encrypt(x509s, in, (EVP_CIPHER*)ciph, flg))){
- BIO_free(in);
- sk_X509_pop_free(x509s, X509_free);
- ossl_raise(ePKCS7Error, NULL);
+ if (!(p7 = PKCS7_encrypt(x509s, in, ciph, flg))) {
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
}
BIO_free(in);
SetPKCS7(ret, p7);
ossl_pkcs7_set_data(ret, data);
+ rb_ivar_set(ret, id_cipher_holder, cipher_holder);
sk_X509_pop_free(x509s, X509_free);
return ret;
@@ -313,7 +358,7 @@ ossl_pkcs7_alloc(VALUE klass)
obj = NewPKCS7(klass);
if (!(pkcs7 = PKCS7_new())) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
SetPKCS7(obj, pkcs7);
@@ -335,7 +380,7 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
VALUE arg;
if(rb_scan_args(argc, argv, "01", &arg) == 0)
- return self;
+ return self;
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
p7 = d2i_PKCS7_bio(in, NULL);
@@ -345,7 +390,11 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
}
BIO_free(in);
if (!p7)
- ossl_raise(rb_eArgError, "Could not parse the PKCS7");
+ ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
+ if (!p7->d.ptr) {
+ PKCS7_free(p7);
+ ossl_raise(ePKCS7Error, "No content in PKCS7");
+ }
RTYPEDDATA_DATA(self) = p7;
PKCS7_free(p7_orig);
@@ -355,6 +404,7 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_pkcs7_copy(VALUE self, VALUE other)
{
@@ -368,7 +418,7 @@ ossl_pkcs7_copy(VALUE self, VALUE other)
pkcs7 = PKCS7_dup(b);
if (!pkcs7) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
DATA_PTR(self) = pkcs7;
PKCS7_free(a);
@@ -400,13 +450,13 @@ ossl_pkcs7_sym2typeid(VALUE sym)
RSTRING_GETMEM(sym, s, l);
for(i = 0; ; i++){
- if(i == numberof(p7_type_tab))
- ossl_raise(ePKCS7Error, "unknown type \"%"PRIsVALUE"\"", sym);
- if(strlen(p7_type_tab[i].name) != l) continue;
- if(strcmp(p7_type_tab[i].name, s) == 0){
- ret = p7_type_tab[i].nid;
- break;
- }
+ if(i == numberof(p7_type_tab))
+ ossl_raise(ePKCS7Error, "unknown type \"%"PRIsVALUE"\"", sym);
+ if(strlen(p7_type_tab[i].name) != l) continue;
+ if(memcmp(p7_type_tab[i].name, s, l) == 0){
+ ret = p7_type_tab[i].nid;
+ break;
+ }
}
return ret;
@@ -423,7 +473,7 @@ ossl_pkcs7_set_type(VALUE self, VALUE type)
GetPKCS7(self, p7);
if(!PKCS7_set_type(p7, ossl_pkcs7_sym2typeid(type)))
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
return type;
}
@@ -439,15 +489,15 @@ ossl_pkcs7_get_type(VALUE self)
GetPKCS7(self, p7);
if(PKCS7_type_is_signed(p7))
- return ID2SYM(rb_intern("signed"));
+ return ID2SYM(rb_intern("signed"));
if(PKCS7_type_is_encrypted(p7))
- return ID2SYM(rb_intern("encrypted"));
+ return ID2SYM(rb_intern("encrypted"));
if(PKCS7_type_is_enveloped(p7))
- return ID2SYM(rb_intern("enveloped"));
+ return ID2SYM(rb_intern("enveloped"));
if(PKCS7_type_is_signedAndEnveloped(p7))
- return ID2SYM(rb_intern("signedAndEnveloped"));
+ return ID2SYM(rb_intern("signedAndEnveloped"));
if(PKCS7_type_is_data(p7))
- return ID2SYM(rb_intern("data"));
+ return ID2SYM(rb_intern("data"));
return Qnil;
}
@@ -458,9 +508,9 @@ ossl_pkcs7_set_detached(VALUE self, VALUE flag)
GetPKCS7(self, p7);
if(flag != Qtrue && flag != Qfalse)
- ossl_raise(ePKCS7Error, "must specify a boolean");
+ ossl_raise(ePKCS7Error, "must specify a boolean");
if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0))
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
return flag;
}
@@ -470,6 +520,8 @@ ossl_pkcs7_get_detached(VALUE self)
{
PKCS7 *p7;
GetPKCS7(self, p7);
+ if (!PKCS7_type_is_signed(p7))
+ return Qfalse;
return PKCS7_get_detached(p7) ? Qtrue : Qfalse;
}
@@ -485,11 +537,14 @@ static VALUE
ossl_pkcs7_set_cipher(VALUE self, VALUE cipher)
{
PKCS7 *pkcs7;
+ const EVP_CIPHER *ciph;
+ VALUE cipher_holder;
GetPKCS7(self, pkcs7);
- if (!PKCS7_set_cipher(pkcs7, ossl_evp_get_cipherbyname(cipher))) {
- ossl_raise(ePKCS7Error, NULL);
- }
+ ciph = ossl_evp_cipher_fetch(cipher, &cipher_holder);
+ if (!PKCS7_set_cipher(pkcs7, ciph))
+ ossl_raise(ePKCS7Error, "PKCS7_set_cipher");
+ rb_ivar_set(self, id_cipher_holder, cipher_holder);
return cipher;
}
@@ -520,22 +575,17 @@ ossl_pkcs7_get_signer(VALUE self)
{
PKCS7 *pkcs7;
STACK_OF(PKCS7_SIGNER_INFO) *sk;
- PKCS7_SIGNER_INFO *si;
int num, i;
VALUE ary;
GetPKCS7(self, pkcs7);
- if (!(sk = PKCS7_get_signer_info(pkcs7))) {
- OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!");
- return rb_ary_new();
- }
- if ((num = sk_PKCS7_SIGNER_INFO_num(sk)) < 0) {
- ossl_raise(ePKCS7Error, "Negative number of signers!");
- }
- ary = rb_ary_new2(num);
+ if (!(sk = PKCS7_get_signer_info(pkcs7)))
+ return rb_ary_new();
+ num = sk_PKCS7_SIGNER_INFO_num(sk);
+ ary = rb_ary_new_capa(num);
for (i=0; i<num; i++) {
- si = sk_PKCS7_SIGNER_INFO_value(sk, i);
- rb_ary_push(ary, ossl_pkcs7si_new(si));
+ PKCS7_SIGNER_INFO *si = sk_PKCS7_SIGNER_INFO_value(sk, i);
+ rb_ary_push(ary, ossl_pkcs7si_new(si));
}
return ary;
@@ -567,24 +617,21 @@ ossl_pkcs7_get_recipient(VALUE self)
{
PKCS7 *pkcs7;
STACK_OF(PKCS7_RECIP_INFO) *sk;
- PKCS7_RECIP_INFO *si;
int num, i;
VALUE ary;
GetPKCS7(self, pkcs7);
if (PKCS7_type_is_enveloped(pkcs7))
- sk = pkcs7->d.enveloped->recipientinfo;
+ sk = pkcs7->d.enveloped->recipientinfo;
else if (PKCS7_type_is_signedAndEnveloped(pkcs7))
- sk = pkcs7->d.signed_and_enveloped->recipientinfo;
+ sk = pkcs7->d.signed_and_enveloped->recipientinfo;
else sk = NULL;
if (!sk) return rb_ary_new();
- if ((num = sk_PKCS7_RECIP_INFO_num(sk)) < 0) {
- ossl_raise(ePKCS7Error, "Negative number of recipient!");
- }
- ary = rb_ary_new2(num);
+ num = sk_PKCS7_RECIP_INFO_num(sk);
+ ary = rb_ary_new_capa(num);
for (i=0; i<num; i++) {
- si = sk_PKCS7_RECIP_INFO_value(sk, i);
- rb_ary_push(ary, ossl_pkcs7ri_new(si));
+ PKCS7_RECIP_INFO *ri = sk_PKCS7_RECIP_INFO_value(sk, i);
+ rb_ary_push(ary, ossl_pkcs7ri_new(ri));
}
return ary;
@@ -599,7 +646,7 @@ ossl_pkcs7_add_certificate(VALUE self, VALUE cert)
GetPKCS7(self, pkcs7);
x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
if (!PKCS7_add_certificate(pkcs7, x509)){
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
return self;
@@ -615,13 +662,13 @@ pkcs7_get_certs(VALUE self)
GetPKCS7(self, pkcs7);
i = OBJ_obj2nid(pkcs7->type);
switch(i){
- case NID_pkcs7_signed:
+ case NID_pkcs7_signed:
certs = pkcs7->d.sign->cert;
break;
- case NID_pkcs7_signedAndEnveloped:
+ case NID_pkcs7_signedAndEnveloped:
certs = pkcs7->d.signed_and_enveloped->cert;
break;
- default:
+ default:
certs = NULL;
}
@@ -638,13 +685,13 @@ pkcs7_get_crls(VALUE self)
GetPKCS7(self, pkcs7);
i = OBJ_obj2nid(pkcs7->type);
switch(i){
- case NID_pkcs7_signed:
+ case NID_pkcs7_signed:
crls = pkcs7->d.sign->crl;
break;
- case NID_pkcs7_signedAndEnveloped:
+ case NID_pkcs7_signedAndEnveloped:
crls = pkcs7->d.signed_and_enveloped->crl;
break;
- default:
+ default:
crls = NULL;
}
@@ -664,7 +711,10 @@ ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
X509 *cert;
certs = pkcs7_get_certs(self);
- while((cert = sk_X509_pop(certs))) X509_free(cert);
+ if (certs) {
+ while ((cert = sk_X509_pop(certs)))
+ X509_free(cert);
+ }
rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_certs_i, self);
return ary;
@@ -673,7 +723,10 @@ ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
static VALUE
ossl_pkcs7_get_certificates(VALUE self)
{
- return ossl_x509_sk2ary(pkcs7_get_certs(self));
+ STACK_OF(X509) *certs = pkcs7_get_certs(self);
+ if (!certs)
+ return Qnil;
+ return ossl_x509_sk2ary(certs);
}
static VALUE
@@ -685,7 +738,7 @@ ossl_pkcs7_add_crl(VALUE self, VALUE crl)
GetPKCS7(self, pkcs7); /* NO DUP needed! */
x509crl = GetX509CRLPtr(crl);
if (!PKCS7_add_crl(pkcs7, x509crl)) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
return self;
@@ -704,7 +757,10 @@ ossl_pkcs7_set_crls(VALUE self, VALUE ary)
X509_CRL *crl;
crls = pkcs7_get_crls(self);
- while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
+ if (crls) {
+ while ((crl = sk_X509_CRL_pop(crls)))
+ X509_CRL_free(crl);
+ }
rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_crls_i, self);
return ary;
@@ -713,7 +769,10 @@ ossl_pkcs7_set_crls(VALUE self, VALUE ary)
static VALUE
ossl_pkcs7_get_crls(VALUE self)
{
- return ossl_x509crl_sk2ary(pkcs7_get_crls(self));
+ STACK_OF(X509_CRL) *crls = pkcs7_get_crls(self);
+ if (!crls)
+ return Qnil;
+ return ossl_x509crl_sk2ary(crls);
}
static VALUE
@@ -726,7 +785,6 @@ ossl_pkcs7_verify(int argc, VALUE *argv, VALUE self)
BIO *in, *out;
PKCS7 *p7;
VALUE data;
- const char *msg;
GetPKCS7(self, p7);
rb_scan_args(argc, argv, "22", &certs, &store, &indata, &flags);
@@ -736,28 +794,30 @@ ossl_pkcs7_verify(int argc, VALUE *argv, VALUE self)
in = NIL_P(indata) ? NULL : ossl_obj2bio(&indata);
if(NIL_P(certs)) x509s = NULL;
else{
- x509s = ossl_protect_x509_ary2sk(certs, &status);
- if(status){
- BIO_free(in);
- rb_jump_tag(status);
- }
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
}
if(!(out = BIO_new(BIO_s_mem()))){
- BIO_free(in);
- sk_X509_pop_free(x509s, X509_free);
- ossl_raise(ePKCS7Error, NULL);
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
}
ok = PKCS7_verify(p7, x509s, x509st, in, out, flg);
BIO_free(in);
sk_X509_pop_free(x509s, X509_free);
- if (ok < 0) ossl_raise(ePKCS7Error, "PKCS7_verify");
- msg = ERR_reason_error_string(ERR_peek_error());
- ossl_pkcs7_set_err_string(self, msg ? rb_str_new2(msg) : Qnil);
- ossl_clear_error();
data = ossl_membio2str(out);
ossl_pkcs7_set_data(self, data);
-
- return (ok == 1) ? Qtrue : Qfalse;
+ if (ok != 1) {
+ const char *msg = ERR_reason_error_string(ERR_peek_error());
+ ossl_pkcs7_set_err_string(self, msg ? rb_str_new_cstr(msg) : Qnil);
+ ossl_clear_error();
+ return Qfalse;
+ }
+ ossl_pkcs7_set_err_string(self, Qnil);
+ return Qtrue;
}
static VALUE
@@ -777,10 +837,10 @@ ossl_pkcs7_decrypt(int argc, VALUE *argv, VALUE self)
flg = NIL_P(flags) ? 0 : NUM2INT(flags);
GetPKCS7(self, p7);
if(!(out = BIO_new(BIO_s_mem())))
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
if(!PKCS7_decrypt(p7, key, x509, out, flg)){
- BIO_free(out);
- ossl_raise(ePKCS7Error, NULL);
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
}
str = ossl_membio2str(out); /* out will be free */
@@ -793,30 +853,38 @@ ossl_pkcs7_add_data(VALUE self, VALUE data)
PKCS7 *pkcs7;
BIO *out, *in;
char buf[4096];
- int len;
+ int len, ret;
GetPKCS7(self, pkcs7);
- if(PKCS7_type_is_signed(pkcs7)){
- if(!PKCS7_content_new(pkcs7, NID_pkcs7_data))
- ossl_raise(ePKCS7Error, NULL);
+ if (PKCS7_type_is_signed(pkcs7)) {
+ if (!PKCS7_content_new(pkcs7, NID_pkcs7_data))
+ ossl_raise(ePKCS7Error, "PKCS7_content_new");
}
in = ossl_obj2bio(&data);
- if(!(out = PKCS7_dataInit(pkcs7, NULL))) goto err;
- for(;;){
- if((len = BIO_read(in, buf, sizeof(buf))) <= 0)
- break;
- if(BIO_write(out, buf, len) != len)
- goto err;
+ if (!(out = PKCS7_dataInit(pkcs7, NULL))) {
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, "PKCS7_dataInit");
}
- if(!PKCS7_dataFinal(pkcs7, out)) goto err;
- ossl_pkcs7_set_data(self, Qnil);
-
- err:
+ for (;;) {
+ if ((len = BIO_read(in, buf, sizeof(buf))) <= 0)
+ break;
+ if (BIO_write(out, buf, len) != len) {
+ BIO_free_all(out);
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, "BIO_write");
+ }
+ }
+ if (BIO_flush(out) <= 0) {
+ BIO_free_all(out);
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, "BIO_flush");
+ }
+ ret = PKCS7_dataFinal(pkcs7, out);
BIO_free_all(out);
BIO_free(in);
- if(ERR_peek_error()){
- ossl_raise(ePKCS7Error, NULL);
- }
+ if (!ret)
+ ossl_raise(ePKCS7Error, "PKCS7_dataFinal");
+ ossl_pkcs7_set_data(self, Qnil);
return data;
}
@@ -831,17 +899,36 @@ ossl_pkcs7_to_der(VALUE self)
GetPKCS7(self, pkcs7);
if((len = i2d_PKCS7(pkcs7, NULL)) <= 0)
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_PKCS7(pkcs7, &p) <= 0)
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
ossl_str_adjust(str, p);
return str;
}
static VALUE
+ossl_pkcs7_to_text(VALUE self)
+{
+ PKCS7 *pkcs7;
+ BIO *out;
+ VALUE str;
+
+ GetPKCS7(self, pkcs7);
+ if(!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(ePKCS7Error, NULL);
+ if(!PKCS7_print_ctx(out, pkcs7, 0, NULL)) {
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
ossl_pkcs7_to_pem(VALUE self)
{
PKCS7 *pkcs7;
@@ -850,11 +937,11 @@ ossl_pkcs7_to_pem(VALUE self)
GetPKCS7(self, pkcs7);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
if (!PEM_write_bio_PKCS7(out, pkcs7)) {
- BIO_free(out);
- ossl_raise(ePKCS7Error, NULL);
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
}
str = ossl_membio2str(out);
@@ -872,7 +959,7 @@ ossl_pkcs7si_alloc(VALUE klass)
obj = NewPKCS7si(klass);
if (!(p7si = PKCS7_SIGNER_INFO_new())) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
SetPKCS7si(obj, p7si);
@@ -886,14 +973,15 @@ ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
EVP_PKEY *pkey;
X509 *x509;
const EVP_MD *md;
+ VALUE md_holder;
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
GetPKCS7si(self, p7si);
- if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) {
- ossl_raise(ePKCS7Error, NULL);
- }
+ if (PKCS7_SIGNER_INFO_set(p7si, x509, pkey, md) <= 0)
+ ossl_raise(ePKCS7Error, "PKCS7_SIGNER_INFO_set");
+ rb_ivar_set(self, id_md_holder, md_holder);
return self;
}
@@ -922,15 +1010,15 @@ static VALUE
ossl_pkcs7si_get_signed_time(VALUE self)
{
PKCS7_SIGNER_INFO *p7si;
- ASN1_TYPE *asn1obj;
+ const ASN1_TYPE *asn1obj;
GetPKCS7si(self, p7si);
if (!(asn1obj = PKCS7_get_signed_attribute(p7si, NID_pkcs9_signingTime))) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
if (asn1obj->type == V_ASN1_UTCTIME) {
- return asn1time_to_time(asn1obj->value.utctime);
+ return asn1time_to_time(asn1obj->value.utctime);
}
/*
* OR
@@ -952,7 +1040,7 @@ ossl_pkcs7ri_alloc(VALUE klass)
obj = NewPKCS7ri(klass);
if (!(p7ri = PKCS7_RECIP_INFO_new())) {
- ossl_raise(ePKCS7Error, NULL);
+ ossl_raise(ePKCS7Error, NULL);
}
SetPKCS7ri(obj, p7ri);
@@ -967,8 +1055,8 @@ ossl_pkcs7ri_initialize(VALUE self, VALUE cert)
x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
GetPKCS7ri(self, p7ri);
- if (!PKCS7_RECIP_INFO_set(p7ri, x509)) {
- ossl_raise(ePKCS7Error, NULL);
+ if (PKCS7_RECIP_INFO_set(p7ri, x509) <= 0) {
+ ossl_raise(ePKCS7Error, NULL);
}
return self;
@@ -1011,11 +1099,6 @@ void
Init_ossl_pkcs7(void)
{
#undef rb_intern
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject);
ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError);
rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
@@ -1050,6 +1133,7 @@ Init_ossl_pkcs7(void)
rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
rb_define_alias(cPKCS7, "to_s", "to_pem");
rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
+ rb_define_method(cPKCS7, "to_text", ossl_pkcs7_to_text, 0);
cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
rb_define_const(cPKCS7, "Signer", cPKCS7Signer);
@@ -1078,4 +1162,7 @@ Init_ossl_pkcs7(void)
DefPKCS7Const(BINARY);
DefPKCS7Const(NOATTR);
DefPKCS7Const(NOSMIMECAP);
+
+ id_md_holder = rb_intern_const("EVP_MD_holder");
+ id_cipher_holder = rb_intern_const("EVP_CIPHER_holder");
}
diff --git a/ext/openssl/ossl_pkcs7.h b/ext/openssl/ossl_pkcs7.h
index 3e1b094670..140fda1835 100644
--- a/ext/openssl/ossl_pkcs7.h
+++ b/ext/openssl/ossl_pkcs7.h
@@ -5,32 +5,12 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_PKCS7_H_)
#define _OSSL_PKCS7_H_
-#define NewPKCS7(klass) \
- TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, 0)
-#define SetPKCS7(obj, pkcs7) do { \
- if (!(pkcs7)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
- } \
- RTYPEDDATA_DATA(obj) = (pkcs7); \
-} while (0)
-#define GetPKCS7(obj, pkcs7) do { \
- TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \
- if (!(pkcs7)) { \
- ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
- } \
-} while (0)
-
-extern const rb_data_type_t ossl_pkcs7_type;
-extern VALUE cPKCS7;
-extern VALUE cPKCS7Signer;
-extern VALUE cPKCS7Recipient;
-extern VALUE ePKCS7Error;
-
+VALUE ossl_pkcs7_new(PKCS7 *p7);
void Init_ossl_pkcs7(void);
#endif /* _OSSL_PKCS7_H_ */
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 476256679b..a53332b17e 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -33,13 +33,13 @@ ossl_evp_pkey_free(void *ptr)
const rb_data_type_t ossl_evp_pkey_type = {
"OpenSSL/EVP_PKEY",
{
- 0, ossl_evp_pkey_free,
+ 0, ossl_evp_pkey_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
-pkey_new0(VALUE arg)
+pkey_wrap0(VALUE arg)
{
EVP_PKEY *pkey = (EVP_PKEY *)arg;
VALUE klass, obj;
@@ -65,15 +65,15 @@ pkey_new0(VALUE arg)
}
VALUE
-ossl_pkey_new(EVP_PKEY *pkey)
+ossl_pkey_wrap(EVP_PKEY *pkey)
{
VALUE obj;
int status;
- obj = rb_protect(pkey_new0, (VALUE)pkey, &status);
+ obj = rb_protect(pkey_wrap0, (VALUE)pkey, &status);
if (status) {
- EVP_PKEY_free(pkey);
- rb_jump_tag(status);
+ EVP_PKEY_free(pkey);
+ rb_jump_tag(status);
}
return obj;
@@ -82,31 +82,63 @@ ossl_pkey_new(EVP_PKEY *pkey)
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
# include <openssl/decoder.h>
-EVP_PKEY *
-ossl_pkey_read_generic(BIO *bio, VALUE pass)
+static EVP_PKEY *
+ossl_pkey_read(BIO *bio, const char *input_type, int selection, VALUE pass)
{
void *ppass = (void *)pass;
OSSL_DECODER_CTX *dctx;
EVP_PKEY *pkey = NULL;
int pos = 0, pos2;
- dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, "DER", NULL, NULL, 0, NULL, NULL);
+ dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, input_type, NULL, NULL,
+ selection, NULL, NULL);
if (!dctx)
goto out;
- if (OSSL_DECODER_CTX_set_pem_password_cb(dctx, ossl_pem_passwd_cb, ppass) != 1)
- goto out;
-
- /* First check DER */
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
+ if (selection == EVP_PKEY_KEYPAIR &&
+ OSSL_DECODER_CTX_set_pem_password_cb(dctx, ossl_pem_passwd_cb,
+ ppass) != 1)
goto out;
+ while (1) {
+ if (OSSL_DECODER_from_bio(dctx, bio) == 1)
+ goto out;
+ if (BIO_eof(bio))
+ break;
+ pos2 = BIO_tell(bio);
+ if (pos2 < 0 || pos2 <= pos)
+ break;
+ ossl_clear_error();
+ pos = pos2;
+ }
+ out:
OSSL_BIO_reset(bio);
+ OSSL_DECODER_CTX_free(dctx);
+ return pkey;
+}
- /* Then check PEM; multiple OSSL_DECODER_from_bio() calls may be needed */
- if (OSSL_DECODER_CTX_set_input_type(dctx, "PEM") != 1)
- goto out;
+EVP_PKEY *
+ossl_pkey_read_generic(BIO *bio, VALUE pass)
+{
+ EVP_PKEY *pkey = NULL;
+ /* First check DER, then check PEM. */
+ const char *input_types[] = {"DER", "PEM"};
+ int input_type_num = (int)(sizeof(input_types) / sizeof(char *));
/*
- * First check for private key formats. This is to keep compatibility with
- * ruby/openssl < 3.0 which decoded the following as a private key.
+ * Non-zero selections to try to decode.
+ *
+ * See EVP_PKEY_fromdata(3) - Selections to see all the selections.
+ *
+ * This is a workaround for the decoder failing to decode or returning
+ * bogus keys with selection 0, if a key management provider is different
+ * from a decoder provider. The workaround is to avoid using selection 0.
+ *
+ * Affected OpenSSL versions: >= 3.1.0, <= 3.1.2, or >= 3.0.0, <= 3.0.10
+ * Fixed OpenSSL versions: 3.2, next release of the 3.1.z and 3.0.z
+ *
+ * See https://github.com/openssl/openssl/pull/21519 for details.
+ *
+ * First check for private key formats (EVP_PKEY_KEYPAIR). This is to keep
+ * compatibility with ruby/openssl < 3.0 which decoded the following as a
+ * private key.
*
* $ openssl ecparam -name prime256v1 -genkey -outform PEM
* -----BEGIN EC PARAMETERS-----
@@ -124,36 +156,28 @@ ossl_pkey_read_generic(BIO *bio, VALUE pass)
*
* Note that normally, the input is supposed to contain a single decodable
* PEM block only, so this special handling should not create a new problem.
+ *
+ * Note that we need to create the OSSL_DECODER_CTX variable each time when
+ * we use the different selection as a workaround.
+ * See https://github.com/openssl/openssl/issues/20657 for details.
*/
- OSSL_DECODER_CTX_set_selection(dctx, EVP_PKEY_KEYPAIR);
- while (1) {
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
- goto out;
- if (BIO_eof(bio))
- break;
- pos2 = BIO_tell(bio);
- if (pos2 < 0 || pos2 <= pos)
- break;
- ossl_clear_error();
- pos = pos2;
- }
-
- OSSL_BIO_reset(bio);
- OSSL_DECODER_CTX_set_selection(dctx, 0);
- while (1) {
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
- goto out;
- if (BIO_eof(bio))
- break;
- pos2 = BIO_tell(bio);
- if (pos2 < 0 || pos2 <= pos)
- break;
- ossl_clear_error();
- pos = pos2;
+ int selections[] = {
+ EVP_PKEY_KEYPAIR,
+ EVP_PKEY_KEY_PARAMETERS,
+ EVP_PKEY_PUBLIC_KEY
+ };
+ int selection_num = (int)(sizeof(selections) / sizeof(int));
+ int i, j;
+
+ for (i = 0; i < input_type_num; i++) {
+ for (j = 0; j < selection_num; j++) {
+ pkey = ossl_pkey_read(bio, input_types[i], selections[j], pass);
+ if (pkey) {
+ goto out;
+ }
+ }
}
-
out:
- OSSL_DECODER_CTX_free(dctx);
return pkey;
}
#else
@@ -164,23 +188,23 @@ ossl_pkey_read_generic(BIO *bio, VALUE pass)
EVP_PKEY *pkey;
if ((pkey = d2i_PrivateKey_bio(bio, NULL)))
- goto out;
+ goto out;
OSSL_BIO_reset(bio);
if ((pkey = d2i_PKCS8PrivateKey_bio(bio, NULL, ossl_pem_passwd_cb, ppass)))
- goto out;
+ goto out;
OSSL_BIO_reset(bio);
if ((pkey = d2i_PUBKEY_bio(bio, NULL)))
- goto out;
+ goto out;
OSSL_BIO_reset(bio);
/* PEM_read_bio_PrivateKey() also parses PKCS #8 formats */
if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, ossl_pem_passwd_cb, ppass)))
- goto out;
+ goto out;
OSSL_BIO_reset(bio);
if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)))
- goto out;
+ goto out;
OSSL_BIO_reset(bio);
if ((pkey = PEM_read_bio_Parameters(bio, NULL)))
- goto out;
+ goto out;
out:
return pkey;
@@ -215,8 +239,8 @@ ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
pkey = ossl_pkey_read_generic(bio, ossl_pem_passwd_value(pass));
BIO_free(bio);
if (!pkey)
- ossl_raise(ePKeyError, "Could not parse PKey");
- return ossl_pkey_new(pkey);
+ ossl_raise(ePKeyError, "Could not parse PKey");
+ return ossl_pkey_wrap(pkey);
}
static VALUE
@@ -260,9 +284,9 @@ struct pkey_blocking_generate_arg {
EVP_PKEY_CTX *ctx;
EVP_PKEY *pkey;
int state;
- int yield: 1;
- int genparam: 1;
- int interrupted: 1;
+ unsigned int yield: 1;
+ unsigned int genparam: 1;
+ unsigned int interrupted: 1;
};
static VALUE
@@ -420,7 +444,7 @@ pkey_generate(int argc, VALUE *argv, VALUE self, int genparam)
}
}
- return ossl_pkey_new(gen_arg.pkey);
+ return ossl_pkey_wrap(gen_arg.pkey);
}
/*
@@ -484,7 +508,7 @@ ossl_pkey_s_generate_key(int argc, VALUE *argv, VALUE self)
void
ossl_pkey_check_public_key(const EVP_PKEY *pkey)
{
-#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
if (EVP_PKEY_missing_parameters(pkey))
ossl_raise(ePKeyError, "parameters missing");
#else
@@ -492,35 +516,34 @@ ossl_pkey_check_public_key(const EVP_PKEY *pkey)
const BIGNUM *n, *e, *pubkey;
if (EVP_PKEY_missing_parameters(pkey))
- ossl_raise(ePKeyError, "parameters missing");
+ ossl_raise(ePKeyError, "parameters missing");
- /* OpenSSL < 1.1.0 takes non-const pointer */
- ptr = EVP_PKEY_get0((EVP_PKEY *)pkey);
+ ptr = EVP_PKEY_get0(pkey);
switch (EVP_PKEY_base_id(pkey)) {
case EVP_PKEY_RSA:
- RSA_get0_key(ptr, &n, &e, NULL);
- if (n && e)
- return;
- break;
+ RSA_get0_key(ptr, &n, &e, NULL);
+ if (n && e)
+ return;
+ break;
case EVP_PKEY_DSA:
- DSA_get0_key(ptr, &pubkey, NULL);
- if (pubkey)
- return;
- break;
+ DSA_get0_key(ptr, &pubkey, NULL);
+ if (pubkey)
+ return;
+ break;
case EVP_PKEY_DH:
- DH_get0_key(ptr, &pubkey, NULL);
- if (pubkey)
- return;
- break;
+ DH_get0_key(ptr, &pubkey, NULL);
+ if (pubkey)
+ return;
+ break;
#if !defined(OPENSSL_NO_EC)
case EVP_PKEY_EC:
- if (EC_KEY_get0_public_key(ptr))
- return;
- break;
+ if (EC_KEY_get0_public_key(ptr))
+ return;
+ break;
#endif
default:
- /* unsupported type; assuming ok */
- return;
+ /* unsupported type; assuming ok */
+ return;
}
ossl_raise(ePKeyError, "public key missing");
#endif
@@ -587,12 +610,13 @@ static VALUE
ossl_pkey_initialize(VALUE self)
{
if (rb_obj_is_instance_of(self, cPKey)) {
- ossl_raise(rb_eTypeError, "OpenSSL::PKey::PKey can't be instantiated directly");
+ ossl_raise(rb_eTypeError, "OpenSSL::PKey::PKey can't be instantiated directly");
}
return self;
}
#ifdef HAVE_EVP_PKEY_DUP
+/* :nodoc: */
static VALUE
ossl_pkey_initialize_copy(VALUE self, VALUE other)
{
@@ -612,6 +636,93 @@ ossl_pkey_initialize_copy(VALUE self, VALUE other)
}
#endif
+#ifndef OSSL_USE_PROVIDER
+static int
+lookup_pkey_type(VALUE type)
+{
+ const EVP_PKEY_ASN1_METHOD *ameth;
+ int pkey_id;
+
+ StringValue(type);
+ /*
+ * XXX: EVP_PKEY_asn1_find_str() looks up a PEM type string. Should we use
+ * OBJ_txt2nid() instead (and then somehow check if the NID is an acceptable
+ * EVP_PKEY type)?
+ * It is probably fine, though, since it can handle all algorithms that
+ * support raw keys in 1.1.1: { X25519, X448, ED25519, ED448, HMAC }.
+ */
+ ameth = EVP_PKEY_asn1_find_str(NULL, RSTRING_PTR(type), RSTRING_LENINT(type));
+ if (!ameth)
+ ossl_raise(ePKeyError, "algorithm %"PRIsVALUE" not found", type);
+ EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
+ return pkey_id;
+}
+#endif
+
+/*
+ * call-seq:
+ * OpenSSL::PKey.new_raw_private_key(algo, string) -> PKey
+ *
+ * See the OpenSSL documentation for EVP_PKEY_new_raw_private_key()
+ */
+
+static VALUE
+ossl_pkey_new_raw_private_key(VALUE self, VALUE type, VALUE key)
+{
+ EVP_PKEY *pkey;
+ size_t keylen;
+
+ StringValue(key);
+ keylen = RSTRING_LEN(key);
+
+#ifdef OSSL_USE_PROVIDER
+ pkey = EVP_PKEY_new_raw_private_key_ex(NULL, StringValueCStr(type), NULL,
+ (unsigned char *)RSTRING_PTR(key),
+ keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_private_key_ex");
+#else
+ int pkey_id = lookup_pkey_type(type);
+ pkey = EVP_PKEY_new_raw_private_key(pkey_id, NULL, (unsigned char *)RSTRING_PTR(key), keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_private_key");
+#endif
+
+ return ossl_pkey_wrap(pkey);
+}
+
+/*
+ * call-seq:
+ * OpenSSL::PKey.new_raw_public_key(algo, string) -> PKey
+ *
+ * See the OpenSSL documentation for EVP_PKEY_new_raw_public_key()
+ */
+
+static VALUE
+ossl_pkey_new_raw_public_key(VALUE self, VALUE type, VALUE key)
+{
+ EVP_PKEY *pkey;
+ size_t keylen;
+
+ StringValue(key);
+ keylen = RSTRING_LEN(key);
+
+#ifdef OSSL_USE_PROVIDER
+ pkey = EVP_PKEY_new_raw_public_key_ex(NULL, StringValueCStr(type), NULL,
+ (unsigned char *)RSTRING_PTR(key),
+ keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_public_key_ex");
+#else
+ int pkey_id = lookup_pkey_type(type);
+ pkey = EVP_PKEY_new_raw_public_key(pkey_id, NULL, (unsigned char *)RSTRING_PTR(key), keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_public_key");
+#endif
+
+ return ossl_pkey_wrap(pkey);
+}
+
/*
* call-seq:
* pkey.oid -> string
@@ -626,6 +737,10 @@ ossl_pkey_oid(VALUE self)
GetPKey(self, pkey);
nid = EVP_PKEY_id(pkey);
+#ifdef OSSL_USE_PROVIDER
+ if (nid == EVP_PKEY_KEYMGMT)
+ ossl_raise(ePKeyError, "EVP_PKEY_id");
+#endif
return rb_str_new_cstr(OBJ_nid2sn(nid));
}
@@ -639,13 +754,23 @@ static VALUE
ossl_pkey_inspect(VALUE self)
{
EVP_PKEY *pkey;
- int nid;
GetPKey(self, pkey);
- nid = EVP_PKEY_id(pkey);
- return rb_sprintf("#<%"PRIsVALUE":%p oid=%s>",
- rb_class_name(CLASS_OF(self)), (void *)self,
- OBJ_nid2sn(nid));
+ VALUE str = rb_sprintf("#<%"PRIsVALUE":%p",
+ rb_obj_class(self), (void *)self);
+ int nid = EVP_PKEY_id(pkey);
+#ifdef OSSL_USE_PROVIDER
+ if (nid != EVP_PKEY_KEYMGMT)
+#endif
+ rb_str_catf(str, " oid=%s", OBJ_nid2sn(nid));
+#ifdef OSSL_USE_PROVIDER
+ rb_str_catf(str, " type_name=%s", EVP_PKEY_get0_type_name(pkey));
+ const OSSL_PROVIDER *prov = EVP_PKEY_get0_provider(pkey);
+ if (prov)
+ rb_str_catf(str, " provider=%s", OSSL_PROVIDER_get0_name(prov));
+#endif
+ rb_str_catf(str, ">");
+ return str;
}
/*
@@ -689,44 +814,33 @@ VALUE
ossl_pkey_export_traditional(int argc, VALUE *argv, VALUE self, int to_der)
{
EVP_PKEY *pkey;
- VALUE cipher, pass;
+ VALUE cipher, pass, cipher_holder;
const EVP_CIPHER *enc = NULL;
BIO *bio;
GetPKey(self, pkey);
rb_scan_args(argc, argv, "02", &cipher, &pass);
if (!NIL_P(cipher)) {
- enc = ossl_evp_get_cipherbyname(cipher);
- pass = ossl_pem_passwd_value(pass);
+ enc = ossl_evp_cipher_fetch(cipher, &cipher_holder);
+ pass = ossl_pem_passwd_value(pass);
}
bio = BIO_new(BIO_s_mem());
if (!bio)
- ossl_raise(ePKeyError, "BIO_new");
+ ossl_raise(ePKeyError, "BIO_new");
if (to_der) {
- if (!i2d_PrivateKey_bio(bio, pkey)) {
- BIO_free(bio);
- ossl_raise(ePKeyError, "i2d_PrivateKey_bio");
- }
+ if (!i2d_PrivateKey_bio(bio, pkey)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "i2d_PrivateKey_bio");
+ }
}
else {
-#if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_LIBRESSL_PREREQ(3, 5, 0)
- if (!PEM_write_bio_PrivateKey_traditional(bio, pkey, enc, NULL, 0,
- ossl_pem_passwd_cb,
- (void *)pass)) {
-#else
- char pem_str[80];
- const char *aname;
-
- EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &aname, pkey->ameth);
- snprintf(pem_str, sizeof(pem_str), "%s PRIVATE KEY", aname);
- if (!PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey, pem_str, bio,
- pkey, enc, NULL, 0, ossl_pem_passwd_cb,
- (void *)pass)) {
-#endif
- BIO_free(bio);
- ossl_raise(ePKeyError, "PEM_write_bio_PrivateKey_traditional");
- }
+ if (!PEM_write_bio_PrivateKey_traditional(bio, pkey, enc, NULL, 0,
+ ossl_pem_passwd_cb,
+ (void *)pass)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "PEM_write_bio_PrivateKey_traditional");
+ }
}
return ossl_membio2str(bio);
}
@@ -735,37 +849,37 @@ static VALUE
do_pkcs8_export(int argc, VALUE *argv, VALUE self, int to_der)
{
EVP_PKEY *pkey;
- VALUE cipher, pass;
+ VALUE cipher, pass, cipher_holder;
const EVP_CIPHER *enc = NULL;
BIO *bio;
GetPKey(self, pkey);
rb_scan_args(argc, argv, "02", &cipher, &pass);
if (argc > 0) {
- /*
- * TODO: EncryptedPrivateKeyInfo actually has more options.
- * Should they be exposed?
- */
- enc = ossl_evp_get_cipherbyname(cipher);
- pass = ossl_pem_passwd_value(pass);
+ /*
+ * TODO: EncryptedPrivateKeyInfo actually has more options.
+ * Should they be exposed?
+ */
+ enc = ossl_evp_cipher_fetch(cipher, &cipher_holder);
+ pass = ossl_pem_passwd_value(pass);
}
bio = BIO_new(BIO_s_mem());
if (!bio)
- ossl_raise(ePKeyError, "BIO_new");
+ ossl_raise(ePKeyError, "BIO_new");
if (to_der) {
- if (!i2d_PKCS8PrivateKey_bio(bio, pkey, enc, NULL, 0,
- ossl_pem_passwd_cb, (void *)pass)) {
- BIO_free(bio);
- ossl_raise(ePKeyError, "i2d_PKCS8PrivateKey_bio");
- }
+ if (!i2d_PKCS8PrivateKey_bio(bio, pkey, enc, NULL, 0,
+ ossl_pem_passwd_cb, (void *)pass)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "i2d_PKCS8PrivateKey_bio");
+ }
}
else {
- if (!PEM_write_bio_PKCS8PrivateKey(bio, pkey, enc, NULL, 0,
- ossl_pem_passwd_cb, (void *)pass)) {
- BIO_free(bio);
- ossl_raise(ePKeyError, "PEM_write_bio_PKCS8PrivateKey");
- }
+ if (!PEM_write_bio_PKCS8PrivateKey(bio, pkey, enc, NULL, 0,
+ ossl_pem_passwd_cb, (void *)pass)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "PEM_write_bio_PKCS8PrivateKey");
+ }
}
return ossl_membio2str(bio);
}
@@ -793,6 +907,18 @@ ossl_pkey_private_to_der(int argc, VALUE *argv, VALUE self)
*
* Serializes the private key to PEM-encoded PKCS #8 format. See #private_to_der
* for more details.
+ *
+ * An unencrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN PRIVATE KEY-----
+ * [...]
+ * -----END PRIVATE KEY-----
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN ENCRYPTED PRIVATE KEY-----
+ * [...]
+ * -----END ENCRYPTED PRIVATE KEY-----
*/
static VALUE
ossl_pkey_private_to_pem(int argc, VALUE *argv, VALUE self)
@@ -800,6 +926,33 @@ ossl_pkey_private_to_pem(int argc, VALUE *argv, VALUE self)
return do_pkcs8_export(argc, argv, self, 0);
}
+/*
+ * call-seq:
+ * pkey.raw_private_key => string
+ *
+ * See the OpenSSL documentation for EVP_PKEY_get_raw_private_key()
+ */
+
+static VALUE
+ossl_pkey_raw_private_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE str;
+ size_t len;
+
+ GetPKey(self, pkey);
+ if (EVP_PKEY_get_raw_private_key(pkey, NULL, &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_private_key");
+ str = rb_str_new(NULL, len);
+
+ if (EVP_PKEY_get_raw_private_key(pkey, (unsigned char *)RSTRING_PTR(str), &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_private_key");
+
+ rb_str_set_len(str, len);
+
+ return str;
+}
+
VALUE
ossl_pkey_export_spki(VALUE self, int to_der)
{
@@ -807,20 +960,21 @@ ossl_pkey_export_spki(VALUE self, int to_der)
BIO *bio;
GetPKey(self, pkey);
+ ossl_pkey_check_public_key(pkey);
bio = BIO_new(BIO_s_mem());
if (!bio)
- ossl_raise(ePKeyError, "BIO_new");
+ ossl_raise(ePKeyError, "BIO_new");
if (to_der) {
- if (!i2d_PUBKEY_bio(bio, pkey)) {
- BIO_free(bio);
- ossl_raise(ePKeyError, "i2d_PUBKEY_bio");
- }
+ if (!i2d_PUBKEY_bio(bio, pkey)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "i2d_PUBKEY_bio");
+ }
}
else {
- if (!PEM_write_bio_PUBKEY(bio, pkey)) {
- BIO_free(bio);
- ossl_raise(ePKeyError, "PEM_write_bio_PUBKEY");
- }
+ if (!PEM_write_bio_PUBKEY(bio, pkey)) {
+ BIO_free(bio);
+ ossl_raise(ePKeyError, "PEM_write_bio_PUBKEY");
+ }
}
return ossl_membio2str(bio);
}
@@ -842,6 +996,12 @@ ossl_pkey_public_to_der(VALUE self)
* pkey.public_to_pem -> string
*
* Serializes the public key to PEM-encoded X.509 SubjectPublicKeyInfo format.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
*/
static VALUE
ossl_pkey_public_to_pem(VALUE self)
@@ -851,6 +1011,33 @@ ossl_pkey_public_to_pem(VALUE self)
/*
* call-seq:
+ * pkey.raw_public_key => string
+ *
+ * See the OpenSSL documentation for EVP_PKEY_get_raw_public_key()
+ */
+
+static VALUE
+ossl_pkey_raw_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE str;
+ size_t len;
+
+ GetPKey(self, pkey);
+ if (EVP_PKEY_get_raw_public_key(pkey, NULL, &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_public_key");
+ str = rb_str_new(NULL, len);
+
+ if (EVP_PKEY_get_raw_public_key(pkey, (unsigned char *)RSTRING_PTR(str), &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_public_key");
+
+ rb_str_set_len(str, len);
+
+ return str;
+}
+
+/*
+ * call-seq:
* pkey.compare?(another_pkey) -> true | false
*
* Used primarily to check if an OpenSSL::X509::Certificate#public_key compares to its private key.
@@ -924,7 +1111,7 @@ static VALUE
ossl_pkey_sign(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
- VALUE digest, data, options, sig;
+ VALUE digest, data, options, sig, md_holder;
const EVP_MD *md = NULL;
EVP_MD_CTX *ctx;
EVP_PKEY_CTX *pctx;
@@ -934,7 +1121,7 @@ ossl_pkey_sign(int argc, VALUE *argv, VALUE self)
pkey = GetPrivPKeyPtr(self);
rb_scan_args(argc, argv, "21", &digest, &data, &options);
if (!NIL_P(digest))
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(data);
ctx = EVP_MD_CTX_new();
@@ -951,7 +1138,6 @@ ossl_pkey_sign(int argc, VALUE *argv, VALUE self)
rb_jump_tag(state);
}
}
-#if OSSL_OPENSSL_PREREQ(1, 1, 1) || OSSL_LIBRESSL_PREREQ(3, 4, 0)
if (EVP_DigestSign(ctx, NULL, &siglen, (unsigned char *)RSTRING_PTR(data),
RSTRING_LEN(data)) < 1) {
EVP_MD_CTX_free(ctx);
@@ -972,30 +1158,6 @@ ossl_pkey_sign(int argc, VALUE *argv, VALUE self)
EVP_MD_CTX_free(ctx);
ossl_raise(ePKeyError, "EVP_DigestSign");
}
-#else
- if (EVP_DigestSignUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data)) < 1) {
- EVP_MD_CTX_free(ctx);
- ossl_raise(ePKeyError, "EVP_DigestSignUpdate");
- }
- if (EVP_DigestSignFinal(ctx, NULL, &siglen) < 1) {
- EVP_MD_CTX_free(ctx);
- ossl_raise(ePKeyError, "EVP_DigestSignFinal");
- }
- if (siglen > LONG_MAX) {
- EVP_MD_CTX_free(ctx);
- rb_raise(ePKeyError, "signature would be too large");
- }
- sig = ossl_str_new(NULL, (long)siglen, &state);
- if (state) {
- EVP_MD_CTX_free(ctx);
- rb_jump_tag(state);
- }
- if (EVP_DigestSignFinal(ctx, (unsigned char *)RSTRING_PTR(sig),
- &siglen) < 1) {
- EVP_MD_CTX_free(ctx);
- ossl_raise(ePKeyError, "EVP_DigestSignFinal");
- }
-#endif
EVP_MD_CTX_free(ctx);
rb_str_set_len(sig, siglen);
return sig;
@@ -1028,7 +1190,7 @@ static VALUE
ossl_pkey_verify(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
- VALUE digest, sig, data, options;
+ VALUE digest, sig, data, options, md_holder;
const EVP_MD *md = NULL;
EVP_MD_CTX *ctx;
EVP_PKEY_CTX *pctx;
@@ -1038,7 +1200,7 @@ ossl_pkey_verify(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "31", &digest, &sig, &data, &options);
ossl_pkey_check_public_key(pkey);
if (!NIL_P(digest))
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(sig);
StringValue(data);
@@ -1056,24 +1218,12 @@ ossl_pkey_verify(int argc, VALUE *argv, VALUE self)
rb_jump_tag(state);
}
}
-#if OSSL_OPENSSL_PREREQ(1, 1, 1) || OSSL_LIBRESSL_PREREQ(3, 4, 0)
ret = EVP_DigestVerify(ctx, (unsigned char *)RSTRING_PTR(sig),
RSTRING_LEN(sig), (unsigned char *)RSTRING_PTR(data),
RSTRING_LEN(data));
EVP_MD_CTX_free(ctx);
if (ret < 0)
ossl_raise(ePKeyError, "EVP_DigestVerify");
-#else
- if (EVP_DigestVerifyUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data)) < 1) {
- EVP_MD_CTX_free(ctx);
- ossl_raise(ePKeyError, "EVP_DigestVerifyUpdate");
- }
- ret = EVP_DigestVerifyFinal(ctx, (unsigned char *)RSTRING_PTR(sig),
- RSTRING_LEN(sig));
- EVP_MD_CTX_free(ctx);
- if (ret < 0)
- ossl_raise(ePKeyError, "EVP_DigestVerifyFinal");
-#endif
if (ret)
return Qtrue;
else {
@@ -1119,7 +1269,7 @@ static VALUE
ossl_pkey_sign_raw(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
- VALUE digest, data, options, sig;
+ VALUE digest, data, options, sig, md_holder;
const EVP_MD *md = NULL;
EVP_PKEY_CTX *ctx;
size_t outlen;
@@ -1128,7 +1278,7 @@ ossl_pkey_sign_raw(int argc, VALUE *argv, VALUE self)
GetPKey(self, pkey);
rb_scan_args(argc, argv, "21", &digest, &data, &options);
if (!NIL_P(digest))
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(data);
ctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
@@ -1195,7 +1345,7 @@ static VALUE
ossl_pkey_verify_raw(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
- VALUE digest, sig, data, options;
+ VALUE digest, sig, data, options, md_holder;
const EVP_MD *md = NULL;
EVP_PKEY_CTX *ctx;
int state, ret;
@@ -1204,7 +1354,7 @@ ossl_pkey_verify_raw(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "31", &digest, &sig, &data, &options);
ossl_pkey_check_public_key(pkey);
if (!NIL_P(digest))
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(sig);
StringValue(data);
@@ -1258,7 +1408,7 @@ static VALUE
ossl_pkey_verify_recover(int argc, VALUE *argv, VALUE self)
{
EVP_PKEY *pkey;
- VALUE digest, sig, options, out;
+ VALUE digest, sig, options, out, md_holder;
const EVP_MD *md = NULL;
EVP_PKEY_CTX *ctx;
int state;
@@ -1268,7 +1418,7 @@ ossl_pkey_verify_recover(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "21", &digest, &sig, &options);
ossl_pkey_check_public_key(pkey);
if (!NIL_P(digest))
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(sig);
ctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
@@ -1346,8 +1496,10 @@ ossl_pkey_derive(int argc, VALUE *argv, VALUE self)
EVP_PKEY_CTX_free(ctx);
ossl_raise(ePKeyError, "EVP_PKEY_derive");
}
- if (keylen > LONG_MAX)
+ if (keylen > LONG_MAX) {
+ EVP_PKEY_CTX_free(ctx);
rb_raise(ePKeyError, "derived key would be too large");
+ }
str = ossl_str_new(NULL, (long)keylen, &state);
if (state) {
EVP_PKEY_CTX_free(ctx);
@@ -1508,11 +1660,6 @@ void
Init_ossl_pkey(void)
{
#undef rb_intern
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
/* Document-module: OpenSSL::PKey
*
* == Asymmetric Public Key Algorithms
@@ -1568,7 +1715,16 @@ Init_ossl_pkey(void)
/* Document-class: OpenSSL::PKey::PKeyError
*
- *Raised when errors occur during PKey#sign or PKey#verify.
+ * Raised when errors occur during PKey#sign or PKey#verify.
+ *
+ * Before version 4.0.0, OpenSSL::PKey::PKeyError had the following
+ * subclasses. These subclasses have been removed and the constants are
+ * now defined as aliases of OpenSSL::PKey::PKeyError.
+ *
+ * * OpenSSL::PKey::DHError
+ * * OpenSSL::PKey::DSAError
+ * * OpenSSL::PKey::ECError
+ * * OpenSSL::PKey::RSAError
*/
ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
@@ -1586,6 +1742,8 @@ Init_ossl_pkey(void)
rb_define_module_function(mPKey, "read", ossl_pkey_new_from_data, -1);
rb_define_module_function(mPKey, "generate_parameters", ossl_pkey_s_generate_parameters, -1);
rb_define_module_function(mPKey, "generate_key", ossl_pkey_s_generate_key, -1);
+ rb_define_module_function(mPKey, "new_raw_private_key", ossl_pkey_new_raw_private_key, 2);
+ rb_define_module_function(mPKey, "new_raw_public_key", ossl_pkey_new_raw_public_key, 2);
rb_define_alloc_func(cPKey, ossl_pkey_alloc);
rb_define_method(cPKey, "initialize", ossl_pkey_initialize, 0);
@@ -1601,6 +1759,8 @@ Init_ossl_pkey(void)
rb_define_method(cPKey, "private_to_pem", ossl_pkey_private_to_pem, -1);
rb_define_method(cPKey, "public_to_der", ossl_pkey_public_to_der, 0);
rb_define_method(cPKey, "public_to_pem", ossl_pkey_public_to_pem, 0);
+ rb_define_method(cPKey, "raw_private_key", ossl_pkey_raw_private_key, 0);
+ rb_define_method(cPKey, "raw_public_key", ossl_pkey_raw_public_key, 0);
rb_define_method(cPKey, "compare?", ossl_pkey_compare, 1);
rb_define_method(cPKey, "sign", ossl_pkey_sign, -1);
diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h
index 10669b824c..efba33b752 100644
--- a/ext/openssl/ossl_pkey.h
+++ b/ext/openssl/ossl_pkey.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(OSSL_PKEY_H)
#define OSSL_PKEY_H
@@ -22,12 +22,12 @@ extern const rb_data_type_t ossl_evp_pkey_type;
#define GetPKey(obj, pkey) do {\
TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
if (!(pkey)) { \
- rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
} \
} while (0)
/* Takes ownership of the EVP_PKEY */
-VALUE ossl_pkey_new(EVP_PKEY *);
+VALUE ossl_pkey_wrap(EVP_PKEY *);
void ossl_pkey_check_public_key(const EVP_PKEY *);
EVP_PKEY *ossl_pkey_read_generic(BIO *, VALUE);
EVP_PKEY *GetPKeyPtr(VALUE);
@@ -45,7 +45,7 @@ VALUE ossl_pkey_export_spki(VALUE self, int to_der);
* #to_der.
*/
VALUE ossl_pkey_export_traditional(int argc, VALUE *argv, VALUE self,
- int to_der);
+ int to_der);
void Init_ossl_pkey(void);
@@ -53,152 +53,140 @@ void Init_ossl_pkey(void);
* RSA
*/
extern VALUE cRSA;
-extern VALUE eRSAError;
-
void Init_ossl_rsa(void);
/*
* DSA
*/
extern VALUE cDSA;
-extern VALUE eDSAError;
-
void Init_ossl_dsa(void);
/*
* DH
*/
extern VALUE cDH;
-extern VALUE eDHError;
-
void Init_ossl_dh(void);
/*
* EC
*/
extern VALUE cEC;
-extern VALUE eECError;
-extern VALUE cEC_GROUP;
-extern VALUE eEC_GROUP;
-extern VALUE cEC_POINT;
-extern VALUE eEC_POINT;
-VALUE ossl_ec_new(EVP_PKEY *);
void Init_ossl_ec(void);
-#define OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, _name, _get) \
-/* \
- * call-seq: \
- * _keytype##.##_name -> aBN \
- */ \
-static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
-{ \
- const _type *obj; \
- const BIGNUM *bn; \
- \
- Get##_type(self, obj); \
- _get; \
- if (bn == NULL) \
- return Qnil; \
- return ossl_bn_new(bn); \
+#define OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, _name, _get) \
+/* \
+ * call-seq: \
+ * _keytype##.##_name -> aBN \
+ */ \
+static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
+{ \
+ const _type *obj; \
+ const BIGNUM *bn; \
+ \
+ Get##_type(self, obj); \
+ _get; \
+ if (bn == NULL) \
+ return Qnil; \
+ return ossl_bn_new(bn); \
}
-#define OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
- OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
- _type##_get0_##_group(obj, &bn, NULL, NULL)) \
- OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
- _type##_get0_##_group(obj, NULL, &bn, NULL)) \
- OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a3, \
- _type##_get0_##_group(obj, NULL, NULL, &bn))
-
-#define OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
- OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
- _type##_get0_##_group(obj, &bn, NULL)) \
- OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
- _type##_get0_##_group(obj, NULL, &bn))
-
-#if !OSSL_OPENSSL_PREREQ(3, 0, 0)
-#define OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
-/* \
- * call-seq: \
- * _keytype##.set_##_group(a1, a2, a3) -> self \
- */ \
+#define OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
+ _type##_get0_##_group(obj, &bn, NULL, NULL)) \
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
+ _type##_get0_##_group(obj, NULL, &bn, NULL)) \
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a3, \
+ _type##_get0_##_group(obj, NULL, NULL, &bn))
+
+#define OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
+ _type##_get0_##_group(obj, &bn, NULL)) \
+ OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
+ _type##_get0_##_group(obj, NULL, &bn))
+
+#ifndef OSSL_HAVE_IMMUTABLE_PKEY
+#define OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
+/* \
+ * call-seq: \
+ * _keytype##.set_##_group(a1, a2, a3) -> self \
+ */ \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2, VALUE v3) \
-{ \
- _type *obj; \
- BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
- BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
- BIGNUM *bn3 = NULL, *orig_bn3 = NIL_P(v3) ? NULL : GetBNPtr(v3);\
- \
- Get##_type(self, obj); \
- if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
- (orig_bn2 && !(bn2 = BN_dup(orig_bn2))) || \
- (orig_bn3 && !(bn3 = BN_dup(orig_bn3)))) { \
- BN_clear_free(bn1); \
- BN_clear_free(bn2); \
- BN_clear_free(bn3); \
- ossl_raise(eBNError, NULL); \
- } \
- \
- if (!_type##_set0_##_group(obj, bn1, bn2, bn3)) { \
- BN_clear_free(bn1); \
- BN_clear_free(bn2); \
- BN_clear_free(bn3); \
- ossl_raise(ePKeyError, #_type"_set0_"#_group); \
- } \
- return self; \
+{ \
+ _type *obj; \
+ BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
+ BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
+ BIGNUM *bn3 = NULL, *orig_bn3 = NIL_P(v3) ? NULL : GetBNPtr(v3);\
+ \
+ Get##_type(self, obj); \
+ if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
+ (orig_bn2 && !(bn2 = BN_dup(orig_bn2))) || \
+ (orig_bn3 && !(bn3 = BN_dup(orig_bn3)))) { \
+ BN_clear_free(bn1); \
+ BN_clear_free(bn2); \
+ BN_clear_free(bn3); \
+ ossl_raise(ePKeyError, "BN_dup"); \
+ } \
+ \
+ if (!_type##_set0_##_group(obj, bn1, bn2, bn3)) { \
+ BN_clear_free(bn1); \
+ BN_clear_free(bn2); \
+ BN_clear_free(bn3); \
+ ossl_raise(ePKeyError, #_type"_set0_"#_group); \
+ } \
+ return self; \
}
-#define OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
-/* \
- * call-seq: \
- * _keytype##.set_##_group(a1, a2) -> self \
- */ \
+#define OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
+/* \
+ * call-seq: \
+ * _keytype##.set_##_group(a1, a2) -> self \
+ */ \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2) \
-{ \
- _type *obj; \
- BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
- BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
- \
- Get##_type(self, obj); \
- if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
- (orig_bn2 && !(bn2 = BN_dup(orig_bn2)))) { \
- BN_clear_free(bn1); \
- BN_clear_free(bn2); \
- ossl_raise(eBNError, NULL); \
- } \
- \
- if (!_type##_set0_##_group(obj, bn1, bn2)) { \
- BN_clear_free(bn1); \
- BN_clear_free(bn2); \
- ossl_raise(ePKeyError, #_type"_set0_"#_group); \
- } \
- return self; \
+{ \
+ _type *obj; \
+ BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
+ BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
+ \
+ Get##_type(self, obj); \
+ if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
+ (orig_bn2 && !(bn2 = BN_dup(orig_bn2)))) { \
+ BN_clear_free(bn1); \
+ BN_clear_free(bn2); \
+ ossl_raise(ePKeyError, "BN_dup"); \
+ } \
+ \
+ if (!_type##_set0_##_group(obj, bn1, bn2)) { \
+ BN_clear_free(bn1); \
+ BN_clear_free(bn2); \
+ ossl_raise(ePKeyError, #_type"_set0_"#_group); \
+ } \
+ return self; \
}
#else
-#define OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
+#define OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2, VALUE v3) \
-{ \
- rb_raise(ePKeyError, \
+{ \
+ rb_raise(ePKeyError, \
#_keytype"#set_"#_group"= is incompatible with OpenSSL 3.0"); \
}
-#define OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
+#define OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2) \
-{ \
- rb_raise(ePKeyError, \
+{ \
+ rb_raise(ePKeyError, \
#_keytype"#set_"#_group"= is incompatible with OpenSSL 3.0"); \
}
#endif
-#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3) \
- OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
- OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3)
+#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3) \
+ OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
+ OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3)
-#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2) \
- OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
- OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2)
+#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2) \
+ OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
+ OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2)
-#define DEF_OSSL_PKEY_BN(class, keytype, name) \
- rb_define_method((class), #name, ossl_##keytype##_get_##name, 0)
+#define DEF_OSSL_PKEY_BN(class, keytype, name) \
+ rb_define_method((class), #name, ossl_##keytype##_get_##name, 0)
#endif /* OSSL_PKEY_H */
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 83c41378fe..3f2975c5a3 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -14,20 +14,21 @@
#define GetPKeyDH(obj, pkey) do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) { /* PARANOIA? */ \
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
} \
} while (0)
#define GetDH(obj, dh) do { \
EVP_PKEY *_pkey; \
GetPKeyDH((obj), _pkey); \
(dh) = EVP_PKEY_get0_DH(_pkey); \
+ if ((dh) == NULL) \
+ ossl_raise(ePKeyError, "failed to get DH from EVP_PKEY"); \
} while (0)
/*
* Classes
*/
VALUE cDH;
-VALUE eDHError;
/*
* Private
@@ -43,6 +44,7 @@ VALUE eDHError;
* If called without arguments, an empty instance without any parameter or key
* components is created. Use #set_pqg to manually set the parameters afterwards
* (and optionally #set_key to set private and public key components).
+ * This form is not compatible with OpenSSL 3.0 or later.
*
* If a String is given, tries to parse it as a DER- or PEM- encoded parameters.
* See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -58,14 +60,15 @@ VALUE eDHError;
*
* Examples:
* # Creating an instance from scratch
- * # Note that this is deprecated and will not work on OpenSSL 3.0 or later.
+ * # Note that this is deprecated and will result in ArgumentError when
+ * # using OpenSSL 3.0 or later.
* dh = OpenSSL::PKey::DH.new
* dh.set_pqg(bn_p, nil, bn_g)
*
* # Generating a parameters and a key pair
* dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048)
*
- * # Reading DH parameters
+ * # Reading DH parameters from a PEM-encoded string
* dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only
* dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair
*/
@@ -84,10 +87,15 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
/* The DH.new(size, generator) form is handled by lib/openssl/pkey.rb */
if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
+ rb_raise(rb_eArgError, "OpenSSL::PKey::DH.new cannot be called " \
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
+#else
dh = DH_new();
if (!dh)
- ossl_raise(eDHError, "DH_new");
+ ossl_raise(ePKeyError, "DH_new");
goto legacy;
+#endif
}
arg = ossl_to_der_if_possible(arg);
@@ -105,12 +113,12 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
pkey = ossl_pkey_read_generic(in, Qnil);
BIO_free(in);
if (!pkey)
- ossl_raise(eDHError, "could not parse pkey");
+ ossl_raise(ePKeyError, "could not parse pkey");
type = EVP_PKEY_base_id(pkey);
if (type != EVP_PKEY_DH) {
EVP_PKEY_free(pkey);
- rb_raise(eDHError, "incorrect pkey type: %s", OBJ_nid2sn(type));
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
}
RTYPEDDATA_DATA(self) = pkey;
return self;
@@ -121,13 +129,14 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
if (!pkey || EVP_PKEY_assign_DH(pkey, dh) != 1) {
EVP_PKEY_free(pkey);
DH_free(dh);
- ossl_raise(eDHError, "EVP_PKEY_assign_DH");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_DH");
}
RTYPEDDATA_DATA(self) = pkey;
return self;
}
#ifndef HAVE_EVP_PKEY_DUP
+/* :nodoc: */
static VALUE
ossl_dh_initialize_copy(VALUE self, VALUE other)
{
@@ -142,26 +151,26 @@ ossl_dh_initialize_copy(VALUE self, VALUE other)
dh = DHparams_dup(dh_other);
if (!dh)
- ossl_raise(eDHError, "DHparams_dup");
+ ossl_raise(ePKeyError, "DHparams_dup");
DH_get0_key(dh_other, &pub, &priv);
if (pub) {
- BIGNUM *pub2 = BN_dup(pub);
- BIGNUM *priv2 = BN_dup(priv);
+ BIGNUM *pub2 = BN_dup(pub);
+ BIGNUM *priv2 = BN_dup(priv);
if (!pub2 || (priv && !priv2)) {
- BN_clear_free(pub2);
- BN_clear_free(priv2);
- ossl_raise(eDHError, "BN_dup");
- }
- DH_set0_key(dh, pub2, priv2);
+ BN_clear_free(pub2);
+ BN_clear_free(priv2);
+ ossl_raise(ePKeyError, "BN_dup");
+ }
+ DH_set0_key(dh, pub2, priv2);
}
pkey = EVP_PKEY_new();
if (!pkey || EVP_PKEY_assign_DH(pkey, dh) != 1) {
EVP_PKEY_free(pkey);
DH_free(dh);
- ossl_raise(eDHError, "EVP_PKEY_assign_DH");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_DH");
}
RTYPEDDATA_DATA(self) = pkey;
return self;
@@ -216,9 +225,20 @@ ossl_dh_is_private(VALUE self)
* dh.to_pem -> aString
* dh.to_s -> aString
*
- * Encodes this DH to its PEM encoding. Note that any existing per-session
- * public/private keys will *not* get encoded, just the Diffie-Hellman
- * parameters will be encoded.
+ * Serializes the DH parameters to a PEM-encoding.
+ *
+ * Note that any existing per-session public/private keys will *not* get
+ * encoded, just the Diffie-Hellman parameters will be encoded.
+ *
+ * PEM-encoded parameters will look like:
+ *
+ * -----BEGIN DH PARAMETERS-----
+ * [...]
+ * -----END DH PARAMETERS-----
+ *
+ * See also #public_to_pem (X.509 SubjectPublicKeyInfo) and
+ * #private_to_pem (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for
+ * serialization with the private or public key components.
*/
static VALUE
ossl_dh_export(VALUE self)
@@ -229,11 +249,11 @@ ossl_dh_export(VALUE self)
GetDH(self, dh);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eDHError, NULL);
+ ossl_raise(ePKeyError, NULL);
}
if (!PEM_write_bio_DHparams(out, dh)) {
- BIO_free(out);
- ossl_raise(eDHError, NULL);
+ BIO_free(out);
+ ossl_raise(ePKeyError, NULL);
}
str = ossl_membio2str(out);
@@ -244,10 +264,14 @@ ossl_dh_export(VALUE self)
* call-seq:
* dh.to_der -> aString
*
- * Encodes this DH to its DER encoding. Note that any existing per-session
- * public/private keys will *not* get encoded, just the Diffie-Hellman
- * parameters will be encoded.
-
+ * Serializes the DH parameters to a DER-encoding
+ *
+ * Note that any existing per-session public/private keys will *not* get
+ * encoded, just the Diffie-Hellman parameters will be encoded.
+ *
+ * See also #public_to_der (X.509 SubjectPublicKeyInfo) and
+ * #private_to_der (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for
+ * serialization with the private or public key components.
*/
static VALUE
ossl_dh_to_der(VALUE self)
@@ -259,11 +283,11 @@ ossl_dh_to_der(VALUE self)
GetDH(self, dh);
if((len = i2d_DHparams(dh, NULL)) <= 0)
- ossl_raise(eDHError, NULL);
+ ossl_raise(ePKeyError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_DHparams(dh, &p) < 0)
- ossl_raise(eDHError, NULL);
+ ossl_raise(ePKeyError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -271,35 +295,6 @@ ossl_dh_to_der(VALUE self)
/*
* call-seq:
- * dh.params -> hash
- *
- * Stores all parameters of key to the hash
- * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
- * Don't use :-)) (I's up to you)
- */
-static VALUE
-ossl_dh_get_params(VALUE self)
-{
- OSSL_3_const DH *dh;
- VALUE hash;
- const BIGNUM *p, *q, *g, *pub_key, *priv_key;
-
- GetDH(self, dh);
- DH_get0_pqg(dh, &p, &q, &g);
- DH_get0_key(dh, &pub_key, &priv_key);
-
- hash = rb_hash_new();
- rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
- rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
- rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(g));
- rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pub_key));
- rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(priv_key));
-
- return hash;
-}
-
-/*
- * call-seq:
* dh.params_ok? -> true | false
*
* Validates the Diffie-Hellman parameters associated with this instance.
@@ -319,7 +314,7 @@ ossl_dh_check_params(VALUE self)
GetPKey(self, pkey);
pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
if (!pctx)
- ossl_raise(eDHError, "EVP_PKEY_CTX_new");
+ ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
ret = EVP_PKEY_param_check(pctx);
EVP_PKEY_CTX_free(pctx);
#else
@@ -362,19 +357,6 @@ OSSL_PKEY_BN_DEF2(dh, DH, key, pub_key, priv_key)
void
Init_ossl_dh(void)
{
-#if 0
- mPKey = rb_define_module_under(mOSSL, "PKey");
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
-#endif
-
- /* Document-class: OpenSSL::PKey::DHError
- *
- * Generic exception that is raised if an operation on a DH PKey
- * fails unexpectedly or in case an instantiation of an instance of DH
- * fails due to non-conformant input data.
- */
- eDHError = rb_define_class_under(mPKey, "DHError", ePKeyError);
/* Document-class: OpenSSL::PKey::DH
*
* An implementation of the Diffie-Hellman key exchange protocol based on
@@ -428,8 +410,6 @@ Init_ossl_dh(void)
DEF_OSSL_PKEY_BN(cDH, dh, priv_key);
rb_define_method(cDH, "set_pqg", ossl_dh_set_pqg, 3);
rb_define_method(cDH, "set_key", ossl_dh_set_key, 2);
-
- rb_define_method(cDH, "params", ossl_dh_get_params, 0);
}
#else /* defined NO_DH */
diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c
index b097f8c9d2..041646a058 100644
--- a/ext/openssl/ossl_pkey_dsa.c
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -14,13 +14,15 @@
#define GetPKeyDSA(obj, pkey) do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DSA) { /* PARANOIA? */ \
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
} \
} while (0)
#define GetDSA(obj, dsa) do { \
EVP_PKEY *_pkey; \
GetPKeyDSA((obj), _pkey); \
(dsa) = EVP_PKEY_get0_DSA(_pkey); \
+ if ((dsa) == NULL) \
+ ossl_raise(ePKeyError, "failed to get DSA from EVP_PKEY"); \
} while (0)
static inline int
@@ -41,7 +43,6 @@ DSA_PRIVATE(VALUE obj, OSSL_3_const DSA *dsa)
* Classes
*/
VALUE cDSA;
-VALUE eDSAError;
/*
* Private
@@ -56,6 +57,7 @@ VALUE eDSAError;
*
* If called without arguments, creates a new instance with no key components
* set. They can be set individually by #set_pqg and #set_key.
+ * This form is not compatible with OpenSSL 3.0 or later.
*
* If called with a String, tries to parse as DER or PEM encoding of a \DSA key.
* See also OpenSSL::PKey.read which can parse keys of any kinds.
@@ -96,10 +98,15 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
/* The DSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
rb_scan_args(argc, argv, "02", &arg, &pass);
if (argc == 0) {
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
+ rb_raise(rb_eArgError, "OpenSSL::PKey::DSA.new cannot be called " \
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
+#else
dsa = DSA_new();
if (!dsa)
- ossl_raise(eDSAError, "DSA_new");
+ ossl_raise(ePKeyError, "DSA_new");
goto legacy;
+#endif
}
pass = ossl_pem_passwd_value(pass);
@@ -117,12 +124,12 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
pkey = ossl_pkey_read_generic(in, pass);
BIO_free(in);
if (!pkey)
- ossl_raise(eDSAError, "Neither PUB key nor PRIV key");
+ ossl_raise(ePKeyError, "Neither PUB key nor PRIV key");
type = EVP_PKEY_base_id(pkey);
if (type != EVP_PKEY_DSA) {
EVP_PKEY_free(pkey);
- rb_raise(eDSAError, "incorrect pkey type: %s", OBJ_nid2sn(type));
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
}
RTYPEDDATA_DATA(self) = pkey;
return self;
@@ -133,13 +140,14 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
if (!pkey || EVP_PKEY_assign_DSA(pkey, dsa) != 1) {
EVP_PKEY_free(pkey);
DSA_free(dsa);
- ossl_raise(eDSAError, "EVP_PKEY_assign_DSA");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_DSA");
}
RTYPEDDATA_DATA(self) = pkey;
return self;
}
#ifndef HAVE_EVP_PKEY_DUP
+/* :nodoc: */
static VALUE
ossl_dsa_initialize_copy(VALUE self, VALUE other)
{
@@ -155,13 +163,13 @@ ossl_dsa_initialize_copy(VALUE self, VALUE other)
(d2i_of_void *)d2i_DSAPrivateKey,
(char *)dsa);
if (!dsa_new)
- ossl_raise(eDSAError, "ASN1_dup");
+ ossl_raise(ePKeyError, "ASN1_dup");
pkey = EVP_PKEY_new();
if (!pkey || EVP_PKEY_assign_DSA(pkey, dsa_new) != 1) {
EVP_PKEY_free(pkey);
DSA_free(dsa_new);
- ossl_raise(eDSAError, "EVP_PKEY_assign_DSA");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_DSA");
}
RTYPEDDATA_DATA(self) = pkey;
@@ -211,16 +219,58 @@ ossl_dsa_is_private(VALUE self)
* dsa.to_pem([cipher, password]) -> aString
* dsa.to_s([cipher, password]) -> aString
*
- * Encodes this DSA to its PEM encoding.
+ * Serializes a private or public key to a PEM-encoding.
+ *
+ * [When the key contains public components only]
+ *
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether it is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a traditional \OpenSSL DSAPrivateKey.
+ *
+ * A PEM-encoded key will look like:
*
- * === Parameters
- * * _cipher_ is an OpenSSL::Cipher.
- * * _password_ is a string containing your password.
+ * -----BEGIN DSA PRIVATE KEY-----
+ * [...]
+ * -----END DSA PRIVATE KEY-----
*
- * === Examples
- * DSA.to_pem -> aString
- * DSA.to_pem(cipher, 'mypassword') -> aString
+ * [When the key contains private components, and _cipher_ and _password_ are given]
*
+ * Serializes it into a traditional \OpenSSL DSAPrivateKey and encrypts it in
+ * OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN DSA PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END DSA PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the traditional, non-standard \OpenSSL format
+ * is required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_dsa_export(int argc, VALUE *argv, VALUE self)
@@ -238,8 +288,15 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* dsa.to_der -> aString
*
- * Encodes this DSA to its DER encoding.
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
*
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the traditional, non-standard \OpenSSL format
+ * is required.
+ *
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_dsa_to_der(VALUE self)
@@ -255,35 +312,6 @@ ossl_dsa_to_der(VALUE self)
/*
- * call-seq:
- * dsa.params -> hash
- *
- * Stores all parameters of key to the hash
- * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
- * Don't use :-)) (I's up to you)
- */
-static VALUE
-ossl_dsa_get_params(VALUE self)
-{
- OSSL_3_const DSA *dsa;
- VALUE hash;
- const BIGNUM *p, *q, *g, *pub_key, *priv_key;
-
- GetDSA(self, dsa);
- DSA_get0_pqg(dsa, &p, &q, &g);
- DSA_get0_key(dsa, &pub_key, &priv_key);
-
- hash = rb_hash_new();
- rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
- rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
- rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(g));
- rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pub_key));
- rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(priv_key));
-
- return hash;
-}
-
-/*
* Document-method: OpenSSL::PKey::DSA#set_pqg
* call-seq:
* dsa.set_pqg(p, q, g) -> self
@@ -306,20 +334,6 @@ OSSL_PKEY_BN_DEF2(dsa, DSA, key, pub_key, priv_key)
void
Init_ossl_dsa(void)
{
-#if 0
- mPKey = rb_define_module_under(mOSSL, "PKey");
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
-#endif
-
- /* Document-class: OpenSSL::PKey::DSAError
- *
- * Generic exception that is raised if an operation on a DSA PKey
- * fails unexpectedly or in case an instantiation of an instance of DSA
- * fails due to non-conformant input data.
- */
- eDSAError = rb_define_class_under(mPKey, "DSAError", ePKeyError);
-
/* Document-class: OpenSSL::PKey::DSA
*
* DSA, the Digital Signature Algorithm, is specified in NIST's
@@ -347,8 +361,6 @@ Init_ossl_dsa(void)
DEF_OSSL_PKEY_BN(cDSA, dsa, priv_key);
rb_define_method(cDSA, "set_pqg", ossl_dsa_set_pqg, 3);
rb_define_method(cDSA, "set_key", ossl_dsa_set_key, 2);
-
- rb_define_method(cDSA, "params", ossl_dsa_get_params, 0);
}
#else /* defined NO_DSA */
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
index 92842f95ac..35f031819d 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -15,25 +15,27 @@ static const rb_data_type_t ossl_ec_point_type;
#define GetPKeyEC(obj, pkey) do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC) { \
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
} \
} while (0)
#define GetEC(obj, key) do { \
EVP_PKEY *_pkey; \
GetPKeyEC(obj, _pkey); \
(key) = EVP_PKEY_get0_EC_KEY(_pkey); \
+ if ((key) == NULL) \
+ ossl_raise(ePKeyError, "failed to get EC_KEY from EVP_PKEY"); \
} while (0)
#define GetECGroup(obj, group) do { \
TypedData_Get_Struct(obj, EC_GROUP, &ossl_ec_group_type, group); \
if ((group) == NULL) \
- ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
+ ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
} while (0)
#define GetECPoint(obj, point) do { \
TypedData_Get_Struct(obj, EC_POINT, &ossl_ec_point_type, point); \
if ((point) == NULL) \
- ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
+ ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
} while (0)
#define GetECPointGroup(obj, group) do { \
VALUE _group = rb_attr_get(obj, id_i_group); \
@@ -41,17 +43,13 @@ static const rb_data_type_t ossl_ec_point_type;
} while (0)
VALUE cEC;
-VALUE eECError;
-VALUE cEC_GROUP;
-VALUE eEC_GROUP;
-VALUE cEC_POINT;
-VALUE eEC_POINT;
+static VALUE cEC_GROUP;
+static VALUE eEC_GROUP;
+static VALUE cEC_POINT;
+static VALUE eEC_POINT;
-static ID s_GFp, s_GF2m;
-
-static ID ID_uncompressed;
-static ID ID_compressed;
-static ID ID_hybrid;
+static VALUE sym_GFp, sym_GF2m;
+static VALUE sym_uncompressed, sym_compressed, sym_hybrid;
static ID id_i_group;
@@ -68,27 +66,27 @@ ec_key_new_from_group(VALUE arg)
EC_KEY *ec;
if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
- EC_GROUP *group;
+ EC_GROUP *group;
- GetECGroup(arg, group);
- if (!(ec = EC_KEY_new()))
- ossl_raise(eECError, NULL);
+ GetECGroup(arg, group);
+ if (!(ec = EC_KEY_new()))
+ ossl_raise(ePKeyError, NULL);
- if (!EC_KEY_set_group(ec, group)) {
- EC_KEY_free(ec);
- ossl_raise(eECError, NULL);
- }
+ if (!EC_KEY_set_group(ec, group)) {
+ EC_KEY_free(ec);
+ ossl_raise(ePKeyError, NULL);
+ }
} else {
- int nid = OBJ_sn2nid(StringValueCStr(arg));
+ int nid = OBJ_sn2nid(StringValueCStr(arg));
- if (nid == NID_undef)
- ossl_raise(eECError, "invalid curve name");
+ if (nid == NID_undef)
+ ossl_raise(ePKeyError, "invalid curve name");
- if (!(ec = EC_KEY_new_by_curve_name(nid)))
- ossl_raise(eECError, NULL);
+ if (!(ec = EC_KEY_new_by_curve_name(nid)))
+ ossl_raise(ePKeyError, NULL);
- EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
- EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
+ EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
+ EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
}
return ec;
@@ -115,12 +113,12 @@ ossl_ec_key_s_generate(VALUE klass, VALUE arg)
if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) {
EVP_PKEY_free(pkey);
EC_KEY_free(ec);
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
}
RTYPEDDATA_DATA(obj) = pkey;
if (!EC_KEY_generate_key(ec))
- ossl_raise(eECError, "EC_KEY_generate_key");
+ ossl_raise(ePKeyError, "EC_KEY_generate_key");
return obj;
}
@@ -150,9 +148,14 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "02", &arg, &pass);
if (NIL_P(arg)) {
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
+ rb_raise(rb_eArgError, "OpenSSL::PKey::EC.new cannot be called " \
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
+#else
if (!(ec = EC_KEY_new()))
- ossl_raise(eECError, "EC_KEY_new");
+ ossl_raise(ePKeyError, "EC_KEY_new");
goto legacy;
+#endif
}
else if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
ec = ec_key_new_from_group(arg);
@@ -174,7 +177,7 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
type = EVP_PKEY_base_id(pkey);
if (type != EVP_PKEY_EC) {
EVP_PKEY_free(pkey);
- rb_raise(eDSAError, "incorrect pkey type: %s", OBJ_nid2sn(type));
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
}
RTYPEDDATA_DATA(self) = pkey;
return self;
@@ -184,13 +187,14 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) {
EVP_PKEY_free(pkey);
EC_KEY_free(ec);
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
}
RTYPEDDATA_DATA(self) = pkey;
return self;
}
#ifndef HAVE_EVP_PKEY_DUP
+/* :nodoc: */
static VALUE
ossl_ec_key_initialize_copy(VALUE self, VALUE other)
{
@@ -204,12 +208,12 @@ ossl_ec_key_initialize_copy(VALUE self, VALUE other)
ec_new = EC_KEY_dup(ec);
if (!ec_new)
- ossl_raise(eECError, "EC_KEY_dup");
+ ossl_raise(ePKeyError, "EC_KEY_dup");
pkey = EVP_PKEY_new();
if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec_new) != 1) {
EC_KEY_free(ec_new);
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
}
RTYPEDDATA_DATA(self) = pkey;
@@ -233,7 +237,7 @@ ossl_ec_key_get_group(VALUE self)
GetEC(self, ec);
group = EC_KEY_get0_group(ec);
if (!group)
- return Qnil;
+ return Qnil;
return ec_group_new(group);
}
@@ -248,7 +252,7 @@ ossl_ec_key_get_group(VALUE self)
static VALUE
ossl_ec_key_set_group(VALUE self, VALUE group_v)
{
-#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
#else
EC_KEY *ec;
@@ -258,7 +262,7 @@ ossl_ec_key_set_group(VALUE self, VALUE group_v)
GetECGroup(group_v, group);
if (EC_KEY_set_group(ec, group) != 1)
- ossl_raise(eECError, "EC_KEY_set_group");
+ ossl_raise(ePKeyError, "EC_KEY_set_group");
return group_v;
#endif
@@ -290,7 +294,7 @@ static VALUE ossl_ec_key_get_private_key(VALUE self)
*/
static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
{
-#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
#else
EC_KEY *ec;
@@ -301,14 +305,14 @@ static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
bn = GetBNPtr(private_key);
switch (EC_KEY_set_private_key(ec, bn)) {
- case 1:
+ case 1:
break;
- case 0:
+ case 0:
if (bn == NULL)
break;
- /* fallthrough */
- default:
- ossl_raise(eECError, "EC_KEY_set_private_key");
+ /* fallthrough */
+ default:
+ ossl_raise(ePKeyError, "EC_KEY_set_private_key");
}
return private_key;
@@ -341,7 +345,7 @@ static VALUE ossl_ec_key_get_public_key(VALUE self)
*/
static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
{
-#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
#else
EC_KEY *ec;
@@ -352,14 +356,14 @@ static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
GetECPoint(public_key, point);
switch (EC_KEY_set_public_key(ec, point)) {
- case 1:
+ case 1:
break;
- case 0:
+ case 0:
if (point == NULL)
break;
- /* fallthrough */
- default:
- ossl_raise(eECError, "EC_KEY_set_public_key");
+ /* fallthrough */
+ default:
+ ossl_raise(ePKeyError, "EC_KEY_set_public_key");
}
return public_key;
@@ -400,13 +404,61 @@ static VALUE ossl_ec_key_is_private(VALUE self)
/*
* call-seq:
- * key.export([cipher, pass_phrase]) => String
- * key.to_pem([cipher, pass_phrase]) => String
+ * key.export([cipher, password]) => String
+ * key.to_pem([cipher, password]) => String
+ *
+ * Serializes a private or public key to a PEM-encoding.
+ *
+ * [When the key contains public components only]
+ *
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether it is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a SEC 1/RFC 5915 ECPrivateKey.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN EC PRIVATE KEY-----
+ * [...]
+ * -----END EC PRIVATE KEY-----
*
- * Outputs the EC key in PEM encoding. If _cipher_ and _pass_phrase_ are given
- * they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher
- * instance. Note that encryption will only be effective for a private key,
- * public keys will always be encoded in plain text.
+ * [When the key contains private components, and _cipher_ and _password_ are given]
+ *
+ * Serializes it into a SEC 1/RFC 5915 ECPrivateKey
+ * and encrypts it in OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN EC PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END EC PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the SEC 1/RFC 5915 ECPrivateKey format is
+ * required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
@@ -415,7 +467,7 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
GetEC(self, ec);
if (EC_KEY_get0_public_key(ec) == NULL)
- ossl_raise(eECError, "can't export - no public key set");
+ ossl_raise(ePKeyError, "can't export - no public key set");
if (EC_KEY_get0_private_key(ec))
return ossl_pkey_export_traditional(argc, argv, self, 0);
else
@@ -426,7 +478,15 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* key.to_der => String
*
- * See the OpenSSL documentation for i2d_ECPrivateKey_bio()
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the SEC 1/RFC 5915 ECPrivateKey format is
+ * required.
+ *
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_ec_key_to_der(VALUE self)
@@ -435,7 +495,7 @@ ossl_ec_key_to_der(VALUE self)
GetEC(self, ec);
if (EC_KEY_get0_public_key(ec) == NULL)
- ossl_raise(eECError, "can't export - no public key set");
+ ossl_raise(ePKeyError, "can't export - no public key set");
if (EC_KEY_get0_private_key(ec))
return ossl_pkey_export_traditional(0, NULL, self, 1);
else
@@ -457,14 +517,14 @@ ossl_ec_key_to_der(VALUE self)
*/
static VALUE ossl_ec_key_generate_key(VALUE self)
{
-#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
#else
EC_KEY *ec;
GetEC(self, ec);
if (EC_KEY_generate_key(ec) != 1)
- ossl_raise(eECError, "EC_KEY_generate_key");
+ ossl_raise(ePKeyError, "EC_KEY_generate_key");
return self;
#endif
@@ -489,18 +549,18 @@ static VALUE ossl_ec_key_check_key(VALUE self)
GetEC(self, ec);
pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
if (!pctx)
- ossl_raise(eECError, "EVP_PKEY_CTX_new");
+ ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
if (EC_KEY_get0_private_key(ec) != NULL) {
if (EVP_PKEY_check(pctx) != 1) {
EVP_PKEY_CTX_free(pctx);
- ossl_raise(eECError, "EVP_PKEY_check");
+ ossl_raise(ePKeyError, "EVP_PKEY_check");
}
}
else {
if (EVP_PKEY_public_check(pctx) != 1) {
EVP_PKEY_CTX_free(pctx);
- ossl_raise(eECError, "EVP_PKEY_public_check");
+ ossl_raise(ePKeyError, "EVP_PKEY_public_check");
}
}
@@ -510,7 +570,7 @@ static VALUE ossl_ec_key_check_key(VALUE self)
GetEC(self, ec);
if (EC_KEY_check_key(ec) != 1)
- ossl_raise(eECError, "EC_KEY_check_key");
+ ossl_raise(ePKeyError, "EC_KEY_check_key");
#endif
return Qtrue;
@@ -528,9 +588,9 @@ ossl_ec_group_free(void *ptr)
static const rb_data_type_t ossl_ec_group_type = {
"OpenSSL/ec_group",
{
- 0, ossl_ec_group_free,
+ 0, ossl_ec_group_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -548,7 +608,7 @@ ec_group_new(const EC_GROUP *group)
obj = ossl_ec_group_alloc(cEC_GROUP);
group_new = EC_GROUP_dup(group);
if (!group_new)
- ossl_raise(eEC_GROUP, "EC_GROUP_dup");
+ ossl_raise(eEC_GROUP, "EC_GROUP_dup");
RTYPEDDATA_DATA(obj) = group_new;
return obj;
@@ -576,7 +636,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
ossl_raise(rb_eRuntimeError, "EC_GROUP is already initialized");
switch (rb_scan_args(argc, argv, "13", &arg1, &arg2, &arg3, &arg4)) {
- case 1:
+ case 1:
if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
const EC_GROUP *arg1_group;
@@ -588,7 +648,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
if (!group) {
- OSSL_BIO_reset(in);
+ OSSL_BIO_reset(in);
group = d2i_ECPKParameters_bio(in, NULL);
}
@@ -598,11 +658,14 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
const char *name = StringValueCStr(arg1);
int nid = OBJ_sn2nid(name);
- ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
+ ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
if (nid == NID_undef)
ossl_raise(eEC_GROUP, "unknown curve name (%"PRIsVALUE")", arg1);
-
+#if !defined(OPENSSL_IS_AWSLC)
group = EC_GROUP_new_by_curve_name(nid);
+#else /* EC_GROUPs are static and immutable by default in AWS-LC. */
+ group = EC_GROUP_new_by_curve_name_mutable(nid);
+#endif
if (group == NULL)
ossl_raise(eEC_GROUP, "unable to create curve (%"PRIsVALUE")", arg1);
@@ -612,33 +675,34 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
}
break;
- case 4:
+ case 4:
if (SYMBOL_P(arg1)) {
- ID id = SYM2ID(arg1);
EC_GROUP *(*new_curve)(const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL;
const BIGNUM *p = GetBNPtr(arg2);
const BIGNUM *a = GetBNPtr(arg3);
const BIGNUM *b = GetBNPtr(arg4);
- if (id == s_GFp) {
+ if (arg1 == sym_GFp) {
new_curve = EC_GROUP_new_curve_GFp;
+ }
#if !defined(OPENSSL_NO_EC2M)
- } else if (id == s_GF2m) {
+ else if (arg1 == sym_GF2m) {
new_curve = EC_GROUP_new_curve_GF2m;
+ }
#endif
- } else {
+ else {
ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
}
if ((group = new_curve(p, a, b, ossl_bn_ctx)) == NULL)
ossl_raise(eEC_GROUP, "EC_GROUP_new_by_GF*");
} else {
- ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
+ ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
}
break;
- default:
- ossl_raise(rb_eArgError, "wrong number of arguments");
+ default:
+ ossl_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1 or 4)", argc);
}
ASSUME(group);
@@ -647,6 +711,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_ec_group_initialize_copy(VALUE self, VALUE other)
{
@@ -654,12 +719,12 @@ ossl_ec_group_initialize_copy(VALUE self, VALUE other)
TypedData_Get_Struct(self, EC_GROUP, &ossl_ec_group_type, group_new);
if (group_new)
- ossl_raise(eEC_GROUP, "EC::Group already initialized");
+ ossl_raise(eEC_GROUP, "EC::Group already initialized");
GetECGroup(other, group);
group_new = EC_GROUP_dup(group);
if (!group_new)
- ossl_raise(eEC_GROUP, "EC_GROUP_dup");
+ ossl_raise(eEC_GROUP, "EC_GROUP_dup");
RTYPEDDATA_DATA(self) = group_new;
return self;
@@ -681,9 +746,9 @@ static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
GetECGroup(b, group2);
switch (EC_GROUP_cmp(group1, group2, ossl_bn_ctx)) {
- case 0: return Qtrue;
- case 1: return Qfalse;
- default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
+ case 0: return Qtrue;
+ case 1: return Qfalse;
+ default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
}
}
@@ -703,7 +768,7 @@ static VALUE ossl_ec_group_get_generator(VALUE self)
GetECGroup(self, group);
generator = EC_GROUP_get0_generator(group);
if (!generator)
- return Qnil;
+ return Qnil;
return ec_point_new(generator, group);
}
@@ -746,11 +811,10 @@ static VALUE ossl_ec_group_get_order(VALUE self)
{
VALUE bn_obj;
BIGNUM *bn;
- EC_GROUP *group = NULL;
+ EC_GROUP *group;
GetECGroup(self, group);
-
- bn_obj = ossl_bn_new(NULL);
+ bn_obj = ossl_bn_new(BN_value_one());
bn = GetBNPtr(bn_obj);
if (EC_GROUP_get_order(group, bn, ossl_bn_ctx) != 1)
@@ -771,11 +835,10 @@ static VALUE ossl_ec_group_get_cofactor(VALUE self)
{
VALUE bn_obj;
BIGNUM *bn;
- EC_GROUP *group = NULL;
+ EC_GROUP *group;
GetECGroup(self, group);
-
- bn_obj = ossl_bn_new(NULL);
+ bn_obj = ossl_bn_new(BN_value_one());
bn = GetBNPtr(bn_obj);
if (EC_GROUP_get_cofactor(group, bn, ossl_bn_ctx) != 1)
@@ -786,25 +849,23 @@ static VALUE ossl_ec_group_get_cofactor(VALUE self)
/*
* call-seq:
- * group.curve_name => String
+ * group.curve_name -> string or nil
*
- * Returns the curve name (sn).
+ * Returns the curve name (short name) corresponding to this group, or +nil+
+ * if \OpenSSL does not have an OID associated with the group.
*
* See the OpenSSL documentation for EC_GROUP_get_curve_name()
*/
static VALUE ossl_ec_group_get_curve_name(VALUE self)
{
- EC_GROUP *group = NULL;
+ EC_GROUP *group;
int nid;
GetECGroup(self, group);
- if (group == NULL)
- return Qnil;
-
nid = EC_GROUP_get_curve_name(group);
-
-/* BUG: an nid or asn1 object should be returned, maybe. */
- return rb_str_new2(OBJ_nid2sn(nid));
+ if (nid == NID_undef)
+ return Qnil;
+ return rb_str_new_cstr(OBJ_nid2sn(nid));
}
/*
@@ -897,37 +958,36 @@ static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
*/
static VALUE ossl_ec_group_get_point_conversion_form(VALUE self)
{
- EC_GROUP *group = NULL;
+ EC_GROUP *group;
point_conversion_form_t form;
- VALUE ret;
GetECGroup(self, group);
form = EC_GROUP_get_point_conversion_form(group);
switch (form) {
- case POINT_CONVERSION_UNCOMPRESSED: ret = ID_uncompressed; break;
- case POINT_CONVERSION_COMPRESSED: ret = ID_compressed; break;
- case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break;
- default: ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form);
+ case POINT_CONVERSION_UNCOMPRESSED:
+ return sym_uncompressed;
+ case POINT_CONVERSION_COMPRESSED:
+ return sym_compressed;
+ case POINT_CONVERSION_HYBRID:
+ return sym_hybrid;
+ default:
+ ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, " \
+ "this module should be updated", form);
}
-
- return ID2SYM(ret);
}
static point_conversion_form_t
parse_point_conversion_form_symbol(VALUE sym)
{
- ID id = SYM2ID(sym);
-
- if (id == ID_uncompressed)
- return POINT_CONVERSION_UNCOMPRESSED;
- else if (id == ID_compressed)
- return POINT_CONVERSION_COMPRESSED;
- else if (id == ID_hybrid)
- return POINT_CONVERSION_HYBRID;
- else
- ossl_raise(rb_eArgError, "unsupported point conversion form %+"PRIsVALUE
- " (expected :compressed, :uncompressed, or :hybrid)", sym);
+ if (sym == sym_uncompressed)
+ return POINT_CONVERSION_UNCOMPRESSED;
+ if (sym == sym_compressed)
+ return POINT_CONVERSION_COMPRESSED;
+ if (sym == sym_hybrid)
+ return POINT_CONVERSION_HYBRID;
+ ossl_raise(rb_eArgError, "unsupported point conversion form %+"PRIsVALUE
+ " (expected :compressed, :uncompressed, or :hybrid)", sym);
}
/*
@@ -1032,20 +1092,20 @@ static VALUE ossl_ec_group_to_string(VALUE self, int format)
ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
switch(format) {
- case EXPORT_PEM:
+ case EXPORT_PEM:
i = PEM_write_bio_ECPKParameters(out, group);
- break;
- case EXPORT_DER:
+ break;
+ case EXPORT_DER:
i = i2d_ECPKParameters_bio(out, group);
- break;
- default:
+ break;
+ default:
BIO_free(out);
- ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
+ ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
}
if (i != 1) {
BIO_free(out);
- ossl_raise(eECError, NULL);
+ ossl_raise(ePKeyError, NULL);
}
str = ossl_membio2str(out);
@@ -1089,11 +1149,11 @@ static VALUE ossl_ec_group_to_text(VALUE self)
GetECGroup(self, group);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
+ ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
}
if (!ECPKParameters_print(out, group, 0)) {
- BIO_free(out);
- ossl_raise(eEC_GROUP, NULL);
+ BIO_free(out);
+ ossl_raise(eEC_GROUP, NULL);
}
str = ossl_membio2str(out);
@@ -1113,9 +1173,9 @@ ossl_ec_point_free(void *ptr)
static const rb_data_type_t ossl_ec_point_type = {
"OpenSSL/EC_POINT",
{
- 0, ossl_ec_point_free,
+ 0, ossl_ec_point_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -1133,7 +1193,7 @@ ec_point_new(const EC_POINT *point, const EC_GROUP *group)
obj = ossl_ec_point_alloc(cEC_POINT);
point_new = EC_POINT_dup(point, group);
if (!point_new)
- ossl_raise(eEC_POINT, "EC_POINT_dup");
+ ossl_raise(eEC_POINT, "EC_POINT_dup");
RTYPEDDATA_DATA(obj) = point_new;
rb_ivar_set(obj, id_i_group, ec_group_new(group));
@@ -1161,39 +1221,39 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point);
if (point)
- rb_raise(eEC_POINT, "EC_POINT already initialized");
+ rb_raise(eEC_POINT, "EC_POINT already initialized");
rb_scan_args(argc, argv, "11", &group_v, &arg2);
if (rb_obj_is_kind_of(group_v, cEC_POINT)) {
- if (argc != 1)
- rb_raise(rb_eArgError, "invalid second argument");
- return ossl_ec_point_initialize_copy(self, group_v);
+ if (argc != 1)
+ rb_raise(rb_eArgError, "invalid second argument");
+ return ossl_ec_point_initialize_copy(self, group_v);
}
GetECGroup(group_v, group);
if (argc == 1) {
- point = EC_POINT_new(group);
- if (!point)
- ossl_raise(eEC_POINT, "EC_POINT_new");
+ point = EC_POINT_new(group);
+ if (!point)
+ ossl_raise(eEC_POINT, "EC_POINT_new");
}
else {
- if (rb_obj_is_kind_of(arg2, cBN)) {
- point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
- if (!point)
- ossl_raise(eEC_POINT, "EC_POINT_bn2point");
- }
- else {
- StringValue(arg2);
- point = EC_POINT_new(group);
- if (!point)
- ossl_raise(eEC_POINT, "EC_POINT_new");
- if (!EC_POINT_oct2point(group, point,
- (unsigned char *)RSTRING_PTR(arg2),
- RSTRING_LEN(arg2), ossl_bn_ctx)) {
- EC_POINT_free(point);
- ossl_raise(eEC_POINT, "EC_POINT_oct2point");
- }
- }
+ if (rb_obj_is_kind_of(arg2, cBN)) {
+ point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
+ if (!point)
+ ossl_raise(eEC_POINT, "EC_POINT_bn2point");
+ }
+ else {
+ StringValue(arg2);
+ point = EC_POINT_new(group);
+ if (!point)
+ ossl_raise(eEC_POINT, "EC_POINT_new");
+ if (!EC_POINT_oct2point(group, point,
+ (unsigned char *)RSTRING_PTR(arg2),
+ RSTRING_LEN(arg2), ossl_bn_ctx)) {
+ EC_POINT_free(point);
+ ossl_raise(eEC_POINT, "EC_POINT_oct2point");
+ }
+ }
}
RTYPEDDATA_DATA(self) = point;
@@ -1202,6 +1262,7 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_ec_point_initialize_copy(VALUE self, VALUE other)
{
@@ -1211,7 +1272,7 @@ ossl_ec_point_initialize_copy(VALUE self, VALUE other)
TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point_new);
if (point_new)
- ossl_raise(eEC_POINT, "EC::Point already initialized");
+ ossl_raise(eEC_POINT, "EC::Point already initialized");
GetECPoint(other, point);
group_v = rb_obj_dup(rb_attr_get(other, id_i_group));
@@ -1219,7 +1280,7 @@ ossl_ec_point_initialize_copy(VALUE self, VALUE other)
point_new = EC_POINT_dup(point, group);
if (!point_new)
- ossl_raise(eEC_POINT, "EC_POINT_dup");
+ ossl_raise(eEC_POINT, "EC_POINT_dup");
RTYPEDDATA_DATA(self) = point_new;
rb_ivar_set(self, id_i_group, group_v);
@@ -1246,9 +1307,9 @@ static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
GetECGroup(group_v1, group);
switch (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx)) {
- case 0: return Qtrue;
- case 1: return Qfalse;
- default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
+ case 0: return Qtrue;
+ case 1: return Qfalse;
+ default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
}
UNREACHABLE;
@@ -1267,9 +1328,9 @@ static VALUE ossl_ec_point_is_at_infinity(VALUE self)
GetECPointGroup(self, group);
switch (EC_POINT_is_at_infinity(group, point)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: ossl_raise(eEC_POINT, "EC_POINT_is_at_infinity");
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: ossl_raise(eEC_POINT, "EC_POINT_is_at_infinity");
}
UNREACHABLE;
@@ -1288,9 +1349,9 @@ static VALUE ossl_ec_point_is_on_curve(VALUE self)
GetECPointGroup(self, group);
switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
- case 1: return Qtrue;
- case 0: return Qfalse;
- default: ossl_raise(eEC_POINT, "EC_POINT_is_on_curve");
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: ossl_raise(eEC_POINT, "EC_POINT_is_on_curve");
}
UNREACHABLE;
@@ -1311,7 +1372,7 @@ static VALUE ossl_ec_point_make_affine(VALUE self)
GetECPointGroup(self, group);
rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated");
-#if !OSSL_OPENSSL_PREREQ(3, 0, 0)
+#if !defined(OSSL_HAVE_IMMUTABLE_PKEY) && !defined(OPENSSL_IS_AWSLC)
if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
ossl_raise(eEC_POINT, "EC_POINT_make_affine");
#endif
@@ -1382,12 +1443,12 @@ ossl_ec_point_to_octet_string(VALUE self, VALUE conversion_form)
len = EC_POINT_point2oct(group, point, form, NULL, 0, ossl_bn_ctx);
if (!len)
- ossl_raise(eEC_POINT, "EC_POINT_point2oct");
+ ossl_raise(eEC_POINT, "EC_POINT_point2oct");
str = rb_str_new(NULL, (long)len);
if (!EC_POINT_point2oct(group, point, form,
- (unsigned char *)RSTRING_PTR(str), len,
- ossl_bn_ctx))
- ossl_raise(eEC_POINT, "EC_POINT_point2oct");
+ (unsigned char *)RSTRING_PTR(str), len,
+ ossl_bn_ctx))
+ ossl_raise(eEC_POINT, "EC_POINT_point2oct");
return str;
}
@@ -1422,7 +1483,6 @@ static VALUE ossl_ec_point_add(VALUE self, VALUE other)
/*
* call-seq:
* point.mul(bn1 [, bn2]) => point
- * point.mul(bns, points [, bn2]) => point
*
* Performs elliptic curve point multiplication.
*
@@ -1430,11 +1490,9 @@ static VALUE ossl_ec_point_add(VALUE self, VALUE other)
* generator of the group of _point_. _bn2_ may be omitted, and in that case,
* the result is just <tt>bn1 * point</tt>.
*
- * The second form calculates <tt>bns[0] * point + bns[1] * points[0] + ...
- * + bns[-1] * points[-1] + bn2 * G</tt>. _bn2_ may be omitted. _bns_ must be
- * an array of OpenSSL::BN. _points_ must be an array of
- * OpenSSL::PKey::EC::Point. Please note that <tt>points[0]</tt> is not
- * multiplied by <tt>bns[0]</tt>, but <tt>bns[1]</tt>.
+ * Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
+ * method allowed another form:
+ * point.mul(bns, points [, bn2]) => point
*/
static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
{
@@ -1452,62 +1510,15 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
GetECPoint(result, point_result);
rb_scan_args(argc, argv, "12", &arg1, &arg2, &arg3);
- if (!RB_TYPE_P(arg1, T_ARRAY)) {
- BIGNUM *bn = GetBNPtr(arg1);
+ if (RB_TYPE_P(arg1, T_ARRAY) || argc > 2)
+ rb_raise(rb_eNotImpError, "OpenSSL::PKey::EC::Point#mul with arrays " \
+ "is no longer supported");
- if (!NIL_P(arg2))
- bn_g = GetBNPtr(arg2);
- if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1)
- ossl_raise(eEC_POINT, NULL);
- } else {
-#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) || defined(LIBRESSL_VERSION_NUMBER)
- rb_raise(rb_eNotImpError, "calling #mul with arrays is not" \
- "supported by this OpenSSL version");
-#else
- /*
- * bignums | arg1[0] | arg1[1] | arg1[2] | ...
- * points | self | arg2[0] | arg2[1] | ...
- */
- long i, num;
- VALUE bns_tmp, tmp_p, tmp_b;
- const EC_POINT **points;
- const BIGNUM **bignums;
-
- Check_Type(arg1, T_ARRAY);
- Check_Type(arg2, T_ARRAY);
- if (RARRAY_LEN(arg1) != RARRAY_LEN(arg2) + 1) /* arg2 must be 1 larger */
- ossl_raise(rb_eArgError, "bns must be 1 longer than points; see the documentation");
-
- rb_warning("OpenSSL::PKey::EC::Point#mul(ary, ary) is deprecated; " \
- "use #mul(bn) form instead");
-
- num = RARRAY_LEN(arg1);
- bns_tmp = rb_ary_tmp_new(num);
- bignums = ALLOCV_N(const BIGNUM *, tmp_b, num);
- for (i = 0; i < num; i++) {
- VALUE item = RARRAY_AREF(arg1, i);
- bignums[i] = GetBNPtr(item);
- rb_ary_push(bns_tmp, item);
- }
-
- points = ALLOCV_N(const EC_POINT *, tmp_p, num);
- points[0] = point_self; /* self */
- for (i = 0; i < num - 1; i++)
- GetECPoint(RARRAY_AREF(arg2, i), points[i + 1]);
-
- if (!NIL_P(arg3))
- bn_g = GetBNPtr(arg3);
-
- if (EC_POINTs_mul(group, point_result, bn_g, num, points, bignums, ossl_bn_ctx) != 1) {
- ALLOCV_END(tmp_b);
- ALLOCV_END(tmp_p);
- ossl_raise(eEC_POINT, NULL);
- }
-
- ALLOCV_END(tmp_b);
- ALLOCV_END(tmp_p);
-#endif
- }
+ BIGNUM *bn = GetBNPtr(arg1);
+ if (!NIL_P(arg2))
+ bn_g = GetBNPtr(arg2);
+ if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1)
+ ossl_raise(eEC_POINT, NULL);
return result;
}
@@ -1515,15 +1526,6 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
void Init_ossl_ec(void)
{
#undef rb_intern
-#if 0
- mPKey = rb_define_module_under(mOSSL, "PKey");
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
-#endif
-
- eECError = rb_define_class_under(mPKey, "ECError", ePKeyError);
-
/*
* Document-class: OpenSSL::PKey::EC
*
@@ -1545,17 +1547,15 @@ void Init_ossl_ec(void)
eEC_GROUP = rb_define_class_under(cEC_GROUP, "Error", eOSSLError);
eEC_POINT = rb_define_class_under(cEC_POINT, "Error", eOSSLError);
- s_GFp = rb_intern("GFp");
- s_GF2m = rb_intern("GF2m");
+ sym_GFp = ID2SYM(rb_intern_const("GFp"));
+ sym_GF2m = ID2SYM(rb_intern_const("GF2m"));
- ID_uncompressed = rb_intern("uncompressed");
- ID_compressed = rb_intern("compressed");
- ID_hybrid = rb_intern("hybrid");
+ sym_uncompressed = ID2SYM(rb_intern_const("uncompressed"));
+ sym_compressed = ID2SYM(rb_intern_const("compressed"));
+ sym_hybrid = ID2SYM(rb_intern_const("hybrid"));
rb_define_const(cEC, "NAMED_CURVE", INT2NUM(OPENSSL_EC_NAMED_CURVE));
-#if defined(OPENSSL_EC_EXPLICIT_CURVE)
rb_define_const(cEC, "EXPLICIT_CURVE", INT2NUM(OPENSSL_EC_EXPLICIT_CURVE));
-#endif
rb_define_singleton_method(cEC, "builtin_curves", ossl_s_builtin_curves, 0);
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 072adabe62..039b2c6a34 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -14,13 +14,15 @@
#define GetPKeyRSA(obj, pkey) do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA) { /* PARANOIA? */ \
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
} \
} while (0)
#define GetRSA(obj, rsa) do { \
EVP_PKEY *_pkey; \
GetPKeyRSA((obj), _pkey); \
(rsa) = EVP_PKEY_get0_RSA(_pkey); \
+ if ((rsa) == NULL) \
+ ossl_raise(ePKeyError, "failed to get RSA from EVP_PKEY"); \
} while (0)
static inline int
@@ -42,7 +44,6 @@ RSA_PRIVATE(VALUE obj, OSSL_3_const RSA *rsa)
* Classes
*/
VALUE cRSA;
-VALUE eRSAError;
/*
* Private
@@ -50,8 +51,8 @@ VALUE eRSAError;
/*
* call-seq:
* RSA.new -> rsa
- * RSA.new(encoded_key [, passphrase]) -> rsa
- * RSA.new(encoded_key) { passphrase } -> rsa
+ * RSA.new(encoded_key [, password ]) -> rsa
+ * RSA.new(encoded_key) { password } -> rsa
* RSA.new(size [, exponent]) -> rsa
*
* Generates or loads an \RSA keypair.
@@ -59,11 +60,12 @@ VALUE eRSAError;
* If called without arguments, creates a new instance with no key components
* set. They can be set individually by #set_key, #set_factors, and
* #set_crt_params.
+ * This form is not compatible with OpenSSL 3.0 or later.
*
* If called with a String, tries to parse as DER or PEM encoding of an \RSA key.
- * Note that, if _passphrase_ is not specified but the key is encrypted with a
- * passphrase, \OpenSSL will prompt for it.
- * See also OpenSSL::PKey.read which can parse keys of any kinds.
+ * Note that if _password_ is not specified, but the key is encrypted with a
+ * password, \OpenSSL will prompt for it.
+ * See also OpenSSL::PKey.read which can parse keys of any kind.
*
* If called with a number, generates a new key pair. This form works as an
* alias of RSA.generate.
@@ -71,7 +73,7 @@ VALUE eRSAError;
* Examples:
* OpenSSL::PKey::RSA.new 2048
* OpenSSL::PKey::RSA.new File.read 'rsa.pem'
- * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
+ * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my password'
*/
static VALUE
ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
@@ -89,10 +91,15 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
/* The RSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
rb_scan_args(argc, argv, "02", &arg, &pass);
if (argc == 0) {
- rsa = RSA_new();
+#ifdef OSSL_HAVE_IMMUTABLE_PKEY
+ rb_raise(rb_eArgError, "OpenSSL::PKey::RSA.new cannot be called " \
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
+#else
+ rsa = RSA_new();
if (!rsa)
- ossl_raise(eRSAError, "RSA_new");
+ ossl_raise(ePKeyError, "RSA_new");
goto legacy;
+#endif
}
pass = ossl_pem_passwd_value(pass);
@@ -113,12 +120,12 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
pkey = ossl_pkey_read_generic(in, pass);
BIO_free(in);
if (!pkey)
- ossl_raise(eRSAError, "Neither PUB key nor PRIV key");
+ ossl_raise(ePKeyError, "Neither PUB key nor PRIV key");
type = EVP_PKEY_base_id(pkey);
if (type != EVP_PKEY_RSA) {
EVP_PKEY_free(pkey);
- rb_raise(eRSAError, "incorrect pkey type: %s", OBJ_nid2sn(type));
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
}
RTYPEDDATA_DATA(self) = pkey;
return self;
@@ -129,13 +136,14 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa) != 1) {
EVP_PKEY_free(pkey);
RSA_free(rsa);
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
}
RTYPEDDATA_DATA(self) = pkey;
return self;
}
#ifndef HAVE_EVP_PKEY_DUP
+/* :nodoc: */
static VALUE
ossl_rsa_initialize_copy(VALUE self, VALUE other)
{
@@ -151,12 +159,12 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
(d2i_of_void *)d2i_RSAPrivateKey,
(char *)rsa);
if (!rsa_new)
- ossl_raise(eRSAError, "ASN1_dup");
+ ossl_raise(ePKeyError, "ASN1_dup");
pkey = EVP_PKEY_new();
if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa_new) != 1) {
RSA_free(rsa_new);
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
}
RTYPEDDATA_DATA(self) = pkey;
@@ -217,13 +225,61 @@ can_export_rsaprivatekey(VALUE self)
/*
* call-seq:
- * rsa.export([cipher, pass_phrase]) => PEM-format String
- * rsa.to_pem([cipher, pass_phrase]) => PEM-format String
- * rsa.to_s([cipher, pass_phrase]) => PEM-format String
+ * rsa.export([cipher, password]) => PEM-format String
+ * rsa.to_pem([cipher, password]) => PEM-format String
+ * rsa.to_s([cipher, password]) => PEM-format String
+ *
+ * Serializes a private or public key to a PEM-encoding.
+ *
+ * [When the key contains public components only]
+ *
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether the key is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a PKCS #1 RSAPrivateKey.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN RSA PRIVATE KEY-----
+ * [...]
+ * -----END RSA PRIVATE KEY-----
+ *
+ * [When the key contains private components, and _cipher_ and _password_ are given]
*
- * Outputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are
- * given they will be used to encrypt the key. _cipher_ must be an
- * OpenSSL::Cipher instance.
+ * Serializes it into a PKCS #1 RSAPrivateKey
+ * and encrypts it in OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN RSA PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END RSA PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the PKCS #1 RSAPrivateKey format is required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_rsa_export(int argc, VALUE *argv, VALUE self)
@@ -238,7 +294,14 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* rsa.to_der => DER-format String
*
- * Outputs this keypair in DER encoding.
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the PKCS #1 RSAPrivateKey format is required.
+ *
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_rsa_to_der(VALUE self)
@@ -256,7 +319,7 @@ ossl_rsa_to_der(VALUE self)
* Signs _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns
* the calculated signature.
*
- * RSAError will be raised if an error occurs.
+ * PKeyError will be raised if an error occurs.
*
* See #verify_pss for the verification operation.
*
@@ -285,7 +348,7 @@ ossl_rsa_to_der(VALUE self)
static VALUE
ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
{
- VALUE digest, data, options, kwargs[2], signature;
+ VALUE digest, data, options, kwargs[2], signature, mgf1md_holder, md_holder;
static ID kwargs_ids[2];
EVP_PKEY *pkey;
EVP_PKEY_CTX *pkey_ctx;
@@ -295,46 +358,46 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
int salt_len;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("salt_length");
- kwargs_ids[1] = rb_intern_const("mgf1_hash");
+ kwargs_ids[0] = rb_intern_const("salt_length");
+ kwargs_ids[1] = rb_intern_const("mgf1_hash");
}
rb_scan_args(argc, argv, "2:", &digest, &data, &options);
rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
if (kwargs[0] == ID2SYM(rb_intern("max")))
- salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
+ salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
else if (kwargs[0] == ID2SYM(rb_intern("digest")))
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
else
- salt_len = NUM2INT(kwargs[0]);
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
+ salt_len = NUM2INT(kwargs[0]);
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
pkey = GetPrivPKeyPtr(self);
buf_len = EVP_PKEY_size(pkey);
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(data);
signature = rb_str_new(NULL, (long)buf_len);
md_ctx = EVP_MD_CTX_new();
if (!md_ctx)
- goto err;
+ goto err;
if (EVP_DigestSignInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
- goto err;
+ goto err;
if (EVP_DigestSignUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
- goto err;
+ goto err;
if (EVP_DigestSignFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), &buf_len) != 1)
- goto err;
+ goto err;
rb_str_set_len(signature, (long)buf_len);
@@ -343,7 +406,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
err:
EVP_MD_CTX_free(md_ctx);
- ossl_raise(eRSAError, NULL);
+ ossl_raise(ePKeyError, NULL);
}
/*
@@ -353,7 +416,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
* Verifies _data_ using the Probabilistic Signature Scheme (RSA-PSS).
*
* The return value is +true+ if the signature is valid, +false+ otherwise.
- * RSAError will be raised if an error occurs.
+ * PKeyError will be raised if an error occurs.
*
* See #sign_pss for the signing operation and an example code.
*
@@ -372,7 +435,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
static VALUE
ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
{
- VALUE digest, signature, data, options, kwargs[2];
+ VALUE digest, signature, data, options, kwargs[2], mgf1md_holder, md_holder;
static ID kwargs_ids[2];
EVP_PKEY *pkey;
EVP_PKEY_CTX *pkey_ctx;
@@ -381,98 +444,61 @@ ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
int result, salt_len;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("salt_length");
- kwargs_ids[1] = rb_intern_const("mgf1_hash");
+ kwargs_ids[0] = rb_intern_const("salt_length");
+ kwargs_ids[1] = rb_intern_const("mgf1_hash");
}
rb_scan_args(argc, argv, "3:", &digest, &signature, &data, &options);
rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
if (kwargs[0] == ID2SYM(rb_intern("auto")))
- salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
+ salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
else if (kwargs[0] == ID2SYM(rb_intern("digest")))
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
else
- salt_len = NUM2INT(kwargs[0]);
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
+ salt_len = NUM2INT(kwargs[0]);
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
GetPKey(self, pkey);
- md = ossl_evp_get_digestbyname(digest);
+ md = ossl_evp_md_fetch(digest, &md_holder);
StringValue(signature);
StringValue(data);
md_ctx = EVP_MD_CTX_new();
if (!md_ctx)
- goto err;
+ goto err;
if (EVP_DigestVerifyInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
- goto err;
+ goto err;
if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
- goto err;
+ goto err;
if (EVP_DigestVerifyUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
- goto err;
+ goto err;
result = EVP_DigestVerifyFinal(md_ctx,
- (unsigned char *)RSTRING_PTR(signature),
- RSTRING_LEN(signature));
+ (unsigned char *)RSTRING_PTR(signature),
+ RSTRING_LEN(signature));
+ EVP_MD_CTX_free(md_ctx);
switch (result) {
case 0:
- ossl_clear_error();
- EVP_MD_CTX_free(md_ctx);
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
case 1:
- EVP_MD_CTX_free(md_ctx);
- return Qtrue;
+ return Qtrue;
default:
- goto err;
+ ossl_raise(ePKeyError, "EVP_DigestVerifyFinal");
}
err:
EVP_MD_CTX_free(md_ctx);
- ossl_raise(eRSAError, NULL);
-}
-
-/*
- * call-seq:
- * rsa.params => hash
- *
- * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
- *
- * Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
- * 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
- *
- * Don't use :-)) (It's up to you)
- */
-static VALUE
-ossl_rsa_get_params(VALUE self)
-{
- OSSL_3_const RSA *rsa;
- VALUE hash;
- const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
-
- GetRSA(self, rsa);
- RSA_get0_key(rsa, &n, &e, &d);
- RSA_get0_factors(rsa, &p, &q);
- RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
-
- hash = rb_hash_new();
- rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(n));
- rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(e));
- rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(d));
- rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
- rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
- rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(dmp1));
- rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(dmq1));
- rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(iqmp));
-
- return hash;
+ ossl_raise(ePKeyError, NULL);
}
/*
@@ -510,20 +536,6 @@ OSSL_PKEY_BN_DEF3(rsa, RSA, crt_params, dmp1, dmq1, iqmp)
void
Init_ossl_rsa(void)
{
-#if 0
- mPKey = rb_define_module_under(mOSSL, "PKey");
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
-#endif
-
- /* Document-class: OpenSSL::PKey::RSAError
- *
- * Generic exception that is raised if an operation on an RSA PKey
- * fails unexpectedly or in case an instantiation of an instance of RSA
- * fails due to non-conformant input data.
- */
- eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
-
/* Document-class: OpenSSL::PKey::RSA
*
* RSA is an asymmetric public key algorithm that has been formalized in
@@ -562,8 +574,6 @@ Init_ossl_rsa(void)
rb_define_method(cRSA, "set_factors", ossl_rsa_set_factors, 2);
rb_define_method(cRSA, "set_crt_params", ossl_rsa_set_crt_params, 3);
- rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
-
/*
* TODO: Test it
rb_define_method(cRSA, "blinding_on!", ossl_rsa_blinding_on, 0);
diff --git a/ext/openssl/ossl_provider.c b/ext/openssl/ossl_provider.c
new file mode 100644
index 0000000000..ea5abb8e48
--- /dev/null
+++ b/ext/openssl/ossl_provider.c
@@ -0,0 +1,204 @@
+/*
+ * This program is licensed under the same licence as Ruby.
+ * (See the file 'COPYING'.)
+ */
+#include "ossl.h"
+
+#ifdef OSSL_USE_PROVIDER
+#define NewProvider(klass) \
+ TypedData_Wrap_Struct((klass), &ossl_provider_type, 0)
+#define SetProvider(obj, provider) do { \
+ if (!(provider)) { \
+ ossl_raise(rb_eRuntimeError, "Provider wasn't initialized."); \
+ } \
+ RTYPEDDATA_DATA(obj) = (provider); \
+} while(0)
+#define GetProvider(obj, provider) do { \
+ TypedData_Get_Struct((obj), OSSL_PROVIDER, &ossl_provider_type, (provider)); \
+ if (!(provider)) { \
+ ossl_raise(rb_eRuntimeError, "PROVIDER wasn't initialized."); \
+ } \
+} while (0)
+
+static const rb_data_type_t ossl_provider_type = {
+ "OpenSSL/Provider",
+ {
+ 0,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+
+/*
+ * Classes
+ */
+/* Document-class: OpenSSL::Provider
+ *
+ * This class is the access to openssl's Provider
+ * See also, https://www.openssl.org/docs/manmaster/man7/provider.html
+ */
+static VALUE cProvider;
+/* Document-class: OpenSSL::Provider::ProviderError
+ *
+ * This is the generic exception for OpenSSL::Provider related errors
+ */
+static VALUE eProviderError;
+
+/*
+ * call-seq:
+ * OpenSSL::Provider.load(name) -> provider
+ *
+ * This method loads and initializes a provider
+ */
+static VALUE
+ossl_provider_s_load(VALUE klass, VALUE name)
+{
+ OSSL_PROVIDER *provider = NULL;
+ VALUE obj;
+
+ const char *provider_name_ptr = StringValueCStr(name);
+
+ provider = OSSL_PROVIDER_load(NULL, provider_name_ptr);
+ if (provider == NULL) {
+ ossl_raise(eProviderError, "Failed to load %s provider", provider_name_ptr);
+ }
+ obj = NewProvider(klass);
+ SetProvider(obj, provider);
+
+ return obj;
+}
+
+struct ary_with_state { VALUE ary; int state; };
+struct rb_push_provider_name_args { OSSL_PROVIDER *prov; VALUE ary; };
+
+static VALUE
+rb_push_provider_name(VALUE rb_push_provider_name_args)
+{
+ struct rb_push_provider_name_args *args = (struct rb_push_provider_name_args *)rb_push_provider_name_args;
+
+ VALUE name = rb_str_new2(OSSL_PROVIDER_get0_name(args->prov));
+ return rb_ary_push(args->ary, name);
+}
+
+static int
+push_provider(OSSL_PROVIDER *prov, void *cbdata)
+{
+ struct ary_with_state *ary_with_state = (struct ary_with_state *)cbdata;
+ struct rb_push_provider_name_args args = { prov, ary_with_state->ary };
+
+ rb_protect(rb_push_provider_name, (VALUE)&args, &ary_with_state->state);
+ if (ary_with_state->state) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+/*
+ * call-seq:
+ * OpenSSL::Provider.provider_names -> [provider_name, ...]
+ *
+ * Returns an array of currently loaded provider names.
+ */
+static VALUE
+ossl_provider_s_provider_names(VALUE klass)
+{
+ VALUE ary = rb_ary_new();
+ struct ary_with_state cbdata = { ary, 0 };
+
+ int result = OSSL_PROVIDER_do_all(NULL, &push_provider, (void*)&cbdata);
+ if (result != 1 ) {
+ if (cbdata.state) {
+ rb_jump_tag(cbdata.state);
+ } else {
+ ossl_raise(eProviderError, "Failed to load provider names");
+ }
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * provider.unload -> true
+ *
+ * This method unloads this provider.
+ *
+ * if provider unload fails or already unloaded, it raises OpenSSL::Provider::ProviderError
+ */
+static VALUE
+ossl_provider_unload(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL) {
+ ossl_raise(eProviderError, "Provider already unloaded.");
+ }
+ GetProvider(self, prov);
+
+ int result = OSSL_PROVIDER_unload(prov);
+
+ if (result != 1) {
+ ossl_raise(eProviderError, "Failed to unload provider");
+ }
+ RTYPEDDATA_DATA(self) = NULL;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * provider.name -> string
+ *
+ * Get the name of this provider.
+ *
+ * if this provider is already unloaded, it raises OpenSSL::Provider::ProviderError
+ */
+static VALUE
+ossl_provider_get_name(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL) {
+ ossl_raise(eProviderError, "Provider already unloaded.");
+ }
+ GetProvider(self, prov);
+
+ return rb_str_new2(OSSL_PROVIDER_get0_name(prov));
+}
+
+/*
+ * call-seq:
+ * provider.inspect -> string
+ *
+ * Pretty prints this provider.
+ */
+static VALUE
+ossl_provider_inspect(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL ) {
+ return rb_sprintf("#<%"PRIsVALUE" unloaded provider>", rb_obj_class(self));
+ }
+ GetProvider(self, prov);
+
+ return rb_sprintf("#<%"PRIsVALUE" name=\"%s\">",
+ rb_obj_class(self), OSSL_PROVIDER_get0_name(prov));
+}
+
+void
+Init_ossl_provider(void)
+{
+ cProvider = rb_define_class_under(mOSSL, "Provider", rb_cObject);
+ eProviderError = rb_define_class_under(cProvider, "ProviderError", eOSSLError);
+
+ rb_undef_alloc_func(cProvider);
+ rb_define_singleton_method(cProvider, "load", ossl_provider_s_load, 1);
+ rb_define_singleton_method(cProvider, "provider_names", ossl_provider_s_provider_names, 0);
+
+ rb_define_method(cProvider, "unload", ossl_provider_unload, 0);
+ rb_define_method(cProvider, "name", ossl_provider_get_name, 0);
+ rb_define_method(cProvider, "inspect", ossl_provider_inspect, 0);
+}
+#else
+void
+Init_ossl_provider(void)
+{
+}
+#endif
diff --git a/ext/openssl/ossl_provider.h b/ext/openssl/ossl_provider.h
new file mode 100644
index 0000000000..1d69cb1e44
--- /dev/null
+++ b/ext/openssl/ossl_provider.h
@@ -0,0 +1,5 @@
+#if !defined(OSSL_PROVIDER_H)
+#define OSSL_PROVIDER_H
+
+void Init_ossl_provider(void);
+#endif
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index 659dc818b6..753f8b25f7 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -5,12 +5,12 @@
* All rights reserved.
*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
-VALUE mRandom;
-VALUE eRandomError;
+static VALUE mRandom;
+static VALUE eRandomError;
/*
* call-seq:
@@ -68,7 +68,7 @@ static VALUE
ossl_rand_load_file(VALUE self, VALUE filename)
{
if(!RAND_load_file(StringValueCStr(filename), -1)) {
- ossl_raise(eRandomError, NULL);
+ ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
@@ -85,14 +85,14 @@ static VALUE
ossl_rand_write_file(VALUE self, VALUE filename)
{
if (RAND_write_file(StringValueCStr(filename)) == -1) {
- ossl_raise(eRandomError, NULL);
+ ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
/*
* call-seq:
- * random_bytes(length) -> string
+ * random_bytes(length) -> string
*
* Generates a String with _length_ number of cryptographically strong
* pseudo-random bytes.
@@ -112,9 +112,9 @@ ossl_rand_bytes(VALUE self, VALUE len)
str = rb_str_new(0, n);
ret = RAND_bytes((unsigned char *)RSTRING_PTR(str), n);
if (ret == 0) {
- ossl_raise(eRandomError, "RAND_bytes");
+ ossl_raise(eRandomError, "RAND_bytes");
} else if (ret == -1) {
- ossl_raise(eRandomError, "RAND_bytes is not supported");
+ ossl_raise(eRandomError, "RAND_bytes is not supported");
}
return str;
@@ -131,7 +131,7 @@ static VALUE
ossl_rand_egd(VALUE self, VALUE filename)
{
if (RAND_egd(StringValueCStr(filename)) == -1) {
- ossl_raise(eRandomError, NULL);
+ ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
@@ -151,7 +151,7 @@ ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
int n = NUM2INT(len);
if (RAND_egd_bytes(StringValueCStr(filename), n) == -1) {
- ossl_raise(eRandomError, NULL);
+ ossl_raise(eRandomError, NULL);
}
return Qtrue;
}
@@ -175,11 +175,6 @@ ossl_rand_status(VALUE self)
void
Init_ossl_rand(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
-
mRandom = rb_define_module_under(mOSSL, "Random");
eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
@@ -189,9 +184,7 @@ Init_ossl_rand(void)
rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1);
rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1);
rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1);
-#if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER)
rb_define_alias(rb_singleton_class(mRandom), "pseudo_bytes", "random_bytes");
-#endif
#ifdef HAVE_RAND_EGD
rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1);
rb_define_module_function(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
diff --git a/ext/openssl/ossl_rand.h b/ext/openssl/ossl_rand.h
index 8f77a3b239..294986d017 100644
--- a/ext/openssl/ossl_rand.h
+++ b/ext/openssl/ossl_rand.h
@@ -5,14 +5,11 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_RAND_H_)
#define _OSSL_RAND_H_
-extern VALUE mRandom;
-extern VALUE eRandomError;
-
void Init_ossl_rand(void);
#endif /* _OSSL_RAND_H_ */
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index f63992664a..3d913a3968 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -7,7 +7,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -18,11 +18,6 @@
# define OSSL_USE_NEXTPROTONEG
#endif
-#if !defined(TLS1_3_VERSION) && \
- OSSL_LIBRESSL_PREREQ(3, 2, 0) && !OSSL_LIBRESSL_PREREQ(3, 4, 0)
-# define TLS1_3_VERSION 0x0304
-#endif
-
#ifdef _WIN32
# define TO_SOCKET(s) _get_osfhandle(s)
#else
@@ -30,32 +25,30 @@
#endif
#define GetSSLCTX(obj, ctx) do { \
- TypedData_Get_Struct((obj), SSL_CTX, &ossl_sslctx_type, (ctx)); \
+ TypedData_Get_Struct((obj), SSL_CTX, &ossl_sslctx_type, (ctx)); \
} while (0)
VALUE mSSL;
static VALUE eSSLError;
-VALUE cSSLContext;
+static VALUE cSSLContext;
VALUE cSSLSocket;
static VALUE eSSLErrorWaitReadable;
static VALUE eSSLErrorWaitWritable;
-static ID id_call, ID_callback_state, id_tmp_dh_callback,
- id_npn_protocols_encoded, id_each;
+static ID id_call, ID_callback_state, id_npn_protocols_encoded, id_each;
static VALUE sym_exception, sym_wait_readable, sym_wait_writable;
static ID id_i_cert_store, id_i_ca_file, id_i_ca_path, id_i_verify_mode,
- id_i_verify_depth, id_i_verify_callback, id_i_client_ca,
- id_i_renegotiation_cb, id_i_cert, id_i_key, id_i_extra_chain_cert,
- id_i_client_cert_cb, id_i_timeout,
- id_i_session_id_context, id_i_session_get_cb, id_i_session_new_cb,
- id_i_session_remove_cb, id_i_npn_select_cb, id_i_npn_protocols,
- id_i_alpn_select_cb, id_i_alpn_protocols, id_i_servername_cb,
- id_i_verify_hostname, id_i_keylog_cb;
-static ID id_i_io, id_i_context, id_i_hostname;
-
-static int ossl_ssl_ex_vcb_idx;
+ id_i_verify_depth, id_i_verify_callback, id_i_client_ca,
+ id_i_renegotiation_cb, id_i_cert, id_i_key, id_i_extra_chain_cert,
+ id_i_client_cert_cb, id_i_timeout,
+ id_i_session_id_context, id_i_session_get_cb, id_i_session_new_cb,
+ id_i_session_remove_cb, id_i_npn_select_cb, id_i_npn_protocols,
+ id_i_alpn_select_cb, id_i_alpn_protocols, id_i_servername_cb,
+ id_i_verify_hostname, id_i_keylog_cb, id_i_tmp_dh_callback;
+static ID id_i_io, id_i_context, id_i_hostname, id_i_sync_close;
+
static int ossl_ssl_ex_ptr_idx;
static int ossl_sslctx_ex_ptr_idx;
@@ -77,7 +70,7 @@ static const rb_data_type_t ossl_sslctx_type = {
{
ossl_sslctx_mark, ossl_sslctx_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -85,127 +78,25 @@ ossl_sslctx_s_alloc(VALUE klass)
{
SSL_CTX *ctx;
long mode = 0 |
- SSL_MODE_ENABLE_PARTIAL_WRITE |
- SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
- SSL_MODE_RELEASE_BUFFERS;
+ SSL_MODE_ENABLE_PARTIAL_WRITE |
+ SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
+ SSL_MODE_RELEASE_BUFFERS;
VALUE obj;
obj = TypedData_Wrap_Struct(klass, &ossl_sslctx_type, 0);
-#if OPENSSL_VERSION_NUMBER >= 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
ctx = SSL_CTX_new(TLS_method());
-#else
- ctx = SSL_CTX_new(SSLv23_method());
-#endif
if (!ctx) {
ossl_raise(eSSLError, "SSL_CTX_new");
}
SSL_CTX_set_mode(ctx, mode);
+ SSL_CTX_set_dh_auto(ctx, 1);
RTYPEDDATA_DATA(obj) = ctx;
- SSL_CTX_set_ex_data(ctx, ossl_sslctx_ex_ptr_idx, (void *)obj);
-
-#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER < 0x10100000 && \
- !defined(LIBRESSL_VERSION_NUMBER)
- /* We use SSL_CTX_set1_curves_list() to specify the curve used in ECDH. It
- * allows to specify multiple curve names and OpenSSL will select
- * automatically from them. In OpenSSL 1.0.2, the automatic selection has to
- * be enabled explicitly. OpenSSL 1.1.0 and LibreSSL 2.6.1 removed the knob
- * and it is always enabled. To uniform the behavior, we enable the
- * automatic selection also in 1.0.2. Users can still disable ECDH by
- * removing ECDH cipher suites by SSLContext#ciphers=. */
- if (!SSL_CTX_set_ecdh_auto(ctx, 1))
- ossl_raise(eSSLError, "SSL_CTX_set_ecdh_auto");
-#endif
+ if (!SSL_CTX_set_ex_data(ctx, ossl_sslctx_ex_ptr_idx, (void *)obj))
+ ossl_raise(eSSLError, "SSL_CTX_set_ex_data");
return obj;
}
-static int
-parse_proto_version(VALUE str)
-{
- int i;
- static const struct {
- const char *name;
- int version;
- } map[] = {
- { "SSL2", SSL2_VERSION },
- { "SSL3", SSL3_VERSION },
- { "TLS1", TLS1_VERSION },
- { "TLS1_1", TLS1_1_VERSION },
- { "TLS1_2", TLS1_2_VERSION },
-#ifdef TLS1_3_VERSION
- { "TLS1_3", TLS1_3_VERSION },
-#endif
- };
-
- if (NIL_P(str))
- return 0;
- if (RB_INTEGER_TYPE_P(str))
- return NUM2INT(str);
-
- if (SYMBOL_P(str))
- str = rb_sym2str(str);
- StringValue(str);
- for (i = 0; i < numberof(map); i++)
- if (!strncmp(map[i].name, RSTRING_PTR(str), RSTRING_LEN(str)))
- return map[i].version;
- rb_raise(rb_eArgError, "unrecognized version %+"PRIsVALUE, str);
-}
-
-/*
- * call-seq:
- * ctx.set_minmax_proto_version(min, max) -> nil
- *
- * Sets the minimum and maximum supported protocol versions. See #min_version=
- * and #max_version=.
- */
-static VALUE
-ossl_sslctx_set_minmax_proto_version(VALUE self, VALUE min_v, VALUE max_v)
-{
- SSL_CTX *ctx;
- int min, max;
-
- GetSSLCTX(self, ctx);
- min = parse_proto_version(min_v);
- max = parse_proto_version(max_v);
-
-#ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
- if (!SSL_CTX_set_min_proto_version(ctx, min))
- ossl_raise(eSSLError, "SSL_CTX_set_min_proto_version");
- if (!SSL_CTX_set_max_proto_version(ctx, max))
- ossl_raise(eSSLError, "SSL_CTX_set_max_proto_version");
-#else
- {
- unsigned long sum = 0, opts = 0;
- int i;
- static const struct {
- int ver;
- unsigned long opts;
- } options_map[] = {
- { SSL2_VERSION, SSL_OP_NO_SSLv2 },
- { SSL3_VERSION, SSL_OP_NO_SSLv3 },
- { TLS1_VERSION, SSL_OP_NO_TLSv1 },
- { TLS1_1_VERSION, SSL_OP_NO_TLSv1_1 },
- { TLS1_2_VERSION, SSL_OP_NO_TLSv1_2 },
-# if defined(TLS1_3_VERSION)
- { TLS1_3_VERSION, SSL_OP_NO_TLSv1_3 },
-# endif
- };
-
- for (i = 0; i < numberof(options_map); i++) {
- sum |= options_map[i].opts;
- if ((min && min > options_map[i].ver) ||
- (max && max < options_map[i].ver)) {
- opts |= options_map[i].opts;
- }
- }
- SSL_CTX_clear_options(ctx, sum);
- SSL_CTX_set_options(ctx, opts);
- }
-#endif
-
- return Qnil;
-}
-
static VALUE
ossl_call_client_cert_cb(VALUE obj)
{
@@ -214,7 +105,7 @@ ossl_call_client_cert_cb(VALUE obj)
ctx_obj = rb_attr_get(obj, id_i_context);
cb = rb_attr_get(ctx_obj, id_i_client_cert_cb);
if (NIL_P(cb))
- return Qnil;
+ return Qnil;
ary = rb_funcallv(cb, id_call, 1, &obj);
Check_Type(ary, T_ARRAY);
@@ -232,7 +123,7 @@ ossl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
ret = rb_protect(ossl_call_client_cert_cb, obj, NULL);
if (NIL_P(ret))
- return 0;
+ return 0;
*x509 = DupX509CertPtr(RARRAY_AREF(ret, 0));
*pkey = DupPKeyPtr(RARRAY_AREF(ret, 1));
@@ -243,8 +134,6 @@ ossl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
#if !defined(OPENSSL_NO_DH)
struct tmp_dh_callback_args {
VALUE ssl_obj;
- ID id;
- int type;
int is_export;
int keylength;
};
@@ -253,48 +142,36 @@ static VALUE
ossl_call_tmp_dh_callback(VALUE arg)
{
struct tmp_dh_callback_args *args = (struct tmp_dh_callback_args *)arg;
- VALUE cb, dh;
- EVP_PKEY *pkey;
+ VALUE ctx_obj, cb, obj;
+ const DH *dh;
- cb = rb_funcall(args->ssl_obj, args->id, 0);
+ ctx_obj = rb_attr_get(args->ssl_obj, id_i_context);
+ cb = rb_attr_get(ctx_obj, id_i_tmp_dh_callback);
if (NIL_P(cb))
- return (VALUE)NULL;
- dh = rb_funcall(cb, id_call, 3, args->ssl_obj, INT2NUM(args->is_export),
- INT2NUM(args->keylength));
- pkey = GetPKeyPtr(dh);
- if (EVP_PKEY_base_id(pkey) != args->type)
- return (VALUE)NULL;
+ return (VALUE)NULL;
+
+ obj = rb_funcall(cb, id_call, 3, args->ssl_obj, INT2NUM(args->is_export),
+ INT2NUM(args->keylength));
+ // TODO: We should riase if obj is not DH
+ dh = EVP_PKEY_get0_DH(GetPKeyPtr(obj));
+ if (!dh)
+ ossl_clear_error();
- return (VALUE)pkey;
+ return (VALUE)dh;
}
-#endif
-#if !defined(OPENSSL_NO_DH)
static DH *
ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
{
- VALUE rb_ssl;
- EVP_PKEY *pkey;
- struct tmp_dh_callback_args args;
int state;
-
- rb_ssl = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
- args.ssl_obj = rb_ssl;
- args.id = id_tmp_dh_callback;
- args.is_export = is_export;
- args.keylength = keylength;
- args.type = EVP_PKEY_DH;
-
- pkey = (EVP_PKEY *)rb_protect(ossl_call_tmp_dh_callback,
- (VALUE)&args, &state);
+ VALUE rb_ssl = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
+ struct tmp_dh_callback_args args = {rb_ssl, is_export, keylength};
+ VALUE ret = rb_protect(ossl_call_tmp_dh_callback, (VALUE)&args, &state);
if (state) {
- rb_ivar_set(rb_ssl, ID_callback_state, INT2NUM(state));
- return NULL;
+ rb_ivar_set(rb_ssl, ID_callback_state, INT2NUM(state));
+ return NULL;
}
- if (!pkey)
- return NULL;
-
- return (DH *)EVP_PKEY_get0_DH(pkey);
+ return (DH *)ret;
}
#endif /* OPENSSL_NO_DH */
@@ -310,13 +187,13 @@ call_verify_certificate_identity(VALUE ctx_v)
hostname = rb_attr_get(ssl_obj, id_i_hostname);
if (!RTEST(hostname)) {
- rb_warning("verify_hostname requires hostname to be set");
- return Qtrue;
+ rb_warning("verify_hostname requires hostname to be set");
+ return Qtrue;
}
cert_obj = ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx));
return rb_funcall(mSSL, rb_intern("verify_certificate_identity"), 2,
- cert_obj, hostname);
+ cert_obj, hostname);
}
static int
@@ -327,25 +204,21 @@ ossl_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
int status;
ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
- cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx);
ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
sslctx_obj = rb_attr_get(ssl_obj, id_i_context);
+ cb = rb_attr_get(sslctx_obj, id_i_verify_callback);
verify_hostname = rb_attr_get(sslctx_obj, id_i_verify_hostname);
if (preverify_ok && RTEST(verify_hostname) && !SSL_is_server(ssl) &&
- !X509_STORE_CTX_get_error_depth(ctx)) {
- ret = rb_protect(call_verify_certificate_identity, (VALUE)ctx, &status);
- if (status) {
- rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(status));
- return 0;
- }
+ !X509_STORE_CTX_get_error_depth(ctx)) {
+ ret = rb_protect(call_verify_certificate_identity, (VALUE)ctx, &status);
+ if (status) {
+ rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(status));
+ return 0;
+ }
if (ret != Qtrue) {
preverify_ok = 0;
-#if defined(X509_V_ERR_HOSTNAME_MISMATCH)
X509_STORE_CTX_set_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH);
-#else
- X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
-#endif
}
}
@@ -367,11 +240,7 @@ ossl_call_session_get_cb(VALUE ary)
}
static SSL_SESSION *
-#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER >= 0x10100000
ossl_sslctx_session_get_cb(SSL *ssl, const unsigned char *buf, int len, int *copy)
-#else
-ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy)
-#endif
{
VALUE ary, ssl_obj, ret_obj;
SSL_SESSION *sess;
@@ -444,7 +313,7 @@ ossl_sslctx_session_new_cb(SSL *ssl, SSL_SESSION *sess)
return 0;
}
-#if OPENSSL_VERSION_NUMBER >= 0x10101000 && !defined(LIBRESSL_VERSION_NUMBER)
+#if !OSSL_IS_LIBRESSL
/*
* It is only compatible with OpenSSL >= 1.1.1. Even if LibreSSL implements
* SSL_CTX_set_keylog_callback() from v3.4.2, it does nothing (see
@@ -517,7 +386,7 @@ ossl_sslctx_session_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
* when SSL_CTX_free() is called.
*/
if (rb_during_gc())
- return;
+ return;
OSSL_Debug("SSL SESSION remove callback entered");
@@ -548,8 +417,9 @@ ossl_sslctx_add_extra_chain_cert_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
GetSSLCTX(arg, ctx);
x509 = DupX509CertPtr(i);
- if(!SSL_CTX_add_extra_chain_cert(ctx, x509)){
- ossl_raise(eSSLError, NULL);
+ if (!SSL_CTX_add_extra_chain_cert(ctx, x509)) {
+ X509_free(x509);
+ ossl_raise(eSSLError, "SSL_CTX_add_extra_chain_cert");
}
return i;
@@ -558,52 +428,42 @@ ossl_sslctx_add_extra_chain_cert_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
static VALUE ossl_sslctx_setup(VALUE self);
static VALUE
-ossl_call_servername_cb(VALUE ary)
+ossl_call_servername_cb(VALUE arg)
{
- VALUE ssl_obj, sslctx_obj, cb, ret_obj;
-
- Check_Type(ary, T_ARRAY);
- ssl_obj = rb_ary_entry(ary, 0);
+ SSL *ssl = (void *)arg;
+ const char *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+ if (!servername)
+ return Qnil;
- sslctx_obj = rb_attr_get(ssl_obj, id_i_context);
- cb = rb_attr_get(sslctx_obj, id_i_servername_cb);
- if (NIL_P(cb)) return Qnil;
+ VALUE ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
+ VALUE sslctx_obj = rb_attr_get(ssl_obj, id_i_context);
+ VALUE cb = rb_attr_get(sslctx_obj, id_i_servername_cb);
+ VALUE ary = rb_assoc_new(ssl_obj, rb_str_new_cstr(servername));
- ret_obj = rb_funcallv(cb, id_call, 1, &ary);
+ VALUE ret_obj = rb_funcallv(cb, id_call, 1, &ary);
if (rb_obj_is_kind_of(ret_obj, cSSLContext)) {
- SSL *ssl;
SSL_CTX *ctx2;
-
ossl_sslctx_setup(ret_obj);
- GetSSL(ssl_obj, ssl);
GetSSLCTX(ret_obj, ctx2);
- SSL_set_SSL_CTX(ssl, ctx2);
+ if (!SSL_set_SSL_CTX(ssl, ctx2))
+ ossl_raise(eSSLError, "SSL_set_SSL_CTX");
rb_ivar_set(ssl_obj, id_i_context, ret_obj);
} else if (!NIL_P(ret_obj)) {
- ossl_raise(rb_eArgError, "servername_cb must return an "
- "OpenSSL::SSL::SSLContext object or nil");
+ ossl_raise(rb_eArgError, "servername_cb must return an "
+ "OpenSSL::SSL::SSLContext object or nil");
}
- return ret_obj;
+ return Qnil;
}
static int
ssl_servername_cb(SSL *ssl, int *ad, void *arg)
{
- VALUE ary, ssl_obj;
- int state = 0;
- const char *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
-
- if (!servername)
- return SSL_TLSEXT_ERR_OK;
-
- ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
- ary = rb_ary_new2(2);
- rb_ary_push(ary, ssl_obj);
- rb_ary_push(ary, rb_str_new2(servername));
+ int state;
- rb_protect(ossl_call_servername_cb, ary, &state);
+ rb_protect(ossl_call_servername_cb, (VALUE)ssl, &state);
if (state) {
+ VALUE ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
@@ -630,7 +490,7 @@ ssl_npn_encode_protocol_i(RB_BLOCK_CALL_FUNC_ARGLIST(cur, encoded))
int len = RSTRING_LENINT(cur);
char len_byte;
if (len < 1 || len > 255)
- ossl_raise(eSSLError, "Advertised protocol must have length 1..255");
+ ossl_raise(eSSLError, "Advertised protocol must have length 1..255");
/* Encode the length byte */
len_byte = len;
rb_str_buf_cat(encoded, &len_byte, 1);
@@ -664,16 +524,16 @@ npn_select_cb_common_i(VALUE tmp)
/* assume OpenSSL verifies this format */
/* The format is len_1|proto_1|...|len_n|proto_n */
while (in < in_end) {
- l = *in++;
- rb_ary_push(protocols, rb_str_new((const char *)in, l));
- in += l;
+ l = *in++;
+ rb_ary_push(protocols, rb_str_new((const char *)in, l));
+ in += l;
}
selected = rb_funcallv(args->cb, id_call, 1, &protocols);
StringValue(selected);
len = RSTRING_LEN(selected);
if (len < 1 || len >= 256) {
- ossl_raise(eSSLError, "Selected protocol name must have length 1..255");
+ ossl_raise(eSSLError, "Selected protocol name must have length 1..255");
}
return selected;
@@ -681,8 +541,8 @@ npn_select_cb_common_i(VALUE tmp)
static int
ssl_npn_select_cb_common(SSL *ssl, VALUE cb, const unsigned char **out,
- unsigned char *outlen, const unsigned char *in,
- unsigned int inlen)
+ unsigned char *outlen, const unsigned char *in,
+ unsigned int inlen)
{
VALUE selected;
int status;
@@ -694,10 +554,10 @@ ssl_npn_select_cb_common(SSL *ssl, VALUE cb, const unsigned char **out,
selected = rb_protect(npn_select_cb_common_i, (VALUE)&args, &status);
if (status) {
- VALUE ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
+ VALUE ssl_obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
- rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(status));
- return SSL_TLSEXT_ERR_ALERT_FATAL;
+ rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(status));
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
}
*out = (unsigned char *)RSTRING_PTR(selected);
@@ -709,7 +569,7 @@ ssl_npn_select_cb_common(SSL *ssl, VALUE cb, const unsigned char **out,
#ifdef OSSL_USE_NEXTPROTONEG
static int
ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen,
- void *arg)
+ void *arg)
{
VALUE protocols = rb_attr_get((VALUE)arg, id_npn_protocols_encoded);
@@ -721,7 +581,7 @@ ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen,
static int
ssl_npn_select_cb(SSL *ssl, unsigned char **out, unsigned char *outlen,
- const unsigned char *in, unsigned int inlen, void *arg)
+ const unsigned char *in, unsigned int inlen, void *arg)
{
VALUE sslctx_obj, cb;
@@ -729,13 +589,13 @@ ssl_npn_select_cb(SSL *ssl, unsigned char **out, unsigned char *outlen,
cb = rb_attr_get(sslctx_obj, id_i_npn_select_cb);
return ssl_npn_select_cb_common(ssl, cb, (const unsigned char **)out,
- outlen, in, inlen);
+ outlen, in, inlen);
}
#endif
static int
ssl_alpn_select_cb(SSL *ssl, const unsigned char **out, unsigned char *outlen,
- const unsigned char *in, unsigned int inlen, void *arg)
+ const unsigned char *in, unsigned int inlen, void *arg)
{
VALUE sslctx_obj, cb;
@@ -752,12 +612,15 @@ ssl_info_cb(const SSL *ssl, int where, int val)
int is_server = SSL_is_server((SSL *)ssl);
if (is_server && where & SSL_CB_HANDSHAKE_START) {
- ssl_renegotiation_cb(ssl);
+ ssl_renegotiation_cb(ssl);
}
}
/*
- * Gets various OpenSSL options.
+ * call-seq:
+ * ctx.options -> integer
+ *
+ * Gets various \OpenSSL options.
*/
static VALUE
ossl_sslctx_get_options(VALUE self)
@@ -772,7 +635,17 @@ ossl_sslctx_get_options(VALUE self)
}
/*
- * Sets various OpenSSL options.
+ * call-seq:
+ * ctx.options = integer
+ *
+ * Sets various \OpenSSL options. The options are a bit field and can be
+ * combined with the bitwise OR operator (<tt>|</tt>). Available options are
+ * defined as constants in OpenSSL::SSL that begin with +OP_+.
+ *
+ * For backwards compatibility, passing +nil+ has the same effect as passing
+ * OpenSSL::SSL::OP_ALL.
+ *
+ * See also man page SSL_CTX_set_options(3).
*/
static VALUE
ossl_sslctx_set_options(VALUE self, VALUE options)
@@ -785,9 +658,9 @@ ossl_sslctx_set_options(VALUE self, VALUE options)
SSL_CTX_clear_options(ctx, SSL_CTX_get_options(ctx));
if (NIL_P(options)) {
- SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ SSL_CTX_set_options(ctx, SSL_OP_ALL);
} else {
- SSL_CTX_set_options(ctx, NUM2ULONG(options));
+ SSL_CTX_set_options(ctx, NUM2ULONG(options));
}
return self;
@@ -817,23 +690,26 @@ ossl_sslctx_setup(VALUE self)
GetSSLCTX(self, ctx);
#if !defined(OPENSSL_NO_DH)
- SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
+ if (!NIL_P(rb_attr_get(self, id_i_tmp_dh_callback))) {
+ SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
+ SSL_CTX_set_dh_auto(ctx, 0);
+ }
#endif
-#ifdef HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH
+#if !defined(OPENSSL_IS_AWSLC) /* AWS-LC has no support for TLS 1.3 PHA. */
SSL_CTX_set_post_handshake_auth(ctx, 1);
#endif
val = rb_attr_get(self, id_i_cert_store);
if (!NIL_P(val)) {
- X509_STORE *store = GetX509StorePtr(val); /* NO NEED TO DUP */
- SSL_CTX_set_cert_store(ctx, store);
- X509_STORE_up_ref(store);
+ X509_STORE *store = GetX509StorePtr(val); /* NO NEED TO DUP */
+ SSL_CTX_set_cert_store(ctx, store);
+ X509_STORE_up_ref(store);
}
val = rb_attr_get(self, id_i_extra_chain_cert);
if(!NIL_P(val)){
- rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self);
+ rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self);
}
/* private key may be bundled in certificate file. */
@@ -857,22 +733,22 @@ ossl_sslctx_setup(VALUE self)
val = rb_attr_get(self, id_i_client_ca);
if(!NIL_P(val)){
- if (RB_TYPE_P(val, T_ARRAY)) {
- for(i = 0; i < RARRAY_LEN(val); i++){
- client_ca = GetX509CertPtr(RARRAY_AREF(val, i));
- if (!SSL_CTX_add_client_CA(ctx, client_ca)){
- /* Copies X509_NAME => FREE it. */
- ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
- }
- }
+ if (RB_TYPE_P(val, T_ARRAY)) {
+ for(i = 0; i < RARRAY_LEN(val); i++){
+ client_ca = GetX509CertPtr(RARRAY_AREF(val, i));
+ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ }
+ }
}
- else{
- client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */
+ else{
+ client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */
if (!SSL_CTX_add_client_CA(ctx, client_ca)){
- /* Copies X509_NAME => FREE it. */
- ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
}
- }
+ }
}
val = rb_attr_get(self, id_i_ca_file);
@@ -885,9 +761,9 @@ ossl_sslctx_setup(VALUE self)
if (ca_path && !SSL_CTX_load_verify_dir(ctx, ca_path))
ossl_raise(eSSLError, "SSL_CTX_load_verify_dir");
#else
- if(ca_file || ca_path){
- if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
- rb_warning("can't set verify locations");
+ if (ca_file || ca_path) {
+ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
+ ossl_raise(eSSLError, "SSL_CTX_load_verify_locations");
}
#endif
@@ -895,7 +771,7 @@ ossl_sslctx_setup(VALUE self)
verify_mode = NIL_P(val) ? SSL_VERIFY_NONE : NUM2INT(val);
SSL_CTX_set_verify(ctx, verify_mode, ossl_ssl_verify_callback);
if (RTEST(rb_attr_get(self, id_i_client_cert_cb)))
- SSL_CTX_set_client_cert_cb(ctx, ossl_client_cert_cb);
+ SSL_CTX_set_client_cert_cb(ctx, ossl_client_cert_cb);
val = rb_attr_get(self, id_i_timeout);
if(!NIL_P(val)) SSL_CTX_set_timeout(ctx, NUM2LONG(val));
@@ -906,63 +782,63 @@ ossl_sslctx_setup(VALUE self)
#ifdef OSSL_USE_NEXTPROTONEG
val = rb_attr_get(self, id_i_npn_protocols);
if (!NIL_P(val)) {
- VALUE encoded = ssl_encode_npn_protocols(val);
- rb_ivar_set(self, id_npn_protocols_encoded, encoded);
- SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)self);
- OSSL_Debug("SSL NPN advertise callback added");
+ VALUE encoded = ssl_encode_npn_protocols(val);
+ rb_ivar_set(self, id_npn_protocols_encoded, encoded);
+ SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)self);
+ OSSL_Debug("SSL NPN advertise callback added");
}
if (RTEST(rb_attr_get(self, id_i_npn_select_cb))) {
- SSL_CTX_set_next_proto_select_cb(ctx, ssl_npn_select_cb, (void *) self);
- OSSL_Debug("SSL NPN select callback added");
+ SSL_CTX_set_next_proto_select_cb(ctx, ssl_npn_select_cb, (void *) self);
+ OSSL_Debug("SSL NPN select callback added");
}
#endif
val = rb_attr_get(self, id_i_alpn_protocols);
if (!NIL_P(val)) {
- VALUE rprotos = ssl_encode_npn_protocols(val);
+ VALUE rprotos = ssl_encode_npn_protocols(val);
- /* returns 0 on success */
- if (SSL_CTX_set_alpn_protos(ctx, (unsigned char *)RSTRING_PTR(rprotos),
- RSTRING_LENINT(rprotos)))
- ossl_raise(eSSLError, "SSL_CTX_set_alpn_protos");
- OSSL_Debug("SSL ALPN values added");
+ /* returns 0 on success */
+ if (SSL_CTX_set_alpn_protos(ctx, (unsigned char *)RSTRING_PTR(rprotos),
+ RSTRING_LENINT(rprotos)))
+ ossl_raise(eSSLError, "SSL_CTX_set_alpn_protos");
+ OSSL_Debug("SSL ALPN values added");
}
if (RTEST(rb_attr_get(self, id_i_alpn_select_cb))) {
- SSL_CTX_set_alpn_select_cb(ctx, ssl_alpn_select_cb, (void *) self);
- OSSL_Debug("SSL ALPN select callback added");
+ SSL_CTX_set_alpn_select_cb(ctx, ssl_alpn_select_cb, (void *) self);
+ OSSL_Debug("SSL ALPN select callback added");
}
rb_obj_freeze(self);
val = rb_attr_get(self, id_i_session_id_context);
if (!NIL_P(val)){
- StringValue(val);
- if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val),
- RSTRING_LENINT(val))){
- ossl_raise(eSSLError, "SSL_CTX_set_session_id_context");
- }
+ StringValue(val);
+ if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val),
+ RSTRING_LENINT(val))){
+ ossl_raise(eSSLError, "SSL_CTX_set_session_id_context");
+ }
}
if (RTEST(rb_attr_get(self, id_i_session_get_cb))) {
- SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb);
- OSSL_Debug("SSL SESSION get callback added");
+ SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb);
+ OSSL_Debug("SSL SESSION get callback added");
}
if (RTEST(rb_attr_get(self, id_i_session_new_cb))) {
- SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb);
- OSSL_Debug("SSL SESSION new callback added");
+ SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb);
+ OSSL_Debug("SSL SESSION new callback added");
}
if (RTEST(rb_attr_get(self, id_i_session_remove_cb))) {
- SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb);
- OSSL_Debug("SSL SESSION remove callback added");
+ SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb);
+ OSSL_Debug("SSL SESSION remove callback added");
}
val = rb_attr_get(self, id_i_servername_cb);
if (!NIL_P(val)) {
SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb);
- OSSL_Debug("SSL TLSEXT servername callback added");
+ OSSL_Debug("SSL TLSEXT servername callback added");
}
-#if OPENSSL_VERSION_NUMBER >= 0x10101000 && !defined(LIBRESSL_VERSION_NUMBER)
+#if !OSSL_IS_LIBRESSL
/*
* It is only compatible with OpenSSL >= 1.1.1. Even if LibreSSL implements
* SSL_CTX_set_keylog_callback() from v3.4.2, it does nothing (see
@@ -977,6 +853,93 @@ ossl_sslctx_setup(VALUE self)
return Qtrue;
}
+static int
+parse_proto_version(VALUE str)
+{
+ int i;
+ static const struct {
+ const char *name;
+ int version;
+ } map[] = {
+ { "SSL2", SSL2_VERSION },
+ { "SSL3", SSL3_VERSION },
+ { "TLS1", TLS1_VERSION },
+ { "TLS1_1", TLS1_1_VERSION },
+ { "TLS1_2", TLS1_2_VERSION },
+ { "TLS1_3", TLS1_3_VERSION },
+ };
+
+ if (NIL_P(str))
+ return 0;
+ if (RB_INTEGER_TYPE_P(str))
+ return NUM2INT(str);
+
+ if (SYMBOL_P(str))
+ str = rb_sym2str(str);
+ StringValue(str);
+ for (i = 0; i < numberof(map); i++)
+ if (!strncmp(map[i].name, RSTRING_PTR(str), RSTRING_LEN(str)))
+ return map[i].version;
+ rb_raise(rb_eArgError, "unrecognized version %+"PRIsVALUE, str);
+}
+
+/*
+ * call-seq:
+ * ctx.min_version = OpenSSL::SSL::TLS1_2_VERSION
+ * ctx.min_version = :TLS1_2
+ * ctx.min_version = nil
+ *
+ * Sets the lower bound on the supported SSL/TLS protocol version. The
+ * version may be specified by an integer constant named
+ * OpenSSL::SSL::*_VERSION, a Symbol, or +nil+ which means "any version".
+ *
+ * === Example
+ * ctx = OpenSSL::SSL::SSLContext.new
+ * ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
+ * ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
+ *
+ * sock = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx)
+ * sock.connect # Initiates a connection using either TLS 1.1 or TLS 1.2
+ */
+static VALUE
+ossl_sslctx_set_min_version(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+ int version;
+
+ rb_check_frozen(self);
+ GetSSLCTX(self, ctx);
+ version = parse_proto_version(v);
+
+ if (!SSL_CTX_set_min_proto_version(ctx, version))
+ ossl_raise(eSSLError, "SSL_CTX_set_min_proto_version");
+ return v;
+}
+
+/*
+ * call-seq:
+ * ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
+ * ctx.max_version = :TLS1_2
+ * ctx.max_version = nil
+ *
+ * Sets the upper bound of the supported SSL/TLS protocol version. See
+ * #min_version= for the possible values.
+ */
+static VALUE
+ossl_sslctx_set_max_version(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+ int version;
+
+ rb_check_frozen(self);
+ GetSSLCTX(self, ctx);
+ version = parse_proto_version(v);
+
+ if (!SSL_CTX_set_max_proto_version(ctx, version))
+ ossl_raise(eSSLError, "SSL_CTX_set_max_proto_version");
+ return v;
+}
+
static VALUE
ossl_ssl_cipher_to_ary(const SSL_CIPHER *cipher)
{
@@ -1026,11 +989,10 @@ static VALUE
build_cipher_string(VALUE v)
{
VALUE str, elem;
- int i;
if (RB_TYPE_P(v, T_ARRAY)) {
str = rb_str_new(0, 0);
- for (i = 0; i < RARRAY_LEN(v); i++) {
+ for (long i = 0; i < RARRAY_LEN(v); i++) {
elem = rb_ary_entry(v, i);
if (RB_TYPE_P(elem, T_ARRAY)) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
@@ -1051,9 +1013,14 @@ build_cipher_string(VALUE v)
* ctx.ciphers = [name, ...]
* ctx.ciphers = [[name, version, bits, alg_bits], ...]
*
- * Sets the list of available cipher suites for this context. Note in a server
- * context some ciphers require the appropriate certificates. For example, an
- * RSA cipher suite can only be chosen when an RSA certificate is available.
+ * Sets the list of available cipher suites for TLS 1.2 and below for this
+ * context.
+ *
+ * Note in a server context some ciphers require the appropriate certificates.
+ * For example, an RSA cipher suite can only be chosen when an RSA certificate
+ * is available.
+ *
+ * This method does not affect TLS 1.3 connections. See also #ciphersuites=.
*/
static VALUE
ossl_sslctx_set_ciphers(VALUE self, VALUE v)
@@ -1062,6 +1029,7 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
VALUE str;
rb_check_frozen(self);
+ // Assigning nil is a no-op for compatibility
if (NIL_P(v))
return v;
@@ -1074,14 +1042,12 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
return v;
}
-#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
/*
* call-seq:
* ctx.ciphersuites = "cipher1:cipher2:..."
* ctx.ciphersuites = [name, ...]
- * ctx.ciphersuites = [[name, version, bits, alg_bits], ...]
*
- * Sets the list of available TLSv1.3 cipher suites for this context.
+ * Sets the list of available TLS 1.3 cipher suites for this context.
*/
static VALUE
ossl_sslctx_set_ciphersuites(VALUE self, VALUE v)
@@ -1090,6 +1056,7 @@ ossl_sslctx_set_ciphersuites(VALUE self, VALUE v)
VALUE str;
rb_check_frozen(self);
+ // Assigning nil is a no-op for compatibility
if (NIL_P(v))
return v;
@@ -1101,6 +1068,62 @@ ossl_sslctx_set_ciphersuites(VALUE self, VALUE v)
return v;
}
+
+#ifdef HAVE_SSL_CTX_SET1_SIGALGS_LIST
+/*
+ * call-seq:
+ * ctx.sigalgs = "sigalg1:sigalg2:..."
+ *
+ * Sets the list of "supported signature algorithms" for this context.
+ *
+ * For a TLS client, the list is used in the "signature_algorithms" extension
+ * in the ClientHello message. For a server, the list is used by OpenSSL to
+ * determine the set of shared signature algorithms. OpenSSL will pick the most
+ * appropriate one from it.
+ *
+ * See also #client_sigalgs= for the client authentication equivalent.
+ */
+static VALUE
+ossl_sslctx_set_sigalgs(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+
+ rb_check_frozen(self);
+ GetSSLCTX(self, ctx);
+
+ if (!SSL_CTX_set1_sigalgs_list(ctx, StringValueCStr(v)))
+ ossl_raise(eSSLError, "SSL_CTX_set1_sigalgs_list");
+
+ return v;
+}
+#endif
+
+#ifdef HAVE_SSL_CTX_SET1_CLIENT_SIGALGS_LIST
+/*
+ * call-seq:
+ * ctx.client_sigalgs = "sigalg1:sigalg2:..."
+ *
+ * Sets the list of "supported signature algorithms" for client authentication
+ * for this context.
+ *
+ * For a TLS server, the list is sent to the client as part of the
+ * CertificateRequest message.
+ *
+ * See also #sigalgs= for the server authentication equivalent.
+ */
+static VALUE
+ossl_sslctx_set_client_sigalgs(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+
+ rb_check_frozen(self);
+ GetSSLCTX(self, ctx);
+
+ if (!SSL_CTX_set1_client_sigalgs_list(ctx, StringValueCStr(v)))
+ ossl_raise(eSSLError, "SSL_CTX_set1_client_sigalgs_list");
+
+ return v;
+}
#endif
#ifndef OPENSSL_NO_DH
@@ -1115,7 +1138,7 @@ ossl_sslctx_set_ciphersuites(VALUE self, VALUE v)
* contained in the key object, if any, are ignored. The server will always
* generate a new key pair for each handshake.
*
- * Added in version 3.0. See also the man page SSL_set0_tmp_dh_pkey(3).
+ * Added in version 3.0. See also the man page SSL_CTX_set0_tmp_dh_pkey(3).
*
* Example:
* ctx = OpenSSL::SSL::SSLContext.new
@@ -1136,7 +1159,7 @@ ossl_sslctx_set_tmp_dh(VALUE self, VALUE arg)
if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH)
rb_raise(eSSLError, "invalid pkey type %s (expected DH)",
OBJ_nid2sn(EVP_PKEY_base_id(pkey)));
-#ifdef HAVE_SSL_SET0_TMP_DH_PKEY
+#ifdef HAVE_SSL_CTX_SET0_TMP_DH_PKEY
if (!SSL_CTX_set0_tmp_dh_pkey(ctx, pkey))
ossl_raise(eSSLError, "SSL_CTX_set0_tmp_dh_pkey");
EVP_PKEY_up_ref(pkey);
@@ -1145,29 +1168,36 @@ ossl_sslctx_set_tmp_dh(VALUE self, VALUE arg)
ossl_raise(eSSLError, "SSL_CTX_set_tmp_dh");
#endif
+ // Turn off the "auto" DH parameters set by ossl_sslctx_s_alloc()
+ SSL_CTX_set_dh_auto(ctx, 0);
+
return arg;
}
#endif
-#if !defined(OPENSSL_NO_EC)
/*
* call-seq:
- * ctx.ecdh_curves = curve_list -> curve_list
+ * ctx.groups = groups_list
+ * ctx.ecdh_curves = groups_list
+ *
+ * Sets the list of supported groups for key agreement for this context.
+ *
+ * For a TLS client, the list is directly used in the "supported_groups"
+ * extension. For a server, the list is used by OpenSSL to determine the set of
+ * shared supported groups. OpenSSL will pick the most appropriate one from it.
*
- * Sets the list of "supported elliptic curves" for this context.
+ * #ecdh_curves= is a deprecated alias for #groups=.
*
- * For a TLS client, the list is directly used in the Supported Elliptic Curves
- * Extension. For a server, the list is used by OpenSSL to determine the set of
- * shared curves. OpenSSL will pick the most appropriate one from it.
+ * See also the man page SSL_CTX_set1_groups_list(3).
*
* === Example
* ctx1 = OpenSSL::SSL::SSLContext.new
- * ctx1.ecdh_curves = "X25519:P-256:P-224"
+ * ctx1.groups = "X25519:P-256:P-224"
* svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1)
* Thread.new { svr.accept }
*
* ctx2 = OpenSSL::SSL::SSLContext.new
- * ctx2.ecdh_curves = "P-256"
+ * ctx2.groups = "P-256"
* cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2)
* cli.connect
*
@@ -1175,7 +1205,7 @@ ossl_sslctx_set_tmp_dh(VALUE self, VALUE arg)
* # => "prime256v1" (is an alias for NIST P-256)
*/
static VALUE
-ossl_sslctx_set_ecdh_curves(VALUE self, VALUE arg)
+ossl_sslctx_set_groups(VALUE self, VALUE arg)
{
SSL_CTX *ctx;
@@ -1183,13 +1213,10 @@ ossl_sslctx_set_ecdh_curves(VALUE self, VALUE arg)
GetSSLCTX(self, ctx);
StringValueCStr(arg);
- if (!SSL_CTX_set1_curves_list(ctx, RSTRING_PTR(arg)))
- ossl_raise(eSSLError, NULL);
+ if (!SSL_CTX_set1_groups_list(ctx, RSTRING_PTR(arg)))
+ ossl_raise(eSSLError, "SSL_CTX_set1_groups_list");
return arg;
}
-#else
-#define ossl_sslctx_set_ecdh_curves rb_f_notimplement
-#endif
/*
* call-seq:
@@ -1206,12 +1233,7 @@ ossl_sslctx_get_security_level(VALUE self)
GetSSLCTX(self, ctx);
-#if defined(HAVE_SSL_CTX_GET_SECURITY_LEVEL)
return INT2NUM(SSL_CTX_get_security_level(ctx));
-#else
- (void)ctx;
- return INT2FIX(0);
-#endif
}
/*
@@ -1241,14 +1263,7 @@ ossl_sslctx_set_security_level(VALUE self, VALUE value)
rb_check_frozen(self);
GetSSLCTX(self, ctx);
-#if defined(HAVE_SSL_CTX_GET_SECURITY_LEVEL)
SSL_CTX_set_security_level(ctx, NUM2INT(value));
-#else
- (void)ctx;
- if (NUM2INT(value) != 0)
- ossl_raise(rb_eNotImpError, "setting security level to other than 0 is "
- "not supported in this version of OpenSSL");
-#endif
return value;
}
@@ -1330,20 +1345,20 @@ ossl_sslctx_add_certificate(int argc, VALUE *argv, VALUE self)
pub_pkey = X509_get_pubkey(x509);
EVP_PKEY_free(pub_pkey);
if (!pub_pkey)
- rb_raise(rb_eArgError, "certificate does not contain public key");
+ rb_raise(rb_eArgError, "certificate does not contain public key");
if (EVP_PKEY_eq(pub_pkey, pkey) != 1)
- rb_raise(rb_eArgError, "public key mismatch");
+ rb_raise(rb_eArgError, "public key mismatch");
if (argc >= 3)
- extra_chain = ossl_x509_ary2sk(extra_chain_ary);
+ extra_chain = ossl_x509_ary2sk(extra_chain_ary);
if (!SSL_CTX_use_certificate(ctx, x509)) {
- sk_X509_pop_free(extra_chain, X509_free);
- ossl_raise(eSSLError, "SSL_CTX_use_certificate");
+ sk_X509_pop_free(extra_chain, X509_free);
+ ossl_raise(eSSLError, "SSL_CTX_use_certificate");
}
if (!SSL_CTX_use_PrivateKey(ctx, pkey)) {
- sk_X509_pop_free(extra_chain, X509_free);
- ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey");
+ sk_X509_pop_free(extra_chain, X509_free);
+ ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey");
}
if (extra_chain && !SSL_CTX_set0_chain(ctx, extra_chain)) {
sk_X509_pop_free(extra_chain, X509_free);
@@ -1553,7 +1568,6 @@ ossl_ssl_mark(void *ptr)
{
SSL *ssl = ptr;
rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx));
- rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx));
}
static void
@@ -1567,7 +1581,7 @@ const rb_data_type_t ossl_ssl_type = {
{
ossl_ssl_mark, ossl_ssl_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -1577,32 +1591,31 @@ ossl_ssl_s_alloc(VALUE klass)
}
static VALUE
-peer_ip_address(VALUE self)
+peer_ip_address(VALUE io)
{
- VALUE remote_address = rb_funcall(rb_attr_get(self, id_i_io), rb_intern("remote_address"), 0);
+ VALUE remote_address = rb_funcall(io, rb_intern("remote_address"), 0);
return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0);
}
static VALUE
-fallback_peer_ip_address(VALUE self, VALUE args)
+fallback_peer_ip_address(VALUE self, VALUE exc)
{
return rb_str_new_cstr("(null)");
}
static VALUE
-peeraddr_ip_str(VALUE self)
+peeraddr_ip_str(VALUE io)
{
- VALUE rb_mErrno = rb_const_get(rb_cObject, rb_intern("Errno"));
- VALUE rb_eSystemCallError = rb_const_get(rb_mErrno, rb_intern("SystemCallError"));
-
- return rb_rescue2(peer_ip_address, self, fallback_peer_ip_address, (VALUE)0, rb_eSystemCallError, NULL);
+ return rb_rescue2(peer_ip_address, io, fallback_peer_ip_address, Qnil,
+ rb_eSystemCallError, (VALUE)0);
}
/*
* call-seq:
* SSLSocket.new(io) => aSSLSocket
* SSLSocket.new(io, ctx) => aSSLSocket
+ * SSLSocket.new(io, ctx, sync_close:) => aSSLSocket
*
* Creates a new SSL socket from _io_ which must be a real IO object (not an
* IO-like object that responds to read/write).
@@ -1610,6 +1623,10 @@ peeraddr_ip_str(VALUE self)
* If _ctx_ is provided the SSL Sockets initial params will be taken from
* the context.
*
+ * The optional _sync_close_ keyword parameter sets the _sync_close_ instance
+ * variable. Setting this to +true+ will cause the underlying socket to be
+ * closed when the SSL/TLS connection is shut down.
+ *
* The OpenSSL::Buffering module provides additional IO methods.
*
* This method will freeze the SSLContext if one is provided;
@@ -1618,41 +1635,64 @@ peeraddr_ip_str(VALUE self)
static VALUE
ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
{
- VALUE io, v_ctx, verify_cb;
+ static ID kw_ids[1];
+ VALUE kw_args[1];
+ VALUE opts;
+
+ VALUE io, v_ctx;
SSL *ssl;
SSL_CTX *ctx;
TypedData_Get_Struct(self, SSL, &ossl_ssl_type, ssl);
if (ssl)
- ossl_raise(eSSLError, "SSL already initialized");
+ ossl_raise(eSSLError, "SSL already initialized");
+
+ if (rb_scan_args(argc, argv, "11:", &io, &v_ctx, &opts) == 1)
+ v_ctx = rb_funcall(cSSLContext, rb_intern("new"), 0);
+
+ if (!kw_ids[0]) {
+ kw_ids[0] = rb_intern_const("sync_close");
+ }
- if (rb_scan_args(argc, argv, "11", &io, &v_ctx) == 1)
- v_ctx = rb_funcall(cSSLContext, rb_intern("new"), 0);
+ rb_get_kwargs(opts, kw_ids, 0, 1, kw_args);
+ if (kw_args[0] != Qundef) {
+ rb_ivar_set(self, id_i_sync_close, kw_args[0]);
+ }
GetSSLCTX(v_ctx, ctx);
rb_ivar_set(self, id_i_context, v_ctx);
ossl_sslctx_setup(v_ctx);
if (rb_respond_to(io, rb_intern("nonblock=")))
- rb_funcall(io, rb_intern("nonblock="), 1, Qtrue);
+ rb_funcall(io, rb_intern("nonblock="), 1, Qtrue);
Check_Type(io, T_FILE);
rb_ivar_set(self, id_i_io, io);
ssl = SSL_new(ctx);
if (!ssl)
- ossl_raise(eSSLError, NULL);
+ ossl_raise(eSSLError, NULL);
RTYPEDDATA_DATA(self) = ssl;
- SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void *)self);
+ if (!SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void *)self))
+ ossl_raise(eSSLError, "SSL_set_ex_data");
SSL_set_info_callback(ssl, ssl_info_cb);
- verify_cb = rb_attr_get(v_ctx, id_i_verify_callback);
- SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void *)verify_cb);
rb_call_super(0, NULL);
return self;
}
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
static VALUE
ossl_ssl_setup(VALUE self)
{
@@ -1662,36 +1702,40 @@ ossl_ssl_setup(VALUE self)
GetSSL(self, ssl);
if (ssl_started(ssl))
- return Qtrue;
+ return Qtrue;
io = rb_attr_get(self, id_i_io);
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_writable(fptr);
- if (!SSL_set_fd(ssl, TO_SOCKET(fptr->fd)))
- ossl_raise(eSSLError, "SSL_set_fd");
+ if (!SSL_set_fd(ssl, TO_SOCKET(rb_io_descriptor(io))))
+ ossl_raise(eSSLError, "SSL_set_fd");
return Qtrue;
}
+static int
+errno_mapped(void)
+{
#ifdef _WIN32
-#define ssl_get_error(ssl, ret) (errno = rb_w32_map_errno(WSAGetLastError()), SSL_get_error((ssl), (ret)))
+ return rb_w32_map_errno(WSAGetLastError());
#else
-#define ssl_get_error(ssl, ret) SSL_get_error((ssl), (ret))
+ return errno;
#endif
+}
static void
write_would_block(int nonblock)
{
if (nonblock)
- ossl_raise(eSSLErrorWaitWritable, "write would block");
+ ossl_raise(eSSLErrorWaitWritable, "write would block");
}
static void
read_would_block(int nonblock)
{
if (nonblock)
- ossl_raise(eSSLErrorWaitReadable, "read would block");
+ ossl_raise(eSSLErrorWaitReadable, "read would block");
}
static int
@@ -1699,7 +1743,7 @@ no_exception_p(VALUE opts)
{
if (RB_TYPE_P(opts, T_HASH) &&
rb_hash_lookup2(opts, sym_exception, Qundef) == Qfalse)
- return 1;
+ return 1;
return 0;
}
@@ -1708,23 +1752,38 @@ no_exception_p(VALUE opts)
#define RUBY_IO_TIMEOUT_DEFAULT Qnil
#endif
+#ifdef HAVE_RB_IO_TIMEOUT
+#define IO_TIMEOUT_ERROR rb_eIOTimeoutError
+#else
+#define IO_TIMEOUT_ERROR rb_eIOError
+#endif
+
+
static void
-io_wait_writable(rb_io_t *fptr)
+io_wait_writable(VALUE io)
{
#ifdef HAVE_RB_IO_MAYBE_WAIT
- rb_io_maybe_wait_writable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT);
+ if (!rb_io_wait(io, INT2NUM(RUBY_IO_WRITABLE), RUBY_IO_TIMEOUT_DEFAULT)) {
+ rb_raise(IO_TIMEOUT_ERROR, "Timed out while waiting to become writable!");
+ }
#else
- rb_io_wait_writable(fptr->fd);
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ rb_thread_fd_writable(fptr->fd);
#endif
}
static void
-io_wait_readable(rb_io_t *fptr)
+io_wait_readable(VALUE io)
{
#ifdef HAVE_RB_IO_MAYBE_WAIT
- rb_io_maybe_wait_readable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT);
+ if (!rb_io_wait(io, INT2NUM(RUBY_IO_READABLE), RUBY_IO_TIMEOUT_DEFAULT)) {
+ rb_raise(IO_TIMEOUT_ERROR, "Timed out while waiting to become readable!");
+ }
#else
- rb_io_wait_readable(fptr->fd);
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ rb_thread_wait_fd(fptr->fd);
#endif
}
@@ -1732,75 +1791,76 @@ static VALUE
ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
{
SSL *ssl;
- rb_io_t *fptr;
- int ret, ret2;
VALUE cb_state;
int nonblock = opts != Qfalse;
-#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
- unsigned long err;
-#endif
rb_ivar_set(self, ID_callback_state, Qnil);
GetSSL(self, ssl);
- GetOpenFile(rb_attr_get(self, id_i_io), fptr);
- for(;;){
- ret = func(ssl);
+ VALUE io = rb_attr_get(self, id_i_io);
+ for (;;) {
+ int ret = func(ssl);
+ int saved_errno = errno_mapped();
- cb_state = rb_attr_get(self, ID_callback_state);
+ cb_state = rb_attr_get(self, ID_callback_state);
if (!NIL_P(cb_state)) {
- /* must cleanup OpenSSL error stack before re-raising */
- ossl_clear_error();
- rb_jump_tag(NUM2INT(cb_state));
- }
+ /* must cleanup OpenSSL error stack before re-raising */
+ ossl_clear_error();
+ rb_jump_tag(NUM2INT(cb_state));
+ }
- if (ret > 0)
- break;
+ if (ret > 0)
+ break;
- switch((ret2 = ssl_get_error(ssl, ret))){
- case SSL_ERROR_WANT_WRITE:
+ int code = SSL_get_error(ssl, ret);
+ switch (code) {
+ case SSL_ERROR_WANT_WRITE:
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
- io_wait_writable(fptr);
+ io_wait_writable(io);
continue;
- case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_READ:
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
- io_wait_readable(fptr);
+ io_wait_readable(io);
continue;
- case SSL_ERROR_SYSCALL:
+ case SSL_ERROR_SYSCALL:
#ifdef __APPLE__
/* See ossl_ssl_write_internal() */
- if (errno == EPROTOTYPE)
+ if (saved_errno == EPROTOTYPE)
continue;
#endif
- if (errno) rb_sys_fail(funcname);
- ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl));
-
+ if (saved_errno)
+ rb_exc_raise(rb_syserr_new(saved_errno, funcname));
+ /* fallthrough */
+ default: {
+ VALUE error_append = Qnil;
#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
- case SSL_ERROR_SSL:
- err = ERR_peek_last_error();
- if (ERR_GET_LIB(err) == ERR_LIB_SSL &&
- ERR_GET_REASON(err) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
- const char *err_msg = ERR_reason_error_string(err),
- *verify_msg = X509_verify_cert_error_string(SSL_get_verify_result(ssl));
- if (!err_msg)
- err_msg = "(null)";
- if (!verify_msg)
- verify_msg = "(null)";
- ossl_clear_error(); /* let ossl_raise() not append message */
- ossl_raise(eSSLError, "%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s: %s (%s)",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl),
- err_msg, verify_msg);
- }
+ unsigned long err = ERR_peek_last_error();
+ if (ERR_GET_LIB(err) == ERR_LIB_SSL &&
+ ERR_GET_REASON(err) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
+ const char *err_msg = ERR_reason_error_string(err),
+ *verify_msg = X509_verify_cert_error_string(SSL_get_verify_result(ssl));
+ if (!err_msg)
+ err_msg = "(null)";
+ if (!verify_msg)
+ verify_msg = "(null)";
+ ossl_clear_error(); /* let ossl_raise() not append message */
+ error_append = rb_sprintf(": %s (%s)", err_msg, verify_msg);
+ }
#endif
- /* fallthrough */
- default:
- ossl_raise(eSSLError, "%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl));
- }
+ ossl_raise(eSSLError,
+ "%s%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s%"PRIsVALUE,
+ funcname,
+ code == SSL_ERROR_SYSCALL ? " SYSCALL" : "",
+ code,
+ saved_errno,
+ peeraddr_ip_str(io),
+ SSL_state_string_long(ssl),
+ error_append);
+ }
+ }
}
return self;
@@ -1905,14 +1965,13 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
{
SSL *ssl;
int ilen;
- VALUE len, str;
- rb_io_t *fptr;
- VALUE io, opts = Qnil;
+ VALUE len, str, cb_state;
+ VALUE opts = Qnil;
if (nonblock) {
- rb_scan_args(argc, argv, "11:", &len, &str, &opts);
+ rb_scan_args(argc, argv, "11:", &len, &str, &opts);
} else {
- rb_scan_args(argc, argv, "11", &len, &str);
+ rb_scan_args(argc, argv, "11", &len, &str);
}
GetSSL(self, ssl);
if (!ssl_started(ssl))
@@ -1920,54 +1979,60 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
ilen = NUM2INT(len);
if (NIL_P(str))
- str = rb_str_new(0, ilen);
+ str = rb_str_new(0, ilen);
else {
- StringValue(str);
- if (RSTRING_LEN(str) >= ilen)
- rb_str_modify(str);
- else
- rb_str_modify_expand(str, ilen - RSTRING_LEN(str));
+ StringValue(str);
+ if (RSTRING_LEN(str) >= ilen)
+ rb_str_modify(str);
+ else
+ rb_str_modify_expand(str, ilen - RSTRING_LEN(str));
}
- rb_str_set_len(str, 0);
- if (ilen == 0)
- return str;
- io = rb_attr_get(self, id_i_io);
- GetOpenFile(io, fptr);
+ if (ilen == 0) {
+ rb_str_set_len(str, 0);
+ return str;
+ }
+
+ VALUE io = rb_attr_get(self, id_i_io);
- rb_str_locktmp(str);
for (;;) {
+ rb_str_locktmp(str);
int nread = SSL_read(ssl, RSTRING_PTR(str), ilen);
- switch (ssl_get_error(ssl, nread)) {
+ int saved_errno = errno_mapped();
+ rb_str_unlocktmp(str);
+
+ cb_state = rb_attr_get(self, ID_callback_state);
+ if (!NIL_P(cb_state)) {
+ rb_ivar_set(self, ID_callback_state, Qnil);
+ ossl_clear_error();
+ rb_jump_tag(NUM2INT(cb_state));
+ }
+
+ switch (SSL_get_error(ssl, nread)) {
case SSL_ERROR_NONE:
- rb_str_unlocktmp(str);
rb_str_set_len(str, nread);
return str;
case SSL_ERROR_ZERO_RETURN:
- rb_str_unlocktmp(str);
if (no_exception_p(opts)) { return Qnil; }
rb_eof_error();
case SSL_ERROR_WANT_WRITE:
if (nonblock) {
- rb_str_unlocktmp(str);
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
}
- io_wait_writable(fptr);
- continue;
+ io_wait_writable(io);
+ break;
case SSL_ERROR_WANT_READ:
if (nonblock) {
- rb_str_unlocktmp(str);
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
}
- io_wait_readable(fptr);
- continue;
+ io_wait_readable(io);
+ break;
case SSL_ERROR_SYSCALL:
if (!ERR_peek_error()) {
- rb_str_unlocktmp(str);
- if (errno)
- rb_sys_fail(0);
+ if (saved_errno)
+ rb_exc_raise(rb_syserr_new(saved_errno, "SSL_read"));
else {
/*
* The underlying BIO returned 0. This is actually a
@@ -1982,9 +2047,13 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
}
/* fall through */
default:
- rb_str_unlocktmp(str);
ossl_raise(eSSLError, "SSL_read");
}
+
+ // Ensure the buffer is not modified during io_wait_*able()
+ rb_str_modify(str);
+ if (rb_str_capacity(str) < (size_t)ilen)
+ rb_raise(eSSLError, "read buffer was modified");
}
}
@@ -2022,40 +2091,53 @@ ossl_ssl_read_nonblock(int argc, VALUE *argv, VALUE self)
}
static VALUE
-ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
+ossl_ssl_write_internal_safe(VALUE _args)
{
+ VALUE *args = (VALUE*)_args;
+ VALUE self = args[0];
+ VALUE str = args[1];
+ VALUE opts = args[2];
+
SSL *ssl;
rb_io_t *fptr;
int num, nonblock = opts != Qfalse;
- VALUE tmp, io;
+ VALUE cb_state;
GetSSL(self, ssl);
if (!ssl_started(ssl))
rb_raise(eSSLError, "SSL session is not started yet");
- tmp = rb_str_new_frozen(StringValue(str));
- io = rb_attr_get(self, id_i_io);
+ VALUE io = rb_attr_get(self, id_i_io);
GetOpenFile(io, fptr);
/* SSL_write(3ssl) manpage states num == 0 is undefined */
- num = RSTRING_LENINT(tmp);
+ num = RSTRING_LENINT(str);
if (num == 0)
return INT2FIX(0);
for (;;) {
- int nwritten = SSL_write(ssl, RSTRING_PTR(tmp), num);
- switch (ssl_get_error(ssl, nwritten)) {
+ int nwritten = SSL_write(ssl, RSTRING_PTR(str), num);
+ int saved_errno = errno_mapped();
+
+ cb_state = rb_attr_get(self, ID_callback_state);
+ if (!NIL_P(cb_state)) {
+ rb_ivar_set(self, ID_callback_state, Qnil);
+ ossl_clear_error();
+ rb_jump_tag(NUM2INT(cb_state));
+ }
+
+ switch (SSL_get_error(ssl, nwritten)) {
case SSL_ERROR_NONE:
return INT2NUM(nwritten);
case SSL_ERROR_WANT_WRITE:
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
- io_wait_writable(fptr);
+ io_wait_writable(io);
continue;
case SSL_ERROR_WANT_READ:
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
- io_wait_readable(fptr);
+ io_wait_readable(io);
continue;
case SSL_ERROR_SYSCALL:
#ifdef __APPLE__
@@ -2065,10 +2147,11 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
* make the error handling in line with the socket library.
* [Bug #14713] https://bugs.ruby-lang.org/issues/14713
*/
- if (errno == EPROTOTYPE)
+ if (saved_errno == EPROTOTYPE)
continue;
#endif
- if (errno) rb_sys_fail(0);
+ if (saved_errno)
+ rb_exc_raise(rb_syserr_new(saved_errno, "SSL_write"));
/* fallthrough */
default:
ossl_raise(eSSLError, "SSL_write");
@@ -2076,6 +2159,28 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
}
}
+
+static VALUE
+ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
+{
+ StringValue(str);
+ int frozen = RB_OBJ_FROZEN(str);
+ if (!frozen) {
+ rb_str_locktmp(str);
+ }
+ int state;
+ VALUE args[3] = {self, str, opts};
+ VALUE result = rb_protect(ossl_ssl_write_internal_safe, (VALUE)args, &state);
+ if (!frozen) {
+ rb_str_unlocktmp(str);
+ }
+
+ if (state) {
+ rb_jump_tag(state);
+ }
+ return result;
+}
+
/*
* call-seq:
* ssl.syswrite(string) => Integer
@@ -2091,9 +2196,12 @@ ossl_ssl_write(VALUE self, VALUE str)
/*
* call-seq:
* ssl.syswrite_nonblock(string) => Integer
+ * ssl.syswrite_nonblock(string, opts) => Integer
*
* Writes _string_ to the SSL connection in a non-blocking manner. Raises an
- * SSLError if writing would block.
+ * SSLError if writing would block. If "exception: false" is passed, this
+ * method returns a symbol of :wait_readable or :wait_writable, rather than
+ * raising an exception.
*/
static VALUE
ossl_ssl_write_nonblock(int argc, VALUE *argv, VALUE self)
@@ -2120,12 +2228,12 @@ ossl_ssl_stop(VALUE self)
GetSSL(self, ssl);
if (!ssl_started(ssl))
- return Qnil;
+ return Qnil;
ret = SSL_shutdown(ssl);
if (ret == 1) /* Have already received close_notify */
- return Qnil;
+ return Qnil;
if (ret == 0) /* Sent close_notify, but we don't wait for reply */
- return Qnil;
+ return Qnil;
/*
* XXX: Something happened. Possibly it failed because the underlying socket
@@ -2211,20 +2319,20 @@ ossl_ssl_get_peer_cert_chain(VALUE self)
num = sk_X509_num(chain);
ary = rb_ary_new2(num);
for (i = 0; i < num; i++){
- cert = sk_X509_value(chain, i);
- rb_ary_push(ary, ossl_x509_new(cert));
+ cert = sk_X509_value(chain, i);
+ rb_ary_push(ary, ossl_x509_new(cert));
}
return ary;
}
/*
-* call-seq:
-* ssl.ssl_version => String
-*
-* Returns a String representing the SSL/TLS version that was negotiated
-* for the connection, for example "TLSv1.2".
-*/
+ * call-seq:
+ * ssl.ssl_version => String
+ *
+ * Returns a String representing the SSL/TLS version that was negotiated
+ * for the connection, for example "TLSv1.2".
+ */
static VALUE
ossl_ssl_get_version(VALUE self)
{
@@ -2345,10 +2453,10 @@ ossl_ssl_set_hostname(VALUE self, VALUE arg)
GetSSL(self, ssl);
if (!NIL_P(arg))
- hostname = StringValueCStr(arg);
+ hostname = StringValueCStr(arg);
if (!SSL_set_tlsext_host_name(ssl, hostname))
- ossl_raise(eSSLError, NULL);
+ ossl_raise(eSSLError, NULL);
/* for SSLSocket#hostname */
rb_ivar_set(self, id_i_hostname, arg);
@@ -2377,16 +2485,15 @@ ossl_ssl_get_verify_result(VALUE self)
/*
* call-seq:
- * ssl.finished_message => "finished message"
- *
- * Returns the last *Finished* message sent
+ * ssl.finished_message -> string or nil
*
+ * Returns the contents of the last +Finished+ message sent to the peer.
*/
static VALUE
ossl_ssl_get_finished(VALUE self)
{
SSL *ssl;
- char sizer[1], *buf;
+ char sizer[1];
size_t len;
GetSSL(self, ssl);
@@ -2395,23 +2502,23 @@ ossl_ssl_get_finished(VALUE self)
if (len == 0)
return Qnil;
- buf = ALLOCA_N(char, len);
- SSL_get_finished(ssl, buf, len);
- return rb_str_new(buf, len);
+ VALUE str = rb_str_new(NULL, len);
+ SSL_get_finished(ssl, RSTRING_PTR(str), len);
+ return str;
}
/*
* call-seq:
- * ssl.peer_finished_message => "peer finished message"
- *
- * Returns the last *Finished* message received
+ * ssl.peer_finished_message -> string or nil
*
+ * Returns the contents of the last +Finished+ message expected to be sent
+ * by the peer.
*/
static VALUE
ossl_ssl_get_peer_finished(VALUE self)
{
SSL *ssl;
- char sizer[1], *buf;
+ char sizer[1];
size_t len;
GetSSL(self, ssl);
@@ -2420,14 +2527,14 @@ ossl_ssl_get_peer_finished(VALUE self)
if (len == 0)
return Qnil;
- buf = ALLOCA_N(char, len);
- SSL_get_peer_finished(ssl, buf, len);
- return rb_str_new(buf, len);
+ VALUE str = rb_str_new(NULL, len);
+ SSL_get_peer_finished(ssl, RSTRING_PTR(str), len);
+ return str;
}
/*
* call-seq:
- * ssl.client_ca => [x509name, ...]
+ * ssl.client_ca => [x509name, ...] or nil
*
* Returns the list of client CAs. Please note that in contrast to
* SSLContext#client_ca= no array of X509::Certificate is returned but
@@ -2445,6 +2552,8 @@ ossl_ssl_get_client_ca_list(VALUE self)
GetSSL(self, ssl);
ca = SSL_get_client_CA_list(ssl);
+ if (!ca)
+ return Qnil;
return ossl_x509name_sk2ary(ca);
}
@@ -2467,9 +2576,9 @@ ossl_ssl_npn_protocol(VALUE self)
SSL_get0_next_proto_negotiated(ssl, &out, &outlen);
if (!outlen)
- return Qnil;
+ return Qnil;
else
- return rb_str_new((const char *) out, outlen);
+ return rb_str_new((const char *) out, outlen);
}
# endif
@@ -2491,9 +2600,9 @@ ossl_ssl_alpn_protocol(VALUE self)
SSL_get0_alpn_selected(ssl, &out, &outlen);
if (!outlen)
- return Qnil;
+ return Qnil;
else
- return rb_str_new((const char *) out, outlen);
+ return rb_str_new((const char *) out, outlen);
}
/*
@@ -2526,15 +2635,15 @@ ossl_ssl_export_keying_material(int argc, VALUE *argv, VALUE self)
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (!NIL_P(context)) {
- use_ctx = 1;
- StringValue(context);
- ctx = (unsigned char *)RSTRING_PTR(context);
- ctx_len = RSTRING_LEN(context);
+ use_ctx = 1;
+ StringValue(context);
+ ctx = (unsigned char *)RSTRING_PTR(context);
+ ctx_len = RSTRING_LEN(context);
}
ret = SSL_export_keying_material(ssl, p, len, (char *)RSTRING_PTR(label),
- RSTRING_LENINT(label), ctx, ctx_len, use_ctx);
+ RSTRING_LENINT(label), ctx, ctx_len, use_ctx);
if (ret == 0 || ret == -1) {
- ossl_raise(eSSLError, "SSL_export_keying_material");
+ ossl_raise(eSSLError, "SSL_export_keying_material");
}
return str;
}
@@ -2553,17 +2662,77 @@ ossl_ssl_tmp_key(VALUE self)
GetSSL(self, ssl);
if (!SSL_get_server_tmp_key(ssl, &key))
- return Qnil;
- return ossl_pkey_new(key);
+ return Qnil;
+ return ossl_pkey_wrap(key);
+}
+
+#ifdef HAVE_SSL_GET0_PEER_SIGNATURE_NAME
+/*
+ * call-seq:
+ * ssl.sigalg => String or nil
+ *
+ * Returns the signature algorithm name, the IANA name of the signature scheme
+ * used by the local to sign the TLS handshake.
+ */
+static VALUE
+ossl_ssl_get_sigalg(VALUE self)
+{
+ SSL *ssl;
+ const char *name;
+
+ GetSSL(self, ssl);
+ if (!SSL_get0_signature_name(ssl, &name))
+ return Qnil;
+ return rb_str_new_cstr(name);
}
+
+/*
+ * call-seq:
+ * ssl.peer_sigalg => String or nil
+ *
+ * Returns the signature algorithm name, the IANA name of the signature scheme
+ * used by the peer to sign the TLS handshake.
+ */
+static VALUE
+ossl_ssl_get_peer_sigalg(VALUE self)
+{
+ SSL *ssl;
+ const char *name;
+
+ GetSSL(self, ssl);
+ if (!SSL_get0_peer_signature_name(ssl, &name))
+ return Qnil;
+ return rb_str_new_cstr(name);
+}
+#endif
+
+#ifdef HAVE_SSL_GET0_GROUP_NAME
+/*
+ * call-seq:
+ * ssl.group => String or nil
+ *
+ * Returns the name of the group that was used for the key agreement of the
+ * current TLS session establishment.
+ */
+static VALUE
+ossl_ssl_get_group(VALUE self)
+{
+ SSL *ssl;
+ const char *name;
+
+ GetSSL(self, ssl);
+ if (!(name = SSL_get0_group_name(ssl)))
+ return Qnil;
+ return rb_str_new_cstr(name);
+}
+#endif
+
#endif /* !defined(OPENSSL_NO_SOCK) */
void
Init_ossl_ssl(void)
{
#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
rb_mWaitReadable = rb_define_module_under(rb_cIO, "WaitReadable");
rb_mWaitWritable = rb_define_module_under(rb_cIO, "WaitWritable");
#endif
@@ -2572,15 +2741,12 @@ Init_ossl_ssl(void)
id_call = rb_intern_const("call");
ID_callback_state = rb_intern_const("callback_state");
- ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0, (void *)"ossl_ssl_ex_vcb_idx", 0, 0, 0);
- if (ossl_ssl_ex_vcb_idx < 0)
- ossl_raise(rb_eRuntimeError, "SSL_get_ex_new_index");
ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0, (void *)"ossl_ssl_ex_ptr_idx", 0, 0, 0);
if (ossl_ssl_ex_ptr_idx < 0)
- ossl_raise(rb_eRuntimeError, "SSL_get_ex_new_index");
+ ossl_raise(rb_eRuntimeError, "SSL_get_ex_new_index");
ossl_sslctx_ex_ptr_idx = SSL_CTX_get_ex_new_index(0, (void *)"ossl_sslctx_ex_ptr_idx", 0, 0, 0);
if (ossl_sslctx_ex_ptr_idx < 0)
- ossl_raise(rb_eRuntimeError, "SSL_CTX_get_ex_new_index");
+ ossl_raise(rb_eRuntimeError, "SSL_CTX_get_ex_new_index");
/* Document-module: OpenSSL::SSL
*
@@ -2718,6 +2884,23 @@ Init_ossl_ssl(void)
*/
rb_attr(cSSLContext, rb_intern_const("client_cert_cb"), 1, 1, Qfalse);
+#ifndef OPENSSL_NO_DH
+ /*
+ * A callback invoked when DH parameters are required for ephemeral DH key
+ * exchange.
+ *
+ * The callback is invoked with the SSLSocket, a
+ * flag indicating the use of an export cipher and the keylength
+ * required.
+ *
+ * The callback must return an OpenSSL::PKey::DH instance of the correct
+ * key length.
+ *
+ * <b>Deprecated in version 3.0.</b> Use #tmp_dh= instead.
+ */
+ rb_attr(cSSLContext, rb_intern_const("tmp_dh_callback"), 1, 1, Qfalse);
+#endif
+
/*
* Sets the context in which a session can be reused. This allows
* sessions for multiple applications to be distinguished, for example, by
@@ -2860,17 +3043,22 @@ Init_ossl_ssl(void)
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");
- rb_define_private_method(cSSLContext, "set_minmax_proto_version",
- ossl_sslctx_set_minmax_proto_version, 2);
+ rb_define_method(cSSLContext, "min_version=", ossl_sslctx_set_min_version, 1);
+ rb_define_method(cSSLContext, "max_version=", ossl_sslctx_set_max_version, 1);
rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
-#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
rb_define_method(cSSLContext, "ciphersuites=", ossl_sslctx_set_ciphersuites, 1);
+#ifdef HAVE_SSL_CTX_SET1_SIGALGS_LIST // Not in LibreSSL yet
+ rb_define_method(cSSLContext, "sigalgs=", ossl_sslctx_set_sigalgs, 1);
+#endif
+#ifdef HAVE_SSL_CTX_SET1_CLIENT_SIGALGS_LIST // Not in LibreSSL or AWS-LC yet
+ rb_define_method(cSSLContext, "client_sigalgs=", ossl_sslctx_set_client_sigalgs, 1);
#endif
#ifndef OPENSSL_NO_DH
rb_define_method(cSSLContext, "tmp_dh=", ossl_sslctx_set_tmp_dh, 1);
#endif
- rb_define_method(cSSLContext, "ecdh_curves=", ossl_sslctx_set_ecdh_curves, 1);
+ rb_define_method(cSSLContext, "groups=", ossl_sslctx_set_groups, 1);
+ rb_define_alias(cSSLContext, "ecdh_curves=", "groups=");
rb_define_method(cSSLContext, "security_level", ossl_sslctx_get_security_level, 0);
rb_define_method(cSSLContext, "security_level=", ossl_sslctx_set_security_level, 1);
#ifdef SSL_MODE_SEND_FALLBACK_SCSV
@@ -2977,6 +3165,13 @@ Init_ossl_ssl(void)
# ifdef OSSL_USE_NEXTPROTONEG
rb_define_method(cSSLSocket, "npn_protocol", ossl_ssl_npn_protocol, 0);
# endif
+#ifdef HAVE_SSL_GET0_PEER_SIGNATURE_NAME
+ rb_define_method(cSSLSocket, "sigalg", ossl_ssl_get_sigalg, 0);
+ rb_define_method(cSSLSocket, "peer_sigalg", ossl_ssl_get_peer_sigalg, 0);
+#endif
+#ifdef HAVE_SSL_GET0_GROUP_NAME
+ rb_define_method(cSSLSocket, "group", ossl_ssl_get_group, 0);
+#endif
rb_define_const(mSSL, "VERIFY_NONE", INT2NUM(SSL_VERIFY_NONE));
rb_define_const(mSSL, "VERIFY_PEER", INT2NUM(SSL_VERIFY_PEER));
@@ -3002,7 +3197,7 @@ Init_ossl_ssl(void)
#ifdef SSL_OP_DISABLE_TLSEXT_CA_NAMES /* OpenSSL 3.0 */
rb_define_const(mSSL, "OP_DISABLE_TLSEXT_CA_NAMES", ULONG2NUM(SSL_OP_DISABLE_TLSEXT_CA_NAMES));
#endif
-#ifdef SSL_OP_ALLOW_NO_DHE_KEX /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_ALLOW_NO_DHE_KEX /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_ALLOW_NO_DHE_KEX", ULONG2NUM(SSL_OP_ALLOW_NO_DHE_KEX));
#endif
rb_define_const(mSSL, "OP_DONT_INSERT_EMPTY_FRAGMENTS", ULONG2NUM(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
@@ -3010,28 +3205,26 @@ Init_ossl_ssl(void)
rb_define_const(mSSL, "OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION", ULONG2NUM(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION));
rb_define_const(mSSL, "OP_NO_COMPRESSION", ULONG2NUM(SSL_OP_NO_COMPRESSION));
rb_define_const(mSSL, "OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION", ULONG2NUM(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION));
-#ifdef SSL_OP_NO_ENCRYPT_THEN_MAC /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_NO_ENCRYPT_THEN_MAC /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_NO_ENCRYPT_THEN_MAC", ULONG2NUM(SSL_OP_NO_ENCRYPT_THEN_MAC));
#endif
-#ifdef SSL_OP_ENABLE_MIDDLEBOX_COMPAT /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_ENABLE_MIDDLEBOX_COMPAT /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_ENABLE_MIDDLEBOX_COMPAT", ULONG2NUM(SSL_OP_ENABLE_MIDDLEBOX_COMPAT));
#endif
-#ifdef SSL_OP_PRIORITIZE_CHACHA /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_PRIORITIZE_CHACHA /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_PRIORITIZE_CHACHA", ULONG2NUM(SSL_OP_PRIORITIZE_CHACHA));
#endif
-#ifdef SSL_OP_NO_ANTI_REPLAY /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_NO_ANTI_REPLAY /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_NO_ANTI_REPLAY", ULONG2NUM(SSL_OP_NO_ANTI_REPLAY));
#endif
rb_define_const(mSSL, "OP_NO_SSLv3", ULONG2NUM(SSL_OP_NO_SSLv3));
rb_define_const(mSSL, "OP_NO_TLSv1", ULONG2NUM(SSL_OP_NO_TLSv1));
rb_define_const(mSSL, "OP_NO_TLSv1_1", ULONG2NUM(SSL_OP_NO_TLSv1_1));
rb_define_const(mSSL, "OP_NO_TLSv1_2", ULONG2NUM(SSL_OP_NO_TLSv1_2));
-#ifdef SSL_OP_NO_TLSv1_3 /* OpenSSL 1.1.1 */
rb_define_const(mSSL, "OP_NO_TLSv1_3", ULONG2NUM(SSL_OP_NO_TLSv1_3));
-#endif
rb_define_const(mSSL, "OP_CIPHER_SERVER_PREFERENCE", ULONG2NUM(SSL_OP_CIPHER_SERVER_PREFERENCE));
rb_define_const(mSSL, "OP_TLS_ROLLBACK_BUG", ULONG2NUM(SSL_OP_TLS_ROLLBACK_BUG));
-#ifdef SSL_OP_NO_RENEGOTIATION /* OpenSSL 1.1.1 */
+#ifdef SSL_OP_NO_RENEGOTIATION /* OpenSSL 1.1.1, missing in LibreSSL */
rb_define_const(mSSL, "OP_NO_RENEGOTIATION", ULONG2NUM(SSL_OP_NO_RENEGOTIATION));
#endif
rb_define_const(mSSL, "OP_CRYPTOPRO_TLSEXT_BUG", ULONG2NUM(SSL_OP_CRYPTOPRO_TLSEXT_BUG));
@@ -3093,17 +3286,14 @@ Init_ossl_ssl(void)
rb_define_const(mSSL, "TLS1_1_VERSION", INT2NUM(TLS1_1_VERSION));
/* TLS 1.2 */
rb_define_const(mSSL, "TLS1_2_VERSION", INT2NUM(TLS1_2_VERSION));
-#ifdef TLS1_3_VERSION /* OpenSSL 1.1.1 */
/* TLS 1.3 */
rb_define_const(mSSL, "TLS1_3_VERSION", INT2NUM(TLS1_3_VERSION));
-#endif
sym_exception = ID2SYM(rb_intern_const("exception"));
sym_wait_readable = ID2SYM(rb_intern_const("wait_readable"));
sym_wait_writable = ID2SYM(rb_intern_const("wait_writable"));
- id_tmp_dh_callback = rb_intern_const("tmp_dh_callback");
id_npn_protocols_encoded = rb_intern_const("npn_protocols_encoded");
id_each = rb_intern_const("each");
@@ -3134,9 +3324,11 @@ Init_ossl_ssl(void)
DefIVarID(servername_cb);
DefIVarID(verify_hostname);
DefIVarID(keylog_cb);
+ DefIVarID(tmp_dh_callback);
DefIVarID(io);
DefIVarID(context);
DefIVarID(hostname);
+ DefIVarID(sync_close);
#endif /* !defined(OPENSSL_NO_SOCK) */
}
diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h
index 535c56097c..a87e62d450 100644
--- a/ext/openssl/ossl_ssl.h
+++ b/ext/openssl/ossl_ssl.h
@@ -5,23 +5,23 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_SSL_H_)
#define _OSSL_SSL_H_
#define GetSSL(obj, ssl) do { \
- TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
- if (!(ssl)) { \
- ossl_raise(rb_eRuntimeError, "SSL is not initialized"); \
- } \
+ TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
+ if (!(ssl)) { \
+ ossl_raise(rb_eRuntimeError, "SSL is not initialized"); \
+ } \
} while (0)
#define GetSSLSession(obj, sess) do { \
- TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
- if (!(sess)) { \
- ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
- } \
+ TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
+ if (!(sess)) { \
+ ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
+ } \
} while (0)
extern const rb_data_type_t ossl_ssl_type;
diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c
index 139a474b04..8a2fbf4100 100644
--- a/ext/openssl/ossl_ssl_session.c
+++ b/ext/openssl/ossl_ssl_session.c
@@ -17,14 +17,14 @@ ossl_ssl_session_free(void *ptr)
const rb_data_type_t ossl_ssl_session_type = {
"OpenSSL/SSL/Session",
{
- 0, ossl_ssl_session_free,
+ 0, ossl_ssl_session_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE ossl_ssl_session_alloc(VALUE klass)
{
- return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
+ return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
}
/*
@@ -69,6 +69,7 @@ ossl_ssl_session_initialize(VALUE self, VALUE arg1)
return self;
}
+/* :nodoc: */
static VALUE
ossl_ssl_session_initialize_copy(VALUE self, VALUE other)
{
@@ -79,9 +80,9 @@ ossl_ssl_session_initialize_copy(VALUE self, VALUE other)
GetSSLSession(other, sess_other);
sess_new = ASN1_dup((i2d_of_void *)i2d_SSL_SESSION, (d2i_of_void *)d2i_SSL_SESSION,
- (char *)sess_other);
+ (char *)sess_other);
if (!sess_new)
- ossl_raise(eSSLSession, "ASN1_dup");
+ ossl_raise(eSSLSession, "ASN1_dup");
RTYPEDDATA_DATA(self) = sess_new;
SSL_SESSION_free(sess);
@@ -98,9 +99,9 @@ ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
const unsigned char *b_sid = SSL_SESSION_get_id(b, &b_len);
if (SSL_SESSION_get_protocol_version(a) != SSL_SESSION_get_protocol_version(b))
- return 1;
+ return 1;
if (a_len != b_len)
- return 1;
+ return 1;
return CRYPTO_memcmp(a_sid, b_sid, a_len);
}
@@ -113,15 +114,15 @@ ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
*/
static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2)
{
- SSL_SESSION *ctx1, *ctx2;
+ SSL_SESSION *ctx1, *ctx2;
- GetSSLSession(val1, ctx1);
- GetSSLSession(val2, ctx2);
+ GetSSLSession(val1, ctx1);
+ GetSSLSession(val2, ctx2);
- switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) {
- case 0: return Qtrue;
- default: return Qfalse;
- }
+ switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) {
+ case 0: return Qtrue;
+ default: return Qfalse;
+ }
}
/*
@@ -139,7 +140,7 @@ ossl_ssl_session_get_time(VALUE self)
GetSSLSession(self, ctx);
t = SSL_SESSION_get_time(ctx);
if (t == 0)
- return Qnil;
+ return Qnil;
return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM(t));
}
@@ -174,16 +175,16 @@ ossl_ssl_session_get_timeout(VALUE self)
*/
static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
{
- SSL_SESSION *ctx;
- long t;
-
- GetSSLSession(self, ctx);
- if (rb_obj_is_instance_of(time_v, rb_cTime)) {
- time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
- }
- t = NUM2LONG(time_v);
- SSL_SESSION_set_time(ctx, t);
- return ossl_ssl_session_get_time(self);
+ SSL_SESSION *ctx;
+ long t;
+
+ GetSSLSession(self, ctx);
+ if (rb_obj_is_instance_of(time_v, rb_cTime)) {
+ time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
+ }
+ t = NUM2LONG(time_v);
+ SSL_SESSION_set_time(ctx, t);
+ return ossl_ssl_session_get_time(self);
}
/*
@@ -194,13 +195,13 @@ static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
*/
static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
{
- SSL_SESSION *ctx;
- long t;
+ SSL_SESSION *ctx;
+ long t;
- GetSSLSession(self, ctx);
- t = NUM2LONG(time_v);
- SSL_SESSION_set_timeout(ctx, t);
- return ossl_ssl_session_get_timeout(self);
+ GetSSLSession(self, ctx);
+ t = NUM2LONG(time_v);
+ SSL_SESSION_set_timeout(ctx, t);
+ return ossl_ssl_session_get_timeout(self);
}
/*
@@ -208,18 +209,18 @@ static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
* session.id -> String
*
* Returns the Session ID.
-*/
+ */
static VALUE ossl_ssl_session_get_id(VALUE self)
{
- SSL_SESSION *ctx;
- const unsigned char *p = NULL;
- unsigned int i = 0;
+ SSL_SESSION *ctx;
+ const unsigned char *p = NULL;
+ unsigned int i = 0;
- GetSSLSession(self, ctx);
+ GetSSLSession(self, ctx);
- p = SSL_SESSION_get_id(ctx, &i);
+ p = SSL_SESSION_get_id(ctx, &i);
- return rb_str_new((const char *) p, i);
+ return rb_str_new((const char *) p, i);
}
/*
@@ -230,22 +231,22 @@ static VALUE ossl_ssl_session_get_id(VALUE self)
*/
static VALUE ossl_ssl_session_to_der(VALUE self)
{
- SSL_SESSION *ctx;
- unsigned char *p;
- int len;
- VALUE str;
-
- GetSSLSession(self, ctx);
- len = i2d_SSL_SESSION(ctx, NULL);
- if (len <= 0) {
- ossl_raise(eSSLSession, "i2d_SSL_SESSION");
- }
-
- str = rb_str_new(0, len);
- p = (unsigned char *)RSTRING_PTR(str);
- i2d_SSL_SESSION(ctx, &p);
- ossl_str_adjust(str, p);
- return str;
+ SSL_SESSION *ctx;
+ unsigned char *p;
+ int len;
+ VALUE str;
+
+ GetSSLSession(self, ctx);
+ len = i2d_SSL_SESSION(ctx, NULL);
+ if (len <= 0) {
+ ossl_raise(eSSLSession, "i2d_SSL_SESSION");
+ }
+
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ i2d_SSL_SESSION(ctx, &p);
+ ossl_str_adjust(str, p);
+ return str;
}
/*
@@ -256,22 +257,22 @@ static VALUE ossl_ssl_session_to_der(VALUE self)
*/
static VALUE ossl_ssl_session_to_pem(VALUE self)
{
- SSL_SESSION *ctx;
- BIO *out;
+ SSL_SESSION *ctx;
+ BIO *out;
- GetSSLSession(self, ctx);
+ GetSSLSession(self, ctx);
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eSSLSession, "BIO_s_mem()");
- }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSSLSession, "BIO_s_mem()");
+ }
- if (!PEM_write_bio_SSL_SESSION(out, ctx)) {
- BIO_free(out);
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
- }
+ if (!PEM_write_bio_SSL_SESSION(out, ctx)) {
+ BIO_free(out);
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
+ }
- return ossl_membio2str(out);
+ return ossl_membio2str(out);
}
@@ -283,49 +284,44 @@ static VALUE ossl_ssl_session_to_pem(VALUE self)
*/
static VALUE ossl_ssl_session_to_text(VALUE self)
{
- SSL_SESSION *ctx;
- BIO *out;
+ SSL_SESSION *ctx;
+ BIO *out;
- GetSSLSession(self, ctx);
+ GetSSLSession(self, ctx);
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eSSLSession, "BIO_s_mem()");
- }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSSLSession, "BIO_s_mem()");
+ }
- if (!SSL_SESSION_print(out, ctx)) {
- BIO_free(out);
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
- }
+ if (!SSL_SESSION_print(out, ctx)) {
+ BIO_free(out);
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
+ }
- return ossl_membio2str(out);
+ return ossl_membio2str(out);
}
#endif /* !defined(OPENSSL_NO_SOCK) */
void Init_ossl_ssl_session(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- mSSL = rb_define_module_under(mOSSL, "SSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
-#endif
#ifndef OPENSSL_NO_SOCK
- cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
- eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
-
- rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
- rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
- rb_define_method(cSSLSession, "initialize_copy", ossl_ssl_session_initialize_copy, 1);
-
- rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
-
- rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
- rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
- rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
- rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
- rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
- rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
- rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
- rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
+ cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
+ eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
+
+ rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
+ rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
+ rb_define_method(cSSLSession, "initialize_copy", ossl_ssl_session_initialize_copy, 1);
+
+ rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
+
+ rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
+ rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
+ rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
+ rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
+ rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
+ rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
+ rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
+ rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
#endif /* !defined(OPENSSL_NO_SOCK) */
}
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index b33ff10c10..317f7786aa 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licenced under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -83,7 +83,7 @@ static const rb_data_type_t ossl_ts_req_type = {
{
0, ossl_ts_req_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -97,13 +97,13 @@ static const rb_data_type_t ossl_ts_resp_type = {
{
0, ossl_ts_resp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
ossl_ts_token_info_free(void *ptr)
{
- TS_TST_INFO_free(ptr);
+ TS_TST_INFO_free(ptr);
}
static const rb_data_type_t ossl_ts_token_info_type = {
@@ -111,7 +111,7 @@ static const rb_data_type_t ossl_ts_token_info_type = {
{
0, ossl_ts_token_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -132,41 +132,10 @@ asn1_to_der(void *template, int (*i2d)(void *template, unsigned char **pp))
return str;
}
-static ASN1_OBJECT*
-obj_to_asn1obj(VALUE obj)
-{
- ASN1_OBJECT *a1obj;
-
- StringValue(obj);
- a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 0);
- if(!a1obj) a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 1);
- if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID");
-
- return a1obj;
-}
-
static VALUE
obj_to_asn1obj_i(VALUE obj)
{
- return (VALUE)obj_to_asn1obj(obj);
-}
-
-static VALUE
-get_asn1obj(ASN1_OBJECT *obj)
-{
- BIO *out;
- VALUE ret;
- int nid;
- if ((nid = OBJ_obj2nid(obj)) != NID_undef)
- ret = rb_str_new2(OBJ_nid2sn(nid));
- else{
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509AttrError, NULL);
- i2a_ASN1_OBJECT(out, obj);
- ret = ossl_membio2str(out);
- }
-
- return ret;
+ return (VALUE)ossl_to_asn1obj(obj);
}
static VALUE
@@ -199,7 +168,7 @@ ossl_ts_req_alloc(VALUE klass)
static VALUE
ossl_ts_req_initialize(int argc, VALUE *argv, VALUE self)
{
- TS_REQ *ts_req = DATA_PTR(self);
+ TS_REQ *req, *req_orig = DATA_PTR(self);
BIO *in;
VALUE arg;
@@ -209,13 +178,14 @@ ossl_ts_req_initialize(int argc, VALUE *argv, VALUE self)
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
- ts_req = d2i_TS_REQ_bio(in, &ts_req);
+ req = d2i_TS_REQ_bio(in, NULL);
BIO_free(in);
- if (!ts_req) {
- DATA_PTR(self) = NULL;
- ossl_raise(eTimestampError, "Error when decoding the timestamp request");
+ if (!req) {
+ ossl_raise(eTimestampError,
+ "Error when decoding the timestamp request");
}
- DATA_PTR(self) = ts_req;
+ TS_REQ_free(req_orig);
+ RTYPEDDATA_DATA(self) = req;
return self;
}
@@ -233,11 +203,13 @@ ossl_ts_req_get_algorithm(VALUE self)
TS_REQ *req;
TS_MSG_IMPRINT *mi;
X509_ALGOR *algor;
+ const ASN1_OBJECT *obj;
GetTSRequest(self, req);
mi = TS_REQ_get_msg_imprint(req);
algor = TS_MSG_IMPRINT_get_algo(mi);
- return get_asn1obj(algor->algorithm);
+ X509_ALGOR_get0(&obj, NULL, NULL, algor);
+ return ossl_asn1obj_to_string(obj);
}
/*
@@ -259,7 +231,7 @@ ossl_ts_req_set_algorithm(VALUE self, VALUE algo)
X509_ALGOR *algor;
GetTSRequest(self, req);
- obj = obj_to_asn1obj(algo);
+ obj = ossl_to_asn1obj(algo);
mi = TS_REQ_get_msg_imprint(req);
algor = TS_MSG_IMPRINT_get_algo(mi);
if (!X509_ALGOR_set0(algor, obj, V_ASN1_NULL, NULL)) {
@@ -288,7 +260,7 @@ ossl_ts_req_get_msg_imprint(VALUE self)
mi = TS_REQ_get_msg_imprint(req);
hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
- ret = rb_str_new((const char *)hashed_msg->data, hashed_msg->length);
+ ret = asn1str_to_str(hashed_msg);
return ret;
}
@@ -366,7 +338,7 @@ ossl_ts_req_get_policy_id(VALUE self)
GetTSRequest(self, req);
if (!TS_REQ_get_policy_id(req))
return Qnil;
- return get_asn1obj(TS_REQ_get_policy_id(req));
+ return ossl_asn1obj_to_string(TS_REQ_get_policy_id(req));
}
/*
@@ -389,7 +361,7 @@ ossl_ts_req_set_policy_id(VALUE self, VALUE oid)
int ok;
GetTSRequest(self, req);
- obj = obj_to_asn1obj(oid);
+ obj = ossl_to_asn1obj(oid);
ok = TS_REQ_set_policy_id(req, obj);
ASN1_OBJECT_free(obj);
if (!ok)
@@ -487,23 +459,44 @@ ossl_ts_req_to_der(VALUE self)
TS_REQ *req;
TS_MSG_IMPRINT *mi;
X509_ALGOR *algo;
+ const ASN1_OBJECT *obj;
ASN1_OCTET_STRING *hashed_msg;
GetTSRequest(self, req);
mi = TS_REQ_get_msg_imprint(req);
algo = TS_MSG_IMPRINT_get_algo(mi);
- if (OBJ_obj2nid(algo->algorithm) == NID_undef)
+ X509_ALGOR_get0(&obj, NULL, NULL, algo);
+ if (OBJ_obj2nid(obj) == NID_undef)
ossl_raise(eTimestampError, "Message imprint missing algorithm");
hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
- if (!hashed_msg->length)
+ if (!ASN1_STRING_length(hashed_msg))
ossl_raise(eTimestampError, "Message imprint missing hashed message");
return asn1_to_der((void *)req, (int (*)(void *, unsigned char **))i2d_TS_REQ);
}
static VALUE
+ossl_ts_req_to_text(VALUE self)
+{
+ TS_REQ *req;
+ BIO *out;
+
+ GetTSRequest(self, req);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eTimestampError, NULL);
+
+ if (!TS_REQ_print_bio(out, req)) {
+ BIO_free(out);
+ ossl_raise(eTimestampError, NULL);
+ }
+
+ return ossl_membio2str(out);
+}
+
+static VALUE
ossl_ts_resp_alloc(VALUE klass)
{
TS_RESP *resp;
@@ -530,18 +523,19 @@ ossl_ts_resp_alloc(VALUE klass)
static VALUE
ossl_ts_resp_initialize(VALUE self, VALUE der)
{
- TS_RESP *ts_resp = DATA_PTR(self);
+ TS_RESP *resp, *resp_orig = DATA_PTR(self);
BIO *in;
der = ossl_to_der_if_possible(der);
- in = ossl_obj2bio(&der);
- ts_resp = d2i_TS_RESP_bio(in, &ts_resp);
+ in = ossl_obj2bio(&der);
+ resp = d2i_TS_RESP_bio(in, NULL);
BIO_free(in);
- if (!ts_resp) {
- DATA_PTR(self) = NULL;
- ossl_raise(eTimestampError, "Error when decoding the timestamp response");
+ if (!resp) {
+ ossl_raise(eTimestampError,
+ "Error when decoding the timestamp response");
}
- DATA_PTR(self) = ts_resp;
+ TS_RESP_free(resp_orig);
+ RTYPEDDATA_DATA(self) = resp;
return self;
}
@@ -598,14 +592,7 @@ ossl_ts_resp_get_failure_info(VALUE self)
{
TS_RESP *resp;
TS_STATUS_INFO *si;
-
- /* The ASN1_BIT_STRING_get_bit changed from 1.0.0. to 1.1.0, making this
- * const. */
- #if defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO)
const ASN1_BIT_STRING *fi;
- #else
- ASN1_BIT_STRING *fi;
- #endif
GetTSResponse(self, resp);
si = TS_RESP_get_status_info(resp);
@@ -672,21 +659,12 @@ static VALUE
ossl_ts_resp_get_token(VALUE self)
{
TS_RESP *resp;
- PKCS7 *p7, *copy;
- VALUE obj;
+ PKCS7 *p7;
GetTSResponse(self, resp);
if (!(p7 = TS_RESP_get_token(resp)))
return Qnil;
-
- obj = NewPKCS7(cPKCS7);
-
- if (!(copy = PKCS7_dup(p7)))
- ossl_raise(eTimestampError, NULL);
-
- SetPKCS7(obj, copy);
-
- return obj;
+ return ossl_pkcs7_new(p7);
}
/*
@@ -730,7 +708,7 @@ ossl_ts_resp_get_tsa_certificate(VALUE self)
TS_RESP *resp;
PKCS7 *p7;
PKCS7_SIGNER_INFO *ts_info;
- X509 *cert;
+ const X509 *cert;
GetTSResponse(self, resp);
if (!(p7 = TS_RESP_get_token(resp)))
@@ -757,6 +735,25 @@ ossl_ts_resp_to_der(VALUE self)
return asn1_to_der((void *)resp, (int (*)(void *, unsigned char **))i2d_TS_RESP);
}
+static VALUE
+ossl_ts_resp_to_text(VALUE self)
+{
+ TS_RESP *resp;
+ BIO *out;
+
+ GetTSResponse(self, resp);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eTimestampError, NULL);
+
+ if (!TS_RESP_print_bio(out, resp)) {
+ BIO_free(out);
+ ossl_raise(eTimestampError, NULL);
+ }
+
+ return ossl_membio2str(out);
+}
+
/*
* Verifies a timestamp token by checking the signature, validating the
* certificate chain implied by tsa_certificate and by checking conformance to
@@ -826,16 +823,26 @@ ossl_ts_resp_verify(int argc, VALUE *argv, VALUE self)
X509_up_ref(cert);
}
+ if (!X509_STORE_up_ref(x509st)) {
+ sk_X509_pop_free(x509inter, X509_free);
+ TS_VERIFY_CTX_free(ctx);
+ ossl_raise(eTimestampError, "X509_STORE_up_ref");
+ }
+
+#ifdef HAVE_TS_VERIFY_CTX_SET0_CERTS
+ TS_VERIFY_CTX_set0_certs(ctx, x509inter);
+ TS_VERIFY_CTX_set0_store(ctx, x509st);
+#else
+# if OSSL_OPENSSL_PREREQ(3, 0, 0) || OSSL_IS_LIBRESSL
TS_VERIFY_CTX_set_certs(ctx, x509inter);
- TS_VERIFY_CTX_add_flags(ctx, TS_VFY_SIGNATURE);
+# else
+ TS_VERIFY_CTS_set_certs(ctx, x509inter);
+# endif
TS_VERIFY_CTX_set_store(ctx, x509st);
+#endif
+ TS_VERIFY_CTX_add_flags(ctx, TS_VFY_SIGNATURE);
ok = TS_RESP_verify_response(ctx, resp);
- /*
- * TS_VERIFY_CTX_set_store() call above does not increment the reference
- * counter, so it must be unset before TS_VERIFY_CTX_free() is called.
- */
- TS_VERIFY_CTX_set_store(ctx, NULL);
TS_VERIFY_CTX_free(ctx);
if (!ok)
@@ -871,18 +878,19 @@ ossl_ts_token_info_alloc(VALUE klass)
static VALUE
ossl_ts_token_info_initialize(VALUE self, VALUE der)
{
- TS_TST_INFO *info = DATA_PTR(self);
+ TS_TST_INFO *info, *info_orig = DATA_PTR(self);
BIO *in;
der = ossl_to_der_if_possible(der);
- in = ossl_obj2bio(&der);
- info = d2i_TS_TST_INFO_bio(in, &info);
+ in = ossl_obj2bio(&der);
+ info = d2i_TS_TST_INFO_bio(in, NULL);
BIO_free(in);
if (!info) {
- DATA_PTR(self) = NULL;
- ossl_raise(eTimestampError, "Error when decoding the timestamp token info");
+ ossl_raise(eTimestampError,
+ "Error when decoding the timestamp token info");
}
- DATA_PTR(self) = info;
+ TS_TST_INFO_free(info_orig);
+ RTYPEDDATA_DATA(self) = info;
return self;
}
@@ -922,7 +930,7 @@ ossl_ts_token_info_get_policy_id(VALUE self)
TS_TST_INFO *info;
GetTSTokenInfo(self, info);
- return get_asn1obj(TS_TST_INFO_get_policy_id(info));
+ return ossl_asn1obj_to_string(TS_TST_INFO_get_policy_id(info));
}
/*
@@ -944,11 +952,13 @@ ossl_ts_token_info_get_algorithm(VALUE self)
TS_TST_INFO *info;
TS_MSG_IMPRINT *mi;
X509_ALGOR *algo;
+ const ASN1_OBJECT *obj;
GetTSTokenInfo(self, info);
mi = TS_TST_INFO_get_msg_imprint(info);
algo = TS_MSG_IMPRINT_get_algo(mi);
- return get_asn1obj(algo->algorithm);
+ X509_ALGOR_get0(&obj, NULL, NULL, algo);
+ return ossl_asn1obj_to_string(obj);
}
/*
@@ -974,7 +984,7 @@ ossl_ts_token_info_get_msg_imprint(VALUE self)
GetTSTokenInfo(self, info);
mi = TS_TST_INFO_get_msg_imprint(info);
hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
- ret = rb_str_new((const char *)hashed_msg->data, hashed_msg->length);
+ ret = asn1str_to_str(hashed_msg);
return ret;
}
@@ -1073,6 +1083,25 @@ ossl_ts_token_info_to_der(VALUE self)
return asn1_to_der((void *)info, (int (*)(void *, unsigned char **))i2d_TS_TST_INFO);
}
+static VALUE
+ossl_ts_token_info_to_text(VALUE self)
+{
+ TS_TST_INFO *info;
+ BIO *out;
+
+ GetTSTokenInfo(self, info);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eTimestampError, NULL);
+
+ if (!TS_TST_INFO_print_bio(out, info)) {
+ BIO_free(out);
+ ossl_raise(eTimestampError, NULL);
+ }
+
+ return ossl_membio2str(out);
+}
+
static ASN1_INTEGER *
ossl_tsfac_serial_cb(struct TS_resp_ctx *ctx, void *data)
{
@@ -1095,9 +1124,14 @@ ossl_tsfac_time_cb(struct TS_resp_ctx *ctx, void *data, time_t *sec, long *usec)
}
static VALUE
-ossl_evp_get_digestbyname_i(VALUE arg)
+ossl_evp_md_fetch_i(VALUE args_)
{
- return (VALUE)ossl_evp_get_digestbyname(arg);
+ VALUE *args = (VALUE *)args_, md_holder;
+ const EVP_MD *md;
+
+ md = ossl_evp_md_fetch(args[1], &md_holder);
+ rb_ary_push(args[0], md_holder);
+ return (VALUE)md;
}
static VALUE
@@ -1133,7 +1167,8 @@ ossl_obj2bio_i(VALUE arg)
static VALUE
ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
{
- VALUE serial_number, def_policy_id, gen_time, additional_certs, allowed_digests;
+ VALUE serial_number, def_policy_id, gen_time, additional_certs,
+ allowed_digests, allowed_digests_tmp = Qnil;
VALUE str;
STACK_OF(X509) *inter_certs;
VALUE tsresp, ret = Qnil;
@@ -1194,7 +1229,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
if (rb_obj_is_kind_of(additional_certs, rb_cArray)) {
inter_certs = ossl_protect_x509_ary2sk(additional_certs, &status);
if (status)
- goto end;
+ goto end;
/* this dups the sk_X509 and ups each cert's ref count */
TS_RESP_CTX_set_certs(ctx, inter_certs);
@@ -1210,16 +1245,18 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
allowed_digests = ossl_tsfac_get_allowed_digests(self);
if (rb_obj_is_kind_of(allowed_digests, rb_cArray)) {
- int i;
- VALUE rbmd;
- const EVP_MD *md;
-
- for (i = 0; i < RARRAY_LEN(allowed_digests); i++) {
- rbmd = rb_ary_entry(allowed_digests, i);
- md = (const EVP_MD *)rb_protect(ossl_evp_get_digestbyname_i, rbmd, &status);
+ allowed_digests_tmp = rb_ary_new_capa(RARRAY_LEN(allowed_digests));
+ for (long i = 0; i < RARRAY_LEN(allowed_digests); i++) {
+ VALUE args[] = {
+ allowed_digests_tmp,
+ rb_ary_entry(allowed_digests, i),
+ };
+ const EVP_MD *md = (const EVP_MD *)rb_protect(ossl_evp_md_fetch_i,
+ (VALUE)args, &status);
if (status)
goto end;
- TS_RESP_CTX_add_md(ctx, md);
+ if (!TS_RESP_CTX_add_md(ctx, md))
+ goto end;
}
}
@@ -1233,6 +1270,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
response = TS_RESP_create_response(ctx, req_bio);
BIO_free(req_bio);
+ RB_GC_GUARD(allowed_digests_tmp);
if (!response) {
err_msg = "Error during response generation";
@@ -1246,7 +1284,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
SetTSResponse(tsresp, response);
ret = tsresp;
-end:
+ end:
ASN1_INTEGER_free(asn1_serial);
ASN1_OBJECT_free(def_policy_id_obj);
TS_RESP_CTX_free(ctx);
@@ -1263,10 +1301,6 @@ end:
void
Init_ossl_ts(void)
{
- #if 0
- mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
- #endif
-
/*
* Possible return value for +Response#failure_info+. Indicates that the
* timestamp server rejects the message imprint algorithm used in the
@@ -1356,6 +1390,7 @@ Init_ossl_ts(void)
rb_define_method(cTimestampResponse, "token_info", ossl_ts_resp_get_token_info, 0);
rb_define_method(cTimestampResponse, "tsa_certificate", ossl_ts_resp_get_tsa_certificate, 0);
rb_define_method(cTimestampResponse, "to_der", ossl_ts_resp_to_der, 0);
+ rb_define_method(cTimestampResponse, "to_text", ossl_ts_resp_to_text, 0);
rb_define_method(cTimestampResponse, "verify", ossl_ts_resp_verify, -1);
/* Document-class: OpenSSL::Timestamp::TokenInfo
@@ -1374,6 +1409,7 @@ Init_ossl_ts(void)
rb_define_method(cTimestampTokenInfo, "ordering", ossl_ts_token_info_get_ordering, 0);
rb_define_method(cTimestampTokenInfo, "nonce", ossl_ts_token_info_get_nonce, 0);
rb_define_method(cTimestampTokenInfo, "to_der", ossl_ts_token_info_to_der, 0);
+ rb_define_method(cTimestampTokenInfo, "to_text", ossl_ts_token_info_to_text, 0);
/* Document-class: OpenSSL::Timestamp::Request
* Allows to create timestamp requests or parse existing ones. A Request is
@@ -1399,6 +1435,7 @@ Init_ossl_ts(void)
rb_define_method(cTimestampRequest, "cert_requested=", ossl_ts_req_set_cert_requested, 1);
rb_define_method(cTimestampRequest, "cert_requested?", ossl_ts_req_get_cert_requested, 0);
rb_define_method(cTimestampRequest, "to_der", ossl_ts_req_to_der, 0);
+ rb_define_method(cTimestampRequest, "to_text", ossl_ts_req_to_text, 0);
/*
* Indicates a successful response. Equal to +0+.
@@ -1473,67 +1510,45 @@ Init_ossl_ts(void)
* fac.default_policy_id = '1.2.3.4.5'
* fac.additional_certificates = [ inter1, inter2 ]
* timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
- *
- * ==Attributes
- *
- * ===default_policy_id
+ */
+ cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
+ /*
+ * The list of digest algorithms that the factory is allowed
+ * create timestamps for. Known vulnerable or weak algorithms should not be
+ * allowed where possible. Must be an Array of String or OpenSSL::Digest
+ * subclass instances.
+ */
+ rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
+ /*
+ * A String representing the default policy object identifier, or +nil+.
*
* Request#policy_id will always be preferred over this if present in the
- * Request, only if Request#policy_id is nil default_policy will be used.
+ * Request, only if Request#policy_id is +nil+ default_policy will be used.
* If none of both is present, a TimestampError will be raised when trying
* to create a Response.
- *
- * call-seq:
- * factory.default_policy_id = "string" -> string
- * factory.default_policy_id -> string or nil
- *
- * ===serial_number
- *
- * Sets or retrieves the serial number to be used for timestamp creation.
- * Must be present for timestamp creation.
- *
- * call-seq:
- * factory.serial_number = number -> number
- * factory.serial_number -> number or nil
- *
- * ===gen_time
- *
- * Sets or retrieves the Time value to be used in the Response. Must be
- * present for timestamp creation.
- *
- * call-seq:
- * factory.gen_time = Time -> Time
- * factory.gen_time -> Time or nil
- *
- * ===additional_certs
- *
- * Sets or retrieves additional certificates apart from the timestamp
- * certificate (e.g. intermediate certificates) to be added to the Response.
- * Must be an Array of OpenSSL::X509::Certificate.
- *
- * call-seq:
- * factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ]
- * factory.additional_certs -> array or nil
- *
- * ===allowed_digests
- *
- * Sets or retrieves the digest algorithms that the factory is allowed
- * create timestamps for. Known vulnerable or weak algorithms should not be
- * allowed where possible.
- * Must be an Array of String or OpenSSL::Digest subclass instances.
- *
- * call-seq:
- * factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ]
- * factory.allowed_digests -> array or nil
- *
*/
- cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
- rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
rb_attr(cTimestampFactory, rb_intern_const("default_policy_id"), 1, 1, 0);
+ /*
+ * The serial number to be used for timestamp creation. Must be present for
+ * timestamp creation. Must be an instance of OpenSSL::BN or Integer.
+ */
rb_attr(cTimestampFactory, rb_intern_const("serial_number"), 1, 1, 0);
+ /*
+ * The Time value to be used in the Response. Must be present for timestamp
+ * creation.
+ */
rb_attr(cTimestampFactory, rb_intern_const("gen_time"), 1, 1, 0);
+ /*
+ * Additional certificates apart from the timestamp certificate (e.g.
+ * intermediate certificates) to be added to the Response.
+ * Must be an Array of OpenSSL::X509::Certificate, or +nil+.
+ */
rb_attr(cTimestampFactory, rb_intern_const("additional_certs"), 1, 1, 0);
rb_define_method(cTimestampFactory, "create_timestamp", ossl_tsfac_create_ts, 3);
}
-
+#else /* OPENSSL_NO_TS */
+void
+Init_ossl_ts(void)
+{
+}
#endif
diff --git a/ext/openssl/ossl_ts.h b/ext/openssl/ossl_ts.h
index 25fb0e1d64..eeca3046eb 100644
--- a/ext/openssl/ossl_ts.h
+++ b/ext/openssl/ossl_ts.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licenced under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_TS_H_)
diff --git a/ext/openssl/ossl_x509.c b/ext/openssl/ossl_x509.c
index f8470703fc..bc3914fda2 100644
--- a/ext/openssl/ossl_x509.c
+++ b/ext/openssl/ossl_x509.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,7 +13,8 @@ VALUE mX509;
#define DefX509Const(x) rb_define_const(mX509, #x, INT2NUM(X509_##x))
#define DefX509Default(x,i) \
- rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i()))
+ rb_define_const(mX509, "DEFAULT_" #x, \
+ rb_obj_freeze(rb_str_new_cstr(X509_get_default_##i())))
ASN1_TIME *
ossl_x509_time_adjust(ASN1_TIME *s, VALUE time)
@@ -29,10 +30,6 @@ ossl_x509_time_adjust(ASN1_TIME *s, VALUE time)
void
Init_ossl_x509(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
-#endif
-
mX509 = rb_define_module_under(mOSSL, "X509");
Init_ossl_x509attr();
@@ -48,9 +45,7 @@ Init_ossl_x509(void)
/* Certificate verification error code */
DefX509Const(V_OK);
-#if defined(X509_V_ERR_UNSPECIFIED) /* 1.0.1r, 1.0.2f, 1.1.0 */
DefX509Const(V_ERR_UNSPECIFIED);
-#endif
DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT);
DefX509Const(V_ERR_UNABLE_TO_GET_CRL);
DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
@@ -104,10 +99,10 @@ Init_ossl_x509(void)
DefX509Const(V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
DefX509Const(V_ERR_UNSUPPORTED_NAME_SYNTAX);
DefX509Const(V_ERR_CRL_PATH_VALIDATION_ERROR);
-#if defined(X509_V_ERR_PATH_LOOP)
+#if defined(X509_V_ERR_PATH_LOOP) /* OpenSSL 1.1.0, missing in LibreSSL */
DefX509Const(V_ERR_PATH_LOOP);
#endif
-#if defined(X509_V_ERR_SUITE_B_INVALID_VERSION)
+#if defined(X509_V_ERR_SUITE_B_INVALID_VERSION) /* OpenSSL 1.1.0, missing in LibreSSL */
DefX509Const(V_ERR_SUITE_B_INVALID_VERSION);
DefX509Const(V_ERR_SUITE_B_INVALID_ALGORITHM);
DefX509Const(V_ERR_SUITE_B_INVALID_CURVE);
@@ -118,27 +113,21 @@ Init_ossl_x509(void)
DefX509Const(V_ERR_HOSTNAME_MISMATCH);
DefX509Const(V_ERR_EMAIL_MISMATCH);
DefX509Const(V_ERR_IP_ADDRESS_MISMATCH);
-#if defined(X509_V_ERR_DANE_NO_MATCH)
+#if defined(X509_V_ERR_DANE_NO_MATCH) /* OpenSSL 1.1.0, missing in LibreSSL */
DefX509Const(V_ERR_DANE_NO_MATCH);
#endif
-#if defined(X509_V_ERR_EE_KEY_TOO_SMALL)
DefX509Const(V_ERR_EE_KEY_TOO_SMALL);
DefX509Const(V_ERR_CA_KEY_TOO_SMALL);
DefX509Const(V_ERR_CA_MD_TOO_WEAK);
-#endif
-#if defined(X509_V_ERR_INVALID_CALL)
DefX509Const(V_ERR_INVALID_CALL);
-#endif
-#if defined(X509_V_ERR_STORE_LOOKUP)
DefX509Const(V_ERR_STORE_LOOKUP);
-#endif
-#if defined(X509_V_ERR_NO_VALID_SCTS)
+#if defined(X509_V_ERR_NO_VALID_SCTS) /* OpenSSL 1.1.0, missing in LibreSSL */
DefX509Const(V_ERR_NO_VALID_SCTS);
#endif
-#if defined(X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION)
+#if defined(X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION) /* OpenSSL 1.1.0, missing in LibreSSL */
DefX509Const(V_ERR_PROXY_SUBJECT_NAME_VIOLATION);
#endif
-#if defined(X509_V_ERR_OCSP_VERIFY_NEEDED)
+#if defined(X509_V_ERR_OCSP_VERIFY_NEEDED) /* OpenSSL 1.1.1, missing in LibreSSL */
DefX509Const(V_ERR_OCSP_VERIFY_NEEDED);
DefX509Const(V_ERR_OCSP_VERIFY_FAILED);
DefX509Const(V_ERR_OCSP_CERT_UNKNOWN);
@@ -189,17 +178,13 @@ Init_ossl_x509(void)
* certificate chain, search the Store first for the issuer certificate.
* Enabled by default in OpenSSL >= 1.1.0. */
DefX509Const(V_FLAG_TRUSTED_FIRST);
-#if defined(X509_V_FLAG_SUITEB_128_LOS_ONLY)
+#if defined(X509_V_FLAG_SUITEB_128_LOS_ONLY) /* OpenSSL 1.1.0, missing in LibreSSL */
/* Set by Store#flags= and StoreContext#flags=.
* Enables Suite B 128 bit only mode. */
DefX509Const(V_FLAG_SUITEB_128_LOS_ONLY);
-#endif
-#if defined(X509_V_FLAG_SUITEB_192_LOS)
/* Set by Store#flags= and StoreContext#flags=.
* Enables Suite B 192 bit only mode. */
DefX509Const(V_FLAG_SUITEB_192_LOS);
-#endif
-#if defined(X509_V_FLAG_SUITEB_128_LOS)
/* Set by Store#flags= and StoreContext#flags=.
* Enables Suite B 128 bit mode allowing 192 bit algorithms. */
DefX509Const(V_FLAG_SUITEB_128_LOS);
@@ -207,17 +192,13 @@ Init_ossl_x509(void)
/* Set by Store#flags= and StoreContext#flags=.
* Allows partial chains if at least one certificate is in trusted store. */
DefX509Const(V_FLAG_PARTIAL_CHAIN);
-#if defined(X509_V_FLAG_NO_ALT_CHAINS)
/* Set by Store#flags= and StoreContext#flags=. Suppresses searching for
* a alternative chain. No effect in OpenSSL >= 1.1.0. */
DefX509Const(V_FLAG_NO_ALT_CHAINS);
-#endif
-#if defined(X509_V_FLAG_NO_CHECK_TIME)
/* Set by Store#flags= and StoreContext#flags=. Suppresses checking the
* validity period of certificates and CRLs. No effect when the current
* time is explicitly set by Store#time= or StoreContext#time=. */
DefX509Const(V_FLAG_NO_CHECK_TIME);
-#endif
/* Set by Store#purpose=. SSL/TLS client. */
DefX509Const(PURPOSE_SSL_CLIENT);
diff --git a/ext/openssl/ossl_x509.h b/ext/openssl/ossl_x509.h
index 4fadfa6b82..71932ef1a9 100644
--- a/ext/openssl/ossl_x509.h
+++ b/ext/openssl/ossl_x509.h
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#if !defined(_OSSL_X509_H_)
#define _OSSL_X509_H_
@@ -28,9 +28,8 @@ void Init_ossl_x509(void);
* X509Attr
*/
extern VALUE cX509Attr;
-extern VALUE eX509AttrError;
-VALUE ossl_x509attr_new(X509_ATTRIBUTE *);
+VALUE ossl_x509attr_new(const X509_ATTRIBUTE *);
X509_ATTRIBUTE *GetX509AttrPtr(VALUE);
void Init_ossl_x509attr(void);
@@ -38,9 +37,8 @@ void Init_ossl_x509attr(void);
* X509Cert
*/
extern VALUE cX509Cert;
-extern VALUE eX509CertError;
-VALUE ossl_x509_new(X509 *);
+VALUE ossl_x509_new(const X509 *);
X509 *GetX509CertPtr(VALUE);
X509 *DupX509CertPtr(VALUE);
void Init_ossl_x509cert(void);
@@ -48,10 +46,7 @@ void Init_ossl_x509cert(void);
/*
* X509CRL
*/
-extern VALUE cX509CRL;
-extern VALUE eX509CRLError;
-
-VALUE ossl_x509crl_new(X509_CRL *);
+VALUE ossl_x509crl_new(const X509_CRL *);
X509_CRL *GetX509CRLPtr(VALUE);
void Init_ossl_x509crl(void);
@@ -59,29 +54,21 @@ void Init_ossl_x509crl(void);
* X509Extension
*/
extern VALUE cX509Ext;
-extern VALUE cX509ExtFactory;
-extern VALUE eX509ExtError;
-VALUE ossl_x509ext_new(X509_EXTENSION *);
+VALUE ossl_x509ext_new(const X509_EXTENSION *);
X509_EXTENSION *GetX509ExtPtr(VALUE);
void Init_ossl_x509ext(void);
/*
* X509Name
*/
-extern VALUE cX509Name;
-extern VALUE eX509NameError;
-
-VALUE ossl_x509name_new(X509_NAME *);
+VALUE ossl_x509name_new(const X509_NAME *);
X509_NAME *GetX509NamePtr(VALUE);
void Init_ossl_x509name(void);
/*
* X509Request
*/
-extern VALUE cX509Req;
-extern VALUE eX509ReqError;
-
X509_REQ *GetX509ReqPtr(VALUE);
void Init_ossl_x509req(void);
@@ -89,21 +76,15 @@ void Init_ossl_x509req(void);
* X509Revoked
*/
extern VALUE cX509Rev;
-extern VALUE eX509RevError;
-VALUE ossl_x509revoked_new(X509_REVOKED *);
+VALUE ossl_x509revoked_new(const X509_REVOKED *);
X509_REVOKED *DupX509RevokedPtr(VALUE);
void Init_ossl_x509revoked(void);
/*
* X509Store and X509StoreContext
*/
-extern VALUE cX509Store;
-extern VALUE cX509StoreContext;
-extern VALUE eX509StoreError;
-
X509_STORE *GetX509StorePtr(VALUE);
-
void Init_ossl_x509store(void);
/*
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c
index 60846cfe9d..38600b9b00 100644
--- a/ext/openssl/ossl_x509attr.c
+++ b/ext/openssl/ossl_x509attr.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,14 +13,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509attr_type, 0)
#define SetX509Attr(obj, attr) do { \
if (!(attr)) { \
- ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (attr); \
} while (0)
#define GetX509Attr(obj, attr) do { \
TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \
if (!(attr)) { \
- ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
} \
} while (0)
@@ -28,7 +28,7 @@
* Classes
*/
VALUE cX509Attr;
-VALUE eX509AttrError;
+static VALUE eX509AttrError;
static void
ossl_x509attr_free(void *ptr)
@@ -39,29 +39,25 @@ ossl_x509attr_free(void *ptr)
static const rb_data_type_t ossl_x509attr_type = {
"OpenSSL/X509/ATTRIBUTE",
{
- 0, ossl_x509attr_free,
+ 0, ossl_x509attr_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* Public
*/
VALUE
-ossl_x509attr_new(X509_ATTRIBUTE *attr)
+ossl_x509attr_new(const X509_ATTRIBUTE *attr)
{
X509_ATTRIBUTE *new;
VALUE obj;
obj = NewX509Attr(cX509Attr);
- if (!attr) {
- new = X509_ATTRIBUTE_new();
- } else {
- new = X509_ATTRIBUTE_dup(attr);
- }
- if (!new) {
- ossl_raise(eX509AttrError, NULL);
- }
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ new = X509_ATTRIBUTE_dup((X509_ATTRIBUTE *)attr);
+ if (!new)
+ ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
SetX509Attr(obj, new);
return obj;
@@ -88,7 +84,7 @@ ossl_x509attr_alloc(VALUE klass)
obj = NewX509Attr(klass);
if (!(attr = X509_ATTRIBUTE_new()))
- ossl_raise(eX509AttrError, NULL);
+ ossl_raise(eX509AttrError, NULL);
SetX509Attr(obj, attr);
return obj;
@@ -107,15 +103,15 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
GetX509Attr(self, attr);
if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){
- oid = ossl_to_der_if_possible(oid);
- StringValue(oid);
- p = (unsigned char *)RSTRING_PTR(oid);
- x = d2i_X509_ATTRIBUTE(&attr, &p, RSTRING_LEN(oid));
- DATA_PTR(self) = attr;
- if(!x){
- ossl_raise(eX509AttrError, NULL);
- }
- return self;
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = (unsigned char *)RSTRING_PTR(oid);
+ x = d2i_X509_ATTRIBUTE(&attr, &p, RSTRING_LEN(oid));
+ DATA_PTR(self) = attr;
+ if(!x){
+ ossl_raise(eX509AttrError, NULL);
+ }
+ return self;
}
rb_funcall(self, rb_intern("oid="), 1, oid);
rb_funcall(self, rb_intern("value="), 1, value);
@@ -123,6 +119,7 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509attr_initialize_copy(VALUE self, VALUE other)
{
@@ -134,7 +131,7 @@ ossl_x509attr_initialize_copy(VALUE self, VALUE other)
attr_new = X509_ATTRIBUTE_dup(attr_other);
if (!attr_new)
- ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
+ ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
SetX509Attr(self, attr_new);
X509_ATTRIBUTE_free(attr);
@@ -158,8 +155,8 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
obj = OBJ_txt2obj(s, 0);
if(!obj) ossl_raise(eX509AttrError, NULL);
if (!X509_ATTRIBUTE_set1_object(attr, obj)) {
- ASN1_OBJECT_free(obj);
- ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_object");
+ ASN1_OBJECT_free(obj);
+ ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_object");
}
ASN1_OBJECT_free(obj);
@@ -168,29 +165,18 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
/*
* call-seq:
- * attr.oid => string
+ * attr.oid -> string
+ *
+ * Returns the OID of the attribute. Returns the short name or the dotted
+ * decimal notation.
*/
static VALUE
ossl_x509attr_get_oid(VALUE self)
{
X509_ATTRIBUTE *attr;
- ASN1_OBJECT *oid;
- BIO *out;
- VALUE ret;
- int nid;
GetX509Attr(self, attr);
- oid = X509_ATTRIBUTE_get0_object(attr);
- if ((nid = OBJ_obj2nid(oid)) != NID_undef)
- ret = rb_str_new2(OBJ_nid2sn(nid));
- else{
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509AttrError, NULL);
- i2a_ASN1_OBJECT(out, oid);
- ret = ossl_membio2str(out);
- }
-
- return ret;
+ return ossl_asn1obj_to_string(X509_ATTRIBUTE_get0_object(attr));
}
/*
@@ -201,37 +187,36 @@ static VALUE
ossl_x509attr_set_value(VALUE self, VALUE value)
{
X509_ATTRIBUTE *attr;
- VALUE asn1_value;
- int i, asn1_tag;
+ GetX509Attr(self, attr);
OSSL_Check_Kind(value, cASN1Data);
- asn1_tag = NUM2INT(rb_attr_get(value, rb_intern("@tag")));
- asn1_value = rb_attr_get(value, rb_intern("@value"));
- if (asn1_tag != V_ASN1_SET)
- ossl_raise(eASN1Error, "argument must be ASN1::Set");
- if (!RB_TYPE_P(asn1_value, T_ARRAY))
- ossl_raise(eASN1Error, "ASN1::Set has non-array value");
+ VALUE der = ossl_to_der(value);
+ const unsigned char *p = (const unsigned char *)RSTRING_PTR(der);
+ STACK_OF(ASN1_TYPE) *sk = d2i_ASN1_SET_ANY(NULL, &p, RSTRING_LEN(der));
+ if (!sk)
+ ossl_raise(eX509AttrError, "attribute value must be ASN1::Set");
- GetX509Attr(self, attr);
if (X509_ATTRIBUTE_count(attr)) { /* populated, reset first */
- ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
- X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1);
- if (!new_attr)
- ossl_raise(eX509AttrError, NULL);
- SetX509Attr(self, new_attr);
- X509_ATTRIBUTE_free(attr);
- attr = new_attr;
+ const ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
+ X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1);
+ if (!new_attr) {
+ sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
+ ossl_raise(eX509AttrError, "X509_ATTRIBUTE_create_by_OBJ");
+ }
+ SetX509Attr(self, new_attr);
+ X509_ATTRIBUTE_free(attr);
+ attr = new_attr;
}
- for (i = 0; i < RARRAY_LEN(asn1_value); i++) {
- ASN1_TYPE *a1type = ossl_asn1_get_asn1type(RARRAY_AREF(asn1_value, i));
- if (!X509_ATTRIBUTE_set1_data(attr, ASN1_TYPE_get(a1type),
- a1type->value.ptr, -1)) {
- ASN1_TYPE_free(a1type);
- ossl_raise(eX509AttrError, NULL);
- }
- ASN1_TYPE_free(a1type);
+ for (int i = 0; i < sk_ASN1_TYPE_num(sk); i++) {
+ ASN1_TYPE *a1type = sk_ASN1_TYPE_value(sk, i);
+ if (!X509_ATTRIBUTE_set1_data(attr, ASN1_TYPE_get(a1type),
+ a1type->value.ptr, -1)) {
+ sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
+ ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_data");
+ }
}
+ sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
return value;
}
@@ -250,23 +235,32 @@ ossl_x509attr_get_value(VALUE self)
unsigned char *p;
GetX509Attr(self, attr);
+ count = X509_ATTRIBUTE_count(attr);
/* there is no X509_ATTRIBUTE_get0_set() :( */
+#ifdef HAVE_OPENSSL_SK_NEW_RESERVE
+ if (!(sk = sk_ASN1_TYPE_new_reserve(NULL, count)))
+ ossl_raise(eX509AttrError, "sk_new_reserve");
+#else
if (!(sk = sk_ASN1_TYPE_new_null()))
- ossl_raise(eX509AttrError, "sk_new");
+ ossl_raise(eX509AttrError, "sk_new");
+#endif
- count = X509_ATTRIBUTE_count(attr);
- for (i = 0; i < count; i++)
- sk_ASN1_TYPE_push(sk, X509_ATTRIBUTE_get0_type(attr, i));
+ for (i = 0; i < count; i++) {
+ if (!sk_ASN1_TYPE_push(sk, (ASN1_TYPE *)X509_ATTRIBUTE_get0_type(attr, i))) {
+ sk_ASN1_TYPE_free(sk);
+ ossl_raise(eX509AttrError, NULL);
+ }
+ }
if ((len = i2d_ASN1_SET_ANY(sk, NULL)) <= 0) {
- sk_ASN1_TYPE_free(sk);
- ossl_raise(eX509AttrError, NULL);
+ sk_ASN1_TYPE_free(sk);
+ ossl_raise(eX509AttrError, NULL);
}
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_ASN1_SET_ANY(sk, &p) <= 0) {
- sk_ASN1_TYPE_free(sk);
- ossl_raise(eX509AttrError, NULL);
+ sk_ASN1_TYPE_free(sk);
+ ossl_raise(eX509AttrError, NULL);
}
ossl_str_adjust(str, p);
sk_ASN1_TYPE_free(sk);
@@ -288,11 +282,11 @@ ossl_x509attr_to_der(VALUE self)
GetX509Attr(self, attr);
if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0)
- ossl_raise(eX509AttrError, NULL);
+ ossl_raise(eX509AttrError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
- ossl_raise(eX509AttrError, NULL);
+ ossl_raise(eX509AttrError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -304,12 +298,6 @@ ossl_x509attr_to_der(VALUE self)
void
Init_ossl_x509attr(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509AttrError = rb_define_class_under(mX509, "AttributeError", eOSSLError);
cX509Attr = rb_define_class_under(mX509, "Attribute", rb_cObject);
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 9443541645..08dd184a0c 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,14 +13,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509_type, 0)
#define SetX509(obj, x509) do { \
if (!(x509)) { \
- ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (x509); \
} while (0)
#define GetX509(obj, x509) do { \
TypedData_Get_Struct((obj), X509, &ossl_x509_type, (x509)); \
if (!(x509)) { \
- ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
} \
} while (0)
@@ -28,7 +28,7 @@
* Classes
*/
VALUE cX509Cert;
-VALUE eX509CertError;
+static VALUE eX509CertError;
static void
ossl_x509_free(void *ptr)
@@ -39,29 +39,25 @@ ossl_x509_free(void *ptr)
static const rb_data_type_t ossl_x509_type = {
"OpenSSL/X509",
{
- 0, ossl_x509_free,
+ 0, ossl_x509_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* Public
*/
VALUE
-ossl_x509_new(X509 *x509)
+ossl_x509_new(const X509 *x509)
{
X509 *new;
VALUE obj;
obj = NewX509(cX509Cert);
- if (!x509) {
- new = X509_new();
- } else {
- new = X509_dup(x509);
- }
- if (!new) {
- ossl_raise(eX509CertError, NULL);
- }
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ new = X509_dup((X509 *)x509);
+ if (!new)
+ ossl_raise(eX509CertError, "X509_dup");
SetX509(obj, new);
return obj;
@@ -120,8 +116,8 @@ ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
rb_check_frozen(self);
if (rb_scan_args(argc, argv, "01", &arg) == 0) {
- /* create just empty X509Cert */
- return self;
+ /* create just empty X509Cert */
+ return self;
}
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
@@ -140,6 +136,7 @@ ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509_copy(VALUE self, VALUE other)
{
@@ -174,11 +171,11 @@ ossl_x509_to_der(VALUE self)
GetX509(self, x509);
if ((len = i2d_X509(x509, NULL)) <= 0)
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_X509(x509, &p) <= 0)
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -200,8 +197,8 @@ ossl_x509_to_pem(VALUE self)
if (!out) ossl_raise(eX509CertError, NULL);
if (!PEM_write_bio_X509(out, x509)) {
- BIO_free(out);
- ossl_raise(eX509CertError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
}
str = ossl_membio2str(out);
@@ -225,8 +222,8 @@ ossl_x509_to_text(VALUE self)
if (!out) ossl_raise(eX509CertError, NULL);
if (!X509_print(out, x509)) {
- BIO_free(out);
- ossl_raise(eX509CertError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
}
str = ossl_membio2str(out);
@@ -246,7 +243,7 @@ ossl_x509_to_req(VALUE self)
GetX509(self, x509);
if (!(req = X509_to_X509_REQ(x509, NULL, EVP_md5()))) {
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
obj = ossl_x509req_new(req);
X509_REQ_free(req);
@@ -280,11 +277,11 @@ ossl_x509_set_version(VALUE self, VALUE version)
long ver;
if ((ver = NUM2LONG(version)) < 0) {
- ossl_raise(eX509CertError, "version must be >= 0!");
+ ossl_raise(eX509CertError, "version must be >= 0!");
}
GetX509(self, x509);
if (!X509_set_version(x509, ver)) {
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return version;
@@ -314,7 +311,9 @@ ossl_x509_set_serial(VALUE self, VALUE num)
X509 *x509;
GetX509(self, x509);
- X509_set_serialNumber(x509, num_to_asn1integer(num, X509_get_serialNumber(x509)));
+ if (!X509_set_serialNumber(x509, num_to_asn1integer(num, X509_get_serialNumber(x509)))) {
+ ossl_raise(eX509CertError, NULL);
+ }
return num;
}
@@ -322,25 +321,23 @@ ossl_x509_set_serial(VALUE self, VALUE num)
/*
* call-seq:
* cert.signature_algorithm => string
+ *
+ * Returns the signature algorithm used to sign this certificate. This returns
+ * the algorithm name found in the TBSCertificate structure, not the outer
+ * \Certificate structure.
+ *
+ * Returns the long name of the signature algorithm, or the dotted decimal
+ * notation if \OpenSSL does not define a long name for it.
*/
static VALUE
ossl_x509_get_signature_algorithm(VALUE self)
{
X509 *x509;
- BIO *out;
- VALUE str;
+ const ASN1_OBJECT *obj;
GetX509(self, x509);
- out = BIO_new(BIO_s_mem());
- if (!out) ossl_raise(eX509CertError, NULL);
-
- if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) {
- BIO_free(out);
- ossl_raise(eX509CertError, NULL);
- }
- str = ossl_membio2str(out);
-
- return str;
+ X509_ALGOR_get0(&obj, NULL, NULL, X509_get0_tbs_sigalg(x509));
+ return ossl_asn1obj_to_string_long_name(obj);
}
/*
@@ -351,11 +348,11 @@ static VALUE
ossl_x509_get_subject(VALUE self)
{
X509 *x509;
- X509_NAME *name;
+ const X509_NAME *name;
GetX509(self, x509);
if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return ossl_x509name_new(name);
@@ -372,7 +369,7 @@ ossl_x509_set_subject(VALUE self, VALUE subject)
GetX509(self, x509);
if (!X509_set_subject_name(x509, GetX509NamePtr(subject))) { /* DUPs name */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return subject;
@@ -386,11 +383,11 @@ static VALUE
ossl_x509_get_issuer(VALUE self)
{
X509 *x509;
- X509_NAME *name;
+ const X509_NAME *name;
GetX509(self, x509);
if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return ossl_x509name_new(name);
@@ -407,7 +404,7 @@ ossl_x509_set_issuer(VALUE self, VALUE issuer)
GetX509(self, x509);
if (!X509_set_issuer_name(x509, GetX509NamePtr(issuer))) { /* DUPs name */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return issuer;
@@ -425,7 +422,7 @@ ossl_x509_get_not_before(VALUE self)
GetX509(self, x509);
if (!(asn1time = X509_get0_notBefore(x509))) {
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return asn1time_to_time(asn1time);
@@ -444,8 +441,8 @@ ossl_x509_set_not_before(VALUE self, VALUE time)
GetX509(self, x509);
asn1time = ossl_x509_time_adjust(NULL, time);
if (!X509_set1_notBefore(x509, asn1time)) {
- ASN1_TIME_free(asn1time);
- ossl_raise(eX509CertError, "X509_set_notBefore");
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509CertError, "X509_set_notBefore");
}
ASN1_TIME_free(asn1time);
@@ -464,7 +461,7 @@ ossl_x509_get_not_after(VALUE self)
GetX509(self, x509);
if (!(asn1time = X509_get0_notAfter(x509))) {
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return asn1time_to_time(asn1time);
@@ -483,8 +480,8 @@ ossl_x509_set_not_after(VALUE self, VALUE time)
GetX509(self, x509);
asn1time = ossl_x509_time_adjust(NULL, time);
if (!X509_set1_notAfter(x509, asn1time)) {
- ASN1_TIME_free(asn1time);
- ossl_raise(eX509CertError, "X509_set_notAfter");
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509CertError, "X509_set_notAfter");
}
ASN1_TIME_free(asn1time);
@@ -503,10 +500,10 @@ ossl_x509_get_public_key(VALUE self)
GetX509(self, x509);
if (!(pkey = X509_get_pubkey(x509))) { /* adds an reference */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
- return ossl_pkey_new(pkey); /* NO DUP - OK */
+ return ossl_pkey_wrap(pkey);
}
/*
@@ -523,7 +520,7 @@ ossl_x509_set_public_key(VALUE self, VALUE key)
pkey = GetPKeyPtr(key);
ossl_pkey_check_public_key(pkey);
if (!X509_set_pubkey(x509, pkey))
- ossl_raise(eX509CertError, "X509_set_pubkey");
+ ossl_raise(eX509CertError, "X509_set_pubkey");
return key;
}
@@ -537,13 +534,14 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
X509 *x509;
EVP_PKEY *pkey;
const EVP_MD *md;
+ VALUE md_holder;
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
+ /* NULL needed for some key types, e.g. Ed25519 */
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
GetX509(self, x509);
- if (!X509_sign(x509, pkey, md)) {
- ossl_raise(eX509CertError, NULL);
- }
+ if (!X509_sign(x509, pkey, md))
+ ossl_raise(eX509CertError, "X509_sign");
return self;
}
@@ -566,12 +564,12 @@ ossl_x509_verify(VALUE self, VALUE key)
ossl_pkey_check_public_key(pkey);
switch (X509_verify(x509, pkey)) {
case 1:
- return Qtrue;
+ return Qtrue;
case 0:
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
default:
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
}
@@ -592,8 +590,8 @@ ossl_x509_check_private_key(VALUE self, VALUE key)
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
GetX509(self, x509);
if (!X509_check_private_key(x509, pkey)) {
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
}
return Qtrue;
@@ -608,18 +606,14 @@ ossl_x509_get_extensions(VALUE self)
{
X509 *x509;
int count, i;
- X509_EXTENSION *ext;
VALUE ary;
GetX509(self, x509);
count = X509_get_ext_count(x509);
- if (count < 0) {
- return rb_ary_new();
- }
- ary = rb_ary_new2(count);
+ ary = rb_ary_new_capa(count);
for (i=0; i<count; i++) {
- ext = X509_get_ext(x509, i); /* NO DUP - don't free! */
- rb_ary_push(ary, ossl_x509ext_new(ext));
+ const X509_EXTENSION *ext = X509_get_ext(x509, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext));
}
return ary;
@@ -639,16 +633,16 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary's members should be X509Extension */
for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
+ OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
}
GetX509(self, x509);
for (i = X509_get_ext_count(x509); i > 0; i--)
X509_EXTENSION_free(X509_delete_ext(x509, 0));
for (i=0; i<RARRAY_LEN(ary); i++) {
- ext = GetX509ExtPtr(RARRAY_AREF(ary, i));
- if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext */
- ossl_raise(eX509CertError, "X509_add_ext");
- }
+ ext = GetX509ExtPtr(RARRAY_AREF(ary, i));
+ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext */
+ ossl_raise(eX509CertError, "X509_add_ext");
+ }
}
return ary;
@@ -667,32 +661,24 @@ ossl_x509_add_extension(VALUE self, VALUE extension)
GetX509(self, x509);
ext = GetX509ExtPtr(extension);
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
- ossl_raise(eX509CertError, NULL);
+ ossl_raise(eX509CertError, NULL);
}
return extension;
}
-static VALUE
-ossl_x509_inspect(VALUE self)
-{
- return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", "
- "issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", "
- "not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">",
- rb_obj_class(self),
- ossl_x509_get_subject(self),
- ossl_x509_get_issuer(self),
- ossl_x509_get_serial(self),
- ossl_x509_get_not_before(self),
- ossl_x509_get_not_after(self));
-}
-
/*
* call-seq:
* cert1 == cert2 -> true | false
*
* Compares the two certificates. Note that this takes into account all fields,
* not just the issuer name and the serial number.
+ *
+ * This method uses X509_cmp() from OpenSSL, which compares certificates based
+ * on their cached DER encodings. The comparison can be unreliable if a
+ * certificate is incomplete.
+ *
+ * See also the man page X509_cmp(3).
*/
static VALUE
ossl_x509_eq(VALUE self, VALUE other)
@@ -701,12 +687,42 @@ ossl_x509_eq(VALUE self, VALUE other)
GetX509(self, a);
if (!rb_obj_is_kind_of(other, cX509Cert))
- return Qfalse;
+ return Qfalse;
GetX509(other, b);
return !X509_cmp(a, b) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * cert.tbs_bytes => string
+ *
+ * Returns the DER-encoded bytes of the certificate's to be signed certificate.
+ * This is mainly useful for validating embedded certificate transparency signatures.
+ */
+static VALUE
+ossl_x509_tbs_bytes(VALUE self)
+{
+ X509 *x509;
+ int len;
+ unsigned char *p0;
+ VALUE str;
+
+ GetX509(self, x509);
+ len = i2d_re_X509_tbs(x509, NULL);
+ if (len <= 0) {
+ ossl_raise(eX509CertError, "i2d_re_X509_tbs");
+ }
+ str = rb_str_new(NULL, len);
+ p0 = (unsigned char *)RSTRING_PTR(str);
+ if (i2d_re_X509_tbs(x509, &p0) <= 0) {
+ ossl_raise(eX509CertError, "i2d_re_X509_tbs");
+ }
+ ossl_str_adjust(str, p0);
+
+ return str;
+}
+
struct load_chained_certificates_arguments {
VALUE certificates;
X509 *certificate;
@@ -766,7 +782,7 @@ load_chained_certificates_PEM(BIO *in) {
certificates = load_chained_certificates_append(Qnil, certificate);
while ((certificate = PEM_read_bio_X509(in, NULL, NULL, NULL))) {
- load_chained_certificates_append(certificates, certificate);
+ load_chained_certificates_append(certificates, certificate);
}
/* We tried to read one more certificate but could not read start line: */
@@ -864,12 +880,6 @@ ossl_x509_load(VALUE klass, VALUE buffer)
void
Init_ossl_x509cert(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509CertError = rb_define_class_under(mX509, "CertificateError", eOSSLError);
/* Document-class: OpenSSL::X509::Certificate
@@ -997,6 +1007,6 @@ Init_ossl_x509cert(void)
rb_define_method(cX509Cert, "extensions", ossl_x509_get_extensions, 0);
rb_define_method(cX509Cert, "extensions=", ossl_x509_set_extensions, 1);
rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1);
- rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0);
rb_define_method(cX509Cert, "==", ossl_x509_eq, 1);
+ rb_define_method(cX509Cert, "tbs_bytes", ossl_x509_tbs_bytes, 0);
}
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
index 6c1d915370..9b59bda9e2 100644
--- a/ext/openssl/ossl_x509crl.c
+++ b/ext/openssl/ossl_x509crl.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,22 +13,22 @@
TypedData_Wrap_Struct((klass), &ossl_x509crl_type, 0)
#define SetX509CRL(obj, crl) do { \
if (!(crl)) { \
- ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (crl); \
} while (0)
#define GetX509CRL(obj, crl) do { \
TypedData_Get_Struct((obj), X509_CRL, &ossl_x509crl_type, (crl)); \
if (!(crl)) { \
- ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
} \
} while (0)
/*
* Classes
*/
-VALUE cX509CRL;
-VALUE eX509CRLError;
+static VALUE cX509CRL;
+static VALUE eX509CRLError;
static void
ossl_x509crl_free(void *ptr)
@@ -39,9 +39,9 @@ ossl_x509crl_free(void *ptr)
static const rb_data_type_t ossl_x509crl_type = {
"OpenSSL/X509/CRL",
{
- 0, ossl_x509crl_free,
+ 0, ossl_x509crl_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -58,14 +58,16 @@ GetX509CRLPtr(VALUE obj)
}
VALUE
-ossl_x509crl_new(X509_CRL *crl)
+ossl_x509crl_new(const X509_CRL *crl)
{
X509_CRL *tmp;
VALUE obj;
obj = NewX509CRL(cX509CRL);
- tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
- if(!tmp) ossl_raise(eX509CRLError, NULL);
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ tmp = X509_CRL_dup((X509_CRL *)crl);
+ if (!tmp)
+ ossl_raise(eX509CRLError, "X509_CRL_dup");
SetX509CRL(obj, tmp);
return obj;
@@ -82,7 +84,7 @@ ossl_x509crl_alloc(VALUE klass)
obj = NewX509CRL(klass);
if (!(crl = X509_CRL_new())) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
SetX509CRL(obj, crl);
@@ -98,7 +100,7 @@ ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)
rb_check_frozen(self);
if (rb_scan_args(argc, argv, "01", &arg) == 0) {
- return self;
+ return self;
}
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
@@ -117,6 +119,7 @@ ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509crl_copy(VALUE self, VALUE other)
{
@@ -127,7 +130,7 @@ ossl_x509crl_copy(VALUE self, VALUE other)
GetX509CRL(self, a);
GetX509CRL(other, b);
if (!(crl = X509_CRL_dup(b))) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
X509_CRL_free(a);
DATA_PTR(self) = crl;
@@ -154,34 +157,36 @@ ossl_x509crl_set_version(VALUE self, VALUE version)
long ver;
if ((ver = NUM2LONG(version)) < 0) {
- ossl_raise(eX509CRLError, "version must be >= 0!");
+ ossl_raise(eX509CRLError, "version must be >= 0!");
}
GetX509CRL(self, crl);
if (!X509_CRL_set_version(crl, ver)) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
return version;
}
+/*
+ * call-seq:
+ * crl.signature_algorithm -> string
+ *
+ * Returns the signature algorithm used to sign this CRL.
+ *
+ * Returns the long name of the signature algorithm, or the dotted decimal
+ * notation if \OpenSSL does not define a long name for it.
+ */
static VALUE
ossl_x509crl_get_signature_algorithm(VALUE self)
{
X509_CRL *crl;
const X509_ALGOR *alg;
- BIO *out;
+ const ASN1_OBJECT *obj;
GetX509CRL(self, crl);
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509CRLError, NULL);
- }
X509_CRL_get0_signature(crl, NULL, &alg);
- if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
- BIO_free(out);
- ossl_raise(eX509CRLError, NULL);
- }
-
- return ossl_membio2str(out);
+ X509_ALGOR_get0(&obj, NULL, NULL, alg);
+ return ossl_asn1obj_to_string_long_name(obj);
}
static VALUE
@@ -202,7 +207,7 @@ ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
GetX509CRL(self, crl);
if (!X509_CRL_set_issuer_name(crl, GetX509NamePtr(issuer))) { /* DUPs name */
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
return issuer;
}
@@ -216,7 +221,7 @@ ossl_x509crl_get_last_update(VALUE self)
GetX509CRL(self, crl);
time = X509_CRL_get0_lastUpdate(crl);
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -230,8 +235,8 @@ ossl_x509crl_set_last_update(VALUE self, VALUE time)
GetX509CRL(self, crl);
asn1time = ossl_x509_time_adjust(NULL, time);
if (!X509_CRL_set1_lastUpdate(crl, asn1time)) {
- ASN1_TIME_free(asn1time);
- ossl_raise(eX509CRLError, "X509_CRL_set_lastUpdate");
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509CRLError, "X509_CRL_set_lastUpdate");
}
ASN1_TIME_free(asn1time);
@@ -247,7 +252,7 @@ ossl_x509crl_get_next_update(VALUE self)
GetX509CRL(self, crl);
time = X509_CRL_get0_nextUpdate(crl);
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -261,8 +266,8 @@ ossl_x509crl_set_next_update(VALUE self, VALUE time)
GetX509CRL(self, crl);
asn1time = ossl_x509_time_adjust(NULL, time);
if (!X509_CRL_set1_nextUpdate(crl, asn1time)) {
- ASN1_TIME_free(asn1time);
- ossl_raise(eX509CRLError, "X509_CRL_set_nextUpdate");
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509CRLError, "X509_CRL_set_nextUpdate");
}
ASN1_TIME_free(asn1time);
@@ -274,21 +279,19 @@ ossl_x509crl_get_revoked(VALUE self)
{
X509_CRL *crl;
int i, num;
- X509_REVOKED *rev;
- VALUE ary, revoked;
+ STACK_OF(X509_REVOKED) *sk;
+ VALUE ary;
GetX509CRL(self, crl);
- num = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
- if (num < 0) {
- OSSL_Debug("num < 0???");
- return rb_ary_new();
- }
- ary = rb_ary_new2(num);
+ sk = X509_CRL_get_REVOKED(crl);
+ if (!sk)
+ return rb_ary_new();
+
+ num = sk_X509_REVOKED_num(sk);
+ ary = rb_ary_new_capa(num);
for(i=0; i<num; i++) {
- /* NO DUP - don't free! */
- rev = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i);
- revoked = ossl_x509revoked_new(rev);
- rb_ary_push(ary, revoked);
+ const X509_REVOKED *rev = sk_X509_REVOKED_value(sk, i);
+ rb_ary_push(ary, ossl_x509revoked_new(rev));
}
return ary;
@@ -305,19 +308,19 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Revoked */
for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Rev);
+ OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Rev);
}
GetX509CRL(self, crl);
if ((sk = X509_CRL_get_REVOKED(crl))) {
- while ((rev = sk_X509_REVOKED_pop(sk)))
- X509_REVOKED_free(rev);
+ while ((rev = sk_X509_REVOKED_pop(sk)))
+ X509_REVOKED_free(rev);
}
for (i=0; i<RARRAY_LEN(ary); i++) {
- rev = DupX509RevokedPtr(RARRAY_AREF(ary, i));
- if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
- X509_REVOKED_free(rev);
- ossl_raise(eX509CRLError, "X509_CRL_add0_revoked");
- }
+ rev = DupX509RevokedPtr(RARRAY_AREF(ary, i));
+ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
+ X509_REVOKED_free(rev);
+ ossl_raise(eX509CRLError, "X509_CRL_add0_revoked");
+ }
}
X509_CRL_sort(crl);
@@ -333,8 +336,8 @@ ossl_x509crl_add_revoked(VALUE self, VALUE revoked)
GetX509CRL(self, crl);
rev = DupX509RevokedPtr(revoked);
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
- X509_REVOKED_free(rev);
- ossl_raise(eX509CRLError, "X509_CRL_add0_revoked");
+ X509_REVOKED_free(rev);
+ ossl_raise(eX509CRLError, "X509_CRL_add0_revoked");
}
X509_CRL_sort(crl);
@@ -347,13 +350,14 @@ ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
X509_CRL *crl;
EVP_PKEY *pkey;
const EVP_MD *md;
+ VALUE md_holder;
GetX509CRL(self, crl);
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
- if (!X509_CRL_sign(crl, pkey, md)) {
- ossl_raise(eX509CRLError, NULL);
- }
+ /* NULL needed for some key types, e.g. Ed25519 */
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
+ if (!X509_CRL_sign(crl, pkey, md))
+ ossl_raise(eX509CRLError, "X509_CRL_sign");
return self;
}
@@ -369,12 +373,12 @@ ossl_x509crl_verify(VALUE self, VALUE key)
ossl_pkey_check_public_key(pkey);
switch (X509_CRL_verify(crl, pkey)) {
case 1:
- return Qtrue;
+ return Qtrue;
case 0:
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
default:
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
}
@@ -386,11 +390,11 @@ ossl_x509crl_to_der(VALUE self)
GetX509CRL(self, crl);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
if (!i2d_X509_CRL_bio(out, crl)) {
- BIO_free(out);
- ossl_raise(eX509CRLError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
}
return ossl_membio2str(out);
@@ -404,11 +408,11 @@ ossl_x509crl_to_pem(VALUE self)
GetX509CRL(self, crl);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
if (!PEM_write_bio_X509_CRL(out, crl)) {
- BIO_free(out);
- ossl_raise(eX509CRLError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
}
return ossl_membio2str(out);
@@ -422,11 +426,11 @@ ossl_x509crl_to_text(VALUE self)
GetX509CRL(self, crl);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
if (!X509_CRL_print(out, crl)) {
- BIO_free(out);
- ossl_raise(eX509CRLError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
}
return ossl_membio2str(out);
@@ -440,19 +444,14 @@ ossl_x509crl_get_extensions(VALUE self)
{
X509_CRL *crl;
int count, i;
- X509_EXTENSION *ext;
VALUE ary;
GetX509CRL(self, crl);
count = X509_CRL_get_ext_count(crl);
- if (count < 0) {
- OSSL_Debug("count < 0???");
- return rb_ary_new();
- }
- ary = rb_ary_new2(count);
+ ary = rb_ary_new_capa(count);
for (i=0; i<count; i++) {
- ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */
- rb_ary_push(ary, ossl_x509ext_new(ext));
+ const X509_EXTENSION *ext = X509_CRL_get_ext(crl, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext));
}
return ary;
@@ -471,16 +470,16 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Extensions */
for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
+ OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
}
GetX509CRL(self, crl);
for (i = X509_CRL_get_ext_count(crl); i > 0; i--)
X509_EXTENSION_free(X509_CRL_delete_ext(crl, 0));
for (i=0; i<RARRAY_LEN(ary); i++) {
- ext = GetX509ExtPtr(RARRAY_AREF(ary, i)); /* NO NEED TO DUP */
- if (!X509_CRL_add_ext(crl, ext, -1)) {
- ossl_raise(eX509CRLError, "X509_CRL_add_ext");
- }
+ ext = GetX509ExtPtr(RARRAY_AREF(ary, i)); /* NO NEED TO DUP */
+ if (!X509_CRL_add_ext(crl, ext, -1)) {
+ ossl_raise(eX509CRLError, "X509_CRL_add_ext");
+ }
}
return ary;
@@ -495,7 +494,7 @@ ossl_x509crl_add_extension(VALUE self, VALUE extension)
GetX509CRL(self, crl);
ext = GetX509ExtPtr(extension);
if (!X509_CRL_add_ext(crl, ext, -1)) {
- ossl_raise(eX509CRLError, NULL);
+ ossl_raise(eX509CRLError, NULL);
}
return extension;
@@ -507,12 +506,6 @@ ossl_x509crl_add_extension(VALUE self, VALUE extension)
void
Init_ossl_x509crl(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError);
cX509CRL = rb_define_class_under(mX509, "CRL", rb_cObject);
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
index e54102c771..1fe727d3f1 100644
--- a/ext/openssl/ossl_x509ext.c
+++ b/ext/openssl/ossl_x509ext.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,14 +13,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509ext_type, 0)
#define SetX509Ext(obj, ext) do { \
if (!(ext)) { \
- ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (ext); \
} while (0)
#define GetX509Ext(obj, ext) do { \
TypedData_Get_Struct((obj), X509_EXTENSION, &ossl_x509ext_type, (ext)); \
if (!(ext)) { \
- ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
} \
} while (0)
#define MakeX509ExtFactory(klass, obj, ctx) do { \
@@ -33,7 +33,7 @@
#define GetX509ExtFactory(obj, ctx) do { \
TypedData_Get_Struct((obj), X509V3_CTX, &ossl_x509extfactory_type, (ctx)); \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
} \
} while (0)
@@ -41,8 +41,8 @@
* Classes
*/
VALUE cX509Ext;
-VALUE cX509ExtFactory;
-VALUE eX509ExtError;
+static VALUE cX509ExtFactory;
+static VALUE eX509ExtError;
static void
ossl_x509ext_free(void *ptr)
@@ -53,29 +53,25 @@ ossl_x509ext_free(void *ptr)
static const rb_data_type_t ossl_x509ext_type = {
"OpenSSL/X509/EXTENSION",
{
- 0, ossl_x509ext_free,
+ 0, ossl_x509ext_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* Public
*/
VALUE
-ossl_x509ext_new(X509_EXTENSION *ext)
+ossl_x509ext_new(const X509_EXTENSION *ext)
{
X509_EXTENSION *new;
VALUE obj;
obj = NewX509Ext(cX509Ext);
- if (!ext) {
- new = X509_EXTENSION_new();
- } else {
- new = X509_EXTENSION_dup(ext);
- }
- if (!new) {
- ossl_raise(eX509ExtError, NULL);
- }
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ new = X509_EXTENSION_dup((X509_EXTENSION *)ext);
+ if (!new)
+ ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
SetX509Ext(obj, new);
return obj;
@@ -106,9 +102,9 @@ ossl_x509extfactory_free(void *ctx)
static const rb_data_type_t ossl_x509extfactory_type = {
"OpenSSL/X509/EXTENSION/Factory",
{
- 0, ossl_x509extfactory_free,
+ 0, ossl_x509extfactory_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -180,15 +176,15 @@ ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self)
/*GetX509ExtFactory(self, ctx);*/
rb_scan_args(argc, argv, "04",
- &issuer_cert, &subject_cert, &subject_req, &crl);
+ &issuer_cert, &subject_cert, &subject_req, &crl);
if (!NIL_P(issuer_cert))
- ossl_x509extfactory_set_issuer_cert(self, issuer_cert);
+ ossl_x509extfactory_set_issuer_cert(self, issuer_cert);
if (!NIL_P(subject_cert))
- ossl_x509extfactory_set_subject_cert(self, subject_cert);
+ ossl_x509extfactory_set_subject_cert(self, subject_cert);
if (!NIL_P(subject_req))
- ossl_x509extfactory_set_subject_req(self, subject_req);
+ ossl_x509extfactory_set_subject_req(self, subject_req);
if (!NIL_P(crl))
- ossl_x509extfactory_set_crl(self, crl);
+ ossl_x509extfactory_set_crl(self, crl);
return self;
}
@@ -209,15 +205,16 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
int nid;
VALUE rconf;
CONF *conf;
+ const char *oid_cstr = NULL;
rb_scan_args(argc, argv, "21", &oid, &value, &critical);
- StringValueCStr(oid);
StringValue(value);
if(NIL_P(critical)) critical = Qfalse;
- nid = OBJ_ln2nid(RSTRING_PTR(oid));
- if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid));
- if(!nid) ossl_raise(eX509ExtError, "unknown OID `%"PRIsVALUE"'", oid);
+ oid_cstr = StringValueCStr(oid);
+ nid = OBJ_ln2nid(oid_cstr);
+ if (nid != NID_undef)
+ oid_cstr = OBJ_nid2sn(nid);
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
rb_str_append(valstr, value);
@@ -228,10 +225,11 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
rconf = rb_iv_get(self, "@config");
conf = NIL_P(rconf) ? NULL : GetConfig(rconf);
X509V3_set_nconf(ctx, conf);
- ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr));
+
+ ext = X509V3_EXT_nconf(conf, ctx, oid_cstr, RSTRING_PTR(valstr));
X509V3_set_ctx_nodb(ctx);
if (!ext){
- ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr);
+ ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr);
}
SetX509Ext(obj, ext);
@@ -249,7 +247,7 @@ ossl_x509ext_alloc(VALUE klass)
obj = NewX509Ext(klass);
if(!(ext = X509_EXTENSION_new())){
- ossl_raise(eX509ExtError, NULL);
+ ossl_raise(eX509ExtError, NULL);
}
SetX509Ext(obj, ext);
@@ -277,14 +275,14 @@ ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
GetX509Ext(self, ext);
if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
- oid = ossl_to_der_if_possible(oid);
- StringValue(oid);
- p = (unsigned char *)RSTRING_PTR(oid);
- x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid));
- DATA_PTR(self) = ext;
- if(!x)
- ossl_raise(eX509ExtError, NULL);
- return self;
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = (unsigned char *)RSTRING_PTR(oid);
+ x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid));
+ DATA_PTR(self) = ext;
+ if(!x)
+ ossl_raise(eX509ExtError, NULL);
+ return self;
}
rb_funcall(self, rb_intern("oid="), 1, oid);
rb_funcall(self, rb_intern("value="), 1, value);
@@ -293,6 +291,7 @@ ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509ext_initialize_copy(VALUE self, VALUE other)
{
@@ -304,7 +303,7 @@ ossl_x509ext_initialize_copy(VALUE self, VALUE other)
ext_new = X509_EXTENSION_dup(ext_other);
if (!ext_new)
- ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
+ ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
SetX509Ext(self, ext_new);
X509_EXTENSION_free(ext);
@@ -321,10 +320,10 @@ ossl_x509ext_set_oid(VALUE self, VALUE oid)
GetX509Ext(self, ext);
obj = OBJ_txt2obj(StringValueCStr(oid), 0);
if (!obj)
- ossl_raise(eX509ExtError, "OBJ_txt2obj");
+ ossl_raise(eX509ExtError, "OBJ_txt2obj");
if (!X509_EXTENSION_set_object(ext, obj)) {
- ASN1_OBJECT_free(obj);
- ossl_raise(eX509ExtError, "X509_EXTENSION_set_object");
+ ASN1_OBJECT_free(obj);
+ ossl_raise(eX509ExtError, "X509_EXTENSION_set_object");
}
ASN1_OBJECT_free(obj);
@@ -340,12 +339,20 @@ ossl_x509ext_set_value(VALUE self, VALUE data)
GetX509Ext(self, ext);
data = ossl_to_der_if_possible(data);
StringValue(data);
- asn1s = X509_EXTENSION_get_data(ext);
+ asn1s = ASN1_OCTET_STRING_new();
+ if (!asn1s)
+ ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_new");
if (!ASN1_OCTET_STRING_set(asn1s, (unsigned char *)RSTRING_PTR(data),
- RSTRING_LENINT(data))) {
- ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set");
+ RSTRING_LENINT(data))) {
+ ASN1_OCTET_STRING_free(asn1s);
+ ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set");
+ }
+ if (!X509_EXTENSION_set_data(ext, asn1s)) {
+ ASN1_OCTET_STRING_free(asn1s);
+ ossl_raise(eX509ExtError, "X509_EXTENSION_set_data");
}
+ ASN1_OCTET_STRING_free(asn1s);
return data;
}
@@ -361,27 +368,20 @@ ossl_x509ext_set_critical(VALUE self, VALUE flag)
return flag;
}
+/*
+ * call-seq:
+ * ext.oid -> string
+ *
+ * Returns the OID of the extension. Returns the short name or the dotted
+ * decimal notation.
+ */
static VALUE
ossl_x509ext_get_oid(VALUE obj)
{
X509_EXTENSION *ext;
- ASN1_OBJECT *extobj;
- BIO *out;
- VALUE ret;
- int nid;
GetX509Ext(obj, ext);
- extobj = X509_EXTENSION_get_object(ext);
- if ((nid = OBJ_obj2nid(extobj)) != NID_undef)
- ret = rb_str_new2(OBJ_nid2sn(nid));
- else{
- if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509ExtError, NULL);
- i2a_ASN1_OBJECT(out, extobj);
- ret = ossl_membio2str(out);
- }
-
- return ret;
+ return ossl_asn1obj_to_string(X509_EXTENSION_get_object(ext));
}
static VALUE
@@ -393,9 +393,9 @@ ossl_x509ext_get_value(VALUE obj)
GetX509Ext(obj, ext);
if (!(out = BIO_new(BIO_s_mem())))
- ossl_raise(eX509ExtError, NULL);
+ ossl_raise(eX509ExtError, NULL);
if (!X509V3_EXT_print(out, ext, 0, 0))
- ASN1_STRING_print(out, (ASN1_STRING *)X509_EXTENSION_get_data(ext));
+ ASN1_STRING_print(out, X509_EXTENSION_get_data(ext));
ret = ossl_membio2str(out);
return ret;
@@ -405,13 +405,13 @@ static VALUE
ossl_x509ext_get_value_der(VALUE obj)
{
X509_EXTENSION *ext;
- ASN1_OCTET_STRING *value;
+ const ASN1_OCTET_STRING *value;
GetX509Ext(obj, ext);
if ((value = X509_EXTENSION_get_data(ext)) == NULL)
- ossl_raise(eX509ExtError, NULL);
+ ossl_raise(eX509ExtError, NULL);
- return rb_str_new((const char *)value->data, value->length);
+ return asn1str_to_str(value);
}
static VALUE
@@ -433,11 +433,11 @@ ossl_x509ext_to_der(VALUE obj)
GetX509Ext(obj, ext);
if((len = i2d_X509_EXTENSION(ext, NULL)) <= 0)
- ossl_raise(eX509ExtError, NULL);
+ ossl_raise(eX509ExtError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_X509_EXTENSION(ext, &p) < 0)
- ossl_raise(eX509ExtError, NULL);
+ ossl_raise(eX509ExtError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -450,12 +450,6 @@ void
Init_ossl_x509ext(void)
{
#undef rb_intern
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError);
cX509ExtFactory = rb_define_class_under(mX509, "ExtensionFactory", rb_cObject);
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index 13a2b2c030..eb97b23c02 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,27 +13,27 @@
TypedData_Wrap_Struct((klass), &ossl_x509name_type, 0)
#define SetX509Name(obj, name) do { \
if (!(name)) { \
- ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (name); \
} while (0)
#define GetX509Name(obj, name) do { \
TypedData_Get_Struct((obj), X509_NAME, &ossl_x509name_type, (name)); \
if (!(name)) { \
- ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
} \
} while (0)
#define OBJECT_TYPE_TEMPLATE \
- rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
+ rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
#define DEFAULT_OBJECT_TYPE \
- rb_const_get(cX509Name, rb_intern("DEFAULT_OBJECT_TYPE"))
+ rb_const_get(cX509Name, rb_intern("DEFAULT_OBJECT_TYPE"))
/*
* Classes
*/
-VALUE cX509Name;
-VALUE eX509NameError;
+static VALUE cX509Name;
+static VALUE eX509NameError;
static void
ossl_x509name_free(void *ptr)
@@ -44,29 +44,25 @@ ossl_x509name_free(void *ptr)
static const rb_data_type_t ossl_x509name_type = {
"OpenSSL/X509/NAME",
{
- 0, ossl_x509name_free,
+ 0, ossl_x509name_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* Public
*/
VALUE
-ossl_x509name_new(X509_NAME *name)
+ossl_x509name_new(const X509_NAME *name)
{
X509_NAME *new;
VALUE obj;
obj = NewX509Name(cX509Name);
- if (!name) {
- new = X509_NAME_new();
- } else {
- new = X509_NAME_dup(name);
- }
- if (!new) {
- ossl_raise(eX509NameError, NULL);
- }
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ new = X509_NAME_dup((X509_NAME *)name);
+ if (!new)
+ ossl_raise(eX509NameError, "X509_NAME_dup");
SetX509Name(obj, new);
return obj;
@@ -93,7 +89,7 @@ ossl_x509name_alloc(VALUE klass)
obj = NewX509Name(klass);
if (!(name = X509_NAME_new())) {
- ossl_raise(eX509NameError, NULL);
+ ossl_raise(eX509NameError, NULL);
}
SetX509Name(obj, name);
@@ -150,33 +146,34 @@ ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
GetX509Name(self, name);
if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) {
- return self;
+ return self;
}
else {
- VALUE tmp = rb_check_array_type(arg);
- if (!NIL_P(tmp)) {
- VALUE args;
- if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
- args = rb_ary_new3(2, self, template);
- rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args);
- }
- else{
- const unsigned char *p;
- VALUE str = ossl_to_der_if_possible(arg);
- X509_NAME *x;
- StringValue(str);
- p = (unsigned char *)RSTRING_PTR(str);
- x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str));
- DATA_PTR(self) = name;
- if(!x){
- ossl_raise(eX509NameError, NULL);
- }
- }
+ VALUE tmp = rb_check_array_type(arg);
+ if (!NIL_P(tmp)) {
+ VALUE args;
+ if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
+ args = rb_ary_new3(2, self, template);
+ rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args);
+ }
+ else{
+ const unsigned char *p;
+ VALUE str = ossl_to_der_if_possible(arg);
+ X509_NAME *x;
+ StringValue(str);
+ p = (unsigned char *)RSTRING_PTR(str);
+ x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str));
+ DATA_PTR(self) = name;
+ if(!x){
+ ossl_raise(eX509NameError, NULL);
+ }
+ }
}
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509name_initialize_copy(VALUE self, VALUE other)
{
@@ -188,7 +185,7 @@ ossl_x509name_initialize_copy(VALUE self, VALUE other)
name_new = X509_NAME_dup(name_other);
if (!name_new)
- ossl_raise(eX509NameError, "X509_NAME_dup");
+ ossl_raise(eX509NameError, "X509_NAME_dup");
SetX509Name(self, name_new);
X509_NAME_free(name);
@@ -225,8 +222,8 @@ VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
int loc = -1, set = 0;
if (!kwargs_ids[0]) {
- kwargs_ids[0] = rb_intern_const("loc");
- kwargs_ids[1] = rb_intern_const("set");
+ kwargs_ids[0] = rb_intern_const("loc");
+ kwargs_ids[1] = rb_intern_const("set");
}
rb_scan_args(argc, argv, "21:", &oid, &value, &type, &opts);
rb_get_kwargs(opts, kwargs_ids, 0, 2, kwargs);
@@ -234,14 +231,14 @@ VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
StringValue(value);
if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
if (kwargs[0] != Qundef)
- loc = NUM2INT(kwargs[0]);
+ loc = NUM2INT(kwargs[0]);
if (kwargs[1] != Qundef)
- set = NUM2INT(kwargs[1]);
+ set = NUM2INT(kwargs[1]);
GetX509Name(self, name);
if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
- (unsigned char *)RSTRING_PTR(value),
- RSTRING_LENINT(value), loc, set))
- ossl_raise(eX509NameError, "X509_NAME_add_entry_by_txt");
+ (unsigned char *)RSTRING_PTR(value),
+ RSTRING_LENINT(value), loc, set))
+ ossl_raise(eX509NameError, "X509_NAME_add_entry_by_txt");
return self;
}
@@ -254,7 +251,7 @@ ossl_x509name_to_s_old(VALUE self)
GetX509Name(self, name);
buf = X509_NAME_oneline(name, NULL, 0);
if (!buf)
- ossl_raise(eX509NameError, "X509_NAME_oneline");
+ ossl_raise(eX509NameError, "X509_NAME_oneline");
return ossl_buf2str(buf, rb_long2int(strlen(buf)));
}
@@ -268,11 +265,11 @@ x509name_print(VALUE self, unsigned long iflag)
GetX509Name(self, name);
out = BIO_new(BIO_s_mem());
if (!out)
- ossl_raise(eX509NameError, NULL);
+ ossl_raise(eX509NameError, NULL);
ret = X509_NAME_print_ex(out, name, 0, iflag);
if (ret < 0 || (iflag == XN_FLAG_COMPAT && ret == 0)) {
- BIO_free(out);
- ossl_raise(eX509NameError, "X509_NAME_print_ex");
+ BIO_free(out);
+ ossl_raise(eX509NameError, "X509_NAME_print_ex");
}
return ossl_membio2str(out);
}
@@ -306,9 +303,9 @@ ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
rb_check_arity(argc, 0, 1);
/* name.to_s(nil) was allowed */
if (!argc || NIL_P(argv[0]))
- return ossl_x509name_to_s_old(self);
+ return ossl_x509name_to_s_old(self);
else
- return x509name_print(self, NUM2ULONG(argv[0]));
+ return x509name_print(self, NUM2ULONG(argv[0]));
}
/*
@@ -331,7 +328,7 @@ static VALUE
ossl_x509name_inspect(VALUE self)
{
return rb_enc_sprintf(rb_utf8_encoding(), "#<%"PRIsVALUE" %"PRIsVALUE">",
- rb_obj_class(self), ossl_x509name_to_utf8(self));
+ rb_obj_class(self), ossl_x509name_to_utf8(self));
}
/*
@@ -345,38 +342,22 @@ static VALUE
ossl_x509name_to_a(VALUE self)
{
X509_NAME *name;
- X509_NAME_ENTRY *entry;
- int i,entries,nid;
- char long_name[512];
- const char *short_name;
- VALUE ary, vname, ret;
- ASN1_STRING *value;
+ int entries;
+ VALUE ret;
GetX509Name(self, name);
entries = X509_NAME_entry_count(name);
- if (entries < 0) {
- OSSL_Debug("name entries < 0!");
- return rb_ary_new();
- }
- ret = rb_ary_new2(entries);
- for (i=0; i<entries; i++) {
- if (!(entry = X509_NAME_get_entry(name, i))) {
- ossl_raise(eX509NameError, NULL);
- }
- if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name),
- X509_NAME_ENTRY_get_object(entry))) {
- ossl_raise(eX509NameError, NULL);
- }
- nid = OBJ_ln2nid(long_name);
- if (nid == NID_undef) {
- vname = rb_str_new2((const char *) &long_name);
- } else {
- short_name = OBJ_nid2sn(nid);
- vname = rb_str_new2(short_name); /*do not free*/
- }
- value = X509_NAME_ENTRY_get_data(entry);
- ary = rb_ary_new3(3, vname, asn1str_to_str(value), INT2NUM(value->type));
- rb_ary_push(ret, ary);
+ ret = rb_ary_new_capa(entries);
+ for (int i = 0; i < entries; i++) {
+ const X509_NAME_ENTRY *entry = X509_NAME_get_entry(name, i);
+ if (!entry)
+ ossl_raise(eX509NameError, "X509_NAME_get_entry");
+ const ASN1_OBJECT *obj = X509_NAME_ENTRY_get_object(entry);
+ VALUE vname = ossl_asn1obj_to_string(obj);
+ const ASN1_STRING *data = X509_NAME_ENTRY_get_data(entry);
+ VALUE vdata = asn1str_to_str(data);
+ VALUE type = INT2NUM(ASN1_STRING_type(data));
+ rb_ary_push(ret, rb_ary_new_from_args(3, vname, vdata, type));
}
return ret;
}
@@ -385,11 +366,17 @@ static int
ossl_x509name_cmp0(VALUE self, VALUE other)
{
X509_NAME *name1, *name2;
+ int result;
GetX509Name(self, name1);
GetX509Name(other, name2);
- return X509_NAME_cmp(name1, name2);
+ result = X509_NAME_cmp(name1, name2);
+ if (result == -2) {
+ ossl_raise(eX509NameError, NULL);
+ }
+
+ return result;
}
/*
@@ -407,7 +394,7 @@ ossl_x509name_cmp(VALUE self, VALUE other)
int result;
if (!rb_obj_is_kind_of(other, cX509Name))
- return Qnil;
+ return Qnil;
result = ossl_x509name_cmp0(self, other);
if (result < 0) return INT2FIX(-1);
@@ -426,7 +413,7 @@ static VALUE
ossl_x509name_eql(VALUE self, VALUE other)
{
if (!rb_obj_is_kind_of(other, cX509Name))
- return Qfalse;
+ return Qfalse;
return ossl_x509name_cmp0(self, other) == 0 ? Qtrue : Qfalse;
}
@@ -486,11 +473,11 @@ ossl_x509name_to_der(VALUE self)
GetX509Name(self, name);
if((len = i2d_X509_NAME(name, NULL)) <= 0)
- ossl_raise(eX509NameError, NULL);
+ ossl_raise(eX509NameError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_X509_NAME(name, &p) <= 0)
- ossl_raise(eX509NameError, NULL);
+ ossl_raise(eX509NameError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -516,12 +503,6 @@ Init_ossl_x509name(void)
#undef rb_intern
VALUE utf8str, ptrstr, ia5str, hash;
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
id_aref = rb_intern("[]");
eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError);
cX509Name = rb_define_class_under(mX509, "Name", rb_cObject);
@@ -560,6 +541,7 @@ Init_ossl_x509name(void)
rb_hash_aset(hash, rb_str_new2("DC"), ia5str);
rb_hash_aset(hash, rb_str_new2("domainComponent"), ia5str);
rb_hash_aset(hash, rb_str_new2("emailAddress"), ia5str);
+ rb_obj_freeze(hash);
/*
* The default object type template for name entries.
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 77a7d3f2ff..ad5dd08033 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,22 +13,22 @@
TypedData_Wrap_Struct((klass), &ossl_x509req_type, 0)
#define SetX509Req(obj, req) do { \
if (!(req)) { \
- ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (req); \
} while (0)
#define GetX509Req(obj, req) do { \
TypedData_Get_Struct((obj), X509_REQ, &ossl_x509req_type, (req)); \
if (!(req)) { \
- ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
} \
} while (0)
/*
* Classes
*/
-VALUE cX509Req;
-VALUE eX509ReqError;
+static VALUE cX509Req;
+static VALUE eX509ReqError;
static void
ossl_x509req_free(void *ptr)
@@ -39,9 +39,9 @@ ossl_x509req_free(void *ptr)
static const rb_data_type_t ossl_x509req_type = {
"OpenSSL/X509/REQ",
{
- 0, ossl_x509req_free,
+ 0, ossl_x509req_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -68,7 +68,7 @@ ossl_x509req_alloc(VALUE klass)
obj = NewX509Req(klass);
if (!(req = X509_REQ_new())) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
SetX509Req(obj, req);
@@ -84,7 +84,7 @@ ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
rb_check_frozen(self);
if (rb_scan_args(argc, argv, "01", &arg) == 0) {
- return self;
+ return self;
}
arg = ossl_to_der_if_possible(arg);
in = ossl_obj2bio(&arg);
@@ -103,6 +103,7 @@ ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509req_copy(VALUE self, VALUE other)
{
@@ -113,7 +114,7 @@ ossl_x509req_copy(VALUE self, VALUE other)
GetX509Req(self, a);
GetX509Req(other, b);
if (!(req = X509_REQ_dup(b))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
X509_REQ_free(a);
DATA_PTR(self) = req;
@@ -129,11 +130,11 @@ ossl_x509req_to_pem(VALUE self)
GetX509Req(self, req);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
if (!PEM_write_bio_X509_REQ(out, req)) {
- BIO_free(out);
- ossl_raise(eX509ReqError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
}
return ossl_membio2str(out);
@@ -149,11 +150,11 @@ ossl_x509req_to_der(VALUE self)
GetX509Req(self, req);
if ((len = i2d_X509_REQ(req, NULL)) <= 0)
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_X509_REQ(req, &p) <= 0)
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
ossl_str_adjust(str, p);
return str;
@@ -167,11 +168,11 @@ ossl_x509req_to_text(VALUE self)
GetX509Req(self, req);
if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
if (!X509_REQ_print(out, req)) {
- BIO_free(out);
- ossl_raise(eX509ReqError, NULL);
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
}
return ossl_membio2str(out);
@@ -190,7 +191,7 @@ ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
GetX509Req(self, req);
...
if (!(x509 = X509_REQ_to_X509(req, d, pkey))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
return ossl_x509_new(x509);
@@ -216,11 +217,11 @@ ossl_x509req_set_version(VALUE self, VALUE version)
long ver;
if ((ver = NUM2LONG(version)) < 0) {
- ossl_raise(eX509ReqError, "version must be >= 0!");
+ ossl_raise(eX509ReqError, "version must be >= 0!");
}
GetX509Req(self, req);
if (!X509_REQ_set_version(req, ver)) {
- ossl_raise(eX509ReqError, "X509_REQ_set_version");
+ ossl_raise(eX509ReqError, "X509_REQ_set_version");
}
return version;
@@ -230,11 +231,11 @@ static VALUE
ossl_x509req_get_subject(VALUE self)
{
X509_REQ *req;
- X509_NAME *name;
+ const X509_NAME *name;
GetX509Req(self, req);
if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
return ossl_x509name_new(name);
@@ -248,31 +249,32 @@ ossl_x509req_set_subject(VALUE self, VALUE subject)
GetX509Req(self, req);
/* DUPs name */
if (!X509_REQ_set_subject_name(req, GetX509NamePtr(subject))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
return subject;
}
+/*
+ * call-seq:
+ * req.signature_algorithm -> string
+ *
+ * Returns the signature algorithm used to sign this request.
+ *
+ * Returns the long name of the signature algorithm, or the dotted decimal
+ * notation if \OpenSSL does not define a long name for it.
+ */
static VALUE
ossl_x509req_get_signature_algorithm(VALUE self)
{
X509_REQ *req;
const X509_ALGOR *alg;
- BIO *out;
+ const ASN1_OBJECT *obj;
GetX509Req(self, req);
-
- if (!(out = BIO_new(BIO_s_mem()))) {
- ossl_raise(eX509ReqError, NULL);
- }
X509_REQ_get0_signature(req, NULL, &alg);
- if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
- BIO_free(out);
- ossl_raise(eX509ReqError, NULL);
- }
-
- return ossl_membio2str(out);
+ X509_ALGOR_get0(&obj, NULL, NULL, alg);
+ return ossl_asn1obj_to_string_long_name(obj);
}
static VALUE
@@ -283,10 +285,10 @@ ossl_x509req_get_public_key(VALUE self)
GetX509Req(self, req);
if (!(pkey = X509_REQ_get_pubkey(req))) { /* adds reference */
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
- return ossl_pkey_new(pkey); /* NO DUP - OK */
+ return ossl_pkey_wrap(pkey);
}
static VALUE
@@ -299,7 +301,7 @@ ossl_x509req_set_public_key(VALUE self, VALUE key)
pkey = GetPKeyPtr(key);
ossl_pkey_check_public_key(pkey);
if (!X509_REQ_set_pubkey(req, pkey))
- ossl_raise(eX509ReqError, "X509_REQ_set_pubkey");
+ ossl_raise(eX509ReqError, "X509_REQ_set_pubkey");
return key;
}
@@ -309,13 +311,14 @@ ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
X509_REQ *req;
EVP_PKEY *pkey;
const EVP_MD *md;
+ VALUE md_holder;
GetX509Req(self, req);
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
- md = ossl_evp_get_digestbyname(digest);
- if (!X509_REQ_sign(req, pkey, md)) {
- ossl_raise(eX509ReqError, NULL);
- }
+ /* NULL needed for some key types, e.g. Ed25519 */
+ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder);
+ if (!X509_REQ_sign(req, pkey, md))
+ ossl_raise(eX509ReqError, "X509_REQ_sign");
return self;
}
@@ -334,12 +337,12 @@ ossl_x509req_verify(VALUE self, VALUE key)
ossl_pkey_check_public_key(pkey);
switch (X509_REQ_verify(req, pkey)) {
case 1:
- return Qtrue;
+ return Qtrue;
case 0:
- ossl_clear_error();
- return Qfalse;
+ ossl_clear_error();
+ return Qfalse;
default:
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
}
@@ -348,20 +351,20 @@ ossl_x509req_get_attributes(VALUE self)
{
X509_REQ *req;
int count, i;
- X509_ATTRIBUTE *attr;
+ const X509_ATTRIBUTE *attr;
VALUE ary;
GetX509Req(self, req);
count = X509_REQ_get_attr_count(req);
if (count < 0) {
- OSSL_Debug("count < 0???");
- return rb_ary_new();
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
}
ary = rb_ary_new2(count);
for (i=0; i<count; i++) {
- attr = X509_REQ_get_attr(req, i);
- rb_ary_push(ary, ossl_x509attr_new(attr));
+ attr = X509_REQ_get_attr(req, i);
+ rb_ary_push(ary, ossl_x509attr_new(attr));
}
return ary;
@@ -377,17 +380,17 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
for (i=0;i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
+ OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Attr);
}
GetX509Req(self, req);
for (i = X509_REQ_get_attr_count(req); i > 0; i--)
X509_ATTRIBUTE_free(X509_REQ_delete_attr(req, 0));
for (i=0;i<RARRAY_LEN(ary); i++) {
- item = RARRAY_AREF(ary, i);
- attr = GetX509AttrPtr(item);
- if (!X509_REQ_add1_attr(req, attr)) {
- ossl_raise(eX509ReqError, "X509_REQ_add1_attr");
- }
+ item = RARRAY_AREF(ary, i);
+ attr = GetX509AttrPtr(item);
+ if (!X509_REQ_add1_attr(req, attr)) {
+ ossl_raise(eX509ReqError, "X509_REQ_add1_attr");
+ }
}
return ary;
}
@@ -399,7 +402,7 @@ ossl_x509req_add_attribute(VALUE self, VALUE attr)
GetX509Req(self, req);
if (!X509_REQ_add1_attr(req, GetX509AttrPtr(attr))) {
- ossl_raise(eX509ReqError, NULL);
+ ossl_raise(eX509ReqError, NULL);
}
return attr;
@@ -411,12 +414,6 @@ ossl_x509req_add_attribute(VALUE self, VALUE attr)
void
Init_ossl_x509req(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError);
cX509Req = rb_define_class_under(mX509, "Request", rb_cObject);
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index 10b8aa4ad6..0151961e9f 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,14 +13,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509rev_type, 0)
#define SetX509Rev(obj, rev) do { \
if (!(rev)) { \
- ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (rev); \
} while (0)
#define GetX509Rev(obj, rev) do { \
TypedData_Get_Struct((obj), X509_REVOKED, &ossl_x509rev_type, (rev)); \
if (!(rev)) { \
- ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
} \
} while (0)
@@ -28,7 +28,7 @@
* Classes
*/
VALUE cX509Rev;
-VALUE eX509RevError;
+static VALUE eX509RevError;
static void
ossl_x509rev_free(void *ptr)
@@ -39,29 +39,25 @@ ossl_x509rev_free(void *ptr)
static const rb_data_type_t ossl_x509rev_type = {
"OpenSSL/X509/REV",
{
- 0, ossl_x509rev_free,
+ 0, ossl_x509rev_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
* PUBLIC
*/
VALUE
-ossl_x509revoked_new(X509_REVOKED *rev)
+ossl_x509revoked_new(const X509_REVOKED *rev)
{
X509_REVOKED *new;
VALUE obj;
obj = NewX509Rev(cX509Rev);
- if (!rev) {
- new = X509_REVOKED_new();
- } else {
- new = X509_REVOKED_dup(rev);
- }
- if (!new) {
- ossl_raise(eX509RevError, NULL);
- }
+ /* OpenSSL 1.1.1 takes a non-const pointer */
+ new = X509_REVOKED_dup((X509_REVOKED *)rev);
+ if (!new)
+ ossl_raise(eX509RevError, "X509_REVOKED_dup");
SetX509Rev(obj, new);
return obj;
@@ -74,7 +70,7 @@ DupX509RevokedPtr(VALUE obj)
GetX509Rev(obj, rev);
if (!(new = X509_REVOKED_dup(rev))) {
- ossl_raise(eX509RevError, NULL);
+ ossl_raise(eX509RevError, NULL);
}
return new;
@@ -91,7 +87,7 @@ ossl_x509revoked_alloc(VALUE klass)
obj = NewX509Rev(klass);
if (!(rev = X509_REVOKED_new())) {
- ossl_raise(eX509RevError, NULL);
+ ossl_raise(eX509RevError, NULL);
}
SetX509Rev(obj, rev);
@@ -105,6 +101,7 @@ ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+/* :nodoc: */
static VALUE
ossl_x509revoked_initialize_copy(VALUE self, VALUE other)
{
@@ -116,7 +113,7 @@ ossl_x509revoked_initialize_copy(VALUE self, VALUE other)
rev_new = X509_REVOKED_dup(rev_other);
if (!rev_new)
- ossl_raise(eX509RevError, "X509_REVOKED_dup");
+ ossl_raise(eX509RevError, "X509_REVOKED_dup");
SetX509Rev(self, rev_new);
X509_REVOKED_free(rev);
@@ -143,8 +140,8 @@ ossl_x509revoked_set_serial(VALUE self, VALUE num)
GetX509Rev(self, rev);
asn1int = num_to_asn1integer(num, NULL);
if (!X509_REVOKED_set_serialNumber(rev, asn1int)) {
- ASN1_INTEGER_free(asn1int);
- ossl_raise(eX509RevError, "X509_REVOKED_set_serialNumber");
+ ASN1_INTEGER_free(asn1int);
+ ossl_raise(eX509RevError, "X509_REVOKED_set_serialNumber");
}
ASN1_INTEGER_free(asn1int);
@@ -160,7 +157,7 @@ ossl_x509revoked_get_time(VALUE self)
GetX509Rev(self, rev);
time = X509_REVOKED_get0_revocationDate(rev);
if (!time)
- return Qnil;
+ return Qnil;
return asn1time_to_time(time);
}
@@ -174,8 +171,8 @@ ossl_x509revoked_set_time(VALUE self, VALUE time)
GetX509Rev(self, rev);
asn1time = ossl_x509_time_adjust(NULL, time);
if (!X509_REVOKED_set_revocationDate(rev, asn1time)) {
- ASN1_TIME_free(asn1time);
- ossl_raise(eX509RevError, "X509_REVOKED_set_revocationDate");
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509RevError, "X509_REVOKED_set_revocationDate");
}
ASN1_TIME_free(asn1time);
@@ -189,19 +186,15 @@ ossl_x509revoked_get_extensions(VALUE self)
{
X509_REVOKED *rev;
int count, i;
- X509_EXTENSION *ext;
+ const X509_EXTENSION *ext;
VALUE ary;
GetX509Rev(self, rev);
count = X509_REVOKED_get_ext_count(rev);
- if (count < 0) {
- OSSL_Debug("count < 0???");
- return rb_ary_new();
- }
- ary = rb_ary_new2(count);
+ ary = rb_ary_new_capa(count);
for (i=0; i<count; i++) {
- ext = X509_REVOKED_get_ext(rev, i);
- rb_ary_push(ary, ossl_x509ext_new(ext));
+ ext = X509_REVOKED_get_ext(rev, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext));
}
return ary;
@@ -220,17 +213,17 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
for (i=0; i<RARRAY_LEN(ary); i++) {
- OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
+ OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
}
GetX509Rev(self, rev);
for (i = X509_REVOKED_get_ext_count(rev); i > 0; i--)
X509_EXTENSION_free(X509_REVOKED_delete_ext(rev, 0));
for (i=0; i<RARRAY_LEN(ary); i++) {
- item = RARRAY_AREF(ary, i);
- ext = GetX509ExtPtr(item);
- if(!X509_REVOKED_add_ext(rev, ext, -1)) {
- ossl_raise(eX509RevError, "X509_REVOKED_add_ext");
- }
+ item = RARRAY_AREF(ary, i);
+ ext = GetX509ExtPtr(item);
+ if(!X509_REVOKED_add_ext(rev, ext, -1)) {
+ ossl_raise(eX509RevError, "X509_REVOKED_add_ext");
+ }
}
return ary;
@@ -243,7 +236,7 @@ ossl_x509revoked_add_extension(VALUE self, VALUE ext)
GetX509Rev(self, rev);
if (!X509_REVOKED_add_ext(rev, GetX509ExtPtr(ext), -1)) {
- ossl_raise(eX509RevError, NULL);
+ ossl_raise(eX509RevError, NULL);
}
return ext;
@@ -260,11 +253,11 @@ ossl_x509revoked_to_der(VALUE self)
GetX509Rev(self, rev);
len = i2d_X509_REVOKED(rev, NULL);
if (len <= 0)
- ossl_raise(eX509RevError, "i2d_X509_REVOKED");
+ ossl_raise(eX509RevError, "i2d_X509_REVOKED");
str = rb_str_new(NULL, len);
p = (unsigned char *)RSTRING_PTR(str);
if (i2d_X509_REVOKED(rev, &p) <= 0)
- ossl_raise(eX509RevError, "i2d_X509_REVOKED");
+ ossl_raise(eX509RevError, "i2d_X509_REVOKED");
ossl_str_adjust(str, p);
return str;
}
@@ -275,12 +268,6 @@ ossl_x509revoked_to_der(VALUE self)
void
Init_ossl_x509revoked(void)
{
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
eX509RevError = rb_define_class_under(mX509, "RevokedError", eOSSLError);
cX509Rev = rb_define_class_under(mX509, "Revoked", rb_cObject);
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 7c546187c3..9e43336c44 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -5,7 +5,7 @@
*/
/*
* This program is licensed under the same licence as Ruby.
- * (See the file 'LICENCE'.)
+ * (See the file 'COPYING'.)
*/
#include "ossl.h"
@@ -13,14 +13,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509store_type, 0)
#define SetX509Store(obj, st) do { \
if (!(st)) { \
- ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (st); \
} while (0)
#define GetX509Store(obj, st) do { \
TypedData_Get_Struct((obj), X509_STORE, &ossl_x509store_type, (st)); \
if (!(st)) { \
- ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
} \
} while (0)
@@ -28,14 +28,14 @@
TypedData_Wrap_Struct((klass), &ossl_x509stctx_type, 0)
#define SetX509StCtx(obj, ctx) do { \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (ctx); \
} while (0)
#define GetX509StCtx(obj, ctx) do { \
TypedData_Get_Struct((obj), X509_STORE_CTX, &ossl_x509stctx_type, (ctx)); \
if (!(ctx)) { \
- ossl_raise(rb_eRuntimeError, "STORE_CTX is out of scope!"); \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX is out of scope!"); \
} \
} while (0)
@@ -62,7 +62,7 @@ call_verify_cb_proc(VALUE arg)
{
struct ossl_verify_cb_args *args = (struct ossl_verify_cb_args *)arg;
return rb_funcall(args->proc, rb_intern("call"), 2,
- args->preverify_ok, args->store_ctx);
+ args->preverify_ok, args->store_ctx);
}
int
@@ -73,33 +73,33 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
int state;
if (NIL_P(proc))
- return ok;
+ return ok;
ret = Qfalse;
rctx = rb_protect(ossl_x509stctx_new_i, (VALUE)ctx, &state);
if (state) {
- rb_set_errinfo(Qnil);
- rb_warn("StoreContext initialization failure");
+ rb_set_errinfo(Qnil);
+ rb_warn("StoreContext initialization failure");
}
else {
- args.proc = proc;
- args.preverify_ok = ok ? Qtrue : Qfalse;
- args.store_ctx = rctx;
- ret = rb_protect(call_verify_cb_proc, (VALUE)&args, &state);
- if (state) {
- rb_set_errinfo(Qnil);
- rb_warn("exception in verify_callback is ignored");
- }
- RTYPEDDATA_DATA(rctx) = NULL;
+ args.proc = proc;
+ args.preverify_ok = ok ? Qtrue : Qfalse;
+ args.store_ctx = rctx;
+ ret = rb_protect(call_verify_cb_proc, (VALUE)&args, &state);
+ if (state) {
+ rb_set_errinfo(Qnil);
+ rb_warn("exception in verify_callback is ignored");
+ }
+ RTYPEDDATA_DATA(rctx) = NULL;
}
if (ret == Qtrue) {
- X509_STORE_CTX_set_error(ctx, X509_V_OK);
- ok = 1;
+ X509_STORE_CTX_set_error(ctx, X509_V_OK);
+ ok = 1;
}
else {
- if (X509_STORE_CTX_get_error(ctx) == X509_V_OK)
- X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
- ok = 0;
+ if (X509_STORE_CTX_get_error(ctx) == X509_V_OK)
+ X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
+ ok = 0;
}
return ok;
@@ -108,14 +108,17 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
/*
* Classes
*/
-VALUE cX509Store;
-VALUE cX509StoreContext;
-VALUE eX509StoreError;
+static VALUE cX509Store;
+static VALUE cX509StoreContext;
+static VALUE eX509StoreError;
static void
ossl_x509store_mark(void *ptr)
{
X509_STORE *store = ptr;
+ // Note: this reference is stored as @verify_callback so we don't need to mark it.
+ // However we do need to ensure GC compaction won't move it, hence why
+ // we call rb_gc_mark here.
rb_gc_mark((VALUE)X509_STORE_get_ex_data(store, store_ex_verify_cb_idx));
}
@@ -130,7 +133,7 @@ static const rb_data_type_t ossl_x509store_type = {
{
ossl_x509store_mark, ossl_x509store_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -156,10 +159,10 @@ x509store_verify_cb(int ok, X509_STORE_CTX *ctx)
proc = (VALUE)X509_STORE_CTX_get_ex_data(ctx, stctx_ex_verify_cb_idx);
if (!proc)
- proc = (VALUE)X509_STORE_get_ex_data(X509_STORE_CTX_get0_store(ctx),
- store_ex_verify_cb_idx);
+ proc = (VALUE)X509_STORE_get_ex_data(X509_STORE_CTX_get0_store(ctx),
+ store_ex_verify_cb_idx);
if (!proc)
- return ok;
+ return ok;
return ossl_verify_cb_call(proc, ok, ctx);
}
@@ -187,8 +190,10 @@ ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
X509_STORE *store;
GetX509Store(self, store);
- X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb);
+ if (!X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb))
+ ossl_raise(eX509StoreError, "X509_STORE_set_ex_data");
rb_iv_set(self, "@verify_callback", cb);
+ RB_OBJ_WRITTEN(self, Qundef, cb);
return cb;
}
@@ -208,10 +213,6 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
GetX509Store(self, store);
if (argc != 0)
rb_warn("OpenSSL::X509::Store.new does not take any arguments");
-#if !defined(HAVE_OPAQUE_OPENSSL)
- /* [Bug #405] [Bug #1678] [Bug #3000]; already fixed? */
- store->ex_data.sk = NULL;
-#endif
X509_STORE_set_verify_cb(store, x509store_verify_cb);
ossl_x509store_set_vfy_cb(self, Qnil);
@@ -219,7 +220,6 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
rb_iv_set(self, "@error", Qnil);
rb_iv_set(self, "@error_string", Qnil);
rb_iv_set(self, "@chain", Qnil);
- rb_iv_set(self, "@time", Qnil);
return self;
}
@@ -325,7 +325,12 @@ ossl_x509store_set_trust(VALUE self, VALUE trust)
static VALUE
ossl_x509store_set_time(VALUE self, VALUE time)
{
- rb_iv_set(self, "@time", time);
+ X509_STORE *store;
+ X509_VERIFY_PARAM *param;
+
+ GetX509Store(self, store);
+ param = X509_STORE_get0_param(store);
+ X509_VERIFY_PARAM_set_time(param, NUM2LONG(rb_Integer(time)));
return time;
}
@@ -353,15 +358,6 @@ ossl_x509store_add_file(VALUE self, VALUE file)
ossl_raise(eX509StoreError, "X509_STORE_add_lookup");
if (X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1)
ossl_raise(eX509StoreError, "X509_LOOKUP_load_file");
-#if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER)
- /*
- * X509_load_cert_crl_file() which is called from X509_LOOKUP_load_file()
- * did not check the return value of X509_STORE_add_{cert,crl}(), leaking
- * "cert already in hash table" errors on the error queue, if duplicate
- * certificates are found. This will be fixed by OpenSSL 1.1.1.
- */
- ossl_clear_error();
-#endif
return self;
}
@@ -489,7 +485,7 @@ ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "11", &cert, &chain);
ctx = rb_funcall(cX509StoreContext, rb_intern("new"), 3, self, cert, chain);
proc = rb_block_given_p() ? rb_block_proc() :
- rb_iv_get(self, "@verify_callback");
+ rb_iv_get(self, "@verify_callback");
rb_iv_set(ctx, "@verify_callback", proc);
result = rb_funcall(ctx, rb_intern("verify"), 0);
@@ -507,6 +503,9 @@ static void
ossl_x509stctx_mark(void *ptr)
{
X509_STORE_CTX *ctx = ptr;
+ // Note: this reference is stored as @verify_callback so we don't need to mark it.
+ // However we do need to ensure GC compaction won't move it, hence why
+ // we call rb_gc_mark here.
rb_gc_mark((VALUE)X509_STORE_CTX_get_ex_data(ctx, stctx_ex_verify_cb_idx));
}
@@ -514,10 +513,8 @@ static void
ossl_x509stctx_free(void *ptr)
{
X509_STORE_CTX *ctx = ptr;
- if (X509_STORE_CTX_get0_untrusted(ctx))
- sk_X509_pop_free(X509_STORE_CTX_get0_untrusted(ctx), X509_free);
- if (X509_STORE_CTX_get0_cert(ctx))
- X509_free(X509_STORE_CTX_get0_cert(ctx));
+ sk_X509_pop_free(X509_STORE_CTX_get0_untrusted(ctx), X509_free);
+ X509_free((X509 *)X509_STORE_CTX_get0_cert(ctx));
X509_STORE_CTX_free(ctx);
}
@@ -526,7 +523,7 @@ static const rb_data_type_t ossl_x509stctx_type = {
{
ossl_x509stctx_mark, ossl_x509stctx_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -557,7 +554,6 @@ ossl_x509stctx_new(X509_STORE_CTX *ctx)
static VALUE ossl_x509stctx_set_flags(VALUE, VALUE);
static VALUE ossl_x509stctx_set_purpose(VALUE, VALUE);
static VALUE ossl_x509stctx_set_trust(VALUE, VALUE);
-static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
/*
* call-seq:
@@ -568,7 +564,7 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
static VALUE
ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
{
- VALUE store, cert, chain, t;
+ VALUE store, cert, chain;
X509_STORE_CTX *ctx;
X509_STORE *x509st;
X509 *x509 = NULL;
@@ -592,8 +588,6 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
sk_X509_pop_free(x509s, X509_free);
ossl_raise(eX509StoreError, "X509_STORE_CTX_init");
}
- if (!NIL_P(t = rb_iv_get(store, "@time")))
- ossl_x509stctx_set_time(self, t);
rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback"));
rb_iv_set(self, "@cert", cert);
@@ -614,8 +608,10 @@ ossl_x509stctx_verify(VALUE self)
X509_STORE_CTX *ctx;
GetX509StCtx(self, ctx);
- X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx,
- (void *)rb_iv_get(self, "@verify_callback"));
+ VALUE cb = rb_iv_get(self, "@verify_callback");
+ if (!X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx, (void *)cb))
+ ossl_raise(eX509StoreError, "X509_STORE_CTX_set_ex_data");
+ RB_OBJ_WRITTEN(self, Qundef, cb);
switch (X509_verify_cert(ctx)) {
case 1:
@@ -624,7 +620,7 @@ ossl_x509stctx_verify(VALUE self)
ossl_clear_error();
return Qfalse;
default:
- ossl_raise(eX509CertError, "X509_verify_cert");
+ ossl_raise(eX509StoreError, "X509_verify_cert");
}
}
@@ -740,10 +736,14 @@ static VALUE
ossl_x509stctx_get_curr_cert(VALUE self)
{
X509_STORE_CTX *ctx;
+ const X509 *x509;
GetX509StCtx(self, ctx);
+ x509 = X509_STORE_CTX_get_current_cert(ctx);
+ if (!x509)
+ return Qnil;
- return ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx));
+ return ossl_x509_new(x509);
}
/*
@@ -758,12 +758,12 @@ static VALUE
ossl_x509stctx_get_curr_crl(VALUE self)
{
X509_STORE_CTX *ctx;
- X509_CRL *crl;
+ const X509_CRL *crl;
GetX509StCtx(self, ctx);
crl = X509_STORE_CTX_get0_current_crl(ctx);
if (!crl)
- return Qnil;
+ return Qnil;
return ossl_x509crl_new(crl);
}
@@ -859,19 +859,13 @@ void
Init_ossl_x509store(void)
{
#undef rb_intern
-#if 0
- mOSSL = rb_define_module("OpenSSL");
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
- mX509 = rb_define_module_under(mOSSL, "X509");
-#endif
-
/* Register ext_data slot for verify callback Proc */
stctx_ex_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, (void *)"stctx_ex_verify_cb_idx", 0, 0, 0);
if (stctx_ex_verify_cb_idx < 0)
- ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index");
+ ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index");
store_ex_verify_cb_idx = X509_STORE_get_ex_new_index(0, (void *)"store_ex_verify_cb_idx", 0, 0, 0);
if (store_ex_verify_cb_idx < 0)
- ossl_raise(eOSSLError, "X509_STORE_get_ex_new_index");
+ ossl_raise(eOSSLError, "X509_STORE_get_ex_new_index");
eX509StoreError = rb_define_class_under(mX509, "StoreError", eOSSLError);
diff --git a/ext/pathname/depend b/ext/pathname/depend
deleted file mode 100644
index 5dd8b042de..0000000000
--- a/ext/pathname/depend
+++ /dev/null
@@ -1,173 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-pathname.o: $(RUBY_EXTCONF_H)
-pathname.o: $(arch_hdrdir)/ruby/config.h
-pathname.o: $(hdrdir)/ruby.h
-pathname.o: $(hdrdir)/ruby/assert.h
-pathname.o: $(hdrdir)/ruby/backward.h
-pathname.o: $(hdrdir)/ruby/backward/2/assume.h
-pathname.o: $(hdrdir)/ruby/backward/2/attributes.h
-pathname.o: $(hdrdir)/ruby/backward/2/bool.h
-pathname.o: $(hdrdir)/ruby/backward/2/inttypes.h
-pathname.o: $(hdrdir)/ruby/backward/2/limits.h
-pathname.o: $(hdrdir)/ruby/backward/2/long_long.h
-pathname.o: $(hdrdir)/ruby/backward/2/stdalign.h
-pathname.o: $(hdrdir)/ruby/backward/2/stdarg.h
-pathname.o: $(hdrdir)/ruby/defines.h
-pathname.o: $(hdrdir)/ruby/encoding.h
-pathname.o: $(hdrdir)/ruby/intern.h
-pathname.o: $(hdrdir)/ruby/internal/abi.h
-pathname.o: $(hdrdir)/ruby/internal/anyargs.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-pathname.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-pathname.o: $(hdrdir)/ruby/internal/assume.h
-pathname.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-pathname.o: $(hdrdir)/ruby/internal/attr/artificial.h
-pathname.o: $(hdrdir)/ruby/internal/attr/cold.h
-pathname.o: $(hdrdir)/ruby/internal/attr/const.h
-pathname.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-pathname.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-pathname.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-pathname.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-pathname.o: $(hdrdir)/ruby/internal/attr/error.h
-pathname.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-pathname.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-pathname.o: $(hdrdir)/ruby/internal/attr/format.h
-pathname.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-pathname.o: $(hdrdir)/ruby/internal/attr/noalias.h
-pathname.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-pathname.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-pathname.o: $(hdrdir)/ruby/internal/attr/noinline.h
-pathname.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-pathname.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-pathname.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-pathname.o: $(hdrdir)/ruby/internal/attr/pure.h
-pathname.o: $(hdrdir)/ruby/internal/attr/restrict.h
-pathname.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-pathname.o: $(hdrdir)/ruby/internal/attr/warning.h
-pathname.o: $(hdrdir)/ruby/internal/attr/weakref.h
-pathname.o: $(hdrdir)/ruby/internal/cast.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-pathname.o: $(hdrdir)/ruby/internal/compiler_since.h
-pathname.o: $(hdrdir)/ruby/internal/config.h
-pathname.o: $(hdrdir)/ruby/internal/constant_p.h
-pathname.o: $(hdrdir)/ruby/internal/core.h
-pathname.o: $(hdrdir)/ruby/internal/core/rarray.h
-pathname.o: $(hdrdir)/ruby/internal/core/rbasic.h
-pathname.o: $(hdrdir)/ruby/internal/core/rbignum.h
-pathname.o: $(hdrdir)/ruby/internal/core/rclass.h
-pathname.o: $(hdrdir)/ruby/internal/core/rdata.h
-pathname.o: $(hdrdir)/ruby/internal/core/rfile.h
-pathname.o: $(hdrdir)/ruby/internal/core/rhash.h
-pathname.o: $(hdrdir)/ruby/internal/core/robject.h
-pathname.o: $(hdrdir)/ruby/internal/core/rregexp.h
-pathname.o: $(hdrdir)/ruby/internal/core/rstring.h
-pathname.o: $(hdrdir)/ruby/internal/core/rstruct.h
-pathname.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-pathname.o: $(hdrdir)/ruby/internal/ctype.h
-pathname.o: $(hdrdir)/ruby/internal/dllexport.h
-pathname.o: $(hdrdir)/ruby/internal/dosish.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/re.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/string.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-pathname.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-pathname.o: $(hdrdir)/ruby/internal/error.h
-pathname.o: $(hdrdir)/ruby/internal/eval.h
-pathname.o: $(hdrdir)/ruby/internal/event.h
-pathname.o: $(hdrdir)/ruby/internal/fl_type.h
-pathname.o: $(hdrdir)/ruby/internal/gc.h
-pathname.o: $(hdrdir)/ruby/internal/glob.h
-pathname.o: $(hdrdir)/ruby/internal/globals.h
-pathname.o: $(hdrdir)/ruby/internal/has/attribute.h
-pathname.o: $(hdrdir)/ruby/internal/has/builtin.h
-pathname.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-pathname.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-pathname.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-pathname.o: $(hdrdir)/ruby/internal/has/extension.h
-pathname.o: $(hdrdir)/ruby/internal/has/feature.h
-pathname.o: $(hdrdir)/ruby/internal/has/warning.h
-pathname.o: $(hdrdir)/ruby/internal/intern/array.h
-pathname.o: $(hdrdir)/ruby/internal/intern/bignum.h
-pathname.o: $(hdrdir)/ruby/internal/intern/class.h
-pathname.o: $(hdrdir)/ruby/internal/intern/compar.h
-pathname.o: $(hdrdir)/ruby/internal/intern/complex.h
-pathname.o: $(hdrdir)/ruby/internal/intern/cont.h
-pathname.o: $(hdrdir)/ruby/internal/intern/dir.h
-pathname.o: $(hdrdir)/ruby/internal/intern/enum.h
-pathname.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-pathname.o: $(hdrdir)/ruby/internal/intern/error.h
-pathname.o: $(hdrdir)/ruby/internal/intern/eval.h
-pathname.o: $(hdrdir)/ruby/internal/intern/file.h
-pathname.o: $(hdrdir)/ruby/internal/intern/hash.h
-pathname.o: $(hdrdir)/ruby/internal/intern/io.h
-pathname.o: $(hdrdir)/ruby/internal/intern/load.h
-pathname.o: $(hdrdir)/ruby/internal/intern/marshal.h
-pathname.o: $(hdrdir)/ruby/internal/intern/numeric.h
-pathname.o: $(hdrdir)/ruby/internal/intern/object.h
-pathname.o: $(hdrdir)/ruby/internal/intern/parse.h
-pathname.o: $(hdrdir)/ruby/internal/intern/proc.h
-pathname.o: $(hdrdir)/ruby/internal/intern/process.h
-pathname.o: $(hdrdir)/ruby/internal/intern/random.h
-pathname.o: $(hdrdir)/ruby/internal/intern/range.h
-pathname.o: $(hdrdir)/ruby/internal/intern/rational.h
-pathname.o: $(hdrdir)/ruby/internal/intern/re.h
-pathname.o: $(hdrdir)/ruby/internal/intern/ruby.h
-pathname.o: $(hdrdir)/ruby/internal/intern/select.h
-pathname.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-pathname.o: $(hdrdir)/ruby/internal/intern/signal.h
-pathname.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-pathname.o: $(hdrdir)/ruby/internal/intern/string.h
-pathname.o: $(hdrdir)/ruby/internal/intern/struct.h
-pathname.o: $(hdrdir)/ruby/internal/intern/thread.h
-pathname.o: $(hdrdir)/ruby/internal/intern/time.h
-pathname.o: $(hdrdir)/ruby/internal/intern/variable.h
-pathname.o: $(hdrdir)/ruby/internal/intern/vm.h
-pathname.o: $(hdrdir)/ruby/internal/interpreter.h
-pathname.o: $(hdrdir)/ruby/internal/iterator.h
-pathname.o: $(hdrdir)/ruby/internal/memory.h
-pathname.o: $(hdrdir)/ruby/internal/method.h
-pathname.o: $(hdrdir)/ruby/internal/module.h
-pathname.o: $(hdrdir)/ruby/internal/newobj.h
-pathname.o: $(hdrdir)/ruby/internal/scan_args.h
-pathname.o: $(hdrdir)/ruby/internal/special_consts.h
-pathname.o: $(hdrdir)/ruby/internal/static_assert.h
-pathname.o: $(hdrdir)/ruby/internal/stdalign.h
-pathname.o: $(hdrdir)/ruby/internal/stdbool.h
-pathname.o: $(hdrdir)/ruby/internal/symbol.h
-pathname.o: $(hdrdir)/ruby/internal/value.h
-pathname.o: $(hdrdir)/ruby/internal/value_type.h
-pathname.o: $(hdrdir)/ruby/internal/variable.h
-pathname.o: $(hdrdir)/ruby/internal/warning_push.h
-pathname.o: $(hdrdir)/ruby/internal/xmalloc.h
-pathname.o: $(hdrdir)/ruby/missing.h
-pathname.o: $(hdrdir)/ruby/onigmo.h
-pathname.o: $(hdrdir)/ruby/oniguruma.h
-pathname.o: $(hdrdir)/ruby/ruby.h
-pathname.o: $(hdrdir)/ruby/st.h
-pathname.o: $(hdrdir)/ruby/subst.h
-pathname.o: pathname.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/pathname/extconf.rb b/ext/pathname/extconf.rb
deleted file mode 100644
index 84e68277aa..0000000000
--- a/ext/pathname/extconf.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: false
-require 'mkmf'
-have_func("rb_file_s_birthtime")
-create_makefile('pathname')
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
deleted file mode 100644
index 7bdfd0eb39..0000000000
--- a/ext/pathname/lib/pathname.rb
+++ /dev/null
@@ -1,604 +0,0 @@
-# frozen_string_literal: true
-#
-# = pathname.rb
-#
-# Object-Oriented Pathname Class
-#
-# Author:: Tanaka Akira <akr@m17n.org>
-# Documentation:: Author and Gavin Sinclair
-#
-# For documentation, see class Pathname.
-#
-
-require 'pathname.so'
-
-class Pathname
-
- # :stopdoc:
-
- # to_path is implemented so Pathname objects are usable with File.open, etc.
- TO_PATH = :to_path
-
- SAME_PATHS = if File::FNM_SYSCASE.nonzero?
- # Avoid #zero? here because #casecmp can return nil.
- proc {|a, b| a.casecmp(b) == 0}
- else
- proc {|a, b| a == b}
- end
-
-
- if File::ALT_SEPARATOR
- SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}"
- SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
- else
- SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}"
- SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
- end
-
- if File.dirname('A:') == 'A:.' # DOSish drive letter
- ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/o
- else
- ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/o
- end
- private_constant :ABSOLUTE_PATH
-
- # :startdoc:
-
- # chop_basename(path) -> [pre-basename, basename] or nil
- def chop_basename(path) # :nodoc:
- base = File.basename(path)
- if /\A#{SEPARATOR_PAT}?\z/o.match?(base)
- return nil
- else
- return path[0, path.rindex(base)], base
- end
- end
- private :chop_basename
-
- # split_names(path) -> prefix, [name, ...]
- def split_names(path) # :nodoc:
- names = []
- while r = chop_basename(path)
- path, basename = r
- names.unshift basename
- end
- return path, names
- end
- private :split_names
-
- def prepend_prefix(prefix, relpath) # :nodoc:
- if relpath.empty?
- File.dirname(prefix)
- elsif /#{SEPARATOR_PAT}/o.match?(prefix)
- prefix = File.dirname(prefix)
- prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
- prefix + relpath
- else
- prefix + relpath
- end
- end
- private :prepend_prefix
-
- # Returns clean pathname of +self+ with consecutive slashes and useless dots
- # removed. The filesystem is not accessed.
- #
- # If +consider_symlink+ is +true+, then a more conservative algorithm is used
- # to avoid breaking symbolic linkages. This may retain more +..+
- # entries than absolutely necessary, but without accessing the filesystem,
- # this can't be avoided.
- #
- # See Pathname#realpath.
- #
- def cleanpath(consider_symlink=false)
- if consider_symlink
- cleanpath_conservative
- else
- cleanpath_aggressive
- end
- end
-
- #
- # Clean the path simply by resolving and removing excess +.+ and +..+ entries.
- # Nothing more, nothing less.
- #
- def cleanpath_aggressive # :nodoc:
- path = @path
- names = []
- pre = path
- while r = chop_basename(pre)
- pre, base = r
- case base
- when '.'
- when '..'
- names.unshift base
- else
- if names[0] == '..'
- names.shift
- else
- names.unshift base
- end
- end
- end
- pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
- names.shift while names[0] == '..'
- end
- self.class.new(prepend_prefix(pre, File.join(*names)))
- end
- private :cleanpath_aggressive
-
- # has_trailing_separator?(path) -> bool
- def has_trailing_separator?(path) # :nodoc:
- if r = chop_basename(path)
- pre, basename = r
- pre.length + basename.length < path.length
- else
- false
- end
- end
- private :has_trailing_separator?
-
- # add_trailing_separator(path) -> path
- def add_trailing_separator(path) # :nodoc:
- if File.basename(path + 'a') == 'a'
- path
- else
- File.join(path, "") # xxx: Is File.join is appropriate to add separator?
- end
- end
- private :add_trailing_separator
-
- def del_trailing_separator(path) # :nodoc:
- if r = chop_basename(path)
- pre, basename = r
- pre + basename
- elsif /#{SEPARATOR_PAT}+\z/o =~ path
- $` + File.dirname(path)[/#{SEPARATOR_PAT}*\z/o]
- else
- path
- end
- end
- private :del_trailing_separator
-
- def cleanpath_conservative # :nodoc:
- path = @path
- names = []
- pre = path
- while r = chop_basename(pre)
- pre, base = r
- names.unshift base if base != '.'
- end
- pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
- names.shift while names[0] == '..'
- end
- if names.empty?
- self.class.new(File.dirname(pre))
- else
- if names.last != '..' && File.basename(path) == '.'
- names << '.'
- end
- result = prepend_prefix(pre, File.join(*names))
- if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
- self.class.new(add_trailing_separator(result))
- else
- self.class.new(result)
- end
- end
- end
- private :cleanpath_conservative
-
- # Returns the parent directory.
- #
- # This is same as <code>self + '..'</code>.
- def parent
- self + '..'
- end
-
- # Returns +true+ if +self+ points to a mountpoint.
- def mountpoint?
- begin
- stat1 = self.lstat
- stat2 = self.parent.lstat
- stat1.dev != stat2.dev || stat1.ino == stat2.ino
- rescue Errno::ENOENT
- false
- end
- end
-
- #
- # Predicate method for root directories. Returns +true+ if the
- # pathname consists of consecutive slashes.
- #
- # It doesn't access the filesystem. So it may return +false+ for some
- # pathnames which points to roots such as <tt>/usr/..</tt>.
- #
- def root?
- chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o.match?(@path)
- end
-
- # Predicate method for testing whether a path is absolute.
- #
- # It returns +true+ if the pathname begins with a slash.
- #
- # p = Pathname.new('/im/sure')
- # p.absolute?
- # #=> true
- #
- # p = Pathname.new('not/so/sure')
- # p.absolute?
- # #=> false
- def absolute?
- ABSOLUTE_PATH.match? @path
- end
-
- # The opposite of Pathname#absolute?
- #
- # It returns +false+ if the pathname begins with a slash.
- #
- # p = Pathname.new('/im/sure')
- # p.relative?
- # #=> false
- #
- # p = Pathname.new('not/so/sure')
- # p.relative?
- # #=> true
- def relative?
- !absolute?
- end
-
- #
- # Iterates over each component of the path.
- #
- # Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
- # # yields "usr", "bin", and "ruby".
- #
- # Returns an Enumerator if no block was given.
- #
- # enum = Pathname.new("/usr/bin/ruby").each_filename
- # # ... do stuff ...
- # enum.each { |e| ... }
- # # yields "usr", "bin", and "ruby".
- #
- def each_filename # :yield: filename
- return to_enum(__method__) unless block_given?
- _, names = split_names(@path)
- names.each {|filename| yield filename }
- nil
- end
-
- # Iterates over and yields a new Pathname object
- # for each element in the given path in descending order.
- #
- # Pathname.new('/path/to/some/file.rb').descend {|v| p v}
- # #<Pathname:/>
- # #<Pathname:/path>
- # #<Pathname:/path/to>
- # #<Pathname:/path/to/some>
- # #<Pathname:/path/to/some/file.rb>
- #
- # Pathname.new('path/to/some/file.rb').descend {|v| p v}
- # #<Pathname:path>
- # #<Pathname:path/to>
- # #<Pathname:path/to/some>
- # #<Pathname:path/to/some/file.rb>
- #
- # Returns an Enumerator if no block was given.
- #
- # enum = Pathname.new("/usr/bin/ruby").descend
- # # ... do stuff ...
- # enum.each { |e| ... }
- # # yields Pathnames /, /usr, /usr/bin, and /usr/bin/ruby.
- #
- # It doesn't access the filesystem.
- #
- def descend
- return to_enum(__method__) unless block_given?
- vs = []
- ascend {|v| vs << v }
- vs.reverse_each {|v| yield v }
- nil
- end
-
- # Iterates over and yields a new Pathname object
- # for each element in the given path in ascending order.
- #
- # Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
- # #<Pathname:/path/to/some/file.rb>
- # #<Pathname:/path/to/some>
- # #<Pathname:/path/to>
- # #<Pathname:/path>
- # #<Pathname:/>
- #
- # Pathname.new('path/to/some/file.rb').ascend {|v| p v}
- # #<Pathname:path/to/some/file.rb>
- # #<Pathname:path/to/some>
- # #<Pathname:path/to>
- # #<Pathname:path>
- #
- # Returns an Enumerator if no block was given.
- #
- # enum = Pathname.new("/usr/bin/ruby").ascend
- # # ... do stuff ...
- # enum.each { |e| ... }
- # # yields Pathnames /usr/bin/ruby, /usr/bin, /usr, and /.
- #
- # It doesn't access the filesystem.
- #
- def ascend
- return to_enum(__method__) unless block_given?
- path = @path
- yield self
- while r = chop_basename(path)
- path, = r
- break if path.empty?
- yield self.class.new(del_trailing_separator(path))
- end
- end
-
- #
- # Appends a pathname fragment to +self+ to produce a new Pathname object.
- # Since +other+ is considered as a path relative to +self+, if +other+ is
- # an absolute path, the new Pathname object is created from just +other+.
- #
- # p1 = Pathname.new("/usr") # Pathname:/usr
- # p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
- # p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
- #
- # # / is aliased to +.
- # p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
- # p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
- #
- # This method doesn't access the file system; it is pure string manipulation.
- #
- def +(other)
- other = Pathname.new(other) unless Pathname === other
- Pathname.new(plus(@path, other.to_s))
- end
- alias / +
-
- def plus(path1, path2) # -> path # :nodoc:
- prefix2 = path2
- index_list2 = []
- basename_list2 = []
- while r2 = chop_basename(prefix2)
- prefix2, basename2 = r2
- index_list2.unshift prefix2.length
- basename_list2.unshift basename2
- end
- return path2 if prefix2 != ''
- prefix1 = path1
- while true
- while !basename_list2.empty? && basename_list2.first == '.'
- index_list2.shift
- basename_list2.shift
- end
- break unless r1 = chop_basename(prefix1)
- prefix1, basename1 = r1
- next if basename1 == '.'
- if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
- prefix1 = prefix1 + basename1
- break
- end
- index_list2.shift
- basename_list2.shift
- end
- r1 = chop_basename(prefix1)
- if !r1 && (r1 = /#{SEPARATOR_PAT}/o.match?(File.basename(prefix1)))
- while !basename_list2.empty? && basename_list2.first == '..'
- index_list2.shift
- basename_list2.shift
- end
- end
- if !basename_list2.empty?
- suffix2 = path2[index_list2.first..-1]
- r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
- else
- r1 ? prefix1 : File.dirname(prefix1)
- end
- end
- private :plus
-
- #
- # Joins the given pathnames onto +self+ to create a new Pathname object.
- # This is effectively the same as using Pathname#+ to append +self+ and
- # all arguments sequentially.
- #
- # path0 = Pathname.new("/usr") # Pathname:/usr
- # path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
- # # is the same as
- # path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
- # path0 == path1
- # #=> true
- #
- def join(*args)
- return self if args.empty?
- result = args.pop
- result = Pathname.new(result) unless Pathname === result
- return result if result.absolute?
- args.reverse_each {|arg|
- arg = Pathname.new(arg) unless Pathname === arg
- result = arg + result
- return result if result.absolute?
- }
- self + result
- end
-
- #
- # Returns the children of the directory (files and subdirectories, not
- # recursive) as an array of Pathname objects.
- #
- # By default, the returned pathnames will have enough information to access
- # the files. If you set +with_directory+ to +false+, then the returned
- # pathnames will contain the filename only.
- #
- # For example:
- # pn = Pathname("/usr/lib/ruby/1.8")
- # pn.children
- # # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
- # Pathname:/usr/lib/ruby/1.8/Env.rb,
- # Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
- # pn.children(false)
- # # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
- #
- # Note that the results never contain the entries +.+ and +..+ in
- # the directory because they are not children.
- #
- def children(with_directory=true)
- with_directory = false if @path == '.'
- result = []
- Dir.foreach(@path) {|e|
- next if e == '.' || e == '..'
- if with_directory
- result << self.class.new(File.join(@path, e))
- else
- result << self.class.new(e)
- end
- }
- result
- end
-
- # Iterates over the children of the directory
- # (files and subdirectories, not recursive).
- #
- # It yields Pathname object for each child.
- #
- # By default, the yielded pathnames will have enough information to access
- # the files.
- #
- # If you set +with_directory+ to +false+, then the returned pathnames will
- # contain the filename only.
- #
- # Pathname("/usr/local").each_child {|f| p f }
- # #=> #<Pathname:/usr/local/share>
- # # #<Pathname:/usr/local/bin>
- # # #<Pathname:/usr/local/games>
- # # #<Pathname:/usr/local/lib>
- # # #<Pathname:/usr/local/include>
- # # #<Pathname:/usr/local/sbin>
- # # #<Pathname:/usr/local/src>
- # # #<Pathname:/usr/local/man>
- #
- # Pathname("/usr/local").each_child(false) {|f| p f }
- # #=> #<Pathname:share>
- # # #<Pathname:bin>
- # # #<Pathname:games>
- # # #<Pathname:lib>
- # # #<Pathname:include>
- # # #<Pathname:sbin>
- # # #<Pathname:src>
- # # #<Pathname:man>
- #
- # Note that the results never contain the entries +.+ and +..+ in
- # the directory because they are not children.
- #
- # See Pathname#children
- #
- def each_child(with_directory=true, &b)
- children(with_directory).each(&b)
- end
-
- #
- # Returns a relative path from the given +base_directory+ to the receiver.
- #
- # If +self+ is absolute, then +base_directory+ must be absolute too.
- #
- # If +self+ is relative, then +base_directory+ must be relative too.
- #
- # This method doesn't access the filesystem. It assumes no symlinks.
- #
- # ArgumentError is raised when it cannot find a relative path.
- #
- # Note that this method does not handle situations where the case sensitivity
- # of the filesystem in use differs from the operating system default.
- #
- def relative_path_from(base_directory)
- base_directory = Pathname.new(base_directory) unless base_directory.is_a? Pathname
- dest_directory = self.cleanpath.to_s
- base_directory = base_directory.cleanpath.to_s
- dest_prefix = dest_directory
- dest_names = []
- while r = chop_basename(dest_prefix)
- dest_prefix, basename = r
- dest_names.unshift basename if basename != '.'
- end
- base_prefix = base_directory
- base_names = []
- while r = chop_basename(base_prefix)
- base_prefix, basename = r
- base_names.unshift basename if basename != '.'
- end
- unless SAME_PATHS[dest_prefix, base_prefix]
- raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
- end
- while !dest_names.empty? &&
- !base_names.empty? &&
- SAME_PATHS[dest_names.first, base_names.first]
- dest_names.shift
- base_names.shift
- end
- if base_names.include? '..'
- raise ArgumentError, "base_directory has ..: #{base_directory.inspect}"
- end
- base_names.fill('..')
- relpath_names = base_names + dest_names
- if relpath_names.empty?
- Pathname.new('.')
- else
- Pathname.new(File.join(*relpath_names))
- end
- end
-end
-
-
-class Pathname # * Find *
- #
- # Iterates over the directory tree in a depth first manner, yielding a
- # Pathname for each file under "this" directory.
- #
- # Returns an Enumerator if no block is given.
- #
- # Since it is implemented by the standard library module Find, Find.prune can
- # be used to control the traversal.
- #
- # If +self+ is +.+, yielded pathnames begin with a filename in the
- # current directory, not +./+.
- #
- # See Find.find
- #
- def find(ignore_error: true) # :yield: pathname
- return to_enum(__method__, ignore_error: ignore_error) unless block_given?
- require 'find'
- if @path == '.'
- Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
- else
- Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f) }
- end
- end
-end
-
-
-autoload(:FileUtils, 'fileutils')
-
-class Pathname # * FileUtils *
- # Creates a full path, including any intermediate directories that don't yet
- # exist.
- #
- # See FileUtils.mkpath and FileUtils.mkdir_p
- def mkpath(mode: nil)
- FileUtils.mkpath(@path, mode: mode)
- nil
- end
-
- # Recursively deletes a directory, including all directories beneath it.
- #
- # See FileUtils.rm_rf
- def rmtree(noop: nil, verbose: nil, secure: nil)
- # The name "rmtree" is borrowed from File::Path of Perl.
- # File::Path provides "mkpath" and "rmtree".
- require 'fileutils'
- FileUtils.rm_rf(@path, noop: noop, verbose: verbose, secure: secure)
- nil
- end
-end
-
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
deleted file mode 100644
index 8ee4bcec5b..0000000000
--- a/ext/pathname/pathname.c
+++ /dev/null
@@ -1,1701 +0,0 @@
-#include "ruby.h"
-#include "ruby/encoding.h"
-
-static VALUE rb_cPathname;
-static ID id_ENOTDIR;
-static ID id_at_path;
-static ID id_atime;
-static ID id_base;
-static ID id_basename;
-static ID id_binread;
-static ID id_binwrite;
-static ID id_birthtime;
-static ID id_blockdev_p;
-static ID id_chardev_p;
-static ID id_chmod;
-static ID id_chown;
-static ID id_ctime;
-static ID id_directory_p;
-static ID id_dirname;
-static ID id_empty_p;
-static ID id_entries;
-static ID id_executable_p;
-static ID id_executable_real_p;
-static ID id_exist_p;
-static ID id_expand_path;
-static ID id_extname;
-static ID id_file_p;
-static ID id_fnmatch;
-static ID id_foreach;
-static ID id_ftype;
-static ID id_getwd;
-static ID id_glob;
-static ID id_grpowned_p;
-static ID id_lchmod;
-static ID id_lchown;
-static ID id_link;
-static ID id_lstat;
-static ID id_lutime;
-static ID id_mkdir;
-static ID id_mtime;
-static ID id_open;
-static ID id_owned_p;
-static ID id_pipe_p;
-static ID id_read;
-static ID id_readable_p;
-static ID id_readable_real_p;
-static ID id_readlines;
-static ID id_readlink;
-static ID id_realdirpath;
-static ID id_realpath;
-static ID id_rename;
-static ID id_rmdir;
-static ID id_setgid_p;
-static ID id_setuid_p;
-static ID id_size;
-static ID id_size_p;
-static ID id_socket_p;
-static ID id_split;
-static ID id_stat;
-static ID id_sticky_p;
-static ID id_sub;
-static ID id_symlink;
-static ID id_symlink_p;
-static ID id_sysopen;
-static ID id_to_path;
-static ID id_truncate;
-static ID id_unlink;
-static ID id_utime;
-static ID id_world_readable_p;
-static ID id_world_writable_p;
-static ID id_writable_p;
-static ID id_writable_real_p;
-static ID id_write;
-static ID id_zero_p;
-
-static VALUE
-get_strpath(VALUE obj)
-{
- VALUE strpath;
- strpath = rb_ivar_get(obj, id_at_path);
- if (!RB_TYPE_P(strpath, T_STRING))
- rb_raise(rb_eTypeError, "unexpected @path");
- return strpath;
-}
-
-static void
-set_strpath(VALUE obj, VALUE val)
-{
- rb_ivar_set(obj, id_at_path, val);
-}
-
-/*
- * Create a Pathname object from the given String (or String-like object).
- * If +path+ contains a NULL character (<tt>\0</tt>), an ArgumentError is raised.
- */
-static VALUE
-path_initialize(VALUE self, VALUE arg)
-{
- VALUE str;
- if (RB_TYPE_P(arg, T_STRING)) {
- str = arg;
- }
- else {
- str = rb_check_funcall(arg, id_to_path, 0, NULL);
- if (str == Qundef)
- str = arg;
- StringValue(str);
- }
- if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
- rb_raise(rb_eArgError, "pathname contains null byte");
- str = rb_obj_dup(str);
-
- set_strpath(self, str);
- return self;
-}
-
-/*
- * call-seq:
- * pathname.freeze -> obj
- *
- * Freezes this Pathname.
- *
- * See Object.freeze.
- */
-static VALUE
-path_freeze(VALUE self)
-{
- rb_call_super(0, 0);
- rb_str_freeze(get_strpath(self));
- return self;
-}
-
-/*
- * call-seq:
- * pathname.taint -> obj
- *
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
- */
-static VALUE
-path_taint(VALUE self)
-{
- rb_warn("Pathname#taint is deprecated and will be removed in Ruby 3.2.");
- return self;
-}
-
-/*
- * call-seq:
- * pathname.untaint -> obj
- *
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
- */
-static VALUE
-path_untaint(VALUE self)
-{
- rb_warn("Pathname#untaint is deprecated and will be removed in Ruby 3.2.");
- return self;
-}
-
-/*
- * Compare this pathname with +other+. The comparison is string-based.
- * Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
- * can refer to the same file.
- */
-static VALUE
-path_eq(VALUE self, VALUE other)
-{
- if (!rb_obj_is_kind_of(other, rb_cPathname))
- return Qfalse;
- return rb_str_equal(get_strpath(self), get_strpath(other));
-}
-
-/*
- * Provides a case-sensitive comparison operator for pathnames.
- *
- * Pathname.new('/usr') <=> Pathname.new('/usr/bin')
- * #=> -1
- * Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin')
- * #=> 0
- * Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN')
- * #=> 1
- *
- * It will return +-1+, +0+ or +1+ depending on the value of the left argument
- * relative to the right argument. Or it will return +nil+ if the arguments
- * are not comparable.
- */
-static VALUE
-path_cmp(VALUE self, VALUE other)
-{
- VALUE s1, s2;
- char *p1, *p2;
- char *e1, *e2;
- if (!rb_obj_is_kind_of(other, rb_cPathname))
- return Qnil;
- s1 = get_strpath(self);
- s2 = get_strpath(other);
- p1 = RSTRING_PTR(s1);
- p2 = RSTRING_PTR(s2);
- e1 = p1 + RSTRING_LEN(s1);
- e2 = p2 + RSTRING_LEN(s2);
- while (p1 < e1 && p2 < e2) {
- int c1, c2;
- c1 = (unsigned char)*p1++;
- c2 = (unsigned char)*p2++;
- if (c1 == '/') c1 = '\0';
- if (c2 == '/') c2 = '\0';
- if (c1 != c2) {
- if (c1 < c2)
- return INT2FIX(-1);
- else
- return INT2FIX(1);
- }
- }
- if (p1 < e1)
- return INT2FIX(1);
- if (p2 < e2)
- return INT2FIX(-1);
- return INT2FIX(0);
-}
-
-#ifndef ST2FIX
-#define ST2FIX(h) LONG2FIX((long)(h))
-#endif
-
-/* :nodoc: */
-static VALUE
-path_hash(VALUE self)
-{
- return ST2FIX(rb_str_hash(get_strpath(self)));
-}
-
-/*
- * call-seq:
- * pathname.to_s -> string
- * pathname.to_path -> string
- *
- * Return the path as a String.
- *
- * to_path is implemented so Pathname objects are usable with File.open, etc.
- */
-static VALUE
-path_to_s(VALUE self)
-{
- return rb_obj_dup(get_strpath(self));
-}
-
-/* :nodoc: */
-static VALUE
-path_inspect(VALUE self)
-{
- const char *c = rb_obj_classname(self);
- VALUE str = get_strpath(self);
- return rb_sprintf("#<%s:%"PRIsVALUE">", c, str);
-}
-
-/*
- * Return a pathname which is substituted by String#sub.
- *
- * path1 = Pathname.new('/usr/bin/perl')
- * path1.sub('perl', 'ruby')
- * #=> #<Pathname:/usr/bin/ruby>
- */
-static VALUE
-path_sub(int argc, VALUE *argv, VALUE self)
-{
- VALUE str = get_strpath(self);
-
- if (rb_block_given_p()) {
- str = rb_block_call(str, id_sub, argc, argv, 0, 0);
- }
- else {
- str = rb_funcallv(str, id_sub, argc, argv);
- }
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Return a pathname with +repl+ added as a suffix to the basename.
- *
- * If self has no extension part, +repl+ is appended.
- *
- * Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
- * #=> #<Pathname:/usr/bin/shutdown.rb>
- */
-static VALUE
-path_sub_ext(VALUE self, VALUE repl)
-{
- VALUE str = get_strpath(self);
- VALUE str2;
- long extlen;
- const char *ext;
- const char *p;
-
- StringValue(repl);
- p = RSTRING_PTR(str);
- extlen = RSTRING_LEN(str);
- ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str));
- if (ext == NULL) {
- ext = p + RSTRING_LEN(str);
- }
- else if (extlen <= 1) {
- ext += extlen;
- }
- str2 = rb_str_subseq(str, 0, ext-p);
- rb_str_append(str2, repl);
- return rb_class_new_instance(1, &str2, rb_obj_class(self));
-}
-
-/* Facade for File */
-
-/*
- * Returns the real (absolute) pathname for +self+ in the actual
- * filesystem.
- *
- * Does not contain symlinks or useless dots, +..+ and +.+.
- *
- * All components of the pathname must exist when this method is
- * called.
- *
- */
-static VALUE
-path_realpath(int argc, VALUE *argv, VALUE self)
-{
- VALUE basedir, str;
- rb_scan_args(argc, argv, "01", &basedir);
- str = rb_funcall(rb_cFile, id_realpath, 2, get_strpath(self), basedir);
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Returns the real (absolute) pathname of +self+ in the actual filesystem.
- *
- * Does not contain symlinks or useless dots, +..+ and +.+.
- *
- * The last component of the real pathname can be nonexistent.
- */
-static VALUE
-path_realdirpath(int argc, VALUE *argv, VALUE self)
-{
- VALUE basedir, str;
- rb_scan_args(argc, argv, "01", &basedir);
- str = rb_funcall(rb_cFile, id_realdirpath, 2, get_strpath(self), basedir);
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * call-seq:
- * pathname.each_line {|line| ... }
- * pathname.each_line(sep=$/ [, open_args]) {|line| block } -> nil
- * pathname.each_line(limit [, open_args]) {|line| block } -> nil
- * pathname.each_line(sep, limit [, open_args]) {|line| block } -> nil
- * pathname.each_line(...) -> an_enumerator
- *
- * Iterates over each line in the file and yields a String object for each.
- */
-static VALUE
-path_each_line(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cFile, id_foreach, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
- }
- else {
- return rb_funcallv_kw(rb_cFile, id_foreach, 1+n, args, RB_PASS_CALLED_KEYWORDS);
- }
-}
-
-/*
- * call-seq:
- * pathname.read([length [, offset]]) -> string
- * pathname.read([length [, offset]], open_args) -> string
- *
- * Returns all data from the file, or the first +N+ bytes if specified.
- *
- * See File.read.
- *
- */
-static VALUE
-path_read(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_read, 1+n, args, RB_PASS_CALLED_KEYWORDS);
-}
-
-/*
- * call-seq:
- * pathname.binread([length [, offset]]) -> string
- *
- * Returns all the bytes from the file, or the first +N+ if specified.
- *
- * See File.binread.
- *
- */
-static VALUE
-path_binread(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[3];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
- return rb_funcallv(rb_cFile, id_binread, 1+n, args);
-}
-
-/*
- * call-seq:
- * pathname.write(string, [offset] ) => fixnum
- * pathname.write(string, [offset], open_args ) => fixnum
- *
- * Writes +contents+ to the file.
- *
- * See File.write.
- *
- */
-static VALUE
-path_write(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_write, 1+n, args, RB_PASS_CALLED_KEYWORDS);
-}
-
-/*
- * call-seq:
- * pathname.binwrite(string, [offset] ) => fixnum
- * pathname.binwrite(string, [offset], open_args ) => fixnum
- *
- * Writes +contents+ to the file, opening it in binary mode.
- *
- * See File.binwrite.
- *
- */
-static VALUE
-path_binwrite(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_binwrite, 1+n, args, RB_PASS_CALLED_KEYWORDS);
-}
-
-/*
- * call-seq:
- * pathname.readlines(sep=$/ [, open_args]) -> array
- * pathname.readlines(limit [, open_args]) -> array
- * pathname.readlines(sep, limit [, open_args]) -> array
- *
- * Returns all the lines from the file.
- *
- * See File.readlines.
- *
- */
-static VALUE
-path_readlines(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv_kw(rb_cFile, id_readlines, 1+n, args, RB_PASS_CALLED_KEYWORDS);
-}
-
-/*
- * call-seq:
- * pathname.sysopen([mode, [perm]]) -> fixnum
- *
- * See IO.sysopen.
- *
- */
-static VALUE
-path_sysopen(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[3];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
- return rb_funcallv(rb_cIO, id_sysopen, 1+n, args);
-}
-
-/*
- * call-seq:
- * pathname.atime -> time
- *
- * Returns the last access time for the file.
- *
- * See File.atime.
- */
-static VALUE
-path_atime(VALUE self)
-{
- return rb_funcall(rb_cFile, id_atime, 1, get_strpath(self));
-}
-
-#if defined(HAVE_RB_FILE_S_BIRTHTIME)
-/*
- * call-seq:
- * pathname.birthtime -> time
- *
- * Returns the birth time for the file.
- * If the platform doesn't have birthtime, raises NotImplementedError.
- *
- * See File.birthtime.
- */
-static VALUE
-path_birthtime(VALUE self)
-{
- return rb_funcall(rb_cFile, id_birthtime, 1, get_strpath(self));
-}
-#else
-/* check at compilation time for `respond_to?` */
-# define path_birthtime rb_f_notimplement
-#endif
-
-/*
- * call-seq:
- * pathname.ctime -> time
- *
- * Returns the last change time, using directory information, not the file itself.
- *
- * See File.ctime.
- */
-static VALUE
-path_ctime(VALUE self)
-{
- return rb_funcall(rb_cFile, id_ctime, 1, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.mtime -> time
- *
- * Returns the last modified time of the file.
- *
- * See File.mtime.
- */
-static VALUE
-path_mtime(VALUE self)
-{
- return rb_funcall(rb_cFile, id_mtime, 1, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.chmod(mode_int) -> integer
- *
- * Changes file permissions.
- *
- * See File.chmod.
- */
-static VALUE
-path_chmod(VALUE self, VALUE mode)
-{
- return rb_funcall(rb_cFile, id_chmod, 2, mode, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.lchmod(mode_int) -> integer
- *
- * Same as Pathname.chmod, but does not follow symbolic links.
- *
- * See File.lchmod.
- */
-static VALUE
-path_lchmod(VALUE self, VALUE mode)
-{
- return rb_funcall(rb_cFile, id_lchmod, 2, mode, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.chown(owner_int, group_int) -> integer
- *
- * Change owner and group of the file.
- *
- * See File.chown.
- */
-static VALUE
-path_chown(VALUE self, VALUE owner, VALUE group)
-{
- return rb_funcall(rb_cFile, id_chown, 3, owner, group, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.lchown(owner_int, group_int) -> integer
- *
- * Same as Pathname.chown, but does not follow symbolic links.
- *
- * See File.lchown.
- */
-static VALUE
-path_lchown(VALUE self, VALUE owner, VALUE group)
-{
- return rb_funcall(rb_cFile, id_lchown, 3, owner, group, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.fnmatch(pattern, [flags]) -> true or false
- * pathname.fnmatch?(pattern, [flags]) -> true or false
- *
- * Return +true+ if the receiver matches the given pattern.
- *
- * See File.fnmatch.
- */
-static VALUE
-path_fnmatch(int argc, VALUE *argv, VALUE self)
-{
- VALUE str = get_strpath(self);
- VALUE pattern, flags;
- if (rb_scan_args(argc, argv, "11", &pattern, &flags) == 1)
- return rb_funcall(rb_cFile, id_fnmatch, 2, pattern, str);
- else
- return rb_funcall(rb_cFile, id_fnmatch, 3, pattern, str, flags);
-}
-
-/*
- * call-seq:
- * pathname.ftype -> string
- *
- * Returns "type" of file ("file", "directory", etc).
- *
- * See File.ftype.
- */
-static VALUE
-path_ftype(VALUE self)
-{
- return rb_funcall(rb_cFile, id_ftype, 1, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.make_link(old)
- *
- * Creates a hard link at _pathname_.
- *
- * See File.link.
- */
-static VALUE
-path_make_link(VALUE self, VALUE old)
-{
- return rb_funcall(rb_cFile, id_link, 2, old, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.open()
- * pathname.open(mode="r" [, opt]) -> file
- * pathname.open([mode [, perm]] [, opt]) -> file
- * pathname.open(mode="r" [, opt]) {|file| block } -> obj
- * pathname.open([mode [, perm]] [, opt]) {|file| block } -> obj
- *
- * Opens the file for reading or writing.
- *
- * See File.open.
- */
-static VALUE
-path_open(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[4];
- int n;
-
- args[0] = get_strpath(self);
- n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
- }
- else {
- return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS);
- }
-}
-
-/*
- * Read symbolic link.
- *
- * See File.readlink.
- */
-static VALUE
-path_readlink(VALUE self)
-{
- VALUE str;
- str = rb_funcall(rb_cFile, id_readlink, 1, get_strpath(self));
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Rename the file.
- *
- * See File.rename.
- */
-static VALUE
-path_rename(VALUE self, VALUE to)
-{
- return rb_funcall(rb_cFile, id_rename, 2, get_strpath(self), to);
-}
-
-/*
- * Returns a File::Stat object.
- *
- * See File.stat.
- */
-static VALUE
-path_stat(VALUE self)
-{
- return rb_funcall(rb_cFile, id_stat, 1, get_strpath(self));
-}
-
-/*
- * See File.lstat.
- */
-static VALUE
-path_lstat(VALUE self)
-{
- return rb_funcall(rb_cFile, id_lstat, 1, get_strpath(self));
-}
-
-/*
- * call-seq:
- * pathname.make_symlink(old)
- *
- * Creates a symbolic link.
- *
- * See File.symlink.
- */
-static VALUE
-path_make_symlink(VALUE self, VALUE old)
-{
- return rb_funcall(rb_cFile, id_symlink, 2, old, get_strpath(self));
-}
-
-/*
- * Truncates the file to +length+ bytes.
- *
- * See File.truncate.
- */
-static VALUE
-path_truncate(VALUE self, VALUE length)
-{
- return rb_funcall(rb_cFile, id_truncate, 2, get_strpath(self), length);
-}
-
-/*
- * Update the access and modification times of the file.
- *
- * See File.utime.
- */
-static VALUE
-path_utime(VALUE self, VALUE atime, VALUE mtime)
-{
- return rb_funcall(rb_cFile, id_utime, 3, atime, mtime, get_strpath(self));
-}
-
-/*
- * Update the access and modification times of the file.
- *
- * Same as Pathname#utime, but does not follow symbolic links.
- *
- * See File.lutime.
- */
-static VALUE
-path_lutime(VALUE self, VALUE atime, VALUE mtime)
-{
- return rb_funcall(rb_cFile, id_lutime, 3, atime, mtime, get_strpath(self));
-}
-
-/*
- * Returns the last component of the path.
- *
- * See File.basename.
- */
-static VALUE
-path_basename(int argc, VALUE *argv, VALUE self)
-{
- VALUE str = get_strpath(self);
- VALUE fext;
- if (rb_scan_args(argc, argv, "01", &fext) == 0)
- str = rb_funcall(rb_cFile, id_basename, 1, str);
- else
- str = rb_funcall(rb_cFile, id_basename, 2, str, fext);
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Returns all but the last component of the path.
- *
- * See File.dirname.
- */
-static VALUE
-path_dirname(VALUE self)
-{
- VALUE str = get_strpath(self);
- str = rb_funcall(rb_cFile, id_dirname, 1, str);
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Returns the file's extension.
- *
- * See File.extname.
- */
-static VALUE
-path_extname(VALUE self)
-{
- VALUE str = get_strpath(self);
- return rb_funcall(rb_cFile, id_extname, 1, str);
-}
-
-/*
- * Returns the absolute path for the file.
- *
- * See File.expand_path.
- */
-static VALUE
-path_expand_path(int argc, VALUE *argv, VALUE self)
-{
- VALUE str = get_strpath(self);
- VALUE dname;
- if (rb_scan_args(argc, argv, "01", &dname) == 0)
- str = rb_funcall(rb_cFile, id_expand_path, 1, str);
- else
- str = rb_funcall(rb_cFile, id_expand_path, 2, str, dname);
- return rb_class_new_instance(1, &str, rb_obj_class(self));
-}
-
-/*
- * Returns the #dirname and the #basename in an Array.
- *
- * See File.split.
- */
-static VALUE
-path_split(VALUE self)
-{
- VALUE str = get_strpath(self);
- VALUE ary, dirname, basename;
- ary = rb_funcall(rb_cFile, id_split, 1, str);
- Check_Type(ary, T_ARRAY);
- dirname = rb_ary_entry(ary, 0);
- basename = rb_ary_entry(ary, 1);
- dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self));
- basename = rb_class_new_instance(1, &basename, rb_obj_class(self));
- return rb_ary_new3(2, dirname, basename);
-}
-
-/*
- * See FileTest.blockdev?.
- */
-static VALUE
-path_blockdev_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_blockdev_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.chardev?.
- */
-static VALUE
-path_chardev_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_chardev_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.executable?.
- */
-static VALUE
-path_executable_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_executable_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.executable_real?.
- */
-static VALUE
-path_executable_real_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_executable_real_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.exist?.
- */
-static VALUE
-path_exist_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_exist_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.grpowned?.
- */
-static VALUE
-path_grpowned_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_grpowned_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.directory?.
- */
-static VALUE
-path_directory_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_directory_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.file?.
- */
-static VALUE
-path_file_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_file_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.pipe?.
- */
-static VALUE
-path_pipe_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_pipe_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.socket?.
- */
-static VALUE
-path_socket_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_socket_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.owned?.
- */
-static VALUE
-path_owned_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_owned_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.readable?.
- */
-static VALUE
-path_readable_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_readable_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.world_readable?.
- */
-static VALUE
-path_world_readable_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_world_readable_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.readable_real?.
- */
-static VALUE
-path_readable_real_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_readable_real_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.setuid?.
- */
-static VALUE
-path_setuid_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_setuid_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.setgid?.
- */
-static VALUE
-path_setgid_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_setgid_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.size.
- */
-static VALUE
-path_size(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_size, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.size?.
- */
-static VALUE
-path_size_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_size_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.sticky?.
- */
-static VALUE
-path_sticky_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_sticky_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.symlink?.
- */
-static VALUE
-path_symlink_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_symlink_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.writable?.
- */
-static VALUE
-path_writable_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_writable_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.world_writable?.
- */
-static VALUE
-path_world_writable_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_world_writable_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.writable_real?.
- */
-static VALUE
-path_writable_real_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_writable_real_p, 1, get_strpath(self));
-}
-
-/*
- * See FileTest.zero?.
- */
-static VALUE
-path_zero_p(VALUE self)
-{
- return rb_funcall(rb_mFileTest, id_zero_p, 1, get_strpath(self));
-}
-
-/*
- * Tests the file is empty.
- *
- * See Dir#empty? and FileTest.empty?.
- */
-static VALUE
-path_empty_p(VALUE self)
-{
-
- VALUE path = get_strpath(self);
- if (RTEST(rb_funcall(rb_mFileTest, id_directory_p, 1, path)))
- return rb_funcall(rb_cDir, id_empty_p, 1, path);
- else
- return rb_funcall(rb_mFileTest, id_empty_p, 1, path);
-}
-
-static VALUE
-s_glob_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass))
-{
- return rb_yield(rb_class_new_instance(1, &elt, klass));
-}
-
-/*
- * Returns or yields Pathname objects.
- *
- * Pathname.glob("lib/i*.rb")
- * #=> [#<Pathname:lib/ipaddr.rb>, #<Pathname:lib/irb.rb>]
- *
- * See Dir.glob.
- */
-static VALUE
-path_s_glob(int argc, VALUE *argv, VALUE klass)
-{
- VALUE args[3];
- int n;
-
- n = rb_scan_args(argc, argv, "12", &args[0], &args[1], &args[2]);
- if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cDir, id_glob, n, args, s_glob_i, klass, RB_PASS_CALLED_KEYWORDS);
- }
- else {
- VALUE ary;
- long i;
- ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_CALLED_KEYWORDS);
- ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE elt = RARRAY_AREF(ary, i);
- elt = rb_class_new_instance(1, &elt, klass);
- rb_ary_store(ary, i, elt);
- }
- return ary;
- }
-}
-
-static VALUE
-glob_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, self))
-{
- elt = rb_funcall(self, '+', 1, elt);
- return rb_yield(elt);
-}
-
-/*
- * Returns or yields Pathname objects.
- *
- * Pathname("ruby-2.4.2").glob("R*.md")
- * #=> [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
- *
- * See Dir.glob.
- * This method uses the +base+ keyword argument of Dir.glob.
- */
-static VALUE
-path_glob(int argc, VALUE *argv, VALUE self)
-{
- VALUE args[3];
- int n;
-
- n = rb_scan_args(argc, argv, "11", &args[0], &args[1]);
- if (n == 1)
- args[1] = INT2FIX(0);
-
- args[2] = rb_hash_new();
- rb_hash_aset(args[2], ID2SYM(id_base), get_strpath(self));
-
- n = 3;
-
- if (rb_block_given_p()) {
- return rb_block_call_kw(rb_cDir, id_glob, n, args, glob_i, self, RB_PASS_KEYWORDS);
- }
- else {
- VALUE ary;
- long i;
- ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_KEYWORDS);
- ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE elt = RARRAY_AREF(ary, i);
- elt = rb_funcall(self, '+', 1, elt);
- rb_ary_store(ary, i, elt);
- }
- return ary;
- }
-}
-
-/*
- * Returns the current working directory as a Pathname.
- *
- * Pathname.getwd
- * #=> #<Pathname:/home/zzak/projects/ruby>
- *
- * See Dir.getwd.
- */
-static VALUE
-path_s_getwd(VALUE klass)
-{
- VALUE str;
- str = rb_funcall(rb_cDir, id_getwd, 0);
- return rb_class_new_instance(1, &str, klass);
-}
-
-/*
- * Return the entries (files and subdirectories) in the directory, each as a
- * Pathname object.
- *
- * The results contains just the names in the directory, without any trailing
- * slashes or recursive look-up.
- *
- * pp Pathname.new('/usr/local').entries
- * #=> [#<Pathname:share>,
- * # #<Pathname:lib>,
- * # #<Pathname:..>,
- * # #<Pathname:include>,
- * # #<Pathname:etc>,
- * # #<Pathname:bin>,
- * # #<Pathname:man>,
- * # #<Pathname:games>,
- * # #<Pathname:.>,
- * # #<Pathname:sbin>,
- * # #<Pathname:src>]
- *
- * The result may contain the current directory <code>#<Pathname:.></code> and
- * the parent directory <code>#<Pathname:..></code>.
- *
- * If you don't want +.+ and +..+ and
- * want directories, consider Pathname#children.
- */
-static VALUE
-path_entries(VALUE self)
-{
- VALUE klass, str, ary;
- long i;
- klass = rb_obj_class(self);
- str = get_strpath(self);
- ary = rb_funcall(rb_cDir, id_entries, 1, str);
- ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- VALUE elt = RARRAY_AREF(ary, i);
- elt = rb_class_new_instance(1, &elt, klass);
- rb_ary_store(ary, i, elt);
- }
- return ary;
-}
-
-/*
- * Create the referenced directory.
- *
- * See Dir.mkdir.
- */
-static VALUE
-path_mkdir(int argc, VALUE *argv, VALUE self)
-{
- VALUE str = get_strpath(self);
- VALUE vmode;
- if (rb_scan_args(argc, argv, "01", &vmode) == 0)
- return rb_funcall(rb_cDir, id_mkdir, 1, str);
- else
- return rb_funcall(rb_cDir, id_mkdir, 2, str, vmode);
-}
-
-/*
- * Remove the referenced directory.
- *
- * See Dir.rmdir.
- */
-static VALUE
-path_rmdir(VALUE self)
-{
- return rb_funcall(rb_cDir, id_rmdir, 1, get_strpath(self));
-}
-
-/*
- * Opens the referenced directory.
- *
- * See Dir.open.
- */
-static VALUE
-path_opendir(VALUE self)
-{
- VALUE args[1];
-
- args[0] = get_strpath(self);
- return rb_block_call(rb_cDir, id_open, 1, args, 0, 0);
-}
-
-static VALUE
-each_entry_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass))
-{
- return rb_yield(rb_class_new_instance(1, &elt, klass));
-}
-
-/*
- * Iterates over the entries (files and subdirectories) in the directory,
- * yielding a Pathname object for each entry.
- */
-static VALUE
-path_each_entry(VALUE self)
-{
- VALUE args[1];
- RETURN_ENUMERATOR(self, 0, 0);
-
- args[0] = get_strpath(self);
- return rb_block_call(rb_cDir, id_foreach, 1, args, each_entry_i, rb_obj_class(self));
-}
-
-static VALUE
-unlink_body(VALUE str)
-{
- return rb_funcall(rb_cDir, id_unlink, 1, str);
-}
-
-static VALUE
-unlink_rescue(VALUE str, VALUE errinfo)
-{
- return rb_funcall(rb_cFile, id_unlink, 1, str);
-}
-
-/*
- * Removes a file or directory, using File.unlink if +self+ is a file, or
- * Dir.unlink as necessary.
- */
-static VALUE
-path_unlink(VALUE self)
-{
- VALUE eENOTDIR = rb_const_get_at(rb_mErrno, id_ENOTDIR);
- VALUE str = get_strpath(self);
- return rb_rescue2(unlink_body, str, unlink_rescue, str, eENOTDIR, (VALUE)0);
-}
-
-/*
- * :call-seq:
- * Pathname(path) -> pathname
- *
- * Creates a new Pathname object from the given string, +path+, and returns
- * pathname object.
- *
- * In order to use this constructor, you must first require the Pathname
- * standard library extension.
- *
- * require 'pathname'
- * Pathname("/home/zzak")
- * #=> #<Pathname:/home/zzak>
- *
- * See also Pathname::new for more information.
- */
-static VALUE
-path_f_pathname(VALUE self, VALUE str)
-{
- if (CLASS_OF(str) == rb_cPathname)
- return str;
- return rb_class_new_instance(1, &str, rb_cPathname);
-}
-
-/*
- *
- * Pathname represents the name of a file or directory on the filesystem,
- * but not the file itself.
- *
- * The pathname depends on the Operating System: Unix, Windows, etc.
- * This library works with pathnames of local OS, however non-Unix pathnames
- * are supported experimentally.
- *
- * A Pathname can be relative or absolute. It's not until you try to
- * reference the file that it even matters whether the file exists or not.
- *
- * Pathname is immutable. It has no method for destructive update.
- *
- * The goal of this class is to manipulate file path information in a neater
- * way than standard Ruby provides. The examples below demonstrate the
- * difference.
- *
- * *All* functionality from File, FileTest, and some from Dir and FileUtils is
- * included, in an unsurprising way. It is essentially a facade for all of
- * these, and more.
- *
- * == Examples
- *
- * === Example 1: Using Pathname
- *
- * require 'pathname'
- * pn = Pathname.new("/usr/bin/ruby")
- * size = pn.size # 27662
- * isdir = pn.directory? # false
- * dir = pn.dirname # Pathname:/usr/bin
- * base = pn.basename # Pathname:ruby
- * dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
- * data = pn.read
- * pn.open { |f| _ }
- * pn.each_line { |line| _ }
- *
- * === Example 2: Using standard Ruby
- *
- * pn = "/usr/bin/ruby"
- * size = File.size(pn) # 27662
- * isdir = File.directory?(pn) # false
- * dir = File.dirname(pn) # "/usr/bin"
- * base = File.basename(pn) # "ruby"
- * dir, base = File.split(pn) # ["/usr/bin", "ruby"]
- * data = File.read(pn)
- * File.open(pn) { |f| _ }
- * File.foreach(pn) { |line| _ }
- *
- * === Example 3: Special features
- *
- * p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
- * p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
- * p3 = p1.parent # Pathname:/usr
- * p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
- * pwd = Pathname.pwd # Pathname:/home/gavin
- * pwd.absolute? # true
- * p5 = Pathname.new "." # Pathname:.
- * p5 = p5 + "music/../articles" # Pathname:music/../articles
- * p5.cleanpath # Pathname:articles
- * p5.realpath # Pathname:/home/gavin/articles
- * p5.children # [Pathname:/home/gavin/articles/linux, ...]
- *
- * == Breakdown of functionality
- *
- * === Core methods
- *
- * These methods are effectively manipulating a String, because that's
- * all a path is. None of these access the file system except for
- * #mountpoint?, #children, #each_child, #realdirpath and #realpath.
- *
- * - +
- * - #join
- * - #parent
- * - #root?
- * - #absolute?
- * - #relative?
- * - #relative_path_from
- * - #each_filename
- * - #cleanpath
- * - #realpath
- * - #realdirpath
- * - #children
- * - #each_child
- * - #mountpoint?
- *
- * === File status predicate methods
- *
- * These methods are a facade for FileTest:
- * - #blockdev?
- * - #chardev?
- * - #directory?
- * - #executable?
- * - #executable_real?
- * - #exist?
- * - #file?
- * - #grpowned?
- * - #owned?
- * - #pipe?
- * - #readable?
- * - #world_readable?
- * - #readable_real?
- * - #setgid?
- * - #setuid?
- * - #size
- * - #size?
- * - #socket?
- * - #sticky?
- * - #symlink?
- * - #writable?
- * - #world_writable?
- * - #writable_real?
- * - #zero?
- *
- * === File property and manipulation methods
- *
- * These methods are a facade for File:
- * - #atime
- * - #birthtime
- * - #ctime
- * - #mtime
- * - #chmod(mode)
- * - #lchmod(mode)
- * - #chown(owner, group)
- * - #lchown(owner, group)
- * - #fnmatch(pattern, *args)
- * - #fnmatch?(pattern, *args)
- * - #ftype
- * - #make_link(old)
- * - #open(*args, &block)
- * - #readlink
- * - #rename(to)
- * - #stat
- * - #lstat
- * - #make_symlink(old)
- * - #truncate(length)
- * - #utime(atime, mtime)
- * - #lutime(atime, mtime)
- * - #basename(*args)
- * - #dirname
- * - #extname
- * - #expand_path(*args)
- * - #split
- *
- * === Directory methods
- *
- * These methods are a facade for Dir:
- * - Pathname.glob(*args)
- * - Pathname.getwd / Pathname.pwd
- * - #rmdir
- * - #entries
- * - #each_entry(&block)
- * - #mkdir(*args)
- * - #opendir(*args)
- *
- * === IO
- *
- * These methods are a facade for IO:
- * - #each_line(*args, &block)
- * - #read(*args)
- * - #binread(*args)
- * - #readlines(*args)
- * - #sysopen(*args)
- * - #write(*args)
- * - #binwrite(*args)
- *
- * === Utilities
- *
- * These methods are a mixture of Find, FileUtils, and others:
- * - #find(&block)
- * - #mkpath
- * - #rmtree
- * - #unlink / #delete
- *
- *
- * == Method documentation
- *
- * As the above section shows, most of the methods in Pathname are facades. The
- * documentation for these methods generally just says, for instance, "See
- * FileTest.writable?", as you should be familiar with the original method
- * anyway, and its documentation (e.g. through +ri+) will contain more
- * information. In some cases, a brief description will follow.
- */
-void
-Init_pathname(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
-
- InitVM(pathname);
-
- rb_cPathname = rb_define_class("Pathname", rb_cObject);
- rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
- rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
- rb_define_method(rb_cPathname, "taint", path_taint, 0);
- rb_define_method(rb_cPathname, "untaint", path_untaint, 0);
- rb_define_method(rb_cPathname, "==", path_eq, 1);
- rb_define_method(rb_cPathname, "===", path_eq, 1);
- rb_define_method(rb_cPathname, "eql?", path_eq, 1);
- rb_define_method(rb_cPathname, "<=>", path_cmp, 1);
- rb_define_method(rb_cPathname, "hash", path_hash, 0);
- rb_define_method(rb_cPathname, "to_s", path_to_s, 0);
- rb_define_method(rb_cPathname, "to_path", path_to_s, 0);
- rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
- rb_define_method(rb_cPathname, "sub", path_sub, -1);
- rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1);
- rb_define_method(rb_cPathname, "realpath", path_realpath, -1);
- rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1);
- rb_define_method(rb_cPathname, "each_line", path_each_line, -1);
- rb_define_method(rb_cPathname, "read", path_read, -1);
- rb_define_method(rb_cPathname, "binread", path_binread, -1);
- rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
- rb_define_method(rb_cPathname, "write", path_write, -1);
- rb_define_method(rb_cPathname, "binwrite", path_binwrite, -1);
- rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
- rb_define_method(rb_cPathname, "atime", path_atime, 0);
- rb_define_method(rb_cPathname, "birthtime", path_birthtime, 0);
- rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
- rb_define_method(rb_cPathname, "mtime", path_mtime, 0);
- rb_define_method(rb_cPathname, "chmod", path_chmod, 1);
- rb_define_method(rb_cPathname, "lchmod", path_lchmod, 1);
- rb_define_method(rb_cPathname, "chown", path_chown, 2);
- rb_define_method(rb_cPathname, "lchown", path_lchown, 2);
- rb_define_method(rb_cPathname, "fnmatch", path_fnmatch, -1);
- rb_define_method(rb_cPathname, "fnmatch?", path_fnmatch, -1);
- rb_define_method(rb_cPathname, "ftype", path_ftype, 0);
- rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
- rb_define_method(rb_cPathname, "open", path_open, -1);
- rb_define_method(rb_cPathname, "readlink", path_readlink, 0);
- rb_define_method(rb_cPathname, "rename", path_rename, 1);
- rb_define_method(rb_cPathname, "stat", path_stat, 0);
- rb_define_method(rb_cPathname, "lstat", path_lstat, 0);
- rb_define_method(rb_cPathname, "make_symlink", path_make_symlink, 1);
- rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
- rb_define_method(rb_cPathname, "utime", path_utime, 2);
- rb_define_method(rb_cPathname, "lutime", path_lutime, 2);
- rb_define_method(rb_cPathname, "basename", path_basename, -1);
- rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
- rb_define_method(rb_cPathname, "extname", path_extname, 0);
- rb_define_method(rb_cPathname, "expand_path", path_expand_path, -1);
- rb_define_method(rb_cPathname, "split", path_split, 0);
- rb_define_method(rb_cPathname, "blockdev?", path_blockdev_p, 0);
- rb_define_method(rb_cPathname, "chardev?", path_chardev_p, 0);
- rb_define_method(rb_cPathname, "executable?", path_executable_p, 0);
- rb_define_method(rb_cPathname, "executable_real?", path_executable_real_p, 0);
- rb_define_method(rb_cPathname, "exist?", path_exist_p, 0);
- rb_define_method(rb_cPathname, "grpowned?", path_grpowned_p, 0);
- rb_define_method(rb_cPathname, "directory?", path_directory_p, 0);
- rb_define_method(rb_cPathname, "file?", path_file_p, 0);
- rb_define_method(rb_cPathname, "pipe?", path_pipe_p, 0);
- rb_define_method(rb_cPathname, "socket?", path_socket_p, 0);
- rb_define_method(rb_cPathname, "owned?", path_owned_p, 0);
- rb_define_method(rb_cPathname, "readable?", path_readable_p, 0);
- rb_define_method(rb_cPathname, "world_readable?", path_world_readable_p, 0);
- rb_define_method(rb_cPathname, "readable_real?", path_readable_real_p, 0);
- rb_define_method(rb_cPathname, "setuid?", path_setuid_p, 0);
- rb_define_method(rb_cPathname, "setgid?", path_setgid_p, 0);
- rb_define_method(rb_cPathname, "size", path_size, 0);
- rb_define_method(rb_cPathname, "size?", path_size_p, 0);
- rb_define_method(rb_cPathname, "sticky?", path_sticky_p, 0);
- rb_define_method(rb_cPathname, "symlink?", path_symlink_p, 0);
- rb_define_method(rb_cPathname, "writable?", path_writable_p, 0);
- rb_define_method(rb_cPathname, "world_writable?", path_world_writable_p, 0);
- rb_define_method(rb_cPathname, "writable_real?", path_writable_real_p, 0);
- rb_define_method(rb_cPathname, "zero?", path_zero_p, 0);
- rb_define_method(rb_cPathname, "empty?", path_empty_p, 0);
- rb_define_singleton_method(rb_cPathname, "glob", path_s_glob, -1);
- rb_define_singleton_method(rb_cPathname, "getwd", path_s_getwd, 0);
- rb_define_singleton_method(rb_cPathname, "pwd", path_s_getwd, 0);
- rb_define_method(rb_cPathname, "glob", path_glob, -1);
- rb_define_method(rb_cPathname, "entries", path_entries, 0);
- rb_define_method(rb_cPathname, "mkdir", path_mkdir, -1);
- rb_define_method(rb_cPathname, "rmdir", path_rmdir, 0);
- rb_define_method(rb_cPathname, "opendir", path_opendir, 0);
- rb_define_method(rb_cPathname, "each_entry", path_each_entry, 0);
- rb_define_method(rb_cPathname, "unlink", path_unlink, 0);
- rb_define_method(rb_cPathname, "delete", path_unlink, 0);
- rb_undef_method(rb_cPathname, "=~");
- rb_define_global_function("Pathname", path_f_pathname, 1);
-}
-
-void
-InitVM_pathname(void)
-{
-#undef rb_intern
- id_at_path = rb_intern("@path");
- id_to_path = rb_intern("to_path");
- id_ENOTDIR = rb_intern("ENOTDIR");
- id_atime = rb_intern("atime");
- id_basename = rb_intern("basename");
- id_base = rb_intern("base");
- id_binread = rb_intern("binread");
- id_binwrite = rb_intern("binwrite");
- id_birthtime = rb_intern("birthtime");
- id_blockdev_p = rb_intern("blockdev?");
- id_chardev_p = rb_intern("chardev?");
- id_chmod = rb_intern("chmod");
- id_chown = rb_intern("chown");
- id_ctime = rb_intern("ctime");
- id_directory_p = rb_intern("directory?");
- id_dirname = rb_intern("dirname");
- id_empty_p = rb_intern("empty?");
- id_entries = rb_intern("entries");
- id_executable_p = rb_intern("executable?");
- id_executable_real_p = rb_intern("executable_real?");
- id_exist_p = rb_intern("exist?");
- id_expand_path = rb_intern("expand_path");
- id_extname = rb_intern("extname");
- id_file_p = rb_intern("file?");
- id_fnmatch = rb_intern("fnmatch");
- id_foreach = rb_intern("foreach");
- id_ftype = rb_intern("ftype");
- id_getwd = rb_intern("getwd");
- id_glob = rb_intern("glob");
- id_grpowned_p = rb_intern("grpowned?");
- id_lchmod = rb_intern("lchmod");
- id_lchown = rb_intern("lchown");
- id_link = rb_intern("link");
- id_lstat = rb_intern("lstat");
- id_lutime = rb_intern("lutime");
- id_mkdir = rb_intern("mkdir");
- id_mtime = rb_intern("mtime");
- id_open = rb_intern("open");
- id_owned_p = rb_intern("owned?");
- id_pipe_p = rb_intern("pipe?");
- id_read = rb_intern("read");
- id_readable_p = rb_intern("readable?");
- id_readable_real_p = rb_intern("readable_real?");
- id_readlines = rb_intern("readlines");
- id_readlink = rb_intern("readlink");
- id_realdirpath = rb_intern("realdirpath");
- id_realpath = rb_intern("realpath");
- id_rename = rb_intern("rename");
- id_rmdir = rb_intern("rmdir");
- id_setgid_p = rb_intern("setgid?");
- id_setuid_p = rb_intern("setuid?");
- id_size = rb_intern("size");
- id_size_p = rb_intern("size?");
- id_socket_p = rb_intern("socket?");
- id_split = rb_intern("split");
- id_stat = rb_intern("stat");
- id_sticky_p = rb_intern("sticky?");
- id_sub = rb_intern("sub");
- id_symlink = rb_intern("symlink");
- id_symlink_p = rb_intern("symlink?");
- id_sysopen = rb_intern("sysopen");
- id_truncate = rb_intern("truncate");
- id_unlink = rb_intern("unlink");
- id_utime = rb_intern("utime");
- id_world_readable_p = rb_intern("world_readable?");
- id_world_writable_p = rb_intern("world_writable?");
- id_writable_p = rb_intern("writable?");
- id_writable_real_p = rb_intern("writable_real?");
- id_write = rb_intern("write");
- id_zero_p = rb_intern("zero?");
-}
diff --git a/ext/pathname/pathname.gemspec b/ext/pathname/pathname.gemspec
deleted file mode 100644
index 92bc02b0db..0000000000
--- a/ext/pathname/pathname.gemspec
+++ /dev/null
@@ -1,25 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "pathname"
- spec.version = "0.2.1"
- spec.authors = ["Tanaka Akira"]
- spec.email = ["akr@fsij.org"]
-
- spec.summary = %q{Representation of the name of a file or directory on the filesystem}
- spec.description = %q{Representation of the name of a file or directory on the filesystem}
- spec.homepage = "https://github.com/ruby/pathname"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = []
- spec.require_paths = ["lib"]
- spec.extensions = %w[ext/pathname/extconf.rb]
-end
diff --git a/ext/psych/depend b/ext/psych/depend
index 13fbe3fb19..95175841a2 100644
--- a/ext/psych/depend
+++ b/ext/psych/depend
@@ -152,6 +152,7 @@ psych.o: $(hdrdir)/ruby/internal/intern/re.h
psych.o: $(hdrdir)/ruby/internal/intern/ruby.h
psych.o: $(hdrdir)/ruby/internal/intern/select.h
psych.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+psych.o: $(hdrdir)/ruby/internal/intern/set.h
psych.o: $(hdrdir)/ruby/internal/intern/signal.h
psych.o: $(hdrdir)/ruby/internal/intern/sprintf.h
psych.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -171,6 +172,7 @@ psych.o: $(hdrdir)/ruby/internal/special_consts.h
psych.o: $(hdrdir)/ruby/internal/static_assert.h
psych.o: $(hdrdir)/ruby/internal/stdalign.h
psych.o: $(hdrdir)/ruby/internal/stdbool.h
+psych.o: $(hdrdir)/ruby/internal/stdckdint.h
psych.o: $(hdrdir)/ruby/internal/symbol.h
psych.o: $(hdrdir)/ruby/internal/value.h
psych.o: $(hdrdir)/ruby/internal/value_type.h
@@ -328,6 +330,7 @@ psych_emitter.o: $(hdrdir)/ruby/internal/intern/re.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/ruby.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/select.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+psych_emitter.o: $(hdrdir)/ruby/internal/intern/set.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/signal.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/sprintf.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -347,6 +350,7 @@ psych_emitter.o: $(hdrdir)/ruby/internal/special_consts.h
psych_emitter.o: $(hdrdir)/ruby/internal/static_assert.h
psych_emitter.o: $(hdrdir)/ruby/internal/stdalign.h
psych_emitter.o: $(hdrdir)/ruby/internal/stdbool.h
+psych_emitter.o: $(hdrdir)/ruby/internal/stdckdint.h
psych_emitter.o: $(hdrdir)/ruby/internal/symbol.h
psych_emitter.o: $(hdrdir)/ruby/internal/value.h
psych_emitter.o: $(hdrdir)/ruby/internal/value_type.h
@@ -504,6 +508,7 @@ psych_parser.o: $(hdrdir)/ruby/internal/intern/re.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/ruby.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/select.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+psych_parser.o: $(hdrdir)/ruby/internal/intern/set.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/signal.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/sprintf.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -523,6 +528,7 @@ psych_parser.o: $(hdrdir)/ruby/internal/special_consts.h
psych_parser.o: $(hdrdir)/ruby/internal/static_assert.h
psych_parser.o: $(hdrdir)/ruby/internal/stdalign.h
psych_parser.o: $(hdrdir)/ruby/internal/stdbool.h
+psych_parser.o: $(hdrdir)/ruby/internal/stdckdint.h
psych_parser.o: $(hdrdir)/ruby/internal/symbol.h
psych_parser.o: $(hdrdir)/ruby/internal/value.h
psych_parser.o: $(hdrdir)/ruby/internal/value_type.h
@@ -680,6 +686,7 @@ psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/re.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/ruby.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/select.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/set.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/signal.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/sprintf.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -699,6 +706,7 @@ psych_to_ruby.o: $(hdrdir)/ruby/internal/special_consts.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/static_assert.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/stdalign.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/stdbool.h
+psych_to_ruby.o: $(hdrdir)/ruby/internal/stdckdint.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/symbol.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/value.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/value_type.h
@@ -856,6 +864,7 @@ psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/re.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/ruby.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/select.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/set.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/signal.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/sprintf.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -875,6 +884,7 @@ psych_yaml_tree.o: $(hdrdir)/ruby/internal/special_consts.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/static_assert.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/stdalign.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/stdbool.h
+psych_yaml_tree.o: $(hdrdir)/ruby/internal/stdckdint.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/symbol.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/value.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb
index e7dd0bb60a..589e201c1c 100644
--- a/ext/psych/extconf.rb
+++ b/ext/psych/extconf.rb
@@ -36,8 +36,11 @@ if yaml_source
libyaml = "libyaml.#$LIBEXT"
$cleanfiles << libyaml
$LOCAL_LIBS.prepend("$(LIBYAML) ")
-else # default to pre-installed libyaml
- pkg_config('yaml-0.1')
+
+ # default to pre-installed libyaml
+elsif pkg_config('yaml-0.1')
+ # found with pkg-config
+else
dir_config('libyaml')
find_header('yaml.h') or abort "yaml.h not found"
find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 4a2ab58514..850a6d1937 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -1,4 +1,6 @@
# frozen_string_literal: true
+require 'date'
+
require_relative 'psych/versions'
case RUBY_ENGINE
when 'jruby'
@@ -21,7 +23,6 @@ require_relative 'psych/parser'
require_relative 'psych/omap'
require_relative 'psych/set'
require_relative 'psych/coder'
-require_relative 'psych/core_ext'
require_relative 'psych/stream'
require_relative 'psych/json/tree_builder'
require_relative 'psych/json/stream'
@@ -84,7 +85,7 @@ require_relative 'psych/class_loader'
# Psych.safe_load_file("data.yml", permitted_classes: [Date])
# Psych.load_file("trusted_database.yml")
#
-# ==== Exception handling
+# ==== \Exception handling
#
# begin
# # The second argument changes only the exception contents
@@ -148,7 +149,7 @@ require_relative 'psych/class_loader'
# # Returns Psych::Nodes::Document
# Psych.parse_file('database.yml')
#
-# ==== Exception handling
+# ==== \Exception handling
#
# begin
# # The second argument changes only the exception contents
@@ -268,10 +269,10 @@ module Psych
# YAML documents that are supplied via user input. Instead, please use the
# load method or the safe_load method.
#
- def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false
+ def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true
result = parse(yaml, filename: filename)
return fallback unless result
- result.to_ruby(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer)
+ result.to_ruby(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: parse_symbols)
end
###
@@ -319,13 +320,13 @@ module Psych
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
#
- def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
+ def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true
result = parse(yaml, filename: filename)
return fallback unless result
class_loader = ClassLoader::Restricted.new(permitted_classes.map(&:to_s),
permitted_symbols.map(&:to_s))
- scanner = ScalarScanner.new class_loader, strict_integer: strict_integer
+ scanner = ScalarScanner.new class_loader, strict_integer: strict_integer, parse_symbols: parse_symbols
visitor = if aliases
Visitors::ToRuby.new scanner, class_loader, symbolize_names: symbolize_names, freeze: freeze
else
@@ -340,7 +341,7 @@ module Psych
# provided, the object contained in the first document will be returned.
# +filename+ will be used in the exception message if any exception
# is raised while parsing. If +yaml+ is empty, it returns
- # the specified +fallback+ return value, which defaults to +false+.
+ # the specified +fallback+ return value, which defaults to +nil+.
#
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
#
@@ -365,7 +366,7 @@ module Psych
# Raises a TypeError when `yaml` parameter is NilClass. This method is
# similar to `safe_load` except that `Symbol` objects are allowed by default.
#
- def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
+ def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true
safe_load yaml, permitted_classes: permitted_classes,
permitted_symbols: permitted_symbols,
aliases: aliases,
@@ -373,7 +374,8 @@ module Psych
fallback: fallback,
symbolize_names: symbolize_names,
freeze: freeze,
- strict_integer: strict_integer
+ strict_integer: strict_integer,
+ parse_symbols: parse_symbols
end
###
@@ -479,6 +481,7 @@ module Psych
#
# Default: <tt>2</tt>.
# [<tt>:line_width</tt>] Max character to wrap line at.
+ # For unlimited line width use <tt>-1</tt>.
#
# Default: <tt>0</tt> (meaning "wrap at 81").
# [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
@@ -489,6 +492,10 @@ module Psych
#
# Default: <tt>false</tt>.
#
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
+ #
+ # Default: <tt>false</tt>.
+ #
# Example:
#
# # Dump an array, get back a YAML string
@@ -502,6 +509,9 @@ module Psych
#
# # Dump an array to an IO with indentation set
# Psych.dump(['a', ['b']], StringIO.new, indentation: 3)
+ #
+ # # Dump hash with symbol keys as string
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
def self.dump o, io = nil, options = {}
if Hash === io
options = io
@@ -552,6 +562,7 @@ module Psych
#
# Default: <tt>2</tt>.
# [<tt>:line_width</tt>] Max character to wrap line at.
+ # For unlimited line width use <tt>-1</tt>.
#
# Default: <tt>0</tt> (meaning "wrap at 81").
# [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
@@ -562,6 +573,10 @@ module Psych
#
# Default: <tt>false</tt>.
#
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
+ #
+ # Default: <tt>false</tt>.
+ #
# Example:
#
# # Dump an array, get back a YAML string
@@ -575,6 +590,9 @@ module Psych
#
# # Dump an array to an IO with indentation set
# Psych.safe_dump(['a', ['b']], StringIO.new, indentation: 3)
+ #
+ # # Dump hash with symbol keys as string
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
def self.safe_dump o, io = nil, options = {}
if Hash === io
options = io
@@ -637,6 +655,35 @@ module Psych
end
###
+ # Load multiple documents given in +yaml+. Returns the parsed documents
+ # as a list.
+ #
+ # Example:
+ #
+ # Psych.safe_load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']
+ #
+ # list = []
+ # Psych.safe_load_stream("--- foo\n...\n--- bar\n...") do |ruby|
+ # list << ruby
+ # end
+ # list # => ['foo', 'bar']
+ #
+ def self.safe_load_stream yaml, filename: nil, permitted_classes: [], aliases: false
+ documents = parse_stream(yaml, filename: filename).children.map do |child|
+ stream = Psych::Nodes::Stream.new
+ stream.children << child
+ safe_load(stream.to_yaml, permitted_classes: permitted_classes, aliases: aliases)
+ end
+
+ if block_given?
+ documents.each { |doc| yield doc }
+ nil
+ else
+ documents
+ end
+ end
+
+ ###
# Load the document contained in +filename+. Returns the yaml contained in
# +filename+ as a Ruby object, or if the file is empty, it returns
# the specified +fallback+ return value, which defaults to +false+.
@@ -653,7 +700,7 @@ module Psych
###
# Safely loads the document contained in +filename+. Returns the yaml contained in
# +filename+ as a Ruby object, or if the file is empty, it returns
- # the specified +fallback+ return value, which defaults to +false+.
+ # the specified +fallback+ return value, which defaults to +nil+.
# See safe_load for options.
def self.safe_load_file filename, **kwargs
File.open(filename, 'r:bom|utf-8') { |f|
@@ -664,7 +711,7 @@ module Psych
###
# Loads the document contained in +filename+. Returns the yaml contained in
# +filename+ as a Ruby object, or if the file is empty, it returns
- # the specified +fallback+ return value, which defaults to +false+.
+ # the specified +fallback+ return value, which defaults to +nil+.
# See load for options.
def self.load_file filename, **kwargs
File.open(filename, 'r:bom|utf-8') { |f|
@@ -694,26 +741,8 @@ module Psych
dump_tags[klass] = tag
end
- # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
- def self.warn_with_uplevel(message, uplevel: 1)
- at = parse_caller(caller[uplevel]).join(':')
- warn "#{at}: #{message}"
- end
-
- def self.parse_caller(at)
- if /^(.+?):(\d+)(?::in `.*')?/ =~ at
- file = $1
- line = $2.to_i
- [file, line]
- end
- end
- private_class_method :warn_with_uplevel, :parse_caller
-
class << self
if defined?(Ractor)
- require 'forwardable'
- extend Forwardable
-
class Config
attr_accessor :load_tags, :dump_tags, :domain_types
def initialize
@@ -727,7 +756,29 @@ module Psych
Ractor.current[:PsychConfig] ||= Config.new
end
- def_delegators :config, :load_tags, :dump_tags, :domain_types, :load_tags=, :dump_tags=, :domain_types=
+ def load_tags
+ config.load_tags
+ end
+
+ def dump_tags
+ config.dump_tags
+ end
+
+ def domain_types
+ config.domain_types
+ end
+
+ def load_tags=(value)
+ config.load_tags = value
+ end
+
+ def dump_tags=(value)
+ config.dump_tags = value
+ end
+
+ def domain_types=(value)
+ config.domain_types = value
+ end
else
attr_accessor :load_tags
attr_accessor :dump_tags
@@ -739,3 +790,5 @@ module Psych
self.domain_types = {}
# :startdoc:
end
+
+require_relative 'psych/core_ext'
diff --git a/ext/psych/lib/psych/class_loader.rb b/ext/psych/lib/psych/class_loader.rb
index 50efc35ee2..c8f509720a 100644
--- a/ext/psych/lib/psych/class_loader.rb
+++ b/ext/psych/lib/psych/class_loader.rb
@@ -6,6 +6,7 @@ module Psych
class ClassLoader # :nodoc:
BIG_DECIMAL = 'BigDecimal'
COMPLEX = 'Complex'
+ DATA = 'Data' unless RUBY_VERSION < "3.2"
DATE = 'Date'
DATE_TIME = 'DateTime'
EXCEPTION = 'Exception'
diff --git a/ext/psych/lib/psych/core_ext.rb b/ext/psych/lib/psych/core_ext.rb
index 0721a133c3..6dfd0f1696 100644
--- a/ext/psych/lib/psych/core_ext.rb
+++ b/ext/psych/lib/psych/core_ext.rb
@@ -14,6 +14,23 @@ class Object
end
end
-if defined?(::IRB)
- require_relative 'y'
+# Up to Ruby 3.4, Set was a regular object and was dumped as such
+# by Pysch.
+# Starting from Ruby 4.0 it's a core class written in C, so we have to implement
+# #encode_with / #init_with to preserve backward compatibility.
+if defined?(::Set) && Set.new.instance_variables.empty?
+ class Set
+ def encode_with(coder)
+ hash = {}
+ each do |m|
+ hash[m] = true
+ end
+ coder["hash"] = hash
+ coder
+ end
+
+ def init_with(coder)
+ replace(coder["hash"].keys)
+ end
+ end
end
diff --git a/ext/psych/lib/psych/nodes/node.rb b/ext/psych/lib/psych/nodes/node.rb
index f44fce5f05..fc27448f2e 100644
--- a/ext/psych/lib/psych/nodes/node.rb
+++ b/ext/psych/lib/psych/nodes/node.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require 'stringio'
require_relative '../class_loader'
require_relative '../scalar_scanner'
@@ -46,8 +45,8 @@ module Psych
# Convert this node to Ruby.
#
# See also Psych::Visitors::ToRuby
- def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
- Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer).accept(self)
+ def to_ruby(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
+ Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: parse_symbols).accept(self)
end
alias :transform :to_ruby
@@ -56,6 +55,8 @@ module Psych
#
# See also Psych::Visitors::Emitter
def yaml io = nil, options = {}
+ require "stringio" unless defined?(StringIO)
+
real_io = io || StringIO.new(''.encode('utf-8'))
Visitors::Emitter.new(real_io, options).accept self
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index 3cb4bf3c7e..6a556fb3b8 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -11,26 +11,27 @@ module Psych
# Base 60, [-+]inf and NaN are handled separately
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10))$/x
- # Taken from http://yaml.org/type/int.html
- INTEGER_STRICT = /^(?:[-+]?0b[0-1_]+ (?# base 2)
- |[-+]?0[0-7_]+ (?# base 8)
- |[-+]?(0|[1-9][0-9_]*) (?# base 10)
- |[-+]?0x[0-9a-fA-F_]+ (?# base 16))$/x
+ # Taken from http://yaml.org/type/int.html and modified to ensure at least one numerical symbol exists
+ INTEGER_STRICT = /^(?:[-+]?0b[_]*[0-1][0-1_]* (?# base 2)
+ |[-+]?0[_]*[0-7][0-7_]* (?# base 8)
+ |[-+]?(0|[1-9][0-9_]*) (?# base 10)
+ |[-+]?0x[_]*[0-9a-fA-F][0-9a-fA-F_]* (?# base 16))$/x
# Same as above, but allows commas.
# Not to YML spec, but kept for backwards compatibility
- INTEGER_LEGACY = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
- |[-+]?0[0-7_,]+ (?# base 8)
+ INTEGER_LEGACY = /^(?:[-+]?0b[_,]*[0-1][0-1_,]* (?# base 2)
+ |[-+]?0[_,]*[0-7][0-7_,]* (?# base 8)
|[-+]?(?:0|[1-9](?:[0-9]|,[0-9]|_[0-9])*) (?# base 10)
- |[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
+ |[-+]?0x[_,]*[0-9a-fA-F][0-9a-fA-F_,]* (?# base 16))$/x
attr_reader :class_loader
# Create a new scanner
- def initialize class_loader, strict_integer: false
+ def initialize class_loader, strict_integer: false, parse_symbols: true
@symbol_cache = {}
@class_loader = class_loader
@strict_integer = strict_integer
+ @parse_symbols = parse_symbols
end
# Tokenize +string+ returning the Ruby object
@@ -61,7 +62,6 @@ module Psych
string
end
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
- require 'date'
begin
class_loader.date.strptime(string, '%F', Date::GREGORIAN)
rescue ArgumentError
@@ -73,7 +73,7 @@ module Psych
-Float::INFINITY
elsif string.match?(/^\.nan$/i)
Float::NAN
- elsif string.match?(/^:./)
+ elsif @parse_symbols && string.match?(/^:./)
if string =~ /^:(["'])(.*)\1/
@symbol_cache[string] = class_loader.symbolize($2.sub(/^:/, ''))
else
diff --git a/ext/psych/lib/psych/versions.rb b/ext/psych/lib/psych/versions.rb
index 57b7659b57..6c1679bf65 100644
--- a/ext/psych/lib/psych/versions.rb
+++ b/ext/psych/lib/psych/versions.rb
@@ -2,9 +2,9 @@
module Psych
# The version of Psych you are using
- VERSION = '5.1.0'
+ VERSION = '5.4.0'
if RUBY_ENGINE == 'jruby'
- DEFAULT_SNAKEYAML_VERSION = '2.6'.freeze
+ DEFAULT_SNAKEYAML_VERSION = '2.10'.freeze
end
end
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 8614251ca9..475444e589 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -12,9 +12,13 @@ module Psych
###
# This class walks a YAML AST, converting each node to Ruby
class ToRuby < Psych::Visitors::Visitor
- def self.create(symbolize_names: false, freeze: false, strict_integer: false)
+ unless RUBY_VERSION < "3.2"
+ DATA_INITIALIZE = Data.instance_method(:initialize)
+ end
+
+ def self.create(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
class_loader = ClassLoader.new
- scanner = ScalarScanner.new class_loader, strict_integer: strict_integer
+ scanner = ScalarScanner.new class_loader, strict_integer: strict_integer, parse_symbols: parse_symbols
new(scanner, class_loader, symbolize_names: symbolize_names, freeze: freeze)
end
@@ -36,7 +40,7 @@ module Psych
unless @domain_types.empty? || !target.tag
key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
- key = "tag:#{key}" unless key =~ /^(?:tag:|x-private)/
+ key = "tag:#{key}" unless key.match?(/^(?:tag:|x-private)/)
if @domain_types.key? key
value, block = @domain_types[key]
@@ -79,7 +83,6 @@ module Psych
class_loader.big_decimal._load o.value
when "!ruby/object:DateTime"
class_loader.date_time
- require 'date' unless defined? DateTime
t = @ss.parse_time(o.value)
DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
(t.subsec/86400)
@@ -97,11 +100,11 @@ module Psych
Float(@ss.tokenize(o.value))
when "!ruby/regexp"
klass = class_loader.regexp
- o.value =~ /^\/(.*)\/([mixn]*)$/m
- source = $1
+ matches = /^\/(?<string>.*)\/(?<options>[mixn]*)$/m.match(o.value)
+ source = matches[:string].gsub('\/', '/')
options = 0
lang = nil
- ($2 || '').split('').each do |option|
+ matches[:options].each_char do |option|
case option
when 'x' then options |= Regexp::EXTENDED
when 'i' then options |= Regexp::IGNORECASE
@@ -198,6 +201,32 @@ module Psych
s
end
+ when /^!ruby\/data(-with-ivars)?(?::(.*))?$/
+ data = register(o, resolve_class($2).allocate) if $2
+ members = {}
+
+ if $1 # data-with-ivars
+ ivars = {}
+ o.children.each_slice(2) do |type, vars|
+ case accept(type)
+ when 'members'
+ revive_data_members(members, vars)
+ data ||= allocate_anon_data(o, members)
+ when 'ivars'
+ revive_hash(ivars, vars)
+ end
+ end
+ ivars.each do |ivar, v|
+ data.instance_variable_set ivar, v
+ end
+ else
+ revive_data_members(members, o)
+ end
+ data ||= allocate_anon_data(o, members)
+ DATA_INITIALIZE.bind_call(data, **members)
+ data.freeze
+ data
+
when /^!ruby\/object:?(.*)?$/
name = $1 || 'Object'
@@ -341,6 +370,20 @@ module Psych
list
end
+ def allocate_anon_data node, members
+ klass = class_loader.data.define(*members.keys)
+ register(node, klass.allocate)
+ end
+
+ def revive_data_members hash, o
+ o.children.each_slice(2) do |k,v|
+ name = accept(k)
+ value = accept(v)
+ hash[class_loader.symbolize(name)] = value
+ end
+ hash
+ end
+
def revive_hash hash, o, tagged= false
o.children.each_slice(2) { |k,v|
key = accept(k)
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 51491783c3..b6c86f4c94 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -15,30 +15,25 @@ module Psych
class YAMLTree < Psych::Visitors::Visitor
class Registrar # :nodoc:
def initialize
- @obj_to_id = {}
- @obj_to_node = {}
- @targets = []
+ @obj_to_id = {}.compare_by_identity
+ @obj_to_node = {}.compare_by_identity
@counter = 0
end
def register target, node
- return unless target.respond_to? :object_id
- @targets << target
- @obj_to_node[target.object_id] = node
+ @obj_to_node[target] = node
end
def key? target
- @obj_to_node.key? target.object_id
- rescue NoMethodError
- false
+ @obj_to_node.key? target
end
def id_for target
- @obj_to_id[target.object_id] ||= (@counter += 1)
+ @obj_to_id[target] ||= (@counter += 1)
end
def node_for target
- @obj_to_node[target.object_id]
+ @obj_to_node[target]
end
end
@@ -70,6 +65,7 @@ module Psych
fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
end
end
+ @stringify_names = options[:stringify_names]
@coders = []
@dispatch_cache = Hash.new do |h,klass|
@@ -77,7 +73,7 @@ module Psych
method = respond_to?(method) ? method : h[klass.superclass]
- raise(TypeError, "Can't dump #{target.class}") unless method
+ raise(TypeError, "can't dump #{klass.name}") unless method
h[klass] = method
end.compare_by_identity
@@ -166,6 +162,44 @@ module Psych
alias :visit_Delegator :visit_Object
+ def visit_Data o
+ ivars = o.instance_variables
+ if ivars.empty?
+ tag = ['!ruby/data', o.class.name].compact.join(':')
+ register o, @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
+ o.members.each do |member|
+ @emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
+ accept o.send member
+ end
+ @emitter.end_mapping
+
+ else
+ tag = ['!ruby/data-with-ivars', o.class.name].compact.join(':')
+ node = @emitter.start_mapping(nil, tag, false, Psych::Nodes::Mapping::BLOCK)
+ register(o, node)
+
+ # Dump the members
+ accept 'members'
+ @emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
+ o.members.each do |member|
+ @emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
+ accept o.send member
+ end
+ @emitter.end_mapping
+
+ # Dump the ivars
+ accept 'ivars'
+ @emitter.start_mapping nil, nil, true, Nodes::Mapping::BLOCK
+ ivars.each do |ivar|
+ accept ivar.to_s
+ accept o.instance_variable_get ivar
+ end
+ @emitter.end_mapping
+
+ @emitter.end_mapping
+ end
+ end unless RUBY_VERSION < "3.2"
+
def visit_Struct o
tag = ['!ruby/struct', o.class.name].compact.join(':')
@@ -193,7 +227,8 @@ module Psych
end
def visit_Date o
- register o, visit_Integer(o.gregorian)
+ formatted = format_date o
+ register o, @emitter.scalar(formatted, nil, nil, true, false, Nodes::Scalar::ANY)
end
def visit_DateTime o
@@ -265,20 +300,20 @@ module Psych
style = Nodes::Scalar::LITERAL
plain = false
quote = false
- elsif o =~ /\n(?!\Z)/ # match \n except blank line at the end of string
+ elsif o.match?(/\n(?!\Z)/) # match \n except blank line at the end of string
style = Nodes::Scalar::LITERAL
elsif o == '<<'
style = Nodes::Scalar::SINGLE_QUOTED
tag = 'tag:yaml.org,2002:str'
plain = false
quote = false
- elsif o == 'y' || o == 'n'
+ elsif o == 'y' || o == 'Y' || o == 'n' || o == 'N'
style = Nodes::Scalar::DOUBLE_QUOTED
elsif @line_width && o.length > @line_width
style = Nodes::Scalar::FOLDED
- elsif o =~ /^[^[:word:]][^"]*$/
+ elsif o.match?(/^[^[:word:]][^"]*$/)
style = Nodes::Scalar::DOUBLE_QUOTED
- elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o
+ elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/.match?(o)
style = Nodes::Scalar::SINGLE_QUOTED
end
@@ -328,7 +363,7 @@ module Psych
if o.class == ::Hash
register(o, @emitter.start_mapping(nil, nil, true, Psych::Nodes::Mapping::BLOCK))
o.each do |k,v|
- accept k
+ accept(@stringify_names && Symbol === k ? k.to_s : k)
accept v
end
@emitter.end_mapping
@@ -341,7 +376,7 @@ module Psych
register(o, @emitter.start_mapping(nil, '!set', false, Psych::Nodes::Mapping::BLOCK))
o.each do |k,v|
- accept k
+ accept(@stringify_names && Symbol === k ? k.to_s : k)
accept v
end
@@ -490,6 +525,10 @@ module Psych
end
end
+ def format_date date
+ date.strftime("%Y-%m-%d")
+ end
+
def register target, yaml_obj
@st.register target, yaml_obj
yaml_obj
diff --git a/ext/psych/psych.c b/ext/psych/psych.c
index 8af0bb6a5a..afbd7a3571 100644
--- a/ext/psych/psych.c
+++ b/ext/psych/psych.c
@@ -23,7 +23,7 @@ VALUE mPsych;
void Init_psych(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
- RB_EXT_RACTOR_SAFE(true);
+ RB_EXT_RACTOR_SAFE(true);
#endif
mPsych = rb_define_module("Psych");
@@ -34,4 +34,3 @@ void Init_psych(void)
Init_psych_to_ruby();
Init_psych_yaml_tree();
}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec
index a8ee5da028..a32f79bc16 100644
--- a/ext/psych/psych.gemspec
+++ b/ext/psych/psych.gemspec
@@ -21,28 +21,41 @@ DESCRIPTION
s.licenses = ["MIT"]
s.require_paths = ["lib"]
- # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ # for ruby core repository.
+ # It was generated by
+ # `git ls-files -z`.split("\x0").reject { |f|
+ # f.match(%r{^\.git|^(test|spec|features|bin|tool)/|^[A-Z]\w+file$|/extlibs$|\.(gemspec|java)$|jar})
+ # }
s.files = [
- ".gitignore", "Gemfile", "LICENSE", "Mavenfile", "README.md", "Rakefile", "bin/console",
- "bin/setup", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
- "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
- "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
- "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/exception.rb",
- "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
- "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb",
- "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb",
- "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb",
- "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb",
- "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb",
- "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb",
- "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb",
- "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "psych.gemspec"
+ "CONTRIBUTING.md", "LICENSE", "README.md", "ext/psych/depend",
+ "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
+ "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h",
+ "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
+ "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h",
+ "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
+ "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb",
+ "lib/psych/core_ext.rb", "lib/psych/exception.rb", "lib/psych/handler.rb",
+ "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
+ "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb",
+ "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb",
+ "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb",
+ "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb",
+ "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb",
+ "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb",
+ "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb",
+ "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb",
+ "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb",
+ "lib/psych/versions.rb", "lib/psych/visitors.rb",
+ "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb",
+ "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb",
+ "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb",
+ "lib/psych/y.rb"
]
s.rdoc_options = ["--main", "README.md"]
s.extra_rdoc_files = ["README.md"]
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
s.required_rubygems_version = Gem::Requirement.new(">= 0")
if RUBY_ENGINE == 'jruby'
@@ -62,6 +75,8 @@ DESCRIPTION
s.add_dependency 'stringio'
end
- s.metadata['msys2_mingw_dependencies'] = 'libyaml'
+ s.add_dependency 'date'
+ s.metadata['msys2_mingw_dependencies'] = 'libyaml'
+ s.metadata['changelog_uri'] = s.homepage + '/releases'
end
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index 022ffa0946..624ab7c528 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -17,7 +17,7 @@ static ID id_canonical;
static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
{
if(!yaml_emitter_emit(emitter, event))
- rb_raise(rb_eRuntimeError, "%s", emitter->problem);
+ rb_raise(rb_eRuntimeError, "%s", emitter->problem);
}
static int writer(void *ctx, unsigned char *buffer, size_t size)
@@ -82,13 +82,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
- line_width = rb_funcall(options, id_line_width, 0);
- indent = rb_funcall(options, id_indentation, 0);
- canonical = rb_funcall(options, id_canonical, 0);
+ line_width = rb_funcall(options, id_line_width, 0);
+ indent = rb_funcall(options, id_indentation, 0);
+ canonical = rb_funcall(options, id_canonical, 0);
- yaml_emitter_set_width(emitter, NUM2INT(line_width));
- yaml_emitter_set_indent(emitter, NUM2INT(indent));
- yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
+ yaml_emitter_set_width(emitter, NUM2INT(line_width));
+ yaml_emitter_set_indent(emitter, NUM2INT(indent));
+ yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
}
rb_ivar_set(self, id_io, io);
@@ -136,84 +136,118 @@ static VALUE end_stream(VALUE self)
return self;
}
-/* call-seq: emitter.start_document(version, tags, implicit)
- *
- * Start a document emission with YAML +version+, +tags+, and an +implicit+
- * start.
- *
- * See Psych::Handler#start_document
- */
-static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
+struct start_document_data {
+ VALUE self;
+ VALUE version;
+ VALUE tags;
+ VALUE imp;
+
+ yaml_tag_directive_t * head;
+};
+
+static VALUE start_document_try(VALUE d)
{
+ struct start_document_data * data = (struct start_document_data *)d;
+ VALUE self = data->self;
+ VALUE version = data->version;
+ VALUE tags = data->tags;
+ VALUE imp = data->imp;
+
yaml_emitter_t * emitter;
- yaml_tag_directive_t * head = NULL;
yaml_tag_directive_t * tail = NULL;
yaml_event_t event;
yaml_version_directive_t version_directive;
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
-
Check_Type(version, T_ARRAY);
if(RARRAY_LEN(version) > 0) {
- VALUE major = rb_ary_entry(version, (long)0);
- VALUE minor = rb_ary_entry(version, (long)1);
+ VALUE major = rb_ary_entry(version, (long)0);
+ VALUE minor = rb_ary_entry(version, (long)1);
- version_directive.major = NUM2INT(major);
- version_directive.minor = NUM2INT(minor);
+ version_directive.major = NUM2INT(major);
+ version_directive.minor = NUM2INT(minor);
}
if(RTEST(tags)) {
- long i = 0;
- long len;
- rb_encoding * encoding = rb_utf8_encoding();
-
- Check_Type(tags, T_ARRAY);
-
- len = RARRAY_LEN(tags);
- head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
- tail = head;
-
- for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
- VALUE tuple = RARRAY_AREF(tags, i);
- VALUE name;
- VALUE value;
-
- Check_Type(tuple, T_ARRAY);
-
- if(RARRAY_LEN(tuple) < 2) {
- xfree(head);
- rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
- }
- name = RARRAY_AREF(tuple, 0);
- value = RARRAY_AREF(tuple, 1);
- StringValue(name);
- StringValue(value);
- name = rb_str_export_to_enc(name, encoding);
- value = rb_str_export_to_enc(value, encoding);
-
- tail->handle = (yaml_char_t *)StringValueCStr(name);
- tail->prefix = (yaml_char_t *)StringValueCStr(value);
-
- tail++;
- }
+ long i = 0;
+ long len;
+ rb_encoding * encoding = rb_utf8_encoding();
+
+ Check_Type(tags, T_ARRAY);
+
+ len = RARRAY_LEN(tags);
+ data->head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
+ tail = data->head;
+
+ for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
+ VALUE tuple = RARRAY_AREF(tags, i);
+ VALUE name;
+ VALUE value;
+
+ Check_Type(tuple, T_ARRAY);
+
+ if(RARRAY_LEN(tuple) < 2) {
+ rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
+ }
+
+ name = RARRAY_AREF(tuple, 0);
+ value = RARRAY_AREF(tuple, 1);
+ StringValue(name);
+ StringValue(value);
+ name = rb_str_export_to_enc(name, encoding);
+ value = rb_str_export_to_enc(value, encoding);
+
+ tail->handle = (yaml_char_t *)StringValueCStr(name);
+ tail->prefix = (yaml_char_t *)StringValueCStr(value);
+
+ tail++;
+ }
}
yaml_document_start_event_initialize(
- &event,
- (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
- head,
- tail,
- imp ? 1 : 0
- );
+ &event,
+ (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
+ data->head,
+ tail,
+ imp ? 1 : 0
+ );
emit(emitter, &event);
- if(head) xfree(head);
-
return self;
}
+static VALUE start_document_ensure(VALUE d)
+{
+ struct start_document_data * data = (struct start_document_data *)d;
+
+ xfree(data->head);
+
+ return Qnil;
+}
+
+/* call-seq: emitter.start_document(version, tags, implicit)
+ *
+ * Start a document emission with YAML +version+, +tags+, and an +implicit+
+ * start.
+ *
+ * See Psych::Handler#start_document
+ */
+static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
+{
+ struct start_document_data data = {
+ .self = self,
+ .version = version,
+ .tags = tags,
+ .imp = imp,
+
+ .head = NULL,
+ };
+
+ return rb_ensure(start_document_try, (VALUE)&data, start_document_ensure, (VALUE)&data);
+}
+
/* call-seq: emitter.end_document(implicit)
*
* End a document emission with an +implicit+ ending.
@@ -241,14 +275,14 @@ static VALUE end_document(VALUE self, VALUE imp)
* See Psych::Handler#scalar
*/
static VALUE scalar(
- VALUE self,
- VALUE value,
- VALUE anchor,
- VALUE tag,
- VALUE plain,
- VALUE quoted,
- VALUE style
- ) {
+ VALUE self,
+ VALUE value,
+ VALUE anchor,
+ VALUE tag,
+ VALUE plain,
+ VALUE quoted,
+ VALUE style
+ ) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding *encoding;
@@ -261,25 +295,26 @@ static VALUE scalar(
value = rb_str_export_to_enc(value, encoding);
if(!NIL_P(anchor)) {
- Check_Type(anchor, T_STRING);
- anchor = rb_str_export_to_enc(anchor, encoding);
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
}
if(!NIL_P(tag)) {
- Check_Type(tag, T_STRING);
- tag = rb_str_export_to_enc(tag, encoding);
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
}
+ const char *value_ptr = StringValuePtr(value);
yaml_scalar_event_initialize(
- &event,
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
- (yaml_char_t*)StringValuePtr(value),
- (int)RSTRING_LEN(value),
- plain ? 1 : 0,
- quoted ? 1 : 0,
- (yaml_scalar_style_t)NUM2INT(style)
- );
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
+ (yaml_char_t*)value_ptr,
+ (int)RSTRING_LEN(value),
+ plain ? 1 : 0,
+ quoted ? 1 : 0,
+ (yaml_scalar_style_t)NUM2INT(style)
+ );
emit(emitter, &event);
@@ -294,36 +329,36 @@ static VALUE scalar(
* See Psych::Handler#start_sequence
*/
static VALUE start_sequence(
- VALUE self,
- VALUE anchor,
- VALUE tag,
- VALUE implicit,
- VALUE style
- ) {
+ VALUE self,
+ VALUE anchor,
+ VALUE tag,
+ VALUE implicit,
+ VALUE style
+ ) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding * encoding = rb_utf8_encoding();
if(!NIL_P(anchor)) {
- Check_Type(anchor, T_STRING);
- anchor = rb_str_export_to_enc(anchor, encoding);
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
}
if(!NIL_P(tag)) {
- Check_Type(tag, T_STRING);
- tag = rb_str_export_to_enc(tag, encoding);
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
}
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
yaml_sequence_start_event_initialize(
- &event,
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
- implicit ? 1 : 0,
- (yaml_sequence_style_t)NUM2INT(style)
- );
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
+ implicit ? 1 : 0,
+ (yaml_sequence_style_t)NUM2INT(style)
+ );
emit(emitter, &event);
@@ -357,12 +392,12 @@ static VALUE end_sequence(VALUE self)
* See Psych::Handler#start_mapping
*/
static VALUE start_mapping(
- VALUE self,
- VALUE anchor,
- VALUE tag,
- VALUE implicit,
- VALUE style
- ) {
+ VALUE self,
+ VALUE anchor,
+ VALUE tag,
+ VALUE implicit,
+ VALUE style
+ ) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding *encoding;
@@ -372,22 +407,22 @@ static VALUE start_mapping(
encoding = rb_utf8_encoding();
if(!NIL_P(anchor)) {
- Check_Type(anchor, T_STRING);
- anchor = rb_str_export_to_enc(anchor, encoding);
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
}
if(!NIL_P(tag)) {
- Check_Type(tag, T_STRING);
- tag = rb_str_export_to_enc(tag, encoding);
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
}
yaml_mapping_start_event_initialize(
- &event,
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
- implicit ? 1 : 0,
- (yaml_mapping_style_t)NUM2INT(style)
- );
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
+ implicit ? 1 : 0,
+ (yaml_mapping_style_t)NUM2INT(style)
+ );
emit(emitter, &event);
@@ -426,14 +461,14 @@ static VALUE alias(VALUE self, VALUE anchor)
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
if(!NIL_P(anchor)) {
- Check_Type(anchor, T_STRING);
- anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
}
yaml_alias_event_initialize(
- &event,
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
- );
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
+ );
emit(emitter, &event);
@@ -552,4 +587,3 @@ void Init_psych_emitter(void)
id_indentation = rb_intern("indentation");
id_canonical = rb_intern("canonical");
}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c
index 9c5179cc44..00a2207b58 100644
--- a/ext/psych/psych_parser.c
+++ b/ext/psych/psych_parser.c
@@ -32,9 +32,20 @@ static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
*read = 0;
if(! NIL_P(string)) {
- void * str = (void *)StringValuePtr(string);
- *read = (size_t)RSTRING_LEN(string);
- memcpy(buf, str, *read);
+ char * str = StringValuePtr(string);
+ size_t len = (size_t)RSTRING_LEN(string);
+
+ /* IO#read(size) is documented to return at most `size` bytes, but a
+ * misbehaving IO-like object may return more. Clamp the copy to the
+ * buffer libyaml gave us to avoid writing past its end, rounding down
+ * to a character boundary so a multibyte character is never split. */
+ if(len > size) {
+ rb_encoding * enc = rb_enc_get(string);
+ len = (size_t)(rb_enc_left_char_head(str, str + size, str + len, enc) - str);
+ }
+
+ *read = len;
+ memcpy(buf, str, len);
}
return 1;
@@ -80,23 +91,23 @@ static VALUE allocate(VALUE klass)
static VALUE make_exception(yaml_parser_t * parser, VALUE path)
{
if (parser->error == YAML_MEMORY_ERROR) {
- return rb_eNoMemError;
+ return rb_eNoMemError;
} else {
- size_t line, column;
- VALUE ePsychSyntaxError;
+ size_t line, column;
+ VALUE ePsychSyntaxError;
- line = parser->context_mark.line + 1;
- column = parser->context_mark.column + 1;
+ line = parser->context_mark.line + 1;
+ column = parser->context_mark.column + 1;
- ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
+ ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
- return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
- path,
- SIZET2NUM(line),
- SIZET2NUM(column),
- SIZET2NUM(parser->problem_offset),
- parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
- parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
+ return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
+ path,
+ SIZET2NUM(line),
+ SIZET2NUM(column),
+ SIZET2NUM(parser->problem_offset),
+ parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
+ parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
}
}
@@ -108,18 +119,18 @@ static VALUE transcode_string(VALUE src, int * parser_encoding)
int source_encoding = rb_enc_get_index(src);
if (source_encoding == utf8) {
- *parser_encoding = YAML_UTF8_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
}
if (source_encoding == utf16le) {
- *parser_encoding = YAML_UTF16LE_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF16LE_ENCODING;
+ return src;
}
if (source_encoding == utf16be) {
- *parser_encoding = YAML_UTF16BE_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF16BE_ENCODING;
+ return src;
}
src = rb_str_export_to_enc(src, rb_utf8_encoding());
@@ -138,36 +149,36 @@ static VALUE transcode_io(VALUE src, int * parser_encoding)
/* if no encoding is returned, assume ascii8bit. */
if (NIL_P(io_external_encoding)) {
- io_external_enc_index = rb_ascii8bit_encindex();
+ io_external_enc_index = rb_ascii8bit_encindex();
} else {
- io_external_enc_index = rb_to_encoding_index(io_external_encoding);
+ io_external_enc_index = rb_to_encoding_index(io_external_encoding);
}
/* Treat US-ASCII as utf_8 */
if (io_external_enc_index == rb_usascii_encindex()) {
- *parser_encoding = YAML_UTF8_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
}
if (io_external_enc_index == rb_utf8_encindex()) {
- *parser_encoding = YAML_UTF8_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
}
if (io_external_enc_index == rb_enc_find_index("UTF-16LE")) {
- *parser_encoding = YAML_UTF16LE_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF16LE_ENCODING;
+ return src;
}
if (io_external_enc_index == rb_enc_find_index("UTF-16BE")) {
- *parser_encoding = YAML_UTF16BE_ENCODING;
- return src;
+ *parser_encoding = YAML_UTF16BE_ENCODING;
+ return src;
}
/* Just guess on ASCII-8BIT */
if (io_external_enc_index == rb_ascii8bit_encindex()) {
- *parser_encoding = YAML_ANY_ENCODING;
- return src;
+ *parser_encoding = YAML_ANY_ENCODING;
+ return src;
}
/* If the external encoding is something we don't know how to handle,
@@ -261,238 +272,238 @@ static VALUE parse(VALUE self, VALUE handler, VALUE yaml, VALUE path)
yaml_parser_initialize(parser);
if (rb_respond_to(yaml, id_read)) {
- yaml = transcode_io(yaml, &parser_encoding);
- yaml_parser_set_encoding(parser, parser_encoding);
- yaml_parser_set_input(parser, io_reader, (void *)yaml);
+ yaml = transcode_io(yaml, &parser_encoding);
+ yaml_parser_set_encoding(parser, parser_encoding);
+ yaml_parser_set_input(parser, io_reader, (void *)yaml);
} else {
- StringValue(yaml);
- yaml = transcode_string(yaml, &parser_encoding);
- yaml_parser_set_encoding(parser, parser_encoding);
- yaml_parser_set_input_string(
- parser,
- (const unsigned char *)RSTRING_PTR(yaml),
- (size_t)RSTRING_LEN(yaml)
- );
+ StringValue(yaml);
+ yaml = transcode_string(yaml, &parser_encoding);
+ yaml_parser_set_encoding(parser, parser_encoding);
+ yaml_parser_set_input_string(
+ parser,
+ (const unsigned char *)RSTRING_PTR(yaml),
+ (size_t)RSTRING_LEN(yaml)
+ );
}
while(!done) {
- VALUE event_args[5];
- VALUE start_line, start_column, end_line, end_column;
-
- if(parser->error || !yaml_parser_parse(parser, &event)) {
- VALUE exception;
-
- exception = make_exception(parser, path);
- yaml_parser_delete(parser);
- yaml_parser_initialize(parser);
-
- rb_exc_raise(exception);
- }
-
- start_line = SIZET2NUM(event.start_mark.line);
- start_column = SIZET2NUM(event.start_mark.column);
- end_line = SIZET2NUM(event.end_mark.line);
- end_column = SIZET2NUM(event.end_mark.column);
-
- event_args[0] = handler;
- event_args[1] = start_line;
- event_args[2] = start_column;
- event_args[3] = end_line;
- event_args[4] = end_column;
- rb_protect(protected_event_location, (VALUE)event_args, &state);
-
- switch(event.type) {
- case YAML_STREAM_START_EVENT:
- {
- VALUE args[2];
-
- args[0] = handler;
- args[1] = INT2NUM(event.data.stream_start.encoding);
- rb_protect(protected_start_stream, (VALUE)args, &state);
- }
- break;
- case YAML_DOCUMENT_START_EVENT:
- {
- VALUE args[4];
- /* Get a list of tag directives (if any) */
- VALUE tag_directives = rb_ary_new();
- /* Grab the document version */
- VALUE version = event.data.document_start.version_directive ?
- rb_ary_new3(
- (long)2,
- INT2NUM(event.data.document_start.version_directive->major),
- INT2NUM(event.data.document_start.version_directive->minor)
- ) : rb_ary_new();
-
- if(event.data.document_start.tag_directives.start) {
- yaml_tag_directive_t *start =
- event.data.document_start.tag_directives.start;
- yaml_tag_directive_t *end =
- event.data.document_start.tag_directives.end;
- for(; start != end; start++) {
- VALUE handle = Qnil;
- VALUE prefix = Qnil;
- if(start->handle) {
- handle = rb_str_new2((const char *)start->handle);
- PSYCH_TRANSCODE(handle, encoding, internal_enc);
- }
-
- if(start->prefix) {
- prefix = rb_str_new2((const char *)start->prefix);
- PSYCH_TRANSCODE(prefix, encoding, internal_enc);
- }
-
- rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
- }
- }
- args[0] = handler;
- args[1] = version;
- args[2] = tag_directives;
- args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse;
- rb_protect(protected_start_document, (VALUE)args, &state);
- }
- break;
- case YAML_DOCUMENT_END_EVENT:
- {
- VALUE args[2];
-
- args[0] = handler;
- args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse;
- rb_protect(protected_end_document, (VALUE)args, &state);
- }
- break;
- case YAML_ALIAS_EVENT:
- {
- VALUE args[2];
- VALUE alias = Qnil;
- if(event.data.alias.anchor) {
- alias = rb_str_new2((const char *)event.data.alias.anchor);
- PSYCH_TRANSCODE(alias, encoding, internal_enc);
- }
-
- args[0] = handler;
- args[1] = alias;
- rb_protect(protected_alias, (VALUE)args, &state);
- }
- break;
- case YAML_SCALAR_EVENT:
- {
- VALUE args[7];
- VALUE anchor = Qnil;
- VALUE tag = Qnil;
- VALUE plain_implicit, quoted_implicit, style;
- VALUE val = rb_str_new(
- (const char *)event.data.scalar.value,
- (long)event.data.scalar.length
- );
-
- PSYCH_TRANSCODE(val, encoding, internal_enc);
-
- if(event.data.scalar.anchor) {
- anchor = rb_str_new2((const char *)event.data.scalar.anchor);
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
- }
-
- if(event.data.scalar.tag) {
- tag = rb_str_new2((const char *)event.data.scalar.tag);
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
- }
-
- plain_implicit =
- event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue;
-
- quoted_implicit =
- event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
-
- style = INT2NUM(event.data.scalar.style);
-
- args[0] = handler;
- args[1] = val;
- args[2] = anchor;
- args[3] = tag;
- args[4] = plain_implicit;
- args[5] = quoted_implicit;
- args[6] = style;
- rb_protect(protected_scalar, (VALUE)args, &state);
- }
- break;
- case YAML_SEQUENCE_START_EVENT:
- {
- VALUE args[5];
- VALUE anchor = Qnil;
- VALUE tag = Qnil;
- VALUE implicit, style;
- if(event.data.sequence_start.anchor) {
- anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
- }
-
- tag = Qnil;
- if(event.data.sequence_start.tag) {
- tag = rb_str_new2((const char *)event.data.sequence_start.tag);
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
- }
-
- implicit =
- event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
-
- style = INT2NUM(event.data.sequence_start.style);
-
- args[0] = handler;
- args[1] = anchor;
- args[2] = tag;
- args[3] = implicit;
- args[4] = style;
-
- rb_protect(protected_start_sequence, (VALUE)args, &state);
- }
- break;
- case YAML_SEQUENCE_END_EVENT:
- rb_protect(protected_end_sequence, handler, &state);
- break;
- case YAML_MAPPING_START_EVENT:
- {
- VALUE args[5];
- VALUE anchor = Qnil;
- VALUE tag = Qnil;
- VALUE implicit, style;
- if(event.data.mapping_start.anchor) {
- anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
- }
-
- if(event.data.mapping_start.tag) {
- tag = rb_str_new2((const char *)event.data.mapping_start.tag);
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
- }
-
- implicit =
- event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
-
- style = INT2NUM(event.data.mapping_start.style);
-
- args[0] = handler;
- args[1] = anchor;
- args[2] = tag;
- args[3] = implicit;
- args[4] = style;
-
- rb_protect(protected_start_mapping, (VALUE)args, &state);
- }
- break;
- case YAML_MAPPING_END_EVENT:
- rb_protect(protected_end_mapping, handler, &state);
- break;
- case YAML_NO_EVENT:
- rb_protect(protected_empty, handler, &state);
- break;
- case YAML_STREAM_END_EVENT:
- rb_protect(protected_end_stream, handler, &state);
- done = 1;
- break;
- }
- yaml_event_delete(&event);
- if (state) rb_jump_tag(state);
+ VALUE event_args[5];
+ VALUE start_line, start_column, end_line, end_column;
+
+ if(parser->error || !yaml_parser_parse(parser, &event)) {
+ VALUE exception;
+
+ exception = make_exception(parser, path);
+ yaml_parser_delete(parser);
+ yaml_parser_initialize(parser);
+
+ rb_exc_raise(exception);
+ }
+
+ start_line = SIZET2NUM(event.start_mark.line);
+ start_column = SIZET2NUM(event.start_mark.column);
+ end_line = SIZET2NUM(event.end_mark.line);
+ end_column = SIZET2NUM(event.end_mark.column);
+
+ event_args[0] = handler;
+ event_args[1] = start_line;
+ event_args[2] = start_column;
+ event_args[3] = end_line;
+ event_args[4] = end_column;
+ rb_protect(protected_event_location, (VALUE)event_args, &state);
+
+ switch(event.type) {
+ case YAML_STREAM_START_EVENT:
+ {
+ VALUE args[2];
+
+ args[0] = handler;
+ args[1] = INT2NUM(event.data.stream_start.encoding);
+ rb_protect(protected_start_stream, (VALUE)args, &state);
+ }
+ break;
+ case YAML_DOCUMENT_START_EVENT:
+ {
+ VALUE args[4];
+ /* Get a list of tag directives (if any) */
+ VALUE tag_directives = rb_ary_new();
+ /* Grab the document version */
+ VALUE version = event.data.document_start.version_directive ?
+ rb_ary_new3(
+ (long)2,
+ INT2NUM(event.data.document_start.version_directive->major),
+ INT2NUM(event.data.document_start.version_directive->minor)
+ ) : rb_ary_new();
+
+ if(event.data.document_start.tag_directives.start) {
+ yaml_tag_directive_t *start =
+ event.data.document_start.tag_directives.start;
+ yaml_tag_directive_t *end =
+ event.data.document_start.tag_directives.end;
+ for(; start != end; start++) {
+ VALUE handle = Qnil;
+ VALUE prefix = Qnil;
+ if(start->handle) {
+ handle = rb_str_new2((const char *)start->handle);
+ PSYCH_TRANSCODE(handle, encoding, internal_enc);
+ }
+
+ if(start->prefix) {
+ prefix = rb_str_new2((const char *)start->prefix);
+ PSYCH_TRANSCODE(prefix, encoding, internal_enc);
+ }
+
+ rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
+ }
+ }
+ args[0] = handler;
+ args[1] = version;
+ args[2] = tag_directives;
+ args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse;
+ rb_protect(protected_start_document, (VALUE)args, &state);
+ }
+ break;
+ case YAML_DOCUMENT_END_EVENT:
+ {
+ VALUE args[2];
+
+ args[0] = handler;
+ args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse;
+ rb_protect(protected_end_document, (VALUE)args, &state);
+ }
+ break;
+ case YAML_ALIAS_EVENT:
+ {
+ VALUE args[2];
+ VALUE alias = Qnil;
+ if(event.data.alias.anchor) {
+ alias = rb_str_new2((const char *)event.data.alias.anchor);
+ PSYCH_TRANSCODE(alias, encoding, internal_enc);
+ }
+
+ args[0] = handler;
+ args[1] = alias;
+ rb_protect(protected_alias, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SCALAR_EVENT:
+ {
+ VALUE args[7];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE plain_implicit, quoted_implicit, style;
+ VALUE val = rb_str_new(
+ (const char *)event.data.scalar.value,
+ (long)event.data.scalar.length
+ );
+
+ PSYCH_TRANSCODE(val, encoding, internal_enc);
+
+ if(event.data.scalar.anchor) {
+ anchor = rb_str_new2((const char *)event.data.scalar.anchor);
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+ }
+
+ if(event.data.scalar.tag) {
+ tag = rb_str_new2((const char *)event.data.scalar.tag);
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+ }
+
+ plain_implicit =
+ event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue;
+
+ quoted_implicit =
+ event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM(event.data.scalar.style);
+
+ args[0] = handler;
+ args[1] = val;
+ args[2] = anchor;
+ args[3] = tag;
+ args[4] = plain_implicit;
+ args[5] = quoted_implicit;
+ args[6] = style;
+ rb_protect(protected_scalar, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SEQUENCE_START_EVENT:
+ {
+ VALUE args[5];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE implicit, style;
+ if(event.data.sequence_start.anchor) {
+ anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+ }
+
+ tag = Qnil;
+ if(event.data.sequence_start.tag) {
+ tag = rb_str_new2((const char *)event.data.sequence_start.tag);
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+ }
+
+ implicit =
+ event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM(event.data.sequence_start.style);
+
+ args[0] = handler;
+ args[1] = anchor;
+ args[2] = tag;
+ args[3] = implicit;
+ args[4] = style;
+
+ rb_protect(protected_start_sequence, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SEQUENCE_END_EVENT:
+ rb_protect(protected_end_sequence, handler, &state);
+ break;
+ case YAML_MAPPING_START_EVENT:
+ {
+ VALUE args[5];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE implicit, style;
+ if(event.data.mapping_start.anchor) {
+ anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+ }
+
+ if(event.data.mapping_start.tag) {
+ tag = rb_str_new2((const char *)event.data.mapping_start.tag);
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+ }
+
+ implicit =
+ event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM(event.data.mapping_start.style);
+
+ args[0] = handler;
+ args[1] = anchor;
+ args[2] = tag;
+ args[3] = implicit;
+ args[4] = style;
+
+ rb_protect(protected_start_mapping, (VALUE)args, &state);
+ }
+ break;
+ case YAML_MAPPING_END_EVENT:
+ rb_protect(protected_end_mapping, handler, &state);
+ break;
+ case YAML_NO_EVENT:
+ rb_protect(protected_empty, handler, &state);
+ break;
+ case YAML_STREAM_END_EVENT:
+ rb_protect(protected_end_stream, handler, &state);
+ done = 1;
+ break;
+ }
+ yaml_event_delete(&event);
+ if (state) rb_jump_tag(state);
}
return self;
@@ -562,4 +573,3 @@ void Init_psych_parser(void)
id_end_mapping = rb_intern("end_mapping");
id_event_location = rb_intern("event_location");
}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/psych/psych_to_ruby.c b/ext/psych/psych_to_ruby.c
index b388ff7754..3ab0138b52 100644
--- a/ext/psych/psych_to_ruby.c
+++ b/ext/psych/psych_to_ruby.c
@@ -10,7 +10,11 @@ static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
{
VALUE e = rb_obj_alloc(klass);
+#ifdef TRUFFLERUBY
+ rb_exc_set_message(e, mesg);
+#else
rb_iv_set(e, "mesg", mesg);
+#endif
return e;
}
@@ -36,4 +40,3 @@ void Init_psych_to_ruby(void)
rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
rb_define_private_method(class_loader, "path2class", path2class, 1);
}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/psych/psych_yaml_tree.c b/ext/psych/psych_yaml_tree.c
index 225655d127..bbd93f874d 100644
--- a/ext/psych/psych_yaml_tree.c
+++ b/ext/psych/psych_yaml_tree.c
@@ -9,4 +9,3 @@ void Init_psych_yaml_tree(void)
VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
cPsychVisitorsYamlTree = rb_define_class_under(visitors, "YAMLTree", visitor);
}
-/* vim: set noet sws=4 sw=4: */
diff --git a/ext/pty/depend b/ext/pty/depend
index d4d0d558ef..8fa018d084 100644
--- a/ext/pty/depend
+++ b/ext/pty/depend
@@ -138,6 +138,7 @@ pty.o: $(hdrdir)/ruby/internal/intern/re.h
pty.o: $(hdrdir)/ruby/internal/intern/ruby.h
pty.o: $(hdrdir)/ruby/internal/intern/select.h
pty.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+pty.o: $(hdrdir)/ruby/internal/intern/set.h
pty.o: $(hdrdir)/ruby/internal/intern/signal.h
pty.o: $(hdrdir)/ruby/internal/intern/sprintf.h
pty.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ pty.o: $(hdrdir)/ruby/internal/special_consts.h
pty.o: $(hdrdir)/ruby/internal/static_assert.h
pty.o: $(hdrdir)/ruby/internal/stdalign.h
pty.o: $(hdrdir)/ruby/internal/stdbool.h
+pty.o: $(hdrdir)/ruby/internal/stdckdint.h
pty.o: $(hdrdir)/ruby/internal/symbol.h
pty.o: $(hdrdir)/ruby/internal/value.h
pty.o: $(hdrdir)/ruby/internal/value_type.h
@@ -171,6 +173,7 @@ pty.o: $(hdrdir)/ruby/ruby.h
pty.o: $(hdrdir)/ruby/st.h
pty.o: $(hdrdir)/ruby/subst.h
pty.o: $(hdrdir)/ruby/util.h
+pty.o: $(top_srcdir)/id_table.h
pty.o: $(top_srcdir)/internal.h
pty.o: $(top_srcdir)/internal/array.h
pty.o: $(top_srcdir)/internal/compilers.h
diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb
index ba0c4286fd..ae2cb45d3c 100644
--- a/ext/pty/extconf.rb
+++ b/ext/pty/extconf.rb
@@ -13,11 +13,16 @@ if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
have_header("util.h") # OpenBSD openpty
util = have_library("util", "openpty")
end
- if have_func("posix_openpt") or
+ openpt = have_func("posix_openpt")
+ if openpt
+ have_func("ptsname_r") or have_func("ptsname")
+ end
+ if openpt or
(util or have_func("openpty")) or
have_func("_getpty") or
- have_func("ptsname") or
have_func("ioctl")
+ have_macro("HAVE_FCHMOD") or have_func("fchmod")
+ have_macro("HAVE_FCHOWN") or have_func("fchown")
create_makefile('pty')
end
end
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index acec33f9bf..3d5977707f 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -92,9 +92,13 @@ struct pty_info {
static void getDevice(int*, int*, char [DEVICELEN], int);
+static int start_new_session(char *errbuf, size_t errbuf_len);
+static int obtain_ctty(int master, int slave, const char *slavename, char *errbuf, size_t errbuf_len);
+static int drop_privilege(char *errbuf, size_t errbuf_len);
+
struct child_info {
int master, slave;
- char *slavename;
+ const char *slavename;
VALUE execarg_obj;
struct rb_execarg *eargp;
};
@@ -102,26 +106,42 @@ struct child_info {
static int
chfunc(void *data, char *errbuf, size_t errbuf_len)
{
- struct child_info *carg = data;
+ const struct child_info *carg = data;
int master = carg->master;
int slave = carg->slave;
+ const char *slavename = carg->slavename;
+
+ if (start_new_session(errbuf, errbuf_len))
+ return -1;
+
+ if (obtain_ctty(master, slave, slavename, errbuf, errbuf_len))
+ return -1;
+
+ if (drop_privilege(errbuf, errbuf_len))
+ return -1;
+
+ return rb_exec_async_signal_safe(carg->eargp, errbuf, errbuf_len);
+}
#define ERROR_EXIT(str) do { \
strlcpy(errbuf, (str), errbuf_len); \
return -1; \
} while (0)
- /*
- * Set free from process group and controlling terminal
- */
+/*
+ * Set free from process group and controlling terminal
+ */
+static int
+start_new_session(char *errbuf, size_t errbuf_len)
+{
#ifdef HAVE_SETSID
(void) setsid();
#else /* HAS_SETSID */
# ifdef HAVE_SETPGRP
-# ifdef SETGRP_VOID
+# ifdef SETPGRP_VOID
if (setpgrp() == -1)
ERROR_EXIT("setpgrp()");
-# else /* SETGRP_VOID */
+# else /* SETPGRP_VOID */
if (setpgrp(0, getpid()) == -1)
ERROR_EXIT("setpgrp()");
{
@@ -132,20 +152,25 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
ERROR_EXIT("ioctl(TIOCNOTTY)");
close(i);
}
-# endif /* SETGRP_VOID */
+# endif /* SETPGRP_VOID */
# endif /* HAVE_SETPGRP */
#endif /* HAS_SETSID */
+ return 0;
+}
- /*
- * obtain new controlling terminal
- */
+/*
+ * obtain new controlling terminal
+ */
+static int
+obtain_ctty(int master, int slave, const char *slavename, char *errbuf, size_t errbuf_len)
+{
#if defined(TIOCSCTTY)
close(master);
(void) ioctl(slave, TIOCSCTTY, (char *)0);
/* errors ignored for sun */
#else
close(slave);
- slave = rb_cloexec_open(carg->slavename, O_RDWR, 0);
+ slave = rb_cloexec_open(slavename, O_RDWR, 0);
if (slave < 0) {
ERROR_EXIT("open: pty slave");
}
@@ -155,14 +180,20 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
dup2(slave,0);
dup2(slave,1);
dup2(slave,2);
- if (slave < 0 || slave > 2) (void)!close(slave);
+ if (slave > 2) (void)!close(slave);
+ return 0;
+}
+
+static int
+drop_privilege(char *errbuf, size_t errbuf_len)
+{
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
if (seteuid(getuid())) ERROR_EXIT("seteuid()");
#endif
+ return 0;
+}
- return rb_exec_async_signal_safe(carg->eargp, errbuf, sizeof(errbuf_len));
#undef ERROR_EXIT
-}
static void
establishShell(int argc, VALUE *argv, struct pty_info *info,
@@ -184,9 +215,13 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
else {
#if defined HAVE_PWD_H
const char *username = getenv("USER");
- struct passwd *pwent = getpwnam(username ? username : getlogin());
- if (pwent && pwent->pw_shell)
- shellname = pwent->pw_shell;
+ if (username == NULL)
+ username = getlogin();
+ if (username != NULL) {
+ struct passwd *pwent = getpwnam(username);
+ if (pwent && pwent->pw_shell)
+ shellname = pwent->pw_shell;
+ }
#endif
}
v = rb_str_new2(shellname);
@@ -225,12 +260,37 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
RB_GC_GUARD(carg.execarg_obj);
}
-#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_OPENPTY) || defined(HAVE_PTSNAME)
+#if (defined(HAVE_POSIX_OPENPT) || defined(HAVE_PTSNAME)) && !defined(HAVE_PTSNAME_R)
+/* glibc only, not obsolete interface on Tru64 or HP-UX */
static int
-no_mesg(char *slavedevice, int nomesg)
+ptsname_r(int fd, char *buf, size_t buflen)
+{
+ extern char *ptsname(int);
+ char *name = ptsname(fd);
+ if (!name) return -1;
+ strlcpy(buf, name, buflen);
+ return 0;
+}
+# define HAVE_PTSNAME_R 1
+#endif
+
+#ifdef HAVE_FCHMOD
+# define change_mode(name, fd, mode) fchmod(fd, mode)
+#else
+# define change_mode(name, fd, mode) chmod(name, mode)
+#endif
+#ifdef HAVE_FCHOWN
+# define change_owner(name, fd, uid, gid) fchown(fd, uid, gid)
+#else
+# define change_owner(name, fd, uid, gid) chown(name, uid, gid)
+#endif
+
+#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_OPENPTY) || defined(HAVE_PTSNAME_R)
+static inline int
+prevent_messages(const char *slavedevice, int fd, int nomesg)
{
if (nomesg)
- return chmod(slavedevice, 0600);
+ return change_mode(slavedevice, fd, 0600);
else
return 0;
}
@@ -258,13 +318,19 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
/* Unix98 PTY */
int masterfd = -1, slavefd = -1;
char *slavedevice;
+ struct sigaction dfl, old;
+
+ dfl.sa_handler = SIG_DFL;
+ dfl.sa_flags = 0;
+ sigemptyset(&dfl.sa_mask);
#if defined(__sun) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
/* FreeBSD 9.2 or later supports O_CLOEXEC
* http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
- if (rb_grantpt(masterfd) == -1) goto error;
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
rb_fd_fix_cloexec(masterfd);
#else
{
@@ -278,12 +344,15 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if ((masterfd = posix_openpt(flags)) == -1) goto error;
}
rb_fd_fix_cloexec(masterfd);
- if (rb_grantpt(masterfd) == -1) goto error;
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
#endif
+ if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
if (unlockpt(masterfd) == -1) goto error;
- if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
- if (no_mesg(slavedevice, nomesg) == -1) goto error;
+ if (ptsname_r(masterfd, SlaveName, DEVICELEN) != 0) goto error;
+ slavedevice = SlaveName;
if ((slavefd = rb_cloexec_open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
+ if (prevent_messages(slavedevice, slavefd, nomesg) == -1) goto error;
rb_update_max_fd(slavefd);
#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
@@ -294,9 +363,10 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
*master = masterfd;
*slave = slavefd;
- strlcpy(SlaveName, slavedevice, DEVICELEN);
return 0;
+ grantpt_error:
+ sigaction(SIGCHLD, &old, NULL);
error:
if (slavefd != -1) close(slavefd);
if (masterfd != -1) close(masterfd);
@@ -316,7 +386,9 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
}
rb_fd_fix_cloexec(*master);
rb_fd_fix_cloexec(*slave);
- if (no_mesg(SlaveName, nomesg) == -1) {
+ if (prevent_messages(SlaveName, *slave, nomesg) == -1) {
+ close(*master);
+ close(*slave);
if (!fail) return -1;
rb_raise(rb_eRuntimeError, "can't chmod slave pty");
}
@@ -346,23 +418,27 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
char *slavedevice;
void (*s)();
- extern char *ptsname(int);
extern int unlockpt(int);
+ extern int grantpt(int);
#if defined(__sun)
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
- if(rb_grantpt(masterfd) == -1) goto error;
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
rb_fd_fix_cloexec(masterfd);
#else
if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
rb_update_max_fd(masterfd);
- if(rb_grantpt(masterfd) == -1) goto error;
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
#endif
+ signal(SIGCHLD, s);
if(unlockpt(masterfd) == -1) goto error;
- if((slavedevice = ptsname(masterfd)) == NULL) goto error;
- if (no_mesg(slavedevice, nomesg) == -1) goto error;
+ if (ptsname_r(masterfd, SlaveName, DEVICELEN) != 0) goto error;
+ slavedevice = SlaveName;
if((slavefd = rb_cloexec_open(slavedevice, O_RDWR, 0)) == -1) goto error;
+ if (prevent_messages(slavedevice, slavefd, nomesg) == -1) goto error;
rb_update_max_fd(slavefd);
#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
if(ioctl_I_PUSH(slavefd, "ptem") == -1) goto error;
@@ -371,7 +447,6 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
#endif
*master = masterfd;
*slave = slavefd;
- strlcpy(SlaveName, slavedevice, DEVICELEN);
return 0;
error:
@@ -416,8 +491,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
if ((slavefd = rb_cloexec_open(SlaveName,O_RDWR,0)) >= 0) {
rb_update_max_fd(slavefd);
*slave = slavefd;
- if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
- if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
+ if (change_owner(SlaveName, slavefd, getuid(), getgid()) != 0) goto error;
+ if (change_mode(SlaveName, slavefd, nomesg ? 0600 : 0622) != 0) goto error;
return 0;
}
close(masterfd);
@@ -448,8 +523,10 @@ pty_close_pty(VALUE assoc)
for (i = 0; i < 2; i++) {
io = rb_ary_entry(assoc, i);
- if (RB_TYPE_P(io, T_FILE) && 0 <= RFILE(io)->fptr->fd)
+ if (RB_TYPE_P(io, T_FILE)) {
+ /* it's OK to call rb_io_close again even if it's already closed */
rb_io_close(io);
+ }
}
return Qnil;
}
@@ -499,28 +576,21 @@ pty_open(VALUE klass)
{
int master_fd, slave_fd;
char slavename[DEVICELEN];
- VALUE master_io, slave_file;
- rb_io_t *master_fptr, *slave_fptr;
- VALUE assoc;
getDevice(&master_fd, &slave_fd, slavename, 1);
- master_io = rb_obj_alloc(rb_cIO);
- MakeOpenFile(master_io, master_fptr);
- master_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX;
- master_fptr->fd = master_fd;
- master_fptr->pathv = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));
+ VALUE master_path = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));
+ VALUE master_io = rb_io_open_descriptor(rb_cIO, master_fd, FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX, master_path, RUBY_IO_TIMEOUT_DEFAULT, NULL);
+
+ VALUE slave_path = rb_obj_freeze(rb_str_new_cstr(slavename));
+ VALUE slave_file = rb_io_open_descriptor(rb_cFile, slave_fd, FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY, slave_path, RUBY_IO_TIMEOUT_DEFAULT, NULL);
- slave_file = rb_obj_alloc(rb_cFile);
- MakeOpenFile(slave_file, slave_fptr);
- slave_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY;
- slave_fptr->fd = slave_fd;
- slave_fptr->pathv = rb_obj_freeze(rb_str_new_cstr(slavename));
+ VALUE assoc = rb_assoc_new(master_io, slave_file);
- assoc = rb_assoc_new(master_io, slave_file);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, assoc, pty_close_pty, assoc);
}
+
return assoc;
}
@@ -553,9 +623,17 @@ pty_detach_process(VALUE v)
* +env+ is an optional hash that provides additional environment variables to the spawned pty.
*
* # sets FOO to "bar"
- * PTY.spawn({"FOO"=>"bar"}, "printenv", "FOO") { |r,w,pid| p r.read } #=> "bar\r\n"
+ * PTY.spawn({"FOO"=>"bar"}, "printenv", "FOO") do |r, w, pid|
+ * p r.read #=> "bar\r\n"
+ * ensure
+ * r.close; w.close; Process.wait(pid)
+ * end
* # unsets FOO
- * PTY.spawn({"FOO"=>nil}, "printenv", "FOO") { |r,w,pid| p r.read } #=> ""
+ * PTY.spawn({"FOO"=>nil}, "printenv", "FOO") do |r, w, pid|
+ * p r.read #=> ""
+ * ensure
+ * r.close; w.close; Process.wait(pid)
+ * end
*
* +command+ and +command_line+ are the full commands to run, given a String.
* Any additional +arguments+ will be passed to the command.
@@ -571,36 +649,42 @@ pty_detach_process(VALUE v)
* standard output and standard error
* +w+:: A writable IO that is the command's standard input
* +pid+:: The process identifier for the command.
+ *
+ * === Clean up
+ *
+ * This method does not clean up like closing IOs or waiting for child
+ * process, except that the process is detached in the block form to
+ * prevent it from becoming a zombie (see Process.detach). Any other
+ * cleanup is the responsibility of the caller. If waiting for +pid+,
+ * be sure to close both +r+ and +w+ before doing so; doing it in the
+ * reverse order may cause deadlock on some OSes.
*/
static VALUE
pty_getpty(int argc, VALUE *argv, VALUE self)
{
VALUE res;
struct pty_info info;
- rb_io_t *wfptr,*rfptr;
- VALUE rport = rb_obj_alloc(rb_cFile);
- VALUE wport = rb_obj_alloc(rb_cFile);
char SlaveName[DEVICELEN];
- MakeOpenFile(rport, rfptr);
- MakeOpenFile(wport, wfptr);
-
establishShell(argc, argv, &info, SlaveName);
- rfptr->mode = rb_io_modestr_fmode("r");
- rfptr->fd = info.fd;
- rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName));
+ VALUE pty_path = rb_obj_freeze(rb_str_new_cstr(SlaveName));
+ VALUE rport = rb_io_open_descriptor(
+ rb_cFile, info.fd, FMODE_READABLE, pty_path, RUBY_IO_TIMEOUT_DEFAULT, NULL
+ );
- wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC;
- wfptr->fd = rb_cloexec_dup(info.fd);
- if (wfptr->fd == -1)
+ int wpty_fd = rb_cloexec_dup(info.fd);
+ if (wpty_fd == -1) {
rb_sys_fail("dup()");
- rb_update_max_fd(wfptr->fd);
- wfptr->pathv = rfptr->pathv;
+ }
+ VALUE wport = rb_io_open_descriptor(
+ rb_cFile, wpty_fd, FMODE_WRITABLE | FMODE_TRUNC | FMODE_CREATE | FMODE_SYNC,
+ pty_path, RUBY_IO_TIMEOUT_DEFAULT, NULL
+ );
res = rb_ary_new2(3);
- rb_ary_store(res,0,(VALUE)rport);
- rb_ary_store(res,1,(VALUE)wport);
+ rb_ary_store(res, 0, rport);
+ rb_ary_store(res, 1, wport);
rb_ary_store(res,2,PIDT2NUM(info.child_pid));
if (rb_block_given_p()) {
@@ -753,8 +837,13 @@ void
Init_pty(void)
{
cPTY = rb_define_module("PTY");
- /* :nodoc: */
- rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
+#if 1
+ rb_define_module_function(cPTY,"get""pty",pty_getpty,-1);
+#else /* for RDoc */
+ /* show getpty as an alias of spawn */
+ VALUE sPTY = rb_singleton_class(cPTY);
+ rb_define_alias(sPTY, "getpty", "spawn");
+#endif
rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
rb_define_singleton_method(cPTY,"check",pty_check,-1);
rb_define_singleton_method(cPTY,"open",pty_open,0);
diff --git a/ext/racc/cparse/README b/ext/racc/cparse/README
deleted file mode 100644
index 550e8d49fe..0000000000
--- a/ext/racc/cparse/README
+++ /dev/null
@@ -1,11 +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://i.loveruby.net/en/projects/racc
- - https://github.com/ruby/racc
-
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
deleted file mode 100644
index f752eb7749..0000000000
--- a/ext/racc/cparse/cparse.c
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
-
- cparse.c -- Racc Runtime Core
-
- Copyright (c) 1999-2006 Minero Aoki
-
- This library is free software.
- You can distribute/modify this program under the same terms of ruby.
-
-*/
-
-#include <ruby.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-/* -----------------------------------------------------------------------
- Important Constants
------------------------------------------------------------------------ */
-
-#define RACC_VERSION "1.6.2"
-
-#define DEFAULT_TOKEN -1
-#define ERROR_TOKEN 1
-#define FINAL_TOKEN 0
-
-#define vDEFAULT_TOKEN INT2FIX(DEFAULT_TOKEN)
-#define vERROR_TOKEN INT2FIX(ERROR_TOKEN)
-#define vFINAL_TOKEN INT2FIX(FINAL_TOKEN)
-
-/* -----------------------------------------------------------------------
- File Local Variables
------------------------------------------------------------------------ */
-
-static VALUE RaccBug;
-static VALUE CparseParams;
-
-static ID id_yydebug;
-static ID id_nexttoken;
-static ID id_onerror;
-static ID id_noreduce;
-static ID id_errstatus;
-
-static ID id_d_shift;
-static ID id_d_reduce;
-static ID id_d_accept;
-static ID id_d_read_token;
-static ID id_d_next_state;
-static ID id_d_e_pop;
-
-/* -----------------------------------------------------------------------
- Utils
------------------------------------------------------------------------ */
-
-/* For backward compatibility */
-#ifndef ID2SYM
-# define ID2SYM(i) ULONG2NUM(i)
-#endif
-#ifndef SYM2ID
-# define SYM2ID(v) ((ID)NUM2ULONG(v))
-#endif
-#ifndef SYMBOL_P
-# define SYMBOL_P(v) FIXNUM_P(v)
-#endif
-#ifndef LONG2NUM
-# define LONG2NUM(i) INT2NUM(i)
-#endif
-
-#ifndef HAVE_RB_ARY_SUBSEQ
-# define rb_ary_subseq(ary, beg, len) rb_ary_new4(len, RARRAY_PTR(ary) + beg)
-#endif
-
-static ID value_to_id _((VALUE v));
-static inline long num_to_long _((VALUE n));
-
-static ID
-value_to_id(VALUE v)
-{
- if (! SYMBOL_P(v)) {
- rb_raise(rb_eTypeError, "not symbol");
- }
- return SYM2ID(v);
-}
-
-static inline long
-num_to_long(VALUE n)
-{
- return NUM2LONG(n);
-}
-
-#define AREF(s, idx) \
- ((0 <= idx && idx < RARRAY_LEN(s)) ? rb_ary_entry(s, idx) : Qnil)
-
-/* -----------------------------------------------------------------------
- Parser Stack Interfaces
------------------------------------------------------------------------ */
-
-static VALUE get_stack_tail _((VALUE stack, long len));
-static void cut_stack_tail _((VALUE stack, long len));
-
-static VALUE
-get_stack_tail(VALUE stack, long len)
-{
- if (len < 0) return Qnil; /* system error */
- if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
- return rb_ary_subseq(stack, RARRAY_LEN(stack) - len, len);
-}
-
-static void
-cut_stack_tail(VALUE stack, long len)
-{
- while (len > 0) {
- rb_ary_pop(stack);
- len--;
- }
-}
-
-#define STACK_INIT_LEN 64
-#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
-#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
-#define POP(s) rb_ary_pop(s)
-#define LAST_I(s) \
- ((RARRAY_LEN(s) > 0) ? rb_ary_entry(s, RARRAY_LEN(s) - 1) : Qnil)
-#define GET_TAIL(s, len) get_stack_tail(s, len)
-#define CUT_TAIL(s, len) cut_stack_tail(s, len)
-
-/* -----------------------------------------------------------------------
- struct cparse_params
------------------------------------------------------------------------ */
-
-struct cparse_params {
- VALUE value_v; /* VALUE version of this struct */
-
- VALUE parser; /* parser object */
-
- int lex_is_iterator;
- VALUE lexer; /* scanner object */
- ID lexmid; /* name of scanner method (must be an iterator) */
-
- /* State transition tables (immutable)
- Data structure is from Dragon Book 4.9 */
- /* action table */
- VALUE action_table;
- VALUE action_check;
- VALUE action_default;
- VALUE action_pointer;
- /* goto table */
- VALUE goto_table;
- VALUE goto_check;
- VALUE goto_default;
- VALUE goto_pointer;
-
- long nt_base; /* NonTerminal BASE index */
- VALUE reduce_table; /* reduce data table */
- VALUE token_table; /* token conversion table */
-
- /* parser stacks and parameters */
- VALUE state;
- long curstate;
- VALUE vstack;
- VALUE tstack;
- VALUE t;
- long shift_n;
- long reduce_n;
- long ruleno;
-
- long errstatus; /* nonzero in error recovering mode */
- long nerr; /* number of error */
-
- int use_result_var;
-
- VALUE retval; /* return value of parser routine */
- long fin; /* parse result status */
-#define CP_FIN_ACCEPT 1
-#define CP_FIN_EOT 2
-#define CP_FIN_CANTPOP 3
-
- int debug; /* user level debug */
- int sys_debug; /* system level debug */
-
- long i; /* table index */
-};
-
-/* -----------------------------------------------------------------------
- Parser Main Routines
------------------------------------------------------------------------ */
-
-static VALUE racc_cparse _((VALUE parser, VALUE arg, VALUE sysdebug));
-static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
- VALUE arg, VALUE sysdebug));
-
-static void call_lexer _((struct cparse_params *v));
-static VALUE lexer_i _((RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data)));
-
-static VALUE assert_array _((VALUE a));
-static long assert_integer _((VALUE n));
-static VALUE assert_hash _((VALUE h));
-static VALUE initialize_params _((VALUE vparams, VALUE parser, VALUE arg,
- VALUE lexer, VALUE lexmid));
-static void cparse_params_mark _((void *ptr));
-static size_t cparse_params_memsize _((const void *ptr));
-
-static void parse_main _((struct cparse_params *v,
- VALUE tok, VALUE val, int resume));
-static void extract_user_token _((struct cparse_params *v,
- VALUE block_args, VALUE *tok, VALUE *val));
-static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
-static int reduce _((struct cparse_params* v, long act));
-static rb_block_call_func reduce0;
-
-#ifdef DEBUG
-# define D_puts(msg) if (v->sys_debug) puts(msg)
-# define D_printf(fmt,arg) if (v->sys_debug) printf(fmt,arg)
-#else
-# define D_puts(msg)
-# define D_printf(fmt,arg)
-#endif
-
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 1
-
-static const rb_data_type_t cparse_params_type = {
- "racc/cparse",
- {
- cparse_params_mark,
- RUBY_TYPED_DEFAULT_FREE,
- cparse_params_memsize,
- },
-#ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
-#endif
-};
-
-static VALUE
-racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug)
-{
- VALUE vparams;
- struct cparse_params *v;
-
- vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
- &cparse_params_type, v);
- D_puts("starting cparse");
- v->sys_debug = RTEST(sysdebug);
- vparams = initialize_params(vparams, parser, arg, Qnil, Qnil);
- v->lex_is_iterator = FALSE;
- parse_main(v, Qnil, Qnil, 0);
-
- RB_GC_GUARD(vparams);
- return v->retval;
-}
-
-static VALUE
-racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
-{
- VALUE vparams;
- struct cparse_params *v;
-
- vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
- &cparse_params_type, v);
- v->sys_debug = RTEST(sysdebug);
- D_puts("start C yyparse");
- vparams = initialize_params(vparams, parser, arg, lexer, lexmid);
- v->lex_is_iterator = TRUE;
- D_puts("params initialized");
- parse_main(v, Qnil, Qnil, 0);
- call_lexer(v);
- if (!v->fin) {
- rb_raise(rb_eArgError, "%s() is finished before EndOfToken",
- rb_id2name(v->lexmid));
- }
-
- RB_GC_GUARD(vparams);
- return v->retval;
-}
-
-#ifdef HAVE_RB_BLOCK_CALL
-static void
-call_lexer(struct cparse_params *v)
-{
- rb_block_call(v->lexer, v->lexmid, 0, NULL, lexer_i, v->value_v);
-}
-#else
-static VALUE
-lexer_iter(VALUE data)
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
-
- rb_funcall(v->lexer, v->lexmid, 0);
- return Qnil;
-}
-
-static void
-call_lexer(struct cparse_params *v)
-{
- rb_iterate(lexer_iter, v->value_v, lexer_i, v->value_v);
-}
-#endif
-
-static VALUE
-lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
- VALUE tok, val;
-
- if (v->fin)
- rb_raise(rb_eArgError, "extra token after EndOfToken");
- extract_user_token(v, block_args, &tok, &val);
- parse_main(v, tok, val, 1);
- if (v->fin && v->fin != CP_FIN_ACCEPT)
- rb_iter_break();
- return Qnil;
-}
-
-static VALUE
-assert_array(VALUE a)
-{
- Check_Type(a, T_ARRAY);
- return a;
-}
-
-static VALUE
-assert_hash(VALUE h)
-{
- Check_Type(h, T_HASH);
- return h;
-}
-
-static long
-assert_integer(VALUE n)
-{
- return NUM2LONG(n);
-}
-
-static VALUE
-initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
-{
- struct cparse_params *v = rb_check_typeddata(vparams, &cparse_params_type);
-
- v->value_v = vparams;
- v->parser = parser;
- v->lexer = lexer;
- if (! NIL_P(lexmid))
- v->lexmid = value_to_id(lexmid);
-
- v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
-
- Check_Type(arg, T_ARRAY);
- if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
- rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
- v->action_table = assert_array (rb_ary_entry(arg, 0));
- v->action_check = assert_array (rb_ary_entry(arg, 1));
- v->action_default = assert_array (rb_ary_entry(arg, 2));
- v->action_pointer = assert_array (rb_ary_entry(arg, 3));
- v->goto_table = assert_array (rb_ary_entry(arg, 4));
- v->goto_check = assert_array (rb_ary_entry(arg, 5));
- v->goto_default = assert_array (rb_ary_entry(arg, 6));
- v->goto_pointer = assert_array (rb_ary_entry(arg, 7));
- v->nt_base = assert_integer(rb_ary_entry(arg, 8));
- v->reduce_table = assert_array (rb_ary_entry(arg, 9));
- v->token_table = assert_hash (rb_ary_entry(arg, 10));
- v->shift_n = assert_integer(rb_ary_entry(arg, 11));
- v->reduce_n = assert_integer(rb_ary_entry(arg, 12));
- if (RARRAY_LEN(arg) > 13) {
- v->use_result_var = RTEST(rb_ary_entry(arg, 13));
- }
- else {
- v->use_result_var = TRUE;
- }
-
- v->tstack = v->debug ? NEW_STACK() : Qnil;
- v->vstack = NEW_STACK();
- v->state = NEW_STACK();
- v->curstate = 0;
- PUSH(v->state, INT2FIX(0));
- v->t = INT2FIX(FINAL_TOKEN + 1); /* must not init to FINAL_TOKEN */
- v->nerr = 0;
- v->errstatus = 0;
- rb_ivar_set(parser, id_errstatus, LONG2NUM(v->errstatus));
-
- v->retval = Qnil;
- v->fin = 0;
-
- v->lex_is_iterator = FALSE;
-
- rb_iv_set(parser, "@vstack", v->vstack);
- if (v->debug) {
- rb_iv_set(parser, "@tstack", v->tstack);
- }
- else {
- rb_iv_set(parser, "@tstack", Qnil);
- }
-
- return vparams;
-}
-
-static void
-cparse_params_mark(void *ptr)
-{
- struct cparse_params *v = (struct cparse_params*)ptr;
-
- rb_gc_mark(v->value_v);
- rb_gc_mark(v->parser);
- rb_gc_mark(v->lexer);
- rb_gc_mark(v->action_table);
- rb_gc_mark(v->action_check);
- rb_gc_mark(v->action_default);
- rb_gc_mark(v->action_pointer);
- rb_gc_mark(v->goto_table);
- rb_gc_mark(v->goto_check);
- rb_gc_mark(v->goto_default);
- rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->reduce_table);
- rb_gc_mark(v->token_table);
- rb_gc_mark(v->state);
- rb_gc_mark(v->vstack);
- rb_gc_mark(v->tstack);
- rb_gc_mark(v->t);
- rb_gc_mark(v->retval);
-}
-
-static size_t
-cparse_params_memsize(const void *ptr)
-{
- return sizeof(struct cparse_params);
-}
-
-static void
-extract_user_token(struct cparse_params *v, VALUE block_args,
- VALUE *tok, VALUE *val)
-{
- if (NIL_P(block_args)) {
- /* EOF */
- *tok = Qfalse;
- *val = rb_str_new("$", 1);
- return;
- }
-
- if (!RB_TYPE_P(block_args, T_ARRAY)) {
- rb_raise(rb_eTypeError,
- "%s() %s %"PRIsVALUE" (must be Array[2])",
- v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
- v->lex_is_iterator ? "yielded" : "returned",
- rb_obj_class(block_args));
- }
- if (RARRAY_LEN(block_args) != 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));
- }
- *tok = AREF(block_args, 0);
- *val = AREF(block_args, 1);
-}
-
-#define SHIFT(v,act,tok,val) shift(v,act,tok,val)
-#define REDUCE(v,act) do {\
- switch (reduce(v,act)) { \
- case 0: /* normal */ \
- break; \
- case 1: /* yyerror */ \
- goto user_yyerror; \
- case 2: /* yyaccept */ \
- D_puts("u accept"); \
- goto accept; \
- default: \
- break; \
- } \
-} while (0)
-
-static void
-parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
-{
- long i; /* table index */
- long act; /* action type */
- VALUE act_value; /* action type, VALUE version */
- int read_next = 1; /* true if we need to read next token */
- VALUE tmp;
-
- if (resume)
- goto resume;
-
- while (1) {
- D_puts("");
- D_puts("---- enter new loop ----");
- D_puts("");
-
- D_printf("(act) k1=%ld\n", v->curstate);
- tmp = AREF(v->action_pointer, v->curstate);
- if (NIL_P(tmp)) goto notfound;
- D_puts("(act) pointer[k1] ok");
- i = NUM2LONG(tmp);
-
- D_printf("read_next=%d\n", read_next);
- if (read_next && (v->t != vFINAL_TOKEN)) {
- if (v->lex_is_iterator) {
- D_puts("resuming...");
- if (v->fin) rb_raise(rb_eArgError, "token given after EOF");
- v->i = i; /* save i */
- return;
- resume:
- D_puts("resumed");
- i = v->i; /* load i */
- }
- else {
- D_puts("next_token");
- tmp = rb_funcall(v->parser, id_nexttoken, 0);
- extract_user_token(v, tmp, &tok, &val);
- }
- /* convert token */
- v->t = rb_hash_aref(v->token_table, tok);
- if (NIL_P(v->t)) {
- v->t = vERROR_TOKEN;
- }
- D_printf("(act) t(k2)=%ld\n", NUM2LONG(v->t));
- if (v->debug) {
- rb_funcall(v->parser, id_d_read_token,
- 3, v->t, tok, val);
- }
- }
- read_next = 0;
-
- i += NUM2LONG(v->t);
- D_printf("(act) i=%ld\n", i);
- if (i < 0) goto notfound;
-
- act_value = AREF(v->action_table, i);
- if (NIL_P(act_value)) goto notfound;
- act = NUM2LONG(act_value);
- D_printf("(act) table[i]=%ld\n", act);
-
- tmp = AREF(v->action_check, i);
- if (NIL_P(tmp)) goto notfound;
- if (NUM2LONG(tmp) != v->curstate) goto notfound;
- D_printf("(act) check[i]=%ld\n", NUM2LONG(tmp));
-
- D_puts("(act) found");
- act_fixed:
- D_printf("act=%ld\n", act);
- goto handle_act;
-
- notfound:
- D_puts("(act) not found: use default");
- act_value = AREF(v->action_default, v->curstate);
- act = NUM2LONG(act_value);
- goto act_fixed;
-
-
- handle_act:
- if (act > 0 && act < v->shift_n) {
- D_puts("shift");
- if (v->errstatus > 0) {
- v->errstatus--;
- rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
- }
- SHIFT(v, act, v->t, val);
- read_next = 1;
- }
- else if (act < 0 && act > -(v->reduce_n)) {
- D_puts("reduce");
- REDUCE(v, act);
- }
- else if (act == -(v->reduce_n)) {
- goto error;
- error_recovered:
- ; /* goto label requires stmt */
- }
- else if (act == v->shift_n) {
- D_puts("accept");
- goto accept;
- }
- else {
- rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
- }
-
- if (v->debug) {
- rb_funcall(v->parser, id_d_next_state,
- 2, LONG2NUM(v->curstate), v->state);
- }
- }
- /* not reach */
-
-
- accept:
- if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
- v->retval = rb_ary_entry(v->vstack, 0);
- v->fin = CP_FIN_ACCEPT;
- return;
-
-
- error:
- D_printf("error detected, status=%ld\n", v->errstatus);
- if (v->errstatus == 0) {
- v->nerr++;
- rb_funcall(v->parser, id_onerror,
- 3, v->t, val, v->vstack);
- }
- user_yyerror:
- if (v->errstatus == 3) {
- if (v->t == vFINAL_TOKEN) {
- v->retval = Qnil;
- v->fin = CP_FIN_EOT;
- return;
- }
- read_next = 1;
- }
- v->errstatus = 3;
- rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
-
- /* check if we can shift/reduce error token */
- D_printf("(err) k1=%ld\n", v->curstate);
- D_printf("(err) k2=%d (error)\n", ERROR_TOKEN);
- while (1) {
- tmp = AREF(v->action_pointer, v->curstate);
- if (NIL_P(tmp)) goto error_pop;
- D_puts("(err) pointer[k1] ok");
-
- i = NUM2LONG(tmp) + ERROR_TOKEN;
- D_printf("(err) i=%ld\n", i);
- if (i < 0) goto error_pop;
-
- act_value = AREF(v->action_table, i);
- if (NIL_P(act_value)) {
- D_puts("(err) table[i] == nil");
- goto error_pop;
- }
- act = NUM2LONG(act_value);
- D_printf("(err) table[i]=%ld\n", act);
-
- tmp = AREF(v->action_check, i);
- if (NIL_P(tmp)) {
- D_puts("(err) check[i] == nil");
- goto error_pop;
- }
- if (NUM2LONG(tmp) != v->curstate) {
- D_puts("(err) check[i] != k1");
- goto error_pop;
- }
-
- D_puts("(err) found: can handle error token");
- break;
-
- error_pop:
- D_puts("(err) act not found: can't handle error token; pop");
-
- if (RARRAY_LEN(v->state) <= 1) {
- v->retval = Qnil;
- v->fin = CP_FIN_CANTPOP;
- return;
- }
- POP(v->state);
- POP(v->vstack);
- v->curstate = num_to_long(LAST_I(v->state));
- if (v->debug) {
- POP(v->tstack);
- rb_funcall(v->parser, id_d_e_pop,
- 3, v->state, v->tstack, v->vstack);
- }
- }
-
- /* shift/reduce error token */
- if (act > 0 && act < v->shift_n) {
- D_puts("e shift");
- SHIFT(v, act, ERROR_TOKEN, val);
- }
- else if (act < 0 && act > -(v->reduce_n)) {
- D_puts("e reduce");
- REDUCE(v, act);
- }
- else if (act == v->shift_n) {
- D_puts("e accept");
- goto accept;
- }
- else {
- rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
- }
- goto error_recovered;
-}
-
-static void
-shift(struct cparse_params *v, long act, VALUE tok, VALUE val)
-{
- PUSH(v->vstack, val);
- if (v->debug) {
- PUSH(v->tstack, tok);
- rb_funcall(v->parser, id_d_shift,
- 3, tok, v->tstack, v->vstack);
- }
- v->curstate = act;
- PUSH(v->state, LONG2NUM(v->curstate));
-}
-
-static int
-reduce(struct cparse_params *v, long act)
-{
- VALUE code;
- v->ruleno = -act * 3;
- code = rb_catch("racc_jump", reduce0, v->value_v);
- v->errstatus = num_to_long(rb_ivar_get(v->parser, id_errstatus));
- return NUM2INT(code);
-}
-
-static VALUE
-reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
- VALUE reduce_to, reduce_len, method_id;
- long len;
- ID mid;
- VALUE tmp, tmp_t = Qundef, tmp_v = Qundef;
- long i, k1, k2;
- VALUE goto_state;
-
- reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
- reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
- method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
- len = NUM2LONG(reduce_len);
- mid = value_to_id(method_id);
-
- /* call action */
- if (len == 0) {
- tmp = Qnil;
- if (mid != id_noreduce)
- tmp_v = rb_ary_new();
- if (v->debug)
- tmp_t = rb_ary_new();
- }
- else {
- if (mid != id_noreduce) {
- tmp_v = GET_TAIL(v->vstack, len);
- tmp = rb_ary_entry(tmp_v, 0);
- }
- else {
- tmp = rb_ary_entry(v->vstack, RARRAY_LEN(v->vstack) - len);
- }
- CUT_TAIL(v->vstack, len);
- if (v->debug) {
- tmp_t = GET_TAIL(v->tstack, len);
- CUT_TAIL(v->tstack, len);
- }
- CUT_TAIL(v->state, len);
- }
- if (mid != id_noreduce) {
- if (v->use_result_var) {
- tmp = rb_funcall(v->parser, mid,
- 3, tmp_v, v->vstack, tmp);
- }
- else {
- tmp = rb_funcall(v->parser, mid,
- 2, tmp_v, v->vstack);
- }
- }
-
- /* then push result */
- PUSH(v->vstack, tmp);
- if (v->debug) {
- PUSH(v->tstack, reduce_to);
- rb_funcall(v->parser, id_d_reduce,
- 4, tmp_t, reduce_to, v->tstack, v->vstack);
- }
-
- /* calculate transition state */
- if (RARRAY_LEN(v->state) == 0)
- rb_raise(RaccBug, "state stack unexpectedly empty");
- k2 = num_to_long(LAST_I(v->state));
- k1 = num_to_long(reduce_to) - v->nt_base;
- D_printf("(goto) k1=%ld\n", k1);
- D_printf("(goto) k2=%ld\n", k2);
-
- tmp = AREF(v->goto_pointer, k1);
- if (NIL_P(tmp)) goto notfound;
-
- i = NUM2LONG(tmp) + k2;
- D_printf("(goto) i=%ld\n", i);
- if (i < 0) goto notfound;
-
- goto_state = AREF(v->goto_table, i);
- if (NIL_P(goto_state)) {
- D_puts("(goto) table[i] == nil");
- goto notfound;
- }
- D_printf("(goto) table[i]=%ld (goto_state)\n", NUM2LONG(goto_state));
-
- tmp = AREF(v->goto_check, i);
- if (NIL_P(tmp)) {
- D_puts("(goto) check[i] == nil");
- goto notfound;
- }
- if (tmp != LONG2NUM(k1)) {
- D_puts("(goto) check[i] != table[i]");
- goto notfound;
- }
- D_printf("(goto) check[i]=%ld\n", NUM2LONG(tmp));
-
- D_puts("(goto) found");
- transit:
- PUSH(v->state, goto_state);
- v->curstate = NUM2LONG(goto_state);
- return INT2FIX(0);
-
- notfound:
- D_puts("(goto) not found: use default");
- /* overwrite `goto-state' by default value */
- goto_state = AREF(v->goto_default, k1);
- goto transit;
-}
-
-/* -----------------------------------------------------------------------
- Ruby Interface
------------------------------------------------------------------------ */
-
-void
-Init_cparse(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
-
- VALUE Racc, Parser;
- ID id_racc = rb_intern_const("Racc");
-
- if (rb_const_defined(rb_cObject, id_racc)) {
- Racc = rb_const_get(rb_cObject, id_racc);
- Parser = rb_const_get_at(Racc, rb_intern_const("Parser"));
- }
- else {
- Racc = rb_define_module("Racc");
- Parser = rb_define_class_under(Racc, "Parser", rb_cObject);
- }
- rb_define_private_method(Parser, "_racc_do_parse_c", racc_cparse, 2);
- rb_define_private_method(Parser, "_racc_yyparse_c", racc_yyparse, 4);
- rb_define_const(Parser, "Racc_Runtime_Core_Version_C",
- rb_str_new2(RACC_VERSION));
- rb_define_const(Parser, "Racc_Runtime_Core_Id_C",
- rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));
-
- CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
- rb_undef_alloc_func(CparseParams);
- rb_undef_method(CparseParams, "initialize");
- rb_undef_method(CparseParams, "initialize_copy");
-
- RaccBug = rb_eRuntimeError;
-
- id_yydebug = rb_intern_const("@yydebug");
- id_nexttoken = rb_intern_const("next_token");
- id_onerror = rb_intern_const("on_error");
- id_noreduce = rb_intern_const("_reduce_none");
- id_errstatus = rb_intern_const("@racc_error_status");
-
- id_d_shift = rb_intern_const("racc_shift");
- id_d_reduce = rb_intern_const("racc_reduce");
- id_d_accept = rb_intern_const("racc_accept");
- id_d_read_token = rb_intern_const("racc_read_token");
- id_d_next_state = rb_intern_const("racc_next_state");
- id_d_e_pop = rb_intern_const("racc_e_pop");
-}
diff --git a/ext/racc/cparse/depend b/ext/racc/cparse/depend
deleted file mode 100644
index 80dc7c456b..0000000000
--- a/ext/racc/cparse/depend
+++ /dev/null
@@ -1,161 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-cparse.o: $(RUBY_EXTCONF_H)
-cparse.o: $(arch_hdrdir)/ruby/config.h
-cparse.o: $(hdrdir)/ruby.h
-cparse.o: $(hdrdir)/ruby/assert.h
-cparse.o: $(hdrdir)/ruby/backward.h
-cparse.o: $(hdrdir)/ruby/backward/2/assume.h
-cparse.o: $(hdrdir)/ruby/backward/2/attributes.h
-cparse.o: $(hdrdir)/ruby/backward/2/bool.h
-cparse.o: $(hdrdir)/ruby/backward/2/inttypes.h
-cparse.o: $(hdrdir)/ruby/backward/2/limits.h
-cparse.o: $(hdrdir)/ruby/backward/2/long_long.h
-cparse.o: $(hdrdir)/ruby/backward/2/stdalign.h
-cparse.o: $(hdrdir)/ruby/backward/2/stdarg.h
-cparse.o: $(hdrdir)/ruby/defines.h
-cparse.o: $(hdrdir)/ruby/intern.h
-cparse.o: $(hdrdir)/ruby/internal/abi.h
-cparse.o: $(hdrdir)/ruby/internal/anyargs.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-cparse.o: $(hdrdir)/ruby/internal/assume.h
-cparse.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-cparse.o: $(hdrdir)/ruby/internal/attr/artificial.h
-cparse.o: $(hdrdir)/ruby/internal/attr/cold.h
-cparse.o: $(hdrdir)/ruby/internal/attr/const.h
-cparse.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-cparse.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-cparse.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-cparse.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-cparse.o: $(hdrdir)/ruby/internal/attr/error.h
-cparse.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-cparse.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-cparse.o: $(hdrdir)/ruby/internal/attr/format.h
-cparse.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noalias.h
-cparse.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noinline.h
-cparse.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-cparse.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-cparse.o: $(hdrdir)/ruby/internal/attr/pure.h
-cparse.o: $(hdrdir)/ruby/internal/attr/restrict.h
-cparse.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-cparse.o: $(hdrdir)/ruby/internal/attr/warning.h
-cparse.o: $(hdrdir)/ruby/internal/attr/weakref.h
-cparse.o: $(hdrdir)/ruby/internal/cast.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_since.h
-cparse.o: $(hdrdir)/ruby/internal/config.h
-cparse.o: $(hdrdir)/ruby/internal/constant_p.h
-cparse.o: $(hdrdir)/ruby/internal/core.h
-cparse.o: $(hdrdir)/ruby/internal/core/rarray.h
-cparse.o: $(hdrdir)/ruby/internal/core/rbasic.h
-cparse.o: $(hdrdir)/ruby/internal/core/rbignum.h
-cparse.o: $(hdrdir)/ruby/internal/core/rclass.h
-cparse.o: $(hdrdir)/ruby/internal/core/rdata.h
-cparse.o: $(hdrdir)/ruby/internal/core/rfile.h
-cparse.o: $(hdrdir)/ruby/internal/core/rhash.h
-cparse.o: $(hdrdir)/ruby/internal/core/robject.h
-cparse.o: $(hdrdir)/ruby/internal/core/rregexp.h
-cparse.o: $(hdrdir)/ruby/internal/core/rstring.h
-cparse.o: $(hdrdir)/ruby/internal/core/rstruct.h
-cparse.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-cparse.o: $(hdrdir)/ruby/internal/ctype.h
-cparse.o: $(hdrdir)/ruby/internal/dllexport.h
-cparse.o: $(hdrdir)/ruby/internal/dosish.h
-cparse.o: $(hdrdir)/ruby/internal/error.h
-cparse.o: $(hdrdir)/ruby/internal/eval.h
-cparse.o: $(hdrdir)/ruby/internal/event.h
-cparse.o: $(hdrdir)/ruby/internal/fl_type.h
-cparse.o: $(hdrdir)/ruby/internal/gc.h
-cparse.o: $(hdrdir)/ruby/internal/glob.h
-cparse.o: $(hdrdir)/ruby/internal/globals.h
-cparse.o: $(hdrdir)/ruby/internal/has/attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/builtin.h
-cparse.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/extension.h
-cparse.o: $(hdrdir)/ruby/internal/has/feature.h
-cparse.o: $(hdrdir)/ruby/internal/has/warning.h
-cparse.o: $(hdrdir)/ruby/internal/intern/array.h
-cparse.o: $(hdrdir)/ruby/internal/intern/bignum.h
-cparse.o: $(hdrdir)/ruby/internal/intern/class.h
-cparse.o: $(hdrdir)/ruby/internal/intern/compar.h
-cparse.o: $(hdrdir)/ruby/internal/intern/complex.h
-cparse.o: $(hdrdir)/ruby/internal/intern/cont.h
-cparse.o: $(hdrdir)/ruby/internal/intern/dir.h
-cparse.o: $(hdrdir)/ruby/internal/intern/enum.h
-cparse.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-cparse.o: $(hdrdir)/ruby/internal/intern/error.h
-cparse.o: $(hdrdir)/ruby/internal/intern/eval.h
-cparse.o: $(hdrdir)/ruby/internal/intern/file.h
-cparse.o: $(hdrdir)/ruby/internal/intern/hash.h
-cparse.o: $(hdrdir)/ruby/internal/intern/io.h
-cparse.o: $(hdrdir)/ruby/internal/intern/load.h
-cparse.o: $(hdrdir)/ruby/internal/intern/marshal.h
-cparse.o: $(hdrdir)/ruby/internal/intern/numeric.h
-cparse.o: $(hdrdir)/ruby/internal/intern/object.h
-cparse.o: $(hdrdir)/ruby/internal/intern/parse.h
-cparse.o: $(hdrdir)/ruby/internal/intern/proc.h
-cparse.o: $(hdrdir)/ruby/internal/intern/process.h
-cparse.o: $(hdrdir)/ruby/internal/intern/random.h
-cparse.o: $(hdrdir)/ruby/internal/intern/range.h
-cparse.o: $(hdrdir)/ruby/internal/intern/rational.h
-cparse.o: $(hdrdir)/ruby/internal/intern/re.h
-cparse.o: $(hdrdir)/ruby/internal/intern/ruby.h
-cparse.o: $(hdrdir)/ruby/internal/intern/select.h
-cparse.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-cparse.o: $(hdrdir)/ruby/internal/intern/signal.h
-cparse.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-cparse.o: $(hdrdir)/ruby/internal/intern/string.h
-cparse.o: $(hdrdir)/ruby/internal/intern/struct.h
-cparse.o: $(hdrdir)/ruby/internal/intern/thread.h
-cparse.o: $(hdrdir)/ruby/internal/intern/time.h
-cparse.o: $(hdrdir)/ruby/internal/intern/variable.h
-cparse.o: $(hdrdir)/ruby/internal/intern/vm.h
-cparse.o: $(hdrdir)/ruby/internal/interpreter.h
-cparse.o: $(hdrdir)/ruby/internal/iterator.h
-cparse.o: $(hdrdir)/ruby/internal/memory.h
-cparse.o: $(hdrdir)/ruby/internal/method.h
-cparse.o: $(hdrdir)/ruby/internal/module.h
-cparse.o: $(hdrdir)/ruby/internal/newobj.h
-cparse.o: $(hdrdir)/ruby/internal/scan_args.h
-cparse.o: $(hdrdir)/ruby/internal/special_consts.h
-cparse.o: $(hdrdir)/ruby/internal/static_assert.h
-cparse.o: $(hdrdir)/ruby/internal/stdalign.h
-cparse.o: $(hdrdir)/ruby/internal/stdbool.h
-cparse.o: $(hdrdir)/ruby/internal/symbol.h
-cparse.o: $(hdrdir)/ruby/internal/value.h
-cparse.o: $(hdrdir)/ruby/internal/value_type.h
-cparse.o: $(hdrdir)/ruby/internal/variable.h
-cparse.o: $(hdrdir)/ruby/internal/warning_push.h
-cparse.o: $(hdrdir)/ruby/internal/xmalloc.h
-cparse.o: $(hdrdir)/ruby/missing.h
-cparse.o: $(hdrdir)/ruby/ruby.h
-cparse.o: $(hdrdir)/ruby/st.h
-cparse.o: $(hdrdir)/ruby/subst.h
-cparse.o: cparse.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
deleted file mode 100644
index 18c5689ad8..0000000000
--- a/ext/racc/cparse/extconf.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: false
-#
-
-require 'mkmf'
-
-have_func('rb_block_call')
-have_func('rb_ary_subseq')
-
-create_makefile 'racc/cparse'
diff --git a/ext/rbconfig/sizeof/depend b/ext/rbconfig/sizeof/depend
index 4e4ebd4ae5..7e6c950769 100644
--- a/ext/rbconfig/sizeof/depend
+++ b/ext/rbconfig/sizeof/depend
@@ -142,6 +142,7 @@ limits.o: $(hdrdir)/ruby/internal/intern/re.h
limits.o: $(hdrdir)/ruby/internal/intern/ruby.h
limits.o: $(hdrdir)/ruby/internal/intern/select.h
limits.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+limits.o: $(hdrdir)/ruby/internal/intern/set.h
limits.o: $(hdrdir)/ruby/internal/intern/signal.h
limits.o: $(hdrdir)/ruby/internal/intern/sprintf.h
limits.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -161,6 +162,7 @@ limits.o: $(hdrdir)/ruby/internal/special_consts.h
limits.o: $(hdrdir)/ruby/internal/static_assert.h
limits.o: $(hdrdir)/ruby/internal/stdalign.h
limits.o: $(hdrdir)/ruby/internal/stdbool.h
+limits.o: $(hdrdir)/ruby/internal/stdckdint.h
limits.o: $(hdrdir)/ruby/internal/symbol.h
limits.o: $(hdrdir)/ruby/internal/value.h
limits.o: $(hdrdir)/ruby/internal/value_type.h
@@ -300,6 +302,7 @@ sizes.o: $(hdrdir)/ruby/internal/intern/re.h
sizes.o: $(hdrdir)/ruby/internal/intern/ruby.h
sizes.o: $(hdrdir)/ruby/internal/intern/select.h
sizes.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sizes.o: $(hdrdir)/ruby/internal/intern/set.h
sizes.o: $(hdrdir)/ruby/internal/intern/signal.h
sizes.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sizes.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -319,6 +322,7 @@ sizes.o: $(hdrdir)/ruby/internal/special_consts.h
sizes.o: $(hdrdir)/ruby/internal/static_assert.h
sizes.o: $(hdrdir)/ruby/internal/stdalign.h
sizes.o: $(hdrdir)/ruby/internal/stdbool.h
+sizes.o: $(hdrdir)/ruby/internal/stdckdint.h
sizes.o: $(hdrdir)/ruby/internal/symbol.h
sizes.o: $(hdrdir)/ruby/internal/value.h
sizes.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/readline/.gitignore b/ext/readline/.gitignore
deleted file mode 100644
index 3d372989ae..0000000000
--- a/ext/readline/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/readline-[1-9]*.*
diff --git a/ext/readline/README b/ext/readline/README
deleted file mode 100644
index 57c51b5f5d..0000000000
--- a/ext/readline/README
+++ /dev/null
@@ -1,10 +0,0 @@
-The Readline module provides interface for GNU Readline.
-This module defines a number of methods to facilitate completion
-and accesses input history from the Ruby interpreter.
-This module supported Edit Line(libedit) too.
-libedit is compatible with GNU Readline.
-
-GNU Readline:: http://www.gnu.org/directory/readline.html
-libedit:: http://www.thrysoee.dk/editline/
-
-See RDoc for Readline module.
diff --git a/ext/readline/README.ja b/ext/readline/README.ja
deleted file mode 100644
index 57a6ee4126..0000000000
--- a/ext/readline/README.ja
+++ /dev/null
@@ -1,386 +0,0 @@
-GNU Readline ã«ã‚ˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å…¥åŠ›ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã‚’æä¾›ã™ã‚‹ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«
-ã§ã™ã€‚GNU Readline ã®äº’æ›ãƒ©ã‚¤ãƒ–ラリã®ã²ã¨ã¤ã§ã‚ã‚‹ Edit Line(libedit) ã‚‚
-サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚
-
-GNU Readline:: http://www.gnu.org/directory/readline.html
-libedit:: http://www.thrysoee.dk/editline/
-
-Readline.readline を使用ã—ã¦ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®å…¥åŠ›ã‚’å–å¾—ã§ãã¾ã™ã€‚ã“ã®ã¨ãã€
-GNU Readline ã®ã‚ˆã†ã«å…¥åŠ›ã®è£œå®Œã‚„Emacs ã®ã‚ˆã†ãªã‚­ãƒ¼æ“作ãªã©ãŒã§ãã¾ã™ã€‚
-
- require "readline"
- while buf = Readline.readline("> ", true)
- p buf
- end
-
-ユーザãŒå…¥åŠ›ã—ãŸå†…容を履歴(以下ã€ãƒ’ストリ)ã¨ã—ã¦è¨˜éŒ²ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
-定数 Readline::HISTORY を使用ã—ã¦ãƒ’ストリã«ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚
-
- require "readline"
- while buf = Readline.readline("> ", true)
- p Readline::HISTORY.to_a
- print("-> ", buf, "\n")
- end
-
-使用ã™ã‚‹ãƒ©ã‚¤ãƒ–ラリã«ã‚ˆã‚Šã€ã„ãã¤ã‹ã®ãƒ¡ã‚½ãƒƒãƒ‰ã§ä¾‹å¤– NotImplementedError
-ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-== Readline モジュール
-
-=== モジュール関数
-
-readline([prompt, [add_hist]]) -> String | nil
-
- prompt を出力ã—ã€ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®ã‚­ãƒ¼å…¥åŠ›ã‚’å¾…ã¡ã¾ã™ã€‚
- ã‚¨ãƒ³ã‚¿ãƒ¼ã‚­ãƒ¼ã®æŠ¼ä¸‹ãªã©ã§ãƒ¦ãƒ¼ã‚¶ãŒæ–‡å­—列を入力ã—終ãˆã‚‹ã¨ã€
- 入力ã—ãŸæ–‡å­—列を返ã—ã¾ã™ã€‚
- ã“ã®ã¨ãã€add_hist ㌠true ã§ã‚れã°ã€å…¥åŠ›ã—ãŸæ–‡å­—列をヒストリã«è¿½åŠ ã—ã¾ã™ã€‚
-
- 何も入力ã—ã¦ã„ãªã„状態㧠EOF(UNIX ã§ã¯ ^D) を入力ã™ã‚‹ãªã©ã§ã€
- ユーザã‹ã‚‰ã®å…¥åŠ›ãŒãªã„å ´åˆã¯ nil ã‚’è¿”ã—ã¾ã™ã€‚
-
- æ¬¡ã®æ¡ä»¶ã‚’å…¨ã¦æº€ãŸã™å ´åˆã€ä¾‹å¤– IOError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
- 1. 標準入力㌠tty ã§ãªã„。
- 2. 標準入力をクローズã—ã¦ã„る。(isatty(2) ã® errno ㌠EBADF ã§ã‚る。)
-
- 本メソッドã¯ã‚¹ãƒ¬ãƒƒãƒ‰ã«å¯¾å¿œã—ã¦ã„ã¾ã™ã€‚
- 入力待ã¡çŠ¶æ…‹ã®ã¨ãã¯ã‚¹ãƒ¬ãƒƒãƒ‰ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã®åˆ‡æ›¿ãˆãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
- 入力時ã«ã¯è¡Œå†…編集ãŒå¯èƒ½ã§ã€vi モード㨠Emacs モードãŒç”¨æ„ã•れã¦ã„ã¾ã™ã€‚
- デフォルト㯠Emacs モードã§ã™ã€‚
-
- 本メソッドã«ã¯æ³¨æ„事項ãŒã‚りã¾ã™ã€‚
- 入力待ã¡ã®çŠ¶æ…‹ã§ ^C ã™ã‚‹ã¨ ruby インタプリタãŒçµ‚了ã—ã€ç«¯æœ«çŠ¶æ…‹ã‚’å¾©å¸°ã—ã¾ã›ã‚“。
- ã“れを回é¿ã™ã‚‹ãŸã‚ã®ä¾‹ã‚’3ã¤æŒ™ã’ã¾ã™ã€‚
-
- * ^Cã«ã‚ˆã‚‹Interrupt例外を補足ã—ã¦ã€ç«¯æœ«çŠ¶æ…‹ã‚’å¾©å¸°ã—ã¾ã™:
-
- require "readline"
-
- stty_save = `stty -g`.chomp
- begin
- while buf = Readline.readline
- p buf
- end
- rescue Interrupt
- system("stty", stty_save)
- exit
- end
- end
- end
-
- * INTシグナルを補足ã—ã¦ã€ç«¯æœ«çŠ¶æ…‹ã‚’å¾©å¸°ã—ã¾ã™:
-
- require "readline"
-
- stty_save = `stty -g`.chomp
- trap("INT") { system "stty", stty_save; exit }
-
- while buf = Readline.readline
- p buf
- end
-
- * å˜ã« ^C を無視ã™ã‚‹æ–¹æ³•ã‚‚ã‚りã¾ã™:
-
- require "readline"
-
- trap("INT", "SIG_IGN")
-
- while buf = Readline.readline
- p buf
- end
-
- 入力履歴 Readline::HISTORY を使用ã—ã¦ã€ç©ºè¡Œã‚„ç›´å‰ã®å…¥åŠ›ã¨åŒã˜å†…容ã¯å…¥åŠ›
- å±¥æ­´ã«æ®‹ã•ãªã„ã¨ã„ã†ã“ã¨ã‚‚ã§ãã¾ã™ã€‚
-
- require "readline"
-
- while buf = Readline.readline("> ", true)
- # p Readline::HISTORY.to_a
- Readline::HISTORY.pop if /^\s*$/ =~ buf
-
- begin
- if Readline::HISTORY[Readline::HISTORY.length-2] == buf
- Readline::HISTORY.pop
- end
- rescue IndexError
- end
-
- # p Readline::HISTORY.to_a
- print "-> ", buf, "\n"
- end
-
-=== クラスメソッド
-
-Readline.input = input
-
- Readline.readline メソッドã§ä½¿ç”¨ã™ã‚‹å…¥åŠ›ç”¨ã® File オブジェクト input
- を指定ã—ã¾ã™ã€‚
-
-Readline.output = output
-
- Readline.readline メソッドã§ä½¿ç”¨ã™ã‚‹å‡ºåŠ›ç”¨ã® File オブジェクト
- output を指定ã—ã¾ã™ã€‚
-
-Readline.completion_proc = proc
-
- ユーザã‹ã‚‰ã®å…¥åŠ›ã‚’è£œå®Œã™ã‚‹æ™‚ã®å€™è£œã‚’å–å¾—ã™ã‚‹ Proc オブジェクト proc ã‚’
- 指定ã—ã¾ã™ã€‚proc ã¯ã€æ¬¡ã®ã‚‚ã®ã‚’想定ã—ã¦ã„ã¾ã™ã€‚
- 1. call メソッドをæŒã¡ã¾ã™ã€‚
- call メソッドをæŒãŸãªã„å ´åˆã€ä¾‹å¤– ArgumentError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
- 2. 引数ã«ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®å…¥åŠ›æ–‡å­—åˆ—(注1)ã‚’å–りã¾ã™ã€‚
- 3. å€™è£œã®æ–‡å­—列ã®é…列を返ã—ã¾ã™ã€‚
-
- 注1:「/var/lib /vã€ã®å¾Œã§è£œå®Œã‚’行ã†ã¨ã€
- デフォルトã§ã¯ proc ã®å¼•æ•°ã«ã€Œ/vã€ãŒæ¸¡ã•れã¾ã™ã€‚
- ã“ã®ã‚ˆã†ã«ã€ãƒ¦ãƒ¼ã‚¶ãŒå…¥åŠ›ã—ãŸæ–‡å­—列を
- Readline.completer_word_break_characters ã«å«ã¾ã‚Œã‚‹æ–‡å­—ã§åŒºåˆ‡ã£ãŸã‚‚
- ã®ã‚’å˜èªžã¨ã™ã‚‹ã¨ã€ã‚«ãƒ¼ã‚½ãƒ«ãŒã‚ã‚‹å˜èªžã®æœ€åˆã®æ–‡å­—ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½
- ç½®ã¾ã§ã®æ–‡å­—列㌠proc ã®å¼•æ•°ã«æ¸¡ã•れã¾ã™ã€‚
-
-Readline.completion_proc -> proc
-
- ユーザã‹ã‚‰ã®å…¥åŠ›ã‚’è£œå®Œã™ã‚‹æ™‚ã®å€™è£œã‚’å–å¾—ã™ã‚‹ Proc オブジェクト proc
- ã‚’å–å¾—ã—ã¾ã™ã€‚
-
-Readline.completion_case_fold = bool
-
- ユーザã®å…¥åŠ›ã‚’è£œå®Œã™ã‚‹éš›ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã™ã‚‹ï¼ã—ãªã„を指定ã—ã¾ã™ã€‚
- bool ãŒçœŸãªã‚‰ã°åŒºåˆ¥ã—ã¾ã›ã‚“。bool ãŒå½ãªã‚‰ã°åŒºåˆ¥ã—ã¾ã™ã€‚
-
-Readline.completion_case_fold -> bool
-
- ユーザã®å…¥åŠ›ã‚’è£œå®Œã™ã‚‹éš›ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã™ã‚‹ï¼ã—ãªã„ã‚’å–å¾—ã—ã¾ã™ã€‚
- bool ãŒçœŸãªã‚‰ã°åŒºåˆ¥ã—ã¾ã›ã‚“。bool ãŒå½ãªã‚‰ã°åŒºåˆ¥ã—ã¾ã™ã€‚
-
- ãªãŠã€Readline.completion_case_fold= ãƒ¡ã‚½ãƒƒãƒ‰ã§æŒ‡å®šã—ãŸã‚ªãƒ–ジェクトを
- ãã®ã¾ã¾å–å¾—ã™ã‚‹ã®ã§ã€æ¬¡ã®ã‚ˆã†ãªå‹•作をã—ã¾ã™ã€‚
-
- require "readline"
-
- Readline.completion_case_fold = "This is a String."
- p Readline.completion_case_fold # => "This is a String."
-
-Readline.line_buffer -> string
-
- 入力中ã®è¡Œå…¨ä½“ã‚’è¿”ã—ã¾ã™ã€‚complete_proc ã®ä¸­ã§ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—
- ã¦ã„ã¾ã™ã€‚Readline.line_buffer ã®é•·ã•㯠GNU Readline ã® rl_end 変数ã®
- 値ã¨ä¸€è‡´ã—ã¾ã™ã€‚
-
-Readline.point -> int
-
- ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã‚’è¿”ã—ã¾ã™ã€‚
- Readline モジュールã¯è£œå®Œå¯¾è±¡ã®å˜èªžã®é–‹å§‹ä½ç½®ã®æƒ…報をæä¾›ã—ã¦ã„ã¾ã›ã‚“。
- ã—ã‹ã—ãªãŒã‚‰ã€ completion_proc ã®ä¸­ã§å…¥åŠ›ã—ãŸå˜èªž text ã¨
- Readline.point を使用ã™ã‚‹ã“ã¨ã§é–‹å§‹ä½ç½®ã‚’å°Žãã“ã¨ãŒã§ãã¾ã™ã€‚
-
- é–‹å§‹ä½ç½® = 入力ã—ãŸå˜èªžã®é•·ã• - Readline.point
-
-Readline.vi_editing_mode -> nil
-
- 編集モードを vi モードã«ã—ã¾ã™ã€‚
- vi モードã®è©³ç´°ã¯ã€GNU Readline ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.vi_editing_mode? -> bool
-
- 編集モード㌠vi モードã®å ´åˆã€true ã‚’è¿”ã—ã¾ã™ã€‚ãã†ã§ãªã‘れ㰠false
- ã‚’è¿”ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.emacs_editing_mode -> nil
-
- 編集モードを Emacs モードã«ã—ã¾ã™ã€‚
- デフォルト㯠Emacs モードã§ã™ã€‚
- Emacs モードã®è©³ç´°ã¯ã€GNU Readline ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.emacs_editing_mode? -> bool
-
- 編集モード㌠Emacs モードã®å ´åˆã€true ã‚’è¿”ã—ã¾ã™ã€‚ãã†ã§ãªã‘れ㰠false
- ã‚’è¿”ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completion_append_character = char
-
- ユーザã®å…¥åŠ›ã®è£œå®ŒãŒå®Œäº†ã—ãŸå ´åˆã«ã€æœ€å¾Œã«ä»˜åŠ ã™ã‚‹æ–‡å­— char を指定ã—
- ã¾ã™ã€‚åŠè§’スペース「" "ã€ãªã©ã®å˜èªžã‚’区切る文字を指定ã™ã‚Œã°ã€é€£ç¶šã—ã¦
- 入力ã™ã‚‹éš›ã«ä¾¿åˆ©ã§ã™ã€‚
-
- 使用例:
-
- require "readline"
-
- Readline.readline("> ", true)
- Readline.completion_append_character = " "
-
- 実行例:
-
- >
- ã“ã“ã§ "/var/li" を入力ã—ã¾ã™ã€‚
-
- > /var/li
- ã“ã“ã§ TAB キーを入力ã—ã¾ã™ã€‚
-
- > /var/lib
- "b" ãŒè£œå®Œã•ã‚Œã€æœ€å¾Œã« " " ãŒè¿½åŠ ã•れるã®ã§ã€"/usr" を連続ã—ã¦å…¥åŠ›ã§ãã¾ã™ã€‚
-
- > /var/lib /usr
-
- ãªãŠã€1文字ã—ã‹æŒ‡å®šã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。
- 例ãˆã°ã€"string"を指定ã—ãŸå ´åˆã¯æœ€åˆã®æ–‡å­—ã§ã‚ã‚‹"s"ã ã‘を使用ã—ã¾ã™ã€‚
-
- require "readline"
-
- Readline.completion_append_character = "string"
- p Readline.completion_append_character # => "s"
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completion_append_character -> char
-
- ユーザã®å…¥åŠ›ã®è£œå®ŒãŒå®Œäº†ã—ãŸå ´åˆã«ã€æœ€å¾Œã«ä»˜åŠ ã™ã‚‹æ–‡å­—ã‚’å–å¾—ã—ã¾ã™ã€‚
- デフォルトã¯ç©ºç™½ (" ") ã§ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.basic_word_break_characters = string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる
- 文字列 string を指定ã—ã¾ã™ã€‚
-
- GNU Readline ã®ãƒ‡ãƒ•ォルトã®å€¤ã¯ã€Bash ã®è£œå®Œå‡¦ç†ã§ä½¿ç”¨ã—ã¦ã„る文字列
- " \t\n\"\\'`@$><=;|&{(" (スペースをå«ã‚€) ã«ãªã£ã¦ã„ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.basic_word_break_characters -> string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる
- 文字列をå–å¾—ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completer_word_break_characters = string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる
- 文字列 string を指定ã—ã¾ã™ã€‚
- Readline.basic_word_break_characters= ã¨ã®é•ã„ã¯ã€
- GNU Readline ã® rl_complete_internal 関数ã§ä½¿ç”¨ã•れるã“ã¨ã§ã™ã€‚
-
- GNU Readline ã®ãƒ‡ãƒ•ォルトã®å€¤ã¯ã€
- Readline.basic_word_break_characters ã¨åŒã˜ã§ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completer_word_break_characters -> string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れãŸ
- 文字列をå–å¾—ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.basic_quote_characters = string
-
- スペースãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる
- 文字列 string を指定ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.basic_quote_characters -> string
-
- スペースãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる
- 文字列をå–å¾—ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completer_quote_characters = string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
- クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる文字列 string を指定ã—ã¾ã™ã€‚
- 指定ã—ãŸæ–‡å­—ã®é–“ã§ã¯ã€Readline.completer_word_break_characters=
- ã§æŒ‡å®šã—ãŸæ–‡å­—列ã«å«ã¾ã‚Œã‚‹æ–‡å­—ã‚‚ã€æ™®é€šã®æ–‡å­—列ã¨ã—ã¦æ‰±ã‚れã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.completer_quote_characters -> string
-
- ユーザã®å…¥åŠ›ã®è£œå®Œã‚’行ã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
- クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる文字列をå–å¾—ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.filename_quote_characters = string
-
- ユーザã®å…¥åŠ›æ™‚ã«ãƒ•ァイルåã®è£œå®Œã‚’行ã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
- クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる文字列 string を指定ã—ã¾ã™ã€‚
-
- GNU Readline ã®ãƒ‡ãƒ•ォルト値㯠nil ã§ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-Readline.filename_quote_characters -> string
-
- ユーザã®å…¥åŠ›æ™‚ã«ãƒ•ァイルåã®è£œå®Œã‚’行ã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
- クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•れる文字列をå–å¾—ã—ã¾ã™ã€‚
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
-
-=== クラス定数
-
-HISTORY
-
- 定数 HISTORY を使用ã—ã¦ãƒ’ストリã«ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚
- Enumerable モジュールを extend ã—ã¦ãŠã‚Šã€
- é…列ã®ã‚ˆã†ã«æŒ¯ã‚‹èˆžã†ã“ã¨ãŒã§ãã¾ã™ã€‚
- 例ãˆã°ã€HISTORY[4] ã«ã‚ˆã‚Š 5 番目ã«å…¥åŠ›ã—ãŸå†…容をå–り出ã™ã“ã¨ãŒã§ãã¾ã™ã€‚
-
- require "readline"
-
- Readline::HISTORY.push("a", "b", "c", "d", "e")
- p Readline::HISTORY[4] # => "e"
-
- 実装ã—ã¦ã„ã‚‹ãƒ¡ã‚½ãƒƒãƒ‰ã‚’æ¬¡ã«æŒ™ã’ã¾ã™ã€‚
- * HISTORY.to_s -> "HISTORY"
- * HISTORY[index] -> string
- * HISTORY[index] = string
- * HISTORY.push(string[, string, ...]) -> self
- * HISTORY << string -> self
- * HISTORY.pop -> string
- * HISTORY.shift -> string
- * HISTORY.each -> Enumerator
- * HISTORY.each { |i| } -> [string]
- * HISTORY.length -> Integer
- * HISTORY.empty? -> true or false
- * HISTORY.delete_at(index) -> string
- * HISTORY.clear -> self
-
- サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€æ¬¡ã®ãƒ¡ã‚½ãƒƒãƒ‰ã§ä¾‹å¤– NotImplementedError ãŒ
- 発生ã—ã¾ã™ã€‚
- * HISTORY[index] = string
- * HISTORY.pop -> string
- * HISTORY.shift -> string
- * HISTORY.delete_at(index) -> string
- * HISTORY.clear -> self
-
-FILENAME_COMPLETION_PROC
-
- ファイルåã®è£œå®Œã‚’行ㆠcall メソッドをæŒã¤ã‚ªãƒ–ジェクトã§ã™ã€‚
-
- Readline.completion_proc= ã«ã‚ˆã‚Šã€ãƒ¦ãƒ¼ã‚¶ã®å…¥åŠ›æ™‚ã«ãƒ•ァイルåã®è£œå®Œã‚’
- 行ã†ã‚ˆã†ã«è¨­å®šã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã¾ã™ã€‚
-
-USERNAME_COMPLETION_PROC
-
- ユーザåã®è£œå®Œã‚’行ㆠcall メソッドをæŒã¤ã‚ªãƒ–ジェクトã§ã™ã€‚
-
- Readline.completion_proc= ã«ã‚ˆã‚Šã€ãƒ¦ãƒ¼ã‚¶ã®å…¥åŠ›æ™‚ã«ãƒ¦ãƒ¼ã‚¶åã®è£œå®Œã‚’行
- ã†ã‚ˆã†ã«è¨­å®šã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã¾ã™ã€‚
-
-VERSION
-
- 使用ã—ã¦ã„ã‚‹ GNU Readline ã¾ãŸã¯ libedit ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã™ã€‚
diff --git a/ext/readline/depend b/ext/readline/depend
deleted file mode 100644
index 8e42a12dd5..0000000000
--- a/ext/readline/depend
+++ /dev/null
@@ -1,174 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-readline.o: $(RUBY_EXTCONF_H)
-readline.o: $(arch_hdrdir)/ruby/config.h
-readline.o: $(hdrdir)/ruby/assert.h
-readline.o: $(hdrdir)/ruby/backward.h
-readline.o: $(hdrdir)/ruby/backward/2/assume.h
-readline.o: $(hdrdir)/ruby/backward/2/attributes.h
-readline.o: $(hdrdir)/ruby/backward/2/bool.h
-readline.o: $(hdrdir)/ruby/backward/2/inttypes.h
-readline.o: $(hdrdir)/ruby/backward/2/limits.h
-readline.o: $(hdrdir)/ruby/backward/2/long_long.h
-readline.o: $(hdrdir)/ruby/backward/2/stdalign.h
-readline.o: $(hdrdir)/ruby/backward/2/stdarg.h
-readline.o: $(hdrdir)/ruby/defines.h
-readline.o: $(hdrdir)/ruby/encoding.h
-readline.o: $(hdrdir)/ruby/intern.h
-readline.o: $(hdrdir)/ruby/internal/abi.h
-readline.o: $(hdrdir)/ruby/internal/anyargs.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-readline.o: $(hdrdir)/ruby/internal/assume.h
-readline.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-readline.o: $(hdrdir)/ruby/internal/attr/artificial.h
-readline.o: $(hdrdir)/ruby/internal/attr/cold.h
-readline.o: $(hdrdir)/ruby/internal/attr/const.h
-readline.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-readline.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-readline.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-readline.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-readline.o: $(hdrdir)/ruby/internal/attr/error.h
-readline.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-readline.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-readline.o: $(hdrdir)/ruby/internal/attr/format.h
-readline.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-readline.o: $(hdrdir)/ruby/internal/attr/noalias.h
-readline.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-readline.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-readline.o: $(hdrdir)/ruby/internal/attr/noinline.h
-readline.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-readline.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-readline.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-readline.o: $(hdrdir)/ruby/internal/attr/pure.h
-readline.o: $(hdrdir)/ruby/internal/attr/restrict.h
-readline.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-readline.o: $(hdrdir)/ruby/internal/attr/warning.h
-readline.o: $(hdrdir)/ruby/internal/attr/weakref.h
-readline.o: $(hdrdir)/ruby/internal/cast.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-readline.o: $(hdrdir)/ruby/internal/compiler_since.h
-readline.o: $(hdrdir)/ruby/internal/config.h
-readline.o: $(hdrdir)/ruby/internal/constant_p.h
-readline.o: $(hdrdir)/ruby/internal/core.h
-readline.o: $(hdrdir)/ruby/internal/core/rarray.h
-readline.o: $(hdrdir)/ruby/internal/core/rbasic.h
-readline.o: $(hdrdir)/ruby/internal/core/rbignum.h
-readline.o: $(hdrdir)/ruby/internal/core/rclass.h
-readline.o: $(hdrdir)/ruby/internal/core/rdata.h
-readline.o: $(hdrdir)/ruby/internal/core/rfile.h
-readline.o: $(hdrdir)/ruby/internal/core/rhash.h
-readline.o: $(hdrdir)/ruby/internal/core/robject.h
-readline.o: $(hdrdir)/ruby/internal/core/rregexp.h
-readline.o: $(hdrdir)/ruby/internal/core/rstring.h
-readline.o: $(hdrdir)/ruby/internal/core/rstruct.h
-readline.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-readline.o: $(hdrdir)/ruby/internal/ctype.h
-readline.o: $(hdrdir)/ruby/internal/dllexport.h
-readline.o: $(hdrdir)/ruby/internal/dosish.h
-readline.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-readline.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-readline.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-readline.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-readline.o: $(hdrdir)/ruby/internal/encoding/re.h
-readline.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-readline.o: $(hdrdir)/ruby/internal/encoding/string.h
-readline.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-readline.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-readline.o: $(hdrdir)/ruby/internal/error.h
-readline.o: $(hdrdir)/ruby/internal/eval.h
-readline.o: $(hdrdir)/ruby/internal/event.h
-readline.o: $(hdrdir)/ruby/internal/fl_type.h
-readline.o: $(hdrdir)/ruby/internal/gc.h
-readline.o: $(hdrdir)/ruby/internal/glob.h
-readline.o: $(hdrdir)/ruby/internal/globals.h
-readline.o: $(hdrdir)/ruby/internal/has/attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/builtin.h
-readline.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/extension.h
-readline.o: $(hdrdir)/ruby/internal/has/feature.h
-readline.o: $(hdrdir)/ruby/internal/has/warning.h
-readline.o: $(hdrdir)/ruby/internal/intern/array.h
-readline.o: $(hdrdir)/ruby/internal/intern/bignum.h
-readline.o: $(hdrdir)/ruby/internal/intern/class.h
-readline.o: $(hdrdir)/ruby/internal/intern/compar.h
-readline.o: $(hdrdir)/ruby/internal/intern/complex.h
-readline.o: $(hdrdir)/ruby/internal/intern/cont.h
-readline.o: $(hdrdir)/ruby/internal/intern/dir.h
-readline.o: $(hdrdir)/ruby/internal/intern/enum.h
-readline.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-readline.o: $(hdrdir)/ruby/internal/intern/error.h
-readline.o: $(hdrdir)/ruby/internal/intern/eval.h
-readline.o: $(hdrdir)/ruby/internal/intern/file.h
-readline.o: $(hdrdir)/ruby/internal/intern/hash.h
-readline.o: $(hdrdir)/ruby/internal/intern/io.h
-readline.o: $(hdrdir)/ruby/internal/intern/load.h
-readline.o: $(hdrdir)/ruby/internal/intern/marshal.h
-readline.o: $(hdrdir)/ruby/internal/intern/numeric.h
-readline.o: $(hdrdir)/ruby/internal/intern/object.h
-readline.o: $(hdrdir)/ruby/internal/intern/parse.h
-readline.o: $(hdrdir)/ruby/internal/intern/proc.h
-readline.o: $(hdrdir)/ruby/internal/intern/process.h
-readline.o: $(hdrdir)/ruby/internal/intern/random.h
-readline.o: $(hdrdir)/ruby/internal/intern/range.h
-readline.o: $(hdrdir)/ruby/internal/intern/rational.h
-readline.o: $(hdrdir)/ruby/internal/intern/re.h
-readline.o: $(hdrdir)/ruby/internal/intern/ruby.h
-readline.o: $(hdrdir)/ruby/internal/intern/select.h
-readline.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-readline.o: $(hdrdir)/ruby/internal/intern/signal.h
-readline.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-readline.o: $(hdrdir)/ruby/internal/intern/string.h
-readline.o: $(hdrdir)/ruby/internal/intern/struct.h
-readline.o: $(hdrdir)/ruby/internal/intern/thread.h
-readline.o: $(hdrdir)/ruby/internal/intern/time.h
-readline.o: $(hdrdir)/ruby/internal/intern/variable.h
-readline.o: $(hdrdir)/ruby/internal/intern/vm.h
-readline.o: $(hdrdir)/ruby/internal/interpreter.h
-readline.o: $(hdrdir)/ruby/internal/iterator.h
-readline.o: $(hdrdir)/ruby/internal/memory.h
-readline.o: $(hdrdir)/ruby/internal/method.h
-readline.o: $(hdrdir)/ruby/internal/module.h
-readline.o: $(hdrdir)/ruby/internal/newobj.h
-readline.o: $(hdrdir)/ruby/internal/scan_args.h
-readline.o: $(hdrdir)/ruby/internal/special_consts.h
-readline.o: $(hdrdir)/ruby/internal/static_assert.h
-readline.o: $(hdrdir)/ruby/internal/stdalign.h
-readline.o: $(hdrdir)/ruby/internal/stdbool.h
-readline.o: $(hdrdir)/ruby/internal/symbol.h
-readline.o: $(hdrdir)/ruby/internal/value.h
-readline.o: $(hdrdir)/ruby/internal/value_type.h
-readline.o: $(hdrdir)/ruby/internal/variable.h
-readline.o: $(hdrdir)/ruby/internal/warning_push.h
-readline.o: $(hdrdir)/ruby/internal/xmalloc.h
-readline.o: $(hdrdir)/ruby/io.h
-readline.o: $(hdrdir)/ruby/missing.h
-readline.o: $(hdrdir)/ruby/onigmo.h
-readline.o: $(hdrdir)/ruby/oniguruma.h
-readline.o: $(hdrdir)/ruby/ruby.h
-readline.o: $(hdrdir)/ruby/st.h
-readline.o: $(hdrdir)/ruby/subst.h
-readline.o: $(hdrdir)/ruby/thread.h
-readline.o: readline.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/readline/depend-gem b/ext/readline/depend-gem
deleted file mode 100644
index df01bd2a86..0000000000
--- a/ext/readline/depend-gem
+++ /dev/null
@@ -1,4 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-readline.o: $(RUBY_EXTCONF_H)
-readline.o: readline.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
deleted file mode 100644
index d3e7872e65..0000000000
--- a/ext/readline/extconf.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: false
-require "mkmf"
-
-readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
-
-def readline.have_header(header)
- if super(header, &extra_check)
- headers.push(header)
- return true
- else
- return false
- end
-end
-
-def readline.have_var(var)
- return super(var, headers)
-end
-
-def readline.have_func(func)
- return super(func, headers)
-end
-
-def readline.have_type(type)
- return super(type, headers)
-end
-
-dir_config('curses')
-dir_config('ncurses')
-dir_config('termcap')
-dir_config("readline")
-enable_libedit = enable_config("libedit")
-
-have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
-have_library("ncurses", "tgetnum") ||
- have_library("termcap", "tgetnum") ||
- have_library("curses", "tgetnum")
-
-case enable_libedit
-when true
- # --enable-libedit
- dir_config("libedit")
- unless (readline.have_header("editline/readline.h") ||
- readline.have_header("readline/readline.h")) &&
- have_library("edit", "readline")
- raise "libedit not found"
- end
-when false
- # --disable-libedit
- unless ((readline.have_header("readline/readline.h") &&
- readline.have_header("readline/history.h")) &&
- have_library("readline", "readline"))
- raise "readline not found"
- end
-else
- # does not specify
- unless ((readline.have_header("readline/readline.h") &&
- readline.have_header("readline/history.h")) &&
- (have_library("readline", "readline") ||
- have_library("edit", "readline"))) ||
- (readline.have_header("editline/readline.h") &&
- have_library("edit", "readline"))
- raise "Neither readline nor libedit was found"
- end
-end
-
-readline.have_func("rl_getc")
-readline.have_func("rl_getc_function")
-readline.have_func("rl_filename_completion_function")
-readline.have_func("rl_username_completion_function")
-readline.have_func("rl_completion_matches")
-readline.have_func("rl_refresh_line")
-readline.have_var("rl_deprep_term_function")
-readline.have_var("rl_completion_append_character")
-readline.have_var("rl_completion_quote_character")
-readline.have_var("rl_basic_word_break_characters")
-readline.have_var("rl_completer_word_break_characters")
-readline.have_var("rl_basic_quote_characters")
-readline.have_var("rl_completer_quote_characters")
-readline.have_var("rl_filename_quote_characters")
-readline.have_var("rl_attempted_completion_over")
-readline.have_var("rl_library_version")
-readline.have_var("rl_editing_mode")
-readline.have_var("rl_line_buffer")
-readline.have_var("rl_point")
-readline.have_var("rl_char_is_quoted_p")
-# workaround for native windows.
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
-readline.have_var("rl_pre_input_hook")
-readline.have_var("rl_special_prefixes")
-readline.have_func("rl_cleanup_after_signal")
-readline.have_func("rl_free_line_state")
-readline.have_func("rl_clear_signals")
-readline.have_func("rl_set_screen_size")
-readline.have_func("rl_get_screen_size")
-readline.have_func("rl_vi_editing_mode")
-readline.have_func("rl_emacs_editing_mode")
-readline.have_func("replace_history_entry")
-readline.have_func("remove_history")
-readline.have_func("clear_history")
-readline.have_func("rl_redisplay")
-readline.have_func("rl_insert_text")
-readline.have_func("rl_delete_text")
-unless readline.have_type("rl_hook_func_t*")
- # rl_hook_func_t is available since readline-4.2 (2001).
- # Function is removed at readline-6.3 (2014).
- # However, editline (NetBSD 6.1.3, 2014) doesn't have rl_hook_func_t.
- $defs << "-Drl_hook_func_t=Function"
-end
-
-create_makefile("readline")
diff --git a/ext/readline/readline-ext.gemspec b/ext/readline/readline-ext.gemspec
deleted file mode 100644
index 1e16edbfe6..0000000000
--- a/ext/readline/readline-ext.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "readline-ext"
- spec.version = "0.1.5"
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.description = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.homepage = "https://github.com/ruby/readline-ext"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.extensions = %w[ext/readline/extconf.rb]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
deleted file mode 100644
index fc254ce315..0000000000
--- a/ext/readline/readline.c
+++ /dev/null
@@ -1,2144 +0,0 @@
-/************************************************
-
- readline.c - GNU Readline module
-
- $Author$
- created at: Wed Jan 20 13:59:32 JST 1999
-
- Copyright (C) 1997-2008 Shugo Maeda
- Copyright (C) 2008-2013 Kouji Takao
-
- $Id$
-
- Contact:
- - Kouji Takao <kouji dot takao at gmail dot com> (current maintainer)
-
-************************************************/
-
-#ifdef RUBY_EXTCONF_H
-#include RUBY_EXTCONF_H
-#endif
-
-#include "ruby/config.h"
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
-#endif
-#ifdef HAVE_READLINE_HISTORY_H
-#include <readline/history.h>
-#endif
-#ifdef HAVE_EDITLINE_READLINE_H
-#include <editline/readline.h>
-#endif
-
-#include "ruby/io.h"
-#include "ruby/thread.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-static VALUE mReadline;
-
-#define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
-#ifndef USE_INSERT_IGNORE_ESCAPE
-# if !defined(HAVE_EDITLINE_READLINE_H) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
-# define USE_INSERT_IGNORE_ESCAPE 1
-# else
-# define USE_INSERT_IGNORE_ESCAPE 0
-# endif
-#endif
-
-#define COMPLETION_PROC "completion_proc"
-#define COMPLETION_CASE_FOLD "completion_case_fold"
-static ID id_call, completion_proc, completion_case_fold;
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
-#define QUOTING_DETECTION_PROC "quoting_detection_proc"
-static ID quoting_detection_proc;
-#endif
-#if USE_INSERT_IGNORE_ESCAPE
-static ID id_orig_prompt, id_last_prompt;
-#endif
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
-static ID id_pre_input_hook;
-#endif
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
-static ID id_special_prefixes;
-#endif
-
-#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
-# define rl_filename_completion_function filename_completion_function
-#endif
-#ifndef HAVE_RL_USERNAME_COMPLETION_FUNCTION
-# define rl_username_completion_function username_completion_function
-#else
-RUBY_EXTERN char *rl_username_completion_function(const char *, int);
-#endif
-#ifndef HAVE_RL_COMPLETION_MATCHES
-# define rl_completion_matches completion_matches
-#endif
-
-static int (*history_get_offset_func)(int);
-static int (*history_replace_offset_func)(int);
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-static int readline_completion_append_character;
-#endif
-
-static char **readline_attempted_completion_function(const char *text,
- int start, int end);
-
-#define OutputStringValue(str) do {\
- StringValueCStr(str);\
- (str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\
-} while (0)\
-
-
-/*
- * Document-class: Readline
- *
- * The Readline module provides interface for GNU Readline.
- * This module defines a number of methods to facilitate completion
- * and accesses input history from the Ruby interpreter.
- * This module supported Edit Line(libedit) too.
- * libedit is compatible with GNU Readline.
- *
- * GNU Readline:: http://www.gnu.org/directory/readline.html
- * libedit:: http://www.thrysoee.dk/editline/
- *
- * Reads one inputted line with line edit by Readline.readline method.
- * At this time, the facilitatation completion and the key
- * bind like Emacs can be operated like GNU Readline.
- *
- * require "readline"
- * while buf = Readline.readline("> ", true)
- * p buf
- * end
- *
- * The content that the user input can be recorded to the history.
- * The history can be accessed by Readline::HISTORY constant.
- *
- * require "readline"
- * while buf = Readline.readline("> ", true)
- * p Readline::HISTORY.to_a
- * print("-> ", buf, "\n")
- * end
- *
- * Documented by Kouji Takao <kouji dot takao at gmail dot com>.
- */
-
-static VALUE readline_instream;
-static VALUE readline_outstream;
-static FILE *readline_rl_instream;
-static FILE *readline_rl_outstream;
-
-static void
-mustbe_callable(VALUE proc)
-{
- if (!NIL_P(proc) && !rb_respond_to(proc, id_call))
- rb_raise(rb_eArgError, "argument must respond to `call'");
-}
-
-#if defined HAVE_RL_GETC_FUNCTION
-
-#ifndef HAVE_RL_GETC
-#define rl_getc(f) EOF
-#endif
-
-struct getc_struct {
- FILE *input;
- int fd;
- int ret;
- int err;
-};
-
-static int
-getc_body(struct getc_struct *p)
-{
- char ch;
- ssize_t ss;
-
-#if defined(_WIN32)
- {
- INPUT_RECORD ir;
- DWORD n;
- static int prior_key = '0';
- for (;;) {
- HANDLE h;
- if (prior_key > 0xff) {
- prior_key = rl_getc(p->input);
- return prior_key;
- }
- h = (HANDLE)_get_osfhandle(p->fd);
- if (PeekConsoleInput(h, &ir, 1, &n)) {
- if (n == 1) {
- if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) {
- prior_key = rl_getc(p->input);
- return prior_key;
- } else {
- ReadConsoleInput(h, &ir, 1, &n);
- }
- } else {
- rb_w32_wait_events_blocking(&h, 1, INFINITE);
- }
- } else {
- break;
- }
- }
- }
-#endif
-
- ss = read(p->fd, &ch, 1);
- if (ss == 0) {
- errno = 0;
- return EOF;
- }
- if (ss != 1)
- return EOF;
- return (unsigned char)ch;
-}
-
-static void *
-getc_func(void *data1)
-{
- struct getc_struct *p = data1;
- errno = 0;
- p->ret = getc_body(p);
- p->err = errno;
- return NULL;
-}
-
-static int
-readline_getc(FILE *input)
-{
- struct getc_struct data;
- if (input == NULL) /* editline may give NULL as input. */
- input = stdin;
- data.input = input;
- data.fd = fileno(input);
- again:
- data.ret = EOF;
- data.err = EINTR; /* getc_func is not called if already interrupted. */
- rb_thread_call_without_gvl2(getc_func, &data, RUBY_UBF_IO, NULL);
- if (data.ret == EOF) {
- if (data.err == 0) {
- return EOF;
- }
- if (data.err == EINTR) {
- rb_thread_check_ints();
- goto again;
- }
- if (data.err == EWOULDBLOCK || data.err == EAGAIN) {
- int ret;
- if (fileno(input) != data.fd)
- rb_bug("readline_getc: input closed unexpectedly or memory corrupted");
- ret = rb_wait_for_single_fd(data.fd, RB_WAITFD_IN, NULL);
- if (ret != -1 || errno == EINTR)
- goto again;
- rb_sys_fail("rb_wait_for_single_fd");
- }
- rb_syserr_fail(data.err, "read");
- }
- return data.ret;
-}
-
-#elif defined HAVE_RL_EVENT_HOOK
-#define BUSY_WAIT 0
-
-static int readline_event(void);
-static int
-readline_event(void)
-{
-#if BUSY_WAIT
- rb_thread_schedule();
-#else
- rb_wait_for_single_fd(fileno(rl_instream), RB_WAITFD_IN, NULL);
- return 0;
-#endif
-}
-#endif
-
-#if USE_INSERT_IGNORE_ESCAPE
-static VALUE
-insert_ignore_escape(VALUE self, VALUE prompt)
-{
- VALUE last_prompt, orig_prompt = rb_attr_get(self, id_orig_prompt);
- int ignoring = 0;
- const char *s0, *s, *e;
- long len;
- static const char ignore_code[2] = {RL_PROMPT_START_IGNORE, RL_PROMPT_END_IGNORE};
-
- prompt = rb_str_new_shared(prompt);
- last_prompt = rb_attr_get(self, id_last_prompt);
- if (orig_prompt == prompt) return last_prompt;
- len = RSTRING_LEN(prompt);
- if (NIL_P(last_prompt)) {
- last_prompt = rb_str_tmp_new(len);
- }
-
- s = s0 = RSTRING_PTR(prompt);
- e = s0 + len;
- rb_str_set_len(last_prompt, 0);
- while (s < e && *s) {
- switch (*s) {
- case RL_PROMPT_START_IGNORE:
- ignoring = -1;
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- case RL_PROMPT_END_IGNORE:
- ignoring = 0;
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- case '\033':
- if (++s < e && *s == '[') {
- rb_str_cat(last_prompt, s0, s - s0 - 1);
- s0 = s - 1;
- while (++s < e && *s) {
- if (ISALPHA(*(unsigned char *)s)) {
- if (!ignoring) {
- ignoring = 1;
- rb_str_cat(last_prompt, ignore_code+0, 1);
- }
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- }
- else if (!(('0' <= *s && *s <= '9') || *s == ';')) {
- break;
- }
- }
- }
- break;
- default:
- if (ignoring > 0) {
- ignoring = 0;
- rb_str_cat(last_prompt, ignore_code+1, 1);
- }
- s++;
- break;
- }
- }
- if (ignoring > 0) {
- ignoring = 0;
- rb_str_cat(last_prompt, ignore_code+1, 1);
- }
- rb_str_cat(last_prompt, s0, s - s0);
-
- rb_ivar_set(self, id_orig_prompt, prompt);
- rb_ivar_set(self, id_last_prompt, last_prompt);
-
- return last_prompt;
-}
-#endif
-
-static VALUE
-readline_get(VALUE prompt)
-{
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
- readline_completion_append_character = rl_completion_append_character;
-#endif
- return (VALUE)readline((char *)prompt);
-}
-
-static void
-clear_rl_instream(void)
-{
- if (readline_rl_instream) {
- fclose(readline_rl_instream);
- if (rl_instream == readline_rl_instream)
- rl_instream = NULL;
- readline_rl_instream = NULL;
- }
- readline_instream = Qfalse;
-}
-
-static void
-clear_rl_outstream(void)
-{
- if (readline_rl_outstream) {
- fclose(readline_rl_outstream);
- if (rl_outstream == readline_rl_outstream)
- rl_outstream = NULL;
- readline_rl_outstream = NULL;
- }
- readline_outstream = Qfalse;
-}
-
-static void
-prepare_readline(void)
-{
- static int initialized = 0;
- if (!initialized) {
- rl_initialize();
- initialized = 1;
- }
-
- if (readline_instream) {
- rb_io_t *ifp;
- rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
- if (ifp->fd < 0) {
- clear_rl_instream();
- rb_raise(rb_eIOError, "closed readline input");
- }
- }
-
- if (readline_outstream) {
- rb_io_t *ofp;
- rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
- if (ofp->fd < 0) {
- clear_rl_outstream();
- rb_raise(rb_eIOError, "closed readline output");
- }
- }
-}
-
-/*
- * call-seq:
- * Readline.readline(prompt = "", add_hist = false) -> string or nil
- *
- * Shows the +prompt+ and reads the inputted line with line editing.
- * The inputted line is added to the history if +add_hist+ is true.
- *
- * Returns nil when the inputted line is empty and user inputs EOF
- * (Presses ^D on UNIX).
- *
- * Raises IOError exception if one of below conditions are satisfied.
- * 1. stdin was closed.
- * 2. stdout was closed.
- *
- * This method supports thread. Switches the thread context when waits
- * inputting line.
- *
- * Supports line edit when inputs line. Provides VI and Emacs editing mode.
- * Default is Emacs editing mode.
- *
- * NOTE: Terminates ruby interpreter and does not return the terminal
- * status after user pressed '^C' when wait inputting line.
- * Give 3 examples that avoid it.
- *
- * * Catches the Interrupt exception by pressed ^C after returns
- * terminal status:
- *
- * require "readline"
- *
- * stty_save = `stty -g`.chomp
- * begin
- * while buf = Readline.readline
- * p buf
- * end
- * rescue Interrupt
- * system("stty", stty_save)
- * exit
- * end
- * end
- * end
- *
- * * Catches the INT signal by pressed ^C after returns terminal
- * status:
- *
- * require "readline"
- *
- * stty_save = `stty -g`.chomp
- * trap("INT") { system "stty", stty_save; exit }
- *
- * while buf = Readline.readline
- * p buf
- * end
- *
- * * Ignores pressing ^C:
- *
- * require "readline"
- *
- * trap("INT", "SIG_IGN")
- *
- * while buf = Readline.readline
- * p buf
- * end
- *
- * Can make as follows with Readline::HISTORY constant.
- * It does not record to the history if the inputted line is empty or
- * the same it as last one.
- *
- * require "readline"
- *
- * while buf = Readline.readline("> ", true)
- * # p Readline::HISTORY.to_a
- * Readline::HISTORY.pop if /^\s*$/ =~ buf
- *
- * begin
- * if Readline::HISTORY[Readline::HISTORY.length-2] == buf
- * Readline::HISTORY.pop
- * end
- * rescue IndexError
- * end
- *
- * # p Readline::HISTORY.to_a
- * print "-> ", buf, "\n"
- * end
- */
-static VALUE
-readline_readline(int argc, VALUE *argv, VALUE self)
-{
- VALUE tmp, add_hist, result;
- char *prompt = NULL;
- char *buff;
- int status;
-
- if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
- OutputStringValue(tmp);
-#if USE_INSERT_IGNORE_ESCAPE
- tmp = insert_ignore_escape(self, tmp);
- rb_str_locktmp(tmp);
-#endif
- prompt = RSTRING_PTR(tmp);
- }
-
- prepare_readline();
-
-#ifdef _WIN32
- rl_prep_terminal(1);
-#endif
- buff = (char*)rb_protect(readline_get, (VALUE)prompt, &status);
-#if USE_INSERT_IGNORE_ESCAPE
- if (prompt) {
- rb_str_unlocktmp(tmp);
- }
-#endif
- if (status) {
-#if defined HAVE_RL_CLEANUP_AFTER_SIGNAL
- /* restore terminal mode and signal handler*/
-#if defined HAVE_RL_FREE_LINE_STATE
- rl_free_line_state();
-#endif
- rl_cleanup_after_signal();
-#elif defined HAVE_RL_DEPREP_TERM_FUNCTION
- /* restore terminal mode */
- if (rl_deprep_term_function != NULL) /* NULL in libedit. [ruby-dev:29116] */
- (*rl_deprep_term_function)();
- else
-#else
- rl_deprep_terminal();
-#endif
- rb_jump_tag(status);
- }
-
- if (RTEST(add_hist) && buff) {
- add_history(buff);
- }
- if (buff) {
- result = rb_locale_str_new_cstr(buff);
- }
- else
- result = Qnil;
- if (buff) free(buff);
- return result;
-}
-
-/*
- * call-seq:
- * Readline.input = input
- *
- * Specifies a File object +input+ that is input stream for
- * Readline.readline method.
- */
-static VALUE
-readline_s_set_input(VALUE self, VALUE input)
-{
- rb_io_t *ifp;
- int fd;
- FILE *f;
-
- if (NIL_P(input)) {
- clear_rl_instream();
- }
- else {
- Check_Type(input, T_FILE);
- GetOpenFile(input, ifp);
- clear_rl_instream();
- fd = rb_cloexec_dup(ifp->fd);
- if (fd == -1)
- rb_sys_fail("dup");
- f = fdopen(fd, "r");
- if (f == NULL) {
- int save_errno = errno;
- close(fd);
- rb_syserr_fail(save_errno, "fdopen");
- }
- rl_instream = readline_rl_instream = f;
- readline_instream = input;
- }
- return input;
-}
-
-/*
- * call-seq:
- * Readline.output = output
- *
- * Specifies a File object +output+ that is output stream for
- * Readline.readline method.
- */
-static VALUE
-readline_s_set_output(VALUE self, VALUE output)
-{
- rb_io_t *ofp;
- int fd;
- FILE *f;
-
- if (NIL_P(output)) {
- clear_rl_outstream();
- }
- else {
- Check_Type(output, T_FILE);
- GetOpenFile(output, ofp);
- clear_rl_outstream();
- fd = rb_cloexec_dup(ofp->fd);
- if (fd == -1)
- rb_sys_fail("dup");
- f = fdopen(fd, "w");
- if (f == NULL) {
- int save_errno = errno;
- close(fd);
- rb_syserr_fail(save_errno, "fdopen");
- }
- rl_outstream = readline_rl_outstream = f;
- readline_outstream = output;
- }
- return output;
-}
-
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
-/*
- * call-seq:
- * Readline.pre_input_hook = proc
- *
- * Specifies a Proc object +proc+ to call after the first prompt has
- * been printed and just before readline starts reading input
- * characters.
- *
- * See GNU Readline's rl_pre_input_hook variable.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_pre_input_hook(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, id_pre_input_hook, proc);
-}
-
-/*
- * call-seq:
- * Readline.pre_input_hook -> proc
- *
- * Returns a Proc object +proc+ to call after the first prompt has
- * been printed and just before readline starts reading input
- * characters. The default is nil.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_pre_input_hook(VALUE self)
-{
- return rb_attr_get(mReadline, id_pre_input_hook);
-}
-
-static int
-readline_pre_input_hook(void)
-{
- VALUE proc;
-
- proc = rb_attr_get(mReadline, id_pre_input_hook);
- if (!NIL_P(proc))
- rb_funcall(proc, id_call, 0);
- return 0;
-}
-#else
-#define readline_s_set_pre_input_hook rb_f_notimplement
-#define readline_s_get_pre_input_hook rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_INSERT_TEXT)
-/*
- * call-seq:
- * Readline.insert_text(string) -> self
- *
- * Insert text into the line at the current cursor position.
- *
- * See GNU Readline's rl_insert_text function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_insert_text(VALUE self, VALUE str)
-{
- OutputStringValue(str);
- rl_insert_text(RSTRING_PTR(str));
- return self;
-}
-#else
-#define readline_s_insert_text rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_DELETE_TEXT)
-RUBY_EXTERN int rl_delete_text(int, int);
-static const char *
-str_subpos(const char *ptr, const char *end, long beg, long *sublen, rb_encoding *enc)
-{
- VALUE str = rb_enc_str_new_static(ptr, end-ptr, enc);
- OBJ_FREEZE(str);
- ptr = rb_str_subpos(str, beg, sublen);
- return ptr;
-}
-
-/*
- * call-seq:
- * Readline.delete_text([start[, length]]) -> self
- * Readline.delete_text(start..end) -> self
- * Readline.delete_text() -> self
- *
- * Delete text between start and end in the current line.
- *
- * See GNU Readline's rl_delete_text function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_delete_text(int argc, VALUE *argv, VALUE self)
-{
- rb_check_arity(argc, 0, 2);
- if (rl_line_buffer) {
- const char *p, *ptr = rl_line_buffer;
- long beg = 0, len = strlen(ptr);
- const char *end = ptr + len;
- rb_encoding *enc = rb_locale_encoding();
- if (argc == 2) {
- beg = NUM2LONG(argv[0]);
- len = NUM2LONG(argv[1]);
- num_pos:
- p = str_subpos(ptr, end, beg, &len, enc);
- if (!p) rb_raise(rb_eArgError, "invalid index");
- beg = p - ptr;
- }
- else if (argc == 1) {
- len = rb_enc_strlen(ptr, ptr + len, enc);
- if (!rb_range_beg_len(argv[0], &beg, &len, len, 1)) {
- beg = NUM2LONG(argv[0]);
- goto num_pos;
- }
- }
- rl_delete_text(rb_long2int(beg), rb_long2int(beg + len));
- }
- return self;
-}
-#else
-#define readline_s_delete_text rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_REDISPLAY)
-/*
- * call-seq:
- * Readline.redisplay -> self
- *
- * Change what's displayed on the screen to reflect the current
- * contents.
- *
- * See GNU Readline's rl_redisplay function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_redisplay(VALUE self)
-{
- rl_redisplay();
- return self;
-}
-#else
-#define readline_s_redisplay rb_f_notimplement
-#endif
-
-/*
- * call-seq:
- * Readline.completion_proc = proc
- *
- * Specifies a Proc object +proc+ to determine completion behavior. It
- * should take input string and return an array of completion candidates.
- *
- * The default completion is used if +proc+ is nil.
- *
- * The String that is passed to the Proc depends on the
- * Readline.completer_word_break_characters property. By default the word
- * under the cursor is passed to the Proc. For example, if the input is "foo
- * bar" then only "bar" would be passed to the completion Proc.
- *
- * Upon successful completion the Readline.completion_append_character will be
- * appended to the input so the user can start working on their next argument.
- *
- * = Examples
- *
- * == Completion for a Static List
- *
- * require 'readline'
- *
- * LIST = [
- * 'search', 'download', 'open',
- * 'help', 'history', 'quit',
- * 'url', 'next', 'clear',
- * 'prev', 'past'
- * ].sort
- *
- * comp = proc { |s| LIST.grep(/^#{Regexp.escape(s)}/) }
- *
- * Readline.completion_append_character = " "
- * Readline.completion_proc = comp
- *
- * while line = Readline.readline('> ', true)
- * p line
- * end
- *
- * == Completion For Directory Contents
- *
- * require 'readline'
- *
- * Readline.completion_append_character = " "
- * Readline.completion_proc = Proc.new do |str|
- * Dir[str+'*'].grep(/^#{Regexp.escape(str)}/)
- * end
- *
- * while line = Readline.readline('> ', true)
- * p line
- * end
- *
- * = Autocomplete strategies
- *
- * When working with auto-complete there are some strategies that work well.
- * To get some ideas you can take a look at the
- * completion.rb[https://git.ruby-lang.org/ruby.git/tree/lib/irb/completion.rb]
- * file for irb.
- *
- * The common strategy is to take a list of possible completions and filter it
- * down to those completions that start with the user input. In the above
- * examples Enumerator.grep is used. The input is escaped to prevent Regexp
- * special characters from interfering with the matching.
- *
- * It may also be helpful to use the Abbrev library to generate completions.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- */
-static VALUE
-readline_s_set_completion_proc(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, completion_proc, proc);
-}
-
-/*
- * call-seq:
- * Readline.completion_proc -> proc
- *
- * Returns the completion Proc object.
- */
-static VALUE
-readline_s_get_completion_proc(VALUE self)
-{
- return rb_attr_get(mReadline, completion_proc);
-}
-
-#ifdef HAVE_RL_CHAR_IS_QUOTED_P
-/*
- * call-seq:
- * Readline.quoting_detection_proc = proc
- *
- * Specifies a Proc object +proc+ to determine if a character in the user's
- * input is escaped. It should take the user's input and the index of the
- * character in question as input, and return a boolean (true if the specified
- * character is escaped).
- *
- * Readline will only call this proc with characters specified in
- * +completer_quote_characters+, to discover if they indicate the end of a
- * quoted argument, or characters specified in
- * +completer_word_break_characters+, to discover if they indicate a break
- * between arguments.
- *
- * If +completer_quote_characters+ is not set, or if the user input doesn't
- * contain one of the +completer_quote_characters+ or a +\+ character,
- * Readline will not attempt to use this proc at all.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- */
-static VALUE
-readline_s_set_quoting_detection_proc(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, quoting_detection_proc, proc);
-}
-
-/*
- * call-seq:
- * Readline.quoting_detection_proc -> proc
- *
- * Returns the quoting detection Proc object.
- */
-static VALUE
-readline_s_get_quoting_detection_proc(VALUE self)
-{
- return rb_attr_get(mReadline, quoting_detection_proc);
-}
-#else
-#define readline_s_set_quoting_detection_proc rb_f_notimplement
-#define readline_s_get_quoting_detection_proc rb_f_notimplement
-#endif
-
-/*
- * call-seq:
- * Readline.completion_case_fold = bool
- *
- * Sets whether or not to ignore case on completion.
- */
-static VALUE
-readline_s_set_completion_case_fold(VALUE self, VALUE val)
-{
- return rb_ivar_set(mReadline, completion_case_fold, val);
-}
-
-/*
- * call-seq:
- * Readline.completion_case_fold -> bool
- *
- * Returns true if completion ignores case. If no, returns false.
- *
- * NOTE: Returns the same object that is specified by
- * Readline.completion_case_fold= method.
- *
- * require "readline"
- *
- * Readline.completion_case_fold = "This is a String."
- * p Readline.completion_case_fold # => "This is a String."
- */
-static VALUE
-readline_s_get_completion_case_fold(VALUE self)
-{
- return rb_attr_get(mReadline, completion_case_fold);
-}
-
-#ifdef HAVE_RL_LINE_BUFFER
-/*
- * call-seq:
- * Readline.line_buffer -> string
- *
- * Returns the full line that is being edited. This is useful from
- * within the complete_proc for determining the context of the
- * completion request.
- *
- * The length of +Readline.line_buffer+ and GNU Readline's rl_end are
- * same.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_line_buffer(VALUE self)
-{
- if (rl_line_buffer == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_line_buffer);
-}
-#else
-#define readline_s_get_line_buffer rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_POINT
-/*
- * call-seq:
- * Readline.point -> int
- *
- * Returns the index of the current cursor position in
- * +Readline.line_buffer+.
- *
- * The index in +Readline.line_buffer+ which matches the start of
- * input-string passed to completion_proc is computed by subtracting
- * the length of input-string from +Readline.point+.
- *
- * start = (the length of input-string) - Readline.point
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_point(VALUE self)
-{
- return INT2NUM(rl_point);
-}
-
-/*
- * call-seq:
- * Readline.point = int
- *
- * Set the index of the current cursor position in
- * +Readline.line_buffer+.
- *
- * Raises NotImplementedError if the using readline library does not support.
- *
- * See +Readline.point+.
- */
-static VALUE
-readline_s_set_point(VALUE self, VALUE pos)
-{
- rl_point = NUM2INT(pos);
- return pos;
-}
-#else
-#define readline_s_get_point rb_f_notimplement
-#define readline_s_set_point rb_f_notimplement
-#endif
-
-static char **
-readline_attempted_completion_function(const char *text, int start, int end)
-{
- VALUE proc, ary, temp;
- char **result;
- int case_fold;
- long i, matches;
- rb_encoding *enc;
- VALUE encobj;
-
- proc = rb_attr_get(mReadline, completion_proc);
- if (NIL_P(proc))
- return NULL;
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
- rl_completion_append_character = readline_completion_append_character;
-#endif
-#ifdef HAVE_RL_ATTEMPTED_COMPLETION_OVER
- rl_attempted_completion_over = 1;
-#endif
- case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold));
- ary = rb_funcall(proc, id_call, 1, rb_locale_str_new_cstr(text));
- if (!RB_TYPE_P(ary, T_ARRAY))
- ary = rb_Array(ary);
- matches = RARRAY_LEN(ary);
- if (matches == 0) return NULL;
- result = (char**)malloc((matches + 2)*sizeof(char*));
- if (result == NULL) rb_memerror();
- enc = rb_locale_encoding();
- encobj = rb_enc_from_encoding(enc);
- for (i = 0; i < matches; i++) {
- temp = rb_obj_as_string(RARRAY_AREF(ary, i));
- StringValueCStr(temp); /* must be NUL-terminated */
- rb_enc_check(encobj, temp);
- result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1);
- if (result[i + 1] == NULL) rb_memerror();
- strcpy(result[i + 1], RSTRING_PTR(temp));
- }
- result[matches + 1] = NULL;
-
- if (matches == 1) {
- result[0] = strdup(result[1]);
- }
- else {
- const char *result1 = result[1];
- long low = strlen(result1);
-
- for (i = 1; i < matches; ++i) {
- register int c1, c2;
- long i1, i2, l2;
- int n1, n2;
- const char *p2 = result[i + 1];
-
- l2 = strlen(p2);
- for (i1 = i2 = 0; i1 < low && i2 < l2; i1 += n1, i2 += n2) {
- c1 = rb_enc_codepoint_len(result1 + i1, result1 + low, &n1, enc);
- c2 = rb_enc_codepoint_len(p2 + i2, p2 + l2, &n2, enc);
- if (case_fold) {
- c1 = rb_tolower(c1);
- c2 = rb_tolower(c2);
- }
- if (c1 != c2) break;
- }
-
- low = i1;
- }
- result[0] = (char*)malloc(low + 1);
- if (result[0] == NULL) rb_memerror();
- strncpy(result[0], result[1], low);
- result[0][low] = '\0';
- }
-
- return result;
-}
-
-#ifdef HAVE_RL_CHAR_IS_QUOTED_P
-static int
-readline_char_is_quoted(char *text, int byte_index)
-{
- VALUE proc, result, str;
- long char_index;
- size_t len;
-
- proc = rb_attr_get(mReadline, quoting_detection_proc);
- if (NIL_P(proc)) {
- return 0;
- }
-
- len = strlen(text);
- if (byte_index < 0 || len < (size_t)byte_index) {
- rb_raise(rb_eIndexError, "invalid byte index (%d in %"PRIdSIZE")",
- byte_index, len);
- }
-
- str = rb_locale_str_new(text, len);
- char_index = rb_str_sublen(str, byte_index);
- result = rb_funcall(proc, id_call, 2, str, LONG2FIX(char_index));
- return RTEST(result);
-}
-#endif
-
-#ifdef HAVE_RL_SET_SCREEN_SIZE
-/*
- * call-seq:
- * Readline.set_screen_size(rows, columns) -> self
- *
- * Set terminal size to +rows+ and +columns+.
- *
- * See GNU Readline's rl_set_screen_size function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns)
-{
- rl_set_screen_size(NUM2INT(rows), NUM2INT(columns));
- return self;
-}
-#else
-#define readline_s_set_screen_size rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_GET_SCREEN_SIZE
-/*
- * call-seq:
- * Readline.get_screen_size -> [rows, columns]
- *
- * Returns the terminal's rows and columns.
- *
- * See GNU Readline's rl_get_screen_size function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_screen_size(VALUE self)
-{
- int rows, columns;
- VALUE res;
-
- rl_get_screen_size(&rows, &columns);
- res = rb_ary_new();
- rb_ary_push(res, INT2NUM(rows));
- rb_ary_push(res, INT2NUM(columns));
- return res;
-}
-#else
-#define readline_s_get_screen_size rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_VI_EDITING_MODE
-RUBY_EXTERN int rl_vi_editing_mode(int, int);
-/*
- * call-seq:
- * Readline.vi_editing_mode -> nil
- *
- * Specifies VI editing mode. See the manual of GNU Readline for
- * details of VI editing mode.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_vi_editing_mode(VALUE self)
-{
- rl_vi_editing_mode(1,0);
- return Qnil;
-}
-#else
-#define readline_s_vi_editing_mode rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EDITING_MODE
-/*
- * call-seq:
- * Readline.vi_editing_mode? -> bool
- *
- * Returns true if vi mode is active. Returns false if not.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_vi_editing_mode_p(VALUE self)
-{
- return rl_editing_mode == 0 ? Qtrue : Qfalse;
-}
-#else
-#define readline_s_vi_editing_mode_p rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EMACS_EDITING_MODE
-RUBY_EXTERN int rl_emacs_editing_mode(int, int);
-/*
- * call-seq:
- * Readline.emacs_editing_mode -> nil
- *
- * Specifies Emacs editing mode. The default is this mode. See the
- * manual of GNU Readline for details of Emacs editing mode.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_emacs_editing_mode(VALUE self)
-{
- rl_emacs_editing_mode(1,0);
- return Qnil;
-}
-#else
-#define readline_s_emacs_editing_mode rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EDITING_MODE
-/*
- * call-seq:
- * Readline.emacs_editing_mode? -> bool
- *
- * Returns true if emacs mode is active. Returns false if not.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_emacs_editing_mode_p(VALUE self)
-{
- return rl_editing_mode == 1 ? Qtrue : Qfalse;
-}
-#else
-#define readline_s_emacs_editing_mode_p rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-/*
- * call-seq:
- * Readline.completion_append_character = char
- *
- * Specifies a character to be appended on completion.
- * Nothing will be appended if an empty string ("") or nil is
- * specified.
- *
- * For example:
- * require "readline"
- *
- * Readline.readline("> ", true)
- * Readline.completion_append_character = " "
- *
- * Result:
- * >
- * Input "/var/li".
- *
- * > /var/li
- * Press TAB key.
- *
- * > /var/lib
- * Completes "b" and appends " ". So, you can continuously input "/usr".
- *
- * > /var/lib /usr
- *
- * NOTE: Only one character can be specified. When "string" is
- * specified, sets only "s" that is the first.
- *
- * require "readline"
- *
- * Readline.completion_append_character = "string"
- * p Readline.completion_append_character # => "s"
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completion_append_character(VALUE self, VALUE str)
-{
- if (NIL_P(str)) {
- rl_completion_append_character = '\0';
- }
- else {
- OutputStringValue(str);
- if (RSTRING_LEN(str) == 0) {
- rl_completion_append_character = '\0';
- } else {
- rl_completion_append_character = RSTRING_PTR(str)[0];
- }
- }
- return self;
-}
-#else
-#define readline_s_set_completion_append_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-/*
- * call-seq:
- * Readline.completion_append_character -> char
- *
- * Returns a string containing a character to be appended on
- * completion. The default is a space (" ").
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completion_append_character(VALUE self)
-{
- char buf[1];
-
- if (rl_completion_append_character == '\0')
- return Qnil;
-
- buf[0] = (char) rl_completion_append_character;
- return rb_locale_str_new(buf, 1);
-}
-#else
-#define readline_s_get_completion_append_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_QUOTE_CHARACTER
-/*
- * call-seq:
- * Readline.completion_quote_character -> char
- *
- * When called during a completion (e.g. from within your completion_proc),
- * it will return a string containing the character used to quote the
- * argument being completed, or nil if the argument is unquoted.
- *
- * When called at other times, it will always return nil.
- *
- * Note that Readline.completer_quote_characters must be set,
- * or this method will always return nil.
- */
-static VALUE
-readline_s_get_completion_quote_character(VALUE self)
-{
- char buf[1];
-
- if (rl_completion_quote_character == '\0')
- return Qnil;
-
- buf[0] = (char) rl_completion_quote_character;
- return rb_locale_str_new(buf, 1);
-}
-#else
-#define readline_s_get_completion_quote_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_word_break_characters = string
- *
- * Sets the basic list of characters that signal a break between words
- * for the completer routine. The default is the characters which
- * break words for completion in Bash: " \t\n\"\\'`@$><=;|&{(".
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
-{
- static char *basic_word_break_characters = NULL;
-
- OutputStringValue(str);
- if (basic_word_break_characters == NULL) {
- basic_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(basic_word_break_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(basic_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_word_break_characters[RSTRING_LEN(str)] = '\0';
- rl_basic_word_break_characters = basic_word_break_characters;
- return self;
-}
-#else
-#define readline_s_set_basic_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_word_break_characters -> string
- *
- * Gets the basic list of characters that signal a break between words
- * for the completer routine.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_basic_word_break_characters(VALUE self)
-{
- if (rl_basic_word_break_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_basic_word_break_characters);
-}
-#else
-#define readline_s_get_basic_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_word_break_characters = string
- *
- * Sets the basic list of characters that signal a break between words
- * for rl_complete_internal(). The default is the value of
- * Readline.basic_word_break_characters.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
-{
- static char *completer_word_break_characters = NULL;
-
- OutputStringValue(str);
- if (completer_word_break_characters == NULL) {
- completer_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(completer_word_break_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(completer_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- completer_word_break_characters[RSTRING_LEN(str)] = '\0';
- rl_completer_word_break_characters = completer_word_break_characters;
- return self;
-}
-#else
-#define readline_s_set_completer_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_word_break_characters -> string
- *
- * Gets the basic list of characters that signal a break between words
- * for rl_complete_internal().
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completer_word_break_characters(VALUE self)
-{
- if (rl_completer_word_break_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_completer_word_break_characters);
-}
-#else
-#define readline_s_get_completer_word_break_characters rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
-/*
- * call-seq:
- * Readline.special_prefixes = string
- *
- * Sets the list of characters that are word break characters, but
- * should be left in text when it is passed to the completion
- * function. Programs can use this to help determine what kind of
- * completing to do. For instance, Bash sets this variable to "$@" so
- * that it can complete shell variables and hostnames.
- *
- * See GNU Readline's rl_special_prefixes variable.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_special_prefixes(VALUE self, VALUE str)
-{
- if (!NIL_P(str)) {
- OutputStringValue(str);
- str = rb_str_dup_frozen(str);
- rb_obj_hide(str);
- }
- rb_ivar_set(mReadline, id_special_prefixes, str);
- if (NIL_P(str)) {
- rl_special_prefixes = NULL;
- }
- else {
- rl_special_prefixes = RSTRING_PTR(str);
- }
- return self;
-}
-
-/*
- * call-seq:
- * Readline.special_prefixes -> string
- *
- * Gets the list of characters that are word break characters, but
- * should be left in text when it is passed to the completion
- * function.
- *
- * See GNU Readline's rl_special_prefixes variable.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_special_prefixes(VALUE self)
-{
- VALUE str;
- if (rl_special_prefixes == NULL) return Qnil;
- str = rb_ivar_get(mReadline, id_special_prefixes);
- if (!NIL_P(str)) {
- str = rb_str_dup_frozen(str);
- rb_obj_reveal(str, rb_cString);
- }
- return str;
-}
-#else
-#define readline_s_set_special_prefixes rb_f_notimplement
-#define readline_s_get_special_prefixes rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_quote_characters = string
- *
- * Sets a list of quote characters which can cause a word break.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_basic_quote_characters(VALUE self, VALUE str)
-{
- static char *basic_quote_characters = NULL;
-
- OutputStringValue(str);
- if (basic_quote_characters == NULL) {
- basic_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(basic_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(basic_quote_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_basic_quote_characters = basic_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_basic_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_quote_characters -> string
- *
- * Gets a list of quote characters which can cause a word break.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_basic_quote_characters(VALUE self)
-{
- if (rl_basic_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_basic_quote_characters);
-}
-#else
-#define readline_s_get_basic_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_quote_characters = string
- *
- * Sets a list of characters which can be used to quote a substring of
- * the line. Completion occurs on the entire substring, and within
- * the substring Readline.completer_word_break_characters are treated
- * as any other character, unless they also appear within this list.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completer_quote_characters(VALUE self, VALUE str)
-{
- static char *completer_quote_characters = NULL;
-
- OutputStringValue(str);
- if (completer_quote_characters == NULL) {
- completer_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(completer_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(completer_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- completer_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_completer_quote_characters = completer_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_completer_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_quote_characters -> string
- *
- * Gets a list of characters which can be used to quote a substring of
- * the line.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completer_quote_characters(VALUE self)
-{
- if (rl_completer_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_completer_quote_characters);
-}
-#else
-#define readline_s_get_completer_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.filename_quote_characters = string
- *
- * Sets a list of characters that cause a filename to be quoted by the completer
- * when they appear in a completed filename. The default is nil.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_filename_quote_characters(VALUE self, VALUE str)
-{
- static char *filename_quote_characters = NULL;
-
- OutputStringValue(str);
- if (filename_quote_characters == NULL) {
- filename_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(filename_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(filename_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- filename_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_filename_quote_characters = filename_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_filename_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.filename_quote_characters -> string
- *
- * Gets a list of characters that cause a filename to be quoted by the completer
- * when they appear in a completed filename.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_filename_quote_characters(VALUE self)
-{
- if (rl_filename_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_filename_quote_characters);
-}
-#else
-#define readline_s_get_filename_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_REFRESH_LINE
-RUBY_EXTERN int rl_refresh_line(int, int);
-/*
- * call-seq:
- * Readline.refresh_line -> nil
- *
- * Clear the current input line.
- */
-static VALUE
-readline_s_refresh_line(VALUE self)
-{
- prepare_readline();
- rl_refresh_line(0, 0);
- return Qnil;
-}
-#else
-#define readline_s_refresh_line rb_f_notimplement
-#endif
-
-static VALUE
-hist_to_s(VALUE self)
-{
- return rb_str_new_cstr("HISTORY");
-}
-
-static int
-history_get_offset_history_base(int offset)
-{
- return history_base + offset;
-}
-
-static int
-history_get_offset_0(int offset)
-{
- return offset;
-}
-
-static VALUE
-hist_get(VALUE self, VALUE index)
-{
- HIST_ENTRY *entry = NULL;
- int i;
-
- i = NUM2INT(index);
- if (i < 0) {
- i += history_length;
- }
- if (i >= 0) {
- entry = history_get(history_get_offset_func(i));
- }
- if (entry == NULL) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return rb_locale_str_new_cstr(entry->line);
-}
-
-#ifdef HAVE_REPLACE_HISTORY_ENTRY
-static VALUE
-hist_set(VALUE self, VALUE index, VALUE str)
-{
- HIST_ENTRY *entry = NULL;
- int i;
-
- i = NUM2INT(index);
- OutputStringValue(str);
- if (i < 0) {
- i += history_length;
- }
- if (i >= 0) {
- entry = replace_history_entry(history_replace_offset_func(i), RSTRING_PTR(str), NULL);
- }
- if (entry == NULL) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return str;
-}
-#else
-#define hist_set rb_f_notimplement
-#endif
-
-static VALUE
-hist_push(VALUE self, VALUE str)
-{
- OutputStringValue(str);
- add_history(RSTRING_PTR(str));
- return self;
-}
-
-static VALUE
-hist_push_method(int argc, VALUE *argv, VALUE self)
-{
- VALUE str;
-
- while (argc--) {
- str = *argv++;
- OutputStringValue(str);
- add_history(RSTRING_PTR(str));
- }
- return self;
-}
-
-static VALUE
-rb_remove_history(int index)
-{
-#ifdef HAVE_REMOVE_HISTORY
- HIST_ENTRY *entry;
- VALUE val;
-
- entry = remove_history(index);
- if (entry) {
- val = rb_locale_str_new_cstr(entry->line);
- free((void *) entry->line);
- free(entry);
- return val;
- }
- return Qnil;
-#else
- rb_notimplement();
-
- UNREACHABLE_RETURN(Qnil);
-#endif
-}
-
-static VALUE
-hist_pop(VALUE self)
-{
- if (history_length > 0) {
- return rb_remove_history(history_length - 1);
- } else {
- return Qnil;
- }
-}
-
-static VALUE
-hist_shift(VALUE self)
-{
- if (history_length > 0) {
- return rb_remove_history(0);
- } else {
- return Qnil;
- }
-}
-
-static VALUE
-hist_each(VALUE self)
-{
- HIST_ENTRY *entry;
- int i;
-
- RETURN_ENUMERATOR(self, 0, 0);
-
- for (i = 0; i < history_length; i++) {
- entry = history_get(history_get_offset_func(i));
- if (entry == NULL)
- break;
- rb_yield(rb_locale_str_new_cstr(entry->line));
- }
- return self;
-}
-
-static VALUE
-hist_length(VALUE self)
-{
- return INT2NUM(history_length);
-}
-
-static VALUE
-hist_empty_p(VALUE self)
-{
- return history_length == 0 ? Qtrue : Qfalse;
-}
-
-static VALUE
-hist_delete_at(VALUE self, VALUE index)
-{
- int i;
-
- i = NUM2INT(index);
- if (i < 0)
- i += history_length;
- if (i < 0 || i > history_length - 1) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return rb_remove_history(i);
-}
-
-#ifdef HAVE_CLEAR_HISTORY
-static VALUE
-hist_clear(VALUE self)
-{
- clear_history();
- return self;
-}
-#else
-#define hist_clear rb_f_notimplement
-#endif
-
-static VALUE
-filename_completion_proc_call(VALUE self, VALUE str)
-{
- VALUE result;
- char **matches;
- int i;
-
- matches = rl_completion_matches(StringValuePtr(str),
- rl_filename_completion_function);
- if (matches) {
- result = rb_ary_new();
- for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
- free(matches[i]);
- }
- free(matches);
- if (RARRAY_LEN(result) >= 2)
- rb_ary_shift(result);
- }
- else {
- result = Qnil;
- }
- return result;
-}
-
-static VALUE
-username_completion_proc_call(VALUE self, VALUE str)
-{
- VALUE result;
- char **matches;
- int i;
-
- matches = rl_completion_matches(StringValuePtr(str),
- rl_username_completion_function);
- if (matches) {
- result = rb_ary_new();
- for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
- free(matches[i]);
- }
- free(matches);
- if (RARRAY_LEN(result) >= 2)
- rb_ary_shift(result);
- }
- else {
- result = Qnil;
- }
- return result;
-}
-
-#ifdef HAVE_RL_CATCH_SIGNALS
-RUBY_EXTERN int rl_catch_signals;
-#endif
-#ifdef HAVE_RL_CLEAR_SIGNALS
-RUBY_EXTERN int rl_clear_signals(void);
-#endif
-
-#undef rb_intern
-void
-Init_readline(void)
-{
- VALUE history, fcomp, ucomp, version;
-
- /* Allow conditional parsing of the ~/.inputrc file. */
- rl_readline_name = (char *)"Ruby";
-
-#if defined HAVE_RL_GETC_FUNCTION
- /* libedit check rl_getc_function only when rl_initialize() is called, */
- /* and using_history() call rl_initialize(). */
- /* This assignment should be placed before using_history() */
- rl_getc_function = readline_getc;
-#elif defined HAVE_RL_EVENT_HOOK
- rl_event_hook = readline_event;
-#endif
-
- using_history();
-
- id_call = rb_intern("call");
- completion_proc = rb_intern(COMPLETION_PROC);
- completion_case_fold = rb_intern(COMPLETION_CASE_FOLD);
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
- id_pre_input_hook = rb_intern("pre_input_hook");
-#endif
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
- id_special_prefixes = rb_intern("special_prefixes");
-#endif
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
- quoting_detection_proc = rb_intern(QUOTING_DETECTION_PROC);
-#endif
-
- 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",
- readline_s_get_completion_proc, 0);
- rb_define_singleton_method(mReadline, "quoting_detection_proc=",
- readline_s_set_quoting_detection_proc, 1);
- rb_define_singleton_method(mReadline, "quoting_detection_proc",
- readline_s_get_quoting_detection_proc, 0);
- rb_define_singleton_method(mReadline, "completion_case_fold=",
- readline_s_set_completion_case_fold, 1);
- rb_define_singleton_method(mReadline, "completion_case_fold",
- readline_s_get_completion_case_fold, 0);
- rb_define_singleton_method(mReadline, "line_buffer",
- readline_s_get_line_buffer, 0);
- rb_define_singleton_method(mReadline, "point",
- readline_s_get_point, 0);
- rb_define_singleton_method(mReadline, "point=",
- readline_s_set_point, 1);
- rb_define_singleton_method(mReadline, "set_screen_size",
- readline_s_set_screen_size, 2);
- rb_define_singleton_method(mReadline, "get_screen_size",
- readline_s_get_screen_size, 0);
- rb_define_singleton_method(mReadline, "vi_editing_mode",
- readline_s_vi_editing_mode, 0);
- rb_define_singleton_method(mReadline, "vi_editing_mode?",
- readline_s_vi_editing_mode_p, 0);
- rb_define_singleton_method(mReadline, "emacs_editing_mode",
- readline_s_emacs_editing_mode, 0);
- rb_define_singleton_method(mReadline, "emacs_editing_mode?",
- readline_s_emacs_editing_mode_p, 0);
- rb_define_singleton_method(mReadline, "completion_append_character=",
- readline_s_set_completion_append_character, 1);
- rb_define_singleton_method(mReadline, "completion_append_character",
- readline_s_get_completion_append_character, 0);
- rb_define_singleton_method(mReadline, "completion_quote_character",
- readline_s_get_completion_quote_character, 0);
- rb_define_singleton_method(mReadline, "basic_word_break_characters=",
- readline_s_set_basic_word_break_characters, 1);
- rb_define_singleton_method(mReadline, "basic_word_break_characters",
- readline_s_get_basic_word_break_characters, 0);
- rb_define_singleton_method(mReadline, "completer_word_break_characters=",
- readline_s_set_completer_word_break_characters, 1);
- rb_define_singleton_method(mReadline, "completer_word_break_characters",
- readline_s_get_completer_word_break_characters, 0);
- rb_define_singleton_method(mReadline, "basic_quote_characters=",
- readline_s_set_basic_quote_characters, 1);
- rb_define_singleton_method(mReadline, "basic_quote_characters",
- readline_s_get_basic_quote_characters, 0);
- rb_define_singleton_method(mReadline, "completer_quote_characters=",
- readline_s_set_completer_quote_characters, 1);
- rb_define_singleton_method(mReadline, "completer_quote_characters",
- readline_s_get_completer_quote_characters, 0);
- rb_define_singleton_method(mReadline, "filename_quote_characters=",
- readline_s_set_filename_quote_characters, 1);
- rb_define_singleton_method(mReadline, "filename_quote_characters",
- readline_s_get_filename_quote_characters, 0);
- rb_define_singleton_method(mReadline, "refresh_line",
- readline_s_refresh_line, 0);
- rb_define_singleton_method(mReadline, "pre_input_hook=",
- readline_s_set_pre_input_hook, 1);
- rb_define_singleton_method(mReadline, "pre_input_hook",
- readline_s_get_pre_input_hook, 0);
- rb_define_singleton_method(mReadline, "insert_text",
- readline_s_insert_text, 1);
- rb_define_singleton_method(mReadline, "delete_text",
- readline_s_delete_text, -1);
- rb_define_singleton_method(mReadline, "redisplay",
- readline_s_redisplay, 0);
- rb_define_singleton_method(mReadline, "special_prefixes=",
- readline_s_set_special_prefixes, 1);
- rb_define_singleton_method(mReadline, "special_prefixes",
- readline_s_get_special_prefixes, 0);
-
-#if USE_INSERT_IGNORE_ESCAPE
- id_orig_prompt = rb_intern("orig_prompt");
- id_last_prompt = rb_intern("last_prompt");
-#endif
-
- history = rb_obj_alloc(rb_cObject);
- rb_extend_object(history, rb_mEnumerable);
- rb_define_singleton_method(history,"to_s", hist_to_s, 0);
- rb_define_singleton_method(history,"[]", hist_get, 1);
- rb_define_singleton_method(history,"[]=", hist_set, 2);
- rb_define_singleton_method(history,"<<", hist_push, 1);
- rb_define_singleton_method(history,"push", hist_push_method, -1);
- rb_define_singleton_method(history,"pop", hist_pop, 0);
- rb_define_singleton_method(history,"shift", hist_shift, 0);
- rb_define_singleton_method(history,"each", hist_each, 0);
- rb_define_singleton_method(history,"length", hist_length, 0);
- rb_define_singleton_method(history,"size", hist_length, 0);
- rb_define_singleton_method(history,"empty?", hist_empty_p, 0);
- rb_define_singleton_method(history,"delete_at", hist_delete_at, 1);
- rb_define_singleton_method(history,"clear", hist_clear, 0);
-
- /*
- * The history buffer. It extends Enumerable module, so it behaves
- * just like an array.
- * For example, gets the fifth content that the user input by
- * <code>HISTORY[4]</code>.
- */
- rb_define_const(mReadline, "HISTORY", history);
-
- fcomp = rb_obj_alloc(rb_cObject);
- rb_define_singleton_method(fcomp, "call",
- filename_completion_proc_call, 1);
- /*
- * The Object with the call method that is a completion for filename.
- * This is sets by Readline.completion_proc= method.
- */
- rb_define_const(mReadline, "FILENAME_COMPLETION_PROC", fcomp);
-
- ucomp = rb_obj_alloc(rb_cObject);
- rb_define_singleton_method(ucomp, "call",
- username_completion_proc_call, 1);
- /*
- * The Object with the call method that is a completion for usernames.
- * This is sets by Readline.completion_proc= method.
- */
- rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
- history_get_offset_func = history_get_offset_history_base;
- history_replace_offset_func = history_get_offset_0;
-#if defined HAVE_RL_LIBRARY_VERSION
- version = rb_str_new_cstr(rl_library_version);
-#if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY
- if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION,
- strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) {
- prepare_readline();
- add_history("1");
- if (history_get(history_get_offset_func(0)) == NULL) {
- history_get_offset_func = history_get_offset_0;
- }
-#ifdef HAVE_REPLACE_HISTORY_ENTRY
- if (replace_history_entry(0, "a", NULL) == NULL) {
- history_replace_offset_func = history_get_offset_history_base;
- }
-#endif
-#ifdef HAVE_CLEAR_HISTORY
- clear_history();
-#else
- {
- HIST_ENTRY *entry = remove_history(0);
- if (entry) {
- free((char *)entry->line);
- free(entry);
- }
- }
-#endif
- }
-#endif
-#else
- version = rb_str_new_cstr("2.0 or prior version");
-#endif
- /* Version string of GNU Readline or libedit. */
- rb_define_const(mReadline, "VERSION", version);
-
- rl_attempted_completion_function = readline_attempted_completion_function;
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
- rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
-#endif
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
- rl_char_is_quoted_p = &readline_char_is_quoted;
-#endif
-#ifdef HAVE_RL_CATCH_SIGNALS
- rl_catch_signals = 0;
-#endif
-#ifdef HAVE_RL_CLEAR_SIGNALS
- rl_clear_signals();
-#endif
-
- rb_gc_register_address(&readline_instream);
- rb_gc_register_address(&readline_outstream);
-}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * end:
- */
diff --git a/ext/ripper/README b/ext/ripper/README
index 2ae2470e13..70fa208920 100644
--- a/ext/ripper/README
+++ b/ext/ripper/README
@@ -13,7 +13,6 @@ Requirements
------------
* ruby 1.9 (support CVS HEAD only)
- * bison 1.28 or later (Other yaccs do not work)
Usage
-----
diff --git a/ext/ripper/depend b/ext/ripper/depend
index ff6cb223e3..db83378a1d 100644
--- a/ext/ripper/depend
+++ b/ext/ripper/depend
@@ -1,27 +1,26 @@
GEN = $(srcdir)/tools/generate.rb
SRC1 = $(top_srcdir)/parse.y
SRC2 = $(srcdir)/eventids2.c
+LRAMA = $(BASERUBY) $(top_srcdir)/tool/lrama/exe/lrama
.SUFFIXES: .y
-src: ripper.c eventids1.c eventids2table.c
+src: ripper.c ripper_init.c eventids1.c eventids1.h eventids2table.c
+ripper.c ripper_init.c eventids1.c eventids1.h eventids2table.c: depend
ripper.o: ripper.c
.y.c:
$(ECHO) compiling compiler $<
- $(Q) $(BISON) -t -v -oy.tab.c $<
- $(Q) sed -e "/^#/s!y\.tab\.c!$@!" -f $(top_srcdir)/tool/ytab.sed y.tab.c > $@
- @$(RM) y.tab.c
+ $(Q) $(LRAMA) -o$@ - $< < $<
all: check
static: check
ripper.y: $(srcdir)/tools/preproc.rb $(srcdir)/tools/dsl.rb $(top_srcdir)/parse.y $(top_srcdir)/defs/id.def
$(ECHO) extracting $@ from $(top_srcdir)/parse.y
- $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb $(top_srcdir)/parse.y > ripper.tmp.y
- $(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@
- $(Q) $(RM) ripper.tmp.y
+ $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb $(top_srcdir)/parse.y | \
+ $(RUBY) $(srcdir)/tools/preproc.rb --output=$@ - ripper.y
check: .eventids2-check
@@ -30,6 +29,10 @@ check: .eventids2-check
$(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
@exit > $@
+eventids1.h: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
+ $(ECHO) generating $@ from $(SRC1)
+ $(Q) $(RUBY) $(GEN) --mode=eventids1_h --ids1src=$(SRC1) --output=$@
+
eventids1.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
$(ECHO) generating $@ from $(SRC1)
$(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
@@ -38,6 +41,10 @@ eventids2table.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC2)
$(ECHO) generating $@ from $(SRC2)
$(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
+ripper_init.c: $(srcdir)/ripper_init.c.tmpl ripper.y $(srcdir)/tools/preproc.rb $(top_srcdir)/internal/ruby_parser.h
+ $(ECHO) generating $@ from $(srcdir)/ripper_init.c.tmpl
+ $(Q) $(RUBY) $(srcdir)/tools/preproc.rb --output=$@ --template=$(srcdir)/ripper_init.c.tmpl $(top_srcdir)/internal/ruby_parser.h
+
# Entries for Ripper maintainer
preproc: ripper.E
@@ -46,10 +53,351 @@ ripper.E: ripper.c
$(Q) $(CC) -E $(INCFLAGS) $(CPPFLAGS) $< | $(RUBY) $(srcdir)/tools/strip.rb > $@
# AUTOGENERATED DEPENDENCIES START
+eventids1.o: $(RUBY_EXTCONF_H)
+eventids1.o: $(arch_hdrdir)/ruby/config.h
+eventids1.o: $(hdrdir)/ruby/assert.h
+eventids1.o: $(hdrdir)/ruby/backward.h
+eventids1.o: $(hdrdir)/ruby/backward/2/assume.h
+eventids1.o: $(hdrdir)/ruby/backward/2/attributes.h
+eventids1.o: $(hdrdir)/ruby/backward/2/bool.h
+eventids1.o: $(hdrdir)/ruby/backward/2/inttypes.h
+eventids1.o: $(hdrdir)/ruby/backward/2/limits.h
+eventids1.o: $(hdrdir)/ruby/backward/2/long_long.h
+eventids1.o: $(hdrdir)/ruby/backward/2/stdalign.h
+eventids1.o: $(hdrdir)/ruby/backward/2/stdarg.h
+eventids1.o: $(hdrdir)/ruby/defines.h
+eventids1.o: $(hdrdir)/ruby/intern.h
+eventids1.o: $(hdrdir)/ruby/internal/abi.h
+eventids1.o: $(hdrdir)/ruby/internal/anyargs.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/assume.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/artificial.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/cold.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/const.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/error.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/format.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noalias.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noinline.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/pure.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/restrict.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/warning.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/weakref.h
+eventids1.o: $(hdrdir)/ruby/internal/cast.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_since.h
+eventids1.o: $(hdrdir)/ruby/internal/config.h
+eventids1.o: $(hdrdir)/ruby/internal/constant_p.h
+eventids1.o: $(hdrdir)/ruby/internal/core.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rarray.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rbasic.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rbignum.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rclass.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rdata.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rfile.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rhash.h
+eventids1.o: $(hdrdir)/ruby/internal/core/robject.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rregexp.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rstring.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rstruct.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+eventids1.o: $(hdrdir)/ruby/internal/ctype.h
+eventids1.o: $(hdrdir)/ruby/internal/dllexport.h
+eventids1.o: $(hdrdir)/ruby/internal/dosish.h
+eventids1.o: $(hdrdir)/ruby/internal/error.h
+eventids1.o: $(hdrdir)/ruby/internal/eval.h
+eventids1.o: $(hdrdir)/ruby/internal/event.h
+eventids1.o: $(hdrdir)/ruby/internal/fl_type.h
+eventids1.o: $(hdrdir)/ruby/internal/gc.h
+eventids1.o: $(hdrdir)/ruby/internal/glob.h
+eventids1.o: $(hdrdir)/ruby/internal/globals.h
+eventids1.o: $(hdrdir)/ruby/internal/has/attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/builtin.h
+eventids1.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/extension.h
+eventids1.o: $(hdrdir)/ruby/internal/has/feature.h
+eventids1.o: $(hdrdir)/ruby/internal/has/warning.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/array.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/bignum.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/class.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/compar.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/complex.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/cont.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/dir.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/enum.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/error.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/eval.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/file.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/hash.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/io.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/load.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/marshal.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/numeric.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/object.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/parse.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/proc.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/process.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/random.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/range.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/rational.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/re.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/ruby.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/select.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/set.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/signal.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/string.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/struct.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/thread.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/time.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/variable.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/vm.h
+eventids1.o: $(hdrdir)/ruby/internal/interpreter.h
+eventids1.o: $(hdrdir)/ruby/internal/iterator.h
+eventids1.o: $(hdrdir)/ruby/internal/memory.h
+eventids1.o: $(hdrdir)/ruby/internal/method.h
+eventids1.o: $(hdrdir)/ruby/internal/module.h
+eventids1.o: $(hdrdir)/ruby/internal/newobj.h
+eventids1.o: $(hdrdir)/ruby/internal/scan_args.h
+eventids1.o: $(hdrdir)/ruby/internal/special_consts.h
+eventids1.o: $(hdrdir)/ruby/internal/static_assert.h
+eventids1.o: $(hdrdir)/ruby/internal/stdalign.h
+eventids1.o: $(hdrdir)/ruby/internal/stdbool.h
+eventids1.o: $(hdrdir)/ruby/internal/stdckdint.h
+eventids1.o: $(hdrdir)/ruby/internal/symbol.h
+eventids1.o: $(hdrdir)/ruby/internal/value.h
+eventids1.o: $(hdrdir)/ruby/internal/value_type.h
+eventids1.o: $(hdrdir)/ruby/internal/variable.h
+eventids1.o: $(hdrdir)/ruby/internal/warning_push.h
+eventids1.o: $(hdrdir)/ruby/internal/xmalloc.h
+eventids1.o: $(hdrdir)/ruby/missing.h
+eventids1.o: $(hdrdir)/ruby/ruby.h
+eventids1.o: $(hdrdir)/ruby/st.h
+eventids1.o: $(hdrdir)/ruby/subst.h
+eventids1.o: eventids1.h
+eventids1.o: {$(VPATH)}eventids1.c
+eventids1.o: {$(VPATH)}eventids1.h
+eventids2.o: $(RUBY_EXTCONF_H)
+eventids2.o: $(arch_hdrdir)/ruby/config.h
+eventids2.o: $(hdrdir)/ruby/assert.h
+eventids2.o: $(hdrdir)/ruby/backward.h
+eventids2.o: $(hdrdir)/ruby/backward/2/assume.h
+eventids2.o: $(hdrdir)/ruby/backward/2/attributes.h
+eventids2.o: $(hdrdir)/ruby/backward/2/bool.h
+eventids2.o: $(hdrdir)/ruby/backward/2/inttypes.h
+eventids2.o: $(hdrdir)/ruby/backward/2/limits.h
+eventids2.o: $(hdrdir)/ruby/backward/2/long_long.h
+eventids2.o: $(hdrdir)/ruby/backward/2/stdalign.h
+eventids2.o: $(hdrdir)/ruby/backward/2/stdarg.h
+eventids2.o: $(hdrdir)/ruby/defines.h
+eventids2.o: $(hdrdir)/ruby/encoding.h
+eventids2.o: $(hdrdir)/ruby/intern.h
+eventids2.o: $(hdrdir)/ruby/internal/abi.h
+eventids2.o: $(hdrdir)/ruby/internal/anyargs.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/assume.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/artificial.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/cold.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/const.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/error.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/format.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noalias.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noinline.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/pure.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/restrict.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/warning.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/weakref.h
+eventids2.o: $(hdrdir)/ruby/internal/cast.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_since.h
+eventids2.o: $(hdrdir)/ruby/internal/config.h
+eventids2.o: $(hdrdir)/ruby/internal/constant_p.h
+eventids2.o: $(hdrdir)/ruby/internal/core.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rarray.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rbasic.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rbignum.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rclass.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rdata.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rfile.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rhash.h
+eventids2.o: $(hdrdir)/ruby/internal/core/robject.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rregexp.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rstring.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rstruct.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+eventids2.o: $(hdrdir)/ruby/internal/ctype.h
+eventids2.o: $(hdrdir)/ruby/internal/dllexport.h
+eventids2.o: $(hdrdir)/ruby/internal/dosish.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/re.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/string.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+eventids2.o: $(hdrdir)/ruby/internal/error.h
+eventids2.o: $(hdrdir)/ruby/internal/eval.h
+eventids2.o: $(hdrdir)/ruby/internal/event.h
+eventids2.o: $(hdrdir)/ruby/internal/fl_type.h
+eventids2.o: $(hdrdir)/ruby/internal/gc.h
+eventids2.o: $(hdrdir)/ruby/internal/glob.h
+eventids2.o: $(hdrdir)/ruby/internal/globals.h
+eventids2.o: $(hdrdir)/ruby/internal/has/attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/builtin.h
+eventids2.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/extension.h
+eventids2.o: $(hdrdir)/ruby/internal/has/feature.h
+eventids2.o: $(hdrdir)/ruby/internal/has/warning.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/array.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/bignum.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/class.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/compar.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/complex.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/cont.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/dir.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/enum.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/error.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/eval.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/file.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/hash.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/io.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/load.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/marshal.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/numeric.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/object.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/parse.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/proc.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/process.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/random.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/range.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/rational.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/re.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/ruby.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/select.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/set.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/signal.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/string.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/struct.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/thread.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/time.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/variable.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/vm.h
+eventids2.o: $(hdrdir)/ruby/internal/interpreter.h
+eventids2.o: $(hdrdir)/ruby/internal/iterator.h
+eventids2.o: $(hdrdir)/ruby/internal/memory.h
+eventids2.o: $(hdrdir)/ruby/internal/method.h
+eventids2.o: $(hdrdir)/ruby/internal/module.h
+eventids2.o: $(hdrdir)/ruby/internal/newobj.h
+eventids2.o: $(hdrdir)/ruby/internal/scan_args.h
+eventids2.o: $(hdrdir)/ruby/internal/special_consts.h
+eventids2.o: $(hdrdir)/ruby/internal/static_assert.h
+eventids2.o: $(hdrdir)/ruby/internal/stdalign.h
+eventids2.o: $(hdrdir)/ruby/internal/stdbool.h
+eventids2.o: $(hdrdir)/ruby/internal/stdckdint.h
+eventids2.o: $(hdrdir)/ruby/internal/symbol.h
+eventids2.o: $(hdrdir)/ruby/internal/value.h
+eventids2.o: $(hdrdir)/ruby/internal/value_type.h
+eventids2.o: $(hdrdir)/ruby/internal/variable.h
+eventids2.o: $(hdrdir)/ruby/internal/warning_push.h
+eventids2.o: $(hdrdir)/ruby/internal/xmalloc.h
+eventids2.o: $(hdrdir)/ruby/missing.h
+eventids2.o: $(hdrdir)/ruby/onigmo.h
+eventids2.o: $(hdrdir)/ruby/oniguruma.h
+eventids2.o: $(hdrdir)/ruby/ruby.h
+eventids2.o: $(hdrdir)/ruby/st.h
+eventids2.o: $(hdrdir)/ruby/subst.h
+eventids2.o: $(top_srcdir)/internal.h
+eventids2.o: $(top_srcdir)/internal/static_assert.h
+eventids2.o: $(top_srcdir)/rubyparser.h
+eventids2.o: eventids2.c
+eventids2.o: eventids2.h
+eventids2.o: {$(VPATH)}eventids2table.c
+eventids2.o: {$(VPATH)}parse.h
ripper.o: $(RUBY_EXTCONF_H)
ripper.o: $(arch_hdrdir)/ruby/config.h
ripper.o: $(hdrdir)/ruby.h
ripper.o: $(hdrdir)/ruby/assert.h
+ripper.o: $(hdrdir)/ruby/atomic.h
ripper.o: $(hdrdir)/ruby/backward.h
ripper.o: $(hdrdir)/ruby/backward/2/assume.h
ripper.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -126,6 +474,7 @@ ripper.o: $(hdrdir)/ruby/internal/core/rclass.h
ripper.o: $(hdrdir)/ruby/internal/core/rdata.h
ripper.o: $(hdrdir)/ruby/internal/core/rfile.h
ripper.o: $(hdrdir)/ruby/internal/core/rhash.h
+ripper.o: $(hdrdir)/ruby/internal/core/rmatch.h
ripper.o: $(hdrdir)/ruby/internal/core/robject.h
ripper.o: $(hdrdir)/ruby/internal/core/rregexp.h
ripper.o: $(hdrdir)/ruby/internal/core/rstring.h
@@ -186,6 +535,7 @@ ripper.o: $(hdrdir)/ruby/internal/intern/re.h
ripper.o: $(hdrdir)/ruby/internal/intern/ruby.h
ripper.o: $(hdrdir)/ruby/internal/intern/select.h
ripper.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ripper.o: $(hdrdir)/ruby/internal/intern/set.h
ripper.o: $(hdrdir)/ruby/internal/intern/signal.h
ripper.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ripper.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -205,6 +555,7 @@ ripper.o: $(hdrdir)/ruby/internal/special_consts.h
ripper.o: $(hdrdir)/ruby/internal/static_assert.h
ripper.o: $(hdrdir)/ruby/internal/stdalign.h
ripper.o: $(hdrdir)/ruby/internal/stdbool.h
+ripper.o: $(hdrdir)/ruby/internal/stdckdint.h
ripper.o: $(hdrdir)/ruby/internal/symbol.h
ripper.o: $(hdrdir)/ruby/internal/value.h
ripper.o: $(hdrdir)/ruby/internal/value_type.h
@@ -216,17 +567,28 @@ ripper.o: $(hdrdir)/ruby/missing.h
ripper.o: $(hdrdir)/ruby/onigmo.h
ripper.o: $(hdrdir)/ruby/oniguruma.h
ripper.o: $(hdrdir)/ruby/ractor.h
+ripper.o: $(hdrdir)/ruby/re.h
ripper.o: $(hdrdir)/ruby/regex.h
ripper.o: $(hdrdir)/ruby/ruby.h
ripper.o: $(hdrdir)/ruby/st.h
ripper.o: $(hdrdir)/ruby/subst.h
+ripper.o: $(hdrdir)/ruby/thread_native.h
ripper.o: $(hdrdir)/ruby/util.h
+ripper.o: $(hdrdir)/ruby/version.h
+ripper.o: $(top_srcdir)/ccan/check_type/check_type.h
+ripper.o: $(top_srcdir)/ccan/container_of/container_of.h
+ripper.o: $(top_srcdir)/ccan/list/list.h
+ripper.o: $(top_srcdir)/ccan/str/str.h
ripper.o: $(top_srcdir)/constant.h
+ripper.o: $(top_srcdir)/encindex.h
ripper.o: $(top_srcdir)/id_table.h
ripper.o: $(top_srcdir)/internal.h
ripper.o: $(top_srcdir)/internal/array.h
+ripper.o: $(top_srcdir)/internal/basic_operators.h
ripper.o: $(top_srcdir)/internal/bignum.h
ripper.o: $(top_srcdir)/internal/bits.h
+ripper.o: $(top_srcdir)/internal/box.h
+ripper.o: $(top_srcdir)/internal/compar.h
ripper.o: $(top_srcdir)/internal/compile.h
ripper.o: $(top_srcdir)/internal/compilers.h
ripper.o: $(top_srcdir)/internal/complex.h
@@ -241,22 +603,37 @@ ripper.o: $(top_srcdir)/internal/numeric.h
ripper.o: $(top_srcdir)/internal/parse.h
ripper.o: $(top_srcdir)/internal/rational.h
ripper.o: $(top_srcdir)/internal/re.h
+ripper.o: $(top_srcdir)/internal/ruby_parser.h
+ripper.o: $(top_srcdir)/internal/sanitizers.h
ripper.o: $(top_srcdir)/internal/serial.h
+ripper.o: $(top_srcdir)/internal/set_table.h
ripper.o: $(top_srcdir)/internal/static_assert.h
ripper.o: $(top_srcdir)/internal/string.h
+ripper.o: $(top_srcdir)/internal/struct.h
ripper.o: $(top_srcdir)/internal/symbol.h
ripper.o: $(top_srcdir)/internal/thread.h
ripper.o: $(top_srcdir)/internal/variable.h
ripper.o: $(top_srcdir)/internal/vm.h
ripper.o: $(top_srcdir)/internal/warnings.h
+ripper.o: $(top_srcdir)/method.h
ripper.o: $(top_srcdir)/node.h
+ripper.o: $(top_srcdir)/parser_node.h
+ripper.o: $(top_srcdir)/parser_st.h
ripper.o: $(top_srcdir)/regenc.h
ripper.o: $(top_srcdir)/ruby_assert.h
+ripper.o: $(top_srcdir)/ruby_atomic.h
+ripper.o: $(top_srcdir)/rubyparser.h
ripper.o: $(top_srcdir)/shape.h
ripper.o: $(top_srcdir)/symbol.h
+ripper.o: $(top_srcdir)/thread_pthread.h
+ripper.o: $(top_srcdir)/vm_core.h
+ripper.o: $(top_srcdir)/vm_opts.h
ripper.o: ../../probes.h
+ripper.o: eventids1.h
ripper.o: eventids2.c
+ripper.o: eventids2.h
ripper.o: ripper.y
+ripper.o: ripper_init.h
ripper.o: {$(VPATH)}eventids1.c
ripper.o: {$(VPATH)}eventids2table.c
ripper.o: {$(VPATH)}id.h
@@ -264,4 +641,201 @@ ripper.o: {$(VPATH)}lex.c
ripper.o: {$(VPATH)}parse.h
ripper.o: {$(VPATH)}probes.dmyh
ripper.o: {$(VPATH)}ripper.c
+ripper_init.o: $(RUBY_EXTCONF_H)
+ripper_init.o: $(arch_hdrdir)/ruby/config.h
+ripper_init.o: $(hdrdir)/ruby/assert.h
+ripper_init.o: $(hdrdir)/ruby/backward.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/assume.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/attributes.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/bool.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/inttypes.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/limits.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/long_long.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/stdalign.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/stdarg.h
+ripper_init.o: $(hdrdir)/ruby/defines.h
+ripper_init.o: $(hdrdir)/ruby/encoding.h
+ripper_init.o: $(hdrdir)/ruby/intern.h
+ripper_init.o: $(hdrdir)/ruby/internal/abi.h
+ripper_init.o: $(hdrdir)/ruby/internal/anyargs.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/assume.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/artificial.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/cold.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/const.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/format.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noalias.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noinline.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/pure.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/restrict.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/warning.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/weakref.h
+ripper_init.o: $(hdrdir)/ruby/internal/cast.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_since.h
+ripper_init.o: $(hdrdir)/ruby/internal/config.h
+ripper_init.o: $(hdrdir)/ruby/internal/constant_p.h
+ripper_init.o: $(hdrdir)/ruby/internal/core.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rarray.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rbasic.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rbignum.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rclass.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rdata.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rfile.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rhash.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/robject.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rregexp.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rstring.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rstruct.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+ripper_init.o: $(hdrdir)/ruby/internal/ctype.h
+ripper_init.o: $(hdrdir)/ruby/internal/dllexport.h
+ripper_init.o: $(hdrdir)/ruby/internal/dosish.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/re.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/string.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+ripper_init.o: $(hdrdir)/ruby/internal/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/eval.h
+ripper_init.o: $(hdrdir)/ruby/internal/event.h
+ripper_init.o: $(hdrdir)/ruby/internal/fl_type.h
+ripper_init.o: $(hdrdir)/ruby/internal/gc.h
+ripper_init.o: $(hdrdir)/ruby/internal/glob.h
+ripper_init.o: $(hdrdir)/ruby/internal/globals.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/builtin.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/extension.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/feature.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/warning.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/array.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/bignum.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/class.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/compar.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/complex.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/cont.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/dir.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/enum.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/eval.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/file.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/hash.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/io.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/load.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/marshal.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/numeric.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/object.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/parse.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/proc.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/process.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/random.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/range.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/rational.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/re.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/ruby.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/select.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/set.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/signal.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/string.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/struct.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/thread.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/time.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/variable.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/vm.h
+ripper_init.o: $(hdrdir)/ruby/internal/interpreter.h
+ripper_init.o: $(hdrdir)/ruby/internal/iterator.h
+ripper_init.o: $(hdrdir)/ruby/internal/memory.h
+ripper_init.o: $(hdrdir)/ruby/internal/method.h
+ripper_init.o: $(hdrdir)/ruby/internal/module.h
+ripper_init.o: $(hdrdir)/ruby/internal/newobj.h
+ripper_init.o: $(hdrdir)/ruby/internal/scan_args.h
+ripper_init.o: $(hdrdir)/ruby/internal/special_consts.h
+ripper_init.o: $(hdrdir)/ruby/internal/static_assert.h
+ripper_init.o: $(hdrdir)/ruby/internal/stdalign.h
+ripper_init.o: $(hdrdir)/ruby/internal/stdbool.h
+ripper_init.o: $(hdrdir)/ruby/internal/stdckdint.h
+ripper_init.o: $(hdrdir)/ruby/internal/symbol.h
+ripper_init.o: $(hdrdir)/ruby/internal/value.h
+ripper_init.o: $(hdrdir)/ruby/internal/value_type.h
+ripper_init.o: $(hdrdir)/ruby/internal/variable.h
+ripper_init.o: $(hdrdir)/ruby/internal/warning_push.h
+ripper_init.o: $(hdrdir)/ruby/internal/xmalloc.h
+ripper_init.o: $(hdrdir)/ruby/missing.h
+ripper_init.o: $(hdrdir)/ruby/onigmo.h
+ripper_init.o: $(hdrdir)/ruby/oniguruma.h
+ripper_init.o: $(hdrdir)/ruby/ruby.h
+ripper_init.o: $(hdrdir)/ruby/st.h
+ripper_init.o: $(hdrdir)/ruby/subst.h
+ripper_init.o: $(top_srcdir)/internal.h
+ripper_init.o: $(top_srcdir)/internal/array.h
+ripper_init.o: $(top_srcdir)/internal/basic_operators.h
+ripper_init.o: $(top_srcdir)/internal/bignum.h
+ripper_init.o: $(top_srcdir)/internal/bits.h
+ripper_init.o: $(top_srcdir)/internal/compar.h
+ripper_init.o: $(top_srcdir)/internal/compilers.h
+ripper_init.o: $(top_srcdir)/internal/complex.h
+ripper_init.o: $(top_srcdir)/internal/fixnum.h
+ripper_init.o: $(top_srcdir)/internal/imemo.h
+ripper_init.o: $(top_srcdir)/internal/numeric.h
+ripper_init.o: $(top_srcdir)/internal/parse.h
+ripper_init.o: $(top_srcdir)/internal/rational.h
+ripper_init.o: $(top_srcdir)/internal/ruby_parser.h
+ripper_init.o: $(top_srcdir)/internal/serial.h
+ripper_init.o: $(top_srcdir)/internal/static_assert.h
+ripper_init.o: $(top_srcdir)/internal/vm.h
+ripper_init.o: $(top_srcdir)/node.h
+ripper_init.o: $(top_srcdir)/ruby_assert.h
+ripper_init.o: $(top_srcdir)/rubyparser.h
+ripper_init.o: eventids1.h
+ripper_init.o: eventids2.h
+ripper_init.o: ripper_init.h
+ripper_init.o: {$(VPATH)}parse.h
+ripper_init.o: {$(VPATH)}ripper_init.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
index 05687497ac..87f2f588ec 100644
--- a/ext/ripper/eventids2.c
+++ b/ext/ripper/eventids2.c
@@ -1,3 +1,11 @@
+#include "ruby/ruby.h"
+#include "rubyparser.h"
+#define YYSTYPE_IS_DECLARED
+#include "parse.h"
+#include "eventids2.h"
+#include "internal.h"
+#include "internal/static_assert.h"
+
typedef struct {
ID ripper_id_backref;
ID ripper_id_backtick;
@@ -57,7 +65,9 @@ static ripper_scanner_ids_t ripper_scanner_ids;
#include "eventids2table.c"
-static void
+STATIC_ASSERT(eventids2_table_size, RIPPER_EVENTIDS2_TABLE_SIZE == sizeof(ripper_scanner_ids)/sizeof(ID));
+
+void
ripper_init_eventids2(void)
{
#define set_id2(name) ripper_scanner_ids.ripper_id_##name = rb_intern_const("on_"#name)
@@ -118,7 +128,7 @@ ripper_init_eventids2(void)
STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
-static ID
+ID
ripper_token2eventid(enum yytokentype tok)
{
#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)+1
@@ -245,7 +255,6 @@ ripper_token2eventid(enum yytokentype tok)
[tRATIONAL] = O(rational),
[tREGEXP_BEG] = O(regexp_beg),
[tREGEXP_END] = O(regexp_end),
- [tRPAREN] = O(rparen),
[tRSHFT] = O(op),
[tSTAR] = O(op),
[tDSTAR] = O(op),
diff --git a/ext/ripper/eventids2.h b/ext/ripper/eventids2.h
new file mode 100644
index 0000000000..49e46432b9
--- /dev/null
+++ b/ext/ripper/eventids2.h
@@ -0,0 +1,8 @@
+#ifndef RIPPER_EVENTIDS2
+#define RIPPER_EVENTIDS2
+
+void ripper_init_eventids2(void);
+void ripper_init_eventids2_table(VALUE self);
+ID ripper_token2eventid(enum yytokentype tok);
+
+#endif /* RIPPER_EVENTIDS2 */
diff --git a/ext/ripper/extconf.rb b/ext/ripper/extconf.rb
index 65cb5030d3..c3c56c27c5 100644
--- a/ext/ripper/extconf.rb
+++ b/ext/ripper/extconf.rb
@@ -5,23 +5,14 @@ require 'mkmf'
require 'rbconfig'
def main
- yacc = ENV["YACC"] || "bison"
-
- unless find_executable(yacc)
- unless File.exist?('ripper.c') or File.exist?("#{$srcdir}/ripper.c")
- raise 'missing bison; abort'
- end
- end
- $objs = %w(ripper.o)
- $distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids2table.c)
+ $objs = %w(eventids1.o eventids2.o ripper.o ripper_init.o)
+ $distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids1.h eventids2table.c ripper_init.c)
$cleanfiles.concat %w(ripper.E ripper.output y.output .eventids2-check)
$defs << '-DRIPPER'
$defs << '-DRIPPER_DEBUG' if $debug
$VPATH << '$(topdir)' << '$(top_srcdir)'
$INCFLAGS << ' -I$(topdir) -I$(top_srcdir)'
- create_makefile 'ripper' do |conf|
- conf << "BISON = #{yacc}"
- end
+ create_makefile 'ripper'
end
main
diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb
index 6a3c04af30..9b849dfeae 100644
--- a/ext/ripper/lib/ripper/lexer.rb
+++ b/ext/ripper/lib/ripper/lexer.rb
@@ -53,6 +53,7 @@ class Ripper
end
class Lexer < ::Ripper #:nodoc: internal use only
+ # :stopdoc:
class State
attr_reader :to_int, :to_s
@@ -67,7 +68,7 @@ class Ripper
when 0, :to_int
@to_int
when 1, :to_s
- @event
+ @to_s
else
nil
end
@@ -242,7 +243,12 @@ class Ripper
end
def on_error2(mesg, elem)
- @errors.push Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
+ if elem
+ elem = Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
+ else
+ elem = Elem.new([lineno(), column()], __callee__, token(), state(), mesg)
+ end
+ @errors.push elem
end
PARSER_EVENTS.grep(/_error\z/) do |e|
arity = PARSER_EVENT_TABLE.fetch(e)
@@ -253,6 +259,7 @@ class Ripper
(SCANNER_EVENTS.map {|event|:"on_#{event}"} - private_instance_methods(false)).each do |event|
alias_method event, :_push_token
end
+ # :startdoc:
end
# [EXPERIMENTAL]
diff --git a/ext/ripper/ripper_init.c.tmpl b/ext/ripper/ripper_init.c.tmpl
new file mode 100644
index 0000000000..11e432423d
--- /dev/null
+++ b/ext/ripper/ripper_init.c.tmpl
@@ -0,0 +1,680 @@
+%# -*- c -*-
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+#include "internal.h"
+#include "rubyparser.h"
+#define YYSTYPE_IS_DECLARED
+#include "parse.h"
+#include "internal/parse.h"
+#include "internal/ruby_parser.h"
+#include "node.h"
+#include "eventids1.h"
+#include "eventids2.h"
+#include "ripper_init.h"
+
+#define STR_NEW2(ptr) rb_enc_str_new((ptr),strlen(ptr),rb_ruby_parser_enc(p))
+#define RIPPER_VERSION "0.1.0"
+
+ID id_warn, id_warning, id_gets, id_assoc;
+
+enum lex_type {
+ lex_type_str,
+ lex_type_io,
+ lex_type_generic,
+};
+
+struct ripper {
+ rb_parser_t *p;
+ enum lex_type type;
+ union {
+ struct lex_pointer_string ptr_str;
+ VALUE val;
+ } data;
+};
+
+static void
+ripper_parser_mark2(void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ if (r->p) {
+ ripper_parser_mark(r->p);
+
+ switch (r->type) {
+ case lex_type_str:
+ rb_gc_mark(r->data.ptr_str.str);
+ break;
+ case lex_type_io:
+ rb_gc_mark(r->data.val);
+ break;
+ case lex_type_generic:
+ rb_gc_mark(r->data.val);
+ break;
+ }
+ }
+}
+
+static void
+ripper_parser_free2(void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ if (r->p) ripper_parser_free(r->p);
+ xfree(r);
+}
+
+static size_t
+ripper_parser_memsize2(const void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ return (r->p) ? ripper_parser_memsize(r->p) : 0;
+}
+
+static const rb_data_type_t parser_data_type = {
+ "ripper",
+ {
+ ripper_parser_mark2,
+ ripper_parser_free2,
+ ripper_parser_memsize2,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static rb_parser_string_t *
+ripper_lex_get_generic(struct parser_params *p, rb_parser_input_data input, int line_count)
+{
+ VALUE src = (VALUE)input;
+ VALUE line = rb_funcallv_public(src, id_gets, 0, 0);
+ if (NIL_P(line)) return 0;
+ if (!RB_TYPE_P(line, T_STRING)) {
+ rb_raise(rb_eTypeError,
+ "gets returned %"PRIsVALUE" (expected String or nil)",
+ rb_obj_class(line));
+ }
+ return rb_str_to_parser_string(p, line);
+}
+
+void
+ripper_compile_error(struct parser_params *p, const char *fmt, ...)
+{
+ VALUE str;
+ va_list args;
+
+ va_start(args, fmt);
+ str = rb_vsprintf(fmt, args);
+ va_end(args);
+ rb_funcall(ripper_value(p), rb_intern("compile_error"), 1, str);
+ ripper_error(p);
+}
+
+static rb_parser_string_t *
+ripper_lex_io_get(struct parser_params *p, rb_parser_input_data input, int line_count)
+{
+ VALUE src = (VALUE)input;
+ VALUE line = rb_io_gets(src);
+ if (NIL_P(line)) return 0;
+ return rb_str_to_parser_string(p, line);
+}
+
+static rb_parser_string_t *
+ripper_lex_get_str(struct parser_params *p, rb_parser_input_data input, int line_count)
+{
+ return rb_parser_lex_get_str(p, (struct lex_pointer_string *)input);
+}
+
+static VALUE
+ripper_s_allocate(VALUE klass)
+{
+ struct ripper *r;
+
+ VALUE self = TypedData_Make_Struct(klass, struct ripper,
+ &parser_data_type, r);
+
+#ifdef UNIVERSAL_PARSER
+ const rb_parser_config_t *config = rb_ruby_parser_config();
+ r->p = rb_ripper_parser_params_allocate(config);
+#else
+ r->p = rb_ruby_ripper_parser_allocate();
+#endif
+ rb_ruby_parser_set_value(r->p, self);
+ return self;
+}
+
+static struct parser_params *
+ripper_parser_params(VALUE self, bool initialized)
+{
+ struct ripper *r;
+ struct parser_params *p;
+
+ TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
+ p = r->p;
+ if (initialized && !rb_ruby_ripper_initialized_p(p)) {
+ rb_raise(rb_eArgError, "method called for uninitialized object");
+ }
+ return p;
+}
+
+/*
+ * call-seq:
+ * ripper.error? -> Boolean
+ *
+ * Return true if parsed source has errors.
+ */
+static VALUE
+ripper_error_p(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return RBOOL(rb_ruby_parser_error_p(p));
+}
+
+/*
+ * call-seq:
+ * ripper.end_seen? -> Boolean
+ *
+ * Return true if parsed source ended by +\_\_END\_\_+.
+ */
+static VALUE
+ripper_parser_end_seen_p(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return RBOOL(rb_ruby_parser_end_seen_p(p));
+}
+
+/*
+ * call-seq:
+ * ripper.encoding -> encoding
+ *
+ * Return encoding of the source.
+ */
+static VALUE
+ripper_parser_encoding(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return rb_enc_from_encoding(rb_ruby_parser_encoding(p));
+}
+
+/*
+ * call-seq:
+ * ripper.yydebug -> true or false
+ *
+ * Get yydebug.
+ */
+static VALUE
+ripper_parser_get_yydebug(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ return RBOOL(rb_ruby_parser_get_yydebug(p));
+}
+
+/*
+ * call-seq:
+ * ripper.yydebug = flag
+ *
+ * Set yydebug.
+ */
+static VALUE
+ripper_parser_set_yydebug(VALUE self, VALUE flag)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ rb_ruby_parser_set_yydebug(p, RTEST(flag));
+ return flag;
+}
+
+/*
+ * call-seq:
+ * ripper.debug_output -> obj
+ *
+ * Get debug output.
+ */
+static VALUE
+ripper_parser_get_debug_output(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ return rb_ruby_parser_debug_output(p);
+}
+
+/*
+ * call-seq:
+ * ripper.debug_output = obj
+ *
+ * Set debug output.
+ */
+static VALUE
+ripper_parser_set_debug_output(VALUE self, VALUE output)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ rb_ruby_parser_set_debug_output(p, output);
+ return output;
+}
+
+static int
+ripper_parser_dedent_string(struct parser_params *p, VALUE string, int width)
+{
+ int col;
+ rb_parser_string_t *str;
+ str = rb_str_to_parser_string(p, string);
+ col = rb_ruby_ripper_dedent_string(p, str, width);
+ rb_str_replace(string, rb_str_new_parser_string(str));
+ rb_parser_string_free(p, str);
+ return col;
+}
+
+#ifdef UNIVERSAL_PARSER
+struct dedent_string_arg {
+ struct parser_params *p;
+ VALUE input;
+ VALUE width;
+};
+
+static VALUE
+parser_dedent_string0(VALUE a)
+{
+ struct dedent_string_arg *arg = (void *)a;
+ int wid, col;
+
+ StringValue(arg->input);
+ wid = NUM2UINT(arg->width);
+ col = ripper_parser_dedent_string(arg->p, arg->input, wid);
+ return INT2NUM(col);
+}
+
+static VALUE
+parser_free(VALUE a)
+{
+ struct parser_params *p = (void *)a;
+
+ rb_ruby_parser_free(p);
+ return Qnil;
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.dedent_string(input, width) -> Integer
+ *
+ * USE OF RIPPER LIBRARY ONLY.
+ *
+ * Strips up to +width+ leading whitespaces from +input+,
+ * and returns the stripped column width.
+ */
+#ifdef UNIVERSAL_PARSER
+static VALUE
+parser_dedent_string(VALUE self, VALUE input, VALUE width)
+{
+ struct parser_params *p;
+ struct dedent_string_arg args;
+
+ p = rb_parser_params_new();
+
+ args.p = p;
+ args.input = input;
+ args.width = width;
+ return rb_ensure(parser_dedent_string0, (VALUE)&args, parser_free, (VALUE)p);
+}
+#else
+static VALUE
+parser_dedent_string(VALUE self, VALUE input, VALUE width)
+{
+ int wid, col;
+
+ StringValue(input);
+ wid = NUM2UINT(width);
+ col = ripper_parser_dedent_string(0, input, wid);
+ return INT2NUM(col);
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.new(src, filename="(ripper)", lineno=1) -> ripper
+ *
+ * Create a new Ripper object.
+ * _src_ must be a String, an 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 ripper *r;
+ struct parser_params *p;
+ VALUE src, fname, lineno;
+ rb_parser_lex_gets_func *gets;
+ VALUE sourcefile_string;
+ const char *sourcefile;
+ int sourceline;
+ rb_parser_input_data input;
+
+ p = ripper_parser_params(self, false);
+ TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
+ rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
+ if (RB_TYPE_P(src, T_FILE)) {
+ gets = ripper_lex_io_get;
+ r->type = lex_type_io;
+ r->data.val = src;
+ input = (rb_parser_input_data)src;
+ }
+ else if (rb_respond_to(src, id_gets)) {
+ gets = ripper_lex_get_generic;
+ r->type = lex_type_generic;
+ r->data.val = src;
+ input = (rb_parser_input_data)src;
+ }
+ else {
+ StringValue(src);
+ gets = ripper_lex_get_str;
+ r->type = lex_type_str;
+ r->data.ptr_str.str = src;
+ r->data.ptr_str.ptr = 0;
+ input = (rb_parser_input_data)&r->data.ptr_str;
+ }
+ if (NIL_P(fname)) {
+ fname = STR_NEW2("(ripper)");
+ OBJ_FREEZE(fname);
+ }
+ else {
+ StringValueCStr(fname);
+ fname = rb_str_new_frozen(fname);
+ }
+ rb_ruby_ripper_parser_initialize(p);
+
+ sourcefile_string = fname;
+ sourcefile = RSTRING_PTR(fname);
+ sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
+
+ rb_ruby_parser_ripper_initialize(p, gets, input, sourcefile_string, sourcefile, sourceline);
+
+ return Qnil;
+}
+
+static VALUE
+ripper_parse0(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ rb_ruby_ripper_parse0(p);
+ return rb_ruby_parser_result(p);
+}
+
+static VALUE
+ripper_ensure(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ rb_ruby_parser_set_parsing_thread(p, 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 *p = ripper_parser_params(self, true);
+ VALUE result;
+
+ if (!NIL_P(rb_ruby_parser_parsing_thread(p))) {
+ if (rb_ruby_parser_parsing_thread(p) == rb_thread_current())
+ rb_raise(rb_eArgError, "Ripper#parse is not reentrant");
+ else
+ rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe");
+ }
+ rb_ruby_parser_set_parsing_thread(p, rb_thread_current());
+ result = rb_ensure(ripper_parse0, self, ripper_ensure, self);
+ RB_GC_GUARD(self);
+
+ return 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 *p = ripper_parser_params(self, true);
+ long col;
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ col = rb_ruby_ripper_column(p);
+ return LONG2NUM(col);
+}
+
+/*
+ * call-seq:
+ * ripper.filename -> String
+ *
+ * Return current parsing filename.
+ */
+static VALUE
+ripper_filename(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+
+ return rb_ruby_parser_ruby_sourcefile_string(p);
+}
+
+/*
+ * 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 *p = ripper_parser_params(self, true);
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ return INT2NUM(rb_ruby_parser_ruby_sourceline(p));
+}
+
+/*
+ * call-seq:
+ * ripper.state -> Integer
+ *
+ * Return scanner state of current token.
+ */
+static VALUE
+ripper_state(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ return INT2NUM(rb_ruby_parser_lex_state(p));
+}
+
+/*
+ * call-seq:
+ * ripper.token -> String
+ *
+ * Return the current token string.
+ */
+static VALUE
+ripper_token(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+ long pos, len;
+ VALUE str;
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ pos = rb_ruby_ripper_column(p);
+ len = rb_ruby_ripper_token_len(p);
+ str = rb_str_new_parser_string(rb_ruby_ripper_lex_lastline(p));
+ return rb_str_subseq(str, pos, len);
+}
+
+#ifdef RIPPER_DEBUG
+/* :nodoc: */
+static VALUE
+ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
+{
+ StringValue(msg);
+ if (UNDEF_P(obj)) {
+ rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
+ }
+ return Qnil;
+}
+
+/* :nodoc: */
+static VALUE
+ripper_raw_value(VALUE self, VALUE obj)
+{
+ return ULONG2NUM(obj);
+}
+
+/* :nodoc: */
+static VALUE
+ripper_validate_object(VALUE self, VALUE x)
+{
+ if (x == Qfalse) return x;
+ if (x == Qtrue) return x;
+ if (NIL_P(x)) return x;
+ if (UNDEF_P(x))
+ rb_raise(rb_eArgError, "Qundef given");
+ if (FIXNUM_P(x)) return x;
+ if (SYMBOL_P(x)) return x;
+ switch (BUILTIN_TYPE(x)) {
+ case T_STRING:
+ case T_OBJECT:
+ case T_ARRAY:
+ case T_BIGNUM:
+ case T_FLOAT:
+ case T_COMPLEX:
+ case T_RATIONAL:
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
+ (void *)x, rb_obj_classname(x));
+ }
+ if (!RBASIC_CLASS(x)) {
+ rb_raise(rb_eArgError, "hidden ruby object: %p (%s)",
+ (void *)x, rb_builtin_type_name(TYPE(x)));
+ }
+ return x;
+}
+#endif
+
+#ifdef UNIVERSAL_PARSER
+struct lex_state_name_arg {
+ struct parser_params *p;
+ VALUE state;
+};
+
+static VALUE
+lex_state_name0(VALUE a)
+{
+ struct lex_state_name_arg *arg = (void *)a;
+
+ return rb_ruby_ripper_lex_state_name(arg->p, NUM2INT(arg->state));
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.lex_state_name(integer) -> string
+ *
+ * Returns a string representation of lex_state.
+ */
+#ifdef UNIVERSAL_PARSER
+static VALUE
+ripper_lex_state_name(VALUE self, VALUE state)
+{
+ struct parser_params *p;
+ struct lex_state_name_arg args;
+
+ p = rb_parser_params_new();
+
+ args.p = p;
+ args.state = state;
+
+ return rb_ensure(lex_state_name0, (VALUE)&args, parser_free, (VALUE)p);
+}
+#else
+static VALUE
+ripper_lex_state_name(VALUE self, VALUE state)
+{
+ return rb_ruby_ripper_lex_state_name(0, NUM2INT(state));
+}
+#endif
+
+void
+Init_ripper(void)
+{
+ ripper_init_eventids1();
+ ripper_init_eventids2();
+ id_warn = rb_intern_const("warn");
+ id_warning = rb_intern_const("warning");
+ id_gets = rb_intern_const("gets");
+ id_assoc = rb_intern_const("=>");
+
+ InitVM(ripper);
+}
+
+void
+InitVM_ripper(void)
+{
+ VALUE Ripper;
+
+ Ripper = rb_define_class("Ripper", rb_cObject);
+ /* version of Ripper */
+ rb_define_const(Ripper, "Version", rb_usascii_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, "filename", ripper_filename, 0);
+ rb_define_method(Ripper, "lineno", ripper_lineno, 0);
+ rb_define_method(Ripper, "state", ripper_state, 0);
+ rb_define_method(Ripper, "token", ripper_token, 0);
+ rb_define_method(Ripper, "end_seen?", ripper_parser_end_seen_p, 0);
+ rb_define_method(Ripper, "encoding", ripper_parser_encoding, 0);
+ rb_define_method(Ripper, "yydebug", ripper_parser_get_yydebug, 0);
+ rb_define_method(Ripper, "yydebug=", ripper_parser_set_yydebug, 1);
+ rb_define_method(Ripper, "debug_output", ripper_parser_get_debug_output, 0);
+ rb_define_method(Ripper, "debug_output=", ripper_parser_set_debug_output, 1);
+ rb_define_method(Ripper, "error?", ripper_error_p, 0);
+#ifdef RIPPER_DEBUG
+ rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2);
+ rb_define_method(Ripper, "rawVALUE", ripper_raw_value, 1);
+ rb_define_method(Ripper, "validate_object", ripper_validate_object, 1);
+#endif
+
+ rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2);
+ rb_define_private_method(Ripper, "dedent_string", parser_dedent_string, 2);
+
+ rb_define_singleton_method(Ripper, "lex_state_name", ripper_lex_state_name, 1);
+
+<% @exprs.each do |expr, desc| -%>
+ /* <%=desc%> */
+ rb_define_const(Ripper, "<%=expr%>", INT2NUM(<%=expr%>));
+<% end %>
+ ripper_init_eventids1_table(Ripper);
+ ripper_init_eventids2_table(Ripper);
+
+# if 0
+ /* Hack to let RDoc document SCRIPT_LINES__ */
+
+ /*
+ * When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded
+ * after the assignment will be added as an Array of lines with the file
+ * name as the key.
+ */
+ rb_define_global_const("SCRIPT_LINES__", Qnil);
+#endif
+}
diff --git a/ext/ripper/ripper_init.h b/ext/ripper/ripper_init.h
new file mode 100644
index 0000000000..9d228107d1
--- /dev/null
+++ b/ext/ripper/ripper_init.h
@@ -0,0 +1,6 @@
+#ifndef RIPPER_INIT_H
+#define RIPPER_INIT_H
+
+PRINTF_ARGS(void ripper_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
+
+#endif /* RIPPER_INIT_H */
diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb
index 49ff51711f..38f859dd97 100644
--- a/ext/ripper/tools/dsl.rb
+++ b/ext/ripper/tools/dsl.rb
@@ -1,83 +1,177 @@
+# frozen_string_literal: true
+
# Simple DSL implementation for Ripper code generation
#
-# input: /*% ripper: stmts_add(stmts_new, void_stmt) %*/
+# input: /*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/
# output:
# VALUE v1, v2;
# v1 = dispatch0(stmts_new);
# v2 = dispatch0(void_stmt);
# $$ = dispatch2(stmts_add, v1, v2);
-
-$dollar = "$$"
-alias $$ $dollar
+#
+# - The code must be a single line.
+#
+# - The code is basically Ruby code, even if it appears like in C and
+# the result will be processed as C. e.g., comments need to be in
+# Ruby style.
class DSL
- def initialize(code, options)
+ TAG_PATTERN = /(?><[a-zA-Z0-9_]+>)/.source
+ NAME_PATTERN = /(?>\$|\d+|[a-zA-Z_][a-zA-Z0-9_]*|\[[a-zA-Z_.][-a-zA-Z0-9_.]*\])(?>(?:\.|->)[a-zA-Z_][a-zA-Z0-9_]*)*/.source
+ NOT_REF_PATTERN = /(?>\#.*|[^\"$@]*|"(?>\\.|[^\"])*")/.source
+
+ def self.line?(line, lineno = nil, indent: nil)
+ if %r<(?<space>\s*)/\*% *ripper(?:\[(?<option>.*?)\])?: *(?<code>.*?) *%\*/> =~ line
+ new(code, comma_split(option), lineno, indent: indent || space)
+ end
+ end
+
+ def self.comma_split(str)
+ str or return []
+ str.scan(/(([^(,)]+|\((?:,|\g<0>)*\))+)/).map(&:first)
+ end
+
+ using Module.new {
+ refine Array do
+ def to_s
+ if empty?
+ "rb_ary_new()"
+ else
+ "rb_ary_new_from_args(#{size}, #{map(&:to_s).join(', ')})"
+ end
+ end
+ end
+ }
+
+ class Var
+ class Table < Hash
+ def initialize(&block)
+ super() {|tbl, arg|
+ tbl.fetch(arg, &block)
+ }
+ end
+
+ def fetch(arg, &block)
+ super {
+ self[arg] = Var.new(self, arg, &block)
+ }
+ end
+
+ def add(&block)
+ v = new_var
+ self[v] = Var.new(self, v, &block)
+ end
+
+ def defined?(name)
+ name = name.to_s
+ any? {|_, v| v.var == name}
+ end
+
+ def new_var
+ "v#{size+1}"
+ end
+ end
+
+ attr_reader :var, :value
+
+ PRETTY_PRINT_INSTANCE_VARIABLES = instance_methods(false).freeze
+
+ def pretty_print_instance_variables
+ PRETTY_PRINT_INSTANCE_VARIABLES
+ end
+
+ alias to_s var
+
+ def initialize(table, arg, &block)
+ @var = table.new_var
+ @value = yield arg
+ @table = table
+ end
+
+ # Indexing.
+ #
+ # $:1 -> v1=get_value($:1)
+ # $:1[0] -> rb_ary_entry(v1, 0)
+ # $:1[0..1] -> [rb_ary_entry(v1, 0), rb_ary_entry(v1, 1)]
+ # *$:1[0..1] -> rb_ary_entry(v1, 0), rb_ary_entry(v1, 1)
+ #
+ # Splat needs `[range]` because `Var` does not have the length info.
+ def [](idx)
+ if ::Range === idx
+ idx.map {|i| self[i]}
+ else
+ @table.fetch("#@var[#{idx}]") {"rb_ary_entry(#{@var}, #{idx})"}
+ end
+ end
+ end
+
+ def initialize(code, options, lineno = nil, indent: "\t\t\t")
+ @lineno = lineno
+ @indent = indent
@events = {}
@error = options.include?("error")
- @brace = options.include?("brace")
if options.include?("final")
@final = "p->result"
else
- @final = (options.grep(/\A\$(?:\$|\d+)\z/)[0] || "$$")
+ @final = (options.grep(/\A\$#{NAME_PATTERN}\z/o)[0] || "p->s_lvalue")
end
- @vars = 0
- # create $1 == "$1", $2 == "$2", ...
- s = (1..20).map {|n| "$#{n}"}
- re = Array.new(s.size, "([^\0]+)")
- /#{re.join("\0")}/ =~ s.join("\0")
+ bind = dsl_binding
+ @var_table = Var::Table.new {|arg| "get_value(#{arg})"}
+ code = code.gsub(%r[\G#{NOT_REF_PATTERN}\K(\$|\$:|@)#{TAG_PATTERN}?#{NAME_PATTERN}]o) {
+ if (arg = $&) == "$:$"
+ '"p->s_lvalue"'
+ elsif arg.start_with?("$:")
+ "(#{@var_table[arg]}=@var_table[#{arg.dump}])"
+ else
+ arg.dump
+ end
+ }
+ @last_value = bind.eval(code)
+ rescue SyntaxError
+ $stderr.puts "error on line #{@lineno}" if @lineno
+ raise
+ end
+ def dsl_binding(p = "p")
# struct parser_params *p
- p = p = "p"
-
- @code = ""
- @last_value = eval(code)
+ binding
end
attr_reader :events
undef lambda
undef hash
- undef class
+ undef :class
def generate
- s = "#@code#@final=#@last_value;"
- s = "{VALUE #{ (1..@vars).map {|v| "v#{ v }" }.join(",") };#{ s }}" if @vars > 0
+ s = "#@final=#@last_value;"
s << "ripper_error(p);" if @error
- s = "{#{ s }}" if @brace
- "\t\t\t#{s}"
- end
-
- def new_var
- "v#{ @vars += 1 }"
- end
-
- def opt_event(event, default, addend)
- add_event(event, [default, addend], true)
+ unless @var_table.empty?
+ vars = @var_table.map {|_, v| "#{v.var}=#{v.value}"}.join(", ")
+ s = "VALUE #{ vars }; #{ s }"
+ end
+ "#{@indent}{#{s}}"
end
- def add_event(event, args, qundef_check = false)
+ def add_event(event, args)
event = event.to_s.sub(/!\z/, "")
@events[event] = args.size
vars = []
args.each do |arg|
- vars << v = new_var
- @code << "#{ v }=#{ arg };"
+ arg = @var_table.add {arg} unless Var === arg
+ vars << arg
end
- v = new_var
- d = "dispatch#{ args.size }(#{ [event, *vars].join(",") })"
- d = "#{ vars.last }==Qundef ? #{ vars.first } : #{ d }" if qundef_check
- @code << "#{ v }=#{ d };"
- v
+ @var_table.add {"dispatch#{ args.size }(#{ [event, *vars].join(",") })"}
end
def method_missing(event, *args)
if event.to_s =~ /!\z/
add_event(event, args)
- elsif args.empty? and /\Aid[A-Z_]/ =~ event.to_s
+ elsif args.empty? and (/\Aid[A-Z_]/ =~ event or @var_table.defined?(event))
event
else
- "#{ event }(#{ args.join(", ") })"
+ "#{ event }(#{ args.map(&:to_s).join(", ") })"
end
end
@@ -85,4 +179,3 @@ class DSL
name
end
end
-
diff --git a/ext/ripper/tools/generate.rb b/ext/ripper/tools/generate.rb
index 883e6ef2df..57ecac0b39 100644
--- a/ext/ripper/tools/generate.rb
+++ b/ext/ripper/tools/generate.rb
@@ -11,7 +11,7 @@ def main
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|
+ parser.on('--mode=MODE', 'check, eventids1_h, eventids1, or eventids2table.') {|m|
mode = m
}
parser.on('--ids1src=PATH', 'A source file of event-IDs 1 (parse.y).') {|path|
@@ -45,6 +45,9 @@ def main
abort "event crash: #{common.join(' ')}"
end
exit 0
+ when 'eventids1_h'
+ usage 'no --ids1src' unless ids1src
+ result = generate_eventids1_h(read_ids1(ids1src))
when 'eventids1'
usage 'no --ids1src' unless ids1src
result = generate_eventids1(read_ids1(ids1src))
@@ -67,28 +70,44 @@ def usage(msg)
exit false
end
-def generate_eventids1(ids)
+def generate_eventids1_h(ids)
buf = "".dup
- buf << %Q[static struct {\n]
+ buf << %Q[#ifndef RIPPER_EVENTIDS1\n]
+ buf << %Q[#define RIPPER_EVENTIDS1\n]
+ buf << %Q[\n]
+ buf << %Q[#define RIPPER_ID(n) ripper_parser_ids.id_ ## n\n]
+ buf << %Q[void ripper_init_eventids1(void);\n]
+ buf << %Q[void ripper_init_eventids1_table(VALUE self);\n]
+ buf << %Q[\n]
+ buf << %Q[struct ripper_parser_ids {\n]
ids.each do |id, arity|
buf << %Q[ ID id_#{id};\n]
end
- buf << %Q[} ripper_parser_ids;\n]
+ buf << %Q[};\n]
buf << %Q[\n]
- ids.each do |id, arity|
- buf << %Q[#define ripper_id_#{id} ripper_parser_ids.id_#{id}\n]
- end
+ buf << %Q[#endif /* RIPPER_EVENTIDS1 */\n]
+ buf << %Q[\n]
+end
+
+def generate_eventids1(ids)
+ buf = "".dup
+ buf << %Q[#include "ruby/ruby.h"\n]
+ buf << %Q[#include "eventids1.h"\n]
+ buf << %Q[\n]
+ buf << %Q[struct ripper_parser_ids ripper_parser_ids;\n]
buf << %Q[\n]
- buf << %Q[static void\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids1(void)\n]
buf << %Q[{\n]
- buf << %Q[#define set_id1(name) ripper_id_##name = rb_intern_const("on_"#name)\n]
+ buf << %Q[#define set_id1(name) RIPPER_ID(name) = rb_intern_const("on_"#name)\n]
ids.each do |id, arity|
buf << %Q[ set_id1(#{id});\n]
end
buf << %Q[}\n]
buf << %Q[\n]
- buf << %Q[static void\n]
+ buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
+ buf << %Q[\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids1_table(VALUE self)\n]
buf << %Q[{\n]
buf << %Q[ VALUE h = rb_hash_new();\n]
@@ -102,7 +121,11 @@ end
def generate_eventids2_table(ids)
buf = "".dup
- buf << %Q[static void\n]
+ buf << %Q[#include "ruby/ruby.h"\n]
+ buf << %Q[\n]
+ buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
+ buf << %Q[\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
buf << %Q[{\n]
buf << %Q[ VALUE h = rb_hash_new();\n]
@@ -111,6 +134,8 @@ def generate_eventids2_table(ids)
buf << %Q[ rb_hash_aset(h, intern_sym("#{id}"), INT2FIX(1));\n]
end
buf << %Q[}\n]
+ buf << %Q[\n]
+ buf << %Q[#define RIPPER_EVENTIDS2_TABLE_SIZE #{ids.size}\n]
buf
end
@@ -146,9 +171,7 @@ def read_ids1_with_locations(path)
line.scan(/\bdispatch(\d)\((\w+)/) do |arity, event|
(h[event] ||= []).push [f.lineno, arity.to_i]
end
- if line =~ %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
- gen = DSL.new($2, ($1 || "").split(","))
- gen.generate
+ if gen = DSL.line?(line, f.lineno)
gen.events.each do |event, arity|
(h[event] ||= []).push [f.lineno, arity.to_i]
end
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index cd85a5da61..5e8a6e0cb5 100644
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -5,11 +5,15 @@ require 'optparse'
def main
output = nil
+ template = nil
parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
+ parser.banner = "Usage: #{File.basename($0)} [--output=PATH] [--template=PATH] <parse.y>"
parser.on('--output=PATH', 'An output file.') {|path|
output = path
}
+ parser.on('--template=PATH', 'An template file.') {|path|
+ template = path
+ }
parser.on('--help', 'Prints this message and quit.') {
puts parser.help
exit true
@@ -17,50 +21,56 @@ def main
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)"
+ warn err.message
+ abort parser.help
end
out = "".dup
- File.open(ARGV[0]) {|f|
- prelude f, out
- grammar f, out
- usercode f, out
- }
- if output
- File.open(output, 'w') {|f|
- f.write out
+ if ARGV[0] == "-"
+ unless ARGV.size == 2
+ abort "wrong number of arguments (#{ARGV.size} for 2)"
+ end
+ process STDIN, out, ARGV[1], template
+ else
+ unless ARGV.size == 1
+ abort "wrong number of arguments (#{ARGV.size} for 1)"
+ end
+ File.open(ARGV[0]) {|f|
+ process f, out, ARGV[0], template
}
+ end
+ if output
+ File.write(output, out)
else
print out
end
end
-def prelude(f, out)
- @exprs = {}
- lex_state_def = false
+def process(f, out, path, template)
+ prelude f, out
+ grammar f, out
+ usercode f, out, path, template
+end
+
+require_relative 'dsl'
+
+def generate_line(f, out)
while line = f.gets
- case line
- when /\A%%/
+ case
+ when gen = DSL.line?(line, f.lineno)
+ out << gen.generate << "\n"
+ when line.start_with?("%%")
out << "%%\n"
- return
- when /\A%token/, /\A} <node>/
- out << line.sub(/<\w+>/, '<val>')
- when /\A%type/
- out << line.sub(/<\w+>/, '<val>')
- when /^enum lex_state_(?:bits|e) \{/
- lex_state_def = true
- out << line
- when /^\}/
- lex_state_def = false
- out << line
+ break
else
- out << line
+ out << yield(line)
end
- if lex_state_def
+ end
+end
+
+def prelude(f, out)
+ @exprs = {}
+ generate_line(f, out) do |line|
+ if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line)
case line
when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\//
@exprs[$1.chomp("_bit")] = $2.strip
@@ -70,38 +80,45 @@ def prelude(f, out)
@exprs[name] = "equals to " + (val.start_with?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
end
end
+ line
end
end
-require_relative "dsl"
-
def grammar(f, out)
- while line = f.gets
+ generate_line(f, out) do |line|
case line
- when %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
- out << DSL.new($2, ($1 || "").split(",")).generate << "\n"
when %r</\*%%%\*/>
- out << "#if 0\n"
+ "#if 0\n"
when %r</\*%>
- out << "#endif\n"
+ "#endif\n"
when %r<%\*/>
- out << "\n"
- when /\A%%/
- out << "%%\n"
- return
+ "\n"
else
- out << line
+ line
end
end
end
-def usercode(f, out)
+def usercode(f, out, path, template)
require 'erb'
+ lineno = nil
+ src = nil
compiler = ERB::Compiler.new('%-')
compiler.put_cmd = compiler.insert_cmd = "out.<<"
- lineno = f.lineno
- src, = compiler.compile(f.read)
- eval(src, binding, f.path, lineno)
+
+ if template
+ File.open(template) do |f|
+ out.clear
+ lineno = f.lineno
+ src, = compiler.compile(f.read)
+ path = template
+ end
+ else
+ lineno = f.lineno
+ src, = compiler.compile(f.read)
+ end
+
+ eval(src, binding, path, lineno)
end
main
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 7406177de2..f1e9e42524 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1555,6 +1555,10 @@ bsock_recvmsg_internal(VALUE sock,
ss = rb_recvmsg(fptr->fd, &mh, flags);
+ if (ss == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
+
if (ss == -1) {
int e;
if (!nonblock && rb_io_maybe_wait_readable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT)) {
@@ -1639,14 +1643,14 @@ bsock_recvmsg_internal(VALUE sock,
rb_obj_reveal(dat_str, rb_cString);
}
- ret = rb_ary_new3(3, dat_str,
- rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
- INT2NUM(mh.msg_flags)
+ VALUE msg_flags = INT2NUM(mh.msg_flags);
#else
- Qnil
+ VALUE msg_flags = Qnil;
#endif
- );
+ ret = rb_ary_new3(3, dat_str,
+ rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
+ msg_flags);
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
family = rsock_getfamily(fptr);
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index 54c369f6fc..2fcae8eb54 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -124,7 +124,7 @@ bsock_close_read(VALUE sock)
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- shutdown(fptr->fd, 0);
+ shutdown(fptr->fd, SHUT_RD);
if (!(fptr->mode & FMODE_WRITABLE)) {
return rb_io_close(sock);
}
@@ -157,7 +157,7 @@ bsock_close_write(VALUE sock)
if (!(fptr->mode & FMODE_READABLE)) {
return rb_io_close(sock);
}
- shutdown(fptr->fd, 1);
+ shutdown(fptr->fd, SHUT_WR);
fptr->mode &= ~FMODE_WRITABLE;
return Qnil;
@@ -597,7 +597,7 @@ rsock_bsock_send(int argc, VALUE *argv, VALUE socket)
rb_io_wait(socket, RB_INT2NUM(RUBY_IO_WRITABLE), Qnil);
#endif
- ssize_t n = (ssize_t)BLOCKING_REGION_FD(func, &arg);
+ ssize_t n = (ssize_t)rb_io_blocking_region(fptr, func, &arg);
if (n >= 0) return SSIZET2NUM(n);
diff --git a/ext/socket/depend b/ext/socket/depend
index 1c02f574bd..77f6239a3d 100644
--- a/ext/socket/depend
+++ b/ext/socket/depend
@@ -13,6 +13,7 @@ constdefs.c: constdefs.h
ancdata.o: $(RUBY_EXTCONF_H)
ancdata.o: $(arch_hdrdir)/ruby/config.h
ancdata.o: $(hdrdir)/ruby/assert.h
+ancdata.o: $(hdrdir)/ruby/atomic.h
ancdata.o: $(hdrdir)/ruby/backward.h
ancdata.o: $(hdrdir)/ruby/backward/2/assume.h
ancdata.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -150,6 +151,7 @@ ancdata.o: $(hdrdir)/ruby/internal/intern/re.h
ancdata.o: $(hdrdir)/ruby/internal/intern/ruby.h
ancdata.o: $(hdrdir)/ruby/internal/intern/select.h
ancdata.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ancdata.o: $(hdrdir)/ruby/internal/intern/set.h
ancdata.o: $(hdrdir)/ruby/internal/intern/signal.h
ancdata.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ancdata.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -169,6 +171,7 @@ ancdata.o: $(hdrdir)/ruby/internal/special_consts.h
ancdata.o: $(hdrdir)/ruby/internal/static_assert.h
ancdata.o: $(hdrdir)/ruby/internal/stdalign.h
ancdata.o: $(hdrdir)/ruby/internal/stdbool.h
+ancdata.o: $(hdrdir)/ruby/internal/stdckdint.h
ancdata.o: $(hdrdir)/ruby/internal/symbol.h
ancdata.o: $(hdrdir)/ruby/internal/value.h
ancdata.o: $(hdrdir)/ruby/internal/value_type.h
@@ -183,27 +186,50 @@ ancdata.o: $(hdrdir)/ruby/ruby.h
ancdata.o: $(hdrdir)/ruby/st.h
ancdata.o: $(hdrdir)/ruby/subst.h
ancdata.o: $(hdrdir)/ruby/thread.h
+ancdata.o: $(hdrdir)/ruby/thread_native.h
ancdata.o: $(hdrdir)/ruby/util.h
+ancdata.o: $(hdrdir)/ruby/version.h
+ancdata.o: $(top_srcdir)/ccan/check_type/check_type.h
+ancdata.o: $(top_srcdir)/ccan/container_of/container_of.h
+ancdata.o: $(top_srcdir)/ccan/list/list.h
+ancdata.o: $(top_srcdir)/ccan/str/str.h
+ancdata.o: $(top_srcdir)/encindex.h
+ancdata.o: $(top_srcdir)/id_table.h
ancdata.o: $(top_srcdir)/internal.h
ancdata.o: $(top_srcdir)/internal/array.h
+ancdata.o: $(top_srcdir)/internal/basic_operators.h
+ancdata.o: $(top_srcdir)/internal/box.h
ancdata.o: $(top_srcdir)/internal/compilers.h
ancdata.o: $(top_srcdir)/internal/error.h
ancdata.o: $(top_srcdir)/internal/gc.h
+ancdata.o: $(top_srcdir)/internal/imemo.h
ancdata.o: $(top_srcdir)/internal/io.h
+ancdata.o: $(top_srcdir)/internal/sanitizers.h
ancdata.o: $(top_srcdir)/internal/serial.h
+ancdata.o: $(top_srcdir)/internal/set_table.h
ancdata.o: $(top_srcdir)/internal/static_assert.h
ancdata.o: $(top_srcdir)/internal/string.h
ancdata.o: $(top_srcdir)/internal/thread.h
ancdata.o: $(top_srcdir)/internal/vm.h
ancdata.o: $(top_srcdir)/internal/warnings.h
+ancdata.o: $(top_srcdir)/method.h
+ancdata.o: $(top_srcdir)/node.h
+ancdata.o: $(top_srcdir)/ruby_assert.h
+ancdata.o: $(top_srcdir)/ruby_atomic.h
+ancdata.o: $(top_srcdir)/rubyparser.h
ancdata.o: $(top_srcdir)/shape.h
+ancdata.o: $(top_srcdir)/thread_pthread.h
+ancdata.o: $(top_srcdir)/vm_core.h
+ancdata.o: $(top_srcdir)/vm_opts.h
ancdata.o: ancdata.c
ancdata.o: constdefs.h
ancdata.o: rubysocket.h
ancdata.o: sockport.h
+ancdata.o: {$(VPATH)}id.h
basicsocket.o: $(RUBY_EXTCONF_H)
basicsocket.o: $(arch_hdrdir)/ruby/config.h
basicsocket.o: $(hdrdir)/ruby/assert.h
+basicsocket.o: $(hdrdir)/ruby/atomic.h
basicsocket.o: $(hdrdir)/ruby/backward.h
basicsocket.o: $(hdrdir)/ruby/backward/2/assume.h
basicsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -341,6 +367,7 @@ basicsocket.o: $(hdrdir)/ruby/internal/intern/re.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/select.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+basicsocket.o: $(hdrdir)/ruby/internal/intern/set.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/signal.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -360,6 +387,7 @@ basicsocket.o: $(hdrdir)/ruby/internal/special_consts.h
basicsocket.o: $(hdrdir)/ruby/internal/static_assert.h
basicsocket.o: $(hdrdir)/ruby/internal/stdalign.h
basicsocket.o: $(hdrdir)/ruby/internal/stdbool.h
+basicsocket.o: $(hdrdir)/ruby/internal/stdckdint.h
basicsocket.o: $(hdrdir)/ruby/internal/symbol.h
basicsocket.o: $(hdrdir)/ruby/internal/value.h
basicsocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -374,27 +402,50 @@ basicsocket.o: $(hdrdir)/ruby/ruby.h
basicsocket.o: $(hdrdir)/ruby/st.h
basicsocket.o: $(hdrdir)/ruby/subst.h
basicsocket.o: $(hdrdir)/ruby/thread.h
+basicsocket.o: $(hdrdir)/ruby/thread_native.h
basicsocket.o: $(hdrdir)/ruby/util.h
+basicsocket.o: $(hdrdir)/ruby/version.h
+basicsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+basicsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+basicsocket.o: $(top_srcdir)/ccan/list/list.h
+basicsocket.o: $(top_srcdir)/ccan/str/str.h
+basicsocket.o: $(top_srcdir)/encindex.h
+basicsocket.o: $(top_srcdir)/id_table.h
basicsocket.o: $(top_srcdir)/internal.h
basicsocket.o: $(top_srcdir)/internal/array.h
+basicsocket.o: $(top_srcdir)/internal/basic_operators.h
+basicsocket.o: $(top_srcdir)/internal/box.h
basicsocket.o: $(top_srcdir)/internal/compilers.h
basicsocket.o: $(top_srcdir)/internal/error.h
basicsocket.o: $(top_srcdir)/internal/gc.h
+basicsocket.o: $(top_srcdir)/internal/imemo.h
basicsocket.o: $(top_srcdir)/internal/io.h
+basicsocket.o: $(top_srcdir)/internal/sanitizers.h
basicsocket.o: $(top_srcdir)/internal/serial.h
+basicsocket.o: $(top_srcdir)/internal/set_table.h
basicsocket.o: $(top_srcdir)/internal/static_assert.h
basicsocket.o: $(top_srcdir)/internal/string.h
basicsocket.o: $(top_srcdir)/internal/thread.h
basicsocket.o: $(top_srcdir)/internal/vm.h
basicsocket.o: $(top_srcdir)/internal/warnings.h
+basicsocket.o: $(top_srcdir)/method.h
+basicsocket.o: $(top_srcdir)/node.h
+basicsocket.o: $(top_srcdir)/ruby_assert.h
+basicsocket.o: $(top_srcdir)/ruby_atomic.h
+basicsocket.o: $(top_srcdir)/rubyparser.h
basicsocket.o: $(top_srcdir)/shape.h
+basicsocket.o: $(top_srcdir)/thread_pthread.h
+basicsocket.o: $(top_srcdir)/vm_core.h
+basicsocket.o: $(top_srcdir)/vm_opts.h
basicsocket.o: basicsocket.c
basicsocket.o: constdefs.h
basicsocket.o: rubysocket.h
basicsocket.o: sockport.h
+basicsocket.o: {$(VPATH)}id.h
constants.o: $(RUBY_EXTCONF_H)
constants.o: $(arch_hdrdir)/ruby/config.h
constants.o: $(hdrdir)/ruby/assert.h
+constants.o: $(hdrdir)/ruby/atomic.h
constants.o: $(hdrdir)/ruby/backward.h
constants.o: $(hdrdir)/ruby/backward/2/assume.h
constants.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -532,6 +583,7 @@ constants.o: $(hdrdir)/ruby/internal/intern/re.h
constants.o: $(hdrdir)/ruby/internal/intern/ruby.h
constants.o: $(hdrdir)/ruby/internal/intern/select.h
constants.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+constants.o: $(hdrdir)/ruby/internal/intern/set.h
constants.o: $(hdrdir)/ruby/internal/intern/signal.h
constants.o: $(hdrdir)/ruby/internal/intern/sprintf.h
constants.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -551,6 +603,7 @@ constants.o: $(hdrdir)/ruby/internal/special_consts.h
constants.o: $(hdrdir)/ruby/internal/static_assert.h
constants.o: $(hdrdir)/ruby/internal/stdalign.h
constants.o: $(hdrdir)/ruby/internal/stdbool.h
+constants.o: $(hdrdir)/ruby/internal/stdckdint.h
constants.o: $(hdrdir)/ruby/internal/symbol.h
constants.o: $(hdrdir)/ruby/internal/value.h
constants.o: $(hdrdir)/ruby/internal/value_type.h
@@ -565,28 +618,51 @@ constants.o: $(hdrdir)/ruby/ruby.h
constants.o: $(hdrdir)/ruby/st.h
constants.o: $(hdrdir)/ruby/subst.h
constants.o: $(hdrdir)/ruby/thread.h
+constants.o: $(hdrdir)/ruby/thread_native.h
constants.o: $(hdrdir)/ruby/util.h
+constants.o: $(hdrdir)/ruby/version.h
+constants.o: $(top_srcdir)/ccan/check_type/check_type.h
+constants.o: $(top_srcdir)/ccan/container_of/container_of.h
+constants.o: $(top_srcdir)/ccan/list/list.h
+constants.o: $(top_srcdir)/ccan/str/str.h
+constants.o: $(top_srcdir)/encindex.h
+constants.o: $(top_srcdir)/id_table.h
constants.o: $(top_srcdir)/internal.h
constants.o: $(top_srcdir)/internal/array.h
+constants.o: $(top_srcdir)/internal/basic_operators.h
+constants.o: $(top_srcdir)/internal/box.h
constants.o: $(top_srcdir)/internal/compilers.h
constants.o: $(top_srcdir)/internal/error.h
constants.o: $(top_srcdir)/internal/gc.h
+constants.o: $(top_srcdir)/internal/imemo.h
constants.o: $(top_srcdir)/internal/io.h
+constants.o: $(top_srcdir)/internal/sanitizers.h
constants.o: $(top_srcdir)/internal/serial.h
+constants.o: $(top_srcdir)/internal/set_table.h
constants.o: $(top_srcdir)/internal/static_assert.h
constants.o: $(top_srcdir)/internal/string.h
constants.o: $(top_srcdir)/internal/thread.h
constants.o: $(top_srcdir)/internal/vm.h
constants.o: $(top_srcdir)/internal/warnings.h
+constants.o: $(top_srcdir)/method.h
+constants.o: $(top_srcdir)/node.h
+constants.o: $(top_srcdir)/ruby_assert.h
+constants.o: $(top_srcdir)/ruby_atomic.h
+constants.o: $(top_srcdir)/rubyparser.h
constants.o: $(top_srcdir)/shape.h
+constants.o: $(top_srcdir)/thread_pthread.h
+constants.o: $(top_srcdir)/vm_core.h
+constants.o: $(top_srcdir)/vm_opts.h
constants.o: constants.c
constants.o: constdefs.c
constants.o: constdefs.h
constants.o: rubysocket.h
constants.o: sockport.h
+constants.o: {$(VPATH)}id.h
ifaddr.o: $(RUBY_EXTCONF_H)
ifaddr.o: $(arch_hdrdir)/ruby/config.h
ifaddr.o: $(hdrdir)/ruby/assert.h
+ifaddr.o: $(hdrdir)/ruby/atomic.h
ifaddr.o: $(hdrdir)/ruby/backward.h
ifaddr.o: $(hdrdir)/ruby/backward/2/assume.h
ifaddr.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -724,6 +800,7 @@ ifaddr.o: $(hdrdir)/ruby/internal/intern/re.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/ruby.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/select.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ifaddr.o: $(hdrdir)/ruby/internal/intern/set.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/signal.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -743,6 +820,7 @@ ifaddr.o: $(hdrdir)/ruby/internal/special_consts.h
ifaddr.o: $(hdrdir)/ruby/internal/static_assert.h
ifaddr.o: $(hdrdir)/ruby/internal/stdalign.h
ifaddr.o: $(hdrdir)/ruby/internal/stdbool.h
+ifaddr.o: $(hdrdir)/ruby/internal/stdckdint.h
ifaddr.o: $(hdrdir)/ruby/internal/symbol.h
ifaddr.o: $(hdrdir)/ruby/internal/value.h
ifaddr.o: $(hdrdir)/ruby/internal/value_type.h
@@ -757,27 +835,50 @@ ifaddr.o: $(hdrdir)/ruby/ruby.h
ifaddr.o: $(hdrdir)/ruby/st.h
ifaddr.o: $(hdrdir)/ruby/subst.h
ifaddr.o: $(hdrdir)/ruby/thread.h
+ifaddr.o: $(hdrdir)/ruby/thread_native.h
ifaddr.o: $(hdrdir)/ruby/util.h
+ifaddr.o: $(hdrdir)/ruby/version.h
+ifaddr.o: $(top_srcdir)/ccan/check_type/check_type.h
+ifaddr.o: $(top_srcdir)/ccan/container_of/container_of.h
+ifaddr.o: $(top_srcdir)/ccan/list/list.h
+ifaddr.o: $(top_srcdir)/ccan/str/str.h
+ifaddr.o: $(top_srcdir)/encindex.h
+ifaddr.o: $(top_srcdir)/id_table.h
ifaddr.o: $(top_srcdir)/internal.h
ifaddr.o: $(top_srcdir)/internal/array.h
+ifaddr.o: $(top_srcdir)/internal/basic_operators.h
+ifaddr.o: $(top_srcdir)/internal/box.h
ifaddr.o: $(top_srcdir)/internal/compilers.h
ifaddr.o: $(top_srcdir)/internal/error.h
ifaddr.o: $(top_srcdir)/internal/gc.h
+ifaddr.o: $(top_srcdir)/internal/imemo.h
ifaddr.o: $(top_srcdir)/internal/io.h
+ifaddr.o: $(top_srcdir)/internal/sanitizers.h
ifaddr.o: $(top_srcdir)/internal/serial.h
+ifaddr.o: $(top_srcdir)/internal/set_table.h
ifaddr.o: $(top_srcdir)/internal/static_assert.h
ifaddr.o: $(top_srcdir)/internal/string.h
ifaddr.o: $(top_srcdir)/internal/thread.h
ifaddr.o: $(top_srcdir)/internal/vm.h
ifaddr.o: $(top_srcdir)/internal/warnings.h
+ifaddr.o: $(top_srcdir)/method.h
+ifaddr.o: $(top_srcdir)/node.h
+ifaddr.o: $(top_srcdir)/ruby_assert.h
+ifaddr.o: $(top_srcdir)/ruby_atomic.h
+ifaddr.o: $(top_srcdir)/rubyparser.h
ifaddr.o: $(top_srcdir)/shape.h
+ifaddr.o: $(top_srcdir)/thread_pthread.h
+ifaddr.o: $(top_srcdir)/vm_core.h
+ifaddr.o: $(top_srcdir)/vm_opts.h
ifaddr.o: constdefs.h
ifaddr.o: ifaddr.c
ifaddr.o: rubysocket.h
ifaddr.o: sockport.h
+ifaddr.o: {$(VPATH)}id.h
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
init.o: $(hdrdir)/ruby/assert.h
+init.o: $(hdrdir)/ruby/atomic.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/backward/2/assume.h
init.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -915,6 +1016,7 @@ init.o: $(hdrdir)/ruby/internal/intern/re.h
init.o: $(hdrdir)/ruby/internal/intern/ruby.h
init.o: $(hdrdir)/ruby/internal/intern/select.h
init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+init.o: $(hdrdir)/ruby/internal/intern/set.h
init.o: $(hdrdir)/ruby/internal/intern/signal.h
init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
init.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -934,6 +1036,7 @@ init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
init.o: $(hdrdir)/ruby/internal/stdalign.h
init.o: $(hdrdir)/ruby/internal/stdbool.h
+init.o: $(hdrdir)/ruby/internal/stdckdint.h
init.o: $(hdrdir)/ruby/internal/symbol.h
init.o: $(hdrdir)/ruby/internal/value.h
init.o: $(hdrdir)/ruby/internal/value_type.h
@@ -948,27 +1051,50 @@ init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
init.o: $(hdrdir)/ruby/thread.h
+init.o: $(hdrdir)/ruby/thread_native.h
init.o: $(hdrdir)/ruby/util.h
+init.o: $(hdrdir)/ruby/version.h
+init.o: $(top_srcdir)/ccan/check_type/check_type.h
+init.o: $(top_srcdir)/ccan/container_of/container_of.h
+init.o: $(top_srcdir)/ccan/list/list.h
+init.o: $(top_srcdir)/ccan/str/str.h
+init.o: $(top_srcdir)/encindex.h
+init.o: $(top_srcdir)/id_table.h
init.o: $(top_srcdir)/internal.h
init.o: $(top_srcdir)/internal/array.h
+init.o: $(top_srcdir)/internal/basic_operators.h
+init.o: $(top_srcdir)/internal/box.h
init.o: $(top_srcdir)/internal/compilers.h
init.o: $(top_srcdir)/internal/error.h
init.o: $(top_srcdir)/internal/gc.h
+init.o: $(top_srcdir)/internal/imemo.h
init.o: $(top_srcdir)/internal/io.h
+init.o: $(top_srcdir)/internal/sanitizers.h
init.o: $(top_srcdir)/internal/serial.h
+init.o: $(top_srcdir)/internal/set_table.h
init.o: $(top_srcdir)/internal/static_assert.h
init.o: $(top_srcdir)/internal/string.h
init.o: $(top_srcdir)/internal/thread.h
init.o: $(top_srcdir)/internal/vm.h
init.o: $(top_srcdir)/internal/warnings.h
+init.o: $(top_srcdir)/method.h
+init.o: $(top_srcdir)/node.h
+init.o: $(top_srcdir)/ruby_assert.h
+init.o: $(top_srcdir)/ruby_atomic.h
+init.o: $(top_srcdir)/rubyparser.h
init.o: $(top_srcdir)/shape.h
+init.o: $(top_srcdir)/thread_pthread.h
+init.o: $(top_srcdir)/vm_core.h
+init.o: $(top_srcdir)/vm_opts.h
init.o: constdefs.h
init.o: init.c
init.o: rubysocket.h
init.o: sockport.h
+init.o: {$(VPATH)}id.h
ipsocket.o: $(RUBY_EXTCONF_H)
ipsocket.o: $(arch_hdrdir)/ruby/config.h
ipsocket.o: $(hdrdir)/ruby/assert.h
+ipsocket.o: $(hdrdir)/ruby/atomic.h
ipsocket.o: $(hdrdir)/ruby/backward.h
ipsocket.o: $(hdrdir)/ruby/backward/2/assume.h
ipsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1106,6 +1232,7 @@ ipsocket.o: $(hdrdir)/ruby/internal/intern/re.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/select.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ipsocket.o: $(hdrdir)/ruby/internal/intern/set.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/signal.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1125,6 +1252,7 @@ ipsocket.o: $(hdrdir)/ruby/internal/special_consts.h
ipsocket.o: $(hdrdir)/ruby/internal/static_assert.h
ipsocket.o: $(hdrdir)/ruby/internal/stdalign.h
ipsocket.o: $(hdrdir)/ruby/internal/stdbool.h
+ipsocket.o: $(hdrdir)/ruby/internal/stdckdint.h
ipsocket.o: $(hdrdir)/ruby/internal/symbol.h
ipsocket.o: $(hdrdir)/ruby/internal/value.h
ipsocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1139,27 +1267,50 @@ ipsocket.o: $(hdrdir)/ruby/ruby.h
ipsocket.o: $(hdrdir)/ruby/st.h
ipsocket.o: $(hdrdir)/ruby/subst.h
ipsocket.o: $(hdrdir)/ruby/thread.h
+ipsocket.o: $(hdrdir)/ruby/thread_native.h
ipsocket.o: $(hdrdir)/ruby/util.h
+ipsocket.o: $(hdrdir)/ruby/version.h
+ipsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+ipsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+ipsocket.o: $(top_srcdir)/ccan/list/list.h
+ipsocket.o: $(top_srcdir)/ccan/str/str.h
+ipsocket.o: $(top_srcdir)/encindex.h
+ipsocket.o: $(top_srcdir)/id_table.h
ipsocket.o: $(top_srcdir)/internal.h
ipsocket.o: $(top_srcdir)/internal/array.h
+ipsocket.o: $(top_srcdir)/internal/basic_operators.h
+ipsocket.o: $(top_srcdir)/internal/box.h
ipsocket.o: $(top_srcdir)/internal/compilers.h
ipsocket.o: $(top_srcdir)/internal/error.h
ipsocket.o: $(top_srcdir)/internal/gc.h
+ipsocket.o: $(top_srcdir)/internal/imemo.h
ipsocket.o: $(top_srcdir)/internal/io.h
+ipsocket.o: $(top_srcdir)/internal/sanitizers.h
ipsocket.o: $(top_srcdir)/internal/serial.h
+ipsocket.o: $(top_srcdir)/internal/set_table.h
ipsocket.o: $(top_srcdir)/internal/static_assert.h
ipsocket.o: $(top_srcdir)/internal/string.h
ipsocket.o: $(top_srcdir)/internal/thread.h
ipsocket.o: $(top_srcdir)/internal/vm.h
ipsocket.o: $(top_srcdir)/internal/warnings.h
+ipsocket.o: $(top_srcdir)/method.h
+ipsocket.o: $(top_srcdir)/node.h
+ipsocket.o: $(top_srcdir)/ruby_assert.h
+ipsocket.o: $(top_srcdir)/ruby_atomic.h
+ipsocket.o: $(top_srcdir)/rubyparser.h
ipsocket.o: $(top_srcdir)/shape.h
+ipsocket.o: $(top_srcdir)/thread_pthread.h
+ipsocket.o: $(top_srcdir)/vm_core.h
+ipsocket.o: $(top_srcdir)/vm_opts.h
ipsocket.o: constdefs.h
ipsocket.o: ipsocket.c
ipsocket.o: rubysocket.h
ipsocket.o: sockport.h
+ipsocket.o: {$(VPATH)}id.h
option.o: $(RUBY_EXTCONF_H)
option.o: $(arch_hdrdir)/ruby/config.h
option.o: $(hdrdir)/ruby/assert.h
+option.o: $(hdrdir)/ruby/atomic.h
option.o: $(hdrdir)/ruby/backward.h
option.o: $(hdrdir)/ruby/backward/2/assume.h
option.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1297,6 +1448,7 @@ option.o: $(hdrdir)/ruby/internal/intern/re.h
option.o: $(hdrdir)/ruby/internal/intern/ruby.h
option.o: $(hdrdir)/ruby/internal/intern/select.h
option.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+option.o: $(hdrdir)/ruby/internal/intern/set.h
option.o: $(hdrdir)/ruby/internal/intern/signal.h
option.o: $(hdrdir)/ruby/internal/intern/sprintf.h
option.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1316,6 +1468,7 @@ option.o: $(hdrdir)/ruby/internal/special_consts.h
option.o: $(hdrdir)/ruby/internal/static_assert.h
option.o: $(hdrdir)/ruby/internal/stdalign.h
option.o: $(hdrdir)/ruby/internal/stdbool.h
+option.o: $(hdrdir)/ruby/internal/stdckdint.h
option.o: $(hdrdir)/ruby/internal/symbol.h
option.o: $(hdrdir)/ruby/internal/value.h
option.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1330,27 +1483,50 @@ option.o: $(hdrdir)/ruby/ruby.h
option.o: $(hdrdir)/ruby/st.h
option.o: $(hdrdir)/ruby/subst.h
option.o: $(hdrdir)/ruby/thread.h
+option.o: $(hdrdir)/ruby/thread_native.h
option.o: $(hdrdir)/ruby/util.h
+option.o: $(hdrdir)/ruby/version.h
+option.o: $(top_srcdir)/ccan/check_type/check_type.h
+option.o: $(top_srcdir)/ccan/container_of/container_of.h
+option.o: $(top_srcdir)/ccan/list/list.h
+option.o: $(top_srcdir)/ccan/str/str.h
+option.o: $(top_srcdir)/encindex.h
+option.o: $(top_srcdir)/id_table.h
option.o: $(top_srcdir)/internal.h
option.o: $(top_srcdir)/internal/array.h
+option.o: $(top_srcdir)/internal/basic_operators.h
+option.o: $(top_srcdir)/internal/box.h
option.o: $(top_srcdir)/internal/compilers.h
option.o: $(top_srcdir)/internal/error.h
option.o: $(top_srcdir)/internal/gc.h
+option.o: $(top_srcdir)/internal/imemo.h
option.o: $(top_srcdir)/internal/io.h
+option.o: $(top_srcdir)/internal/sanitizers.h
option.o: $(top_srcdir)/internal/serial.h
+option.o: $(top_srcdir)/internal/set_table.h
option.o: $(top_srcdir)/internal/static_assert.h
option.o: $(top_srcdir)/internal/string.h
option.o: $(top_srcdir)/internal/thread.h
option.o: $(top_srcdir)/internal/vm.h
option.o: $(top_srcdir)/internal/warnings.h
+option.o: $(top_srcdir)/method.h
+option.o: $(top_srcdir)/node.h
+option.o: $(top_srcdir)/ruby_assert.h
+option.o: $(top_srcdir)/ruby_atomic.h
+option.o: $(top_srcdir)/rubyparser.h
option.o: $(top_srcdir)/shape.h
+option.o: $(top_srcdir)/thread_pthread.h
+option.o: $(top_srcdir)/vm_core.h
+option.o: $(top_srcdir)/vm_opts.h
option.o: constdefs.h
option.o: option.c
option.o: rubysocket.h
option.o: sockport.h
+option.o: {$(VPATH)}id.h
raddrinfo.o: $(RUBY_EXTCONF_H)
raddrinfo.o: $(arch_hdrdir)/ruby/config.h
raddrinfo.o: $(hdrdir)/ruby/assert.h
+raddrinfo.o: $(hdrdir)/ruby/atomic.h
raddrinfo.o: $(hdrdir)/ruby/backward.h
raddrinfo.o: $(hdrdir)/ruby/backward/2/assume.h
raddrinfo.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1488,6 +1664,7 @@ raddrinfo.o: $(hdrdir)/ruby/internal/intern/re.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/ruby.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/select.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+raddrinfo.o: $(hdrdir)/ruby/internal/intern/set.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/signal.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/sprintf.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1507,6 +1684,7 @@ raddrinfo.o: $(hdrdir)/ruby/internal/special_consts.h
raddrinfo.o: $(hdrdir)/ruby/internal/static_assert.h
raddrinfo.o: $(hdrdir)/ruby/internal/stdalign.h
raddrinfo.o: $(hdrdir)/ruby/internal/stdbool.h
+raddrinfo.o: $(hdrdir)/ruby/internal/stdckdint.h
raddrinfo.o: $(hdrdir)/ruby/internal/symbol.h
raddrinfo.o: $(hdrdir)/ruby/internal/value.h
raddrinfo.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1521,27 +1699,50 @@ raddrinfo.o: $(hdrdir)/ruby/ruby.h
raddrinfo.o: $(hdrdir)/ruby/st.h
raddrinfo.o: $(hdrdir)/ruby/subst.h
raddrinfo.o: $(hdrdir)/ruby/thread.h
+raddrinfo.o: $(hdrdir)/ruby/thread_native.h
raddrinfo.o: $(hdrdir)/ruby/util.h
+raddrinfo.o: $(hdrdir)/ruby/version.h
+raddrinfo.o: $(top_srcdir)/ccan/check_type/check_type.h
+raddrinfo.o: $(top_srcdir)/ccan/container_of/container_of.h
+raddrinfo.o: $(top_srcdir)/ccan/list/list.h
+raddrinfo.o: $(top_srcdir)/ccan/str/str.h
+raddrinfo.o: $(top_srcdir)/encindex.h
+raddrinfo.o: $(top_srcdir)/id_table.h
raddrinfo.o: $(top_srcdir)/internal.h
raddrinfo.o: $(top_srcdir)/internal/array.h
+raddrinfo.o: $(top_srcdir)/internal/basic_operators.h
+raddrinfo.o: $(top_srcdir)/internal/box.h
raddrinfo.o: $(top_srcdir)/internal/compilers.h
raddrinfo.o: $(top_srcdir)/internal/error.h
raddrinfo.o: $(top_srcdir)/internal/gc.h
+raddrinfo.o: $(top_srcdir)/internal/imemo.h
raddrinfo.o: $(top_srcdir)/internal/io.h
+raddrinfo.o: $(top_srcdir)/internal/sanitizers.h
raddrinfo.o: $(top_srcdir)/internal/serial.h
+raddrinfo.o: $(top_srcdir)/internal/set_table.h
raddrinfo.o: $(top_srcdir)/internal/static_assert.h
raddrinfo.o: $(top_srcdir)/internal/string.h
raddrinfo.o: $(top_srcdir)/internal/thread.h
raddrinfo.o: $(top_srcdir)/internal/vm.h
raddrinfo.o: $(top_srcdir)/internal/warnings.h
+raddrinfo.o: $(top_srcdir)/method.h
+raddrinfo.o: $(top_srcdir)/node.h
+raddrinfo.o: $(top_srcdir)/ruby_assert.h
+raddrinfo.o: $(top_srcdir)/ruby_atomic.h
+raddrinfo.o: $(top_srcdir)/rubyparser.h
raddrinfo.o: $(top_srcdir)/shape.h
+raddrinfo.o: $(top_srcdir)/thread_pthread.h
+raddrinfo.o: $(top_srcdir)/vm_core.h
+raddrinfo.o: $(top_srcdir)/vm_opts.h
raddrinfo.o: constdefs.h
raddrinfo.o: raddrinfo.c
raddrinfo.o: rubysocket.h
raddrinfo.o: sockport.h
+raddrinfo.o: {$(VPATH)}id.h
socket.o: $(RUBY_EXTCONF_H)
socket.o: $(arch_hdrdir)/ruby/config.h
socket.o: $(hdrdir)/ruby/assert.h
+socket.o: $(hdrdir)/ruby/atomic.h
socket.o: $(hdrdir)/ruby/backward.h
socket.o: $(hdrdir)/ruby/backward/2/assume.h
socket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1679,6 +1880,7 @@ socket.o: $(hdrdir)/ruby/internal/intern/re.h
socket.o: $(hdrdir)/ruby/internal/intern/ruby.h
socket.o: $(hdrdir)/ruby/internal/intern/select.h
socket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+socket.o: $(hdrdir)/ruby/internal/intern/set.h
socket.o: $(hdrdir)/ruby/internal/intern/signal.h
socket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
socket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1698,6 +1900,7 @@ socket.o: $(hdrdir)/ruby/internal/special_consts.h
socket.o: $(hdrdir)/ruby/internal/static_assert.h
socket.o: $(hdrdir)/ruby/internal/stdalign.h
socket.o: $(hdrdir)/ruby/internal/stdbool.h
+socket.o: $(hdrdir)/ruby/internal/stdckdint.h
socket.o: $(hdrdir)/ruby/internal/symbol.h
socket.o: $(hdrdir)/ruby/internal/value.h
socket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1712,27 +1915,50 @@ socket.o: $(hdrdir)/ruby/ruby.h
socket.o: $(hdrdir)/ruby/st.h
socket.o: $(hdrdir)/ruby/subst.h
socket.o: $(hdrdir)/ruby/thread.h
+socket.o: $(hdrdir)/ruby/thread_native.h
socket.o: $(hdrdir)/ruby/util.h
+socket.o: $(hdrdir)/ruby/version.h
+socket.o: $(top_srcdir)/ccan/check_type/check_type.h
+socket.o: $(top_srcdir)/ccan/container_of/container_of.h
+socket.o: $(top_srcdir)/ccan/list/list.h
+socket.o: $(top_srcdir)/ccan/str/str.h
+socket.o: $(top_srcdir)/encindex.h
+socket.o: $(top_srcdir)/id_table.h
socket.o: $(top_srcdir)/internal.h
socket.o: $(top_srcdir)/internal/array.h
+socket.o: $(top_srcdir)/internal/basic_operators.h
+socket.o: $(top_srcdir)/internal/box.h
socket.o: $(top_srcdir)/internal/compilers.h
socket.o: $(top_srcdir)/internal/error.h
socket.o: $(top_srcdir)/internal/gc.h
+socket.o: $(top_srcdir)/internal/imemo.h
socket.o: $(top_srcdir)/internal/io.h
+socket.o: $(top_srcdir)/internal/sanitizers.h
socket.o: $(top_srcdir)/internal/serial.h
+socket.o: $(top_srcdir)/internal/set_table.h
socket.o: $(top_srcdir)/internal/static_assert.h
socket.o: $(top_srcdir)/internal/string.h
socket.o: $(top_srcdir)/internal/thread.h
socket.o: $(top_srcdir)/internal/vm.h
socket.o: $(top_srcdir)/internal/warnings.h
+socket.o: $(top_srcdir)/method.h
+socket.o: $(top_srcdir)/node.h
+socket.o: $(top_srcdir)/ruby_assert.h
+socket.o: $(top_srcdir)/ruby_atomic.h
+socket.o: $(top_srcdir)/rubyparser.h
socket.o: $(top_srcdir)/shape.h
+socket.o: $(top_srcdir)/thread_pthread.h
+socket.o: $(top_srcdir)/vm_core.h
+socket.o: $(top_srcdir)/vm_opts.h
socket.o: constdefs.h
socket.o: rubysocket.h
socket.o: socket.c
socket.o: sockport.h
+socket.o: {$(VPATH)}id.h
sockssocket.o: $(RUBY_EXTCONF_H)
sockssocket.o: $(arch_hdrdir)/ruby/config.h
sockssocket.o: $(hdrdir)/ruby/assert.h
+sockssocket.o: $(hdrdir)/ruby/atomic.h
sockssocket.o: $(hdrdir)/ruby/backward.h
sockssocket.o: $(hdrdir)/ruby/backward/2/assume.h
sockssocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1870,6 +2096,7 @@ sockssocket.o: $(hdrdir)/ruby/internal/intern/re.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/select.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+sockssocket.o: $(hdrdir)/ruby/internal/intern/set.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/signal.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -1889,6 +2116,7 @@ sockssocket.o: $(hdrdir)/ruby/internal/special_consts.h
sockssocket.o: $(hdrdir)/ruby/internal/static_assert.h
sockssocket.o: $(hdrdir)/ruby/internal/stdalign.h
sockssocket.o: $(hdrdir)/ruby/internal/stdbool.h
+sockssocket.o: $(hdrdir)/ruby/internal/stdckdint.h
sockssocket.o: $(hdrdir)/ruby/internal/symbol.h
sockssocket.o: $(hdrdir)/ruby/internal/value.h
sockssocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -1903,27 +2131,50 @@ sockssocket.o: $(hdrdir)/ruby/ruby.h
sockssocket.o: $(hdrdir)/ruby/st.h
sockssocket.o: $(hdrdir)/ruby/subst.h
sockssocket.o: $(hdrdir)/ruby/thread.h
+sockssocket.o: $(hdrdir)/ruby/thread_native.h
sockssocket.o: $(hdrdir)/ruby/util.h
+sockssocket.o: $(hdrdir)/ruby/version.h
+sockssocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+sockssocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+sockssocket.o: $(top_srcdir)/ccan/list/list.h
+sockssocket.o: $(top_srcdir)/ccan/str/str.h
+sockssocket.o: $(top_srcdir)/encindex.h
+sockssocket.o: $(top_srcdir)/id_table.h
sockssocket.o: $(top_srcdir)/internal.h
sockssocket.o: $(top_srcdir)/internal/array.h
+sockssocket.o: $(top_srcdir)/internal/basic_operators.h
+sockssocket.o: $(top_srcdir)/internal/box.h
sockssocket.o: $(top_srcdir)/internal/compilers.h
sockssocket.o: $(top_srcdir)/internal/error.h
sockssocket.o: $(top_srcdir)/internal/gc.h
+sockssocket.o: $(top_srcdir)/internal/imemo.h
sockssocket.o: $(top_srcdir)/internal/io.h
+sockssocket.o: $(top_srcdir)/internal/sanitizers.h
sockssocket.o: $(top_srcdir)/internal/serial.h
+sockssocket.o: $(top_srcdir)/internal/set_table.h
sockssocket.o: $(top_srcdir)/internal/static_assert.h
sockssocket.o: $(top_srcdir)/internal/string.h
sockssocket.o: $(top_srcdir)/internal/thread.h
sockssocket.o: $(top_srcdir)/internal/vm.h
sockssocket.o: $(top_srcdir)/internal/warnings.h
+sockssocket.o: $(top_srcdir)/method.h
+sockssocket.o: $(top_srcdir)/node.h
+sockssocket.o: $(top_srcdir)/ruby_assert.h
+sockssocket.o: $(top_srcdir)/ruby_atomic.h
+sockssocket.o: $(top_srcdir)/rubyparser.h
sockssocket.o: $(top_srcdir)/shape.h
+sockssocket.o: $(top_srcdir)/thread_pthread.h
+sockssocket.o: $(top_srcdir)/vm_core.h
+sockssocket.o: $(top_srcdir)/vm_opts.h
sockssocket.o: constdefs.h
sockssocket.o: rubysocket.h
sockssocket.o: sockport.h
sockssocket.o: sockssocket.c
+sockssocket.o: {$(VPATH)}id.h
tcpserver.o: $(RUBY_EXTCONF_H)
tcpserver.o: $(arch_hdrdir)/ruby/config.h
tcpserver.o: $(hdrdir)/ruby/assert.h
+tcpserver.o: $(hdrdir)/ruby/atomic.h
tcpserver.o: $(hdrdir)/ruby/backward.h
tcpserver.o: $(hdrdir)/ruby/backward/2/assume.h
tcpserver.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2061,6 +2312,7 @@ tcpserver.o: $(hdrdir)/ruby/internal/intern/re.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/ruby.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/select.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+tcpserver.o: $(hdrdir)/ruby/internal/intern/set.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/signal.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/sprintf.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2080,6 +2332,7 @@ tcpserver.o: $(hdrdir)/ruby/internal/special_consts.h
tcpserver.o: $(hdrdir)/ruby/internal/static_assert.h
tcpserver.o: $(hdrdir)/ruby/internal/stdalign.h
tcpserver.o: $(hdrdir)/ruby/internal/stdbool.h
+tcpserver.o: $(hdrdir)/ruby/internal/stdckdint.h
tcpserver.o: $(hdrdir)/ruby/internal/symbol.h
tcpserver.o: $(hdrdir)/ruby/internal/value.h
tcpserver.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2094,27 +2347,50 @@ tcpserver.o: $(hdrdir)/ruby/ruby.h
tcpserver.o: $(hdrdir)/ruby/st.h
tcpserver.o: $(hdrdir)/ruby/subst.h
tcpserver.o: $(hdrdir)/ruby/thread.h
+tcpserver.o: $(hdrdir)/ruby/thread_native.h
tcpserver.o: $(hdrdir)/ruby/util.h
+tcpserver.o: $(hdrdir)/ruby/version.h
+tcpserver.o: $(top_srcdir)/ccan/check_type/check_type.h
+tcpserver.o: $(top_srcdir)/ccan/container_of/container_of.h
+tcpserver.o: $(top_srcdir)/ccan/list/list.h
+tcpserver.o: $(top_srcdir)/ccan/str/str.h
+tcpserver.o: $(top_srcdir)/encindex.h
+tcpserver.o: $(top_srcdir)/id_table.h
tcpserver.o: $(top_srcdir)/internal.h
tcpserver.o: $(top_srcdir)/internal/array.h
+tcpserver.o: $(top_srcdir)/internal/basic_operators.h
+tcpserver.o: $(top_srcdir)/internal/box.h
tcpserver.o: $(top_srcdir)/internal/compilers.h
tcpserver.o: $(top_srcdir)/internal/error.h
tcpserver.o: $(top_srcdir)/internal/gc.h
+tcpserver.o: $(top_srcdir)/internal/imemo.h
tcpserver.o: $(top_srcdir)/internal/io.h
+tcpserver.o: $(top_srcdir)/internal/sanitizers.h
tcpserver.o: $(top_srcdir)/internal/serial.h
+tcpserver.o: $(top_srcdir)/internal/set_table.h
tcpserver.o: $(top_srcdir)/internal/static_assert.h
tcpserver.o: $(top_srcdir)/internal/string.h
tcpserver.o: $(top_srcdir)/internal/thread.h
tcpserver.o: $(top_srcdir)/internal/vm.h
tcpserver.o: $(top_srcdir)/internal/warnings.h
+tcpserver.o: $(top_srcdir)/method.h
+tcpserver.o: $(top_srcdir)/node.h
+tcpserver.o: $(top_srcdir)/ruby_assert.h
+tcpserver.o: $(top_srcdir)/ruby_atomic.h
+tcpserver.o: $(top_srcdir)/rubyparser.h
tcpserver.o: $(top_srcdir)/shape.h
+tcpserver.o: $(top_srcdir)/thread_pthread.h
+tcpserver.o: $(top_srcdir)/vm_core.h
+tcpserver.o: $(top_srcdir)/vm_opts.h
tcpserver.o: constdefs.h
tcpserver.o: rubysocket.h
tcpserver.o: sockport.h
tcpserver.o: tcpserver.c
+tcpserver.o: {$(VPATH)}id.h
tcpsocket.o: $(RUBY_EXTCONF_H)
tcpsocket.o: $(arch_hdrdir)/ruby/config.h
tcpsocket.o: $(hdrdir)/ruby/assert.h
+tcpsocket.o: $(hdrdir)/ruby/atomic.h
tcpsocket.o: $(hdrdir)/ruby/backward.h
tcpsocket.o: $(hdrdir)/ruby/backward/2/assume.h
tcpsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2252,6 +2528,7 @@ tcpsocket.o: $(hdrdir)/ruby/internal/intern/re.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/select.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+tcpsocket.o: $(hdrdir)/ruby/internal/intern/set.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/signal.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2271,6 +2548,7 @@ tcpsocket.o: $(hdrdir)/ruby/internal/special_consts.h
tcpsocket.o: $(hdrdir)/ruby/internal/static_assert.h
tcpsocket.o: $(hdrdir)/ruby/internal/stdalign.h
tcpsocket.o: $(hdrdir)/ruby/internal/stdbool.h
+tcpsocket.o: $(hdrdir)/ruby/internal/stdckdint.h
tcpsocket.o: $(hdrdir)/ruby/internal/symbol.h
tcpsocket.o: $(hdrdir)/ruby/internal/value.h
tcpsocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2285,27 +2563,50 @@ tcpsocket.o: $(hdrdir)/ruby/ruby.h
tcpsocket.o: $(hdrdir)/ruby/st.h
tcpsocket.o: $(hdrdir)/ruby/subst.h
tcpsocket.o: $(hdrdir)/ruby/thread.h
+tcpsocket.o: $(hdrdir)/ruby/thread_native.h
tcpsocket.o: $(hdrdir)/ruby/util.h
+tcpsocket.o: $(hdrdir)/ruby/version.h
+tcpsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+tcpsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+tcpsocket.o: $(top_srcdir)/ccan/list/list.h
+tcpsocket.o: $(top_srcdir)/ccan/str/str.h
+tcpsocket.o: $(top_srcdir)/encindex.h
+tcpsocket.o: $(top_srcdir)/id_table.h
tcpsocket.o: $(top_srcdir)/internal.h
tcpsocket.o: $(top_srcdir)/internal/array.h
+tcpsocket.o: $(top_srcdir)/internal/basic_operators.h
+tcpsocket.o: $(top_srcdir)/internal/box.h
tcpsocket.o: $(top_srcdir)/internal/compilers.h
tcpsocket.o: $(top_srcdir)/internal/error.h
tcpsocket.o: $(top_srcdir)/internal/gc.h
+tcpsocket.o: $(top_srcdir)/internal/imemo.h
tcpsocket.o: $(top_srcdir)/internal/io.h
+tcpsocket.o: $(top_srcdir)/internal/sanitizers.h
tcpsocket.o: $(top_srcdir)/internal/serial.h
+tcpsocket.o: $(top_srcdir)/internal/set_table.h
tcpsocket.o: $(top_srcdir)/internal/static_assert.h
tcpsocket.o: $(top_srcdir)/internal/string.h
tcpsocket.o: $(top_srcdir)/internal/thread.h
tcpsocket.o: $(top_srcdir)/internal/vm.h
tcpsocket.o: $(top_srcdir)/internal/warnings.h
+tcpsocket.o: $(top_srcdir)/method.h
+tcpsocket.o: $(top_srcdir)/node.h
+tcpsocket.o: $(top_srcdir)/ruby_assert.h
+tcpsocket.o: $(top_srcdir)/ruby_atomic.h
+tcpsocket.o: $(top_srcdir)/rubyparser.h
tcpsocket.o: $(top_srcdir)/shape.h
+tcpsocket.o: $(top_srcdir)/thread_pthread.h
+tcpsocket.o: $(top_srcdir)/vm_core.h
+tcpsocket.o: $(top_srcdir)/vm_opts.h
tcpsocket.o: constdefs.h
tcpsocket.o: rubysocket.h
tcpsocket.o: sockport.h
tcpsocket.o: tcpsocket.c
+tcpsocket.o: {$(VPATH)}id.h
udpsocket.o: $(RUBY_EXTCONF_H)
udpsocket.o: $(arch_hdrdir)/ruby/config.h
udpsocket.o: $(hdrdir)/ruby/assert.h
+udpsocket.o: $(hdrdir)/ruby/atomic.h
udpsocket.o: $(hdrdir)/ruby/backward.h
udpsocket.o: $(hdrdir)/ruby/backward/2/assume.h
udpsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2443,6 +2744,7 @@ udpsocket.o: $(hdrdir)/ruby/internal/intern/re.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/select.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+udpsocket.o: $(hdrdir)/ruby/internal/intern/set.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/signal.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2462,6 +2764,7 @@ udpsocket.o: $(hdrdir)/ruby/internal/special_consts.h
udpsocket.o: $(hdrdir)/ruby/internal/static_assert.h
udpsocket.o: $(hdrdir)/ruby/internal/stdalign.h
udpsocket.o: $(hdrdir)/ruby/internal/stdbool.h
+udpsocket.o: $(hdrdir)/ruby/internal/stdckdint.h
udpsocket.o: $(hdrdir)/ruby/internal/symbol.h
udpsocket.o: $(hdrdir)/ruby/internal/value.h
udpsocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2476,27 +2779,50 @@ udpsocket.o: $(hdrdir)/ruby/ruby.h
udpsocket.o: $(hdrdir)/ruby/st.h
udpsocket.o: $(hdrdir)/ruby/subst.h
udpsocket.o: $(hdrdir)/ruby/thread.h
+udpsocket.o: $(hdrdir)/ruby/thread_native.h
udpsocket.o: $(hdrdir)/ruby/util.h
+udpsocket.o: $(hdrdir)/ruby/version.h
+udpsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+udpsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+udpsocket.o: $(top_srcdir)/ccan/list/list.h
+udpsocket.o: $(top_srcdir)/ccan/str/str.h
+udpsocket.o: $(top_srcdir)/encindex.h
+udpsocket.o: $(top_srcdir)/id_table.h
udpsocket.o: $(top_srcdir)/internal.h
udpsocket.o: $(top_srcdir)/internal/array.h
+udpsocket.o: $(top_srcdir)/internal/basic_operators.h
+udpsocket.o: $(top_srcdir)/internal/box.h
udpsocket.o: $(top_srcdir)/internal/compilers.h
udpsocket.o: $(top_srcdir)/internal/error.h
udpsocket.o: $(top_srcdir)/internal/gc.h
+udpsocket.o: $(top_srcdir)/internal/imemo.h
udpsocket.o: $(top_srcdir)/internal/io.h
+udpsocket.o: $(top_srcdir)/internal/sanitizers.h
udpsocket.o: $(top_srcdir)/internal/serial.h
+udpsocket.o: $(top_srcdir)/internal/set_table.h
udpsocket.o: $(top_srcdir)/internal/static_assert.h
udpsocket.o: $(top_srcdir)/internal/string.h
udpsocket.o: $(top_srcdir)/internal/thread.h
udpsocket.o: $(top_srcdir)/internal/vm.h
udpsocket.o: $(top_srcdir)/internal/warnings.h
+udpsocket.o: $(top_srcdir)/method.h
+udpsocket.o: $(top_srcdir)/node.h
+udpsocket.o: $(top_srcdir)/ruby_assert.h
+udpsocket.o: $(top_srcdir)/ruby_atomic.h
+udpsocket.o: $(top_srcdir)/rubyparser.h
udpsocket.o: $(top_srcdir)/shape.h
+udpsocket.o: $(top_srcdir)/thread_pthread.h
+udpsocket.o: $(top_srcdir)/vm_core.h
+udpsocket.o: $(top_srcdir)/vm_opts.h
udpsocket.o: constdefs.h
udpsocket.o: rubysocket.h
udpsocket.o: sockport.h
udpsocket.o: udpsocket.c
+udpsocket.o: {$(VPATH)}id.h
unixserver.o: $(RUBY_EXTCONF_H)
unixserver.o: $(arch_hdrdir)/ruby/config.h
unixserver.o: $(hdrdir)/ruby/assert.h
+unixserver.o: $(hdrdir)/ruby/atomic.h
unixserver.o: $(hdrdir)/ruby/backward.h
unixserver.o: $(hdrdir)/ruby/backward/2/assume.h
unixserver.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2634,6 +2960,7 @@ unixserver.o: $(hdrdir)/ruby/internal/intern/re.h
unixserver.o: $(hdrdir)/ruby/internal/intern/ruby.h
unixserver.o: $(hdrdir)/ruby/internal/intern/select.h
unixserver.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+unixserver.o: $(hdrdir)/ruby/internal/intern/set.h
unixserver.o: $(hdrdir)/ruby/internal/intern/signal.h
unixserver.o: $(hdrdir)/ruby/internal/intern/sprintf.h
unixserver.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2653,6 +2980,7 @@ unixserver.o: $(hdrdir)/ruby/internal/special_consts.h
unixserver.o: $(hdrdir)/ruby/internal/static_assert.h
unixserver.o: $(hdrdir)/ruby/internal/stdalign.h
unixserver.o: $(hdrdir)/ruby/internal/stdbool.h
+unixserver.o: $(hdrdir)/ruby/internal/stdckdint.h
unixserver.o: $(hdrdir)/ruby/internal/symbol.h
unixserver.o: $(hdrdir)/ruby/internal/value.h
unixserver.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2667,27 +2995,50 @@ unixserver.o: $(hdrdir)/ruby/ruby.h
unixserver.o: $(hdrdir)/ruby/st.h
unixserver.o: $(hdrdir)/ruby/subst.h
unixserver.o: $(hdrdir)/ruby/thread.h
+unixserver.o: $(hdrdir)/ruby/thread_native.h
unixserver.o: $(hdrdir)/ruby/util.h
+unixserver.o: $(hdrdir)/ruby/version.h
+unixserver.o: $(top_srcdir)/ccan/check_type/check_type.h
+unixserver.o: $(top_srcdir)/ccan/container_of/container_of.h
+unixserver.o: $(top_srcdir)/ccan/list/list.h
+unixserver.o: $(top_srcdir)/ccan/str/str.h
+unixserver.o: $(top_srcdir)/encindex.h
+unixserver.o: $(top_srcdir)/id_table.h
unixserver.o: $(top_srcdir)/internal.h
unixserver.o: $(top_srcdir)/internal/array.h
+unixserver.o: $(top_srcdir)/internal/basic_operators.h
+unixserver.o: $(top_srcdir)/internal/box.h
unixserver.o: $(top_srcdir)/internal/compilers.h
unixserver.o: $(top_srcdir)/internal/error.h
unixserver.o: $(top_srcdir)/internal/gc.h
+unixserver.o: $(top_srcdir)/internal/imemo.h
unixserver.o: $(top_srcdir)/internal/io.h
+unixserver.o: $(top_srcdir)/internal/sanitizers.h
unixserver.o: $(top_srcdir)/internal/serial.h
+unixserver.o: $(top_srcdir)/internal/set_table.h
unixserver.o: $(top_srcdir)/internal/static_assert.h
unixserver.o: $(top_srcdir)/internal/string.h
unixserver.o: $(top_srcdir)/internal/thread.h
unixserver.o: $(top_srcdir)/internal/vm.h
unixserver.o: $(top_srcdir)/internal/warnings.h
+unixserver.o: $(top_srcdir)/method.h
+unixserver.o: $(top_srcdir)/node.h
+unixserver.o: $(top_srcdir)/ruby_assert.h
+unixserver.o: $(top_srcdir)/ruby_atomic.h
+unixserver.o: $(top_srcdir)/rubyparser.h
unixserver.o: $(top_srcdir)/shape.h
+unixserver.o: $(top_srcdir)/thread_pthread.h
+unixserver.o: $(top_srcdir)/vm_core.h
+unixserver.o: $(top_srcdir)/vm_opts.h
unixserver.o: constdefs.h
unixserver.o: rubysocket.h
unixserver.o: sockport.h
unixserver.o: unixserver.c
+unixserver.o: {$(VPATH)}id.h
unixsocket.o: $(RUBY_EXTCONF_H)
unixsocket.o: $(arch_hdrdir)/ruby/config.h
unixsocket.o: $(hdrdir)/ruby/assert.h
+unixsocket.o: $(hdrdir)/ruby/atomic.h
unixsocket.o: $(hdrdir)/ruby/backward.h
unixsocket.o: $(hdrdir)/ruby/backward/2/assume.h
unixsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2825,6 +3176,7 @@ unixsocket.o: $(hdrdir)/ruby/internal/intern/re.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/ruby.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/select.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+unixsocket.o: $(hdrdir)/ruby/internal/intern/set.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/signal.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/sprintf.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -2844,6 +3196,7 @@ unixsocket.o: $(hdrdir)/ruby/internal/special_consts.h
unixsocket.o: $(hdrdir)/ruby/internal/static_assert.h
unixsocket.o: $(hdrdir)/ruby/internal/stdalign.h
unixsocket.o: $(hdrdir)/ruby/internal/stdbool.h
+unixsocket.o: $(hdrdir)/ruby/internal/stdckdint.h
unixsocket.o: $(hdrdir)/ruby/internal/symbol.h
unixsocket.o: $(hdrdir)/ruby/internal/value.h
unixsocket.o: $(hdrdir)/ruby/internal/value_type.h
@@ -2858,22 +3211,44 @@ unixsocket.o: $(hdrdir)/ruby/ruby.h
unixsocket.o: $(hdrdir)/ruby/st.h
unixsocket.o: $(hdrdir)/ruby/subst.h
unixsocket.o: $(hdrdir)/ruby/thread.h
+unixsocket.o: $(hdrdir)/ruby/thread_native.h
unixsocket.o: $(hdrdir)/ruby/util.h
+unixsocket.o: $(hdrdir)/ruby/version.h
+unixsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+unixsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+unixsocket.o: $(top_srcdir)/ccan/list/list.h
+unixsocket.o: $(top_srcdir)/ccan/str/str.h
+unixsocket.o: $(top_srcdir)/encindex.h
+unixsocket.o: $(top_srcdir)/id_table.h
unixsocket.o: $(top_srcdir)/internal.h
unixsocket.o: $(top_srcdir)/internal/array.h
+unixsocket.o: $(top_srcdir)/internal/basic_operators.h
+unixsocket.o: $(top_srcdir)/internal/box.h
unixsocket.o: $(top_srcdir)/internal/compilers.h
unixsocket.o: $(top_srcdir)/internal/error.h
unixsocket.o: $(top_srcdir)/internal/gc.h
+unixsocket.o: $(top_srcdir)/internal/imemo.h
unixsocket.o: $(top_srcdir)/internal/io.h
+unixsocket.o: $(top_srcdir)/internal/sanitizers.h
unixsocket.o: $(top_srcdir)/internal/serial.h
+unixsocket.o: $(top_srcdir)/internal/set_table.h
unixsocket.o: $(top_srcdir)/internal/static_assert.h
unixsocket.o: $(top_srcdir)/internal/string.h
unixsocket.o: $(top_srcdir)/internal/thread.h
unixsocket.o: $(top_srcdir)/internal/vm.h
unixsocket.o: $(top_srcdir)/internal/warnings.h
+unixsocket.o: $(top_srcdir)/method.h
+unixsocket.o: $(top_srcdir)/node.h
+unixsocket.o: $(top_srcdir)/ruby_assert.h
+unixsocket.o: $(top_srcdir)/ruby_atomic.h
+unixsocket.o: $(top_srcdir)/rubyparser.h
unixsocket.o: $(top_srcdir)/shape.h
+unixsocket.o: $(top_srcdir)/thread_pthread.h
+unixsocket.o: $(top_srcdir)/vm_core.h
+unixsocket.o: $(top_srcdir)/vm_opts.h
unixsocket.o: constdefs.h
unixsocket.o: rubysocket.h
unixsocket.o: sockport.h
unixsocket.o: unixsocket.c
+unixsocket.o: {$(VPATH)}id.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 4ca0983c68..a814e21c3a 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -327,6 +327,8 @@ end
net/if_dl.h
arpa/nameser.h
resolv.h
+ pthread.h
+ sched.h
].each {|h|
if have_header(h, headers)
headers << h
@@ -699,5 +701,11 @@ SRC
"not needed"
end
end
+
+ have_func("pthread_create")
+ have_func("pthread_detach")
+ have_func("pthread_attr_setdetachstate")
+
+ $VPATH << '$(topdir)' << '$(top_srcdir)'
create_makefile("socket")
end
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index 95a2feb3be..9a65490b1d 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -62,9 +62,6 @@
#endif
#include <unistd.h>
#else
-#if defined(_MSC_VER) && _MSC_VER <= 1200
-#include <windows.h>
-#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
@@ -171,9 +168,7 @@ static const char *const ai_errlist[] = {
#define GET_CANONNAME(ai, str) \
if (pai->ai_flags & AI_CANONNAME) {\
- if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
- strcpy((ai)->ai_canonname, (str));\
- } else {\
+ if (((ai)->ai_canonname = strdup(str)) == NULL) {\
error = EAI_MEMORY;\
goto free;\
}\
@@ -219,8 +214,7 @@ freeaddrinfo(struct addrinfo *ai)
do {
next = ai->ai_next;
- if (ai->ai_canonname)
- free(ai->ai_canonname);
+ free(ai->ai_canonname);
/* no need to free(ai->ai_addr) */
free(ai);
} while ((ai = next) != NULL);
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index ae5284fab6..98da8c1647 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -55,9 +55,6 @@
#endif
#endif
#ifdef _WIN32
-#if defined(_MSC_VER) && _MSC_VER <= 1200
-#include <windows.h>
-#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#define snprintf _snprintf
@@ -158,16 +155,14 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t ho
/* what we should do? */
} else if (flags & NI_NUMERICSERV) {
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) + 1 > servlen)
+ if (strlcpy(serv, numserv, servlen) >= servlen)
return ENI_MEMORY;
- strcpy(serv, numserv);
} else {
#if defined(HAVE_GETSERVBYPORT)
struct servent *sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (sp) {
- if (strlen(sp->s_name) + 1 > servlen)
+ if (strlcpy(serv, sp->s_name, servlen) >= servlen)
return ENI_MEMORY;
- strcpy(serv, sp->s_name);
} else
return ENI_NOSERVNAME;
#else
@@ -202,9 +197,8 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t ho
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_SYSTEM;
- if (strlen(numaddr) > hostlen)
+ if (strlcpy(host, numaddr, hostlen) >= hostlen)
return ENI_MEMORY;
- strcpy(host, numaddr);
} else {
#ifdef INET6
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
@@ -218,13 +212,12 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t ho
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
- if (strlen(hp->h_name) + 1 > hostlen) {
+ if (strlcpy(host, hp->h_name, hostlen) >= hostlen) {
#ifdef INET6
freehostent(hp);
#endif
return ENI_MEMORY;
}
- strcpy(host, hp->h_name);
#ifdef INET6
freehostent(hp);
#endif
@@ -234,9 +227,8 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t ho
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_NOHOSTNAME;
- if (strlen(numaddr) > hostlen)
+ if (strlcpy(host, numaddr, hostlen) >= hostlen)
return ENI_MEMORY;
- strcpy(host, numaddr);
}
}
return SUCCESS;
diff --git a/ext/socket/ifaddr.c b/ext/socket/ifaddr.c
index ab163dcc8f..3596c40a11 100644
--- a/ext/socket/ifaddr.c
+++ b/ext/socket/ifaddr.c
@@ -177,6 +177,8 @@ ifaddr_ifindex(VALUE self)
* ifaddr.flags => integer
*
* Returns the flags of _ifaddr_.
+ *
+ * The value is bitwise-or of Socket::IFF_* constants such as Socket::IFF_LOOPBACK.
*/
static VALUE
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 557d4374a5..6091385561 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -27,6 +27,7 @@ VALUE rb_cSocket;
VALUE rb_cAddrinfo;
VALUE rb_eSocket;
+VALUE rb_eResolution;
#ifdef SOCKS
VALUE rb_cSOCKSSocket;
@@ -34,9 +35,10 @@ VALUE rb_cSOCKSSocket;
int rsock_do_not_reverse_lookup = 1;
static VALUE sym_wait_readable;
+static ID id_error_code;
void
-rsock_raise_socket_error(const char *reason, int error)
+rsock_raise_resolution_error(const char *reason, int error)
{
#ifdef EAI_SYSTEM
int e;
@@ -48,10 +50,14 @@ rsock_raise_socket_error(const char *reason, int error)
VALUE msg = rb_sprintf("%s: ", reason);
if (!enc) enc = rb_default_internal_encoding();
rb_str_concat(msg, rb_w32_conv_from_wchar(gai_strerrorW(error), enc));
- rb_exc_raise(rb_exc_new_str(rb_eSocket, msg));
#else
- rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
+ VALUE msg = rb_sprintf("%s: %s", reason, gai_strerror(error));
#endif
+
+ StringValue(msg);
+ VALUE self = rb_class_new_instance(1, &msg, rb_eResolution);
+ rb_ivar_set(self, id_error_code, INT2NUM(error));
+ rb_exc_raise(self);
}
#if defined __APPLE__
@@ -101,6 +107,7 @@ rsock_send_blocking(void *data)
}
struct recvfrom_arg {
+ rb_io_t *fptr;
int fd, flags;
VALUE str;
size_t length;
@@ -116,6 +123,7 @@ recvfrom_blocking(void *data)
ssize_t ret;
ret = recvfrom(arg->fd, RSTRING_PTR(arg->str), arg->length,
arg->flags, &arg->buf.addr, &arg->alen);
+
if (ret != -1 && len0 < arg->alen)
arg->alen = len0;
@@ -144,7 +152,19 @@ recvfrom_locktmp(VALUE v)
{
struct recvfrom_arg *arg = (struct recvfrom_arg *)v;
- return rb_thread_io_blocking_region(recvfrom_blocking, arg, arg->fd);
+ return rb_io_blocking_region(arg->fptr, recvfrom_blocking, arg);
+}
+
+int
+rsock_is_dgram(rb_io_t *fptr)
+{
+ int socktype;
+ socklen_t optlen = (socklen_t)sizeof(socktype);
+ int ret = getsockopt(fptr->fd, SOL_SOCKET, SO_TYPE, (void*)&socktype, &optlen);
+ if (ret == -1) {
+ rb_sys_fail("getsockopt(SO_TYPE)");
+ }
+ return socktype == SOCK_DGRAM;
}
VALUE
@@ -173,6 +193,7 @@ rsock_s_recvfrom(VALUE socket, int argc, VALUE *argv, enum sock_recv_type from)
rb_raise(rb_eIOError, "recv for buffered IO");
}
+ arg.fptr = fptr;
arg.fd = fptr->fd;
arg.alen = (socklen_t)sizeof(arg.buf);
arg.str = str;
@@ -185,8 +206,12 @@ rsock_s_recvfrom(VALUE socket, int argc, VALUE *argv, enum sock_recv_type from)
rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
#endif
- slen = (long)rb_str_locktmp_ensure(str, recvfrom_locktmp, (VALUE)&arg);
+ rb_str_locktmp(str);
+ slen = (long)rb_ensure(recvfrom_locktmp, (VALUE)&arg, rb_str_unlocktmp, str);
+ if (slen == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
if (slen >= 0) break;
if (!rb_io_maybe_wait_readable(errno, socket, RUBY_IO_TIMEOUT_DEFAULT))
@@ -259,6 +284,10 @@ rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
if (slen != -1 && len0 < alen)
alen = len0;
+ if (slen == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
+
if (slen < 0) {
int e = errno;
switch (e) {
@@ -392,7 +421,7 @@ rsock_write_nonblock(VALUE sock, VALUE str, VALUE ex)
if (e == EWOULDBLOCK || e == EAGAIN) {
if (ex == Qfalse) return sym_wait_writable;
rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e,
- "write would block");
+ "write would block");
}
rb_syserr_fail_path(e, fptr->pathv);
}
@@ -433,9 +462,9 @@ rsock_socket(int domain, int type, int proto)
fd = rsock_socket0(domain, type, proto);
if (fd < 0) {
- if (rb_gc_for_fd(errno)) {
- fd = rsock_socket0(domain, type, proto);
- }
+ if (rb_gc_for_fd(errno)) {
+ fd = rsock_socket0(domain, type, proto);
+ }
}
if (0 <= fd)
rb_update_max_fd(fd);
@@ -444,10 +473,11 @@ rsock_socket(int domain, int type, int proto)
/* emulate blocking connect behavior on EINTR or non-blocking socket */
static int
-wait_connectable(int fd, struct timeval *timeout)
+wait_connectable(VALUE self, VALUE timeout, const struct sockaddr *sockaddr, int len)
{
- int sockerr, revents;
+ int sockerr;
socklen_t sockerrlen;
+ int fd = rb_io_descriptor(self);
sockerrlen = (socklen_t)sizeof(sockerr);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) < 0)
@@ -481,7 +511,15 @@ wait_connectable(int fd, struct timeval *timeout)
*
* Note: rb_wait_for_single_fd already retries on EINTR/ERESTART
*/
- revents = rb_wait_for_single_fd(fd, RB_WAITFD_IN|RB_WAITFD_OUT, timeout);
+ VALUE result = rb_io_wait(self, RB_INT2NUM(RUBY_IO_READABLE|RUBY_IO_WRITABLE), timeout);
+
+ if (result == Qfalse) {
+ VALUE rai = rsock_addrinfo_new((struct sockaddr *)sockaddr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
+ VALUE addr_str = rsock_addrinfo_inspect_sockaddr(rai);
+ rb_raise(rb_eIOTimeoutError, "user specified timeout for %" PRIsVALUE, addr_str);
+ }
+
+ int revents = RB_NUM2INT(result);
if (revents < 0)
return -1;
@@ -492,16 +530,10 @@ wait_connectable(int fd, struct timeval *timeout)
switch (sockerr) {
case 0:
- /*
- * be defensive in case some platforms set SO_ERROR on the original,
- * interrupted connect()
- */
-
- /* when the connection timed out, no errno is set and revents is 0. */
- if (timeout && revents == 0) {
- errno = ETIMEDOUT;
- return -1;
- }
+ /*
+ * be defensive in case some platforms set SO_ERROR on the original,
+ * interrupted connect()
+ */
case EINTR:
#ifdef ERESTART
case ERESTART:
@@ -549,19 +581,19 @@ socks_connect_blocking(void *data)
#endif
int
-rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks, struct timeval *timeout)
+rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, VALUE timeout)
{
- int status;
+ int descriptor = rb_io_descriptor(self);
rb_blocking_function_t *func = connect_blocking;
- struct connect_arg arg;
+ struct connect_arg arg = {.fd = descriptor, .sockaddr = sockaddr, .len = len};
+
+ rb_io_t *fptr;
+ RB_IO_POINTER(self, fptr);
- arg.fd = fd;
- arg.sockaddr = sockaddr;
- arg.len = len;
#if defined(SOCKS) && !defined(SOCKS5)
if (socks) func = socks_connect_blocking;
#endif
- status = (int)BLOCKING_REGION_FD(func, &arg);
+ int status = (int)rb_io_blocking_region(fptr, func, &arg);
if (status < 0) {
switch (errno) {
@@ -573,7 +605,7 @@ rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks, struc
#ifdef EINPROGRESS
case EINPROGRESS:
#endif
- return wait_connectable(fd, timeout);
+ return wait_connectable(self, timeout, sockaddr, len);
}
}
return status;
@@ -681,9 +713,9 @@ rsock_s_accept(VALUE klass, VALUE io, struct sockaddr *sockaddr, socklen_t *len)
RB_IO_POINTER(io, fptr);
struct accept_arg accept_arg = {
- .fd = fptr->fd,
- .sockaddr = sockaddr,
- .len = len
+ .fd = fptr->fd,
+ .sockaddr = sockaddr,
+ .len = len
};
int retry = 0, peer;
@@ -692,7 +724,7 @@ rsock_s_accept(VALUE klass, VALUE io, struct sockaddr *sockaddr, socklen_t *len)
#ifdef RSOCK_WAIT_BEFORE_BLOCKING
rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
#endif
- peer = (int)BLOCKING_REGION_FD(accept_blocking, &accept_arg);
+ peer = (int)rb_io_blocking_region(fptr, accept_blocking, &accept_arg);
if (peer < 0) {
int error = errno;
@@ -730,10 +762,10 @@ rsock_getfamily(rb_io_t *fptr)
if (cached) {
switch (cached) {
#ifdef AF_UNIX
- case FMODE_UNIX: return AF_UNIX;
+ case FMODE_UNIX: return AF_UNIX;
#endif
- case FMODE_INET: return AF_INET;
- case FMODE_INET6: return AF_INET6;
+ case FMODE_INET: return AF_INET;
+ case FMODE_INET6: return AF_INET6;
}
}
@@ -752,6 +784,28 @@ rsock_getfamily(rb_io_t *fptr)
return ss.addr.sa_family;
}
+/*
+ * call-seq:
+ * error_code -> integer
+ *
+ * Returns the raw error code indicating the cause of the hostname resolution failure.
+ *
+ * begin
+ * Addrinfo.getaddrinfo("ruby-lang.org", nil)
+ * rescue Socket::ResolutionError => e
+ * if e.error_code == Socket::EAI_AGAIN
+ * puts "Temporary failure in name resolution."
+ * end
+ * end
+ *
+ * Note that error codes depend on the operating system.
+ */
+static VALUE
+sock_resolv_error_code(VALUE self)
+{
+ return rb_attr_get(self, id_error_code);
+}
+
void
rsock_init_socket_init(void)
{
@@ -759,6 +813,11 @@ rsock_init_socket_init(void)
* SocketError is the error class for socket.
*/
rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
+ /*
+ * Socket::ResolutionError is the error class for hostname resolution.
+ */
+ rb_eResolution = rb_define_class_under(rb_cSocket, "ResolutionError", rb_eSocket);
+ rb_define_method(rb_eResolution, "error_code", sock_resolv_error_code, 0);
rsock_init_ipsocket();
rsock_init_tcpsocket();
rsock_init_tcpserver();
@@ -772,6 +831,8 @@ rsock_init_socket_init(void)
rsock_init_sockifaddr();
rsock_init_socket_constants();
+ id_error_code = rb_intern_const("error_code");
+
#undef rb_intern
sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index 0c13620258..e1943b8496 100644
--- a/ext/socket/ipsocket.c
+++ b/ext/socket/ipsocket.c
@@ -9,20 +9,39 @@
************************************************/
#include "rubysocket.h"
+#include <stdio.h>
struct inetsock_arg
{
- VALUE sock;
+ VALUE self;
+ VALUE io;
+
struct {
VALUE host, serv;
struct rb_addrinfo *res;
} remote, local;
int type;
- int fd;
VALUE resolv_timeout;
VALUE connect_timeout;
+ VALUE open_timeout;
};
+void
+rsock_raise_user_specified_timeout(struct addrinfo *ai, VALUE host, VALUE port)
+{
+ VALUE message;
+
+ if (ai && ai->ai_addr) {
+ VALUE rai = rsock_addrinfo_new((struct sockaddr *)ai->ai_addr, (socklen_t)ai->ai_addrlen, PF_UNSPEC, 0, 0, Qnil, Qnil);
+ VALUE addr_str = rsock_addrinfo_inspect_sockaddr(rai);
+ message = rb_sprintf("user specified timeout for %" PRIsVALUE, addr_str);
+ } else {
+ message = rb_sprintf("user specified timeout for %" PRIsVALUE " port %" PRIsVALUE, host, port);
+ }
+
+ rb_exc_raise(rb_exc_new_str(rb_eIOTimeoutError, message));
+}
+
static VALUE
inetsock_cleanup(VALUE v)
{
@@ -35,35 +54,42 @@ inetsock_cleanup(VALUE v)
rb_freeaddrinfo(arg->local.res);
arg->local.res = 0;
}
- if (arg->fd >= 0) {
- close(arg->fd);
+ if (arg->io != Qnil) {
+ rb_io_close(arg->io);
+ arg->io = Qnil;
}
return Qnil;
}
static VALUE
+current_clocktime(void)
+{
+ VALUE clock_monotnic_const = rb_const_get(rb_mProcess, rb_intern("CLOCK_MONOTONIC"));
+ return rb_funcall(rb_mProcess, rb_intern("clock_gettime"), 1, clock_monotnic_const);
+}
+
+static VALUE
init_inetsock_internal(VALUE v)
{
struct inetsock_arg *arg = (void *)v;
int error = 0;
int type = arg->type;
struct addrinfo *res, *lres;
- int fd, status = 0, local = 0;
+ int status = 0, local = 0;
int family = AF_UNSPEC;
const char *syscall = 0;
+ VALUE resolv_timeout = arg->resolv_timeout;
VALUE connect_timeout = arg->connect_timeout;
- struct timeval tv_storage;
- struct timeval *tv = NULL;
+ VALUE open_timeout = arg->open_timeout;
+ VALUE timeout;
+ VALUE starts_at;
- if (!NIL_P(connect_timeout)) {
- tv_storage = rb_time_interval(connect_timeout);
- tv = &tv_storage;
- }
+ timeout = NIL_P(open_timeout) ? resolv_timeout : open_timeout;
+ starts_at = current_clocktime();
arg->remote.res = rsock_addrinfo(arg->remote.host, arg->remote.serv,
family, SOCK_STREAM,
- (type == INET_SERVER) ? AI_PASSIVE : 0);
-
+ (type == INET_SERVER) ? AI_PASSIVE : 0, timeout);
/*
* Maybe also accept a local address
@@ -71,10 +97,11 @@ init_inetsock_internal(VALUE v)
if (type != INET_SERVER && (!NIL_P(arg->local.host) || !NIL_P(arg->local.serv))) {
arg->local.res = rsock_addrinfo(arg->local.host, arg->local.serv,
- family, SOCK_STREAM, 0);
+ family, SOCK_STREAM, 0, timeout);
}
- arg->fd = fd = -1;
+ VALUE io = Qnil;
+
for (res = arg->remote.res->ai; res; res = res->ai_next) {
#if !defined(INET6) && defined(AF_INET6)
if (res->ai_family == AF_INET6)
@@ -96,12 +123,14 @@ init_inetsock_internal(VALUE v)
}
status = rsock_socket(res->ai_family,res->ai_socktype,res->ai_protocol);
syscall = "socket(2)";
- fd = status;
- if (fd < 0) {
+ if (status < 0) {
error = errno;
continue;
}
- arg->fd = fd;
+
+ int fd = status;
+ io = arg->io = rsock_init_sock(arg->self, fd);
+
if (type == INET_SERVER) {
#if !defined(_WIN32) && !defined(__CYGWIN__)
status = 1;
@@ -123,21 +152,33 @@ init_inetsock_internal(VALUE v)
syscall = "bind(2)";
}
+ if (NIL_P(open_timeout)) {
+ timeout = connect_timeout;
+ } else {
+ VALUE elapsed = rb_funcall(current_clocktime(), '-', 1, starts_at);
+ timeout = rb_funcall(open_timeout, '-', 1, elapsed);
+ if (rb_funcall(timeout, '<', 1, INT2FIX(0)) == Qtrue) {
+ rsock_raise_user_specified_timeout(res, arg->remote.host, arg->remote.serv);
+ }
+ }
+
if (status >= 0) {
- status = rsock_connect(fd, res->ai_addr, res->ai_addrlen,
- (type == INET_SOCKS), tv);
+ status = rsock_connect(io, res->ai_addr, res->ai_addrlen, (type == INET_SOCKS), timeout);
syscall = "connect(2)";
}
}
if (status < 0) {
error = errno;
- close(fd);
- arg->fd = fd = -1;
+ arg->io = Qnil;
+ rb_io_close(io);
+ io = Qnil;
continue;
- } else
+ } else {
break;
+ }
}
+
if (status < 0) {
VALUE host, port;
@@ -152,28 +193,38 @@ init_inetsock_internal(VALUE v)
rsock_syserr_fail_host_port(error, syscall, host, port);
}
- arg->fd = -1;
+ // Don't close the socket in `inetsock_cleanup` if we are returning it:
+ arg->io = Qnil;
- if (type == INET_SERVER) {
- status = listen(fd, SOMAXCONN);
+ if (type == INET_SERVER && io != Qnil) {
+ status = listen(rb_io_descriptor(io), SOMAXCONN);
if (status < 0) {
error = errno;
- close(fd);
+ rb_io_close(io);
rb_syserr_fail(error, "listen(2)");
}
}
/* create new instance */
- return rsock_init_sock(arg->sock, fd);
+ return io;
}
+#if FAST_FALLBACK_INIT_INETSOCK_IMPL == 0
+
VALUE
-rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
- VALUE local_host, VALUE local_serv, int type,
- VALUE resolv_timeout, VALUE connect_timeout)
+rsock_init_inetsock(
+ VALUE self, VALUE remote_host, VALUE remote_serv,
+ VALUE local_host, VALUE local_serv, int type,
+ VALUE resolv_timeout, VALUE connect_timeout, VALUE open_timeout,
+ VALUE _fast_fallback, VALUE _test_mode_settings)
{
+ if (!NIL_P(open_timeout) && (!NIL_P(resolv_timeout) || !NIL_P(connect_timeout))) {
+ rb_raise(rb_eArgError, "Cannot specify open_timeout along with connect_timeout or resolv_timeout");
+ }
+
struct inetsock_arg arg;
- arg.sock = sock;
+ arg.self = self;
+ arg.io = Qnil;
arg.remote.host = remote_host;
arg.remote.serv = remote_serv;
arg.remote.res = 0;
@@ -181,13 +232,1205 @@ rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
arg.local.serv = local_serv;
arg.local.res = 0;
arg.type = type;
- arg.fd = -1;
arg.resolv_timeout = resolv_timeout;
arg.connect_timeout = connect_timeout;
+ arg.open_timeout = open_timeout;
return rb_ensure(init_inetsock_internal, (VALUE)&arg,
inetsock_cleanup, (VALUE)&arg);
}
+#elif FAST_FALLBACK_INIT_INETSOCK_IMPL == 1
+
+#define IPV6_ENTRY_POS 0
+#define IPV4_ENTRY_POS 1
+#define RESOLUTION_ERROR 0
+#define SYSCALL_ERROR 1
+
+static int
+is_specified_ip_address(const char *hostname)
+{
+ if (!hostname) return false;
+
+ struct in_addr ipv4addr;
+ struct in6_addr ipv6addr;
+
+ return (inet_pton(AF_INET6, hostname, &ipv6addr) == 1 ||
+ inet_pton(AF_INET, hostname, &ipv4addr) == 1);
+}
+
+static int
+is_local_port_fixed(const char *portp)
+{
+ if (!portp) return 0;
+
+ char *endp;
+ errno = 0;
+ long port = strtol(portp, &endp, 10);
+
+ if (endp == portp) return 0;
+ if (errno == ERANGE) return 0;
+
+ return port > 0;
+}
+
+struct fast_fallback_inetsock_arg
+{
+ VALUE self;
+ VALUE io;
+
+ struct {
+ VALUE host, serv;
+ struct rb_addrinfo *res;
+ } remote, local;
+ int type;
+ VALUE resolv_timeout;
+ VALUE connect_timeout;
+ VALUE open_timeout;
+
+ const char *hostp, *portp;
+ int *families;
+ int family_size;
+ int additional_flags;
+ struct fast_fallback_getaddrinfo_entry *getaddrinfo_entries[2];
+ struct fast_fallback_getaddrinfo_shared *getaddrinfo_shared;
+ rb_fdset_t readfds, writefds;
+ int wait;
+ int connection_attempt_fds_size;
+ int *connection_attempt_fds;
+ VALUE test_mode_settings;
+};
+
+static struct fast_fallback_getaddrinfo_shared *
+allocate_fast_fallback_getaddrinfo_shared(int family_size)
+{
+ struct fast_fallback_getaddrinfo_shared *shared;
+
+ shared = (struct fast_fallback_getaddrinfo_shared *)calloc(
+ 1,
+ sizeof(struct fast_fallback_getaddrinfo_shared) + (family_size == 1 ? 0 : 2) * sizeof(struct fast_fallback_getaddrinfo_entry)
+ );
+
+ return shared;
+}
+
+static void
+allocate_fast_fallback_getaddrinfo_hints(struct addrinfo *hints, int family, int remote_addrinfo_hints, int additional_flags)
+{
+ MEMZERO(hints, struct addrinfo, 1);
+ hints->ai_family = family;
+ hints->ai_socktype = SOCK_STREAM;
+ hints->ai_protocol = IPPROTO_TCP;
+ hints->ai_flags = remote_addrinfo_hints;
+ hints->ai_flags |= additional_flags;
+}
+
+static int*
+allocate_connection_attempt_fds(int additional_capacity)
+{
+ int *fds = (int *)malloc(additional_capacity * sizeof(int));
+ if (!fds) rb_syserr_fail(errno, "malloc(3)");
+ for (int i = 0; i < additional_capacity; i++) fds[i] = -1;
+ return fds;
+}
+
+static int
+reallocate_connection_attempt_fds(int **fds, int current_capacity, int additional_capacity)
+{
+ int new_capacity = current_capacity + additional_capacity;
+ int *new_fds;
+
+ new_fds = realloc(*fds, new_capacity * sizeof(int));
+ if (new_fds == NULL) {
+ rb_syserr_fail(errno, "realloc(3)");
+ }
+ *fds = new_fds;
+
+ for (int i = current_capacity; i < new_capacity; i++) (*fds)[i] = -1;
+ return new_capacity;
+}
+
+struct hostname_resolution_result
+{
+ struct addrinfo *ai;
+ int finished;
+ int has_error;
+};
+
+struct hostname_resolution_store
+{
+ struct hostname_resolution_result v6;
+ struct hostname_resolution_result v4;
+ int is_all_finished;
+};
+
+static int
+any_addrinfos(struct hostname_resolution_store *resolution_store)
+{
+ return resolution_store->v6.ai || resolution_store->v4.ai;
+}
+
+static struct timespec
+current_clocktime_ts(void)
+{
+ struct timespec ts;
+ if ((clock_gettime(CLOCK_MONOTONIC, &ts)) < 0) {
+ rb_syserr_fail(errno, "clock_gettime(2)");
+ }
+ return ts;
+}
+
+static void
+set_timeout_tv(struct timeval *tv, long ms, struct timespec from)
+{
+ long sec = ms / 1000;
+ long nsec = (ms % 1000) * 1000000;
+ long result_sec = from.tv_sec + sec;
+ long result_nsec = from.tv_nsec + nsec;
+
+ result_sec += result_nsec / 1000000000;
+ result_nsec = result_nsec % 1000000000;
+
+ tv->tv_sec = result_sec;
+ tv->tv_usec = (int)(result_nsec / 1000);
+}
+
+static struct timeval
+add_ts_to_tv(struct timeval tv, struct timespec ts)
+{
+ long ts_usec = ts.tv_nsec / 1000;
+ tv.tv_sec += ts.tv_sec;
+ tv.tv_usec += ts_usec;
+
+ if (tv.tv_usec >= 1000000) {
+ tv.tv_sec += tv.tv_usec / 1000000;
+ tv.tv_usec = tv.tv_usec % 1000000;
+ }
+
+ return tv;
+}
+
+static VALUE
+tv_to_seconds(struct timeval *timeout) {
+ if (timeout == NULL) return Qnil;
+
+ double seconds = (double)timeout->tv_sec + (double)timeout->tv_usec / 1000000.0;
+
+ return DBL2NUM(seconds);
+}
+
+static int
+is_infinity(struct timeval tv)
+{
+ // { -1, -1 } as infinity
+ return tv.tv_sec == -1 || tv.tv_usec == -1;
+}
+
+static int
+is_timeout_tv(struct timeval *timeout_tv, struct timespec now) {
+ if (!timeout_tv) return false;
+ if (timeout_tv->tv_sec == -1 && timeout_tv->tv_usec == -1) return false;
+
+ struct timespec ts;
+ ts.tv_sec = timeout_tv->tv_sec;
+ ts.tv_nsec = timeout_tv->tv_usec * 1000;
+
+ if (now.tv_sec > ts.tv_sec) return true;
+ if (now.tv_sec == ts.tv_sec && now.tv_nsec >= ts.tv_nsec) return true;
+ return false;
+}
+
+static struct timeval *
+select_expires_at(
+ struct hostname_resolution_store *resolution_store,
+ struct timeval *resolution_delay,
+ struct timeval *connection_attempt_delay,
+ struct timeval *user_specified_resolv_timeout_at,
+ struct timeval *user_specified_connect_timeout_at,
+ struct timeval *user_specified_open_timeout_at)
+{
+ if (any_addrinfos(resolution_store)) {
+ struct timeval *delay;
+ delay = resolution_delay ? resolution_delay : connection_attempt_delay;
+
+ if (user_specified_open_timeout_at &&
+ timercmp(user_specified_open_timeout_at, delay, <)) {
+ return user_specified_open_timeout_at;
+ }
+ return delay;
+ }
+
+ if (user_specified_open_timeout_at) return user_specified_open_timeout_at;
+
+ struct timeval *timeout = NULL;
+
+ if (user_specified_resolv_timeout_at) {
+ if (is_infinity(*user_specified_resolv_timeout_at)) return NULL;
+ timeout = user_specified_resolv_timeout_at;
+ }
+
+ if (user_specified_connect_timeout_at) {
+ if (is_infinity(*user_specified_connect_timeout_at)) return NULL;
+ if (!timeout || timercmp(user_specified_connect_timeout_at, timeout, >)) {
+ return user_specified_connect_timeout_at;
+ }
+ }
+
+ return timeout;
+}
+
+static struct timeval
+tv_to_timeout(struct timeval *ends_at, struct timespec now)
+{
+ struct timeval delay;
+ struct timespec expires_at;
+ expires_at.tv_sec = ends_at->tv_sec;
+ expires_at.tv_nsec = ends_at->tv_usec * 1000;
+
+ struct timespec diff;
+ diff.tv_sec = expires_at.tv_sec - now.tv_sec;
+
+ if (expires_at.tv_nsec >= now.tv_nsec) {
+ diff.tv_nsec = expires_at.tv_nsec - now.tv_nsec;
+ } else {
+ diff.tv_sec -= 1;
+ diff.tv_nsec = (1000000000 + expires_at.tv_nsec) - now.tv_nsec;
+ }
+
+ delay.tv_sec = diff.tv_sec;
+ delay.tv_usec = (int)diff.tv_nsec / 1000;
+
+ return delay;
+}
+
+static struct addrinfo *
+pick_addrinfo(struct hostname_resolution_store *resolution_store, int last_family)
+{
+ int priority_on_v6[2] = { AF_INET6, AF_INET };
+ int priority_on_v4[2] = { AF_INET, AF_INET6 };
+ int *precedences = last_family == AF_INET6 ? priority_on_v4 : priority_on_v6;
+ struct addrinfo *selected_ai = NULL;
+
+ for (int i = 0; i < 2; i++) {
+ if (precedences[i] == AF_INET6) {
+ selected_ai = resolution_store->v6.ai;
+ if (selected_ai) {
+ resolution_store->v6.ai = selected_ai->ai_next;
+ break;
+ }
+ } else {
+ selected_ai = resolution_store->v4.ai;
+ if (selected_ai) {
+ resolution_store->v4.ai = selected_ai->ai_next;
+ break;
+ }
+ }
+ }
+ return selected_ai;
+}
+
+static void
+socket_nonblock_set(int fd)
+{
+ int flags = fcntl(fd, F_GETFL);
+
+ if (flags < 0) rb_syserr_fail(errno, "fcntl(2)");
+ if ((flags & O_NONBLOCK) != 0) return;
+
+ flags |= O_NONBLOCK;
+
+ if (fcntl(fd, F_SETFL, flags) < 0) rb_syserr_fail(errno, "fcntl(2)");
+ return;
+}
+
+static int
+in_progress_fds(int fds_size)
+{
+ return fds_size > 0;
+}
+
+static void
+remove_connection_attempt_fd(int *fds, int *fds_size, int removing_fd)
+{
+ int i, j;
+
+ for (i = 0; i < *fds_size; i++) {
+ if (fds[i] != removing_fd) continue;
+
+ for (j = i; j < *fds_size - 1; j++) {
+ fds[j] = fds[j + 1];
+ }
+
+ (*fds_size)--;
+ fds[*fds_size] = -1;
+ break;
+ }
+}
+
+struct fast_fallback_error
+{
+ int type;
+ int ecode;
+};
+
+static VALUE
+init_fast_fallback_inetsock_internal(VALUE v)
+{
+ struct fast_fallback_inetsock_arg *arg = (void *)v;
+ VALUE io = arg->io;
+ VALUE resolv_timeout = arg->resolv_timeout;
+ VALUE connect_timeout = arg->connect_timeout;
+ VALUE open_timeout = arg->open_timeout;
+ VALUE test_mode_settings = arg->test_mode_settings;
+ struct addrinfo *remote_ai = NULL, *local_ai = NULL;
+ int connected_fd = -1, status = 0, local_status = 0;
+ int remote_addrinfo_hints = 0;
+ struct fast_fallback_error last_error = { 0, 0 };
+ const char *syscall = 0;
+ VALUE host, serv;
+
+ #ifdef HAVE_CONST_AI_ADDRCONFIG
+ remote_addrinfo_hints |= AI_ADDRCONFIG;
+ #endif
+
+ pthread_t threads[arg->family_size];
+ char resolved_type[2];
+ ssize_t resolved_type_size;
+ int hostname_resolution_waiter = -1, hostname_resolution_notifier = -1;
+ int pipefd[2];
+
+ int nfds = 0;
+ struct timeval *ends_at = NULL;
+ struct timeval delay = (struct timeval){ -1, -1 };
+ struct timeval *delay_p = NULL;
+
+ struct hostname_resolution_store resolution_store;
+ resolution_store.is_all_finished = false;
+ resolution_store.v6.ai = NULL;
+ resolution_store.v6.finished = false;
+ resolution_store.v6.has_error = false;
+ resolution_store.v4.ai = NULL;
+ resolution_store.v4.finished = false;
+ resolution_store.v4.has_error = false;
+
+ int last_family = 0;
+ int additional_capacity = 10;
+ int current_capacity = additional_capacity;
+ arg->connection_attempt_fds = allocate_connection_attempt_fds(additional_capacity);
+ arg->connection_attempt_fds_size = 0;
+
+ struct timeval resolution_delay_storage;
+ struct timeval *resolution_delay_expires_at = NULL;
+ struct timeval connection_attempt_delay_strage;
+ struct timeval *connection_attempt_delay_expires_at = NULL;
+ struct timeval user_specified_resolv_timeout_storage;
+ struct timeval *user_specified_resolv_timeout_at = NULL;
+ struct timeval user_specified_connect_timeout_storage;
+ struct timeval *user_specified_connect_timeout_at = NULL;
+ struct timeval user_specified_open_timeout_storage;
+ struct timeval *user_specified_open_timeout_at = NULL;
+ struct timespec now = current_clocktime_ts();
+ VALUE starts_at = current_clocktime();
+
+ if (!NIL_P(open_timeout)) {
+ struct timeval open_timeout_tv = rb_time_interval(open_timeout);
+ user_specified_open_timeout_storage = add_ts_to_tv(open_timeout_tv, now);
+ user_specified_open_timeout_at = &user_specified_open_timeout_storage;
+ }
+
+ /* start of hostname resolution */
+ if (arg->family_size == 1) {
+ arg->wait = -1;
+ arg->getaddrinfo_shared = NULL;
+
+ int family = arg->families[0];
+ VALUE t = NIL_P(open_timeout) ? resolv_timeout : open_timeout;
+
+ arg->remote.res = rsock_addrinfo(
+ arg->remote.host,
+ arg->remote.serv,
+ family,
+ SOCK_STREAM,
+ 0,
+ t
+ );
+
+ if (family == AF_INET6) {
+ resolution_store.v6.ai = arg->remote.res->ai;
+ resolution_store.v6.finished = true;
+ resolution_store.v4.finished = true;
+ } else if (family == AF_INET) {
+ resolution_store.v4.ai = arg->remote.res->ai;
+ resolution_store.v4.finished = true;
+ resolution_store.v6.finished = true;
+ }
+ resolution_store.is_all_finished = true;
+ } else {
+ if (pipe(pipefd) != 0) rb_syserr_fail(errno, "pipe(2)");
+ hostname_resolution_waiter = pipefd[0];
+ int waiter_flags = fcntl(hostname_resolution_waiter, F_GETFL, 0);
+ if (waiter_flags < 0) rb_syserr_fail(errno, "fcntl(2)");
+ if ((fcntl(hostname_resolution_waiter, F_SETFL, waiter_flags | O_NONBLOCK)) < 0) {
+ rb_syserr_fail(errno, "fcntl(2)");
+ }
+ arg->wait = hostname_resolution_waiter;
+ hostname_resolution_notifier = pipefd[1];
+
+ arg->getaddrinfo_shared = allocate_fast_fallback_getaddrinfo_shared(arg->family_size);
+ if (!arg->getaddrinfo_shared) rb_syserr_fail(errno, "calloc(3)");
+
+ rb_nativethread_lock_initialize(&arg->getaddrinfo_shared->lock);
+ arg->getaddrinfo_shared->notify = hostname_resolution_notifier;
+
+ arg->getaddrinfo_shared->node = arg->hostp ? ruby_strdup(arg->hostp) : NULL;
+ arg->getaddrinfo_shared->service = arg->portp ? ruby_strdup(arg->portp) : NULL;
+ arg->getaddrinfo_shared->refcount = arg->family_size + 1;
+
+ for (int i = 0; i < arg->family_size; i++) {
+ arg->getaddrinfo_entries[i] = &arg->getaddrinfo_shared->getaddrinfo_entries[i];
+ arg->getaddrinfo_entries[i]->shared = arg->getaddrinfo_shared;
+
+ struct addrinfo getaddrinfo_hints[arg->family_size];
+
+ allocate_fast_fallback_getaddrinfo_hints(
+ &getaddrinfo_hints[i],
+ arg->families[i],
+ remote_addrinfo_hints,
+ arg->additional_flags
+ );
+
+ arg->getaddrinfo_entries[i]->hints = getaddrinfo_hints[i];
+ arg->getaddrinfo_entries[i]->ai = NULL;
+ arg->getaddrinfo_entries[i]->family = arg->families[i];
+ arg->getaddrinfo_entries[i]->refcount = 2;
+ arg->getaddrinfo_entries[i]->has_syserr = false;
+ arg->getaddrinfo_entries[i]->test_sleep_ms = 0;
+ arg->getaddrinfo_entries[i]->test_ecode = 0;
+
+ /* for testing HEv2 */
+ if (!NIL_P(test_mode_settings) && RB_TYPE_P(test_mode_settings, T_HASH)) {
+ const char *family_sym = arg->families[i] == AF_INET6 ? "ipv6" : "ipv4";
+
+ VALUE test_delay_setting = rb_hash_aref(test_mode_settings, ID2SYM(rb_intern("delay")));
+ if (!NIL_P(test_delay_setting)) {
+ VALUE rb_test_delay_ms = rb_hash_aref(test_delay_setting, ID2SYM(rb_intern(family_sym)));
+ long test_delay_ms = NIL_P(rb_test_delay_ms) ? 0 : rb_test_delay_ms;
+ arg->getaddrinfo_entries[i]->test_sleep_ms = test_delay_ms;
+ }
+
+ VALUE test_error_setting = rb_hash_aref(test_mode_settings, ID2SYM(rb_intern("error")));
+ if (!NIL_P(test_error_setting)) {
+ VALUE rb_test_ecode = rb_hash_aref(test_error_setting, ID2SYM(rb_intern(family_sym)));
+ if (!NIL_P(rb_test_ecode)) {
+ arg->getaddrinfo_entries[i]->test_ecode = NUM2INT(rb_test_ecode);
+ }
+ }
+ }
+
+ if (raddrinfo_pthread_create(&threads[i], fork_safe_do_fast_fallback_getaddrinfo, arg->getaddrinfo_entries[i]) != 0) {
+ rsock_raise_resolution_error("getaddrinfo(3)", EAI_AGAIN);
+ }
+ }
+
+ if (NIL_P(resolv_timeout)) {
+ user_specified_resolv_timeout_storage = (struct timeval){ -1, -1 };
+ } else {
+ struct timeval resolv_timeout_tv = rb_time_interval(resolv_timeout);
+ user_specified_resolv_timeout_storage = add_ts_to_tv(resolv_timeout_tv, now);
+ }
+ user_specified_resolv_timeout_at = &user_specified_resolv_timeout_storage;
+ }
+
+ while (true) {
+ /* start of connection */
+ if (any_addrinfos(&resolution_store) &&
+ !resolution_delay_expires_at &&
+ !connection_attempt_delay_expires_at) {
+ while ((remote_ai = pick_addrinfo(&resolution_store, last_family))) {
+ int fd = -1;
+
+ #if !defined(INET6) && defined(AF_INET6)
+ if (remote_ai->ai_family == AF_INET6) {
+ if (any_addrinfos(&resolution_store)) continue;
+ if (!in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (resolution_store.is_all_finished) break;
+
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+ #endif
+
+ local_ai = NULL;
+
+ if (arg->local.res) {
+ for (local_ai = arg->local.res->ai; local_ai; local_ai = local_ai->ai_next) {
+ if (local_ai->ai_family == remote_ai->ai_family) break;
+ }
+ if (!local_ai) {
+ if (any_addrinfos(&resolution_store)) continue;
+ if (in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (!resolution_store.is_all_finished) break;
+
+ /* Use a different family local address if no choice, this
+ * will cause EAFNOSUPPORT. */
+ rsock_syserr_fail_host_port(EAFNOSUPPORT, syscall, arg->local.host, arg->local.serv);
+ }
+ }
+
+ status = rsock_socket(remote_ai->ai_family, remote_ai->ai_socktype, remote_ai->ai_protocol);
+ syscall = "socket(2)";
+
+ if (status < 0) {
+ last_error.type = SYSCALL_ERROR;
+ last_error.ecode = errno;
+
+ if (any_addrinfos(&resolution_store)) continue;
+ if (in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (!resolution_store.is_all_finished) break;
+
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+
+ fd = status;
+
+ if (local_ai) {
+ #if !defined(_WIN32) && !defined(__CYGWIN__)
+ status = 1;
+ if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&status, (socklen_t)sizeof(status))) < 0) {
+ rb_syserr_fail(errno, "setsockopt(2)");
+ }
+ #endif
+ status = bind(fd, local_ai->ai_addr, local_ai->ai_addrlen);
+ local_status = status;
+ syscall = "bind(2)";
+
+ if (status < 0) {
+ last_error.type = SYSCALL_ERROR;
+ last_error.ecode = errno;
+ close(fd);
+
+ if (any_addrinfos(&resolution_store)) continue;
+ if (in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (!resolution_store.is_all_finished) break;
+
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+ }
+
+ syscall = "connect(2)";
+
+ if (any_addrinfos(&resolution_store) ||
+ in_progress_fds(arg->connection_attempt_fds_size) ||
+ !resolution_store.is_all_finished) {
+ socket_nonblock_set(fd);
+ status = connect(fd, remote_ai->ai_addr, remote_ai->ai_addrlen);
+ last_family = remote_ai->ai_family;
+ } else {
+ VALUE timeout = Qnil;
+
+ if (!NIL_P(open_timeout)) {
+ VALUE elapsed = rb_funcall(current_clocktime(), '-', 1, starts_at);
+ timeout = rb_funcall(open_timeout, '-', 1, elapsed);
+
+ if (rb_funcall(timeout, '<', 1, INT2FIX(0)) == Qtrue) {
+ rsock_raise_user_specified_timeout(NULL, arg->remote.host, arg->remote.serv);
+ }
+ }
+ if (NIL_P(timeout)) {
+ if (!NIL_P(connect_timeout)) {
+ user_specified_connect_timeout_storage = rb_time_interval(connect_timeout);
+ user_specified_connect_timeout_at = &user_specified_connect_timeout_storage;
+ }
+ timeout =
+ (user_specified_connect_timeout_at && is_infinity(*user_specified_connect_timeout_at)) ?
+ Qnil : tv_to_seconds(user_specified_connect_timeout_at);
+ }
+
+ io = arg->io = rsock_init_sock(arg->self, fd);
+ status = rsock_connect(io, remote_ai->ai_addr, remote_ai->ai_addrlen, 0, timeout);
+ }
+
+ if (status == 0) {
+ connected_fd = fd;
+ break;
+ }
+
+ if (errno == EINPROGRESS) {
+ if (current_capacity == arg->connection_attempt_fds_size) {
+ current_capacity = reallocate_connection_attempt_fds(
+ &arg->connection_attempt_fds,
+ current_capacity,
+ additional_capacity
+ );
+ }
+ arg->connection_attempt_fds[arg->connection_attempt_fds_size] = fd;
+ (arg->connection_attempt_fds_size)++;
+
+ set_timeout_tv(&connection_attempt_delay_strage, 250, now);
+ connection_attempt_delay_expires_at = &connection_attempt_delay_strage;
+
+ if (!any_addrinfos(&resolution_store)) {
+ if (NIL_P(connect_timeout)) {
+ user_specified_connect_timeout_storage = (struct timeval){ -1, -1 };
+ } else {
+ struct timeval connect_timeout_tv = rb_time_interval(connect_timeout);
+ user_specified_connect_timeout_storage = add_ts_to_tv(connect_timeout_tv, now);
+ }
+ user_specified_connect_timeout_at = &user_specified_connect_timeout_storage;
+ }
+
+ break;
+ }
+
+ last_error.type = SYSCALL_ERROR;
+ last_error.ecode = errno;
+
+ if (NIL_P(io)) {
+ close(fd);
+ } else {
+ rb_io_close(io);
+ }
+
+ if (any_addrinfos(&resolution_store)) continue;
+ if (in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (!resolution_store.is_all_finished) break;
+
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+ }
+
+ if (connected_fd >= 0) break;
+
+ ends_at = select_expires_at(
+ &resolution_store,
+ resolution_delay_expires_at,
+ connection_attempt_delay_expires_at,
+ user_specified_resolv_timeout_at,
+ user_specified_connect_timeout_at,
+ user_specified_open_timeout_at
+ );
+ if (ends_at) {
+ delay = tv_to_timeout(ends_at, now);
+ delay_p = &delay;
+ } else {
+ if (((resolution_store.v6.finished && !resolution_store.v4.finished) ||
+ (resolution_store.v4.finished && !resolution_store.v6.finished)) &&
+ !any_addrinfos(&resolution_store) &&
+ !in_progress_fds(arg->connection_attempt_fds_size)) {
+ /* A limited timeout is introduced to prevent select(2) from hanging when it is exclusively
+ * waiting for name resolution and write(2) failure occurs in a child thread. */
+ delay.tv_sec = 0;
+ delay.tv_usec = 50000;
+ delay_p = &delay;
+ } else {
+ delay_p = NULL;
+ }
+ }
+
+ nfds = 0;
+ rb_fd_zero(&arg->writefds);
+ if (in_progress_fds(arg->connection_attempt_fds_size)) {
+ int n = 0;
+ for (int i = 0; i < arg->connection_attempt_fds_size; i++) {
+ int cfd = arg->connection_attempt_fds[i];
+ if (cfd < 0) continue;
+ if (cfd > n) n = cfd;
+ rb_fd_set(cfd, &arg->writefds);
+ }
+ if (n > 0) n++;
+ nfds = n;
+ }
+
+ rb_fd_zero(&arg->readfds);
+ if (arg->family_size > 1) {
+ rb_fd_set(hostname_resolution_waiter, &arg->readfds);
+
+ if ((hostname_resolution_waiter + 1) > nfds) {
+ nfds = hostname_resolution_waiter + 1;
+ }
+ }
+
+ status = rb_thread_fd_select(nfds, &arg->readfds, &arg->writefds, NULL, delay_p);
+
+ now = current_clocktime_ts();
+ if (is_timeout_tv(resolution_delay_expires_at, now)) {
+ resolution_delay_expires_at = NULL;
+ }
+ if (is_timeout_tv(connection_attempt_delay_expires_at, now)) {
+ connection_attempt_delay_expires_at = NULL;
+ }
+
+ if (status < 0 && (errno && errno != EINTR)) rb_syserr_fail(errno, "select(2)");
+
+ if (status > 0) {
+ /* check for connection */
+ if (in_progress_fds(arg->connection_attempt_fds_size)) {
+ for (int i = 0; i < arg->connection_attempt_fds_size; i++) {
+ int fd = arg->connection_attempt_fds[i];
+ if (fd < 0 || !rb_fd_isset(fd, &arg->writefds)) continue;
+
+ int err;
+ socklen_t len = sizeof(err);
+
+ status = getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &len);
+
+ if (status < 0) {
+ last_error.type = SYSCALL_ERROR;
+ last_error.ecode = errno;
+ close(fd);
+
+ if (any_addrinfos(&resolution_store)) continue;
+ if (in_progress_fds(arg->connection_attempt_fds_size)) break;
+ if (!resolution_store.is_all_finished) break;
+
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+
+ if (err == 0) { /* success */
+ remove_connection_attempt_fd(
+ arg->connection_attempt_fds,
+ &arg->connection_attempt_fds_size,
+ fd
+ );
+ connected_fd = fd;
+ break;
+ } else { /* fail */
+ close(fd);
+ remove_connection_attempt_fd(
+ arg->connection_attempt_fds,
+ &arg->connection_attempt_fds_size,
+ fd
+ );
+ last_error.type = SYSCALL_ERROR;
+ last_error.ecode = err;
+ }
+ }
+
+ if (connected_fd >= 0) break;
+
+ if (!in_progress_fds(arg->connection_attempt_fds_size)) {
+ if (!any_addrinfos(&resolution_store) && resolution_store.is_all_finished) {
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+ connection_attempt_delay_expires_at = NULL;
+ user_specified_connect_timeout_at = NULL;
+ }
+ }
+
+ /* check for hostname resolution */
+ if (!resolution_store.is_all_finished && rb_fd_isset(hostname_resolution_waiter, &arg->readfds)) {
+ while (true) {
+ resolved_type_size = read(
+ hostname_resolution_waiter,
+ resolved_type,
+ sizeof(resolved_type) - 1
+ );
+
+ if (resolved_type_size > 0) {
+ resolved_type[resolved_type_size] = '\0';
+
+ if (resolved_type[0] == IPV6_HOSTNAME_RESOLVED) {
+ resolution_store.v6.finished = true;
+
+ if (arg->getaddrinfo_entries[IPV6_ENTRY_POS]->err &&
+ arg->getaddrinfo_entries[IPV6_ENTRY_POS]->err != EAI_ADDRFAMILY) {
+ if (!resolution_store.v4.finished || resolution_store.v4.has_error) {
+ last_error.type = RESOLUTION_ERROR;
+ last_error.ecode = arg->getaddrinfo_entries[IPV6_ENTRY_POS]->err;
+ syscall = "getaddrinfo(3)";
+ }
+ resolution_store.v6.has_error = true;
+ } else {
+ resolution_store.v6.ai = arg->getaddrinfo_entries[IPV6_ENTRY_POS]->ai;
+ }
+ if (resolution_store.v4.finished) {
+ resolution_store.is_all_finished = true;
+ resolution_delay_expires_at = NULL;
+ user_specified_resolv_timeout_at = NULL;
+ break;
+ }
+ } else if (resolved_type[0] == IPV4_HOSTNAME_RESOLVED) {
+ resolution_store.v4.finished = true;
+
+ if (arg->getaddrinfo_entries[IPV4_ENTRY_POS]->err) {
+ if (!resolution_store.v6.finished || resolution_store.v6.has_error) {
+ last_error.type = RESOLUTION_ERROR;
+ last_error.ecode = arg->getaddrinfo_entries[IPV4_ENTRY_POS]->err;
+ syscall = "getaddrinfo(3)";
+ }
+ resolution_store.v4.has_error = true;
+ } else {
+ resolution_store.v4.ai = arg->getaddrinfo_entries[IPV4_ENTRY_POS]->ai;
+ }
+
+ if (resolution_store.v6.finished) {
+ resolution_store.is_all_finished = true;
+ resolution_delay_expires_at = NULL;
+ user_specified_resolv_timeout_at = NULL;
+ break;
+ }
+ } else {
+ /* Retry to read from hostname_resolution_waiter */
+ }
+ } else if (resolved_type_size < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
+ errno = 0;
+ break;
+ } else {
+ /* Retry to read from hostname_resolution_waiter */
+ }
+
+ if (!resolution_store.v6.finished &&
+ resolution_store.v4.finished &&
+ !resolution_store.v4.has_error) {
+ set_timeout_tv(&resolution_delay_storage, 50, now);
+ resolution_delay_expires_at = &resolution_delay_storage;
+ }
+ }
+ }
+
+ status = 0;
+ }
+
+ /* For cases where write(2) fails in child threads */
+ if (!resolution_store.is_all_finished) {
+ if (!resolution_store.v6.finished && arg->getaddrinfo_entries[IPV6_ENTRY_POS]->has_syserr) {
+ resolution_store.v6.finished = true;
+
+ if (arg->getaddrinfo_entries[IPV6_ENTRY_POS]->err) {
+ if (!resolution_store.v4.finished || resolution_store.v4.has_error) {
+ last_error.type = RESOLUTION_ERROR;
+ last_error.ecode = arg->getaddrinfo_entries[IPV6_ENTRY_POS]->err;
+ syscall = "getaddrinfo(3)";
+ }
+ resolution_store.v6.has_error = true;
+ } else {
+ resolution_store.v6.ai = arg->getaddrinfo_entries[IPV6_ENTRY_POS]->ai;
+ }
+
+ if (resolution_store.v4.finished) {
+ resolution_store.is_all_finished = true;
+ resolution_delay_expires_at = NULL;
+ user_specified_resolv_timeout_at = NULL;
+ }
+ }
+ if (!resolution_store.v4.finished && arg->getaddrinfo_entries[IPV4_ENTRY_POS]->has_syserr) {
+ resolution_store.v4.finished = true;
+
+ if (arg->getaddrinfo_entries[IPV4_ENTRY_POS]->err) {
+ if (!resolution_store.v6.finished || resolution_store.v6.has_error) {
+ last_error.type = RESOLUTION_ERROR;
+ last_error.ecode = arg->getaddrinfo_entries[IPV4_ENTRY_POS]->err;
+ syscall = "getaddrinfo(3)";
+ }
+ resolution_store.v4.has_error = true;
+ } else {
+ resolution_store.v4.ai = arg->getaddrinfo_entries[IPV4_ENTRY_POS]->ai;
+ }
+
+ if (resolution_store.v6.finished) {
+ resolution_store.is_all_finished = true;
+ resolution_delay_expires_at = NULL;
+ user_specified_resolv_timeout_at = NULL;
+ } else {
+ set_timeout_tv(&resolution_delay_storage, 50, now);
+ resolution_delay_expires_at = &resolution_delay_storage;
+ }
+ }
+ }
+
+ if (is_timeout_tv(user_specified_open_timeout_at, now)) {
+ rsock_raise_user_specified_timeout(NULL, arg->remote.host, arg->remote.serv);
+ }
+
+ if (!any_addrinfos(&resolution_store)) {
+ if (!in_progress_fds(arg->connection_attempt_fds_size) &&
+ resolution_store.is_all_finished) {
+ if (local_status < 0) {
+ host = arg->local.host;
+ serv = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ serv = arg->remote.serv;
+ }
+ if (last_error.type == RESOLUTION_ERROR) {
+ rsock_raise_resolution_error(syscall, last_error.ecode);
+ } else {
+ rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
+ }
+ }
+
+ if ((is_timeout_tv(user_specified_resolv_timeout_at, now) ||
+ resolution_store.is_all_finished) &&
+ (is_timeout_tv(user_specified_connect_timeout_at, now) ||
+ !in_progress_fds(arg->connection_attempt_fds_size))) {
+ rsock_raise_user_specified_timeout(NULL, arg->remote.host, arg->remote.serv);
+ }
+ }
+ }
+
+ if (NIL_P(arg->io)) {
+ /* create new instance */
+ arg->io = rsock_init_sock(arg->self, connected_fd);
+ }
+
+ return arg->io;
+}
+
+static VALUE
+fast_fallback_inetsock_cleanup(VALUE v)
+{
+ struct fast_fallback_inetsock_arg *arg = (void *)v;
+ struct fast_fallback_getaddrinfo_shared *getaddrinfo_shared = arg->getaddrinfo_shared;
+
+ if (arg->remote.res) {
+ rb_freeaddrinfo(arg->remote.res);
+ arg->remote.res = 0;
+ }
+ if (arg->local.res) {
+ rb_freeaddrinfo(arg->local.res);
+ arg->local.res = 0;
+ }
+
+ if (arg->wait != -1) close(arg->wait);
+
+ if (getaddrinfo_shared) {
+ if (getaddrinfo_shared->notify != -1) close(getaddrinfo_shared->notify);
+ getaddrinfo_shared->notify = -1;
+
+ int shared_need_free = 0;
+ struct addrinfo *ais[arg->family_size];
+ for (int i = 0; i < arg->family_size; i++) ais[i] = NULL;
+
+ rb_nativethread_lock_lock(&getaddrinfo_shared->lock);
+ {
+ for (int i = 0; i < arg->family_size; i++) {
+ struct fast_fallback_getaddrinfo_entry *getaddrinfo_entry = arg->getaddrinfo_entries[i];
+
+ if (!getaddrinfo_entry) continue;
+
+ if (--(getaddrinfo_entry->refcount) == 0) {
+ ais[i] = getaddrinfo_entry->ai;
+ getaddrinfo_entry->ai = NULL;
+ }
+ }
+ if (--(getaddrinfo_shared->refcount) == 0) {
+ shared_need_free = 1;
+ }
+ }
+ rb_nativethread_lock_unlock(&getaddrinfo_shared->lock);
+
+ for (int i = 0; i < arg->family_size; i++) {
+ if (ais[i]) freeaddrinfo(ais[i]);
+ }
+ if (getaddrinfo_shared && shared_need_free) {
+ free_fast_fallback_getaddrinfo_shared(&getaddrinfo_shared);
+ }
+ }
+
+ int connection_attempt_fd;
+
+ for (int i = 0; i < arg->connection_attempt_fds_size; i++) {
+ connection_attempt_fd = arg->connection_attempt_fds[i];
+
+ if (connection_attempt_fd >= 0) {
+ int error = 0;
+ socklen_t len = sizeof(error);
+ getsockopt(connection_attempt_fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ if (error == 0) shutdown(connection_attempt_fd, SHUT_RDWR);
+ close(connection_attempt_fd);
+ }
+ }
+
+ if (arg->readfds.fdset) rb_fd_term(&arg->readfds);
+ if (arg->writefds.fdset) rb_fd_term(&arg->writefds);
+
+ if (arg->connection_attempt_fds) {
+ free(arg->connection_attempt_fds);
+ arg->connection_attempt_fds = NULL;
+ }
+
+ return Qnil;
+}
+
+VALUE
+rsock_init_inetsock(
+ VALUE self, VALUE remote_host, VALUE remote_serv,
+ VALUE local_host, VALUE local_serv, int type,
+ VALUE resolv_timeout, VALUE connect_timeout, VALUE open_timeout,
+ VALUE fast_fallback, VALUE test_mode_settings)
+{
+ if (!NIL_P(open_timeout) && (!NIL_P(resolv_timeout) || !NIL_P(connect_timeout))) {
+ rb_raise(rb_eArgError, "Cannot specify open_timeout along with connect_timeout or resolv_timeout");
+ }
+
+ if (type == INET_CLIENT && FAST_FALLBACK_INIT_INETSOCK_IMPL == 1 && RTEST(fast_fallback)) {
+ struct rb_addrinfo *local_res = NULL;
+ char *hostp, *portp, *local_portp;
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV], local_pbuf[NI_MAXSERV];
+ int additional_flags = 0;
+ int local_flags = 0;
+ hostp = raddrinfo_host_str(remote_host, hbuf, sizeof(hbuf), &additional_flags);
+ portp = raddrinfo_port_str(remote_serv, pbuf, sizeof(pbuf), &additional_flags);
+ local_portp = raddrinfo_port_str(local_serv, local_pbuf, sizeof(local_pbuf), &local_flags);
+
+ if (!is_specified_ip_address(hostp) && !is_local_port_fixed(local_portp)) {
+ int target_families[2] = { 0, 0 };
+ int resolving_family_size = 0;
+
+ /*
+ * Maybe also accept a local address
+ */
+ if (!NIL_P(local_host) || !NIL_P(local_serv)) {
+ VALUE t = NIL_P(open_timeout) ? resolv_timeout : open_timeout;
+ local_res = rsock_addrinfo(
+ local_host,
+ local_serv,
+ AF_UNSPEC,
+ SOCK_STREAM,
+ 0,
+ t
+ );
+
+ struct addrinfo *tmp_p = local_res->ai;
+ for (; tmp_p != NULL; tmp_p = tmp_p->ai_next) {
+ if (target_families[0] == 0 && tmp_p->ai_family == AF_INET6) {
+ target_families[0] = AF_INET6;
+ resolving_family_size++;
+ }
+ if (target_families[1] == 0 && tmp_p->ai_family == AF_INET) {
+ target_families[1] = AF_INET;
+ resolving_family_size++;
+ }
+ }
+ } else {
+ resolving_family_size = 2;
+ target_families[0] = AF_INET6;
+ target_families[1] = AF_INET;
+ }
+
+ struct fast_fallback_inetsock_arg fast_fallback_arg;
+ memset(&fast_fallback_arg, 0, sizeof(fast_fallback_arg));
+
+ fast_fallback_arg.self = self;
+ fast_fallback_arg.io = Qnil;
+ fast_fallback_arg.remote.host = remote_host;
+ fast_fallback_arg.remote.serv = remote_serv;
+ fast_fallback_arg.remote.res = 0;
+ fast_fallback_arg.local.host = local_host;
+ fast_fallback_arg.local.serv = local_serv;
+ fast_fallback_arg.local.res = local_res;
+ fast_fallback_arg.type = type;
+ fast_fallback_arg.resolv_timeout = resolv_timeout;
+ fast_fallback_arg.connect_timeout = connect_timeout;
+ fast_fallback_arg.open_timeout = open_timeout;
+ fast_fallback_arg.hostp = hostp;
+ fast_fallback_arg.portp = portp;
+ fast_fallback_arg.additional_flags = additional_flags;
+
+ int resolving_families[resolving_family_size];
+ int resolving_family_index = 0;
+ for (int i = 0; 2 > i; i++) {
+ if (target_families[i] != 0) {
+ resolving_families[resolving_family_index] = target_families[i];
+ resolving_family_index++;
+ }
+ }
+ fast_fallback_arg.families = resolving_families;
+ fast_fallback_arg.family_size = resolving_family_size;
+ fast_fallback_arg.test_mode_settings = test_mode_settings;
+
+ rb_fd_init(&fast_fallback_arg.readfds);
+ rb_fd_init(&fast_fallback_arg.writefds);
+
+ return rb_ensure(init_fast_fallback_inetsock_internal, (VALUE)&fast_fallback_arg,
+ fast_fallback_inetsock_cleanup, (VALUE)&fast_fallback_arg);
+ }
+ }
+
+ struct inetsock_arg arg;
+ arg.self = self;
+ arg.io = Qnil;
+ arg.remote.host = remote_host;
+ arg.remote.serv = remote_serv;
+ arg.remote.res = 0;
+ arg.local.host = local_host;
+ arg.local.serv = local_serv;
+ arg.local.res = 0;
+ arg.type = type;
+ arg.resolv_timeout = resolv_timeout;
+ arg.connect_timeout = connect_timeout;
+ arg.open_timeout = open_timeout;
+
+ return rb_ensure(init_inetsock_internal, (VALUE)&arg,
+ inetsock_cleanup, (VALUE)&arg);
+}
+
+#endif
+
static ID id_numeric, id_hostname;
int
@@ -274,16 +1517,13 @@ ip_inspect(VALUE sock)
static VALUE
ip_addr(int argc, VALUE *argv, VALUE sock)
{
- rb_io_t *fptr;
union_sockaddr addr;
socklen_t len = (socklen_t)sizeof addr;
int norevlookup;
- GetOpenFile(sock, fptr);
-
if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup))
- norevlookup = fptr->mode & FMODE_NOREVLOOKUP;
- if (getsockname(fptr->fd, &addr.addr, &len) < 0)
+ norevlookup = rb_io_mode(sock) & FMODE_NOREVLOOKUP;
+ if (getsockname(rb_io_descriptor(sock), &addr.addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return rsock_ipaddr(&addr.addr, len, norevlookup);
}
@@ -315,16 +1555,13 @@ ip_addr(int argc, VALUE *argv, VALUE sock)
static VALUE
ip_peeraddr(int argc, VALUE *argv, VALUE sock)
{
- rb_io_t *fptr;
union_sockaddr addr;
socklen_t len = (socklen_t)sizeof addr;
int norevlookup;
- GetOpenFile(sock, fptr);
-
if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup))
- norevlookup = fptr->mode & FMODE_NOREVLOOKUP;
- if (getpeername(fptr->fd, &addr.addr, &len) < 0)
+ norevlookup = rb_io_mode(sock) & FMODE_NOREVLOOKUP;
+ if (getpeername(rb_io_descriptor(sock), &addr.addr, &len) < 0)
rb_sys_fail("getpeername(2)");
return rsock_ipaddr(&addr.addr, len, norevlookup);
}
@@ -372,7 +1609,7 @@ static VALUE
ip_s_getaddress(VALUE obj, VALUE host)
{
union_sockaddr addr;
- struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, 0);
+ struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, 0, Qnil);
socklen_t len = res->ai->ai_addrlen;
/* just take the first one */
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index eecdc7d4b8..465b74964f 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -62,7 +62,7 @@ class Addrinfo
break
when :wait_writable
sock.wait_writable(timeout) or
- raise Errno::ETIMEDOUT, 'user specified timeout'
+ raise Errno::ETIMEDOUT, "user specified timeout for #{self.ip_address}:#{self.ip_port}"
end while true
else
sock.connect(self)
@@ -333,9 +333,10 @@ class BasicSocket < IO
# _flags_ is zero or more of the +MSG_+ options.
# The result, _mesg_, is the data received.
#
- # When recvfrom(2) returns 0, Socket#recv_nonblock returns
- # an empty string as data.
- # The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but for UDP connections
+ # it may mean an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the number of bytes to receive from the socket
@@ -480,9 +481,10 @@ class Socket < BasicSocket
# The second element, _sender_addrinfo_, contains protocol-specific address
# information of the sender.
#
- # When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns
- # an empty string as data.
- # The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but for UDP connections
+ # it may mean an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the maximum number of bytes to receive from the socket
@@ -597,19 +599,54 @@ class Socket < BasicSocket
__accept_nonblock(exception)
end
+ # :stopdoc:
+ RESOLUTION_DELAY = 0.05
+ private_constant :RESOLUTION_DELAY
+
+ CONNECTION_ATTEMPT_DELAY = 0.25
+ private_constant :CONNECTION_ATTEMPT_DELAY
+
+ ADDRESS_FAMILIES = {
+ ipv6: Socket::AF_INET6,
+ ipv4: Socket::AF_INET
+ }.freeze
+ private_constant :ADDRESS_FAMILIES
+
+ HOSTNAME_RESOLUTION_QUEUE_UPDATED = 0
+ private_constant :HOSTNAME_RESOLUTION_QUEUE_UPDATED
+
+ IPV6_ADDRESS_FORMAT = /\A(?i:(?:(?:[0-9A-F]{1,4}:){7}(?:[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){6}(?:[0-9A-F]{1,4}|:(?:[0-9A-F]{1,4}:){1,5}[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){5}(?:(?::[0-9A-F]{1,4}){1,2}|:(?:[0-9A-F]{1,4}:){1,4}[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){4}(?:(?::[0-9A-F]{1,4}){1,3}|:(?:[0-9A-F]{1,4}:){1,3}[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){3}(?:(?::[0-9A-F]{1,4}){1,4}|:(?:[0-9A-F]{1,4}:){1,2}[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){2}(?:(?::[0-9A-F]{1,4}){1,5}|:(?:[0-9A-F]{1,4}:)[0-9A-F]{1,4}|:)|(?:[0-9A-F]{1,4}:){1}(?:(?::[0-9A-F]{1,4}){1,6}|:(?:[0-9A-F]{1,4}:){0,5}[0-9A-F]{1,4}|:)|(?:::(?:[0-9A-F]{1,4}:){0,7}[0-9A-F]{1,4}|::)))(?:%.+)?\z/
+ private_constant :IPV6_ADDRESS_FORMAT
+ # :startdoc:
+
# :call-seq:
# Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) {|socket| ... }
# Socket.tcp(host, port, local_host=nil, local_port=nil, [opts])
#
# creates a new socket object connected to host:port using TCP/IP.
#
+ # Starting from Ruby 3.4, this method operates according to the
+ # Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305])
+ # algorithm by default.
+ #
+ # For details on Happy Eyeballs Version 2,
+ # see {Socket.tcp_fast_fallback=}[rdoc-ref:Socket.tcp_fast_fallback=].
+ #
+ # To make it behave the same as in Ruby 3.3 and earlier,
+ # explicitly specify the option fast_fallback:false.
+ # Or, setting Socket.tcp_fast_fallback=false will disable
+ # Happy Eyeballs Version 2 not only for this method but for all Socket globally.
+ #
# If local_host:local_port is given,
# the socket is bound to it.
#
# The optional last argument _opts_ is options represented by a hash.
# _opts_ may have following options:
#
- # [:connect_timeout] specify the timeout in seconds.
+ # [:resolv_timeout] Specifies the timeout in seconds from when the hostname resolution starts.
+ # [:connect_timeout] This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled.
+ # [:open_timeout] Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.<br>If this option is specified together with other timeout options, an +ArgumentError+ will be raised.
+ # [:fast_fallback] Enables the Happy Eyeballs Version 2 algorithm (enabled by default).
#
# If a block is given, the block is called with the socket.
# The value of the block is returned.
@@ -622,17 +659,292 @@ class Socket < BasicSocket
# sock.close_write
# puts sock.read
# }
- #
- def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil) # :yield: socket
+ def self.tcp(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, open_timeout: nil, fast_fallback: tcp_fast_fallback, &) # :yield: socket
+ if open_timeout && (connect_timeout || resolv_timeout)
+ raise ArgumentError, "Cannot specify open_timeout along with connect_timeout or resolv_timeout"
+ end
+
+ sock = if fast_fallback && !(host && ip_address?(host)) && !(local_port && local_port.to_i != 0)
+ tcp_with_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, open_timeout:)
+ else
+ tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, open_timeout:)
+ end
+
+ if block_given?
+ begin
+ yield sock
+ ensure
+ sock.close
+ end
+ else
+ sock
+ end
+ end
+
+ # :stopdoc:
+ def self.tcp_with_fast_fallback(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, open_timeout: nil)
+ if local_host || local_port
+ local_addrinfos = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, timeout: open_timeout || resolv_timeout)
+ resolving_family_names = local_addrinfos.map { |lai| ADDRESS_FAMILIES.key(lai.afamily) }.uniq
+ else
+ local_addrinfos = []
+ resolving_family_names = ADDRESS_FAMILIES.keys
+ end
+
+ hostname_resolution_threads = []
+ resolution_store = HostnameResolutionStore.new(resolving_family_names)
+ connecting_sockets = {}
+ is_windows_environment ||= (RUBY_PLATFORM =~ /mswin|mingw|cygwin/)
+
+ now = current_clock_time
+ starts_at = now
+ resolution_delay_expires_at = nil
+ connection_attempt_delay_expires_at = nil
+ user_specified_connect_timeout_at = nil
+ user_specified_open_timeout_at = open_timeout ? now + open_timeout : nil
+ last_error = nil
+ last_error_from_thread = false
+
+ if resolving_family_names.size == 1
+ family_name = resolving_family_names.first
+ addrinfos = Addrinfo.getaddrinfo(host, port, ADDRESS_FAMILIES[:family_name], :STREAM, timeout: open_timeout || resolv_timeout)
+ resolution_store.add_resolved(family_name, addrinfos)
+ hostname_resolution_result = nil
+ hostname_resolution_notifier = nil
+ user_specified_resolv_timeout_at = nil
+ else
+ hostname_resolution_result = HostnameResolutionResult.new(resolving_family_names.size)
+ hostname_resolution_notifier = hostname_resolution_result.notifier
+
+ hostname_resolution_threads.concat(
+ resolving_family_names.map { |family|
+ thread_args = [family, host, port, hostname_resolution_result]
+ thread = Thread.new(*thread_args) { |*thread_args| resolve_hostname(*thread_args) }
+ Thread.pass
+ thread
+ }
+ )
+ user_specified_resolv_timeout_at = resolv_timeout ? now + resolv_timeout : Float::INFINITY
+ end
+
+ loop do
+ if resolution_store.any_addrinfos? &&
+ !resolution_delay_expires_at &&
+ !connection_attempt_delay_expires_at
+ while (addrinfo = resolution_store.get_addrinfo)
+ if local_addrinfos.any?
+ local_addrinfo = local_addrinfos.find { |lai| lai.afamily == addrinfo.afamily }
+
+ if local_addrinfo.nil?
+ if resolution_store.any_addrinfos?
+ # Try other Addrinfo in next "while"
+ next
+ elsif connecting_sockets.any? || resolution_store.any_unresolved_family?
+ # Exit this "while" and wait for connections to be established or hostname resolution in next loop
+ # Or exit this "while" and wait for hostname resolution in next loop
+ break
+ else
+ raise SocketError.new 'no appropriate local address'
+ end
+ end
+ end
+
+ begin
+ if resolution_store.any_addrinfos? ||
+ connecting_sockets.any? ||
+ resolution_store.any_unresolved_family?
+ socket = Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol)
+ socket.bind(local_addrinfo) if local_addrinfo
+ result = socket.connect_nonblock(addrinfo, exception: false)
+ else
+ timeout =
+ if open_timeout
+ t = open_timeout - (current_clock_time - starts_at)
+ t.negative? ? 0 : t
+ else
+ connect_timeout
+ end
+ result = socket = local_addrinfo ?
+ addrinfo.connect_from(local_addrinfo, timeout:) :
+ addrinfo.connect(timeout:)
+ end
+
+ if result == :wait_writable
+ connection_attempt_delay_expires_at = now + CONNECTION_ATTEMPT_DELAY
+ if resolution_store.empty_addrinfos?
+ user_specified_connect_timeout_at = connect_timeout ? now + connect_timeout : Float::INFINITY
+ end
+
+ connecting_sockets[socket] = addrinfo
+ break
+ else
+ return socket # connection established
+ end
+ rescue SystemCallError => e
+ socket&.close
+ last_error = e
+
+ if resolution_store.any_addrinfos?
+ # Try other Addrinfo in next "while"
+ next
+ elsif connecting_sockets.any? || resolution_store.any_unresolved_family?
+ # Exit this "while" and wait for connections to be established or hostname resolution in next loop
+ # Or exit this "while" and wait for hostname resolution in next loop
+ break
+ else
+ raise last_error
+ end
+ end
+ end
+ end
+
+ ends_at =
+ if resolution_store.any_addrinfos?
+ [(resolution_delay_expires_at || connection_attempt_delay_expires_at),
+ user_specified_open_timeout_at].compact.min
+ elsif user_specified_open_timeout_at
+ user_specified_open_timeout_at
+ else
+ [user_specified_resolv_timeout_at, user_specified_connect_timeout_at].compact.max
+ end
+
+ hostname_resolved, writable_sockets, except_sockets = IO.select(
+ hostname_resolution_notifier,
+ connecting_sockets.keys,
+ # Use errorfds to wait for non-blocking connect failures on Windows
+ is_windows_environment ? connecting_sockets.keys : nil,
+ second_to_timeout(current_clock_time, ends_at),
+ )
+ now = current_clock_time
+ resolution_delay_expires_at = nil if expired?(now, resolution_delay_expires_at)
+ connection_attempt_delay_expires_at = nil if expired?(now, connection_attempt_delay_expires_at)
+
+ if writable_sockets&.any?
+ while (writable_socket = writable_sockets.pop)
+ is_connected = is_windows_environment || (
+ sockopt = writable_socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
+ sockopt.int.zero?
+ )
+
+ if is_connected
+ connecting_sockets.delete writable_socket
+ return writable_socket
+ else
+ failed_ai = connecting_sockets.delete writable_socket
+ writable_socket.close
+ ip_address = failed_ai.ipv6? ? "[#{failed_ai.ip_address}]" : failed_ai.ip_address
+ last_error = SystemCallError.new("connect(2) for #{ip_address}:#{failed_ai.ip_port}", sockopt.int)
+
+ if writable_sockets.any? || connecting_sockets.any?
+ # Try other writable socket in next "while"
+ # Or exit this "while" and wait for connections to be established or hostname resolution in next loop
+ elsif resolution_store.any_addrinfos? || resolution_store.any_unresolved_family?
+ # Exit this "while" and try other connection attempt
+ # Or exit this "while" and wait for hostname resolution in next loop
+ connection_attempt_delay_expires_at = nil
+ user_specified_connect_timeout_at = nil
+ else
+ raise last_error
+ end
+ end
+ end
+ end
+
+ if except_sockets&.any?
+ except_sockets.each do |except_socket|
+ failed_ai = connecting_sockets.delete except_socket
+ sockopt = except_socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
+ except_socket.close
+ ip_address = failed_ai.ipv6? ? "[#{failed_ai.ip_address}]" : failed_ai.ip_address
+ last_error = SystemCallError.new("connect(2) for #{ip_address}:#{failed_ai.ip_port}", sockopt.int)
+
+ if except_sockets.any? || connecting_sockets.any?
+ # Cleanup other except socket in next "each"
+ # Or exit this "while" and wait for connections to be established or hostname resolution in next loop
+ elsif resolution_store.any_addrinfos? || resolution_store.any_unresolved_family?
+ # Exit this "while" and try other connection attempt
+ # Or exit this "while" and wait for hostname resolution in next loop
+ connection_attempt_delay_expires_at = nil
+ user_specified_connect_timeout_at = nil
+ else
+ raise last_error
+ end
+ end
+ end
+
+ if hostname_resolved&.any?
+ while (family_and_result = hostname_resolution_result.get)
+ family_name, result = family_and_result
+
+ if result.is_a? Exception
+ resolution_store.add_error(family_name, result)
+
+ unless (Socket.const_defined?(:EAI_ADDRFAMILY)) &&
+ (result.is_a?(Socket::ResolutionError)) &&
+ (result.error_code == Socket::EAI_ADDRFAMILY)
+ other = family_name == :ipv6 ? :ipv4 : :ipv6
+ if !resolution_store.resolved?(other) || !resolution_store.resolved_successfully?(other)
+ last_error = result
+ last_error_from_thread = true
+ end
+ end
+ else
+ resolution_store.add_resolved(family_name, result)
+ end
+ end
+
+ if resolution_store.resolved?(:ipv4)
+ if resolution_store.resolved?(:ipv6)
+ hostname_resolution_notifier = nil
+ resolution_delay_expires_at = nil
+ user_specified_resolv_timeout_at = nil
+ elsif resolution_store.resolved_successfully?(:ipv4)
+ resolution_delay_expires_at = now + RESOLUTION_DELAY
+ end
+ end
+ end
+
+ if expired?(now, user_specified_open_timeout_at)
+ raise(IO::TimeoutError, "user specified timeout for #{host}:#{port}")
+ end
+
+ if resolution_store.empty_addrinfos?
+ if connecting_sockets.empty? && resolution_store.resolved_all_families?
+ if last_error_from_thread
+ raise last_error.class, last_error.message, cause: last_error
+ else
+ raise last_error
+ end
+ end
+
+ if (expired?(now, user_specified_resolv_timeout_at) || resolution_store.resolved_all_families?) &&
+ (expired?(now, user_specified_connect_timeout_at) || connecting_sockets.empty?)
+ raise(IO::TimeoutError, "user specified timeout for #{host}:#{port}")
+ end
+ end
+ end
+ ensure
+ hostname_resolution_threads.each(&:exit).each(&:join)
+
+ hostname_resolution_result&.close
+
+ connecting_sockets.each_key(&:close)
+ end
+ private_class_method :tcp_with_fast_fallback
+
+ def self.tcp_without_fast_fallback(host, port, local_host, local_port, connect_timeout:, resolv_timeout:, open_timeout:)
last_error = nil
ret = nil
local_addr_list = nil
if local_host != nil || local_port != nil
- local_addr_list = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil)
+ local_addr_list = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil, timeout: open_timeout || resolv_timeout)
end
- Addrinfo.foreach(host, port, nil, :STREAM, timeout: resolv_timeout) {|ai|
+ timeout = open_timeout ? open_timeout : resolv_timeout
+ starts_at = current_clock_time
+
+ Addrinfo.foreach(host, port, nil, :STREAM, timeout:) {|ai|
if local_addr_list
local_addr = local_addr_list.find {|local_ai| local_ai.afamily == ai.afamily }
next unless local_addr
@@ -640,9 +952,17 @@ class Socket < BasicSocket
local_addr = nil
end
begin
+ timeout =
+ if open_timeout
+ t = open_timeout - (current_clock_time - starts_at)
+ t.negative? ? 0 : t
+ else
+ connect_timeout
+ end
+
sock = local_addr ?
- ai.connect_from(local_addr, timeout: connect_timeout) :
- ai.connect(timeout: connect_timeout)
+ ai.connect_from(local_addr, timeout:) :
+ ai.connect(timeout:)
rescue SystemCallError
last_error = $!
next
@@ -657,18 +977,150 @@ class Socket < BasicSocket
raise SocketError, "no appropriate local address"
end
end
- if block_given?
- begin
- yield ret
- ensure
- ret.close
+
+ ret
+ end
+ private_class_method :tcp_without_fast_fallback
+
+ def self.ip_address?(hostname)
+ hostname.match?(IPV6_ADDRESS_FORMAT) || hostname.match?(/\A([0-9]{1,3}\.){3}[0-9]{1,3}\z/)
+ end
+ private_class_method :ip_address?
+
+ def self.resolve_hostname(family, host, port, hostname_resolution_result)
+ begin
+ resolved_addrinfos = Addrinfo.getaddrinfo(host, port, ADDRESS_FAMILIES[family], :STREAM)
+ hostname_resolution_result.add(family, resolved_addrinfos)
+ rescue => e
+ hostname_resolution_result.add(family, e)
+ end
+ end
+ private_class_method :resolve_hostname
+
+ def self.current_clock_time
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ end
+ private_class_method :current_clock_time
+
+ def self.second_to_timeout(started_at, ends_at)
+ return nil if ends_at == Float::INFINITY || ends_at.nil?
+
+ remaining = (ends_at - started_at)
+ remaining.negative? ? 0 : remaining
+ end
+ private_class_method :second_to_timeout
+
+ def self.expired?(started_at, ends_at)
+ second_to_timeout(started_at, ends_at)&.zero?
+ end
+ private_class_method :expired?
+
+ class HostnameResolutionResult
+ def initialize(size)
+ @size = size
+ @taken_count = 0
+ @rpipe, @wpipe = IO.pipe
+ @results = []
+ @mutex = Mutex.new
+ end
+
+ def notifier
+ [@rpipe]
+ end
+
+ def add(family, result)
+ @mutex.synchronize do
+ @results.push [family, result]
+ @wpipe.putc HOSTNAME_RESOLUTION_QUEUE_UPDATED
end
- else
- ret
+ end
+
+ def get
+ return nil if @results.empty?
+
+ res = nil
+
+ @mutex.synchronize do
+ @rpipe.getbyte
+ res = @results.shift
+ end
+
+ @taken_count += 1
+ close if @taken_count == @size
+ res
+ end
+
+ def close
+ @rpipe.close
+ @wpipe.close
end
end
+ private_constant :HostnameResolutionResult
+
+ class HostnameResolutionStore
+ PRIORITY_ON_V6 = [:ipv6, :ipv4].freeze
+ PRIORITY_ON_V4 = [:ipv4, :ipv6].freeze
+
+ def initialize(family_names)
+ @family_names = family_names
+ @addrinfo_dict = {}
+ @error_dict = {}
+ @last_family = nil
+ end
+
+ def add_resolved(family_name, addrinfos)
+ @addrinfo_dict[family_name] = addrinfos
+ end
+
+ def add_error(family_name, error)
+ @addrinfo_dict[family_name] = []
+ @error_dict[family_name] = error
+ end
+
+ def get_addrinfo
+ precedences =
+ case @last_family
+ when :ipv4, nil then PRIORITY_ON_V6
+ when :ipv6 then PRIORITY_ON_V4
+ end
+
+ precedences.each do |family_name|
+ addrinfo = @addrinfo_dict[family_name]&.shift
+ next unless addrinfo
+
+ @last_family = family_name
+ return addrinfo
+ end
+
+ nil
+ end
+
+ def empty_addrinfos?
+ @addrinfo_dict.all? { |_, addrinfos| addrinfos.empty? }
+ end
+
+ def any_addrinfos?
+ !empty_addrinfos?
+ end
+
+ def resolved?(family)
+ @addrinfo_dict.has_key? family
+ end
+
+ def resolved_successfully?(family)
+ resolved?(family) && !@error_dict[family]
+ end
+
+ def resolved_all_families?
+ (@family_names - @addrinfo_dict.keys).empty?
+ end
+
+ def any_unresolved_family?
+ !resolved_all_families?
+ end
+ end
+ private_constant :HostnameResolutionStore
- # :stopdoc:
def self.ip_sockets_port0(ai_list, reuseaddr)
sockets = []
begin
@@ -701,9 +1153,7 @@ class Socket < BasicSocket
end
sockets
end
- class << self
- private :ip_sockets_port0
- end
+ private_class_method :ip_sockets_port0
def self.tcp_server_sockets_port0(host)
ai_list = Addrinfo.getaddrinfo(host, 0, nil, :STREAM, nil, Socket::AI_PASSIVE)
@@ -1131,13 +1581,18 @@ class Socket < BasicSocket
end
end
- class << self
- private
-
- def unix_socket_abstract_name?(path)
- /linux/ =~ RUBY_PLATFORM && /\A(\0|\z)/ =~ path
+ # :stopdoc:
+ if RUBY_PLATFORM.include?("linux")
+ def self.unix_socket_abstract_name?(path)
+ path.empty? or path.start_with?("\0")
+ end
+ else
+ def self.unix_socket_abstract_name?(path)
+ false
end
end
+ private_class_method :unix_socket_abstract_name?
+ # :startdoc:
# creates a UNIX socket server on _path_.
# It calls the block for each socket accepted.
@@ -1177,7 +1632,7 @@ class Socket < BasicSocket
# Returns 0 if successful, otherwise an exception is raised.
#
# === Parameter
- # # +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
+ # * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
#
# === Example:
# # Pull down Google's web page
@@ -1212,7 +1667,7 @@ class Socket < BasicSocket
# return the symbol +:wait_writable+ instead.
#
# === See
- # # Socket#connect
+ # * Socket#connect
def connect_nonblock(addr, exception: true)
__connect_nonblock(addr, exception)
end
@@ -1229,9 +1684,10 @@ class UDPSocket < IPSocket
# The first element of the results, _mesg_, is the data received.
# The second element, _sender_inet_addr_, is an array to represent the sender address.
#
- # When recvfrom(2) returns 0,
- # Socket#recvfrom_nonblock returns an empty string as data.
- # It means an empty packet.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but it may also mean
+ # an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the number of bytes to receive from the socket
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 5e6c0668f6..4271e40cd8 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -51,7 +51,10 @@ DATA.each_line {|s|
next
end
h[name] = default_value
- COMMENTS[name] = comment
+ if comment
+ # Stop unintentional references
+ COMMENTS[name] = comment.gsub(/\b(Data|Kernel|Process|Set|Socket|Time)\b/, '\\\\\\&')
+ end
}
DEFS = h.to_a
@@ -73,15 +76,11 @@ def each_name(pat)
}
end
-erb_new = lambda do |src, safe, trim|
- if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
- ERB.new(src, trim_mode: trim)
- else
- ERB.new(src, safe, trim)
- end
+erb_new = lambda do |src, trim|
+ ERB.new(src, trim_mode: trim)
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_decls")
% each_const {|guard, name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -95,7 +94,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
#if defined(<%=name%>)
/* <%= COMMENTS[name] %> */
rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2NUM(<%=name%>));
@@ -104,7 +103,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name
#endif
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs")
% each_const {|guard, name, default_value|
% if guard
#if <%=guard%>
@@ -154,7 +153,7 @@ def each_names_with_len(pat, prefix_optional=nil)
}
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
int <%=funcname%>(const char *str, long len, int *valp);
@@ -164,7 +163,7 @@ int <%=funcname%>(const char *str, long len, int *valp);
%end
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
int
<%=funcname%>(const char *str, long len, int *valp)
{
@@ -186,7 +185,7 @@ int
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
%if guard
#ifdef <%=guard%>
<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
@@ -215,7 +214,7 @@ def reverse_each_name_with_prefix_optional(pat, prefix_pat)
end
end
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
<%=hash_var%> = st_init_numtable();
% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
#ifdef <%=n%>
@@ -224,7 +223,7 @@ erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_va
% }
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
ID
<%=func_name%>(int val)
{
@@ -235,7 +234,7 @@ ID
}
EOS
-erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
+erb_new.call(<<'EOS', '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
ID <%=func_name%>(int val);
EOS
@@ -284,7 +283,7 @@ def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
-result = erb_new.call(<<'EOS', nil, '%').result(binding)
+result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
@@ -327,7 +326,7 @@ init_constants(void)
EOS
-header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
+header_result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
@@ -423,8 +422,8 @@ AF_ISDN nil Integrated Services Digital Network
PF_ISDN nil Integrated Services Digital Network
AF_NATM nil Native ATM access
PF_NATM nil Native ATM access
-AF_SYSTEM
-PF_SYSTEM
+AF_SYSTEM nil Kernel event messages
+PF_SYSTEM nil Kernel event messages
AF_NETBIOS nil NetBIOS
PF_NETBIOS nil NetBIOS
AF_PPP nil Point-to-Point Protocol
@@ -440,8 +439,8 @@ PF_PACKET nil Direct link-layer access
AF_E164 nil CCITT (ITU-T) E.164 recommendation
PF_XTP nil eXpress Transfer Protocol
-PF_RTIP
-PF_PIP
+PF_RTIP nil Help Identify RTIP packets
+PF_PIP nil Help Identify PIP packets
AF_KEY nil Key management protocol, originally developed for usage with IPsec
PF_KEY nil Key management protocol, originally developed for usage with IPsec
AF_NETLINK nil Kernel user interface device
@@ -666,6 +665,7 @@ SO_SETFIB nil Set the associated routing table for the socket (FreeBSD
SO_RTABLE nil Set the routing table for this socket (OpenBSD)
SO_INCOMING_CPU nil Receive the cpu attached to the socket (Linux 3.19)
SO_INCOMING_NAPI_ID nil Receive the napi ID attached to a RX queue (Linux 4.12)
+SO_CONNECT_TIME nil Returns the number of seconds a socket has been connected. This option is only valid for connection-oriented protocols (Windows)
SOPRI_INTERACTIVE nil Interactive socket priority
SOPRI_NORMAL nil Normal socket priority
@@ -745,6 +745,7 @@ SHUT_RDWR 2 Shut down the both sides of the socket
IPV6_JOIN_GROUP nil Join a group membership
IPV6_LEAVE_GROUP nil Leave a group membership
+IPV6_MTU_DISCOVER nil Path MTU discovery
IPV6_MULTICAST_HOPS nil IP6 multicast hops
IPV6_MULTICAST_IF nil IP6 multicast interface
IPV6_MULTICAST_LOOP nil IP6 multicast loopback
@@ -759,6 +760,7 @@ IPV6_NEXTHOP nil Next hop address
IPV6_PATHMTU nil Retrieve current path MTU
IPV6_PKTINFO nil Receive packet information with datagram
IPV6_RECVDSTOPTS nil Receive all IP6 options for response
+IPV6_RECVERR nil Enable extended reliable error message passing
IPV6_RECVHOPLIMIT nil Receive hop limit with datagram
IPV6_RECVHOPOPTS nil Receive hop-by-hop options
IPV6_RECVPKTINFO nil Receive destination IP address and incoming interface
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 269edc4dad..f1fbcc35de 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -10,6 +10,22 @@
#include "rubysocket.h"
+// GETADDRINFO_IMPL == 0 : call getaddrinfo/getnameinfo directly
+// GETADDRINFO_IMPL == 1 : call getaddrinfo/getnameinfo without gvl (but uncancellable)
+// GETADDRINFO_IMPL == 2 : call getaddrinfo/getnameinfo in a dedicated pthread
+// (and if the call is interrupted, the pthread is detached)
+
+#ifndef GETADDRINFO_IMPL
+# ifdef GETADDRINFO_EMU
+# define GETADDRINFO_IMPL 0
+# elif !defined(HAVE_PTHREAD_CREATE) || !defined(HAVE_PTHREAD_DETACH) || defined(__MINGW32__) || defined(__MINGW64__)
+# define GETADDRINFO_IMPL 1
+# else
+# define GETADDRINFO_IMPL 2
+# include "ruby/thread_native.h"
+# endif
+#endif
+
#if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET6))
#define LOOKUP_ORDERS (sizeof(lookup_order_table) / sizeof(lookup_order_table[0]))
static const int lookup_order_table[] = {
@@ -173,32 +189,6 @@ parse_numeric_port(const char *service, int *portp)
}
#endif
-#ifndef GETADDRINFO_EMU
-struct getaddrinfo_arg
-{
- const char *node;
- const char *service;
- const struct addrinfo *hints;
- struct addrinfo **res;
-};
-
-static void *
-nogvl_getaddrinfo(void *arg)
-{
- int ret;
- struct getaddrinfo_arg *ptr = arg;
- ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
-#ifdef __linux__
- /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
- * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
- */
- if (ret == EAI_SYSTEM && errno == ENOENT)
- ret = EAI_NONAME;
-#endif
- return (void *)(VALUE)ret;
-}
-#endif
-
static int
numeric_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
@@ -287,8 +277,9 @@ numeric_getaddrinfo(const char *node, const char *service,
void
rb_freeaddrinfo(struct rb_addrinfo *ai)
{
- if (!ai->allocated_by_malloc)
- freeaddrinfo(ai->ai);
+ if (!ai->allocated_by_malloc) {
+ if (ai->ai) freeaddrinfo(ai->ai);
+ }
else {
struct addrinfo *ai1, *ai2;
ai1 = ai->ai;
@@ -302,7 +293,349 @@ rb_freeaddrinfo(struct rb_addrinfo *ai)
xfree(ai);
}
-#ifndef GETADDRINFO_EMU
+static int
+rsock_value_timeout_to_msec(VALUE timeout)
+{
+ double seconds = NUM2DBL(timeout);
+ if (seconds < 0) rb_raise(rb_eArgError, "timeout must not be negative");
+
+ double msec = seconds * 1000.0;
+ if (msec > UINT_MAX) rb_raise(rb_eArgError, "timeout too large");
+
+ return (unsigned int)(msec + 0.5);
+}
+
+#if GETADDRINFO_IMPL == 0
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai, int _timeout)
+{
+ return getaddrinfo(hostp, portp, hints, ai);
+}
+
+#elif GETADDRINFO_IMPL == 1
+
+struct getaddrinfo_arg
+{
+ const char *node;
+ const char *service;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+};
+
+static void *
+nogvl_getaddrinfo(void *arg)
+{
+ int ret;
+ struct getaddrinfo_arg *ptr = arg;
+ ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
+#ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (ret == EAI_SYSTEM && errno == ENOENT)
+ ret = EAI_NONAME;
+#endif
+ return (void *)(VALUE)ret;
+}
+
+static void *
+fork_safe_getaddrinfo(void *arg)
+{
+ return rb_thread_prevent_fork(nogvl_getaddrinfo, arg);
+}
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai, int _timeout)
+{
+ struct getaddrinfo_arg arg;
+ MEMZERO(&arg, struct getaddrinfo_arg, 1);
+ arg.node = hostp;
+ arg.service = portp;
+ arg.hints = hints;
+ arg.res = ai;
+ return (int)(VALUE)rb_thread_call_without_gvl(fork_safe_getaddrinfo, &arg, RUBY_UBF_IO, 0);
+}
+
+#elif GETADDRINFO_IMPL == 2
+
+struct getaddrinfo_arg
+{
+ char *node, *service;
+ struct addrinfo hints;
+ struct addrinfo *ai;
+ int err, gai_errno, refcount, done, cancelled, timedout;
+ rb_nativethread_lock_t lock;
+ rb_nativethread_cond_t cond;
+ int timeout;
+};
+
+static struct getaddrinfo_arg *
+allocate_getaddrinfo_arg(const char *hostp, const char *portp, const struct addrinfo *hints, int timeout)
+{
+ size_t hostp_offset = sizeof(struct getaddrinfo_arg);
+ size_t portp_offset = hostp_offset + (hostp ? strlen(hostp) + 1 : 0);
+ size_t bufsize = portp_offset + (portp ? strlen(portp) + 1 : 0);
+
+ char *buf = malloc(bufsize);
+ if (!buf) {
+ rb_gc();
+ buf = malloc(bufsize);
+ if (!buf) return NULL;
+ }
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)buf;
+
+ if (hostp) {
+ arg->node = buf + hostp_offset;
+ memcpy(arg->node, hostp, portp_offset - hostp_offset);
+ }
+ else {
+ arg->node = NULL;
+ }
+
+ if (portp) {
+ arg->service = buf + portp_offset;
+ memcpy(arg->service, portp, bufsize - portp_offset);
+ }
+ else {
+ arg->service = NULL;
+ }
+
+ arg->hints = *hints;
+ arg->ai = NULL;
+
+ arg->refcount = 2;
+ arg->done = arg->cancelled = arg->timedout = 0;
+ arg->timeout = timeout;
+
+ rb_nativethread_lock_initialize(&arg->lock);
+ rb_native_cond_initialize(&arg->cond);
+
+ return arg;
+}
+
+static void
+free_getaddrinfo_arg(struct getaddrinfo_arg *arg)
+{
+ rb_native_cond_destroy(&arg->cond);
+ rb_nativethread_lock_destroy(&arg->lock);
+ free(arg);
+}
+
+static void *
+do_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+
+ int err, gai_errno;
+ err = getaddrinfo(arg->node, arg->service, &arg->hints, &arg->ai);
+ gai_errno = errno;
+#ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (err == EAI_SYSTEM && errno == ENOENT)
+ err = EAI_NONAME;
+#endif
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ arg->err = err;
+ arg->gai_errno = gai_errno;
+ if (arg->cancelled) {
+ if (arg->ai) freeaddrinfo(arg->ai);
+ }
+ else {
+ arg->done = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getaddrinfo_arg(arg);
+
+ return 0;
+}
+
+static void *
+wait_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ while (!arg->done && !arg->cancelled) {
+ long msec = arg->timeout;
+ if (msec == 0) {
+ arg->cancelled = 1;
+ arg->timedout = 1;
+ } else if (msec > 0) {
+ rb_native_cond_timedwait(&arg->cond, &arg->lock, msec);
+ if (!arg->done) {
+ arg->cancelled = 1;
+ arg->timedout = 1;
+ }
+ } else {
+ rb_native_cond_wait(&arg->cond, &arg->lock);
+ }
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+ return 0;
+}
+
+static void
+cancel_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ arg->cancelled = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+}
+
+int
+raddrinfo_pthread_create(pthread_t *th, void *(*start_routine) (void *), void *arg)
+{
+ int limit = 3, ret;
+ int saved_errno;
+#ifdef HAVE_PTHREAD_ATTR_SETDETACHSTATE
+ pthread_attr_t attr;
+ pthread_attr_t *attr_p = &attr;
+ int err;
+ int init_retries = 0;
+ int init_retries_max = 3;
+retry_attr_init:
+ if ((err = pthread_attr_init(attr_p)) != 0) {
+ if (err == ENOMEM && init_retries < init_retries_max) {
+ init_retries++;
+ rb_gc();
+ goto retry_attr_init;
+ }
+ return err;
+ }
+ if ((err = pthread_attr_setdetachstate(attr_p, PTHREAD_CREATE_DETACHED)) != 0) {
+ saved_errno = errno;
+ pthread_attr_destroy(attr_p);
+ errno = saved_errno;
+ return err; // EINVAL - shouldn't happen
+ }
+#else
+ pthread_attr_t *attr_p = NULL;
+#endif
+ do {
+ // It is said that pthread_create may fail spuriously, so we follow the JDK and retry several times.
+ //
+ // https://bugs.openjdk.org/browse/JDK-8268605
+ // https://github.com/openjdk/jdk/commit/e35005d5ce383ddd108096a3079b17cb0bcf76f1
+ ret = pthread_create(th, attr_p, start_routine, arg);
+ } while (ret == EAGAIN && limit-- > 0);
+#ifdef HAVE_PTHREAD_ATTR_SETDETACHSTATE
+ saved_errno = errno;
+ pthread_attr_destroy(attr_p);
+ if (ret != 0) {
+ errno = saved_errno;
+ }
+#else
+ if (ret == 0) {
+ pthread_detach(th); // this can race with shutdown routine of thread in some glibc versions
+ }
+#endif
+ return ret;
+}
+
+static void *
+fork_safe_do_getaddrinfo(void *ptr)
+{
+ return rb_thread_prevent_fork(do_getaddrinfo, ptr);
+}
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai, int timeout)
+{
+ int retry;
+ struct getaddrinfo_arg *arg;
+ int err = 0, gai_errno = 0, timedout = 0;
+
+start:
+ retry = 0;
+
+ arg = allocate_getaddrinfo_arg(hostp, portp, hints, timeout);
+ if (!arg) {
+ return EAI_MEMORY;
+ }
+
+ pthread_t th;
+ if (raddrinfo_pthread_create(&th, fork_safe_do_getaddrinfo, arg) != 0) {
+ int err = errno;
+ free_getaddrinfo_arg(arg);
+ errno = err;
+ return EAI_SYSTEM;
+ }
+
+ rb_thread_call_without_gvl2(wait_getaddrinfo, arg, cancel_getaddrinfo, arg);
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ if (arg->done) {
+ err = arg->err;
+ gai_errno = arg->gai_errno;
+ if (err == 0) *ai = arg->ai;
+ }
+ else if (arg->cancelled) {
+ retry = 1;
+ timedout = arg->timedout;
+ }
+ else {
+ // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getaddrinfo.
+ // In this case, it could be !arg->done && !arg->cancelled.
+ arg->cancelled = 1; // to make do_getaddrinfo call freeaddrinfo
+ retry = 1;
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getaddrinfo_arg(arg);
+
+ if (timedout) {
+ VALUE host = rb_str_new_cstr(hostp);
+ VALUE port = rb_str_new_cstr(portp);
+ rsock_raise_user_specified_timeout(NULL, host, port);
+ }
+
+ // If the current thread is interrupted by asynchronous exception, the following raises the exception.
+ // But if the current thread is interrupted by timer thread, the following returns; we need to manually retry.
+ rb_thread_check_ints();
+ if (retry) goto start;
+
+ /* Because errno is threadlocal, the errno value we got from the call to getaddrinfo() in the thread
+ * (in case of EAI_SYSTEM return value) is not propagated to the caller of _this_ function. Set errno
+ * explicitly, as round-tripped through struct getaddrinfo_arg, to deal with that */
+ if (gai_errno) errno = gai_errno;
+ return err;
+}
+
+#endif
+
+#define GETNAMEINFO_WONT_BLOCK(host, serv, flags) \
+ ((!(host) || ((flags) & NI_NUMERICHOST)) && \
+ (!(serv) || ((flags) & NI_NUMERICSERV)))
+
+#if GETADDRINFO_IMPL == 0
+
+int
+rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+ return getnameinfo(sa, salen, host, (socklen_t)hostlen, serv, (socklen_t)servlen, flags);
+}
+
+#elif GETADDRINFO_IMPL == 1
+
struct getnameinfo_arg
{
const struct sockaddr *sa;
@@ -323,16 +656,15 @@ nogvl_getnameinfo(void *arg)
ptr->serv, (socklen_t)ptr->servlen,
ptr->flags);
}
-#endif
-
int
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
- char *host, size_t hostlen,
- char *serv, size_t servlen, int flags)
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
{
-#ifdef GETADDRINFO_EMU
- return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
-#else
+ if (GETNAMEINFO_WONT_BLOCK(host, serv, flags)) {
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+ }
+
struct getnameinfo_arg arg;
int ret;
arg.sa = sa;
@@ -344,17 +676,190 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
arg.flags = flags;
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
return ret;
-#endif
+}
+
+#elif GETADDRINFO_IMPL == 2
+
+struct getnameinfo_arg
+{
+ struct sockaddr *sa;
+ socklen_t salen;
+ int flags;
+ char *host;
+ size_t hostlen;
+ char *serv;
+ size_t servlen;
+ int err, gni_errno, refcount, done, cancelled;
+ rb_nativethread_lock_t lock;
+ rb_nativethread_cond_t cond;
+};
+
+static struct getnameinfo_arg *
+allocate_getnameinfo_arg(const struct sockaddr *sa, socklen_t salen, size_t hostlen, size_t servlen, int flags)
+{
+ size_t sa_offset = sizeof(struct getnameinfo_arg);
+ size_t host_offset = sa_offset + salen;
+ size_t serv_offset = host_offset + hostlen;
+ size_t bufsize = serv_offset + servlen;
+
+ char *buf = malloc(bufsize);
+ if (!buf) {
+ rb_gc();
+ buf = malloc(bufsize);
+ if (!buf) return NULL;
+ }
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)buf;
+
+ arg->sa = (struct sockaddr *)(buf + sa_offset);
+ memcpy(arg->sa, sa, salen);
+ arg->salen = salen;
+ arg->host = buf + host_offset;
+ arg->hostlen = hostlen;
+ arg->serv = buf + serv_offset;
+ arg->servlen = servlen;
+ arg->flags = flags;
+
+ arg->refcount = 2;
+ arg->done = arg->cancelled = 0;
+
+ rb_nativethread_lock_initialize(&arg->lock);
+ rb_native_cond_initialize(&arg->cond);
+
+ return arg;
}
static void
+free_getnameinfo_arg(struct getnameinfo_arg *arg)
+{
+ rb_native_cond_destroy(&arg->cond);
+ rb_nativethread_lock_destroy(&arg->lock);
+
+ free(arg);
+}
+
+static void *
+do_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+
+ int err, gni_errno;
+ err = getnameinfo(arg->sa, arg->salen, arg->host, (socklen_t)arg->hostlen, arg->serv, (socklen_t)arg->servlen, arg->flags);
+ gni_errno = errno;
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ arg->err = err;
+ arg->gni_errno = gni_errno;
+ if (!arg->cancelled) {
+ arg->done = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getnameinfo_arg(arg);
+
+ return 0;
+}
+
+static void *
+wait_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ while (!arg->done && !arg->cancelled) {
+ rb_native_cond_wait(&arg->cond, &arg->lock);
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+ return 0;
+}
+
+static void
+cancel_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ arg->cancelled = 1;
+ rb_native_cond_signal(&arg->cond);
+ rb_nativethread_lock_unlock(&arg->lock);
+}
+
+int
+rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+ int retry;
+ struct getnameinfo_arg *arg;
+ int err = 0, gni_errno = 0;
+
+ if (GETNAMEINFO_WONT_BLOCK(host, serv, flags)) {
+ return getnameinfo(sa, salen, host, (socklen_t)hostlen, serv, (socklen_t)servlen, flags);
+ }
+
+start:
+ retry = 0;
+
+ arg = allocate_getnameinfo_arg(sa, salen, hostlen, servlen, flags);
+ if (!arg) {
+ return EAI_MEMORY;
+ }
+
+ pthread_t th;
+ if (raddrinfo_pthread_create(&th, do_getnameinfo, arg) != 0) {
+ int err = errno;
+ free_getnameinfo_arg(arg);
+ errno = err;
+ return EAI_SYSTEM;
+ }
+
+ rb_thread_call_without_gvl2(wait_getnameinfo, arg, cancel_getnameinfo, arg);
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ if (arg->done) {
+ err = arg->err;
+ gni_errno = arg->gni_errno;
+ if (err == 0) {
+ if (host) memcpy(host, arg->host, hostlen);
+ if (serv) memcpy(serv, arg->serv, servlen);
+ }
+ }
+ else if (arg->cancelled) {
+ retry = 1;
+ }
+ else {
+ // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getnameinfo.
+ // In this case, it could be !arg->done && !arg->cancelled.
+ arg->cancelled = 1;
+ retry = 1;
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getnameinfo_arg(arg);
+
+ // If the current thread is interrupted by asynchronous exception, the following raises the exception.
+ // But if the current thread is interrupted by timer thread, the following returns; we need to manually retry.
+ rb_thread_check_ints();
+ if (retry) goto start;
+
+ /* Make sure we copy the thread-local errno value from the getnameinfo thread back to this thread, so
+ * calling code sees the correct errno */
+ if (gni_errno) errno = gni_errno;
+ return err;
+}
+
+#endif
+
+static void
make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
{
int error;
error = rb_getnameinfo(addr, addrlen, buf, buflen, NULL, 0, NI_NUMERICHOST);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
}
@@ -396,8 +901,8 @@ str_is_number(const char *p)
((ptr)[0] == name[0] && \
rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0)
-static char*
-host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
+char*
+raddrinfo_host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
{
if (NIL_P(host)) {
return NULL;
@@ -435,8 +940,8 @@ host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
}
}
-static char*
-port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
+char*
+raddrinfo_port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
{
if (NIL_P(port)) {
return 0;
@@ -488,7 +993,7 @@ rb_scheduler_getaddrinfo(VALUE scheduler, VALUE host, const char *service,
for(i=0; i<len; i++) {
ip_address = rb_ary_entry(ip_addresses_array, i);
- hostp = host_str(ip_address, _hbuf, sizeof(_hbuf), &_additional_flags);
+ hostp = raddrinfo_host_str(ip_address, _hbuf, sizeof(_hbuf), &_additional_flags);
error = numeric_getaddrinfo(hostp, service, hints, &ai);
if (error == 0) {
if (!res_allocated) {
@@ -515,7 +1020,7 @@ rb_scheduler_getaddrinfo(VALUE scheduler, VALUE host, const char *service,
}
struct rb_addrinfo*
-rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
+rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack, VALUE timeout)
{
struct rb_addrinfo* res = NULL;
struct addrinfo *ai;
@@ -524,8 +1029,8 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int additional_flags = 0;
- hostp = host_str(host, hbuf, sizeof(hbuf), &additional_flags);
- portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
+ hostp = raddrinfo_host_str(host, hbuf, sizeof(hbuf), &additional_flags);
+ portp = raddrinfo_port_str(port, pbuf, sizeof(pbuf), &additional_flags);
if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
hints->ai_socktype = SOCK_DGRAM;
@@ -550,17 +1055,8 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
}
if (!resolved) {
-#ifdef GETADDRINFO_EMU
- error = getaddrinfo(hostp, portp, hints, &ai);
-#else
- struct getaddrinfo_arg arg;
- MEMZERO(&arg, struct getaddrinfo_arg, 1);
- arg.node = hostp;
- arg.service = portp;
- arg.hints = hints;
- arg.res = &ai;
- error = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
-#endif
+ int t = NIL_P(timeout) ? -1 : rsock_value_timeout_to_msec(timeout);
+ error = rb_getaddrinfo(hostp, portp, hints, &ai, t);
if (error == 0) {
res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo));
res->allocated_by_malloc = 0;
@@ -573,7 +1069,7 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
}
- rsock_raise_socket_error("getaddrinfo", error);
+ rsock_raise_resolution_error("getaddrinfo", error);
}
return res;
@@ -593,7 +1089,7 @@ rsock_fd_family(int fd)
}
struct rb_addrinfo*
-rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags)
+rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags, VALUE timeout)
{
struct addrinfo hints;
@@ -601,7 +1097,7 @@ rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags)
hints.ai_family = family;
hints.ai_socktype = socktype;
hints.ai_flags = flags;
- return rsock_getaddrinfo(host, port, &hints, 1);
+ return rsock_getaddrinfo(host, port, &hints, 1, timeout);
}
VALUE
@@ -632,7 +1128,7 @@ rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
addr2 = rb_str_new2(hbuf);
if (addr1 == Qnil) {
@@ -721,7 +1217,7 @@ make_hostent_internal(VALUE v)
hostp = addr->ai_canonname;
}
else {
- hostp = host_str(host, hbuf, sizeof(hbuf), NULL);
+ hostp = raddrinfo_host_str(host, hbuf, sizeof(hbuf), NULL);
}
rb_ary_push(ary, rb_str_new2(hostp));
@@ -795,6 +1291,7 @@ addrinfo_memsize(const void *ptr)
static const rb_data_type_t addrinfo_type = {
"socket/addrinfo",
{addrinfo_mark, addrinfo_free, addrinfo_memsize,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -832,7 +1329,7 @@ alloc_addrinfo(void)
}
static void
-init_addrinfo(rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len,
+init_addrinfo(VALUE self, rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len,
int pfamily, int socktype, int protocol,
VALUE canonname, VALUE inspectname)
{
@@ -844,8 +1341,8 @@ init_addrinfo(rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len,
rai->pfamily = pfamily;
rai->socktype = socktype;
rai->protocol = protocol;
- rai->canonname = canonname;
- rai->inspectname = inspectname;
+ RB_OBJ_WRITE(self, &rai->canonname, canonname);
+ RB_OBJ_WRITE(self, &rai->inspectname, inspectname);
}
VALUE
@@ -858,7 +1355,7 @@ rsock_addrinfo_new(struct sockaddr *addr, socklen_t len,
a = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(a) = rai = alloc_addrinfo();
- init_addrinfo(rai, addr, len, family, socktype, protocol, canonname, inspectname);
+ init_addrinfo(a, rai, addr, len, family, socktype, protocol, canonname, inspectname);
return a;
}
@@ -883,7 +1380,7 @@ call_getaddrinfo(VALUE node, VALUE service,
hints.ai_flags = NUM2INT(flags);
}
- res = rsock_getaddrinfo(node, service, &hints, socktype_hack);
+ res = rsock_getaddrinfo(node, service, &hints, socktype_hack, timeout);
if (res == NULL)
rb_raise(rb_eSocket, "host not found");
@@ -893,7 +1390,7 @@ call_getaddrinfo(VALUE node, VALUE service,
static VALUE make_inspectname(VALUE node, VALUE service, struct addrinfo *res);
static void
-init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
+init_addrinfo_getaddrinfo(VALUE self, rb_addrinfo_t *rai, VALUE node, VALUE service,
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
VALUE inspectnode, VALUE inspectservice)
{
@@ -907,7 +1404,7 @@ init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
OBJ_FREEZE(canonname);
}
- init_addrinfo(rai, res->ai->ai_addr, res->ai->ai_addrlen,
+ init_addrinfo(self, rai, res->ai->ai_addr, res->ai->ai_addrlen,
NUM2INT(family), NUM2INT(socktype), NUM2INT(protocol),
canonname, inspectname);
@@ -1019,7 +1516,7 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE
#ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
static void
-init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
+init_unix_addrinfo(VALUE self, rb_addrinfo_t *rai, VALUE path, int socktype)
{
struct sockaddr_un un;
socklen_t len;
@@ -1035,7 +1532,7 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
len = rsock_unix_sockaddr_len(path);
- init_addrinfo(rai, (struct sockaddr *)&un, len,
+ init_addrinfo(self, rai, (struct sockaddr *)&un, len,
PF_UNIX, socktype, 0, Qnil, Qnil);
}
@@ -1139,7 +1636,7 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
flags |= AI_NUMERICSERV;
#endif
- init_addrinfo_getaddrinfo(rai, numericnode, service,
+ init_addrinfo_getaddrinfo(self, rai, numericnode, service,
INT2NUM(i_pfamily ? i_pfamily : af), INT2NUM(i_socktype), INT2NUM(i_protocol),
INT2NUM(flags),
nodename, service);
@@ -1151,7 +1648,7 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE path = rb_ary_entry(sockaddr_ary, 1);
StringValue(path);
- init_unix_addrinfo(rai, path, SOCK_STREAM);
+ init_unix_addrinfo(self, rai, path, SOCK_STREAM);
break;
}
#endif
@@ -1164,7 +1661,7 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
StringValue(sockaddr_arg);
sockaddr_ptr = (struct sockaddr *)RSTRING_PTR(sockaddr_arg);
sockaddr_len = RSTRING_SOCKLEN(sockaddr_arg);
- init_addrinfo(rai, sockaddr_ptr, sockaddr_len,
+ init_addrinfo(self, rai, sockaddr_ptr, sockaddr_len,
i_pfamily, i_socktype, i_protocol,
canonname, inspectname);
}
@@ -1266,11 +1763,11 @@ rsock_inspect_sockaddr(struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE r
* RFC 4007: IPv6 Scoped Address Architecture
* draft-ietf-ipv6-scope-api-00.txt: Scoped Address Extensions to the IPv6 Basic Socket API
*/
- error = getnameinfo(&sockaddr->addr, socklen,
- hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
- NI_NUMERICHOST|NI_NUMERICSERV);
+ error = rb_getnameinfo(&sockaddr->addr, socklen,
+ hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
if (addr->sin6_port == 0) {
rb_str_cat2(ret, hbuf);
@@ -1634,11 +2131,11 @@ addrinfo_mdump(VALUE self)
{
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int error;
- error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
- hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ error = rb_getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf));
break;
@@ -1753,7 +2250,7 @@ addrinfo_mload(VALUE self, VALUE ary)
}
DATA_PTR(self) = rai = alloc_addrinfo();
- init_addrinfo(rai, &ss.addr, len,
+ init_addrinfo(self, rai, &ss.addr, len,
pfamily, socktype, protocol,
canonname, inspectname);
return self;
@@ -1980,11 +2477,11 @@ addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
if (rai->socktype == SOCK_DGRAM)
flags |= NI_DGRAM;
- error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
- hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
- flags);
+ error = rb_getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ flags);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
@@ -2521,7 +3018,7 @@ addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
addr = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(addr) = rai = alloc_addrinfo();
- init_unix_addrinfo(rai, path, socktype);
+ init_unix_addrinfo(self, rai, path, socktype);
return addr;
}
@@ -2608,18 +3105,111 @@ rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
UNREACHABLE_RETURN(Qnil);
}
+#if FAST_FALLBACK_INIT_INETSOCK_IMPL == 1
+
+void
+free_fast_fallback_getaddrinfo_shared(struct fast_fallback_getaddrinfo_shared **shared)
+{
+ xfree((*shared)->node);
+ (*shared)->node = NULL;
+ xfree((*shared)->service);
+ (*shared)->service = NULL;
+ rb_nativethread_lock_destroy(&(*shared)->lock);
+ free(*shared);
+ *shared = NULL;
+}
+
+static void *
+do_fast_fallback_getaddrinfo(void *ptr)
+{
+ struct fast_fallback_getaddrinfo_entry *entry = (struct fast_fallback_getaddrinfo_entry *)ptr;
+ struct fast_fallback_getaddrinfo_shared *shared = entry->shared;
+ int err = 0, shared_need_free = 0;
+ struct addrinfo *ai = NULL;
+
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &set, NULL);
+
+ err = numeric_getaddrinfo(shared->node, shared->service, &entry->hints, &entry->ai);
+
+ if (err != 0) {
+ err = getaddrinfo(shared->node, shared->service, &entry->hints, &entry->ai);
+ #ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (err == EAI_SYSTEM && errno == ENOENT)
+ err = EAI_NONAME;
+ #endif
+ }
+
+ /* for testing HEv2 */
+ if (entry->test_sleep_ms > 0) {
+ struct timespec sleep_ts;
+ sleep_ts.tv_sec = entry->test_sleep_ms / 1000;
+ sleep_ts.tv_nsec = (entry->test_sleep_ms % 1000) * 1000000L;
+ if (sleep_ts.tv_nsec >= 1000000000L) {
+ sleep_ts.tv_sec += sleep_ts.tv_nsec / 1000000000L;
+ sleep_ts.tv_nsec = sleep_ts.tv_nsec % 1000000000L;
+ }
+ nanosleep(&sleep_ts, NULL);
+ }
+ if (entry->test_ecode != 0) {
+ err = entry->test_ecode;
+ if (entry->ai) {
+ freeaddrinfo(entry->ai);
+ entry->ai = NULL;
+ }
+ }
+
+ rb_nativethread_lock_lock(&shared->lock);
+ {
+ entry->err = err;
+ const char notification = entry->family == AF_INET6 ?
+ IPV6_HOSTNAME_RESOLVED : IPV4_HOSTNAME_RESOLVED;
+
+ if (shared->notify != -1 && (write(shared->notify, &notification, 1)) < 0) {
+ entry->err = errno;
+ entry->has_syserr = true;
+ }
+ if (--(entry->refcount) == 0) {
+ ai = entry->ai;
+ entry->ai = NULL;
+ }
+ if (--(shared->refcount) == 0) shared_need_free = 1;
+ }
+ rb_nativethread_lock_unlock(&shared->lock);
+
+ if (ai) freeaddrinfo(ai);
+ if (shared_need_free && shared) {
+ free_fast_fallback_getaddrinfo_shared(&shared);
+ }
+
+ return 0;
+}
+
+void *
+fork_safe_do_fast_fallback_getaddrinfo(void *ptr)
+{
+ return rb_thread_prevent_fork(do_fast_fallback_getaddrinfo, ptr);
+}
+
+#endif
+
/*
* Addrinfo class
*/
void
rsock_init_addrinfo(void)
{
+ id_timeout = rb_intern("timeout");
+
/*
* The Addrinfo class maps <tt>struct addrinfo</tt> to ruby. This
* structure identifies an Internet host and a service.
*/
- id_timeout = rb_intern("timeout");
-
rb_cAddrinfo = rb_define_class("Addrinfo", rb_cObject);
rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 5f803ba0da..2ec3ab335a 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -35,6 +35,7 @@
#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
+# include <mswsock.h>
# include <iphlpapi.h>
# if defined(_MSC_VER)
# undef HAVE_TYPE_STRUCT_SOCKADDR_DL
@@ -137,6 +138,7 @@
#include "internal.h"
#include "internal/array.h"
+#include "internal/compilers.h"
#include "internal/error.h"
#include "internal/gc.h"
#include "internal/io.h"
@@ -285,19 +287,18 @@ extern VALUE rb_cAddrinfo;
extern VALUE rb_cSockOpt;
extern VALUE rb_eSocket;
+extern VALUE rb_eResolution;
#ifdef SOCKS
extern VALUE rb_cSOCKSSocket;
# ifndef SOCKS5
-void SOCKSinit();
-int Rconnect();
+void SOCKSinit(char *);
+int Rconnect(int, const struct sockaddr *, socklen_t);
# endif
#endif
#include "constdefs.h"
-#define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
-
#define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
#define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
#define SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
@@ -307,7 +308,7 @@ VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret
VALUE rb_check_sockaddr_string_type(VALUE);
-NORETURN(void rsock_raise_socket_error(const char *, int));
+NORETURN(void rsock_raise_resolution_error(const char *, int));
int rsock_family_arg(VALUE domain);
int rsock_socktype_arg(VALUE type);
@@ -326,8 +327,8 @@ void rb_freeaddrinfo(struct rb_addrinfo *ai);
VALUE rsock_freeaddrinfo(VALUE arg);
int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
int rsock_fd_family(int fd);
-struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags);
-struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
+struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags, VALUE timeout);
+struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack, VALUE timeout);
VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
@@ -354,7 +355,7 @@ int rsock_socket(int domain, int type, int proto);
int rsock_detect_cloexec(int fd);
VALUE rsock_init_sock(VALUE sock, int fd);
VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass);
-VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type, VALUE resolv_timeout, VALUE connect_timeout);
+VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type, VALUE resolv_timeout, VALUE connect_timeout, VALUE open_timeout, VALUE fast_fallback, VALUE test_mode_settings);
VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server);
struct rsock_send_arg {
@@ -379,7 +380,7 @@ VALUE rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
VALUE ex, enum sock_recv_type from);
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
-int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks, struct timeval *timeout);
+int rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, VALUE timeout);
VALUE rsock_s_accept(VALUE klass, VALUE io, struct sockaddr *sockaddr, socklen_t *len);
VALUE rsock_s_accept_nonblock(VALUE klass, VALUE ex, rb_io_t *fptr,
@@ -413,6 +414,47 @@ ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
#endif
+char *raddrinfo_host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr);
+char *raddrinfo_port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr);
+
+#ifndef FAST_FALLBACK_INIT_INETSOCK_IMPL
+# if !defined(HAVE_PTHREAD_CREATE) || !defined(HAVE_PTHREAD_DETACH) || defined(__MINGW32__) || defined(__MINGW64__)
+# define FAST_FALLBACK_INIT_INETSOCK_IMPL 0
+# else
+# include "ruby/thread_native.h"
+# define FAST_FALLBACK_INIT_INETSOCK_IMPL 1
+# define IPV6_HOSTNAME_RESOLVED '1'
+# define IPV4_HOSTNAME_RESOLVED '2'
+# define SELECT_CANCELLED '3'
+
+struct fast_fallback_getaddrinfo_entry
+{
+ int family, err, refcount;
+ struct addrinfo hints;
+ struct addrinfo *ai;
+ struct fast_fallback_getaddrinfo_shared *shared;
+ int has_syserr;
+ long test_sleep_ms;
+ int test_ecode;
+};
+
+struct fast_fallback_getaddrinfo_shared
+{
+ int notify, refcount;
+ char *node, *service;
+ rb_nativethread_lock_t lock;
+ struct fast_fallback_getaddrinfo_entry getaddrinfo_entries[FLEX_ARY_LEN];
+};
+
+int raddrinfo_pthread_create(pthread_t *th, void *(*start_routine) (void *), void *arg);
+void *fork_safe_do_fast_fallback_getaddrinfo(void *ptr);
+void free_fast_fallback_getaddrinfo_entry(struct fast_fallback_getaddrinfo_entry **entry);
+void free_fast_fallback_getaddrinfo_shared(struct fast_fallback_getaddrinfo_shared **shared);
+# endif
+#endif
+
+NORETURN(void rsock_raise_user_specified_timeout(struct addrinfo *ai, VALUE host, VALUE port));
+
void rsock_init_basicsocket(void);
void rsock_init_ipsocket(void);
void rsock_init_tcpsocket(void);
@@ -459,12 +501,14 @@ VALUE rsock_write_nonblock(VALUE sock, VALUE buf, VALUE ex);
void rsock_make_fd_nonblock(int fd);
+int rsock_is_dgram(rb_io_t *fptr);
+
+extern ID tcp_fast_fallback;
+
#if !defined HAVE_INET_NTOP && ! defined _WIN32
const char *inet_ntop(int, const void *, char *, size_t);
#elif defined __MINGW32__
# define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
-#elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
-const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
#endif
#endif
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index eb74f7a936..a8e5ae8119 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -14,6 +14,8 @@ static VALUE sym_wait_writable;
static VALUE sock_s_unpack_sockaddr_in(VALUE, VALUE);
+ID tcp_fast_fallback;
+
void
rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
{
@@ -387,22 +389,20 @@ rsock_sock_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(VALUE self, VALUE addr)
{
VALUE rai;
- rb_io_t *fptr;
- int fd, n;
SockAddrStringValueWithAddrinfo(addr, rai);
addr = rb_str_new4(addr);
- GetOpenFile(sock, fptr);
- fd = fptr->fd;
- n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0, NULL);
- if (n < 0) {
+
+ int result = rsock_connect(self, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0, RUBY_IO_TIMEOUT_DEFAULT);
+
+ if (result < 0) {
rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
}
- return INT2FIX(n);
+ return INT2FIX(result);
}
/* :nodoc: */
@@ -965,7 +965,7 @@ sock_s_gethostbyname(VALUE obj, VALUE host)
{
rb_warn("Socket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead.");
struct rb_addrinfo *res =
- rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME);
+ rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME, Qnil);
return rsock_make_hostent(host, res, sock_sockaddr);
}
@@ -1183,7 +1183,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv, VALUE _)
norevlookup = rsock_do_not_reverse_lookup;
}
- res = rsock_getaddrinfo(host, port, &hints, 0);
+ res = rsock_getaddrinfo(host, port, &hints, 0, Qnil);
ret = make_addrinfo(res, norevlookup);
rb_freeaddrinfo(res);
@@ -1279,7 +1279,7 @@ sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM;
/* af */
hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af);
- res = rsock_getaddrinfo(host, port, &hints, 0);
+ res = rsock_getaddrinfo(host, port, &hints, 0, Qnil);
sap = res->ai->ai_addr;
salen = res->ai->ai_addrlen;
}
@@ -1313,7 +1313,7 @@ sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
saved_errno = errno;
if (res) rb_freeaddrinfo(res);
errno = saved_errno;
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
UNREACHABLE_RETURN(Qnil);
}
@@ -1335,7 +1335,7 @@ sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
static VALUE
sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
{
- struct rb_addrinfo *res = rsock_addrinfo(host, port, AF_UNSPEC, 0, 0);
+ struct rb_addrinfo *res = rsock_addrinfo(host, port, AF_UNSPEC, 0, 0, Qnil);
VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen);
rb_freeaddrinfo(res);
@@ -1654,8 +1654,7 @@ socket_s_ip_address_list(VALUE self)
finish:
save_errno = errno;
- if (lc.lifc_buf != NULL)
- xfree(lc.lifc_req);
+ xfree(lc.lifc_req);
if (fd != -1)
close(fd);
errno = save_errno;
@@ -1857,6 +1856,67 @@ socket_s_ip_address_list(VALUE self)
#define socket_s_ip_address_list rb_f_notimplement
#endif
+/*
+ * call-seq:
+ * Socket.tcp_fast_fallback -> true or false
+ *
+ * Returns whether Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305]),
+ * which is provided starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp,
+ * is enabled or disabled.
+ *
+ * If true, it is enabled for TCPSocket.new and Socket.tcp.
+ * (Note: Happy Eyeballs Version 2 is not provided when using TCPSocket.new on Windows.)
+ *
+ * If false, Happy Eyeballs Version 2 is disabled.
+ *
+ * For details on Happy Eyeballs Version 2,
+ * see {Socket.tcp_fast_fallback=}[rdoc-ref:Socket.tcp_fast_fallback=].
+ */
+VALUE socket_s_tcp_fast_fallback(VALUE self) {
+ return rb_ivar_get(rb_cSocket, tcp_fast_fallback);
+}
+
+/*
+ * call-seq:
+ * Socket.tcp_fast_fallback= -> true or false
+ *
+ * Enable or disable Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305])
+ * globally, which is provided starting from Ruby 3.4 when using TCPSocket.new and Socket.tcp.
+ *
+ * When set to true, the feature is enabled for both `TCPSocket.new` and `Socket.tcp`.
+ * (Note: This feature is not available when using TCPSocket.new on Windows.)
+ *
+ * When set to false, the behavior reverts to that of Ruby 3.3 or earlier.
+ *
+ * The default value is true if no value is explicitly set by calling this method.
+ * However, when the environment variable RUBY_TCP_NO_FAST_FALLBACK=1 is set,
+ * the default is false.
+ *
+ * To control the setting on a per-method basis, use the fast_fallback keyword argument for each method.
+ *
+ * === Happy Eyeballs Version 2
+ * Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305])
+ * is an algorithm designed to improve client socket connectivity.<br>
+ * It aims for more reliable and efficient connections by performing hostname resolution
+ * and connection attempts in parallel, instead of serially.
+ *
+ * Starting from Ruby 3.4, this method operates as follows with this algorithm:
+ *
+ * 1. Start resolving both IPv6 and IPv4 addresses concurrently.
+ * 2. Start connecting to the one of the addresses that are obtained first.<br>If IPv4 addresses are obtained first,
+ * the method waits 50 ms for IPv6 name resolution to prioritize IPv6 connections.
+ * 3. After starting a connection attempt, wait 250 ms for the connection to be established.<br>
+ * If no connection is established within this time, a new connection is started every 250 ms<br>
+ * until a connection is established or there are no more candidate addresses.<br>
+ * (Although RFC 8305 strictly specifies sorting addresses,<br>
+ * this method only alternates between IPv6 / IPv4 addresses due to the performance concerns)
+ * 4. Once a connection is established, all remaining connection attempts are canceled.
+ */
+VALUE socket_s_tcp_fast_fallback_set(VALUE self, VALUE value) {
+ rb_ivar_set(rb_cSocket, tcp_fast_fallback, value);
+ return value;
+}
+
void
Init_socket(void)
{
@@ -1985,6 +2045,16 @@ Init_socket(void)
rsock_init_socket_init();
+ const char *tcp_no_fast_fallback_config = getenv("RUBY_TCP_NO_FAST_FALLBACK");
+ VALUE fast_fallback_default;
+ if (tcp_no_fast_fallback_config == NULL || strcmp(tcp_no_fast_fallback_config, "0") == 0) {
+ fast_fallback_default = Qtrue;
+ } else {
+ fast_fallback_default = Qfalse;
+ }
+ tcp_fast_fallback = rb_intern_const("tcp_fast_fallback");
+ rb_ivar_set(rb_cSocket, tcp_fast_fallback, fast_fallback_default);
+
rb_define_method(rb_cSocket, "initialize", sock_initialize, -1);
rb_define_method(rb_cSocket, "connect", sock_connect, 1);
@@ -2028,6 +2098,9 @@ Init_socket(void)
rb_define_singleton_method(rb_cSocket, "ip_address_list", socket_s_ip_address_list, 0);
+ rb_define_singleton_method(rb_cSocket, "tcp_fast_fallback", socket_s_tcp_fast_fallback, 0);
+ rb_define_singleton_method(rb_cSocket, "tcp_fast_fallback=", socket_s_tcp_fast_fallback_set, 1);
+
#undef rb_intern
sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
}
diff --git a/ext/socket/sockssocket.c b/ext/socket/sockssocket.c
index f263ac3804..30860ea257 100644
--- a/ext/socket/sockssocket.c
+++ b/ext/socket/sockssocket.c
@@ -30,11 +30,12 @@ socks_init(VALUE sock, VALUE host, VALUE port)
static int init = 0;
if (init == 0) {
- SOCKSinit("ruby");
+ char progname[] = "ruby";
+ SOCKSinit(progname);
init = 1;
}
- return rsock_init_inetsock(sock, host, port, Qnil, Qnil, INET_SOCKS, Qnil, Qnil);
+ return rsock_init_inetsock(sock, host, port, Qnil, Qnil, INET_SOCKS, Qnil, Qnil, Qnil, Qfalse, Qnil);
}
#ifdef SOCKS5
@@ -48,7 +49,7 @@ socks_s_close(VALUE sock)
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- shutdown(fptr->fd, 2);
+ shutdown(fptr->fd, SHUT_RDWR);
return rb_io_close(sock);
}
#endif
diff --git a/ext/socket/tcpserver.c b/ext/socket/tcpserver.c
index 04e5a0bb51..0069f3c703 100644
--- a/ext/socket/tcpserver.c
+++ b/ext/socket/tcpserver.c
@@ -36,7 +36,7 @@ tcp_svr_init(int argc, VALUE *argv, VALUE sock)
VALUE hostname, port;
rb_scan_args(argc, argv, "011", &hostname, &port);
- return rsock_init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER, Qnil, Qnil);
+ return rsock_init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER, Qnil, Qnil, Qnil, Qfalse, Qnil);
}
/*
diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c
index 03787272f3..7ce536e0af 100644
--- a/ext/socket/tcpsocket.c
+++ b/ext/socket/tcpsocket.c
@@ -12,13 +12,31 @@
/*
* call-seq:
- * TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil, connect_timeout: nil)
+ * TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil, resolv_timeout: nil, connect_timeout: nil, open_timeout: nil, fast_fallback: true)
*
* Opens a TCP connection to +remote_host+ on +remote_port+. If +local_host+
* and +local_port+ are specified, then those parameters are used on the local
* end to establish the connection.
*
- * [:connect_timeout] specify the timeout in seconds.
+ * Starting from Ruby 3.4, this method operates according to the
+ * Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305])
+ * algorithm by default, except on Windows.
+ *
+ * For details on Happy Eyeballs Version 2,
+ * see {Socket.tcp_fast_fallback=}[rdoc-ref:Socket.tcp_fast_fallback=].
+ *
+ * To make it behave the same as in Ruby 3.3 and earlier,
+ * explicitly specify the option fast_fallback:false.
+ * Or, setting Socket.tcp_fast_fallback=false will disable
+ * Happy Eyeballs Version 2 not only for this method but for all Socket globally.
+ *
+ * When using TCPSocket.new on Windows, Happy Eyeballs Version 2 is not provided,
+ * and it behaves the same as in Ruby 3.3 and earlier.
+ *
+ * [:resolv_timeout] Specifies the timeout in seconds from when the hostname resolution starts.
+ * [:connect_timeout] This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled.
+ * [:open_timeout] Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.<br>If this option is specified together with other timeout options, an +ArgumentError+ will be raised.
+ * [:fast_fallback] Enables the Happy Eyeballs Version 2 algorithm (enabled by default).
*/
static VALUE
tcp_init(int argc, VALUE *argv, VALUE sock)
@@ -26,28 +44,43 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
VALUE remote_host, remote_serv;
VALUE local_host, local_serv;
VALUE opt;
- static ID keyword_ids[2];
- VALUE kwargs[2];
+ static ID keyword_ids[5];
+ VALUE kwargs[5];
VALUE resolv_timeout = Qnil;
VALUE connect_timeout = Qnil;
+ VALUE open_timeout = Qnil;
+ VALUE fast_fallback = Qnil;
+ VALUE test_mode_settings = Qnil;
if (!keyword_ids[0]) {
CONST_ID(keyword_ids[0], "resolv_timeout");
CONST_ID(keyword_ids[1], "connect_timeout");
+ CONST_ID(keyword_ids[2], "open_timeout");
+ CONST_ID(keyword_ids[3], "fast_fallback");
+ CONST_ID(keyword_ids[4], "test_mode_settings");
}
rb_scan_args(argc, argv, "22:", &remote_host, &remote_serv,
&local_host, &local_serv, &opt);
if (!NIL_P(opt)) {
- rb_get_kwargs(opt, keyword_ids, 0, 2, kwargs);
+ rb_get_kwargs(opt, keyword_ids, 0, 5, kwargs);
if (kwargs[0] != Qundef) { resolv_timeout = kwargs[0]; }
if (kwargs[1] != Qundef) { connect_timeout = kwargs[1]; }
+ if (kwargs[2] != Qundef) { open_timeout = kwargs[2]; }
+ if (kwargs[3] != Qundef) { fast_fallback = kwargs[3]; }
+ if (kwargs[4] != Qundef) { test_mode_settings = kwargs[4]; }
+ }
+
+ if (fast_fallback == Qnil) {
+ fast_fallback = rb_ivar_get(rb_cSocket, tcp_fast_fallback);
+ if (fast_fallback == Qnil) fast_fallback = Qtrue;
}
return rsock_init_inetsock(sock, remote_host, remote_serv,
local_host, local_serv, INET_CLIENT,
- resolv_timeout, connect_timeout);
+ resolv_timeout, connect_timeout, open_timeout,
+ fast_fallback, test_mode_settings);
}
static VALUE
@@ -80,7 +113,7 @@ tcp_s_gethostbyname(VALUE obj, VALUE host)
{
rb_warn("TCPSocket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead.");
struct rb_addrinfo *res =
- rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME);
+ rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME, Qnil);
return rsock_make_hostent(host, res, tcp_sockaddr);
}
diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c
index 5224e48a96..b2bc925538 100644
--- a/ext/socket/udpsocket.c
+++ b/ext/socket/udpsocket.c
@@ -45,22 +45,18 @@ udp_init(int argc, VALUE *argv, VALUE sock)
struct udp_arg
{
+ VALUE io;
struct rb_addrinfo *res;
- rb_io_t *fptr;
};
static VALUE
udp_connect_internal(VALUE v)
{
struct udp_arg *arg = (void *)v;
- rb_io_t *fptr;
- int fd;
struct addrinfo *res;
- rb_io_check_closed(fptr = arg->fptr);
- fd = fptr->fd;
for (res = arg->res->ai; res; res = res->ai_next) {
- if (rsock_connect(fd, res->ai_addr, res->ai_addrlen, 0, NULL) >= 0) {
+ if (rsock_connect(arg->io, res->ai_addr, res->ai_addrlen, 0, RUBY_IO_TIMEOUT_DEFAULT) >= 0) {
return Qtrue;
}
}
@@ -84,16 +80,17 @@ udp_connect_internal(VALUE v)
*
*/
static VALUE
-udp_connect(VALUE sock, VALUE host, VALUE port)
+udp_connect(VALUE self, VALUE host, VALUE port)
{
- struct udp_arg arg;
- VALUE ret;
+ struct udp_arg arg = {.io = self};
+
+ arg.res = rsock_addrinfo(host, port, rsock_fd_family(rb_io_descriptor(self)), SOCK_DGRAM, 0, Qnil);
+
+ int result = (int)rb_ensure(udp_connect_internal, (VALUE)&arg, rsock_freeaddrinfo, (VALUE)arg.res);
+ if (!result) {
+ rsock_sys_fail_host_port("connect(2)", host, port);
+ }
- GetOpenFile(sock, arg.fptr);
- arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0);
- ret = rb_ensure(udp_connect_internal, (VALUE)&arg,
- rsock_freeaddrinfo, (VALUE)arg.res);
- if (!ret) rsock_sys_fail_host_port("connect(2)", host, port);
return INT2FIX(0);
}
@@ -101,14 +98,13 @@ static VALUE
udp_bind_internal(VALUE v)
{
struct udp_arg *arg = (void *)v;
- rb_io_t *fptr;
- int fd;
struct addrinfo *res;
- rb_io_check_closed(fptr = arg->fptr);
- fd = fptr->fd;
+ rb_io_t *fptr;
+ RB_IO_POINTER(arg->io, fptr);
+
for (res = arg->res->ai; res; res = res->ai_next) {
- if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {
+ if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) {
continue;
}
return Qtrue;
@@ -129,22 +125,23 @@ udp_bind_internal(VALUE v)
*
*/
static VALUE
-udp_bind(VALUE sock, VALUE host, VALUE port)
+udp_bind(VALUE self, VALUE host, VALUE port)
{
- struct udp_arg arg;
- VALUE ret;
+ struct udp_arg arg = {.io = self};
+
+ arg.res = rsock_addrinfo(host, port, rsock_fd_family(rb_io_descriptor(self)), SOCK_DGRAM, 0, Qnil);
+
+ VALUE result = rb_ensure(udp_bind_internal, (VALUE)&arg, rsock_freeaddrinfo, (VALUE)arg.res);
+ if (!result) {
+ rsock_sys_fail_host_port("bind(2)", host, port);
+ }
- GetOpenFile(sock, arg.fptr);
- arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0);
- ret = rb_ensure(udp_bind_internal, (VALUE)&arg,
- rsock_freeaddrinfo, (VALUE)arg.res);
- if (!ret) rsock_sys_fail_host_port("bind(2)", host, port);
return INT2FIX(0);
}
struct udp_send_arg {
- struct rb_addrinfo *res;
rb_io_t *fptr;
+ struct rb_addrinfo *res;
struct rsock_send_arg sarg;
};
@@ -166,7 +163,7 @@ udp_send_internal(VALUE v)
rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_WRITABLE), Qnil);
#endif
- ssize_t n = (ssize_t)BLOCKING_REGION_FD(rsock_sendto_blocking, &arg->sarg);
+ ssize_t n = (ssize_t)rb_io_blocking_region(fptr, rsock_sendto_blocking, &arg->sarg);
if (n >= 0) return RB_SSIZE2NUM(n);
@@ -215,7 +212,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
GetOpenFile(sock, arg.fptr);
arg.sarg.fd = arg.fptr->fd;
arg.sarg.flags = NUM2INT(flags);
- arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0);
+ arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0, Qnil);
ret = rb_ensure(udp_send_internal, (VALUE)&arg,
rsock_freeaddrinfo, (VALUE)arg.res);
if (!ret) rsock_sys_fail_host_port("sendto(2)", host, port);
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index a8475e3e60..2ec9376074 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -14,15 +14,14 @@
struct unixsock_arg {
struct sockaddr_un *sockaddr;
socklen_t sockaddrlen;
- int fd;
+ VALUE io;
};
static VALUE
unixsock_connect_internal(VALUE a)
{
struct unixsock_arg *arg = (struct unixsock_arg *)a;
- return (VALUE)rsock_connect(arg->fd, (struct sockaddr*)arg->sockaddr,
- arg->sockaddrlen, 0, NULL);
+ return (VALUE)rsock_connect(arg->io, (struct sockaddr*)arg->sockaddr, arg->sockaddrlen, 0, RUBY_IO_TIMEOUT_DEFAULT);
}
static VALUE
@@ -43,15 +42,16 @@ unixsock_path_value(VALUE path)
}
}
#endif
+ path = rb_get_path(path);
#ifdef _WIN32
/* UNIXSocket requires UTF-8 per spec. */
path = rb_str_export_to_enc(path, rb_utf8_encoding());
#endif
- return rb_get_path(path);
+ return path;
}
VALUE
-rsock_init_unixsock(VALUE sock, VALUE path, int server)
+rsock_init_unixsock(VALUE self, VALUE path, int server)
{
struct sockaddr_un sockaddr;
socklen_t sockaddrlen;
@@ -73,43 +73,46 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server)
rsock_sys_fail_path("socket(2)", path);
}
+ VALUE io = rsock_init_sock(self, fd);
+ RB_IO_POINTER(io, fptr);
+
if (server) {
status = bind(fd, (struct sockaddr*)&sockaddr, sockaddrlen);
}
else {
- int prot;
+ int error_tag;
struct unixsock_arg arg;
arg.sockaddr = &sockaddr;
arg.sockaddrlen = sockaddrlen;
- arg.fd = fd;
- status = (int)rb_protect(unixsock_connect_internal, (VALUE)&arg, &prot);
- if (prot) {
- close(fd);
- rb_jump_tag(prot);
+ arg.io = io;
+
+ status = (int)rb_protect(unixsock_connect_internal, (VALUE)&arg, &error_tag);
+
+ if (error_tag) {
+ rb_io_close(io);
+ rb_jump_tag(error_tag);
}
}
if (status < 0) {
int e = errno;
- close(fd);
+ rb_io_close(io);
rsock_syserr_fail_path(e, "connect(2)", path);
}
if (server) {
if (listen(fd, SOMAXCONN) < 0) {
int e = errno;
- close(fd);
+ rb_io_close(io);
rsock_syserr_fail_path(e, "listen(2)", path);
}
}
- rsock_init_sock(sock, fd);
if (server) {
- GetOpenFile(sock, fptr);
fptr->pathv = rb_str_new_frozen(path);
}
- return sock;
+ return io;
}
/*
@@ -125,9 +128,9 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server)
*
*/
static VALUE
-unix_init(VALUE sock, VALUE path)
+unix_init(VALUE self, VALUE path)
{
- return rsock_init_unixsock(sock, path, 0);
+ return rsock_init_unixsock(self, path, 0);
}
/*
@@ -288,7 +291,7 @@ unix_send_io(VALUE sock, VALUE val)
#endif
arg.fd = fptr->fd;
- while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) {
+ while ((int)rb_io_blocking_region(fptr, sendmsg_blocking, &arg) == -1) {
if (!rb_io_wait_writable(arg.fd))
rsock_sys_fail_path("sendmsg(2)", fptr->pathv);
}
@@ -390,7 +393,7 @@ retry:
#endif
arg.fd = fptr->fd;
- while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
+ while ((int)rb_io_blocking_region(fptr, recvmsg_blocking, &arg) == -1) {
int e = errno;
if (e == EMSGSIZE && !(gc_reason & GC_REASON_EMSGSIZE)) {
/* FreeBSD gets here when we're out of FDs */
diff --git a/ext/stringio/.document b/ext/stringio/.document
new file mode 100644
index 0000000000..decba0135a
--- /dev/null
+++ b/ext/stringio/.document
@@ -0,0 +1 @@
+*.[ch]
diff --git a/ext/stringio/depend b/ext/stringio/depend
index ba2b812041..3a82ad0a11 100644
--- a/ext/stringio/depend
+++ b/ext/stringio/depend
@@ -138,6 +138,7 @@ stringio.o: $(hdrdir)/ruby/internal/intern/re.h
stringio.o: $(hdrdir)/ruby/internal/intern/ruby.h
stringio.o: $(hdrdir)/ruby/internal/intern/select.h
stringio.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+stringio.o: $(hdrdir)/ruby/internal/intern/set.h
stringio.o: $(hdrdir)/ruby/internal/intern/signal.h
stringio.o: $(hdrdir)/ruby/internal/intern/sprintf.h
stringio.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ stringio.o: $(hdrdir)/ruby/internal/special_consts.h
stringio.o: $(hdrdir)/ruby/internal/static_assert.h
stringio.o: $(hdrdir)/ruby/internal/stdalign.h
stringio.o: $(hdrdir)/ruby/internal/stdbool.h
+stringio.o: $(hdrdir)/ruby/internal/stdckdint.h
stringio.o: $(hdrdir)/ruby/internal/symbol.h
stringio.o: $(hdrdir)/ruby/internal/value.h
stringio.o: $(hdrdir)/ruby/internal/value_type.h
@@ -170,5 +172,6 @@ stringio.o: $(hdrdir)/ruby/oniguruma.h
stringio.o: $(hdrdir)/ruby/ruby.h
stringio.o: $(hdrdir)/ruby/st.h
stringio.o: $(hdrdir)/ruby/subst.h
+stringio.o: $(hdrdir)/ruby/version.h
stringio.o: stringio.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/stringio/extconf.rb b/ext/stringio/extconf.rb
index a933159766..0089766983 100644
--- a/ext/stringio/extconf.rb
+++ b/ext/stringio/extconf.rb
@@ -1,4 +1,9 @@
# frozen_string_literal: false
require 'mkmf'
-have_func("rb_io_extract_modeenc", "ruby/io.h")
-create_makefile('stringio')
+if RUBY_ENGINE == 'ruby'
+ have_type("rb_io_mode_t", "ruby/io.h")
+
+ create_makefile('stringio')
+else
+ File.write('Makefile', dummy_makefile("").join)
+end
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 5edd970e1c..41aa71f893 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -12,11 +12,15 @@
**********************************************************************/
-#define STRINGIO_VERSION "3.0.6"
+static const char *const
+STRINGIO_VERSION = "3.2.1.dev";
+
+#include <stdbool.h>
#include "ruby.h"
#include "ruby/io.h"
#include "ruby/encoding.h"
+#include "ruby/version.h"
#if defined(HAVE_FCNTL_H) || defined(_WIN32)
#include <fcntl.h>
#elif defined(HAVE_SYS_FCNTL_H)
@@ -32,84 +36,21 @@
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
#endif
-#ifndef HAVE_RB_IO_EXTRACT_MODEENC
-#define rb_io_extract_modeenc strio_extract_modeenc
-static void
-strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
- int *oflags_p, int *fmode_p, struct rb_io_enc_t *convconfig_p)
+static inline bool
+str_chilled_p(VALUE str)
{
- VALUE mode = *vmode_p;
- VALUE intmode;
- int fmode;
- int has_enc = 0, has_vmode = 0;
-
- convconfig_p->enc = convconfig_p->enc2 = 0;
-
- vmode_handle:
- if (NIL_P(mode)) {
- fmode = FMODE_READABLE;
- }
- else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) {
- int flags = NUM2INT(intmode);
- fmode = rb_io_oflags_fmode(flags);
- }
- else {
- const char *m = StringValueCStr(mode), *n, *e;
- fmode = rb_io_modestr_fmode(m);
- n = strchr(m, ':');
- if (n) {
- long len;
- char encname[ENCODING_MAXNAMELEN+1];
- has_enc = 1;
- if (fmode & FMODE_SETENC_BY_BOM) {
- n = strchr(n, '|');
- }
- e = strchr(++n, ':');
- len = e ? e - n : (long)strlen(n);
- if (len > 0 && len <= ENCODING_MAXNAMELEN) {
- rb_encoding *enc;
- if (e) {
- memcpy(encname, n, len);
- encname[len] = '\0';
- n = encname;
- }
- enc = rb_enc_find(n);
- if (e)
- convconfig_p->enc2 = enc;
- else
- convconfig_p->enc = enc;
- }
- if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) {
- convconfig_p->enc = rb_enc_find(e);
- }
- }
- }
-
- if (!NIL_P(opthash)) {
- rb_encoding *extenc = 0, *intenc = 0;
- VALUE v;
- if (!has_vmode) {
- ID id_mode;
- CONST_ID(id_mode, "mode");
- v = rb_hash_aref(opthash, ID2SYM(id_mode));
- if (!NIL_P(v)) {
- if (!NIL_P(mode)) {
- rb_raise(rb_eArgError, "mode specified twice");
- }
- has_vmode = 1;
- mode = v;
- goto vmode_handle;
- }
- }
-
- if (rb_io_extract_encoding_option(opthash, &extenc, &intenc, &fmode)) {
- if (has_enc) {
- rb_raise(rb_eArgError, "encoding specified twice");
- }
- }
- }
- *fmode_p = fmode;
+#if (RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 4) || RUBY_API_VERSION_MAJOR >= 4
+ // Do not attempt to modify chilled strings on Ruby 3.4+
+ // RUBY_FL_USER2 == STR_CHILLED_LITERAL
+ // RUBY_FL_USER3 == STR_CHILLED_SYMBOL_TO_S
+ return FL_TEST_RAW(str, RUBY_FL_USER2 | RUBY_FL_USER3);
+#else
+ return false;
+#endif
}
+
+#ifndef HAVE_TYPE_RB_IO_MODE_T
+typedef int rb_io_mode_t;
#endif
struct StringIO {
@@ -117,17 +58,24 @@ struct StringIO {
rb_encoding *enc;
long pos;
long lineno;
- int flags;
+ rb_io_mode_t flags;
int count;
};
+static struct StringIO *get_strio_for_read(VALUE self);
static VALUE strio_init(int, VALUE *, struct StringIO *, VALUE);
static VALUE strio_unget_bytes(struct StringIO *, const char *, long);
static long strio_write(VALUE self, VALUE str);
#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
#define error_inval(msg) (rb_syserr_fail(EINVAL, msg))
-#define get_enc(ptr) ((ptr)->enc ? (ptr)->enc : rb_enc_get((ptr)->string))
+#define get_enc(ptr) ((ptr)->enc ? (ptr)->enc : !NIL_P((ptr)->string) ? rb_enc_get((ptr)->string) : NULL)
+
+static bool
+readonly_string_p(VALUE string)
+{
+ return OBJ_FROZEN_RAW(string);
+}
static struct StringIO *
strio_alloc(void)
@@ -179,8 +127,14 @@ static const rb_data_type_t strio_data_type = {
static struct StringIO*
get_strio(VALUE self)
{
- struct StringIO *ptr = check_strio(rb_io_taint_check(self));
+ rb_check_frozen(self);
+ return get_strio_for_read(self);
+}
+static struct StringIO*
+get_strio_for_read(VALUE self)
+{
+ struct StringIO *ptr = check_strio(self);
if (!ptr) {
rb_raise(rb_eIOError, "uninitialized stream");
}
@@ -207,14 +161,38 @@ strio_substr(struct StringIO *ptr, long pos, long len, rb_encoding *enc)
return enc_subseq(str, pos, len, enc);
}
+static VALUE
+strio_readbuf(struct StringIO *ptr, VALUE str)
+{
+ if (!NIL_P(str)) {
+ StringValue(str);
+ rb_str_modify(str);
+ if (str == ptr->string) {
+ rb_raise(rb_eArgError, "cannot read into the underlying string");
+ }
+ }
+ return str;
+}
+
#define StringIO(obj) get_strio(obj)
+#define StringIOForRead(obj) get_strio_for_read(obj)
#define STRIO_READABLE FL_USER4
#define STRIO_WRITABLE FL_USER5
#define STRIO_READWRITE (STRIO_READABLE|STRIO_WRITABLE)
typedef char strio_flags_check[(STRIO_READABLE/FMODE_READABLE == STRIO_WRITABLE/FMODE_WRITABLE) * 2 - 1];
+#ifndef RB_FL_TEST_RAW
+# define RB_FL_TEST_RAW(obj, bits) (RBASIC(obj)->flags & (bits))
+#endif
+#ifndef RB_FL_SET_RAW
+# define RB_FL_SET_RAW(obj, bits) (RBASIC(obj)->flags |= (bits))
+#endif
+#ifndef RB_FL_UNSET_RAW
+# define RB_FL_UNSET_RAW(obj, bits) (RBASIC(obj)->flags &= ~(bits))
+#endif
+
#define STRIO_MODE_SET_P(strio, mode) \
- ((RBASIC(strio)->flags & STRIO_##mode) && \
+ (RB_FL_TEST_RAW(strio, STRIO_##mode) && \
((struct StringIO*)DATA_PTR(strio))->flags & FMODE_##mode)
#define CLOSED(strio) (!STRIO_MODE_SET_P(strio, READWRITE))
#define READABLE(strio) STRIO_MODE_SET_P(strio, READABLE)
@@ -225,7 +203,7 @@ static VALUE sym_exception;
static struct StringIO*
readable(VALUE strio)
{
- struct StringIO *ptr = StringIO(strio);
+ struct StringIO *ptr = StringIOForRead(strio);
if (!READABLE(strio)) {
rb_raise(rb_eIOError, "not opened for reading");
}
@@ -245,9 +223,27 @@ writable(VALUE strio)
static void
check_modifiable(struct StringIO *ptr)
{
- if (OBJ_FROZEN(ptr->string)) {
+ if (NIL_P(ptr->string)) {
+ /* Null device StringIO */
+ }
+ else if (OBJ_FROZEN_RAW(ptr->string)) {
rb_raise(rb_eIOError, "not modifiable string");
}
+ else {
+ rb_str_modify(ptr->string);
+ }
+}
+
+static inline bool
+outside_p(struct StringIO *ptr, long pos)
+{
+ return NIL_P(ptr->string) || pos >= RSTRING_LEN(ptr->string);
+}
+
+static inline bool
+eos_p(struct StringIO *ptr)
+{
+ return outside_p(ptr, ptr->pos);
}
static VALUE
@@ -260,17 +256,32 @@ strio_s_allocate(VALUE klass)
* call-seq:
* StringIO.new(string = '', mode = 'r+') -> new_stringio
*
- * Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
- *
* Returns a new \StringIO instance formed from +string+ and +mode+;
- * see {Access Modes}[rdoc-ref:File@Access+Modes]:
+ * the instance should be closed when no longer needed:
+ *
+ * strio = StringIO.new
+ * strio.string # => ""
+ * strio.closed_read? # => false
+ * strio.closed_write? # => false
+ * strio.close
*
- * strio = StringIO.new # => #<StringIO>
+ * If +string+ is frozen, the default +mode+ is <tt>'r'</tt>:
+ *
+ * strio = StringIO.new('foo'.freeze)
+ * strio.string # => "foo"
+ * strio.closed_read? # => false
+ * strio.closed_write? # => true
* strio.close
*
- * The instance should be closed when no longer needed.
+ * Argument +mode+ must be a valid
+ * {Access Mode}[rdoc-ref:File@Access+Modes],
+ * which may be a string or an integer constant:
+ *
+ * StringIO.new('foo', 'w+')
+ * StringIO.new('foo', File::RDONLY)
*
- * Related: StringIO.open (accepts block; closes automatically).
+ * Related: StringIO.open
+ * (passes the \StringIO object to the block; closes the object automatically on block exit).
*/
static VALUE
strio_initialize(int argc, VALUE *argv, VALUE self)
@@ -356,17 +367,18 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
{
VALUE string, vmode, opt;
int oflags;
- struct rb_io_enc_t convconfig;
+ rb_io_enc_t convconfig;
argc = rb_scan_args(argc, argv, "02:", &string, &vmode, &opt);
rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &ptr->flags, &convconfig);
- if (argc) {
+ if (!NIL_P(string)) {
StringValue(string);
}
- else {
+ else if (!argc) {
string = rb_enc_str_new("", 0, rb_default_external_encoding());
}
- if (OBJ_FROZEN_RAW(string)) {
+
+ if (!NIL_P(string) && readonly_string_p(string)) {
if (ptr->flags & FMODE_WRITABLE) {
rb_syserr_fail(EACCES, 0);
}
@@ -376,11 +388,11 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
ptr->flags |= FMODE_WRITABLE;
}
}
- if (ptr->flags & FMODE_TRUNC) {
+ if (!NIL_P(string) && (ptr->flags & FMODE_TRUNC)) {
rb_str_resize(string, 0);
}
RB_OBJ_WRITE(self, &ptr->string, string);
- if (argc == 1) {
+ if (argc == 1 && !NIL_P(string)) {
ptr->enc = rb_enc_get(string);
}
else {
@@ -389,14 +401,15 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
ptr->pos = 0;
ptr->lineno = 0;
if (ptr->flags & FMODE_SETENC_BY_BOM) set_encoding_by_bom(ptr);
- RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
+ RB_FL_SET_RAW(self, (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE));
return self;
}
static VALUE
strio_finalize(VALUE self)
{
- struct StringIO *ptr = StringIO(self);
+ struct StringIO *ptr = check_strio(self);
+ if (!ptr) return Qnil;
RB_OBJ_WRITE(self, &ptr->string, Qnil);
ptr->flags &= ~FMODE_READWRITE;
return self;
@@ -404,23 +417,20 @@ strio_finalize(VALUE self)
/*
* call-seq:
- * StringIO.open(string = '', mode = 'r+') {|strio| ... }
+ * StringIO.open(string = '', mode = 'r+') -> new_stringio
+ * StringIO.open(string = '', mode = 'r+') {|strio| ... } -> object
*
- * Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
+ * Creates new \StringIO instance by calling <tt>StringIO.new(string, mode)</tt>.
*
- * Creates a new \StringIO instance formed from +string+ and +mode+;
- * see {Access Modes}[rdoc-ref:File@Access+Modes].
- *
- * With no block, returns the new instance:
+ * With no block given, returns the new instance:
*
* strio = StringIO.open # => #<StringIO>
*
- * With a block, calls the block with the new instance
+ * With a block given, calls the block with the new instance
* and returns the block's value;
- * closes the instance on block exit.
+ * closes the instance on block exit:
*
- * StringIO.open {|strio| p strio }
- * # => #<StringIO>
+ * StringIO.open('foo') {|strio| strio.string.upcase } # => "FOO"
*
* Related: StringIO.new.
*/
@@ -446,42 +456,42 @@ strio_s_new(int argc, VALUE *argv, VALUE klass)
}
/*
- * Returns +false+. Just for compatibility to IO.
+ * Returns +false+; for compatibility with IO.
*/
static VALUE
strio_false(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
return Qfalse;
}
/*
- * Returns +nil+. Just for compatibility to IO.
+ * Returns +nil+; for compatibility with IO.
*/
static VALUE
strio_nil(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
return Qnil;
}
/*
- * Returns an object itself. Just for compatibility to IO.
+ * Returns +self+; for compatibility with IO.
*/
static VALUE
strio_self(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
return self;
}
/*
- * Returns 0. Just for compatibility to IO.
+ * Returns 0; for compatibility with IO.
*/
static VALUE
strio_0(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
return INT2FIX(0);
}
@@ -491,7 +501,7 @@ strio_0(VALUE self)
static VALUE
strio_first(VALUE self, VALUE arg)
{
- StringIO(self);
+ StringIOForRead(self);
return arg;
}
@@ -501,7 +511,7 @@ strio_first(VALUE self, VALUE arg)
static VALUE
strio_unimpl(int argc, VALUE *argv, VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
rb_notimplement();
UNREACHABLE;
@@ -529,14 +539,14 @@ strio_unimpl(int argc, VALUE *argv, VALUE self)
static VALUE
strio_get_string(VALUE self)
{
- return StringIO(self)->string;
+ return StringIOForRead(self)->string;
}
/*
* call-seq:
* string = other_string -> other_string
*
- * Assigns the underlying string as +other_string+, and sets position to zero;
+ * Replaces the stored string with +other_string+, and sets the position to zero;
* returns +other_string+:
*
* StringIO.open('foo') do |strio|
@@ -550,7 +560,7 @@ strio_get_string(VALUE self)
* "foo"
* "bar"
*
- * Related: StringIO#string (returns the underlying string).
+ * Related: StringIO#string (returns the stored string).
*/
static VALUE
strio_set_string(VALUE self, VALUE string)
@@ -560,7 +570,7 @@ strio_set_string(VALUE self, VALUE string)
rb_io_taint_check(self);
ptr->flags &= ~FMODE_READWRITE;
StringValue(string);
- ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ ptr->flags = readonly_string_p(string) ? FMODE_READABLE : FMODE_READWRITE;
ptr->pos = 0;
ptr->lineno = 0;
RB_OBJ_WRITE(self, &ptr->string, string);
@@ -571,17 +581,22 @@ strio_set_string(VALUE self, VALUE string)
* call-seq:
* close -> nil
*
- * Closes +self+ for both reading and writing.
+ * Closes +self+ for both reading and writing; returns +nil+:
*
- * Raises IOError if reading or writing is attempted.
+ * strio = StringIO.new
+ * strio.closed? # => false
+ * strio.close # => nil
+ * strio.closed? # => true
+ * strio.read # Raises IOError: not opened for reading
+ * strio.write # Raises IOError: not opened for writing
*
- * Related: StringIO#close_read, StringIO#close_write.
+ * Related: StringIO#close_read, StringIO#close_write, StringIO.closed?.
*/
static VALUE
strio_close(VALUE self)
{
StringIO(self);
- RBASIC(self)->flags &= ~STRIO_READWRITE;
+ RB_FL_UNSET_RAW(self, STRIO_READWRITE);
return Qnil;
}
@@ -589,9 +604,16 @@ strio_close(VALUE self)
* call-seq:
* close_read -> nil
*
- * Closes +self+ for reading; closed-write setting remains unchanged.
+ * Closes +self+ for reading;
+ * closed-write setting remains unchanged;
+ * returns +nil+:
*
- * Raises IOError if reading is attempted.
+ * strio = StringIO.new
+ * strio.closed_read? # => false
+ * strio.close_read # => nil
+ * strio.closed_read? # => true
+ * strio.closed_write? # => false
+ * strio.read # Raises IOError: not opened for reading
*
* Related: StringIO#close, StringIO#close_write.
*/
@@ -602,7 +624,7 @@ strio_close_read(VALUE self)
if (!(ptr->flags & FMODE_READABLE)) {
rb_raise(rb_eIOError, "closing non-duplex IO for reading");
}
- RBASIC(self)->flags &= ~STRIO_READABLE;
+ RB_FL_UNSET_RAW(self, STRIO_READABLE);
return Qnil;
}
@@ -610,11 +632,16 @@ strio_close_read(VALUE self)
* call-seq:
* close_write -> nil
*
- * Closes +self+ for writing; closed-read setting remains unchanged.
+ * Closes +self+ for writing; closed-read setting remains unchanged; returns +nil+:
*
- * Raises IOError if writing is attempted.
+ * strio = StringIO.new
+ * strio.closed_write? # => false
+ * strio.close_write # => nil
+ * strio.closed_write? # => true
+ * strio.closed_read? # => false
+ * strio.write('foo') # Raises IOError: not opened for writing
*
- * Related: StringIO#close, StringIO#close_read.
+ * Related: StringIO#close, StringIO#close_read, StringIO#closed_write?.
*/
static VALUE
strio_close_write(VALUE self)
@@ -623,7 +650,7 @@ strio_close_write(VALUE self)
if (!(ptr->flags & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "closing non-duplex IO for writing");
}
- RBASIC(self)->flags &= ~STRIO_WRITABLE;
+ RB_FL_UNSET_RAW(self, STRIO_WRITABLE);
return Qnil;
}
@@ -631,13 +658,21 @@ strio_close_write(VALUE self)
* call-seq:
* closed? -> true or false
*
- * Returns +true+ if +self+ is closed for both reading and writing,
- * +false+ otherwise.
+ * Returns whether +self+ is closed for both reading and writing:
+ *
+ * strio = StringIO.new
+ * strio.closed? # => false # Open for reading and writing.
+ * strio.close_read
+ * strio.closed? # => false # Still open for writing.
+ * strio.close_write
+ * strio.closed? # => true # Now closed for both.
+ *
+ * Related: StringIO.closed_read?, StringIO.closed_write?.
*/
static VALUE
strio_closed(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
if (!CLOSED(self)) return Qfalse;
return Qtrue;
}
@@ -646,12 +681,19 @@ strio_closed(VALUE self)
* call-seq:
* closed_read? -> true or false
*
- * Returns +true+ if +self+ is closed for reading, +false+ otherwise.
+ * Returns whether +self+ is closed for reading:
+ *
+ * strio = StringIO.new
+ * strio.closed_read? # => false
+ * strio.close_read
+ * strio.closed_read? # => true
+ *
+ * Related: StringIO#closed?, StringIO#closed_write?, StringIO#close_read.
*/
static VALUE
strio_closed_read(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
if (READABLE(self)) return Qfalse;
return Qtrue;
}
@@ -660,12 +702,19 @@ strio_closed_read(VALUE self)
* call-seq:
* closed_write? -> true or false
*
- * Returns +true+ if +self+ is closed for writing, +false+ otherwise.
+ * Returns whether +self+ is closed for writing:
+ *
+ * strio = StringIO.new
+ * strio.closed_write? # => false
+ * strio.close_write
+ * strio.closed_write? # => true
+ *
+ * Related: StringIO#close_write, StringIO#closed?, StringIO#closed_read?.
*/
static VALUE
strio_closed_write(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
if (WRITABLE(self)) return Qfalse;
return Qtrue;
}
@@ -674,18 +723,26 @@ static struct StringIO *
strio_to_read(VALUE self)
{
struct StringIO *ptr = readable(self);
- if (ptr->pos < RSTRING_LEN(ptr->string)) return ptr;
- return NULL;
+ if (eos_p(ptr)) return NULL;
+ return ptr;
}
/*
* call-seq:
* eof? -> true or false
*
- * Returns +true+ if positioned at end-of-stream, +false+ otherwise;
- * see {Position}[rdoc-ref:File@Position].
+ * Returns whether +self+ is positioned at end-of-stream:
+ *
+ * strio = StringIO.new('foo')
+ * strio.pos # => 0
+ * strio.eof? # => false
+ * strio.read # => "foo"
+ * strio.pos # => 3
+ * strio.eof? # => true
+ * strio.close_read
+ * strio.eof? # Raises IOError: not opened for reading
*
- * Raises IOError if the stream is not opened for reading.
+ * Related: StringIO#pos.
*/
static VALUE
strio_eof(VALUE self)
@@ -698,17 +755,21 @@ strio_eof(VALUE self)
static VALUE
strio_copy(VALUE copy, VALUE orig)
{
- struct StringIO *ptr;
+ struct StringIO *ptr, *old_ptr;
+ VALUE old_string = Qundef;
orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
if (copy == orig) return copy;
- ptr = StringIO(orig);
- if (check_strio(copy)) {
- strio_free(DATA_PTR(copy));
+ ptr = StringIOForRead(orig);
+ old_ptr = check_strio(copy);
+ if (old_ptr) {
+ old_string = old_ptr->string;
+ strio_free(old_ptr);
}
DATA_PTR(copy) = ptr;
- RBASIC(copy)->flags &= ~STRIO_READWRITE;
- RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE;
+ RB_OBJ_WRITTEN(copy, old_string, ptr->string);
+ RB_FL_UNSET_RAW(copy, STRIO_READWRITE);
+ RB_FL_SET_RAW(copy, RB_FL_TEST_RAW(orig, STRIO_READWRITE));
++ptr->count;
return copy;
}
@@ -718,12 +779,12 @@ strio_copy(VALUE copy, VALUE orig)
* lineno -> current_line_number
*
* Returns the current line number in +self+;
- * see {Line Number}[rdoc-ref:IO@Line+Number].
+ * see {Line Number}[rdoc-ref:StringIO@Line+Number].
*/
static VALUE
strio_get_lineno(VALUE self)
{
- return LONG2NUM(StringIO(self)->lineno);
+ return LONG2NUM(StringIOForRead(self)->lineno);
}
/*
@@ -731,7 +792,7 @@ strio_get_lineno(VALUE self)
* lineno = new_line_number -> new_line_number
*
* Sets the current line number in +self+ to the given +new_line_number+;
- * see {Line Number}[rdoc-ref:IO@Line+Number].
+ * see {Line Number}[rdoc-ref:StringIO@Line+Number].
*/
static VALUE
strio_set_lineno(VALUE self, VALUE lineno)
@@ -745,7 +806,7 @@ strio_set_lineno(VALUE self, VALUE lineno)
* binmode -> self
*
* Sets the data mode in +self+ to binary mode;
- * see {Data Mode}[rdoc-ref:File@Data+Mode].
+ * see {Data Mode}[rdoc-ref:StringIO@Data+Mode].
*
*/
static VALUE
@@ -806,12 +867,12 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
* pos -> stream_position
*
* Returns the current position (in bytes);
- * see {Position}[rdoc-ref:IO@Position].
+ * see {Position}[rdoc-ref:StringIO@Position].
*/
static VALUE
strio_get_pos(VALUE self)
{
- return LONG2NUM(StringIO(self)->pos);
+ return LONG2NUM(StringIOForRead(self)->pos);
}
/*
@@ -819,7 +880,7 @@ strio_get_pos(VALUE self)
* pos = new_position -> new_position
*
* Sets the current position (in bytes);
- * see {Position}[rdoc-ref:IO@Position].
+ * see {Position}[rdoc-ref:StringIO@Position].
*/
static VALUE
strio_set_pos(VALUE self, VALUE pos)
@@ -854,9 +915,9 @@ strio_rewind(VALUE self)
* call-seq:
* seek(offset, whence = SEEK_SET) -> 0
*
- * Sets the current position to the given integer +offset+ (in bytes),
+ * Sets the position to the given integer +offset+ (in bytes),
* with respect to a given constant +whence+;
- * see {Position}[rdoc-ref:IO@Position].
+ * see {IO#seek}[rdoc-ref:IO#seek].
*/
static VALUE
strio_seek(int argc, VALUE *argv, VALUE self)
@@ -878,7 +939,11 @@ strio_seek(int argc, VALUE *argv, VALUE self)
offset = ptr->pos;
break;
case 2:
- offset = RSTRING_LEN(ptr->string);
+ if (NIL_P(ptr->string)) {
+ offset = 0;
+ } else {
+ offset = RSTRING_LEN(ptr->string);
+ }
break;
default:
error_inval("invalid whence");
@@ -899,7 +964,7 @@ strio_seek(int argc, VALUE *argv, VALUE self)
static VALUE
strio_get_sync(VALUE self)
{
- StringIO(self);
+ StringIOForRead(self);
return Qtrue;
}
@@ -911,10 +976,9 @@ strio_get_sync(VALUE self)
* call-seq:
* each_byte {|byte| ... } -> self
*
- * With a block given, calls the block with each remaining byte in the stream;
- * see {Byte IO}[rdoc-ref:IO@Byte+IO].
+ * :include: stringio/each_byte.rdoc
*
- * With no block given, returns an enumerator.
+ * Related: StringIO#each_char, StringIO#each_codepoint, StringIO#each_line.
*/
static VALUE
strio_each_byte(VALUE self)
@@ -932,10 +996,10 @@ strio_each_byte(VALUE self)
/*
* call-seq:
- * getc -> character or nil
+ * getc -> character, byte, or nil
+ *
+ * :include: stringio/getc.rdoc
*
- * Reads and returns the next character from the stream;
- * see {Character IO}[rdoc-ref:IO@Character+IO].
*/
static VALUE
strio_getc(VALUE self)
@@ -947,7 +1011,7 @@ strio_getc(VALUE self)
int len;
char *p;
- if (pos >= RSTRING_LEN(str)) {
+ if (eos_p(ptr)) {
return Qnil;
}
p = RSTRING_PTR(str)+pos;
@@ -958,17 +1022,17 @@ strio_getc(VALUE self)
/*
* call-seq:
- * getbyte -> byte or nil
+ * getbyte -> integer or nil
+ *
+ * :include: stringio/getbyte.rdoc
*
- * Reads and returns the next 8-bit byte from the stream;
- * see {Byte IO}[rdoc-ref:IO@Byte+IO].
*/
static VALUE
strio_getbyte(VALUE self)
{
struct StringIO *ptr = readable(self);
int c;
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
+ if (eos_p(ptr)) {
return Qnil;
}
c = RSTRING_PTR(ptr->string)[ptr->pos++];
@@ -990,8 +1054,17 @@ strio_extend(struct StringIO *ptr, long pos, long len)
if (pos > olen)
MEMZERO(RSTRING_PTR(ptr->string) + olen, char, pos - olen);
}
- else {
- rb_str_modify(ptr->string);
+}
+
+static void
+strio_unget_string(struct StringIO *ptr, VALUE c)
+{
+ const char *cp = NULL;
+ long cl = RSTRING_LEN(c);
+ if (cl > 0) {
+ if (c != ptr->string) cp = RSTRING_PTR(c);
+ strio_unget_bytes(ptr, cp, cl);
+ RB_GC_GUARD(c);
}
}
@@ -1009,6 +1082,7 @@ strio_ungetc(VALUE self, VALUE c)
rb_encoding *enc, *enc2;
check_modifiable(ptr);
+ if (NIL_P(ptr->string)) return Qnil;
if (NIL_P(c)) return Qnil;
if (RB_INTEGER_TYPE_P(c)) {
int len, cc = NUM2INT(c);
@@ -1016,19 +1090,22 @@ strio_ungetc(VALUE self, VALUE c)
enc = rb_enc_get(ptr->string);
len = rb_enc_codelen(cc, enc);
- if (len <= 0) rb_enc_uint_chr(cc, enc);
+ if (len <= 0) {
+ rb_enc_uint_chr(cc, enc); /* to raise an exception */
+ UNREACHABLE;
+ }
rb_enc_mbcput(cc, buf, enc);
return strio_unget_bytes(ptr, buf, len);
}
else {
- SafeStringValue(c);
+ StringValue(c);
+ if (RSTRING_LEN(c) == 0) return Qnil;
enc = rb_enc_get(ptr->string);
enc2 = rb_enc_get(c);
if (enc != enc2 && enc != rb_ascii8bit_encoding()) {
c = rb_str_conv_enc(c, enc2, enc);
}
- strio_unget_bytes(ptr, RSTRING_PTR(c), RSTRING_LEN(c));
- RB_GC_GUARD(c);
+ strio_unget_string(ptr, c);
return Qnil;
}
}
@@ -1046,21 +1123,17 @@ strio_ungetbyte(VALUE self, VALUE c)
struct StringIO *ptr = readable(self);
check_modifiable(ptr);
+ if (NIL_P(ptr->string)) return Qnil;
if (NIL_P(c)) return Qnil;
if (RB_INTEGER_TYPE_P(c)) {
- /* rb_int_and() not visible from exts */
- VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
- const char cc = NUM2INT(v) & 0xFF;
- strio_unget_bytes(ptr, &cc, 1);
+ /* rb_int_and() not visible from exts */
+ VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
+ const char cc = NUM2INT(v) & 0xFF;
+ strio_unget_bytes(ptr, &cc, 1);
}
else {
- long cl;
- SafeStringValue(c);
- cl = RSTRING_LEN(c);
- if (cl > 0) {
- strio_unget_bytes(ptr, RSTRING_PTR(c), cl);
- RB_GC_GUARD(c);
- }
+ StringValue(c);
+ strio_unget_string(ptr, c);
}
return Qnil;
}
@@ -1091,7 +1164,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
if (rest > cl) memset(s + len, 0, rest - cl);
pos -= cl;
}
- memcpy(s + pos, cp, cl);
+ memcpy(s + pos, (cp ? cp : s), cl);
ptr->pos = pos;
return Qnil;
}
@@ -1128,12 +1201,11 @@ strio_readbyte(VALUE self)
/*
* call-seq:
- * each_char {|c| ... } -> self
+ * each_char {|char| ... } -> self
*
- * With a block given, calls the block with each remaining character in the stream;
- * see {Character IO}[rdoc-ref:IO@Character+IO].
+ * :include: stringio/each_char.rdoc
*
- * With no block given, returns an enumerator.
+ * Related: StringIO#each_byte, StringIO#each_codepoint, StringIO#each_line.
*/
static VALUE
strio_each_char(VALUE self)
@@ -1152,10 +1224,9 @@ strio_each_char(VALUE self)
* call-seq:
* each_codepoint {|codepoint| ... } -> self
*
- * With a block given, calls the block with each remaining codepoint in the stream;
- * see {Codepoint IO}[rdoc-ref:IO@Codepoint+IO].
+ * :include: stringio/each_codepoint.rdoc
*
- * With no block given, returns an enumerator.
+ * Related: StringIO#each_byte, StringIO#each_char, StringIO#each_line.
*/
static VALUE
strio_each_codepoint(VALUE self)
@@ -1218,38 +1289,57 @@ struct getline_arg {
};
static struct getline_arg *
-prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
+prepare_getline_args(struct StringIO *ptr, struct getline_arg *arg, int argc, VALUE *argv)
{
- VALUE str, lim, opts;
+ VALUE rs, lim, opts;
long limit = -1;
int respect_chomp;
- argc = rb_scan_args(argc, argv, "02:", &str, &lim, &opts);
- respect_chomp = argc == 0 || !NIL_P(str);
+ argc = rb_scan_args(argc, argv, "02:", &rs, &lim, &opts);
+ respect_chomp = argc == 0 || !NIL_P(rs);
switch (argc) {
case 0:
- str = rb_rs;
+ rs = rb_rs;
break;
case 1:
- if (!NIL_P(str) && !RB_TYPE_P(str, T_STRING)) {
- VALUE tmp = rb_check_string_type(str);
+ if (!NIL_P(rs) && !RB_TYPE_P(rs, T_STRING)) {
+ VALUE tmp = rb_check_string_type(rs);
if (NIL_P(tmp)) {
- limit = NUM2LONG(str);
- str = rb_rs;
+ limit = NUM2LONG(rs);
+ rs = rb_rs;
}
else {
- str = tmp;
+ rs = tmp;
}
}
break;
case 2:
- if (!NIL_P(str)) StringValue(str);
+ if (!NIL_P(rs)) StringValue(rs);
if (!NIL_P(lim)) limit = NUM2LONG(lim);
break;
}
- arg->rs = str;
+ if (!NIL_P(ptr->string) && !NIL_P(rs)) {
+ rb_encoding *enc_rs, *enc_io;
+ enc_rs = rb_enc_get(rs);
+ enc_io = get_enc(ptr);
+ if (enc_rs != enc_io &&
+ (rb_enc_str_coderange(rs) != ENC_CODERANGE_7BIT ||
+ (RSTRING_LEN(rs) > 0 && !rb_enc_asciicompat(enc_io)))) {
+ if (rs == rb_rs) {
+ rs = rb_enc_str_new(0, 0, enc_io);
+ rb_str_buf_cat_ascii(rs, "\n");
+ rs = rs;
+ }
+ else {
+ rb_raise(rb_eArgError, "encoding mismatch: %s IO with %s RS",
+ rb_enc_name(enc_io),
+ rb_enc_name(enc_rs));
+ }
+ }
+ }
+ arg->rs = rs;
arg->limit = limit;
arg->chomp = 0;
if (!NIL_P(opts)) {
@@ -1259,9 +1349,9 @@ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
keywords[0] = rb_intern_const("chomp");
}
rb_get_kwargs(opts, keywords, 0, 1, &vchomp);
- if (respect_chomp) {
+ if (respect_chomp) {
arg->chomp = (vchomp != Qundef) && RTEST(vchomp);
- }
+ }
}
return arg;
}
@@ -1285,7 +1375,7 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
long w = 0;
rb_encoding *enc = get_enc(ptr);
- if (ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
+ if (NIL_P(ptr->string) || ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
return Qnil;
}
s = RSTRING_PTR(ptr->string);
@@ -1301,7 +1391,7 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
str = strio_substr(ptr, ptr->pos, e - s - w, enc);
}
else if ((n = RSTRING_LEN(str)) == 0) {
- const char *paragraph_end = NULL;
+ const char *paragraph_end = NULL;
p = s;
while (p[(p + 1 < e) && (*p == '\r') && 0] == '\n') {
p += *p == '\r';
@@ -1311,18 +1401,18 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
}
s = p;
while ((p = memchr(p, '\n', e - p)) && (p != e)) {
- p++;
- if (!((p < e && *p == '\n') ||
- (p + 1 < e && *p == '\r' && *(p+1) == '\n'))) {
- continue;
- }
- paragraph_end = p - ((*(p-2) == '\r') ? 2 : 1);
- while ((p < e && *p == '\n') ||
- (p + 1 < e && *p == '\r' && *(p+1) == '\n')) {
- p += (*p == '\r') ? 2 : 1;
- }
- e = p;
- break;
+ p++;
+ if (!((p < e && *p == '\n') ||
+ (p + 1 < e && *p == '\r' && *(p+1) == '\n'))) {
+ continue;
+ }
+ paragraph_end = p - ((*(p-2) == '\r') ? 2 : 1);
+ while ((p < e && *p == '\n') ||
+ (p + 1 < e && *p == '\r' && *(p+1) == '\n')) {
+ p += (*p == '\r') ? 2 : 1;
+ }
+ e = p;
+ break;
}
if (arg->chomp && paragraph_end) {
w = e - paragraph_end;
@@ -1370,22 +1460,22 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
* gets(limit, chomp: false) -> string or nil
* gets(sep, limit, chomp: false) -> string or nil
*
- * Reads and returns a line from the stream;
- * assigns the return value to <tt>$_</tt>;
- * see {Line IO}[rdoc-ref:IO@Line+IO].
+ * :include: stringio/gets.rdoc
+ *
*/
static VALUE
strio_gets(int argc, VALUE *argv, VALUE self)
{
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
VALUE str;
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
- struct StringIO *ptr = readable(self);
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
+ if (NIL_P(ptr->string)) return Qnil;
return rb_enc_str_new(0, 0, get_enc(ptr));
}
- str = strio_getline(&arg, readable(self));
+ str = strio_getline(&arg, ptr);
rb_lastline_set(str);
return str;
}
@@ -1408,30 +1498,30 @@ strio_readline(int argc, VALUE *argv, VALUE self)
}
/*
+ * :markup: markdown
+ *
* call-seq:
* each_line(sep = $/, chomp: false) {|line| ... } -> self
* each_line(limit, chomp: false) {|line| ... } -> self
* each_line(sep, limit, chomp: false) {|line| ... } -> self
*
- * Calls the block with each remaining line read from the stream;
- * does nothing if already at end-of-file;
- * returns +self+.
- * See {Line IO}[rdoc-ref:IO@Line+IO].
+ * :include: stringio/each_line.md
+ *
*/
static VALUE
strio_each(int argc, VALUE *argv, VALUE self)
{
VALUE line;
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
- StringIO(self);
RETURN_ENUMERATOR(self, argc, argv);
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
rb_raise(rb_eArgError, "invalid limit: 0 for each_line");
}
- while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
+ while (!NIL_P(line = strio_getline(&arg, ptr))) {
rb_yield(line);
}
return self;
@@ -1449,15 +1539,15 @@ static VALUE
strio_readlines(int argc, VALUE *argv, VALUE self)
{
VALUE ary, line;
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
- StringIO(self);
- ary = rb_ary_new();
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
}
- while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
+ ary = rb_ary_new();
+ while (!NIL_P(line = strio_getline(&arg, ptr))) {
rb_ary_push(ary, line);
}
return ary;
@@ -1496,6 +1586,7 @@ strio_write(VALUE self, VALUE str)
if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
enc = get_enc(ptr);
+ if (!enc) return 0;
enc2 = rb_enc_get(str);
if (enc != enc2 && enc != ascii8bit && enc != (usascii = rb_usascii_encoding())) {
VALUE converted = rb_str_conv_enc(str, enc2, enc);
@@ -1521,6 +1612,7 @@ strio_write(VALUE self, VALUE str)
}
else {
strio_extend(ptr, ptr->pos, len);
+ rb_str_modify(ptr->string);
memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len);
}
RB_GC_GUARD(str);
@@ -1555,9 +1647,10 @@ strio_write(VALUE self, VALUE str)
/*
* call-seq:
- * strio.putc(obj) -> obj
+ * putc(object) -> object
+ *
+ * :include: stringio/putc.rdoc
*
- * See IO#putc.
*/
static VALUE
strio_putc(VALUE self, VALUE ch)
@@ -1567,10 +1660,12 @@ strio_putc(VALUE self, VALUE ch)
check_modifiable(ptr);
if (RB_TYPE_P(ch, T_STRING)) {
+ if (NIL_P(ptr->string)) return ch;
str = rb_str_substr(ch, 0, 1);
}
else {
char c = NUM2CHR(ch);
+ if (NIL_P(ptr->string)) return ch;
str = rb_str_new(&c, 1);
}
strio_write(self, str);
@@ -1587,9 +1682,10 @@ strio_putc(VALUE self, VALUE ch)
/*
* call-seq:
- * strio.read([length [, outbuf]]) -> string, outbuf, or nil
+ * read(maxlen = nil, out_string = nil) → new_string, out_string, or nil
+ *
+ * :include: stringio/read.rdoc
*
- * See IO#read.
*/
static VALUE
strio_read(int argc, VALUE *argv, VALUE self)
@@ -1601,11 +1697,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
switch (argc) {
case 2:
- str = argv[1];
- if (!NIL_P(str)) {
- StringValue(str);
- rb_str_modify(str);
- }
+ str = strio_readbuf(ptr, argv[1]);
/* fall through */
case 1:
if (!NIL_P(argv[0])) {
@@ -1613,15 +1705,16 @@ 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 (eos_p(ptr)) {
if (!NIL_P(str)) rb_str_resize(str, 0);
- return Qnil;
+ return len > 0 ? Qnil : rb_str_new(0, 0);
}
binary = 1;
break;
}
/* fall through */
case 0:
+ if (NIL_P(ptr->string)) return Qnil;
len = RSTRING_LEN(ptr->string);
if (len <= ptr->pos) {
rb_encoding *enc = get_enc(ptr);
@@ -1639,7 +1732,7 @@ strio_read(int argc, VALUE *argv, VALUE self)
}
break;
default:
- rb_error_arity(argc, 0, 2);
+ rb_error_arity(argc, 0, 2);
}
if (NIL_P(str)) {
rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr);
@@ -1650,16 +1743,66 @@ strio_read(int argc, VALUE *argv, VALUE self)
if (len > rest) len = rest;
rb_str_resize(str, len);
MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len);
- if (binary)
- rb_enc_associate(str, rb_ascii8bit_encoding());
- else
+ if (!binary) {
rb_enc_copy(str, ptr->string);
+ }
}
ptr->pos += RSTRING_LEN(str);
return str;
}
/*
+ * call-seq:
+ * pread(maxlen, offset, out_string = nil) -> new_string or out_string
+ *
+ * :include: stringio/pread.rdoc
+ *
+ */
+static VALUE
+strio_pread(int argc, VALUE *argv, VALUE self)
+{
+ VALUE rb_len, rb_offset, rb_buf;
+ struct StringIO *ptr = readable(self);
+
+ rb_scan_args(argc, argv, "21", &rb_len, &rb_offset, &rb_buf);
+ long len = NUM2LONG(rb_len);
+ long offset = NUM2LONG(rb_offset);
+
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative string size (or size too big): %" PRIsVALUE, rb_len);
+ }
+
+ if (offset < 0) {
+ rb_syserr_fail_str(EINVAL, rb_sprintf("pread: Invalid offset argument: %" PRIsVALUE, rb_offset));
+ }
+
+ rb_buf = strio_readbuf(ptr, rb_buf);
+
+ if (len == 0) {
+ if (NIL_P(rb_buf)) {
+ return rb_str_new("", 0);
+ }
+ return rb_buf;
+ }
+
+ if (outside_p(ptr, offset)) {
+ rb_eof_error();
+ }
+
+ if (NIL_P(rb_buf)) {
+ return strio_substr(ptr, offset, len, rb_ascii8bit_encoding());
+ }
+
+ long rest = RSTRING_LEN(ptr->string) - offset;
+ if (len > rest) len = rest;
+ rb_str_resize(rb_buf, len);
+ rb_enc_associate(rb_buf, rb_ascii8bit_encoding());
+ MEMCPY(RSTRING_PTR(rb_buf), RSTRING_PTR(ptr->string) + offset, char, len);
+ return rb_buf;
+}
+
+
+/*
* call-seq:
* strio.sysread(integer[, outbuf]) -> string
* strio.readpartial(integer[, outbuf]) -> string
@@ -1707,8 +1850,14 @@ strio_read_nonblock(int argc, VALUE *argv, VALUE self)
return val;
}
+/*
+ * See IO#write
+ */
#define strio_syswrite rb_io_write
+/*
+ * See IO#write_nonblock
+ */
static VALUE
strio_syswrite_nonblock(int argc, VALUE *argv, VALUE self)
{
@@ -1726,17 +1875,17 @@ strio_syswrite_nonblock(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * strio.length -> integer
- * strio.size -> integer
+ * size -> integer
+ *
+ * :include: stringio/size.rdoc
*
- * Returns the size of the buffer string.
*/
static VALUE
strio_size(VALUE self)
{
- VALUE string = StringIO(self)->string;
+ VALUE string = StringIOForRead(self)->string;
if (NIL_P(string)) {
- rb_raise(rb_eIOError, "not opened");
+ return INT2FIX(0);
}
return ULONG2NUM(RSTRING_LEN(string));
}
@@ -1753,10 +1902,12 @@ strio_truncate(VALUE self, VALUE len)
{
VALUE string = writable(self)->string;
long l = NUM2LONG(len);
- long plen = RSTRING_LEN(string);
+ long plen;
if (l < 0) {
error_inval("negative length");
}
+ if (NIL_P(string)) return 0;
+ plen = RSTRING_LEN(string);
rb_str_resize(string, l);
if (plen < l) {
MEMZERO(RSTRING_PTR(string) + plen, char, l - plen);
@@ -1765,27 +1916,34 @@ strio_truncate(VALUE self, VALUE len)
}
/*
- * call-seq:
- * strio.external_encoding => encoding
+ * call-seq:
+ * external_encoding -> encoding or nil
+ *
+ * Returns an Encoding object that represents the encoding of the string;
+ * see {Encodings}[rdoc-ref:StringIO@Encodings]:
+ *
+ * strio = StringIO.new('foo')
+ * strio.external_encoding # => #<Encoding:UTF-8>
+ *
+ * Returns +nil+ if +self+ has no string and is in write mode:
+ *
+ * strio = StringIO.new(nil, 'w+')
+ * strio.external_encoding # => nil
*
- * Returns the Encoding object that represents the encoding of the file.
- * If the stream is write mode and no encoding is specified, returns
- * +nil+.
*/
static VALUE
strio_external_encoding(VALUE self)
{
- struct StringIO *ptr = StringIO(self);
+ struct StringIO *ptr = StringIOForRead(self);
return rb_enc_from_encoding(get_enc(ptr));
}
/*
* call-seq:
- * strio.internal_encoding => encoding
+ * internal_encoding -> nil
*
- * Returns the Encoding of the internal string if conversion is
- * specified. Otherwise returns +nil+.
+ * Returns +nil+; for compatibility with IO.
*/
static VALUE
@@ -1819,21 +1977,31 @@ strio_set_encoding(int argc, VALUE *argv, VALUE self)
else {
enc = rb_find_encoding(ext_enc);
if (!enc) {
- struct rb_io_enc_t convconfig;
- int oflags, fmode;
+ rb_io_enc_t convconfig;
+ int oflags;
+ rb_io_mode_t fmode;
VALUE vmode = rb_str_append(rb_str_new_cstr("r:"), ext_enc);
rb_io_extract_modeenc(&vmode, 0, Qnil, &oflags, &fmode, &convconfig);
enc = convconfig.enc2;
}
}
ptr->enc = enc;
- if (WRITABLE(self)) {
+ if (!NIL_P(ptr->string) && WRITABLE(self) && !str_chilled_p(ptr->string)) {
rb_enc_associate(ptr->string, enc);
}
return self;
}
+/*
+ * call-seq:
+ * strio.set_encoding_by_bom => strio or nil
+ *
+ * Sets the encoding according to the BOM (Byte Order Mark) in the
+ * string.
+ *
+ * Returns +self+ if the BOM is found, otherwise +nil.
+ */
static VALUE
strio_set_encoding_by_bom(VALUE self)
{
@@ -1844,16 +2012,9 @@ strio_set_encoding_by_bom(VALUE self)
}
/*
- * \IO streams for strings, with access similar to
- * {IO}[rdoc-ref:IO];
- * see {IO}[rdoc-ref:IO].
- *
- * === About the Examples
- *
- * Examples on this page assume that \StringIO has been required:
- *
- * require 'stringio'
+ * :markup: markdown
*
+ * :include: stringio/stringio.md
*/
void
Init_stringio(void)
@@ -1861,15 +2022,20 @@ Init_stringio(void)
#undef rb_intern
#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
+ rb_ext_ractor_safe(true);
#endif
VALUE StringIO = rb_define_class("StringIO", rb_cObject);
+ /* The version string */
rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
rb_include_module(StringIO, rb_mEnumerable);
rb_define_alloc_func(StringIO, strio_s_allocate);
+
+ /* Maximum length that a StringIO instance can hold */
+ rb_define_const(StringIO, "MAX_LENGTH", LONG2NUM(LONG_MAX));
+
rb_define_singleton_method(StringIO, "new", strio_s_new, -1);
rb_define_singleton_method(StringIO, "open", strio_s_open, -1);
rb_define_method(StringIO, "initialize", strio_initialize, -1);
@@ -1919,6 +2085,7 @@ Init_stringio(void)
rb_define_method(StringIO, "gets", strio_gets, -1);
rb_define_method(StringIO, "readlines", strio_readlines, -1);
rb_define_method(StringIO, "read", strio_read, -1);
+ rb_define_method(StringIO, "pread", strio_pread, -1);
rb_define_method(StringIO, "write", strio_write_m, -1);
rb_define_method(StringIO, "putc", strio_putc, 1);
@@ -1947,7 +2114,9 @@ Init_stringio(void)
rb_define_method(StringIO, "set_encoding_by_bom", strio_set_encoding_by_bom, 0);
{
+ /* :stopdoc: */
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
+ /* :startdoc: */
rb_define_method(mReadable, "readchar", strio_readchar, 0);
rb_define_method(mReadable, "readbyte", strio_readbyte, 0);
rb_define_method(mReadable, "readline", strio_readline, -1);
@@ -1957,7 +2126,9 @@ Init_stringio(void)
rb_include_module(StringIO, mReadable);
}
{
+ /* :stopdoc: */
VALUE mWritable = rb_define_module_under(rb_cIO, "generic_writable");
+ /* :startdoc: */
rb_define_method(mWritable, "<<", strio_addstr, 1);
rb_define_method(mWritable, "print", strio_print, -1);
rb_define_method(mWritable, "printf", strio_printf, -1);
diff --git a/ext/stringio/stringio.gemspec b/ext/stringio/stringio.gemspec
index 1015d261f5..f9a0742049 100644
--- a/ext/stringio/stringio.gemspec
+++ b/ext/stringio/stringio.gemspec
@@ -4,7 +4,7 @@
source_version = ["", "ext/stringio/"].find do |dir|
begin
break File.open(File.join(__dir__, "#{dir}stringio.c")) {|f|
- f.gets("\n#define STRINGIO_VERSION ")
+ f.gets("\nSTRINGIO_VERSION ")
f.gets[/\s*"(.+)"/, 1]
}
rescue Errno::ENOENT
@@ -14,7 +14,6 @@ Gem::Specification.new do |s|
s.name = "stringio"
s.version = source_version
- s.required_rubygems_version = Gem::Requirement.new(">= 2.6")
s.require_paths = ["lib"]
s.authors = ["Nobu Nakada", "Charles Oliver Nutter"]
s.description = "Pseudo `IO` class from/to `String`."
@@ -22,17 +21,26 @@ Gem::Specification.new do |s|
s.files = ["README.md"]
jruby = true if Gem::Platform.new('java') =~ s.platform or RUBY_ENGINE == 'jruby'
if jruby
- s.files += ["lib/stringio.rb", "lib/stringio.jar"]
+ s.require_paths = "lib/java"
+ s.files += ["lib/java/stringio.rb", "lib/java/stringio.jar"]
s.platform = "java"
else
s.extensions = ["ext/stringio/extconf.rb"]
s.files += ["ext/stringio/extconf.rb", "ext/stringio/stringio.c"]
end
+
+ s.extra_rdoc_files = [
+ ".document", ".rdoc_options", "COPYING", "LICENSE.txt",
+ "NEWS.md", "README.md", "docs/io.rb", "ext/stringio/.document",
+ ]
+
s.homepage = "https://github.com/ruby/stringio"
s.licenses = ["Ruby", "BSD-2-Clause"]
- s.required_ruby_version = ">= 2.5"
+ s.required_ruby_version = ">= 2.7"
s.summary = "Pseudo IO on String"
+ s.metadata["changelog_uri"] = "#{s.homepage}/releases/tag/v#{s.version}"
+
# s.cert_chain = %w[certs/nobu.pem]
# s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
end
diff --git a/ext/strscan/depend b/ext/strscan/depend
index 8d985b59e8..b40a025230 100644
--- a/ext/strscan/depend
+++ b/ext/strscan/depend
@@ -138,6 +138,7 @@ strscan.o: $(hdrdir)/ruby/internal/intern/re.h
strscan.o: $(hdrdir)/ruby/internal/intern/ruby.h
strscan.o: $(hdrdir)/ruby/internal/intern/select.h
strscan.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+strscan.o: $(hdrdir)/ruby/internal/intern/set.h
strscan.o: $(hdrdir)/ruby/internal/intern/signal.h
strscan.o: $(hdrdir)/ruby/internal/intern/sprintf.h
strscan.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ strscan.o: $(hdrdir)/ruby/internal/special_consts.h
strscan.o: $(hdrdir)/ruby/internal/static_assert.h
strscan.o: $(hdrdir)/ruby/internal/stdalign.h
strscan.o: $(hdrdir)/ruby/internal/stdbool.h
+strscan.o: $(hdrdir)/ruby/internal/stdckdint.h
strscan.o: $(hdrdir)/ruby/internal/symbol.h
strscan.o: $(hdrdir)/ruby/internal/value.h
strscan.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/strscan/extconf.rb b/ext/strscan/extconf.rb
index b53b63e455..4e8d851fdb 100644
--- a/ext/strscan/extconf.rb
+++ b/ext/strscan/extconf.rb
@@ -2,7 +2,12 @@
require 'mkmf'
if RUBY_ENGINE == 'ruby'
$INCFLAGS << " -I$(top_srcdir)" if $extmk
- have_func("onig_region_memsize", "ruby.h")
+ have_func("onig_region_memsize(NULL)")
+ have_func("rb_reg_onig_match", "ruby/re.h")
+ have_func("rb_deprecate_constant")
+ have_func("rb_int_parse_cstr", "ruby.h") # RUBY_VERSION >= 2.5
+ have_func("rb_gc_location", "ruby.h") # RUBY_VERSION >= 2.7
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
create_makefile 'strscan'
else
File.write('Makefile', dummy_makefile("").join)
diff --git a/ext/strscan/lib/strscan.rb b/ext/strscan/lib/strscan.rb
new file mode 100644
index 0000000000..4e8910d141
--- /dev/null
+++ b/ext/strscan/lib/strscan.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+case RUBY_ENGINE
+when 'ruby'
+ require 'strscan.so'
+ require_relative 'strscan/strscan'
+when 'jruby'
+ require 'strscan.jar'
+ JRuby::Util.load_ext('org.jruby.ext.strscan.StringScannerLibrary')
+ require_relative 'strscan/strscan'
+when 'truffleruby'
+ if RUBY_ENGINE_VERSION.to_i >= 34
+ require 'strscan/truffleruby'
+ else
+ $LOAD_PATH.delete __dir__
+ require 'strscan'
+ end
+else
+ raise NotImplementedError, "Unknown Ruby: #{RUBY_ENGINE}"
+end
diff --git a/ext/strscan/lib/strscan/strscan.rb b/ext/strscan/lib/strscan/strscan.rb
new file mode 100644
index 0000000000..5e262f4007
--- /dev/null
+++ b/ext/strscan/lib/strscan/strscan.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+class StringScanner
+ unless method_defined?(:integer_at) # For JRuby
+ def integer_at(specifier, *to_i_args)
+ self[specifier]&.to_i(*to_i_args)
+ end
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # scan_integer(base: 10) -> integer or nil
+ #
+ # Returns an integer scanned from `self`,
+ # beginning at the current position;
+ # returns `nil` if no such integer was available.
+ #
+ # When `base` is `10` (the default),
+ # equivalent to calling #scan with argument +pattern+
+ # as `'[+-]?\d+'`:
+ #
+ # ```ruby
+ # scanner = StringScanner.new('Form 27B/6')
+ # scanner.scan_integer # => nil # No integer at position 0.
+ # scanner.pos = 5
+ # scanner.scan_integer # => 27
+ # scanner.matched # => "27"
+ # scanner.pos # => 7
+ # ```
+ #
+ # When `base` is `16` (the only other value allowed),
+ # equivalent to calling #scan with argument `pattern`
+ # as `'[+-]?(0x)?[0-9a-fA-F]+'`:
+ #
+ # ```ruby
+ # scanner.pos = 5
+ # scanner.scan_integer(base: 16) # => 635
+ # scanner.matched # => "27B"
+ # scanner.pos # => 8
+ # ```
+ #
+ # Raises Encoding::CompatibilityError if `self` does not have
+ # an ASCII compatible encoding.
+ def scan_integer(base: 10)
+ case base
+ when 10
+ scan_base10_integer
+ when 16
+ scan_base16_integer
+ else
+ raise ArgumentError, "Unsupported integer base: #{base.inspect}, expected 10 or 16"
+ end
+ end
+end
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index f7888e2cf1..dede57218b 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -22,7 +22,15 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
#include <stdbool.h>
-#define STRSCAN_VERSION "3.0.7"
+#define STRSCAN_VERSION "3.1.9.dev"
+
+
+#ifdef HAVE_RB_DEPRECATE_CONSTANT
+/* In ruby 3.0, defined but exposed in external headers */
+extern void rb_deprecate_constant(VALUE mod, const char *name);
+#else
+# define rb_deprecate_constant(mod, name) ((void)0)
+#endif
/* =======================================================================
Data Type Definitions
@@ -30,7 +38,8 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
static VALUE StringScanner;
static VALUE ScanError;
-static ID id_byteslice;
+
+static int usascii_encindex, utf8_encindex, binary_encindex;
struct strscanner
{
@@ -56,8 +65,13 @@ struct strscanner
};
#define MATCHED_P(s) ((s)->flags & FLAG_MATCHED)
-#define MATCHED(s) (s)->flags |= FLAG_MATCHED
-#define CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED
+#define MATCHED(s) ((s)->flags |= FLAG_MATCHED)
+#define CLEAR_MATCHED(s) ((s)->flags &= ~FLAG_MATCHED)
+#define CLEAR_NAMED_CAPTURES(s) ((s)->regex = Qnil)
+#define CLEAR_MATCH_STATUS(s) do {\
+ CLEAR_MATCHED(s);\
+ CLEAR_NAMED_CAPTURES(s);\
+} while (0)
#define S_PBEG(s) (RSTRING_PTR((s)->str))
#define S_LEN(s) (RSTRING_LEN((s)->str))
@@ -90,7 +104,6 @@ static VALUE strscan_init_copy _((VALUE vself, VALUE vorig));
static VALUE strscan_s_mustc _((VALUE self));
static VALUE strscan_terminate _((VALUE self));
-static VALUE strscan_clear _((VALUE self));
static VALUE strscan_get_string _((VALUE self));
static VALUE strscan_set_string _((VALUE self, VALUE str));
static VALUE strscan_concat _((VALUE self, VALUE str));
@@ -112,13 +125,11 @@ static VALUE strscan_search_full _((VALUE self, VALUE re,
static void adjust_registers_to_matched _((struct strscanner *p));
static VALUE strscan_getch _((VALUE self));
static VALUE strscan_get_byte _((VALUE self));
-static VALUE strscan_getbyte _((VALUE self));
static VALUE strscan_peek _((VALUE self, VALUE len));
-static VALUE strscan_peep _((VALUE self, VALUE len));
+static VALUE strscan_scan_base10_integer _((VALUE self));
static VALUE strscan_unscan _((VALUE self));
static VALUE strscan_bol_p _((VALUE self));
static VALUE strscan_eos_p _((VALUE self));
-static VALUE strscan_empty_p _((VALUE self));
static VALUE strscan_rest_p _((VALUE self));
static VALUE strscan_matched_p _((VALUE self));
static VALUE strscan_matched _((VALUE self));
@@ -171,12 +182,35 @@ extract_beg_len(struct strscanner *p, long beg_i, long len)
Constructor
======================================================================= */
+#ifdef RUBY_TYPED_EMBEDDABLE
+# define HAVE_RUBY_TYPED_EMBEDDABLE 1
+#else
+# ifdef HAVE_CONST_RUBY_TYPED_EMBEDDABLE
+# define RUBY_TYPED_EMBEDDABLE RUBY_TYPED_EMBEDDABLE
+# define HAVE_RUBY_TYPED_EMBEDDABLE 1
+# else
+# define RUBY_TYPED_EMBEDDABLE 0
+# endif
+#endif
+
+#ifdef HAVE_RB_GC_LOCATION
+static void
+strscan_compact(void *ptr)
+{
+ struct strscanner *p = ptr;
+ p->str = rb_gc_location(p->str);
+ p->regex = rb_gc_location(p->regex);
+}
+#else
+#define rb_gc_mark_movable rb_gc_mark
+#endif
+
static void
strscan_mark(void *ptr)
{
struct strscanner *p = ptr;
- rb_gc_mark(p->str);
- rb_gc_mark(p->regex);
+ rb_gc_mark_movable(p->str);
+ rb_gc_mark_movable(p->regex);
}
static void
@@ -184,24 +218,37 @@ strscan_free(void *ptr)
{
struct strscanner *p = ptr;
onig_region_free(&(p->regs), 0);
+#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
ruby_xfree(p);
+#endif
}
static size_t
strscan_memsize(const void *ptr)
{
- const struct strscanner *p = ptr;
- size_t size = sizeof(*p) - sizeof(p->regs);
+ size_t size = 0;
+#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
+ size += sizeof(struct strscanner);
+#endif
+
#ifdef HAVE_ONIG_REGION_MEMSIZE
- size += onig_region_memsize(&p->regs);
+ const struct strscanner *p = ptr;
+ size += onig_region_memsize(&p->regs) - sizeof(p->regs);
#endif
return size;
}
static const rb_data_type_t strscanner_type = {
- "StringScanner",
- {strscan_mark, strscan_free, strscan_memsize},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ .wrap_struct_name = "StringScanner",
+ .function = {
+ .dmark = strscan_mark,
+ .dfree = strscan_free,
+ .dsize = strscan_memsize,
+#ifdef HAVE_RB_GC_LOCATION
+ .dcompact = strscan_compact,
+#endif
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static VALUE
@@ -213,21 +260,32 @@ strscan_s_allocate(VALUE klass)
CLEAR_MATCH_STATUS(p);
onig_region_init(&(p->regs));
p->str = Qnil;
- p->regex = Qnil;
return obj;
}
/*
- * call-seq:
- * StringScanner.new(string, fixed_anchor: false)
- * StringScanner.new(string, dup = false)
- *
- * Creates a new StringScanner object to scan over the given +string+.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * If +fixed_anchor+ is +true+, +\A+ always matches the beginning of
- * the string. Otherwise, +\A+ always matches the current position.
+ * call-seq:
+ * StringScanner.new(string, fixed_anchor: false) -> string_scanner
+ *
+ * Returns a new `StringScanner` object whose [stored string][1]
+ * is the given `string`;
+ * sets the [fixed-anchor property][10]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.string # => "foobarbaz"
+ * scanner.fixed_anchor? # => false
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 0
+ * # charpos: 0
+ * # rest: "foobarbaz"
+ * # rest_size: 9
+ * ```
*
- * +dup+ argument is obsolete and not used now.
*/
static VALUE
strscan_initialize(int argc, VALUE *argv, VALUE self)
@@ -254,7 +312,7 @@ strscan_initialize(int argc, VALUE *argv, VALUE self)
p->fixed_anchor_p = false;
}
StringValue(str);
- p->str = str;
+ RB_OBJ_WRITE(self, &p->str, str);
return self;
}
@@ -266,11 +324,14 @@ check_strscan(VALUE obj)
}
/*
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
* call-seq:
- * dup
- * clone
+ * dup -> shallow_copy
*
- * Duplicates a StringScanner object.
+ * Returns a shallow copy of `self`;
+ * the [stored string][1] in the copy is the same string as in `self`.
*/
static VALUE
strscan_init_copy(VALUE vself, VALUE vorig)
@@ -281,7 +342,7 @@ strscan_init_copy(VALUE vself, VALUE vorig)
orig = check_strscan(vorig);
if (self != orig) {
self->flags = orig->flags;
- self->str = orig->str;
+ RB_OBJ_WRITE(vself, &self->str, orig->str);
self->prev = orig->prev;
self->curr = orig->curr;
if (rb_reg_region_copy(&self->regs, &orig->regs))
@@ -297,10 +358,13 @@ strscan_init_copy(VALUE vself, VALUE vorig)
======================================================================= */
/*
- * call-seq: StringScanner.must_C_version
+ * call-seq:
+ * StringScanner.must_C_version -> self
*
- * This method is defined for backward compatibility.
+ * Returns +self+; defined for backward compatibility.
*/
+
+ /* :nodoc: */
static VALUE
strscan_s_mustc(VALUE self)
{
@@ -308,7 +372,30 @@ strscan_s_mustc(VALUE self)
}
/*
- * Reset the scan pointer (index 0) and clear matching data.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * reset -> self
+ *
+ * Sets both [byte position][2] and [character position][7] to zero,
+ * and clears [match values][9];
+ * returns +self+:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.exist?(/bar/) # => 6
+ * scanner.reset # => #<StringScanner 0/9 @ "fooba...">
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 0
+ * # charpos: 0
+ * # rest: "foobarbaz"
+ * # rest_size: 9
+ * # => nil
+ * match_values_cleared?(scanner) # => true
+ * ```
+ *
*/
static VALUE
strscan_reset(VALUE self)
@@ -322,11 +409,12 @@ strscan_reset(VALUE self)
}
/*
- * call-seq:
- * terminate
- * clear
+ * :markup: markdown
+ * :call-seq:
+ * terminate -> self
*
- * Sets the scan pointer to the end of the string and clear matching data.
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/terminate.md
*/
static VALUE
strscan_terminate(VALUE self)
@@ -340,18 +428,21 @@ strscan_terminate(VALUE self)
}
/*
- * Equivalent to #terminate.
- * This method is obsolete; use #terminate instead.
- */
-static VALUE
-strscan_clear(VALUE self)
-{
- rb_warning("StringScanner#clear is obsolete; use #terminate instead");
- return strscan_terminate(self);
-}
-
-/*
- * Returns the string being scanned.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * string -> stored_string
+ *
+ * Returns the [stored string][1]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobar')
+ * scanner.string # => "foobar"
+ * scanner.concat('baz')
+ * scanner.string # => "foobarbaz"
+ * ```
+ *
*/
static VALUE
strscan_get_string(VALUE self)
@@ -363,10 +454,39 @@ strscan_get_string(VALUE self)
}
/*
- * call-seq: string=(str)
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * string = other_string -> other_string
+ *
+ * Replaces the [stored string][1] with the given `other_string`:
+ *
+ * - Sets both [positions][11] to zero.
+ * - Clears [match values][9].
+ * - Returns `other_string`.
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobar')
+ * scanner.scan(/foo/)
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 3
+ * # charpos: 3
+ * # rest: "bar"
+ * # rest_size: 3
+ * match_values_cleared?(scanner) # => false
+ *
+ * scanner.string = 'baz' # => "baz"
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 0
+ * # charpos: 0
+ * # rest: "baz"
+ * # rest_size: 3
+ * match_values_cleared?(scanner) # => true
+ * ```
*
- * Changes the string being scanned to +str+ and resets the scanner.
- * Returns +str+.
*/
static VALUE
strscan_set_string(VALUE self, VALUE str)
@@ -374,25 +494,40 @@ strscan_set_string(VALUE self, VALUE str)
struct strscanner *p = check_strscan(self);
StringValue(str);
- p->str = str;
+ RB_OBJ_WRITE(self, &p->str, str);
p->curr = 0;
CLEAR_MATCH_STATUS(p);
return str;
}
/*
- * call-seq:
- * concat(str)
- * <<(str)
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * Appends +str+ to the string being scanned.
- * This method does not affect scan pointer.
+ * call-seq:
+ * concat(more_string) -> self
+ *
+ * - Appends the given `more_string`
+ * to the [stored string][1].
+ * - Returns `self`.
+ * - Does not affect the [positions][11]
+ * or [match values][9].
+ *
+ *
+ * ```rb
+ * scanner = StringScanner.new('foo')
+ * scanner.string # => "foo"
+ * scanner.terminate
+ * scanner.concat('barbaz') # => #<StringScanner 3/9 "foo" @ "barba...">
+ * scanner.string # => "foobarbaz"
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 3
+ * # charpos: 3
+ * # rest: "barbaz"
+ * # rest_size: 6
+ * ```
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan(/Fri /)
- * s << " +1000 GMT"
- * s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT"
- * s.scan(/Dec/) # -> "Dec"
*/
static VALUE
strscan_concat(VALUE self, VALUE str)
@@ -406,18 +541,12 @@ strscan_concat(VALUE self, VALUE str)
}
/*
- * Returns the byte position of the scan pointer. In the 'reset' position, this
- * value is zero. In the 'terminated' position (i.e. the string is exhausted),
- * this value is the bytesize of the string.
+ * :markup: markdown
+ * :call-seq:
+ * pos -> byte_position
*
- * In short, it's a 0-based index into bytes of the string.
- *
- * s = StringScanner.new('test string')
- * s.pos # -> 0
- * s.scan_until /str/ # -> "test str"
- * s.pos # -> 8
- * s.terminate # -> #<StringScanner fin>
- * s.pos # -> 11
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/get_pos.md
*/
static VALUE
strscan_get_pos(VALUE self)
@@ -425,21 +554,16 @@ strscan_get_pos(VALUE self)
struct strscanner *p;
GET_SCANNER(self, p);
- return INT2FIX(p->curr);
+ return LONG2NUM(p->curr);
}
/*
- * Returns the character position of the scan pointer. In the 'reset' position, this
- * value is zero. In the 'terminated' position (i.e. the string is exhausted),
- * this value is the size of the string.
+ * :markup: markdown
+ * :call-seq:
+ * charpos -> character_position
*
- * In short, it's a 0-based index into the string.
- *
- * s = StringScanner.new("abc\u00e4def\u00f6ghi")
- * s.charpos # -> 0
- * s.scan_until(/\u00e4/) # -> "abc\u00E4"
- * s.pos # -> 5
- * s.charpos # -> 4
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/get_charpos.md
*/
static VALUE
strscan_get_charpos(VALUE self)
@@ -452,13 +576,13 @@ strscan_get_charpos(VALUE self)
}
/*
- * call-seq: pos=(n)
- *
- * Sets the byte position of the scan pointer.
+ * :markup: markdown
+ * :call-seq:
+ * pos = n -> n
+ * pointer = n -> n
*
- * s = StringScanner.new('test string')
- * s.pos = 7 # -> 7
- * s.rest # -> "ring"
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/set_pos.md
*/
static VALUE
strscan_set_pos(VALUE self, VALUE v)
@@ -467,7 +591,7 @@ strscan_set_pos(VALUE self, VALUE v)
long i;
GET_SCANNER(self, p);
- i = NUM2INT(v);
+ i = NUM2LONG(v);
if (i < 0) i += S_LEN(p);
if (i < 0) rb_raise(rb_eRangeError, "index out of range");
if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range");
@@ -488,19 +612,20 @@ match_target(struct strscanner *p)
}
static inline void
-set_registers(struct strscanner *p, size_t length)
+set_registers(struct strscanner *p, size_t pos, size_t length)
{
const int at = 0;
OnigRegion *regs = &(p->regs);
onig_region_clear(regs);
if (onig_region_set(regs, at, 0, 0)) return;
if (p->fixed_anchor_p) {
- regs->beg[at] = p->curr;
- regs->end[at] = p->curr + length;
+ regs->beg[at] = pos + p->curr;
+ regs->end[at] = pos + p->curr + length;
}
else
{
- regs->end[at] = length;
+ regs->beg[at] = pos;
+ regs->end[at] = pos + length;
}
}
@@ -539,19 +664,82 @@ adjust_register_position(struct strscanner *p, long position)
}
}
-static VALUE
-strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly)
+/* rb_reg_onig_match is available in Ruby 3.3 and later. */
+#ifndef HAVE_RB_REG_ONIG_MATCH
+static OnigPosition
+rb_reg_onig_match(VALUE re, VALUE str,
+ OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args),
+ void *args, struct re_registers *regs)
{
- struct strscanner *p;
+ OnigPosition result;
+ regex_t *reg = rb_reg_prepare_re(re, str);
+
+ bool tmpreg = reg != RREGEXP_PTR(re);
+ if (!tmpreg) RREGEXP(re)->usecnt++;
+
+ result = match(reg, str, regs, args);
+
+ if (!tmpreg) RREGEXP(re)->usecnt--;
+ if (tmpreg) {
+ if (RREGEXP(re)->usecnt) {
+ onig_free(reg);
+ }
+ else {
+ onig_free(RREGEXP_PTR(re));
+ RREGEXP_PTR(re) = reg;
+ }
+ }
- if (headonly) {
- if (!RB_TYPE_P(pattern, T_REGEXP)) {
- StringValue(pattern);
+ if (result < 0) {
+ if (result != ONIG_MISMATCH) {
+ rb_raise(ScanError, "regexp buffer overflow");
}
}
- else {
- Check_Type(pattern, T_REGEXP);
+
+ return result;
+}
+#endif
+
+static OnigPosition
+strscan_match(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr)
+{
+ struct strscanner *p = (struct strscanner *)args_ptr;
+
+ return onig_match(reg,
+ match_target(p),
+ (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p),
+ regs,
+ ONIG_OPTION_NONE);
+}
+
+static OnigPosition
+strscan_search(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr)
+{
+ struct strscanner *p = (struct strscanner *)args_ptr;
+
+ return onig_search(reg,
+ match_target(p),
+ (UChar *)(CURPTR(p) + S_RESTLEN(p)),
+ (UChar *)CURPTR(p),
+ (UChar *)(CURPTR(p) + S_RESTLEN(p)),
+ regs,
+ ONIG_OPTION_NONE);
+}
+
+static void
+strscan_enc_check(VALUE str1, VALUE str2)
+{
+ if (RB_ENCODING_GET(str1) != RB_ENCODING_GET(str2)) {
+ rb_enc_check(str1, str2);
}
+}
+
+static VALUE
+strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly)
+{
+ struct strscanner *p;
+
GET_SCANNER(self, p);
CLEAR_MATCH_STATUS(p);
@@ -560,59 +748,42 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
}
if (RB_TYPE_P(pattern, T_REGEXP)) {
- regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
- regex_t *re;
- long ret;
- int tmpreg;
-
- p->regex = pattern;
- re = rb_reg_prepare_re(pattern, p->str);
- tmpreg = re != RREGEXP_PTR(pattern);
- if (!tmpreg) RREGEXP(pattern)->usecnt++;
-
- if (headonly) {
- ret = onig_match(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- else {
- ret = onig_search(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- if (!tmpreg) RREGEXP(pattern)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(pattern)->usecnt) {
- onig_free(re);
- }
- else {
- onig_free(RREGEXP_PTR(pattern));
- RREGEXP_PTR(pattern) = re;
- }
- }
-
- if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
- if (ret < 0) {
- /* not matched */
+ OnigPosition ret;
+ RB_OBJ_WRITE(self, &p->regex, pattern);
+ ret = rb_reg_onig_match(p->regex,
+ p->str,
+ headonly ? strscan_match : strscan_search,
+ (void *)p,
+ &(p->regs));
+
+ if (ret == ONIG_MISMATCH) {
return Qnil;
}
}
else {
- rb_enc_check(p->str, pattern);
+ StringValue(pattern);
if (S_RESTLEN(p) < RSTRING_LEN(pattern)) {
+ strscan_enc_check(p->str, pattern);
return Qnil;
}
- if (memcmp(CURPTR(p), RSTRING_PTR(pattern), RSTRING_LEN(pattern)) != 0) {
- return Qnil;
+
+ if (headonly) {
+ strscan_enc_check(p->str, pattern);
+
+ if (memcmp(CURPTR(p), RSTRING_PTR(pattern), RSTRING_LEN(pattern)) != 0) {
+ return Qnil;
+ }
+ set_registers(p, 0, RSTRING_LEN(pattern));
+ }
+ else {
+ rb_encoding *enc = rb_enc_check(p->str, pattern);
+ long pos = rb_memsearch(RSTRING_PTR(pattern), RSTRING_LEN(pattern),
+ CURPTR(p), S_RESTLEN(p), enc);
+ if (pos == -1) {
+ return Qnil;
+ }
+ set_registers(p, pos, RSTRING_LEN(pattern));
}
- set_registers(p, RSTRING_LEN(pattern));
}
MATCHED(p);
@@ -633,20 +804,12 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
}
/*
- * call-seq: scan(pattern) => String
- *
- * Tries to match with +pattern+ at the current position. If there's a match,
- * the scanner advances the "scan pointer" and returns the matched string.
- * Otherwise, the scanner returns +nil+.
- *
- * s = StringScanner.new('test string')
- * p s.scan(/\w+/) # -> "test"
- * p s.scan(/\w+/) # -> nil
- * p s.scan(/\s+/) # -> " "
- * p s.scan("str") # -> "str"
- * p s.scan(/\w+/) # -> "ing"
- * p s.scan(/./) # -> nil
+ * :markup: markdown
+ * :call-seq:
+ * scan(pattern) -> substring or nil
*
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/scan.md
*/
static VALUE
strscan_scan(VALUE self, VALUE re)
@@ -655,16 +818,60 @@ strscan_scan(VALUE self, VALUE re)
}
/*
- * call-seq: match?(pattern)
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * Tests whether the given +pattern+ is matched from the current scan pointer.
- * Returns the length of the match, or +nil+. The scan pointer is not advanced.
+ * call-seq:
+ * match?(pattern) -> match_size or nil
+ *
+ * Attempts to [match][17] the given `pattern`
+ * at the beginning of the [target substring][3];
+ * does not modify the [positions][11].
+ *
+ * If the match succeeds:
+ *
+ * - Sets [match values][9].
+ * - Returns the size in bytes of the matched substring.
+ *
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.pos = 3
+ * scanner.match?(/bar/) => 3
+ * put_match_values(scanner)
+ * # Basic match values:
+ * # matched?: true
+ * # matched_size: 3
+ * # pre_match: "foo"
+ * # matched : "bar"
+ * # post_match: "baz"
+ * # Captured match values:
+ * # size: 1
+ * # captures: []
+ * # named_captures: {}
+ * # values_at: ["bar", nil]
+ * # []:
+ * # [0]: "bar"
+ * # [1]: nil
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 3
+ * # charpos: 3
+ * # rest: "barbaz"
+ * # rest_size: 6
+ * ```
+ *
+ * If the match fails:
+ *
+ * - Clears match values.
+ * - Returns `nil`.
+ * - Does not increment positions.
+ *
+ * ```rb
+ * scanner.match?(/nope/) # => nil
+ * match_values_cleared?(scanner) # => true
+ * ```
*
- * s = StringScanner.new('test string')
- * p s.match?(/\w+/) # -> 4
- * p s.match?(/\w+/) # -> 4
- * p s.match?("test") # -> 4
- * p s.match?(/\s+/) # -> nil
*/
static VALUE
strscan_match_p(VALUE self, VALUE re)
@@ -673,22 +880,12 @@ strscan_match_p(VALUE self, VALUE re)
}
/*
- * call-seq: skip(pattern)
- *
- * Attempts to skip over the given +pattern+ beginning with the scan pointer.
- * If it matches, the scan pointer is advanced to the end of the match, and the
- * length of the match is returned. Otherwise, +nil+ is returned.
- *
- * It's similar to #scan, but without returning the matched string.
- *
- * s = StringScanner.new('test string')
- * p s.skip(/\w+/) # -> 4
- * p s.skip(/\w+/) # -> nil
- * p s.skip(/\s+/) # -> 1
- * p s.skip("st") # -> 2
- * p s.skip(/\w+/) # -> 4
- * p s.skip(/./) # -> nil
+ * :markup: markdown
+ * call-seq:
+ * skip(pattern) -> match_size or nil
*
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/skip.md
*/
static VALUE
strscan_skip(VALUE self, VALUE re)
@@ -697,19 +894,59 @@ strscan_skip(VALUE self, VALUE re)
}
/*
- * call-seq: check(pattern)
- *
- * This returns the value that #scan would return, without advancing the scan
- * pointer. The match register is affected, though.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.check /Fri/ # -> "Fri"
- * s.pos # -> 0
- * s.matched # -> "Fri"
- * s.check /12/ # -> nil
- * s.matched # -> nil
+ * call-seq:
+ * check(pattern) -> matched_substring or nil
+ *
+ * Attempts to [match][17] the given `pattern`
+ * at the beginning of the [target substring][3];
+ * does not modify the [positions][11].
+ *
+ * If the match succeeds:
+ *
+ * - Returns the matched substring.
+ * - Sets all [match values][9].
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.pos = 3
+ * scanner.check('bar') # => "bar"
+ * put_match_values(scanner)
+ * # Basic match values:
+ * # matched?: true
+ * # matched_size: 3
+ * # pre_match: "foo"
+ * # matched : "bar"
+ * # post_match: "baz"
+ * # Captured match values:
+ * # size: 1
+ * # captures: []
+ * # named_captures: {}
+ * # values_at: ["bar", nil]
+ * # []:
+ * # [0]: "bar"
+ * # [1]: nil
+ * # => 0..1
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 3
+ * # charpos: 3
+ * # rest: "barbaz"
+ * # rest_size: 6
+ * ```
+ *
+ * If the match fails:
+ *
+ * - Returns `nil`.
+ * - Clears all [match values][9].
+ *
+ * ```rb
+ * scanner.check(/nope/) # => nil
+ * match_values_cleared?(scanner) # => true
+ * ```
*
- * Mnemonic: it "checks" to see whether a #scan will return a value.
*/
static VALUE
strscan_check(VALUE self, VALUE re)
@@ -718,15 +955,24 @@ strscan_check(VALUE self, VALUE re)
}
/*
- * call-seq: scan_full(pattern, advance_pointer_p, return_string_p)
+ * call-seq:
+ * scan_full(pattern, advance_pointer_p, return_string_p) -> matched_substring or length or nil
+ *
+ * Equivalent to one of the following:
+ *
+ * - +advance_pointer_p+ +true+:
*
- * Tests whether the given +pattern+ is matched from the current scan pointer.
- * Advances the scan pointer if +advance_pointer_p+ is true.
- * Returns the matched string if +return_string_p+ is true.
- * The match register is affected.
+ * - +return_string_p+ +true+: StringScanner#scan(pattern).
+ * - +return_string_p+ +false+: StringScanner#skip(pattern).
+ *
+ * - +advance_pointer_p+ +false+:
+ *
+ * - +return_string_p+ +true+: StringScanner#check(pattern).
+ * - +return_string_p+ +false+: StringScanner#match?(pattern).
*
- * "full" means "#scan with full parameters".
*/
+
+ /* :nodoc: */
static VALUE
strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f)
{
@@ -734,16 +980,12 @@ strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f)
}
/*
- * call-seq: scan_until(pattern)
+ * :markup: markdown
+ * :call-seq:
+ * scan_until(pattern) -> substring or nil
*
- * Scans the string _until_ the +pattern+ is matched. Returns the substring up
- * to and including the end of the match, advancing the scan pointer to that
- * location. If there is no match, +nil+ is returned.
- *
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan_until(/1/) # -> "Fri Dec 1"
- * s.pre_match # -> "Fri Dec "
- * s.scan_until(/XYZ/) # -> nil
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/scan_until.md
*/
static VALUE
strscan_scan_until(VALUE self, VALUE re)
@@ -752,17 +994,61 @@ strscan_scan_until(VALUE self, VALUE re)
}
/*
- * call-seq: exist?(pattern)
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * Looks _ahead_ to see if the +pattern+ exists _anywhere_ in the string,
- * without advancing the scan pointer. This predicates whether a #scan_until
- * will return a value.
+ * call-seq:
+ * exist?(pattern) -> byte_offset or nil
+ *
+ * Attempts to [match][17] the given `pattern`
+ * anywhere (at any [position][2])
+ * n the [target substring][3];
+ * does not modify the [positions][11].
+ *
+ * If the match succeeds:
+ *
+ * - Returns a byte offset:
+ * the distance in bytes between the current [position][2]
+ * and the end of the matched substring.
+ * - Sets all [match values][9].
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbazbatbam')
+ * scanner.pos = 6
+ * scanner.exist?(/bat/) # => 6
+ * put_match_values(scanner)
+ * # Basic match values:
+ * # matched?: true
+ * # matched_size: 3
+ * # pre_match: "foobarbaz"
+ * # matched : "bat"
+ * # post_match: "bam"
+ * # Captured match values:
+ * # size: 1
+ * # captures: []
+ * # named_captures: {}
+ * # values_at: ["bat", nil]
+ * # []:
+ * # [0]: "bat"
+ * # [1]: nil
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 6
+ * # charpos: 6
+ * # rest: "bazbatbam"
+ * # rest_size: 9
+ * ```
+ *
+ * If the match fails:
+ *
+ * - Returns `nil`.
+ * - Clears all [match values][9].
+ *
+ * ```rb
+ * scanner.exist?(/nope/) # => nil
+ * match_values_cleared?(scanner) # => true
+ * ```
*
- * s = StringScanner.new('test string')
- * s.exist? /s/ # -> 3
- * s.scan /test/ # -> "test"
- * s.exist? /s/ # -> 2
- * s.exist? /e/ # -> nil
*/
static VALUE
strscan_exist_p(VALUE self, VALUE re)
@@ -771,20 +1057,12 @@ strscan_exist_p(VALUE self, VALUE re)
}
/*
- * call-seq: skip_until(pattern)
- *
- * Advances the scan pointer until +pattern+ is matched and consumed. Returns
- * the number of bytes advanced, or +nil+ if no match was found.
+ * :markup: markdown
+ * :call-seq:
+ * skip_until(pattern) -> matched_substring_size or nil
*
- * Look ahead to match +pattern+, and advance the scan pointer to the _end_
- * of the match. Return the number of characters advanced, or +nil+ if the
- * match was unsuccessful.
- *
- * It's similar to #scan_until, but without returning the intervening string.
- *
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.skip_until /12/ # -> 10
- * s #
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/skip_until.md
*/
static VALUE
strscan_skip_until(VALUE self, VALUE re)
@@ -793,17 +1071,61 @@ strscan_skip_until(VALUE self, VALUE re)
}
/*
- * call-seq: check_until(pattern)
- *
- * This returns the value that #scan_until would return, without advancing the
- * scan pointer. The match register is affected, though.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.check_until /12/ # -> "Fri Dec 12"
- * s.pos # -> 0
- * s.matched # -> 12
+ * call-seq:
+ * check_until(pattern) -> substring or nil
+ *
+ * Attempts to [match][17] the given `pattern`
+ * anywhere (at any [position][2])
+ * in the [target substring][3];
+ * does not modify the [positions][11].
+ *
+ * If the match succeeds:
+ *
+ * - Sets all [match values][9].
+ * - Returns the matched substring,
+ * which extends from the current [position][2]
+ * to the end of the matched substring.
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbazbatbam')
+ * scanner.pos = 6
+ * scanner.check_until(/bat/) # => "bazbat"
+ * put_match_values(scanner)
+ * # Basic match values:
+ * # matched?: true
+ * # matched_size: 3
+ * # pre_match: "foobarbaz"
+ * # matched : "bat"
+ * # post_match: "bam"
+ * # Captured match values:
+ * # size: 1
+ * # captures: []
+ * # named_captures: {}
+ * # values_at: ["bat", nil]
+ * # []:
+ * # [0]: "bat"
+ * # [1]: nil
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 6
+ * # charpos: 6
+ * # rest: "bazbatbam"
+ * # rest_size: 9
+ * ```
+ *
+ * If the match fails:
+ *
+ * - Clears all [match values][9].
+ * - Returns `nil`.
+ *
+ * ```rb
+ * scanner.check_until(/nope/) # => nil
+ * match_values_cleared?(scanner) # => true
+ * ```
*
- * Mnemonic: it "checks" to see whether a #scan_until will return a value.
*/
static VALUE
strscan_check_until(VALUE self, VALUE re)
@@ -812,14 +1134,24 @@ strscan_check_until(VALUE self, VALUE re)
}
/*
- * call-seq: search_full(pattern, advance_pointer_p, return_string_p)
+ * call-seq:
+ * search_full(pattern, advance_pointer_p, return_string_p) -> matched_substring or position_delta or nil
+ *
+ * Equivalent to one of the following:
+ *
+ * - +advance_pointer_p+ +true+:
+ *
+ * - +return_string_p+ +true+: StringScanner#scan_until(pattern).
+ * - +return_string_p+ +false+: StringScanner#skip_until(pattern).
+ *
+ * - +advance_pointer_p+ +false+:
+ *
+ * - +return_string_p+ +true+: StringScanner#check_until(pattern).
+ * - +return_string_p+ +false+: StringScanner#exist?(pattern).
*
- * Scans the string _until_ the +pattern+ is matched.
- * Advances the scan pointer if +advance_pointer_p+, otherwise not.
- * Returns the matched string if +return_string_p+ is true, otherwise
- * returns the number of bytes advanced.
- * This method does affect the match register.
*/
+
+ /* :nodoc: */
static VALUE
strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f)
{
@@ -839,17 +1171,12 @@ adjust_registers_to_matched(struct strscanner *p)
}
/*
- * Scans one character and returns it.
- * This method is multibyte character sensitive.
- *
- * s = StringScanner.new("ab")
- * s.getch # => "a"
- * s.getch # => "b"
- * s.getch # => nil
+ * :markup: markdown
+ * :call-seq:
+ * getch -> character or nil
*
- * s = StringScanner.new("\244\242".force_encoding("euc-jp"))
- * s.getch # => "\x{A4A2}" # Japanese hira-kana "A" in EUC-JP
- * s.getch # => nil
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/getch.md
*/
static VALUE
strscan_getch(VALUE self)
@@ -874,59 +1201,95 @@ strscan_getch(VALUE self)
}
/*
- * Scans one byte and returns it.
+ * call-seq:
+ * scan_byte -> integer_byte or nil
+ *
+ * Scans one byte and returns it as an integer.
* This method is not multibyte character sensitive.
* See also: #getch.
*
- * s = StringScanner.new('ab')
- * s.get_byte # => "a"
- * s.get_byte # => "b"
- * s.get_byte # => nil
- *
- * s = StringScanner.new("\244\242".force_encoding("euc-jp"))
- * s.get_byte # => "\xA4"
- * s.get_byte # => "\xA2"
- * s.get_byte # => nil
*/
static VALUE
-strscan_get_byte(VALUE self)
+strscan_scan_byte(VALUE self)
{
struct strscanner *p;
+ VALUE byte;
GET_SCANNER(self, p);
CLEAR_MATCH_STATUS(p);
if (EOS_P(p))
return Qnil;
+ byte = INT2FIX((unsigned char)*CURPTR(p));
p->prev = p->curr;
p->curr++;
MATCHED(p);
adjust_registers_to_matched(p);
- return extract_range(p,
- adjust_register_position(p, p->regs.beg[0]),
- adjust_register_position(p, p->regs.end[0]));
+ return byte;
}
/*
- * Equivalent to #get_byte.
- * This method is obsolete; use #get_byte instead.
+ * Peeks at the current byte and returns it as an integer.
+ *
+ * s = StringScanner.new('ab')
+ * s.peek_byte # => 97
*/
static VALUE
-strscan_getbyte(VALUE self)
+strscan_peek_byte(VALUE self)
{
- rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead");
- return strscan_get_byte(self);
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p))
+ return Qnil;
+
+ return INT2FIX((unsigned char)*CURPTR(p));
+}
+
+/*
+ * :markup: markdown
+ * :call-seq:
+ * get_byte -> byte_as_character or nil
+ *
+ * :include: strscan/link_refs.txt
+ * :include: strscan/methods/get_byte.md
+ */
+static VALUE
+strscan_get_byte(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p))
+ return Qnil;
+
+ p->prev = p->curr;
+ p->curr++;
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+ return extract_range(p,
+ adjust_register_position(p, p->regs.beg[0]),
+ adjust_register_position(p, p->regs.end[0]));
}
/*
- * call-seq: peek(len)
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * Extracts a string corresponding to <tt>string[pos,len]</tt>, without
- * advancing the scan pointer.
+ * call-seq:
+ * peek(length) -> substring
*
- * s = StringScanner.new('test string')
- * s.peek(7) # => "test st"
- * s.peek(7) # => "test st"
+ * Returns the substring `string[pos, length]`;
+ * does not update [match values][9] or [positions][11]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.pos = 3
+ * scanner.peek(3) # => "bar"
+ * scanner.terminate
+ * scanner.peek(3) # => ""
+ * ```
*
*/
static VALUE
@@ -945,27 +1308,161 @@ strscan_peek(VALUE self, VALUE vlen)
return extract_beg_len(p, p->curr, len);
}
-/*
- * Equivalent to #peek.
- * This method is obsolete; use #peek instead.
- */
static VALUE
-strscan_peep(VALUE self, VALUE vlen)
+strscan_parse_integer(struct strscanner *p, int base, long len)
+{
+ VALUE buffer_v, integer;
+
+ char *buffer = RB_ALLOCV_N(char, buffer_v, len + 1);
+
+ MEMCPY(buffer, CURPTR(p), char, len);
+ buffer[len] = '\0';
+ integer = rb_cstr2inum(buffer, base);
+ RB_ALLOCV_END(buffer_v);
+ p->curr += len;
+
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+
+ return integer;
+}
+
+static inline bool
+strscan_ascii_compat_fastpath(VALUE str)
+{
+ int encindex = ENCODING_GET_INLINED(str);
+ /* The overwhelming majority of strings are in one of these 3 encodings. */
+ return encindex == utf8_encindex || encindex == binary_encindex || encindex == usascii_encindex;
+}
+
+static inline void
+strscan_must_ascii_compat(VALUE str)
{
- rb_warning("StringScanner#peep is obsolete; use #peek instead");
- return strscan_peek(self, vlen);
+ /* The overwhelming majority of strings are in one of these 3 encodings. */
+ if (RB_LIKELY(strscan_ascii_compat_fastpath(str))) {
+ return;
+ }
+
+ rb_must_asciicompat(str);
+}
+
+/* :nodoc: */
+static VALUE
+strscan_scan_base10_integer(VALUE self)
+{
+ char *ptr;
+ long len = 0, remaining_len;
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+
+ strscan_must_ascii_compat(p->str);
+
+ ptr = CURPTR(p);
+
+ remaining_len = S_RESTLEN(p);
+
+ if (remaining_len <= 0) {
+ return Qnil;
+ }
+
+ if (ptr[len] == '-' || ptr[len] == '+') {
+ len++;
+ }
+
+ if (!rb_isdigit(ptr[len])) {
+ return Qnil;
+ }
+
+ p->prev = p->curr;
+
+ while (len < remaining_len && rb_isdigit(ptr[len])) {
+ len++;
+ }
+
+ return strscan_parse_integer(p, 10, len);
+}
+
+/* :nodoc: */
+static VALUE
+strscan_scan_base16_integer(VALUE self)
+{
+ char *ptr;
+ long len = 0, remaining_len;
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+
+ strscan_must_ascii_compat(p->str);
+
+ ptr = CURPTR(p);
+
+ remaining_len = S_RESTLEN(p);
+
+ if (remaining_len <= 0) {
+ return Qnil;
+ }
+
+ if (ptr[len] == '-' || ptr[len] == '+') {
+ len++;
+ }
+
+ if ((remaining_len >= (len + 3)) && ptr[len] == '0' && ptr[len + 1] == 'x' && rb_isxdigit(ptr[len + 2])) {
+ len += 2;
+ }
+
+ if (len >= remaining_len || !rb_isxdigit(ptr[len])) {
+ return Qnil;
+ }
+
+ p->prev = p->curr;
+
+ while (len < remaining_len && rb_isxdigit(ptr[len])) {
+ len++;
+ }
+
+ return strscan_parse_integer(p, 16, len);
}
/*
- * Sets the scan pointer to the previous position. Only one previous position is
- * remembered, and it changes with each scanning operation.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * unscan -> self
+ *
+ * Sets the [position][2] to its value previous to the recent successful
+ * [match][17] attempt:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.scan(/foo/)
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 3
+ * # charpos: 3
+ * # rest: "barbaz"
+ * # rest_size: 6
+ * scanner.unscan
+ * # => #<StringScanner 0/9 @ "fooba...">
+ * put_situation(scanner)
+ * # Situation:
+ * # pos: 0
+ * # charpos: 0
+ * # rest: "foobarbaz"
+ * # rest_size: 9
+ * ```
+ *
+ * Raises an exception if match values are clear:
+ *
+ * ```rb
+ * scanner.scan(/nope/) # => nil
+ * match_values_cleared?(scanner) # => true
+ * scanner.unscan # Raises StringScanner::Error.
+ * ```
*
- * s = StringScanner.new('test string')
- * s.scan(/\w+/) # => "test"
- * s.unscan
- * s.scan(/../) # => "te"
- * s.scan(/\d/) # => nil
- * s.unscan # ScanError: unscan failed: previous match record not exist
*/
static VALUE
strscan_unscan(VALUE self)
@@ -981,16 +1478,37 @@ strscan_unscan(VALUE self)
}
/*
- * Returns +true+ if and only if the scan pointer is at the beginning of the line.
- *
- * s = StringScanner.new("test\ntest\n")
- * s.bol? # => true
- * s.scan(/te/)
- * s.bol? # => false
- * s.scan(/st\n/)
- * s.bol? # => true
- * s.terminate
- * s.bol? # => true
+ *
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * beginning_of_line? -> true or false
+ *
+ * Returns whether the [position][2] is at the beginning of a line;
+ * that is, at the beginning of the [stored string][1]
+ * or immediately after a newline:
+ *
+ * scanner = StringScanner.new(MULTILINE_TEXT)
+ * scanner.string
+ * # => "Go placidly amid the noise and haste,\nand remember what peace there may be in silence.\n"
+ * scanner.pos # => 0
+ * scanner.beginning_of_line? # => true
+ *
+ * scanner.scan_until(/,/) # => "Go placidly amid the noise and haste,"
+ * scanner.beginning_of_line? # => false
+ *
+ * scanner.scan(/\n/) # => "\n"
+ * scanner.beginning_of_line? # => true
+ *
+ * scanner.terminate
+ * scanner.beginning_of_line? # => true
+ *
+ * scanner.concat('x')
+ * scanner.terminate
+ * scanner.beginning_of_line? # => false
+ *
+ * StringScanner#bol? is an alias for StringScanner#beginning_of_line?.
*/
static VALUE
strscan_bol_p(VALUE self)
@@ -1004,14 +1522,24 @@ strscan_bol_p(VALUE self)
}
/*
- * Returns +true+ if the scan pointer is at the end of the string.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * eos? -> true or false
+ *
+ * Returns whether the [position][2]
+ * is at the end of the [stored string][1]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.eos? # => false
+ * pos = 3
+ * scanner.eos? # => false
+ * scanner.terminate
+ * scanner.eos? # => true
+ * ```
*
- * s = StringScanner.new('test string')
- * p s.eos? # => false
- * s.scan(/test/)
- * p s.eos? # => false
- * s.terminate
- * p s.eos? # => true
*/
static VALUE
strscan_eos_p(VALUE self)
@@ -1023,25 +1551,18 @@ strscan_eos_p(VALUE self)
}
/*
- * Equivalent to #eos?.
- * This method is obsolete, use #eos? instead.
- */
-static VALUE
-strscan_empty_p(VALUE self)
-{
- rb_warning("StringScanner#empty? is obsolete; use #eos? instead");
- return strscan_eos_p(self);
-}
-
-/*
+ * call-seq:
+ * rest?
+ *
* Returns true if and only if there is more data in the string. See #eos?.
- * This method is obsolete; use #eos? instead.
*
* s = StringScanner.new('test string')
* # These two are opposites
* s.eos? # => false
* s.rest? # => true
*/
+
+ /* :nodoc: */
static VALUE
strscan_rest_p(VALUE self)
{
@@ -1052,13 +1573,26 @@ strscan_rest_p(VALUE self)
}
/*
- * Returns +true+ if and only if the last match was successful.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * matched? -> true or false
+ *
+ * Returns `true` of the most recent [match attempt][17] was successful,
+ * `false` otherwise;
+ * see [Basic Matched Values][18]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.matched? # => false
+ * scanner.pos = 3
+ * scanner.exist?(/baz/) # => 6
+ * scanner.matched? # => true
+ * scanner.exist?(/nope/) # => nil
+ * scanner.matched? # => false
+ * ```
*
- * s = StringScanner.new('test string')
- * s.match?(/\w+/) # => 4
- * s.matched? # => true
- * s.match?(/\d+/) # => nil
- * s.matched? # => false
*/
static VALUE
strscan_matched_p(VALUE self)
@@ -1070,11 +1604,27 @@ strscan_matched_p(VALUE self)
}
/*
- * Returns the last matched string.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * matched -> matched_substring or nil
+ *
+ * Returns the matched substring from the most recent [match][17] attempt
+ * if it was successful,
+ * or `nil` otherwise;
+ * see [Basic Matched Values][18]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.matched # => nil
+ * scanner.pos = 3
+ * scanner.match?(/bar/) # => 3
+ * scanner.matched # => "bar"
+ * scanner.match?(/nope/) # => nil
+ * scanner.matched # => nil
+ * ```
*
- * s = StringScanner.new('test string')
- * s.match?(/\w+/) # -> 4
- * s.matched # -> "test"
*/
static VALUE
strscan_matched(VALUE self)
@@ -1089,15 +1639,29 @@ strscan_matched(VALUE self)
}
/*
- * Returns the size of the most recent match in bytes, or +nil+ if there
- * was no recent match. This is different than <tt>matched.size</tt>,
- * which will return the size in characters.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * matched_size -> substring_size or nil
+ *
+ * Returns the size (in bytes) of the matched substring
+ * from the most recent match [match attempt][17] if it was successful,
+ * or `nil` otherwise;
+ * see [Basic Matched Values][18]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.matched_size # => nil
+ *
+ * pos = 3
+ * scanner.exist?(/baz/) # => 9
+ * scanner.matched_size # => 3
+ *
+ * scanner.exist?(/nope/) # => nil
+ * scanner.matched_size # => nil
+ * ```
*
- * s = StringScanner.new('test string')
- * s.check /\w+/ # -> "test"
- * s.matched_size # -> 4
- * s.check /\d+/ # -> nil
- * s.matched_size # -> nil
*/
static VALUE
strscan_matched_size(VALUE self)
@@ -1112,75 +1676,131 @@ strscan_matched_size(VALUE self)
static int
name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end, rb_encoding *enc)
{
- int num;
-
- num = onig_name_to_backref_number(RREGEXP_PTR(regexp),
- (const unsigned char* )name, (const unsigned char* )name_end, regs);
- if (num >= 1) {
- return num;
- }
- else {
- rb_enc_raise(enc, rb_eIndexError, "undefined group name reference: %.*s",
- rb_long2int(name_end - name), name);
+ if (RTEST(regexp)) {
+ int num = onig_name_to_backref_number(RREGEXP_PTR(regexp),
+ (const unsigned char* )name,
+ (const unsigned char* )name_end,
+ regs);
+ if (num >= 1) {
+ return num;
+ }
}
-
- UNREACHABLE;
+ rb_enc_raise(enc, rb_eIndexError, "undefined group name reference: %.*s",
+ rb_long2int(name_end - name), name);
}
/*
- * call-seq: [](n)
- *
- * Returns the n-th subgroup in the most recent match.
- *
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
- * s[0] # -> "Fri Dec 12 "
- * s[1] # -> "Fri"
- * s[2] # -> "Dec"
- * s[3] # -> "12"
- * s.post_match # -> "1975 14:39"
- * s.pre_match # -> ""
- *
- * s.reset
- * s.scan(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /) # -> "Fri Dec 12 "
- * s[0] # -> "Fri Dec 12 "
- * s[1] # -> "Fri"
- * s[2] # -> "Dec"
- * s[3] # -> "12"
- * s[:wday] # -> "Fri"
- * s[:month] # -> "Dec"
- * s[:day] # -> "12"
- * s.post_match # -> "1975 14:39"
- * s.pre_match # -> ""
+ * Resolve capture group index from Integer, Symbol, or String.
+ * Returns the resolved register index, or -1 if unmatched/out of range.
+ * For Symbol/String specifiers, raises IndexError if the named group
+ * does not exist.
*/
-static VALUE
-strscan_aref(VALUE self, VALUE idx)
+static long
+resolve_capture_index(struct strscanner *p, VALUE specifier)
{
const char *name;
- struct strscanner *p;
long i;
-
- GET_SCANNER(self, p);
- if (! MATCHED_P(p)) return Qnil;
-
- switch (TYPE(idx)) {
+ if (! MATCHED_P(p)) return -1;
+ switch (TYPE(specifier)) {
case T_SYMBOL:
- idx = rb_sym2str(idx);
+ specifier = rb_sym2str(specifier);
/* fall through */
case T_STRING:
- if (!RTEST(p->regex)) return Qnil;
- RSTRING_GETMEM(idx, name, i);
- i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx));
+ RSTRING_GETMEM(specifier, name, i);
+ i = name_to_backref_number(&(p->regs), p->regex, name, name + i,
+ rb_enc_get(specifier));
break;
default:
- i = NUM2LONG(idx);
+ i = NUM2LONG(specifier);
}
-
if (i < 0)
i += p->regs.num_regs;
- if (i < 0) return Qnil;
- if (i >= p->regs.num_regs) return Qnil;
- if (p->regs.beg[i] == -1) return Qnil;
+ if (i < 0) return -1;
+ if (i >= p->regs.num_regs) return -1;
+ if (p->regs.beg[i] == -1) return -1;
+ return i;
+}
+
+/*
+ *
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * [](specifier) -> substring or nil
+ *
+ * Returns a captured substring or `nil`;
+ * see [Captured Match Values][13].
+ *
+ * When there are captures:
+ *
+ * ```rb
+ * scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+ * scanner.scan(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /)
+ * ```
+ *
+ * - `specifier` zero: returns the entire matched substring:
+ *
+ * ```rb
+ * scanner[0] # => "Fri Dec 12 "
+ * scanner.pre_match # => ""
+ * scanner.post_match # => "1975 14:39"
+ * ```
+ *
+ * - `specifier` positive integer. returns the `n`th capture, or `nil` if out of range:
+ *
+ * ```rb
+ * scanner[1] # => "Fri"
+ * scanner[2] # => "Dec"
+ * scanner[3] # => "12"
+ * scanner[4] # => nil
+ * ```
+ *
+ * - `specifier` negative integer. counts backward from the last subgroup:
+ *
+ * ```rb
+ * scanner[-1] # => "12"
+ * scanner[-4] # => "Fri Dec 12 "
+ * scanner[-5] # => nil
+ * ```
+ *
+ * - `specifier` symbol or string. returns the named subgroup, or `nil` if no such:
+ *
+ * ```rb
+ * scanner[:wday] # => "Fri"
+ * scanner['wday'] # => "Fri"
+ * scanner[:month] # => "Dec"
+ * scanner[:day] # => "12"
+ * scanner[:nope] # => nil
+ * ```
+ *
+ * When there are no captures, only `[0]` returns non-`nil`:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.exist?(/bar/)
+ * scanner[0] # => "bar"
+ * scanner[1] # => nil
+ * ```
+ *
+ * For a failed match, even `[0]` returns `nil`:
+ *
+ * ```rb
+ * scanner.scan(/nope/) # => nil
+ * scanner[0] # => nil
+ * scanner[1] # => nil
+ * ```
+ *
+ */
+static VALUE
+strscan_aref(VALUE self, VALUE idx)
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ i = resolve_capture_index(p, idx);
+ if (i < 0) return Qnil;
return extract_range(p,
adjust_register_position(p, p->regs.beg[i]),
@@ -1188,14 +1808,103 @@ strscan_aref(VALUE self, VALUE idx)
}
/*
- * call-seq: size
+ * :markup: markdown
+ *
+ * call-seq:
+ * integer_at(specifier, base=10) -> integer or nil
+ *
+ * Returns the captured substring at the given `specifier` as an Integer,
+ * following the behavior of `String#to_i(base)`.
+ *
+ * `specifier` can be an Integer (positive, negative, or zero), a Symbol,
+ * or a String for named capture groups.
+ *
+ * Returns `nil` if:
+ * - No match has been performed or the last match failed
+ * - The `specifier` is an Integer and is out of range
+ * - The group at `specifier` did not participate in the match
+ *
+ * Raises IndexError if `specifier` is a Symbol or String that does not
+ * correspond to a named capture group, consistent with
+ * `StringScanner#[]`.
*
- * Returns the amount of subgroups in the most recent match.
- * The full match counts as a subgroup.
+ * This is semantically equivalent to `self[specifier]&.to_i(base)`
+ * but avoids the allocation of a temporary String when possible.
+ *
+ * ```rb
+ * scanner = StringScanner.new("2024-06-15")
+ * scanner.scan(/(\d{4})-(\d{2})-(\d{2})/)
+ * scanner.integer_at(1) # => 2024
+ * scanner.integer_at(1, 16) # => 8228
+ * ```
+ */
+static VALUE
+strscan_integer_at(int argc, VALUE *argv, VALUE self)
+{
+ struct strscanner *p;
+ long i;
+ long beg, end, len;
+ const char *ptr;
+ VALUE rb_specifier;
+ VALUE rb_base;
+ int base = 10;
+
+ GET_SCANNER(self, p);
+ rb_scan_args(argc, argv, "11", &rb_specifier, &rb_base);
+ if (argc > 1)
+ base = NUM2INT(rb_base);
+ i = resolve_capture_index(p, rb_specifier);
+ if (i < 0)
+ return Qnil;
+
+ beg = adjust_register_position(p, p->regs.beg[i]);
+ end = adjust_register_position(p, p->regs.end[i]);
+ len = end - beg;
+ ptr = S_PBEG(p) + beg;
+#ifdef HAVE_RB_INT_PARSE_CSTR
+ {
+ /*
+ * Ruby 2.5 or later export the rb_int_parse_cstr() symbol but
+ * prototype definition isn't provided. Ruby 4.1 or later
+ * provide prototype definition.
+ */
+# ifndef RB_INT_PARSE_DEFAULT
+ VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp,
+ size_t *ndigits, int base, int flags);
+# define RB_INT_PARSE_DEFAULT 0x07
+# endif
+ char *endp;
+ return rb_int_parse_cstr(ptr, len, &endp, NULL, base,
+ RB_INT_PARSE_DEFAULT);
+ }
+#else
+ return rb_str_to_inum(rb_str_new(ptr, len), base, 0);
+#endif
+}
+
+/*
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * size -> captures_count
+ *
+ * Returns the count of captures if the most recent match attempt succeeded, `nil` otherwise;
+ * see [Captures Match Values][13]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+ * scanner.size # => nil
+ *
+ * pattern = /(?<wday>\w+) (?<month>\w+) (?<day>\d+) /
+ * scanner.match?(pattern)
+ * scanner.values_at(*0..scanner.size) # => ["Fri Dec 12 ", "Fri", "Dec", "12", nil]
+ * scanner.size # => 4
+ *
+ * scanner.match?(/nope/) # => nil
+ * scanner.size # => nil
+ * ```
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
- * s.size # -> 4
*/
static VALUE
strscan_size(VALUE self)
@@ -1208,16 +1917,30 @@ strscan_size(VALUE self)
}
/*
- * call-seq: captures
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * captures -> substring_array or nil
+ *
+ * Returns the array of [captured match values][13] at indexes `(1..)`
+ * if the most recent match attempt succeeded, or `nil` otherwise:
+ *
+ * ```rb
+ * scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+ * scanner.captures # => nil
+ *
+ * scanner.exist?(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /)
+ * scanner.captures # => ["Fri", "Dec", "12"]
+ * scanner.values_at(*0..4) # => ["Fri Dec 12 ", "Fri", "Dec", "12", nil]
*
- * Returns the subgroups in the most recent match (not including the full match).
- * If nothing was priorly matched, it returns nil.
+ * scanner.exist?(/Fri/)
+ * scanner.captures # => []
+ *
+ * scanner.scan(/nope/)
+ * scanner.captures # => nil
+ * ```
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
- * s.captures # -> ["Fri", "Dec", "12"]
- * s.scan(/(\w+) (\w+) (\d+) /) # -> nil
- * s.captures # -> nil
*/
static VALUE
strscan_captures(VALUE self)
@@ -1233,9 +1956,13 @@ strscan_captures(VALUE self)
new_ary = rb_ary_new2(num_regs);
for (i = 1; i < num_regs; i++) {
- VALUE str = extract_range(p,
- adjust_register_position(p, p->regs.beg[i]),
- adjust_register_position(p, p->regs.end[i]));
+ VALUE str;
+ if (p->regs.beg[i] == -1)
+ str = Qnil;
+ else
+ str = extract_range(p,
+ adjust_register_position(p, p->regs.beg[i]),
+ adjust_register_position(p, p->regs.end[i]));
rb_ary_push(new_ary, str);
}
@@ -1243,17 +1970,25 @@ strscan_captures(VALUE self)
}
/*
- * call-seq:
- * scanner.values_at( i1, i2, ... iN ) -> an_array
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * values_at(*specifiers) -> array_of_captures or nil
+ *
+ * Returns an array of captured substrings, or `nil` of none.
*
- * Returns the subgroups in the most recent match at the given indices.
- * If nothing was priorly matched, it returns nil.
+ * For each `specifier`, the returned substring is `[specifier]`;
+ * see #[].
+ *
+ * ```rb
+ * scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+ * pattern = /(?<wday>\w+) (?<month>\w+) (?<day>\d+) /
+ * scanner.match?(pattern)
+ * scanner.values_at(*0..3) # => ["Fri Dec 12 ", "Fri", "Dec", "12"]
+ * scanner.values_at(*%i[wday month day]) # => ["Fri", "Dec", "12"]
+ * ```
*
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
- * s.values_at 0, -1, 5, 2 # -> ["Fri Dec 12 ", "12", nil, "Dec"]
- * s.scan(/(\w+) (\w+) (\d+) /) # -> nil
- * s.values_at 0, -1, 5, 2 # -> nil
*/
static VALUE
@@ -1275,13 +2010,29 @@ strscan_values_at(int argc, VALUE *argv, VALUE self)
}
/*
- * Returns the <i><b>pre</b>-match</i> (in the regular expression sense) of the last scan.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * pre_match -> substring
+ *
+ * Returns the substring that precedes the matched substring
+ * from the most recent match attempt if it was successful,
+ * or `nil` otherwise;
+ * see [Basic Match Values][18]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.pre_match # => nil
+ *
+ * scanner.pos = 3
+ * scanner.exist?(/baz/) # => 6
+ * scanner.pre_match # => "foobar" # Substring of entire string, not just target string.
+ *
+ * scanner.exist?(/nope/) # => nil
+ * scanner.pre_match # => nil
+ * ```
*
- * s = StringScanner.new('test string')
- * s.scan(/\w+/) # -> "test"
- * s.scan(/\s+/) # -> " "
- * s.pre_match # -> "test"
- * s.post_match # -> "string"
*/
static VALUE
strscan_pre_match(VALUE self)
@@ -1296,13 +2047,29 @@ strscan_pre_match(VALUE self)
}
/*
- * Returns the <i><b>post</b>-match</i> (in the regular expression sense) of the last scan.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * post_match -> substring
+ *
+ * Returns the substring that follows the matched substring
+ * from the most recent match attempt if it was successful,
+ * or `nil` otherwise;
+ * see [Basic Match Values][18]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.post_match # => nil
+ *
+ * scanner.pos = 3
+ * scanner.match?(/bar/) # => 3
+ * scanner.post_match # => "baz"
+ *
+ * scanner.match?(/nope/) # => nil
+ * scanner.post_match # => nil
+ * ```
*
- * s = StringScanner.new('test string')
- * s.scan(/\w+/) # -> "test"
- * s.scan(/\s+/) # -> " "
- * s.pre_match # -> "test"
- * s.post_match # -> "string"
*/
static VALUE
strscan_post_match(VALUE self)
@@ -1317,8 +2084,24 @@ strscan_post_match(VALUE self)
}
/*
- * Returns the "rest" of the string (i.e. everything after the scan pointer).
- * If there is no more data (eos? = true), it returns <tt>""</tt>.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * rest -> target_substring
+ *
+ * Returns the 'rest' of the [stored string][1] (all after the current [position][2]),
+ * which is the [target substring][3]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.rest # => "foobarbaz"
+ * scanner.pos = 3
+ * scanner.rest # => "barbaz"
+ * scanner.terminate
+ * scanner.rest # => ""
+ * ```
+ *
*/
static VALUE
strscan_rest(VALUE self)
@@ -1333,7 +2116,26 @@ strscan_rest(VALUE self)
}
/*
- * <tt>s.rest_size</tt> is equivalent to <tt>s.rest.size</tt>.
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * rest_size -> integer
+ *
+ * Returns the size (in bytes) of the #rest of the [stored string][1]:
+ *
+ * ```rb
+ * scanner = StringScanner.new('foobarbaz')
+ * scanner.rest # => "foobarbaz"
+ * scanner.rest_size # => 9
+ * scanner.pos = 3
+ * scanner.rest # => "barbaz"
+ * scanner.rest_size # => 6
+ * scanner.terminate
+ * scanner.rest # => ""
+ * scanner.rest_size # => 0
+ * ```
+ *
*/
static VALUE
strscan_rest_size(VALUE self)
@@ -1349,29 +2151,42 @@ strscan_rest_size(VALUE self)
return INT2FIX(i);
}
-/*
- * <tt>s.restsize</tt> is equivalent to <tt>s.rest_size</tt>.
- * This method is obsolete; use #rest_size instead.
- */
-static VALUE
-strscan_restsize(VALUE self)
-{
- rb_warning("StringScanner#restsize is obsolete; use #rest_size instead");
- return strscan_rest_size(self);
-}
-
#define INSPECT_LENGTH 5
/*
- * Returns a string that represents the StringScanner object, showing:
- * - the current position
- * - the size of the string
- * - the characters surrounding the scan pointer
- *
- * s = StringScanner.new("Fri Dec 12 1975 14:39")
- * s.inspect # -> '#<StringScanner 0/21 @ "Fri D...">'
- * s.scan_until /12/ # -> "Fri Dec 12"
- * s.inspect # -> '#<StringScanner 10/21 "...ec 12" @ " 1975...">'
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
+ * call-seq:
+ * inspect -> string
+ *
+ * Returns a string representation of `self` that may show:
+ *
+ * 1. The current [position][2].
+ * 2. The size (in bytes) of the [stored string][1].
+ * 3. The substring preceding the current position.
+ * 4. The substring following the current position (which is also the [target substring][3]).
+ *
+ * ```rb
+ * scanner = StringScanner.new("Fri Dec 12 1975 14:39")
+ * scanner.pos = 11
+ * scanner.inspect # => "#<StringScanner 11/21 \"...c 12 \" @ \"1975 ...\">"
+ * ```
+ *
+ * If at beginning-of-string, item 4 above (following substring) is omitted:
+ *
+ * ```rb
+ * scanner.reset
+ * scanner.inspect # => "#<StringScanner 0/21 @ \"Fri D...\">"
+ * ```
+ *
+ * If at end-of-string, all items above are omitted:
+ *
+ * ```rb
+ * scanner.terminate
+ * scanner.inspect # => "#<StringScanner fin>"
+ * ```
+ *
*/
static VALUE
strscan_inspect(VALUE self)
@@ -1443,13 +2258,13 @@ inspect2(struct strscanner *p)
}
/*
- * call-seq:
- * scanner.fixed_anchor? -> true or false
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
*
- * Whether +scanner+ uses fixed anchor mode or not.
+ * call-seq:
+ * fixed_anchor? -> true or false
*
- * If fixed anchor mode is used, +\A+ always matches the beginning of
- * the string. Otherwise, +\A+ always matches the current position.
+ * Returns whether the [fixed-anchor property][10] is set.
*/
static VALUE
strscan_fixed_anchor_p(VALUE self)
@@ -1478,31 +2293,54 @@ named_captures_iter(const OnigUChar *name,
VALUE value = RUBY_Qnil;
int i;
for (i = 0; i < back_num; i++) {
- value = strscan_aref(data->self, INT2NUM(back_refs[i]));
+ VALUE v = strscan_aref(data->self, INT2NUM(back_refs[i]));
+ if (!RB_NIL_P(v)) {
+ value = v;
+ }
}
rb_hash_aset(data->captures, key, value);
return 0;
}
/*
+ * :markup: markdown
+ * :include: strscan/link_refs.txt
+ *
* call-seq:
- * scanner.named_captures -> hash
+ * named_captures -> hash
+ *
+ * Returns a hash of named captures for the most recent regexp match,
+ * or an empty hash if there are no named captures;
+ * see [Captured Match Values][13]:
*
- * Returns a hash of string variables matching the regular expression.
+ * ```rb
+ * scanner = StringScanner.new('Fri Dec 12 1975 14:39')
+ * scanner.named_captures # => {}
+ *
+ * pattern = /(?<wday>\w+) (?<month>\w+) (?<day>\d+) /
+ * scanner.match?(pattern)
+ * scanner.named_captures # => {"wday"=>"Fri", "month"=>"Dec", "day"=>"12"}
+ *
+ * scanner.string = 'nope'
+ * scanner.match?(pattern)
+ * scanner.named_captures # => {"wday"=>nil, "month"=>nil, "day"=>nil}
+ *
+ * scanner.match?(/nosuch/)
+ * scanner.named_captures # => {}
+ * ```
*
- * scan = StringScanner.new('foobarbaz')
- * scan.match?(/(?<f>foo)(?<r>bar)(?<z>baz)/)
- * scan.named_captures # -> {"f"=>"foo", "r"=>"bar", "z"=>"baz"}
*/
static VALUE
strscan_named_captures(VALUE self)
{
struct strscanner *p;
- GET_SCANNER(self, p);
named_captures_data data;
+ GET_SCANNER(self, p);
data.self = self;
data.captures = rb_hash_new();
- onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
+ if (!RB_NIL_P(p->regex)) {
+ onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
+ }
return data.captures;
}
@@ -1512,109 +2350,20 @@ strscan_named_captures(VALUE self)
======================================================================= */
/*
- * Document-class: StringScanner
- *
- * StringScanner provides for lexical scanning operations on a String. Here is
- * an example of its usage:
- *
- * require 'strscan'
- *
- * s = StringScanner.new('This is an example string')
- * s.eos? # -> false
- *
- * p s.scan(/\w+/) # -> "This"
- * p s.scan(/\w+/) # -> nil
- * p s.scan(/\s+/) # -> " "
- * p s.scan(/\s+/) # -> nil
- * p s.scan(/\w+/) # -> "is"
- * s.eos? # -> false
- *
- * p s.scan(/\s+/) # -> " "
- * p s.scan(/\w+/) # -> "an"
- * p s.scan(/\s+/) # -> " "
- * p s.scan(/\w+/) # -> "example"
- * p s.scan(/\s+/) # -> " "
- * p s.scan(/\w+/) # -> "string"
- * s.eos? # -> true
- *
- * p s.scan(/\s+/) # -> nil
- * p s.scan(/\w+/) # -> nil
- *
- * Scanning a string means remembering the position of a <i>scan pointer</i>,
- * which is just an index. The point of scanning is to move forward a bit at
- * a time, so matches are sought after the scan pointer; usually immediately
- * after it.
- *
- * Given the string "test string", here are the pertinent scan pointer
- * positions:
- *
- * t e s t s t r i n g
- * 0 1 2 ... 1
- * 0
- *
- * When you #scan for a pattern (a regular expression), the match must occur
- * at the character after the scan pointer. If you use #scan_until, then the
- * match can occur anywhere after the scan pointer. In both cases, the scan
- * pointer moves <i>just beyond</i> the last character of the match, ready to
- * scan again from the next character onwards. This is demonstrated by the
- * example above.
- *
- * == Method Categories
- *
- * There are other methods besides the plain scanners. You can look ahead in
- * the string without actually scanning. You can access the most recent match.
- * You can modify the string being scanned, reset or terminate the scanner,
- * find out or change the position of the scan pointer, skip ahead, and so on.
- *
- * === Advancing the Scan Pointer
+ * Document-class: StringScanner::Error
*
- * - #getch
- * - #get_byte
- * - #scan
- * - #scan_until
- * - #skip
- * - #skip_until
- *
- * === Looking Ahead
- *
- * - #check
- * - #check_until
- * - #exist?
- * - #match?
- * - #peek
- *
- * === Finding Where we Are
- *
- * - #beginning_of_line? (<tt>#bol?</tt>)
- * - #eos?
- * - #rest?
- * - #rest_size
- * - #pos
- *
- * === Setting Where we Are
- *
- * - #reset
- * - #terminate
- * - #pos=
- *
- * === Match Data
- *
- * - #matched
- * - #matched?
- * - #matched_size
- * - <tt>#[]</tt>
- * - #pre_match
- * - #post_match
+ * The error class for StringScanner.
+ * See StringScanner#unscan.
+ */
+
+/*
+ * Document-class: StringScanner
*
- * === Miscellaneous
+ * :markup: markdown
*
- * - <tt><<</tt>
- * - #concat
- * - #string
- * - #string=
- * - #unscan
+ * :include: strscan/link_refs.txt
+ * :include: strscan/strscan.md
*
- * There are aliases to several of the methods.
*/
void
Init_strscan(void)
@@ -1627,12 +2376,15 @@ Init_strscan(void)
ID id_scanerr = rb_intern("ScanError");
VALUE tmp;
- id_byteslice = rb_intern("byteslice");
+ usascii_encindex = rb_usascii_encindex();
+ utf8_encindex = rb_utf8_encindex();
+ binary_encindex = rb_ascii8bit_encindex();
StringScanner = rb_define_class("StringScanner", rb_cObject);
ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError);
if (!rb_const_defined(rb_cObject, id_scanerr)) {
rb_const_set(rb_cObject, id_scanerr, ScanError);
+ rb_deprecate_constant(rb_cObject, "ScanError");
}
tmp = rb_str_new2(STRSCAN_VERSION);
rb_obj_freeze(tmp);
@@ -1640,6 +2392,7 @@ Init_strscan(void)
tmp = rb_str_new2("$Id$");
rb_obj_freeze(tmp);
rb_const_set(StringScanner, rb_intern("Id"), tmp);
+ rb_deprecate_constant(StringScanner, "Id");
rb_define_alloc_func(StringScanner, strscan_s_allocate);
rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1);
@@ -1647,7 +2400,6 @@ Init_strscan(void)
rb_define_singleton_method(StringScanner, "must_C_version", strscan_s_mustc, 0);
rb_define_method(StringScanner, "reset", strscan_reset, 0);
rb_define_method(StringScanner, "terminate", strscan_terminate, 0);
- rb_define_method(StringScanner, "clear", strscan_clear, 0);
rb_define_method(StringScanner, "string", strscan_get_string, 0);
rb_define_method(StringScanner, "string=", strscan_set_string, 1);
rb_define_method(StringScanner, "concat", strscan_concat, 1);
@@ -1672,22 +2424,25 @@ Init_strscan(void)
rb_define_method(StringScanner, "getch", strscan_getch, 0);
rb_define_method(StringScanner, "get_byte", strscan_get_byte, 0);
- rb_define_method(StringScanner, "getbyte", strscan_getbyte, 0);
+ rb_define_method(StringScanner, "scan_byte", strscan_scan_byte, 0);
rb_define_method(StringScanner, "peek", strscan_peek, 1);
- rb_define_method(StringScanner, "peep", strscan_peep, 1);
+ rb_define_method(StringScanner, "peek_byte", strscan_peek_byte, 0);
+
+ rb_define_private_method(StringScanner, "scan_base10_integer", strscan_scan_base10_integer, 0);
+ rb_define_private_method(StringScanner, "scan_base16_integer", strscan_scan_base16_integer, 0);
rb_define_method(StringScanner, "unscan", strscan_unscan, 0);
rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0);
rb_alias(StringScanner, rb_intern("bol?"), rb_intern("beginning_of_line?"));
rb_define_method(StringScanner, "eos?", strscan_eos_p, 0);
- rb_define_method(StringScanner, "empty?", strscan_empty_p, 0);
rb_define_method(StringScanner, "rest?", strscan_rest_p, 0);
rb_define_method(StringScanner, "matched?", strscan_matched_p, 0);
rb_define_method(StringScanner, "matched", strscan_matched, 0);
rb_define_method(StringScanner, "matched_size", strscan_matched_size, 0);
rb_define_method(StringScanner, "[]", strscan_aref, 1);
+ rb_define_method(StringScanner, "integer_at", strscan_integer_at, -1);
rb_define_method(StringScanner, "pre_match", strscan_pre_match, 0);
rb_define_method(StringScanner, "post_match", strscan_post_match, 0);
rb_define_method(StringScanner, "size", strscan_size, 0);
@@ -1696,7 +2451,6 @@ Init_strscan(void)
rb_define_method(StringScanner, "rest", strscan_rest, 0);
rb_define_method(StringScanner, "rest_size", strscan_rest_size, 0);
- rb_define_method(StringScanner, "restsize", strscan_restsize, 0);
rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
diff --git a/ext/strscan/strscan.gemspec b/ext/strscan/strscan.gemspec
index 8a61c7abe6..a51285fa7e 100644
--- a/ext/strscan/strscan.gemspec
+++ b/ext/strscan/strscan.gemspec
@@ -16,19 +16,27 @@ Gem::Specification.new do |s|
s.summary = "Provides lexical scanning operations on a String."
s.description = "Provides lexical scanning operations on a String."
- files = [
- "COPYING",
- "LICENSE.txt",
+ files = %w[
+ COPYING
+ LICENSE.txt
+ lib/strscan.rb
+ lib/strscan/strscan.rb
+ lib/strscan/truffleruby.rb
]
+
+ s.require_paths = %w{lib}
+
if RUBY_ENGINE == "jruby"
- s.require_paths = %w{ext/jruby/lib lib}
- files << "ext/jruby/lib/strscan.rb"
files << "lib/strscan.jar"
s.platform = "java"
else
- s.require_paths = %w{lib}
files << "ext/strscan/extconf.rb"
files << "ext/strscan/strscan.c"
+ s.rdoc_options << "-idoc"
+ s.extra_rdoc_files = [
+ ".rdoc_options",
+ *Dir.glob("doc/strscan/**/*")
+ ]
s.extensions = %w{ext/strscan/extconf.rb}
end
s.files = files
diff --git a/ext/syslog/depend b/ext/syslog/depend
deleted file mode 100644
index ee4ac5f47d..0000000000
--- a/ext/syslog/depend
+++ /dev/null
@@ -1,161 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-syslog.o: $(RUBY_EXTCONF_H)
-syslog.o: $(arch_hdrdir)/ruby/config.h
-syslog.o: $(hdrdir)/ruby/assert.h
-syslog.o: $(hdrdir)/ruby/backward.h
-syslog.o: $(hdrdir)/ruby/backward/2/assume.h
-syslog.o: $(hdrdir)/ruby/backward/2/attributes.h
-syslog.o: $(hdrdir)/ruby/backward/2/bool.h
-syslog.o: $(hdrdir)/ruby/backward/2/inttypes.h
-syslog.o: $(hdrdir)/ruby/backward/2/limits.h
-syslog.o: $(hdrdir)/ruby/backward/2/long_long.h
-syslog.o: $(hdrdir)/ruby/backward/2/stdalign.h
-syslog.o: $(hdrdir)/ruby/backward/2/stdarg.h
-syslog.o: $(hdrdir)/ruby/defines.h
-syslog.o: $(hdrdir)/ruby/intern.h
-syslog.o: $(hdrdir)/ruby/internal/abi.h
-syslog.o: $(hdrdir)/ruby/internal/anyargs.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-syslog.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-syslog.o: $(hdrdir)/ruby/internal/assume.h
-syslog.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-syslog.o: $(hdrdir)/ruby/internal/attr/artificial.h
-syslog.o: $(hdrdir)/ruby/internal/attr/cold.h
-syslog.o: $(hdrdir)/ruby/internal/attr/const.h
-syslog.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-syslog.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-syslog.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-syslog.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-syslog.o: $(hdrdir)/ruby/internal/attr/error.h
-syslog.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-syslog.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-syslog.o: $(hdrdir)/ruby/internal/attr/format.h
-syslog.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-syslog.o: $(hdrdir)/ruby/internal/attr/noalias.h
-syslog.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-syslog.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-syslog.o: $(hdrdir)/ruby/internal/attr/noinline.h
-syslog.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-syslog.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-syslog.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
-syslog.o: $(hdrdir)/ruby/internal/attr/pure.h
-syslog.o: $(hdrdir)/ruby/internal/attr/restrict.h
-syslog.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-syslog.o: $(hdrdir)/ruby/internal/attr/warning.h
-syslog.o: $(hdrdir)/ruby/internal/attr/weakref.h
-syslog.o: $(hdrdir)/ruby/internal/cast.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-syslog.o: $(hdrdir)/ruby/internal/compiler_since.h
-syslog.o: $(hdrdir)/ruby/internal/config.h
-syslog.o: $(hdrdir)/ruby/internal/constant_p.h
-syslog.o: $(hdrdir)/ruby/internal/core.h
-syslog.o: $(hdrdir)/ruby/internal/core/rarray.h
-syslog.o: $(hdrdir)/ruby/internal/core/rbasic.h
-syslog.o: $(hdrdir)/ruby/internal/core/rbignum.h
-syslog.o: $(hdrdir)/ruby/internal/core/rclass.h
-syslog.o: $(hdrdir)/ruby/internal/core/rdata.h
-syslog.o: $(hdrdir)/ruby/internal/core/rfile.h
-syslog.o: $(hdrdir)/ruby/internal/core/rhash.h
-syslog.o: $(hdrdir)/ruby/internal/core/robject.h
-syslog.o: $(hdrdir)/ruby/internal/core/rregexp.h
-syslog.o: $(hdrdir)/ruby/internal/core/rstring.h
-syslog.o: $(hdrdir)/ruby/internal/core/rstruct.h
-syslog.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-syslog.o: $(hdrdir)/ruby/internal/ctype.h
-syslog.o: $(hdrdir)/ruby/internal/dllexport.h
-syslog.o: $(hdrdir)/ruby/internal/dosish.h
-syslog.o: $(hdrdir)/ruby/internal/error.h
-syslog.o: $(hdrdir)/ruby/internal/eval.h
-syslog.o: $(hdrdir)/ruby/internal/event.h
-syslog.o: $(hdrdir)/ruby/internal/fl_type.h
-syslog.o: $(hdrdir)/ruby/internal/gc.h
-syslog.o: $(hdrdir)/ruby/internal/glob.h
-syslog.o: $(hdrdir)/ruby/internal/globals.h
-syslog.o: $(hdrdir)/ruby/internal/has/attribute.h
-syslog.o: $(hdrdir)/ruby/internal/has/builtin.h
-syslog.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-syslog.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-syslog.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-syslog.o: $(hdrdir)/ruby/internal/has/extension.h
-syslog.o: $(hdrdir)/ruby/internal/has/feature.h
-syslog.o: $(hdrdir)/ruby/internal/has/warning.h
-syslog.o: $(hdrdir)/ruby/internal/intern/array.h
-syslog.o: $(hdrdir)/ruby/internal/intern/bignum.h
-syslog.o: $(hdrdir)/ruby/internal/intern/class.h
-syslog.o: $(hdrdir)/ruby/internal/intern/compar.h
-syslog.o: $(hdrdir)/ruby/internal/intern/complex.h
-syslog.o: $(hdrdir)/ruby/internal/intern/cont.h
-syslog.o: $(hdrdir)/ruby/internal/intern/dir.h
-syslog.o: $(hdrdir)/ruby/internal/intern/enum.h
-syslog.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-syslog.o: $(hdrdir)/ruby/internal/intern/error.h
-syslog.o: $(hdrdir)/ruby/internal/intern/eval.h
-syslog.o: $(hdrdir)/ruby/internal/intern/file.h
-syslog.o: $(hdrdir)/ruby/internal/intern/hash.h
-syslog.o: $(hdrdir)/ruby/internal/intern/io.h
-syslog.o: $(hdrdir)/ruby/internal/intern/load.h
-syslog.o: $(hdrdir)/ruby/internal/intern/marshal.h
-syslog.o: $(hdrdir)/ruby/internal/intern/numeric.h
-syslog.o: $(hdrdir)/ruby/internal/intern/object.h
-syslog.o: $(hdrdir)/ruby/internal/intern/parse.h
-syslog.o: $(hdrdir)/ruby/internal/intern/proc.h
-syslog.o: $(hdrdir)/ruby/internal/intern/process.h
-syslog.o: $(hdrdir)/ruby/internal/intern/random.h
-syslog.o: $(hdrdir)/ruby/internal/intern/range.h
-syslog.o: $(hdrdir)/ruby/internal/intern/rational.h
-syslog.o: $(hdrdir)/ruby/internal/intern/re.h
-syslog.o: $(hdrdir)/ruby/internal/intern/ruby.h
-syslog.o: $(hdrdir)/ruby/internal/intern/select.h
-syslog.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-syslog.o: $(hdrdir)/ruby/internal/intern/signal.h
-syslog.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-syslog.o: $(hdrdir)/ruby/internal/intern/string.h
-syslog.o: $(hdrdir)/ruby/internal/intern/struct.h
-syslog.o: $(hdrdir)/ruby/internal/intern/thread.h
-syslog.o: $(hdrdir)/ruby/internal/intern/time.h
-syslog.o: $(hdrdir)/ruby/internal/intern/variable.h
-syslog.o: $(hdrdir)/ruby/internal/intern/vm.h
-syslog.o: $(hdrdir)/ruby/internal/interpreter.h
-syslog.o: $(hdrdir)/ruby/internal/iterator.h
-syslog.o: $(hdrdir)/ruby/internal/memory.h
-syslog.o: $(hdrdir)/ruby/internal/method.h
-syslog.o: $(hdrdir)/ruby/internal/module.h
-syslog.o: $(hdrdir)/ruby/internal/newobj.h
-syslog.o: $(hdrdir)/ruby/internal/scan_args.h
-syslog.o: $(hdrdir)/ruby/internal/special_consts.h
-syslog.o: $(hdrdir)/ruby/internal/static_assert.h
-syslog.o: $(hdrdir)/ruby/internal/stdalign.h
-syslog.o: $(hdrdir)/ruby/internal/stdbool.h
-syslog.o: $(hdrdir)/ruby/internal/symbol.h
-syslog.o: $(hdrdir)/ruby/internal/value.h
-syslog.o: $(hdrdir)/ruby/internal/value_type.h
-syslog.o: $(hdrdir)/ruby/internal/variable.h
-syslog.o: $(hdrdir)/ruby/internal/warning_push.h
-syslog.o: $(hdrdir)/ruby/internal/xmalloc.h
-syslog.o: $(hdrdir)/ruby/missing.h
-syslog.o: $(hdrdir)/ruby/ruby.h
-syslog.o: $(hdrdir)/ruby/st.h
-syslog.o: $(hdrdir)/ruby/subst.h
-syslog.o: $(hdrdir)/ruby/util.h
-syslog.o: syslog.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/syslog/extconf.rb b/ext/syslog/extconf.rb
deleted file mode 100644
index 1230a4d52e..0000000000
--- a/ext/syslog/extconf.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: false
-# $RoughId: extconf.rb,v 1.3 2001/11/24 17:49:26 knu Exp $
-# $Id$
-
-require 'mkmf'
-
-have_library("log") # for Android
-
-have_header("syslog.h") &&
- have_func("openlog") &&
- have_func("setlogmask") &&
- create_makefile("syslog")
-
diff --git a/ext/syslog/lib/syslog/logger.rb b/ext/syslog/lib/syslog/logger.rb
deleted file mode 100644
index 453ca2785c..0000000000
--- a/ext/syslog/lib/syslog/logger.rb
+++ /dev/null
@@ -1,209 +0,0 @@
-# frozen_string_literal: false
-require 'syslog'
-require 'logger'
-
-##
-# Syslog::Logger is a Logger work-alike that logs via syslog instead of to a
-# file. You can use Syslog::Logger to aggregate logs between multiple
-# machines.
-#
-# By default, Syslog::Logger uses the program name 'ruby', but this can be
-# changed via the first argument to Syslog::Logger.new.
-#
-# NOTE! You can only set the Syslog::Logger program name when you initialize
-# Syslog::Logger for the first time. This is a limitation of the way
-# Syslog::Logger uses syslog (and in some ways, a limitation of the way
-# syslog(3) works). Attempts to change Syslog::Logger's program name after
-# the first initialization will be ignored.
-#
-# === Example
-#
-# The following will log to syslogd on your local machine:
-#
-# require 'syslog/logger'
-#
-# log = Syslog::Logger.new 'my_program'
-# log.info 'this line will be logged via syslog(3)'
-#
-# Also the facility may be set to specify the facility level which will be used:
-#
-# log.info 'this line will be logged using Syslog default facility level'
-#
-# log_local1 = Syslog::Logger.new 'my_program', Syslog::LOG_LOCAL1
-# log_local1.info 'this line will be logged using local1 facility level'
-#
-#
-# You may need to perform some syslog.conf setup first. For a BSD machine add
-# the following lines to /etc/syslog.conf:
-#
-# !my_program
-# *.* /var/log/my_program.log
-#
-# Then touch /var/log/my_program.log and signal syslogd with a HUP
-# (killall -HUP syslogd, on FreeBSD).
-#
-# If you wish to have logs automatically roll over and archive, see the
-# newsyslog.conf(5) and newsyslog(8) man pages.
-
-class Syslog::Logger
- # Default formatter for log messages.
- class Formatter
- def call severity, time, progname, msg
- clean msg
- end
-
- private
-
- ##
- # Clean up messages so they're nice and pretty.
-
- def clean message
- message = message.to_s.strip
- message.gsub!(/\e\[[0-9;]*m/, '') # remove useless ansi color codes
- return message
- end
- end
-
- ##
- # The version of Syslog::Logger you are using.
-
- VERSION = '2.1.0'
-
- ##
- # Maps Logger warning types to syslog(3) warning types.
- #
- # Messages from Ruby applications are not considered as critical as messages
- # from other system daemons using syslog(3), so most messages are reduced by
- # one level. For example, a fatal message for Ruby's Logger is considered
- # an error for syslog(3).
-
- LEVEL_MAP = {
- ::Logger::UNKNOWN => Syslog::LOG_ALERT,
- ::Logger::FATAL => Syslog::LOG_ERR,
- ::Logger::ERROR => Syslog::LOG_WARNING,
- ::Logger::WARN => Syslog::LOG_NOTICE,
- ::Logger::INFO => Syslog::LOG_INFO,
- ::Logger::DEBUG => Syslog::LOG_DEBUG,
- }
-
- ##
- # Returns the internal Syslog object that is initialized when the
- # first instance is created.
-
- def self.syslog
- @@syslog
- end
-
- ##
- # Specifies the internal Syslog object to be used.
-
- def self.syslog= syslog
- @@syslog = syslog
- end
-
- ##
- # Builds a methods for level +meth+.
-
- def self.make_methods meth
- level = ::Logger.const_get(meth.upcase)
- eval <<-EOM, nil, __FILE__, __LINE__ + 1
- def #{meth}(message = nil, &block)
- add(#{level}, message, &block)
- end
-
- def #{meth}?
- level <= #{level}
- end
- EOM
- end
-
- ##
- # :method: unknown
- #
- # Logs a +message+ at the unknown (syslog alert) log level, or logs the
- # message returned from the block.
-
- ##
- # :method: fatal
- #
- # Logs a +message+ at the fatal (syslog err) log level, or logs the message
- # returned from the block.
-
- ##
- # :method: error
- #
- # Logs a +message+ at the error (syslog warning) log level, or logs the
- # message returned from the block.
-
- ##
- # :method: warn
- #
- # Logs a +message+ at the warn (syslog notice) log level, or logs the
- # message returned from the block.
-
- ##
- # :method: info
- #
- # Logs a +message+ at the info (syslog info) log level, or logs the message
- # returned from the block.
-
- ##
- # :method: debug
- #
- # Logs a +message+ at the debug (syslog debug) log level, or logs the
- # message returned from the block.
-
- Logger::Severity::constants.each do |severity|
- make_methods severity.downcase
- end
-
- ##
- # Log level for Logger compatibility.
-
- attr_accessor :level
-
- # Logging formatter, as a +Proc+ that will take four arguments and
- # return the formatted message. The arguments are:
- #
- # +severity+:: The Severity of the log message.
- # +time+:: A Time instance representing when the message was logged.
- # +progname+:: The #progname configured, or passed to the logger method.
- # +msg+:: The _Object_ the user passed to the log message; not necessarily a
- # String.
- #
- # The block should return an Object that can be written to the logging
- # device via +write+. The default formatter is used when no formatter is
- # set.
- attr_accessor :formatter
-
- ##
- # The facility argument is used to specify what type of program is logging the message.
-
- attr_accessor :facility
-
- ##
- # Fills in variables for Logger compatibility. If this is the first
- # instance of Syslog::Logger, +program_name+ may be set to change the logged
- # program name. The +facility+ may be set to specify the facility level which will be used.
- #
- # Due to the way syslog works, only one program name may be chosen.
-
- def initialize program_name = 'ruby', facility = nil
- @level = ::Logger::DEBUG
- @formatter = Formatter.new
-
- @@syslog ||= Syslog.open(program_name)
-
- @facility = (facility || @@syslog.facility)
- end
-
- ##
- # Almost duplicates Logger#add. +progname+ is ignored.
-
- def add severity, message = nil, progname = nil, &block
- severity ||= ::Logger::UNKNOWN
- level <= severity and
- @@syslog.log( (LEVEL_MAP[severity] | @facility), '%s', formatter.call(severity, Time.now, progname, (message || block.call)) )
- true
- end
-end
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
deleted file mode 100644
index 8f3674aa8d..0000000000
--- a/ext/syslog/syslog.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * UNIX Syslog extension for Ruby
- * Amos Gouaux, University of Texas at Dallas
- * <amos+ruby@utdallas.edu>
- * Documented by mathew <meta@pobox.com>
- *
- * $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $
- * $Id$
- */
-
-#include "ruby/ruby.h"
-#include "ruby/util.h"
-#include <syslog.h>
-
-/* Syslog class */
-static VALUE mSyslog;
-/*
- * Module holding all Syslog constants. See Syslog::log and
- * Syslog::open for constant descriptions.
- */
-static VALUE mSyslogConstants;
-/* Module holding Syslog option constants */
-static VALUE mSyslogOption;
-/* Module holding Syslog facility constants */
-static VALUE mSyslogFacility;
-/* Module holding Syslog level constants */
-static VALUE mSyslogLevel;
-/* Module holding Syslog utility macros */
-static VALUE mSyslogMacros;
-
-static const char *syslog_ident = NULL;
-static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
-static int syslog_opened = 0;
-
-/* Package helper routines */
-static void syslog_write(int pri, int argc, VALUE *argv)
-{
- VALUE str;
-
- if (argc < 1) {
- rb_raise(rb_eArgError, "no log message supplied");
- }
-
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "must open syslog before write");
- }
-
- str = rb_f_sprintf(argc, argv);
-
- syslog(pri, "%s", RSTRING_PTR(str));
-}
-
-/* Closes the syslog facility.
- * Raises a runtime exception if it is not open.
- */
-static VALUE mSyslog_close(VALUE self)
-{
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "syslog not opened");
- }
-
- closelog();
-
- xfree((void *)syslog_ident);
- syslog_ident = NULL;
- syslog_options = syslog_facility = syslog_mask = -1;
- syslog_opened = 0;
-
- return Qnil;
-}
-
-/* call-seq:
- * open(ident, options, facility) => syslog
- *
- * :yields: syslog
- *
- * Open the syslog facility.
- * Raises a runtime exception if it is already open.
- *
- * Can be called with or without a code block. If called with a block, the
- * Syslog object created is passed to the block.
- *
- * If the syslog is already open, raises a RuntimeError.
- *
- * +ident+ is a String which identifies the calling program.
- *
- * +options+ is the logical OR of any of the following:
- *
- * LOG_CONS:: If there is an error while sending to the system logger,
- * write directly to the console instead.
- *
- * LOG_NDELAY:: Open the connection now, rather than waiting for the first
- * message to be written.
- *
- * LOG_NOWAIT:: Don't wait for any child processes created while logging
- * messages. (Has no effect on Linux.)
- *
- * LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before
- * opening the connection. (This is the default.)
- *
- * LOG_PERROR:: Print the message to stderr as well as sending it to syslog.
- * (Not in POSIX.1-2001.)
- *
- * LOG_PID:: Include the current process ID with each message.
- *
- * +facility+ describes the type of program opening the syslog, and is
- * the logical OR of any of the following which are defined for the host OS:
- *
- * LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV
- * instead.
- *
- * LOG_AUTHPRIV:: Security or authorization messages which should be kept
- * private.
- *
- * LOG_CONSOLE:: System console message.
- *
- * LOG_CRON:: System task scheduler (cron or at).
- *
- * LOG_DAEMON:: A system daemon which has no facility value of its own.
- *
- * LOG_FTP:: An FTP server.
- *
- * LOG_KERN:: A kernel message (not sendable by user processes, so not of
- * much use to Ruby, but listed here for completeness).
- *
- * LOG_LPR:: Line printer subsystem.
- *
- * LOG_MAIL:: Mail delivery or transport subsystem.
- *
- * LOG_NEWS:: Usenet news system.
- *
- * LOG_NTP:: Network Time Protocol server.
- *
- * LOG_SECURITY:: General security message.
- *
- * LOG_SYSLOG:: Messages generated internally by syslog.
- *
- * LOG_USER:: Generic user-level message.
- *
- * LOG_UUCP:: UUCP subsystem.
- *
- * LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities.
- *
- * Example:
- *
- * Syslog.open("webrick", Syslog::LOG_PID,
- * Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3)
- *
- */
-static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
-{
- VALUE ident, opt, fac;
- const char *ident_ptr;
-
- if (syslog_opened) {
- rb_raise(rb_eRuntimeError, "syslog already open");
- }
-
- rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
-
- if (NIL_P(ident)) {
- ident = rb_gv_get("$0");
- }
- ident_ptr = StringValueCStr(ident);
- syslog_ident = strdup(ident_ptr);
-
- if (NIL_P(opt)) {
- syslog_options = LOG_PID | LOG_CONS;
- } else {
- syslog_options = NUM2INT(opt);
- }
-
- if (NIL_P(fac)) {
- syslog_facility = LOG_USER;
- } else {
- syslog_facility = NUM2INT(fac);
- }
-
- openlog(syslog_ident, syslog_options, syslog_facility);
-
- syslog_opened = 1;
-
- setlogmask(syslog_mask = setlogmask(0));
-
- /* be like File.new.open {...} */
- if (rb_block_given_p()) {
- rb_ensure(rb_yield, self, mSyslog_close, self);
- }
-
- return self;
-}
-
-/* call-seq:
- * reopen(ident, options, facility) => syslog
- *
- * :yields: syslog
- *
- * Closes and then reopens the syslog.
- *
- * Arguments are the same as for open().
- */
-static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self)
-{
- mSyslog_close(self);
-
- return mSyslog_open(argc, argv, self);
-}
-
-/* call-seq:
- * opened?
- *
- * Returns true if the syslog is open.
- */
-static VALUE mSyslog_isopen(VALUE self)
-{
- return syslog_opened ? Qtrue : Qfalse;
-}
-
-/* Returns the identity string used in the last call to open()
- */
-static VALUE mSyslog_ident(VALUE self)
-{
- return syslog_opened ? rb_str_new2(syslog_ident) : Qnil;
-}
-
-/* Returns the options bitmask used in the last call to open()
- */
-static VALUE mSyslog_options(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_options) : Qnil;
-}
-
-/* Returns the facility number used in the last call to open()
- */
-static VALUE mSyslog_facility(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_facility) : Qnil;
-}
-
-/* Returns the log priority mask in effect. The mask is not reset by opening
- * or closing syslog.
- */
-static VALUE mSyslog_get_mask(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_mask) : Qnil;
-}
-
-/* call-seq:
- * mask=(priority_mask)
- *
- * Sets the log priority mask. A method LOG_UPTO is defined to make it easier
- * to set mask values. Example:
- *
- * Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
- *
- * Alternatively, specific priorities can be selected and added together using
- * binary OR. Example:
- *
- * Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT)
- *
- * The priority mask persists through calls to open() and close().
- */
-static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
-{
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
- }
-
- setlogmask(syslog_mask = NUM2INT(mask));
-
- return mask;
-}
-
-/* call-seq:
- * log(priority, format_string, *format_args)
- *
- * Log a message with the specified priority. Example:
- *
- * Syslog.log(Syslog::LOG_CRIT, "Out of disk space")
- * Syslog.log(Syslog::LOG_CRIT, "User %s logged in", ENV['USER'])
- *
- * The priority levels, in descending order, are:
- *
- * LOG_EMERG:: System is unusable
- * LOG_ALERT:: Action needs to be taken immediately
- * LOG_CRIT:: A critical condition has occurred
- * LOG_ERR:: An error occurred
- * LOG_WARNING:: Warning of a possible problem
- * LOG_NOTICE:: A normal but significant condition occurred
- * LOG_INFO:: Informational message
- * LOG_DEBUG:: Debugging information
- *
- * Each priority level also has a shortcut method that logs with it's named priority.
- * As an example, the two following statements would produce the same result:
- *
- * Syslog.log(Syslog::LOG_ALERT, "Out of memory")
- * Syslog.alert("Out of memory")
- *
- */
-static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
-{
- VALUE pri;
-
- rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
-
- argc--;
- pri = *argv++;
-
- if (!FIXNUM_P(pri)) {
- rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri));
- }
-
- syslog_write(FIX2INT(pri), argc, argv);
-
- return self;
-}
-
-/* Returns an inspect() string summarizing the object state.
- */
-static VALUE mSyslog_inspect(VALUE self)
-{
- Check_Type(self, T_MODULE);
-
- if (!syslog_opened)
- return rb_sprintf("<#%"PRIsVALUE": opened=false>", self);
-
- return rb_sprintf("<#%"PRIsVALUE": opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
- self,
- syslog_ident,
- syslog_options,
- syslog_facility,
- syslog_mask);
-}
-
-/* Returns self, for backward compatibility.
- */
-static VALUE mSyslog_instance(VALUE self)
-{
- return self;
-}
-
-#define define_syslog_shortcut_method(pri, name) \
-static VALUE mSyslog_##name(int argc, VALUE *argv, VALUE self) \
-{ \
- syslog_write((pri), argc, argv); \
-\
- return self; \
-}
-
-#ifdef LOG_EMERG
-define_syslog_shortcut_method(LOG_EMERG, emerg)
-#endif
-#ifdef LOG_ALERT
-define_syslog_shortcut_method(LOG_ALERT, alert)
-#endif
-#ifdef LOG_CRIT
-define_syslog_shortcut_method(LOG_CRIT, crit)
-#endif
-#ifdef LOG_ERR
-define_syslog_shortcut_method(LOG_ERR, err)
-#endif
-#ifdef LOG_WARNING
-define_syslog_shortcut_method(LOG_WARNING, warning)
-#endif
-#ifdef LOG_NOTICE
-define_syslog_shortcut_method(LOG_NOTICE, notice)
-#endif
-#ifdef LOG_INFO
-define_syslog_shortcut_method(LOG_INFO, info)
-#endif
-#ifdef LOG_DEBUG
-define_syslog_shortcut_method(LOG_DEBUG, debug)
-#endif
-
-/* call-seq:
- * LOG_MASK(priority_level) => priority_mask
- *
- * Generates a mask bit for a priority level. See #mask=
- */
-static VALUE mSyslogMacros_LOG_MASK(VALUE mod, VALUE pri)
-{
- return INT2FIX(LOG_MASK(NUM2INT(pri)));
-}
-
-/* call-seq:
- * LOG_UPTO(priority_level) => priority_mask
- *
- * Generates a mask value for priority levels at or below the level specified.
- * See #mask=
- */
-static VALUE mSyslogMacros_LOG_UPTO(VALUE mod, VALUE pri)
-{
- return INT2FIX(LOG_UPTO(NUM2INT(pri)));
-}
-
-static VALUE mSyslogMacros_included(VALUE mod, VALUE target)
-{
- rb_extend_object(target, mSyslogMacros);
- return mod;
-}
-
-/* The syslog package provides a Ruby interface to the POSIX system logging
- * facility.
- *
- * Syslog messages are typically passed to a central logging daemon.
- * The daemon may filter them; route them into different files (usually
- * found under /var/log); place them in SQL databases; forward
- * them to centralized logging servers via TCP or UDP; or even alert the
- * system administrator via email, pager or text message.
- *
- * Unlike application-level logging via Logger or Log4r, syslog is designed
- * to allow secure tamper-proof logging.
- *
- * The syslog protocol is standardized in RFC 5424.
- */
-void Init_syslog(void)
-{
-#undef rb_intern
- mSyslog = rb_define_module("Syslog");
-
- mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
-
- mSyslogOption = rb_define_module_under(mSyslog, "Option");
- mSyslogFacility = rb_define_module_under(mSyslog, "Facility");
- mSyslogLevel = rb_define_module_under(mSyslog, "Level");
- mSyslogMacros = rb_define_module_under(mSyslog, "Macros");
-
- rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
- rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
- rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
- rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);
-
- rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
- rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
- rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);
-
- rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
- rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
- rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
- rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);
-
- rb_define_singleton_method(mSyslog, "inspect", mSyslog_inspect, 0);
- rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);
-
- /* Syslog options */
-
-#define rb_define_syslog_option(c) \
- rb_define_const(mSyslogOption, #c, INT2NUM(c))
-
-#ifdef LOG_PID
- rb_define_syslog_option(LOG_PID);
-#endif
-#ifdef LOG_CONS
- rb_define_syslog_option(LOG_CONS);
-#endif
-#ifdef LOG_ODELAY
- rb_define_syslog_option(LOG_ODELAY); /* deprecated */
-#endif
-#ifdef LOG_NDELAY
- rb_define_syslog_option(LOG_NDELAY);
-#endif
-#ifdef LOG_NOWAIT
- rb_define_syslog_option(LOG_NOWAIT); /* deprecated */
-#endif
-#ifdef LOG_PERROR
- rb_define_syslog_option(LOG_PERROR);
-#endif
-
- /* Syslog facilities */
-
-#define rb_define_syslog_facility(c) \
- rb_define_const(mSyslogFacility, #c, INT2NUM(c))
-
-#ifdef LOG_AUTH
- rb_define_syslog_facility(LOG_AUTH);
-#endif
-#ifdef LOG_AUTHPRIV
- rb_define_syslog_facility(LOG_AUTHPRIV);
-#endif
-#ifdef LOG_CONSOLE
- rb_define_syslog_facility(LOG_CONSOLE);
-#endif
-#ifdef LOG_CRON
- rb_define_syslog_facility(LOG_CRON);
-#endif
-#ifdef LOG_DAEMON
- rb_define_syslog_facility(LOG_DAEMON);
-#endif
-#ifdef LOG_FTP
- rb_define_syslog_facility(LOG_FTP);
-#endif
-#ifdef LOG_KERN
- rb_define_syslog_facility(LOG_KERN);
-#endif
-#ifdef LOG_LPR
- rb_define_syslog_facility(LOG_LPR);
-#endif
-#ifdef LOG_MAIL
- rb_define_syslog_facility(LOG_MAIL);
-#endif
-#ifdef LOG_NEWS
- rb_define_syslog_facility(LOG_NEWS);
-#endif
-#ifdef LOG_NTP
- rb_define_syslog_facility(LOG_NTP);
-#endif
-#ifdef LOG_SECURITY
- rb_define_syslog_facility(LOG_SECURITY);
-#endif
-#ifdef LOG_SYSLOG
- rb_define_syslog_facility(LOG_SYSLOG);
-#endif
-#ifdef LOG_USER
- rb_define_syslog_facility(LOG_USER);
-#endif
-#ifdef LOG_UUCP
- rb_define_syslog_facility(LOG_UUCP);
-#endif
-#ifdef LOG_LOCAL0
- rb_define_syslog_facility(LOG_LOCAL0);
-#endif
-#ifdef LOG_LOCAL1
- rb_define_syslog_facility(LOG_LOCAL1);
-#endif
-#ifdef LOG_LOCAL2
- rb_define_syslog_facility(LOG_LOCAL2);
-#endif
-#ifdef LOG_LOCAL3
- rb_define_syslog_facility(LOG_LOCAL3);
-#endif
-#ifdef LOG_LOCAL4
- rb_define_syslog_facility(LOG_LOCAL4);
-#endif
-#ifdef LOG_LOCAL5
- rb_define_syslog_facility(LOG_LOCAL5);
-#endif
-#ifdef LOG_LOCAL6
- rb_define_syslog_facility(LOG_LOCAL6);
-#endif
-#ifdef LOG_LOCAL7
- rb_define_syslog_facility(LOG_LOCAL7);
-#endif
-
- /* Syslog levels and the shortcut methods */
-
-#define rb_define_syslog_level(c, m) \
- rb_define_const(mSyslogLevel, #c, INT2NUM(c)); \
- rb_define_module_function(mSyslog, #m, mSyslog_##m, -1)
-
-#ifdef LOG_EMERG
- rb_define_syslog_level(LOG_EMERG, emerg);
-#endif
-#ifdef LOG_ALERT
- rb_define_syslog_level(LOG_ALERT, alert);
-#endif
-#ifdef LOG_CRIT
- rb_define_syslog_level(LOG_CRIT, crit);
-#endif
-#ifdef LOG_ERR
- rb_define_syslog_level(LOG_ERR, err);
-#endif
-#ifdef LOG_WARNING
- rb_define_syslog_level(LOG_WARNING, warning);
-#endif
-#ifdef LOG_NOTICE
- rb_define_syslog_level(LOG_NOTICE, notice);
-#endif
-#ifdef LOG_INFO
- rb_define_syslog_level(LOG_INFO, info);
-#endif
-#ifdef LOG_DEBUG
- rb_define_syslog_level(LOG_DEBUG, debug);
-#endif
-
- /* Syslog macros */
-
- rb_define_method(mSyslogMacros, "LOG_MASK", mSyslogMacros_LOG_MASK, 1);
- rb_define_method(mSyslogMacros, "LOG_UPTO", mSyslogMacros_LOG_UPTO, 1);
- rb_define_singleton_method(mSyslogMacros, "included", mSyslogMacros_included, 1);
-
- rb_include_module(mSyslogConstants, mSyslogOption);
- rb_include_module(mSyslogConstants, mSyslogFacility);
- rb_include_module(mSyslogConstants, mSyslogLevel);
- rb_funcall(mSyslogConstants, rb_intern("include"), 1, mSyslogMacros);
-
- rb_define_singleton_method(mSyslogConstants, "included", mSyslogMacros_included, 1);
- rb_funcall(mSyslog, rb_intern("include"), 1, mSyslogConstants);
-}
diff --git a/ext/syslog/syslog.gemspec b/ext/syslog/syslog.gemspec
deleted file mode 100644
index 6aa2e9570d..0000000000
--- a/ext/syslog/syslog.gemspec
+++ /dev/null
@@ -1,23 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "syslog"
- spec.version = "0.1.1"
- spec.authors = ["Akinori MUSHA"]
- spec.email = ["knu@idaemons.org"]
-
- spec.summary = %q{Ruby interface for the POSIX system logging facility.}
- spec.description = %q{Ruby interface for the POSIX system logging facility.}
- spec.homepage = "https://github.com/ruby/syslog"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.extensions = ["ext/syslog/extconf.rb"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/ext/syslog/syslog.txt b/ext/syslog/syslog.txt
deleted file mode 100644
index 1507a87924..0000000000
--- a/ext/syslog/syslog.txt
+++ /dev/null
@@ -1,124 +0,0 @@
-.\" syslog.txt - -*- Indented-Text -*-
-$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
-$Id$
-
-UNIX Syslog extension for Ruby
-Amos Gouaux, University of Texas at Dallas
-<amos+ruby@utdallas.edu>
-&
-Akinori MUSHA
-<knu@iDaemons.org>
-
-Contact:
- - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
-
-** Syslog(Module)
-
-Included Modules: Syslog::Constants
-
-require 'syslog'
-
-A Simple wrapper for the UNIX syslog system calls that might be handy
-if you're writing a server in Ruby. For the details of the syslog(8)
-architecture and constants, see the syslog(3) manual page of your
-platform.
-
-Module Methods:
-
- open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER) [{ |syslog| ... }]
-
- Opens syslog with the given options and returns the module
- itself. If a block is given, calls it with an argument of
- itself. If syslog is already opened, raises RuntimeError.
-
- Example:
- Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY,
- Syslog::LOG_FTP)
-
- open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER)
- reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER)
-
- Same as open, but does a close first.
-
- opened?
-
- Returns true if syslog opened, otherwise false.
-
- ident
- options
- facility
-
- Returns the parameters given in the last open, respectively.
- Every call of Syslog::open resets these values.
-
- log(pri, message, ...)
-
- Writes message to syslog.
-
- Example:
- Syslog.log(Syslog::LOG_CRIT, "the sky is falling in %d seconds!", 10)
-
- crit(message, ...)
- emerg(message, ...)
- alert(message, ...)
- err(message, ...)
- warning(message, ...)
- notice(message, ...)
- info(message, ...)
- debug(message, ...)
-
- These are shortcut methods of Syslog::log(). The lineup may
- vary depending on what priorities are defined on your system.
-
- Example:
- Syslog.crit("the sky is falling in %d seconds!", 5)
-
- mask
- mask=(mask)
-
- Returns or sets the log priority mask. The value of the mask
- is persistent and will not be reset by Syslog::open or
- Syslog::close.
-
- Example:
- Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
-
- close
-
- Closes syslog.
-
- inspect
-
- Returns the "inspect" string of the Syslog module.
-
- instance
-
- Returns the module itself. (Just for backward compatibility)
-
- LOG_MASK(pri)
-
- Creates a mask for one priority.
-
- LOG_UPTO(pri)
-
- Creates a mask for all priorities up to pri.
-
-** Syslog::Constants(Module)
-
-require 'syslog'
-include Syslog::Constants
-
-This module includes the LOG_* constants available on the system.
-
-Module Methods:
-
- LOG_MASK(pri)
-
- Creates a mask for one priority.
-
- LOG_UPTO(pri)
-
- Creates a mask for all priorities up to pri.
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
deleted file mode 100644
index b5b99ff684..0000000000
--- a/ext/win32/lib/win32/registry.rb
+++ /dev/null
@@ -1,913 +0,0 @@
-# frozen_string_literal: false
-require 'fiddle/import'
-
-module Win32
-
-=begin rdoc
-= Win32 Registry
-
-win32/registry is registry accessor library for Win32 platform.
-It uses importer 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
-
---- info
-
---- 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 the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp] article.
-
-=end rdoc
-
- WCHAR = Encoding::UTF_16LE
- WCHAR_NUL = "\0".encode(WCHAR).freeze
- WCHAR_CR = "\r".encode(WCHAR).freeze
- WCHAR_SIZE = WCHAR_NUL.bytesize
- LOCALE = Encoding.find(Encoding.locale_charmap)
-
- class Registry
-
- #
- # For detail, see the MSDN[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.
- 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
- module Kernel32
- extend Fiddle::Importer
- dlload "kernel32.dll"
- end
- FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall
- def initialize(code)
- @code = code
- buff = WCHAR_NUL * 1024
- lang = 0
- begin
- len = FormatMessageW.call(0x1200, 0, code, lang, buff, 1024, 0)
- msg = buff.byteslice(0, len * WCHAR_SIZE)
- msg.delete!(WCHAR_CR)
- msg.chomp!
- msg.encode!(LOCALE)
- rescue EncodingError
- raise unless lang == 0
- lang = 0x0409 # en_US
- retry
- end
- super msg
- 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 method 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.to_s)
- end
- end
-
- #
- # Win32 APIs
- #
- module API
- include Constants
- extend Fiddle::Importer
- dlload "advapi32.dll"
- [
- "long RegOpenKeyExW(void *, void *, long, long, void *)",
- "long RegCreateKeyExW(void *, void *, long, long, long, long, void *, void *, void *)",
- "long RegEnumValueW(void *, long, void *, void *, void *, void *, void *, void *)",
- "long RegEnumKeyExW(void *, long, void *, void *, void *, void *, void *, void *)",
- "long RegQueryValueExW(void *, void *, void *, void *, void *, void *)",
- "long RegSetValueExW(void *, void *, long, long, void *, long)",
- "long RegDeleteValueW(void *, void *)",
- "long RegDeleteKeyW(void *, void *)",
- "long RegFlushKey(void *)",
- "long RegCloseKey(void *)",
- "long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
- ].each do |fn|
- cfunc = extern fn, :stdcall
- const_set cfunc.name.intern, cfunc
- end
-
- module_function
-
- def check(result)
- raise Error, result, caller(1) if result != 0
- end
-
- def win64?
- /^(?:x64|x86_64)/ =~ RUBY_PLATFORM
- end
-
- def packhandle(h)
- win64? ? packqw(h) : packdw(h)
- end
-
- def unpackhandle(h)
- win64? ? unpackqw(h) : unpackdw(h)
- 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 make_wstr(str)
- str.encode(WCHAR)
- end
-
- def OpenKey(hkey, name, opt, desired)
- result = packhandle(0)
- check RegOpenKeyExW.call(hkey, make_wstr(name), opt, desired, result)
- unpackhandle(result)
- end
-
- def CreateKey(hkey, name, opt, desired)
- result = packhandle(0)
- disp = packdw(0)
- check RegCreateKeyExW.call(hkey, make_wstr(name), 0, 0, opt, desired,
- 0, result, disp)
- [ unpackhandle(result), unpackdw(disp) ]
- end
-
- def EnumValue(hkey, index)
- name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
- size = packdw(Constants::MAX_KEY_LENGTH)
- check RegEnumValueW.call(hkey, index, name, size, 0, 0, 0, 0)
- name.byteslice(0, unpackdw(size) * WCHAR_SIZE)
- end
-
- def EnumKey(hkey, index)
- name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
- size = packdw(Constants::MAX_KEY_LENGTH)
- wtime = ' ' * 8
- check RegEnumKeyExW.call(hkey, index, name, size, 0, 0, 0, wtime)
- [ name.byteslice(0, unpackdw(size) * WCHAR_SIZE), unpackqw(wtime) ]
- end
-
- def QueryValue(hkey, name)
- type = packdw(0)
- size = packdw(0)
- name = make_wstr(name)
- check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
- data = "\0".force_encoding('ASCII-8BIT') * unpackdw(size)
- check RegQueryValueExW.call(hkey, name, 0, type, data, size)
- [ unpackdw(type), data[0, unpackdw(size)] ]
- end
-
- def SetValue(hkey, name, type, data, size)
- case type
- when REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
- data = data.encode(WCHAR)
- size ||= data.bytesize + WCHAR_SIZE
- end
- check RegSetValueExW.call(hkey, make_wstr(name), 0, type, data, size)
- end
-
- def DeleteValue(hkey, name)
- check RegDeleteValueW.call(hkey, make_wstr(name))
- end
-
- def DeleteKey(hkey, name)
- check RegDeleteKeyW.call(hkey, make_wstr(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
-
- #
- # Replace %\w+% into the environment value of what is contained between the %'s
- # This method is used for REG_EXPAND_SZ.
- #
- # For detail, see expandEnvironmentStrings[http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp] \Win32 \API.
- #
- def self.expand_environ(str)
- str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) {
- v = $1.encode(LOCALE)
- (e = ENV[v] || ENV[v.upcase]; e.encode(str.encoding) if e) ||
- $&
- }
- 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
- ].inject([]) do |ary, type|
- type.freeze
- ary[Constants.const_get(type)] = type
- ary
- end.freeze
-
- #
- # Convert registry type value to readable string.
- #
- def self.type2name(type)
- @@type2name[type] || type.to_s
- end
-
- #
- # Convert 64-bit FILETIME integer into Time object.
- #
- def self.wtime2time(wtime)
- Time.at((wtime - 116444736000000000) / 10000000)
- end
-
- #
- # Convert Time object or Integer object into 64-bit FILETIME.
- #
- def self.time2wtime(time)
- time.to_i * 10000000 + 116444736000000000
- end
-
- #
- # constructor
- #
- private_class_method :new
-
- #
- # --- 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 the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp].
- # If block is given, the key is closed automatically.
- 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
-
- #
- # --- 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.
- #
- 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
-
- # Returns key handle value.
- attr_reader :hkey
- # Win32::Registry object of parent key, or nil if predefeined key.
- attr_reader :parent
- # Same as subkey value of Registry.open or
- # Registry.create method.
- attr_reader :keyname
- # Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).
- attr_reader :disposition
-
- #
- # Returns if key is created ((*newly*)).
- # (see Registry.create) -- basically you call create
- # then when you call created? on the instance returned
- # it will tell if it was successful or not
- #
- def created?
- @disposition == REG_CREATED_NEW_KEY
- end
-
- #
- # Returns if key is not closed.
- #
- def open?
- !@hkey.nil?
- end
-
- #
- # Full path of key such as 'HKEY_CURRENT_USER\SOFTWARE\foo\bar'.
- #
- 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 is not allowed
- #
- def _dump(depth)
- raise TypeError, "can't dump Win32::Registry"
- end
-
- #
- # Same as Win32::Registry.open (self, subkey, desired, opt)
- #
- def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
- self.class.open(self, subkey, desired, opt, &blk)
- end
-
- #
- # Same as Win32::Registry.create (self, subkey, desired, opt)
- #
- def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
- self.class.create(self, subkey, desired, opt, &blk)
- end
-
- #
- # Close key.
- #
- # After close, most method raise an error.
- #
- def close
- API.CloseKey(@hkey)
- @hkey = @parent = @keyname = nil
- @hkeyfinal[0] = nil
- end
-
- #
- # Enumerate values.
- #
- def each_value
- index = 0
- while true
- begin
- subkey = API.EnumValue(@hkey, index)
- rescue Error
- break
- end
- subkey = export_string(subkey)
- begin
- type, data = read(subkey)
- rescue Error
- else
- yield subkey, type, data
- end
- index += 1
- end
- index
- end
- alias each each_value
-
- #
- # return values as an array
- #
- def values
- vals_ary = []
- each_value { |*, val| vals_ary << val }
- vals_ary
- end
-
- #
- # Enumerate subkeys.
- #
- # subkey is String which contains name of subkey.
- # wtime is last write time as FILETIME (64-bit integer).
- # (see Registry.wtime2time)
- #
- def each_key
- index = 0
- while true
- begin
- subkey, wtime = API.EnumKey(@hkey, index)
- rescue Error
- break
- end
- subkey = export_string(subkey)
- yield subkey, wtime
- index += 1
- end
- index
- end
-
- #
- # return keys as an array
- #
- def keys
- keys_ary = []
- each_key { |key,| keys_ary << key }
- keys_ary
- end
-
- # 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, REG_NONE
- # String (contains binary data)
- #
- # When rtype is specified, the value type must be included by
- # rtype array, or TypeError is raised.
- def read(name, *rtype)
- type, data = API.QueryValue(@hkey, name)
- unless rtype.empty? or rtype.include?(type)
- raise TypeError, "Type mismatch (expect [#{
- rtype.map{|t|Registry.type2name(t)}.join(', ')}] but #{
- Registry.type2name(type)} present)"
- end
- case type
- when REG_SZ, REG_EXPAND_SZ
- [ type, data.encode(name.encoding, WCHAR).chop ]
- when REG_MULTI_SZ
- [ type, data.encode(name.encoding, WCHAR).split(/\0/) ]
- when REG_BINARY, REG_NONE
- [ 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 #{Registry.type2name(type)} is not supported."
- end
- end
-
- #
- # Read a registry value named name and return its value data.
- # The class of the value is the same as the #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 the same as for the #read method.
- #
- 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 #{Registry.type2name(type)} is not supported."
- end
- end
-
- # 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.
- def read_s(name)
- read(name, REG_SZ)[1]
- end
-
- #
- # 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.
- #
- 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
-
- #
- # 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.
- #
- def read_i(name)
- read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
- end
-
- #
- # 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.
- #
- def read_bin(name)
- read(name, REG_BINARY)[1]
- end
-
- #
- # 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.
- #
- def write(name, type, data)
- termsize = 0
- case type
- when REG_SZ, REG_EXPAND_SZ
- data = data.encode(WCHAR)
- termsize = WCHAR_SIZE
- when REG_MULTI_SZ
- data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL
- termsize = WCHAR_SIZE
- when REG_BINARY, REG_NONE
- 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 #{Registry.type2name(type)}"
- end
- API.SetValue(@hkey, name, type, data, data.bytesize + termsize)
- end
-
- #
- # 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
- #
- 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
-
- #
- # 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).
- #
- def write_s(name, value)
- write name, REG_SZ, value.to_s
- end
-
- #
- # 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).
- #
- def write_i(name, value)
- write name, REG_DWORD, value.to_i
- end
-
- #
- # 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).
- #
- def write_bin(name, value)
- write name, REG_BINARY, value.to_s
- end
-
- #
- # Delete a registry value named name.
- # We can not delete the `default' value.
- #
- def delete_value(name)
- API.DeleteValue(@hkey, name)
- end
- alias delete delete_value
-
- #
- # 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.
- #
- 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
-
- #
- # Write all the attributes into the registry file.
- #
- def flush
- API.FlushKey @hkey
- end
-
- #
- # 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[http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp] Win32 API.
- #
- def info
- API.QueryInfoKey(@hkey)
- end
-
- #
- # Returns an item of key information.
- #
- %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
-
- private
-
- def export_string(str, enc = Encoding.default_internal || LOCALE) # :nodoc:
- str.encode(enc)
- end
- end
-end
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index d06658f0aa..08fed08563 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -4,12 +4,23 @@
=end
-require 'win32/registry'
+require 'win32/resolv.so'
+# Generic namespace for Windows platform-specific features.
module Win32
- module Resolv
- API = Registry::API
- Error = Registry::Error
+ module Resolv # :nodoc:
+ # Error at Win32 API
+ class Error < StandardError
+ # +code+ Win32 Error code
+ # +message+ Formatted message for +code+
+ def initialize(code, message)
+ super(message)
+ @code = code
+ end
+
+ # Win32 error code
+ attr_reader :code
+ end
def self.get_hosts_path
path = get_hosts_dir
@@ -34,98 +45,59 @@ module Win32
end
[ search, nameserver ]
end
- end
-end
-
-begin
- require 'win32/resolv.so'
-rescue LoadError
-end
-
-module Win32
-#====================================================================
-# Windows NT
-#====================================================================
- module Resolv
- module SZ
- refine Registry do
- # ad hoc workaround for broken registry
- def read_s(key)
- type, str = read(key)
- unless type == Registry::REG_SZ
- warn "Broken registry, #{name}\\#{key} was #{Registry.type2name(type)}, ignored"
- return String.new
- end
- str
- end
- end
- end
- using SZ
-
- 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')
+ tcpip_params do |params|
+ params.value('DataBasePath')
end
end
def get_info
search = nil
nameserver = get_dns_server_list
- 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
+
+ tcpip_params do |params|
+ slist = params.value('SearchList')
+ search = slist.split(/,\s*/) if slist and !slist.empty?
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+\./ =~ nvdom
- devo = $'
- end
+ domain = params.value('Domain')
+
+ if domain and !domain.empty?
+ search = [ domain ]
+ udmnd = params.value('UseDomainNameDevolution')
+ if udmnd&.nonzero?
+ if /^\w+\./ =~ domain
+ devo = $'
end
end
- rescue Registry::Error
end
end
- reg.open('Interfaces') do |h|
- h.each_key do |iface, |
- h.open(iface) do |regif|
- next unless ns = %w[NameServer DhcpNameServer].find do |key|
- begin
- ns = regif.read_s(key)
- rescue Registry::Error
- else
- break ns.split(/[,\s]\s*/) unless ns.empty?
- end
- end
- next if (nameserver & ns).empty?
+ params.open('Interfaces') do |reg|
+ reg.each_key do |iface|
+ next unless ns = %w[NameServer DhcpNameServer].find do |key|
+ ns = iface.value(key)
+ break ns.split(/[,\s]\s*/) if ns and !ns.empty?
+ 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
+ next if (nameserver & ns).empty?
+
+ if add_search
+ [ 'Domain', 'DhcpDomain' ].each do |key|
+ dom = iface.value(key)
+ if dom and !dom.empty?
+ search.concat(dom.split(/,\s*/))
+ break
end
end
end
end
end
+
search << devo if add_search and devo
end
[ search.uniq, nameserver.uniq ]
diff --git a/ext/win32/lib/win32/sspi.rb b/ext/win32/lib/win32/sspi.rb
deleted file mode 100644
index 20205fd4d6..0000000000
--- a/ext/win32/lib/win32/sspi.rb
+++ /dev/null
@@ -1,338 +0,0 @@
-# frozen_string_literal: false
-#
-# = 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 'fiddle/import'
-
-# 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
- extend Fiddle::Importer
- dlload "secur32.dll"
- [
- # Can be called with AcquireCredentialsHandleA.call()
- "unsigned long AcquireCredentialsHandleA(void *, void *, unsigned long, void *, void *, void *, void *, void *, void *)",
- # Can be called with InitializeSecurityContextA.call()
- "unsigned long InitializeSecurityContextA(void *, void *, void *, unsigned long, unsigned long, unsigned long, void *, unsigned long, void *, void *, void *, void *)",
- # Can be called with DeleteSecurityContext.call()
- "unsigned long DeleteSecurityContext(void *)",
- # Can be called with FreeCredentialsHandle.call()
- "unsigned long FreeCredentialsHandle(void *)"
- ].each do |fn|
- cfunc = extern fn, :stdcall
- const_set cfunc.name.intern, cfunc
- end
- 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 representations 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 connection 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::InitializeSecurityContextA.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::AcquireCredentialsHandleA.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
diff --git a/ext/win32/resolv/extconf.rb b/ext/win32/resolv/extconf.rb
index 01f3df730a..5ee4c0d7c4 100644
--- a/ext/win32/resolv/extconf.rb
+++ b/ext/win32/resolv/extconf.rb
@@ -1,3 +1,7 @@
-if have_library('iphlpapi', 'GetNetworkParams')
+require 'mkmf'
+if RUBY_ENGINE == "ruby" and have_library('iphlpapi', 'GetNetworkParams', ['windows.h', 'iphlpapi.h'])
+ have_library('advapi32', 'RegGetValueW', ['windows.h'])
create_makefile('win32/resolv')
+else
+ File.write('Makefile', "all clean install:\n\t@echo Done: $(@)\n")
end
diff --git a/ext/win32/resolv/resolv.c b/ext/win32/resolv/resolv.c
index 8a50ef7824..9150df5dc1 100644
--- a/ext/win32/resolv/resolv.c
+++ b/ext/win32/resolv/resolv.c
@@ -1,24 +1,59 @@
#include <ruby.h>
#include <ruby/encoding.h>
#include <windows.h>
+#include <windns.h>
#ifndef NTDDI_VERSION
#define NTDDI_VERSION 0x06000000
#endif
#include <iphlpapi.h>
+#ifndef numberof
+#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
+#endif
+
static VALUE
w32error_make_error(DWORD e)
{
- VALUE code = ULONG2NUM(e);
- return rb_class_new_instance(1, &code, rb_path2class("Win32::Resolv::Error"));
+ char buffer[512], *p;
+ DWORD source = 0;
+ VALUE args[2];
+ if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS, &source, e,
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+ buffer, sizeof(buffer), NULL)) {
+ snprintf(buffer, sizeof(buffer), "Unknown Error %lu", (unsigned long)e);
+ }
+ p = buffer;
+ while ((p = strpbrk(p, "\r\n")) != NULL) {
+ memmove(p, p + 1, strlen(p));
+ if (!p[1]) {
+ p[0] = '\0';
+ break;
+ }
+ }
+ args[0] = ULONG2NUM(e);
+ args[1] = rb_str_new_cstr(buffer);
+ return rb_class_new_instance(2, args, rb_path2class("Win32::Resolv::Error"));
}
static void
-w32error_raise(DWORD e)
+w32error_check(DWORD e)
+{
+ if (e != NO_ERROR) {
+ rb_exc_raise(w32error_make_error(e));
+ }
+}
+
+static VALUE
+wchar_to_utf8(const WCHAR *w, int n)
{
- rb_exc_raise(w32error_make_error(e));
+ int clen = WideCharToMultiByte(CP_UTF8, 0, w, n, NULL, 0, NULL, NULL);
+ VALUE str = rb_enc_str_new(NULL, clen, rb_utf8_encoding());
+ WideCharToMultiByte(CP_UTF8, 0, w, n, RSTRING_PTR(str), clen, NULL, NULL);
+ return str;
}
+/* :nodoc: */
static VALUE
get_dns_server_list(VALUE self)
{
@@ -28,9 +63,7 @@ get_dns_server_list(VALUE self)
VALUE buf, nameservers = Qnil;
ret = GetNetworkParams(NULL, &buflen);
- if (ret != NO_ERROR && ret != ERROR_BUFFER_OVERFLOW) {
- w32error_raise(ret);
- }
+ if (ret != ERROR_BUFFER_OVERFLOW) w32error_check(ret);
fixedinfo = ALLOCV(buf, buflen);
ret = GetNetworkParams(fixedinfo, &buflen);
if (ret == NO_ERROR) {
@@ -44,18 +77,181 @@ get_dns_server_list(VALUE self)
} while ((ipaddr = ipaddr->Next) != NULL);
}
ALLOCV_END(buf);
- if (ret != NO_ERROR) w32error_raise(ret);
+ w32error_check(ret);
return nameservers;
}
+static const WCHAR TCPIP_Params[] = L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
+
+static void
+hkey_finalize(void *p)
+{
+ RegCloseKey((HKEY)p);
+}
+
+static const rb_data_type_t hkey_type = {
+ "RegKey",
+ {0, hkey_finalize},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+hkey_close(VALUE self)
+{
+ RegCloseKey((HKEY)DATA_PTR(self));
+ DATA_PTR(self) = 0;
+ return self;
+}
+
+static VALUE reg_key_class;
+
+static VALUE
+reg_open_key(VALUE klass, HKEY hkey, const WCHAR *wname)
+{
+ VALUE k = TypedData_Wrap_Struct(klass, &hkey_type, NULL);
+ DWORD e = RegOpenKeyExW(hkey, wname, 0, KEY_READ, (HKEY *)&DATA_PTR(k));
+ if (e == ERROR_FILE_NOT_FOUND) return Qnil;
+ w32error_check(e);
+ return rb_ensure(rb_yield, k, hkey_close, k);
+}
+
+/* :nodoc: */
+static VALUE
+tcpip_params_open(VALUE klass)
+{
+ return reg_open_key(reg_key_class, HKEY_LOCAL_MACHINE, TCPIP_Params);
+}
+
+static int
+to_wname(VALUE *name, WCHAR *wname, int wlen)
+{
+ const char *n = StringValueCStr(*name);
+ int nlen = RSTRING_LEN(*name);
+ int len = MultiByteToWideChar(CP_UTF8, 0, n, nlen, wname, wlen - 1);
+ if (len == 0) w32error_check(GetLastError());
+ if (len >= wlen) rb_raise(rb_eArgError, "too long name");
+ wname[len] = L'\0';
+ return len;
+}
+
+static VALUE
+reg_open(VALUE self, VALUE name)
+{
+ HKEY hkey = DATA_PTR(self);
+ WCHAR wname[256];
+ to_wname(&name, wname, numberof(wname));
+ return reg_open_key(CLASS_OF(self), hkey, wname);
+}
+
+
+static VALUE
+reg_each_key(VALUE self)
+{
+ WCHAR wname[256];
+ HKEY hkey = DATA_PTR(self);
+ VALUE k = TypedData_Wrap_Struct(CLASS_OF(self), &hkey_type, NULL);
+ DWORD i, e, n;
+ for (i = 0; n = numberof(wname), (e = RegEnumKeyExW(hkey, i, wname, &n, NULL, NULL, NULL, NULL)) == ERROR_SUCCESS; i++) {
+ e = RegOpenKeyExW(hkey, wname, 0, KEY_READ, (HKEY *)&DATA_PTR(k));
+ w32error_check(e);
+ rb_ensure(rb_yield, k, hkey_close, k);
+ }
+ if (e != ERROR_NO_MORE_ITEMS) w32error_check(e);
+ return self;
+}
+
+static inline DWORD
+swap_dw(DWORD x)
+{
+#if defined(_MSC_VER)
+ return _byteswap_ulong(x);
+#else
+ return __builtin_bswap32(x);
+#endif
+}
+
+static VALUE
+reg_value(VALUE self, VALUE name)
+{
+ HKEY hkey = DATA_PTR(self);
+ DWORD type = 0, size = 0, e;
+ VALUE result, value_buffer;
+ void *buffer;
+ WCHAR wname[256];
+ to_wname(&name, wname, numberof(wname));
+ e = RegGetValueW(hkey, NULL, wname, RRF_RT_ANY, &type, NULL, &size);
+ if (e == ERROR_FILE_NOT_FOUND) return Qnil;
+ w32error_check(e);
+# define get_value_2nd(data, dsize) do { \
+ DWORD type2 = type; \
+ w32error_check(RegGetValueW(hkey, NULL, wname, RRF_RT_ANY, &type2, data, dsize)); \
+ if (type != type2) { \
+ rb_raise(rb_eRuntimeError, "registry value type changed %lu -> %lu", \
+ (unsigned long)type, (unsigned long)type2); \
+ } \
+ } while (0)
+
+ switch (type) {
+ case REG_DWORD: case REG_DWORD_BIG_ENDIAN:
+ {
+ DWORD d;
+ if (size != sizeof(d)) rb_raise(rb_eRuntimeError, "invalid size returned: %lu", (unsigned long)size);
+ w32error_check(RegGetValueW(hkey, NULL, wname, RRF_RT_REG_DWORD, &type, &d, &size));
+ if (type == REG_DWORD_BIG_ENDIAN) d = swap_dw(d);
+ return ULONG2NUM(d);
+ }
+ case REG_QWORD:
+ {
+ QWORD q;
+ if (size != sizeof(q)) rb_raise(rb_eRuntimeError, "invalid size returned: %lu", (unsigned long)size);
+ w32error_check(RegGetValueW(hkey, NULL, wname, RRF_RT_REG_QWORD, &type, &q, &size));
+ return ULL2NUM(q);
+ }
+ case REG_SZ: case REG_MULTI_SZ: case REG_EXPAND_SZ:
+ if (size % sizeof(WCHAR)) rb_raise(rb_eRuntimeError, "invalid size returned: %lu", (unsigned long)size);
+ buffer = ALLOCV_N(char, value_buffer, size);
+ get_value_2nd(buffer, &size);
+ if (type == REG_MULTI_SZ) {
+ const WCHAR *w = (WCHAR *)buffer;
+ result = rb_ary_new();
+ size /= sizeof(WCHAR);
+ size -= 1;
+ for (size_t i = 0; i < size; ++i) {
+ int n = lstrlenW(w+i);
+ rb_ary_push(result, wchar_to_utf8(w+i, n));
+ i += n;
+ }
+ }
+ else {
+ result = wchar_to_utf8((WCHAR *)buffer, lstrlenW((WCHAR *)buffer));
+ }
+ ALLOCV_END(value_buffer);
+ break;
+ default:
+ result = rb_str_new(0, size);
+ get_value_2nd(RSTRING_PTR(result), &size);
+ rb_str_set_len(result, size);
+ break;
+ }
+ return result;
+}
+
void
InitVM_resolv(void)
{
VALUE mWin32 = rb_define_module("Win32");
VALUE resolv = rb_define_module_under(mWin32, "Resolv");
VALUE singl = rb_singleton_class(resolv);
+ VALUE regkey = rb_define_class_under(resolv, "registry key", rb_cObject);
+
+ reg_key_class = regkey;
+ rb_undef_alloc_func(regkey);
rb_define_private_method(singl, "get_dns_server_list", get_dns_server_list, 0);
+ rb_define_private_method(singl, "tcpip_params", tcpip_params_open, 0);
+ rb_define_method(regkey, "open", reg_open, 1);
+ rb_define_method(regkey, "each_key", reg_each_key, 0);
+ rb_define_method(regkey, "value", reg_value, 1);
}
void
diff --git a/ext/win32ole/depend b/ext/win32ole/depend
deleted file mode 100644
index c8445ad5fa..0000000000
--- a/ext/win32ole/depend
+++ /dev/null
@@ -1,12 +0,0 @@
-WIN32OLE_HEADERS = $(HDRS) $(ruby_headers)
-win32ole.o : win32ole.c $(WIN32OLE_HEADERS)
-win32ole_variant_m.o : win32ole_variant_m.c $(WIN32OLE_HEADERS)
-win32ole_typelib.o : win32ole_typelib.c $(WIN32OLE_HEADERS)
-win32ole_type.o : win32ole_type.c $(WIN32OLE_HEADERS)
-win32ole_variable.o : win32ole_variable.c $(WIN32OLE_HEADERS)
-win32ole_method.o : win32ole_method.c $(WIN32OLE_HEADERS)
-win32ole_param.o : win32ole_param.c $(WIN32OLE_HEADERS)
-win32ole_variant.o : win32ole_variant.c $(WIN32OLE_HEADERS)
-win32ole_event.o : win32ole_event.c $(WIN32OLE_HEADERS)
-win32ole_record.o : win32ole_record.c $(WIN32OLE_HEADERS)
-win32ole_error.o : win32ole_error.c $(WIN32OLE_HEADERS)
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
deleted file mode 100644
index d2044663a9..0000000000
--- a/ext/win32ole/extconf.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: false
-#----------------------------------
-# extconf.rb
-# $Revision$
-#----------------------------------
-require 'mkmf'
-
-case RUBY_PLATFORM
-when /cygwin/
- inc = nil
- lib = '/usr/lib/w32api'
-end
-
-dir_config("win32", inc, lib)
-
-def create_win32ole_makefile
- if have_library("ole32") and
- have_library("oleaut32") and
- have_library("uuid", "&CLSID_CMultiLanguage", "mlang.h") and
- have_library("user32") and
- have_library("kernel32") and
- have_library("advapi32") and
- have_header("windows.h")
- unless have_type("IMultiLanguage2", "mlang.h")
- have_type("IMultiLanguage", "mlang.h")
- end
- spec = nil
- checking_for('thread_specific', '%s') do
- spec = %w[__declspec(thread) __thread].find {|th|
- try_compile("#{th} int foo;", "", :werror => true)
- }
- spec or 'no'
- end
- $defs << "-DRB_THREAD_SPECIFIC=#{spec}" if spec
- create_makefile("win32ole")
- end
-end
-
-
-case RUBY_PLATFORM
-when /mswin/
- $CFLAGS.sub!(/((?:\A|\s)[-\/])W\d(?=\z|\s)/, '\1W3') or
- $CFLAGS += ' -W3'
-end
-create_win32ole_makefile
diff --git a/ext/win32ole/lib/win32ole.rb b/ext/win32ole/lib/win32ole.rb
deleted file mode 100644
index d7034f7845..0000000000
--- a/ext/win32ole/lib/win32ole.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-begin
- require 'win32ole.so'
-rescue LoadError
- # do nothing
-end
-
-if defined?(WIN32OLE)
- # WIN32OLE
- class WIN32OLE
-
- #
- # By overriding Object#methods, WIN32OLE might
- # work well with did_you_mean gem.
- # This is experimental.
- #
- # require 'win32ole'
- # dict = WIN32OLE.new('Scripting.Dictionary')
- # dict.Ade('a', 1)
- # #=> Did you mean? Add
- #
- def methods(*args)
- super + ole_methods_safely.map(&:name).map(&:to_sym)
- end
-
- private
-
- def ole_methods_safely
- ole_methods
- rescue WIN32OLEQueryInterfaceError
- []
- end
- end
-end
diff --git a/ext/win32ole/lib/win32ole/property.rb b/ext/win32ole/lib/win32ole/property.rb
deleted file mode 100644
index fea047cd19..0000000000
--- a/ext/win32ole/lib/win32ole/property.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: false
-# OLEProperty
-# helper class of Property with arguments.
-class OLEProperty
- def initialize(obj, dispid, gettypes, settypes)
- @obj = obj
- @dispid = dispid
- @gettypes = gettypes
- @settypes = settypes
- end
- def [](*args)
- @obj._getproperty(@dispid, args, @gettypes)
- end
- def []=(*args)
- @obj._setproperty(@dispid, args, @settypes)
- end
-end
diff --git a/ext/win32ole/sample/excel1.rb b/ext/win32ole/sample/excel1.rb
deleted file mode 100644
index 4fe1d0c2a9..0000000000
--- a/ext/win32ole/sample/excel1.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-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;
-
-print "Now quit Excel... Please enter."
-gets
-
-application.ActiveWorkbook.Close(0);
-application.Quit();
-
diff --git a/ext/win32ole/sample/excel2.rb b/ext/win32ole/sample/excel2.rb
deleted file mode 100644
index 47a5715f84..0000000000
--- a/ext/win32ole/sample/excel2.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-# -4100 is the value for the Excel constant xl3DColumn.
-ChartTypeVal = -4100;
-
-# Creates OLE object to Excel
-excel = WIN32OLE.new("excel.application")
-
-# Create and rotate the chart
-excel.visible = true;
-excel.Workbooks.Add();
-excel.Range("a1").value = 3;
-excel.Range("a2").value = 2;
-excel.Range("a3").value = 1;
-excel.Range("a1:a3").Select();
-excelchart = excel.Charts.Add();
-excelchart.type = ChartTypeVal;
-
-i = 0
-i.step(180, 10) do |rot|
- excelchart.rotation=rot;
- sleep 0.1
-end
-# Done, bye
-
-print "Now quit Excel... Please enter."
-gets
-
-excel.ActiveWorkbook.Close(0);
-excel.Quit();
diff --git a/ext/win32ole/sample/excel3.rb b/ext/win32ole/sample/excel3.rb
deleted file mode 100644
index 72aee2a929..0000000000
--- a/ext/win32ole/sample/excel3.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-#application = WIN32OLE.new('Excel.Application.5')
-application = WIN32OLE.new('Excel.Application')
-
-application.visible = true
-workbook = application.Workbooks.Add();
-sheet = workbook.Worksheets(1);
-sheetS = workbook.Worksheets
-puts "The number of sheets is #{sheetS.count}"
-puts "Now add 2 sheets after of `#{sheet.name}`"
-sheetS.add({'count'=>2, 'after'=>sheet})
-puts "The number of sheets is #{sheetS.count}"
-
-print "Now quit Excel... Please enter."
-gets
-
-application.ActiveWorkbook.Close(0);
-application.Quit();
-
diff --git a/ext/win32ole/sample/ie.rb b/ext/win32ole/sample/ie.rb
deleted file mode 100644
index 4db64eed30..0000000000
--- a/ext/win32ole/sample/ie.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-url = 'http://www.ruby-lang.org/'
-ie = WIN32OLE.new('InternetExplorer.Application')
-ie.visible = true
-ie.gohome
-print "Now navigate Ruby home page... Please enter."
-gets
-ie.navigate(url)
-print "Now quit Internet Explorer... Please enter."
-gets
-ie.Quit()
diff --git a/ext/win32ole/sample/ieconst.rb b/ext/win32ole/sample/ieconst.rb
deleted file mode 100644
index 363a4f8153..0000000000
--- a/ext/win32ole/sample/ieconst.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-ie = WIN32OLE.new('InternetExplorer.Application')
-=begin
-WIN32OLE.const_load(ie)
-WIN32OLE.constants.sort.each do |c|
- puts "#{c} = #{WIN32OLE.const_get(c)}"
-end
-=end
-
-module IE_CONST
-end
-
-WIN32OLE.const_load(ie, IE_CONST)
-IE_CONST.constants.sort.each do |c|
- puts "#{c} = #{IE_CONST.const_get(c)}"
-end
-
-#------------------------------------------------------------
-# Remark!!! CONSTANTS has not tested enoughly!!!
-# CONSTANTS is alpha release.
-# If there are constants which first letter is not [a-zA-Z],
-# like a '_Foo', then maybe you can access the value by
-# using CONSTANTS['_Foo']
-#------------------------------------------------------------
-IE_CONST::CONSTANTS.each do |k, v|
- puts "#{k} = #{v}"
-end
-
-puts WIN32OLE::VERSION
-ie.quit
-
diff --git a/ext/win32ole/sample/ienavi.rb b/ext/win32ole/sample/ienavi.rb
deleted file mode 100644
index 5d0536028b..0000000000
--- a/ext/win32ole/sample/ienavi.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-$urls = []
-
-def navigate(url)
- $urls << url
-end
-
-def stop_msg_loop
- puts "Now Stop IE..."
- $LOOP = false;
-end
-
-def default_handler(event, *args)
- case event
- when "BeforeNavigate"
- puts "Now Navigate #{args[0]}..."
- end
-end
-
-ie = WIN32OLE.new('InternetExplorer.Application')
-ie.visible = true
-ie.gohome
-
-ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
-
-ev.on_event {|*args| default_handler(*args)}
-ev.on_event("NavigateComplete") {|url| navigate(url)}
-ev.on_event("Quit") {|*args| stop_msg_loop}
-
-$LOOP = true
-while ($LOOP)
- WIN32OLE_EVENT.message_loop
-end
-
-puts "You Navigated the URLs ..."
-$urls.each_with_index do |url, i|
- puts "(#{i+1}) #{url}"
-end
-
diff --git a/ext/win32ole/sample/ienavi2.rb b/ext/win32ole/sample/ienavi2.rb
deleted file mode 100644
index 3248393077..0000000000
--- a/ext/win32ole/sample/ienavi2.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: false
-require 'win32ole'
-
-class IEHandler
- attr_reader :loop
- def initialize
- @urls = []
- @loop = true
- end
- def method_missing(event, *args)
- case event
- when "BeforeNavigate2"
- puts "Now Navigate #{args[1]}..."
- end
- end
- def onNavigateComplete2(pdisp, url)
- @urls << url
- end
- def onOnQuit
- puts "Now Stop IE..."
- @loop = false
- end
- def put_urls
- puts "You Navigated the URLs ..."
- @urls.each_with_index do |url, i|
- puts "(#{i+1}) #{url}"
- end
- end
-end
-
-ie = WIN32OLE.new('InternetExplorer.Application')
-ie.visible = true
-ie.gohome
-
-ev = WIN32OLE_EVENT.new(ie)
-ev.handler = IEHandler.new
-
-while (ev.handler.loop)
- WIN32OLE_EVENT.message_loop
-end
-ev.handler.put_urls
diff --git a/ext/win32ole/sample/oledirs.rb b/ext/win32ole/sample/oledirs.rb
deleted file mode 100644
index e52a0fd7ac..0000000000
--- a/ext/win32ole/sample/oledirs.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: false
-#
-# You need WSH(Windows Scripting Host) to run this script.
-#
-
-require "win32ole"
-
-def listup(items)
-# items.each do |i|
- for i in items
- puts i.name
- end
-end
-
-fs = WIN32OLE.new("Scripting.FileSystemObject")
-
-folder = fs.GetFolder(".")
-
-puts "--- folder of #{folder.path} ---"
-listup(folder.SubFolders)
-
-puts "--- files of #{folder.path} ---"
-listup(folder.Files)
-
diff --git a/ext/win32ole/sample/olegen.rb b/ext/win32ole/sample/olegen.rb
deleted file mode 100644
index 4b088a774f..0000000000
--- a/ext/win32ole/sample/olegen.rb
+++ /dev/null
@@ -1,348 +0,0 @@
-# frozen_string_literal: false
-#-----------------------------
-# olegen.rb
-# $Revision$
-#-----------------------------
-
-require 'win32ole'
-
-class WIN32COMGen
- def initialize(typelib)
- @typelib = typelib
- @receiver = ""
- end
- attr_reader :typelib
-
- def ole_classes(typelib)
- begin
- @ole = WIN32OLE.new(typelib)
- [@ole.ole_obj_help]
- rescue
- WIN32OLE_TYPE.ole_classes(typelib)
- end
- end
-
- def generate_args(method)
- args = []
- if method.size_opt_params >= 0
- size_required_params = method.size_params - method.size_opt_params
- else
- size_required_params = method.size_params - 1
- end
- size_required_params.times do |i|
- if method.params[i] && method.params[i].optional?
- args.push "arg#{i}=nil"
- else
- args.push "arg#{i}"
- end
- end
- if method.size_opt_params >= 0
- method.size_opt_params.times do |i|
- args.push "arg#{i + size_required_params}=nil"
- end
- else
- args.push "*arg"
- end
- args.join(", ")
- end
-
- def generate_argtype(typedetails)
- ts = ''
- typedetails.each do |t|
- case t
- when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8'
-# raise "Sorry type\"" + t + "\" not supported"
- ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\""
- when 'USERDEFINED', 'Unknown Type 9'
- ts << 'VT_DISPATCH'
- break;
- when 'SAFEARRAY'
- ts << 'VT_ARRAY|'
- when 'PTR'
- ts << 'VT_BYREF|'
- when 'INT'
- ts << 'VT_I4'
- else
- if String === t
- ts << 'VT_' + t
- end
- end
- end
- if ts.empty?
- ts = 'VT_VARIANT'
- elsif ts[-1] == ?|
- ts += 'VT_VARIANT'
- end
- ts
- end
-
- def generate_argtypes(method, proptypes)
- types = method.params.collect{|param|
- generate_argtype(param.ole_type_detail)
- }.join(", ")
- if proptypes
- types += ", " if types.size > 0
- types += generate_argtype(proptypes)
- end
- types
- end
-
- def generate_method_body(method, disptype, types=nil)
- " ret = #{@receiver}#{disptype}(#{method.dispid}, [" +
- generate_args(method).gsub("=nil", "") +
- "], [" +
- generate_argtypes(method, types) +
- "])\n" +
- " @lastargs = WIN32OLE::ARGV\n" +
- " ret"
- end
-
- def generate_method_help(method, type = nil)
- str = " # "
- if type
- str += type
- else
- str += method.return_type
- end
- str += " #{method.name}"
- if method.event?
- str += " EVENT"
- str += " in #{method.event_interface}"
- end
- if method.helpstring && method.helpstring != ""
- str += "\n # "
- str += method.helpstring
- end
- args_help = generate_method_args_help(method)
- if args_help
- str += "\n"
- str += args_help
- end
- str
- end
-
- def generate_method_args_help(method)
- args = []
- method.params.each_with_index {|param, i|
- h = " # #{param.ole_type} arg#{i} --- #{param.name}"
- inout = []
- inout.push "IN" if param.input?
- inout.push "OUT" if param.output?
- h += " [#{inout.join('/')}]"
- h += " ( = #{param.default})" if param.default
- args.push h
- }
- if args.size > 0
- args.join("\n")
- else
- nil
- end
- end
-
- def generate_method(method, disptype, io = STDOUT, types = nil)
- io.puts "\n"
- io.puts generate_method_help(method)
- if method.invoke_kind == 'PROPERTYPUT'
- io.print " def #{method.name}=("
- else
- io.print " def #{method.name}("
- end
- io.print generate_args(method)
- io.puts ")"
- io.puts generate_method_body(method, disptype, types)
- io.puts " end"
- end
-
- def generate_propputref_methods(klass, io = STDOUT)
- klass.ole_methods.select {|method|
- method.invoke_kind == 'PROPERTYPUTREF' && method.visible?
- }.each do |method|
- generate_method(method, io)
- end
- end
-
- def generate_properties_with_args(klass, io = STDOUT)
- klass.ole_methods.select {|method|
- method.invoke_kind == 'PROPERTYGET' &&
- method.visible? &&
- method.size_params > 0
- }.each do |method|
- types = method.return_type_detail
- io.puts "\n"
- io.puts generate_method_help(method, types[0])
- io.puts " def #{method.name}"
- if klass.ole_type == "Class"
- io.print " OLEProperty.new(@dispatch, #{method.dispid}, ["
- else
- io.print " OLEProperty.new(self, #{method.dispid}, ["
- end
- io.print generate_argtypes(method, nil)
- io.print "], ["
- io.print generate_argtypes(method, types)
- io.puts "])"
- io.puts " end"
- end
- end
-
- def generate_propput_methods(klass, io = STDOUT)
- klass.ole_methods.select {|method|
- method.invoke_kind == 'PROPERTYPUT' && method.visible? &&
- method.size_params == 1
- }.each do |method|
- ms = klass.ole_methods.select {|m|
- m.invoke_kind == 'PROPERTYGET' &&
- m.dispid == method.dispid
- }
- types = []
- if ms.size == 1
- types = ms[0].return_type_detail
- end
- generate_method(method, '_setproperty', io, types)
- end
- end
-
- def generate_propget_methods(klass, io = STDOUT)
- klass.ole_methods.select {|method|
- method.invoke_kind == 'PROPERTYGET' && method.visible? &&
- method.size_params == 0
- }.each do |method|
- generate_method(method, '_getproperty', io)
- end
- end
-
- def generate_func_methods(klass, io = STDOUT)
- klass.ole_methods.select {|method|
- method.invoke_kind == "FUNC" && method.visible?
- }.each do |method|
- generate_method(method, '_invoke', io)
- end
- end
-
- def generate_methods(klass, io = STDOUT)
- generate_propget_methods(klass, io)
- generate_propput_methods(klass, io)
- generate_properties_with_args(klass, io)
- generate_func_methods(klass, io)
-# generate_propputref_methods(klass, io)
- end
-
- def generate_constants(klass, io = STDOUT)
- klass.variables.select {|v|
- v.visible? && v.variable_kind == 'CONSTANT'
- }.each do |v|
- io.print " "
- io.print v.name.sub(/^./){$&.upcase}
- io.print " = "
- io.puts v.value
- end
- end
-
- def class_name(klass)
- klass_name = klass.name
- if klass.ole_type == "Class" &&
- klass.guid &&
- klass.progid
- klass_name = klass.progid.gsub(/\./, '_')
- end
- if /^[A-Z]/ !~ klass_name || Module.constants.include?(klass_name)
- klass_name = 'OLE' + klass_name
- end
- klass_name
- end
-
- def define_initialize(klass)
- <<STR
-
- def initialize(obj = nil)
- @clsid = "#{klass.guid}"
- @progid = "#{klass.progid}"
- if obj.nil?
- @dispatch = WIN32OLE.new @progid
- else
- @dispatch = obj
- end
- end
-STR
- end
-
- def define_include
- " include WIN32OLE::VARIANT"
- end
-
- def define_instance_variables
- " attr_reader :lastargs"
- end
-
- def define_method_missing
- <<STR
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-STR
- end
-
- def define_class(klass, io = STDOUT)
- io.puts "class #{class_name(klass)} # #{klass.name}"
- io.puts define_include
- io.puts define_instance_variables
- io.puts " attr_reader :dispatch"
- io.puts " attr_reader :clsid"
- io.puts " attr_reader :progid"
- io.puts define_initialize(klass)
- io.puts define_method_missing
- end
-
- def define_module(klass, io = STDOUT)
- io.puts "module #{class_name(klass)}"
- io.puts define_include
- io.puts define_instance_variables
- end
-
- def generate_class(klass, io = STDOUT)
- io.puts "\n# #{klass.helpstring}"
- if klass.ole_type == "Class" &&
- klass.guid &&
- klass.progid
- @receiver = "@dispatch."
- define_class(klass, io)
- else
- @receiver = ""
- define_module(klass, io)
- end
- generate_constants(klass, io)
- generate_methods(klass, io)
- io.puts "end"
- end
-
- def generate(io = STDOUT)
- io.puts "require 'win32ole'"
- io.puts "require 'win32ole/property'"
-
- ole_classes(typelib).select{|klass|
- klass.visible? &&
- (klass.ole_type == "Class" ||
- klass.ole_type == "Interface" ||
- klass.ole_type == "Dispatch" ||
- klass.ole_type == "Enum")
- }.each do |klass|
- generate_class(klass, io)
- end
- begin
- @ole.quit if @ole
- rescue
- end
- end
-end
-
-require 'win32ole'
-if __FILE__ == $0
- if ARGV.size == 0
- $stderr.puts "usage: #{$0} Type Library [...]"
- exit 1
- end
- ARGV.each do |typelib|
- comgen = WIN32COMGen.new(typelib)
- comgen.generate
- end
-end
diff --git a/ext/win32ole/sample/xml.rb b/ext/win32ole/sample/xml.rb
deleted file mode 100644
index 5a239c9336..0000000000
--- a/ext/win32ole/sample/xml.rb
+++ /dev/null
@@ -1,7307 +0,0 @@
-# frozen_string_literal: false
-#
-# This file created by olegen.rb as following.
-# ruby olegen.rb 'Microsoft XML, version 2.0' > xml.rb
-#
-require 'win32ole'
-require 'win32ole/property'
-
-#
-module IXMLDOMImplementation
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BOOL hasFeature
- # BSTR arg0 --- feature [IN]
- # BSTR arg1 --- version [IN]
- def hasFeature(arg0, arg1)
- ret = _invoke(145, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# Core DOM node interface
-module IXMLDOMNode
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# Constants that define a node's type
-module OLEtagDOMNodeType
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- NODE_INVALID = 0
- NODE_ELEMENT = 1
- NODE_ATTRIBUTE = 2
- NODE_TEXT = 3
- NODE_CDATA_SECTION = 4
- NODE_ENTITY_REFERENCE = 5
- NODE_ENTITY = 6
- NODE_PROCESSING_INSTRUCTION = 7
- NODE_COMMENT = 8
- NODE_DOCUMENT = 9
- NODE_DOCUMENT_TYPE = 10
- NODE_DOCUMENT_FRAGMENT = 11
- NODE_NOTATION = 12
-end
-
-#
-module IXMLDOMNodeList
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # I4 length
- # number of nodes in the collection
- def length()
- ret = _getproperty(74, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # PTR item
- # collection of nodes
- # I4 arg0 --- index [IN]
- def item
- OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
- end
-
- # IXMLDOMNode nextNode
- # get next node from iterator
- def nextNode()
- ret = _invoke(76, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID reset
- # reset the position of iterator
- def reset()
- ret = _invoke(77, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMNamedNodeMap
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # I4 length
- # number of nodes in the collection
- def length()
- ret = _getproperty(74, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # PTR item
- # collection of nodes
- # I4 arg0 --- index [IN]
- def item
- OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
- end
-
- # IXMLDOMNode getNamedItem
- # lookup item by name
- # BSTR arg0 --- name [IN]
- def getNamedItem(arg0)
- ret = _invoke(83, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode setNamedItem
- # set item by name
- # IXMLDOMNode arg0 --- newItem [IN]
- def setNamedItem(arg0)
- ret = _invoke(84, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeNamedItem
- # remove item by name
- # BSTR arg0 --- name [IN]
- def removeNamedItem(arg0)
- ret = _invoke(85, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode getQualifiedItem
- # lookup the item by name and namespace
- # BSTR arg0 --- baseName [IN]
- # BSTR arg1 --- namespaceURI [IN]
- def getQualifiedItem(arg0, arg1)
- ret = _invoke(87, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeQualifiedItem
- # remove the item by name and namespace
- # BSTR arg0 --- baseName [IN]
- # BSTR arg1 --- namespaceURI [IN]
- def removeQualifiedItem(arg0, arg1)
- ret = _invoke(88, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextNode
- # get next node from iterator
- def nextNode()
- ret = _invoke(89, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID reset
- # reset the position of iterator
- def reset()
- ret = _invoke(90, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMDocument
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentType doctype
- # node corresponding to the DOCTYPE
- def doctype()
- ret = _getproperty(38, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMImplementation implementation
- # info on this DOM implementation
- def implementation()
- ret = _getproperty(39, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement documentElement
- # the root of the tree
- def documentElement()
- ret = _getproperty(40, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- # get the state of the XML document
- def readyState()
- ret = _getproperty(-525, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMParseError parseError
- # get the last parser error
- def parseError()
- ret = _getproperty(59, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR url
- # get the URL for the loaded XML document
- def url()
- ret = _getproperty(60, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL async
- # flag for asynchronous download
- def async()
- ret = _getproperty(61, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse()
- ret = _getproperty(65, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals()
- ret = _getproperty(66, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace()
- ret = _getproperty(67, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID async
- # flag for asynchronous download
- def async=(arg0)
- ret = _setproperty(61, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse=(arg0)
- ret = _setproperty(65, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals=(arg0)
- ret = _setproperty(66, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace=(arg0)
- ret = _setproperty(67, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID onreadystatechange
- # register a readystatechange event handler
- def onreadystatechange=(arg0)
- ret = _setproperty(68, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ondataavailable
- # register an ondataavailable event handler
- def ondataavailable=(arg0)
- ret = _setproperty(69, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ontransformnode
- # register an ontransformnode event handler
- def ontransformnode=(arg0)
- ret = _setproperty(70, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement createElement
- # create an Element node
- # BSTR arg0 --- tagName [IN]
- def createElement(arg0)
- ret = _invoke(41, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentFragment createDocumentFragment
- # create a DocumentFragment node
- def createDocumentFragment()
- ret = _invoke(42, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMText createTextNode
- # create a text node
- # BSTR arg0 --- data [IN]
- def createTextNode(arg0)
- ret = _invoke(43, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMComment createComment
- # create a comment node
- # BSTR arg0 --- data [IN]
- def createComment(arg0)
- ret = _invoke(44, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMCDATASection createCDATASection
- # create a CDATA section node
- # BSTR arg0 --- data [IN]
- def createCDATASection(arg0)
- ret = _invoke(45, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMProcessingInstruction createProcessingInstruction
- # create a processing instruction node
- # BSTR arg0 --- target [IN]
- # BSTR arg1 --- data [IN]
- def createProcessingInstruction(arg0, arg1)
- ret = _invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute createAttribute
- # create an attribute node
- # BSTR arg0 --- name [IN]
- def createAttribute(arg0)
- ret = _invoke(47, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMEntityReference createEntityReference
- # create an entity reference node
- # BSTR arg0 --- name [IN]
- def createEntityReference(arg0)
- ret = _invoke(49, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList getElementsByTagName
- # build a list of elements by name
- # BSTR arg0 --- tagName [IN]
- def getElementsByTagName(arg0)
- ret = _invoke(50, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode createNode
- # create a node of the specified node type and name
- # VARIANT arg0 --- type [IN]
- # BSTR arg1 --- name [IN]
- # BSTR arg2 --- namespaceURI [IN]
- def createNode(arg0, arg1, arg2)
- ret = _invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nodeFromID
- # retrieve node from it's ID
- # BSTR arg0 --- idString [IN]
- def nodeFromID(arg0)
- ret = _invoke(56, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL load
- # load document from the specified XML source
- # VARIANT arg0 --- xmlSource [IN]
- def load(arg0)
- ret = _invoke(58, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID abort
- # abort an asynchronous download
- def abort()
- ret = _invoke(62, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL loadXML
- # load the document from a string
- # BSTR arg0 --- bstrXML [IN]
- def loadXML(arg0)
- ret = _invoke(63, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID save
- # save the document to a specified destination
- # VARIANT arg0 --- destination [IN]
- def save(arg0)
- ret = _invoke(64, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMDocumentType
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR name
- # name of the document type (root of the tree)
- def name()
- ret = _getproperty(131, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap entities
- # a list of entities in the document
- def entities()
- ret = _getproperty(132, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap notations
- # a list of notations in the document
- def notations()
- ret = _getproperty(133, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMElement
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR tagName
- # get the tagName of the element
- def tagName()
- ret = _getproperty(97, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT getAttribute
- # look up the string value of an attribute by name
- # BSTR arg0 --- name [IN]
- def getAttribute(arg0)
- ret = _invoke(99, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID setAttribute
- # set the string value of an attribute by name
- # BSTR arg0 --- name [IN]
- # VARIANT arg1 --- value [IN]
- def setAttribute(arg0, arg1)
- ret = _invoke(100, [arg0, arg1], [VT_BSTR, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID removeAttribute
- # remove an attribute by name
- # BSTR arg0 --- name [IN]
- def removeAttribute(arg0)
- ret = _invoke(101, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute getAttributeNode
- # look up the attribute node by name
- # BSTR arg0 --- name [IN]
- def getAttributeNode(arg0)
- ret = _invoke(102, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute setAttributeNode
- # set the specified attribute on the element
- # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
- def setAttributeNode(arg0)
- ret = _invoke(103, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute removeAttributeNode
- # remove the specified attribute
- # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
- def removeAttributeNode(arg0)
- ret = _invoke(104, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList getElementsByTagName
- # build a list of elements by name
- # BSTR arg0 --- tagName [IN]
- def getElementsByTagName(arg0)
- ret = _invoke(105, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID normalize
- # collapse all adjacent text nodes in sub-tree
- def normalize()
- ret = _invoke(106, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMAttribute
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR name
- # get name of the attribute
- def name()
- ret = _getproperty(118, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT value
- # string value of the attribute
- def value()
- ret = _getproperty(120, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID value
- # string value of the attribute
- def value=(arg0)
- ret = _setproperty(120, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMDocumentFragment
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMText
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR data
- # value of the node
- def data()
- ret = _getproperty(109, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 length
- # number of characters in value
- def length()
- ret = _getproperty(110, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID data
- # value of the node
- def data=(arg0)
- ret = _setproperty(109, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR substringData
- # retrieve substring of value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def substringData(arg0, arg1)
- ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID appendData
- # append string to value
- # BSTR arg0 --- data [IN]
- def appendData(arg0)
- ret = _invoke(112, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID insertData
- # insert string into value
- # I4 arg0 --- offset [IN]
- # BSTR arg1 --- data [IN]
- def insertData(arg0, arg1)
- ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID deleteData
- # delete string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def deleteData(arg0, arg1)
- ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID replaceData
- # replace string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- # BSTR arg2 --- data [IN]
- def replaceData(arg0, arg1, arg2)
- ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMText splitText
- # split the text node into two text nodes at the position specified
- # I4 arg0 --- offset [IN]
- def splitText(arg0)
- ret = _invoke(123, [arg0], [VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMCharacterData
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR data
- # value of the node
- def data()
- ret = _getproperty(109, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 length
- # number of characters in value
- def length()
- ret = _getproperty(110, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID data
- # value of the node
- def data=(arg0)
- ret = _setproperty(109, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR substringData
- # retrieve substring of value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def substringData(arg0, arg1)
- ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID appendData
- # append string to value
- # BSTR arg0 --- data [IN]
- def appendData(arg0)
- ret = _invoke(112, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID insertData
- # insert string into value
- # I4 arg0 --- offset [IN]
- # BSTR arg1 --- data [IN]
- def insertData(arg0, arg1)
- ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID deleteData
- # delete string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def deleteData(arg0, arg1)
- ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID replaceData
- # replace string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- # BSTR arg2 --- data [IN]
- def replaceData(arg0, arg1, arg2)
- ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMComment
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR data
- # value of the node
- def data()
- ret = _getproperty(109, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 length
- # number of characters in value
- def length()
- ret = _getproperty(110, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID data
- # value of the node
- def data=(arg0)
- ret = _setproperty(109, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR substringData
- # retrieve substring of value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def substringData(arg0, arg1)
- ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID appendData
- # append string to value
- # BSTR arg0 --- data [IN]
- def appendData(arg0)
- ret = _invoke(112, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID insertData
- # insert string into value
- # I4 arg0 --- offset [IN]
- # BSTR arg1 --- data [IN]
- def insertData(arg0, arg1)
- ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID deleteData
- # delete string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def deleteData(arg0, arg1)
- ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID replaceData
- # replace string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- # BSTR arg2 --- data [IN]
- def replaceData(arg0, arg1, arg2)
- ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMCDATASection
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR data
- # value of the node
- def data()
- ret = _getproperty(109, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 length
- # number of characters in value
- def length()
- ret = _getproperty(110, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID data
- # value of the node
- def data=(arg0)
- ret = _setproperty(109, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR substringData
- # retrieve substring of value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def substringData(arg0, arg1)
- ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID appendData
- # append string to value
- # BSTR arg0 --- data [IN]
- def appendData(arg0)
- ret = _invoke(112, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID insertData
- # insert string into value
- # I4 arg0 --- offset [IN]
- # BSTR arg1 --- data [IN]
- def insertData(arg0, arg1)
- ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID deleteData
- # delete string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- def deleteData(arg0, arg1)
- ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID replaceData
- # replace string within the value
- # I4 arg0 --- offset [IN]
- # I4 arg1 --- count [IN]
- # BSTR arg2 --- data [IN]
- def replaceData(arg0, arg1, arg2)
- ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMText splitText
- # split the text node into two text nodes at the position specified
- # I4 arg0 --- offset [IN]
- def splitText(arg0)
- ret = _invoke(123, [arg0], [VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMProcessingInstruction
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR target
- # the target
- def target()
- ret = _getproperty(127, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR data
- # the data
- def data()
- ret = _getproperty(128, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID data
- # the data
- def data=(arg0)
- ret = _setproperty(128, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMEntityReference
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# structure for reporting parser errors
-module IXMLDOMParseError
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # I4 errorCode
- # the error code
- def errorCode()
- ret = _getproperty(0, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR url
- # the URL of the XML document containing the error
- def url()
- ret = _getproperty(179, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR reason
- # the cause of the error
- def reason()
- ret = _getproperty(180, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR srcText
- # the data where the error occurred
- def srcText()
- ret = _getproperty(181, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 line
- # the line number in the XML document where the error occurred
- def line()
- ret = _getproperty(182, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 linepos
- # the character position in the line containing the error
- def linepos()
- ret = _getproperty(183, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 filepos
- # the absolute file position in the XML document containing the error
- def filepos()
- ret = _getproperty(184, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMNotation
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT publicId
- # the public ID
- def publicId()
- ret = _getproperty(136, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT systemId
- # the system ID
- def systemId()
- ret = _getproperty(137, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-#
-module IXMLDOMEntity
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT publicId
- # the public ID
- def publicId()
- ret = _getproperty(140, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT systemId
- # the system ID
- def systemId()
- ret = _getproperty(141, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR notationName
- # the name of the notation
- def notationName()
- ret = _getproperty(142, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# XTL runtime object
-module IXTLRuntime
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = _getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = _getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = _getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = _getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = _getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = _getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = _getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = _getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = _getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = _getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = _getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = _getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = _getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = _getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = _getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = _getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = _setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = _setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = _setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = _setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = _invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = _invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = _invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = _invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 uniqueID
- # IXMLDOMNode arg0 --- pNode [IN]
- def uniqueID(arg0)
- ret = _invoke(187, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 depth
- # IXMLDOMNode arg0 --- pNode [IN]
- def depth(arg0)
- ret = _invoke(188, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 childNumber
- # IXMLDOMNode arg0 --- pNode [IN]
- def childNumber(arg0)
- ret = _invoke(189, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 ancestorChildNumber
- # BSTR arg0 --- bstrNodeName [IN]
- # IXMLDOMNode arg1 --- pNode [IN]
- def ancestorChildNumber(arg0, arg1)
- ret = _invoke(190, [arg0, arg1], [VT_BSTR, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 absoluteChildNumber
- # IXMLDOMNode arg0 --- pNode [IN]
- def absoluteChildNumber(arg0)
- ret = _invoke(191, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR formatIndex
- # I4 arg0 --- lIndex [IN]
- # BSTR arg1 --- bstrFormat [IN]
- def formatIndex(arg0, arg1)
- ret = _invoke(192, [arg0, arg1], [VT_I4, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR formatNumber
- # R8 arg0 --- dblNumber [IN]
- # BSTR arg1 --- bstrFormat [IN]
- def formatNumber(arg0, arg1)
- ret = _invoke(193, [arg0, arg1], [VT_R8, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR formatDate
- # VARIANT arg0 --- varDate [IN]
- # BSTR arg1 --- bstrFormat [IN]
- # VARIANT arg2 --- varDestLocale [IN]
- def formatDate(arg0, arg1, arg2=nil)
- ret = _invoke(194, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR formatTime
- # VARIANT arg0 --- varTime [IN]
- # BSTR arg1 --- bstrFormat [IN]
- # VARIANT arg2 --- varDestLocale [IN]
- def formatTime(arg0, arg1, arg2=nil)
- ret = _invoke(195, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# W3C-DOM XML Document
-class Microsoft_XMLDOM_1_0 # DOMDocument
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- attr_reader :dispatch
- attr_reader :clsid
- attr_reader :progid
-
- def initialize(obj = nil)
- @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}"
- @progid = "Microsoft.XMLDOM.1.0"
- if obj.nil?
- @dispatch = WIN32OLE.new(@progid)
- else
- @dispatch = obj
- end
- end
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = @dispatch._getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = @dispatch._getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = @dispatch._getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = @dispatch._getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = @dispatch._getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = @dispatch._getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = @dispatch._getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = @dispatch._getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = @dispatch._getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = @dispatch._getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = @dispatch._getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = @dispatch._getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = @dispatch._getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = @dispatch._getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = @dispatch._getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = @dispatch._getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = @dispatch._getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = @dispatch._getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = @dispatch._getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = @dispatch._getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = @dispatch._getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = @dispatch._getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentType doctype
- # node corresponding to the DOCTYPE
- def doctype()
- ret = @dispatch._getproperty(38, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMImplementation implementation
- # info on this DOM implementation
- def implementation()
- ret = @dispatch._getproperty(39, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement documentElement
- # the root of the tree
- def documentElement()
- ret = @dispatch._getproperty(40, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- # get the state of the XML document
- def readyState()
- ret = @dispatch._getproperty(-525, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMParseError parseError
- # get the last parser error
- def parseError()
- ret = @dispatch._getproperty(59, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR url
- # get the URL for the loaded XML document
- def url()
- ret = @dispatch._getproperty(60, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL async
- # flag for asynchronous download
- def async()
- ret = @dispatch._getproperty(61, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse()
- ret = @dispatch._getproperty(65, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals()
- ret = @dispatch._getproperty(66, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace()
- ret = @dispatch._getproperty(67, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID async
- # flag for asynchronous download
- def async=(arg0)
- ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse=(arg0)
- ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals=(arg0)
- ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace=(arg0)
- ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID onreadystatechange
- # register a readystatechange event handler
- def onreadystatechange=(arg0)
- ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ondataavailable
- # register an ondataavailable event handler
- def ondataavailable=(arg0)
- ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ontransformnode
- # register an ontransformnode event handler
- def ontransformnode=(arg0)
- ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = @dispatch._invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement createElement
- # create an Element node
- # BSTR arg0 --- tagName [IN]
- def createElement(arg0)
- ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentFragment createDocumentFragment
- # create a DocumentFragment node
- def createDocumentFragment()
- ret = @dispatch._invoke(42, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMText createTextNode
- # create a text node
- # BSTR arg0 --- data [IN]
- def createTextNode(arg0)
- ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMComment createComment
- # create a comment node
- # BSTR arg0 --- data [IN]
- def createComment(arg0)
- ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMCDATASection createCDATASection
- # create a CDATA section node
- # BSTR arg0 --- data [IN]
- def createCDATASection(arg0)
- ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMProcessingInstruction createProcessingInstruction
- # create a processing instruction node
- # BSTR arg0 --- target [IN]
- # BSTR arg1 --- data [IN]
- def createProcessingInstruction(arg0, arg1)
- ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute createAttribute
- # create an attribute node
- # BSTR arg0 --- name [IN]
- def createAttribute(arg0)
- ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMEntityReference createEntityReference
- # create an entity reference node
- # BSTR arg0 --- name [IN]
- def createEntityReference(arg0)
- ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList getElementsByTagName
- # build a list of elements by name
- # BSTR arg0 --- tagName [IN]
- def getElementsByTagName(arg0)
- ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode createNode
- # create a node of the specified node type and name
- # VARIANT arg0 --- type [IN]
- # BSTR arg1 --- name [IN]
- # BSTR arg2 --- namespaceURI [IN]
- def createNode(arg0, arg1, arg2)
- ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nodeFromID
- # retrieve node from it's ID
- # BSTR arg0 --- idString [IN]
- def nodeFromID(arg0)
- ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL load
- # load document from the specified XML source
- # VARIANT arg0 --- xmlSource [IN]
- def load(arg0)
- ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID abort
- # abort an asynchronous download
- def abort()
- ret = @dispatch._invoke(62, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL loadXML
- # load the document from a string
- # BSTR arg0 --- bstrXML [IN]
- def loadXML(arg0)
- ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID save
- # save the document to a specified destination
- # VARIANT arg0 --- destination [IN]
- def save(arg0)
- ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
- def ondataavailable()
- ret = @dispatch._invoke(198, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
- def onreadystatechange()
- ret = @dispatch._invoke(-609, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# W3C-DOM XML Document (Apartment)
-class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- attr_reader :dispatch
- attr_reader :clsid
- attr_reader :progid
-
- def initialize(obj = nil)
- @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}"
- @progid = "Microsoft.FreeThreadedXMLDOM.1.0"
- if obj.nil?
- @dispatch = WIN32OLE.new(@progid)
- else
- @dispatch = obj
- end
- end
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-
- # BSTR nodeName
- # name of the node
- def nodeName()
- ret = @dispatch._getproperty(2, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeValue
- # value stored in the node
- def nodeValue()
- ret = @dispatch._getproperty(3, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DOMNodeType nodeType
- # the node's type
- def nodeType()
- ret = @dispatch._getproperty(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode parentNode
- # parent of the node
- def parentNode()
- ret = @dispatch._getproperty(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList childNodes
- # the collection of the node's children
- def childNodes()
- ret = @dispatch._getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode firstChild
- # first child of the node
- def firstChild()
- ret = @dispatch._getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode lastChild
- # first child of the node
- def lastChild()
- ret = @dispatch._getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode previousSibling
- # left sibling of the node
- def previousSibling()
- ret = @dispatch._getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nextSibling
- # right sibling of the node
- def nextSibling()
- ret = @dispatch._getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNamedNodeMap attributes
- # the collection of the node's attributes
- def attributes()
- ret = @dispatch._getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocument ownerDocument
- # document that contains the node
- def ownerDocument()
- ret = @dispatch._getproperty(18, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR nodeTypeString
- # the type of node in string form
- def nodeTypeString()
- ret = @dispatch._getproperty(21, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR text
- # text content of the node and subtree
- def text()
- ret = @dispatch._getproperty(24, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL specified
- # indicates whether node is a default value
- def specified()
- ret = @dispatch._getproperty(22, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode definition
- # pointer to the definition of the node in the DTD or schema
- def definition()
- ret = @dispatch._getproperty(23, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue()
- ret = @dispatch._getproperty(25, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT dataType
- # the data type of the node
- def dataType()
- ret = @dispatch._getproperty(26, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR xml
- # return the XML source for the node and each of its descendants
- def xml()
- ret = @dispatch._getproperty(27, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL parsed
- # has sub-tree been completely parsed
- def parsed()
- ret = @dispatch._getproperty(31, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR namespaceURI
- # the URI for the namespace applying to the node
- def namespaceURI()
- ret = @dispatch._getproperty(32, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR prefix
- # the prefix for the namespace applying to the node
- def prefix()
- ret = @dispatch._getproperty(33, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR baseName
- # the base name of the node (nodename with the prefix stripped off)
- def baseName()
- ret = @dispatch._getproperty(34, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentType doctype
- # node corresponding to the DOCTYPE
- def doctype()
- ret = @dispatch._getproperty(38, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMImplementation implementation
- # info on this DOM implementation
- def implementation()
- ret = @dispatch._getproperty(39, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement documentElement
- # the root of the tree
- def documentElement()
- ret = @dispatch._getproperty(40, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- # get the state of the XML document
- def readyState()
- ret = @dispatch._getproperty(-525, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMParseError parseError
- # get the last parser error
- def parseError()
- ret = @dispatch._getproperty(59, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR url
- # get the URL for the loaded XML document
- def url()
- ret = @dispatch._getproperty(60, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL async
- # flag for asynchronous download
- def async()
- ret = @dispatch._getproperty(61, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse()
- ret = @dispatch._getproperty(65, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals()
- ret = @dispatch._getproperty(66, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace()
- ret = @dispatch._getproperty(67, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeValue
- # value stored in the node
- def nodeValue=(arg0)
- ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID text
- # text content of the node and subtree
- def text=(arg0)
- ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID nodeTypedValue
- # get the strongly typed value of the node
- def nodeTypedValue=(arg0)
- ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID dataType
- # the data type of the node
- def dataType=(arg0)
- ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID async
- # flag for asynchronous download
- def async=(arg0)
- ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID validateOnParse
- # indicates whether the parser performs validation
- def validateOnParse=(arg0)
- ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID resolveExternals
- # indicates whether the parser resolves references to external DTD/Entities/Schema
- def resolveExternals=(arg0)
- ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID preserveWhiteSpace
- # indicates whether the parser preserves whitespace
- def preserveWhiteSpace=(arg0)
- ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID onreadystatechange
- # register a readystatechange event handler
- def onreadystatechange=(arg0)
- ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ondataavailable
- # register an ondataavailable event handler
- def ondataavailable=(arg0)
- ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID ontransformnode
- # register an ontransformnode event handler
- def ontransformnode=(arg0)
- ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode insertBefore
- # insert a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # VARIANT arg1 --- refChild [IN]
- def insertBefore(arg0, arg1)
- ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode replaceChild
- # replace a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- # IXMLDOMNode arg1 --- oldChild [IN]
- def replaceChild(arg0, arg1)
- ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode removeChild
- # remove a child node
- # IXMLDOMNode arg0 --- childNode [IN]
- def removeChild(arg0)
- ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode appendChild
- # append a child node
- # IXMLDOMNode arg0 --- newChild [IN]
- def appendChild(arg0)
- ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL hasChildNodes
- def hasChildNodes()
- ret = @dispatch._invoke(17, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode cloneNode
- # BOOL arg0 --- deep [IN]
- def cloneNode(arg0)
- ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR transformNode
- # apply the stylesheet to the subtree
- # IXMLDOMNode arg0 --- stylesheet [IN]
- def transformNode(arg0)
- ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList selectNodes
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectNodes(arg0)
- ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode selectSingleNode
- # execute query on the subtree
- # BSTR arg0 --- queryString [IN]
- def selectSingleNode(arg0)
- ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID transformNodeToObject
- # apply the stylesheet to the subtree, returning the result through a document or a stream
- # IXMLDOMNode arg0 --- stylesheet [IN]
- # VARIANT arg1 --- outputObject [IN]
- def transformNodeToObject(arg0, arg1)
- ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMElement createElement
- # create an Element node
- # BSTR arg0 --- tagName [IN]
- def createElement(arg0)
- ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMDocumentFragment createDocumentFragment
- # create a DocumentFragment node
- def createDocumentFragment()
- ret = @dispatch._invoke(42, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMText createTextNode
- # create a text node
- # BSTR arg0 --- data [IN]
- def createTextNode(arg0)
- ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMComment createComment
- # create a comment node
- # BSTR arg0 --- data [IN]
- def createComment(arg0)
- ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMCDATASection createCDATASection
- # create a CDATA section node
- # BSTR arg0 --- data [IN]
- def createCDATASection(arg0)
- ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMProcessingInstruction createProcessingInstruction
- # create a processing instruction node
- # BSTR arg0 --- target [IN]
- # BSTR arg1 --- data [IN]
- def createProcessingInstruction(arg0, arg1)
- ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMAttribute createAttribute
- # create an attribute node
- # BSTR arg0 --- name [IN]
- def createAttribute(arg0)
- ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMEntityReference createEntityReference
- # create an entity reference node
- # BSTR arg0 --- name [IN]
- def createEntityReference(arg0)
- ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNodeList getElementsByTagName
- # build a list of elements by name
- # BSTR arg0 --- tagName [IN]
- def getElementsByTagName(arg0)
- ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode createNode
- # create a node of the specified node type and name
- # VARIANT arg0 --- type [IN]
- # BSTR arg1 --- name [IN]
- # BSTR arg2 --- namespaceURI [IN]
- def createNode(arg0, arg1, arg2)
- ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # IXMLDOMNode nodeFromID
- # retrieve node from it's ID
- # BSTR arg0 --- idString [IN]
- def nodeFromID(arg0)
- ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL load
- # load document from the specified XML source
- # VARIANT arg0 --- xmlSource [IN]
- def load(arg0)
- ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID abort
- # abort an asynchronous download
- def abort()
- ret = @dispatch._invoke(62, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BOOL loadXML
- # load the document from a string
- # BSTR arg0 --- bstrXML [IN]
- def loadXML(arg0)
- ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID save
- # save the document to a specified destination
- # VARIANT arg0 --- destination [IN]
- def save(arg0)
- ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
- def ondataavailable()
- ret = @dispatch._invoke(198, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
- def onreadystatechange()
- ret = @dispatch._invoke(-609, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# IXMLHttpRequest Interface
-module IXMLHttpRequest
- include WIN32OLE::VARIANT
- attr_reader :lastargs
-
- # I4 status
- # Get HTTP status code
- def status()
- ret = _getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR statusText
- # Get HTTP status text
- def statusText()
- ret = _getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DISPATCH responseXML
- # Get response body
- def responseXML()
- ret = _getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR responseText
- # Get response body
- def responseText()
- ret = _getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT responseBody
- # Get response body
- def responseBody()
- ret = _getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT responseStream
- # Get response body
- def responseStream()
- ret = _getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- # Get ready state
- def readyState()
- ret = _getproperty(13, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID onreadystatechange
- # Register a complete event handler
- def onreadystatechange=(arg0)
- ret = _setproperty(14, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID open
- # Open HTTP connection
- # BSTR arg0 --- bstrMethod [IN]
- # BSTR arg1 --- bstrUrl [IN]
- # VARIANT arg2 --- varAsync [IN]
- # VARIANT arg3 --- bstrUser [IN]
- # VARIANT arg4 --- bstrPassword [IN]
- def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
- ret = _invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID setRequestHeader
- # Add HTTP request header
- # BSTR arg0 --- bstrHeader [IN]
- # BSTR arg1 --- bstrValue [IN]
- def setRequestHeader(arg0, arg1)
- ret = _invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR getResponseHeader
- # Get HTTP response header
- # BSTR arg0 --- bstrHeader [IN]
- def getResponseHeader(arg0)
- ret = _invoke(3, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR getAllResponseHeaders
- # Get all HTTP response headers
- def getAllResponseHeaders()
- ret = _invoke(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID send
- # Send HTTP request
- # VARIANT arg0 --- varBody [IN]
- def send(arg0=nil)
- ret = _invoke(5, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID abort
- # Abort HTTP request
- def abort()
- ret = _invoke(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# XML HTTP Request class.
-class Microsoft_XMLHTTP_1 # XMLHTTPRequest
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- attr_reader :dispatch
- attr_reader :clsid
- attr_reader :progid
-
- def initialize(obj = nil)
- @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}"
- @progid = "Microsoft.XMLHTTP.1"
- if obj.nil?
- @dispatch = WIN32OLE.new(@progid)
- else
- @dispatch = obj
- end
- end
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-
- # I4 status
- # Get HTTP status code
- def status()
- ret = @dispatch._getproperty(7, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR statusText
- # Get HTTP status text
- def statusText()
- ret = @dispatch._getproperty(8, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # DISPATCH responseXML
- # Get response body
- def responseXML()
- ret = @dispatch._getproperty(9, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR responseText
- # Get response body
- def responseText()
- ret = @dispatch._getproperty(10, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT responseBody
- # Get response body
- def responseBody()
- ret = @dispatch._getproperty(11, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VARIANT responseStream
- # Get response body
- def responseStream()
- ret = @dispatch._getproperty(12, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- # Get ready state
- def readyState()
- ret = @dispatch._getproperty(13, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID onreadystatechange
- # Register a complete event handler
- def onreadystatechange=(arg0)
- ret = @dispatch._setproperty(14, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID open
- # Open HTTP connection
- # BSTR arg0 --- bstrMethod [IN]
- # BSTR arg1 --- bstrUrl [IN]
- # VARIANT arg2 --- varAsync [IN]
- # VARIANT arg3 --- bstrUser [IN]
- # VARIANT arg4 --- bstrPassword [IN]
- def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
- ret = @dispatch._invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID setRequestHeader
- # Add HTTP request header
- # BSTR arg0 --- bstrHeader [IN]
- # BSTR arg1 --- bstrValue [IN]
- def setRequestHeader(arg0, arg1)
- ret = @dispatch._invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR getResponseHeader
- # Get HTTP response header
- # BSTR arg0 --- bstrHeader [IN]
- def getResponseHeader(arg0)
- ret = @dispatch._invoke(3, [arg0], [VT_BSTR])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # BSTR getAllResponseHeaders
- # Get all HTTP response headers
- def getAllResponseHeaders()
- ret = @dispatch._invoke(4, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID send
- # Send HTTP request
- # VARIANT arg0 --- varBody [IN]
- def send(arg0=nil)
- ret = @dispatch._invoke(5, [arg0], [VT_VARIANT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID abort
- # Abort HTTP request
- def abort()
- ret = @dispatch._invoke(6, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# XML Data Source Object
-class Microsoft_XMLDSO_1_0 # XMLDSOControl
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- attr_reader :dispatch
- attr_reader :clsid
- attr_reader :progid
-
- def initialize(obj = nil)
- @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}"
- @progid = "Microsoft.XMLDSO.1.0"
- if obj.nil?
- @dispatch = WIN32OLE.new(@progid)
- else
- @dispatch = obj
- end
- end
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-
- # IXMLDOMDocument XMLDocument
- def XMLDocument()
- ret = @dispatch._getproperty(65537, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 JavaDSOCompatible
- def JavaDSOCompatible()
- ret = @dispatch._getproperty(65538, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # I4 readyState
- def readyState()
- ret = @dispatch._getproperty(-525, [], [])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID XMLDocument
- def XMLDocument=(arg0)
- ret = @dispatch._setproperty(65537, [arg0], [VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # VOID JavaDSOCompatible
- def JavaDSOCompatible=(arg0)
- ret = @dispatch._setproperty(65538, [arg0], [VT_I4])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
-
-# Constants that define types for IXMLElement.
-module OLEtagXMLEMEM_TYPE
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- XMLELEMTYPE_ELEMENT = 0
- XMLELEMTYPE_TEXT = 1
- XMLELEMTYPE_COMMENT = 2
- XMLELEMTYPE_DOCUMENT = 3
- XMLELEMTYPE_DTD = 4
- XMLELEMTYPE_PI = 5
- XMLELEMTYPE_OTHER = 6
-end
-
-# XMLDocument extends IXML Document. It is obsolete. You should use DOMDocument. This object should not be confused with the XMLDocument property on the XML data island.
-class Msxml # XMLDocument
- include WIN32OLE::VARIANT
- attr_reader :lastargs
- attr_reader :dispatch
- attr_reader :clsid
- attr_reader :progid
-
- def initialize(obj = nil)
- @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}"
- @progid = "Msxml"
- if obj.nil?
- @dispatch = WIN32OLE.new(@progid)
- else
- @dispatch = obj
- end
- end
-
- def method_missing(cmd, *arg)
- @dispatch.method_missing(cmd, *arg)
- end
-
- # HRESULT url
- # set URL to load an XML document from the URL.
- # BSTR arg0 --- p [IN]
- def url=(arg0)
- ret = @dispatch._setproperty(65641, [arg0], [VT_BSTR, VT_HRESULT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT charset
- # get encoding.
- # BSTR arg0 --- p [IN]
- def charset=(arg0)
- ret = @dispatch._setproperty(65645, [arg0], [VT_BSTR, VT_HRESULT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT async
- # get asynchronous loading flag.
- # BOOL arg0 --- pf [IN]
- def async=(arg0)
- ret = @dispatch._setproperty(65649, [arg0], [VT_BOOL, VT_HRESULT])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-
- # HRESULT root
- # get root IXMLElement of the XML document.
- # IXMLElement2,IXMLElement2 arg0 --- p [OUT]
- def root
- OLEProperty.new(@dispatch, 65637, [VT_BYREF|VT_BYREF|VT_DISPATCH], [VT_BYREF|VT_BYREF|VT_DISPATCH, VT_HRESULT])
- end
-
- # HRESULT url
- # set URL to load an XML document from the URL.
- # BSTR arg0 --- p [OUT]
- def url
- OLEProperty.new(@dispatch, 65641, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
- end
-
- # HRESULT readyState
- # get ready state.
- # I4 arg0 --- pl [OUT]
- def readyState
- OLEProperty.new(@dispatch, 65643, [VT_BYREF|VT_I4], [VT_BYREF|VT_I4, VT_HRESULT])
- end
-
- # HRESULT charset
- # get encoding.
- # BSTR arg0 --- p [OUT]
- def charset
- OLEProperty.new(@dispatch, 65645, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
- end
-
- # HRESULT version
- # get XML version number.
- # BSTR arg0 --- p [OUT]
- def version
- OLEProperty.new(@dispatch, 65646, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
- end
-
- # HRESULT doctype
- # get document type.
- # BSTR arg0 --- p [OUT]
- def doctype
- OLEProperty.new(@dispatch, 65647, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
- end
-
- # HRESULT async
- # get asynchronous loading flag.
- # BOOL arg0 --- pf [OUT]
- def async
- OLEProperty.new(@dispatch, 65649, [VT_BYREF|VT_BOOL], [VT_BYREF|VT_BOOL, VT_HRESULT])
- end
-
- # HRESULT createElement
- # create different types of IXMLElements.
- # VARIANT arg0 --- vType [IN]
- # VARIANT arg1 --- var1 [IN]
- # IXMLElement2,IXMLElement2 arg2 --- ppElem [OUT]
- def createElement(arg0, arg1=nil, arg2=nil)
- ret = @dispatch._invoke(65644, [arg0, arg1, arg2], [VT_VARIANT, VT_VARIANT, VT_BYREF|VT_BYREF|VT_DISPATCH])
- @lastargs = WIN32OLE::ARGV
- ret
- end
-end
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
deleted file mode 100644
index 3f083bb12d..0000000000
--- a/ext/win32ole/win32ole.c
+++ /dev/null
@@ -1,4142 +0,0 @@
-/*
- * (c) 1995 Microsoft Corporation. All rights reserved.
- * Developed by ActiveWare Internet Corp., now known as
- * ActiveState Tool Corp., http://www.ActiveState.com
- *
- * Other modifications Copyright (c) 1997, 1998 by Gurusamy Sarathy
- * <gsar@umich.edu> and Jan Dubois <jan.dubois@ibm.net>
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file
- * of the Perl distribution.
- *
- */
-
-/*
- modified for win32ole (ruby) by Masaki.Suketa <masaki.suketa@nifty.ne.jp>
- */
-
-#include "win32ole.h"
-
-/*
- * unfortunately IID_IMultiLanguage2 is not included in any libXXX.a
- * in Cygwin(mingw32).
- */
-#if defined(__CYGWIN__) || defined(__MINGW32__)
-#undef IID_IMultiLanguage2
-const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A}};
-#endif
-
-#define WIN32OLE_VERSION "1.8.8"
-
-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);
-VALUE cWIN32OLE;
-
-#if defined(RB_THREAD_SPECIFIC) && (defined(__CYGWIN__))
-static RB_THREAD_SPECIFIC BOOL g_ole_initialized;
-# define g_ole_initialized_init() ((void)0)
-# define g_ole_initialized_set(val) (g_ole_initialized = (val))
-#else
-static volatile DWORD g_ole_initialized_key = TLS_OUT_OF_INDEXES;
-# define g_ole_initialized (TlsGetValue(g_ole_initialized_key)!=0)
-# define g_ole_initialized_init() (g_ole_initialized_key = TlsAlloc())
-# define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
-#endif
-
-static BOOL g_uninitialize_hooked = FALSE;
-static BOOL g_cp_installed = FALSE;
-static BOOL g_lcid_installed = FALSE;
-static BOOL g_running_nano = FALSE;
-static HINSTANCE ghhctrl = NULL;
-static HINSTANCE gole32 = NULL;
-static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL;
-static VALUE com_hash;
-static VALUE enc2cp_hash;
-static IDispatchVtbl com_vtbl;
-static UINT cWIN32OLE_cp = CP_ACP;
-static rb_encoding *cWIN32OLE_enc;
-static UINT g_cp_to_check = CP_ACP;
-static char g_lcid_to_check[8 + 1];
-static VARTYPE g_nil_to = VT_ERROR;
-static IMessageFilterVtbl message_filter;
-static IMessageFilter imessage_filter = { &message_filter };
-static IMessageFilter* previous_filter;
-
-#if defined(HAVE_TYPE_IMULTILANGUAGE2)
-static IMultiLanguage2 *pIMultiLanguage = NULL;
-#elif defined(HAVE_TYPE_IMULTILANGUAGE)
-static IMultiLanguage *pIMultiLanguage = NULL;
-#else
-#define pIMultiLanguage NULL /* dummy */
-#endif
-
-struct oleparam {
- DISPPARAMS dp;
- OLECHAR** pNamedArgs;
-};
-
-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 double rbtime2vtdate(VALUE tmobj);
-static VALUE vtdate2rbtime(double date);
-static rb_encoding *ole_cp2encoding(UINT cp);
-static UINT ole_encoding2cp(rb_encoding *enc);
-NORETURN(static void failed_load_conv51932(void));
-#ifndef pIMultiLanguage
-static void load_conv_function51932(void);
-#endif
-static UINT ole_init_cp(void);
-static void ole_freeexceptinfo(EXCEPINFO *pExInfo);
-static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
-static void ole_free(void *ptr);
-static size_t ole_size(const void *ptr);
-static LPWSTR ole_mb2wc(char *pm, int len, UINT cp);
-static VALUE ole_ary_m_entry(VALUE val, LONG *pid);
-static VALUE is_all_index_under(LONG *pid, long *pub, long dim);
-static void * get_ptr_of_variant(VARIANT *pvar);
-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 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 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(VALUE self, VALUE ole, VALUE host, VALUE others);
-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 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_s_ole_initialize(VALUE self);
-static VALUE fole_s_ole_uninitialize(VALUE self);
-static VALUE fole_initialize(int argc, VALUE *argv, VALUE self);
-static int hash2named_arg(VALUE key, VALUE val, VALUE 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 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 fole_type(VALUE self);
-static VALUE fole_typelib(VALUE self);
-static VALUE fole_query_interface(VALUE self, VALUE str_iid);
-static VALUE fole_respond_to(VALUE self, VALUE method);
-static VALUE ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-static VALUE ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-static VALUE fole_method_help(VALUE self, VALUE cmdname);
-static VALUE fole_activex_initialize(VALUE self);
-
-static void com_hash_free(void *ptr);
-static void com_hash_mark(void *ptr);
-static size_t com_hash_size(const void *ptr);
-static void check_nano_server(void);
-
-static const rb_data_type_t ole_datatype = {
- "win32ole",
- {NULL, ole_free, ole_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static const rb_data_type_t win32ole_hash_datatype = {
- "win32ole_hash",
- {com_hash_mark, com_hash_free, com_hash_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-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 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;
- ULONG refcount;
- VALUE obj;
-} Win32OLEIDispatch;
-
-static HRESULT ( STDMETHODCALLTYPE QueryInterface )(
- IDispatch __RPC_FAR * This,
- /* [in] */ REFIID riid,
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
-{
- if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
- || MEMCMP(riid, &IID_IDispatch, GUID, 1) == 0)
- {
- Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- p->refcount++;
- *ppvObject = This;
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-static ULONG ( STDMETHODCALLTYPE AddRef )(
- IDispatch __RPC_FAR * This)
-{
- Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- return ++(p->refcount);
-}
-
-static ULONG ( STDMETHODCALLTYPE Release )(
- IDispatch __RPC_FAR * This)
-{
- Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- ULONG u = --(p->refcount);
- if (u == 0) {
- st_data_t key = p->obj;
- st_delete(DATA_PTR(com_hash), &key, 0);
- free(p);
- }
- return u;
-}
-
-static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount )(
- IDispatch __RPC_FAR * This,
- /* [out] */ UINT __RPC_FAR *pctinfo)
-{
- return E_NOTIMPL;
-}
-
-static HRESULT ( STDMETHODCALLTYPE GetTypeInfo )(
- IDispatch __RPC_FAR * This,
- /* [in] */ UINT iTInfo,
- /* [in] */ LCID lcid,
- /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
-{
- return E_NOTIMPL;
-}
-
-
-static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(
- IDispatch __RPC_FAR * This,
- /* [in] */ REFIID riid,
- /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
- /* [in] */ UINT cNames,
- /* [in] */ LCID lcid,
- /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
-{
- /*
- Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- */
- char* psz = ole_wc2mb(*rgszNames); // support only one method
- ID nameid = rb_check_id_cstr(psz, (long)strlen(psz), cWIN32OLE_enc);
- free(psz);
- if ((ID)(DISPID)nameid != nameid) return E_NOINTERFACE;
- *rgDispId = (DISPID)nameid;
- return S_OK;
-}
-
-static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke )(
- IDispatch __RPC_FAR * This,
- /* [in] */ DISPID dispIdMember,
- /* [in] */ REFIID riid,
- /* [in] */ LCID lcid,
- /* [in] */ WORD wFlags,
- /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
- /* [out] */ VARIANT __RPC_FAR *pVarResult,
- /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
- /* [out] */ UINT __RPC_FAR *puArgErr)
-{
- VALUE v;
- int i;
- int args = pDispParams->cArgs;
- Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- VALUE* parg = ALLOCA_N(VALUE, args);
- ID mid = (ID)dispIdMember;
- for (i = 0; i < args; i++) {
- *(parg + i) = ole_variant2val(&pDispParams->rgvarg[args - i - 1]);
- }
- if (dispIdMember == DISPID_VALUE) {
- if (wFlags == DISPATCH_METHOD) {
- mid = rb_intern("call");
- } else if (wFlags & DISPATCH_PROPERTYGET) {
- mid = rb_intern("value");
- }
- }
- v = rb_funcallv(p->obj, mid, args, parg);
- ole_val2variant(v, pVarResult);
- return S_OK;
-}
-
-BOOL
-ole_initialized(void)
-{
- return g_ole_initialized;
-}
-
-static IDispatch*
-val2dispatch(VALUE val)
-{
- struct st_table *tbl = DATA_PTR(com_hash);
- Win32OLEIDispatch* pdisp;
- st_data_t data;
- if (st_lookup(tbl, val, &data)) {
- pdisp = (Win32OLEIDispatch *)(data & ~FIXNUM_FLAG);
- pdisp->refcount++;
- }
- else {
- pdisp = ALLOC(Win32OLEIDispatch);
- pdisp->dispatch.lpVtbl = &com_vtbl;
- pdisp->refcount = 1;
- pdisp->obj = val;
- st_insert(tbl, val, (VALUE)pdisp | FIXNUM_FLAG);
- }
- return &pdisp->dispatch;
-}
-
-static double
-rbtime2vtdate(VALUE tmobj)
-{
- SYSTEMTIME st;
- double t;
- double nsec;
-
- st.wYear = RB_FIX2INT(rb_funcall(tmobj, rb_intern("year"), 0));
- st.wMonth = RB_FIX2INT(rb_funcall(tmobj, rb_intern("month"), 0));
- st.wDay = RB_FIX2INT(rb_funcall(tmobj, rb_intern("mday"), 0));
- st.wHour = RB_FIX2INT(rb_funcall(tmobj, rb_intern("hour"), 0));
- st.wMinute = RB_FIX2INT(rb_funcall(tmobj, rb_intern("min"), 0));
- st.wSecond = RB_FIX2INT(rb_funcall(tmobj, rb_intern("sec"), 0));
- st.wMilliseconds = 0;
- SystemTimeToVariantTime(&st, &t);
-
- /*
- * Unfortunately SystemTimeToVariantTime function always ignores the
- * wMilliseconds of SYSTEMTIME struct.
- * So, we need to calculate milliseconds by ourselves.
- */
- nsec = RB_FIX2INT(rb_funcall(tmobj, rb_intern("nsec"), 0));
- nsec /= 1000000.0;
- nsec /= (24.0 * 3600.0);
- nsec /= 1000;
- return t + nsec;
-}
-
-static VALUE
-vtdate2rbtime(double date)
-{
- SYSTEMTIME st;
- VALUE v;
- double msec;
- double sec;
- VariantTimeToSystemTime(date, &st);
- v = rb_funcall(rb_cTime, rb_intern("new"), 6,
- RB_INT2FIX(st.wYear),
- RB_INT2FIX(st.wMonth),
- RB_INT2FIX(st.wDay),
- RB_INT2FIX(st.wHour),
- RB_INT2FIX(st.wMinute),
- RB_INT2FIX(st.wSecond));
- st.wYear = RB_FIX2INT(rb_funcall(v, rb_intern("year"), 0));
- st.wMonth = RB_FIX2INT(rb_funcall(v, rb_intern("month"), 0));
- st.wDay = RB_FIX2INT(rb_funcall(v, rb_intern("mday"), 0));
- st.wHour = RB_FIX2INT(rb_funcall(v, rb_intern("hour"), 0));
- st.wMinute = RB_FIX2INT(rb_funcall(v, rb_intern("min"), 0));
- st.wSecond = RB_FIX2INT(rb_funcall(v, rb_intern("sec"), 0));
- st.wMilliseconds = 0;
- SystemTimeToVariantTime(&st, &sec);
- /*
- * Unfortunately VariantTimeToSystemTime always ignores the
- * wMilliseconds of SYSTEMTIME struct(The wMilliseconds is 0).
- * So, we need to calculate milliseconds by ourselves.
- */
- msec = date - sec;
- msec *= 24 * 60;
- msec -= floor(msec);
- msec *= 60;
- if (msec >= 59) {
- msec -= 60;
- }
- if (msec != 0) {
- return rb_funcall(v, rb_intern("+"), 1, rb_float_new(msec));
- }
- return v;
-}
-
-#define ENC_MACHING_CP(enc,encname,cp) if(strcasecmp(rb_enc_name((enc)),(encname)) == 0) return cp
-
-static UINT ole_encoding2cp(rb_encoding *enc)
-{
- /*
- * Is there any better solution to convert
- * Ruby encoding to Windows codepage???
- */
- ENC_MACHING_CP(enc, "Big5", 950);
- ENC_MACHING_CP(enc, "CP51932", 51932);
- ENC_MACHING_CP(enc, "CP850", 850);
- ENC_MACHING_CP(enc, "CP852", 852);
- ENC_MACHING_CP(enc, "CP855", 855);
- ENC_MACHING_CP(enc, "CP949", 949);
- ENC_MACHING_CP(enc, "EUC-JP", 20932);
- ENC_MACHING_CP(enc, "EUC-KR", 51949);
- ENC_MACHING_CP(enc, "EUC-TW", 51950);
- ENC_MACHING_CP(enc, "GB18030", 54936);
- ENC_MACHING_CP(enc, "GB2312", 20936);
- ENC_MACHING_CP(enc, "GBK", 936);
- ENC_MACHING_CP(enc, "IBM437", 437);
- ENC_MACHING_CP(enc, "IBM720", 720);
- ENC_MACHING_CP(enc, "IBM737", 737);
- ENC_MACHING_CP(enc, "IBM775", 775);
- ENC_MACHING_CP(enc, "IBM852", 852);
- ENC_MACHING_CP(enc, "IBM855", 855);
- ENC_MACHING_CP(enc, "IBM857", 857);
- ENC_MACHING_CP(enc, "IBM860", 860);
- ENC_MACHING_CP(enc, "IBM861", 861);
- ENC_MACHING_CP(enc, "IBM862", 862);
- ENC_MACHING_CP(enc, "IBM863", 863);
- ENC_MACHING_CP(enc, "IBM864", 864);
- ENC_MACHING_CP(enc, "IBM865", 865);
- ENC_MACHING_CP(enc, "IBM866", 866);
- ENC_MACHING_CP(enc, "IBM869", 869);
- ENC_MACHING_CP(enc, "ISO-2022-JP", 50220);
- ENC_MACHING_CP(enc, "ISO-8859-1", 28591);
- ENC_MACHING_CP(enc, "ISO-8859-15", 28605);
- ENC_MACHING_CP(enc, "ISO-8859-2", 28592);
- ENC_MACHING_CP(enc, "ISO-8859-3", 28593);
- ENC_MACHING_CP(enc, "ISO-8859-4", 28594);
- ENC_MACHING_CP(enc, "ISO-8859-5", 28595);
- ENC_MACHING_CP(enc, "ISO-8859-6", 28596);
- ENC_MACHING_CP(enc, "ISO-8859-7", 28597);
- ENC_MACHING_CP(enc, "ISO-8859-8", 28598);
- ENC_MACHING_CP(enc, "ISO-8859-9", 28599);
- ENC_MACHING_CP(enc, "KOI8-R", 20866);
- ENC_MACHING_CP(enc, "KOI8-U", 21866);
- ENC_MACHING_CP(enc, "Shift_JIS", 932);
- ENC_MACHING_CP(enc, "UTF-16BE", 1201);
- ENC_MACHING_CP(enc, "UTF-16LE", 1200);
- ENC_MACHING_CP(enc, "UTF-7", 65000);
- ENC_MACHING_CP(enc, "UTF-8", 65001);
- ENC_MACHING_CP(enc, "Windows-1250", 1250);
- ENC_MACHING_CP(enc, "Windows-1251", 1251);
- ENC_MACHING_CP(enc, "Windows-1252", 1252);
- ENC_MACHING_CP(enc, "Windows-1253", 1253);
- ENC_MACHING_CP(enc, "Windows-1254", 1254);
- ENC_MACHING_CP(enc, "Windows-1255", 1255);
- ENC_MACHING_CP(enc, "Windows-1256", 1256);
- ENC_MACHING_CP(enc, "Windows-1257", 1257);
- ENC_MACHING_CP(enc, "Windows-1258", 1258);
- ENC_MACHING_CP(enc, "Windows-31J", 932);
- ENC_MACHING_CP(enc, "Windows-874", 874);
- ENC_MACHING_CP(enc, "eucJP-ms", 20932);
- return CP_ACP;
-}
-
-static void
-failed_load_conv51932(void)
-{
- rb_raise(eWIN32OLERuntimeError, "fail to load convert function for CP51932");
-}
-
-#ifndef pIMultiLanguage
-static void
-load_conv_function51932(void)
-{
- HRESULT hr = E_NOINTERFACE;
- void *p;
- if (!pIMultiLanguage) {
-#if defined(HAVE_TYPE_IMULTILANGUAGE2)
- hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
- &IID_IMultiLanguage2, &p);
-#elif defined(HAVE_TYPE_IMULTILANGUAGE)
- hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
- &IID_IMultiLanguage, &p);
-#endif
- if (FAILED(hr)) {
- failed_load_conv51932();
- }
- pIMultiLanguage = p;
- }
-}
-#define need_conv_function51932() (load_conv_function51932(), 1)
-#else
-#define load_conv_function51932() failed_load_conv51932()
-#define need_conv_function51932() (failed_load_conv51932(), 0)
-#endif
-
-#define conv_51932(cp) ((cp) == 51932 && need_conv_function51932())
-
-static void
-set_ole_codepage(UINT cp)
-{
- if (code_page_installed(cp)) {
- 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;
- case 51932:
- cWIN32OLE_cp = cp;
- load_conv_function51932();
- 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;
- }
- }
- cWIN32OLE_enc = ole_cp2encoding(cWIN32OLE_cp);
-}
-
-
-static UINT
-ole_init_cp(void)
-{
- UINT cp;
- rb_encoding *encdef;
- encdef = rb_default_internal_encoding();
- if (!encdef) {
- encdef = rb_default_external_encoding();
- }
- cp = ole_encoding2cp(encdef);
- set_ole_codepage(cp);
- return cp;
-}
-
-struct myCPINFOEX {
- UINT MaxCharSize;
- BYTE DefaultChar[2];
- BYTE LeadByte[12];
- WCHAR UnicodeDefaultChar;
- UINT CodePage;
- char CodePageName[MAX_PATH];
-};
-
-static rb_encoding *
-ole_cp2encoding(UINT cp)
-{
- static BOOL (*pGetCPInfoEx)(UINT, DWORD, struct myCPINFOEX *) = NULL;
- struct myCPINFOEX* buf;
- VALUE enc_name;
- char *enc_cstr;
- int idx;
-
- if (!code_page_installed(cp)) {
- switch(cp) {
- case CP_ACP:
- cp = GetACP();
- break;
- case CP_OEMCP:
- cp = GetOEMCP();
- break;
- case CP_MACCP:
- case CP_THREAD_ACP:
- if (!pGetCPInfoEx) {
- pGetCPInfoEx = (BOOL (*)(UINT, DWORD, struct myCPINFOEX *))
- GetProcAddress(GetModuleHandle("kernel32"), "GetCPInfoEx");
- if (!pGetCPInfoEx) {
- pGetCPInfoEx = (void*)-1;
- }
- }
- buf = ALLOCA_N(struct myCPINFOEX, 1);
- ZeroMemory(buf, sizeof(struct myCPINFOEX));
- if (pGetCPInfoEx == (void*)-1 || !pGetCPInfoEx(cp, 0, buf)) {
- rb_raise(eWIN32OLERuntimeError, "cannot map codepage to encoding.");
- break; /* never reach here */
- }
- cp = buf->CodePage;
- break;
- case CP_SYMBOL:
- case CP_UTF7:
- case CP_UTF8:
- break;
- case 51932:
- load_conv_function51932();
- 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;
- }
- }
-
- enc_name = rb_sprintf("CP%d", cp);
- idx = rb_enc_find_index(enc_cstr = StringValueCStr(enc_name));
- if (idx < 0)
- idx = rb_define_dummy_encoding(enc_cstr);
- return rb_enc_from_index(idx);
-}
-
-#ifndef pIMultiLanguage
-static HRESULT
-ole_ml_wc2mb_conv0(LPWSTR pw, LPSTR pm, UINT *size)
-{
- DWORD dw = 0;
- return pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
- &dw, cWIN32OLE_cp, pw, NULL, pm, size);
-}
-#define ole_ml_wc2mb_conv(pw, pm, size, onfailure) do { \
- HRESULT hr = ole_ml_wc2mb_conv0(pw, pm, &size); \
- if (FAILED(hr)) { \
- onfailure; \
- ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp); \
- } \
- } while (0)
-#endif
-
-#define ole_wc2mb_conv(pw, pm, size) WideCharToMultiByte(cWIN32OLE_cp, 0, (pw), -1, (pm), (size), NULL, NULL)
-
-static char *
-ole_wc2mb_alloc(LPWSTR pw, char *(alloc)(UINT size, void *arg), void *arg)
-{
- LPSTR pm;
- UINT size = 0;
- if (conv_51932(cWIN32OLE_cp)) {
-#ifndef pIMultiLanguage
- ole_ml_wc2mb_conv(pw, NULL, size, {});
- pm = alloc(size, arg);
- if (size) ole_ml_wc2mb_conv(pw, pm, size, xfree(pm));
- pm[size] = '\0';
- return pm;
-#endif
- }
- size = ole_wc2mb_conv(pw, NULL, 0);
- pm = alloc(size, arg);
- if (size) ole_wc2mb_conv(pw, pm, size);
- pm[size] = '\0';
- return pm;
-}
-
-static char *
-ole_alloc_str(UINT size, void *arg)
-{
- return ALLOC_N(char, size + 1);
-}
-
-char *
-ole_wc2mb(LPWSTR pw)
-{
- return ole_wc2mb_alloc(pw, ole_alloc_str, NULL);
-}
-
-static void
-ole_freeexceptinfo(EXCEPINFO *pExInfo)
-{
- SysFreeString(pExInfo->bstrDescription);
- SysFreeString(pExInfo->bstrSource);
- SysFreeString(pExInfo->bstrHelpFile);
-}
-
-static VALUE
-ole_excepinfo2msg(EXCEPINFO *pExInfo)
-{
- char error_code[40];
- char *pSource = NULL;
- char *pDescription = NULL;
- VALUE error_msg;
- if(pExInfo->pfnDeferredFillIn != NULL) {
- (*pExInfo->pfnDeferredFillIn)(pExInfo);
- }
- if (pExInfo->bstrSource != NULL) {
- pSource = ole_wc2mb(pExInfo->bstrSource);
- }
- if (pExInfo->bstrDescription != NULL) {
- pDescription = ole_wc2mb(pExInfo->bstrDescription);
- }
- if(pExInfo->wCode == 0) {
- sprintf(error_code, "\n OLE error code:%lX in ", (unsigned long)pExInfo->scode);
- }
- else{
- sprintf(error_code, "\n OLE error code:%u in ", pExInfo->wCode);
- }
- error_msg = rb_str_new2(error_code);
- if(pSource != NULL) {
- rb_str_cat2(error_msg, pSource);
- }
- else {
- rb_str_cat(error_msg, "<Unknown>", 9);
- }
- rb_str_cat2(error_msg, "\n ");
- if(pDescription != NULL) {
- rb_str_cat2(error_msg, pDescription);
- }
- else {
- rb_str_cat2(error_msg, "<No Description>");
- }
- if(pSource) free(pSource);
- if(pDescription) free(pDescription);
- ole_freeexceptinfo(pExInfo);
- return error_msg;
-}
-
-void
-ole_uninitialize(void)
-{
- if (!g_ole_initialized) return;
- OleUninitialize();
- g_ole_initialized_set(FALSE);
-}
-
-static void
-ole_uninitialize_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
-{
- ole_uninitialize();
-}
-
-void
-ole_initialize(void)
-{
- HRESULT hr;
-
- if(!g_uninitialize_hooked) {
- rb_add_event_hook(ole_uninitialize_hook, RUBY_EVENT_THREAD_END, Qnil);
- g_uninitialize_hooked = TRUE;
- }
-
- if(g_ole_initialized == FALSE) {
- if(g_running_nano) {
- hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
- } else {
- hr = OleInitialize(NULL);
- }
- if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "fail: OLE initialize");
- }
- g_ole_initialized_set(TRUE);
-
- if (g_running_nano == FALSE) {
- hr = CoRegisterMessageFilter(&imessage_filter, &previous_filter);
- if(FAILED(hr)) {
- previous_filter = NULL;
- ole_raise(hr, rb_eRuntimeError, "fail: install OLE MessageFilter");
- }
- }
- }
-}
-
-static void
-ole_free(void *ptr)
-{
- struct oledata *pole = ptr;
- OLE_FREE(pole->pDispatch);
- free(pole);
-}
-
-static size_t ole_size(const void *ptr)
-{
- return ptr ? sizeof(struct oledata) : 0;
-}
-
-struct oledata *
-oledata_get_struct(VALUE ole)
-{
- struct oledata *pole;
- TypedData_Get_Struct(ole, struct oledata, &ole_datatype, pole);
- return pole;
-}
-
-LPWSTR
-ole_vstr2wc(VALUE vstr)
-{
- rb_encoding *enc;
- int cp;
- LPWSTR pw;
- st_data_t data;
- struct st_table *tbl = DATA_PTR(enc2cp_hash);
-
- /* do not type-conversion here to prevent from other arguments
- * changing (if exist) */
- Check_Type(vstr, T_STRING);
- if (RSTRING_LEN(vstr) == 0) {
- return NULL;
- }
-
- enc = rb_enc_get(vstr);
-
- if (st_lookup(tbl, (VALUE)enc | FIXNUM_FLAG, &data)) {
- cp = RB_FIX2INT((VALUE)data);
- } else {
- cp = ole_encoding2cp(enc);
- if (code_page_installed(cp) ||
- cp == CP_ACP ||
- cp == CP_OEMCP ||
- cp == CP_MACCP ||
- cp == CP_THREAD_ACP ||
- cp == CP_SYMBOL ||
- cp == CP_UTF7 ||
- cp == CP_UTF8 ||
- cp == 51932) {
- st_insert(tbl, (VALUE)enc | FIXNUM_FLAG, RB_INT2FIX(cp));
- } else {
- rb_raise(eWIN32OLERuntimeError, "not installed Windows codepage(%d) according to `%s'", cp, rb_enc_name(enc));
- }
- }
- pw = ole_mb2wc(RSTRING_PTR(vstr), RSTRING_LENINT(vstr), cp);
- RB_GC_GUARD(vstr);
- return pw;
-}
-
-static LPWSTR
-ole_mb2wc(char *pm, int len, UINT cp)
-{
- UINT size = 0;
- LPWSTR pw;
-
- if (conv_51932(cp)) {
-#ifndef pIMultiLanguage
- DWORD dw = 0;
- UINT n = len;
- HRESULT hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
- &dw, cp, pm, &n, NULL, &size);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
- }
- pw = SysAllocStringLen(NULL, size);
- n = len;
- hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
- &dw, cp, pm, &n, pw, &size);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
- }
- return pw;
-#endif
- }
- size = MultiByteToWideChar(cp, 0, pm, len, NULL, 0);
- pw = SysAllocStringLen(NULL, size);
- pw[size-1] = 0;
- MultiByteToWideChar(cp, 0, pm, len, pw, size);
- return pw;
-}
-
-static char *
-ole_alloc_vstr(UINT size, void *arg)
-{
- VALUE str = rb_enc_str_new(NULL, size, cWIN32OLE_enc);
- *(VALUE *)arg = str;
- return RSTRING_PTR(str);
-}
-
-VALUE
-ole_wc2vstr(LPWSTR pw, BOOL isfree)
-{
- VALUE vstr;
- ole_wc2mb_alloc(pw, ole_alloc_vstr, &vstr);
- rb_str_set_len(vstr, (long)strlen(RSTRING_PTR(vstr)));
- if(isfree)
- SysFreeString(pw);
- return vstr;
-}
-
-static VALUE
-ole_ary_m_entry(VALUE val, LONG *pid)
-{
- VALUE obj = Qnil;
- int i = 0;
- obj = val;
- while(RB_TYPE_P(obj, T_ARRAY)) {
- obj = rb_ary_entry(obj, pid[i]);
- i++;
- }
- return obj;
-}
-
-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;
-}
-
-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 (defined(_MSC_VER) && (_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 /* (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__) */
- ole_val2variant2(val, var);
-#endif
-}
-
-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;
-}
-
-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 (defined(_MSC_VER) && (_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 void
-ole_set_safe_array(long n, SAFEARRAY *psa, LONG *pid, long *pub, VALUE val, long dim, VARTYPE vt)
-{
- VALUE val1;
- HRESULT hr = S_OK;
- VARIANT var;
- VOID *p = NULL;
- long i = n;
- while(i >= 0) {
- val1 = ole_ary_m_entry(val, pid);
- VariantInit(&var);
- 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, "element of array does not have IDispatch or IUnknown Interface");
- }
- hr = SafeArrayPutElement(psa, pid, p);
- }
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayPutElement");
- }
- pid[i] += 1;
- if (pid[i] > pub[i]) {
- pid[i] = 0;
- i -= 1;
- } else {
- i = dim - 1;
- }
- }
-}
-
-static long
-dimension(VALUE val) {
- long dim = 0;
- long dim1 = 0;
- long len = 0;
- long i = 0;
- if (RB_TYPE_P(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 (RB_TYPE_P(ary, T_ARRAY)) {
- ary_len = RARRAY_LEN(ary);
- }
- } else {
- if (RB_TYPE_P(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;
-}
-
-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;
- LONG *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((VARTYPE)(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, (VARTYPE)(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;
-}
-
-void
-ole_val2variant(VALUE val, VARIANT *var)
-{
- struct oledata *pole = NULL;
- if(rb_obj_is_kind_of(val, cWIN32OLE)) {
- pole = oledata_get_struct(val);
- OLE_ADDREF(pole->pDispatch);
- V_VT(var) = VT_DISPATCH;
- V_DISPATCH(var) = pole->pDispatch;
- return;
- }
- if (rb_obj_is_kind_of(val, cWIN32OLE_VARIANT)) {
- ole_variant2variant(val, var);
- return;
- }
- if (rb_obj_is_kind_of(val, cWIN32OLE_RECORD)) {
- ole_rec2variant(val, var);
- return;
- }
- if (rb_obj_is_kind_of(val, rb_cTime)) {
- V_VT(var) = VT_DATE;
- V_DATE(var) = rbtime2vtdate(val);
- return;
- }
- switch (TYPE(val)) {
- case T_ARRAY:
- ole_val_ary2variant_ary(val, var, VT_VARIANT|VT_ARRAY);
- break;
- case T_STRING:
- V_VT(var) = VT_BSTR;
- V_BSTR(var) = ole_vstr2wc(val);
- break;
- case T_FIXNUM:
- V_VT(var) = VT_I4;
- {
- long v = RB_NUM2LONG(val);
- V_I4(var) = (LONG)v;
-#if SIZEOF_LONG > 4
- if (V_I4(var) != v) {
- V_I8(var) = v;
- V_VT(var) = VT_I8;
- }
-#endif
- }
- break;
- case T_BIGNUM:
- V_VT(var) = VT_R8;
- V_R8(var) = rb_big2dbl(val);
- break;
- case T_FLOAT:
- V_VT(var) = VT_R8;
- V_R8(var) = NUM2DBL(val);
- break;
- case T_TRUE:
- V_VT(var) = VT_BOOL;
- V_BOOL(var) = VARIANT_TRUE;
- break;
- case T_FALSE:
- V_VT(var) = VT_BOOL;
- V_BOOL(var) = VARIANT_FALSE;
- break;
- case T_NIL:
- if (g_nil_to == VT_ERROR) {
- V_VT(var) = VT_ERROR;
- V_ERROR(var) = DISP_E_PARAMNOTFOUND;
- }else {
- V_VT(var) = VT_EMPTY;
- }
- break;
- default:
- V_VT(var) = VT_DISPATCH;
- V_DISPATCH(var) = val2dispatch(val);
- break;
- }
-}
-
-void
-ole_val2variant2(VALUE val, VARIANT *var)
-{
- g_nil_to = VT_EMPTY;
- ole_val2variant(val, var);
- g_nil_to = VT_ERROR;
-}
-
-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;
-}
-
-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)
-{
- struct oledata *pole = NULL;
- pole = oledata_get_struct(self);
- if (pole->pDispatch) {
- OLE_RELEASE(pole->pDispatch);
- pole->pDispatch = NULL;
- }
- pole->pDispatch = dispatch;
- return self;
-}
-
-
-static VALUE
-fole_s_allocate(VALUE klass)
-{
- struct oledata *pole;
- VALUE obj;
- ole_initialize();
- obj = TypedData_Make_Struct(klass, struct oledata, &ole_datatype, pole);
- pole->pDispatch = NULL;
- return obj;
-}
-
-static VALUE
-create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv)
-{
- VALUE obj = fole_s_allocate(klass);
- ole_set_member(obj, pDispatch);
- return obj;
-}
-
-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);
-}
-
-VALUE
-ole_variant2val(VARIANT *pvar)
-{
- VALUE obj = Qnil;
- VARTYPE vt = V_VT(pvar);
- HRESULT hr;
- while ( vt == (VT_BYREF | VT_VARIANT) ) {
- pvar = V_VARIANTREF(pvar);
- vt = V_VT(pvar);
- }
-
- if(V_ISARRAY(pvar)) {
- VARTYPE vt_base = vt & VT_TYPEMASK;
- SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar);
- UINT i = 0;
- LONG *pid, *plb, *pub;
- VARIANT variant;
- VALUE val;
- UINT dim = 0;
- if (!psa) {
- return obj;
- }
- dim = SafeArrayGetDim(psa);
- pid = ALLOC_N(LONG, dim);
- plb = ALLOC_N(LONG, dim);
- pub = ALLOC_N(LONG, dim);
-
- if(!pid || !plb || !pub) {
- if(pid) free(pid);
- if(plb) free(plb);
- if(pub) free(pub);
- rb_raise(rb_eRuntimeError, "memory allocation error");
- }
-
- for(i = 0; i < dim; ++i) {
- SafeArrayGetLBound(psa, i+1, &plb[i]);
- SafeArrayGetLBound(psa, i+1, &pid[i]);
- SafeArrayGetUBound(psa, i+1, &pub[i]);
- }
- hr = SafeArrayLock(psa);
- if (SUCCEEDED(hr)) {
- obj = rb_ary_new();
- i = 0;
- VariantInit(&variant);
- V_VT(&variant) = vt_base | VT_BYREF;
- if (vt_base == VT_RECORD) {
- hr = SafeArrayGetRecordInfo(psa, &V_RECORDINFO(&variant));
- if (SUCCEEDED(hr)) {
- V_VT(&variant) = VT_RECORD;
- }
- }
- while (i < dim) {
- ary_new_dim(obj, pid, plb, dim);
- if (vt_base == VT_RECORD)
- hr = SafeArrayPtrOfIndex(psa, pid, &V_RECORD(&variant));
- else
- 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])
- break;
- pid[i] = plb[i];
- }
- }
- SafeArrayUnlock(psa);
- }
- if(pid) free(pid);
- if(plb) free(plb);
- if(pub) free(pub);
- return obj;
- }
- switch(V_VT(pvar) & ~VT_BYREF){
- case VT_EMPTY:
- break;
- case VT_NULL:
- break;
- case VT_I1:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_I1REF(pvar));
- else
- obj = RB_INT2NUM((long)V_I1(pvar));
- break;
-
- case VT_UI1:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_UI1REF(pvar));
- else
- obj = RB_INT2NUM((long)V_UI1(pvar));
- break;
-
- case VT_I2:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_I2REF(pvar));
- else
- obj = RB_INT2NUM((long)V_I2(pvar));
- break;
-
- case VT_UI2:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_UI2REF(pvar));
- else
- obj = RB_INT2NUM((long)V_UI2(pvar));
- break;
-
- case VT_I4:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_I4REF(pvar));
- else
- obj = RB_INT2NUM((long)V_I4(pvar));
- break;
-
- case VT_UI4:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_UI4REF(pvar));
- else
- obj = RB_INT2NUM((long)V_UI4(pvar));
- break;
-
- case VT_INT:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_INTREF(pvar));
- else
- obj = RB_INT2NUM((long)V_INT(pvar));
- break;
-
- case VT_UINT:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM((long)*V_UINTREF(pvar));
- else
- obj = RB_INT2NUM((long)V_UINT(pvar));
- break;
-
-#if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
- case VT_I8:
- if(V_ISBYREF(pvar))
-#if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
-#ifdef V_I8REF
- obj = I8_2_NUM(*V_I8REF(pvar));
-#endif
-#else
- obj = Qnil;
-#endif
- else
- obj = I8_2_NUM(V_I8(pvar));
- break;
- case VT_UI8:
- if(V_ISBYREF(pvar))
-#if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
-#ifdef V_UI8REF
- obj = UI8_2_NUM(*V_UI8REF(pvar));
-#endif
-#else
- obj = Qnil;
-#endif
- else
- obj = UI8_2_NUM(V_UI8(pvar));
- break;
-#endif /* (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__) */
-
- case VT_R4:
- if(V_ISBYREF(pvar))
- obj = rb_float_new(*V_R4REF(pvar));
- else
- obj = rb_float_new(V_R4(pvar));
- break;
-
- case VT_R8:
- if(V_ISBYREF(pvar))
- obj = rb_float_new(*V_R8REF(pvar));
- else
- obj = rb_float_new(V_R8(pvar));
- break;
-
- case VT_BSTR:
- {
- BSTR bstr;
- if(V_ISBYREF(pvar))
- bstr = *V_BSTRREF(pvar);
- else
- bstr = V_BSTR(pvar);
- obj = (SysStringLen(bstr) == 0)
- ? rb_str_new2("")
- : ole_wc2vstr(bstr, FALSE);
- break;
- }
-
- case VT_ERROR:
- if(V_ISBYREF(pvar))
- obj = RB_INT2NUM(*V_ERRORREF(pvar));
- else
- obj = RB_INT2NUM(V_ERROR(pvar));
- break;
-
- case VT_BOOL:
- if (V_ISBYREF(pvar))
- obj = (*V_BOOLREF(pvar) ? Qtrue : Qfalse);
- else
- obj = (V_BOOL(pvar) ? Qtrue : Qfalse);
- break;
-
- case VT_DISPATCH:
- {
- IDispatch *pDispatch;
-
- if (V_ISBYREF(pvar))
- pDispatch = *V_DISPATCHREF(pvar);
- else
- pDispatch = V_DISPATCH(pvar);
-
- if (pDispatch != NULL ) {
- OLE_ADDREF(pDispatch);
- obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
- }
- break;
- }
-
- case VT_UNKNOWN:
- {
- /* get IDispatch interface from IUnknown interface */
- IUnknown *punk;
- IDispatch *pDispatch;
- void *p;
- HRESULT hr;
-
- if (V_ISBYREF(pvar))
- punk = *V_UNKNOWNREF(pvar);
- else
- punk = V_UNKNOWN(pvar);
-
- if(punk != NULL) {
- hr = punk->lpVtbl->QueryInterface(punk, &IID_IDispatch, &p);
- if(SUCCEEDED(hr)) {
- pDispatch = p;
- obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
- }
- }
- break;
- }
-
- case VT_DATE:
- {
- DATE date;
- if(V_ISBYREF(pvar))
- date = *V_DATEREF(pvar);
- else
- date = V_DATE(pvar);
-
- obj = vtdate2rbtime(date);
- break;
- }
-
- case VT_RECORD:
- {
- IRecordInfo *pri = V_RECORDINFO(pvar);
- void *prec = V_RECORD(pvar);
- obj = create_win32ole_record(pri, prec);
- break;
- }
-
- case VT_CY:
- default:
- {
- HRESULT hr;
- VARIANT variant;
- VariantInit(&variant);
- hr = VariantChangeTypeEx(&variant, pvar,
- cWIN32OLE_lcid, 0, VT_BSTR);
- if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR) {
- obj = ole_wc2vstr(V_BSTR(&variant), FALSE);
- }
- VariantClear(&variant);
- break;
- }
- }
- return obj;
-}
-
-LONG
-reg_open_key(HKEY hkey, const char *name, HKEY *phkey)
-{
- return RegOpenKeyEx(hkey, name, 0, KEY_READ, phkey);
-}
-
-LONG
-reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey)
-{
- return reg_open_key(hkey, StringValuePtr(key), phkey);
-}
-
-VALUE
-reg_enum_key(HKEY hkey, DWORD i)
-{
- char buf[BUFSIZ + 1];
- DWORD size_buf = sizeof(buf);
- FILETIME ft;
- LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf,
- NULL, NULL, NULL, &ft);
- if(err == ERROR_SUCCESS) {
- buf[BUFSIZ] = '\0';
- return rb_str_new2(buf);
- }
- return Qnil;
-}
-
-VALUE
-reg_get_val(HKEY hkey, const char *subkey)
-{
- char *pbuf;
- DWORD dwtype = 0;
- DWORD 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, (BYTE *)pbuf, &size);
- if (err == ERROR_SUCCESS) {
- pbuf[size] = '\0';
- if (dwtype == REG_EXPAND_SZ) {
- char* pbuf2 = (char *)pbuf;
- DWORD len = ExpandEnvironmentStrings(pbuf2, NULL, 0);
- pbuf = ALLOC_N(char, len + 1);
- ExpandEnvironmentStrings(pbuf2, pbuf, len + 1);
- free(pbuf2);
- }
- val = rb_str_new2((char *)pbuf);
- }
- free(pbuf);
- }
- return val;
-}
-
-VALUE
-reg_get_val2(HKEY hkey, const char *subkey)
-{
- HKEY hsubkey;
- LONG err;
- VALUE val = Qnil;
- err = RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &hsubkey);
- if (err == ERROR_SUCCESS) {
- val = reg_get_val(hsubkey, NULL);
- RegCloseKey(hsubkey);
- }
- if (val == Qnil) {
- val = reg_get_val(hkey, subkey);
- }
- return val;
-}
-
-static void
-ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self)
-{
- unsigned int count;
- unsigned int index;
- int iVar;
- ITypeInfo *pTypeInfo;
- TYPEATTR *pTypeAttr;
- VARDESC *pVarDesc;
- HRESULT hr;
- unsigned int len;
- BSTR bstr;
- char *pName = NULL;
- VALUE val;
- VALUE constant;
- ID id;
- constant = rb_hash_new();
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (index = 0; index < count; index++) {
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, index, &pTypeInfo);
- if (FAILED(hr))
- continue;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if(FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- continue;
- }
- for(iVar = 0; iVar < pTypeAttr->cVars; iVar++) {
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, iVar, &pVarDesc);
- if(FAILED(hr))
- continue;
- if(pVarDesc->varkind == VAR_CONST &&
- !(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
- VARFLAG_FRESTRICTED |
- VARFLAG_FNONBROWSABLE))) {
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
- 1, &len);
- if(FAILED(hr) || len == 0 || !bstr)
- continue;
- pName = ole_wc2mb(bstr);
- val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
- *pName = toupper((int)*pName);
- id = rb_intern(pName);
- if (rb_is_const_id(id)) {
- if(!rb_const_defined_at(klass, id)) {
- rb_define_const(klass, pName, val);
- }
- }
- else {
- rb_hash_aset(constant, rb_str_new2(pName), val);
- }
- SysFreeString(bstr);
- if(pName) {
- free(pName);
- pName = NULL;
- }
- }
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- }
- pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
- OLE_RELEASE(pTypeInfo);
- }
- rb_define_const(klass, "CONSTANTS", constant);
-}
-
-static HRESULT
-clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid)
-{
- HKEY hlm;
- HKEY hpid;
- VALUE subkey;
- LONG err;
- char clsid[100];
- OLECHAR *pbuf;
- DWORD len;
- DWORD dwtype;
- HRESULT hr = S_OK;
- err = RegConnectRegistry(StringValuePtr(host), HKEY_LOCAL_MACHINE, &hlm);
- if (err != ERROR_SUCCESS)
- return HRESULT_FROM_WIN32(err);
- subkey = rb_str_new2("SOFTWARE\\Classes\\");
- rb_str_concat(subkey, com);
- rb_str_cat2(subkey, "\\CLSID");
- err = RegOpenKeyEx(hlm, StringValuePtr(subkey), 0, KEY_READ, &hpid);
- if (err != ERROR_SUCCESS)
- hr = HRESULT_FROM_WIN32(err);
- else {
- len = sizeof(clsid);
- err = RegQueryValueEx(hpid, "", NULL, &dwtype, (BYTE *)clsid, &len);
- if (err == ERROR_SUCCESS && dwtype == REG_SZ) {
- pbuf = ole_mb2wc(clsid, -1, cWIN32OLE_cp);
- hr = CLSIDFromString(pbuf, pclsid);
- SysFreeString(pbuf);
- }
- else {
- hr = HRESULT_FROM_WIN32(err);
- }
- RegCloseKey(hpid);
- }
- RegCloseKey(hlm);
- return hr;
-}
-
-static VALUE
-ole_create_dcom(VALUE self, VALUE ole, VALUE host, VALUE others)
-{
- HRESULT hr;
- CLSID clsid;
- OLECHAR *pbuf;
-
- COSERVERINFO serverinfo;
- MULTI_QI multi_qi;
- DWORD clsctx = CLSCTX_REMOTE_SERVER;
-
- if (!gole32)
- gole32 = LoadLibrary("OLE32");
- if (!gole32)
- rb_raise(rb_eRuntimeError, "failed to load OLE32");
- if (!gCoCreateInstanceEx)
- gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*)
- GetProcAddress(gole32, "CoCreateInstanceEx");
- if (!gCoCreateInstanceEx)
- rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment");
-
- pbuf = ole_vstr2wc(ole);
- hr = CLSIDFromProgID(pbuf, &clsid);
- if (FAILED(hr))
- hr = clsid_from_remote(host, ole, &clsid);
- if (FAILED(hr))
- hr = CLSIDFromString(pbuf, &clsid);
- SysFreeString(pbuf);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError,
- "unknown OLE server: `%s'",
- StringValuePtr(ole));
- memset(&serverinfo, 0, sizeof(COSERVERINFO));
- serverinfo.pwszName = ole_vstr2wc(host);
- memset(&multi_qi, 0, sizeof(MULTI_QI));
- multi_qi.pIID = &IID_IDispatch;
- hr = gCoCreateInstanceEx(&clsid, NULL, clsctx, &serverinfo, 1, &multi_qi);
- SysFreeString(serverinfo.pwszName);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to create DCOM server `%s' in `%s'",
- StringValuePtr(ole),
- StringValuePtr(host));
-
- ole_set_member(self, (IDispatch*)multi_qi.pItf);
- return self;
-}
-
-static VALUE
-ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
-{
- IBindCtx *pBindCtx;
- IMoniker *pMoniker;
- IDispatch *pDispatch;
- void *p;
- HRESULT hr;
- OLECHAR *pbuf;
- ULONG eaten = 0;
-
- ole_initialize();
-
- hr = CreateBindCtx(0, &pBindCtx);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to create bind context");
- }
-
- pbuf = ole_vstr2wc(moniker);
- hr = MkParseDisplayName(pBindCtx, pbuf, &eaten, &pMoniker);
- SysFreeString(pbuf);
- if(FAILED(hr)) {
- OLE_RELEASE(pBindCtx);
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to parse display name of moniker `%s'",
- StringValuePtr(moniker));
- }
- hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL,
- &IID_IDispatch, &p);
- pDispatch = p;
- OLE_RELEASE(pMoniker);
- OLE_RELEASE(pBindCtx);
-
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to bind moniker `%s'",
- StringValuePtr(moniker));
- }
- return create_win32ole_object(self, pDispatch, argc, argv);
-}
-
-/*
- * call-seq:
- * WIN32OLE.connect( ole ) --> aWIN32OLE
- *
- * Returns running OLE Automation object or WIN32OLE object from moniker.
- * 1st argument should be OLE program id or class id or moniker.
- *
- * WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel.
- */
-static VALUE
-fole_s_connect(int argc, VALUE *argv, VALUE self)
-{
- VALUE svr_name;
- VALUE others;
- HRESULT hr;
- CLSID clsid;
- OLECHAR *pBuf;
- IDispatch *pDispatch;
- void *p;
- IUnknown *pUnknown;
-
- /* initialize to use OLE */
- ole_initialize();
-
- rb_scan_args(argc, argv, "1*", &svr_name, &others);
- StringValue(svr_name);
-
- /* get CLSID from OLE server name */
- pBuf = ole_vstr2wc(svr_name);
- hr = CLSIDFromProgID(pBuf, &clsid);
- if(FAILED(hr)) {
- hr = CLSIDFromString(pBuf, &clsid);
- }
- SysFreeString(pBuf);
- if(FAILED(hr)) {
- return ole_bind_obj(svr_name, argc, argv, self);
- }
-
- hr = GetActiveObject(&clsid, 0, &pUnknown);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "OLE server `%s' not running", StringValuePtr(svr_name));
- }
- hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch, &p);
- pDispatch = p;
- if(FAILED(hr)) {
- OLE_RELEASE(pUnknown);
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to create WIN32OLE server `%s'",
- StringValuePtr(svr_name));
- }
-
- OLE_RELEASE(pUnknown);
-
- return create_win32ole_object(self, pDispatch, argc, argv);
-}
-
-/*
- * call-seq:
- * WIN32OLE.const_load( ole, mod = WIN32OLE)
- *
- * Defines the constants of OLE Automation server as mod's constants.
- * The first argument is WIN32OLE object or type library name.
- * If 2nd argument is omitted, the default is WIN32OLE.
- * The first letter of Ruby's constant variable name is upper case,
- * so constant variable name of WIN32OLE object is capitalized.
- * For example, the 'xlTop' constant of Excel is changed to 'XlTop'
- * in WIN32OLE.
- * If the first letter of constant variable is not [A-Z], then
- * the constant is defined as CONSTANTS hash element.
- *
- * module EXCEL_CONST
- * end
- * excel = WIN32OLE.new('Excel.Application')
- * WIN32OLE.const_load(excel, EXCEL_CONST)
- * puts EXCEL_CONST::XlTop # => -4160
- * puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541
- *
- * WIN32OLE.const_load(excel)
- * puts WIN32OLE::XlTop # => -4160
- *
- * module MSO
- * end
- * WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO)
- * puts MSO::MsoLineSingle # => 1
- */
-static VALUE
-fole_s_const_load(int argc, VALUE *argv, VALUE self)
-{
- VALUE ole;
- VALUE klass;
- struct oledata *pole = NULL;
- ITypeInfo *pTypeInfo;
- ITypeLib *pTypeLib;
- unsigned int index;
- HRESULT hr;
- OLECHAR *pBuf;
- VALUE file;
- LCID lcid = cWIN32OLE_lcid;
-
- rb_scan_args(argc, argv, "11", &ole, &klass);
- if (!RB_TYPE_P(klass, T_CLASS) &&
- !RB_TYPE_P(klass, T_MODULE) &&
- !RB_TYPE_P(klass, T_NIL)) {
- rb_raise(rb_eTypeError, "2nd parameter must be Class or Module");
- }
- if (rb_obj_is_kind_of(ole, cWIN32OLE)) {
- pole = oledata_get_struct(ole);
- hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
- 0, lcid, &pTypeInfo);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo");
- }
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
- if(FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetContainingTypeLib");
- }
- OLE_RELEASE(pTypeInfo);
- if(!RB_TYPE_P(klass, T_NIL)) {
- ole_const_load(pTypeLib, klass, self);
- }
- else {
- ole_const_load(pTypeLib, cWIN32OLE, self);
- }
- OLE_RELEASE(pTypeLib);
- }
- else if(RB_TYPE_P(ole, T_STRING)) {
- file = typelib_file(ole);
- if (file == Qnil) {
- file = ole;
- }
- pBuf = ole_vstr2wc(file);
- hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
- SysFreeString(pBuf);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
- if(!RB_TYPE_P(klass, T_NIL)) {
- ole_const_load(pTypeLib, klass, self);
- }
- else {
- ole_const_load(pTypeLib, cWIN32OLE, self);
- }
- OLE_RELEASE(pTypeLib);
- }
- else {
- rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE instance");
- }
- return Qnil;
-}
-
-static ULONG
-reference_count(struct oledata * pole)
-{
- ULONG n = 0;
- if(pole->pDispatch) {
- OLE_ADDREF(pole->pDispatch);
- n = OLE_RELEASE(pole->pDispatch);
- }
- return n;
-}
-
-/*
- * call-seq:
- * WIN32OLE.ole_reference_count(aWIN32OLE) --> number
- *
- * Returns reference counter of Dispatch interface of WIN32OLE object.
- * You should not use this method because this method
- * exists only for debugging WIN32OLE.
- */
-static VALUE
-fole_s_reference_count(VALUE self, VALUE obj)
-{
- struct oledata * pole = NULL;
- pole = oledata_get_struct(obj);
- return RB_INT2NUM(reference_count(pole));
-}
-
-/*
- * call-seq:
- * WIN32OLE.ole_free(aWIN32OLE) --> number
- *
- * Invokes Release method of Dispatch interface of WIN32OLE object.
- * You should not use this method because this method
- * exists only for debugging WIN32OLE.
- * The return value is reference counter of OLE object.
- */
-static VALUE
-fole_s_free(VALUE self, VALUE obj)
-{
- ULONG n = 0;
- struct oledata * pole = NULL;
- pole = oledata_get_struct(obj);
- if(pole->pDispatch) {
- if (reference_count(pole) > 0) {
- n = OLE_RELEASE(pole->pDispatch);
- }
- }
- return RB_INT2NUM(n);
-}
-
-static HWND
-ole_show_help(VALUE helpfile, VALUE helpcontext)
-{
- FNHTMLHELP *pfnHtmlHelp;
- HWND hwnd = 0;
-
- if(!ghhctrl)
- ghhctrl = LoadLibrary("HHCTRL.OCX");
- if (!ghhctrl)
- return hwnd;
- pfnHtmlHelp = (FNHTMLHELP*)GetProcAddress(ghhctrl, "HtmlHelpA");
- if (!pfnHtmlHelp)
- return hwnd;
- hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
- 0x0f, RB_NUM2INT(helpcontext));
- if (hwnd == 0)
- hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
- 0, RB_NUM2INT(helpcontext));
- return hwnd;
-}
-
-/*
- * call-seq:
- * WIN32OLE.ole_show_help(obj [,helpcontext])
- *
- * Displays helpfile. The 1st argument specifies WIN32OLE_TYPE
- * object or WIN32OLE_METHOD object or helpfile.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * typeobj = excel.ole_type
- * WIN32OLE.ole_show_help(typeobj)
- */
-static VALUE
-fole_s_show_help(int argc, VALUE *argv, VALUE self)
-{
- VALUE target;
- VALUE helpcontext;
- VALUE helpfile;
- VALUE name;
- HWND hwnd;
- rb_scan_args(argc, argv, "11", &target, &helpcontext);
- if (rb_obj_is_kind_of(target, cWIN32OLE_TYPE) ||
- rb_obj_is_kind_of(target, cWIN32OLE_METHOD)) {
- helpfile = rb_funcall(target, rb_intern("helpfile"), 0);
- if(strlen(StringValuePtr(helpfile)) == 0) {
- name = rb_ivar_get(target, rb_intern("name"));
- rb_raise(rb_eRuntimeError, "no helpfile of `%s'",
- StringValuePtr(name));
- }
- helpcontext = rb_funcall(target, rb_intern("helpcontext"), 0);
- } else {
- helpfile = target;
- }
- if (!RB_TYPE_P(helpfile, T_STRING)) {
- rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)");
- }
- hwnd = ole_show_help(helpfile, helpcontext);
- if(hwnd == 0) {
- rb_raise(rb_eRuntimeError, "failed to open help file `%s'",
- StringValuePtr(helpfile));
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE.codepage
- *
- * Returns current codepage.
- * WIN32OLE.codepage # => WIN32OLE::CP_ACP
- */
-static VALUE
-fole_s_get_code_page(VALUE self)
-{
- return RB_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.
- * The WIN32OLE.codepage is initialized according to
- * Encoding.default_internal.
- * If Encoding.default_internal is nil then WIN32OLE.codepage
- * is initialized according to Encoding.default_external.
- *
- * WIN32OLE.codepage = WIN32OLE::CP_UTF8
- * WIN32OLE.codepage = 65001
- */
-static VALUE
-fole_s_set_code_page(VALUE self, VALUE vcp)
-{
- UINT cp = RB_FIX2INT(vcp);
- set_ole_codepage(cp);
- /*
- * Should this method return old codepage?
- */
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE.locale -> locale id.
- *
- * Returns current locale id (lcid). The default locale is
- * WIN32OLE::LOCALE_SYSTEM_DEFAULT.
- *
- * lcid = WIN32OLE.locale
- */
-static VALUE
-fole_s_get_locale(VALUE self)
-{
- return RB_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", (unsigned long)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 = RB_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);
-}
-
-/*
- * WIN32OLE.ole_initialize and WIN32OLE.ole_uninitialize
- * are used in win32ole.rb to fix the issue bug #2618 (ruby-core:27634).
- * You must not use these method.
- */
-
-/* :nodoc: */
-static VALUE
-fole_s_ole_initialize(VALUE self)
-{
- ole_initialize();
- return Qnil;
-}
-
-/* :nodoc: */
-static VALUE
-fole_s_ole_uninitialize(VALUE self)
-{
- ole_uninitialize();
- return Qnil;
-}
-
-/*
- * 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 or WIN32OLE_VARIANT object.
- * If you want to get the result value of argument passed by reference,
- * you can use WIN32OLE::ARGV or WIN32OLE_VARIANT.
- *
- * oleobj.method(arg1, arg2, refargv3)
- * puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method
- *
- * or
- *
- * refargv3 = WIN32OLE_VARIANT.new(XXX,
- * WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_XXX)
- * oleobj.method(arg1, arg2, refargv3)
- * p refargv3.value # the value of refargv3 after called oleobj.method.
- *
- */
-
-/*
- * call-seq:
- * WIN32OLE.new(server, [host]) -> WIN32OLE object
- * WIN32OLE.new(server, license: 'key') -> WIN32OLE object
- *
- * Returns a new WIN32OLE object(OLE Automation object).
- * The first argument server specifies OLE Automation server.
- * The first argument should be CLSID or PROGID.
- * If second argument host specified, then returns OLE Automation
- * object on host.
- * If :license keyword argument is provided,
- * IClassFactory2::CreateInstanceLic is used to create instance of
- * licensed server.
- *
- * WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object.
- * WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object.
- */
-static VALUE
-fole_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE svr_name;
- VALUE host;
- VALUE others;
- VALUE opts;
- HRESULT hr;
- CLSID clsid;
- OLECHAR *pBuf;
- OLECHAR *key_buf;
- IDispatch *pDispatch;
- IClassFactory2 * pIClassFactory2;
- void *p;
- static ID keyword_ids[1];
- VALUE kwargs[1];
-
- rb_call_super(0, 0);
- rb_scan_args(argc, argv, "11*:", &svr_name, &host, &others, &opts);
-
- StringValue(svr_name);
- if (!NIL_P(host)) {
- StringValue(host);
- return ole_create_dcom(self, svr_name, host, others);
- }
-
- /* get CLSID from OLE server name */
- pBuf = ole_vstr2wc(svr_name);
- hr = CLSIDFromProgID(pBuf, &clsid);
- if(FAILED(hr)) {
- hr = CLSIDFromString(pBuf, &clsid);
- }
- SysFreeString(pBuf);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "unknown OLE server: `%s'",
- StringValuePtr(svr_name));
- }
-
- if (!keyword_ids[0]) {
- keyword_ids[0] = rb_intern_const("license");
- }
- rb_get_kwargs(opts, keyword_ids, 0, 1, kwargs);
-
- if (kwargs[0] == Qundef) {
- /* get IDispatch interface */
- hr = CoCreateInstance(
- &clsid,
- NULL,
- CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
- &IID_IDispatch,
- &p
- );
- } else {
- hr = CoGetClassObject(
- &clsid,
- CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
- NULL,
- &IID_IClassFactory2,
- (LPVOID)&pIClassFactory2
- );
- if (hr == S_OK) {
- key_buf = ole_vstr2wc(kwargs[0]);
- hr = pIClassFactory2->lpVtbl->CreateInstanceLic(pIClassFactory2, NULL, NULL, &IID_IDispatch, key_buf, &p);
- SysFreeString(key_buf);
- OLE_RELEASE(pIClassFactory2);
- }
- }
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to create WIN32OLE object from `%s'",
- StringValuePtr(svr_name));
- }
- pDispatch = p;
-
- ole_set_member(self, pDispatch);
- return self;
-}
-
-static int
-hash2named_arg(VALUE key, VALUE val, VALUE pop)
-{
- struct oleparam* pOp = (struct oleparam *)pop;
- unsigned int index, i;
- index = pOp->dp.cNamedArgs;
- /*---------------------------------------------
- the data-type of key must be String or Symbol
- -----------------------------------------------*/
- if(!RB_TYPE_P(key, T_STRING) && !RB_TYPE_P(key, T_SYMBOL)) {
- /* clear name of dispatch parameters */
- for(i = 1; i < index + 1; i++) {
- SysFreeString(pOp->pNamedArgs[i]);
- }
- /* clear dispatch parameters */
- for(i = 0; i < index; i++ ) {
- VariantClear(&(pOp->dp.rgvarg[i]));
- }
- /* raise an exception */
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- if (RB_TYPE_P(key, T_SYMBOL)) {
- key = rb_sym2str(key);
- }
-
- /* pNamedArgs[0] is <method name>, so "index + 1" */
- pOp->pNamedArgs[index + 1] = ole_vstr2wc(key);
-
- VariantInit(&(pOp->dp.rgvarg[index]));
- ole_val2variant(val, &(pOp->dp.rgvarg[index]));
-
- pOp->dp.cNamedArgs += 1;
- return ST_CONTINUE;
-}
-
-static VALUE
-set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end)
-{
- VALUE argv = rb_const_get(cWIN32OLE, rb_intern("ARGV"));
-
- Check_Type(argv, T_ARRAY);
- rb_ary_clear(argv);
- while (end-- > beg) {
- rb_ary_push(argv, ole_variant2val(&realargs[end]));
- if (V_VT(&realargs[end]) != VT_RECORD) {
- VariantClear(&realargs[end]);
- }
- }
- return argv;
-}
-
-static VALUE
-ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
-{
- LCID lcid = cWIN32OLE_lcid;
- struct oledata *pole = NULL;
- HRESULT hr;
- VALUE cmd;
- VALUE paramS;
- VALUE param;
- VALUE obj;
- VALUE v;
-
- BSTR wcmdname;
-
- DISPID DispID;
- DISPID* pDispID;
- EXCEPINFO excepinfo;
- VARIANT result;
- VARIANTARG* realargs = NULL;
- unsigned int argErr = 0;
- unsigned int i;
- unsigned int cNamedArgs;
- int n;
- struct oleparam op;
- memset(&excepinfo, 0, sizeof(EXCEPINFO));
-
- VariantInit(&result);
-
- op.dp.rgvarg = NULL;
- op.dp.rgdispidNamedArgs = NULL;
- op.dp.cNamedArgs = 0;
- op.dp.cArgs = 0;
-
- rb_scan_args(argc, argv, "1*", &cmd, &paramS);
- if(!RB_TYPE_P(cmd, T_STRING) && !RB_TYPE_P(cmd, T_SYMBOL) && !is_bracket) {
- rb_raise(rb_eTypeError, "method is wrong type (expected String or Symbol)");
- }
- if (RB_TYPE_P(cmd, T_SYMBOL)) {
- cmd = rb_sym2str(cmd);
- }
- pole = oledata_get_struct(self);
- if(!pole->pDispatch) {
- rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
- }
- if (is_bracket) {
- DispID = DISPID_VALUE;
- argc += 1;
- rb_ary_unshift(paramS, cmd);
- } else {
- wcmdname = ole_vstr2wc(cmd);
- hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
- &wcmdname, 1, lcid, &DispID);
- SysFreeString(wcmdname);
- if(FAILED(hr)) {
- return rb_eNoMethodError;
- }
- }
-
- /* pick up last argument of method */
- param = rb_ary_entry(paramS, argc-2);
-
- op.dp.cNamedArgs = 0;
-
- /* if last arg is hash object */
- if(RB_TYPE_P(param, T_HASH)) {
- /*------------------------------------------
- hash object ==> named dispatch parameters
- --------------------------------------------*/
- cNamedArgs = rb_long2int((long)RHASH_SIZE(param));
- op.dp.cArgs = cNamedArgs + argc - 2;
- op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
- op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
-
- rb_hash_foreach(param, hash2named_arg, (VALUE)&op);
-
- pDispID = ALLOCA_N(DISPID, cNamedArgs + 1);
- op.pNamedArgs[0] = ole_vstr2wc(cmd);
- hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch,
- &IID_NULL,
- op.pNamedArgs,
- op.dp.cNamedArgs + 1,
- lcid, pDispID);
- for(i = 0; i < op.dp.cNamedArgs + 1; i++) {
- SysFreeString(op.pNamedArgs[i]);
- op.pNamedArgs[i] = NULL;
- }
- if(FAILED(hr)) {
- /* clear dispatch parameters */
- for(i = 0; i < op.dp.cArgs; i++ ) {
- VariantClear(&op.dp.rgvarg[i]);
- }
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to get named argument info: `%s'",
- StringValuePtr(cmd));
- }
- op.dp.rgdispidNamedArgs = &(pDispID[1]);
- }
- else {
- cNamedArgs = 0;
- op.dp.cArgs = argc - 1;
- op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
- if (op.dp.cArgs > 0) {
- op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
- }
- }
- /*--------------------------------------
- non hash args ==> dispatch parameters
- ----------------------------------------*/
- if(op.dp.cArgs > cNamedArgs) {
- realargs = ALLOCA_N(VARIANTARG, op.dp.cArgs-cNamedArgs+1);
- for(i = cNamedArgs; i < op.dp.cArgs; i++) {
- n = op.dp.cArgs - i + cNamedArgs - 1;
- VariantInit(&realargs[n]);
- VariantInit(&op.dp.rgvarg[n]);
- param = rb_ary_entry(paramS, i-cNamedArgs);
- if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
- ole_variant2variant(param, &op.dp.rgvarg[n]);
- } else if (rb_obj_is_kind_of(param, cWIN32OLE_RECORD)) {
- ole_val2variant(param, &realargs[n]);
- op.dp.rgvarg[n] = realargs[n];
- V_VT(&op.dp.rgvarg[n]) = VT_RECORD | VT_BYREF;
- } else {
- 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");
-
- op.dp.cNamedArgs = 1;
- op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
- op.dp.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
- }
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
- &IID_NULL, lcid, wFlags, &op.dp,
- &result, &excepinfo, &argErr);
-
- if (FAILED(hr)) {
- /* retry to call args by value */
- if(op.dp.cArgs >= cNamedArgs) {
- for(i = cNamedArgs; i < op.dp.cArgs; i++) {
- n = op.dp.cArgs - i + cNamedArgs - 1;
- param = rb_ary_entry(paramS, i-cNamedArgs);
- ole_val2variant(param, &op.dp.rgvarg[n]);
- }
- if (hr == DISP_E_EXCEPTION) {
- ole_freeexceptinfo(&excepinfo);
- }
- memset(&excepinfo, 0, sizeof(EXCEPINFO));
- VariantInit(&result);
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
- &IID_NULL, lcid, wFlags,
- &op.dp, &result,
- &excepinfo, &argErr);
-
- /* mega kludge. if a method in WORD is called and we ask
- * for a result when one is not returned then
- * hResult == DISP_E_EXCEPTION. this only happens on
- * functions whose DISPID > 0x8000 */
- if ((hr == DISP_E_EXCEPTION || 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;
- if (V_VT(&op.dp.rgvarg[n]) != VT_RECORD) {
- VariantClear(&op.dp.rgvarg[n]);
- }
- }
- }
-
- if (FAILED(hr)) {
- /* retry after converting nil to VT_EMPTY */
- if (op.dp.cArgs > cNamedArgs) {
- for(i = cNamedArgs; i < op.dp.cArgs; i++) {
- n = op.dp.cArgs - i + cNamedArgs - 1;
- param = rb_ary_entry(paramS, i-cNamedArgs);
- ole_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,
- &IID_NULL, lcid, wFlags,
- &op.dp, &result,
- &excepinfo, &argErr);
- for(i = cNamedArgs; i < op.dp.cArgs; i++) {
- n = op.dp.cArgs - i + cNamedArgs - 1;
- if (V_VT(&op.dp.rgvarg[n]) != VT_RECORD) {
- VariantClear(&op.dp.rgvarg[n]);
- }
- }
- }
- }
-
- }
- /* 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]);
- } else if ( rb_obj_is_kind_of(param, cWIN32OLE_RECORD) &&
- V_VT(&realargs[n]) == VT_RECORD ) {
- olerecord_set_ivar(param, V_RECORDINFO(&realargs[n]), V_RECORD(&realargs[n]));
- }
- }
- set_argv(realargs, cNamedArgs, op.dp.cArgs);
- }
- else {
- for(i = 0; i < op.dp.cArgs; i++) {
- VariantClear(&op.dp.rgvarg[i]);
- }
- }
-
- if (FAILED(hr)) {
- v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `%s': )%s",
- StringValuePtr(cmd),
- StringValuePtr(v));
- }
- obj = ole_variant2val(&result);
- VariantClear(&result);
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE#invoke(method, [arg1,...]) => return value of method.
- *
- * Runs OLE method.
- * The first argument specifies the method name of OLE Automation object.
- * The others specify argument of the <i>method</i>.
- * If you can not execute <i>method</i> directly, then use this method instead.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * excel.invoke('Quit') # => same as excel.Quit
- *
- */
-static VALUE
-fole_invoke(int argc, VALUE *argv, VALUE self)
-{
- VALUE v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
- if (v == rb_eNoMethodError) {
- return rb_call_super(argc, argv);
- }
- return v;
-}
-
-static VALUE
-ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
-{
- HRESULT hr;
- struct oledata *pole = NULL;
- unsigned int argErr = 0;
- EXCEPINFO excepinfo;
- VARIANT result;
- DISPPARAMS dispParams;
- VARIANTARG* realargs = NULL;
- int i, j; VALUE obj = Qnil;
- VALUE tp, param;
- VALUE v;
- VARTYPE vt;
-
- Check_Type(args, T_ARRAY);
- Check_Type(types, T_ARRAY);
-
- memset(&excepinfo, 0, sizeof(EXCEPINFO));
- memset(&dispParams, 0, sizeof(DISPPARAMS));
- VariantInit(&result);
- pole = oledata_get_struct(self);
-
- dispParams.cArgs = RARRAY_LEN(args);
- dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
- realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
- for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
- {
- VariantInit(&realargs[i]);
- VariantInit(&dispParams.rgvarg[i]);
- tp = rb_ary_entry(types, j);
- vt = (VARTYPE)RB_FIX2INT(tp);
- V_VT(&dispParams.rgvarg[i]) = vt;
- param = rb_ary_entry(args, j);
- if (param == Qnil)
- {
-
- V_VT(&dispParams.rgvarg[i]) = V_VT(&realargs[i]) = VT_ERROR;
- V_ERROR(&dispParams.rgvarg[i]) = V_ERROR(&realargs[i]) = DISP_E_PARAMNOTFOUND;
- }
- else
- {
- if (vt & VT_ARRAY)
- {
- int ent;
- LPBYTE pb;
- short* ps;
- LPLONG pl;
- VARIANT* pv;
- CY *py;
- VARTYPE v;
- SAFEARRAYBOUND rgsabound[1];
- Check_Type(param, T_ARRAY);
- rgsabound[0].lLbound = 0;
- rgsabound[0].cElements = RARRAY_LEN(param);
- v = vt & ~(VT_ARRAY | VT_BYREF);
- V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
- V_VT(&realargs[i]) = VT_ARRAY | v;
- SafeArrayLock(V_ARRAY(&realargs[i]));
- pb = V_ARRAY(&realargs[i])->pvData;
- ps = V_ARRAY(&realargs[i])->pvData;
- pl = V_ARRAY(&realargs[i])->pvData;
- py = V_ARRAY(&realargs[i])->pvData;
- pv = V_ARRAY(&realargs[i])->pvData;
- for (ent = 0; ent < (int)rgsabound[0].cElements; ent++)
- {
- VARIANT velem;
- VALUE elem = rb_ary_entry(param, ent);
- ole_val2variant(elem, &velem);
- if (v != VT_VARIANT)
- {
- VariantChangeTypeEx(&velem, &velem,
- cWIN32OLE_lcid, 0, v);
- }
- switch (v)
- {
- /* 128 bits */
- case VT_VARIANT:
- *pv++ = velem;
- break;
- /* 64 bits */
- case VT_R8:
- case VT_CY:
- case VT_DATE:
- *py++ = V_CY(&velem);
- break;
- /* 16 bits */
- case VT_BOOL:
- case VT_I2:
- case VT_UI2:
- *ps++ = V_I2(&velem);
- break;
- /* 8 bites */
- case VT_UI1:
- case VT_I1:
- *pb++ = V_UI1(&velem);
- break;
- /* 32 bits */
- default:
- *pl++ = V_I4(&velem);
- break;
- }
- }
- SafeArrayUnlock(V_ARRAY(&realargs[i]));
- }
- else
- {
- ole_val2variant(param, &realargs[i]);
- if ((vt & (~VT_BYREF)) != VT_VARIANT)
- {
- hr = VariantChangeTypeEx(&realargs[i], &realargs[i],
- cWIN32OLE_lcid, 0,
- (VARTYPE)(vt & (~VT_BYREF)));
- if (hr != S_OK)
- {
- rb_raise(rb_eTypeError, "not valid value");
- }
- }
- }
- if ((vt & VT_BYREF) || vt == VT_VARIANT)
- {
- if (vt == VT_VARIANT)
- V_VT(&dispParams.rgvarg[i]) = VT_VARIANT | VT_BYREF;
- switch (vt & (~VT_BYREF))
- {
- /* 128 bits */
- case VT_VARIANT:
- V_VARIANTREF(&dispParams.rgvarg[i]) = &realargs[i];
- break;
- /* 64 bits */
- case VT_R8:
- case VT_CY:
- case VT_DATE:
- V_CYREF(&dispParams.rgvarg[i]) = &V_CY(&realargs[i]);
- break;
- /* 16 bits */
- case VT_BOOL:
- case VT_I2:
- case VT_UI2:
- V_I2REF(&dispParams.rgvarg[i]) = &V_I2(&realargs[i]);
- break;
- /* 8 bites */
- case VT_UI1:
- case VT_I1:
- V_UI1REF(&dispParams.rgvarg[i]) = &V_UI1(&realargs[i]);
- break;
- /* 32 bits */
- default:
- V_I4REF(&dispParams.rgvarg[i]) = &V_I4(&realargs[i]);
- break;
- }
- }
- else
- {
- /* copy 64 bits of data */
- V_CY(&dispParams.rgvarg[i]) = V_CY(&realargs[i]);
- }
- }
- }
-
- if (dispkind & DISPATCH_PROPERTYPUT) {
- dispParams.cNamedArgs = 1;
- dispParams.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
- dispParams.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
- }
-
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, RB_NUM2INT(dispid),
- &IID_NULL, cWIN32OLE_lcid,
- dispkind,
- &dispParams, &result,
- &excepinfo, &argErr);
-
- if (FAILED(hr)) {
- v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `<dispatch id:%d>': )%s",
- RB_NUM2INT(dispid),
- StringValuePtr(v));
- }
-
- /* clear dispatch parameter */
- if(dispParams.cArgs > 0) {
- set_argv(realargs, 0, dispParams.cArgs);
- }
-
- obj = ole_variant2val(&result);
- VariantClear(&result);
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE#_invoke(dispid, args, types)
- *
- * Runs the early binding method.
- * The 1st argument specifies dispatch ID,
- * the 2nd argument specifies the array of arguments,
- * the 3rd argument specifies the array of the type of arguments.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * excel._invoke(302, [], []) # same effect as excel.Quit
- */
-static VALUE
-fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types)
-{
- return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD);
-}
-
-/*
- * call-seq:
- * WIN32OLE#_getproperty(dispid, args, types)
- *
- * Runs the early binding method to get property.
- * The 1st argument specifies dispatch ID,
- * the 2nd argument specifies the array of arguments,
- * the 3rd argument specifies the array of the type of arguments.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * puts excel._getproperty(558, [], []) # same effect as puts excel.visible
- */
-static VALUE
-fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
-{
- return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET);
-}
-
-/*
- * call-seq:
- * WIN32OLE#_setproperty(dispid, args, types)
- *
- * Runs the early binding method to set property.
- * The 1st argument specifies dispatch ID,
- * the 2nd argument specifies the array of arguments,
- * the 3rd argument specifies the array of the type of arguments.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * 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)
-{
- 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)
-{
- VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE);
- if (v == rb_eNoMethodError) {
- return rb_call_super(argc, argv);
- }
- return v;
-}
-
-/*
- * call-seq:
- * 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
- * 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)
-{
- VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE);
- if (v == rb_eNoMethodError) {
- return rb_call_super(argc, argv);
- }
- return v;
-}
-
-/*
- * call-seq:
- * WIN32OLE[a1,a2,...]
- *
- * Returns the value of Collection specified by a1, a2,....
- *
- * 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.
- *
- */
-static VALUE
-fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self)
-{
- VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE);
- if (v == rb_eNoMethodError) {
- return rb_call_super(argc, argv);
- }
- return v;
-}
-
-static VALUE
-ole_propertyput(VALUE self, VALUE property, VALUE value)
-{
- struct oledata *pole = NULL;
- unsigned argErr;
- unsigned int index;
- HRESULT hr;
- EXCEPINFO excepinfo;
- DISPID dispID = DISPID_VALUE;
- DISPID dispIDParam = DISPID_PROPERTYPUT;
- USHORT wFlags = DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF;
- DISPPARAMS dispParams;
- VARIANTARG propertyValue[2];
- OLECHAR* pBuf[1];
- VALUE v;
- LCID lcid = cWIN32OLE_lcid;
- dispParams.rgdispidNamedArgs = &dispIDParam;
- dispParams.rgvarg = propertyValue;
- dispParams.cNamedArgs = 1;
- dispParams.cArgs = 1;
-
- VariantInit(&propertyValue[0]);
- VariantInit(&propertyValue[1]);
- memset(&excepinfo, 0, sizeof(excepinfo));
-
- pole = oledata_get_struct(self);
-
- /* get ID from property name */
- pBuf[0] = ole_vstr2wc(property);
- hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch, &IID_NULL,
- pBuf, 1, lcid, &dispID);
- SysFreeString(pBuf[0]);
- pBuf[0] = NULL;
-
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "unknown property or method: `%s'",
- StringValuePtr(property));
- }
- /* set property value */
- ole_val2variant(value, &propertyValue[0]);
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, dispID, &IID_NULL,
- lcid, wFlags, &dispParams,
- NULL, &excepinfo, &argErr);
-
- for(index = 0; index < dispParams.cArgs; ++index) {
- VariantClear(&propertyValue[index]);
- }
- if (FAILED(hr)) {
- v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in setting property `%s': )%s",
- StringValuePtr(property),
- StringValuePtr(v));
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_free
- *
- * invokes Release method of Dispatch interface of WIN32OLE object.
- * Usually, you do not need to call this method because Release method
- * called automatically when WIN32OLE object garbaged.
- *
- */
-static VALUE
-fole_free(VALUE self)
-{
- struct oledata *pole = NULL;
- pole = oledata_get_struct(self);
- OLE_FREE(pole->pDispatch);
- pole->pDispatch = NULL;
- return Qnil;
-}
-
-static VALUE
-ole_each_sub(VALUE pEnumV)
-{
- VARIANT variant;
- VALUE obj = Qnil;
- IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
- VariantInit(&variant);
- while(pEnum->lpVtbl->Next(pEnum, 1, &variant, NULL) == S_OK) {
- obj = ole_variant2val(&variant);
- VariantClear(&variant);
- VariantInit(&variant);
- rb_yield(obj);
- }
- return Qnil;
-}
-
-static VALUE
-ole_ienum_free(VALUE pEnumV)
-{
- IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
- OLE_RELEASE(pEnum);
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE#each {|i|...}
- *
- * Iterates over each item of OLE collection which has IEnumVARIANT interface.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * book = excel.workbooks.add
- * sheets = book.worksheets(1)
- * cells = sheets.cells("A1:A5")
- * cells.each do |cell|
- * cell.value = 10
- * end
- */
-static VALUE
-fole_each(VALUE self)
-{
- LCID lcid = cWIN32OLE_lcid;
-
- struct oledata *pole = NULL;
-
- unsigned int argErr;
- EXCEPINFO excepinfo;
- DISPPARAMS dispParams;
- VARIANT result;
- HRESULT hr;
- IEnumVARIANT *pEnum = NULL;
- void *p;
-
- RETURN_ENUMERATOR(self, 0, 0);
-
- VariantInit(&result);
- dispParams.rgvarg = NULL;
- dispParams.rgdispidNamedArgs = NULL;
- dispParams.cNamedArgs = 0;
- dispParams.cArgs = 0;
- memset(&excepinfo, 0, sizeof(excepinfo));
-
- pole = oledata_get_struct(self);
- hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM,
- &IID_NULL, lcid,
- DISPATCH_METHOD | DISPATCH_PROPERTYGET,
- &dispParams, &result,
- &excepinfo, &argErr);
-
- if (FAILED(hr)) {
- VariantClear(&result);
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface");
- }
-
- if (V_VT(&result) == VT_UNKNOWN) {
- hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result),
- &IID_IEnumVARIANT,
- &p);
- pEnum = p;
- } else if (V_VT(&result) == VT_DISPATCH) {
- hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result),
- &IID_IEnumVARIANT,
- &p);
- pEnum = p;
- }
- if (FAILED(hr) || !pEnum) {
- VariantClear(&result);
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface");
- }
-
- VariantClear(&result);
- rb_ensure(ole_each_sub, (VALUE)pEnum, ole_ienum_free, (VALUE)pEnum);
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE#method_missing(id [,arg1, arg2, ...])
- *
- * Calls WIN32OLE#invoke method.
- */
-static VALUE
-fole_missing(int argc, VALUE *argv, VALUE self)
-{
- VALUE mid, org_mid, sym, v;
- const char* mname;
- long n;
- rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
- mid = org_mid = argv[0];
- sym = rb_check_symbol(&mid);
- if (!NIL_P(sym)) mid = rb_sym2str(sym);
- mname = StringValueCStr(mid);
- if(!mname) {
- rb_raise(rb_eRuntimeError, "fail: unknown method or property");
- }
- n = RSTRING_LEN(mid);
- if(mname[n-1] == '=') {
- rb_check_arity(argc, 2, 2);
- argv[0] = rb_enc_associate(rb_str_subseq(mid, 0, n-1), cWIN32OLE_enc);
-
- return ole_propertyput(self, argv[0], argv[1]);
- }
- else {
- argv[0] = rb_enc_associate(rb_str_dup(mid), cWIN32OLE_enc);
- v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
- if (v == rb_eNoMethodError) {
- argv[0] = org_mid;
- return rb_call_super(argc, argv);
- }
- return v;
- }
-}
-
-static HRESULT
-typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti)
-{
- ITypeInfo *pTypeInfo;
- ITypeLib *pTypeLib;
- BSTR bstr;
- VALUE type;
- UINT i;
- UINT count;
- LCID lcid = cWIN32OLE_lcid;
- HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
- 0, lcid, &pTypeInfo);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo");
- }
- hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo,
- -1,
- &bstr,
- NULL, NULL, NULL);
- type = WC2VSTR(bstr);
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
- OLE_RELEASE(pTypeInfo);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetContainingTypeLib");
- }
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (i = 0; i < count; i++) {
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
- &bstr, NULL, NULL, NULL);
- if (SUCCEEDED(hr) && rb_str_cmp(WC2VSTR(bstr), type) == 0) {
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
- if (SUCCEEDED(hr)) {
- *ppti = pTypeInfo;
- break;
- }
- }
- }
- OLE_RELEASE(pTypeLib);
- return hr;
-}
-
-static VALUE
-ole_methods(VALUE self, int mask)
-{
- ITypeInfo *pTypeInfo;
- HRESULT hr;
- VALUE methods;
- struct oledata *pole = NULL;
-
- pole = oledata_get_struct(self);
- methods = rb_ary_new();
-
- hr = typeinfo_from_ole(pole, &pTypeInfo);
- if(FAILED(hr))
- return methods;
- rb_ary_concat(methods, ole_methods_from_typeinfo(pTypeInfo, mask));
- OLE_RELEASE(pTypeInfo);
- return methods;
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_methods
- *
- * Returns the array of WIN32OLE_METHOD object.
- * The element is OLE method of WIN32OLE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * methods = excel.ole_methods
- *
- */
-static VALUE
-fole_methods(VALUE self)
-{
- return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_get_methods
- *
- * Returns the array of WIN32OLE_METHOD object .
- * The element of the array is property (gettable) of WIN32OLE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * properties = excel.ole_get_methods
- */
-static VALUE
-fole_get_methods(VALUE self)
-{
- return ole_methods( self, INVOKE_PROPERTYGET);
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_put_methods
- *
- * Returns the array of WIN32OLE_METHOD object .
- * The element of the array is property (settable) of WIN32OLE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * properties = excel.ole_put_methods
- */
-static VALUE
-fole_put_methods(VALUE self)
-{
- return ole_methods( self, INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF);
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_func_methods
- *
- * Returns the array of WIN32OLE_METHOD object .
- * The element of the array is property (settable) of WIN32OLE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * properties = excel.ole_func_methods
- *
- */
-static VALUE
-fole_func_methods(VALUE self)
-{
- return ole_methods( self, INVOKE_FUNC);
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_type
- *
- * Returns WIN32OLE_TYPE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * tobj = excel.ole_type
- */
-static VALUE
-fole_type(VALUE self)
-{
- ITypeInfo *pTypeInfo;
- HRESULT hr;
- struct oledata *pole = NULL;
- LCID lcid = cWIN32OLE_lcid;
- VALUE type = Qnil;
-
- pole = oledata_get_struct(self);
-
- hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo );
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "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;
-}
-
-/*
- * 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 = NULL;
- HRESULT hr;
- ITypeInfo *pTypeInfo;
- LCID lcid = cWIN32OLE_lcid;
- VALUE vtlib = Qnil;
-
- pole = oledata_get_struct(self);
- hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
- 0, lcid, &pTypeInfo);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo");
- }
- vtlib = ole_typelib_from_itypeinfo(pTypeInfo);
- 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 = NULL;
- IDispatch *pDispatch;
- void *p;
-
- pBuf = ole_vstr2wc(str_iid);
- hr = CLSIDFromString(pBuf, &iid);
- SysFreeString(pBuf);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "invalid iid: `%s'",
- StringValuePtr(str_iid));
- }
-
- pole = oledata_get_struct(self);
- if(!pole->pDispatch) {
- rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
- }
-
- hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &iid,
- &p);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError,
- "failed to get interface `%s'",
- StringValuePtr(str_iid));
- }
-
- pDispatch = p;
- return create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_respond_to?(method) -> true or false
- *
- * Returns true when OLE object has OLE method, otherwise returns false.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ie.ole_respond_to?("gohome") => true
- */
-static VALUE
-fole_respond_to(VALUE self, VALUE method)
-{
- struct oledata *pole = NULL;
- BSTR wcmdname;
- DISPID DispID;
- HRESULT hr;
- if(!RB_TYPE_P(method, T_STRING) && !RB_TYPE_P(method, T_SYMBOL)) {
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- if (RB_TYPE_P(method, T_SYMBOL)) {
- method = rb_sym2str(method);
- }
- pole = oledata_get_struct(self);
- wcmdname = ole_vstr2wc(method);
- hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
- &wcmdname, 1, cWIN32OLE_lcid, &DispID);
- SysFreeString(wcmdname);
- return SUCCEEDED(hr) ? Qtrue : Qfalse;
-}
-
-HRESULT
-ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile)
-{
- HRESULT hr;
- ITypeLib *pTypeLib;
- UINT i;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
- if (FAILED(hr)) {
- return hr;
- }
-
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
- name, helpstr,
- helpcontext, helpfile);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeLib);
- return hr;
- }
- OLE_RELEASE(pTypeLib);
- return hr;
-}
-
-static VALUE
-ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
-{
- HRESULT hr;
- BSTR bstr;
- ITypeInfo *pRefTypeInfo;
- VALUE type = Qnil;
-
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
- V_UNION1(pTypeDesc, hreftype),
- &pRefTypeInfo);
- if(FAILED(hr))
- return Qnil;
- hr = ole_docinfo_from_type(pRefTypeInfo, &bstr, NULL, NULL, NULL);
- if(FAILED(hr)) {
- OLE_RELEASE(pRefTypeInfo);
- return Qnil;
- }
- OLE_RELEASE(pRefTypeInfo);
- type = WC2VSTR(bstr);
- if(typedetails != Qnil)
- rb_ary_push(typedetails, type);
- return type;
-}
-
-static VALUE
-ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
-{
- TYPEDESC *p = pTypeDesc;
- VALUE type = rb_str_new2("");
-
- if (p->vt == VT_PTR || p->vt == VT_SAFEARRAY) {
- p = V_UNION1(p, lptdesc);
- type = ole_typedesc2val(pTypeInfo, p, typedetails);
- }
- return type;
-}
-
-VALUE
-ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
-{
- VALUE str;
- VALUE typestr = Qnil;
- switch(pTypeDesc->vt) {
- case VT_I2:
- typestr = rb_str_new2("I2");
- break;
- case VT_I4:
- typestr = rb_str_new2("I4");
- break;
- case VT_R4:
- typestr = rb_str_new2("R4");
- break;
- case VT_R8:
- typestr = rb_str_new2("R8");
- break;
- case VT_CY:
- typestr = rb_str_new2("CY");
- break;
- case VT_DATE:
- typestr = rb_str_new2("DATE");
- break;
- case VT_BSTR:
- typestr = rb_str_new2("BSTR");
- break;
- case VT_BOOL:
- typestr = rb_str_new2("BOOL");
- break;
- case VT_VARIANT:
- typestr = rb_str_new2("VARIANT");
- break;
- case VT_DECIMAL:
- typestr = rb_str_new2("DECIMAL");
- break;
- case VT_I1:
- typestr = rb_str_new2("I1");
- break;
- case VT_UI1:
- typestr = rb_str_new2("UI1");
- break;
- case VT_UI2:
- typestr = rb_str_new2("UI2");
- break;
- case VT_UI4:
- typestr = rb_str_new2("UI4");
- break;
-#if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
- case VT_I8:
- typestr = rb_str_new2("I8");
- break;
- case VT_UI8:
- typestr = rb_str_new2("UI8");
- break;
-#endif
- case VT_INT:
- typestr = rb_str_new2("INT");
- break;
- case VT_UINT:
- typestr = rb_str_new2("UINT");
- break;
- case VT_VOID:
- typestr = rb_str_new2("VOID");
- break;
- case VT_HRESULT:
- typestr = rb_str_new2("HRESULT");
- break;
- case VT_PTR:
- typestr = rb_str_new2("PTR");
- if(typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
- return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
- case VT_SAFEARRAY:
- typestr = rb_str_new2("SAFEARRAY");
- if(typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
- return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
- case VT_CARRAY:
- typestr = rb_str_new2("CARRAY");
- break;
- case VT_USERDEFINED:
- typestr = rb_str_new2("USERDEFINED");
- if (typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
- str = ole_usertype2val(pTypeInfo, pTypeDesc, typedetails);
- if (str != Qnil) {
- return str;
- }
- return typestr;
- case VT_UNKNOWN:
- typestr = rb_str_new2("UNKNOWN");
- break;
- 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;
- case VT_RECORD:
- typestr = rb_str_new2("RECORD");
- break;
- default:
- typestr = rb_str_new2("Unknown Type ");
- rb_str_concat(typestr, rb_fix2str(RB_INT2FIX(pTypeDesc->vt), 10));
- break;
- }
- if (typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
- return typestr;
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_method_help(method)
- *
- * Returns WIN32OLE_METHOD object corresponding with method
- * specified by 1st argument.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * method = excel.ole_method_help('Quit')
- *
- */
-static VALUE
-fole_method_help(VALUE self, VALUE cmdname)
-{
- ITypeInfo *pTypeInfo;
- HRESULT hr;
- struct oledata *pole = NULL;
- VALUE obj;
-
- SafeStringValue(cmdname);
- pole = oledata_get_struct(self);
- hr = typeinfo_from_ole(pole, &pTypeInfo);
- if(FAILED(hr))
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get ITypeInfo");
-
- obj = create_win32ole_method(pTypeInfo, cmdname);
-
- OLE_RELEASE(pTypeInfo);
- if (obj == Qnil)
- rb_raise(eWIN32OLERuntimeError, "not found %s",
- StringValuePtr(cmdname));
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_activex_initialize() -> Qnil
- *
- * Initialize WIN32OLE object(ActiveX Control) by calling
- * IPersistMemory::InitNew.
- *
- * Before calling OLE method, some kind of the ActiveX controls
- * created with MFC should be initialized by calling
- * IPersistXXX::InitNew.
- *
- * If and only if you received the exception "HRESULT error code:
- * 0x8000ffff catastrophic failure", try this method before
- * invoking any ole_method.
- *
- * obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
- * obj.ole_activex_initialize
- * obj.method(...)
- *
- */
-static VALUE
-fole_activex_initialize(VALUE self)
-{
- struct oledata *pole = NULL;
- IPersistMemory *pPersistMemory;
- void *p;
-
- HRESULT hr = S_OK;
-
- pole = oledata_get_struct(self);
-
- hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &IID_IPersistMemory, &p);
- pPersistMemory = p;
- if (SUCCEEDED(hr)) {
- hr = pPersistMemory->lpVtbl->InitNew(pPersistMemory);
- OLE_RELEASE(pPersistMemory);
- if (SUCCEEDED(hr)) {
- return Qnil;
- }
- }
-
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to initialize ActiveX control");
- }
-
- return Qnil;
-}
-
-HRESULT
-typelib_from_val(VALUE obj, ITypeLib **pTypeLib)
-{
- LCID lcid = cWIN32OLE_lcid;
- HRESULT hr;
- struct oledata *pole = NULL;
- unsigned int index;
- ITypeInfo *pTypeInfo;
- pole = oledata_get_struct(obj);
- hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
- 0, lcid, &pTypeInfo);
- if (FAILED(hr)) {
- return hr;
- }
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, pTypeLib, &index);
- OLE_RELEASE(pTypeInfo);
- return hr;
-}
-
-static void
-com_hash_free(void *ptr)
-{
- st_table *tbl = ptr;
- st_free_table(tbl);
-}
-
-static void
-com_hash_mark(void *ptr)
-{
- st_table *tbl = ptr;
- rb_mark_hash(tbl);
-}
-
-static size_t
-com_hash_size(const void *ptr)
-{
- const st_table *tbl = ptr;
- return st_memsize(tbl);
-}
-
-static void
-check_nano_server(void)
-{
- HKEY hsubkey;
- LONG err;
- const char * subkey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels";
- const char * regval = "NanoServer";
-
- err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, KEY_READ, &hsubkey);
- if (err == ERROR_SUCCESS) {
- err = RegQueryValueEx(hsubkey, regval, NULL, NULL, NULL, NULL);
- if (err == ERROR_SUCCESS) {
- g_running_nano = TRUE;
- }
- RegCloseKey(hsubkey);
- }
-}
-
-LCID cWIN32OLE_lcid;
-
-void
-Init_win32ole(void)
-{
- cWIN32OLE_lcid = LOCALE_SYSTEM_DEFAULT;
- g_ole_initialized_init();
- check_nano_server();
-
- com_vtbl.QueryInterface = QueryInterface;
- com_vtbl.AddRef = AddRef;
- com_vtbl.Release = Release;
- com_vtbl.GetTypeInfoCount = GetTypeInfoCount;
- com_vtbl.GetTypeInfo = GetTypeInfo;
- com_vtbl.GetIDsOfNames = GetIDsOfNames;
- com_vtbl.Invoke = Invoke;
-
- 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;
-
- enc2cp_hash = TypedData_Wrap_Struct(0, &win32ole_hash_datatype, 0);
- RTYPEDDATA_DATA(enc2cp_hash) = st_init_numtable();
- rb_gc_register_mark_object(enc2cp_hash);
-
- com_hash = TypedData_Wrap_Struct(0, &win32ole_hash_datatype, 0);
- RTYPEDDATA_DATA(com_hash) = st_init_numtable();
- rb_gc_register_mark_object(com_hash);
-
- cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject);
-
- rb_define_alloc_func(cWIN32OLE, fole_s_allocate);
-
- rb_define_method(cWIN32OLE, "initialize", fole_initialize, -1);
-
- rb_define_singleton_method(cWIN32OLE, "connect", fole_s_connect, -1);
- rb_define_singleton_method(cWIN32OLE, "const_load", fole_s_const_load, -1);
-
- rb_define_singleton_method(cWIN32OLE, "ole_free", fole_s_free, 1);
- rb_define_singleton_method(cWIN32OLE, "ole_reference_count", fole_s_reference_count, 1);
- rb_define_singleton_method(cWIN32OLE, "ole_show_help", fole_s_show_help, -1);
- rb_define_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_singleton_method(cWIN32OLE, "ole_initialize", fole_s_ole_initialize, 0);
- rb_define_singleton_method(cWIN32OLE, "ole_uninitialize", fole_s_ole_uninitialize, 0);
-
- rb_define_method(cWIN32OLE, "invoke", fole_invoke, -1);
- rb_define_method(cWIN32OLE, "[]", fole_getproperty_with_bracket, -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, "ole_free", fole_free, 0);
-
- rb_define_method(cWIN32OLE, "each", fole_each, 0);
- rb_define_method(cWIN32OLE, "method_missing", fole_missing, -1);
-
- /* support setproperty method much like Perl ;-) */
- rb_define_method(cWIN32OLE, "setproperty", fole_setproperty, -1);
-
- rb_define_method(cWIN32OLE, "ole_methods", fole_methods, 0);
- rb_define_method(cWIN32OLE, "ole_get_methods", fole_get_methods, 0);
- rb_define_method(cWIN32OLE, "ole_put_methods", fole_put_methods, 0);
- rb_define_method(cWIN32OLE, "ole_func_methods", fole_func_methods, 0);
-
- rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1);
- rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method");
- rb_define_method(cWIN32OLE, "ole_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_method(cWIN32OLE, "ole_respond_to?", fole_respond_to, 1);
-
- /* Constants definition */
-
- /*
- * Version string of WIN32OLE.
- */
- rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION));
-
- /*
- * After invoking OLE methods with reference arguments, you can access
- * the value of arguments by using ARGV.
- *
- * If the method of OLE(COM) server written by C#.NET is following:
- *
- * void calcsum(int a, int b, out int c) {
- * c = a + b;
- * }
- *
- * then, the Ruby OLE(COM) client script to retrieve the value of
- * argument c after invoking calcsum method is following:
- *
- * a = 10
- * b = 20
- * c = 0
- * comserver.calcsum(a, b, c)
- * p c # => 0
- * p WIN32OLE::ARGV # => [10, 20, 30]
- *
- * You can use WIN32OLE_VARIANT object to retrieve the value of reference
- * arguments instead of referring WIN32OLE::ARGV.
- *
- */
- rb_define_const(cWIN32OLE, "ARGV", rb_ary_new());
-
- /*
- * 0: ANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_ACP", RB_INT2FIX(CP_ACP));
-
- /*
- * 1: OEM code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_OEMCP", RB_INT2FIX(CP_OEMCP));
-
- /*
- * 2
- */
- rb_define_const(cWIN32OLE, "CP_MACCP", RB_INT2FIX(CP_MACCP));
-
- /*
- * 3: current thread ANSI code page. See WIN32OLE.codepage and
- * WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_THREAD_ACP", RB_INT2FIX(CP_THREAD_ACP));
-
- /*
- * 42: symbol code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_SYMBOL", RB_INT2FIX(CP_SYMBOL));
-
- /*
- * 65000: UTF-7 code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_UTF7", RB_INT2FIX(CP_UTF7));
-
- /*
- * 65001: UTF-8 code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
- */
- rb_define_const(cWIN32OLE, "CP_UTF8", RB_INT2FIX(CP_UTF8));
-
- /*
- * 0x0800: default locale for the operating system. See WIN32OLE.locale
- * and WIN32OLE.locale=.
- */
- rb_define_const(cWIN32OLE, "LOCALE_SYSTEM_DEFAULT", RB_INT2FIX(LOCALE_SYSTEM_DEFAULT));
-
- /*
- * 0x0400: default locale for the user or process. See WIN32OLE.locale
- * and WIN32OLE.locale=.
- */
- rb_define_const(cWIN32OLE, "LOCALE_USER_DEFAULT", RB_INT2FIX(LOCALE_USER_DEFAULT));
-
- Init_win32ole_variant_m();
- Init_win32ole_typelib();
- Init_win32ole_type();
- Init_win32ole_variable();
- Init_win32ole_method();
- Init_win32ole_param();
- Init_win32ole_event();
- Init_win32ole_variant();
- Init_win32ole_record();
- Init_win32ole_error();
-
- ole_init_cp();
-}
diff --git a/ext/win32ole/win32ole.gemspec b/ext/win32ole/win32ole.gemspec
deleted file mode 100644
index b6ea8e8a55..0000000000
--- a/ext/win32ole/win32ole.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "win32ole"
- spec.version = "1.8.9"
- spec.authors = ["Masaki Suketa"]
- spec.email = ["suke@ruby-lang.org"]
-
- spec.summary = %q{Provides an interface for OLE Automation in Ruby}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/win32ole"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/ext/win32ole/win32ole.h b/ext/win32ole/win32ole.h
deleted file mode 100644
index cd627ef765..0000000000
--- a/ext/win32ole/win32ole.h
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef WIN32OLE_H
-#define WIN32OLE_H 1
-#include "ruby/ruby.h"
-#include "ruby/st.h"
-#include "ruby/encoding.h"
-
-#define GNUC_OLDER_3_4_4 \
- ((__GNUC__ < 3) || \
- ((__GNUC__ <= 3) && (__GNUC_MINOR__ < 4)) || \
- ((__GNUC__ <= 3) && (__GNUC_MINOR__ <= 4) && (__GNUC_PATCHLEVEL__ <= 4)))
-
-#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
-#ifndef NONAMELESSUNION
-#define NONAMELESSUNION 1
-#endif
-#endif
-
-#include <ctype.h>
-
-#include <windows.h>
-#include <ocidl.h>
-#include <olectl.h>
-#include <ole2.h>
-#if defined(HAVE_TYPE_IMULTILANGUAGE2) || defined(HAVE_TYPE_IMULTILANGUAGE)
-#include <mlang.h>
-#endif
-#include <stdlib.h>
-#include <math.h>
-#ifdef HAVE_STDARG_PROTOTYPES
-#include <stdarg.h>
-#define va_init_list(a,b) va_start(a,b)
-#else
-#include <varargs.h>
-#define va_init_list(a,b) va_start(a)
-#endif
-#include <objidl.h>
-
-#define DOUT fprintf(stderr,"%s(%d)\n", __FILE__, __LINE__)
-#define DOUTS(x) fprintf(stderr,"%s(%d):" #x "=%s\n",__FILE__, __LINE__,x)
-#define DOUTMSG(x) fprintf(stderr, "%s(%d):" #x "\n",__FILE__, __LINE__)
-#define DOUTI(x) fprintf(stderr, "%s(%d):" #x "=%d\n",__FILE__, __LINE__,x)
-#define DOUTD(x) fprintf(stderr, "%s(%d):" #x "=%f\n",__FILE__, __LINE__,x)
-
-#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
-#define V_UNION1(X, Y) ((X)->u.Y)
-#else
-#define V_UNION1(X, Y) ((X)->Y)
-#endif
-
-#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
-#undef V_UNION
-#define V_UNION(X,Y) ((X)->n1.n2.n3.Y)
-
-#undef V_VT
-#define V_VT(X) ((X)->n1.n2.vt)
-
-#undef V_BOOL
-#define V_BOOL(X) V_UNION(X,boolVal)
-#endif
-
-#ifndef V_I1REF
-#define V_I1REF(X) V_UNION(X, pcVal)
-#endif
-
-#ifndef V_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
-
-#ifdef HAVE_LONG_LONG
-#define I8_2_NUM LL2NUM
-#define UI8_2_NUM ULL2NUM
-#define NUM2I8 RB_NUM2LL
-#define NUM2UI8 RB_NUM2ULL
-#else
-#define I8_2_NUM RB_INT2NUM
-#define UI8_2_NUM RB_UINT2NUM
-#define NUM2I8 RB_NUM2INT
-#define NUM2UI8 RB_NUM2UINT
-#endif
-
-#define OLE_ADDREF(X) (X) ? ((X)->lpVtbl->AddRef(X)) : 0
-#define OLE_RELEASE(X) (X) ? ((X)->lpVtbl->Release(X)) : 0
-#define OLE_FREE(x) {\
- if(ole_initialized() == TRUE) {\
- if(x) {\
- OLE_RELEASE(x);\
- (x) = 0;\
- }\
- }\
-}
-
-#define OLE_GET_TYPEATTR(X, Y) ((X)->lpVtbl->GetTypeAttr((X), (Y)))
-#define OLE_RELEASE_TYPEATTR(X, Y) ((X)->lpVtbl->ReleaseTypeAttr((X), (Y)))
-
-struct oledata {
- IDispatch *pDispatch;
-};
-
-extern VALUE cWIN32OLE;
-extern LCID cWIN32OLE_lcid;
-
-struct oledata *oledata_get_struct(VALUE obj);
-LPWSTR ole_vstr2wc(VALUE vstr);
-LONG reg_open_key(HKEY hkey, const char *name, HKEY *phkey);
-LONG reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey);
-VALUE reg_enum_key(HKEY hkey, DWORD i);
-VALUE reg_get_val(HKEY hkey, const char *subkey);
-VALUE reg_get_val2(HKEY hkey, const char *subkey);
-void ole_initialize(void);
-VALUE default_inspect(VALUE self, const char *class_name);
-char *ole_wc2mb(LPWSTR pw);
-VALUE ole_wc2vstr(LPWSTR pw, BOOL isfree);
-
-#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-
-BOOL ole_initialized(void);
-HRESULT ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile);
-VALUE ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-VALUE make_inspect(const char *class_name, VALUE detail);
-void ole_val2variant(VALUE val, VARIANT *var);
-void ole_val2variant2(VALUE val, VARIANT *var);
-void ole_val2variant_ex(VALUE val, VARIANT *var, VARTYPE vt);
-VALUE ole_variant2val(VARIANT *pvar);
-HRESULT ole_val_ary2variant_ary(VALUE val, VARIANT *var, VARTYPE vt);
-VOID *val2variant_ptr(VALUE val, VARIANT *var, VARTYPE vt);
-HRESULT typelib_from_val(VALUE obj, ITypeLib **pTypeLib);
-
-#include "win32ole_variant_m.h"
-#include "win32ole_typelib.h"
-#include "win32ole_type.h"
-#include "win32ole_variable.h"
-#include "win32ole_method.h"
-#include "win32ole_param.h"
-#include "win32ole_event.h"
-#include "win32ole_variant.h"
-#include "win32ole_record.h"
-#include "win32ole_error.h"
-
-#endif
diff --git a/ext/win32ole/win32ole_error.c b/ext/win32ole/win32ole_error.c
deleted file mode 100644
index 2bb5156263..0000000000
--- a/ext/win32ole/win32ole_error.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "win32ole.h"
-
-static VALUE ole_hresult2msg(HRESULT hr);
-
-static VALUE
-ole_hresult2msg(HRESULT hr)
-{
- VALUE msg = Qnil;
- char *p_msg = NULL;
- char *term = NULL;
- DWORD dwCount;
-
- char strhr[100];
- sprintf(strhr, " HRESULT error code:0x%08x\n ", (unsigned)hr);
- msg = rb_str_new2(strhr);
- dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, hr,
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
- (LPTSTR)&p_msg, 0, NULL);
- if (dwCount == 0) {
- dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, hr, cWIN32OLE_lcid,
- (LPTSTR)&p_msg, 0, NULL);
- }
- if (dwCount > 0) {
- term = p_msg + strlen(p_msg);
- while (p_msg < term) {
- term--;
- if (*term == '\r' || *term == '\n')
- *term = '\0';
- else break;
- }
- if (p_msg[0] != '\0') {
- rb_str_cat2(msg, p_msg);
- }
- }
- LocalFree(p_msg);
- return msg;
-}
-
-void
-ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
-{
- va_list args;
- VALUE msg;
- VALUE err_msg;
- va_init_list(args, fmt);
- msg = rb_vsprintf(fmt, args);
- va_end(args);
-
- err_msg = ole_hresult2msg(hr);
- if(err_msg != Qnil) {
- rb_str_cat2(msg, "\n");
- rb_str_append(msg, err_msg);
- }
- rb_exc_raise(rb_exc_new_str(ecs, msg));
-}
-
-VALUE eWIN32OLERuntimeError;
-VALUE eWIN32OLEQueryInterfaceError;
-
-void
-Init_win32ole_error(void)
-{
- /*
- * Document-class: WIN32OLERuntimeError
- *
- * Raised when OLE processing failed.
- *
- * EX:
- *
- * obj = WIN32OLE.new("NonExistProgID")
- *
- * raises the exception:
- *
- * WIN32OLERuntimeError: unknown OLE server: `NonExistProgID'
- * HRESULT error code:0x800401f3
- * Invalid class string
- *
- */
- eWIN32OLERuntimeError = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError);
- eWIN32OLEQueryInterfaceError = rb_define_class("WIN32OLEQueryInterfaceError", eWIN32OLERuntimeError);
-}
diff --git a/ext/win32ole/win32ole_error.h b/ext/win32ole/win32ole_error.h
deleted file mode 100644
index a2f329856f..0000000000
--- a/ext/win32ole/win32ole_error.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef WIN32OLE_ERROR_H
-#define WIN32OLE_ERROR_H 1
-
-extern VALUE eWIN32OLERuntimeError;
-extern VALUE eWIN32OLEQueryInterfaceError;
-NORETURN(PRINTF_ARGS(void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...), 3, 4));
-void Init_win32ole_error(void);
-
-#endif
diff --git a/ext/win32ole/win32ole_event.c b/ext/win32ole/win32ole_event.c
deleted file mode 100644
index 45ebf13433..0000000000
--- a/ext/win32ole/win32ole_event.c
+++ /dev/null
@@ -1,1278 +0,0 @@
-#include "win32ole.h"
-
-/*
- * Document-class: WIN32OLE_EVENT
- *
- * <code>WIN32OLE_EVENT</code> objects controls OLE event.
- */
-
-RUBY_EXTERN void rb_write_error_str(VALUE mesg);
-
-typedef struct {
- struct IEventSinkVtbl * lpVtbl;
-} IEventSink, *PEVENTSINK;
-
-typedef struct IEventSinkVtbl IEventSinkVtbl;
-
-struct IEventSinkVtbl {
- STDMETHOD(QueryInterface)(
- PEVENTSINK,
- REFIID,
- LPVOID *);
- STDMETHOD_(ULONG, AddRef)(PEVENTSINK);
- STDMETHOD_(ULONG, Release)(PEVENTSINK);
-
- STDMETHOD(GetTypeInfoCount)(
- PEVENTSINK,
- UINT *);
- STDMETHOD(GetTypeInfo)(
- PEVENTSINK,
- UINT,
- LCID,
- ITypeInfo **);
- STDMETHOD(GetIDsOfNames)(
- PEVENTSINK,
- REFIID,
- OLECHAR **,
- UINT,
- LCID,
- DISPID *);
- STDMETHOD(Invoke)(
- PEVENTSINK,
- DISPID,
- REFIID,
- LCID,
- WORD,
- DISPPARAMS *,
- VARIANT *,
- EXCEPINFO *,
- UINT *);
-};
-
-typedef struct tagIEVENTSINKOBJ {
- const IEventSinkVtbl *lpVtbl;
- DWORD m_cRef;
- IID m_iid;
- long m_event_id;
- ITypeInfo *pTypeInfo;
-}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
-
-struct oleeventdata {
- DWORD dwCookie;
- IConnectionPoint *pConnectionPoint;
- IDispatch *pDispatch;
- long event_id;
-};
-
-static VALUE ary_ole_event;
-static ID id_events;
-
-VALUE cWIN32OLE_EVENT;
-
-STDMETHODIMP EVENTSINK_QueryInterface(PEVENTSINK, REFIID, LPVOID*);
-STDMETHODIMP_(ULONG) EVENTSINK_AddRef(PEVENTSINK);
-STDMETHODIMP_(ULONG) EVENTSINK_Release(PEVENTSINK);
-STDMETHODIMP EVENTSINK_GetTypeInfoCount(PEVENTSINK, UINT*);
-STDMETHODIMP EVENTSINK_GetTypeInfo(PEVENTSINK, UINT, LCID, ITypeInfo**);
-STDMETHODIMP EVENTSINK_GetIDsOfNames(PEVENTSINK, REFIID, OLECHAR**, UINT, LCID, DISPID*);
-STDMETHODIMP EVENTSINK_Invoke(PEVENTSINK, DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
-
-static const IEventSinkVtbl vtEventSink = {
- EVENTSINK_QueryInterface,
- EVENTSINK_AddRef,
- EVENTSINK_Release,
- EVENTSINK_GetTypeInfoCount,
- EVENTSINK_GetTypeInfo,
- EVENTSINK_GetIDsOfNames,
- EVENTSINK_Invoke,
-};
-
-void EVENTSINK_Destructor(PIEVENTSINKOBJ);
-static void ole_val2ptr_variant(VALUE val, VARIANT *var);
-static void hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams);
-static VALUE hash2result(VALUE hash);
-static void ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams);
-static VALUE exec_callback(VALUE arg);
-static VALUE rescue_callback(VALUE arg);
-static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo);
-static HRESULT find_coclass(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **pTypeInfo2, TYPEATTR **pTypeAttr2);
-static HRESULT find_default_source_from_typeinfo(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **ppTypeInfo);
-static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
-static long ole_search_event_at(VALUE ary, VALUE ev);
-static VALUE ole_search_event(VALUE ary, VALUE ev, BOOL *is_default);
-static VALUE ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler);
-static void ole_delete_event(VALUE ary, VALUE ev);
-static void oleevent_free(void *ptr);
-static size_t oleevent_size(const void *ptr);
-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 void ole_msg_loop(void);
-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_off_event(int argc, VALUE *argv, VALUE self);
-static VALUE fev_unadvise(VALUE self);
-static VALUE fev_set_handler(VALUE self, VALUE val);
-static VALUE fev_get_handler(VALUE self);
-static VALUE evs_push(VALUE ev);
-static VALUE evs_delete(long i);
-static VALUE evs_entry(long i);
-static long evs_length(void);
-
-
-static const rb_data_type_t oleevent_datatype = {
- "win32ole_event",
- {NULL, oleevent_free, oleevent_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-STDMETHODIMP EVENTSINK_Invoke(
- PEVENTSINK pEventSink,
- DISPID dispid,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- DISPPARAMS *pdispparams,
- VARIANT *pvarResult,
- EXCEPINFO *pexcepinfo,
- UINT *puArgErr
- ) {
-
- HRESULT hr;
- BSTR bstr;
- unsigned int count;
- unsigned int i;
- ITypeInfo *pTypeInfo;
- VARIANT *pvar;
- VALUE ary, obj, event, args, outargv, ev, result;
- VALUE handler = Qnil;
- VALUE arg[3];
- VALUE mid;
- VALUE is_outarg = Qfalse;
- BOOL is_default_handler = FALSE;
- int state;
-
- PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
- pTypeInfo = pEV->pTypeInfo;
- obj = evs_entry(pEV->m_event_id);
- if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) {
- return NOERROR;
- }
-
- ary = rb_ivar_get(obj, id_events);
- if (NIL_P(ary) || !RB_TYPE_P(ary, T_ARRAY)) {
- return NOERROR;
- }
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
- &bstr, 1, &count);
- if (FAILED(hr)) {
- return NOERROR;
- }
- ev = WC2VSTR(bstr);
- event = ole_search_event(ary, ev, &is_default_handler);
- if (RB_TYPE_P(event, T_ARRAY)) {
- handler = rb_ary_entry(event, 0);
- mid = rb_intern("call");
- is_outarg = rb_ary_entry(event, 3);
- } else {
- handler = rb_ivar_get(obj, rb_intern("handler"));
- if (handler == Qnil) {
- return NOERROR;
- }
- mid = ole_search_handler_method(handler, ev, &is_default_handler);
- }
- if (handler == Qnil || mid == Qnil) {
- return NOERROR;
- }
-
- args = rb_ary_new();
- if (is_default_handler) {
- rb_ary_push(args, ev);
- }
-
- /* make argument of event handler */
- for (i = 0; i < pdispparams->cArgs; ++i) {
- pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
- rb_ary_push(args, ole_variant2val(pvar));
- }
- outargv = Qnil;
- if (is_outarg == Qtrue) {
- outargv = rb_ary_new();
- rb_ary_push(args, outargv);
- }
-
- /*
- * if exception raised in event callback,
- * then you receive cfp consistency error.
- * to avoid this error we use begin rescue end.
- * and the exception raised then error message print
- * and exit ruby process by Win32OLE itself.
- */
- arg[0] = handler;
- arg[1] = mid;
- arg[2] = args;
- result = rb_protect(exec_callback, (VALUE)arg, &state);
- if (state != 0) {
- rescue_callback(Qnil);
- }
- if(RB_TYPE_P(result, T_HASH)) {
- hash2ptr_dispparams(result, pTypeInfo, dispid, pdispparams);
- result = hash2result(result);
- }else if (is_outarg == Qtrue && RB_TYPE_P(outargv, T_ARRAY)) {
- ary2ptr_dispparams(outargv, pdispparams);
- }
-
- if (pvarResult) {
- VariantInit(pvarResult);
- ole_val2variant(result, pvarResult);
- }
-
- return NOERROR;
-}
-
-STDMETHODIMP
-EVENTSINK_QueryInterface(
- PEVENTSINK pEV,
- REFIID iid,
- LPVOID* ppv
- ) {
- if (IsEqualIID(iid, &IID_IUnknown) ||
- IsEqualIID(iid, &IID_IDispatch) ||
- IsEqualIID(iid, &((PIEVENTSINKOBJ)pEV)->m_iid)) {
- *ppv = pEV;
- }
- else {
- *ppv = NULL;
- return E_NOINTERFACE;
- }
- ((LPUNKNOWN)*ppv)->lpVtbl->AddRef((LPUNKNOWN)*ppv);
- return NOERROR;
-}
-
-STDMETHODIMP_(ULONG)
-EVENTSINK_AddRef(
- PEVENTSINK pEV
- ){
- PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
- return ++pEVObj->m_cRef;
-}
-
-STDMETHODIMP_(ULONG) EVENTSINK_Release(
- PEVENTSINK pEV
- ) {
- PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
- --pEVObj->m_cRef;
- if(pEVObj->m_cRef != 0)
- return pEVObj->m_cRef;
- EVENTSINK_Destructor(pEVObj);
- return 0;
-}
-
-STDMETHODIMP EVENTSINK_GetTypeInfoCount(
- PEVENTSINK pEV,
- UINT *pct
- ) {
- *pct = 0;
- return NOERROR;
-}
-
-STDMETHODIMP EVENTSINK_GetTypeInfo(
- PEVENTSINK pEV,
- UINT info,
- LCID lcid,
- ITypeInfo **pInfo
- ) {
- *pInfo = NULL;
- return DISP_E_BADINDEX;
-}
-
-STDMETHODIMP EVENTSINK_GetIDsOfNames(
- PEVENTSINK pEventSink,
- REFIID riid,
- OLECHAR **szNames,
- UINT cNames,
- LCID lcid,
- DISPID *pDispID
- ) {
- ITypeInfo *pTypeInfo;
- PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
- pTypeInfo = pEV->pTypeInfo;
- if (pTypeInfo) {
- return pTypeInfo->lpVtbl->GetIDsOfNames(pTypeInfo, szNames, cNames, pDispID);
- }
- return DISP_E_UNKNOWNNAME;
-}
-
-PIEVENTSINKOBJ
-EVENTSINK_Constructor(void)
-{
- PIEVENTSINKOBJ pEv;
- pEv = ALLOC_N(IEVENTSINKOBJ, 1);
- if(pEv == NULL) return NULL;
- pEv->lpVtbl = &vtEventSink;
- pEv->m_cRef = 0;
- pEv->m_event_id = 0;
- pEv->pTypeInfo = NULL;
- return pEv;
-}
-
-void
-EVENTSINK_Destructor(
- PIEVENTSINKOBJ pEVObj
- ) {
- if(pEVObj != NULL) {
- OLE_RELEASE(pEVObj->pTypeInfo);
- free(pEVObj);
- pEVObj = NULL;
- }
-}
-
-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_vstr2wc(val);
- }
- break;
- case T_FIXNUM:
- switch(V_VT(var)) {
- case (VT_UI1 | VT_BYREF) :
- *V_UI1REF(var) = RB_NUM2CHR(val);
- break;
- case (VT_I2 | VT_BYREF) :
- *V_I2REF(var) = (short)RB_NUM2INT(val);
- break;
- case (VT_I4 | VT_BYREF) :
- *V_I4REF(var) = RB_NUM2INT(val);
- break;
- case (VT_R4 | VT_BYREF) :
- *V_R4REF(var) = (float)RB_NUM2INT(val);
- break;
- case (VT_R8 | VT_BYREF) :
- *V_R8REF(var) = RB_NUM2INT(val);
- break;
- default:
- break;
- }
- break;
- case T_FLOAT:
- switch(V_VT(var)) {
- case (VT_I2 | VT_BYREF) :
- *V_I2REF(var) = (short)RB_NUM2INT(val);
- break;
- case (VT_I4 | VT_BYREF) :
- *V_I4REF(var) = RB_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
-hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams)
-{
- BSTR *bstrs;
- HRESULT hr;
- UINT len, i;
- VARIANT *pvar;
- VALUE val;
- VALUE key;
- len = 0;
- bstrs = ALLOCA_N(BSTR, pdispparams->cArgs + 1);
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
- bstrs, pdispparams->cArgs + 1,
- &len);
- if (FAILED(hr))
- return;
-
- for (i = 0; i < len - 1; i++) {
- key = WC2VSTR(bstrs[i + 1]);
- val = rb_hash_aref(hash, RB_UINT2NUM(i));
- if (val == Qnil)
- val = rb_hash_aref(hash, key);
- if (val == Qnil)
- val = rb_hash_aref(hash, rb_str_intern(key));
- pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
- ole_val2ptr_variant(val, pvar);
- }
-}
-
-static VALUE
-hash2result(VALUE hash)
-{
- VALUE ret = Qnil;
- ret = rb_hash_aref(hash, rb_str_new2("return"));
- if (ret == Qnil)
- ret = rb_hash_aref(hash, rb_str_intern(rb_str_new2("return")));
- return ret;
-}
-
-static void
-ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
-{
- int i;
- VALUE v;
- VARIANT *pvar;
- for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
- v = rb_ary_entry(ary, i);
- pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
- ole_val2ptr_variant(v, pvar);
- }
-}
-
-static VALUE
-exec_callback(VALUE arg)
-{
- VALUE *parg = (VALUE *)arg;
- VALUE handler = parg[0];
- VALUE mid = parg[1];
- VALUE args = parg[2];
- return rb_apply(handler, mid, args);
-}
-
-static VALUE
-rescue_callback(VALUE arg)
-{
-
- VALUE error;
- VALUE e = rb_errinfo();
- VALUE bt = rb_funcall(e, rb_intern("backtrace"), 0);
- VALUE msg = rb_funcall(e, rb_intern("message"), 0);
- bt = rb_ary_entry(bt, 0);
- error = rb_sprintf("%"PRIsVALUE": %"PRIsVALUE" (%s)\n", bt, msg, rb_obj_classname(e));
- rb_write_error_str(error);
- rb_backtrace();
- ruby_finalize();
- exit(-1);
-
- return Qnil;
-}
-
-static HRESULT
-find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
-{
- HRESULT hr;
- IDispatch *pDispatch;
- ITypeInfo *pTypeInfo;
- ITypeLib *pTypeLib;
- TYPEATTR *pTypeAttr;
- HREFTYPE RefType;
- ITypeInfo *pImplTypeInfo;
- TYPEATTR *pImplTypeAttr;
-
- struct oledata *pole = NULL;
- unsigned int index;
- unsigned int count;
- int type;
- BSTR bstr;
- char *pstr;
-
- BOOL is_found = FALSE;
- LCID lcid = cWIN32OLE_lcid;
-
- pole = oledata_get_struct(ole);
-
- pDispatch = pole->pDispatch;
-
- hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, lcid, &pTypeInfo);
- if (FAILED(hr))
- return hr;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo,
- &pTypeLib,
- &index);
- OLE_RELEASE(pTypeInfo);
- if (FAILED(hr))
- return hr;
-
- if (!pitf) {
- hr = pTypeLib->lpVtbl->GetTypeInfoOfGuid(pTypeLib,
- piid,
- ppTypeInfo);
- OLE_RELEASE(pTypeLib);
- return hr;
- }
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (index = 0; index < count; index++) {
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib,
- index,
- &pTypeInfo);
- if (FAILED(hr))
- break;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
-
- if(FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- break;
- }
- if(pTypeAttr->typekind == TKIND_COCLASS) {
- for (type = 0; type < pTypeAttr->cImplTypes; type++) {
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
- type,
- &RefType);
- if (FAILED(hr))
- break;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
- RefType,
- &pImplTypeInfo);
- if (FAILED(hr))
- break;
-
- hr = pImplTypeInfo->lpVtbl->GetDocumentation(pImplTypeInfo,
- -1,
- &bstr,
- NULL, NULL, NULL);
- if (FAILED(hr)) {
- OLE_RELEASE(pImplTypeInfo);
- break;
- }
- pstr = ole_wc2mb(bstr);
- if (strcmp(pitf, pstr) == 0) {
- hr = pImplTypeInfo->lpVtbl->GetTypeAttr(pImplTypeInfo,
- &pImplTypeAttr);
- if (SUCCEEDED(hr)) {
- is_found = TRUE;
- *piid = pImplTypeAttr->guid;
- if (ppTypeInfo) {
- *ppTypeInfo = pImplTypeInfo;
- (*ppTypeInfo)->lpVtbl->AddRef((*ppTypeInfo));
- }
- pImplTypeInfo->lpVtbl->ReleaseTypeAttr(pImplTypeInfo,
- pImplTypeAttr);
- }
- }
- free(pstr);
- OLE_RELEASE(pImplTypeInfo);
- if (is_found || FAILED(hr))
- break;
- }
- }
-
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- OLE_RELEASE(pTypeInfo);
- if (is_found || FAILED(hr))
- break;
- }
- OLE_RELEASE(pTypeLib);
- if(!is_found)
- return E_NOINTERFACE;
- return hr;
-}
-
-static HRESULT
-find_coclass(
- ITypeInfo *pTypeInfo,
- TYPEATTR *pTypeAttr,
- ITypeInfo **pCOTypeInfo,
- TYPEATTR **pCOTypeAttr)
-{
- HRESULT hr = E_NOINTERFACE;
- ITypeLib *pTypeLib;
- int count;
- BOOL found = FALSE;
- ITypeInfo *pTypeInfo2;
- TYPEATTR *pTypeAttr2;
- int flags;
- int i,j;
- HREFTYPE href;
- ITypeInfo *pRefTypeInfo;
- TYPEATTR *pRefTypeAttr;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, NULL);
- if (FAILED(hr)) {
- return hr;
- }
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (i = 0; i < count && !found; i++) {
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo2);
- if (FAILED(hr))
- continue;
- hr = OLE_GET_TYPEATTR(pTypeInfo2, &pTypeAttr2);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeInfo2);
- continue;
- }
- if (pTypeAttr2->typekind != TKIND_COCLASS) {
- OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
- OLE_RELEASE(pTypeInfo2);
- continue;
- }
- for (j = 0; j < pTypeAttr2->cImplTypes && !found; j++) {
- hr = pTypeInfo2->lpVtbl->GetImplTypeFlags(pTypeInfo2, j, &flags);
- if (FAILED(hr))
- continue;
- if (!(flags & IMPLTYPEFLAG_FDEFAULT))
- continue;
- hr = pTypeInfo2->lpVtbl->GetRefTypeOfImplType(pTypeInfo2, j, &href);
- if (FAILED(hr))
- continue;
- hr = pTypeInfo2->lpVtbl->GetRefTypeInfo(pTypeInfo2, href, &pRefTypeInfo);
- if (FAILED(hr))
- continue;
- hr = OLE_GET_TYPEATTR(pRefTypeInfo, &pRefTypeAttr);
- if (FAILED(hr)) {
- OLE_RELEASE(pRefTypeInfo);
- continue;
- }
- if (IsEqualGUID(&(pTypeAttr->guid), &(pRefTypeAttr->guid))) {
- found = TRUE;
- }
- }
- if (!found) {
- OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
- OLE_RELEASE(pTypeInfo2);
- }
- }
- OLE_RELEASE(pTypeLib);
- if (found) {
- *pCOTypeInfo = pTypeInfo2;
- *pCOTypeAttr = pTypeAttr2;
- hr = S_OK;
- } else {
- hr = E_NOINTERFACE;
- }
- return hr;
-}
-
-static HRESULT
-find_default_source_from_typeinfo(
- ITypeInfo *pTypeInfo,
- TYPEATTR *pTypeAttr,
- ITypeInfo **ppTypeInfo)
-{
- int i = 0;
- HRESULT hr = E_NOINTERFACE;
- int flags;
- HREFTYPE hRefType;
- /* Enumerate all implemented types of the COCLASS */
- for (i = 0; i < pTypeAttr->cImplTypes; i++) {
- hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
- if (FAILED(hr))
- continue;
-
- /*
- looking for the [default] [source]
- we just hope that it is a dispinterface :-)
- */
- if ((flags & IMPLTYPEFLAG_FDEFAULT) &&
- (flags & IMPLTYPEFLAG_FSOURCE)) {
-
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
- i, &hRefType);
- if (FAILED(hr))
- continue;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
- hRefType, ppTypeInfo);
- if (SUCCEEDED(hr))
- break;
- }
- }
- return hr;
-}
-
-static HRESULT
-find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
-{
- HRESULT hr;
- IProvideClassInfo2 *pProvideClassInfo2;
- IProvideClassInfo *pProvideClassInfo;
- void *p;
-
- IDispatch *pDispatch;
- ITypeInfo *pTypeInfo;
- ITypeInfo *pTypeInfo2 = NULL;
- TYPEATTR *pTypeAttr;
- TYPEATTR *pTypeAttr2 = NULL;
-
- struct oledata *pole = NULL;
-
- pole = oledata_get_struct(ole);
- pDispatch = pole->pDispatch;
- hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
- &IID_IProvideClassInfo2,
- &p);
- if (SUCCEEDED(hr)) {
- pProvideClassInfo2 = p;
- hr = pProvideClassInfo2->lpVtbl->GetGUID(pProvideClassInfo2,
- GUIDKIND_DEFAULT_SOURCE_DISP_IID,
- piid);
- OLE_RELEASE(pProvideClassInfo2);
- if (SUCCEEDED(hr)) {
- hr = find_iid(ole, NULL, piid, ppTypeInfo);
- }
- }
- if (SUCCEEDED(hr)) {
- return hr;
- }
- hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
- &IID_IProvideClassInfo,
- &p);
- if (SUCCEEDED(hr)) {
- pProvideClassInfo = p;
- hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo,
- &pTypeInfo);
- OLE_RELEASE(pProvideClassInfo);
- }
- if (FAILED(hr)) {
- hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, cWIN32OLE_lcid, &pTypeInfo );
- }
- if (FAILED(hr))
- return hr;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- return hr;
- }
-
- *ppTypeInfo = 0;
- hr = find_default_source_from_typeinfo(pTypeInfo, pTypeAttr, ppTypeInfo);
- if (!*ppTypeInfo) {
- hr = find_coclass(pTypeInfo, pTypeAttr, &pTypeInfo2, &pTypeAttr2);
- if (SUCCEEDED(hr)) {
- hr = find_default_source_from_typeinfo(pTypeInfo2, pTypeAttr2, ppTypeInfo);
- OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
- OLE_RELEASE(pTypeInfo2);
- }
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- OLE_RELEASE(pTypeInfo);
- /* Now that would be a bad surprise, if we didn't find it, wouldn't it? */
- if (!*ppTypeInfo) {
- if (SUCCEEDED(hr))
- hr = E_UNEXPECTED;
- return hr;
- }
-
- /* Determine IID of default source interface */
- hr = (*ppTypeInfo)->lpVtbl->GetTypeAttr(*ppTypeInfo, &pTypeAttr);
- if (SUCCEEDED(hr)) {
- *piid = pTypeAttr->guid;
- (*ppTypeInfo)->lpVtbl->ReleaseTypeAttr(*ppTypeInfo, pTypeAttr);
- }
- else
- OLE_RELEASE(*ppTypeInfo);
-
- return hr;
-}
-
-static long
-ole_search_event_at(VALUE ary, VALUE ev)
-{
- VALUE event;
- VALUE event_name;
- long i, len;
- long ret = -1;
- len = RARRAY_LEN(ary);
- for(i = 0; i < len; i++) {
- event = rb_ary_entry(ary, i);
- event_name = rb_ary_entry(event, 1);
- if(NIL_P(event_name) && NIL_P(ev)) {
- ret = i;
- break;
- }
- else if (RB_TYPE_P(ev, T_STRING) &&
- RB_TYPE_P(event_name, T_STRING) &&
- rb_str_cmp(ev, event_name) == 0) {
- ret = i;
- break;
- }
- }
- return ret;
-}
-
-static VALUE
-ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
-{
- VALUE event;
- VALUE def_event;
- VALUE event_name;
- int i, len;
- *is_default = FALSE;
- def_event = Qnil;
- len = RARRAY_LEN(ary);
- for(i = 0; i < len; i++) {
- event = rb_ary_entry(ary, i);
- event_name = rb_ary_entry(event, 1);
- if(NIL_P(event_name)) {
- *is_default = TRUE;
- def_event = event;
- }
- else if (rb_str_cmp(ev, event_name) == 0) {
- *is_default = FALSE;
- return event;
- }
- }
- return def_event;
-}
-
-static VALUE
-ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler)
-{
- VALUE mid;
-
- *is_default_handler = FALSE;
- mid = rb_to_id(rb_sprintf("on%"PRIsVALUE, ev));
- if (rb_respond_to(handler, mid)) {
- return mid;
- }
- mid = rb_intern("method_missing");
- if (rb_respond_to(handler, mid)) {
- *is_default_handler = TRUE;
- return mid;
- }
- return Qnil;
-}
-
-static void
-ole_delete_event(VALUE ary, VALUE ev)
-{
- long at = -1;
- at = ole_search_event_at(ary, ev);
- if (at >= 0) {
- rb_ary_delete_at(ary, at);
- }
-}
-
-
-static void
-oleevent_free(void *ptr)
-{
- struct oleeventdata *poleev = ptr;
- if (poleev->pConnectionPoint) {
- poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie);
- OLE_RELEASE(poleev->pConnectionPoint);
- poleev->pConnectionPoint = NULL;
- }
- OLE_RELEASE(poleev->pDispatch);
- free(poleev);
-}
-
-static size_t
-oleevent_size(const void *ptr)
-{
- return ptr ? sizeof(struct oleeventdata) : 0;
-}
-
-static VALUE
-fev_s_allocate(VALUE klass)
-{
- VALUE obj;
- struct oleeventdata *poleev;
- obj = TypedData_Make_Struct(klass, struct oleeventdata, &oleevent_datatype, poleev);
- poleev->dwCookie = 0;
- poleev->pConnectionPoint = NULL;
- poleev->event_id = 0;
- poleev->pDispatch = NULL;
- return obj;
-}
-
-static VALUE
-ev_advise(int argc, VALUE *argv, VALUE self)
-{
-
- VALUE ole, itf;
- struct oledata *pole = NULL;
- char *pitf;
- HRESULT hr;
- IID iid;
- ITypeInfo *pTypeInfo = 0;
- IDispatch *pDispatch;
- IConnectionPointContainer *pContainer;
- IConnectionPoint *pConnectionPoint;
- IEVENTSINKOBJ *pIEV;
- DWORD dwCookie;
- struct oleeventdata *poleev;
- void *p;
-
- rb_scan_args(argc, argv, "11", &ole, &itf);
-
- if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
- rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object");
- }
-
- if(!RB_TYPE_P(itf, T_NIL)) {
- pitf = StringValuePtr(itf);
- hr = find_iid(ole, pitf, &iid, &pTypeInfo);
- }
- else {
- hr = find_default_source(ole, &iid, &pTypeInfo);
- }
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "interface not found");
- }
-
- pole = oledata_get_struct(ole);
- pDispatch = pole->pDispatch;
- hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
- &IID_IConnectionPointContainer,
- &p);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- ole_raise(hr, eWIN32OLEQueryInterfaceError,
- "failed to query IConnectionPointContainer");
- }
- pContainer = p;
-
- hr = pContainer->lpVtbl->FindConnectionPoint(pContainer,
- &iid,
- &pConnectionPoint);
- OLE_RELEASE(pContainer);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeInfo);
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to query IConnectionPoint");
- }
- pIEV = EVENTSINK_Constructor();
- pIEV->m_iid = iid;
- hr = pConnectionPoint->lpVtbl->Advise(pConnectionPoint,
- (IUnknown*)pIEV,
- &dwCookie);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "Advise Error");
- }
-
- TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
- pIEV->m_event_id = evs_length();
- pIEV->pTypeInfo = pTypeInfo;
- poleev->dwCookie = dwCookie;
- poleev->pConnectionPoint = pConnectionPoint;
- poleev->event_id = pIEV->m_event_id;
- poleev->pDispatch = pDispatch;
- OLE_ADDREF(pDispatch);
-
- 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());
- fev_set_handler(self, Qnil);
- return self;
-}
-
-static void
-ole_msg_loop(void)
-{
- MSG msg;
- while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT.message_loop
- *
- * Translates and dispatches Windows message.
- */
-static VALUE
-fev_s_msg_loop(VALUE klass)
-{
- ole_msg_loop();
- return Qnil;
-}
-
-static void
-add_event_call_back(VALUE obj, VALUE event, VALUE data)
-{
- VALUE events = rb_ivar_get(obj, id_events);
- if (NIL_P(events) || !RB_TYPE_P(events, T_ARRAY)) {
- events = rb_ary_new();
- rb_ivar_set(obj, id_events, events);
- }
- ole_delete_event(events, event);
- rb_ary_push(events, data);
-}
-
-static VALUE
-ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
-{
- struct oleeventdata *poleev;
- VALUE event, args, data;
- TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, 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)) {
- if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- if (RB_TYPE_P(event, T_SYMBOL)) {
- event = rb_sym2str(event);
- }
- }
- data = rb_ary_new3(4, rb_block_proc(), event, args, is_ary_arg);
- add_event_call_back(self, event, data);
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#on_event([event]){...}
- *
- * Defines the callback event.
- * If argument is omitted, this method defines the callback of all events.
- * If you want to modify reference argument in callback, return hash in
- * callback. If you want to return value to OLE server as result of callback
- * use `return' or :return.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie)
- * ev.on_event("NavigateComplete") {|url| puts url}
- * ev.on_event() {|ev, *args| puts "#{ev} fired"}
- *
- * ev.on_event("BeforeNavigate2") {|*args|
- * ...
- * # set true to BeforeNavigate reference argument `Cancel'.
- * # Cancel is 7-th argument of BeforeNavigate,
- * # so you can use 6 as key of hash instead of 'Cancel'.
- * # The argument is counted from 0.
- * # The hash key of 0 means first argument.)
- * {:Cancel => true} # or {'Cancel' => true} or {6 => true}
- * }
- *
- * ev.on_event(...) {|*args|
- * {:return => 1, :xxx => yyy}
- * }
- */
-static VALUE
-fev_on_event(int argc, VALUE *argv, VALUE self)
-{
- return ev_on_event(argc, argv, self, Qfalse);
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#on_event_with_outargs([event]){...}
- *
- * Defines the callback of event.
- * If you want modify argument in callback,
- * you could use this method instead of WIN32OLE_EVENT#on_event.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie)
- * ev.on_event_with_outargs('BeforeNavigate2') {|*args|
- * args.last[6] = true
- * }
- */
-static VALUE
-fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self)
-{
- return ev_on_event(argc, argv, self, Qtrue);
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#off_event([event])
- *
- * removes the callback of event.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie)
- * ev.on_event('BeforeNavigate2') {|*args|
- * args.last[6] = true
- * }
- * ...
- * ev.off_event('BeforeNavigate2')
- * ...
- */
-static VALUE
-fev_off_event(int argc, VALUE *argv, VALUE self)
-{
- VALUE event = Qnil;
- VALUE events;
-
- rb_scan_args(argc, argv, "01", &event);
- if(!NIL_P(event)) {
- if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- if (RB_TYPE_P(event, T_SYMBOL)) {
- event = rb_sym2str(event);
- }
- }
- events = rb_ivar_get(self, id_events);
- if (NIL_P(events)) {
- return Qnil;
- }
- ole_delete_event(events, event);
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#unadvise -> nil
- *
- * disconnects OLE server. If this method called, then the WIN32OLE_EVENT object
- * does not receive the OLE server event any more.
- * This method is trial implementation.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie)
- * ev.on_event() {...}
- * ...
- * ev.unadvise
- *
- */
-static VALUE
-fev_unadvise(VALUE self)
-{
- struct oleeventdata *poleev;
- TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, 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;
- }
- OLE_FREE(poleev->pDispatch);
- 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 long
-evs_length(void)
-{
- return RARRAY_LEN(ary_ole_event);
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#handler=
- *
- * sets event handler object. If handler object has onXXX
- * method according to XXX event, then onXXX method is called
- * when XXX event occurs.
- *
- * If handler object has method_missing and there is no
- * method according to the event, then method_missing
- * called and 1-st argument is event name.
- *
- * If handler object has onXXX method and there is block
- * defined by WIN32OLE_EVENT#on_event('XXX'){},
- * then block is executed but handler object method is not called
- * when XXX event occurs.
- *
- * class Handler
- * def onStatusTextChange(text)
- * puts "StatusTextChanged"
- * end
- * def onPropertyChange(prop)
- * puts "PropertyChanged"
- * end
- * def method_missing(ev, *arg)
- * puts "other event #{ev}"
- * end
- * end
- *
- * handler = Handler.new
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie)
- * ev.on_event("StatusTextChange") {|*args|
- * puts "this block executed."
- * puts "handler.onStatusTextChange method is not called."
- * }
- * ev.handler = handler
- *
- */
-static VALUE
-fev_set_handler(VALUE self, VALUE val)
-{
- return rb_ivar_set(self, rb_intern("handler"), val);
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT#handler
- *
- * returns handler object.
- *
- */
-static VALUE
-fev_get_handler(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("handler"));
-}
-
-void
-Init_win32ole_event(void)
-{
-#undef rb_intern
- ary_ole_event = rb_ary_new();
- rb_gc_register_mark_object(ary_ole_event);
- id_events = rb_intern("events");
- cWIN32OLE_EVENT = rb_define_class_under(cWIN32OLE, "Event", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_EVENT", cWIN32OLE_EVENT);
- 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_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, "off_event", fev_off_event, -1);
- rb_define_method(cWIN32OLE_EVENT, "unadvise", fev_unadvise, 0);
- rb_define_method(cWIN32OLE_EVENT, "handler=", fev_set_handler, 1);
- rb_define_method(cWIN32OLE_EVENT, "handler", fev_get_handler, 0);
-}
diff --git a/ext/win32ole/win32ole_event.h b/ext/win32ole/win32ole_event.h
deleted file mode 100644
index f1a5aa234d..0000000000
--- a/ext/win32ole/win32ole_event.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef WIN32OLE_EVENT_H
-#define WIN32OLE_EVENT_H 1
-
-void Init_win32ole_event(void);
-
-#endif
diff --git a/ext/win32ole/win32ole_method.c b/ext/win32ole/win32ole_method.c
deleted file mode 100644
index 646fdaf60c..0000000000
--- a/ext/win32ole/win32ole_method.c
+++ /dev/null
@@ -1,953 +0,0 @@
-#include "win32ole.h"
-
-static void olemethod_free(void *ptr);
-static size_t olemethod_size(const void *ptr);
-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 olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name);
-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 HRESULT 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 const rb_data_type_t olemethod_datatype = {
- "win32ole_method",
- {NULL, olemethod_free, olemethod_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static void
-olemethod_free(void *ptr)
-{
- struct olemethoddata *polemethod = ptr;
- OLE_FREE(polemethod->pTypeInfo);
- OLE_FREE(polemethod->pOwnerTypeInfo);
- free(polemethod);
-}
-
-static size_t
-olemethod_size(const void *ptr)
-{
- return ptr ? sizeof(struct olemethoddata) : 0;
-}
-
-struct olemethoddata *
-olemethod_data_get_struct(VALUE obj)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(obj, struct olemethoddata, &olemethod_datatype, pmethod);
- return pmethod;
-}
-
-static VALUE
-ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- BSTR bstr;
- FUNCDESC *pFuncDesc;
- WORD i;
- VALUE fname;
- VALUE method = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr");
- }
- for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
- if (FAILED(hr))
- continue;
-
- hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr)) {
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- continue;
- }
- fname = WC2VSTR(bstr);
- if (strcasecmp(StringValuePtr(name), StringValuePtr(fname)) == 0) {
- olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, i, fname);
- method = self;
- }
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- pFuncDesc=NULL;
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return method;
-}
-
-VALUE
-ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- WORD i;
- HREFTYPE href;
- ITypeInfo *pRefTypeInfo;
- VALUE methods = rb_ary_new();
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr");
- }
-
- ole_methods_sub(0, pTypeInfo, methods, mask);
- for(i=0; i < pTypeAttr->cImplTypes; i++){
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
- if(FAILED(hr))
- continue;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
- if (FAILED(hr))
- continue;
- ole_methods_sub(pTypeInfo, pRefTypeInfo, methods, mask);
- OLE_RELEASE(pRefTypeInfo);
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return methods;
-}
-
-static VALUE
-olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- WORD i;
- HREFTYPE href;
- ITypeInfo *pRefTypeInfo;
- VALUE method = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr");
- }
- method = ole_method_sub(self, 0, pTypeInfo, name);
- if (method != Qnil) {
- return method;
- }
- for(i=0; i < pTypeAttr->cImplTypes && method == Qnil; i++){
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
- if(FAILED(hr))
- continue;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
- if (FAILED(hr))
- continue;
- method = ole_method_sub(self, pTypeInfo, pRefTypeInfo, name);
- OLE_RELEASE(pRefTypeInfo);
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return method;
-}
-
-static VALUE
-ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- BSTR bstr;
- FUNCDESC *pFuncDesc;
- VALUE method;
- WORD i;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr");
- }
- for(i = 0; i < pTypeAttr->cFuncs; i++) {
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
- if (FAILED(hr))
- continue;
-
- hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr)) {
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- continue;
- }
- if(pFuncDesc->invkind & mask) {
- method = folemethod_s_allocate(cWIN32OLE_METHOD);
- olemethod_set_member(method, pTypeInfo, pOwnerTypeInfo,
- i, WC2VSTR(bstr));
- rb_ary_push(methods, method);
- }
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- pFuncDesc=NULL;
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
-
- return methods;
-}
-
-VALUE
-create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name)
-{
-
- VALUE method = folemethod_s_allocate(cWIN32OLE_METHOD);
- VALUE obj = olemethod_from_typeinfo(method, pTypeInfo, name);
- return obj;
-}
-
-/*
- * Document-class: WIN32OLE_METHOD
- *
- * <code>WIN32OLE_METHOD</code> objects represent OLE method information.
- */
-
-static VALUE
-olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- pmethod->pTypeInfo = pTypeInfo;
- OLE_ADDREF(pTypeInfo);
- pmethod->pOwnerTypeInfo = pOwnerTypeInfo;
- OLE_ADDREF(pOwnerTypeInfo);
- pmethod->index = index;
- rb_ivar_set(self, rb_intern("name"), name);
- return self;
-}
-
-VALUE
-folemethod_s_allocate(VALUE klass)
-{
- struct olemethoddata *pmethod;
- VALUE obj;
- obj = TypedData_Make_Struct(klass,
- struct olemethoddata,
- &olemethod_datatype, pmethod);
- pmethod->pTypeInfo = NULL;
- pmethod->pOwnerTypeInfo = NULL;
- pmethod->index = 0;
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD.new(ole_type, method) -> WIN32OLE_METHOD object
- *
- * Returns a new WIN32OLE_METHOD object which represents the information
- * about OLE method.
- * The first argument <i>ole_type</i> specifies WIN32OLE_TYPE object.
- * The second argument <i>method</i> specifies OLE method name defined OLE class
- * which represents WIN32OLE_TYPE object.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- */
-static VALUE
-folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
-{
- VALUE obj = Qnil;
- ITypeInfo *pTypeInfo;
- if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) {
- SafeStringValue(method);
- pTypeInfo = itypeinfo(oletype);
- obj = olemethod_from_typeinfo(self, pTypeInfo, method);
- if (obj == Qnil) {
- rb_raise(eWIN32OLERuntimeError, "not found %s",
- StringValuePtr(method));
- }
- }
- else {
- rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object");
- }
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#name
- *
- * Returns the name of the method.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * puts method.name # => SaveAs
- *
- */
-static VALUE
-folemethod_name(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("name"));
-}
-
-static VALUE
-ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE type;
-
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetFuncDesc");
-
- type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#return_type
- *
- * Returns string of return value type of method.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.return_type # => Workbook
- *
- */
-static VALUE
-folemethod_return_type(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_return_type(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE vvt;
-
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
-
- vvt = RB_INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return vvt;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#return_vtype
- *
- * Returns number of return value type of method.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.return_vtype # => 26
- *
- */
-static VALUE
-folemethod_return_vtype(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE type = rb_ary_new();
-
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return type;
-
- ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), type);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#return_type_detail
- *
- * Returns detail information of return value type of method.
- * The information is array.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]
- */
-static VALUE
-folemethod_return_type_detail(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_invkind(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");
- invkind = RB_INT2FIX(pFuncDesc->invkind);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return invkind;
-}
-
-static VALUE
-ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index)
-{
- VALUE type = rb_str_new2("UNKNOWN");
- VALUE invkind = ole_method_invkind(pTypeInfo, method_index);
- if((RB_FIX2INT(invkind) & INVOKE_PROPERTYGET) &&
- (RB_FIX2INT(invkind) & INVOKE_PROPERTYPUT) ) {
- type = rb_str_new2("PROPERTY");
- } else if(RB_FIX2INT(invkind) & INVOKE_PROPERTYGET) {
- type = rb_str_new2("PROPERTYGET");
- } else if(RB_FIX2INT(invkind) & INVOKE_PROPERTYPUT) {
- type = rb_str_new2("PROPERTYPUT");
- } else if(RB_FIX2INT(invkind) & INVOKE_PROPERTYPUTREF) {
- type = rb_str_new2("PROPERTYPUTREF");
- } else if(RB_FIX2INT(invkind) & INVOKE_FUNC) {
- type = rb_str_new2("FUNC");
- }
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#invkind
- *
- * Returns the method invoke kind.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.invkind # => 1
- *
- */
-static VALUE
-folemethod_invkind(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_invkind(pmethod->pTypeInfo, pmethod->index);
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#invoke_kind
- *
- * Returns the method kind string. The string is "UNKNOWN" or "PROPERTY"
- * or "PROPERTY" or "PROPERTYGET" or "PROPERTYPUT" or "PROPERTYPPUTREF"
- * or "FUNC".
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.invoke_kind # => "FUNC"
- */
-static VALUE
-folemethod_invoke_kind(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE visible;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if(FAILED(hr))
- return Qfalse;
- if (pFuncDesc->wFuncFlags & (FUNCFLAG_FRESTRICTED |
- FUNCFLAG_FHIDDEN |
- FUNCFLAG_FNONBROWSABLE)) {
- visible = Qfalse;
- } else {
- visible = Qtrue;
- }
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return visible;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#visible?
- *
- * Returns true if the method is public.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.visible? # => true
- */
-static VALUE
-folemethod_visible(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_visible(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name)
-{
- TYPEATTR *pTypeAttr;
- HRESULT hr;
- WORD i;
- int flags;
- HREFTYPE href;
- ITypeInfo *pRefTypeInfo;
- FUNCDESC *pFuncDesc;
- BSTR bstr;
- VALUE name;
- VALUE event = Qfalse;
-
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- return event;
- if(pTypeAttr->typekind != TKIND_COCLASS) {
- pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
- return event;
- }
- for (i = 0; i < pTypeAttr->cImplTypes; i++) {
- hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
- if (FAILED(hr))
- continue;
-
- if (flags & IMPLTYPEFLAG_FSOURCE) {
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
- i, &href);
- if (FAILED(hr))
- continue;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
- href, &pRefTypeInfo);
- if (FAILED(hr))
- continue;
- hr = pRefTypeInfo->lpVtbl->GetFuncDesc(pRefTypeInfo, method_index,
- &pFuncDesc);
- if (FAILED(hr)) {
- OLE_RELEASE(pRefTypeInfo);
- continue;
- }
-
- hr = pRefTypeInfo->lpVtbl->GetDocumentation(pRefTypeInfo,
- pFuncDesc->memid,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr)) {
- pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
- OLE_RELEASE(pRefTypeInfo);
- continue;
- }
-
- name = WC2VSTR(bstr);
- pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
- OLE_RELEASE(pRefTypeInfo);
- if (rb_str_cmp(method_name, name) == 0) {
- event = Qtrue;
- break;
- }
- }
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return event;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#event?
- *
- * Returns true if the method is event.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SheetActivate')
- * puts method.event? # => true
- *
- */
-static VALUE
-folemethod_event(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- if (!pmethod->pOwnerTypeInfo)
- return Qfalse;
- return ole_method_event(pmethod->pOwnerTypeInfo,
- pmethod->index,
- rb_ivar_get(self, rb_intern("name")));
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#event_interface
- *
- * Returns event interface name if the method is event.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SheetActivate')
- * puts method.event_interface # => WorkbookEvents
- */
-static VALUE
-folemethod_event_interface(VALUE self)
-{
- BSTR name;
- struct olemethoddata *pmethod;
- HRESULT hr;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- if(folemethod_event(self) == Qtrue) {
- hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL);
- if(SUCCEEDED(hr))
- return WC2VSTR(name);
- }
- return Qnil;
-}
-
-static HRESULT
-ole_method_docinfo_from_type(
- ITypeInfo *pTypeInfo,
- UINT method_index,
- BSTR *name,
- BSTR *helpstr,
- DWORD *helpcontext,
- BSTR *helpfile
- )
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return hr;
- hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
- name, helpstr,
- helpcontext, helpfile);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return hr;
-}
-
-static VALUE
-ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index)
-{
- HRESULT hr;
- BSTR bhelpstring;
- hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, &bhelpstring,
- NULL, NULL);
- if (FAILED(hr))
- return Qnil;
- return WC2VSTR(bhelpstring);
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#helpstring
- *
- * Returns help string of OLE method. If the help string is not found,
- * then the method returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
- * method = WIN32OLE_METHOD.new(tobj, 'Navigate')
- * puts method.helpstring # => Navigates to a URL or file.
- *
- */
-static VALUE
-folemethod_helpstring(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index)
-{
- HRESULT hr;
- BSTR bhelpfile;
- hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
- NULL, &bhelpfile);
- if (FAILED(hr))
- return Qnil;
- return WC2VSTR(bhelpfile);
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#helpfile
- *
- * Returns help file. If help file is not found, then
- * the method returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.helpfile # => C:\...\VBAXL9.CHM
- */
-static VALUE
-folemethod_helpfile(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
-
- return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index)
-{
- HRESULT hr;
- DWORD helpcontext = 0;
- hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
- &helpcontext, NULL);
- if (FAILED(hr))
- return Qnil;
- return RB_INT2FIX(helpcontext);
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#helpcontext
- *
- * Returns help context.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.helpcontext # => 65717
- */
-static VALUE
-folemethod_helpcontext(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE dispid = Qnil;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return dispid;
- dispid = RB_INT2NUM(pFuncDesc->memid);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return dispid;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#dispid
- *
- * Returns dispatch ID.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.dispid # => 181
- */
-static VALUE
-folemethod_dispid(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_dispid(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE offset_vtbl = Qnil;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return offset_vtbl;
- offset_vtbl = RB_INT2FIX(pFuncDesc->oVft);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return offset_vtbl;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#offset_vtbl
- *
- * Returns the offset ov VTBL.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
- * method = WIN32OLE_METHOD.new(tobj, 'Add')
- * puts method.offset_vtbl # => 40
- */
-static VALUE
-folemethod_offset_vtbl(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE size_params = Qnil;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return size_params;
- size_params = RB_INT2FIX(pFuncDesc->cParams);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return size_params;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#size_params
- *
- * Returns the size of arguments of the method.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * puts method.size_params # => 11
- *
- */
-static VALUE
-folemethod_size_params(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_size_params(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE size_opt_params = Qnil;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return size_opt_params;
- size_opt_params = RB_INT2FIX(pFuncDesc->cParamsOpt);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return size_opt_params;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#size_opt_params
- *
- * Returns the size of optional parameters.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * puts method.size_opt_params # => 4
- */
-static VALUE
-folemethod_size_opt_params(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index);
-}
-
-static VALUE
-ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- BSTR *bstrs;
- UINT len, i;
- VALUE param;
- VALUE params = rb_ary_new();
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return params;
-
- len = 0;
- bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
- bstrs, pFuncDesc->cParams + 1,
- &len);
- if (FAILED(hr)) {
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return params;
- }
- SysFreeString(bstrs[0]);
- if (pFuncDesc->cParams > 0) {
- for(i = 1; i < len; i++) {
- param = create_win32ole_param(pTypeInfo, method_index, i-1, WC2VSTR(bstrs[i]));
- rb_ary_push(params, param);
- }
- }
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return params;
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#params
- *
- * returns array of WIN32OLE_PARAM object corresponding with method parameters.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * p method.params # => [Filename, FileFormat, Password, WriteResPassword,
- * ReadOnlyRecommended, CreateBackup, AccessMode,
- * ConflictResolution, AddToMru, TextCodepage,
- * TextVisualLayout]
- */
-static VALUE
-folemethod_params(VALUE self)
-{
- struct olemethoddata *pmethod;
- TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
- return ole_method_params(pmethod->pTypeInfo, pmethod->index);
-}
-
-/*
- * call-seq:
- * WIN32OLE_METHOD#inspect -> String
- *
- * Returns the method name with class name.
- *
- */
-static VALUE
-folemethod_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_METHOD");
-}
-
-VALUE cWIN32OLE_METHOD;
-
-void Init_win32ole_method(void)
-{
- cWIN32OLE_METHOD = rb_define_class_under(cWIN32OLE, "Method", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_METHOD", cWIN32OLE_METHOD);
- rb_define_alloc_func(cWIN32OLE_METHOD, folemethod_s_allocate);
- rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2);
- rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0);
- rb_define_method(cWIN32OLE_METHOD, "return_type", folemethod_return_type, 0);
- rb_define_method(cWIN32OLE_METHOD, "return_vtype", folemethod_return_vtype, 0);
- rb_define_method(cWIN32OLE_METHOD, "return_type_detail", folemethod_return_type_detail, 0);
- rb_define_method(cWIN32OLE_METHOD, "invoke_kind", folemethod_invoke_kind, 0);
- rb_define_method(cWIN32OLE_METHOD, "invkind", folemethod_invkind, 0);
- rb_define_method(cWIN32OLE_METHOD, "visible?", folemethod_visible, 0);
- rb_define_method(cWIN32OLE_METHOD, "event?", folemethod_event, 0);
- rb_define_method(cWIN32OLE_METHOD, "event_interface", folemethod_event_interface, 0);
- rb_define_method(cWIN32OLE_METHOD, "helpstring", folemethod_helpstring, 0);
- rb_define_method(cWIN32OLE_METHOD, "helpfile", folemethod_helpfile, 0);
- rb_define_method(cWIN32OLE_METHOD, "helpcontext", folemethod_helpcontext, 0);
- rb_define_method(cWIN32OLE_METHOD, "dispid", folemethod_dispid, 0);
- rb_define_method(cWIN32OLE_METHOD, "offset_vtbl", folemethod_offset_vtbl, 0);
- rb_define_method(cWIN32OLE_METHOD, "size_params", folemethod_size_params, 0);
- rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0);
- rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0);
- rb_define_alias(cWIN32OLE_METHOD, "to_s", "name");
- rb_define_method(cWIN32OLE_METHOD, "inspect", folemethod_inspect, 0);
-}
diff --git a/ext/win32ole/win32ole_method.h b/ext/win32ole/win32ole_method.h
deleted file mode 100644
index ef907d2fac..0000000000
--- a/ext/win32ole/win32ole_method.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef WIN32OLE_METHOD_H
-#define WIN32OLE_METHOD_H 1
-
-struct olemethoddata {
- ITypeInfo *pOwnerTypeInfo;
- ITypeInfo *pTypeInfo;
- UINT index;
-};
-
-extern VALUE cWIN32OLE_METHOD;
-VALUE folemethod_s_allocate(VALUE klass);
-VALUE ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask);
-VALUE create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name);
-struct olemethoddata *olemethod_data_get_struct(VALUE obj);
-void Init_win32ole_method(void);
-#endif
diff --git a/ext/win32ole/win32ole_param.c b/ext/win32ole/win32ole_param.c
deleted file mode 100644
index b654aaa845..0000000000
--- a/ext/win32ole/win32ole_param.c
+++ /dev/null
@@ -1,439 +0,0 @@
-#include "win32ole.h"
-
-VALUE cWIN32OLE_PARAM;
-
-struct oleparamdata {
- ITypeInfo *pTypeInfo;
- UINT method_index;
- UINT index;
-};
-
-static void oleparam_free(void *ptr);
-static size_t oleparam_size(const void *ptr);
-static VALUE foleparam_s_allocate(VALUE klass);
-static VALUE oleparam_ole_param_from_index(VALUE self, ITypeInfo *pTypeInfo, UINT method_index, int param_index);
-static VALUE oleparam_ole_param(VALUE self, VALUE olemethod, int n);
-static VALUE foleparam_initialize(VALUE self, VALUE olemethod, VALUE n);
-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 const rb_data_type_t oleparam_datatype = {
- "win32ole_param",
- {NULL, oleparam_free, oleparam_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static void
-oleparam_free(void *ptr)
-{
- struct oleparamdata *pole = ptr;
- OLE_FREE(pole->pTypeInfo);
- free(pole);
-}
-
-static size_t
-oleparam_size(const void *ptr)
-{
- return ptr ? sizeof(struct oleparamdata) : 0;
-}
-
-VALUE
-create_win32ole_param(ITypeInfo *pTypeInfo, UINT method_index, UINT index, VALUE name)
-{
- struct oleparamdata *pparam;
- VALUE obj = foleparam_s_allocate(cWIN32OLE_PARAM);
- TypedData_Get_Struct(obj, struct oleparamdata, &oleparam_datatype, pparam);
-
- pparam->pTypeInfo = pTypeInfo;
- OLE_ADDREF(pTypeInfo);
- pparam->method_index = method_index;
- pparam->index = index;
- rb_ivar_set(obj, rb_intern("name"), name);
- return obj;
-}
-
-/*
- * Document-class: WIN32OLE_PARAM
- *
- * <code>WIN32OLE_PARAM</code> objects represent param information of
- * the OLE method.
- */
-static VALUE
-foleparam_s_allocate(VALUE klass)
-{
- struct oleparamdata *pparam;
- VALUE obj;
- obj = TypedData_Make_Struct(klass,
- struct oleparamdata,
- &oleparam_datatype, pparam);
- pparam->pTypeInfo = NULL;
- pparam->method_index = 0;
- pparam->index = 0;
- return obj;
-}
-
-static VALUE
-oleparam_ole_param_from_index(VALUE self, ITypeInfo *pTypeInfo, UINT method_index, int param_index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- BSTR *bstrs;
- UINT len;
- struct oleparamdata *pparam;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- ole_raise(hr, rb_eRuntimeError, "fail to ITypeInfo::GetFuncDesc");
-
- len = 0;
- bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
- bstrs, pFuncDesc->cParams + 1,
- &len);
- if (FAILED(hr)) {
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- ole_raise(hr, rb_eRuntimeError, "fail to ITypeInfo::GetNames");
- }
- SysFreeString(bstrs[0]);
- if (param_index < 1 || len <= (UINT)param_index)
- {
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- rb_raise(rb_eIndexError, "index of param must be in 1..%d", len);
- }
-
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- pparam->pTypeInfo = pTypeInfo;
- OLE_ADDREF(pTypeInfo);
- pparam->method_index = method_index;
- pparam->index = param_index - 1;
- rb_ivar_set(self, rb_intern("name"), WC2VSTR(bstrs[param_index]));
-
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return self;
-}
-
-static VALUE
-oleparam_ole_param(VALUE self, VALUE olemethod, int n)
-{
- struct olemethoddata *pmethod = olemethod_data_get_struct(olemethod);
- return oleparam_ole_param_from_index(self, pmethod->pTypeInfo, pmethod->index, n);
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM.new(method, n) -> WIN32OLE_PARAM object
- *
- * Returns WIN32OLE_PARAM object which represents OLE parameter information.
- * 1st argument should be WIN32OLE_METHOD object.
- * 2nd argument `n' is n-th parameter of the method specified by 1st argument.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem')
- * method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile')
- * param = WIN32OLE_PARAM.new(method, 2) # => #<WIN32OLE_PARAM:Overwrite=true>
- *
- */
-static VALUE
-foleparam_initialize(VALUE self, VALUE olemethod, VALUE n)
-{
- int idx;
- if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) {
- rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE_METHOD object");
- }
- idx = RB_FIX2INT(n);
- return oleparam_ole_param(self, olemethod, idx);
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#name
- *
- * Returns name.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * param1 = method.params[0]
- * puts param1.name # => Filename
- */
-static VALUE
-foleparam_name(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("name"));
-}
-
-static VALUE
-ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE type = rb_str_new2("unknown type");
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return type;
- type = ole_typedesc2val(pTypeInfo,
- &(pFuncDesc->lprgelemdescParam[index].tdesc), Qnil);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#ole_type
- *
- * Returns OLE type of WIN32OLE_PARAM object(parameter of OLE method).
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * param1 = method.params[0]
- * puts param1.ole_type # => VARIANT
- */
-static VALUE
-foleparam_ole_type(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index,
- pparam->index);
-}
-
-static VALUE
-ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE typedetail = rb_ary_new();
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return typedetail;
- ole_typedesc2val(pTypeInfo,
- &(pFuncDesc->lprgelemdescParam[index].tdesc), typedetail);
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return typedetail;
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#ole_type_detail
- *
- * Returns detail information of type of argument.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction')
- * method = WIN32OLE_METHOD.new(tobj, 'SumIf')
- * param1 = method.params[0]
- * p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"]
- */
-static VALUE
-foleparam_ole_type_detail(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index,
- pparam->index);
-}
-
-static VALUE
-ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT mask)
-{
- FUNCDESC *pFuncDesc;
- HRESULT hr;
- VALUE ret = Qfalse;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if(FAILED(hr))
- return ret;
- if (V_UNION1((&(pFuncDesc->lprgelemdescParam[index])), paramdesc).wParamFlags &mask)
- ret = Qtrue;
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return ret;
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#input?
- *
- * Returns true if the parameter is input.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * param1 = method.params[0]
- * puts param1.input? # => true
- */
-static VALUE
-foleparam_input(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
- pparam->index, PARAMFLAG_FIN);
-}
-
-/*
- * call-seq:
- * WIN32OLE#output?
- *
- * Returns true if argument is output.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'DWebBrowserEvents')
- * method = WIN32OLE_METHOD.new(tobj, 'NewWindow')
- * method.params.each do |param|
- * puts "#{param.name} #{param.output?}"
- * end
- *
- * The result of above script is following:
- * URL false
- * Flags false
- * TargetFrameName false
- * PostData false
- * Headers false
- * Processed true
- */
-static VALUE
-foleparam_output(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
- pparam->index, PARAMFLAG_FOUT);
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#optional?
- *
- * Returns true if argument is optional.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * param1 = method.params[0]
- * puts "#{param1.name} #{param1.optional?}" # => Filename true
- */
-static VALUE
-foleparam_optional(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
- pparam->index, PARAMFLAG_FOPT);
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#retval?
- *
- * Returns true if argument is return value.
- * tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library',
- * 'DirectPlayLobbyConnection')
- * method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName')
- * param = method.params[0]
- * puts "#{param.name} #{param.retval?}" # => name true
- */
-static VALUE
-foleparam_retval(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
- pparam->index, PARAMFLAG_FRETVAL);
-}
-
-static VALUE
-ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
-{
- FUNCDESC *pFuncDesc;
- ELEMDESC *pElemDesc;
- PARAMDESCEX * pParamDescEx;
- HRESULT hr;
- USHORT wParamFlags;
- USHORT mask = PARAMFLAG_FOPT|PARAMFLAG_FHASDEFAULT;
- VALUE defval = Qnil;
- hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
- if (FAILED(hr))
- return defval;
- pElemDesc = &pFuncDesc->lprgelemdescParam[index];
- wParamFlags = V_UNION1(pElemDesc, paramdesc).wParamFlags;
- if ((wParamFlags & mask) == mask) {
- pParamDescEx = V_UNION1(pElemDesc, paramdesc).pparamdescex;
- defval = ole_variant2val(&pParamDescEx->varDefaultValue);
- }
- pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return defval;
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#default
- *
- * Returns default value. If the default value does not exist,
- * this method returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
- * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
- * method.params.each do |param|
- * if param.default
- * puts "#{param.name} (= #{param.default})"
- * else
- * puts "#{param}"
- * end
- * end
- *
- * The above script result is following:
- * Filename
- * FileFormat
- * Password
- * WriteResPassword
- * ReadOnlyRecommended
- * CreateBackup
- * AccessMode (= 1)
- * ConflictResolution
- * AddToMru
- * TextCodepage
- * TextVisualLayout
- */
-static VALUE
-foleparam_default(VALUE self)
-{
- struct oleparamdata *pparam;
- TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
- return ole_param_default(pparam->pTypeInfo, pparam->method_index,
- pparam->index);
-}
-
-/*
- * call-seq:
- * WIN32OLE_PARAM#inspect -> String
- *
- * Returns the parameter name with class name. If the parameter has default value,
- * then returns name=value string with class name.
- *
- */
-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_inspect(defval));
- }
- return make_inspect("WIN32OLE_PARAM", detail);
-}
-
-void
-Init_win32ole_param(void)
-{
- cWIN32OLE_PARAM = rb_define_class_under(cWIN32OLE, "Param", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_PARAM", cWIN32OLE_PARAM);
- rb_define_alloc_func(cWIN32OLE_PARAM, foleparam_s_allocate);
- rb_define_method(cWIN32OLE_PARAM, "initialize", foleparam_initialize, 2);
- rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0);
- rb_define_method(cWIN32OLE_PARAM, "ole_type", foleparam_ole_type, 0);
- rb_define_method(cWIN32OLE_PARAM, "ole_type_detail", foleparam_ole_type_detail, 0);
- rb_define_method(cWIN32OLE_PARAM, "input?", foleparam_input, 0);
- rb_define_method(cWIN32OLE_PARAM, "output?", foleparam_output, 0);
- rb_define_method(cWIN32OLE_PARAM, "optional?", foleparam_optional, 0);
- rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0);
- rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0);
- rb_define_alias(cWIN32OLE_PARAM, "to_s", "name");
- rb_define_method(cWIN32OLE_PARAM, "inspect", foleparam_inspect, 0);
-}
diff --git a/ext/win32ole/win32ole_param.h b/ext/win32ole/win32ole_param.h
deleted file mode 100644
index 7e2650cb44..0000000000
--- a/ext/win32ole/win32ole_param.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef WIN32OLE_PARAM_H
-#define WIN32OLE_PARAM_H
-
-VALUE create_win32ole_param(ITypeInfo *pTypeInfo, UINT method_index, UINT index, VALUE name);
-void Init_win32ole_param(void);
-
-#endif
-
diff --git a/ext/win32ole/win32ole_record.c b/ext/win32ole/win32ole_record.c
deleted file mode 100644
index 9e18653db9..0000000000
--- a/ext/win32ole/win32ole_record.c
+++ /dev/null
@@ -1,607 +0,0 @@
-#include "win32ole.h"
-
-struct olerecorddata {
- IRecordInfo *pri;
- void *pdata;
-};
-
-static HRESULT recordinfo_from_itypelib(ITypeLib *pTypeLib, VALUE name, IRecordInfo **ppri);
-static int hash2olerec(VALUE key, VALUE val, VALUE rec);
-static void olerecord_free(void *pvar);
-static size_t olerecord_size(const void *ptr);
-static VALUE folerecord_s_allocate(VALUE klass);
-static VALUE folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj);
-static VALUE folerecord_to_h(VALUE self);
-static VALUE folerecord_typename(VALUE self);
-static VALUE olerecord_ivar_get(VALUE self, VALUE name);
-static VALUE olerecord_ivar_set(VALUE self, VALUE name, VALUE val);
-static VALUE folerecord_method_missing(int argc, VALUE *argv, VALUE self);
-static VALUE folerecord_ole_instance_variable_get(VALUE self, VALUE name);
-static VALUE folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val);
-static VALUE folerecord_inspect(VALUE self);
-
-static const rb_data_type_t olerecord_datatype = {
- "win32ole_record",
- {NULL, olerecord_free, olerecord_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static HRESULT
-recordinfo_from_itypelib(ITypeLib *pTypeLib, VALUE name, IRecordInfo **ppri)
-{
-
- unsigned int count;
- unsigned int i;
- ITypeInfo *pTypeInfo;
- HRESULT hr = OLE_E_LAST;
- BSTR bstr;
-
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (i = 0; i < count; i++) {
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr))
- continue;
-
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
- if (FAILED(hr))
- continue;
-
- if (rb_str_cmp(WC2VSTR(bstr), name) == 0) {
- hr = GetRecordInfoFromTypeInfo(pTypeInfo, ppri);
- OLE_RELEASE(pTypeInfo);
- return hr;
- }
- OLE_RELEASE(pTypeInfo);
- }
- hr = OLE_E_LAST;
- return hr;
-}
-
-static int
-hash2olerec(VALUE key, VALUE val, VALUE rec)
-{
- VARIANT var;
- OLECHAR *pbuf;
- struct olerecorddata *prec;
- IRecordInfo *pri;
- HRESULT hr;
-
- if (val != Qnil) {
- TypedData_Get_Struct(rec, struct olerecorddata, &olerecord_datatype, prec);
- pri = prec->pri;
- VariantInit(&var);
- ole_val2variant(val, &var);
- pbuf = ole_vstr2wc(key);
- hr = pri->lpVtbl->PutField(pri, INVOKE_PROPERTYPUT, prec->pdata, pbuf, &var);
- SysFreeString(pbuf);
- VariantClear(&var);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to putfield of `%s`", StringValuePtr(key));
- }
- }
- return ST_CONTINUE;
-}
-
-void
-ole_rec2variant(VALUE rec, VARIANT *var)
-{
- struct olerecorddata *prec;
- ULONG size = 0;
- IRecordInfo *pri;
- HRESULT hr;
- VALUE fields;
- TypedData_Get_Struct(rec, struct olerecorddata, &olerecord_datatype, prec);
- pri = prec->pri;
- if (pri) {
- hr = pri->lpVtbl->GetSize(pri, &size);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get size for allocation of VT_RECORD object");
- }
- if (prec->pdata) {
- free(prec->pdata);
- }
- prec->pdata = ALLOC_N(char, size);
- if (!prec->pdata) {
- rb_raise(rb_eRuntimeError, "failed to memory allocation of %lu bytes", (unsigned long)size);
- }
- hr = pri->lpVtbl->RecordInit(pri, prec->pdata);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to initialize VT_RECORD object");
- }
- fields = folerecord_to_h(rec);
- rb_hash_foreach(fields, hash2olerec, rec);
- V_RECORDINFO(var) = pri;
- V_RECORD(var) = prec->pdata;
- V_VT(var) = VT_RECORD;
- } else {
- rb_raise(eWIN32OLERuntimeError, "failed to retrieve IRecordInfo interface");
- }
-}
-
-void
-olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec)
-{
- HRESULT hr;
- BSTR bstr;
- BSTR *bstrs;
- ULONG count = 0;
- ULONG i;
- VALUE fields;
- VALUE val;
- VARIANT var;
- void *pdata = NULL;
- struct olerecorddata *pvar;
-
- TypedData_Get_Struct(obj, struct olerecorddata, &olerecord_datatype, pvar);
- OLE_ADDREF(pri);
- OLE_RELEASE(pvar->pri);
- pvar->pri = pri;
-
- hr = pri->lpVtbl->GetName(pri, &bstr);
- if (SUCCEEDED(hr)) {
- rb_ivar_set(obj, rb_intern("typename"), WC2VSTR(bstr));
- }
-
- hr = pri->lpVtbl->GetFieldNames(pri, &count, NULL);
- if (FAILED(hr) || count == 0)
- return;
- bstrs = ALLOCA_N(BSTR, count);
- hr = pri->lpVtbl->GetFieldNames(pri, &count, bstrs);
- if (FAILED(hr)) {
- return;
- }
-
- fields = rb_hash_new();
- rb_ivar_set(obj, rb_intern("fields"), fields);
- for (i = 0; i < count; i++) {
- pdata = NULL;
- VariantInit(&var);
- val = Qnil;
- if (prec) {
- hr = pri->lpVtbl->GetFieldNoCopy(pri, prec, bstrs[i], &var, &pdata);
- if (SUCCEEDED(hr)) {
- val = ole_variant2val(&var);
- }
- }
- rb_hash_aset(fields, WC2VSTR(bstrs[i]), val);
- }
-}
-
-VALUE
-create_win32ole_record(IRecordInfo *pri, void *prec)
-{
- VALUE obj = folerecord_s_allocate(cWIN32OLE_RECORD);
- olerecord_set_ivar(obj, pri, prec);
- return obj;
-}
-
-/*
- * Document-class: WIN32OLE_RECORD
- *
- * <code>WIN32OLE_RECORD</code> objects represents VT_RECORD OLE variant.
- * Win32OLE returns WIN32OLE_RECORD object if the result value of invoking
- * OLE methods.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure Book
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Structure
- * Public Function getBook() As Book
- * Dim book As New Book
- * book.title = "The Ruby Book"
- * book.cost = 20
- * Return book
- * End Function
- * End Class
- *
- * then, you can retrieve getBook return value from the following
- * Ruby script:
- *
- * require 'win32ole'
- * obj = WIN32OLE.new('ComServer.ComClass')
- * book = obj.getBook
- * book.class # => WIN32OLE_RECORD
- * book.title # => "The Ruby Book"
- * book.cost # => 20
- *
- */
-
-static void
-olerecord_free(void *ptr) {
- struct olerecorddata *pvar = ptr;
- OLE_FREE(pvar->pri);
- if (pvar->pdata) {
- free(pvar->pdata);
- }
- free(pvar);
-}
-
-static size_t
-olerecord_size(const void *ptr)
-{
- const struct olerecorddata *pvar = ptr;
- size_t s = 0;
- ULONG size = 0;
- HRESULT hr;
- if (ptr) {
- s += sizeof(struct olerecorddata);
- if (pvar->pri) {
- hr = pvar->pri->lpVtbl->GetSize(pvar->pri, &size);
- if (SUCCEEDED(hr)) {
- s += size;
- }
- }
- }
- return s;
-}
-
-static VALUE
-folerecord_s_allocate(VALUE klass) {
- VALUE obj = Qnil;
- struct olerecorddata *pvar;
- obj = TypedData_Make_Struct(klass, struct olerecorddata, &olerecord_datatype, pvar);
- pvar->pri = NULL;
- pvar->pdata = NULL;
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD.new(typename, obj) -> WIN32OLE_RECORD object
- *
- * Returns WIN32OLE_RECORD object. The first argument is struct name (String
- * or Symbol).
- * The second parameter obj should be WIN32OLE object or WIN32OLE_TYPELIB object.
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure Book
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Structure
- * End Class
- *
- * then, you can create WIN32OLE_RECORD object is as following:
- *
- * require 'win32ole'
- * obj = WIN32OLE.new('ComServer.ComClass')
- * book1 = WIN32OLE_RECORD.new('Book', obj) # => WIN32OLE_RECORD object
- * tlib = obj.ole_typelib
- * book2 = WIN32OLE_RECORD.new('Book', tlib) # => WIN32OLE_RECORD object
- *
- */
-static VALUE
-folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj) {
- HRESULT hr;
- ITypeLib *pTypeLib = NULL;
- IRecordInfo *pri = NULL;
-
- if (!RB_TYPE_P(typename, T_STRING) && !RB_TYPE_P(typename, T_SYMBOL)) {
- rb_raise(rb_eArgError, "1st argument should be String or Symbol");
- }
- if (RB_TYPE_P(typename, T_SYMBOL)) {
- typename = rb_sym2str(typename);
- }
-
- hr = S_OK;
- if(rb_obj_is_kind_of(oleobj, cWIN32OLE)) {
- hr = typelib_from_val(oleobj, &pTypeLib);
- } else if (rb_obj_is_kind_of(oleobj, cWIN32OLE_TYPELIB)) {
- pTypeLib = itypelib(oleobj);
- OLE_ADDREF(pTypeLib);
- if (pTypeLib) {
- hr = S_OK;
- } else {
- hr = E_FAIL;
- }
- } else {
- rb_raise(rb_eArgError, "2nd argument should be WIN32OLE object or WIN32OLE_TYPELIB object");
- }
-
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to query ITypeLib interface");
- }
-
- hr = recordinfo_from_itypelib(pTypeLib, typename, &pri);
- OLE_RELEASE(pTypeLib);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to query IRecordInfo interface for `%s'", StringValuePtr(typename));
- }
-
- olerecord_set_ivar(self, pri, NULL);
-
- return self;
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#to_h #=> Ruby Hash object.
- *
- * Returns Ruby Hash object which represents VT_RECORD variable.
- * The keys of Hash object are member names of VT_RECORD OLE variable and
- * the values of Hash object are values of VT_RECORD OLE variable.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure Book
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Structure
- * Public Function getBook() As Book
- * Dim book As New Book
- * book.title = "The Ruby Book"
- * book.cost = 20
- * Return book
- * End Function
- * End Class
- *
- * then, the result of WIN32OLE_RECORD#to_h is the following:
- *
- * require 'win32ole'
- * obj = WIN32OLE.new('ComServer.ComClass')
- * book = obj.getBook
- * book.to_h # => {"title"=>"The Ruby Book", "cost"=>20}
- *
- */
-static VALUE
-folerecord_to_h(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("fields"));
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#typename #=> String object
- *
- * Returns the type name of VT_RECORD OLE variable.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure Book
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Structure
- * Public Function getBook() As Book
- * Dim book As New Book
- * book.title = "The Ruby Book"
- * book.cost = 20
- * Return book
- * End Function
- * End Class
- *
- * then, the result of WIN32OLE_RECORD#typename is the following:
- *
- * require 'win32ole'
- * obj = WIN32OLE.new('ComServer.ComClass')
- * book = obj.getBook
- * book.typename # => "Book"
- *
- */
-static VALUE
-folerecord_typename(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("typename"));
-}
-
-static VALUE
-olerecord_ivar_get(VALUE self, VALUE name)
-{
- VALUE fields;
- fields = rb_ivar_get(self, rb_intern("fields"));
- return rb_hash_fetch(fields, name);
-}
-
-static VALUE
-olerecord_ivar_set(VALUE self, VALUE name, VALUE val)
-{
- long len;
- char *p;
- VALUE fields;
- len = RSTRING_LEN(name);
- p = RSTRING_PTR(name);
- if (p[len-1] == '=') {
- name = rb_str_subseq(name, 0, len-1);
- }
- fields = rb_ivar_get(self, rb_intern("fields"));
- rb_hash_fetch(fields, name);
- return rb_hash_aset(fields, name, val);
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#method_missing(name)
- *
- * Returns value specified by the member name of VT_RECORD OLE variable.
- * Or sets value specified by the member name of VT_RECORD OLE variable.
- * If the member name is not correct, KeyError exception is raised.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure Book
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Structure
- * End Class
- *
- * Then getting/setting value from Ruby is as the following:
- *
- * obj = WIN32OLE.new('ComServer.ComClass')
- * book = WIN32OLE_RECORD.new('Book', obj)
- * book.title # => nil ( book.method_missing(:title) is invoked. )
- * book.title = "Ruby" # ( book.method_missing(:title=, "Ruby") is invoked. )
- */
-static VALUE
-folerecord_method_missing(int argc, VALUE *argv, VALUE self)
-{
- VALUE name;
- rb_check_arity(argc, 1, 2);
- name = rb_sym2str(argv[0]);
-
-#if SIZEOF_SIZE_T > SIZEOF_LONG
- {
- size_t n = strlen(StringValueCStr(name));
- if (n >= LONG_MAX) {
- rb_raise(rb_eRuntimeError, "too long member name");
- }
- }
-#endif
-
- if (argc == 1) {
- return olerecord_ivar_get(self, name);
- } else if (argc == 2) {
- return olerecord_ivar_set(self, name, argv[1]);
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#ole_instance_variable_get(name)
- *
- * Returns value specified by the member name of VT_RECORD OLE object.
- * If the member name is not correct, KeyError exception is raised.
- * If you can't access member variable of VT_RECORD OLE object directly,
- * use this method.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * Public Structure ComObject
- * Public object_id As Ineger
- * End Structure
- * End Class
- *
- * and Ruby Object class has title attribute:
- *
- * then accessing object_id of ComObject from Ruby is as the following:
- *
- * srver = WIN32OLE.new('ComServer.ComClass')
- * obj = WIN32OLE_RECORD.new('ComObject', server)
- * # obj.object_id returns Ruby Object#object_id
- * obj.ole_instance_variable_get(:object_id) # => nil
- *
- */
-static VALUE
-folerecord_ole_instance_variable_get(VALUE self, VALUE name)
-{
- VALUE sname;
- if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- sname = name;
- if (RB_TYPE_P(name, T_SYMBOL)) {
- sname = rb_sym2str(name);
- }
- return olerecord_ivar_get(self, sname);
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#ole_instance_variable_set(name, val)
- *
- * Sets value specified by the member name of VT_RECORD OLE object.
- * If the member name is not correct, KeyError exception is raised.
- * If you can't set value of member of VT_RECORD OLE object directly,
- * use this method.
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Class
- *
- * then setting value of the `title' member is as following:
- *
- * srver = WIN32OLE.new('ComServer.ComClass')
- * obj = WIN32OLE_RECORD.new('Book', server)
- * obj.ole_instance_variable_set(:title, "The Ruby Book")
- *
- */
-static VALUE
-folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val)
-{
- VALUE sname;
- if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- sname = name;
- if (RB_TYPE_P(name, T_SYMBOL)) {
- sname = rb_sym2str(name);
- }
- return olerecord_ivar_set(self, sname, val);
-}
-
-/*
- * call-seq:
- * WIN32OLE_RECORD#inspect -> String
- *
- * Returns the OLE struct name and member name and the value of member
- *
- * If COM server in VB.NET ComServer project is the following:
- *
- * Imports System.Runtime.InteropServices
- * Public Class ComClass
- * <MarshalAs(UnmanagedType.BStr)> _
- * Public title As String
- * Public cost As Integer
- * End Class
- *
- * then
- *
- * srver = WIN32OLE.new('ComServer.ComClass')
- * obj = WIN32OLE_RECORD.new('Book', server)
- * obj.inspect # => <WIN32OLE_RECORD(ComClass) {"title" => nil, "cost" => nil}>
- *
- */
-static VALUE
-folerecord_inspect(VALUE self)
-{
- VALUE tname;
- VALUE field;
- tname = folerecord_typename(self);
- if (tname == Qnil) {
- tname = rb_inspect(tname);
- }
- field = rb_inspect(folerecord_to_h(self));
- return rb_sprintf("#<WIN32OLE_RECORD(%"PRIsVALUE") %"PRIsVALUE">",
- tname,
- field);
-}
-
-VALUE cWIN32OLE_RECORD;
-
-void
-Init_win32ole_record(void)
-{
- cWIN32OLE_RECORD = rb_define_class_under(cWIN32OLE, "Record", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_RECORD", cWIN32OLE_RECORD);
- rb_define_alloc_func(cWIN32OLE_RECORD, folerecord_s_allocate);
- rb_define_method(cWIN32OLE_RECORD, "initialize", folerecord_initialize, 2);
- rb_define_method(cWIN32OLE_RECORD, "to_h", folerecord_to_h, 0);
- rb_define_method(cWIN32OLE_RECORD, "typename", folerecord_typename, 0);
- rb_define_method(cWIN32OLE_RECORD, "method_missing", folerecord_method_missing, -1);
- rb_define_method(cWIN32OLE_RECORD, "ole_instance_variable_get", folerecord_ole_instance_variable_get, 1);
- rb_define_method(cWIN32OLE_RECORD, "ole_instance_variable_set", folerecord_ole_instance_variable_set, 2);
- rb_define_method(cWIN32OLE_RECORD, "inspect", folerecord_inspect, 0);
-}
diff --git a/ext/win32ole/win32ole_record.h b/ext/win32ole/win32ole_record.h
deleted file mode 100644
index ab1df0ee7f..0000000000
--- a/ext/win32ole/win32ole_record.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef WIN32OLE_RECORD_H
-#define WIN32OLE_RECORD_H 1
-
-extern VALUE cWIN32OLE_RECORD;
-void ole_rec2variant(VALUE rec, VARIANT *var);
-void olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec);
-VALUE create_win32ole_record(IRecordInfo *pri, void *prec);
-void Init_win32ole_record(void);
-
-#endif
diff --git a/ext/win32ole/win32ole_type.c b/ext/win32ole/win32ole_type.c
deleted file mode 100644
index 1b96aea858..0000000000
--- a/ext/win32ole/win32ole_type.c
+++ /dev/null
@@ -1,918 +0,0 @@
-#include "win32ole.h"
-
-struct oletypedata {
- ITypeInfo *pTypeInfo;
-};
-
-static void oletype_free(void *ptr);
-static size_t oletype_size(const void *ptr);
-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 oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
-static VALUE foletype_s_allocate(VALUE klass);
-static VALUE oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass);
-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 ole_variables(ITypeInfo *pTypeInfo);
-static VALUE foletype_variables(VALUE self);
-static VALUE foletype_methods(VALUE self);
-static VALUE foletype_ole_typelib(VALUE self);
-static VALUE ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags);
-static VALUE foletype_impl_ole_types(VALUE self);
-static VALUE foletype_source_ole_types(VALUE self);
-static VALUE foletype_default_event_sources(VALUE self);
-static VALUE foletype_default_ole_types(VALUE self);
-static VALUE foletype_inspect(VALUE self);
-
-static const rb_data_type_t oletype_datatype = {
- "win32ole_type",
- {NULL, oletype_free, oletype_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-/*
- * Document-class: WIN32OLE_TYPE
- *
- * <code>WIN32OLE_TYPE</code> objects represent OLE type library information.
- */
-
-static void
-oletype_free(void *ptr)
-{
- struct oletypedata *poletype = ptr;
- OLE_FREE(poletype->pTypeInfo);
- free(poletype);
-}
-
-static size_t
-oletype_size(const void *ptr)
-{
- return ptr ? sizeof(struct oletypedata) : 0;
-}
-
-ITypeInfo *itypeinfo(VALUE self)
-{
- struct oletypedata *ptype;
- TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype);
- return ptype->pTypeInfo;
-}
-
-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 = create_win32ole_type(pTypeInfo, WC2VSTR(bstr));
- return type;
-}
-
-
-/*
- * call-seq:
- * 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)
-{
- VALUE obj;
-
- /*
- 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);
-}
-
-/*
- * call-seq:
- * 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)
-{
- /*
- 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}");
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE.progids
- *
- * Returns array of ProgID.
- */
-static VALUE
-foletype_s_progids(VALUE self)
-{
- HKEY hclsids, hclsid;
- DWORD i;
- LONG err;
- VALUE clsid;
- VALUE v = rb_str_new2("");
- VALUE progids = rb_ary_new();
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids);
- if(err != ERROR_SUCCESS) {
- return progids;
- }
- for(i = 0; ; i++) {
- clsid = reg_enum_key(hclsids, i);
- if (clsid == Qnil)
- break;
- err = reg_open_vkey(hclsids, clsid, &hclsid);
- if (err != ERROR_SUCCESS)
- continue;
- if ((v = reg_get_val2(hclsid, "ProgID")) != Qnil)
- rb_ary_push(progids, v);
- if ((v = reg_get_val2(hclsid, "VersionIndependentProgID")) != Qnil)
- rb_ary_push(progids, v);
- RegCloseKey(hclsid);
- }
- RegCloseKey(hclsids);
- return progids;
-}
-
-static VALUE
-oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
-{
- struct oletypedata *ptype;
- TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype);
- rb_ivar_set(self, rb_intern("name"), name);
- ptype->pTypeInfo = pTypeInfo;
- OLE_ADDREF(pTypeInfo);
- return self;
-}
-
-static VALUE
-foletype_s_allocate(VALUE klass)
-{
- struct oletypedata *poletype;
- VALUE obj;
- ole_initialize();
- obj = TypedData_Make_Struct(klass,struct oletypedata, &oletype_datatype, poletype);
- poletype->pTypeInfo = NULL;
- return obj;
-}
-
-VALUE
-create_win32ole_type(ITypeInfo *pTypeInfo, VALUE name)
-{
- VALUE obj = foletype_s_allocate(cWIN32OLE_TYPE);
- oletype_set_member(obj, pTypeInfo, name);
- return obj;
-}
-
-static VALUE
-oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass)
-{
-
- long count;
- int i;
- HRESULT hr;
- BSTR bstr;
- VALUE typelib;
- ITypeInfo *pTypeInfo;
-
- VALUE found = Qfalse;
-
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (i = 0; i < count && found == Qfalse; i++) {
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
- if (FAILED(hr))
- continue;
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr))
- continue;
- typelib = WC2VSTR(bstr);
- if (rb_str_cmp(oleclass, typelib) == 0) {
- oletype_set_member(self, pTypeInfo, typelib);
- found = Qtrue;
- }
- OLE_RELEASE(pTypeInfo);
- }
- return found;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE.new(typelib, ole_class) -> WIN32OLE_TYPE object
- *
- * Returns a new WIN32OLE_TYPE object.
- * The first argument <i>typelib</i> specifies OLE type library name.
- * The second argument specifies OLE class name.
- *
- * WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * # => WIN32OLE_TYPE object of Application class of Excel.
- */
-static VALUE
-foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
-{
- VALUE file;
- OLECHAR * pbuf;
- ITypeLib *pTypeLib;
- HRESULT hr;
-
- SafeStringValue(oleclass);
- SafeStringValue(typelib);
- file = typelib_file(typelib);
- if (file == Qnil) {
- file = typelib;
- }
- pbuf = ole_vstr2wc(file);
- hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
- SysFreeString(pbuf);
- if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
- OLE_RELEASE(pTypeLib);
- rb_raise(eWIN32OLERuntimeError, "not found `%s` in `%s`",
- StringValuePtr(oleclass), StringValuePtr(typelib));
- }
- OLE_RELEASE(pTypeLib);
- return self;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#name #=> OLE type name
- *
- * Returns OLE type name.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * puts tobj.name # => Application
- */
-static VALUE
-foletype_name(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("name"));
-}
-
-static VALUE
-ole_ole_type(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- VALUE type = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if(FAILED(hr)){
- return type;
- }
- switch(pTypeAttr->typekind) {
- case TKIND_ENUM:
- type = rb_str_new2("Enum");
- break;
- case TKIND_RECORD:
- type = rb_str_new2("Record");
- break;
- case TKIND_MODULE:
- type = rb_str_new2("Module");
- break;
- case TKIND_INTERFACE:
- type = rb_str_new2("Interface");
- break;
- case TKIND_DISPATCH:
- type = rb_str_new2("Dispatch");
- break;
- case TKIND_COCLASS:
- type = rb_str_new2("Class");
- break;
- case TKIND_ALIAS:
- type = rb_str_new2("Alias");
- break;
- case TKIND_UNION:
- type = rb_str_new2("Union");
- break;
- case TKIND_MAX:
- type = rb_str_new2("Max");
- break;
- default:
- type = Qnil;
- break;
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#ole_type #=> OLE type string.
- *
- * returns type of OLE class.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * puts tobj.ole_type # => Class
- */
-static VALUE
-foletype_ole_type(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_ole_type(pTypeInfo);
-}
-
-static VALUE
-ole_type_guid(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- int len;
- OLECHAR bstr[80];
- VALUE guid = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- return guid;
- len = StringFromGUID2(&pTypeAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
- if (len > 3) {
- guid = ole_wc2vstr(bstr, FALSE);
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return guid;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#guid #=> GUID
- *
- * Returns GUID.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * puts tobj.guid # => {00024500-0000-0000-C000-000000000046}
- */
-static VALUE
-foletype_guid(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_guid(pTypeInfo);
-}
-
-static VALUE
-ole_type_progid(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- OLECHAR *pbuf;
- VALUE progid = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- return progid;
- hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
- if (SUCCEEDED(hr)) {
- progid = ole_wc2vstr(pbuf, FALSE);
- CoTaskMemFree(pbuf);
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return progid;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#progid #=> ProgID
- *
- * Returns ProgID if it exists. If not found, then returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * puts tobj.progid # => Excel.Application.9
- */
-static VALUE
-foletype_progid(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_progid(pTypeInfo);
-}
-
-
-static VALUE
-ole_type_visible(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- VALUE visible;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- return Qtrue;
- if (pTypeAttr->wTypeFlags & (TYPEFLAG_FHIDDEN | TYPEFLAG_FRESTRICTED)) {
- visible = Qfalse;
- } else {
- visible = Qtrue;
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return visible;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#visible? #=> true or false
- *
- * Returns true if the OLE class is public.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
- * puts tobj.visible # => true
- */
-static VALUE
-foletype_visible(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_visible(pTypeInfo);
-}
-
-static VALUE
-ole_type_major_version(ITypeInfo *pTypeInfo)
-{
- VALUE ver;
- TYPEATTR *pTypeAttr;
- HRESULT hr;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
- ver = RB_INT2FIX(pTypeAttr->wMajorVerNum);
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return ver;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#major_version
- *
- * Returns major version.
- * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
- * puts tobj.major_version # => 8
- */
-static VALUE
-foletype_major_version(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_major_version(pTypeInfo);
-}
-
-static VALUE
-ole_type_minor_version(ITypeInfo *pTypeInfo)
-{
- VALUE ver;
- TYPEATTR *pTypeAttr;
- HRESULT hr;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
- ver = RB_INT2FIX(pTypeAttr->wMinorVerNum);
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return ver;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#minor_version #=> OLE minor version
- *
- * Returns minor version.
- * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
- * puts tobj.minor_version # => 2
- */
-static VALUE
-foletype_minor_version(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_minor_version(pTypeInfo);
-}
-
-static VALUE
-ole_type_typekind(ITypeInfo *pTypeInfo)
-{
- VALUE typekind;
- TYPEATTR *pTypeAttr;
- HRESULT hr;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
- typekind = RB_INT2FIX(pTypeAttr->typekind);
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return typekind;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#typekind #=> number of type.
- *
- * Returns number which represents type.
- * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
- * puts tobj.typekind # => 4
- *
- */
-static VALUE
-foletype_typekind(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_typekind(pTypeInfo);
-}
-
-static VALUE
-ole_type_helpstring(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- BSTR bhelpstr;
- hr = ole_docinfo_from_type(pTypeInfo, NULL, &bhelpstr, NULL, NULL);
- if(FAILED(hr)) {
- return Qnil;
- }
- return WC2VSTR(bhelpstr);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#helpstring #=> help string.
- *
- * Returns help string.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
- * puts tobj.helpstring # => Web Browser interface
- */
-static VALUE
-foletype_helpstring(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_helpstring(pTypeInfo);
-}
-
-static VALUE
-ole_type_src_type(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- VALUE alias = Qnil;
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr))
- return alias;
- if(pTypeAttr->typekind != TKIND_ALIAS) {
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return alias;
- }
- alias = ole_typedesc2val(pTypeInfo, &(pTypeAttr->tdescAlias), Qnil);
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return alias;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#src_type #=> OLE source class
- *
- * Returns source class when the OLE class is 'Alias'.
- * tobj = WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType')
- * puts tobj.src_type # => I4
- *
- */
-static VALUE
-foletype_src_type(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_src_type(pTypeInfo);
-}
-
-static VALUE
-ole_type_helpfile(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- BSTR bhelpfile;
- hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL, NULL, &bhelpfile);
- if(FAILED(hr)) {
- return Qnil;
- }
- return WC2VSTR(bhelpfile);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#helpfile
- *
- * Returns helpfile path. If helpfile is not found, then returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
- * puts tobj.helpfile # => C:\...\VBAXL9.CHM
- *
- */
-static VALUE
-foletype_helpfile(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_helpfile(pTypeInfo);
-}
-
-static VALUE
-ole_type_helpcontext(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- DWORD helpcontext;
- hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL,
- &helpcontext, NULL);
- if(FAILED(hr))
- return Qnil;
- return RB_INT2FIX(helpcontext);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#helpcontext
- *
- * Returns helpcontext. If helpcontext is not found, then returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
- * puts tobj.helpfile # => 131185
- */
-static VALUE
-foletype_helpcontext(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_helpcontext(pTypeInfo);
-}
-
-static VALUE
-ole_variables(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- TYPEATTR *pTypeAttr;
- WORD i;
- UINT len;
- BSTR bstr;
- VARDESC *pVarDesc;
- VALUE var;
- VALUE variables = rb_ary_new();
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
- }
-
- for(i = 0; i < pTypeAttr->cVars; i++) {
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, i, &pVarDesc);
- if(FAILED(hr))
- continue;
- len = 0;
- hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
- 1, &len);
- if(FAILED(hr) || len == 0 || !bstr)
- continue;
-
- var = create_win32ole_variable(pTypeInfo, i, WC2VSTR(bstr));
- rb_ary_push(variables, var);
-
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- pVarDesc = NULL;
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return variables;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#variables
- *
- * Returns array of WIN32OLE_VARIABLE objects which represent variables
- * defined in OLE class.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * vars = tobj.variables
- * vars.each do |v|
- * puts "#{v.name} = #{v.value}"
- * end
- *
- * The result of above sample script is follows:
- * xlChart = -4109
- * xlDialogSheet = -4116
- * xlExcel4IntlMacroSheet = 4
- * xlExcel4MacroSheet = 3
- * xlWorksheet = -4167
- *
- */
-static VALUE
-foletype_variables(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_variables(pTypeInfo);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#ole_methods # the array of WIN32OLE_METHOD objects.
- *
- * Returns array of WIN32OLE_METHOD objects which represent OLE method defined in
- * OLE type library.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
- * methods = tobj.ole_methods.collect{|m|
- * m.name
- * }
- * # => ['Activate', 'Copy', 'Delete',....]
- */
-static VALUE
-foletype_methods(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_methods_from_typeinfo(pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
-}
-
-/*
- * 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)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_typelib_from_itypeinfo(pTypeInfo);
-}
-
-static VALUE
-ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags)
-{
- 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;
-
- if ((flags & implflags) == implflags) {
- 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)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_impl_ole_types(pTypeInfo, 0);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#source_ole_types
- *
- * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
- * object and having IMPLTYPEFLAG_FSOURCE.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
- * p tobj.source_ole_types
- * # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]
- */
-static VALUE
-foletype_source_ole_types(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#default_event_sources
- *
- * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
- * object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
- * p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
- */
-static VALUE
-foletype_default_event_sources(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#default_ole_types
- *
- * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
- * object and having IMPLTYPEFLAG_FDEFAULT.
- * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
- * p tobj.default_ole_types
- * # => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>]
- */
-static VALUE
-foletype_default_ole_types(VALUE self)
-{
- ITypeInfo *pTypeInfo = itypeinfo(self);
- return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FDEFAULT);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#inspect -> String
- *
- * Returns the type name with class name.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2>
- */
-static VALUE
-foletype_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_TYPE");
-}
-
-VALUE cWIN32OLE_TYPE;
-
-void Init_win32ole_type(void)
-{
- cWIN32OLE_TYPE = rb_define_class_under(cWIN32OLE, "Type", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_TYPE", cWIN32OLE_TYPE);
- rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1);
- rb_define_singleton_method(cWIN32OLE_TYPE, "typelibs", foletype_s_typelibs, 0);
- rb_define_singleton_method(cWIN32OLE_TYPE, "progids", foletype_s_progids, 0);
- rb_define_alloc_func(cWIN32OLE_TYPE, foletype_s_allocate);
- rb_define_method(cWIN32OLE_TYPE, "initialize", foletype_initialize, 2);
- rb_define_method(cWIN32OLE_TYPE, "name", foletype_name, 0);
- rb_define_method(cWIN32OLE_TYPE, "ole_type", foletype_ole_type, 0);
- rb_define_method(cWIN32OLE_TYPE, "guid", foletype_guid, 0);
- rb_define_method(cWIN32OLE_TYPE, "progid", foletype_progid, 0);
- rb_define_method(cWIN32OLE_TYPE, "visible?", foletype_visible, 0);
- rb_define_alias(cWIN32OLE_TYPE, "to_s", "name");
- rb_define_method(cWIN32OLE_TYPE, "major_version", foletype_major_version, 0);
- rb_define_method(cWIN32OLE_TYPE, "minor_version", foletype_minor_version, 0);
- rb_define_method(cWIN32OLE_TYPE, "typekind", foletype_typekind, 0);
- rb_define_method(cWIN32OLE_TYPE, "helpstring", foletype_helpstring, 0);
- rb_define_method(cWIN32OLE_TYPE, "src_type", foletype_src_type, 0);
- rb_define_method(cWIN32OLE_TYPE, "helpfile", foletype_helpfile, 0);
- rb_define_method(cWIN32OLE_TYPE, "helpcontext", foletype_helpcontext, 0);
- rb_define_method(cWIN32OLE_TYPE, "variables", foletype_variables, 0);
- rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, 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, "source_ole_types", foletype_source_ole_types, 0);
- rb_define_method(cWIN32OLE_TYPE, "default_event_sources", foletype_default_event_sources, 0);
- rb_define_method(cWIN32OLE_TYPE, "default_ole_types", foletype_default_ole_types, 0);
- rb_define_method(cWIN32OLE_TYPE, "inspect", foletype_inspect, 0);
-}
diff --git a/ext/win32ole/win32ole_type.h b/ext/win32ole/win32ole_type.h
deleted file mode 100644
index 87b551e502..0000000000
--- a/ext/win32ole/win32ole_type.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef WIN32OLE_TYPE_H
-#define WIN32OLE_TYPE_H 1
-extern VALUE cWIN32OLE_TYPE;
-VALUE create_win32ole_type(ITypeInfo *pTypeInfo, VALUE name);
-ITypeInfo *itypeinfo(VALUE self);
-VALUE ole_type_from_itypeinfo(ITypeInfo *pTypeInfo);
-void Init_win32ole_type(void);
-#endif
diff --git a/ext/win32ole/win32ole_typelib.c b/ext/win32ole/win32ole_typelib.c
deleted file mode 100644
index fb68bebda8..0000000000
--- a/ext/win32ole/win32ole_typelib.c
+++ /dev/null
@@ -1,847 +0,0 @@
-#include "win32ole.h"
-
-struct oletypelibdata {
- ITypeLib *pTypeLib;
-};
-
-static VALUE reg_get_typelib_file_path(HKEY hkey);
-static VALUE oletypelib_path(VALUE guid, VALUE version);
-static HRESULT oletypelib_from_guid(VALUE guid, VALUE version, ITypeLib **ppTypeLib);
-static VALUE foletypelib_s_typelibs(VALUE self);
-static VALUE oletypelib_set_member(VALUE self, ITypeLib *pTypeLib);
-static void oletypelib_free(void *ptr);
-static size_t oletypelib_size(const void *ptr);
-static VALUE foletypelib_s_allocate(VALUE klass);
-static VALUE oletypelib_search_registry(VALUE self, VALUE typelib);
-static void oletypelib_get_libattr(ITypeLib *pTypeLib, TLIBATTR **ppTLibAttr);
-static VALUE oletypelib_search_registry2(VALUE self, VALUE args);
-static VALUE foletypelib_initialize(VALUE self, VALUE args);
-static VALUE foletypelib_guid(VALUE self);
-static VALUE foletypelib_name(VALUE self);
-static VALUE make_version_str(VALUE major, VALUE minor);
-static VALUE foletypelib_version(VALUE self);
-static VALUE foletypelib_major_version(VALUE self);
-static VALUE foletypelib_minor_version(VALUE self);
-static VALUE foletypelib_path(VALUE self);
-static VALUE foletypelib_visible(VALUE self);
-static VALUE foletypelib_library_name(VALUE self);
-static VALUE ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes);
-static VALUE typelib_file_from_typelib(VALUE ole);
-static VALUE typelib_file_from_clsid(VALUE ole);
-static VALUE foletypelib_ole_types(VALUE self);
-static VALUE foletypelib_inspect(VALUE self);
-
-static const rb_data_type_t oletypelib_datatype = {
- "win32ole_typelib",
- {NULL, oletypelib_free, oletypelib_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static VALUE
-reg_get_typelib_file_path(HKEY hkey)
-{
- VALUE path = Qnil;
- path = reg_get_val2(hkey, "win64");
- if (path != Qnil) {
- return path;
- }
- path = reg_get_val2(hkey, "win32");
- if (path != Qnil) {
- return path;
- }
- path = reg_get_val2(hkey, "win16");
- return path;
-}
-
-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;
-}
-
-static HRESULT
-oletypelib_from_guid(VALUE guid, VALUE version, ITypeLib **ppTypeLib)
-{
- VALUE path;
- OLECHAR *pBuf;
- HRESULT hr;
- path = oletypelib_path(guid, version);
- if (path == Qnil) {
- return E_UNEXPECTED;
- }
- pBuf = ole_vstr2wc(path);
- hr = LoadTypeLibEx(pBuf, REGKIND_NONE, ppTypeLib);
- SysFreeString(pBuf);
- return hr;
-}
-
-ITypeLib *
-itypelib(VALUE self)
-{
- struct oletypelibdata *ptlib;
- TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
- return ptlib->pTypeLib;
-}
-
-VALUE
-ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- ITypeLib *pTypeLib;
- unsigned int index;
- VALUE retval = Qnil;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
- if(FAILED(hr)) {
- return Qnil;
- }
- retval = create_win32ole_typelib(pTypeLib);
- return retval;
-}
-
-/*
- * Document-class: WIN32OLE_TYPELIB
- *
- * <code>WIN32OLE_TYPELIB</code> objects represent OLE tyblib information.
- */
-
-/*
- * 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;
- HRESULT hr;
- ITypeLib *pTypeLib;
-
- 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 ) {
- hr = oletypelib_from_guid(guid, version, &pTypeLib);
- if (SUCCEEDED(hr)) {
- typelib = create_win32ole_typelib(pTypeLib);
- rb_ary_push(typelibs, typelib);
- }
- }
- }
- RegCloseKey(hguid);
- }
- RegCloseKey(htypelib);
- return typelibs;
-}
-
-static VALUE
-oletypelib_set_member(VALUE self, ITypeLib *pTypeLib)
-{
- struct oletypelibdata *ptlib;
- TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
- ptlib->pTypeLib = pTypeLib;
- return self;
-}
-
-static void
-oletypelib_free(void *ptr)
-{
- struct oletypelibdata *poletypelib = ptr;
- OLE_FREE(poletypelib->pTypeLib);
- free(poletypelib);
-}
-
-static size_t
-oletypelib_size(const void *ptr)
-{
- return ptr ? sizeof(struct oletypelibdata) : 0;
-}
-
-static VALUE
-foletypelib_s_allocate(VALUE klass)
-{
- struct oletypelibdata *poletypelib;
- VALUE obj;
- ole_initialize();
- obj = TypedData_Make_Struct(klass, struct oletypelibdata, &oletypelib_datatype, poletypelib);
- poletypelib->pTypeLib = NULL;
- return obj;
-}
-
-VALUE
-create_win32ole_typelib(ITypeLib *pTypeLib)
-{
- VALUE obj = foletypelib_s_allocate(cWIN32OLE_TYPELIB);
- oletypelib_set_member(obj, pTypeLib);
- return obj;
-}
-
-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;
- HRESULT hr;
- ITypeLib *pTypeLib;
-
- 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) {
- hr = oletypelib_from_guid(guid, ver, &pTypeLib);
- if (SUCCEEDED(hr)) {
- oletypelib_set_member(self, pTypeLib);
- found = Qtrue;
- }
- }
- RegCloseKey(hversion);
- }
- RegCloseKey(hguid);
- }
- RegCloseKey(htypelib);
- return found;
-}
-
-static void
-oletypelib_get_libattr(ITypeLib *pTypeLib, TLIBATTR **ppTLibAttr)
-{
- HRESULT hr;
- hr = pTypeLib->lpVtbl->GetLibAttr(pTypeLib, ppTLibAttr);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to get library attribute(TLIBATTR) from ITypeLib");
- }
-}
-
-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;
- HRESULT hr;
- ITypeLib *pTypeLib;
-
- 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) {
- hr = oletypelib_from_guid(guid, version, &pTypeLib);
- if (SUCCEEDED(hr)) {
- found = Qtrue;
- oletypelib_set_member(self, pTypeLib);
- }
- }
- 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;
- HRESULT hr = S_OK;
-
- len = RARRAY_LEN(args);
- rb_check_arity(len, 1, 3);
-
- typelib = rb_ary_entry(args, 0);
-
- SafeStringValue(typelib);
-
- found = oletypelib_search_registry(self, typelib);
- if (found == Qfalse) {
- found = oletypelib_search_registry2(self, args);
- }
- if (found == Qfalse) {
- pbuf = ole_vstr2wc(typelib);
- hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
- SysFreeString(pbuf);
- if (SUCCEEDED(hr)) {
- found = Qtrue;
- oletypelib_set_member(self, pTypeLib);
- }
- }
-
- 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)
-{
- ITypeLib *pTypeLib;
- OLECHAR bstr[80];
- VALUE guid = Qnil;
- int len;
- TLIBATTR *pTLibAttr;
-
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
- len = StringFromGUID2(&pTLibAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
- if (len > 3) {
- guid = ole_wc2vstr(bstr, FALSE);
- }
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- return 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)
-{
- ITypeLib *pTypeLib;
- HRESULT hr;
- BSTR bstr;
- VALUE name;
- pTypeLib = itypelib(self);
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1,
- NULL, &bstr, NULL, NULL);
-
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get name from ITypeLib");
- }
- name = WC2VSTR(bstr);
- return name;
-}
-
-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;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#version -> The type library version String object.
- *
- * 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)
-{
- TLIBATTR *pTLibAttr;
- ITypeLib *pTypeLib;
- VALUE version;
-
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
- version = rb_sprintf("%d.%d", pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum);
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- return version;
-}
-
-/*
- * 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)
-{
- TLIBATTR *pTLibAttr;
- VALUE major;
- ITypeLib *pTypeLib;
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
-
- major = RB_INT2NUM(pTLibAttr->wMajorVerNum);
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- return major;
-}
-
-/*
- * 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)
-{
- TLIBATTR *pTLibAttr;
- VALUE minor;
- ITypeLib *pTypeLib;
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
- minor = RB_INT2NUM(pTLibAttr->wMinorVerNum);
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- return minor;
-}
-
-/*
- * 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)
-{
- TLIBATTR *pTLibAttr;
- HRESULT hr = S_OK;
- BSTR bstr;
- LCID lcid = cWIN32OLE_lcid;
- VALUE path;
- ITypeLib *pTypeLib;
-
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
- hr = QueryPathOfRegTypeLib(&pTLibAttr->guid,
- pTLibAttr->wMajorVerNum,
- pTLibAttr->wMinorVerNum,
- lcid,
- &bstr);
- if (FAILED(hr)) {
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- ole_raise(hr, eWIN32OLERuntimeError, "failed to QueryPathOfRegTypeTypeLib");
- }
-
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- path = WC2VSTR(bstr);
- return 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)
-{
- ITypeLib *pTypeLib = NULL;
- VALUE visible = Qtrue;
- TLIBATTR *pTLibAttr;
-
- pTypeLib = itypelib(self);
- oletypelib_get_libattr(pTypeLib, &pTLibAttr);
-
- if ((pTLibAttr->wLibFlags == 0) ||
- (pTLibAttr->wLibFlags & LIBFLAG_FRESTRICTED) ||
- (pTLibAttr->wLibFlags & LIBFLAG_FHIDDEN)) {
- visible = Qfalse;
- }
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- 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;
-
- pTypeLib = itypelib(self);
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get library name");
- }
- libname = WC2VSTR(bstr);
- return libname;
-}
-
-static VALUE
-ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes)
-{
- long count;
- int i;
- HRESULT hr;
- BSTR bstr;
- ITypeInfo *pTypeInfo;
- VALUE type;
-
- count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
- for (i = 0; i < count; i++) {
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr))
- continue;
-
- hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
- if (FAILED(hr))
- continue;
-
- type = create_win32ole_type(pTypeInfo, WC2VSTR(bstr));
-
- rb_ary_push(classes, type);
- OLE_RELEASE(pTypeInfo);
- }
- return classes;
-}
-
-static VALUE
-typelib_file_from_typelib(VALUE ole)
-{
- HKEY htypelib, hclsid, hversion, hlang;
- double fver;
- DWORD i, j, k;
- LONG err;
- BOOL found = FALSE;
- VALUE typelib;
- VALUE file = Qnil;
- VALUE clsid;
- VALUE ver;
- VALUE lang;
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
- if(err != ERROR_SUCCESS) {
- return Qnil;
- }
- for(i = 0; !found; i++) {
- clsid = reg_enum_key(htypelib, i);
- if (clsid == Qnil)
- break;
- err = reg_open_vkey(htypelib, clsid, &hclsid);
- if (err != ERROR_SUCCESS)
- continue;
- fver = 0;
- for(j = 0; !found; j++) {
- ver = reg_enum_key(hclsid, j);
- if (ver == Qnil)
- break;
- err = reg_open_vkey(hclsid, ver, &hversion);
- if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver)))
- continue;
- fver = atof(StringValuePtr(ver));
- typelib = reg_get_val(hversion, NULL);
- if (typelib == Qnil)
- continue;
- if (rb_str_cmp(typelib, ole) == 0) {
- for(k = 0; !found; k++) {
- lang = reg_enum_key(hversion, k);
- if (lang == Qnil)
- break;
- err = reg_open_vkey(hversion, lang, &hlang);
- if (err == ERROR_SUCCESS) {
- if ((file = reg_get_typelib_file_path(hlang)) != Qnil)
- found = TRUE;
- RegCloseKey(hlang);
- }
- }
- }
- RegCloseKey(hversion);
- }
- RegCloseKey(hclsid);
- }
- RegCloseKey(htypelib);
- return file;
-}
-
-static VALUE
-typelib_file_from_clsid(VALUE ole)
-{
- HKEY hroot, hclsid;
- LONG err;
- VALUE typelib;
- char path[MAX_PATH + 1];
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hroot);
- if (err != ERROR_SUCCESS) {
- return Qnil;
- }
- err = reg_open_key(hroot, StringValuePtr(ole), &hclsid);
- if (err != ERROR_SUCCESS) {
- RegCloseKey(hroot);
- return Qnil;
- }
- typelib = reg_get_val2(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;
-}
-
-VALUE
-typelib_file(VALUE ole)
-{
- VALUE file = typelib_file_from_clsid(ole);
- if (file != Qnil) {
- return file;
- }
- return typelib_file_from_typelib(ole);
-}
-
-
-/*
- * 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();
- pTypeLib = itypelib(self);
- ole_types_from_typelib(pTypeLib, classes);
- return classes;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#inspect -> String
- *
- * Returns the type library name with class name.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>"
- */
-static VALUE
-foletypelib_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_TYPELIB");
-}
-
-VALUE cWIN32OLE_TYPELIB;
-
-void
-Init_win32ole_typelib(void)
-{
- cWIN32OLE_TYPELIB = rb_define_class_under(cWIN32OLE, "Typelib", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_TYPELIB", cWIN32OLE_TYPELIB);
- rb_define_singleton_method(cWIN32OLE_TYPELIB, "typelibs", foletypelib_s_typelibs, 0);
- rb_define_alloc_func(cWIN32OLE_TYPELIB, foletypelib_s_allocate);
- 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);
-}
diff --git a/ext/win32ole/win32ole_typelib.h b/ext/win32ole/win32ole_typelib.h
deleted file mode 100644
index 2c2730bb58..0000000000
--- a/ext/win32ole/win32ole_typelib.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef WIN32OLE_TYPELIB_H
-#define WIN32OLE_TYPELIB_H 1
-
-extern VALUE cWIN32OLE_TYPELIB;
-
-void Init_win32ole_typelib(void);
-ITypeLib * itypelib(VALUE self);
-VALUE typelib_file(VALUE ole);
-VALUE create_win32ole_typelib(ITypeLib *pTypeLib);
-VALUE ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo);
-#endif
diff --git a/ext/win32ole/win32ole_variable.c b/ext/win32ole/win32ole_variable.c
deleted file mode 100644
index e7f58c891e..0000000000
--- a/ext/win32ole/win32ole_variable.c
+++ /dev/null
@@ -1,384 +0,0 @@
-#include "win32ole.h"
-
-struct olevariabledata {
- ITypeInfo *pTypeInfo;
- UINT index;
-};
-
-static void olevariable_free(void *ptr);
-static size_t olevariable_size(const void *ptr);
-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 const rb_data_type_t olevariable_datatype = {
- "win32ole_variable",
- {NULL, olevariable_free, olevariable_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static void
-olevariable_free(void *ptr)
-{
- struct olevariabledata *polevar = ptr;
- OLE_FREE(polevar->pTypeInfo);
- free(polevar);
-}
-
-static size_t
-olevariable_size(const void *ptr)
-{
- return ptr ? sizeof(struct olevariabledata) : 0;
-}
-
-/*
- * Document-class: WIN32OLE_VARIABLE
- *
- * <code>WIN32OLE_VARIABLE</code> objects represent OLE variable information.
- */
-
-VALUE
-create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name)
-{
- struct olevariabledata *pvar;
- VALUE obj = TypedData_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata,
- &olevariable_datatype, pvar);
- pvar->pTypeInfo = pTypeInfo;
- OLE_ADDREF(pTypeInfo);
- pvar->index = index;
- rb_ivar_set(obj, rb_intern("name"), name);
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#name
- *
- * Returns the name of variable.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.name}"
- * end
- *
- * The result of above script is following:
- * xlChart
- * xlDialogSheet
- * xlExcel4IntlMacroSheet
- * xlExcel4MacroSheet
- * xlWorksheet
- *
- */
-static VALUE
-folevariable_name(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("name"));
-}
-
-static VALUE
-ole_variable_ole_type(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");
- type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#ole_type
- *
- * Returns OLE type string.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.ole_type} #{variable.name}"
- * end
- *
- * The result of above script is following:
- * INT xlChart
- * INT xlDialogSheet
- * INT xlExcel4IntlMacroSheet
- * INT xlExcel4MacroSheet
- * INT xlWorksheet
- *
- */
-static VALUE
-folevariable_ole_type(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_ole_type(pvar->pTypeInfo, pvar->index);
-}
-
-static VALUE
-ole_variable_ole_type_detail(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_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- return type;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#ole_type_detail
- *
- * Returns detail information of type. The information is array of type.
- *
- * tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS')
- * variable = tobj.variables.find {|variable| variable.name == 'lFlags'}
- * tdetail = variable.ole_type_detail
- * p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"]
- *
- */
-static VALUE
-folevariable_ole_type_detail(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index);
-}
-
-static VALUE
-ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index)
-{
- VARDESC *pVarDesc;
- HRESULT hr;
- VALUE val = Qnil;
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
- if (FAILED(hr))
- return Qnil;
- if(pVarDesc->varkind == VAR_CONST)
- val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- return val;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#value
- *
- * Returns value if value is exists. If the value does not exist,
- * this method returns nil.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.name} #{variable.value}"
- * end
- *
- * The result of above script is following:
- * xlChart = -4109
- * xlDialogSheet = -4116
- * xlExcel4IntlMacroSheet = 4
- * xlExcel4MacroSheet = 3
- * xlWorksheet = -4167
- *
- */
-static VALUE
-folevariable_value(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_value(pvar->pTypeInfo, pvar->index);
-}
-
-static VALUE
-ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index)
-{
- VARDESC *pVarDesc;
- HRESULT hr;
- VALUE visible = Qfalse;
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
- if (FAILED(hr))
- return visible;
- if (!(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
- VARFLAG_FRESTRICTED |
- VARFLAG_FNONBROWSABLE))) {
- visible = Qtrue;
- }
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- return visible;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#visible?
- *
- * Returns true if the variable is public.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.name} #{variable.visible?}"
- * end
- *
- * The result of above script is following:
- * xlChart true
- * xlDialogSheet true
- * xlExcel4IntlMacroSheet true
- * xlExcel4MacroSheet true
- * xlWorksheet true
- *
- */
-static VALUE
-folevariable_visible(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_visible(pvar->pTypeInfo, pvar->index);
-}
-
-static VALUE
-ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index)
-{
- VARDESC *pVarDesc;
- HRESULT hr;
- VALUE kind = rb_str_new2("UNKNOWN");
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
- if (FAILED(hr))
- return kind;
- switch(pVarDesc->varkind) {
- case VAR_PERINSTANCE:
- kind = rb_str_new2("PERINSTANCE");
- break;
- case VAR_STATIC:
- kind = rb_str_new2("STATIC");
- break;
- case VAR_CONST:
- kind = rb_str_new2("CONSTANT");
- break;
- case VAR_DISPATCH:
- kind = rb_str_new2("DISPATCH");
- break;
- default:
- break;
- }
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- return kind;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#variable_kind
- *
- * Returns variable kind string.
- *
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.name} #{variable.variable_kind}"
- * end
- *
- * The result of above script is following:
- * xlChart CONSTANT
- * xlDialogSheet CONSTANT
- * xlExcel4IntlMacroSheet CONSTANT
- * xlExcel4MacroSheet CONSTANT
- * xlWorksheet CONSTANT
- */
-static VALUE
-folevariable_variable_kind(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_kind(pvar->pTypeInfo, pvar->index);
-}
-
-static VALUE
-ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index)
-{
- VARDESC *pVarDesc;
- HRESULT hr;
- VALUE kind = Qnil;
- hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
- if (FAILED(hr))
- return kind;
- pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
- kind = RB_INT2FIX(pVarDesc->varkind);
- return kind;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#varkind
- *
- * Returns the number which represents variable kind.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
- * variables = tobj.variables
- * variables.each do |variable|
- * puts "#{variable.name} #{variable.varkind}"
- * end
- *
- * The result of above script is following:
- * xlChart 2
- * xlDialogSheet 2
- * xlExcel4IntlMacroSheet 2
- * xlExcel4MacroSheet 2
- * xlWorksheet 2
- */
-static VALUE
-folevariable_varkind(VALUE self)
-{
- struct olevariabledata *pvar;
- TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
- return ole_variable_varkind(pvar->pTypeInfo, pvar->index);
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIABLE#inspect -> String
- *
- * Returns the OLE variable name and the value with class name.
- *
- */
-static VALUE
-folevariable_inspect(VALUE self)
-{
- VALUE v = rb_inspect(folevariable_value(self));
- VALUE n = folevariable_name(self);
- VALUE detail = rb_sprintf("%"PRIsVALUE"=%"PRIsVALUE, n, v);
- return make_inspect("WIN32OLE_VARIABLE", detail);
-}
-
-VALUE cWIN32OLE_VARIABLE;
-
-void Init_win32ole_variable(void)
-{
- cWIN32OLE_VARIABLE = rb_define_class_under(cWIN32OLE, "Variable", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_VARIABLE", cWIN32OLE_VARIABLE);
- rb_undef_alloc_func(cWIN32OLE_VARIABLE);
- rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "ole_type", folevariable_ole_type, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "ole_type_detail", folevariable_ole_type_detail, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "value", folevariable_value, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "visible?", folevariable_visible, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "variable_kind", folevariable_variable_kind, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "varkind", folevariable_varkind, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "inspect", folevariable_inspect, 0);
- rb_define_alias(cWIN32OLE_VARIABLE, "to_s", "name");
-}
diff --git a/ext/win32ole/win32ole_variable.h b/ext/win32ole/win32ole_variable.h
deleted file mode 100644
index 209613fd44..0000000000
--- a/ext/win32ole/win32ole_variable.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef WIN32OLE_VARIABLE_H
-#define WIN32OLE_VARIABLE_H 1
-
-extern VALUE cWIN32OLE_VARIABLE;
-VALUE create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name);
-void Init_win32ole_variable(void);
-
-#endif
diff --git a/ext/win32ole/win32ole_variant.c b/ext/win32ole/win32ole_variant.c
deleted file mode 100644
index f1d83ed2e1..0000000000
--- a/ext/win32ole/win32ole_variant.c
+++ /dev/null
@@ -1,736 +0,0 @@
-#include "win32ole.h"
-
-struct olevariantdata {
- VARIANT realvar;
- VARIANT var;
-};
-
-static void olevariant_free(void *ptr);
-static size_t olevariant_size(const void *ptr);
-static void ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar);
-static void ole_val2variant_err(VALUE val, VARIANT *var);
-static void ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt);
-static VALUE folevariant_s_allocate(VALUE klass);
-static VALUE folevariant_s_array(VALUE klass, VALUE dims, VALUE vvt);
-static void check_type_val2variant(VALUE val);
-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 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 const rb_data_type_t olevariant_datatype = {
- "win32ole_variant",
- {NULL, olevariant_free, olevariant_size,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static void
-olevariant_free(void *ptr)
-{
- struct olevariantdata *pvar = ptr;
- VariantClear(&(pvar->realvar));
- VariantClear(&(pvar->var));
- free(pvar);
-}
-
-static size_t
-olevariant_size(const void *ptr)
-{
- return ptr ? sizeof(struct olevariantdata) : 0;
-}
-
-static void
-ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar)
-{
- HRESULT hr = S_OK;
-
- if (((vt & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && RB_TYPE_P(val, T_STRING)) {
- long len = RSTRING_LEN(val);
- void *pdest = NULL;
- SAFEARRAY *p = NULL;
- SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, len);
- if (!psa) {
- rb_raise(rb_eRuntimeError, "fail to SafeArrayCreateVector");
- }
- hr = SafeArrayAccessData(psa, &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), (VARTYPE)(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 (defined(_MSC_VER) && (_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 ( (vt & ~VT_BYREF) == VT_ERROR) {
- ole_val2variant_err(val, &(pvar->realvar));
- if (vt & VT_BYREF) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- } else {
- hr = VariantCopy(&(pvar->var), &(pvar->realvar));
- }
- } 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), (VARTYPE)(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_val2variant_err(VALUE val, VARIANT *var)
-{
- VALUE v = val;
- if (rb_obj_is_kind_of(v, cWIN32OLE_VARIANT)) {
- v = folevariant_value(v);
- }
- if (!(FIXNUM_P(v) || RB_TYPE_P(v, T_BIGNUM) || v == Qnil)) {
- rb_raise(eWIN32OLERuntimeError, "failed to convert VT_ERROR VARIANT:`%"PRIsVALUE"'", rb_inspect(v));
- }
- V_VT(var) = VT_ERROR;
- if (v != Qnil) {
- V_ERROR(var) = RB_NUM2LONG(val);
- } else {
- V_ERROR(var) = 0;
- }
-}
-
-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 (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
-#ifdef V_I8REF
- case VT_I8:
- V_I8REF(var) = &V_I8(realvar);
- break;
-#endif
-#ifdef V_UI8REF
- case VT_UI8:
- V_UI8REF(var) = &V_UI8(realvar);
- break;
-#endif
-#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 VALUE
-folevariant_s_allocate(VALUE klass)
-{
- struct olevariantdata *pvar;
- VALUE obj;
- ole_initialize();
- obj = TypedData_Make_Struct(klass, struct olevariantdata, &olevariant_datatype, 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 = RB_NUM2UINT(vvt);
- vt = (vt | VT_ARRAY);
- Check_Type(elems, T_ARRAY);
- obj = folevariant_s_allocate(klass);
-
- TypedData_Get_Struct(obj, struct olevariantdata, &olevariant_datatype, 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 = RB_FIX2INT(rb_ary_entry(elems, i));
- psab[i].lLbound = 0;
- }
-
- psa = SafeArrayCreate((VARTYPE)(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;
-}
-
-static void
-check_type_val2variant(VALUE val)
-{
- VALUE elem;
- int len = 0;
- int i = 0;
- if(!rb_obj_is_kind_of(val, cWIN32OLE) &&
- !rb_obj_is_kind_of(val, cWIN32OLE_VARIANT) &&
- !rb_obj_is_kind_of(val, rb_cTime)) {
- switch (TYPE(val)) {
- case T_ARRAY:
- len = RARRAY_LEN(val);
- for(i = 0; i < len; i++) {
- elem = rb_ary_entry(val, i);
- check_type_val2variant(elem);
- }
- break;
- case T_STRING:
- case T_FIXNUM:
- case T_BIGNUM:
- case T_FLOAT:
- case T_TRUE:
- case T_FALSE:
- case T_NIL:
- break;
- default:
- rb_raise(rb_eTypeError, "can not convert WIN32OLE_VARIANT from type %s",
- rb_obj_classname(val));
- }
- }
-}
-
-/*
- * Document-class: WIN32OLE_VARIANT
- *
- * <code>WIN32OLE_VARIANT</code> objects represents OLE variant.
- *
- * Win32OLE converts Ruby object into OLE variant automatically when
- * invoking OLE methods. If OLE method requires the argument which is
- * different from the variant by automatic conversion of Win32OLE, you
- * can convert the specified variant type by using WIN32OLE_VARIANT class.
- *
- * param = WIN32OLE_VARIANT.new(10, WIN32OLE::VARIANT::VT_R4)
- * oleobj.method(param)
- *
- * WIN32OLE_VARIANT does not support VT_RECORD variant. Use WIN32OLE_RECORD
- * class instead of WIN32OLE_VARIANT if the VT_RECORD variant is needed.
- */
-
-/*
- * 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);
- rb_check_arity(len, 1, 3);
- VariantInit(&var);
- val = rb_ary_entry(args, 0);
-
- check_type_val2variant(val);
-
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
- if (len == 1) {
- ole_val2variant(val, &(pvar->var));
- } else {
- vvt = rb_ary_entry(args, 1);
- vt = RB_NUM2INT(vvt);
- if ((vt & VT_TYPEMASK) == VT_RECORD) {
- rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE_VARIANT object");
- }
- ole_val2olevariantdata(val, vt, pvar);
- }
- return self;
-}
-
-static SAFEARRAY *
-get_locked_safe_array(VALUE val)
-{
- struct olevariantdata *pvar;
- SAFEARRAY *psa = NULL;
- HRESULT hr;
- TypedData_Get_Struct(val, struct olevariantdata, &olevariant_datatype, 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] = RB_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 indices should be 0 or natural number and
- * lower than or equal to max indices.
- * (This point is different with Ruby Array indices.)
- *
- * 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;
-
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, 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;
-}
-
-/*
- * 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 indices should be 0 or natural number and
- * lower than or equal to max indices.
- * (This point is different with Ruby Array indices.)
- *
- * 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;
-
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, 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 Integer object, but String object "1")
- *
- */
-static VALUE
-folevariant_value(VALUE self)
-{
- struct olevariantdata *pvar;
- VALUE val = Qnil;
- VARTYPE vt;
- int dim;
- SAFEARRAY *psa;
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, 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;
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
- return RB_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.
- * This 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;
- TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
- vt = V_VT(&(pvar->var));
- if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || !RB_TYPE_P(val, T_STRING))) {
- rb_raise(eWIN32OLERuntimeError,
- "`value=' is not available for this variant type object");
- }
- ole_val2olevariantdata(val, vt, pvar);
- return Qnil;
-}
-
-void
-ole_variant2variant(VALUE val, VARIANT *var)
-{
- struct olevariantdata *pvar;
- TypedData_Get_Struct(val, struct olevariantdata, &olevariant_datatype, pvar);
- VariantCopy(var, &(pvar->var));
-}
-
-VALUE cWIN32OLE_VARIANT;
-
-void
-Init_win32ole_variant(void)
-{
-#undef rb_intern
- cWIN32OLE_VARIANT = rb_define_class_under(cWIN32OLE, "Variant", rb_cObject);
- rb_define_const(rb_cObject, "WIN32OLE_VARIANT", cWIN32OLE_VARIANT);
- 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);
-
- /*
- * represents VT_EMPTY OLE object.
- */
- rb_define_const(cWIN32OLE_VARIANT, "Empty",
- rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_EMPTY)));
-
- /*
- * represents VT_NULL OLE object.
- */
- rb_define_const(cWIN32OLE_VARIANT, "Null",
- rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_NULL)));
-
- /*
- * represents Nothing of VB.NET or VB.
- */
- rb_define_const(cWIN32OLE_VARIANT, "Nothing",
- rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_DISPATCH)));
-
- /*
- * represents VT_ERROR variant with DISP_E_PARAMNOTFOUND.
- * This constants is used for not specified parameter.
- *
- * fso = WIN32OLE.new("Scripting.FileSystemObject")
- * fso.openTextFile(filename, WIN32OLE_VARIANT::NoParam, false)
- */
- rb_define_const(cWIN32OLE_VARIANT, "NoParam",
- rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, INT2NUM(DISP_E_PARAMNOTFOUND), RB_INT2FIX(VT_ERROR)));
-}
diff --git a/ext/win32ole/win32ole_variant.h b/ext/win32ole/win32ole_variant.h
deleted file mode 100644
index 4bd3b0aeea..0000000000
--- a/ext/win32ole/win32ole_variant.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef WIN32OLE_VARIANT_H
-#define WIN32OLE_VARIANT_H 1
-
-extern VALUE cWIN32OLE_VARIANT;
-void ole_variant2variant(VALUE val, VARIANT *var);
-void Init_win32ole_variant(void);
-
-#endif
-
diff --git a/ext/win32ole/win32ole_variant_m.c b/ext/win32ole/win32ole_variant_m.c
deleted file mode 100644
index c285a00177..0000000000
--- a/ext/win32ole/win32ole_variant_m.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#include "win32ole.h"
-
-VALUE mWIN32OLE_VARIANT;
-
-void Init_win32ole_variant_m(void)
-{
- /*
- * Document-module: WIN32OLE::VARIANT
- *
- * The WIN32OLE::VARIANT module includes constants of VARIANT type constants.
- * The constants is used when creating WIN32OLE_VARIANT object.
- *
- * obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4)
- * obj.value # => 2000.0
- *
- */
- mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT");
-
- /*
- * represents VT_EMPTY type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_EMPTY", RB_INT2FIX(VT_EMPTY));
-
- /*
- * represents VT_NULL type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_NULL", RB_INT2FIX(VT_NULL));
-
- /*
- * represents VT_I2 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_I2", RB_INT2FIX(VT_I2));
-
- /*
- * represents VT_I4 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_I4", RB_INT2FIX(VT_I4));
-
- /*
- * represents VT_R4 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_R4", RB_INT2FIX(VT_R4));
-
- /*
- * represents VT_R8 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_R8", RB_INT2FIX(VT_R8));
-
- /*
- * represents VT_CY type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_CY", RB_INT2FIX(VT_CY));
-
- /*
- * represents VT_DATE type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", RB_INT2FIX(VT_DATE));
-
- /*
- * represents VT_BSTR type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", RB_INT2FIX(VT_BSTR));
-
- /*
- * represents VT_USERDEFINED type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", RB_INT2FIX(VT_USERDEFINED));
-
- /*
- * represents VT_PTR type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", RB_INT2FIX(VT_PTR));
-
- /*
- * represents VT_DISPATCH type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", RB_INT2FIX(VT_DISPATCH));
-
- /*
- * represents VT_ERROR type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", RB_INT2FIX(VT_ERROR));
-
- /*
- * represents VT_BOOL type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", RB_INT2FIX(VT_BOOL));
-
- /*
- * represents VT_VARIANT type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", RB_INT2FIX(VT_VARIANT));
-
- /*
- * represents VT_UNKNOWN type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", RB_INT2FIX(VT_UNKNOWN));
-
- /*
- * represents VT_I1 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_I1", RB_INT2FIX(VT_I1));
-
- /*
- * represents VT_UI1 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", RB_INT2FIX(VT_UI1));
-
- /*
- * represents VT_UI2 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", RB_INT2FIX(VT_UI2));
-
- /*
- * represents VT_UI4 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", RB_INT2FIX(VT_UI4));
-
-#if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__CYGWIN__) || defined(__MINGW32__)
- /*
- * represents VT_I8 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_I8", RB_INT2FIX(VT_I8));
-
- /*
- * represents VT_UI8 type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UI8", RB_INT2FIX(VT_UI8));
-#endif
-
- /*
- * represents VT_INT type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_INT", RB_INT2FIX(VT_INT));
-
- /*
- * represents VT_UINT type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", RB_INT2FIX(VT_UINT));
-
- /*
- * represents VT_ARRAY type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", RB_INT2FIX(VT_ARRAY));
-
- /*
- * represents VT_BYREF type constant.
- */
- rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", RB_INT2FIX(VT_BYREF));
-
-}
diff --git a/ext/win32ole/win32ole_variant_m.h b/ext/win32ole/win32ole_variant_m.h
deleted file mode 100644
index 6272a6578f..0000000000
--- a/ext/win32ole/win32ole_variant_m.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef WIN32OLE_VARIANT_M_H
-#define WIN32OLE_VARIANT_M_H 1
-
-extern VALUE mWIN32OLE_VARIANT;
-void Init_win32ole_variant_m(void);
-
-#endif
diff --git a/ext/zlib/depend b/ext/zlib/depend
index bdcf6a93e8..22e9ca867a 100644
--- a/ext/zlib/depend
+++ b/ext/zlib/depend
@@ -138,6 +138,7 @@ zlib.o: $(hdrdir)/ruby/internal/intern/re.h
zlib.o: $(hdrdir)/ruby/internal/intern/ruby.h
zlib.o: $(hdrdir)/ruby/internal/intern/select.h
zlib.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+zlib.o: $(hdrdir)/ruby/internal/intern/set.h
zlib.o: $(hdrdir)/ruby/internal/intern/signal.h
zlib.o: $(hdrdir)/ruby/internal/intern/sprintf.h
zlib.o: $(hdrdir)/ruby/internal/intern/string.h
@@ -157,6 +158,7 @@ zlib.o: $(hdrdir)/ruby/internal/special_consts.h
zlib.o: $(hdrdir)/ruby/internal/static_assert.h
zlib.o: $(hdrdir)/ruby/internal/stdalign.h
zlib.o: $(hdrdir)/ruby/internal/stdbool.h
+zlib.o: $(hdrdir)/ruby/internal/stdckdint.h
zlib.o: $(hdrdir)/ruby/internal/symbol.h
zlib.o: $(hdrdir)/ruby/internal/value.h
zlib.o: $(hdrdir)/ruby/internal/value_type.h
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index 1254c62a17..2b2dbb1a5b 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -120,12 +120,18 @@ if have_zlib
$defs << "-DHAVE_CRC32_COMBINE"
$defs << "-DHAVE_ADLER32_COMBINE"
$defs << "-DHAVE_TYPE_Z_CRC_T"
- $defs << "-DHAVE_TYPE_Z_SIZE_T"
+ $defs << "-DHAVE_CRC32_Z"
+ $defs << "-DHAVE_ADLER32_Z"
+ $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS"
else
have_func('crc32_combine', 'zlib.h')
have_func('adler32_combine', 'zlib.h')
have_type('z_crc_t', 'zlib.h')
- have_type('z_size_t', 'zlib.h')
+ if (have_type('z_size_t', 'zlib.h') &&
+ have_func('crc32_z', 'zlib.h') &&
+ have_func('adler32_z', 'zlib.h'))
+ $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS"
+ end
end
create_makefile('zlib') {|conf|
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index aefdba0ebd..481d74b2b6 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -25,7 +25,7 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
-#define RUBY_ZLIB_VERSION "3.0.0"
+#define RUBY_ZLIB_VERSION "3.2.3"
#ifndef RB_PASS_CALLED_KEYWORDS
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
@@ -44,7 +44,7 @@
#endif
#endif
-#if defined(HAVE_TYPE_Z_SIZE_T)
+#if defined(HAVE_ZLIB_SIZE_T_FUNCS)
typedef uLong (*checksum_func)(uLong, const Bytef*, z_size_t);
# define crc32 crc32_z
# define adler32 adler32_z
@@ -90,7 +90,7 @@ static void zstream_expand_buffer_into(struct zstream*, unsigned long);
static int zstream_expand_buffer_non_stream(struct zstream *z);
static void zstream_append_buffer(struct zstream*, const Bytef*, long);
static VALUE zstream_detach_buffer(struct zstream*);
-static VALUE zstream_shift_buffer(struct zstream*, long);
+static VALUE zstream_shift_buffer(struct zstream*, long, VALUE);
static void zstream_buffer_ungets(struct zstream*, const Bytef*, unsigned long);
static void zstream_buffer_ungetbyte(struct zstream*, int);
static void zstream_append_input(struct zstream*, const Bytef*, long);
@@ -170,8 +170,8 @@ static void gzfile_check_footer(struct gzfile*, VALUE outbuf);
static void gzfile_write(struct gzfile*, Bytef*, long);
static long gzfile_read_more(struct gzfile*, VALUE outbuf);
static void gzfile_calc_crc(struct gzfile*, VALUE);
-static VALUE gzfile_read(struct gzfile*, long);
-static VALUE gzfile_read_all(struct gzfile*);
+static VALUE gzfile_read(struct gzfile*, long, VALUE);
+static VALUE gzfile_read_all(struct gzfile*, VALUE);
static void gzfile_ungets(struct gzfile*, const Bytef*, long);
static void gzfile_ungetbyte(struct gzfile*, int);
static VALUE gzfile_writer_end_run(VALUE);
@@ -388,7 +388,7 @@ rb_zlib_version(VALUE klass)
# define mask32(x) (x)
#endif
-#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_TYPE_Z_SIZE_T)
+#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_ZLIB_SIZE_T_FUNCS)
static uLong
checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *ptr, long len)
{
@@ -674,9 +674,7 @@ zstream_expand_buffer(struct zstream *z)
rb_obj_reveal(z->buf, rb_cString);
}
- rb_mutex_unlock(z->mutex);
- rb_protect(rb_yield, z->buf, &state);
- rb_mutex_lock(z->mutex);
+ rb_protect(rb_yield, z->buf, &state);
if (ZSTREAM_REUSE_BUFFER_P(z)) {
rb_str_modify(z->buf);
@@ -720,15 +718,14 @@ zstream_expand_buffer_into(struct zstream *z, unsigned long size)
}
}
-static void *
-zstream_expand_buffer_protect(void *ptr)
+static int
+zstream_expand_buffer_protect(struct zstream *z)
{
- struct zstream *z = (struct zstream *)ptr;
int state = 0;
rb_protect((VALUE (*)(VALUE))zstream_expand_buffer, (VALUE)z, &state);
- return (void *)(VALUE)state;
+ return state;
}
static int
@@ -820,19 +817,31 @@ zstream_detach_buffer(struct zstream *z)
}
static VALUE
-zstream_shift_buffer(struct zstream *z, long len)
+zstream_shift_buffer(struct zstream *z, long len, VALUE dst)
{
- VALUE dst;
char *bufptr;
long buflen = ZSTREAM_BUF_FILLED(z);
if (buflen <= len) {
- return zstream_detach_buffer(z);
+ if (NIL_P(dst) || (!ZSTREAM_IS_FINISHED(z) && !ZSTREAM_IS_GZFILE(z) &&
+ rb_block_given_p())) {
+ return zstream_detach_buffer(z);
+ } else {
+ bufptr = RSTRING_PTR(z->buf);
+ rb_str_resize(dst, buflen);
+ memcpy(RSTRING_PTR(dst), bufptr, buflen);
+ }
+ buflen = 0;
+ } else {
+ bufptr = RSTRING_PTR(z->buf);
+ if (NIL_P(dst)) {
+ dst = rb_str_new(bufptr, len);
+ } else {
+ rb_str_resize(dst, len);
+ memcpy(RSTRING_PTR(dst), bufptr, len);
+ }
+ buflen -= len;
}
-
- bufptr = RSTRING_PTR(z->buf);
- dst = rb_str_new(bufptr, len);
- buflen -= len;
memmove(bufptr, bufptr + len, buflen);
rb_str_set_len(z->buf, buflen);
z->stream.next_out = (Bytef*)RSTRING_END(z->buf);
@@ -851,9 +860,7 @@ zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len)
char *bufptr;
long filled;
- if (NIL_P(z->buf) || (long)rb_str_capacity(z->buf) <= ZSTREAM_BUF_FILLED(z)) {
- zstream_expand_buffer_into(z, len);
- }
+ zstream_expand_buffer_into(z, len);
RSTRING_GETMEM(z->buf, bufptr, filled);
memmove(bufptr + len, bufptr, filled);
@@ -923,7 +930,7 @@ zstream_discard_input(struct zstream *z, long len)
z->input = Qnil;
}
else {
- z->input = rb_str_substr(z->input, len,
+ z->input = rb_str_subseq(z->input, len,
RSTRING_LEN(z->input) - len);
}
}
@@ -1011,57 +1018,14 @@ zstream_ensure_end(VALUE v)
}
static void *
-zstream_run_func(void *ptr)
+zstream_run_once(void *_arguments)
{
- struct zstream_run_args *args = (struct zstream_run_args *)ptr;
- int err, state, flush = args->flush;
- struct zstream *z = args->z;
- uInt n;
-
- err = Z_OK;
- while (!args->interrupt) {
- n = z->stream.avail_out;
- err = z->func->run(&z->stream, flush);
- rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out));
+ struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
+ struct zstream *z = arguments->z;
- if (err == Z_STREAM_END) {
- z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
- z->flags |= ZSTREAM_FLAG_FINISHED;
- break;
- }
-
- if (err != Z_OK && err != Z_BUF_ERROR)
- break;
-
- if (z->stream.avail_out > 0) {
- z->flags |= ZSTREAM_FLAG_IN_STREAM;
- break;
- }
-
- if (z->stream.avail_in == 0 && z->func == &inflate_funcs) {
- /* break here because inflate() return Z_BUF_ERROR when avail_in == 0. */
- /* but deflate() could be called with avail_in == 0 (there's hidden buffer
- in zstream->state) */
- z->flags |= ZSTREAM_FLAG_IN_STREAM;
- break;
- }
-
- if (args->stream_output) {
- state = (int)(VALUE)rb_thread_call_with_gvl(zstream_expand_buffer_protect,
- (void *)z);
- }
- else {
- state = zstream_expand_buffer_non_stream(z);
- }
-
- if (state) {
- err = Z_OK; /* buffer expanded but stream processing was stopped */
- args->jump_state = state;
- break;
- }
- }
+ uintptr_t error = z->func->run(&z->stream, arguments->flush);
- return (void *)(VALUE)err;
+ return (void*)error;
}
/*
@@ -1076,6 +1040,92 @@ zstream_unblock_func(void *ptr)
args->interrupt = 1;
}
+#ifndef RB_NOGVL_OFFLOAD_SAFE
+// Default to no-op if it's not defined:
+#define RB_NOGVL_OFFLOAD_SAFE 0
+#endif
+
+static VALUE
+zstream_run_once_begin(VALUE _arguments)
+{
+ struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
+ struct zstream *z = arguments->z;
+
+ rb_str_locktmp(z->buf);
+
+#ifndef RB_NOGVL_UBF_ASYNC_SAFE
+ return (VALUE)rb_thread_call_without_gvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments);
+#else
+ return (VALUE)rb_nogvl(zstream_run_once, (void *)arguments, zstream_unblock_func, (void *)arguments, RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_OFFLOAD_SAFE);
+#endif
+}
+
+static VALUE
+zstream_run_once_ensure(VALUE _arguments)
+{
+ struct zstream_run_args *arguments = (struct zstream_run_args *)_arguments;
+ struct zstream *z = arguments->z;
+
+ rb_str_unlocktmp(z->buf);
+
+ return Qnil;
+}
+
+static int
+zstream_run_func(struct zstream_run_args *args)
+{
+ struct zstream *z = args->z;
+ int state;
+ uInt n;
+
+ int err = Z_OK;
+ while (!args->interrupt) {
+ n = z->stream.avail_out;
+
+ err = (int)(VALUE)rb_ensure(zstream_run_once_begin, (VALUE)args, zstream_run_once_ensure, (VALUE)args);
+
+ rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out));
+
+ if (err == Z_STREAM_END) {
+ z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
+ z->flags |= ZSTREAM_FLAG_FINISHED;
+ break;
+ }
+
+ if (err != Z_OK && err != Z_BUF_ERROR) {
+ break;
+ }
+
+ if (z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+
+ if (z->stream.avail_in == 0 && z->func == &inflate_funcs) {
+ /* break here because inflate() return Z_BUF_ERROR when avail_in == 0. */
+ /* but deflate() could be called with avail_in == 0 (there's hidden buffer
+ in zstream->state) */
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+
+ if (args->stream_output) {
+ state = zstream_expand_buffer_protect(z);
+ }
+ else {
+ state = zstream_expand_buffer_non_stream(z);
+ }
+
+ if (state) {
+ err = Z_OK; /* buffer expanded but stream processing was stopped */
+ args->jump_state = state;
+ break;
+ }
+ }
+
+ return err;
+}
+
static VALUE
zstream_run_try(VALUE value_arg)
{
@@ -1088,6 +1138,12 @@ zstream_run_try(VALUE value_arg)
int err;
VALUE old_input = Qnil;
+ /* Cannot start zstream while it is in progress. */
+ if (z->flags & ZSTREAM_IN_PROGRESS) {
+ rb_raise(cInProgressError, "zlib stream is in progress");
+ }
+ z->flags |= ZSTREAM_IN_PROGRESS;
+
if (NIL_P(z->input) && len == 0) {
z->stream.next_in = (Bytef*)"";
z->stream.avail_in = 0;
@@ -1108,24 +1164,22 @@ zstream_run_try(VALUE value_arg)
}
loop:
-#ifndef RB_NOGVL_UBF_ASYNC_SAFE
- err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)args,
- zstream_unblock_func, (void *)args);
-#else
- err = (int)(VALUE)rb_nogvl(zstream_run_func, (void *)args,
- zstream_unblock_func, (void *)args,
- RB_NOGVL_UBF_ASYNC_SAFE);
-#endif
+ err = zstream_run_func(args);
/* retry if no exception is thrown */
if (err == Z_OK && args->interrupt) {
args->interrupt = 0;
- goto loop;
+
+ /* Retry only if both avail_in > 0 (more input to process) and avail_out > 0
+ * (output buffer has space). If avail_out == 0, the buffer is full and should
+ * be consumed by the caller first. If avail_in == 0, there's nothing more to process. */
+ if (z->stream.avail_in > 0 && z->stream.avail_out > 0) {
+ goto loop;
+ }
}
- if (flush != Z_FINISH && err == Z_BUF_ERROR
- && z->stream.avail_out > 0) {
- z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ if (flush != Z_FINISH && err == Z_BUF_ERROR && z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
}
zstream_reset_input(z);
@@ -1155,9 +1209,6 @@ loop:
rb_str_resize(old_input, 0);
}
- if (args->jump_state)
- rb_jump_tag(args->jump_state);
-
return Qnil;
}
@@ -1165,25 +1216,10 @@ static VALUE
zstream_run_ensure(VALUE value_arg)
{
struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
+ struct zstream *z = args->z;
/* Remove ZSTREAM_IN_PROGRESS flag to signal that this zstream is not in use. */
- args->z->flags &= ~ZSTREAM_IN_PROGRESS;
-
- return Qnil;
-}
-
-static VALUE
-zstream_run_synchronized(VALUE value_arg)
-{
- struct zstream_run_args *args = (struct zstream_run_args *)value_arg;
-
- /* Cannot start zstream while it is in progress. */
- if (args->z->flags & ZSTREAM_IN_PROGRESS) {
- rb_raise(cInProgressError, "zlib stream is in progress");
- }
- args->z->flags |= ZSTREAM_IN_PROGRESS;
-
- rb_ensure(zstream_run_try, value_arg, zstream_run_ensure, value_arg);
+ z->flags &= ~ZSTREAM_IN_PROGRESS;
return Qnil;
}
@@ -1200,7 +1236,10 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
.jump_state = 0,
.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p(),
};
- rb_mutex_synchronize(z->mutex, zstream_run_synchronized, (VALUE)&args);
+
+ rb_ensure(zstream_run_try, (VALUE)&args, zstream_run_ensure, (VALUE)&args);
+ if (args.jump_state)
+ rb_jump_tag(args.jump_state);
}
static VALUE
@@ -1421,6 +1460,7 @@ rb_zstream_finish(VALUE obj)
* call-seq:
* flush_next_in -> input
*
+ * Flushes input buffer and returns all data in that buffer.
*/
static VALUE
rb_zstream_flush_next_in(VALUE obj)
@@ -1509,7 +1549,7 @@ rb_zstream_total_out(VALUE obj)
}
/*
- * Guesses the type of the data which have been inputed into the stream. The
+ * Guesses the type of the data which have been inputted into the stream. The
* returned value is either <tt>BINARY</tt>, <tt>ASCII</tt>, or
* <tt>UNKNOWN</tt>.
*/
@@ -1766,6 +1806,22 @@ do_deflate(struct zstream *z, VALUE src, int flush)
}
}
+struct rb_zlib_deflate_arguments {
+ struct zstream *z;
+ VALUE src;
+ int flush;
+};
+
+static VALUE
+rb_deflate_deflate_body(VALUE args)
+{
+ struct rb_zlib_deflate_arguments *arguments = (struct rb_zlib_deflate_arguments *)args;
+
+ do_deflate(arguments->z, arguments->src, arguments->flush);
+
+ return zstream_detach_buffer(arguments->z);
+}
+
/*
* Document-method: Zlib::Deflate#deflate
*
@@ -1797,11 +1853,10 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
{
struct zstream *z = get_zstream(obj);
VALUE src, flush;
-
rb_scan_args(argc, argv, "11", &src, &flush);
- do_deflate(z, src, ARG_FLUSH(flush));
+ struct rb_zlib_deflate_arguments arguments = {z, src, ARG_FLUSH(flush)};
- return zstream_detach_buffer(z);
+ return rb_mutex_synchronize(z->mutex, rb_deflate_deflate_body, (VALUE)&arguments);
}
/*
@@ -2097,56 +2152,19 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
return obj;
}
-/*
- * Document-method: Zlib::Inflate#inflate
- *
- * call-seq:
- * inflate(deflate_string, buffer: nil) -> String
- * inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil
- *
- * Inputs +deflate_string+ into the inflate stream and returns the output from
- * the stream. Calling this method, both the input and the output buffer of
- * the stream are flushed. If string is +nil+, this method finishes the
- * stream, just like Zlib::ZStream#finish.
- *
- * If a block is given consecutive inflated chunks from the +deflate_string+
- * are yielded to the block and +nil+ is returned.
- *
- * If a :buffer keyword argument is given and not nil:
- *
- * * The :buffer keyword should be a String, and will used as the output buffer.
- * Using this option can reuse the memory required during inflation.
- * * When not passing a block, the return value will be the same object as the
- * :buffer keyword argument.
- * * When passing a block, the yielded chunks will be the same value as the
- * :buffer keyword argument.
- *
- * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
- * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
- * call this method again with an empty string to flush the stream:
- *
- * inflater = Zlib::Inflate.new
- *
- * begin
- * out = inflater.inflate compressed
- * rescue Zlib::NeedDict
- * # ensure the dictionary matches the stream's required dictionary
- * raise unless inflater.adler == Zlib.adler32(dictionary)
- *
- * inflater.set_dictionary dictionary
- * inflater.inflate ''
- * end
- *
- * # ...
- *
- * inflater.close
- *
- * See also Zlib::Inflate.new
- */
+struct rb_zlib_inflate_arguments {
+ struct zstream *z;
+ int argc;
+ VALUE *argv;
+};
+
static VALUE
-rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
+rb_inflate_inflate_body(VALUE _arguments)
{
- struct zstream *z = get_zstream(obj);
+ struct rb_zlib_inflate_arguments *arguments = (struct rb_zlib_inflate_arguments*)_arguments;
+ struct zstream *z = arguments->z;
+ int argc = arguments->argc;
+ VALUE *argv = arguments->argv;
VALUE dst, src, opts, buffer = Qnil;
if (OPTHASH_GIVEN_P(opts)) {
@@ -2202,6 +2220,60 @@ rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
}
/*
+ * Document-method: Zlib::Inflate#inflate
+ *
+ * call-seq:
+ * inflate(deflate_string, buffer: nil) -> String
+ * inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil
+ *
+ * Inputs +deflate_string+ into the inflate stream and returns the output from
+ * the stream. Calling this method, both the input and the output buffer of
+ * the stream are flushed. If string is +nil+, this method finishes the
+ * stream, just like Zlib::ZStream#finish.
+ *
+ * If a block is given consecutive inflated chunks from the +deflate_string+
+ * are yielded to the block and +nil+ is returned.
+ *
+ * If a :buffer keyword argument is given and not nil:
+ *
+ * * The :buffer keyword should be a String, and will used as the output buffer.
+ * Using this option can reuse the memory required during inflation.
+ * * When not passing a block, the return value will be the same object as the
+ * :buffer keyword argument.
+ * * When passing a block, the yielded chunks will be the same value as the
+ * :buffer keyword argument.
+ *
+ * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
+ * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
+ * call this method again with an empty string to flush the stream:
+ *
+ * inflater = Zlib::Inflate.new
+ *
+ * begin
+ * out = inflater.inflate compressed
+ * rescue Zlib::NeedDict
+ * # ensure the dictionary matches the stream's required dictionary
+ * raise unless inflater.adler == Zlib.adler32(dictionary)
+ *
+ * inflater.set_dictionary dictionary
+ * inflater.inflate ''
+ * end
+ *
+ * # ...
+ *
+ * inflater.close
+ *
+ * See also Zlib::Inflate.new
+ */
+static VALUE
+rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
+{
+ struct zstream *z = get_zstream(obj);
+ struct rb_zlib_inflate_arguments arguments = {z, argc, argv};
+ return rb_mutex_synchronize(z->mutex, rb_inflate_inflate_body, (VALUE)&arguments);
+}
+
+/*
* call-seq: << string
*
* Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
@@ -2377,17 +2449,16 @@ struct gzfile {
#define GZFILE_READ_SIZE 2048
+enum { read_raw_arg_len, read_raw_arg_buf, read_raw_arg__count};
struct read_raw_arg {
VALUE io;
- union {
- const VALUE argv[2]; /* for rb_funcallv */
- struct {
- VALUE len;
- VALUE buf;
- } in;
- } as;
+ const VALUE argv[read_raw_arg__count]; /* for rb_funcallv */
};
+#define read_raw_arg_argc(ra) \
+ ((int)read_raw_arg__count - NIL_P((ra)->argv[read_raw_arg__count - 1]))
+#define read_raw_arg_init(io, len, buf) { io, { len, buf } }
+
static void
gzfile_mark(void *p)
{
@@ -2513,9 +2584,9 @@ gzfile_read_raw_partial(VALUE arg)
{
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
VALUE str;
- int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
+ int argc = read_raw_arg_argc(ra);
- str = rb_funcallv(ra->io, id_readpartial, argc, ra->as.argv);
+ str = rb_funcallv(ra->io, id_readpartial, argc, ra->argv);
Check_Type(str, T_STRING);
return str;
}
@@ -2526,8 +2597,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
struct read_raw_arg *ra = (struct read_raw_arg *)arg;
VALUE str = Qnil;
if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
- int argc = NIL_P(ra->as.argv[1]) ? 1 : 2;
- str = rb_funcallv(ra->io, id_read, argc, ra->as.argv);
+ int argc = read_raw_arg_argc(ra);
+ str = rb_funcallv(ra->io, id_read, argc, ra->argv);
if (!NIL_P(str)) {
Check_Type(str, T_STRING);
}
@@ -2538,11 +2609,8 @@ gzfile_read_raw_rescue(VALUE arg, VALUE _)
static VALUE
gzfile_read_raw(struct gzfile *gz, VALUE outbuf)
{
- struct read_raw_arg ra;
-
- ra.io = gz->io;
- ra.as.in.len = INT2FIX(GZFILE_READ_SIZE);
- ra.as.in.buf = outbuf;
+ struct read_raw_arg ra =
+ read_raw_arg_init(gz->io, INT2FIX(GZFILE_READ_SIZE), outbuf);
return rb_rescue2(gzfile_read_raw_partial, (VALUE)&ra,
gzfile_read_raw_rescue, (VALUE)&ra,
@@ -2874,18 +2942,18 @@ gzfile_newstr(struct gzfile *gz, VALUE str)
}
static long
-gzfile_fill(struct gzfile *gz, long len)
+gzfile_fill(struct gzfile *gz, long len, VALUE outbuf)
{
if (len < 0)
rb_raise(rb_eArgError, "negative length %ld given", len);
if (len == 0)
return 0;
while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) < len) {
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz, outbuf);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz, outbuf);
}
return -1;
}
@@ -2893,14 +2961,27 @@ gzfile_fill(struct gzfile *gz, long len)
}
static VALUE
-gzfile_read(struct gzfile *gz, long len)
+gzfile_read(struct gzfile *gz, long len, VALUE outbuf)
{
VALUE dst;
- len = gzfile_fill(gz, len);
- if (len == 0) return rb_str_new(0, 0);
- if (len < 0) return Qnil;
- dst = zstream_shift_buffer(&gz->z, len);
+ len = gzfile_fill(gz, len, outbuf);
+
+ if (len < 0) {
+ if (!NIL_P(outbuf))
+ rb_str_resize(outbuf, 0);
+ return Qnil;
+ }
+ if (len == 0) {
+ if (NIL_P(outbuf))
+ return rb_str_new(0, 0);
+ else {
+ rb_str_resize(outbuf, 0);
+ return outbuf;
+ }
+ }
+
+ dst = zstream_shift_buffer(&gz->z, len, outbuf);
if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
return dst;
}
@@ -2933,29 +3014,26 @@ gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
rb_raise(rb_eEOFError, "end of file reached");
}
- dst = zstream_shift_buffer(&gz->z, len);
+ dst = zstream_shift_buffer(&gz->z, len, outbuf);
gzfile_calc_crc(gz, dst);
- if (!NIL_P(outbuf)) {
- rb_str_resize(outbuf, RSTRING_LEN(dst));
- memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
- dst = outbuf;
- }
return dst;
}
static VALUE
-gzfile_read_all(struct gzfile *gz)
+gzfile_read_all(struct gzfile *gz, VALUE dst)
{
- VALUE dst;
-
while (!ZSTREAM_IS_FINISHED(&gz->z)) {
- gzfile_read_more(gz, Qnil);
+ gzfile_read_more(gz, dst);
}
if (GZFILE_IS_FINISHED(gz)) {
if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz, Qnil);
+ gzfile_check_footer(gz, dst);
}
+ if (!NIL_P(dst)) {
+ rb_str_resize(dst, 0);
+ return dst;
+ }
return rb_str_new(0, 0);
}
@@ -2993,7 +3071,7 @@ gzfile_getc(struct gzfile *gz)
de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
(void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
rb_econv_check_error(gz->ec);
- dst = zstream_shift_buffer(&gz->z, sp - ss);
+ dst = zstream_shift_buffer(&gz->z, sp - ss, Qnil);
gzfile_calc_crc(gz, dst);
rb_str_resize(cbuf, dp - ds);
return cbuf;
@@ -3001,7 +3079,7 @@ gzfile_getc(struct gzfile *gz)
else {
buf = gz->z.buf;
len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
- dst = gzfile_read(gz, len);
+ dst = gzfile_read(gz, len, Qnil);
if (NIL_P(dst)) return dst;
return gzfile_newstr(gz, dst);
}
@@ -3500,6 +3578,9 @@ static VALUE
rb_gzfile_eof_p(VALUE obj)
{
struct gzfile *gz = get_gzfile(obj);
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && ZSTREAM_BUF_FILLED(&gz->z) == 0) {
+ gzfile_read_more(gz, Qnil);
+ }
return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse;
}
@@ -3906,7 +3987,7 @@ rb_gzreader_s_zcat(int argc, VALUE *argv, VALUE klass)
if (!buf) {
buf = rb_str_new(0, 0);
}
- tmpbuf = gzfile_read_all(get_gzfile(obj));
+ tmpbuf = gzfile_read_all(get_gzfile(obj), Qnil);
rb_str_cat(buf, RSTRING_PTR(tmpbuf), RSTRING_LEN(tmpbuf));
}
@@ -4008,19 +4089,19 @@ static VALUE
rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
{
struct gzfile *gz = get_gzfile(obj);
- VALUE vlen;
+ VALUE vlen, outbuf;
long len;
- rb_scan_args(argc, argv, "01", &vlen);
+ rb_scan_args(argc, argv, "02", &vlen, &outbuf);
if (NIL_P(vlen)) {
- return gzfile_read_all(gz);
+ return gzfile_read_all(gz, outbuf);
}
len = NUM2INT(vlen);
if (len < 0) {
rb_raise(rb_eArgError, "negative length %ld given", len);
}
- return gzfile_read(gz, len);
+ return gzfile_read(gz, len, outbuf);
}
/*
@@ -4029,7 +4110,7 @@ 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
+ * Reads at most <i>maxlen</i> bytes from the gzipped 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.
@@ -4093,7 +4174,7 @@ rb_gzreader_getbyte(VALUE obj)
struct gzfile *gz = get_gzfile(obj);
VALUE dst;
- dst = gzfile_read(gz, 1);
+ dst = gzfile_read(gz, 1, Qnil);
if (!NIL_P(dst)) {
dst = INT2FIX((unsigned int)(RSTRING_PTR(dst)[0]) & 0xff);
}
@@ -4204,6 +4285,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
while (n++, *(p++) == '\n') {
if (n >= ZSTREAM_BUF_FILLED(&gz->z)) {
str = zstream_detach_buffer(&gz->z);
+ ASSUME(!NIL_P(str));
gzfile_calc_crc(gz, str);
while (ZSTREAM_BUF_FILLED(&gz->z) == 0) {
if (GZFILE_IS_FINISHED(gz)) return;
@@ -4214,7 +4296,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
}
}
- str = zstream_shift_buffer(&gz->z, n - 1);
+ str = zstream_shift_buffer(&gz->z, n - 1, Qnil);
gzfile_calc_crc(gz, str);
}
@@ -4235,7 +4317,7 @@ gzreader_charboundary(struct gzfile *gz, long n)
if (l < n) {
int n_bytes = rb_enc_precise_mbclen(p, e, gz->enc);
if (MBCLEN_NEEDMORE_P(n_bytes)) {
- if ((l = gzfile_fill(gz, n + MBCLEN_NEEDMORE_LEN(n_bytes))) > 0) {
+ if ((l = gzfile_fill(gz, n + MBCLEN_NEEDMORE_LEN(n_bytes), Qnil)) > 0) {
return l;
}
}
@@ -4287,10 +4369,10 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
if (NIL_P(rs)) {
if (limit < 0) {
- dst = gzfile_read_all(gz);
+ dst = gzfile_read_all(gz, Qnil);
if (RSTRING_LEN(dst) == 0) return Qnil;
}
- else if ((n = gzfile_fill(gz, limit)) <= 0) {
+ else if ((n = gzfile_fill(gz, limit, Qnil)) <= 0) {
return Qnil;
}
else {
@@ -4300,7 +4382,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
else {
n = limit;
}
- dst = zstream_shift_buffer(&gz->z, n);
+ dst = zstream_shift_buffer(&gz->z, n, Qnil);
if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
dst = gzfile_newstr(gz, dst);
@@ -4327,7 +4409,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
while (ZSTREAM_BUF_FILLED(&gz->z) < rslen) {
if (ZSTREAM_IS_FINISHED(&gz->z)) {
if (ZSTREAM_BUF_FILLED(&gz->z) > 0) gz->lineno++;
- return gzfile_read(gz, rslen);
+ return gzfile_read(gz, rslen, Qnil);
}
gzfile_read_more(gz, Qnil);
}
@@ -4364,7 +4446,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
}
gz->lineno++;
- dst = gzfile_read(gz, n);
+ dst = gzfile_read(gz, n, Qnil);
if (NIL_P(dst)) return dst;
if (rspara) {
gzreader_skip_linebreaks(gz);
@@ -4612,6 +4694,7 @@ zlib_gunzip_run(VALUE arg)
gzfile_read_header(gz, Qnil);
dst = zstream_detach_buffer(&gz->z);
+ ASSUME(!NIL_P(dst));
gzfile_calc_crc(gz, dst);
if (!ZSTREAM_IS_FINISHED(&gz->z)) {
rb_raise(cGzError, "unexpected end of file");
diff --git a/ext/zlib/zlib.gemspec b/ext/zlib/zlib.gemspec
index 4a5f8f2ee8..345dc5f225 100644
--- a/ext/zlib/zlib.gemspec
+++ b/ext/zlib/zlib.gemspec
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/zlib"
spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.files = ["LICENSE.txt", "README.md", "ext/zlib/extconf.rb", "ext/zlib/zlib.c", "zlib.gemspec"]
+ spec.files = ["COPYING", "BSDL", "README.md", "ext/zlib/extconf.rb", "ext/zlib/zlib.c", "zlib.gemspec"]
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
spec.extensions = "ext/zlib/extconf.rb"
- spec.required_ruby_version = ">= 2.3.0"
+ spec.required_ruby_version = ">= 2.5.0"
end
diff --git a/file.c b/file.c
index 68122de6ae..c4a531d783 100644
--- a/file.c
+++ b/file.c
@@ -12,6 +12,7 @@
**********************************************************************/
#include "ruby/internal/config.h"
+#include "ruby/internal/attr/nonstring.h"
#ifdef _WIN32
# include "missing/file.h"
@@ -131,6 +132,14 @@ int flock(int, int);
# define STAT(p, s) stat((p), (s))
#endif /* _WIN32 */
+#ifdef HAVE_STRUCT_STATX_STX_BTIME
+# define ST_(name) stx_ ## name
+typedef struct statx_timestamp stat_timestamp;
+#else
+# define ST_(name) st_ ## name
+typedef struct timespec stat_timestamp;
+#endif
+
#if defined _WIN32 || defined __APPLE__
# define USE_OSPATH 1
# define TO_OSPATH(str) rb_str_encode_ospath(str)
@@ -160,6 +169,7 @@ int flock(int, int);
#include "internal.h"
#include "internal/compilers.h"
#include "internal/dir.h"
+#include "internal/encoding.h"
#include "internal/error.h"
#include "internal/file.h"
#include "internal/io.h"
@@ -169,10 +179,16 @@ int flock(int, int);
#include "internal/thread.h"
#include "internal/vm.h"
#include "ruby/encoding.h"
-#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
+#define UIANY2NUM(x) \
+ ((sizeof(x) <= sizeof(unsigned int)) ? \
+ UINT2NUM((unsigned)(x)) : \
+ (sizeof(x) <= sizeof(unsigned long)) ? \
+ ULONG2NUM((unsigned long)(x)) : \
+ ULL2NUM((unsigned LONG_LONG)(x)))
+
VALUE rb_cFile;
VALUE rb_mFileTest;
VALUE rb_cStat;
@@ -198,15 +214,16 @@ file_path_convert(VALUE name)
return name;
}
-static rb_encoding *
+static void
check_path_encoding(VALUE str)
{
- rb_encoding *enc = rb_enc_get(str);
- if (!rb_enc_asciicompat(enc)) {
- rb_raise(rb_eEncCompatError, "path name must be ASCII-compatible (%s): %"PRIsVALUE,
- rb_enc_name(enc), rb_str_inspect(str));
+ if (RB_UNLIKELY(!rb_str_enc_fastpath(str))) {
+ rb_encoding *enc = rb_str_enc_get(str);
+ if (!rb_enc_asciicompat(enc)) {
+ rb_raise(rb_eEncCompatError, "path name must be ASCII-compatible (%s): %"PRIsVALUE,
+ rb_enc_name(enc), rb_str_inspect(str));
+ }
}
- return enc;
}
VALUE
@@ -228,13 +245,20 @@ VALUE
rb_get_path_check_convert(VALUE obj)
{
obj = file_path_convert(obj);
+ rb_get_path_check_no_convert(obj);
+ return rb_str_new_frozen(obj);
+}
+/* TODO: name */
+VALUE
+rb_get_path_check_no_convert(VALUE obj)
+{
check_path_encoding(obj);
if (!rb_str_to_cstr(obj)) {
rb_raise(rb_eArgError, "path name contains null byte");
}
- return rb_str_new4(obj);
+ return obj;
}
VALUE
@@ -249,6 +273,19 @@ rb_get_path(VALUE obj)
return rb_get_path_check_convert(rb_get_path_check_to_string(obj));
}
+static inline VALUE
+check_path(VALUE obj, const char **cstr)
+{
+ VALUE str = rb_get_path_check_convert(rb_get_path_check_to_string(obj));
+#if RUBY_DEBUG
+ str = rb_str_new_frozen(str);
+#endif
+ *cstr = RSTRING_PTR(str);
+ return str;
+}
+
+#define CheckPath(str, cstr) RB_GC_GUARD(str) = check_path(str, &cstr);
+
VALUE
rb_str_encode_ospath(VALUE path)
{
@@ -272,6 +309,18 @@ rb_str_encode_ospath(VALUE path)
# define NORMALIZE_UTF8PATH 1
# ifdef HAVE_WORKING_FORK
+static CFMutableStringRef
+mutable_CFString_new(CFStringRef *s, const char *ptr, long len)
+{
+ const CFAllocatorRef alloc = kCFAllocatorDefault;
+ *s = CFStringCreateWithBytesNoCopy(alloc, (const UInt8 *)ptr, len,
+ kCFStringEncodingUTF8, FALSE,
+ kCFAllocatorNull);
+ return CFStringCreateMutableCopy(alloc, len, *s);
+}
+
+# define mutable_CFString_release(m, s) (CFRelease(m), CFRelease(s))
+
static void
rb_CFString_class_initialize_before_fork(void)
{
@@ -298,15 +347,17 @@ rb_CFString_class_initialize_before_fork(void)
/* Enough small but non-empty ASCII string to fit in NSTaggedPointerString. */
const char small_str[] = "/";
long len = sizeof(small_str) - 1;
-
- const CFAllocatorRef alloc = kCFAllocatorDefault;
- CFStringRef s = CFStringCreateWithBytesNoCopy(alloc,
- (const UInt8 *)small_str,
- len, kCFStringEncodingUTF8,
- FALSE, kCFAllocatorNull);
- CFMutableStringRef m = CFStringCreateMutableCopy(alloc, len, s);
- CFRelease(m);
- CFRelease(s);
+ CFStringRef s;
+ /*
+ * Touch `CFStringCreateWithBytesNoCopy` *twice* because the implementation
+ * shipped with macOS 15.0 24A5331b does not return `NSTaggedPointerString`
+ * instance for the first call (totally not sure why). CoreFoundation
+ * shipped with macOS 15.1 does not have this issue.
+ */
+ for (int i = 0; i < 2; i++) {
+ CFMutableStringRef m = mutable_CFString_new(&s, small_str, len);
+ mutable_CFString_release(m, s);
+ }
}
# endif /* HAVE_WORKING_FORK */
@@ -315,11 +366,8 @@ rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len)
{
CFIndex buflen = 0;
CFRange all;
- CFStringRef s = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
- (const UInt8 *)ptr, len,
- kCFStringEncodingUTF8, FALSE,
- kCFAllocatorNull);
- CFMutableStringRef m = CFStringCreateMutableCopy(kCFAllocatorDefault, len, s);
+ CFStringRef s;
+ CFMutableStringRef m = mutable_CFString_new(&s, ptr, len);
long oldlen = RSTRING_LEN(str);
CFStringNormalize(m, kCFStringNormalizationFormC);
@@ -329,8 +377,7 @@ rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len)
CFStringGetBytes(m, all, kCFStringEncodingUTF8, '?', FALSE,
(UInt8 *)(RSTRING_PTR(str) + oldlen), buflen, &buflen);
rb_str_set_len(str, oldlen + buflen);
- CFRelease(m);
- CFRelease(s);
+ mutable_CFString_release(m, s);
return str;
}
@@ -340,16 +387,22 @@ rb_str_normalize_ospath(const char *ptr, long len)
const char *p = ptr;
const char *e = ptr + len;
const char *p1 = p;
- VALUE str = rb_str_buf_new(len);
rb_encoding *enc = rb_utf8_encoding();
- rb_enc_associate(str, enc);
+ VALUE str = rb_utf8_str_new(ptr, len);
+ if (RB_LIKELY(rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)) {
+ return str;
+ }
+ else {
+ str = rb_str_buf_new(len);
+ rb_enc_associate(str, enc);
+ }
while (p < e) {
int l, c;
int r = rb_enc_precise_mbclen(p, e, enc);
if (!MBCLEN_CHARFOUND_P(r)) {
/* invalid byte shall not happen but */
- static const char invalid[3] = "\xEF\xBF\xBD";
+ RBIMPL_ATTR_NONSTRING() static const char invalid[3] = "\xEF\xBF\xBD";
rb_str_append_normalized_ospath(str, p1, p-p1);
rb_str_cat(str, invalid, sizeof(invalid));
p += 1;
@@ -469,7 +522,7 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
aa->fn[aa->i].path = path;
}
- rb_thread_call_without_gvl(no_gvl_apply2files, aa, RUBY_UBF_IO, 0);
+ IO_WITHOUT_GVL(no_gvl_apply2files, aa);
if (aa->errnum) {
#ifdef UTIME_EINVAL
if (func == utime_internal) {
@@ -484,70 +537,135 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
return LONG2FIX(argc);
}
-static size_t
-stat_memsize(const void *p)
-{
- return sizeof(struct stat);
-}
+static stat_timestamp stat_atimespec(const struct stat *st);
+static stat_timestamp stat_mtimespec(const struct stat *st);
+static stat_timestamp stat_ctimespec(const struct stat *st);
static const rb_data_type_t stat_data_type = {
"stat",
- {NULL, RUBY_TYPED_DEFAULT_FREE, stat_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+ {
+ NULL,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // No external memory to report
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
-static VALUE
-stat_new_0(VALUE klass, const struct stat *st)
+struct rb_stat {
+ rb_io_stat_data stat;
+ bool initialized;
+};
+
+static struct rb_stat *
+stat_alloc(VALUE klass, VALUE *obj)
{
- struct stat *nst = 0;
- VALUE obj = TypedData_Wrap_Struct(klass, &stat_data_type, 0);
+ struct rb_stat *rb_st;
+ *obj = TypedData_Make_Struct(klass, struct rb_stat, &stat_data_type, rb_st);
+ return rb_st;
+}
+VALUE
+rb_stat_new(const struct stat *st)
+{
+ VALUE obj;
+ struct rb_stat *rb_st = stat_alloc(rb_cStat, &obj);
if (st) {
- nst = ALLOC(struct stat);
- *nst = *st;
- RTYPEDDATA_DATA(obj) = nst;
+#if RUBY_USE_STATX
+# define CP(m) .stx_ ## m = st->st_ ## m
+# define CP_32(m) .stx_ ## m = (uint32_t)st->st_ ## m
+# define CP_TS(m) .stx_ ## m = stat_ ## m ## spec(st)
+ rb_st->stat = (struct statx){
+ .stx_mask = STATX_BASIC_STATS,
+ CP(mode),
+ CP_32(nlink),
+ CP(uid),
+ CP(gid),
+ CP_TS(atime),
+ CP_TS(mtime),
+ CP_TS(ctime),
+ CP(ino),
+ CP(size),
+ CP(blocks),
+ };
+# undef CP
+# undef CP_TS
+#else
+ rb_st->stat = *st;
+#endif
+ rb_st->initialized = true;
}
+
return obj;
}
+#ifndef rb_statx_new
VALUE
-rb_stat_new(const struct stat *st)
+rb_statx_new(const rb_io_stat_data *st)
{
- return stat_new_0(rb_cStat, st);
+ VALUE obj;
+ struct rb_stat *rb_st = stat_alloc(rb_cStat, &obj);
+ if (st) {
+ rb_st->stat = *st;
+ rb_st->initialized = true;
+ }
+ return obj;
}
+#endif
-static struct stat*
+static rb_io_stat_data*
get_stat(VALUE self)
{
- struct stat* st;
- TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
- if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat");
- return st;
+ struct rb_stat* rb_st;
+ TypedData_Get_Struct(self, struct rb_stat, &stat_data_type, rb_st);
+ if (!rb_st->initialized) rb_raise(rb_eTypeError, "uninitialized File::Stat");
+ return &rb_st->stat;
}
-static struct timespec stat_mtimespec(const struct stat *st);
+#if RUBY_USE_STATX
+static stat_timestamp
+statx_mtimespec(const rb_io_stat_data *st)
+{
+ return st->stx_mtime;
+}
+#else
+# define statx_mtimespec stat_mtimespec
+#endif
/*
* call-seq:
- * stat <=> other_stat -> -1, 0, 1, nil
+ * self <=> other -> -1, 0, 1, or nil
+ *
+ * Compares +self+ and +other+, by comparing their modification times;
+ * that is, by comparing <tt>self.mtime</tt> and <tt>other.mtime</tt>.
*
- * Compares File::Stat objects by comparing their respective modification
- * times.
+ * Returns:
*
- * +nil+ is returned if +other_stat+ is not a File::Stat object
+ * - +-1+, if <tt>self.mtime</tt> is earlier.
+ * - +0+, if the two values are equal.
+ * - +1+, if <tt>self.mtime</tt> is later.
+ * - +nil+, if +other+ is not a File::Stat object.
*
- * f1 = File.new("f1", "w")
- * sleep 1
- * f2 = File.new("f2", "w")
- * f1.stat <=> f2.stat #=> -1
+ * Examples:
+ *
+ * stat0 = File.stat('README.md')
+ * stat1 = File.stat('NEWS.md')
+ * stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
+ * stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
+ * stat0 <=> stat1 # => -1
+ * stat0 <=> stat0.dup # => 0
+ * stat1 <=> stat0 # => 1
+ * stat0 <=> :foo # => nil
+ *
+ * \Class \File::Stat includes module Comparable,
+ * each of whose methods uses File::Stat#<=> for comparison.
*/
static VALUE
rb_stat_cmp(VALUE self, VALUE 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));
+ stat_timestamp ts1 = statx_mtimespec(get_stat(self));
+ stat_timestamp ts2 = statx_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);
@@ -584,7 +702,11 @@ rb_stat_cmp(VALUE self, VALUE other)
static VALUE
rb_stat_dev(VALUE self)
{
-#if SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_DEV_T
+#if RUBY_USE_STATX
+ unsigned int m = get_stat(self)->stx_dev_major;
+ unsigned int n = get_stat(self)->stx_dev_minor;
+ return ULL2NUM(makedev(m, n));
+#elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_DEV_T
return DEVT2NUM(get_stat(self)->st_dev);
#elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_LONG
return ULONG2NUM(get_stat(self)->st_dev);
@@ -607,7 +729,9 @@ rb_stat_dev(VALUE self)
static VALUE
rb_stat_dev_major(VALUE self)
{
-#if defined(major)
+#if RUBY_USE_STATX
+ return UINT2NUM(get_stat(self)->stx_dev_major);
+#elif defined(major)
return UINT2NUM(major(get_stat(self)->st_dev));
#else
return Qnil;
@@ -628,7 +752,9 @@ rb_stat_dev_major(VALUE self)
static VALUE
rb_stat_dev_minor(VALUE self)
{
-#if defined(minor)
+#if RUBY_USE_STATX
+ return UINT2NUM(get_stat(self)->stx_dev_minor);
+#elif defined(minor)
return UINT2NUM(minor(get_stat(self)->st_dev));
#else
return Qnil;
@@ -648,16 +774,15 @@ rb_stat_dev_minor(VALUE self)
static VALUE
rb_stat_ino(VALUE self)
{
+ rb_io_stat_data *ptr = get_stat(self);
#ifdef HAVE_STRUCT_STAT_ST_INOHIGH
/* assume INTEGER_PACK_LSWORD_FIRST and st_inohigh is just next of st_ino */
- return rb_integer_unpack(&get_stat(self)->st_ino, 2,
+ return rb_integer_unpack(&ptr->st_ino, 2,
SIZEOF_STRUCT_STAT_ST_INO, 0,
INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER|
INTEGER_PACK_2COMP);
-#elif SIZEOF_STRUCT_STAT_ST_INO > SIZEOF_LONG
- return ULL2NUM(get_stat(self)->st_ino);
#else
- return ULONG2NUM(get_stat(self)->st_ino);
+ return UIANY2NUM(ptr->ST_(ino));
#endif
}
@@ -677,7 +802,7 @@ rb_stat_ino(VALUE self)
static VALUE
rb_stat_mode(VALUE self)
{
- return UINT2NUM(ST2UINT(get_stat(self)->st_mode));
+ return UINT2NUM(ST2UINT(get_stat(self)->ST_(mode)));
}
/*
@@ -696,20 +821,9 @@ static VALUE
rb_stat_nlink(VALUE self)
{
/* struct stat::st_nlink is nlink_t in POSIX. Not the case for Windows. */
- const struct stat *ptr = get_stat(self);
+ const rb_io_stat_data *ptr = get_stat(self);
- if (sizeof(ptr->st_nlink) <= sizeof(int)) {
- return UINT2NUM((unsigned)ptr->st_nlink);
- }
- else if (sizeof(ptr->st_nlink) == sizeof(long)) {
- return ULONG2NUM((unsigned long)ptr->st_nlink);
- }
- else if (sizeof(ptr->st_nlink) == sizeof(LONG_LONG)) {
- return ULL2NUM((unsigned LONG_LONG)ptr->st_nlink);
- }
- else {
- rb_bug(":FIXME: don't know what to do");
- }
+ return UIANY2NUM(ptr->ST_(nlink));
}
/*
@@ -725,7 +839,7 @@ rb_stat_nlink(VALUE self)
static VALUE
rb_stat_uid(VALUE self)
{
- return UIDT2NUM(get_stat(self)->st_uid);
+ return UIDT2NUM(get_stat(self)->ST_(uid));
}
/*
@@ -741,7 +855,7 @@ rb_stat_uid(VALUE self)
static VALUE
rb_stat_gid(VALUE self)
{
- return GIDT2NUM(get_stat(self)->st_gid);
+ return GIDT2NUM(get_stat(self)->ST_(gid));
}
/*
@@ -759,16 +873,18 @@ rb_stat_gid(VALUE self)
static VALUE
rb_stat_rdev(VALUE self)
{
-#ifdef HAVE_STRUCT_STAT_ST_RDEV
-# if SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_DEV_T
- return DEVT2NUM(get_stat(self)->st_rdev);
-# elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_LONG
- return ULONG2NUM(get_stat(self)->st_rdev);
-# else
- return ULL2NUM(get_stat(self)->st_rdev);
-# endif
-#else
+#if RUBY_USE_STATX
+ unsigned int m = get_stat(self)->stx_rdev_major;
+ unsigned int n = get_stat(self)->stx_rdev_minor;
+ return ULL2NUM(makedev(m, n));
+#elif !defined(HAVE_STRUCT_STAT_ST_RDEV)
return Qnil;
+#elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_DEV_T
+ return DEVT2NUM(get_stat(self)->ST_(rdev));
+#elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_LONG
+ return ULONG2NUM(get_stat(self)->ST_(rdev));
+#else
+ return ULL2NUM(get_stat(self)->ST_(rdev));
#endif
}
@@ -786,8 +902,10 @@ rb_stat_rdev(VALUE self)
static VALUE
rb_stat_rdev_major(VALUE self)
{
-#if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(major)
- return UINT2NUM(major(get_stat(self)->st_rdev));
+#if RUBY_USE_STATX
+ return UINT2NUM(get_stat(self)->stx_rdev_major);
+#elif defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(major)
+ return UINT2NUM(major(get_stat(self)->ST_(rdev)));
#else
return Qnil;
#endif
@@ -807,8 +925,10 @@ rb_stat_rdev_major(VALUE self)
static VALUE
rb_stat_rdev_minor(VALUE self)
{
-#if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(minor)
- return UINT2NUM(minor(get_stat(self)->st_rdev));
+#if RUBY_USE_STATX
+ return UINT2NUM(get_stat(self)->stx_rdev_minor);
+#elif defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(minor)
+ return UINT2NUM(minor(get_stat(self)->ST_(rdev)));
#else
return Qnil;
#endif
@@ -826,7 +946,7 @@ rb_stat_rdev_minor(VALUE self)
static VALUE
rb_stat_size(VALUE self)
{
- return OFFT2NUM(get_stat(self)->st_size);
+ return OFFT2NUM(get_stat(self)->ST_(size));
}
/*
@@ -844,7 +964,7 @@ static VALUE
rb_stat_blksize(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
- return ULONG2NUM(get_stat(self)->st_blksize);
+ return ULONG2NUM(get_stat(self)->ST_(blksize));
#else
return Qnil;
#endif
@@ -866,34 +986,44 @@ rb_stat_blocks(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
# if SIZEOF_STRUCT_STAT_ST_BLOCKS > SIZEOF_LONG
- return ULL2NUM(get_stat(self)->st_blocks);
+ return ULL2NUM(get_stat(self)->ST_(blocks));
# else
- return ULONG2NUM(get_stat(self)->st_blocks);
+ return ULONG2NUM(get_stat(self)->ST_(blocks));
# endif
#else
return Qnil;
#endif
}
-static struct timespec
+static stat_timestamp
stat_atimespec(const struct stat *st)
{
- struct timespec ts;
+ stat_timestamp ts;
ts.tv_sec = st->st_atime;
#if defined(HAVE_STRUCT_STAT_ST_ATIM)
- ts.tv_nsec = st->st_atim.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_atim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
- ts.tv_nsec = st->st_atimespec.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_atimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
- ts.tv_nsec = (long)st->st_atimensec;
+ ts.tv_nsec = (uint32_t)st->st_atimensec;
#else
- ts.tv_nsec = 0;
+ ts.tv_nsec = 0
#endif
return ts;
}
+#if RUBY_USE_STATX
+static stat_timestamp
+statx_atimespec(const rb_io_stat_data *st)
+{
+ return st->stx_atime;
+}
+#else
+# define statx_atimespec stat_atimespec
+#endif
+
static VALUE
-stat_time(const struct timespec ts)
+stat_time(const stat_timestamp ts)
{
return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
}
@@ -904,17 +1034,17 @@ stat_atime(const struct stat *st)
return stat_time(stat_atimespec(st));
}
-static struct timespec
+static stat_timestamp
stat_mtimespec(const struct stat *st)
{
- struct timespec ts;
+ stat_timestamp ts;
ts.tv_sec = st->st_mtime;
#if defined(HAVE_STRUCT_STAT_ST_MTIM)
- ts.tv_nsec = st->st_mtim.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_mtim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
- ts.tv_nsec = st->st_mtimespec.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_mtimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
- ts.tv_nsec = (long)st->st_mtimensec;
+ ts.tv_nsec = (uint32_t)st->st_mtimensec;
#else
ts.tv_nsec = 0;
#endif
@@ -927,23 +1057,33 @@ stat_mtime(const struct stat *st)
return stat_time(stat_mtimespec(st));
}
-static struct timespec
+static stat_timestamp
stat_ctimespec(const struct stat *st)
{
- struct timespec ts;
+ stat_timestamp ts;
ts.tv_sec = st->st_ctime;
#if defined(HAVE_STRUCT_STAT_ST_CTIM)
- ts.tv_nsec = st->st_ctim.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_ctim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
- ts.tv_nsec = st->st_ctimespec.tv_nsec;
+ ts.tv_nsec = (uint32_t)st->st_ctimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC)
- ts.tv_nsec = (long)st->st_ctimensec;
+ ts.tv_nsec = (uint32_t)st->st_ctimensec;
#else
ts.tv_nsec = 0;
#endif
return ts;
}
+#if RUBY_USE_STATX
+static stat_timestamp
+statx_ctimespec(const rb_io_stat_data *st)
+{
+ return st->stx_ctime;
+}
+#else
+# define statx_ctimespec stat_ctimespec
+#endif
+
static VALUE
stat_ctime(const struct stat *st)
{
@@ -952,35 +1092,50 @@ stat_ctime(const struct stat *st)
#define HAVE_STAT_BIRTHTIME
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
-typedef struct stat statx_data;
static VALUE
-stat_birthtime(const struct stat *st)
+statx_birthtime(const rb_io_stat_data *st)
{
- const struct timespec *ts = &st->st_birthtimespec;
+ const stat_timestamp *ts = &st->ST_(birthtimespec);
return rb_time_nano_new(ts->tv_sec, ts->tv_nsec);
}
+#elif defined(HAVE_STRUCT_STATX_STX_BTIME)
+static VALUE statx_birthtime(const rb_io_stat_data *st);
#elif defined(_WIN32)
-typedef struct stat statx_data;
-# define stat_birthtime stat_ctime
+# define statx_birthtime stat_ctime
#else
# undef HAVE_STAT_BIRTHTIME
#endif /* defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) */
/*
* call-seq:
- * stat.atime -> time
- *
- * Returns the last access time for this file as an object of class
- * Time.
- *
- * File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
- *
+ * atime -> new_time
+ *
+ * Returns a new Time object containing the access time
+ * of the object represented by +self+
+ * at the time +self+ was created;
+ * see {Snapshot}[rdoc-ref:File::Stat@Snapshot]:
+ *
+ * filepath = 't.tmp'
+ * File.write(filepath, 'foo')
+ * file = File.new(filepath, 'w')
+ * stat = File::Stat.new(filepath)
+ * file.atime # => 2026-03-31 16:26:39.5913207 -0500
+ * stat.atime # => 2026-03-31 16:26:39.5913207 -0500
+ * File.write(filepath, 'bar')
+ * file.atime # => 2026-03-31 16:27:01.4981624 -0500 # Changed by access.
+ * stat.atime # => 2026-03-31 16:26:39.5913207 -0500 # Unchanged by access.
+ * stat = File::Stat.new(filepath)
+ * stat.atime # => 2026-03-31 16:27:01.4981624 -0500 # New access time.
+ * file.close
+ * File.delete(filepath)
+ *
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
static VALUE
rb_stat_atime(VALUE self)
{
- return stat_atime(get_stat(self));
+ return stat_time(statx_atimespec(get_stat(self)));
}
/*
@@ -996,7 +1151,7 @@ rb_stat_atime(VALUE self)
static VALUE
rb_stat_mtime(VALUE self)
{
- return stat_mtime(get_stat(self));
+ return stat_time(statx_mtimespec(get_stat(self)));
}
/*
@@ -1016,36 +1171,34 @@ rb_stat_mtime(VALUE self)
static VALUE
rb_stat_ctime(VALUE self)
{
- return stat_ctime(get_stat(self));
+ return stat_time(statx_ctimespec(get_stat(self)));
}
#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
- * stat.birthtime -> time
- *
- * Returns the birth time for <i>stat</i>.
- *
- * If the platform doesn't have birthtime, raises NotImplementedError.
- *
- * File.write("testfile", "foo")
- * sleep 10
- * File.write("testfile", "bar")
- * sleep 10
- * File.chmod(0644, "testfile")
- * sleep 10
- * File.read("testfile")
- * File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900
- * File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900
- * File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900
- * File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
- *
+ * birthtime -> new_time
+ *
+ * Returns a new Time object containing the create time
+ * of the object represented by +self+
+ * at the time +self+ was created;
+ * see {Snapshot}[rdoc-ref:File::Stat@Snapshot]:
+ *
+ * filename = 't.tmp'
+ * stat = File::Stat.new(filename) # Raises Errno::ENOENT: No such file or directory
+ * File.write(filename, 'foo')
+ * stat = File::Stat.new(filename)
+ * stat.birthtime # => 2026-04-14 10:41:55.5146554 -0500
+ * File.delete(filename)
+ * stat.birthtime # => 2026-04-14 10:41:55.5146554 -0500
+ *
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
static VALUE
rb_stat_birthtime(VALUE self)
{
- return stat_birthtime(get_stat(self));
+ return statx_birthtime(get_stat(self));
}
#else
# define rb_stat_birthtime rb_f_notimplement
@@ -1093,9 +1246,9 @@ rb_stat_inspect(VALUE self)
#endif
};
- struct stat* st;
- TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
- if (!st) {
+ struct rb_stat* rb_st;
+ TypedData_Get_Struct(self, struct rb_stat, &stat_data_type, rb_st);
+ if (!rb_st->initialized) {
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
}
@@ -1143,14 +1296,14 @@ no_gvl_fstat(void *data)
}
static int
-fstat_without_gvl(int fd, struct stat *st)
+fstat_without_gvl(rb_io_t *fptr, struct stat *st)
{
no_gvl_stat_data data;
- data.file.fd = fd;
+ data.file.fd = fptr->fd;
data.st = st;
- return (int)(VALUE)rb_thread_io_blocking_region(no_gvl_fstat, &data, fd);
+ return (int)rb_io_blocking_region(fptr, no_gvl_fstat, &data);
}
static void *
@@ -1168,13 +1321,14 @@ stat_without_gvl(const char *path, struct stat *st)
data.file.path = path;
data.st = st;
- return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_stat, &data,
- RUBY_UBF_IO, NULL);
+ return IO_WITHOUT_GVL_INT(no_gvl_stat, &data);
}
#if !defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) && \
defined(HAVE_STRUCT_STATX_STX_BTIME)
+# define STATX(path, st, mask) statx(AT_FDCWD, path, 0, mask, st)
+
# ifndef HAVE_STATX
# ifdef HAVE_SYSCALL_H
# include <syscall.h>
@@ -1192,18 +1346,18 @@ statx(int dirfd, const char *pathname, int flags,
# endif /* __linux__ */
# endif /* HAVE_STATX */
-typedef struct no_gvl_statx_data {
+typedef struct no_gvl_rb_io_stat_data {
struct statx *stx;
int fd;
const char *path;
int flags;
unsigned int mask;
-} no_gvl_statx_data;
+} no_gvl_rb_io_stat_data;
static VALUE
io_blocking_statx(void *data)
{
- no_gvl_statx_data *arg = data;
+ no_gvl_rb_io_stat_data *arg = data;
return (VALUE)statx(arg->fd, arg->path, arg->flags, arg->mask, arg->stx);
}
@@ -1214,24 +1368,34 @@ no_gvl_statx(void *data)
}
static int
-statx_without_gvl(const char *path, struct statx *stx, unsigned int mask)
+statx_without_gvl(const char *path, rb_io_stat_data *stx, unsigned int mask)
+{
+ no_gvl_rb_io_stat_data data = {stx, AT_FDCWD, path, 0, mask};
+
+ /* call statx(2) with pathname */
+ return IO_WITHOUT_GVL_INT(no_gvl_statx, &data);
+}
+
+static int
+lstatx_without_gvl(const char *path, rb_io_stat_data *stx, unsigned int mask)
{
- no_gvl_statx_data data = {stx, AT_FDCWD, path, 0, mask};
+ no_gvl_rb_io_stat_data data = {stx, AT_FDCWD, path, AT_SYMLINK_NOFOLLOW, mask};
/* call statx(2) with pathname */
- return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_statx, &data,
- RUBY_UBF_IO, NULL);
+ return IO_WITHOUT_GVL_INT(no_gvl_statx, &data);
}
static int
-fstatx_without_gvl(int fd, struct statx *stx, unsigned int mask)
+fstatx_without_gvl(rb_io_t *fptr, rb_io_stat_data *stx, unsigned int mask)
{
- no_gvl_statx_data data = {stx, fd, "", AT_EMPTY_PATH, mask};
+ no_gvl_rb_io_stat_data data = {stx, fptr->fd, "", AT_EMPTY_PATH, mask};
/* call statx(2) with fd */
- return (int)rb_thread_io_blocking_region(io_blocking_statx, &data, fd);
+ return (int)rb_io_blocking_region(fptr, io_blocking_statx, &data);
}
+#define FSTATX(fd, st) statx(fd, "", AT_EMPTY_PATH, STATX_ALL, st)
+
static int
rb_statx(VALUE file, struct statx *stx, unsigned int mask)
{
@@ -1241,8 +1405,9 @@ rb_statx(VALUE file, struct statx *stx, unsigned int mask)
tmp = rb_check_convert_type_with_id(file, T_FILE, "IO", idTo_io);
if (!NIL_P(tmp)) {
rb_io_t *fptr;
+
GetOpenFile(tmp, fptr);
- result = fstatx_without_gvl(fptr->fd, stx, mask);
+ result = fstatx_without_gvl(fptr, stx, mask);
file = tmp;
}
else {
@@ -1269,7 +1434,7 @@ statx_notimplement(const char *field_name)
}
static VALUE
-statx_birthtime(const struct statx *stx, VALUE fname)
+statx_birthtime(const rb_io_stat_data *stx)
{
if (!statx_has_birthtime(stx)) {
/* birthtime is not supported on the filesystem */
@@ -1278,20 +1443,27 @@ statx_birthtime(const struct statx *stx, VALUE fname)
return rb_time_nano_new((time_t)stx->stx_btime.tv_sec, stx->stx_btime.tv_nsec);
}
-typedef struct statx statx_data;
-# define HAVE_STAT_BIRTHTIME
+#else
-#elif defined(HAVE_STAT_BIRTHTIME)
# define statx_without_gvl(path, st, mask) stat_without_gvl(path, st)
-# define fstatx_without_gvl(fd, st, mask) fstat_without_gvl(fd, st)
-# define statx_birthtime(st, fname) stat_birthtime(st)
+# define fstatx_without_gvl(fptr, st, mask) fstat_without_gvl(fptr, st)
+# define lstatx_without_gvl(path, st, mask) lstat_without_gvl(path, st)
+# define rb_statx(file, stx, mask) rb_stat(file, stx)
+# define STATX(path, st, mask) STAT(path, st)
+
+#if defined(HAVE_STAT_BIRTHTIME)
# define statx_has_birthtime(st) 1
-# define rb_statx(file, st, mask) rb_stat(file, st)
#else
# define statx_has_birthtime(st) 0
+#endif
+
#endif /* !defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) && \
defined(HAVE_STRUCT_STATX_STX_BTIME) */
+#ifndef FSTAT
+# define FSTAT(fd, st) fstat(fd, st)
+#endif
+
static int
rb_stat(VALUE file, struct stat *st)
{
@@ -1303,7 +1475,7 @@ rb_stat(VALUE file, struct stat *st)
rb_io_t *fptr;
GetOpenFile(tmp, fptr);
- result = fstat_without_gvl(fptr->fd, st);
+ result = fstat_without_gvl(fptr, st);
file = tmp;
}
else {
@@ -1328,14 +1500,14 @@ rb_stat(VALUE file, struct stat *st)
static VALUE
rb_file_s_stat(VALUE klass, VALUE fname)
{
- struct stat st;
+ rb_io_stat_data st;
FilePathValue(fname);
fname = rb_str_encode_ospath(fname);
- if (stat_without_gvl(RSTRING_PTR(fname), &st) < 0) {
+ if (statx_without_gvl(RSTRING_PTR(fname), &st, STATX_ALL) < 0) {
rb_sys_fail_path(fname);
}
- return rb_stat_new(&st);
+ return rb_statx_new(&st);
}
/*
@@ -1357,13 +1529,13 @@ static VALUE
rb_io_stat(VALUE obj)
{
rb_io_t *fptr;
- struct stat st;
+ rb_io_stat_data st;
GetOpenFile(obj, fptr);
- if (fstat(fptr->fd, &st) == -1) {
+ if (fstatx_without_gvl(fptr, &st, STATX_ALL) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return rb_stat_new(&st);
+ return rb_statx_new(&st);
}
#ifdef HAVE_LSTAT
@@ -1382,8 +1554,7 @@ lstat_without_gvl(const char *path, struct stat *st)
data.file.path = path;
data.st = st;
- return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_lstat, &data,
- RUBY_UBF_IO, NULL);
+ return IO_WITHOUT_GVL_INT(no_gvl_lstat, &data);
}
#endif /* HAVE_LSTAT */
@@ -1404,14 +1575,14 @@ static VALUE
rb_file_s_lstat(VALUE klass, VALUE fname)
{
#ifdef HAVE_LSTAT
- struct stat st;
+ rb_io_stat_data st;
FilePathValue(fname);
fname = rb_str_encode_ospath(fname);
- if (lstat_without_gvl(StringValueCStr(fname), &st) == -1) {
+ if (lstatx_without_gvl(StringValueCStr(fname), &st, STATX_ALL) == -1) {
rb_sys_fail_path(fname);
}
- return rb_stat_new(&st);
+ return rb_statx_new(&st);
#else
return rb_file_s_stat(klass, fname);
#endif
@@ -1436,16 +1607,16 @@ rb_file_lstat(VALUE obj)
{
#ifdef HAVE_LSTAT
rb_io_t *fptr;
- struct stat st;
+ rb_io_stat_data st;
VALUE path;
GetOpenFile(obj, fptr);
if (NIL_P(fptr->pathv)) return Qnil;
path = rb_str_encode_ospath(fptr->pathv);
- if (lstat_without_gvl(RSTRING_PTR(path), &st) == -1) {
+ if (lstatx_without_gvl(RSTRING_PTR(path), &st, STATX_ALL) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return rb_stat_new(&st);
+ return rb_statx_new(&st);
#else
return rb_io_stat(obj);
#endif
@@ -1557,8 +1728,7 @@ rb_eaccess(VALUE fname, int mode)
aa.path = StringValueCStr(fname);
aa.mode = mode;
- return (int)(VALUE)rb_thread_call_without_gvl(nogvl_eaccess, &aa,
- RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL_INT(nogvl_eaccess, &aa);
}
static void *
@@ -1579,8 +1749,7 @@ rb_access(VALUE fname, int mode)
aa.path = StringValueCStr(fname);
aa.mode = mode;
- return (int)(VALUE)rb_thread_call_without_gvl(nogvl_access, &aa,
- RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL_INT(nogvl_access, &aa);
}
/*
@@ -1594,8 +1763,6 @@ rb_access(VALUE fname, int mode)
*/
/*
- * Document-method: directory?
- *
* call-seq:
* File.directory?(path) -> true or false
*
@@ -1774,7 +1941,7 @@ rb_file_blockdev_p(VALUE obj, VALUE fname)
*
* Returns +true+ if +filepath+ points to a character device, +false+ otherwise.
*
- * File.chardev?($stdin) # => true
+ * File.chardev?($stdin) # => true
* File.chardev?('t.txt') # => false
*
*/
@@ -2060,7 +2227,7 @@ rb_file_size_p(VALUE obj, VALUE fname)
* File.owned?(file_name) -> true or false
*
* Returns <code>true</code> if the named file exists and the
- * effective used id of the calling process is the owner of
+ * effective user id of the calling process is the owner of
* the file.
*
* _file_name_ can be an IO object.
@@ -2234,36 +2401,36 @@ rb_file_s_size(VALUE klass, VALUE fname)
}
static VALUE
-rb_file_ftype(const struct stat *st)
+rb_file_ftype(mode_t mode)
{
const char *t;
- if (S_ISREG(st->st_mode)) {
+ if (S_ISREG(mode)) {
t = "file";
}
- else if (S_ISDIR(st->st_mode)) {
+ else if (S_ISDIR(mode)) {
t = "directory";
}
- else if (S_ISCHR(st->st_mode)) {
+ else if (S_ISCHR(mode)) {
t = "characterSpecial";
}
#ifdef S_ISBLK
- else if (S_ISBLK(st->st_mode)) {
+ else if (S_ISBLK(mode)) {
t = "blockSpecial";
}
#endif
#ifdef S_ISFIFO
- else if (S_ISFIFO(st->st_mode)) {
+ else if (S_ISFIFO(mode)) {
t = "fifo";
}
#endif
#ifdef S_ISLNK
- else if (S_ISLNK(st->st_mode)) {
+ else if (S_ISLNK(mode)) {
t = "link";
}
#endif
#ifdef S_ISSOCK
- else if (S_ISSOCK(st->st_mode)) {
+ else if (S_ISSOCK(mode)) {
t = "socket";
}
#endif
@@ -2271,7 +2438,7 @@ rb_file_ftype(const struct stat *st)
t = "unknown";
}
- return rb_usascii_str_new2(t);
+ return rb_fstring_cstr(t);
}
/*
@@ -2300,19 +2467,30 @@ rb_file_s_ftype(VALUE klass, VALUE fname)
rb_sys_fail_path(fname);
}
- return rb_file_ftype(&st);
+ return rb_file_ftype(st.st_mode);
}
/*
* call-seq:
- * File.atime(file_name) -> time
+ * File.atime(object) -> new_time
*
- * Returns the last access time for the named file as a Time object.
+ * Returns a new Time object containing the time of the most recent
+ * access (read or write) to the object,
+ * which may be a string filepath or dirpath, or a File or Dir object:
*
- * _file_name_ can be an IO object.
+ * filepath = 't.tmp'
+ * File.exist?(filepath) # => false
+ * File.atime(filepath) # Raises Errno::ENOENT.
+ * File.write(filepath, 'foo')
+ * File.atime(filepath) # => 2026-03-31 16:39:37.9290772 -0500
+ * File.write(filepath, 'bar')
+ * File.atime(filepath) # => 2026-03-31 16:39:57.7710876 -0500
*
- * File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
+ * File.atime('.') # => 2026-03-31 16:47:49.0970483 -0500
+ * File.atime(File.new('README.md')) # => 2026-03-31 11:15:27.8215934 -0500
+ * File.atime(Dir.new('.')) # => 2026-03-31 12:39:45.5910591 -0500
*
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
static VALUE
@@ -2325,18 +2503,27 @@ rb_file_s_atime(VALUE klass, VALUE fname)
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
- return stat_atime(&st);
+ return stat_time(stat_atimespec(&st));
}
/*
* call-seq:
- * file.atime -> time
- *
- * Returns the last access time (a Time object) for <i>file</i>, or
- * epoch if <i>file</i> has not been accessed.
- *
- * File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
- *
+ * atime -> new_time
+ *
+ * Returns a new Time object containing the time of the most recent
+ * access (read or write) to the file represented by +self+:
+ *
+ * filepath = 't.tmp'
+ * file = File.new(filepath, 'a+')
+ * file.atime # => 2026-03-31 17:11:27.7285397 -0500
+ * file.write('foo')
+ * file.atime # => 2026-03-31 17:11:27.7285397 -0500 # Unchanged; not yet written.
+ * file.flush
+ * file.atime # => 2026-03-31 17:12:11.3408054 -0500 # Changed; now written.
+ * file.close
+ * File.delete(filename)
+ *
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
static VALUE
@@ -2349,7 +2536,7 @@ rb_file_atime(VALUE obj)
if (fstat(fptr->fd, &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return stat_atime(&st);
+ return stat_time(stat_atimespec(&st));
}
/*
@@ -2374,7 +2561,7 @@ rb_file_s_mtime(VALUE klass, VALUE fname)
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
- return stat_mtime(&st);
+ return stat_time(stat_mtimespec(&st));
}
/*
@@ -2397,7 +2584,7 @@ rb_file_mtime(VALUE obj)
if (fstat(fptr->fd, &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return stat_mtime(&st);
+ return stat_time(stat_mtimespec(&st));
}
/*
@@ -2426,7 +2613,7 @@ rb_file_s_ctime(VALUE klass, VALUE fname)
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
- return stat_ctime(&st);
+ return stat_time(stat_ctimespec(&st));
}
/*
@@ -2452,35 +2639,40 @@ rb_file_ctime(VALUE obj)
if (fstat(fptr->fd, &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return stat_ctime(&st);
+ return stat_time(stat_ctimespec(&st));
}
+#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
- * File.birthtime(file_name) -> time
+ * File.birthtime(entry_path) -> new_time
*
- * Returns the birth time for the named file.
+ * Returns a new Time object containing the create time
+ * of the entry at the given +path+:
*
- * _file_name_ can be an IO object.
- *
- * File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
- *
- * If the platform doesn't have birthtime, raises NotImplementedError.
+ * path = 't.tmp'
+ * File.birthtime(path) # Raises Errno::ENOENT: No such file or directory
+ * File.write(path, 'foo')
+ * File.birthtime(path) # => 2026-04-14 11:10:43.2891695 -0500
+ * File.write(path, 'bar')
+ * File.birthtime(path) # => 2026-04-14 11:10:43.2891695 -0500
+ * File.delete(path)
+ * File.birthtime(path) # Raises Errno::ENOENT: No such file or directory
*
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
-#if defined(HAVE_STAT_BIRTHTIME)
-RUBY_FUNC_EXPORTED VALUE
+VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
{
- statx_data st;
+ rb_io_stat_data st;
if (rb_statx(fname, &st, STATX_BTIME) < 0) {
int e = errno;
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
- return statx_birthtime(&st, fname);
+ return statx_birthtime(&st);
}
#else
# define rb_file_s_birthtime rb_f_notimplement
@@ -2489,42 +2681,39 @@ rb_file_s_birthtime(VALUE klass, VALUE fname)
#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
- * file.birthtime -> time
+ * birthtime -> new_time
*
- * Returns the birth time for <i>file</i>.
+ * Returns a new Time object containing the create time for +self+:
*
- * File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003
- *
- * If the platform doesn't have birthtime, raises NotImplementedError.
+ * filepath = 't.tmp'
+ * File.write(filepath, 'foo')
+ * file = File.new(filepath)
+ * file.birthtime # => 2026-04-14 15:53:45.002656 -0500
+ * File.write(filepath, 'bar')
+ * file.birthtime # => 2026-04-14 15:53:45.002656 -0500
+ * file.close
+ * File.delete(filepath)
+ * file.birthtime # Raises IOError: closed stream
*
+ * See {File System Timestamps}[rdoc-ref:file/timestamps.md].
*/
static VALUE
rb_file_birthtime(VALUE obj)
{
rb_io_t *fptr;
- statx_data st;
+ rb_io_stat_data st;
GetOpenFile(obj, fptr);
- if (fstatx_without_gvl(fptr->fd, &st, STATX_BTIME) == -1) {
+ if (fstatx_without_gvl(fptr, &st, STATX_BTIME) == -1) {
rb_sys_fail_path(fptr->pathv);
}
- return statx_birthtime(&st, fptr->pathv);
+ return statx_birthtime(&st);
}
#else
# define rb_file_birthtime rb_f_notimplement
#endif
-/*
- * call-seq:
- * file.size -> integer
- *
- * Returns the size of <i>file</i> in bytes.
- *
- * File.new("testfile").size #=> 66
- *
- */
-
rb_off_t
rb_file_size(VALUE file)
{
@@ -2548,12 +2737,45 @@ rb_file_size(VALUE file)
}
}
+/*
+ * call-seq:
+ * file.size -> integer
+ *
+ * Returns the size of <i>file</i> in bytes.
+ *
+ * File.new("testfile").size #=> 66
+ *
+ */
+
static VALUE
file_size(VALUE self)
{
return OFFT2NUM(rb_file_size(self));
}
+struct nogvl_chmod_data {
+ const char *path;
+ mode_t mode;
+};
+
+static void *
+nogvl_chmod(void *ptr)
+{
+ struct nogvl_chmod_data *data = ptr;
+ int ret = chmod(data->path, data->mode);
+ return (void *)(VALUE)ret;
+}
+
+static int
+rb_chmod(const char *path, mode_t mode)
+{
+ struct nogvl_chmod_data data = {
+ .path = path,
+ .mode = mode,
+ };
+ return IO_WITHOUT_GVL_INT(nogvl_chmod, &data);
+}
+
static int
chmod_internal(const char *path, void *mode)
{
@@ -2584,6 +2806,29 @@ rb_file_s_chmod(int argc, VALUE *argv, VALUE _)
return apply2files(chmod_internal, argc, argv, &mode);
}
+#ifdef HAVE_FCHMOD
+struct nogvl_fchmod_data {
+ int fd;
+ mode_t mode;
+};
+
+static VALUE
+io_blocking_fchmod(void *ptr)
+{
+ struct nogvl_fchmod_data *data = ptr;
+ int ret = fchmod(data->fd, data->mode);
+ return (VALUE)ret;
+}
+
+static int
+rb_fchmod(struct rb_io* io, mode_t mode)
+{
+ (void)rb_chmod; /* suppress unused-function warning when HAVE_FCHMOD */
+ struct nogvl_fchmod_data data = {.fd = io->fd, .mode = mode};
+ return (int)rb_thread_io_blocking_region(io, io_blocking_fchmod, &data);
+}
+#endif
+
/*
* call-seq:
* file.chmod(mode_int) -> 0
@@ -2610,7 +2855,7 @@ rb_file_chmod(VALUE obj, VALUE vmode)
GetOpenFile(obj, fptr);
#ifdef HAVE_FCHMOD
- if (fchmod(fptr->fd, mode) == -1) {
+ if (rb_fchmod(fptr, mode) == -1) {
if (HAVE_FCHMOD || errno != ENOSYS)
rb_sys_fail_path(fptr->pathv);
}
@@ -2621,7 +2866,7 @@ rb_file_chmod(VALUE obj, VALUE vmode)
#if !defined HAVE_FCHMOD || !HAVE_FCHMOD
if (NIL_P(fptr->pathv)) return Qnil;
path = rb_str_encode_ospath(fptr->pathv);
- if (chmod(RSTRING_PTR(path), mode) == -1)
+ if (rb_chmod(RSTRING_PTR(path), mode) == -1)
rb_sys_fail_path(fptr->pathv);
#endif
@@ -2716,6 +2961,51 @@ rb_file_s_chown(int argc, VALUE *argv, VALUE _)
return apply2files(chown_internal, argc, argv, &arg);
}
+struct nogvl_chown_data {
+ union {
+ const char *path;
+ int fd;
+ } as;
+ struct chown_args new;
+};
+
+static void *
+nogvl_chown(void *ptr)
+{
+ struct nogvl_chown_data *data = ptr;
+ return (void *)(VALUE)chown(data->as.path, data->new.owner, data->new.group);
+}
+
+static int
+rb_chown(const char *path, rb_uid_t owner, rb_gid_t group)
+{
+ struct nogvl_chown_data data = {
+ .as = {.path = path},
+ .new = {.owner = owner, .group = group},
+ };
+ return IO_WITHOUT_GVL_INT(nogvl_chown, &data);
+}
+
+#ifdef HAVE_FCHOWN
+static void *
+nogvl_fchown(void *ptr)
+{
+ struct nogvl_chown_data *data = ptr;
+ return (void *)(VALUE)fchown(data->as.fd, data->new.owner, data->new.group);
+}
+
+static int
+rb_fchown(int fd, rb_uid_t owner, rb_gid_t group)
+{
+ (void)rb_chown; /* suppress unused-function warning when HAVE_FCHMOD */
+ struct nogvl_chown_data data = {
+ .as = {.fd = fd},
+ .new = {.owner = owner, .group = group},
+ };
+ return IO_WITHOUT_GVL_INT(nogvl_fchown, &data);
+}
+#endif
+
/*
* call-seq:
* file.chown(owner_int, group_int ) -> 0
@@ -2747,10 +3037,10 @@ rb_file_chown(VALUE obj, VALUE owner, VALUE group)
#ifndef HAVE_FCHOWN
if (NIL_P(fptr->pathv)) return Qnil;
path = rb_str_encode_ospath(fptr->pathv);
- if (chown(RSTRING_PTR(path), o, g) == -1)
+ if (rb_chown(RSTRING_PTR(path), o, g) == -1)
rb_sys_fail_path(fptr->pathv);
#else
- if (fchown(fptr->fd, o, g) == -1)
+ if (rb_fchown(fptr->fd, o, g) == -1)
rb_sys_fail_path(fptr->pathv);
#endif
@@ -2846,7 +3136,7 @@ utime_failed(struct apply_arg *aa)
# elif defined(__APPLE__) && \
(!defined(MAC_OS_X_VERSION_13_0) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_13_0))
-# if defined(__has_attribute) && __has_attribute(availability)
+# if __has_attribute(availability) && __has_warning("-Wunguarded-availability-new")
typedef int utimensat_func(int, const char *, const struct timespec [2], int);
RBIMPL_WARNING_PUSH()
@@ -2861,7 +3151,7 @@ RBIMPL_WARNING_POP()
# define utimensat rb_utimensat()
# else /* __API_AVAILABLE macro does nothing on gcc */
__attribute__((weak)) int utimensat(int, const char *, const struct timespec [2], int);
-# endif /* defined(__has_attribute) && __has_attribute(availability) */
+# endif /* utimesat availability */
# endif /* __APPLE__ && < MAC_OS_X_VERSION_13_0 */
static int
@@ -2934,7 +3224,7 @@ static int
utime_internal(const char *path, void *arg)
{
struct utime_args *v = arg;
- const struct timespec *tsp = v->tsp;
+ const stat_timestamp *tsp = v->tsp;
struct utimbuf utbuf, *utp = NULL;
if (tsp) {
utbuf.actime = tsp[0].tv_sec;
@@ -3142,8 +3432,7 @@ readlink_without_gvl(VALUE path, VALUE buf, size_t size)
ra.buf = RSTRING_PTR(buf);
ra.size = size;
- return (ssize_t)rb_thread_call_without_gvl(nogvl_readlink, &ra,
- RUBY_UBF_IO, 0);
+ return (ssize_t)IO_WITHOUT_GVL(nogvl_readlink, &ra);
}
VALUE
@@ -3194,7 +3483,7 @@ unlink_internal(const char *path, void *arg)
* Since the underlying implementation relies on the
* <code>unlink(2)</code> system call, the type of
* exception raised depends on its error type (see
- * https://linux.die.net/man/2/unlink) and has the form of
+ * https://man7.org/linux/man-pages/man2/unlink.2.html) and has the form of
* e.g. Errno::ENOENT.
*
* See also Dir::rmdir.
@@ -3244,8 +3533,7 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
#if defined __CYGWIN__
errno = 0;
#endif
- if ((int)(VALUE)rb_thread_call_without_gvl(no_gvl_rename, &ra,
- RUBY_UBF_IO, 0) < 0) {
+ if (IO_WITHOUT_GVL_INT(no_gvl_rename, &ra) < 0) {
int e = errno;
#if defined DOSISH
switch (e) {
@@ -3341,8 +3629,10 @@ static const char file_alt_separator[] = {FILE_ALT_SEPARATOR, '\0'};
# define isADS(x) 0
#endif
-#define Next(p, e, enc) ((p) + rb_enc_mbclen((p), (e), (enc)))
-#define Inc(p, e, enc) ((p) = Next((p), (e), (enc)))
+#define enc_mbclen_needed(enc) (!rb_str_encindex_fastpath(rb_enc_to_index(enc)))
+
+#define Next(p, e, mb_enc, enc) ((p) + ((mb_enc) ? rb_enc_mbclen((p), (e), (enc)) : 1))
+#define Inc(p, e, mb_enc, enc) ((p) = Next((p), (e), (mb_enc), (enc)))
#if defined(DOSISH_UNC)
#define has_unc(buf) (isdirsep((buf)[0]) && isdirsep((buf)[1]))
@@ -3406,7 +3696,7 @@ not_same_drive(VALUE path, int drive)
#endif /* DOSISH_DRIVE_LETTER */
static inline char *
-skiproot(const char *path, const char *end, rb_encoding *enc)
+skiproot(const char *path, const char *end)
{
#ifdef DOSISH_DRIVE_LETTER
if (path + 2 <= end && has_drive_letter(path)) path += 2;
@@ -3415,57 +3705,76 @@ skiproot(const char *path, const char *end, rb_encoding *enc)
return (char *)path;
}
-#define nextdirsep rb_enc_path_next
-char *
-rb_enc_path_next(const char *s, const char *e, rb_encoding *enc)
+static inline char *
+enc_path_next(const char *s, const char *e, bool mb_enc, rb_encoding *enc)
{
while (s < e && !isdirsep(*s)) {
- Inc(s, e, enc);
+ Inc(s, e, mb_enc, enc);
}
return (char *)s;
}
+#define nextdirsep rb_enc_path_next
+char *
+rb_enc_path_next(const char *s, const char *e, rb_encoding *enc)
+{
+ return enc_path_next(s, e, enc_mbclen_needed(enc), enc);
+}
+
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
-#define skipprefix rb_enc_path_skip_prefix
+#define skipprefix enc_path_skip_prefix
#else
-#define skipprefix(path, end, enc) (path)
+#define skipprefix(path, end, mb_enc, enc) (path)
#endif
-char *
-rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc)
+static inline char *
+enc_path_skip_prefix(const char *path, const char *end, bool mb_enc, rb_encoding *enc)
{
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
#ifdef DOSISH_UNC
if (path + 2 <= end && isdirsep(path[0]) && isdirsep(path[1])) {
path += 2;
while (path < end && isdirsep(*path)) path++;
- if ((path = rb_enc_path_next(path, end, enc)) < end && path[0] && path[1] && !isdirsep(path[1]))
- path = rb_enc_path_next(path + 1, end, enc);
+ if ((path = enc_path_next(path, end, mb_enc, enc)) < end &&
+ path + 2 <= end && !isdirsep(path[1])) {
+ path = enc_path_next(path + 1, end, mb_enc, enc);
+ }
return (char *)path;
}
#endif
#ifdef DOSISH_DRIVE_LETTER
- if (has_drive_letter(path))
+ if (path + 2 <= end && has_drive_letter(path))
return (char *)(path + 2);
#endif
#endif /* defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) */
return (char *)path;
}
+char *
+rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc)
+{
+ return enc_path_skip_prefix(path, end, enc_mbclen_needed(enc), enc);
+}
+
static inline char *
skipprefixroot(const char *path, const char *end, rb_encoding *enc)
{
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
- char *p = skipprefix(path, end, enc);
- while (isdirsep(*p)) p++;
+ char *p = skipprefix(path, end, enc_mbclen_needed(enc), enc);
+ while (p < end && isdirsep(*p)) p++;
return p;
#else
- return skiproot(path, end, enc);
+ return skiproot(path, end);
#endif
}
-#define strrdirsep rb_enc_path_last_separator
char *
-rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
+rb_enc_path_skip_prefix_root(const char *path, const char *end, rb_encoding *enc)
+{
+ return skipprefixroot(path, end, enc);
+}
+
+static char *
+enc_path_last_separator(const char *path, const char *end, bool mb_enc, rb_encoding *enc)
{
char *last = NULL;
while (path < end) {
@@ -3476,14 +3785,44 @@ rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
last = (char *)tmp;
}
else {
- Inc(path, end, enc);
+ Inc(path, end, mb_enc, enc);
}
}
return last;
}
+char *
+rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
+{
+ return enc_path_last_separator(path, end, enc_mbclen_needed(enc), enc);
+}
+
+static inline char *
+strrdirsep(const char *path, const char *end, bool mb_enc, rb_encoding *enc)
+{
+ if (RB_UNLIKELY(mb_enc)) {
+ return enc_path_last_separator(path, end, mb_enc, enc);
+ }
+
+ const char *cursor = end - 1;
+
+ while (isdirsep(cursor[0])) {
+ cursor--;
+ }
+
+ while (cursor >= path) {
+ if (isdirsep(cursor[0])) {
+ while (cursor > path && isdirsep(cursor[-1])) {
+ cursor--;
+ }
+ return (char *)cursor;
+ }
+ cursor--;
+ }
+ return NULL;
+}
static char *
-chompdirsep(const char *path, const char *end, rb_encoding *enc)
+chompdirsep(const char *path, const char *end, bool mb_enc, rb_encoding *enc)
{
while (path < end) {
if (isdirsep(*path)) {
@@ -3492,7 +3831,7 @@ chompdirsep(const char *path, const char *end, rb_encoding *enc)
if (path >= end) return (char *)last;
}
else {
- Inc(path, end, enc);
+ Inc(path, end, mb_enc, enc);
}
}
return (char *)path;
@@ -3502,13 +3841,13 @@ char *
rb_enc_path_end(const char *path, const char *end, rb_encoding *enc)
{
if (path < end && isdirsep(*path)) path++;
- return chompdirsep(path, end, enc);
+ return chompdirsep(path, end, enc_mbclen_needed(enc), enc);
}
static rb_encoding *
fs_enc_check(VALUE path1, VALUE path2)
{
- rb_encoding *enc = rb_enc_check(path1, path2);
+ rb_encoding *enc = rb_enc_check_str(path1, path2);
int encidx = rb_enc_to_index(enc);
if (encidx == ENCINDEX_US_ASCII) {
encidx = rb_enc_get_index(path1);
@@ -3523,6 +3862,7 @@ fs_enc_check(VALUE path1, VALUE path2)
static char *
ntfs_tail(const char *path, const char *end, rb_encoding *enc)
{
+ bool mb_enc = enc_mbclen_needed(enc);
while (path < end && *path == '.') path++;
while (path < end && !isADS(*path)) {
if (istrailinggarbage(*path)) {
@@ -3537,7 +3877,7 @@ ntfs_tail(const char *path, const char *end, rb_encoding *enc)
if (isADS(*path)) path++;
}
else {
- Inc(path, end, enc);
+ Inc(path, end, mb_enc, enc);
}
}
return (char *)path;
@@ -3585,10 +3925,6 @@ static VALUE
copy_home_path(VALUE result, const char *dir)
{
char *buf;
-#if defined DOSISH || defined __CYGWIN__
- char *p, *bend;
- rb_encoding *enc;
-#endif
long dirlen;
int encidx;
@@ -3597,10 +3933,11 @@ copy_home_path(VALUE result, const char *dir)
memcpy(buf = RSTRING_PTR(result), dir, dirlen);
encidx = rb_filesystem_encindex();
rb_enc_associate_index(result, encidx);
-#if defined DOSISH || defined __CYGWIN__
- enc = rb_enc_from_index(encidx);
- for (bend = (p = buf) + dirlen; p < bend; Inc(p, bend, enc)) {
- if (*p == '\\') {
+#if defined FILE_ALT_SEPARATOR
+ rb_encoding *enc = rb_enc_from_index(encidx);
+ bool mb_enc = enc_mbclen_needed(enc);
+ for (char *p = buf, *bend = p + dirlen; p < bend; Inc(p, bend, mb_enc, enc)) {
+ if (*p == FILE_ALT_SEPARATOR) {
*p = '/';
}
}
@@ -3612,12 +3949,16 @@ VALUE
rb_home_dir_of(VALUE user, VALUE result)
{
#ifdef HAVE_PWD_H
- struct passwd *pwPtr;
+ VALUE dirname = rb_getpwdirnam_for_login(user);
+ if (dirname == Qnil) {
+ rb_raise(rb_eArgError, "user %"PRIsVALUE" doesn't exist", user);
+ }
+ const char *dir = RSTRING_PTR(dirname);
#else
extern char *getlogin(void);
const char *pwPtr = 0;
+ const char *login;
# define endpwent() ((void)0)
-#endif
const char *dir, *username = RSTRING_PTR(user);
rb_encoding *enc = rb_enc_get(user);
#if defined _WIN32
@@ -3629,21 +3970,13 @@ rb_home_dir_of(VALUE user, VALUE result)
dir = username = RSTRING_PTR(rb_str_conv_enc(user, enc, fsenc));
}
-#ifdef HAVE_PWD_H
- pwPtr = getpwnam(username);
-#else
- if (strcasecmp(username, getlogin()) == 0)
+ if ((login = getlogin()) && strcasecmp(username, login) == 0)
dir = pwPtr = getenv("HOME");
-#endif
if (!pwPtr) {
- endpwent();
rb_raise(rb_eArgError, "user %"PRIsVALUE" doesn't exist", user);
}
-#ifdef HAVE_PWD_H
- dir = pwPtr->pw_dir;
#endif
copy_home_path(result, dir);
- endpwent();
return result;
}
@@ -3675,7 +4008,7 @@ rb_default_home_dir(VALUE result)
* lookup by getuid() has a chance of succeeding.
*/
if (NIL_P(login_name)) {
- rb_raise(rb_eArgError, "couldn't find login name -- expanding `~'");
+ rb_raise(rb_eArgError, "couldn't find login name -- expanding '~'");
}
# endif /* !defined(HAVE_GETPWUID_R) && !defined(HAVE_GETPWUID) */
@@ -3683,7 +4016,7 @@ rb_default_home_dir(VALUE result)
if (NIL_P(pw_dir)) {
pw_dir = rb_getpwdiruid();
if (NIL_P(pw_dir)) {
- rb_raise(rb_eArgError, "couldn't find home for uid `%ld'", (long)getuid());
+ rb_raise(rb_eArgError, "couldn't find home for uid '%ld'", (long)getuid());
}
}
@@ -3694,7 +4027,7 @@ rb_default_home_dir(VALUE result)
}
#endif /* defined HAVE_PWD_H */
if (!dir) {
- rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'");
+ rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding '~'");
}
return copy_home_path(result, dir);
}
@@ -3719,7 +4052,15 @@ append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encodi
size_t dirlen = strlen(dir), buflen = rb_str_capacity(result);
if (NORMALIZE_UTF8PATH || *enc != fsenc) {
- rb_encoding *direnc = fs_enc_check(fname, dirname = ospath_new(dir, dirlen, fsenc));
+ dirname = ospath_new(dir, dirlen, fsenc);
+ if (!rb_enc_compatible(fname, dirname)) {
+ xfree(dir);
+ /* rb_enc_check must raise because the two encodings are not
+ * compatible. */
+ rb_enc_check(fname, dirname);
+ rb_bug("unreachable");
+ }
+ rb_encoding *direnc = fs_enc_check(fname, dirname);
if (direnc != fsenc) {
dirname = rb_str_conv_enc(dirname, fsenc, direnc);
RSTRING_GETMEM(dirname, cwdp, dirlen);
@@ -3749,16 +4090,21 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
s = StringValuePtr(fname);
fend = s + RSTRING_LEN(fname);
- enc = rb_enc_get(fname);
+ enc = rb_str_enc_get(fname);
+ bool mb_enc = enc_mbclen_needed(enc);
+ if (!mb_enc && RTEST(dname)) {
+ mb_enc = enc_mbclen_needed(rb_str_enc_get(dname));
+ }
+
BUFINIT();
- if (s[0] == '~' && abs_mode == 0) { /* execute only if NOT absolute_path() */
+ if (s < fend && s[0] == '~' && abs_mode == 0) { /* execute only if NOT absolute_path() */
long userlen = 0;
- if (isdirsep(s[1]) || s[1] == '\0') {
+ if (s + 1 == fend || isdirsep(s[1])) {
buf = 0;
b = 0;
rb_str_set_len(result, 0);
- if (*++s) ++s;
+ if (++s < fend) ++s;
rb_default_home_dir(result);
}
else {
@@ -3788,8 +4134,8 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
#ifdef DOSISH_DRIVE_LETTER
/* skip drive letter */
- else if (has_drive_letter(s)) {
- if (isdirsep(s[2])) {
+ else if (s + 1 < fend && has_drive_letter(s)) {
+ if (s + 2 < fend && isdirsep(s[2])) {
/* specified drive letter, and full path */
/* skip drive letter */
BUFCHECK(bdiff + 2 >= buflen);
@@ -3818,12 +4164,12 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
rb_enc_associate(result, enc = fs_enc_check(result, fname));
p = pend;
}
- p = chompdirsep(skiproot(buf, p, enc), p, enc);
+ p = chompdirsep(skiproot(buf, p), p, mb_enc, enc);
s += 2;
}
}
#endif /* DOSISH_DRIVE_LETTER */
- else if (!rb_is_absolute_path(s)) {
+ else if (s == fend || !rb_is_absolute_path(s)) {
if (!NIL_P(dname)) {
rb_file_expand_path_internal(dname, Qnil, abs_mode, long_name, result);
rb_enc_associate(result, fs_enc_check(result, fname));
@@ -3835,20 +4181,20 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
BUFINIT();
p = e;
}
-#if defined DOSISH || defined __CYGWIN__
- if (isdirsep(*s)) {
+#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
+ if (s < fend && isdirsep(*s)) {
/* specified full path, but not drive letter nor UNC */
/* we need to get the drive letter or UNC share name */
- p = skipprefix(buf, p, enc);
+ p = skipprefix(buf, p, mb_enc, enc);
}
else
-#endif /* defined DOSISH || defined __CYGWIN__ */
- p = chompdirsep(skiproot(buf, p, enc), p, enc);
+#endif /* defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC */
+ p = chompdirsep(skiproot(buf, p), p, mb_enc, enc);
}
else {
size_t len;
b = s;
- do s++; while (isdirsep(*s));
+ do s++; while (s < fend && isdirsep(*s));
len = s - b;
p = buf + len;
BUFCHECK(bdiff >= buflen);
@@ -3867,23 +4213,24 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
rb_str_set_len(result, p-buf+1);
BUFCHECK(bdiff + 1 >= buflen);
p[1] = 0;
- root = skipprefix(buf, p+1, enc);
+ root = skipprefix(buf, p+1, mb_enc, enc);
b = s;
- while (*s) {
+ while (s < fend) {
switch (*s) {
case '.':
if (b == s++) { /* beginning of path element */
- switch (*s) {
- case '\0':
+ if (s == fend) {
b = s;
break;
+ }
+ switch (*s) {
case '.':
- if (*(s+1) == '\0' || isdirsep(*(s+1))) {
+ if (s+1 == fend || isdirsep(*(s+1))) {
/* We must go back to the parent */
char *n;
*p = '\0';
- if (!(n = strrdirsep(root, p, enc))) {
+ if (!(n = strrdirsep(root, p, mb_enc, enc))) {
*p = '/';
}
else {
@@ -3893,13 +4240,13 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
#if USE_NTFS
else {
- do ++s; while (istrailinggarbage(*s));
+ do ++s; while (s < fend && istrailinggarbage(*s));
}
#endif /* USE_NTFS */
break;
case '/':
-#if defined DOSISH || defined __CYGWIN__
- case '\\':
+#if defined FILE_ALT_SEPARATOR
+ case FILE_ALT_SEPARATOR:
#endif
b = ++s;
break;
@@ -3923,8 +4270,8 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
#endif /* USE_NTFS */
break;
case '/':
-#if defined DOSISH || defined __CYGWIN__
- case '\\':
+#if defined FILE_ALT_SEPARATOR
+ case FILE_ALT_SEPARATOR:
#endif
if (s > b) {
WITH_ROOTDIFF(BUFCOPY(b, s-b));
@@ -3946,7 +4293,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
}
}
#endif /* __APPLE__ */
- Inc(s, fend, enc);
+ Inc(s, fend, mb_enc, enc);
break;
}
}
@@ -3974,7 +4321,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
BUFCOPY(b, s-b);
rb_str_set_len(result, p-buf);
}
- if (p == skiproot(buf, p + !!*p, enc) - 1) p++;
+ if (p == skiproot(buf, p + !!*p) - 1) p++;
#if USE_NTFS
*p = '\0';
@@ -4132,31 +4479,43 @@ rb_file_s_expand_path(int argc, const VALUE *argv)
}
/*
+ * :markup: markdown
+ *
* call-seq:
- * File.expand_path(file_name [, dir_string] ) -> abs_file_name
+ * File.expand_path(path, dirpath = '.') -> absolute_path
*
- * Converts a pathname to an absolute pathname. Relative paths are
- * referenced from the current working directory of the process unless
- * +dir_string+ is given, in which case it will be used as the
- * starting point. The given pathname may start with a
- * ``<code>~</code>'', which expands to the process owner's home
- * directory (the environment variable +HOME+ must be set
- * correctly). ``<code>~</code><i>user</i>'' expands to the named
- * user's home directory.
+ * Returns the string absolute path for the given `path`.
+ *
+ * Evaluates a relative path with respect to the directory given by `dirpath`:
+ *
+ * ```ruby
+ * Dir.chdir('/snap')
+ * # Default dirpath.
+ * File.expand_path('README') # => "/snap/README"
+ * File.expand_path('bin') # => "/snap/bin"
+ * File.expand_path('bin/../var') # => "/snap/var" # Cleaned.
+ * # Other dirpath.
+ * File.expand_path('../zip', '/usr/bin/ruby') # => "/usr/bin/zip"
+ * Dir.chdir('/usr/bin')
+ * File.expand_path('../../snap', __FILE__) # => "/usr/snap"
+ * ```
*
- * File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
+ * Evaluates an absolute path without respect to `dirpath`:
*
- * A simple example of using +dir_string+ is as follows.
- * File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby"
+ * ```ruby
+ * File.expand_path('/snap') # => "/snap"
+ * File.expand_path('/snap', 'nosuch') # => "/snap"
+ * File.expand_path('/snap/../snap') # => "/snap" # Cleaned.
+ * ```
*
- * A more complex example which also resolves parent directory is as follows.
- * Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb.
+ * More examples:
*
- * File.expand_path("../../lib/mygem.rb", __FILE__)
- * #=> ".../path/to/project/lib/mygem.rb"
+ * ```
+ * Dir.chdir('/usr/bin')
+ * File.expand_path('../../snap', __FILE__) # => "/usr/snap"
+ * File.expand_path('../../snap') # => "/snap"
+ * ```
*
- * So first it resolves the parent of __FILE__, that is bin/, then go to the
- * parent, the root of the project and appends +lib/mygem.rb+.
*/
static VALUE
@@ -4244,9 +4603,10 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE f
}
else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') {
if (*prefixlenp < RSTRING_LEN(*resolvedp)) {
+ bool mb_enc = enc_mbclen_needed(enc);
const char *resolved_str = RSTRING_PTR(*resolvedp);
const char *resolved_names = resolved_str + *prefixlenp;
- const char *lastsep = strrdirsep(resolved_names, resolved_str + RSTRING_LEN(*resolvedp), enc);
+ const char *lastsep = strrdirsep(resolved_names, resolved_str + RSTRING_LEN(*resolvedp), mb_enc, enc);
long len = lastsep ? lastsep - resolved_names : 0;
rb_str_resize(*resolvedp, *prefixlenp + len);
}
@@ -4386,7 +4746,8 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
root_found:
RSTRING_GETMEM(resolved, prefixptr, prefixlen);
pend = prefixptr + prefixlen;
- ptr = chompdirsep(prefixptr, pend, enc);
+ bool mb_enc = enc_mbclen_needed(enc);
+ ptr = chompdirsep(prefixptr, pend, mb_enc, enc);
if (ptr < pend) {
prefixlen = ++ptr - prefixptr;
rb_str_set_len(resolved, prefixlen);
@@ -4396,7 +4757,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
if (*prefixptr == FILE_ALT_SEPARATOR) {
*prefixptr = '/';
}
- Inc(prefixptr, pend, enc);
+ Inc(prefixptr, pend, mb_enc, enc);
}
#endif
@@ -4432,7 +4793,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum
return resolved;
}
-static VALUE rb_file_join(VALUE ary);
+static VALUE rb_file_join(long argc, VALUE *args);
#ifndef HAVE_REALPATH
static VALUE
@@ -4447,6 +4808,11 @@ rb_check_realpath_emulate_rescue(VALUE arg, VALUE exc)
{
return Qnil;
}
+#elif !defined(NEEDS_REALPATH_BUFFER) && defined(__APPLE__) && \
+ (!defined(MAC_OS_X_VERSION_10_6) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6))
+/* realpath() on OSX < 10.6 doesn't implement automatic allocation */
+# include <sys/syslimits.h>
+# define NEEDS_REALPATH_BUFFER 1
#endif /* HAVE_REALPATH */
static VALUE
@@ -4456,6 +4822,11 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
VALUE unresolved_path;
char *resolved_ptr = NULL;
VALUE resolved;
+# if defined(NEEDS_REALPATH_BUFFER) && NEEDS_REALPATH_BUFFER
+ char resolved_buffer[PATH_MAX];
+# else
+ char *const resolved_buffer = NULL;
+# endif
if (mode == RB_REALPATH_DIR) {
return rb_check_realpath_emulate(basedir, path, origenc, mode);
@@ -4463,17 +4834,22 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
unresolved_path = rb_str_dup_frozen(path);
if (*RSTRING_PTR(unresolved_path) != '/' && !NIL_P(basedir)) {
- unresolved_path = rb_file_join(rb_assoc_new(basedir, unresolved_path));
+ VALUE paths[2] = {basedir, unresolved_path};
+ unresolved_path = rb_file_join(2, paths);
}
if (origenc) unresolved_path = TO_OSPATH(unresolved_path);
- if ((resolved_ptr = realpath(RSTRING_PTR(unresolved_path), NULL)) == NULL) {
- /* glibc realpath(3) does not allow /path/to/file.rb/../other_file.rb,
+ if ((resolved_ptr = realpath(RSTRING_PTR(unresolved_path), resolved_buffer)) == NULL) {
+ /*
+ wasi-libc 22 and later support realpath(3) but return ENOTSUP
+ when the underlying host syscall returns it.
+ glibc realpath(3) does not allow /path/to/file.rb/../other_file.rb,
returning ENOTDIR in that case.
glibc realpath(3) can also return ENOENT for paths that exist,
such as /dev/fd/5.
Fallback to the emulated approach in either of those cases. */
- if (errno == ENOTDIR ||
+ if (errno == ENOTSUP ||
+ errno == ENOTDIR ||
(errno == ENOENT && rb_file_exist_p(0, unresolved_path))) {
return rb_check_realpath_emulate(basedir, path, origenc, mode);
@@ -4484,9 +4860,11 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
rb_sys_fail_path(unresolved_path);
}
resolved = ospath_new(resolved_ptr, strlen(resolved_ptr), rb_filesystem_encoding());
+# if !(defined(NEEDS_REALPATH_BUFFER) && NEEDS_REALPATH_BUFFER)
free(resolved_ptr);
+# endif
-# if !defined(__LINUX__) && !defined(__APPLE__)
+# if !defined(__linux__) && !defined(__APPLE__)
/* As `resolved` is a String in the filesystem encoding, no
* conversion is needed */
struct stat st;
@@ -4496,7 +4874,7 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
}
rb_sys_fail_path(unresolved_path);
}
-# endif /* !defined(__LINUX__) && !defined(__APPLE__) */
+# endif /* !defined(__linux__) && !defined(__APPLE__) */
if (origenc && origenc != rb_enc_get(resolved)) {
if (!rb_enc_str_asciionly_p(resolved)) {
@@ -4611,7 +4989,7 @@ rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
if (l1 < l2) return l1;
s = p+l1-l2;
- if (rb_enc_left_char_head(p, s, p+l1, enc) != s) return 0;
+ if (!at_char_boundary(p, s, p+l1, enc)) return 0;
#if CASEFOLD_FILESYSTEM
#define fncomp strncasecmp
#else
@@ -4623,23 +5001,29 @@ rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
return 0;
}
-const char *
-ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
+static inline const char *
+enc_find_basename(const char *name, long *baselen, long *alllen, bool mb_enc, rb_encoding *enc)
{
const char *p, *q, *e, *end;
-#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
- const char *root;
-#endif
long f = 0, n = -1;
- end = name + (alllen ? (size_t)*alllen : strlen(name));
- name = skipprefix(name, end, enc);
+ long len = (alllen ? (size_t)*alllen : strlen(name));
+
+ if (len <= 0) {
+ return name;
+ }
+
+ end = name + len;
+ name = skipprefix(name, end, mb_enc, enc);
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
- root = name;
+ const char *root = name;
#endif
- while (isdirsep(*name))
+
+ while (name < end && isdirsep(*name)) {
name++;
- if (!*name) {
+ }
+
+ if (name == end) {
p = name - 1;
f = 1;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
@@ -4660,91 +5044,127 @@ ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encodin
#endif /* defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC */
}
else {
- if (!(p = strrdirsep(name, end, enc))) {
+ p = strrdirsep(name, end, mb_enc, enc);
+ if (!p) {
p = name;
}
else {
- while (isdirsep(*p)) p++; /* skip last / */
+ while (isdirsep(*p)) {
+ p++; /* skip last / */
+ }
}
#if USE_NTFS
n = ntfs_tail(p, end, enc) - p;
#else
- n = chompdirsep(p, end, enc) - p;
+ n = chompdirsep(p, end, mb_enc, enc) - p;
#endif
for (q = p; q - p < n && *q == '.'; q++);
- for (e = 0; q - p < n; Inc(q, end, enc)) {
+ for (e = 0; q - p < n; Inc(q, end, mb_enc, enc)) {
if (*q == '.') e = q;
}
- if (e) f = e - p;
- else f = n;
+ if (e) {
+ f = e - p;
+ }
+ else {
+ f = n;
+ }
}
- if (baselen)
+ if (baselen) {
*baselen = f;
- if (alllen)
+ }
+ if (alllen) {
*alllen = n;
+ }
return p;
}
+const char *
+ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
+{
+ return enc_find_basename(name, baselen, alllen, enc_mbclen_needed(enc), enc);
+}
+
/*
* call-seq:
- * File.basename(file_name [, suffix] ) -> base_name
+ * File.basename(path, suffix = '') -> new_string
*
- * Returns the last component of the filename given in
- * <i>file_name</i> (after first stripping trailing separators),
- * which can be formed using both File::SEPARATOR and
- * File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is
- * not <code>nil</code>. If <i>suffix</i> is given and present at the
- * end of <i>file_name</i>, it is removed. If <i>suffix</i> is ".*",
- * any extension will be removed.
+ * Returns a new string containing all or part of the last entry of the given +path+.
+ * Entries are delimited by the value of constant File::SEPARATOR
+ * and, if non-nil, the value of constant File::ALT_SEPARATOR.
+ *
+ * When +suffix+ is the empty string <tt>''</tt>,
+ * returns all of the last entry:
+ *
+ * File.basename('foo/bar/baz/bat.txt') # => "bat.txt"
+ * File.basename('foo/bar/baz') # => "baz"
+ *
+ * File::SEPARATOR # => "/"
+ * File.basename('foo/bar.txt////') # => "bar.txt"
+ * File::ALT_SEPARATOR # => "\\" # On Windows.
+ * File.basename('foo/bar.txt//\\\\//') # => "bar.txt"
+ *
+ * When +suffix+ is <tt>'.*'</tt>,
+ * the last {filename extension}[https://en.wikipedia.org/wiki/Filename_extension],
+ * if any, is removed:
+ *
+ * File.basename('foo/bar.txt', '.*') # => "bar"
+ * File.basename('foo/bar.txt.old', '.*') # => "bar.txt"
+ * File.basename('foo/bar', '.*') # => "bar"
+ *
+ * When +suffix+ is any string other than <tt>''</tt> or <tt>'.*'</tt>,
+ * the matching trailing substring, if any, is removed:
+ *
+ * File.basename('foo/bar.txt', '.txt') # => "bar"
+ * File.basename('foo/bar.txt', 'txt') # => "bar."
+ * File.basename('foo/bar.txt', '*') # => "bar.txt"
+ * File.basename('foo/bar.txt', '.') # => "bar.txt"
*
- * File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
- * File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
- * File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
*/
static VALUE
rb_file_s_basename(int argc, VALUE *argv, VALUE _)
{
- VALUE fname, fext, basename;
- const char *name, *p;
- long f, n;
+ VALUE fname, fext = Qnil;
+ const char *name, *p, *fp = 0;
+ long f = 0, n;
rb_encoding *enc;
- fext = Qnil;
- if (rb_check_arity(argc, 1, 2) == 2) {
+ argc = rb_check_arity(argc, 1, 2);
+ fname = argv[0];
+ CheckPath(fname, name);
+ if (argc == 2) {
fext = argv[1];
- StringValue(fext);
- enc = check_path_encoding(fext);
+ fp = StringValueCStr(fext);
+ check_path_encoding(fext);
}
- fname = argv[0];
- FilePathStringValue(fname);
if (NIL_P(fext) || !(enc = rb_enc_compatible(fname, fext))) {
- enc = rb_enc_get(fname);
- fext = Qnil;
+ enc = rb_str_enc_get(fname);
}
- if ((n = RSTRING_LEN(fname)) == 0 || !*(name = RSTRING_PTR(fname)))
- return rb_str_new_shared(fname);
- p = ruby_enc_find_basename(name, &f, &n, enc);
+ n = RSTRING_LEN(fname);
+ if (n <= 0 || !*name) {
+ return rb_enc_str_new(0, 0, enc);
+ }
+
+ bool mb_enc = enc_mbclen_needed(enc);
+ p = enc_find_basename(name, &f, &n, mb_enc, enc);
if (n >= 0) {
- if (NIL_P(fext)) {
+ if (!fp) {
f = n;
}
else {
- const char *fp;
- fp = StringValueCStr(fext);
if (!(f = rmext(p, f, n, fp, RSTRING_LEN(fext), enc))) {
f = n;
}
RB_GC_GUARD(fext);
}
- if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname);
+ if (f == RSTRING_LEN(fname)) {
+ return rb_str_new_shared(fname);
+ }
}
- basename = rb_str_new(p, f);
- rb_enc_copy(basename, fname);
- return basename;
+ return rb_enc_str_new(p, f, enc);
}
static VALUE rb_file_dirname_n(VALUE fname, int n);
@@ -4789,19 +5209,18 @@ rb_file_dirname_n(VALUE fname, int n)
{
const char *name, *root, *p, *end;
VALUE dirname;
- rb_encoding *enc;
- VALUE sepsv = 0;
- const char **seps;
if (n < 0) rb_raise(rb_eArgError, "negative level: %d", n);
- FilePathStringValue(fname);
- name = StringValueCStr(fname);
+ CheckPath(fname, name);
end = name + RSTRING_LEN(fname);
- enc = rb_enc_get(fname);
- root = skiproot(name, end, enc);
+
+ bool mb_enc = !rb_str_enc_fastpath(fname);
+ rb_encoding *enc = rb_str_enc_get(fname);
+
+ root = skiproot(name, end);
#ifdef DOSISH_UNC
if (root > name + 1 && isdirsep(*name))
- root = skipprefix(name = root - 2, end, enc);
+ root = skipprefix(name = root - 2, end, mb_enc, enc);
#else
if (root > name + 1)
name = root - 1;
@@ -4810,72 +5229,41 @@ rb_file_dirname_n(VALUE fname, int n)
p = root;
}
else {
- int i;
- switch (n) {
- case 0:
- p = end;
- break;
- case 1:
- if (!(p = strrdirsep(root, end, enc))) p = root;
- break;
- default:
- seps = ALLOCV_N(const char *, sepsv, n);
- for (i = 0; i < n; ++i) seps[i] = root;
- i = 0;
- for (p = root; p < end; ) {
- if (isdirsep(*p)) {
- const char *tmp = p++;
- while (p < end && isdirsep(*p)) p++;
- if (p >= end) break;
- seps[i++] = tmp;
- if (i == n) i = 0;
- }
- else {
- Inc(p, end, enc);
- }
+ p = end;
+ while (n) {
+ if (!(p = strrdirsep(root, p, mb_enc, enc))) {
+ p = root;
+ break;
}
- p = seps[i];
- ALLOCV_END(sepsv);
- break;
+ n--;
}
}
- if (p == name)
- return rb_usascii_str_new2(".");
+
+ if (p == name) {
+ return rb_enc_str_new(".", 1, enc);
+ }
#ifdef DOSISH_DRIVE_LETTER
- if (has_drive_letter(name) && isdirsep(*(name + 2))) {
- const char *top = skiproot(name + 2, end, enc);
- dirname = rb_str_new(name, 3);
+ if (name + 3 < end && has_drive_letter(name) && isdirsep(*(name + 2))) {
+ const char *top = skiproot(name + 2, end);
+ dirname = rb_enc_str_new(name, 3, enc);
rb_str_cat(dirname, top, p - top);
}
else
#endif
- dirname = rb_str_new(name, p - name);
+ dirname = rb_enc_str_new(name, p - name, enc);
#ifdef DOSISH_DRIVE_LETTER
- if (has_drive_letter(name) && root == name + 2 && p - name == 2)
+ if (root == name + 2 && p == root && name[1] == ':')
rb_str_cat(dirname, ".", 1);
#endif
- rb_enc_copy(dirname, fname);
return dirname;
}
-/*
- * accept a String, and return the pointer of the extension.
- * if len is passed, set the length of extension to it.
- * returned pointer is in ``name'' or NULL.
- * returns *len
- * no dot NULL 0
- * dotfile top 0
- * end with dot dot 1
- * .ext dot len of .ext
- * .ext:stream dot len of .ext without :stream (NTFS only)
- *
- */
-const char *
-ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
+static inline const char *
+enc_find_extname(const char *name, long *len, bool mb_enc, rb_encoding *enc)
{
const char *p, *e, *end = name + (len ? *len : (long)strlen(name));
- p = strrdirsep(name, end, enc); /* get the last path component */
+ p = strrdirsep(name, end, mb_enc, enc); /* get the last path component */
if (!p)
p = name;
else
@@ -4908,7 +5296,7 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
#endif
else if (isdirsep(*p))
break;
- Inc(p, end, enc);
+ Inc(p, end, mb_enc, enc);
}
if (len) {
@@ -4924,57 +5312,106 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
}
/*
+ * accept a String, and return the pointer of the extension.
+ * if len is passed, set the length of extension to it.
+ * returned pointer is in ``name'' or NULL.
+ * returns *len
+ * no dot NULL 0
+ * dotfile top 0
+ * end with dot dot 1
+ * .ext dot len of .ext
+ * .ext:stream dot len of .ext without :stream (NTFS only)
+ *
+ */
+const char *
+ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
+{
+ return enc_find_extname(name, len, enc_mbclen_needed(enc), enc);
+}
+
+/*
+ * :markup: markdown
+ *
* call-seq:
- * File.extname(path) -> string
+ * File.extname(path) -> extension
+ *
+ * Returns the filename extension --
+ * usually the portion of the string `path`
+ * beginning from the last period:
+ *
+ * ```ruby
+ * File.extname('t.rb') # => ".rb"
+ * File.extname('foo.bar.t.rb') # => ".rb"
+ * File.extname('foo/bar/t.rb') # => ".rb"
+ * File.extname('nosuch.txt') # => ".txt" # Path need not exist.
+ * ```
*
- * Returns the extension (the portion of file name in +path+
- * starting from the last period).
+ * Returns the entire string when there is no period:
*
- * If +path+ is a dotfile, or starts with a period, then the starting
- * dot is not dealt with the start of the extension.
+ * ```ruby
+ * Pathname('foo').extname # => ""
+ * ```
*
- * An empty string will also be returned when the period is the last character
- * in +path+.
+ * Returns an empty string when the only period is the first character:
*
- * On Windows, trailing dots are truncated.
+ * ```ruby
+ * File.extname('.irbrc') # => ""
+ * ```
*
- * File.extname("test.rb") #=> ".rb"
- * File.extname("a/b/d/test.rb") #=> ".rb"
- * File.extname(".a/b/d/test.rb") #=> ".rb"
- * File.extname("foo.") #=> "" on Windows
- * File.extname("foo.") #=> "." on non-Windows
- * File.extname("test") #=> ""
- * File.extname(".profile") #=> ""
- * File.extname(".profile.sh") #=> ".sh"
+ * Returns an empty string or `'.'` when `path` ends with a period:
+ *
+ * ```
+ * File.extname('foo.') # => "" # On Windows.
+ * File.extname('foo.') # => "." # Elsewhere.
+ * File.extname('foo....') # => "" # On Windows.
+ * File.extname('foo....') # => "." # Elsewhere.
+ * ```
*
*/
static VALUE
rb_file_s_extname(VALUE klass, VALUE fname)
{
- const char *name, *e;
- long len;
- VALUE extname;
+ const char *name;
+ CheckPath(fname, name);
+ long len = RSTRING_LEN(fname);
- FilePathStringValue(fname);
- name = StringValueCStr(fname);
- len = RSTRING_LEN(fname);
- e = ruby_enc_find_extname(name, &len, rb_enc_get(fname));
- if (len < 1)
- return rb_str_new(0, 0);
- extname = rb_str_subseq(fname, e - name, len); /* keep the dot, too! */
- return extname;
+ if (len < 1) {
+ return rb_enc_str_new(0, 0, rb_str_enc_get(fname));
+ }
+
+ bool mb_enc = !rb_str_enc_fastpath(fname);
+ rb_encoding *enc = rb_str_enc_get(fname);
+
+ const char *ext = enc_find_extname(name, &len, mb_enc, enc);
+ return rb_enc_str_new(ext, len, enc);
}
/*
- * call-seq:
+ * call-seq:
* File.path(path) -> string
*
- * Returns the string representation of the path
+ * Returns the string representation of the path
*
- * File.path("/dev/null") #=> "/dev/null"
+ * File.path(File::NULL) #=> "/dev/null"
* File.path(Pathname.new("/tmp")) #=> "/tmp"
*
+ * If +path+ is not a String:
+ *
+ * 1. If it has the +to_path+ method, that method will be called to
+ * coerce to a String.
+ *
+ * 2. Otherwise, or if the coerced result is not a String too, the
+ * standard coercion using +to_str+ method will take place on that
+ * object. (See also String.try_convert)
+ *
+ * The coerced string must satisfy the following conditions:
+ *
+ * 1. It must be in an ASCII-compatible encoding; otherwise, an
+ * Encoding::CompatibilityError is raised.
+ *
+ * 2. It must not contain the NUL character (<tt>\0</tt>); otherwise,
+ * an ArgumentError is raised.
*/
static VALUE
@@ -5001,15 +5438,17 @@ rb_file_s_split(VALUE klass, VALUE path)
return rb_assoc_new(rb_file_dirname(path), rb_file_s_basename(1,&path,Qundef));
}
+static VALUE rb_file_join_ary(VALUE ary);
+
static VALUE
file_inspect_join(VALUE ary, VALUE arg, int recur)
{
if (recur || ary == arg) rb_raise(rb_eArgError, "recursive array");
- return rb_file_join(arg);
+ return rb_file_join_ary(arg);
}
static VALUE
-rb_file_join(VALUE ary)
+rb_file_join_ary(VALUE ary)
{
long len, i;
VALUE result, tmp;
@@ -5057,11 +5496,11 @@ rb_file_join(VALUE ary)
rb_enc_copy(result, tmp);
}
else {
- tail = chompdirsep(name, name + len, rb_enc_get(result));
- if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) {
+ tail = chompdirsep(name, name + len, true, rb_enc_get(result));
+ if (RSTRING_LEN(tmp) > 0 && isdirsep(RSTRING_PTR(tmp)[0])) {
rb_str_set_len(result, tail - name);
}
- else if (!*tail) {
+ else if (tail == name + len) {
rb_str_cat(result, "/", 1);
}
}
@@ -5074,6 +5513,77 @@ rb_file_join(VALUE ary)
return result;
}
+static inline VALUE
+rb_file_join_fastpath(long argc, VALUE *args)
+{
+ long size = argc;
+
+ long i;
+ for (i = 0; i < argc; i++) {
+ VALUE tmp = args[i];
+ if (RB_LIKELY(RB_TYPE_P(tmp, T_STRING) && rb_str_enc_fastpath(tmp))) {
+ size += RSTRING_LEN(tmp);
+ }
+ else {
+ return 0;
+ }
+ }
+
+ VALUE result = rb_str_buf_new(size);
+
+ int encidx = ENCODING_GET_INLINED(args[0]);
+ ENCODING_SET_INLINED(result, encidx);
+ rb_str_buf_append(result, args[0]);
+
+ const char *name = RSTRING_PTR(result);
+ for (i = 1; i < argc; i++) {
+ VALUE tmp = args[i];
+ long len = RSTRING_LEN(result);
+
+ const char *tmp_s;
+ long tmp_len;
+ RSTRING_GETMEM(tmp, tmp_s, tmp_len);
+
+ if (tmp_len > 0 && isdirsep(tmp_s[0])) {
+ // right side has a leading separator, remove left side separators.
+ long chomp = len;
+ while (chomp > 0 && isdirsep(name[chomp - 1])) {
+ --chomp;
+ }
+ rb_str_set_len(result, chomp);
+ }
+ else if (len < 1 || !isdirsep(name[len - 1])) {
+ // neither side have a separator, append one;
+ rb_str_cat(result, "/", 1);
+ }
+
+ if (RB_UNLIKELY(ENCODING_GET_INLINED(tmp) != encidx)) {
+ rb_encoding *new_enc = fs_enc_check(result, tmp);
+ rb_enc_associate(result, new_enc);
+ encidx = rb_enc_to_index(new_enc);
+ }
+
+ rb_str_buf_cat(result, tmp_s, tmp_len);
+ }
+
+ rb_str_null_check(result);
+ return result;
+}
+
+static inline VALUE
+rb_file_join(long argc, VALUE *args)
+{
+ if (RB_UNLIKELY(argc == 0)) {
+ return rb_str_new(0, 0);
+ }
+
+ VALUE result = rb_file_join_fastpath(argc, args);
+ if (RB_LIKELY(result)) {
+ return result;
+ }
+
+ return rb_file_join_ary(rb_ary_new_from_values(argc, args));
+}
/*
* call-seq:
* File.join(string, ...) -> string
@@ -5086,9 +5596,9 @@ rb_file_join(VALUE ary)
*/
static VALUE
-rb_file_s_join(VALUE klass, VALUE args)
+rb_file_s_join(int argc, VALUE *argv, VALUE klass)
{
- return rb_file_join(args);
+ return rb_file_join(argc, argv);
}
#if defined(HAVE_TRUNCATE)
@@ -5130,8 +5640,7 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
path = rb_str_encode_ospath(path);
ta.path = StringValueCStr(path);
- r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_truncate, &ta,
- RUBY_UBF_IO, NULL);
+ r = IO_WITHOUT_GVL_INT(nogvl_truncate, &ta);
if (r < 0)
rb_sys_fail_path(path);
return INT2FIX(0);
@@ -5181,7 +5690,7 @@ rb_file_truncate(VALUE obj, VALUE len)
}
rb_io_flush_raw(obj, 0);
fa.fd = fptr->fd;
- if ((int)rb_thread_io_blocking_region(nogvl_ftruncate, &fa, fa.fd) < 0) {
+ if ((int)rb_io_blocking_region(fptr, nogvl_ftruncate, &fa) < 0) {
rb_sys_fail_path(fptr->pathv);
}
return INT2FIX(0);
@@ -5224,47 +5733,46 @@ rb_thread_flock(void *data)
return (VALUE)ret;
}
-/*
+/* :markup: markdown
+ *
* call-seq:
- * file.flock(locking_constant) -> 0 or false
- *
- * Locks or unlocks a file according to <i>locking_constant</i> (a
- * logical <em>or</em> of the values in the table below).
- * Returns <code>false</code> if File::LOCK_NB is specified and the
- * operation would otherwise have blocked. Not available on all
- * platforms.
- *
- * Locking constants (in class File):
- *
- * LOCK_EX | Exclusive lock. Only one process may hold an
- * | exclusive lock for a given file at a time.
- * ----------+------------------------------------------------
- * LOCK_NB | Don't block when locking. May be combined
- * | with other lock options using logical or.
- * ----------+------------------------------------------------
- * LOCK_SH | Shared lock. Multiple processes may each hold a
- * | shared lock for a given file at the same time.
- * ----------+------------------------------------------------
- * LOCK_UN | Unlock.
+ * flock(locking_constant) -> 0 or false
+ *
+ * Locks or unlocks file `self` according to the given `locking_constant`,
+ * a bitwise OR of the values in the table below.
+ *
+ * Not available on all platforms.
+ *
+ * Returns `false` if `File::LOCK_NB` is specified and the operation would have blocked;
+ * otherwise returns `0`.
+ *
+ * | Constant | Lock | Effect
+ * |-----------------|--------------|-----------------------------------------------------------------------------------------------------------------|
+ * | `File::LOCK_EX` | Exclusive | Only one process may hold an exclusive lock for `self` at a time. |
+ * | `File::LOCK_NB` | Non-blocking | No blocking; may be combined with `File::LOCK_SH` or `File::LOCK_EX` using the bitwise OR operator <tt>\|</tt>. |
+ * | `File::LOCK_SH` | Shared | Multiple processes may each hold a shared lock for `self` at the same time. |
+ * | `File::LOCK_UN` | Unlock | Remove an existing lock held by this process. |
*
* Example:
*
- * # update a counter using write lock
- * # don't use "w" because it truncates the file before lock.
- * File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
- * f.flock(File::LOCK_EX)
- * value = f.read.to_i + 1
- * f.rewind
- * f.write("#{value}\n")
- * f.flush
- * f.truncate(f.pos)
- * }
- *
- * # read the counter using read lock
- * File.open("counter", "r") {|f|
- * f.flock(File::LOCK_SH)
- * p f.read
- * }
+ * ```ruby
+ * # Update a counter using an exclusive lock.
+ * # Don't use File::WRONLY because it truncates the file.
+ * File.open('counter', File::RDWR | File::CREAT, 0644) do |f|
+ * f.flock(File::LOCK_EX)
+ * value = f.read.to_i + 1
+ * f.rewind
+ * f.write("#{value}\n")
+ * f.flush
+ * f.truncate(f.pos)
+ * end
+ *
+ * # Read the counter using a shared lock.
+ * File.open('counter', 'r') do |f|
+ * f.flock(File::LOCK_SH)
+ * f.read
+ * end
+ * ```
*
*/
@@ -5282,7 +5790,7 @@ rb_file_flock(VALUE obj, VALUE operation)
if (fptr->mode & FMODE_WRITABLE) {
rb_io_flush_raw(obj, 0);
}
- while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) {
+ while ((int)rb_io_blocking_region(fptr, rb_thread_flock, op) < 0) {
int e = errno;
switch (e) {
case EAGAIN:
@@ -5328,60 +5836,83 @@ test_check(int n, int argc, VALUE *argv)
#define CHECK(n) test_check((n), argc, argv)
/*
+ * :markup: markdown
+ *
* call-seq:
- * test(cmd, file1 [, file2] ) -> obj
- *
- * Uses the character +cmd+ to perform various tests on +file1+ (first
- * table below) or on +file1+ and +file2+ (second table).
- *
- * File tests on a single file:
- *
- * Cmd Returns Meaning
- * "A" | Time | Last access time for file1
- * "b" | boolean | True if file1 is a block device
- * "c" | boolean | True if file1 is a character device
- * "C" | Time | Last change time for file1
- * "d" | boolean | True if file1 exists and is a directory
- * "e" | boolean | True if file1 exists
- * "f" | boolean | True if file1 exists and is a regular file
- * "g" | boolean | True if file1 has the setgid bit set
- * "G" | boolean | True if file1 exists and has a group
- * | | ownership equal to the caller's group
- * "k" | boolean | True if file1 exists and has the sticky bit set
- * "l" | boolean | True if file1 exists and is a symbolic link
- * "M" | Time | Last modification time for file1
- * "o" | boolean | True if file1 exists and is owned by
- * | | the caller's effective uid
- * "O" | boolean | True if file1 exists and is owned by
- * | | the caller's real uid
- * "p" | boolean | True if file1 exists and is a fifo
- * "r" | boolean | True if file1 is readable by the effective
- * | | uid/gid of the caller
- * "R" | boolean | True if file is readable by the real
- * | | uid/gid of the caller
- * "s" | int/nil | If file1 has nonzero size, return the size,
- * | | otherwise return nil
- * "S" | boolean | True if file1 exists and is a socket
- * "u" | boolean | True if file1 has the setuid bit set
- * "w" | boolean | True if file1 exists and is writable by
- * | | the effective uid/gid
- * "W" | boolean | True if file1 exists and is writable by
- * | | the real uid/gid
- * "x" | boolean | True if file1 exists and is executable by
- * | | the effective uid/gid
- * "X" | boolean | True if file1 exists and is executable by
- * | | the real uid/gid
- * "z" | boolean | True if file1 exists and has a zero length
- *
- * Tests that take two files:
- *
- * "-" | boolean | True if file1 and file2 are identical
- * "=" | boolean | True if the modification times of file1
- * | | and file2 are equal
- * "<" | boolean | True if the modification time of file1
- * | | is prior to that of file2
- * ">" | boolean | True if the modification time of file1
- * | | is after that of file2
+ * test(char, path0, path1 = nil) -> object
+ *
+ * Performs a test on one or both of the <i>filesystem entities</i> at the given paths
+ * `path0` and `path1`:
+ *
+ * - Each path `path0` or `path1` points to a file, directory, device, pipe, etc.
+ * - Character `char` selects a specific test.
+ *
+ * The tests:
+ *
+ * - Each of these tests operates only on the entity at `path0`,
+ * and returns `true` or `false`;
+ * for a non-existent entity, returns `false` (does not raise exception):
+ *
+ * | Character | Test |
+ * |:------------:|:--------------------------------------------------------------------------|
+ * | <tt>'b'</tt> | Whether the entity is a block device. |
+ * | <tt>'c'</tt> | Whether the entity is a character device. |
+ * | <tt>'d'</tt> | Whether the entity is a directory. |
+ * | <tt>'e'</tt> | Whether the entity is an existing entity. |
+ * | <tt>'f'</tt> | Whether the entity is an existing regular file. |
+ * | <tt>'g'</tt> | Whether the entity's setgid bit is set. |
+ * | <tt>'G'</tt> | Whether the entity's group ownership is equal to the caller's. |
+ * | <tt>'k'</tt> | Whether the entity's sticky bit is set. |
+ * | <tt>'l'</tt> | Whether the entity is a symbolic link. |
+ * | <tt>'o'</tt> | Whether the entity is owned by the caller's effective uid. |
+ * | <tt>'O'</tt> | Like <tt>'o'</tt>, but uses the real uid (not the effective uid). |
+ * | <tt>'p'</tt> | Whether the entity is a FIFO device (named pipe). |
+ * | <tt>'r'</tt> | Whether the entity is readable by the caller's effective uid/gid. |
+ * | <tt>'R'</tt> | Like <tt>'r'</tt>, but uses the real uid/gid (not the effective uid/gid). |
+ * | <tt>'S'</tt> | Whether the entity is a socket. |
+ * | <tt>'u'</tt> | Whether the entity's setuid bit is set. |
+ * | <tt>'w'</tt> | Whether the entity is writable by the caller's effective uid/gid. |
+ * | <tt>'W'</tt> | Like <tt>'w'</tt>, but uses the real uid/gid (not the effective uid/gid). |
+ * | <tt>'x'</tt> | Whether the entity is executable by the caller's effective uid/gid. |
+ * | <tt>'X'</tt> | Like <tt>'x'</tt>, but uses the real uid/gid (not the effective uid/git). |
+ * | <tt>'z'</tt> | Whether the entity exists and is of length zero. |
+ *
+ * - This test operates only on the entity at `path0`,
+ * and returns an integer size or `nil`:
+ *
+ * | Character | Test |
+ * |:------------:|:---------------------------------------------------------------------------------------------|
+ * | <tt>'s'</tt> | Returns positive integer size if the entity exists and has non-zero length, `nil` otherwise. |
+ *
+ * - Each of these tests operates only on the entity at `path0`,
+ * and returns a Time object;
+ * raises an exception if the entity does not exist:
+ *
+ * | Character | Test |
+ * |:------------:|:---------------------------------------|
+ * | <tt>'A'</tt> | Last access time for the entity. |
+ * | <tt>'C'</tt> | Last change time for the entity. |
+ * | <tt>'M'</tt> | Last modification time for the entity. |
+ *
+ * - Each of these tests operates on the modification time (`mtime`)
+ * of each of the entities at `path0` and `path1`,
+ * and returns a `true` or `false`;
+ * returns `false` if either entity does not exist:
+ *
+ * | Character | Test |
+ * |:------------:|:----------------------------------------------------------------|
+ * | <tt>'<'</tt> | Whether the `mtime` at `path0` is less than that at `path1`. |
+ * | <tt>'='</tt> | Whether the `mtime` at `path0` is equal to that at `path1`. |
+ * | <tt>'>'</tt> | Whether the `mtime` at `path0` is greater than that at `path1`. |
+ *
+ * - This test operates on the content of each of the entities at `path0` and `path1`,
+ * and returns a `true` or `false`;
+ * returns `false` if either entity does not exist:
+ *
+ * | Character | Test |
+ * |:------------:|:----------------------------------------------|
+ * | <tt>'-'</tt> | Whether the entities exist and are identical. |
+ *
*/
static VALUE
@@ -5493,7 +6024,7 @@ rb_f_test(int argc, VALUE *argv, VALUE _)
if (strchr("=<>", cmd)) {
struct stat st1, st2;
- struct timespec t1, t2;
+ stat_timestamp t1, t2;
CHECK(2);
if (rb_stat(argv[1], &st1) < 0) return Qfalse;
@@ -5533,24 +6064,60 @@ rb_f_test(int argc, VALUE *argv, VALUE _)
/*
* Document-class: File::Stat
*
- * Objects of class File::Stat encapsulate common status information
- * for File objects. The information is recorded at the moment the
- * File::Stat object is created; changes made to the file after that
- * point will not be reflected. File::Stat objects are returned by
- * IO#stat, File::stat, File#lstat, and File::lstat. Many of these
- * methods return platform-specific values, and not all values are
- * meaningful on all systems. See also Kernel#test.
+ * A \File::Stat object contains information about an entry in the file system.
+ *
+ * Each of these methods returns a new \File::Stat object:
+ *
+ * - File#lstat.
+ * - File::Stat.new.
+ * - File::lstat.
+ * - File::stat.
+ * - IO#stat.
+ *
+ * === Snapshot
+ *
+ * A new \File::Stat object takes an immediate "snapshot" of the entry's information;
+ * the captured information is never updated,
+ * regardless of changes in the actual entry:
+ *
+ * The entry must exist when File::Stat.new is called:
+ *
+ * filepath = 't.tmp'
+ * File.exist?(filepath) # => false
+ * File::Stat.new(filepath) # Raises Errno::ENOENT: No such file or directory.
+ * File.write(filepath, 'foo') # Create the file.
+ * stat = File::Stat.new(filepath) # Okay.
+ *
+ * Later changes to the actual entry do not change the \File::Stat object:
+ *
+ * File.atime(filepath) # => 2026-04-01 11:51:38.0014518 -0500
+ * stat.atime # => 2026-04-01 11:51:38.0014518 -0500
+ * File.write(filepath, 'bar')
+ * File.atime(filepath) # => 2026-04-01 11:58:11.922614 -0500
+ * stat.atime # => 2026-04-01 11:51:38.0014518 -0500
+ * File.delete(filepath)
+ * stat.atime # => 2026-04-01 11:51:38.0014518 -0500
+ *
+ * === OS-Dependencies
+ *
+ * Methods in a \File::Stat object may return platform-dependents values,
+ * and not all values are meaningful on all systems;
+ * for example, File::Stat#blocks returns +nil+ on Windows,
+ * but returns an integer on Linux.
+ *
+ * See also Kernel#test.
*/
static VALUE
rb_stat_s_alloc(VALUE klass)
{
- return stat_new_0(klass, 0);
+ VALUE obj;
+ stat_alloc(rb_cStat, &obj);
+ return obj;
}
/*
* call-seq:
- *
* File::Stat.new(file_name) -> stat
*
* Create a File::Stat object for the given file name (raising an
@@ -5560,21 +6127,19 @@ rb_stat_s_alloc(VALUE klass)
static VALUE
rb_stat_init(VALUE obj, VALUE fname)
{
- struct stat st, *nst;
+ rb_io_stat_data st;
FilePathValue(fname);
fname = rb_str_encode_ospath(fname);
- if (STAT(StringValueCStr(fname), &st) == -1) {
+ if (STATX(StringValueCStr(fname), &st, STATX_ALL) == -1) {
rb_sys_fail_path(fname);
}
- if (DATA_PTR(obj)) {
- xfree(DATA_PTR(obj));
- DATA_PTR(obj) = NULL;
- }
- nst = ALLOC(struct stat);
- *nst = st;
- DATA_PTR(obj) = nst;
+ struct rb_stat *rb_st;
+ TypedData_Get_Struct(obj, struct rb_stat, &stat_data_type, rb_st);
+
+ rb_st->stat = st;
+ rb_st->initialized = true;
return Qnil;
}
@@ -5583,19 +6148,15 @@ rb_stat_init(VALUE obj, VALUE fname)
static VALUE
rb_stat_init_copy(VALUE copy, VALUE orig)
{
- struct stat *nst;
-
if (!OBJ_INIT_COPY(copy, orig)) return copy;
- if (DATA_PTR(copy)) {
- xfree(DATA_PTR(copy));
- DATA_PTR(copy) = 0;
- }
- if (DATA_PTR(orig)) {
- nst = ALLOC(struct stat);
- *nst = *(struct stat*)DATA_PTR(orig);
- DATA_PTR(copy) = nst;
- }
+ struct rb_stat *orig_rb_st;
+ TypedData_Get_Struct(orig, struct rb_stat, &stat_data_type, orig_rb_st);
+
+ struct rb_stat *copy_rb_st;
+ TypedData_Get_Struct(copy, struct rb_stat, &stat_data_type, copy_rb_st);
+
+ *copy_rb_st = *orig_rb_st;
return copy;
}
@@ -5616,7 +6177,7 @@ rb_stat_init_copy(VALUE copy, VALUE orig)
static VALUE
rb_stat_ftype(VALUE obj)
{
- return rb_file_ftype(get_stat(obj));
+ return rb_file_ftype(get_stat(obj)->ST_(mode));
}
/*
@@ -5633,7 +6194,7 @@ rb_stat_ftype(VALUE obj)
static VALUE
rb_stat_d(VALUE obj)
{
- if (S_ISDIR(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISDIR(get_stat(obj)->ST_(mode))) return Qtrue;
return Qfalse;
}
@@ -5649,7 +6210,7 @@ static VALUE
rb_stat_p(VALUE obj)
{
#ifdef S_IFIFO
- if (S_ISFIFO(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISFIFO(get_stat(obj)->ST_(mode))) return Qtrue;
#endif
return Qfalse;
@@ -5675,7 +6236,7 @@ static VALUE
rb_stat_l(VALUE obj)
{
#ifdef S_ISLNK
- if (S_ISLNK(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISLNK(get_stat(obj)->ST_(mode))) return Qtrue;
#endif
return Qfalse;
}
@@ -5696,7 +6257,7 @@ static VALUE
rb_stat_S(VALUE obj)
{
#ifdef S_ISSOCK
- if (S_ISSOCK(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISSOCK(get_stat(obj)->ST_(mode))) return Qtrue;
#endif
return Qfalse;
@@ -5719,7 +6280,7 @@ static VALUE
rb_stat_b(VALUE obj)
{
#ifdef S_ISBLK
- if (S_ISBLK(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISBLK(get_stat(obj)->ST_(mode))) return Qtrue;
#endif
return Qfalse;
@@ -5740,7 +6301,7 @@ rb_stat_b(VALUE obj)
static VALUE
rb_stat_c(VALUE obj)
{
- if (S_ISCHR(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISCHR(get_stat(obj)->ST_(mode))) return Qtrue;
return Qfalse;
}
@@ -5760,14 +6321,14 @@ rb_stat_c(VALUE obj)
static VALUE
rb_stat_owned(VALUE obj)
{
- if (get_stat(obj)->st_uid == geteuid()) return Qtrue;
+ if (get_stat(obj)->ST_(uid) == geteuid()) return Qtrue;
return Qfalse;
}
static VALUE
rb_stat_rowned(VALUE obj)
{
- if (get_stat(obj)->st_uid == getuid()) return Qtrue;
+ if (get_stat(obj)->ST_(uid) == getuid()) return Qtrue;
return Qfalse;
}
@@ -5787,7 +6348,7 @@ static VALUE
rb_stat_grpowned(VALUE obj)
{
#ifndef _WIN32
- if (rb_group_member(get_stat(obj)->st_gid)) return Qtrue;
+ if (rb_group_member(get_stat(obj)->ST_(gid))) return Qtrue;
#endif
return Qfalse;
}
@@ -5806,21 +6367,21 @@ rb_stat_grpowned(VALUE obj)
static VALUE
rb_stat_r(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
if (rb_stat_owned(obj))
- return RBOOL(st->st_mode & S_IRUSR);
+ return RBOOL(st->ST_(mode) & S_IRUSR);
#endif
#ifdef S_IRGRP
if (rb_stat_grpowned(obj))
- return RBOOL(st->st_mode & S_IRGRP);
+ return RBOOL(st->ST_(mode) & S_IRGRP);
#endif
#ifdef S_IROTH
- if (!(st->st_mode & S_IROTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IROTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -5839,21 +6400,21 @@ rb_stat_r(VALUE obj)
static VALUE
rb_stat_R(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
if (rb_stat_rowned(obj))
- return RBOOL(st->st_mode & S_IRUSR);
+ return RBOOL(st->ST_(mode) & S_IRUSR);
#endif
#ifdef S_IRGRP
- if (rb_group_member(get_stat(obj)->st_gid))
- return RBOOL(st->st_mode & S_IRGRP);
+ if (rb_group_member(get_stat(obj)->ST_(gid)))
+ return RBOOL(st->ST_(mode) & S_IRGRP);
#endif
#ifdef S_IROTH
- if (!(st->st_mode & S_IROTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IROTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -5875,14 +6436,12 @@ static VALUE
rb_stat_wr(VALUE obj)
{
#ifdef S_IROTH
- struct stat *st = get_stat(obj);
- if ((st->st_mode & (S_IROTH)) == S_IROTH) {
- return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
- else {
- return Qnil;
+ rb_io_stat_data *st = get_stat(obj);
+ if ((st->ST_(mode) & (S_IROTH)) == S_IROTH) {
+ return UINT2NUM(st->ST_(mode) & (S_IRUGO|S_IWUGO|S_IXUGO));
}
#endif
+ return Qnil;
}
/*
@@ -5899,21 +6458,21 @@ rb_stat_wr(VALUE obj)
static VALUE
rb_stat_w(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
if (rb_stat_owned(obj))
- return RBOOL(st->st_mode & S_IWUSR);
+ return RBOOL(st->ST_(mode) & S_IWUSR);
#endif
#ifdef S_IWGRP
if (rb_stat_grpowned(obj))
- return RBOOL(st->st_mode & S_IWGRP);
+ return RBOOL(st->ST_(mode) & S_IWGRP);
#endif
#ifdef S_IWOTH
- if (!(st->st_mode & S_IWOTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IWOTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -5932,21 +6491,21 @@ rb_stat_w(VALUE obj)
static VALUE
rb_stat_W(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
if (rb_stat_rowned(obj))
- return RBOOL(st->st_mode & S_IWUSR);
+ return RBOOL(st->ST_(mode) & S_IWUSR);
#endif
#ifdef S_IWGRP
- if (rb_group_member(get_stat(obj)->st_gid))
- return RBOOL(st->st_mode & S_IWGRP);
+ if (rb_group_member(get_stat(obj)->ST_(gid)))
+ return RBOOL(st->ST_(mode) & S_IWGRP);
#endif
#ifdef S_IWOTH
- if (!(st->st_mode & S_IWOTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IWOTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -5967,15 +6526,13 @@ rb_stat_W(VALUE obj)
static VALUE
rb_stat_ww(VALUE obj)
{
-#ifdef S_IROTH
- struct stat *st = get_stat(obj);
- if ((st->st_mode & (S_IWOTH)) == S_IWOTH) {
- return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
- else {
- return Qnil;
+#ifdef S_IWOTH
+ rb_io_stat_data *st = get_stat(obj);
+ if ((st->ST_(mode) & (S_IWOTH)) == S_IWOTH) {
+ return UINT2NUM(st->ST_(mode) & (S_IRUGO|S_IWUGO|S_IXUGO));
}
#endif
+ return Qnil;
}
/*
@@ -5994,23 +6551,23 @@ rb_stat_ww(VALUE obj)
static VALUE
rb_stat_x(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) {
- return RBOOL(st->st_mode & S_IXUGO);
+ return RBOOL(st->ST_(mode) & S_IXUGO);
}
#endif
#ifdef S_IXUSR
if (rb_stat_owned(obj))
- return RBOOL(st->st_mode & S_IXUSR);
+ return RBOOL(st->ST_(mode) & S_IXUSR);
#endif
#ifdef S_IXGRP
if (rb_stat_grpowned(obj))
- return RBOOL(st->st_mode & S_IXGRP);
+ return RBOOL(st->ST_(mode) & S_IXGRP);
#endif
#ifdef S_IXOTH
- if (!(st->st_mode & S_IXOTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IXOTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -6026,23 +6583,23 @@ rb_stat_x(VALUE obj)
static VALUE
rb_stat_X(VALUE obj)
{
- struct stat *st = get_stat(obj);
+ rb_io_stat_data *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) {
- return RBOOL(st->st_mode & S_IXUGO);
+ return RBOOL(st->ST_(mode) & S_IXUGO);
}
#endif
#ifdef S_IXUSR
if (rb_stat_rowned(obj))
- return RBOOL(st->st_mode & S_IXUSR);
+ return RBOOL(st->ST_(mode) & S_IXUSR);
#endif
#ifdef S_IXGRP
- if (rb_group_member(get_stat(obj)->st_gid))
- return RBOOL(st->st_mode & S_IXGRP);
+ if (rb_group_member(get_stat(obj)->ST_(gid)))
+ return RBOOL(st->ST_(mode) & S_IXGRP);
#endif
#ifdef S_IXOTH
- if (!(st->st_mode & S_IXOTH)) return Qfalse;
+ if (!(st->ST_(mode) & S_IXOTH)) return Qfalse;
#endif
return Qtrue;
}
@@ -6061,7 +6618,7 @@ rb_stat_X(VALUE obj)
static VALUE
rb_stat_f(VALUE obj)
{
- if (S_ISREG(get_stat(obj)->st_mode)) return Qtrue;
+ if (S_ISREG(get_stat(obj)->ST_(mode))) return Qtrue;
return Qfalse;
}
@@ -6079,7 +6636,7 @@ rb_stat_f(VALUE obj)
static VALUE
rb_stat_z(VALUE obj)
{
- if (get_stat(obj)->st_size == 0) return Qtrue;
+ if (get_stat(obj)->ST_(size) == 0) return Qtrue;
return Qfalse;
}
@@ -6091,14 +6648,14 @@ rb_stat_z(VALUE obj)
* the file otherwise.
*
* File.stat("testfile").size? #=> 66
- * File.stat("/dev/null").size? #=> nil
+ * File.stat(File::NULL).size? #=> nil
*
*/
static VALUE
rb_stat_s(VALUE obj)
{
- rb_off_t size = get_stat(obj)->st_size;
+ rb_off_t size = get_stat(obj)->ST_(size);
if (size == 0) return Qnil;
return OFFT2NUM(size);
@@ -6119,7 +6676,7 @@ static VALUE
rb_stat_suid(VALUE obj)
{
#ifdef S_ISUID
- if (get_stat(obj)->st_mode & S_ISUID) return Qtrue;
+ if (get_stat(obj)->ST_(mode) & S_ISUID) return Qtrue;
#endif
return Qfalse;
}
@@ -6140,7 +6697,7 @@ static VALUE
rb_stat_sgid(VALUE obj)
{
#ifdef S_ISGID
- if (get_stat(obj)->st_mode & S_ISGID) return Qtrue;
+ if (get_stat(obj)->ST_(mode) & S_ISGID) return Qtrue;
#endif
return Qfalse;
}
@@ -6161,7 +6718,7 @@ static VALUE
rb_stat_sticky(VALUE obj)
{
#ifdef S_ISVTX
- if (get_stat(obj)->st_mode & S_ISVTX) return Qtrue;
+ if (get_stat(obj)->ST_(mode) & S_ISVTX) return Qtrue;
#endif
return Qfalse;
}
@@ -6210,7 +6767,7 @@ rb_file_s_mkfifo(int argc, VALUE *argv, VALUE _)
FilePathValue(path);
path = rb_str_encode_ospath(path);
ma.path = RSTRING_PTR(path);
- if (rb_thread_call_without_gvl(nogvl_mkfifo, &ma, RUBY_UBF_IO, 0)) {
+ if (IO_WITHOUT_GVL(nogvl_mkfifo, &ma)) {
rb_sys_fail_path(path);
}
return INT2FIX(0);
@@ -6242,95 +6799,6 @@ rb_is_absolute_path(const char *path)
return 0;
}
-#ifndef ENABLE_PATH_CHECK
-# if defined DOSISH || defined __CYGWIN__
-# define ENABLE_PATH_CHECK 0
-# else
-# define ENABLE_PATH_CHECK 1
-# endif
-#endif
-
-#if ENABLE_PATH_CHECK
-static int
-path_check_0(VALUE path)
-{
- struct stat st;
- const char *p0 = StringValueCStr(path);
- const char *e0;
- rb_encoding *enc;
- char *p = 0, *s;
-
- if (!rb_is_absolute_path(p0)) {
- char *buf = ruby_getcwd();
- VALUE newpath;
-
- newpath = rb_str_new2(buf);
- xfree(buf);
-
- rb_str_cat2(newpath, "/");
- rb_str_cat2(newpath, p0);
- path = newpath;
- p0 = RSTRING_PTR(path);
- }
- e0 = p0 + RSTRING_LEN(path);
- enc = rb_enc_get(path);
- for (;;) {
-#ifndef S_IWOTH
-# define S_IWOTH 002
-#endif
- if (STAT(p0, &st) == 0 && S_ISDIR(st.st_mode) && (st.st_mode & S_IWOTH)
-#ifdef S_ISVTX
- && !(p && (st.st_mode & S_ISVTX))
-#endif
- && !access(p0, W_OK)) {
- rb_enc_warn(enc, "Insecure world writable dir %s in PATH, mode 0%"
-#if SIZEOF_DEV_T > SIZEOF_INT
- PRI_MODET_PREFIX"o",
-#else
- "o",
-#endif
- p0, st.st_mode);
- if (p) *p = '/';
- RB_GC_GUARD(path);
- return 0;
- }
- s = strrdirsep(p0, e0, enc);
- if (p) *p = '/';
- if (!s || s == p0) return 1;
- p = s;
- e0 = p;
- *p = '\0';
- }
-}
-#endif
-
-int
-rb_path_check(const char *path)
-{
-#if ENABLE_PATH_CHECK
- const char *p0, *p, *pend;
- const char sep = PATH_SEP_CHAR;
-
- if (!path) return 1;
-
- pend = path + strlen(path);
- p0 = path;
- p = strchr(path, sep);
- if (!p) p = pend;
-
- for (;;) {
- if (!path_check_0(rb_str_new(p0, p - p0))) {
- return 0; /* not safe */
- }
- p0 = p + 1;
- if (p0 > pend) break;
- p = strchr(p0, sep);
- if (!p) p = pend;
- }
-#endif
- return 1;
-}
-
int
ruby_is_fd_loadable(int fd)
{
@@ -6533,10 +7001,10 @@ const char ruby_null_device[] =
/*
* A \File object is a representation of a file in the underlying platform.
*
- * \Class \File extends module FileTest, supporting such singleton methods
+ * Class \File extends module FileTest, supporting such singleton methods
* as <tt>File.exist?</tt>.
*
- * === About the Examples
+ * == About the Examples
*
* Many examples here use these variables:
*
@@ -6544,14 +7012,14 @@ const char ruby_null_device[] =
*
* == Access Modes
*
- * \Methods File.new and File.open each create a \File object for a given file path.
+ * Methods File.new and File.open each create a \File object for a given file path.
*
* === \String Access Modes
*
- * \Methods File.new and File.open each may take string argument +mode+, which:
+ * Methods File.new and File.open each may take string argument +mode+, which:
*
* - Begins with a 1- or 2-character
- * {read/write mode}[rdoc-ref:File@Read-2FWrite+Mode].
+ * {read/write mode}[rdoc-ref:File@ReadWrite+Mode].
* - May also contain a 1-character {data mode}[rdoc-ref:File@Data+Mode].
* - May also contain a 1-character
* {file-create mode}[rdoc-ref:File@File-Create+Mode].
@@ -6617,7 +7085,7 @@ const char ruby_null_device[] =
*
* - <tt>'r'</tt>:
*
- * - File is not initially truncated:
+ * - \File is not initially truncated:
*
* f = File.new('t.txt') # => #<File:t.txt>
* f.size == 0 # => false
@@ -6626,7 +7094,7 @@ const char ruby_null_device[] =
*
* f.pos # => 0
*
- * - File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
+ * - \File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
*
* f.readline # => "First line\n"
* f.readline # => "Second line\n"
@@ -6646,7 +7114,7 @@ const char ruby_null_device[] =
*
* - <tt>'w'</tt>:
*
- * - File is initially truncated:
+ * - \File is initially truncated:
*
* path = 't.tmp'
* File.write(path, text)
@@ -6657,7 +7125,7 @@ const char ruby_null_device[] =
*
* f.pos # => 0
*
- * - File may be written anywhere (even past end-of-file);
+ * - \File may be written anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.write('foo')
@@ -6700,7 +7168,7 @@ const char ruby_null_device[] =
*
* - <tt>'a'</tt>:
*
- * - File is not initially truncated:
+ * - \File is not initially truncated:
*
* path = 't.tmp'
* File.write(path, 'foo')
@@ -6711,7 +7179,7 @@ const char ruby_null_device[] =
*
* f.pos # => 0
*
- * - File may be written only at end-of-file;
+ * - \File may be written only at end-of-file;
* IO#rewind, IO#pos=, IO#seek do not affect writing:
*
* f.write('bar')
@@ -6732,7 +7200,7 @@ const char ruby_null_device[] =
*
* - <tt>'r+'</tt>:
*
- * - File is not initially truncated:
+ * - \File is not initially truncated:
*
* path = 't.tmp'
* File.write(path, text)
@@ -6743,7 +7211,7 @@ const char ruby_null_device[] =
*
* f.pos # => 0
*
- * - File may be read or written anywhere (even past end-of-file);
+ * - \File may be read or written anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.readline # => "First line\n"
@@ -6788,7 +7256,7 @@ const char ruby_null_device[] =
*
* - <tt>'a+'</tt>:
*
- * - File is not initially truncated:
+ * - \File is not initially truncated:
*
* path = 't.tmp'
* File.write(path, 'foo')
@@ -6799,7 +7267,7 @@ const char ruby_null_device[] =
*
* f.pos # => 0
*
- * - File may be written only at end-of-file;
+ * - \File may be written only at end-of-file;
* IO#rewind, IO#pos=, IO#seek do not affect writing:
*
* f.write('bar')
@@ -6814,7 +7282,7 @@ const char ruby_null_device[] =
* f.flush
* File.read(path) # => "foobarbazbat"
*
- * - File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
+ * - \File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
*
* f.rewind
* f.read # => "foobarbazbat"
@@ -6839,7 +7307,7 @@ const char ruby_null_device[] =
* f = File.new(path, 'w')
* f.pos # => 0
*
- * - File may be written anywhere (even past end-of-file);
+ * - \File may be written anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.write('foo')
@@ -6916,7 +7384,7 @@ const char ruby_null_device[] =
* f = File.new(path, 'w+')
* f.pos # => 0
*
- * - File may be written anywhere (even past end-of-file);
+ * - \File may be written anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.write('foo')
@@ -6953,7 +7421,7 @@ const char ruby_null_device[] =
* File.read(path) # => "bazbam\u0000\u0000bah"
* f.pos # => 11
*
- * - File may be read anywhere (even past end-of-file);
+ * - \File may be read anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.rewind
@@ -6994,7 +7462,7 @@ const char ruby_null_device[] =
* f.flush
* File.read(path) # => "foobarbaz"
*
- * - File may be read anywhere (even past end-of-file);
+ * - \File may be read anywhere (even past end-of-file);
* see IO#rewind, IO#pos=, IO#seek:
*
* f.rewind
@@ -7139,7 +7607,6 @@ const char ruby_null_device[] =
*
* Note that file permissions are quite different from the _mode_
* of a file stream (\File object).
- * See IO@Modes.
*
* In a \File object, the permissions are available thus,
* where method +mode+, despite its name, returns permissions:
@@ -7185,17 +7652,17 @@ const char ruby_null_device[] =
*
* == \File \Constants
*
- * Various constants for use in \File and \IO methods
+ * Various constants for use in \File and IO methods
* may be found in module File::Constants;
* an array of their names is returned by <tt>File::Constants.constants</tt>.
*
* == What's Here
*
- * First, what's elsewhere. \Class \File:
+ * First, what's elsewhere. Class \File:
*
- * - Inherits from {class IO}[rdoc-ref:IO@What-27s+Here],
+ * - Inherits from {class IO}[rdoc-ref:IO@Whats+Here],
* in particular, methods for creating, reading, and writing files
- * - Includes {module FileTest}[rdoc-ref:FileTest@What-27s+Here].
+ * - Includes module FileTest,
* which provides dozens of additional methods.
*
* Here, class \File provides methods that are useful for:
@@ -7240,15 +7707,15 @@ const char ruby_null_device[] =
*
* _Times_
*
- * - ::atime: Returns a \Time for the most recent access to the given file.
- * - ::birthtime: Returns a \Time for the creation of the given file.
- * - ::ctime: Returns a \Time for the metadata change of the given file.
- * - ::mtime: Returns a \Time for the most recent data modification to
+ * - ::atime: Returns a Time for the most recent access to the given file.
+ * - ::birthtime: Returns a Time for the creation of the given file.
+ * - ::ctime: Returns a Time for the metadata change of the given file.
+ * - ::mtime: Returns a Time for the most recent data modification to
* the content of the given file.
- * - #atime: Returns a \Time for the most recent access to +self+.
- * - #birthtime: Returns a \Time the creation for +self+.
- * - #ctime: Returns a \Time for the metadata change of +self+.
- * - #mtime: Returns a \Time for the most recent data modification
+ * - #atime: Returns a Time for the most recent access to +self+.
+ * - #birthtime: Returns a Time the creation for +self+.
+ * - #ctime: Returns a Time for the metadata change of +self+.
+ * - #mtime: Returns a Time for the most recent data modification
* to the content of +self+.
*
* _Types_
@@ -7408,7 +7875,7 @@ Init_File(void)
/* separates directory parts in path */
rb_define_const(rb_cFile, "SEPARATOR", separator);
rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1);
- rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
+ rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -1);
#ifdef DOSISH
/* platform specific alternative separator */
@@ -7437,93 +7904,400 @@ Init_File(void)
/*
* Document-module: File::Constants
*
- * File::Constants provides file-related constants. All possible
- * file constants are listed in the documentation but they may not all
- * be present on your platform.
+ * Module +File::Constants+ defines file-related constants.
+ *
+ * There are two families of constants here:
+ *
+ * - Those having to do with {file access}[rdoc-ref:File::Constants@File+Access].
+ * - Those having to do with {filename globbing}[rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-3AFNM_-2A-29].
+ *
+ * \File constants defined for the local process may be retrieved
+ * with method File::Constants.constants:
+ *
+ * File::Constants.constants.take(5)
+ * # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]
+ *
+ * == \File Access
+ *
+ * \File-access constants may be used with optional argument +mode+ in calls
+ * to the following methods:
+ *
+ * - File.new.
+ * - File.open.
+ * - IO.for_fd.
+ * - IO.new.
+ * - IO.open.
+ * - IO.popen.
+ * - IO.reopen.
+ * - IO.sysopen.
+ * - StringIO.new.
+ * - StringIO.open.
+ * - StringIO#reopen.
+ *
+ * === Read/Write Access
+ *
+ * Read-write access for a stream
+ * may be specified by a file-access constant.
+ *
+ * The constant may be specified as part of a bitwise OR of other such constants.
+ *
+ * Any combination of the constants in this section may be specified.
+ *
+ * ==== File::RDONLY
+ *
+ * Flag File::RDONLY specifies the stream should be opened for reading only:
+ *
+ * filepath = '/tmp/t.tmp'
+ * f = File.new(filepath, File::RDONLY)
+ * f.write('Foo') # Raises IOError (not opened for writing).
+ *
+ * ==== File::WRONLY
+ *
+ * Flag File::WRONLY specifies that the stream should be opened for writing only:
+ *
+ * f = File.new(filepath, File::WRONLY)
+ * f.read # Raises IOError (not opened for reading).
+ *
+ * ==== File::RDWR
+ *
+ * Flag File::RDWR specifies that the stream should be opened
+ * for both reading and writing:
+ *
+ * f = File.new(filepath, File::RDWR)
+ * f.write('Foo') # => 3
+ * f.rewind # => 0
+ * f.read # => "Foo"
+ *
+ * === \File Positioning
+ *
+ * ==== File::APPEND
+ *
+ * Flag File::APPEND specifies that the stream should be opened
+ * in append mode.
+ *
+ * Before each write operation, the position is set to end-of-stream.
+ * The modification of the position and the following write operation
+ * are performed as a single atomic step.
+ *
+ * ==== File::TRUNC
+ *
+ * Flag File::TRUNC specifies that the stream should be truncated
+ * at its beginning.
+ * If the file exists and is successfully opened for writing,
+ * it is to be truncated to position zero;
+ * its ctime and mtime are updated.
+ *
+ * There is no effect on a FIFO special file or a terminal device.
+ * The effect on other file types is implementation-defined.
+ * The result of using File::TRUNC with File::RDONLY is undefined.
+ *
+ * === Creating and Preserving
+ *
+ * ==== File::CREAT
+ *
+ * Flag File::CREAT specifies that the stream should be created
+ * if it does not already exist.
+ *
+ * If the file exists:
+ *
+ * - Raise an exception if File::EXCL is also specified.
+ * - Otherwise, do nothing.
+ *
+ * If the file does not exist, then it is created.
+ * Upon successful completion, the atime, ctime, and mtime of the file are updated,
+ * and the ctime and mtime of the parent directory are updated.
+ *
+ * ==== File::EXCL
+ *
+ * Flag File::EXCL specifies that the stream should not already exist;
+ * If flags File::CREAT and File::EXCL are both specified
+ * and the stream already exists, an exception is raised.
+ *
+ * The check for the existence and creation of the file is performed as an
+ * atomic operation.
*
- * If the underlying platform doesn't define a constant the corresponding
- * Ruby constant is not defined.
+ * If both File::EXCL and File::CREAT are specified and the path names a symbolic link,
+ * an exception is raised regardless of the contents of the symbolic link.
+ *
+ * If File::EXCL is specified and File::CREAT is not specified,
+ * the result is undefined.
+ *
+ * === POSIX \File \Constants
+ *
+ * Some file-access constants are defined only on POSIX-compliant systems;
+ * those are:
+ *
+ * - File::SYNC.
+ * - File::DSYNC.
+ * - File::RSYNC.
+ * - File::DIRECT.
+ * - File::NOATIME.
+ * - File::NOCTTY.
+ * - File::NOFOLLOW.
+ * - File::TMPFILE.
+ *
+ * ==== File::SYNC, File::RSYNC, and File::DSYNC
+ *
+ * Flag File::SYNC, File::RSYNC, or File::DSYNC
+ * specifies synchronization of I/O operations with the underlying file system.
+ *
+ * These flags are valid only for POSIX-compliant systems.
+ *
+ * - File::SYNC specifies that all write operations (both data and metadata)
+ * are immediately to be flushed to the underlying storage device.
+ * This means that the data is written to the storage device,
+ * and the file's metadata (e.g., file size, timestamps, permissions)
+ * are also synchronized.
+ * This guarantees that data is safely stored on the storage medium
+ * before returning control to the calling program.
+ * This flag can have a significant impact on performance
+ * since it requires synchronous writes, which can be slower
+ * compared to asynchronous writes.
+ *
+ * - File::RSYNC specifies that any read operations on the file will not return
+ * until all outstanding write operations
+ * (those that have been issued but not completed) are also synchronized.
+ * This is useful when you want to read the most up-to-date data,
+ * which may still be in the process of being written.
+ *
+ * - File::DSYNC specifies that all _data_ write operations
+ * are immediately to be flushed to the underlying storage device;
+ * this differs from File::SYNC, which requires that _metadata_
+ * also be synchronized.
+ *
+ * Note that the behavior of these flags may vary slightly
+ * depending on the operating system and filesystem being used.
+ * Additionally, using these flags can have an impact on performance
+ * due to the synchronous nature of the I/O operations,
+ * so they should be used judiciously,
+ * especially in performance-critical applications.
+ *
+ * ==== File::NOCTTY
+ *
+ * Flag File::NOCTTY specifies that if the stream is a terminal device,
+ * that device does not become the controlling terminal for the process.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::DIRECT
+ *
+ * Flag File::DIRECT requests that cache effects of the I/O to and from the stream
+ * be minimized.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::NOATIME
+ *
+ * Flag File::NOATIME specifies that act of opening the stream
+ * should not modify its access time (atime).
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::NOFOLLOW
+ *
+ * Flag File::NOFOLLOW specifies that if path is a symbolic link,
+ * it should not be followed.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::TMPFILE
+ *
+ * Flag File::TMPFILE specifies that the opened stream
+ * should be a new temporary file.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * === Other File-Access \Constants
+ *
+ * ==== File::NONBLOCK
+ *
+ * When possible, the file is opened in nonblocking mode.
+ * Neither the open operation nor any subsequent I/O operations on
+ * the file will cause the calling process to wait.
+ *
+ * ==== File::BINARY
+ *
+ * Flag File::BINARY specifies that the stream is to be accessed in binary mode.
+ *
+ * ==== File::SHARE_DELETE
+ *
+ * Flag File::SHARE_DELETE enables other processes to open the stream
+ * with delete access.
+ *
+ * Windows only.
+ *
+ * If the stream is opened for (local) delete access without File::SHARE_DELETE,
+ * and another process attempts to open it with delete access,
+ * the attempt fails and the stream is not opened for that process.
+ *
+ * == Locking
+ *
+ * Four file constants relate to stream locking;
+ * see File#flock:
+ *
+ * ==== File::LOCK_EX
+ *
+ * Flag File::LOCK_EX specifies an exclusive lock;
+ * only one process a a time may lock the stream.
+ *
+ * ==== File::LOCK_NB
+ *
+ * Flag File::LOCK_NB specifies non-blocking locking for the stream;
+ * may be combined with File::LOCK_EX or File::LOCK_SH.
+ *
+ * ==== File::LOCK_SH
+ *
+ * Flag File::LOCK_SH specifies that multiple processes may lock
+ * the stream at the same time.
+ *
+ * ==== File::LOCK_UN
+ *
+ * Flag File::LOCK_UN specifies that the stream is not to be locked.
+ *
+ * == Filename Globbing \Constants (File::FNM_*)
+ *
+ * Filename-globbing constants may be used with optional argument +flags+
+ * in calls to the following methods:
+ *
+ * - Dir.glob.
+ * - File.fnmatch.
+ * - Pathname#fnmatch.
+ * - Pathname.glob.
+ * - Pathname#glob.
+ *
+ * The constants are:
+ *
+ * ==== File::FNM_CASEFOLD
+ *
+ * Flag File::FNM_CASEFOLD makes patterns case insensitive
+ * for File.fnmatch (but not Dir.glob).
+ *
+ * ==== File::FNM_DOTMATCH
+ *
+ * Flag File::FNM_DOTMATCH makes the <tt>'*'</tt> pattern
+ * match a filename starting with <tt>'.'</tt>.
+ *
+ * ==== File::FNM_EXTGLOB
+ *
+ * Flag File::FNM_EXTGLOB enables pattern <tt>'{a,b}'</tt>,
+ * which matches pattern '_a_' and pattern '_b_';
+ * behaves like
+ * a {regexp union}[rdoc-ref:Regexp.union]
+ * (e.g., <tt>'(?:a|b)'</tt>):
+ *
+ * pattern = '{LEGAL,BSDL}'
+ * Dir.glob(pattern) # => ["LEGAL", "BSDL"]
+ * Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
+ * pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
+ *
+ * ==== File::FNM_NOESCAPE
+ *
+ * Flag File::FNM_NOESCAPE disables <tt>'\'</tt> escaping.
+ *
+ * ==== File::FNM_PATHNAME
+ *
+ * Flag File::FNM_PATHNAME specifies that patterns <tt>'*'</tt> and <tt>'?'</tt>
+ * do not match the directory separator
+ * (the value of constant File::SEPARATOR).
+ *
+ * ==== File::FNM_SHORTNAME
+ *
+ * Flag File::FNM_SHORTNAME allows patterns to match short names if they exist.
+ *
+ * Windows only.
+ *
+ * ==== File::FNM_SYSCASE
+ *
+ * Flag File::FNM_SYSCASE specifies that case sensitivity
+ * is the same as in the underlying operating system;
+ * effective for File.fnmatch, but not Dir.glob.
+ *
+ * == Other \Constants
+ *
+ * ==== File::NULL
+ *
+ * Flag File::NULL contains the string value of the null device:
+ *
+ * - On a Unix-like OS, <tt>'/dev/null'</tt>.
+ * - On Windows, <tt>'NUL'</tt>.
*
- * Your platform documentations (e.g. man open(2)) may describe more
- * detailed information.
*/
rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
rb_include_module(rb_cIO, rb_mFConst);
-
- /* open for reading only */
+ /* {File::RDONLY}[rdoc-ref:File::Constants@File-3A-3ARDONLY] */
rb_define_const(rb_mFConst, "RDONLY", INT2FIX(O_RDONLY));
- /* open for writing only */
+ /* {File::WRONLY}[rdoc-ref:File::Constants@File-3A-3AWRONLY] */
rb_define_const(rb_mFConst, "WRONLY", INT2FIX(O_WRONLY));
- /* open for reading and writing */
+ /* {File::RDWR}[rdoc-ref:File::Constants@File-3A-3ARDWR] */
rb_define_const(rb_mFConst, "RDWR", INT2FIX(O_RDWR));
- /* append on each write */
+ /* {File::APPEND}[rdoc-ref:File::Constants@File-3A-3AAPPEND] */
rb_define_const(rb_mFConst, "APPEND", INT2FIX(O_APPEND));
- /* create file if it does not exist */
+ /* {File::CREAT}[rdoc-ref:File::Constants@File-3A-3ACREAT] */
rb_define_const(rb_mFConst, "CREAT", INT2FIX(O_CREAT));
- /* error if CREAT and the file exists */
+ /* {File::EXCL}[rdoc-ref:File::Constants@File-3A-3AEXCL] */
rb_define_const(rb_mFConst, "EXCL", INT2FIX(O_EXCL));
#if defined(O_NDELAY) || defined(O_NONBLOCK)
# ifndef O_NONBLOCK
# define O_NONBLOCK O_NDELAY
# endif
- /* do not block on open or for data to become available */
+ /* {File::NONBLOCK}[rdoc-ref:File::Constants@File-3A-3ANONBLOCK] */
rb_define_const(rb_mFConst, "NONBLOCK", INT2FIX(O_NONBLOCK));
#endif
- /* truncate size to 0 */
+ /* {File::TRUNC}[rdoc-ref:File::Constants@File-3A-3ATRUNC] */
rb_define_const(rb_mFConst, "TRUNC", INT2FIX(O_TRUNC));
#ifdef O_NOCTTY
- /* not to make opened IO the controlling terminal device */
+ /* {File::NOCTTY}[rdoc-ref:File::Constants@File-3A-3ANOCTTY] */
rb_define_const(rb_mFConst, "NOCTTY", INT2FIX(O_NOCTTY));
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
- /* disable line code conversion */
+ /* {File::BINARY}[rdoc-ref:File::Constants@File-3A-3ABINARY] */
rb_define_const(rb_mFConst, "BINARY", INT2FIX(O_BINARY));
#ifndef O_SHARE_DELETE
# define O_SHARE_DELETE 0
#endif
- /* can delete opened file */
+ /* {File::SHARE_DELETE}[rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE] */
rb_define_const(rb_mFConst, "SHARE_DELETE", INT2FIX(O_SHARE_DELETE));
#ifdef O_SYNC
- /* any write operation perform synchronously */
+ /* {File::SYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "SYNC", INT2FIX(O_SYNC));
#endif
#ifdef O_DSYNC
- /* any write operation perform synchronously except some meta data */
+ /* {File::DSYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "DSYNC", INT2FIX(O_DSYNC));
#endif
#ifdef O_RSYNC
- /* any read operation perform synchronously. used with SYNC or DSYNC. */
+ /* {File::RSYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "RSYNC", INT2FIX(O_RSYNC));
#endif
#ifdef O_NOFOLLOW
- /* do not follow symlinks */
+ /* {File::NOFOLLOW}[rdoc-ref:File::Constants@File-3A-3ANOFOLLOW] */
rb_define_const(rb_mFConst, "NOFOLLOW", INT2FIX(O_NOFOLLOW)); /* FreeBSD, Linux */
#endif
#ifdef O_NOATIME
- /* do not change atime */
+ /* {File::NOATIME}[rdoc-ref:File::Constants@File-3A-3ANOATIME] */
rb_define_const(rb_mFConst, "NOATIME", INT2FIX(O_NOATIME)); /* Linux */
#endif
#ifdef O_DIRECT
- /* Try to minimize cache effects of the I/O to and from this file. */
+ /* {File::DIRECT}[rdoc-ref:File::Constants@File-3A-3ADIRECT] */
rb_define_const(rb_mFConst, "DIRECT", INT2FIX(O_DIRECT));
#endif
#ifdef O_TMPFILE
- /* Create an unnamed temporary file */
+ /* {File::TMPFILE}[rdoc-ref:File::Constants@File-3A-3ATMPFILE] */
rb_define_const(rb_mFConst, "TMPFILE", INT2FIX(O_TMPFILE));
#endif
- /* shared lock. see File#flock */
+ /* {File::LOCK_SH}[rdoc-ref:File::Constants@File-3A-3ALOCK_SH] */
rb_define_const(rb_mFConst, "LOCK_SH", INT2FIX(LOCK_SH));
- /* exclusive lock. see File#flock */
+ /* {File::LOCK_EX}[rdoc-ref:File::Constants@File-3A-3ALOCK_EX] */
rb_define_const(rb_mFConst, "LOCK_EX", INT2FIX(LOCK_EX));
- /* unlock. see File#flock */
+ /* {File::LOCK_UN}[rdoc-ref:File::Constants@File-3A-3ALOCK_UN] */
rb_define_const(rb_mFConst, "LOCK_UN", INT2FIX(LOCK_UN));
- /* non-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock */
+ /* {File::LOCK_NB}[rdoc-ref:File::Constants@File-3A-3ALOCK_NB] */
rb_define_const(rb_mFConst, "LOCK_NB", INT2FIX(LOCK_NB));
- /* Name of the null device */
+ /* {File::NULL}[rdoc-ref:File::Constants@File-3A-3ANULL] */
rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(ruby_null_device));
rb_define_global_function("test", rb_f_test, -1);
diff --git a/gc.c b/gc.c
index 151258db39..2772f95638 100644
--- a/gc.c
+++ b/gc.c
@@ -11,23 +11,11 @@
**********************************************************************/
-#define rb_data_object_alloc rb_data_object_alloc
-#define rb_data_typed_object_alloc rb_data_typed_object_alloc
-
#include "ruby/internal/config.h"
#ifdef _WIN32
# include "ruby/ruby.h"
#endif
-#include <signal.h>
-
-#define sighandler_t ruby_sighandler_t
-
-#ifndef _WIN32
-#include <unistd.h>
-#include <sys/mman.h>
-#endif
-
#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
# include "wasm/setjmp.h"
# include "wasm/machine.h"
@@ -60,10 +48,6 @@
# endif
#endif
-#if !defined(PAGE_SIZE) && defined(HAVE_SYS_USER_H)
-/* LIST_HEAD conflicts with sys/queue.h on macOS */
-# include <sys/user.h>
-#endif
/* MALLOC_HEADERS_END */
#ifdef HAVE_SYS_TIME_H
@@ -87,21 +71,23 @@
#include <emscripten.h>
#endif
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
-# include <mach/task.h>
-# include <mach/mach_init.h>
-# include <mach/mach_port.h>
+/* For ruby_annotate_mmap */
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
#endif
+
#undef LIST_HEAD /* ccan/list conflicts with BSD-origin sys/queue.h. */
#include "constant.h"
#include "debug_counter.h"
#include "eval_intern.h"
+#include "gc/gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/compile.h"
#include "internal/complex.h"
+#include "internal/concurrent_set.h"
#include "internal/cont.h"
#include "internal/error.h"
#include "internal/eval.h"
@@ -113,13 +99,13 @@
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/rational.h"
+#include "internal/re.h"
#include "internal/sanitizers.h"
#include "internal/struct.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "internal/warnings.h"
-#include "rjit.h"
#include "probes.h"
#include "regint.h"
#include "ruby/debug.h"
@@ -128,3337 +114,1375 @@
#include "ruby/st.h"
#include "ruby/thread.h"
#include "ruby/util.h"
+#include "ruby/vm.h"
#include "ruby_assert.h"
#include "ruby_atomic.h"
#include "symbol.h"
-#include "transient_heap.h"
+#include "variable.h"
#include "vm_core.h"
#include "vm_sync.h"
#include "vm_callinfo.h"
#include "ractor_core.h"
+#include "yjit.h"
+#include "zjit.h"
#include "builtin.h"
#include "shape.h"
-#define rb_setjmp(env) RUBY_SETJMP(env)
-#define rb_jmp_buf rb_jmpbuf_t
-#undef rb_data_object_wrap
-
-#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
-static inline struct rbimpl_size_mul_overflow_tag
-size_add_overflow(size_t x, size_t y)
-{
- size_t z;
- bool p;
-#if 0
-
-#elif __has_builtin(__builtin_add_overflow)
- p = __builtin_add_overflow(x, y, &z);
-
-#elif defined(DSIZE_T)
- RB_GNUC_EXTENSION DSIZE_T dx = x;
- RB_GNUC_EXTENSION DSIZE_T dy = y;
- RB_GNUC_EXTENSION DSIZE_T dz = dx + dy;
- p = dz > SIZE_MAX;
- z = (size_t)dz;
-
-#else
- z = x + y;
- p = z < y;
-
-#endif
- return (struct rbimpl_size_mul_overflow_tag) { p, z, };
-}
-
-static inline struct rbimpl_size_mul_overflow_tag
-size_mul_add_overflow(size_t x, size_t y, size_t z) /* x * y + z */
-{
- struct rbimpl_size_mul_overflow_tag t = rbimpl_size_mul_overflow(x, y);
- struct rbimpl_size_mul_overflow_tag u = size_add_overflow(t.right, z);
- return (struct rbimpl_size_mul_overflow_tag) { t.left || u.left, u.right };
-}
-
-static inline struct rbimpl_size_mul_overflow_tag
-size_mul_add_mul_overflow(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- struct rbimpl_size_mul_overflow_tag t = rbimpl_size_mul_overflow(x, y);
- struct rbimpl_size_mul_overflow_tag u = rbimpl_size_mul_overflow(z, w);
- struct rbimpl_size_mul_overflow_tag v = size_add_overflow(t.right, u.right);
- return (struct rbimpl_size_mul_overflow_tag) { t.left || u.left || v.left, v.right };
-}
-
-PRINTF_ARGS(NORETURN(static void gc_raise(VALUE, const char*, ...)), 2, 3);
-
-static inline size_t
-size_mul_or_raise(size_t x, size_t y, VALUE exc)
+// TODO: Don't export this function in modular GC, instead MMTk should figure out
+// how to combine GC thread backtrace with mutator thread backtrace.
+void
+rb_gc_print_backtrace(void)
{
- struct rbimpl_size_mul_overflow_tag t = rbimpl_size_mul_overflow(x, y);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIuSIZE
- " * %"PRIuSIZE
- " > %"PRIuSIZE,
- x, y, (size_t)SIZE_MAX);
- }
+ rb_print_backtrace(stderr);
}
-size_t
-rb_size_mul_or_raise(size_t x, size_t y, VALUE exc)
+unsigned int
+rb_gc_vm_lock(const char *file, int line)
{
- return size_mul_or_raise(x, y, exc);
+ unsigned int lev = 0;
+ rb_vm_lock_enter(&lev, file, line);
+ return lev;
}
-static inline size_t
-size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
+void
+rb_gc_vm_unlock(unsigned int lev, const char *file, int line)
{
- struct rbimpl_size_mul_overflow_tag t = size_mul_add_overflow(x, y, z);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIuSIZE
- " * %"PRIuSIZE
- " + %"PRIuSIZE
- " > %"PRIuSIZE,
- x, y, z, (size_t)SIZE_MAX);
- }
+ rb_vm_lock_leave(&lev, file, line);
}
-size_t
-rb_size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
+unsigned int
+rb_gc_cr_lock(const char *file, int line)
{
- return size_mul_add_or_raise(x, y, z, exc);
+ unsigned int lev;
+ rb_vm_lock_enter_cr(GET_RACTOR(), &lev, file, line);
+ return lev;
}
-static inline size_t
-size_mul_add_mul_or_raise(size_t x, size_t y, size_t z, size_t w, VALUE exc)
+void
+rb_gc_cr_unlock(unsigned int lev, const char *file, int line)
{
- struct rbimpl_size_mul_overflow_tag t = size_mul_add_mul_overflow(x, y, z, w);
- if (LIKELY(!t.left)) {
- return t.right;
- }
- else if (rb_during_gc()) {
- rb_memerror(); /* or...? */
- }
- else {
- gc_raise(
- exc,
- "integer overflow: %"PRIdSIZE
- " * %"PRIdSIZE
- " + %"PRIdSIZE
- " * %"PRIdSIZE
- " > %"PRIdSIZE,
- x, y, z, w, (size_t)SIZE_MAX);
- }
+ rb_vm_lock_leave_cr(GET_RACTOR(), &lev, file, line);
}
-#if defined(HAVE_RB_GC_GUARDED_PTR_VAL) && HAVE_RB_GC_GUARDED_PTR_VAL
-/* trick the compiler into thinking a external signal handler uses this */
-volatile VALUE rb_gc_guarded_val;
-volatile VALUE *
-rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
+unsigned int
+rb_gc_vm_lock_no_barrier(const char *file, int line)
{
- rb_gc_guarded_val = val;
-
- return ptr;
+ unsigned int lev = 0;
+ rb_vm_lock_enter_nb(&lev, file, line);
+ return lev;
}
-#endif
-
-#ifndef GC_HEAP_INIT_SLOTS
-#define GC_HEAP_INIT_SLOTS 10000
-#endif
-#ifndef GC_HEAP_FREE_SLOTS
-#define GC_HEAP_FREE_SLOTS 4096
-#endif
-#ifndef GC_HEAP_GROWTH_FACTOR
-#define GC_HEAP_GROWTH_FACTOR 1.8
-#endif
-#ifndef GC_HEAP_GROWTH_MAX_SLOTS
-#define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */
-#endif
-#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR
-#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
-#endif
-
-#ifndef GC_HEAP_FREE_SLOTS_MIN_RATIO
-#define GC_HEAP_FREE_SLOTS_MIN_RATIO 0.20
-#endif
-#ifndef GC_HEAP_FREE_SLOTS_GOAL_RATIO
-#define GC_HEAP_FREE_SLOTS_GOAL_RATIO 0.40
-#endif
-#ifndef GC_HEAP_FREE_SLOTS_MAX_RATIO
-#define GC_HEAP_FREE_SLOTS_MAX_RATIO 0.65
-#endif
-
-#ifndef GC_MALLOC_LIMIT_MIN
-#define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
-#endif
-#ifndef GC_MALLOC_LIMIT_MAX
-#define GC_MALLOC_LIMIT_MAX (32 * 1024 * 1024 /* 32MB */)
-#endif
-#ifndef GC_MALLOC_LIMIT_GROWTH_FACTOR
-#define GC_MALLOC_LIMIT_GROWTH_FACTOR 1.4
-#endif
-
-#ifndef GC_OLDMALLOC_LIMIT_MIN
-#define GC_OLDMALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
-#endif
-#ifndef GC_OLDMALLOC_LIMIT_GROWTH_FACTOR
-#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR 1.2
-#endif
-#ifndef GC_OLDMALLOC_LIMIT_MAX
-#define GC_OLDMALLOC_LIMIT_MAX (128 * 1024 * 1024 /* 128MB */)
-#endif
-
-#ifndef PRINT_MEASURE_LINE
-#define PRINT_MEASURE_LINE 0
-#endif
-#ifndef PRINT_ENTER_EXIT_TICK
-#define PRINT_ENTER_EXIT_TICK 0
-#endif
-#ifndef PRINT_ROOT_TICKS
-#define PRINT_ROOT_TICKS 0
-#endif
-
-#define USE_TICK_T (PRINT_ENTER_EXIT_TICK || PRINT_MEASURE_LINE || PRINT_ROOT_TICKS)
-#define TICK_TYPE 1
-
-typedef struct {
- size_t heap_init_slots;
- size_t heap_free_slots;
- double growth_factor;
- size_t growth_max_slots;
-
- double heap_free_slots_min_ratio;
- double heap_free_slots_goal_ratio;
- double heap_free_slots_max_ratio;
- double oldobject_limit_factor;
-
- size_t malloc_limit_min;
- size_t malloc_limit_max;
- double malloc_limit_growth_factor;
-
- size_t oldmalloc_limit_min;
- size_t oldmalloc_limit_max;
- double oldmalloc_limit_growth_factor;
-
- VALUE gc_stress;
-} ruby_gc_params_t;
-
-static ruby_gc_params_t gc_params = {
- GC_HEAP_INIT_SLOTS,
- GC_HEAP_FREE_SLOTS,
- GC_HEAP_GROWTH_FACTOR,
- GC_HEAP_GROWTH_MAX_SLOTS,
-
- GC_HEAP_FREE_SLOTS_MIN_RATIO,
- GC_HEAP_FREE_SLOTS_GOAL_RATIO,
- GC_HEAP_FREE_SLOTS_MAX_RATIO,
- GC_HEAP_OLDOBJECT_LIMIT_FACTOR,
-
- GC_MALLOC_LIMIT_MIN,
- GC_MALLOC_LIMIT_MAX,
- GC_MALLOC_LIMIT_GROWTH_FACTOR,
-
- GC_OLDMALLOC_LIMIT_MIN,
- GC_OLDMALLOC_LIMIT_MAX,
- GC_OLDMALLOC_LIMIT_GROWTH_FACTOR,
-
- FALSE,
-};
-
-/* GC_DEBUG:
- * enable to embed GC debugging information.
- */
-#ifndef GC_DEBUG
-#define GC_DEBUG 0
-#endif
-
-/* RGENGC_DEBUG:
- * 1: basic information
- * 2: remember set operation
- * 3: mark
- * 4:
- * 5: sweep
- */
-#ifndef RGENGC_DEBUG
-#ifdef RUBY_DEVEL
-#define RGENGC_DEBUG -1
-#else
-#define RGENGC_DEBUG 0
-#endif
-#endif
-#if RGENGC_DEBUG < 0 && !defined(_MSC_VER)
-# define RGENGC_DEBUG_ENABLED(level) (-(RGENGC_DEBUG) >= (level) && ruby_rgengc_debug >= (level))
-#elif defined(HAVE_VA_ARGS_MACRO)
-# define RGENGC_DEBUG_ENABLED(level) ((RGENGC_DEBUG) >= (level))
-#else
-# define RGENGC_DEBUG_ENABLED(level) 0
-#endif
-int ruby_rgengc_debug;
-
-/* RGENGC_CHECK_MODE
- * 0: disable all assertions
- * 1: enable assertions (to debug RGenGC)
- * 2: enable internal consistency check at each GC (for debugging)
- * 3: enable internal consistency check at each GC steps (for debugging)
- * 4: enable liveness check
- * 5: show all references
- */
-#ifndef RGENGC_CHECK_MODE
-#define RGENGC_CHECK_MODE 0
-#endif
-
-// Note: using RUBY_ASSERT_WHEN() extend a macro in expr (info by nobu).
-#define GC_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RGENGC_CHECK_MODE > 0, expr, #expr)
-/* RGENGC_OLD_NEWOBJ_CHECK
- * 0: disable all assertions
- * >0: make a OLD object when new object creation.
- *
- * Make one OLD object per RGENGC_OLD_NEWOBJ_CHECK WB protected objects creation.
- */
-#ifndef RGENGC_OLD_NEWOBJ_CHECK
-#define RGENGC_OLD_NEWOBJ_CHECK 0
-#endif
-
-/* RGENGC_PROFILE
- * 0: disable RGenGC profiling
- * 1: enable profiling for basic information
- * 2: enable profiling for each types
- */
-#ifndef RGENGC_PROFILE
-#define RGENGC_PROFILE 0
-#endif
-
-/* RGENGC_ESTIMATE_OLDMALLOC
- * Enable/disable to estimate increase size of malloc'ed size by old objects.
- * If estimation exceeds threshold, then will invoke full GC.
- * 0: disable estimation.
- * 1: enable estimation.
- */
-#ifndef RGENGC_ESTIMATE_OLDMALLOC
-#define RGENGC_ESTIMATE_OLDMALLOC 1
-#endif
-
-/* RGENGC_FORCE_MAJOR_GC
- * Force major/full GC if this macro is not 0.
- */
-#ifndef RGENGC_FORCE_MAJOR_GC
-#define RGENGC_FORCE_MAJOR_GC 0
-#endif
-
-#ifndef GC_PROFILE_MORE_DETAIL
-#define GC_PROFILE_MORE_DETAIL 0
-#endif
-#ifndef GC_PROFILE_DETAIL_MEMORY
-#define GC_PROFILE_DETAIL_MEMORY 0
-#endif
-#ifndef GC_ENABLE_LAZY_SWEEP
-#define GC_ENABLE_LAZY_SWEEP 1
-#endif
-#ifndef CALC_EXACT_MALLOC_SIZE
-#define CALC_EXACT_MALLOC_SIZE USE_GC_MALLOC_OBJ_INFO_DETAILS
-#endif
-#if defined(HAVE_MALLOC_USABLE_SIZE) || CALC_EXACT_MALLOC_SIZE > 0
-#ifndef MALLOC_ALLOCATED_SIZE
-#define MALLOC_ALLOCATED_SIZE 0
-#endif
-#else
-#define MALLOC_ALLOCATED_SIZE 0
-#endif
-#ifndef MALLOC_ALLOCATED_SIZE_CHECK
-#define MALLOC_ALLOCATED_SIZE_CHECK 0
-#endif
-
-#ifndef GC_DEBUG_STRESS_TO_CLASS
-#define GC_DEBUG_STRESS_TO_CLASS 0
-#endif
-
-#ifndef RGENGC_OBJ_INFO
-#define RGENGC_OBJ_INFO (RGENGC_DEBUG | RGENGC_CHECK_MODE)
-#endif
-
-typedef enum {
- GPR_FLAG_NONE = 0x000,
- /* major reason */
- GPR_FLAG_MAJOR_BY_NOFREE = 0x001,
- GPR_FLAG_MAJOR_BY_OLDGEN = 0x002,
- GPR_FLAG_MAJOR_BY_SHADY = 0x004,
- GPR_FLAG_MAJOR_BY_FORCE = 0x008,
-#if RGENGC_ESTIMATE_OLDMALLOC
- GPR_FLAG_MAJOR_BY_OLDMALLOC = 0x020,
-#endif
- GPR_FLAG_MAJOR_MASK = 0x0ff,
-
- /* gc reason */
- GPR_FLAG_NEWOBJ = 0x100,
- GPR_FLAG_MALLOC = 0x200,
- GPR_FLAG_METHOD = 0x400,
- GPR_FLAG_CAPI = 0x800,
- GPR_FLAG_STRESS = 0x1000,
-
- /* others */
- GPR_FLAG_IMMEDIATE_SWEEP = 0x2000,
- GPR_FLAG_HAVE_FINALIZE = 0x4000,
- GPR_FLAG_IMMEDIATE_MARK = 0x8000,
- GPR_FLAG_FULL_MARK = 0x10000,
- GPR_FLAG_COMPACT = 0x20000,
-
- GPR_DEFAULT_REASON =
- (GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
- GPR_FLAG_IMMEDIATE_SWEEP | GPR_FLAG_CAPI),
-} gc_profile_record_flag;
-
-typedef struct gc_profile_record {
- unsigned int flags;
-
- double gc_time;
- double gc_invoke_time;
-
- size_t heap_total_objects;
- size_t heap_use_size;
- size_t heap_total_size;
- size_t moved_objects;
-
-#if GC_PROFILE_MORE_DETAIL
- double gc_mark_time;
- double gc_sweep_time;
-
- size_t heap_use_pages;
- size_t heap_live_objects;
- size_t heap_free_objects;
-
- size_t allocate_increase;
- size_t allocate_limit;
-
- double prepare_time;
- size_t removing_objects;
- size_t empty_objects;
-#if GC_PROFILE_DETAIL_MEMORY
- long maxrss;
- long minflt;
- long majflt;
-#endif
-#endif
-#if MALLOC_ALLOCATED_SIZE
- size_t allocated_size;
-#endif
-
-#if RGENGC_PROFILE > 0
- size_t old_objects;
- size_t remembered_normal_objects;
- size_t remembered_shady_objects;
-#endif
-} gc_profile_record;
-
-struct RMoved {
- VALUE flags;
- VALUE dummy;
- VALUE destination;
- shape_id_t original_shape_id;
-};
-
-#define RMOVED(obj) ((struct RMoved *)(obj))
-
-typedef struct RVALUE {
- union {
- struct {
- VALUE flags; /* always 0 for freed obj */
- struct RVALUE *next;
- } free;
- struct RMoved moved;
- 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 RTypedData typeddata;
- struct RStruct rstruct;
- struct RBignum bignum;
- struct RFile file;
- struct RMatch match;
- struct RRational rational;
- struct RComplex complex;
- struct RSymbol symbol;
- union {
- rb_cref_t cref;
- struct vm_svar svar;
- struct vm_throw_data throw_data;
- struct vm_ifunc ifunc;
- struct MEMO memo;
- struct rb_method_entry_struct ment;
- const rb_iseq_t iseq;
- rb_env_t env;
- struct rb_imemo_tmpbuf_struct alloc;
- rb_ast_t ast;
- } imemo;
- struct {
- struct RBasic basic;
- VALUE v1;
- VALUE v2;
- VALUE v3;
- } values;
- } as;
-
- /* Start of RVALUE_OVERHEAD.
- * Do not directly read these members from the RVALUE as they're located
- * at the end of the slot (which may differ in size depending on the size
- * pool). */
-#if RACTOR_CHECK_MODE
- uint32_t _ractor_belonging_id;
-#endif
-#if GC_DEBUG
- const char *file;
- int line;
-#endif
-} RVALUE;
-
-#if RACTOR_CHECK_MODE
-# define RVALUE_OVERHEAD (sizeof(RVALUE) - offsetof(RVALUE, _ractor_belonging_id))
-#elif GC_DEBUG
-# define RVALUE_OVERHEAD (sizeof(RVALUE) - offsetof(RVALUE, file))
-#else
-# define RVALUE_OVERHEAD 0
-#endif
-
-STATIC_ASSERT(sizeof_rvalue, sizeof(RVALUE) == (SIZEOF_VALUE * 5) + RVALUE_OVERHEAD);
-STATIC_ASSERT(alignof_rvalue, RUBY_ALIGNOF(RVALUE) == SIZEOF_VALUE);
-
-typedef uintptr_t bits_t;
-enum {
- BITS_SIZE = sizeof(bits_t),
- BITS_BITLENGTH = ( BITS_SIZE * CHAR_BIT )
-};
-#define popcount_bits rb_popcount_intptr
-
-struct heap_page_header {
- struct heap_page *page;
-};
-
-struct heap_page_body {
- struct heap_page_header header;
- /* char gap[]; */
- /* RVALUE values[]; */
-};
-
-struct gc_list {
- VALUE *varptr;
- struct gc_list *next;
-};
-
-#define STACK_CHUNK_SIZE 500
-
-typedef struct stack_chunk {
- VALUE data[STACK_CHUNK_SIZE];
- struct stack_chunk *next;
-} stack_chunk_t;
-
-typedef struct mark_stack {
- stack_chunk_t *chunk;
- stack_chunk_t *cache;
- int index;
- int limit;
- size_t cache_size;
- size_t unused_cache_size;
-} mark_stack_t;
-
-#define SIZE_POOL_EDEN_HEAP(size_pool) (&(size_pool)->eden_heap)
-#define SIZE_POOL_TOMB_HEAP(size_pool) (&(size_pool)->tomb_heap)
-
-typedef struct rb_heap_struct {
- struct heap_page *free_pages;
- struct ccan_list_head pages;
- struct heap_page *sweeping_page; /* iterator for .pages */
- struct heap_page *compact_cursor;
- uintptr_t compact_cursor_index;
- struct heap_page *pooled_pages;
- size_t total_pages; /* total page count in a heap */
- size_t total_slots; /* total slot count (about total_pages * HEAP_PAGE_OBJ_LIMIT) */
-} rb_heap_t;
-
-typedef struct rb_size_pool_struct {
- short slot_size;
-
- size_t allocatable_pages;
-
- /* Basic statistics */
- size_t total_allocated_pages;
- size_t total_freed_pages;
- size_t force_major_gc_count;
-
-#if USE_RVARGC
- /* Sweeping statistics */
- size_t freed_slots;
- size_t empty_slots;
-#endif
-
- rb_heap_t eden_heap;
- rb_heap_t tomb_heap;
-} rb_size_pool_t;
-
-enum gc_mode {
- gc_mode_none,
- gc_mode_marking,
- gc_mode_sweeping,
- gc_mode_compacting,
-};
-
-typedef struct rb_objspace {
- struct {
- size_t limit;
- size_t increase;
-#if MALLOC_ALLOCATED_SIZE
- size_t allocated_size;
- size_t allocations;
-#endif
-
- } malloc_params;
-
- struct {
- unsigned int mode : 2;
- unsigned int immediate_sweep : 1;
- unsigned int dont_gc : 1;
- unsigned int dont_incremental : 1;
- unsigned int during_gc : 1;
- unsigned int during_compacting : 1;
- unsigned int during_reference_updating : 1;
- unsigned int gc_stressful: 1;
- unsigned int has_hook: 1;
- unsigned int during_minor_gc : 1;
- unsigned int during_incremental_marking : 1;
- unsigned int measure_gc : 1;
- } flags;
-
- rb_event_flag_t hook_events;
- size_t total_allocated_objects;
- VALUE next_object_id;
-
- rb_size_pool_t size_pools[SIZE_POOL_COUNT];
-
- struct {
- rb_atomic_t finalizing;
- } atomic_flags;
-
- mark_stack_t mark_stack;
- size_t marked_slots;
-
- struct {
- struct heap_page **sorted;
- size_t allocated_pages;
- size_t allocatable_pages;
- size_t sorted_length;
- uintptr_t range[2];
- size_t freeable_pages;
-
- /* final */
- size_t final_slots;
- VALUE deferred_final;
- } heap_pages;
-
- st_table *finalizer_table;
-
- struct {
- int run;
- unsigned int latest_gc_info;
- gc_profile_record *records;
- gc_profile_record *current_record;
- size_t next_index;
- size_t size;
-
-#if GC_PROFILE_MORE_DETAIL
- double prepare_time;
-#endif
- double invoke_time;
-
- size_t minor_gc_count;
- size_t major_gc_count;
- size_t compact_count;
- size_t read_barrier_faults;
-#if RGENGC_PROFILE > 0
- size_t total_generated_normal_object_count;
- size_t total_generated_shady_object_count;
- size_t total_shade_operation_count;
- size_t total_promoted_count;
- size_t total_remembered_normal_object_count;
- size_t total_remembered_shady_object_count;
-
-#if RGENGC_PROFILE >= 2
- size_t generated_normal_object_count_types[RUBY_T_MASK];
- size_t generated_shady_object_count_types[RUBY_T_MASK];
- size_t shade_operation_count_types[RUBY_T_MASK];
- size_t promoted_types[RUBY_T_MASK];
- size_t remembered_normal_object_count_types[RUBY_T_MASK];
- size_t remembered_shady_object_count_types[RUBY_T_MASK];
-#endif
-#endif /* RGENGC_PROFILE */
-
- /* temporary profiling space */
- double gc_sweep_start_time;
- size_t total_allocated_objects_at_gc_start;
- size_t heap_used_at_gc_start;
-
- /* basic statistics */
- size_t count;
- size_t total_freed_objects;
- uint64_t marking_time_ns;
- struct timespec marking_start_time;
- uint64_t sweeping_time_ns;
- struct timespec sweeping_start_time;
- } profile;
- struct gc_list *global_list;
-
- VALUE gc_stress_mode;
-
- struct {
- VALUE parent_object;
- int need_major_gc;
- size_t last_major_gc;
- size_t uncollectible_wb_unprotected_objects;
- size_t uncollectible_wb_unprotected_objects_limit;
- size_t old_objects;
- size_t old_objects_limit;
-
-#if RGENGC_ESTIMATE_OLDMALLOC
- size_t oldmalloc_increase;
- size_t oldmalloc_increase_limit;
-#endif
-
-#if RGENGC_CHECK_MODE >= 2
- struct st_table *allrefs_table;
- size_t error_count;
-#endif
- } rgengc;
-
- struct {
- size_t considered_count_table[T_MASK];
- size_t moved_count_table[T_MASK];
- size_t moved_up_count_table[T_MASK];
- size_t moved_down_count_table[T_MASK];
- size_t total_moved;
- } rcompactor;
-
- struct {
- size_t pooled_slots;
- size_t step_slots;
- } rincgc;
-
- st_table *id_to_obj_tbl;
- st_table *obj_to_id_tbl;
-
-#if GC_DEBUG_STRESS_TO_CLASS
- VALUE stress_to_class;
-#endif
-} rb_objspace_t;
-
-
-#ifndef HEAP_PAGE_ALIGN_LOG
-/* default tiny heap size: 64KiB */
-#define HEAP_PAGE_ALIGN_LOG 16
-#endif
-
-#define BASE_SLOT_SIZE sizeof(RVALUE)
-
-#define CEILDIV(i, mod) roomof(i, mod)
-enum {
- HEAP_PAGE_ALIGN = (1UL << HEAP_PAGE_ALIGN_LOG),
- HEAP_PAGE_ALIGN_MASK = (~(~0UL << HEAP_PAGE_ALIGN_LOG)),
- HEAP_PAGE_SIZE = HEAP_PAGE_ALIGN,
- HEAP_PAGE_OBJ_LIMIT = (unsigned int)((HEAP_PAGE_SIZE - sizeof(struct heap_page_header)) / BASE_SLOT_SIZE),
- HEAP_PAGE_BITMAP_LIMIT = CEILDIV(CEILDIV(HEAP_PAGE_SIZE, BASE_SLOT_SIZE), BITS_BITLENGTH),
- HEAP_PAGE_BITMAP_SIZE = (BITS_SIZE * HEAP_PAGE_BITMAP_LIMIT),
-};
-#define HEAP_PAGE_ALIGN (1 << HEAP_PAGE_ALIGN_LOG)
-#define HEAP_PAGE_SIZE HEAP_PAGE_ALIGN
-
-#if !defined(INCREMENTAL_MARK_STEP_ALLOCATIONS)
-# define INCREMENTAL_MARK_STEP_ALLOCATIONS 500
-#endif
-
-#undef INIT_HEAP_PAGE_ALLOC_USE_MMAP
-/* Must define either HEAP_PAGE_ALLOC_USE_MMAP or
- * INIT_HEAP_PAGE_ALLOC_USE_MMAP. */
-
-#ifndef HAVE_MMAP
-/* We can't use mmap of course, if it is not available. */
-static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
-
-#elif defined(__wasm__)
-/* wasmtime does not have proper support for mmap.
- * See https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-mmap-and-friends
- */
-static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
-
-#elif HAVE_CONST_PAGE_SIZE
-/* If we have the PAGE_SIZE and it is a constant, then we can directly use it. */
-static const bool HEAP_PAGE_ALLOC_USE_MMAP = (PAGE_SIZE <= HEAP_PAGE_SIZE);
-
-#elif defined(PAGE_MAX_SIZE) && (PAGE_MAX_SIZE <= HEAP_PAGE_SIZE)
-/* If we can use the maximum page size. */
-static const bool HEAP_PAGE_ALLOC_USE_MMAP = true;
-
-#elif defined(PAGE_SIZE)
-/* If the PAGE_SIZE macro can be used dynamically. */
-# define INIT_HEAP_PAGE_ALLOC_USE_MMAP (PAGE_SIZE <= HEAP_PAGE_SIZE)
-
-#elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
-/* If we can use sysconf to determine the page size. */
-# define INIT_HEAP_PAGE_ALLOC_USE_MMAP (sysconf(_SC_PAGE_SIZE) <= HEAP_PAGE_SIZE)
-
-#else
-/* Otherwise we can't determine the system page size, so don't use mmap. */
-static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
-#endif
-
-#ifdef INIT_HEAP_PAGE_ALLOC_USE_MMAP
-/* We can determine the system page size at runtime. */
-# define HEAP_PAGE_ALLOC_USE_MMAP (heap_page_alloc_use_mmap != false)
-
-static bool heap_page_alloc_use_mmap;
-#endif
-
-struct heap_page {
- short slot_size;
- short total_slots;
- short free_slots;
- short final_slots;
- struct {
- unsigned int before_sweep : 1;
- unsigned int has_remembered_objects : 1;
- unsigned int has_uncollectible_shady_objects : 1;
- unsigned int in_tomb : 1;
- } flags;
-
- rb_size_pool_t *size_pool;
-
- struct heap_page *free_next;
- uintptr_t start;
- RVALUE *freelist;
- struct ccan_list_node page_node;
-
- bits_t wb_unprotected_bits[HEAP_PAGE_BITMAP_LIMIT];
- /* the following three bitmaps are cleared at the beginning of full GC */
- bits_t mark_bits[HEAP_PAGE_BITMAP_LIMIT];
- bits_t uncollectible_bits[HEAP_PAGE_BITMAP_LIMIT];
- bits_t marking_bits[HEAP_PAGE_BITMAP_LIMIT];
-
- /* If set, the object is not movable */
- bits_t pinned_bits[HEAP_PAGE_BITMAP_LIMIT];
-};
-
-/*
- * When asan is enabled, this will prohibit writing to the freelist until it is unlocked
- */
-static void
-asan_lock_freelist(struct heap_page *page)
+void
+rb_gc_vm_unlock_no_barrier(unsigned int lev, const char *file, int line)
{
- asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
+ rb_vm_lock_leave_nb(&lev, file, line);
}
-/*
- * When asan is enabled, this will enable the ability to write to the freelist
- */
-static void
-asan_unlock_freelist(struct heap_page *page)
-{
- asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
-}
-
-#define GET_PAGE_BODY(x) ((struct heap_page_body *)((bits_t)(x) & ~(HEAP_PAGE_ALIGN_MASK)))
-#define GET_PAGE_HEADER(x) (&GET_PAGE_BODY(x)->header)
-#define GET_HEAP_PAGE(x) (GET_PAGE_HEADER(x)->page)
-
-#define NUM_IN_PAGE(p) (((bits_t)(p) & HEAP_PAGE_ALIGN_MASK) / BASE_SLOT_SIZE)
-#define BITMAP_INDEX(p) (NUM_IN_PAGE(p) / BITS_BITLENGTH )
-#define BITMAP_OFFSET(p) (NUM_IN_PAGE(p) & (BITS_BITLENGTH-1))
-#define BITMAP_BIT(p) ((bits_t)1 << BITMAP_OFFSET(p))
-
-/* Bitmap Operations */
-#define MARKED_IN_BITMAP(bits, p) ((bits)[BITMAP_INDEX(p)] & BITMAP_BIT(p))
-#define MARK_IN_BITMAP(bits, p) ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] | BITMAP_BIT(p))
-#define CLEAR_IN_BITMAP(bits, p) ((bits)[BITMAP_INDEX(p)] = (bits)[BITMAP_INDEX(p)] & ~BITMAP_BIT(p))
-
-/* getting bitmap */
-#define GET_HEAP_MARK_BITS(x) (&GET_HEAP_PAGE(x)->mark_bits[0])
-#define GET_HEAP_PINNED_BITS(x) (&GET_HEAP_PAGE(x)->pinned_bits[0])
-#define GET_HEAP_UNCOLLECTIBLE_BITS(x) (&GET_HEAP_PAGE(x)->uncollectible_bits[0])
-#define GET_HEAP_WB_UNPROTECTED_BITS(x) (&GET_HEAP_PAGE(x)->wb_unprotected_bits[0])
-#define GET_HEAP_MARKING_BITS(x) (&GET_HEAP_PAGE(x)->marking_bits[0])
-
-#define GC_SWEEP_PAGES_FREEABLE_PER_STEP 3
-
-/* Aliases */
-#define rb_objspace (*rb_objspace_of(GET_VM()))
-#define rb_objspace_of(vm) ((vm)->objspace)
-
-#define ruby_initial_gc_stress gc_params.gc_stress
-
-VALUE *ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress;
-
-#define malloc_limit objspace->malloc_params.limit
-#define malloc_increase objspace->malloc_params.increase
-#define malloc_allocated_size objspace->malloc_params.allocated_size
-#define heap_pages_sorted objspace->heap_pages.sorted
-#define heap_allocated_pages objspace->heap_pages.allocated_pages
-#define heap_pages_sorted_length objspace->heap_pages.sorted_length
-#define heap_pages_lomem objspace->heap_pages.range[0]
-#define heap_pages_himem objspace->heap_pages.range[1]
-#define heap_pages_freeable_pages objspace->heap_pages.freeable_pages
-#define heap_pages_final_slots objspace->heap_pages.final_slots
-#define heap_pages_deferred_final objspace->heap_pages.deferred_final
-#define size_pools objspace->size_pools
-#define during_gc objspace->flags.during_gc
-#define finalizing objspace->atomic_flags.finalizing
-#define finalizer_table objspace->finalizer_table
-#define global_list objspace->global_list
-#define ruby_gc_stressful objspace->flags.gc_stressful
-#define ruby_gc_stress_mode objspace->gc_stress_mode
-#if GC_DEBUG_STRESS_TO_CLASS
-#define stress_to_class objspace->stress_to_class
-#else
-#define stress_to_class 0
-#endif
-
-#if 0
-#define dont_gc_on() (fprintf(stderr, "dont_gc_on@%s:%d\n", __FILE__, __LINE__), objspace->flags.dont_gc = 1)
-#define dont_gc_off() (fprintf(stderr, "dont_gc_off@%s:%d\n", __FILE__, __LINE__), objspace->flags.dont_gc = 0)
-#define dont_gc_set(b) (fprintf(stderr, "dont_gc_set(%d)@%s:%d\n", __FILE__, __LINE__), (int)b), objspace->flags.dont_gc = (b))
-#define dont_gc_val() (objspace->flags.dont_gc)
-#else
-#define dont_gc_on() (objspace->flags.dont_gc = 1)
-#define dont_gc_off() (objspace->flags.dont_gc = 0)
-#define dont_gc_set(b) (((int)b), objspace->flags.dont_gc = (b))
-#define dont_gc_val() (objspace->flags.dont_gc)
-#endif
-
-static inline enum gc_mode
-gc_mode_verify(enum gc_mode mode)
+void
+rb_gc_vm_barrier(void)
{
-#if RGENGC_CHECK_MODE > 0
- switch (mode) {
- case gc_mode_none:
- case gc_mode_marking:
- case gc_mode_sweeping:
- case gc_mode_compacting:
- break;
- default:
- rb_bug("gc_mode_verify: unreachable (%d)", (int)mode);
- }
-#endif
- return mode;
+ rb_vm_barrier();
}
-static inline bool
-has_sweeping_pages(rb_objspace_t *objspace)
+void *
+rb_gc_get_ractor_newobj_cache(void)
{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- if (SIZE_POOL_EDEN_HEAP(&size_pools[i])->sweeping_page) {
- return TRUE;
- }
- }
- return FALSE;
+ return GET_RACTOR()->newobj_cache;
}
-static inline size_t
-heap_eden_total_pages(rb_objspace_t *objspace)
+void
+rb_gc_initialize_vm_context(struct rb_gc_vm_context *context)
{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- count += SIZE_POOL_EDEN_HEAP(&size_pools[i])->total_pages;
- }
- return count;
+ rb_native_mutex_initialize(&context->lock);
+ context->ec = GET_EC();
}
-static inline size_t
-heap_eden_total_slots(rb_objspace_t *objspace)
+bool
+rb_gc_event_hook_required_p(rb_event_flag_t event)
{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- count += SIZE_POOL_EDEN_HEAP(&size_pools[i])->total_slots;
- }
- return count;
+ return ruby_vm_event_flags & event;
}
-static inline size_t
-heap_tomb_total_pages(rb_objspace_t *objspace)
-{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- count += SIZE_POOL_TOMB_HEAP(&size_pools[i])->total_pages;
- }
- return count;
-}
-
-static inline size_t
-heap_allocatable_pages(rb_objspace_t *objspace)
+void
+rb_gc_event_hook(VALUE obj, rb_event_flag_t event)
{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- count += size_pools[i].allocatable_pages;
- }
- return count;
-}
+ if (LIKELY(!rb_gc_event_hook_required_p(event))) return;
-static inline size_t
-heap_allocatable_slots(rb_objspace_t *objspace)
-{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- int slot_size_multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- count += size_pool->allocatable_pages * HEAP_PAGE_OBJ_LIMIT / slot_size_multiple;
- }
- return count;
-}
+ rb_execution_context_t *ec = rb_gc_get_ec();
+ if (!ec->cfp) return;
-static inline size_t
-total_allocated_pages(rb_objspace_t *objspace)
-{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- count += size_pool->total_allocated_pages;
- }
- return count;
-}
+#if USE_MODULAR_GC
+ bool gc_thread_p = false;
+ if (!GET_EC()) {
+ gc_thread_p = true;
-static inline size_t
-total_freed_pages(rb_objspace_t *objspace)
-{
- size_t count = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- count += size_pool->total_freed_pages;
+# ifdef RB_THREAD_LOCAL_SPECIFIER
+ rb_current_ec_set(ec);
+# else
+ native_tls_set(ruby_current_ec_key, ec);
+# endif
}
- return count;
-}
-
-#define gc_mode(objspace) gc_mode_verify((enum gc_mode)(objspace)->flags.mode)
-#define gc_mode_set(objspace, mode) ((objspace)->flags.mode = (unsigned int)gc_mode_verify(mode))
-
-#define is_marking(objspace) (gc_mode(objspace) == gc_mode_marking)
-#define is_sweeping(objspace) (gc_mode(objspace) == gc_mode_sweeping)
-#define is_full_marking(objspace) ((objspace)->flags.during_minor_gc == FALSE)
-#define is_incremental_marking(objspace) ((objspace)->flags.during_incremental_marking != FALSE)
-#define will_be_incremental_marking(objspace) ((objspace)->rgengc.need_major_gc != GPR_FLAG_NONE)
-#define GC_INCREMENTAL_SWEEP_SLOT_COUNT 2048
-#define is_lazy_sweeping(objspace) (GC_ENABLE_LAZY_SWEEP && has_sweeping_pages(objspace))
-
-#if SIZEOF_LONG == SIZEOF_VOIDP
-# define obj_id_to_ref(objid) ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-# define obj_id_to_ref(objid) (FIXNUM_P(objid) ? \
- ((objid) ^ FIXNUM_FLAG) : (NUM2PTR(objid) << 1))
-#else
-# error not supported
-#endif
-
-#define RANY(o) ((RVALUE*)(o))
-
-struct RZombie {
- struct RBasic basic;
- VALUE next;
- void (*dfree)(void *);
- void *data;
-};
-
-#define RZOMBIE(o) ((struct RZombie *)(o))
-
-#define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory]
-
-#if RUBY_MARK_FREE_DEBUG
-int ruby_gc_debug_indent = 0;
#endif
-VALUE rb_mGC;
-int ruby_disable_gc = 0;
-int ruby_enable_autocompact = 0;
-
-void rb_iseq_mark_and_move(rb_iseq_t *iseq, bool referece_updating);
-void rb_iseq_free(const rb_iseq_t *iseq);
-size_t rb_iseq_memsize(const rb_iseq_t *iseq);
-void rb_vm_update_references(void *ptr);
-
-void rb_gcdebug_print_obj_condition(VALUE obj);
-
-NORETURN(static void *gc_vraise(void *ptr));
-NORETURN(static void gc_raise(VALUE exc, const char *fmt, ...));
-NORETURN(static void negative_size_allocation_error(const char *));
-
-static void init_mark_stack(mark_stack_t *stack);
-
-static int ready_to_gc(rb_objspace_t *objspace);
-
-static int garbage_collect(rb_objspace_t *, unsigned int reason);
-
-static int gc_start(rb_objspace_t *objspace, unsigned int reason);
-static void gc_rest(rb_objspace_t *objspace);
-
-enum gc_enter_event {
- gc_enter_event_start,
- gc_enter_event_continue,
- gc_enter_event_rest,
- gc_enter_event_finalizer,
- gc_enter_event_rb_memerror,
-};
-
-static inline void gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
-static inline void gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
-static void gc_marking_enter(rb_objspace_t *objspace);
-static void gc_marking_exit(rb_objspace_t *objspace);
-static void gc_sweeping_enter(rb_objspace_t *objspace);
-static void gc_sweeping_exit(rb_objspace_t *objspace);
-
-static void gc_marks_start(rb_objspace_t *objspace, int full);
-static void gc_marks_finish(rb_objspace_t *objspace);
-static bool gc_marks_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
-
-static void gc_sweep(rb_objspace_t *objspace);
-static void gc_sweep_start(rb_objspace_t *objspace);
-#if USE_RVARGC
-static void gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool);
-#endif
-static void gc_sweep_finish(rb_objspace_t *objspace);
-static int gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
-static void gc_sweep_rest(rb_objspace_t *objspace);
-static void gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
-
-static inline void gc_mark(rb_objspace_t *objspace, VALUE ptr);
-static inline void gc_pin(rb_objspace_t *objspace, VALUE ptr);
-static inline void gc_mark_and_pin(rb_objspace_t *objspace, VALUE ptr);
-static void gc_mark_ptr(rb_objspace_t *objspace, VALUE ptr);
-NO_SANITIZE("memory", static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr));
-static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr);
-
-static int gc_mark_stacked_objects_incremental(rb_objspace_t *, size_t count);
-static int gc_mark_stacked_objects_all(rb_objspace_t *);
-static void gc_grey(rb_objspace_t *objspace, VALUE ptr);
-
-static inline int gc_mark_set(rb_objspace_t *objspace, VALUE obj);
-NO_SANITIZE("memory", static inline int is_pointer_to_heap(rb_objspace_t *objspace, void *ptr));
-
-static void push_mark_stack(mark_stack_t *, VALUE);
-static int pop_mark_stack(mark_stack_t *, VALUE *);
-static size_t mark_stack_size(mark_stack_t *stack);
-static void shrink_stack_chunk_cache(mark_stack_t *stack);
-
-static size_t obj_memsize_of(VALUE obj, int use_all_types);
-static void gc_verify_internal_consistency(rb_objspace_t *objspace);
-static int gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj);
-static int gc_verify_heap_pages(rb_objspace_t *objspace);
-
-static void gc_stress_set(rb_objspace_t *objspace, VALUE flag);
-static VALUE gc_disable_no_rest(rb_objspace_t *);
-
-static double getrusage_time(void);
-static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, unsigned int reason);
-static inline void gc_prof_timer_start(rb_objspace_t *);
-static inline void gc_prof_timer_stop(rb_objspace_t *);
-static inline void gc_prof_mark_timer_start(rb_objspace_t *);
-static inline void gc_prof_mark_timer_stop(rb_objspace_t *);
-static inline void gc_prof_sweep_timer_start(rb_objspace_t *);
-static inline void gc_prof_sweep_timer_stop(rb_objspace_t *);
-static inline void gc_prof_set_malloc_info(rb_objspace_t *);
-static inline void gc_prof_set_heap_info(rb_objspace_t *);
-
-#define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \
- if (gc_object_moved_p((_objspace), (VALUE)(_thing))) { \
- *(_type *)&(_thing) = (_type)RMOVED(_thing)->destination; \
- } \
-} while (0)
-
-#define UPDATE_IF_MOVED(_objspace, _thing) TYPED_UPDATE_IF_MOVED(_objspace, VALUE, _thing)
-
-#define gc_prof_record(objspace) (objspace)->profile.current_record
-#define gc_prof_enabled(objspace) ((objspace)->profile.run && (objspace)->profile.current_record)
-
-#ifdef HAVE_VA_ARGS_MACRO
-# define gc_report(level, objspace, ...) \
- if (!RGENGC_DEBUG_ENABLED(level)) {} else gc_report_body(level, objspace, __VA_ARGS__)
-#else
-# define gc_report if (!RGENGC_DEBUG_ENABLED(0)) {} else gc_report_body
-#endif
-PRINTF_ARGS(static void gc_report_body(int level, rb_objspace_t *objspace, const char *fmt, ...), 3, 4);
-static const char *obj_info(VALUE obj);
-static const char *obj_type_name(VALUE obj);
-
-/*
- * 1 - TSC (H/W Time Stamp Counter)
- * 2 - getrusage
- */
-#ifndef TICK_TYPE
-#define TICK_TYPE 1
-#endif
-
-#if USE_TICK_T
-
-#if TICK_TYPE == 1
-/* the following code is only for internal tuning. */
-
-/* Source code to use RDTSC is quoted and modified from
- * https://www.mcs.anl.gov/~kazutomo/rdtsc.html
- * written by Kazutomo Yoshii <kazutomo@mcs.anl.gov>
- */
-
-#if defined(__GNUC__) && defined(__i386__)
-typedef unsigned long long tick_t;
-#define PRItick "llu"
-static inline tick_t
-tick(void)
-{
- unsigned long long int x;
- __asm__ __volatile__ ("rdtsc" : "=A" (x));
- return x;
-}
-
-#elif defined(__GNUC__) && defined(__x86_64__)
-typedef unsigned long long tick_t;
-#define PRItick "llu"
-
-static __inline__ tick_t
-tick(void)
-{
- unsigned long hi, lo;
- __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
- return ((unsigned long long)lo)|( ((unsigned long long)hi)<<32);
-}
-
-#elif defined(__powerpc64__) && (GCC_VERSION_SINCE(4,8,0) || defined(__clang__))
-typedef unsigned long long tick_t;
-#define PRItick "llu"
-
-static __inline__ tick_t
-tick(void)
-{
- unsigned long long val = __builtin_ppc_get_timebase();
- return val;
-}
-
-/* Implementation for macOS PPC by @nobu
- * See: https://github.com/ruby/ruby/pull/5975#discussion_r890045558
- */
-#elif defined(__POWERPC__) && defined(__APPLE__)
-typedef unsigned long long tick_t;
-#define PRItick "llu"
-
-static __inline__ tick_t
-tick(void)
-{
- unsigned long int upper, lower, tmp;
- # define mftbu(r) __asm__ volatile("mftbu %0" : "=r"(r))
- # define mftb(r) __asm__ volatile("mftb %0" : "=r"(r))
- do {
- mftbu(upper);
- mftb(lower);
- mftbu(tmp);
- } while (tmp != upper);
- return ((tick_t)upper << 32) | lower;
-}
-
-#elif defined(__aarch64__) && defined(__GNUC__)
-typedef unsigned long tick_t;
-#define PRItick "lu"
-
-static __inline__ tick_t
-tick(void)
-{
- unsigned long val;
- __asm__ __volatile__ ("mrs %0, cntvct_el0" : "=r" (val));
- return val;
-}
+ EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, obj);
-#elif defined(_WIN32) && defined(_MSC_VER)
-#include <intrin.h>
-typedef unsigned __int64 tick_t;
-#define PRItick "llu"
-
-static inline tick_t
-tick(void)
-{
- return __rdtsc();
-}
-
-#else /* use clock */
-typedef clock_t tick_t;
-#define PRItick "llu"
-
-static inline tick_t
-tick(void)
-{
- return clock();
-}
-#endif /* TSC */
-
-#elif TICK_TYPE == 2
-typedef double tick_t;
-#define PRItick "4.9f"
-
-static inline tick_t
-tick(void)
-{
- return getrusage_time();
-}
-#else /* TICK_TYPE */
-#error "choose tick type"
-#endif /* TICK_TYPE */
-
-#define MEASURE_LINE(expr) do { \
- volatile tick_t start_time = tick(); \
- volatile tick_t end_time; \
- expr; \
- end_time = tick(); \
- fprintf(stderr, "0\t%"PRItick"\t%s\n", end_time - start_time, #expr); \
-} while (0)
-
-#else /* USE_TICK_T */
-#define MEASURE_LINE(expr) expr
-#endif /* USE_TICK_T */
-
-static inline void *
-asan_unpoison_object_temporary(VALUE obj)
-{
- void *ptr = asan_poisoned_object_p(obj);
- asan_unpoison_object(obj, false);
- return ptr;
-}
-
-static inline void *
-asan_poison_object_restore(VALUE obj, void *ptr)
-{
- if (ptr) {
- asan_poison_object(obj);
+#if USE_MODULAR_GC
+ if (gc_thread_p) {
+# ifdef RB_THREAD_LOCAL_SPECIFIER
+ rb_current_ec_set(NULL);
+# else
+ native_tls_set(ruby_current_ec_key, NULL);
+# endif
}
- return NULL;
-}
-
-#define asan_unpoisoning_object(obj) \
- for (void *poisoned = asan_unpoison_object_temporary(obj), \
- *unpoisoning = &poisoned; /* flag to loop just once */ \
- unpoisoning; \
- unpoisoning = asan_poison_object_restore(obj, poisoned))
-
-#define FL_CHECK2(name, x, pred) \
- ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? \
- (rb_bug(name": SPECIAL_CONST (%p)", (void *)(x)), 0) : (pred))
-#define FL_TEST2(x,f) FL_CHECK2("FL_TEST2", x, FL_TEST_RAW((x),(f)) != 0)
-#define FL_SET2(x,f) FL_CHECK2("FL_SET2", x, RBASIC(x)->flags |= (f))
-#define FL_UNSET2(x,f) FL_CHECK2("FL_UNSET2", x, RBASIC(x)->flags &= ~(f))
-
-#define RVALUE_MARK_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), (obj))
-#define RVALUE_PIN_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), (obj))
-#define RVALUE_PAGE_MARKED(page, obj) MARKED_IN_BITMAP((page)->mark_bits, (obj))
-
-#define RVALUE_WB_UNPROTECTED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), (obj))
-#define RVALUE_UNCOLLECTIBLE_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), (obj))
-#define RVALUE_MARKING_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), (obj))
-
-#define RVALUE_PAGE_WB_UNPROTECTED(page, obj) MARKED_IN_BITMAP((page)->wb_unprotected_bits, (obj))
-#define RVALUE_PAGE_UNCOLLECTIBLE(page, obj) MARKED_IN_BITMAP((page)->uncollectible_bits, (obj))
-#define RVALUE_PAGE_MARKING(page, obj) MARKED_IN_BITMAP((page)->marking_bits, (obj))
-
-#define RVALUE_OLD_AGE 3
-#define RVALUE_AGE_SHIFT 5 /* FL_PROMOTED0 bit */
-
-static int rgengc_remembered(rb_objspace_t *objspace, VALUE obj);
-static int rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj);
-static int rgengc_remember(rb_objspace_t *objspace, VALUE obj);
-static void rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap);
-static void rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap);
-
-static inline int
-RVALUE_FLAGS_AGE(VALUE flags)
-{
- return (int)((flags & (FL_PROMOTED0 | FL_PROMOTED1)) >> RVALUE_AGE_SHIFT);
+#endif
}
-static int
-check_rvalue_consistency_force(const VALUE obj, int terminate)
+void *
+rb_gc_get_objspace(void)
{
- int err = 0;
- rb_objspace_t *objspace = &rb_objspace;
-
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
- if (SPECIAL_CONST_P(obj)) {
- fprintf(stderr, "check_rvalue_consistency: %p is a special const.\n", (void *)obj);
- err++;
- }
- else if (!is_pointer_to_heap(objspace, (void *)obj)) {
- /* check if it is in tomb_pages */
- struct heap_page *page = NULL;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- ccan_list_for_each(&size_pool->tomb_heap.pages, page, page_node) {
- if (page->start <= (uintptr_t)obj &&
- (uintptr_t)obj < (page->start + (page->total_slots * size_pool->slot_size))) {
- fprintf(stderr, "check_rvalue_consistency: %p is in a tomb_heap (%p).\n",
- (void *)obj, (void *)page);
- err++;
- goto skip;
- }
- }
- }
- bp();
- fprintf(stderr, "check_rvalue_consistency: %p is not a Ruby object.\n", (void *)obj);
- err++;
- skip:
- ;
- }
- else {
- const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
- const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
- const int mark_bit = RVALUE_MARK_BITMAP(obj) != 0;
- const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0, remembered_bit = marking_bit;
- const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-
- if (GET_HEAP_PAGE(obj)->flags.in_tomb) {
- fprintf(stderr, "check_rvalue_consistency: %s is in tomb page.\n", obj_info(obj));
- err++;
- }
- if (BUILTIN_TYPE(obj) == T_NONE) {
- fprintf(stderr, "check_rvalue_consistency: %s is T_NONE.\n", obj_info(obj));
- err++;
- }
- if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
- fprintf(stderr, "check_rvalue_consistency: %s is T_ZOMBIE.\n", obj_info(obj));
- err++;
- }
-
- obj_memsize_of((VALUE)obj, FALSE);
-
- /* check generation
- *
- * OLD == age == 3 && old-bitmap && mark-bit (except incremental marking)
- */
- if (age > 0 && wb_unprotected_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is not WB protected, but age is %d > 0.\n", obj_info(obj), age);
- err++;
- }
-
- if (!is_marking(objspace) && uncollectible_bit && !mark_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but is not marked while !gc.\n", obj_info(obj));
- err++;
- }
-
- if (!is_full_marking(objspace)) {
- if (uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.\n",
- obj_info(obj), age);
- err++;
- }
- if (remembered_bit && age != RVALUE_OLD_AGE) {
- fprintf(stderr, "check_rvalue_consistency: %s is remembered, but not old (age: %d).\n",
- obj_info(obj), age);
- err++;
- }
- }
-
- /*
- * check coloring
- *
- * marking:false marking:true
- * marked:false white *invalid*
- * marked:true black grey
- */
- if (is_incremental_marking(objspace) && marking_bit) {
- if (!is_marking(objspace) && !mark_bit) {
- fprintf(stderr, "check_rvalue_consistency: %s is marking, but not marked.\n", obj_info(obj));
- err++;
- }
- }
- }
- }
- RB_VM_LOCK_LEAVE_NO_BARRIER();
-
- if (err > 0 && terminate) {
- rb_bug("check_rvalue_consistency_force: there is %d errors.", err);
- }
- return err;
+ return GET_VM()->gc.objspace;
}
-#if RGENGC_CHECK_MODE == 0
-static inline VALUE
-check_rvalue_consistency(const VALUE obj)
-{
- return obj;
-}
-#else
-static VALUE
-check_rvalue_consistency(const VALUE obj)
+void
+rb_gc_ractor_newobj_cache_foreach(void (*func)(void *cache, void *data), void *data)
{
- check_rvalue_consistency_force(obj, TRUE);
- return obj;
-}
-#endif
+ rb_ractor_t *r = NULL;
+ if (RB_LIKELY(ruby_single_main_ractor)) {
+ GC_ASSERT(
+ ccan_list_empty(&GET_VM()->ractor.set) ||
+ (ccan_list_top(&GET_VM()->ractor.set, rb_ractor_t, vmlr_node) == ruby_single_main_ractor &&
+ ccan_list_tail(&GET_VM()->ractor.set, rb_ractor_t, vmlr_node) == ruby_single_main_ractor)
+ );
-static inline int
-gc_object_moved_p(rb_objspace_t * objspace, VALUE obj)
-{
- if (RB_SPECIAL_CONST_P(obj)) {
- return FALSE;
+ func(ruby_single_main_ractor->newobj_cache, data);
}
else {
- void *poisoned = asan_unpoison_object_temporary(obj);
-
- int ret = BUILTIN_TYPE(obj) == T_MOVED;
- /* Re-poison slot if it's not the one we want */
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
+ ccan_list_for_each(&GET_VM()->ractor.set, r, vmlr_node) {
+ func(r->newobj_cache, data);
}
- return ret;
}
}
-static inline int
-RVALUE_MARKED(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_MARK_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_PINNED(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_PIN_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_WB_UNPROTECTED(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_MARKING(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_MARKING_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_REMEMBERED(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_MARKING_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_UNCOLLECTIBLE(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
-}
-
-static inline int
-RVALUE_OLD_P_RAW(VALUE obj)
-{
- const VALUE promoted = FL_PROMOTED0 | FL_PROMOTED1;
- return (RBASIC(obj)->flags & promoted) == promoted;
-}
-
-static inline int
-RVALUE_OLD_P(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_OLD_P_RAW(obj);
-}
-
-#if RGENGC_CHECK_MODE || GC_DEBUG
-static inline int
-RVALUE_AGE(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-}
-#endif
-
-static inline void
-RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
+void
+rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void *data), void *data)
{
- MARK_IN_BITMAP(&page->uncollectible_bits[0], obj);
- objspace->rgengc.old_objects++;
- rb_transient_heap_promote(obj);
-
-#if RGENGC_PROFILE >= 2
- objspace->profile.total_promoted_count++;
- objspace->profile.promoted_types[BUILTIN_TYPE(obj)]++;
-#endif
-}
+ volatile struct {
+ VALUE errinfo;
+ VALUE final;
+ rb_control_frame_t *cfp;
+ VALUE *sp;
+ long finished;
+ } saved;
-static inline void
-RVALUE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, VALUE obj)
-{
- RB_DEBUG_COUNTER_INC(obj_promote);
- RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, GET_HEAP_PAGE(obj), obj);
-}
+ rb_execution_context_t * volatile ec = GET_EC();
+#define RESTORE_FINALIZER() (\
+ ec->cfp = saved.cfp, \
+ ec->cfp->sp = saved.sp, \
+ ec->errinfo = saved.errinfo)
-static inline VALUE
-RVALUE_FLAGS_AGE_SET(VALUE flags, int age)
-{
- flags &= ~(FL_PROMOTED0 | FL_PROMOTED1);
- flags |= (age << RVALUE_AGE_SHIFT);
- return flags;
-}
+ saved.errinfo = ec->errinfo;
+ saved.cfp = ec->cfp;
+ saved.sp = ec->cfp->sp;
+ saved.finished = 0;
+ saved.final = Qundef;
-/* set age to age+1 */
-static inline void
-RVALUE_AGE_INC(rb_objspace_t *objspace, VALUE obj)
-{
- VALUE flags = RBASIC(obj)->flags;
- int age = RVALUE_FLAGS_AGE(flags);
+ ASSERT_vm_unlocking();
+ rb_ractor_ignore_belonging(true);
+ EC_PUSH_TAG(ec);
+ enum ruby_tag_type state = EC_EXEC_TAG();
+ if (state != TAG_NONE) {
+ ++saved.finished; /* skip failed finalizer */
- if (RGENGC_CHECK_MODE && age == RVALUE_OLD_AGE) {
- rb_bug("RVALUE_AGE_INC: can not increment age of OLD object %s.", obj_info(obj));
+ VALUE failed_final = saved.final;
+ saved.final = Qundef;
+ if (!UNDEF_P(failed_final) && !NIL_P(ruby_verbose)) {
+ rb_warn("Exception in finalizer %+"PRIsVALUE, failed_final);
+ rb_ec_error_print(ec, ec->errinfo);
+ }
}
- age++;
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(flags, age);
-
- if (age == RVALUE_OLD_AGE) {
- RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
+ for (long i = saved.finished; RESTORE_FINALIZER(), i < count; saved.finished = ++i) {
+ saved.final = callback(i, data);
+ rb_check_funcall(saved.final, idCall, 1, &objid);
}
- check_rvalue_consistency(obj);
+ EC_POP_TAG();
+ rb_ractor_ignore_belonging(false);
+#undef RESTORE_FINALIZER
}
-/* set age to RVALUE_OLD_AGE */
-static inline void
-RVALUE_AGE_SET_OLD(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_set_pending_interrupt(void)
{
- check_rvalue_consistency(obj);
- GC_ASSERT(!RVALUE_OLD_P(obj));
-
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, RVALUE_OLD_AGE);
- RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
-
- check_rvalue_consistency(obj);
+ rb_execution_context_t *ec = GET_EC();
+ ec->interrupt_mask |= PENDING_INTERRUPT_MASK;
}
-/* set age to RVALUE_OLD_AGE - 1 */
-static inline void
-RVALUE_AGE_SET_CANDIDATE(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_unset_pending_interrupt(void)
{
- check_rvalue_consistency(obj);
- GC_ASSERT(!RVALUE_OLD_P(obj));
-
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, RVALUE_OLD_AGE - 1);
-
- check_rvalue_consistency(obj);
+ rb_execution_context_t *ec = GET_EC();
+ ec->interrupt_mask &= ~PENDING_INTERRUPT_MASK;
}
-static inline void
-RVALUE_DEMOTE_RAW(rb_objspace_t *objspace, VALUE obj)
+bool
+rb_gc_multi_ractor_p(void)
{
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), obj);
+ return rb_multi_ractor_p();
}
-static inline void
-RVALUE_DEMOTE(rb_objspace_t *objspace, VALUE obj)
+bool
+rb_gc_shutdown_call_finalizer_p(VALUE obj)
{
- check_rvalue_consistency(obj);
- GC_ASSERT(RVALUE_OLD_P(obj));
-
- if (!is_incremental_marking(objspace) && RVALUE_REMEMBERED(obj)) {
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
- }
-
- RVALUE_DEMOTE_RAW(objspace, obj);
+ switch (BUILTIN_TYPE(obj)) {
+ case T_DATA:
+ if (!ruby_free_at_exit_p()) {
+ if (!RDATA(obj)->type) return false;
+ if (!rbimpl_typeddata_embedded_p(obj) && !RTYPEDDATA(obj)->data) return false;
+ }
+ if (rb_obj_is_thread(obj)) return false;
+ if (rb_obj_is_mutex(obj)) return false;
+ if (rb_obj_is_fiber(obj)) return false;
+ if (rb_ractor_p(obj)) return false;
+ if (rb_obj_is_fstring_table(obj)) return false;
+ if (rb_obj_is_symbol_table(obj)) return false;
- if (RVALUE_MARKED(obj)) {
- objspace->rgengc.old_objects--;
- }
+ return true;
- check_rvalue_consistency(obj);
-}
+ case T_FILE:
+ return true;
-static inline void
-RVALUE_AGE_RESET_RAW(VALUE obj)
-{
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
-}
+ case T_SYMBOL:
+ return true;
-static inline void
-RVALUE_AGE_RESET(VALUE obj)
-{
- check_rvalue_consistency(obj);
- GC_ASSERT(!RVALUE_OLD_P(obj));
+ case T_NONE:
+ return false;
- RVALUE_AGE_RESET_RAW(obj);
- check_rvalue_consistency(obj);
+ default:
+ return ruby_free_at_exit_p();
+ }
}
-static inline int
-RVALUE_BLACK_P(VALUE obj)
+void
+rb_gc_obj_changed_pool(VALUE obj, size_t heap_id)
{
- return RVALUE_MARKED(obj) && !RVALUE_MARKING(obj);
-}
+ RUBY_ASSERT(RB_TYPE_P(obj, T_OBJECT));
-#if 0
-static inline int
-RVALUE_GREY_P(VALUE obj)
-{
- return RVALUE_MARKED(obj) && RVALUE_MARKING(obj);
+ RBASIC_SET_SHAPE_ID(obj, rb_obj_shape_transition_heap(obj, heap_id));
}
-#endif
-static inline int
-RVALUE_WHITE_P(VALUE obj)
-{
- return RVALUE_MARKED(obj) == FALSE;
-}
-
-/*
- --------------------------- ObjectSpace -----------------------------
-*/
+void rb_vm_update_references(void *ptr);
-static inline void *
-calloc1(size_t n)
-{
- return calloc(1, n);
-}
+#define rb_setjmp(env) RUBY_SETJMP(env)
+#define rb_jmp_buf rb_jmpbuf_t
-rb_objspace_t *
-rb_objspace_alloc(void)
-{
- rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
- objspace->flags.measure_gc = 1;
- malloc_limit = gc_params.malloc_limit_min;
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
+#define unless_objspace(objspace) \
+ void *objspace; \
+ rb_vm_t *unless_objspace_vm = GET_VM(); \
+ if (unless_objspace_vm) objspace = unless_objspace_vm->gc.objspace; \
+ else /* return; or objspace will be warned uninitialized */
- size_pool->slot_size = (1 << i) * BASE_SLOT_SIZE;
+#define RMOVED(obj) ((struct RMoved *)(obj))
- ccan_list_head_init(&SIZE_POOL_EDEN_HEAP(size_pool)->pages);
- ccan_list_head_init(&SIZE_POOL_TOMB_HEAP(size_pool)->pages);
- }
+#define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \
+ if (gc_object_moved_p_internal((_objspace), (VALUE)(_thing))) { \
+ *(_type *)&(_thing) = (_type)gc_location_internal(_objspace, (VALUE)_thing); \
+ } \
+} while (0)
- dont_gc_on();
+#define UPDATE_IF_MOVED(_objspace, _thing) TYPED_UPDATE_IF_MOVED(_objspace, VALUE, _thing)
- return objspace;
-}
+#if RUBY_MARK_FREE_DEBUG
+int ruby_gc_debug_indent = 0;
+#endif
-static void free_stack_chunks(mark_stack_t *);
-static void mark_stack_free_cache(mark_stack_t *);
-static void heap_page_free(rb_objspace_t *objspace, struct heap_page *page);
+#ifndef RGENGC_OBJ_INFO
+# define RGENGC_OBJ_INFO RGENGC_CHECK_MODE
+#endif
-void
-rb_objspace_free(rb_objspace_t *objspace)
-{
- if (is_lazy_sweeping(objspace))
- rb_bug("lazy sweeping underway when freeing object space");
+#ifndef CALC_EXACT_MALLOC_SIZE
+# define CALC_EXACT_MALLOC_SIZE 0
+#endif
- if (objspace->profile.records) {
- free(objspace->profile.records);
- objspace->profile.records = 0;
- }
+VALUE rb_mGC;
- if (global_list) {
- struct gc_list *list, *next;
- for (list = global_list; list; list = next) {
- next = list->next;
- xfree(list);
- }
- }
- if (heap_pages_sorted) {
- size_t i;
- for (i = 0; i < heap_allocated_pages; ++i) {
- heap_page_free(objspace, heap_pages_sorted[i]);
- }
- free(heap_pages_sorted);
- heap_allocated_pages = 0;
- heap_pages_sorted_length = 0;
- heap_pages_lomem = 0;
- heap_pages_himem = 0;
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- SIZE_POOL_EDEN_HEAP(size_pool)->total_pages = 0;
- SIZE_POOL_EDEN_HEAP(size_pool)->total_slots = 0;
+static size_t malloc_offset = 0;
+#if defined(HAVE_MALLOC_USABLE_SIZE)
+static size_t
+gc_compute_malloc_offset(void)
+{
+ // Different allocators use different metadata storage strategies which result in different
+ // ideal sizes.
+ // For instance malloc(64) will waste 8B with glibc, but waste 0B with jemalloc.
+ // But malloc(56) will waste 0B with glibc, but waste 8B with jemalloc.
+ // So we try allocating 64, 56 and 48 bytes and select the first offset that doesn't
+ // waste memory.
+ // This was tested on Linux with glibc 2.35 and jemalloc 5, and for both it result in
+ // no wasted memory.
+ size_t offset = 0;
+ for (offset = 0; offset <= 16; offset += 8) {
+ size_t allocated = (64 - offset);
+ void *test_ptr = malloc(allocated);
+ size_t wasted = malloc_usable_size(test_ptr) - allocated;
+ free(test_ptr);
+
+ if (wasted == 0) {
+ return offset;
}
}
- st_free_table(objspace->id_to_obj_tbl);
- st_free_table(objspace->obj_to_id_tbl);
-
- free_stack_chunks(&objspace->mark_stack);
- mark_stack_free_cache(&objspace->mark_stack);
-
- free(objspace);
+ return 0;
}
-
-static void
-heap_pages_expand_sorted_to(rb_objspace_t *objspace, size_t next_length)
+#else
+static size_t
+gc_compute_malloc_offset(void)
{
- struct heap_page **sorted;
- size_t size = size_mul_or_raise(next_length, sizeof(struct heap_page *), rb_eRuntimeError);
-
- gc_report(3, objspace, "heap_pages_expand_sorted: next_length: %"PRIdSIZE", size: %"PRIdSIZE"\n",
- next_length, size);
-
- if (heap_pages_sorted_length > 0) {
- sorted = (struct heap_page **)realloc(heap_pages_sorted, size);
- if (sorted) heap_pages_sorted = sorted;
- }
- else {
- sorted = heap_pages_sorted = (struct heap_page **)malloc(size);
- }
-
- if (sorted == 0) {
- rb_memerror();
- }
-
- heap_pages_sorted_length = next_length;
+ // If we don't have malloc_usable_size, we use powers of 2.
+ return 0;
}
+#endif
-static void
-heap_pages_expand_sorted(rb_objspace_t *objspace)
+size_t
+rb_malloc_grow_capa(size_t current, size_t type_size)
{
- /* usually heap_allocatable_pages + heap_eden->total_pages == heap_pages_sorted_length
- * because heap_allocatable_pages contains heap_tomb->total_pages (recycle heap_tomb pages).
- * however, if there are pages which do not have empty slots, then try to create new pages
- * so that the additional allocatable_pages counts (heap_tomb->total_pages) are added.
- */
- size_t next_length = heap_allocatable_pages(objspace);
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- next_length += SIZE_POOL_EDEN_HEAP(size_pool)->total_pages;
- next_length += SIZE_POOL_TOMB_HEAP(size_pool)->total_pages;
- }
-
- if (next_length > heap_pages_sorted_length) {
- heap_pages_expand_sorted_to(objspace, next_length);
+ size_t current_capacity = current;
+ if (current_capacity < 4) {
+ current_capacity = 4;
}
+ current_capacity *= type_size;
- GC_ASSERT(heap_allocatable_pages(objspace) + heap_eden_total_pages(objspace) <= heap_pages_sorted_length);
- GC_ASSERT(heap_allocated_pages <= heap_pages_sorted_length);
-}
-
-static void
-size_pool_allocatable_pages_set(rb_objspace_t *objspace, rb_size_pool_t *size_pool, size_t s)
-{
- size_pool->allocatable_pages = s;
- heap_pages_expand_sorted(objspace);
-}
-
-static inline void
-heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
-{
- ASSERT_vm_locking();
+ // We double the current capacity.
+ size_t new_capacity = (current_capacity * 2);
- RVALUE *p = (RVALUE *)obj;
-
- asan_unpoison_object(obj, false);
-
- asan_unlock_freelist(page);
-
- p->as.free.flags = 0;
- p->as.free.next = page->freelist;
- page->freelist = p;
- asan_lock_freelist(page);
-
- if (RGENGC_CHECK_MODE &&
- /* obj should belong to page */
- !(page->start <= (uintptr_t)obj &&
- (uintptr_t)obj < ((uintptr_t)page->start + (page->total_slots * page->slot_size)) &&
- obj % BASE_SLOT_SIZE == 0)) {
- rb_bug("heap_page_add_freeobj: %p is not rvalue.", (void *)p);
+ // And round up to the next power of 2 if it's not already one.
+ if (rb_popcount64(new_capacity) != 1) {
+ new_capacity = (size_t)(1 << (64 - nlz_int64(new_capacity)));
}
- asan_poison_object(obj);
- gc_report(3, objspace, "heap_page_add_freeobj: add %p to freelist\n", (void *)obj);
-}
-
-static inline void
-heap_add_freepage(rb_heap_t *heap, struct heap_page *page)
-{
- asan_unlock_freelist(page);
- GC_ASSERT(page->free_slots != 0);
- GC_ASSERT(page->freelist != NULL);
-
- page->free_next = heap->free_pages;
- heap->free_pages = page;
-
- RUBY_DEBUG_LOG("page:%p freelist:%p", (void *)page, (void *)page->freelist);
-
- asan_lock_freelist(page);
+ new_capacity -= malloc_offset;
+ new_capacity /= type_size;
+ if (current > new_capacity) {
+ rb_bug("rb_malloc_grow_capa: current_capacity=%zu, new_capacity=%zu, malloc_offset=%zu", current, new_capacity, malloc_offset);
+ }
+ RUBY_ASSERT(new_capacity > current);
+ return new_capacity;
}
-static inline void
-heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+static inline struct rbimpl_size_overflow_tag
+size_mul_add_overflow(size_t x, size_t y, size_t z) /* x * y + z */
{
- asan_unlock_freelist(page);
- GC_ASSERT(page->free_slots != 0);
- GC_ASSERT(page->freelist != NULL);
-
- page->free_next = heap->pooled_pages;
- heap->pooled_pages = page;
- objspace->rincgc.pooled_slots += page->free_slots;
-
- asan_lock_freelist(page);
+ struct rbimpl_size_overflow_tag t = rbimpl_size_mul_overflow(x, y);
+ struct rbimpl_size_overflow_tag u = rbimpl_size_add_overflow(t.result, z);
+ return (struct rbimpl_size_overflow_tag) { t.overflowed || u.overflowed, u.result };
}
-static void
-heap_unlink_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+static inline struct rbimpl_size_overflow_tag
+size_mul_add_mul_overflow(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
{
- ccan_list_del(&page->page_node);
- heap->total_pages--;
- heap->total_slots -= page->total_slots;
+ struct rbimpl_size_overflow_tag t = rbimpl_size_mul_overflow(x, y);
+ struct rbimpl_size_overflow_tag u = rbimpl_size_mul_overflow(z, w);
+ struct rbimpl_size_overflow_tag v = rbimpl_size_add_overflow(t.result, u.result);
+ return (struct rbimpl_size_overflow_tag) { t.overflowed || u.overflowed || v.overflowed, v.result };
}
-static void rb_aligned_free(void *ptr, size_t size);
+PRINTF_ARGS(NORETURN(static void gc_raise(VALUE, const char*, ...)), 2, 3);
-static void
-heap_page_body_free(struct heap_page_body *page_body)
+static inline size_t
+size_mul_or_raise(size_t x, size_t y, VALUE exc)
{
- GC_ASSERT((uintptr_t)page_body % HEAP_PAGE_ALIGN == 0);
-
- if (HEAP_PAGE_ALLOC_USE_MMAP) {
-#ifdef HAVE_MMAP
- GC_ASSERT(HEAP_PAGE_SIZE % sysconf(_SC_PAGE_SIZE) == 0);
- if (munmap(page_body, HEAP_PAGE_SIZE)) {
- rb_bug("heap_page_body_free: munmap failed");
- }
-#endif
+ struct rbimpl_size_overflow_tag t = rbimpl_size_mul_overflow(x, y);
+ if (LIKELY(!t.overflowed)) {
+ return t.result;
+ }
+ else if (rb_during_gc()) {
+ rb_memerror(); /* or...? */
}
else {
- rb_aligned_free(page_body, HEAP_PAGE_SIZE);
+ gc_raise(
+ exc,
+ "integer overflow: %"PRIuSIZE
+ " * %"PRIuSIZE
+ " > %"PRIuSIZE,
+ x, y, (size_t)SIZE_MAX);
}
}
-static void
-heap_page_free(rb_objspace_t *objspace, struct heap_page *page)
+size_t
+rb_size_mul_or_raise(size_t x, size_t y, VALUE exc)
{
- heap_allocated_pages--;
- page->size_pool->total_freed_pages++;
- heap_page_body_free(GET_PAGE_BODY(page->start));
- free(page);
+ return size_mul_or_raise(x, y, exc);
}
-static void
-heap_pages_free_unused_pages(rb_objspace_t *objspace)
+static inline size_t
+size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
{
- size_t i, j;
-
- bool has_pages_in_tomb_heap = FALSE;
- for (i = 0; i < SIZE_POOL_COUNT; i++) {
- if (!ccan_list_empty(&SIZE_POOL_TOMB_HEAP(&size_pools[i])->pages)) {
- has_pages_in_tomb_heap = TRUE;
- break;
- }
+ struct rbimpl_size_overflow_tag t = size_mul_add_overflow(x, y, z);
+ if (LIKELY(!t.overflowed)) {
+ return t.result;
}
-
- if (has_pages_in_tomb_heap) {
- for (i = j = 1; j < heap_allocated_pages; i++) {
- struct heap_page *page = heap_pages_sorted[i];
-
- if (page->flags.in_tomb && page->free_slots == page->total_slots) {
- heap_unlink_page(objspace, SIZE_POOL_TOMB_HEAP(page->size_pool), page);
- heap_page_free(objspace, page);
- }
- else {
- if (i != j) {
- heap_pages_sorted[j] = page;
- }
- j++;
- }
- }
-
- struct heap_page *hipage = heap_pages_sorted[heap_allocated_pages - 1];
- uintptr_t himem = (uintptr_t)hipage->start + (hipage->total_slots * hipage->slot_size);
- GC_ASSERT(himem <= heap_pages_himem);
- heap_pages_himem = himem;
-
- GC_ASSERT(j == heap_allocated_pages);
- }
-}
-
-static struct heap_page_body *
-heap_page_body_allocate(void)
-{
- struct heap_page_body *page_body;
-
- if (HEAP_PAGE_ALLOC_USE_MMAP) {
-#ifdef HAVE_MMAP
- GC_ASSERT(HEAP_PAGE_ALIGN % sysconf(_SC_PAGE_SIZE) == 0);
-
- char *ptr = mmap(NULL, HEAP_PAGE_ALIGN + HEAP_PAGE_SIZE,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (ptr == MAP_FAILED) {
- return NULL;
- }
-
- char *aligned = ptr + HEAP_PAGE_ALIGN;
- aligned -= ((VALUE)aligned & (HEAP_PAGE_ALIGN - 1));
- GC_ASSERT(aligned > ptr);
- GC_ASSERT(aligned <= ptr + HEAP_PAGE_ALIGN);
-
- size_t start_out_of_range_size = aligned - ptr;
- GC_ASSERT(start_out_of_range_size % sysconf(_SC_PAGE_SIZE) == 0);
- if (start_out_of_range_size > 0) {
- if (munmap(ptr, start_out_of_range_size)) {
- rb_bug("heap_page_body_allocate: munmap failed for start");
- }
- }
-
- size_t end_out_of_range_size = HEAP_PAGE_ALIGN - start_out_of_range_size;
- GC_ASSERT(end_out_of_range_size % sysconf(_SC_PAGE_SIZE) == 0);
- if (end_out_of_range_size > 0) {
- if (munmap(aligned + HEAP_PAGE_SIZE, end_out_of_range_size)) {
- rb_bug("heap_page_body_allocate: munmap failed for end");
- }
- }
-
- page_body = (struct heap_page_body *)aligned;
-#endif
+ else if (rb_during_gc()) {
+ rb_memerror(); /* or...? */
}
else {
- page_body = rb_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
- }
-
- GC_ASSERT((uintptr_t)page_body % HEAP_PAGE_ALIGN == 0);
-
- return page_body;
-}
-
-static struct heap_page *
-heap_page_allocate(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
-{
- uintptr_t start, end, p;
- struct heap_page *page;
- uintptr_t hi, lo, mid;
- size_t stride = size_pool->slot_size;
- unsigned int limit = (unsigned int)((HEAP_PAGE_SIZE - sizeof(struct heap_page_header)))/(int)stride;
-
- /* assign heap_page body (contains heap_page_header and RVALUEs) */
- struct heap_page_body *page_body = heap_page_body_allocate();
- if (page_body == 0) {
- rb_memerror();
- }
-
- /* assign heap_page entry */
- page = calloc1(sizeof(struct heap_page));
- if (page == 0) {
- heap_page_body_free(page_body);
- rb_memerror();
- }
-
- /* adjust obj_limit (object number available in this page) */
- start = (uintptr_t)((VALUE)page_body + sizeof(struct heap_page_header));
-
- if (start % BASE_SLOT_SIZE != 0) {
- int delta = BASE_SLOT_SIZE - (start % BASE_SLOT_SIZE);
- start = start + delta;
- GC_ASSERT(NUM_IN_PAGE(start) == 0 || NUM_IN_PAGE(start) == 1);
-
- /* Find a num in page that is evenly divisible by `stride`.
- * This is to ensure that objects are aligned with bit planes.
- * In other words, ensure there are an even number of objects
- * per bit plane. */
- if (NUM_IN_PAGE(start) == 1) {
- start += stride - BASE_SLOT_SIZE;
- }
-
- GC_ASSERT(NUM_IN_PAGE(start) * BASE_SLOT_SIZE % stride == 0);
-
- limit = (HEAP_PAGE_SIZE - (int)(start - (uintptr_t)page_body))/(int)stride;
- }
- end = start + (limit * (int)stride);
-
- /* setup heap_pages_sorted */
- lo = 0;
- hi = (uintptr_t)heap_allocated_pages;
- while (lo < hi) {
- struct heap_page *mid_page;
-
- mid = (lo + hi) / 2;
- mid_page = heap_pages_sorted[mid];
- if ((uintptr_t)mid_page->start < start) {
- lo = mid + 1;
- }
- else if ((uintptr_t)mid_page->start > start) {
- hi = mid;
- }
- else {
- rb_bug("same heap page is allocated: %p at %"PRIuVALUE, (void *)page_body, (VALUE)mid);
- }
- }
-
- if (hi < (uintptr_t)heap_allocated_pages) {
- MEMMOVE(&heap_pages_sorted[hi+1], &heap_pages_sorted[hi], struct heap_page_header*, heap_allocated_pages - hi);
- }
-
- heap_pages_sorted[hi] = page;
-
- heap_allocated_pages++;
-
- GC_ASSERT(heap_eden_total_pages(objspace) + heap_allocatable_pages(objspace) <= heap_pages_sorted_length);
- GC_ASSERT(heap_eden_total_pages(objspace) + heap_tomb_total_pages(objspace) == heap_allocated_pages - 1);
- GC_ASSERT(heap_allocated_pages <= heap_pages_sorted_length);
-
- size_pool->total_allocated_pages++;
-
- if (heap_allocated_pages > heap_pages_sorted_length) {
- rb_bug("heap_page_allocate: allocated(%"PRIdSIZE") > sorted(%"PRIdSIZE")",
- heap_allocated_pages, heap_pages_sorted_length);
- }
-
- if (heap_pages_lomem == 0 || heap_pages_lomem > start) heap_pages_lomem = start;
- if (heap_pages_himem < end) heap_pages_himem = end;
-
- page->start = start;
- page->total_slots = limit;
- page->slot_size = size_pool->slot_size;
- page->size_pool = size_pool;
- page_body->header.page = page;
-
- for (p = start; p != end; p += stride) {
- gc_report(3, objspace, "assign_heap_page: %p is added to freelist\n", (void *)p);
- heap_page_add_freeobj(objspace, page, (VALUE)p);
- }
- page->free_slots = limit;
-
- asan_lock_freelist(page);
- return page;
-}
-
-static struct heap_page *
-heap_page_resurrect(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
-{
- struct heap_page *page = 0, *next;
-
- ccan_list_for_each_safe(&SIZE_POOL_TOMB_HEAP(size_pool)->pages, page, next, page_node) {
- asan_unlock_freelist(page);
- if (page->freelist != NULL) {
- heap_unlink_page(objspace, &size_pool->tomb_heap, page);
- asan_lock_freelist(page);
- return page;
- }
- }
-
- return NULL;
-}
-
-static struct heap_page *
-heap_page_create(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
-{
- struct heap_page *page;
- const char *method = "recycle";
-
- size_pool->allocatable_pages--;
-
- page = heap_page_resurrect(objspace, size_pool);
-
- if (page == NULL) {
- page = heap_page_allocate(objspace, size_pool);
- method = "allocate";
+ gc_raise(
+ exc,
+ "integer overflow: %"PRIuSIZE
+ " * %"PRIuSIZE
+ " + %"PRIuSIZE
+ " > %"PRIuSIZE,
+ x, y, z, (size_t)SIZE_MAX);
}
- if (0) fprintf(stderr, "heap_page_create: %s - %p, "
- "heap_allocated_pages: %"PRIdSIZE", "
- "heap_allocated_pages: %"PRIdSIZE", "
- "tomb->total_pages: %"PRIdSIZE"\n",
- method, (void *)page, heap_pages_sorted_length, heap_allocated_pages, SIZE_POOL_TOMB_HEAP(size_pool)->total_pages);
- return page;
-}
-
-static void
-heap_add_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, struct heap_page *page)
-{
- /* Adding to eden heap during incremental sweeping is forbidden */
- GC_ASSERT(!(heap == SIZE_POOL_EDEN_HEAP(size_pool) && heap->sweeping_page));
- page->flags.in_tomb = (heap == SIZE_POOL_TOMB_HEAP(size_pool));
- ccan_list_add_tail(&heap->pages, &page->page_node);
- heap->total_pages++;
- heap->total_slots += page->total_slots;
}
-static void
-heap_assign_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- struct heap_page *page = heap_page_create(objspace, size_pool);
- heap_add_page(objspace, size_pool, heap, page);
- heap_add_freepage(heap, page);
-}
-
-static void
-heap_add_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, size_t add)
+size_t
+rb_size_mul_add_or_raise(size_t x, size_t y, size_t z, VALUE exc)
{
- size_t i;
-
- size_pool_allocatable_pages_set(objspace, size_pool, add);
-
- for (i = 0; i < add; i++) {
- heap_assign_page(objspace, size_pool, heap);
- }
-
- GC_ASSERT(size_pool->allocatable_pages == 0);
+ return size_mul_add_or_raise(x, y, z, exc);
}
-static size_t
-heap_extend_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, size_t free_slots, size_t total_slots, size_t used)
+static inline size_t
+size_mul_add_mul_or_raise(size_t x, size_t y, size_t z, size_t w, VALUE exc)
{
- double goal_ratio = gc_params.heap_free_slots_goal_ratio;
- size_t next_used;
-
- if (goal_ratio == 0.0) {
- next_used = (size_t)(used * gc_params.growth_factor);
+ struct rbimpl_size_overflow_tag t = size_mul_add_mul_overflow(x, y, z, w);
+ if (LIKELY(!t.overflowed)) {
+ return t.result;
}
- else if (total_slots == 0) {
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- next_used = (gc_params.heap_init_slots * multiple) / HEAP_PAGE_OBJ_LIMIT;
+ else if (rb_during_gc()) {
+ rb_memerror(); /* or...? */
}
else {
- /* Find `f' where free_slots = f * total_slots * goal_ratio
- * => f = (total_slots - free_slots) / ((1 - goal_ratio) * total_slots)
- */
- double f = (double)(total_slots - free_slots) / ((1 - goal_ratio) * total_slots);
-
- if (f > gc_params.growth_factor) f = gc_params.growth_factor;
- if (f < 1.0) f = 1.1;
-
- next_used = (size_t)(f * used);
-
- if (0) {
- fprintf(stderr,
- "free_slots(%8"PRIuSIZE")/total_slots(%8"PRIuSIZE")=%1.2f,"
- " G(%1.2f), f(%1.2f),"
- " used(%8"PRIuSIZE") => next_used(%8"PRIuSIZE")\n",
- free_slots, total_slots, free_slots/(double)total_slots,
- goal_ratio, f, used, next_used);
- }
- }
-
- if (gc_params.growth_max_slots > 0) {
- size_t max_used = (size_t)(used + gc_params.growth_max_slots/HEAP_PAGE_OBJ_LIMIT);
- if (next_used > max_used) next_used = max_used;
- }
-
- size_t extend_page_count = next_used - used;
- /* Extend by at least 1 page. */
- if (extend_page_count == 0) extend_page_count = 1;
-
- return extend_page_count;
-}
-
-static int
-heap_increment(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- if (size_pool->allocatable_pages > 0) {
- gc_report(1, objspace, "heap_increment: heap_pages_sorted_length: %"PRIdSIZE", "
- "heap_pages_inc: %"PRIdSIZE", heap->total_pages: %"PRIdSIZE"\n",
- heap_pages_sorted_length, size_pool->allocatable_pages, heap->total_pages);
-
- GC_ASSERT(heap_allocatable_pages(objspace) + heap_eden_total_pages(objspace) <= heap_pages_sorted_length);
- GC_ASSERT(heap_allocated_pages <= heap_pages_sorted_length);
-
- heap_assign_page(objspace, size_pool, heap);
- return TRUE;
+ gc_raise(
+ exc,
+ "integer overflow: %"PRIdSIZE
+ " * %"PRIdSIZE
+ " + %"PRIdSIZE
+ " * %"PRIdSIZE
+ " > %"PRIdSIZE,
+ x, y, z, w, (size_t)SIZE_MAX);
}
- return FALSE;
}
-static void
-gc_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
+#if defined(HAVE_RB_GC_GUARDED_PTR_VAL) && HAVE_RB_GC_GUARDED_PTR_VAL
+/* trick the compiler into thinking a external signal handler uses this */
+volatile VALUE rb_gc_guarded_val;
+volatile VALUE *
+rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
{
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_continue, &lock_lev);
-
- /* Continue marking if in incremental marking. */
- if (heap->free_pages == NULL && is_incremental_marking(objspace)) {
- if (gc_marks_continue(objspace, size_pool, heap)) {
- gc_sweep(objspace);
- }
- }
-
- /* Continue sweeping if in lazy sweeping or the previous incremental
- * marking finished and did not yield a free page. */
- if (heap->free_pages == NULL && is_lazy_sweeping(objspace)) {
- gc_sweep_continue(objspace, size_pool, heap);
- }
+ rb_gc_guarded_val = val;
- gc_exit(objspace, gc_enter_event_continue, &lock_lev);
+ return ptr;
}
+#endif
-static void
-heap_prepare(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- GC_ASSERT(heap->free_pages == NULL);
-
- /* Continue incremental marking or lazy sweeping, if in any of those steps. */
- gc_continue(objspace, size_pool, heap);
-
- /* If we still don't have a free page and not allowed to create a new page,
- * we should start a new GC cycle. */
- if (heap->free_pages == NULL &&
- (will_be_incremental_marking(objspace) ||
- (heap_increment(objspace, size_pool, heap) == FALSE))) {
- if (gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
- rb_memerror();
- }
- else {
- /* Do steps of incremental marking or lazy sweeping if the GC run permits. */
- gc_continue(objspace, size_pool, heap);
-
- /* If we're not incremental marking (e.g. a minor GC) or finished
- * sweeping and still don't have a free page, then
- * gc_sweep_finish_size_pool should allow us to create a new page. */
- if (heap->free_pages == NULL && !heap_increment(objspace, size_pool, heap)) {
- if (objspace->rgengc.need_major_gc == GPR_FLAG_NONE) {
- rb_bug("cannot create a new page after GC");
- }
- else { // Major GC is required, which will allow us to create new page
- if (gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
- rb_memerror();
- }
- else {
- /* Do steps of incremental marking or lazy sweeping. */
- gc_continue(objspace, size_pool, heap);
-
- if (heap->free_pages == NULL &&
- !heap_increment(objspace, size_pool, heap)) {
- rb_bug("cannot create a new page after major GC");
- }
- }
+static const char *obj_type_name(VALUE obj);
+static st_table *id2ref_tbl;
+#include "gc/default/default.c"
+
+#if USE_MODULAR_GC && !defined(HAVE_DLOPEN)
+# error "Modular GC requires dlopen"
+#elif USE_MODULAR_GC
+#include <dlfcn.h>
+
+typedef struct gc_function_map {
+ // Bootup
+ void *(*objspace_alloc)(void);
+ void (*objspace_init)(void *objspace_ptr);
+ void *(*ractor_cache_alloc)(void *objspace_ptr, void *ractor);
+ void (*set_params)(void *objspace_ptr);
+ void (*init)(void);
+ size_t *(*heap_sizes)(void *objspace_ptr);
+ // Shutdown
+ void (*shutdown_free_objects)(void *objspace_ptr);
+ void (*objspace_free)(void *objspace_ptr);
+ void (*ractor_cache_free)(void *objspace_ptr, void *cache);
+ // GC
+ void (*start)(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact);
+ bool (*during_gc_p)(void *objspace_ptr);
+ void (*prepare_heap)(void *objspace_ptr);
+ void (*gc_enable)(void *objspace_ptr);
+ void (*gc_disable)(void *objspace_ptr, bool finish_current_gc);
+ bool (*gc_enabled_p)(void *objspace_ptr);
+ VALUE (*config_get)(void *objpace_ptr);
+ void (*config_set)(void *objspace_ptr, VALUE hash);
+ void (*stress_set)(void *objspace_ptr, VALUE flag);
+ VALUE (*stress_get)(void *objspace_ptr);
+ struct rb_gc_vm_context *(*get_vm_context)(void *objspace_ptr);
+ // Object allocation
+ VALUE (*new_obj)(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags, bool wb_protected, size_t alloc_size);
+ size_t (*obj_slot_size)(VALUE obj);
+ size_t (*heap_id_for_size)(void *objspace_ptr, size_t size);
+ bool (*size_allocatable_p)(size_t size);
+ // Malloc
+ void *(*malloc)(void *objspace_ptr, size_t size, bool gc_allowed);
+ void *(*calloc)(void *objspace_ptr, size_t size, bool gc_allowed);
+ void *(*realloc)(void *objspace_ptr, void *ptr, size_t new_size, size_t old_size, bool gc_allowed);
+ void (*free)(void *objspace_ptr, void *ptr, size_t old_size);
+ void (*adjust_memory_usage)(void *objspace_ptr, ssize_t diff);
+ // Marking
+ void (*mark)(void *objspace_ptr, VALUE obj);
+ void (*mark_and_move)(void *objspace_ptr, VALUE *ptr);
+ void (*mark_and_pin)(void *objspace_ptr, VALUE obj);
+ void (*mark_maybe)(void *objspace_ptr, VALUE obj);
+ // Weak references
+ void (*declare_weak_references)(void *objspace_ptr, VALUE obj);
+ bool (*handle_weak_references_alive_p)(void *objspace_ptr, VALUE obj);
+ // Compaction
+ void (*register_pinning_obj)(void *objspace_ptr, VALUE obj);
+ bool (*object_moved_p)(void *objspace_ptr, VALUE obj);
+ VALUE (*location)(void *objspace_ptr, VALUE value);
+ // Write barriers
+ void (*writebarrier)(void *objspace_ptr, VALUE a, VALUE b);
+ void (*writebarrier_unprotect)(void *objspace_ptr, VALUE obj);
+ void (*writebarrier_remember)(void *objspace_ptr, VALUE obj);
+ // Heap walking
+ void (*each_objects)(void *objspace_ptr, int (*callback)(void *, void *, size_t, void *), void *data);
+ void (*each_object)(void *objspace_ptr, void (*func)(VALUE obj, void *data), void *data);
+ // Finalizers
+ void (*make_zombie)(void *objspace_ptr, VALUE obj, void (*dfree)(void *), void *data);
+ VALUE (*define_finalizer)(void *objspace_ptr, VALUE obj, VALUE block);
+ void (*undefine_finalizer)(void *objspace_ptr, VALUE obj);
+ void (*copy_finalizer)(void *objspace_ptr, VALUE dest, VALUE obj);
+ void (*shutdown_call_finalizer)(void *objspace_ptr);
+ // Forking
+ void (*before_fork)(void *objspace_ptr);
+ void (*after_fork)(void *objspace_ptr, rb_pid_t pid);
+ // Statistics
+ void (*set_measure_total_time)(void *objspace_ptr, VALUE flag);
+ bool (*get_measure_total_time)(void *objspace_ptr);
+ unsigned long long (*get_total_time)(void *objspace_ptr);
+ size_t (*gc_count)(void *objspace_ptr);
+ VALUE (*latest_gc_info)(void *objspace_ptr, VALUE key);
+ VALUE (*stat)(void *objspace_ptr, VALUE hash_or_sym);
+ VALUE (*stat_heap)(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
+ const char *(*active_gc_name)(void);
+ // Miscellaneous
+ struct rb_gc_object_metadata_entry *(*object_metadata)(void *objspace_ptr, VALUE obj);
+ bool (*pointer_to_heap_p)(void *objspace_ptr, const void *ptr);
+ bool (*garbage_object_p)(void *objspace_ptr, VALUE obj);
+ void (*set_event_hook)(void *objspace_ptr, const rb_event_flag_t event);
+ void (*copy_attributes)(void *objspace_ptr, VALUE dest, VALUE obj);
+
+ bool modular_gc_loaded_p;
+} rb_gc_function_map_t;
+
+static rb_gc_function_map_t rb_gc_functions;
+
+# define RUBY_GC_LIBRARY "RUBY_GC_LIBRARY"
+# define MODULAR_GC_DIR STRINGIZE(modular_gc_dir)
+
+static void
+ruby_modular_gc_init(void)
+{
+ // Assert that the directory path ends with a /
+ RUBY_ASSERT_ALWAYS(MODULAR_GC_DIR[sizeof(MODULAR_GC_DIR) - 2] == '/');
+
+ const char *gc_so_file = getenv(RUBY_GC_LIBRARY);
+
+ rb_gc_function_map_t gc_functions = { 0 };
+
+ char *gc_so_path = NULL;
+ void *handle = NULL;
+ if (gc_so_file) {
+ /* Check to make sure that gc_so_file matches /[\w-_]+/ so that it does
+ * not load a shared object outside of the directory. */
+ for (size_t i = 0; i < strlen(gc_so_file); i++) {
+ char c = gc_so_file[i];
+ if (isalnum(c)) continue;
+ switch (c) {
+ case '-':
+ case '_':
+ break;
+ default:
+ fprintf(stderr, "Only alphanumeric, dash, and underscore is allowed in "RUBY_GC_LIBRARY"\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ size_t gc_so_path_size = strlen(MODULAR_GC_DIR "librubygc." DLEXT) + strlen(gc_so_file) + 1;
+#ifdef LOAD_RELATIVE
+ Dl_info dli;
+ size_t prefix_len = 0;
+ if (dladdr((void *)(uintptr_t)ruby_modular_gc_init, &dli)) {
+ const char *base = strrchr(dli.dli_fname, '/');
+ if (base) {
+ size_t tail = 0;
+# define end_with_p(lit) \
+ (prefix_len >= (tail = rb_strlen_lit(lit)) && \
+ memcmp(base - tail, lit, tail) == 0)
+
+ prefix_len = base - dli.dli_fname;
+ if (end_with_p("/bin") || end_with_p("/lib")) {
+ prefix_len -= tail;
}
+ prefix_len += MODULAR_GC_DIR[0] != '/';
+ gc_so_path_size += prefix_len;
}
}
- }
-
- GC_ASSERT(heap->free_pages != NULL);
-}
-
-void
-rb_objspace_set_event_hook(const rb_event_flag_t event)
-{
- rb_objspace_t *objspace = &rb_objspace;
- objspace->hook_events = event & RUBY_INTERNAL_EVENT_OBJSPACE_MASK;
- objspace->flags.has_hook = (objspace->hook_events != 0);
-}
-
-static void
-gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
-{
- if (UNLIKELY(!ec->cfp)) return;
- const VALUE *pc = ec->cfp->pc;
- if (pc && VM_FRAME_RUBYFRAME_P(ec->cfp)) {
- int prev_opcode = rb_vm_insn_addr2opcode((void *)*ec->cfp->iseq->body->iseq_encoded);
- for (const VALUE *insn = ec->cfp->iseq->body->iseq_encoded; insn < pc; insn += rb_insn_len(prev_opcode)) {
- prev_opcode = rb_vm_insn_addr2opcode((void *)*insn);
+#endif
+ gc_so_path = alloca(gc_so_path_size);
+ {
+ size_t gc_so_path_idx = 0;
+#define GC_SO_PATH_APPEND(str) do { \
+ gc_so_path_idx += strlcpy(gc_so_path + gc_so_path_idx, str, gc_so_path_size - gc_so_path_idx); \
+} while (0)
+#ifdef LOAD_RELATIVE
+ if (prefix_len > 0) {
+ memcpy(gc_so_path, dli.dli_fname, prefix_len);
+ gc_so_path_idx = prefix_len;
+ }
+#endif
+ GC_SO_PATH_APPEND(MODULAR_GC_DIR "librubygc.");
+ GC_SO_PATH_APPEND(gc_so_file);
+ GC_SO_PATH_APPEND(DLEXT);
+ GC_ASSERT(gc_so_path_idx == gc_so_path_size - 1);
+#undef GC_SO_PATH_APPEND
}
- /* If the previous instruction is a leaf instruction, then the PC is
- * the currently executing instruction. We should increment the PC
- * because the source line is calculated with PC-1 in calc_pos.
- *
- * If the previous instruction is not a leaf instruction and the
- * current instruction is not a leaf instruction, then the PC was
- * incremented before the instruction was ran (meaning the currently
- * executing instruction is actually the previous instruction), so we
- * should not increment the PC otherwise we will calculate the source
- * line for the next instruction.
- *
- * However, this implementation still has a bug. Consider the
- * following situation:
- *
- * non-leaf
- * leaf <-
- *
- * Where the PC currently points to a leaf instruction. We don't know
- * which instruction we really are at since we could be at the non-leaf
- * instruction (since it incremented the PC before executing the
- * instruction). We could also be at the leaf instruction since the PC
- * doesn't get incremented until the instruction finishes.
- */
- if (rb_insns_leaf_p(prev_opcode)) {
- ec->cfp->pc++;
+ handle = dlopen(gc_so_path, RTLD_LAZY | RTLD_GLOBAL);
+ if (!handle) {
+ fprintf(stderr, "ruby_modular_gc_init: Shared library %s cannot be opened: %s\n", gc_so_path, dlerror());
+ exit(EXIT_FAILURE);
}
+
+ gc_functions.modular_gc_loaded_p = true;
}
- EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, data);
- ec->cfp->pc = pc;
-}
-#define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook)
-#define gc_event_hook_needed_p(objspace, event) ((objspace)->hook_events & (event))
+ unsigned int err_count = 0;
-#define gc_event_hook_prep(objspace, event, data, prep) do { \
- if (UNLIKELY(gc_event_hook_needed_p(objspace, event))) { \
- prep; \
- gc_event_hook_body(GET_EC(), (objspace), (event), (data)); \
+# define load_modular_gc_func(name) do { \
+ if (handle) { \
+ const char *func_name = "rb_gc_impl_" #name; \
+ gc_functions.name = dlsym(handle, func_name); \
+ if (!gc_functions.name) { \
+ fprintf(stderr, "ruby_modular_gc_init: %s function not exported by library %s\n", func_name, gc_so_path); \
+ err_count++; \
+ } \
+ } \
+ else { \
+ gc_functions.name = rb_gc_impl_##name; \
} \
} while (0)
-#define gc_event_hook(objspace, event, data) gc_event_hook_prep(objspace, event, data, (void)0)
-
-static inline VALUE
-newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, VALUE obj)
-{
-#if !__has_feature(memory_sanitizer)
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
-#endif
- RVALUE *p = RANY(obj);
- p->as.basic.flags = flags;
- *((VALUE *)&p->as.basic.klass) = klass;
-
-#if RACTOR_CHECK_MODE
- rb_ractor_setup_belonging(obj);
-#endif
-
-#if RGENGC_CHECK_MODE
- p->as.values.v1 = p->as.values.v2 = p->as.values.v3 = 0;
-
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
- check_rvalue_consistency(obj);
-
- GC_ASSERT(RVALUE_MARKED(obj) == FALSE);
- GC_ASSERT(RVALUE_MARKING(obj) == FALSE);
- GC_ASSERT(RVALUE_OLD_P(obj) == FALSE);
- GC_ASSERT(RVALUE_WB_UNPROTECTED(obj) == FALSE);
-
- if (flags & FL_PROMOTED1) {
- if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj));
- }
- else {
- if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
- }
- if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
- }
- RB_VM_LOCK_LEAVE_NO_BARRIER();
-#endif
-
- if (UNLIKELY(wb_protected == FALSE)) {
- ASSERT_vm_locking();
- MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
+ // Bootup
+ load_modular_gc_func(objspace_alloc);
+ load_modular_gc_func(objspace_init);
+ load_modular_gc_func(ractor_cache_alloc);
+ load_modular_gc_func(set_params);
+ load_modular_gc_func(init);
+ load_modular_gc_func(heap_sizes);
+ // Shutdown
+ load_modular_gc_func(shutdown_free_objects);
+ load_modular_gc_func(objspace_free);
+ load_modular_gc_func(ractor_cache_free);
+ // GC
+ load_modular_gc_func(start);
+ load_modular_gc_func(during_gc_p);
+ load_modular_gc_func(prepare_heap);
+ load_modular_gc_func(gc_enable);
+ load_modular_gc_func(gc_disable);
+ load_modular_gc_func(gc_enabled_p);
+ load_modular_gc_func(config_set);
+ load_modular_gc_func(config_get);
+ load_modular_gc_func(stress_set);
+ load_modular_gc_func(stress_get);
+ load_modular_gc_func(get_vm_context);
+ // Object allocation
+ load_modular_gc_func(new_obj);
+ load_modular_gc_func(obj_slot_size);
+ load_modular_gc_func(heap_id_for_size);
+ load_modular_gc_func(size_allocatable_p);
+ // Malloc
+ load_modular_gc_func(malloc);
+ load_modular_gc_func(calloc);
+ load_modular_gc_func(realloc);
+ load_modular_gc_func(free);
+ load_modular_gc_func(adjust_memory_usage);
+ // Marking
+ load_modular_gc_func(mark);
+ load_modular_gc_func(mark_and_move);
+ load_modular_gc_func(mark_and_pin);
+ load_modular_gc_func(mark_maybe);
+ // Weak references
+ load_modular_gc_func(declare_weak_references);
+ load_modular_gc_func(handle_weak_references_alive_p);
+ // Compaction
+ load_modular_gc_func(register_pinning_obj);
+ load_modular_gc_func(object_moved_p);
+ load_modular_gc_func(location);
+ // Write barriers
+ load_modular_gc_func(writebarrier);
+ load_modular_gc_func(writebarrier_unprotect);
+ load_modular_gc_func(writebarrier_remember);
+ // Heap walking
+ load_modular_gc_func(each_objects);
+ load_modular_gc_func(each_object);
+ // Finalizers
+ load_modular_gc_func(make_zombie);
+ load_modular_gc_func(define_finalizer);
+ load_modular_gc_func(undefine_finalizer);
+ load_modular_gc_func(copy_finalizer);
+ load_modular_gc_func(shutdown_call_finalizer);
+ // Forking
+ load_modular_gc_func(before_fork);
+ load_modular_gc_func(after_fork);
+ // Statistics
+ load_modular_gc_func(set_measure_total_time);
+ load_modular_gc_func(get_measure_total_time);
+ load_modular_gc_func(get_total_time);
+ load_modular_gc_func(gc_count);
+ load_modular_gc_func(latest_gc_info);
+ load_modular_gc_func(stat);
+ load_modular_gc_func(stat_heap);
+ load_modular_gc_func(active_gc_name);
+ // Miscellaneous
+ load_modular_gc_func(object_metadata);
+ load_modular_gc_func(pointer_to_heap_p);
+ load_modular_gc_func(garbage_object_p);
+ load_modular_gc_func(set_event_hook);
+ load_modular_gc_func(copy_attributes);
+
+ if (err_count > 0) {
+ fprintf(stderr, "ruby_modular_gc_init: found %u missing exports in library %s\n", err_count, gc_so_path);
+ exit(EXIT_FAILURE);
}
- // TODO: make it atomic, or ractor local
- objspace->total_allocated_objects++;
-
-#if RGENGC_PROFILE
- if (wb_protected) {
- objspace->profile.total_generated_normal_object_count++;
-#if RGENGC_PROFILE >= 2
- objspace->profile.generated_normal_object_count_types[BUILTIN_TYPE(obj)]++;
-#endif
- }
- else {
- objspace->profile.total_generated_shady_object_count++;
-#if RGENGC_PROFILE >= 2
- objspace->profile.generated_shady_object_count_types[BUILTIN_TYPE(obj)]++;
-#endif
- }
-#endif
+# undef load_modular_gc_func
+
+ rb_gc_functions = gc_functions;
+}
+
+// Bootup
+# define rb_gc_impl_objspace_alloc rb_gc_functions.objspace_alloc
+# define rb_gc_impl_objspace_init rb_gc_functions.objspace_init
+# define rb_gc_impl_ractor_cache_alloc rb_gc_functions.ractor_cache_alloc
+# define rb_gc_impl_set_params rb_gc_functions.set_params
+# define rb_gc_impl_init rb_gc_functions.init
+# define rb_gc_impl_heap_sizes rb_gc_functions.heap_sizes
+// Shutdown
+# define rb_gc_impl_shutdown_free_objects rb_gc_functions.shutdown_free_objects
+# define rb_gc_impl_objspace_free rb_gc_functions.objspace_free
+# define rb_gc_impl_ractor_cache_free rb_gc_functions.ractor_cache_free
+// GC
+# define rb_gc_impl_start rb_gc_functions.start
+# define rb_gc_impl_during_gc_p rb_gc_functions.during_gc_p
+# define rb_gc_impl_prepare_heap rb_gc_functions.prepare_heap
+# define rb_gc_impl_gc_enable rb_gc_functions.gc_enable
+# define rb_gc_impl_gc_disable rb_gc_functions.gc_disable
+# define rb_gc_impl_gc_enabled_p rb_gc_functions.gc_enabled_p
+# define rb_gc_impl_config_get rb_gc_functions.config_get
+# define rb_gc_impl_config_set rb_gc_functions.config_set
+# define rb_gc_impl_stress_set rb_gc_functions.stress_set
+# define rb_gc_impl_stress_get rb_gc_functions.stress_get
+# define rb_gc_impl_get_vm_context rb_gc_functions.get_vm_context
+// Object allocation
+# define rb_gc_impl_new_obj rb_gc_functions.new_obj
+# define rb_gc_impl_obj_slot_size rb_gc_functions.obj_slot_size
+# define rb_gc_impl_heap_id_for_size rb_gc_functions.heap_id_for_size
+# define rb_gc_impl_size_allocatable_p rb_gc_functions.size_allocatable_p
+// Malloc
+# define rb_gc_impl_malloc rb_gc_functions.malloc
+# define rb_gc_impl_calloc rb_gc_functions.calloc
+# define rb_gc_impl_realloc rb_gc_functions.realloc
+# define rb_gc_impl_free rb_gc_functions.free
+# define rb_gc_impl_adjust_memory_usage rb_gc_functions.adjust_memory_usage
+// Marking
+# define rb_gc_impl_mark rb_gc_functions.mark
+# define rb_gc_impl_mark_and_move rb_gc_functions.mark_and_move
+# define rb_gc_impl_mark_and_pin rb_gc_functions.mark_and_pin
+# define rb_gc_impl_mark_maybe rb_gc_functions.mark_maybe
+// Weak references
+# define rb_gc_impl_declare_weak_references rb_gc_functions.declare_weak_references
+# define rb_gc_impl_handle_weak_references_alive_p rb_gc_functions.handle_weak_references_alive_p
+// Compaction
+# define rb_gc_impl_register_pinning_obj rb_gc_functions.register_pinning_obj
+# define rb_gc_impl_object_moved_p rb_gc_functions.object_moved_p
+# define rb_gc_impl_location rb_gc_functions.location
+// Write barriers
+# define rb_gc_impl_writebarrier rb_gc_functions.writebarrier
+# define rb_gc_impl_writebarrier_unprotect rb_gc_functions.writebarrier_unprotect
+# define rb_gc_impl_writebarrier_remember rb_gc_functions.writebarrier_remember
+// Heap walking
+# define rb_gc_impl_each_objects rb_gc_functions.each_objects
+# define rb_gc_impl_each_object rb_gc_functions.each_object
+// Finalizers
+# define rb_gc_impl_make_zombie rb_gc_functions.make_zombie
+# define rb_gc_impl_define_finalizer rb_gc_functions.define_finalizer
+# define rb_gc_impl_undefine_finalizer rb_gc_functions.undefine_finalizer
+# define rb_gc_impl_copy_finalizer rb_gc_functions.copy_finalizer
+# define rb_gc_impl_shutdown_call_finalizer rb_gc_functions.shutdown_call_finalizer
+// Forking
+# define rb_gc_impl_before_fork rb_gc_functions.before_fork
+# define rb_gc_impl_after_fork rb_gc_functions.after_fork
+// Statistics
+# define rb_gc_impl_set_measure_total_time rb_gc_functions.set_measure_total_time
+# define rb_gc_impl_get_measure_total_time rb_gc_functions.get_measure_total_time
+# define rb_gc_impl_get_total_time rb_gc_functions.get_total_time
+# define rb_gc_impl_gc_count rb_gc_functions.gc_count
+# define rb_gc_impl_latest_gc_info rb_gc_functions.latest_gc_info
+# define rb_gc_impl_stat rb_gc_functions.stat
+# define rb_gc_impl_stat_heap rb_gc_functions.stat_heap
+# define rb_gc_impl_active_gc_name rb_gc_functions.active_gc_name
+// Miscellaneous
+# define rb_gc_impl_object_metadata rb_gc_functions.object_metadata
+# define rb_gc_impl_pointer_to_heap_p rb_gc_functions.pointer_to_heap_p
+# define rb_gc_impl_garbage_object_p rb_gc_functions.garbage_object_p
+# define rb_gc_impl_set_event_hook rb_gc_functions.set_event_hook
+# define rb_gc_impl_copy_attributes rb_gc_functions.copy_attributes
+#endif
+
+#ifdef RUBY_ASAN_ENABLED
+static void
+asan_death_callback(void)
+{
+ if (GET_VM()) {
+ rb_bug_without_die("ASAN error");
+ }
+}
+#endif
+
+static VALUE initial_stress = Qfalse;
-#if GC_DEBUG
- RANY(obj)->file = rb_source_location_cstr(&RANY(obj)->line);
- GC_ASSERT(!SPECIAL_CONST_P(obj)); /* check alignment */
+void *
+rb_objspace_alloc(void)
+{
+#if USE_MODULAR_GC
+ ruby_modular_gc_init();
#endif
- gc_report(5, objspace, "newobj: %s\n", obj_info(obj));
-
-#if RGENGC_OLD_NEWOBJ_CHECK > 0
- {
- static int newobj_cnt = RGENGC_OLD_NEWOBJ_CHECK;
-
- if (!is_incremental_marking(objspace) &&
- flags & FL_WB_PROTECTED && /* do not promote WB unprotected objects */
- ! RB_TYPE_P(obj, T_ARRAY)) { /* array.c assumes that allocated objects are new */
- if (--newobj_cnt == 0) {
- newobj_cnt = RGENGC_OLD_NEWOBJ_CHECK;
-
- gc_mark_set(objspace, obj);
- RVALUE_AGE_SET_OLD(objspace, obj);
+ void *objspace = rb_gc_impl_objspace_alloc();
+ ruby_current_vm_ptr->gc.objspace = objspace;
+ rb_gc_impl_objspace_init(objspace);
+ rb_gc_impl_stress_set(objspace, initial_stress);
- rb_gc_writebarrier_remember(obj);
- }
- }
- }
+#ifdef RUBY_ASAN_ENABLED
+ __sanitizer_set_death_callback(asan_death_callback);
#endif
- // RUBY_DEBUG_LOG("obj:%p (%s)", (void *)obj, obj_type_name(obj));
- return obj;
-}
-size_t
-rb_gc_obj_slot_size(VALUE obj)
-{
- return GET_HEAP_PAGE(obj)->slot_size - RVALUE_OVERHEAD;
+ return objspace;
}
-static inline size_t
-size_pool_slot_size(unsigned char pool_id)
+void
+rb_objspace_free(void *objspace)
{
- GC_ASSERT(pool_id < SIZE_POOL_COUNT);
-
- size_t slot_size = (1 << pool_id) * BASE_SLOT_SIZE;
-
-#if RGENGC_CHECK_MODE
- rb_objspace_t *objspace = &rb_objspace;
- GC_ASSERT(size_pools[pool_id].slot_size == (short)slot_size);
-#endif
-
- slot_size -= RVALUE_OVERHEAD;
-
- return slot_size;
+ rb_gc_impl_objspace_free(objspace);
}
size_t
-rb_size_pool_slot_size(unsigned char pool_id)
-{
- return size_pool_slot_size(pool_id);
-}
-
-bool
-rb_gc_size_allocatable_p(size_t size)
-{
- return size <= size_pool_slot_size(SIZE_POOL_COUNT - 1);
-}
-
-static inline VALUE
-ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache,
- size_t size_pool_idx)
-{
- rb_ractor_newobj_size_pool_cache_t *size_pool_cache = &cache->size_pool_caches[size_pool_idx];
- RVALUE *p = size_pool_cache->freelist;
-
- if (is_incremental_marking(objspace)) {
- // Not allowed to allocate without running an incremental marking step
- if (cache->incremental_mark_step_allocated_slots >= INCREMENTAL_MARK_STEP_ALLOCATIONS) {
- return Qfalse;
- }
-
- if (p) {
- cache->incremental_mark_step_allocated_slots++;
- }
- }
-
- if (p) {
- VALUE obj = (VALUE)p;
- MAYBE_UNUSED(const size_t) stride = size_pool_slot_size(size_pool_idx);
- size_pool_cache->freelist = p->as.free.next;
-#if USE_RVARGC
- asan_unpoison_memory_region(p, stride, true);
-#else
- asan_unpoison_object(obj, true);
-#endif
-#if RGENGC_CHECK_MODE
- GC_ASSERT(rb_gc_obj_slot_size(obj) == stride);
- // zero clear
- MEMZERO((char *)obj, char, stride);
-#endif
- return obj;
- }
- else {
- return Qfalse;
- }
-}
-
-static struct heap_page *
-heap_next_free_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
+rb_gc_obj_slot_size(VALUE obj)
{
- ASSERT_vm_locking();
-
- struct heap_page *page;
-
- if (heap->free_pages == NULL) {
- heap_prepare(objspace, size_pool, heap);
- }
-
- page = heap->free_pages;
- heap->free_pages = page->free_next;
-
- GC_ASSERT(page->free_slots != 0);
- RUBY_DEBUG_LOG("page:%p freelist:%p cnt:%d", (void *)page, (void *)page->freelist, page->free_slots);
-
- asan_unlock_freelist(page);
-
- return page;
+ return rb_gc_impl_obj_slot_size(obj);
}
static inline void
-ractor_cache_set_page(rb_ractor_newobj_cache_t *cache, size_t size_pool_idx,
- struct heap_page *page)
+gc_validate_pc(VALUE obj)
{
- gc_report(3, &rb_objspace, "ractor_set_cache: Using page %p\n", (void *)GET_PAGE_BODY(page->start));
-
- rb_ractor_newobj_size_pool_cache_t *size_pool_cache = &cache->size_pool_caches[size_pool_idx];
-
- GC_ASSERT(size_pool_cache->freelist == NULL);
- GC_ASSERT(page->free_slots != 0);
- GC_ASSERT(page->freelist != NULL);
-
- size_pool_cache->using_page = page;
- size_pool_cache->freelist = page->freelist;
- page->free_slots = 0;
- page->freelist = NULL;
-
- asan_unpoison_object((VALUE)size_pool_cache->freelist, false);
- GC_ASSERT(RB_TYPE_P((VALUE)size_pool_cache->freelist, T_NONE));
- asan_poison_object((VALUE)size_pool_cache->freelist);
-}
-
-static inline VALUE
-newobj_fill(VALUE obj, VALUE v1, VALUE v2, VALUE v3)
-{
- RVALUE *p = (RVALUE *)obj;
- p->as.values.v1 = v1;
- p->as.values.v2 = v2;
- p->as.values.v3 = v3;
- return obj;
-}
-
-static inline size_t
-size_pool_idx_for_size(size_t size)
-{
-#if USE_RVARGC
- size += RVALUE_OVERHEAD;
-
- size_t slot_count = CEILDIV(size, BASE_SLOT_SIZE);
-
- /* size_pool_idx is ceil(log2(slot_count)) */
- size_t size_pool_idx = 64 - nlz_int64(slot_count - 1);
+#if RUBY_DEBUG
+ // IMEMOs and objects without a class (e.g managed id table) are not traceable
+ if (RB_TYPE_P(obj, T_IMEMO) || !CLASS_OF(obj)) return;
- if (size_pool_idx >= SIZE_POOL_COUNT) {
- rb_bug("size_pool_idx_for_size: allocation size too large");
+ rb_execution_context_t *ec = GET_EC();
+ const rb_control_frame_t *cfp = ec->cfp;
+ if (cfp && VM_FRAME_RUBYFRAME_P(cfp) && CFP_PC(cfp)) {
+ const VALUE *iseq_encoded = ISEQ_BODY(CFP_ISEQ(cfp))->iseq_encoded;
+ const VALUE *iseq_encoded_end = iseq_encoded + ISEQ_BODY(CFP_ISEQ(cfp))->iseq_size;
+ RUBY_ASSERT(CFP_PC(cfp) >= iseq_encoded, "PC not set when allocating, breaking tracing");
+ RUBY_ASSERT(CFP_PC(cfp) <= iseq_encoded_end, "PC not set when allocating, breaking tracing");
}
-
-#if RGENGC_CHECK_MODE
- rb_objspace_t *objspace = &rb_objspace;
- GC_ASSERT(size <= (size_t)size_pools[size_pool_idx].slot_size);
- if (size_pool_idx > 0) GC_ASSERT(size > (size_t)size_pools[size_pool_idx - 1].slot_size);
#endif
-
- return size_pool_idx;
-#else
- GC_ASSERT(size <= sizeof(RVALUE));
- return 0;
-#endif
-}
-
-static VALUE
-newobj_alloc(rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx, bool vm_locked)
-{
- rb_size_pool_t *size_pool = &size_pools[size_pool_idx];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- rb_ractor_newobj_cache_t *cache = &cr->newobj_cache;
-
- VALUE obj = ractor_cache_allocate_slot(objspace, cache, size_pool_idx);
-
- if (UNLIKELY(obj == Qfalse)) {
- unsigned int lev;
- bool unlock_vm = false;
-
- if (!vm_locked) {
- RB_VM_LOCK_ENTER_CR_LEV(cr, &lev);
- vm_locked = true;
- unlock_vm = true;
- }
-
- {
- ASSERT_vm_locking();
-
- if (is_incremental_marking(objspace)) {
- gc_continue(objspace, size_pool, heap);
- cache->incremental_mark_step_allocated_slots = 0;
-
- // Retry allocation after resetting incremental_mark_step_allocated_slots
- obj = ractor_cache_allocate_slot(objspace, cache, size_pool_idx);
- }
-
- if (obj == Qfalse) {
- // Get next free page (possibly running GC)
- struct heap_page *page = heap_next_free_page(objspace, size_pool, heap);
- ractor_cache_set_page(cache, size_pool_idx, page);
-
- // Retry allocation after moving to new page
- obj = ractor_cache_allocate_slot(objspace, cache, size_pool_idx);
-
- GC_ASSERT(obj != Qfalse);
- }
- }
-
- if (unlock_vm) {
- RB_VM_LOCK_LEAVE_CR_LEV(cr, &lev);
- }
- }
-
- return obj;
}
+NOINLINE(static void gc_newobj_hook(VALUE obj));
static void
-newobj_zero_slot(VALUE obj)
+gc_newobj_hook(VALUE obj)
{
- memset((char *)obj + sizeof(struct RBasic), 0, rb_gc_obj_slot_size(obj) - sizeof(struct RBasic));
-}
-
-ALWAYS_INLINE(static VALUE newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, int wb_protected, size_t size_pool_idx));
-
-static inline VALUE
-newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, int wb_protected, size_t size_pool_idx)
-{
- VALUE obj;
- unsigned int lev;
-
- RB_VM_LOCK_ENTER_CR_LEV(cr, &lev);
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
{
- if (UNLIKELY(during_gc || ruby_gc_stressful)) {
- if (during_gc) {
- dont_gc_on();
- during_gc = 0;
- rb_bug("object allocation during garbage collection phase");
- }
-
- if (ruby_gc_stressful) {
- if (!garbage_collect(objspace, GPR_FLAG_NEWOBJ)) {
- rb_memerror();
- }
- }
+ size_t slot_size = rb_gc_obj_slot_size(obj);
+ memset((char *)obj + sizeof(struct RBasic), 0, slot_size - sizeof(struct RBasic));
+
+ /* We must disable GC here because the callback could call xmalloc
+ * which could potentially trigger a GC, and a lot of code is unsafe
+ * to trigger a GC right after an object has been allocated because
+ * they perform initialization for the object and assume that the
+ * GC does not trigger before then. */
+ bool gc_disabled = RTEST(rb_gc_disable_no_rest());
+ {
+ rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_NEWOBJ);
}
-
- obj = newobj_alloc(objspace, cr, size_pool_idx, true);
-#if SHAPE_IN_BASIC_FLAGS
- flags |= (VALUE)(size_pool_idx) << SHAPE_FLAG_SHIFT;
-#endif
- newobj_init(klass, flags, wb_protected, objspace, obj);
-
- gc_event_hook_prep(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj, newobj_zero_slot(obj));
+ if (!gc_disabled) rb_gc_enable();
}
- RB_VM_LOCK_LEAVE_CR_LEV(cr, &lev);
-
- return obj;
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
}
-NOINLINE(static VALUE newobj_slowpath_wb_protected(VALUE klass, VALUE flags,
- rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx));
-NOINLINE(static VALUE newobj_slowpath_wb_unprotected(VALUE klass, VALUE flags,
- rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx));
-
-static VALUE
-newobj_slowpath_wb_protected(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx)
+VALUE
+rb_newobj(rb_execution_context_t *ec, VALUE klass, VALUE flags, shape_id_t shape_id, bool wb_protected, size_t size)
{
- return newobj_slowpath(klass, flags, objspace, cr, TRUE, size_pool_idx);
-}
+ GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ VALUE obj = rb_gc_impl_new_obj(rb_gc_get_objspace(), cr->newobj_cache, klass, flags, wb_protected, size);
-static VALUE
-newobj_slowpath_wb_unprotected(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx)
-{
- return newobj_slowpath(klass, flags, objspace, cr, FALSE, size_pool_idx);
-}
+#if RACTOR_CHECK_MODE
+ void rb_ractor_setup_belonging(VALUE obj);
+ rb_ractor_setup_belonging(obj);
+#endif
-static inline VALUE
-newobj_of0(VALUE klass, VALUE flags, int wb_protected, rb_ractor_t *cr, size_t alloc_size)
-{
- VALUE obj;
- rb_objspace_t *objspace = &rb_objspace;
+ RBASIC_SET_SHAPE_ID_NO_CHECKS(obj, shape_id);
- RB_DEBUG_COUNTER_INC(obj_newobj);
- (void)RB_DEBUG_COUNTER_INC_IF(obj_newobj_wb_unprotected, !wb_protected);
+ gc_validate_pc(obj);
-#if GC_DEBUG_STRESS_TO_CLASS
- if (UNLIKELY(stress_to_class)) {
- long i, cnt = RARRAY_LEN(stress_to_class);
- for (i = 0; i < cnt; ++i) {
- if (klass == RARRAY_AREF(stress_to_class, i)) rb_memerror();
- }
+ if (UNLIKELY(rb_gc_event_hook_required_p(RUBY_INTERNAL_EVENT_NEWOBJ))) {
+ gc_newobj_hook(obj);
}
-#endif
- size_t size_pool_idx = size_pool_idx_for_size(alloc_size);
+#if RGENGC_CHECK_MODE
+# ifndef GC_DEBUG_SLOT_FILL_SPECIAL_VALUE
+# define GC_DEBUG_SLOT_FILL_SPECIAL_VALUE 255
+# endif
- if (!UNLIKELY(during_gc ||
- ruby_gc_stressful ||
- gc_event_hook_available_p(objspace)) &&
- wb_protected) {
- obj = newobj_alloc(objspace, cr, size_pool_idx, false);
-#if SHAPE_IN_BASIC_FLAGS
- flags |= (VALUE)size_pool_idx << SHAPE_FLAG_SHIFT;
+ memset(
+ (void *)(obj + sizeof(struct RBasic)),
+ GC_DEBUG_SLOT_FILL_SPECIAL_VALUE,
+ rb_gc_obj_slot_size(obj) - sizeof(struct RBasic)
+ );
#endif
- newobj_init(klass, flags, wb_protected, objspace, obj);
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_newobj_slowpath);
-
- obj = wb_protected ?
- newobj_slowpath_wb_protected(klass, flags, objspace, cr, size_pool_idx) :
- newobj_slowpath_wb_unprotected(klass, flags, objspace, cr, size_pool_idx);
- }
return obj;
}
-static inline VALUE
-newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, size_t alloc_size)
-{
- VALUE obj = newobj_of0(klass, flags, wb_protected, GET_RACTOR(), alloc_size);
- return newobj_fill(obj, v1, v2, v3);
-}
-
-static inline VALUE
-newobj_of_cr(rb_ractor_t *cr, VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, size_t alloc_size)
-{
- VALUE obj = newobj_of0(klass, flags, wb_protected, cr, alloc_size);
- return newobj_fill(obj, v1, v2, v3);
-}
-
VALUE
-rb_wb_unprotected_newobj_of(VALUE klass, VALUE flags, size_t size)
+rb_ec_newobj_of(rb_execution_context_t *ec, VALUE klass, VALUE flags, size_t size)
{
- GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of(klass, flags, 0, 0, 0, FALSE, size);
-}
+ VALUE type = flags & T_MASK;
+ RUBY_ASSERT(type != T_OBJECT);
+ RUBY_ASSERT(type != T_DATA);
+ RUBY_ASSERT(type != T_CLASS);
+ RUBY_ASSERT(type != T_MODULE);
+ RUBY_ASSERT(type != T_ICLASS);
+ (void)type;
-VALUE
-rb_wb_protected_newobj_of(VALUE klass, VALUE flags, size_t size)
-{
- GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of(klass, flags, 0, 0, 0, TRUE, size);
+ return rb_newobj(ec, klass, flags, ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER, true, size);
}
VALUE
-rb_ec_wb_protected_newobj_of(rb_execution_context_t *ec, VALUE klass, VALUE flags, size_t size)
+rb_newobj_of_with_shape(VALUE klass, VALUE flags, shape_id_t shape_id, size_t size)
{
- GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of_cr(rb_ec_ractor_ptr(ec), klass, flags, 0, 0, 0, TRUE, size);
+ return rb_newobj(GET_EC(), klass, flags, shape_id, true, size);
}
-/* for compatibility */
-
VALUE
-rb_newobj(void)
+rb_newobj_of(VALUE klass, VALUE flags, size_t size)
{
- return newobj_of(0, T_NONE, 0, 0, 0, FALSE, RVALUE_SIZE);
+ return rb_newobj(GET_EC(), klass, flags, ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER, true, size);
}
-static size_t
-rb_obj_embedded_size(uint32_t numiv)
+static
+VALUE class_allocate_complex_instance(VALUE klass, uint32_t capacity)
{
- return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * numiv);
+ shape_id_t initial_shape_id = rb_shape_id_with_robject_layout(rb_shape_root(rb_gc_heap_id_for_size(sizeof(struct RObject))));
+ VALUE obj = rb_newobj_of_with_shape(klass, T_OBJECT, initial_shape_id, sizeof(struct RObject));
+ rb_obj_init_complex(obj, rb_st_init_numtable_with_size(capacity));
+ return obj;
}
-static VALUE
-rb_class_instance_allocate_internal(VALUE klass, VALUE flags, bool wb_protected)
+VALUE
+rb_class_allocate_instance(VALUE klass)
{
- GC_ASSERT((flags & RUBY_T_MASK) == T_OBJECT);
- GC_ASSERT(flags & ROBJECT_EMBED);
-
- size_t size;
-#if USE_RVARGC
- uint32_t index_tbl_num_entries = RCLASS_EXT(klass)->max_iv_count;
+ uint32_t index_tbl_num_entries = RCLASS_MAX_IV_COUNT(klass);
+ VALUE obj;
- size = rb_obj_embedded_size(index_tbl_num_entries);
- if (!rb_gc_size_allocatable_p(size)) {
- size = sizeof(struct RObject);
+ // Directly start as COMPLEX if we know we're over the limit.
+ RUBY_ASSERT(rb_shape_tree.max_capacity > 0);
+ if (RB_UNLIKELY(index_tbl_num_entries > rb_shape_tree.max_capacity)) {
+ obj = class_allocate_complex_instance(klass, index_tbl_num_entries);
}
-#else
- size = sizeof(struct RObject);
-#endif
+ else {
+ size_t size = rb_obj_embedded_size(index_tbl_num_entries);
+ if (!rb_gc_size_allocatable_p(size)) {
+ size = sizeof(struct RObject);
+ }
- VALUE obj = newobj_of(klass, flags, 0, 0, 0, wb_protected, size);
- RUBY_ASSERT(rb_shape_get_shape(obj)->type == SHAPE_ROOT ||
- rb_shape_get_shape(obj)->type == SHAPE_INITIAL_CAPACITY);
+ // There might be a NEWOBJ tracepoint callback, and it may set fields.
+ // So the shape must be passed to `NEWOBJ_OF`.
+ obj = rb_newobj_of_with_shape(klass, T_OBJECT, rb_shape_id_with_robject_layout(rb_shape_root(rb_gc_heap_id_for_size(size))), size);
- // Set the shape to the specific T_OBJECT shape which is always
- // SIZE_POOL_COUNT away from the root shape.
- ROBJECT_SET_SHAPE_ID(obj, ROBJECT_SHAPE_ID(obj) + SIZE_POOL_COUNT);
+ #if RUBY_DEBUG
+ VALUE *ptr = ROBJECT_FIELDS(obj);
+ size_t fields_count = RSHAPE_LEN(RBASIC_SHAPE_ID(obj));
+ for (size_t i = fields_count; i < ROBJECT_FIELDS_CAPACITY(obj); i++) {
+ ptr[i] = Qundef;
+ }
+ #endif
+ }
#if RUBY_DEBUG
- RUBY_ASSERT(!rb_shape_obj_too_complex(obj));
- VALUE *ptr = ROBJECT_IVPTR(obj);
- for (size_t i = 0; i < ROBJECT_IV_CAPACITY(obj); i++) {
- ptr[i] = Qundef;
+ if (rb_obj_class(obj) != rb_class_real(klass)) {
+ rb_bug("Expected rb_class_allocate_instance to set the class correctly");
}
#endif
return obj;
}
-VALUE
-rb_newobj_of(VALUE klass, VALUE flags)
+void
+rb_gc_register_pinning_obj(VALUE obj)
{
- if ((flags & RUBY_T_MASK) == T_OBJECT) {
- return rb_class_instance_allocate_internal(klass, (flags | ROBJECT_EMBED) & ~FL_WB_PROTECTED, flags & FL_WB_PROTECTED);
- }
- else {
- return newobj_of(klass, flags & ~FL_WB_PROTECTED, 0, 0, 0, flags & FL_WB_PROTECTED, RVALUE_SIZE);
- }
+ rb_gc_impl_register_pinning_obj(rb_gc_get_objspace(), obj);
}
#define UNEXPECTED_NODE(func) \
rb_bug(#func"(): GC does not handle T_NODE 0x%x(%p) 0x%"PRIxVALUE, \
BUILTIN_TYPE(obj), (void*)(obj), RBASIC(obj)->flags)
-const char *
-rb_imemo_name(enum imemo_type type)
+static inline void
+rb_data_object_check(VALUE klass)
{
- // put no default case to get a warning if an imemo type is missing
- switch (type) {
-#define IMEMO_NAME(x) case imemo_##x: return #x;
- IMEMO_NAME(env);
- IMEMO_NAME(cref);
- IMEMO_NAME(svar);
- IMEMO_NAME(throw_data);
- IMEMO_NAME(ifunc);
- IMEMO_NAME(memo);
- IMEMO_NAME(ment);
- IMEMO_NAME(iseq);
- IMEMO_NAME(tmpbuf);
- IMEMO_NAME(ast);
- IMEMO_NAME(parser_strterm);
- IMEMO_NAME(callinfo);
- IMEMO_NAME(callcache);
- IMEMO_NAME(constcache);
-#undef IMEMO_NAME
+ RUBY_ASSERT(!RCLASS_SINGLETON_P(klass));
+ if (klass != rb_cObject && (rb_get_alloc_func(klass) == rb_class_allocate_instance)) {
+ rb_undef_alloc_func(klass);
+ rb_warn("undefining the allocator of T_DATA class %"PRIsVALUE, klass);
}
- return "unknown";
}
-#undef rb_imemo_new
-
-VALUE
-rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
-{
- size_t size = RVALUE_SIZE;
- VALUE flags = T_IMEMO | (type << FL_USHIFT);
- return newobj_of(v0, flags, v1, v2, v3, TRUE, size);
-}
+#define RTYPEDDATA_EMBEDDED_P rbimpl_typeddata_embedded_p
+#define RB_DATA_TYPE_EMBEDDABLE_P(type) ((type)->flags & RUBY_TYPED_EMBEDDABLE)
+#define RTYPEDDATA_EMBEDDABLE_P(obj) RB_DATA_TYPE_EMBEDDABLE_P(RTYPEDDATA_TYPE(obj))
static VALUE
-rb_imemo_tmpbuf_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
+typed_data_alloc(VALUE klass, VALUE typed_flag, void *datap, const rb_data_type_t *type, size_t size)
{
- size_t size = sizeof(struct rb_imemo_tmpbuf_struct);
- VALUE flags = T_IMEMO | (imemo_tmpbuf << FL_USHIFT);
- return newobj_of(v0, flags, v1, v2, v3, FALSE, size);
-}
+ RBIMPL_NONNULL_ARG(type);
+ if (klass) rb_data_object_check(klass);
+ bool wb_protected = (type->flags & RUBY_FL_WB_PROTECTED) || !type->function.dmark;
+ VALUE obj = rb_newobj(GET_EC(), klass, T_DATA, ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_RDATA, wb_protected, size);
-static VALUE
-rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(void *buf, size_t cnt)
-{
- return rb_imemo_tmpbuf_new((VALUE)buf, 0, (VALUE)cnt, 0);
-}
+ rb_gc_register_pinning_obj(obj);
-rb_imemo_tmpbuf_t *
-rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
-{
- return (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new((VALUE)buf, (VALUE)old_heap, (VALUE)cnt, 0);
-}
+ struct RTypedData *data = (struct RTypedData *)obj;
+ data->fields_obj = 0;
+ *(VALUE *)&data->type = ((VALUE)type) | typed_flag;
+ data->data = datap;
-static size_t
-imemo_memsize(VALUE obj)
-{
- size_t size = 0;
- switch (imemo_type(obj)) {
- case imemo_ment:
- size += sizeof(RANY(obj)->as.imemo.ment.def);
- break;
- case imemo_iseq:
- size += rb_iseq_memsize((rb_iseq_t *)obj);
- break;
- case imemo_env:
- size += RANY(obj)->as.imemo.env.env_size * sizeof(VALUE);
- break;
- case imemo_tmpbuf:
- size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE);
- break;
- case imemo_ast:
- size += rb_ast_memsize(&RANY(obj)->as.imemo.ast);
- break;
- case imemo_cref:
- case imemo_svar:
- case imemo_throw_data:
- case imemo_ifunc:
- case imemo_memo:
- case imemo_parser_strterm:
- break;
- default:
- /* unreachable */
- break;
- }
- return size;
+ return obj;
}
-#if IMEMO_DEBUG
VALUE
-rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line)
+rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
{
- VALUE memo = rb_imemo_new(type, v1, v2, v3, v0);
- fprintf(stderr, "memo %p (type: %d) @ %s:%d\n", (void *)memo, imemo_type(memo), file, line);
- return memo;
+ if (UNLIKELY(RB_DATA_TYPE_EMBEDDABLE_P(type))) {
+ rb_raise(rb_eTypeError, "Cannot wrap an embeddable TypedData");
+ }
+
+ return typed_data_alloc(klass, 0, datap, type, sizeof(struct RTypedData));
}
-#endif
VALUE
-rb_class_allocate_instance(VALUE klass)
+rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
{
- return rb_class_instance_allocate_internal(klass, T_OBJECT | ROBJECT_EMBED, RGENGC_WB_PROTECTED_OBJECT);
-}
+ if (RB_DATA_TYPE_EMBEDDABLE_P(type)) {
+ if (!(type->flags & RUBY_TYPED_FREE_IMMEDIATELY)) {
+ rb_raise(rb_eTypeError, "Embeddable TypedData must be freed immediately");
+ }
-static inline void
-rb_data_object_check(VALUE klass)
-{
- if (klass != rb_cObject && (rb_get_alloc_func(klass) == rb_class_allocate_instance)) {
- rb_undef_alloc_func(klass);
- rb_warn("undefining the allocator of T_DATA class %"PRIsVALUE, klass);
+ size_t embed_size = offsetof(struct RTypedData, data) + size;
+ if (rb_gc_size_allocatable_p(embed_size)) {
+ VALUE obj = typed_data_alloc(klass, TYPED_DATA_EMBEDDED, 0, type, embed_size);
+ memset((char *)obj + offsetof(struct RTypedData, data), 0, size);
+ return obj;
+ }
}
-}
-VALUE
-rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
-{
- RUBY_ASSERT_ALWAYS(dfree != (RUBY_DATA_FUNC)1);
- if (klass) rb_data_object_check(klass);
- return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, !dmark, sizeof(struct RTypedData));
-}
-
-VALUE
-rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
-{
- VALUE obj = rb_data_object_wrap(klass, 0, dmark, dfree);
+ VALUE obj = typed_data_alloc(klass, 0, NULL, type, sizeof(struct RTypedData));
DATA_PTR(obj) = xcalloc(1, size);
return obj;
}
-VALUE
-rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
-{
- RBIMPL_NONNULL_ARG(type);
- if (klass) rb_data_object_check(klass);
- bool wb_protected = (type->flags & RUBY_FL_WB_PROTECTED) || !type->function.dmark;
- return newobj_of(klass, T_DATA, (VALUE)type, (VALUE)1, (VALUE)datap, wb_protected, sizeof(struct RTypedData));
-}
-
-VALUE
-rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
+static size_t
+ruby_xmalloc_usable_size(void *ptr)
{
- VALUE obj = rb_data_typed_object_wrap(klass, 0, type);
- DATA_PTR(obj) = xcalloc(1, size);
- return obj;
+#ifdef HAVE_MALLOC_USABLE_SIZE
+#if CALC_EXACT_MALLOC_SIZE
+ struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
+ return malloc_usable_size(info) - sizeof(struct malloc_obj_info);
+#else
+ return malloc_usable_size(ptr);
+#endif
+#else
+ return 0;
+#endif
}
-size_t
+static size_t
rb_objspace_data_type_memsize(VALUE obj)
{
- if (RTYPEDDATA_P(obj)) {
+ size_t size = 0;
+ const void *ptr = RTYPEDDATA_GET_DATA(obj);
+
+ if (ptr) {
+ if (RTYPEDDATA_EMBEDDABLE_P(obj) && !RTYPEDDATA_EMBEDDED_P(obj)) {
+ size += ruby_xmalloc_usable_size((void *)ptr);
+ }
+
const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
- const void *ptr = RTYPEDDATA_DATA(obj);
- if (ptr && type->function.dsize) {
- return type->function.dsize(ptr);
+ if (type->function.dsize) {
+ size += type->function.dsize(ptr);
}
}
- return 0;
+
+ return size;
}
const char *
rb_objspace_data_type_name(VALUE obj)
{
- if (RTYPEDDATA_P(obj)) {
- return RTYPEDDATA_TYPE(obj)->wrap_struct_name;
- }
- else {
- return 0;
- }
+ return RTYPEDDATA_TYPE(obj)->wrap_struct_name;
}
-static int
-ptr_in_page_body_p(const void *ptr, const void *memb)
+void
+rb_gc_declare_weak_references(VALUE obj)
{
- struct heap_page *page = *(struct heap_page **)memb;
- uintptr_t p_body = (uintptr_t)GET_PAGE_BODY(page->start);
-
- if ((uintptr_t)ptr >= p_body) {
- return (uintptr_t)ptr < (p_body + HEAP_PAGE_SIZE) ? 0 : 1;
- }
- else {
- return -1;
- }
+ rb_gc_impl_declare_weak_references(rb_gc_get_objspace(), obj);
}
-PUREFUNC(static inline struct heap_page * heap_page_for_ptr(rb_objspace_t *objspace, uintptr_t ptr);)
-static inline struct heap_page *
-heap_page_for_ptr(rb_objspace_t *objspace, uintptr_t ptr)
+bool
+rb_gc_handle_weak_references_alive_p(VALUE obj)
{
- struct heap_page **res;
-
- if (ptr < (uintptr_t)heap_pages_lomem ||
- ptr > (uintptr_t)heap_pages_himem) {
- return NULL;
- }
-
- res = bsearch((void *)ptr, heap_pages_sorted,
- (size_t)heap_allocated_pages, sizeof(struct heap_page *),
- ptr_in_page_body_p);
+ if (SPECIAL_CONST_P(obj)) return true;
- if (res) {
- return *res;
- }
- else {
- return NULL;
- }
+ return rb_gc_impl_handle_weak_references_alive_p(rb_gc_get_objspace(), obj);
}
-PUREFUNC(static inline int is_pointer_to_heap(rb_objspace_t *objspace, void *ptr);)
-static inline int
-is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
+void
+rb_gc_handle_weak_references(VALUE obj)
{
- register uintptr_t p = (uintptr_t)ptr;
- register struct heap_page *page;
-
- RB_DEBUG_COUNTER_INC(gc_isptr_trial);
-
- if (p < heap_pages_lomem || p > heap_pages_himem) return FALSE;
- RB_DEBUG_COUNTER_INC(gc_isptr_range);
-
- if (p % BASE_SLOT_SIZE != 0) return FALSE;
- RB_DEBUG_COUNTER_INC(gc_isptr_align);
+ switch (BUILTIN_TYPE(obj)) {
+ case T_DATA:
+ {
+ const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
- page = heap_page_for_ptr(objspace, (uintptr_t)ptr);
- if (page) {
- RB_DEBUG_COUNTER_INC(gc_isptr_maybe);
- if (page->flags.in_tomb) {
- return FALSE;
+ if (type->function.handle_weak_references) {
+ (type->function.handle_weak_references)(RTYPEDDATA_GET_DATA(obj));
+ }
+ else {
+ rb_bug(
+ "rb_gc_handle_weak_references: TypedData %s does not implement handle_weak_references",
+ RTYPEDDATA_TYPE(obj)->wrap_struct_name
+ );
+ }
}
- else {
- if (p < page->start) return FALSE;
- if (p >= page->start + (page->total_slots * page->slot_size)) return FALSE;
- if ((NUM_IN_PAGE(p) * BASE_SLOT_SIZE) % page->slot_size != 0) return FALSE;
+ break;
- return TRUE;
+ case T_IMEMO: {
+ switch (imemo_type(obj)) {
+ case imemo_callcache: {
+ struct rb_callcache *cc = (struct rb_callcache *)obj;
+ if (cc->klass != Qundef &&
+ (!rb_gc_handle_weak_references_alive_p(cc->klass) ||
+ !rb_gc_handle_weak_references_alive_p((VALUE)cc->cme_))) {
+ vm_cc_invalidate(cc);
+ }
+ break;
+ }
+ case imemo_subclasses: {
+ struct rb_subclasses *subs = (struct rb_subclasses *)obj;
+ VALUE *entries = rb_imemo_subclasses_entries(obj);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ if (entries[i] && !rb_gc_handle_weak_references_alive_p(entries[i])) {
+ entries[i] = 0;
+ }
+ }
+ break;
+ }
+ default:
+ rb_bug("rb_gc_handle_weak_references: unexpected imemo type");
}
+
+ break;
+ }
+ default:
+ rb_bug("rb_gc_handle_weak_references: type not supported\n");
}
- return FALSE;
}
-static enum rb_id_table_iterator_result
-free_const_entry_i(VALUE value, void *data)
+static inline bool
+rb_gc_imemo_needs_cleanup_p(VALUE obj)
{
- rb_const_entry_t *ce = (rb_const_entry_t *)value;
- xfree(ce);
- return ID_TABLE_CONTINUE;
-}
+ switch (imemo_type(obj)) {
+ case imemo_constcache:
+ case imemo_cref:
+ case imemo_ifunc:
+ case imemo_memo:
+ case imemo_svar:
+ case imemo_callcache:
+ case imemo_throw_data:
+ case imemo_cvar_entry:
+ return false;
-void
-rb_free_const_table(struct rb_id_table *tbl)
-{
- rb_id_table_foreach_values(tbl, free_const_entry_i, 0);
- rb_id_table_free(tbl);
-}
+ case imemo_env:
+ case imemo_ment:
+ case imemo_iseq:
+ case imemo_callinfo:
+ case imemo_cdhash:
+ return true;
-// alive: if false, target pointers can be freed already.
-// To check it, we need objspace parameter.
-static void
-vm_ccs_free(struct rb_class_cc_entries *ccs, int alive, rb_objspace_t *objspace, VALUE klass)
-{
- if (ccs->entries) {
- for (int i=0; i<ccs->len; i++) {
- const struct rb_callcache *cc = ccs->entries[i].cc;
- if (!alive) {
- void *ptr = asan_unpoison_object_temporary((VALUE)cc);
- // ccs can be free'ed.
- if (is_pointer_to_heap(objspace, (void *)cc) &&
- IMEMO_TYPE_P(cc, imemo_callcache) &&
- cc->klass == klass) {
- // OK. maybe target cc.
- }
- else {
- if (ptr) {
- asan_poison_object((VALUE)cc);
- }
- continue;
- }
- if (ptr) {
- asan_poison_object((VALUE)cc);
- }
- }
- vm_cc_invalidate(cc);
- }
- ruby_xfree(ccs->entries);
+ case imemo_subclasses:
+ return FL_TEST_RAW(obj, IMEMO_SUBCLASSES_HEAP);
+
+ case imemo_tmpbuf:
+ return ((rb_imemo_tmpbuf_t *)obj)->ptr != NULL;
+
+ case imemo_fields:
+ return FL_TEST_RAW(obj, OBJ_FIELD_HEAP) || (id2ref_tbl && rb_obj_shape_has_id(obj));
}
- ruby_xfree(ccs);
+ UNREACHABLE_RETURN(true);
}
-void
-rb_vm_ccs_free(struct rb_class_cc_entries *ccs)
+/*
+ * Returns true if the object requires a full rb_gc_obj_free() call during sweep,
+ * false if it can be freed quickly without calling destructors or cleanup.
+ *
+ * Objects that return false are:
+ * - Simple embedded objects without external allocations
+ * - Objects without finalizers
+ * - Objects without object IDs registered in id2ref
+ * - Objects without generic instance variables
+ *
+ * This is used by the GC sweep fast path to avoid function call overhead
+ * for the majority of simple objects.
+ */
+bool
+rb_gc_obj_needs_cleanup_p(VALUE obj)
{
- RB_DEBUG_COUNTER_INC(ccs_free);
- vm_ccs_free(ccs, TRUE, NULL, Qundef);
-}
+ VALUE flags = RBASIC(obj)->flags;
-struct cc_tbl_i_data {
- rb_objspace_t *objspace;
- VALUE klass;
- bool alive;
-};
+ if (flags & FL_FINALIZE) return true;
-static enum rb_id_table_iterator_result
-cc_table_mark_i(ID id, VALUE ccs_ptr, void *data_ptr)
-{
- struct cc_tbl_i_data *data = data_ptr;
- struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_ptr;
- VM_ASSERT(vm_ccs_p(ccs));
- VM_ASSERT(id == ccs->cme->called_id);
+ switch (flags & RUBY_T_MASK) {
+ case T_IMEMO:
+ return rb_gc_imemo_needs_cleanup_p(obj);
- if (METHOD_ENTRY_INVALIDATED(ccs->cme)) {
- rb_vm_ccs_free(ccs);
- return ID_TABLE_DELETE;
+ case T_DATA:
+ case T_OBJECT:
+ case T_STRING:
+ case T_ARRAY:
+ case T_HASH:
+ case T_BIGNUM:
+ case T_STRUCT:
+ case T_FLOAT:
+ case T_RATIONAL:
+ case T_COMPLEX:
+ case T_MATCH:
+ break;
+
+ case T_FILE:
+ case T_SYMBOL:
+ case T_CLASS:
+ case T_ICLASS:
+ case T_MODULE:
+ case T_REGEXP:
+ return true;
}
- else {
- gc_mark(data->objspace, (VALUE)ccs->cme);
- for (int i=0; i<ccs->len; i++) {
- VM_ASSERT(data->klass == ccs->entries[i].cc->klass);
- VM_ASSERT(vm_cc_check_cme(ccs->entries[i].cc, ccs->cme));
+ shape_id_t shape_id = RBASIC_SHAPE_ID(obj);
+ if (id2ref_tbl && rb_shape_has_object_id(shape_id)) return true;
+
+ switch (flags & RUBY_T_MASK) {
+ case T_OBJECT:
+ if (flags & ROBJECT_HEAP) return true;
+ return false;
- gc_mark(data->objspace, (VALUE)ccs->entries[i].ci);
- gc_mark(data->objspace, (VALUE)ccs->entries[i].cc);
+ case T_DATA:
+ {
+ uintptr_t type = (uintptr_t)RTYPEDDATA(obj)->type;
+ if (type & TYPED_DATA_EMBEDDED) {
+ RUBY_DATA_FUNC dfree = ((const rb_data_type_t *)(type & TYPED_DATA_PTR_MASK))->function.dfree;
+ if (dfree == RUBY_NEVER_FREE || dfree == RUBY_TYPED_DEFAULT_FREE) {
+ return false;
+ }
+ }
}
- return ID_TABLE_CONTINUE;
- }
-}
+ return true;
-static void
-cc_table_mark(rb_objspace_t *objspace, VALUE klass)
-{
- struct rb_id_table *cc_tbl = RCLASS_CC_TBL(klass);
- if (cc_tbl) {
- struct cc_tbl_i_data data = {
- .objspace = objspace,
- .klass = klass,
- };
- rb_id_table_foreach(cc_tbl, cc_table_mark_i, &data);
- }
-}
+ case T_STRING:
+ if (flags & (RSTRING_NOEMBED | RSTRING_FSTR)) return true;
+ return rb_shape_has_fields(shape_id);
-static enum rb_id_table_iterator_result
-cc_table_free_i(VALUE ccs_ptr, void *data_ptr)
-{
- struct cc_tbl_i_data *data = data_ptr;
- struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_ptr;
- VM_ASSERT(vm_ccs_p(ccs));
- vm_ccs_free(ccs, data->alive, data->objspace, data->klass);
- return ID_TABLE_CONTINUE;
-}
+ case T_ARRAY:
+ if (!(flags & RARRAY_EMBED_FLAG)) return true;
+ return rb_shape_has_fields(shape_id);
-static void
-cc_table_free(rb_objspace_t *objspace, VALUE klass, bool alive)
-{
- struct rb_id_table *cc_tbl = RCLASS_CC_TBL(klass);
+ case T_HASH:
+ if (flags & RHASH_ST_TABLE_FLAG) return true;
+ return rb_shape_has_fields(shape_id);
- if (cc_tbl) {
- struct cc_tbl_i_data data = {
- .objspace = objspace,
- .klass = klass,
- .alive = alive,
- };
- rb_id_table_foreach_values(cc_tbl, cc_table_free_i, &data);
- rb_id_table_free(cc_tbl);
- }
-}
+ case T_MATCH:
+ if ((flags & (RMATCH_ONIG | RMATCH_OFFSETS_EXTERNAL)) || USE_DEBUG_COUNTER) return true;
+ return rb_shape_has_fields(shape_id);
-static enum rb_id_table_iterator_result
-cvar_table_free_i(VALUE value, void * ctx)
-{
- xfree((void *) value);
- return ID_TABLE_CONTINUE;
-}
+ case T_BIGNUM:
+ if (!(flags & BIGNUM_EMBED_FLAG)) return true;
+ return rb_shape_has_fields(shape_id);
-void
-rb_cc_table_free(VALUE klass)
-{
- cc_table_free(&rb_objspace, klass, TRUE);
-}
+ case T_STRUCT:
+ if (!(flags & RSTRUCT_EMBED_LEN_MASK)) return true;
+ if (flags & RSTRUCT_GEN_FIELDS) return rb_shape_has_fields(shape_id);
+ return false;
-static inline void
-make_zombie(rb_objspace_t *objspace, VALUE obj, void (*dfree)(void *), void *data)
-{
- struct RZombie *zombie = RZOMBIE(obj);
- zombie->basic.flags = T_ZOMBIE | (zombie->basic.flags & FL_SEEN_OBJ_ID);
- zombie->dfree = dfree;
- zombie->data = data;
- VALUE prev, next = heap_pages_deferred_final;
- do {
- zombie->next = prev = next;
- next = RUBY_ATOMIC_VALUE_CAS(heap_pages_deferred_final, prev, obj);
- } while (next != prev);
+ case T_FLOAT:
+ case T_RATIONAL:
+ case T_COMPLEX:
+ return rb_shape_has_fields(shape_id);
- struct heap_page *page = GET_HEAP_PAGE(obj);
- page->final_slots++;
- heap_pages_final_slots++;
+ default:
+ UNREACHABLE_RETURN(true);
+ }
}
-static inline void
-make_io_zombie(rb_objspace_t *objspace, VALUE obj)
+static void
+io_fptr_finalize(void *fptr)
{
- rb_io_t *fptr = RANY(obj)->as.file.fptr;
- make_zombie(objspace, obj, rb_io_fptr_finalize_internal, fptr);
+ rb_io_fptr_finalize((struct rb_io *)fptr);
}
-static void
-obj_free_object_id(rb_objspace_t *objspace, VALUE obj)
+static inline void
+make_io_zombie(void *objspace, VALUE obj)
{
- ASSERT_vm_locking();
- st_data_t o = (st_data_t)obj, id;
-
- GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
- FL_UNSET(obj, FL_SEEN_OBJ_ID);
-
- if (st_delete(objspace->obj_to_id_tbl, &o, &id)) {
- GC_ASSERT(id);
- st_delete(objspace->id_to_obj_tbl, &id, NULL);
- }
- else {
- rb_bug("Object ID seen, but not in mapping table: %s\n", obj_info(obj));
- }
+ rb_io_t *fptr = RFILE(obj)->fptr;
+ rb_gc_impl_make_zombie(objspace, obj, io_fptr_finalize, fptr);
}
static bool
-rb_data_free(rb_objspace_t *objspace, VALUE obj)
+rb_data_free(void *objspace, VALUE obj)
{
- if (DATA_PTR(obj)) {
+ void *data = RTYPEDDATA_GET_DATA(obj);
+ if (data) {
int free_immediately = false;
void (*dfree)(void *);
- void *data = DATA_PTR(obj);
- if (RTYPEDDATA_P(obj)) {
- free_immediately = (RANY(obj)->as.typeddata.type->flags & RUBY_TYPED_FREE_IMMEDIATELY) != 0;
- dfree = RANY(obj)->as.typeddata.type->function.dfree;
- }
- else {
- dfree = RANY(obj)->as.data.dfree;
- }
+ free_immediately = (RTYPEDDATA_TYPE(obj)->flags & RUBY_TYPED_FREE_IMMEDIATELY) != 0;
+ dfree = RTYPEDDATA_TYPE(obj)->function.dfree;
if (dfree) {
if (dfree == RUBY_DEFAULT_FREE) {
- xfree(data);
- RB_DEBUG_COUNTER_INC(obj_data_xfree);
+ if (!RTYPEDDATA_EMBEDDED_P(obj)) {
+ xfree(data);
+ RB_DEBUG_COUNTER_INC(obj_data_xfree);
+ }
}
else if (free_immediately) {
(*dfree)(data);
+ if (RTYPEDDATA_EMBEDDABLE_P(obj) && !RTYPEDDATA_EMBEDDED_P(obj)) {
+ xfree(data);
+ }
+
RB_DEBUG_COUNTER_INC(obj_data_imm_free);
}
else {
+ rb_gc_impl_make_zombie(objspace, obj, dfree, data);
RB_DEBUG_COUNTER_INC(obj_data_zombie);
- make_zombie(objspace, obj, dfree, data);
- return false;
+ return FALSE;
}
}
else {
@@ -3469,13 +1493,33 @@ rb_data_free(rb_objspace_t *objspace, VALUE obj)
return true;
}
-static int
-obj_free(rb_objspace_t *objspace, VALUE obj)
+struct classext_foreach_args {
+ VALUE klass;
+ rb_objspace_t *objspace; // used for update_*
+};
+
+static void
+classext_free(rb_classext_t *ext, bool is_prime, VALUE box_value, void *arg)
{
- RB_DEBUG_COUNTER_INC(obj_free);
- // RUBY_DEBUG_LOG("obj:%p (%s)", (void *)obj, obj_type_name(obj));
+ struct classext_foreach_args *args = (struct classext_foreach_args *)arg;
+
+ rb_class_classext_free(args->klass, ext, is_prime);
+}
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_FREEOBJ, obj);
+static void
+classext_iclass_free(rb_classext_t *ext, bool is_prime, VALUE box_value, void *arg)
+{
+ struct classext_foreach_args *args = (struct classext_foreach_args *)arg;
+
+ rb_iclass_classext_free(args->klass, ext, is_prime);
+}
+
+bool
+rb_gc_obj_free(void *objspace, VALUE obj)
+{
+ struct classext_foreach_args args;
+
+ RB_DEBUG_COUNTER_INC(obj_free);
switch (BUILTIN_TYPE(obj)) {
case T_NIL:
@@ -3488,69 +1532,32 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
}
- if (FL_TEST(obj, FL_EXIVAR)) {
- rb_free_generic_ivar((VALUE)obj);
- FL_UNSET(obj, FL_EXIVAR);
- }
-
- if (FL_TEST(obj, FL_SEEN_OBJ_ID) && !FL_TEST(obj, FL_FINALIZE)) {
- obj_free_object_id(objspace, obj);
- }
-
- if (RVALUE_WB_UNPROTECTED(obj)) CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
-
-#if RGENGC_CHECK_MODE
-#define CHECK(x) if (x(obj) != FALSE) rb_bug("obj_free: " #x "(%s) != FALSE", obj_info(obj))
- CHECK(RVALUE_WB_UNPROTECTED);
- CHECK(RVALUE_MARKED);
- CHECK(RVALUE_MARKING);
- CHECK(RVALUE_UNCOLLECTIBLE);
-#undef CHECK
-#endif
-
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
- if (rb_shape_obj_too_complex(obj)) {
- RB_DEBUG_COUNTER_INC(obj_obj_too_complex);
- rb_id_table_free(ROBJECT_IV_HASH(obj));
- }
- else if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
- RB_DEBUG_COUNTER_INC(obj_obj_embed);
- }
- else if (ROBJ_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_obj_transient);
+ if (FL_TEST_RAW(obj, ROBJECT_HEAP)) {
+ if (rb_obj_shape_complex_p(obj)) {
+ RB_DEBUG_COUNTER_INC(obj_obj_complex);
+ st_free_table(ROBJECT_FIELDS_HASH(obj));
+ }
+ else {
+ SIZED_FREE_N(ROBJECT(obj)->as.heap.fields, ROBJECT_FIELDS_CAPACITY(obj));
+ RB_DEBUG_COUNTER_INC(obj_obj_ptr);
+ }
}
else {
- xfree(RANY(obj)->as.object.as.heap.ivptr);
- RB_DEBUG_COUNTER_INC(obj_obj_ptr);
+ RB_DEBUG_COUNTER_INC(obj_obj_embed);
}
break;
case T_MODULE:
case T_CLASS:
- rb_id_table_free(RCLASS_M_TBL(obj));
- cc_table_free(objspace, obj, FALSE);
- if (RCLASS_IVPTR(obj)) {
- xfree(RCLASS_IVPTR(obj));
- }
- if (RCLASS_CONST_TBL(obj)) {
- rb_free_const_table(RCLASS_CONST_TBL(obj));
- }
- if (RCLASS_CVC_TBL(obj)) {
- rb_id_table_foreach_values(RCLASS_CVC_TBL(obj), cvar_table_free_i, NULL);
- rb_id_table_free(RCLASS_CVC_TBL(obj));
- }
- rb_class_remove_subclass_head(obj);
- rb_class_remove_from_module_subclasses(obj);
- rb_class_remove_from_super_subclasses(obj);
- if (FL_TEST_RAW(obj, RCLASS_SUPERCLASSES_INCLUDE_SELF)) {
- xfree(RCLASS_SUPERCLASSES(obj));
- }
-
-#if !RCLASS_EXT_EMBEDDED
- if (RCLASS_EXT(obj))
- xfree(RCLASS_EXT(obj));
+#if USE_ZJIT
+ rb_zjit_klass_free(obj);
#endif
-
+ args.klass = obj;
+ rb_class_classext_foreach(obj, classext_free, (void *)&args);
+ if (RCLASS_CLASSEXT_TBL(obj)) {
+ st_free_table(RCLASS_CLASSEXT_TBL(obj));
+ }
(void)RB_DEBUG_COUNTER_INC_IF(obj_module_ptr, BUILTIN_TYPE(obj) == T_MODULE);
(void)RB_DEBUG_COUNTER_INC_IF(obj_class_ptr, BUILTIN_TYPE(obj) == T_CLASS);
break;
@@ -3601,26 +1608,12 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
RB_DEBUG_COUNTER_INC(obj_hash_st);
}
#endif
- if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
- struct ar_table_struct *tab = RHASH(obj)->as.ar;
- if (tab) {
- if (RHASH_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_hash_transient);
- }
- else {
- ruby_xfree(tab);
- }
- }
- }
- else {
- GC_ASSERT(RHASH_ST_TABLE_P(obj));
- st_free_table(RHASH(obj)->as.st);
- }
+ rb_hash_free(obj);
break;
case T_REGEXP:
- if (RANY(obj)->as.regexp.ptr) {
- onig_free(RANY(obj)->as.regexp.ptr);
+ if (RREGEXP(obj)->ptr) {
+ onig_free(RREGEXP(obj)->ptr);
RB_DEBUG_COUNTER_INC(obj_regexp_ptr);
}
break;
@@ -3628,32 +1621,33 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (!rb_data_free(objspace, obj)) return false;
break;
case T_MATCH:
- if (RANY(obj)->as.match.rmatch) {
- struct rmatch *rm = RANY(obj)->as.match.rmatch;
+ {
+ struct RMatch *rm = RMATCH(obj);
#if USE_DEBUG_COUNTER
- if (rm->regs.num_regs >= 8) {
+ if (rm->num_regs >= 8) {
RB_DEBUG_COUNTER_INC(obj_match_ge8);
}
- else if (rm->regs.num_regs >= 4) {
+ else if (rm->num_regs >= 4) {
RB_DEBUG_COUNTER_INC(obj_match_ge4);
}
- else if (rm->regs.num_regs >= 1) {
+ else if (rm->num_regs >= 1) {
RB_DEBUG_COUNTER_INC(obj_match_under4);
}
#endif
- onig_region_free(&rm->regs, 0);
- if (rm->char_offset)
- xfree(rm->char_offset);
- xfree(rm);
+ if (FL_TEST_RAW(obj, RMATCH_ONIG)) {
+ onig_region_free(&rm->as.onig, 0);
+ }
+ SIZED_FREE_N(rm->char_offset, rm->char_offset_num_allocated);
RB_DEBUG_COUNTER_INC(obj_match_ptr);
}
break;
case T_FILE:
- if (RANY(obj)->as.file.fptr) {
- make_io_zombie(objspace, obj);
+ if (RFILE(obj)->fptr) {
+ bool closed = rb_io_fptr_finalize_closed(RFILE(obj)->fptr);
+ if (!closed) make_io_zombie(objspace, obj);
RB_DEBUG_COUNTER_INC(obj_file_ptr);
- return FALSE;
+ return closed;
}
break;
case T_RATIONAL:
@@ -3665,21 +1659,12 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_MOVED:
break;
case T_ICLASS:
- /* Basically , T_ICLASS shares table with the module */
- if (RICLASS_OWNS_M_TBL_P(obj)) {
- /* Method table is not shared for origin iclasses of classes */
- rb_id_table_free(RCLASS_M_TBL(obj));
- }
- if (RCLASS_CALLABLE_M_TBL(obj) != NULL) {
- rb_id_table_free(RCLASS_CALLABLE_M_TBL(obj));
+ args.klass = obj;
+
+ rb_class_classext_foreach(obj, classext_iclass_free, (void *)&args);
+ if (RCLASS_CLASSEXT_TBL(obj)) {
+ st_free_table(RCLASS_CLASSEXT_TBL(obj));
}
- rb_class_remove_subclass_head(obj);
- cc_table_free(objspace, obj, FALSE);
- rb_class_remove_from_module_subclasses(obj);
- rb_class_remove_from_super_subclasses(obj);
-#if !USE_RVARGC
- xfree(RCLASS_EXT(obj));
-#endif
RB_DEBUG_COUNTER_INC(obj_iclass_ptr);
break;
@@ -3690,7 +1675,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_BIGNUM:
if (!BIGNUM_EMBED_P(obj) && BIGNUM_DIGITS(obj)) {
- xfree(BIGNUM_DIGITS(obj));
+ SIZED_FREE_N(BIGNUM_DIGITS(obj), BIGNUM_LEN(obj));
RB_DEBUG_COUNTER_INC(obj_bignum_ptr);
}
else {
@@ -3704,85 +1689,30 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_STRUCT:
if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) ||
- RANY(obj)->as.rstruct.as.heap.ptr == NULL) {
+ RSTRUCT(obj)->as.heap.ptr == NULL) {
RB_DEBUG_COUNTER_INC(obj_struct_embed);
}
- else if (RSTRUCT_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_struct_transient);
- }
else {
- xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
+ SIZED_FREE_N(RSTRUCT(obj)->as.heap.ptr, RSTRUCT(obj)->as.heap.len);
RB_DEBUG_COUNTER_INC(obj_struct_ptr);
}
break;
case T_SYMBOL:
- {
- rb_gc_free_dsymbol(obj);
- RB_DEBUG_COUNTER_INC(obj_symbol);
- }
+ RB_DEBUG_COUNTER_INC(obj_symbol);
break;
case T_IMEMO:
- switch (imemo_type(obj)) {
- case imemo_ment:
- rb_free_method_entry(&RANY(obj)->as.imemo.ment);
- RB_DEBUG_COUNTER_INC(obj_imemo_ment);
- break;
- case imemo_iseq:
- rb_iseq_free(&RANY(obj)->as.imemo.iseq);
- RB_DEBUG_COUNTER_INC(obj_imemo_iseq);
- break;
- case imemo_env:
- GC_ASSERT(VM_ENV_ESCAPED_P(RANY(obj)->as.imemo.env.ep));
- xfree((VALUE *)RANY(obj)->as.imemo.env.env);
- RB_DEBUG_COUNTER_INC(obj_imemo_env);
- break;
- case imemo_tmpbuf:
- xfree(RANY(obj)->as.imemo.alloc.ptr);
- RB_DEBUG_COUNTER_INC(obj_imemo_tmpbuf);
- break;
- case imemo_ast:
- rb_ast_free(&RANY(obj)->as.imemo.ast);
- RB_DEBUG_COUNTER_INC(obj_imemo_ast);
- break;
- case imemo_cref:
- RB_DEBUG_COUNTER_INC(obj_imemo_cref);
- break;
- case imemo_svar:
- RB_DEBUG_COUNTER_INC(obj_imemo_svar);
- break;
- case imemo_throw_data:
- RB_DEBUG_COUNTER_INC(obj_imemo_throw_data);
- break;
- case imemo_ifunc:
- RB_DEBUG_COUNTER_INC(obj_imemo_ifunc);
- break;
- case imemo_memo:
- RB_DEBUG_COUNTER_INC(obj_imemo_memo);
- break;
- case imemo_parser_strterm:
- RB_DEBUG_COUNTER_INC(obj_imemo_parser_strterm);
- break;
- case imemo_callinfo:
- RB_DEBUG_COUNTER_INC(obj_imemo_callinfo);
- break;
- case imemo_callcache:
- RB_DEBUG_COUNTER_INC(obj_imemo_callcache);
- break;
- case imemo_constcache:
- RB_DEBUG_COUNTER_INC(obj_imemo_constcache);
- break;
- }
- return TRUE;
+ rb_imemo_free((VALUE)obj);
+ break;
default:
rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE,
BUILTIN_TYPE(obj), (void*)obj, RBASIC(obj)->flags);
}
- if (FL_TEST(obj, FL_FINALIZE)) {
- make_zombie(objspace, obj, 0, 0);
+ if (FL_TEST_RAW(obj, FL_FINALIZE)) {
+ rb_gc_impl_make_zombie(objspace, obj, 0, 0);
return FALSE;
}
else {
@@ -3790,264 +1720,18 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
}
-
-#define OBJ_ID_INCREMENT (sizeof(RVALUE) / 2)
-#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT * 2)
-
-static int
-object_id_cmp(st_data_t x, st_data_t y)
-{
- if (RB_BIGNUM_TYPE_P(x)) {
- return !rb_big_eql(x, y);
- }
- else {
- return x != y;
- }
-}
-
-static st_index_t
-object_id_hash(st_data_t n)
-{
- if (RB_BIGNUM_TYPE_P(n)) {
- return FIX2LONG(rb_big_hash(n));
- }
- else {
- return st_numhash(n);
- }
-}
-static const struct st_hash_type object_id_hash_type = {
- object_id_cmp,
- object_id_hash,
-};
-
-void
-Init_heap(void)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
-#if defined(INIT_HEAP_PAGE_ALLOC_USE_MMAP)
- /* Need to determine if we can use mmap at runtime. */
- heap_page_alloc_use_mmap = INIT_HEAP_PAGE_ALLOC_USE_MMAP;
-#endif
-
- objspace->next_object_id = INT2FIX(OBJ_ID_INITIAL);
- objspace->id_to_obj_tbl = st_init_table(&object_id_hash_type);
- objspace->obj_to_id_tbl = st_init_numtable();
-
-#if RGENGC_ESTIMATE_OLDMALLOC
- objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
-#endif
-
- heap_add_pages(objspace, &size_pools[0], SIZE_POOL_EDEN_HEAP(&size_pools[0]), gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
-
- /* Give other size pools allocatable pages. */
- for (int i = 1; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_pool->allocatable_pages = gc_params.heap_init_slots * multiple / HEAP_PAGE_OBJ_LIMIT;
- }
- heap_pages_expand_sorted(objspace);
-
- init_mark_stack(&objspace->mark_stack);
-
- objspace->profile.invoke_time = getrusage_time();
- finalizer_table = st_init_numtable();
-}
-
void
-Init_gc_stress(void)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- gc_stress_set(objspace, ruby_initial_gc_stress);
-}
-
-typedef int each_obj_callback(void *, void *, size_t, void *);
-
-static void objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected);
-static void objspace_reachable_objects_from_root(rb_objspace_t *, void (func)(const char *, VALUE, void *), void *);
-
-struct each_obj_data {
- rb_objspace_t *objspace;
- bool reenable_incremental;
-
- each_obj_callback *callback;
- void *data;
-
- struct heap_page **pages[SIZE_POOL_COUNT];
- size_t pages_counts[SIZE_POOL_COUNT];
-};
-
-static VALUE
-objspace_each_objects_ensure(VALUE arg)
-{
- struct each_obj_data *data = (struct each_obj_data *)arg;
- rb_objspace_t *objspace = data->objspace;
-
- /* Reenable incremental GC */
- if (data->reenable_incremental) {
- objspace->flags.dont_incremental = FALSE;
- }
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- struct heap_page **pages = data->pages[i];
- /* pages could be NULL if an error was raised during setup (e.g.
- * malloc failed due to out of memory). */
- if (pages) {
- free(pages);
- }
- }
-
- return Qnil;
-}
-
-static VALUE
-objspace_each_objects_try(VALUE arg)
-{
- struct each_obj_data *data = (struct each_obj_data *)arg;
- rb_objspace_t *objspace = data->objspace;
-
- /* Copy pages from all size_pools to their respective buffers. */
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- size_t size = size_mul_or_raise(SIZE_POOL_EDEN_HEAP(size_pool)->total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
-
- struct heap_page **pages = malloc(size);
- if (!pages) rb_memerror();
-
- /* Set up pages buffer by iterating over all pages in the current eden
- * heap. This will be a snapshot of the state of the heap before we
- * call the callback over each page that exists in this buffer. Thus it
- * is safe for the callback to allocate objects without possibly entering
- * an infinite loop. */
- struct heap_page *page = 0;
- size_t pages_count = 0;
- ccan_list_for_each(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, page, page_node) {
- pages[pages_count] = page;
- pages_count++;
- }
- data->pages[i] = pages;
- data->pages_counts[i] = pages_count;
- GC_ASSERT(pages_count == SIZE_POOL_EDEN_HEAP(size_pool)->total_pages);
- }
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- size_t pages_count = data->pages_counts[i];
- struct heap_page **pages = data->pages[i];
-
- struct heap_page *page = ccan_list_top(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, struct heap_page, page_node);
- for (size_t i = 0; i < pages_count; i++) {
- /* If we have reached the end of the linked list then there are no
- * more pages, so break. */
- if (page == NULL) break;
-
- /* If this page does not match the one in the buffer, then move to
- * the next page in the buffer. */
- if (pages[i] != page) continue;
-
- uintptr_t pstart = (uintptr_t)page->start;
- uintptr_t pend = pstart + (page->total_slots * size_pool->slot_size);
-
- if (!__asan_region_is_poisoned((void *)pstart, pend - pstart) &&
- (*data->callback)((void *)pstart, (void *)pend, size_pool->slot_size, data->data)) {
- break;
- }
-
- page = ccan_list_next(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, page, page_node);
- }
- }
-
- return Qnil;
-}
-
-/*
- * rb_objspace_each_objects() is special C API to walk through
- * Ruby object space. This C API is too difficult to use it.
- * To be frank, you should not use it. Or you need to read the
- * source code of this function and understand what this function does.
- *
- * 'callback' will be called several times (the number of heap page,
- * at current implementation) with:
- * vstart: a pointer to the first living object of the heap_page.
- * vend: a pointer to next to the valid heap_page area.
- * stride: a distance to next VALUE.
- *
- * If callback() returns non-zero, the iteration will be stopped.
- *
- * This is a sample callback code to iterate liveness objects:
- *
- * int
- * sample_callback(void *vstart, void *vend, int stride, void *data) {
- * VALUE v = (VALUE)vstart;
- * for (; v != (VALUE)vend; v += stride) {
- * if (RBASIC(v)->flags) { // liveness check
- * // do something with live object 'v'
- * }
- * return 0; // continue to iteration
- * }
- *
- * Note: 'vstart' is not a top of heap_page. This point the first
- * living object to grasp at least one object to avoid GC issue.
- * This means that you can not walk through all Ruby object page
- * including freed object page.
- *
- * Note: On this implementation, 'stride' is the same as sizeof(RVALUE).
- * However, there are possibilities to pass variable values with
- * 'stride' with some reasons. You must use stride instead of
- * use some constant value in the iteration.
- */
-void
-rb_objspace_each_objects(each_obj_callback *callback, void *data)
-{
- objspace_each_objects(&rb_objspace, callback, data, TRUE);
-}
-
-static void
-objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected)
-{
- /* Disable incremental GC */
- bool reenable_incremental = FALSE;
- if (protected) {
- reenable_incremental = !objspace->flags.dont_incremental;
-
- gc_rest(objspace);
- objspace->flags.dont_incremental = TRUE;
- }
-
- struct each_obj_data each_obj_data = {
- .objspace = objspace,
- .reenable_incremental = reenable_incremental,
-
- .callback = callback,
- .data = data,
-
- .pages = {NULL},
- .pages_counts = {0},
- };
- rb_ensure(objspace_each_objects_try, (VALUE)&each_obj_data,
- objspace_each_objects_ensure, (VALUE)&each_obj_data);
-}
-
-void
-rb_objspace_each_objects_without_setup(each_obj_callback *callback, void *data)
+rb_objspace_set_event_hook(const rb_event_flag_t event)
{
- objspace_each_objects(&rb_objspace, callback, data, FALSE);
+ rb_gc_impl_set_event_hook(rb_gc_get_objspace(), event);
}
-struct os_each_struct {
- size_t num;
- VALUE of;
-};
-
static int
internal_object_p(VALUE obj)
{
- RVALUE *p = (RVALUE *)obj;
void *ptr = asan_unpoison_object_temporary(obj);
- bool used_p = p->as.basic.flags;
- if (used_p) {
+ if (RBASIC(obj)->flags) {
switch (BUILTIN_TYPE(obj)) {
case T_NODE:
UNEXPECTED_NODE(internal_object_p);
@@ -4059,18 +1743,21 @@ internal_object_p(VALUE obj)
case T_ZOMBIE:
break;
case T_CLASS:
- if (!p->as.basic.klass) break;
- if (FL_TEST(obj, FL_SINGLETON)) {
+ if (obj == rb_mRubyVMFrozenCore)
+ return 1;
+
+ if (!RBASIC_CLASS(obj)) break;
+ if (RCLASS_SINGLETON_P(obj)) {
return rb_singleton_class_internal_p(obj);
}
return 0;
default:
- if (!p->as.basic.klass) break;
+ if (!RBASIC(obj)->klass) break;
return 0;
}
}
- if (ptr || ! used_p) {
- asan_poison_object(obj);
+ if (ptr || !RBASIC(obj)->flags) {
+ rb_asan_poison_object(obj);
}
return 1;
}
@@ -4081,6 +1768,11 @@ rb_objspace_internal_object_p(VALUE obj)
return internal_object_p(obj);
}
+struct os_each_struct {
+ size_t num;
+ VALUE of;
+};
+
static int
os_obj_of_i(void *vstart, void *vend, size_t stride, void *data)
{
@@ -4121,30 +1813,34 @@ os_obj_of(VALUE of)
* Ruby process. If <i>module</i> is specified, calls the block
* for only those classes or modules that match (or are a subclass of)
* <i>module</i>. Returns the number of objects found. Immediate
- * objects (<code>Fixnum</code>s, <code>Symbol</code>s
- * <code>true</code>, <code>false</code>, and <code>nil</code>) are
- * never returned. In the example below, #each_object returns both
- * the numbers we defined and several constants defined in the Math
- * module.
+ * objects (such as <code>Fixnum</code>s, static <code>Symbol</code>s
+ * <code>true</code>, <code>false</code> and <code>nil</code>) are
+ * never returned.
*
* If no block is given, an enumerator is returned instead.
*
- * a = 102.7
- * b = 95 # Won't be returned
- * c = 12345678987654321
- * count = ObjectSpace.each_object(Numeric) {|x| p x }
+ * Job = Class.new
+ * jobs = [Job.new, Job.new]
+ * count = ObjectSpace.each_object(Job) {|x| p x }
* puts "Total count: #{count}"
*
* <em>produces:</em>
*
- * 12345678987654321
- * 102.7
- * 2.71828182845905
- * 3.14159265358979
- * 2.22044604925031e-16
- * 1.7976931348623157e+308
- * 2.2250738585072e-308
- * Total count: 7
+ * #<Job:0x000000011d6cbbf0>
+ * #<Job:0x000000011d6cbc68>
+ * Total count: 2
+ *
+ * Due to a current Ractor implementation issue, this method does not yield
+ * Ractor-unshareable objects when the process is in multi-Ractor mode. Multi-ractor
+ * mode is enabled when <code>Ractor.new</code> has been called for the first time.
+ * See https://bugs.ruby-lang.org/issues/19387 for more information.
+ *
+ * a = 12345678987654321 # shareable
+ * b = [].freeze # shareable
+ * c = {} # not shareable
+ * ObjectSpace.each_object {|x| x } # yields a, b, and c
+ * Ractor.new {} # enter multi-Ractor mode
+ * ObjectSpace.each_object {|x| x } # does not yield c
*
*/
@@ -4175,11 +1871,10 @@ undefine_final(VALUE os, VALUE obj)
VALUE
rb_undefine_finalizer(VALUE obj)
{
- rb_objspace_t *objspace = &rb_objspace;
- st_data_t data = obj;
rb_check_frozen(obj);
- st_delete(finalizer_table, &data, 0);
- FL_UNSET(obj, FL_FINALIZE);
+
+ rb_gc_impl_undefine_finalizer(rb_gc_get_objspace(), obj);
+
return obj;
}
@@ -4202,104 +1897,76 @@ should_be_finalizable(VALUE obj)
rb_check_frozen(obj);
}
-VALUE
-rb_define_finalizer_no_check(VALUE obj, VALUE block)
+void
+rb_gc_copy_finalizer(VALUE dest, VALUE obj)
{
- rb_objspace_t *objspace = &rb_objspace;
- VALUE table;
- st_data_t data;
-
- RBASIC(obj)->flags |= FL_FINALIZE;
-
- if (st_lookup(finalizer_table, obj, &data)) {
- table = (VALUE)data;
-
- /* avoid duplicate block, table is usually small */
- {
- long len = RARRAY_LEN(table);
- long i;
-
- for (i = 0; i < len; i++) {
- VALUE recv = RARRAY_AREF(table, i);
- if (rb_equal(recv, block)) {
- block = recv;
- goto end;
- }
- }
- }
-
- rb_ary_push(table, block);
- }
- else {
- table = rb_ary_new3(1, block);
- RBASIC_CLEAR_CLASS(table);
- st_add_direct(finalizer_table, obj, table);
- }
- end:
- block = rb_ary_new3(2, INT2FIX(0), block);
- OBJ_FREEZE(block);
- return block;
+ rb_gc_impl_copy_finalizer(rb_gc_get_objspace(), dest, obj);
}
/*
* call-seq:
- * ObjectSpace.define_finalizer(obj, aProc=proc())
+ * ObjectSpace.define_finalizer(obj) {|id| ... } -> array
+ * ObjectSpace.define_finalizer(obj, finalizer) -> array
*
- * Adds <i>aProc</i> as a finalizer, to be called after <i>obj</i>
- * was destroyed. The object ID of the <i>obj</i> will be passed
- * as an argument to <i>aProc</i>. If <i>aProc</i> is a lambda or
- * method, make sure it can be called with a single argument.
+ * Adds a new finalizer for +obj+ that is called when +obj+ is destroyed
+ * by the garbage collector or when Ruby shuts down (which ever comes first).
*
- * The return value is an array <code>[0, aProc]</code>.
+ * With a block given, uses the block as the callback. Without a block given,
+ * uses a callable object +finalizer+ as the callback. The callback is called
+ * when +obj+ is destroyed with a single argument +id+ which is the object
+ * ID of +obj+ (see Object#object_id).
*
- * The two recommended patterns are to either create the finaliser proc
- * in a non-instance method where it can safely capture the needed state,
- * or to use a custom callable object that stores the needed state
- * explicitly as instance variables.
+ * The return value is an array <code>[0, callback]</code>, where +callback+
+ * is a Proc created from the block if one was given or +finalizer+ otherwise.
*
- * class Foo
- * def initialize(data_needed_for_finalization)
- * ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization))
- * end
+ * Note that defining a finalizer in an instance method of the object may prevent
+ * the object from being garbage collected since if the block or +finalizer+ refers
+ * to +obj+ then +obj+ will never be reclaimed by the garbage collector. For example,
+ * the following script demonstrates the issue:
*
- * def self.create_finalizer(data_needed_for_finalization)
- * proc {
- * puts "finalizing #{data_needed_for_finalization}"
- * }
+ * class Foo
+ * def define_final
+ * ObjectSpace.define_finalizer(self) do |id|
+ * puts "Running finalizer for #{id}!"
+ * end
* end
* end
*
- * class Bar
- * class Remover
- * def initialize(data_needed_for_finalization)
- * @data_needed_for_finalization = data_needed_for_finalization
- * end
+ * obj = Foo.new
+ * obj.define_final
*
- * def call(id)
- * puts "finalizing #{@data_needed_for_finalization}"
- * end
+ * There are two patterns to solve this issue:
+ *
+ * - Create the finalizer in a non-instance method so it can safely capture
+ * the needed state:
+ *
+ * class Foo
+ * def define_final
+ * ObjectSpace.define_finalizer(self, self.class.create_finalizer)
* end
*
- * def initialize(data_needed_for_finalization)
- * ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization))
+ * def self.create_finalizer
+ * proc do |id|
+ * puts "Running finalizer for #{id}!"
+ * end
* end
* end
*
- * Note that if your finalizer references the object to be
- * finalized it will never be run on GC, although it will still be
- * run at exit. You will get a warning if you capture the object
- * to be finalized as the receiver of the finalizer.
+ * - Use a callable object:
+ *
+ * class Foo
+ * class Finalizer
+ * def call(id)
+ * puts "Running finalizer for #{id}!"
+ * end
+ * end
*
- * class CapturesSelf
- * def initialize(name)
- * ObjectSpace.define_finalizer(self, proc {
- * # this finalizer will only be run on exit
- * puts "finalizing #{name}"
- * })
+ * def define_final
+ * ObjectSpace.define_finalizer(self, Finalizer.new)
* end
* end
*
- * Also note that finalization can be unpredictable and is never guaranteed
+ * Note that finalization can be unpredictable and is never guaranteed
* to be run except on exit.
*/
@@ -4309,19 +1976,15 @@ define_final(int argc, VALUE *argv, VALUE os)
VALUE obj, block;
rb_scan_args(argc, argv, "11", &obj, &block);
- should_be_finalizable(obj);
if (argc == 1) {
block = rb_block_proc();
}
- else {
- should_be_callable(block);
- }
if (rb_callable_receiver(block) == obj) {
rb_warn("finalizer references object to be finalized");
}
- return rb_define_finalizer_no_check(obj, block);
+ return rb_define_finalizer(obj, block);
}
VALUE
@@ -4329,350 +1992,377 @@ rb_define_finalizer(VALUE obj, VALUE block)
{
should_be_finalizable(obj);
should_be_callable(block);
- return rb_define_finalizer_no_check(obj, block);
+
+ block = rb_gc_impl_define_finalizer(rb_gc_get_objspace(), obj, block);
+
+ block = rb_ary_new3(2, INT2FIX(0), block);
+ OBJ_FREEZE(block);
+ return block;
}
void
-rb_gc_copy_finalizer(VALUE dest, VALUE obj)
+rb_objspace_call_finalizer(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- VALUE table;
- st_data_t data;
-
- if (!FL_TEST(obj, FL_FINALIZE)) return;
- if (st_lookup(finalizer_table, obj, &data)) {
- table = (VALUE)data;
- st_insert(finalizer_table, dest, table);
- }
- FL_SET(dest, FL_FINALIZE);
+ rb_gc_impl_shutdown_call_finalizer(rb_gc_get_objspace());
}
-static VALUE
-run_single_final(VALUE cmd, VALUE objid)
+void
+rb_objspace_free_objects(void *objspace)
{
- return rb_check_funcall(cmd, idCall, 1, &objid);
+ rb_gc_impl_shutdown_free_objects(objspace);
}
-static void
-warn_exception_in_finalizer(rb_execution_context_t *ec, VALUE final)
+int
+rb_objspace_garbage_object_p(VALUE obj)
{
- if (!UNDEF_P(final) && !NIL_P(ruby_verbose)) {
- VALUE errinfo = ec->errinfo;
- rb_warn("Exception in finalizer %+"PRIsVALUE, final);
- rb_ec_error_print(ec, errinfo);
- }
+ return !SPECIAL_CONST_P(obj) && rb_gc_impl_garbage_object_p(rb_gc_get_objspace(), obj);
}
-static void
-run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
+bool
+rb_gc_pointer_to_heap_p(VALUE obj)
{
- long i;
- enum ruby_tag_type state;
- volatile struct {
- VALUE errinfo;
- VALUE objid;
- VALUE final;
- rb_control_frame_t *cfp;
- long finished;
- } saved;
- rb_execution_context_t * volatile ec = GET_EC();
-#define RESTORE_FINALIZER() (\
- ec->cfp = saved.cfp, \
- ec->errinfo = saved.errinfo)
+ return rb_gc_impl_pointer_to_heap_p(rb_gc_get_objspace(), (void *)obj);
+}
- saved.errinfo = ec->errinfo;
- saved.objid = rb_obj_id(obj);
- saved.cfp = ec->cfp;
- saved.finished = 0;
- saved.final = Qundef;
+#define OBJ_ID_INCREMENT (RUBY_IMMEDIATE_MASK + 1)
+#define LAST_OBJECT_ID() (object_id_counter * OBJ_ID_INCREMENT)
+static VALUE id2ref_value = 0;
- EC_PUSH_TAG(ec);
- state = EC_EXEC_TAG();
- if (state != TAG_NONE) {
- ++saved.finished; /* skip failed finalizer */
- warn_exception_in_finalizer(ec, ATOMIC_VALUE_EXCHANGE(saved.final, Qundef));
- }
- for (i = saved.finished;
- RESTORE_FINALIZER(), i<RARRAY_LEN(table);
- saved.finished = ++i) {
- run_single_final(saved.final = RARRAY_AREF(table, i), saved.objid);
- }
- EC_POP_TAG();
-#undef RESTORE_FINALIZER
-}
+#if SIZEOF_SIZE_T == SIZEOF_LONG_LONG
+static size_t object_id_counter = 1;
+#else
+static unsigned long long object_id_counter = 1;
+#endif
-static void
-run_final(rb_objspace_t *objspace, VALUE zombie)
+static inline VALUE
+generate_next_object_id(void)
{
- st_data_t key, table;
+#if SIZEOF_SIZE_T == SIZEOF_LONG_LONG
+ // 64bit atomics are available
+ return SIZET2NUM(RUBY_ATOMIC_SIZE_FETCH_ADD(object_id_counter, 1) * OBJ_ID_INCREMENT);
+#else
+ unsigned int lock_lev = RB_GC_VM_LOCK();
+ VALUE id = ULL2NUM(++object_id_counter * OBJ_ID_INCREMENT);
+ RB_GC_VM_UNLOCK(lock_lev);
+ return id;
+#endif
+}
- if (RZOMBIE(zombie)->dfree) {
- RZOMBIE(zombie)->dfree(RZOMBIE(zombie)->data);
+void
+rb_gc_obj_id_moved(VALUE obj)
+{
+ if (UNLIKELY(id2ref_tbl)) {
+ st_insert(id2ref_tbl, (st_data_t)rb_obj_id(obj), (st_data_t)obj);
}
+}
- key = (st_data_t)zombie;
- if (st_delete(finalizer_table, &key, &table)) {
- run_finalizer(objspace, zombie, (VALUE)table);
+static int
+object_id_cmp(st_data_t x, st_data_t y)
+{
+ if (RB_TYPE_P(x, T_BIGNUM)) {
+ return !rb_big_eql(x, y);
+ }
+ else {
+ return x != y;
}
}
-static void
-finalize_list(rb_objspace_t *objspace, VALUE zombie)
+static st_index_t
+object_id_hash(st_data_t n)
{
- while (zombie) {
- VALUE next_zombie;
- struct heap_page *page;
- asan_unpoison_object(zombie, false);
- next_zombie = RZOMBIE(zombie)->next;
- page = GET_HEAP_PAGE(zombie);
-
- run_final(objspace, zombie);
-
- RB_VM_LOCK_ENTER();
- {
- GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
- if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) {
- obj_free_object_id(objspace, zombie);
- }
-
- GC_ASSERT(heap_pages_final_slots > 0);
- GC_ASSERT(page->final_slots > 0);
+ return FIX2LONG(rb_hash((VALUE)n));
+}
- heap_pages_final_slots--;
- page->final_slots--;
- page->free_slots++;
- heap_page_add_freeobj(objspace, page, zombie);
- objspace->profile.total_freed_objects++;
- }
- RB_VM_LOCK_LEAVE();
+static const struct st_hash_type object_id_hash_type = {
+ object_id_cmp,
+ object_id_hash,
+};
- zombie = next_zombie;
- }
-}
+static void gc_mark_tbl_no_pin(st_table *table);
static void
-finalize_deferred_heap_pages(rb_objspace_t *objspace)
+id2ref_tbl_mark(void *data)
{
- VALUE zombie;
- while ((zombie = ATOMIC_VALUE_EXCHANGE(heap_pages_deferred_final, 0)) != 0) {
- finalize_list(objspace, zombie);
+ st_table *table = (st_table *)data;
+ if (UNLIKELY(!RB_POSFIXABLE(LAST_OBJECT_ID()))) {
+ // It's very unlikely, but if enough object ids were generated, keys may be T_BIGNUM
+ rb_mark_set(table);
}
+ // We purposely don't mark values, as they are weak references.
+ // rb_gc_obj_free_vm_weak_references takes care of cleaning them up.
}
-static void
-finalize_deferred(rb_objspace_t *objspace)
+static size_t
+id2ref_tbl_memsize(const void *data)
{
- rb_execution_context_t *ec = GET_EC();
- ec->interrupt_mask |= PENDING_INTERRUPT_MASK;
- finalize_deferred_heap_pages(objspace);
- ec->interrupt_mask &= ~PENDING_INTERRUPT_MASK;
+ return rb_st_memsize(data);
}
static void
-gc_finalize_deferred(void *dmy)
+id2ref_tbl_free(void *data)
{
- rb_objspace_t *objspace = dmy;
- if (ATOMIC_EXCHANGE(finalizing, 1)) return;
-
- finalize_deferred(objspace);
- ATOMIC_SET(finalizing, 0);
+ id2ref_tbl = NULL; // clear global ref
+ st_table *table = (st_table *)data;
+ st_free_table(table);
}
-static void
-gc_finalize_deferred_register(rb_objspace_t *objspace)
+static const rb_data_type_t id2ref_tbl_type = {
+ .wrap_struct_name = "VM/_id2ref_table",
+ .function = {
+ .dmark = id2ref_tbl_mark,
+ .dfree = id2ref_tbl_free,
+ .dsize = id2ref_tbl_memsize,
+ // dcompact function not required because the table is reference updated
+ // in rb_gc_vm_weak_table_foreach
+ },
+ .flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE
+class_object_id(VALUE klass)
{
- if (rb_postponed_job_register_one(0, gc_finalize_deferred, objspace) == 0) {
- rb_bug("gc_finalize_deferred_register: can't register finalizer.");
+ VALUE id = RUBY_ATOMIC_VALUE_LOAD(RCLASS(klass)->object_id);
+ if (!id) {
+ unsigned int lock_lev = RB_GC_VM_LOCK();
+ id = generate_next_object_id();
+ VALUE existing_id = RUBY_ATOMIC_VALUE_CAS(RCLASS(klass)->object_id, 0, id);
+ if (existing_id) {
+ id = existing_id;
+ }
+ else if (RB_UNLIKELY(id2ref_tbl)) {
+ st_insert(id2ref_tbl, id, klass);
+ }
+ RB_GC_VM_UNLOCK(lock_lev);
}
+ return id;
}
-struct force_finalize_list {
- VALUE obj;
- VALUE table;
- struct force_finalize_list *next;
-};
+static inline VALUE
+object_id_get(VALUE obj, shape_id_t shape_id)
+{
+ VALUE id;
+ if (rb_shape_complex_p(shape_id)) {
+ id = rb_obj_field_get(obj, ROOT_COMPLEX_WITH_OBJ_ID);
+ }
+ else {
+ id = rb_obj_field_get(obj, rb_shape_object_id(shape_id));
+ }
-static int
-force_chain_object(st_data_t key, st_data_t val, st_data_t arg)
-{
- struct force_finalize_list **prev = (struct force_finalize_list **)arg;
- struct force_finalize_list *curr = ALLOC(struct force_finalize_list);
- curr->obj = key;
- curr->table = val;
- curr->next = *prev;
- *prev = curr;
- return ST_CONTINUE;
-}
+#if RUBY_DEBUG
+ if (!(FIXNUM_P(id) || RB_TYPE_P(id, T_BIGNUM))) {
+ rb_p(obj);
+ rb_bug("Object's shape includes object_id, but it's missing %s", rb_obj_info(obj));
+ }
+#endif
-bool rb_obj_is_main_ractor(VALUE gv);
+ return id;
+}
-void
-rb_objspace_call_finalizer(rb_objspace_t *objspace)
+static VALUE
+object_id0(VALUE obj)
{
- size_t i;
+ VALUE id = Qfalse;
+ shape_id_t shape_id = RBASIC_SHAPE_ID(obj);
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
- gc_rest(objspace);
-
- if (ATOMIC_EXCHANGE(finalizing, 1)) return;
-
- /* run finalizers */
- finalize_deferred(objspace);
- GC_ASSERT(heap_pages_deferred_final == 0);
-
- gc_rest(objspace);
- /* prohibit incremental GC */
- objspace->flags.dont_incremental = 1;
-
- /* force to run finalizer */
- while (finalizer_table->num_entries) {
- struct force_finalize_list *list = 0;
- st_foreach(finalizer_table, force_chain_object, (st_data_t)&list);
- while (list) {
- struct force_finalize_list *curr = list;
- st_data_t obj = (st_data_t)curr->obj;
- run_finalizer(objspace, curr->obj, curr->table);
- st_delete(finalizer_table, &obj, 0);
- list = curr->next;
- xfree(curr);
- }
+ if (rb_shape_has_object_id(shape_id)) {
+ return object_id_get(obj, shape_id);
}
- /* prohibit GC because force T_DATA finalizers can break an object graph consistency */
- dont_gc_on();
-
- /* running data/file finalizers are part of garbage collection */
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_finalizer, &lock_lev);
-
- /* run data/file object's finalizers */
- for (i = 0; i < heap_allocated_pages; i++) {
- struct heap_page *page = heap_pages_sorted[i];
- short stride = page->slot_size;
-
- uintptr_t p = (uintptr_t)page->start;
- uintptr_t pend = p + page->total_slots * stride;
- for (; p < pend; p += stride) {
- VALUE vp = (VALUE)p;
- void *poisoned = asan_unpoison_object_temporary(vp);
- switch (BUILTIN_TYPE(vp)) {
- case T_DATA:
- if (!DATA_PTR(p) || !RANY(p)->as.data.dfree) break;
- if (rb_obj_is_thread(vp)) break;
- if (rb_obj_is_mutex(vp)) break;
- if (rb_obj_is_fiber(vp)) break;
- if (rb_obj_is_main_ractor(vp)) break;
-
- rb_data_free(objspace, vp);
- break;
- case T_FILE:
- if (RANY(p)->as.file.fptr) {
- make_io_zombie(objspace, vp);
- }
- break;
- default:
- break;
- }
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(vp) == T_NONE);
- asan_poison_object(vp);
- }
- }
- }
+ shape_id_t object_id_shape_id = rb_obj_shape_transition_object_id(obj);
- gc_exit(objspace, gc_enter_event_finalizer, &lock_lev);
+ id = generate_next_object_id();
+ rb_obj_field_set(obj, object_id_shape_id, 0, id);
- finalize_deferred_heap_pages(objspace);
+ RUBY_ASSERT(RBASIC_SHAPE_ID(obj) == object_id_shape_id);
+ RUBY_ASSERT(rb_obj_shape_has_id(obj));
- st_free_table(finalizer_table);
- finalizer_table = 0;
- ATOMIC_SET(finalizing, 0);
+ if (RB_UNLIKELY(id2ref_tbl)) {
+ RB_VM_LOCKING() {
+ st_insert(id2ref_tbl, (st_data_t)id, (st_data_t)obj);
+ }
+ }
+ return id;
}
-static inline int
-is_swept_object(rb_objspace_t *objspace, VALUE ptr)
+static VALUE
+object_id(VALUE obj)
{
- struct heap_page *page = GET_HEAP_PAGE(ptr);
- return page->flags.before_sweep ? FALSE : TRUE;
+ switch (BUILTIN_TYPE(obj)) {
+ case T_CLASS:
+ case T_MODULE:
+ // With Ruby Box, classes and modules have different fields
+ // in different boxes, so we cannot store the object id
+ // in fields.
+ return class_object_id(obj);
+ case T_IMEMO:
+ RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_fields));
+ break;
+ default:
+ break;
+ }
+
+ if (UNLIKELY(rb_gc_multi_ractor_p() && rb_ractor_shareable_p(obj))) {
+ unsigned int lock_lev = RB_GC_VM_LOCK();
+ VALUE id = object_id0(obj);
+ RB_GC_VM_UNLOCK(lock_lev);
+ return id;
+ }
+
+ return object_id0(obj);
}
-/* garbage objects will be collected soon. */
-static inline int
-is_garbage_object(rb_objspace_t *objspace, VALUE ptr)
+static void
+build_id2ref_i(VALUE obj, void *data)
{
- if (!is_lazy_sweeping(objspace) ||
- is_swept_object(objspace, ptr) ||
- MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(ptr), ptr)) {
+ st_table *id2ref_tbl = (st_table *)data;
- return FALSE;
- }
- else {
- return TRUE;
+ switch (BUILTIN_TYPE(obj)) {
+ case T_CLASS:
+ case T_MODULE:
+ RUBY_ASSERT(!rb_objspace_garbage_object_p(obj));
+ if (RCLASS(obj)->object_id) {
+ st_insert(id2ref_tbl, RCLASS(obj)->object_id, obj);
+ }
+ break;
+ case T_IMEMO:
+ RUBY_ASSERT(!rb_objspace_garbage_object_p(obj));
+ if (IMEMO_TYPE_P(obj, imemo_fields) && rb_obj_shape_has_id(obj)) {
+ st_insert(id2ref_tbl, rb_obj_id(obj), rb_imemo_fields_owner(obj));
+ }
+ break;
+ case T_OBJECT:
+ RUBY_ASSERT(!rb_objspace_garbage_object_p(obj));
+ if (rb_obj_shape_has_id(obj)) {
+ st_insert(id2ref_tbl, rb_obj_id(obj), obj);
+ }
+ break;
+ default:
+ // For generic_fields, the T_IMEMO/fields is responsible for populating the entry.
+ break;
}
}
-static inline int
-is_live_object(rb_objspace_t *objspace, VALUE ptr)
+static VALUE
+object_id_to_ref(void *objspace_ptr, VALUE object_id)
{
- switch (BUILTIN_TYPE(ptr)) {
- case T_NONE:
- case T_MOVED:
- case T_ZOMBIE:
- return FALSE;
- default:
- break;
+ rb_objspace_t *objspace = objspace_ptr;
+
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ if (!id2ref_tbl) {
+ rb_gc_vm_barrier(); // stop other ractors
+
+ // GC Must not trigger while we build the table, otherwise if we end
+ // up freeing an object that had an ID, we might try to delete it from
+ // the table even though it wasn't inserted yet.
+ st_table *tmp_id2ref_tbl = st_init_table(&object_id_hash_type);
+ VALUE tmp_id2ref_value = TypedData_Wrap_Struct(0, &id2ref_tbl_type, tmp_id2ref_tbl);
+
+ // build_id2ref_i will most certainly malloc, which could trigger GC and sweep
+ // objects we just added to the table.
+ // By calling rb_gc_disable() we also save having to handle potentially garbage objects.
+ bool gc_disabled = RTEST(rb_gc_disable());
+ {
+ id2ref_tbl = tmp_id2ref_tbl;
+ id2ref_value = tmp_id2ref_value;
+
+ rb_gc_impl_each_object(objspace, build_id2ref_i, (void *)id2ref_tbl);
+ }
+ if (!gc_disabled) rb_gc_enable();
}
- if (!is_garbage_object(objspace, ptr)) {
- return TRUE;
+ VALUE obj;
+ bool found = st_lookup(id2ref_tbl, object_id, &obj) && !rb_gc_impl_garbage_object_p(objspace, obj);
+
+ RB_GC_VM_UNLOCK(lev);
+
+ if (found) {
+ return obj;
+ }
+
+ if (rb_funcall(object_id, rb_intern(">="), 1, ULL2NUM(LAST_OBJECT_ID()))) {
+ rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not an id value", rb_funcall(object_id, rb_intern("to_s"), 1, INT2FIX(10)));
}
else {
- return FALSE;
+ rb_raise(rb_eRangeError, "%+"PRIsVALUE" is a recycled object", rb_funcall(object_id, rb_intern("to_s"), 1, INT2FIX(10)));
}
}
-static inline int
-is_markable_object(rb_objspace_t *objspace, VALUE obj)
+static inline void
+obj_free_object_id(VALUE obj)
{
- if (rb_special_const_p(obj)) return FALSE; /* special const is not markable */
- check_rvalue_consistency(obj);
- return TRUE;
-}
+ VALUE obj_id = 0;
+ if (RB_UNLIKELY(id2ref_tbl)) {
+ switch (BUILTIN_TYPE(obj)) {
+ case T_CLASS:
+ case T_MODULE:
+ obj_id = RCLASS(obj)->object_id;
+ break;
+ case T_IMEMO:
+ if (!IMEMO_TYPE_P(obj, imemo_fields)) {
+ return;
+ }
+ // fallthrough
+ case T_OBJECT:
+ {
+ shape_id_t shape_id = RBASIC_SHAPE_ID(obj);
+ if (rb_shape_has_object_id(shape_id)) {
+ obj_id = object_id_get(obj, shape_id);
+ }
+ break;
+ }
+ default:
+ // For generic_fields, the T_IMEMO/fields is responsible for freeing the id.
+ return;
+ }
-int
-rb_objspace_markable_object_p(VALUE obj)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return is_markable_object(objspace, obj) && is_live_object(objspace, obj);
-}
+ if (RB_UNLIKELY(obj_id)) {
+ RUBY_ASSERT(FIXNUM_P(obj_id) || RB_TYPE_P(obj_id, T_BIGNUM));
-int
-rb_objspace_garbage_object_p(VALUE obj)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return is_garbage_object(objspace, obj);
-}
-
-bool
-rb_gc_is_ptr_to_obj(void *ptr)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return is_pointer_to_heap(objspace, ptr);
+ if (!st_delete(id2ref_tbl, (st_data_t *)&obj_id, NULL)) {
+ // The the object is a T_IMEMO/fields, then it's possible the actual object
+ // has been garbage collected already.
+ if (!RB_TYPE_P(obj, T_IMEMO)) {
+ rb_bug("Object ID seen, but not in _id2ref table: object_id=%llu object=%s", NUM2ULL(obj_id), rb_obj_info(obj));
+ }
+ }
+ }
+ }
}
-VALUE
-rb_gc_id2ref_obj_tbl(VALUE objid)
+void
+rb_gc_obj_free_vm_weak_references(VALUE obj)
{
- rb_objspace_t *objspace = &rb_objspace;
+ ASSUME(!RB_SPECIAL_CONST_P(obj));
+ obj_free_object_id(obj);
- VALUE orig;
- if (st_lookup(objspace->id_to_obj_tbl, objid, &orig)) {
- return orig;
+ if (rb_obj_gen_fields_p(obj)) {
+ rb_free_generic_ivar(obj);
}
- else {
- return Qundef;
+
+ switch (BUILTIN_TYPE(obj)) {
+ case T_STRING:
+ if (FL_TEST_RAW(obj, RSTRING_FSTR)) {
+ rb_gc_free_fstring(obj);
+ }
+ break;
+ case T_SYMBOL:
+ rb_gc_free_dsymbol(obj);
+ break;
+ case T_IMEMO:
+ switch (imemo_type(obj)) {
+ case imemo_callinfo:
+ rb_vm_ci_free((const struct rb_callinfo *)obj);
+ break;
+ case imemo_ment:
+ rb_free_method_entry_vm_weak_references((const rb_method_entry_t *)obj);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
}
}
@@ -4689,56 +2379,43 @@ rb_gc_id2ref_obj_tbl(VALUE objid)
*
* On multi-ractor mode, if the object is not shareable, it raises
* RangeError.
+ *
+ * This method is deprecated and should no longer be used.
*/
static VALUE
id2ref(VALUE objid)
{
-#if SIZEOF_LONG == SIZEOF_VOIDP
-#define NUM2PTR(x) NUM2ULONG(x)
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-#define NUM2PTR(x) NUM2ULL(x)
-#endif
- rb_objspace_t *objspace = &rb_objspace;
- VALUE ptr;
- VALUE orig;
- void *p0;
-
objid = rb_to_int(objid);
if (FIXNUM_P(objid) || rb_big_size(objid) <= SIZEOF_VOIDP) {
- ptr = NUM2PTR(objid);
- if (ptr == Qtrue) return Qtrue;
- if (ptr == Qfalse) return Qfalse;
- if (NIL_P(ptr)) return Qnil;
- if (FIXNUM_P(ptr)) return (VALUE)ptr;
- if (FLONUM_P(ptr)) return (VALUE)ptr;
-
- ptr = obj_id_to_ref(objid);
- if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
- ID symid = ptr / sizeof(RVALUE);
- p0 = (void *)ptr;
- if (!rb_static_id_valid_p(symid))
- rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
- return ID2SYM(symid);
- }
- }
-
- if (!UNDEF_P(orig = rb_gc_id2ref_obj_tbl(objid)) &&
- is_live_object(objspace, orig)) {
+ VALUE ptr = (VALUE)NUM2PTR(objid);
+ if (SPECIAL_CONST_P(ptr)) {
+ if (ptr == Qtrue) return Qtrue;
+ if (ptr == Qfalse) return Qfalse;
+ if (NIL_P(ptr)) return Qnil;
+ if (FIXNUM_P(ptr)) return ptr;
+ if (FLONUM_P(ptr)) return ptr;
+
+ if (SYMBOL_P(ptr)) {
+ // Check that the symbol is valid
+ if (rb_static_id_valid_p(SYM2ID(ptr))) {
+ return ptr;
+ }
+ else {
+ rb_raise(rb_eRangeError, "%p is not a symbol id value", (void *)ptr);
+ }
+ }
- if (!rb_multi_ractor_p() || rb_ractor_shareable_p(orig)) {
- return orig;
- }
- else {
- rb_raise(rb_eRangeError, "%+"PRIsVALUE" is id of the unshareable object on multi-ractor", rb_int2str(objid, 10));
+ rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not an id value", rb_int2str(objid, 10));
}
}
- if (rb_int_ge(objid, objspace->next_object_id)) {
- rb_raise(rb_eRangeError, "%+"PRIsVALUE" is not id value", rb_int2str(objid, 10));
+ VALUE obj = object_id_to_ref(rb_gc_get_objspace(), objid);
+ if (!rb_multi_ractor_p() || rb_ractor_shareable_p(obj)) {
+ return obj;
}
else {
- rb_raise(rb_eRangeError, "%+"PRIsVALUE" is recycled object", rb_int2str(objid, 10));
+ rb_raise(rb_eRangeError, "%+"PRIsVALUE" is the id of an unshareable object on multi-ractor", rb_int2str(objid, 10));
}
}
@@ -4746,57 +2423,25 @@ id2ref(VALUE objid)
static VALUE
os_id2ref(VALUE os, VALUE objid)
{
+ rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "ObjectSpace._id2ref is deprecated");
return id2ref(objid);
}
static VALUE
-rb_find_object_id(VALUE obj, VALUE (*get_heap_object_id)(VALUE))
+rb_find_object_id(void *objspace, VALUE obj, VALUE (*get_heap_object_id)(VALUE))
{
- if (STATIC_SYM_P(obj)) {
- return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
- }
- else if (FLONUM_P(obj)) {
+ if (SPECIAL_CONST_P(obj)) {
#if SIZEOF_LONG == SIZEOF_VOIDP
return LONG2NUM((SIGNED_VALUE)obj);
#else
return LL2NUM((SIGNED_VALUE)obj);
#endif
}
- else if (SPECIAL_CONST_P(obj)) {
- return LONG2NUM((SIGNED_VALUE)obj);
- }
return get_heap_object_id(obj);
}
static VALUE
-cached_object_id(VALUE obj)
-{
- VALUE id;
- rb_objspace_t *objspace = &rb_objspace;
-
- RB_VM_LOCK_ENTER();
- if (st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, &id)) {
- GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
- }
- else {
- GC_ASSERT(!FL_TEST(obj, FL_SEEN_OBJ_ID));
-
- id = objspace->next_object_id;
- objspace->next_object_id = rb_int_plus(id, INT2FIX(OBJ_ID_INCREMENT));
-
- VALUE already_disabled = rb_gc_disable_no_rest();
- st_insert(objspace->obj_to_id_tbl, (st_data_t)obj, (st_data_t)id);
- st_insert(objspace->id_to_obj_tbl, (st_data_t)id, (st_data_t)obj);
- if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
- FL_SET(obj, FL_SEEN_OBJ_ID);
- }
- RB_VM_LOCK_LEAVE();
-
- return id;
-}
-
-static VALUE
nonspecial_obj_id(VALUE obj)
{
#if SIZEOF_LONG == SIZEOF_VOIDP
@@ -4811,7 +2456,7 @@ nonspecial_obj_id(VALUE obj)
VALUE
rb_memory_id(VALUE obj)
{
- return rb_find_object_id(obj, nonspecial_obj_id);
+ return rb_find_object_id(NULL, obj, nonspecial_obj_id);
}
/*
@@ -4844,58 +2489,87 @@ rb_memory_id(VALUE obj)
VALUE
rb_obj_id(VALUE obj)
{
- /*
- * 32-bit VALUE space
- * MSB ------------------------ LSB
- * false 00000000000000000000000000000000
- * true 00000000000000000000000000000010
- * nil 00000000000000000000000000000100
- * undef 00000000000000000000000000000110
- * symbol ssssssssssssssssssssssss00001110
- * object oooooooooooooooooooooooooooooo00 = 0 (mod sizeof(RVALUE))
- * fixnum fffffffffffffffffffffffffffffff1
- *
- * object_id space
- * LSB
- * false 00000000000000000000000000000000
- * true 00000000000000000000000000000010
- * nil 00000000000000000000000000000100
- * undef 00000000000000000000000000000110
- * symbol 000SSSSSSSSSSSSSSSSSSSSSSSSSSS0 S...S % A = 4 (S...S = s...s * A + 4)
- * object oooooooooooooooooooooooooooooo0 o...o % A = 0
- * fixnum fffffffffffffffffffffffffffffff1 bignum if required
- *
- * where A = sizeof(RVALUE)/4
- *
- * sizeof(RVALUE) is
- * 20 if 32-bit, double is 4-byte aligned
- * 24 if 32-bit, double is 8-byte aligned
- * 40 if 64-bit
- */
+ /* If obj is an immediate, the object ID is obj directly converted to a Numeric.
+ * Otherwise, the object ID is a Numeric that is a non-zero multiple of
+ * (RUBY_IMMEDIATE_MASK + 1) which guarantees that it does not collide with
+ * any immediates. */
+ return rb_find_object_id(rb_gc_get_objspace(), obj, object_id);
+}
- return rb_find_object_id(obj, cached_object_id);
+bool
+rb_obj_id_p(VALUE obj)
+{
+ return !RB_TYPE_P(obj, T_IMEMO) && rb_obj_shape_has_id(obj);
}
-static enum rb_id_table_iterator_result
-cc_table_memsize_i(VALUE ccs_ptr, void *data_ptr)
+/*
+ * GC implementations should call this function before the GC phase that updates references
+ * embedded in the machine code generated by JIT compilers. JIT compilers usually enforce the
+ * "W^X" policy and protect the code memory from being modified during execution. This function
+ * makes the code memory writeable.
+ */
+void
+rb_gc_before_updating_jit_code(void)
{
- size_t *total_size = data_ptr;
- struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_ptr;
- *total_size += sizeof(*ccs);
- *total_size += sizeof(ccs->entries[0]) * ccs->capa;
- return ID_TABLE_CONTINUE;
+#if USE_YJIT
+ rb_yjit_mark_all_writeable();
+#endif
+#if USE_ZJIT
+ rb_zjit_mark_all_writable();
+#endif
}
-static size_t
-cc_table_memsize(struct rb_id_table *cc_table)
+/*
+ * GC implementations should call this function before the GC phase that updates references
+ * embedded in the machine code generated by JIT compilers. This function makes the code memory
+ * executable again.
+ */
+void
+rb_gc_after_updating_jit_code(void)
{
- size_t total = rb_id_table_memsize(cc_table);
- rb_id_table_foreach_values(cc_table, cc_table_memsize_i, &total);
- return total;
+#if USE_YJIT
+ rb_yjit_mark_all_executable();
+#endif
+#if USE_ZJIT
+ rb_zjit_mark_all_executable();
+#endif
}
-static size_t
-obj_memsize_of(VALUE obj, int use_all_types)
+static void
+classext_memsize(rb_classext_t *ext, bool prime, VALUE box_value, void *arg)
+{
+ size_t *size = (size_t *)arg;
+ size_t s = 0;
+
+ if (RCLASSEXT_M_TBL(ext)) {
+ s += rb_id_table_memsize(RCLASSEXT_M_TBL(ext));
+ }
+ if (RCLASSEXT_CONST_TBL(ext)) {
+ s += rb_id_table_memsize(RCLASSEXT_CONST_TBL(ext));
+ }
+ if (RCLASSEXT_SUPERCLASSES_WITH_SELF(ext)) {
+ s += (RCLASSEXT_SUPERCLASS_DEPTH(ext) + 1) * sizeof(VALUE);
+ }
+ if (!prime) {
+ s += sizeof(rb_classext_t);
+ }
+ *size += s;
+}
+
+static void
+classext_superclasses_memsize(rb_classext_t *ext, bool prime, VALUE box_value, void *arg)
+{
+ size_t *size = (size_t *)arg;
+ size_t array_size;
+ if (RCLASSEXT_SUPERCLASSES_WITH_SELF(ext)) {
+ RUBY_ASSERT(prime);
+ array_size = RCLASSEXT_SUPERCLASS_DEPTH(ext) + 1;
+ *size += array_size * sizeof(VALUE);
+ }
+}
+
+size_t
+rb_obj_memsize_of(VALUE obj)
{
size_t size = 0;
@@ -4903,43 +2577,21 @@ obj_memsize_of(VALUE obj, int use_all_types)
return 0;
}
- if (FL_TEST(obj, FL_EXIVAR)) {
- size += rb_generic_ivar_memsize(obj);
- }
-
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
- if (rb_shape_obj_too_complex(obj)) {
- size += rb_id_table_memsize(ROBJECT_IV_HASH(obj));
- }
- else if (!(RBASIC(obj)->flags & ROBJECT_EMBED)) {
- size += ROBJECT_IV_CAPACITY(obj) * sizeof(VALUE);
+ if (FL_TEST_RAW(obj, ROBJECT_HEAP)) {
+ if (rb_obj_shape_complex_p(obj)) {
+ size += rb_st_memsize(ROBJECT_FIELDS_HASH(obj));
+ }
+ else {
+ size += ROBJECT_FIELDS_CAPACITY(obj) * sizeof(VALUE);
+ }
}
break;
case T_MODULE:
case T_CLASS:
- if (RCLASS_EXT(obj)) {
- if (RCLASS_M_TBL(obj)) {
- size += rb_id_table_memsize(RCLASS_M_TBL(obj));
- }
- // class IV sizes are allocated as powers of two
- size += SIZEOF_VALUE << bit_length(RCLASS_IV_COUNT(obj));
- if (RCLASS_CVC_TBL(obj)) {
- size += rb_id_table_memsize(RCLASS_CVC_TBL(obj));
- }
- if (RCLASS_EXT(obj)->const_tbl) {
- size += rb_id_table_memsize(RCLASS_EXT(obj)->const_tbl);
- }
- if (RCLASS_CC_TBL(obj)) {
- size += cc_table_memsize(RCLASS_CC_TBL(obj));
- }
- if (FL_TEST_RAW(obj, RCLASS_SUPERCLASSES_INCLUDE_SELF)) {
- size += (RCLASS_SUPERCLASS_DEPTH(obj) + 1) * sizeof(VALUE);
- }
-#if !RCLASS_EXT_EMBEDDED
- size += sizeof(rb_classext_t);
-#endif
- }
+ rb_class_classext_foreach(obj, classext_memsize, (void *)&size);
+ rb_class_classext_foreach(obj, classext_superclasses_memsize, (void *)&size);
break;
case T_ICLASS:
if (RICLASS_OWNS_M_TBL_P(obj)) {
@@ -4947,9 +2599,6 @@ obj_memsize_of(VALUE obj, int use_all_types)
size += rb_id_table_memsize(RCLASS_M_TBL(obj));
}
}
- if (RCLASS_EXT(obj) && RCLASS_CC_TBL(obj)) {
- size += cc_table_memsize(RCLASS_CC_TBL(obj));
- }
break;
case T_STRING:
size += rb_str_memsize(obj);
@@ -4958,15 +2607,10 @@ obj_memsize_of(VALUE obj, int use_all_types)
size += rb_ary_memsize(obj);
break;
case T_HASH:
- if (RHASH_AR_TABLE_P(obj)) {
- if (RHASH_AR_TABLE(obj) != NULL) {
- size_t rb_hash_ar_table_size(void);
- size += rb_hash_ar_table_size();
- }
- }
- else {
+ if (RHASH_ST_TABLE_P(obj)) {
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
- size += st_memsize(RHASH_ST_TABLE(obj));
+ /* st_table is in the slot */
+ size += st_memsize(RHASH_ST_TABLE(obj)) - sizeof(st_table);
}
break;
case T_REGEXP:
@@ -4975,14 +2619,15 @@ obj_memsize_of(VALUE obj, int use_all_types)
}
break;
case T_DATA:
- if (use_all_types) size += rb_objspace_data_type_memsize(obj);
+ size += rb_objspace_data_type_memsize(obj);
break;
case T_MATCH:
- if (RMATCH(obj)->rmatch) {
- struct rmatch *rm = RMATCH(obj)->rmatch;
- size += onig_region_memsize(&rm->regs);
+ {
+ struct RMatch *rm = RMATCH(obj);
+ if (FL_TEST_RAW(obj, RMATCH_ONIG)) {
+ size += onig_region_memsize(&rm->as.onig);
+ }
size += sizeof(struct rmatch_offset) * rm->char_offset_num_allocated;
- size += sizeof(struct rmatch);
}
break;
case T_FILE:
@@ -4994,7 +2639,7 @@ obj_memsize_of(VALUE obj, int use_all_types)
case T_COMPLEX:
break;
case T_IMEMO:
- size += imemo_memsize(obj);
+ size += rb_imemo_memsize(obj);
break;
case T_FLOAT:
@@ -5012,9 +2657,8 @@ obj_memsize_of(VALUE obj, int use_all_types)
break;
case T_STRUCT:
- if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
- RSTRUCT(obj)->as.heap.ptr) {
- size += sizeof(VALUE) * RSTRUCT_LEN(obj);
+ if (RSTRUCT_EMBED_LEN(obj) == 0) {
+ size += sizeof(VALUE) * RSTRUCT_LEN_RAW(obj);
}
break;
@@ -5030,12 +2674,6 @@ obj_memsize_of(VALUE obj, int use_all_types)
return size + rb_gc_obj_slot_size(obj);
}
-size_t
-rb_obj_memsize_of(VALUE obj)
-{
- return obj_memsize_of(obj, TRUE);
-}
-
static int
set_zero(st_data_t key, st_data_t val, st_data_t arg)
{
@@ -5045,73 +2683,62 @@ set_zero(st_data_t key, st_data_t val, st_data_t arg)
return ST_CONTINUE;
}
-static VALUE
-type_sym(size_t type)
+struct count_objects_data {
+ size_t counts[T_MASK+1];
+ size_t freed;
+ size_t total;
+};
+
+static void
+count_objects_i(VALUE obj, void *d)
{
- switch (type) {
-#define COUNT_TYPE(t) case (t): return ID2SYM(rb_intern(#t)); break;
- COUNT_TYPE(T_NONE);
- COUNT_TYPE(T_OBJECT);
- COUNT_TYPE(T_CLASS);
- COUNT_TYPE(T_MODULE);
- COUNT_TYPE(T_FLOAT);
- COUNT_TYPE(T_STRING);
- COUNT_TYPE(T_REGEXP);
- COUNT_TYPE(T_ARRAY);
- COUNT_TYPE(T_HASH);
- COUNT_TYPE(T_STRUCT);
- COUNT_TYPE(T_BIGNUM);
- COUNT_TYPE(T_FILE);
- COUNT_TYPE(T_DATA);
- COUNT_TYPE(T_MATCH);
- COUNT_TYPE(T_COMPLEX);
- COUNT_TYPE(T_RATIONAL);
- COUNT_TYPE(T_NIL);
- COUNT_TYPE(T_TRUE);
- COUNT_TYPE(T_FALSE);
- COUNT_TYPE(T_SYMBOL);
- COUNT_TYPE(T_FIXNUM);
- COUNT_TYPE(T_IMEMO);
- COUNT_TYPE(T_UNDEF);
- COUNT_TYPE(T_NODE);
- COUNT_TYPE(T_ICLASS);
- COUNT_TYPE(T_ZOMBIE);
- COUNT_TYPE(T_MOVED);
-#undef COUNT_TYPE
- default: return SIZET2NUM(type); break;
+ struct count_objects_data *data = (struct count_objects_data *)d;
+
+ if (RBASIC(obj)->flags) {
+ data->counts[BUILTIN_TYPE(obj)]++;
+ }
+ else {
+ data->freed++;
}
+
+ data->total++;
}
/*
* call-seq:
- * ObjectSpace.count_objects([result_hash]) -> hash
+ * ObjectSpace.count_objects(result_hash = {}) -> hash
+ *
+ * Counts the number of objects, grouped by type.
*
- * Counts all objects grouped by type.
+ * It returns a hash that looks like:
*
- * It returns a hash, such as:
- * {
- * :TOTAL=>10000,
- * :FREE=>3011,
- * :T_OBJECT=>6,
- * :T_CLASS=>404,
- * # ...
- * }
+ * {
+ * TOTAL: 10000,
+ * FREE: 3011,
+ * T_OBJECT: 6,
+ * T_CLASS: 404,
+ * # ...
+ * }
*
- * The contents of the returned hash are implementation specific.
- * It may be changed in future.
+ * The contents of the returned hash are implementation specific and
+ * may be changed in future versions without notice.
*
- * The keys starting with +:T_+ means live objects.
+ * The keys starting with +:T_+ are live objects of a particular type.
* For example, +:T_ARRAY+ is the number of arrays.
- * +:FREE+ means object slots which is not used now.
- * +:TOTAL+ means sum of above.
+ *
+ * The key +:FREE+ is the number of object slots which are empty.
+ *
+ * The key +:TOTAL+ is the total number of slots (which is the sum of
+ * all of the other values).
*
* If the optional argument +result_hash+ is given,
- * it is overwritten and returned. This is intended to avoid probe effect.
+ * it is overwritten and returned.
+ * This is intended to avoid the probe effect.
*
* h = {}
* ObjectSpace.count_objects(h)
* puts h
- * # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 }
+ * # => { TOTAL: 10000, T_CLASS: 158280, T_MODULE: 20672, T_STRING: 527249 }
*
* This method is only expected to work on C Ruby.
*
@@ -5120,12 +2747,9 @@ type_sym(size_t type)
static VALUE
count_objects(int argc, VALUE *argv, VALUE os)
{
- rb_objspace_t *objspace = &rb_objspace;
- size_t counts[T_MASK+1];
- size_t freed = 0;
- size_t total = 0;
- size_t i;
+ struct count_objects_data data = { 0 };
VALUE hash = Qnil;
+ VALUE types[T_MASK + 1];
if (rb_check_arity(argc, 0, 1) == 1) {
hash = argv[0];
@@ -5133,34 +2757,18 @@ count_objects(int argc, VALUE *argv, VALUE os)
rb_raise(rb_eTypeError, "non-hash given");
}
- for (i = 0; i <= T_MASK; i++) {
- counts[i] = 0;
+ for (size_t i = 0; i <= T_MASK; i++) {
+ // type_sym can allocate an object,
+ // so we need to create all key symbols in advance
+ // not to disturb the result
+ types[i] = type_sym(i);
}
- for (i = 0; i < heap_allocated_pages; i++) {
- struct heap_page *page = heap_pages_sorted[i];
- short stride = page->slot_size;
+ // Same as type_sym, we need to create all key symbols in advance
+ VALUE total = ID2SYM(rb_intern("TOTAL"));
+ VALUE free = ID2SYM(rb_intern("FREE"));
- uintptr_t p = (uintptr_t)page->start;
- uintptr_t pend = p + page->total_slots * stride;
- for (;p < pend; p += stride) {
- VALUE vp = (VALUE)p;
- GC_ASSERT((NUM_IN_PAGE(vp) * BASE_SLOT_SIZE) % page->slot_size == 0);
-
- void *poisoned = asan_unpoison_object_temporary(vp);
- if (RANY(p)->as.basic.flags) {
- counts[BUILTIN_TYPE(vp)]++;
- }
- else {
- freed++;
- }
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(vp) == T_NONE);
- asan_poison_object(vp);
- }
- }
- total += page->total_slots;
- }
+ rb_gc_impl_each_object(rb_gc_get_objspace(), count_objects_i, &data);
if (NIL_P(hash)) {
hash = rb_hash_new();
@@ -5168,1274 +2776,18 @@ count_objects(int argc, VALUE *argv, VALUE os)
else if (!RHASH_EMPTY_P(hash)) {
rb_hash_stlike_foreach(hash, set_zero, hash);
}
- rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total));
- rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed));
-
- for (i = 0; i <= T_MASK; i++) {
- VALUE type = type_sym(i);
- if (counts[i])
- rb_hash_aset(hash, type, SIZET2NUM(counts[i]));
- }
-
- return hash;
-}
-
-/*
- ------------------------ Garbage Collection ------------------------
-*/
-
-/* Sweeping */
-
-static size_t
-objspace_available_slots(rb_objspace_t *objspace)
-{
- size_t total_slots = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- total_slots += SIZE_POOL_EDEN_HEAP(size_pool)->total_slots;
- total_slots += SIZE_POOL_TOMB_HEAP(size_pool)->total_slots;
- }
- return total_slots;
-}
-
-static size_t
-objspace_live_slots(rb_objspace_t *objspace)
-{
- return (objspace->total_allocated_objects - objspace->profile.total_freed_objects) - heap_pages_final_slots;
-}
-
-static size_t
-objspace_free_slots(rb_objspace_t *objspace)
-{
- return objspace_available_slots(objspace) - objspace_live_slots(objspace) - heap_pages_final_slots;
-}
-
-static void
-gc_setup_mark_bits(struct heap_page *page)
-{
- /* copy oldgen bitmap to mark bitmap */
- memcpy(&page->mark_bits[0], &page->uncollectible_bits[0], HEAP_PAGE_BITMAP_SIZE);
-}
-
-static int gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj);
-static VALUE gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, size_t slot_size);
-
-#if defined(_WIN32)
-enum {HEAP_PAGE_LOCK = PAGE_NOACCESS, HEAP_PAGE_UNLOCK = PAGE_READWRITE};
-
-static BOOL
-protect_page_body(struct heap_page_body *body, DWORD protect)
-{
- DWORD old_protect;
- return VirtualProtect(body, HEAP_PAGE_SIZE, protect, &old_protect) != 0;
-}
-#else
-enum {HEAP_PAGE_LOCK = PROT_NONE, HEAP_PAGE_UNLOCK = PROT_READ | PROT_WRITE};
-#define protect_page_body(body, protect) !mprotect((body), HEAP_PAGE_SIZE, (protect))
-#endif
-
-static void
-lock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
-{
- if (!protect_page_body(body, HEAP_PAGE_LOCK)) {
- rb_bug("Couldn't protect page %p, errno: %s", (void *)body, strerror(errno));
- }
- else {
- gc_report(5, objspace, "Protecting page in move %p\n", (void *)body);
- }
-}
+ rb_hash_aset(hash, total, SIZET2NUM(data.total));
+ rb_hash_aset(hash, free, SIZET2NUM(data.freed));
-static void
-unlock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
-{
- if (!protect_page_body(body, HEAP_PAGE_UNLOCK)) {
- rb_bug("Couldn't unprotect page %p, errno: %s", (void *)body, strerror(errno));
- }
- else {
- gc_report(5, objspace, "Unprotecting page in move %p\n", (void *)body);
- }
-}
-
-static bool
-try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *free_page, VALUE src)
-{
- GC_ASSERT(gc_is_moveable_obj(objspace, src));
-
- struct heap_page *src_page = GET_HEAP_PAGE(src);
- if (!free_page) {
- return false;
- }
-
- /* We should return true if either src is successfully moved, or src is
- * unmoveable. A false return will cause the sweeping cursor to be
- * incremented to the next page, and src will attempt to move again */
- GC_ASSERT(MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(src), src));
-
- asan_unlock_freelist(free_page);
- VALUE dest = (VALUE)free_page->freelist;
- asan_lock_freelist(free_page);
- asan_unpoison_object(dest, false);
- if (!dest) {
- /* if we can't get something from the freelist then the page must be
- * full */
- return false;
- }
- free_page->freelist = RANY(dest)->as.free.next;
-
- GC_ASSERT(RB_BUILTIN_TYPE(dest) == T_NONE);
-
- if (src_page->slot_size > free_page->slot_size) {
- objspace->rcompactor.moved_down_count_table[BUILTIN_TYPE(src)]++;
- }
- else if (free_page->slot_size > src_page->slot_size) {
- objspace->rcompactor.moved_up_count_table[BUILTIN_TYPE(src)]++;
- }
- objspace->rcompactor.moved_count_table[BUILTIN_TYPE(src)]++;
- objspace->rcompactor.total_moved++;
-
- gc_move(objspace, src, dest, src_page->slot_size, free_page->slot_size);
- gc_pin(objspace, src);
- free_page->free_slots--;
-
- return true;
-}
-
-static void
-gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap)
-{
- struct heap_page *cursor = heap->compact_cursor;
-
- while (cursor) {
- unlock_page_body(objspace, GET_PAGE_BODY(cursor->start));
- cursor = ccan_list_next(&heap->pages, cursor, page_node);
- }
-}
-
-static void gc_update_references(rb_objspace_t * objspace);
-static void invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page);
-
-#ifndef GC_CAN_COMPILE_COMPACTION
-#if defined(__wasi__) /* WebAssembly doesn't support signals */
-# define GC_CAN_COMPILE_COMPACTION 0
-#else
-# define GC_CAN_COMPILE_COMPACTION 1
-#endif
-#endif
-
-#if defined(__MINGW32__) || defined(_WIN32)
-# define GC_COMPACTION_SUPPORTED 1
-#else
-/* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for
- * the read barrier, so we must disable compaction. */
-# define GC_COMPACTION_SUPPORTED (GC_CAN_COMPILE_COMPACTION && HEAP_PAGE_ALLOC_USE_MMAP)
-#endif
-
-#if GC_CAN_COMPILE_COMPACTION
-static void
-read_barrier_handler(uintptr_t original_address)
-{
- VALUE obj;
- rb_objspace_t * objspace = &rb_objspace;
-
- /* Calculate address aligned to slots. */
- uintptr_t address = original_address - (original_address % BASE_SLOT_SIZE);
-
- obj = (VALUE)address;
-
- struct heap_page_body *page_body = GET_PAGE_BODY(obj);
-
- /* If the page_body is NULL, then mprotect cannot handle it and will crash
- * with "Cannot allocate memory". */
- if (page_body == NULL) {
- rb_bug("read_barrier_handler: segmentation fault at %p", (void *)original_address);
- }
-
- RB_VM_LOCK_ENTER();
- {
- unlock_page_body(objspace, page_body);
-
- objspace->profile.read_barrier_faults++;
-
- invalidate_moved_page(objspace, GET_HEAP_PAGE(obj));
- }
- RB_VM_LOCK_LEAVE();
-}
-#endif
-
-#if !GC_CAN_COMPILE_COMPACTION
-static void
-uninstall_handlers(void)
-{
- /* no-op */
-}
-
-static void
-install_handlers(void)
-{
- /* no-op */
-}
-#elif defined(_WIN32)
-static LPTOP_LEVEL_EXCEPTION_FILTER old_handler;
-typedef void (*signal_handler)(int);
-static signal_handler old_sigsegv_handler;
-
-static LONG WINAPI
-read_barrier_signal(EXCEPTION_POINTERS * info)
-{
- /* EXCEPTION_ACCESS_VIOLATION is what's raised by access to protected pages */
- if (info->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
- /* > The second array element specifies the virtual address of the inaccessible data.
- * https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record
- *
- * Use this address to invalidate the page */
- read_barrier_handler((uintptr_t)info->ExceptionRecord->ExceptionInformation[1]);
- return EXCEPTION_CONTINUE_EXECUTION;
- }
- else {
- return EXCEPTION_CONTINUE_SEARCH;
- }
-}
-
-static void
-uninstall_handlers(void)
-{
- signal(SIGSEGV, old_sigsegv_handler);
- SetUnhandledExceptionFilter(old_handler);
-}
-
-static void
-install_handlers(void)
-{
- /* Remove SEGV handler so that the Unhandled Exception Filter handles it */
- old_sigsegv_handler = signal(SIGSEGV, NULL);
- /* Unhandled Exception Filter has access to the violation address similar
- * to si_addr from sigaction */
- old_handler = SetUnhandledExceptionFilter(read_barrier_signal);
-}
-#else
-static struct sigaction old_sigbus_handler;
-static struct sigaction old_sigsegv_handler;
-
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
-static exception_mask_t old_exception_masks[32];
-static mach_port_t old_exception_ports[32];
-static exception_behavior_t old_exception_behaviors[32];
-static thread_state_flavor_t old_exception_flavors[32];
-static mach_msg_type_number_t old_exception_count;
-
-static void
-disable_mach_bad_access_exc(void)
-{
- old_exception_count = sizeof(old_exception_masks) / sizeof(old_exception_masks[0]);
- task_swap_exception_ports(
- mach_task_self(), EXC_MASK_BAD_ACCESS,
- MACH_PORT_NULL, EXCEPTION_DEFAULT, 0,
- old_exception_masks, &old_exception_count,
- old_exception_ports, old_exception_behaviors, old_exception_flavors
- );
-}
-
-static void
-restore_mach_bad_access_exc(void)
-{
- for (mach_msg_type_number_t i = 0; i < old_exception_count; i++) {
- task_set_exception_ports(
- mach_task_self(),
- old_exception_masks[i], old_exception_ports[i],
- old_exception_behaviors[i], old_exception_flavors[i]
- );
- }
-}
-#endif
-
-static void
-read_barrier_signal(int sig, siginfo_t * info, void * data)
-{
- // setup SEGV/BUS handlers for errors
- struct sigaction prev_sigbus, prev_sigsegv;
- sigaction(SIGBUS, &old_sigbus_handler, &prev_sigbus);
- sigaction(SIGSEGV, &old_sigsegv_handler, &prev_sigsegv);
-
- // enable SIGBUS/SEGV
- sigset_t set, prev_set;
- sigemptyset(&set);
- sigaddset(&set, SIGBUS);
- sigaddset(&set, SIGSEGV);
- sigprocmask(SIG_UNBLOCK, &set, &prev_set);
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
- disable_mach_bad_access_exc();
-#endif
- // run handler
- read_barrier_handler((uintptr_t)info->si_addr);
-
- // reset SEGV/BUS handlers
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
- restore_mach_bad_access_exc();
-#endif
- sigaction(SIGBUS, &prev_sigbus, NULL);
- sigaction(SIGSEGV, &prev_sigsegv, NULL);
- sigprocmask(SIG_SETMASK, &prev_set, NULL);
-}
-
-static void
-uninstall_handlers(void)
-{
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
- restore_mach_bad_access_exc();
-#endif
- sigaction(SIGBUS, &old_sigbus_handler, NULL);
- sigaction(SIGSEGV, &old_sigsegv_handler, NULL);
-}
-
-static void
-install_handlers(void)
-{
- struct sigaction action;
- memset(&action, 0, sizeof(struct sigaction));
- sigemptyset(&action.sa_mask);
- action.sa_sigaction = read_barrier_signal;
- action.sa_flags = SA_SIGINFO | SA_ONSTACK;
-
- sigaction(SIGBUS, &action, &old_sigbus_handler);
- sigaction(SIGSEGV, &action, &old_sigsegv_handler);
-#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
- disable_mach_bad_access_exc();
-#endif
-}
-#endif
-
-static void
-revert_stack_objects(VALUE stack_obj, void *ctx)
-{
- rb_objspace_t * objspace = (rb_objspace_t*)ctx;
-
- if (BUILTIN_TYPE(stack_obj) == T_MOVED) {
- /* For now we'll revert the whole page if the object made it to the
- * stack. I think we can change this to move just the one object
- * back though */
- invalidate_moved_page(objspace, GET_HEAP_PAGE(stack_obj));
- }
-}
-
-static void
-revert_machine_stack_references(rb_objspace_t *objspace, VALUE v)
-{
- if (is_pointer_to_heap(objspace, (void *)v)) {
- if (BUILTIN_TYPE(v) == T_MOVED) {
- /* For now we'll revert the whole page if the object made it to the
- * stack. I think we can change this to move just the one object
- * back though */
- invalidate_moved_page(objspace, GET_HEAP_PAGE(v));
+ for (size_t i = 0; i <= T_MASK; i++) {
+ if (data.counts[i]) {
+ rb_hash_aset(hash, types[i], SIZET2NUM(data.counts[i]));
}
}
-}
-
-static void each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspace_t *, VALUE));
-
-static void
-check_stack_for_moved(rb_objspace_t *objspace)
-{
- rb_execution_context_t *ec = GET_EC();
- rb_vm_t *vm = rb_ec_vm_ptr(ec);
- rb_vm_each_stack_value(vm, revert_stack_objects, (void*)objspace);
- each_machine_stack_value(ec, revert_machine_stack_references);
-}
-
-static void gc_mode_transition(rb_objspace_t *objspace, enum gc_mode mode);
-
-static void
-gc_compact_finish(rb_objspace_t *objspace)
-{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- gc_unprotect_pages(objspace, heap);
- }
-
- uninstall_handlers();
- /* The mutator is allowed to run during incremental sweeping. T_MOVED
- * objects can get pushed on the stack and when the compaction process
- * finishes up, it may remove the read barrier before anything has a
- * chance to read from the T_MOVED address. To fix this, we scan the stack
- * then revert any moved objects that made it to the stack. */
- check_stack_for_moved(objspace);
-
- gc_update_references(objspace);
- objspace->profile.compact_count++;
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- heap->compact_cursor = NULL;
- heap->free_pages = NULL;
- heap->compact_cursor_index = 0;
- }
-
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->moved_objects = objspace->rcompactor.total_moved - record->moved_objects;
- }
- objspace->flags.during_compacting = FALSE;
-}
-
-struct gc_sweep_context {
- struct heap_page *page;
- int final_slots;
- int freed_slots;
- int empty_slots;
-};
-
-static inline void
-gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct gc_sweep_context *ctx)
-{
- struct heap_page * sweep_page = ctx->page;
- short slot_size = sweep_page->slot_size;
- short slot_bits = slot_size / BASE_SLOT_SIZE;
- GC_ASSERT(slot_bits > 0);
-
- do {
- VALUE vp = (VALUE)p;
- GC_ASSERT(vp % BASE_SLOT_SIZE == 0);
-
- asan_unpoison_object(vp, false);
- if (bitset & 1) {
- switch (BUILTIN_TYPE(vp)) {
- default: /* majority case */
- gc_report(2, objspace, "page_sweep: free %p\n", (void *)p);
-#if RGENGC_CHECK_MODE
- if (!is_full_marking(objspace)) {
- if (RVALUE_OLD_P(vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p);
- if (rgengc_remembered_sweep(objspace, vp)) rb_bug("page_sweep: %p - remembered.", (void *)p);
- }
-#endif
- if (obj_free(objspace, vp)) {
- // always add free slots back to the swept pages freelist,
- // so that if we're comapacting, we can re-use the slots
- (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, BASE_SLOT_SIZE);
- heap_page_add_freeobj(objspace, sweep_page, vp);
- gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp));
- ctx->freed_slots++;
- }
- else {
- ctx->final_slots++;
- }
- break;
-
- case T_MOVED:
- if (objspace->flags.during_compacting) {
- /* The sweep cursor shouldn't have made it to any
- * T_MOVED slots while the compact flag is enabled.
- * The sweep cursor and compact cursor move in
- * opposite directions, and when they meet references will
- * get updated and "during_compacting" should get disabled */
- rb_bug("T_MOVED shouldn't be seen until compaction is finished\n");
- }
- gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp));
- ctx->empty_slots++;
- heap_page_add_freeobj(objspace, sweep_page, vp);
- break;
- case T_ZOMBIE:
- /* already counted */
- break;
- case T_NONE:
- ctx->empty_slots++; /* already freed */
- break;
- }
- }
- p += slot_size;
- bitset >>= slot_bits;
- } while (bitset);
-}
-
-static inline void
-gc_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct gc_sweep_context *ctx)
-{
- struct heap_page *sweep_page = ctx->page;
- GC_ASSERT(SIZE_POOL_EDEN_HEAP(sweep_page->size_pool) == heap);
-
- uintptr_t p;
- bits_t *bits, bitset;
-
- gc_report(2, objspace, "page_sweep: start.\n");
-
-#if RGENGC_CHECK_MODE
- if (!objspace->flags.immediate_sweep) {
- GC_ASSERT(sweep_page->flags.before_sweep == TRUE);
- }
-#endif
- sweep_page->flags.before_sweep = FALSE;
- sweep_page->free_slots = 0;
-
- p = (uintptr_t)sweep_page->start;
- bits = sweep_page->mark_bits;
-
- int page_rvalue_count = sweep_page->total_slots * (sweep_page->slot_size / BASE_SLOT_SIZE);
- int out_of_range_bits = (NUM_IN_PAGE(p) + page_rvalue_count) % BITS_BITLENGTH;
- if (out_of_range_bits != 0) { // sizeof(RVALUE) == 64
- bits[BITMAP_INDEX(p) + page_rvalue_count / BITS_BITLENGTH] |= ~(((bits_t)1 << out_of_range_bits) - 1);
- }
-
- /* The last bitmap plane may not be used if the last plane does not
- * have enough space for the slot_size. In that case, the last plane must
- * be skipped since none of the bits will be set. */
- int bitmap_plane_count = CEILDIV(NUM_IN_PAGE(p) + page_rvalue_count, BITS_BITLENGTH);
- GC_ASSERT(bitmap_plane_count == HEAP_PAGE_BITMAP_LIMIT - 1 ||
- bitmap_plane_count == HEAP_PAGE_BITMAP_LIMIT);
-
- // Skip out of range slots at the head of the page
- bitset = ~bits[0];
- bitset >>= NUM_IN_PAGE(p);
- if (bitset) {
- gc_sweep_plane(objspace, heap, p, bitset, ctx);
- }
- p += (BITS_BITLENGTH - NUM_IN_PAGE(p)) * BASE_SLOT_SIZE;
-
- for (int i = 1; i < bitmap_plane_count; i++) {
- bitset = ~bits[i];
- if (bitset) {
- gc_sweep_plane(objspace, heap, p, bitset, ctx);
- }
- p += BITS_BITLENGTH * BASE_SLOT_SIZE;
- }
-
- if (!heap->compact_cursor) {
- gc_setup_mark_bits(sweep_page);
- }
-
-#if GC_PROFILE_MORE_DETAIL
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->removing_objects += ctx->final_slots + ctx->freed_slots;
- record->empty_objects += ctx->empty_slots;
- }
-#endif
- if (0) fprintf(stderr, "gc_sweep_page(%"PRIdSIZE"): total_slots: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
- rb_gc_count(),
- sweep_page->total_slots,
- ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
-
- sweep_page->free_slots += ctx->freed_slots + ctx->empty_slots;
- objspace->profile.total_freed_objects += ctx->freed_slots;
-
- if (heap_pages_deferred_final && !finalizing) {
- rb_thread_t *th = GET_THREAD();
- if (th) {
- gc_finalize_deferred_register(objspace);
- }
- }
-
-#if RGENGC_CHECK_MODE
- short freelist_len = 0;
- asan_unlock_freelist(sweep_page);
- RVALUE *ptr = sweep_page->freelist;
- while (ptr) {
- freelist_len++;
- ptr = ptr->as.free.next;
- }
- asan_lock_freelist(sweep_page);
- if (freelist_len != sweep_page->free_slots) {
- rb_bug("inconsistent freelist length: expected %d but was %d", sweep_page->free_slots, freelist_len);
- }
-#endif
-
- gc_report(2, objspace, "page_sweep: end.\n");
-}
-
-#if !USE_RVARGC
-/* allocate additional minimum page to work */
-static void
-gc_heap_prepare_minimum_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- if (!heap->free_pages && heap_increment(objspace, size_pool, heap) == FALSE) {
- /* there is no free after page_sweep() */
- size_pool_allocatable_pages_set(objspace, size_pool, 1);
- if (!heap_increment(objspace, size_pool, heap)) { /* can't allocate additional free objects */
- rb_memerror();
- }
- }
- }
-}
-#endif
-
-static const char *
-gc_mode_name(enum gc_mode mode)
-{
- switch (mode) {
- case gc_mode_none: return "none";
- case gc_mode_marking: return "marking";
- case gc_mode_sweeping: return "sweeping";
- case gc_mode_compacting: return "compacting";
- default: rb_bug("gc_mode_name: unknown mode: %d", (int)mode);
- }
-}
-
-static void
-gc_mode_transition(rb_objspace_t *objspace, enum gc_mode mode)
-{
-#if RGENGC_CHECK_MODE
- enum gc_mode prev_mode = gc_mode(objspace);
- switch (prev_mode) {
- case gc_mode_none: GC_ASSERT(mode == gc_mode_marking); break;
- case gc_mode_marking: GC_ASSERT(mode == gc_mode_sweeping); break;
- case gc_mode_sweeping: GC_ASSERT(mode == gc_mode_none || mode == gc_mode_compacting); break;
- case gc_mode_compacting: GC_ASSERT(mode == gc_mode_none); break;
- }
-#endif
- if (0) fprintf(stderr, "gc_mode_transition: %s->%s\n", gc_mode_name(gc_mode(objspace)), gc_mode_name(mode));
- gc_mode_set(objspace, mode);
-}
-
-static void
-heap_page_freelist_append(struct heap_page *page, RVALUE *freelist)
-{
- if (freelist) {
- asan_unlock_freelist(page);
- if (page->freelist) {
- RVALUE *p = page->freelist;
- asan_unpoison_object((VALUE)p, false);
- while (p->as.free.next) {
- RVALUE *prev = p;
- p = p->as.free.next;
- asan_poison_object((VALUE)prev);
- asan_unpoison_object((VALUE)p, false);
- }
- p->as.free.next = freelist;
- asan_poison_object((VALUE)p);
- }
- else {
- page->freelist = freelist;
- }
- asan_lock_freelist(page);
- }
-}
-
-static void
-gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
-{
- heap->sweeping_page = ccan_list_top(&heap->pages, struct heap_page, page_node);
- heap->free_pages = NULL;
- heap->pooled_pages = NULL;
- if (!objspace->flags.immediate_sweep) {
- struct heap_page *page = NULL;
-
- ccan_list_for_each(&heap->pages, page, page_node) {
- page->flags.before_sweep = TRUE;
- }
- }
-}
-
-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4
-__attribute__((noinline))
-#endif
-static void
-gc_sweep_start(rb_objspace_t *objspace)
-{
- gc_mode_transition(objspace, gc_mode_sweeping);
- objspace->rincgc.pooled_slots = 0;
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
-
- gc_sweep_start_heap(objspace, heap);
-
-#if USE_RVARGC
- /* We should call gc_sweep_finish_size_pool for size pools with no pages. */
- if (heap->sweeping_page == NULL) {
- GC_ASSERT(heap->total_pages == 0);
- GC_ASSERT(heap->total_slots == 0);
- gc_sweep_finish_size_pool(objspace, size_pool);
- }
-#endif
- }
-
- rb_ractor_t *r = NULL;
- ccan_list_for_each(&GET_VM()->ractor.set, r, vmlr_node) {
- rb_gc_ractor_newobj_cache_clear(&r->newobj_cache);
- }
-}
-
-#if USE_RVARGC
-static void
-gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
-{
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- size_t total_slots = heap->total_slots + SIZE_POOL_TOMB_HEAP(size_pool)->total_slots;
- size_t total_pages = heap->total_pages + SIZE_POOL_TOMB_HEAP(size_pool)->total_pages;
- size_t swept_slots = size_pool->freed_slots + size_pool->empty_slots;
-
- size_t min_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_min_ratio);
-
- /* If we don't have enough slots and we have pages on the tomb heap, move
- * pages from the tomb heap to the eden heap. This may prevent page
- * creation thrashing (frequently allocating and deallocting pages) and
- * GC thrashing (running GC more frequently than required). */
- struct heap_page *resurrected_page;
- while ((swept_slots < min_free_slots || swept_slots < gc_params.heap_init_slots) &&
- (resurrected_page = heap_page_resurrect(objspace, size_pool))) {
- swept_slots += resurrected_page->free_slots;
-
- heap_add_page(objspace, size_pool, heap, resurrected_page);
- heap_add_freepage(heap, resurrected_page);
- }
-
- /* Some size pools may have very few pages (or even no pages). These size pools
- * should still have allocatable pages. */
- if (min_free_slots < gc_params.heap_init_slots && swept_slots < gc_params.heap_init_slots) {
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_t extra_slots = gc_params.heap_init_slots - swept_slots;
- size_t extend_page_count = CEILDIV(extra_slots * multiple, HEAP_PAGE_OBJ_LIMIT);
- if (extend_page_count > size_pool->allocatable_pages) {
- size_pool_allocatable_pages_set(objspace, size_pool, extend_page_count);
- }
- }
-
- if (swept_slots < min_free_slots) {
- bool grow_heap = is_full_marking(objspace);
-
- if (!is_full_marking(objspace)) {
- /* The heap is a growth heap if it freed more slots than had empty
- * slots and used up all of its allocatable pages. */
- bool is_growth_heap = (size_pool->empty_slots == 0 ||
- size_pool->freed_slots > size_pool->empty_slots) &&
- size_pool->allocatable_pages == 0;
-
- if (objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE) {
- grow_heap = TRUE;
- }
- else if (is_growth_heap) { /* Only growth heaps are allowed to start a major GC. */
- objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_NOFREE;
- size_pool->force_major_gc_count++;
- }
- }
-
- if (grow_heap) {
- size_t extend_page_count = heap_extend_pages(objspace, size_pool, swept_slots, total_slots, total_pages);
-
- if (extend_page_count > size_pool->allocatable_pages) {
- size_pool_allocatable_pages_set(objspace, size_pool, extend_page_count);
- }
- }
- }
-}
-#endif
-
-static void
-gc_sweep_finish(rb_objspace_t *objspace)
-{
- gc_report(1, objspace, "gc_sweep_finish\n");
-
- gc_prof_set_heap_info(objspace);
- heap_pages_free_unused_pages(objspace);
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
-
- /* if heap_pages has unused pages, then assign them to increment */
- size_t tomb_pages = SIZE_POOL_TOMB_HEAP(size_pool)->total_pages;
- if (size_pool->allocatable_pages < tomb_pages) {
- size_pool->allocatable_pages = tomb_pages;
- }
-
-#if USE_RVARGC
- size_pool->freed_slots = 0;
- size_pool->empty_slots = 0;
-
- if (!will_be_incremental_marking(objspace)) {
- rb_heap_t *eden_heap = SIZE_POOL_EDEN_HEAP(size_pool);
- struct heap_page *end_page = eden_heap->free_pages;
- if (end_page) {
- while (end_page->free_next) end_page = end_page->free_next;
- end_page->free_next = eden_heap->pooled_pages;
- }
- else {
- eden_heap->free_pages = eden_heap->pooled_pages;
- }
- eden_heap->pooled_pages = NULL;
- objspace->rincgc.pooled_slots = 0;
- }
-#endif
- }
- heap_pages_expand_sorted(objspace);
-
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_SWEEP, 0);
- gc_mode_transition(objspace, gc_mode_none);
-
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
-}
-
-static int
-gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- struct heap_page *sweep_page = heap->sweeping_page;
- int unlink_limit = GC_SWEEP_PAGES_FREEABLE_PER_STEP;
- int swept_slots = 0;
-#if USE_RVARGC
- bool need_pool = TRUE;
-#else
- int need_pool = will_be_incremental_marking(objspace) ? TRUE : FALSE;
-#endif
-
- gc_report(2, objspace, "gc_sweep_step (need_pool: %d)\n", need_pool);
-
- if (sweep_page == NULL) return FALSE;
-
-#if GC_ENABLE_LAZY_SWEEP
- gc_prof_sweep_timer_start(objspace);
-#endif
-
- do {
- RUBY_DEBUG_LOG("sweep_page:%p", (void *)sweep_page);
-
- struct gc_sweep_context ctx = {
- .page = sweep_page,
- .final_slots = 0,
- .freed_slots = 0,
- .empty_slots = 0,
- };
- gc_sweep_page(objspace, heap, &ctx);
- int free_slots = ctx.freed_slots + ctx.empty_slots;
-
- heap->sweeping_page = ccan_list_next(&heap->pages, sweep_page, page_node);
-
- if (sweep_page->final_slots + free_slots == sweep_page->total_slots &&
- heap_pages_freeable_pages > 0 &&
- unlink_limit > 0) {
- heap_pages_freeable_pages--;
- unlink_limit--;
- /* there are no living objects -> move this page to tomb heap */
- heap_unlink_page(objspace, heap, sweep_page);
- heap_add_page(objspace, size_pool, SIZE_POOL_TOMB_HEAP(size_pool), sweep_page);
- }
- else if (free_slots > 0) {
-#if USE_RVARGC
- size_pool->freed_slots += ctx.freed_slots;
- size_pool->empty_slots += ctx.empty_slots;
-#endif
-
- if (need_pool) {
- heap_add_poolpage(objspace, heap, sweep_page);
- need_pool = FALSE;
- }
- else {
- heap_add_freepage(heap, sweep_page);
- swept_slots += free_slots;
- if (swept_slots > GC_INCREMENTAL_SWEEP_SLOT_COUNT) {
- break;
- }
- }
- }
- else {
- sweep_page->free_next = NULL;
- }
- } while ((sweep_page = heap->sweeping_page));
-
- if (!heap->sweeping_page) {
-#if USE_RVARGC
- gc_sweep_finish_size_pool(objspace, size_pool);
-#endif
-
- if (!has_sweeping_pages(objspace)) {
- gc_sweep_finish(objspace);
- }
- }
-
-#if GC_ENABLE_LAZY_SWEEP
- gc_prof_sweep_timer_stop(objspace);
-#endif
-
- return heap->free_pages != NULL;
-}
-
-static void
-gc_sweep_rest(rb_objspace_t *objspace)
-{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
-
- while (SIZE_POOL_EDEN_HEAP(size_pool)->sweeping_page) {
- gc_sweep_step(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
- }
- }
-}
-
-static void
-gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *sweep_size_pool, rb_heap_t *heap)
-{
- GC_ASSERT(dont_gc_val() == FALSE);
- if (!GC_ENABLE_LAZY_SWEEP) return;
-
- gc_sweeping_enter(objspace);
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- if (!gc_sweep_step(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool))) {
-#if USE_RVARGC
- /* sweep_size_pool requires a free slot but sweeping did not yield any. */
- if (size_pool == sweep_size_pool) {
- if (size_pool->allocatable_pages > 0) {
- heap_increment(objspace, size_pool, heap);
- }
- else {
- /* Not allowed to create a new page so finish sweeping. */
- gc_sweep_rest(objspace);
- break;
- }
- }
-#endif
- }
- }
-
- gc_sweeping_exit(objspace);
-}
-
-static void
-invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_t p, bits_t bitset)
-{
- if (bitset) {
- do {
- if (bitset & 1) {
- VALUE forwarding_object = (VALUE)p;
- VALUE object;
-
- if (BUILTIN_TYPE(forwarding_object) == T_MOVED) {
- GC_ASSERT(MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(forwarding_object), forwarding_object));
- GC_ASSERT(!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(forwarding_object), forwarding_object));
-
- CLEAR_IN_BITMAP(GET_HEAP_PINNED_BITS(forwarding_object), forwarding_object);
-
- object = rb_gc_location(forwarding_object);
-
- shape_id_t original_shape_id = 0;
- if (RB_TYPE_P(object, T_OBJECT)) {
- original_shape_id = RMOVED(forwarding_object)->original_shape_id;
- }
-
- gc_move(objspace, object, forwarding_object, GET_HEAP_PAGE(object)->slot_size, page->slot_size);
- /* forwarding_object is now our actual object, and "object"
- * is the free slot for the original page */
-
- if (original_shape_id) {
- ROBJECT_SET_SHAPE_ID(forwarding_object, original_shape_id);
- }
-
- struct heap_page *orig_page = GET_HEAP_PAGE(object);
- orig_page->free_slots++;
- heap_page_add_freeobj(objspace, orig_page, object);
-
- GC_ASSERT(MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(forwarding_object), forwarding_object));
- GC_ASSERT(BUILTIN_TYPE(forwarding_object) != T_MOVED);
- GC_ASSERT(BUILTIN_TYPE(forwarding_object) != T_NONE);
- }
- }
- p += BASE_SLOT_SIZE;
- bitset >>= 1;
- } while (bitset);
- }
-}
-
-static void
-invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page)
-{
- int i;
- bits_t *mark_bits, *pin_bits;
- bits_t bitset;
-
- mark_bits = page->mark_bits;
- pin_bits = page->pinned_bits;
-
- uintptr_t p = page->start;
-
- // Skip out of range slots at the head of the page
- bitset = pin_bits[0] & ~mark_bits[0];
- bitset >>= NUM_IN_PAGE(p);
- invalidate_moved_plane(objspace, page, p, bitset);
- p += (BITS_BITLENGTH - NUM_IN_PAGE(p)) * BASE_SLOT_SIZE;
-
- for (i=1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
- /* Moved objects are pinned but never marked. We reuse the pin bits
- * to indicate there is a moved object in this slot. */
- bitset = pin_bits[i] & ~mark_bits[i];
-
- invalidate_moved_plane(objspace, page, p, bitset);
- p += BITS_BITLENGTH * BASE_SLOT_SIZE;
- }
-}
-
-static void
-gc_compact_start(rb_objspace_t *objspace)
-{
- struct heap_page *page = NULL;
- gc_mode_transition(objspace, gc_mode_compacting);
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(&size_pools[i]);
- ccan_list_for_each(&heap->pages, page, page_node) {
- page->flags.before_sweep = TRUE;
- }
-
- heap->compact_cursor = ccan_list_tail(&heap->pages, struct heap_page, page_node);
- heap->compact_cursor_index = 0;
- }
-
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->moved_objects = objspace->rcompactor.total_moved;
- }
-
- memset(objspace->rcompactor.considered_count_table, 0, T_MASK * sizeof(size_t));
- memset(objspace->rcompactor.moved_count_table, 0, T_MASK * sizeof(size_t));
- memset(objspace->rcompactor.moved_up_count_table, 0, T_MASK * sizeof(size_t));
- memset(objspace->rcompactor.moved_down_count_table, 0, T_MASK * sizeof(size_t));
-
- /* Set up read barrier for pages containing MOVED objects */
- install_handlers();
-}
-
-static void gc_sweep_compact(rb_objspace_t *objspace);
-
-static void
-gc_sweep(rb_objspace_t *objspace)
-{
- gc_sweeping_enter(objspace);
-
- const unsigned int immediate_sweep = objspace->flags.immediate_sweep;
-
- gc_report(1, objspace, "gc_sweep: immediate: %d\n", immediate_sweep);
-
- gc_sweep_start(objspace);
- if (objspace->flags.during_compacting) {
- gc_sweep_compact(objspace);
- }
-
- if (immediate_sweep) {
-#if !GC_ENABLE_LAZY_SWEEP
- gc_prof_sweep_timer_start(objspace);
-#endif
- gc_sweep_rest(objspace);
-#if !GC_ENABLE_LAZY_SWEEP
- gc_prof_sweep_timer_stop(objspace);
-#endif
- }
- else {
-
- /* Sweep every size pool. */
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- gc_sweep_step(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
- }
- }
-
-#if !USE_RVARGC
- rb_size_pool_t *size_pool = &size_pools[0];
- gc_heap_prepare_minimum_pages(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
-#endif
-
- gc_sweeping_exit(objspace);
-}
-
-/* Marking - Marking stack */
-
-static stack_chunk_t *
-stack_chunk_alloc(void)
-{
- stack_chunk_t *res;
-
- res = malloc(sizeof(stack_chunk_t));
- if (!res)
- rb_memerror();
-
- return res;
-}
-
-static inline int
-is_mark_stack_empty(mark_stack_t *stack)
-{
- return stack->chunk == NULL;
-}
-
-static size_t
-mark_stack_size(mark_stack_t *stack)
-{
- size_t size = stack->index;
- stack_chunk_t *chunk = stack->chunk ? stack->chunk->next : NULL;
-
- while (chunk) {
- size += stack->limit;
- chunk = chunk->next;
- }
- return size;
-}
-
-static void
-add_stack_chunk_cache(mark_stack_t *stack, stack_chunk_t *chunk)
-{
- chunk->next = stack->cache;
- stack->cache = chunk;
- stack->cache_size++;
-}
-
-static void
-shrink_stack_chunk_cache(mark_stack_t *stack)
-{
- stack_chunk_t *chunk;
-
- if (stack->unused_cache_size > (stack->cache_size/2)) {
- chunk = stack->cache;
- stack->cache = stack->cache->next;
- stack->cache_size--;
- free(chunk);
- }
- stack->unused_cache_size = stack->cache_size;
-}
-
-static void
-push_mark_stack_chunk(mark_stack_t *stack)
-{
- stack_chunk_t *next;
-
- GC_ASSERT(stack->index == stack->limit);
-
- if (stack->cache_size > 0) {
- next = stack->cache;
- stack->cache = stack->cache->next;
- stack->cache_size--;
- if (stack->unused_cache_size > stack->cache_size)
- stack->unused_cache_size = stack->cache_size;
- }
- else {
- next = stack_chunk_alloc();
- }
- next->next = stack->chunk;
- stack->chunk = next;
- stack->index = 0;
-}
-
-static void
-pop_mark_stack_chunk(mark_stack_t *stack)
-{
- stack_chunk_t *prev;
-
- prev = stack->chunk->next;
- GC_ASSERT(stack->index == 0);
- add_stack_chunk_cache(stack, stack->chunk);
- stack->chunk = prev;
- stack->index = stack->limit;
-}
-
-static void
-mark_stack_chunk_list_free(stack_chunk_t *chunk)
-{
- stack_chunk_t *next = NULL;
-
- while (chunk != NULL) {
- next = chunk->next;
- free(chunk);
- chunk = next;
- }
-}
-
-static void
-free_stack_chunks(mark_stack_t *stack)
-{
- mark_stack_chunk_list_free(stack->chunk);
-}
-
-static void
-mark_stack_free_cache(mark_stack_t *stack)
-{
- mark_stack_chunk_list_free(stack->cache);
- stack->cache_size = 0;
- stack->unused_cache_size = 0;
-}
-
-static void
-push_mark_stack(mark_stack_t *stack, VALUE data)
-{
- VALUE obj = data;
- switch (BUILTIN_TYPE(obj)) {
- case T_OBJECT:
- case T_CLASS:
- case T_MODULE:
- case T_FLOAT:
- case T_STRING:
- case T_REGEXP:
- case T_ARRAY:
- case T_HASH:
- case T_STRUCT:
- case T_BIGNUM:
- case T_FILE:
- case T_DATA:
- case T_MATCH:
- case T_COMPLEX:
- case T_RATIONAL:
- case T_TRUE:
- case T_FALSE:
- case T_SYMBOL:
- case T_IMEMO:
- case T_ICLASS:
- if (stack->index == stack->limit) {
- push_mark_stack_chunk(stack);
- }
- stack->chunk->data[stack->index++] = data;
- return;
-
- case T_NONE:
- case T_NIL:
- case T_FIXNUM:
- case T_MOVED:
- case T_ZOMBIE:
- case T_UNDEF:
- case T_MASK:
- rb_bug("push_mark_stack() called for broken object");
- break;
-
- case T_NODE:
- UNEXPECTED_NODE(push_mark_stack);
- break;
- }
-
- rb_bug("rb_gc_mark(): unknown data type 0x%x(%p) %s",
- BUILTIN_TYPE(obj), (void *)data,
- is_pointer_to_heap(&rb_objspace, (void *)data) ? "corrupted object" : "non object");
-}
-
-static int
-pop_mark_stack(mark_stack_t *stack, VALUE *data)
-{
- if (is_mark_stack_empty(stack)) {
- return FALSE;
- }
- if (stack->index == 1) {
- *data = stack->chunk->data[--stack->index];
- pop_mark_stack_chunk(stack);
- }
- else {
- *data = stack->chunk->data[--stack->index];
- }
- return TRUE;
-}
-
-static void
-init_mark_stack(mark_stack_t *stack)
-{
- int i;
-
- MEMZERO(stack, mark_stack_t, 1);
- stack->index = stack->limit = STACK_CHUNK_SIZE;
-
- for (i=0; i < 4; i++) {
- add_stack_chunk_cache(stack, stack_chunk_alloc());
- }
- stack->unused_cache_size = stack->cache_size;
+ return hash;
}
-/* Marking */
-
#define SET_STACK_END SET_MACHINE_STACK_END(&ec->machine.stack_end)
#define STACK_START (ec->machine.stack_start)
@@ -6509,261 +2861,192 @@ ruby_stack_check(void)
return stack_check(GET_EC(), STACKFRAME_FOR_CALL_CFUNC);
}
-ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(static void each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void (*cb)(rb_objspace_t *, VALUE)));
-static void
-each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void (*cb)(rb_objspace_t *, VALUE))
+/* ==================== Marking ==================== */
+
+#define RB_GC_MARK_OR_TRAVERSE(func, obj_or_ptr, obj, check_obj) do { \
+ if (!RB_SPECIAL_CONST_P(obj)) { \
+ rb_vm_t *vm = GET_VM(); \
+ void *objspace = vm->gc.objspace; \
+ if (LIKELY(vm->gc.mark_func_data == NULL)) { \
+ GC_ASSERT(rb_gc_impl_during_gc_p(objspace)); \
+ (func)(objspace, (obj_or_ptr)); \
+ } \
+ else if (check_obj ? \
+ rb_gc_impl_pointer_to_heap_p(objspace, (const void *)obj) && \
+ !rb_gc_impl_garbage_object_p(objspace, obj) : \
+ true) { \
+ GC_ASSERT(!rb_gc_impl_during_gc_p(objspace)); \
+ struct gc_mark_func_data_struct *mark_func_data = vm->gc.mark_func_data; \
+ vm->gc.mark_func_data = NULL; \
+ mark_func_data->mark_func((obj), mark_func_data->data); \
+ vm->gc.mark_func_data = mark_func_data; \
+ } \
+ } \
+} while (0)
+
+static inline void
+gc_mark_internal(VALUE obj)
{
- VALUE v;
- while (n--) {
- v = *x;
- cb(objspace, v);
- x++;
- }
+ RB_GC_MARK_OR_TRAVERSE(rb_gc_impl_mark, obj, obj, false);
}
-static void
-gc_mark_locations(rb_objspace_t *objspace, const VALUE *start, const VALUE *end, void (*cb)(rb_objspace_t *, VALUE))
+void
+rb_gc_mark_movable(VALUE obj)
{
- long n;
-
- if (end <= start) return;
- n = end - start;
- each_location(objspace, start, n, cb);
+ gc_mark_internal(obj);
}
void
-rb_gc_mark_locations(const VALUE *start, const VALUE *end)
+rb_gc_mark_and_move(VALUE *ptr)
{
- gc_mark_locations(&rb_objspace, start, end, gc_mark_maybe);
+ RB_GC_MARK_OR_TRAVERSE(rb_gc_impl_mark_and_move, ptr, *ptr, false);
}
-static void
-gc_mark_values(rb_objspace_t *objspace, long n, const VALUE *values)
+static inline void
+gc_mark_and_pin_internal(VALUE obj)
{
- long i;
-
- for (i=0; i<n; i++) {
- gc_mark(objspace, values[i]);
- }
+ RB_GC_MARK_OR_TRAVERSE(rb_gc_impl_mark_and_pin, obj, obj, false);
}
void
-rb_gc_mark_values(long n, const VALUE *values)
+rb_gc_mark(VALUE obj)
{
- long i;
- rb_objspace_t *objspace = &rb_objspace;
-
- for (i=0; i<n; i++) {
- gc_mark_and_pin(objspace, values[i]);
- }
+ gc_mark_and_pin_internal(obj);
}
-static void
-gc_mark_stack_values(rb_objspace_t *objspace, long n, const VALUE *values)
+static inline void
+gc_mark_maybe_internal(VALUE obj)
{
- long i;
-
- for (i=0; i<n; i++) {
- if (is_markable_object(objspace, values[i])) {
- gc_mark_and_pin(objspace, values[i]);
- }
- }
+ RB_GC_MARK_OR_TRAVERSE(rb_gc_impl_mark_maybe, obj, obj, true);
}
void
-rb_gc_mark_vm_stack_values(long n, const VALUE *values)
+rb_gc_mark_maybe(VALUE obj)
{
- rb_objspace_t *objspace = &rb_objspace;
- gc_mark_stack_values(objspace, n, values);
+ gc_mark_maybe_internal(obj);
}
-static int
-mark_value(st_data_t key, st_data_t value, st_data_t data)
+ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(static void each_location(register const VALUE *x, register long n, void (*cb)(VALUE, void *), void *data));
+static void
+each_location(register const VALUE *x, register long n, void (*cb)(VALUE, void *), void *data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark(objspace, (VALUE)value);
- return ST_CONTINUE;
+ VALUE v;
+ while (n--) {
+ v = *x;
+ cb(v, data);
+ x++;
+ }
}
-static int
-mark_value_pin(st_data_t key, st_data_t value, st_data_t data)
+static void
+each_location_ptr(const VALUE *start, const VALUE *end, void (*cb)(VALUE, void *), void *data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark_and_pin(objspace, (VALUE)value);
- return ST_CONTINUE;
+ if (end <= start) return;
+ each_location(start, end - start, cb, data);
}
static void
-mark_tbl_no_pin(rb_objspace_t *objspace, st_table *tbl)
+gc_mark_maybe_each_location(VALUE obj, void *data)
{
- if (!tbl || tbl->num_entries == 0) return;
- st_foreach(tbl, mark_value, (st_data_t)objspace);
+ gc_mark_maybe_internal(obj);
}
-static void
-mark_tbl(rb_objspace_t *objspace, st_table *tbl)
+void
+rb_gc_mark_locations(const VALUE *start, const VALUE *end)
{
- if (!tbl || tbl->num_entries == 0) return;
- st_foreach(tbl, mark_value_pin, (st_data_t)objspace);
+ each_location_ptr(start, end, gc_mark_maybe_each_location, NULL);
}
-static int
-mark_key(st_data_t key, st_data_t value, st_data_t data)
+void
+rb_gc_mark_values(long n, const VALUE *values)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark_and_pin(objspace, (VALUE)key);
- return ST_CONTINUE;
+ for (long i = 0; i < n; i++) {
+ gc_mark_internal(values[i]);
+ }
}
-static void
-mark_set(rb_objspace_t *objspace, st_table *tbl)
+void
+rb_gc_mark_vm_stack_values(long n, const VALUE *values)
{
- if (!tbl) return;
- st_foreach(tbl, mark_key, (st_data_t)objspace);
+ for (long i = 0; i < n; i++) {
+ gc_mark_and_pin_internal(values[i]);
+ }
}
static int
-pin_value(st_data_t key, st_data_t value, st_data_t data)
+mark_key(st_data_t key, st_data_t value, st_data_t data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- gc_mark_and_pin(objspace, (VALUE)value);
- return ST_CONTINUE;
-}
+ gc_mark_and_pin_internal((VALUE)key);
-static void
-mark_finalizer_tbl(rb_objspace_t *objspace, st_table *tbl)
-{
- if (!tbl) return;
- st_foreach(tbl, pin_value, (st_data_t)objspace);
+ return ST_CONTINUE;
}
void
rb_mark_set(st_table *tbl)
{
- mark_set(&rb_objspace, tbl);
+ if (!tbl) return;
+
+ st_foreach(tbl, mark_key, (st_data_t)rb_gc_get_objspace());
}
static int
mark_keyvalue(st_data_t key, st_data_t value, st_data_t data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
+ gc_mark_internal((VALUE)key);
+ gc_mark_internal((VALUE)value);
- gc_mark(objspace, (VALUE)key);
- gc_mark(objspace, (VALUE)value);
return ST_CONTINUE;
}
static int
pin_key_pin_value(st_data_t key, st_data_t value, st_data_t data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
+ gc_mark_and_pin_internal((VALUE)key);
+ gc_mark_and_pin_internal((VALUE)value);
- gc_mark_and_pin(objspace, (VALUE)key);
- gc_mark_and_pin(objspace, (VALUE)value);
return ST_CONTINUE;
}
static int
pin_key_mark_value(st_data_t key, st_data_t value, st_data_t data)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
+ gc_mark_and_pin_internal((VALUE)key);
+ gc_mark_internal((VALUE)value);
- gc_mark_and_pin(objspace, (VALUE)key);
- gc_mark(objspace, (VALUE)value);
return ST_CONTINUE;
}
static void
-mark_hash(rb_objspace_t *objspace, VALUE hash)
+mark_hash(VALUE hash)
{
if (rb_hash_compare_by_id_p(hash)) {
- rb_hash_stlike_foreach(hash, pin_key_mark_value, (st_data_t)objspace);
- }
- else {
- rb_hash_stlike_foreach(hash, mark_keyvalue, (st_data_t)objspace);
- }
-
- if (RHASH_AR_TABLE_P(hash)) {
- if (LIKELY(during_gc) && RHASH_TRANSIENT_P(hash)) {
- rb_transient_heap_mark(hash, RHASH_AR_TABLE(hash));
- }
+ rb_hash_stlike_foreach(hash, pin_key_mark_value, 0);
}
else {
- VM_ASSERT(!RHASH_TRANSIENT_P(hash));
+ rb_hash_stlike_foreach(hash, mark_keyvalue, 0);
}
- gc_mark(objspace, RHASH(hash)->ifnone);
-}
-static void
-mark_st(rb_objspace_t *objspace, st_table *tbl)
-{
- if (!tbl) return;
- st_foreach(tbl, pin_key_pin_value, (st_data_t)objspace);
+ gc_mark_internal(RHASH(hash)->ifnone);
}
void
rb_mark_hash(st_table *tbl)
{
- mark_st(&rb_objspace, tbl);
-}
-
-static void
-mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
-{
- const rb_method_definition_t *def = me->def;
-
- gc_mark(objspace, me->owner);
- gc_mark(objspace, me->defined_class);
-
- if (def) {
- switch (def->type) {
- case VM_METHOD_TYPE_ISEQ:
- if (def->body.iseq.iseqptr) gc_mark(objspace, (VALUE)def->body.iseq.iseqptr);
- gc_mark(objspace, (VALUE)def->body.iseq.cref);
+ if (!tbl) return;
- if (def->iseq_overload && me->defined_class) {
- // it can be a key of "overloaded_cme" table
- // so it should be pinned.
- gc_mark_and_pin(objspace, (VALUE)me);
- }
- break;
- case VM_METHOD_TYPE_ATTRSET:
- case VM_METHOD_TYPE_IVAR:
- gc_mark(objspace, def->body.attr.location);
- break;
- case VM_METHOD_TYPE_BMETHOD:
- gc_mark(objspace, def->body.bmethod.proc);
- if (def->body.bmethod.hooks) rb_hook_list_mark(def->body.bmethod.hooks);
- break;
- case VM_METHOD_TYPE_ALIAS:
- gc_mark(objspace, (VALUE)def->body.alias.original_me);
- return;
- case VM_METHOD_TYPE_REFINED:
- gc_mark(objspace, (VALUE)def->body.refined.orig_me);
- gc_mark(objspace, (VALUE)def->body.refined.owner);
- break;
- case VM_METHOD_TYPE_CFUNC:
- case VM_METHOD_TYPE_ZSUPER:
- case VM_METHOD_TYPE_MISSING:
- case VM_METHOD_TYPE_OPTIMIZED:
- case VM_METHOD_TYPE_UNDEF:
- case VM_METHOD_TYPE_NOTIMPLEMENTED:
- break;
- }
- }
+ st_foreach(tbl, pin_key_pin_value, 0);
}
static enum rb_id_table_iterator_result
-mark_method_entry_i(VALUE me, void *data)
+mark_method_entry_i(VALUE me, void *objspace)
{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
+ gc_mark_internal(me);
- gc_mark(objspace, me);
return ID_TABLE_CONTINUE;
}
static void
-mark_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
+mark_m_tbl(void *objspace, struct rb_id_table *tbl)
{
if (tbl) {
rb_id_table_foreach_values(tbl, mark_method_entry_i, objspace);
@@ -6771,13 +3054,14 @@ mark_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
}
static enum rb_id_table_iterator_result
-mark_const_entry_i(VALUE value, void *data)
+mark_const_entry_i(VALUE value, void *objspace)
{
const rb_const_entry_t *ce = (const rb_const_entry_t *)value;
- rb_objspace_t *objspace = data;
- gc_mark(objspace, ce->value);
- gc_mark(objspace, ce->file);
+ if (!rb_gc_checking_shareable()) {
+ gc_mark_internal(ce->value);
+ gc_mark_internal(ce->file); // TODO: ce->file should be shareable?
+ }
return ID_TABLE_CONTINUE;
}
@@ -6798,8 +3082,53 @@ mark_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
((start) = STACK_END, (end) = STACK_START) : ((start) = STACK_START, (end) = STACK_END+(appendix)))
#endif
-static void each_stack_location(rb_objspace_t *objspace, const rb_execution_context_t *ec,
- const VALUE *stack_start, const VALUE *stack_end, void (*cb)(rb_objspace_t *, VALUE));
+static void
+gc_mark_machine_stack_location_maybe(VALUE obj, void *data)
+{
+ gc_mark_maybe_internal(obj);
+
+#ifdef RUBY_ASAN_ENABLED
+ const rb_execution_context_t *ec = (const rb_execution_context_t *)data;
+ void *fake_frame_start;
+ void *fake_frame_end;
+ bool is_fake_frame = asan_get_fake_stack_extents(
+ ec->machine.asan_fake_stack_handle, obj,
+ ec->machine.stack_start, ec->machine.stack_end,
+ &fake_frame_start, &fake_frame_end
+ );
+ if (is_fake_frame) {
+ each_location_ptr(fake_frame_start, fake_frame_end, gc_mark_maybe_each_location, NULL);
+ }
+#endif
+}
+
+static bool
+gc_object_moved_p_internal(void *objspace, VALUE obj)
+{
+ if (SPECIAL_CONST_P(obj)) {
+ return false;
+ }
+
+ return rb_gc_impl_object_moved_p(objspace, obj);
+}
+
+static VALUE
+gc_location_internal(void *objspace, VALUE value)
+{
+ if (SPECIAL_CONST_P(value)) {
+ return value;
+ }
+
+ GC_ASSERT(rb_gc_impl_pointer_to_heap_p(objspace, (void *)value));
+
+ return rb_gc_impl_location(objspace, value);
+}
+
+VALUE
+rb_gc_location(VALUE value)
+{
+ return gc_location_internal(rb_gc_get_objspace(), value);
+}
#if defined(__wasm__)
@@ -6813,450 +3142,259 @@ rb_mark_locations(void *begin, void *end)
rb_stack_range_tmp[1] = end;
}
+void
+rb_gc_save_machine_context(void)
+{
+ // no-op
+}
+
# if defined(__EMSCRIPTEN__)
static void
-mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec)
+mark_current_machine_context(const rb_execution_context_t *ec)
{
emscripten_scan_stack(rb_mark_locations);
- each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe);
+ each_location_ptr(rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_each_location, NULL);
emscripten_scan_registers(rb_mark_locations);
- each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe);
+ each_location_ptr(rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_each_location, NULL);
}
# else // use Asyncify version
static void
-mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec)
+mark_current_machine_context(rb_execution_context_t *ec)
{
VALUE *stack_start, *stack_end;
SET_STACK_END;
GET_STACK_BOUNDS(stack_start, stack_end, 1);
- each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe);
+ each_location_ptr(stack_start, stack_end, gc_mark_maybe_each_location, NULL);
rb_wasm_scan_locals(rb_mark_locations);
- each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe);
+ each_location_ptr(rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_each_location, NULL);
}
# endif
#else // !defined(__wasm__)
-static void
-mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec)
+void
+rb_gc_save_machine_context(void)
{
- union {
- rb_jmp_buf j;
- VALUE v[sizeof(rb_jmp_buf) / (sizeof(VALUE))];
- } save_regs_gc_mark;
- VALUE *stack_start, *stack_end;
-
- FLUSH_REGISTER_WINDOWS;
- memset(&save_regs_gc_mark, 0, sizeof(save_regs_gc_mark));
- /* This assumes that all registers are saved into the jmp_buf (and stack) */
- rb_setjmp(save_regs_gc_mark.j);
+ rb_thread_t *thread = GET_THREAD();
- /* SET_STACK_END must be called in this function because
- * the stack frame of this function may contain
- * callee save registers and they should be marked. */
- SET_STACK_END;
- GET_STACK_BOUNDS(stack_start, stack_end, 1);
+ RB_VM_SAVE_MACHINE_CONTEXT(thread);
+}
- each_location(objspace, save_regs_gc_mark.v, numberof(save_regs_gc_mark.v), gc_mark_maybe);
- each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe);
+static void
+mark_current_machine_context(const rb_execution_context_t *ec)
+{
+ rb_gc_mark_machine_context(ec);
}
#endif
-static void
-each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspace_t *, VALUE))
+void
+rb_gc_mark_machine_context(const rb_execution_context_t *ec)
{
- rb_objspace_t *objspace = &rb_objspace;
VALUE *stack_start, *stack_end;
GET_STACK_BOUNDS(stack_start, stack_end, 0);
- each_stack_location(objspace, ec, stack_start, stack_end, cb);
-}
+ RUBY_DEBUG_LOG("ec->th:%u stack_start:%p stack_end:%p", rb_ec_thread_ptr(ec)->serial, stack_start, stack_end);
-void
-rb_gc_mark_machine_stack(const rb_execution_context_t *ec)
-{
- each_machine_stack_value(ec, gc_mark_maybe);
+ void *data =
+#ifdef RUBY_ASAN_ENABLED
+ /* gc_mark_machine_stack_location_maybe() uses data as const */
+ (rb_execution_context_t *)ec;
+#else
+ NULL;
+#endif
+
+ each_location_ptr(stack_start, stack_end, gc_mark_machine_stack_location_maybe, data);
+ int num_regs = sizeof(ec->machine.regs)/(sizeof(VALUE));
+ each_location((VALUE*)&ec->machine.regs, num_regs, gc_mark_machine_stack_location_maybe, data);
}
-static void
-each_stack_location(rb_objspace_t *objspace, const rb_execution_context_t *ec,
- const VALUE *stack_start, const VALUE *stack_end, void (*cb)(rb_objspace_t *, VALUE))
+static int
+rb_mark_tbl_i(st_data_t key, st_data_t value, st_data_t data)
{
+ gc_mark_and_pin_internal((VALUE)value);
- gc_mark_locations(objspace, stack_start, stack_end, cb);
-
-#if defined(__mc68000__)
- gc_mark_locations(objspace,
- (VALUE*)((char*)stack_start + 2),
- (VALUE*)((char*)stack_end - 2), cb);
-#endif
+ return ST_CONTINUE;
}
void
rb_mark_tbl(st_table *tbl)
{
- mark_tbl(&rb_objspace, tbl);
-}
+ if (!tbl || tbl->num_entries == 0) return;
-void
-rb_mark_tbl_no_pin(st_table *tbl)
-{
- mark_tbl_no_pin(&rb_objspace, tbl);
+ st_foreach(tbl, rb_mark_tbl_i, 0);
}
static void
-gc_mark_maybe(rb_objspace_t *objspace, VALUE obj)
+gc_mark_tbl_no_pin(st_table *tbl)
{
- (void)VALGRIND_MAKE_MEM_DEFINED(&obj, sizeof(obj));
-
- if (is_pointer_to_heap(objspace, (void *)obj)) {
- void *ptr = asan_unpoison_object_temporary(obj);
-
- /* Garbage can live on the stack, so do not mark or pin */
- switch (BUILTIN_TYPE(obj)) {
- case T_ZOMBIE:
- case T_NONE:
- break;
- default:
- gc_mark_and_pin(objspace, obj);
- break;
- }
+ if (!tbl || tbl->num_entries == 0) return;
- if (ptr) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
- }
- }
+ st_foreach(tbl, gc_mark_tbl_no_pin_i, 0);
}
void
-rb_gc_mark_maybe(VALUE obj)
+rb_mark_tbl_no_pin(st_table *tbl)
{
- gc_mark_maybe(&rb_objspace, obj);
+ gc_mark_tbl_no_pin(tbl);
}
-static inline int
-gc_mark_set(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_mark_set_no_pin(st_table *tbl)
{
- ASSERT_vm_locking();
- if (RVALUE_MARKED(obj)) return 0;
- MARK_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj);
- return 1;
+ if (!tbl || tbl->num_entries == 0) return;
+
+ st_foreach(tbl, gc_mark_set_no_pin_i, 0);
}
-static int
-gc_remember_unprotected(rb_objspace_t *objspace, VALUE obj)
+static bool
+gc_declarative_marking_p(const rb_data_type_t *type)
{
- struct heap_page *page = GET_HEAP_PAGE(obj);
- bits_t *uncollectible_bits = &page->uncollectible_bits[0];
+ return (type->flags & RUBY_TYPED_DECL_MARKING) != 0;
+}
- if (!MARKED_IN_BITMAP(uncollectible_bits, obj)) {
- page->flags.has_uncollectible_shady_objects = TRUE;
- MARK_IN_BITMAP(uncollectible_bits, obj);
- objspace->rgengc.uncollectible_wb_unprotected_objects++;
+rb_execution_context_t *
+rb_gc_get_ec(void)
+{
+ void *objspace = rb_gc_get_objspace();
-#if RGENGC_PROFILE > 0
- objspace->profile.total_remembered_shady_object_count++;
-#if RGENGC_PROFILE >= 2
- objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++;
-#endif
-#endif
- return TRUE;
+ if (RB_LIKELY(rb_gc_impl_during_gc_p(objspace))) {
+ return rb_gc_impl_get_vm_context(objspace)->ec;
}
else {
- return FALSE;
+ return GET_EC();
}
}
-static void
-rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_mark_roots(void *objspace, const char **categoryp)
{
- const VALUE old_parent = objspace->rgengc.parent_object;
+ rb_execution_context_t *ec = rb_gc_get_ec();
+ rb_vm_t *vm = rb_ec_vm_ptr(ec);
- if (old_parent) { /* parent object is old */
- if (RVALUE_WB_UNPROTECTED(obj)) {
- if (gc_remember_unprotected(objspace, obj)) {
- gc_report(2, objspace, "relation: (O->S) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- }
- }
- else {
- if (!RVALUE_OLD_P(obj)) {
- if (RVALUE_MARKED(obj)) {
- /* An object pointed from an OLD object should be OLD. */
- gc_report(2, objspace, "relation: (O->unmarked Y) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- RVALUE_AGE_SET_OLD(objspace, obj);
- if (is_incremental_marking(objspace)) {
- if (!RVALUE_MARKING(obj)) {
- gc_grey(objspace, obj);
- }
- }
- else {
- rgengc_remember(objspace, obj);
- }
- }
- else {
- gc_report(2, objspace, "relation: (O->Y) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- RVALUE_AGE_SET_CANDIDATE(objspace, obj);
- }
- }
- }
- }
+#define MARK_CHECKPOINT(category) do { \
+ if (categoryp) *categoryp = category; \
+} while (0)
- GC_ASSERT(old_parent == objspace->rgengc.parent_object);
-}
+ MARK_CHECKPOINT("vm");
+ rb_vm_mark(vm);
-static void
-gc_grey(rb_objspace_t *objspace, VALUE obj)
-{
-#if RGENGC_CHECK_MODE
- if (RVALUE_MARKED(obj) == FALSE) rb_bug("gc_grey: %s is not marked.", obj_info(obj));
- if (RVALUE_MARKING(obj) == TRUE) rb_bug("gc_grey: %s is marking/remembered.", obj_info(obj));
-#endif
+ MARK_CHECKPOINT("end_proc");
+ rb_mark_end_proc();
+
+ MARK_CHECKPOINT("global_tbl");
+ rb_gc_mark_global_tbl();
+
+#if USE_YJIT
+ void rb_yjit_root_mark(void); // in Rust
- if (is_incremental_marking(objspace)) {
- MARK_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
+ if (rb_yjit_enabled_p) {
+ MARK_CHECKPOINT("YJIT");
+ rb_yjit_root_mark();
}
+#endif
- push_mark_stack(&objspace->mark_stack, obj);
-}
+#if USE_ZJIT
+ void rb_zjit_root_mark(void);
+ if (rb_zjit_enabled_p) {
+ MARK_CHECKPOINT("ZJIT");
+ rb_zjit_root_mark();
+ }
+#endif
-static void
-gc_aging(rb_objspace_t *objspace, VALUE obj)
-{
- struct heap_page *page = GET_HEAP_PAGE(obj);
+ MARK_CHECKPOINT("machine_context");
+ mark_current_machine_context(ec);
- GC_ASSERT(RVALUE_MARKING(obj) == FALSE);
- check_rvalue_consistency(obj);
+ MARK_CHECKPOINT("global_symbols");
+ rb_sym_global_symbols_mark_and_move();
- if (!RVALUE_PAGE_WB_UNPROTECTED(page, obj)) {
- if (!RVALUE_OLD_P(obj)) {
- gc_report(3, objspace, "gc_aging: YOUNG: %s\n", obj_info(obj));
- RVALUE_AGE_INC(objspace, obj);
- }
- else if (is_full_marking(objspace)) {
- GC_ASSERT(RVALUE_PAGE_UNCOLLECTIBLE(page, obj) == FALSE);
- RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, page, obj);
- }
- }
- check_rvalue_consistency(obj);
+ MARK_CHECKPOINT("finish");
- objspace->marked_slots++;
+#undef MARK_CHECKPOINT
}
-NOINLINE(static void gc_mark_ptr(rb_objspace_t *objspace, VALUE obj));
-static void reachable_objects_from_callback(VALUE obj);
+struct gc_mark_classext_foreach_arg {
+ rb_objspace_t *objspace;
+ VALUE obj;
+};
static void
-gc_mark_ptr(rb_objspace_t *objspace, VALUE obj)
+gc_mark_classext_module(rb_classext_t *ext, bool prime, VALUE box_value, void *arg)
{
- if (LIKELY(during_gc)) {
- rgengc_check_relation(objspace, obj);
- if (!gc_mark_set(objspace, obj)) return; /* already marked */
-
- if (0) { // for debug GC marking miss
- if (objspace->rgengc.parent_object) {
- RUBY_DEBUG_LOG("%p (%s) parent:%p (%s)",
- (void *)obj, obj_type_name(obj),
- (void *)objspace->rgengc.parent_object, obj_type_name(objspace->rgengc.parent_object));
- }
- else {
- RUBY_DEBUG_LOG("%p (%s)", (void *)obj, obj_type_name(obj));
- }
- }
+ struct gc_mark_classext_foreach_arg *foreach_arg = (struct gc_mark_classext_foreach_arg *)arg;
+ rb_objspace_t *objspace = foreach_arg->objspace;
- if (UNLIKELY(RB_TYPE_P(obj, T_NONE))) {
- rp(obj);
- rb_bug("try to mark T_NONE object"); /* check here will help debugging */
- }
- gc_aging(objspace, obj);
- gc_grey(objspace, obj);
- }
- else {
- reachable_objects_from_callback(obj);
+ if (RCLASSEXT_SUPER(ext)) {
+ gc_mark_internal(RCLASSEXT_SUPER(ext));
}
-}
+ mark_m_tbl(objspace, RCLASSEXT_M_TBL(ext));
-static inline void
-gc_pin(rb_objspace_t *objspace, VALUE obj)
-{
- GC_ASSERT(is_markable_object(objspace, obj));
- if (UNLIKELY(objspace->flags.during_compacting)) {
- if (LIKELY(during_gc)) {
- MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj);
- }
+ if (!rb_gc_checking_shareable()) {
+ // unshareable
+ gc_mark_internal(RCLASSEXT_FIELDS_OBJ(ext));
+ gc_mark_internal(RCLASSEXT_CVC_TBL(ext));
}
-}
-static inline void
-gc_mark_and_pin(rb_objspace_t *objspace, VALUE obj)
-{
- if (!is_markable_object(objspace, obj)) return;
- gc_pin(objspace, obj);
- gc_mark_ptr(objspace, obj);
-}
-
-static inline void
-gc_mark(rb_objspace_t *objspace, VALUE obj)
-{
- if (!is_markable_object(objspace, obj)) return;
- gc_mark_ptr(objspace, obj);
-}
-
-void
-rb_gc_mark_movable(VALUE ptr)
-{
- gc_mark(&rb_objspace, ptr);
-}
-
-void
-rb_gc_mark(VALUE ptr)
-{
- gc_mark_and_pin(&rb_objspace, ptr);
-}
-
-void
-rb_gc_mark_and_move(VALUE *ptr)
-{
- rb_objspace_t *objspace = &rb_objspace;
- if (RB_SPECIAL_CONST_P(*ptr)) return;
-
- if (UNLIKELY(objspace->flags.during_reference_updating)) {
- GC_ASSERT(objspace->flags.during_compacting);
- GC_ASSERT(during_gc);
-
- *ptr = rb_gc_location(*ptr);
+ if (!RCLASSEXT_SHARED_CONST_TBL(ext) && RCLASSEXT_CONST_TBL(ext)) {
+ mark_const_tbl(objspace, RCLASSEXT_CONST_TBL(ext));
}
- else {
- gc_mark_ptr(objspace, *ptr);
+ mark_m_tbl(objspace, RCLASSEXT_CALLABLE_M_TBL(ext));
+ gc_mark_internal(RCLASSEXT_CC_TBL(ext));
+ if (RCLASSEXT_SUBCLASSES(ext)) {
+ gc_mark_internal(RCLASSEXT_SUBCLASSES(ext));
}
+ gc_mark_internal(RCLASSEXT_CLASSPATH(ext));
}
-/* CAUTION: THIS FUNCTION ENABLE *ONLY BEFORE* SWEEPING.
- * This function is only for GC_END_MARK timing.
- */
-
-int
-rb_objspace_marked_object_p(VALUE obj)
+static void
+gc_mark_classext_iclass(rb_classext_t *ext, bool prime, VALUE box_value, void *arg)
{
- return RVALUE_MARKED(obj) ? TRUE : FALSE;
-}
+ struct gc_mark_classext_foreach_arg *foreach_arg = (struct gc_mark_classext_foreach_arg *)arg;
+ rb_objspace_t *objspace = foreach_arg->objspace;
-static inline void
-gc_mark_set_parent(rb_objspace_t *objspace, VALUE obj)
-{
- if (RVALUE_OLD_P(obj)) {
- objspace->rgengc.parent_object = obj;
+ if (RCLASSEXT_SUPER(ext)) {
+ gc_mark_internal(RCLASSEXT_SUPER(ext));
}
- else {
- objspace->rgengc.parent_object = Qfalse;
+ if (RCLASSEXT_ICLASS_IS_ORIGIN(ext) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext)) {
+ mark_m_tbl(objspace, RCLASSEXT_M_TBL(ext));
+ }
+ if (RCLASSEXT_INCLUDER(ext)) {
+ gc_mark_internal(RCLASSEXT_INCLUDER(ext));
+ }
+ mark_m_tbl(objspace, RCLASSEXT_CALLABLE_M_TBL(ext));
+ gc_mark_internal(RCLASSEXT_CC_TBL(ext));
+ if (RCLASSEXT_SUBCLASSES(ext)) {
+ gc_mark_internal(RCLASSEXT_SUBCLASSES(ext));
}
}
-static void
-gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
+#define TYPED_DATA_REFS_OFFSET_LIST(d) (size_t *)(uintptr_t)RTYPEDDATA_TYPE(d)->function.dmark
+
+void
+rb_gc_move_obj_during_marking(VALUE from, VALUE to)
{
- switch (imemo_type(obj)) {
- case imemo_env:
- {
- const rb_env_t *env = (const rb_env_t *)obj;
-
- if (LIKELY(env->ep)) {
- // just after newobj() can be NULL here.
- GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
- GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
- gc_mark_values(objspace, (long)env->env_size, env->env);
- VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
- gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
- gc_mark(objspace, (VALUE)env->iseq);
- }
- }
- return;
- case imemo_cref:
- gc_mark(objspace, RANY(obj)->as.imemo.cref.klass_or_self);
- gc_mark(objspace, (VALUE)RANY(obj)->as.imemo.cref.next);
- gc_mark(objspace, RANY(obj)->as.imemo.cref.refinements);
- return;
- case imemo_svar:
- gc_mark(objspace, RANY(obj)->as.imemo.svar.cref_or_me);
- gc_mark(objspace, RANY(obj)->as.imemo.svar.lastline);
- gc_mark(objspace, RANY(obj)->as.imemo.svar.backref);
- gc_mark(objspace, RANY(obj)->as.imemo.svar.others);
- return;
- case imemo_throw_data:
- gc_mark(objspace, RANY(obj)->as.imemo.throw_data.throw_obj);
- return;
- case imemo_ifunc:
- gc_mark_maybe(objspace, (VALUE)RANY(obj)->as.imemo.ifunc.data);
- return;
- case imemo_memo:
- gc_mark(objspace, RANY(obj)->as.imemo.memo.v1);
- gc_mark(objspace, RANY(obj)->as.imemo.memo.v2);
- gc_mark_maybe(objspace, RANY(obj)->as.imemo.memo.u3.value);
- return;
- case imemo_ment:
- mark_method_entry(objspace, &RANY(obj)->as.imemo.ment);
- return;
- case imemo_iseq:
- rb_iseq_mark_and_move((rb_iseq_t *)obj, false);
- return;
- case imemo_tmpbuf:
- {
- const rb_imemo_tmpbuf_t *m = &RANY(obj)->as.imemo.alloc;
- do {
- rb_gc_mark_locations(m->ptr, m->ptr + m->cnt);
- } while ((m = m->next) != NULL);
- }
- return;
- case imemo_ast:
- rb_ast_mark(&RANY(obj)->as.imemo.ast);
- return;
- case imemo_parser_strterm:
- rb_strterm_mark(obj);
- return;
- case imemo_callinfo:
- return;
- case imemo_callcache:
- {
- const struct rb_callcache *cc = (const struct rb_callcache *)obj;
- // should not mark klass here
- gc_mark(objspace, (VALUE)vm_cc_cme(cc));
- }
- return;
- case imemo_constcache:
- {
- const struct iseq_inline_constant_cache_entry *ice = (struct iseq_inline_constant_cache_entry *)obj;
- gc_mark(objspace, ice->value);
- }
- return;
-#if VM_CHECK_MODE > 0
- default:
- VM_UNREACHABLE(gc_mark_imemo);
-#endif
+ if (rb_obj_using_gen_fields_table_p(to)) {
+ rb_mark_generic_ivar(from);
}
}
-static void
-gc_mark_children(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_mark_children(void *objspace, VALUE obj)
{
- register RVALUE *any = RANY(obj);
- gc_mark_set_parent(objspace, obj);
+ struct gc_mark_classext_foreach_arg foreach_args;
- if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_and_update_generic_ivar(obj);
+ if (rb_obj_using_gen_fields_table_p(obj)) {
+ rb_mark_generic_ivar(obj);
}
switch (BUILTIN_TYPE(obj)) {
case T_FLOAT:
case T_BIGNUM:
- case T_SYMBOL:
- /* Not immediates, but does not have references and singleton
- * class */
return;
case T_NIL:
@@ -7269,3294 +3407,987 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
break;
case T_IMEMO:
- gc_mark_imemo(objspace, obj);
+ rb_imemo_mark_and_move(obj, false);
return;
default:
break;
}
- gc_mark(objspace, any->as.basic.klass);
+ gc_mark_internal(RBASIC(obj)->klass);
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
- if (FL_TEST(obj, FL_SINGLETON)) {
- gc_mark(objspace, RCLASS_ATTACHED_OBJECT(obj));
+ if (FL_TEST_RAW(obj, FL_SINGLETON) &&
+ !rb_gc_checking_shareable()) {
+ gc_mark_internal(RCLASS_ATTACHED_OBJECT(obj));
}
// Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
- if (RCLASS_SUPER(obj)) {
- gc_mark(objspace, RCLASS_SUPER(obj));
+ foreach_args.objspace = objspace;
+ foreach_args.obj = obj;
+ rb_class_classext_foreach(obj, gc_mark_classext_module, (void *)&foreach_args);
+ if (BOX_USER_P(RCLASS_PRIME_BOX(obj))) {
+ gc_mark_internal(RCLASS_PRIME_BOX(obj)->box_object);
}
- if (!RCLASS_EXT(obj)) break;
-
- mark_m_tbl(objspace, RCLASS_M_TBL(obj));
- cc_table_mark(objspace, obj);
- for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
- gc_mark(objspace, RCLASS_IVPTR(obj)[i]);
- }
- mark_const_tbl(objspace, RCLASS_CONST_TBL(obj));
-
- gc_mark(objspace, RCLASS_EXT(obj)->classpath);
break;
case T_ICLASS:
- if (RICLASS_OWNS_M_TBL_P(obj)) {
- mark_m_tbl(objspace, RCLASS_M_TBL(obj));
- }
- if (RCLASS_SUPER(obj)) {
- gc_mark(objspace, RCLASS_SUPER(obj));
- }
- if (!RCLASS_EXT(obj)) break;
-
- if (RCLASS_INCLUDER(obj)) {
- gc_mark(objspace, RCLASS_INCLUDER(obj));
+ foreach_args.objspace = objspace;
+ foreach_args.obj = obj;
+ rb_class_classext_foreach(obj, gc_mark_classext_iclass, (void *)&foreach_args);
+ if (BOX_USER_P(RCLASS_PRIME_BOX(obj))) {
+ gc_mark_internal(RCLASS_PRIME_BOX(obj)->box_object);
}
- mark_m_tbl(objspace, RCLASS_CALLABLE_M_TBL(obj));
- cc_table_mark(objspace, obj);
break;
case T_ARRAY:
if (ARY_SHARED_P(obj)) {
VALUE root = ARY_SHARED_ROOT(obj);
- gc_mark(objspace, root);
+ gc_mark_internal(root);
}
else {
- long i, len = RARRAY_LEN(obj);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(obj);
- for (i=0; i < len; i++) {
- gc_mark(objspace, ptr[i]);
- }
-
- if (LIKELY(during_gc)) {
- if (!ARY_EMBED_P(obj) && RARRAY_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
+ long len = RARRAY_LEN(obj);
+ const VALUE *ptr = RARRAY_CONST_PTR(obj);
+ for (long i = 0; i < len; i++) {
+ gc_mark_internal(ptr[i]);
}
}
break;
case T_HASH:
- mark_hash(objspace, obj);
+ mark_hash(obj);
break;
- case T_STRING:
- if (STR_SHARED_P(obj)) {
- gc_mark(objspace, any->as.string.as.heap.aux.shared);
- }
+ case T_SYMBOL:
+ gc_mark_internal(RSYMBOL(obj)->fstr);
break;
- case T_DATA:
- {
- void *const ptr = DATA_PTR(obj);
- if (ptr) {
- RUBY_DATA_FUNC mark_func = RTYPEDDATA_P(obj) ?
- any->as.typeddata.type->function.dmark :
- any->as.data.dmark;
- if (mark_func) (*mark_func)(ptr);
+ case T_STRING:
+ if (STR_SHARED_P(obj)) {
+ if (STR_EMBED_P(RSTRING(obj)->as.heap.aux.shared)) {
+ /* Embedded shared strings cannot be moved because this string
+ * points into the slot of the shared string. There may be code
+ * using the RSTRING_PTR on the stack, which would pin this
+ * string but not pin the shared string, causing it to move. */
+ gc_mark_and_pin_internal(RSTRING(obj)->as.heap.aux.shared);
+ }
+ else {
+ gc_mark_internal(RSTRING(obj)->as.heap.aux.shared);
}
}
break;
- case T_OBJECT:
- {
- rb_shape_t *shape = rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj));
- if (rb_shape_obj_too_complex(obj)) {
- mark_m_tbl(objspace, ROBJECT_IV_HASH(obj));
- }
- else {
- const VALUE * const ptr = ROBJECT_IVPTR(obj);
+ case T_DATA: {
+ void *const ptr = RTYPEDDATA_GET_DATA(obj);
- uint32_t i, len = ROBJECT_IV_COUNT(obj);
- for (i = 0; i < len; i++) {
- gc_mark(objspace, ptr[i]);
- }
+ gc_mark_internal(RTYPEDDATA(obj)->fields_obj);
- if (LIKELY(during_gc) &&
- ROBJ_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
+ if (ptr) {
+ if (gc_declarative_marking_p(RTYPEDDATA_TYPE(obj))) {
+ size_t *offset_list = TYPED_DATA_REFS_OFFSET_LIST(obj);
+
+ for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) {
+ gc_mark_internal(*(VALUE *)((char *)ptr + offset));
}
}
- if (shape) {
- VALUE klass = RBASIC_CLASS(obj);
+ else {
+ RUBY_DATA_FUNC mark_func = RTYPEDDATA_TYPE(obj)->function.dmark;
+ if (mark_func) (*mark_func)(ptr);
+ }
+ }
- // Increment max_iv_count if applicable, used to determine size pool allocation
- uint32_t num_of_ivs = shape->next_iv_index;
- if (RCLASS_EXT(klass)->max_iv_count < num_of_ivs) {
- RCLASS_EXT(klass)->max_iv_count = num_of_ivs;
- }
+ break;
+ }
+
+ case T_OBJECT: {
+ uint32_t len;
+ if (rb_obj_shape_complex_p(obj)) {
+ gc_mark_tbl_no_pin(ROBJECT_FIELDS_HASH(obj));
+ len = ROBJECT_FIELDS_COUNT_COMPLEX(obj);
+ }
+ else {
+ const VALUE * const ptr = ROBJECT_FIELDS(obj);
+
+ len = ROBJECT_FIELDS_COUNT_NOT_COMPLEX(obj);
+ for (uint32_t i = 0; i < len; i++) {
+ gc_mark_internal(ptr[i]);
}
}
break;
+ }
case T_FILE:
- if (any->as.file.fptr) {
- gc_mark(objspace, any->as.file.fptr->self);
- gc_mark(objspace, any->as.file.fptr->pathv);
- gc_mark(objspace, any->as.file.fptr->tied_io_for_writing);
- gc_mark(objspace, any->as.file.fptr->writeconv_asciicompat);
- gc_mark(objspace, any->as.file.fptr->writeconv_pre_ecopts);
- gc_mark(objspace, any->as.file.fptr->encs.ecopts);
- gc_mark(objspace, any->as.file.fptr->write_lock);
- gc_mark(objspace, any->as.file.fptr->timeout);
+ if (RFILE(obj)->fptr) {
+ gc_mark_internal(RFILE(obj)->fptr->self);
+ gc_mark_internal(RFILE(obj)->fptr->pathv);
+ gc_mark_internal(RFILE(obj)->fptr->tied_io_for_writing);
+ gc_mark_internal(RFILE(obj)->fptr->writeconv_asciicompat);
+ gc_mark_internal(RFILE(obj)->fptr->writeconv_pre_ecopts);
+ gc_mark_internal(RFILE(obj)->fptr->encs.ecopts);
+ gc_mark_internal(RFILE(obj)->fptr->write_lock);
+ gc_mark_internal(RFILE(obj)->fptr->timeout);
+ gc_mark_internal(RFILE(obj)->fptr->wakeup_mutex);
}
break;
case T_REGEXP:
- gc_mark(objspace, any->as.regexp.src);
+ gc_mark_internal(RREGEXP(obj)->src);
break;
case T_MATCH:
- gc_mark(objspace, any->as.match.regexp);
- if (any->as.match.str) {
- gc_mark(objspace, any->as.match.str);
+ gc_mark_internal(RMATCH(obj)->regexp);
+ if (RMATCH(obj)->str) {
+ gc_mark_internal(RMATCH(obj)->str);
}
break;
case T_RATIONAL:
- gc_mark(objspace, any->as.rational.num);
- gc_mark(objspace, any->as.rational.den);
+ gc_mark_internal(RRATIONAL(obj)->num);
+ gc_mark_internal(RRATIONAL(obj)->den);
break;
case T_COMPLEX:
- gc_mark(objspace, any->as.complex.real);
- gc_mark(objspace, any->as.complex.imag);
+ gc_mark_internal(RCOMPLEX(obj)->real);
+ gc_mark_internal(RCOMPLEX(obj)->imag);
break;
- case T_STRUCT:
- {
- long i;
- const long len = RSTRUCT_LEN(obj);
- const VALUE * const ptr = RSTRUCT_CONST_PTR(obj);
+ case T_STRUCT: {
+ const long len = RSTRUCT_LEN(obj);
+ const VALUE * const ptr = RSTRUCT_CONST_PTR(obj);
- for (i=0; i<len; i++) {
- gc_mark(objspace, ptr[i]);
- }
+ for (long i = 0; i < len; i++) {
+ gc_mark_internal(ptr[i]);
+ }
- if (LIKELY(during_gc) &&
- RSTRUCT_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
+ if (rb_obj_shape_has_fields(obj) && !FL_TEST_RAW(obj, RSTRUCT_GEN_FIELDS)) {
+ gc_mark_internal(RSTRUCT_FIELDS_OBJ(obj));
}
+
break;
+ }
default:
-#if GC_DEBUG
- rb_gcdebug_print_obj_condition((VALUE)obj);
-#endif
if (BUILTIN_TYPE(obj) == T_MOVED) rb_bug("rb_gc_mark(): %p is T_MOVED", (void *)obj);
if (BUILTIN_TYPE(obj) == T_NONE) rb_bug("rb_gc_mark(): %p is T_NONE", (void *)obj);
if (BUILTIN_TYPE(obj) == T_ZOMBIE) rb_bug("rb_gc_mark(): %p is T_ZOMBIE", (void *)obj);
rb_bug("rb_gc_mark(): unknown data type 0x%x(%p) %s",
- BUILTIN_TYPE(obj), (void *)any,
- is_pointer_to_heap(objspace, any) ? "corrupted object" : "non object");
+ BUILTIN_TYPE(obj), (void *)obj,
+ rb_gc_impl_pointer_to_heap_p(objspace, (void *)obj) ? "corrupted object" : "non object");
}
}
-/**
- * incremental: 0 -> not incremental (do all)
- * incremental: n -> mark at most `n' objects
- */
-static inline int
-gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
+size_t
+rb_gc_obj_optimal_size(VALUE obj)
{
- mark_stack_t *mstack = &objspace->mark_stack;
- VALUE obj;
- size_t marked_slots_at_the_beginning = objspace->marked_slots;
- size_t popped_count = 0;
-
- while (pop_mark_stack(mstack, &obj)) {
- if (UNDEF_P(obj)) continue; /* skip */
-
- if (RGENGC_CHECK_MODE && !RVALUE_MARKED(obj)) {
- rb_bug("gc_mark_stacked_objects: %s is not marked.", obj_info(obj));
- }
- gc_mark_children(objspace, obj);
-
- if (incremental) {
- if (RGENGC_CHECK_MODE && !RVALUE_MARKING(obj)) {
- rb_bug("gc_mark_stacked_objects: incremental, but marking bit is 0");
+ switch (BUILTIN_TYPE(obj)) {
+ case T_ARRAY:
+ {
+ size_t size = rb_ary_size_as_embedded(obj);
+ if (rb_gc_size_allocatable_p(size)) {
+ return size;
}
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
- popped_count++;
-
- if (popped_count + (objspace->marked_slots - marked_slots_at_the_beginning) > count) {
- break;
+ else {
+ return sizeof(struct RArray);
}
}
- else {
- /* just ignore marking bits */
- }
- }
-
- if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
-
- if (is_mark_stack_empty(mstack)) {
- shrink_stack_chunk_cache(mstack);
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static int
-gc_mark_stacked_objects_incremental(rb_objspace_t *objspace, size_t count)
-{
- return gc_mark_stacked_objects(objspace, TRUE, count);
-}
-
-static int
-gc_mark_stacked_objects_all(rb_objspace_t *objspace)
-{
- return gc_mark_stacked_objects(objspace, FALSE, 0);
-}
-
-#if PRINT_ROOT_TICKS
-#define MAX_TICKS 0x100
-static tick_t mark_ticks[MAX_TICKS];
-static const char *mark_ticks_categories[MAX_TICKS];
-static void
-show_mark_ticks(void)
-{
- int i;
- fprintf(stderr, "mark ticks result:\n");
- for (i=0; i<MAX_TICKS; i++) {
- const char *category = mark_ticks_categories[i];
- if (category) {
- fprintf(stderr, "%s\t%8lu\n", category, (unsigned long)mark_ticks[i]);
+ case T_OBJECT:
+ if (rb_obj_shape_complex_p(obj)) {
+ return sizeof(struct RObject);
}
else {
- break;
+ size_t size = rb_obj_embedded_size(ROBJECT_FIELDS_CAPACITY(obj));
+ if (rb_gc_size_allocatable_p(size)) {
+ return size;
+ }
+ else {
+ return sizeof(struct RObject);
+ }
}
- }
-}
-
-#endif /* PRINT_ROOT_TICKS */
-
-static void
-gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
-{
- struct gc_list *list;
- rb_execution_context_t *ec = GET_EC();
- rb_vm_t *vm = rb_ec_vm_ptr(ec);
-
-#if PRINT_ROOT_TICKS
- tick_t start_tick = tick();
- int tick_count = 0;
- const char *prev_category = 0;
-
- if (mark_ticks_categories[0] == 0) {
- atexit(show_mark_ticks);
- }
-#endif
-
- if (categoryp) *categoryp = "xxx";
-
- objspace->rgengc.parent_object = Qfalse;
-
-#if PRINT_ROOT_TICKS
-#define MARK_CHECKPOINT_PRINT_TICK(category) do { \
- if (prev_category) { \
- tick_t t = tick(); \
- mark_ticks[tick_count] = t - start_tick; \
- mark_ticks_categories[tick_count] = prev_category; \
- tick_count++; \
- } \
- prev_category = category; \
- start_tick = tick(); \
-} while (0)
-#else /* PRINT_ROOT_TICKS */
-#define MARK_CHECKPOINT_PRINT_TICK(category)
-#endif
-
-#define MARK_CHECKPOINT(category) do { \
- if (categoryp) *categoryp = category; \
- MARK_CHECKPOINT_PRINT_TICK(category); \
-} while (0)
- MARK_CHECKPOINT("vm");
- SET_STACK_END;
- rb_vm_mark(vm);
- if (vm->self) gc_mark(objspace, vm->self);
-
- MARK_CHECKPOINT("finalizers");
- mark_finalizer_tbl(objspace, finalizer_table);
+ case T_STRING:
+ {
+ size_t size = rb_str_size_as_embedded(obj);
+ if (rb_gc_size_allocatable_p(size)) {
+ return size;
+ }
+ else {
+ return sizeof(struct RString);
+ }
+ }
- MARK_CHECKPOINT("machine_context");
- mark_current_machine_context(objspace, ec);
+ case T_HASH:
+ {
+ if (RB_OBJ_FROZEN(obj) && RHASH_AR_TABLE_P(obj)) {
+ return sizeof(struct RHash) + offsetof(ar_table, pairs) + RHASH_AR_TABLE_BOUND(obj) * sizeof(ar_table_pair);
+ }
+ return sizeof(struct RHash) + (RHASH_ST_TABLE_P(obj) ? sizeof(st_table) : sizeof(ar_table));
+ }
- /* mark protected global variables */
- MARK_CHECKPOINT("global_list");
- for (list = global_list; list; list = list->next) {
- gc_mark_maybe(objspace, *list->varptr);
+ default:
+ return 0;
}
-
- MARK_CHECKPOINT("end_proc");
- rb_mark_end_proc();
-
- MARK_CHECKPOINT("global_tbl");
- rb_gc_mark_global_tbl();
-
- MARK_CHECKPOINT("object_id");
- rb_gc_mark(objspace->next_object_id);
- mark_tbl_no_pin(objspace, objspace->obj_to_id_tbl); /* Only mark ids */
-
- if (stress_to_class) rb_gc_mark(stress_to_class);
-
- MARK_CHECKPOINT("finish");
-#undef MARK_CHECKPOINT
}
-#if RGENGC_CHECK_MODE >= 4
-
-#define MAKE_ROOTSIG(obj) (((VALUE)(obj) << 1) | 0x01)
-#define IS_ROOTSIG(obj) ((VALUE)(obj) & 0x01)
-#define GET_ROOTSIG(obj) ((const char *)((VALUE)(obj) >> 1))
-
-struct reflist {
- VALUE *list;
- int pos;
- int size;
-};
-
-static struct reflist *
-reflist_create(VALUE obj)
+void
+rb_gc_writebarrier(VALUE a, VALUE b)
{
- struct reflist *refs = xmalloc(sizeof(struct reflist));
- refs->size = 1;
- refs->list = ALLOC_N(VALUE, refs->size);
- refs->list[0] = obj;
- refs->pos = 1;
- return refs;
+ rb_gc_impl_writebarrier(rb_gc_get_objspace(), a, b);
}
-static void
-reflist_destruct(struct reflist *refs)
+void
+rb_gc_writebarrier_unprotect(VALUE obj)
{
- xfree(refs->list);
- xfree(refs);
+ rb_gc_impl_writebarrier_unprotect(rb_gc_get_objspace(), obj);
}
-static void
-reflist_add(struct reflist *refs, VALUE obj)
+/*
+ * remember `obj' if needed.
+ */
+void
+rb_gc_writebarrier_remember(VALUE obj)
{
- if (refs->pos == refs->size) {
- refs->size *= 2;
- SIZED_REALLOC_N(refs->list, VALUE, refs->size, refs->size/2);
- }
-
- refs->list[refs->pos++] = obj;
+ rb_gc_impl_writebarrier_remember(rb_gc_get_objspace(), obj);
}
-static void
-reflist_dump(struct reflist *refs)
+void
+rb_gc_copy_attributes(VALUE dest, VALUE obj)
{
- int i;
- for (i=0; i<refs->pos; i++) {
- VALUE obj = refs->list[i];
- if (IS_ROOTSIG(obj)) { /* root */
- fprintf(stderr, "<root@%s>", GET_ROOTSIG(obj));
- }
- else {
- fprintf(stderr, "<%s>", obj_info(obj));
- }
- if (i+1 < refs->pos) fprintf(stderr, ", ");
- }
+ rb_gc_impl_copy_attributes(rb_gc_get_objspace(), dest, obj);
}
-static int
-reflist_referred_from_machine_context(struct reflist *refs)
+#if USE_MODULAR_GC
+int
+rb_gc_modular_gc_loaded_p(void)
{
- int i;
- for (i=0; i<refs->pos; i++) {
- VALUE obj = refs->list[i];
- if (IS_ROOTSIG(obj) && strcmp(GET_ROOTSIG(obj), "machine_context") == 0) return 1;
- }
- return 0;
+ return rb_gc_functions.modular_gc_loaded_p;
}
-struct allrefs {
- rb_objspace_t *objspace;
- /* a -> obj1
- * b -> obj1
- * c -> obj1
- * c -> obj2
- * d -> obj3
- * #=> {obj1 => [a, b, c], obj2 => [c, d]}
- */
- struct st_table *references;
- const char *category;
- VALUE root_obj;
- mark_stack_t mark_stack;
-};
-
-static int
-allrefs_add(struct allrefs *data, VALUE obj)
+const char *
+rb_gc_active_gc_name(void)
{
- struct reflist *refs;
- st_data_t r;
+ const char *gc_name = rb_gc_impl_active_gc_name();
- if (st_lookup(data->references, obj, &r)) {
- refs = (struct reflist *)r;
- reflist_add(refs, data->root_obj);
- return 0;
- }
- else {
- refs = reflist_create(data->root_obj);
- st_insert(data->references, obj, (st_data_t)refs);
- return 1;
+ const size_t len = strlen(gc_name);
+ if (len > RB_GC_MAX_NAME_LEN) {
+ rb_bug("GC should have a name no more than %d chars long. Currently: %zu (%s)",
+ RB_GC_MAX_NAME_LEN, len, gc_name);
}
-}
-
-static void
-allrefs_i(VALUE obj, void *ptr)
-{
- struct allrefs *data = (struct allrefs *)ptr;
- if (allrefs_add(data, obj)) {
- push_mark_stack(&data->mark_stack, obj);
- }
+ return gc_name;
}
+#endif
-static void
-allrefs_roots_i(VALUE obj, void *ptr)
+struct rb_gc_object_metadata_entry *
+rb_gc_object_metadata(VALUE obj)
{
- struct allrefs *data = (struct allrefs *)ptr;
- if (strlen(data->category) == 0) rb_bug("!!!");
- data->root_obj = MAKE_ROOTSIG(data->category);
-
- if (allrefs_add(data, obj)) {
- push_mark_stack(&data->mark_stack, obj);
- }
+ return rb_gc_impl_object_metadata(rb_gc_get_objspace(), obj);
}
-#define PUSH_MARK_FUNC_DATA(v) do { \
- struct gc_mark_func_data_struct *prev_mark_func_data = GET_RACTOR()->mfd; \
- GET_RACTOR()->mfd = (v);
-
-#define POP_MARK_FUNC_DATA() GET_RACTOR()->mfd = prev_mark_func_data;} while (0)
-
-static st_table *
-objspace_allrefs(rb_objspace_t *objspace)
-{
- struct allrefs data;
- struct gc_mark_func_data_struct mfd;
- VALUE obj;
- int prev_dont_gc = dont_gc_val();
- dont_gc_on();
-
- data.objspace = objspace;
- data.references = st_init_numtable();
- init_mark_stack(&data.mark_stack);
- mfd.mark_func = allrefs_roots_i;
- mfd.data = &data;
-
- /* traverse root objects */
- PUSH_MARK_FUNC_DATA(&mfd);
- GET_RACTOR()->mfd = &mfd;
- gc_mark_roots(objspace, &data.category);
- POP_MARK_FUNC_DATA();
-
- /* traverse rest objects reachable from root objects */
- while (pop_mark_stack(&data.mark_stack, &obj)) {
- rb_objspace_reachable_objects_from(data.root_obj = obj, allrefs_i, &data);
- }
- free_stack_chunks(&data.mark_stack);
-
- dont_gc_set(prev_dont_gc);
- return data.references;
-}
+/* GC */
-static int
-objspace_allrefs_destruct_i(st_data_t key, st_data_t value, st_data_t ptr)
+void *
+rb_gc_ractor_cache_alloc(rb_ractor_t *ractor)
{
- struct reflist *refs = (struct reflist *)value;
- reflist_destruct(refs);
- return ST_CONTINUE;
+ return rb_gc_impl_ractor_cache_alloc(rb_gc_get_objspace(), ractor);
}
-static void
-objspace_allrefs_destruct(struct st_table *refs)
+void
+rb_gc_ractor_cache_free(void *cache)
{
- st_foreach(refs, objspace_allrefs_destruct_i, 0);
- st_free_table(refs);
+ rb_gc_impl_ractor_cache_free(rb_gc_get_objspace(), cache);
}
-#if RGENGC_CHECK_MODE >= 5
-static int
-allrefs_dump_i(st_data_t k, st_data_t v, st_data_t ptr)
+void
+rb_gc_register_mark_object(VALUE obj)
{
- VALUE obj = (VALUE)k;
- struct reflist *refs = (struct reflist *)v;
- fprintf(stderr, "[allrefs_dump_i] %s <- ", obj_info(obj));
- reflist_dump(refs);
- fprintf(stderr, "\n");
- return ST_CONTINUE;
-}
+ if (!rb_gc_impl_pointer_to_heap_p(rb_gc_get_objspace(), (void *)obj))
+ return;
-static void
-allrefs_dump(rb_objspace_t *objspace)
-{
- VALUE size = objspace->rgengc.allrefs_table->num_entries;
- fprintf(stderr, "[all refs] (size: %"PRIuVALUE")\n", size);
- st_foreach(objspace->rgengc.allrefs_table, allrefs_dump_i, 0);
+ rb_vm_register_global_object(obj);
}
-#endif
-static int
-gc_check_after_marks_i(st_data_t k, st_data_t v, st_data_t ptr)
+void
+rb_gc_register_address(VALUE *addr)
{
- VALUE obj = k;
- struct reflist *refs = (struct reflist *)v;
- rb_objspace_t *objspace = (rb_objspace_t *)ptr;
+ rb_vm_t *vm = GET_VM();
- /* object should be marked or oldgen */
- if (!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj)) {
- fprintf(stderr, "gc_check_after_marks_i: %s is not marked and not oldgen.\n", obj_info(obj));
- fprintf(stderr, "gc_check_after_marks_i: %p is referred from ", (void *)obj);
- reflist_dump(refs);
+ VALUE obj = *addr;
- if (reflist_referred_from_machine_context(refs)) {
- fprintf(stderr, " (marked from machine stack).\n");
- /* marked from machine context can be false positive */
- }
- else {
- objspace->rgengc.error_count++;
- fprintf(stderr, "\n");
+ RB_VM_LOCKING() {
+ if (vm->global_object_list_size == vm->global_object_list_capa) {
+ size_t new_capa = vm->global_object_list_capa ? vm->global_object_list_capa * 2 : 64;
+ SIZED_REALLOC_N(vm->global_object_list, VALUE *, new_capa, vm->global_object_list_capa);
+ vm->global_object_list_capa = new_capa;
}
- }
- return ST_CONTINUE;
-}
-
-static void
-gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func, const char *checker_name)
-{
- size_t saved_malloc_increase = objspace->malloc_params.increase;
-#if RGENGC_ESTIMATE_OLDMALLOC
- size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
-#endif
- VALUE already_disabled = rb_objspace_gc_disable(objspace);
-
- objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
- if (checker_func) {
- st_foreach(objspace->rgengc.allrefs_table, checker_func, (st_data_t)objspace);
+ vm->global_object_list[vm->global_object_list_size++] = addr;
}
- if (objspace->rgengc.error_count > 0) {
-#if RGENGC_CHECK_MODE >= 5
- allrefs_dump(objspace);
-#endif
- if (checker_name) rb_bug("%s: GC has problem.", checker_name);
+ /*
+ * Because some C extensions have assignment-then-register bugs,
+ * we guard `obj` here so that it would not get swept defensively.
+ */
+ RB_GC_GUARD(obj);
+ if (0 && !SPECIAL_CONST_P(obj)) {
+ rb_warn("Object is assigned to registering address already: %"PRIsVALUE,
+ rb_obj_class(obj));
+ rb_print_backtrace(stderr);
}
-
- objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
- objspace->rgengc.allrefs_table = 0;
-
- if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
- objspace->malloc_params.increase = saved_malloc_increase;
-#if RGENGC_ESTIMATE_OLDMALLOC
- objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
-#endif
}
-#endif /* RGENGC_CHECK_MODE >= 4 */
-struct verify_internal_consistency_struct {
- rb_objspace_t *objspace;
- int err_count;
- size_t live_object_count;
- size_t zombie_object_count;
-
- VALUE parent;
- size_t old_object_count;
- size_t remembered_shady_count;
-};
-
-static void
-check_generation_i(const VALUE child, void *ptr)
+void
+rb_gc_unregister_address(VALUE *addr)
{
- struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
- const VALUE parent = data->parent;
-
- if (RGENGC_CHECK_MODE) GC_ASSERT(RVALUE_OLD_P(parent));
-
- if (!RVALUE_OLD_P(child)) {
- if (!RVALUE_REMEMBERED(parent) &&
- !RVALUE_REMEMBERED(child) &&
- !RVALUE_UNCOLLECTIBLE(child)) {
- fprintf(stderr, "verify_internal_consistency_reachable_i: WB miss (O->Y) %s -> %s\n", obj_info(parent), obj_info(child));
- data->err_count++;
+ rb_vm_t *vm = GET_VM();
+ RB_VM_LOCKING() {
+ size_t index;
+ for (index = 0; index < vm->global_object_list_size; index++) {
+ if (addr == vm->global_object_list[index]) {
+ MEMMOVE(
+ vm->global_object_list[index],
+ &vm->global_object_list[index + 1],
+ VALUE *,
+ vm->global_object_list_size - index - 1
+ );
+ vm->global_object_list_size--;
+ break;
+ }
}
}
}
-static void
-check_color_i(const VALUE child, void *ptr)
-{
- struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
- const VALUE parent = data->parent;
-
- if (!RVALUE_WB_UNPROTECTED(parent) && RVALUE_WHITE_P(child)) {
- fprintf(stderr, "verify_internal_consistency_reachable_i: WB miss (B->W) - %s -> %s\n",
- obj_info(parent), obj_info(child));
- data->err_count++;
- }
-}
-
-static void
-check_children_i(const VALUE child, void *ptr)
+void
+rb_global_variable(VALUE *var)
{
- struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
- if (check_rvalue_consistency_force(child, FALSE) != 0) {
- fprintf(stderr, "check_children_i: %s has error (referenced from %s)",
- obj_info(child), obj_info(data->parent));
- rb_print_backtrace(); /* C backtrace will help to debug */
-
- data->err_count++;
- }
+ rb_gc_register_address(var);
}
-static int
-verify_internal_consistency_i(void *page_start, void *page_end, size_t stride,
- struct verify_internal_consistency_struct *data)
+static VALUE
+gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE immediate_mark, VALUE immediate_sweep, VALUE compact)
{
- VALUE obj;
- rb_objspace_t *objspace = data->objspace;
-
- for (obj = (VALUE)page_start; obj != (VALUE)page_end; obj += stride) {
- void *poisoned = asan_unpoison_object_temporary(obj);
-
- if (is_live_object(objspace, obj)) {
- /* count objects */
- data->live_object_count++;
- data->parent = obj;
-
- /* Normally, we don't expect T_MOVED objects to be in the heap.
- * But they can stay alive on the stack, */
- if (!gc_object_moved_p(objspace, obj)) {
- /* moved slots don't have children */
- rb_objspace_reachable_objects_from(obj, check_children_i, (void *)data);
- }
-
- /* check health of children */
- if (RVALUE_OLD_P(obj)) data->old_object_count++;
- if (RVALUE_WB_UNPROTECTED(obj) && RVALUE_UNCOLLECTIBLE(obj)) data->remembered_shady_count++;
-
- if (!is_marking(objspace) && RVALUE_OLD_P(obj)) {
- /* reachable objects from an oldgen object should be old or (young with remember) */
- data->parent = obj;
- rb_objspace_reachable_objects_from(obj, check_generation_i, (void *)data);
- }
-
- if (is_incremental_marking(objspace)) {
- if (RVALUE_BLACK_P(obj)) {
- /* reachable objects from black objects should be black or grey objects */
- data->parent = obj;
- rb_objspace_reachable_objects_from(obj, check_color_i, (void *)data);
- }
- }
- }
- else {
- if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
- GC_ASSERT((RBASIC(obj)->flags & ~FL_SEEN_OBJ_ID) == T_ZOMBIE);
- data->zombie_object_count++;
- }
- }
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
- asan_poison_object(obj);
- }
- }
-
- return 0;
-}
-
-static int
-gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
-{
- unsigned int has_remembered_shady = FALSE;
- unsigned int has_remembered_old = FALSE;
- int remembered_old_objects = 0;
- int free_objects = 0;
- int zombie_objects = 0;
-
- short slot_size = page->slot_size;
- uintptr_t start = (uintptr_t)page->start;
- uintptr_t end = start + page->total_slots * slot_size;
-
- for (uintptr_t ptr = start; ptr < end; ptr += slot_size) {
- VALUE val = (VALUE)ptr;
- void *poisoned = asan_unpoison_object_temporary(val);
- enum ruby_value_type type = BUILTIN_TYPE(val);
-
- if (type == T_NONE) free_objects++;
- if (type == T_ZOMBIE) zombie_objects++;
- if (RVALUE_PAGE_UNCOLLECTIBLE(page, val) && RVALUE_PAGE_WB_UNPROTECTED(page, val)) {
- has_remembered_shady = TRUE;
- }
- if (RVALUE_PAGE_MARKING(page, val)) {
- has_remembered_old = TRUE;
- remembered_old_objects++;
- }
-
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(val) == T_NONE);
- asan_poison_object(val);
- }
- }
-
- if (!is_incremental_marking(objspace) &&
- page->flags.has_remembered_objects == FALSE && has_remembered_old == TRUE) {
-
- for (uintptr_t ptr = start; ptr < end; ptr += slot_size) {
- VALUE val = (VALUE)ptr;
- if (RVALUE_PAGE_MARKING(page, val)) {
- fprintf(stderr, "marking -> %s\n", obj_info(val));
- }
- }
- rb_bug("page %p's has_remembered_objects should be false, but there are remembered old objects (%d). %s",
- (void *)page, remembered_old_objects, obj ? obj_info(obj) : "");
- }
-
- if (page->flags.has_uncollectible_shady_objects == FALSE && has_remembered_shady == TRUE) {
- rb_bug("page %p's has_remembered_shady should be false, but there are remembered shady objects. %s",
- (void *)page, obj ? obj_info(obj) : "");
- }
-
- if (0) {
- /* free_slots may not equal to free_objects */
- if (page->free_slots != free_objects) {
- rb_bug("page %p's free_slots should be %d, but %d\n", (void *)page, page->free_slots, free_objects);
- }
- }
- if (page->final_slots != zombie_objects) {
- rb_bug("page %p's final_slots should be %d, but %d\n", (void *)page, page->final_slots, zombie_objects);
- }
-
- return remembered_old_objects;
-}
-
-static int
-gc_verify_heap_pages_(rb_objspace_t *objspace, struct ccan_list_head *head)
-{
- int remembered_old_objects = 0;
- struct heap_page *page = 0;
-
- ccan_list_for_each(head, page, page_node) {
- asan_unlock_freelist(page);
- RVALUE *p = page->freelist;
- while (p) {
- VALUE vp = (VALUE)p;
- VALUE prev = vp;
- asan_unpoison_object(vp, false);
- if (BUILTIN_TYPE(vp) != T_NONE) {
- fprintf(stderr, "freelist slot expected to be T_NONE but was: %s\n", obj_info(vp));
- }
- p = p->as.free.next;
- asan_poison_object(prev);
- }
- asan_lock_freelist(page);
-
- if (page->flags.has_remembered_objects == FALSE) {
- remembered_old_objects += gc_verify_heap_page(objspace, page, Qfalse);
- }
- }
-
- return remembered_old_objects;
-}
+ rb_gc_impl_start(rb_gc_get_objspace(), RTEST(full_mark), RTEST(immediate_mark), RTEST(immediate_sweep), RTEST(compact));
-static int
-gc_verify_heap_pages(rb_objspace_t *objspace)
-{
- int remembered_old_objects = 0;
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- remembered_old_objects += gc_verify_heap_pages_(objspace, &(SIZE_POOL_EDEN_HEAP(&size_pools[i])->pages));
- remembered_old_objects += gc_verify_heap_pages_(objspace, &(SIZE_POOL_TOMB_HEAP(&size_pools[i])->pages));
- }
- return remembered_old_objects;
+ return Qnil;
}
/*
- * call-seq:
- * GC.verify_internal_consistency -> nil
+ * rb_objspace_each_objects() is special C API to walk through
+ * Ruby object space. This C API is too difficult to use it.
+ * To be frank, you should not use it. Or you need to read the
+ * source code of this function and understand what this function does.
*
- * Verify internal consistency.
+ * 'callback' will be called several times (the number of heap page,
+ * at current implementation) with:
+ * vstart: a pointer to the first living object of the heap_page.
+ * vend: a pointer to next to the valid heap_page area.
+ * stride: a distance to next VALUE.
+ *
+ * If callback() returns non-zero, the iteration will be stopped.
+ *
+ * This is a sample callback code to iterate liveness objects:
*
- * This method is implementation specific.
- * Now this method checks generational consistency
- * if RGenGC is supported.
+ * static int
+ * sample_callback(void *vstart, void *vend, int stride, void *data)
+ * {
+ * VALUE v = (VALUE)vstart;
+ * for (; v != (VALUE)vend; v += stride) {
+ * if (!rb_objspace_internal_object_p(v)) { // liveness check
+ * // do something with live object 'v'
+ * }
+ * }
+ * return 0; // continue to iteration
+ * }
+ *
+ * Note: 'vstart' is not a top of heap_page. This point the first
+ * living object to grasp at least one object to avoid GC issue.
+ * This means that you can not walk through all Ruby object page
+ * including freed object page.
+ *
+ * Note: On this implementation, 'stride' is the same as sizeof(RVALUE).
+ * However, there are possibilities to pass variable values with
+ * 'stride' with some reasons. You must use stride instead of
+ * use some constant value in the iteration.
*/
-static VALUE
-gc_verify_internal_consistency_m(VALUE dummy)
-{
- gc_verify_internal_consistency(&rb_objspace);
- return Qnil;
-}
-
-static void
-gc_verify_internal_consistency_(rb_objspace_t *objspace)
-{
- struct verify_internal_consistency_struct data = {0};
-
- data.objspace = objspace;
- gc_report(5, objspace, "gc_verify_internal_consistency: start\n");
-
- /* check relations */
- for (size_t i = 0; i < heap_allocated_pages; i++) {
- struct heap_page *page = heap_pages_sorted[i];
- short slot_size = page->slot_size;
-
- uintptr_t start = (uintptr_t)page->start;
- uintptr_t end = start + page->total_slots * slot_size;
-
- verify_internal_consistency_i((void *)start, (void *)end, slot_size, &data);
- }
-
- if (data.err_count != 0) {
-#if RGENGC_CHECK_MODE >= 5
- objspace->rgengc.error_count = data.err_count;
- gc_marks_check(objspace, NULL, NULL);
- allrefs_dump(objspace);
-#endif
- rb_bug("gc_verify_internal_consistency: found internal inconsistency.");
- }
-
- /* check heap_page status */
- gc_verify_heap_pages(objspace);
-
- /* check counters */
-
- if (!is_lazy_sweeping(objspace) &&
- !finalizing &&
- ruby_single_main_ractor != NULL) {
- if (objspace_live_slots(objspace) != data.live_object_count) {
- fprintf(stderr, "heap_pages_final_slots: %"PRIdSIZE", "
- "objspace->profile.total_freed_objects: %"PRIdSIZE"\n",
- heap_pages_final_slots, objspace->profile.total_freed_objects);
- rb_bug("inconsistent live slot number: expect %"PRIuSIZE", but %"PRIuSIZE".",
- objspace_live_slots(objspace), data.live_object_count);
- }
- }
-
- if (!is_marking(objspace)) {
- if (objspace->rgengc.old_objects != data.old_object_count) {
- rb_bug("inconsistent old slot number: expect %"PRIuSIZE", but %"PRIuSIZE".",
- objspace->rgengc.old_objects, data.old_object_count);
- }
- if (objspace->rgengc.uncollectible_wb_unprotected_objects != data.remembered_shady_count) {
- rb_bug("inconsistent number of wb unprotected objects: expect %"PRIuSIZE", but %"PRIuSIZE".",
- objspace->rgengc.uncollectible_wb_unprotected_objects, data.remembered_shady_count);
- }
- }
-
- if (!finalizing) {
- size_t list_count = 0;
-
- {
- VALUE z = heap_pages_deferred_final;
- while (z) {
- list_count++;
- z = RZOMBIE(z)->next;
- }
- }
-
- if (heap_pages_final_slots != data.zombie_object_count ||
- heap_pages_final_slots != list_count) {
-
- rb_bug("inconsistent finalizing object count:\n"
- " expect %"PRIuSIZE"\n"
- " but %"PRIuSIZE" zombies\n"
- " heap_pages_deferred_final list has %"PRIuSIZE" items.",
- heap_pages_final_slots,
- data.zombie_object_count,
- list_count);
- }
- }
-
- gc_report(5, objspace, "gc_verify_internal_consistency: OK\n");
-}
-
-static void
-gc_verify_internal_consistency(rb_objspace_t *objspace)
-{
- RB_VM_LOCK_ENTER();
- {
- rb_vm_barrier(); // stop other ractors
-
- unsigned int prev_during_gc = during_gc;
- during_gc = FALSE; // stop gc here
- {
- gc_verify_internal_consistency_(objspace);
- }
- during_gc = prev_during_gc;
- }
- RB_VM_LOCK_LEAVE();
-}
-
void
-rb_gc_verify_internal_consistency(void)
+rb_objspace_each_objects(int (*callback)(void *, void *, size_t, void *), void *data)
{
- gc_verify_internal_consistency(&rb_objspace);
-}
-
-static VALUE
-gc_verify_transient_heap_internal_consistency(VALUE dmy)
-{
- rb_transient_heap_verify();
- return Qnil;
+ rb_gc_impl_each_objects(rb_gc_get_objspace(), callback, data);
}
static void
-heap_move_pooled_pages_to_free_pages(rb_heap_t *heap)
+gc_ref_update_array(void *objspace, VALUE v)
{
- if (heap->pooled_pages) {
- if (heap->free_pages) {
- struct heap_page *free_pages_tail = heap->free_pages;
- while (free_pages_tail->free_next) {
- free_pages_tail = free_pages_tail->free_next;
- }
- free_pages_tail->free_next = heap->pooled_pages;
- }
- else {
- heap->free_pages = heap->pooled_pages;
- }
-
- heap->pooled_pages = NULL;
- }
-}
+ if (ARY_SHARED_P(v)) {
+ VALUE old_root = RARRAY(v)->as.heap.aux.shared_root;
-/* marks */
+ UPDATE_IF_MOVED(objspace, RARRAY(v)->as.heap.aux.shared_root);
-static void
-gc_marks_start(rb_objspace_t *objspace, int full_mark)
-{
- /* start marking */
- gc_report(1, objspace, "gc_marks_start: (%s)\n", full_mark ? "full" : "minor");
- gc_mode_transition(objspace, gc_mode_marking);
-
- if (full_mark) {
- size_t incremental_marking_steps = (objspace->rincgc.pooled_slots / INCREMENTAL_MARK_STEP_ALLOCATIONS) + 1;
- objspace->rincgc.step_slots = (objspace->marked_slots * 2) / incremental_marking_steps;
-
- if (0) fprintf(stderr, "objspace->marked_slots: %"PRIdSIZE", "
- "objspace->rincgc.pooled_page_num: %"PRIdSIZE", "
- "objspace->rincgc.step_slots: %"PRIdSIZE", \n",
- objspace->marked_slots, objspace->rincgc.pooled_slots, objspace->rincgc.step_slots);
- objspace->flags.during_minor_gc = FALSE;
- if (ruby_enable_autocompact) {
- objspace->flags.during_compacting |= TRUE;
- }
- objspace->profile.major_gc_count++;
- objspace->rgengc.uncollectible_wb_unprotected_objects = 0;
- objspace->rgengc.old_objects = 0;
- objspace->rgengc.last_major_gc = objspace->profile.count;
- objspace->marked_slots = 0;
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- rgengc_mark_and_rememberset_clear(objspace, heap);
- heap_move_pooled_pages_to_free_pages(heap);
+ VALUE new_root = RARRAY(v)->as.heap.aux.shared_root;
+ // If the root is embedded and its location has changed
+ if (ARY_EMBED_P(new_root) && new_root != old_root) {
+ size_t offset = (size_t)(RARRAY(v)->as.heap.ptr - RARRAY(old_root)->as.ary);
+ GC_ASSERT(RARRAY(v)->as.heap.ptr >= RARRAY(old_root)->as.ary);
+ RARRAY(v)->as.heap.ptr = RARRAY(new_root)->as.ary + offset;
}
}
else {
- objspace->flags.during_minor_gc = TRUE;
- objspace->marked_slots =
- objspace->rgengc.old_objects + objspace->rgengc.uncollectible_wb_unprotected_objects; /* uncollectible objects are marked already */
- objspace->profile.minor_gc_count++;
+ long len = RARRAY_LEN(v);
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rgengc_rememberset_mark(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
+ if (len > 0) {
+ VALUE *ptr = (VALUE *)RARRAY_CONST_PTR(v);
+ for (long i = 0; i < len; i++) {
+ UPDATE_IF_MOVED(objspace, ptr[i]);
+ }
}
- }
-
- gc_mark_roots(objspace, NULL);
-
- gc_report(1, objspace, "gc_marks_start: (%s) end, stack in %"PRIdSIZE"\n",
- full_mark ? "full" : "minor", mark_stack_size(&objspace->mark_stack));
-}
-static inline void
-gc_marks_wb_unprotected_objects_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bits)
-{
- if (bits) {
- do {
- if (bits & 1) {
- gc_report(2, objspace, "gc_marks_wb_unprotected_objects: marked shady: %s\n", obj_info((VALUE)p));
- GC_ASSERT(RVALUE_WB_UNPROTECTED((VALUE)p));
- GC_ASSERT(RVALUE_MARKED((VALUE)p));
- gc_mark_children(objspace, (VALUE)p);
+ if (rb_gc_obj_slot_size(v) >= rb_ary_size_as_embedded(v)) {
+ if (rb_ary_embeddable_p(v)) {
+ rb_ary_make_embedded(v);
}
- p += BASE_SLOT_SIZE;
- bits >>= 1;
- } while (bits);
- }
-}
-
-static void
-gc_marks_wb_unprotected_objects(rb_objspace_t *objspace, rb_heap_t *heap)
-{
- struct heap_page *page = 0;
-
- ccan_list_for_each(&heap->pages, page, page_node) {
- bits_t *mark_bits = page->mark_bits;
- bits_t *wbun_bits = page->wb_unprotected_bits;
- uintptr_t p = page->start;
- size_t j;
-
- bits_t bits = mark_bits[0] & wbun_bits[0];
- bits >>= NUM_IN_PAGE(p);
- gc_marks_wb_unprotected_objects_plane(objspace, p, bits);
- p += (BITS_BITLENGTH - NUM_IN_PAGE(p)) * BASE_SLOT_SIZE;
-
- for (j=1; j<HEAP_PAGE_BITMAP_LIMIT; j++) {
- bits_t bits = mark_bits[j] & wbun_bits[j];
-
- gc_marks_wb_unprotected_objects_plane(objspace, p, bits);
- p += BITS_BITLENGTH * BASE_SLOT_SIZE;
}
}
-
- gc_mark_stacked_objects_all(objspace);
}
static void
-gc_marks_finish(rb_objspace_t *objspace)
+gc_ref_update_object(void *objspace, VALUE v)
{
- /* finish incremental GC */
- if (is_incremental_marking(objspace)) {
- if (RGENGC_CHECK_MODE && is_mark_stack_empty(&objspace->mark_stack) == 0) {
- rb_bug("gc_marks_finish: mark stack is not empty (%"PRIdSIZE").",
- mark_stack_size(&objspace->mark_stack));
- }
-
- gc_mark_roots(objspace, 0);
- while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == false);
+ VALUE *ptr = ROBJECT_FIELDS(v);
-#if RGENGC_CHECK_MODE >= 2
- if (gc_verify_heap_pages(objspace) != 0) {
- rb_bug("gc_marks_finish (incremental): there are remembered old objects.");
+ if (FL_TEST_RAW(v, ROBJECT_HEAP)) {
+ if (rb_obj_shape_complex_p(v)) {
+ gc_ref_update_table_values_only(ROBJECT_FIELDS_HASH(v));
+ return;
}
-#endif
- objspace->flags.during_incremental_marking = FALSE;
- /* check children of all marked wb-unprotected objects */
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- gc_marks_wb_unprotected_objects(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
+ size_t slot_size = rb_gc_obj_slot_size(v);
+ size_t embed_size = rb_obj_embedded_size(ROBJECT_FIELDS_CAPACITY(v));
+ if (slot_size >= embed_size) {
+ // Object can be re-embedded
+ memcpy(ROBJECT(v)->as.ary, ptr, sizeof(VALUE) * ROBJECT_FIELDS_COUNT(v));
+ SIZED_FREE_N(ptr, ROBJECT_FIELDS_CAPACITY(v));
+ FL_UNSET_RAW(v, ROBJECT_HEAP);
+ ptr = ROBJECT(v)->as.ary;
}
}
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
-
-#if RGENGC_CHECK_MODE >= 4
- during_gc = FALSE;
- gc_marks_check(objspace, gc_check_after_marks_i, "after_marks");
- during_gc = TRUE;
-#endif
-
- {
- /* decide full GC is needed or not */
- size_t total_slots = heap_allocatable_slots(objspace) + heap_eden_total_slots(objspace);
- size_t sweep_slots = total_slots - objspace->marked_slots; /* will be swept slots */
- size_t max_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_max_ratio);
- size_t min_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_min_ratio);
- int full_marking = is_full_marking(objspace);
- const int r_cnt = GET_VM()->ractor.cnt;
- const int r_mul = r_cnt > 8 ? 8 : r_cnt; // upto 8
-
- GC_ASSERT(heap_eden_total_slots(objspace) >= objspace->marked_slots);
-
- /* setup free-able page counts */
- if (max_free_slots < gc_params.heap_init_slots * r_mul) {
- max_free_slots = gc_params.heap_init_slots * r_mul;
- }
-
- if (sweep_slots > max_free_slots) {
- heap_pages_freeable_pages = (sweep_slots - max_free_slots) / HEAP_PAGE_OBJ_LIMIT;
- }
- else {
- heap_pages_freeable_pages = 0;
- }
-
- /* check free_min */
- if (min_free_slots < gc_params.heap_free_slots * r_mul) {
- min_free_slots = gc_params.heap_free_slots * r_mul;
- }
-
- if (sweep_slots < min_free_slots) {
- if (!full_marking) {
- if (objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE) {
- full_marking = TRUE;
- /* do not update last_major_gc, because full marking is not done. */
- /* goto increment; */
- }
- else {
- gc_report(1, objspace, "gc_marks_finish: next is full GC!!)\n");
- objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_NOFREE;
- }
- }
-
-#if !USE_RVARGC
- if (full_marking) {
- /* increment: */
- gc_report(1, objspace, "gc_marks_finish: heap_set_increment!!\n");
- rb_size_pool_t *size_pool = &size_pools[0];
- size_pool_allocatable_pages_set(objspace, size_pool, heap_extend_pages(objspace, size_pool, sweep_slots, total_slots, heap_allocated_pages + heap_allocatable_pages(objspace)));
-
- heap_increment(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
- }
-#endif
- }
-
- if (full_marking) {
- /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
- const double r = gc_params.oldobject_limit_factor;
- objspace->rgengc.uncollectible_wb_unprotected_objects_limit = (size_t)(objspace->rgengc.uncollectible_wb_unprotected_objects * r);
- objspace->rgengc.old_objects_limit = (size_t)(objspace->rgengc.old_objects * r);
- }
-
- if (objspace->rgengc.uncollectible_wb_unprotected_objects > objspace->rgengc.uncollectible_wb_unprotected_objects_limit) {
- objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_SHADY;
- }
- if (objspace->rgengc.old_objects > objspace->rgengc.old_objects_limit) {
- objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_OLDGEN;
- }
- if (RGENGC_FORCE_MAJOR_GC) {
- objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_FORCE;
- }
-
- gc_report(1, objspace, "gc_marks_finish (marks %"PRIdSIZE" objects, "
- "old %"PRIdSIZE" objects, total %"PRIdSIZE" slots, "
- "sweep %"PRIdSIZE" slots, increment: %"PRIdSIZE", next GC: %s)\n",
- objspace->marked_slots, objspace->rgengc.old_objects, heap_eden_total_slots(objspace), sweep_slots, heap_allocatable_pages(objspace),
- objspace->rgengc.need_major_gc ? "major" : "minor");
+ for (uint32_t i = 0; i < ROBJECT_FIELDS_COUNT(v); i++) {
+ UPDATE_IF_MOVED(objspace, ptr[i]);
}
-
- rb_transient_heap_finish_marking();
- rb_ractor_finish_marking();
-
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_MARK, 0);
}
-static bool
-gc_compact_heap_cursors_met_p(rb_heap_t *heap)
+void
+rb_gc_ref_update_table_values_only(st_table *tbl)
{
- return heap->sweeping_page == heap->compact_cursor;
+ gc_ref_update_table_values_only(tbl);
}
-static rb_size_pool_t *
-gc_compact_destination_pool(rb_objspace_t *objspace, rb_size_pool_t *src_pool, VALUE src)
+/* Update MOVED references in a VALUE=>VALUE st_table */
+void
+rb_gc_update_tbl_refs(st_table *ptr)
{
- size_t obj_size;
- size_t idx = 0;
-
- switch (BUILTIN_TYPE(src)) {
- case T_ARRAY:
- obj_size = rb_ary_size_as_embedded(src);
- break;
-
- case T_OBJECT:
- if (rb_shape_obj_too_complex(src)) {
- return &size_pools[0];
- }
- else {
- obj_size = rb_obj_embedded_size(ROBJECT_IV_CAPACITY(src));
- }
- break;
-
- case T_STRING:
- obj_size = rb_str_size_as_embedded(src);
- break;
-
- default:
- return src_pool;
- }
-
- if (rb_gc_size_allocatable_p(obj_size)){
- idx = size_pool_idx_for_size(obj_size);
- }
- return &size_pools[idx];
+ gc_update_table_refs(ptr);
}
-static bool
-gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, rb_size_pool_t *size_pool, VALUE src)
+static int
+rb_gc_update_set_refs_i(st_data_t key, st_data_t value, st_data_t argp, int error)
{
- GC_ASSERT(BUILTIN_TYPE(src) != T_MOVED);
- GC_ASSERT(gc_is_moveable_obj(objspace, src));
-
- rb_size_pool_t *dest_pool = gc_compact_destination_pool(objspace, size_pool, src);
- rb_heap_t *dheap = SIZE_POOL_EDEN_HEAP(dest_pool);
- rb_shape_t *new_shape = NULL;
- rb_shape_t *orig_shape = NULL;
-
- if (gc_compact_heap_cursors_met_p(dheap)) {
- return dheap != heap;
- }
-
- if (RB_TYPE_P(src, T_OBJECT)) {
- orig_shape = rb_shape_get_shape(src);
- if (dheap != heap && !rb_shape_obj_too_complex(src)) {
- rb_shape_t *initial_shape = rb_shape_get_shape_by_id((shape_id_t)((dest_pool - size_pools) + SIZE_POOL_COUNT));
- new_shape = rb_shape_traverse_from_new_root(initial_shape, orig_shape);
-
- if (!new_shape) {
- dest_pool = size_pool;
- dheap = heap;
- }
- }
- }
-
- while (!try_move(objspace, dheap, dheap->free_pages, src)) {
- struct gc_sweep_context ctx = {
- .page = dheap->sweeping_page,
- .final_slots = 0,
- .freed_slots = 0,
- .empty_slots = 0,
- };
-
- /* The page of src could be partially compacted, so it may contain
- * T_MOVED. Sweeping a page may read objects on this page, so we
- * need to lock the page. */
- lock_page_body(objspace, GET_PAGE_BODY(src));
- gc_sweep_page(objspace, dheap, &ctx);
- unlock_page_body(objspace, GET_PAGE_BODY(src));
-
- if (dheap->sweeping_page->free_slots > 0) {
- heap_add_freepage(dheap, dheap->sweeping_page);
- }
-
- dheap->sweeping_page = ccan_list_next(&dheap->pages, dheap->sweeping_page, page_node);
- if (gc_compact_heap_cursors_met_p(dheap)) {
- return dheap != heap;
- }
- }
-
- if (orig_shape) {
- if (new_shape) {
- VALUE dest = rb_gc_location(src);
- rb_shape_set_shape(dest, new_shape);
- }
- RMOVED(src)->original_shape_id = rb_shape_id(orig_shape);
+ if (rb_gc_location((VALUE)key) != (VALUE)key) {
+ return ST_REPLACE;
}
- return true;
-}
-
-static bool
-gc_compact_plane(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct heap_page *page)
-{
- short slot_size = page->slot_size;
- short slot_bits = slot_size / BASE_SLOT_SIZE;
- GC_ASSERT(slot_bits > 0);
-
- do {
- VALUE vp = (VALUE)p;
- GC_ASSERT(vp % sizeof(RVALUE) == 0);
-
- if (bitset & 1) {
- objspace->rcompactor.considered_count_table[BUILTIN_TYPE(vp)]++;
-
- if (gc_is_moveable_obj(objspace, vp)) {
- if (!gc_compact_move(objspace, heap, size_pool, vp)) {
- //the cursors met. bubble up
- return false;
- }
- }
- }
- p += slot_size;
- bitset >>= slot_bits;
- } while (bitset);
-
- return true;
+ return ST_CONTINUE;
}
-// Iterate up all the objects in page, moving them to where they want to go
-static bool
-gc_compact_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, struct heap_page *page)
+static int
+rb_gc_update_set_refs_replace_i(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
{
- GC_ASSERT(page == heap->compact_cursor);
-
- bits_t *mark_bits, *pin_bits;
- bits_t bitset;
- uintptr_t p = page->start;
-
- mark_bits = page->mark_bits;
- pin_bits = page->pinned_bits;
-
- // objects that can be moved are marked and not pinned
- bitset = (mark_bits[0] & ~pin_bits[0]);
- bitset >>= NUM_IN_PAGE(p);
- if (bitset) {
- if (!gc_compact_plane(objspace, size_pool, heap, (uintptr_t)p, bitset, page))
- return false;
- }
- p += (BITS_BITLENGTH - NUM_IN_PAGE(p)) * BASE_SLOT_SIZE;
-
- for (int j = 1; j < HEAP_PAGE_BITMAP_LIMIT; j++) {
- bitset = (mark_bits[j] & ~pin_bits[j]);
- if (bitset) {
- if (!gc_compact_plane(objspace, size_pool, heap, (uintptr_t)p, bitset, page))
- return false;
- }
- p += BITS_BITLENGTH * BASE_SLOT_SIZE;
+ if (rb_gc_location((VALUE)*key) != (VALUE)*key) {
+ *key = rb_gc_location((VALUE)*key);
}
- return true;
+ return ST_CONTINUE;
}
-static bool
-gc_compact_all_compacted_p(rb_objspace_t *objspace)
+void
+rb_gc_update_set_refs(st_table *tbl)
{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ if (!tbl || tbl->num_entries == 0) return;
- if (heap->total_pages > 0 &&
- !gc_compact_heap_cursors_met_p(heap)) {
- return false;
- }
+ if (st_foreach_with_replace(tbl, rb_gc_update_set_refs_i, rb_gc_update_set_refs_replace_i, 0)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
}
-
- return true;
}
static void
-gc_sweep_compact(rb_objspace_t *objspace)
+gc_ref_update_hash(void *objspace, VALUE v)
{
- gc_compact_start(objspace);
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
-
- while (!gc_compact_all_compacted_p(objspace)) {
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
-
- if (gc_compact_heap_cursors_met_p(heap)) {
- continue;
- }
-
- struct heap_page *start_page = heap->compact_cursor;
-
- if (!gc_compact_page(objspace, size_pool, heap, start_page)) {
- lock_page_body(objspace, GET_PAGE_BODY(start_page->start));
-
- continue;
- }
-
- // If we get here, we've finished moving all objects on the compact_cursor page
- // So we can lock it and move the cursor on to the next one.
- lock_page_body(objspace, GET_PAGE_BODY(start_page->start));
- heap->compact_cursor = ccan_list_prev(&heap->pages, heap->compact_cursor, page_node);
- }
- }
-
- gc_compact_finish(objspace);
-
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
+ rb_hash_stlike_foreach_with_replace(v, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace);
}
static void
-gc_marks_rest(rb_objspace_t *objspace)
+gc_update_values(void *objspace, long n, VALUE *values)
{
- gc_report(1, objspace, "gc_marks_rest\n");
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- SIZE_POOL_EDEN_HEAP(&size_pools[i])->pooled_pages = NULL;
- }
-
- if (is_incremental_marking(objspace)) {
- while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == FALSE);
- }
- else {
- gc_mark_stacked_objects_all(objspace);
+ for (long i = 0; i < n; i++) {
+ UPDATE_IF_MOVED(objspace, values[i]);
}
-
- gc_marks_finish(objspace);
}
-static bool
-gc_marks_step(rb_objspace_t *objspace, size_t slots)
+void
+rb_gc_update_values(long n, VALUE *values)
{
- bool marking_finished = false;
-
- GC_ASSERT(is_marking(objspace));
- if (gc_mark_stacked_objects_incremental(objspace, slots)) {
- gc_marks_finish(objspace);
-
- marking_finished = true;
- }
-
- return marking_finished;
+ gc_update_values(rb_gc_get_objspace(), n, values);
}
-static bool
-gc_marks_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
+static enum rb_id_table_iterator_result
+check_id_table_move(VALUE value, void *data)
{
- GC_ASSERT(dont_gc_val() == FALSE);
- bool marking_finished = true;
+ void *objspace = (void *)data;
- gc_marking_enter(objspace);
-
- if (heap->free_pages) {
- gc_report(2, objspace, "gc_marks_continue: has pooled pages");
-
- marking_finished = gc_marks_step(objspace, objspace->rincgc.step_slots);
- }
- else {
- gc_report(2, objspace, "gc_marks_continue: no more pooled pages (stack depth: %"PRIdSIZE").\n",
- mark_stack_size(&objspace->mark_stack));
- gc_marks_rest(objspace);
+ if (gc_object_moved_p_internal(objspace, (VALUE)value)) {
+ return ID_TABLE_REPLACE;
}
- gc_marking_exit(objspace);
-
- return marking_finished;
+ return ID_TABLE_CONTINUE;
}
-static bool
-gc_marks(rb_objspace_t *objspace, int full_mark)
+void
+rb_gc_prepare_heap_process_object(VALUE obj)
{
- gc_prof_mark_timer_start(objspace);
- gc_marking_enter(objspace);
-
- bool marking_finished = false;
-
- /* setup marking */
-
- gc_marks_start(objspace, full_mark);
- if (!is_incremental_marking(objspace)) {
- gc_marks_rest(objspace);
- marking_finished = true;
- }
-
-#if RGENGC_PROFILE > 0
- if (gc_prof_record(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->old_objects = objspace->rgengc.old_objects;
+ switch (BUILTIN_TYPE(obj)) {
+ case T_STRING:
+ // Precompute the string coderange. This both save time for when it will be
+ // eventually needed, and avoid mutating heap pages after a potential fork.
+ rb_enc_str_coderange(obj);
+ break;
+ default:
+ break;
}
-#endif
-
- gc_marking_exit(objspace);
- gc_prof_mark_timer_stop(objspace);
-
- return marking_finished;
}
-/* RGENGC */
-
-static void
-gc_report_body(int level, rb_objspace_t *objspace, const char *fmt, ...)
+void
+rb_gc_prepare_heap(void)
{
- if (level <= RGENGC_DEBUG) {
- char buf[1024];
- FILE *out = stderr;
- va_list args;
- const char *status = " ";
-
- if (during_gc) {
- status = is_full_marking(objspace) ? "+" : "-";
- }
- else {
- if (is_lazy_sweeping(objspace)) {
- status = "S";
- }
- if (is_incremental_marking(objspace)) {
- status = "M";
- }
- }
-
- va_start(args, fmt);
- vsnprintf(buf, 1024, fmt, args);
- va_end(args);
-
- fprintf(out, "%s|", status);
- fputs(buf, out);
- }
+ rb_gc_impl_prepare_heap(rb_gc_get_objspace());
}
-/* bit operations */
-
-static int
-rgengc_remembersetbits_get(rb_objspace_t *objspace, VALUE obj)
+size_t
+rb_gc_heap_id_for_size(size_t size)
{
- return RVALUE_REMEMBERED(obj);
+ return rb_gc_impl_heap_id_for_size(rb_gc_get_objspace(), size);
}
-static int
-rgengc_remembersetbits_set(rb_objspace_t *objspace, VALUE obj)
+bool
+rb_gc_size_allocatable_p(size_t size)
{
- struct heap_page *page = GET_HEAP_PAGE(obj);
- bits_t *bits = &page->marking_bits[0];
-
- GC_ASSERT(!is_incremental_marking(objspace));
-
- if (MARKED_IN_BITMAP(bits, obj)) {
- return FALSE;
- }
- else {
- page->flags.has_remembered_objects = TRUE;
- MARK_IN_BITMAP(bits, obj);
- return TRUE;
- }
+ return rb_gc_impl_size_allocatable_p(size);
}
-/* wb, etc */
-
-/* return FALSE if already remembered */
-static int
-rgengc_remember(rb_objspace_t *objspace, VALUE obj)
+static enum rb_id_table_iterator_result
+update_id_table(VALUE *value, void *data, int existing)
{
- gc_report(6, objspace, "rgengc_remember: %s %s\n", obj_info(obj),
- rgengc_remembersetbits_get(objspace, obj) ? "was already remembered" : "is remembered now");
-
- check_rvalue_consistency(obj);
-
- if (RGENGC_CHECK_MODE) {
- if (RVALUE_WB_UNPROTECTED(obj)) rb_bug("rgengc_remember: %s is not wb protected.", obj_info(obj));
- }
+ void *objspace = (void *)data;
-#if RGENGC_PROFILE > 0
- if (!rgengc_remembered(objspace, obj)) {
- if (RVALUE_WB_UNPROTECTED(obj) == 0) {
- objspace->profile.total_remembered_normal_object_count++;
-#if RGENGC_PROFILE >= 2
- objspace->profile.remembered_normal_object_count_types[BUILTIN_TYPE(obj)]++;
-#endif
- }
+ if (gc_object_moved_p_internal(objspace, (VALUE)*value)) {
+ *value = gc_location_internal(objspace, (VALUE)*value);
}
-#endif /* RGENGC_PROFILE > 0 */
-
- return rgengc_remembersetbits_set(objspace, obj);
-}
-
-static int
-rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj)
-{
- int result = rgengc_remembersetbits_get(objspace, obj);
- check_rvalue_consistency(obj);
- return result;
-}
-static int
-rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
-{
- gc_report(6, objspace, "rgengc_remembered: %s\n", obj_info(obj));
- return rgengc_remembered_sweep(objspace, obj);
-}
-
-#ifndef PROFILE_REMEMBERSET_MARK
-#define PROFILE_REMEMBERSET_MARK 0
-#endif
-
-static inline void
-rgengc_rememberset_mark_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bitset)
-{
- if (bitset) {
- do {
- if (bitset & 1) {
- VALUE obj = (VALUE)p;
- gc_report(2, objspace, "rgengc_rememberset_mark: mark %s\n", obj_info(obj));
- GC_ASSERT(RVALUE_UNCOLLECTIBLE(obj));
- GC_ASSERT(RVALUE_OLD_P(obj) || RVALUE_WB_UNPROTECTED(obj));
-
- gc_mark_children(objspace, obj);
- }
- p += BASE_SLOT_SIZE;
- bitset >>= 1;
- } while (bitset);
- }
+ return ID_TABLE_CONTINUE;
}
static void
-rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
+update_m_tbl(void *objspace, struct rb_id_table *tbl)
{
- size_t j;
- struct heap_page *page = 0;
-#if PROFILE_REMEMBERSET_MARK
- int has_old = 0, has_shady = 0, has_both = 0, skip = 0;
-#endif
- gc_report(1, objspace, "rgengc_rememberset_mark: start\n");
-
- ccan_list_for_each(&heap->pages, page, page_node) {
- if (page->flags.has_remembered_objects | page->flags.has_uncollectible_shady_objects) {
- uintptr_t p = page->start;
- bits_t bitset, bits[HEAP_PAGE_BITMAP_LIMIT];
- bits_t *marking_bits = page->marking_bits;
- bits_t *uncollectible_bits = page->uncollectible_bits;
- bits_t *wb_unprotected_bits = page->wb_unprotected_bits;
-#if PROFILE_REMEMBERSET_MARK
- if (page->flags.has_remembered_objects && page->flags.has_uncollectible_shady_objects) has_both++;
- else if (page->flags.has_remembered_objects) has_old++;
- else if (page->flags.has_uncollectible_shady_objects) has_shady++;
-#endif
- for (j=0; j<HEAP_PAGE_BITMAP_LIMIT; j++) {
- bits[j] = marking_bits[j] | (uncollectible_bits[j] & wb_unprotected_bits[j]);
- marking_bits[j] = 0;
- }
- page->flags.has_remembered_objects = FALSE;
-
- bitset = bits[0];
- bitset >>= NUM_IN_PAGE(p);
- rgengc_rememberset_mark_plane(objspace, p, bitset);
- p += (BITS_BITLENGTH - NUM_IN_PAGE(p)) * BASE_SLOT_SIZE;
-
- for (j=1; j < HEAP_PAGE_BITMAP_LIMIT; j++) {
- bitset = bits[j];
- rgengc_rememberset_mark_plane(objspace, p, bitset);
- p += BITS_BITLENGTH * BASE_SLOT_SIZE;
- }
- }
-#if PROFILE_REMEMBERSET_MARK
- else {
- skip++;
- }
-#endif
+ if (tbl) {
+ rb_id_table_foreach_values_with_replace(tbl, check_id_table_move, update_id_table, objspace);
}
-
-#if PROFILE_REMEMBERSET_MARK
- fprintf(stderr, "%d\t%d\t%d\t%d\n", has_both, has_old, has_shady, skip);
-#endif
- gc_report(1, objspace, "rgengc_rememberset_mark: finished\n");
}
-static void
-rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap)
+static enum rb_id_table_iterator_result
+update_const_tbl_i(VALUE value, void *objspace)
{
- struct heap_page *page = 0;
+ rb_const_entry_t *ce = (rb_const_entry_t *)value;
- ccan_list_for_each(&heap->pages, page, page_node) {
- memset(&page->mark_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- memset(&page->uncollectible_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- memset(&page->marking_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- memset(&page->pinned_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- page->flags.has_uncollectible_shady_objects = FALSE;
- page->flags.has_remembered_objects = FALSE;
+ if (gc_object_moved_p_internal(objspace, ce->value)) {
+ ce->value = gc_location_internal(objspace, ce->value);
}
-}
-
-/* RGENGC: APIs */
-NOINLINE(static void gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace));
-
-static void
-gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace)
-{
- if (RGENGC_CHECK_MODE) {
- if (!RVALUE_OLD_P(a)) rb_bug("gc_writebarrier_generational: %s is not an old object.", obj_info(a));
- if ( RVALUE_OLD_P(b)) rb_bug("gc_writebarrier_generational: %s is an old object.", obj_info(b));
- if (is_incremental_marking(objspace)) rb_bug("gc_writebarrier_generational: called while incremental marking: %s -> %s", obj_info(a), obj_info(b));
+ if (gc_object_moved_p_internal(objspace, ce->file)) {
+ ce->file = gc_location_internal(objspace, ce->file);
}
-#if 1
- /* mark `a' and remember (default behavior) */
- if (!rgengc_remembered(objspace, a)) {
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
- rgengc_remember(objspace, a);
- }
- RB_VM_LOCK_LEAVE_NO_BARRIER();
- gc_report(1, objspace, "gc_writebarrier_generational: %s (remembered) -> %s\n", obj_info(a), obj_info(b));
- }
-#else
- /* mark `b' and remember */
- MARK_IN_BITMAP(GET_HEAP_MARK_BITS(b), b);
- if (RVALUE_WB_UNPROTECTED(b)) {
- gc_remember_unprotected(objspace, b);
- }
- else {
- RVALUE_AGE_SET_OLD(objspace, b);
- rgengc_remember(objspace, b);
- }
-
- gc_report(1, objspace, "gc_writebarrier_generational: %s -> %s (remembered)\n", obj_info(a), obj_info(b));
-#endif
-
- check_rvalue_consistency(a);
- check_rvalue_consistency(b);
+ return ID_TABLE_CONTINUE;
}
static void
-gc_mark_from(rb_objspace_t *objspace, VALUE obj, VALUE parent)
+update_const_tbl(void *objspace, struct rb_id_table *tbl)
{
- gc_mark_set_parent(objspace, parent);
- rgengc_check_relation(objspace, obj);
- if (gc_mark_set(objspace, obj) == FALSE) return;
- gc_aging(objspace, obj);
- gc_grey(objspace, obj);
+ if (!tbl) return;
+ rb_id_table_foreach_values(tbl, update_const_tbl_i, objspace);
}
-NOINLINE(static void gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace));
-
static void
-gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace)
-{
- gc_report(2, objspace, "gc_writebarrier_incremental: [LG] %p -> %s\n", (void *)a, obj_info(b));
-
- if (RVALUE_BLACK_P(a)) {
- if (RVALUE_WHITE_P(b)) {
- if (!RVALUE_WB_UNPROTECTED(a)) {
- gc_report(2, objspace, "gc_writebarrier_incremental: [IN] %p -> %s\n", (void *)a, obj_info(b));
- gc_mark_from(objspace, b, a);
- }
- }
- else if (RVALUE_OLD_P(a) && !RVALUE_OLD_P(b)) {
- if (!RVALUE_WB_UNPROTECTED(b)) {
- gc_report(1, objspace, "gc_writebarrier_incremental: [GN] %p -> %s\n", (void *)a, obj_info(b));
- RVALUE_AGE_SET_OLD(objspace, b);
-
- if (RVALUE_BLACK_P(b)) {
- gc_grey(objspace, b);
- }
- }
- else {
- gc_report(1, objspace, "gc_writebarrier_incremental: [LL] %p -> %s\n", (void *)a, obj_info(b));
- gc_remember_unprotected(objspace, b);
- }
- }
-
- if (UNLIKELY(objspace->flags.during_compacting)) {
- MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(b), b);
- }
- }
-}
-
-void
-rb_gc_writebarrier(VALUE a, VALUE b)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- if (RGENGC_CHECK_MODE) {
- if (SPECIAL_CONST_P(a)) rb_bug("rb_gc_writebarrier: a is special const: %"PRIxVALUE, a);
- if (SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const: %"PRIxVALUE, b);
- }
-
- retry:
- if (!is_incremental_marking(objspace)) {
- if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) {
- // do nothing
- }
- else {
- gc_writebarrier_generational(a, b, objspace);
- }
- }
- else {
- bool retry = false;
- /* slow path */
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
- if (is_incremental_marking(objspace)) {
- gc_writebarrier_incremental(a, b, objspace);
- }
- else {
- retry = true;
- }
- }
- RB_VM_LOCK_LEAVE_NO_BARRIER();
-
- if (retry) goto retry;
- }
- return;
-}
-
-void
-rb_gc_writebarrier_unprotect(VALUE obj)
+update_superclasses(rb_objspace_t *objspace, rb_classext_t *ext)
{
- if (RVALUE_WB_UNPROTECTED(obj)) {
- return;
- }
- else {
- rb_objspace_t *objspace = &rb_objspace;
-
- gc_report(2, objspace, "rb_gc_writebarrier_unprotect: %s %s\n", obj_info(obj),
- rgengc_remembered(objspace, obj) ? " (already remembered)" : "");
-
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
- if (RVALUE_OLD_P(obj)) {
- gc_report(1, objspace, "rb_gc_writebarrier_unprotect: %s\n", obj_info(obj));
- RVALUE_DEMOTE(objspace, obj);
- gc_mark_set(objspace, obj);
- gc_remember_unprotected(objspace, obj);
-
-#if RGENGC_PROFILE
- objspace->profile.total_shade_operation_count++;
-#if RGENGC_PROFILE >= 2
- objspace->profile.shade_operation_count_types[BUILTIN_TYPE(obj)]++;
-#endif /* RGENGC_PROFILE >= 2 */
-#endif /* RGENGC_PROFILE */
- }
- else {
- RVALUE_AGE_RESET(obj);
- }
-
- RB_DEBUG_COUNTER_INC(obj_wb_unprotect);
- MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
+ if (RCLASSEXT_SUPERCLASSES_WITH_SELF(ext)) {
+ size_t array_size = RCLASSEXT_SUPERCLASS_DEPTH(ext) + 1;
+ for (size_t i = 0; i < array_size; i++) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_SUPERCLASSES(ext)[i]);
}
- RB_VM_LOCK_LEAVE_NO_BARRIER();
}
}
-/*
- * remember `obj' if needed.
- */
-void
-rb_gc_writebarrier_remember(VALUE obj)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- gc_report(1, objspace, "rb_gc_writebarrier_remember: %s\n", obj_info(obj));
-
- if (is_incremental_marking(objspace)) {
- if (RVALUE_BLACK_P(obj)) {
- gc_grey(objspace, obj);
- }
- }
- else {
- if (RVALUE_OLD_P(obj)) {
- rgengc_remember(objspace, obj);
- }
- }
-}
-
-void
-rb_copy_wb_protected_attribute(VALUE dest, VALUE obj)
+static void
+update_classext_values(rb_objspace_t *objspace, rb_classext_t *ext, bool is_iclass)
{
- rb_objspace_t *objspace = &rb_objspace;
-
- if (RVALUE_WB_UNPROTECTED(obj) && !RVALUE_WB_UNPROTECTED(dest)) {
- if (!RVALUE_OLD_P(dest)) {
- MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
- RVALUE_AGE_RESET_RAW(dest);
- }
- else {
- RVALUE_DEMOTE(objspace, dest);
- }
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_ORIGIN(ext));
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_REFINED_CLASS(ext));
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_CLASSPATH(ext));
+ if (is_iclass) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_INCLUDER(ext));
}
-
- check_rvalue_consistency(dest);
-}
-
-/* RGENGC analysis information */
-
-VALUE
-rb_obj_rgengc_writebarrier_protected_p(VALUE obj)
-{
- return RBOOL(!RVALUE_WB_UNPROTECTED(obj));
}
-VALUE
-rb_obj_rgengc_promoted_p(VALUE obj)
-{
- return RBOOL(OBJ_PROMOTED(obj));
-}
-
-size_t
-rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
+static void
+update_classext(rb_classext_t *ext, bool is_prime, VALUE box_value, void *arg)
{
- size_t n = 0;
- static ID ID_marked;
- static ID ID_wb_protected, ID_old, ID_marking, ID_uncollectible, ID_pinned;
+ struct classext_foreach_args *args = (struct classext_foreach_args *)arg;
+ rb_objspace_t *objspace = args->objspace;
- if (!ID_marked) {
-#define I(s) ID_##s = rb_intern(#s);
- I(marked);
- I(wb_protected);
- I(old);
- I(marking);
- I(uncollectible);
- I(pinned);
-#undef I
+ if (RCLASSEXT_SUPER(ext)) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_SUPER(ext));
}
- if (RVALUE_WB_UNPROTECTED(obj) == 0 && n<max) flags[n++] = ID_wb_protected;
- if (RVALUE_OLD_P(obj) && n<max) flags[n++] = ID_old;
- if (RVALUE_UNCOLLECTIBLE(obj) && n<max) flags[n++] = ID_uncollectible;
- if (MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj) && n<max) flags[n++] = ID_marking;
- if (MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) && n<max) flags[n++] = ID_marked;
- if (MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj) && n<max) flags[n++] = ID_pinned;
- return n;
-}
-
-/* GC */
-
-void
-rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache)
-{
- newobj_cache->incremental_mark_step_allocated_slots = 0;
-
- for (size_t size_pool_idx = 0; size_pool_idx < SIZE_POOL_COUNT; size_pool_idx++) {
- rb_ractor_newobj_size_pool_cache_t *cache = &newobj_cache->size_pool_caches[size_pool_idx];
-
- struct heap_page *page = cache->using_page;
- RVALUE *freelist = cache->freelist;
- RUBY_DEBUG_LOG("ractor using_page:%p freelist:%p", (void *)page, (void *)freelist);
+ update_m_tbl(objspace, RCLASSEXT_M_TBL(ext));
- heap_page_freelist_append(page, freelist);
-
- cache->using_page = NULL;
- cache->freelist = NULL;
+ UPDATE_IF_MOVED(objspace, ext->fields_obj);
+ if (!RCLASSEXT_SHARED_CONST_TBL(ext)) {
+ update_const_tbl(objspace, RCLASSEXT_CONST_TBL(ext));
}
-}
-
-void
-rb_gc_force_recycle(VALUE obj)
-{
- /* no-op */
-}
-
-#ifndef MARK_OBJECT_ARY_BUCKET_SIZE
-#define MARK_OBJECT_ARY_BUCKET_SIZE 1024
-#endif
-
-void
-rb_gc_register_mark_object(VALUE obj)
-{
- if (!is_pointer_to_heap(&rb_objspace, (void *)obj))
- return;
-
- RB_VM_LOCK_ENTER();
- {
- VALUE ary_ary = GET_VM()->mark_object_ary;
- VALUE ary = rb_ary_last(0, 0, ary_ary);
-
- if (NIL_P(ary) || RARRAY_LEN(ary) >= MARK_OBJECT_ARY_BUCKET_SIZE) {
- ary = rb_ary_hidden_new(MARK_OBJECT_ARY_BUCKET_SIZE);
- rb_ary_push(ary_ary, ary);
- }
-
- rb_ary_push(ary, obj);
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_CC_TBL(ext));
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_CVC_TBL(ext));
+ update_superclasses(objspace, ext);
+ if (RCLASSEXT_SUBCLASSES(ext)) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_SUBCLASSES(ext));
}
- RB_VM_LOCK_LEAVE();
-}
-void
-rb_gc_register_address(VALUE *addr)
-{
- rb_objspace_t *objspace = &rb_objspace;
- struct gc_list *tmp;
-
- tmp = ALLOC(struct gc_list);
- tmp->next = global_list;
- tmp->varptr = addr;
- global_list = tmp;
+ update_classext_values(objspace, ext, false);
}
-void
-rb_gc_unregister_address(VALUE *addr)
+static void
+update_iclass_classext(rb_classext_t *ext, bool is_prime, VALUE box_value, void *arg)
{
- rb_objspace_t *objspace = &rb_objspace;
- struct gc_list *tmp = global_list;
+ struct classext_foreach_args *args = (struct classext_foreach_args *)arg;
+ rb_objspace_t *objspace = args->objspace;
- if (tmp->varptr == addr) {
- global_list = tmp->next;
- xfree(tmp);
- return;
+ if (RCLASSEXT_SUPER(ext)) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_SUPER(ext));
}
- while (tmp->next) {
- if (tmp->next->varptr == addr) {
- struct gc_list *t = tmp->next;
-
- tmp->next = tmp->next->next;
- xfree(t);
- break;
- }
- tmp = tmp->next;
+ update_m_tbl(objspace, RCLASSEXT_M_TBL(ext));
+ update_m_tbl(objspace, RCLASSEXT_CALLABLE_M_TBL(ext));
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_CC_TBL(ext));
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_CVC_TBL(ext));
+ if (RCLASSEXT_SUBCLASSES(ext)) {
+ UPDATE_IF_MOVED(objspace, RCLASSEXT_SUBCLASSES(ext));
}
-}
-void
-rb_global_variable(VALUE *var)
-{
- rb_gc_register_address(var);
+ update_classext_values(objspace, ext, true);
}
-#define GC_NOTIFY 0
-
-enum {
- gc_stress_no_major,
- gc_stress_no_immediate_sweep,
- gc_stress_full_mark_after_malloc,
- gc_stress_max
+struct global_vm_table_foreach_data {
+ vm_table_foreach_callback_func callback;
+ vm_table_update_callback_func update_callback;
+ void *data;
+ bool weak_only;
};
-#define gc_stress_full_mark_after_malloc_p() \
- (FIXNUM_P(ruby_gc_stress_mode) && (FIX2LONG(ruby_gc_stress_mode) & (1<<gc_stress_full_mark_after_malloc)))
-
-static void
-heap_ready_to_gc(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- if (!heap->free_pages) {
- if (!heap_increment(objspace, size_pool, heap)) {
- size_pool_allocatable_pages_set(objspace, size_pool, 1);
- heap_increment(objspace, size_pool, heap);
- }
- }
-}
-
static int
-ready_to_gc(rb_objspace_t *objspace)
+vm_weak_table_foreach_weak_key(st_data_t key, st_data_t value, st_data_t data, int error)
{
- if (dont_gc_val() || during_gc || ruby_disable_gc) {
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- heap_ready_to_gc(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
- }
- return FALSE;
- }
- else {
- return TRUE;
- }
-}
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
-static void
-gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
-{
- gc_prof_set_malloc_info(objspace);
- {
- size_t inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
- size_t old_limit = malloc_limit;
+ int ret = iter_data->callback((VALUE)key, iter_data->data);
- if (inc > malloc_limit) {
- malloc_limit = (size_t)(inc * gc_params.malloc_limit_growth_factor);
- if (malloc_limit > gc_params.malloc_limit_max) {
- malloc_limit = gc_params.malloc_limit_max;
- }
- }
- else {
- malloc_limit = (size_t)(malloc_limit * 0.98); /* magic number */
- if (malloc_limit < gc_params.malloc_limit_min) {
- malloc_limit = gc_params.malloc_limit_min;
- }
- }
+ if (!iter_data->weak_only) {
+ if (ret != ST_CONTINUE) return ret;
- if (0) {
- if (old_limit != malloc_limit) {
- fprintf(stderr, "[%"PRIuSIZE"] malloc_limit: %"PRIuSIZE" -> %"PRIuSIZE"\n",
- rb_gc_count(), old_limit, malloc_limit);
- }
- else {
- fprintf(stderr, "[%"PRIuSIZE"] malloc_limit: not changed (%"PRIuSIZE")\n",
- rb_gc_count(), malloc_limit);
- }
- }
+ ret = iter_data->callback((VALUE)value, iter_data->data);
}
- /* reset oldmalloc info */
-#if RGENGC_ESTIMATE_OLDMALLOC
- if (!full_mark) {
- if (objspace->rgengc.oldmalloc_increase > objspace->rgengc.oldmalloc_increase_limit) {
- objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_OLDMALLOC;
- objspace->rgengc.oldmalloc_increase_limit =
- (size_t)(objspace->rgengc.oldmalloc_increase_limit * gc_params.oldmalloc_limit_growth_factor);
-
- if (objspace->rgengc.oldmalloc_increase_limit > gc_params.oldmalloc_limit_max) {
- objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_max;
- }
- }
-
- if (0) fprintf(stderr, "%"PRIdSIZE"\t%d\t%"PRIuSIZE"\t%"PRIuSIZE"\t%"PRIdSIZE"\n",
- rb_gc_count(),
- objspace->rgengc.need_major_gc,
- objspace->rgengc.oldmalloc_increase,
- objspace->rgengc.oldmalloc_increase_limit,
- gc_params.oldmalloc_limit_max);
- }
- else {
- /* major GC */
- objspace->rgengc.oldmalloc_increase = 0;
-
- if ((objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_BY_OLDMALLOC) == 0) {
- objspace->rgengc.oldmalloc_increase_limit =
- (size_t)(objspace->rgengc.oldmalloc_increase_limit / ((gc_params.oldmalloc_limit_growth_factor - 1)/10 + 1));
- if (objspace->rgengc.oldmalloc_increase_limit < gc_params.oldmalloc_limit_min) {
- objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
- }
- }
- }
-#endif
+ return ret;
}
static int
-garbage_collect(rb_objspace_t *objspace, unsigned int reason)
+vm_weak_table_foreach_update_weak_key(st_data_t *key, st_data_t *value, st_data_t data, int existing)
{
- int ret;
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
- RB_VM_LOCK_ENTER();
- {
-#if GC_PROFILE_MORE_DETAIL
- objspace->profile.prepare_time = getrusage_time();
-#endif
-
- gc_rest(objspace);
+ int ret = iter_data->update_callback((VALUE *)key, iter_data->data);
-#if GC_PROFILE_MORE_DETAIL
- objspace->profile.prepare_time = getrusage_time() - objspace->profile.prepare_time;
-#endif
+ if (!iter_data->weak_only) {
+ if (ret != ST_CONTINUE) return ret;
- ret = gc_start(objspace, reason);
+ ret = iter_data->update_callback((VALUE *)value, iter_data->data);
}
- RB_VM_LOCK_LEAVE();
return ret;
}
static int
-gc_start(rb_objspace_t *objspace, unsigned int reason)
-{
- unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK);
- unsigned int immediate_mark = reason & GPR_FLAG_IMMEDIATE_MARK;
-
- /* reason may be clobbered, later, so keep set immediate_sweep here */
- objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);
-
- /* Explicitly enable compaction (GC.compact) */
- if (do_full_mark && ruby_enable_autocompact) {
- objspace->flags.during_compacting = TRUE;
- }
- else {
- objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
- }
-
- if (!heap_allocated_pages) return FALSE; /* heap is not ready */
- if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
-
- GC_ASSERT(gc_mode(objspace) == gc_mode_none);
- GC_ASSERT(!is_lazy_sweeping(objspace));
- GC_ASSERT(!is_incremental_marking(objspace));
-
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_start, &lock_lev);
-
-#if RGENGC_CHECK_MODE >= 2
- gc_verify_internal_consistency(objspace);
-#endif
-
- if (ruby_gc_stressful) {
- int flag = FIXNUM_P(ruby_gc_stress_mode) ? FIX2INT(ruby_gc_stress_mode) : 0;
-
- if ((flag & (1<<gc_stress_no_major)) == 0) {
- do_full_mark = TRUE;
- }
-
- objspace->flags.immediate_sweep = !(flag & (1<<gc_stress_no_immediate_sweep));
- }
- else {
- if (objspace->rgengc.need_major_gc) {
- reason |= objspace->rgengc.need_major_gc;
- do_full_mark = TRUE;
- }
- else if (RGENGC_FORCE_MAJOR_GC) {
- reason = GPR_FLAG_MAJOR_BY_FORCE;
- do_full_mark = TRUE;
- }
-
- objspace->rgengc.need_major_gc = GPR_FLAG_NONE;
- }
-
- if (do_full_mark && (reason & GPR_FLAG_MAJOR_MASK) == 0) {
- reason |= GPR_FLAG_MAJOR_BY_FORCE; /* GC by CAPI, METHOD, and so on. */
- }
-
- if (objspace->flags.dont_incremental || immediate_mark) {
- objspace->flags.during_incremental_marking = FALSE;
- }
- else {
- objspace->flags.during_incremental_marking = do_full_mark;
- }
-
- if (!GC_ENABLE_LAZY_SWEEP || objspace->flags.dont_incremental) {
- objspace->flags.immediate_sweep = TRUE;
- }
-
- if (objspace->flags.immediate_sweep) reason |= GPR_FLAG_IMMEDIATE_SWEEP;
-
- gc_report(1, objspace, "gc_start(reason: %x) => %u, %d, %d\n",
- reason,
- do_full_mark, !is_incremental_marking(objspace), objspace->flags.immediate_sweep);
-
-#if USE_DEBUG_COUNTER
- RB_DEBUG_COUNTER_INC(gc_count);
-
- if (reason & GPR_FLAG_MAJOR_MASK) {
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_nofree, reason & GPR_FLAG_MAJOR_BY_NOFREE);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldgen, reason & GPR_FLAG_MAJOR_BY_OLDGEN);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_shady, reason & GPR_FLAG_MAJOR_BY_SHADY);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_force, reason & GPR_FLAG_MAJOR_BY_FORCE);
-#if RGENGC_ESTIMATE_OLDMALLOC
- (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldmalloc, reason & GPR_FLAG_MAJOR_BY_OLDMALLOC);
-#endif
- }
- else {
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_newobj, reason & GPR_FLAG_NEWOBJ);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_malloc, reason & GPR_FLAG_MALLOC);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_method, reason & GPR_FLAG_METHOD);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_capi, reason & GPR_FLAG_CAPI);
- (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_stress, reason & GPR_FLAG_STRESS);
- }
-#endif
-
- objspace->profile.count++;
- objspace->profile.latest_gc_info = reason;
- objspace->profile.total_allocated_objects_at_gc_start = objspace->total_allocated_objects;
- objspace->profile.heap_used_at_gc_start = heap_allocated_pages;
- gc_prof_setup_new_record(objspace, reason);
- gc_reset_malloc_info(objspace, do_full_mark);
- rb_transient_heap_start_marking(do_full_mark);
-
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
- GC_ASSERT(during_gc);
-
- gc_prof_timer_start(objspace);
- {
- if (gc_marks(objspace, do_full_mark)) {
- gc_sweep(objspace);
- }
- }
- gc_prof_timer_stop(objspace);
-
- gc_exit(objspace, gc_enter_event_start, &lock_lev);
- return TRUE;
-}
-
-static void
-gc_rest(rb_objspace_t *objspace)
-{
- int marking = is_incremental_marking(objspace);
- int sweeping = is_lazy_sweeping(objspace);
-
- if (marking || sweeping) {
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_rest, &lock_lev);
-
- if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(objspace);
-
- if (is_incremental_marking(objspace)) {
- gc_marking_enter(objspace);
- gc_marks_rest(objspace);
- gc_marking_exit(objspace);
-
- gc_sweep(objspace);
- }
-
- if (is_lazy_sweeping(objspace)) {
- gc_sweeping_enter(objspace);
- gc_sweep_rest(objspace);
- gc_sweeping_exit(objspace);
- }
-
- gc_exit(objspace, gc_enter_event_rest, &lock_lev);
- }
-}
-
-struct objspace_and_reason {
- rb_objspace_t *objspace;
- unsigned int reason;
-};
-
-static void
-gc_current_status_fill(rb_objspace_t *objspace, char *buff)
-{
- int i = 0;
- if (is_marking(objspace)) {
- buff[i++] = 'M';
- if (is_full_marking(objspace)) buff[i++] = 'F';
- if (is_incremental_marking(objspace)) buff[i++] = 'I';
- }
- else if (is_sweeping(objspace)) {
- buff[i++] = 'S';
- if (is_lazy_sweeping(objspace)) buff[i++] = 'L';
- }
- else {
- buff[i++] = 'N';
- }
- buff[i] = '\0';
-}
-
-static const char *
-gc_current_status(rb_objspace_t *objspace)
-{
- static char buff[0x10];
- gc_current_status_fill(objspace, buff);
- return buff;
-}
-
-#if PRINT_ENTER_EXIT_TICK
-
-static tick_t last_exit_tick;
-static tick_t enter_tick;
-static int enter_count = 0;
-static char last_gc_status[0x10];
-
-static inline void
-gc_record(rb_objspace_t *objspace, int direction, const char *event)
-{
- if (direction == 0) { /* enter */
- enter_count++;
- enter_tick = tick();
- gc_current_status_fill(objspace, last_gc_status);
- }
- else { /* exit */
- tick_t exit_tick = tick();
- char current_gc_status[0x10];
- gc_current_status_fill(objspace, current_gc_status);
-#if 1
- /* [last mutator time] [gc time] [event] */
- fprintf(stderr, "%"PRItick"\t%"PRItick"\t%s\t[%s->%s|%c]\n",
- enter_tick - last_exit_tick,
- exit_tick - enter_tick,
- event,
- last_gc_status, current_gc_status,
- (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) ? '+' : '-');
- last_exit_tick = exit_tick;
-#else
- /* [enter_tick] [gc time] [event] */
- fprintf(stderr, "%"PRItick"\t%"PRItick"\t%s\t[%s->%s|%c]\n",
- enter_tick,
- exit_tick - enter_tick,
- event,
- last_gc_status, current_gc_status,
- (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) ? '+' : '-');
-#endif
- }
-}
-#else /* PRINT_ENTER_EXIT_TICK */
-static inline void
-gc_record(rb_objspace_t *objspace, int direction, const char *event)
-{
- /* null */
-}
-#endif /* PRINT_ENTER_EXIT_TICK */
-
-static const char *
-gc_enter_event_cstr(enum gc_enter_event event)
-{
- switch (event) {
- case gc_enter_event_start: return "start";
- case gc_enter_event_continue: return "continue";
- case gc_enter_event_rest: return "rest";
- case gc_enter_event_finalizer: return "finalizer";
- case gc_enter_event_rb_memerror: return "rb_memerror";
- }
- return NULL;
-}
-
-static void
-gc_enter_count(enum gc_enter_event event)
+vm_weak_table_sym_set_foreach(VALUE *sym_ptr, void *data)
{
- switch (event) {
- case gc_enter_event_start: RB_DEBUG_COUNTER_INC(gc_enter_start); break;
- case gc_enter_event_continue: RB_DEBUG_COUNTER_INC(gc_enter_continue); break;
- case gc_enter_event_rest: RB_DEBUG_COUNTER_INC(gc_enter_rest); break;
- case gc_enter_event_finalizer: RB_DEBUG_COUNTER_INC(gc_enter_finalizer); break;
- case gc_enter_event_rb_memerror: /* nothing */ break;
- }
-}
-
-#ifndef MEASURE_GC
-#define MEASURE_GC (objspace->flags.measure_gc)
-#endif
-
-static bool current_process_time(struct timespec *ts);
+ VALUE sym = *sym_ptr;
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
-static void
-gc_clock_start(struct timespec *ts)
-{
- if (!current_process_time(ts)) {
- ts->tv_sec = 0;
- ts->tv_nsec = 0;
- }
-}
+ if (RB_SPECIAL_CONST_P(sym)) return ST_CONTINUE;
-static uint64_t
-gc_clock_end(struct timespec *ts)
-{
- struct timespec end_time;
+ int ret = iter_data->callback(sym, iter_data->data);
- if ((ts->tv_sec > 0 || ts->tv_nsec > 0) &&
- current_process_time(&end_time) &&
- end_time.tv_sec >= ts->tv_sec) {
- return (uint64_t)(end_time.tv_sec - ts->tv_sec) * (1000 * 1000 * 1000) +
- (end_time.tv_nsec - ts->tv_nsec);
+ if (ret == ST_REPLACE) {
+ ret = iter_data->update_callback(sym_ptr, iter_data->data);
}
- return 0;
-}
-
-static inline void
-gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev)
-{
- RB_VM_LOCK_ENTER_LEV(lock_lev);
-
- switch (event) {
- case gc_enter_event_rest:
- if (!is_marking(objspace)) break;
- // fall through
- case gc_enter_event_start:
- case gc_enter_event_continue:
- // stop other ractors
- rb_vm_barrier();
- break;
- default:
- break;
- }
-
- gc_enter_count(event);
- if (UNLIKELY(during_gc != 0)) rb_bug("during_gc != 0");
- if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
-
- during_gc = TRUE;
- RUBY_DEBUG_LOG("%s (%s)",gc_enter_event_cstr(event), gc_current_status(objspace));
- gc_report(1, objspace, "gc_enter: %s [%s]\n", gc_enter_event_cstr(event), gc_current_status(objspace));
- gc_record(objspace, 0, gc_enter_event_cstr(event));
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_ENTER, 0); /* TODO: which parameter should be passed? */
-}
-
-static inline void
-gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev)
-{
- GC_ASSERT(during_gc != 0);
-
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_EXIT, 0); /* TODO: which parameter should be passed? */
- gc_record(objspace, 1, gc_enter_event_cstr(event));
- RUBY_DEBUG_LOG("%s (%s)", gc_enter_event_cstr(event), gc_current_status(objspace));
- gc_report(1, objspace, "gc_exit: %s [%s]\n", gc_enter_event_cstr(event), gc_current_status(objspace));
- during_gc = FALSE;
-
- RB_VM_LOCK_LEAVE_LEV(lock_lev);
-}
-
-static void
-gc_marking_enter(rb_objspace_t *objspace)
-{
- GC_ASSERT(during_gc != 0);
-
- gc_clock_start(&objspace->profile.marking_start_time);
-}
-
-static void
-gc_marking_exit(rb_objspace_t *objspace)
-{
- GC_ASSERT(during_gc != 0);
-
- objspace->profile.marking_time_ns += gc_clock_end(&objspace->profile.marking_start_time);
-}
-
-static void
-gc_sweeping_enter(rb_objspace_t *objspace)
-{
- GC_ASSERT(during_gc != 0);
-
- gc_clock_start(&objspace->profile.sweeping_start_time);
-}
-
-static void
-gc_sweeping_exit(rb_objspace_t *objspace)
-{
- GC_ASSERT(during_gc != 0);
-
- objspace->profile.sweeping_time_ns += gc_clock_end(&objspace->profile.sweeping_start_time);
+ return ret;
}
-static void *
-gc_with_gvl(void *ptr)
-{
- struct objspace_and_reason *oar = (struct objspace_and_reason *)ptr;
- return (void *)(VALUE)garbage_collect(oar->objspace, oar->reason);
-}
+struct st_table *rb_generic_fields_tbl_get(void);
static int
-garbage_collect_with_gvl(rb_objspace_t *objspace, unsigned int reason)
+vm_weak_table_id2ref_foreach(st_data_t key, st_data_t value, st_data_t data, int error)
{
- if (dont_gc_val()) return TRUE;
- if (ruby_thread_has_gvl_p()) {
- return garbage_collect(objspace, reason);
- }
- else {
- if (ruby_native_thread_p()) {
- struct objspace_and_reason oar;
- oar.objspace = objspace;
- oar.reason = reason;
- return (int)(VALUE)rb_thread_call_with_gvl(gc_with_gvl, (void *)&oar);
- }
- else {
- /* no ruby thread */
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- exit(EXIT_FAILURE);
- }
- }
-}
-
-static VALUE
-gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE immediate_mark, VALUE immediate_sweep, VALUE compact)
-{
- rb_objspace_t *objspace = &rb_objspace;
- unsigned int reason = (GPR_FLAG_FULL_MARK |
- GPR_FLAG_IMMEDIATE_MARK |
- GPR_FLAG_IMMEDIATE_SWEEP |
- GPR_FLAG_METHOD);
-
- /* For now, compact implies full mark / sweep, so ignore other flags */
- if (RTEST(compact)) {
- GC_ASSERT(GC_COMPACTION_SUPPORTED);
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
- reason |= GPR_FLAG_COMPACT;
+ if (!iter_data->weak_only && !FIXNUM_P((VALUE)key)) {
+ int ret = iter_data->callback((VALUE)key, iter_data->data);
+ if (ret != ST_CONTINUE) return ret;
}
- else {
- if (!RTEST(full_mark)) reason &= ~GPR_FLAG_FULL_MARK;
- if (!RTEST(immediate_mark)) reason &= ~GPR_FLAG_IMMEDIATE_MARK;
- if (!RTEST(immediate_sweep)) reason &= ~GPR_FLAG_IMMEDIATE_SWEEP;
- }
-
- garbage_collect(objspace, reason);
- gc_finalize_deferred(objspace);
- return Qnil;
+ return iter_data->callback((VALUE)value, iter_data->data);
}
static int
-gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
+vm_weak_table_id2ref_foreach_update(st_data_t *key, st_data_t *value, st_data_t data, int existing)
{
- GC_ASSERT(!SPECIAL_CONST_P(obj));
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
- switch (BUILTIN_TYPE(obj)) {
- case T_NONE:
- case T_NIL:
- case T_MOVED:
- case T_ZOMBIE:
- return FALSE;
- case T_SYMBOL:
- if (DYNAMIC_SYM_P(obj) && (RSYMBOL(obj)->id & ~ID_SCOPE_MASK)) {
- return FALSE;
- }
- /* fall through */
- case T_STRING:
- case T_OBJECT:
- case T_FLOAT:
- case T_IMEMO:
- case T_ARRAY:
- case T_BIGNUM:
- case T_ICLASS:
- case T_MODULE:
- case T_REGEXP:
- case T_DATA:
- case T_MATCH:
- case T_STRUCT:
- case T_HASH:
- case T_FILE:
- case T_COMPLEX:
- case T_RATIONAL:
- case T_NODE:
- case T_CLASS:
- if (FL_TEST(obj, FL_FINALIZE)) {
- /* The finalizer table is a numtable. It looks up objects by address.
- * We can't mark the keys in the finalizer table because that would
- * prevent the objects from being collected. This check prevents
- * objects that are keys in the finalizer table from being moved
- * without directly pinning them. */
- if (st_is_member(finalizer_table, obj)) {
- return FALSE;
- }
- }
- GC_ASSERT(RVALUE_MARKED(obj));
- GC_ASSERT(!RVALUE_PINNED(obj));
-
- return TRUE;
-
- default:
- rb_bug("gc_is_moveable_obj: unreachable (%d)", (int)BUILTIN_TYPE(obj));
- break;
- }
-
- return FALSE;
-}
-
-/* Used in places that could malloc, which can cause the GC to run. We need to
- * temporarily disable the GC to allow the malloc to happen. */
-#define COULD_MALLOC_REGION_START() \
- GC_ASSERT(during_gc); \
- VALUE _already_disabled = rb_gc_disable_no_rest(); \
-
-#define COULD_MALLOC_REGION_END() \
- if (_already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
-
-static VALUE
-gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, size_t slot_size)
-{
- int marked;
- int wb_unprotected;
- int uncollectible;
- int marking;
- RVALUE *dest = (RVALUE *)free;
- RVALUE *src = (RVALUE *)scan;
-
- gc_report(4, objspace, "Moving object: %p -> %p\n", (void*)scan, (void *)free);
-
- GC_ASSERT(BUILTIN_TYPE(scan) != T_NONE);
- GC_ASSERT(!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(free), free));
-
- /* Save off bits for current object. */
- marked = rb_objspace_marked_object_p((VALUE)src);
- wb_unprotected = RVALUE_WB_UNPROTECTED((VALUE)src);
- uncollectible = RVALUE_UNCOLLECTIBLE((VALUE)src);
- marking = RVALUE_MARKING((VALUE)src);
-
- /* Clear bits for eventual T_MOVED */
- CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)src), (VALUE)src);
-
- if (FL_TEST((VALUE)src, FL_EXIVAR)) {
- /* Resizing the st table could cause a malloc */
- COULD_MALLOC_REGION_START();
- {
- rb_mv_generic_ivar((VALUE)src, (VALUE)dest);
- }
- COULD_MALLOC_REGION_END();
- }
-
- st_data_t srcid = (st_data_t)src, id;
-
- /* If the source object's object_id has been seen, we need to update
- * the object to object id mapping. */
- if (st_lookup(objspace->obj_to_id_tbl, srcid, &id)) {
- gc_report(4, objspace, "Moving object with seen id: %p -> %p\n", (void *)src, (void *)dest);
- /* Resizing the st table could cause a malloc */
- COULD_MALLOC_REGION_START();
- {
- st_delete(objspace->obj_to_id_tbl, &srcid, 0);
- st_insert(objspace->obj_to_id_tbl, (st_data_t)dest, id);
- }
- COULD_MALLOC_REGION_END();
- }
-
- /* Move the object */
- memcpy(dest, src, MIN(src_slot_size, slot_size));
-
- if (RVALUE_OVERHEAD > 0) {
- void *dest_overhead = (void *)(((uintptr_t)dest) + slot_size - RVALUE_OVERHEAD);
- void *src_overhead = (void *)(((uintptr_t)src) + src_slot_size - RVALUE_OVERHEAD);
-
- memcpy(dest_overhead, src_overhead, RVALUE_OVERHEAD);
- }
-
- memset(src, 0, src_slot_size);
-
- /* Set bits for object in new location */
- if (marking) {
- MARK_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
- }
-
- if (marked) {
- MARK_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)dest), (VALUE)dest);
- }
-
- if (wb_unprotected) {
- MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)dest), (VALUE)dest);
- }
- else {
- CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)dest), (VALUE)dest);
- }
+ iter_data->update_callback((VALUE *)value, iter_data->data);
- if (uncollectible) {
- MARK_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)dest), (VALUE)dest);
+ if (!iter_data->weak_only && !FIXNUM_P((VALUE)*key)) {
+ iter_data->update_callback((VALUE *)key, iter_data->data);
}
- else {
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)dest), (VALUE)dest);
- }
-
- /* Assign forwarding address */
- src->as.moved.flags = T_MOVED;
- src->as.moved.dummy = Qundef;
- src->as.moved.destination = (VALUE)dest;
- GC_ASSERT(BUILTIN_TYPE((VALUE)dest) != T_NONE);
- return (VALUE)src;
+ return ST_CONTINUE;
}
-#if GC_CAN_COMPILE_COMPACTION
static int
-compare_free_slots(const void *left, const void *right, void *dummy)
+vm_weak_table_gen_fields_foreach(st_data_t key, st_data_t value, st_data_t data)
{
- struct heap_page *left_page;
- struct heap_page *right_page;
-
- left_page = *(struct heap_page * const *)left;
- right_page = *(struct heap_page * const *)right;
-
- return left_page->free_slots - right_page->free_slots;
-}
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
-static void
-gc_sort_heap_by_empty_slots(rb_objspace_t *objspace)
-{
- for (int j = 0; j < SIZE_POOL_COUNT; j++) {
- rb_size_pool_t *size_pool = &size_pools[j];
+ int ret = iter_data->callback((VALUE)key, iter_data->data);
- size_t total_pages = SIZE_POOL_EDEN_HEAP(size_pool)->total_pages;
- size_t size = size_mul_or_raise(total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
- struct heap_page *page = 0, **page_list = malloc(size);
- size_t i = 0;
+ VALUE new_value = (VALUE)value;
+ VALUE new_key = (VALUE)key;
- SIZE_POOL_EDEN_HEAP(size_pool)->free_pages = NULL;
- ccan_list_for_each(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, page, page_node) {
- page_list[i++] = page;
- GC_ASSERT(page);
- }
-
- GC_ASSERT((size_t)i == total_pages);
-
- /* Sort the heap so "filled pages" are first. `heap_add_page` adds to the
- * head of the list, so empty pages will end up at the start of the heap */
- ruby_qsort(page_list, total_pages, sizeof(struct heap_page *), compare_free_slots, NULL);
+ switch (ret) {
+ case ST_CONTINUE:
+ break;
- /* Reset the eden heap */
- ccan_list_head_init(&SIZE_POOL_EDEN_HEAP(size_pool)->pages);
+ case ST_DELETE:
+ // When we're removing an object from the weak ref table, we need to
+ // set the shape on it so that the GC finalizer won't try to remove
+ // it again. A "root shape" indicates to the GC that this object
+ // has no fields on it, hence it won't be in the gen fields table.
+ RBASIC_SET_SHAPE_ID((VALUE)key, ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER);
+ return ST_DELETE;
- for (i = 0; i < total_pages; i++) {
- ccan_list_add(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, &page_list[i]->page_node);
- if (page_list[i]->free_slots != 0) {
- heap_add_freepage(SIZE_POOL_EDEN_HEAP(size_pool), page_list[i]);
- }
+ case ST_REPLACE: {
+ ret = iter_data->update_callback(&new_key, iter_data->data);
+ if (key != new_key) {
+ ret = ST_DELETE;
}
+ break;
+ }
- free(page_list);
+ default:
+ rb_bug("vm_weak_table_gen_fields_foreach: return value %d not supported", ret);
}
-}
-#endif
-static void
-gc_ref_update_array(rb_objspace_t * objspace, VALUE v)
-{
- if (ARY_SHARED_P(v)) {
-#if USE_RVARGC
- VALUE old_root = RARRAY(v)->as.heap.aux.shared_root;
-#endif
-
- UPDATE_IF_MOVED(objspace, RARRAY(v)->as.heap.aux.shared_root);
-
-#if USE_RVARGC
- VALUE new_root = RARRAY(v)->as.heap.aux.shared_root;
- // If the root is embedded and its location has changed
- if (ARY_EMBED_P(new_root) && new_root != old_root) {
- size_t offset = (size_t)(RARRAY(v)->as.heap.ptr - RARRAY(old_root)->as.ary);
- GC_ASSERT(RARRAY(v)->as.heap.ptr >= RARRAY(old_root)->as.ary);
- RARRAY(v)->as.heap.ptr = RARRAY(new_root)->as.ary + offset;
- }
-#endif
- }
- else {
- long len = RARRAY_LEN(v);
+ if (!iter_data->weak_only) {
+ int ivar_ret = iter_data->callback(new_value, iter_data->data);
+ switch (ivar_ret) {
+ case ST_CONTINUE:
+ break;
- if (len > 0) {
- VALUE *ptr = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(v);
- for (long i = 0; i < len; i++) {
- UPDATE_IF_MOVED(objspace, ptr[i]);
- }
- }
+ case ST_REPLACE:
+ iter_data->update_callback(&new_value, iter_data->data);
+ break;
-#if USE_RVARGC
- if (rb_gc_obj_slot_size(v) >= rb_ary_size_as_embedded(v)) {
- if (rb_ary_embeddable_p(v)) {
- rb_ary_make_embedded(v);
- }
+ default:
+ rb_bug("vm_weak_table_gen_fields_foreach: return value %d not supported", ivar_ret);
}
-#endif
}
-}
-static void update_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl);
-
-static void
-gc_ref_update_object(rb_objspace_t *objspace, VALUE v)
-{
- VALUE *ptr = ROBJECT_IVPTR(v);
-
- if (rb_shape_obj_too_complex(v)) {
- update_m_tbl(objspace, ROBJECT_IV_HASH(v));
- return;
- }
-
-#if USE_RVARGC
- size_t slot_size = rb_gc_obj_slot_size(v);
- size_t embed_size = rb_obj_embedded_size(ROBJECT_IV_CAPACITY(v));
- if (slot_size >= embed_size && !RB_FL_TEST_RAW(v, ROBJECT_EMBED)) {
- // Object can be re-embedded
- memcpy(ROBJECT(v)->as.ary, ptr, sizeof(VALUE) * ROBJECT_IV_COUNT(v));
- RB_FL_SET_RAW(v, ROBJECT_EMBED);
- if (ROBJ_TRANSIENT_P(v)) {
- ROBJ_TRANSIENT_UNSET(v);
- }
- else {
- xfree(ptr);
+ if (key != new_key || value != new_value) {
+ DURING_GC_COULD_MALLOC_REGION_START();
+ {
+ st_insert(rb_generic_fields_tbl_get(), (st_data_t)new_key, new_value);
}
- ptr = ROBJECT(v)->as.ary;
+ DURING_GC_COULD_MALLOC_REGION_END();
}
-#endif
- for (uint32_t i = 0; i < ROBJECT_IV_COUNT(v); i++) {
- UPDATE_IF_MOVED(objspace, ptr[i]);
- }
-}
-
-static int
-hash_replace_ref(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)*key)) {
- *key = rb_gc_location((VALUE)*key);
- }
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ST_CONTINUE;
-}
-
-static int
-hash_foreach_replace(st_data_t key, st_data_t value, st_data_t argp, int error)
-{
- rb_objspace_t *objspace;
-
- objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)key)) {
- return ST_REPLACE;
- }
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ST_REPLACE;
- }
- return ST_CONTINUE;
-}
-
-static int
-hash_replace_ref_value(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ST_CONTINUE;
+ return ret;
}
static int
-hash_foreach_replace_value(st_data_t key, st_data_t value, st_data_t argp, int error)
+vm_weak_table_frozen_strings_foreach(VALUE *str, void *data)
{
- rb_objspace_t *objspace;
+ // int retval = vm_weak_table_foreach_weak_key(key, value, data, error);
+ struct global_vm_table_foreach_data *iter_data = (struct global_vm_table_foreach_data *)data;
+ int retval = iter_data->callback(*str, iter_data->data);
- objspace = (rb_objspace_t *)argp;
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ST_REPLACE;
+ if (retval == ST_REPLACE) {
+ retval = iter_data->update_callback(str, iter_data->data);
}
- return ST_CONTINUE;
-}
-static void
-gc_update_tbl_refs(rb_objspace_t * objspace, st_table *tbl)
-{
- if (!tbl || tbl->num_entries == 0) return;
-
- if (st_foreach_with_replace(tbl, hash_foreach_replace_value, hash_replace_ref_value, (st_data_t)objspace)) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ if (retval == ST_DELETE) {
+ FL_UNSET(*str, RSTRING_FSTR);
}
-}
-
-static void
-gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl)
-{
- if (!tbl || tbl->num_entries == 0) return;
- if (st_foreach_with_replace(tbl, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace)) {
- rb_raise(rb_eRuntimeError, "hash modified during iteration");
- }
+ return retval;
}
-/* Update MOVED references in an st_table */
+void rb_fstring_foreach_with_replace(int (*callback)(VALUE *str, void *data), void *data);
void
-rb_gc_update_tbl_refs(st_table *ptr)
-{
- rb_objspace_t *objspace = &rb_objspace;
- gc_update_table_refs(objspace, ptr);
-}
-
-static void
-gc_ref_update_hash(rb_objspace_t * objspace, VALUE v)
-{
- rb_hash_stlike_foreach_with_replace(v, hash_foreach_replace, hash_replace_ref, (st_data_t)objspace);
-}
-
-static void
-gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
-{
- rb_method_definition_t *def = me->def;
-
- UPDATE_IF_MOVED(objspace, me->owner);
- UPDATE_IF_MOVED(objspace, me->defined_class);
-
- if (def) {
- switch (def->type) {
- case VM_METHOD_TYPE_ISEQ:
- if (def->body.iseq.iseqptr) {
- TYPED_UPDATE_IF_MOVED(objspace, rb_iseq_t *, def->body.iseq.iseqptr);
- }
- TYPED_UPDATE_IF_MOVED(objspace, rb_cref_t *, def->body.iseq.cref);
- break;
- case VM_METHOD_TYPE_ATTRSET:
- case VM_METHOD_TYPE_IVAR:
- UPDATE_IF_MOVED(objspace, def->body.attr.location);
- break;
- case VM_METHOD_TYPE_BMETHOD:
- UPDATE_IF_MOVED(objspace, def->body.bmethod.proc);
- break;
- case VM_METHOD_TYPE_ALIAS:
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.alias.original_me);
- return;
- case VM_METHOD_TYPE_REFINED:
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.refined.orig_me);
- UPDATE_IF_MOVED(objspace, def->body.refined.owner);
- break;
- case VM_METHOD_TYPE_CFUNC:
- case VM_METHOD_TYPE_ZSUPER:
- case VM_METHOD_TYPE_MISSING:
- case VM_METHOD_TYPE_OPTIMIZED:
- case VM_METHOD_TYPE_UNDEF:
- case VM_METHOD_TYPE_NOTIMPLEMENTED:
- break;
- }
- }
-}
-
-static void
-gc_update_values(rb_objspace_t *objspace, long n, VALUE *values)
+rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback,
+ vm_table_update_callback_func update_callback,
+ void *data,
+ bool weak_only,
+ enum rb_gc_vm_weak_tables table)
{
- long i;
+ rb_vm_t *vm = GET_VM();
- for (i=0; i<n; i++) {
- UPDATE_IF_MOVED(objspace, values[i]);
- }
-}
+ struct global_vm_table_foreach_data foreach_data = {
+ .callback = callback,
+ .update_callback = update_callback,
+ .data = data,
+ .weak_only = weak_only,
+ };
-static void
-gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
-{
- switch (imemo_type(obj)) {
- case imemo_env:
- {
- rb_env_t *env = (rb_env_t *)obj;
- if (LIKELY(env->ep)) {
- // just after newobj() can be NULL here.
- TYPED_UPDATE_IF_MOVED(objspace, rb_iseq_t *, env->iseq);
- UPDATE_IF_MOVED(objspace, env->ep[VM_ENV_DATA_INDEX_ENV]);
- gc_update_values(objspace, (long)env->env_size, (VALUE *)env->env);
- }
- }
- break;
- case imemo_cref:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.cref.klass_or_self);
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_cref_struct *, RANY(obj)->as.imemo.cref.next);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.cref.refinements);
- break;
- case imemo_svar:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.cref_or_me);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.lastline);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.backref);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.svar.others);
- break;
- case imemo_throw_data:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.throw_data.throw_obj);
- break;
- case imemo_ifunc:
- break;
- case imemo_memo:
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.memo.v1);
- UPDATE_IF_MOVED(objspace, RANY(obj)->as.imemo.memo.v2);
- break;
- case imemo_ment:
- gc_ref_update_method_entry(objspace, &RANY(obj)->as.imemo.ment);
+ switch (table) {
+ case RB_GC_VM_CI_TABLE: {
+ st_foreach_with_replace(
+ &vm->ci_table,
+ vm_weak_table_foreach_weak_key,
+ vm_weak_table_foreach_update_weak_key,
+ (st_data_t)&foreach_data
+ );
break;
- case imemo_iseq:
- rb_iseq_mark_and_move((rb_iseq_t *)obj, true);
+ }
+ case RB_GC_VM_OVERLOADED_CME_TABLE: {
+ st_foreach_with_replace(
+ &vm->overloaded_cme_table,
+ vm_weak_table_foreach_weak_key,
+ vm_weak_table_foreach_update_weak_key,
+ (st_data_t)&foreach_data
+ );
break;
- case imemo_ast:
- rb_ast_update_references((rb_ast_t *)obj);
+ }
+ case RB_GC_VM_GLOBAL_SYMBOLS_TABLE: {
+ rb_sym_global_symbol_table_foreach_weak_reference(
+ vm_weak_table_sym_set_foreach,
+ &foreach_data
+ );
break;
- case imemo_callcache:
- {
- const struct rb_callcache *cc = (const struct rb_callcache *)obj;
- if (cc->klass) {
- UPDATE_IF_MOVED(objspace, cc->klass);
- if (!is_live_object(objspace, cc->klass)) {
- *((VALUE *)(&cc->klass)) = (VALUE)0;
- }
- }
-
- if (cc->cme_) {
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_callable_method_entry_struct *, cc->cme_);
- if (!is_live_object(objspace, (VALUE)cc->cme_)) {
- *((struct rb_callable_method_entry_struct **)(&cc->cme_)) = (struct rb_callable_method_entry_struct *)0;
- }
- }
+ }
+ case RB_GC_VM_ID2REF_TABLE: {
+ if (id2ref_tbl) {
+ st_foreach_with_replace(
+ id2ref_tbl,
+ vm_weak_table_id2ref_foreach,
+ vm_weak_table_id2ref_foreach_update,
+ (st_data_t)&foreach_data
+ );
}
break;
- case imemo_constcache:
- {
- const struct iseq_inline_constant_cache_entry *ice = (struct iseq_inline_constant_cache_entry *)obj;
- UPDATE_IF_MOVED(objspace, ice->value);
+ }
+ case RB_GC_VM_GENERIC_FIELDS_TABLE: {
+ st_table *generic_fields_tbl = rb_generic_fields_tbl_get();
+ if (generic_fields_tbl) {
+ st_foreach(
+ generic_fields_tbl,
+ vm_weak_table_gen_fields_foreach,
+ (st_data_t)&foreach_data
+ );
}
break;
- case imemo_parser_strterm:
- case imemo_tmpbuf:
- case imemo_callinfo:
+ }
+ case RB_GC_VM_FROZEN_STRINGS_TABLE: {
+ rb_fstring_foreach_with_replace(
+ vm_weak_table_frozen_strings_foreach,
+ &foreach_data
+ );
break;
+ }
+ case RB_GC_VM_WEAK_TABLE_COUNT:
+ rb_bug("Unreachable");
default:
- rb_bug("not reachable %d", imemo_type(obj));
- break;
- }
-}
-
-static enum rb_id_table_iterator_result
-check_id_table_move(VALUE value, void *data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, (VALUE)value)) {
- return ID_TABLE_REPLACE;
- }
-
- return ID_TABLE_CONTINUE;
-}
-
-/* Returns the new location of an object, if it moved. Otherwise returns
- * the existing location. */
-VALUE
-rb_gc_location(VALUE value)
-{
-
- VALUE destination;
-
- if (!SPECIAL_CONST_P(value)) {
- void *poisoned = asan_unpoison_object_temporary(value);
-
- if (BUILTIN_TYPE(value) == T_MOVED) {
- destination = (VALUE)RMOVED(value)->destination;
- GC_ASSERT(BUILTIN_TYPE(destination) != T_NONE);
- }
- else {
- destination = value;
- }
-
- /* Re-poison slot if it's not the one we want */
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(value) == T_NONE);
- asan_poison_object(value);
- }
- }
- else {
- destination = value;
- }
-
- return destination;
-}
-
-static enum rb_id_table_iterator_result
-update_id_table(VALUE *value, void *data, int existing)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, (VALUE)*value)) {
- *value = rb_gc_location((VALUE)*value);
- }
-
- return ID_TABLE_CONTINUE;
-}
-
-static void
-update_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
-{
- if (tbl) {
- rb_id_table_foreach_values_with_replace(tbl, check_id_table_move, update_id_table, objspace);
+ rb_bug("rb_gc_vm_weak_table_foreach: unknown table %d", table);
}
}
-static enum rb_id_table_iterator_result
-update_cc_tbl_i(VALUE ccs_ptr, void *data)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)data;
- struct rb_class_cc_entries *ccs = (struct rb_class_cc_entries *)ccs_ptr;
- VM_ASSERT(vm_ccs_p(ccs));
-
- if (gc_object_moved_p(objspace, (VALUE)ccs->cme)) {
- ccs->cme = (const rb_callable_method_entry_t *)rb_gc_location((VALUE)ccs->cme);
- }
-
- for (int i=0; i<ccs->len; i++) {
- if (gc_object_moved_p(objspace, (VALUE)ccs->entries[i].ci)) {
- ccs->entries[i].ci = (struct rb_callinfo *)rb_gc_location((VALUE)ccs->entries[i].ci);
- }
- if (gc_object_moved_p(objspace, (VALUE)ccs->entries[i].cc)) {
- ccs->entries[i].cc = (struct rb_callcache *)rb_gc_location((VALUE)ccs->entries[i].cc);
- }
- }
-
- // do not replace
- return ID_TABLE_CONTINUE;
-}
-
-static void
-update_cc_tbl(rb_objspace_t *objspace, VALUE klass)
-{
- struct rb_id_table *tbl = RCLASS_CC_TBL(klass);
- if (tbl) {
- rb_id_table_foreach_values(tbl, update_cc_tbl_i, objspace);
- }
-}
-
-static enum rb_id_table_iterator_result
-update_cvc_tbl_i(VALUE cvc_entry, void *data)
-{
- struct rb_cvar_class_tbl_entry *entry;
-
- entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
-
- entry->class_value = rb_gc_location(entry->class_value);
-
- return ID_TABLE_CONTINUE;
-}
-
-static void
-update_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
-{
- struct rb_id_table *tbl = RCLASS_CVC_TBL(klass);
- if (tbl) {
- rb_id_table_foreach_values(tbl, update_cvc_tbl_i, objspace);
- }
-}
-
-static enum rb_id_table_iterator_result
-update_const_table(VALUE value, void *data)
+void
+rb_gc_update_vm_references(void *objspace)
{
- rb_const_entry_t *ce = (rb_const_entry_t *)value;
- rb_objspace_t * objspace = (rb_objspace_t *)data;
-
- if (gc_object_moved_p(objspace, ce->value)) {
- ce->value = rb_gc_location(ce->value);
- }
-
- if (gc_object_moved_p(objspace, ce->file)) {
- ce->file = rb_gc_location(ce->file);
- }
+ rb_execution_context_t *ec = GET_EC();
+ rb_vm_t *vm = rb_ec_vm_ptr(ec);
- return ID_TABLE_CONTINUE;
-}
+ rb_vm_update_references(vm);
+ rb_gc_update_global_tbl();
+ rb_sym_global_symbols_mark_and_move();
-static void
-update_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
-{
- if (!tbl) return;
- rb_id_table_foreach_values(tbl, update_const_table, objspace);
-}
+#if USE_YJIT
+ void rb_yjit_root_update_references(void); // in Rust
-static void
-update_subclass_entries(rb_objspace_t *objspace, rb_subclass_entry_t *entry)
-{
- while (entry) {
- UPDATE_IF_MOVED(objspace, entry->klass);
- entry = entry->next;
+ if (rb_yjit_enabled_p) {
+ rb_yjit_root_update_references();
}
-}
+#endif
-static void
-update_class_ext(rb_objspace_t *objspace, rb_classext_t *ext)
-{
- UPDATE_IF_MOVED(objspace, ext->origin_);
- UPDATE_IF_MOVED(objspace, ext->includer);
- UPDATE_IF_MOVED(objspace, ext->refined_class);
- update_subclass_entries(objspace, ext->subclasses);
-}
+#if USE_ZJIT
+ void rb_zjit_root_update_references(void); // in Rust
-static void
-update_superclasses(rb_objspace_t *objspace, VALUE obj)
-{
- if (FL_TEST_RAW(obj, RCLASS_SUPERCLASSES_INCLUDE_SELF)) {
- for (size_t i = 0; i < RCLASS_SUPERCLASS_DEPTH(obj) + 1; i++) {
- UPDATE_IF_MOVED(objspace, RCLASS_SUPERCLASSES(obj)[i]);
- }
+ if (rb_zjit_enabled_p) {
+ rb_zjit_root_update_references();
}
+#endif
}
-static void
-gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
+void
+rb_gc_update_object_references(void *objspace, VALUE obj)
{
- RVALUE *any = RANY(obj);
-
- gc_report(4, objspace, "update-refs: %p ->\n", (void *)obj);
-
- if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_and_update_generic_ivar(obj);
- }
+ struct classext_foreach_args args;
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
- if (FL_TEST(obj, FL_SINGLETON)) {
+ if (FL_TEST_RAW(obj, FL_SINGLETON)) {
UPDATE_IF_MOVED(objspace, RCLASS_ATTACHED_OBJECT(obj));
}
// Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
- if (RCLASS_SUPER((VALUE)obj)) {
- UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
- }
- if (!RCLASS_EXT(obj)) break;
- update_m_tbl(objspace, RCLASS_M_TBL(obj));
- update_cc_tbl(objspace, obj);
- update_cvc_tbl(objspace, obj);
- update_superclasses(objspace, obj);
-
- for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
- UPDATE_IF_MOVED(objspace, RCLASS_IVPTR(obj)[i]);
- }
-
- update_class_ext(objspace, RCLASS_EXT(obj));
- update_const_tbl(objspace, RCLASS_CONST_TBL(obj));
-
- UPDATE_IF_MOVED(objspace, RCLASS_EXT(obj)->classpath);
+ args.klass = obj;
+ args.objspace = objspace;
+ rb_class_classext_foreach(obj, update_classext, (void *)&args);
break;
case T_ICLASS:
- if (FL_TEST(obj, RICLASS_IS_ORIGIN) &&
- !FL_TEST(obj, RICLASS_ORIGIN_SHARED_MTBL)) {
- update_m_tbl(objspace, RCLASS_M_TBL(obj));
- }
- if (RCLASS_SUPER((VALUE)obj)) {
- UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
- }
- if (!RCLASS_EXT(obj)) break;
- update_class_ext(objspace, RCLASS_EXT(obj));
- update_m_tbl(objspace, RCLASS_CALLABLE_M_TBL(obj));
- update_cc_tbl(objspace, obj);
+ args.objspace = objspace;
+ rb_class_classext_foreach(obj, update_iclass_classext, (void *)&args);
break;
case T_IMEMO:
- gc_ref_update_imemo(objspace, obj);
+ rb_imemo_mark_and_move(obj, true);
return;
case T_NIL:
@@ -10573,23 +4404,15 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
case T_HASH:
gc_ref_update_hash(objspace, obj);
- UPDATE_IF_MOVED(objspace, any->as.hash.ifnone);
+ UPDATE_IF_MOVED(objspace, RHASH(obj)->ifnone);
break;
case T_STRING:
{
if (STR_SHARED_P(obj)) {
-#if USE_RVARGC
- VALUE old_root = any->as.string.as.heap.aux.shared;
-#endif
- UPDATE_IF_MOVED(objspace, any->as.string.as.heap.aux.shared);
-#if USE_RVARGC
- VALUE new_root = any->as.string.as.heap.aux.shared;
- rb_str_update_shared_ary(obj, old_root, new_root);
-#endif
+ UPDATE_IF_MOVED(objspace, RSTRING(obj)->as.heap.aux.shared);
}
-#if USE_RVARGC
/* If, after move the string is not embedded, and can fit in the
* slot it's been placed in, then re-embed it. */
if (rb_gc_obj_slot_size(obj) >= rb_str_size_as_embedded(obj)) {
@@ -10597,17 +4420,27 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
rb_str_make_embedded(obj);
}
}
-#endif
break;
}
case T_DATA:
/* Call the compaction callback, if it exists */
{
- void *const ptr = DATA_PTR(obj);
+ void *const ptr = RTYPEDDATA_GET_DATA(obj);
+
+ UPDATE_IF_MOVED(objspace, RTYPEDDATA(obj)->fields_obj);
+
if (ptr) {
- if (RTYPEDDATA_P(obj)) {
- RUBY_DATA_FUNC compact_func = any->as.typeddata.type->function.dcompact;
+ if (gc_declarative_marking_p(RTYPEDDATA_TYPE(obj))) {
+ size_t *offset_list = TYPED_DATA_REFS_OFFSET_LIST(obj);
+
+ for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) {
+ VALUE *ref = (VALUE *)((char *)ptr + offset);
+ *ref = gc_location_internal(objspace, *ref);
+ }
+ }
+ else {
+ RUBY_DATA_FUNC compact_func = RTYPEDDATA_TYPE(obj)->function.dcompact;
if (compact_func) (*compact_func)(ptr);
}
}
@@ -10619,24 +4452,24 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
break;
case T_FILE:
- if (any->as.file.fptr) {
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->self);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->pathv);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->tied_io_for_writing);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->writeconv_asciicompat);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->writeconv_pre_ecopts);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->encs.ecopts);
- UPDATE_IF_MOVED(objspace, any->as.file.fptr->write_lock);
+ if (RFILE(obj)->fptr) {
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->self);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->pathv);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->tied_io_for_writing);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->writeconv_asciicompat);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->writeconv_pre_ecopts);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->encs.ecopts);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->write_lock);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->timeout);
+ UPDATE_IF_MOVED(objspace, RFILE(obj)->fptr->wakeup_mutex);
}
break;
case T_REGEXP:
- UPDATE_IF_MOVED(objspace, any->as.regexp.src);
+ UPDATE_IF_MOVED(objspace, RREGEXP(obj)->src);
break;
case T_SYMBOL:
- if (DYNAMIC_SYM_P((VALUE)any)) {
- UPDATE_IF_MOVED(objspace, RSYMBOL(any)->fstr);
- }
+ UPDATE_IF_MOVED(objspace, RSYMBOL(obj)->fstr);
break;
case T_FLOAT:
@@ -10644,21 +4477,21 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
break;
case T_MATCH:
- UPDATE_IF_MOVED(objspace, any->as.match.regexp);
+ UPDATE_IF_MOVED(objspace, RMATCH(obj)->regexp);
- if (any->as.match.str) {
- UPDATE_IF_MOVED(objspace, any->as.match.str);
+ if (RMATCH(obj)->str) {
+ UPDATE_IF_MOVED(objspace, RMATCH(obj)->str);
}
break;
case T_RATIONAL:
- UPDATE_IF_MOVED(objspace, any->as.rational.num);
- UPDATE_IF_MOVED(objspace, any->as.rational.den);
+ UPDATE_IF_MOVED(objspace, RRATIONAL(obj)->num);
+ UPDATE_IF_MOVED(objspace, RRATIONAL(obj)->den);
break;
case T_COMPLEX:
- UPDATE_IF_MOVED(objspace, any->as.complex.real);
- UPDATE_IF_MOVED(objspace, any->as.complex.imag);
+ UPDATE_IF_MOVED(objspace, RCOMPLEX(obj)->real);
+ UPDATE_IF_MOVED(objspace, RCOMPLEX(obj)->imag);
break;
@@ -10670,291 +4503,24 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
for (i = 0; i < len; i++) {
UPDATE_IF_MOVED(objspace, ptr[i]);
}
- }
- break;
- default:
-#if GC_DEBUG
- rb_gcdebug_print_obj_condition((VALUE)obj);
- rb_obj_info_dump(obj);
- rb_bug("unreachable");
-#endif
- break;
-
- }
-
- UPDATE_IF_MOVED(objspace, RBASIC(obj)->klass);
-
- gc_report(4, objspace, "update-refs: %p <-\n", (void *)obj);
-}
-
-static int
-gc_ref_update(void *vstart, void *vend, size_t stride, rb_objspace_t * objspace, struct heap_page *page)
-{
- VALUE v = (VALUE)vstart;
- asan_unlock_freelist(page);
- asan_lock_freelist(page);
- page->flags.has_uncollectible_shady_objects = FALSE;
- page->flags.has_remembered_objects = FALSE;
- /* For each object on the page */
- for (; v != (VALUE)vend; v += stride) {
- void *poisoned = asan_unpoison_object_temporary(v);
-
- switch (BUILTIN_TYPE(v)) {
- case T_NONE:
- case T_MOVED:
- case T_ZOMBIE:
- break;
- default:
- if (RVALUE_WB_UNPROTECTED(v)) {
- page->flags.has_uncollectible_shady_objects = TRUE;
- }
- if (RVALUE_PAGE_MARKING(page, v)) {
- page->flags.has_remembered_objects = TRUE;
- }
- if (page->flags.before_sweep) {
- if (RVALUE_MARKED(v)) {
- gc_update_object_references(objspace, v);
+ if (RSTRUCT_EMBED_LEN(obj)) {
+ if (!FL_TEST_RAW(obj, RSTRUCT_GEN_FIELDS)) {
+ UPDATE_IF_MOVED(objspace, ptr[len]);
}
}
else {
- gc_update_object_references(objspace, v);
- }
- }
-
- if (poisoned) {
- asan_poison_object(v);
- }
- }
-
- return 0;
-}
-
-extern rb_symbols_t ruby_global_symbols;
-#define global_symbols ruby_global_symbols
-
-static void
-gc_update_references(rb_objspace_t *objspace)
-{
- objspace->flags.during_reference_updating = true;
-
- rb_execution_context_t *ec = GET_EC();
- rb_vm_t *vm = rb_ec_vm_ptr(ec);
-
- struct heap_page *page = NULL;
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- bool should_set_mark_bits = TRUE;
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
-
- ccan_list_for_each(&heap->pages, page, page_node) {
- uintptr_t start = (uintptr_t)page->start;
- uintptr_t end = start + (page->total_slots * size_pool->slot_size);
-
- gc_ref_update((void *)start, (void *)end, size_pool->slot_size, objspace, page);
- if (page == heap->sweeping_page) {
- should_set_mark_bits = FALSE;
- }
- if (should_set_mark_bits) {
- gc_setup_mark_bits(page);
- }
- }
- }
- rb_vm_update_references(vm);
- rb_transient_heap_update_references();
- rb_gc_update_global_tbl();
- global_symbols.ids = rb_gc_location(global_symbols.ids);
- global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash);
- gc_update_tbl_refs(objspace, objspace->obj_to_id_tbl);
- gc_update_table_refs(objspace, objspace->id_to_obj_tbl);
- gc_update_table_refs(objspace, global_symbols.str_sym);
- gc_update_table_refs(objspace, finalizer_table);
-
- objspace->flags.during_reference_updating = false;
-}
-
-#if GC_CAN_COMPILE_COMPACTION
-/*
- * call-seq:
- * GC.latest_compact_info -> hash
- *
- * Returns information about object moved in the most recent \GC compaction.
- *
- * The returned hash has two keys :considered and :moved. The hash for
- * :considered lists the number of objects that were considered for movement
- * by the compactor, and the :moved hash lists the number of objects that
- * were actually moved. Some objects can't be moved (maybe they were pinned)
- * so these numbers can be used to calculate compaction efficiency.
- */
-static VALUE
-gc_compact_stats(VALUE self)
-{
- size_t i;
- rb_objspace_t *objspace = &rb_objspace;
- VALUE h = rb_hash_new();
- VALUE considered = rb_hash_new();
- VALUE moved = rb_hash_new();
- VALUE moved_up = rb_hash_new();
- VALUE moved_down = rb_hash_new();
-
- for (i=0; i<T_MASK; i++) {
- if (objspace->rcompactor.considered_count_table[i]) {
- rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i]));
- }
-
- if (objspace->rcompactor.moved_count_table[i]) {
- rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i]));
- }
-
- if (objspace->rcompactor.moved_up_count_table[i]) {
- rb_hash_aset(moved_up, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_up_count_table[i]));
- }
-
- if (objspace->rcompactor.moved_down_count_table[i]) {
- rb_hash_aset(moved_down, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_down_count_table[i]));
- }
- }
-
- rb_hash_aset(h, ID2SYM(rb_intern("considered")), considered);
- rb_hash_aset(h, ID2SYM(rb_intern("moved")), moved);
- rb_hash_aset(h, ID2SYM(rb_intern("moved_up")), moved_up);
- rb_hash_aset(h, ID2SYM(rb_intern("moved_down")), moved_down);
-
- return h;
-}
-#else
-# define gc_compact_stats rb_f_notimplement
-#endif
-
-#if GC_CAN_COMPILE_COMPACTION
-static void
-root_obj_check_moved_i(const char *category, VALUE obj, void *data)
-{
- if (gc_object_moved_p(&rb_objspace, obj)) {
- rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_location(obj)));
- }
-}
-
-static void
-reachable_object_check_moved_i(VALUE ref, void *data)
-{
- VALUE parent = (VALUE)data;
- if (gc_object_moved_p(&rb_objspace, ref)) {
- rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
- }
-}
-
-static int
-heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)
-{
- VALUE v = (VALUE)vstart;
- for (; v != (VALUE)vend; v += stride) {
- if (gc_object_moved_p(&rb_objspace, v)) {
- /* Moved object still on the heap, something may have a reference. */
- }
- else {
- void *poisoned = asan_unpoison_object_temporary(v);
-
- switch (BUILTIN_TYPE(v)) {
- case T_NONE:
- case T_ZOMBIE:
- break;
- default:
- if (!rb_objspace_garbage_object_p(v)) {
- rb_objspace_reachable_objects_from(v, reachable_object_check_moved_i, (void *)v);
- }
- }
-
- if (poisoned) {
- GC_ASSERT(BUILTIN_TYPE(v) == T_NONE);
- asan_poison_object(v);
+ UPDATE_IF_MOVED(objspace, RSTRUCT(obj)->as.heap.fields_obj);
}
}
+ break;
+ default:
+ rb_bug("unreachable");
+ break;
}
- return 0;
-}
-
-/*
- * call-seq:
- * GC.compact
- *
- * This function compacts objects together in Ruby's heap. It eliminates
- * unused space (or fragmentation) in the heap by moving objects in to that
- * unused space. This function returns a hash which contains statistics about
- * which objects were moved. See <tt>GC.latest_gc_info</tt> for details about
- * compaction statistics.
- *
- * This method is implementation specific and not expected to be implemented
- * in any implementation besides MRI.
- *
- * To test whether \GC compaction is supported, use the idiom:
- *
- * GC.respond_to?(:compact)
- */
-static VALUE
-gc_compact(VALUE self)
-{
- /* Run GC with compaction enabled */
- gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qtrue);
-
- return gc_compact_stats(self);
-}
-#else
-# define gc_compact rb_f_notimplement
-#endif
-
-#if GC_CAN_COMPILE_COMPACTION
-static VALUE
-gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE double_heap, VALUE expand_heap, VALUE toward_empty)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- /* Clear the heap. */
- gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qfalse);
- size_t growth_slots = gc_params.heap_init_slots;
-
- if (RTEST(double_heap)) {
- rb_warn("double_heap is deprecated, please use expand_heap instead");
- }
-
- RB_VM_LOCK_ENTER();
- {
- gc_rest(objspace);
-
- /* if both double_heap and expand_heap are set, expand_heap takes precedence */
- if (RTEST(double_heap) || RTEST(expand_heap)) {
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
-
- if (RTEST(expand_heap)) {
- size_t required_pages = growth_slots / size_pool->slot_size;
- heap_add_pages(objspace, size_pool, heap, MAX(required_pages, heap->total_pages));
- }
- else {
- heap_add_pages(objspace, size_pool, heap, heap->total_pages);
- }
- }
- }
-
- if (RTEST(toward_empty)) {
- gc_sort_heap_by_empty_slots(objspace);
- }
- }
- RB_VM_LOCK_LEAVE();
-
- gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qtrue);
-
- objspace_reachable_objects_from_root(objspace, root_obj_check_moved_i, NULL);
- objspace_each_objects(objspace, heap_check_moved_i, NULL, TRUE);
-
- return gc_compact_stats(self);
+ UPDATE_IF_MOVED(objspace, RBASIC(obj)->klass);
}
-#else
-# define gc_verify_compaction_references (rb_builtin_arity3_function_type)rb_f_notimplement
-#endif
VALUE
rb_gc_start(void)
@@ -10966,39 +4532,23 @@ rb_gc_start(void)
void
rb_gc(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- unsigned int reason = GPR_DEFAULT_REASON;
- garbage_collect(objspace, reason);
+ unless_objspace(objspace) { return; }
+
+ rb_gc_impl_start(objspace, true, true, true, false);
}
int
rb_during_gc(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- return during_gc;
-}
-
-#if RGENGC_PROFILE >= 2
-
-static const char *type_name(int type, VALUE obj);
+ unless_objspace(objspace) { return FALSE; }
-static void
-gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
-{
- VALUE result = rb_hash_new_with_size(T_MASK);
- int i;
- for (i=0; i<T_MASK; i++) {
- const char *type = type_name(i, 0);
- rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i]));
- }
- rb_hash_aset(hash, ID2SYM(rb_intern(name)), result);
+ return rb_gc_impl_during_gc_p(objspace);
}
-#endif
size_t
rb_gc_count(void)
{
- return rb_objspace.profile.count;
+ return rb_gc_impl_gc_count(rb_gc_get_objspace());
}
static VALUE
@@ -11007,528 +4557,155 @@ gc_count(rb_execution_context_t *ec, VALUE self)
return SIZET2NUM(rb_gc_count());
}
-static VALUE
-gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned int orig_flags)
+VALUE
+rb_gc_latest_gc_info(VALUE key)
{
- static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state, sym_need_major_by;
- static VALUE sym_nofree, sym_oldgen, sym_shady, sym_force, sym_stress;
-#if RGENGC_ESTIMATE_OLDMALLOC
- static VALUE sym_oldmalloc;
-#endif
- static VALUE sym_newobj, sym_malloc, sym_method, sym_capi;
- static VALUE sym_none, sym_marking, sym_sweeping;
- VALUE hash = Qnil, key = Qnil;
- VALUE major_by, need_major_by;
- unsigned int flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
-
- if (SYMBOL_P(hash_or_key)) {
- key = hash_or_key;
- }
- else if (RB_TYPE_P(hash_or_key, T_HASH)) {
- hash = hash_or_key;
- }
- else {
+ if (!SYMBOL_P(key) && !RB_TYPE_P(key, T_HASH)) {
rb_raise(rb_eTypeError, "non-hash or symbol given");
}
- if (NIL_P(sym_major_by)) {
-#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
- S(major_by);
- S(gc_by);
- S(immediate_sweep);
- S(have_finalizer);
- S(state);
- S(need_major_by);
-
- S(stress);
- S(nofree);
- S(oldgen);
- S(shady);
- S(force);
-#if RGENGC_ESTIMATE_OLDMALLOC
- S(oldmalloc);
-#endif
- S(newobj);
- S(malloc);
- S(method);
- S(capi);
-
- S(none);
- S(marking);
- S(sweeping);
-#undef S
- }
-
-#define SET(name, attr) \
- if (key == sym_##name) \
- return (attr); \
- else if (hash != Qnil) \
- rb_hash_aset(hash, sym_##name, (attr));
-
- major_by =
- (flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
- (flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
- (flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
- (flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
-#if RGENGC_ESTIMATE_OLDMALLOC
- (flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
-#endif
- Qnil;
- SET(major_by, major_by);
-
- if (orig_flags == 0) { /* set need_major_by only if flags not set explicitly */
- unsigned int need_major_flags = objspace->rgengc.need_major_gc;
- need_major_by =
- (need_major_flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
- (need_major_flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
- (need_major_flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
- (need_major_flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
-#if RGENGC_ESTIMATE_OLDMALLOC
- (need_major_flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
-#endif
- Qnil;
- SET(need_major_by, need_major_by);
- }
-
- SET(gc_by,
- (flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
- (flags & GPR_FLAG_MALLOC) ? sym_malloc :
- (flags & GPR_FLAG_METHOD) ? sym_method :
- (flags & GPR_FLAG_CAPI) ? sym_capi :
- (flags & GPR_FLAG_STRESS) ? sym_stress :
- Qnil
- );
-
- SET(have_finalizer, RBOOL(flags & GPR_FLAG_HAVE_FINALIZE));
- SET(immediate_sweep, RBOOL(flags & GPR_FLAG_IMMEDIATE_SWEEP));
+ VALUE val = rb_gc_impl_latest_gc_info(rb_gc_get_objspace(), key);
- if (orig_flags == 0) {
- SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
- gc_mode(objspace) == gc_mode_marking ? sym_marking : sym_sweeping);
- }
-#undef SET
-
- if (!NIL_P(key)) {/* matched key should return above */
+ if (val == Qundef) {
rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
}
- return hash;
-}
-
-VALUE
-rb_gc_latest_gc_info(VALUE key)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return gc_info_decode(objspace, key, 0);
+ return val;
}
static VALUE
-gc_latest_gc_info(rb_execution_context_t *ec, VALUE self, VALUE arg)
+gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || hash || symbol)
{
- rb_objspace_t *objspace = &rb_objspace;
-
if (NIL_P(arg)) {
arg = rb_hash_new();
}
- else if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) {
+ else if (!RB_TYPE_P(arg, T_HASH) && !SYMBOL_P(arg)) {
rb_raise(rb_eTypeError, "non-hash or symbol given");
}
- return gc_info_decode(objspace, arg, 0);
-}
-
-enum gc_stat_sym {
- gc_stat_sym_count,
- gc_stat_sym_time,
- gc_stat_sym_marking_time,
- gc_stat_sym_sweeping_time,
- gc_stat_sym_heap_allocated_pages,
- gc_stat_sym_heap_sorted_length,
- gc_stat_sym_heap_allocatable_pages,
- gc_stat_sym_heap_available_slots,
- gc_stat_sym_heap_live_slots,
- gc_stat_sym_heap_free_slots,
- gc_stat_sym_heap_final_slots,
- gc_stat_sym_heap_marked_slots,
- gc_stat_sym_heap_eden_pages,
- gc_stat_sym_heap_tomb_pages,
- gc_stat_sym_total_allocated_pages,
- gc_stat_sym_total_freed_pages,
- gc_stat_sym_total_allocated_objects,
- gc_stat_sym_total_freed_objects,
- gc_stat_sym_malloc_increase_bytes,
- gc_stat_sym_malloc_increase_bytes_limit,
- gc_stat_sym_minor_gc_count,
- gc_stat_sym_major_gc_count,
- gc_stat_sym_compact_count,
- gc_stat_sym_read_barrier_faults,
- gc_stat_sym_total_moved_objects,
- gc_stat_sym_remembered_wb_unprotected_objects,
- gc_stat_sym_remembered_wb_unprotected_objects_limit,
- gc_stat_sym_old_objects,
- gc_stat_sym_old_objects_limit,
-#if RGENGC_ESTIMATE_OLDMALLOC
- gc_stat_sym_oldmalloc_increase_bytes,
- gc_stat_sym_oldmalloc_increase_bytes_limit,
-#endif
-#if RGENGC_PROFILE
- gc_stat_sym_total_generated_normal_object_count,
- gc_stat_sym_total_generated_shady_object_count,
- gc_stat_sym_total_shade_operation_count,
- gc_stat_sym_total_promoted_count,
- gc_stat_sym_total_remembered_normal_object_count,
- gc_stat_sym_total_remembered_shady_object_count,
-#endif
- gc_stat_sym_last
-};
+ VALUE ret = rb_gc_impl_stat(rb_gc_get_objspace(), arg);
-static VALUE gc_stat_symbols[gc_stat_sym_last];
+ if (ret == Qundef) {
+ GC_ASSERT(SYMBOL_P(arg));
-static void
-setup_gc_stat_symbols(void)
-{
- if (gc_stat_symbols[0] == 0) {
-#define S(s) gc_stat_symbols[gc_stat_sym_##s] = ID2SYM(rb_intern_const(#s))
- S(count);
- S(time);
- S(marking_time),
- S(sweeping_time),
- S(heap_allocated_pages);
- S(heap_sorted_length);
- S(heap_allocatable_pages);
- S(heap_available_slots);
- S(heap_live_slots);
- S(heap_free_slots);
- S(heap_final_slots);
- S(heap_marked_slots);
- S(heap_eden_pages);
- S(heap_tomb_pages);
- S(total_allocated_pages);
- S(total_freed_pages);
- S(total_allocated_objects);
- S(total_freed_objects);
- S(malloc_increase_bytes);
- S(malloc_increase_bytes_limit);
- S(minor_gc_count);
- S(major_gc_count);
- S(compact_count);
- S(read_barrier_faults);
- S(total_moved_objects);
- S(remembered_wb_unprotected_objects);
- S(remembered_wb_unprotected_objects_limit);
- S(old_objects);
- S(old_objects_limit);
-#if RGENGC_ESTIMATE_OLDMALLOC
- S(oldmalloc_increase_bytes);
- S(oldmalloc_increase_bytes_limit);
-#endif
-#if RGENGC_PROFILE
- S(total_generated_normal_object_count);
- S(total_generated_shady_object_count);
- S(total_shade_operation_count);
- S(total_promoted_count);
- S(total_remembered_normal_object_count);
- S(total_remembered_shady_object_count);
-#endif /* RGENGC_PROFILE */
-#undef S
+ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(arg));
}
-}
-static uint64_t
-ns_to_ms(uint64_t ns)
-{
- return ns / (1000 * 1000);
+ return ret;
}
-static size_t
-gc_stat_internal(VALUE hash_or_sym)
+size_t
+rb_gc_stat(VALUE arg)
{
- rb_objspace_t *objspace = &rb_objspace;
- VALUE hash = Qnil, key = Qnil;
-
- setup_gc_stat_symbols();
-
- if (RB_TYPE_P(hash_or_sym, T_HASH)) {
- hash = hash_or_sym;
- }
- else if (SYMBOL_P(hash_or_sym)) {
- key = hash_or_sym;
- }
- else {
- rb_raise(rb_eTypeError, "non-hash or symbol argument");
- }
-
-#define SET(name, attr) \
- if (key == gc_stat_symbols[gc_stat_sym_##name]) \
- return attr; \
- else if (hash != Qnil) \
- rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
-
- SET(count, objspace->profile.count);
- SET(time, (size_t)ns_to_ms(objspace->profile.marking_time_ns + objspace->profile.sweeping_time_ns)); // TODO: UINT64T2NUM
- SET(marking_time, (size_t)ns_to_ms(objspace->profile.marking_time_ns));
- SET(sweeping_time, (size_t)ns_to_ms(objspace->profile.sweeping_time_ns));
-
- /* implementation dependent counters */
- SET(heap_allocated_pages, heap_allocated_pages);
- SET(heap_sorted_length, heap_pages_sorted_length);
- SET(heap_allocatable_pages, heap_allocatable_pages(objspace));
- SET(heap_available_slots, objspace_available_slots(objspace));
- SET(heap_live_slots, objspace_live_slots(objspace));
- SET(heap_free_slots, objspace_free_slots(objspace));
- SET(heap_final_slots, heap_pages_final_slots);
- SET(heap_marked_slots, objspace->marked_slots);
- SET(heap_eden_pages, heap_eden_total_pages(objspace));
- SET(heap_tomb_pages, heap_tomb_total_pages(objspace));
- SET(total_allocated_pages, total_allocated_pages(objspace));
- SET(total_freed_pages, total_freed_pages(objspace));
- SET(total_allocated_objects, objspace->total_allocated_objects);
- SET(total_freed_objects, objspace->profile.total_freed_objects);
- SET(malloc_increase_bytes, malloc_increase);
- SET(malloc_increase_bytes_limit, malloc_limit);
- SET(minor_gc_count, objspace->profile.minor_gc_count);
- SET(major_gc_count, objspace->profile.major_gc_count);
- SET(compact_count, objspace->profile.compact_count);
- SET(read_barrier_faults, objspace->profile.read_barrier_faults);
- SET(total_moved_objects, objspace->rcompactor.total_moved);
- SET(remembered_wb_unprotected_objects, objspace->rgengc.uncollectible_wb_unprotected_objects);
- SET(remembered_wb_unprotected_objects_limit, objspace->rgengc.uncollectible_wb_unprotected_objects_limit);
- SET(old_objects, objspace->rgengc.old_objects);
- SET(old_objects_limit, objspace->rgengc.old_objects_limit);
-#if RGENGC_ESTIMATE_OLDMALLOC
- SET(oldmalloc_increase_bytes, objspace->rgengc.oldmalloc_increase);
- SET(oldmalloc_increase_bytes_limit, objspace->rgengc.oldmalloc_increase_limit);
-#endif
-
-#if RGENGC_PROFILE
- SET(total_generated_normal_object_count, objspace->profile.total_generated_normal_object_count);
- SET(total_generated_shady_object_count, objspace->profile.total_generated_shady_object_count);
- SET(total_shade_operation_count, objspace->profile.total_shade_operation_count);
- SET(total_promoted_count, objspace->profile.total_promoted_count);
- SET(total_remembered_normal_object_count, objspace->profile.total_remembered_normal_object_count);
- SET(total_remembered_shady_object_count, objspace->profile.total_remembered_shady_object_count);
-#endif /* RGENGC_PROFILE */
-#undef SET
-
- if (!NIL_P(key)) { /* matched key should return above */
- rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
+ if (!RB_TYPE_P(arg, T_HASH) && !SYMBOL_P(arg)) {
+ rb_raise(rb_eTypeError, "non-hash or symbol given");
}
-#if defined(RGENGC_PROFILE) && RGENGC_PROFILE >= 2
- if (hash != Qnil) {
- gc_count_add_each_types(hash, "generated_normal_object_count_types", objspace->profile.generated_normal_object_count_types);
- gc_count_add_each_types(hash, "generated_shady_object_count_types", objspace->profile.generated_shady_object_count_types);
- gc_count_add_each_types(hash, "shade_operation_count_types", objspace->profile.shade_operation_count_types);
- gc_count_add_each_types(hash, "promoted_types", objspace->profile.promoted_types);
- gc_count_add_each_types(hash, "remembered_normal_object_count_types", objspace->profile.remembered_normal_object_count_types);
- gc_count_add_each_types(hash, "remembered_shady_object_count_types", objspace->profile.remembered_shady_object_count_types);
- }
-#endif
+ VALUE ret = rb_gc_impl_stat(rb_gc_get_objspace(), arg);
- return 0;
-}
+ if (ret == Qundef) {
+ GC_ASSERT(SYMBOL_P(arg));
-static VALUE
-gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || hash || symbol)
-{
- if (NIL_P(arg)) {
- arg = rb_hash_new();
- }
- else if (SYMBOL_P(arg)) {
- size_t value = gc_stat_internal(arg);
- return SIZET2NUM(value);
- }
- else if (RB_TYPE_P(arg, T_HASH)) {
- // ok
- }
- else {
- rb_raise(rb_eTypeError, "non-hash or symbol given");
+ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(arg));
}
- gc_stat_internal(arg);
- return arg;
-}
-
-size_t
-rb_gc_stat(VALUE key)
-{
- if (SYMBOL_P(key)) {
- size_t value = gc_stat_internal(key);
- return value;
+ if (SYMBOL_P(arg)) {
+ return NUM2SIZET(ret);
}
else {
- gc_stat_internal(key);
return 0;
}
}
-
-enum gc_stat_heap_sym {
- gc_stat_heap_sym_slot_size,
- gc_stat_heap_sym_heap_allocatable_pages,
- gc_stat_heap_sym_heap_eden_pages,
- gc_stat_heap_sym_heap_eden_slots,
- gc_stat_heap_sym_heap_tomb_pages,
- gc_stat_heap_sym_heap_tomb_slots,
- gc_stat_heap_sym_total_allocated_pages,
- gc_stat_heap_sym_total_freed_pages,
- gc_stat_heap_sym_force_major_gc_count,
- gc_stat_heap_sym_last
-};
-
-static VALUE gc_stat_heap_symbols[gc_stat_heap_sym_last];
-
-static void
-setup_gc_stat_heap_symbols(void)
+static VALUE
+gc_stat_heap(rb_execution_context_t *ec, VALUE self, VALUE heap_name, VALUE arg)
{
- if (gc_stat_heap_symbols[0] == 0) {
-#define S(s) gc_stat_heap_symbols[gc_stat_heap_sym_##s] = ID2SYM(rb_intern_const(#s))
- S(slot_size);
- S(heap_allocatable_pages);
- S(heap_eden_pages);
- S(heap_eden_slots);
- S(heap_tomb_pages);
- S(heap_tomb_slots);
- S(total_allocated_pages);
- S(total_freed_pages);
- S(force_major_gc_count);
-#undef S
+ if (NIL_P(arg)) {
+ arg = rb_hash_new();
}
-}
-
-static size_t
-gc_stat_heap_internal(int size_pool_idx, VALUE hash_or_sym)
-{
- rb_objspace_t *objspace = &rb_objspace;
- VALUE hash = Qnil, key = Qnil;
- setup_gc_stat_heap_symbols();
-
- if (RB_TYPE_P(hash_or_sym, T_HASH)) {
- hash = hash_or_sym;
+ if (NIL_P(heap_name)) {
+ if (!RB_TYPE_P(arg, T_HASH)) {
+ rb_raise(rb_eTypeError, "non-hash given");
+ }
}
- else if (SYMBOL_P(hash_or_sym)) {
- key = hash_or_sym;
+ else if (FIXNUM_P(heap_name)) {
+ if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) {
+ rb_raise(rb_eTypeError, "non-hash or symbol given");
+ }
}
else {
- rb_raise(rb_eTypeError, "non-hash or symbol argument");
- }
-
- if (size_pool_idx < 0 || size_pool_idx >= SIZE_POOL_COUNT) {
- rb_raise(rb_eArgError, "size pool index out of range");
+ rb_raise(rb_eTypeError, "heap_name must be nil or an Integer");
}
- rb_size_pool_t *size_pool = &size_pools[size_pool_idx];
-
-#define SET(name, attr) \
- if (key == gc_stat_heap_symbols[gc_stat_heap_sym_##name]) \
- return attr; \
- else if (hash != Qnil) \
- rb_hash_aset(hash, gc_stat_heap_symbols[gc_stat_heap_sym_##name], SIZET2NUM(attr));
+ VALUE ret = rb_gc_impl_stat_heap(rb_gc_get_objspace(), heap_name, arg);
- SET(slot_size, size_pool->slot_size);
- SET(heap_allocatable_pages, size_pool->allocatable_pages);
- SET(heap_eden_pages, SIZE_POOL_EDEN_HEAP(size_pool)->total_pages);
- SET(heap_eden_slots, SIZE_POOL_EDEN_HEAP(size_pool)->total_slots);
- SET(heap_tomb_pages, SIZE_POOL_TOMB_HEAP(size_pool)->total_pages);
- SET(heap_tomb_slots, SIZE_POOL_TOMB_HEAP(size_pool)->total_slots);
- SET(total_allocated_pages, size_pool->total_allocated_pages);
- SET(total_freed_pages, size_pool->total_freed_pages);
- SET(force_major_gc_count, size_pool->force_major_gc_count);
-#undef SET
+ if (ret == Qundef) {
+ GC_ASSERT(SYMBOL_P(arg));
- if (!NIL_P(key)) { /* matched key should return above */
- rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
+ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(arg));
}
- return 0;
+ return ret;
}
static VALUE
-gc_stat_heap(rb_execution_context_t *ec, VALUE self, VALUE heap_name, VALUE arg)
+gc_config_get(rb_execution_context_t *ec, VALUE self)
{
- if (NIL_P(heap_name)) {
- if (NIL_P(arg)) {
- arg = rb_hash_new();
- }
- else if (RB_TYPE_P(arg, T_HASH)) {
- // ok
- }
- else {
- rb_raise(rb_eTypeError, "non-hash given");
- }
+ VALUE cfg_hash = rb_gc_impl_config_get(rb_gc_get_objspace());
+ rb_hash_aset(cfg_hash, sym("implementation"), rb_fstring_cstr(rb_gc_impl_active_gc_name()));
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- VALUE hash = rb_hash_aref(arg, INT2FIX(i));
- if (NIL_P(hash)) {
- hash = rb_hash_new();
- rb_hash_aset(arg, INT2FIX(i), hash);
- }
- gc_stat_heap_internal(i, hash);
- }
- }
- else if (FIXNUM_P(heap_name)) {
- int size_pool_idx = FIX2INT(heap_name);
+ return cfg_hash;
+}
- if (NIL_P(arg)) {
- arg = rb_hash_new();
- }
- else if (SYMBOL_P(arg)) {
- size_t value = gc_stat_heap_internal(size_pool_idx, arg);
- return SIZET2NUM(value);
- }
- else if (RB_TYPE_P(arg, T_HASH)) {
- // ok
- }
- else {
- rb_raise(rb_eTypeError, "non-hash or symbol given");
- }
+static VALUE
+gc_config_set(rb_execution_context_t *ec, VALUE self, VALUE hash)
+{
+ void *objspace = rb_gc_get_objspace();
- gc_stat_heap_internal(size_pool_idx, arg);
- }
- else {
- rb_raise(rb_eTypeError, "heap_name must be nil or an Integer");
- }
+ rb_gc_impl_config_set(objspace, hash);
- return arg;
+ return Qnil;
}
static VALUE
gc_stress_get(rb_execution_context_t *ec, VALUE self)
{
- rb_objspace_t *objspace = &rb_objspace;
- return ruby_gc_stress_mode;
-}
-
-static void
-gc_stress_set(rb_objspace_t *objspace, VALUE flag)
-{
- objspace->flags.gc_stressful = RTEST(flag);
- objspace->gc_stress_mode = flag;
+ return rb_gc_impl_stress_get(rb_gc_get_objspace());
}
static VALUE
gc_stress_set_m(rb_execution_context_t *ec, VALUE self, VALUE flag)
{
- rb_objspace_t *objspace = &rb_objspace;
- gc_stress_set(objspace, flag);
+ rb_gc_impl_stress_set(rb_gc_get_objspace(), flag);
+
return flag;
}
+void
+rb_gc_initial_stress_set(VALUE flag)
+{
+ initial_stress = flag;
+}
+
+size_t *
+rb_gc_heap_sizes(void)
+{
+ return rb_gc_impl_heap_sizes(rb_gc_get_objspace());
+}
+
VALUE
rb_gc_enable(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- return rb_objspace_gc_enable(objspace);
+ return rb_objspace_gc_enable(rb_gc_get_objspace());
}
VALUE
-rb_objspace_gc_enable(rb_objspace_t *objspace)
+rb_objspace_gc_enable(void *objspace)
{
- int old = dont_gc_val();
-
- dont_gc_off();
- return RBOOL(old);
+ bool disabled = !rb_gc_impl_gc_enabled_p(objspace);
+ rb_gc_impl_gc_enable(objspace);
+ return RBOOL(disabled);
}
static VALUE
@@ -11537,33 +4714,32 @@ gc_enable(rb_execution_context_t *ec, VALUE _)
return rb_gc_enable();
}
-VALUE
-rb_gc_disable_no_rest(void)
+static VALUE
+gc_disable_no_rest(void *objspace)
{
- rb_objspace_t *objspace = &rb_objspace;
- return gc_disable_no_rest(objspace);
+ bool disabled = !rb_gc_impl_gc_enabled_p(objspace);
+ rb_gc_impl_gc_disable(objspace, false);
+ return RBOOL(disabled);
}
-static VALUE
-gc_disable_no_rest(rb_objspace_t *objspace)
+VALUE
+rb_gc_disable_no_rest(void)
{
- int old = dont_gc_val();
- dont_gc_on();
- return RBOOL(old);
+ return gc_disable_no_rest(rb_gc_get_objspace());
}
VALUE
rb_gc_disable(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- return rb_objspace_gc_disable(objspace);
+ return rb_objspace_gc_disable(rb_gc_get_objspace());
}
VALUE
-rb_objspace_gc_disable(rb_objspace_t *objspace)
+rb_objspace_gc_disable(void *objspace)
{
- gc_rest(objspace);
- return gc_disable_no_rest(objspace);
+ bool disabled = !rb_gc_impl_gc_enabled_p(objspace);
+ rb_gc_impl_gc_disable(objspace, true);
+ return RBOOL(disabled);
}
static VALUE
@@ -11572,296 +4748,32 @@ gc_disable(rb_execution_context_t *ec, VALUE _)
return rb_gc_disable();
}
-#if GC_CAN_COMPILE_COMPACTION
-/*
- * call-seq:
- * GC.auto_compact = flag
- *
- * Updates automatic compaction mode.
- *
- * When enabled, the compactor will execute on every major collection.
- *
- * Enabling compaction will degrade performance on major collections.
- */
-static VALUE
-gc_set_auto_compact(VALUE _, VALUE v)
-{
- GC_ASSERT(GC_COMPACTION_SUPPORTED);
-
- ruby_enable_autocompact = RTEST(v);
- return v;
-}
-#else
-# define gc_set_auto_compact rb_f_notimplement
-#endif
-
-#if GC_CAN_COMPILE_COMPACTION
-/*
- * call-seq:
- * GC.auto_compact -> true or false
- *
- * Returns whether or not automatic compaction has been enabled.
- */
-static VALUE
-gc_get_auto_compact(VALUE _)
-{
- return RBOOL(ruby_enable_autocompact);
-}
-#else
-# define gc_get_auto_compact rb_f_notimplement
-#endif
-
-static int
-get_envparam_size(const char *name, size_t *default_value, size_t lower_bound)
-{
- const char *ptr = getenv(name);
- ssize_t val;
-
- if (ptr != NULL && *ptr) {
- size_t unit = 0;
- char *end;
-#if SIZEOF_SIZE_T == SIZEOF_LONG_LONG
- val = strtoll(ptr, &end, 0);
-#else
- val = strtol(ptr, &end, 0);
-#endif
- switch (*end) {
- case 'k': case 'K':
- unit = 1024;
- ++end;
- break;
- case 'm': case 'M':
- unit = 1024*1024;
- ++end;
- break;
- case 'g': case 'G':
- unit = 1024*1024*1024;
- ++end;
- break;
- }
- while (*end && isspace((unsigned char)*end)) end++;
- if (*end) {
- if (RTEST(ruby_verbose)) fprintf(stderr, "invalid string for %s: %s\n", name, ptr);
- return 0;
- }
- if (unit > 0) {
- if (val < -(ssize_t)(SIZE_MAX / 2 / unit) || (ssize_t)(SIZE_MAX / 2 / unit) < val) {
- if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%s is ignored because it overflows\n", name, ptr);
- return 0;
- }
- val *= unit;
- }
- if (val > 0 && (size_t)val > lower_bound) {
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "%s=%"PRIdSIZE" (default value: %"PRIuSIZE")\n", name, val, *default_value);
- }
- *default_value = (size_t)val;
- return 1;
- }
- else {
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "%s=%"PRIdSIZE" (default value: %"PRIuSIZE") is ignored because it must be greater than %"PRIuSIZE".\n",
- name, val, *default_value, lower_bound);
- }
- return 0;
- }
- }
- return 0;
-}
-
-static int
-get_envparam_double(const char *name, double *default_value, double lower_bound, double upper_bound, int accept_zero)
-{
- const char *ptr = getenv(name);
- double val;
-
- if (ptr != NULL && *ptr) {
- char *end;
- val = strtod(ptr, &end);
- if (!*ptr || *end) {
- if (RTEST(ruby_verbose)) fprintf(stderr, "invalid string for %s: %s\n", name, ptr);
- return 0;
- }
-
- if (accept_zero && val == 0.0) {
- goto accept;
- }
- else if (val <= lower_bound) {
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n",
- name, val, *default_value, lower_bound);
- }
- }
- else if (upper_bound != 0.0 && /* ignore upper_bound if it is 0.0 */
- val > upper_bound) {
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be lower than %f.\n",
- name, val, *default_value, upper_bound);
- }
- }
- else {
- goto accept;
- }
- }
- return 0;
-
- accept:
- if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f)\n", name, val, *default_value);
- *default_value = val;
- return 1;
-}
-
-static void
-gc_set_initial_pages(rb_objspace_t *objspace, int global_heap_init_slots)
-{
- gc_rest(objspace);
-
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- rb_size_pool_t *size_pool = &size_pools[i];
- char env_key[sizeof("RUBY_GC_HEAP_INIT_SIZE_" "_SLOTS") + DECIMAL_SIZE_OF_BITS(sizeof(size_pool->slot_size) * CHAR_BIT)];
- snprintf(env_key, sizeof(env_key), "RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS", size_pool->slot_size);
-
- size_t pool_init_slots = 0;
- if (!get_envparam_size(env_key, &pool_init_slots, 0)) {
- if (global_heap_init_slots) {
- // If we use the global init slot we ponderate it by slot size
- pool_init_slots = gc_params.heap_init_slots / (size_pool->slot_size / BASE_SLOT_SIZE);
- }
- else {
- continue;
- }
- }
-
- if (pool_init_slots > size_pool->eden_heap.total_slots) {
- size_t slots = pool_init_slots - size_pool->eden_heap.total_slots;
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_pool->allocatable_pages = slots * multiple / HEAP_PAGE_OBJ_LIMIT;
- }
- else {
- /* We already have more slots than heap_init_slots allows, so
- * prevent creating more pages. */
- size_pool->allocatable_pages = 0;
- }
- }
- heap_pages_expand_sorted(objspace);
-}
-
-/*
- * GC tuning environment variables
- *
- * * RUBY_GC_HEAP_INIT_SLOTS
- * - Initial allocation slots.
- * * RUBY_GC_HEAP_FREE_SLOTS
- * - Prepare at least this amount of slots after GC.
- * - Allocate slots if there are not enough slots.
- * * RUBY_GC_HEAP_GROWTH_FACTOR (new from 2.1)
- * - Allocate slots by this factor.
- * - (next slots number) = (current slots number) * (this factor)
- * * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1)
- * - Allocation rate is limited to this number of slots.
- * * RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO (new from 2.4)
- * - Allocate additional pages when the number of free slots is
- * lower than the value (total_slots * (this ratio)).
- * * RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO (new from 2.4)
- * - Allocate slots to satisfy this formula:
- * free_slots = total_slots * goal_ratio
- * - In other words, prepare (total_slots * goal_ratio) free slots.
- * - if this value is 0.0, then use RUBY_GC_HEAP_GROWTH_FACTOR directly.
- * * RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO (new from 2.4)
- * - Allow to free pages when the number of free slots is
- * greater than the value (total_slots * (this ratio)).
- * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1)
- * - Do full GC when the number of old objects is more than R * N
- * where R is this factor and
- * N is the number of old objects just after last full GC.
- *
- * * obsolete
- * * RUBY_FREE_MIN -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1)
- * * RUBY_HEAP_MIN_SLOTS -> RUBY_GC_HEAP_INIT_SLOTS (from 2.1)
- *
- * * RUBY_GC_MALLOC_LIMIT
- * * RUBY_GC_MALLOC_LIMIT_MAX (new from 2.1)
- * * RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR (new from 2.1)
- *
- * * RUBY_GC_OLDMALLOC_LIMIT (new from 2.1)
- * * RUBY_GC_OLDMALLOC_LIMIT_MAX (new from 2.1)
- * * RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR (new from 2.1)
- */
-
+// TODO: think about moving ruby_gc_set_params into Init_heap or Init_gc
void
ruby_gc_set_params(void)
{
- rb_objspace_t *objspace = &rb_objspace;
- /* RUBY_GC_HEAP_FREE_SLOTS */
- if (get_envparam_size("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) {
- /* ok */
- }
-
- /* RUBY_GC_HEAP_INIT_SLOTS */
- if (get_envparam_size("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) {
- gc_set_initial_pages(objspace, TRUE);
- }
- else {
- gc_set_initial_pages(objspace, FALSE);
- }
-
- get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0, 0.0, FALSE);
- get_envparam_size ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0);
- get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO", &gc_params.heap_free_slots_min_ratio,
- 0.0, 1.0, FALSE);
- get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO", &gc_params.heap_free_slots_max_ratio,
- gc_params.heap_free_slots_min_ratio, 1.0, FALSE);
- get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", &gc_params.heap_free_slots_goal_ratio,
- gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
- get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
-
- if (get_envparam_size("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0)) {
- malloc_limit = gc_params.malloc_limit_min;
- }
- get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
- if (!gc_params.malloc_limit_max) { /* ignore max-check if 0 */
- gc_params.malloc_limit_max = SIZE_MAX;
- }
- get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0, 0.0, FALSE);
-
-#if RGENGC_ESTIMATE_OLDMALLOC
- if (get_envparam_size("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
- objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
- }
- get_envparam_size ("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
- get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0, 0.0, FALSE);
-#endif
-}
-
-static void
-reachable_objects_from_callback(VALUE obj)
-{
- rb_ractor_t *cr = GET_RACTOR();
- cr->mfd->mark_func(obj, cr->mfd->data);
+ rb_gc_impl_set_params(rb_gc_get_objspace());
}
void
rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data)
{
- rb_objspace_t *objspace = &rb_objspace;
+ RB_VM_LOCKING() {
+ if (rb_gc_impl_during_gc_p(rb_gc_get_objspace())) rb_bug("rb_objspace_reachable_objects_from() is not supported while during GC");
- RB_VM_LOCK_ENTER();
- {
- if (during_gc) rb_bug("rb_objspace_reachable_objects_from() is not supported while during_gc == true");
-
- if (is_markable_object(objspace, obj)) {
- rb_ractor_t *cr = GET_RACTOR();
+ if (!RB_SPECIAL_CONST_P(obj)) {
+ rb_vm_t *vm = GET_VM();
+ struct gc_mark_func_data_struct *prev_mfd = vm->gc.mark_func_data;
struct gc_mark_func_data_struct mfd = {
.mark_func = func,
.data = data,
- }, *prev_mfd = cr->mfd;
+ };
- cr->mfd = &mfd;
- gc_mark_children(objspace, obj);
- cr->mfd = prev_mfd;
+ vm->gc.mark_func_data = &mfd;
+ rb_gc_mark_children(rb_gc_get_objspace(), obj);
+ vm->gc.mark_func_data = prev_mfd;
}
}
- RB_VM_LOCK_LEAVE();
}
struct root_objects_data {
@@ -11880,1524 +4792,25 @@ root_objects_from(VALUE obj, void *ptr)
void
rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *passing_data)
{
- rb_objspace_t *objspace = &rb_objspace;
- objspace_reachable_objects_from_root(objspace, func, passing_data);
-}
+ if (rb_gc_impl_during_gc_p(rb_gc_get_objspace())) rb_bug("rb_gc_impl_objspace_reachable_objects_from_root() is not supported while during GC");
-static void
-objspace_reachable_objects_from_root(rb_objspace_t *objspace, void (func)(const char *category, VALUE, void *), void *passing_data)
-{
- if (during_gc) rb_bug("objspace_reachable_objects_from_root() is not supported while during_gc == true");
+ rb_vm_t *vm = GET_VM();
- rb_ractor_t *cr = GET_RACTOR();
struct root_objects_data data = {
.func = func,
.data = passing_data,
};
+
+ struct gc_mark_func_data_struct *prev_mfd = vm->gc.mark_func_data;
struct gc_mark_func_data_struct mfd = {
.mark_func = root_objects_from,
.data = &data,
- }, *prev_mfd = cr->mfd;
-
- cr->mfd = &mfd;
- gc_mark_roots(objspace, &data.category);
- cr->mfd = prev_mfd;
-}
-
-/*
- ------------------------ Extended allocator ------------------------
-*/
-
-struct gc_raise_tag {
- VALUE exc;
- const char *fmt;
- va_list *ap;
-};
-
-static void *
-gc_vraise(void *ptr)
-{
- struct gc_raise_tag *argv = ptr;
- rb_vraise(argv->exc, argv->fmt, *argv->ap);
- UNREACHABLE_RETURN(NULL);
-}
-
-static void
-gc_raise(VALUE exc, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- struct gc_raise_tag argv = {
- exc, fmt, &ap,
};
- if (ruby_thread_has_gvl_p()) {
- gc_vraise(&argv);
- UNREACHABLE;
- }
- else if (ruby_native_thread_p()) {
- rb_thread_call_with_gvl(gc_vraise, &argv);
- UNREACHABLE;
- }
- else {
- /* Not in a ruby thread */
- fprintf(stderr, "%s", "[FATAL] ");
- vfprintf(stderr, fmt, ap);
- }
-
- va_end(ap);
- abort();
-}
-
-static void objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t size);
-
-static void
-negative_size_allocation_error(const char *msg)
-{
- gc_raise(rb_eNoMemError, "%s", msg);
-}
-
-static void *
-ruby_memerror_body(void *dummy)
-{
- rb_memerror();
- return 0;
-}
-
-NORETURN(static void ruby_memerror(void));
-RBIMPL_ATTR_MAYBE_UNUSED()
-static void
-ruby_memerror(void)
-{
- if (ruby_thread_has_gvl_p()) {
- rb_memerror();
- }
- else {
- if (ruby_native_thread_p()) {
- rb_thread_call_with_gvl(ruby_memerror_body, 0);
- }
- else {
- /* no ruby thread */
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- }
- }
- exit(EXIT_FAILURE);
-}
-
-void
-rb_memerror(void)
-{
- rb_execution_context_t *ec = GET_EC();
- rb_objspace_t *objspace = rb_objspace_of(rb_ec_vm_ptr(ec));
- VALUE exc;
-
- if (0) {
- // Print out pid, sleep, so you can attach debugger to see what went wrong:
- fprintf(stderr, "rb_memerror pid=%"PRI_PIDT_PREFIX"d\n", getpid());
- sleep(60);
- }
-
- if (during_gc) {
- // TODO: OMG!! How to implement it?
- gc_exit(objspace, gc_enter_event_rb_memerror, NULL);
- }
-
- exc = nomem_error;
- if (!exc ||
- rb_ec_raised_p(ec, RAISED_NOMEMORY)) {
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- exit(EXIT_FAILURE);
- }
- if (rb_ec_raised_p(ec, RAISED_NOMEMORY)) {
- rb_ec_raised_clear(ec);
- }
- else {
- rb_ec_raised_set(ec, RAISED_NOMEMORY);
- exc = ruby_vm_special_exception_copy(exc);
- }
- ec->errinfo = exc;
- EC_JUMP_TAG(ec, TAG_RAISE);
-}
-
-void *
-rb_aligned_malloc(size_t alignment, size_t size)
-{
- /* alignment must be a power of 2 */
- GC_ASSERT(((alignment - 1) & alignment) == 0);
- GC_ASSERT(alignment % sizeof(void*) == 0);
-
- void *res;
-
-#if defined __MINGW32__
- res = __mingw_aligned_malloc(size, alignment);
-#elif defined _WIN32
- void *_aligned_malloc(size_t, size_t);
- res = _aligned_malloc(size, alignment);
-#elif defined(HAVE_POSIX_MEMALIGN)
- if (posix_memalign(&res, alignment, size) != 0) {
- return NULL;
- }
-#elif defined(HAVE_MEMALIGN)
- res = memalign(alignment, size);
-#else
- char* aligned;
- res = malloc(alignment + size + sizeof(void*));
- aligned = (char*)res + alignment + sizeof(void*);
- aligned -= ((VALUE)aligned & (alignment - 1));
- ((void**)aligned)[-1] = res;
- res = (void*)aligned;
-#endif
-
- GC_ASSERT((uintptr_t)res % alignment == 0);
-
- return res;
-}
-
-static void
-rb_aligned_free(void *ptr, size_t size)
-{
-#if defined __MINGW32__
- __mingw_aligned_free(ptr);
-#elif defined _WIN32
- _aligned_free(ptr);
-#elif defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)
- free(ptr);
-#else
- free(((void**)ptr)[-1]);
-#endif
-}
-
-static inline size_t
-objspace_malloc_size(rb_objspace_t *objspace, void *ptr, size_t hint)
-{
-#ifdef HAVE_MALLOC_USABLE_SIZE
- return malloc_usable_size(ptr);
-#else
- return hint;
-#endif
-}
-
-enum memop_type {
- MEMOP_TYPE_MALLOC = 0,
- MEMOP_TYPE_FREE,
- MEMOP_TYPE_REALLOC
-};
-
-static inline void
-atomic_sub_nounderflow(size_t *var, size_t sub)
-{
- if (sub == 0) return;
-
- while (1) {
- size_t val = *var;
- if (val < sub) sub = val;
- if (ATOMIC_SIZE_CAS(*var, val, val-sub) == val) break;
- }
-}
-
-static void
-objspace_malloc_gc_stress(rb_objspace_t *objspace)
-{
- if (ruby_gc_stressful && ruby_native_thread_p()) {
- unsigned int reason = (GPR_FLAG_IMMEDIATE_MARK | GPR_FLAG_IMMEDIATE_SWEEP |
- GPR_FLAG_STRESS | GPR_FLAG_MALLOC);
-
- if (gc_stress_full_mark_after_malloc_p()) {
- reason |= GPR_FLAG_FULL_MARK;
- }
- garbage_collect_with_gvl(objspace, reason);
- }
-}
-
-static inline bool
-objspace_malloc_increase_report(rb_objspace_t *objspace, void *mem, size_t new_size, size_t old_size, enum memop_type type)
-{
- if (0) fprintf(stderr, "increase - ptr: %p, type: %s, new_size: %"PRIdSIZE", old_size: %"PRIdSIZE"\n",
- mem,
- type == MEMOP_TYPE_MALLOC ? "malloc" :
- type == MEMOP_TYPE_FREE ? "free " :
- type == MEMOP_TYPE_REALLOC ? "realloc": "error",
- new_size, old_size);
- return false;
-}
-
-static bool
-objspace_malloc_increase_body(rb_objspace_t *objspace, void *mem, size_t new_size, size_t old_size, enum memop_type type)
-{
- if (new_size > old_size) {
- ATOMIC_SIZE_ADD(malloc_increase, new_size - old_size);
-#if RGENGC_ESTIMATE_OLDMALLOC
- ATOMIC_SIZE_ADD(objspace->rgengc.oldmalloc_increase, new_size - old_size);
-#endif
- }
- else {
- atomic_sub_nounderflow(&malloc_increase, old_size - new_size);
-#if RGENGC_ESTIMATE_OLDMALLOC
- atomic_sub_nounderflow(&objspace->rgengc.oldmalloc_increase, old_size - new_size);
-#endif
- }
-
- if (type == MEMOP_TYPE_MALLOC) {
- retry:
- if (malloc_increase > malloc_limit && ruby_native_thread_p() && !dont_gc_val()) {
- if (ruby_thread_has_gvl_p() && is_lazy_sweeping(objspace)) {
- gc_rest(objspace); /* gc_rest can reduce malloc_increase */
- goto retry;
- }
- garbage_collect_with_gvl(objspace, GPR_FLAG_MALLOC);
- }
- }
-
-#if MALLOC_ALLOCATED_SIZE
- if (new_size >= old_size) {
- ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, new_size - old_size);
- }
- else {
- size_t dec_size = old_size - new_size;
- size_t allocated_size = objspace->malloc_params.allocated_size;
-
-#if MALLOC_ALLOCATED_SIZE_CHECK
- if (allocated_size < dec_size) {
- rb_bug("objspace_malloc_increase: underflow malloc_params.allocated_size.");
- }
-#endif
- atomic_sub_nounderflow(&objspace->malloc_params.allocated_size, dec_size);
- }
-
- switch (type) {
- case MEMOP_TYPE_MALLOC:
- ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
- break;
- case MEMOP_TYPE_FREE:
- {
- size_t allocations = objspace->malloc_params.allocations;
- if (allocations > 0) {
- atomic_sub_nounderflow(&objspace->malloc_params.allocations, 1);
- }
-#if MALLOC_ALLOCATED_SIZE_CHECK
- else {
- GC_ASSERT(objspace->malloc_params.allocations > 0);
- }
-#endif
- }
- break;
- case MEMOP_TYPE_REALLOC: /* ignore */ break;
- }
-#endif
- return true;
-}
-
-#define objspace_malloc_increase(...) \
- for (bool malloc_increase_done = objspace_malloc_increase_report(__VA_ARGS__); \
- !malloc_increase_done; \
- malloc_increase_done = objspace_malloc_increase_body(__VA_ARGS__))
-
-struct malloc_obj_info { /* 4 words */
- size_t size;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- size_t gen;
- const char *file;
- size_t line;
-#endif
-};
-
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
-const char *ruby_malloc_info_file;
-int ruby_malloc_info_line;
-#endif
-
-static inline size_t
-objspace_malloc_prepare(rb_objspace_t *objspace, size_t size)
-{
- if (size == 0) size = 1;
-
-#if CALC_EXACT_MALLOC_SIZE
- size += sizeof(struct malloc_obj_info);
-#endif
-
- return size;
-}
-
-static bool
-malloc_during_gc_p(rb_objspace_t *objspace)
-{
- /* malloc is not allowed during GC when we're not using multiple ractors
- * (since ractors can run while another thread is sweeping) and when we
- * have the GVL (since if we don't have the GVL, we'll try to acquire the
- * GVL which will block and ensure the other thread finishes GC). */
- return during_gc && !dont_gc_val() && !rb_multi_ractor_p() && ruby_thread_has_gvl_p();
-}
-
-static inline void *
-objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
-{
- size = objspace_malloc_size(objspace, mem, size);
- objspace_malloc_increase(objspace, mem, size, 0, MEMOP_TYPE_MALLOC);
-
-#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = mem;
- info->size = size;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- info->gen = objspace->profile.count;
- info->file = ruby_malloc_info_file;
- info->line = info->file ? ruby_malloc_info_line : 0;
-#endif
- mem = info + 1;
- }
-#endif
-
- return mem;
-}
-
-#if defined(__GNUC__) && RUBY_DEBUG
-#define RB_BUG_INSTEAD_OF_RB_MEMERROR 1
-#endif
-
-#ifndef RB_BUG_INSTEAD_OF_RB_MEMERROR
-# define RB_BUG_INSTEAD_OF_RB_MEMERROR 0
-#endif
-
-#define GC_MEMERROR(...) \
- ((RB_BUG_INSTEAD_OF_RB_MEMERROR+0) ? rb_bug("" __VA_ARGS__) : rb_memerror())
-
-#define TRY_WITH_GC(siz, expr) do { \
- const gc_profile_record_flag gpr = \
- GPR_FLAG_FULL_MARK | \
- GPR_FLAG_IMMEDIATE_MARK | \
- GPR_FLAG_IMMEDIATE_SWEEP | \
- GPR_FLAG_MALLOC; \
- objspace_malloc_gc_stress(objspace); \
- \
- if (LIKELY((expr))) { \
- /* Success on 1st try */ \
- } \
- else if (!garbage_collect_with_gvl(objspace, gpr)) { \
- /* @shyouhei thinks this doesn't happen */ \
- GC_MEMERROR("TRY_WITH_GC: could not GC"); \
- } \
- else if ((expr)) { \
- /* Success on 2nd try */ \
- } \
- else { \
- GC_MEMERROR("TRY_WITH_GC: could not allocate:" \
- "%"PRIdSIZE" bytes for %s", \
- siz, # expr); \
- } \
- } while (0)
-
-static void
-check_malloc_not_in_gc(rb_objspace_t *objspace, const char *msg)
-{
- if (UNLIKELY(malloc_during_gc_p(objspace))) {
- dont_gc_on();
- during_gc = false;
- rb_bug("Cannot %s during GC", msg);
- }
-}
-
-/* these shouldn't be called directly.
- * objspace_* functions do not check allocation size.
- */
-static void *
-objspace_xmalloc0(rb_objspace_t *objspace, size_t size)
-{
- check_malloc_not_in_gc(objspace, "malloc");
-
- void *mem;
-
- size = objspace_malloc_prepare(objspace, size);
- TRY_WITH_GC(size, mem = malloc(size));
- RB_DEBUG_COUNTER_INC(heap_xmalloc);
- return objspace_malloc_fixup(objspace, mem, size);
-}
-
-static inline size_t
-xmalloc2_size(const size_t count, const size_t elsize)
-{
- return size_mul_or_raise(count, elsize, rb_eArgError);
-}
-
-static void *
-objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t old_size)
-{
- check_malloc_not_in_gc(objspace, "realloc");
-
- void *mem;
-
- if (!ptr) return objspace_xmalloc0(objspace, new_size);
-
- /*
- * The behavior of realloc(ptr, 0) is implementation defined.
- * Therefore we don't use realloc(ptr, 0) for portability reason.
- * see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_400.htm
- */
- if (new_size == 0) {
- if ((mem = objspace_xmalloc0(objspace, 0)) != NULL) {
- /*
- * - OpenBSD's malloc(3) man page says that when 0 is passed, it
- * returns a non-NULL pointer to an access-protected memory page.
- * The returned pointer cannot be read / written at all, but
- * still be a valid argument of free().
- *
- * https://man.openbsd.org/malloc.3
- *
- * - Linux's malloc(3) man page says that it _might_ perhaps return
- * a non-NULL pointer when its argument is 0. That return value
- * is safe (and is expected) to be passed to free().
- *
- * https://man7.org/linux/man-pages/man3/malloc.3.html
- *
- * - As I read the implementation jemalloc's malloc() returns fully
- * normal 16 bytes memory region when its argument is 0.
- *
- * - As I read the implementation musl libc's malloc() returns
- * fully normal 32 bytes memory region when its argument is 0.
- *
- * - Other malloc implementations can also return non-NULL.
- */
- objspace_xfree(objspace, ptr, old_size);
- return mem;
- }
- else {
- /*
- * It is dangerous to return NULL here, because that could lead to
- * RCE. Fallback to 1 byte instead of zero.
- *
- * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11932
- */
- new_size = 1;
- }
- }
-
-#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- new_size += sizeof(struct malloc_obj_info);
- ptr = info;
- old_size = info->size;
- }
-#endif
-
- old_size = objspace_malloc_size(objspace, ptr, old_size);
- TRY_WITH_GC(new_size, mem = RB_GNUC_EXTENSION_BLOCK(realloc(ptr, new_size)));
- new_size = objspace_malloc_size(objspace, mem, new_size);
-
-#if CALC_EXACT_MALLOC_SIZE
- {
- struct malloc_obj_info *info = mem;
- info->size = new_size;
- mem = info + 1;
- }
-#endif
-
- objspace_malloc_increase(objspace, mem, new_size, old_size, MEMOP_TYPE_REALLOC);
-
- RB_DEBUG_COUNTER_INC(heap_xrealloc);
- return mem;
-}
-
-#if CALC_EXACT_MALLOC_SIZE && USE_GC_MALLOC_OBJ_INFO_DETAILS
-
-#define MALLOC_INFO_GEN_SIZE 100
-#define MALLOC_INFO_SIZE_SIZE 10
-static size_t malloc_info_gen_cnt[MALLOC_INFO_GEN_SIZE];
-static size_t malloc_info_gen_size[MALLOC_INFO_GEN_SIZE];
-static size_t malloc_info_size[MALLOC_INFO_SIZE_SIZE+1];
-static st_table *malloc_info_file_table;
-
-static int
-mmalloc_info_file_i(st_data_t key, st_data_t val, st_data_t dmy)
-{
- const char *file = (void *)key;
- const size_t *data = (void *)val;
-
- fprintf(stderr, "%s\t%"PRIdSIZE"\t%"PRIdSIZE"\n", file, data[0], data[1]);
-
- return ST_CONTINUE;
-}
-
-__attribute__((destructor))
-void
-rb_malloc_info_show_results(void)
-{
- int i;
-
- fprintf(stderr, "* malloc_info gen statistics\n");
- for (i=0; i<MALLOC_INFO_GEN_SIZE; i++) {
- if (i == MALLOC_INFO_GEN_SIZE-1) {
- fprintf(stderr, "more\t%"PRIdSIZE"\t%"PRIdSIZE"\n", malloc_info_gen_cnt[i], malloc_info_gen_size[i]);
- }
- else {
- fprintf(stderr, "%d\t%"PRIdSIZE"\t%"PRIdSIZE"\n", i, malloc_info_gen_cnt[i], malloc_info_gen_size[i]);
- }
- }
-
- fprintf(stderr, "* malloc_info size statistics\n");
- for (i=0; i<MALLOC_INFO_SIZE_SIZE; i++) {
- int s = 16 << i;
- fprintf(stderr, "%d\t%"PRIdSIZE"\n", s, malloc_info_size[i]);
- }
- fprintf(stderr, "more\t%"PRIdSIZE"\n", malloc_info_size[i]);
-
- if (malloc_info_file_table) {
- fprintf(stderr, "* malloc_info file statistics\n");
- st_foreach(malloc_info_file_table, mmalloc_info_file_i, 0);
- }
-}
-#else
-void
-rb_malloc_info_show_results(void)
-{
-}
-#endif
-
-static void
-objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t old_size)
-{
- if (!ptr) {
- /*
- * ISO/IEC 9899 says "If ptr is a null pointer, no action occurs" since
- * its first version. We would better follow.
- */
- return;
- }
-#if CALC_EXACT_MALLOC_SIZE
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- ptr = info;
- old_size = info->size;
-
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- {
- int gen = (int)(objspace->profile.count - info->gen);
- int gen_index = gen >= MALLOC_INFO_GEN_SIZE ? MALLOC_INFO_GEN_SIZE-1 : gen;
- int i;
-
- malloc_info_gen_cnt[gen_index]++;
- malloc_info_gen_size[gen_index] += info->size;
-
- for (i=0; i<MALLOC_INFO_SIZE_SIZE; i++) {
- size_t s = 16 << i;
- if (info->size <= s) {
- malloc_info_size[i]++;
- goto found;
- }
- }
- malloc_info_size[i]++;
- found:;
-
- {
- st_data_t key = (st_data_t)info->file, d;
- size_t *data;
-
- if (malloc_info_file_table == NULL) {
- malloc_info_file_table = st_init_numtable_with_size(1024);
- }
- if (st_lookup(malloc_info_file_table, key, &d)) {
- /* hit */
- data = (size_t *)d;
- }
- else {
- data = malloc(xmalloc2_size(2, sizeof(size_t)));
- if (data == NULL) rb_bug("objspace_xfree: can not allocate memory");
- data[0] = data[1] = 0;
- st_insert(malloc_info_file_table, key, (st_data_t)data);
- }
- data[0] ++;
- data[1] += info->size;
- };
- if (0 && gen >= 2) { /* verbose output */
- if (info->file) {
- fprintf(stderr, "free - size:%"PRIdSIZE", gen:%d, pos: %s:%"PRIdSIZE"\n",
- info->size, gen, info->file, info->line);
- }
- else {
- fprintf(stderr, "free - size:%"PRIdSIZE", gen:%d\n",
- info->size, gen);
- }
- }
- }
-#endif
-#endif
- old_size = objspace_malloc_size(objspace, ptr, old_size);
-
- objspace_malloc_increase(objspace, ptr, 0, old_size, MEMOP_TYPE_FREE) {
- free(ptr);
- ptr = NULL;
- RB_DEBUG_COUNTER_INC(heap_xfree);
- }
-}
-
-static void *
-ruby_xmalloc0(size_t size)
-{
- return objspace_xmalloc0(&rb_objspace, size);
-}
-
-void *
-ruby_xmalloc_body(size_t size)
-{
- if ((ssize_t)size < 0) {
- negative_size_allocation_error("too large allocation size");
- }
- return ruby_xmalloc0(size);
-}
-
-void
-ruby_malloc_size_overflow(size_t count, size_t elsize)
-{
- rb_raise(rb_eArgError,
- "malloc: possible integer overflow (%"PRIuSIZE"*%"PRIuSIZE")",
- count, elsize);
-}
-
-void *
-ruby_xmalloc2_body(size_t n, size_t size)
-{
- return objspace_xmalloc0(&rb_objspace, xmalloc2_size(n, size));
-}
-
-static void *
-objspace_xcalloc(rb_objspace_t *objspace, size_t size)
-{
- if (UNLIKELY(malloc_during_gc_p(objspace))) {
- rb_warn("calloc during GC detected, this could cause crashes if it triggers another GC");
-#if RGENGC_CHECK_MODE || RUBY_DEBUG
- rb_bug("Cannot calloc during GC");
-#endif
- }
-
- void *mem;
-
- size = objspace_malloc_prepare(objspace, size);
- TRY_WITH_GC(size, mem = calloc1(size));
- return objspace_malloc_fixup(objspace, mem, size);
-}
-
-void *
-ruby_xcalloc_body(size_t n, size_t size)
-{
- return objspace_xcalloc(&rb_objspace, xmalloc2_size(n, size));
-}
-
-#ifdef ruby_sized_xrealloc
-#undef ruby_sized_xrealloc
-#endif
-void *
-ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
-{
- if ((ssize_t)new_size < 0) {
- negative_size_allocation_error("too large allocation size");
- }
-
- return objspace_xrealloc(&rb_objspace, ptr, new_size, old_size);
-}
-
-void *
-ruby_xrealloc_body(void *ptr, size_t new_size)
-{
- return ruby_sized_xrealloc(ptr, new_size, 0);
-}
-
-#ifdef ruby_sized_xrealloc2
-#undef ruby_sized_xrealloc2
-#endif
-void *
-ruby_sized_xrealloc2(void *ptr, size_t n, size_t size, size_t old_n)
-{
- size_t len = xmalloc2_size(n, size);
- return objspace_xrealloc(&rb_objspace, ptr, len, old_n * size);
-}
-
-void *
-ruby_xrealloc2_body(void *ptr, size_t n, size_t size)
-{
- return ruby_sized_xrealloc2(ptr, n, size, 0);
-}
-
-#ifdef ruby_sized_xfree
-#undef ruby_sized_xfree
-#endif
-void
-ruby_sized_xfree(void *x, size_t size)
-{
- if (x) {
- objspace_xfree(&rb_objspace, x, size);
- }
-}
-
-void
-ruby_xfree(void *x)
-{
- ruby_sized_xfree(x, 0);
-}
-
-void *
-rb_xmalloc_mul_add(size_t x, size_t y, size_t z) /* x * y + z */
-{
- size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
- return ruby_xmalloc(w);
-}
-
-void *
-rb_xcalloc_mul_add(size_t x, size_t y, size_t z) /* x * y + z */
-{
- size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
- return ruby_xcalloc(w, 1);
-}
-
-void *
-rb_xrealloc_mul_add(const void *p, size_t x, size_t y, size_t z) /* x * y + z */
-{
- size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
- return ruby_xrealloc((void *)p, w);
-}
-
-void *
-rb_xmalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
- return ruby_xmalloc(u);
-}
-
-void *
-rb_xcalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
-{
- size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
- return ruby_xcalloc(u, 1);
-}
-
-/* Mimic ruby_xmalloc, but need not rb_objspace.
- * should return pointer suitable for ruby_xfree
- */
-void *
-ruby_mimmalloc(size_t size)
-{
- void *mem;
-#if CALC_EXACT_MALLOC_SIZE
- size += sizeof(struct malloc_obj_info);
-#endif
- mem = malloc(size);
-#if CALC_EXACT_MALLOC_SIZE
- if (!mem) {
- return NULL;
- }
- else
- /* set 0 for consistency of allocated_size/allocations */
- {
- struct malloc_obj_info *info = mem;
- info->size = 0;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- info->gen = 0;
- info->file = NULL;
- info->line = 0;
-#endif
- mem = info + 1;
- }
-#endif
- return mem;
-}
-
-void
-ruby_mimfree(void *ptr)
-{
-#if CALC_EXACT_MALLOC_SIZE
- struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
- ptr = info;
-#endif
- free(ptr);
-}
-
-void *
-rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
-{
- void *ptr;
- VALUE imemo;
- rb_imemo_tmpbuf_t *tmpbuf;
-
- /* Keep the order; allocate an empty imemo first then xmalloc, to
- * get rid of potential memory leak */
- imemo = rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(NULL, 0);
- *store = imemo;
- ptr = ruby_xmalloc0(size);
- tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
- tmpbuf->ptr = ptr;
- tmpbuf->cnt = cnt;
- return ptr;
-}
-
-void *
-rb_alloc_tmp_buffer(volatile VALUE *store, long len)
-{
- long cnt;
-
- if (len < 0 || (cnt = (long)roomof(len, sizeof(VALUE))) < 0) {
- rb_raise(rb_eArgError, "negative buffer size (or size too big)");
- }
-
- return rb_alloc_tmp_buffer_with_count(store, len, cnt);
-}
-
-void
-rb_free_tmp_buffer(volatile VALUE *store)
-{
- rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
- if (s) {
- void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0);
- s->cnt = 0;
- ruby_xfree(ptr);
- }
-}
-
-#if MALLOC_ALLOCATED_SIZE
-/*
- * call-seq:
- * GC.malloc_allocated_size -> Integer
- *
- * Returns the size of memory allocated by malloc().
- *
- * Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
- */
-
-static VALUE
-gc_malloc_allocated_size(VALUE self)
-{
- return UINT2NUM(rb_objspace.malloc_params.allocated_size);
-}
-
-/*
- * call-seq:
- * GC.malloc_allocations -> Integer
- *
- * Returns the number of malloc() allocations.
- *
- * Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
- */
-
-static VALUE
-gc_malloc_allocations(VALUE self)
-{
- return UINT2NUM(rb_objspace.malloc_params.allocations);
-}
-#endif
-
-void
-rb_gc_adjust_memory_usage(ssize_t diff)
-{
- rb_objspace_t *objspace = &rb_objspace;
- if (diff > 0) {
- objspace_malloc_increase(objspace, 0, diff, 0, MEMOP_TYPE_REALLOC);
- }
- else if (diff < 0) {
- objspace_malloc_increase(objspace, 0, 0, -diff, MEMOP_TYPE_REALLOC);
- }
-}
-
-/*
- ------------------------------ GC profiler ------------------------------
-*/
-
-#define GC_PROFILE_RECORD_DEFAULT_SIZE 100
-
-static bool
-current_process_time(struct timespec *ts)
-{
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
- {
- static int try_clock_gettime = 1;
- if (try_clock_gettime && clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ts) == 0) {
- return true;
- }
- else {
- try_clock_gettime = 0;
- }
- }
-#endif
-
-#ifdef RUSAGE_SELF
- {
- struct rusage usage;
- struct timeval time;
- if (getrusage(RUSAGE_SELF, &usage) == 0) {
- time = usage.ru_utime;
- ts->tv_sec = time.tv_sec;
- ts->tv_nsec = (int32_t)time.tv_usec * 1000;
- return true;
- }
- }
-#endif
-
-#ifdef _WIN32
- {
- FILETIME creation_time, exit_time, kernel_time, user_time;
- ULARGE_INTEGER ui;
-
- if (GetProcessTimes(GetCurrentProcess(),
- &creation_time, &exit_time, &kernel_time, &user_time) != 0) {
- memcpy(&ui, &user_time, sizeof(FILETIME));
-#define PER100NSEC (uint64_t)(1000 * 1000 * 10)
- ts->tv_nsec = (long)(ui.QuadPart % PER100NSEC);
- ts->tv_sec = (time_t)(ui.QuadPart / PER100NSEC);
- return true;
- }
- }
-#endif
-
- return false;
-}
-
-static double
-getrusage_time(void)
-{
- struct timespec ts;
- if (current_process_time(&ts)) {
- return ts.tv_sec + ts.tv_nsec * 1e-9;
- }
- else {
- return 0.0;
- }
-}
-
-
-static inline void
-gc_prof_setup_new_record(rb_objspace_t *objspace, unsigned int reason)
-{
- if (objspace->profile.run) {
- size_t index = objspace->profile.next_index;
- gc_profile_record *record;
-
- /* create new record */
- objspace->profile.next_index++;
-
- if (!objspace->profile.records) {
- objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE;
- objspace->profile.records = malloc(xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
- }
- if (index >= objspace->profile.size) {
- void *ptr;
- objspace->profile.size += 1000;
- ptr = realloc(objspace->profile.records, xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
- if (!ptr) rb_memerror();
- objspace->profile.records = ptr;
- }
- if (!objspace->profile.records) {
- rb_bug("gc_profile malloc or realloc miss");
- }
- record = objspace->profile.current_record = &objspace->profile.records[objspace->profile.next_index - 1];
- MEMZERO(record, gc_profile_record, 1);
-
- /* setup before-GC parameter */
- record->flags = reason | (ruby_gc_stressful ? GPR_FLAG_STRESS : 0);
-#if MALLOC_ALLOCATED_SIZE
- record->allocated_size = malloc_allocated_size;
-#endif
-#if GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY
-#ifdef RUSAGE_SELF
- {
- struct rusage usage;
- if (getrusage(RUSAGE_SELF, &usage) == 0) {
- record->maxrss = usage.ru_maxrss;
- record->minflt = usage.ru_minflt;
- record->majflt = usage.ru_majflt;
- }
- }
-#endif
-#endif
- }
-}
-
-static inline void
-gc_prof_timer_start(rb_objspace_t *objspace)
-{
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
-#if GC_PROFILE_MORE_DETAIL
- record->prepare_time = objspace->profile.prepare_time;
-#endif
- record->gc_time = 0;
- record->gc_invoke_time = getrusage_time();
- }
-}
-
-static double
-elapsed_time_from(double time)
-{
- double now = getrusage_time();
- if (now > time) {
- return now - time;
- }
- else {
- return 0;
- }
-}
-
-static inline void
-gc_prof_timer_stop(rb_objspace_t *objspace)
-{
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->gc_time = elapsed_time_from(record->gc_invoke_time);
- record->gc_invoke_time -= objspace->profile.invoke_time;
- }
-}
-
-#define RUBY_DTRACE_GC_HOOK(name) \
- do {if (RUBY_DTRACE_GC_##name##_ENABLED()) RUBY_DTRACE_GC_##name();} while (0)
-static inline void
-gc_prof_mark_timer_start(rb_objspace_t *objspace)
-{
- RUBY_DTRACE_GC_HOOK(MARK_BEGIN);
-#if GC_PROFILE_MORE_DETAIL
- if (gc_prof_enabled(objspace)) {
- gc_prof_record(objspace)->gc_mark_time = getrusage_time();
- }
-#endif
-}
-
-static inline void
-gc_prof_mark_timer_stop(rb_objspace_t *objspace)
-{
- RUBY_DTRACE_GC_HOOK(MARK_END);
-#if GC_PROFILE_MORE_DETAIL
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->gc_mark_time = elapsed_time_from(record->gc_mark_time);
- }
-#endif
-}
-
-static inline void
-gc_prof_sweep_timer_start(rb_objspace_t *objspace)
-{
- RUBY_DTRACE_GC_HOOK(SWEEP_BEGIN);
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
-
- if (record->gc_time > 0 || GC_PROFILE_MORE_DETAIL) {
- objspace->profile.gc_sweep_start_time = getrusage_time();
- }
- }
-}
-
-static inline void
-gc_prof_sweep_timer_stop(rb_objspace_t *objspace)
-{
- RUBY_DTRACE_GC_HOOK(SWEEP_END);
-
- if (gc_prof_enabled(objspace)) {
- double sweep_time;
- gc_profile_record *record = gc_prof_record(objspace);
-
- if (record->gc_time > 0) {
- sweep_time = elapsed_time_from(objspace->profile.gc_sweep_start_time);
- /* need to accumulate GC time for lazy sweep after gc() */
- record->gc_time += sweep_time;
- }
- else if (GC_PROFILE_MORE_DETAIL) {
- sweep_time = elapsed_time_from(objspace->profile.gc_sweep_start_time);
- }
-
-#if GC_PROFILE_MORE_DETAIL
- record->gc_sweep_time += sweep_time;
- if (heap_pages_deferred_final) record->flags |= GPR_FLAG_HAVE_FINALIZE;
-#endif
- if (heap_pages_deferred_final) objspace->profile.latest_gc_info |= GPR_FLAG_HAVE_FINALIZE;
- }
-}
-
-static inline void
-gc_prof_set_malloc_info(rb_objspace_t *objspace)
-{
-#if GC_PROFILE_MORE_DETAIL
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- record->allocate_increase = malloc_increase;
- record->allocate_limit = malloc_limit;
- }
-#endif
-}
-
-static inline void
-gc_prof_set_heap_info(rb_objspace_t *objspace)
-{
- if (gc_prof_enabled(objspace)) {
- gc_profile_record *record = gc_prof_record(objspace);
- size_t live = objspace->profile.total_allocated_objects_at_gc_start - objspace->profile.total_freed_objects;
- size_t total = objspace->profile.heap_used_at_gc_start * HEAP_PAGE_OBJ_LIMIT;
-
-#if GC_PROFILE_MORE_DETAIL
- record->heap_use_pages = objspace->profile.heap_used_at_gc_start;
- record->heap_live_objects = live;
- record->heap_free_objects = total - live;
-#endif
-
- record->heap_total_objects = total;
- record->heap_use_size = live * sizeof(RVALUE);
- record->heap_total_size = total * sizeof(RVALUE);
- }
-}
-
-/*
- * call-seq:
- * GC::Profiler.clear -> nil
- *
- * Clears the \GC profiler data.
- *
- */
-
-static VALUE
-gc_profile_clear(VALUE _)
-{
- rb_objspace_t *objspace = &rb_objspace;
- void *p = objspace->profile.records;
- objspace->profile.records = NULL;
- objspace->profile.size = 0;
- objspace->profile.next_index = 0;
- objspace->profile.current_record = 0;
- if (p) {
- free(p);
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * GC::Profiler.raw_data -> [Hash, ...]
- *
- * Returns an Array of individual raw profile data Hashes ordered
- * from earliest to latest by +:GC_INVOKE_TIME+.
- *
- * For example:
- *
- * [
- * {
- * :GC_TIME=>1.3000000000000858e-05,
- * :GC_INVOKE_TIME=>0.010634999999999999,
- * :HEAP_USE_SIZE=>289640,
- * :HEAP_TOTAL_SIZE=>588960,
- * :HEAP_TOTAL_OBJECTS=>14724,
- * :GC_IS_MARKED=>false
- * },
- * # ...
- * ]
- *
- * The keys mean:
- *
- * +:GC_TIME+::
- * Time elapsed in seconds for this GC run
- * +:GC_INVOKE_TIME+::
- * Time elapsed in seconds from startup to when the GC was invoked
- * +:HEAP_USE_SIZE+::
- * Total bytes of heap used
- * +:HEAP_TOTAL_SIZE+::
- * Total size of heap in bytes
- * +:HEAP_TOTAL_OBJECTS+::
- * Total number of objects
- * +:GC_IS_MARKED+::
- * Returns +true+ if the GC is in mark phase
- *
- * If ruby was built with +GC_PROFILE_MORE_DETAIL+, you will also have access
- * to the following hash keys:
- *
- * +:GC_MARK_TIME+::
- * +:GC_SWEEP_TIME+::
- * +:ALLOCATE_INCREASE+::
- * +:ALLOCATE_LIMIT+::
- * +:HEAP_USE_PAGES+::
- * +:HEAP_LIVE_OBJECTS+::
- * +:HEAP_FREE_OBJECTS+::
- * +:HAVE_FINALIZE+::
- *
- */
-
-static VALUE
-gc_profile_record_get(VALUE _)
-{
- VALUE prof;
- VALUE gc_profile = rb_ary_new();
- size_t i;
- rb_objspace_t *objspace = (&rb_objspace);
-
- if (!objspace->profile.run) {
- return Qnil;
- }
-
- for (i =0; i < objspace->profile.next_index; i++) {
- gc_profile_record *record = &objspace->profile.records[i];
-
- prof = rb_hash_new();
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(0, rb_hash_new(), record->flags));
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_TIME")), DBL2NUM(record->gc_time));
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_INVOKE_TIME")), DBL2NUM(record->gc_invoke_time));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_SIZE")), SIZET2NUM(record->heap_use_size));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_SIZE")), SIZET2NUM(record->heap_total_size));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_OBJECTS")), SIZET2NUM(record->heap_total_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("MOVED_OBJECTS")), SIZET2NUM(record->moved_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_IS_MARKED")), Qtrue);
-#if GC_PROFILE_MORE_DETAIL
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_MARK_TIME")), DBL2NUM(record->gc_mark_time));
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_SWEEP_TIME")), DBL2NUM(record->gc_sweep_time));
- rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_INCREASE")), SIZET2NUM(record->allocate_increase));
- rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_LIMIT")), SIZET2NUM(record->allocate_limit));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_PAGES")), SIZET2NUM(record->heap_use_pages));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_LIVE_OBJECTS")), SIZET2NUM(record->heap_live_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_FREE_OBJECTS")), SIZET2NUM(record->heap_free_objects));
-
- rb_hash_aset(prof, ID2SYM(rb_intern("REMOVING_OBJECTS")), SIZET2NUM(record->removing_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("EMPTY_OBJECTS")), SIZET2NUM(record->empty_objects));
-
- rb_hash_aset(prof, ID2SYM(rb_intern("HAVE_FINALIZE")), RBOOL(record->flags & GPR_FLAG_HAVE_FINALIZE));
-#endif
-
-#if RGENGC_PROFILE > 0
- rb_hash_aset(prof, ID2SYM(rb_intern("OLD_OBJECTS")), SIZET2NUM(record->old_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_NORMAL_OBJECTS")), SIZET2NUM(record->remembered_normal_objects));
- rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_SHADY_OBJECTS")), SIZET2NUM(record->remembered_shady_objects));
-#endif
- rb_ary_push(gc_profile, prof);
- }
-
- return gc_profile;
-}
-
-#if GC_PROFILE_MORE_DETAIL
-#define MAJOR_REASON_MAX 0x10
-
-static char *
-gc_profile_dump_major_reason(unsigned int flags, char *buff)
-{
- unsigned int reason = flags & GPR_FLAG_MAJOR_MASK;
- int i = 0;
-
- if (reason == GPR_FLAG_NONE) {
- buff[0] = '-';
- buff[1] = 0;
- }
- else {
-#define C(x, s) \
- if (reason & GPR_FLAG_MAJOR_BY_##x) { \
- buff[i++] = #x[0]; \
- if (i >= MAJOR_REASON_MAX) rb_bug("gc_profile_dump_major_reason: overflow"); \
- buff[i] = 0; \
- }
- C(NOFREE, N);
- C(OLDGEN, O);
- C(SHADY, S);
-#if RGENGC_ESTIMATE_OLDMALLOC
- C(OLDMALLOC, M);
-#endif
-#undef C
- }
- return buff;
-}
-#endif
-
-static void
-gc_profile_dump_on(VALUE out, VALUE (*append)(VALUE, VALUE))
-{
- rb_objspace_t *objspace = &rb_objspace;
- size_t count = objspace->profile.next_index;
-#ifdef MAJOR_REASON_MAX
- char reason_str[MAJOR_REASON_MAX];
-#endif
-
- if (objspace->profile.run && count /* > 1 */) {
- size_t i;
- const gc_profile_record *record;
-
- append(out, rb_sprintf("GC %"PRIuSIZE" invokes.\n", objspace->profile.count));
- append(out, rb_str_new_cstr("Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)\n"));
-
- for (i = 0; i < count; i++) {
- record = &objspace->profile.records[i];
- append(out, rb_sprintf("%5"PRIuSIZE" %19.3f %20"PRIuSIZE" %20"PRIuSIZE" %20"PRIuSIZE" %30.20f\n",
- i+1, record->gc_invoke_time, record->heap_use_size,
- record->heap_total_size, record->heap_total_objects, record->gc_time*1000));
- }
-
-#if GC_PROFILE_MORE_DETAIL
- const char *str = "\n\n" \
- "More detail.\n" \
- "Prepare Time = Previously GC's rest sweep time\n"
- "Index Flags Allocate Inc. Allocate Limit"
-#if CALC_EXACT_MALLOC_SIZE
- " Allocated Size"
-#endif
- " Use Page Mark Time(ms) Sweep Time(ms) Prepare Time(ms) LivingObj FreeObj RemovedObj EmptyObj"
-#if RGENGC_PROFILE
- " OldgenObj RemNormObj RemShadObj"
-#endif
-#if GC_PROFILE_DETAIL_MEMORY
- " MaxRSS(KB) MinorFLT MajorFLT"
-#endif
- "\n";
- append(out, rb_str_new_cstr(str));
-
- for (i = 0; i < count; i++) {
- record = &objspace->profile.records[i];
- append(out, rb_sprintf("%5"PRIuSIZE" %4s/%c/%6s%c %13"PRIuSIZE" %15"PRIuSIZE
-#if CALC_EXACT_MALLOC_SIZE
- " %15"PRIuSIZE
-#endif
- " %9"PRIuSIZE" %17.12f %17.12f %17.12f %10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE
-#if RGENGC_PROFILE
- "%10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE
-#endif
-#if GC_PROFILE_DETAIL_MEMORY
- "%11ld %8ld %8ld"
-#endif
-
- "\n",
- i+1,
- gc_profile_dump_major_reason(record->flags, reason_str),
- (record->flags & GPR_FLAG_HAVE_FINALIZE) ? 'F' : '.',
- (record->flags & GPR_FLAG_NEWOBJ) ? "NEWOBJ" :
- (record->flags & GPR_FLAG_MALLOC) ? "MALLOC" :
- (record->flags & GPR_FLAG_METHOD) ? "METHOD" :
- (record->flags & GPR_FLAG_CAPI) ? "CAPI__" : "??????",
- (record->flags & GPR_FLAG_STRESS) ? '!' : ' ',
- record->allocate_increase, record->allocate_limit,
-#if CALC_EXACT_MALLOC_SIZE
- record->allocated_size,
-#endif
- record->heap_use_pages,
- record->gc_mark_time*1000,
- record->gc_sweep_time*1000,
- record->prepare_time*1000,
-
- record->heap_live_objects,
- record->heap_free_objects,
- record->removing_objects,
- record->empty_objects
-#if RGENGC_PROFILE
- ,
- record->old_objects,
- record->remembered_normal_objects,
- record->remembered_shady_objects
-#endif
-#if GC_PROFILE_DETAIL_MEMORY
- ,
- record->maxrss / 1024,
- record->minflt,
- record->majflt
-#endif
-
- ));
- }
-#endif
- }
-}
-
-/*
- * call-seq:
- * GC::Profiler.result -> String
- *
- * Returns a profile data report such as:
- *
- * GC 1 invokes.
- * Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
- * 1 0.012 159240 212940 10647 0.00000000000001530000
- */
-
-static VALUE
-gc_profile_result(VALUE _)
-{
- VALUE str = rb_str_buf_new(0);
- gc_profile_dump_on(str, rb_str_buf_append);
- return str;
-}
-
-/*
- * call-seq:
- * GC::Profiler.report
- * GC::Profiler.report(io)
- *
- * Writes the GC::Profiler.result to <tt>$stdout</tt> or the given IO object.
- *
- */
-
-static VALUE
-gc_profile_report(int argc, VALUE *argv, VALUE self)
-{
- VALUE out;
-
- out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]);
- gc_profile_dump_on(out, rb_io_write);
-
- return Qnil;
-}
-
-/*
- * call-seq:
- * GC::Profiler.total_time -> float
- *
- * The total time used for garbage collection in seconds
- */
-
-static VALUE
-gc_profile_total_time(VALUE self)
-{
- double time = 0;
- rb_objspace_t *objspace = &rb_objspace;
-
- if (objspace->profile.run && objspace->profile.next_index > 0) {
- size_t i;
- size_t count = objspace->profile.next_index;
-
- for (i = 0; i < count; i++) {
- time += objspace->profile.records[i].gc_time;
- }
- }
- return DBL2NUM(time);
-}
-
-/*
- * call-seq:
- * GC::Profiler.enabled? -> true or false
- *
- * The current status of \GC profile mode.
- */
-
-static VALUE
-gc_profile_enable_get(VALUE self)
-{
- rb_objspace_t *objspace = &rb_objspace;
- return RBOOL(objspace->profile.run);
-}
-
-/*
- * call-seq:
- * GC::Profiler.enable -> nil
- *
- * Starts the \GC profiler.
- *
- */
-
-static VALUE
-gc_profile_enable(VALUE _)
-{
- rb_objspace_t *objspace = &rb_objspace;
- objspace->profile.run = TRUE;
- objspace->profile.current_record = 0;
- return Qnil;
-}
-
-/*
- * call-seq:
- * GC::Profiler.disable -> nil
- *
- * Stops the \GC profiler.
- *
- */
-
-static VALUE
-gc_profile_disable(VALUE _)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- objspace->profile.run = FALSE;
- objspace->profile.current_record = 0;
- return Qnil;
+ vm->gc.mark_func_data = &mfd;
+ rb_gc_save_machine_context();
+ rb_gc_mark_roots(vm->gc.objspace, &data.category);
+ vm->gc.mark_func_data = prev_mfd;
}
/*
@@ -13455,7 +4868,7 @@ rb_method_type_name(rb_method_type_t type)
{
switch (type) {
case VM_METHOD_TYPE_ISEQ: return "iseq";
- case VM_METHOD_TYPE_ATTRSET: return "attrest";
+ case VM_METHOD_TYPE_ATTRSET: return "attrset";
case VM_METHOD_TYPE_IVAR: return "ivar";
case VM_METHOD_TYPE_BMETHOD: return "bmethod";
case VM_METHOD_TYPE_ALIAS: return "alias";
@@ -13501,7 +4914,6 @@ str_len_no_raise(VALUE str)
memcpy(buff + pos, (s), rb_strlen_lit(s) + 1); \
} \
} while (0)
-#define TF(c) ((c) != 0 ? "true" : "false")
#define C(c, s) ((c) != 0 ? (s) : " ")
static size_t
@@ -13520,24 +4932,26 @@ rb_raw_obj_info_common(char *const buff, const size_t buff_size, const VALUE obj
}
}
else {
- const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-
- if (is_pointer_to_heap(&rb_objspace, (void *)obj)) {
- APPEND_F("%p [%d%s%s%s%s%s%s] %s ",
- (void *)obj, age,
- C(RVALUE_UNCOLLECTIBLE_BITMAP(obj), "L"),
- C(RVALUE_MARK_BITMAP(obj), "M"),
- C(RVALUE_PIN_BITMAP(obj), "P"),
- C(RVALUE_MARKING_BITMAP(obj), "R"),
- C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
- C(rb_objspace_garbage_object_p(obj), "G"),
- obj_type_name(obj));
+ // const int age = RVALUE_AGE_GET(obj);
+
+ if (rb_gc_impl_pointer_to_heap_p(rb_gc_get_objspace(), (void *)obj)) {
+ APPEND_F("%p %s/", (void *)obj, obj_type_name(obj));
+ // TODO: fixme
+ // APPEND_F("%p [%d%s%s%s%s%s%s] %s ",
+ // (void *)obj, age,
+ // C(RVALUE_UNCOLLECTIBLE_BITMAP(obj), "L"),
+ // C(RVALUE_MARK_BITMAP(obj), "M"),
+ // C(RVALUE_PIN_BITMAP(obj), "P"),
+ // C(RVALUE_MARKING_BITMAP(obj), "R"),
+ // C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
+ // C(rb_objspace_garbage_object_p(obj), "G"),
+ // obj_type_name(obj));
}
else {
/* fake */
- APPEND_F("%p [%dXXXX] %s",
- (void *)obj, age,
- obj_type_name(obj));
+ // APPEND_F("%p [%dXXXX] %s",
+ // (void *)obj, age,
+ // obj_type_name(obj));
}
if (internal_object_p(obj)) {
@@ -13547,21 +4961,19 @@ rb_raw_obj_info_common(char *const buff, const size_t buff_size, const VALUE obj
APPEND_S("(temporary internal)");
}
else if (RTEST(RBASIC(obj)->klass)) {
- VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass);
+ VALUE class_path = rb_mod_name(RBASIC(obj)->klass);
if (!NIL_P(class_path)) {
- APPEND_F("(%s)", RSTRING_PTR(class_path));
+ APPEND_F("%s ", RSTRING_PTR(class_path));
}
}
-
-#if GC_DEBUG
- APPEND_F("@%s:%d", RANY(obj)->file, RANY(obj)->line);
-#endif
}
end:
return pos;
}
+const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
+
static size_t
rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALUE obj, size_t pos)
{
@@ -13577,23 +4989,29 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
APPEND_S("shared -> ");
rb_raw_obj_info(BUFF_ARGS, ARY_SHARED_ROOT(obj));
}
- else if (ARY_EMBED_P(obj)) {
- APPEND_F("[%s%s] len: %ld (embed)",
- C(ARY_EMBED_P(obj), "E"),
- C(ARY_SHARED_P(obj), "S"),
- RARRAY_LEN(obj));
- }
else {
- APPEND_F("[%s%s%s] len: %ld, capa:%ld ptr:%p",
- C(ARY_EMBED_P(obj), "E"),
+ APPEND_F("[%s%s%s] ",
+ C(ARY_EMBED_P(obj), "E"),
C(ARY_SHARED_P(obj), "S"),
- C(RARRAY_TRANSIENT_P(obj), "T"),
- RARRAY_LEN(obj),
- ARY_EMBED_P(obj) ? -1L : RARRAY(obj)->as.heap.aux.capa,
- (void *)RARRAY_CONST_PTR_TRANSIENT(obj));
+ C(ARY_SHARED_ROOT_P(obj), "R"));
+
+ if (ARY_EMBED_P(obj)) {
+ APPEND_F("len: %ld (embed)",
+ RARRAY_LEN(obj));
+ }
+ else {
+ APPEND_F("len: %ld, capa:%ld ptr:%p",
+ RARRAY_LEN(obj),
+ RARRAY(obj)->as.heap.aux.capa,
+ (void *)RARRAY_CONST_PTR(obj));
+ }
}
break;
case T_STRING: {
+ APPEND_F("[%s%s] ",
+ C(FL_TEST(obj, RSTRING_FSTR), "F"),
+ C(RB_OBJ_FROZEN(obj), "R"));
+
if (STR_SHARED_P(obj)) {
APPEND_F(" [shared] len: %ld", RSTRING_LEN(obj));
}
@@ -13617,31 +5035,30 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
break;
}
case T_MOVED: {
- APPEND_F("-> %p", (void*)rb_gc_location(obj));
+ APPEND_F("-> %p", (void*)gc_location_internal(rb_gc_get_objspace(), obj));
break;
}
case T_HASH: {
- APPEND_F("[%c%c] %"PRIdSIZE,
+ APPEND_F("[%c] %"PRIdSIZE,
RHASH_AR_TABLE_P(obj) ? 'A' : 'S',
- RHASH_TRANSIENT_P(obj) ? 'T' : ' ',
RHASH_SIZE(obj));
break;
}
case T_CLASS:
case T_MODULE:
{
- VALUE class_path = rb_class_path_cached(obj);
+ VALUE class_path = rb_mod_name(obj);
if (!NIL_P(class_path)) {
APPEND_F("%s", RSTRING_PTR(class_path));
}
else {
- APPEND_S("(annon)");
+ APPEND_S("(anon)");
}
break;
}
case T_ICLASS:
{
- VALUE class_path = rb_class_path_cached(RBASIC_CLASS(obj));
+ VALUE class_path = rb_mod_name(RBASIC_CLASS(obj));
if (!NIL_P(class_path)) {
APPEND_F("src:%s", RSTRING_PTR(class_path));
}
@@ -13649,14 +5066,17 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
}
case T_OBJECT:
{
- uint32_t len = ROBJECT_IV_CAPACITY(obj);
-
- if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
- APPEND_F("(embed) len:%d", len);
+ if (FL_TEST_RAW(obj, ROBJECT_HEAP)) {
+ if (rb_obj_shape_complex_p(obj)) {
+ size_t hash_len = rb_st_table_size(ROBJECT_FIELDS_HASH(obj));
+ APPEND_F("(complex) len:%zu", hash_len);
+ }
+ else {
+ APPEND_F("(embed) len:%d capa:%d", RSHAPE_LEN(RBASIC_SHAPE_ID(obj)), ROBJECT_FIELDS_CAPACITY(obj));
+ }
}
else {
- VALUE *ptr = ROBJECT_IVPTR(obj);
- APPEND_F("len:%d ptr:%p", len, (void *)ptr);
+ APPEND_F("len:%d capa:%d ptr:%p", RSHAPE_LEN(RBASIC_SHAPE_ID(obj)), ROBJECT_FIELDS_CAPACITY(obj), (void *)ROBJECT_FIELDS(obj));
}
}
break;
@@ -13675,12 +5095,6 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
APPEND_F("r:%d", r->pub.id);
}
}
- else {
- const char * const type_name = rb_objspace_data_type_name(obj);
- if (type_name) {
- APPEND_F("%s", type_name);
- }
- }
break;
}
case T_IMEMO: {
@@ -13689,9 +5103,9 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
switch (imemo_type(obj)) {
case imemo_ment:
{
- const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment;
+ const rb_method_entry_t *me = (const rb_method_entry_t *)obj;
- APPEND_F(":%s (%s%s%s%s) type:%s alias:%d owner:%p defined_class:%p",
+ APPEND_F(":%s (%s%s%s%s) type:%s aliased:%d owner:%p defined_class:%p",
rb_id2name(me->called_id),
METHOD_ENTRY_VISI(me) == METHOD_VISI_PUBLIC ? "pub" :
METHOD_ENTRY_VISI(me) == METHOD_VISI_PRIVATE ? "pri" : "pro",
@@ -13699,7 +5113,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
METHOD_ENTRY_CACHED(me) ? ",cc" : "",
METHOD_ENTRY_INVALIDATED(me) ? ",inv" : "",
me->def ? rb_method_type_name(me->def->type) : "NULL",
- me->def ? me->def->alias_count : -1,
+ me->def ? me->def->aliased : -1,
(void *)me->owner, // obj_info(me->owner),
(void *)me->defined_class); //obj_info(me->defined_class)));
@@ -13735,15 +5149,15 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
case imemo_callcache:
{
const struct rb_callcache *cc = (const struct rb_callcache *)obj;
- VALUE class_path = cc->klass ? rb_class_path_cached(cc->klass) : Qnil;
+ VALUE class_path = vm_cc_valid(cc) ? rb_mod_name(cc->klass) : Qnil;
const rb_callable_method_entry_t *cme = vm_cc_cme(cc);
APPEND_F("(klass:%s cme:%s%s (%p) call:%p",
- NIL_P(class_path) ? (cc->klass ? "??" : "<NULL>") : RSTRING_PTR(class_path),
+ NIL_P(class_path) ? (vm_cc_valid(cc) ? "??" : "<NULL>") : RSTRING_PTR(class_path),
cme ? rb_id2name(cme->called_id) : "<NULL>",
cme ? (METHOD_ENTRY_INVALIDATED(cme) ? " [inv]" : "") : "",
(void *)cme,
- (void *)vm_cc_call(cc));
+ (void *)(uintptr_t)vm_cc_call(cc));
break;
}
default:
@@ -13759,18 +5173,60 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
return pos;
}
-#undef TF
#undef C
+#ifdef RUBY_ASAN_ENABLED
+void
+rb_asan_poison_object(VALUE obj)
+{
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
+ asan_poison_memory_region(ptr, rb_gc_obj_slot_size(obj));
+}
+
+void
+rb_asan_unpoison_object(VALUE obj, bool newobj_p)
+{
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
+ asan_unpoison_memory_region(ptr, rb_gc_obj_slot_size(obj), newobj_p);
+}
+
+void *
+rb_asan_poisoned_object_p(VALUE obj)
+{
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
+ return __asan_region_is_poisoned(ptr, rb_gc_obj_slot_size(obj));
+}
+#endif
+
+static void
+raw_obj_info(char *const buff, const size_t buff_size, VALUE obj)
+{
+ size_t pos = rb_raw_obj_info_common(buff, buff_size, obj);
+ pos = rb_raw_obj_info_buitin_type(buff, buff_size, obj, pos);
+ if (pos >= buff_size) {} // truncated
+}
+
const char *
rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj)
{
- asan_unpoisoning_object(obj) {
- size_t pos = rb_raw_obj_info_common(buff, buff_size, obj);
- pos = rb_raw_obj_info_buitin_type(buff, buff_size, obj, pos);
- if (pos >= buff_size) {} // truncated
- }
+ void *objspace = rb_gc_get_objspace();
+ if (SPECIAL_CONST_P(obj)) {
+ raw_obj_info(buff, buff_size, obj);
+ }
+ else if (!rb_gc_impl_pointer_to_heap_p(objspace, (const void *)obj)) {
+ snprintf(buff, buff_size, "out-of-heap:%p", (void *)obj);
+ }
+#if 0 // maybe no need to check it?
+ else if (0 && rb_gc_impl_garbage_object_p(objspace, obj)) {
+ snprintf(buff, buff_size, "garbage:%p", (void *)obj);
+ }
+#endif
+ else {
+ asan_unpoisoning_object(obj) {
+ raw_obj_info(buff, buff_size, obj);
+ }
+ }
return buff;
}
@@ -13778,19 +5234,13 @@ rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj)
#undef APPEND_F
#undef BUFF_ARGS
-#if RGENGC_OBJ_INFO
-#define OBJ_INFO_BUFFERS_NUM 10
-#define OBJ_INFO_BUFFERS_SIZE 0x100
-static rb_atomic_t obj_info_buffers_index = 0;
-static char obj_info_buffers[OBJ_INFO_BUFFERS_NUM][OBJ_INFO_BUFFERS_SIZE];
-
/* Increments *var atomically and resets *var to 0 when maxval is
* reached. Returns the wraparound old *var value (0...maxval). */
static rb_atomic_t
atomic_inc_wraparound(rb_atomic_t *var, const rb_atomic_t maxval)
{
rb_atomic_t oldval = RUBY_ATOMIC_FETCH_ADD(*var, 1);
- if (UNLIKELY(oldval >= maxval - 1)) { // wraparound *var
+ if (RB_UNLIKELY(oldval >= maxval - 1)) { // wraparound *var
const rb_atomic_t newval = oldval + 1;
RUBY_ATOMIC_CAS(*var, newval, newval % maxval);
oldval %= maxval;
@@ -13801,137 +5251,501 @@ atomic_inc_wraparound(rb_atomic_t *var, const rb_atomic_t maxval)
static const char *
obj_info(VALUE obj)
{
- rb_atomic_t index = atomic_inc_wraparound(&obj_info_buffers_index, OBJ_INFO_BUFFERS_NUM);
- char *const buff = obj_info_buffers[index];
- return rb_raw_obj_info(buff, OBJ_INFO_BUFFERS_SIZE, obj);
+ if (RGENGC_OBJ_INFO) {
+ static struct {
+ rb_atomic_t index;
+ char buffers[10][0x100];
+ } info = {0};
+
+ rb_atomic_t index = atomic_inc_wraparound(&info.index, numberof(info.buffers));
+ char *const buff = info.buffers[index];
+ return rb_raw_obj_info(buff, sizeof(info.buffers[0]), obj);
+ }
+ return obj_type_name(obj);
}
-#else
-static const char *
-obj_info(VALUE obj)
+
+/*
+ ------------------------ Extended allocator ------------------------
+*/
+
+struct gc_raise_tag {
+ VALUE exc;
+ const char *fmt;
+ va_list *ap;
+};
+
+static void *
+gc_vraise(void *ptr)
{
- return obj_type_name(obj);
+ struct gc_raise_tag *argv = ptr;
+ rb_vraise(argv->exc, argv->fmt, *argv->ap);
+ UNREACHABLE_RETURN(NULL);
}
-#endif
-const char *
-rb_obj_info(VALUE obj)
+static void
+gc_raise(VALUE exc, const char *fmt, ...)
{
- return obj_info(obj);
+ va_list ap;
+ va_start(ap, fmt);
+ struct gc_raise_tag argv = {
+ exc, fmt, &ap,
+ };
+
+ if (ruby_native_thread_p()) {
+ rb_thread_call_with_gvl(gc_vraise, &argv);
+ UNREACHABLE;
+ }
+ else {
+ /* Not in a ruby thread */
+ fprintf(stderr, "%s", "[FATAL] ");
+ vfprintf(stderr, fmt, ap);
+ }
+
+ va_end(ap);
+ abort();
}
-void
-rb_obj_info_dump(VALUE obj)
+NORETURN(static void negative_size_allocation_error(const char *));
+static void
+negative_size_allocation_error(const char *msg)
{
- char buff[0x100];
- fprintf(stderr, "rb_obj_info_dump: %s\n", rb_raw_obj_info(buff, 0x100, obj));
+ gc_raise(rb_eNoMemError, "%s", msg);
}
-void
-rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func)
+static void *
+ruby_memerror_body(void *dummy)
{
- char buff[0x100];
- fprintf(stderr, "<OBJ_INFO:%s@%s:%d> %s\n", func, file, line, rb_raw_obj_info(buff, 0x100, obj));
+ rb_memerror();
+ return 0;
}
-#if GC_DEBUG
+NORETURN(static void ruby_memerror(void));
+RBIMPL_ATTR_MAYBE_UNUSED()
+static void
+ruby_memerror(void)
+{
+ if (ruby_thread_has_gvl_p()) {
+ rb_memerror();
+ }
+ else {
+ if (ruby_native_thread_p()) {
+ rb_thread_call_with_gvl(ruby_memerror_body, 0);
+ }
+ else {
+ /* no ruby thread */
+ fprintf(stderr, "[FATAL] failed to allocate memory\n");
+ }
+ }
+
+ /* We have discussions whether we should die here; */
+ /* We might rethink about it later. */
+ exit(EXIT_FAILURE);
+}
void
-rb_gcdebug_print_obj_condition(VALUE obj)
+rb_memerror(void)
{
- rb_objspace_t *objspace = &rb_objspace;
+ /* the `GET_VM()->special_exceptions` below assumes that
+ * the VM is reachable from the current thread. We should
+ * definitely make sure of that. */
+ RUBY_ASSERT_ALWAYS(ruby_thread_has_gvl_p());
- fprintf(stderr, "created at: %s:%d\n", RANY(obj)->file, RANY(obj)->line);
+ rb_execution_context_t *ec = GET_EC();
+ VALUE exc = GET_VM()->special_exceptions[ruby_error_nomemory];
- if (BUILTIN_TYPE(obj) == T_MOVED) {
- fprintf(stderr, "moved?: true\n");
- }
- else {
- fprintf(stderr, "moved?: false\n");
+ if (!exc ||
+ rb_ec_raised_p(ec, RAISED_NOMEMORY) ||
+ rb_ec_vm_lock_rec(ec) != ec->tag->lock_rec) {
+ fprintf(stderr, "[FATAL] failed to allocate memory\n");
+ exit(EXIT_FAILURE);
}
- if (is_pointer_to_heap(objspace, (void *)obj)) {
- fprintf(stderr, "pointer to heap?: true\n");
+ if (rb_ec_raised_p(ec, RAISED_NOMEMORY)) {
+ rb_ec_raised_clear(ec);
}
else {
- fprintf(stderr, "pointer to heap?: false\n");
- return;
+ rb_ec_raised_set(ec, RAISED_NOMEMORY);
+ exc = ruby_vm_special_exception_copy(exc);
}
+ ec->errinfo = exc;
+ EC_JUMP_TAG(ec, TAG_RAISE);
+}
- fprintf(stderr, "marked? : %s\n", MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) ? "true" : "false");
- fprintf(stderr, "pinned? : %s\n", MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj) ? "true" : "false");
- fprintf(stderr, "age? : %d\n", RVALUE_AGE(obj));
- fprintf(stderr, "old? : %s\n", RVALUE_OLD_P(obj) ? "true" : "false");
- fprintf(stderr, "WB-protected?: %s\n", RVALUE_WB_UNPROTECTED(obj) ? "false" : "true");
- fprintf(stderr, "remembered? : %s\n", RVALUE_REMEMBERED(obj) ? "true" : "false");
+bool
+rb_memerror_reentered(void)
+{
+ rb_execution_context_t *ec = GET_EC();
+ return (ec && rb_ec_raised_p(ec, RAISED_NOMEMORY));
+}
- if (is_lazy_sweeping(objspace)) {
- fprintf(stderr, "lazy sweeping?: true\n");
- fprintf(stderr, "swept?: %s\n", is_swept_object(objspace, obj) ? "done" : "not yet");
+static void *
+handle_malloc_failure(void *ptr)
+{
+ if (LIKELY(ptr)) {
+ return ptr;
}
else {
- fprintf(stderr, "lazy sweeping?: false\n");
+ ruby_memerror();
+ UNREACHABLE_RETURN(ptr);
}
}
-static VALUE
-gcdebug_sentinel(RB_BLOCK_CALL_FUNC_ARGLIST(obj, name))
+static void *ruby_xmalloc_body(size_t size);
+
+void *
+ruby_xmalloc(size_t size)
{
- fprintf(stderr, "WARNING: object %s(%p) is inadvertently collected\n", (char *)name, (void *)obj);
- return Qnil;
+ return handle_malloc_failure(ruby_xmalloc_body(size));
+}
+
+static bool
+malloc_gc_allowed(void)
+{
+ rb_ractor_t *r = rb_current_ractor_raw(false);
+
+ return r == NULL || !r->malloc_gc_disabled;
+}
+
+static void *
+ruby_xmalloc_body(size_t size)
+{
+ if ((ssize_t)size < 0) {
+ negative_size_allocation_error("too large allocation size");
+ }
+
+ return rb_gc_impl_malloc(rb_gc_get_objspace(), size, malloc_gc_allowed());
}
void
-rb_gcdebug_sentinel(VALUE obj, const char *name)
+ruby_malloc_size_overflow(size_t count, size_t elsize)
{
- rb_define_finalizer(obj, rb_proc_new(gcdebug_sentinel, (VALUE)name));
+ rb_raise(rb_eArgError,
+ "malloc: possible integer overflow (%"PRIuSIZE"*%"PRIuSIZE")",
+ count, elsize);
}
-#endif /* GC_DEBUG */
+void
+ruby_malloc_add_size_overflow(size_t x, size_t y)
+{
+ rb_raise(rb_eArgError,
+ "malloc: possible integer overflow (%"PRIuSIZE"+%"PRIuSIZE")",
+ x, y);
+}
-#if GC_DEBUG_STRESS_TO_CLASS
-/*
- * call-seq:
- * GC.add_stress_to_class(class[, ...])
- *
- * Raises NoMemoryError when allocating an instance of the given classes.
- *
- */
-static VALUE
-rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
+static void *ruby_xmalloc2_body(size_t n, size_t size);
+
+void *
+ruby_xmalloc2(size_t n, size_t size)
{
- rb_objspace_t *objspace = &rb_objspace;
+ return handle_malloc_failure(ruby_xmalloc2_body(n, size));
+}
- if (!stress_to_class) {
- stress_to_class = rb_ary_hidden_new(argc);
+static void *
+ruby_xmalloc2_body(size_t n, size_t size)
+{
+ return rb_gc_impl_malloc(rb_gc_get_objspace(), xmalloc2_size(n, size), malloc_gc_allowed());
+}
+
+static void *ruby_xcalloc_body(size_t n, size_t size);
+
+void *
+ruby_xcalloc(size_t n, size_t size)
+{
+ return handle_malloc_failure(ruby_xcalloc_body(n, size));
+}
+
+static void *
+ruby_xcalloc_body(size_t n, size_t size)
+{
+ return rb_gc_impl_calloc(rb_gc_get_objspace(), xmalloc2_size(n, size), malloc_gc_allowed());
+}
+
+static void *ruby_xrealloc_sized_body(void *ptr, size_t new_size, size_t old_size);
+
+#ifdef ruby_xrealloc_sized
+#undef ruby_xrealloc_sized
+#endif
+void *
+ruby_xrealloc_sized(void *ptr, size_t new_size, size_t old_size)
+{
+ return handle_malloc_failure(ruby_xrealloc_sized_body(ptr, new_size, old_size));
+}
+
+static void *
+ruby_xrealloc_sized_body(void *ptr, size_t new_size, size_t old_size)
+{
+ if ((ssize_t)new_size < 0) {
+ negative_size_allocation_error("too large allocation size");
}
- rb_ary_cat(stress_to_class, argv, argc);
- return self;
+
+ return rb_gc_impl_realloc(rb_gc_get_objspace(), ptr, new_size, old_size, malloc_gc_allowed());
}
-/*
- * call-seq:
- * GC.remove_stress_to_class(class[, ...])
- *
- * No longer raises NoMemoryError when allocating an instance of the
- * given classes.
- *
- */
-static VALUE
-rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
+void *
+ruby_xrealloc(void *ptr, size_t new_size)
+{
+ return ruby_xrealloc_sized(ptr, new_size, 0);
+}
+
+static void *ruby_xrealloc2_sized_body(void *ptr, size_t n, size_t size, size_t old_n);
+
+#ifdef ruby_xrealloc2_sized
+#undef ruby_xrealloc2_sized
+#endif
+void *
+ruby_xrealloc2_sized(void *ptr, size_t n, size_t size, size_t old_n)
+{
+ return handle_malloc_failure(ruby_xrealloc2_sized_body(ptr, n, size, old_n));
+}
+
+static void *
+ruby_xrealloc2_sized_body(void *ptr, size_t n, size_t size, size_t old_n)
{
- rb_objspace_t *objspace = &rb_objspace;
- int i;
+ size_t len = xmalloc2_size(n, size);
+ return rb_gc_impl_realloc(rb_gc_get_objspace(), ptr, len, old_n * size, malloc_gc_allowed());
+}
- if (stress_to_class) {
- for (i = 0; i < argc; ++i) {
- rb_ary_delete_same(stress_to_class, argv[i]);
+void *
+ruby_xrealloc2(void *ptr, size_t n, size_t size)
+{
+ return ruby_xrealloc2_sized(ptr, n, size, 0);
+}
+
+#ifdef ruby_xfree_sized
+#undef ruby_xfree_sized
+#endif
+void
+ruby_xfree_sized(void *x, size_t size)
+{
+ if (LIKELY(x)) {
+ /* It's possible for a C extension's pthread destructor function set by pthread_key_create
+ * to be called after ruby_vm_destruct and attempt to free memory. Fall back to mimfree in
+ * that case. */
+ if (LIKELY(GET_VM())) {
+ rb_gc_impl_free(rb_gc_get_objspace(), x, size);
}
- if (RARRAY_LEN(stress_to_class) == 0) {
- stress_to_class = 0;
+ else {
+ ruby_mimfree(x);
}
}
- return Qnil;
}
+
+void
+ruby_xfree(void *x)
+{
+ ruby_xfree_sized(x, 0);
+}
+
+void *
+rb_xmalloc_mul_add(size_t x, size_t y, size_t z) /* x * y + z */
+{
+ size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
+ return ruby_xmalloc(w);
+}
+
+void *
+rb_xcalloc_mul_add(size_t x, size_t y, size_t z) /* x * y + z */
+{
+ size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
+ return ruby_xcalloc(w, 1);
+}
+
+void *
+rb_xrealloc_mul_add(const void *p, size_t x, size_t y, size_t z) /* x * y + z */
+{
+ size_t w = size_mul_add_or_raise(x, y, z, rb_eArgError);
+ return ruby_xrealloc((void *)p, w);
+}
+
+void *
+rb_xmalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
+{
+ size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
+ return ruby_xmalloc(u);
+}
+
+void *
+rb_xcalloc_mul_add_mul(size_t x, size_t y, size_t z, size_t w) /* x * y + z * w */
+{
+ size_t u = size_mul_add_mul_or_raise(x, y, z, w, rb_eArgError);
+ return ruby_xcalloc(u, 1);
+}
+
+/* Mimic ruby_xmalloc, but need not rb_objspace.
+ * should return pointer suitable for ruby_xfree
+ */
+void *
+ruby_mimmalloc(size_t size)
+{
+ void *mem;
+#if CALC_EXACT_MALLOC_SIZE
+ size += sizeof(struct malloc_obj_info);
+#endif
+ mem = malloc(size);
+#if CALC_EXACT_MALLOC_SIZE
+ if (!mem) {
+ return NULL;
+ }
+ else
+ /* set 0 for consistency of allocated_size/allocations */
+ {
+ struct malloc_obj_info *info = mem;
+ info->size = 0;
+ mem = info + 1;
+ }
+#endif
+ return mem;
+}
+
+void *
+ruby_mimcalloc(size_t num, size_t size)
+{
+ void *mem;
+#if CALC_EXACT_MALLOC_SIZE
+ struct rbimpl_size_overflow_tag t = rbimpl_size_mul_overflow(num, size);
+ if (UNLIKELY(t.overflowed)) {
+ return NULL;
+ }
+ size = t.result + sizeof(struct malloc_obj_info);
+ mem = calloc1(size);
+ if (!mem) {
+ return NULL;
+ }
+ else
+ /* set 0 for consistency of allocated_size/allocations */
+ {
+ struct malloc_obj_info *info = mem;
+ info->size = 0;
+ mem = info + 1;
+ }
+#else
+ mem = calloc(num, size);
+#endif
+ return mem;
+}
+
+void
+ruby_mimfree(void *ptr)
+{
+#if CALC_EXACT_MALLOC_SIZE
+ struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
+ ptr = info;
#endif
+ free(ptr);
+}
+
+void
+rb_gc_adjust_memory_usage(ssize_t diff)
+{
+ unless_objspace(objspace) { return; }
+
+ rb_gc_impl_adjust_memory_usage(objspace, diff);
+}
+
+const char *
+rb_obj_info(VALUE obj)
+{
+ return obj_info(obj);
+}
+
+void
+rb_obj_info_dump(VALUE obj)
+{
+ char buff[0x100];
+ fprintf(stderr, "rb_obj_info_dump: %s\n", rb_raw_obj_info(buff, 0x100, obj));
+}
+
+void
+rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func)
+{
+ char buff[0x100];
+ fprintf(stderr, "<OBJ_INFO:%s@%s:%d> %s\n", func, file, line, rb_raw_obj_info(buff, 0x100, obj));
+}
+
+void
+rb_gc_before_fork(void)
+{
+ rb_gc_impl_before_fork(rb_gc_get_objspace());
+}
+
+void
+rb_gc_after_fork(rb_pid_t pid)
+{
+ rb_gc_impl_after_fork(rb_gc_get_objspace(), pid);
+}
+
+bool
+rb_gc_obj_shareable_p(VALUE obj)
+{
+ return RB_OBJ_SHAREABLE_P(obj);
+}
+
+void
+rb_gc_rp(VALUE obj)
+{
+ rp(obj);
+}
+
+struct check_shareable_data {
+ VALUE parent;
+ long err_count;
+};
+
+static void
+check_shareable_i(const VALUE child, void *ptr)
+{
+ struct check_shareable_data *data = (struct check_shareable_data *)ptr;
+
+ if (!rb_gc_obj_shareable_p(child)) {
+ fprintf(stderr, "(a) ");
+ rb_gc_rp(data->parent);
+ fprintf(stderr, "(b) ");
+ rb_gc_rp(child);
+ fprintf(stderr, "check_shareable_i: shareable (a) -> unshareable (b)\n");
+
+ data->err_count++;
+ rb_bug("!! violate shareable constraint !!");
+ }
+}
+
+static bool gc_checking_shareable = false;
+
+static void
+gc_verify_shareable(void *objspace, VALUE obj, void *data)
+{
+ // while gc_checking_shareable is true,
+ // other Ractors should not run the GC, until the flag is not local.
+ // TODO: remove VM locking if the flag is Ractor local
+
+ unsigned int lev = RB_GC_VM_LOCK();
+ {
+ gc_checking_shareable = true;
+ rb_objspace_reachable_objects_from(obj, check_shareable_i, (void *)data);
+ gc_checking_shareable = false;
+ }
+ RB_GC_VM_UNLOCK(lev);
+}
+
+// TODO: only one level (non-recursive)
+void
+rb_gc_verify_shareable(VALUE obj)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ struct check_shareable_data data = {
+ .parent = obj,
+ .err_count = 0,
+ };
+ gc_verify_shareable(objspace, obj, &data);
+
+ if (data.err_count > 0) {
+ rb_bug("rb_gc_verify_shareable");
+ }
+}
+
+bool
+rb_gc_checking_shareable(void)
+{
+ return gc_checking_shareable;
+}
/*
* Document-module: ObjectSpace
@@ -13941,10 +5755,9 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
* traverse all living objects with an iterator.
*
* ObjectSpace also provides support for object finalizers, procs that will be
- * called when a specific object is about to be destroyed by garbage
- * collection. See the documentation for
- * <code>ObjectSpace.define_finalizer</code> for important information on
- * how to use this method correctly.
+ * called after a specific object was destroyed by garbage collection. See
+ * the documentation for +ObjectSpace.define_finalizer+ for important
+ * information on how to use this method correctly.
*
* a = "A"
* b = "B"
@@ -13980,61 +5793,18 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
*/
#include "gc.rbinc"
-/*
- * call-seq:
- * GC.using_rvargc? -> true or false
- *
- * Returns true if using experimental feature Variable Width Allocation, false
- * otherwise.
- */
-static VALUE
-gc_using_rvargc_p(VALUE mod)
-{
-#if USE_RVARGC
- return Qtrue;
-#else
- return Qfalse;
-#endif
-}
void
Init_GC(void)
{
#undef rb_intern
- VALUE rb_mObjSpace;
- VALUE rb_mProfiler;
- VALUE gc_constants;
+ rb_gc_register_address(&id2ref_value);
+
+ malloc_offset = gc_compute_malloc_offset();
rb_mGC = rb_define_module("GC");
- gc_constants = rb_hash_new();
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), RBOOL(GC_DEBUG));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("BASE_SLOT_SIZE")), SIZET2NUM(BASE_SLOT_SIZE - RVALUE_OVERHEAD));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), SIZET2NUM(RVALUE_OVERHEAD));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(RVALUE)));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_OBJ_LIMIT")), SIZET2NUM(HEAP_PAGE_OBJ_LIMIT));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_SIZE")), SIZET2NUM(HEAP_PAGE_SIZE));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("SIZE_POOL_COUNT")), LONG2FIX(SIZE_POOL_COUNT));
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(size_pool_slot_size(SIZE_POOL_COUNT - 1)));
- if (RB_BUG_INSTEAD_OF_RB_MEMERROR+0) {
- rb_hash_aset(gc_constants, ID2SYM(rb_intern("RB_BUG_INSTEAD_OF_RB_MEMERROR")), Qtrue);
- }
- OBJ_FREEZE(gc_constants);
- /* internal constants */
- rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
-
- rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
- rb_define_singleton_method(rb_mProfiler, "enabled?", gc_profile_enable_get, 0);
- rb_define_singleton_method(rb_mProfiler, "enable", gc_profile_enable, 0);
- rb_define_singleton_method(rb_mProfiler, "raw_data", gc_profile_record_get, 0);
- rb_define_singleton_method(rb_mProfiler, "disable", gc_profile_disable, 0);
- rb_define_singleton_method(rb_mProfiler, "clear", gc_profile_clear, 0);
- rb_define_singleton_method(rb_mProfiler, "result", gc_profile_result, 0);
- rb_define_singleton_method(rb_mProfiler, "report", gc_profile_report, -1);
- rb_define_singleton_method(rb_mProfiler, "total_time", gc_profile_total_time, 0);
-
- rb_mObjSpace = rb_define_module("ObjectSpace");
+ VALUE rb_mObjSpace = rb_define_module("ObjectSpace");
rb_define_module_function(rb_mObjSpace, "each_object", os_each_obj, -1);
@@ -14050,121 +5820,38 @@ Init_GC(void)
rb_define_module_function(rb_mObjSpace, "count_objects", count_objects, -1);
- /* internal methods */
- rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency_m, 0);
- rb_define_singleton_method(rb_mGC, "verify_transient_heap_internal_consistency", gc_verify_transient_heap_internal_consistency, 0);
-#if MALLOC_ALLOCATED_SIZE
- rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
- rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
-#endif
-
- rb_define_singleton_method(rb_mGC, "using_rvargc?", gc_using_rvargc_p, 0);
-
- if (GC_COMPACTION_SUPPORTED) {
- rb_define_singleton_method(rb_mGC, "compact", gc_compact, 0);
- rb_define_singleton_method(rb_mGC, "auto_compact", gc_get_auto_compact, 0);
- rb_define_singleton_method(rb_mGC, "auto_compact=", gc_set_auto_compact, 1);
- rb_define_singleton_method(rb_mGC, "latest_compact_info", gc_compact_stats, 0);
- }
- else {
- rb_define_singleton_method(rb_mGC, "compact", rb_f_notimplement, 0);
- rb_define_singleton_method(rb_mGC, "auto_compact", rb_f_notimplement, 0);
- rb_define_singleton_method(rb_mGC, "auto_compact=", rb_f_notimplement, 1);
- rb_define_singleton_method(rb_mGC, "latest_compact_info", rb_f_notimplement, 0);
- /* When !GC_COMPACTION_SUPPORTED, this method is not defined in gc.rb */
- rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
- }
-
-#if GC_DEBUG_STRESS_TO_CLASS
- rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
- rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
-#endif
-
- {
- VALUE opts;
- /* \GC build options */
- rb_define_const(rb_mGC, "OPTS", opts = rb_ary_new());
-#define OPT(o) if (o) rb_ary_push(opts, rb_fstring_lit(#o))
- OPT(GC_DEBUG);
- OPT(USE_RGENGC);
- OPT(RGENGC_DEBUG);
- OPT(RGENGC_CHECK_MODE);
- OPT(RGENGC_PROFILE);
- OPT(RGENGC_ESTIMATE_OLDMALLOC);
- OPT(GC_PROFILE_MORE_DETAIL);
- OPT(GC_ENABLE_LAZY_SWEEP);
- OPT(CALC_EXACT_MALLOC_SIZE);
- OPT(MALLOC_ALLOCATED_SIZE);
- OPT(MALLOC_ALLOCATED_SIZE_CHECK);
- OPT(GC_PROFILE_DETAIL_MEMORY);
- OPT(GC_COMPACTION_SUPPORTED);
-#undef OPT
- OBJ_FREEZE(opts);
- }
-}
-
-#ifdef ruby_xmalloc
-#undef ruby_xmalloc
-#endif
-#ifdef ruby_xmalloc2
-#undef ruby_xmalloc2
-#endif
-#ifdef ruby_xcalloc
-#undef ruby_xcalloc
-#endif
-#ifdef ruby_xrealloc
-#undef ruby_xrealloc
-#endif
-#ifdef ruby_xrealloc2
-#undef ruby_xrealloc2
-#endif
-
-void *
-ruby_xmalloc(size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xmalloc_body(size);
-}
-
-void *
-ruby_xmalloc2(size_t n, size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xmalloc2_body(n, size);
-}
-
-void *
-ruby_xcalloc(size_t n, size_t size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xcalloc_body(n, size);
-}
-
-void *
-ruby_xrealloc(void *ptr, size_t new_size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
-#endif
- return ruby_xrealloc_body(ptr, new_size);
-}
-
-void *
-ruby_xrealloc2(void *ptr, size_t n, size_t new_size)
-{
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
- ruby_malloc_info_file = __FILE__;
- ruby_malloc_info_line = __LINE__;
+ rb_gc_impl_init();
+}
+
+// Set a name for the anonymous virtual memory area. `addr` is the starting
+// address of the area and `size` is its length in bytes. `name` is a
+// NUL-terminated human-readable string.
+//
+// This function is usually called after calling `mmap()`. The human-readable
+// annotation helps developers identify the call site of `mmap()` that created
+// the memory mapping.
+//
+// This function currently only works on Linux 5.17 or higher. After calling
+// this function, we can see annotations in the form of "[anon:...]" in
+// `/proc/self/maps`, where `...` is the content of `name`. This function has
+// no effect when called on other platforms.
+void
+ruby_annotate_mmap(const void *addr, unsigned long size, const char *name)
+{
+#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
+ // The name length cannot exceed 80 (including the '\0').
+ RUBY_ASSERT(strlen(name) < 80);
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);
+ // We ignore errors in prctl. prctl may set errno to EINVAL for several
+ // reasons.
+ // 1. The attr (PR_SET_VMA_ANON_NAME) is not a valid attribute.
+ // 2. addr is an invalid address.
+ // 3. The string pointed by name is too long.
+ // The first error indicates PR_SET_VMA_ANON_NAME is not available, and may
+ // happen if we run the compiled binary on an old kernel. In theory, all
+ // other errors should result in a failure. But since EINVAL cannot tell
+ // the first error from others, and this function is mainly used for
+ // debugging, we silently ignore the error.
+ errno = 0;
#endif
- return ruby_xrealloc2_body(ptr, n, new_size);
}
diff --git a/gc.rb b/gc.rb
index dd4fb6c274..48bed27880 100644
--- a/gc.rb
+++ b/gc.rb
@@ -1,293 +1,605 @@
# for gc.c
-# The GC module provides an interface to Ruby's mark and
-# sweep garbage collection mechanism.
+# The \GC module provides an interface to Ruby's mark-and-sweep garbage collection mechanism.
#
-# Some of the underlying methods are also available via the ObjectSpace
-# module.
+# Some of the underlying methods are also available via the ObjectSpace module.
#
-# You may obtain information about the operation of the \GC through
-# GC::Profiler.
+# You may obtain information about the operation of the \GC through GC::Profiler.
module GC
- # call-seq:
- # GC.start -> nil
- # ObjectSpace.garbage_collect -> nil
- # include GC; garbage_collect -> nil
- # GC.start(full_mark: true, immediate_sweep: true) -> nil
- # ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) -> nil
- # include GC; garbage_collect(full_mark: true, immediate_sweep: true) -> nil
+ # Initiates garbage collection, even if explicitly disabled by GC.disable.
#
- # Initiates garbage collection, even if manually disabled.
+ # Keyword arguments:
#
- # This method is defined with keyword arguments that default to true:
+ # - +full_mark+:
+ # its boolean value determines whether to perform a major garbage collection cycle:
#
- # def GC.start(full_mark: true, immediate_sweep: true); end
+ # - +true+: initiates a major garbage collection cycle,
+ # meaning all objects (old and new) are marked.
+ # - +false+: initiates a minor garbage collection cycle,
+ # meaning only young objects are marked.
#
- # Use full_mark: false to perform a minor \GC.
- # Use immediate_sweep: false to defer sweeping (use lazy sweep).
+ # - +immediate_mark+:
+ # its boolean value determines whether to perform incremental marking:
#
- # Note: These keyword arguments are implementation and version dependent. They
- # are not guaranteed to be future-compatible, and may be ignored if the
- # underlying implementation does not support them.
+ # - +true+: marking is completed before the method returns.
+ # - +false+: marking is performed by parts,
+ # interleaved with program execution both before the method returns and afterward;
+ # therefore marking may not be completed before the return.
+ # Note that if +full_mark+ is +false+, marking will always be immediate,
+ # regardless of the value of +immediate_mark+.
+ #
+ # - +immediate_sweep+:
+ # its boolean value determines whether to defer sweeping (using lazy sweep):
+ #
+ # - +true+: sweeping is completed before the method returns.
+ # - +false+: sweeping is performed by parts,
+ # interleaved with program execution both before the method returns and afterward;
+ # therefore sweeping may not be completed before the return.
+ #
+ # Note that these keyword arguments are implementation- and version-dependent,
+ # are not guaranteed to be future-compatible,
+ # and may be ignored in some implementations.
def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
+ # Alias of GC.start
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
- # call-seq:
- # GC.enable -> true or false
+ # call-seq:
+ # GC.enable -> true or false
#
- # Enables garbage collection, returning +true+ if garbage
- # collection was previously disabled.
+ # Enables garbage collection;
+ # returns whether garbage collection was disabled:
#
- # GC.disable #=> false
- # GC.enable #=> true
- # GC.enable #=> false
+ # GC.disable
+ # GC.enable # => true
+ # GC.enable # => false
#
def self.enable
Primitive.gc_enable
end
- # call-seq:
- # GC.disable -> true or false
+ # call-seq:
+ # GC.disable -> true or false
+ #
+ # Disables garbage collection (but GC.start remains potent):
+ # returns whether garbage collection was already disabled.
#
- # Disables garbage collection, returning +true+ if garbage
- # collection was already disabled.
+ # GC.enable
+ # GC.disable # => false
+ # GC.disable # => true
#
- # GC.disable #=> false
- # GC.disable #=> true
def self.disable
Primitive.gc_disable
end
- # call-seq:
- # GC.stress -> integer, true or false
+ # call-seq:
+ # GC.stress -> setting
#
- # Returns current status of \GC stress mode.
+ # Returns the current \GC stress-mode setting,
+ # which initially is +false+.
+ #
+ # The stress mode may be set by method GC.stress=.
def self.stress
Primitive.gc_stress_get
end
- # call-seq:
- # GC.stress = flag -> flag
+ # call-seq:
+ # GC.stress = value -> value
+ #
+ # Enables or disables stress mode;
+ # enabling stress mode will degrade performance; it is only for debugging.
#
- # Updates the \GC stress mode.
+ # Sets the current \GC stress mode to the given value:
#
- # When stress mode is enabled, the \GC is invoked at every \GC opportunity:
- # all memory and object allocations.
+ # - If the value is +nil+ or +false+, disables stress mode.
+ # - If the value is an integer,
+ # enables stress mode with certain flags; see below.
+ # - Otherwise, enables stress mode;
+ # \GC is invoked at every \GC opportunity: all memory and object allocations.
#
- # Enabling stress mode will degrade performance, it is only for debugging.
+ # The flags are bits in the given integer:
+ #
+ # - +0x01+: No major \GC.
+ # - +0x02+: No immediate sweep.
+ # - +0x04+: Full mark after malloc/calloc/realloc.
#
- # flag can be true, false, or an integer bit-ORed following flags.
- # 0x01:: no major GC
- # 0x02:: no immediate sweep
- # 0x04:: full mark after malloc/calloc/realloc
def self.stress=(flag)
Primitive.gc_stress_set_m flag
end
- # call-seq:
- # GC.count -> Integer
+ # call-seq:
+ # self.count -> integer
+ #
+ # Returns the total number of times garbage collection has occurred:
#
- # The number of times \GC occurred.
+ # GC.count # => 385
+ # GC.start
+ # GC.count # => 386
#
- # It returns the number of times \GC occurred since the process started.
def self.count
Primitive.gc_count
end
- # call-seq:
- # GC.stat -> Hash
- # GC.stat(hash) -> Hash
- # GC.stat(:key) -> Numeric
- #
- # Returns a Hash containing information about the \GC.
- #
- # The contents of the hash are implementation specific and may change in
- # the future without notice.
- #
- # The hash includes information about internal statistics about \GC such as:
- #
- # [count]
- # The total number of garbage collections ran since application start
- # (count includes both minor and major garbage collections)
- # [time]
- # The total time spent in garbage collections (in milliseconds)
- # [heap_allocated_pages]
- # The total number of +:heap_eden_pages+ + +:heap_tomb_pages+
- # [heap_sorted_length]
- # The number of pages that can fit into the buffer that holds references to
- # all pages
- # [heap_allocatable_pages]
- # The total number of pages the application could allocate without additional \GC
- # [heap_available_slots]
- # The total number of slots in all +:heap_allocated_pages+
- # [heap_live_slots]
- # The total number of slots which contain live objects
- # [heap_free_slots]
- # The total number of slots which do not contain live objects
- # [heap_final_slots]
- # The total number of slots with pending finalizers to be run
- # [heap_marked_slots]
- # The total number of objects marked in the last \GC
- # [heap_eden_pages]
- # The total number of pages which contain at least one live slot
- # [heap_tomb_pages]
- # The total number of pages which do not contain any live slots
- # [total_allocated_pages]
- # The cumulative number of pages allocated since application start
- # [total_freed_pages]
- # The cumulative number of pages freed since application start
- # [total_allocated_objects]
- # The cumulative number of objects allocated since application start
- # [total_freed_objects]
- # The cumulative number of objects freed since application start
- # [malloc_increase_bytes]
- # Amount of memory allocated on the heap for objects. Decreased by any \GC
- # [malloc_increase_bytes_limit]
- # When +:malloc_increase_bytes+ crosses this limit, \GC is triggered
- # [minor_gc_count]
- # The total number of minor garbage collections run since process start
- # [major_gc_count]
- # The total number of major garbage collections run since process start
- # [compact_count]
- # The total number of compactions run since process start
- # [read_barrier_faults]
- # The total number of times the read barrier was triggered during
- # compaction
- # [total_moved_objects]
- # The total number of objects compaction has moved
- # [remembered_wb_unprotected_objects]
- # The total number of objects without write barriers
- # [remembered_wb_unprotected_objects_limit]
- # When +:remembered_wb_unprotected_objects+ crosses this limit,
- # major \GC is triggered
- # [old_objects]
- # Number of live, old objects which have survived at least 3 garbage collections
- # [old_objects_limit]
- # When +:old_objects+ crosses this limit, major \GC is triggered
- # [oldmalloc_increase_bytes]
- # Amount of memory allocated on the heap for objects. Decreased by major \GC
- # [oldmalloc_increase_bytes_limit]
- # When +:old_malloc_increase_bytes+ crosses this limit, major \GC is triggered
- #
- # If the optional argument, hash, is given,
- # it is overwritten and returned.
- # This is intended to avoid probe effect.
- #
- # This method is only expected to work on CRuby.
+ # call-seq:
+ # GC.stat -> new_hash
+ # GC.stat(key) -> value
+ # GC.stat(hash) -> hash
+ #
+ # This method is implementation-specific to CRuby.
+ #
+ # Returns \GC statistics.
+ # The particular statistics are implementation-specific
+ # and may change in the future without notice.
+ #
+ # With no argument given,
+ # returns information about the most recent garbage collection:
+ #
+ # GC.stat
+ # # =>
+ # {count: 28,
+ # time: 1,
+ # marking_time: 1,
+ # sweeping_time: 0,
+ # heap_allocated_pages: 521,
+ # heap_empty_pages: 0,
+ # heap_allocatable_bytes: 0,
+ # heap_available_slots: 539590,
+ # heap_live_slots: 422243,
+ # heap_free_slots: 117347,
+ # heap_final_slots: 0,
+ # heap_marked_slots: 264877,
+ # heap_eden_pages: 521,
+ # total_allocated_pages: 521,
+ # total_freed_pages: 0,
+ # total_allocated_objects: 2246376,
+ # total_freed_objects: 1824133,
+ # malloc_increase_bytes: 50982,
+ # malloc_increase_bytes_limit: 18535172,
+ # minor_gc_count: 18,
+ # major_gc_count: 10,
+ # compact_count: 0,
+ # read_barrier_faults: 0,
+ # total_moved_objects: 0,
+ # remembered_wb_unprotected_objects: 0,
+ # remembered_wb_unprotected_objects_limit: 2162,
+ # old_objects: 216365,
+ # old_objects_limit: 432540,
+ # oldmalloc_increase_bytes: 1654232,
+ # oldmalloc_increase_bytes_limit: 16846103}
+ #
+ # With symbol argument +key+ given,
+ # returns the value for that key:
+ #
+ # GC.stat(:count) # => 30
+ #
+ # With hash argument +hash+ given,
+ # returns that hash with GC statistics merged into its content;
+ # this form may be useful in minimizing {probe effects}[https://en.wikipedia.org/wiki/Probe_effect]:
+ #
+ # h = {foo: 0, bar: 1}
+ # GC.stat(h)
+ # h.keys.take(5) # => [:foo, :bar, :count, :time, :marking_time]
+ #
+ # The hash includes entries such as:
+ #
+ # - +:count+:
+ # The total number of garbage collections run since application start
+ # (count includes both minor and major garbage collections).
+ # - +:time+:
+ # The total time spent in garbage collections (in milliseconds).
+ # - +:heap_allocated_pages+:
+ # The total number of allocated pages.
+ # - +:heap_empty_pages+:
+ # The number of pages with no live objects, and that could be released to the system.
+ # - +:heap_sorted_length+:
+ # The number of pages that can fit into the buffer that holds references to all pages.
+ # - +:heap_allocatable_pages+:
+ # The total number of pages the application could allocate without additional \GC.
+ # - +:heap_available_slots+:
+ # The total number of slots in all +:heap_allocated_pages+.
+ # - +:heap_live_slots+:
+ # The total number of slots which contain live objects.
+ # - +:heap_free_slots+:
+ # The total number of slots which do not contain live objects.
+ # - +:heap_final_slots+:
+ # The total number of slots with pending finalizers to be run.
+ # - +:heap_marked_slots+:
+ # The total number of objects marked in the last \GC.
+ # - +:heap_eden_pages+:
+ # The total number of pages which contain at least one live slot.
+ # - +:total_allocated_pages+:
+ # The cumulative number of pages allocated since application start.
+ # - +:total_freed_pages+:
+ # The cumulative number of pages freed since application start.
+ # - +:total_allocated_objects+:
+ # The cumulative number of objects allocated since application start.
+ # - +:total_freed_objects+:
+ # The cumulative number of objects freed since application start.
+ # - +:malloc_increase_bytes+:
+ # Amount of memory allocated on the heap for objects. Decreased by any \GC.
+ # - +:malloc_increase_bytes_limit+:
+ # When +:malloc_increase_bytes+ crosses this limit, \GC is triggered.
+ # - +:minor_gc_count+:
+ # The total number of minor garbage collections run since process start.
+ # - +:major_gc_count+:
+ # The total number of major garbage collections run since process start.
+ # - +:compact_count+:
+ # The total number of compactions run since process start.
+ # - +:read_barrier_faults+:
+ # The total number of times the read barrier was triggered during compaction.
+ # - +:total_moved_objects+:
+ # The total number of objects compaction has moved.
+ # - +:remembered_wb_unprotected_objects+:
+ # The total number of objects without write barriers.
+ # - +:remembered_wb_unprotected_objects_limit+:
+ # When +:remembered_wb_unprotected_objects+ crosses this limit, major \GC is triggered.
+ # - +:old_objects+:
+ # Number of live, old objects which have survived at least 3 garbage collections.
+ # - +:old_objects_limit+:
+ # When +:old_objects+ crosses this limit, major \GC is triggered.
+ # - +:oldmalloc_increase_bytes+:
+ # Amount of memory allocated on the heap for objects. Decreased by major \GC.
+ # - +:oldmalloc_increase_bytes_limit+:
+ # When +:oldmalloc_increase_bytes+ crosses this limit, major \GC is triggered.
+ #
def self.stat hash_or_key = nil
Primitive.gc_stat hash_or_key
end
# call-seq:
- # GC.stat_heap -> Hash
- # GC.stat_heap(nil, hash) -> Hash
- # GC.stat_heap(heap_name) -> Hash
- # GC.stat_heap(heap_name, hash) -> Hash
- # GC.stat_heap(heap_name, :key) -> Numeric
+ # GC.stat_heap -> new_hash
+ # GC.stat_heap(heap_id) -> new_hash
+ # GC.stat_heap(heap_id, key) -> value
+ # GC.stat_heap(nil, hash) -> hash
+ # GC.stat_heap(heap_id, hash) -> hash
+ #
+ # This method is implementation-specific to CRuby.
+ #
+ # Returns statistics for \GC heaps.
+ # The particular statistics are implementation-specific
+ # and may change in the future without notice.
+ #
+ # With no argument given, returns statistics for all heaps:
+ #
+ # GC.stat_heap
+ # # =>
+ # {0 =>
+ # {slot_size: 32,
+ # heap_eden_pages: 24,
+ # heap_eden_slots: 12288,
+ # total_allocated_pages: 24,
+ # force_major_gc_count: 0,
+ # force_incremental_marking_finish_count: 0,
+ # total_allocated_objects: 8450,
+ # total_freed_objects: 3120},
+ # 1 =>
+ # {slot_size: 64,
+ # heap_eden_pages: 246,
+ # heap_eden_slots: 402802,
+ # total_allocated_pages: 246,
+ # force_major_gc_count: 2,
+ # force_incremental_marking_finish_count: 1,
+ # total_allocated_objects: 33867152,
+ # total_freed_objects: 33520523},
+ # 2 =>
+ # {slot_size: 128,
+ # heap_eden_pages: 84,
+ # heap_eden_slots: 68746,
+ # total_allocated_pages: 84,
+ # force_major_gc_count: 1,
+ # force_incremental_marking_finish_count: 4,
+ # total_allocated_objects: 147491,
+ # total_freed_objects: 90699},
+ # 3 =>
+ # {slot_size: 256,
+ # heap_eden_pages: 157,
+ # heap_eden_slots: 64182,
+ # total_allocated_pages: 157,
+ # force_major_gc_count: 0,
+ # force_incremental_marking_finish_count: 0,
+ # total_allocated_objects: 211460,
+ # total_freed_objects: 190075},
+ # 4 =>
+ # {slot_size: 512,
+ # heap_eden_pages: 8,
+ # heap_eden_slots: 1631,
+ # total_allocated_pages: 8,
+ # force_major_gc_count: 0,
+ # force_incremental_marking_finish_count: 0,
+ # total_allocated_objects: 1422,
+ # total_freed_objects: 700},
+ # 5 =>
+ # {slot_size: 1024,
+ # heap_eden_pages: 16,
+ # heap_eden_slots: 1628,
+ # total_allocated_pages: 16,
+ # force_major_gc_count: 0,
+ # force_incremental_marking_finish_count: 0,
+ # total_allocated_objects: 1230,
+ # total_freed_objects: 309}}
+ #
+ # In the example above, the keys in the outer hash are the heap identifiers:
+ #
+ # GC.stat_heap.keys # => [0, 1, 2, 3, 4, 5]
+ #
+ # On CRuby, each heap identifier is an integer;
+ # on other implementations, a heap identifier may be a string.
+ #
+ # With only argument +heap_id+ given,
+ # returns statistics for the given heap identifier:
+ #
+ # GC.stat_heap(3)
+ # # =>
+ # {slot_size: 256,
+ # heap_eden_pages: 157,
+ # heap_eden_slots: 64182,
+ # total_allocated_pages: 157,
+ # force_major_gc_count: 0,
+ # force_incremental_marking_finish_count: 0,
+ # total_allocated_objects: 225018,
+ # total_freed_objects: 206647}
+ #
+ # With arguments +heap_id+ and +key+ given,
+ # returns the value for the given key in the given heap:
+ #
+ # GC.stat_heap(3, :slot_size) # => 256
+ #
+ # With arguments +nil+ and +hash+ given,
+ # merges the statistics for all heaps into the given hash:
+ #
+ # h = {foo: 0, bar: 1}
+ # GC.stat_heap(nil, h).keys # => [:foo, :bar, 0, 1, 2, 3, 4]
+ #
+ # With arguments +heap_id+ and +hash+ given,
+ # merges the statistics for the given heap into the given hash:
+ #
+ # h = {foo: 0, bar: 1}
+ # GC.stat_heap(2, h).keys
+ # # =>
+ # [:foo,
+ # :bar,
+ # :slot_size,
+ # :heap_eden_pages,
+ # :heap_eden_slots,
+ # :total_allocated_pages,
+ # :force_major_gc_count,
+ # :force_incremental_marking_finish_count,
+ # :total_allocated_objects,
+ # :total_freed_objects]
+ #
+ # The statistics for a heap may include:
+ #
+ # - +:slot_size+:
+ # The slot size of the heap in bytes.
+ # - +:heap_allocatable_pages+:
+ # The number of pages that can be allocated without triggering a new
+ # garbage collection cycle.
+ # - +:heap_eden_pages+:
+ # The number of pages in the eden heap.
+ # - +:heap_eden_slots+:
+ # The total number of slots in all of the pages in the eden heap.
+ # - +:total_allocated_pages+:
+ # The total number of pages that have been allocated in the heap.
+ # - +:total_freed_pages+:
+ # The total number of pages that have been freed and released back to the
+ # system in the heap.
+ # - +:force_major_gc_count+:
+ # The number of times this heap has forced major garbage collection cycles
+ # to start due to running out of free slots.
+ # - +:force_incremental_marking_finish_count+:
+ # The number of times this heap has forced incremental marking to complete
+ # due to running out of pooled slots.
#
- # Returns information for memory pools in the \GC.
+ def self.stat_heap heap_name = nil, hash_or_key = nil
+ Primitive.gc_stat_heap heap_name, hash_or_key
+ end
+
+ # call-seq:
+ # GC.config -> hash
+ # GC.config(hash_to_merge) -> hash
#
- # If the first optional argument, +heap_name+, is passed in and not +nil+, it
- # returns a +Hash+ containing information about the particular memory pool.
- # Otherwise, it will return a +Hash+ with memory pool names as keys and
- # a +Hash+ containing information about the memory pool as values.
+ # This method is implementation-specific to CRuby.
#
- # If the second optional argument, +hash_or_key+, is given as +Hash+, it will
- # be overwritten and returned. This is intended to avoid the probe effect.
+ # Sets or gets information about the current \GC configuration.
#
- # If both optional arguments are passed in and the second optional argument is
- # a symbol, it will return a +Numeric+ of the value for the particular memory
- # pool.
+ # Configuration parameters are \GC implementation-specific and may change without notice.
#
- # On CRuby, +heap_name+ is of the type +Integer+ but may be of type +String+
- # on other implementations.
+ # With no argument given, returns a hash containing the configuration:
#
- # The contents of the hash are implementation specific and may change in
- # the future without notice.
+ # GC.config
+ # # => {rgengc_allow_full_mark: true, implementation: "default"}
#
- # If the optional argument, hash, is given, it is overwritten and returned.
+ # With argument +hash_to_merge+ given,
+ # merges that hash into the stored configuration hash;
+ # ignores unknown hash keys;
+ # returns the configuration hash:
#
- # This method is only expected to work on CRuby.
- def self.stat_heap heap_name = nil, hash_or_key = nil
- Primitive.gc_stat_heap heap_name, hash_or_key
+ # GC.config(rgengc_allow_full_mark: false)
+ # # => {rgengc_allow_full_mark: false, implementation: "default"}
+ # GC.config(foo: 'bar')
+ # # => {rgengc_allow_full_mark: false, implementation: "default"}
+ #
+ # <b>All-Implementations Configuration</b>
+ #
+ # The single read-only entry for all implementations is:
+ #
+ # - +:implementation+:
+ # the string name of the implementation;
+ # for the Ruby default implementation, <tt>'default'</tt>.
+ #
+ # <b>Implementation-Specific Configuration</b>
+ #
+ # A \GC implementation maintains its own implementation-specific configuration.
+ #
+ # For Ruby's default implementation the single entry is:
+ #
+ # - +:rgengc_allow_full_mark+:
+ # Controls whether the \GC is allowed to run a full mark (young & old objects):
+ #
+ # - +true+ (default): \GC interleaves major and minor collections.
+ # A flag is set to notify GC that a full mark has been requested.
+ # This flag is accessible via GC.latest_gc_info(:need_major_by).
+ # - +false+: \GC does not initiate a full marking cycle unless explicitly directed by user code;
+ # see GC.start.
+ # Setting this parameter to +false+ disables young-to-old promotion.
+ # For performance reasons, we recommended warming up the application using Process.warmup
+ # before setting this parameter to +false+.
+ #
+ def self.config hash = nil
+ if Primitive.cexpr!("RBOOL(RB_TYPE_P(hash, T_HASH))")
+ if hash.include?(:implementation)
+ raise ArgumentError, 'Attempting to set read-only key "Implementation"'
+ end
+
+ Primitive.gc_config_set hash
+ elsif hash != nil
+ raise ArgumentError
+ end
+
+ Primitive.gc_config_get
end
# call-seq:
- # GC.latest_gc_info -> hash
- # GC.latest_gc_info(hash) -> hash
- # GC.latest_gc_info(:major_by) -> :malloc
- #
- # Returns information about the most recent garbage collection.
+ # GC.latest_gc_info -> new_hash
+ # GC.latest_gc_info(key) -> value
+ # GC.latest_gc_info(hash) -> hash
+ #
+ # With no argument given,
+ # returns information about the most recent garbage collection:
+ #
+ # GC.latest_gc_info
+ # # =>
+ # {major_by: :force,
+ # need_major_by: nil,
+ # gc_by: :method,
+ # have_finalizer: false,
+ # immediate_sweep: true,
+ # state: :none,
+ # weak_references_count: 0,
+ # retained_weak_references_count: 0}
+ #
+ # With symbol argument +key+ given,
+ # returns the value for that key:
+ #
+ # GC.latest_gc_info(:gc_by) # => :newobj
+ #
+ # With hash argument +hash+ given,
+ # returns that hash with GC information merged into its content;
+ # this form may be useful in minimizing {probe effects}[https://en.wikipedia.org/wiki/Probe_effect]:
+ #
+ # h = {foo: 0, bar: 1}
+ # GC.latest_gc_info(h)
+ # # =>
+ # {foo: 0,
+ # bar: 1,
+ # major_by: nil,
+ # need_major_by: nil,
+ # gc_by: :newobj,
+ # have_finalizer: false,
+ # immediate_sweep: false,
+ # state: :sweeping,
+ # weak_references_count: 0,
+ # retained_weak_references_count: 0}
#
- # If the optional argument, hash, is given,
- # it is overwritten and returned.
- # This is intended to avoid probe effect.
def self.latest_gc_info hash_or_key = nil
- Primitive.gc_latest_gc_info hash_or_key
- end
-
- if respond_to?(:compact)
- # call-seq:
- # GC.verify_compaction_references(toward: nil, double_heap: false) -> hash
- #
- # Verify compaction reference consistency.
- #
- # This method is implementation specific. During compaction, objects that
- # were moved are replaced with T_MOVED objects. No object should have a
- # reference to a T_MOVED object after compaction.
- #
- # This function expands the heap to ensure room to move all objects,
- # compacts the heap to make sure everything moves, updates all references,
- # then performs a full \GC. If any object contains a reference to a T_MOVED
- # object, that object should be pushed on the mark stack, and will
- # make a SEGV.
- def self.verify_compaction_references(toward: nil, double_heap: false, expand_heap: false)
- Primitive.gc_verify_compaction_references(double_heap, expand_heap, toward == :empty)
+ if hash_or_key == nil
+ hash_or_key = {}
+ elsif Primitive.cexpr!("RBOOL(!SYMBOL_P(hash_or_key) && !RB_TYPE_P(hash_or_key, T_HASH))")
+ raise TypeError, "non-hash or symbol given"
end
+
+ Primitive.cstmt! %{
+ return rb_gc_latest_gc_info(hash_or_key);
+ }
end
# call-seq:
- # GC.measure_total_time = true/false
+ # GC.measure_total_time = setting -> setting
+ #
+ # Enables or disables \GC total time measurement;
+ # returns +setting+.
+ # See GC.total_time.
+ #
+ # When argument +object+ is +nil+ or +false+, disables total time measurement;
+ # GC.measure_total_time then returns +false+:
+ #
+ # GC.measure_total_time = nil # => nil
+ # GC.measure_total_time # => false
+ # GC.measure_total_time = false # => false
+ # GC.measure_total_time # => false
+ #
+ # Otherwise, enables total time measurement;
+ # GC.measure_total_time then returns +true+:
+ #
+ # GC.measure_total_time = true # => true
+ # GC.measure_total_time # => true
+ # GC.measure_total_time = :foo # => :foo
+ # GC.measure_total_time # => true
#
- # Enable to measure \GC time.
- # You can get the result with <tt>GC.stat(:time)</tt>.
- # Note that \GC time measurement can cause some performance overhead.
+ # Note that when enabled, total time measurement affects performance.
def self.measure_total_time=(flag)
Primitive.cstmt! %{
- rb_objspace.flags.measure_gc = RTEST(flag) ? TRUE : FALSE;
+ rb_gc_impl_set_measure_total_time(rb_gc_get_objspace(), flag);
return flag;
}
end
# call-seq:
- # GC.measure_total_time -> true/false
+ # GC.measure_total_time -> true or false
#
- # Return measure_total_time flag (default: +true+).
- # Note that measurement can affect the application performance.
+ # Returns the setting for \GC total time measurement;
+ # the initial setting is +true+.
+ # See GC.total_time.
def self.measure_total_time
Primitive.cexpr! %{
- RBOOL(rb_objspace.flags.measure_gc)
+ RBOOL(rb_gc_impl_get_measure_total_time(rb_gc_get_objspace()))
}
end
# call-seq:
- # GC.total_time -> int
+ # GC.total_time -> integer
+ #
+ # Returns the \GC total time in nanoseconds:
+ #
+ # GC.total_time # => 156250
+ #
+ # Note that total time accumulates
+ # only when total time measurement is enabled
+ # (that is, when GC.measure_total_time is +true+):
+ #
+ # GC.measure_total_time # => true
+ # GC.total_time # => 625000
+ # GC.start
+ # GC.total_time # => 937500
+ # GC.start
+ # GC.total_time # => 1093750
+ #
+ # GC.measure_total_time = false
+ # GC.total_time # => 1250000
+ # GC.start
+ # GC.total_time # => 1250000
+ # GC.start
+ # GC.total_time # => 1250000
+ #
+ # GC.measure_total_time = true
+ # GC.total_time # => 1250000
+ # GC.start
+ # GC.total_time # => 1406250
#
- # Return measured \GC total time in nano seconds.
def self.total_time
Primitive.cexpr! %{
- ULL2NUM(rb_objspace.profile.marking_time_ns + rb_objspace.profile.sweeping_time_ns)
+ ULL2NUM(rb_gc_impl_get_total_time(rb_gc_get_objspace()))
}
end
end
module ObjectSpace
+ # Alias of GC.start
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
diff --git a/gc/README.md b/gc/README.md
new file mode 100644
index 0000000000..cb71357973
--- /dev/null
+++ b/gc/README.md
@@ -0,0 +1,37 @@
+# Ruby's Garbage Collectors
+
+This directory contains implementations for Ruby's garbage collector (GC). The GC implementations use the Modular GC API to interact with Ruby. For more details about this API, see the [Modular GC API](#modular-gc-api) section.
+
+Two GC implementations are included in Ruby:
+
+- Default: The GC implementation that is used by default in Ruby. This GC is stable and production ready. The implementation uses a mark-sweep-compact algorithm.
+- MMTk: An experimental implementation using the [MMTk](https://www.mmtk.io/) framework. The code lives in the [ruby/mmtk](https://github.com/ruby/mmtk) repository and is synchronized here. MMTk provides a [wide variety of GC algorithms](https://www.mmtk.io/status#implemented-collectors) to choose from. For usage instructions and current progress, refer to the [ruby/mmtk](https://github.com/ruby/mmtk) repository.
+
+## Building guide
+
+> [!TIP]
+> If you are not sure how to build Ruby, follow the [Building Ruby](https://docs.ruby-lang.org/en/master/contributing/building_ruby_md.html) guide.
+
+> [!IMPORTANT]
+> Ruby's modular GC feature is experimental and subject to change. There may be bugs or performance impacts. Use at your own risk.
+
+### Building Ruby with Modular GC
+
+1. Configure Ruby with the `--with-modular-gc=<dir>` option, where `dir` is the directory you want to place the built GC libraries into.
+2. Build Ruby as usual.
+
+### Building GC implementations shipped with Ruby
+
+1. Build your desired GC implementation with `make install-modular-gc MODULAR_GC=<impl>`. This will build the GC implementation and place the built library into the `dir` specified in step 1. `impl` can be one of:
+ - `default`: The default GC that Ruby ships with.
+ - `mmtk`: The GC that uses [MMTk](https://www.mmtk.io/) as the back-end. See Ruby-specific details in the [ruby/mmtk](https://github.com/ruby/mmtk) repository.
+2. Run your desired GC implementation by setting the `RUBY_GC_LIBRARY=<lib>` environment variable, where `lib` could be `default`, `mmtk`, or your own implementation (as long as you place it in the `dir` specified in step 1).
+
+## Modular GC API
+
+> [!WARNING]
+> The Modular GC API is experimental and subject to change without notice.
+
+GC implementations interact with Ruby via the Modular GC API. All implementations must provide the functions in [gc/gc_impl.h](https://github.com/ruby/ruby/blob/master/gc/gc_impl.h) for Ruby to hook into. GC implementations can use any public C API in Ruby, along with additional APIs defined in [gc/gc.h](https://github.com/ruby/ruby/blob/master/gc/gc.h).
+
+Additionally, create an extconf.rb file to build the GC library. This file must use [gc/extconf_base.rb](https://github.com/ruby/ruby/blob/master/gc/extconf_base.rb) and the `create_gc_makefile` method.
diff --git a/gc/default/default.c b/gc/default/default.c
new file mode 100644
index 0000000000..145140dfbf
--- /dev/null
+++ b/gc/default/default.c
@@ -0,0 +1,9834 @@
+#include "ruby/internal/config.h"
+
+#include <signal.h>
+
+#ifndef _WIN32
+# include <sys/mman.h>
+# include <unistd.h>
+# ifdef HAVE_SYS_PRCTL_H
+# include <sys/prctl.h>
+# endif
+#endif
+
+#if !defined(PAGE_SIZE) && defined(HAVE_SYS_USER_H)
+/* LIST_HEAD conflicts with sys/queue.h on macOS */
+# include <sys/user.h>
+#endif
+
+#ifdef BUILDING_MODULAR_GC
+# define nlz_int64(x) (x == 0 ? 64 : (unsigned int)__builtin_clzll((unsigned long long)x))
+#else
+# include "internal/bits.h"
+#endif
+
+#include "ruby/ruby.h"
+#include "ruby/atomic.h"
+#include "ruby_atomic.h"
+#include "ruby/debug.h"
+#include "ruby/thread.h"
+#include "ruby/util.h"
+#include "ruby/vm.h"
+#include "ruby/internal/encoding/string.h"
+#include "ccan/list/list.h"
+#include "darray.h"
+#include "gc/gc.h"
+#include "gc/gc_impl.h"
+
+#ifndef BUILDING_MODULAR_GC
+# include "probes.h"
+#endif
+
+#ifdef BUILDING_MODULAR_GC
+# define RB_DEBUG_COUNTER_INC(_name) ((void)0)
+# define RB_DEBUG_COUNTER_INC_IF(_name, cond) (!!(cond))
+#else
+# include "debug_counter.h"
+#endif
+
+#ifdef BUILDING_MODULAR_GC
+# define rb_asan_poison_object(obj) ((void)(obj))
+# define rb_asan_unpoison_object(obj, newobj_p) ((void)(obj), (void)(newobj_p))
+# define asan_unpoisoning_object(obj) if ((obj) || true)
+# define asan_poison_memory_region(ptr, size) ((void)(ptr), (void)(size))
+# define asan_unpoison_memory_region(ptr, size, malloc_p) ((void)(ptr), (size), (malloc_p))
+# define asan_unpoisoning_memory_region(ptr, size) if ((ptr) || (size) || true)
+
+# define VALGRIND_MAKE_MEM_DEFINED(ptr, size) ((void)(ptr), (void)(size))
+# define VALGRIND_MAKE_MEM_UNDEFINED(ptr, size) ((void)(ptr), (void)(size))
+#else
+# include "internal/sanitizers.h"
+#endif
+
+/* MALLOC_HEADERS_BEGIN */
+#ifndef HAVE_MALLOC_USABLE_SIZE
+# ifdef _WIN32
+# define HAVE_MALLOC_USABLE_SIZE
+# define malloc_usable_size(a) _msize(a)
+# elif defined HAVE_MALLOC_SIZE
+# define HAVE_MALLOC_USABLE_SIZE
+# define malloc_usable_size(a) malloc_size(a)
+# endif
+#endif
+
+#ifdef HAVE_MALLOC_USABLE_SIZE
+# ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
+/* Alternative malloc header is included in ruby/missing.h */
+# elif defined(HAVE_MALLOC_H)
+# include <malloc.h>
+# elif defined(HAVE_MALLOC_NP_H)
+# include <malloc_np.h>
+# elif defined(HAVE_MALLOC_MALLOC_H)
+# include <malloc/malloc.h>
+# endif
+#endif
+
+#ifdef HAVE_MALLOC_TRIM
+# include <malloc.h>
+
+# ifdef __EMSCRIPTEN__
+/* malloc_trim is defined in emscripten/emmalloc.h on emscripten. */
+# include <emscripten/emmalloc.h>
+# endif
+#endif
+
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+# include <mach/task.h>
+# include <mach/mach_init.h>
+# include <mach/mach_port.h>
+#endif
+
+#ifndef RUBY_DEBUG_LOG
+# define RUBY_DEBUG_LOG(...)
+#endif
+
+#ifndef GC_HEAP_INIT_BYTES
+#define GC_HEAP_INIT_BYTES (2560 * 1024)
+#endif
+#ifndef GC_HEAP_FREE_SLOTS
+#define GC_HEAP_FREE_SLOTS 4096
+#endif
+#ifndef GC_HEAP_GROWTH_FACTOR
+#define GC_HEAP_GROWTH_FACTOR 1.8
+#endif
+#ifndef GC_HEAP_GROWTH_MAX_BYTES
+#define GC_HEAP_GROWTH_MAX_BYTES 0 /* 0 is disable */
+#endif
+#ifndef GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO
+# define GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO 0.01
+#endif
+#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR
+#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
+#endif
+
+#ifndef GC_HEAP_FREE_SLOTS_MIN_RATIO
+#define GC_HEAP_FREE_SLOTS_MIN_RATIO 0.20
+#endif
+#ifndef GC_HEAP_FREE_SLOTS_GOAL_RATIO
+#define GC_HEAP_FREE_SLOTS_GOAL_RATIO 0.40
+#endif
+#ifndef GC_HEAP_FREE_SLOTS_MAX_RATIO
+#define GC_HEAP_FREE_SLOTS_MAX_RATIO 0.65
+#endif
+
+#ifndef GC_MALLOC_LIMIT_MIN
+#define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
+#endif
+#ifndef GC_MALLOC_LIMIT_MAX
+#define GC_MALLOC_LIMIT_MAX (32 * 1024 * 1024 /* 32MB */)
+#endif
+#ifndef GC_MALLOC_LIMIT_GROWTH_FACTOR
+#define GC_MALLOC_LIMIT_GROWTH_FACTOR 1.4
+#endif
+
+#ifndef GC_OLDMALLOC_LIMIT_MIN
+#define GC_OLDMALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
+#endif
+#ifndef GC_OLDMALLOC_LIMIT_GROWTH_FACTOR
+#define GC_OLDMALLOC_LIMIT_GROWTH_FACTOR 1.2
+#endif
+#ifndef GC_OLDMALLOC_LIMIT_MAX
+#define GC_OLDMALLOC_LIMIT_MAX (128 * 1024 * 1024 /* 128MB */)
+#endif
+
+#ifndef GC_MALLOC_INCREASE_LOCAL_THRESHOLD
+#define GC_MALLOC_INCREASE_LOCAL_THRESHOLD (8 * 1024 /* 8KB */)
+#endif
+
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+#define USE_MALLOC_INCREASE_LOCAL 1
+static RB_THREAD_LOCAL_SPECIFIER int malloc_increase_local;
+#else
+#define USE_MALLOC_INCREASE_LOCAL 0
+#endif
+
+#ifndef GC_CAN_COMPILE_COMPACTION
+#if defined(__wasi__) /* WebAssembly doesn't support signals */
+# define GC_CAN_COMPILE_COMPACTION 0
+#else
+# define GC_CAN_COMPILE_COMPACTION 1
+#endif
+#endif
+
+#ifndef PRINT_ENTER_EXIT_TICK
+# define PRINT_ENTER_EXIT_TICK 0
+#endif
+#ifndef PRINT_ROOT_TICKS
+#define PRINT_ROOT_TICKS 0
+#endif
+
+#define USE_TICK_T (PRINT_ENTER_EXIT_TICK || PRINT_ROOT_TICKS)
+
+#ifndef HEAP_COUNT
+# if SIZEOF_VALUE >= 8
+# define HEAP_COUNT 12
+# else
+# define HEAP_COUNT 5
+# endif
+#endif
+
+/* The reciprocal table and pool_slot_sizes array are both generated from this
+ * single definition, so they can never get out of sync. */
+#if SIZEOF_VALUE >= 8
+# define EACH_POOL_SLOT_SIZE(SLOT) \
+ SLOT(32) SLOT(40) SLOT(64) SLOT(80) SLOT(96) SLOT(128) \
+ SLOT(160) SLOT(256) SLOT(512) SLOT(640) SLOT(768) SLOT(1024)
+#else
+# define EACH_POOL_SLOT_SIZE(SLOT) \
+ SLOT(32) SLOT(64) SLOT(128) SLOT(256) SLOT(512)
+#endif
+
+typedef struct ractor_newobj_heap_cache {
+ struct free_slot *freelist;
+ struct heap_page *using_page;
+ size_t allocated_objects_count;
+} rb_ractor_newobj_heap_cache_t;
+
+typedef struct ractor_newobj_cache {
+ size_t incremental_mark_step_allocated_slots;
+ rb_ractor_newobj_heap_cache_t heap_caches[HEAP_COUNT];
+} rb_ractor_newobj_cache_t;
+
+typedef struct {
+ size_t heap_init_bytes;
+ size_t heap_free_slots;
+ double growth_factor;
+ size_t growth_max_bytes;
+
+ double heap_free_slots_min_ratio;
+ double heap_free_slots_goal_ratio;
+ double heap_free_slots_max_ratio;
+ double uncollectible_wb_unprotected_objects_limit_ratio;
+ double oldobject_limit_factor;
+
+ size_t malloc_limit_min;
+ size_t malloc_limit_max;
+ double malloc_limit_growth_factor;
+
+ size_t oldmalloc_limit_min;
+ size_t oldmalloc_limit_max;
+ double oldmalloc_limit_growth_factor;
+} ruby_gc_params_t;
+
+static ruby_gc_params_t gc_params = {
+ GC_HEAP_INIT_BYTES,
+ GC_HEAP_FREE_SLOTS,
+ GC_HEAP_GROWTH_FACTOR,
+ GC_HEAP_GROWTH_MAX_BYTES,
+
+ GC_HEAP_FREE_SLOTS_MIN_RATIO,
+ GC_HEAP_FREE_SLOTS_GOAL_RATIO,
+ GC_HEAP_FREE_SLOTS_MAX_RATIO,
+ GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO,
+ GC_HEAP_OLDOBJECT_LIMIT_FACTOR,
+
+ GC_MALLOC_LIMIT_MIN,
+ GC_MALLOC_LIMIT_MAX,
+ GC_MALLOC_LIMIT_GROWTH_FACTOR,
+
+ GC_OLDMALLOC_LIMIT_MIN,
+ GC_OLDMALLOC_LIMIT_MAX,
+ GC_OLDMALLOC_LIMIT_GROWTH_FACTOR,
+};
+
+/* GC_DEBUG:
+ * enable to embed GC debugging information.
+ */
+#ifndef GC_DEBUG
+#define GC_DEBUG 0
+#endif
+
+/* RGENGC_DEBUG:
+ * 1: basic information
+ * 2: remember set operation
+ * 3: mark
+ * 4:
+ * 5: sweep
+ */
+#ifndef RGENGC_DEBUG
+#ifdef RUBY_DEVEL
+#define RGENGC_DEBUG -1
+#else
+#define RGENGC_DEBUG 0
+#endif
+#endif
+#if RGENGC_DEBUG < 0 && !defined(_MSC_VER)
+# define RGENGC_DEBUG_ENABLED(level) (-(RGENGC_DEBUG) >= (level) && ruby_rgengc_debug >= (level))
+#elif defined(HAVE_VA_ARGS_MACRO)
+# define RGENGC_DEBUG_ENABLED(level) ((RGENGC_DEBUG) >= (level))
+#else
+# define RGENGC_DEBUG_ENABLED(level) 0
+#endif
+int ruby_rgengc_debug;
+
+/* RGENGC_PROFILE
+ * 0: disable RGenGC profiling
+ * 1: enable profiling for basic information
+ * 2: enable profiling for each types
+ */
+#ifndef RGENGC_PROFILE
+# define RGENGC_PROFILE 0
+#endif
+
+/* RGENGC_ESTIMATE_OLDMALLOC
+ * Enable/disable to estimate increase size of malloc'ed size by old objects.
+ * If estimation exceeds threshold, then will invoke full GC.
+ * 0: disable estimation.
+ * 1: enable estimation.
+ */
+#ifndef RGENGC_ESTIMATE_OLDMALLOC
+# define RGENGC_ESTIMATE_OLDMALLOC 1
+#endif
+
+#ifndef GC_PROFILE_MORE_DETAIL
+# define GC_PROFILE_MORE_DETAIL 0
+#endif
+#ifndef GC_PROFILE_DETAIL_MEMORY
+# define GC_PROFILE_DETAIL_MEMORY 0
+#endif
+#ifndef GC_ENABLE_LAZY_SWEEP
+# define GC_ENABLE_LAZY_SWEEP 1
+#endif
+
+#ifndef VERIFY_FREE_SIZE
+#if RUBY_DEBUG
+#define VERIFY_FREE_SIZE 1
+#else
+#define VERIFY_FREE_SIZE 0
+#endif
+#endif
+
+#if VERIFY_FREE_SIZE
+#undef CALC_EXACT_MALLOC_SIZE
+#define CALC_EXACT_MALLOC_SIZE 1
+#endif
+
+#ifndef CALC_EXACT_MALLOC_SIZE
+# define CALC_EXACT_MALLOC_SIZE 0
+#endif
+
+#if defined(HAVE_MALLOC_USABLE_SIZE) || CALC_EXACT_MALLOC_SIZE > 0
+# ifndef MALLOC_ALLOCATED_SIZE
+# define MALLOC_ALLOCATED_SIZE 0
+# endif
+#else
+# define MALLOC_ALLOCATED_SIZE 0
+#endif
+#ifndef MALLOC_ALLOCATED_SIZE_CHECK
+# define MALLOC_ALLOCATED_SIZE_CHECK 0
+#endif
+
+#ifndef GC_DEBUG_STRESS_TO_CLASS
+# define GC_DEBUG_STRESS_TO_CLASS RUBY_DEBUG
+#endif
+
+typedef enum {
+ GPR_FLAG_NONE = 0x000,
+ /* major reason */
+ GPR_FLAG_MAJOR_BY_NOFREE = 0x001,
+ GPR_FLAG_MAJOR_BY_OLDGEN = 0x002,
+ GPR_FLAG_MAJOR_BY_SHADY = 0x004,
+ GPR_FLAG_MAJOR_BY_FORCE = 0x008,
+#if RGENGC_ESTIMATE_OLDMALLOC
+ GPR_FLAG_MAJOR_BY_OLDMALLOC = 0x020,
+#endif
+ GPR_FLAG_MAJOR_MASK = 0x0ff,
+
+ /* gc reason */
+ GPR_FLAG_NEWOBJ = 0x100,
+ GPR_FLAG_MALLOC = 0x200,
+ GPR_FLAG_METHOD = 0x400,
+ GPR_FLAG_CAPI = 0x800,
+ GPR_FLAG_STRESS = 0x1000,
+
+ /* others */
+ GPR_FLAG_IMMEDIATE_SWEEP = 0x2000,
+ GPR_FLAG_HAVE_FINALIZE = 0x4000,
+ GPR_FLAG_IMMEDIATE_MARK = 0x8000,
+ GPR_FLAG_FULL_MARK = 0x10000,
+ GPR_FLAG_COMPACT = 0x20000,
+
+ GPR_DEFAULT_REASON =
+ (GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
+ GPR_FLAG_IMMEDIATE_SWEEP | GPR_FLAG_CAPI),
+} gc_profile_record_flag;
+
+typedef struct gc_profile_record {
+ unsigned int flags;
+
+ double gc_time;
+ double gc_invoke_time;
+
+ size_t heap_total_objects;
+ size_t heap_use_size;
+ size_t heap_total_size;
+ size_t moved_objects;
+
+#if GC_PROFILE_MORE_DETAIL
+ double gc_mark_time;
+ double gc_sweep_time;
+
+ size_t heap_use_pages;
+ size_t heap_live_objects;
+ size_t heap_free_objects;
+
+ size_t allocate_increase;
+ size_t allocate_limit;
+
+ double prepare_time;
+ size_t removing_objects;
+ size_t empty_objects;
+#if GC_PROFILE_DETAIL_MEMORY
+ long maxrss;
+ long minflt;
+ long majflt;
+#endif
+#endif
+#if MALLOC_ALLOCATED_SIZE
+ size_t allocated_size;
+#endif
+
+#if RGENGC_PROFILE > 0
+ size_t old_objects;
+ size_t remembered_normal_objects;
+ size_t remembered_shady_objects;
+#endif
+} gc_profile_record;
+
+struct RMoved {
+ VALUE flags;
+ VALUE dummy;
+ VALUE destination;
+};
+
+#define RMOVED(obj) ((struct RMoved *)(obj))
+
+typedef uintptr_t bits_t;
+enum {
+ BITS_SIZE = sizeof(bits_t),
+ BITS_BITLENGTH = ( BITS_SIZE * CHAR_BIT )
+};
+
+struct heap_page_header {
+ struct heap_page *page;
+};
+
+struct heap_page_body {
+ struct heap_page_header header;
+ /* char gap[]; */
+ /* RVALUE values[]; */
+};
+
+#define STACK_CHUNK_SIZE 500
+
+typedef struct stack_chunk {
+ VALUE data[STACK_CHUNK_SIZE];
+ struct stack_chunk *next;
+} stack_chunk_t;
+
+typedef struct mark_stack {
+ stack_chunk_t *chunk;
+ stack_chunk_t *cache;
+ int index;
+ int limit;
+ size_t cache_size;
+ size_t unused_cache_size;
+} mark_stack_t;
+
+typedef int (*gc_compact_compare_func)(const void *l, const void *r, void *d);
+
+typedef struct rb_heap_struct {
+ short slot_size;
+
+ /* Basic statistics */
+ size_t total_allocated_pages;
+ size_t force_major_gc_count;
+ size_t force_incremental_marking_finish_count;
+ size_t total_allocated_objects;
+ size_t total_freed_objects;
+ size_t final_slots_count;
+
+ /* Sweeping statistics */
+ size_t freed_slots;
+ size_t empty_slots;
+
+ struct heap_page *free_pages;
+ struct ccan_list_head pages;
+ struct heap_page *sweeping_page; /* iterator for .pages */
+ struct heap_page *compact_cursor;
+ uintptr_t compact_cursor_index;
+ struct heap_page *pooled_pages;
+ size_t total_pages; /* total page count in a heap */
+ size_t total_slots; /* total slot count */
+
+} rb_heap_t;
+
+enum {
+ gc_stress_no_major,
+ gc_stress_no_immediate_sweep,
+ gc_stress_full_mark_after_malloc,
+ gc_stress_max
+};
+
+enum gc_mode {
+ gc_mode_none,
+ gc_mode_marking,
+ gc_mode_sweeping,
+ gc_mode_compacting,
+};
+
+typedef rbimpl_atomic_uint64_t gc_counter_t;
+
+#if !defined(HAVE_GCC_ATOMIC_BUILTINS_64) && !defined(_WIN32) && \
+ !(defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx)))
+# define MALLOC_COUNTERS_NEED_LOCK 1
+#endif
+
+struct gc_malloc_bytes {
+ gc_counter_t malloc;
+ gc_counter_t free;
+
+ /* Snapshots of `malloc` / `free` taken at the end of the last GC */
+ gc_counter_t malloc_at_last_gc;
+ gc_counter_t free_at_last_gc;
+};
+
+typedef struct rb_objspace {
+ struct {
+ struct gc_malloc_bytes counters;
+#if RGENGC_ESTIMATE_OLDMALLOC
+ struct gc_malloc_bytes oldcounters;
+#endif
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ rb_nativethread_lock_t lock;
+#endif
+ } malloc_counters;
+
+ struct {
+ size_t limit;
+#if MALLOC_ALLOCATED_SIZE
+ size_t allocated_size;
+ size_t allocations;
+#endif
+ } malloc_params;
+
+ struct rb_gc_config {
+ bool full_mark;
+ } gc_config;
+
+ struct {
+ unsigned int mode : 2;
+ unsigned int immediate_sweep : 1;
+ unsigned int dont_gc : 1;
+ unsigned int dont_incremental : 1;
+ unsigned int during_gc : 1;
+ unsigned int during_compacting : 1;
+ unsigned int during_reference_updating : 1;
+ unsigned int gc_stressful: 1;
+ unsigned int during_minor_gc : 1;
+ unsigned int during_incremental_marking : 1;
+ unsigned int measure_gc : 1;
+ } flags;
+
+ rb_event_flag_t hook_events;
+
+ rb_heap_t heaps[HEAP_COUNT];
+ size_t empty_pages_count;
+ struct heap_page *empty_pages;
+
+ struct {
+ rb_atomic_t finalizing;
+ } atomic_flags;
+
+ mark_stack_t mark_stack;
+ size_t marked_slots;
+
+ struct {
+ rb_darray(struct heap_page *) sorted;
+
+ size_t allocated_pages;
+ size_t freed_pages;
+ uintptr_t range[2];
+ size_t freeable_pages;
+
+ size_t allocatable_bytes;
+
+ /* final */
+ VALUE deferred_final;
+ } heap_pages;
+
+ st_table *finalizer_table;
+
+ struct {
+ int run;
+ unsigned int latest_gc_info;
+ gc_profile_record *records;
+ gc_profile_record *current_record;
+ size_t next_index;
+ size_t size;
+
+#if GC_PROFILE_MORE_DETAIL
+ double prepare_time;
+#endif
+ double invoke_time;
+
+ size_t minor_gc_count;
+ size_t major_gc_count;
+ size_t compact_count;
+ size_t read_barrier_faults;
+#if RGENGC_PROFILE > 0
+ size_t total_generated_normal_object_count;
+ size_t total_generated_shady_object_count;
+ size_t total_shade_operation_count;
+ size_t total_promoted_count;
+ size_t total_remembered_normal_object_count;
+ size_t total_remembered_shady_object_count;
+
+#if RGENGC_PROFILE >= 2
+ size_t generated_normal_object_count_types[RUBY_T_MASK];
+ size_t generated_shady_object_count_types[RUBY_T_MASK];
+ size_t shade_operation_count_types[RUBY_T_MASK];
+ size_t promoted_types[RUBY_T_MASK];
+ size_t remembered_normal_object_count_types[RUBY_T_MASK];
+ size_t remembered_shady_object_count_types[RUBY_T_MASK];
+#endif
+#endif /* RGENGC_PROFILE */
+
+ /* temporary profiling space */
+ double gc_sweep_start_time;
+ size_t total_allocated_objects_at_gc_start;
+ size_t heap_used_at_gc_start;
+ size_t heap_total_slots_at_gc_start;
+
+ /* basic statistics */
+ size_t count;
+ unsigned long long marking_time_ns;
+ struct timespec marking_start_time;
+ unsigned long long sweeping_time_ns;
+ struct timespec sweeping_start_time;
+
+ /* Weak references */
+ size_t weak_references_count;
+ } profile;
+
+ VALUE gc_stress_mode;
+
+ struct {
+ bool parent_object_old_p;
+ VALUE parent_object;
+
+ int need_major_gc;
+ size_t last_major_gc;
+ size_t uncollectible_wb_unprotected_objects;
+ size_t uncollectible_wb_unprotected_objects_limit;
+ size_t old_objects;
+ size_t old_objects_limit;
+
+#if RGENGC_ESTIMATE_OLDMALLOC
+ size_t oldmalloc_increase_limit;
+#endif
+
+#if RGENGC_CHECK_MODE >= 2
+ struct st_table *allrefs_table;
+ size_t error_count;
+#endif
+ } rgengc;
+
+ struct {
+ size_t considered_count_table[T_MASK];
+ size_t moved_count_table[T_MASK];
+ size_t moved_up_count_table[T_MASK];
+ size_t moved_down_count_table[T_MASK];
+ size_t total_moved;
+
+ /* This function will be used, if set, to sort the heap prior to compaction */
+ gc_compact_compare_func compare_func;
+ } rcompactor;
+
+ struct {
+ size_t pooled_slots;
+ size_t step_slots;
+ } rincgc;
+
+#if GC_DEBUG_STRESS_TO_CLASS
+ VALUE stress_to_class;
+#endif
+
+ rb_darray(VALUE) weak_references;
+ rb_postponed_job_handle_t finalize_deferred_pjob;
+
+ unsigned long live_ractor_cache_count;
+
+ int sweeping_heap_count;
+
+ int fork_vm_lock_lev;
+
+ struct rb_gc_vm_context vm_context;
+} rb_objspace_t;
+
+#ifndef HEAP_PAGE_ALIGN_LOG
+/* default tiny heap size: 64KiB */
+#define HEAP_PAGE_ALIGN_LOG 16
+#endif
+
+#if RB_GC_OBJ_HAS_SUFFIX || GC_DEBUG
+struct rvalue_overhead {
+# if RB_GC_OBJ_HAS_SUFFIX
+ struct rb_gc_obj_suffix suffix;
+# endif
+# if GC_DEBUG
+ const char *file;
+ int line;
+# endif
+};
+
+// Make sure that RVALUE_OVERHEAD aligns to sizeof(VALUE)
+# define RVALUE_OVERHEAD (sizeof(struct { \
+ union { \
+ struct rvalue_overhead overhead; \
+ VALUE value; \
+ }; \
+}))
+size_t rb_gc_impl_obj_slot_size(VALUE obj);
+# define GET_RVALUE_OVERHEAD(obj) ((struct rvalue_overhead *)((uintptr_t)obj + rb_gc_impl_obj_slot_size(obj)))
+#else
+# ifndef RVALUE_OVERHEAD
+# define RVALUE_OVERHEAD 0
+# endif
+#endif
+
+#define RVALUE_SLOT_SIZE (sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]) + RVALUE_OVERHEAD)
+
+static const size_t pool_slot_sizes[HEAP_COUNT] = {
+#define SLOT(size) ((size) + RVALUE_OVERHEAD),
+ EACH_POOL_SLOT_SIZE(SLOT)
+#undef SLOT
+};
+
+/* Precomputed reciprocals for fast slot index calculation.
+ * For slot size d: reciprocal = ceil(2^48 / d).
+ * Then offset / d == (uint32_t)((offset * reciprocal) >> 48)
+ * for all offset < HEAP_PAGE_SIZE. */
+#define SLOT_RECIPROCAL_SHIFT 48
+#define SLOT_RECIPROCAL(size) (((1ULL << SLOT_RECIPROCAL_SHIFT) + (size) - 1) / (size))
+
+static const uint64_t heap_slot_reciprocal_table[HEAP_COUNT] = {
+#define SLOT(size) SLOT_RECIPROCAL((size) + RVALUE_OVERHEAD),
+ EACH_POOL_SLOT_SIZE(SLOT)
+#undef SLOT
+};
+
+#if SIZEOF_VALUE >= 8
+static uint8_t size_to_heap_idx[1024 / 8 + 1];
+#else
+static uint8_t size_to_heap_idx[512 / 8 + 1];
+#endif
+
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+#define roomof(x, y) (((x) + (y) - 1) / (y))
+#define CEILDIV(i, mod) roomof(i, mod)
+#define MIN_POOL_SLOT_SIZE 32
+enum {
+ HEAP_PAGE_ALIGN = (1UL << HEAP_PAGE_ALIGN_LOG),
+ HEAP_PAGE_ALIGN_MASK = (~(~0UL << HEAP_PAGE_ALIGN_LOG)),
+ HEAP_PAGE_SIZE = HEAP_PAGE_ALIGN,
+ HEAP_PAGE_BITMAP_LIMIT = CEILDIV(CEILDIV(HEAP_PAGE_SIZE, MIN_POOL_SLOT_SIZE), BITS_BITLENGTH),
+ HEAP_PAGE_BITMAP_SIZE = (BITS_SIZE * HEAP_PAGE_BITMAP_LIMIT),
+};
+#define HEAP_PAGE_ALIGN (1 << HEAP_PAGE_ALIGN_LOG)
+#define HEAP_PAGE_SIZE HEAP_PAGE_ALIGN
+
+#if !defined(INCREMENTAL_MARK_STEP_ALLOCATIONS)
+# define INCREMENTAL_MARK_STEP_ALLOCATIONS 500
+#endif
+
+#undef INIT_HEAP_PAGE_ALLOC_USE_MMAP
+/* Must define either HEAP_PAGE_ALLOC_USE_MMAP or
+ * INIT_HEAP_PAGE_ALLOC_USE_MMAP. */
+
+#ifndef HAVE_MMAP
+/* We can't use mmap of course, if it is not available. */
+static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
+
+#elif defined(__wasm__)
+/* wasmtime does not have proper support for mmap.
+ * See https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-mmap-and-friends
+ */
+static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
+
+#elif HAVE_CONST_PAGE_SIZE
+/* If we have the PAGE_SIZE and it is a constant, then we can directly use it. */
+static const bool HEAP_PAGE_ALLOC_USE_MMAP = (PAGE_SIZE <= HEAP_PAGE_SIZE);
+
+#elif defined(PAGE_MAX_SIZE) && (PAGE_MAX_SIZE <= HEAP_PAGE_SIZE)
+/* If we can use the maximum page size. */
+static const bool HEAP_PAGE_ALLOC_USE_MMAP = true;
+
+#elif defined(PAGE_SIZE)
+/* If the PAGE_SIZE macro can be used dynamically. */
+# define INIT_HEAP_PAGE_ALLOC_USE_MMAP (PAGE_SIZE <= HEAP_PAGE_SIZE)
+
+#elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
+/* If we can use sysconf to determine the page size. */
+# define INIT_HEAP_PAGE_ALLOC_USE_MMAP (sysconf(_SC_PAGE_SIZE) <= HEAP_PAGE_SIZE)
+
+#else
+/* Otherwise we can't determine the system page size, so don't use mmap. */
+static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
+#endif
+
+#ifdef INIT_HEAP_PAGE_ALLOC_USE_MMAP
+/* We can determine the system page size at runtime. */
+# define HEAP_PAGE_ALLOC_USE_MMAP (heap_page_alloc_use_mmap != false)
+
+static bool heap_page_alloc_use_mmap;
+#endif
+
+#define RVALUE_AGE_BIT_COUNT 2
+#define RVALUE_AGE_BIT_MASK (((bits_t)1 << RVALUE_AGE_BIT_COUNT) - 1)
+#define RVALUE_OLD_AGE 3
+
+struct free_slot {
+ VALUE flags; /* always 0 for freed obj */
+ struct free_slot *next;
+};
+
+struct heap_page {
+ /* Cache line 0: allocation fast path + SLOT_INDEX */
+ struct free_slot *freelist;
+ uintptr_t start;
+ uint64_t slot_size_reciprocal;
+ unsigned short slot_size;
+ unsigned short total_slots;
+ unsigned short free_slots;
+ unsigned short final_slots;
+ unsigned short pinned_slots;
+ struct {
+ unsigned int before_sweep : 1;
+ unsigned int has_remembered_objects : 1;
+ unsigned int has_uncollectible_wb_unprotected_objects : 1;
+ } flags;
+
+ rb_heap_t *heap;
+
+ struct heap_page *free_next;
+ struct heap_page_body *body;
+ struct ccan_list_node page_node;
+
+ bits_t wb_unprotected_bits[HEAP_PAGE_BITMAP_LIMIT];
+ /* the following three bitmaps are cleared at the beginning of full GC */
+ bits_t mark_bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t uncollectible_bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t marking_bits[HEAP_PAGE_BITMAP_LIMIT];
+
+ bits_t remembered_bits[HEAP_PAGE_BITMAP_LIMIT];
+
+ /* If set, the object is not movable */
+ bits_t pinned_bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t age_bits[HEAP_PAGE_BITMAP_LIMIT * RVALUE_AGE_BIT_COUNT];
+};
+
+/*
+ * When asan is enabled, this will prohibit writing to the freelist until it is unlocked
+ */
+static void
+asan_lock_freelist(struct heap_page *page)
+{
+ asan_poison_memory_region(&page->freelist, sizeof(struct free_list *));
+}
+
+/*
+ * When asan is enabled, this will enable the ability to write to the freelist
+ */
+static void
+asan_unlock_freelist(struct heap_page *page)
+{
+ asan_unpoison_memory_region(&page->freelist, sizeof(struct free_list *), false);
+}
+
+static inline bool
+heap_page_in_global_empty_pages_pool(rb_objspace_t *objspace, struct heap_page *page)
+{
+ if (page->total_slots == 0) {
+ GC_ASSERT(page->start == 0);
+ GC_ASSERT(page->slot_size == 0);
+ GC_ASSERT(page->heap == NULL);
+ GC_ASSERT(page->free_slots == 0);
+ asan_unpoisoning_memory_region(&page->freelist, sizeof(&page->freelist)) {
+ GC_ASSERT(page->freelist == NULL);
+ }
+
+ return true;
+ }
+ else {
+ GC_ASSERT(page->start != 0);
+ GC_ASSERT(page->slot_size != 0);
+ GC_ASSERT(page->heap != NULL);
+
+ return false;
+ }
+}
+
+#define GET_PAGE_BODY(x) ((struct heap_page_body *)((bits_t)(x) & ~(HEAP_PAGE_ALIGN_MASK)))
+#define GET_PAGE_HEADER(x) (&GET_PAGE_BODY(x)->header)
+#define GET_HEAP_PAGE(x) (GET_PAGE_HEADER(x)->page)
+
+static inline size_t
+slot_index_for_offset(size_t offset, uint64_t reciprocal)
+{
+ return (uint32_t)(((uint64_t)offset * reciprocal) >> SLOT_RECIPROCAL_SHIFT);
+}
+
+#define SLOT_INDEX(page, p) slot_index_for_offset((uintptr_t)(p) - (page)->start, (page)->slot_size_reciprocal)
+#define SLOT_BITMAP_INDEX(page, p) (SLOT_INDEX(page, p) / BITS_BITLENGTH)
+#define SLOT_BITMAP_OFFSET(page, p) (SLOT_INDEX(page, p) & (BITS_BITLENGTH - 1))
+#define SLOT_BITMAP_BIT(page, p) ((bits_t)1 << SLOT_BITMAP_OFFSET(page, p))
+
+#define _MARKED_IN_BITMAP(bits, page, p) ((bits)[SLOT_BITMAP_INDEX(page, p)] & SLOT_BITMAP_BIT(page, p))
+#define _MARK_IN_BITMAP(bits, page, p) ((bits)[SLOT_BITMAP_INDEX(page, p)] |= SLOT_BITMAP_BIT(page, p))
+#define _CLEAR_IN_BITMAP(bits, page, p) ((bits)[SLOT_BITMAP_INDEX(page, p)] &= ~SLOT_BITMAP_BIT(page, p))
+
+#define MARKED_IN_BITMAP(bits, p) _MARKED_IN_BITMAP(bits, GET_HEAP_PAGE(p), p)
+#define MARK_IN_BITMAP(bits, p) _MARK_IN_BITMAP(bits, GET_HEAP_PAGE(p), p)
+#define CLEAR_IN_BITMAP(bits, p) _CLEAR_IN_BITMAP(bits, GET_HEAP_PAGE(p), p)
+
+#define GET_HEAP_MARK_BITS(x) (&GET_HEAP_PAGE(x)->mark_bits[0])
+#define GET_HEAP_PINNED_BITS(x) (&GET_HEAP_PAGE(x)->pinned_bits[0])
+#define GET_HEAP_UNCOLLECTIBLE_BITS(x) (&GET_HEAP_PAGE(x)->uncollectible_bits[0])
+#define GET_HEAP_WB_UNPROTECTED_BITS(x) (&GET_HEAP_PAGE(x)->wb_unprotected_bits[0])
+#define GET_HEAP_MARKING_BITS(x) (&GET_HEAP_PAGE(x)->marking_bits[0])
+
+static int
+RVALUE_AGE_GET(VALUE obj)
+{
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+ bits_t *age_bits = page->age_bits;
+ size_t slot_idx = SLOT_INDEX(page, obj);
+ size_t idx = (slot_idx / BITS_BITLENGTH) * 2;
+ int shift = (int)(slot_idx & (BITS_BITLENGTH - 1));
+ int lo = (age_bits[idx] >> shift) & 1;
+ int hi = (age_bits[idx + 1] >> shift) & 1;
+ return lo | (hi << 1);
+}
+
+static void
+RVALUE_AGE_SET_BITMAP(VALUE obj, int age)
+{
+ RUBY_ASSERT(age <= RVALUE_OLD_AGE);
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+ bits_t *age_bits = page->age_bits;
+ size_t slot_idx = SLOT_INDEX(page, obj);
+ size_t idx = (slot_idx / BITS_BITLENGTH) * 2;
+ int shift = (int)(slot_idx & (BITS_BITLENGTH - 1));
+ bits_t mask = (bits_t)1 << shift;
+
+ age_bits[idx] = (age_bits[idx] & ~mask) | ((bits_t)(age & 1) << shift);
+ age_bits[idx + 1] = (age_bits[idx + 1] & ~mask) | ((bits_t)((age >> 1) & 1) << shift);
+}
+
+static void
+RVALUE_AGE_SET(VALUE obj, int age)
+{
+ RVALUE_AGE_SET_BITMAP(obj, age);
+ if (age == RVALUE_OLD_AGE) {
+ RB_FL_SET_RAW(obj, RUBY_FL_PROMOTED);
+ }
+ else {
+ RB_FL_UNSET_RAW(obj, RUBY_FL_PROMOTED);
+ }
+}
+
+#define malloc_limit objspace->malloc_params.limit
+#define malloc_increase gc_malloc_counters_increase_unsigned(objspace, &objspace->malloc_counters.counters)
+#define malloc_allocated_size objspace->malloc_params.allocated_size
+
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+# define MALLOC_COUNTERS_LOCK(o) rb_native_mutex_lock(&(o)->malloc_counters.lock)
+# define MALLOC_COUNTERS_UNLOCK(o) rb_native_mutex_unlock(&(o)->malloc_counters.lock)
+#else
+# define MALLOC_COUNTERS_LOCK(o) ((void)0)
+# define MALLOC_COUNTERS_UNLOCK(o) ((void)0)
+#endif
+
+static inline void
+gc_counter_add(gc_counter_t *p, size_t delta)
+{
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ *p += (gc_counter_t)delta;
+#else
+ rbimpl_atomic_u64_fetch_add_relaxed(p, (uint64_t)delta);
+#endif
+}
+
+static inline gc_counter_t
+gc_counter_load_relaxed(const gc_counter_t *p)
+{
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ return *p;
+#else
+ return rbimpl_atomic_u64_load_relaxed(p);
+#endif
+}
+
+static inline gc_counter_t
+gc_counter_load_acquire(const gc_counter_t *p)
+{
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ return *p;
+#else
+ return rbimpl_atomic_u64_load_acquire(p);
+#endif
+}
+
+static inline void
+gc_counter_store_release(gc_counter_t *p, gc_counter_t v)
+{
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ *p = v;
+#else
+ rbimpl_atomic_u64_set_release(p, v);
+#endif
+}
+
+static inline int64_t
+gc_malloc_counters_increase(rb_objspace_t *objspace, const struct gc_malloc_bytes *c)
+{
+ MALLOC_COUNTERS_LOCK(objspace);
+ gc_counter_t malloc_at = gc_counter_load_acquire(&c->malloc_at_last_gc);
+ gc_counter_t free_at = gc_counter_load_acquire(&c->free_at_last_gc);
+ gc_counter_t malloc_now = gc_counter_load_relaxed(&c->malloc);
+ gc_counter_t free_now = gc_counter_load_relaxed(&c->free);
+ MALLOC_COUNTERS_UNLOCK(objspace);
+
+ gc_counter_t malloc_delta = malloc_now - malloc_at;
+ gc_counter_t free_delta = free_now - free_at;
+
+ if (malloc_delta >= free_delta) {
+ return (int64_t)(malloc_delta - free_delta);
+ }
+ else {
+ return -(int64_t)(free_delta - malloc_delta);
+ }
+}
+
+static inline size_t
+gc_malloc_counters_increase_unsigned(rb_objspace_t *objspace, const struct gc_malloc_bytes *c)
+{
+ int64_t inc = gc_malloc_counters_increase(objspace, c);
+ if (inc <= 0) return 0;
+#if SIZEOF_SIZE_T < 8
+ if ((uint64_t)inc > SIZE_MAX) return SIZE_MAX;
+#endif
+ return (size_t)inc;
+}
+
+static inline int64_t
+gc_malloc_counters_snapshot(rb_objspace_t *objspace, struct gc_malloc_bytes *c)
+{
+ MALLOC_COUNTERS_LOCK(objspace);
+ gc_counter_t malloc_now = gc_counter_load_relaxed(&c->malloc);
+ gc_counter_t free_now = gc_counter_load_relaxed(&c->free);
+ gc_counter_t malloc_at = gc_counter_load_relaxed(&c->malloc_at_last_gc);
+ gc_counter_t free_at = gc_counter_load_relaxed(&c->free_at_last_gc);
+ gc_counter_store_release(&c->malloc_at_last_gc, malloc_now);
+ gc_counter_store_release(&c->free_at_last_gc, free_now);
+ MALLOC_COUNTERS_UNLOCK(objspace);
+
+ gc_counter_t malloc_delta = malloc_now - malloc_at;
+ gc_counter_t free_delta = free_now - free_at;
+
+ if (malloc_delta >= free_delta) {
+ return (int64_t)(malloc_delta - free_delta);
+ }
+ else {
+ return -(int64_t)(free_delta - malloc_delta);
+ }
+}
+
+#define heap_pages_lomem objspace->heap_pages.range[0]
+#define heap_pages_himem objspace->heap_pages.range[1]
+#define heap_pages_freeable_pages objspace->heap_pages.freeable_pages
+#define heap_pages_deferred_final objspace->heap_pages.deferred_final
+#define heaps objspace->heaps
+#define during_gc objspace->flags.during_gc
+#define finalizing objspace->atomic_flags.finalizing
+#define finalizer_table objspace->finalizer_table
+#define ruby_gc_stressful objspace->flags.gc_stressful
+#define ruby_gc_stress_mode objspace->gc_stress_mode
+#if GC_DEBUG_STRESS_TO_CLASS
+#define stress_to_class objspace->stress_to_class
+#define set_stress_to_class(c) (stress_to_class = (c))
+#else
+#define stress_to_class ((void)objspace, 0)
+#define set_stress_to_class(c) ((void)objspace, (c))
+#endif
+
+#if 0
+#define dont_gc_on() (fprintf(stderr, "dont_gc_on@%s:%d\n", __FILE__, __LINE__), objspace->flags.dont_gc = 1)
+#define dont_gc_off() (fprintf(stderr, "dont_gc_off@%s:%d\n", __FILE__, __LINE__), objspace->flags.dont_gc = 0)
+#define dont_gc_set(b) (fprintf(stderr, "dont_gc_set(%d)@%s:%d\n", __FILE__, __LINE__), objspace->flags.dont_gc = (int)(b))
+#define dont_gc_val() (objspace->flags.dont_gc)
+#else
+#define dont_gc_on() (objspace->flags.dont_gc = 1)
+#define dont_gc_off() (objspace->flags.dont_gc = 0)
+#define dont_gc_set(b) (objspace->flags.dont_gc = (int)(b))
+#define dont_gc_val() (objspace->flags.dont_gc)
+#endif
+
+#define gc_config_full_mark_set(b) (objspace->gc_config.full_mark = (int)(b))
+#define gc_config_full_mark_val (objspace->gc_config.full_mark)
+
+#ifndef DURING_GC_COULD_MALLOC_REGION_START
+# define DURING_GC_COULD_MALLOC_REGION_START() \
+ assert(rb_during_gc()); \
+ bool _prev_enabled = rb_gc_impl_gc_enabled_p(objspace); \
+ rb_gc_impl_gc_disable(objspace, false)
+#endif
+
+#ifndef DURING_GC_COULD_MALLOC_REGION_END
+# define DURING_GC_COULD_MALLOC_REGION_END() \
+ if (_prev_enabled) rb_gc_impl_gc_enable(objspace)
+#endif
+
+static inline enum gc_mode
+gc_mode_verify(enum gc_mode mode)
+{
+#if RGENGC_CHECK_MODE > 0
+ switch (mode) {
+ case gc_mode_none:
+ case gc_mode_marking:
+ case gc_mode_sweeping:
+ case gc_mode_compacting:
+ break;
+ default:
+ rb_bug("gc_mode_verify: unreachable (%d)", (int)mode);
+ }
+#endif
+ return mode;
+}
+
+static inline bool
+has_sweeping_pages(rb_objspace_t *objspace)
+{
+ return objspace->sweeping_heap_count != 0;
+}
+
+static inline size_t
+heap_eden_total_pages(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ count += (&heaps[i])->total_pages;
+ }
+ return count;
+}
+
+static inline size_t
+total_allocated_objects(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ count += heap->total_allocated_objects;
+ }
+ return count;
+}
+
+static inline size_t
+total_freed_objects(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ count += heap->total_freed_objects;
+ }
+ return count;
+}
+
+static inline size_t
+total_final_slots_count(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ count += heap->final_slots_count;
+ }
+ return count;
+}
+
+#define gc_mode(objspace) gc_mode_verify((enum gc_mode)(objspace)->flags.mode)
+#define gc_mode_set(objspace, m) ((objspace)->flags.mode = (unsigned int)gc_mode_verify(m))
+#define gc_needs_major_flags objspace->rgengc.need_major_gc
+
+#define is_marking(objspace) (gc_mode(objspace) == gc_mode_marking)
+#define is_sweeping(objspace) (gc_mode(objspace) == gc_mode_sweeping)
+#define is_full_marking(objspace) ((objspace)->flags.during_minor_gc == FALSE)
+#define is_incremental_marking(objspace) ((objspace)->flags.during_incremental_marking != FALSE)
+#define will_be_incremental_marking(objspace) ((objspace)->rgengc.need_major_gc != GPR_FLAG_NONE)
+/*
+ * Byte budget for incremental sweep steps. Each step sweeps at most
+ * this many bytes worth of slots before yielding. The effective slot
+ * count per step is GC_INCREMENTAL_SWEEP_BYTES / heap->slot_size,
+ * so larger slot pools (which are less heavily used) naturally get
+ * fewer slots swept per step.
+ *
+ * Baseline: 2048 slots * RVALUE_SLOT_SIZE = 2048 * 40 = 81920 bytes,
+ * preserving the historical behavior for the smallest heap.
+ */
+#define GC_INCREMENTAL_SWEEP_BYTES (2048 * RVALUE_SLOT_SIZE)
+#define GC_INCREMENTAL_SWEEP_POOL_BYTES (1024 * RVALUE_SLOT_SIZE)
+#define is_lazy_sweeping(objspace) (GC_ENABLE_LAZY_SWEEP && has_sweeping_pages(objspace))
+/* In lazy sweeping or the previous incremental marking finished and did not yield a free page. */
+#define needs_continue_sweeping(objspace, heap) \
+ ((heap)->free_pages == NULL && is_lazy_sweeping(objspace))
+
+#if SIZEOF_LONG == SIZEOF_VOIDP
+# define obj_id_to_ref(objid) ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+# define obj_id_to_ref(objid) (FIXNUM_P(objid) ? \
+ ((objid) ^ FIXNUM_FLAG) : (NUM2PTR(objid) << 1))
+#else
+# error not supported
+#endif
+
+struct RZombie {
+ VALUE flags;
+ VALUE next;
+ void (*dfree)(void *);
+ void *data;
+};
+
+#define RZOMBIE(o) ((struct RZombie *)(o))
+
+static bool ruby_enable_autocompact = false;
+#if RGENGC_CHECK_MODE
+static gc_compact_compare_func ruby_autocompact_compare_func;
+#endif
+
+static void init_mark_stack(mark_stack_t *stack);
+static int garbage_collect(rb_objspace_t *, unsigned int reason);
+
+static int gc_start(rb_objspace_t *objspace, unsigned int reason);
+static void gc_rest(rb_objspace_t *objspace);
+
+enum gc_enter_event {
+ gc_enter_event_start,
+ gc_enter_event_continue,
+ gc_enter_event_rest,
+ gc_enter_event_finalizer,
+};
+
+static inline void gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
+static inline void gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
+static void gc_marking_enter(rb_objspace_t *objspace);
+static void gc_marking_exit(rb_objspace_t *objspace);
+static void gc_sweeping_enter(rb_objspace_t *objspace);
+static void gc_sweeping_exit(rb_objspace_t *objspace);
+static bool gc_marks_continue(rb_objspace_t *objspace, rb_heap_t *heap);
+
+static void gc_sweep(rb_objspace_t *objspace);
+static void gc_sweep_finish_heap(rb_objspace_t *objspace, rb_heap_t *heap);
+static void gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *heap);
+
+static inline void gc_mark(rb_objspace_t *objspace, VALUE ptr);
+static inline void gc_pin(rb_objspace_t *objspace, VALUE ptr);
+static inline void gc_mark_and_pin(rb_objspace_t *objspace, VALUE ptr);
+
+static int gc_mark_stacked_objects_incremental(rb_objspace_t *, size_t count);
+NO_SANITIZE("memory", static inline bool is_pointer_to_heap(rb_objspace_t *objspace, const void *ptr));
+
+static void gc_verify_internal_consistency(void *objspace_ptr);
+
+static double getrusage_time(void);
+static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, unsigned int reason);
+static inline void gc_prof_timer_start(rb_objspace_t *);
+static inline void gc_prof_timer_stop(rb_objspace_t *);
+static inline void gc_prof_mark_timer_start(rb_objspace_t *);
+static inline void gc_prof_mark_timer_stop(rb_objspace_t *);
+static inline void gc_prof_sweep_timer_start(rb_objspace_t *);
+static inline void gc_prof_sweep_timer_stop(rb_objspace_t *);
+static inline void gc_prof_set_malloc_info(rb_objspace_t *);
+static inline void gc_prof_set_heap_info(rb_objspace_t *);
+
+#define gc_prof_record(objspace) (objspace)->profile.current_record
+#define gc_prof_enabled(objspace) ((objspace)->profile.run && (objspace)->profile.current_record)
+
+#ifdef HAVE_VA_ARGS_MACRO
+# define gc_report(level, objspace, ...) \
+ if (!RGENGC_DEBUG_ENABLED(level)) {} else gc_report_body(level, objspace, __VA_ARGS__)
+#else
+# define gc_report if (!RGENGC_DEBUG_ENABLED(0)) {} else gc_report_body
+#endif
+PRINTF_ARGS(static void gc_report_body(int level, rb_objspace_t *objspace, const char *fmt, ...), 3, 4);
+
+static void gc_finalize_deferred(void *dmy);
+
+#if USE_TICK_T
+
+/* the following code is only for internal tuning. */
+
+/* Source code to use RDTSC is quoted and modified from
+ * https://www.mcs.anl.gov/~kazutomo/rdtsc.html
+ * written by Kazutomo Yoshii <kazutomo@mcs.anl.gov>
+ */
+
+#if defined(__GNUC__) && defined(__i386__)
+typedef unsigned long long tick_t;
+#define PRItick "llu"
+static inline tick_t
+tick(void)
+{
+ unsigned long long int x;
+ __asm__ __volatile__ ("rdtsc" : "=A" (x));
+ return x;
+}
+
+#elif defined(__GNUC__) && defined(__x86_64__)
+typedef unsigned long long tick_t;
+#define PRItick "llu"
+
+static __inline__ tick_t
+tick(void)
+{
+ unsigned long hi, lo;
+ __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
+ return ((unsigned long long)lo)|( ((unsigned long long)hi)<<32);
+}
+
+#elif defined(__powerpc64__) && (GCC_VERSION_SINCE(4,8,0) || defined(__clang__))
+typedef unsigned long long tick_t;
+#define PRItick "llu"
+
+static __inline__ tick_t
+tick(void)
+{
+ unsigned long long val = __builtin_ppc_get_timebase();
+ return val;
+}
+
+#elif defined(__POWERPC__) && defined(__APPLE__)
+/* Implementation for macOS PPC by @nobu
+ * See: https://github.com/ruby/ruby/pull/5975#discussion_r890045558
+ */
+typedef unsigned long long tick_t;
+#define PRItick "llu"
+
+static __inline__ tick_t
+tick(void)
+{
+ unsigned long int upper, lower, tmp;
+ # define mftbu(r) __asm__ volatile("mftbu %0" : "=r"(r))
+ # define mftb(r) __asm__ volatile("mftb %0" : "=r"(r))
+ do {
+ mftbu(upper);
+ mftb(lower);
+ mftbu(tmp);
+ } while (tmp != upper);
+ return ((tick_t)upper << 32) | lower;
+}
+
+#elif defined(__aarch64__) && defined(__GNUC__)
+typedef unsigned long tick_t;
+#define PRItick "lu"
+
+static __inline__ tick_t
+tick(void)
+{
+ unsigned long val;
+ __asm__ __volatile__ ("mrs %0, cntvct_el0" : "=r" (val));
+ return val;
+}
+
+
+#elif defined(_WIN32) && defined(_MSC_VER)
+#include <intrin.h>
+typedef unsigned __int64 tick_t;
+#define PRItick "llu"
+
+static inline tick_t
+tick(void)
+{
+ return __rdtsc();
+}
+
+#else /* use clock */
+typedef clock_t tick_t;
+#define PRItick "llu"
+
+static inline tick_t
+tick(void)
+{
+ return clock();
+}
+#endif /* TSC */
+#else /* USE_TICK_T */
+#define MEASURE_LINE(expr) expr
+#endif /* USE_TICK_T */
+
+static inline VALUE check_rvalue_consistency(rb_objspace_t *objspace, const VALUE obj);
+
+#define RVALUE_MARKED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), (obj))
+#define RVALUE_WB_UNPROTECTED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), (obj))
+#define RVALUE_MARKING_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), (obj))
+#define RVALUE_UNCOLLECTIBLE_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), (obj))
+#define RVALUE_PINNED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), (obj))
+
+static inline int
+RVALUE_MARKED(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return RVALUE_MARKED_BITMAP(obj) != 0;
+}
+
+static inline int
+RVALUE_PINNED(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return RVALUE_PINNED_BITMAP(obj) != 0;
+}
+
+static inline int
+RVALUE_WB_UNPROTECTED(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
+}
+
+static inline int
+RVALUE_MARKING(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return RVALUE_MARKING_BITMAP(obj) != 0;
+}
+
+static inline int
+RVALUE_REMEMBERED(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return MARKED_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj) != 0;
+}
+
+static inline int
+RVALUE_UNCOLLECTIBLE(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ return RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
+}
+
+#define RVALUE_PAGE_WB_UNPROTECTED(page, obj) MARKED_IN_BITMAP((page)->wb_unprotected_bits, (obj))
+#define RVALUE_PAGE_UNCOLLECTIBLE(page, obj) MARKED_IN_BITMAP((page)->uncollectible_bits, (obj))
+#define RVALUE_PAGE_MARKING(page, obj) MARKED_IN_BITMAP((page)->marking_bits, (obj))
+
+static int rgengc_remember(rb_objspace_t *objspace, VALUE obj);
+static void rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap);
+static void rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap);
+
+static int
+check_rvalue_consistency_force(rb_objspace_t *objspace, const VALUE obj, int terminate)
+{
+ int err = 0;
+
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ if (SPECIAL_CONST_P(obj)) {
+ fprintf(stderr, "check_rvalue_consistency: %p is a special const.\n", (void *)obj);
+ err++;
+ }
+ else if (!is_pointer_to_heap(objspace, (void *)obj)) {
+ struct heap_page *empty_page = objspace->empty_pages;
+ while (empty_page) {
+ if ((uintptr_t)empty_page->body <= (uintptr_t)obj &&
+ (uintptr_t)obj < (uintptr_t)empty_page->body + HEAP_PAGE_SIZE) {
+ GC_ASSERT(heap_page_in_global_empty_pages_pool(objspace, empty_page));
+ fprintf(stderr, "check_rvalue_consistency: %p is in an empty page (%p).\n",
+ (void *)obj, (void *)empty_page);
+ err++;
+ goto skip;
+ }
+ }
+ fprintf(stderr, "check_rvalue_consistency: %p is not a Ruby object.\n", (void *)obj);
+ err++;
+ skip:
+ ;
+ }
+ else {
+ const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
+ const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
+ const int mark_bit = RVALUE_MARKED_BITMAP(obj) != 0;
+ const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0;
+ const int remembered_bit = MARKED_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj) != 0;
+ const int age = RVALUE_AGE_GET((VALUE)obj);
+
+ if (heap_page_in_global_empty_pages_pool(objspace, GET_HEAP_PAGE(obj))) {
+ fprintf(stderr, "check_rvalue_consistency: %s is in tomb page.\n", rb_obj_info(obj));
+ err++;
+ }
+ if (BUILTIN_TYPE(obj) == T_NONE) {
+ fprintf(stderr, "check_rvalue_consistency: %s is T_NONE.\n", rb_obj_info(obj));
+ err++;
+ }
+ if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
+ fprintf(stderr, "check_rvalue_consistency: %s is T_ZOMBIE.\n", rb_obj_info(obj));
+ err++;
+ }
+
+ if (BUILTIN_TYPE(obj) != T_DATA) {
+ rb_obj_memsize_of((VALUE)obj);
+ }
+
+ /* check generation
+ *
+ * OLD == age == 3 && old-bitmap && mark-bit (except incremental marking)
+ */
+ if (age > 0 && wb_unprotected_bit) {
+ fprintf(stderr, "check_rvalue_consistency: %s is not WB protected, but age is %d > 0.\n", rb_obj_info(obj), age);
+ err++;
+ }
+
+ if (!is_marking(objspace) && uncollectible_bit && !mark_bit) {
+ fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but is not marked while !gc.\n", rb_obj_info(obj));
+ err++;
+ }
+
+ if (!is_full_marking(objspace)) {
+ if (uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
+ fprintf(stderr, "check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.\n",
+ rb_obj_info(obj), age);
+ err++;
+ }
+ if (remembered_bit && age != RVALUE_OLD_AGE) {
+ fprintf(stderr, "check_rvalue_consistency: %s is remembered, but not old (age: %d).\n",
+ rb_obj_info(obj), age);
+ err++;
+ }
+ }
+
+ /*
+ * check coloring
+ *
+ * marking:false marking:true
+ * marked:false white *invalid*
+ * marked:true black grey
+ */
+ if (is_incremental_marking(objspace) && marking_bit) {
+ if (!is_marking(objspace) && !mark_bit) {
+ fprintf(stderr, "check_rvalue_consistency: %s is marking, but not marked.\n", rb_obj_info(obj));
+ err++;
+ }
+ }
+ }
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+
+ if (err > 0 && terminate) {
+ rb_bug("check_rvalue_consistency_force: there is %d errors.", err);
+ }
+ return err;
+}
+
+#if RGENGC_CHECK_MODE == 0
+static inline VALUE
+check_rvalue_consistency(rb_objspace_t *objspace, const VALUE obj)
+{
+ return obj;
+}
+#else
+static VALUE
+check_rvalue_consistency(rb_objspace_t *objspace, const VALUE obj)
+{
+ check_rvalue_consistency_force(objspace, obj, TRUE);
+ return obj;
+}
+#endif
+
+static inline bool
+gc_object_moved_p(rb_objspace_t *objspace, VALUE obj)
+{
+
+ bool ret;
+ asan_unpoisoning_object(obj) {
+ ret = BUILTIN_TYPE(obj) == T_MOVED;
+ }
+ return ret;
+}
+
+static inline int
+RVALUE_OLD_P(rb_objspace_t *objspace, VALUE obj)
+{
+ GC_ASSERT(!RB_SPECIAL_CONST_P(obj));
+ check_rvalue_consistency(objspace, obj);
+ // Because this will only ever be called on GC controlled objects,
+ // we can use the faster _RAW function here
+ return RB_OBJ_PROMOTED_RAW(obj);
+}
+
+static inline void
+RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
+{
+ MARK_IN_BITMAP(&page->uncollectible_bits[0], obj);
+ objspace->rgengc.old_objects++;
+
+#if RGENGC_PROFILE >= 2
+ objspace->profile.total_promoted_count++;
+ objspace->profile.promoted_types[BUILTIN_TYPE(obj)]++;
+#endif
+}
+
+static inline void
+RVALUE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, VALUE obj)
+{
+ RB_DEBUG_COUNTER_INC(obj_promote);
+ RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, GET_HEAP_PAGE(obj), obj);
+}
+
+/* set age to age+1 */
+static inline void
+RVALUE_AGE_INC(rb_objspace_t *objspace, VALUE obj)
+{
+ int age = RVALUE_AGE_GET((VALUE)obj);
+
+ if (RGENGC_CHECK_MODE && age == RVALUE_OLD_AGE) {
+ rb_bug("RVALUE_AGE_INC: can not increment age of OLD object %s.", rb_obj_info(obj));
+ }
+
+ age++;
+ RVALUE_AGE_SET(obj, age);
+
+ if (age == RVALUE_OLD_AGE) {
+ RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
+ }
+
+ check_rvalue_consistency(objspace, obj);
+}
+
+static inline void
+RVALUE_AGE_SET_CANDIDATE(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ GC_ASSERT(!RVALUE_OLD_P(objspace, obj));
+ RVALUE_AGE_SET(obj, RVALUE_OLD_AGE - 1);
+ check_rvalue_consistency(objspace, obj);
+}
+
+static inline void
+RVALUE_AGE_RESET(VALUE obj)
+{
+ RVALUE_AGE_SET(obj, 0);
+}
+
+static inline void
+RVALUE_DEMOTE(rb_objspace_t *objspace, VALUE obj)
+{
+ check_rvalue_consistency(objspace, obj);
+ GC_ASSERT(RVALUE_OLD_P(objspace, obj));
+
+ if (!is_incremental_marking(objspace) && RVALUE_REMEMBERED(objspace, obj)) {
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj);
+ }
+
+ CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), obj);
+ RVALUE_AGE_RESET(obj);
+
+ if (RVALUE_MARKED(objspace, obj)) {
+ objspace->rgengc.old_objects--;
+ }
+
+ check_rvalue_consistency(objspace, obj);
+}
+
+static inline int
+RVALUE_BLACK_P(rb_objspace_t *objspace, VALUE obj)
+{
+ return RVALUE_MARKED(objspace, obj) && !RVALUE_MARKING(objspace, obj);
+}
+
+static inline int
+RVALUE_WHITE_P(rb_objspace_t *objspace, VALUE obj)
+{
+ return !RVALUE_MARKED(objspace, obj);
+}
+
+bool
+rb_gc_impl_gc_enabled_p(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ return !dont_gc_val();
+}
+
+void
+rb_gc_impl_gc_enable(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ dont_gc_off();
+}
+
+void
+rb_gc_impl_gc_disable(void *objspace_ptr, bool finish_current_gc)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (finish_current_gc) {
+ gc_rest(objspace);
+ }
+
+ dont_gc_on();
+}
+
+/*
+ --------------------------- ObjectSpace -----------------------------
+*/
+
+static inline void *
+calloc1(size_t n)
+{
+ return calloc(1, n);
+}
+
+void
+rb_gc_impl_set_event_hook(void *objspace_ptr, const rb_event_flag_t event)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ objspace->hook_events = event & RUBY_INTERNAL_EVENT_OBJSPACE_MASK;
+}
+
+unsigned long long
+rb_gc_impl_get_total_time(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ unsigned long long marking_time = objspace->profile.marking_time_ns;
+ unsigned long long sweeping_time = objspace->profile.sweeping_time_ns;
+
+ return marking_time + sweeping_time;
+}
+
+void
+rb_gc_impl_set_measure_total_time(void *objspace_ptr, VALUE flag)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ objspace->flags.measure_gc = RTEST(flag) ? TRUE : FALSE;
+}
+
+bool
+rb_gc_impl_get_measure_total_time(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ return objspace->flags.measure_gc;
+}
+
+/* garbage objects will be collected soon. */
+bool
+rb_gc_impl_garbage_object_p(void *objspace_ptr, VALUE ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ bool dead = false;
+
+ asan_unpoisoning_object(ptr) {
+ switch (BUILTIN_TYPE(ptr)) {
+ case T_NONE:
+ case T_MOVED:
+ case T_ZOMBIE:
+ dead = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (dead) return true;
+ return is_lazy_sweeping(objspace) && GET_HEAP_PAGE(ptr)->flags.before_sweep &&
+ !RVALUE_MARKED(objspace, ptr);
+}
+
+struct rb_gc_vm_context *
+rb_gc_impl_get_vm_context(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ return &objspace->vm_context;
+}
+
+static void free_stack_chunks(mark_stack_t *);
+static void mark_stack_free_cache(mark_stack_t *);
+static void heap_page_free(rb_objspace_t *objspace, struct heap_page *page);
+
+static inline void
+heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
+{
+ rb_asan_unpoison_object(obj, false);
+
+ asan_unlock_freelist(page);
+
+ struct free_slot *slot = (struct free_slot *)obj;
+ slot->flags = 0;
+ slot->next = page->freelist;
+ page->freelist = slot;
+ asan_lock_freelist(page);
+
+ // Should have already been reset
+ GC_ASSERT(RVALUE_AGE_GET(obj) == 0);
+
+ if (RGENGC_CHECK_MODE &&
+ /* obj should belong to page */
+ !(page->start <= (uintptr_t)obj &&
+ (uintptr_t)obj < ((uintptr_t)page->start + (page->total_slots * page->slot_size)) &&
+ obj % sizeof(VALUE) == 0)) {
+ rb_bug("heap_page_add_freeobj: %p is not rvalue.", (void *)obj);
+ }
+
+ rb_asan_poison_object(obj);
+ gc_report(3, objspace, "heap_page_add_freeobj: add %p to freelist\n", (void *)obj);
+}
+
+static void
+heap_allocatable_bytes_expand(rb_objspace_t *objspace,
+ rb_heap_t *heap, size_t free_slots, size_t total_slots, size_t slot_size)
+{
+ double goal_ratio = gc_params.heap_free_slots_goal_ratio;
+ size_t target_total_slots;
+
+ if (goal_ratio == 0.0) {
+ target_total_slots = (size_t)(total_slots * gc_params.growth_factor);
+ }
+ else if (total_slots == 0) {
+ target_total_slots = gc_params.heap_init_bytes / slot_size;
+ }
+ else {
+ /* Find `f' where free_slots = f * total_slots * goal_ratio
+ * => f = (total_slots - free_slots) / ((1 - goal_ratio) * total_slots)
+ */
+ double f = (double)(total_slots - free_slots) / ((1 - goal_ratio) * total_slots);
+
+ if (f > gc_params.growth_factor) f = gc_params.growth_factor;
+ if (f < 1.0) f = 1.1;
+
+ target_total_slots = (size_t)(f * total_slots);
+
+ if (0) {
+ fprintf(stderr,
+ "free_slots(%8"PRIuSIZE")/total_slots(%8"PRIuSIZE")=%1.2f,"
+ " G(%1.2f), f(%1.2f),"
+ " total_slots(%8"PRIuSIZE") => target_total_slots(%8"PRIuSIZE")\n",
+ free_slots, total_slots, free_slots/(double)total_slots,
+ goal_ratio, f, total_slots, target_total_slots);
+ }
+ }
+
+ if (gc_params.growth_max_bytes > 0) {
+ size_t max_total_slots = total_slots + gc_params.growth_max_bytes / slot_size;
+ if (target_total_slots > max_total_slots) target_total_slots = max_total_slots;
+ }
+
+ size_t extend_slot_count = target_total_slots - total_slots;
+ /* Extend by at least 1 page. */
+ if (extend_slot_count == 0) extend_slot_count = 1;
+
+ objspace->heap_pages.allocatable_bytes += extend_slot_count * slot_size;
+}
+
+static inline void
+heap_add_freepage(rb_heap_t *heap, struct heap_page *page)
+{
+ asan_unlock_freelist(page);
+ GC_ASSERT(page->free_slots != 0);
+ GC_ASSERT(page->freelist != NULL);
+
+ page->free_next = heap->free_pages;
+ heap->free_pages = page;
+
+ RUBY_DEBUG_LOG("page:%p freelist:%p", (void *)page, (void *)page->freelist);
+
+ asan_lock_freelist(page);
+}
+
+static inline void
+heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+{
+ asan_unlock_freelist(page);
+ GC_ASSERT(page->free_slots != 0);
+ GC_ASSERT(page->freelist != NULL);
+
+ page->free_next = heap->pooled_pages;
+ heap->pooled_pages = page;
+ objspace->rincgc.pooled_slots += page->free_slots;
+
+ asan_lock_freelist(page);
+}
+
+static void
+heap_unlink_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+{
+ ccan_list_del(&page->page_node);
+ heap->total_pages--;
+ heap->total_slots -= page->total_slots;
+}
+
+static void
+gc_aligned_free(void *ptr, size_t size)
+{
+#if defined __MINGW32__
+ __mingw_aligned_free(ptr);
+#elif defined _WIN32
+ _aligned_free(ptr);
+#elif defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)
+ free(ptr);
+#else
+ free(((void**)ptr)[-1]);
+#endif
+}
+
+static void
+heap_page_body_free(struct heap_page_body *page_body)
+{
+ GC_ASSERT((uintptr_t)page_body % HEAP_PAGE_ALIGN == 0);
+
+ if (HEAP_PAGE_ALLOC_USE_MMAP) {
+#ifdef HAVE_MMAP
+ GC_ASSERT(HEAP_PAGE_SIZE % sysconf(_SC_PAGE_SIZE) == 0);
+ if (munmap(page_body, HEAP_PAGE_SIZE)) {
+ rb_bug("heap_page_body_free: munmap failed");
+ }
+#endif
+ }
+ else {
+ gc_aligned_free(page_body, HEAP_PAGE_SIZE);
+ }
+}
+
+static void
+heap_page_free(rb_objspace_t *objspace, struct heap_page *page)
+{
+ objspace->heap_pages.freed_pages++;
+ heap_page_body_free(page->body);
+ free(page);
+}
+
+static void
+heap_pages_free_unused_pages(rb_objspace_t *objspace)
+{
+ if (objspace->empty_pages != NULL && heap_pages_freeable_pages > 0) {
+ GC_ASSERT(objspace->empty_pages_count > 0);
+ objspace->empty_pages = NULL;
+ objspace->empty_pages_count = 0;
+
+ size_t i, j;
+ for (i = j = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ struct heap_page *page = rb_darray_get(objspace->heap_pages.sorted, i);
+
+ if (heap_page_in_global_empty_pages_pool(objspace, page) && heap_pages_freeable_pages > 0) {
+ heap_page_free(objspace, page);
+ heap_pages_freeable_pages--;
+ }
+ else {
+ if (heap_page_in_global_empty_pages_pool(objspace, page)) {
+ page->free_next = objspace->empty_pages;
+ objspace->empty_pages = page;
+ objspace->empty_pages_count++;
+ }
+
+ if (i != j) {
+ rb_darray_set(objspace->heap_pages.sorted, j, page);
+ }
+ j++;
+ }
+ }
+
+ rb_darray_pop(objspace->heap_pages.sorted, i - j);
+ GC_ASSERT(rb_darray_size(objspace->heap_pages.sorted) == j);
+
+ struct heap_page *hipage = rb_darray_get(objspace->heap_pages.sorted, rb_darray_size(objspace->heap_pages.sorted) - 1);
+ uintptr_t himem = (uintptr_t)hipage->body + HEAP_PAGE_SIZE;
+ GC_ASSERT(himem <= heap_pages_himem);
+ heap_pages_himem = himem;
+
+ struct heap_page *lopage = rb_darray_get(objspace->heap_pages.sorted, 0);
+ uintptr_t lomem = (uintptr_t)lopage->body + sizeof(struct heap_page_header);
+ GC_ASSERT(lomem >= heap_pages_lomem);
+ heap_pages_lomem = lomem;
+ }
+}
+
+static void *
+gc_aligned_malloc(size_t alignment, size_t size)
+{
+ /* alignment must be a power of 2 */
+ GC_ASSERT(((alignment - 1) & alignment) == 0);
+ GC_ASSERT(alignment % sizeof(void*) == 0);
+
+ void *res;
+
+#if defined __MINGW32__
+ res = __mingw_aligned_malloc(size, alignment);
+#elif defined _WIN32
+ void *_aligned_malloc(size_t, size_t);
+ res = _aligned_malloc(size, alignment);
+#elif defined(HAVE_POSIX_MEMALIGN)
+ if (posix_memalign(&res, alignment, size) != 0) {
+ return NULL;
+ }
+#elif defined(HAVE_MEMALIGN)
+ res = memalign(alignment, size);
+#else
+ char* aligned;
+ res = malloc(alignment + size + sizeof(void*));
+ aligned = (char*)res + alignment + sizeof(void*);
+ aligned -= ((VALUE)aligned & (alignment - 1));
+ ((void**)aligned)[-1] = res;
+ res = (void*)aligned;
+#endif
+
+ GC_ASSERT((uintptr_t)res % alignment == 0);
+
+ return res;
+}
+
+static struct heap_page_body *
+heap_page_body_allocate(void)
+{
+ struct heap_page_body *page_body;
+
+ if (HEAP_PAGE_ALLOC_USE_MMAP) {
+#ifdef HAVE_MMAP
+ GC_ASSERT(HEAP_PAGE_ALIGN % sysconf(_SC_PAGE_SIZE) == 0);
+
+ size_t mmap_size = HEAP_PAGE_ALIGN + HEAP_PAGE_SIZE;
+ char *ptr = mmap(NULL, mmap_size,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (ptr == MAP_FAILED) {
+ return NULL;
+ }
+
+ // If we are building `default.c` as part of the ruby executable, we
+ // may just call `ruby_annotate_mmap`. But if we are building
+ // `default.c` as a shared library, we will not have access to private
+ // symbols, and we have to either call prctl directly or make our own
+ // wrapper.
+#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, mmap_size, "Ruby:GC:default:heap_page_body_allocate");
+ errno = 0;
+#endif
+
+ char *aligned = ptr + HEAP_PAGE_ALIGN;
+ aligned -= ((VALUE)aligned & (HEAP_PAGE_ALIGN - 1));
+ GC_ASSERT(aligned > ptr);
+ GC_ASSERT(aligned <= ptr + HEAP_PAGE_ALIGN);
+
+ size_t start_out_of_range_size = aligned - ptr;
+ GC_ASSERT(start_out_of_range_size % sysconf(_SC_PAGE_SIZE) == 0);
+ if (start_out_of_range_size > 0) {
+ if (munmap(ptr, start_out_of_range_size)) {
+ rb_bug("heap_page_body_allocate: munmap failed for start");
+ }
+ }
+
+ size_t end_out_of_range_size = HEAP_PAGE_ALIGN - start_out_of_range_size;
+ GC_ASSERT(end_out_of_range_size % sysconf(_SC_PAGE_SIZE) == 0);
+ if (end_out_of_range_size > 0) {
+ if (munmap(aligned + HEAP_PAGE_SIZE, end_out_of_range_size)) {
+ rb_bug("heap_page_body_allocate: munmap failed for end");
+ }
+ }
+
+ page_body = (struct heap_page_body *)aligned;
+#endif
+ }
+ else {
+ page_body = gc_aligned_malloc(HEAP_PAGE_ALIGN, HEAP_PAGE_SIZE);
+ }
+
+ GC_ASSERT((uintptr_t)page_body % HEAP_PAGE_ALIGN == 0);
+
+ return page_body;
+}
+
+static struct heap_page *
+heap_page_resurrect(rb_objspace_t *objspace)
+{
+ struct heap_page *page = NULL;
+ if (objspace->empty_pages == NULL) {
+ GC_ASSERT(objspace->empty_pages_count == 0);
+ }
+ else {
+ GC_ASSERT(objspace->empty_pages_count > 0);
+ objspace->empty_pages_count--;
+ page = objspace->empty_pages;
+ objspace->empty_pages = page->free_next;
+ }
+
+ return page;
+}
+
+static struct heap_page *
+heap_page_allocate(rb_objspace_t *objspace)
+{
+ struct heap_page_body *page_body = heap_page_body_allocate();
+ if (page_body == 0) {
+ rb_memerror();
+ }
+
+ struct heap_page *page = calloc1(sizeof(struct heap_page));
+ if (page == 0) {
+ heap_page_body_free(page_body);
+ rb_memerror();
+ }
+
+ uintptr_t start = (uintptr_t)page_body + sizeof(struct heap_page_header);
+ uintptr_t end = (uintptr_t)page_body + HEAP_PAGE_SIZE;
+
+ size_t lo = 0;
+ size_t hi = rb_darray_size(objspace->heap_pages.sorted);
+ while (lo < hi) {
+ struct heap_page *mid_page;
+
+ size_t mid = (lo + hi) / 2;
+ mid_page = rb_darray_get(objspace->heap_pages.sorted, mid);
+ if ((uintptr_t)mid_page->start < start) {
+ lo = mid + 1;
+ }
+ else if ((uintptr_t)mid_page->start > start) {
+ hi = mid;
+ }
+ else {
+ rb_bug("same heap page is allocated: %p at %"PRIuVALUE, (void *)page_body, (VALUE)mid);
+ }
+ }
+
+ rb_darray_insert_without_gc(&objspace->heap_pages.sorted, hi, page);
+
+ if (heap_pages_lomem == 0 || heap_pages_lomem > start) heap_pages_lomem = start;
+ if (heap_pages_himem < end) heap_pages_himem = end;
+
+ page->body = page_body;
+ page_body->header.page = page;
+
+ objspace->heap_pages.allocated_pages++;
+
+ return page;
+}
+
+static void
+heap_add_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+{
+ /* Adding to eden heap during incremental sweeping is forbidden */
+ GC_ASSERT(!heap->sweeping_page);
+ GC_ASSERT(heap_page_in_global_empty_pages_pool(objspace, page));
+
+ /* Align start to slot_size boundary */
+ uintptr_t start = (uintptr_t)page->body + sizeof(struct heap_page_header);
+ uintptr_t rem = start % heap->slot_size;
+ if (rem) start += heap->slot_size - rem;
+
+ int slot_count = (int)((HEAP_PAGE_SIZE - (start - (uintptr_t)page->body))/heap->slot_size);
+
+ page->start = start;
+ page->total_slots = slot_count;
+ page->slot_size = heap->slot_size;
+ page->slot_size_reciprocal = heap_slot_reciprocal_table[heap - heaps];
+ page->heap = heap;
+
+ memset(&page->wb_unprotected_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->age_bits[0], 0, sizeof(page->age_bits));
+
+ asan_unlock_freelist(page);
+ page->freelist = NULL;
+ asan_unpoison_memory_region(page->body, HEAP_PAGE_SIZE, false);
+ for (VALUE p = (VALUE)start; p < start + (slot_count * heap->slot_size); p += heap->slot_size) {
+ heap_page_add_freeobj(objspace, page, p);
+ }
+ asan_lock_freelist(page);
+
+ page->free_slots = slot_count;
+
+ heap->total_allocated_pages++;
+
+ ccan_list_add_tail(&heap->pages, &page->page_node);
+ heap->total_pages++;
+ heap->total_slots += page->total_slots;
+}
+
+static int
+heap_page_allocate_and_initialize(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ gc_report(1, objspace, "heap_page_allocate_and_initialize: rb_darray_size(objspace->heap_pages.sorted): %"PRIdSIZE", "
+ "allocatable_bytes: %"PRIdSIZE", heap->total_pages: %"PRIdSIZE"\n",
+ rb_darray_size(objspace->heap_pages.sorted), objspace->heap_pages.allocatable_bytes, heap->total_pages);
+
+ bool allocated = false;
+ struct heap_page *page = heap_page_resurrect(objspace);
+
+ if (page == NULL && objspace->heap_pages.allocatable_bytes > 0) {
+ page = heap_page_allocate(objspace);
+ allocated = true;
+
+ GC_ASSERT(page != NULL);
+ }
+
+ if (page != NULL) {
+ heap_add_page(objspace, heap, page);
+ heap_add_freepage(heap, page);
+
+ if (allocated) {
+ size_t page_bytes = (size_t)page->total_slots * page->slot_size;
+ if (objspace->heap_pages.allocatable_bytes > page_bytes) {
+ objspace->heap_pages.allocatable_bytes -= page_bytes;
+ }
+ else {
+ objspace->heap_pages.allocatable_bytes = 0;
+ }
+ }
+ }
+
+ return page != NULL;
+}
+
+static void
+heap_page_allocate_and_initialize_force(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ size_t prev_allocatable_bytes = objspace->heap_pages.allocatable_bytes;
+ objspace->heap_pages.allocatable_bytes = HEAP_PAGE_SIZE;
+ heap_page_allocate_and_initialize(objspace, heap);
+ GC_ASSERT(heap->free_pages != NULL);
+ objspace->heap_pages.allocatable_bytes = prev_allocatable_bytes;
+}
+
+static void
+gc_continue(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ unsigned int lock_lev;
+ bool needs_gc = is_incremental_marking(objspace) || needs_continue_sweeping(objspace, heap);
+ if (!needs_gc) return;
+
+ gc_enter(objspace, gc_enter_event_continue, &lock_lev); // takes vm barrier, try to avoid
+
+ /* Continue marking if in incremental marking. */
+ if (is_incremental_marking(objspace)) {
+ if (gc_marks_continue(objspace, heap)) {
+ gc_sweep(objspace);
+ }
+ }
+
+ if (needs_continue_sweeping(objspace, heap)) {
+ gc_sweep_continue(objspace, heap);
+ }
+
+ gc_exit(objspace, gc_enter_event_continue, &lock_lev);
+}
+
+static void
+heap_prepare(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ GC_ASSERT(heap->free_pages == NULL);
+
+ if (heap->total_slots < gc_params.heap_init_bytes / heap->slot_size &&
+ heap->sweeping_page == NULL) {
+ heap_page_allocate_and_initialize_force(objspace, heap);
+ GC_ASSERT(heap->free_pages != NULL);
+ return;
+ }
+
+ /* Continue incremental marking or lazy sweeping, if in any of those steps. */
+ gc_continue(objspace, heap);
+
+ if (heap->free_pages == NULL) {
+ heap_page_allocate_and_initialize(objspace, heap);
+ }
+
+ /* If we still don't have a free page and not allowed to create a new page,
+ * we should start a new GC cycle. */
+ if (heap->free_pages == NULL) {
+ GC_ASSERT(objspace->empty_pages_count == 0);
+ GC_ASSERT(objspace->heap_pages.allocatable_bytes == 0);
+
+ if (gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
+ rb_memerror();
+ }
+ else {
+ if (objspace->heap_pages.allocatable_bytes == 0 && !gc_config_full_mark_val) {
+ heap_allocatable_bytes_expand(objspace, heap,
+ heap->freed_slots + heap->empty_slots,
+ heap->total_slots, heap->slot_size);
+ GC_ASSERT(objspace->heap_pages.allocatable_bytes > 0);
+ }
+ /* Do steps of incremental marking or lazy sweeping if the GC run permits. */
+ gc_continue(objspace, heap);
+
+ /* If we're not incremental marking (e.g. a minor GC) or finished
+ * sweeping and still don't have a free page, then
+ * gc_sweep_finish_heap should allow us to create a new page. */
+ if (heap->free_pages == NULL && !heap_page_allocate_and_initialize(objspace, heap)) {
+ if (gc_needs_major_flags == GPR_FLAG_NONE) {
+ rb_bug("cannot create a new page after GC");
+ }
+ else { // Major GC is required, which will allow us to create new page
+ if (gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
+ rb_memerror();
+ }
+ else {
+ /* Do steps of incremental marking or lazy sweeping. */
+ gc_continue(objspace, heap);
+
+ if (heap->free_pages == NULL &&
+ !heap_page_allocate_and_initialize(objspace, heap)) {
+ rb_bug("cannot create a new page after major GC");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ GC_ASSERT(heap->free_pages != NULL);
+}
+
+#if GC_DEBUG
+static inline const char*
+rb_gc_impl_source_location_cstr(int *ptr)
+{
+ /* We could directly refer `rb_source_location_cstr()` before, but not any
+ * longer. We have to heavy lift using our debugging API. */
+ if (! ptr) {
+ return NULL;
+ }
+ else if (! (*ptr = rb_sourceline())) {
+ return NULL;
+ }
+ else {
+ return rb_sourcefile();
+ }
+}
+#endif
+
+static inline VALUE
+newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, VALUE obj)
+{
+ GC_ASSERT(BUILTIN_TYPE(obj) == T_NONE);
+ GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
+ RBASIC(obj)->flags = flags;
+ *((VALUE *)&RBASIC(obj)->klass) = klass;
+#if RBASIC_SHAPE_ID_FIELD
+ RBASIC(obj)->shape_id = 0;
+#endif
+
+#if RGENGC_CHECK_MODE
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ check_rvalue_consistency(objspace, obj);
+
+ GC_ASSERT(RVALUE_MARKED(objspace, obj) == FALSE);
+ GC_ASSERT(RVALUE_MARKING(objspace, obj) == FALSE);
+ GC_ASSERT(RVALUE_OLD_P(objspace, obj) == FALSE);
+ GC_ASSERT(RVALUE_WB_UNPROTECTED(objspace, obj) == FALSE);
+
+ if (RVALUE_REMEMBERED(objspace, obj)) rb_bug("newobj: %s is remembered.", rb_obj_info(obj));
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+#endif
+
+ if (RB_UNLIKELY(wb_protected == FALSE)) {
+ MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
+ }
+
+#if RGENGC_PROFILE
+ if (wb_protected) {
+ objspace->profile.total_generated_normal_object_count++;
+#if RGENGC_PROFILE >= 2
+ objspace->profile.generated_normal_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+ }
+ else {
+ objspace->profile.total_generated_shady_object_count++;
+#if RGENGC_PROFILE >= 2
+ objspace->profile.generated_shady_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+ }
+#endif
+
+#if GC_DEBUG
+ GET_RVALUE_OVERHEAD(obj)->file = rb_gc_impl_source_location_cstr(&GET_RVALUE_OVERHEAD(obj)->line);
+ GC_ASSERT(!SPECIAL_CONST_P(obj)); /* check alignment */
+#endif
+
+ gc_report(5, objspace, "newobj: %s\n", rb_obj_info(obj));
+
+ // RUBY_DEBUG_LOG("obj:%p (%s)", (void *)obj, rb_obj_info(obj));
+ return obj;
+}
+
+size_t
+rb_gc_impl_obj_slot_size(VALUE obj)
+{
+ return GET_HEAP_PAGE(obj)->slot_size - RVALUE_OVERHEAD;
+}
+
+static inline size_t
+heap_slot_size(unsigned char pool_id)
+{
+ GC_ASSERT(pool_id < HEAP_COUNT);
+
+ return pool_slot_sizes[pool_id] - RVALUE_OVERHEAD;
+}
+
+bool
+rb_gc_impl_size_allocatable_p(size_t size)
+{
+ return size + RVALUE_OVERHEAD <= pool_slot_sizes[HEAP_COUNT - 1];
+}
+
+static const size_t ALLOCATED_COUNT_STEP = 1024;
+static void
+ractor_cache_flush_count(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache)
+{
+ for (int heap_idx = 0; heap_idx < HEAP_COUNT; heap_idx++) {
+ rb_ractor_newobj_heap_cache_t *heap_cache = &cache->heap_caches[heap_idx];
+
+ rb_heap_t *heap = &heaps[heap_idx];
+ RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, heap_cache->allocated_objects_count);
+ heap_cache->allocated_objects_count = 0;
+ }
+}
+
+static inline VALUE
+ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache,
+ size_t heap_idx)
+{
+ rb_ractor_newobj_heap_cache_t *heap_cache = &cache->heap_caches[heap_idx];
+ struct free_slot *p = heap_cache->freelist;
+
+ if (RB_UNLIKELY(is_incremental_marking(objspace))) {
+ // Not allowed to allocate without running an incremental marking step
+ if (cache->incremental_mark_step_allocated_slots >= INCREMENTAL_MARK_STEP_ALLOCATIONS) {
+ return Qfalse;
+ }
+
+ if (p) {
+ cache->incremental_mark_step_allocated_slots++;
+ }
+ }
+
+ if (RB_LIKELY(p)) {
+ VALUE obj = (VALUE)p;
+ rb_asan_unpoison_object(obj, true);
+ heap_cache->freelist = p->next;
+
+ heap_cache->allocated_objects_count++;
+ rb_heap_t *heap = &heaps[heap_idx];
+ if (heap_cache->allocated_objects_count >= ALLOCATED_COUNT_STEP) {
+ RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, heap_cache->allocated_objects_count);
+ heap_cache->allocated_objects_count = 0;
+ }
+
+#if RGENGC_CHECK_MODE
+ GC_ASSERT(rb_gc_impl_obj_slot_size(obj) == heap_slot_size(heap_idx));
+ // zero clear
+ MEMZERO((char *)obj, char, heap_slot_size(heap_idx));
+#endif
+ return obj;
+ }
+ else {
+ return Qfalse;
+ }
+}
+
+static struct heap_page *
+heap_next_free_page(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ struct heap_page *page;
+
+ if (heap->free_pages == NULL) {
+ heap_prepare(objspace, heap);
+ }
+
+ page = heap->free_pages;
+ heap->free_pages = page->free_next;
+
+ GC_ASSERT(page->free_slots != 0);
+
+ asan_unlock_freelist(page);
+
+ return page;
+}
+
+static inline void
+ractor_cache_set_page(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx,
+ struct heap_page *page)
+{
+ gc_report(3, objspace, "ractor_set_cache: Using page %p\n", (void *)page->body);
+
+ rb_ractor_newobj_heap_cache_t *heap_cache = &cache->heap_caches[heap_idx];
+
+ GC_ASSERT(heap_cache->freelist == NULL);
+ GC_ASSERT(page->free_slots != 0);
+ GC_ASSERT(page->freelist != NULL);
+
+ heap_cache->using_page = page;
+ heap_cache->freelist = page->freelist;
+ page->free_slots = 0;
+ page->freelist = NULL;
+
+ rb_asan_unpoison_object((VALUE)heap_cache->freelist, false);
+ GC_ASSERT(RB_TYPE_P((VALUE)heap_cache->freelist, T_NONE));
+ rb_asan_poison_object((VALUE)heap_cache->freelist);
+}
+
+static void
+init_size_to_heap_idx(void)
+{
+ for (size_t i = 0; i < sizeof(size_to_heap_idx); i++) {
+ size_t effective = i * 8 + RVALUE_OVERHEAD;
+ uint8_t idx;
+ for (idx = 0; idx < HEAP_COUNT; idx++) {
+ if (effective <= pool_slot_sizes[idx]) break;
+ }
+ size_to_heap_idx[i] = idx;
+ }
+}
+
+static inline size_t
+heap_idx_for_size(size_t size)
+{
+ size_t compressed = (size + 7) >> 3;
+ if (compressed < sizeof(size_to_heap_idx)) {
+ size_t heap_idx = size_to_heap_idx[compressed];
+ if (RB_LIKELY(heap_idx < HEAP_COUNT)) return heap_idx;
+ }
+
+ rb_bug("heap_idx_for_size: allocation size too large "
+ "(size=%"PRIuSIZE")", size);
+}
+
+size_t
+rb_gc_impl_heap_id_for_size(void *objspace_ptr, size_t size)
+{
+ return heap_idx_for_size(size);
+}
+
+
+static size_t heap_sizes[HEAP_COUNT + 1] = { 0 };
+
+size_t *
+rb_gc_impl_heap_sizes(void *objspace_ptr)
+{
+ if (heap_sizes[0] == 0) {
+ for (unsigned char i = 0; i < HEAP_COUNT; i++) {
+ heap_sizes[i] = heap_slot_size(i);
+ }
+ }
+
+ return heap_sizes;
+}
+
+NOINLINE(static VALUE newobj_cache_miss(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx, bool vm_locked));
+
+static VALUE
+newobj_cache_miss(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx, bool vm_locked)
+{
+ rb_heap_t *heap = &heaps[heap_idx];
+ VALUE obj = Qfalse;
+
+ unsigned int lev = 0;
+ bool unlock_vm = false;
+
+ if (!vm_locked) {
+ lev = RB_GC_CR_LOCK();
+ unlock_vm = true;
+ }
+
+ {
+ if (is_incremental_marking(objspace)) {
+ gc_continue(objspace, heap);
+ cache->incremental_mark_step_allocated_slots = 0;
+
+ // Retry allocation after resetting incremental_mark_step_allocated_slots
+ obj = ractor_cache_allocate_slot(objspace, cache, heap_idx);
+ }
+
+ if (obj == Qfalse) {
+ // Get next free page (possibly running GC)
+ struct heap_page *page = heap_next_free_page(objspace, heap);
+ ractor_cache_set_page(objspace, cache, heap_idx, page);
+
+ // Retry allocation after moving to new page
+ obj = ractor_cache_allocate_slot(objspace, cache, heap_idx);
+ }
+ }
+
+ if (unlock_vm) {
+ RB_GC_CR_UNLOCK(lev);
+ }
+
+ if (RB_UNLIKELY(obj == Qfalse)) {
+ rb_memerror();
+ }
+ return obj;
+}
+
+static VALUE
+newobj_alloc(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx, bool vm_locked)
+{
+ VALUE obj = ractor_cache_allocate_slot(objspace, cache, heap_idx);
+
+ if (RB_UNLIKELY(obj == Qfalse)) {
+ obj = newobj_cache_miss(objspace, cache, heap_idx, vm_locked);
+ }
+
+ return obj;
+}
+
+ALWAYS_INLINE(static VALUE newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, int wb_protected, size_t heap_idx));
+
+static inline VALUE
+newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, int wb_protected, size_t heap_idx)
+{
+ VALUE obj;
+ unsigned int lev;
+
+ lev = RB_GC_CR_LOCK();
+ {
+ if (RB_UNLIKELY(during_gc || ruby_gc_stressful)) {
+ if (during_gc) {
+ dont_gc_on();
+ during_gc = 0;
+ if (rb_memerror_reentered()) {
+ rb_memerror();
+ }
+ rb_bug("object allocation during garbage collection phase");
+ }
+
+ if (ruby_gc_stressful) {
+ if (!garbage_collect(objspace, GPR_FLAG_NEWOBJ)) {
+ rb_memerror();
+ }
+ }
+ }
+
+ obj = newobj_alloc(objspace, cache, heap_idx, true);
+ newobj_init(klass, flags, wb_protected, objspace, obj);
+ }
+ RB_GC_CR_UNLOCK(lev);
+
+ return obj;
+}
+
+NOINLINE(static VALUE newobj_slowpath_wb_protected(VALUE klass, VALUE flags,
+ rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx));
+NOINLINE(static VALUE newobj_slowpath_wb_unprotected(VALUE klass, VALUE flags,
+ rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx));
+
+static VALUE
+newobj_slowpath_wb_protected(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx)
+{
+ return newobj_slowpath(klass, flags, objspace, cache, TRUE, heap_idx);
+}
+
+static VALUE
+newobj_slowpath_wb_unprotected(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_newobj_cache_t *cache, size_t heap_idx)
+{
+ return newobj_slowpath(klass, flags, objspace, cache, FALSE, heap_idx);
+}
+
+VALUE
+rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags, bool wb_protected, size_t alloc_size)
+{
+ VALUE obj;
+ rb_objspace_t *objspace = objspace_ptr;
+
+ RB_DEBUG_COUNTER_INC(obj_newobj);
+ (void)RB_DEBUG_COUNTER_INC_IF(obj_newobj_wb_unprotected, !wb_protected);
+
+ if (RB_UNLIKELY(stress_to_class)) {
+ if (rb_hash_lookup2(stress_to_class, klass, Qundef) != Qundef) {
+ rb_memerror();
+ }
+ }
+
+ size_t heap_idx = heap_idx_for_size(alloc_size);
+
+ rb_ractor_newobj_cache_t *cache = (rb_ractor_newobj_cache_t *)cache_ptr;
+
+ if (!RB_UNLIKELY(during_gc || ruby_gc_stressful) &&
+ wb_protected) {
+ obj = newobj_alloc(objspace, cache, heap_idx, false);
+ newobj_init(klass, flags, wb_protected, objspace, obj);
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(obj_newobj_slowpath);
+
+ obj = wb_protected ?
+ newobj_slowpath_wb_protected(klass, flags, objspace, cache, heap_idx) :
+ newobj_slowpath_wb_unprotected(klass, flags, objspace, cache, heap_idx);
+ }
+
+ return obj;
+}
+
+static int
+ptr_in_page_body_p(const void *ptr, const void *memb)
+{
+ struct heap_page *page = *(struct heap_page **)memb;
+ uintptr_t p_body = (uintptr_t)page->body;
+
+ if ((uintptr_t)ptr >= p_body) {
+ return (uintptr_t)ptr < (p_body + HEAP_PAGE_SIZE) ? 0 : 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+PUREFUNC(static inline struct heap_page *heap_page_for_ptr(rb_objspace_t *objspace, uintptr_t ptr);)
+static inline struct heap_page *
+heap_page_for_ptr(rb_objspace_t *objspace, uintptr_t ptr)
+{
+ struct heap_page **res;
+
+ if (ptr < (uintptr_t)heap_pages_lomem ||
+ ptr > (uintptr_t)heap_pages_himem) {
+ return NULL;
+ }
+
+ res = bsearch((void *)ptr, rb_darray_ref(objspace->heap_pages.sorted, 0),
+ rb_darray_size(objspace->heap_pages.sorted), sizeof(struct heap_page *),
+ ptr_in_page_body_p);
+
+ if (res) {
+ return *res;
+ }
+ else {
+ return NULL;
+ }
+}
+
+PUREFUNC(static inline bool is_pointer_to_heap(rb_objspace_t *objspace, const void *ptr);)
+static inline bool
+is_pointer_to_heap(rb_objspace_t *objspace, const void *ptr)
+{
+ register uintptr_t p = (uintptr_t)ptr;
+ register struct heap_page *page;
+
+ RB_DEBUG_COUNTER_INC(gc_isptr_trial);
+
+ if (p < heap_pages_lomem || p > heap_pages_himem) return FALSE;
+ RB_DEBUG_COUNTER_INC(gc_isptr_range);
+
+ if (p % sizeof(VALUE) != 0) return FALSE;
+ RB_DEBUG_COUNTER_INC(gc_isptr_align);
+
+ page = heap_page_for_ptr(objspace, (uintptr_t)ptr);
+ if (page) {
+ RB_DEBUG_COUNTER_INC(gc_isptr_maybe);
+ if (heap_page_in_global_empty_pages_pool(objspace, page)) {
+ return FALSE;
+ }
+ else {
+ if (p < page->start) return FALSE;
+ if (p >= page->start + (page->total_slots * page->slot_size)) return FALSE;
+ if ((p - page->start) % page->slot_size != 0) return FALSE;
+
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+bool
+rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr)
+{
+ return is_pointer_to_heap(objspace_ptr, ptr);
+}
+
+#define ZOMBIE_OBJ_KEPT_FLAGS (FL_FINALIZE)
+
+void
+rb_gc_impl_make_zombie(void *objspace_ptr, VALUE obj, void (*dfree)(void *), void *data)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ struct RZombie *zombie = RZOMBIE(obj);
+ zombie->flags = T_ZOMBIE | (zombie->flags & ZOMBIE_OBJ_KEPT_FLAGS);
+ zombie->dfree = dfree;
+ zombie->data = data;
+ VALUE prev, next = heap_pages_deferred_final;
+ do {
+ zombie->next = prev = next;
+ next = RUBY_ATOMIC_VALUE_CAS(heap_pages_deferred_final, prev, obj);
+ } while (next != prev);
+
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+ page->final_slots++;
+ page->heap->final_slots_count++;
+}
+
+typedef int each_obj_callback(void *, void *, size_t, void *);
+typedef int each_page_callback(struct heap_page *, void *);
+
+struct each_obj_data {
+ rb_objspace_t *objspace;
+ bool reenable_incremental;
+
+ each_obj_callback *each_obj_callback;
+ each_page_callback *each_page_callback;
+ void *data;
+
+ struct heap_page **pages[HEAP_COUNT];
+ size_t pages_counts[HEAP_COUNT];
+};
+
+static VALUE
+objspace_each_objects_ensure(VALUE arg)
+{
+ struct each_obj_data *data = (struct each_obj_data *)arg;
+ rb_objspace_t *objspace = data->objspace;
+
+ /* Reenable incremental GC */
+ if (data->reenable_incremental) {
+ objspace->flags.dont_incremental = FALSE;
+ }
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ struct heap_page **pages = data->pages[i];
+ free(pages);
+ }
+
+ return Qnil;
+}
+
+static VALUE
+objspace_each_objects_try(VALUE arg)
+{
+ struct each_obj_data *data = (struct each_obj_data *)arg;
+ rb_objspace_t *objspace = data->objspace;
+
+ /* Copy pages from all heaps to their respective buffers. */
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ size_t size = heap->total_pages * sizeof(struct heap_page *);
+
+ struct heap_page **pages = malloc(size);
+ if (!pages) rb_memerror();
+
+ /* Set up pages buffer by iterating over all pages in the current eden
+ * heap. This will be a snapshot of the state of the heap before we
+ * call the callback over each page that exists in this buffer. Thus it
+ * is safe for the callback to allocate objects without possibly entering
+ * an infinite loop. */
+ struct heap_page *page = 0;
+ size_t pages_count = 0;
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ pages[pages_count] = page;
+ pages_count++;
+ }
+ data->pages[i] = pages;
+ data->pages_counts[i] = pages_count;
+ GC_ASSERT(pages_count == heap->total_pages);
+ }
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ size_t pages_count = data->pages_counts[i];
+ struct heap_page **pages = data->pages[i];
+
+ struct heap_page *page = ccan_list_top(&heap->pages, struct heap_page, page_node);
+ for (size_t i = 0; i < pages_count; i++) {
+ /* If we have reached the end of the linked list then there are no
+ * more pages, so break. */
+ if (page == NULL) break;
+
+ /* If this page does not match the one in the buffer, then move to
+ * the next page in the buffer. */
+ if (pages[i] != page) continue;
+
+ uintptr_t pstart = (uintptr_t)page->start;
+ uintptr_t pend = pstart + (page->total_slots * heap->slot_size);
+
+ if (data->each_obj_callback &&
+ (*data->each_obj_callback)((void *)pstart, (void *)pend, heap->slot_size, data->data)) {
+ break;
+ }
+ if (data->each_page_callback &&
+ (*data->each_page_callback)(page, data->data)) {
+ break;
+ }
+
+ page = ccan_list_next(&heap->pages, page, page_node);
+ }
+ }
+
+ return Qnil;
+}
+
+static void
+objspace_each_exec(bool protected, struct each_obj_data *each_obj_data)
+{
+ /* Disable incremental GC */
+ rb_objspace_t *objspace = each_obj_data->objspace;
+ bool reenable_incremental = FALSE;
+ if (protected) {
+ reenable_incremental = !objspace->flags.dont_incremental;
+
+ gc_rest(objspace);
+ objspace->flags.dont_incremental = TRUE;
+ }
+
+ each_obj_data->reenable_incremental = reenable_incremental;
+ memset(&each_obj_data->pages, 0, sizeof(each_obj_data->pages));
+ memset(&each_obj_data->pages_counts, 0, sizeof(each_obj_data->pages_counts));
+ rb_ensure(objspace_each_objects_try, (VALUE)each_obj_data,
+ objspace_each_objects_ensure, (VALUE)each_obj_data);
+}
+
+static void
+objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected)
+{
+ struct each_obj_data each_obj_data = {
+ .objspace = objspace,
+ .each_obj_callback = callback,
+ .each_page_callback = NULL,
+ .data = data,
+ };
+ objspace_each_exec(protected, &each_obj_data);
+}
+
+void
+rb_gc_impl_each_objects(void *objspace_ptr, each_obj_callback *callback, void *data)
+{
+ objspace_each_objects(objspace_ptr, callback, data, TRUE);
+}
+
+#if GC_CAN_COMPILE_COMPACTION
+static void
+objspace_each_pages(rb_objspace_t *objspace, each_page_callback *callback, void *data, bool protected)
+{
+ struct each_obj_data each_obj_data = {
+ .objspace = objspace,
+ .each_obj_callback = NULL,
+ .each_page_callback = callback,
+ .data = data,
+ };
+ objspace_each_exec(protected, &each_obj_data);
+}
+#endif
+
+VALUE
+rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ VALUE table;
+ st_data_t data;
+
+ GC_ASSERT(!OBJ_FROZEN(obj));
+
+ RBASIC(obj)->flags |= FL_FINALIZE;
+
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ if (st_lookup(finalizer_table, obj, &data)) {
+ table = (VALUE)data;
+ VALUE dup_table = rb_ary_dup(table);
+
+ RB_GC_VM_UNLOCK(lev);
+ /* avoid duplicate block, table is usually small */
+ {
+ long len = RARRAY_LEN(table);
+ long i;
+
+ for (i = 0; i < len; i++) {
+ VALUE recv = RARRAY_AREF(dup_table, i);
+ if (rb_equal(recv, block)) { // can't be called with VM lock held
+ return recv;
+ }
+ }
+ }
+ lev = RB_GC_VM_LOCK();
+ RB_GC_GUARD(dup_table);
+
+ rb_ary_push(table, block);
+ }
+ else {
+ table = rb_ary_new3(2, rb_obj_id(obj), block);
+ rb_obj_hide(table);
+ st_add_direct(finalizer_table, obj, table);
+ }
+
+ RB_GC_VM_UNLOCK(lev);
+
+ return block;
+}
+
+void
+rb_gc_impl_undefine_finalizer(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ GC_ASSERT(!OBJ_FROZEN(obj));
+
+ st_data_t data = obj;
+
+ int lev = RB_GC_VM_LOCK();
+ st_delete(finalizer_table, &data, 0);
+ RB_GC_VM_UNLOCK(lev);
+
+ FL_UNSET(obj, FL_FINALIZE);
+}
+
+void
+rb_gc_impl_copy_finalizer(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ VALUE table;
+ st_data_t data;
+
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+
+ int lev = RB_GC_VM_LOCK();
+ if (RB_LIKELY(st_lookup(finalizer_table, obj, &data))) {
+ table = rb_ary_dup((VALUE)data);
+ RARRAY_ASET(table, 0, rb_obj_id(dest));
+ st_insert(finalizer_table, dest, table);
+ FL_SET(dest, FL_FINALIZE);
+ }
+ else {
+ rb_bug("rb_gc_copy_finalizer: FL_FINALIZE set but not found in finalizer_table: %s", rb_obj_info(obj));
+ }
+ RB_GC_VM_UNLOCK(lev);
+}
+
+static VALUE
+get_final(long i, void *data)
+{
+ VALUE table = (VALUE)data;
+
+ return RARRAY_AREF(table, i + 1);
+}
+
+static unsigned int
+run_final(rb_objspace_t *objspace, VALUE zombie, unsigned int lev)
+{
+ if (RZOMBIE(zombie)->dfree) {
+ RZOMBIE(zombie)->dfree(RZOMBIE(zombie)->data);
+ }
+
+ st_data_t key = (st_data_t)zombie;
+ if (FL_TEST_RAW(zombie, FL_FINALIZE)) {
+ FL_UNSET(zombie, FL_FINALIZE);
+ st_data_t table;
+ if (st_delete(finalizer_table, &key, &table)) {
+ RB_GC_VM_UNLOCK(lev);
+ rb_gc_run_obj_finalizer(RARRAY_AREF(table, 0), RARRAY_LEN(table) - 1, get_final, (void *)table);
+ lev = RB_GC_VM_LOCK();
+ }
+ else {
+ rb_bug("FL_FINALIZE flag is set, but finalizers are not found");
+ }
+ }
+ else {
+ GC_ASSERT(!st_lookup(finalizer_table, key, NULL));
+ }
+ return lev;
+}
+
+static void
+finalize_list(rb_objspace_t *objspace, VALUE zombie)
+{
+ while (zombie) {
+ VALUE next_zombie;
+ struct heap_page *page;
+ rb_asan_unpoison_object(zombie, false);
+ next_zombie = RZOMBIE(zombie)->next;
+ page = GET_HEAP_PAGE(zombie);
+
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ lev = run_final(objspace, zombie, lev);
+ {
+ GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
+ GC_ASSERT(page->heap->final_slots_count > 0);
+ GC_ASSERT(page->final_slots > 0);
+
+ page->heap->final_slots_count--;
+ page->final_slots--;
+ page->free_slots++;
+ RVALUE_AGE_SET_BITMAP(zombie, 0);
+ heap_page_add_freeobj(objspace, page, zombie);
+ page->heap->total_freed_objects++;
+ }
+ RB_GC_VM_UNLOCK(lev);
+
+ zombie = next_zombie;
+ }
+}
+
+static void
+finalize_deferred_heap_pages(rb_objspace_t *objspace)
+{
+ VALUE zombie;
+ while ((zombie = RUBY_ATOMIC_VALUE_EXCHANGE(heap_pages_deferred_final, 0)) != 0) {
+ finalize_list(objspace, zombie);
+ }
+}
+
+static void
+finalize_deferred(rb_objspace_t *objspace)
+{
+ rb_gc_set_pending_interrupt();
+ finalize_deferred_heap_pages(objspace);
+ rb_gc_unset_pending_interrupt();
+}
+
+static void
+gc_finalize_deferred(void *dmy)
+{
+ rb_objspace_t *objspace = dmy;
+ if (RUBY_ATOMIC_EXCHANGE(finalizing, 1)) return;
+
+ finalize_deferred(objspace);
+ RUBY_ATOMIC_SET(finalizing, 0);
+}
+
+static void
+gc_finalize_deferred_register(rb_objspace_t *objspace)
+{
+ /* will enqueue a call to gc_finalize_deferred */
+ rb_postponed_job_trigger(objspace->finalize_deferred_pjob);
+}
+
+static int pop_mark_stack(mark_stack_t *stack, VALUE *data);
+
+static void
+gc_abort(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (is_incremental_marking(objspace)) {
+ /* Remove all objects from the mark stack. */
+ VALUE obj;
+ while (pop_mark_stack(&objspace->mark_stack, &obj));
+
+ objspace->flags.during_incremental_marking = FALSE;
+ }
+
+ if (is_lazy_sweeping(objspace)) {
+ objspace->sweeping_heap_count = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ heap->sweeping_page = NULL;
+ struct heap_page *page = NULL;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->flags.before_sweep = false;
+ }
+ }
+ }
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ rgengc_mark_and_rememberset_clear(objspace, heap);
+ }
+
+ gc_mode_set(objspace, gc_mode_none);
+}
+
+void
+rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ for (size_t i = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ struct heap_page *page = rb_darray_get(objspace->heap_pages.sorted, i);
+ short stride = page->slot_size;
+
+ uintptr_t p = (uintptr_t)page->start;
+ uintptr_t pend = p + page->total_slots * stride;
+ for (; p < pend; p += stride) {
+ VALUE vp = (VALUE)p;
+ asan_unpoisoning_object(vp) {
+ if (RB_BUILTIN_TYPE(vp) != T_NONE) {
+ rb_gc_obj_free_vm_weak_references(vp);
+ if (rb_gc_obj_free(objspace, vp)) {
+ RBASIC(vp)->flags = 0;
+ }
+ }
+ }
+ }
+ }
+}
+
+static int
+rb_gc_impl_shutdown_call_finalizer_i(st_data_t key, st_data_t val, st_data_t _data)
+{
+ VALUE obj = (VALUE)key;
+ VALUE table = (VALUE)val;
+
+ GC_ASSERT(RB_FL_TEST(obj, FL_FINALIZE));
+ GC_ASSERT(RB_BUILTIN_TYPE(val) == T_ARRAY);
+
+ rb_gc_run_obj_finalizer(RARRAY_AREF(table, 0), RARRAY_LEN(table) - 1, get_final, (void *)table);
+
+ FL_UNSET(obj, FL_FINALIZE);
+
+ return ST_DELETE;
+}
+
+void
+rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+
+ /* prohibit incremental GC */
+ objspace->flags.dont_incremental = 1;
+
+ if (RUBY_ATOMIC_EXCHANGE(finalizing, 1)) {
+ /* Abort incremental marking and lazy sweeping to speed up shutdown. */
+ gc_abort(objspace);
+ dont_gc_on();
+ return;
+ }
+
+ while (finalizer_table->num_entries) {
+ st_foreach(finalizer_table, rb_gc_impl_shutdown_call_finalizer_i, 0);
+ }
+
+ /* run finalizers */
+ finalize_deferred(objspace);
+ GC_ASSERT(heap_pages_deferred_final == 0);
+
+ /* Abort incremental marking and lazy sweeping to speed up shutdown. */
+ gc_abort(objspace);
+
+ /* prohibit GC because force T_DATA finalizers can break an object graph consistency */
+ dont_gc_on();
+
+ /* running data/file finalizers are part of garbage collection */
+ unsigned int lock_lev;
+ gc_enter(objspace, gc_enter_event_finalizer, &lock_lev);
+
+ /* run data/file object's finalizers */
+ for (size_t i = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ struct heap_page *page = rb_darray_get(objspace->heap_pages.sorted, i);
+ short stride = page->slot_size;
+
+ uintptr_t p = (uintptr_t)page->start;
+ uintptr_t pend = p + page->total_slots * stride;
+ for (; p < pend; p += stride) {
+ VALUE vp = (VALUE)p;
+ asan_unpoisoning_object(vp) {
+ if (rb_gc_shutdown_call_finalizer_p(vp)) {
+ rb_gc_obj_free_vm_weak_references(vp);
+ if (rb_gc_obj_free(objspace, vp)) {
+ RBASIC(vp)->flags = 0;
+ }
+ }
+ }
+ }
+ }
+
+ gc_exit(objspace, gc_enter_event_finalizer, &lock_lev);
+
+ finalize_deferred_heap_pages(objspace);
+
+ st_free_table(finalizer_table);
+ finalizer_table = 0;
+ RUBY_ATOMIC_SET(finalizing, 0);
+}
+
+void
+rb_gc_impl_each_object(void *objspace_ptr, void (*func)(VALUE obj, void *data), void *data)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ for (size_t i = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ struct heap_page *page = rb_darray_get(objspace->heap_pages.sorted, i);
+ short stride = page->slot_size;
+
+ uintptr_t p = (uintptr_t)page->start;
+ uintptr_t pend = p + page->total_slots * stride;
+ for (; p < pend; p += stride) {
+ VALUE obj = (VALUE)p;
+
+ asan_unpoisoning_object(obj) {
+ func(obj, data);
+ }
+ }
+ }
+}
+
+/*
+ ------------------------ Garbage Collection ------------------------
+*/
+
+/* Sweeping */
+
+static size_t
+objspace_available_slots(rb_objspace_t *objspace)
+{
+ size_t total_slots = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ total_slots += heap->total_slots;
+ }
+ return total_slots;
+}
+
+static size_t
+objspace_live_slots(rb_objspace_t *objspace)
+{
+ return total_allocated_objects(objspace) - total_freed_objects(objspace) - total_final_slots_count(objspace);
+}
+
+static size_t
+objspace_free_slots(rb_objspace_t *objspace)
+{
+ return objspace_available_slots(objspace) - objspace_live_slots(objspace) - total_final_slots_count(objspace);
+}
+
+static void
+gc_setup_mark_bits(struct heap_page *page)
+{
+ /* copy oldgen bitmap to mark bitmap */
+ memcpy(&page->mark_bits[0], &page->uncollectible_bits[0], HEAP_PAGE_BITMAP_SIZE);
+}
+
+static int gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj);
+static VALUE gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, struct heap_page *src_page, struct heap_page *dest_page);
+
+#if defined(_WIN32)
+enum {HEAP_PAGE_LOCK = PAGE_NOACCESS, HEAP_PAGE_UNLOCK = PAGE_READWRITE};
+
+static BOOL
+protect_page_body(struct heap_page_body *body, DWORD protect)
+{
+ DWORD old_protect;
+ return VirtualProtect(body, HEAP_PAGE_SIZE, protect, &old_protect) != 0;
+}
+#elif defined(__wasi__)
+// wasi-libc's mprotect emulation does not support PROT_NONE
+enum {HEAP_PAGE_LOCK, HEAP_PAGE_UNLOCK};
+#define protect_page_body(body, protect) 1
+#else
+enum {HEAP_PAGE_LOCK = PROT_NONE, HEAP_PAGE_UNLOCK = PROT_READ | PROT_WRITE};
+#define protect_page_body(body, protect) !mprotect((body), HEAP_PAGE_SIZE, (protect))
+#endif
+
+static void
+lock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
+{
+ if (!protect_page_body(body, HEAP_PAGE_LOCK)) {
+ rb_bug("Couldn't protect page %p, errno: %s", (void *)body, strerror(errno));
+ }
+ else {
+ gc_report(5, objspace, "Protecting page in move %p\n", (void *)body);
+ }
+}
+
+static void
+unlock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
+{
+ if (!protect_page_body(body, HEAP_PAGE_UNLOCK)) {
+ rb_bug("Couldn't unprotect page %p, errno: %s", (void *)body, strerror(errno));
+ }
+ else {
+ gc_report(5, objspace, "Unprotecting page in move %p\n", (void *)body);
+ }
+}
+
+static bool
+try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *free_page, VALUE src)
+{
+ GC_ASSERT(gc_is_moveable_obj(objspace, src));
+
+ struct heap_page *src_page = GET_HEAP_PAGE(src);
+ if (!free_page) {
+ return false;
+ }
+
+ /* We should return true if either src is successfully moved, or src is
+ * unmoveable. A false return will cause the sweeping cursor to be
+ * incremented to the next page, and src will attempt to move again */
+ GC_ASSERT(RVALUE_MARKED(objspace, src));
+
+ asan_unlock_freelist(free_page);
+ VALUE dest = (VALUE)free_page->freelist;
+ asan_lock_freelist(free_page);
+ if (dest) {
+ rb_asan_unpoison_object(dest, false);
+ }
+ else {
+ /* if we can't get something from the freelist then the page must be
+ * full */
+ return false;
+ }
+ asan_unlock_freelist(free_page);
+ free_page->freelist = ((struct free_slot *)dest)->next;
+ asan_lock_freelist(free_page);
+
+ GC_ASSERT(RB_BUILTIN_TYPE(dest) == T_NONE);
+
+ if (src_page->slot_size > free_page->slot_size) {
+ objspace->rcompactor.moved_down_count_table[BUILTIN_TYPE(src)]++;
+ }
+ else if (free_page->slot_size > src_page->slot_size) {
+ objspace->rcompactor.moved_up_count_table[BUILTIN_TYPE(src)]++;
+ }
+ objspace->rcompactor.moved_count_table[BUILTIN_TYPE(src)]++;
+ objspace->rcompactor.total_moved++;
+
+ gc_move(objspace, src, dest, src_page, free_page);
+ gc_pin(objspace, src);
+ free_page->free_slots--;
+
+ return true;
+}
+
+static void
+gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ struct heap_page *cursor = heap->compact_cursor;
+
+ while (cursor) {
+ unlock_page_body(objspace, cursor->body);
+ cursor = ccan_list_next(&heap->pages, cursor, page_node);
+ }
+}
+
+static void gc_update_references(rb_objspace_t *objspace);
+#if GC_CAN_COMPILE_COMPACTION
+static void invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page);
+#endif
+
+#if defined(__MINGW32__) || defined(_WIN32)
+# define GC_COMPACTION_SUPPORTED 1
+#else
+/* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for
+ * the read barrier, so we must disable compaction. */
+# define GC_COMPACTION_SUPPORTED (GC_CAN_COMPILE_COMPACTION && HEAP_PAGE_ALLOC_USE_MMAP)
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+static void
+read_barrier_handler(uintptr_t address)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)rb_gc_get_objspace();
+
+ struct heap_page_body *page_body = GET_PAGE_BODY(address);
+
+ /* If the page_body is NULL, then mprotect cannot handle it and will crash
+ * with "Cannot allocate memory". */
+ if (page_body == NULL) {
+ rb_bug("read_barrier_handler: segmentation fault at %p", (void *)address);
+ }
+
+ int lev = RB_GC_VM_LOCK();
+ {
+ unlock_page_body(objspace, page_body);
+
+ objspace->profile.read_barrier_faults++;
+
+ invalidate_moved_page(objspace, GET_HEAP_PAGE(address));
+ }
+ RB_GC_VM_UNLOCK(lev);
+}
+#endif
+
+#if !GC_CAN_COMPILE_COMPACTION
+static void
+uninstall_handlers(void)
+{
+ /* no-op */
+}
+
+static void
+install_handlers(void)
+{
+ /* no-op */
+}
+#elif defined(_WIN32)
+static LPTOP_LEVEL_EXCEPTION_FILTER old_handler;
+typedef void (*signal_handler)(int);
+static signal_handler old_sigsegv_handler;
+
+static LONG WINAPI
+read_barrier_signal(EXCEPTION_POINTERS *info)
+{
+ /* EXCEPTION_ACCESS_VIOLATION is what's raised by access to protected pages */
+ if (info->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
+ /* > The second array element specifies the virtual address of the inaccessible data.
+ * https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record
+ *
+ * Use this address to invalidate the page */
+ read_barrier_handler((uintptr_t)info->ExceptionRecord->ExceptionInformation[1]);
+ return EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else {
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+}
+
+static void
+uninstall_handlers(void)
+{
+ signal(SIGSEGV, old_sigsegv_handler);
+ SetUnhandledExceptionFilter(old_handler);
+}
+
+static void
+install_handlers(void)
+{
+ /* Remove SEGV handler so that the Unhandled Exception Filter handles it */
+ old_sigsegv_handler = signal(SIGSEGV, NULL);
+ /* Unhandled Exception Filter has access to the violation address similar
+ * to si_addr from sigaction */
+ old_handler = SetUnhandledExceptionFilter(read_barrier_signal);
+}
+#else
+static struct sigaction old_sigbus_handler;
+static struct sigaction old_sigsegv_handler;
+
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+static exception_mask_t old_exception_masks[32];
+static mach_port_t old_exception_ports[32];
+static exception_behavior_t old_exception_behaviors[32];
+static thread_state_flavor_t old_exception_flavors[32];
+static mach_msg_type_number_t old_exception_count;
+
+static void
+disable_mach_bad_access_exc(void)
+{
+ old_exception_count = sizeof(old_exception_masks) / sizeof(old_exception_masks[0]);
+ task_swap_exception_ports(
+ mach_task_self(), EXC_MASK_BAD_ACCESS,
+ MACH_PORT_NULL, EXCEPTION_DEFAULT, 0,
+ old_exception_masks, &old_exception_count,
+ old_exception_ports, old_exception_behaviors, old_exception_flavors
+ );
+}
+
+static void
+restore_mach_bad_access_exc(void)
+{
+ for (mach_msg_type_number_t i = 0; i < old_exception_count; i++) {
+ task_set_exception_ports(
+ mach_task_self(),
+ old_exception_masks[i], old_exception_ports[i],
+ old_exception_behaviors[i], old_exception_flavors[i]
+ );
+ }
+}
+#endif
+
+static void
+read_barrier_signal(int sig, siginfo_t *info, void *data)
+{
+ // setup SEGV/BUS handlers for errors
+ struct sigaction prev_sigbus, prev_sigsegv;
+ sigaction(SIGBUS, &old_sigbus_handler, &prev_sigbus);
+ sigaction(SIGSEGV, &old_sigsegv_handler, &prev_sigsegv);
+
+ // enable SIGBUS/SEGV
+ sigset_t set, prev_set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGBUS);
+ sigaddset(&set, SIGSEGV);
+ sigprocmask(SIG_UNBLOCK, &set, &prev_set);
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+ disable_mach_bad_access_exc();
+#endif
+ // run handler
+ read_barrier_handler((uintptr_t)info->si_addr);
+
+ // reset SEGV/BUS handlers
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+ restore_mach_bad_access_exc();
+#endif
+ sigaction(SIGBUS, &prev_sigbus, NULL);
+ sigaction(SIGSEGV, &prev_sigsegv, NULL);
+ sigprocmask(SIG_SETMASK, &prev_set, NULL);
+}
+
+static void
+uninstall_handlers(void)
+{
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+ restore_mach_bad_access_exc();
+#endif
+ sigaction(SIGBUS, &old_sigbus_handler, NULL);
+ sigaction(SIGSEGV, &old_sigsegv_handler, NULL);
+}
+
+static void
+install_handlers(void)
+{
+ struct sigaction action;
+ memset(&action, 0, sizeof(struct sigaction));
+ sigemptyset(&action.sa_mask);
+ action.sa_sigaction = read_barrier_signal;
+ action.sa_flags = SA_SIGINFO | SA_ONSTACK;
+
+ sigaction(SIGBUS, &action, &old_sigbus_handler);
+ sigaction(SIGSEGV, &action, &old_sigsegv_handler);
+#ifdef HAVE_MACH_TASK_EXCEPTION_PORTS
+ disable_mach_bad_access_exc();
+#endif
+}
+#endif
+
+static void
+gc_compact_finish(rb_objspace_t *objspace)
+{
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ gc_unprotect_pages(objspace, heap);
+ }
+
+ uninstall_handlers();
+
+ gc_update_references(objspace);
+ objspace->profile.compact_count++;
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ heap->compact_cursor = NULL;
+ heap->free_pages = NULL;
+ heap->compact_cursor_index = 0;
+ }
+
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->moved_objects = objspace->rcompactor.total_moved - record->moved_objects;
+ }
+ objspace->flags.during_compacting = FALSE;
+}
+
+struct gc_sweep_context {
+ struct heap_page *page;
+ int final_slots;
+ int freed_slots;
+ int empty_slots;
+};
+
+static inline void
+gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct gc_sweep_context *ctx)
+{
+ struct heap_page *sweep_page = ctx->page;
+ short slot_size = sweep_page->slot_size;
+
+ do {
+ VALUE vp = (VALUE)p;
+ GC_ASSERT(vp % sizeof(VALUE) == 0);
+
+ rb_asan_unpoison_object(vp, false);
+ if (bitset & 1) {
+ switch (BUILTIN_TYPE(vp)) {
+ case T_MOVED:
+ if (objspace->flags.during_compacting) {
+ /* The sweep cursor shouldn't have made it to any
+ * T_MOVED slots while the compact flag is enabled.
+ * The sweep cursor and compact cursor move in
+ * opposite directions, and when they meet references will
+ * get updated and "during_compacting" should get disabled */
+ rb_bug("T_MOVED shouldn't be seen until compaction is finished");
+ }
+ gc_report(3, objspace, "page_sweep: %s is added to freelist\n", rb_obj_info(vp));
+ ctx->empty_slots++;
+ heap_page_add_freeobj(objspace, sweep_page, vp);
+ break;
+ case T_ZOMBIE:
+ /* already counted */
+ break;
+ case T_NONE:
+ ctx->empty_slots++; /* already freed */
+ break;
+
+ default:
+#if RGENGC_CHECK_MODE
+ if (!is_full_marking(objspace)) {
+ if (RVALUE_OLD_P(objspace, vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p);
+ if (RVALUE_REMEMBERED(objspace, vp)) rb_bug("page_sweep: %p - remembered.", (void *)p);
+ }
+#endif
+
+#if RGENGC_CHECK_MODE
+#define CHECK(x) if (x(objspace, vp) != FALSE) rb_bug("obj_free: " #x "(%s) != FALSE", rb_obj_info(vp))
+ CHECK(RVALUE_WB_UNPROTECTED);
+ CHECK(RVALUE_MARKED);
+ CHECK(RVALUE_MARKING);
+ CHECK(RVALUE_UNCOLLECTIBLE);
+#undef CHECK
+#endif
+
+ if (!rb_gc_obj_needs_cleanup_p(vp)) {
+ if (RB_UNLIKELY(objspace->hook_events & RUBY_INTERNAL_EVENT_FREEOBJ)) {
+ rb_gc_event_hook(vp, RUBY_INTERNAL_EVENT_FREEOBJ);
+ }
+
+ (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, slot_size);
+ heap_page_add_freeobj(objspace, sweep_page, vp);
+ gc_report(3, objspace, "page_sweep: %s (fast path) added to freelist\n", rb_obj_info(vp));
+ ctx->freed_slots++;
+ }
+ else {
+ gc_report(2, objspace, "page_sweep: free %p\n", (void *)p);
+
+ rb_gc_event_hook(vp, RUBY_INTERNAL_EVENT_FREEOBJ);
+
+ rb_gc_obj_free_vm_weak_references(vp);
+ if (rb_gc_obj_free(objspace, vp)) {
+ (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, slot_size);
+ heap_page_add_freeobj(objspace, sweep_page, vp);
+ gc_report(3, objspace, "page_sweep: %s is added to freelist\n", rb_obj_info(vp));
+ ctx->freed_slots++;
+ }
+ else {
+ ctx->final_slots++;
+ }
+ }
+ break;
+ }
+ }
+ p += slot_size;
+ bitset >>= 1;
+ } while (bitset);
+}
+
+static inline void
+gc_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct gc_sweep_context *ctx)
+{
+ struct heap_page *sweep_page = ctx->page;
+ GC_ASSERT(sweep_page->heap == heap);
+
+ uintptr_t p;
+ bits_t *bits, bitset;
+
+ gc_report(2, objspace, "page_sweep: start.\n");
+
+#if RGENGC_CHECK_MODE
+ if (!objspace->flags.immediate_sweep) {
+ GC_ASSERT(sweep_page->flags.before_sweep == TRUE);
+ }
+#endif
+ sweep_page->flags.before_sweep = FALSE;
+ sweep_page->free_slots = 0;
+
+ p = (uintptr_t)sweep_page->start;
+ bits = sweep_page->mark_bits;
+ short slot_size = sweep_page->slot_size;
+ int total_slots = sweep_page->total_slots;
+ int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH);
+
+ int out_of_range_bits = total_slots % BITS_BITLENGTH;
+ if (out_of_range_bits != 0) {
+ bits[bitmap_plane_count - 1] |= ~(((bits_t)1 << out_of_range_bits) - 1);
+ }
+
+ // Clear wb_unprotected and age bits for all unmarked slots
+ {
+ bits_t *wb_unprotected_bits = sweep_page->wb_unprotected_bits;
+ bits_t *age_bits = sweep_page->age_bits;
+ for (int i = 0; i < bitmap_plane_count; i++) {
+ bits_t unmarked = ~bits[i];
+ wb_unprotected_bits[i] &= ~unmarked;
+ age_bits[i * 2] &= ~unmarked;
+ age_bits[i * 2 + 1] &= ~unmarked;
+ }
+ }
+
+ for (int i = 0; i < bitmap_plane_count; i++) {
+ bitset = ~bits[i];
+ if (bitset) {
+ gc_sweep_plane(objspace, heap, p, bitset, ctx);
+ }
+ p += BITS_BITLENGTH * slot_size;
+ }
+
+ if (!heap->compact_cursor) {
+ gc_setup_mark_bits(sweep_page);
+ }
+
+#if GC_PROFILE_MORE_DETAIL
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->removing_objects += ctx->final_slots + ctx->freed_slots;
+ record->empty_objects += ctx->empty_slots;
+ }
+#endif
+ if (0) fprintf(stderr, "gc_sweep_page(%"PRIdSIZE"): total_slots: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
+ rb_gc_count(),
+ sweep_page->total_slots,
+ ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
+
+ sweep_page->free_slots += ctx->freed_slots + ctx->empty_slots;
+ sweep_page->heap->total_freed_objects += ctx->freed_slots;
+
+ if (heap_pages_deferred_final && !finalizing) {
+ gc_finalize_deferred_register(objspace);
+ }
+
+#if RGENGC_CHECK_MODE
+ short freelist_len = 0;
+ asan_unlock_freelist(sweep_page);
+ struct free_slot *ptr = sweep_page->freelist;
+ while (ptr) {
+ freelist_len++;
+ rb_asan_unpoison_object((VALUE)ptr, false);
+ struct free_slot *next = ptr->next;
+ rb_asan_poison_object((VALUE)ptr);
+ ptr = next;
+ }
+ asan_lock_freelist(sweep_page);
+ if (freelist_len != sweep_page->free_slots) {
+ rb_bug("inconsistent freelist length: expected %d but was %d", sweep_page->free_slots, freelist_len);
+ }
+#endif
+
+ gc_report(2, objspace, "page_sweep: end.\n");
+}
+
+static const char *
+gc_mode_name(enum gc_mode mode)
+{
+ switch (mode) {
+ case gc_mode_none: return "none";
+ case gc_mode_marking: return "marking";
+ case gc_mode_sweeping: return "sweeping";
+ case gc_mode_compacting: return "compacting";
+ default: rb_bug("gc_mode_name: unknown mode: %d", (int)mode);
+ }
+}
+
+static void
+gc_mode_transition(rb_objspace_t *objspace, enum gc_mode mode)
+{
+#if RGENGC_CHECK_MODE
+ enum gc_mode prev_mode = gc_mode(objspace);
+ switch (prev_mode) {
+ case gc_mode_none: GC_ASSERT(mode == gc_mode_marking); break;
+ case gc_mode_marking: GC_ASSERT(mode == gc_mode_sweeping); break;
+ case gc_mode_sweeping: GC_ASSERT(mode == gc_mode_none || mode == gc_mode_compacting); break;
+ case gc_mode_compacting: GC_ASSERT(mode == gc_mode_none); break;
+ }
+#endif
+ if (0) fprintf(stderr, "gc_mode_transition: %s->%s\n", gc_mode_name(gc_mode(objspace)), gc_mode_name(mode));
+ gc_mode_set(objspace, mode);
+}
+
+static void
+heap_page_freelist_append(struct heap_page *page, struct free_slot *freelist)
+{
+ if (freelist) {
+ asan_unlock_freelist(page);
+ if (page->freelist) {
+ struct free_slot *p = page->freelist;
+ rb_asan_unpoison_object((VALUE)p, false);
+ while (p->next) {
+ struct free_slot *prev = p;
+ p = p->next;
+ rb_asan_poison_object((VALUE)prev);
+ rb_asan_unpoison_object((VALUE)p, false);
+ }
+ p->next = freelist;
+ rb_asan_poison_object((VALUE)p);
+ }
+ else {
+ page->freelist = freelist;
+ }
+ asan_lock_freelist(page);
+ }
+}
+
+static void
+gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ heap->sweeping_page = ccan_list_top(&heap->pages, struct heap_page, page_node);
+ if (heap->sweeping_page) {
+ objspace->sweeping_heap_count++;
+ }
+ heap->free_pages = NULL;
+ heap->pooled_pages = NULL;
+ if (!objspace->flags.immediate_sweep) {
+ struct heap_page *page = NULL;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->flags.before_sweep = TRUE;
+ }
+ }
+}
+
+#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4
+__attribute__((noinline))
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+static void gc_sort_heap_by_compare_func(rb_objspace_t *objspace, gc_compact_compare_func compare_func);
+static int compare_pinned_slots(const void *left, const void *right, void *d);
+#endif
+
+static void
+gc_ractor_newobj_cache_clear(void *c, void *data)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ rb_ractor_newobj_cache_t *newobj_cache = c;
+
+ newobj_cache->incremental_mark_step_allocated_slots = 0;
+
+ for (size_t heap_idx = 0; heap_idx < HEAP_COUNT; heap_idx++) {
+
+ rb_ractor_newobj_heap_cache_t *cache = &newobj_cache->heap_caches[heap_idx];
+
+ rb_heap_t *heap = &heaps[heap_idx];
+ RUBY_ATOMIC_SIZE_ADD(heap->total_allocated_objects, cache->allocated_objects_count);
+ cache->allocated_objects_count = 0;
+
+ struct heap_page *page = cache->using_page;
+ struct free_slot *freelist = cache->freelist;
+ RUBY_DEBUG_LOG("ractor using_page:%p freelist:%p", (void *)page, (void *)freelist);
+
+ heap_page_freelist_append(page, freelist);
+
+ cache->using_page = NULL;
+ cache->freelist = NULL;
+ }
+}
+
+static void
+gc_sweep_start(rb_objspace_t *objspace)
+{
+ gc_mode_transition(objspace, gc_mode_sweeping);
+ objspace->rincgc.pooled_slots = 0;
+
+#if GC_CAN_COMPILE_COMPACTION
+ if (objspace->flags.during_compacting) {
+ gc_sort_heap_by_compare_func(
+ objspace,
+ objspace->rcompactor.compare_func ? objspace->rcompactor.compare_func : compare_pinned_slots
+ );
+ }
+#endif
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ gc_sweep_start_heap(objspace, heap);
+
+ /* We should call gc_sweep_finish_heap for size pools with no pages. */
+ if (heap->sweeping_page == NULL) {
+ GC_ASSERT(heap->total_pages == 0);
+ GC_ASSERT(heap->total_slots == 0);
+ gc_sweep_finish_heap(objspace, heap);
+ }
+ }
+
+ rb_gc_ractor_newobj_cache_foreach(gc_ractor_newobj_cache_clear, NULL);
+}
+
+static void
+gc_sweep_finish_heap(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ size_t total_slots = heap->total_slots;
+ size_t swept_slots = heap->freed_slots + heap->empty_slots;
+
+ size_t init_slots = gc_params.heap_init_bytes / heap->slot_size;
+ size_t min_free_slots = (size_t)(MAX(total_slots, init_slots) * gc_params.heap_free_slots_min_ratio);
+
+ if (swept_slots < min_free_slots &&
+ /* The heap is a growth heap if it freed more slots than had empty slots. */
+ ((heap->empty_slots == 0 && total_slots > 0) || heap->freed_slots > heap->empty_slots)) {
+ /* If we don't have enough slots and we have pages on the tomb heap, move
+ * pages from the tomb heap to the eden heap. This may prevent page
+ * creation thrashing (frequently allocating and deallocting pages) and
+ * GC thrashing (running GC more frequently than required). */
+ struct heap_page *resurrected_page;
+ while (swept_slots < min_free_slots &&
+ (resurrected_page = heap_page_resurrect(objspace))) {
+ heap_add_page(objspace, heap, resurrected_page);
+ heap_add_freepage(heap, resurrected_page);
+
+ swept_slots += resurrected_page->free_slots;
+ }
+
+ if (swept_slots < min_free_slots) {
+ /* Grow this heap if we are in a major GC or if we haven't run at least
+ * RVALUE_OLD_AGE minor GC since the last major GC. */
+ if (is_full_marking(objspace) ||
+ objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE) {
+ if (objspace->heap_pages.allocatable_bytes < min_free_slots * heap->slot_size) {
+ heap_allocatable_bytes_expand(objspace, heap, swept_slots, heap->total_slots, heap->slot_size);
+ }
+ }
+ else if (swept_slots < min_free_slots * 7 / 8 &&
+ objspace->heap_pages.allocatable_bytes < (min_free_slots * 7 / 8 - swept_slots) * heap->slot_size) {
+ gc_needs_major_flags |= GPR_FLAG_MAJOR_BY_NOFREE;
+ heap->force_major_gc_count++;
+ }
+ }
+ }
+}
+
+static void
+gc_sweep_finish(rb_objspace_t *objspace)
+{
+ gc_report(1, objspace, "gc_sweep_finish\n");
+
+ gc_prof_set_heap_info(objspace);
+ heap_pages_free_unused_pages(objspace);
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ heap->freed_slots = 0;
+ heap->empty_slots = 0;
+
+ if (!will_be_incremental_marking(objspace)) {
+ struct heap_page *end_page = heap->free_pages;
+ if (end_page) {
+ while (end_page->free_next) end_page = end_page->free_next;
+ end_page->free_next = heap->pooled_pages;
+ }
+ else {
+ heap->free_pages = heap->pooled_pages;
+ }
+ heap->pooled_pages = NULL;
+ objspace->rincgc.pooled_slots = 0;
+ }
+ }
+
+ (void)gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.counters);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ if (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) {
+ (void)gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.oldcounters);
+ }
+#endif
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_END_SWEEP);
+ gc_mode_transition(objspace, gc_mode_none);
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+}
+
+static int
+gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ struct heap_page *sweep_page = heap->sweeping_page;
+ int swept_slots = 0;
+ int pooled_slots = 0;
+ int sweep_budget = GC_INCREMENTAL_SWEEP_BYTES / heap->slot_size;
+ int pool_budget = GC_INCREMENTAL_SWEEP_POOL_BYTES / heap->slot_size;
+
+ if (sweep_page == NULL) return FALSE;
+
+#if GC_ENABLE_LAZY_SWEEP
+ gc_prof_sweep_timer_start(objspace);
+#endif
+
+ do {
+ RUBY_DEBUG_LOG("sweep_page:%p", (void *)sweep_page);
+
+ struct gc_sweep_context ctx = {
+ .page = sweep_page,
+ .final_slots = 0,
+ .freed_slots = 0,
+ .empty_slots = 0,
+ };
+ gc_sweep_page(objspace, heap, &ctx);
+ int free_slots = ctx.freed_slots + ctx.empty_slots;
+
+ heap->sweeping_page = ccan_list_next(&heap->pages, sweep_page, page_node);
+
+ if (free_slots == sweep_page->total_slots) {
+ /* There are no living objects, so move this page to the global empty pages. */
+ heap_unlink_page(objspace, heap, sweep_page);
+
+ sweep_page->start = 0;
+ sweep_page->total_slots = 0;
+ sweep_page->slot_size = 0;
+ sweep_page->heap = NULL;
+ sweep_page->free_slots = 0;
+
+ asan_unlock_freelist(sweep_page);
+ sweep_page->freelist = NULL;
+ asan_lock_freelist(sweep_page);
+
+ asan_poison_memory_region(sweep_page->body, HEAP_PAGE_SIZE);
+
+ objspace->empty_pages_count++;
+ sweep_page->free_next = objspace->empty_pages;
+ objspace->empty_pages = sweep_page;
+ }
+ else if (free_slots > 0) {
+ heap->freed_slots += ctx.freed_slots;
+ heap->empty_slots += ctx.empty_slots;
+
+ if (pooled_slots < pool_budget) {
+ heap_add_poolpage(objspace, heap, sweep_page);
+ pooled_slots += free_slots;
+ }
+ else {
+ heap_add_freepage(heap, sweep_page);
+ swept_slots += free_slots;
+ if (swept_slots > sweep_budget) {
+ break;
+ }
+ }
+ }
+ else {
+ sweep_page->free_next = NULL;
+ }
+ } while ((sweep_page = heap->sweeping_page));
+
+ if (!heap->sweeping_page) {
+ objspace->sweeping_heap_count--;
+ GC_ASSERT(objspace->sweeping_heap_count >= 0);
+ gc_sweep_finish_heap(objspace, heap);
+
+ if (!has_sweeping_pages(objspace)) {
+ gc_sweep_finish(objspace);
+ }
+ }
+
+#if GC_ENABLE_LAZY_SWEEP
+ gc_prof_sweep_timer_stop(objspace);
+#endif
+
+ return heap->free_pages != NULL;
+}
+
+static void
+gc_sweep_rest(rb_objspace_t *objspace)
+{
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ while (heap->sweeping_page) {
+ gc_sweep_step(objspace, heap);
+ }
+ }
+}
+
+static void
+gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *sweep_heap)
+{
+ GC_ASSERT(dont_gc_val() == FALSE || objspace->profile.latest_gc_info & GPR_FLAG_METHOD);
+ if (!GC_ENABLE_LAZY_SWEEP) return;
+
+ gc_sweeping_enter(objspace);
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ if (gc_sweep_step(objspace, heap)) {
+ GC_ASSERT(heap->free_pages != NULL);
+ }
+ else if (heap == sweep_heap) {
+ if (objspace->empty_pages_count > 0 || objspace->heap_pages.allocatable_bytes > 0) {
+ /* [Bug #21548]
+ *
+ * If this heap is the heap we want to sweep, but we weren't able
+ * to free any slots, but we also either have empty pages or could
+ * allocate new pages, then we want to preemptively claim a page
+ * because it's possible that sweeping another heap will call
+ * gc_sweep_finish_heap, which may use up all of the
+ * empty/allocatable pages. If other heaps are not finished sweeping
+ * then we do not finish this GC and we will end up triggering a new
+ * GC cycle during this GC phase. */
+ heap_page_allocate_and_initialize(objspace, heap);
+
+ GC_ASSERT(heap->free_pages != NULL);
+ }
+ else {
+ /* Not allowed to create a new page so finish sweeping. */
+ gc_sweep_rest(objspace);
+ GC_ASSERT(gc_mode(objspace) == gc_mode_none);
+ break;
+ }
+ }
+ }
+
+ gc_sweeping_exit(objspace);
+}
+
+VALUE
+rb_gc_impl_location(void *objspace_ptr, VALUE value)
+{
+ VALUE destination;
+
+ asan_unpoisoning_object(value) {
+ if (BUILTIN_TYPE(value) == T_MOVED) {
+ destination = (VALUE)RMOVED(value)->destination;
+ GC_ASSERT(BUILTIN_TYPE(destination) != T_NONE);
+ }
+ else {
+ destination = value;
+ }
+ }
+
+ return destination;
+}
+
+#if GC_CAN_COMPILE_COMPACTION
+static void
+invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_t p, bits_t bitset)
+{
+ if (bitset) {
+ do {
+ if (bitset & 1) {
+ VALUE forwarding_object = (VALUE)p;
+ VALUE object;
+
+ if (BUILTIN_TYPE(forwarding_object) == T_MOVED) {
+ GC_ASSERT(RVALUE_PINNED(objspace, forwarding_object));
+ GC_ASSERT(!RVALUE_MARKED(objspace, forwarding_object));
+
+ CLEAR_IN_BITMAP(GET_HEAP_PINNED_BITS(forwarding_object), forwarding_object);
+
+ object = rb_gc_impl_location(objspace, forwarding_object);
+ gc_move(objspace, object, forwarding_object, GET_HEAP_PAGE(object), page);
+ /* forwarding_object is now our actual object, and "object"
+ * is the free slot for the original page */
+
+ struct heap_page *orig_page = GET_HEAP_PAGE(object);
+ orig_page->free_slots++;
+ RVALUE_AGE_SET_BITMAP(object, 0);
+ heap_page_add_freeobj(objspace, orig_page, object);
+
+ GC_ASSERT(RVALUE_MARKED(objspace, forwarding_object));
+ GC_ASSERT(BUILTIN_TYPE(forwarding_object) != T_MOVED);
+ GC_ASSERT(BUILTIN_TYPE(forwarding_object) != T_NONE);
+ }
+ }
+ p += page->slot_size;
+ bitset >>= 1;
+ } while (bitset);
+ }
+}
+
+static void
+invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page)
+{
+ int i;
+ bits_t *mark_bits, *pin_bits;
+ bits_t bitset;
+ short slot_size = page->slot_size;
+ int total_slots = page->total_slots;
+ int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH);
+
+ mark_bits = page->mark_bits;
+ pin_bits = page->pinned_bits;
+
+ uintptr_t p = page->start;
+
+ for (i=0; i < bitmap_plane_count; i++) {
+ /* Moved objects are pinned but never marked. We reuse the pin bits
+ * to indicate there is a moved object in this slot. */
+ bitset = pin_bits[i] & ~mark_bits[i];
+ invalidate_moved_plane(objspace, page, p, bitset);
+ p += BITS_BITLENGTH * slot_size;
+ }
+}
+#endif
+
+static void
+gc_compact_start(rb_objspace_t *objspace)
+{
+ struct heap_page *page = NULL;
+ gc_mode_transition(objspace, gc_mode_compacting);
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->flags.before_sweep = TRUE;
+ }
+
+ heap->compact_cursor = ccan_list_tail(&heap->pages, struct heap_page, page_node);
+ heap->compact_cursor_index = 0;
+ }
+
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->moved_objects = objspace->rcompactor.total_moved;
+ }
+
+ memset(objspace->rcompactor.considered_count_table, 0, T_MASK * sizeof(size_t));
+ memset(objspace->rcompactor.moved_count_table, 0, T_MASK * sizeof(size_t));
+ memset(objspace->rcompactor.moved_up_count_table, 0, T_MASK * sizeof(size_t));
+ memset(objspace->rcompactor.moved_down_count_table, 0, T_MASK * sizeof(size_t));
+
+ /* Set up read barrier for pages containing MOVED objects */
+ install_handlers();
+}
+
+static void gc_sweep_compact(rb_objspace_t *objspace);
+
+static void
+gc_sweep(rb_objspace_t *objspace)
+{
+ gc_sweeping_enter(objspace);
+
+ const unsigned int immediate_sweep = objspace->flags.immediate_sweep;
+
+ gc_report(1, objspace, "gc_sweep: immediate: %d\n", immediate_sweep);
+
+ gc_sweep_start(objspace);
+ if (objspace->flags.during_compacting) {
+ gc_sweep_compact(objspace);
+ }
+
+ if (immediate_sweep) {
+#if !GC_ENABLE_LAZY_SWEEP
+ gc_prof_sweep_timer_start(objspace);
+#endif
+ gc_sweep_rest(objspace);
+#if !GC_ENABLE_LAZY_SWEEP
+ gc_prof_sweep_timer_stop(objspace);
+#endif
+ }
+ else {
+
+ /* Sweep every size pool. */
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ gc_sweep_step(objspace, heap);
+ }
+ }
+
+ gc_sweeping_exit(objspace);
+}
+
+/* Marking - Marking stack */
+
+static stack_chunk_t *
+stack_chunk_alloc(void)
+{
+ stack_chunk_t *res;
+
+ res = malloc(sizeof(stack_chunk_t));
+ if (!res)
+ rb_memerror();
+
+ return res;
+}
+
+static inline int
+is_mark_stack_empty(mark_stack_t *stack)
+{
+ return stack->chunk == NULL;
+}
+
+static size_t
+mark_stack_size(mark_stack_t *stack)
+{
+ size_t size = stack->index;
+ stack_chunk_t *chunk = stack->chunk ? stack->chunk->next : NULL;
+
+ while (chunk) {
+ size += stack->limit;
+ chunk = chunk->next;
+ }
+ return size;
+}
+
+static void
+add_stack_chunk_cache(mark_stack_t *stack, stack_chunk_t *chunk)
+{
+ chunk->next = stack->cache;
+ stack->cache = chunk;
+ stack->cache_size++;
+}
+
+static void
+shrink_stack_chunk_cache(mark_stack_t *stack)
+{
+ stack_chunk_t *chunk;
+
+ if (stack->unused_cache_size > (stack->cache_size/2)) {
+ chunk = stack->cache;
+ stack->cache = stack->cache->next;
+ stack->cache_size--;
+ free(chunk);
+ }
+ stack->unused_cache_size = stack->cache_size;
+}
+
+static void
+push_mark_stack_chunk(mark_stack_t *stack)
+{
+ stack_chunk_t *next;
+
+ GC_ASSERT(stack->index == stack->limit);
+
+ if (stack->cache_size > 0) {
+ next = stack->cache;
+ stack->cache = stack->cache->next;
+ stack->cache_size--;
+ if (stack->unused_cache_size > stack->cache_size)
+ stack->unused_cache_size = stack->cache_size;
+ }
+ else {
+ next = stack_chunk_alloc();
+ }
+ next->next = stack->chunk;
+ stack->chunk = next;
+ stack->index = 0;
+}
+
+static void
+pop_mark_stack_chunk(mark_stack_t *stack)
+{
+ stack_chunk_t *prev;
+
+ prev = stack->chunk->next;
+ GC_ASSERT(stack->index == 0);
+ add_stack_chunk_cache(stack, stack->chunk);
+ stack->chunk = prev;
+ stack->index = stack->limit;
+}
+
+static void
+mark_stack_chunk_list_free(stack_chunk_t *chunk)
+{
+ stack_chunk_t *next = NULL;
+
+ while (chunk != NULL) {
+ next = chunk->next;
+ free(chunk);
+ chunk = next;
+ }
+}
+
+static void
+free_stack_chunks(mark_stack_t *stack)
+{
+ mark_stack_chunk_list_free(stack->chunk);
+}
+
+static void
+mark_stack_free_cache(mark_stack_t *stack)
+{
+ mark_stack_chunk_list_free(stack->cache);
+ stack->cache_size = 0;
+ stack->unused_cache_size = 0;
+}
+
+static void
+push_mark_stack(mark_stack_t *stack, VALUE obj)
+{
+ switch (BUILTIN_TYPE(obj)) {
+ case T_OBJECT:
+ case T_CLASS:
+ case T_MODULE:
+ case T_FLOAT:
+ case T_STRING:
+ case T_REGEXP:
+ case T_ARRAY:
+ case T_HASH:
+ case T_STRUCT:
+ case T_BIGNUM:
+ case T_FILE:
+ case T_DATA:
+ case T_MATCH:
+ case T_COMPLEX:
+ case T_RATIONAL:
+ case T_TRUE:
+ case T_FALSE:
+ case T_SYMBOL:
+ case T_IMEMO:
+ case T_ICLASS:
+ if (stack->index == stack->limit) {
+ push_mark_stack_chunk(stack);
+ }
+ stack->chunk->data[stack->index++] = obj;
+ return;
+
+ case T_NONE:
+ case T_NIL:
+ case T_FIXNUM:
+ case T_MOVED:
+ case T_ZOMBIE:
+ case T_UNDEF:
+ case T_MASK:
+ rb_bug("push_mark_stack() called for broken object");
+ break;
+
+ case T_NODE:
+ rb_bug("push_mark_stack: unexpected T_NODE object");
+ break;
+ }
+
+ rb_bug("rb_gc_mark(): unknown data type 0x%x(%p) %s",
+ BUILTIN_TYPE(obj), (void *)obj,
+ is_pointer_to_heap((rb_objspace_t *)rb_gc_get_objspace(), (void *)obj) ? "corrupted object" : "non object");
+}
+
+static int
+pop_mark_stack(mark_stack_t *stack, VALUE *data)
+{
+ if (is_mark_stack_empty(stack)) {
+ return FALSE;
+ }
+ if (stack->index == 1) {
+ *data = stack->chunk->data[--stack->index];
+ pop_mark_stack_chunk(stack);
+ }
+ else {
+ *data = stack->chunk->data[--stack->index];
+ }
+ return TRUE;
+}
+
+static void
+init_mark_stack(mark_stack_t *stack)
+{
+ int i;
+
+ MEMZERO(stack, mark_stack_t, 1);
+ stack->index = stack->limit = STACK_CHUNK_SIZE;
+
+ for (i=0; i < 4; i++) {
+ add_stack_chunk_cache(stack, stack_chunk_alloc());
+ }
+ stack->unused_cache_size = stack->cache_size;
+}
+
+/* Marking */
+
+static void
+rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
+{
+ if (objspace->rgengc.parent_object_old_p) {
+ if (RVALUE_WB_UNPROTECTED(objspace, obj) || !RVALUE_OLD_P(objspace, obj)) {
+ rgengc_remember(objspace, objspace->rgengc.parent_object);
+ }
+ }
+}
+
+static inline int
+gc_mark_set(rb_objspace_t *objspace, VALUE obj)
+{
+ if (RVALUE_MARKED(objspace, obj)) return 0;
+ MARK_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj);
+ return 1;
+}
+
+static void
+gc_aging(rb_objspace_t *objspace, VALUE obj)
+{
+ /* Disable aging if Major GC's are disabled. This will prevent longish lived
+ * objects filling up the heap at the expense of marking many more objects.
+ *
+ * We should always pre-warm our process when disabling majors, by running
+ * GC manually several times so that most objects likely to become oldgen
+ * are already oldgen.
+ */
+ if(!gc_config_full_mark_val)
+ return;
+
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+
+ GC_ASSERT(RVALUE_MARKING(objspace, obj) == FALSE);
+ check_rvalue_consistency(objspace, obj);
+
+ if (!RVALUE_PAGE_WB_UNPROTECTED(page, obj)) {
+ if (!RVALUE_OLD_P(objspace, obj)) {
+ int t = BUILTIN_TYPE(obj);
+ if (t == T_CLASS || t == T_MODULE || t == T_ICLASS) {
+ gc_report(3, objspace, "gc_aging: YOUNG class: %s\n", rb_obj_info(obj));
+ RVALUE_AGE_SET(obj, RVALUE_OLD_AGE);
+ RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
+ }
+ else {
+ gc_report(3, objspace, "gc_aging: YOUNG: %s\n", rb_obj_info(obj));
+ RVALUE_AGE_INC(objspace, obj);
+ }
+ }
+ else if (is_full_marking(objspace)) {
+ GC_ASSERT(RVALUE_PAGE_UNCOLLECTIBLE(page, obj) == FALSE);
+ RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, page, obj);
+ }
+ }
+ check_rvalue_consistency(objspace, obj);
+
+ objspace->marked_slots++;
+}
+
+static void
+gc_grey(rb_objspace_t *objspace, VALUE obj)
+{
+#if RGENGC_CHECK_MODE
+ if (RVALUE_MARKED(objspace, obj) == FALSE) rb_bug("gc_grey: %s is not marked.", rb_obj_info(obj));
+ if (RVALUE_MARKING(objspace, obj) == TRUE) rb_bug("gc_grey: %s is marking/remembered.", rb_obj_info(obj));
+#endif
+
+ if (is_incremental_marking(objspace)) {
+ MARK_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
+ }
+
+ if (RB_FL_TEST_RAW(obj, RUBY_FL_WEAK_REFERENCE)) {
+ rb_darray_append_without_gc(&objspace->weak_references, obj);
+ }
+
+ push_mark_stack(&objspace->mark_stack, obj);
+}
+
+static inline void
+gc_mark_check_t_none(rb_objspace_t *objspace, VALUE obj)
+{
+ if (RB_UNLIKELY(BUILTIN_TYPE(obj) == T_NONE)) {
+ enum {info_size = 256};
+ char obj_info_buf[info_size];
+ rb_raw_obj_info(obj_info_buf, info_size, obj);
+
+ char parent_obj_info_buf[info_size];
+ rb_raw_obj_info(parent_obj_info_buf, info_size, objspace->rgengc.parent_object);
+
+ rb_bug("try to mark T_NONE object (obj: %s, parent: %s)", obj_info_buf, parent_obj_info_buf);
+ }
+}
+
+static void
+gc_mark(rb_objspace_t *objspace, VALUE obj)
+{
+ GC_ASSERT(during_gc);
+ GC_ASSERT(!objspace->flags.during_reference_updating);
+
+ rgengc_check_relation(objspace, obj);
+ if (!gc_mark_set(objspace, obj)) return; /* already marked */
+
+ if (0) { // for debug GC marking miss
+ RUBY_DEBUG_LOG("%p (%s) parent:%p (%s)",
+ (void *)obj, obj_type_name(obj),
+ (void *)objspace->rgengc.parent_object, obj_type_name(objspace->rgengc.parent_object));
+ }
+
+ gc_mark_check_t_none(objspace, obj);
+
+ gc_aging(objspace, obj);
+ gc_grey(objspace, obj);
+}
+
+static inline void
+gc_pin(rb_objspace_t *objspace, VALUE obj)
+{
+ GC_ASSERT(!SPECIAL_CONST_P(obj));
+ if (RB_UNLIKELY(objspace->flags.during_compacting)) {
+ if (RB_LIKELY(during_gc)) {
+ if (!RVALUE_PINNED(objspace, obj)) {
+ GC_ASSERT(GET_HEAP_PAGE(obj)->pinned_slots <= GET_HEAP_PAGE(obj)->total_slots);
+ GET_HEAP_PAGE(obj)->pinned_slots++;
+ MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj);
+ }
+ }
+ }
+}
+
+static inline void
+gc_mark_and_pin(rb_objspace_t *objspace, VALUE obj)
+{
+ gc_pin(objspace, obj);
+ gc_mark(objspace, obj);
+}
+
+void
+rb_gc_impl_mark_and_move(void *objspace_ptr, VALUE *ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (RB_UNLIKELY(objspace->flags.during_reference_updating)) {
+ GC_ASSERT(objspace->flags.during_compacting);
+ GC_ASSERT(during_gc);
+
+ VALUE destination = rb_gc_impl_location(objspace, *ptr);
+ if (destination != *ptr) {
+ *ptr = destination;
+ }
+ }
+ else {
+ gc_mark(objspace, *ptr);
+ }
+}
+
+void
+rb_gc_impl_mark(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ gc_mark(objspace, obj);
+}
+
+void
+rb_gc_impl_mark_and_pin(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ gc_mark_and_pin(objspace, obj);
+}
+
+void
+rb_gc_impl_mark_maybe(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(&obj, sizeof(obj));
+
+ if (is_pointer_to_heap(objspace, (void *)obj)) {
+ asan_unpoisoning_object(obj) {
+ /* Garbage can live on the stack, so do not mark or pin */
+ switch (BUILTIN_TYPE(obj)) {
+ case T_ZOMBIE:
+ case T_NONE:
+ break;
+ default:
+ gc_mark_and_pin(objspace, obj);
+ break;
+ }
+ }
+ }
+}
+
+static int
+pin_value(st_data_t key, st_data_t value, st_data_t data)
+{
+ rb_gc_impl_mark_and_pin((void *)data, (VALUE)value);
+
+ return ST_CONTINUE;
+}
+
+static inline void
+gc_mark_set_parent_raw(rb_objspace_t *objspace, VALUE obj, bool old_p)
+{
+ asan_unpoison_memory_region(&objspace->rgengc.parent_object, sizeof(objspace->rgengc.parent_object), false);
+ asan_unpoison_memory_region(&objspace->rgengc.parent_object_old_p, sizeof(objspace->rgengc.parent_object_old_p), false);
+ objspace->rgengc.parent_object = obj;
+ objspace->rgengc.parent_object_old_p = old_p;
+}
+
+static inline void
+gc_mark_set_parent(rb_objspace_t *objspace, VALUE obj)
+{
+ gc_mark_set_parent_raw(objspace, obj, RVALUE_OLD_P(objspace, obj));
+}
+
+static inline void
+gc_mark_set_parent_invalid(rb_objspace_t *objspace)
+{
+ asan_poison_memory_region(&objspace->rgengc.parent_object, sizeof(objspace->rgengc.parent_object));
+ asan_poison_memory_region(&objspace->rgengc.parent_object_old_p, sizeof(objspace->rgengc.parent_object_old_p));
+}
+
+static void
+mark_roots(rb_objspace_t *objspace, const char **categoryp)
+{
+#define MARK_CHECKPOINT(category) do { \
+ if (categoryp) *categoryp = category; \
+} while (0)
+
+ MARK_CHECKPOINT("objspace");
+ gc_mark_set_parent_raw(objspace, Qundef, false);
+
+ if (finalizer_table != NULL) {
+ st_foreach(finalizer_table, pin_value, (st_data_t)objspace);
+ }
+
+ if (stress_to_class) rb_gc_mark(stress_to_class);
+
+ rb_gc_save_machine_context();
+ rb_gc_mark_roots(objspace, categoryp);
+ gc_mark_set_parent_invalid(objspace);
+}
+
+static void
+gc_mark_children(rb_objspace_t *objspace, VALUE obj)
+{
+ gc_mark_set_parent(objspace, obj);
+ rb_gc_mark_children(objspace, obj);
+ gc_mark_set_parent_invalid(objspace);
+}
+
+/**
+ * incremental: 0 -> not incremental (do all)
+ * incremental: n -> mark at most `n' objects
+ */
+static inline int
+gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
+{
+ mark_stack_t *mstack = &objspace->mark_stack;
+ VALUE obj;
+ size_t marked_slots_at_the_beginning = objspace->marked_slots;
+ size_t popped_count = 0;
+
+ while (pop_mark_stack(mstack, &obj)) {
+ if (obj == Qundef) continue; /* skip */
+
+ if (RGENGC_CHECK_MODE && !RVALUE_MARKED(objspace, obj)) {
+ rb_bug("gc_mark_stacked_objects: %s is not marked.", rb_obj_info(obj));
+ }
+ gc_mark_children(objspace, obj);
+
+ if (incremental) {
+ if (RGENGC_CHECK_MODE && !RVALUE_MARKING(objspace, obj)) {
+ rb_bug("gc_mark_stacked_objects: incremental, but marking bit is 0");
+ }
+ CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
+ popped_count++;
+
+ if (popped_count + (objspace->marked_slots - marked_slots_at_the_beginning) > count) {
+ break;
+ }
+ }
+ else {
+ /* just ignore marking bits */
+ }
+ }
+
+ if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
+
+ if (is_mark_stack_empty(mstack)) {
+ shrink_stack_chunk_cache(mstack);
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+static int
+gc_mark_stacked_objects_incremental(rb_objspace_t *objspace, size_t count)
+{
+ return gc_mark_stacked_objects(objspace, TRUE, count);
+}
+
+static int
+gc_mark_stacked_objects_all(rb_objspace_t *objspace)
+{
+ return gc_mark_stacked_objects(objspace, FALSE, 0);
+}
+
+#if RGENGC_CHECK_MODE >= 4
+
+#define MAKE_ROOTSIG(obj) (((VALUE)(obj) << 1) | 0x01)
+#define IS_ROOTSIG(obj) ((VALUE)(obj) & 0x01)
+#define GET_ROOTSIG(obj) ((const char *)((VALUE)(obj) >> 1))
+
+struct reflist {
+ VALUE *list;
+ int pos;
+ int size;
+};
+
+static struct reflist *
+reflist_create(VALUE obj)
+{
+ struct reflist *refs = xmalloc(sizeof(struct reflist));
+ refs->size = 1;
+ refs->list = ALLOC_N(VALUE, refs->size);
+ refs->list[0] = obj;
+ refs->pos = 1;
+ return refs;
+}
+
+static void
+reflist_destruct(struct reflist *refs)
+{
+ xfree(refs->list);
+ xfree(refs);
+}
+
+static void
+reflist_add(struct reflist *refs, VALUE obj)
+{
+ if (refs->pos == refs->size) {
+ refs->size *= 2;
+ SIZED_REALLOC_N(refs->list, VALUE, refs->size, refs->size/2);
+ }
+
+ refs->list[refs->pos++] = obj;
+}
+
+static void
+reflist_dump(struct reflist *refs)
+{
+ int i;
+ for (i=0; i<refs->pos; i++) {
+ VALUE obj = refs->list[i];
+ if (IS_ROOTSIG(obj)) { /* root */
+ fprintf(stderr, "<root@%s>", GET_ROOTSIG(obj));
+ }
+ else {
+ fprintf(stderr, "<%s>", rb_obj_info(obj));
+ }
+ if (i+1 < refs->pos) fprintf(stderr, ", ");
+ }
+}
+
+static int
+reflist_referred_from_machine_context(struct reflist *refs)
+{
+ int i;
+ for (i=0; i<refs->pos; i++) {
+ VALUE obj = refs->list[i];
+ if (IS_ROOTSIG(obj) && strcmp(GET_ROOTSIG(obj), "machine_context") == 0) return 1;
+ }
+ return 0;
+}
+
+struct allrefs {
+ rb_objspace_t *objspace;
+ /* a -> obj1
+ * b -> obj1
+ * c -> obj1
+ * c -> obj2
+ * d -> obj3
+ * #=> {obj1 => [a, b, c], obj2 => [c, d]}
+ */
+ struct st_table *references;
+ const char *category;
+ VALUE root_obj;
+ mark_stack_t mark_stack;
+};
+
+static int
+allrefs_add(struct allrefs *data, VALUE obj)
+{
+ struct reflist *refs;
+ st_data_t r;
+
+ if (st_lookup(data->references, obj, &r)) {
+ refs = (struct reflist *)r;
+ reflist_add(refs, data->root_obj);
+ return 0;
+ }
+ else {
+ refs = reflist_create(data->root_obj);
+ st_insert(data->references, obj, (st_data_t)refs);
+ return 1;
+ }
+}
+
+static void
+allrefs_i(VALUE obj, void *ptr)
+{
+ struct allrefs *data = (struct allrefs *)ptr;
+
+ if (allrefs_add(data, obj)) {
+ push_mark_stack(&data->mark_stack, obj);
+ }
+}
+
+static void
+allrefs_roots_i(VALUE obj, void *ptr)
+{
+ struct allrefs *data = (struct allrefs *)ptr;
+ if (strlen(data->category) == 0) rb_bug("!!!");
+ data->root_obj = MAKE_ROOTSIG(data->category);
+
+ if (allrefs_add(data, obj)) {
+ push_mark_stack(&data->mark_stack, obj);
+ }
+}
+#define PUSH_MARK_FUNC_DATA(v) do { \
+ struct gc_mark_func_data_struct *prev_mark_func_data = GET_VM()->gc.mark_func_data; \
+ GET_VM()->gc.mark_func_data = (v);
+
+#define POP_MARK_FUNC_DATA() GET_VM()->gc.mark_func_data = prev_mark_func_data;} while (0)
+
+static st_table *
+objspace_allrefs(rb_objspace_t *objspace)
+{
+ struct allrefs data;
+ struct gc_mark_func_data_struct mfd;
+ VALUE obj;
+ int prev_dont_gc = dont_gc_val();
+ dont_gc_on();
+
+ data.objspace = objspace;
+ data.references = st_init_numtable();
+ init_mark_stack(&data.mark_stack);
+
+ mfd.mark_func = allrefs_roots_i;
+ mfd.data = &data;
+
+ /* traverse root objects */
+ PUSH_MARK_FUNC_DATA(&mfd);
+ GET_VM()->gc.mark_func_data = &mfd;
+ mark_roots(objspace, &data.category);
+ POP_MARK_FUNC_DATA();
+
+ /* traverse rest objects reachable from root objects */
+ while (pop_mark_stack(&data.mark_stack, &obj)) {
+ rb_objspace_reachable_objects_from(data.root_obj = obj, allrefs_i, &data);
+ }
+ free_stack_chunks(&data.mark_stack);
+
+ dont_gc_set(prev_dont_gc);
+ return data.references;
+}
+
+static int
+objspace_allrefs_destruct_i(st_data_t key, st_data_t value, st_data_t ptr)
+{
+ struct reflist *refs = (struct reflist *)value;
+ reflist_destruct(refs);
+ return ST_CONTINUE;
+}
+
+static void
+objspace_allrefs_destruct(struct st_table *refs)
+{
+ st_foreach(refs, objspace_allrefs_destruct_i, 0);
+ st_free_table(refs);
+}
+
+#if RGENGC_CHECK_MODE >= 5
+static int
+allrefs_dump_i(st_data_t k, st_data_t v, st_data_t ptr)
+{
+ VALUE obj = (VALUE)k;
+ struct reflist *refs = (struct reflist *)v;
+ fprintf(stderr, "[allrefs_dump_i] %s <- ", rb_obj_info(obj));
+ reflist_dump(refs);
+ fprintf(stderr, "\n");
+ return ST_CONTINUE;
+}
+
+static void
+allrefs_dump(rb_objspace_t *objspace)
+{
+ VALUE size = objspace->rgengc.allrefs_table->num_entries;
+ fprintf(stderr, "[all refs] (size: %"PRIuVALUE")\n", size);
+ st_foreach(objspace->rgengc.allrefs_table, allrefs_dump_i, 0);
+}
+#endif
+
+static int
+gc_check_after_marks_i(st_data_t k, st_data_t v, st_data_t ptr)
+{
+ VALUE obj = k;
+ struct reflist *refs = (struct reflist *)v;
+ rb_objspace_t *objspace = (rb_objspace_t *)ptr;
+
+ /* object should be marked or oldgen */
+ if (!RVALUE_MARKED(objspace, obj)) {
+ fprintf(stderr, "gc_check_after_marks_i: %s is not marked and not oldgen.\n", rb_obj_info(obj));
+ fprintf(stderr, "gc_check_after_marks_i: %p is referred from ", (void *)obj);
+ reflist_dump(refs);
+
+ if (reflist_referred_from_machine_context(refs)) {
+ fprintf(stderr, " (marked from machine stack).\n");
+ /* marked from machine context can be false positive */
+ }
+ else {
+ objspace->rgengc.error_count++;
+ fprintf(stderr, "\n");
+ }
+ }
+ return ST_CONTINUE;
+}
+
+static void
+gc_marks_check(rb_objspace_t *objspace, st_foreach_callback_func *checker_func, const char *checker_name)
+{
+ MALLOC_COUNTERS_LOCK(objspace);
+ struct gc_malloc_bytes saved_malloc = {
+ .malloc = gc_counter_load_relaxed(&objspace->malloc_counters.counters.malloc),
+ .free = gc_counter_load_relaxed(&objspace->malloc_counters.counters.free),
+ .malloc_at_last_gc = gc_counter_load_relaxed(&objspace->malloc_counters.counters.malloc_at_last_gc),
+ .free_at_last_gc = gc_counter_load_relaxed(&objspace->malloc_counters.counters.free_at_last_gc),
+ };
+#if RGENGC_ESTIMATE_OLDMALLOC
+ struct gc_malloc_bytes saved_oldmalloc = {
+ .malloc = gc_counter_load_relaxed(&objspace->malloc_counters.oldcounters.malloc),
+ .free = gc_counter_load_relaxed(&objspace->malloc_counters.oldcounters.free),
+ .malloc_at_last_gc = gc_counter_load_relaxed(&objspace->malloc_counters.oldcounters.malloc_at_last_gc),
+ .free_at_last_gc = gc_counter_load_relaxed(&objspace->malloc_counters.oldcounters.free_at_last_gc),
+ };
+#endif
+ MALLOC_COUNTERS_UNLOCK(objspace);
+ VALUE already_disabled = rb_objspace_gc_disable(objspace);
+
+ objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
+
+ if (checker_func) {
+ st_foreach(objspace->rgengc.allrefs_table, checker_func, (st_data_t)objspace);
+ }
+
+ if (objspace->rgengc.error_count > 0) {
+#if RGENGC_CHECK_MODE >= 5
+ allrefs_dump(objspace);
+#endif
+ if (checker_name) rb_bug("%s: GC has problem.", checker_name);
+ }
+
+ objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
+ objspace->rgengc.allrefs_table = 0;
+
+ if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
+ MALLOC_COUNTERS_LOCK(objspace);
+ gc_counter_store_release(&objspace->malloc_counters.counters.malloc, saved_malloc.malloc);
+ gc_counter_store_release(&objspace->malloc_counters.counters.free, saved_malloc.free);
+ gc_counter_store_release(&objspace->malloc_counters.counters.malloc_at_last_gc, saved_malloc.malloc_at_last_gc);
+ gc_counter_store_release(&objspace->malloc_counters.counters.free_at_last_gc, saved_malloc.free_at_last_gc);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ gc_counter_store_release(&objspace->malloc_counters.oldcounters.malloc, saved_oldmalloc.malloc);
+ gc_counter_store_release(&objspace->malloc_counters.oldcounters.free, saved_oldmalloc.free);
+ gc_counter_store_release(&objspace->malloc_counters.oldcounters.malloc_at_last_gc, saved_oldmalloc.malloc_at_last_gc);
+ gc_counter_store_release(&objspace->malloc_counters.oldcounters.free_at_last_gc, saved_oldmalloc.free_at_last_gc);
+#endif
+ MALLOC_COUNTERS_UNLOCK(objspace);
+}
+#endif /* RGENGC_CHECK_MODE >= 4 */
+
+struct verify_internal_consistency_struct {
+ rb_objspace_t *objspace;
+ int err_count;
+ size_t live_object_count;
+ size_t zombie_object_count;
+
+ VALUE parent;
+ size_t old_object_count;
+ size_t remembered_shady_count;
+};
+
+static void
+check_generation_i(const VALUE child, void *ptr)
+{
+ struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
+ const VALUE parent = data->parent;
+
+ if (RGENGC_CHECK_MODE) GC_ASSERT(RVALUE_OLD_P(data->objspace, parent));
+
+ if (!RVALUE_OLD_P(data->objspace, child)) {
+ if (!RVALUE_REMEMBERED(data->objspace, parent) &&
+ !RVALUE_REMEMBERED(data->objspace, child) &&
+ !RVALUE_UNCOLLECTIBLE(data->objspace, child)) {
+ fprintf(stderr, "verify_internal_consistency_reachable_i: WB miss (O->Y) %s -> %s\n", rb_obj_info(parent), rb_obj_info(child));
+ data->err_count++;
+ }
+ }
+}
+
+static void
+check_color_i(const VALUE child, void *ptr)
+{
+ struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
+ const VALUE parent = data->parent;
+
+ if (!RVALUE_WB_UNPROTECTED(data->objspace, parent) && RVALUE_WHITE_P(data->objspace, child)) {
+ fprintf(stderr, "verify_internal_consistency_reachable_i: WB miss (B->W) - %s -> %s\n",
+ rb_obj_info(parent), rb_obj_info(child));
+ data->err_count++;
+ }
+}
+
+static void
+check_children_i(const VALUE child, void *ptr)
+{
+ struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
+ if (check_rvalue_consistency_force(data->objspace, child, FALSE) != 0) {
+ fprintf(stderr, "check_children_i: %s has error (referenced from %s)",
+ rb_obj_info(child), rb_obj_info(data->parent));
+
+ data->err_count++;
+ }
+}
+
+static int
+verify_internal_consistency_i(void *page_start, void *page_end, size_t stride,
+ struct verify_internal_consistency_struct *data)
+{
+ VALUE obj;
+ rb_objspace_t *objspace = data->objspace;
+
+ for (obj = (VALUE)page_start; obj != (VALUE)page_end; obj += stride) {
+ asan_unpoisoning_object(obj) {
+ if (!rb_gc_impl_garbage_object_p(objspace, obj)) {
+ /* count objects */
+ data->live_object_count++;
+ data->parent = obj;
+
+ /* Normally, we don't expect T_MOVED objects to be in the heap.
+ * But they can stay alive on the stack, */
+ if (!gc_object_moved_p(objspace, obj)) {
+ /* moved slots don't have children */
+ rb_objspace_reachable_objects_from(obj, check_children_i, (void *)data);
+ }
+
+ /* check health of children */
+ if (RVALUE_OLD_P(objspace, obj)) data->old_object_count++;
+ if (RVALUE_WB_UNPROTECTED(objspace, obj) && RVALUE_UNCOLLECTIBLE(objspace, obj)) data->remembered_shady_count++;
+
+ if (!is_marking(objspace) && RVALUE_OLD_P(objspace, obj)) {
+ /* reachable objects from an oldgen object should be old or (young with remember) */
+ data->parent = obj;
+ rb_objspace_reachable_objects_from(obj, check_generation_i, (void *)data);
+ }
+
+ if (!is_marking(objspace) && rb_gc_obj_shareable_p(obj)) {
+ rb_gc_verify_shareable(obj);
+ }
+
+ if (is_incremental_marking(objspace)) {
+ if (RVALUE_BLACK_P(objspace, obj)) {
+ /* reachable objects from black objects should be black or grey objects */
+ data->parent = obj;
+ rb_objspace_reachable_objects_from(obj, check_color_i, (void *)data);
+ }
+ }
+ }
+ else {
+ if (BUILTIN_TYPE(obj) == T_ZOMBIE) {
+ data->zombie_object_count++;
+
+ if ((RBASIC(obj)->flags & ~ZOMBIE_OBJ_KEPT_FLAGS) != T_ZOMBIE) {
+ fprintf(stderr, "verify_internal_consistency_i: T_ZOMBIE has extra flags set: %s\n",
+ rb_obj_info(obj));
+ data->err_count++;
+ }
+
+ if (!!FL_TEST(obj, FL_FINALIZE) != !!st_is_member(finalizer_table, obj)) {
+ fprintf(stderr, "verify_internal_consistency_i: FL_FINALIZE %s but %s finalizer_table: %s\n",
+ FL_TEST(obj, FL_FINALIZE) ? "set" : "not set", st_is_member(finalizer_table, obj) ? "in" : "not in",
+ rb_obj_info(obj));
+ data->err_count++;
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int
+gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
+{
+ unsigned int has_remembered_shady = FALSE;
+ unsigned int has_remembered_old = FALSE;
+ int remembered_old_objects = 0;
+ int free_objects = 0;
+ int zombie_objects = 0;
+
+ short slot_size = page->slot_size;
+ uintptr_t start = (uintptr_t)page->start;
+ uintptr_t end = start + page->total_slots * slot_size;
+
+ for (uintptr_t ptr = start; ptr < end; ptr += slot_size) {
+ VALUE val = (VALUE)ptr;
+ asan_unpoisoning_object(val) {
+ enum ruby_value_type type = BUILTIN_TYPE(val);
+
+ if (type == T_NONE) free_objects++;
+ if (type == T_ZOMBIE) zombie_objects++;
+ if (RVALUE_PAGE_UNCOLLECTIBLE(page, val) && RVALUE_PAGE_WB_UNPROTECTED(page, val)) {
+ has_remembered_shady = TRUE;
+ }
+ if (RVALUE_PAGE_MARKING(page, val)) {
+ has_remembered_old = TRUE;
+ remembered_old_objects++;
+ }
+ }
+ }
+
+ if (!is_incremental_marking(objspace) &&
+ page->flags.has_remembered_objects == FALSE && has_remembered_old == TRUE) {
+
+ for (uintptr_t ptr = start; ptr < end; ptr += slot_size) {
+ VALUE val = (VALUE)ptr;
+ if (RVALUE_PAGE_MARKING(page, val)) {
+ fprintf(stderr, "marking -> %s\n", rb_obj_info(val));
+ }
+ }
+ rb_bug("page %p's has_remembered_objects should be false, but there are remembered old objects (%d). %s",
+ (void *)page, remembered_old_objects, obj ? rb_obj_info(obj) : "");
+ }
+
+ if (page->flags.has_uncollectible_wb_unprotected_objects == FALSE && has_remembered_shady == TRUE) {
+ rb_bug("page %p's has_remembered_shady should be false, but there are remembered shady objects. %s",
+ (void *)page, obj ? rb_obj_info(obj) : "");
+ }
+
+ if (0) {
+ /* free_slots may not equal to free_objects */
+ if (page->free_slots != free_objects) {
+ rb_bug("page %p's free_slots should be %d, but %d", (void *)page, page->free_slots, free_objects);
+ }
+ }
+ if (page->final_slots != zombie_objects) {
+ rb_bug("page %p's final_slots should be %d, but %d", (void *)page, page->final_slots, zombie_objects);
+ }
+
+ return remembered_old_objects;
+}
+
+static int
+gc_verify_heap_pages_(rb_objspace_t *objspace, struct ccan_list_head *head)
+{
+ int remembered_old_objects = 0;
+ struct heap_page *page = 0;
+
+ ccan_list_for_each(head, page, page_node) {
+ asan_unlock_freelist(page);
+ struct free_slot *p = page->freelist;
+ while (p) {
+ VALUE vp = (VALUE)p;
+ VALUE prev = vp;
+ rb_asan_unpoison_object(vp, false);
+ if (BUILTIN_TYPE(vp) != T_NONE) {
+ fprintf(stderr, "freelist slot expected to be T_NONE but was: %s\n", rb_obj_info(vp));
+ }
+ p = p->next;
+ rb_asan_poison_object(prev);
+ }
+ asan_lock_freelist(page);
+
+ if (page->flags.has_remembered_objects == FALSE) {
+ remembered_old_objects += gc_verify_heap_page(objspace, page, Qfalse);
+ }
+ }
+
+ return remembered_old_objects;
+}
+
+static int
+gc_verify_heap_pages(rb_objspace_t *objspace)
+{
+ int remembered_old_objects = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ remembered_old_objects += gc_verify_heap_pages_(objspace, &((&heaps[i])->pages));
+ }
+ return remembered_old_objects;
+}
+
+static void
+gc_verify_internal_consistency_(rb_objspace_t *objspace)
+{
+ struct verify_internal_consistency_struct data = {0};
+
+ data.objspace = objspace;
+ gc_report(5, objspace, "gc_verify_internal_consistency: start\n");
+
+ /* check relations */
+ for (size_t i = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ struct heap_page *page = rb_darray_get(objspace->heap_pages.sorted, i);
+ short slot_size = page->slot_size;
+
+ uintptr_t start = (uintptr_t)page->start;
+ uintptr_t end = start + page->total_slots * slot_size;
+
+ verify_internal_consistency_i((void *)start, (void *)end, slot_size, &data);
+ }
+
+ if (data.err_count != 0) {
+#if RGENGC_CHECK_MODE >= 5
+ objspace->rgengc.error_count = data.err_count;
+ gc_marks_check(objspace, NULL, NULL);
+ allrefs_dump(objspace);
+#endif
+ rb_bug("gc_verify_internal_consistency: found internal inconsistency.");
+ }
+
+ /* check heap_page status */
+ gc_verify_heap_pages(objspace);
+
+ /* check counters */
+
+ ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());
+
+ if (!is_lazy_sweeping(objspace) &&
+ !finalizing &&
+ !rb_gc_multi_ractor_p()) {
+ if (objspace_live_slots(objspace) != data.live_object_count) {
+ fprintf(stderr, "heap_pages_final_slots: %"PRIdSIZE", total_freed_objects: %"PRIdSIZE"\n",
+ total_final_slots_count(objspace), total_freed_objects(objspace));
+ rb_bug("inconsistent live slot number: expect %"PRIuSIZE", but %"PRIuSIZE".",
+ objspace_live_slots(objspace), data.live_object_count);
+ }
+ }
+
+ if (!is_marking(objspace)) {
+ if (objspace->rgengc.old_objects != data.old_object_count) {
+ rb_bug("inconsistent old slot number: expect %"PRIuSIZE", but %"PRIuSIZE".",
+ objspace->rgengc.old_objects, data.old_object_count);
+ }
+ if (objspace->rgengc.uncollectible_wb_unprotected_objects != data.remembered_shady_count) {
+ rb_bug("inconsistent number of wb unprotected objects: expect %"PRIuSIZE", but %"PRIuSIZE".",
+ objspace->rgengc.uncollectible_wb_unprotected_objects, data.remembered_shady_count);
+ }
+ }
+
+ if (!finalizing) {
+ size_t list_count = 0;
+
+ {
+ VALUE z = heap_pages_deferred_final;
+ while (z) {
+ list_count++;
+ z = RZOMBIE(z)->next;
+ }
+ }
+
+ if (total_final_slots_count(objspace) != data.zombie_object_count ||
+ total_final_slots_count(objspace) != list_count) {
+
+ rb_bug("inconsistent finalizing object count:\n"
+ " expect %"PRIuSIZE"\n"
+ " but %"PRIuSIZE" zombies\n"
+ " heap_pages_deferred_final list has %"PRIuSIZE" items.",
+ total_final_slots_count(objspace),
+ data.zombie_object_count,
+ list_count);
+ }
+ }
+
+ gc_report(5, objspace, "gc_verify_internal_consistency: OK\n");
+}
+
+static void
+gc_verify_internal_consistency(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ unsigned int lev = RB_GC_VM_LOCK();
+ {
+ rb_gc_vm_barrier(); // stop other ractors
+
+ unsigned int prev_during_gc = during_gc;
+ during_gc = FALSE; // stop gc here
+ {
+ gc_verify_internal_consistency_(objspace);
+ }
+ during_gc = prev_during_gc;
+ }
+ RB_GC_VM_UNLOCK(lev);
+}
+
+static void
+heap_move_pooled_pages_to_free_pages(rb_heap_t *heap)
+{
+ if (heap->pooled_pages) {
+ if (heap->free_pages) {
+ struct heap_page *free_pages_tail = heap->free_pages;
+ while (free_pages_tail->free_next) {
+ free_pages_tail = free_pages_tail->free_next;
+ }
+ free_pages_tail->free_next = heap->pooled_pages;
+ }
+ else {
+ heap->free_pages = heap->pooled_pages;
+ }
+
+ heap->pooled_pages = NULL;
+ }
+}
+
+static int
+gc_remember_unprotected(rb_objspace_t *objspace, VALUE obj)
+{
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+ bits_t *uncollectible_bits = &page->uncollectible_bits[0];
+
+ if (!MARKED_IN_BITMAP(uncollectible_bits, obj)) {
+ page->flags.has_uncollectible_wb_unprotected_objects = TRUE;
+ MARK_IN_BITMAP(uncollectible_bits, obj);
+ objspace->rgengc.uncollectible_wb_unprotected_objects++;
+
+#if RGENGC_PROFILE > 0
+ objspace->profile.total_remembered_shady_object_count++;
+#if RGENGC_PROFILE >= 2
+ objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+#endif
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+static inline void
+gc_marks_wb_unprotected_objects_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bits, short slot_size)
+{
+ if (bits) {
+ do {
+ if (bits & 1) {
+ gc_report(2, objspace, "gc_marks_wb_unprotected_objects: marked shady: %s\n", rb_obj_info((VALUE)p));
+ GC_ASSERT(RVALUE_WB_UNPROTECTED(objspace, (VALUE)p));
+ GC_ASSERT(RVALUE_MARKED(objspace, (VALUE)p));
+ gc_mark_children(objspace, (VALUE)p);
+ }
+ p += slot_size;
+ bits >>= 1;
+ } while (bits);
+ }
+}
+
+static void
+gc_marks_wb_unprotected_objects(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ struct heap_page *page = 0;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ bits_t *mark_bits = page->mark_bits;
+ bits_t *wbun_bits = page->wb_unprotected_bits;
+ uintptr_t p = page->start;
+ short slot_size = page->slot_size;
+ int total_slots = page->total_slots;
+ int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH);
+ size_t j;
+
+ for (j=0; j<(size_t)bitmap_plane_count; j++) {
+ bits_t bits = mark_bits[j] & wbun_bits[j];
+ gc_marks_wb_unprotected_objects_plane(objspace, p, bits, slot_size);
+ p += BITS_BITLENGTH * slot_size;
+ }
+ }
+
+ gc_mark_stacked_objects_all(objspace);
+}
+
+void
+rb_gc_impl_declare_weak_references(void *objspace_ptr, VALUE obj)
+{
+ FL_SET_RAW(obj, RUBY_FL_WEAK_REFERENCE);
+}
+
+bool
+rb_gc_impl_handle_weak_references_alive_p(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ bool marked = RVALUE_MARKED(objspace, obj);
+
+ if (marked) {
+ rgengc_check_relation(objspace, obj);
+ }
+
+ return marked;
+}
+
+static void
+gc_update_weak_references(rb_objspace_t *objspace)
+{
+ VALUE *obj_ptr;
+ rb_darray_foreach(objspace->weak_references, i, obj_ptr) {
+ gc_mark_set_parent(objspace, *obj_ptr);
+ rb_gc_handle_weak_references(*obj_ptr);
+ gc_mark_set_parent_invalid(objspace);
+ }
+
+ size_t capa = rb_darray_capa(objspace->weak_references);
+ size_t size = rb_darray_size(objspace->weak_references);
+
+ objspace->profile.weak_references_count = size;
+
+ rb_darray_clear(objspace->weak_references);
+
+ /* If the darray has capacity for more than four times the amount used, we
+ * shrink it down to half of that capacity. */
+ if (capa > size * 4) {
+ rb_darray_resize_capa_without_gc(&objspace->weak_references, size * 2);
+ }
+}
+
+static void
+gc_marks_finish(rb_objspace_t *objspace)
+{
+ /* finish incremental GC */
+ if (is_incremental_marking(objspace)) {
+ if (RGENGC_CHECK_MODE && is_mark_stack_empty(&objspace->mark_stack) == 0) {
+ rb_bug("gc_marks_finish: mark stack is not empty (%"PRIdSIZE").",
+ mark_stack_size(&objspace->mark_stack));
+ }
+
+ mark_roots(objspace, NULL);
+ while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == false);
+
+#if RGENGC_CHECK_MODE >= 2
+ if (gc_verify_heap_pages(objspace) != 0) {
+ rb_bug("gc_marks_finish (incremental): there are remembered old objects.");
+ }
+#endif
+
+ objspace->flags.during_incremental_marking = FALSE;
+ /* check children of all marked wb-unprotected objects */
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ gc_marks_wb_unprotected_objects(objspace, &heaps[i]);
+ }
+ }
+
+ gc_update_weak_references(objspace);
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+
+#if RGENGC_CHECK_MODE >= 4
+ during_gc = FALSE;
+ gc_marks_check(objspace, gc_check_after_marks_i, "after_marks");
+ during_gc = TRUE;
+#endif
+
+ {
+ const unsigned long r_mul = objspace->live_ractor_cache_count > 8 ? 8 : objspace->live_ractor_cache_count; // upto 8
+
+ size_t total_slots = objspace_available_slots(objspace);
+ size_t sweep_slots = total_slots - objspace->marked_slots; /* will be swept slots */
+ size_t max_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_max_ratio);
+ size_t min_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_min_ratio);
+ if (min_free_slots < gc_params.heap_free_slots * r_mul) {
+ min_free_slots = gc_params.heap_free_slots * r_mul;
+ }
+
+ int full_marking = is_full_marking(objspace);
+
+ GC_ASSERT(objspace_available_slots(objspace) >= objspace->marked_slots);
+
+ /* Setup freeable slots. */
+ size_t total_init_slots = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ total_init_slots += (gc_params.heap_init_bytes / heaps[i].slot_size) * r_mul;
+ }
+
+ if (max_free_slots < total_init_slots) {
+ max_free_slots = total_init_slots;
+ }
+
+ /* Approximate freeable pages using the average slots-per-pages across all heaps */
+ if (sweep_slots > max_free_slots) {
+ size_t excess_slots = sweep_slots - max_free_slots;
+ size_t total_heap_pages = heap_eden_total_pages(objspace);
+ heap_pages_freeable_pages = total_heap_pages > 0
+ ? excess_slots * total_heap_pages / total_slots
+ : 0;
+ }
+ else {
+ heap_pages_freeable_pages = 0;
+ }
+
+ if (objspace->heap_pages.allocatable_bytes == 0 && sweep_slots < min_free_slots) {
+ if (!full_marking && sweep_slots < min_free_slots * 7 / 8) {
+ if (objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE) {
+ full_marking = TRUE;
+ }
+ else {
+ gc_report(1, objspace, "gc_marks_finish: next is full GC!!)\n");
+ gc_needs_major_flags |= GPR_FLAG_MAJOR_BY_NOFREE;
+ }
+ }
+
+ if (full_marking) {
+ heap_allocatable_bytes_expand(objspace, NULL, sweep_slots, total_slots, heaps[0].slot_size);
+ }
+ }
+
+ if (full_marking) {
+ /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
+ const double r = gc_params.oldobject_limit_factor;
+ objspace->rgengc.uncollectible_wb_unprotected_objects_limit = MAX(
+ (size_t)(objspace->rgengc.uncollectible_wb_unprotected_objects * r),
+ (size_t)(objspace->rgengc.old_objects * gc_params.uncollectible_wb_unprotected_objects_limit_ratio)
+ );
+ objspace->rgengc.old_objects_limit = (size_t)(objspace->rgengc.old_objects * r);
+ }
+
+ if (objspace->rgengc.uncollectible_wb_unprotected_objects > objspace->rgengc.uncollectible_wb_unprotected_objects_limit) {
+ gc_needs_major_flags |= GPR_FLAG_MAJOR_BY_SHADY;
+ }
+ if (objspace->rgengc.old_objects > objspace->rgengc.old_objects_limit) {
+ gc_needs_major_flags |= GPR_FLAG_MAJOR_BY_OLDGEN;
+ }
+
+ gc_report(1, objspace, "gc_marks_finish (marks %"PRIdSIZE" objects, "
+ "old %"PRIdSIZE" objects, total %"PRIdSIZE" slots, "
+ "sweep %"PRIdSIZE" slots, allocatable %"PRIdSIZE" bytes, next GC: %s)\n",
+ objspace->marked_slots, objspace->rgengc.old_objects, objspace_available_slots(objspace), sweep_slots, objspace->heap_pages.allocatable_bytes,
+ gc_needs_major_flags ? "major" : "minor");
+ }
+
+ // TODO: refactor so we don't need to call this
+ rb_ractor_finish_marking();
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_END_MARK);
+}
+
+static bool
+gc_compact_heap_cursors_met_p(rb_heap_t *heap)
+{
+ return heap->sweeping_page == heap->compact_cursor;
+}
+
+
+static rb_heap_t *
+gc_compact_destination_pool(rb_objspace_t *objspace, rb_heap_t *src_pool, VALUE obj)
+{
+ size_t obj_size = rb_gc_obj_optimal_size(obj);
+ if (obj_size == 0) {
+ return src_pool;
+ }
+
+ GC_ASSERT(rb_gc_impl_size_allocatable_p(obj_size));
+
+ size_t idx = heap_idx_for_size(obj_size);
+
+ return &heaps[idx];
+}
+
+static bool
+gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
+{
+ GC_ASSERT(BUILTIN_TYPE(src) != T_MOVED);
+ GC_ASSERT(gc_is_moveable_obj(objspace, src));
+
+ rb_heap_t *dest_pool = gc_compact_destination_pool(objspace, heap, src);
+ if (gc_compact_heap_cursors_met_p(dest_pool)) {
+ return dest_pool != heap;
+ }
+
+ while (!try_move(objspace, dest_pool, dest_pool->free_pages, src)) {
+ struct gc_sweep_context ctx = {
+ .page = dest_pool->sweeping_page,
+ .final_slots = 0,
+ .freed_slots = 0,
+ .empty_slots = 0,
+ };
+
+ /* The page of src could be partially compacted, so it may contain
+ * T_MOVED. Sweeping a page may read objects on this page, so we
+ * need to lock the page. */
+ lock_page_body(objspace, GET_PAGE_BODY(src));
+ gc_sweep_page(objspace, dest_pool, &ctx);
+ unlock_page_body(objspace, GET_PAGE_BODY(src));
+
+ if (dest_pool->sweeping_page->free_slots > 0) {
+ heap_add_freepage(dest_pool, dest_pool->sweeping_page);
+ }
+
+ dest_pool->sweeping_page = ccan_list_next(&dest_pool->pages, dest_pool->sweeping_page, page_node);
+ if (gc_compact_heap_cursors_met_p(dest_pool)) {
+ return dest_pool != heap;
+ }
+ }
+
+ return true;
+}
+
+static bool
+gc_compact_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct heap_page *page)
+{
+ short slot_size = page->slot_size;
+
+ do {
+ VALUE vp = (VALUE)p;
+ GC_ASSERT(vp % sizeof(VALUE) == 0);
+
+ if (bitset & 1) {
+ objspace->rcompactor.considered_count_table[BUILTIN_TYPE(vp)]++;
+
+ if (gc_is_moveable_obj(objspace, vp)) {
+ if (!gc_compact_move(objspace, heap, vp)) {
+ //the cursors met. bubble up
+ return false;
+ }
+ }
+ }
+ p += slot_size;
+ bitset >>= 1;
+ } while (bitset);
+
+ return true;
+}
+
+// Iterate up all the objects in page, moving them to where they want to go
+static bool
+gc_compact_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
+{
+ GC_ASSERT(page == heap->compact_cursor);
+
+ bits_t *mark_bits, *pin_bits;
+ bits_t bitset;
+ uintptr_t p = page->start;
+ short slot_size = page->slot_size;
+ int total_slots = page->total_slots;
+ int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH);
+
+ mark_bits = page->mark_bits;
+ pin_bits = page->pinned_bits;
+
+ for (int j = 0; j < bitmap_plane_count; j++) {
+ // objects that can be moved are marked and not pinned
+ bitset = (mark_bits[j] & ~pin_bits[j]);
+ if (bitset) {
+ if (!gc_compact_plane(objspace, heap, (uintptr_t)p, bitset, page))
+ return false;
+ }
+ p += BITS_BITLENGTH * slot_size;
+ }
+
+ return true;
+}
+
+static bool
+gc_compact_all_compacted_p(rb_objspace_t *objspace)
+{
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ if (heap->total_pages > 0 &&
+ !gc_compact_heap_cursors_met_p(heap)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void
+gc_sweep_compact(rb_objspace_t *objspace)
+{
+ gc_compact_start(objspace);
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+
+ while (!gc_compact_all_compacted_p(objspace)) {
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ if (gc_compact_heap_cursors_met_p(heap)) {
+ continue;
+ }
+
+ struct heap_page *start_page = heap->compact_cursor;
+
+ if (!gc_compact_page(objspace, heap, start_page)) {
+ lock_page_body(objspace, start_page->body);
+
+ continue;
+ }
+
+ // If we get here, we've finished moving all objects on the compact_cursor page
+ // So we can lock it and move the cursor on to the next one.
+ lock_page_body(objspace, start_page->body);
+ heap->compact_cursor = ccan_list_prev(&heap->pages, heap->compact_cursor, page_node);
+ }
+ }
+
+ gc_compact_finish(objspace);
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+}
+
+static void
+gc_marks_rest(rb_objspace_t *objspace)
+{
+ gc_report(1, objspace, "gc_marks_rest\n");
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ (&heaps[i])->pooled_pages = NULL;
+ }
+
+ if (is_incremental_marking(objspace)) {
+ while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == FALSE);
+ }
+ else {
+ gc_mark_stacked_objects_all(objspace);
+ }
+
+ gc_marks_finish(objspace);
+}
+
+static bool
+gc_marks_step(rb_objspace_t *objspace, size_t slots)
+{
+ bool marking_finished = false;
+
+ GC_ASSERT(is_marking(objspace));
+ if (gc_mark_stacked_objects_incremental(objspace, slots)) {
+ gc_marks_finish(objspace);
+
+ marking_finished = true;
+ }
+
+ return marking_finished;
+}
+
+static bool
+gc_marks_continue(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ GC_ASSERT(dont_gc_val() == FALSE || objspace->profile.latest_gc_info & GPR_FLAG_METHOD);
+ bool marking_finished = true;
+
+ gc_marking_enter(objspace);
+
+ if (heap->free_pages) {
+ gc_report(2, objspace, "gc_marks_continue: has pooled pages");
+
+ marking_finished = gc_marks_step(objspace, objspace->rincgc.step_slots);
+ }
+ else {
+ gc_report(2, objspace, "gc_marks_continue: no more pooled pages (stack depth: %"PRIdSIZE").\n",
+ mark_stack_size(&objspace->mark_stack));
+ heap->force_incremental_marking_finish_count++;
+ gc_marks_rest(objspace);
+ }
+
+ gc_marking_exit(objspace);
+
+ return marking_finished;
+}
+
+static void
+gc_marks_start(rb_objspace_t *objspace, int full_mark)
+{
+ /* start marking */
+ gc_report(1, objspace, "gc_marks_start: (%s)\n", full_mark ? "full" : "minor");
+ gc_mode_transition(objspace, gc_mode_marking);
+
+ if (full_mark) {
+ size_t incremental_marking_steps = (objspace->rincgc.pooled_slots / INCREMENTAL_MARK_STEP_ALLOCATIONS) + 1;
+ objspace->rincgc.step_slots = (objspace->marked_slots * 2) / incremental_marking_steps;
+
+ if (0) fprintf(stderr, "objspace->marked_slots: %"PRIdSIZE", "
+ "objspace->rincgc.pooled_page_num: %"PRIdSIZE", "
+ "objspace->rincgc.step_slots: %"PRIdSIZE", \n",
+ objspace->marked_slots, objspace->rincgc.pooled_slots, objspace->rincgc.step_slots);
+ objspace->flags.during_minor_gc = FALSE;
+ if (ruby_enable_autocompact) {
+ objspace->flags.during_compacting |= TRUE;
+ }
+ objspace->profile.major_gc_count++;
+ objspace->rgengc.uncollectible_wb_unprotected_objects = 0;
+ objspace->rgengc.old_objects = 0;
+ objspace->rgengc.last_major_gc = objspace->profile.count;
+ objspace->marked_slots = 0;
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ rgengc_mark_and_rememberset_clear(objspace, heap);
+ heap_move_pooled_pages_to_free_pages(heap);
+
+ if (objspace->flags.during_compacting) {
+ struct heap_page *page = NULL;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->pinned_slots = 0;
+ }
+ }
+ }
+ }
+ else {
+ objspace->flags.during_minor_gc = TRUE;
+ objspace->marked_slots =
+ objspace->rgengc.old_objects + objspace->rgengc.uncollectible_wb_unprotected_objects; /* uncollectible objects are marked already */
+ objspace->profile.minor_gc_count++;
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rgengc_rememberset_mark(objspace, &heaps[i]);
+ }
+ }
+
+ mark_roots(objspace, NULL);
+
+ gc_report(1, objspace, "gc_marks_start: (%s) end, stack in %"PRIdSIZE"\n",
+ full_mark ? "full" : "minor", mark_stack_size(&objspace->mark_stack));
+}
+
+static bool
+gc_marks(rb_objspace_t *objspace, int full_mark)
+{
+ gc_marking_enter(objspace);
+
+ bool marking_finished = false;
+
+ /* setup marking */
+
+ gc_marks_start(objspace, full_mark);
+ if (!is_incremental_marking(objspace)) {
+ gc_marks_rest(objspace);
+ marking_finished = true;
+ }
+
+#if RGENGC_PROFILE > 0
+ if (gc_prof_record(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->old_objects = objspace->rgengc.old_objects;
+ }
+#endif
+
+ gc_marking_exit(objspace);
+
+ return marking_finished;
+}
+
+/* RGENGC */
+
+static void
+gc_report_body(int level, rb_objspace_t *objspace, const char *fmt, ...)
+{
+ if (level <= RGENGC_DEBUG) {
+ char buf[1024];
+ FILE *out = stderr;
+ va_list args;
+ const char *status = " ";
+
+ if (during_gc) {
+ status = is_full_marking(objspace) ? "+" : "-";
+ }
+ else {
+ if (is_lazy_sweeping(objspace)) {
+ status = "S";
+ }
+ if (is_incremental_marking(objspace)) {
+ status = "M";
+ }
+ }
+
+ va_start(args, fmt);
+ vsnprintf(buf, 1024, fmt, args);
+ va_end(args);
+
+ fprintf(out, "%s|", status);
+ fputs(buf, out);
+ }
+}
+
+/* bit operations */
+
+static int
+rgengc_remembersetbits_set(rb_objspace_t *objspace, VALUE obj)
+{
+ struct heap_page *page = GET_HEAP_PAGE(obj);
+ bits_t *bits = &page->remembered_bits[0];
+
+ if (MARKED_IN_BITMAP(bits, obj)) {
+ return FALSE;
+ }
+ else {
+ page->flags.has_remembered_objects = TRUE;
+ MARK_IN_BITMAP(bits, obj);
+ return TRUE;
+ }
+}
+
+/* wb, etc */
+
+/* return FALSE if already remembered */
+static int
+rgengc_remember(rb_objspace_t *objspace, VALUE obj)
+{
+ gc_report(6, objspace, "rgengc_remember: %s %s\n", rb_obj_info(obj),
+ RVALUE_REMEMBERED(objspace, obj) ? "was already remembered" : "is remembered now");
+
+ check_rvalue_consistency(objspace, obj);
+
+ if (RGENGC_CHECK_MODE) {
+ if (RVALUE_WB_UNPROTECTED(objspace, obj)) rb_bug("rgengc_remember: %s is not wb protected.", rb_obj_info(obj));
+ }
+
+#if RGENGC_PROFILE > 0
+ if (!RVALUE_REMEMBERED(objspace, obj)) {
+ if (RVALUE_WB_UNPROTECTED(objspace, obj) == 0) {
+ objspace->profile.total_remembered_normal_object_count++;
+#if RGENGC_PROFILE >= 2
+ objspace->profile.remembered_normal_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+ }
+ }
+#endif /* RGENGC_PROFILE > 0 */
+
+ return rgengc_remembersetbits_set(objspace, obj);
+}
+
+#ifndef PROFILE_REMEMBERSET_MARK
+#define PROFILE_REMEMBERSET_MARK 0
+#endif
+
+static inline void
+rgengc_rememberset_mark_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bitset, short slot_size)
+{
+ if (bitset) {
+ do {
+ if (bitset & 1) {
+ VALUE obj = (VALUE)p;
+ gc_report(2, objspace, "rgengc_rememberset_mark: mark %s\n", rb_obj_info(obj));
+ GC_ASSERT(RVALUE_UNCOLLECTIBLE(objspace, obj));
+ GC_ASSERT(RVALUE_OLD_P(objspace, obj) || RVALUE_WB_UNPROTECTED(objspace, obj));
+
+ gc_mark_children(objspace, obj);
+
+ if (RB_FL_TEST_RAW(obj, RUBY_FL_WEAK_REFERENCE)) {
+ rb_darray_append_without_gc(&objspace->weak_references, obj);
+ }
+ }
+ p += slot_size;
+ bitset >>= 1;
+ } while (bitset);
+ }
+}
+
+static void
+rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ size_t j;
+ struct heap_page *page = 0;
+#if PROFILE_REMEMBERSET_MARK
+ int has_old = 0, has_shady = 0, has_both = 0, skip = 0;
+#endif
+ gc_report(1, objspace, "rgengc_rememberset_mark: start\n");
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ if (page->flags.has_remembered_objects | page->flags.has_uncollectible_wb_unprotected_objects) {
+ uintptr_t p = page->start;
+ short slot_size = page->slot_size;
+ int total_slots = page->total_slots;
+ int bitmap_plane_count = CEILDIV(total_slots, BITS_BITLENGTH);
+ bits_t bitset, bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t *remembered_bits = page->remembered_bits;
+ bits_t *uncollectible_bits = page->uncollectible_bits;
+ bits_t *wb_unprotected_bits = page->wb_unprotected_bits;
+#if PROFILE_REMEMBERSET_MARK
+ if (page->flags.has_remembered_objects && page->flags.has_uncollectible_wb_unprotected_objects) has_both++;
+ else if (page->flags.has_remembered_objects) has_old++;
+ else if (page->flags.has_uncollectible_wb_unprotected_objects) has_shady++;
+#endif
+ for (j=0; j < (size_t)bitmap_plane_count; j++) {
+ bits[j] = remembered_bits[j] | (uncollectible_bits[j] & wb_unprotected_bits[j]);
+ remembered_bits[j] = 0;
+ }
+ page->flags.has_remembered_objects = FALSE;
+
+ for (j=0; j < (size_t)bitmap_plane_count; j++) {
+ bitset = bits[j];
+ rgengc_rememberset_mark_plane(objspace, p, bitset, slot_size);
+ p += BITS_BITLENGTH * slot_size;
+ }
+ }
+#if PROFILE_REMEMBERSET_MARK
+ else {
+ skip++;
+ }
+#endif
+ }
+
+#if PROFILE_REMEMBERSET_MARK
+ fprintf(stderr, "%d\t%d\t%d\t%d\n", has_both, has_old, has_shady, skip);
+#endif
+ gc_report(1, objspace, "rgengc_rememberset_mark: finished\n");
+}
+
+static void
+rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ struct heap_page *page = 0;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ memset(&page->mark_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->uncollectible_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->marking_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->remembered_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->pinned_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ page->flags.has_uncollectible_wb_unprotected_objects = FALSE;
+ page->flags.has_remembered_objects = FALSE;
+ }
+}
+
+/* RGENGC: APIs */
+
+NOINLINE(static void gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace));
+
+static void
+gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace)
+{
+ if (RGENGC_CHECK_MODE) {
+ if (!RVALUE_OLD_P(objspace, a)) rb_bug("gc_writebarrier_generational: %s is not an old object.", rb_obj_info(a));
+ if ( RVALUE_OLD_P(objspace, b)) rb_bug("gc_writebarrier_generational: %s is an old object.", rb_obj_info(b));
+ if (is_incremental_marking(objspace)) rb_bug("gc_writebarrier_generational: called while incremental marking: %s -> %s", rb_obj_info(a), rb_obj_info(b));
+ }
+
+ /* mark `a' and remember (default behavior) */
+ if (!RVALUE_REMEMBERED(objspace, a)) {
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ rgengc_remember(objspace, a);
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+
+ gc_report(1, objspace, "gc_writebarrier_generational: %s (remembered) -> %s\n", rb_obj_info(a), rb_obj_info(b));
+ }
+
+ check_rvalue_consistency(objspace, a);
+ check_rvalue_consistency(objspace, b);
+}
+
+static void
+gc_mark_from(rb_objspace_t *objspace, VALUE obj, VALUE parent)
+{
+ gc_mark_set_parent(objspace, parent);
+ rgengc_check_relation(objspace, obj);
+ if (gc_mark_set(objspace, obj) != FALSE) {
+ gc_aging(objspace, obj);
+ gc_grey(objspace, obj);
+ }
+ gc_mark_set_parent_invalid(objspace);
+}
+
+NOINLINE(static void gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace));
+
+static void
+gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace)
+{
+ gc_report(2, objspace, "gc_writebarrier_incremental: [LG] %p -> %s\n", (void *)a, rb_obj_info(b));
+
+ if (RVALUE_BLACK_P(objspace, a)) {
+ if (RVALUE_WHITE_P(objspace, b)) {
+ if (!RVALUE_WB_UNPROTECTED(objspace, a)) {
+ gc_report(2, objspace, "gc_writebarrier_incremental: [IN] %p -> %s\n", (void *)a, rb_obj_info(b));
+ gc_mark_from(objspace, b, a);
+ }
+ }
+ else if (RVALUE_OLD_P(objspace, a) && !RVALUE_OLD_P(objspace, b)) {
+ rgengc_remember(objspace, a);
+ }
+
+ if (RB_UNLIKELY(objspace->flags.during_compacting)) {
+ MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(b), b);
+ }
+ }
+}
+
+void
+rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+#if RGENGC_CHECK_MODE
+ if (SPECIAL_CONST_P(a)) rb_bug("rb_gc_writebarrier: a is special const: %"PRIxVALUE, a);
+ if (SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const: %"PRIxVALUE, b);
+#else
+ RBIMPL_ASSERT_OR_ASSUME(!SPECIAL_CONST_P(a));
+ RBIMPL_ASSERT_OR_ASSUME(!SPECIAL_CONST_P(b));
+#endif
+
+ GC_ASSERT(!during_gc);
+ GC_ASSERT(RB_BUILTIN_TYPE(a) != T_NONE);
+ GC_ASSERT(RB_BUILTIN_TYPE(a) != T_MOVED);
+ GC_ASSERT(RB_BUILTIN_TYPE(a) != T_ZOMBIE);
+ GC_ASSERT(RB_BUILTIN_TYPE(b) != T_NONE);
+ GC_ASSERT(RB_BUILTIN_TYPE(b) != T_MOVED);
+ GC_ASSERT(RB_BUILTIN_TYPE(b) != T_ZOMBIE);
+
+ retry:
+ if (!is_incremental_marking(objspace)) {
+ if (!RVALUE_OLD_P(objspace, a) || RVALUE_OLD_P(objspace, b)) {
+ // do nothing
+ }
+ else {
+ gc_writebarrier_generational(a, b, objspace);
+ }
+ }
+ else {
+ bool retry = false;
+ /* slow path */
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ if (is_incremental_marking(objspace)) {
+ gc_writebarrier_incremental(a, b, objspace);
+ }
+ else {
+ retry = true;
+ }
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+
+ if (retry) goto retry;
+ }
+ return;
+}
+
+void
+rb_gc_impl_writebarrier_unprotect(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (RVALUE_WB_UNPROTECTED(objspace, obj)) {
+ return;
+ }
+ else {
+ gc_report(2, objspace, "rb_gc_writebarrier_unprotect: %s %s\n", rb_obj_info(obj),
+ RVALUE_REMEMBERED(objspace, obj) ? " (already remembered)" : "");
+
+ unsigned int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ if (RVALUE_OLD_P(objspace, obj)) {
+ gc_report(1, objspace, "rb_gc_writebarrier_unprotect: %s\n", rb_obj_info(obj));
+ RVALUE_DEMOTE(objspace, obj);
+ gc_mark_set(objspace, obj);
+ gc_remember_unprotected(objspace, obj);
+
+#if RGENGC_PROFILE
+ objspace->profile.total_shade_operation_count++;
+#if RGENGC_PROFILE >= 2
+ objspace->profile.shade_operation_count_types[BUILTIN_TYPE(obj)]++;
+#endif /* RGENGC_PROFILE >= 2 */
+#endif /* RGENGC_PROFILE */
+ }
+ else {
+ RVALUE_AGE_RESET(obj);
+ }
+
+ RB_DEBUG_COUNTER_INC(obj_wb_unprotect);
+ MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+ }
+}
+
+void
+rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (RVALUE_WB_UNPROTECTED(objspace, obj)) {
+ rb_gc_impl_writebarrier_unprotect(objspace, dest);
+ }
+ rb_gc_impl_copy_finalizer(objspace, dest, obj);
+}
+
+const char *
+rb_gc_impl_active_gc_name(void)
+{
+ return "default";
+}
+
+void
+rb_gc_impl_writebarrier_remember(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ gc_report(1, objspace, "rb_gc_writebarrier_remember: %s\n", rb_obj_info(obj));
+
+ if (is_incremental_marking(objspace) || RVALUE_OLD_P(objspace, obj)) {
+ int lev = RB_GC_VM_LOCK_NO_BARRIER();
+ {
+ if (is_incremental_marking(objspace)) {
+ if (RVALUE_BLACK_P(objspace, obj)) {
+ gc_grey(objspace, obj);
+ }
+ }
+ else if (RVALUE_OLD_P(objspace, obj)) {
+ rgengc_remember(objspace, obj);
+ }
+ }
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+ }
+}
+
+struct rb_gc_object_metadata_names {
+ // Must be ID only
+ ID ID_wb_protected, ID_age, ID_old, ID_uncollectible, ID_marking,
+ ID_marked, ID_pinned, ID_remembered, ID_object_id, ID_shareable;
+};
+
+#define RB_GC_OBJECT_METADATA_ENTRY_COUNT (sizeof(struct rb_gc_object_metadata_names) / sizeof(ID))
+static struct rb_gc_object_metadata_entry object_metadata_entries[RB_GC_OBJECT_METADATA_ENTRY_COUNT + 1];
+
+struct rb_gc_object_metadata_entry *
+rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ size_t n = 0;
+ static struct rb_gc_object_metadata_names names;
+
+ if (!names.ID_marked) {
+#define I(s) names.ID_##s = rb_intern(#s)
+ I(wb_protected);
+ I(age);
+ I(old);
+ I(uncollectible);
+ I(marking);
+ I(marked);
+ I(pinned);
+ I(remembered);
+ I(object_id);
+ I(shareable);
+#undef I
+ }
+
+#define SET_ENTRY(na, v) do { \
+ GC_ASSERT(n <= RB_GC_OBJECT_METADATA_ENTRY_COUNT); \
+ object_metadata_entries[n].name = names.ID_##na; \
+ object_metadata_entries[n].val = v; \
+ n++; \
+} while (0)
+
+ if (!RVALUE_WB_UNPROTECTED(objspace, obj)) SET_ENTRY(wb_protected, Qtrue);
+ SET_ENTRY(age, INT2FIX(RVALUE_AGE_GET(obj)));
+ if (RVALUE_OLD_P(objspace, obj)) SET_ENTRY(old, Qtrue);
+ if (RVALUE_UNCOLLECTIBLE(objspace, obj)) SET_ENTRY(uncollectible, Qtrue);
+ if (RVALUE_MARKING(objspace, obj)) SET_ENTRY(marking, Qtrue);
+ if (RVALUE_MARKED(objspace, obj)) SET_ENTRY(marked, Qtrue);
+ if (RVALUE_PINNED(objspace, obj)) SET_ENTRY(pinned, Qtrue);
+ if (RVALUE_REMEMBERED(objspace, obj)) SET_ENTRY(remembered, Qtrue);
+ if (rb_obj_id_p(obj)) SET_ENTRY(object_id, rb_obj_id(obj));
+ if (FL_TEST(obj, FL_SHAREABLE)) SET_ENTRY(shareable, Qtrue);
+
+ object_metadata_entries[n].name = 0;
+ object_metadata_entries[n].val = 0;
+#undef SET_ENTRY
+
+ return object_metadata_entries;
+}
+
+void *
+rb_gc_impl_ractor_cache_alloc(void *objspace_ptr, void *ractor)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ objspace->live_ractor_cache_count++;
+
+ return calloc1(sizeof(rb_ractor_newobj_cache_t));
+}
+
+void
+rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ objspace->live_ractor_cache_count--;
+ gc_ractor_newobj_cache_clear(cache, NULL);
+ free(cache);
+}
+
+static void
+heap_ready_to_gc(rb_objspace_t *objspace, rb_heap_t *heap)
+{
+ if (!heap->free_pages) {
+ if (!heap_page_allocate_and_initialize(objspace, heap)) {
+ objspace->heap_pages.allocatable_bytes = HEAP_PAGE_SIZE;
+ heap_page_allocate_and_initialize(objspace, heap);
+ }
+ }
+}
+
+static int
+ready_to_gc(rb_objspace_t *objspace)
+{
+ if (dont_gc_val() || during_gc) {
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ heap_ready_to_gc(objspace, heap);
+ }
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+}
+
+static void
+gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
+{
+ gc_prof_set_malloc_info(objspace);
+ {
+ int64_t inc = gc_malloc_counters_increase(objspace, &objspace->malloc_counters.counters);
+ size_t old_limit = malloc_limit;
+
+ /* A net-negative `inc` (more freed than malloc'd since last GC) is
+ * treated the same as "allocated less than malloc_limit".
+ * This matches what we were doing pre-monotonic counters, but is it right? */
+ if (inc > 0 && (size_t)inc > malloc_limit) {
+ malloc_limit = (size_t)((size_t)inc * gc_params.malloc_limit_growth_factor);
+ if (malloc_limit > gc_params.malloc_limit_max) {
+ malloc_limit = gc_params.malloc_limit_max;
+ }
+ }
+ else {
+ malloc_limit = (size_t)(malloc_limit * 0.98); /* magic number */
+ if (malloc_limit < gc_params.malloc_limit_min) {
+ malloc_limit = gc_params.malloc_limit_min;
+ }
+ }
+
+ if (0) {
+ if (old_limit != malloc_limit) {
+ fprintf(stderr, "[%"PRIuSIZE"] malloc_limit: %"PRIuSIZE" -> %"PRIuSIZE"\n",
+ rb_gc_count(), old_limit, malloc_limit);
+ }
+ else {
+ fprintf(stderr, "[%"PRIuSIZE"] malloc_limit: not changed (%"PRIuSIZE")\n",
+ rb_gc_count(), malloc_limit);
+ }
+ }
+ }
+
+ /* reset oldmalloc info */
+#if RGENGC_ESTIMATE_OLDMALLOC
+ if (!full_mark) {
+ /* Don't snapshot on minor GC: oldmalloc_increase is meant to
+ * accumulate across minor GCs and only reset at major GC. */
+ int64_t oldmalloc_increase = gc_malloc_counters_increase(objspace, &objspace->malloc_counters.oldcounters);
+ if (oldmalloc_increase > 0 &&
+ (uint64_t)oldmalloc_increase > objspace->rgengc.oldmalloc_increase_limit) {
+ gc_needs_major_flags |= GPR_FLAG_MAJOR_BY_OLDMALLOC;
+ objspace->rgengc.oldmalloc_increase_limit =
+ (size_t)(objspace->rgengc.oldmalloc_increase_limit * gc_params.oldmalloc_limit_growth_factor);
+
+ if (objspace->rgengc.oldmalloc_increase_limit > gc_params.oldmalloc_limit_max) {
+ objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_max;
+ }
+ }
+
+ if (0) fprintf(stderr, "%"PRIdSIZE"\t%d\t%"PRId64"\t%"PRIuSIZE"\t%"PRIdSIZE"\n",
+ rb_gc_count(),
+ gc_needs_major_flags,
+ oldmalloc_increase,
+ objspace->rgengc.oldmalloc_increase_limit,
+ gc_params.oldmalloc_limit_max);
+ }
+ else {
+ if ((objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_BY_OLDMALLOC) == 0) {
+ objspace->rgengc.oldmalloc_increase_limit =
+ (size_t)(objspace->rgengc.oldmalloc_increase_limit / ((gc_params.oldmalloc_limit_growth_factor - 1)/10 + 1));
+ if (objspace->rgengc.oldmalloc_increase_limit < gc_params.oldmalloc_limit_min) {
+ objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
+ }
+ }
+ }
+#endif
+}
+
+static int
+garbage_collect(rb_objspace_t *objspace, unsigned int reason)
+{
+ int ret;
+
+ int lev = RB_GC_VM_LOCK();
+ {
+#if GC_PROFILE_MORE_DETAIL
+ objspace->profile.prepare_time = getrusage_time();
+#endif
+
+ gc_rest(objspace);
+
+#if GC_PROFILE_MORE_DETAIL
+ objspace->profile.prepare_time = getrusage_time() - objspace->profile.prepare_time;
+#endif
+
+ ret = gc_start(objspace, reason);
+ }
+ RB_GC_VM_UNLOCK(lev);
+
+ return ret;
+}
+
+static int
+gc_start(rb_objspace_t *objspace, unsigned int reason)
+{
+ unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK);
+
+ if (!rb_darray_size(objspace->heap_pages.sorted)) return TRUE; /* heap is not ready */
+ if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
+
+ rb_gc_initialize_vm_context(&objspace->vm_context);
+
+ GC_ASSERT(gc_mode(objspace) == gc_mode_none, "gc_mode is %s\n", gc_mode_name(gc_mode(objspace)));
+ GC_ASSERT(!is_lazy_sweeping(objspace));
+ GC_ASSERT(!is_incremental_marking(objspace));
+
+ unsigned int lock_lev;
+ gc_enter(objspace, gc_enter_event_start, &lock_lev);
+
+ /* reason may be clobbered, later, so keep set immediate_sweep here */
+ objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
+
+ if (ruby_gc_stressful) {
+ int flag = FIXNUM_P(ruby_gc_stress_mode) ? FIX2INT(ruby_gc_stress_mode) : 0;
+
+ if ((flag & (1 << gc_stress_no_major)) == 0) {
+ do_full_mark = TRUE;
+ }
+
+ objspace->flags.immediate_sweep = !(flag & (1<<gc_stress_no_immediate_sweep));
+ }
+
+ if (gc_needs_major_flags) {
+ reason |= gc_needs_major_flags;
+ do_full_mark = TRUE;
+ }
+
+ /* if major gc has been disabled, never do a full mark */
+ if (!gc_config_full_mark_val) {
+ do_full_mark = FALSE;
+ }
+ gc_needs_major_flags = GPR_FLAG_NONE;
+
+ if (do_full_mark && (reason & GPR_FLAG_MAJOR_MASK) == 0) {
+ reason |= GPR_FLAG_MAJOR_BY_FORCE; /* GC by CAPI, METHOD, and so on. */
+ }
+
+ if (objspace->flags.dont_incremental ||
+ reason & GPR_FLAG_IMMEDIATE_MARK ||
+ ruby_gc_stressful) {
+ objspace->flags.during_incremental_marking = FALSE;
+ }
+ else {
+ objspace->flags.during_incremental_marking = do_full_mark;
+ }
+
+ /* Explicitly enable compaction (GC.compact) */
+ if (do_full_mark && ruby_enable_autocompact) {
+ objspace->flags.during_compacting = TRUE;
+#if RGENGC_CHECK_MODE
+ objspace->rcompactor.compare_func = ruby_autocompact_compare_func;
+#endif
+ }
+ else {
+ objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
+ }
+
+ if (!GC_ENABLE_LAZY_SWEEP || objspace->flags.dont_incremental) {
+ objspace->flags.immediate_sweep = TRUE;
+ }
+
+ if (objspace->flags.immediate_sweep) reason |= GPR_FLAG_IMMEDIATE_SWEEP;
+
+ gc_report(1, objspace, "gc_start(reason: %x) => %u, %d, %d\n",
+ reason,
+ do_full_mark, !is_incremental_marking(objspace), objspace->flags.immediate_sweep);
+
+ RB_DEBUG_COUNTER_INC(gc_count);
+
+ if (reason & GPR_FLAG_MAJOR_MASK) {
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_major_nofree, reason & GPR_FLAG_MAJOR_BY_NOFREE);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldgen, reason & GPR_FLAG_MAJOR_BY_OLDGEN);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_major_shady, reason & GPR_FLAG_MAJOR_BY_SHADY);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_major_force, reason & GPR_FLAG_MAJOR_BY_FORCE);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldmalloc, reason & GPR_FLAG_MAJOR_BY_OLDMALLOC);
+#endif
+ }
+ else {
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_newobj, reason & GPR_FLAG_NEWOBJ);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_malloc, reason & GPR_FLAG_MALLOC);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_method, reason & GPR_FLAG_METHOD);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_capi, reason & GPR_FLAG_CAPI);
+ (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_stress, reason & GPR_FLAG_STRESS);
+ }
+
+ objspace->profile.count++;
+ objspace->profile.latest_gc_info = reason;
+ objspace->profile.total_allocated_objects_at_gc_start = total_allocated_objects(objspace);
+ objspace->profile.heap_used_at_gc_start = rb_darray_size(objspace->heap_pages.sorted);
+ objspace->profile.heap_total_slots_at_gc_start = objspace_available_slots(objspace);
+ objspace->profile.weak_references_count = 0;
+ gc_prof_setup_new_record(objspace, reason);
+ gc_reset_malloc_info(objspace, do_full_mark);
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_START);
+
+ GC_ASSERT(during_gc);
+
+ gc_prof_timer_start(objspace);
+ {
+ if (gc_marks(objspace, do_full_mark)) {
+ gc_sweep(objspace);
+ }
+ }
+ gc_prof_timer_stop(objspace);
+
+ gc_exit(objspace, gc_enter_event_start, &lock_lev);
+ return TRUE;
+}
+
+static void
+gc_rest(rb_objspace_t *objspace)
+{
+ if (is_incremental_marking(objspace) || is_lazy_sweeping(objspace)) {
+ unsigned int lock_lev;
+ gc_enter(objspace, gc_enter_event_rest, &lock_lev);
+
+ if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(objspace);
+
+ if (is_incremental_marking(objspace)) {
+ gc_marking_enter(objspace);
+ gc_marks_rest(objspace);
+ gc_marking_exit(objspace);
+
+ gc_sweep(objspace);
+ }
+
+ if (is_lazy_sweeping(objspace)) {
+ gc_sweeping_enter(objspace);
+ gc_sweep_rest(objspace);
+ gc_sweeping_exit(objspace);
+ }
+
+ gc_exit(objspace, gc_enter_event_rest, &lock_lev);
+ }
+}
+
+struct objspace_and_reason {
+ rb_objspace_t *objspace;
+ unsigned int reason;
+};
+
+static void
+gc_current_status_fill(rb_objspace_t *objspace, char *buff)
+{
+ int i = 0;
+ if (is_marking(objspace)) {
+ buff[i++] = 'M';
+ if (is_full_marking(objspace)) buff[i++] = 'F';
+ if (is_incremental_marking(objspace)) buff[i++] = 'I';
+ }
+ else if (is_sweeping(objspace)) {
+ buff[i++] = 'S';
+ if (is_lazy_sweeping(objspace)) buff[i++] = 'L';
+ }
+ else {
+ buff[i++] = 'N';
+ }
+ buff[i] = '\0';
+}
+
+static const char *
+gc_current_status(rb_objspace_t *objspace)
+{
+ static char buff[0x10];
+ gc_current_status_fill(objspace, buff);
+ return buff;
+}
+
+#if PRINT_ENTER_EXIT_TICK
+
+static tick_t last_exit_tick;
+static tick_t enter_tick;
+static int enter_count = 0;
+static char last_gc_status[0x10];
+
+static inline void
+gc_record(rb_objspace_t *objspace, int direction, const char *event)
+{
+ if (direction == 0) { /* enter */
+ enter_count++;
+ enter_tick = tick();
+ gc_current_status_fill(objspace, last_gc_status);
+ }
+ else { /* exit */
+ tick_t exit_tick = tick();
+ char current_gc_status[0x10];
+ gc_current_status_fill(objspace, current_gc_status);
+#if 1
+ /* [last mutator time] [gc time] [event] */
+ fprintf(stderr, "%"PRItick"\t%"PRItick"\t%s\t[%s->%s|%c]\n",
+ enter_tick - last_exit_tick,
+ exit_tick - enter_tick,
+ event,
+ last_gc_status, current_gc_status,
+ (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) ? '+' : '-');
+ last_exit_tick = exit_tick;
+#else
+ /* [enter_tick] [gc time] [event] */
+ fprintf(stderr, "%"PRItick"\t%"PRItick"\t%s\t[%s->%s|%c]\n",
+ enter_tick,
+ exit_tick - enter_tick,
+ event,
+ last_gc_status, current_gc_status,
+ (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) ? '+' : '-');
+#endif
+ }
+}
+#else /* PRINT_ENTER_EXIT_TICK */
+static inline void
+gc_record(rb_objspace_t *objspace, int direction, const char *event)
+{
+ /* null */
+}
+#endif /* PRINT_ENTER_EXIT_TICK */
+
+static const char *
+gc_enter_event_cstr(enum gc_enter_event event)
+{
+ switch (event) {
+ case gc_enter_event_start: return "start";
+ case gc_enter_event_continue: return "continue";
+ case gc_enter_event_rest: return "rest";
+ case gc_enter_event_finalizer: return "finalizer";
+ }
+ return NULL;
+}
+
+static void
+gc_enter_count(enum gc_enter_event event)
+{
+ switch (event) {
+ case gc_enter_event_start: RB_DEBUG_COUNTER_INC(gc_enter_start); break;
+ case gc_enter_event_continue: RB_DEBUG_COUNTER_INC(gc_enter_continue); break;
+ case gc_enter_event_rest: RB_DEBUG_COUNTER_INC(gc_enter_rest); break;
+ case gc_enter_event_finalizer: RB_DEBUG_COUNTER_INC(gc_enter_finalizer); break;
+ }
+}
+
+static bool current_process_time(struct timespec *ts);
+
+static void
+gc_clock_start(struct timespec *ts)
+{
+ if (!current_process_time(ts)) {
+ ts->tv_sec = 0;
+ ts->tv_nsec = 0;
+ }
+}
+
+static unsigned long long
+gc_clock_end(struct timespec *ts)
+{
+ struct timespec end_time;
+
+ if ((ts->tv_sec > 0 || ts->tv_nsec > 0) &&
+ current_process_time(&end_time) &&
+ end_time.tv_sec >= ts->tv_sec) {
+ return (unsigned long long)(end_time.tv_sec - ts->tv_sec) * (1000 * 1000 * 1000) +
+ (end_time.tv_nsec - ts->tv_nsec);
+ }
+
+ return 0;
+}
+
+static inline void
+gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev)
+{
+ *lock_lev = RB_GC_VM_LOCK();
+
+ switch (event) {
+ case gc_enter_event_rest:
+ case gc_enter_event_start:
+ case gc_enter_event_continue:
+ // stop other ractors
+ rb_gc_vm_barrier();
+ break;
+ default:
+ break;
+ }
+
+ gc_enter_count(event);
+ if (RB_UNLIKELY(during_gc != 0)) rb_bug("during_gc != 0");
+ if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
+
+ during_gc = TRUE;
+ RUBY_DEBUG_LOG("%s (%s)",gc_enter_event_cstr(event), gc_current_status(objspace));
+ gc_report(1, objspace, "gc_enter: %s [%s]\n", gc_enter_event_cstr(event), gc_current_status(objspace));
+ gc_record(objspace, 0, gc_enter_event_cstr(event));
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_ENTER);
+}
+
+static inline void
+gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev)
+{
+ GC_ASSERT(during_gc != 0);
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_EXIT);
+
+ gc_record(objspace, 1, gc_enter_event_cstr(event));
+ RUBY_DEBUG_LOG("%s (%s)", gc_enter_event_cstr(event), gc_current_status(objspace));
+ gc_report(1, objspace, "gc_exit: %s [%s]\n", gc_enter_event_cstr(event), gc_current_status(objspace));
+ during_gc = FALSE;
+
+ RB_GC_VM_UNLOCK(*lock_lev);
+}
+
+#ifndef MEASURE_GC
+#define MEASURE_GC (objspace->flags.measure_gc)
+#endif
+
+static void
+gc_marking_enter(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ gc_prof_mark_timer_start(objspace);
+
+ if (MEASURE_GC) {
+ gc_clock_start(&objspace->profile.marking_start_time);
+ }
+
+ rb_gc_initialize_vm_context(&objspace->vm_context);
+}
+
+static void
+gc_marking_exit(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ objspace->profile.marking_time_ns += gc_clock_end(&objspace->profile.marking_start_time);
+ }
+
+ gc_prof_mark_timer_stop(objspace);
+}
+
+static void
+gc_sweeping_enter(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ gc_clock_start(&objspace->profile.sweeping_start_time);
+ }
+}
+
+static void
+gc_sweeping_exit(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ objspace->profile.sweeping_time_ns += gc_clock_end(&objspace->profile.sweeping_start_time);
+ }
+}
+
+static void *
+gc_with_gvl(void *ptr)
+{
+ struct objspace_and_reason *oar = (struct objspace_and_reason *)ptr;
+ return (void *)(VALUE)garbage_collect(oar->objspace, oar->reason);
+}
+
+int ruby_thread_has_gvl_p(void);
+
+static int
+garbage_collect_with_gvl(rb_objspace_t *objspace, unsigned int reason)
+{
+ if (dont_gc_val()) {
+ return TRUE;
+ }
+ else if (!ruby_native_thread_p()) {
+ return TRUE;
+ }
+ else if (!ruby_thread_has_gvl_p()) {
+ void *ret;
+ struct objspace_and_reason oar;
+ oar.objspace = objspace;
+ oar.reason = reason;
+ ret = rb_thread_call_with_gvl(gc_with_gvl, (void *)&oar);
+
+ return !!ret;
+ }
+ else {
+ return garbage_collect(objspace, reason);
+ }
+}
+
+static int
+gc_set_candidate_object_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)data;
+
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ asan_unpoisoning_object(v) {
+ switch (BUILTIN_TYPE(v)) {
+ case T_NONE:
+ case T_ZOMBIE:
+ break;
+ default:
+ rb_gc_prepare_heap_process_object(v);
+ if (!RVALUE_OLD_P(objspace, v) && !RVALUE_WB_UNPROTECTED(objspace, v)) {
+ RVALUE_AGE_SET_CANDIDATE(objspace, v);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+void
+rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ unsigned int reason = (GPR_FLAG_FULL_MARK |
+ GPR_FLAG_IMMEDIATE_MARK |
+ GPR_FLAG_IMMEDIATE_SWEEP |
+ GPR_FLAG_METHOD);
+
+ int full_marking_p = gc_config_full_mark_val;
+ gc_config_full_mark_set(TRUE);
+
+ /* For now, compact implies full mark / sweep, so ignore other flags */
+ if (compact) {
+ GC_ASSERT(GC_COMPACTION_SUPPORTED);
+
+ reason |= GPR_FLAG_COMPACT;
+ }
+ else {
+ if (!full_mark) reason &= ~GPR_FLAG_FULL_MARK;
+ if (!immediate_mark) reason &= ~GPR_FLAG_IMMEDIATE_MARK;
+ if (!immediate_sweep) reason &= ~GPR_FLAG_IMMEDIATE_SWEEP;
+ }
+
+ garbage_collect(objspace, reason);
+ gc_finalize_deferred(objspace);
+
+ gc_config_full_mark_set(full_marking_p);
+}
+
+void
+rb_gc_impl_prepare_heap(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ size_t orig_total_slots = objspace_available_slots(objspace);
+ size_t orig_allocatable_bytes = objspace->heap_pages.allocatable_bytes;
+
+ rb_gc_impl_each_objects(objspace, gc_set_candidate_object_i, objspace_ptr);
+
+ double orig_max_free_slots = gc_params.heap_free_slots_max_ratio;
+ /* Ensure that all empty pages are moved onto empty_pages. */
+ gc_params.heap_free_slots_max_ratio = 0.0;
+ rb_gc_impl_start(objspace, true, true, true, true);
+ gc_params.heap_free_slots_max_ratio = orig_max_free_slots;
+
+ objspace->heap_pages.allocatable_bytes = 0;
+ heap_pages_freeable_pages = objspace->empty_pages_count;
+ heap_pages_free_unused_pages(objspace_ptr);
+ GC_ASSERT(heap_pages_freeable_pages == 0);
+ GC_ASSERT(objspace->empty_pages_count == 0);
+ objspace->heap_pages.allocatable_bytes = orig_allocatable_bytes;
+
+ size_t total_slots = objspace_available_slots(objspace);
+ if (orig_total_slots > total_slots) {
+ objspace->heap_pages.allocatable_bytes += (orig_total_slots - total_slots) * heaps[0].slot_size;
+ }
+
+#if defined(HAVE_MALLOC_TRIM) && !defined(RUBY_ALTERNATIVE_MALLOC_HEADER)
+ malloc_trim(0);
+#endif
+}
+
+static int
+gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
+{
+ GC_ASSERT(!SPECIAL_CONST_P(obj));
+
+ switch (BUILTIN_TYPE(obj)) {
+ case T_NONE:
+ case T_MOVED:
+ case T_ZOMBIE:
+ return FALSE;
+ case T_SYMBOL:
+ case T_STRING:
+ case T_OBJECT:
+ case T_FLOAT:
+ case T_IMEMO:
+ case T_ARRAY:
+ case T_BIGNUM:
+ case T_ICLASS:
+ case T_MODULE:
+ case T_REGEXP:
+ case T_DATA:
+ case T_MATCH:
+ case T_STRUCT:
+ case T_HASH:
+ case T_FILE:
+ case T_COMPLEX:
+ case T_RATIONAL:
+ case T_NODE:
+ case T_CLASS:
+ if (FL_TEST_RAW(obj, FL_FINALIZE)) {
+ /* The finalizer table is a numtable. It looks up objects by address.
+ * We can't mark the keys in the finalizer table because that would
+ * prevent the objects from being collected. This check prevents
+ * objects that are keys in the finalizer table from being moved
+ * without directly pinning them. */
+ GC_ASSERT(st_is_member(finalizer_table, obj));
+
+ return FALSE;
+ }
+ GC_ASSERT(RVALUE_MARKED(objspace, obj));
+ GC_ASSERT(!RVALUE_PINNED(objspace, obj));
+
+ return TRUE;
+
+ default:
+ rb_bug("gc_is_moveable_obj: unreachable (%d)", (int)BUILTIN_TYPE(obj));
+ break;
+ }
+
+ return FALSE;
+}
+
+void rb_mv_generic_ivar(VALUE src, VALUE dst);
+
+static VALUE
+gc_move(rb_objspace_t *objspace, VALUE src, VALUE dest, struct heap_page *src_page, struct heap_page *dest_page)
+{
+ size_t src_slot_size = src_page->slot_size;
+ size_t slot_size = dest_page->slot_size;
+
+ int marked;
+ int wb_unprotected;
+ int uncollectible;
+ int age;
+
+ gc_report(4, objspace, "Moving object: %p -> %p\n", (void *)src, (void *)dest);
+
+ GC_ASSERT(BUILTIN_TYPE(src) != T_NONE);
+ GC_ASSERT(!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(dest), dest));
+
+ GC_ASSERT(!RVALUE_MARKING(objspace, src));
+
+ /* Save off bits for current object. */
+ marked = RVALUE_MARKED(objspace, src);
+ wb_unprotected = RVALUE_WB_UNPROTECTED(objspace, src);
+ uncollectible = RVALUE_UNCOLLECTIBLE(objspace, src);
+ bool remembered = RVALUE_REMEMBERED(objspace, src);
+ age = RVALUE_AGE_GET(src);
+
+ /* Clear bits for eventual T_MOVED */
+ CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS(src), src);
+ CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(src), src);
+ CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(src), src);
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE(src)->remembered_bits, src);
+
+ /* Move the object */
+ memcpy((void *)dest, (void *)src, MIN(src_slot_size, slot_size));
+
+ if (src_slot_size != slot_size && RB_TYPE_P(src, T_OBJECT)) {
+ rb_gc_obj_changed_pool(dest, dest_page->heap - heaps);
+ }
+
+ if (RVALUE_OVERHEAD > 0) {
+ void *dest_overhead = (void *)(((uintptr_t)dest) + slot_size - RVALUE_OVERHEAD);
+ void *src_overhead = (void *)(((uintptr_t)src) + src_slot_size - RVALUE_OVERHEAD);
+
+ memcpy(dest_overhead, src_overhead, RVALUE_OVERHEAD);
+ }
+
+ memset((void *)src, 0, src_slot_size);
+ RVALUE_AGE_SET_BITMAP(src, 0);
+
+ /* Set bits for object in new location */
+ if (remembered) {
+ MARK_IN_BITMAP(GET_HEAP_PAGE(dest)->remembered_bits, dest);
+ }
+ else {
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE(dest)->remembered_bits, dest);
+ }
+
+ if (marked) {
+ MARK_IN_BITMAP(GET_HEAP_MARK_BITS(dest), dest);
+ }
+ else {
+ CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS(dest), dest);
+ }
+
+ if (wb_unprotected) {
+ MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
+ }
+ else {
+ CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
+ }
+
+ if (uncollectible) {
+ MARK_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(dest), dest);
+ }
+ else {
+ CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(dest), dest);
+ }
+
+ RVALUE_AGE_SET(dest, age);
+ /* Assign forwarding address */
+ RMOVED(src)->flags = T_MOVED;
+ RMOVED(src)->dummy = Qundef;
+ RMOVED(src)->destination = dest;
+ GC_ASSERT(BUILTIN_TYPE(dest) != T_NONE);
+
+ GET_HEAP_PAGE(src)->heap->total_freed_objects++;
+ GET_HEAP_PAGE(dest)->heap->total_allocated_objects++;
+
+ return src;
+}
+
+#if GC_CAN_COMPILE_COMPACTION
+static int
+compare_pinned_slots(const void *left, const void *right, void *dummy)
+{
+ struct heap_page *left_page;
+ struct heap_page *right_page;
+
+ left_page = *(struct heap_page * const *)left;
+ right_page = *(struct heap_page * const *)right;
+
+ return left_page->pinned_slots - right_page->pinned_slots;
+}
+
+static int
+compare_free_slots(const void *left, const void *right, void *dummy)
+{
+ struct heap_page *left_page;
+ struct heap_page *right_page;
+
+ left_page = *(struct heap_page * const *)left;
+ right_page = *(struct heap_page * const *)right;
+
+ return left_page->free_slots - right_page->free_slots;
+}
+
+static void
+gc_sort_heap_by_compare_func(rb_objspace_t *objspace, gc_compact_compare_func compare_func)
+{
+ for (int j = 0; j < HEAP_COUNT; j++) {
+ rb_heap_t *heap = &heaps[j];
+
+ size_t total_pages = heap->total_pages;
+ size_t size = rb_size_mul_or_raise(total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
+ struct heap_page *page = 0, **page_list = malloc(size);
+ size_t i = 0;
+
+ heap->free_pages = NULL;
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page_list[i++] = page;
+ GC_ASSERT(page);
+ }
+
+ GC_ASSERT((size_t)i == total_pages);
+
+ /* Sort the heap so "filled pages" are first. `heap_add_page` adds to the
+ * head of the list, so empty pages will end up at the start of the heap */
+ ruby_qsort(page_list, total_pages, sizeof(struct heap_page *), compare_func, NULL);
+
+ /* Reset the eden heap */
+ ccan_list_head_init(&heap->pages);
+
+ for (i = 0; i < total_pages; i++) {
+ ccan_list_add(&heap->pages, &page_list[i]->page_node);
+ if (page_list[i]->free_slots != 0) {
+ heap_add_freepage(heap, page_list[i]);
+ }
+ }
+
+ free(page_list);
+ }
+}
+#endif
+
+void
+rb_gc_impl_register_pinning_obj(void *objspace_ptr, VALUE obj)
+{
+ /* no-op */
+}
+
+bool
+rb_gc_impl_object_moved_p(void *objspace_ptr, VALUE obj)
+{
+ return gc_object_moved_p(objspace_ptr, obj);
+}
+
+static int
+gc_ref_update(void *vstart, void *vend, size_t stride, rb_objspace_t *objspace, struct heap_page *page)
+{
+ VALUE v = (VALUE)vstart;
+
+ page->flags.has_uncollectible_wb_unprotected_objects = FALSE;
+ page->flags.has_remembered_objects = FALSE;
+
+ /* For each object on the page */
+ for (; v != (VALUE)vend; v += stride) {
+ asan_unpoisoning_object(v) {
+ switch (BUILTIN_TYPE(v)) {
+ case T_NONE:
+ case T_MOVED:
+ case T_ZOMBIE:
+ break;
+ default:
+ if (RVALUE_WB_UNPROTECTED(objspace, v)) {
+ page->flags.has_uncollectible_wb_unprotected_objects = TRUE;
+ }
+ if (RVALUE_REMEMBERED(objspace, v)) {
+ page->flags.has_remembered_objects = TRUE;
+ }
+ if (page->flags.before_sweep) {
+ if (RVALUE_MARKED(objspace, v)) {
+ rb_gc_update_object_references(objspace, v);
+ }
+ }
+ else {
+ rb_gc_update_object_references(objspace, v);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int
+gc_update_references_weak_table_i(VALUE obj, void *data)
+{
+ int ret;
+ asan_unpoisoning_object(obj) {
+ ret = BUILTIN_TYPE(obj) == T_MOVED ? ST_REPLACE : ST_CONTINUE;
+ }
+ return ret;
+}
+
+static int
+gc_update_references_weak_table_replace_i(VALUE *obj, void *data)
+{
+ *obj = rb_gc_location(*obj);
+
+ return ST_CONTINUE;
+}
+
+static void
+gc_update_references(rb_objspace_t *objspace)
+{
+ objspace->flags.during_reference_updating = true;
+
+ rb_gc_before_updating_jit_code();
+
+ struct heap_page *page = NULL;
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ bool should_set_mark_bits = TRUE;
+ rb_heap_t *heap = &heaps[i];
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ uintptr_t start = (uintptr_t)page->start;
+ uintptr_t end = start + (page->total_slots * heap->slot_size);
+
+ gc_ref_update((void *)start, (void *)end, heap->slot_size, objspace, page);
+ if (page == heap->sweeping_page) {
+ should_set_mark_bits = FALSE;
+ }
+ if (should_set_mark_bits) {
+ gc_setup_mark_bits(page);
+ }
+ }
+ }
+
+ gc_update_table_refs(finalizer_table);
+
+ rb_gc_update_vm_references((void *)objspace);
+
+ for (int table = 0; table < RB_GC_VM_WEAK_TABLE_COUNT; table++) {
+ rb_gc_vm_weak_table_foreach(
+ gc_update_references_weak_table_i,
+ gc_update_references_weak_table_replace_i,
+ NULL,
+ false,
+ table
+ );
+ }
+
+ rb_gc_after_updating_jit_code();
+
+ objspace->flags.during_reference_updating = false;
+}
+
+#if GC_CAN_COMPILE_COMPACTION
+static void
+root_obj_check_moved_i(const char *category, VALUE obj, void *data)
+{
+ rb_objspace_t *objspace = data;
+
+ if (gc_object_moved_p(objspace, obj)) {
+ rb_bug("ROOT %s points to MOVED: %p -> %s", category, (void *)obj, rb_obj_info(rb_gc_impl_location(objspace, obj)));
+ }
+}
+
+static void
+reachable_object_check_moved_i(VALUE ref, void *data)
+{
+ VALUE parent = (VALUE)data;
+ if (gc_object_moved_p(rb_gc_get_objspace(), ref)) {
+ rb_bug("Object %s points to MOVED: %p -> %s", rb_obj_info(parent), (void *)ref, rb_obj_info(rb_gc_impl_location(rb_gc_get_objspace(), ref)));
+ }
+}
+
+static int
+heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ rb_objspace_t *objspace = data;
+
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ if (gc_object_moved_p(objspace, v)) {
+ /* Moved object still on the heap, something may have a reference. */
+ }
+ else {
+ asan_unpoisoning_object(v) {
+ switch (BUILTIN_TYPE(v)) {
+ case T_NONE:
+ case T_ZOMBIE:
+ break;
+ default:
+ if (!rb_gc_impl_garbage_object_p(objspace, v)) {
+ rb_objspace_reachable_objects_from(v, reachable_object_check_moved_i, (void *)v);
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+#endif
+
+bool
+rb_gc_impl_during_gc_p(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ return during_gc;
+}
+
+#if RGENGC_PROFILE >= 2
+
+static const char*
+type_name(int type, VALUE obj)
+{
+ switch ((enum ruby_value_type)type) {
+ case RUBY_T_NONE: return "T_NONE";
+ case RUBY_T_OBJECT: return "T_OBJECT";
+ case RUBY_T_CLASS: return "T_CLASS";
+ case RUBY_T_MODULE: return "T_MODULE";
+ case RUBY_T_FLOAT: return "T_FLOAT";
+ case RUBY_T_STRING: return "T_STRING";
+ case RUBY_T_REGEXP: return "T_REGEXP";
+ case RUBY_T_ARRAY: return "T_ARRAY";
+ case RUBY_T_HASH: return "T_HASH";
+ case RUBY_T_STRUCT: return "T_STRUCT";
+ case RUBY_T_BIGNUM: return "T_BIGNUM";
+ case RUBY_T_FILE: return "T_FILE";
+ case RUBY_T_DATA: return "T_DATA";
+ case RUBY_T_MATCH: return "T_MATCH";
+ case RUBY_T_COMPLEX: return "T_COMPLEX";
+ case RUBY_T_RATIONAL: return "T_RATIONAL";
+ case RUBY_T_NIL: return "T_NIL";
+ case RUBY_T_TRUE: return "T_TRUE";
+ case RUBY_T_FALSE: return "T_FALSE";
+ case RUBY_T_SYMBOL: return "T_SYMBOL";
+ case RUBY_T_FIXNUM: return "T_FIXNUM";
+ case RUBY_T_UNDEF: return "T_UNDEF";
+ case RUBY_T_IMEMO: return "T_IMEMO";
+ case RUBY_T_NODE: return "T_NODE";
+ case RUBY_T_ICLASS: return "T_ICLASS";
+ case RUBY_T_ZOMBIE: return "T_ZOMBIE";
+ case RUBY_T_MOVED: return "T_MOVED";
+ default: return "unknown";
+ }
+}
+
+static void
+gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
+{
+ VALUE result = rb_hash_new_with_size(T_MASK);
+ int i;
+ for (i=0; i<T_MASK; i++) {
+ const char *type = type_name(i, 0);
+ rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i]));
+ }
+ rb_hash_aset(hash, ID2SYM(rb_intern(name)), result);
+}
+#endif
+
+size_t
+rb_gc_impl_gc_count(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ return objspace->profile.count;
+}
+
+static VALUE
+gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned int orig_flags)
+{
+ static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state, sym_need_major_by;
+ static VALUE sym_nofree, sym_oldgen, sym_shady, sym_force, sym_stress;
+#if RGENGC_ESTIMATE_OLDMALLOC
+ static VALUE sym_oldmalloc;
+#endif
+ static VALUE sym_newobj, sym_malloc, sym_method, sym_capi;
+ static VALUE sym_none, sym_marking, sym_sweeping;
+ static VALUE sym_weak_references_count;
+ VALUE hash = Qnil, key = Qnil;
+ VALUE major_by, need_major_by;
+ unsigned int flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
+
+ if (SYMBOL_P(hash_or_key)) {
+ key = hash_or_key;
+ }
+ else if (RB_TYPE_P(hash_or_key, T_HASH)) {
+ hash = hash_or_key;
+ }
+ else {
+ rb_bug("gc_info_decode: non-hash or symbol given");
+ }
+
+ if (NIL_P(sym_major_by)) {
+#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
+ S(major_by);
+ S(gc_by);
+ S(immediate_sweep);
+ S(have_finalizer);
+ S(state);
+ S(need_major_by);
+
+ S(stress);
+ S(nofree);
+ S(oldgen);
+ S(shady);
+ S(force);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ S(oldmalloc);
+#endif
+ S(newobj);
+ S(malloc);
+ S(method);
+ S(capi);
+
+ S(none);
+ S(marking);
+ S(sweeping);
+
+ S(weak_references_count);
+#undef S
+ }
+
+#define SET(name, attr) \
+ if (key == sym_##name) \
+ return (attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, sym_##name, (attr));
+
+ major_by =
+ (flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
+ (flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
+ (flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
+ (flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
+#if RGENGC_ESTIMATE_OLDMALLOC
+ (flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
+#endif
+ Qnil;
+ SET(major_by, major_by);
+
+ if (orig_flags == 0) { /* set need_major_by only if flags not set explicitly */
+ unsigned int need_major_flags = gc_needs_major_flags;
+ need_major_by =
+ (need_major_flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
+#if RGENGC_ESTIMATE_OLDMALLOC
+ (need_major_flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
+#endif
+ Qnil;
+ SET(need_major_by, need_major_by);
+ }
+
+ SET(gc_by,
+ (flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
+ (flags & GPR_FLAG_MALLOC) ? sym_malloc :
+ (flags & GPR_FLAG_METHOD) ? sym_method :
+ (flags & GPR_FLAG_CAPI) ? sym_capi :
+ (flags & GPR_FLAG_STRESS) ? sym_stress :
+ Qnil
+ );
+
+ SET(have_finalizer, (flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse);
+ SET(immediate_sweep, (flags & GPR_FLAG_IMMEDIATE_SWEEP) ? Qtrue : Qfalse);
+
+ if (orig_flags == 0) {
+ SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
+ gc_mode(objspace) == gc_mode_marking ? sym_marking : sym_sweeping);
+ }
+
+ SET(weak_references_count, LONG2FIX(objspace->profile.weak_references_count));
+#undef SET
+
+ if (!NIL_P(key)) {
+ // Matched key should return above
+ return Qundef;
+ }
+
+ return hash;
+}
+
+VALUE
+rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE key)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ return gc_info_decode(objspace, key, 0);
+}
+
+
+enum gc_stat_sym {
+ gc_stat_sym_count,
+ gc_stat_sym_time,
+ gc_stat_sym_marking_time,
+ gc_stat_sym_sweeping_time,
+ gc_stat_sym_heap_allocated_pages,
+ gc_stat_sym_heap_empty_pages,
+ gc_stat_sym_heap_allocatable_bytes,
+ gc_stat_sym_heap_available_slots,
+ gc_stat_sym_heap_live_slots,
+ gc_stat_sym_heap_free_slots,
+ gc_stat_sym_heap_final_slots,
+ gc_stat_sym_heap_marked_slots,
+ gc_stat_sym_heap_eden_pages,
+ gc_stat_sym_total_allocated_pages,
+ gc_stat_sym_total_freed_pages,
+ gc_stat_sym_total_allocated_objects,
+ gc_stat_sym_total_freed_objects,
+ gc_stat_sym_total_malloc_bytes,
+ gc_stat_sym_total_free_bytes,
+ gc_stat_sym_malloc_increase_bytes,
+ gc_stat_sym_malloc_increase_bytes_limit,
+ gc_stat_sym_minor_gc_count,
+ gc_stat_sym_major_gc_count,
+ gc_stat_sym_compact_count,
+ gc_stat_sym_read_barrier_faults,
+ gc_stat_sym_total_moved_objects,
+ gc_stat_sym_remembered_wb_unprotected_objects,
+ gc_stat_sym_remembered_wb_unprotected_objects_limit,
+ gc_stat_sym_old_objects,
+ gc_stat_sym_old_objects_limit,
+#if RGENGC_ESTIMATE_OLDMALLOC
+ gc_stat_sym_oldmalloc_increase_bytes,
+ gc_stat_sym_oldmalloc_increase_bytes_limit,
+#endif
+#if RGENGC_PROFILE
+ gc_stat_sym_total_generated_normal_object_count,
+ gc_stat_sym_total_generated_shady_object_count,
+ gc_stat_sym_total_shade_operation_count,
+ gc_stat_sym_total_promoted_count,
+ gc_stat_sym_total_remembered_normal_object_count,
+ gc_stat_sym_total_remembered_shady_object_count,
+#endif
+ gc_stat_sym_last
+};
+
+static VALUE gc_stat_symbols[gc_stat_sym_last];
+
+static void
+setup_gc_stat_symbols(void)
+{
+ if (gc_stat_symbols[0] == 0) {
+#define S(s) gc_stat_symbols[gc_stat_sym_##s] = ID2SYM(rb_intern_const(#s))
+ S(count);
+ S(time);
+ S(marking_time),
+ S(sweeping_time),
+ S(heap_allocated_pages);
+ S(heap_empty_pages);
+ S(heap_allocatable_bytes);
+ S(heap_available_slots);
+ S(heap_live_slots);
+ S(heap_free_slots);
+ S(heap_final_slots);
+ S(heap_marked_slots);
+ S(heap_eden_pages);
+ S(total_allocated_pages);
+ S(total_freed_pages);
+ S(total_allocated_objects);
+ S(total_freed_objects);
+ S(total_malloc_bytes);
+ S(total_free_bytes);
+ S(malloc_increase_bytes);
+ S(malloc_increase_bytes_limit);
+ S(minor_gc_count);
+ S(major_gc_count);
+ S(compact_count);
+ S(read_barrier_faults);
+ S(total_moved_objects);
+ S(remembered_wb_unprotected_objects);
+ S(remembered_wb_unprotected_objects_limit);
+ S(old_objects);
+ S(old_objects_limit);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ S(oldmalloc_increase_bytes);
+ S(oldmalloc_increase_bytes_limit);
+#endif
+#if RGENGC_PROFILE
+ S(total_generated_normal_object_count);
+ S(total_generated_shady_object_count);
+ S(total_shade_operation_count);
+ S(total_promoted_count);
+ S(total_remembered_normal_object_count);
+ S(total_remembered_shady_object_count);
+#endif /* RGENGC_PROFILE */
+#undef S
+ }
+}
+
+static uint64_t
+ns_to_ms(uint64_t ns)
+{
+ return ns / (1000 * 1000);
+}
+
+static void malloc_increase_local_flush(rb_objspace_t *objspace);
+
+VALUE
+rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ VALUE hash = Qnil, key = Qnil;
+
+ setup_gc_stat_symbols();
+
+ ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());
+ malloc_increase_local_flush(objspace);
+
+ if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ hash = hash_or_sym;
+ }
+ else if (SYMBOL_P(hash_or_sym)) {
+ key = hash_or_sym;
+ }
+ else {
+ rb_bug("non-hash or symbol given");
+ }
+
+#define SET(name, attr) \
+ if (key == gc_stat_symbols[gc_stat_sym_##name]) \
+ return SIZET2NUM(attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
+#define SET64(name, attr) \
+ if (key == gc_stat_symbols[gc_stat_sym_##name]) \
+ return ULL2NUM(attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], ULL2NUM(attr));
+
+ SET(count, objspace->profile.count);
+ SET(time, (size_t)ns_to_ms(objspace->profile.marking_time_ns + objspace->profile.sweeping_time_ns)); // TODO: UINT64T2NUM
+ SET(marking_time, (size_t)ns_to_ms(objspace->profile.marking_time_ns));
+ SET(sweeping_time, (size_t)ns_to_ms(objspace->profile.sweeping_time_ns));
+
+ {
+ uint64_t total_malloc = (uint64_t)gc_counter_load_relaxed(&objspace->malloc_counters.counters.malloc);
+ uint64_t total_free = (uint64_t)gc_counter_load_relaxed(&objspace->malloc_counters.counters.free);
+ SET64(total_malloc_bytes, total_malloc);
+ SET64(total_free_bytes, total_free);
+ }
+
+ /* implementation dependent counters (small / fixnum-safe) */
+ SET(heap_allocated_pages, rb_darray_size(objspace->heap_pages.sorted));
+ SET(heap_empty_pages, objspace->empty_pages_count)
+ SET(heap_allocatable_bytes, objspace->heap_pages.allocatable_bytes);
+ SET(heap_eden_pages, heap_eden_total_pages(objspace));
+ SET(total_allocated_pages, objspace->heap_pages.allocated_pages);
+ SET(total_freed_pages, objspace->heap_pages.freed_pages);
+ SET(malloc_increase_bytes, gc_malloc_counters_increase_unsigned(objspace, &objspace->malloc_counters.counters));
+ SET(malloc_increase_bytes_limit, malloc_limit);
+ SET(minor_gc_count, objspace->profile.minor_gc_count);
+ SET(major_gc_count, objspace->profile.major_gc_count);
+ SET(compact_count, objspace->profile.compact_count);
+ SET(read_barrier_faults, objspace->profile.read_barrier_faults);
+ SET(total_moved_objects, objspace->rcompactor.total_moved);
+ SET(remembered_wb_unprotected_objects, objspace->rgengc.uncollectible_wb_unprotected_objects);
+ SET(remembered_wb_unprotected_objects_limit, objspace->rgengc.uncollectible_wb_unprotected_objects_limit);
+ SET(old_objects, objspace->rgengc.old_objects);
+ SET(old_objects_limit, objspace->rgengc.old_objects_limit);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ SET(oldmalloc_increase_bytes, gc_malloc_counters_increase_unsigned(objspace, &objspace->malloc_counters.oldcounters));
+ SET(oldmalloc_increase_bytes_limit, objspace->rgengc.oldmalloc_increase_limit);
+#endif
+
+ ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());
+ SET(total_allocated_objects, total_allocated_objects(objspace));
+ SET(total_freed_objects, total_freed_objects(objspace));
+ SET(heap_available_slots, objspace_available_slots(objspace));
+ SET(heap_live_slots, objspace_live_slots(objspace));
+ SET(heap_free_slots, objspace_free_slots(objspace));
+ SET(heap_final_slots, total_final_slots_count(objspace));
+ SET(heap_marked_slots, objspace->marked_slots);
+
+#if RGENGC_PROFILE
+ SET(total_generated_normal_object_count, objspace->profile.total_generated_normal_object_count);
+ SET(total_generated_shady_object_count, objspace->profile.total_generated_shady_object_count);
+ SET(total_shade_operation_count, objspace->profile.total_shade_operation_count);
+ SET(total_promoted_count, objspace->profile.total_promoted_count);
+ SET(total_remembered_normal_object_count, objspace->profile.total_remembered_normal_object_count);
+ SET(total_remembered_shady_object_count, objspace->profile.total_remembered_shady_object_count);
+#endif /* RGENGC_PROFILE */
+#undef SET
+#undef SET64
+
+ if (!NIL_P(key)) {
+ // Matched key should return above
+ return Qundef;
+ }
+
+#if defined(RGENGC_PROFILE) && RGENGC_PROFILE >= 2
+ if (hash != Qnil) {
+ gc_count_add_each_types(hash, "generated_normal_object_count_types", objspace->profile.generated_normal_object_count_types);
+ gc_count_add_each_types(hash, "generated_shady_object_count_types", objspace->profile.generated_shady_object_count_types);
+ gc_count_add_each_types(hash, "shade_operation_count_types", objspace->profile.shade_operation_count_types);
+ gc_count_add_each_types(hash, "promoted_types", objspace->profile.promoted_types);
+ gc_count_add_each_types(hash, "remembered_normal_object_count_types", objspace->profile.remembered_normal_object_count_types);
+ gc_count_add_each_types(hash, "remembered_shady_object_count_types", objspace->profile.remembered_shady_object_count_types);
+ }
+#endif
+
+ return hash;
+}
+
+enum gc_stat_heap_sym {
+ gc_stat_heap_sym_slot_size,
+ gc_stat_heap_sym_heap_live_slots,
+ gc_stat_heap_sym_heap_free_slots,
+ gc_stat_heap_sym_heap_final_slots,
+ gc_stat_heap_sym_heap_eden_pages,
+ gc_stat_heap_sym_heap_eden_slots,
+ gc_stat_heap_sym_total_allocated_pages,
+ gc_stat_heap_sym_force_major_gc_count,
+ gc_stat_heap_sym_force_incremental_marking_finish_count,
+ gc_stat_heap_sym_heap_allocatable_slots,
+ gc_stat_heap_sym_total_allocated_objects,
+ gc_stat_heap_sym_total_freed_objects,
+ gc_stat_heap_sym_last
+};
+
+static VALUE gc_stat_heap_symbols[gc_stat_heap_sym_last];
+
+static void
+setup_gc_stat_heap_symbols(void)
+{
+ if (gc_stat_heap_symbols[0] == 0) {
+#define S(s) gc_stat_heap_symbols[gc_stat_heap_sym_##s] = ID2SYM(rb_intern_const(#s))
+ S(slot_size);
+ S(heap_live_slots);
+ S(heap_free_slots);
+ S(heap_final_slots);
+ S(heap_eden_pages);
+ S(heap_eden_slots);
+ S(heap_allocatable_slots);
+ S(total_allocated_pages);
+ S(force_major_gc_count);
+ S(force_incremental_marking_finish_count);
+ S(total_allocated_objects);
+ S(total_freed_objects);
+#undef S
+ }
+}
+
+static VALUE
+stat_one_heap(rb_objspace_t *objspace, rb_heap_t *heap, VALUE hash, VALUE key)
+{
+#define SET(name, attr) \
+ if (key == gc_stat_heap_symbols[gc_stat_heap_sym_##name]) \
+ return SIZET2NUM(attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, gc_stat_heap_symbols[gc_stat_heap_sym_##name], SIZET2NUM(attr));
+
+ SET(slot_size, heap->slot_size);
+ SET(heap_live_slots, heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count);
+ SET(heap_free_slots, heap->total_slots - (heap->total_allocated_objects - heap->total_freed_objects));
+ SET(heap_final_slots, heap->final_slots_count);
+ SET(heap_eden_pages, heap->total_pages);
+ SET(heap_eden_slots, heap->total_slots);
+ SET(heap_allocatable_slots, objspace->heap_pages.allocatable_bytes / heap->slot_size);
+ SET(total_allocated_pages, heap->total_allocated_pages);
+ SET(force_major_gc_count, heap->force_major_gc_count);
+ SET(force_incremental_marking_finish_count, heap->force_incremental_marking_finish_count);
+ SET(total_allocated_objects, heap->total_allocated_objects);
+ SET(total_freed_objects, heap->total_freed_objects);
+#undef SET
+
+ if (!NIL_P(key)) {
+ // Matched key should return above
+ return Qundef;
+ }
+
+ return hash;
+}
+
+VALUE
+rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ ractor_cache_flush_count(objspace, rb_gc_get_ractor_newobj_cache());
+
+ setup_gc_stat_heap_symbols();
+
+ if (NIL_P(heap_name)) {
+ if (!RB_TYPE_P(hash_or_sym, T_HASH)) {
+ rb_bug("non-hash given");
+ }
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ VALUE hash = rb_hash_aref(hash_or_sym, INT2FIX(i));
+ if (NIL_P(hash)) {
+ hash = rb_hash_new();
+ rb_hash_aset(hash_or_sym, INT2FIX(i), hash);
+ }
+
+ stat_one_heap(objspace, &heaps[i], hash, Qnil);
+ }
+ }
+ else if (FIXNUM_P(heap_name)) {
+ int heap_idx = FIX2INT(heap_name);
+
+ if (heap_idx < 0 || heap_idx >= HEAP_COUNT) {
+ rb_raise(rb_eArgError, "size pool index out of range");
+ }
+
+ if (SYMBOL_P(hash_or_sym)) {
+ return stat_one_heap(objspace, &heaps[heap_idx], Qnil, hash_or_sym);
+ }
+ else if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ return stat_one_heap(objspace, &heaps[heap_idx], hash_or_sym, Qnil);
+ }
+ else {
+ rb_bug("non-hash or symbol given");
+ }
+ }
+ else {
+ rb_bug("heap_name must be nil or an Integer");
+ }
+
+ return hash_or_sym;
+}
+
+/* I could include internal.h for this, but doing so undefines some Array macros
+ * necessary for initialising objects, and I don't want to include all the array
+ * headers to get them back
+ * TODO: Investigate why RARRAY_AREF gets undefined in internal.h
+ */
+#ifndef RBOOL
+#define RBOOL(v) (v ? Qtrue : Qfalse)
+#endif
+
+VALUE
+rb_gc_impl_config_get(void *objspace_ptr)
+{
+#define sym(name) ID2SYM(rb_intern_const(name))
+ rb_objspace_t *objspace = objspace_ptr;
+ VALUE hash = rb_hash_new();
+
+ rb_hash_aset(hash, sym("rgengc_allow_full_mark"), RBOOL(gc_config_full_mark_val));
+
+ return hash;
+}
+
+static int
+gc_config_set_key(VALUE key, VALUE value, VALUE data)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)data;
+ if (rb_sym2id(key) == rb_intern("rgengc_allow_full_mark")) {
+ gc_rest(objspace);
+ gc_config_full_mark_set(RTEST(value));
+ }
+ return ST_CONTINUE;
+}
+
+void
+rb_gc_impl_config_set(void *objspace_ptr, VALUE hash)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (!RB_TYPE_P(hash, T_HASH)) {
+ rb_raise(rb_eArgError, "expected keyword arguments");
+ }
+
+ rb_hash_foreach(hash, gc_config_set_key, (st_data_t)objspace);
+}
+
+VALUE
+rb_gc_impl_stress_get(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ return ruby_gc_stress_mode;
+}
+
+void
+rb_gc_impl_stress_set(void *objspace_ptr, VALUE flag)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ objspace->flags.gc_stressful = RTEST(flag);
+ objspace->gc_stress_mode = flag;
+}
+
+static int
+get_envparam_size(const char *name, size_t *default_value, size_t lower_bound)
+{
+ const char *ptr = getenv(name);
+ ssize_t val;
+
+ if (ptr != NULL && *ptr) {
+ size_t unit = 0;
+ char *end;
+#if SIZEOF_SIZE_T == SIZEOF_LONG_LONG
+ val = strtoll(ptr, &end, 0);
+#else
+ val = strtol(ptr, &end, 0);
+#endif
+ switch (*end) {
+ case 'k': case 'K':
+ unit = 1024;
+ ++end;
+ break;
+ case 'm': case 'M':
+ unit = 1024*1024;
+ ++end;
+ break;
+ case 'g': case 'G':
+ unit = 1024*1024*1024;
+ ++end;
+ break;
+ }
+ while (*end && isspace((unsigned char)*end)) end++;
+ if (*end) {
+ if (RTEST(ruby_verbose)) fprintf(stderr, "invalid string for %s: %s\n", name, ptr);
+ return 0;
+ }
+ if (unit > 0) {
+ if (val < -(ssize_t)(SIZE_MAX / 2 / unit) || (ssize_t)(SIZE_MAX / 2 / unit) < val) {
+ if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%s is ignored because it overflows\n", name, ptr);
+ return 0;
+ }
+ val *= unit;
+ }
+ if (val > 0 && (size_t)val > lower_bound) {
+ if (RTEST(ruby_verbose)) {
+ fprintf(stderr, "%s=%"PRIdSIZE" (default value: %"PRIuSIZE")\n", name, val, *default_value);
+ }
+ *default_value = (size_t)val;
+ return 1;
+ }
+ else {
+ if (RTEST(ruby_verbose)) {
+ fprintf(stderr, "%s=%"PRIdSIZE" (default value: %"PRIuSIZE") is ignored because it must be greater than %"PRIuSIZE".\n",
+ name, val, *default_value, lower_bound);
+ }
+ return 0;
+ }
+ }
+ return 0;
+}
+
+static int
+get_envparam_double(const char *name, double *default_value, double lower_bound, double upper_bound, int accept_zero)
+{
+ const char *ptr = getenv(name);
+ double val;
+
+ if (ptr != NULL && *ptr) {
+ char *end;
+ val = strtod(ptr, &end);
+ if (!*ptr || *end) {
+ if (RTEST(ruby_verbose)) fprintf(stderr, "invalid string for %s: %s\n", name, ptr);
+ return 0;
+ }
+
+ if (accept_zero && val == 0.0) {
+ goto accept;
+ }
+ else if (val <= lower_bound) {
+ if (RTEST(ruby_verbose)) {
+ fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n",
+ name, val, *default_value, lower_bound);
+ }
+ }
+ else if (upper_bound != 0.0 && /* ignore upper_bound if it is 0.0 */
+ val > upper_bound) {
+ if (RTEST(ruby_verbose)) {
+ fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be lower than %f.\n",
+ name, val, *default_value, upper_bound);
+ }
+ }
+ else {
+ goto accept;
+ }
+ }
+ return 0;
+
+ accept:
+ if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f)\n", name, val, *default_value);
+ *default_value = val;
+ return 1;
+}
+
+/*
+ * GC tuning environment variables
+ *
+ * * RUBY_GC_HEAP_FREE_SLOTS
+ * - Prepare at least this amount of slots after GC.
+ * - Allocate slots if there are not enough slots.
+ * * RUBY_GC_HEAP_GROWTH_FACTOR (new from 2.1)
+ * - Allocate slots by this factor.
+ * - (next slots number) = (current slots number) * (this factor)
+ * * RUBY_GC_HEAP_GROWTH_MAX_BYTES (was RUBY_GC_HEAP_GROWTH_MAX_SLOTS)
+ * - Allocation rate is limited to this number of bytes.
+ * * RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO (new from 2.4)
+ * - Allocate additional pages when the number of free slots is
+ * lower than the value (total_slots * (this ratio)).
+ * * RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO (new from 2.4)
+ * - Allocate slots to satisfy this formula:
+ * free_slots = total_slots * goal_ratio
+ * - In other words, prepare (total_slots * goal_ratio) free slots.
+ * - if this value is 0.0, then use RUBY_GC_HEAP_GROWTH_FACTOR directly.
+ * * RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO (new from 2.4)
+ * - Allow to free pages when the number of free slots is
+ * greater than the value (total_slots * (this ratio)).
+ * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1)
+ * - Do full GC when the number of old objects is more than R * N
+ * where R is this factor and
+ * N is the number of old objects just after last full GC.
+ *
+ * * obsolete
+ * * RUBY_FREE_MIN -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1)
+ * * RUBY_HEAP_MIN_SLOTS -> RUBY_GC_HEAP_INIT_SLOTS (from 2.1) -> RUBY_GC_HEAP_INIT_BYTES
+ *
+ * * RUBY_GC_MALLOC_LIMIT
+ * * RUBY_GC_MALLOC_LIMIT_MAX (new from 2.1)
+ * * RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR (new from 2.1)
+ *
+ * * RUBY_GC_OLDMALLOC_LIMIT (new from 2.1)
+ * * RUBY_GC_OLDMALLOC_LIMIT_MAX (new from 2.1)
+ * * RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR (new from 2.1)
+ */
+
+void
+rb_gc_impl_set_params(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ /* RUBY_GC_HEAP_FREE_SLOTS */
+ if (get_envparam_size("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) {
+ /* ok */
+ }
+
+ get_envparam_size("RUBY_GC_HEAP_INIT_BYTES", &gc_params.heap_init_bytes, 0);
+
+ get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0, 0.0, FALSE);
+ get_envparam_size ("RUBY_GC_HEAP_GROWTH_MAX_BYTES", &gc_params.growth_max_bytes, 0);
+ get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO", &gc_params.heap_free_slots_min_ratio,
+ 0.0, 1.0, FALSE);
+ get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO", &gc_params.heap_free_slots_max_ratio,
+ gc_params.heap_free_slots_min_ratio, 1.0, FALSE);
+ get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", &gc_params.heap_free_slots_goal_ratio,
+ gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
+ get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
+ get_envparam_double("RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO", &gc_params.uncollectible_wb_unprotected_objects_limit_ratio, 0.0, 0.0, TRUE);
+
+ if (get_envparam_size("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0)) {
+ malloc_limit = gc_params.malloc_limit_min;
+ }
+ get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
+ if (!gc_params.malloc_limit_max) { /* ignore max-check if 0 */
+ gc_params.malloc_limit_max = SIZE_MAX;
+ }
+ get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0, 0.0, FALSE);
+
+#if RGENGC_ESTIMATE_OLDMALLOC
+ if (get_envparam_size("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
+ objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
+ }
+ get_envparam_size ("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
+ get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0, 0.0, FALSE);
+#endif
+}
+
+static inline size_t
+objspace_malloc_size(rb_objspace_t *objspace, void *ptr, size_t hint)
+{
+#ifdef HAVE_MALLOC_USABLE_SIZE
+ if (!hint) {
+ hint = malloc_usable_size(ptr);
+ }
+#endif
+ return hint;
+}
+
+enum memop_type {
+ MEMOP_TYPE_MALLOC = 0,
+ MEMOP_TYPE_FREE,
+ MEMOP_TYPE_REALLOC
+};
+
+static inline void
+atomic_sub_nounderflow(size_t *var, size_t sub)
+{
+ if (sub == 0) return;
+
+ while (1) {
+ size_t val = *var;
+ if (val < sub) sub = val;
+ if (RUBY_ATOMIC_SIZE_CAS(*var, val, val-sub) == val) break;
+ }
+}
+
+#define gc_stress_full_mark_after_malloc_p() \
+ (FIXNUM_P(ruby_gc_stress_mode) && (FIX2LONG(ruby_gc_stress_mode) & (1<<gc_stress_full_mark_after_malloc)))
+
+static void
+objspace_malloc_gc_stress(rb_objspace_t *objspace)
+{
+ if (ruby_gc_stressful && ruby_native_thread_p()) {
+ unsigned int reason = (GPR_FLAG_IMMEDIATE_MARK | GPR_FLAG_IMMEDIATE_SWEEP |
+ GPR_FLAG_STRESS | GPR_FLAG_MALLOC);
+
+ if (gc_stress_full_mark_after_malloc_p()) {
+ reason |= GPR_FLAG_FULL_MARK;
+ }
+ garbage_collect_with_gvl(objspace, reason);
+ }
+}
+
+static void
+malloc_increase_commit(rb_objspace_t *objspace, size_t new_size, size_t old_size)
+{
+ if (new_size > old_size) {
+ size_t delta = new_size - old_size;
+ MALLOC_COUNTERS_LOCK(objspace);
+ gc_counter_add(&objspace->malloc_counters.counters.malloc, delta);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ gc_counter_add(&objspace->malloc_counters.oldcounters.malloc, delta);
+#endif
+ MALLOC_COUNTERS_UNLOCK(objspace);
+ }
+ else if (old_size > new_size) {
+ size_t delta = old_size - new_size;
+ MALLOC_COUNTERS_LOCK(objspace);
+ gc_counter_add(&objspace->malloc_counters.counters.free, delta);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ gc_counter_add(&objspace->malloc_counters.oldcounters.free, delta);
+#endif
+ MALLOC_COUNTERS_UNLOCK(objspace);
+ }
+}
+
+#if USE_MALLOC_INCREASE_LOCAL
+static void
+malloc_increase_local_flush(rb_objspace_t *objspace)
+{
+ int delta = malloc_increase_local;
+ if (delta == 0) return;
+
+ malloc_increase_local = 0;
+ if (delta > 0) {
+ malloc_increase_commit(objspace, (size_t)delta, 0);
+ }
+ else {
+ malloc_increase_commit(objspace, 0, (size_t)(-delta));
+ }
+}
+#else
+static void
+malloc_increase_local_flush(rb_objspace_t *objspace)
+{
+}
+#endif
+
+static inline bool
+objspace_malloc_increase_report(rb_objspace_t *objspace, void *mem, size_t new_size, size_t old_size, enum memop_type type, bool gc_allowed)
+{
+ if (0) fprintf(stderr, "increase - ptr: %p, type: %s, new_size: %"PRIdSIZE", old_size: %"PRIdSIZE"\n",
+ mem,
+ type == MEMOP_TYPE_MALLOC ? "malloc" :
+ type == MEMOP_TYPE_FREE ? "free " :
+ type == MEMOP_TYPE_REALLOC ? "realloc": "error",
+ new_size, old_size);
+ return false;
+}
+
+static bool
+objspace_malloc_increase_body(rb_objspace_t *objspace, void *mem, size_t new_size, size_t old_size, enum memop_type type, bool gc_allowed)
+{
+#if USE_MALLOC_INCREASE_LOCAL
+ if (new_size < GC_MALLOC_INCREASE_LOCAL_THRESHOLD &&
+ old_size < GC_MALLOC_INCREASE_LOCAL_THRESHOLD) {
+ malloc_increase_local += (int)new_size - (int)old_size;
+
+ if (malloc_increase_local >= GC_MALLOC_INCREASE_LOCAL_THRESHOLD ||
+ malloc_increase_local <= -GC_MALLOC_INCREASE_LOCAL_THRESHOLD) {
+ malloc_increase_local_flush(objspace);
+ }
+ }
+ else {
+ malloc_increase_local_flush(objspace);
+ malloc_increase_commit(objspace, new_size, old_size);
+ }
+#else
+ malloc_increase_commit(objspace, new_size, old_size);
+#endif
+
+ if (type == MEMOP_TYPE_MALLOC && gc_allowed) {
+ retry:
+ if (malloc_increase > malloc_limit && ruby_native_thread_p() && !dont_gc_val()) {
+ if (ruby_thread_has_gvl_p() && is_lazy_sweeping(objspace)) {
+ gc_rest(objspace); /* gc_rest can reduce malloc_increase */
+ goto retry;
+ }
+ garbage_collect_with_gvl(objspace, GPR_FLAG_MALLOC);
+ }
+ }
+
+#if MALLOC_ALLOCATED_SIZE
+ if (new_size >= old_size) {
+ RUBY_ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, new_size - old_size);
+ }
+ else {
+ size_t dec_size = old_size - new_size;
+
+#if MALLOC_ALLOCATED_SIZE_CHECK
+ size_t allocated_size = objspace->malloc_params.allocated_size;
+ if (allocated_size < dec_size) {
+ rb_bug("objspace_malloc_increase: underflow malloc_params.allocated_size.");
+ }
+#endif
+ atomic_sub_nounderflow(&objspace->malloc_params.allocated_size, dec_size);
+ }
+
+ switch (type) {
+ case MEMOP_TYPE_MALLOC:
+ RUBY_ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
+ break;
+ case MEMOP_TYPE_FREE:
+ {
+ size_t allocations = objspace->malloc_params.allocations;
+ if (allocations > 0) {
+ atomic_sub_nounderflow(&objspace->malloc_params.allocations, 1);
+ }
+#if MALLOC_ALLOCATED_SIZE_CHECK
+ else {
+ GC_ASSERT(objspace->malloc_params.allocations > 0);
+ }
+#endif
+ }
+ break;
+ case MEMOP_TYPE_REALLOC: /* ignore */ break;
+ }
+#endif
+ return true;
+}
+
+#define objspace_malloc_increase(...) \
+ for (bool malloc_increase_done = objspace_malloc_increase_report(__VA_ARGS__); \
+ !malloc_increase_done; \
+ malloc_increase_done = objspace_malloc_increase_body(__VA_ARGS__))
+
+struct malloc_obj_info { /* 4 words */
+ size_t size;
+};
+
+static inline size_t
+objspace_malloc_prepare(rb_objspace_t *objspace, size_t size)
+{
+ if (size == 0) size = 1;
+
+#if CALC_EXACT_MALLOC_SIZE
+ size += sizeof(struct malloc_obj_info);
+#endif
+
+ return size;
+}
+
+static bool
+malloc_during_gc_p(rb_objspace_t *objspace)
+{
+ /* malloc is not allowed during GC when we're not using multiple ractors
+ * (since ractors can run while another thread is sweeping) and when we
+ * have the GVL (since if we don't have the GVL, we'll try to acquire the
+ * GVL which will block and ensure the other thread finishes GC). */
+ return during_gc && !dont_gc_val() && !rb_gc_multi_ractor_p() && ruby_thread_has_gvl_p();
+}
+
+static inline void *
+objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size, bool gc_allowed)
+{
+ size = objspace_malloc_size(objspace, mem, size);
+ objspace_malloc_increase(objspace, mem, size, 0, MEMOP_TYPE_MALLOC, gc_allowed) {}
+
+#if CALC_EXACT_MALLOC_SIZE
+ {
+ struct malloc_obj_info *info = mem;
+ info->size = size;
+ mem = info + 1;
+ }
+#endif
+
+ return mem;
+}
+
+#if defined(__GNUC__) && RUBY_DEBUG
+#define RB_BUG_INSTEAD_OF_RB_MEMERROR 1
+#endif
+
+#ifndef RB_BUG_INSTEAD_OF_RB_MEMERROR
+# define RB_BUG_INSTEAD_OF_RB_MEMERROR 0
+#endif
+
+#define GC_MEMERROR(...) \
+ ((RB_BUG_INSTEAD_OF_RB_MEMERROR+0) ? rb_bug("" __VA_ARGS__) : (void)0)
+
+#define TRY_WITH_GC(siz, expr) do { \
+ const gc_profile_record_flag gpr = \
+ GPR_FLAG_FULL_MARK | \
+ GPR_FLAG_IMMEDIATE_MARK | \
+ GPR_FLAG_IMMEDIATE_SWEEP | \
+ GPR_FLAG_MALLOC; \
+ objspace_malloc_gc_stress(objspace); \
+ \
+ if (RB_LIKELY((expr))) { \
+ /* Success on 1st try */ \
+ } \
+ else if (gc_allowed && !garbage_collect_with_gvl(objspace, gpr)) { \
+ /* @shyouhei thinks this doesn't happen */ \
+ GC_MEMERROR("TRY_WITH_GC: could not GC"); \
+ } \
+ else if ((expr)) { \
+ /* Success on 2nd try */ \
+ } \
+ else { \
+ GC_MEMERROR("TRY_WITH_GC: could not allocate:" \
+ "%"PRIdSIZE" bytes for %s", \
+ siz, # expr); \
+ } \
+ } while (0)
+
+static void
+check_malloc_not_in_gc(rb_objspace_t *objspace, const char *msg)
+{
+ if (RB_UNLIKELY(malloc_during_gc_p(objspace))) {
+ dont_gc_on();
+ during_gc = false;
+ rb_bug("Cannot %s during GC", msg);
+ }
+}
+
+void
+rb_gc_impl_free(void *objspace_ptr, void *ptr, size_t old_size)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (!ptr) {
+ /*
+ * ISO/IEC 9899 says "If ptr is a null pointer, no action occurs" since
+ * its first version. We would better follow.
+ */
+ return;
+ }
+#if CALC_EXACT_MALLOC_SIZE
+ struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
+#if VERIFY_FREE_SIZE
+ if (!info->size) {
+ rb_bug("buffer %p has no recorded size. Was it allocated with ruby_mimalloc? If so it should be freed with ruby_mimfree", ptr);
+ }
+
+ if (old_size && (old_size + sizeof(struct malloc_obj_info)) != info->size) {
+ rb_bug("buffer %p freed with old_size=%zu, but was allocated with size=%zu", ptr, old_size, info->size - sizeof(struct malloc_obj_info));
+ }
+#endif
+ ptr = info;
+ old_size = info->size;
+#endif
+ old_size = objspace_malloc_size(objspace, ptr, old_size);
+
+ objspace_malloc_increase(objspace, ptr, 0, old_size, MEMOP_TYPE_FREE, true) {
+ free(ptr);
+ ptr = NULL;
+ RB_DEBUG_COUNTER_INC(heap_xfree);
+ }
+}
+
+void *
+rb_gc_impl_malloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+ check_malloc_not_in_gc(objspace, "malloc");
+
+ void *mem;
+
+ size = objspace_malloc_prepare(objspace, size);
+ TRY_WITH_GC(size, mem = malloc(size));
+ RB_DEBUG_COUNTER_INC(heap_xmalloc);
+ if (!mem) return mem;
+ return objspace_malloc_fixup(objspace, mem, size, gc_allowed);
+}
+
+void *
+rb_gc_impl_calloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (RB_UNLIKELY(malloc_during_gc_p(objspace))) {
+ rb_warn("calloc during GC detected, this could cause crashes if it triggers another GC");
+#if RGENGC_CHECK_MODE || RUBY_DEBUG
+ rb_bug("Cannot calloc during GC");
+#endif
+ }
+
+ void *mem;
+
+ size = objspace_malloc_prepare(objspace, size);
+ TRY_WITH_GC(size, mem = calloc1(size));
+ if (!mem) return mem;
+ return objspace_malloc_fixup(objspace, mem, size, gc_allowed);
+}
+
+void *
+rb_gc_impl_realloc(void *objspace_ptr, void *ptr, size_t new_size, size_t old_size, bool gc_allowed)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ check_malloc_not_in_gc(objspace, "realloc");
+
+ void *mem;
+
+ if (!ptr) return rb_gc_impl_malloc(objspace, new_size, gc_allowed);
+
+ /*
+ * The behavior of realloc(ptr, 0) is implementation defined.
+ * Therefore we don't use realloc(ptr, 0) for portability reason.
+ * see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_400.htm
+ */
+ if (new_size == 0) {
+ if ((mem = rb_gc_impl_malloc(objspace, 0, gc_allowed)) != NULL) {
+ /*
+ * - OpenBSD's malloc(3) man page says that when 0 is passed, it
+ * returns a non-NULL pointer to an access-protected memory page.
+ * The returned pointer cannot be read / written at all, but
+ * still be a valid argument of free().
+ *
+ * https://man.openbsd.org/malloc.3
+ *
+ * - Linux's malloc(3) man page says that it _might_ perhaps return
+ * a non-NULL pointer when its argument is 0. That return value
+ * is safe (and is expected) to be passed to free().
+ *
+ * https://man7.org/linux/man-pages/man3/malloc.3.html
+ *
+ * - As I read the implementation jemalloc's malloc() returns fully
+ * normal 16 bytes memory region when its argument is 0.
+ *
+ * - As I read the implementation musl libc's malloc() returns
+ * fully normal 32 bytes memory region when its argument is 0.
+ *
+ * - Other malloc implementations can also return non-NULL.
+ */
+ rb_gc_impl_free(objspace, ptr, old_size);
+ return mem;
+ }
+ else {
+ /*
+ * It is dangerous to return NULL here, because that could lead to
+ * RCE. Fallback to 1 byte instead of zero.
+ *
+ * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11932
+ */
+ new_size = 1;
+ }
+ }
+
+#if CALC_EXACT_MALLOC_SIZE
+ {
+ struct malloc_obj_info *info = (struct malloc_obj_info *)ptr - 1;
+ new_size += sizeof(struct malloc_obj_info);
+ ptr = info;
+#if VERIFY_FREE_SIZE
+ if (old_size && (old_size + sizeof(struct malloc_obj_info)) != info->size) {
+ rb_bug("buffer %p realloced with old_size=%zu, but was allocated with size=%zu", ptr, old_size, info->size - sizeof(struct malloc_obj_info));
+ }
+#endif
+ old_size = info->size;
+ }
+#endif
+
+ old_size = objspace_malloc_size(objspace, ptr, old_size);
+ TRY_WITH_GC(new_size, mem = RB_GNUC_EXTENSION_BLOCK(realloc(ptr, new_size)));
+ if (!mem) return mem;
+ new_size = objspace_malloc_size(objspace, mem, new_size);
+
+#if CALC_EXACT_MALLOC_SIZE
+ {
+ struct malloc_obj_info *info = mem;
+ info->size = new_size;
+ mem = info + 1;
+ }
+#endif
+
+ objspace_malloc_increase(objspace, mem, new_size, old_size, MEMOP_TYPE_REALLOC, gc_allowed);
+
+ RB_DEBUG_COUNTER_INC(heap_xrealloc);
+ return mem;
+}
+
+void
+rb_gc_impl_adjust_memory_usage(void *objspace_ptr, ssize_t diff)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (diff > 0) {
+ objspace_malloc_increase(objspace, 0, diff, 0, MEMOP_TYPE_REALLOC, true);
+ }
+ else if (diff < 0) {
+ objspace_malloc_increase(objspace, 0, 0, -diff, MEMOP_TYPE_REALLOC, true);
+ }
+}
+
+// TODO: move GC profiler stuff back into gc.c
+/*
+ ------------------------------ GC profiler ------------------------------
+*/
+
+#define GC_PROFILE_RECORD_DEFAULT_SIZE 100
+
+static bool
+current_process_time(struct timespec *ts)
+{
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
+ {
+ static int try_clock_gettime = 1;
+ if (try_clock_gettime && clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ts) == 0) {
+ return true;
+ }
+ else {
+ try_clock_gettime = 0;
+ }
+ }
+#endif
+
+#ifdef RUSAGE_SELF
+ {
+ struct rusage usage;
+ struct timeval time;
+ if (getrusage(RUSAGE_SELF, &usage) == 0) {
+ time = usage.ru_utime;
+ ts->tv_sec = time.tv_sec;
+ ts->tv_nsec = (int32_t)time.tv_usec * 1000;
+ return true;
+ }
+ }
+#endif
+
+#ifdef _WIN32
+ {
+ FILETIME creation_time, exit_time, kernel_time, user_time;
+ ULARGE_INTEGER ui;
+
+ if (GetProcessTimes(GetCurrentProcess(),
+ &creation_time, &exit_time, &kernel_time, &user_time) != 0) {
+ memcpy(&ui, &user_time, sizeof(FILETIME));
+#define PER100NSEC (uint64_t)(1000 * 1000 * 10)
+ ts->tv_nsec = (long)(ui.QuadPart % PER100NSEC);
+ ts->tv_sec = (time_t)(ui.QuadPart / PER100NSEC);
+ return true;
+ }
+ }
+#endif
+
+ return false;
+}
+
+static double
+getrusage_time(void)
+{
+ struct timespec ts;
+ if (current_process_time(&ts)) {
+ return ts.tv_sec + ts.tv_nsec * 1e-9;
+ }
+ else {
+ return 0.0;
+ }
+}
+
+
+static inline void
+gc_prof_setup_new_record(rb_objspace_t *objspace, unsigned int reason)
+{
+ if (objspace->profile.run) {
+ size_t index = objspace->profile.next_index;
+ gc_profile_record *record;
+
+ /* create new record */
+ objspace->profile.next_index++;
+
+ if (!objspace->profile.records) {
+ objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE;
+ objspace->profile.records = malloc(xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
+ }
+ if (index >= objspace->profile.size) {
+ void *ptr;
+ objspace->profile.size += 1000;
+ ptr = realloc(objspace->profile.records, xmalloc2_size(sizeof(gc_profile_record), objspace->profile.size));
+ if (!ptr) rb_memerror();
+ objspace->profile.records = ptr;
+ }
+ if (!objspace->profile.records) {
+ rb_bug("gc_profile malloc or realloc miss");
+ }
+ record = objspace->profile.current_record = &objspace->profile.records[objspace->profile.next_index - 1];
+ MEMZERO(record, gc_profile_record, 1);
+
+ /* setup before-GC parameter */
+ record->flags = reason | (ruby_gc_stressful ? GPR_FLAG_STRESS : 0);
+#if MALLOC_ALLOCATED_SIZE
+ record->allocated_size = malloc_allocated_size;
+#endif
+#if GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY
+#ifdef RUSAGE_SELF
+ {
+ struct rusage usage;
+ if (getrusage(RUSAGE_SELF, &usage) == 0) {
+ record->maxrss = usage.ru_maxrss;
+ record->minflt = usage.ru_minflt;
+ record->majflt = usage.ru_majflt;
+ }
+ }
+#endif
+#endif
+ }
+}
+
+static inline void
+gc_prof_timer_start(rb_objspace_t *objspace)
+{
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+#if GC_PROFILE_MORE_DETAIL
+ record->prepare_time = objspace->profile.prepare_time;
+#endif
+ record->gc_time = 0;
+ record->gc_invoke_time = getrusage_time();
+ }
+}
+
+static double
+elapsed_time_from(double time)
+{
+ double now = getrusage_time();
+ if (now > time) {
+ return now - time;
+ }
+ else {
+ return 0;
+ }
+}
+
+static inline void
+gc_prof_timer_stop(rb_objspace_t *objspace)
+{
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->gc_time = elapsed_time_from(record->gc_invoke_time);
+ record->gc_invoke_time -= objspace->profile.invoke_time;
+ }
+}
+
+#ifdef BUILDING_MODULAR_GC
+# define RUBY_DTRACE_GC_HOOK(name)
+#else
+# define RUBY_DTRACE_GC_HOOK(name) \
+ do {if (RUBY_DTRACE_GC_##name##_ENABLED()) RUBY_DTRACE_GC_##name();} while (0)
+#endif
+
+static inline void
+gc_prof_mark_timer_start(rb_objspace_t *objspace)
+{
+ RUBY_DTRACE_GC_HOOK(MARK_BEGIN);
+#if GC_PROFILE_MORE_DETAIL
+ if (gc_prof_enabled(objspace)) {
+ gc_prof_record(objspace)->gc_mark_time = getrusage_time();
+ }
+#endif
+}
+
+static inline void
+gc_prof_mark_timer_stop(rb_objspace_t *objspace)
+{
+ RUBY_DTRACE_GC_HOOK(MARK_END);
+#if GC_PROFILE_MORE_DETAIL
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->gc_mark_time = elapsed_time_from(record->gc_mark_time);
+ }
+#endif
+}
+
+static inline void
+gc_prof_sweep_timer_start(rb_objspace_t *objspace)
+{
+ RUBY_DTRACE_GC_HOOK(SWEEP_BEGIN);
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+
+ if (record->gc_time > 0 || GC_PROFILE_MORE_DETAIL) {
+ objspace->profile.gc_sweep_start_time = getrusage_time();
+ }
+ }
+}
+
+static inline void
+gc_prof_sweep_timer_stop(rb_objspace_t *objspace)
+{
+ RUBY_DTRACE_GC_HOOK(SWEEP_END);
+
+ if (gc_prof_enabled(objspace)) {
+ double sweep_time;
+ gc_profile_record *record = gc_prof_record(objspace);
+
+ if (record->gc_time > 0) {
+ sweep_time = elapsed_time_from(objspace->profile.gc_sweep_start_time);
+ /* need to accumulate GC time for lazy sweep after gc() */
+ record->gc_time += sweep_time;
+ }
+ else if (GC_PROFILE_MORE_DETAIL) {
+ sweep_time = elapsed_time_from(objspace->profile.gc_sweep_start_time);
+ }
+
+#if GC_PROFILE_MORE_DETAIL
+ record->gc_sweep_time += sweep_time;
+ if (heap_pages_deferred_final) record->flags |= GPR_FLAG_HAVE_FINALIZE;
+#endif
+ if (heap_pages_deferred_final) objspace->profile.latest_gc_info |= GPR_FLAG_HAVE_FINALIZE;
+ }
+}
+
+static inline void
+gc_prof_set_malloc_info(rb_objspace_t *objspace)
+{
+#if GC_PROFILE_MORE_DETAIL
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+ record->allocate_increase = malloc_increase;
+ record->allocate_limit = malloc_limit;
+ }
+#endif
+}
+
+static inline void
+gc_prof_set_heap_info(rb_objspace_t *objspace)
+{
+ if (gc_prof_enabled(objspace)) {
+ gc_profile_record *record = gc_prof_record(objspace);
+
+ /* Sum across all size pools since each has a different slot size. */
+ size_t total = 0;
+ size_t use_size = 0;
+ size_t total_size = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ size_t heap_live = heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count;
+ total += heap->total_slots;
+ use_size += heap_live * heap->slot_size;
+ total_size += heap->total_slots * heap->slot_size;
+ }
+
+#if GC_PROFILE_MORE_DETAIL
+ size_t live = objspace->profile.total_allocated_objects_at_gc_start - total_freed_objects(objspace);
+ record->heap_use_pages = objspace->profile.heap_used_at_gc_start;
+ record->heap_live_objects = live;
+ record->heap_free_objects = total - live;
+#endif
+
+ record->heap_total_objects = total;
+ record->heap_use_size = use_size;
+ record->heap_total_size = total_size;
+ }
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.clear -> nil
+ *
+ * Clears the \GC profiler data.
+ *
+ */
+
+static VALUE
+gc_profile_clear(VALUE _)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ void *p = objspace->profile.records;
+ objspace->profile.records = NULL;
+ objspace->profile.size = 0;
+ objspace->profile.next_index = 0;
+ objspace->profile.current_record = 0;
+ free(p);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.raw_data -> [Hash, ...]
+ *
+ * Returns an Array of individual raw profile data Hashes ordered
+ * from earliest to latest by +:GC_INVOKE_TIME+.
+ *
+ * For example:
+ *
+ * [
+ * {
+ * :GC_TIME=>1.3000000000000858e-05,
+ * :GC_INVOKE_TIME=>0.010634999999999999,
+ * :HEAP_USE_SIZE=>289640,
+ * :HEAP_TOTAL_SIZE=>588960,
+ * :HEAP_TOTAL_OBJECTS=>14724,
+ * :GC_IS_MARKED=>false
+ * },
+ * # ...
+ * ]
+ *
+ * The keys mean:
+ *
+ * +:GC_TIME+::
+ * Time elapsed in seconds for this GC run
+ * +:GC_INVOKE_TIME+::
+ * Time elapsed in seconds from startup to when the GC was invoked
+ * +:HEAP_USE_SIZE+::
+ * Total bytes of heap used
+ * +:HEAP_TOTAL_SIZE+::
+ * Total size of heap in bytes
+ * +:HEAP_TOTAL_OBJECTS+::
+ * Total number of objects
+ * +:GC_IS_MARKED+::
+ * Returns +true+ if the GC is in mark phase
+ *
+ * If ruby was built with +GC_PROFILE_MORE_DETAIL+, you will also have access
+ * to the following hash keys:
+ *
+ * +:GC_MARK_TIME+::
+ * +:GC_SWEEP_TIME+::
+ * +:ALLOCATE_INCREASE+::
+ * +:ALLOCATE_LIMIT+::
+ * +:HEAP_USE_PAGES+::
+ * +:HEAP_LIVE_OBJECTS+::
+ * +:HEAP_FREE_OBJECTS+::
+ * +:HAVE_FINALIZE+::
+ *
+ */
+
+static VALUE
+gc_profile_record_get(VALUE _)
+{
+ VALUE prof;
+ VALUE gc_profile = rb_ary_new();
+ size_t i;
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ if (!objspace->profile.run) {
+ return Qnil;
+ }
+
+ for (i =0; i < objspace->profile.next_index; i++) {
+ gc_profile_record *record = &objspace->profile.records[i];
+
+ prof = rb_hash_new();
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(objspace, rb_hash_new(), record->flags));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_TIME")), DBL2NUM(record->gc_time));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_INVOKE_TIME")), DBL2NUM(record->gc_invoke_time));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_SIZE")), SIZET2NUM(record->heap_use_size));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_SIZE")), SIZET2NUM(record->heap_total_size));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_TOTAL_OBJECTS")), SIZET2NUM(record->heap_total_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("MOVED_OBJECTS")), SIZET2NUM(record->moved_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_IS_MARKED")), Qtrue);
+#if GC_PROFILE_MORE_DETAIL
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_MARK_TIME")), DBL2NUM(record->gc_mark_time));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_SWEEP_TIME")), DBL2NUM(record->gc_sweep_time));
+ rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_INCREASE")), SIZET2NUM(record->allocate_increase));
+ rb_hash_aset(prof, ID2SYM(rb_intern("ALLOCATE_LIMIT")), SIZET2NUM(record->allocate_limit));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_PAGES")), SIZET2NUM(record->heap_use_pages));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_LIVE_OBJECTS")), SIZET2NUM(record->heap_live_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_FREE_OBJECTS")), SIZET2NUM(record->heap_free_objects));
+
+ rb_hash_aset(prof, ID2SYM(rb_intern("REMOVING_OBJECTS")), SIZET2NUM(record->removing_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("EMPTY_OBJECTS")), SIZET2NUM(record->empty_objects));
+
+ rb_hash_aset(prof, ID2SYM(rb_intern("HAVE_FINALIZE")), (record->flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse);
+#endif
+
+#if RGENGC_PROFILE > 0
+ rb_hash_aset(prof, ID2SYM(rb_intern("OLD_OBJECTS")), SIZET2NUM(record->old_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_NORMAL_OBJECTS")), SIZET2NUM(record->remembered_normal_objects));
+ rb_hash_aset(prof, ID2SYM(rb_intern("REMEMBERED_SHADY_OBJECTS")), SIZET2NUM(record->remembered_shady_objects));
+#endif
+ rb_ary_push(gc_profile, prof);
+ }
+
+ return gc_profile;
+}
+
+#if GC_PROFILE_MORE_DETAIL
+#define MAJOR_REASON_MAX 0x10
+
+static char *
+gc_profile_dump_major_reason(unsigned int flags, char *buff)
+{
+ unsigned int reason = flags & GPR_FLAG_MAJOR_MASK;
+ int i = 0;
+
+ if (reason == GPR_FLAG_NONE) {
+ buff[0] = '-';
+ buff[1] = 0;
+ }
+ else {
+#define C(x, s) \
+ if (reason & GPR_FLAG_MAJOR_BY_##x) { \
+ buff[i++] = #x[0]; \
+ if (i >= MAJOR_REASON_MAX) rb_bug("gc_profile_dump_major_reason: overflow"); \
+ buff[i] = 0; \
+ }
+ C(NOFREE, N);
+ C(OLDGEN, O);
+ C(SHADY, S);
+#if RGENGC_ESTIMATE_OLDMALLOC
+ C(OLDMALLOC, M);
+#endif
+#undef C
+ }
+ return buff;
+}
+#endif
+
+
+
+static void
+gc_profile_dump_on(VALUE out, VALUE (*append)(VALUE, VALUE))
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ size_t count = objspace->profile.next_index;
+#ifdef MAJOR_REASON_MAX
+ char reason_str[MAJOR_REASON_MAX];
+#endif
+
+ if (objspace->profile.run && count /* > 1 */) {
+ size_t i;
+ const gc_profile_record *record;
+
+ append(out, rb_sprintf("GC %"PRIuSIZE" invokes.\n", objspace->profile.count));
+ append(out, rb_str_new_cstr("Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)\n"));
+
+ for (i = 0; i < count; i++) {
+ record = &objspace->profile.records[i];
+ append(out, rb_sprintf("%5"PRIuSIZE" %19.3f %20"PRIuSIZE" %20"PRIuSIZE" %20"PRIuSIZE" %30.20f\n",
+ i+1, record->gc_invoke_time, record->heap_use_size,
+ record->heap_total_size, record->heap_total_objects, record->gc_time*1000));
+ }
+
+#if GC_PROFILE_MORE_DETAIL
+ const char *str = "\n\n" \
+ "More detail.\n" \
+ "Prepare Time = Previously GC's rest sweep time\n"
+ "Index Flags Allocate Inc. Allocate Limit"
+#if CALC_EXACT_MALLOC_SIZE
+ " Allocated Size"
+#endif
+ " Use Page Mark Time(ms) Sweep Time(ms) Prepare Time(ms) LivingObj FreeObj RemovedObj EmptyObj"
+#if RGENGC_PROFILE
+ " OldgenObj RemNormObj RemShadObj"
+#endif
+#if GC_PROFILE_DETAIL_MEMORY
+ " MaxRSS(KB) MinorFLT MajorFLT"
+#endif
+ "\n";
+ append(out, rb_str_new_cstr(str));
+
+ for (i = 0; i < count; i++) {
+ record = &objspace->profile.records[i];
+ append(out, rb_sprintf("%5"PRIuSIZE" %4s/%c/%6s%c %13"PRIuSIZE" %15"PRIuSIZE
+#if CALC_EXACT_MALLOC_SIZE
+ " %15"PRIuSIZE
+#endif
+ " %9"PRIuSIZE" %17.12f %17.12f %17.12f %10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE
+#if RGENGC_PROFILE
+ "%10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE
+#endif
+#if GC_PROFILE_DETAIL_MEMORY
+ "%11ld %8ld %8ld"
+#endif
+
+ "\n",
+ i+1,
+ gc_profile_dump_major_reason(record->flags, reason_str),
+ (record->flags & GPR_FLAG_HAVE_FINALIZE) ? 'F' : '.',
+ (record->flags & GPR_FLAG_NEWOBJ) ? "NEWOBJ" :
+ (record->flags & GPR_FLAG_MALLOC) ? "MALLOC" :
+ (record->flags & GPR_FLAG_METHOD) ? "METHOD" :
+ (record->flags & GPR_FLAG_CAPI) ? "CAPI__" : "??????",
+ (record->flags & GPR_FLAG_STRESS) ? '!' : ' ',
+ record->allocate_increase, record->allocate_limit,
+#if CALC_EXACT_MALLOC_SIZE
+ record->allocated_size,
+#endif
+ record->heap_use_pages,
+ record->gc_mark_time*1000,
+ record->gc_sweep_time*1000,
+ record->prepare_time*1000,
+
+ record->heap_live_objects,
+ record->heap_free_objects,
+ record->removing_objects,
+ record->empty_objects
+#if RGENGC_PROFILE
+ ,
+ record->old_objects,
+ record->remembered_normal_objects,
+ record->remembered_shady_objects
+#endif
+#if GC_PROFILE_DETAIL_MEMORY
+ ,
+ record->maxrss / 1024,
+ record->minflt,
+ record->majflt
+#endif
+
+ ));
+ }
+#endif
+ }
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.result -> String
+ *
+ * Returns a profile data report such as:
+ *
+ * GC 1 invokes.
+ * Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
+ * 1 0.012 159240 212940 10647 0.00000000000001530000
+ */
+
+static VALUE
+gc_profile_result(VALUE _)
+{
+ VALUE str = rb_str_buf_new(0);
+ gc_profile_dump_on(str, rb_str_buf_append);
+ return str;
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.report
+ * GC::Profiler.report(io)
+ *
+ * Writes the GC::Profiler.result to <tt>$stdout</tt> or the given IO object.
+ *
+ */
+
+static VALUE
+gc_profile_report(int argc, VALUE *argv, VALUE self)
+{
+ VALUE out;
+
+ out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]);
+ gc_profile_dump_on(out, rb_io_write);
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.total_time -> float
+ *
+ * The total time used for garbage collection in seconds
+ */
+
+static VALUE
+gc_profile_total_time(VALUE self)
+{
+ double time = 0;
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ if (objspace->profile.run && objspace->profile.next_index > 0) {
+ size_t i;
+ size_t count = objspace->profile.next_index;
+
+ for (i = 0; i < count; i++) {
+ time += objspace->profile.records[i].gc_time;
+ }
+ }
+ return DBL2NUM(time);
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.enabled? -> true or false
+ *
+ * The current status of \GC profile mode.
+ */
+
+static VALUE
+gc_profile_enable_get(VALUE self)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ return objspace->profile.run ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.enable -> nil
+ *
+ * Starts the \GC profiler.
+ *
+ */
+
+static VALUE
+gc_profile_enable(VALUE _)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ objspace->profile.run = TRUE;
+ objspace->profile.current_record = 0;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * GC::Profiler.disable -> nil
+ *
+ * Stops the \GC profiler.
+ *
+ */
+
+static VALUE
+gc_profile_disable(VALUE _)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ objspace->profile.run = FALSE;
+ objspace->profile.current_record = 0;
+ return Qnil;
+}
+
+void
+rb_gc_verify_internal_consistency(void)
+{
+ gc_verify_internal_consistency(rb_gc_get_objspace());
+}
+
+/*
+ * call-seq:
+ * GC.verify_internal_consistency -> nil
+ *
+ * Verify internal consistency.
+ *
+ * This method is implementation specific.
+ * Now this method checks generational consistency
+ * if RGenGC is supported.
+ */
+static VALUE
+gc_verify_internal_consistency_m(VALUE dummy)
+{
+ rb_gc_verify_internal_consistency();
+ return Qnil;
+}
+
+#if GC_CAN_COMPILE_COMPACTION
+/*
+ * call-seq:
+ * GC.auto_compact = flag
+ *
+ * Updates automatic compaction mode.
+ *
+ * When enabled, the compactor will execute on every major collection.
+ *
+ * Enabling compaction will degrade performance on major collections.
+ */
+static VALUE
+gc_set_auto_compact(VALUE _, VALUE v)
+{
+ GC_ASSERT(GC_COMPACTION_SUPPORTED);
+
+ ruby_enable_autocompact = RTEST(v);
+
+#if RGENGC_CHECK_MODE
+ ruby_autocompact_compare_func = NULL;
+
+ if (SYMBOL_P(v)) {
+ ID id = RB_SYM2ID(v);
+ if (id == rb_intern("empty")) {
+ ruby_autocompact_compare_func = compare_free_slots;
+ }
+ }
+#endif
+
+ return v;
+}
+#else
+# define gc_set_auto_compact rb_f_notimplement
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+/*
+ * call-seq:
+ * GC.auto_compact -> true or false
+ *
+ * Returns whether or not automatic compaction has been enabled.
+ */
+static VALUE
+gc_get_auto_compact(VALUE _)
+{
+ return ruby_enable_autocompact ? Qtrue : Qfalse;
+}
+#else
+# define gc_get_auto_compact rb_f_notimplement
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+/*
+ * call-seq:
+ * GC.latest_compact_info -> hash
+ *
+ * Returns information about object moved in the most recent \GC compaction.
+ *
+ * The returned +hash+ contains the following keys:
+ *
+ * [considered]
+ * Hash containing the type of the object as the key and the number of
+ * objects of that type that were considered for movement.
+ * [moved]
+ * Hash containing the type of the object as the key and the number of
+ * objects of that type that were actually moved.
+ * [moved_up]
+ * Hash containing the type of the object as the key and the number of
+ * objects of that type that were increased in size.
+ * [moved_down]
+ * Hash containing the type of the object as the key and the number of
+ * objects of that type that were decreased in size.
+ *
+ * Some objects can't be moved (due to pinning) so these numbers can be used to
+ * calculate compaction efficiency.
+ */
+static VALUE
+gc_compact_stats(VALUE self)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ VALUE h = rb_hash_new();
+ VALUE considered = rb_hash_new();
+ VALUE moved = rb_hash_new();
+ VALUE moved_up = rb_hash_new();
+ VALUE moved_down = rb_hash_new();
+
+ for (size_t i = 0; i < T_MASK; i++) {
+ if (objspace->rcompactor.considered_count_table[i]) {
+ rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i]));
+ }
+
+ if (objspace->rcompactor.moved_count_table[i]) {
+ rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i]));
+ }
+
+ if (objspace->rcompactor.moved_up_count_table[i]) {
+ rb_hash_aset(moved_up, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_up_count_table[i]));
+ }
+
+ if (objspace->rcompactor.moved_down_count_table[i]) {
+ rb_hash_aset(moved_down, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_down_count_table[i]));
+ }
+ }
+
+ rb_hash_aset(h, ID2SYM(rb_intern("considered")), considered);
+ rb_hash_aset(h, ID2SYM(rb_intern("moved")), moved);
+ rb_hash_aset(h, ID2SYM(rb_intern("moved_up")), moved_up);
+ rb_hash_aset(h, ID2SYM(rb_intern("moved_down")), moved_down);
+
+ return h;
+}
+#else
+# define gc_compact_stats rb_f_notimplement
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+/*
+ * call-seq:
+ * GC.compact -> hash
+ *
+ * This function compacts objects together in Ruby's heap. It eliminates
+ * unused space (or fragmentation) in the heap by moving objects in to that
+ * unused space.
+ *
+ * The returned +hash+ contains statistics about the objects that were moved;
+ * see GC.latest_compact_info.
+ *
+ * This method is only expected to work on CRuby.
+ *
+ * To test whether \GC compaction is supported, use the idiom:
+ *
+ * GC.respond_to?(:compact)
+ */
+static VALUE
+gc_compact(VALUE self)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+ int full_marking_p = gc_config_full_mark_val;
+ gc_config_full_mark_set(TRUE);
+
+ /* Run GC with compaction enabled */
+ rb_gc_impl_start(rb_gc_get_objspace(), true, true, true, true);
+ gc_config_full_mark_set(full_marking_p);
+
+ return gc_compact_stats(self);
+}
+#else
+# define gc_compact rb_f_notimplement
+#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+struct desired_compaction_pages_i_data {
+ rb_objspace_t *objspace;
+ size_t required_slots[HEAP_COUNT];
+};
+
+static int
+desired_compaction_pages_i(struct heap_page *page, void *data)
+{
+ struct desired_compaction_pages_i_data *tdata = data;
+ rb_objspace_t *objspace = tdata->objspace;
+ VALUE vstart = (VALUE)page->start;
+ VALUE vend = vstart + (VALUE)(page->total_slots * page->heap->slot_size);
+
+
+ for (VALUE v = vstart; v != vend; v += page->heap->slot_size) {
+ asan_unpoisoning_object(v) {
+ /* skip T_NONEs; they won't be moved */
+ if (BUILTIN_TYPE(v) != T_NONE) {
+ rb_heap_t *dest_pool = gc_compact_destination_pool(objspace, page->heap, v);
+ size_t dest_pool_idx = dest_pool - heaps;
+ tdata->required_slots[dest_pool_idx]++;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* call-seq:
+ * GC.verify_compaction_references(toward: nil, double_heap: false) -> hash
+ *
+ * Verify compaction reference consistency.
+ *
+ * This method is implementation specific. During compaction, objects that
+ * were moved are replaced with T_MOVED objects. No object should have a
+ * reference to a T_MOVED object after compaction.
+ *
+ * This function expands the heap to ensure room to move all objects,
+ * compacts the heap to make sure everything moves, updates all references,
+ * then performs a full \GC. If any object contains a reference to a T_MOVED
+ * object, that object should be pushed on the mark stack, and will
+ * make a SEGV.
+ */
+static VALUE
+gc_verify_compaction_references(int argc, VALUE* argv, VALUE self)
+{
+ static ID keywords[3] = {0};
+ if (!keywords[0]) {
+ keywords[0] = rb_intern("toward");
+ keywords[1] = rb_intern("double_heap");
+ keywords[2] = rb_intern("expand_heap");
+ }
+
+ VALUE options;
+ rb_scan_args_kw(rb_keyword_given_p(), argc, argv, ":", &options);
+
+ VALUE arguments[3] = { Qnil, Qfalse, Qfalse };
+ int kwarg_count = rb_get_kwargs(options, keywords, 0, 3, arguments);
+ bool toward_empty = kwarg_count > 0 && SYMBOL_P(arguments[0]) && SYM2ID(arguments[0]) == rb_intern("empty");
+ bool expand_heap = (kwarg_count > 1 && RTEST(arguments[1])) || (kwarg_count > 2 && RTEST(arguments[2]));
+
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ /* Clear the heap. */
+ rb_gc_impl_start(objspace, true, true, true, false);
+
+ unsigned int lev = RB_GC_VM_LOCK();
+ {
+ gc_rest(objspace);
+
+ /* if both double_heap and expand_heap are set, expand_heap takes precedence */
+ if (expand_heap) {
+ struct desired_compaction_pages_i_data desired_compaction = {
+ .objspace = objspace,
+ .required_slots = {0},
+ };
+ /* Work out how many objects want to be in each size pool, taking account of moves */
+ objspace_each_pages(objspace, desired_compaction_pages_i, &desired_compaction, TRUE);
+
+ /* Find out which pool has the most pages */
+ size_t max_existing_pages = 0;
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ max_existing_pages = MAX(max_existing_pages, heap->total_pages);
+ }
+
+ /* Add pages to each size pool so that compaction is guaranteed to move every object */
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ size_t pages_to_add = 0;
+ /*
+ * Step 1: Make sure every pool has the same number of pages, by adding empty pages
+ * to smaller pools. This is required to make sure the compact cursor can advance
+ * through all of the pools in `gc_sweep_compact` without hitting the "sweep &
+ * compact cursors met" condition on some pools before fully compacting others
+ */
+ pages_to_add += max_existing_pages - heap->total_pages;
+ /*
+ * Step 2: Now add additional free pages to each size pool sufficient to hold all objects
+ * that want to be in that size pool, whether moved into it or moved within it
+ */
+ objspace->heap_pages.allocatable_bytes = desired_compaction.required_slots[i] * heap->slot_size;
+ while (objspace->heap_pages.allocatable_bytes > 0) {
+ heap_page_allocate_and_initialize(objspace, heap);
+ }
+ /*
+ * Step 3: Add two more pages so that the compact & sweep cursors will meet _after_ all objects
+ * have been moved, and not on the last iteration of the `gc_sweep_compact` loop
+ */
+ pages_to_add += 2;
+
+ for (; pages_to_add > 0; pages_to_add--) {
+ heap_page_allocate_and_initialize_force(objspace, heap);
+ }
+ }
+ }
+
+ if (toward_empty) {
+ objspace->rcompactor.compare_func = compare_free_slots;
+ }
+ }
+ RB_GC_VM_UNLOCK(lev);
+
+ rb_gc_impl_start(rb_gc_get_objspace(), true, true, true, true);
+
+ rb_objspace_reachable_objects_from_root(root_obj_check_moved_i, objspace);
+ objspace_each_objects(objspace, heap_check_moved_i, objspace, TRUE);
+
+ objspace->rcompactor.compare_func = NULL;
+
+ return gc_compact_stats(self);
+}
+#else
+# define gc_verify_compaction_references rb_f_notimplement
+#endif
+
+void
+rb_gc_impl_objspace_free(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ if (is_lazy_sweeping(objspace))
+ rb_bug("lazy sweeping underway when freeing object space");
+
+ free(objspace->profile.records);
+ objspace->profile.records = NULL;
+
+ for (size_t i = 0; i < rb_darray_size(objspace->heap_pages.sorted); i++) {
+ heap_page_free(objspace, rb_darray_get(objspace->heap_pages.sorted, i));
+ }
+ rb_darray_free_without_gc(objspace->heap_pages.sorted);
+ heap_pages_lomem = 0;
+ heap_pages_himem = 0;
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+ heap->total_pages = 0;
+ heap->total_slots = 0;
+ }
+
+ free_stack_chunks(&objspace->mark_stack);
+ mark_stack_free_cache(&objspace->mark_stack);
+
+ rb_darray_free_without_gc(objspace->weak_references);
+
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ rb_native_mutex_destroy(&objspace->malloc_counters.lock);
+#endif
+
+ free(objspace);
+}
+
+#if MALLOC_ALLOCATED_SIZE
+/*
+ * call-seq:
+ * GC.malloc_allocated_size -> Integer
+ *
+ * Returns the size of memory allocated by malloc().
+ *
+ * Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
+ */
+
+static VALUE
+gc_malloc_allocated_size(VALUE self)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)rb_gc_get_objspace();
+ return ULL2NUM(objspace->malloc_params.allocated_size);
+}
+
+/*
+ * call-seq:
+ * GC.malloc_allocations -> Integer
+ *
+ * Returns the number of malloc() allocations.
+ *
+ * Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
+ */
+
+static VALUE
+gc_malloc_allocations(VALUE self)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)rb_gc_get_objspace();
+ return ULL2NUM(objspace->malloc_params.allocations);
+}
+#endif
+
+void
+rb_gc_impl_before_fork(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ objspace->fork_vm_lock_lev = RB_GC_VM_LOCK();
+ rb_gc_vm_barrier();
+}
+
+void
+rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ RB_GC_VM_UNLOCK(objspace->fork_vm_lock_lev);
+ objspace->fork_vm_lock_lev = 0;
+
+ if (pid == 0) { /* child process */
+ rb_gc_ractor_newobj_cache_foreach(gc_ractor_newobj_cache_clear, NULL);
+ }
+}
+
+VALUE rb_ident_hash_new_with_size(st_index_t size);
+
+#if GC_DEBUG_STRESS_TO_CLASS
+/*
+ * call-seq:
+ * GC.add_stress_to_class(class[, ...])
+ *
+ * Raises NoMemoryError when allocating an instance of the given classes.
+ *
+ */
+static VALUE
+rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ if (!stress_to_class) {
+ set_stress_to_class(rb_ident_hash_new_with_size(argc));
+ }
+
+ for (int i = 0; i < argc; i++) {
+ VALUE klass = argv[i];
+ rb_hash_aset(stress_to_class, klass, Qtrue);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * GC.remove_stress_to_class(class[, ...])
+ *
+ * No longer raises NoMemoryError when allocating an instance of the
+ * given classes.
+ *
+ */
+static VALUE
+rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
+{
+ rb_objspace_t *objspace = rb_gc_get_objspace();
+
+ if (stress_to_class) {
+ for (int i = 0; i < argc; ++i) {
+ rb_hash_delete(stress_to_class, argv[i]);
+ }
+
+ if (rb_hash_size(stress_to_class) == 0) {
+ stress_to_class = 0;
+ }
+ }
+
+ return Qnil;
+}
+#endif
+
+void *
+rb_gc_impl_objspace_alloc(void)
+{
+ rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
+
+ return objspace;
+}
+
+void
+rb_gc_impl_objspace_init(void *objspace_ptr)
+{
+ rb_objspace_t *objspace = objspace_ptr;
+
+ gc_config_full_mark_set(TRUE);
+
+ objspace->flags.measure_gc = true;
+ malloc_limit = gc_params.malloc_limit_min;
+#ifdef MALLOC_COUNTERS_NEED_LOCK
+ rb_native_mutex_initialize(&objspace->malloc_counters.lock);
+#endif
+ objspace->finalize_deferred_pjob = rb_postponed_job_preregister(0, gc_finalize_deferred, objspace);
+ if (objspace->finalize_deferred_pjob == POSTPONED_JOB_HANDLE_INVALID) {
+ rb_bug("Could not preregister postponed job for GC");
+ }
+
+ /* A standard RVALUE (RBasic + embedded VALUEs + debug overhead) must fit
+ * in at least one pool. In debug builds RVALUE_OVERHEAD can push this
+ * beyond the 48-byte pool into the 64-byte pool, which is fine. */
+ GC_ASSERT(rb_gc_impl_size_allocatable_p(sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX])));
+
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ rb_heap_t *heap = &heaps[i];
+
+ heap->slot_size = pool_slot_sizes[i];
+
+ ccan_list_head_init(&heap->pages);
+ }
+
+ init_size_to_heap_idx();
+
+ rb_darray_make_without_gc(&objspace->heap_pages.sorted, 0);
+ rb_darray_make_without_gc(&objspace->weak_references, 0);
+
+#if defined(INIT_HEAP_PAGE_ALLOC_USE_MMAP)
+ /* Need to determine if we can use mmap at runtime. */
+ heap_page_alloc_use_mmap = INIT_HEAP_PAGE_ALLOC_USE_MMAP;
+#endif
+#if RGENGC_ESTIMATE_OLDMALLOC
+ objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
+#endif
+ gc_params.heap_init_bytes = GC_HEAP_INIT_BYTES;
+
+ init_mark_stack(&objspace->mark_stack);
+
+ objspace->profile.invoke_time = getrusage_time();
+ finalizer_table = st_init_numtable();
+}
+
+void
+rb_gc_impl_init(void)
+{
+ VALUE gc_constants = rb_hash_new();
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), GC_DEBUG ? Qtrue : Qfalse);
+ /* Minimum slot size that fits a standard RVALUE */
+ size_t rvalue_pool = 0;
+ for (size_t i = 0; i < HEAP_COUNT; i++) {
+ if (pool_slot_sizes[i] >= RVALUE_SLOT_SIZE) { rvalue_pool = pool_slot_sizes[i]; break; }
+ }
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(rvalue_pool - RVALUE_OVERHEAD));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), SIZET2NUM(RVALUE_OVERHEAD));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_SIZE")), SIZET2NUM(HEAP_PAGE_SIZE));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_COUNT")), LONG2FIX(HEAP_COUNT));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(heap_slot_size(HEAP_COUNT - 1)));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OLD_AGE")), LONG2FIX(RVALUE_OLD_AGE));
+ if (RB_BUG_INSTEAD_OF_RB_MEMERROR+0) {
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RB_BUG_INSTEAD_OF_RB_MEMERROR")), Qtrue);
+ }
+ OBJ_FREEZE(gc_constants);
+ /* Internal constants in the garbage collector. */
+ rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
+
+ if (GC_COMPACTION_SUPPORTED) {
+ rb_define_singleton_method(rb_mGC, "compact", gc_compact, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact", gc_get_auto_compact, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact=", gc_set_auto_compact, 1);
+ rb_define_singleton_method(rb_mGC, "latest_compact_info", gc_compact_stats, 0);
+ rb_define_singleton_method(rb_mGC, "verify_compaction_references", gc_verify_compaction_references, -1);
+ }
+ else {
+ rb_define_singleton_method(rb_mGC, "compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact=", rb_f_notimplement, 1);
+ rb_define_singleton_method(rb_mGC, "latest_compact_info", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
+ }
+
+#if GC_DEBUG_STRESS_TO_CLASS
+ rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
+ rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
+#endif
+
+ /* internal methods */
+ rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency_m, 0);
+
+#if MALLOC_ALLOCATED_SIZE
+ rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
+ rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
+#endif
+
+ VALUE rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
+ rb_define_singleton_method(rb_mProfiler, "enabled?", gc_profile_enable_get, 0);
+ rb_define_singleton_method(rb_mProfiler, "enable", gc_profile_enable, 0);
+ rb_define_singleton_method(rb_mProfiler, "raw_data", gc_profile_record_get, 0);
+ rb_define_singleton_method(rb_mProfiler, "disable", gc_profile_disable, 0);
+ rb_define_singleton_method(rb_mProfiler, "clear", gc_profile_clear, 0);
+ rb_define_singleton_method(rb_mProfiler, "result", gc_profile_result, 0);
+ rb_define_singleton_method(rb_mProfiler, "report", gc_profile_report, -1);
+ rb_define_singleton_method(rb_mProfiler, "total_time", gc_profile_total_time, 0);
+
+ {
+ VALUE opts;
+ /* \GC build options */
+ rb_define_const(rb_mGC, "OPTS", opts = rb_ary_new());
+#define OPT(o) if (o) rb_ary_push(opts, rb_interned_str(#o, sizeof(#o) - 1))
+ OPT(GC_DEBUG);
+ OPT(USE_RGENGC);
+ OPT(RGENGC_DEBUG);
+ OPT(RGENGC_CHECK_MODE);
+ OPT(RGENGC_PROFILE);
+ OPT(RGENGC_ESTIMATE_OLDMALLOC);
+ OPT(GC_PROFILE_MORE_DETAIL);
+ OPT(GC_ENABLE_LAZY_SWEEP);
+ OPT(CALC_EXACT_MALLOC_SIZE);
+ OPT(MALLOC_ALLOCATED_SIZE);
+ OPT(MALLOC_ALLOCATED_SIZE_CHECK);
+ OPT(GC_PROFILE_DETAIL_MEMORY);
+ OPT(GC_COMPACTION_SUPPORTED);
+#undef OPT
+ OBJ_FREEZE(opts);
+ }
+}
diff --git a/gc/default/extconf.rb b/gc/default/extconf.rb
new file mode 100644
index 0000000000..2940a4c962
--- /dev/null
+++ b/gc/default/extconf.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+require_relative "../extconf_base"
+
+create_gc_makefile("default")
diff --git a/gc/extconf_base.rb b/gc/extconf_base.rb
new file mode 100644
index 0000000000..2a224b9b0e
--- /dev/null
+++ b/gc/extconf_base.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+require "mkmf"
+
+srcdir = File.join(__dir__, "..")
+$INCFLAGS << " -I#{srcdir}"
+
+$CPPFLAGS << " -DBUILDING_MODULAR_GC"
+
+append_cflags("-fPIC")
+
+def create_gc_makefile(name, &block)
+ create_makefile("librubygc.#{name}", &block)
+end
diff --git a/gc/gc.h b/gc/gc.h
new file mode 100644
index 0000000000..d147a3122a
--- /dev/null
+++ b/gc/gc.h
@@ -0,0 +1,293 @@
+#ifndef GC_GC_H
+#define GC_GC_H
+/**
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @brief Private header for the default GC and other GC implementations
+ * first introduced for [Feature #20470].
+ */
+#include "ruby/ruby.h"
+#include "ruby/assert.h"
+
+#include "ruby/thread_native.h"
+
+#ifndef VM_CHECK_MODE
+# define VM_CHECK_MODE RUBY_DEBUG
+#endif
+
+// From ractor_core.h
+#ifndef RACTOR_CHECK_MODE
+# define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
+#endif
+
+#if RACTOR_CHECK_MODE
+void rb_ractor_setup_belonging(VALUE obj);
+
+struct rb_gc_obj_suffix {
+ uint32_t _ractor_belonging_id;
+};
+
+# define RB_GC_OBJ_HAS_SUFFIX 1
+# define RB_GC_OBJ_SUFFIX_SIZE (sizeof(struct rb_gc_obj_suffix))
+#else
+# define RB_GC_OBJ_HAS_SUFFIX 0
+# define RB_GC_OBJ_SUFFIX_SIZE 0
+#endif
+
+struct rb_gc_vm_context {
+ rb_nativethread_lock_t lock;
+
+ struct rb_execution_context_struct *ec;
+};
+
+typedef int (*vm_table_foreach_callback_func)(VALUE value, void *data);
+typedef int (*vm_table_update_callback_func)(VALUE *value, void *data);
+
+enum rb_gc_vm_weak_tables {
+ RB_GC_VM_CI_TABLE,
+ RB_GC_VM_OVERLOADED_CME_TABLE,
+ RB_GC_VM_GLOBAL_SYMBOLS_TABLE,
+ RB_GC_VM_ID2REF_TABLE,
+ RB_GC_VM_GENERIC_FIELDS_TABLE,
+ RB_GC_VM_FROZEN_STRINGS_TABLE,
+ RB_GC_VM_WEAK_TABLE_COUNT
+};
+
+#define RB_GC_VM_LOCK() rb_gc_vm_lock(__FILE__, __LINE__)
+#define RB_GC_VM_UNLOCK(lev) rb_gc_vm_unlock(lev, __FILE__, __LINE__)
+#define RB_GC_CR_LOCK() rb_gc_cr_lock(__FILE__, __LINE__)
+#define RB_GC_CR_UNLOCK(lev) rb_gc_cr_unlock(lev, __FILE__, __LINE__)
+#define RB_GC_VM_LOCK_NO_BARRIER() rb_gc_vm_lock_no_barrier(__FILE__, __LINE__)
+#define RB_GC_VM_UNLOCK_NO_BARRIER(lev) rb_gc_vm_unlock_no_barrier(lev, __FILE__, __LINE__)
+
+#if USE_MODULAR_GC
+# define MODULAR_GC_FN
+#else
+// This takes advantage of internal linkage winning when appearing first.
+// See C99 6.2.2p4.
+# define MODULAR_GC_FN static
+#endif
+
+#if USE_MODULAR_GC
+RUBY_SYMBOL_EXPORT_BEGIN
+#endif
+
+// These functions cannot be defined as static because they are used by other
+// files in Ruby.
+size_t rb_size_mul_or_raise(size_t x, size_t y, VALUE exc);
+void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
+const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
+const char *rb_obj_info(VALUE obj);
+size_t rb_obj_memsize_of(VALUE obj);
+bool ruby_free_at_exit_p(void);
+void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *passing_data);
+void rb_gc_verify_shareable(VALUE);
+
+MODULAR_GC_FN unsigned int rb_gc_vm_lock(const char *file, int line);
+MODULAR_GC_FN void rb_gc_vm_unlock(unsigned int lev, const char *file, int line);
+MODULAR_GC_FN unsigned int rb_gc_cr_lock(const char *file, int line);
+MODULAR_GC_FN void rb_gc_cr_unlock(unsigned int lev, const char *file, int line);
+MODULAR_GC_FN unsigned int rb_gc_vm_lock_no_barrier(const char *file, int line);
+MODULAR_GC_FN void rb_gc_vm_unlock_no_barrier(unsigned int lev, const char *file, int line);
+MODULAR_GC_FN void rb_gc_vm_barrier(void);
+MODULAR_GC_FN size_t rb_gc_obj_optimal_size(VALUE obj);
+MODULAR_GC_FN void rb_gc_mark_children(void *objspace, VALUE obj);
+MODULAR_GC_FN void rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback, vm_table_update_callback_func update_callback, void *data, bool weak_only, enum rb_gc_vm_weak_tables table);
+MODULAR_GC_FN void rb_gc_update_object_references(void *objspace, VALUE obj);
+MODULAR_GC_FN void rb_gc_update_vm_references(void *objspace);
+MODULAR_GC_FN void rb_gc_event_hook(VALUE obj, rb_event_flag_t event);
+MODULAR_GC_FN void *rb_gc_get_objspace(void);
+MODULAR_GC_FN void rb_gc_run_obj_finalizer(VALUE objid, long count, VALUE (*callback)(long i, void *data), void *data);
+MODULAR_GC_FN void rb_gc_set_pending_interrupt(void);
+MODULAR_GC_FN void rb_gc_unset_pending_interrupt(void);
+MODULAR_GC_FN void rb_gc_obj_free_vm_weak_references(VALUE obj);
+MODULAR_GC_FN bool rb_gc_obj_free(void *objspace, VALUE obj);
+MODULAR_GC_FN void rb_gc_save_machine_context(void);
+MODULAR_GC_FN void rb_gc_mark_roots(void *objspace, const char **categoryp);
+MODULAR_GC_FN void rb_gc_ractor_newobj_cache_foreach(void (*func)(void *cache, void *data), void *data);
+MODULAR_GC_FN bool rb_gc_multi_ractor_p(void);
+MODULAR_GC_FN bool rb_gc_shutdown_call_finalizer_p(VALUE obj);
+MODULAR_GC_FN void rb_gc_obj_changed_pool(VALUE obj, size_t heap_id);
+MODULAR_GC_FN void rb_gc_prepare_heap_process_object(VALUE obj);
+MODULAR_GC_FN bool rb_memerror_reentered(void);
+MODULAR_GC_FN bool rb_obj_id_p(VALUE);
+MODULAR_GC_FN void rb_gc_before_updating_jit_code(void);
+MODULAR_GC_FN void rb_gc_after_updating_jit_code(void);
+MODULAR_GC_FN bool rb_gc_obj_shareable_p(VALUE);
+MODULAR_GC_FN void rb_gc_rp(VALUE);
+MODULAR_GC_FN void rb_gc_handle_weak_references(VALUE obj);
+MODULAR_GC_FN bool rb_gc_obj_needs_cleanup_p(VALUE obj);
+
+#if USE_MODULAR_GC
+MODULAR_GC_FN bool rb_gc_event_hook_required_p(rb_event_flag_t event);
+MODULAR_GC_FN void *rb_gc_get_ractor_newobj_cache(void);
+MODULAR_GC_FN void rb_gc_initialize_vm_context(struct rb_gc_vm_context *context);
+MODULAR_GC_FN void rb_gc_move_obj_during_marking(VALUE from, VALUE to);
+MODULAR_GC_FN void rb_gc_print_backtrace();
+#endif
+
+#if USE_MODULAR_GC
+RUBY_SYMBOL_EXPORT_END
+#endif
+
+void rb_ractor_finish_marking(void);
+
+// -------------------Private section begin------------------------
+// Functions in this section are private to the default GC and gc.c
+
+#ifdef BUILDING_MODULAR_GC
+RBIMPL_WARNING_PUSH()
+RBIMPL_WARNING_IGNORED(-Wunused-function)
+#endif
+
+/* RGENGC_CHECK_MODE
+ * 0: disable all assertions
+ * 1: enable assertions (to debug RGenGC)
+ * 2: enable internal consistency check at each GC (for debugging)
+ * 3: enable internal consistency check at each GC steps (for debugging)
+ * 4: enable liveness check
+ * 5: show all references
+ */
+#ifndef RGENGC_CHECK_MODE
+# define RGENGC_CHECK_MODE 0
+#endif
+
+#ifndef GC_ASSERT
+# define GC_ASSERT(expr, ...) RUBY_ASSERT_MESG_WHEN(RGENGC_CHECK_MODE > 0, expr, #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+#endif
+
+static int
+hash_foreach_replace_value(st_data_t key, st_data_t value, st_data_t argp, int error)
+{
+ if (rb_gc_location((VALUE)value) != (VALUE)value) {
+ return ST_REPLACE;
+ }
+ return ST_CONTINUE;
+}
+
+static int
+hash_replace_ref_value(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
+{
+ *value = rb_gc_location((VALUE)*value);
+
+ return ST_CONTINUE;
+}
+
+static void
+gc_ref_update_table_values_only(st_table *tbl)
+{
+ if (!tbl || tbl->num_entries == 0) return;
+
+ if (st_foreach_with_replace(tbl, hash_foreach_replace_value, hash_replace_ref_value, 0)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
+}
+
+static int
+gc_mark_tbl_no_pin_i(st_data_t key, st_data_t value, st_data_t data)
+{
+ rb_gc_mark_movable((VALUE)value);
+
+ return ST_CONTINUE;
+}
+
+static int
+gc_mark_set_no_pin_i(st_data_t key, st_data_t value, st_data_t data)
+{
+ rb_gc_mark_movable((VALUE)key);
+
+ return ST_CONTINUE;
+}
+
+static int
+hash_foreach_replace(st_data_t key, st_data_t value, st_data_t argp, int error)
+{
+ if (rb_gc_location((VALUE)key) != (VALUE)key) {
+ return ST_REPLACE;
+ }
+
+ if (rb_gc_location((VALUE)value) != (VALUE)value) {
+ return ST_REPLACE;
+ }
+
+ return ST_CONTINUE;
+}
+
+static int
+hash_replace_ref(st_data_t *key, st_data_t *value, st_data_t argp, int existing)
+{
+ VALUE new_key = rb_gc_location((VALUE)*key);
+ if (new_key != (VALUE)*key) {
+ *key = new_key;
+ }
+
+ VALUE new_value = rb_gc_location((VALUE)*value);
+ if (new_value != (VALUE)*value) {
+ *value = new_value;
+ }
+
+ return ST_CONTINUE;
+}
+
+static void
+gc_update_table_refs(st_table *tbl)
+{
+ if (!tbl || tbl->num_entries == 0) return;
+
+ if (st_foreach_with_replace(tbl, hash_foreach_replace, hash_replace_ref, 0)) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
+}
+
+static inline size_t
+xmalloc2_size(const size_t count, const size_t elsize)
+{
+ return rb_size_mul_or_raise(count, elsize, rb_eArgError);
+}
+
+static VALUE
+type_sym(size_t type)
+{
+ switch (type) {
+#define COUNT_TYPE(t) case (t): return ID2SYM(rb_intern(#t)); break;
+ COUNT_TYPE(T_NONE);
+ COUNT_TYPE(T_OBJECT);
+ COUNT_TYPE(T_CLASS);
+ COUNT_TYPE(T_MODULE);
+ COUNT_TYPE(T_FLOAT);
+ COUNT_TYPE(T_STRING);
+ COUNT_TYPE(T_REGEXP);
+ COUNT_TYPE(T_ARRAY);
+ COUNT_TYPE(T_HASH);
+ COUNT_TYPE(T_STRUCT);
+ COUNT_TYPE(T_BIGNUM);
+ COUNT_TYPE(T_FILE);
+ COUNT_TYPE(T_DATA);
+ COUNT_TYPE(T_MATCH);
+ COUNT_TYPE(T_COMPLEX);
+ COUNT_TYPE(T_RATIONAL);
+ COUNT_TYPE(T_NIL);
+ COUNT_TYPE(T_TRUE);
+ COUNT_TYPE(T_FALSE);
+ COUNT_TYPE(T_SYMBOL);
+ COUNT_TYPE(T_FIXNUM);
+ COUNT_TYPE(T_IMEMO);
+ COUNT_TYPE(T_UNDEF);
+ COUNT_TYPE(T_NODE);
+ COUNT_TYPE(T_ICLASS);
+ COUNT_TYPE(T_ZOMBIE);
+ COUNT_TYPE(T_MOVED);
+#undef COUNT_TYPE
+ default: return SIZET2NUM(type); break;
+ }
+}
+
+#ifdef BUILDING_MODULAR_GC
+RBIMPL_WARNING_POP()
+#endif
+// -------------------Private section end------------------------
+
+#endif
diff --git a/gc/gc_impl.h b/gc/gc_impl.h
new file mode 100644
index 0000000000..d9e44cc66d
--- /dev/null
+++ b/gc/gc_impl.h
@@ -0,0 +1,127 @@
+#ifndef GC_GC_IMPL_H
+#define GC_GC_IMPL_H
+/**
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @brief Header for GC implementations introduced in [Feature #20470].
+ */
+#include "ruby/ruby.h"
+
+#ifndef RB_GC_OBJECT_METADATA_ENTRY_DEFINED
+# define RB_GC_OBJECT_METADATA_ENTRY_DEFINED
+struct rb_gc_object_metadata_entry {
+ ID name;
+ VALUE val;
+};
+#endif
+
+#ifdef BUILDING_MODULAR_GC
+# define GC_IMPL_FN
+#else
+// `GC_IMPL_FN` is an implementation detail of `!USE_MODULAR_GC` builds
+// to have the default GC in the same translation unit as gc.c for
+// the sake of optimizer visibility. It expands to nothing unless
+// you're the default GC.
+//
+// For the default GC, do not copy-paste this when implementing
+// these functions. This takes advantage of internal linkage winning
+// when appearing first. See C99 6.2.2p4.
+# define GC_IMPL_FN static
+#endif
+
+// Bootup
+GC_IMPL_FN void *rb_gc_impl_objspace_alloc(void);
+GC_IMPL_FN void rb_gc_impl_objspace_init(void *objspace_ptr);
+GC_IMPL_FN void *rb_gc_impl_ractor_cache_alloc(void *objspace_ptr, void *ractor);
+GC_IMPL_FN void rb_gc_impl_set_params(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_init(void);
+GC_IMPL_FN size_t *rb_gc_impl_heap_sizes(void *objspace_ptr);
+// Shutdown
+GC_IMPL_FN void rb_gc_impl_shutdown_free_objects(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_objspace_free(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache);
+// GC
+GC_IMPL_FN void rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact);
+GC_IMPL_FN bool rb_gc_impl_during_gc_p(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_prepare_heap(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_gc_enable(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_gc_disable(void *objspace_ptr, bool finish_current_gc);
+GC_IMPL_FN bool rb_gc_impl_gc_enabled_p(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_stress_set(void *objspace_ptr, VALUE flag);
+GC_IMPL_FN VALUE rb_gc_impl_stress_get(void *objspace_ptr);
+GC_IMPL_FN VALUE rb_gc_impl_config_get(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_config_set(void *objspace_ptr, VALUE hash);
+GC_IMPL_FN struct rb_gc_vm_context *rb_gc_impl_get_vm_context(void *objspace_ptr);
+// Object allocation
+GC_IMPL_FN VALUE rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags, bool wb_protected, size_t alloc_size);
+GC_IMPL_FN size_t rb_gc_impl_obj_slot_size(VALUE obj);
+GC_IMPL_FN size_t rb_gc_impl_heap_id_for_size(void *objspace_ptr, size_t size);
+GC_IMPL_FN bool rb_gc_impl_size_allocatable_p(size_t size);
+// Malloc
+/*
+ * BEWARE: These functions may or may not run under GVL.
+ *
+ * You might want to make them thread-safe.
+ * Garbage collecting inside is possible if and only if you
+ * already have GVL. Also raising exceptions without one is a
+ * total disaster.
+ *
+ * When you absolutely cannot allocate the requested amount of
+ * memory just return NULL (with appropriate errno set).
+ * The caller side takes care of that situation.
+ */
+GC_IMPL_FN void *rb_gc_impl_malloc(void *objspace_ptr, size_t size, bool gc_allowed);
+GC_IMPL_FN void *rb_gc_impl_calloc(void *objspace_ptr, size_t size, bool gc_allowed);
+GC_IMPL_FN void *rb_gc_impl_realloc(void *objspace_ptr, void *ptr, size_t new_size, size_t old_size, bool gc_allowed);
+GC_IMPL_FN void rb_gc_impl_free(void *objspace_ptr, void *ptr, size_t old_size);
+GC_IMPL_FN void rb_gc_impl_adjust_memory_usage(void *objspace_ptr, ssize_t diff);
+// Marking
+GC_IMPL_FN void rb_gc_impl_mark(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_mark_and_move(void *objspace_ptr, VALUE *ptr);
+GC_IMPL_FN void rb_gc_impl_mark_and_pin(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_mark_maybe(void *objspace_ptr, VALUE obj);
+// Weak references
+GC_IMPL_FN void rb_gc_impl_declare_weak_references(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN bool rb_gc_impl_handle_weak_references_alive_p(void *objspace_ptr, VALUE obj);
+// Compaction
+GC_IMPL_FN void rb_gc_impl_register_pinning_obj(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN bool rb_gc_impl_object_moved_p(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN VALUE rb_gc_impl_location(void *objspace_ptr, VALUE value);
+// Write barriers
+GC_IMPL_FN void rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b);
+GC_IMPL_FN void rb_gc_impl_writebarrier_unprotect(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_writebarrier_remember(void *objspace_ptr, VALUE obj);
+// Heap walking
+GC_IMPL_FN void rb_gc_impl_each_objects(void *objspace_ptr, int (*callback)(void *, void *, size_t, void *), void *data);
+GC_IMPL_FN void rb_gc_impl_each_object(void *objspace_ptr, void (*func)(VALUE obj, void *data), void *data);
+// Finalizers
+GC_IMPL_FN void rb_gc_impl_make_zombie(void *objspace_ptr, VALUE obj, void (*dfree)(void *), void *data);
+GC_IMPL_FN VALUE rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block);
+GC_IMPL_FN void rb_gc_impl_undefine_finalizer(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_copy_finalizer(void *objspace_ptr, VALUE dest, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr);
+// Forking
+GC_IMPL_FN void rb_gc_impl_before_fork(void *objspace_ptr);
+GC_IMPL_FN void rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid);
+// Statistics
+GC_IMPL_FN void rb_gc_impl_set_measure_total_time(void *objspace_ptr, VALUE flag);
+GC_IMPL_FN bool rb_gc_impl_get_measure_total_time(void *objspace_ptr);
+GC_IMPL_FN unsigned long long rb_gc_impl_get_total_time(void *objspace_ptr);
+GC_IMPL_FN size_t rb_gc_impl_gc_count(void *objspace_ptr);
+GC_IMPL_FN VALUE rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE key);
+GC_IMPL_FN VALUE rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym);
+GC_IMPL_FN VALUE rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
+GC_IMPL_FN const char *rb_gc_impl_active_gc_name(void);
+// Miscellaneous
+GC_IMPL_FN struct rb_gc_object_metadata_entry *rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN bool rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr);
+GC_IMPL_FN bool rb_gc_impl_garbage_object_p(void *objspace_ptr, VALUE obj);
+GC_IMPL_FN void rb_gc_impl_set_event_hook(void *objspace_ptr, const rb_event_flag_t event);
+GC_IMPL_FN void rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj);
+
+#undef GC_IMPL_FN
+
+#endif
diff --git a/gc/mmtk/.gitignore b/gc/mmtk/.gitignore
new file mode 100644
index 0000000000..eb5a316cbd
--- /dev/null
+++ b/gc/mmtk/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/gc/mmtk/Cargo.lock b/gc/mmtk/Cargo.lock
new file mode 100644
index 0000000000..910048fa80
--- /dev/null
+++ b/gc/mmtk/Cargo.lock
@@ -0,0 +1,1108 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anstream"
+version = "0.6.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys",
+]
+
+[[package]]
+name = "atomic"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994"
+dependencies = [
+ "bytemuck",
+]
+
+[[package]]
+name = "atomic-traits"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "707f750b93bd1b739cf9ddf85f8fe7c97a4a62c60ccf8b6f232514bd9103bedc"
+dependencies = [
+ "cfg-if",
+ "rustc_version",
+]
+
+[[package]]
+name = "atomic_refcell"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41e67cd8309bbd06cd603a9e693a784ac2e5d1e955f11286e355089fcab3047c"
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
+[[package]]
+name = "bitflags"
+version = "2.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
+
+[[package]]
+name = "built"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b"
+dependencies = [
+ "git2",
+]
+
+[[package]]
+name = "bytemuck"
+version = "1.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
+dependencies = [
+ "bytemuck_derive",
+]
+
+[[package]]
+name = "bytemuck_derive"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "cc"
+version = "1.2.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7"
+dependencies = [
+ "jobserver",
+ "libc",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "crossbeam"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
+dependencies = [
+ "crossbeam-channel",
+ "crossbeam-deque",
+ "crossbeam-epoch",
+ "crossbeam-queue",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-deque"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
+dependencies = [
+ "crossbeam-epoch",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-epoch"
+version = "0.9.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-queue"
+version = "0.3.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
+
+[[package]]
+name = "delegate"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9b6483c2bbed26f97861cf57651d4f2b731964a28cd2257f934a4b452480d21"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "downcast-rs"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea8a8b81cacc08888170eef4d13b775126db426d0b348bee9d18c2c1eaf123cf"
+
+[[package]]
+name = "either"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
+
+[[package]]
+name = "enum-map"
+version = "2.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9"
+dependencies = [
+ "enum-map-derive",
+]
+
+[[package]]
+name = "enum-map-derive"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "env_filter"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
+dependencies = [
+ "log",
+ "regex",
+]
+
+[[package]]
+name = "env_logger"
+version = "0.11.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "env_filter",
+ "jiff",
+ "log",
+]
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+ "wasi",
+]
+
+[[package]]
+name = "git2"
+version = "0.20.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b"
+dependencies = [
+ "bitflags",
+ "libc",
+ "libgit2-sys",
+ "log",
+ "url",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hermit-abi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+
+[[package]]
+name = "hermit-abi"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
+
+[[package]]
+name = "idna"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "279259b0ac81c89d11c290495fdcfa96ea3643b7df311c138b6fe8ca5237f0f8"
+dependencies = [
+ "idna_mapping",
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "idna_mapping"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11c13906586a4b339310541a274dd927aff6fcbb5b8e3af90634c4b31681c792"
+dependencies = [
+ "unicode-joining-type",
+]
+
+[[package]]
+name = "is-terminal"
+version = "0.4.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
+dependencies = [
+ "hermit-abi 0.5.1",
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+
+[[package]]
+name = "itertools"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "jiff"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a194df1107f33c79f4f93d02c80798520551949d59dfad22b6157048a88cca93"
+dependencies = [
+ "jiff-static",
+ "log",
+ "portable-atomic",
+ "portable-atomic-util",
+ "serde",
+]
+
+[[package]]
+name = "jiff-static"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c6e1db7ed32c6c71b759497fae34bf7933636f75a251b9e736555da426f6442"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "jobserver"
+version = "0.1.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
+dependencies = [
+ "getrandom",
+ "libc",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
+
+[[package]]
+name = "libc"
+version = "0.2.172"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
+
+[[package]]
+name = "libgit2-sys"
+version = "0.18.3+1.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487"
+dependencies = [
+ "cc",
+ "libc",
+ "libz-sys",
+ "pkg-config",
+]
+
+[[package]]
+name = "libz-sys"
+version = "1.1.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "lock_api"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
+
+[[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
+name = "memoffset"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "mmtk"
+version = "0.31.0"
+source = "git+https://github.com/mmtk/mmtk-core.git?rev=c6317a3f1c262e33fc2e427e4cc999c17bcc4791#c6317a3f1c262e33fc2e427e4cc999c17bcc4791"
+dependencies = [
+ "atomic",
+ "atomic-traits",
+ "atomic_refcell",
+ "built",
+ "bytemuck",
+ "bytemuck_derive",
+ "cfg-if",
+ "crossbeam",
+ "delegate",
+ "downcast-rs",
+ "enum-map",
+ "env_logger",
+ "idna_adapter",
+ "is-terminal",
+ "itertools",
+ "lazy_static",
+ "libc",
+ "log",
+ "memoffset",
+ "mmtk-macros",
+ "num-traits",
+ "num_cpus",
+ "portable-atomic",
+ "probe",
+ "rayon-core",
+ "regex",
+ "rustversion",
+ "spin",
+ "static_assertions",
+ "strum",
+ "strum_macros",
+ "sysinfo 0.33.1",
+]
+
+[[package]]
+name = "mmtk-macros"
+version = "0.31.0"
+source = "git+https://github.com/mmtk/mmtk-core.git?rev=c6317a3f1c262e33fc2e427e4cc999c17bcc4791#c6317a3f1c262e33fc2e427e4cc999c17bcc4791"
+dependencies = [
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "mmtk_ruby"
+version = "0.1.0"
+dependencies = [
+ "atomic_refcell",
+ "env_logger",
+ "libc",
+ "log",
+ "mmtk",
+ "once_cell",
+ "probe",
+ "sysinfo 0.32.1",
+]
+
+[[package]]
+name = "ntapi"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+dependencies = [
+ "hermit-abi 0.3.9",
+ "libc",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
+[[package]]
+name = "portable-atomic"
+version = "1.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
+
+[[package]]
+name = "portable-atomic-util"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
+dependencies = [
+ "portable-atomic",
+]
+
+[[package]]
+name = "probe"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8e2d2444b730c8f027344c60f9e1f1554d7a3342df9bdd425142ed119a6e5a3"
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.95"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "5.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
+
+[[package]]
+name = "rayon"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
+dependencies = [
+ "either",
+ "rayon-core",
+]
+
+[[package]]
+name = "rayon-core"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
+dependencies = [
+ "crossbeam-deque",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "regex"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "semver"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
+
+[[package]]
+name = "serde"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "smallvec"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
+
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+dependencies = [
+ "lock_api",
+]
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "strum"
+version = "0.27.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32"
+
+[[package]]
+name = "strum_macros"
+version = "0.27.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.101"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "sysinfo"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c33cd241af0f2e9e3b5c32163b873b29956890b5342e6745b917ce9d490f4af"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+ "memchr",
+ "ntapi",
+ "rayon",
+ "windows",
+]
+
+[[package]]
+name = "sysinfo"
+version = "0.33.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+ "memchr",
+ "ntapi",
+ "rayon",
+ "windows",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71"
+dependencies = [
+ "tinyvec_macros",
+]
+
+[[package]]
+name = "tinyvec_macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+
+[[package]]
+name = "unicode-bidi"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
+[[package]]
+name = "unicode-joining-type"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8d00a78170970967fdb83f9d49b92f959ab2bb829186b113e4f4604ad98e180"
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "url"
+version = "2.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+]
+
+[[package]]
+name = "utf8_iter"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "wasi"
+version = "0.14.2+wasi-0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
+dependencies = [
+ "wit-bindgen-rt",
+]
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
+dependencies = [
+ "windows-core",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-result",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "windows-result"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "wit-bindgen-rt"
+version = "0.39.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
+dependencies = [
+ "bitflags",
+]
diff --git a/gc/mmtk/Cargo.toml b/gc/mmtk/Cargo.toml
new file mode 100644
index 0000000000..d856122900
--- /dev/null
+++ b/gc/mmtk/Cargo.toml
@@ -0,0 +1,42 @@
+[package]
+name = "mmtk_ruby"
+version = "0.1.0"
+authors = []
+edition = "2021"
+
+[lib]
+name = "mmtk_ruby"
+crate-type = ["cdylib", "staticlib"]
+
+[profile.release]
+lto = true
+
+[dependencies]
+libc = "0.2"
+log = "0.4.14"
+env_logger = "0.11.3"
+once_cell = "1.17.0"
+atomic_refcell = "0.1.9"
+probe = "0.5"
+sysinfo = "0.32.0"
+
+[dependencies.mmtk]
+features = ["is_mmtk_object", "object_pinning", "sticky_immix_non_moving_nursery"]
+
+# Uncomment the following lines to use mmtk-core from the official repository.
+git = "https://github.com/mmtk/mmtk-core.git"
+rev = "c6317a3f1c262e33fc2e427e4cc999c17bcc4791"
+
+# Uncomment the following line to use mmtk-core from a local repository.
+# path = "../../../mmtk-core"
+
+[features]
+default = []
+
+# When moving an object, clear its original copy.
+clear_old_copy = []
+
+# Enable extra assertions in release build. For debugging.
+extra_assert = []
+
+[workspace]
diff --git a/gc/mmtk/cbindgen.toml b/gc/mmtk/cbindgen.toml
new file mode 100644
index 0000000000..b99c30efc8
--- /dev/null
+++ b/gc/mmtk/cbindgen.toml
@@ -0,0 +1,36 @@
+language = "C"
+
+include_guard = "MMTK_H"
+
+autogen_warning = "/* Warning, this file is autogenerated by cbindgen from the mmtk-ruby repository. Don't modify this manually. */"
+
+tab_width = 4
+
+usize_is_size_t = true
+
+after_includes = """
+
+typedef struct MMTk_Builder MMTk_Builder;
+typedef struct MMTk_Mutator MMTk_Mutator;
+
+typedef struct MMTk_ractor_cache *MMTk_VMThread;
+typedef struct MMTk_ractor_cache *MMTk_VMMutatorThread;
+typedef struct MMTk_GCThreadTLS *MMTk_VMWorkerThread;
+typedef void *MMTk_Address;
+typedef void *MMTk_ObjectReference;
+typedef void *MMTk_NullableObjectReference;
+typedef uint32_t MMTk_AllocationSemantics;
+
+typedef struct MMTk_BumpPointer {
+ uintptr_t cursor;
+ uintptr_t limit;
+} MMTk_BumpPointer;
+"""
+
+[export]
+exclude = ["RubyMutator"]
+prefix = "MMTk_"
+
+[export.rename]
+"MMTKBuilder" = "Builder"
+"RubyMutator" = "Mutator"
diff --git a/gc/mmtk/depend b/gc/mmtk/depend
new file mode 100644
index 0000000000..77b229af36
--- /dev/null
+++ b/gc/mmtk/depend
@@ -0,0 +1,18 @@
+$(TARGET_SO): $(MMTK_BUILD)/$(LIBMMTK_RUBY)
+
+# Add the `libmmtk_ruby.a` target to run `cargo build`
+
+release/$(LIBMMTK_RUBY) debug/$(LIBMMTK_RUBY): $(RUSTSRCS) $(srcdir)/Cargo.toml $(srcdir)/Cargo.toml
+
+release/$(LIBMMTK_RUBY):
+ CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml --release
+
+debug/$(LIBMMTK_RUBY):
+ CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml
+
+clean: clean-mmtk
+
+.PHONY: clean-mmtk
+clean-mmtk:
+ -$(Q)$(RM_RF) debug release
+ -$(Q)$(RM) .rustc_info.json
diff --git a/gc/mmtk/extconf.rb b/gc/mmtk/extconf.rb
new file mode 100644
index 0000000000..c0e788037e
--- /dev/null
+++ b/gc/mmtk/extconf.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require_relative "../extconf_base"
+
+# Statically link `libmmtk_ruby.a`
+$LIBS << " $(MMTK_BUILD)/$(LIBMMTK_RUBY)"
+
+rustsrcs = Dir.glob("src/*.rs", base: __dir__).map {|s| "$(srcdir)/#{s}"}
+
+create_gc_makefile("mmtk") do |makefile|
+ [
+ *makefile,
+
+ <<~MAKEFILE,
+ MMTK_BUILD = debug
+ LIBMMTK_RUBY = libmmtk_ruby.#$LIBEXT
+ RUSTSRCS = #{rustsrcs.join(" \\\n\t ")}
+
+ ifeq ($(MMTK_BUILD), debug)
+ CPPFLAGS += -DMMTK_DEBUG
+ endif
+ MAKEFILE
+ ]
+end
diff --git a/gc/mmtk/mmtk.c b/gc/mmtk/mmtk.c
new file mode 100644
index 0000000000..95176b692b
--- /dev/null
+++ b/gc/mmtk/mmtk.c
@@ -0,0 +1,1656 @@
+#include <pthread.h>
+#include <stdbool.h>
+
+#include "ruby/assert.h"
+#include "ruby/atomic.h"
+#include "ruby/debug.h"
+
+#include "gc/gc.h"
+#include "gc/gc_impl.h"
+#include "gc/mmtk/mmtk.h"
+
+#include "ccan/list/list.h"
+#include "darray.h"
+
+#ifdef __APPLE__
+#include <sys/sysctl.h>
+#endif
+
+struct objspace {
+ bool measure_gc_time;
+ bool gc_stress;
+
+ size_t gc_count;
+ size_t moving_gc_count;
+ size_t total_gc_time;
+ size_t total_allocated_objects;
+
+ st_table *finalizer_table;
+ struct MMTk_final_job *finalizer_jobs;
+ rb_postponed_job_handle_t finalizer_postponed_job;
+
+ struct ccan_list_head ractor_caches;
+ unsigned long live_ractor_cache_count;
+
+ pthread_mutex_t mutex;
+ rb_atomic_t mutator_blocking_count;
+ bool world_stopped;
+ pthread_cond_t cond_world_stopped;
+ pthread_cond_t cond_world_started;
+ size_t start_the_world_count;
+
+ pthread_mutex_t event_hook_mutex;
+
+ struct {
+ bool gc_thread_crashed;
+ char crash_msg[256];
+ } crash_context;
+
+ struct rb_gc_vm_context vm_context;
+
+ unsigned int fork_hook_vm_lock_lev;
+};
+
+#define OBJ_FREE_BUF_CAPACITY 128
+
+struct MMTk_ractor_cache {
+ struct ccan_list_node list_node;
+
+ MMTk_Mutator *mutator;
+ bool gc_mutator_p;
+
+ MMTk_BumpPointer *bump_pointer;
+
+ MMTk_ObjectReference obj_free_parallel_buf[OBJ_FREE_BUF_CAPACITY];
+ size_t obj_free_parallel_count;
+ MMTk_ObjectReference obj_free_non_parallel_buf[OBJ_FREE_BUF_CAPACITY];
+ size_t obj_free_non_parallel_count;
+};
+
+struct MMTk_final_job {
+ struct MMTk_final_job *next;
+ enum {
+ MMTK_FINAL_JOB_DFREE,
+ MMTK_FINAL_JOB_FINALIZE,
+ } kind;
+ union {
+ struct {
+ void (*func)(void *);
+ void *data;
+ } dfree;
+ struct {
+ /* HACK: we store the object ID on the 0th element of this array. */
+ VALUE finalizer_array;
+ } finalize;
+ } as;
+};
+
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+RB_THREAD_LOCAL_SPECIFIER struct MMTk_GCThreadTLS *rb_mmtk_gc_thread_tls;
+
+RB_THREAD_LOCAL_SPECIFIER VALUE marking_parent_object;
+#else
+# error We currently need language-supported TLS
+#endif
+
+#ifdef MMTK_DEBUG
+# define MMTK_ASSERT(expr, ...) RUBY_ASSERT_ALWAYS(expr, #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+#else
+# define MMTK_ASSERT(expr, ...) ((void)0)
+#endif
+
+#include <pthread.h>
+
+static inline VALUE rb_mmtk_call_object_closure(VALUE obj, bool pin);
+
+static void
+rb_mmtk_init_gc_worker_thread(MMTk_VMWorkerThread gc_thread_tls)
+{
+ rb_mmtk_gc_thread_tls = gc_thread_tls;
+}
+
+static bool
+rb_mmtk_is_mutator(void)
+{
+ return ruby_native_thread_p();
+}
+
+static void
+rb_mmtk_stop_the_world(void)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ int err;
+ if ((err = pthread_mutex_lock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot lock objspace->mutex: %s", strerror(err));
+ }
+
+ while (!objspace->world_stopped) {
+ pthread_cond_wait(&objspace->cond_world_stopped, &objspace->mutex);
+ }
+
+ if ((err = pthread_mutex_unlock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot release objspace->mutex: %s", strerror(err));
+ }
+}
+
+static void
+rb_mmtk_resume_mutators(bool current_gc_may_move)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ int err;
+ if ((err = pthread_mutex_lock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot lock objspace->mutex: %s", strerror(err));
+ }
+
+ objspace->world_stopped = false;
+ objspace->gc_count++;
+ if (current_gc_may_move) objspace->moving_gc_count++;
+ pthread_cond_broadcast(&objspace->cond_world_started);
+
+ if ((err = pthread_mutex_unlock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot release objspace->mutex: %s", strerror(err));
+ }
+}
+
+static void mmtk_flush_obj_free_buffer(struct MMTk_ractor_cache *cache);
+
+static void
+rb_mmtk_block_for_gc(MMTk_VMMutatorThread mutator)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ size_t starting_gc_count = objspace->gc_count;
+ RUBY_ATOMIC_INC(objspace->mutator_blocking_count);
+ int lock_lev = RB_GC_VM_LOCK();
+ RUBY_ATOMIC_DEC(objspace->mutator_blocking_count);
+ int err;
+ if ((err = pthread_mutex_lock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot lock objspace->mutex: %s", strerror(err));
+ }
+
+ if (objspace->gc_count == starting_gc_count) {
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_START);
+
+ rb_gc_initialize_vm_context(&objspace->vm_context);
+
+ mutator->gc_mutator_p = true;
+
+ struct timespec gc_start_time;
+ if (objspace->measure_gc_time) {
+ clock_gettime(CLOCK_MONOTONIC, &gc_start_time);
+ }
+
+ rb_gc_save_machine_context();
+
+ rb_gc_vm_barrier();
+
+ struct MMTk_ractor_cache *rc;
+ ccan_list_for_each(&objspace->ractor_caches, rc, list_node) {
+ mmtk_flush_obj_free_buffer(rc);
+ }
+
+ objspace->world_stopped = true;
+
+ pthread_cond_broadcast(&objspace->cond_world_stopped);
+
+ // Wait for GC end
+ while (objspace->world_stopped) {
+ pthread_cond_wait(&objspace->cond_world_started, &objspace->mutex);
+ }
+
+ if (RB_UNLIKELY(objspace->crash_context.gc_thread_crashed)) {
+ rb_bug("%s", objspace->crash_context.crash_msg);
+ }
+
+ if (objspace->measure_gc_time) {
+ struct timespec gc_end_time;
+ clock_gettime(CLOCK_MONOTONIC, &gc_end_time);
+
+ objspace->total_gc_time +=
+ (gc_end_time.tv_sec - gc_start_time.tv_sec) * (1000 * 1000 * 1000) +
+ (gc_end_time.tv_nsec - gc_start_time.tv_nsec);
+ }
+ }
+
+ if ((err = pthread_mutex_unlock(&objspace->mutex)) != 0) {
+ rb_bug("ERROR: cannot release objspace->mutex: %s", strerror(err));
+ }
+ RB_GC_VM_UNLOCK(lock_lev);
+}
+
+static void
+rb_mmtk_before_updating_jit_code(void)
+{
+ rb_gc_before_updating_jit_code();
+}
+
+static void
+rb_mmtk_after_updating_jit_code(void)
+{
+ rb_gc_after_updating_jit_code();
+}
+
+static size_t
+rb_mmtk_number_of_mutators(void)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+ return objspace->live_ractor_cache_count;
+}
+
+static void
+rb_mmtk_get_mutators(void (*visit_mutator)(MMTk_Mutator *mutator, void *data), void *data)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+ struct MMTk_ractor_cache *ractor_cache;
+
+ ccan_list_for_each(&objspace->ractor_caches, ractor_cache, list_node) {
+ visit_mutator(ractor_cache->mutator, data);
+ }
+}
+
+static void
+rb_mmtk_scan_gc_roots(void)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ rb_gc_mark_roots(objspace, NULL);
+}
+
+static int
+pin_value(st_data_t key, st_data_t value, st_data_t data)
+{
+ rb_gc_impl_mark_and_pin((void *)data, (VALUE)value);
+
+ return ST_CONTINUE;
+}
+
+static void
+rb_mmtk_scan_objspace(void)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ if (objspace->finalizer_table != NULL) {
+ st_foreach(objspace->finalizer_table, pin_value, (st_data_t)objspace);
+ }
+
+ struct MMTk_final_job *job = objspace->finalizer_jobs;
+ while (job != NULL) {
+ switch (job->kind) {
+ case MMTK_FINAL_JOB_DFREE:
+ break;
+ case MMTK_FINAL_JOB_FINALIZE:
+ rb_gc_impl_mark(objspace, job->as.finalize.finalizer_array);
+ break;
+ default:
+ rb_bug("rb_mmtk_scan_objspace: unknown final job type %d", job->kind);
+ }
+
+ job = job->next;
+ }
+}
+
+static void
+rb_mmtk_move_obj_during_marking(MMTk_ObjectReference from, MMTk_ObjectReference to)
+{
+ rb_gc_move_obj_during_marking((VALUE)from, (VALUE)to);
+}
+
+static void
+rb_mmtk_update_object_references(MMTk_ObjectReference mmtk_object)
+{
+ VALUE object = (VALUE)mmtk_object;
+
+ if (!RB_FL_TEST(object, RUBY_FL_WEAK_REFERENCE)) {
+ marking_parent_object = object;
+ rb_gc_update_object_references(rb_gc_get_objspace(), object);
+ marking_parent_object = 0;
+ }
+}
+
+static void
+rb_mmtk_call_gc_mark_children(MMTk_ObjectReference object)
+{
+ marking_parent_object = (VALUE)object;
+ rb_gc_mark_children(rb_gc_get_objspace(), (VALUE)object);
+ marking_parent_object = 0;
+}
+
+static void
+rb_mmtk_handle_weak_references(MMTk_ObjectReference mmtk_object, bool moving)
+{
+ VALUE object = (VALUE)mmtk_object;
+
+ marking_parent_object = object;
+
+ rb_gc_handle_weak_references(object);
+
+ if (moving) {
+ rb_gc_update_object_references(rb_gc_get_objspace(), object);
+ }
+
+ marking_parent_object = 0;
+}
+
+static void
+rb_mmtk_call_obj_free(MMTk_ObjectReference object)
+{
+ VALUE obj = (VALUE)object;
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ if (RB_UNLIKELY(rb_gc_event_hook_required_p(RUBY_INTERNAL_EVENT_FREEOBJ))) {
+ pthread_mutex_lock(&objspace->event_hook_mutex);
+ rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_FREEOBJ);
+ pthread_mutex_unlock(&objspace->event_hook_mutex);
+ }
+
+ rb_gc_obj_free(objspace, obj);
+
+#ifdef MMTK_DEBUG
+ memset((void *)obj, 0, rb_gc_impl_obj_slot_size(obj));
+#endif
+}
+
+static size_t
+rb_mmtk_vm_live_bytes(void)
+{
+ return 0;
+}
+
+static void
+make_final_job(struct objspace *objspace, VALUE obj, VALUE table)
+{
+ MMTK_ASSERT(RB_BUILTIN_TYPE(table) == T_ARRAY);
+
+ struct MMTk_final_job *job = xmalloc(sizeof(struct MMTk_final_job));
+ job->next = objspace->finalizer_jobs;
+ job->kind = MMTK_FINAL_JOB_FINALIZE;
+ job->as.finalize.finalizer_array = table;
+
+ objspace->finalizer_jobs = job;
+}
+
+static int
+rb_mmtk_update_finalizer_table_i(st_data_t key, st_data_t value, st_data_t data, int error)
+{
+ MMTK_ASSERT(mmtk_is_reachable((MMTk_ObjectReference)value));
+ MMTK_ASSERT(RB_BUILTIN_TYPE(value) == T_ARRAY);
+
+ struct objspace *objspace = (struct objspace *)data;
+
+ if (mmtk_is_reachable((MMTk_ObjectReference)key)) {
+ VALUE new_key_location = rb_mmtk_call_object_closure((VALUE)key, false);
+
+ MMTK_ASSERT(RB_FL_TEST(new_key_location, RUBY_FL_FINALIZE));
+
+ if (new_key_location != key) {
+ return ST_REPLACE;
+ }
+ }
+ else {
+ make_final_job(objspace, (VALUE)key, (VALUE)value);
+
+ rb_postponed_job_trigger(objspace->finalizer_postponed_job);
+
+ return ST_DELETE;
+ }
+
+ return ST_CONTINUE;
+}
+
+static int
+rb_mmtk_update_finalizer_table_replace_i(st_data_t *key, st_data_t *value, st_data_t data, int existing)
+{
+ *key = rb_mmtk_call_object_closure((VALUE)*key, false);
+
+ return ST_CONTINUE;
+}
+
+static void
+rb_mmtk_update_finalizer_table(void)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ st_foreach_with_replace(
+ objspace->finalizer_table,
+ rb_mmtk_update_finalizer_table_i,
+ rb_mmtk_update_finalizer_table_replace_i,
+ (st_data_t)objspace
+ );
+}
+
+static int
+rb_mmtk_global_tables_count(void)
+{
+ return RB_GC_VM_WEAK_TABLE_COUNT;
+}
+
+static inline VALUE rb_mmtk_call_object_closure(VALUE obj, bool pin);
+
+static int
+rb_mmtk_update_global_tables_i(VALUE val, void *data)
+{
+ if (!mmtk_is_reachable((MMTk_ObjectReference)val)) {
+ return ST_DELETE;
+ }
+
+ // TODO: check only if in moving GC
+ if (rb_mmtk_call_object_closure(val, false) != val) {
+ return ST_REPLACE;
+ }
+
+ return ST_CONTINUE;
+}
+
+static int
+rb_mmtk_update_global_tables_replace_i(VALUE *ptr, void *data)
+{
+ // TODO: cache the new location so we don't call rb_mmtk_call_object_closure twice
+ *ptr = rb_mmtk_call_object_closure(*ptr, false);
+
+ return ST_CONTINUE;
+}
+
+static void
+rb_mmtk_update_global_tables(int table, bool moving)
+{
+ MMTK_ASSERT(table < RB_GC_VM_WEAK_TABLE_COUNT);
+
+ rb_gc_vm_weak_table_foreach(
+ rb_mmtk_update_global_tables_i,
+ rb_mmtk_update_global_tables_replace_i,
+ NULL,
+ !moving,
+ (enum rb_gc_vm_weak_tables)table
+ );
+}
+
+static bool
+rb_mmtk_special_const_p(MMTk_ObjectReference object)
+{
+ VALUE obj = (VALUE)object;
+
+ return RB_SPECIAL_CONST_P(obj);
+}
+
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
+RBIMPL_ATTR_NORETURN()
+static void
+rb_mmtk_gc_thread_bug(const char *msg, ...)
+{
+ struct objspace *objspace = rb_gc_get_objspace();
+
+ objspace->crash_context.gc_thread_crashed = true;
+
+ va_list args;
+ va_start(args, msg);
+ vsnprintf(objspace->crash_context.crash_msg, sizeof(objspace->crash_context.crash_msg), msg, args);
+ va_end(args);
+
+ fprintf(stderr, "-- GC thread backtrace "
+ "-------------------------------------------\n");
+ rb_gc_print_backtrace();
+ fprintf(stderr, "\n");
+
+ rb_mmtk_resume_mutators(false);
+
+ sleep(5);
+
+ rb_bug("rb_mmtk_gc_thread_bug");
+}
+
+RBIMPL_ATTR_NORETURN()
+static void
+rb_mmtk_gc_thread_panic_handler(void)
+{
+ rb_mmtk_gc_thread_bug("MMTk GC thread panicked");
+}
+
+RBIMPL_ATTR_NORETURN()
+static void
+rb_mmtk_mutator_thread_panic_handler(void)
+{
+ rb_bug("Ruby mutator thread panicked");
+}
+
+// Bootup
+MMTk_RubyUpcalls ruby_upcalls = {
+ rb_mmtk_init_gc_worker_thread,
+ rb_mmtk_is_mutator,
+ rb_mmtk_stop_the_world,
+ rb_mmtk_resume_mutators,
+ rb_mmtk_block_for_gc,
+ rb_mmtk_before_updating_jit_code,
+ rb_mmtk_after_updating_jit_code,
+ rb_mmtk_number_of_mutators,
+ rb_mmtk_get_mutators,
+ rb_mmtk_scan_gc_roots,
+ rb_mmtk_scan_objspace,
+ rb_mmtk_move_obj_during_marking,
+ rb_mmtk_update_object_references,
+ rb_mmtk_call_gc_mark_children,
+ rb_mmtk_handle_weak_references,
+ rb_mmtk_call_obj_free,
+ rb_mmtk_vm_live_bytes,
+ rb_mmtk_update_global_tables,
+ rb_mmtk_global_tables_count,
+ rb_mmtk_update_finalizer_table,
+ rb_mmtk_special_const_p,
+ rb_mmtk_mutator_thread_panic_handler,
+ rb_mmtk_gc_thread_panic_handler,
+};
+
+// Use max 80% of the available memory by default for MMTk
+#define RB_MMTK_HEAP_LIMIT_PERC 80
+#define RB_MMTK_DEFAULT_HEAP_MIN (1024 * 1024)
+#define RB_MMTK_DEFAULT_HEAP_MAX (rb_mmtk_system_physical_memory() / 100 * RB_MMTK_HEAP_LIMIT_PERC)
+
+enum mmtk_heap_mode {
+ RB_MMTK_DYNAMIC_HEAP,
+ RB_MMTK_FIXED_HEAP
+};
+
+MMTk_Builder *
+rb_mmtk_builder_init(void)
+{
+ MMTk_Builder *builder = mmtk_builder_default();
+ return builder;
+}
+
+void *
+rb_gc_impl_objspace_alloc(void)
+{
+ MMTk_Builder *builder = rb_mmtk_builder_init();
+ MMTk_RubyBindingOptions binding_options = {
+ .suffix_size = RB_GC_OBJ_SUFFIX_SIZE,
+ };
+ mmtk_init_binding(builder, &binding_options, &ruby_upcalls);
+
+ return calloc(1, sizeof(struct objspace));
+}
+
+static void gc_run_finalizers(void *data);
+
+void
+rb_gc_impl_objspace_init(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ objspace->measure_gc_time = true;
+
+ objspace->finalizer_table = st_init_numtable();
+ objspace->finalizer_postponed_job = rb_postponed_job_preregister(0, gc_run_finalizers, objspace);
+
+ ccan_list_head_init(&objspace->ractor_caches);
+
+ objspace->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+ objspace->cond_world_stopped = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+ objspace->cond_world_started = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+
+ objspace->event_hook_mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+}
+
+void
+rb_gc_impl_objspace_free(void *objspace_ptr)
+{
+ free(objspace_ptr);
+}
+
+void *
+rb_gc_impl_ractor_cache_alloc(void *objspace_ptr, void *ractor)
+{
+ struct objspace *objspace = objspace_ptr;
+ if (objspace->live_ractor_cache_count == 0) {
+ mmtk_initialize_collection(ractor);
+ }
+ objspace->live_ractor_cache_count++;
+
+ struct MMTk_ractor_cache *cache = calloc(1, sizeof(struct MMTk_ractor_cache));
+ ccan_list_add(&objspace->ractor_caches, &cache->list_node);
+
+ cache->mutator = mmtk_bind_mutator(cache);
+ cache->bump_pointer = mmtk_get_bump_pointer_allocator(cache->mutator);
+
+ return cache;
+}
+
+void
+rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+ struct MMTk_ractor_cache *cache = cache_ptr;
+
+ ccan_list_del(&cache->list_node);
+
+ mmtk_flush_obj_free_buffer(cache);
+
+ if (ruby_free_at_exit_p()) {
+ MMTK_ASSERT(objspace->live_ractor_cache_count > 0);
+ }
+ else {
+ MMTK_ASSERT(objspace->live_ractor_cache_count > 1);
+ }
+
+ objspace->live_ractor_cache_count--;
+
+ mmtk_destroy_mutator(cache->mutator);
+}
+
+void rb_gc_impl_set_params(void *objspace_ptr) { }
+
+static VALUE gc_verify_internal_consistency(VALUE self) { return Qnil; }
+
+#if SIZEOF_VALUE >= 8
+#define MMTK_HEAP_COUNT 12
+#define MMTK_MAX_OBJ_SIZE 1024
+static size_t heap_sizes[MMTK_HEAP_COUNT + 1] = {
+ 32, 40, 64, 80, 96, 128, 160, 256, 512, 640, 768, MMTK_MAX_OBJ_SIZE, 0
+};
+#else
+#define MMTK_HEAP_COUNT 5
+#define MMTK_MAX_OBJ_SIZE 512
+static size_t heap_sizes[MMTK_HEAP_COUNT + 1] = {
+ 32, 64, 128, 256, MMTK_MAX_OBJ_SIZE, 0
+};
+#endif
+
+void
+rb_gc_impl_init(void)
+{
+ VALUE gc_constants = rb_hash_new();
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(SIZEOF_VALUE >= 8 ? 64 : 32));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), INT2NUM(0));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(MMTK_MAX_OBJ_SIZE));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_COUNT")), LONG2FIX(MMTK_HEAP_COUNT));
+ // TODO: correctly set RVALUE_OLD_AGE when we have generational GC support
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OLD_AGE")), INT2FIX(0));
+ OBJ_FREEZE(gc_constants);
+ rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
+
+ // no-ops for compatibility
+ rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency, 0);
+
+ rb_define_singleton_method(rb_mGC, "compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact=", rb_f_notimplement, 1);
+ rb_define_singleton_method(rb_mGC, "latest_compact_info", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
+}
+
+size_t *
+rb_gc_impl_heap_sizes(void *objspace_ptr)
+{
+ return heap_sizes;
+}
+
+int
+rb_mmtk_obj_free_iter_wrapper(VALUE obj, void *data)
+{
+ struct objspace *objspace = data;
+
+ if (!RB_TYPE_P(obj, T_NONE)) {
+ rb_gc_obj_free_vm_weak_references(obj);
+ rb_gc_obj_free(objspace, obj);
+ }
+
+ return 0;
+}
+
+// Shutdown
+static void each_object(struct objspace *objspace, int (*func)(VALUE, void *), void *data);
+
+void
+rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
+{
+ mmtk_set_gc_enabled(false);
+ each_object(objspace_ptr, rb_mmtk_obj_free_iter_wrapper, objspace_ptr);
+ mmtk_set_gc_enabled(true);
+}
+
+// GC
+void
+rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact)
+{
+ mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache(), true, full_mark);
+}
+
+bool
+rb_gc_impl_during_gc_p(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+ return objspace->world_stopped;
+}
+
+static void
+rb_gc_impl_prepare_heap_i(MMTk_ObjectReference obj, void *d)
+{
+ rb_gc_prepare_heap_process_object((VALUE)obj);
+}
+
+void
+rb_gc_impl_prepare_heap(void *objspace_ptr)
+{
+ mmtk_enumerate_objects(rb_gc_impl_prepare_heap_i, NULL);
+}
+
+void
+rb_gc_impl_gc_enable(void *objspace_ptr)
+{
+ mmtk_set_gc_enabled(true);
+}
+
+void
+rb_gc_impl_gc_disable(void *objspace_ptr, bool finish_current_gc)
+{
+ mmtk_set_gc_enabled(false);
+}
+
+bool
+rb_gc_impl_gc_enabled_p(void *objspace_ptr)
+{
+ return mmtk_gc_enabled_p();
+}
+
+void
+rb_gc_impl_stress_set(void *objspace_ptr, VALUE flag)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ objspace->gc_stress = RTEST(flag);
+}
+
+VALUE
+rb_gc_impl_stress_get(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ return objspace->gc_stress ? Qtrue : Qfalse;
+}
+
+VALUE
+rb_gc_impl_config_get(void *objspace_ptr)
+{
+ VALUE hash = rb_hash_new();
+
+ rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_worker_count")), RB_ULONG2NUM(mmtk_worker_count()));
+ rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_plan")), rb_str_new_cstr((const char *)mmtk_plan()));
+ rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_heap_mode")), rb_str_new_cstr((const char *)mmtk_heap_mode()));
+ size_t heap_min = mmtk_heap_min();
+ if (heap_min > 0) rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_heap_min")), RB_ULONG2NUM(heap_min));
+ rb_hash_aset(hash, ID2SYM(rb_intern_const("mmtk_heap_max")), RB_ULONG2NUM(mmtk_heap_max()));
+
+ return hash;
+}
+
+void
+rb_gc_impl_config_set(void *objspace_ptr, VALUE hash)
+{
+ // TODO
+}
+
+struct rb_gc_vm_context *
+rb_gc_impl_get_vm_context(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ return &objspace->vm_context;
+}
+
+// Object allocation
+
+static VALUE
+rb_mmtk_alloc_fast_path(struct objspace *objspace, struct MMTk_ractor_cache *ractor_cache, size_t size, size_t align)
+{
+ MMTk_BumpPointer *bump_pointer = ractor_cache->bump_pointer;
+ if (bump_pointer == NULL) return 0;
+
+ uintptr_t cursor = bump_pointer->cursor;
+
+ // Ensure cursor is aligned
+ size_t mask = align - 1;
+ cursor = (cursor + mask) & ~mask;
+
+ cursor += size;
+
+ if (cursor > bump_pointer->limit) {
+ return 0;
+ }
+ else {
+ VALUE obj = cursor - size;
+ bump_pointer->cursor = cursor;
+ return obj;
+ }
+}
+
+static bool
+obj_can_parallel_free_p(VALUE obj)
+{
+ switch (RB_BUILTIN_TYPE(obj)) {
+ case T_ARRAY:
+ case T_BIGNUM:
+ case T_COMPLEX:
+ case T_FLOAT:
+ case T_HASH:
+ case T_OBJECT:
+ case T_RATIONAL:
+ case T_REGEXP:
+ case T_STRING:
+ case T_STRUCT:
+ case T_SYMBOL:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static void
+mmtk_flush_obj_free_buffer(struct MMTk_ractor_cache *cache)
+{
+ if (cache->obj_free_parallel_count > 0) {
+ mmtk_add_obj_free_candidates(cache->obj_free_parallel_buf,
+ cache->obj_free_parallel_count, true);
+ cache->obj_free_parallel_count = 0;
+ }
+ if (cache->obj_free_non_parallel_count > 0) {
+ mmtk_add_obj_free_candidates(cache->obj_free_non_parallel_buf,
+ cache->obj_free_non_parallel_count, false);
+ cache->obj_free_non_parallel_count = 0;
+ }
+}
+
+static inline void
+mmtk_buffer_obj_free_candidate(struct MMTk_ractor_cache *cache, VALUE obj)
+{
+ if (obj_can_parallel_free_p(obj)) {
+ cache->obj_free_parallel_buf[cache->obj_free_parallel_count++] = (MMTk_ObjectReference)obj;
+ if (cache->obj_free_parallel_count >= OBJ_FREE_BUF_CAPACITY) {
+ mmtk_add_obj_free_candidates(cache->obj_free_parallel_buf,
+ cache->obj_free_parallel_count, true);
+ cache->obj_free_parallel_count = 0;
+ }
+ }
+ else {
+ cache->obj_free_non_parallel_buf[cache->obj_free_non_parallel_count++] = (MMTk_ObjectReference)obj;
+ if (cache->obj_free_non_parallel_count >= OBJ_FREE_BUF_CAPACITY) {
+ mmtk_add_obj_free_candidates(cache->obj_free_non_parallel_buf,
+ cache->obj_free_non_parallel_count, false);
+ cache->obj_free_non_parallel_count = 0;
+ }
+ }
+}
+
+VALUE
+rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags, bool wb_protected, size_t alloc_size)
+{
+#define MMTK_ALLOCATION_SEMANTICS_DEFAULT 0
+ struct objspace *objspace = objspace_ptr;
+ struct MMTk_ractor_cache *ractor_cache = cache_ptr;
+
+ if (alloc_size > MMTK_MAX_OBJ_SIZE) rb_bug("too big");
+ for (int i = 0; i < MMTK_HEAP_COUNT; i++) {
+ if (alloc_size == heap_sizes[i]) break;
+ if (alloc_size < heap_sizes[i]) {
+ alloc_size = heap_sizes[i];
+ break;
+ }
+ }
+
+ if (objspace->gc_stress) {
+ mmtk_handle_user_collection_request(ractor_cache, false, false);
+ }
+
+ // Layout: [hidden size header (sizeof(VALUE))][payload (alloc_size)][suffix (RB_GC_OBJ_SUFFIX_SIZE)]
+ alloc_size += sizeof(VALUE) + RB_GC_OBJ_SUFFIX_SIZE;
+
+ VALUE *alloc_obj = (VALUE *)rb_mmtk_alloc_fast_path(objspace, ractor_cache, alloc_size, MMTk_MIN_OBJ_ALIGN);
+ if (!alloc_obj) {
+ alloc_obj = mmtk_alloc(ractor_cache->mutator, alloc_size, MMTk_MIN_OBJ_ALIGN, 0, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
+ }
+
+ alloc_obj++;
+ alloc_obj[-1] = alloc_size - sizeof(VALUE) - RB_GC_OBJ_SUFFIX_SIZE;
+ alloc_obj[0] = flags;
+ alloc_obj[1] = klass;
+
+ // TODO: implement fast path for mmtk_post_alloc
+ mmtk_post_alloc(ractor_cache->mutator, (void*)alloc_obj, alloc_size, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
+
+ // TODO: only add when object needs obj_free to be called
+ mmtk_buffer_obj_free_candidate(ractor_cache, (VALUE)alloc_obj);
+
+ objspace->total_allocated_objects++;
+
+ return (VALUE)alloc_obj;
+}
+
+size_t
+rb_gc_impl_obj_slot_size(VALUE obj)
+{
+ return ((VALUE *)obj)[-1];
+}
+
+size_t
+rb_gc_impl_heap_id_for_size(void *objspace_ptr, size_t size)
+{
+ for (int i = 0; i < MMTK_HEAP_COUNT; i++) {
+ if (size == heap_sizes[i]) return i;
+ if (size < heap_sizes[i]) return i;
+ }
+
+ rb_bug("size too big");
+}
+
+bool
+rb_gc_impl_size_allocatable_p(size_t size)
+{
+ return size <= MMTK_MAX_OBJ_SIZE;
+}
+
+// Malloc
+void *
+rb_gc_impl_malloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ // TODO: don't use system malloc
+ return malloc(size);
+}
+
+void *
+rb_gc_impl_calloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ // TODO: don't use system calloc
+ return calloc(1, size);
+}
+
+void *
+rb_gc_impl_realloc(void *objspace_ptr, void *ptr, size_t new_size, size_t old_size, bool gc_allowed)
+{
+ // TODO: don't use system realloc
+ return realloc(ptr, new_size);
+}
+
+void
+rb_gc_impl_free(void *objspace_ptr, void *ptr, size_t old_size)
+{
+ // TODO: don't use system free
+ free(ptr);
+}
+
+void rb_gc_impl_adjust_memory_usage(void *objspace_ptr, ssize_t diff) { }
+
+// Marking
+static inline VALUE
+rb_mmtk_call_object_closure(VALUE obj, bool pin)
+{
+ if (RB_UNLIKELY(RB_BUILTIN_TYPE(obj) == T_NONE)) {
+ enum { info_size = 256 };
+ char obj_info_buf[info_size];
+ rb_raw_obj_info(obj_info_buf, info_size, obj);
+
+ char parent_obj_info_buf[info_size];
+ rb_raw_obj_info(parent_obj_info_buf, info_size, marking_parent_object);
+
+ rb_mmtk_gc_thread_bug("try to mark T_NONE object (obj: %s, parent: %s)", obj_info_buf, parent_obj_info_buf);
+ }
+
+ return (VALUE)rb_mmtk_gc_thread_tls->object_closure.c_function(
+ rb_mmtk_gc_thread_tls->object_closure.rust_closure,
+ rb_mmtk_gc_thread_tls->gc_context,
+ (MMTk_ObjectReference)obj,
+ pin
+ );
+}
+
+void
+rb_gc_impl_mark(void *objspace_ptr, VALUE obj)
+{
+ if (RB_SPECIAL_CONST_P(obj)) return;
+
+ rb_mmtk_call_object_closure(obj, false);
+}
+
+void
+rb_gc_impl_mark_and_move(void *objspace_ptr, VALUE *ptr)
+{
+ if (RB_SPECIAL_CONST_P(*ptr)) return;
+
+ VALUE new_obj = rb_mmtk_call_object_closure(*ptr, false);
+ if (new_obj != *ptr) {
+ *ptr = new_obj;
+ }
+}
+
+void
+rb_gc_impl_mark_and_pin(void *objspace_ptr, VALUE obj)
+{
+ if (RB_SPECIAL_CONST_P(obj)) return;
+
+ rb_mmtk_call_object_closure(obj, true);
+}
+
+void
+rb_gc_impl_mark_maybe(void *objspace_ptr, VALUE obj)
+{
+ if (rb_gc_impl_pointer_to_heap_p(objspace_ptr, (const void *)obj)) {
+ rb_gc_impl_mark_and_pin(objspace_ptr, obj);
+ }
+}
+
+void
+rb_gc_impl_declare_weak_references(void *objspace_ptr, VALUE obj)
+{
+ RB_FL_SET(obj, RUBY_FL_WEAK_REFERENCE);
+ mmtk_declare_weak_references((MMTk_ObjectReference)obj);
+}
+
+bool
+rb_gc_impl_handle_weak_references_alive_p(void *objspace_ptr, VALUE obj)
+{
+ return mmtk_weak_references_alive_p((MMTk_ObjectReference)obj);
+}
+
+// Compaction
+void
+rb_gc_impl_register_pinning_obj(void *objspace_ptr, VALUE obj)
+{
+ mmtk_register_pinning_obj((MMTk_ObjectReference)obj);
+}
+
+bool
+rb_gc_impl_object_moved_p(void *objspace_ptr, VALUE obj)
+{
+ return rb_mmtk_call_object_closure(obj, false) != obj;
+}
+
+VALUE
+rb_gc_impl_location(void *objspace_ptr, VALUE obj)
+{
+ return rb_mmtk_call_object_closure(obj, false);
+}
+
+// Write barriers
+void
+rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
+{
+ struct MMTk_ractor_cache *cache = rb_gc_get_ractor_newobj_cache();
+
+ if (SPECIAL_CONST_P(b)) return;
+
+#ifdef MMTK_DEBUG
+ if (!rb_gc_impl_pointer_to_heap_p(objspace_ptr, (void *)a)) {
+ char buff[256];
+ rb_bug("a: %s is not an object", rb_raw_obj_info(buff, 256, a));
+ }
+
+ if (!rb_gc_impl_pointer_to_heap_p(objspace_ptr, (void *)b)) {
+ char buff[256];
+ rb_bug("b: %s is not an object", rb_raw_obj_info(buff, 256, b));
+ }
+#endif
+
+ MMTK_ASSERT(BUILTIN_TYPE(a) != T_NONE);
+ MMTK_ASSERT(BUILTIN_TYPE(b) != T_NONE);
+
+ mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)a);
+}
+
+void
+rb_gc_impl_writebarrier_unprotect(void *objspace_ptr, VALUE obj)
+{
+ mmtk_register_wb_unprotected_object((MMTk_ObjectReference)obj);
+}
+
+void
+rb_gc_impl_writebarrier_remember(void *objspace_ptr, VALUE obj)
+{
+ struct MMTk_ractor_cache *cache = rb_gc_get_ractor_newobj_cache();
+
+ mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)obj);
+}
+
+// Heap walking
+static void
+each_objects_i(MMTk_ObjectReference obj, void *d)
+{
+ rb_darray(VALUE) *objs = d;
+
+ rb_darray_append(objs, (VALUE)obj);
+}
+
+static void
+each_object(struct objspace *objspace, int (*func)(VALUE, void *), void *data)
+{
+ rb_darray(VALUE) objs;
+ rb_darray_make(&objs, 0);
+
+ mmtk_enumerate_objects(each_objects_i, &objs);
+
+ VALUE *obj_ptr;
+ rb_darray_foreach(objs, i, obj_ptr) {
+ if (!mmtk_is_mmtk_object((MMTk_ObjectReference)*obj_ptr)) continue;
+
+ if (func(*obj_ptr, data) != 0) {
+ break;
+ }
+ }
+
+ rb_darray_free(objs);
+}
+
+struct rb_gc_impl_each_objects_data {
+ int (*func)(void *, void *, size_t, void *);
+ void *data;
+};
+
+static int
+rb_gc_impl_each_objects_i(VALUE obj, void *d)
+{
+ struct rb_gc_impl_each_objects_data *data = d;
+
+ size_t slot_size = rb_gc_impl_obj_slot_size(obj);
+
+ return data->func((void *)obj, (void *)(obj + slot_size), slot_size, data->data);
+}
+
+void
+rb_gc_impl_each_objects(void *objspace_ptr, int (*func)(void *, void *, size_t, void *), void *data)
+{
+ struct rb_gc_impl_each_objects_data each_objects_data = {
+ .func = func,
+ .data = data
+ };
+
+ each_object(objspace_ptr, rb_gc_impl_each_objects_i, &each_objects_data);
+}
+
+struct rb_gc_impl_each_object_data {
+ void (*func)(VALUE, void *);
+ void *data;
+};
+
+static int
+rb_gc_impl_each_object_i(VALUE obj, void *d)
+{
+ struct rb_gc_impl_each_object_data *data = d;
+
+ data->func(obj, data->data);
+
+ return 0;
+}
+
+void
+rb_gc_impl_each_object(void *objspace_ptr, void (*func)(VALUE, void *), void *data)
+{
+ struct rb_gc_impl_each_object_data each_object_data = {
+ .func = func,
+ .data = data
+ };
+
+ each_object(objspace_ptr, rb_gc_impl_each_object_i, &each_object_data);
+}
+
+// Finalizers
+static VALUE
+gc_run_finalizers_get_final(long i, void *data)
+{
+ VALUE table = (VALUE)data;
+
+ return RARRAY_AREF(table, i + 1);
+}
+
+static void
+gc_run_finalizers(void *data)
+{
+ struct objspace *objspace = data;
+
+ rb_gc_set_pending_interrupt();
+
+ while (objspace->finalizer_jobs != NULL) {
+ struct MMTk_final_job *job = objspace->finalizer_jobs;
+ objspace->finalizer_jobs = job->next;
+
+ switch (job->kind) {
+ case MMTK_FINAL_JOB_DFREE:
+ job->as.dfree.func(job->as.dfree.data);
+ break;
+ case MMTK_FINAL_JOB_FINALIZE: {
+ VALUE finalizer_array = job->as.finalize.finalizer_array;
+
+ rb_gc_run_obj_finalizer(
+ RARRAY_AREF(finalizer_array, 0),
+ RARRAY_LEN(finalizer_array) - 1,
+ gc_run_finalizers_get_final,
+ (void *)finalizer_array
+ );
+
+ RB_GC_GUARD(finalizer_array);
+ break;
+ }
+ }
+
+ xfree(job);
+ }
+
+ rb_gc_unset_pending_interrupt();
+}
+
+void
+rb_gc_impl_make_zombie(void *objspace_ptr, VALUE obj, void (*dfree)(void *), void *data)
+{
+ if (dfree == NULL) return;
+
+ struct objspace *objspace = objspace_ptr;
+
+ struct MMTk_final_job *job = xmalloc(sizeof(struct MMTk_final_job));
+ job->kind = MMTK_FINAL_JOB_DFREE;
+ job->as.dfree.func = dfree;
+ job->as.dfree.data = data;
+
+ struct MMTk_final_job *prev;
+ do {
+ job->next = objspace->finalizer_jobs;
+ prev = RUBY_ATOMIC_PTR_CAS(objspace->finalizer_jobs, job->next, job);
+ } while (prev != job->next);
+
+ if (!ruby_free_at_exit_p()) {
+ rb_postponed_job_trigger(objspace->finalizer_postponed_job);
+ }
+}
+
+VALUE
+rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block)
+{
+ struct objspace *objspace = objspace_ptr;
+ VALUE table;
+ st_data_t data;
+
+ RBASIC(obj)->flags |= FL_FINALIZE;
+
+ int lev = RB_GC_VM_LOCK();
+
+ if (st_lookup(objspace->finalizer_table, obj, &data)) {
+ table = (VALUE)data;
+
+ /* avoid duplicate block, table is usually small */
+ {
+ long len = RARRAY_LEN(table);
+ long i;
+
+ for (i = 0; i < len; i++) {
+ VALUE recv = RARRAY_AREF(table, i);
+ if (rb_equal(recv, block)) {
+ RB_GC_VM_UNLOCK(lev);
+ return recv;
+ }
+ }
+ }
+
+ rb_ary_push(table, block);
+ }
+ else {
+ table = rb_ary_new3(2, rb_obj_id(obj), block);
+ rb_obj_hide(table);
+ st_add_direct(objspace->finalizer_table, obj, table);
+ }
+
+ RB_GC_VM_UNLOCK(lev);
+
+ return block;
+}
+
+void
+rb_gc_impl_undefine_finalizer(void *objspace_ptr, VALUE obj)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ st_data_t data = obj;
+
+ int lev = RB_GC_VM_LOCK();
+ st_delete(objspace->finalizer_table, &data, 0);
+ RB_GC_VM_UNLOCK(lev);
+
+ FL_UNSET(obj, FL_FINALIZE);
+}
+
+void
+rb_gc_impl_copy_finalizer(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ struct objspace *objspace = objspace_ptr;
+ VALUE table;
+ st_data_t data;
+
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+
+ int lev = RB_GC_VM_LOCK();
+ if (RB_LIKELY(st_lookup(objspace->finalizer_table, obj, &data))) {
+ table = rb_ary_dup((VALUE)data);
+ RARRAY_ASET(table, 0, rb_obj_id(dest));
+ st_insert(objspace->finalizer_table, dest, table);
+ FL_SET(dest, FL_FINALIZE);
+ }
+ else {
+ rb_bug("rb_gc_copy_finalizer: FL_FINALIZE set but not found in finalizer_table: %s", rb_obj_info(obj));
+ }
+ RB_GC_VM_UNLOCK(lev);
+}
+
+static int
+move_finalizer_from_table_i(st_data_t key, st_data_t val, st_data_t arg)
+{
+ struct objspace *objspace = (struct objspace *)arg;
+
+ make_final_job(objspace, (VALUE)key, (VALUE)val);
+
+ return ST_DELETE;
+}
+
+void
+rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ while (objspace->finalizer_table->num_entries) {
+ st_foreach(objspace->finalizer_table, move_finalizer_from_table_i, (st_data_t)objspace);
+
+ gc_run_finalizers(objspace);
+ }
+
+ unsigned int lev = RB_GC_VM_LOCK();
+ {
+ struct MMTk_ractor_cache *rc;
+ ccan_list_for_each(&objspace->ractor_caches, rc, list_node) {
+ mmtk_flush_obj_free_buffer(rc);
+ }
+
+ struct MMTk_RawVecOfObjRef registered_candidates = mmtk_get_all_obj_free_candidates();
+ for (size_t i = 0; i < registered_candidates.len; i++) {
+ VALUE obj = (VALUE)registered_candidates.ptr[i];
+
+ if (rb_gc_shutdown_call_finalizer_p(obj)) {
+ rb_gc_obj_free(objspace_ptr, obj);
+ RBASIC(obj)->flags = 0;
+ }
+ }
+ mmtk_free_raw_vec_of_obj_ref(registered_candidates);
+ }
+ RB_GC_VM_UNLOCK(lev);
+
+ gc_run_finalizers(objspace);
+}
+
+// Forking
+
+void
+rb_gc_impl_before_fork(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ retry:
+ objspace->fork_hook_vm_lock_lev = RB_GC_VM_LOCK();
+ rb_gc_vm_barrier();
+
+ /* At this point, we know that all the Ractors are paused because of the
+ * rb_gc_vm_barrier above. Since rb_mmtk_block_for_gc is a barrier point,
+ * one or more Ractors could be paused there. However, mmtk_before_fork is
+ * not compatible with that because it assumes that the MMTk workers are idle,
+ * but the workers are not idle because they are busy working on a GC.
+ *
+ * This essentially implements a trylock. It will optimistically lock but will
+ * release the lock if it detects that any other Ractors are waiting in
+ * rb_mmtk_block_for_gc.
+ */
+ rb_atomic_t mutator_blocking_count = RUBY_ATOMIC_LOAD(objspace->mutator_blocking_count);
+ if (mutator_blocking_count != 0) {
+ RB_GC_VM_UNLOCK(objspace->fork_hook_vm_lock_lev);
+ goto retry;
+ }
+
+ mmtk_before_fork();
+}
+
+void
+rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ mmtk_after_fork(rb_gc_get_ractor_newobj_cache());
+
+ RB_GC_VM_UNLOCK(objspace->fork_hook_vm_lock_lev);
+}
+
+// Statistics
+
+void
+rb_gc_impl_set_measure_total_time(void *objspace_ptr, VALUE flag)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ objspace->measure_gc_time = RTEST(flag);
+}
+
+bool
+rb_gc_impl_get_measure_total_time(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ return objspace->measure_gc_time;
+}
+
+unsigned long long
+rb_gc_impl_get_total_time(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ return objspace->total_gc_time;
+}
+
+size_t
+rb_gc_impl_gc_count(void *objspace_ptr)
+{
+ struct objspace *objspace = objspace_ptr;
+
+ return objspace->gc_count;
+}
+
+VALUE
+rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE hash_or_key)
+{
+ VALUE hash = Qnil, key = Qnil;
+
+ if (SYMBOL_P(hash_or_key)) {
+ key = hash_or_key;
+ }
+ else if (RB_TYPE_P(hash_or_key, T_HASH)) {
+ hash = hash_or_key;
+ }
+ else {
+ rb_bug("gc_info_decode: non-hash or symbol given");
+ }
+
+#define SET(name, attr) \
+ if (key == ID2SYM(rb_intern_const(#name))) \
+ return (attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, ID2SYM(rb_intern_const(#name)), (attr));
+
+ /* Hack to get StackProf working because it calls rb_gc_latest_gc_info with
+ * the :state key and expects a result. This always returns the :none state. */
+ SET(state, ID2SYM(rb_intern_const("none")));
+#undef SET
+
+ if (!NIL_P(key)) {
+ // Matched key should return above
+ return Qundef;
+ }
+
+ return hash;
+}
+
+enum gc_stat_sym {
+ gc_stat_sym_count,
+ gc_stat_sym_moving_gc_count,
+ gc_stat_sym_time,
+ gc_stat_sym_total_allocated_objects,
+ gc_stat_sym_total_bytes,
+ gc_stat_sym_used_bytes,
+ gc_stat_sym_free_bytes,
+ gc_stat_sym_starting_heap_address,
+ gc_stat_sym_last_heap_address,
+ gc_stat_sym_weak_references_count,
+ gc_stat_sym_last
+};
+
+static VALUE gc_stat_symbols[gc_stat_sym_last];
+
+static void
+setup_gc_stat_symbols(void)
+{
+ if (gc_stat_symbols[0] == 0) {
+#define S(s) gc_stat_symbols[gc_stat_sym_##s] = ID2SYM(rb_intern_const(#s))
+ S(count);
+ S(moving_gc_count);
+ S(time);
+ S(total_allocated_objects);
+ S(total_bytes);
+ S(used_bytes);
+ S(free_bytes);
+ S(starting_heap_address);
+ S(last_heap_address);
+ S(weak_references_count);
+ }
+}
+
+VALUE
+rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
+{
+ struct objspace *objspace = objspace_ptr;
+ VALUE hash = Qnil, key = Qnil;
+
+ setup_gc_stat_symbols();
+
+ if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ hash = hash_or_sym;
+ }
+ else if (SYMBOL_P(hash_or_sym)) {
+ key = hash_or_sym;
+ }
+ else {
+ rb_bug("non-hash or symbol given");
+ }
+
+#define SET(name, attr) \
+ if (key == gc_stat_symbols[gc_stat_sym_##name]) \
+ return SIZET2NUM(attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
+
+ SET(count, objspace->gc_count);
+ SET(moving_gc_count, objspace->moving_gc_count);
+ SET(time, objspace->total_gc_time / (1000 * 1000));
+ SET(total_allocated_objects, objspace->total_allocated_objects);
+ SET(total_bytes, mmtk_total_bytes());
+ SET(used_bytes, mmtk_used_bytes());
+ SET(free_bytes, mmtk_free_bytes());
+ SET(starting_heap_address, (size_t)mmtk_starting_heap_address());
+ SET(last_heap_address, (size_t)mmtk_last_heap_address());
+ SET(weak_references_count, mmtk_weak_references_count());
+#undef SET
+
+ if (!NIL_P(key)) {
+ // Matched key should return above
+ return Qundef;
+ }
+
+ return hash;
+}
+
+VALUE
+rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
+{
+ if (FIXNUM_P(heap_name) && SYMBOL_P(hash_or_sym)) {
+ int heap_idx = FIX2INT(heap_name);
+ if (heap_idx < 0 || heap_idx >= MMTK_HEAP_COUNT) {
+ rb_raise(rb_eArgError, "size pool index out of range");
+ }
+
+ if (hash_or_sym == ID2SYM(rb_intern("slot_size"))) {
+ return SIZET2NUM(heap_sizes[heap_idx]);
+ }
+
+ return Qundef;
+ }
+
+ if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ return hash_or_sym;
+ }
+
+ return Qundef;
+}
+
+// Miscellaneous
+
+#define RB_GC_OBJECT_METADATA_ENTRY_COUNT 1
+static struct rb_gc_object_metadata_entry object_metadata_entries[RB_GC_OBJECT_METADATA_ENTRY_COUNT + 1];
+
+struct rb_gc_object_metadata_entry *
+rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
+{
+ static ID ID_object_id;
+
+ if (!ID_object_id) {
+#define I(s) ID_##s = rb_intern(#s);
+ I(object_id);
+#undef I
+ }
+
+ size_t n = 0;
+
+#define SET_ENTRY(na, v) do { \
+ MMTK_ASSERT(n <= RB_GC_OBJECT_METADATA_ENTRY_COUNT); \
+ object_metadata_entries[n].name = ID_##na; \
+ object_metadata_entries[n].val = v; \
+ n++; \
+} while (0)
+
+ if (rb_obj_id_p(obj)) SET_ENTRY(object_id, rb_obj_id(obj));
+
+ object_metadata_entries[n].name = 0;
+ object_metadata_entries[n].val = 0;
+
+ return object_metadata_entries;
+}
+
+bool
+rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr)
+{
+ if (ptr == NULL) return false;
+ if ((uintptr_t)ptr % sizeof(void*) != 0) return false;
+ return mmtk_is_mmtk_object((MMTk_Address)ptr);
+}
+
+bool
+rb_gc_impl_garbage_object_p(void *objspace_ptr, VALUE obj)
+{
+ return false;
+}
+
+void rb_gc_impl_set_event_hook(void *objspace_ptr, const rb_event_flag_t event) { }
+
+void
+rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ if (mmtk_object_wb_unprotected_p((MMTk_ObjectReference)obj)) {
+ rb_gc_impl_writebarrier_unprotect(objspace_ptr, dest);
+ }
+
+ rb_gc_impl_copy_finalizer(objspace_ptr, dest, obj);
+}
+
+// GC Identification
+
+const char *
+rb_gc_impl_active_gc_name(void)
+{
+ return "mmtk";
+}
diff --git a/gc/mmtk/mmtk.h b/gc/mmtk/mmtk.h
new file mode 100644
index 0000000000..b11e2873e3
--- /dev/null
+++ b/gc/mmtk/mmtk.h
@@ -0,0 +1,175 @@
+#ifndef MMTK_H
+#define MMTK_H
+
+/* Warning, this file is autogenerated by cbindgen from the mmtk-ruby repository. Don't modify this manually. */
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+typedef struct MMTk_Builder MMTk_Builder;
+typedef struct MMTk_Mutator MMTk_Mutator;
+
+typedef struct MMTk_ractor_cache *MMTk_VMThread;
+typedef struct MMTk_ractor_cache *MMTk_VMMutatorThread;
+typedef struct MMTk_GCThreadTLS *MMTk_VMWorkerThread;
+typedef void *MMTk_Address;
+typedef void *MMTk_ObjectReference;
+typedef void *MMTk_NullableObjectReference;
+typedef uint32_t MMTk_AllocationSemantics;
+
+typedef struct MMTk_BumpPointer {
+ uintptr_t cursor;
+ uintptr_t limit;
+} MMTk_BumpPointer;
+
+
+#define MMTk_OBJREF_OFFSET 8
+
+#define MMTk_MIN_OBJ_ALIGN 8
+
+#define MMTk_GC_THREAD_KIND_WORKER 1
+
+typedef struct MMTk_RubyBindingOptions {
+ size_t suffix_size;
+} MMTk_RubyBindingOptions;
+
+typedef MMTk_ObjectReference (*MMTk_ObjectClosureFunction)(void*, void*, MMTk_ObjectReference, bool);
+
+typedef struct MMTk_ObjectClosure {
+ /**
+ * The function to be called from C.
+ */
+ MMTk_ObjectClosureFunction c_function;
+ /**
+ * The pointer to the Rust-level closure object.
+ */
+ void *rust_closure;
+} MMTk_ObjectClosure;
+
+typedef struct MMTk_GCThreadTLS {
+ int kind;
+ void *gc_context;
+ struct MMTk_ObjectClosure object_closure;
+} MMTk_GCThreadTLS;
+
+typedef struct MMTk_RubyUpcalls {
+ void (*init_gc_worker_thread)(struct MMTk_GCThreadTLS *gc_worker_tls);
+ bool (*is_mutator)(void);
+ void (*stop_the_world)(void);
+ void (*resume_mutators)(bool gc_may_move);
+ void (*block_for_gc)(MMTk_VMMutatorThread tls);
+ void (*before_updating_jit_code)(void);
+ void (*after_updating_jit_code)(void);
+ size_t (*number_of_mutators)(void);
+ void (*get_mutators)(void (*visit_mutator)(MMTk_Mutator*, void*), void *data);
+ void (*scan_gc_roots)(void);
+ void (*scan_objspace)(void);
+ void (*move_obj_during_marking)(MMTk_ObjectReference from, MMTk_ObjectReference to);
+ void (*update_object_references)(MMTk_ObjectReference object);
+ void (*call_gc_mark_children)(MMTk_ObjectReference object);
+ void (*handle_weak_references)(MMTk_ObjectReference object, bool moving);
+ void (*call_obj_free)(MMTk_ObjectReference object);
+ size_t (*vm_live_bytes)(void);
+ void (*update_global_tables)(int tbl_idx, bool moving);
+ int (*global_tables_count)(void);
+ void (*update_finalizer_table)(void);
+ bool (*special_const_p)(MMTk_ObjectReference object);
+ void (*mutator_thread_panic_handler)(void);
+ void (*gc_thread_panic_handler)(void);
+} MMTk_RubyUpcalls;
+
+typedef struct MMTk_RawVecOfObjRef {
+ MMTk_ObjectReference *ptr;
+ size_t len;
+ size_t capa;
+} MMTk_RawVecOfObjRef;
+
+bool mmtk_is_live_object(MMTk_ObjectReference object);
+
+bool mmtk_is_reachable(MMTk_ObjectReference object);
+
+MMTk_Builder *mmtk_builder_default(void);
+
+void mmtk_init_binding(MMTk_Builder *builder,
+ const struct MMTk_RubyBindingOptions *binding_options,
+ const struct MMTk_RubyUpcalls *upcalls);
+
+void mmtk_initialize_collection(MMTk_VMThread tls);
+
+MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
+
+MMTk_BumpPointer *mmtk_get_bump_pointer_allocator(MMTk_Mutator *m);
+
+void mmtk_destroy_mutator(MMTk_Mutator *mutator);
+
+void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls, bool force, bool exhaustive);
+
+void mmtk_set_gc_enabled(bool enable);
+
+bool mmtk_gc_enabled_p(void);
+
+MMTk_Address mmtk_alloc(MMTk_Mutator *mutator,
+ size_t size,
+ size_t align,
+ size_t offset,
+ MMTk_AllocationSemantics semantics);
+
+void mmtk_post_alloc(MMTk_Mutator *mutator,
+ MMTk_ObjectReference refer,
+ size_t bytes,
+ MMTk_AllocationSemantics semantics);
+
+void mmtk_add_obj_free_candidates(const MMTk_ObjectReference *objects,
+ size_t count,
+ bool can_parallel_free);
+
+void mmtk_declare_weak_references(MMTk_ObjectReference object);
+
+bool mmtk_weak_references_alive_p(MMTk_ObjectReference object);
+
+size_t mmtk_weak_references_count(void);
+
+void mmtk_register_pinning_obj(MMTk_ObjectReference obj);
+
+void mmtk_object_reference_write_post(MMTk_Mutator *mutator, MMTk_ObjectReference object);
+
+void mmtk_register_wb_unprotected_object(MMTk_ObjectReference object);
+
+bool mmtk_object_wb_unprotected_p(MMTk_ObjectReference object);
+
+void mmtk_enumerate_objects(void (*callback)(MMTk_ObjectReference, void*), void *data);
+
+struct MMTk_RawVecOfObjRef mmtk_get_all_obj_free_candidates(void);
+
+void mmtk_free_raw_vec_of_obj_ref(struct MMTk_RawVecOfObjRef raw_vec);
+
+void mmtk_before_fork(void);
+
+void mmtk_after_fork(MMTk_VMThread tls);
+
+size_t mmtk_total_bytes(void);
+
+size_t mmtk_used_bytes(void);
+
+size_t mmtk_free_bytes(void);
+
+MMTk_Address mmtk_starting_heap_address(void);
+
+MMTk_Address mmtk_last_heap_address(void);
+
+size_t mmtk_worker_count(void);
+
+const uint8_t *mmtk_plan(void);
+
+const uint8_t *mmtk_heap_mode(void);
+
+size_t mmtk_heap_min(void);
+
+size_t mmtk_heap_max(void);
+
+bool mmtk_is_mmtk_object(MMTk_Address addr);
+
+#endif /* MMTK_H */
diff --git a/gc/mmtk/src/abi.rs b/gc/mmtk/src/abi.rs
new file mode 100644
index 0000000000..30890e0853
--- /dev/null
+++ b/gc/mmtk/src/abi.rs
@@ -0,0 +1,335 @@
+use crate::api::RubyMutator;
+use crate::extra_assert;
+use crate::Ruby;
+use libc::c_int;
+use mmtk::scheduler::GCWorker;
+use mmtk::util::Address;
+use mmtk::util::ObjectReference;
+use mmtk::util::VMMutatorThread;
+use mmtk::util::VMWorkerThread;
+
+// For the C binding
+pub const OBJREF_OFFSET: usize = 8;
+pub const MIN_OBJ_ALIGN: usize = 8; // Even on 32-bit machine. A Ruby object is at least 40 bytes large.
+
+pub const GC_THREAD_KIND_WORKER: libc::c_int = 1;
+
+const HIDDEN_SIZE_MASK: usize = 0x0000FFFFFFFFFFFF;
+
+// An opaque type for the C counterpart.
+#[allow(non_camel_case_types)]
+pub struct st_table;
+
+#[repr(C)]
+pub struct HiddenHeader {
+ pub prefix: usize,
+}
+
+impl HiddenHeader {
+ #[inline(always)]
+ pub fn is_sane(&self) -> bool {
+ self.prefix & !HIDDEN_SIZE_MASK == 0
+ }
+
+ #[inline(always)]
+ fn assert_sane(&self) {
+ extra_assert!(
+ self.is_sane(),
+ "Hidden header is corrupted: {:x}",
+ self.prefix
+ );
+ }
+
+ pub fn payload_size(&self) -> usize {
+ self.assert_sane();
+ self.prefix & HIDDEN_SIZE_MASK
+ }
+}
+
+/// Provide convenient methods for accessing Ruby objects.
+/// TODO: Wrap C functions in `RubyUpcalls` as Rust-friendly methods.
+pub struct RubyObjectAccess {
+ objref: ObjectReference,
+}
+
+impl RubyObjectAccess {
+ pub fn from_objref(objref: ObjectReference) -> Self {
+ Self { objref }
+ }
+
+ pub fn obj_start(&self) -> Address {
+ self.objref.to_raw_address().sub(Self::prefix_size())
+ }
+
+ pub fn payload_addr(&self) -> Address {
+ self.objref.to_raw_address()
+ }
+
+ pub fn suffix_addr(&self) -> Address {
+ self.objref.to_raw_address().add(self.payload_size())
+ }
+
+ pub fn obj_end(&self) -> Address {
+ self.suffix_addr() + Self::suffix_size()
+ }
+
+ fn hidden_header(&self) -> &'static HiddenHeader {
+ unsafe { self.obj_start().as_ref() }
+ }
+
+ #[allow(unused)] // Maybe we need to mutate the hidden header in the future.
+ fn hidden_header_mut(&self) -> &'static mut HiddenHeader {
+ unsafe { self.obj_start().as_mut_ref() }
+ }
+
+ pub fn payload_size(&self) -> usize {
+ self.hidden_header().payload_size()
+ }
+
+ fn flags_field(&self) -> Address {
+ self.objref.to_raw_address()
+ }
+
+ pub fn load_flags(&self) -> usize {
+ unsafe { self.flags_field().load::<usize>() }
+ }
+
+ pub fn prefix_size() -> usize {
+ // Currently, a hidden size field of word size is placed before each object.
+ OBJREF_OFFSET
+ }
+
+ pub fn suffix_size() -> usize {
+ // In RACTOR_CHECK_MODE, Ruby hides a field after each object to hold the Ractor ID.
+ unsafe { crate::BINDING_FAST.suffix_size }
+ }
+
+ pub fn object_size(&self) -> usize {
+ Self::prefix_size() + self.payload_size() + Self::suffix_size()
+ }
+}
+
+type ObjectClosureFunction =
+ extern "C" fn(*mut libc::c_void, *mut libc::c_void, ObjectReference, bool) -> ObjectReference;
+
+#[repr(C)]
+pub struct ObjectClosure {
+ /// The function to be called from C.
+ pub c_function: ObjectClosureFunction,
+ /// The pointer to the Rust-level closure object.
+ pub rust_closure: *mut libc::c_void,
+}
+
+impl Default for ObjectClosure {
+ fn default() -> Self {
+ Self {
+ c_function: THE_UNREGISTERED_CLOSURE_FUNC,
+ rust_closure: std::ptr::null_mut(),
+ }
+ }
+}
+
+/// Rust doesn't require function items to have a unique address.
+/// We therefore force using this particular constant.
+///
+/// See: https://rust-lang.github.io/rust-clippy/master/index.html#fn_address_comparisons
+const THE_UNREGISTERED_CLOSURE_FUNC: ObjectClosureFunction = ObjectClosure::c_function_unregistered;
+
+impl ObjectClosure {
+ /// Set this ObjectClosure temporarily to `visit_object`, and execute `f`. During the execution of
+ /// `f`, the Ruby VM may call this ObjectClosure. When the Ruby VM calls this ObjectClosure,
+ /// it effectively calls `visit_object`.
+ ///
+ /// This method is intended to run Ruby VM code in `f` with temporarily modified behavior of
+ /// `rb_gc_mark`, `rb_gc_mark_movable` and `rb_gc_location`
+ ///
+ /// Both `f` and `visit_object` may access and modify local variables in the environment where
+ /// `set_temporarily_and_run_code` called.
+ ///
+ /// Note that this function is not reentrant. Don't call this function in either `callback` or
+ /// `f`.
+ pub fn set_temporarily_and_run_code<'env, T, F1, F2>(
+ &mut self,
+ mut visit_object: F1,
+ f: F2,
+ ) -> T
+ where
+ F1: 'env + FnMut(&'static mut GCWorker<Ruby>, ObjectReference, bool) -> ObjectReference,
+ F2: 'env + FnOnce() -> T,
+ {
+ debug_assert!(
+ std::ptr::fn_addr_eq(self.c_function, THE_UNREGISTERED_CLOSURE_FUNC),
+ "set_temporarily_and_run_code is recursively called."
+ );
+ self.c_function = Self::c_function_registered::<F1>;
+ self.rust_closure = &mut visit_object as *mut F1 as *mut libc::c_void;
+ let result = f();
+ *self = Default::default();
+ result
+ }
+
+ extern "C" fn c_function_registered<F>(
+ rust_closure: *mut libc::c_void,
+ worker: *mut libc::c_void,
+ object: ObjectReference,
+ pin: bool,
+ ) -> ObjectReference
+ where
+ F: FnMut(&'static mut GCWorker<Ruby>, ObjectReference, bool) -> ObjectReference,
+ {
+ let rust_closure = unsafe { &mut *(rust_closure as *mut F) };
+ let worker = unsafe { &mut *(worker as *mut GCWorker<Ruby>) };
+ rust_closure(worker, object, pin)
+ }
+
+ extern "C" fn c_function_unregistered(
+ _rust_closure: *mut libc::c_void,
+ worker: *mut libc::c_void,
+ object: ObjectReference,
+ pin: bool,
+ ) -> ObjectReference {
+ let worker = unsafe { &mut *(worker as *mut GCWorker<Ruby>) };
+ panic!(
+ "object_closure is not set. worker ordinal: {}, object: {}, pin: {}",
+ worker.ordinal, object, pin
+ );
+ }
+}
+
+#[repr(C)]
+pub struct GCThreadTLS {
+ pub kind: libc::c_int,
+ pub gc_context: *mut libc::c_void,
+ pub object_closure: ObjectClosure,
+}
+
+impl GCThreadTLS {
+ fn new(kind: libc::c_int, gc_context: *mut libc::c_void) -> Self {
+ Self {
+ kind,
+ gc_context,
+ object_closure: Default::default(),
+ }
+ }
+
+ pub fn for_worker(gc_context: *mut GCWorker<Ruby>) -> Self {
+ Self::new(GC_THREAD_KIND_WORKER, gc_context as *mut libc::c_void)
+ }
+
+ pub fn from_vwt(vwt: VMWorkerThread) -> *mut GCThreadTLS {
+ unsafe { std::mem::transmute(vwt) }
+ }
+
+ /// Cast a pointer to `GCThreadTLS` to a ref, with assertion for null pointer.
+ ///
+ /// # Safety
+ ///
+ /// Has undefined behavior if `ptr` is invalid.
+ pub unsafe fn check_cast(ptr: *mut GCThreadTLS) -> &'static mut GCThreadTLS {
+ assert!(!ptr.is_null());
+ let result = unsafe { &mut *ptr };
+ debug_assert!({
+ let kind = result.kind;
+ kind == GC_THREAD_KIND_WORKER
+ });
+ result
+ }
+
+ /// Cast a pointer to `VMWorkerThread` to a ref, with assertion for null pointer.
+ ///
+ /// # Safety
+ ///
+ /// Has undefined behavior if `ptr` is invalid.
+ pub unsafe fn from_vwt_check(vwt: VMWorkerThread) -> &'static mut GCThreadTLS {
+ let ptr = Self::from_vwt(vwt);
+ unsafe { Self::check_cast(ptr) }
+ }
+
+ #[allow(clippy::not_unsafe_ptr_arg_deref)] // `transmute` does not dereference pointer
+ pub fn to_vwt(ptr: *mut Self) -> VMWorkerThread {
+ unsafe { std::mem::transmute(ptr) }
+ }
+
+ pub fn worker<'w>(&mut self) -> &'w mut GCWorker<Ruby> {
+ // NOTE: The returned ref points to the worker which does not have the same lifetime as self.
+ assert!(self.kind == GC_THREAD_KIND_WORKER);
+ unsafe { &mut *(self.gc_context as *mut GCWorker<Ruby>) }
+ }
+}
+
+#[repr(C)]
+#[derive(Clone)]
+pub struct RawVecOfObjRef {
+ pub ptr: *mut ObjectReference,
+ pub len: usize,
+ pub capa: usize,
+}
+
+impl RawVecOfObjRef {
+ pub fn from_vec(vec: Vec<ObjectReference>) -> RawVecOfObjRef {
+ // Note: Vec::into_raw_parts is unstable. We implement it manually.
+ let mut vec = std::mem::ManuallyDrop::new(vec);
+ let (ptr, len, capa) = (vec.as_mut_ptr(), vec.len(), vec.capacity());
+
+ RawVecOfObjRef { ptr, len, capa }
+ }
+
+ /// # Safety
+ ///
+ /// This function turns raw pointer into a Vec without check.
+ pub unsafe fn into_vec(self) -> Vec<ObjectReference> {
+ unsafe { Vec::from_raw_parts(self.ptr, self.len, self.capa) }
+ }
+}
+
+impl From<Vec<ObjectReference>> for RawVecOfObjRef {
+ fn from(v: Vec<ObjectReference>) -> Self {
+ Self::from_vec(v)
+ }
+}
+
+#[repr(C)]
+#[derive(Clone)]
+pub struct RubyBindingOptions {
+ pub suffix_size: usize,
+}
+
+#[repr(C)]
+#[derive(Clone)]
+pub struct RubyUpcalls {
+ pub init_gc_worker_thread: extern "C" fn(gc_worker_tls: *mut GCThreadTLS),
+ pub is_mutator: extern "C" fn() -> bool,
+ pub stop_the_world: extern "C" fn(),
+ pub resume_mutators: extern "C" fn(gc_may_move: bool),
+ pub block_for_gc: extern "C" fn(tls: VMMutatorThread),
+ pub before_updating_jit_code: extern "C" fn(),
+ pub after_updating_jit_code: extern "C" fn(),
+ pub number_of_mutators: extern "C" fn() -> usize,
+ pub get_mutators: extern "C" fn(
+ visit_mutator: extern "C" fn(*mut RubyMutator, *mut libc::c_void),
+ data: *mut libc::c_void,
+ ),
+ pub scan_gc_roots: extern "C" fn(),
+ pub scan_objspace: extern "C" fn(),
+ pub move_obj_during_marking: extern "C" fn(from: ObjectReference, to: ObjectReference),
+ pub update_object_references: extern "C" fn(object: ObjectReference),
+ pub call_gc_mark_children: extern "C" fn(object: ObjectReference),
+ pub handle_weak_references: extern "C" fn(object: ObjectReference, moving: bool),
+ pub call_obj_free: extern "C" fn(object: ObjectReference),
+ pub vm_live_bytes: extern "C" fn() -> usize,
+ pub update_global_tables: extern "C" fn(tbl_idx: c_int, moving: bool),
+ pub global_tables_count: extern "C" fn() -> c_int,
+ pub update_finalizer_table: extern "C" fn(),
+ pub special_const_p: extern "C" fn(object: ObjectReference) -> bool,
+ pub mutator_thread_panic_handler: extern "C" fn(),
+ pub gc_thread_panic_handler: extern "C" fn(),
+}
+
+unsafe impl Sync for RubyUpcalls {}
+
+#[repr(C)]
+#[derive(Clone)]
+pub struct HeapBounds {
+ pub start: *mut libc::c_void,
+ pub end: *mut libc::c_void,
+}
diff --git a/gc/mmtk/src/active_plan.rs b/gc/mmtk/src/active_plan.rs
new file mode 100644
index 0000000000..80372a7576
--- /dev/null
+++ b/gc/mmtk/src/active_plan.rs
@@ -0,0 +1,56 @@
+use std::collections::VecDeque;
+use std::marker::PhantomData;
+
+use crate::mmtk;
+use crate::upcalls;
+use crate::Ruby;
+use mmtk::util::opaque_pointer::*;
+use mmtk::vm::ActivePlan;
+use mmtk::Mutator;
+
+pub struct VMActivePlan {}
+
+impl ActivePlan<Ruby> for VMActivePlan {
+ fn number_of_mutators() -> usize {
+ (upcalls().number_of_mutators)()
+ }
+
+ fn is_mutator(_tls: VMThread) -> bool {
+ (upcalls().is_mutator)()
+ }
+
+ fn mutator(_tls: VMMutatorThread) -> &'static mut Mutator<Ruby> {
+ unimplemented!()
+ }
+
+ fn mutators<'a>() -> Box<dyn Iterator<Item = &'a mut Mutator<Ruby>> + 'a> {
+ let mut mutators = VecDeque::new();
+ (upcalls().get_mutators)(
+ add_mutator_to_vec,
+ &mut mutators as *mut VecDeque<&mut Mutator<Ruby>> as _,
+ );
+
+ Box::new(RubyMutatorIterator {
+ mutators,
+ phantom_data: PhantomData,
+ })
+ }
+}
+
+extern "C" fn add_mutator_to_vec(mutator: *mut Mutator<Ruby>, mutators: *mut libc::c_void) {
+ let mutators = unsafe { &mut *(mutators as *mut VecDeque<*mut Mutator<Ruby>>) };
+ mutators.push_back(unsafe { &mut *mutator });
+}
+
+struct RubyMutatorIterator<'a> {
+ mutators: VecDeque<&'a mut Mutator<Ruby>>,
+ phantom_data: PhantomData<&'a ()>,
+}
+
+impl<'a> Iterator for RubyMutatorIterator<'a> {
+ type Item = &'a mut Mutator<Ruby>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.mutators.pop_front()
+ }
+}
diff --git a/gc/mmtk/src/api.rs b/gc/mmtk/src/api.rs
new file mode 100644
index 0000000000..c0540fe0c8
--- /dev/null
+++ b/gc/mmtk/src/api.rs
@@ -0,0 +1,551 @@
+// Functions in this module are unsafe for one reason:
+// They are called by C functions and they need to pass raw pointers to Rust.
+#![allow(clippy::missing_safety_doc)]
+
+use mmtk::util::alloc::BumpPointer;
+use mmtk::util::alloc::ImmixAllocator;
+use mmtk::util::conversions;
+use mmtk::util::options::PlanSelector;
+use std::str::FromStr;
+use std::sync::atomic::Ordering;
+
+use crate::abi::RawVecOfObjRef;
+use crate::abi::RubyBindingOptions;
+use crate::abi::RubyUpcalls;
+use crate::binding;
+use crate::binding::RubyBinding;
+use crate::heap::CpuHeapTriggerConfig;
+use crate::heap::RubyHeapTriggerConfig;
+use crate::heap::CPU_HEAP_TRIGGER_CONFIG;
+use crate::heap::RUBY_HEAP_TRIGGER_CONFIG;
+use crate::mmtk;
+use crate::utils::default_heap_max;
+use crate::utils::parse_capacity;
+use crate::Ruby;
+use crate::RubySlot;
+use mmtk::memory_manager;
+use mmtk::memory_manager::mmtk_init;
+use mmtk::util::constants::MIN_OBJECT_SIZE;
+use mmtk::util::options::GCTriggerSelector;
+use mmtk::util::Address;
+use mmtk::util::ObjectReference;
+use mmtk::util::VMMutatorThread;
+use mmtk::util::VMThread;
+use mmtk::AllocationSemantics;
+use mmtk::MMTKBuilder;
+use mmtk::Mutator;
+
+pub type RubyMutator = Mutator<Ruby>;
+
+#[no_mangle]
+pub extern "C" fn mmtk_is_live_object(object: ObjectReference) -> bool {
+ memory_manager::is_live_object(object)
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_is_reachable(object: ObjectReference) -> bool {
+ object.is_reachable()
+}
+
+// =============== Bootup ===============
+
+fn parse_env_var_with<T, F: FnOnce(&str) -> Option<T>>(key: &str, parse: F) -> Option<T> {
+ let val = match std::env::var(key) {
+ Ok(val) => val,
+ Err(std::env::VarError::NotPresent) => return None,
+ Err(std::env::VarError::NotUnicode(os_string)) => {
+ eprintln!("[FATAL] Invalid {key} {os_string:?}");
+ std::process::exit(1);
+ }
+ };
+
+ let parsed = parse(&val).unwrap_or_else(|| {
+ eprintln!("[FATAL] Invalid {key} {val}");
+ std::process::exit(1);
+ });
+
+ Some(parsed)
+}
+
+fn parse_env_var<T: FromStr>(key: &str) -> Option<T> {
+ parse_env_var_with(key, |s| s.parse().ok())
+}
+
+fn mmtk_builder_default_parse_threads() -> Option<usize> {
+ parse_env_var("MMTK_THREADS")
+}
+
+fn mmtk_builder_default_parse_heap_min() -> usize {
+ const DEFAULT_HEAP_MIN: usize = 1 << 20;
+ parse_env_var_with("MMTK_HEAP_MIN", parse_capacity).unwrap_or(DEFAULT_HEAP_MIN)
+}
+
+fn mmtk_builder_default_parse_heap_max() -> usize {
+ parse_env_var_with("MMTK_HEAP_MAX", parse_capacity).unwrap_or_else(default_heap_max)
+}
+
+fn parse_float_env_var(key: &str, default: f64, min: f64, max: f64) -> f64 {
+ parse_env_var_with(key, |s| {
+ let mut float = f64::from_str(s).unwrap_or(default);
+
+ if float <= min {
+ eprintln!(
+ "{key} has value {float} which must be greater than {min}, using default instead"
+ );
+ float = default;
+ }
+
+ if float >= max {
+ eprintln!(
+ "{key} has value {float} which must be less than {max}, using default instead"
+ );
+ float = default;
+ }
+
+ Some(float)
+ })
+ .unwrap_or(default)
+}
+
+fn mmtk_builder_default_parse_heap_mode(heap_min: usize, heap_max: usize) -> GCTriggerSelector {
+ let make_fixed = || GCTriggerSelector::FixedHeapSize(heap_max);
+ let make_dynamic = || GCTriggerSelector::DynamicHeapSize(heap_min, heap_max);
+
+ parse_env_var_with("MMTK_HEAP_MODE", |s| match s {
+ "fixed" => Some(make_fixed()),
+ "dynamic" => Some(make_dynamic()),
+ "ruby" => {
+ let min_ratio = parse_float_env_var("RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO", 0.2, 0.0, 1.0);
+ let goal_ratio =
+ parse_float_env_var("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", 0.4, min_ratio, 1.0);
+ let max_ratio =
+ parse_float_env_var("RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO", 0.65, goal_ratio, 1.0);
+
+ crate::heap::RUBY_HEAP_TRIGGER_CONFIG
+ .set(RubyHeapTriggerConfig {
+ min_heap_pages: conversions::bytes_to_pages_up(heap_min),
+ max_heap_pages: conversions::bytes_to_pages_up(heap_max),
+ heap_pages_min_ratio: min_ratio,
+ heap_pages_goal_ratio: goal_ratio,
+ heap_pages_max_ratio: max_ratio,
+ })
+ .unwrap_or_else(|_| panic!("RUBY_HEAP_TRIGGER_CONFIG is already set"));
+
+ Some(GCTriggerSelector::Delegated)
+ }
+ "cpu" => {
+ // CPU-overhead-driven heap sizing based on Tavakolisomeh et al.,
+ // "Heap Size Adjustment with CPU Control", MPLR '23.
+ //
+ // Target is expressed as a percentage (0, 100) via
+ // `MMTK_GC_CPU_TARGET`. The paper recommends 15 for ZGC (a
+ // concurrent collector); we default to 5 for MMTk-Ruby. With
+ // MMTk's stop-the-world Immix, every percent of GC CPU is also
+ // a percent of wall-clock the mutator is blocked on, so a much
+ // smaller budget is appropriate. An empirical sweep across
+ // ruby-bench (railsbench, lobsters, psych-load, liquid-render,
+ // lee) found target=5 to be Pareto-optimal: ~6% geomean speedup
+ // vs. the `ruby` heap mode with effectively identical geomean
+ // peak RSS.
+ let target_percent = parse_float_env_var("MMTK_GC_CPU_TARGET", 5.0, 0.0, 100.0);
+ let window_size = parse_env_var::<usize>("MMTK_GC_CPU_WINDOW").unwrap_or(3);
+ let window_size = window_size.max(1);
+
+ let min_heap_pages = conversions::bytes_to_pages_up(heap_min);
+ let max_heap_pages = conversions::bytes_to_pages_up(heap_max);
+ // Start at the min heap size, as the other delegated triggers do.
+ // The control loop will adjust from here after the first GC cycle.
+ let initial_heap_pages = min_heap_pages;
+
+ CPU_HEAP_TRIGGER_CONFIG
+ .set(CpuHeapTriggerConfig {
+ min_heap_pages,
+ max_heap_pages,
+ initial_heap_pages,
+ target_gc_cpu: target_percent / 100.0,
+ window_size,
+ })
+ .unwrap_or_else(|_| panic!("CPU_HEAP_TRIGGER_CONFIG is already set"));
+
+ Some(GCTriggerSelector::Delegated)
+ }
+ _ => None,
+ })
+ .unwrap_or_else(make_dynamic)
+}
+
+fn mmtk_builder_default_parse_plan() -> PlanSelector {
+ parse_env_var_with("MMTK_PLAN", |s| match s {
+ "NoGC" => Some(PlanSelector::NoGC),
+ "MarkSweep" => Some(PlanSelector::MarkSweep),
+ "Immix" => Some(PlanSelector::Immix),
+ _ => None,
+ })
+ .unwrap_or(PlanSelector::Immix)
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_builder_default() -> *mut MMTKBuilder {
+ let mut builder = MMTKBuilder::new_no_env_vars();
+ builder.options.no_finalizer.set(true);
+
+ if let Some(threads) = mmtk_builder_default_parse_threads() {
+ if !builder.options.threads.set(threads) {
+ // MMTk will validate it and reject 0.
+ eprintln!("[FATAL] Failed to set the number of MMTk threads to {threads}");
+ std::process::exit(1);
+ }
+ }
+
+ let heap_min = mmtk_builder_default_parse_heap_min();
+
+ let heap_max = mmtk_builder_default_parse_heap_max();
+
+ if heap_min >= heap_max {
+ eprintln!("[FATAL] MMTK_HEAP_MIN({heap_min}) >= MMTK_HEAP_MAX({heap_max})");
+ std::process::exit(1);
+ }
+
+ builder
+ .options
+ .gc_trigger
+ .set(mmtk_builder_default_parse_heap_mode(heap_min, heap_max));
+
+ builder.options.plan.set(mmtk_builder_default_parse_plan());
+
+ Box::into_raw(Box::new(builder))
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_init_binding(
+ builder: *mut MMTKBuilder,
+ binding_options: *const RubyBindingOptions,
+ upcalls: *const RubyUpcalls,
+) {
+ crate::MUTATOR_THREAD_PANIC_HANDLER
+ .set((unsafe { (*upcalls).clone() }).mutator_thread_panic_handler)
+ .unwrap_or_else(|_| panic!("MUTATOR_THREAD_PANIC_HANDLER is already initialized"));
+
+ crate::set_panic_hook();
+
+ let builder: Box<MMTKBuilder> = unsafe { Box::from_raw(builder) };
+ let binding_options = unsafe { (*binding_options).clone() };
+ let mmtk_boxed = mmtk_init(&builder);
+ let mmtk_static = Box::leak(Box::new(mmtk_boxed));
+
+ let mut binding = RubyBinding::new(mmtk_static, &binding_options, upcalls);
+ binding
+ .weak_proc
+ .init_parallel_obj_free_candidates(memory_manager::num_of_workers(binding.mmtk));
+
+ crate::BINDING
+ .set(binding)
+ .unwrap_or_else(|_| panic!("Binding is already initialized"));
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_initialize_collection(tls: VMThread) {
+ memory_manager::initialize_collection(mmtk(), tls)
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_bind_mutator(tls: VMMutatorThread) -> *mut RubyMutator {
+ Box::into_raw(memory_manager::bind_mutator(mmtk(), tls))
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_get_bump_pointer_allocator(m: *mut RubyMutator) -> *mut BumpPointer {
+ match *crate::BINDING.get().unwrap().mmtk.get_options().plan {
+ PlanSelector::Immix => {
+ let mutator: &mut Mutator<Ruby> = unsafe { &mut *m };
+ let allocator =
+ unsafe { mutator.allocator_mut(mmtk::util::alloc::AllocatorSelector::Immix(0)) };
+
+ if let Some(immix_allocator) = allocator.downcast_mut::<ImmixAllocator<Ruby>>() {
+ &mut immix_allocator.bump_pointer as *mut BumpPointer
+ } else {
+ panic!("Failed to get bump pointer allocator");
+ }
+ }
+ _ => std::ptr::null_mut(),
+ }
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_destroy_mutator(mutator: *mut RubyMutator) {
+ // notify mmtk-core about destroyed mutator
+ memory_manager::destroy_mutator(unsafe { &mut *mutator });
+ // turn the ptr back to a box, and let Rust properly reclaim it
+ let _ = unsafe { Box::from_raw(mutator) };
+}
+
+// =============== GC ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_handle_user_collection_request(
+ tls: VMMutatorThread,
+ force: bool,
+ exhaustive: bool,
+) {
+ crate::mmtk().handle_user_collection_request(tls, force, exhaustive);
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_set_gc_enabled(enable: bool) {
+ crate::CONFIGURATION
+ .gc_enabled
+ .store(enable, Ordering::Relaxed);
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_gc_enabled_p() -> bool {
+ crate::CONFIGURATION.gc_enabled.load(Ordering::Relaxed)
+}
+
+// =============== Object allocation ===============
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_alloc(
+ mutator: *mut RubyMutator,
+ size: usize,
+ align: usize,
+ offset: usize,
+ semantics: AllocationSemantics,
+) -> Address {
+ let clamped_size = size.max(MIN_OBJECT_SIZE);
+ memory_manager::alloc::<Ruby>(
+ unsafe { &mut *mutator },
+ clamped_size,
+ align,
+ offset,
+ semantics,
+ )
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_post_alloc(
+ mutator: *mut RubyMutator,
+ refer: ObjectReference,
+ bytes: usize,
+ semantics: AllocationSemantics,
+) {
+ memory_manager::post_alloc::<Ruby>(unsafe { &mut *mutator }, refer, bytes, semantics)
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_add_obj_free_candidates(
+ objects: *const ObjectReference,
+ count: usize,
+ can_parallel_free: bool,
+) {
+ let objects = unsafe { std::slice::from_raw_parts(objects, count) };
+ binding()
+ .weak_proc
+ .add_obj_free_candidates_batch(objects, can_parallel_free)
+}
+
+// =============== Weak references ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_declare_weak_references(object: ObjectReference) {
+ binding().weak_proc.add_weak_reference(object);
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_weak_references_alive_p(object: ObjectReference) -> bool {
+ object.is_reachable()
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_weak_references_count() -> usize {
+ binding().weak_proc.weak_references_count()
+}
+
+// =============== Compaction ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_register_pinning_obj(obj: ObjectReference) {
+ crate::binding().pinning_registry.register(obj);
+}
+
+// =============== Write barriers ===============
+
+#[no_mangle]
+pub unsafe extern "C" fn mmtk_object_reference_write_post(
+ mutator: *mut RubyMutator,
+ object: ObjectReference,
+) {
+ let ignored_slot = RubySlot::from_address(Address::ZERO);
+ let ignored_target = ObjectReference::from_raw_address(Address::ZERO);
+ mmtk::memory_manager::object_reference_write_post(
+ unsafe { &mut *mutator },
+ object,
+ ignored_slot,
+ ignored_target,
+ )
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_register_wb_unprotected_object(object: ObjectReference) {
+ crate::binding().register_wb_unprotected_object(object)
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_object_wb_unprotected_p(object: ObjectReference) -> bool {
+ crate::binding().object_wb_unprotected_p(object)
+}
+
+// =============== Heap walking ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_enumerate_objects(
+ callback: extern "C" fn(ObjectReference, *mut libc::c_void),
+ data: *mut libc::c_void,
+) {
+ crate::mmtk().enumerate_objects(|object| {
+ callback(object, data);
+ })
+}
+
+// =============== Finalizers ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_get_all_obj_free_candidates() -> RawVecOfObjRef {
+ let vec = binding().weak_proc.get_all_obj_free_candidates();
+ RawVecOfObjRef::from_vec(vec)
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_free_raw_vec_of_obj_ref(raw_vec: RawVecOfObjRef) {
+ unsafe { raw_vec.into_vec() };
+}
+
+// =============== Forking ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_before_fork() {
+ mmtk().prepare_to_fork();
+ binding().join_all_gc_threads();
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_after_fork(tls: VMThread) {
+ mmtk().after_fork(tls);
+}
+
+// =============== Statistics ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_total_bytes() -> usize {
+ memory_manager::total_bytes(mmtk())
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_used_bytes() -> usize {
+ memory_manager::used_bytes(mmtk())
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_free_bytes() -> usize {
+ memory_manager::free_bytes(mmtk())
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_starting_heap_address() -> Address {
+ memory_manager::starting_heap_address()
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_last_heap_address() -> Address {
+ memory_manager::last_heap_address()
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_worker_count() -> usize {
+ memory_manager::num_of_workers(mmtk())
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_plan() -> *const u8 {
+ static NO_GC: &[u8] = b"NoGC\0";
+ static MARK_SWEEP: &[u8] = b"MarkSweep\0";
+ static IMMIX: &[u8] = b"Immix\0";
+
+ match *crate::BINDING.get().unwrap().mmtk.get_options().plan {
+ PlanSelector::NoGC => NO_GC.as_ptr(),
+ PlanSelector::MarkSweep => MARK_SWEEP.as_ptr(),
+ PlanSelector::Immix => IMMIX.as_ptr(),
+ _ => panic!("Unknown plan"),
+ }
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_heap_mode() -> *const u8 {
+ static FIXED_HEAP: &[u8] = b"fixed\0";
+ static DYNAMIC_HEAP: &[u8] = b"dynamic\0";
+ static RUBY_HEAP: &[u8] = b"ruby\0";
+ static CPU_HEAP: &[u8] = b"cpu\0";
+
+ match *crate::BINDING.get().unwrap().mmtk.get_options().gc_trigger {
+ GCTriggerSelector::FixedHeapSize(_) => FIXED_HEAP.as_ptr(),
+ GCTriggerSelector::DynamicHeapSize(_, _) => DYNAMIC_HEAP.as_ptr(),
+ GCTriggerSelector::Delegated => {
+ // Two delegated triggers exist; disambiguate via the populated
+ // config singleton.
+ if CPU_HEAP_TRIGGER_CONFIG.get().is_some() {
+ CPU_HEAP.as_ptr()
+ } else {
+ RUBY_HEAP.as_ptr()
+ }
+ }
+ }
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_heap_min() -> usize {
+ match *crate::BINDING.get().unwrap().mmtk.get_options().gc_trigger {
+ GCTriggerSelector::FixedHeapSize(_) => 0,
+ GCTriggerSelector::DynamicHeapSize(min_size, _) => min_size,
+ GCTriggerSelector::Delegated => {
+ if let Some(cfg) = CPU_HEAP_TRIGGER_CONFIG.get() {
+ conversions::pages_to_bytes(cfg.min_heap_pages)
+ } else {
+ conversions::pages_to_bytes(
+ RUBY_HEAP_TRIGGER_CONFIG
+ .get()
+ .expect("RUBY_HEAP_TRIGGER_CONFIG not set")
+ .min_heap_pages,
+ )
+ }
+ }
+ }
+}
+
+#[no_mangle]
+pub extern "C" fn mmtk_heap_max() -> usize {
+ match *crate::BINDING.get().unwrap().mmtk.get_options().gc_trigger {
+ GCTriggerSelector::FixedHeapSize(max_size) => max_size,
+ GCTriggerSelector::DynamicHeapSize(_, max_size) => max_size,
+ GCTriggerSelector::Delegated => {
+ if let Some(cfg) = CPU_HEAP_TRIGGER_CONFIG.get() {
+ conversions::pages_to_bytes(cfg.max_heap_pages)
+ } else {
+ conversions::pages_to_bytes(
+ RUBY_HEAP_TRIGGER_CONFIG
+ .get()
+ .expect("RUBY_HEAP_TRIGGER_CONFIG not set")
+ .max_heap_pages,
+ )
+ }
+ }
+ }
+}
+
+// =============== Miscellaneous ===============
+
+#[no_mangle]
+pub extern "C" fn mmtk_is_mmtk_object(addr: Address) -> bool {
+ debug_assert!(!addr.is_zero());
+ debug_assert!(addr.is_aligned_to(mmtk::util::is_mmtk_object::VO_BIT_REGION_SIZE));
+ memory_manager::is_mmtk_object(addr).is_some()
+}
diff --git a/gc/mmtk/src/binding.rs b/gc/mmtk/src/binding.rs
new file mode 100644
index 0000000000..36d4a992fd
--- /dev/null
+++ b/gc/mmtk/src/binding.rs
@@ -0,0 +1,129 @@
+use std::collections::HashSet;
+use std::ffi::CString;
+use std::sync::atomic::AtomicBool;
+use std::sync::Mutex;
+use std::thread::JoinHandle;
+
+use mmtk::util::ObjectReference;
+use mmtk::MMTK;
+
+use crate::abi;
+use crate::abi::RubyBindingOptions;
+use crate::pinning_registry::PinningRegistry;
+use crate::weak_proc::WeakProcessor;
+use crate::Ruby;
+
+pub struct RubyBindingFast {
+ pub suffix_size: usize,
+}
+
+impl Default for RubyBindingFast {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl RubyBindingFast {
+ pub const fn new() -> Self {
+ Self { suffix_size: 0 }
+ }
+}
+
+pub struct RubyConfiguration {
+ pub gc_enabled: AtomicBool,
+}
+
+impl Default for RubyConfiguration {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl RubyConfiguration {
+ pub const fn new() -> Self {
+ Self {
+ // Mimic the old behavior when the gc_enabled flag was in mmtk-core.
+ // We may refactor it so that it is false by default.
+ gc_enabled: AtomicBool::new(true),
+ }
+ }
+}
+
+pub struct RubyBinding {
+ pub mmtk: &'static MMTK<Ruby>,
+ pub options: RubyBindingOptions,
+ pub upcalls: *const abi::RubyUpcalls,
+ pub plan_name: Mutex<Option<CString>>,
+ pub weak_proc: WeakProcessor,
+ pub pinning_registry: PinningRegistry,
+ pub gc_thread_join_handles: Mutex<Vec<JoinHandle<()>>>,
+ pub wb_unprotected_objects: Mutex<HashSet<ObjectReference>>,
+}
+
+unsafe impl Sync for RubyBinding {}
+unsafe impl Send for RubyBinding {}
+
+impl RubyBinding {
+ pub fn new(
+ mmtk: &'static MMTK<Ruby>,
+ binding_options: &RubyBindingOptions,
+ upcalls: *const abi::RubyUpcalls,
+ ) -> Self {
+ unsafe {
+ crate::BINDING_FAST.suffix_size = binding_options.suffix_size;
+ }
+
+ Self {
+ mmtk,
+ options: binding_options.clone(),
+ upcalls,
+ plan_name: Mutex::new(None),
+ weak_proc: WeakProcessor::new(),
+ pinning_registry: PinningRegistry::new(),
+ gc_thread_join_handles: Default::default(),
+ wb_unprotected_objects: Default::default(),
+ }
+ }
+
+ pub fn upcalls(&self) -> &'static abi::RubyUpcalls {
+ unsafe { &*self.upcalls as &'static abi::RubyUpcalls }
+ }
+
+ pub fn get_plan_name_c(&self) -> *const libc::c_char {
+ let mut plan_name = self.plan_name.lock().unwrap();
+ if plan_name.is_none() {
+ let name_string = format!("{:?}", *self.mmtk.get_options().plan);
+ let c_string = CString::new(name_string)
+ .unwrap_or_else(|e| panic!("Failed converting plan name to CString: {e}"));
+ *plan_name = Some(c_string);
+ }
+ plan_name.as_deref().unwrap().as_ptr()
+ }
+
+ pub fn join_all_gc_threads(&self) {
+ let handles = {
+ let mut guard = self.gc_thread_join_handles.lock().unwrap();
+ std::mem::take(&mut *guard)
+ };
+
+ debug!("Joining GC threads...");
+ let total = handles.len();
+ let mut joined = 0;
+ for handle in handles {
+ handle.join().unwrap();
+ joined += 1;
+ debug!("{joined}/{total} GC threads joined.");
+ }
+ }
+
+ pub fn register_wb_unprotected_object(&self, object: ObjectReference) {
+ debug!("Registering WB-unprotected object: {object}");
+ let mut objects = self.wb_unprotected_objects.lock().unwrap();
+ objects.insert(object);
+ }
+
+ pub fn object_wb_unprotected_p(&self, object: ObjectReference) -> bool {
+ let objects = self.wb_unprotected_objects.lock().unwrap();
+ objects.contains(&object)
+ }
+}
diff --git a/gc/mmtk/src/collection.rs b/gc/mmtk/src/collection.rs
new file mode 100644
index 0000000000..648efa4e27
--- /dev/null
+++ b/gc/mmtk/src/collection.rs
@@ -0,0 +1,122 @@
+use crate::abi::GCThreadTLS;
+
+use crate::api::RubyMutator;
+use crate::heap::CpuHeapTrigger;
+use crate::heap::RubyHeapTrigger;
+use crate::heap::CPU_HEAP_TRIGGER_CONFIG;
+use crate::mmtk;
+use crate::upcalls;
+use crate::Ruby;
+use mmtk::memory_manager;
+use mmtk::scheduler::*;
+use mmtk::util::heap::GCTriggerPolicy;
+use mmtk::util::VMMutatorThread;
+use mmtk::util::VMThread;
+use mmtk::util::VMWorkerThread;
+use mmtk::vm::Collection;
+use mmtk::vm::GCThreadContext;
+use std::sync::atomic::AtomicBool;
+use std::sync::atomic::Ordering;
+use std::thread;
+
+static CURRENT_GC_MAY_MOVE: AtomicBool = AtomicBool::new(false);
+
+pub struct VMCollection {}
+
+impl Collection<Ruby> for VMCollection {
+ fn is_collection_enabled() -> bool {
+ crate::CONFIGURATION.gc_enabled.load(Ordering::Relaxed)
+ }
+
+ fn stop_all_mutators<F>(tls: VMWorkerThread, mut mutator_visitor: F)
+ where
+ F: FnMut(&'static mut mmtk::Mutator<Ruby>),
+ {
+ (upcalls().stop_the_world)();
+
+ if crate::mmtk().get_plan().current_gc_may_move_object() {
+ CURRENT_GC_MAY_MOVE.store(true, Ordering::Relaxed);
+ (upcalls().before_updating_jit_code)();
+ } else {
+ CURRENT_GC_MAY_MOVE.store(false, Ordering::Relaxed);
+ }
+
+ crate::binding().pinning_registry.pin_children(tls);
+
+ (upcalls().get_mutators)(
+ Self::notify_mutator_ready::<F>,
+ &mut mutator_visitor as *mut F as *mut _,
+ );
+ }
+
+ fn resume_mutators(_tls: VMWorkerThread) {
+ let current_gc_may_move = CURRENT_GC_MAY_MOVE.load(Ordering::Relaxed);
+
+ if current_gc_may_move {
+ (upcalls().after_updating_jit_code)();
+ }
+
+ (upcalls().resume_mutators)(current_gc_may_move);
+ }
+
+ fn block_for_gc(tls: VMMutatorThread) {
+ (upcalls().block_for_gc)(tls);
+ }
+
+ fn spawn_gc_thread(_tls: VMThread, ctx: GCThreadContext<Ruby>) {
+ let join_handle = match ctx {
+ GCThreadContext::Worker(mut worker) => thread::Builder::new()
+ .name("MMTk Worker Thread".to_string())
+ .spawn(move || {
+ let ordinal = worker.ordinal;
+ debug!("Hello! This is MMTk Worker Thread running! ordinal: {ordinal}");
+ crate::register_gc_thread(thread::current().id());
+ let ptr_worker = &mut *worker as *mut GCWorker<Ruby>;
+ let gc_thread_tls =
+ Box::into_raw(Box::new(GCThreadTLS::for_worker(ptr_worker)));
+ (upcalls().init_gc_worker_thread)(gc_thread_tls);
+ memory_manager::start_worker(
+ mmtk(),
+ GCThreadTLS::to_vwt(gc_thread_tls),
+ worker,
+ );
+ debug!("An MMTk Worker Thread is quitting. Good bye! ordinal: {ordinal}");
+ crate::unregister_gc_thread(thread::current().id());
+ })
+ .unwrap(),
+ };
+
+ {
+ let mut handles = crate::binding().gc_thread_join_handles.lock().unwrap();
+ handles.push(join_handle);
+ }
+ }
+
+ fn vm_live_bytes() -> usize {
+ (upcalls().vm_live_bytes)()
+ }
+
+ fn create_gc_trigger() -> Box<dyn GCTriggerPolicy<Ruby>> {
+ // `GCTriggerSelector::Delegated` is currently used by two different
+ // heap modes: `ruby` (the Ruby-like free-slot ratio trigger) and `cpu`
+ // (the CPU-overhead trigger from Tavakolisomeh et al., MPLR '23).
+ // Which one is active is determined by which `OnceCell` config the
+ // `MMTK_HEAP_MODE` parser populated.
+ if CPU_HEAP_TRIGGER_CONFIG.get().is_some() {
+ Box::new(CpuHeapTrigger::default())
+ } else {
+ Box::new(RubyHeapTrigger::default())
+ }
+ }
+}
+
+impl VMCollection {
+ extern "C" fn notify_mutator_ready<F>(mutator_ptr: *mut RubyMutator, data: *mut libc::c_void)
+ where
+ F: FnMut(&'static mut mmtk::Mutator<Ruby>),
+ {
+ let mutator = unsafe { &mut *mutator_ptr };
+ let mutator_visitor = unsafe { &mut *(data as *mut F) };
+ mutator_visitor(mutator);
+ }
+}
diff --git a/gc/mmtk/src/heap/cpu_heap_trigger.rs b/gc/mmtk/src/heap/cpu_heap_trigger.rs
new file mode 100644
index 0000000000..ef5a79fe9a
--- /dev/null
+++ b/gc/mmtk/src/heap/cpu_heap_trigger.rs
@@ -0,0 +1,370 @@
+//! A GC trigger that adjusts the heap size based on the CPU overhead of GC.
+//!
+//! This is an implementation of the heap sizing policy described in
+//! Tavakolisomeh, Shimchenko, Österlund, Bruno, Ferreira, Wrigstad,
+//! "Heap Size Adjustment with CPU Control", MPLR '23.
+//! <https://doi.org/10.1145/3617651.3622988>
+//!
+//! The idea: rather than letting heap size control GC frequency, let a
+//! user-supplied *target GC CPU overhead* control the heap size. After each GC
+//! cycle, we measure the GC CPU overhead (fraction of process CPU time spent
+//! in GC) and compare it to the target. If GC is over budget we grow the heap
+//! (reducing GC frequency); if it is under budget we shrink the heap (trading
+//! memory for more frequent collections).
+//!
+//! ## Algorithm
+//!
+//! After each GC cycle we compute, using an average of the last `n` cycles:
+//!
+//! ```text
+//! GC_CPU = T_GC / T_APP (Eq. 1)
+//! overhead_error = GC_CPU - target (Eq. 2)
+//! sigmoid_error = 1 / (1 + e^(-overhead_error)) (Eq. 3)
+//! adjustment_factor = sigmoid_error + 0.5 (in (0.5, 1.5)) (Eq. 4)
+//! new_size = current_size * adjustment_factor (Eq. 5)
+//! ```
+//!
+//! where:
+//! - `T_GC` is the wall-clock duration of each GC cycle.
+//! - `T_APP` is process CPU time elapsed between consecutive GC cycles (sum of
+//! CPU time over all threads — mutators, GC workers, compilers, etc.), read
+//! via `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)`.
+//!
+//! The final heap size is then clamped to the range
+//! `[max(1.1 * used, min_heap_pages), max_heap_pages]`, providing 10% headroom
+//! above current live memory to avoid triggering GC on an effectively-empty
+//! heap.
+//!
+//! ## Differences from the paper
+//!
+//! The paper targets ZGC, a concurrent generational collector. MMTk's Ruby
+//! binding currently ships stop-the-world collectors (Immix, MarkSweep). The
+//! paper's formula still applies: with a STW collector the process CPU time
+//! during GC closely tracks the wall-clock GC time, and mutator CPU time
+//! during the mutator phase is correctly attributed. For generational plans
+//! we skip nursery-only GCs, consistent with MemBalancer.
+
+use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::Ordering;
+use std::sync::Mutex;
+
+use mmtk::util::heap::GCTriggerPolicy;
+use mmtk::util::heap::SpaceStats;
+use mmtk::Plan;
+use mmtk::MMTK;
+use once_cell::sync::OnceCell;
+
+use crate::Ruby;
+
+pub static CPU_HEAP_TRIGGER_CONFIG: OnceCell<CpuHeapTriggerConfig> = OnceCell::new();
+
+/// Configuration for the [`CpuHeapTrigger`].
+pub struct CpuHeapTriggerConfig {
+ /// Lower bound on heap size (in pages). The trigger will never shrink below
+ /// this value.
+ pub min_heap_pages: usize,
+ /// Upper bound on heap size (in pages). The trigger will never grow above
+ /// this value.
+ pub max_heap_pages: usize,
+ /// Initial heap size (in pages).
+ pub initial_heap_pages: usize,
+ /// Target GC CPU overhead as a fraction of total process CPU time. For
+ /// example, `0.15` means the policy will try to keep GC CPU usage near 15%.
+ /// Valid range: `(0.0, 1.0)`.
+ pub target_gc_cpu: f64,
+ /// Number of recent GC cycles averaged together when computing the CPU
+ /// overhead signal. Smoothes out short-term fluctuations. The paper uses 3.
+ pub window_size: usize,
+}
+
+/// A single GC cycle's timing measurements.
+#[derive(Clone, Copy, Debug, Default)]
+struct GcSample {
+ /// Wall-clock seconds spent inside this GC cycle.
+ gc_seconds: f64,
+ /// Seconds of process CPU time elapsed since the previous GC cycle ended.
+ /// This covers both mutator time and (on multi-threaded mutators) any
+ /// mutator CPU time consumed in parallel with the previous GC.
+ app_cpu_seconds: f64,
+}
+
+struct CpuHeapTriggerState {
+ /// Ring buffer of the last `window_size` samples. Oldest-first.
+ samples: Vec<GcSample>,
+ /// Wall-clock time when the current GC cycle started. `None` when no GC is
+ /// in progress.
+ gc_start_wall: Option<std::time::Instant>,
+ /// Process CPU time (seconds) recorded at the end of the previous GC
+ /// cycle. `None` until the first cycle completes.
+ last_gc_end_cpu: Option<f64>,
+}
+
+impl CpuHeapTriggerState {
+ fn new() -> Self {
+ Self {
+ samples: Vec::new(),
+ gc_start_wall: None,
+ last_gc_end_cpu: None,
+ }
+ }
+
+ /// Pushes a new sample, dropping the oldest when the window is full.
+ fn push_sample(&mut self, sample: GcSample, window_size: usize) {
+ if self.samples.len() >= window_size {
+ self.samples.remove(0);
+ }
+ self.samples.push(sample);
+ }
+
+ /// Returns the arithmetic mean GC CPU overhead across the window, or
+ /// `None` if we don't yet have a full sample (which happens on the first
+ /// GC cycle — we have no baseline for `app_cpu_seconds`).
+ fn mean_gc_cpu(&self) -> Option<f64> {
+ if self.samples.is_empty() {
+ return None;
+ }
+ let total_gc: f64 = self.samples.iter().map(|s| s.gc_seconds).sum();
+ let total_app: f64 = self.samples.iter().map(|s| s.app_cpu_seconds).sum();
+ if total_app <= 0.0 {
+ return None;
+ }
+ Some(total_gc / total_app)
+ }
+}
+
+pub struct CpuHeapTrigger {
+ /// Target heap size in pages. Updated at the end of each GC cycle.
+ target_heap_pages: AtomicUsize,
+ /// Mutable timing state. Wrapped in a `Mutex` because `on_gc_start` and
+ /// `on_gc_end` are the only mutation sites and they are not on an
+ /// allocation hot path; avoiding the complexity of lock-free state is
+ /// worth the trivial contention.
+ state: Mutex<CpuHeapTriggerState>,
+}
+
+impl Default for CpuHeapTrigger {
+ fn default() -> Self {
+ let cfg = Self::get_config();
+ Self {
+ target_heap_pages: AtomicUsize::new(cfg.initial_heap_pages),
+ state: Mutex::new(CpuHeapTriggerState::new()),
+ }
+ }
+}
+
+impl GCTriggerPolicy<Ruby> for CpuHeapTrigger {
+ fn is_gc_required(
+ &self,
+ space_full: bool,
+ space: Option<SpaceStats<Ruby>>,
+ plan: &dyn Plan<VM = Ruby>,
+ ) -> bool {
+ // Let the plan decide, matching the other triggers.
+ plan.collection_required(space_full, space)
+ }
+
+ fn on_gc_start(&self, _mmtk: &'static MMTK<Ruby>) {
+ let mut state = self.state.lock().unwrap();
+ state.gc_start_wall = Some(std::time::Instant::now());
+ }
+
+ fn on_gc_end(&self, mmtk: &'static MMTK<Ruby>) {
+ // Skip nursery-only GCs for generational plans. The heap resizing
+ // decision is driven by the (much more expensive) full collections
+ // where the signal-to-noise ratio is high enough to be useful.
+ if let Some(gen_plan) = mmtk.get_plan().generational() {
+ if gen_plan.is_current_gc_nursery() {
+ return;
+ }
+ }
+
+ let cfg = Self::get_config();
+ let gc_end_cpu = process_cpu_time_seconds();
+
+ let mut state = self.state.lock().unwrap();
+
+ // Duration of this GC cycle (wall clock).
+ let gc_seconds = state
+ .gc_start_wall
+ .take()
+ .map(|start| start.elapsed().as_secs_f64())
+ .unwrap_or(0.0);
+
+ // Process CPU time elapsed since the previous GC cycle ended. We
+ // require at least one previous end timestamp to produce a valid
+ // sample — without it we cannot compute `T_APP`.
+ if let (Some(last_end), Some(now)) = (state.last_gc_end_cpu, gc_end_cpu) {
+ let app_cpu_seconds = (now - last_end).max(0.0);
+ // Only record non-degenerate samples to avoid poisoning the window
+ // with zero-time entries from back-to-back GCs.
+ if app_cpu_seconds > 0.0 {
+ state.push_sample(
+ GcSample {
+ gc_seconds,
+ app_cpu_seconds,
+ },
+ cfg.window_size,
+ );
+ }
+ }
+ state.last_gc_end_cpu = gc_end_cpu;
+
+ // Compute the new heap size only when we have samples to average over.
+ if let Some(gc_cpu) = state.mean_gc_cpu() {
+ // Drop the lock before doing the (relatively cheap) math and
+ // atomic update; nothing below needs the state.
+ drop(state);
+
+ let overhead_error = gc_cpu - cfg.target_gc_cpu; // Eq. (2)
+ let sigmoid_error = sigmoid(overhead_error); // Eq. (3)
+ let adjustment_factor = sigmoid_error + 0.5; // Eq. (4), range (0.5, 1.5)
+
+ let current = self.target_heap_pages.load(Ordering::Relaxed);
+ let suggested = ((current as f64) * adjustment_factor) as usize; // Eq. (5)
+
+ // Clamp:
+ // - upper bound: configured max
+ // - lower bound: max(1.1 * used, min) — 10% headroom above current
+ // live memory, so we never request a heap so small that GC is
+ // triggered immediately on return from this one.
+ let used = mmtk.get_plan().get_used_pages();
+ let floor = ((used as f64) * 1.1).ceil() as usize;
+ let lower = floor.max(cfg.min_heap_pages).min(cfg.max_heap_pages);
+ let upper = cfg.max_heap_pages;
+ let new_target = suggested.clamp(lower, upper);
+
+ self.target_heap_pages.store(new_target, Ordering::Relaxed);
+
+ info!(
+ "CpuHeapTrigger: gc_cpu={:.4} target={:.4} factor={:.4} \
+ pages {} -> {} (used={}, clamp=[{}, {}])",
+ gc_cpu,
+ cfg.target_gc_cpu,
+ adjustment_factor,
+ current,
+ new_target,
+ used,
+ lower,
+ upper
+ );
+ }
+ }
+
+ fn is_heap_full(&self, plan: &dyn Plan<VM = Ruby>) -> bool {
+ plan.get_reserved_pages() > self.target_heap_pages.load(Ordering::Relaxed)
+ }
+
+ fn get_current_heap_size_in_pages(&self) -> usize {
+ self.target_heap_pages.load(Ordering::Relaxed)
+ }
+
+ fn get_max_heap_size_in_pages(&self) -> usize {
+ Self::get_config().max_heap_pages
+ }
+
+ fn can_heap_size_grow(&self) -> bool {
+ self.target_heap_pages.load(Ordering::Relaxed) < Self::get_config().max_heap_pages
+ }
+}
+
+impl CpuHeapTrigger {
+ fn get_config<'b>() -> &'b CpuHeapTriggerConfig {
+ CPU_HEAP_TRIGGER_CONFIG
+ .get()
+ .expect("Attempt to use CPU_HEAP_TRIGGER_CONFIG before it is initialized")
+ }
+}
+
+/// Standard logistic sigmoid. Returns 0.5 when x == 0, asymptotes to 0 and 1.
+fn sigmoid(x: f64) -> f64 {
+ 1.0 / (1.0 + (-x).exp())
+}
+
+/// Reads the process-wide CPU time as a floating-point number of seconds,
+/// summed across all threads of this process. Returns `None` if the clock
+/// query fails (which should be essentially impossible on supported
+/// platforms).
+fn process_cpu_time_seconds() -> Option<f64> {
+ let mut ts = libc::timespec {
+ tv_sec: 0,
+ tv_nsec: 0,
+ };
+ // SAFETY: `clock_gettime` writes exactly `sizeof(timespec)` bytes to the
+ // pointer we pass, which is a valid local stack allocation.
+ let rc = unsafe { libc::clock_gettime(libc::CLOCK_PROCESS_CPUTIME_ID, &mut ts) };
+ if rc != 0 {
+ return None;
+ }
+ Some((ts.tv_sec as f64) + (ts.tv_nsec as f64) / 1_000_000_000.0)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn sigmoid_is_well_behaved() {
+ assert!((sigmoid(0.0) - 0.5).abs() < 1e-12);
+ assert!(sigmoid(-100.0) < 1e-9);
+ assert!(sigmoid(100.0) > 1.0 - 1e-9);
+ // Monotonic.
+ assert!(sigmoid(-1.0) < sigmoid(0.0));
+ assert!(sigmoid(0.0) < sigmoid(1.0));
+ }
+
+ #[test]
+ fn adjustment_factor_is_within_paper_bounds() {
+ // Eq. (4): adjustment_factor = sigmoid(e) + 0.5 must lie in (0.5, 1.5).
+ for e in [-10.0_f64, -1.0, 0.0, 1.0, 10.0] {
+ let f = sigmoid(e) + 0.5;
+ assert!(f > 0.5 && f < 1.5, "factor {f} out of range for e={e}");
+ }
+ }
+
+ #[test]
+ fn mean_gc_cpu_is_total_weighted() {
+ let mut state = CpuHeapTriggerState::new();
+ state.push_sample(
+ GcSample {
+ gc_seconds: 1.0,
+ app_cpu_seconds: 10.0,
+ },
+ 3,
+ );
+ state.push_sample(
+ GcSample {
+ gc_seconds: 3.0,
+ app_cpu_seconds: 10.0,
+ },
+ 3,
+ );
+ // (1 + 3) / (10 + 10) = 0.2
+ assert!((state.mean_gc_cpu().unwrap() - 0.2).abs() < 1e-12);
+ }
+
+ #[test]
+ fn window_drops_oldest() {
+ let mut state = CpuHeapTriggerState::new();
+ for i in 0..5 {
+ state.push_sample(
+ GcSample {
+ gc_seconds: i as f64,
+ app_cpu_seconds: 1.0,
+ },
+ 3,
+ );
+ }
+ assert_eq!(state.samples.len(), 3);
+ // After pushing 0,1,2,3,4 with window 3, we should have [2,3,4].
+ assert_eq!(state.samples[0].gc_seconds, 2.0);
+ assert_eq!(state.samples[2].gc_seconds, 4.0);
+ }
+
+ #[test]
+ fn no_sample_without_prior_gc() {
+ // First GC cycle cannot produce a sample (no previous end time). The
+ // push happens only when last_gc_end_cpu is Some.
+ let state = CpuHeapTriggerState::new();
+ assert!(state.mean_gc_cpu().is_none());
+ }
+}
diff --git a/gc/mmtk/src/heap/mod.rs b/gc/mmtk/src/heap/mod.rs
new file mode 100644
index 0000000000..05a35efb23
--- /dev/null
+++ b/gc/mmtk/src/heap/mod.rs
@@ -0,0 +1,9 @@
+mod cpu_heap_trigger;
+mod ruby_heap_trigger;
+
+pub use cpu_heap_trigger::CpuHeapTrigger;
+pub use cpu_heap_trigger::CpuHeapTriggerConfig;
+pub use cpu_heap_trigger::CPU_HEAP_TRIGGER_CONFIG;
+pub use ruby_heap_trigger::RubyHeapTrigger;
+pub use ruby_heap_trigger::RubyHeapTriggerConfig;
+pub use ruby_heap_trigger::RUBY_HEAP_TRIGGER_CONFIG;
diff --git a/gc/mmtk/src/heap/ruby_heap_trigger.rs b/gc/mmtk/src/heap/ruby_heap_trigger.rs
new file mode 100644
index 0000000000..fe1130043d
--- /dev/null
+++ b/gc/mmtk/src/heap/ruby_heap_trigger.rs
@@ -0,0 +1,105 @@
+use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::Ordering;
+
+use mmtk::util::heap::GCTriggerPolicy;
+use mmtk::util::heap::SpaceStats;
+use mmtk::Plan;
+use mmtk::MMTK;
+use once_cell::sync::OnceCell;
+
+use crate::Ruby;
+
+pub static RUBY_HEAP_TRIGGER_CONFIG: OnceCell<RubyHeapTriggerConfig> = OnceCell::new();
+
+pub struct RubyHeapTriggerConfig {
+ /// Min heap size
+ pub min_heap_pages: usize,
+ /// Max heap size
+ pub max_heap_pages: usize,
+ /// Minimum ratio of empty space after a GC before the heap will grow
+ pub heap_pages_min_ratio: f64,
+ /// Ratio the heap will grow by
+ pub heap_pages_goal_ratio: f64,
+ /// Maximum ratio of empty space after a GC before the heap will shrink
+ pub heap_pages_max_ratio: f64,
+}
+
+pub struct RubyHeapTrigger {
+ /// Target number of heap pages
+ target_heap_pages: AtomicUsize,
+}
+
+impl GCTriggerPolicy<Ruby> for RubyHeapTrigger {
+ fn is_gc_required(
+ &self,
+ space_full: bool,
+ space: Option<SpaceStats<Ruby>>,
+ plan: &dyn Plan<VM = Ruby>,
+ ) -> bool {
+ // Let the plan decide
+ plan.collection_required(space_full, space)
+ }
+
+ fn on_gc_end(&self, mmtk: &'static MMTK<Ruby>) {
+ if let Some(plan) = mmtk.get_plan().generational() {
+ if plan.is_current_gc_nursery() {
+ // Nursery GC
+ } else {
+ // Full GC
+ }
+
+ panic!("TODO: support for generational GC not implemented")
+ } else {
+ let used_pages = mmtk.get_plan().get_used_pages();
+
+ let target_min =
+ (used_pages as f64 * (1.0 + Self::get_config().heap_pages_min_ratio)) as usize;
+ let target_max =
+ (used_pages as f64 * (1.0 + Self::get_config().heap_pages_max_ratio)) as usize;
+ let new_target =
+ (((used_pages as f64) * (1.0 + Self::get_config().heap_pages_goal_ratio)) as usize)
+ .clamp(
+ Self::get_config().min_heap_pages,
+ Self::get_config().max_heap_pages,
+ );
+
+ if used_pages < target_min || used_pages > target_max {
+ self.target_heap_pages.store(new_target, Ordering::Relaxed);
+ }
+ }
+ }
+
+ fn is_heap_full(&self, plan: &dyn Plan<VM = Ruby>) -> bool {
+ plan.get_reserved_pages() > self.target_heap_pages.load(Ordering::Relaxed)
+ }
+
+ fn get_current_heap_size_in_pages(&self) -> usize {
+ self.target_heap_pages.load(Ordering::Relaxed)
+ }
+
+ fn get_max_heap_size_in_pages(&self) -> usize {
+ Self::get_config().max_heap_pages
+ }
+
+ fn can_heap_size_grow(&self) -> bool {
+ self.target_heap_pages.load(Ordering::Relaxed) < Self::get_config().max_heap_pages
+ }
+}
+
+impl Default for RubyHeapTrigger {
+ fn default() -> Self {
+ let min_heap_pages = Self::get_config().min_heap_pages;
+
+ Self {
+ target_heap_pages: AtomicUsize::new(min_heap_pages),
+ }
+ }
+}
+
+impl RubyHeapTrigger {
+ fn get_config<'b>() -> &'b RubyHeapTriggerConfig {
+ RUBY_HEAP_TRIGGER_CONFIG
+ .get()
+ .expect("Attempt to use RUBY_HEAP_TRIGGER_CONFIG before it is initialized")
+ }
+}
diff --git a/gc/mmtk/src/lib.rs b/gc/mmtk/src/lib.rs
new file mode 100644
index 0000000000..52dc782051
--- /dev/null
+++ b/gc/mmtk/src/lib.rs
@@ -0,0 +1,161 @@
+// Warn about unsafe operations in functions that are already marked as unsafe.
+// This will become default in Rust 2024 edition.
+#![warn(unsafe_op_in_unsafe_fn)]
+
+extern crate libc;
+extern crate mmtk;
+#[macro_use]
+extern crate log;
+extern crate probe;
+
+use std::collections::HashSet;
+use std::panic::PanicHookInfo;
+use std::sync::Mutex;
+use std::thread::ThreadId;
+
+use abi::RubyUpcalls;
+use binding::RubyBinding;
+use binding::RubyBindingFast;
+use binding::RubyConfiguration;
+use mmtk::vm::slot::SimpleSlot;
+use mmtk::vm::slot::UnimplementedMemorySlice;
+use mmtk::vm::VMBinding;
+use mmtk::MMTK;
+use once_cell::sync::OnceCell;
+
+pub mod abi;
+pub mod active_plan;
+pub mod api;
+pub mod binding;
+pub mod collection;
+pub mod heap;
+pub mod object_model;
+pub mod pinning_registry;
+pub mod reference_glue;
+pub mod scanning;
+pub mod utils;
+pub mod weak_proc;
+
+#[derive(Default)]
+pub struct Ruby;
+
+/// Ruby slot type, i.e. a slot that holds a VALUE.
+/// Currently we use SimpleSlot.
+/// It doesn't matter, becaues we have not started using slot-enqueuing, yet.
+pub type RubySlot = SimpleSlot;
+
+/// Ruby memory slice, i.e. an array of VALUEs.
+/// It is used by array-copy barriers which is supposed to perform bettern than copying array
+/// elements one by one. At this moment, we just leave it unimplemented.
+pub type RubyMemorySlice = UnimplementedMemorySlice<RubySlot>;
+
+impl VMBinding for Ruby {
+ type VMObjectModel = object_model::VMObjectModel;
+ type VMScanning = scanning::VMScanning;
+ type VMCollection = collection::VMCollection;
+ type VMActivePlan = active_plan::VMActivePlan;
+ type VMReferenceGlue = reference_glue::VMReferenceGlue;
+
+ type VMSlot = RubySlot;
+ type VMMemorySlice = RubyMemorySlice;
+}
+
+/// The callback for mutator thread panic handler (which calls rb_bug to output
+/// debugging information such as the Ruby backtrace and memory maps).
+/// This is set before BINDING is set because mmtk_init could panic.
+pub static MUTATOR_THREAD_PANIC_HANDLER: OnceCell<extern "C" fn()> = OnceCell::new();
+
+/// The singleton object for the Ruby binding itself.
+pub static BINDING: OnceCell<RubyBinding> = OnceCell::new();
+
+/// Some data needs to be accessed fast.
+/// We sacrifice safety for speed using unsynchronized global variables.
+pub static mut BINDING_FAST: RubyBindingFast = RubyBindingFast::new();
+
+/// Some data needs to be accessed fast.
+pub static CONFIGURATION: RubyConfiguration = RubyConfiguration::new();
+
+pub fn binding<'b>() -> &'b RubyBinding {
+ BINDING
+ .get()
+ .expect("Attempt to use the binding before it is initialization")
+}
+
+pub fn mmtk() -> &'static MMTK<Ruby> {
+ binding().mmtk
+}
+
+pub fn upcalls() -> &'static RubyUpcalls {
+ binding().upcalls()
+}
+
+pub static GC_THREADS: OnceCell<Mutex<HashSet<ThreadId>>> = OnceCell::new();
+
+pub(crate) fn register_gc_thread(thread_id: ThreadId) {
+ let mut gc_threads = GC_THREADS.get().unwrap().lock().unwrap();
+ gc_threads.insert(thread_id);
+}
+
+pub(crate) fn unregister_gc_thread(thread_id: ThreadId) {
+ let mut gc_threads = GC_THREADS.get().unwrap().lock().unwrap();
+ gc_threads.remove(&thread_id);
+}
+
+pub(crate) fn is_gc_thread(thread_id: ThreadId) -> bool {
+ let gc_threads = GC_THREADS.get().unwrap().lock().unwrap();
+ gc_threads.contains(&thread_id)
+}
+
+fn handle_gc_thread_panic(panic_info: &PanicHookInfo) {
+ eprintln!("ERROR: An MMTk GC thread panicked. This is a bug.");
+ eprintln!("{panic_info}");
+
+ let bt = std::backtrace::Backtrace::capture();
+ match bt.status() {
+ std::backtrace::BacktraceStatus::Unsupported => {
+ eprintln!("Backtrace is unsupported.")
+ }
+ std::backtrace::BacktraceStatus::Disabled => {
+ eprintln!("Backtrace is disabled.");
+ eprintln!("run with `RUST_BACKTRACE=1` environment variable to display a backtrace");
+ }
+ std::backtrace::BacktraceStatus::Captured => {
+ eprintln!("{bt}");
+ }
+ s => {
+ eprintln!("Unknown backtrace status: {s:?}");
+ }
+ }
+}
+
+pub(crate) fn set_panic_hook() {
+ if GC_THREADS.set(Default::default()).is_err() {
+ return;
+ }
+
+ let old_hook = std::panic::take_hook();
+
+ std::panic::set_hook(Box::new(move |panic_info| {
+ if is_gc_thread(std::thread::current().id()) {
+ handle_gc_thread_panic(panic_info);
+
+ (crate::binding().upcalls().gc_thread_panic_handler)();
+ } else {
+ old_hook(panic_info);
+ (crate::MUTATOR_THREAD_PANIC_HANDLER
+ .get()
+ .expect("MUTATOR_THREAD_PANIC_HANDLER is not set"))();
+ }
+ }));
+}
+
+/// This kind of assertion is enabled if either building in debug mode or the
+/// "extra_assert" feature is enabled.
+#[macro_export]
+macro_rules! extra_assert {
+ ($($arg:tt)*) => {
+ if std::cfg!(any(debug_assertions, feature = "extra_assert")) {
+ std::assert!($($arg)*);
+ }
+ };
+}
diff --git a/gc/mmtk/src/object_model.rs b/gc/mmtk/src/object_model.rs
new file mode 100644
index 0000000000..d673ca11a0
--- /dev/null
+++ b/gc/mmtk/src/object_model.rs
@@ -0,0 +1,124 @@
+use std::ptr::copy_nonoverlapping;
+
+use crate::abi;
+use crate::abi::RubyObjectAccess;
+use crate::abi::MIN_OBJ_ALIGN;
+use crate::abi::OBJREF_OFFSET;
+use crate::Ruby;
+use mmtk::util::constants::BITS_IN_BYTE;
+use mmtk::util::copy::CopySemantics;
+use mmtk::util::copy::GCWorkerCopyContext;
+use mmtk::util::Address;
+use mmtk::util::ObjectReference;
+use mmtk::vm::*;
+
+pub struct VMObjectModel {}
+
+impl VMObjectModel {
+ const OBJREF_OFFSET: usize = abi::OBJREF_OFFSET;
+}
+
+impl ObjectModel<Ruby> for VMObjectModel {
+ const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::side_first();
+
+ // We overwrite the prepended word which were used to hold object sizes.
+ const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec =
+ VMLocalForwardingPointerSpec::in_header(-((OBJREF_OFFSET * BITS_IN_BYTE) as isize));
+
+ const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec =
+ VMLocalForwardingBitsSpec::side_first();
+
+ const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec =
+ VMLocalMarkBitSpec::side_after(Self::LOCAL_FORWARDING_BITS_SPEC.as_spec());
+
+ const LOCAL_PINNING_BIT_SPEC: VMLocalPinningBitSpec =
+ VMLocalPinningBitSpec::side_after(Self::LOCAL_MARK_BIT_SPEC.as_spec());
+
+ const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec =
+ VMLocalLOSMarkNurserySpec::side_after(Self::LOCAL_PINNING_BIT_SPEC.as_spec());
+
+ const UNIFIED_OBJECT_REFERENCE_ADDRESS: bool = false;
+ const OBJECT_REF_OFFSET_LOWER_BOUND: isize = Self::OBJREF_OFFSET as isize;
+
+ const NEED_VO_BITS_DURING_TRACING: bool = true;
+
+ fn copy(
+ from: ObjectReference,
+ semantics: CopySemantics,
+ copy_context: &mut GCWorkerCopyContext<Ruby>,
+ ) -> ObjectReference {
+ let from_acc = RubyObjectAccess::from_objref(from);
+ let from_start = from_acc.obj_start();
+ let object_size = from_acc.object_size();
+ let to_start = copy_context.alloc_copy(from, object_size, MIN_OBJ_ALIGN, 0, semantics);
+ debug_assert!(!to_start.is_zero());
+ let to_payload = to_start.add(OBJREF_OFFSET);
+ unsafe {
+ copy_nonoverlapping::<u8>(from_start.to_ptr(), to_start.to_mut_ptr(), object_size);
+ }
+ let to_obj = unsafe { ObjectReference::from_raw_address_unchecked(to_payload) };
+ copy_context.post_copy(to_obj, object_size, semantics);
+ trace!("Copied object from {} to {}", from, to_obj);
+
+ (crate::binding().upcalls().move_obj_during_marking)(from, to_obj);
+
+ #[cfg(feature = "clear_old_copy")]
+ {
+ trace!(
+ "Clearing old copy {} ({}-{})",
+ from,
+ from_start,
+ from_start + object_size
+ );
+ // For debug purpose, we clear the old copy so that if the Ruby VM reads from the old
+ // copy again, it will likely result in an error.
+ unsafe { std::ptr::write_bytes::<u8>(from_start.to_mut_ptr(), 0, object_size) }
+ }
+
+ to_obj
+ }
+
+ fn copy_to(_from: ObjectReference, _to: ObjectReference, _region: Address) -> Address {
+ unimplemented!(
+ "This function cannot be called because we do not support MarkCompact for Ruby."
+ )
+ }
+
+ fn get_reference_when_copied_to(_from: ObjectReference, _to: Address) -> ObjectReference {
+ unimplemented!(
+ "This function cannot be called because we do not support MarkCompact for Ruby."
+ )
+ }
+
+ fn get_current_size(object: ObjectReference) -> usize {
+ RubyObjectAccess::from_objref(object).object_size()
+ }
+
+ fn get_type_descriptor(_reference: ObjectReference) -> &'static [i8] {
+ todo!()
+ }
+
+ fn ref_to_object_start(object: ObjectReference) -> Address {
+ RubyObjectAccess::from_objref(object).obj_start()
+ }
+
+ fn ref_to_header(object: ObjectReference) -> Address {
+ RubyObjectAccess::from_objref(object).payload_addr()
+ }
+
+ fn get_size_when_copied(object: ObjectReference) -> usize {
+ Self::get_current_size(object)
+ }
+
+ fn get_align_when_copied(_object: ObjectReference) -> usize {
+ todo!()
+ }
+
+ fn get_align_offset_when_copied(_object: ObjectReference) -> usize {
+ todo!()
+ }
+
+ fn dump_object(_object: ObjectReference) {
+ todo!()
+ }
+}
diff --git a/gc/mmtk/src/pinning_registry.rs b/gc/mmtk/src/pinning_registry.rs
new file mode 100644
index 0000000000..b498b508f1
--- /dev/null
+++ b/gc/mmtk/src/pinning_registry.rs
@@ -0,0 +1,187 @@
+use std::sync::Mutex;
+
+use mmtk::memory_manager;
+use mmtk::scheduler::GCWork;
+use mmtk::scheduler::GCWorker;
+use mmtk::scheduler::WorkBucketStage;
+use mmtk::util::ObjectReference;
+use mmtk::util::VMWorkerThread;
+use mmtk::MMTK;
+
+use crate::abi::GCThreadTLS;
+use crate::upcalls;
+use crate::Ruby;
+
+pub struct PinningRegistry {
+ pinning_objs: Mutex<Vec<ObjectReference>>,
+ pinned_objs: Mutex<Vec<ObjectReference>>,
+}
+
+impl PinningRegistry {
+ pub fn new() -> Self {
+ Self {
+ pinning_objs: Default::default(),
+ pinned_objs: Default::default(),
+ }
+ }
+
+ pub fn register(&self, object: ObjectReference) {
+ let mut pinning_objs = self.pinning_objs.lock().unwrap();
+ pinning_objs.push(object);
+ }
+
+ pub fn pin_children(&self, tls: VMWorkerThread) {
+ if !crate::mmtk().get_plan().current_gc_may_move_object() {
+ log::debug!("The current GC is non-moving, skipping pinning children.");
+ return;
+ }
+
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
+ let worker = gc_tls.worker();
+
+ let pinning_objs = self
+ .pinning_objs
+ .try_lock()
+ .expect("PinningRegistry should not have races during GC.");
+
+ let packet_size = 512;
+ let work_packets = pinning_objs
+ .chunks(packet_size)
+ .map(|chunk| {
+ Box::new(PinPinningChildren {
+ pinning_objs: chunk.to_vec(),
+ }) as _
+ })
+ .collect();
+
+ worker.scheduler().work_buckets[WorkBucketStage::Prepare].bulk_add(work_packets);
+ }
+
+ pub fn cleanup(&self, worker: &mut GCWorker<Ruby>) {
+ worker.scheduler().work_buckets[WorkBucketStage::VMRefClosure].add(RemoveDeadPinnings);
+ if crate::mmtk().get_plan().current_gc_may_move_object() {
+ let packet = {
+ let mut pinned_objs = self
+ .pinned_objs
+ .try_lock()
+ .expect("Unexpected contention on pinned_objs");
+ UnpinPinnedObjects {
+ objs: std::mem::take(&mut pinned_objs),
+ }
+ };
+
+ worker.scheduler().work_buckets[WorkBucketStage::VMRefClosure].add(packet);
+ } else {
+ debug!("The current GC is non-moving, skipping unpinning objects.");
+ debug_assert_eq!(
+ {
+ let pinned_objs = self
+ .pinned_objs
+ .try_lock()
+ .expect("Unexpected contention on pinned_objs");
+ pinned_objs.len()
+ },
+ 0
+ );
+ }
+ }
+}
+
+impl Default for PinningRegistry {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+struct PinPinningChildren {
+ pinning_objs: Vec<ObjectReference>,
+}
+
+impl GCWork<Ruby> for PinPinningChildren {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static MMTK<Ruby>) {
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(worker.tls) };
+ let mut pinned_objs = vec![];
+ let mut newly_pinned_objs = vec![];
+
+ let visit_object = |_worker, target_object: ObjectReference, pin| {
+ log::trace!(
+ " -> {} {}",
+ if pin { "(pin)" } else { " " },
+ target_object
+ );
+ if pin {
+ debug_assert!(
+ target_object.get_forwarded_object().is_none(),
+ "Trying to pin {target_object} but has been moved"
+ );
+
+ pinned_objs.push(target_object);
+ }
+ target_object
+ };
+
+ gc_tls
+ .object_closure
+ .set_temporarily_and_run_code(visit_object, || {
+ for obj in self.pinning_objs.iter().cloned() {
+ log::trace!(" Pinning: {}", obj);
+ (upcalls().call_gc_mark_children)(obj);
+ }
+ });
+
+ for target_object in pinned_objs {
+ if memory_manager::pin_object(target_object) {
+ newly_pinned_objs.push(target_object);
+ }
+ }
+
+ let mut pinned_objs = crate::binding()
+ .pinning_registry
+ .pinned_objs
+ .lock()
+ .unwrap();
+ pinned_objs.append(&mut newly_pinned_objs);
+ }
+}
+
+struct RemoveDeadPinnings;
+
+impl GCWork<Ruby> for RemoveDeadPinnings {
+ fn do_work(&mut self, _worker: &mut GCWorker<Ruby>, _mmtk: &'static MMTK<Ruby>) {
+ log::debug!("Removing dead Pinnings...");
+
+ let registry = &crate::binding().pinning_registry;
+ {
+ let mut pinning_objs = registry
+ .pinning_objs
+ .try_lock()
+ .expect("PinningRegistry should not have races during GC.");
+
+ pinning_objs.retain_mut(|obj| {
+ if obj.is_live() {
+ let new_obj = obj.get_forwarded_object().unwrap_or(*obj);
+ *obj = new_obj;
+ true
+ } else {
+ log::trace!(" Dead Pinning removed: {}", *obj);
+ false
+ }
+ });
+ }
+ }
+}
+
+struct UnpinPinnedObjects {
+ objs: Vec<ObjectReference>,
+}
+
+impl GCWork<Ruby> for UnpinPinnedObjects {
+ fn do_work(&mut self, _worker: &mut GCWorker<Ruby>, _mmtk: &'static MMTK<Ruby>) {
+ log::debug!("Unpinning pinned objects...");
+
+ for obj in self.objs.iter() {
+ let unpinned = memory_manager::unpin_object(*obj);
+ debug_assert!(unpinned);
+ }
+ }
+}
diff --git a/gc/mmtk/src/reference_glue.rs b/gc/mmtk/src/reference_glue.rs
new file mode 100644
index 0000000000..1272bd54c1
--- /dev/null
+++ b/gc/mmtk/src/reference_glue.rs
@@ -0,0 +1,26 @@
+use crate::Ruby;
+use mmtk::util::ObjectReference;
+use mmtk::util::VMWorkerThread;
+use mmtk::vm::ReferenceGlue;
+
+pub struct VMReferenceGlue {}
+
+impl ReferenceGlue<Ruby> for VMReferenceGlue {
+ type FinalizableType = ObjectReference;
+
+ fn get_referent(_object: ObjectReference) -> Option<ObjectReference> {
+ unimplemented!()
+ }
+
+ fn set_referent(_reff: ObjectReference, _referent: ObjectReference) {
+ unimplemented!()
+ }
+
+ fn enqueue_references(_references: &[ObjectReference], _tls: VMWorkerThread) {
+ unimplemented!()
+ }
+
+ fn clear_referent(_new_reference: ObjectReference) {
+ unimplemented!()
+ }
+}
diff --git a/gc/mmtk/src/scanning.rs b/gc/mmtk/src/scanning.rs
new file mode 100644
index 0000000000..355a2e7759
--- /dev/null
+++ b/gc/mmtk/src/scanning.rs
@@ -0,0 +1,291 @@
+use crate::abi::GCThreadTLS;
+
+use crate::upcalls;
+use crate::utils::ChunkedVecCollector;
+use crate::Ruby;
+use crate::RubySlot;
+use mmtk::memory_manager;
+use mmtk::scheduler::GCWork;
+use mmtk::scheduler::GCWorker;
+use mmtk::scheduler::WorkBucketStage;
+use mmtk::util::ObjectReference;
+use mmtk::util::VMWorkerThread;
+use mmtk::vm::ObjectTracer;
+use mmtk::vm::RootsWorkFactory;
+use mmtk::vm::Scanning;
+use mmtk::vm::SlotVisitor;
+use mmtk::Mutator;
+
+pub struct VMScanning {}
+
+impl Scanning<Ruby> for VMScanning {
+ const UNIQUE_OBJECT_ENQUEUING: bool = true;
+
+ fn support_slot_enqueuing(_tls: VMWorkerThread, _object: ObjectReference) -> bool {
+ false
+ }
+
+ fn scan_object<EV: SlotVisitor<RubySlot>>(
+ _tls: VMWorkerThread,
+ _object: ObjectReference,
+ _slot_visitor: &mut EV,
+ ) {
+ unreachable!("We have not enabled slot enqueuing for any types, yet.");
+ }
+
+ fn scan_object_and_trace_edges<OT: ObjectTracer>(
+ tls: VMWorkerThread,
+ object: ObjectReference,
+ object_tracer: &mut OT,
+ ) {
+ debug_assert!(
+ mmtk::memory_manager::is_mmtk_object(object.to_raw_address()).is_some(),
+ "Not an MMTk object: {object}",
+ );
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
+ let visit_object = |_worker, target_object: ObjectReference, pin| {
+ trace!(
+ "Tracing edge: {} -> {}{}",
+ object,
+ target_object,
+ if pin { " pin" } else { "" }
+ );
+ debug_assert!(
+ mmtk::memory_manager::is_mmtk_object(target_object.to_raw_address()).is_some(),
+ "Destination is not an MMTk object. Src: {object} dst: {target_object}"
+ );
+
+ debug_assert!(
+ // If we are in a moving GC, all objects should be pinned by PinningRegistry.
+ // If it is requested that target_object be pinned but it is not pinned, then
+ // it is a bug because it could be moved.
+ if crate::mmtk().get_plan().current_gc_may_move_object() && pin {
+ memory_manager::is_pinned(target_object)
+ } else {
+ true
+ },
+ "Object {object} is trying to pin {target_object}"
+ );
+
+ let forwarded_target = object_tracer.trace_object(target_object);
+ if forwarded_target != target_object {
+ trace!(" Forwarded target {target_object} -> {forwarded_target}");
+ }
+ forwarded_target
+ };
+ gc_tls
+ .object_closure
+ .set_temporarily_and_run_code(visit_object, || {
+ (upcalls().call_gc_mark_children)(object);
+
+ if crate::mmtk().get_plan().current_gc_may_move_object() {
+ (upcalls().update_object_references)(object);
+ }
+ });
+ }
+
+ fn notify_initial_thread_scan_complete(_partial_scan: bool, _tls: VMWorkerThread) {
+ // Do nothing
+ }
+
+ fn scan_roots_in_mutator_thread(
+ _tls: VMWorkerThread,
+ _mutator: &'static mut Mutator<Ruby>,
+ mut _factory: impl RootsWorkFactory<RubySlot>,
+ ) {
+ // Do nothing. All stacks (including Ruby stacks and machine stacks) are reachable from
+ // `rb_vm_t` -> ractor -> thread -> fiber -> stacks. It is part of `ScanGCRoots` which
+ // calls `rb_gc_mark_roots` -> `rb_vm_mark`.
+ }
+
+ fn scan_vm_specific_roots(tls: VMWorkerThread, factory: impl RootsWorkFactory<RubySlot>) {
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(tls) };
+ let root_scanning_work_packets: Vec<Box<dyn GCWork<Ruby>>> = vec![
+ Box::new(ScanGCRoots::new(factory.clone())),
+ Box::new(ScanObjspace::new(factory.clone())),
+ ];
+ gc_tls.worker().scheduler().work_buckets[WorkBucketStage::Prepare]
+ .bulk_add(root_scanning_work_packets);
+
+ // Generate WB-unprotected roots scanning work packets
+
+ 'gen_wb_unprotected_work: {
+ let is_nursery_gc = (crate::mmtk().get_plan().generational())
+ .is_some_and(|gen| gen.is_current_gc_nursery());
+ if !is_nursery_gc {
+ break 'gen_wb_unprotected_work;
+ }
+
+ let vecs = {
+ let guard = crate::binding()
+ .wb_unprotected_objects
+ .try_lock()
+ .expect("Someone is holding the lock of wb_unprotected_objects?");
+ if guard.is_empty() {
+ break 'gen_wb_unprotected_work;
+ }
+
+ let mut collector = ChunkedVecCollector::new(128);
+ collector.extend(guard.iter().copied());
+ collector.into_vecs()
+ };
+
+ let packets = vecs
+ .into_iter()
+ .map(|objects| {
+ let factory = factory.clone();
+ Box::new(ScanWbUnprotectedRoots { factory, objects }) as _
+ })
+ .collect::<Vec<_>>();
+
+ gc_tls.worker().scheduler().work_buckets[WorkBucketStage::Prepare].bulk_add(packets);
+ }
+ }
+
+ fn supports_return_barrier() -> bool {
+ false
+ }
+
+ fn prepare_for_roots_re_scanning() {
+ todo!()
+ }
+
+ fn process_weak_refs(
+ worker: &mut GCWorker<Ruby>,
+ tracer_context: impl mmtk::vm::ObjectTracerContext<Ruby>,
+ ) -> bool {
+ crate::binding()
+ .weak_proc
+ .process_weak_stuff(worker, tracer_context);
+ crate::binding().pinning_registry.cleanup(worker);
+ false
+ }
+
+ fn forward_weak_refs(
+ _worker: &mut GCWorker<Ruby>,
+ _tracer_context: impl mmtk::vm::ObjectTracerContext<Ruby>,
+ ) {
+ panic!("We can't use MarkCompact in Ruby.");
+ }
+}
+
+impl VMScanning {
+ const OBJECT_BUFFER_SIZE: usize = 4096;
+
+ fn collect_object_roots_in<F: FnOnce()>(
+ root_scan_kind: &str,
+ gc_tls: &mut GCThreadTLS,
+ factory: &mut impl RootsWorkFactory<RubySlot>,
+ callback: F,
+ ) {
+ let mut buffer: Vec<ObjectReference> = Vec::new();
+ let visit_object = |_, object: ObjectReference, pin| {
+ debug!(
+ "[{}] Visiting object: {}{}",
+ root_scan_kind,
+ object,
+ if pin {
+ "(unmovable root)"
+ } else {
+ "(movable, but we pin it anyway)"
+ }
+ );
+ debug_assert!(
+ mmtk::memory_manager::is_mmtk_object(object.to_raw_address()).is_some(),
+ "Root does not point to MMTk object. object: {object}"
+ );
+ buffer.push(object);
+ if buffer.len() >= Self::OBJECT_BUFFER_SIZE {
+ factory.create_process_pinning_roots_work(std::mem::take(&mut buffer));
+ }
+ object
+ };
+ gc_tls
+ .object_closure
+ .set_temporarily_and_run_code(visit_object, callback);
+
+ if !buffer.is_empty() {
+ factory.create_process_pinning_roots_work(buffer);
+ }
+ }
+}
+
+trait GlobaRootScanningWork {
+ type F: RootsWorkFactory<RubySlot>;
+ const NAME: &'static str;
+
+ fn new(factory: Self::F) -> Self;
+ fn scan_roots();
+ fn roots_work_factory(&mut self) -> &mut Self::F;
+
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(worker.tls) };
+
+ let factory = self.roots_work_factory();
+
+ VMScanning::collect_object_roots_in(Self::NAME, gc_tls, factory, || {
+ Self::scan_roots();
+ });
+ }
+}
+
+macro_rules! define_global_root_scanner {
+ ($name: ident, $code: expr) => {
+ struct $name<F: RootsWorkFactory<RubySlot>> {
+ factory: F,
+ }
+ impl<F: RootsWorkFactory<RubySlot>> GlobaRootScanningWork for $name<F> {
+ type F = F;
+ const NAME: &'static str = stringify!($name);
+ fn new(factory: Self::F) -> Self {
+ Self { factory }
+ }
+ fn scan_roots() {
+ $code
+ }
+ fn roots_work_factory(&mut self) -> &mut Self::F {
+ &mut self.factory
+ }
+ }
+ impl<F: RootsWorkFactory<RubySlot>> GCWork<Ruby> for $name<F> {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, mmtk: &'static mmtk::MMTK<Ruby>) {
+ GlobaRootScanningWork::do_work(self, worker, mmtk);
+ }
+ }
+ };
+}
+
+define_global_root_scanner!(ScanGCRoots, {
+ (crate::upcalls().scan_gc_roots)();
+});
+
+define_global_root_scanner!(ScanObjspace, {
+ (crate::upcalls().scan_objspace)();
+});
+
+struct ScanWbUnprotectedRoots<F: RootsWorkFactory<RubySlot>> {
+ factory: F,
+ objects: Vec<ObjectReference>,
+}
+
+impl<F: RootsWorkFactory<RubySlot>> GCWork<Ruby> for ScanWbUnprotectedRoots<F> {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(worker.tls) };
+ VMScanning::collect_object_roots_in("wb_unprot_roots", gc_tls, &mut self.factory, || {
+ for object in self.objects.iter().copied() {
+ if object.is_reachable() {
+ debug!("[wb_unprot_roots] Visiting WB-unprotected object (parent): {object}");
+ (upcalls().call_gc_mark_children)(object);
+
+ if crate::mmtk().get_plan().current_gc_may_move_object() {
+ (upcalls().update_object_references)(object);
+ }
+ } else {
+ debug!(
+ "[wb_unprot_roots] Skipping young WB-unprotected object (parent): {object}"
+ );
+ }
+ }
+ });
+ }
+}
diff --git a/gc/mmtk/src/utils.rs b/gc/mmtk/src/utils.rs
new file mode 100644
index 0000000000..d1979eaf58
--- /dev/null
+++ b/gc/mmtk/src/utils.rs
@@ -0,0 +1,161 @@
+use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::Ordering;
+
+use atomic_refcell::AtomicRefCell;
+use mmtk::scheduler::GCWork;
+use mmtk::scheduler::GCWorker;
+use mmtk::scheduler::WorkBucketStage;
+
+use crate::Ruby;
+use sysinfo::System;
+
+pub struct ChunkedVecCollector<T> {
+ vecs: Vec<Vec<T>>,
+ current_vec: Vec<T>,
+ chunk_size: usize,
+}
+
+impl<T> ChunkedVecCollector<T> {
+ pub fn new(chunk_size: usize) -> Self {
+ Self {
+ vecs: vec![],
+ current_vec: Vec::with_capacity(chunk_size),
+ chunk_size,
+ }
+ }
+
+ pub fn add(&mut self, item: T) {
+ self.current_vec.push(item);
+ if self.current_vec.len() == self.chunk_size {
+ self.flush();
+ }
+ }
+
+ fn flush(&mut self) {
+ let new_vec = Vec::with_capacity(self.chunk_size);
+ let old_vec = std::mem::replace(&mut self.current_vec, new_vec);
+ self.vecs.push(old_vec);
+ }
+
+ pub fn into_vecs(mut self) -> Vec<Vec<T>> {
+ if !self.current_vec.is_empty() {
+ self.flush();
+ }
+ self.vecs
+ }
+}
+
+impl<A> Extend<A> for ChunkedVecCollector<A> {
+ fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T) {
+ for item in iter {
+ self.add(item);
+ }
+ }
+}
+
+pub struct AfterAll {
+ counter: AtomicUsize,
+ stage: WorkBucketStage,
+ packets: AtomicRefCell<Vec<Box<dyn GCWork<Ruby>>>>,
+}
+
+unsafe impl Sync for AfterAll {}
+
+impl AfterAll {
+ pub fn new(stage: WorkBucketStage) -> Self {
+ Self {
+ counter: AtomicUsize::new(0),
+ stage,
+ packets: AtomicRefCell::new(vec![]),
+ }
+ }
+
+ pub fn add_packets(&self, mut packets: Vec<Box<dyn GCWork<Ruby>>>) {
+ let mut borrow = self.packets.borrow_mut();
+ borrow.append(&mut packets);
+ }
+
+ pub fn count_up(&self, n: usize) {
+ self.counter.fetch_add(n, Ordering::SeqCst);
+ }
+
+ pub fn count_down(&self, worker: &mut GCWorker<Ruby>) {
+ let old = self.counter.fetch_sub(1, Ordering::SeqCst);
+ if old == 1 {
+ let packets = {
+ let mut borrow = self.packets.borrow_mut();
+ std::mem::take(borrow.as_mut())
+ };
+ worker.scheduler().work_buckets[self.stage].bulk_add(packets);
+ }
+ }
+}
+
+pub fn default_heap_max() -> usize {
+ let mut s = System::new();
+ s.refresh_memory();
+ s.total_memory()
+ .checked_mul(80)
+ .and_then(|v| v.checked_div(100))
+ .expect("Invalid Memory size") as usize
+}
+
+pub fn parse_capacity(input: &str) -> Option<usize> {
+ let trimmed = input.trim();
+
+ const KIBIBYTE: usize = 1024;
+ const MEBIBYTE: usize = 1024 * KIBIBYTE;
+ const GIBIBYTE: usize = 1024 * MEBIBYTE;
+
+ let (number, suffix) = if let Some(pos) = trimmed.find(|c: char| !c.is_numeric()) {
+ trimmed.split_at(pos)
+ } else {
+ (trimmed, "")
+ };
+
+ let Ok(v) = number.parse::<usize>() else {
+ return None;
+ };
+
+ match suffix {
+ "GiB" => Some(v * GIBIBYTE),
+ "MiB" => Some(v * MEBIBYTE),
+ "KiB" => Some(v * KIBIBYTE),
+ "" => Some(v),
+ _ => None,
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_parse_capacity_parses_bare_bytes() {
+ assert_eq!(Some(1234), parse_capacity("1234"));
+ }
+
+ #[test]
+ fn test_parse_capacity_parses_kibibytes() {
+ assert_eq!(Some(10240), parse_capacity("10KiB"));
+ }
+
+ #[test]
+ fn test_parse_capacity_parses_mebibytes() {
+ assert_eq!(Some(10485760), parse_capacity("10MiB"))
+ }
+
+ #[test]
+ fn test_parse_capacity_parses_gibibytes() {
+ assert_eq!(Some(10737418240), parse_capacity("10GiB"))
+ }
+
+ #[test]
+ fn test_parse_capacity_parses_nonsense_values() {
+ assert_eq!(None, parse_capacity("notanumber"));
+ assert_eq!(None, parse_capacity("5tartswithanumber"));
+ assert_eq!(None, parse_capacity("number1nthemiddle"));
+ assert_eq!(None, parse_capacity("numberattheend111"));
+ assert_eq!(None, parse_capacity("mult1pl3numb3r5"));
+ }
+}
diff --git a/gc/mmtk/src/weak_proc.rs b/gc/mmtk/src/weak_proc.rs
new file mode 100644
index 0000000000..d38dbe04a4
--- /dev/null
+++ b/gc/mmtk/src/weak_proc.rs
@@ -0,0 +1,328 @@
+use std::sync::Mutex;
+
+use mmtk::scheduler::GCWork;
+use mmtk::scheduler::GCWorker;
+use mmtk::scheduler::WorkBucketStage;
+use mmtk::util::ObjectReference;
+use mmtk::vm::ObjectTracerContext;
+
+use crate::abi::GCThreadTLS;
+use crate::upcalls;
+use crate::Ruby;
+
+pub struct WeakProcessor {
+ non_parallel_obj_free_candidates: Mutex<Vec<ObjectReference>>,
+ parallel_obj_free_candidates: Vec<Mutex<Vec<ObjectReference>>>,
+
+ /// Objects that needs `obj_free` called when dying.
+ /// If it is a bottleneck, replace it with a lock-free data structure,
+ /// or add candidates in batch.
+ weak_references: Mutex<Vec<ObjectReference>>,
+}
+
+impl Default for WeakProcessor {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl WeakProcessor {
+ pub fn new() -> Self {
+ Self {
+ non_parallel_obj_free_candidates: Mutex::new(Vec::new()),
+ parallel_obj_free_candidates: vec![Mutex::new(Vec::new())],
+ weak_references: Mutex::new(Vec::new()),
+ }
+ }
+
+ pub fn init_parallel_obj_free_candidates(&mut self, num_workers: usize) {
+ debug_assert_eq!(self.parallel_obj_free_candidates.len(), 1);
+
+ for _ in 1..num_workers {
+ self.parallel_obj_free_candidates
+ .push(Mutex::new(Vec::new()));
+ }
+ }
+
+ /// Add a batch of objects as candidates for `obj_free`.
+ ///
+ /// Amortizes mutex acquisition over the entire batch. Called when a
+ /// mutator's local buffer is flushed (buffer full or stop-the-world).
+ pub fn add_obj_free_candidates_batch(
+ &self,
+ objects: &[ObjectReference],
+ can_parallel_free: bool,
+ ) {
+ if objects.is_empty() {
+ return;
+ }
+
+ if can_parallel_free {
+ let num_buckets = self.parallel_obj_free_candidates.len();
+ for idx in 0..num_buckets {
+ let mut bucket = self.parallel_obj_free_candidates[idx].lock().unwrap();
+ for (i, &obj) in objects.iter().enumerate() {
+ if i % num_buckets == idx {
+ bucket.push(obj);
+ }
+ }
+ }
+ } else {
+ self.non_parallel_obj_free_candidates
+ .lock()
+ .unwrap()
+ .extend_from_slice(objects);
+ }
+ }
+
+ pub fn get_all_obj_free_candidates(&self) -> Vec<ObjectReference> {
+ // let mut obj_free_candidates = self.obj_free_candidates.lock().unwrap();
+ let mut all_obj_free_candidates = self
+ .non_parallel_obj_free_candidates
+ .lock()
+ .unwrap()
+ .to_vec();
+
+ for candidates_mutex in &self.parallel_obj_free_candidates {
+ all_obj_free_candidates.extend(candidates_mutex.lock().unwrap().to_vec());
+ }
+
+ std::mem::take(all_obj_free_candidates.as_mut())
+ }
+
+ pub fn add_weak_reference(&self, object: ObjectReference) {
+ let mut weak_references = self.weak_references.lock().unwrap();
+ weak_references.push(object);
+ }
+
+ pub fn weak_references_count(&self) -> usize {
+ self.weak_references.lock().unwrap().len()
+ }
+
+ pub fn process_weak_stuff(
+ &self,
+ worker: &mut GCWorker<Ruby>,
+ _tracer_context: impl ObjectTracerContext<Ruby>,
+ ) {
+ worker.add_work(
+ WorkBucketStage::VMRefClosure,
+ ProcessNonParallelObjFreeCanadidates {},
+ );
+
+ for index in 0..self.parallel_obj_free_candidates.len() {
+ worker.add_work(
+ WorkBucketStage::VMRefClosure,
+ ProcessParallelObjFreeCandidates { index },
+ );
+ }
+
+ worker.add_work(WorkBucketStage::VMRefClosure, ProcessWeakReferences);
+
+ worker.add_work(WorkBucketStage::Prepare, UpdateFinalizerObjIdTables);
+
+ let global_tables_count = (crate::upcalls().global_tables_count)();
+ let work_packets = (0..global_tables_count)
+ .map(|i| Box::new(UpdateGlobalTables { idx: i }) as _)
+ .collect();
+
+ worker.scheduler().work_buckets[WorkBucketStage::VMRefClosure].bulk_add(work_packets);
+
+ worker.scheduler().work_buckets[WorkBucketStage::VMRefClosure]
+ .bulk_add(vec![Box::new(UpdateWbUnprotectedObjectsList) as _]);
+ }
+}
+
+fn process_obj_free_candidates(obj_free_candidates: &mut Vec<ObjectReference>) {
+ // Process obj_free
+ let mut new_candidates = Vec::new();
+
+ for object in obj_free_candidates.iter().copied() {
+ if object.is_reachable() {
+ // Forward and add back to the candidate list.
+ let new_object = object.forward();
+ trace!("Forwarding obj_free candidate: {object} -> {new_object}");
+ new_candidates.push(new_object);
+ } else {
+ (upcalls().call_obj_free)(object);
+ }
+ }
+
+ *obj_free_candidates = new_candidates;
+}
+
+struct ProcessParallelObjFreeCandidates {
+ index: usize,
+}
+
+impl GCWork<Ruby> for ProcessParallelObjFreeCandidates {
+ fn do_work(&mut self, _worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let mut obj_free_candidates = crate::binding().weak_proc.parallel_obj_free_candidates
+ [self.index]
+ .try_lock()
+ .expect("Lock for parallel_obj_free_candidates should not be held");
+
+ process_obj_free_candidates(&mut obj_free_candidates);
+ }
+}
+
+struct ProcessNonParallelObjFreeCanadidates;
+
+impl GCWork<Ruby> for ProcessNonParallelObjFreeCanadidates {
+ fn do_work(&mut self, _worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let mut obj_free_candidates = crate::binding()
+ .weak_proc
+ .non_parallel_obj_free_candidates
+ .try_lock()
+ .expect("Lock for non_parallel_obj_free_candidates should not be held");
+
+ process_obj_free_candidates(&mut obj_free_candidates);
+ }
+}
+
+struct ProcessWeakReferences;
+
+impl GCWork<Ruby> for ProcessWeakReferences {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ if crate::mmtk().get_plan().current_gc_may_move_object() {
+ let gc_tls: &mut GCThreadTLS = unsafe { GCThreadTLS::from_vwt_check(worker.tls) };
+
+ let visit_object = |_worker, target_object: ObjectReference, _pin| {
+ debug_assert!(
+ mmtk::memory_manager::is_mmtk_object(target_object.to_raw_address()).is_some(),
+ "Destination is not an MMTk object"
+ );
+
+ target_object
+ .get_forwarded_object()
+ .unwrap_or(target_object)
+ };
+
+ gc_tls
+ .object_closure
+ .set_temporarily_and_run_code(visit_object, || {
+ self.process_weak_references(true);
+ })
+ } else {
+ self.process_weak_references(false);
+ }
+ }
+}
+
+impl ProcessWeakReferences {
+ fn process_weak_references(&mut self, moving_gc: bool) {
+ let mut weak_references = crate::binding()
+ .weak_proc
+ .weak_references
+ .try_lock()
+ .expect("Mutators should not be holding the lock.");
+
+ weak_references.retain_mut(|object_ptr| {
+ let object = object_ptr.get_forwarded_object().unwrap_or(*object_ptr);
+
+ if object != *object_ptr {
+ *object_ptr = object;
+ }
+
+ if object.is_reachable() {
+ (upcalls().handle_weak_references)(object, moving_gc);
+
+ true
+ } else {
+ false
+ }
+ });
+ }
+}
+
+trait GlobalTableProcessingWork {
+ fn process_table(&mut self);
+
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let gc_tls = unsafe { GCThreadTLS::from_vwt_check(worker.tls) };
+
+ // `hash_foreach_replace` depends on `gb_object_moved_p` which has to have the semantics
+ // of `trace_object` due to the way it is used in `UPDATE_IF_MOVED`.
+ let forward_object = |_worker, object: ObjectReference, _pin| {
+ debug_assert!(
+ mmtk::memory_manager::is_mmtk_object(object.to_raw_address()).is_some(),
+ "{object} is not an MMTk object"
+ );
+ let result = object.forward();
+ trace!("Forwarding reference: {object} -> {result}");
+ result
+ };
+
+ gc_tls
+ .object_closure
+ .set_temporarily_and_run_code(forward_object, || {
+ self.process_table();
+ });
+ }
+}
+
+struct UpdateFinalizerObjIdTables;
+impl GlobalTableProcessingWork for UpdateFinalizerObjIdTables {
+ fn process_table(&mut self) {
+ (crate::upcalls().update_finalizer_table)();
+ }
+}
+impl GCWork<Ruby> for UpdateFinalizerObjIdTables {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, mmtk: &'static mmtk::MMTK<Ruby>) {
+ GlobalTableProcessingWork::do_work(self, worker, mmtk);
+ }
+}
+
+struct UpdateGlobalTables {
+ idx: i32,
+}
+impl GlobalTableProcessingWork for UpdateGlobalTables {
+ fn process_table(&mut self) {
+ (crate::upcalls().update_global_tables)(
+ self.idx,
+ crate::mmtk().get_plan().current_gc_may_move_object(),
+ )
+ }
+}
+impl GCWork<Ruby> for UpdateGlobalTables {
+ fn do_work(&mut self, worker: &mut GCWorker<Ruby>, mmtk: &'static mmtk::MMTK<Ruby>) {
+ GlobalTableProcessingWork::do_work(self, worker, mmtk);
+ }
+}
+
+struct UpdateWbUnprotectedObjectsList;
+
+impl GCWork<Ruby> for UpdateWbUnprotectedObjectsList {
+ fn do_work(&mut self, _worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
+ let mut objects = crate::binding().wb_unprotected_objects.try_lock().expect(
+ "Someone is holding the lock of wb_unprotected_objects during weak processing phase?",
+ );
+
+ let old_objects = std::mem::take(&mut *objects);
+
+ debug!("Updating {} WB-unprotected objects", old_objects.len());
+
+ for object in old_objects {
+ if object.is_reachable() {
+ // Forward and add back to the candidate list.
+ let new_object = object.forward();
+ trace!("Forwarding WB-unprotected object: {object} -> {new_object}");
+ objects.insert(new_object);
+ } else {
+ trace!("Removing WB-unprotected object from list: {object}");
+ }
+ }
+
+ debug!("Retained {} live WB-unprotected objects.", objects.len());
+ }
+}
+
+// Provide a shorthand `object.forward()`.
+trait Forwardable {
+ fn forward(&self) -> Self;
+}
+
+impl Forwardable for ObjectReference {
+ fn forward(&self) -> Self {
+ self.get_forwarded_object().unwrap_or(*self)
+ }
+}
diff --git a/gc/wbcheck/extconf.rb b/gc/wbcheck/extconf.rb
new file mode 100644
index 0000000000..18b32d820d
--- /dev/null
+++ b/gc/wbcheck/extconf.rb
@@ -0,0 +1,3 @@
+require_relative '../extconf_base'
+
+create_gc_makefile("wbcheck")
diff --git a/gc/wbcheck/wbcheck.c b/gc/wbcheck/wbcheck.c
new file mode 100644
index 0000000000..a7d4cd6ccf
--- /dev/null
+++ b/gc/wbcheck/wbcheck.c
@@ -0,0 +1,1936 @@
+#include "internal.h"
+#include "ruby/ruby.h"
+#include "ruby/assert.h"
+#include "ruby/atomic.h"
+#include "ruby/debug.h"
+#include "ruby/internal/core/rbasic.h"
+#include "ruby/st.h"
+#include "internal/object.h"
+#include "internal/array.h"
+#include "internal/class.h"
+
+#include "ruby/thread.h"
+#include "gc/gc.h"
+#include "gc/gc_impl.h"
+
+#include <stdbool.h>
+#include <stdarg.h>
+
+// Debug output control
+static bool wbcheck_debug_enabled = false;
+
+// Verification after write barrier control
+static bool wbcheck_verify_after_wb_enabled = false;
+
+// Useless write barrier warning control
+static bool wbcheck_warn_useless_wb_enabled = false;
+
+static void
+wbcheck_debug(const char *format, ...)
+{
+ if (!wbcheck_debug_enabled) return;
+
+ va_list args;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+}
+
+#define WBCHECK_DEBUG(...) do { \
+ if (wbcheck_debug_enabled) { \
+ wbcheck_debug(__VA_ARGS__); \
+ } \
+} while (0)
+
+static void
+wbcheck_debug_obj_info_dump(VALUE obj)
+{
+ if (!wbcheck_debug_enabled) return;
+ char buff[0x100];
+ fprintf(stderr, "%s\n", rb_raw_obj_info(buff, sizeof(buff), obj));
+}
+
+// Forward declaration
+static void lock_and_maybe_gc(void *objspace_ptr);
+static void force_gc(void *objspace_ptr);
+
+// Configure wbcheck from environment variables
+static void
+wbcheck_configure_from_env(void)
+{
+ // Configure debug output based on environment variable
+ const char *debug_env = getenv("WBCHECK_DEBUG");
+ if (debug_env && (strcmp(debug_env, "1") == 0 || strcmp(debug_env, "true") == 0)) {
+ wbcheck_debug_enabled = true;
+ }
+
+ // Configure verification after write barrier based on environment variable
+ const char *verify_after_wb_env = getenv("WBCHECK_VERIFY_AFTER_WB");
+ if (verify_after_wb_env && (strcmp(verify_after_wb_env, "1") == 0 || strcmp(verify_after_wb_env, "true") == 0)) {
+ wbcheck_verify_after_wb_enabled = true;
+ }
+
+ // Configure useless write barrier warnings based on environment variable
+ const char *warn_useless_wb_env = getenv("WBCHECK_WARN_USELESS_WB");
+ if (warn_useless_wb_env && (strcmp(warn_useless_wb_env, "1") == 0 || strcmp(warn_useless_wb_env, "true") == 0)) {
+ wbcheck_warn_useless_wb_enabled = true;
+ }
+}
+
+// Define same heap sizes as the default GC
+static size_t heap_sizes[] = {
+ 32,
+ 40,
+ 48,
+ 56,
+ 64,
+ 72,
+ 80,
+ 96,
+ 128,
+ 160,
+ 256,
+ 512,
+ 640,
+ 768,
+ 1024,
+ 0
+};
+
+#define HEAP_COUNT ((int)(sizeof(heap_sizes) / sizeof(heap_sizes[0])) - 1)
+#define MAX_HEAP_SIZE (heap_sizes[(HEAP_COUNT) - 1])
+
+// Object states for verification tracking
+typedef enum {
+ WBCHECK_STATE_CLEAR, // Just allocated or writebarrier_remember, needs reference capture
+ WBCHECK_STATE_MARKED, // Has valid snapshot, ready for normal operation
+ WBCHECK_STATE_DIRTY // Has seen writebarrier since last snapshot, queued for verification
+} wbcheck_object_state_t;
+
+// Tri-color marking colors
+typedef enum {
+ WBCHECK_COLOR_WHITE, // Unmarked - will be swept
+ WBCHECK_COLOR_GRAY, // Marked but children not processed
+ WBCHECK_COLOR_BLACK // Marked and children processed
+} wbcheck_color_t;
+
+// GC phases
+typedef enum {
+ WBCHECK_PHASE_MUTATOR, // Normal execution
+ WBCHECK_PHASE_SNAPSHOT, // Collecting references for verification
+ WBCHECK_PHASE_FULL_GC // Marking objects during full GC
+} wbcheck_phase_t;
+
+// List of objects
+typedef struct {
+ VALUE *items;
+ size_t count;
+ size_t capacity;
+} wbcheck_object_list_t;
+
+// Helper functions for object list
+static wbcheck_object_list_t *
+wbcheck_object_list_init_with_capacity(size_t capacity)
+{
+ wbcheck_object_list_t *list = calloc(1, sizeof(wbcheck_object_list_t));
+ if (!list) rb_bug("wbcheck: failed to allocate object list structure");
+
+ if (capacity < 4) capacity = 4;
+ list->items = malloc(capacity * sizeof(VALUE));
+ if (!list->items) rb_bug("wbcheck: failed to allocate object list array");
+ list->capacity = capacity;
+ list->count = 0;
+ return list;
+}
+
+static wbcheck_object_list_t *
+wbcheck_object_list_init(void)
+{
+ return wbcheck_object_list_init_with_capacity(4);
+}
+
+static void
+wbcheck_object_list_append(wbcheck_object_list_t *list, VALUE obj)
+{
+ if (list->count >= list->capacity) {
+ size_t new_capacity = list->capacity == 0 ? 4 : list->capacity * 2;
+ VALUE *new_items = realloc(list->items, new_capacity * sizeof(VALUE));
+ if (!new_items) rb_bug("wbcheck: failed to reallocate object list array");
+ list->items = new_items;
+ list->capacity = new_capacity;
+ }
+ list->items[list->count++] = obj;
+}
+
+static void
+wbcheck_object_list_free(wbcheck_object_list_t *list)
+{
+ if (!list) return;
+ if (list->items) {
+ free(list->items);
+ }
+ free(list);
+}
+
+static void
+wbcheck_object_list_debug_print(wbcheck_object_list_t *list)
+{
+ if (!wbcheck_debug_enabled) return;
+ for (size_t i = 0; i < list->count; i++) {
+ char buff[0x100];
+ fprintf(stderr, "-> %s\n", rb_raw_obj_info(buff, sizeof(buff), list->items[i]));
+ }
+}
+
+static bool
+wbcheck_object_list_contains(wbcheck_object_list_t *list, VALUE obj)
+{
+ for (size_t i = 0; i < list->count; i++) {
+ if (list->items[i] == obj) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Information tracked for each object
+typedef struct {
+ size_t alloc_size; // Allocated size (static)
+ bool wb_protected; // Write barrier protection status (static)
+ VALUE finalizers; // Ruby Array of finalizers like [finalizer1, finalizer2, ...]
+ wbcheck_object_list_t *gc_mark_snapshot; // Snapshot of references from last GC mark
+ wbcheck_object_list_t *mark_maybe_snapshot; // Conservative refs reported via mark_maybe; needed for liveness, not verifiable
+ wbcheck_object_list_t *writebarrier_children; // References added via write barriers since last snapshot
+ wbcheck_object_state_t state; // Current state in verification lifecycle
+ wbcheck_color_t color; // Tri-color marking color
+} rb_wbcheck_object_info_t;
+
+// Finalizer job types
+struct wbcheck_final_job {
+ struct wbcheck_final_job *next;
+ enum {
+ WBCHECK_FINAL_JOB_DFREE,
+ WBCHECK_FINAL_JOB_FINALIZE,
+ } kind;
+ union {
+ struct {
+ void (*func)(void *);
+ void *data;
+ } dfree;
+ struct {
+ VALUE finalizer_array;
+ } finalize;
+ } as;
+};
+
+// wbcheck objspace structure to track all objects
+typedef struct {
+ st_table *object_table; // Hash table to track all allocated objects (VALUE -> rb_wbcheck_object_info_t*)
+ wbcheck_object_list_t *objects_to_capture; // Objects that need initial reference capture
+ wbcheck_object_list_t *objects_to_verify; // Objects that need verification after write barriers
+ wbcheck_object_list_t *current_refs; // Current list for collecting references during marking
+ wbcheck_object_list_t *current_maybe_refs; // Current list for collecting mark_maybe references during marking
+ wbcheck_object_list_t *mark_queue; // Queue of gray objects for tri-color marking
+ wbcheck_object_list_t *weak_references; // Objects holding weak references, found during marking
+ wbcheck_phase_t phase; // Current GC phase
+ bool gc_enabled; // Whether GC is allowed to run
+ bool gc_stress; // GC stress mode (run GC on every allocation)
+ size_t gc_threshold; // Trigger GC when object count reaches this
+ size_t missed_write_barrier_parents; // Number of parent objects with missed write barriers
+ size_t missed_write_barrier_children; // Total number of missed write barriers detected
+ size_t simulated_gc_count; // Simulated GC count incremented on each GC.start
+ bool measure_total_time; // Whether to accumulate :time in stats
+ struct wbcheck_final_job *finalizer_jobs; // Linked list of finalizer jobs
+ rb_nativethread_lock_t finalizer_lock; // Protects finalizer_jobs list
+ rb_postponed_job_handle_t finalizer_postponed_job; // Postponed job handle for finalizers
+} rb_wbcheck_objspace_t;
+
+// Global objspace pointer for accessing from obj_slot_size function
+static rb_wbcheck_objspace_t *wbcheck_global_objspace = NULL;
+
+// Forward declarations
+static void wbcheck_foreach_object(rb_wbcheck_objspace_t *objspace, int (*callback)(VALUE obj, rb_wbcheck_object_info_t *info, void *data), void *data);
+static int wbcheck_verify_all_references_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data);
+static int wbcheck_update_all_snapshots_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data);
+static void wbcheck_run_finalizers_for_object(VALUE obj, rb_wbcheck_object_info_t *info);
+static void gc_run_finalizers(void *data);
+static void make_final_job(rb_wbcheck_objspace_t *objspace, VALUE obj, VALUE finalizer_array);
+
+// Helper functions for object tracking
+static rb_wbcheck_object_info_t *
+wbcheck_get_object_info(VALUE obj)
+{
+ // Objspace must be initialized by this point
+ GC_ASSERT(wbcheck_global_objspace);
+
+ st_data_t value;
+ if (st_lookup(wbcheck_global_objspace->object_table, (st_data_t)obj, &value)) {
+ return (rb_wbcheck_object_info_t *)value;
+ }
+
+ fprintf(stderr, "wbcheck: object not found in tracking table\n");
+ char buff[0x100];
+ fprintf(stderr, "%s\n", rb_raw_obj_info(buff, sizeof(buff), obj));
+
+ // Force ASAN crash?
+ ((volatile VALUE *)obj)[0];
+
+ // Object not found in tracking table - this should never happen
+ rb_bug("wbcheck: object not found in tracking table");
+}
+
+static void
+wbcheck_report_error(void *objspace_ptr, VALUE parent_obj, wbcheck_object_list_t *current_refs, wbcheck_object_list_t *gc_mark_snapshot, wbcheck_object_list_t *writebarrier_children, wbcheck_object_list_t *missed_refs)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+
+ rb_wbcheck_object_info_t *parent_info = wbcheck_get_object_info(parent_obj);
+
+ size_t snapshot_count = gc_mark_snapshot ? gc_mark_snapshot->count : 0;
+ size_t wb_count = writebarrier_children ? writebarrier_children->count : 0;
+
+ fprintf(stderr, "WBCHECK ERROR: Missed write barrier detected!\n");
+ fprintf(stderr, " Parent object: %p (wb_protected: %s)\n",
+ (void *)parent_obj, parent_info->wb_protected ? "true" : "false");
+ char buff[0x100];
+ fprintf(stderr, " %s\n", rb_raw_obj_info(buff, sizeof(buff), parent_obj));
+ fprintf(stderr, " Reference counts - snapshot: %zu, writebarrier: %zu, current: %zu, missed: %zu\n",
+ snapshot_count, wb_count, current_refs->count, missed_refs->count);
+
+ for (size_t i = 0; i < missed_refs->count; i++) {
+ VALUE missed_ref = missed_refs->items[i];
+ char buff[0x100];
+ fprintf(stderr, " Missing reference to: %p\n %s\n", (void *)missed_ref, rb_raw_obj_info(buff, sizeof(buff), missed_ref));
+ }
+
+ fprintf(stderr, "\n");
+ objspace->missed_write_barrier_parents++;
+ objspace->missed_write_barrier_children += missed_refs->count;
+}
+
+static void
+wbcheck_compare_references(void *objspace_ptr, VALUE parent_obj, wbcheck_object_list_t *current_refs, wbcheck_object_list_t *gc_mark_snapshot, wbcheck_object_list_t *writebarrier_children)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ (void)objspace;
+
+ size_t snapshot_count = gc_mark_snapshot ? gc_mark_snapshot->count : 0;
+ size_t wb_count = writebarrier_children ? writebarrier_children->count : 0;
+
+ WBCHECK_DEBUG("wbcheck: comparing references for object %p\n", (void *)parent_obj);
+ WBCHECK_DEBUG("wbcheck: current refs: %zu, snapshot refs: %zu, wb refs: %zu\n",
+ current_refs->count, snapshot_count, wb_count);
+
+ // Collect missed references (lazily allocated)
+ wbcheck_object_list_t *missed_refs = NULL;
+
+ // Use circular comparison for better performance when lists are mostly similar
+ size_t snapshot_idx = 0;
+
+ // Check each object in current_refs to see if it's in either stored list
+ for (size_t i = 0; i < current_refs->count; i++) {
+ VALUE current_ref = current_refs->items[i];
+
+ // Usually the lists are nearly identical. We take advantage of this by
+ // attempting to loop over both lists in sequence. When the next element
+ // of the snapshot doesn't match the next element of our current_refs,
+ // we'll loop around the list to try to find it and continue from that
+ // match, so any runs of identical items can be matched efficiently.
+ //
+ // Pathologically this is O(N**2), but is O(N * num_changes)
+ bool found_in_snapshot = false;
+ if (gc_mark_snapshot && snapshot_count > 0) {
+ size_t start_idx = snapshot_idx;
+ do {
+ if (gc_mark_snapshot->items[snapshot_idx] == current_ref) {
+ found_in_snapshot = true;
+ snapshot_idx++;
+ if (snapshot_idx >= snapshot_count) snapshot_idx = 0;
+ break;
+ }
+ snapshot_idx++;
+ if (snapshot_idx >= snapshot_count) snapshot_idx = 0;
+ } while (snapshot_idx != start_idx);
+ }
+
+ if (found_in_snapshot) {
+ continue;
+ }
+
+ // Built-in immortal classes can be assigned via RBASIC_SET_CLASS_RAW,
+ // which bypasses the write barrier. They're pinned as VM roots and
+ // can never be collected, so a missing WB to them is harmless.
+ if (RB_TYPE_P(current_ref, T_CLASS) && FL_TEST_RAW(current_ref, RCLASS_IS_ROOT)) {
+ continue;
+ }
+
+ // Self reference... Weird but okay I guess
+ if (current_ref == parent_obj) {
+ continue;
+ }
+
+
+ // Check if reference exists in writebarrier_children
+ if (writebarrier_children && wbcheck_object_list_contains(writebarrier_children, current_ref)) {
+ continue;
+ }
+
+ // If we get here, the reference wasn't found in either list
+ // Lazily allocate missed_refs list on first miss
+ if (!missed_refs) {
+ missed_refs = wbcheck_object_list_init();
+ }
+ wbcheck_object_list_append(missed_refs, current_ref);
+ }
+
+ // Report any errors found
+ if (missed_refs) {
+ wbcheck_report_error(objspace_ptr, parent_obj, current_refs, gc_mark_snapshot, writebarrier_children, missed_refs);
+ wbcheck_object_list_free(missed_refs);
+ }
+}
+
+static void
+wbcheck_register_object(void *objspace_ptr, VALUE obj, size_t alloc_size, bool wb_protected)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ GC_ASSERT(objspace);
+
+ // Allocate and initialize object info structure
+ rb_wbcheck_object_info_t *info = calloc(1, sizeof(rb_wbcheck_object_info_t));
+ if (!info) rb_bug("wbcheck_register_object: failed to allocate object info");
+
+ info->alloc_size = alloc_size;
+ info->wb_protected = wb_protected;
+ info->finalizers = 0; /* No finalizers initially */
+ info->gc_mark_snapshot = NULL; /* No snapshot initially */
+ info->mark_maybe_snapshot = NULL; /* No mark_maybe snapshot initially */
+ info->writebarrier_children = NULL; /* No write barrier children initially */
+ info->state = WBCHECK_STATE_CLEAR; /* Start in clear state */
+ info->color = WBCHECK_COLOR_BLACK; /* Start as black to survive current GC */
+
+ // Store object info in hash table (VALUE -> rb_wbcheck_object_info_t*)
+ st_insert(objspace->object_table, (st_data_t)obj, (st_data_t)info);
+}
+
+static void
+wbcheck_unregister_object(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ rb_wbcheck_object_info_t *info;
+
+ if (st_delete(objspace->object_table, (st_data_t *)&obj, (st_data_t *)&info)) {
+ // Free object lists if they were allocated
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ wbcheck_object_list_free(info->mark_maybe_snapshot);
+ wbcheck_object_list_free(info->writebarrier_children);
+ free(info);
+ } else {
+ rb_bug("wbcheck_unregister_object: object not found in table");
+ }
+}
+
+// Bootup
+void *
+rb_gc_impl_objspace_alloc(void)
+{
+ wbcheck_configure_from_env();
+
+ rb_wbcheck_objspace_t *objspace = calloc(1, sizeof(rb_wbcheck_objspace_t));
+ if (!objspace) rb_bug("wbcheck: failed to allocate objspace");
+
+ objspace->object_table = st_init_numtable();
+ if (!objspace->object_table) {
+ free(objspace);
+ rb_bug("wbcheck: failed to create object table");
+ }
+
+ objspace->objects_to_capture = wbcheck_object_list_init(); // Initialize empty list
+ objspace->objects_to_verify = wbcheck_object_list_init(); // Initialize empty list
+ objspace->current_refs = NULL; // No current refs initially
+ objspace->current_maybe_refs = NULL; // No current maybe refs initially
+ objspace->mark_queue = wbcheck_object_list_init(); // Initialize mark queue
+ objspace->weak_references = wbcheck_object_list_init(); // Initialize weak references array
+ objspace->phase = WBCHECK_PHASE_MUTATOR; // Start in mutator phase
+ objspace->gc_enabled = true; // GC enabled by default (like default GC)
+ objspace->gc_stress = false; // GC stress disabled by default
+ objspace->gc_threshold = 1000; // Start with 1000 objects, will adjust after first GC
+ objspace->missed_write_barrier_parents = 0; // No errors found yet
+ objspace->missed_write_barrier_children = 0; // No errors found yet
+ objspace->simulated_gc_count = 0; // Start with GC count of 0
+ objspace->measure_total_time = true; // On by default
+
+ return objspace;
+}
+
+void
+rb_gc_impl_objspace_init(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+
+ // Object table is already initialized in objspace_alloc
+ // Set up global objspace pointer for obj_slot_size function
+ wbcheck_global_objspace = objspace;
+
+ // Initialize postponed job for finalizers
+ rb_native_mutex_initialize(&objspace->finalizer_lock);
+ objspace->finalizer_postponed_job = rb_postponed_job_preregister(0, gc_run_finalizers, objspace);
+}
+
+void *
+rb_gc_impl_ractor_cache_alloc(void *objspace_ptr, void *ractor)
+{
+ // Stub implementation
+ return NULL;
+}
+
+void
+rb_gc_impl_set_params(void *objspace_ptr)
+{
+ // Stub implementation
+}
+
+static VALUE
+gc_verify_internal_consistency(VALUE self)
+{
+ return Qnil;
+}
+
+void
+rb_gc_impl_init(void)
+{
+ VALUE gc_constants = rb_hash_new();
+ //rb_hash_aset(gc_constants, ID2SYM(rb_intern("BASE_SLOT_SIZE")), SIZET2NUM(BASE_SLOT_SIZE));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX])));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), INT2NUM(0));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(MAX_HEAP_SIZE));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_COUNT")), LONG2FIX(HEAP_COUNT));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("SIZE_POOL_COUNT")), LONG2FIX(HEAP_COUNT));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OLD_AGE")), INT2FIX(3));
+ OBJ_FREEZE(gc_constants);
+ rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
+
+ // no-ops for compatibility
+ rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency, 0);
+
+ rb_define_singleton_method(rb_mGC, "compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "auto_compact=", rb_f_notimplement, 1);
+ rb_define_singleton_method(rb_mGC, "latest_compact_info", rb_f_notimplement, 0);
+ rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
+ // Stub implementation
+}
+
+size_t *
+rb_gc_impl_heap_sizes(void *objspace_ptr)
+{
+ return heap_sizes;
+}
+
+// Shutdown
+void
+rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
+{
+ // Stub implementation
+}
+
+void
+rb_gc_impl_objspace_free(void *objspace_ptr)
+{
+ // This should free everything, but we'll just let it leak
+}
+
+void
+rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache)
+{
+ // Stub implementation
+}
+
+// GC
+void
+rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ if (objspace) {
+ objspace->simulated_gc_count++;
+ }
+
+ if (!ruby_native_thread_p()) return;
+
+ unsigned int lev = RB_GC_VM_LOCK();
+ rb_gc_vm_barrier();
+ force_gc(objspace_ptr);
+ RB_GC_VM_UNLOCK(lev);
+}
+
+bool
+rb_gc_impl_during_gc_p(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ return objspace->phase != WBCHECK_PHASE_MUTATOR;
+}
+
+static void
+wbcheck_prepare_heap_i(VALUE obj, void *data)
+{
+ rb_gc_prepare_heap_process_object(obj);
+}
+
+void
+rb_gc_impl_prepare_heap(void *objspace_ptr)
+{
+ rb_gc_impl_each_object(objspace_ptr, wbcheck_prepare_heap_i, NULL);
+}
+
+void
+rb_gc_impl_gc_enable(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ objspace->gc_enabled = true;
+}
+
+void
+rb_gc_impl_gc_disable(void *objspace_ptr, bool finish_current_gc)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ objspace->gc_enabled = false;
+}
+
+bool
+rb_gc_impl_gc_enabled_p(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ return objspace->gc_enabled;
+}
+
+void
+rb_gc_impl_stress_set(void *objspace_ptr, VALUE flag)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ objspace->gc_stress = RTEST(flag);
+}
+
+VALUE
+rb_gc_impl_stress_get(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ return objspace->gc_stress ? Qtrue : Qfalse;
+}
+
+VALUE
+rb_gc_impl_config_get(void *objspace_ptr)
+{
+ return rb_hash_new();
+}
+
+void
+rb_gc_impl_config_set(void *objspace_ptr, VALUE hash)
+{
+}
+
+static wbcheck_object_list_t *
+wbcheck_collect_references_from_object(VALUE obj, rb_wbcheck_object_info_t *info)
+{
+ rb_wbcheck_objspace_t *objspace = wbcheck_global_objspace;
+
+ // Use combination of writebarrier children and last snapshot as capacity hint
+ size_t snapshot_count = (info->gc_mark_snapshot) ? info->gc_mark_snapshot->count : 0;
+ size_t wb_children_count = (info->writebarrier_children) ? info->writebarrier_children->count : 0;
+ size_t capacity_hint = snapshot_count + wb_children_count;
+ wbcheck_object_list_t *new_list = wbcheck_object_list_init_with_capacity(capacity_hint);
+
+ // Set up objspace state for marking. current_maybe_refs is allocated lazily
+ // by rb_gc_impl_mark_maybe, since most objects have no conservative refs.
+ objspace->current_refs = new_list;
+ objspace->current_maybe_refs = NULL;
+ objspace->phase = WBCHECK_PHASE_SNAPSHOT;
+
+ // Use the marking infrastructure to collect references
+ rb_gc_mark_children(objspace, obj);
+
+ // Clean up objspace state
+ objspace->phase = WBCHECK_PHASE_MUTATOR;
+ objspace->current_refs = NULL;
+
+ // Update the mark_maybe snapshot in place. These references don't participate
+ // in verification, but we need to keep them so full GC can mark them gray.
+ wbcheck_object_list_free(info->mark_maybe_snapshot);
+ info->mark_maybe_snapshot = objspace->current_maybe_refs;
+ objspace->current_maybe_refs = NULL;
+
+ if (wbcheck_debug_enabled) {
+ WBCHECK_DEBUG("wbcheck: collected %zu references from %p\n", new_list->count, (void *)obj);
+ char buff[0x100];
+ fprintf(stderr, "%s\n", rb_raw_obj_info(buff, sizeof(buff), obj));
+ wbcheck_object_list_debug_print(new_list);
+ }
+
+ return new_list;
+}
+
+static void
+wbcheck_collect_initial_references(void *objspace_ptr, VALUE obj)
+{
+ WBCHECK_DEBUG("wbcheck: collecting initial references from %p:\n", obj);
+ wbcheck_debug_obj_info_dump(obj);
+
+ // Get the object info and set the initial GC mark snapshot
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+ wbcheck_object_list_t *new_list = wbcheck_collect_references_from_object(obj, info);
+ RUBY_ASSERT(!info->gc_mark_snapshot);
+ RUBY_ASSERT(info->state == WBCHECK_STATE_CLEAR);
+ info->gc_mark_snapshot = new_list; // Set the initial snapshot
+ info->state = WBCHECK_STATE_MARKED; // Transition to marked state
+}
+
+static void
+wbcheck_verify_object_references(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+
+ // Ignore objects which are not write barrier protected
+ if (!info->wb_protected) {
+ return;
+ }
+
+ // We hadn't captured initial references
+ if (info->state == WBCHECK_STATE_CLEAR) {
+ RUBY_ASSERT(!info->gc_mark_snapshot);
+ return;
+ }
+
+ WBCHECK_DEBUG("wbcheck: verifying references for object:\n");
+ wbcheck_debug_obj_info_dump(obj);
+
+ // Get the current references from the object
+ wbcheck_object_list_t *current_refs = wbcheck_collect_references_from_object(obj, info);
+
+ // Check for useless write barriers before clearing them
+ if (wbcheck_warn_useless_wb_enabled && info->writebarrier_children) {
+ for (size_t i = 0; i < info->writebarrier_children->count; i++) {
+ VALUE wb_ref = info->writebarrier_children->items[i];
+ if (!wbcheck_object_list_contains(current_refs, wb_ref)) {
+ fprintf(stderr, "WBCHECK WARNING: Potentially useless write barrier detected for object %p\n", (void *)obj);
+ fprintf(stderr, " Write barrier was recorded for reference to %p, but object no longer references it\n", (void *)wb_ref);
+ char buff[0x100];
+ fprintf(stderr, " Parent: %s\n", rb_raw_obj_info(buff, sizeof(buff), obj));
+ fprintf(stderr, " Stale reference: %s\n", rb_raw_obj_info(buff, sizeof(buff), wb_ref));
+ }
+ }
+ }
+
+ // Compare current_refs against both stored lists to detect missed write barriers
+ wbcheck_compare_references(objspace_ptr, obj, current_refs, info->gc_mark_snapshot, info->writebarrier_children);
+
+ // Update the snapshot with current references and clear write barrier children
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ wbcheck_object_list_free(info->writebarrier_children);
+ info->gc_mark_snapshot = current_refs;
+ info->writebarrier_children = NULL;
+ info->state = WBCHECK_STATE_MARKED; // Back to marked state after verification
+}
+
+// Mark object as gray (add to mark queue)
+static void
+wbcheck_mark_gray(rb_wbcheck_objspace_t *objspace, VALUE obj)
+{
+ if (RB_SPECIAL_CONST_P(obj)) return;
+
+ st_data_t value;
+ if (!st_lookup(objspace->object_table, (st_data_t)obj, &value)) {
+ rb_bug("wbcheck: asked to mark object %p not in our object table", (void *)obj);
+ }
+
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)value;
+ if (info->color != WBCHECK_COLOR_WHITE) {
+ return; // Already marked
+ }
+
+ info->color = WBCHECK_COLOR_GRAY;
+ wbcheck_object_list_append(objspace->mark_queue, obj);
+
+ if (RB_FL_TEST_RAW(obj, RUBY_FL_WEAK_REFERENCE)) {
+ wbcheck_object_list_append(objspace->weak_references, obj);
+ }
+
+ WBCHECK_DEBUG("wbcheck: marked gray: %p\n", (void *)obj);
+}
+
+// Reset all objects to white
+static int
+st_foreach_reset_white(st_data_t key, st_data_t val, st_data_t arg)
+{
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)val;
+ info->color = WBCHECK_COLOR_WHITE;
+ return ST_CONTINUE;
+}
+
+// Mark all finalizer arrays to keep them alive during GC
+static int
+st_foreach_mark_finalizers(st_data_t key, st_data_t val, st_data_t arg)
+{
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)val;
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)arg;
+
+ if (info->finalizers) {
+ wbcheck_mark_gray(objspace, info->finalizers);
+ }
+
+ return ST_CONTINUE;
+}
+
+// Full mark phase using tri-color marking with snapshots
+static void
+wbcheck_mark_phase(rb_wbcheck_objspace_t *objspace)
+{
+ WBCHECK_DEBUG("wbcheck: starting GC mark phase\n");
+
+ objspace->phase = WBCHECK_PHASE_FULL_GC;
+
+ // Clear mark queue and reset all objects to white
+ objspace->mark_queue->count = 0;
+ st_foreach(objspace->object_table, st_foreach_reset_white, 0);
+
+ // Mark all finalizer arrays first to keep them alive
+ st_foreach(objspace->object_table, st_foreach_mark_finalizers, (st_data_t)objspace);
+
+ // Mark finalizer arrays in pending jobs to keep them alive.
+ // No lock needed: all other threads are stopped during GC.
+ struct wbcheck_final_job *job = objspace->finalizer_jobs;
+ while (job != NULL) {
+ switch (job->kind) {
+ case WBCHECK_FINAL_JOB_DFREE:
+ break;
+ case WBCHECK_FINAL_JOB_FINALIZE:
+ wbcheck_mark_gray(objspace, job->as.finalize.finalizer_array);
+ break;
+ default:
+ rb_bug("wbcheck_mark_phase: unknown final job type %d", job->kind);
+ }
+ job = job->next;
+ }
+
+ // Mark roots gray
+ rb_gc_save_machine_context();
+ rb_gc_mark_roots(objspace, NULL);
+
+ // Process gray queue until empty
+ while (objspace->mark_queue->count > 0) {
+ // Get last object from queue (LIFO)
+ VALUE obj = objspace->mark_queue->items[--objspace->mark_queue->count];
+
+ st_data_t value;
+ if (st_lookup(objspace->object_table, (st_data_t)obj, &value)) {
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)value;
+ if (info->color == WBCHECK_COLOR_GRAY) {
+ // Mark all children from snapshot gray
+ if (info->gc_mark_snapshot) {
+ for (size_t i = 0; i < info->gc_mark_snapshot->count; i++) {
+ wbcheck_mark_gray(objspace, info->gc_mark_snapshot->items[i]);
+ }
+ }
+
+ // Conservatively-scanned children must also be kept alive
+ if (info->mark_maybe_snapshot) {
+ for (size_t i = 0; i < info->mark_maybe_snapshot->count; i++) {
+ wbcheck_mark_gray(objspace, info->mark_maybe_snapshot->items[i]);
+ }
+ }
+
+ // Mark this object black
+ info->color = WBCHECK_COLOR_BLACK;
+ WBCHECK_DEBUG("wbcheck: marked black: %p\n", (void *)obj);
+ }
+ }
+ }
+
+ objspace->phase = WBCHECK_PHASE_MUTATOR;
+
+ WBCHECK_DEBUG("wbcheck: tri-color mark phase complete\n");
+}
+
+// Sweep phase callback - free white objects
+static int
+wbcheck_sweep_callback(st_data_t key, st_data_t val, st_data_t arg, int error)
+{
+ VALUE obj = (VALUE)key;
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)val;
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)arg;
+
+ if (info->color == WBCHECK_COLOR_WHITE) {
+ WBCHECK_DEBUG("wbcheck: sweeping unmarked object %p\n", (void *)obj);
+
+ rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_FREEOBJ);
+
+ // Clear weak references first
+ rb_gc_obj_free_vm_weak_references(obj);
+
+ // Queue finalizers for postponed job if they exist
+ if (info->finalizers) {
+ make_final_job(objspace, obj, info->finalizers);
+ rb_postponed_job_trigger(objspace->finalizer_postponed_job);
+ }
+
+ // Call rb_gc_obj_free which handles finalizers/zombies
+ if (rb_gc_obj_free(objspace, obj)) {
+ // Object was actually freed, clean up our tracking
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ wbcheck_object_list_free(info->mark_maybe_snapshot);
+ wbcheck_object_list_free(info->writebarrier_children);
+ free(info);
+
+ // Free the actual object memory
+ free((void *)obj);
+
+ return ST_DELETE; // Remove from hash table
+ } else {
+ // Object became a zombie - it will be freed by postponed job
+ // Remove from tracking since we can't safely access it anymore
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ wbcheck_object_list_free(info->mark_maybe_snapshot);
+ wbcheck_object_list_free(info->writebarrier_children);
+ free(info);
+
+ // Free the actual object memory
+ free((void *)obj);
+
+ return ST_DELETE; // Remove from hash table
+ }
+ }
+
+ return ST_CONTINUE; // Keep marked objects
+}
+
+static void
+wbcheck_sweep_phase(rb_wbcheck_objspace_t *objspace)
+{
+ WBCHECK_DEBUG("wbcheck: starting sweep phase\n");
+
+ size_t objects_before = st_table_size(objspace->object_table);
+
+ // Sweep unmarked objects
+ st_foreach_check(objspace->object_table, wbcheck_sweep_callback, (st_data_t)objspace, 0);
+
+ size_t objects_after = st_table_size(objspace->object_table);
+ size_t freed_objects = objects_before - objects_after;
+
+ // Update GC threshold: 2x the live set after GC
+ objspace->gc_threshold = objects_after * 2;
+
+ WBCHECK_DEBUG("wbcheck: sweep phase complete - freed %zu objects (%zu -> %zu), new threshold: %zu\n",
+ freed_objects, objects_before, objects_after, objspace->gc_threshold);
+}
+
+// Process weak references after marking - call rb_gc_handle_weak_references
+// on each object that was flagged with RUBY_FL_WEAK_REFERENCE and collected
+// during the mark phase.
+static void
+wbcheck_process_weak_references(rb_wbcheck_objspace_t *objspace)
+{
+ WBCHECK_DEBUG("wbcheck: processing %zu weak reference objects\n", objspace->weak_references->count);
+
+ for (size_t i = 0; i < objspace->weak_references->count; i++) {
+ VALUE obj = objspace->weak_references->items[i];
+ rb_gc_handle_weak_references(obj);
+ }
+
+ objspace->weak_references->count = 0;
+}
+
+// Full GC: verify all objects then mark from roots
+static void
+wbcheck_full_gc(rb_wbcheck_objspace_t *objspace)
+{
+ WBCHECK_DEBUG("wbcheck: starting full GC\n");
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_ENTER);
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_START);
+
+ // First, update snapshots for all objects (verify wb_protected ones)
+ WBCHECK_DEBUG("wbcheck: updating snapshots for all objects\n");
+ wbcheck_foreach_object(objspace, wbcheck_update_all_snapshots_callback, objspace);
+
+ // Now start tri-color marking
+ wbcheck_mark_phase(objspace);
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_END_MARK);
+
+ // Process weak references after marking, before sweeping
+ wbcheck_process_weak_references(objspace);
+
+ // Sweep unmarked objects
+ wbcheck_sweep_phase(objspace);
+
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_END_SWEEP);
+ rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_EXIT);
+
+ WBCHECK_DEBUG("wbcheck: full GC complete\n");
+}
+
+static void
+gc_step(void *objspace_ptr, bool force)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+
+ // Not initialized yet
+ if (!objspace) return;
+
+ if (!objspace->gc_enabled && !force) return;
+
+ // Process all objects that need verification after write barriers (if enabled)
+ if (wbcheck_verify_after_wb_enabled) {
+ for (size_t i = 0; i < objspace->objects_to_verify->count; i++) {
+ VALUE obj = objspace->objects_to_verify->items[i];
+ wbcheck_verify_object_references(objspace_ptr, obj);
+ }
+
+ // Clear the list after processing
+ objspace->objects_to_verify->count = 0;
+
+ // If any new errors were detected during verification, exit immediately
+ if (objspace->missed_write_barrier_parents > 0) {
+ rb_bug("wbcheck: missed write barrier detected during immediate verification (WBCHECK_VERIFY_AFTER_WB=1)");
+ }
+ }
+
+ // Process all objects that need initial reference capture
+ for (size_t i = 0; i < objspace->objects_to_capture->count; i++) {
+ VALUE obj = objspace->objects_to_capture->items[i];
+ wbcheck_collect_initial_references(objspace_ptr, obj);
+ }
+
+ // Clear the list after processing
+ objspace->objects_to_capture->count = 0;
+
+ // Run full GC if forced, if we exceed the threshold, or if gc_stress is enabled
+ if (ruby_native_thread_p() &&
+ (force ||
+ (objspace->gc_enabled &&
+ (objspace->gc_stress || st_table_size(objspace->object_table) >= objspace->gc_threshold)))) {
+ wbcheck_full_gc(objspace);
+ }
+
+}
+
+static void
+maybe_gc(void *objspace_ptr)
+{
+ gc_step(objspace_ptr, false);
+}
+
+static void
+force_gc(void *objspace_ptr)
+{
+ gc_step(objspace_ptr, true);
+}
+
+int ruby_thread_has_gvl_p(void);
+
+static void *
+lock_and_maybe_gc_gvl(void *objspace_ptr)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+ rb_gc_vm_barrier();
+
+ maybe_gc(objspace_ptr);
+
+ RB_GC_VM_UNLOCK(lev);
+ return NULL;
+}
+
+static void
+lock_and_maybe_gc(void *objspace_ptr)
+{
+ if (!ruby_native_thread_p()) return;
+
+ if (!ruby_thread_has_gvl_p()) {
+ rb_thread_call_with_gvl(lock_and_maybe_gc_gvl, objspace_ptr);
+ }
+ else {
+ lock_and_maybe_gc_gvl(objspace_ptr);
+ }
+}
+
+VALUE
+rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags, bool wb_protected, size_t alloc_size)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+ rb_gc_vm_barrier();
+
+ // Check if we should trigger GC before allocating
+ maybe_gc(objspace_ptr);
+
+ // Ensure minimum allocation size of BASE_SLOT_SIZE
+ alloc_size = heap_sizes[rb_gc_impl_heap_id_for_size(objspace_ptr, alloc_size)];
+
+ // Allocate memory for the object
+ VALUE *mem = malloc(alloc_size);
+ if (!mem) rb_bug("FIXME: malloc failed");
+
+ // Initialize the object
+ VALUE obj = (VALUE)mem;
+ RBASIC(obj)->flags = flags;
+ *((VALUE *)&RBASIC(obj)->klass) = klass;
+
+ // Register the new object in our tracking table
+ wbcheck_register_object(objspace_ptr, obj, alloc_size, wb_protected);
+
+ // Add this object to the list of objects that need initial reference capture
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ wbcheck_object_list_append(objspace->objects_to_capture, obj);
+
+ RB_GC_VM_UNLOCK(lev);
+ return obj;
+}
+
+size_t
+rb_gc_impl_obj_slot_size(VALUE obj)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+ size_t result = info->alloc_size;
+
+ RB_GC_VM_UNLOCK(lev);
+ return result;
+}
+
+size_t
+rb_gc_impl_heap_id_for_size(void *objspace_ptr, size_t size)
+{
+ for (int i = 0; i < HEAP_COUNT; i++) {
+ if (size <= heap_sizes[i]) return i;
+ }
+ rb_bug("size too big");
+}
+
+bool
+rb_gc_impl_size_allocatable_p(size_t size)
+{
+ // Only allow sizes up to the largest heap size
+ return size <= MAX_HEAP_SIZE;
+}
+
+// Malloc
+void *
+rb_gc_impl_malloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ if (gc_allowed) {
+ lock_and_maybe_gc(objspace_ptr);
+ }
+ return malloc(size);
+}
+
+void *
+rb_gc_impl_calloc(void *objspace_ptr, size_t size, bool gc_allowed)
+{
+ if (gc_allowed) {
+ lock_and_maybe_gc(objspace_ptr);
+ }
+ return calloc(1, size);
+}
+
+void *
+rb_gc_impl_realloc(void *objspace_ptr, void *ptr, size_t new_size, size_t old_size, bool gc_allowed)
+{
+ if (gc_allowed) {
+ lock_and_maybe_gc(objspace_ptr);
+ }
+ return realloc(ptr, new_size);
+}
+
+void
+rb_gc_impl_free(void *objspace_ptr, void *ptr, size_t old_size)
+{
+ free(ptr);
+}
+
+void
+rb_gc_impl_adjust_memory_usage(void *objspace_ptr, ssize_t diff)
+{
+ // For wbcheck, we don't track memory usage
+}
+
+// Marking
+static void
+gc_mark(rb_wbcheck_objspace_t *objspace, VALUE obj)
+{
+ WBCHECK_DEBUG("wbcheck: gc_mark called\n");
+ wbcheck_debug_obj_info_dump(obj);
+
+ if (RB_SPECIAL_CONST_P(obj)) return;
+
+ switch (objspace->phase) {
+ case WBCHECK_PHASE_SNAPSHOT:
+ // Collecting references during verification
+ GC_ASSERT(objspace->current_refs);
+ wbcheck_object_list_append(objspace->current_refs, obj);
+ break;
+ case WBCHECK_PHASE_FULL_GC:
+ // Marking during full GC
+ wbcheck_mark_gray(objspace, obj);
+ break;
+ case WBCHECK_PHASE_MUTATOR:
+ // Should not be called during mutator phase
+ rb_bug("wbcheck: gc_mark called during mutator phase");
+ break;
+ }
+}
+
+void
+rb_gc_impl_mark(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+ gc_mark(objspace, obj);
+}
+
+void
+rb_gc_impl_mark_and_move(void *objspace_ptr, VALUE *ptr)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+ gc_mark(objspace, *ptr);
+}
+
+void
+rb_gc_impl_mark_and_pin(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+ gc_mark(objspace, obj);
+}
+
+void
+rb_gc_impl_mark_maybe(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+
+ if (!rb_gc_impl_pointer_to_heap_p(objspace_ptr, (void *)obj)) return;
+
+ switch (objspace->phase) {
+ case WBCHECK_PHASE_SNAPSHOT:
+ // We don't know if this is actually a reference or just a value
+ // that looks like one, so we can't expect a write barrier for it.
+ // Keep it separate from the verifiable refs, but retain it so full
+ // GC can mark the target gray if it does turn out to be live.
+ if (!objspace->current_maybe_refs) {
+ objspace->current_maybe_refs = wbcheck_object_list_init();
+ }
+ wbcheck_object_list_append(objspace->current_maybe_refs, obj);
+ break;
+ case WBCHECK_PHASE_FULL_GC:
+ wbcheck_mark_gray(objspace, obj);
+ break;
+ case WBCHECK_PHASE_MUTATOR:
+ rb_bug("wbcheck: rb_gc_impl_mark_maybe called during mutator phase");
+ break;
+ }
+}
+
+// Weak references
+void
+rb_gc_impl_declare_weak_references(void *objspace_ptr, VALUE obj)
+{
+ FL_SET_RAW(obj, RUBY_FL_WEAK_REFERENCE);
+}
+
+bool
+rb_gc_impl_handle_weak_references_alive_p(void *objspace_ptr, VALUE obj)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+
+ st_data_t value;
+ if (st_lookup(objspace->object_table, (st_data_t)obj, &value)) {
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)value;
+ return info->color != WBCHECK_COLOR_WHITE;
+ }
+
+ return false;
+}
+
+// Compaction
+void
+rb_gc_impl_register_pinning_obj(void *objspace_ptr, VALUE obj)
+{
+ /* no-op */
+}
+
+bool
+rb_gc_impl_object_moved_p(void *objspace_ptr, VALUE obj)
+{
+ // Stub implementation
+ return false;
+}
+
+VALUE
+rb_gc_impl_location(void *objspace_ptr, VALUE value)
+{
+ // Stub implementation
+ return Qnil;
+}
+
+// Write barriers
+void
+rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
+{
+ if (RB_SPECIAL_CONST_P(b)) return;
+
+ unsigned int lev = RB_GC_VM_LOCK_NO_BARRIER();
+
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+
+ // Get the object info for the parent object (a)
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(a);
+
+ // Only record the write barrier if we have a valid snapshot
+ if (info->state != WBCHECK_STATE_CLEAR) {
+ RUBY_ASSERT(info->gc_mark_snapshot);
+
+ // Initialize writebarrier_children list if it doesn't exist
+ if (!info->writebarrier_children) {
+ info->writebarrier_children = wbcheck_object_list_init();
+ }
+
+ // Add the new reference to the write barrier children list
+ wbcheck_object_list_append(info->writebarrier_children, b);
+
+ WBCHECK_DEBUG("wbcheck: write barrier recorded reference from %p to %p\n", (void *)a, (void *)b);
+
+ // If verification after write barrier is enabled, queue the object for verification
+ if (wbcheck_verify_after_wb_enabled && info->state != WBCHECK_STATE_DIRTY) {
+ WBCHECK_DEBUG("wbcheck: queueing object for verification after write barrier\n");
+ info->state = WBCHECK_STATE_DIRTY; // Mark as dirty
+ wbcheck_object_list_append(objspace->objects_to_verify, a);
+ }
+ } else {
+ WBCHECK_DEBUG("wbcheck: write barrier skipped (snapshot not initialized) from %p to %p\n", (void *)a, (void *)b);
+ }
+
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+}
+
+void
+rb_gc_impl_writebarrier_unprotect(void *objspace_ptr, VALUE obj)
+{
+ WBCHECK_DEBUG("wbcheck: writebarrier_unprotect called on object %p\n", (void *)obj);
+
+ unsigned int lev = RB_GC_VM_LOCK_NO_BARRIER();
+
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+ info->wb_protected = false;
+
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+}
+
+void
+rb_gc_impl_writebarrier_remember(void *objspace_ptr, VALUE obj)
+{
+ WBCHECK_DEBUG("wbcheck: writebarrier_remember called on object %p\n", (void *)obj);
+
+ unsigned int lev = RB_GC_VM_LOCK_NO_BARRIER();
+
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+
+ // Clear existing references since they may be stale
+ if (info->state != WBCHECK_STATE_CLEAR) {
+ RUBY_ASSERT(info->gc_mark_snapshot);
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ info->gc_mark_snapshot = NULL;
+
+ wbcheck_object_list_free(info->mark_maybe_snapshot);
+ info->mark_maybe_snapshot = NULL;
+
+ // Only re-add to objects_to_capture if it had previous snapshot
+ // (new objects don't need to be re-added since they'll be captured at allocation)
+ wbcheck_object_list_append(objspace->objects_to_capture, obj);
+
+ // Also clear write barrier children
+ if (info->writebarrier_children) {
+ wbcheck_object_list_free(info->writebarrier_children);
+ info->writebarrier_children = NULL;
+ }
+
+ // Reset to clear state
+ info->state = WBCHECK_STATE_CLEAR;
+ }
+ RUBY_ASSERT(!info->gc_mark_snapshot);
+ RUBY_ASSERT(!info->mark_maybe_snapshot);
+ RUBY_ASSERT(!info->writebarrier_children);
+
+ RB_GC_VM_UNLOCK_NO_BARRIER(lev);
+}
+
+// Heap walking
+struct wbcheck_foreach_data {
+ int (*callback)(VALUE obj, rb_wbcheck_object_info_t *info, void *data);
+ void *data;
+};
+
+static int
+wbcheck_foreach_object_i(st_data_t key, st_data_t val, st_data_t arg)
+{
+ VALUE obj = (VALUE)key;
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)val;
+ struct wbcheck_foreach_data *foreach_data = (struct wbcheck_foreach_data *)arg;
+
+ return foreach_data->callback(obj, info, foreach_data->data);
+}
+
+static void
+wbcheck_foreach_object(rb_wbcheck_objspace_t *objspace, int (*callback)(VALUE obj, rb_wbcheck_object_info_t *info, void *data), void *data)
+{
+ struct wbcheck_foreach_data foreach_data = {
+ .callback = callback,
+ .data = data
+ };
+
+ st_foreach(objspace->object_table, wbcheck_foreach_object_i, (st_data_t)&foreach_data);
+}
+
+// Helper to collect all objects into a snapshot list
+static int
+wbcheck_snapshot_collector(st_data_t key, st_data_t val, st_data_t arg)
+{
+ VALUE obj = (VALUE)key;
+ wbcheck_object_list_t *snapshot = (wbcheck_object_list_t *)arg;
+ wbcheck_object_list_append(snapshot, obj);
+ return ST_CONTINUE;
+}
+
+// Take a snapshot of all objects for safe iteration
+static wbcheck_object_list_t *
+wbcheck_take_object_snapshot(rb_wbcheck_objspace_t *objspace)
+{
+ size_t object_count = st_table_size(objspace->object_table);
+ wbcheck_object_list_t *snapshot = wbcheck_object_list_init_with_capacity(object_count);
+ st_foreach(objspace->object_table, wbcheck_snapshot_collector, (st_data_t)snapshot);
+ return snapshot;
+}
+
+
+void
+rb_gc_impl_each_objects(void *objspace_ptr, int (*callback)(void *, void *, size_t, void *), void *data)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ GC_ASSERT(objspace);
+
+ wbcheck_object_list_t *snapshot = wbcheck_take_object_snapshot(objspace);
+
+ for (size_t i = 0; i < snapshot->count; i++) {
+ VALUE obj = snapshot->items[i];
+ st_data_t value;
+ if (st_lookup(objspace->object_table, (st_data_t)obj, &value)) {
+ rb_wbcheck_object_info_t *info = (rb_wbcheck_object_info_t *)value;
+ int result = callback(
+ (void *)obj,
+ (void *)((char *)obj + info->alloc_size),
+ info->alloc_size,
+ data
+ );
+ if (result != 0) break;
+ }
+ }
+
+ wbcheck_object_list_free(snapshot);
+}
+
+void
+rb_gc_impl_each_object(void *objspace_ptr, void (*func)(VALUE obj, void *data), void *data)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ GC_ASSERT(objspace);
+
+ wbcheck_object_list_t *snapshot = wbcheck_take_object_snapshot(objspace);
+
+ for (size_t i = 0; i < snapshot->count; i++) {
+ VALUE obj = snapshot->items[i];
+ st_data_t value;
+ if (st_lookup(objspace->object_table, (st_data_t)obj, &value)) {
+ func(obj, data);
+ }
+ }
+
+ wbcheck_object_list_free(snapshot);
+}
+
+static void
+finalizer_jobs_push(rb_wbcheck_objspace_t *objspace, struct wbcheck_final_job *job)
+{
+ rb_native_mutex_lock(&objspace->finalizer_lock);
+ job->next = objspace->finalizer_jobs;
+ objspace->finalizer_jobs = job;
+ rb_native_mutex_unlock(&objspace->finalizer_lock);
+}
+
+static struct wbcheck_final_job *
+finalizer_jobs_pop(rb_wbcheck_objspace_t *objspace)
+{
+ rb_native_mutex_lock(&objspace->finalizer_lock);
+ struct wbcheck_final_job *job = objspace->finalizer_jobs;
+ if (job) {
+ objspace->finalizer_jobs = job->next;
+ }
+ rb_native_mutex_unlock(&objspace->finalizer_lock);
+ return job;
+}
+
+// Finalizers
+void
+rb_gc_impl_make_zombie(void *objspace_ptr, VALUE obj, void (*dfree)(void *), void *data)
+{
+ if (dfree == NULL) return;
+
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+
+ struct wbcheck_final_job *job = malloc(sizeof(struct wbcheck_final_job));
+ job->kind = WBCHECK_FINAL_JOB_DFREE;
+ job->as.dfree.func = dfree;
+ job->as.dfree.data = data;
+
+ finalizer_jobs_push(objspace, job);
+
+ if (!ruby_free_at_exit_p()) {
+ rb_postponed_job_trigger(objspace->finalizer_postponed_job);
+ }
+
+ WBCHECK_DEBUG("wbcheck: made zombie for object %p with dfree function\n", (void *)obj);
+}
+
+VALUE
+rb_gc_impl_define_finalizer(void *objspace_ptr, VALUE obj, VALUE block)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ (void)objspace_ptr;
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+
+ GC_ASSERT(!OBJ_FROZEN(obj));
+
+ RBASIC(obj)->flags |= FL_FINALIZE;
+
+ VALUE table = info->finalizers;
+ VALUE result = block;
+
+ if (!table) {
+ /* First finalizer for this object - store object ID as first element */
+ table = rb_ary_new3(2, rb_obj_id(obj), block);
+ rb_obj_hide(table);
+ info->finalizers = table;
+ } else {
+ /* Check for duplicate finalizers (skip index 0 which is object ID) */
+ long len = RARRAY_LEN(table);
+ long i;
+
+ for (i = 1; i < len; i++) {
+ VALUE recv = RARRAY_AREF(table, i);
+ if (rb_equal(recv, block)) {
+ result = recv; /* Duplicate found, return existing */
+ goto unlock_and_return;
+ }
+ }
+
+ rb_ary_push(table, block);
+ }
+
+unlock_and_return:
+ RB_GC_VM_UNLOCK(lev);
+ return result;
+}
+
+void
+rb_gc_impl_undefine_finalizer(void *objspace_ptr, VALUE obj)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ (void)objspace_ptr;
+ rb_wbcheck_object_info_t *info = wbcheck_get_object_info(obj);
+
+ GC_ASSERT(!OBJ_FROZEN(obj));
+
+ info->finalizers = 0;
+ FL_UNSET(obj, FL_FINALIZE);
+
+ RB_GC_VM_UNLOCK(lev);
+}
+
+void
+rb_gc_impl_copy_finalizer(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ (void)objspace_ptr;
+
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ rb_wbcheck_object_info_t *src_info = wbcheck_get_object_info(obj);
+ rb_wbcheck_object_info_t *dest_info = wbcheck_get_object_info(dest);
+
+ if (src_info->finalizers) {
+ VALUE table = rb_ary_dup(src_info->finalizers);
+ RARRAY_ASET(table, 0, rb_obj_id(dest));
+ rb_obj_hide(table);
+ dest_info->finalizers = table;
+ FL_SET(dest, FL_FINALIZE);
+ }
+
+ RB_GC_VM_UNLOCK(lev);
+}
+
+static VALUE
+wbcheck_get_final(long i, void *data)
+{
+ VALUE table = (VALUE)data;
+
+ return RARRAY_AREF(table, i + 1);
+}
+
+static void
+make_final_job(rb_wbcheck_objspace_t *objspace, VALUE obj, VALUE finalizer_array)
+{
+ RUBY_ASSERT(RB_FL_TEST(obj, FL_FINALIZE));
+ RUBY_ASSERT(RB_BUILTIN_TYPE(finalizer_array) == T_ARRAY);
+
+ RB_FL_UNSET(obj, FL_FINALIZE);
+
+ struct wbcheck_final_job *job = malloc(sizeof(struct wbcheck_final_job));
+ job->kind = WBCHECK_FINAL_JOB_FINALIZE;
+ job->as.finalize.finalizer_array = finalizer_array;
+
+ finalizer_jobs_push(objspace, job);
+}
+
+static void
+gc_run_finalizers(void *data)
+{
+ rb_wbcheck_objspace_t *objspace = data;
+
+ rb_gc_set_pending_interrupt();
+
+ struct wbcheck_final_job *job;
+ while ((job = finalizer_jobs_pop(objspace)) != NULL) {
+ switch (job->kind) {
+ case WBCHECK_FINAL_JOB_DFREE:
+ job->as.dfree.func(job->as.dfree.data);
+ break;
+ case WBCHECK_FINAL_JOB_FINALIZE: {
+ VALUE finalizer_array = job->as.finalize.finalizer_array;
+
+ rb_gc_run_obj_finalizer(
+ RARRAY_AREF(finalizer_array, 0),
+ RARRAY_LEN(finalizer_array) - 1,
+ wbcheck_get_final,
+ (void *)finalizer_array
+ );
+
+ RB_GC_GUARD(finalizer_array);
+ break;
+ }
+ }
+
+ free(job);
+ }
+
+ rb_gc_unset_pending_interrupt();
+}
+
+static void
+wbcheck_run_finalizers_for_object(VALUE obj, rb_wbcheck_object_info_t *info)
+{
+ if (info->finalizers) {
+ VALUE table = info->finalizers;
+ long count = RARRAY_LEN(table) - 1;
+ rb_gc_run_obj_finalizer(RARRAY_AREF(table, 0), count, wbcheck_get_final, (void *)table);
+ FL_UNSET(obj, FL_FINALIZE);
+ }
+ info->finalizers = 0;
+}
+
+static int
+wbcheck_shutdown_call_finalizer_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data)
+{
+ wbcheck_run_finalizers_for_object(obj, info);
+ return ST_CONTINUE; /* Keep iterating through all objects */
+}
+
+static int
+wbcheck_verify_all_references_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data)
+{
+ void *objspace_ptr = data;
+ wbcheck_verify_object_references(objspace_ptr, obj);
+ return ST_CONTINUE;
+}
+
+static int
+wbcheck_update_all_snapshots_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data)
+{
+ void *objspace_ptr = data;
+
+ // For wb_protected objects, do full verification if they have a snapshot
+ if (info->wb_protected && info->state != WBCHECK_STATE_CLEAR) {
+ wbcheck_verify_object_references(objspace_ptr, obj);
+ } else {
+ // For CLEAR objects (wb_protected or not) and non-wb_protected objects, just take a new snapshot
+ wbcheck_object_list_t *current_refs = wbcheck_collect_references_from_object(obj, info);
+ wbcheck_object_list_free(info->gc_mark_snapshot);
+ info->gc_mark_snapshot = current_refs;
+ info->state = WBCHECK_STATE_MARKED;
+ }
+
+ return ST_CONTINUE;
+}
+
+static int
+wbcheck_shutdown_finalizer_callback(VALUE obj, rb_wbcheck_object_info_t *info, void *data)
+{
+ void *objspace_ptr = data;
+
+ if (rb_gc_shutdown_call_finalizer_p(obj)) {
+ WBCHECK_DEBUG("wbcheck: finalizing object during shutdown: %p\n", (void *)obj);
+ rb_gc_obj_free_vm_weak_references(obj);
+ if (rb_gc_obj_free(objspace_ptr, obj)) {
+ RBASIC(obj)->flags = 0;
+ }
+ }
+
+ return ST_CONTINUE;
+}
+
+
+void
+rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = objspace_ptr;
+
+ // Call all finalizers for all objects using our shared iteration helper
+ wbcheck_foreach_object(objspace, wbcheck_shutdown_call_finalizer_callback, NULL);
+
+ // After all finalizers have been called, verify all object references
+ unsigned int verify_lev = RB_GC_VM_LOCK();
+ WBCHECK_DEBUG("wbcheck: verifying references for all objects after finalizers\n");
+ wbcheck_foreach_object(objspace, wbcheck_verify_all_references_callback, objspace_ptr);
+ WBCHECK_DEBUG("wbcheck: finished verifying all object references\n");
+ RB_GC_VM_UNLOCK(verify_lev);
+
+ // Print summary and exit with error code if violations were found
+ if (objspace->missed_write_barrier_parents > 0 || objspace->missed_write_barrier_children > 0) {
+ fprintf(stderr, "WBCHECK SUMMARY: Found %zu objects with missed write barriers (%zu total violations)\n",
+ objspace->missed_write_barrier_parents, objspace->missed_write_barrier_children);
+
+
+ exit(1); // Exit with error code to indicate violations were found
+ } else {
+ WBCHECK_DEBUG("wbcheck: no write barrier violations detected\n");
+ }
+
+ // Call rb_gc_obj_free on objects that need shutdown finalization (File, Data with dfree, etc.)
+ unsigned int lev = RB_GC_VM_LOCK();
+ WBCHECK_DEBUG("wbcheck: calling rb_gc_obj_free on objects that need shutdown finalization\n");
+ wbcheck_foreach_object(objspace, wbcheck_shutdown_finalizer_callback, objspace_ptr);
+ WBCHECK_DEBUG("wbcheck: finished calling rb_gc_obj_free\n");
+
+ // Run any pending finalizer jobs (dfree functions)
+ WBCHECK_DEBUG("wbcheck: running pending finalizer jobs\n");
+ gc_run_finalizers(objspace);
+ WBCHECK_DEBUG("wbcheck: finished running finalizer jobs\n");
+ RB_GC_VM_UNLOCK(lev);
+}
+
+// Forking
+void
+rb_gc_impl_before_fork(void *objspace_ptr)
+{
+ // Stub implementation
+}
+
+void
+rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid)
+{
+ // Stub implementation
+}
+
+// Statistics
+void
+rb_gc_impl_set_measure_total_time(void *objspace_ptr, VALUE flag)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ objspace->measure_total_time = RTEST(flag);
+}
+
+bool
+rb_gc_impl_get_measure_total_time(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ return objspace->measure_total_time;
+}
+
+unsigned long long
+rb_gc_impl_get_total_time(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ return objspace->measure_total_time ? objspace->simulated_gc_count : 0;
+}
+
+size_t
+rb_gc_impl_gc_count(void *objspace_ptr)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ if (objspace) {
+ return objspace->simulated_gc_count;
+ }
+ return 0;
+}
+
+VALUE
+rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE key)
+{
+ // Stub implementation
+ return Qnil;
+}
+
+VALUE
+rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
+{
+ rb_wbcheck_objspace_t *objspace = (rb_wbcheck_objspace_t *)objspace_ptr;
+ GC_ASSERT(objspace);
+
+ VALUE hash = Qnil, key = Qnil;
+
+ if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ hash = hash_or_sym;
+ }
+ else if (SYMBOL_P(hash_or_sym)) {
+ key = hash_or_sym;
+ }
+ else {
+ rb_bug("non-hash or symbol given");
+ }
+
+#define SET(name, attr) \
+ if (key == ID2SYM(rb_intern(#name))) \
+ return SIZET2NUM(attr); \
+ else if (hash != Qnil) \
+ rb_hash_aset(hash, ID2SYM(rb_intern(#name)), SIZET2NUM(attr));
+
+ /* Pretend each GC takes 1ms; :time is reported in milliseconds. */
+ SET(count, objspace->simulated_gc_count);
+ SET(time, objspace->measure_total_time ? objspace->simulated_gc_count : 0);
+ SET(tracked_objects, st_table_size(objspace->object_table));
+#undef SET
+
+ if (!NIL_P(key)) {
+ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
+ }
+
+ rb_hash_aset(hash, ID2SYM(rb_intern("gc_implementation")), rb_str_new_cstr("wbcheck"));
+
+ return hash;
+}
+
+VALUE
+rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
+{
+ if (FIXNUM_P(heap_name) && SYMBOL_P(hash_or_sym)) {
+ int heap_idx = FIX2INT(heap_name);
+ if (heap_idx < 0 || heap_idx >= HEAP_COUNT) {
+ rb_raise(rb_eArgError, "size pool index out of range");
+ }
+
+ if (hash_or_sym == ID2SYM(rb_intern("slot_size"))) {
+ return SIZET2NUM(heap_sizes[heap_idx]);
+ }
+
+ return Qundef;
+ }
+
+ if (RB_TYPE_P(hash_or_sym, T_HASH)) {
+ return hash_or_sym;
+ }
+
+ return Qundef;
+}
+
+const char *
+rb_gc_impl_active_gc_name(void)
+{
+ // Stub implementation
+ return "wbcheck";
+}
+
+// Miscellaneous
+#define WBCHECK_OBJECT_METADATA_ENTRY_COUNT 2
+static struct rb_gc_object_metadata_entry object_metadata_entries[WBCHECK_OBJECT_METADATA_ENTRY_COUNT + 1];
+
+struct rb_gc_object_metadata_entry *
+rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
+{
+ static ID ID_object_id, ID_shareable;
+
+ if (!ID_object_id) {
+ ID_object_id = rb_intern("object_id");
+ ID_shareable = rb_intern("shareable");
+ }
+
+ size_t n = 0;
+
+#define SET_ENTRY(na, v) do { \
+ GC_ASSERT(n < WBCHECK_OBJECT_METADATA_ENTRY_COUNT); \
+ object_metadata_entries[n].name = ID_##na; \
+ object_metadata_entries[n].val = v; \
+ n++; \
+} while (0)
+
+ if (rb_obj_id_p(obj)) SET_ENTRY(object_id, rb_obj_id(obj));
+ if (FL_TEST(obj, FL_SHAREABLE)) SET_ENTRY(shareable, Qtrue);
+#undef SET_ENTRY
+
+ object_metadata_entries[n].name = 0;
+ object_metadata_entries[n].val = 0;
+
+ return object_metadata_entries;
+}
+
+bool
+rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr)
+{
+ GC_ASSERT(wbcheck_global_objspace);
+
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ // Check if this pointer exists in our object tracking table
+ st_data_t value;
+ bool result = st_lookup(wbcheck_global_objspace->object_table, (st_data_t)ptr, &value);
+
+ RB_GC_VM_UNLOCK(lev);
+ return result;
+}
+
+bool
+rb_gc_impl_garbage_object_p(void *objspace_ptr, VALUE obj)
+{
+ unsigned int lev = RB_GC_VM_LOCK();
+
+ // Check if this pointer exists in our object tracking table
+ st_data_t value;
+ bool result = st_lookup(wbcheck_global_objspace->object_table, (st_data_t)obj, &value);
+
+ RB_GC_VM_UNLOCK(lev);
+ return !result;
+}
+
+void
+rb_gc_impl_set_event_hook(void *objspace_ptr, const rb_event_flag_t event)
+{
+ // Stub implementation
+}
+
+void
+rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj)
+{
+ rb_wbcheck_object_info_t *src_info = wbcheck_get_object_info(obj);
+
+ if (!src_info->wb_protected) {
+ rb_gc_impl_writebarrier_unprotect(objspace_ptr, dest);
+ }
+ rb_gc_impl_copy_finalizer(objspace_ptr, dest, obj);
+}
+
diff --git a/gem_prelude.rb b/gem_prelude.rb
index f382021ca3..1b78d80c72 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -4,6 +4,8 @@ rescue LoadError => e
raise unless e.path == 'rubygems'
warn "`RubyGems' were not loaded."
+else
+ require 'bundled_gems'
end if defined?(Gem)
begin
@@ -23,4 +25,3 @@ begin
rescue LoadError
warn "`syntax_suggest' was not loaded."
end if defined?(SyntaxSuggest)
-
diff --git a/gems/bundled_gems b/gems/bundled_gems
index f67edba952..8e244af598 100644
--- a/gems/bundled_gems
+++ b/gems/bundled_gems
@@ -5,18 +5,43 @@
# - repository-url: URL from where clone for test
# - revision: revision in repository-url to test
# if `revision` is not given, "v"+`version` or `version` will be used.
-minitest 5.18.0 https://github.com/minitest/minitest
-power_assert 2.0.3 https://github.com/ruby/power_assert
-rake 13.0.6 https://github.com/ruby/rake
-test-unit 3.5.7 https://github.com/test-unit/test-unit
-rexml 3.2.5 https://github.com/ruby/rexml
-rss 0.2.9 https://github.com/ruby/rss
-net-ftp 0.2.0 https://github.com/ruby/net-ftp
-net-imap 0.3.4 https://github.com/ruby/net-imap
-net-pop 0.1.2 https://github.com/ruby/net-pop
-net-smtp 0.3.3 https://github.com/ruby/net-smtp
-matrix 0.4.2 https://github.com/ruby/matrix
-prime 0.1.2 https://github.com/ruby/prime
-rbs 3.0.4 https://github.com/ruby/rbs 55f8f7d088fa71ced2154be1e28eb0e8af897528
-typeprof 0.21.7 https://github.com/ruby/typeprof
-debug 1.7.1 https://github.com/ruby/debug 65197361213529fb5f0b5f6ec111b4d2688a3887
+
+minitest 6.0.6 https://github.com/minitest/minitest
+power_assert 3.0.1 https://github.com/ruby/power_assert
+rake 13.4.2 https://github.com/ruby/rake
+test-unit 3.7.7 https://github.com/test-unit/test-unit
+rexml 3.4.4 https://github.com/ruby/rexml
+rss 0.3.2 https://github.com/ruby/rss
+net-imap 0.6.4 https://github.com/ruby/net-imap
+net-smtp 0.5.1 https://github.com/ruby/net-smtp
+matrix 0.4.3 https://github.com/ruby/matrix
+prime 0.1.4 https://github.com/ruby/prime
+rbs 4.0.2 https://github.com/ruby/rbs 1582ce76429810b057a2816e5000cf5de4b1363d
+typeprof 0.32.0 https://github.com/ruby/typeprof
+debug 1.11.1 https://github.com/ruby/debug 9dc2024a5a05116b3d38afbc5579d9503d8913f3
+racc 1.8.1 https://github.com/ruby/racc
+mutex_m 0.3.0 https://github.com/ruby/mutex_m
+getoptlong 0.2.1 https://github.com/ruby/getoptlong
+base64 0.3.0 https://github.com/ruby/base64
+bigdecimal 4.1.2 https://github.com/ruby/bigdecimal
+observer 0.1.2 https://github.com/ruby/observer
+abbrev 0.1.2 https://github.com/ruby/abbrev
+resolv-replace 0.2.0 https://github.com/ruby/resolv-replace
+rinda 0.2.0 https://github.com/ruby/rinda
+drb 2.2.3 https://github.com/ruby/drb
+nkf 0.2.0 https://github.com/ruby/nkf
+syslog 0.4.0 https://github.com/ruby/syslog
+csv 3.3.5 https://github.com/ruby/csv
+repl_type_completor 0.1.15 https://github.com/ruby/repl_type_completor
+ostruct 0.6.3 https://github.com/ruby/ostruct
+pstore 0.2.1 https://github.com/ruby/pstore
+benchmark 0.5.0 https://github.com/ruby/benchmark
+logger 1.7.0 https://github.com/ruby/logger
+rdoc 7.2.0 https://github.com/ruby/rdoc 1f93543615928b6d45357432f16ec6006e2d8b1e
+win32ole 1.9.3 https://github.com/ruby/win32ole
+irb 1.18.0 https://github.com/ruby/irb
+reline 0.6.3 https://github.com/ruby/reline
+readline 0.0.4 https://github.com/ruby/readline
+fiddle 1.1.8 https://github.com/ruby/fiddle
+tsort 0.2.0 https://github.com/ruby/tsort
+win32-registry 0.1.2 https://github.com/ruby/win32-registry
diff --git a/gems/lib/core_assertions.rb b/gems/lib/core_assertions.rb
new file mode 100644
index 0000000000..7334063885
--- /dev/null
+++ b/gems/lib/core_assertions.rb
@@ -0,0 +1 @@
+require_relative "../../tool/lib/core_assertions.rb"
diff --git a/gems/lib/envutil.rb b/gems/lib/envutil.rb
new file mode 100644
index 0000000000..d684c22cf2
--- /dev/null
+++ b/gems/lib/envutil.rb
@@ -0,0 +1 @@
+require_relative "../../tool/lib/envutil.rb"
diff --git a/gems/lib/rake/extensiontask.rb b/gems/lib/rake/extensiontask.rb
new file mode 100644
index 0000000000..0ab0cb7b50
--- /dev/null
+++ b/gems/lib/rake/extensiontask.rb
@@ -0,0 +1,14 @@
+require "rake/tasklib" unless defined?(Rake::TaskLib)
+
+module Rake
+ class ExtensionTask < TaskLib
+ def initialize(...)
+ task :compile do |args|
+ puts "Dummy `compile` task defined in #{__FILE__}"
+ puts "#{args.name} => #{args.prereqs.join(' ')}"
+ end
+ end
+
+ def lib_dir; end
+ end
+end
diff --git a/goruby.c b/goruby.c
index 5d45277207..3ca96bfda0 100644
--- a/goruby.c
+++ b/goruby.c
@@ -1,4 +1,4 @@
-static void Init_golf(void);
+static void Init_golf_prelude(void);
static void *goruby_options(int argc, char **argv);
static int goruby_run_node(void *arg);
#define ruby_options goruby_options
@@ -17,14 +17,13 @@ static int goruby_run_node(void *arg);
RUBY_EXTERN void *ruby_options(int argc, char **argv);
RUBY_EXTERN int ruby_run_node(void*);
-RUBY_EXTERN void ruby_init_ext(const char *name, void (*init)(void));
-#include "golf_prelude.c"
+#include "golf_prelude.rbbin"
static VALUE
init_golf(VALUE arg)
{
- Init_golf();
+ Init_golf_prelude();
rb_provide("golf.so");
return arg;
}
@@ -61,7 +60,8 @@ int
goruby_run_node(void *arg)
{
int state;
- if (NIL_P(rb_protect(init_golf, Qtrue, &state))) {
+ if (ruby_executable_node(arg, NULL) &&
+ NIL_P(rb_protect(init_golf, Qtrue, &state))) {
return state == EXIT_SUCCESS ? EXIT_FAILURE : state;
}
return ruby_run_node(arg);
diff --git a/hash.c b/hash.c
index c9f741f2ec..9ba8c3d4fe 100644
--- a/hash.c
+++ b/hash.c
@@ -35,6 +35,7 @@
#include "internal/hash.h"
#include "internal/object.h"
#include "internal/proc.h"
+#include "internal/st.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/time.h"
@@ -44,19 +45,32 @@
#include "ruby/util.h"
#include "ruby_assert.h"
#include "symbol.h"
-#include "transient_heap.h"
#include "ruby/thread_native.h"
#include "ruby/ractor.h"
#include "vm_sync.h"
+#include "builtin.h"
+
+/* Flags of RHash
+ *
+ * 1: RHASH_PASS_AS_KEYWORDS
+ * The hash is flagged as Ruby 2 keywords hash.
+ * 2: RHASH_PROC_DEFAULT
+ * The hash has a default proc (rather than a default value).
+ * 3: RHASH_ST_TABLE_FLAG
+ * The hash uses a ST table (rather than an AR table).
+ * 4-7: RHASH_AR_TABLE_SIZE_MASK
+ * The size of the AR table.
+ * 8-11: RHASH_AR_TABLE_BOUND_MASK
+ * The bounds of the AR table.
+ * 13-19: RHASH_LEV_MASK
+ * The iterational level of the hash. Used to prevent modifications
+ * to the hash during iteration.
+ */
#ifndef HASH_DEBUG
#define HASH_DEBUG 0
#endif
-#if HASH_DEBUG
-#include "internal/gc.h"
-#endif
-
#define SET_DEFAULT(hash, ifnone) ( \
FL_UNSET_RAW(hash, RHASH_PROC_DEFAULT), \
RHASH_SET_IFNONE(hash, ifnone))
@@ -85,6 +99,7 @@ static VALUE rb_hash_s_try_convert(VALUE, VALUE);
* 2. Insert WBs
*/
+/* :nodoc: */
VALUE
rb_hash_freeze(VALUE hash)
{
@@ -92,6 +107,7 @@ rb_hash_freeze(VALUE hash)
}
VALUE rb_cHash;
+VALUE rb_cHash_empty_frozen;
static VALUE envtbl;
static ID id_hash, id_flatten_bang;
@@ -164,7 +180,7 @@ any_hash(VALUE a, st_index_t (*other_func)(VALUE))
hnum = rb_hash_start(hnum);
}
else {
- hnum = RSYMBOL(a)->hashval;
+ hnum = RSHIFT(RSYMBOL(a)->hashval, 1);
}
break;
case T_FIXNUM:
@@ -193,10 +209,26 @@ any_hash(VALUE a, st_index_t (*other_func)(VALUE))
return (long)hnum;
}
+VALUE rb_obj_hash(VALUE obj);
+VALUE rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *cme, int kw_splat);
+
static st_index_t
obj_any_hash(VALUE obj)
{
- VALUE hval = rb_check_funcall_basic_kw(obj, id_hash, rb_mKernel, 0, 0, 0);
+ VALUE hval = Qundef;
+ VALUE klass = CLASS_OF(obj);
+ if (klass) {
+ const rb_callable_method_entry_t *cme = rb_callable_method_entry(klass, id_hash);
+ if (cme && METHOD_ENTRY_BASIC(cme)) {
+ // Optimize away the frame push overhead if it's the default Kernel#hash
+ if (cme->def->type == VM_METHOD_TYPE_CFUNC && cme->def->body.cfunc.func == (rb_cfunc_t)rb_obj_hash) {
+ hval = rb_obj_hash(obj);
+ }
+ else if (RBASIC_CLASS(cme->defined_class) == rb_mKernel) {
+ hval = rb_vm_call0(GET_EC(), obj, id_hash, 0, 0, cme, 0);
+ }
+ }
+ }
if (UNDEF_P(hval)) {
hval = rb_exec_recursive_outer_mid(hash_recursive, obj, 0, id_hash);
@@ -289,40 +321,35 @@ objid_hash(VALUE obj)
#endif
}
-/**
+/*
* call-seq:
- * obj.hash -> integer
- *
- * Generates an Integer 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 along with #eql? by the Hash class to determine if
- * two objects reference the same hash key. Any hash value that exceeds the
- * capacity of an Integer will be truncated before being used.
+ * hash -> integer
*
- * The hash value for an object may not be identical across invocations or
- * implementations of Ruby. If you need a stable identifier across Ruby
- * invocations and implementations you will need to generate one with a custom
- * method.
+ * Returns the integer hash value for +self+;
+ * has the property that if <tt>foo.eql?(bar)</tt>
+ * then <tt>foo.hash == bar.hash</tt>.
*
- * Certain core classes such as Integer use built-in hash calculations and
- * do not call the #hash method when used as a hash key.
+ * \Class Hash uses both #hash and #eql? to determine whether two objects
+ * used as hash keys are to be treated as the same key.
+ * A hash value that exceeds the capacity of an Integer is truncated before being used.
*
- * When implementing your own #hash based on multiple values, the best
- * practice is to combine the class and any values using the hash code of an
- * array:
+ * Many core classes override method Object#hash;
+ * other core classes (e.g., Integer) calculate the hash internally,
+ * and do not call the #hash method when used as a hash key.
*
- * For example:
+ * When implementing #hash for a user-defined class,
+ * best practice is to use Array#hash with the class name and the values
+ * that are important in the instance;
+ * this takes advantage of that method's logic for safely and efficiently
+ * generating a hash value:
*
* def hash
* [self.class, a, b, c].hash
* end
*
- * The reason for this is that the Array#hash method already has logic for
- * safely and efficiently combining multiple hash values.
- *--
- * \private
- *++
+ * The hash value may differ among invocations or implementations of Ruby.
+ * If you need stable hash-like identifiers across Ruby invocations and implementations,
+ * use a custom method to generate them.
*/
VALUE
rb_obj_hash(VALUE obj)
@@ -361,16 +388,17 @@ const struct st_hash_type rb_hashtype_ident = {
rb_ident_hash,
};
+#define RHASH_IDENTHASH_P(hash) (RHASH_TYPE(hash) == &identhash)
+#define RHASH_STRING_KEY_P(hash, key) (!RHASH_IDENTHASH_P(hash) && (rb_obj_class(key) == rb_cString))
+
typedef st_index_t st_hash_t;
/*
* RHASH_AR_TABLE_P(h):
- * * as.ar == NULL or
- * as.ar points ar_table.
- * * as.ar is allocated by transient heap or xmalloc.
+ * RHASH_AR_TABLE points to ar_table.
*
* !RHASH_AR_TABLE_P(h):
- * * as.st points st_table.
+ * RHASH_ST_TABLE points st_table.
*/
#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
@@ -378,22 +406,6 @@ typedef st_index_t st_hash_t;
#define RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->pairs[n])
#define RHASH_AR_CLEARED_HINT 0xff
-typedef struct ar_table_pair_struct {
- VALUE key;
- VALUE val;
-} ar_table_pair;
-
-typedef struct ar_table_struct {
- /* 64bit CPU: 8B * 2 * 8 = 128B */
- ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
-} ar_table;
-
-size_t
-rb_hash_ar_table_size(void)
-{
- return sizeof(ar_table);
-}
-
static inline st_hash_t
ar_do_hash(st_data_t key)
{
@@ -409,13 +421,13 @@ ar_do_hash_hint(st_hash_t hash_value)
static inline ar_hint_t
ar_hint(VALUE hash, unsigned int index)
{
- return RHASH(hash)->ar_hint.ary[index];
+ return RHASH_AR_TABLE(hash)->ar_hint.ary[index];
}
static inline void
ar_hint_set_hint(VALUE hash, unsigned int index, ar_hint_t hint)
{
- RHASH(hash)->ar_hint.ary[index] = hint;
+ RHASH_AR_TABLE(hash)->ar_hint.ary[index] = hint;
}
static inline void
@@ -459,53 +471,11 @@ ar_set_entry(VALUE hash, unsigned int index, st_data_t key, st_data_t val, st_ha
#define RHASH_AR_TABLE_SIZE(h) (HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
RHASH_AR_TABLE_SIZE_RAW(h))
-#define RHASH_AR_TABLE_BOUND_RAW(h) \
- ((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
- (RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
-
-#define RHASH_AR_TABLE_BOUND(h) (HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
- RHASH_AR_TABLE_BOUND_RAW(h))
-
-#define RHASH_ST_TABLE_SET(h, s) rb_hash_st_table_set(h, s)
-#define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
-
#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(HASH_DEBUG, expr, #expr)
#if HASH_DEBUG
#define hash_verify(hash) hash_verify_(hash, __FILE__, __LINE__)
-void
-rb_hash_dump(VALUE hash)
-{
- rb_obj_info_dump(hash);
-
- if (RHASH_AR_TABLE_P(hash)) {
- unsigned i, n = 0, bound = RHASH_AR_TABLE_BOUND(hash);
-
- fprintf(stderr, " size:%u bound:%u\n",
- RHASH_AR_TABLE_SIZE(hash), RHASH_AR_TABLE_BOUND(hash));
-
- for (i=0; i<bound; i++) {
- st_data_t k, v;
-
- if (!ar_cleared_entry(hash, i)) {
- char b1[0x100], b2[0x100];
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- k = pair->key;
- v = pair->val;
- fprintf(stderr, " %d key:%s val:%s hint:%02x\n", i,
- rb_raw_obj_info(b1, 0x100, k),
- rb_raw_obj_info(b2, 0x100, v),
- ar_hint(hash, i));
- n++;
- }
- else {
- fprintf(stderr, " %d empty\n", i);
- }
- }
- }
-}
-
static VALUE
hash_verify_(VALUE hash, const char *file, int line)
{
@@ -535,13 +505,6 @@ hash_verify_(VALUE hash, const char *file, int line)
HASH_ASSERT(RHASH_AR_TABLE_BOUND_RAW(hash) == 0);
}
-#if USE_TRANSIENT_HEAP
- if (RHASH_TRANSIENT_P(hash)) {
- volatile st_data_t MAYBE_UNUSED(key) = RHASH_AR_TABLE_REF(hash, 0)->key; /* read */
- HASH_ASSERT(RHASH_AR_TABLE(hash) != NULL);
- HASH_ASSERT(rb_transient_heap_managed_ptr_p(RHASH_AR_TABLE(hash)));
- }
-#endif
return hash;
}
@@ -550,42 +513,29 @@ hash_verify_(VALUE hash, const char *file, int line)
#endif
static inline int
-RHASH_TABLE_NULL_P(VALUE hash)
-{
- if (RHASH(hash)->as.ar == NULL) {
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-static inline int
RHASH_TABLE_EMPTY_P(VALUE hash)
{
return RHASH_SIZE(hash) == 0;
}
-void
-rb_hash_st_table_set(VALUE hash, st_table *st)
+#define RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
+#define RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
+
+static void
+hash_st_table_init(VALUE hash, const struct st_hash_type *type, st_index_t size)
{
- HASH_ASSERT(st != NULL);
- FL_SET_RAW((hash), RHASH_ST_TABLE_FLAG);
- RHASH(hash)->as.st = st;
+ st_init_existing_table_with_size(RHASH_ST_TABLE(hash), type, size);
+ RHASH_SET_ST_FLAG(hash);
}
static void
-hash_ar_table_set(VALUE hash, ar_table *ar)
+rb_hash_st_table_set(VALUE hash, st_table *st)
{
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- HASH_ASSERT((RHASH_TRANSIENT_P(hash) && ar == NULL) ? FALSE : TRUE);
- RHASH(hash)->as.ar = ar;
- hash_verify(hash);
-}
+ HASH_ASSERT(st != NULL);
+ RHASH_SET_ST_FLAG(hash);
-#define RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
-#define RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
+ *RHASH_ST_TABLE(hash) = *st;
+}
static inline void
RHASH_AR_TABLE_BOUND_SET(VALUE h, st_index_t n)
@@ -638,30 +588,11 @@ RHASH_AR_TABLE_SIZE_DEC(VALUE h)
static inline void
RHASH_AR_TABLE_CLEAR(VALUE h)
{
+ RUBY_ASSERT(rb_gc_obj_slot_size(h) >= sizeof(struct RHash) + sizeof(ar_table));
RBASIC(h)->flags &= ~RHASH_AR_TABLE_SIZE_MASK;
RBASIC(h)->flags &= ~RHASH_AR_TABLE_BOUND_MASK;
- hash_ar_table_set(h, NULL);
-}
-
-static ar_table*
-ar_alloc_table(VALUE hash)
-{
- ar_table *tab = (ar_table*)rb_transient_heap_alloc(hash, sizeof(ar_table));
-
- if (tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
-
- RHASH_AR_TABLE_SIZE_SET(hash, 0);
- RHASH_AR_TABLE_BOUND_SET(hash, 0);
- hash_ar_table_set(hash, tab);
-
- return tab;
+ memset(RHASH_AR_TABLE(h), 0, sizeof(ar_table));
}
NOINLINE(static int ar_equal(VALUE x, VALUE y));
@@ -676,7 +607,7 @@ static unsigned
ar_find_entry_hint(VALUE hash, ar_hint_t hint, st_data_t key)
{
unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
- const ar_hint_t *hints = RHASH(hash)->ar_hint.ary;
+ const ar_hint_t *hints = RHASH_AR_TABLE(hash)->ar_hint.ary;
/* if table is NULL, then bound also should be 0 */
@@ -723,92 +654,85 @@ ar_find_entry(VALUE hash, st_hash_t hash_value, st_data_t key)
}
static inline void
-ar_free_and_clear_table(VALUE hash)
+hash_ar_free_and_clear_table(VALUE hash)
{
- ar_table *tab = RHASH_AR_TABLE(hash);
+ RHASH_AR_TABLE_CLEAR(hash);
- if (tab) {
- if (RHASH_TRANSIENT_P(hash)) {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- else {
- ruby_xfree(RHASH_AR_TABLE(hash));
- }
- RHASH_AR_TABLE_CLEAR(hash);
- }
HASH_ASSERT(RHASH_AR_TABLE_SIZE(hash) == 0);
HASH_ASSERT(RHASH_AR_TABLE_BOUND(hash) == 0);
- HASH_ASSERT(RHASH_TRANSIENT_P(hash) == 0);
}
-static void
-ar_try_convert_table(VALUE hash)
-{
- if (!RHASH_AR_TABLE_P(hash)) return;
+void rb_st_add_direct_with_hash(st_table *tab, st_data_t key, st_data_t value, st_hash_t hash); // st.c
- const unsigned size = RHASH_AR_TABLE_SIZE(hash);
-
- st_table *new_tab;
- st_index_t i;
+enum ar_each_key_type {
+ ar_each_key_copy,
+ ar_each_key_cmp,
+ ar_each_key_insert,
+};
- if (size < RHASH_AR_TABLE_MAX_SIZE) {
- return;
+static inline int
+ar_each_key(ar_table *ar, int max, enum ar_each_key_type type, st_data_t *dst_keys, st_table *new_tab, st_hash_t *hashes)
+{
+ for (int i = 0; i < max; i++) {
+ ar_table_pair *pair = &ar->pairs[i];
+
+ switch (type) {
+ case ar_each_key_copy:
+ dst_keys[i] = pair->key;
+ break;
+ case ar_each_key_cmp:
+ if (dst_keys[i] != pair->key) return 1;
+ break;
+ case ar_each_key_insert:
+ if (UNDEF_P(pair->key)) continue; // deleted entry
+ rb_st_add_direct_with_hash(new_tab, pair->key, pair->val, hashes[i]);
+ break;
+ }
}
- new_tab = st_init_table_with_size(&objhash, size * 2);
-
- for (i = 0; i < RHASH_AR_TABLE_MAX_BOUND; i++) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- RHASH_ST_TABLE_SET(hash, new_tab);
- return;
+ return 0;
}
static st_table *
ar_force_convert_table(VALUE hash, const char *file, int line)
{
- st_table *new_tab;
-
if (RHASH_ST_TABLE_P(hash)) {
return RHASH_ST_TABLE(hash);
}
-
- if (RHASH_AR_TABLE(hash)) {
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
-
-#if defined(RHASH_CONVERT_TABLE_DEBUG) && RHASH_CONVERT_TABLE_DEBUG
- rb_obj_info_dump(hash);
- fprintf(stderr, "force_convert: %s:%d\n", file, line);
- RB_DEBUG_COUNTER_INC(obj_hash_force_convert);
-#endif
-
- new_tab = st_init_table_with_size(&objhash, RHASH_AR_TABLE_SIZE(hash));
-
- for (i = 0; i < bound; i++) {
- if (ar_cleared_entry(hash, i)) continue;
-
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- }
else {
- new_tab = st_init_table(&objhash);
- }
- RHASH_ST_TABLE_SET(hash, new_tab);
-
- return new_tab;
-}
+ ar_table *ar = RHASH_AR_TABLE(hash);
+ st_hash_t hashes[RHASH_AR_TABLE_MAX_SIZE];
+ unsigned int bound, size;
+
+ RUBY_ASSERT(rb_gc_obj_slot_size(hash) >= sizeof(struct RHash) + sizeof(ar_table));
+
+ // prepare hash values
+ do {
+ st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];
+ bound = RHASH_AR_TABLE_BOUND(hash);
+ size = RHASH_AR_TABLE_SIZE(hash);
+ ar_each_key(ar, bound, ar_each_key_copy, keys, NULL, NULL);
+
+ for (unsigned int i = 0; i < bound; i++) {
+ // do_hash calls #hash method and it can modify hash object
+ hashes[i] = UNDEF_P(keys[i]) ? 0 : ar_do_hash(keys[i]);
+ }
-static ar_table *
-hash_ar_table(VALUE hash)
-{
- if (RHASH_TABLE_NULL_P(hash)) {
- ar_alloc_table(hash);
+ // check if modified
+ if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash);
+ if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue;
+ if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue;
+ } while (0);
+
+ // make st
+ st_table tab;
+ st_table *new_tab = &tab;
+ st_init_existing_table_with_size(new_tab, &objhash, size);
+ ar_each_key(ar, bound, ar_each_key_insert, NULL, new_tab, hashes);
+ hash_ar_free_and_clear_table(hash);
+ rb_hash_st_table_set(hash, new_tab);
+ return RHASH_ST_TABLE(hash);
}
- return RHASH_AR_TABLE(hash);
}
static int
@@ -861,7 +785,6 @@ ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash
else {
if (UNLIKELY(bin >= RHASH_AR_TABLE_MAX_BOUND)) {
bin = ar_compact_table(hash);
- hash_ar_table(hash);
}
HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
@@ -872,6 +795,14 @@ ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash
}
}
+static void
+ensure_ar_table(VALUE hash)
+{
+ if (!RHASH_AR_TABLE_P(hash)) {
+ rb_raise(rb_eRuntimeError, "hash representation was changed during iteration");
+ }
+}
+
static int
ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
{
@@ -882,7 +813,10 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
if (ar_cleared_entry(hash, i)) continue;
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- enum st_retval retval = (*func)(pair->key, pair->val, arg, 0);
+ st_data_t key = (st_data_t)pair->key;
+ st_data_t val = (st_data_t)pair->val;
+ enum st_retval retval = (*func)(key, val, arg, 0);
+ ensure_ar_table(hash);
/* pair may be not valid here because of theap */
switch (retval) {
@@ -893,14 +827,13 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
return 0;
case ST_REPLACE:
if (replace) {
- VALUE key = pair->key;
- VALUE val = pair->val;
- retval = (*replace)(&key, &val, arg, TRUE);
-
- // TODO: pair should be same as pair before.
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- pair->key = key;
- pair->val = val;
+ (*replace)(&key, &val, arg, TRUE);
+
+ // Pair should not have moved
+ HASH_ASSERT(pair == RHASH_AR_TABLE_REF(hash, i));
+
+ pair->key = (VALUE)key;
+ pair->val = (VALUE)val;
}
break;
case ST_DELETE:
@@ -957,6 +890,7 @@ ar_foreach_check(VALUE hash, st_foreach_check_callback_func *func, st_data_t arg
hint = ar_hint(hash, i);
retval = (*func)(key, pair->val, arg, 0);
+ ensure_ar_table(hash);
hash_verify(hash);
switch (retval) {
@@ -965,7 +899,7 @@ ar_foreach_check(VALUE hash, st_foreach_check_callback_func *func, st_data_t arg
if (pair->key == never) break;
ret = ar_find_entry_hint(hash, hint, key);
if (ret == RHASH_AR_TABLE_MAX_BOUND) {
- retval = (*func)(0, 0, arg, 1);
+ (*func)(0, 0, arg, 1);
return 2;
}
}
@@ -1006,7 +940,6 @@ ar_update(VALUE hash, st_data_t key,
existing = (bin != RHASH_AR_TABLE_MAX_BOUND) ? TRUE : FALSE;
}
else {
- hash_ar_table(hash); /* allocate ltbl if needed */
existing = FALSE;
}
@@ -1018,6 +951,7 @@ ar_update(VALUE hash, st_data_t key,
old_key = key;
retval = (*func)(&key, &value, arg, existing);
/* pair can be invalid here because of theap */
+ ensure_ar_table(hash);
switch (retval) {
case ST_CONTINUE:
@@ -1055,8 +989,6 @@ ar_insert(VALUE hash, st_data_t key, st_data_t value)
return -1;
}
- hash_ar_table(hash); /* prepare ltbl */
-
bin = ar_find_entry(hash, hash_value, key);
if (bin == RHASH_AR_TABLE_MAX_BOUND) {
if (RHASH_AR_TABLE_SIZE(hash) >= RHASH_AR_TABLE_MAX_SIZE) {
@@ -1064,7 +996,6 @@ ar_insert(VALUE hash, st_data_t key, st_data_t value)
}
else if (bin >= RHASH_AR_TABLE_MAX_BOUND) {
bin = ar_compact_table(hash);
- hash_ar_table(hash);
}
HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
@@ -1198,25 +1129,16 @@ ar_values(VALUE hash, st_data_t *values, st_index_t size)
static ar_table*
ar_copy(VALUE hash1, VALUE hash2)
{
+ RUBY_ASSERT(rb_gc_obj_slot_size(hash1) >= sizeof(struct RHash) + sizeof(ar_table));
ar_table *old_tab = RHASH_AR_TABLE(hash2);
ar_table *new_tab = RHASH_AR_TABLE(hash1);
- if (new_tab == NULL) {
- new_tab = (ar_table*) rb_transient_heap_alloc(hash1, sizeof(ar_table));
- if (new_tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash1);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash1);
- new_tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
- }
-
- *new_tab = *old_tab;
- RHASH(hash1)->ar_hint.word = RHASH(hash2)->ar_hint.word;
- RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
+ unsigned int bound = RHASH_AR_TABLE_BOUND(hash2);
+ new_tab->ar_hint.word = old_tab->ar_hint.word;
+ MEMCPY(&new_tab->pairs, &old_tab->pairs, ar_table_pair, bound);
+ RHASH_AR_TABLE(hash1)->ar_hint.word = RHASH_AR_TABLE(hash2)->ar_hint.word;
+ RHASH_AR_TABLE_BOUND_SET(hash1, bound);
RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
- hash_ar_table_set(hash1, new_tab);
rb_gc_writebarrier_remember(hash1);
@@ -1236,32 +1158,28 @@ ar_clear(VALUE hash)
}
}
-#if USE_TRANSIENT_HEAP
-void
-rb_hash_transient_heap_evacuate(VALUE hash, int promote)
+static void
+hash_st_free(VALUE hash)
{
- if (RHASH_TRANSIENT_P(hash)) {
- ar_table *new_tab;
- ar_table *old_tab = RHASH_AR_TABLE(hash);
+ HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- if (UNLIKELY(old_tab == NULL)) {
- return;
- }
- HASH_ASSERT(old_tab != NULL);
- if (! promote) {
- new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
- if (new_tab == NULL) promote = true;
- }
- if (promote) {
- new_tab = ruby_xmalloc(sizeof(ar_table));
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- *new_tab = *old_tab;
- hash_ar_table_set(hash, new_tab);
+ rb_st_free_embedded_table(RHASH_ST_TABLE(hash));
+}
+
+static void
+hash_st_free_and_clear_table(VALUE hash)
+{
+ hash_st_free(hash);
+ RHASH_ST_CLEAR(hash);
+}
+
+void
+rb_hash_free(VALUE hash)
+{
+ if (RHASH_ST_TABLE_P(hash)) {
+ hash_st_free(hash);
}
- hash_verify(hash);
}
-#endif
typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);
@@ -1329,7 +1247,6 @@ hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
if (error) return ST_STOP;
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
- /* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
return hash_iter_status_check(status);
}
@@ -1341,89 +1258,84 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
if (error) return ST_STOP;
- st_table *tbl = RHASH_ST_TABLE(arg->hash);
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
- if (RHASH_ST_TABLE(arg->hash) != tbl) {
- rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
- }
-
return hash_iter_status_check(status);
}
-static int
+static unsigned long
iter_lev_in_ivar(VALUE hash)
{
VALUE levval = rb_ivar_get(hash, id_hash_iter_lev);
HASH_ASSERT(FIXNUM_P(levval));
- return FIX2INT(levval);
+ long lev = FIX2LONG(levval);
+ HASH_ASSERT(lev >= 0);
+ return (unsigned long)lev;
}
void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
static void
-iter_lev_in_ivar_set(VALUE hash, int lev)
+iter_lev_in_ivar_set(VALUE hash, unsigned long lev)
{
- rb_ivar_set_internal(hash, id_hash_iter_lev, INT2FIX(lev));
+ HASH_ASSERT(lev >= RHASH_LEV_MAX);
+ HASH_ASSERT(POSFIXABLE(lev)); /* POSFIXABLE means fitting to long */
+ rb_ivar_set_internal(hash, id_hash_iter_lev, LONG2FIX((long)lev));
}
-static int
+static inline unsigned long
iter_lev_in_flags(VALUE hash)
{
- unsigned int u = (unsigned int)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
- return (int)u;
+ return (unsigned long)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
}
-static int
-RHASH_ITER_LEV(VALUE hash)
+static inline void
+iter_lev_in_flags_set(VALUE hash, unsigned long lev)
{
- int lev = iter_lev_in_flags(hash);
+ HASH_ASSERT(lev <= RHASH_LEV_MAX);
+ RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((VALUE)lev << RHASH_LEV_SHIFT));
+}
- if (lev == RHASH_LEV_MAX) {
- return iter_lev_in_ivar(hash);
- }
- else {
- return lev;
- }
+static inline bool
+hash_iterating_p(VALUE hash)
+{
+ return iter_lev_in_flags(hash) > 0;
}
static void
hash_iter_lev_inc(VALUE hash)
{
- int lev = iter_lev_in_flags(hash);
+ unsigned long lev = iter_lev_in_flags(hash);
if (lev == RHASH_LEV_MAX) {
- lev = iter_lev_in_ivar(hash);
- iter_lev_in_ivar_set(hash, lev+1);
+ lev = iter_lev_in_ivar(hash) + 1;
+ if (!POSFIXABLE(lev)) { /* paranoiac check */
+ rb_raise(rb_eRuntimeError, "too much nested iterations");
+ }
}
else {
lev += 1;
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((VALUE)lev << RHASH_LEV_SHIFT));
- if (lev == RHASH_LEV_MAX) {
- iter_lev_in_ivar_set(hash, lev);
- }
+ iter_lev_in_flags_set(hash, lev);
+ if (lev < RHASH_LEV_MAX) return;
}
+ iter_lev_in_ivar_set(hash, lev);
}
static void
hash_iter_lev_dec(VALUE hash)
{
- int lev = iter_lev_in_flags(hash);
+ unsigned long lev = iter_lev_in_flags(hash);
if (lev == RHASH_LEV_MAX) {
lev = iter_lev_in_ivar(hash);
- HASH_ASSERT(lev > 0);
- iter_lev_in_ivar_set(hash, lev-1);
+ if (lev > RHASH_LEV_MAX) {
+ iter_lev_in_ivar_set(hash, lev-1);
+ return;
+ }
+ rb_attr_delete(hash, id_hash_iter_lev);
}
- else {
- HASH_ASSERT(lev > 0);
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((lev-1) << RHASH_LEV_SHIFT));
+ else if (lev == 0) {
+ rb_raise(rb_eRuntimeError, "iteration level underflow");
}
-}
-
-static VALUE
-hash_foreach_ensure_rollback(VALUE hash)
-{
- hash_iter_lev_inc(hash);
- return 0;
+ iter_lev_in_flags_set(hash, lev - 1);
}
static VALUE
@@ -1433,6 +1345,7 @@ hash_foreach_ensure(VALUE hash)
return 0;
}
+/* This does not manage iteration level */
int
rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg)
{
@@ -1444,6 +1357,7 @@ rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg
}
}
+/* This does not manage iteration level */
int
rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
{
@@ -1494,21 +1408,29 @@ rb_hash_foreach(VALUE hash, rb_foreach_func *func, VALUE farg)
hash_verify(hash);
}
-static VALUE
-hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone)
-{
- const VALUE wb = (RGENGC_WB_PROTECTED_HASH ? FL_WB_PROTECTED : 0);
- NEWOBJ_OF(hash, struct RHash, klass, T_HASH | wb | flags);
+void rb_st_compact_table(st_table *tab);
- RHASH_SET_IFNONE((VALUE)hash, ifnone);
+static void
+compact_after_delete(VALUE hash)
+{
+ if (!hash_iterating_p(hash) && RHASH_ST_TABLE_P(hash)) {
+ rb_st_compact_table(RHASH_ST_TABLE(hash));
+ }
+}
- return (VALUE)hash;
+static VALUE
+hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone, bool st)
+{
+ const size_t size = sizeof(struct RHash) + (st ? sizeof(st_table) : sizeof(ar_table));
+ VALUE hash = rb_newobj_of(klass, T_HASH | flags, size);
+ return rb_hash_set_ifnone(hash, ifnone);
}
static VALUE
hash_alloc(VALUE klass)
{
- return hash_alloc_flags(klass, 0, Qnil);
+ /* Allocate to be able to fit both st_table and ar_table. */
+ return hash_alloc_flags(klass, 0, Qnil, sizeof(st_table) > sizeof(ar_table));
}
static VALUE
@@ -1537,16 +1459,13 @@ copy_compare_by_id(VALUE hash, VALUE basis)
VALUE
rb_hash_new_with_size(st_index_t size)
{
- VALUE ret = rb_hash_new();
- if (size == 0) {
- /* do nothing */
- }
- else if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- ar_alloc_table(ret);
- }
- else {
- RHASH_ST_TABLE_SET(ret, st_init_table_with_size(&objhash, size));
+ bool st = size > RHASH_AR_TABLE_MAX_SIZE;
+ VALUE ret = hash_alloc_flags(rb_cHash, 0, Qnil, st);
+
+ if (st) {
+ hash_st_table_init(ret, &objhash, size);
}
+
return ret;
}
@@ -1556,30 +1475,78 @@ rb_hash_new_capa(long capa)
return rb_hash_new_with_size((st_index_t)capa);
}
+VALUE
+rb_hash_alloc_fixed_size(VALUE klass, st_index_t size)
+{
+ VALUE ret;
+ if (size > RHASH_AR_TABLE_MAX_SIZE) {
+ ret = hash_alloc_flags(klass, 0, Qnil, true);
+ hash_st_table_init(ret, &objhash, size);
+ }
+ else {
+ size_t slot_size = sizeof(struct RHash) + offsetof(ar_table, pairs) + size * sizeof(ar_table_pair);
+ ret = rb_newobj_of(klass, T_HASH, slot_size);
+ }
+
+ RHASH_SET_IFNONE(ret, Qnil);
+ return ret;
+}
+
static VALUE
hash_copy(VALUE ret, VALUE hash)
{
- if (!RHASH_EMPTY_P(hash)) {
- if (RHASH_AR_TABLE_P(hash)) {
+ if (rb_hash_compare_by_id_p(hash)) {
+ rb_gc_register_pinning_obj(ret);
+ }
+
+ if (RHASH_AR_TABLE_P(hash)) {
+ if (RHASH_AR_TABLE_P(ret)) {
ar_copy(ret, hash);
}
else {
- RHASH_ST_TABLE_SET(ret, st_copy(RHASH_ST_TABLE(hash)));
+ st_table *tab = RHASH_ST_TABLE(ret);
+ st_init_existing_table_with_size(tab, &objhash, RHASH_AR_TABLE_SIZE(hash));
+
+ int bound = RHASH_AR_TABLE_BOUND(hash);
+ for (int i = 0; i < bound; i++) {
+ if (ar_cleared_entry(hash, i)) continue;
+
+ ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
+ st_add_direct(tab, pair->key, pair->val);
+ RB_OBJ_WRITTEN(ret, Qundef, pair->key);
+ RB_OBJ_WRITTEN(ret, Qundef, pair->val);
+ }
}
}
+ else {
+ HASH_ASSERT(sizeof(st_table) <= sizeof(ar_table));
+
+ RHASH_SET_ST_FLAG(ret);
+ st_replace(RHASH_ST_TABLE(ret), RHASH_ST_TABLE(hash));
+
+ rb_gc_writebarrier_remember(ret);
+ }
return ret;
}
static VALUE
hash_dup_with_compare_by_id(VALUE hash)
{
- return hash_copy(copy_compare_by_id(rb_hash_new(), hash), hash);
+ VALUE dup = hash_alloc_flags(rb_cHash, 0, Qnil, RHASH_ST_TABLE_P(hash));
+ if (RHASH_ST_TABLE_P(hash)) {
+ RHASH_SET_ST_FLAG(dup);
+ }
+ else {
+ RHASH_UNSET_ST_FLAG(dup);
+ }
+
+ return hash_copy(dup, hash);
}
static VALUE
hash_dup(VALUE hash, VALUE klass, VALUE flags)
{
- return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash)),
+ return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash), !RHASH_EMPTY_P(hash) && RHASH_ST_TABLE_P(hash)),
hash);
}
@@ -1587,10 +1554,10 @@ VALUE
rb_hash_dup(VALUE hash)
{
const VALUE flags = RBASIC(hash)->flags;
- VALUE ret = hash_dup(hash, rb_obj_class(hash),
- flags & (FL_EXIVAR|RHASH_PROC_DEFAULT));
- if (flags & FL_EXIVAR)
- rb_copy_generic_ivar(ret, hash);
+ VALUE ret = hash_dup(hash, rb_obj_class(hash), flags & RHASH_PROC_DEFAULT);
+
+ rb_copy_generic_ivar(ret, hash);
+
return ret;
}
@@ -1607,7 +1574,7 @@ rb_hash_modify_check(VALUE hash)
rb_check_frozen(hash);
}
-RUBY_FUNC_EXPORTED struct st_table *
+struct st_table *
rb_hash_tbl_raw(VALUE hash, const char *file, int line)
{
return ar_force_convert_table(hash, file, line);
@@ -1668,7 +1635,7 @@ rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func,
if (RHASH_AR_TABLE_P(hash)) {
int result = ar_update(hash, key, func, arg);
if (result == -1) {
- ar_try_convert_table(hash);
+ ar_force_convert_table(hash, __FILE__, __LINE__);
}
else {
return result;
@@ -1713,26 +1680,26 @@ tbl_update(VALUE hash, VALUE key, tbl_update_func func, st_data_t optional_arg)
.func = func,
.hash = hash,
.key = key,
- .value = (VALUE)optional_arg,
+ .value = 0
};
int ret = rb_hash_stlike_update(hash, key, tbl_update_modify, (st_data_t)&arg);
/* write barrier */
RB_OBJ_WRITTEN(hash, Qundef, arg.key);
- RB_OBJ_WRITTEN(hash, Qundef, arg.value);
+ if (arg.value) RB_OBJ_WRITTEN(hash, Qundef, arg.value);
return ret;
}
-#define UPDATE_CALLBACK(iter_lev, func) ((iter_lev) > 0 ? func##_noinsert : func##_insert)
+#define UPDATE_CALLBACK(iter_p, func) ((iter_p) ? func##_noinsert : func##_insert)
-#define RHASH_UPDATE_ITER(h, iter_lev, key, func, a) do { \
- tbl_update((h), (key), UPDATE_CALLBACK((iter_lev), func), (st_data_t)(a)); \
+#define RHASH_UPDATE_ITER(h, iter_p, key, func, a) do { \
+ tbl_update((h), (key), UPDATE_CALLBACK(iter_p, func), (st_data_t)(a)); \
} while (0)
#define RHASH_UPDATE(hash, key, func, arg) \
- RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg)
+ RHASH_UPDATE_ITER(hash, hash_iterating_p(hash), key, func, arg)
static void
set_proc_default(VALUE hash, VALUE proc)
@@ -1750,90 +1717,71 @@ set_proc_default(VALUE hash, VALUE proc)
RHASH_SET_IFNONE(hash, proc);
}
-/*
- * call-seq:
- * Hash.new(default_value = nil) -> new_hash
- * Hash.new {|hash, key| ... } -> new_hash
- *
- * Returns a new empty \Hash object.
- *
- * The initial default value and initial default proc for the new hash
- * depend on which form above was used. See {Default Values}[rdoc-ref:Hash@Default+Values].
- *
- * If neither an argument nor a block given,
- * initializes both the default value and the default proc to <tt>nil</tt>:
- * h = Hash.new
- * h.default # => nil
- * h.default_proc # => nil
- *
- * If argument <tt>default_value</tt> given but no block given,
- * initializes the default value to the given <tt>default_value</tt>
- * and the default proc to <tt>nil</tt>:
- * h = Hash.new(false)
- * h.default # => false
- * h.default_proc # => nil
- *
- * If a block given but no argument, stores the block as the default proc
- * and sets the default value to <tt>nil</tt>:
- * h = Hash.new {|hash, key| "Default value for #{key}" }
- * h.default # => nil
- * h.default_proc.class # => Proc
- * h[:nosuch] # => "Default value for nosuch"
- */
-
static VALUE
-rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
+rb_hash_init(rb_execution_context_t *ec, VALUE hash, VALUE capa_value, VALUE ifnone_unset, VALUE ifnone, VALUE block)
{
- VALUE ifnone;
-
rb_hash_modify(hash);
- if (rb_block_given_p()) {
- rb_check_arity(argc, 0, 0);
- ifnone = rb_block_proc();
- SET_PROC_DEFAULT(hash, ifnone);
+
+ if (capa_value != INT2FIX(0)) {
+ long capa = NUM2LONG(capa_value);
+ if (capa > 0 && RHASH_SIZE(hash) == 0 && RHASH_AR_TABLE_P(hash)) {
+ hash_st_table_init(hash, &objhash, capa);
+ }
+ }
+
+ if (!NIL_P(block)) {
+ if (ifnone_unset != Qtrue) {
+ rb_check_arity(1, 0, 0);
+ }
+ else {
+ SET_PROC_DEFAULT(hash, block);
+ }
}
else {
- rb_check_arity(argc, 0, 1);
- ifnone = argc == 0 ? Qnil : argv[0];
- RHASH_SET_IFNONE(hash, ifnone);
+ RHASH_SET_IFNONE(hash, ifnone_unset == Qtrue ? Qnil : ifnone);
}
+ hash_verify(hash);
return hash;
}
+static VALUE rb_hash_to_a(VALUE hash);
+
/*
* call-seq:
* Hash[] -> new_empty_hash
- * Hash[hash] -> new_hash
+ * Hash[other_hash] -> new_hash
* Hash[ [*2_element_arrays] ] -> new_hash
* Hash[*objects] -> new_hash
*
* Returns a new \Hash object populated with the given objects, if any.
* See Hash::new.
*
- * With no argument, returns a new empty \Hash.
+ * With no argument given, returns a new empty hash.
*
- * When the single given argument is a \Hash, returns a new \Hash
- * populated with the entries from the given \Hash, excluding the
- * default value or proc.
+ * With a single argument +other_hash+ given that is a hash,
+ * returns a new hash initialized with the entries from that hash
+ * (but not with its +default+ or +default_proc+):
*
* h = {foo: 0, bar: 1, baz: 2}
- * Hash[h] # => {:foo=>0, :bar=>1, :baz=>2}
+ * Hash[h] # => {foo: 0, bar: 1, baz: 2}
*
- * When the single given argument is an \Array of 2-element Arrays,
- * returns a new \Hash object wherein each 2-element array forms a
+ * With a single argument +2_element_arrays+ given that is an array of 2-element arrays,
+ * returns a new hash wherein each given 2-element array forms a
* key-value entry:
*
- * Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1}
+ * Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {foo: 0, bar: 1}
*
- * When the argument count is an even number;
- * returns a new \Hash object wherein each successive pair of arguments
- * has become a key-value entry:
+ * With an even number of arguments +objects+ given,
+ * returns a new hash wherein each successive pair of arguments
+ * is a key-value entry:
*
- * Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1}
+ * Hash[:foo, 0, :bar, 1] # => {foo: 0, bar: 1}
*
- * Raises an exception if the argument list does not conform to any
+ * Raises ArgumentError if the argument list does not conform to any
* of the above.
+ *
+ * See also {Methods for Creating a Hash}[rdoc-ref:Hash@Methods+for+Creating+a+Hash].
*/
static VALUE
@@ -1844,12 +1792,23 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
if (argc == 1) {
tmp = rb_hash_s_try_convert(Qnil, argv[0]);
if (!NIL_P(tmp)) {
- hash = hash_alloc(klass);
- hash_copy(hash, tmp);
- return hash;
+ if (!RHASH_EMPTY_P(tmp) && rb_hash_compare_by_id_p(tmp)) {
+ /* hash_copy for non-empty hash will copy compare_by_identity
+ flag, but we don't want it copied. Work around by
+ converting hash to flattened array and using that. */
+ tmp = rb_hash_to_a(tmp);
+ }
+ else {
+ hash = hash_alloc(klass);
+ if (!RHASH_EMPTY_P(tmp))
+ hash_copy(hash, tmp);
+ return hash;
+ }
+ }
+ else {
+ tmp = rb_check_array_type(argv[0]);
}
- tmp = rb_check_array_type(argv[0]);
if (!NIL_P(tmp)) {
long i;
@@ -1902,16 +1861,15 @@ rb_check_hash_type(VALUE hash)
/*
* call-seq:
- * Hash.try_convert(obj) -> obj, new_hash, or nil
+ * Hash.try_convert(object) -> object, new_hash, or nil
*
- * If +obj+ is a \Hash object, returns +obj+.
+ * If +object+ is a hash, returns +object+.
*
- * Otherwise if +obj+ responds to <tt>:to_hash</tt>,
- * calls <tt>obj.to_hash</tt> and returns the result.
+ * Otherwise if +object+ responds to +:to_hash+,
+ * calls <tt>object.to_hash</tt>;
+ * returns the result if it is a hash, or raises TypeError if not.
*
- * Returns +nil+ if +obj+ does not respond to <tt>:to_hash</tt>
- *
- * Raises an exception unless <tt>obj.to_hash</tt> returns a \Hash object.
+ * Otherwise if +object+ does not respond to +:to_hash+, returns +nil+.
*/
static VALUE
rb_hash_s_try_convert(VALUE dummy, VALUE hash)
@@ -1960,9 +1918,12 @@ static VALUE
rb_hash_s_ruby2_keywords_hash(VALUE dummy, VALUE hash)
{
Check_Type(hash, T_HASH);
- hash = rb_hash_dup(hash);
- RHASH(hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
- return hash;
+ VALUE tmp = rb_hash_dup(hash);
+ if (RHASH_EMPTY_P(hash) && rb_hash_compare_by_id_p(hash)) {
+ rb_hash_compare_by_id(tmp);
+ }
+ RHASH(tmp)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
+ return tmp;
}
struct rehash_arg {
@@ -1979,15 +1940,19 @@ rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
else {
st_insert(RHASH_ST_TABLE(arg), (st_data_t)key, (st_data_t)value);
}
+
+ RB_OBJ_WRITTEN(arg, Qundef, key);
+ RB_OBJ_WRITTEN(arg, Qundef, value);
return ST_CONTINUE;
}
/*
* call-seq:
- * hash.rehash -> self
+ * rehash -> self
*
- * Rebuilds the hash table by recomputing the hash index for each key;
+ * Rebuilds the hash table for +self+ by recomputing the hash index for each key;
* returns <tt>self</tt>.
+ * Calling this method ensures that the hash table is valid.
*
* The hash table becomes invalid if the hash value of a key
* has changed after the entry was created.
@@ -2000,26 +1965,28 @@ rb_hash_rehash(VALUE hash)
VALUE tmp;
st_table *tbl;
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_raise(rb_eRuntimeError, "rehash during iteration");
}
rb_hash_modify_check(hash);
if (RHASH_AR_TABLE_P(hash)) {
tmp = hash_alloc(0);
- ar_alloc_table(tmp);
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- ar_free_and_clear_table(hash);
+
+ hash_ar_free_and_clear_table(hash);
ar_copy(hash, tmp);
- ar_free_and_clear_table(tmp);
}
else if (RHASH_ST_TABLE_P(hash)) {
st_table *old_tab = RHASH_ST_TABLE(hash);
tmp = hash_alloc(0);
- tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries);
- RHASH_ST_TABLE_SET(tmp, tbl);
+
+ hash_st_table_init(tmp, old_tab->type, old_tab->num_entries);
+ tbl = RHASH_ST_TABLE(tmp);
+
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(old_tab);
- RHASH_ST_TABLE_SET(hash, tbl);
+
+ hash_st_free(hash);
+ rb_hash_st_table_set(hash, tbl);
RHASH_ST_CLEAR(tmp);
}
hash_verify(hash);
@@ -2033,7 +2000,7 @@ call_default_proc(VALUE proc, VALUE hash, VALUE key)
return rb_proc_call_with_block(proc, 2, args, Qnil);
}
-static bool
+bool
rb_hash_default_unredefined(VALUE hash)
{
VALUE klass = RBASIC_CLASS(hash);
@@ -2086,16 +2053,19 @@ rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
/*
* call-seq:
- * hash[key] -> value
+ * self[key] -> object
*
- * Returns the value associated with the given +key+, if found:
- * h = {foo: 0, bar: 1, baz: 2}
- * h[:foo] # => 0
+ * Searches for a hash key equivalent to the given +key+;
+ * see {Hash Key Equivalence}[rdoc-ref:Hash@Hash+Key+Equivalence].
*
- * If +key+ is not found, returns a default value
- * (see {Default Values}[rdoc-ref:Hash@Default+Values]):
- * h = {foo: 0, bar: 1, baz: 2}
- * h[:nosuch] # => nil
+ * If the key is found, returns its value:
+ *
+ * {foo: 0, bar: 1, baz: 2}
+ * h[:bar] # => 1
+ *
+ * Otherwise, returns a default value (see {Hash Default}[rdoc-ref:Hash@Hash+Default]).
+ *
+ * Related: #[]=; see also {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
VALUE
@@ -2132,25 +2102,28 @@ rb_hash_lookup(VALUE hash, VALUE key)
/*
* call-seq:
- * hash.fetch(key) -> object
- * hash.fetch(key, default_value) -> object
- * hash.fetch(key) {|key| ... } -> object
+ * fetch(key) -> object
+ * fetch(key, default_value) -> object
+ * fetch(key) {|key| ... } -> object
+ *
+ * With no block given, returns the value for the given +key+, if found;
*
- * Returns the value for the given +key+, if found.
* h = {foo: 0, bar: 1, baz: 2}
- * h.fetch(:bar) # => 1
+ * h.fetch(:bar) # => 1
*
- * If +key+ is not found and no block was given,
- * returns +default_value+:
- * {}.fetch(:nosuch, :default) # => :default
+ * If the key is not found, returns +default_value+, if given,
+ * or raises KeyError otherwise:
*
- * If +key+ is not found and a block was given,
- * yields +key+ to the block and returns the block's return value:
- * {}.fetch(:nosuch) {|key| "No key #{key}"} # => "No key nosuch"
+ * h.fetch(:nosuch, :default) # => :default
+ * h.fetch(:nosuch) # Raises KeyError.
+ *
+ * With a block given, calls the block with +key+ and returns the block's return value:
*
- * Raises KeyError if neither +default_value+ nor a block was given.
+ * {}.fetch(:nosuch) {|key| "No key #{key}"} # => "No key nosuch"
*
* Note that this method does not use the values of either #default or #default_proc.
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -2197,12 +2170,12 @@ rb_hash_fetch(VALUE hash, VALUE key)
/*
* call-seq:
- * hash.default -> object
- * hash.default(key) -> object
+ * default -> object
+ * default(key) -> object
*
* Returns the default value for the given +key+.
* The returned value will be determined either by the default proc or by the default value.
- * See {Default Values}[rdoc-ref:Hash@Default+Values].
+ * See {Hash Default}[rdoc-ref:Hash@Hash+Default].
*
* With no argument, returns the current default value:
* h = {}
@@ -2231,7 +2204,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
/*
* call-seq:
- * hash.default = value -> object
+ * default = value -> object
*
* Sets the default value to +value+; returns +value+:
* h = {}
@@ -2239,10 +2212,10 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
* h.default = false # => false
* h.default # => false
*
- * See {Default Values}[rdoc-ref:Hash@Default+Values].
+ * See {Hash Default}[rdoc-ref:Hash@Hash+Default].
*/
-static VALUE
+VALUE
rb_hash_set_default(VALUE hash, VALUE ifnone)
{
rb_hash_modify_check(hash);
@@ -2252,10 +2225,10 @@ rb_hash_set_default(VALUE hash, VALUE ifnone)
/*
* call-seq:
- * hash.default_proc -> proc or nil
+ * default_proc -> proc or nil
*
* Returns the default proc for +self+
- * (see {Default Values}[rdoc-ref:Hash@Default+Values]):
+ * (see {Hash Default}[rdoc-ref:Hash@Hash+Default]):
* h = {}
* h.default_proc # => nil
* h.default_proc = proc {|hash, key| "Default value for #{key}" }
@@ -2273,10 +2246,10 @@ rb_hash_default_proc(VALUE hash)
/*
* call-seq:
- * hash.default_proc = proc -> proc
+ * default_proc = proc -> proc
*
- * Sets the default proc for +self+ to +proc+:
- * (see {Default Values}[rdoc-ref:Hash@Default+Values]):
+ * Sets the default proc for +self+ to +proc+
+ * (see {Hash Default}[rdoc-ref:Hash@Hash+Default]):
* h = {}
* h.default_proc # => nil
* h.default_proc = proc { |hash, key| "Default value for #{key}" }
@@ -2320,15 +2293,18 @@ key_i(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
- * hash.key(value) -> key or nil
+ * key(value) -> key or nil
*
* Returns the key for the first-found entry with the given +value+
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
+ *
* h = {foo: 0, bar: 2, baz: 2}
* h.key(0) # => :foo
* h.key(2) # => :bar
*
- * Returns +nil+ if so such value is found.
+ * Returns +nil+ if no such value is found.
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -2393,29 +2369,36 @@ rb_hash_delete(VALUE hash, VALUE key)
/*
* call-seq:
- * hash.delete(key) -> value or nil
- * hash.delete(key) {|key| ... } -> object
+ * delete(key) -> value or nil
+ * delete(key) {|key| ... } -> object
*
- * Deletes the entry for the given +key+ and returns its associated value.
+ * If an entry for the given +key+ is found,
+ * deletes the entry and returns its associated value;
+ * otherwise returns +nil+ or calls the given block.
+ *
+ * With no block given and +key+ found, deletes the entry and returns its value:
*
- * If no block is given and +key+ is found, deletes the entry and returns the associated value:
* h = {foo: 0, bar: 1, baz: 2}
* h.delete(:bar) # => 1
- * h # => {:foo=>0, :baz=>2}
+ * h # => {foo: 0, baz: 2}
+ *
+ * With no block given and +key+ not found, returns +nil+.
*
- * If no block given and +key+ is not found, returns +nil+.
+ * With a block given and +key+ found, ignores the block,
+ * deletes the entry, and returns its value:
*
- * If a block is given and +key+ is found, ignores the block,
- * deletes the entry, and returns the associated value:
* h = {foo: 0, bar: 1, baz: 2}
* h.delete(:baz) { |key| raise 'Will never happen'} # => 2
- * h # => {:foo=>0, :bar=>1}
+ * h # => {foo: 0, bar: 1}
*
- * If a block is given and +key+ is not found,
+ * With a block given and +key+ not found,
* calls the block and returns the block's return value:
+ *
* h = {foo: 0, bar: 1, baz: 2}
* h.delete(:nosuch) { |key| "Key #{key} not found" } # => "Key nosuch not found"
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2427,6 +2410,7 @@ rb_hash_delete_m(VALUE hash, VALUE key)
val = rb_hash_delete_entry(hash, key);
if (!UNDEF_P(val)) {
+ compact_after_delete(hash);
return val;
}
else {
@@ -2456,16 +2440,18 @@ shift_i_safe(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
- * hash.shift -> [key, value] or nil
+ * shift -> [key, value] or nil
+ *
+ * Removes and returns the first entry of +self+ as a 2-element array;
+ * see {Entry Order}[rdoc-ref:Hash@Entry+Order]:
*
- * Removes the first hash entry
- * (see {Entry Order}[rdoc-ref:Hash@Entry+Order]);
- * returns a 2-element \Array containing the removed key and value:
* h = {foo: 0, bar: 1, baz: 2}
* h.shift # => [:foo, 0]
- * h # => {:bar=>1, :baz=>2}
+ * h # => {bar: 1, baz: 2}
+ *
+ * Returns +nil+ if +self+ is empty.
*
- * Returns nil if the hash is empty.
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2476,7 +2462,7 @@ rb_hash_shift(VALUE hash)
rb_hash_modify_check(hash);
if (RHASH_AR_TABLE_P(hash)) {
var.key = Qundef;
- if (RHASH_ITER_LEV(hash) == 0) {
+ if (!hash_iterating_p(hash)) {
if (ar_shift(hash, &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val);
}
@@ -2491,7 +2477,7 @@ rb_hash_shift(VALUE hash)
}
if (RHASH_ST_TABLE_P(hash)) {
var.key = Qundef;
- if (RHASH_ITER_LEV(hash) == 0) {
+ if (!hash_iterating_p(hash)) {
if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val);
}
@@ -2525,19 +2511,19 @@ hash_enum_size(VALUE hash, VALUE args, VALUE eobj)
/*
* call-seq:
- * hash.delete_if {|key, value| ... } -> self
- * hash.delete_if -> new_enumerator
+ * delete_if {|key, value| ... } -> self
+ * delete_if -> new_enumerator
*
- * If a block given, calls the block with each key-value pair;
- * deletes each entry for which the block returns a truthy value;
- * returns +self+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.delete_if {|key, value| value > 0 } # => {:foo=>0}
+ * With a block given, calls the block with each key-value pair,
+ * deletes each entry for which the block returns a truthy value,
+ * and returns +self+:
*
- * If no block given, returns a new \Enumerator:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.delete_if # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:delete_if>
- * e.each { |key, value| value > 0 } # => {:foo=>0}
+ * h.delete_if {|key, value| value > 0 } # => {foo: 0}
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
VALUE
@@ -2547,26 +2533,28 @@ rb_hash_delete_if(VALUE hash)
rb_hash_modify_check(hash);
if (!RHASH_TABLE_EMPTY_P(hash)) {
rb_hash_foreach(hash, delete_if_i, hash);
+ compact_after_delete(hash);
}
return hash;
}
/*
* call-seq:
- * hash.reject! {|key, value| ... } -> self or nil
- * hash.reject! -> new_enumerator
+ * reject! {|key, value| ... } -> self or nil
+ * reject! -> new_enumerator
*
- * Returns +self+, whose remaining entries are those
- * for which the block returns +false+ or +nil+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.reject! {|key, value| value < 2 } # => {:baz=>2}
+ * With a block given, calls the block with each entry's key and value;
+ * removes the entry from +self+ if the block returns a truthy value.
*
- * Returns +nil+ if no entries are removed.
+ * Return +self+ if any entries were removed, +nil+ otherwise:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.reject! # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:reject!>
- * e.each {|key, value| key.start_with?('b') } # => {:foo=>0}
+ * h.reject! {|key, value| value < 2 } # => {baz: 2}
+ * h.reject! {|key, value| value < 2 } # => nil
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2585,20 +2573,21 @@ rb_hash_reject_bang(VALUE hash)
/*
* call-seq:
- * hash.reject {|key, value| ... } -> new_hash
- * hash.reject -> new_enumerator
+ * reject {|key, value| ... } -> new_hash
+ * reject -> new_enumerator
*
- * Returns a new \Hash object whose entries are all those
- * from +self+ for which the block returns +false+ or +nil+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h1 = h.reject {|key, value| key.start_with?('b') }
- * h1 # => {:foo=>0}
+ * With a block given, returns a copy of +self+ with zero or more entries removed;
+ * calls the block with each key-value pair;
+ * excludes the entry in the copy if the block returns a truthy value,
+ * includes it otherwise:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.reject # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:reject>
- * h1 = e.each {|key, value| key.start_with?('b') }
- * h1 # => {:foo=>0}
+ * h.reject {|key, value| key.start_with?('b') }
+ * # => {foo: 0}
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2610,19 +2599,22 @@ rb_hash_reject(VALUE hash)
result = hash_dup_with_compare_by_id(hash);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_foreach(result, delete_if_i, result);
+ compact_after_delete(result);
}
return result;
}
/*
* call-seq:
- * hash.slice(*keys) -> new_hash
+ * slice(*keys) -> new_hash
+ *
+ * Returns a new hash containing the entries from +self+ for the given +keys+;
+ * ignores any keys that are not found:
*
- * Returns a new \Hash object containing the entries for the given +keys+:
* h = {foo: 0, bar: 1, baz: 2}
- * h.slice(:baz, :foo) # => {:baz=>2, :foo=>0}
+ * h.slice(:baz, :foo, :nosuch) # => {baz: 2, foo: 0}
*
- * Any given +keys+ that are not found are ignored.
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2648,13 +2640,16 @@ rb_hash_slice(int argc, VALUE *argv, VALUE hash)
/*
* call-seq:
- * hsh.except(*keys) -> a_hash
+ * except(*keys) -> new_hash
*
- * Returns a new \Hash excluding entries for the given +keys+:
- * h = { a: 100, b: 200, c: 300 }
- * h.except(:a) #=> {:b=>200, :c=>300}
+ * Returns a copy of +self+ that excludes entries for the given +keys+;
+ * any +keys+ that are not found are ignored:
*
- * Any given +keys+ that are not found are ignored.
+ * h = {foo:0, bar: 1, baz: 2} # => {foo: 0, bar: 1, baz: 2}
+ * h.except(:baz, :foo) # => {bar: 1}
+ * h.except(:bar, :nosuch) # => {foo: 0, baz: 2}
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2669,21 +2664,26 @@ rb_hash_except(int argc, VALUE *argv, VALUE hash)
key = argv[i];
rb_hash_delete(result, key);
}
+ compact_after_delete(result);
return result;
}
/*
* call-seq:
- * hash.values_at(*keys) -> new_array
+ * values_at(*keys) -> new_array
+ *
+ * Returns a new array containing values for the given +keys+:
*
- * Returns a new \Array containing values for the given +keys+:
* h = {foo: 0, bar: 1, baz: 2}
* h.values_at(:baz, :foo) # => [2, 0]
*
- * The {default values}[rdoc-ref:Hash@Default+Values] are returned
- * for any keys that are not found:
+ * The {hash default}[rdoc-ref:Hash@Hash+Default] is returned
+ * for each key that is not found:
+ *
* h.values_at(:hello, :foo) # => [nil, 0]
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -2700,22 +2700,26 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
/*
* call-seq:
- * hash.fetch_values(*keys) -> new_array
- * hash.fetch_values(*keys) {|key| ... } -> new_array
+ * fetch_values(*keys) -> new_array
+ * fetch_values(*keys) {|key| ... } -> new_array
+ *
+ * When all given +keys+ are found,
+ * returns a new array containing the values associated with the given +keys+:
*
- * Returns a new \Array containing the values associated with the given keys *keys:
* h = {foo: 0, bar: 1, baz: 2}
* h.fetch_values(:baz, :foo) # => [2, 0]
*
- * Returns a new empty \Array if no arguments given.
+ * When any given +keys+ are not found and a block is given,
+ * calls the block with each unfound key and uses the block's return value
+ * as the value for that key:
*
- * When a block is given, calls the block with each missing key,
- * treating the block's return value as the value for that key:
- * h = {foo: 0, bar: 1, baz: 2}
- * values = h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s}
- * values # => [1, 0, "bad", "bam"]
+ * h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s}
+ * # => [1, 0, "bad", "bam"]
+ *
+ * When any given +keys+ are not found and no block is given,
+ * raises KeyError.
*
- * When no block is given, raises an exception if any given key is not found.
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -2742,17 +2746,18 @@ keep_if_i(VALUE key, VALUE value, VALUE hash)
/*
* call-seq:
- * hash.select {|key, value| ... } -> new_hash
- * hash.select -> new_enumerator
+ * select {|key, value| ... } -> new_hash
+ * select -> new_enumerator
*
- * Returns a new \Hash object whose entries are those for which the block returns a truthy value:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
+ * With a block given, calls the block with each entry's key and value;
+ * returns a new hash whose entries are those for which the block returns a truthy value:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.select # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:select>
- * e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
+ * h.select {|key, value| value < 2 } # => {foo: 0, bar: 1}
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2764,25 +2769,29 @@ rb_hash_select(VALUE hash)
result = hash_dup_with_compare_by_id(hash);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_foreach(result, keep_if_i, result);
+ compact_after_delete(result);
}
return result;
}
/*
* call-seq:
- * hash.select! {|key, value| ... } -> self or nil
- * hash.select! -> new_enumerator
+ * select! {|key, value| ... } -> self or nil
+ * select! -> new_enumerator
*
- * Returns +self+, whose entries are those for which the block returns a truthy value:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1}
+ * With a block given, calls the block with each entry's key and value;
+ * removes from +self+ each entry for which the block returns +false+ or +nil+.
*
- * Returns +nil+ if no entries were removed.
+ * Returns +self+ if any entries were removed, +nil+ otherwise:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.select! # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:select!>
- * e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1}
+ * h.select! {|key, value| value < 2 } # => {foo: 0, bar: 1}
+ * h.select! {|key, value| value < 2 } # => nil
+ *
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2801,19 +2810,19 @@ rb_hash_select_bang(VALUE hash)
/*
* call-seq:
- * hash.keep_if {|key, value| ... } -> self
- * hash.keep_if -> new_enumerator
+ * keep_if {|key, value| ... } -> self
+ * keep_if -> new_enumerator
*
- * Calls the block for each key-value pair;
+ * With a block given, calls the block for each key-value pair;
* retains the entry if the block returns a truthy value;
- * otherwise deletes the entry; returns +self+.
- * h = {foo: 0, bar: 1, baz: 2}
- * h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2}
+ * otherwise deletes the entry; returns +self+:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.keep_if # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:keep_if>
- * e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2}
+ * h.keep_if { |key, value| key.start_with?('b') } # => {bar: 1, baz: 2}
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -2835,9 +2844,11 @@ clear_i(VALUE key, VALUE value, VALUE dummy)
/*
* call-seq:
- * hash.clear -> self
+ * clear -> self
*
- * Removes all hash entries; returns +self+.
+ * Removes all entries from +self+; returns emptied +self+.
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
VALUE
@@ -2845,7 +2856,7 @@ rb_hash_clear(VALUE hash)
{
rb_hash_modify_check(hash);
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_hash_foreach(hash, clear_i, 0);
}
else if (RHASH_AR_TABLE_P(hash)) {
@@ -2853,6 +2864,7 @@ rb_hash_clear(VALUE hash)
}
else {
st_clear(RHASH_ST_TABLE(hash));
+ compact_after_delete(hash);
}
return hash;
@@ -2868,7 +2880,7 @@ hash_aset(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
VALUE
rb_hash_key_str(VALUE key)
{
- if (!RB_FL_ANY_RAW(key, FL_EXIVAR) && RBASIC_CLASS(key) == rb_cString) {
+ if (!rb_obj_gen_fields_p(key) && RBASIC_CLASS(key) == rb_cString) {
return rb_fstring(key);
}
else {
@@ -2890,57 +2902,68 @@ NOINSERT_UPDATE_CALLBACK(hash_aset_str)
/*
* call-seq:
- * hash[key] = value -> value
- * hash.store(key, value)
+ * self[key] = object -> object
+ *
+ * Associates the given +object+ with the given +key+; returns +object+.
*
- * Associates the given +value+ with the given +key+; returns +value+.
+ * Searches for a hash key equivalent to the given +key+;
+ * see {Hash Key Equivalence}[rdoc-ref:Hash@Hash+Key+Equivalence].
*
- * If the given +key+ exists, replaces its value with the given +value+;
+ * If the key is found, replaces its value with the given +object+;
* the ordering is not affected
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
+ *
* h = {foo: 0, bar: 1}
* h[:foo] = 2 # => 2
- * h.store(:bar, 3) # => 3
- * h # => {:foo=>2, :bar=>3}
+ * h[:foo] # => 2
*
- * If +key+ does not exist, adds the +key+ and +value+;
+ * If +key+ is not found, creates a new entry for the given +key+ and +object+;
* the new entry is last in the order
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
+ *
* h = {foo: 0, bar: 1}
* h[:baz] = 2 # => 2
- * h.store(:bat, 3) # => 3
- * h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3}
+ * h[:baz] # => 2
+ * h # => {foo: 0, bar: 1, baz: 2}
+ *
+ * Related: #[]; see also {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
*/
VALUE
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
{
- int iter_lev = RHASH_ITER_LEV(hash);
+ bool iter_p = hash_iterating_p(hash);
rb_hash_modify(hash);
- if (RHASH_TABLE_NULL_P(hash)) {
- if (iter_lev > 0) no_new_key();
- ar_alloc_table(hash);
- }
-
- if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) {
- RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset, val);
+ if (!RHASH_STRING_KEY_P(hash, key)) {
+ RHASH_UPDATE_ITER(hash, iter_p, key, hash_aset, val);
}
else {
- RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset_str, val);
+ RHASH_UPDATE_ITER(hash, iter_p, key, hash_aset_str, val);
}
return val;
}
/*
* call-seq:
- * hash.replace(other_hash) -> self
+ * replace(other_hash) -> self
*
* Replaces the entire contents of +self+ with the contents of +other_hash+;
* returns +self+:
+ *
* h = {foo: 0, bar: 1, baz: 2}
- * h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4}
+ * h.replace({bat: 3, bam: 4}) # => {bat: 3, bam: 4}
+ *
+ * Also replaces the default value or proc of +self+ with the default value
+ * or proc of +other_hash+.
+ *
+ * h = {}
+ * other = Hash.new(:ok)
+ * h.replace(other)
+ * h.default # => :ok
+ *
+ * Related: see {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
*/
static VALUE
@@ -2948,7 +2971,7 @@ rb_hash_replace(VALUE hash, VALUE hash2)
{
rb_hash_modify_check(hash);
if (hash == hash2) return hash;
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_raise(rb_eRuntimeError, "can't replace hash during iteration");
}
hash2 = to_hash(hash2);
@@ -2956,32 +2979,26 @@ rb_hash_replace(VALUE hash, VALUE hash2)
COPY_DEFAULT(hash, hash2);
if (RHASH_AR_TABLE_P(hash)) {
- ar_free_and_clear_table(hash);
+ hash_ar_free_and_clear_table(hash);
}
else {
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_CLEAR(hash);
- }
- hash_copy(hash, hash2);
- if (RHASH_EMPTY_P(hash2) && RHASH_ST_TABLE_P(hash2)) {
- /* ident hash */
- RHASH_ST_TABLE_SET(hash, st_init_table_with_size(RHASH_TYPE(hash2), 0));
+ hash_st_free_and_clear_table(hash);
}
- rb_gc_writebarrier_remember(hash);
+ hash_copy(hash, hash2);
return hash;
}
/*
* call-seq:
- * hash.length -> integer
- * hash.size -> integer
+ * size -> integer
*
* Returns the count of entries in +self+:
*
- * {foo: 0, bar: 1, baz: 2}.length # => 3
+ * {foo: 0, bar: 1, baz: 2}.size # => 3
*
+ * Related: see {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
VALUE
@@ -2998,14 +3015,17 @@ rb_hash_size_num(VALUE hash)
/*
* call-seq:
- * hash.empty? -> true or false
+ * empty? -> true or false
*
* Returns +true+ if there are no hash entries, +false+ otherwise:
+ *
* {}.empty? # => true
- * {foo: 0, bar: 1, baz: 2}.empty? # => false
+ * {foo: 0}.empty? # => false
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
-static VALUE
+VALUE
rb_hash_empty_p(VALUE hash)
{
return RBOOL(RHASH_EMPTY_P(hash));
@@ -3020,26 +3040,22 @@ each_value_i(VALUE key, VALUE value, VALUE _)
/*
* call-seq:
- * hash.each_value {|value| ... } -> self
- * hash.each_value -> new_enumerator
+ * each_value {|value| ... } -> self
+ * each_value -> new_enumerator
*
- * Calls the given block with each value; returns +self+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.each_value {|value| puts value } # => {:foo=>0, :bar=>1, :baz=>2}
- * Output:
- * 0
- * 1
- * 2
+ * With a block given, calls the block with each value; returns +self+:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.each_value # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_value>
- * h1 = e.each {|value| puts value }
- * h1 # => {:foo=>0, :bar=>1, :baz=>2}
+ * h.each_value {|value| puts value } # => {foo: 0, bar: 1, baz: 2}
+ *
* Output:
* 0
* 1
* 2
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Iterating}[rdoc-ref:Hash@Methods+for+Iterating].
*/
static VALUE
@@ -3059,26 +3075,22 @@ each_key_i(VALUE key, VALUE value, VALUE _)
/*
* call-seq:
- * hash.each_key {|key| ... } -> self
- * hash.each_key -> new_enumerator
+ * each_key {|key| ... } -> self
+ * each_key -> new_enumerator
*
- * Calls the given block with each key; returns +self+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.each_key {|key| puts key } # => {:foo=>0, :bar=>1, :baz=>2}
- * Output:
- * foo
- * bar
- * baz
+ * With a block given, calls the block with each key; returns +self+:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.each_key # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_key>
- * h1 = e.each {|key| puts key }
- * h1 # => {:foo=>0, :bar=>1, :baz=>2}
+ * h.each_key {|key| puts key } # => {foo: 0, bar: 1, baz: 2}
+ *
* Output:
* foo
* bar
* baz
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Iterating}[rdoc-ref:Hash@Methods+for+Iterating].
*/
static VALUE
rb_hash_each_key(VALUE hash)
@@ -3107,28 +3119,23 @@ each_pair_i_fast(VALUE key, VALUE value, VALUE _)
/*
* call-seq:
- * hash.each {|key, value| ... } -> self
- * hash.each_pair {|key, value| ... } -> self
- * hash.each -> new_enumerator
- * hash.each_pair -> new_enumerator
+ * each_pair {|key, value| ... } -> self
+ * each_pair -> new_enumerator
*
- * Calls the given block with each key-value pair; returns +self+:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
- * Output:
- * foo: 0
- * bar: 1
- * baz: 2
+ * With a block given, calls the block with each key-value pair; returns +self+:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.each_pair # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_pair>
- * h1 = e.each {|key, value| puts "#{key}: #{value}"}
- * h1 # => {:foo=>0, :bar=>1, :baz=>2}
+ * h.each_pair {|key, value| puts "#{key}: #{value}"} # => {foo: 0, bar: 1, baz: 2}
+ *
* Output:
+ *
* foo: 0
* bar: 1
* baz: 2
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Iterating}[rdoc-ref:Hash@Methods+for+Iterating].
*/
static VALUE
@@ -3174,40 +3181,91 @@ transform_keys_i(VALUE key, VALUE value, VALUE result)
/*
* call-seq:
- * hash.transform_keys {|key| ... } -> new_hash
- * hash.transform_keys(hash2) -> new_hash
- * hash.transform_keys(hash2) {|other_key| ...} -> new_hash
- * hash.transform_keys -> new_enumerator
+ * transform_keys {|old_key| ... } -> new_hash
+ * transform_keys(other_hash) -> new_hash
+ * transform_keys(other_hash) {|old_key| ...} -> new_hash
+ * transform_keys -> new_enumerator
+ *
+ * With an argument, a block, or both given,
+ * derives a new hash +new_hash+ from +self+, the argument, and/or the block;
+ * all, some, or none of its keys may be different from those in +self+.
*
- * Returns a new \Hash object; each entry has:
- * * A key provided by the block.
- * * The value from +self+.
+ * With a block given and no argument,
+ * +new_hash+ has keys determined only by the block.
*
- * An optional hash argument can be provided to map keys to new keys.
- * Any key not given will be mapped using the provided block,
- * or remain the same if no block is given.
+ * For each key/value pair <tt>old_key/value</tt> in +self+, calls the block with +old_key+;
+ * the block's return value becomes +new_key+;
+ * sets <tt>new_hash[new_key] = value</tt>;
+ * a duplicate key overwrites:
*
- * Transform keys:
* h = {foo: 0, bar: 1, baz: 2}
- * h1 = h.transform_keys {|key| key.to_s }
- * h1 # => {"foo"=>0, "bar"=>1, "baz"=>2}
+ * h.transform_keys {|old_key| old_key.to_s }
+ * # => {"foo" => 0, "bar" => 1, "baz" => 2}
+ * h.transform_keys {|old_key| 'xxx' }
+ * # => {"xxx" => 2}
*
- * h.transform_keys(foo: :bar, bar: :foo)
- * #=> {bar: 0, foo: 1, baz: 2}
+ * With argument +other_hash+ given and no block,
+ * +new_hash+ may have new keys provided by +other_hash+
+ * and unchanged keys provided by +self+.
*
- * h.transform_keys(foo: :hello, &:to_s)
- * #=> {:hello=>0, "bar"=>1, "baz"=>2}
+ * For each key/value pair <tt>old_key/old_value</tt> in +self+,
+ * looks for key +old_key+ in +other_hash+:
*
- * Overwrites values for duplicate keys:
- * h = {foo: 0, bar: 1, baz: 2}
- * h1 = h.transform_keys {|key| :bat }
- * h1 # => {:bat=>2}
+ * - If +old_key+ is found, its value <tt>other_hash[old_key]</tt> is taken as +new_key+;
+ * sets <tt>new_hash[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys(baz: :BAZ, bar: :BAR, foo: :FOO)
+ * # => {FOO: 0, BAR: 1, BAZ: 2}
+ * h.transform_keys(baz: :FOO, bar: :FOO, foo: :FOO)
+ * # => {FOO: 2}
+ *
+ * - If +old_key+ is not found,
+ * sets <tt>new_hash[old_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys({})
+ * # => {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys(baz: :foo)
+ * # => {foo: 2, bar: 1}
+ *
+ * Unused keys in +other_hash+ are ignored:
*
- * Returns a new \Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.transform_keys # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:transform_keys>
- * h1 = e.each { |key| key.to_s }
- * h1 # => {"foo"=>0, "bar"=>1, "baz"=>2}
+ * h.transform_keys(bat: 3)
+ * # => {foo: 0, bar: 1, baz: 2}
+ *
+ * With both argument +other_hash+ and a block given,
+ * +new_hash+ has new keys specified by +other_hash+ or by the block,
+ * and unchanged keys provided by +self+.
+ *
+ * For each pair +old_key+ and +value+ in +self+:
+ *
+ * - If +other_hash+ has key +old_key+ (with value +new_key+),
+ * does not call the block for that key;
+ * sets <tt>new_hash[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys(baz: :BAZ, bar: :BAR, foo: :FOO) {|key| fail 'Not called' }
+ * # => {FOO: 0, BAR: 1, BAZ: 2}
+ *
+ * - If +other_hash+ does not have key +old_key+,
+ * calls the block with +old_key+ and takes its return value as +new_key+;
+ * sets <tt>new_hash[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys(baz: :BAZ) {|key| key.to_s.reverse }
+ * # => {"oof" => 0, "rab" => 1, BAZ: 2}
+ * h.transform_keys(baz: :BAZ) {|key| 'ook' }
+ * # => {"ook" => 1, BAZ: 2}
+ *
+ * With no argument and no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
*/
static VALUE
rb_hash_transform_keys(int argc, VALUE *argv, VALUE hash)
@@ -3241,13 +3299,97 @@ static int flatten_i(VALUE key, VALUE val, VALUE ary);
/*
* call-seq:
- * hash.transform_keys! {|key| ... } -> self
- * hash.transform_keys!(hash2) -> self
- * hash.transform_keys!(hash2) {|other_key| ...} -> self
- * hash.transform_keys! -> new_enumerator
+ * transform_keys! {|old_key| ... } -> self
+ * transform_keys!(other_hash) -> self
+ * transform_keys!(other_hash) {|old_key| ...} -> self
+ * transform_keys! -> new_enumerator
+ *
+ * With an argument, a block, or both given,
+ * derives keys from the argument, the block, and +self+;
+ * all, some, or none of the keys in +self+ may be changed.
+ *
+ * With a block given and no argument,
+ * derives keys only from the block;
+ * all, some, or none of the keys in +self+ may be changed.
+ *
+ * For each key/value pair <tt>old_key/value</tt> in +self+, calls the block with +old_key+;
+ * the block's return value becomes +new_key+;
+ * removes the entry for +old_key+: <tt>self.delete(old_key)</tt>;
+ * sets <tt>self[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys! {|old_key| old_key.to_s }
+ * # => {"foo" => 0, "bar" => 1, "baz" => 2}
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys! {|old_key| 'xxx' }
+ * # => {"xxx" => 2}
+ *
+ * With argument +other_hash+ given and no block,
+ * derives keys for +self+ from +other_hash+ and +self+;
+ * all, some, or none of the keys in +self+ may be changed.
+ *
+ * For each key/value pair <tt>old_key/old_value</tt> in +self+,
+ * looks for key +old_key+ in +other_hash+:
+ *
+ * - If +old_key+ is found, takes value <tt>other_hash[old_key]</tt> as +new_key+;
+ * removes the entry for +old_key+: <tt>self.delete(old_key)</tt>;
+ * sets <tt>self[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :BAZ, bar: :BAR, foo: :FOO)
+ * # => {FOO: 0, BAR: 1, BAZ: 2}
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :FOO, bar: :FOO, foo: :FOO)
+ * # => {FOO: 2}
+ *
+ * - If +old_key+ is not found, does nothing:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!({})
+ * # => {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :foo)
+ * # => {foo: 2, bar: 1}
+ *
+ * Unused keys in +other_hash+ are ignored:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(bat: 3)
+ * # => {foo: 0, bar: 1, baz: 2}
+ *
+ * With both argument +other_hash+ and a block given,
+ * derives keys from +other_hash+, the block, and +self+;
+ * all, some, or none of the keys in +self+ may be changed.
+ *
+ * For each pair +old_key+ and +value+ in +self+:
+ *
+ * - If +other_hash+ has key +old_key+ (with value +new_key+),
+ * does not call the block for that key;
+ * removes the entry for +old_key+: <tt>self.delete(old_key)</tt>;
+ * sets <tt>self[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :BAZ, bar: :BAR, foo: :FOO) {|key| fail 'Not called' }
+ * # => {FOO: 0, BAR: 1, BAZ: 2}
*
- * Same as Hash#transform_keys but modifies the receiver in place
- * instead of returning a new hash.
+ * - If +other_hash+ does not have key +old_key+,
+ * calls the block with +old_key+ and takes its return value as +new_key+;
+ * removes the entry for +old_key+: <tt>self.delete(old_key)</tt>;
+ * sets <tt>self[new_key] = value</tt>;
+ * a duplicate key overwrites:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :BAZ) {|key| key.to_s.reverse }
+ * # => {"oof" => 0, "rab" => 1, BAZ: 2}
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.transform_keys!(baz: :BAZ) {|key| 'ook' }
+ * # => {"ook" => 1, BAZ: 2}
+ *
+ * With no argument and no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
*/
static VALUE
rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash)
@@ -3294,6 +3436,7 @@ rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash)
rb_ary_clear(pairs);
rb_hash_clear(new_keys);
}
+ compact_after_delete(hash);
return hash;
}
@@ -3313,25 +3456,37 @@ transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t arg
return ST_CONTINUE;
}
+static VALUE
+transform_values_call(VALUE hash)
+{
+ rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, hash);
+ return hash;
+}
+
+static void
+transform_values(VALUE hash)
+{
+ hash_iter_lev_inc(hash);
+ rb_ensure(transform_values_call, hash, hash_foreach_ensure, hash);
+}
+
/*
* call-seq:
- * hash.transform_values {|value| ... } -> new_hash
- * hash.transform_values -> new_enumerator
+ * transform_values {|value| ... } -> new_hash
+ * transform_values -> new_enumerator
*
- * Returns a new \Hash object; each entry has:
- * * A key from +self+.
- * * A value provided by the block.
+ * With a block given, returns a new hash +new_hash+;
+ * for each pair +key+/+value+ in +self+,
+ * calls the block with +value+ and captures its return as +new_value+;
+ * adds to +new_hash+ the entry +key+/+new_value+:
*
- * Transform values:
* h = {foo: 0, bar: 1, baz: 2}
* h1 = h.transform_values {|value| value * 100}
- * h1 # => {:foo=>0, :bar=>100, :baz=>200}
+ * h1 # => {foo: 0, bar: 100, baz: 200}
*
- * Returns a new \Enumerator if no block given:
- * h = {foo: 0, bar: 1, baz: 2}
- * e = h.transform_values # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:transform_values>
- * h1 = e.each { |value| value * 100}
- * h1 # => {:foo=>0, :bar=>100, :baz=>200}
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
*/
static VALUE
rb_hash_transform_values(VALUE hash)
@@ -3343,7 +3498,8 @@ rb_hash_transform_values(VALUE hash)
SET_DEFAULT(result, Qnil);
if (!RHASH_EMPTY_P(hash)) {
- rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);
+ transform_values(result);
+ compact_after_delete(result);
}
return result;
@@ -3351,18 +3507,24 @@ rb_hash_transform_values(VALUE hash)
/*
* call-seq:
- * hash.transform_values! {|value| ... } -> self
- * hash.transform_values! -> new_enumerator
+ * transform_values! {|old_value| ... } -> self
+ * transform_values! -> new_enumerator
*
- * Returns +self+, whose keys are unchanged, and whose values are determined by the given block.
- * h = {foo: 0, bar: 1, baz: 2}
- * h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200}
*
- * Returns a new \Enumerator if no block given:
+ * With a block given, changes the values of +self+ as determined by the block;
+ * returns +self+.
+ *
+ * For each entry +key+/+old_value+ in +self+,
+ * calls the block with +old_value+,
+ * captures its return value as +new_value+,
+ * and sets <tt>self[key] = new_value</tt>:
+ *
* h = {foo: 0, bar: 1, baz: 2}
- * e = h.transform_values! # => #<Enumerator: {:foo=>0, :bar=>100, :baz=>200}:transform_values!>
- * h1 = e.each {|value| value * 100}
- * h1 # => {:foo=>0, :bar=>100, :baz=>200}
+ * h.transform_values! {|value| value * 100} # => {foo: 0, bar: 100, baz: 200}
+ *
+ * With no block given, returns a new Enumerator.
+ *
+ * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
*/
static VALUE
rb_hash_transform_values_bang(VALUE hash)
@@ -3371,7 +3533,7 @@ rb_hash_transform_values_bang(VALUE hash)
rb_hash_modify_check(hash);
if (!RHASH_TABLE_EMPTY_P(hash)) {
- rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, hash);
+ transform_values(hash);
}
return hash;
@@ -3386,12 +3548,15 @@ to_a_i(VALUE key, VALUE value, VALUE ary)
/*
* call-seq:
- * hash.to_a -> new_array
+ * to_a -> new_array
+ *
+ * Returns all elements of +self+ as an array of 2-element arrays;
+ * each nested array contains a key-value pair from +self+:
*
- * Returns a new \Array of 2-element \Array objects;
- * each nested \Array contains a key-value pair from +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.to_a # => [[:foo, 0], [:bar, 1], [:baz, 2]]
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
@@ -3405,20 +3570,65 @@ rb_hash_to_a(VALUE hash)
return ary;
}
+static bool
+symbol_key_needs_quote(VALUE str)
+{
+ long len = RSTRING_LEN(str);
+ if (len == 0 || !rb_str_symname_p(str)) return true;
+ const char *s = RSTRING_PTR(str);
+ char first = s[0];
+ if (first == '@' || first == '$' || first == '!') return true;
+ if (!at_char_boundary(s, s + len - 1, RSTRING_END(str), rb_enc_get(str))) return false;
+ switch (s[len - 1]) {
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '`':
+ case '%':
+ case '^':
+ case '&':
+ case '|':
+ case ']':
+ case '<':
+ case '=':
+ case '>':
+ case '~':
+ case '@':
+ return true;
+ default:
+ return false;
+ }
+}
+
static int
inspect_i(VALUE key, VALUE value, VALUE str)
{
VALUE str2;
- str2 = rb_inspect(key);
+ bool is_symbol = SYMBOL_P(key);
+ bool quote = false;
+ if (is_symbol) {
+ str2 = rb_sym2str(key);
+ quote = symbol_key_needs_quote(str2);
+ }
+ else {
+ str2 = rb_inspect(key);
+ }
if (RSTRING_LEN(str) > 1) {
rb_str_buf_cat_ascii(str, ", ");
}
else {
rb_enc_copy(str, str2);
}
- rb_str_buf_append(str, str2);
- rb_str_buf_cat_ascii(str, "=>");
+ if (quote) {
+ rb_str_buf_append(str, rb_str_inspect(str2));
+ }
+ else {
+ rb_str_buf_append(str, str2);
+ }
+
+ rb_str_buf_cat_ascii(str, is_symbol ? ": " : " => ");
str2 = rb_inspect(value);
rb_str_buf_append(str, str2);
@@ -3440,13 +3650,14 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
/*
* call-seq:
- * hash.inspect -> new_string
+ * inspect -> new_string
+ *
+ * Returns a new string containing the hash entries:
*
- * Returns a new \String containing the hash entries:
-
* h = {foo: 0, bar: 1, baz: 2}
- * h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
+ * h.inspect # => "{foo: 0, bar: 1, baz: 2}"
*
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
@@ -3459,9 +3670,11 @@ rb_hash_inspect(VALUE hash)
/*
* call-seq:
- * hash.to_hash -> self
+ * to_hash -> self
*
* Returns +self+.
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
rb_hash_to_hash(VALUE hash)
@@ -3504,21 +3717,22 @@ rb_hash_to_h_block(VALUE hash)
/*
* call-seq:
- * hash.to_h -> self or new_hash
- * hash.to_h {|key, value| ... } -> new_hash
- *
- * For an instance of \Hash, returns +self+.
+ * to_h {|key, value| ... } -> new_hash
+ * to_h -> self or new_hash
*
- * For a subclass of \Hash, returns a new \Hash
- * containing the content of +self+.
+ * With a block given, returns a new hash whose content is based on the block;
+ * the block is called with each entry's key and value;
+ * the block should return a 2-element array
+ * containing the key and value to be included in the returned array:
*
- * When a block is given, returns a new \Hash object
- * whose content is based on the block;
- * the block should return a 2-element \Array object
- * specifying the key-value pair to be included in the returned \Array:
* h = {foo: 0, bar: 1, baz: 2}
- * h1 = h.to_h {|key, value| [value, key] }
- * h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
+ * h.to_h {|key, value| [value, key] }
+ * # => {0 => :foo, 1 => :bar, 2 => :baz}
+ *
+ * With no block given, returns +self+ if +self+ is an instance of +Hash+;
+ * if +self+ is a subclass of +Hash+, returns a new hash containing the content of +self+.
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
@@ -3543,11 +3757,14 @@ keys_i(VALUE key, VALUE value, VALUE ary)
/*
* call-seq:
- * hash.keys -> new_array
+ * keys -> new_array
+ *
+ * Returns a new array containing all keys in +self+:
*
- * Returns a new \Array containing all keys in +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.keys # => [:foo, :bar, :baz]
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
VALUE
@@ -3559,7 +3776,7 @@ rb_hash_keys(VALUE hash)
if (size == 0) return keys;
if (ST_DATA_COMPATIBLE_P(VALUE)) {
- RARRAY_PTR_USE_TRANSIENT(keys, ptr, {
+ RARRAY_PTR_USE(keys, ptr, {
if (RHASH_AR_TABLE_P(hash)) {
size = ar_keys(hash, ptr, size);
}
@@ -3587,11 +3804,14 @@ values_i(VALUE key, VALUE value, VALUE ary)
/*
* call-seq:
- * hash.values -> new_array
+ * values -> new_array
+ *
+ * Returns a new array containing all values in +self+:
*
- * Returns a new \Array containing all values in +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.values # => [0, 1, 2]
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
VALUE
@@ -3606,20 +3826,19 @@ rb_hash_values(VALUE hash)
if (ST_DATA_COMPATIBLE_P(VALUE)) {
if (RHASH_AR_TABLE_P(hash)) {
rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
+ RARRAY_PTR_USE(values, ptr, {
size = ar_values(hash, ptr, size);
});
}
else if (RHASH_ST_TABLE_P(hash)) {
st_table *table = RHASH_ST_TABLE(hash);
rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
+ RARRAY_PTR_USE(values, ptr, {
size = st_values(table, ptr, size);
});
}
rb_ary_set_len(values, size);
}
-
else {
rb_hash_foreach(hash, values_i, values);
}
@@ -3629,12 +3848,15 @@ rb_hash_values(VALUE hash)
/*
* call-seq:
- * hash.include?(key) -> true or false
- * hash.has_key?(key) -> true or false
- * hash.key?(key) -> true or false
- * hash.member?(key) -> true or false
+ * include?(key) -> true or false
+ *
+ * Returns whether +key+ is a key in +self+:
*
- * Returns +true+ if +key+ is a key in +self+, otherwise +false+.
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.include?(:bar) # => true
+ * h.include?(:BAR) # => false
+ *
+ * Related: {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
VALUE
@@ -3657,10 +3879,11 @@ rb_hash_search_value(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
- * hash.has_value?(value) -> true or false
- * hash.value?(value) -> true or false
+ * has_value?(value) -> true or false
+ *
+ * Returns whether +value+ is a value in +self+.
*
- * Returns +true+ if +value+ is a value in +self+, otherwise +false+.
+ * Related: {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
static VALUE
@@ -3757,21 +3980,25 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
/*
* call-seq:
- * hash == object -> true or false
+ * self == other -> true or false
*
- * Returns +true+ if all of the following are true:
- * * +object+ is a \Hash object.
- * * +hash+ and +object+ have the same keys (regardless of order).
- * * For each key +key+, <tt>hash[key] == object[key]</tt>.
+ * Returns whether all of the following are true:
*
- * Otherwise, returns +false+.
+ * - +other+ is a +Hash+ object (or can be converted to one).
+ * - +self+ and +other+ have the same keys (regardless of order).
+ * - For each key +key+, <tt>self[key] == other[key]</tt>.
*
- * Equal:
- * h1 = {foo: 0, bar: 1, baz: 2}
- * h2 = {foo: 0, bar: 1, baz: 2}
- * h1 == h2 # => true
- * h3 = {baz: 2, bar: 1, foo: 0}
- * h1 == h3 # => true
+ * Examples:
+ *
+ * h = {foo: 0, bar: 1}
+ * h == {foo: 0, bar: 1} # => true # Equal entries (same order)
+ * h == {bar: 1, foo: 0} # => true # Equal entries (different order).
+ * h == 1 # => false # Object not a hash.
+ * h == {} # => false # Different number of entries.
+ * h == {foo: 0, bat: 1} # => false # Different key.
+ * h == {foo: 0, bar: 2} # => false # Different value.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
static VALUE
@@ -3782,21 +4009,23 @@ rb_hash_equal(VALUE hash1, VALUE hash2)
/*
* call-seq:
- * hash.eql? object -> true or false
+ * eql?(object) -> true or false
*
* Returns +true+ if all of the following are true:
- * * +object+ is a \Hash object.
- * * +hash+ and +object+ have the same keys (regardless of order).
- * * For each key +key+, <tt>h[key] eql? object[key]</tt>.
+ *
+ * - The given +object+ is a +Hash+ object.
+ * - +self+ and +object+ have the same keys (regardless of order).
+ * - For each key +key+, <tt>self[key].eql?(object[key])</tt>.
*
* Otherwise, returns +false+.
*
- * Equal:
* h1 = {foo: 0, bar: 1, baz: 2}
* h2 = {foo: 0, bar: 1, baz: 2}
* h1.eql? h2 # => true
* h3 = {baz: 2, bar: 1, foo: 0}
* h1.eql? h3 # => true
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
static VALUE
@@ -3819,16 +4048,19 @@ hash_i(VALUE key, VALUE val, VALUE arg)
/*
* call-seq:
- * hash.hash -> an_integer
+ * hash -> an_integer
*
- * Returns the \Integer hash-code for the hash.
+ * Returns the integer hash-code for the hash.
+ *
+ * Two hashes have the same hash-code if their content is the same
+ * (regardless of order):
*
- * Two \Hash objects have the same hash-code if their content is the same
- * (regardless or order):
* h1 = {foo: 0, bar: 1, baz: 2}
* h2 = {baz: 2, bar: 1, foo: 0}
* h2.hash == h1.hash # => true
* h2.eql? h1 # => true
+ *
+ * Related: see {Methods for Querying}[rdoc-ref:Hash@Methods+for+Querying].
*/
static VALUE
@@ -3853,17 +4085,21 @@ rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
/*
* call-seq:
- * hash.invert -> new_hash
+ * invert -> new_hash
+ *
+ * Returns a new hash with each key-value pair inverted:
*
- * Returns a new \Hash object with the each key-value pair inverted:
* h = {foo: 0, bar: 1, baz: 2}
* h1 = h.invert
* h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
*
- * Overwrites any repeated new keys:
+ * Overwrites any repeated new keys
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
+ *
* h = {foo: 0, bar: 0, baz: 0}
* h.invert # => {0=>:baz}
+ *
+ * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
*/
static VALUE
@@ -3876,107 +4112,133 @@ rb_hash_invert(VALUE hash)
}
static int
-rb_hash_update_callback(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing)
-{
- *value = arg->arg;
- return ST_CONTINUE;
-}
-
-NOINSERT_UPDATE_CALLBACK(rb_hash_update_callback)
-
-static int
rb_hash_update_i(VALUE key, VALUE value, VALUE hash)
{
- RHASH_UPDATE(hash, key, rb_hash_update_callback, value);
+ rb_hash_aset(hash, key, value);
return ST_CONTINUE;
}
+struct update_call_args {
+ VALUE hash, newvalue, *argv;
+ int argc;
+ bool block_given;
+ bool iterating;
+};
+
static int
rb_hash_update_block_callback(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing)
{
- st_data_t newvalue = arg->arg;
+ VALUE k = (VALUE)*key, v = (VALUE)*value;
+ struct update_call_args *ua = (void *)arg->arg;
+ VALUE newvalue = ua->newvalue, hash = arg->hash;
if (existing) {
- newvalue = (st_data_t)rb_yield_values(3, (VALUE)*key, (VALUE)*value, (VALUE)newvalue);
+ hash_iter_lev_inc(hash);
+ ua->iterating = true;
+ newvalue = rb_yield_values(3, k, v, newvalue);
+ hash_iter_lev_dec(hash);
+ ua->iterating = false;
}
- *value = newvalue;
+ else if (RHASH_STRING_KEY_P(hash, k) && !RB_OBJ_FROZEN(k)) {
+ *key = (st_data_t)rb_hash_key_str(k);
+ }
+ *value = (st_data_t)newvalue;
return ST_CONTINUE;
}
NOINSERT_UPDATE_CALLBACK(rb_hash_update_block_callback)
static int
-rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
+rb_hash_update_block_i(VALUE key, VALUE value, VALUE args)
{
- RHASH_UPDATE(hash, key, rb_hash_update_block_callback, value);
+ struct update_call_args *ua = (void *)args;
+ ua->newvalue = value;
+ RHASH_UPDATE(ua->hash, key, rb_hash_update_block_callback, args);
return ST_CONTINUE;
}
+static VALUE
+rb_hash_update_call(VALUE args)
+{
+ struct update_call_args *arg = (void *)args;
+
+ for (int i = 0; i < arg->argc; i++){
+ VALUE hash = to_hash(arg->argv[i]);
+ if (arg->block_given) {
+ rb_hash_foreach(hash, rb_hash_update_block_i, args);
+ }
+ else {
+ rb_hash_foreach(hash, rb_hash_update_i, arg->hash);
+ }
+ }
+ return arg->hash;
+}
+
+static VALUE
+rb_hash_update_ensure(VALUE args)
+{
+ struct update_call_args *ua = (void *)args;
+ if (ua->iterating) hash_iter_lev_dec(ua->hash);
+ return Qnil;
+}
+
/*
* call-seq:
- * hash.merge! -> self
- * hash.merge!(*other_hashes) -> self
- * hash.merge!(*other_hashes) { |key, old_value, new_value| ... } -> self
+ * update(*other_hashes) -> self
+ * update(*other_hashes) { |key, old_value, new_value| ... } -> self
*
- * Merges each of +other_hashes+ into +self+; returns +self+.
+ * Updates values and/or adds entries to +self+; returns +self+.
*
- * Each argument in +other_hashes+ must be a \Hash.
+ * Each argument +other_hash+ in +other_hashes+ must be a hash.
*
- * With arguments and no block:
- * * Returns +self+, after the given hashes are merged into it.
- * * The given hashes are merged left to right.
- * * Each new entry is added at the end.
- * * Each duplicate-key entry's value overwrites the previous value.
+ * With no block given, for each successive entry +key+/+new_value+ in each successive +other_hash+:
*
- * Example:
- * h = {foo: 0, bar: 1, baz: 2}
- * h1 = {bat: 3, bar: 4}
- * h2 = {bam: 5, bat:6}
- * h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5}
+ * - If +key+ is in +self+, sets <tt>self[key] = new_value</tt>, whose position is unchanged:
*
- * With arguments and a block:
- * * Returns +self+, after the given hashes are merged.
- * * The given hashes are merged left to right.
- * * Each new-key entry is added at the end.
- * * For each duplicate key:
- * * Calls the block with the key and the old and new values.
- * * The block's return value becomes the new value for the entry.
+ * h0 = {foo: 0, bar: 1, baz: 2}
+ * h1 = {bar: 3, foo: -1}
+ * h0.update(h1) # => {foo: -1, bar: 3, baz: 2}
*
- * Example:
- * h = {foo: 0, bar: 1, baz: 2}
- * h1 = {bat: 3, bar: 4}
- * h2 = {bam: 5, bat:6}
- * h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value }
- * h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5}
+ * - If +key+ is not in +self+, adds the entry at the end of +self+:
*
- * With no arguments:
- * * Returns +self+, unmodified.
- * * The block, if given, is ignored.
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.update({bam: 3, bah: 4}) # => {foo: 0, bar: 1, baz: 2, bam: 3, bah: 4}
*
- * Example:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.merge # => {:foo=>0, :bar=>1, :baz=>2}
- * h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' }
- * h1 # => {:foo=>0, :bar=>1, :baz=>2}
+ * With a block given, for each successive entry +key+/+new_value+ in each successive +other_hash+:
+ *
+ * - If +key+ is in +self+, fetches +old_value+ from <tt>self[key]</tt>,
+ * calls the block with +key+, +old_value+, and +new_value+,
+ * and sets <tt>self[key] = new_value</tt>, whose position is unchanged :
+ *
+ * season = {AB: 75, H: 20, HR: 3, SO: 17, W: 11, HBP: 3}
+ * today = {AB: 3, H: 1, W: 1}
+ * yesterday = {AB: 4, H: 2, HR: 1}
+ * season.update(yesterday, today) {|key, old_value, new_value| old_value + new_value }
+ * # => {AB: 82, H: 23, HR: 4, SO: 17, W: 12, HBP: 3}
+ *
+ * - If +key+ is not in +self+, adds the entry at the end of +self+:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h.update({bat: 3}) { fail 'Cannot happen' }
+ * # => {foo: 0, bar: 1, baz: 2, bat: 3}
+ *
+ * Related: see {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
*/
static VALUE
rb_hash_update(int argc, VALUE *argv, VALUE self)
{
- int i;
- bool block_given = rb_block_given_p();
+ struct update_call_args args = {
+ .hash = self,
+ .argv = argv,
+ .argc = argc,
+ .block_given = rb_block_given_p(),
+ .iterating = false,
+ };
+ VALUE arg = (VALUE)&args;
rb_hash_modify(self);
- for (i = 0; i < argc; i++){
- VALUE hash = to_hash(argv[i]);
- if (block_given) {
- rb_hash_foreach(hash, rb_hash_update_block_i, self);
- }
- else {
- rb_hash_foreach(hash, rb_hash_update_i, self);
- }
- }
- return self;
+ return rb_ensure(rb_hash_update_call, arg, rb_hash_update_ensure, arg);
}
struct update_func_arg {
@@ -4030,53 +4292,48 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func)
/*
* call-seq:
- * hash.merge -> copy_of_self
- * hash.merge(*other_hashes) -> new_hash
- * hash.merge(*other_hashes) { |key, old_value, new_value| ... } -> new_hash
- *
- * Returns the new \Hash formed by merging each of +other_hashes+
- * into a copy of +self+.
+ * merge(*other_hashes) -> new_hash
+ * merge(*other_hashes) { |key, old_value, new_value| ... } -> new_hash
*
- * Each argument in +other_hashes+ must be a \Hash.
+ * Each argument +other_hash+ in +other_hashes+ must be a hash.
*
- * ---
+ * With arguments +other_hashes+ given and no block,
+ * returns the new hash formed by merging each successive +other_hash+
+ * into a copy of +self+;
+ * returns that copy;
+ * for each successive entry in +other_hash+:
*
- * With arguments and no block:
- * * Returns the new \Hash object formed by merging each successive
- * \Hash in +other_hashes+ into +self+.
- * * Each new-key entry is added at the end.
- * * Each duplicate-key entry's value overwrites the previous value.
+ * - For a new key, the entry is added at the end of +self+.
+ * - For duplicate key, the entry overwrites the entry in +self+,
+ * whose position is unchanged.
*
* Example:
+ *
* h = {foo: 0, bar: 1, baz: 2}
* h1 = {bat: 3, bar: 4}
* h2 = {bam: 5, bat:6}
- * h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5}
+ * h.merge(h1, h2) # => {foo: 0, bar: 4, baz: 2, bat: 6, bam: 5}
+ *
+ * With arguments +other_hashes+ and a block given, behaves as above
+ * except that for a duplicate key
+ * the overwriting entry takes it value not from the entry in +other_hash+,
+ * but instead from the block:
*
- * With arguments and a block:
- * * Returns a new \Hash object that is the merge of +self+ and each given hash.
- * * The given hashes are merged left to right.
- * * Each new-key entry is added at the end.
- * * For each duplicate key:
- * * Calls the block with the key and the old and new values.
- * * The block's return value becomes the new value for the entry.
+ * - The block is called with the duplicate key and the values
+ * from both +self+ and +other_hash+.
+ * - The block's return value becomes the new value for the entry in +self+.
*
* Example:
+ *
* h = {foo: 0, bar: 1, baz: 2}
* h1 = {bat: 3, bar: 4}
* h2 = {bam: 5, bat:6}
- * h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value }
- * h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5}
+ * h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value }
+ * # => {foo: 0, bar: 5, baz: 2, bat: 9, bam: 5}
*
- * With no arguments:
- * * Returns a copy of +self+.
- * * The block, if given, is ignored.
+ * With no arguments, returns a copy of +self+; the block, if given, is ignored.
*
- * Example:
- * h = {foo: 0, bar: 1, baz: 2}
- * h.merge # => {:foo=>0, :bar=>1, :baz=>2}
- * h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' }
- * h1 # => {:foo=>0, :bar=>1, :baz=>2}
+ * Related: see {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
*/
static VALUE
@@ -4091,24 +4348,17 @@ assoc_cmp(VALUE a, VALUE b)
return !RTEST(rb_equal(a, b));
}
-static VALUE
-lookup2_call(VALUE arg)
-{
- VALUE *args = (VALUE *)arg;
- return rb_hash_lookup2(args[0], args[1], Qundef);
-}
-
-struct reset_hash_type_arg {
- VALUE hash;
- const struct st_hash_type *orighash;
+struct assoc_arg {
+ st_table *tbl;
+ st_data_t key;
};
static VALUE
-reset_hash_type(VALUE arg)
+assoc_lookup(VALUE arg)
{
- struct reset_hash_type_arg *p = (struct reset_hash_type_arg *)arg;
- HASH_ASSERT(RHASH_ST_TABLE_P(p->hash));
- RHASH_ST_TABLE(p->hash)->type = p->orighash;
+ struct assoc_arg *p = (struct assoc_arg*)arg;
+ st_data_t data;
+ if (st_lookup(p->tbl, p->key, &data)) return (VALUE)data;
return Qundef;
}
@@ -4126,42 +4376,46 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
/*
* call-seq:
- * hash.assoc(key) -> new_array or nil
+ * assoc(key) -> entry or nil
+ *
+ * If the given +key+ is found, returns its entry as a 2-element array
+ * containing that key and its value:
*
- * If the given +key+ is found, returns a 2-element \Array containing that key and its value:
* h = {foo: 0, bar: 1, baz: 2}
* h.assoc(:bar) # => [:bar, 1]
*
- * Returns +nil+ if key +key+ is not found.
+ * Returns +nil+ if the key is not found.
+ *
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
rb_hash_assoc(VALUE hash, VALUE key)
{
- st_table *table;
- const struct st_hash_type *orighash;
VALUE args[2];
if (RHASH_EMPTY_P(hash)) return Qnil;
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- table = RHASH_ST_TABLE(hash);
- orighash = table->type;
-
- if (orighash != &identhash) {
- VALUE value;
- struct reset_hash_type_arg ensure_arg;
- struct st_hash_type assochash;
-
- assochash.compare = assoc_cmp;
- assochash.hash = orighash->hash;
- table->type = &assochash;
- args[0] = hash;
- args[1] = key;
- ensure_arg.hash = hash;
- ensure_arg.orighash = orighash;
- value = rb_ensure(lookup2_call, (VALUE)&args, reset_hash_type, (VALUE)&ensure_arg);
+ if (RHASH_ST_TABLE_P(hash) && !RHASH_IDENTHASH_P(hash)) {
+ VALUE value = Qundef;
+ st_table assoctable = *RHASH_ST_TABLE(hash);
+ assoctable.type = &(struct st_hash_type){
+ .compare = assoc_cmp,
+ .hash = assoctable.type->hash,
+ };
+ VALUE arg = (VALUE)&(struct assoc_arg){
+ .tbl = &assoctable,
+ .key = (st_data_t)key,
+ };
+
+ if (RB_OBJ_FROZEN(hash)) {
+ value = assoc_lookup(arg);
+ }
+ else {
+ hash_iter_lev_inc(hash);
+ value = rb_ensure(assoc_lookup, arg, hash_foreach_ensure, hash);
+ }
+ hash_verify(hash);
if (!UNDEF_P(value)) return rb_assoc_new(key, value);
}
@@ -4185,15 +4439,18 @@ rassoc_i(VALUE key, VALUE val, VALUE arg)
/*
* call-seq:
- * hash.rassoc(value) -> new_array or nil
+ * rassoc(value) -> new_array or nil
+ *
+ * Searches +self+ for the first entry whose value is <tt>==</tt> to the given +value+;
+ * see {Entry Order}[rdoc-ref:Hash@Entry+Order].
+ *
+ * If the entry is found, returns its key and value as a 2-element array;
+ * returns +nil+ if not found:
*
- * Returns a new 2-element \Array consisting of the key and value
- * of the first-found entry whose value is <tt>==</tt> to value
- * (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
* h = {foo: 0, bar: 1, baz: 1}
* h.rassoc(1) # => [:bar, 1]
*
- * Returns +nil+ if no such value found.
+ * Related: see {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -4221,33 +4478,38 @@ flatten_i(VALUE key, VALUE val, VALUE ary)
/*
* call-seq:
- * hash.flatten -> new_array
- * hash.flatten(level) -> new_array
+ * flatten(depth = 1) -> new_array
+ *
+ * With positive integer +depth+,
+ * returns a new array that is a recursive flattening of +self+ to the given +depth+.
+ *
+ * At each level of recursion:
*
- * Returns a new \Array object that is a 1-dimensional flattening of +self+.
+ * - Each element whose value is an array is "flattened" (that is, replaced by its individual array elements);
+ * see Array#flatten.
+ * - Each element whose value is not an array is unchanged.
+ * even if the value is an object that has instance method flatten (such as a hash).
*
- * ---
+ * Examples; note that entry <tt>foo: {bar: 1, baz: 2}</tt> is never flattened.
*
- * By default, nested Arrays are not flattened:
- * h = {foo: 0, bar: [:bat, 3], baz: 2}
- * h.flatten # => [:foo, 0, :bar, [:bat, 3], :baz, 2]
+ * h = {foo: {bar: 1, baz: 2}, bat: [:bam, [:bap, [:bah]]]}
+ * h.flatten(1) # => [:foo, {bar: 1, baz: 2}, :bat, [:bam, [:bap, [:bah]]]]
+ * h.flatten(2) # => [:foo, {bar: 1, baz: 2}, :bat, :bam, [:bap, [:bah]]]
+ * h.flatten(3) # => [:foo, {bar: 1, baz: 2}, :bat, :bam, :bap, [:bah]]
+ * h.flatten(4) # => [:foo, {bar: 1, baz: 2}, :bat, :bam, :bap, :bah]
+ * h.flatten(5) # => [:foo, {bar: 1, baz: 2}, :bat, :bam, :bap, :bah]
*
- * Takes the depth of recursive flattening from \Integer argument +level+:
- * h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]}
- * h.flatten(1) # => [:foo, 0, :bar, [:bat, [:baz, [:bat]]]]
- * h.flatten(2) # => [:foo, 0, :bar, :bat, [:baz, [:bat]]]
- * h.flatten(3) # => [:foo, 0, :bar, :bat, :baz, [:bat]]
- * h.flatten(4) # => [:foo, 0, :bar, :bat, :baz, :bat]
+ * With negative integer +depth+,
+ * flattens all levels:
*
- * When +level+ is negative, flattens all nested Arrays:
- * h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]}
- * h.flatten(-1) # => [:foo, 0, :bar, :bat, :baz, :bat]
- * h.flatten(-2) # => [:foo, 0, :bar, :bat, :baz, :bat]
+ * h.flatten(-1) # => [:foo, {bar: 1, baz: 2}, :bat, :bam, :bap, :bah]
*
- * When +level+ is zero, returns the equivalent of #to_a :
- * h = {foo: 0, bar: [:bat, 3], baz: 2}
- * h.flatten(0) # => [[:foo, 0], [:bar, [:bat, 3]], [:baz, 2]]
- * h.flatten(0) == h.to_a # => true
+ * With +depth+ zero,
+ * returns the equivalent of #to_a:
+ *
+ * h.flatten(0) # => [[:foo, {bar: 1, baz: 2}], [:bat, [:bam, [:bap, [:bah]]]]]
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
@@ -4292,44 +4554,46 @@ delete_if_nil(VALUE key, VALUE value, VALUE hash)
return ST_CONTINUE;
}
-static int
-set_if_not_nil(VALUE key, VALUE value, VALUE hash)
-{
- if (!NIL_P(value)) {
- rb_hash_aset(hash, key, value);
- }
- return ST_CONTINUE;
-}
-
/*
* call-seq:
- * hash.compact -> new_hash
+ * compact -> new_hash
*
* Returns a copy of +self+ with all +nil+-valued entries removed:
+ *
* h = {foo: 0, bar: nil, baz: 2, bat: nil}
- * h1 = h.compact
- * h1 # => {:foo=>0, :baz=>2}
+ * h.compact # => {foo: 0, baz: 2}
+ *
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
rb_hash_compact(VALUE hash)
{
- VALUE result = rb_hash_new();
+ VALUE result = rb_hash_dup(hash);
if (!RHASH_EMPTY_P(hash)) {
- rb_hash_foreach(hash, set_if_not_nil, result);
+ rb_hash_foreach(result, delete_if_nil, result);
+ compact_after_delete(result);
+ }
+ else if (rb_hash_compare_by_id_p(hash)) {
+ result = rb_hash_compare_by_id(result);
}
return result;
}
/*
* call-seq:
- * hash.compact! -> self or nil
+ * compact! -> self or nil
+ *
+ * If +self+ contains any +nil+-valued entries,
+ * returns +self+ with all +nil+-valued entries removed;
+ * returns +nil+ otherwise:
*
- * Returns +self+ with all its +nil+-valued entries removed (in place):
* h = {foo: 0, bar: nil, baz: 2, bat: nil}
- * h.compact! # => {:foo=>0, :baz=>2}
+ * h.compact!
+ * h # => {foo: 0, baz: 2}
+ * h.compact! # => nil
*
- * Returns +nil+ if no entries were removed.
+ * Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
*/
static VALUE
@@ -4346,34 +4610,30 @@ rb_hash_compact_bang(VALUE hash)
return Qnil;
}
-static st_table *rb_init_identtable_with_size(st_index_t size);
-
/*
* call-seq:
- * hash.compare_by_identity -> self
+ * compare_by_identity -> self
*
- * Sets +self+ to consider only identity in comparing keys;
- * two keys are considered the same only if they are the same object;
- * returns +self+.
+ * Sets +self+ to compare keys using _identity_ (rather than mere _equality_);
+ * returns +self+:
+ *
+ * By default, two keys are considered to be the same key
+ * if and only if they are _equal_ objects (per method #eql?):
*
- * By default, these two object are considered to be the same key,
- * so +s1+ will overwrite +s0+:
- * s0 = 'x'
- * s1 = 'x'
* h = {}
- * h.compare_by_identity? # => false
- * h[s0] = 0
- * h[s1] = 1
+ * h['x'] = 0
+ * h['x'] = 1 # Overwrites.
* h # => {"x"=>1}
*
- * After calling \#compare_by_identity, the keys are considered to be different,
- * and therefore do not overwrite each other:
- * h = {}
- * h.compare_by_identity # => {}
- * h.compare_by_identity? # => true
- * h[s0] = 0
- * h[s1] = 1
- * h # => {"x"=>0, "x"=>1}
+ * When this method has been called, two keys are considered to be the same key
+ * if and only if they are the _same_ object:
+ *
+ * h.compare_by_identity
+ * h['x'] = 2 # Does not overwrite.
+ * h # => {"x"=>1, "x"=>2}
+ *
+ * Related: #compare_by_identity?;
+ * see also {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
VALUE
@@ -4385,38 +4645,66 @@ rb_hash_compare_by_id(VALUE hash)
if (rb_hash_compare_by_id_p(hash)) return hash;
rb_hash_modify_check(hash);
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
+ if (hash_iterating_p(hash)) {
+ rb_raise(rb_eRuntimeError, "compare_by_identity during iteration");
+ }
- tmp = hash_alloc(0);
- identtable = rb_init_identtable_with_size(RHASH_SIZE(hash));
- RHASH_ST_TABLE_SET(tmp, identtable);
- rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_TABLE_SET(hash, identtable);
- RHASH_ST_CLEAR(tmp);
+ if (RHASH_TABLE_EMPTY_P(hash)) {
+ // Fast path: There's nothing to rehash, so we don't need a `tmp` table.
+ // We're most likely an AR table, so this will need an allocation.
+ ar_force_convert_table(hash, __FILE__, __LINE__);
+ HASH_ASSERT(RHASH_ST_TABLE_P(hash));
+
+ RHASH_ST_TABLE(hash)->type = &identhash;
+ }
+ else {
+ // Slow path: Need to rehash the members of `self` into a new
+ // `tmp` table using the new `identhash` compare/hash functions.
+ tmp = hash_alloc(0);
+ hash_st_table_init(tmp, &identhash, RHASH_SIZE(hash));
+ identtable = RHASH_ST_TABLE(tmp);
+
+ rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
+ rb_hash_free(hash);
+
+ // We know for sure `identtable` is an st table,
+ // so we can skip `ar_force_convert_table` here.
+ rb_hash_st_table_set(hash, identtable);
+ RHASH_ST_CLEAR(tmp);
+ }
+
+ rb_gc_register_pinning_obj(hash);
return hash;
}
/*
* call-seq:
- * hash.compare_by_identity? -> true or false
+ * compare_by_identity? -> true or false
+ *
+ * Returns whether #compare_by_identity has been called:
*
- * Returns +true+ if #compare_by_identity has been called, +false+ otherwise.
+ * h = {}
+ * h.compare_by_identity? # => false
+ * h.compare_by_identity
+ * h.compare_by_identity? # => true
+ *
+ * Related: #compare_by_identity;
+ * see also {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
VALUE
rb_hash_compare_by_id_p(VALUE hash)
{
- return RBOOL(RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash);
+ return RBOOL(RHASH_IDENTHASH_P(hash));
}
VALUE
rb_ident_hash_new(void)
{
VALUE hash = rb_hash_new();
- RHASH_ST_TABLE_SET(hash, st_init_table(&identhash));
+ hash_st_table_init(hash, &identhash, 0);
+ rb_gc_register_pinning_obj(hash);
return hash;
}
@@ -4424,7 +4712,8 @@ VALUE
rb_ident_hash_new_with_size(st_index_t size)
{
VALUE hash = rb_hash_new();
- RHASH_ST_TABLE_SET(hash, st_init_table_with_size(&identhash, size));
+ hash_st_table_init(hash, &identhash, size);
+ rb_gc_register_pinning_obj(hash);
return hash;
}
@@ -4434,12 +4723,6 @@ rb_init_identtable(void)
return st_init_table(&identhash);
}
-static st_table *
-rb_init_identtable_with_size(st_index_t size)
-{
- return st_init_table_with_size(&identhash, size);
-}
-
static int
any_p_i(VALUE key, VALUE value, VALUE arg)
{
@@ -4475,31 +4758,42 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
/*
* call-seq:
- * hash.any? -> true or false
- * hash.any?(object) -> true or false
- * hash.any? {|key, value| ... } -> true or false
+ * any? -> true or false
+ * any?(entry) -> true or false
+ * any? {|key, value| ... } -> true or false
*
* Returns +true+ if any element satisfies a given criterion;
* +false+ otherwise.
*
+ * If +self+ has no element, returns +false+ and argument or block are not used;
+ * otherwise behaves as below.
+ *
* With no argument and no block,
- * returns +true+ if +self+ is non-empty; +false+ if empty.
+ * returns +true+ if +self+ is non-empty, +false+ otherwise.
*
- * With argument +object+ and no block,
+ * With argument +entry+ and no block,
* returns +true+ if for any key +key+
- * <tt>h.assoc(key) == object</tt>:
+ * <tt>self.assoc(key) == entry</tt>, +false+ otherwise:
+ *
* h = {foo: 0, bar: 1, baz: 2}
+ * h.assoc(:bar) # => [:bar, 1]
* h.any?([:bar, 1]) # => true
* h.any?([:bar, 0]) # => false
- * h.any?([:baz, 1]) # => false
*
- * With no argument and a block,
+ * With no argument and a block given,
* calls the block with each key-value pair;
- * returns +true+ if the block returns any truthy value,
+ * returns +true+ if the block returns a truthy value,
* +false+ otherwise:
+ *
* h = {foo: 0, bar: 1, baz: 2}
* h.any? {|key, value| value < 3 } # => true
* h.any? {|key, value| value > 3 } # => false
+ *
+ * With both argument +entry+ and a block given,
+ * issues a warning and ignores the block.
+ *
+ * Related: Enumerable#any? (which this method overrides);
+ * see also {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -4533,31 +4827,37 @@ rb_hash_any_p(int argc, VALUE *argv, VALUE hash)
/*
* call-seq:
- * hash.dig(key, *identifiers) -> object
+ * dig(key, *identifiers) -> object
+ *
+ * Finds and returns an object found in nested objects,
+ * as specified by +key+ and +identifiers+.
*
- * Finds and returns the object in nested objects
- * that is specified by +key+ and +identifiers+.
* The nested objects may be instances of various classes.
* See {Dig Methods}[rdoc-ref:dig_methods.rdoc].
*
- * Nested Hashes:
+ * Nested hashes:
+ *
* h = {foo: {bar: {baz: 2}}}
- * h.dig(:foo) # => {:bar=>{:baz=>2}}
- * h.dig(:foo, :bar) # => {:baz=>2}
+ * h.dig(:foo) # => {bar: {baz: 2}}
+ * h.dig(:foo, :bar) # => {baz: 2}
* h.dig(:foo, :bar, :baz) # => 2
* h.dig(:foo, :bar, :BAZ) # => nil
*
- * Nested Hashes and Arrays:
+ * Nested hashes and arrays:
+ *
* h = {foo: {bar: [:a, :b, :c]}}
* h.dig(:foo, :bar, 2) # => :c
*
- * This method will use the {default values}[rdoc-ref:Hash@Default+Values]
- * for keys that are not present:
+ * If no such object is found,
+ * returns the {hash default}[rdoc-ref:Hash@Hash+Default]:
+ *
* h = {foo: {bar: [:a, :b, :c]}}
* h.dig(:hello) # => nil
* h.default_proc = -> (hash, _key) { hash }
- * h.dig(:hello, :world) # => h
- * h.dig(:hello, :world, :foo, :bar, 2) # => :c
+ * h.dig(:hello, :world)
+ * # => {foo: {bar: [:a, :b, :c]}}
+ *
+ * Related: {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
static VALUE
@@ -4592,14 +4892,21 @@ hash_le(VALUE hash1, VALUE hash2)
/*
* call-seq:
- * hash <= other_hash -> true or false
+ * self <= other -> true or false
*
- * Returns +true+ if +hash+ is a subset of +other_hash+, +false+ otherwise:
- * h1 = {foo: 0, bar: 1}
- * h2 = {foo: 0, bar: 1, baz: 2}
- * h1 <= h2 # => true
- * h2 <= h1 # => false
- * h1 <= h1 # => true
+ * Returns whether the entries of +self+ are a subset of the entries of +other+:
+ *
+ * h0 = {foo: 0, bar: 1}
+ * h1 = {foo: 0, bar: 1, baz: 2}
+ * h0 <= h0 # => true
+ * h0 <= h1 # => true
+ * h1 <= h0 # => false
+ *
+ * See {Hash Inclusion}[rdoc-ref:language/hash_inclusion.rdoc].
+ *
+ * Raises TypeError if +other_hash+ is not a hash and cannot be converted to a hash.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
static VALUE
rb_hash_le(VALUE hash, VALUE other)
@@ -4611,14 +4918,23 @@ rb_hash_le(VALUE hash, VALUE other)
/*
* call-seq:
- * hash < other_hash -> true or false
+ * self < other -> true or false
*
- * Returns +true+ if +hash+ is a proper subset of +other_hash+, +false+ otherwise:
- * h1 = {foo: 0, bar: 1}
- * h2 = {foo: 0, bar: 1, baz: 2}
- * h1 < h2 # => true
- * h2 < h1 # => false
- * h1 < h1 # => false
+ * Returns whether the entries of +self+ are a proper subset of the entries of +other+:
+ *
+ * h = {foo: 0, bar: 1}
+ * h < {foo: 0, bar: 1, baz: 2} # => true # Proper subset.
+ * h < {baz: 2, bar: 1, foo: 0} # => true # Order may differ.
+ * h < h # => false # Not a proper subset.
+ * h < {bar: 1, foo: 0} # => false # Not a proper subset.
+ * h < {foo: 0, bat: 1, baz: 2} # => false # Different key.
+ * h < {foo: 0, bar: 3, baz: 2} # => false # Different value.
+ *
+ * See {Hash Inclusion}[rdoc-ref:language/hash_inclusion.rdoc].
+ *
+ * Raises TypeError if +other_hash+ is not a hash and cannot be converted to a hash.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
static VALUE
rb_hash_lt(VALUE hash, VALUE other)
@@ -4630,14 +4946,21 @@ rb_hash_lt(VALUE hash, VALUE other)
/*
* call-seq:
- * hash >= other_hash -> true or false
+ * self >= other -> true or false
*
- * Returns +true+ if +hash+ is a superset of +other_hash+, +false+ otherwise:
- * h1 = {foo: 0, bar: 1, baz: 2}
- * h2 = {foo: 0, bar: 1}
- * h1 >= h2 # => true
- * h2 >= h1 # => false
- * h1 >= h1 # => true
+ * Returns whether the entries of +self+ are a superset of the entries of +other+:
+ *
+ * h0 = {foo: 0, bar: 1, baz: 2}
+ * h1 = {foo: 0, bar: 1}
+ * h0 >= h1 # => true
+ * h0 >= h0 # => true
+ * h1 >= h0 # => false
+ *
+ * See {Hash Inclusion}[rdoc-ref:language/hash_inclusion.rdoc].
+ *
+ * Raises TypeError if +other_hash+ is not a hash and cannot be converted to a hash.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
static VALUE
rb_hash_ge(VALUE hash, VALUE other)
@@ -4649,14 +4972,23 @@ rb_hash_ge(VALUE hash, VALUE other)
/*
* call-seq:
- * hash > other_hash -> true or false
+ * self > other -> true or false
*
- * Returns +true+ if +hash+ is a proper superset of +other_hash+, +false+ otherwise:
- * h1 = {foo: 0, bar: 1, baz: 2}
- * h2 = {foo: 0, bar: 1}
- * h1 > h2 # => true
- * h2 > h1 # => false
- * h1 > h1 # => false
+ * Returns whether the entries of +self+ are a proper superset of the entries of +other+:
+ *
+ * h = {foo: 0, bar: 1, baz: 2}
+ * h > {foo: 0, bar: 1} # => true # Proper superset.
+ * h > {bar: 1, foo: 0} # => true # Order may differ.
+ * h > h # => false # Not a proper superset.
+ * h > {baz: 2, bar: 1, foo: 0} # => false # Not a proper superset.
+ * h > {foo: 0, bat: 1} # => false # Different key.
+ * h > {foo: 0, bar: 3} # => false # Different value.
+ *
+ * See {Hash Inclusion}[rdoc-ref:language/hash_inclusion.rdoc].
+ *
+ * Raises TypeError if +other_hash+ is not a hash and cannot be converted to a hash.
+ *
+ * Related: see {Methods for Comparing}[rdoc-ref:Hash@Methods+for+Comparing].
*/
static VALUE
rb_hash_gt(VALUE hash, VALUE other)
@@ -4675,15 +5007,20 @@ hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash))
/*
* call-seq:
- * hash.to_proc -> proc
+ * to_proc -> proc
+ *
+ * Returns a Proc object that maps a key to its value:
*
- * Returns a \Proc object that maps a key to its value:
* h = {foo: 0, bar: 1, baz: 2}
* proc = h.to_proc
* proc.class # => Proc
* proc.call(:foo) # => 0
* proc.call(:bar) # => 1
* proc.call(:nosuch) # => nil
+ * h.default_proc = proc { |hash, key| "Missing key: #{key}" } # This affect the existing proc object
+ * proc.call(:nosuch) # => "Missing key: #{nosuch}"
+ *
+ * Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
rb_hash_to_proc(VALUE hash)
@@ -4691,6 +5028,7 @@ rb_hash_to_proc(VALUE hash)
return rb_func_lambda_new(hash_proc_call, hash, 1, 1);
}
+/* :nodoc: */
static VALUE
rb_hash_deconstruct_keys(VALUE hash, VALUE keys)
{
@@ -4700,10 +5038,8 @@ rb_hash_deconstruct_keys(VALUE hash, VALUE keys)
static int
add_new_i(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
{
- VALUE *args = (VALUE *)arg;
if (existing) return ST_STOP;
- RB_OBJ_WRITTEN(args[0], Qundef, (VALUE)*key);
- RB_OBJ_WRITE(args[0], (VALUE *)val, args[1]);
+ *val = arg;
return ST_CONTINUE;
}
@@ -4715,23 +5051,25 @@ int
rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
{
st_table *tbl;
- int ret = 0;
- VALUE args[2];
- args[0] = hash;
- args[1] = val;
+ int ret = -1;
if (RHASH_AR_TABLE_P(hash)) {
- hash_ar_table(hash);
-
- ret = ar_update(hash, (st_data_t)key, add_new_i, (st_data_t)args);
- if (ret != -1) {
- return ret;
+ ret = ar_update(hash, (st_data_t)key, add_new_i, (st_data_t)val);
+ if (ret == -1) {
+ ar_force_convert_table(hash, __FILE__, __LINE__);
}
- ar_try_convert_table(hash);
}
- tbl = RHASH_TBL_RAW(hash);
- return st_update(tbl, (st_data_t)key, add_new_i, (st_data_t)args);
+ if (ret == -1) {
+ tbl = RHASH_TBL_RAW(hash);
+ ret = st_update(tbl, (st_data_t)key, add_new_i, (st_data_t)val);
+ }
+ if (!ret) {
+ // Newly inserted
+ RB_OBJ_WRITTEN(hash, Qundef, key);
+ RB_OBJ_WRITTEN(hash, Qundef, val);
+ }
+ return ret;
}
static st_data_t
@@ -4761,15 +5099,6 @@ rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
if (argc > 0) {
st_index_t size = argc / 2;
- if (RHASH_TABLE_NULL_P(hash)) {
- if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- hash_ar_table(hash);
- }
- else {
- RHASH_TBL_RAW(hash);
- }
- }
-
if (RHASH_AR_TABLE_P(hash) &&
(RHASH_AR_TABLE_SIZE(hash) + size <= RHASH_AR_TABLE_MAX_SIZE)) {
ar_bulk_insert(hash, argc, argv);
@@ -4780,6 +5109,14 @@ rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
}
}
+VALUE
+rb_hash_new_with_bulk_insert(long argc, const VALUE *argv)
+{
+ VALUE val = rb_hash_new_with_size(argc / 2);
+ rb_hash_bulk_insert(argc, argv, val);
+ return val;
+}
+
static char **origenviron;
#ifdef _WIN32
#define GET_ENVIRON(e) ((e) = rb_w32_get_environ())
@@ -4807,8 +5144,7 @@ extern char **environ;
#define ENVNMATCH(s1, s2, n) (memcmp((s1), (s2), (n)) == 0)
#endif
-#define ENV_LOCK() RB_VM_LOCK_ENTER()
-#define ENV_UNLOCK() RB_VM_LOCK_LEAVE()
+#define ENV_LOCKING() RB_VM_LOCKING()
static inline rb_encoding *
env_encoding(void)
@@ -4830,28 +5166,27 @@ env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
}
static VALUE
-env_str_new(const char *ptr, long len)
+env_str_new(const char *ptr, long len, rb_encoding *enc)
{
- return env_enc_str_new(ptr, len, env_encoding());
+ return env_enc_str_new(ptr, len, enc);
}
static VALUE
-env_str_new2(const char *ptr)
+env_str_new2(const char *ptr, rb_encoding *enc)
{
if (!ptr) return Qnil;
- return env_str_new(ptr, strlen(ptr));
+ return env_str_new(ptr, strlen(ptr), enc);
}
static VALUE
getenv_with_lock(const char *name)
{
VALUE ret;
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
const char *val = getenv(name);
- ret = env_str_new2(val);
+ ret = env_str_new2(val, enc);
}
- ENV_UNLOCK();
return ret;
}
@@ -4860,11 +5195,9 @@ has_env_with_lock(const char *name)
{
const char *val;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
val = getenv(name);
}
- ENV_UNLOCK();
return val ? true : false;
}
@@ -4872,9 +5205,7 @@ has_env_with_lock(const char *name)
static const char TZ_ENV[] = "TZ";
static void *
-get_env_cstr(
- VALUE str,
- const char *name)
+get_env_cstr(VALUE str, const char *name)
{
char *var;
rb_encoding *enc = rb_enc_get(str);
@@ -4896,7 +5227,7 @@ static inline const char *
env_name(volatile VALUE *s)
{
const char *name;
- SafeStringValue(*s);
+ StringValue(*s);
get_env_ptr(name, *s);
return name;
}
@@ -4906,7 +5237,7 @@ env_name(volatile VALUE *s)
static VALUE env_aset(VALUE nm, VALUE val);
static void
-reset_by_modified_env(const char *nam)
+reset_by_modified_env(const char *nam, const char *val)
{
/*
* ENV['TZ'] = nil has a special meaning.
@@ -4915,7 +5246,7 @@ reset_by_modified_env(const char *nam)
* This hack might works only on Linux glibc.
*/
if (ENVMATCH(nam, TZ_ENV)) {
- ruby_reset_timezone();
+ ruby_reset_timezone(val);
}
}
@@ -4923,7 +5254,7 @@ static VALUE
env_delete(VALUE name)
{
const char *nam = env_name(name);
- reset_by_modified_env(nam);
+ reset_by_modified_env(nam, NULL);
VALUE val = getenv_with_lock(nam);
if (!NIL_P(val)) {
@@ -5016,7 +5347,7 @@ static VALUE
env_fetch(int argc, VALUE *argv, VALUE _)
{
VALUE key;
- long block_given;
+ int block_given;
const char *nam;
VALUE env;
@@ -5039,6 +5370,42 @@ env_fetch(int argc, VALUE *argv, VALUE _)
return env;
}
+/*
+ * call-seq:
+ * ENV.fetch_values(*names) -> array of values
+ * ENV.fetch_values(*names) {|name| ... } -> array of values
+ *
+ * Returns an Array containing the environment variable values associated with
+ * the given names:
+ * ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
+ * ENV.fetch_values('foo', 'baz') # => ["0", "2"]
+ *
+ * Otherwise if a block is given yields +name+ to
+ * the block and returns the block's return value:
+ * ENV.fetch_values('foo', 'bam') {|key| key.to_s} # => ["0", "bam"]
+ *
+ * Raises KeyError if +name+ is valid, but not found and block is not given:
+ * ENV.fetch_values('foo', 'bam') # Raises KeyError (key not found: "bam")
+ *
+ * Returns an empty Array if no names given.
+ *
+ * Raises an exception if any name is invalid.
+ * See {Invalid Names and Values}[rdoc-ref:ENV@Invalid+Names+and+Values].
+ */
+
+static VALUE
+env_fetch_values(int argc, VALUE *argv, VALUE ehash)
+{
+ VALUE result = rb_ary_new2(argc);
+ long i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(result, env_fetch(1, &argv[i], ehash));
+ }
+
+ return result;
+}
+
#if defined(_WIN32) || (defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
#elif defined __sun
static int
@@ -5069,44 +5436,6 @@ envix(const char *nam)
}
#endif
-#if defined(_WIN32)
-static size_t
-getenvsize(const WCHAR* p)
-{
- const WCHAR* porg = p;
- while (*p++) p += lstrlenW(p) + 1;
- return p - porg + 1;
-}
-
-static size_t
-getenvblocksize(void)
-{
-#ifdef _MAX_ENV
- return _MAX_ENV;
-#else
- return 32767;
-#endif
-}
-
-static int
-check_envsize(size_t n)
-{
- if (_WIN32_WINNT < 0x0600 && rb_w32_osver() < 6) {
- /* https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx */
- /* Windows Server 2003 and Windows XP: The maximum size of the
- * environment block for the process is 32,767 characters. */
- WCHAR* p = GetEnvironmentStringsW();
- if (!p) return -1; /* never happen */
- n += getenvsize(p);
- FreeEnvironmentStringsW(p);
- if (n >= getenvblocksize()) {
- return -1;
- }
- }
- return 0;
-}
-#endif
-
#if defined(_WIN32) || \
(defined(__sun) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV)))
@@ -5132,9 +5461,6 @@ void
ruby_setenv(const char *name, const char *value)
{
#if defined(_WIN32)
-# if defined(MINGW_HAS_SECURE_API) || RUBY_MSVCRT_VERSION >= 80
-# define HAVE__WPUTENV_S 1
-# endif
VALUE buf;
WCHAR *wname;
WCHAR *wvalue = 0;
@@ -5145,43 +5471,30 @@ ruby_setenv(const char *name, const char *value)
if (value) {
int len2;
len2 = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);
- if (check_envsize((size_t)len + len2)) { /* len and len2 include '\0' */
- goto fail; /* 2 for '=' & '\0' */
- }
wname = ALLOCV_N(WCHAR, buf, len + len2);
wvalue = wname + len;
MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, len);
MultiByteToWideChar(CP_UTF8, 0, value, -1, wvalue, len2);
-#ifndef HAVE__WPUTENV_S
- wname[len-1] = L'=';
-#endif
}
else {
wname = ALLOCV_N(WCHAR, buf, len + 1);
MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, len);
wvalue = wname + len;
*wvalue = L'\0';
-#ifndef HAVE__WPUTENV_S
- wname[len-1] = L'=';
-#endif
}
- ENV_LOCK();
- {
-#ifndef HAVE__WPUTENV_S
- failed = _wputenv(wname);
-#else
+ ENV_LOCKING() {
+ /* Use _wputenv_s() instead of SetEnvironmentVariableW() to make sure
+ * special variables like "TZ" are interpret by libc. */
failed = _wputenv_s(wname, wvalue);
-#endif
}
- ENV_UNLOCK();
ALLOCV_END(buf);
/* even if putenv() failed, clean up and try to delete the
* variable from the system area. */
if (!value || !*value) {
/* putenv() doesn't handle empty value */
- if (!SetEnvironmentVariable(name, value) &&
+ if (!SetEnvironmentVariableW(wname, value ? wvalue : NULL) &&
GetLastError() != ERROR_ENVVAR_NOT_FOUND) goto fail;
}
if (failed) {
@@ -5191,30 +5504,24 @@ ruby_setenv(const char *name, const char *value)
#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
if (value) {
int ret;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
ret = setenv(name, value, 1);
}
- ENV_UNLOCK();
- if (ret) rb_sys_fail_str(rb_sprintf("setenv(%s)", name));
+ if (ret) rb_sys_fail_sprintf("setenv(%s)", name);
}
else {
#ifdef VOID_UNSETENV
- ENV_LOCK();
- {
+ ENV_LOCKING() {
unsetenv(name);
}
- ENV_UNLOCK();
#else
int ret;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
ret = unsetenv(name);
}
- ENV_UNLOCK();
- if (ret) rb_sys_fail_str(rb_sprintf("unsetenv(%s)", name));
+ if (ret) rb_sys_fail_sprintf("unsetenv(%s)", name);
#endif
}
#elif defined __sun
@@ -5231,12 +5538,11 @@ ruby_setenv(const char *name, const char *value)
mem_size = len + strlen(value) + 2;
mem_ptr = malloc(mem_size);
if (mem_ptr == NULL)
- rb_sys_fail_str(rb_sprintf("malloc(%"PRIuSIZE")", mem_size));
+ rb_sys_fail_sprintf("malloc(%"PRIuSIZE")", mem_size);
snprintf(mem_ptr, mem_size, "%s=%s", name, value);
}
- ENV_LOCK();
- {
+ ENV_LOCKING() {
for (env_ptr = GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
if (!strncmp(str, name, len) && str[len] == '=') {
if (!in_origenv(str)) free(str);
@@ -5245,27 +5551,23 @@ ruby_setenv(const char *name, const char *value)
}
}
}
- ENV_UNLOCK();
if (value) {
int ret;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
ret = putenv(mem_ptr);
}
- ENV_UNLOCK();
if (ret) {
free(mem_ptr);
- rb_sys_fail_str(rb_sprintf("putenv(%s)", name));
+ rb_sys_fail_sprintf("putenv(%s)", name);
}
}
#else /* WIN32 */
size_t len;
int i;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
i = envix(name); /* where does it go? */
if (environ == origenviron) { /* need we copy environment? */
@@ -5306,7 +5608,6 @@ ruby_setenv(const char *name, const char *value)
finish:;
}
- ENV_UNLOCK();
#endif /* WIN32 */
}
@@ -5373,15 +5674,15 @@ env_aset(VALUE nm, VALUE val)
env_delete(nm);
return Qnil;
}
- SafeStringValue(nm);
- SafeStringValue(val);
+ StringValue(nm);
+ StringValue(val);
/* nm can be modified in `val.to_str`, don't get `name` before
* check for `val` */
get_env_ptr(name, nm);
get_env_ptr(value, val);
ruby_setenv(name, value);
- reset_by_modified_env(name);
+ reset_by_modified_env(name, value);
return val;
}
@@ -5391,8 +5692,7 @@ env_keys(int raw)
rb_encoding *enc = raw ? 0 : rb_locale_encoding();
VALUE ary = rb_ary_new();
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
@@ -5406,7 +5706,6 @@ env_keys(int raw)
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return ary;
}
@@ -5436,8 +5735,7 @@ rb_env_size(VALUE ehash, VALUE args, VALUE eobj)
char **env;
long cnt = 0;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
env = GET_ENVIRON(environ);
for (; *env ; ++env) {
if (strchr(*env, '=')) {
@@ -5446,7 +5744,6 @@ rb_env_size(VALUE ehash, VALUE args, VALUE eobj)
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return LONG2FIX(cnt);
}
@@ -5487,20 +5784,19 @@ env_values(void)
{
VALUE ary = rb_ary_new();
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, env_str_new2(s+1));
+ rb_ary_push(ary, env_str_new2(s+1, enc));
}
env++;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return ary;
}
@@ -5561,7 +5857,7 @@ env_each_value(VALUE ehash)
* ENV.each_pair { |name, value| block } -> ENV
* ENV.each_pair -> an_enumerator
*
- * Yields each environment variable name and its value as a 2-element \Array:
+ * Yields each environment variable name and its value as a 2-element Array:
* h = {}
* ENV.each_pair { |name, value| h[name] = value } # => ENV
* h # => {"bar"=>"1", "foo"=>"0"}
@@ -5581,21 +5877,20 @@ env_each_pair(VALUE ehash)
VALUE ary = rb_ary_new();
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, env_str_new(*env, s-*env));
- rb_ary_push(ary, env_str_new2(s+1));
+ rb_ary_push(ary, env_str_new(*env, s-*env, enc));
+ rb_ary_push(ary, env_str_new2(s+1, enc));
}
env++;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
if (rb_block_pair_yield_optimizable()) {
for (i=0; i<RARRAY_LEN(ary); i+=2) {
@@ -5697,7 +5992,7 @@ env_delete_if(VALUE ehash)
* Returns +nil+ in the Array for each name that is not an ENV name:
* ENV.values_at('foo', 'bat', 'bar', 'bam') # => ["0", nil, "1", nil]
*
- * Returns an empty \Array if no names given.
+ * Returns an empty Array if no names given.
*
* Raises an exception if any name is invalid.
* See {Invalid Names and Values}[rdoc-ref:ENV@Invalid+Names+and+Values].
@@ -5932,30 +6227,27 @@ env_to_s(VALUE _)
static VALUE
env_inspect(VALUE _)
{
- VALUE i;
VALUE str = rb_str_buf_new2("{");
+ rb_encoding *enc = env_encoding();
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
- char *s = strchr(*env, '=');
+ const char *s = strchr(*env, '=');
if (env != environ) {
rb_str_buf_cat2(str, ", ");
}
if (s) {
- rb_str_buf_cat2(str, "\"");
- rb_str_buf_cat(str, *env, s-*env);
- rb_str_buf_cat2(str, "\"=>");
- i = rb_inspect(rb_str_new2(s+1));
- rb_str_buf_append(str, i);
+ rb_str_buf_append(str, rb_str_inspect(env_enc_str_new(*env, s-*env, enc)));
+ rb_str_buf_cat2(str, " => ");
+ s++;
+ rb_str_buf_append(str, rb_str_inspect(env_enc_str_new(s, strlen(s), enc)));
}
env++;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
rb_str_buf_cat2(str, "}");
@@ -5976,20 +6268,19 @@ env_to_a(VALUE _)
{
VALUE ary = rb_ary_new();
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, rb_assoc_new(env_str_new(*env, s-*env),
- env_str_new2(s+1)));
+ rb_ary_push(ary, rb_assoc_new(env_str_new(*env, s-*env, enc),
+ env_str_new2(s+1, enc)));
}
env++;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return ary;
}
@@ -6013,13 +6304,11 @@ env_size_with_lock(void)
{
int i = 0;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (env[i]) i++;
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return i;
}
@@ -6055,15 +6344,13 @@ env_empty_p(VALUE _)
{
bool empty = true;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
if (env[0] != 0) {
empty = false;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return RBOOL(empty);
}
@@ -6152,8 +6439,7 @@ env_has_value(VALUE dmy, VALUE obj)
VALUE ret = Qfalse;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
@@ -6168,7 +6454,6 @@ env_has_value(VALUE dmy, VALUE obj)
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return ret;
}
@@ -6195,13 +6480,12 @@ env_rassoc(VALUE dmy, VALUE obj)
VALUE result = Qnil;
- ENV_LOCK();
- {
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
const char *p = *env;
- char *s = strchr(p, '=');
+ const char *s = strchr(p, '=');
if (s++) {
long len = strlen(s);
if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
@@ -6213,7 +6497,6 @@ env_rassoc(VALUE dmy, VALUE obj)
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return result;
}
@@ -6237,18 +6520,18 @@ env_rassoc(VALUE dmy, VALUE obj)
static VALUE
env_key(VALUE dmy, VALUE value)
{
- SafeStringValue(value);
+ StringValue(value);
VALUE str = Qnil;
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **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);
+ str = env_str_new(*env, s-*env-1, enc);
break;
}
}
@@ -6256,7 +6539,6 @@ env_key(VALUE dmy, VALUE value)
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return str;
}
@@ -6266,20 +6548,19 @@ env_to_hash(void)
{
VALUE hash = rb_hash_new();
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_hash_aset(hash, env_str_new(*env, s-*env),
- env_str_new2(s+1));
+ rb_hash_aset(hash, env_str_new(*env, s-*env, enc),
+ env_str_new2(s+1, enc));
}
env++;
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
return hash;
}
@@ -6323,7 +6604,7 @@ env_f_to_hash(VALUE _)
* Each name/value pair in ENV is yielded to the block.
* The block must return a 2-element Array (name/value pair)
* that is added to the return Hash as a key and value:
- * ENV.to_h { |name, value| [name.to_sym, value.to_i] } # => {:bar=>1, :foo=>0}
+ * ENV.to_h { |name, value| [name.to_sym, value.to_i] } # => {bar: 1, foo: 0}
* Raises an exception if the block does not return an Array:
* ENV.to_h { |name, value| name } # Raises TypeError (wrong element type String (expected array))
* Raises an exception if the block returns an Array of the wrong size:
@@ -6419,21 +6700,20 @@ env_shift(VALUE _)
VALUE result = Qnil;
VALUE key = Qnil;
- ENV_LOCK();
- {
+ rb_encoding *enc = env_encoding();
+ ENV_LOCKING() {
char **env = GET_ENVIRON(environ);
if (*env) {
const char *p = *env;
- char *s = strchr(p, '=');
+ const char *s = strchr(p, '=');
if (s) {
- key = env_str_new(p, s-p);
- VALUE val = env_str_new2(getenv(RSTRING_PTR(key)));
+ key = env_str_new(p, s-p, enc);
+ VALUE val = env_str_new2(getenv(RSTRING_PTR(key)), enc);
result = rb_assoc_new(key, val);
}
}
FREE_ENVIRON(environ);
}
- ENV_UNLOCK();
if (!NIL_P(key)) {
env_delete(key);
@@ -6644,70 +6924,71 @@ static const rb_data_type_t env_data_type = {
};
/*
- * A \Hash maps each of its unique keys to a specific value.
+ * A \Hash object maps each of its unique keys to a specific value.
*
- * A \Hash has certain similarities to an \Array, but:
- * - An \Array index is always an \Integer.
- * - A \Hash key can be (almost) any object.
+ * A hash has certain similarities to an Array, but:
+ *
+ * - An array index is always an integer.
+ * - A hash key can be (almost) any object.
*
* === \Hash \Data Syntax
*
- * The older syntax for \Hash data uses the "hash rocket," <tt>=></tt>:
+ * The original syntax for a hash entry uses the "hash rocket," <tt>=></tt>:
*
* h = {:foo => 0, :bar => 1, :baz => 2}
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
- * Alternatively, but only for a \Hash key that's a \Symbol,
+ * Alternatively, but only for a key that's a symbol,
* you can use a newer JSON-style syntax,
- * where each bareword becomes a \Symbol:
+ * where each bareword becomes a symbol:
*
* h = {foo: 0, bar: 1, baz: 2}
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
- * You can also use a \String in place of a bareword:
+ * You can also use a string in place of a bareword:
*
* h = {'foo': 0, 'bar': 1, 'baz': 2}
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
* And you can mix the styles:
*
* h = {foo: 0, :bar => 1, 'baz': 2}
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
* But it's an error to try the JSON-style syntax
- * for a key that's not a bareword or a String:
+ * for a key that's not a bareword or a string:
*
* # Raises SyntaxError (syntax error, unexpected ':', expecting =>):
* h = {0: 'zero'}
*
- * Hash value can be omitted, meaning that value will be fetched from the context
+ * The value can be omitted, meaning that value will be fetched from the context
* by the name of the key:
*
* x = 0
* y = 100
* h = {x:, y:}
- * h # => {:x=>0, :y=>100}
+ * h # => {x: 0, y: 100}
*
* === Common Uses
*
- * You can use a \Hash to give names to objects:
+ * You can use a hash to give names to objects:
*
* person = {name: 'Matz', language: 'Ruby'}
- * person # => {:name=>"Matz", :language=>"Ruby"}
+ * person # => {name: "Matz", language: "Ruby"}
*
- * You can use a \Hash to give names to method arguments:
+ * You can use a hash to give names to method arguments:
*
* def some_method(hash)
* p hash
* end
- * some_method({foo: 0, bar: 1, baz: 2}) # => {:foo=>0, :bar=>1, :baz=>2}
+ * some_method({foo: 0, bar: 1, baz: 2}) # => {foo: 0, bar: 1, baz: 2}
*
- * Note: when the last argument in a method call is a \Hash,
+ * Note: when the last argument in a method call is a hash,
* the curly braces may be omitted:
*
- * some_method(foo: 0, bar: 1, baz: 2) # => {:foo=>0, :bar=>1, :baz=>2}
+ * some_method(foo: 0, bar: 1, baz: 2) # => {foo: 0, bar: 1, baz: 2}
*
- * You can use a \Hash to initialize an object:
+ * You can use a hash to initialize an object:
*
* class Dev
* attr_accessor :name, :language
@@ -6725,63 +7006,55 @@ static const rb_data_type_t env_data_type = {
*
* - A {hash literal}[rdoc-ref:syntax/literals.rdoc@Hash+Literals].
*
- * You can convert certain objects to Hashes with:
- *
- * - \Method #Hash.
+ * You can convert certain objects to hashes with:
*
- * You can create a \Hash by calling method Hash.new.
+ * - Method Kernel#Hash.
*
- * Create an empty Hash:
+ * You can create a hash by calling method Hash.new:
*
+ * # Create an empty hash.
* h = Hash.new
* h # => {}
* h.class # => Hash
*
- * You can create a \Hash by calling method Hash.[].
- *
- * Create an empty Hash:
+ * You can create a hash by calling method Hash.[]:
*
+ * # Create an empty hash.
* h = Hash[]
* h # => {}
- *
- * Create a \Hash with initial entries:
- *
+ * # Create a hash with initial entries.
* h = Hash[foo: 0, bar: 1, baz: 2]
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
- * You can create a \Hash by using its literal form (curly braces).
- *
- * Create an empty \Hash:
+ * You can create a hash by using its literal form (curly braces):
*
+ * # Create an empty hash.
* h = {}
* h # => {}
- *
- * Create a \Hash with initial entries:
- *
+ * # Create a +Hash+ with initial entries.
* h = {foo: 0, bar: 1, baz: 2}
- * h # => {:foo=>0, :bar=>1, :baz=>2}
- *
+ * h # => {foo: 0, bar: 1, baz: 2}
*
* === \Hash Value Basics
*
- * The simplest way to retrieve a \Hash value (instance method #[]):
+ * The simplest way to retrieve a hash value (instance method #[]):
*
* h = {foo: 0, bar: 1, baz: 2}
* h[:foo] # => 0
*
- * The simplest way to create or update a \Hash value (instance method #[]=):
+ * The simplest way to create or update a hash value (instance method #[]=):
*
* h = {foo: 0, bar: 1, baz: 2}
* h[:bat] = 3 # => 3
- * h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3}
+ * h # => {foo: 0, bar: 1, baz: 2, bat: 3}
* h[:foo] = 4 # => 4
- * h # => {:foo=>4, :bar=>1, :baz=>2, :bat=>3}
+ * h # => {foo: 4, bar: 1, baz: 2, bat: 3}
*
- * The simplest way to delete a \Hash entry (instance method #delete):
+ * The simplest way to delete a hash entry (instance method #delete):
*
* h = {foo: 0, bar: 1, baz: 2}
* h.delete(:bar) # => 1
- * h # => {:foo=>0, :baz=>2}
+ * h # => {foo: 0, baz: 2}
*
* === Entry Order
*
@@ -6789,41 +7062,41 @@ static const rb_data_type_t env_data_type = {
*
* - Iterative methods such as <tt>each</tt>, <tt>each_key</tt>, <tt>each_pair</tt>, <tt>each_value</tt>.
* - Other order-sensitive methods such as <tt>shift</tt>, <tt>keys</tt>, <tt>values</tt>.
- * - The \String returned by method <tt>inspect</tt>.
+ * - The string returned by method <tt>inspect</tt>.
*
- * A new \Hash has its initial ordering per the given entries:
+ * A new hash has its initial ordering per the given entries:
*
* h = Hash[foo: 0, bar: 1]
- * h # => {:foo=>0, :bar=>1}
+ * h # => {foo: 0, bar: 1}
*
* New entries are added at the end:
*
* h[:baz] = 2
- * h # => {:foo=>0, :bar=>1, :baz=>2}
+ * h # => {foo: 0, bar: 1, baz: 2}
*
* Updating a value does not affect the order:
*
* h[:baz] = 3
- * h # => {:foo=>0, :bar=>1, :baz=>3}
+ * h # => {foo: 0, bar: 1, baz: 3}
*
* But re-creating a deleted entry can affect the order:
*
* h.delete(:foo)
* h[:foo] = 5
- * h # => {:bar=>1, :baz=>3, :foo=>5}
+ * h # => {bar: 1, baz: 3, foo: 5}
*
- * === \Hash Keys
+ * === +Hash+ Keys
*
- * ==== \Hash Key Equivalence
+ * ==== +Hash+ Key Equivalence
*
* Two objects are treated as the same \hash key when their <code>hash</code> value
* is identical and the two objects are <code>eql?</code> to each other.
*
- * ==== Modifying an Active \Hash Key
+ * ==== Modifying an Active +Hash+ Key
*
- * Modifying a \Hash key while it is in use damages the hash's index.
+ * Modifying a +Hash+ key while it is in use damages the hash's index.
*
- * This \Hash has keys that are Arrays:
+ * This +Hash+ has keys that are Arrays:
*
* a0 = [ :foo, :bar ]
* a1 = [ :baz, :bat ]
@@ -6837,7 +7110,7 @@ static const rb_data_type_t env_data_type = {
* a0[0] = :bam
* a0.hash # => 1069447059
*
- * And damages the \Hash index:
+ * And damages the +Hash+ index:
*
* h.include?(a0) # => false
* h[a0] # => nil
@@ -6848,9 +7121,9 @@ static const rb_data_type_t env_data_type = {
* h.include?(a0) # => true
* h[a0] # => 0
*
- * A \String key is always safe.
- * That's because an unfrozen \String
- * passed as a key will be replaced by a duplicated and frozen \String:
+ * A String key is always safe.
+ * That's because an unfrozen String
+ * passed as a key will be replaced by a duplicated and frozen String:
*
* s = 'foo'
* s.frozen? # => false
@@ -6858,15 +7131,15 @@ static const rb_data_type_t env_data_type = {
* first_key = h.keys.first
* first_key.frozen? # => true
*
- * ==== User-Defined \Hash Keys
+ * ==== User-Defined +Hash+ Keys
*
- * To be useable as a \Hash key, objects must implement the methods <code>hash</code> and <code>eql?</code>.
- * Note: this requirement does not apply if the \Hash uses #compare_by_identity since comparison will then
+ * To be usable as a +Hash+ key, objects must implement the methods <code>hash</code> and <code>eql?</code>.
+ * Note: this requirement does not apply if the +Hash+ uses #compare_by_identity since comparison will then
* rely on the keys' object id instead of <code>hash</code> and <code>eql?</code>.
*
- * \Object defines basic implementation for <code>hash</code> and <code>eq?</code> that makes each object
+ * Object defines basic implementation for <code>hash</code> and <code>eq?</code> that makes each object
* a distinct key. Typically, user-defined classes will want to override these methods to provide meaningful
- * behavior, or for example inherit \Struct that has useful definitions for these.
+ * behavior, or for example inherit Struct that has useful definitions for these.
*
* A typical implementation of <code>hash</code> is based on the
* object's data while <code>eql?</code> is usually aliased to the overridden
@@ -6889,7 +7162,7 @@ static const rb_data_type_t env_data_type = {
* alias eql? ==
*
* def hash
- * @author.hash ^ @title.hash # XOR
+ * [self.class, @author, @title].hash
* end
* end
*
@@ -6903,103 +7176,98 @@ static const rb_data_type_t env_data_type = {
*
* reviews.length #=> 1
*
- * === Default Values
+ * === Key Not Found?
*
- * The methods #[], #values_at and #dig need to return the value associated to a certain key.
- * When that key is not found, that value will be determined by its default proc (if any)
- * or else its default (initially `nil`).
+ * When a method tries to retrieve and return the value for a key and that key <i>is found</i>,
+ * the returned value is the value associated with the key.
*
- * You can retrieve the default value with method #default:
+ * But what if the key <i>is not found</i>?
+ * In that case, certain methods will return a default value while other will raise a \KeyError.
*
- * h = Hash.new
- * h.default # => nil
+ * ==== Nil Return Value
*
- * You can set the default value by passing an argument to method Hash.new or
- * with method #default=
+ * If you want +nil+ returned for a not-found key, you can call:
*
- * h = Hash.new(-1)
- * h.default # => -1
- * h.default = 0
- * h.default # => 0
+ * - #[](key) (usually written as <tt>#[key]</tt>.
+ * - #assoc(key).
+ * - #dig(key, *identifiers).
+ * - #values_at(*keys).
*
- * This default value is returned for #[], #values_at and #dig when a key is
- * not found:
+ * You can override these behaviors for #[], #dig, and #values_at (but not #assoc);
+ * see {Hash Default}[rdoc-ref:Hash@Hash+Default].
*
- * counts = {foo: 42}
- * counts.default # => nil (default)
- * counts[:foo] = 42
- * counts[:bar] # => nil
- * counts.default = 0
- * counts[:bar] # => 0
- * counts.values_at(:foo, :bar, :baz) # => [42, 0, 0]
- * counts.dig(:bar) # => 0
+ * ==== \KeyError
*
- * Note that the default value is used without being duplicated. It is not advised to set
- * the default value to a mutable object:
+ * If you want KeyError raised for a not-found key, you can call:
*
- * synonyms = Hash.new([])
- * synonyms[:hello] # => []
- * synonyms[:hello] << :hi # => [:hi], but this mutates the default!
- * synonyms.default # => [:hi]
- * synonyms[:world] << :universe
- * synonyms[:world] # => [:hi, :universe], oops
- * synonyms.keys # => [], oops
+ * - #fetch(key).
+ * - #fetch_values(*keys).
*
- * To use a mutable object as default, it is recommended to use a default proc
+ * ==== \Hash Default
*
- * ==== Default \Proc
+ * For certain methods (#[], #dig, and #values_at),
+ * the return value for a not-found key is determined by two hash properties:
*
- * When the default proc for a \Hash is set (i.e., not +nil+),
- * the default value returned by method #[] is determined by the default proc alone.
+ * - <i>default value</i>: returned by method #default.
+ * - <i>default proc</i>: returned by method #default_proc.
*
- * You can retrieve the default proc with method #default_proc:
+ * In the simple case, both values are +nil+,
+ * and the methods return +nil+ for a not-found key;
+ * see {Nil Return Value}[rdoc-ref:Hash@Nil+Return+Value] above.
*
- * h = Hash.new
- * h.default_proc # => nil
+ * Note that this entire section ("Hash Default"):
*
- * You can set the default proc by calling Hash.new with a block or
- * calling the method #default_proc=
+ * - Applies _only_ to methods #[], #dig, and #values_at.
+ * - Does _not_ apply to methods #assoc, #fetch, or #fetch_values,
+ * which are not affected by the default value or default proc.
*
- * h = Hash.new { |hash, key| "Default value for #{key}" }
- * h.default_proc.class # => Proc
- * h.default_proc = proc { |hash, key| "Default value for #{key.inspect}" }
- * h.default_proc.class # => Proc
+ * ===== Any-Key Default
+ *
+ * You can define an any-key default for a hash;
+ * that is, a value that will be returned for _any_ not-found key:
*
- * When the default proc is set (i.e., not +nil+)
- * and method #[] is called with with a non-existent key,
- * #[] calls the default proc with both the \Hash object itself and the missing key,
- * then returns the proc's return value:
+ * - The value of #default_proc <i>must be</i> +nil+.
+ * - The value of #default (which may be any object, including +nil+)
+ * will be returned for a not-found key.
*
- * h = Hash.new { |hash, key| "Default value for #{key}" }
- * h[:nosuch] # => "Default value for nosuch"
+ * You can set the default value when the hash is created with Hash.new and option +default_value+,
+ * or later with method #default=.
*
- * Note that in the example above no entry for key +:nosuch+ is created:
+ * Note: although the value of #default may be any object,
+ * it may not be a good idea to use a mutable object.
*
- * h.include?(:nosuch) # => false
+ * ===== Per-Key Defaults
*
- * However, the proc itself can add a new entry:
+ * You can define a per-key default for a hash;
+ * that is, a Proc that will return a value based on the key itself.
*
- * synonyms = Hash.new { |hash, key| hash[key] = [] }
- * synonyms.include?(:hello) # => false
- * synonyms[:hello] << :hi # => [:hi]
- * synonyms[:world] << :universe # => [:universe]
- * synonyms.keys # => [:hello, :world]
+ * You can set the default proc when the hash is created with Hash.new and a block,
+ * or later with method #default_proc=.
*
- * Note that setting the default proc will clear the default value and vice versa.
+ * Note that the proc can modify +self+,
+ * but modifying +self+ in this way is not thread-safe;
+ * multiple threads can concurrently call into the default proc
+ * for the same key.
*
- * Be aware that a default proc that modifies the hash is not thread-safe in the
- * sense that multiple threads can call into the default proc concurrently for the
- * same key.
+ * ==== \Method Default
+ *
+ * For two methods, you can specify a default value for a not-found key
+ * that has effect only for a single method call
+ * (and not for any subsequent calls):
+ *
+ * - For method #fetch, you can specify an any-key default:
+ * - For either method #fetch or method #fetch_values,
+ * you can specify a per-key default via a block.
*
* === What's Here
*
- * First, what's elsewhere. \Class \Hash:
+ * First, what's elsewhere. Class +Hash+:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Includes {module Enumerable}[rdoc-ref:Enumerable@Whats+Here],
* which provides dozens of additional methods.
*
- * Here, class \Hash provides methods that are useful for:
+ * Here, class +Hash+ provides methods that are useful for:
*
* - {Creating a Hash}[rdoc-ref:Hash@Methods+for+Creating+a+Hash]
* - {Setting Hash State}[rdoc-ref:Hash@Methods+for+Setting+Hash+State]
@@ -7011,17 +7279,16 @@ static const rb_data_type_t env_data_type = {
* - {Iterating}[rdoc-ref:Hash@Methods+for+Iterating]
* - {Converting}[rdoc-ref:Hash@Methods+for+Converting]
* - {Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values]
- * - {And more....}[rdoc-ref:Hash@Other+Methods]
*
- * \Class \Hash also includes methods from module Enumerable.
+ * Class +Hash+ also includes methods from module Enumerable.
*
- * ==== Methods for Creating a \Hash
+ * ==== Methods for Creating a +Hash+
*
* - ::[]: Returns a new hash populated with given objects.
* - ::new: Returns a new empty hash.
* - ::try_convert: Returns a new hash created from a given object.
*
- * ==== Methods for Setting \Hash State
+ * ==== Methods for Setting +Hash+ State
*
* - #compare_by_identity: Sets +self+ to consider only identity in comparing keys.
* - #default=: Sets the default to a given value.
@@ -7037,10 +7304,9 @@ static const rb_data_type_t env_data_type = {
* - #empty?: Returns whether there are no entries.
* - #eql?: Returns whether a given object is equal to +self+.
* - #hash: Returns the integer hash code.
- * - #has_value?: Returns whether a given object is a value in +self+.
- * - #include?, #has_key?, #member?, #key?: Returns whether a given object is a key in +self+.
- * - #length, #size: Returns the count of entries.
- * - #value?: Returns whether a given object is a value in +self+.
+ * - #has_value? (aliased as #value?): Returns whether a given object is a value in +self+.
+ * - #include? (aliased as #has_key?, #member?, #key?): Returns whether a given object is a key in +self+.
+ * - #size (aliased as #length): Returns the count of entries.
*
* ==== Methods for Comparing
*
@@ -7048,7 +7314,7 @@ static const rb_data_type_t env_data_type = {
* - #<=: Returns whether +self+ is a subset of a given object.
* - #==: Returns whether a given object is equal to +self+.
* - #>: Returns whether +self+ is a proper superset of a given object
- * - #>=: Returns whether +self+ is a proper superset of a given object.
+ * - #>=: Returns whether +self+ is a superset of a given object.
*
* ==== Methods for Fetching
*
@@ -7061,16 +7327,16 @@ static const rb_data_type_t env_data_type = {
* - #key: Returns the key for the first-found entry with a given value.
* - #keys: Returns an array containing all keys in +self+.
* - #rassoc: Returns a 2-element array consisting of the key and value
- of the first-found entry having a given value.
- * - #values: Returns an array containing all values in +self+/
+ * of the first-found entry having a given value.
+ * - #values: Returns an array containing all values in +self+.
* - #values_at: Returns an array containing values for given keys.
*
* ==== Methods for Assigning
*
- * - #[]=, #store: Associates a given key with a given value.
+ * - #[]= (aliased as #store): Associates a given key with a given value.
* - #merge: Returns the hash formed by merging each given hash into a copy of +self+.
- * - #merge!, #update: Merges each given hash into +self+.
- * - #replace: Replaces the entire contents of +self+ with the contents of a given hash.
+ * - #update (aliased as #merge!): Merges each given hash into +self+.
+ * - #replace (aliased as #initialize_copy): Replaces the entire contents of +self+ with the contents of a given hash.
*
* ==== Methods for Deleting
*
@@ -7080,7 +7346,7 @@ static const rb_data_type_t env_data_type = {
* - #compact!: Removes all +nil+-valued entries from +self+.
* - #delete: Removes the entry for a given key.
* - #delete_if: Removes entries selected by a given block.
- * - #filter!, #select!: Keep only those entries selected by a given block.
+ * - #select! (aliased as #filter!): Keep only those entries selected by a given block.
* - #keep_if: Keep only those entries selected by a given block.
* - #reject!: Removes entries selected by a given block.
* - #shift: Removes and returns the first entry.
@@ -7089,36 +7355,34 @@ static const rb_data_type_t env_data_type = {
*
* - #compact: Returns a copy of +self+ with all +nil+-valued entries removed.
* - #except: Returns a copy of +self+ with entries removed for specified keys.
- * - #filter, #select: Returns a copy of +self+ with only those entries selected by a given block.
+ * - #select (aliased as #filter): Returns a copy of +self+ with only those entries selected by a given block.
* - #reject: Returns a copy of +self+ with entries removed as specified by a given block.
* - #slice: Returns a hash containing the entries for given keys.
*
* ==== Methods for Iterating
- * - #each, #each_pair: Calls a given block with each key-value pair.
+ * - #each_pair (aliased as #each): Calls a given block with each key-value pair.
* - #each_key: Calls a given block with each key.
* - #each_value: Calls a given block with each value.
*
* ==== Methods for Converting
*
- * - #inspect, #to_s: Returns a new String containing the hash entries.
+ * - #flatten: Returns an array that is a 1-dimensional flattening of +self+.
+ * - #inspect (aliased as #to_s): Returns a new String containing the hash entries.
* - #to_a: Returns a new array of 2-element arrays;
* each nested array contains a key-value pair from +self+.
- * - #to_h: Returns +self+ if a \Hash;
- * if a subclass of \Hash, returns a \Hash containing the entries from +self+.
+ * - #to_h: Returns +self+ if a +Hash+;
+ * if a subclass of +Hash+, returns a +Hash+ containing the entries from +self+.
* - #to_hash: Returns +self+.
* - #to_proc: Returns a proc that maps a given key to its value.
*
* ==== Methods for Transforming Keys and Values
*
+ * - #invert: Returns a hash with the each key-value pair inverted.
* - #transform_keys: Returns a copy of +self+ with modified keys.
* - #transform_keys!: Modifies keys in +self+
* - #transform_values: Returns a copy of +self+ with modified values.
* - #transform_values!: Modifies values in +self+.
*
- * ==== Other Methods
- * - #flatten: Returns an array that is a 1-dimensional flattening of +self+.
- * - #invert: Returns a hash with the each key-value pair inverted.
- *
*/
void
@@ -7135,9 +7399,9 @@ Init_Hash(void)
rb_define_alloc_func(rb_cHash, empty_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, "freeze", rb_hash_freeze, 0);
rb_define_method(rb_cHash, "to_hash", rb_hash_to_hash, 0);
rb_define_method(rb_cHash, "to_h", rb_hash_to_h, 0);
@@ -7224,17 +7488,21 @@ Init_Hash(void)
rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash?", rb_hash_s_ruby2_keywords_hash_p, 1);
rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash", rb_hash_s_ruby2_keywords_hash, 1);
+ rb_cHash_empty_frozen = rb_hash_freeze(rb_hash_alloc_fixed_size(rb_cHash, 0));
+ RB_OBJ_SET_SHAREABLE(rb_cHash_empty_frozen);
+ rb_vm_register_global_object(rb_cHash_empty_frozen);
+
/* Document-class: ENV
*
- * ENV is a hash-like accessor for environment variables.
+ * +ENV+ is a hash-like accessor for environment variables.
*
* === Interaction with the Operating System
*
- * The ENV object interacts with the operating system's environment variables:
+ * The +ENV+ object interacts with the operating system's environment variables:
*
- * - When you get the value for a name in ENV, the value is retrieved from among the current environment variables.
- * - When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables.
- * - When you delete a name-value pair in ENV, it is immediately deleted from the environment variables.
+ * - When you get the value for a name in +ENV+, the value is retrieved from among the current environment variables.
+ * - When you create or set a name-value pair in +ENV+, the name and value are immediately set in the environment variables.
+ * - When you delete a name-value pair in +ENV+, it is immediately deleted from the environment variables.
*
* === Names and Values
*
@@ -7284,33 +7552,33 @@ Init_Hash(void)
*
* === About Ordering
*
- * ENV enumerates its name/value pairs in the order found
+ * +ENV+ enumerates its name/value pairs in the order found
* in the operating system's environment variables.
- * Therefore the ordering of ENV content is OS-dependent, and may be indeterminate.
+ * Therefore the ordering of +ENV+ content is OS-dependent, and may be indeterminate.
*
* This will be seen in:
- * - A Hash returned by an ENV method.
- * - An Enumerator returned by an ENV method.
+ * - A Hash returned by an +ENV+ method.
+ * - An Enumerator returned by an +ENV+ method.
* - An Array returned by ENV.keys, ENV.values, or ENV.to_a.
* - The String returned by ENV.inspect.
* - The Array returned by ENV.shift.
* - The name returned by ENV.key.
*
* === About the Examples
- * Some methods in ENV return ENV itself. Typically, there are many environment variables.
- * It's not useful to display a large ENV in the examples here,
- * so most example snippets begin by resetting the contents of ENV:
- * - ENV.replace replaces ENV with a new collection of entries.
- * - ENV.clear empties ENV.
+ * Some methods in +ENV+ return +ENV+ itself. Typically, there are many environment variables.
+ * It's not useful to display a large +ENV+ in the examples here,
+ * so most example snippets begin by resetting the contents of +ENV+:
+ * - ENV.replace replaces +ENV+ with a new collection of entries.
+ * - ENV.clear empties +ENV+.
*
- * == What's Here
+ * === What's Here
*
- * First, what's elsewhere. \Class \ENV:
+ * First, what's elsewhere. Class +ENV+:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Extends {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Extends {module Enumerable}[rdoc-ref:Enumerable@Whats+Here],
*
- * Here, class \ENV provides methods that are useful for:
+ * Here, class +ENV+ provides methods that are useful for:
*
* - {Querying}[rdoc-ref:ENV@Methods+for+Querying]
* - {Assigning}[rdoc-ref:ENV@Methods+for+Assigning]
@@ -7319,26 +7587,26 @@ Init_Hash(void)
* - {Converting}[rdoc-ref:ENV@Methods+for+Converting]
* - {And more ....}[rdoc-ref:ENV@More+Methods]
*
- * === Methods for Querying
+ * ==== Methods for Querying
*
* - ::[]: Returns the value for the given environment variable name if it exists:
- * - ::empty?: Returns whether \ENV is empty.
- * - ::has_value?, ::value?: Returns whether the given value is in \ENV.
+ * - ::empty?: Returns whether +ENV+ is empty.
+ * - ::has_value?, ::value?: Returns whether the given value is in +ENV+.
* - ::include?, ::has_key?, ::key?, ::member?: Returns whether the given name
- is in \ENV.
+ is in +ENV+.
* - ::key: Returns the name of the first entry with the given value.
* - ::size, ::length: Returns the number of entries.
* - ::value?: Returns whether any entry has the given value.
*
- * === Methods for Assigning
+ * ==== Methods for Assigning
*
* - ::[]=, ::store: Creates, updates, or deletes the named environment variable.
- * - ::clear: Removes every environment variable; returns \ENV:
- * - ::update, ::merge!: Adds to \ENV each key/value pair in the given hash.
- * - ::replace: Replaces the entire content of the \ENV
+ * - ::clear: Removes every environment variable; returns +ENV+:
+ * - ::update, ::merge!: Adds to +ENV+ each key/value pair in the given hash.
+ * - ::replace: Replaces the entire content of the +ENV+
* with the name/value pairs in the given hash.
*
- * === Methods for Deleting
+ * ==== Methods for Deleting
*
* - ::delete: Deletes the named environment variable name if it exists.
* - ::delete_if: Deletes entries selected by the block.
@@ -7347,22 +7615,23 @@ Init_Hash(void)
* - ::select!, ::filter!: Deletes entries selected by the block.
* - ::shift: Removes and returns the first entry.
*
- * === Methods for Iterating
+ * ==== Methods for Iterating
*
* - ::each, ::each_pair: Calls the block with each name/value pair.
* - ::each_key: Calls the block with each name.
* - ::each_value: Calls the block with each value.
*
- * === Methods for Converting
+ * ==== Methods for Converting
*
* - ::assoc: Returns a 2-element array containing the name and value
* of the named environment variable if it exists:
- * - ::clone: Returns \ENV (and issues a warning).
+ * - ::clone: Raises an exception.
* - ::except: Returns a hash of all name/value pairs except those given.
* - ::fetch: Returns the value for the given name.
- * - ::inspect: Returns the contents of \ENV as a string.
- * - ::invert: Returns a hash whose keys are the ENV values,
- and whose values are the corresponding ENV names.
+ * - ::fetch_values: Returns array containing the values associated with given names.
+ * - ::inspect: Returns the contents of +ENV+ as a string.
+ * - ::invert: Returns a hash whose keys are the +ENV+ values,
+ and whose values are the corresponding +ENV+ names.
* - ::keys: Returns an array of all names.
* - ::rassoc: Returns the name and value of the first found entry
* that has the given value.
@@ -7376,11 +7645,11 @@ Init_Hash(void)
* - ::values: Returns all values as an array.
* - ::values_at: Returns an array of the values for the given name.
*
- * === More Methods
+ * ==== More Methods
*
* - ::dup: Raises an exception.
* - ::freeze: Raises an exception.
- * - ::rehash: Returns +nil+, without modifying \ENV.
+ * - ::rehash: Returns +nil+, without modifying +ENV+.
*
*/
@@ -7391,11 +7660,11 @@ Init_Hash(void)
origenviron = environ;
envtbl = TypedData_Wrap_Struct(rb_cObject, &env_data_type, NULL);
rb_extend_object(envtbl, rb_mEnumerable);
- FL_SET_RAW(envtbl, RUBY_FL_SHAREABLE);
-
+ RB_OBJ_SET_SHAREABLE(envtbl);
rb_define_singleton_method(envtbl, "[]", rb_f_getenv, 1);
rb_define_singleton_method(envtbl, "fetch", env_fetch, -1);
+ rb_define_singleton_method(envtbl, "fetch_values", env_fetch_values, -1);
rb_define_singleton_method(envtbl, "[]=", env_aset_m, 2);
rb_define_singleton_method(envtbl, "store", env_aset_m, 2);
rb_define_singleton_method(envtbl, "each", env_each_pair, 0);
@@ -7451,14 +7720,13 @@ Init_Hash(void)
rb_undef_method(envtbl_class, "initialize_dup");
/*
- * ENV is a Hash-like accessor for environment variables.
+ * +ENV+ is a Hash-like accessor for environment variables.
*
* See ENV (the class) for more details.
*/
rb_define_global_const("ENV", envtbl);
- /* for callcc */
- ruby_register_rollback_func_for_ensure(hash_foreach_ensure, hash_foreach_ensure_rollback);
-
HASH_ASSERT(sizeof(ar_hint_t) * RHASH_AR_TABLE_MAX_SIZE == sizeof(VALUE));
}
+
+#include "hash.rbinc"
diff --git a/hash.rb b/hash.rb
new file mode 100644
index 0000000000..40f823783e
--- /dev/null
+++ b/hash.rb
@@ -0,0 +1,40 @@
+class Hash
+ # call-seq:
+ # Hash.new(default_value = nil, capacity: 0) -> new_hash
+ # Hash.new(capacity: 0) {|self, key| ... } -> new_hash
+ #
+ # Returns a new empty \Hash object.
+ #
+ # Initializes the values of Hash#default and Hash#default_proc,
+ # which determine the behavior when a given key is not found;
+ # see {Key Not Found?}[rdoc-ref:Hash@Key+Not+Found].
+ #
+ # By default, a hash has +nil+ values for both +default+ and +default_proc+:
+ #
+ # h = Hash.new # => {}
+ # h.default # => nil
+ # h.default_proc # => nil
+ #
+ # With argument +default_value+ given, sets the +default+ value for the hash:
+ #
+ # h = Hash.new(false) # => {}
+ # h.default # => false
+ # h.default_proc # => nil
+ #
+ # With a block given, sets the +default_proc+ value:
+ #
+ # h = Hash.new {|hash, key| "Hash #{hash}: Default value for #{key}" }
+ # h.default # => nil
+ # h.default_proc # => #<Proc:0x00000289b6fa7048 (irb):185>
+ # h[:nosuch] # => "Hash {}: Default value for nosuch"
+ #
+ # Raises ArgumentError if both +default_value+ and a block are given.
+ #
+ # If optional keyword argument +capacity+ is given with a positive integer value +n+,
+ # initializes the hash with enough capacity to accommodate +n+ entries without resizing.
+ #
+ # See also {Methods for Creating a Hash}[rdoc-ref:Hash@Methods+for+Creating+a+Hash].
+ def initialize(ifnone = (ifnone_unset = true), capacity: 0, &block)
+ Primitive.rb_hash_init(capacity, ifnone_unset, ifnone, block)
+ end
+end
diff --git a/hrtime.h b/hrtime.h
index 7ed4e6b04c..2ca7b0c088 100644
--- a/hrtime.h
+++ b/hrtime.h
@@ -6,6 +6,8 @@
# include <sys/time.h>
#endif
+#include "internal/compilers.h"
+
/*
* Hi-res monotonic clock. It is currently nsec resolution, which has over
* 500 years of range (with an unsigned 64-bit integer). Developers
@@ -61,7 +63,11 @@ rb_hrtime_mul(rb_hrtime_t a, rb_hrtime_t b)
{
rb_hrtime_t c;
-#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
+#ifdef ckd_mul
+ if (ckd_mul(&c, a, b))
+ return RB_HRTIME_MAX;
+
+#elif __has_builtin(__builtin_mul_overflow)
if (__builtin_mul_overflow(a, b, &c))
return RB_HRTIME_MAX;
#else
@@ -81,7 +87,11 @@ rb_hrtime_add(rb_hrtime_t a, rb_hrtime_t b)
{
rb_hrtime_t c;
-#ifdef HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
+#ifdef ckd_add
+ if (ckd_add(&c, a, b))
+ return RB_HRTIME_MAX;
+
+#elif __has_builtin(__builtin_add_overflow)
if (__builtin_add_overflow(a, b, &c))
return RB_HRTIME_MAX;
#else
diff --git a/id_table.c b/id_table.c
index 650721c670..299b7d3ae5 100644
--- a/id_table.c
+++ b/id_table.c
@@ -38,16 +38,9 @@ typedef struct rb_id_item {
VALUE val;
} item_t;
-struct rb_id_table {
- int capa;
- int num;
- int used;
- item_t *items;
-};
-
#if SIZEOF_VALUE == 8
#define ITEM_GET_KEY(tbl, i) ((tbl)->items[i].key)
-#define ITEM_KEY_ISSET(tbl, i) ((tbl)->items[i].key)
+#define ITEM_KEY_ISSET(tbl, i) ((tbl)->items && (tbl)->items[i].key)
#define ITEM_COLLIDED(tbl, i) ((tbl)->items[i].collision)
#define ITEM_SET_COLLIDED(tbl, i) ((tbl)->items[i].collision = 1)
static inline void
@@ -80,9 +73,10 @@ round_capa(int capa)
return (capa + 1) << 2;
}
-static struct rb_id_table *
-rb_id_table_init(struct rb_id_table *tbl, int capa)
+struct rb_id_table *
+rb_id_table_init(struct rb_id_table *tbl, size_t s_capa)
{
+ int capa = (int)s_capa;
MEMZERO(tbl, struct rb_id_table, 1);
if (capa > 0) {
capa = round_capa(capa);
@@ -96,7 +90,13 @@ struct rb_id_table *
rb_id_table_create(size_t capa)
{
struct rb_id_table *tbl = ALLOC(struct rb_id_table);
- return rb_id_table_init(tbl, (int)capa);
+ return rb_id_table_init(tbl, capa);
+}
+
+void
+rb_id_table_free_items(struct rb_id_table *tbl)
+{
+ xfree(tbl->items);
}
void
@@ -150,7 +150,7 @@ hash_table_raw_insert(struct rb_id_table *tbl, id_key_t key, VALUE val)
int mask = tbl->capa - 1;
int ix = key & mask;
int d = 1;
- assert(key != 0);
+ RUBY_ASSERT(key != 0);
while (ITEM_KEY_ISSET(tbl, ix)) {
ITEM_SET_COLLIDED(tbl, ix);
ix = (ix + d) & mask;
@@ -276,7 +276,7 @@ rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, v
if (ITEM_KEY_ISSET(tbl, i)) {
const id_key_t key = ITEM_GET_KEY(tbl, i);
enum rb_id_table_iterator_result ret = (*func)(key2id(key), tbl->items[i].val, data);
- assert(key != 0);
+ RUBY_ASSERT(key != 0);
if (ret == ID_TABLE_DELETE)
hash_delete_index(tbl, i);
@@ -291,6 +291,10 @@ rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_f
{
int i, capa = tbl->capa;
+ if (!tbl->items) {
+ return;
+ }
+
for (i=0; i<capa; i++) {
if (ITEM_KEY_ISSET(tbl, i)) {
enum rb_id_table_iterator_result ret = (*func)(tbl->items[i].val, data);
@@ -324,3 +328,185 @@ rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_for
}
}
+static void
+managed_id_table_free(void *data)
+{
+ struct rb_id_table *tbl = (struct rb_id_table *)data;
+ rb_id_table_free_items(tbl);
+}
+
+static size_t
+managed_id_table_memsize(const void *data)
+{
+ const struct rb_id_table *tbl = (const struct rb_id_table *)data;
+ return rb_id_table_memsize(tbl) - sizeof(struct rb_id_table);
+}
+
+const rb_data_type_t rb_managed_id_table_type = {
+ .wrap_struct_name = "VM/managed_id_table",
+ .function = {
+ .dmark = NULL, // Nothing to mark
+ .dfree = managed_id_table_free,
+ .dsize = managed_id_table_memsize,
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
+};
+
+static inline struct rb_id_table *
+managed_id_table_ptr(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, T_DATA));
+ RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), &rb_managed_id_table_type));
+
+ return RTYPEDDATA_GET_DATA(obj);
+}
+
+VALUE
+rb_managed_id_table_create(const rb_data_type_t *type, size_t capa)
+{
+ struct rb_id_table *tbl;
+ VALUE obj = TypedData_Make_Struct(0, struct rb_id_table, type, tbl);
+ RB_OBJ_SET_SHAREABLE(obj);
+ rb_id_table_init(tbl, capa); // NOTE: this can cause GC, so dmark and dsize need to check tbl->items
+ return obj;
+}
+
+VALUE
+rb_managed_id_table_new(size_t capa)
+{
+ return rb_managed_id_table_create(&rb_managed_id_table_type, capa);
+}
+
+static enum rb_id_table_iterator_result
+managed_id_table_dup_i(ID id, VALUE val, void *data)
+{
+ struct rb_id_table *new_tbl = (struct rb_id_table *)data;
+ rb_id_table_insert(new_tbl, id, val);
+ return ID_TABLE_CONTINUE;
+}
+
+VALUE
+rb_managed_id_table_dup(VALUE old_table)
+{
+ struct rb_id_table *new_tbl;
+ VALUE obj = TypedData_Make_Struct(0, struct rb_id_table, RTYPEDDATA_TYPE(old_table), new_tbl);
+ struct rb_id_table *old_tbl = managed_id_table_ptr(old_table);
+ rb_id_table_init(new_tbl, old_tbl->num + 1);
+ rb_id_table_foreach(old_tbl, managed_id_table_dup_i, new_tbl);
+ return obj;
+}
+
+int
+rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp)
+{
+ return rb_id_table_lookup(managed_id_table_ptr(table), id, valp);
+}
+
+int
+rb_managed_id_table_insert(VALUE table, ID id, VALUE val)
+{
+ return rb_id_table_insert(managed_id_table_ptr(table), id, val);
+}
+
+size_t
+rb_managed_id_table_size(VALUE table)
+{
+ return rb_id_table_size(managed_id_table_ptr(table));
+}
+
+void
+rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data)
+{
+ rb_id_table_foreach(managed_id_table_ptr(table), func, data);
+}
+
+void
+rb_managed_id_table_foreach_values(VALUE table, rb_id_table_foreach_values_func_t *func, void *data)
+{
+ rb_id_table_foreach_values(managed_id_table_ptr(table), func, data);
+}
+
+int
+rb_managed_id_table_delete(VALUE table, ID id)
+{
+ return rb_id_table_delete(managed_id_table_ptr(table), id);
+}
+
+static enum rb_id_table_iterator_result
+marked_id_table_mark_i(VALUE val, void *data)
+{
+ rb_gc_mark_movable(val);
+ return ID_TABLE_CONTINUE;
+}
+
+static void
+marked_id_table_mark(void *ptr)
+{
+ struct rb_id_table *tbl = (struct rb_id_table *)ptr;
+ rb_id_table_foreach_values(tbl, marked_id_table_mark_i, NULL);
+}
+
+static enum rb_id_table_iterator_result
+marked_id_table_compact_check_i(VALUE value, void *data)
+{
+ if (rb_gc_location(value) != value) {
+ return ID_TABLE_REPLACE;
+ }
+ return ID_TABLE_CONTINUE;
+}
+
+static enum rb_id_table_iterator_result
+marked_id_table_compact_replace_i(VALUE *value, void *data, int existing)
+{
+ *value = rb_gc_location(*value);
+ return ID_TABLE_CONTINUE;
+}
+
+static void
+marked_id_table_compact(void *ptr)
+{
+ struct rb_id_table *tbl = (struct rb_id_table *)ptr;
+ rb_id_table_foreach_values_with_replace(tbl, marked_id_table_compact_check_i, marked_id_table_compact_replace_i, NULL);
+}
+
+const rb_data_type_t rb_marked_id_table_type = {
+ .wrap_struct_name = "VM/marked_id_table",
+ .function = {
+ .dmark = marked_id_table_mark,
+ .dfree = managed_id_table_free,
+ .dsize = managed_id_table_memsize,
+ .dcompact = marked_id_table_compact,
+ },
+ .parent = &rb_managed_id_table_type,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
+};
+
+VALUE
+rb_marked_id_table_new(size_t capa)
+{
+ return rb_managed_id_table_create(&rb_marked_id_table_type, capa);
+}
+
+int
+rb_marked_id_table_insert(VALUE table, ID id, VALUE val)
+{
+ int result = rb_managed_id_table_insert(table, id, val);
+ RB_OBJ_WRITTEN(table, Qundef, val);
+ return result;
+}
+
+static enum rb_id_table_iterator_result
+marked_id_table_dup_i(VALUE val, void *data)
+{
+ VALUE new_table = (VALUE)data;
+ RB_OBJ_WRITTEN(new_table, Qundef, val);
+ return ID_TABLE_CONTINUE;
+}
+
+VALUE
+rb_marked_id_table_dup(VALUE old_table)
+{
+ VALUE new_table = rb_managed_id_table_dup(old_table);
+ rb_managed_id_table_foreach_values(new_table, marked_id_table_dup_i, (void *)new_table);
+ return new_table;
+}
diff --git a/id_table.h b/id_table.h
index f72e2d1d92..c4333bea98 100644
--- a/id_table.h
+++ b/id_table.h
@@ -4,7 +4,14 @@
#include <stddef.h>
#include "ruby/ruby.h"
-struct rb_id_table;
+struct rb_id_item;
+
+struct rb_id_table {
+ int capa;
+ int num;
+ int used;
+ struct rb_id_item *items;
+};
/* compatible with ST_* */
enum rb_id_table_iterator_result {
@@ -16,7 +23,10 @@ enum rb_id_table_iterator_result {
};
struct rb_id_table *rb_id_table_create(size_t size);
+struct rb_id_table *rb_id_table_init(struct rb_id_table *tbl, size_t capa);
+
void rb_id_table_free(struct rb_id_table *tbl);
+void rb_id_table_free_items(struct rb_id_table *tbl);
void rb_id_table_clear(struct rb_id_table *tbl);
size_t rb_id_table_memsize(const struct rb_id_table *tbl);
@@ -32,6 +42,28 @@ void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *fu
void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
void rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, rb_id_table_update_value_callback_func_t *replace, void *data);
+VALUE rb_managed_id_table_create(const rb_data_type_t *type, size_t capa);
+VALUE rb_managed_id_table_new(size_t capa);
+VALUE rb_managed_id_table_dup(VALUE table);
+int rb_managed_id_table_insert(VALUE table, ID id, VALUE val);
+int rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp);
+size_t rb_managed_id_table_size(VALUE table);
+void rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data);
+void rb_managed_id_table_foreach_values(VALUE table, rb_id_table_foreach_values_func_t *func, void *data);
+int rb_managed_id_table_delete(VALUE table, ID id);
+
+extern const rb_data_type_t rb_managed_id_table_type;
+
+VALUE rb_marked_id_table_new(size_t capa);
+int rb_marked_id_table_insert(VALUE table, ID id, VALUE val);
+VALUE rb_marked_id_table_dup(VALUE table);
+
+// alisases
+#define rb_marked_id_table_size rb_managed_id_table_size
+#define rb_marked_id_table_lookup rb_managed_id_table_lookup
+#define rb_marked_id_table_foreach rb_managed_id_table_foreach
+#define rb_marked_id_table_foreach_values rb_managed_id_table_foreach_values
+
RUBY_SYMBOL_EXPORT_BEGIN
size_t rb_id_table_size(const struct rb_id_table *tbl);
RUBY_SYMBOL_EXPORT_END
diff --git a/imemo.c b/imemo.c
new file mode 100644
index 0000000000..796e078c89
--- /dev/null
+++ b/imemo.c
@@ -0,0 +1,744 @@
+
+#include "constant.h"
+#include "id_table.h"
+#include "internal.h"
+#include "internal/imemo.h"
+#include "internal/object.h"
+#include "internal/st.h"
+#include "vm_callinfo.h"
+
+size_t rb_iseq_memsize(const rb_iseq_t *iseq);
+void rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating);
+void rb_iseq_free(const rb_iseq_t *iseq);
+
+const char *
+rb_imemo_name(enum imemo_type type)
+{
+ // put no default case to get a warning if an imemo type is missing
+ switch (type) {
+#define IMEMO_NAME(x) case imemo_##x: return #x;
+ IMEMO_NAME(callcache);
+ IMEMO_NAME(callinfo);
+ IMEMO_NAME(constcache);
+ IMEMO_NAME(cref);
+ IMEMO_NAME(env);
+ IMEMO_NAME(ifunc);
+ IMEMO_NAME(iseq);
+ IMEMO_NAME(memo);
+ IMEMO_NAME(ment);
+ IMEMO_NAME(svar);
+ IMEMO_NAME(throw_data);
+ IMEMO_NAME(tmpbuf);
+ IMEMO_NAME(cvar_entry);
+ IMEMO_NAME(fields);
+ IMEMO_NAME(subclasses);
+ IMEMO_NAME(cdhash);
+#undef IMEMO_NAME
+ }
+ rb_bug("unreachable");
+}
+
+/* =========================================================================
+ * allocation
+ * ========================================================================= */
+
+VALUE
+rb_imemo_new(enum imemo_type type, VALUE v0, size_t size, bool is_shareable)
+{
+ VALUE flags = T_IMEMO | (type << FL_USHIFT) | (is_shareable ? FL_SHAREABLE : 0);
+ return rb_newobj_of(v0, flags, size);
+}
+
+VALUE
+rb_imemo_tmpbuf_new(void)
+{
+ VALUE flags = T_IMEMO | (imemo_tmpbuf << FL_USHIFT);
+ UNPROTECTED_NEWOBJ_OF(obj, rb_imemo_tmpbuf_t, 0, flags, sizeof(rb_imemo_tmpbuf_t));
+
+ rb_gc_register_pinning_obj((VALUE)obj);
+
+ obj->ptr = NULL;
+ obj->size = 0;
+
+ return (VALUE)obj;
+}
+
+void *
+rb_alloc_tmp_buffer(volatile VALUE *store, long len)
+{
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative buffer size (or size too big)");
+ }
+
+ /* Keep the order; allocate an empty imemo first then xmalloc, to
+ * get rid of potential memory leak */
+ rb_imemo_tmpbuf_t *tmpbuf = (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new();
+ *store = (VALUE)tmpbuf;
+ void *ptr = ruby_xmalloc(len);
+ tmpbuf->ptr = ptr;
+ tmpbuf->size = len;
+
+ return ptr;
+}
+
+void *
+rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
+{
+ return rb_alloc_tmp_buffer(store, (long)size);
+}
+
+void
+rb_free_tmp_buffer(volatile VALUE *store)
+{
+ if (!*store) return;
+ rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
+ if (s) {
+ void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0);
+ long size = s->size;
+ s->size = 0;
+ ruby_xfree_sized(ptr, size);
+ }
+}
+
+struct MEMO *
+rb_imemo_memo_new(VALUE a, VALUE b, long c)
+{
+ struct MEMO *memo = IMEMO_NEW(struct MEMO, imemo_memo, 0);
+
+ *((VALUE *)&memo->v1) = a;
+ *((VALUE *)&memo->v2) = b;
+ memo->u3.cnt = c;
+
+ return memo;
+}
+
+struct MEMO *
+rb_imemo_memo_new_value(VALUE a, VALUE b, VALUE c)
+{
+ struct MEMO *memo = IMEMO_NEW(struct MEMO, imemo_memo, 0);
+
+ *((VALUE *)&memo->v1) = a;
+ *((VALUE *)&memo->v2) = b;
+ *((VALUE *)&memo->u3.value) = c;
+ memo->flags |= MEMO_U3_IS_VALUE;
+
+ return memo;
+}
+
+VALUE
+rb_imemo_cdhash_new(size_t size, const struct st_hash_type *type)
+{
+ struct rb_imemo_cdhash *memo = IMEMO_NEW(struct rb_imemo_cdhash, imemo_cdhash, 0);
+ memo->tbl.num_entries = 0;
+ st_init_existing_table_with_size(&memo->tbl, type, size);
+ return (VALUE)memo;
+}
+
+VALUE
+rb_imemo_fields_new(VALUE owner, shape_id_t shape_id, bool shareable)
+{
+ size_t capa = RSHAPE_CAPACITY(shape_id);
+ size_t embedded_size = offsetof(struct rb_fields, as.embed) + capa * sizeof(VALUE);
+ RUBY_ASSERT(rb_gc_size_allocatable_p(embedded_size));
+ VALUE fields = rb_imemo_new(imemo_fields, owner, embedded_size, shareable);
+ // imemo fields objects should always have "RObject" layout. The
+ // layout in the shape describes the layout of the thing on which it is set.
+ // Imemo fields have the same layout as robject, therefore the layout
+ // should reflect that fact.
+ RBASIC_SET_SHAPE_ID(fields, rb_shape_id_with_robject_layout(shape_id));
+ RUBY_ASSERT(IMEMO_TYPE_P(fields, imemo_fields));
+ return fields;
+}
+
+VALUE
+rb_imemo_fields_new_complex(VALUE owner, shape_id_t shape_id, size_t capa, bool shareable)
+{
+ VALUE fields = rb_imemo_new(imemo_fields, owner, sizeof(struct rb_fields), shareable);
+ IMEMO_OBJ_FIELDS(fields)->as.complex.table = st_init_numtable_with_size(capa);
+ FL_SET_RAW(fields, OBJ_FIELD_HEAP);
+ // imemo fields objects should always have "RObject" layout. The
+ // layout in the shape describes the layout of the thing on which it is set.
+ // Imemo fields have the same layout as robject, therefore the layout
+ // should reflect that fact.
+ RBASIC_SET_SHAPE_ID(fields, rb_shape_id_with_robject_layout(shape_id));
+ return fields;
+}
+
+static int
+imemo_fields_trigger_wb_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ VALUE field_obj = (VALUE)arg;
+ RB_OBJ_WRITTEN(field_obj, Qundef, (VALUE)value);
+ return ST_CONTINUE;
+}
+
+static int
+imemo_fields_complex_wb_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ RB_OBJ_WRITTEN((VALUE)arg, Qundef, (VALUE)value);
+ return ST_CONTINUE;
+}
+
+VALUE
+rb_imemo_fields_new_complex_tbl(VALUE owner, shape_id_t shape_id, st_table *tbl, bool shareable)
+{
+ VALUE fields = rb_imemo_new(imemo_fields, owner, sizeof(struct rb_fields), shareable);
+ IMEMO_OBJ_FIELDS(fields)->as.complex.table = tbl;
+ FL_SET_RAW(fields, OBJ_FIELD_HEAP);
+ // imemo fields objects should always have "RObject" layout. The
+ // layout in the shape describes the layout of the thing on which it is set.
+ // Imemo fields have the same layout as robject, therefore the layout
+ // should reflect that fact.
+ RBASIC_SET_SHAPE_ID(fields, rb_shape_id_with_robject_layout(shape_id));
+ st_foreach(tbl, imemo_fields_trigger_wb_i, (st_data_t)fields);
+ return fields;
+}
+
+VALUE
+rb_imemo_fields_clone(VALUE fields_obj)
+{
+ shape_id_t shape_id = RBASIC_SHAPE_ID(fields_obj);
+ VALUE clone;
+
+ if (rb_shape_complex_p(shape_id)) {
+ st_table *src_table = rb_imemo_fields_complex_tbl(fields_obj);
+
+ st_table *dest_table = xcalloc(1, sizeof(st_table));
+ clone = rb_imemo_fields_new_complex_tbl(rb_imemo_fields_owner(fields_obj), shape_id, dest_table, false /* TODO: check */);
+
+ st_replace(dest_table, src_table);
+
+ st_foreach(dest_table, imemo_fields_complex_wb_i, (st_data_t)clone);
+ }
+ else {
+ clone = rb_imemo_fields_new(rb_imemo_fields_owner(fields_obj), shape_id, false /* TODO: check */);
+ VALUE *fields = rb_imemo_fields_ptr(clone);
+ attr_index_t fields_count = RSHAPE_LEN(shape_id);
+ MEMCPY(fields, rb_imemo_fields_ptr(fields_obj), VALUE, fields_count);
+ for (attr_index_t i = 0; i < fields_count; i++) {
+ RB_OBJ_WRITTEN(clone, Qundef, fields[i]);
+ }
+ }
+
+ return clone;
+}
+
+void
+rb_imemo_fields_clear(VALUE fields_obj)
+{
+ // When replacing an imemo/fields by another one, we must clear
+ // its shape so that gc.c:obj_free_object_id won't be called.
+ if (rb_obj_shape_complex_p(fields_obj)) {
+ RBASIC_SET_SHAPE_ID(fields_obj, ROOT_COMPLEX_SHAPE_ID);
+ }
+ else {
+ RBASIC_SET_SHAPE_ID(fields_obj, ROOT_SHAPE_ID);
+ }
+ // Invalidate the ec->gen_fields_cache.
+ RBASIC_CLEAR_CLASS(fields_obj);
+}
+
+VALUE
+rb_imemo_subclasses_new(uint32_t capacity)
+{
+ size_t embed_size = offsetof(struct rb_subclasses, as) + capacity * sizeof(VALUE);
+ struct rb_subclasses *subs;
+
+ if (rb_gc_size_allocatable_p(embed_size)) {
+ subs = (struct rb_subclasses *)rb_imemo_new(imemo_subclasses, 0, embed_size, true);
+ subs->count = 0;
+ subs->capacity = capacity;
+ memset(subs->as.embed, 0, capacity * sizeof(VALUE));
+ rb_gc_declare_weak_references((VALUE)subs);
+ }
+ else {
+ subs = (struct rb_subclasses *)rb_imemo_new(imemo_subclasses, 0, sizeof(struct rb_subclasses), true);
+ subs->as.external = NULL;
+ subs->count = 0;
+ subs->capacity = 0;
+ FL_SET_RAW((VALUE)subs, IMEMO_SUBCLASSES_HEAP);
+ rb_gc_declare_weak_references((VALUE)subs);
+ subs->as.external = ZALLOC_N(VALUE, capacity);
+ subs->capacity = capacity;
+ }
+ return (VALUE)subs;
+}
+
+/* =========================================================================
+ * memsize
+ * ========================================================================= */
+
+size_t
+rb_imemo_memsize(VALUE obj)
+{
+ size_t size = 0;
+ switch (imemo_type(obj)) {
+ case imemo_callcache:
+ break;
+ case imemo_callinfo:
+ break;
+ case imemo_constcache:
+ break;
+ case imemo_cref:
+ break;
+ case imemo_env:
+ size += ((rb_env_t *)obj)->env_size * sizeof(VALUE);
+
+ break;
+ case imemo_ifunc:
+ break;
+ case imemo_iseq:
+ size += rb_iseq_memsize((rb_iseq_t *)obj);
+
+ break;
+ case imemo_memo:
+ break;
+ case imemo_ment:
+ size += sizeof(((rb_method_entry_t *)obj)->def);
+
+ break;
+ case imemo_svar:
+ break;
+ case imemo_throw_data:
+ break;
+ case imemo_tmpbuf:
+ size += ((rb_imemo_tmpbuf_t *)obj)->size;
+
+ break;
+ case imemo_cvar_entry:
+ break;
+ case imemo_fields:
+ if (rb_obj_shape_complex_p(obj)) {
+ size += st_memsize(IMEMO_OBJ_FIELDS(obj)->as.complex.table);
+ }
+
+ break;
+ case imemo_subclasses: {
+ if (FL_TEST_RAW(obj, IMEMO_SUBCLASSES_HEAP)) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)obj;
+ size += subs->capacity * sizeof(VALUE);
+ }
+
+ break;
+ }
+ case imemo_cdhash:
+ size += st_memsize(rb_imemo_cdhash_tbl(obj)) - sizeof(st_table);
+
+ break;
+ default:
+ rb_bug("unreachable");
+ }
+
+ return size;
+}
+
+/* =========================================================================
+ * mark
+ * ========================================================================= */
+
+static bool
+moved_or_living_object_strictly_p(VALUE obj)
+{
+ return !SPECIAL_CONST_P(obj) && (!rb_objspace_garbage_object_p(obj) || BUILTIN_TYPE(obj) == T_MOVED);
+}
+
+static void
+mark_and_move_method_entry(rb_method_entry_t *ment, bool reference_updating)
+{
+ rb_method_definition_t *def = ment->def;
+
+ rb_gc_mark_and_move(&ment->owner);
+ rb_gc_mark_and_move(&ment->defined_class);
+
+ if (def) {
+ switch (def->type) {
+ case VM_METHOD_TYPE_ISEQ:
+ if (def->body.iseq.iseqptr) {
+ rb_gc_mark_and_move_ptr(&def->body.iseq.iseqptr);
+ }
+ rb_gc_mark_and_move_ptr(&def->body.iseq.cref);
+
+ if (!reference_updating) {
+ if (def->iseq_overload && ment->defined_class) {
+ // it can be a key of "overloaded_cme" table
+ // so it should be pinned.
+ rb_gc_mark((VALUE)ment);
+ }
+ }
+ break;
+ case VM_METHOD_TYPE_ATTRSET:
+ case VM_METHOD_TYPE_IVAR:
+ rb_gc_mark_and_move(&def->body.attr.location);
+ break;
+ case VM_METHOD_TYPE_BMETHOD:
+ if (!rb_gc_checking_shareable()) {
+ rb_gc_mark_and_move(&def->body.bmethod.proc);
+ }
+ break;
+ case VM_METHOD_TYPE_ALIAS:
+ rb_gc_mark_and_move_ptr(&def->body.alias.original_me);
+ return;
+ case VM_METHOD_TYPE_REFINED:
+ rb_gc_mark_and_move_ptr(&def->body.refined.orig_me);
+ break;
+ case VM_METHOD_TYPE_CFUNC:
+ case VM_METHOD_TYPE_ZSUPER:
+ case VM_METHOD_TYPE_MISSING:
+ case VM_METHOD_TYPE_OPTIMIZED:
+ case VM_METHOD_TYPE_UNDEF:
+ case VM_METHOD_TYPE_NOTIMPLEMENTED:
+ break;
+ }
+ }
+}
+
+void
+rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
+{
+ switch (imemo_type(obj)) {
+ case imemo_callcache: {
+ /* cc is callcache.
+ *
+ * cc->klass (klass) should not be marked because if the klass is
+ * free'ed, the cc->klass will be cleared by `vm_cc_invalidate()`.
+ *
+ * For "normal" CCs cc->cme (cme) should not be marked because the cc is
+ * invalidated through the klass when the cme is free'd.
+ * - klass marks cme if klass uses cme.
+ * - caller class's ccs->cme marks cc->cme.
+ * - if cc is invalidated (klass doesn't refer the cc), cc is
+ * invalidated by `vm_cc_invalidate()` after which cc->cme must not
+ * be accessed.
+ * - With multi-Ractors, cme will be collected with global GC
+ * so that it is safe if GC is not interleaving while accessing
+ * cc and cme.
+ *
+ * However cc_type_super and cc_type_refinement are not chained
+ * from ccs so cc->cme should be marked as long as the cc is valid;
+ * the cme might be reachable only through cc in these cases.
+ */
+ struct rb_callcache *cc = (struct rb_callcache *)obj;
+ if (UNDEF_P(cc->klass)) {
+ /* If it's invalidated, we must not mark anything.
+ * All fields should are considered invalid
+ */
+ }
+ else if (reference_updating) {
+ if (moved_or_living_object_strictly_p((VALUE)cc->cme_)) {
+ *((VALUE *)&cc->klass) = rb_gc_location(cc->klass);
+ *((struct rb_callable_method_entry_struct **)&cc->cme_) =
+ (struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cc->cme_);
+
+ RUBY_ASSERT(RB_TYPE_P(cc->klass, T_CLASS) || RB_TYPE_P(cc->klass, T_ICLASS));
+ RUBY_ASSERT(IMEMO_TYPE_P((VALUE)cc->cme_, imemo_ment));
+ }
+ else {
+ vm_cc_invalidate(cc);
+ }
+ }
+ else {
+ RUBY_ASSERT(RB_TYPE_P(cc->klass, T_CLASS) || RB_TYPE_P(cc->klass, T_ICLASS));
+ RUBY_ASSERT(IMEMO_TYPE_P((VALUE)cc->cme_, imemo_ment));
+
+ if ((vm_cc_super_p(cc) || vm_cc_refinement_p(cc))) {
+ rb_gc_mark_movable((VALUE)cc->cme_);
+ }
+ }
+
+ break;
+ }
+ case imemo_callinfo:
+ break;
+ case imemo_constcache: {
+ struct iseq_inline_constant_cache_entry *ice = (struct iseq_inline_constant_cache_entry *)obj;
+
+ if ((ice->flags & IMEMO_CONST_CACHE_SHAREABLE) ||
+ !rb_gc_checking_shareable()) {
+ rb_gc_mark_and_move(&ice->value);
+ }
+
+ break;
+ }
+ case imemo_cref: {
+ rb_cref_t *cref = (rb_cref_t *)obj;
+
+ if (!rb_gc_checking_shareable()) {
+ // cref->klass_or_self can be unshareable, but no way to access it from other ractors
+ rb_gc_mark_and_move(&cref->klass_or_self);
+ }
+
+ rb_gc_mark_and_move_ptr(&cref->next);
+
+ // TODO: Ractor and refeinements are not resolved yet
+ if (!rb_gc_checking_shareable()) {
+ rb_gc_mark_and_move(&cref->refinements);
+ }
+
+ break;
+ }
+ case imemo_env: {
+ rb_env_t *env = (rb_env_t *)obj;
+
+ if (LIKELY(env->ep)) {
+ // just after newobj() can be NULL here.
+ RUBY_ASSERT(rb_gc_location(env->ep[VM_ENV_DATA_INDEX_ENV]) == rb_gc_location(obj));
+ RUBY_ASSERT(reference_updating || VM_ENV_ESCAPED_P(env->ep));
+
+ for (unsigned int i = 0; i < env->env_size; i++) {
+ rb_gc_mark_and_move((VALUE *)&env->env[i]);
+ }
+
+ rb_gc_mark_and_move_ptr(&env->iseq);
+
+ if (VM_ENV_LOCAL_P(env->ep) && VM_ENV_BOXED_P(env->ep)) {
+ const rb_box_t *box = VM_ENV_BOX(env->ep);
+ if (BOX_USER_P(box)) {
+ rb_gc_mark_and_move((VALUE *)&box->box_object);
+ }
+ }
+
+ if (reference_updating) {
+ ((VALUE *)env->ep)[VM_ENV_DATA_INDEX_ENV] = rb_gc_location(env->ep[VM_ENV_DATA_INDEX_ENV]);
+ }
+ else {
+ if (!VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_WB_REQUIRED)) {
+ VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
+ }
+ rb_gc_mark_movable( (VALUE)rb_vm_env_prev_env(env));
+ }
+ }
+
+ break;
+ }
+ case imemo_ifunc: {
+ struct vm_ifunc *ifunc = (struct vm_ifunc *)obj;
+
+ if (!reference_updating) {
+ rb_gc_mark_maybe((VALUE)ifunc->data);
+ }
+
+ break;
+ }
+ case imemo_iseq:
+ rb_iseq_mark_and_move((rb_iseq_t *)obj, reference_updating);
+ break;
+ case imemo_memo: {
+ struct MEMO *memo = (struct MEMO *)obj;
+
+ rb_gc_mark_and_move((VALUE *)&memo->v1);
+ rb_gc_mark_and_move((VALUE *)&memo->v2);
+ if (FL_TEST_RAW(obj, MEMO_U3_IS_VALUE)) {
+ rb_gc_mark_and_move((VALUE *)&memo->u3.value);
+ }
+
+ break;
+ }
+ case imemo_ment:
+ mark_and_move_method_entry((rb_method_entry_t *)obj, reference_updating);
+ break;
+ case imemo_svar: {
+ struct vm_svar *svar = (struct vm_svar *)obj;
+
+ rb_gc_mark_and_move((VALUE *)&svar->cref_or_me);
+ rb_gc_mark_and_move((VALUE *)&svar->lastline);
+ rb_gc_mark_and_move((VALUE *)&svar->backref);
+ rb_gc_mark_and_move((VALUE *)&svar->others);
+
+ break;
+ }
+ case imemo_throw_data: {
+ struct vm_throw_data *throw_data = (struct vm_throw_data *)obj;
+
+ rb_gc_mark_and_move((VALUE *)&throw_data->throw_obj);
+
+ break;
+ }
+ case imemo_tmpbuf: {
+ const rb_imemo_tmpbuf_t *m = (const rb_imemo_tmpbuf_t *)obj;
+
+ if (!reference_updating) {
+ rb_gc_mark_locations(m->ptr, m->ptr + (m->size / sizeof(VALUE)));
+ }
+
+ break;
+ }
+ case imemo_cvar_entry: {
+ struct rb_cvar_class_tbl_entry *ent = (struct rb_cvar_class_tbl_entry *)obj;
+ rb_gc_mark_and_move(&ent->class_value);
+ rb_gc_mark_and_move((VALUE *)&ent->cref);
+ break;
+ }
+ case imemo_subclasses: {
+ if (reference_updating) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)obj;
+ VALUE *entries = rb_imemo_subclasses_entries(obj);
+ for (uint32_t i = 0; i < subs->count; i++) {
+ if (entries[i]) {
+ entries[i] = rb_gc_location(entries[i]);
+ }
+ }
+ }
+ break;
+ }
+ case imemo_fields: {
+ rb_gc_mark_and_move((VALUE *)&RBASIC(obj)->klass);
+
+ if (!rb_gc_checking_shareable()) {
+ // imemo_fields can refer unshareable objects
+ // even if the imemo_fields is shareable.
+
+ if (rb_obj_shape_complex_p(obj)) {
+ st_table *tbl = rb_imemo_fields_complex_tbl(obj);
+ if (reference_updating) {
+ rb_gc_ref_update_table_values_only(tbl);
+ }
+ else {
+ rb_mark_tbl_no_pin(tbl);
+ }
+ }
+ else {
+ VALUE *fields = rb_imemo_fields_ptr(obj);
+ attr_index_t len = RSHAPE_LEN(RBASIC_SHAPE_ID(obj));
+ for (attr_index_t i = 0; i < len; i++) {
+ rb_gc_mark_and_move(&fields[i]);
+ }
+ }
+ }
+ break;
+ }
+ case imemo_cdhash: {
+ st_table *tbl = rb_imemo_cdhash_tbl(obj);
+ if (reference_updating) {
+ rb_gc_update_set_refs(tbl);
+ }
+ else {
+ rb_gc_mark_set_no_pin(tbl);
+ }
+ break;
+ }
+ default:
+ rb_bug("unreachable");
+ }
+}
+
+/* =========================================================================
+ * free
+ * ========================================================================= */
+
+static enum rb_id_table_iterator_result
+free_const_entry_i(VALUE value, void *data)
+{
+ rb_const_entry_t *ce = (rb_const_entry_t *)value;
+ SIZED_FREE(ce);
+ return ID_TABLE_CONTINUE;
+}
+
+void
+rb_free_const_table(struct rb_id_table *tbl)
+{
+ rb_id_table_foreach_values(tbl, free_const_entry_i, 0);
+ rb_id_table_free(tbl);
+}
+
+static inline void
+imemo_fields_free(struct rb_fields *fields)
+{
+ if (FL_TEST_RAW((VALUE)fields, OBJ_FIELD_HEAP)) {
+ RUBY_ASSERT(rb_shape_complex_p(RBASIC_SHAPE_ID((VALUE)fields)));
+ st_free_table(fields->as.complex.table);
+ }
+}
+
+void
+rb_imemo_free(VALUE obj)
+{
+ switch (imemo_type(obj)) {
+ case imemo_callcache:
+ RB_DEBUG_COUNTER_INC(obj_imemo_callcache);
+
+ break;
+ case imemo_callinfo:{
+ const struct rb_callinfo *ci = ((const struct rb_callinfo *)obj);
+
+ if (ci->kwarg) {
+ if (RUBY_ATOMIC_FETCH_SUB(((struct rb_callinfo_kwarg *)ci->kwarg)->references, 1) == 1) {
+ ruby_xfree_sized((void *)ci->kwarg, rb_callinfo_kwarg_bytes(ci->kwarg->keyword_len));
+ }
+ }
+ RB_DEBUG_COUNTER_INC(obj_imemo_callinfo);
+
+ break;
+ }
+ case imemo_constcache:
+ RB_DEBUG_COUNTER_INC(obj_imemo_constcache);
+
+ break;
+ case imemo_cref:
+ RB_DEBUG_COUNTER_INC(obj_imemo_cref);
+
+ break;
+ case imemo_env: {
+ rb_env_t *env = (rb_env_t *)obj;
+
+ RUBY_ASSERT(VM_ENV_ESCAPED_P(env->ep));
+ SIZED_FREE_N(env->env, env->env_size);
+ RB_DEBUG_COUNTER_INC(obj_imemo_env);
+
+ break;
+ }
+ case imemo_ifunc:
+ RB_DEBUG_COUNTER_INC(obj_imemo_ifunc);
+ break;
+ case imemo_iseq:
+ rb_iseq_free((rb_iseq_t *)obj);
+ RB_DEBUG_COUNTER_INC(obj_imemo_iseq);
+
+ break;
+ case imemo_memo:
+ RB_DEBUG_COUNTER_INC(obj_imemo_memo);
+
+ break;
+ case imemo_ment:
+ rb_free_method_entry((rb_method_entry_t *)obj);
+ RB_DEBUG_COUNTER_INC(obj_imemo_ment);
+
+ break;
+ case imemo_svar:
+ RB_DEBUG_COUNTER_INC(obj_imemo_svar);
+
+ break;
+ case imemo_throw_data:
+ RB_DEBUG_COUNTER_INC(obj_imemo_throw_data);
+
+ break;
+ case imemo_tmpbuf:
+ ruby_xfree_sized(((rb_imemo_tmpbuf_t *)obj)->ptr, ((rb_imemo_tmpbuf_t *)obj)->size);
+ RB_DEBUG_COUNTER_INC(obj_imemo_tmpbuf);
+
+ break;
+ case imemo_cvar_entry:
+ RB_DEBUG_COUNTER_INC(obj_imemo_cvar_entry);
+
+ break;
+ case imemo_fields:
+ imemo_fields_free(IMEMO_OBJ_FIELDS(obj));
+ RB_DEBUG_COUNTER_INC(obj_imemo_fields);
+
+ break;
+ case imemo_subclasses: {
+ if (FL_TEST_RAW(obj, IMEMO_SUBCLASSES_HEAP)) {
+ struct rb_subclasses *subs = (struct rb_subclasses *)obj;
+ SIZED_FREE_N(subs->as.external, subs->capacity);
+ }
+ RB_DEBUG_COUNTER_INC(obj_imemo_subclasses);
+ break;
+ }
+ case imemo_cdhash:
+ st_free_embedded_table(rb_imemo_cdhash_tbl(obj));
+ RB_DEBUG_COUNTER_INC(obj_imemo_cdhash);
+
+ break;
+ default:
+ rb_bug("unreachable");
+ }
+}
diff --git a/include/ruby/assert.h b/include/ruby/assert.h
index 0c052363bc..acc5e5bbfc 100644
--- a/include/ruby/assert.h
+++ b/include/ruby/assert.h
@@ -22,6 +22,7 @@
*/
#include "ruby/internal/assume.h"
#include "ruby/internal/attr/cold.h"
+#include "ruby/internal/attr/format.h"
#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/dllexport.h"
@@ -132,6 +133,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
RBIMPL_ATTR_NORETURN()
RBIMPL_ATTR_COLD()
void rb_assert_failure(const char *file, int line, const char *name, const char *expr);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_COLD()
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 5, 6)
+void rb_assert_failure_detail(const char *file, int line, const char *name, const char *expr, const char *fmt, ...);
RBIMPL_SYMBOL_EXPORT_END()
#ifdef RUBY_FUNCTION_NAME_STRING
@@ -147,8 +153,28 @@ RBIMPL_SYMBOL_EXPORT_END()
*
* @param mesg The message to display.
*/
-#define RUBY_ASSERT_FAIL(mesg) \
+#if defined(HAVE___VA_OPT__)
+# if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
+/* __VA_OPT__ is to be used for the zero variadic macro arguments
+ * cases. */
+RBIMPL_WARNING_IGNORED(-Wgnu-zero-variadic-macro-arguments)
+# endif
+# define RBIMPL_VA_OPT_ARGS(...) __VA_OPT__(,) __VA_ARGS__
+
+# define RUBY_ASSERT_FAIL(mesg, ...) \
+ rb_assert_failure##__VA_OPT__(_detail)( \
+ __FILE__, __LINE__, RBIMPL_ASSERT_FUNC, mesg RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+#elif !defined(__cplusplus)
+# define RBIMPL_VA_OPT_ARGS(...)
+
+# define RUBY_ASSERT_FAIL(mesg, ...) \
rb_assert_failure(__FILE__, __LINE__, RBIMPL_ASSERT_FUNC, mesg)
+#else
+# undef RBIMPL_VA_OPT_ARGS
+
+# define RUBY_ASSERT_FAIL(mesg) \
+ rb_assert_failure(__FILE__, __LINE__, RBIMPL_ASSERT_FUNC, mesg)
+#endif
/**
* Asserts that the expression is truthy. If not aborts with the message.
@@ -156,15 +182,25 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param expr What supposedly evaluates to true.
* @param mesg The message to display on failure.
*/
-#define RUBY_ASSERT_MESG(expr, mesg) \
+#if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_MESG(expr, ...) \
+ (RB_LIKELY(expr) ? RBIMPL_ASSERT_NOTHING : RUBY_ASSERT_FAIL(__VA_ARGS__))
+#else
+# define RUBY_ASSERT_MESG(expr, mesg) \
(RB_LIKELY(expr) ? RBIMPL_ASSERT_NOTHING : RUBY_ASSERT_FAIL(mesg))
+#endif
/**
* A variant of #RUBY_ASSERT that does not interface with #RUBY_DEBUG.
*
* @copydetails #RUBY_ASSERT
*/
-#define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG((expr), #expr)
+#if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_ALWAYS(expr, ...) \
+ RUBY_ASSERT_MESG(expr, #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+#else
+# define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG((expr), #expr)
+#endif
/**
* Asserts that the given expression is truthy if and only if #RUBY_DEBUG is truthy.
@@ -172,9 +208,18 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param expr What supposedly evaluates to true.
*/
#if RUBY_DEBUG
-# define RUBY_ASSERT(expr) RUBY_ASSERT_MESG((expr), #expr)
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT(expr, ...) \
+ RUBY_ASSERT_MESG((expr), #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+# else
+# define RUBY_ASSERT(expr) RUBY_ASSERT_MESG((expr), #expr)
+# endif
#else
-# define RUBY_ASSERT(expr) RBIMPL_ASSERT_NOTHING
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT(/* expr, */...) RBIMPL_ASSERT_NOTHING
+# else
+# define RUBY_ASSERT(expr) RBIMPL_ASSERT_NOTHING
+# endif
#endif
/**
@@ -187,9 +232,18 @@ RBIMPL_SYMBOL_EXPORT_END()
/* Currently `RUBY_DEBUG == ! defined(NDEBUG)` is always true. There is no
* difference any longer between this one and `RUBY_ASSERT`. */
#if defined(NDEBUG)
-# define RUBY_ASSERT_NDEBUG(expr) RBIMPL_ASSERT_NOTHING
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_NDEBUG(/* expr, */...) RBIMPL_ASSERT_NOTHING
+# else
+# define RUBY_ASSERT_NDEBUG(expr) RBIMPL_ASSERT_NOTHING
+# endif
#else
-# define RUBY_ASSERT_NDEBUG(expr) RUBY_ASSERT_MESG((expr), #expr)
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_NDEBUG(expr, ...) \
+ RUBY_ASSERT_MESG((expr), #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+# else
+# define RUBY_ASSERT_NDEBUG(expr) RUBY_ASSERT_MESG((expr), #expr)
+# endif
#endif
/**
@@ -197,10 +251,20 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param mesg The message to display on failure.
*/
#if RUBY_DEBUG
-# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) RUBY_ASSERT_MESG((expr), (mesg))
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_MESG_WHEN(cond, /* expr, */...) \
+ RUBY_ASSERT_MESG(__VA_ARGS__)
+# else
+# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) RUBY_ASSERT_MESG((expr), (mesg))
+# endif
#else
-# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
+# if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_MESG_WHEN(cond, expr, ...) \
+ ((cond) ? RUBY_ASSERT_MESG((expr), __VA_ARGS__) : RBIMPL_ASSERT_NOTHING)
+# else
+# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
((cond) ? RUBY_ASSERT_MESG((expr), (mesg)) : RBIMPL_ASSERT_NOTHING)
+# endif
#endif
/**
@@ -210,7 +274,23 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param cond Extra condition that shall hold for assertion to take effect.
* @param expr What supposedly evaluates to true.
*/
-#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN((cond), (expr), #expr)
+#if defined(RBIMPL_VA_OPT_ARGS)
+# define RUBY_ASSERT_WHEN(cond, expr, ...) \
+ RUBY_ASSERT_MESG_WHEN(cond, expr, #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
+#else
+# define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN((cond), (expr), #expr)
+#endif
+
+/**
+ * A variant of #RUBY_ASSERT that asserts when either #RUBY_DEBUG or built-in
+ * type of `obj` is `type`.
+ *
+ * @param obj Object to check its built-in typue.
+ * @param type Built-in type constant, T_ARRAY, T_STRING, etc.
+ */
+#define RUBY_ASSERT_BUILTIN_TYPE(obj, type) \
+ RUBY_ASSERT(RB_TYPE_P(obj, type), \
+ "Actual type is %s", rb_builtin_type_name(BUILTIN_TYPE(obj)))
/**
* This is either #RUBY_ASSERT or #RBIMPL_ASSUME, depending on #RUBY_DEBUG.
@@ -218,17 +298,19 @@ RBIMPL_SYMBOL_EXPORT_END()
* @copydetails #RUBY_ASSERT
*/
#if RUBY_DEBUG
-# define RBIMPL_ASSERT_OR_ASSUME(expr) RUBY_ASSERT_ALWAYS(expr)
+# define RBIMPL_ASSERT_OR_ASSUME RUBY_ASSERT_ALWAYS
+#elif ! defined(RBIMPL_VA_OPT_ARGS)
+# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSUME(expr)
#elif RBIMPL_COMPILER_BEFORE(Clang, 7, 0, 0)
# /* See commit 67d259c5dccd31fe49d417fec169977712ffdf10 */
-# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
+# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
#elif defined(RUBY_ASSERT_NOASSUME)
# /* See commit d300a734414ef6de7e8eb563b7cc4389c455ed08 */
-# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
+# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
#elif ! defined(RBIMPL_HAVE___ASSUME)
-# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
+# define RBIMPL_ASSERT_OR_ASSUME(...) RBIMPL_ASSERT_NOTHING
#else
-# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSUME(expr)
+# define RBIMPL_ASSERT_OR_ASSUME(expr, ...) RBIMPL_ASSUME(expr)
#endif
#endif /* RUBY_ASSERT_H */
diff --git a/include/ruby/atomic.h b/include/ruby/atomic.h
index 3eb80fbf7d..fcc48f532c 100644
--- a/include/ruby/atomic.h
+++ b/include/ruby/atomic.h
@@ -34,7 +34,7 @@
# include <sys/types.h> /* ssize_t */
#endif
-#if RBIMPL_COMPILER_SINCE(MSVC, 13, 0, 0)
+#if RBIMPL_COMPILER_IS(MSVC)
# pragma intrinsic(_InterlockedOr)
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
# include <atomic.h>
@@ -72,13 +72,40 @@ typedef unsigned int rb_atomic_t;
#elif defined(HAVE_GCC_SYNC_BUILTINS)
typedef unsigned int rb_atomic_t;
#elif defined(_WIN32)
+# include <winsock2.h> // to prevent macro redefinitions
+# include <windows.h> // for `LONG` and `Interlocked` functions
typedef LONG rb_atomic_t;
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
typedef unsigned int rb_atomic_t;
+#elif defined(HAVE_STDATOMIC_H)
+# include <stdatomic.h>
+typedef unsigned int rb_atomic_t;
#else
# error No atomic operation found
#endif
+/* Memory ordering constants */
+#if defined(HAVE_GCC_ATOMIC_BUILTINS)
+# define RBIMPL_ATOMIC_RELAXED __ATOMIC_RELAXED
+# define RBIMPL_ATOMIC_ACQUIRE __ATOMIC_ACQUIRE
+# define RBIMPL_ATOMIC_RELEASE __ATOMIC_RELEASE
+# define RBIMPL_ATOMIC_ACQ_REL __ATOMIC_ACQ_REL
+# define RBIMPL_ATOMIC_SEQ_CST __ATOMIC_SEQ_CST
+#elif defined(HAVE_STDATOMIC_H)
+# define RBIMPL_ATOMIC_RELAXED memory_order_relaxed
+# define RBIMPL_ATOMIC_ACQUIRE memory_order_acquire
+# define RBIMPL_ATOMIC_RELEASE memory_order_release
+# define RBIMPL_ATOMIC_ACQ_REL memory_order_acq_rel
+# define RBIMPL_ATOMIC_SEQ_CST memory_order_seq_cst
+#else
+/* Dummy values for unsupported platforms */
+# define RBIMPL_ATOMIC_RELAXED 0
+# define RBIMPL_ATOMIC_ACQUIRE 1
+# define RBIMPL_ATOMIC_RELEASE 2
+# define RBIMPL_ATOMIC_ACQ_REL 3
+# define RBIMPL_ATOMIC_SEQ_CST 4
+#endif
+
/**
* Atomically replaces the value pointed by `var` with the result of addition
* of `val` to the old value of `var`.
@@ -88,7 +115,7 @@ typedef unsigned int rb_atomic_t;
* @return What was stored in `var` before the addition.
* @post `var` holds `var + val`.
*/
-#define RUBY_ATOMIC_FETCH_ADD(var, val) rbimpl_atomic_fetch_add(&(var), (val))
+#define RUBY_ATOMIC_FETCH_ADD(var, val) rbimpl_atomic_fetch_add(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomically replaces the value pointed by `var` with the result of
@@ -99,7 +126,7 @@ typedef unsigned int rb_atomic_t;
* @return What was stored in `var` before the subtraction.
* @post `var` holds `var - val`.
*/
-#define RUBY_ATOMIC_FETCH_SUB(var, val) rbimpl_atomic_fetch_sub(&(var), (val))
+#define RUBY_ATOMIC_FETCH_SUB(var, val) rbimpl_atomic_fetch_sub(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomically replaces the value pointed by `var` with the result of
@@ -111,7 +138,7 @@ typedef unsigned int rb_atomic_t;
* @post `var` holds `var | val`.
* @note For portability, this macro can return void.
*/
-#define RUBY_ATOMIC_OR(var, val) rbimpl_atomic_or(&(var), (val))
+#define RUBY_ATOMIC_OR(var, val) rbimpl_atomic_or(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomically replaces the value pointed by `var` with `val`. This is just an
@@ -122,7 +149,7 @@ typedef unsigned int rb_atomic_t;
* @return What was stored in `var` before the assignment.
* @post `var` holds `val`.
*/
-#define RUBY_ATOMIC_EXCHANGE(var, val) rbimpl_atomic_exchange(&(var), (val))
+#define RUBY_ATOMIC_EXCHANGE(var, val) rbimpl_atomic_exchange(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomic compare-and-swap. This stores `val` to `var` if and only if the
@@ -136,7 +163,16 @@ typedef unsigned int rb_atomic_t;
* @retval otherwise Something else is at `var`; not updated.
*/
#define RUBY_ATOMIC_CAS(var, oldval, newval) \
- rbimpl_atomic_cas(&(var), (oldval), (newval))
+ rbimpl_atomic_cas(&(var), (oldval), (newval), RBIMPL_ATOMIC_SEQ_CST, RBIMPL_ATOMIC_SEQ_CST)
+
+/**
+ * Atomic load. This loads `var` with an atomic intrinsic and returns
+ * its value.
+ *
+ * @param var A variable of ::rb_atomic_t
+ * @return What was stored in `var`j
+ */
+#define RUBY_ATOMIC_LOAD(var) rbimpl_atomic_load(&(var), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_EXCHANGE, except for the return type.
@@ -146,7 +182,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `val`.
*/
-#define RUBY_ATOMIC_SET(var, val) rbimpl_atomic_set(&(var), (val))
+#define RUBY_ATOMIC_SET(var, val) rbimpl_atomic_store(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_FETCH_ADD, except for the return type.
@@ -156,7 +192,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var + val`.
*/
-#define RUBY_ATOMIC_ADD(var, val) rbimpl_atomic_add(&(var), (val))
+#define RUBY_ATOMIC_ADD(var, val) rbimpl_atomic_add(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_FETCH_SUB, except for the return type.
@@ -166,7 +202,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var - val`.
*/
-#define RUBY_ATOMIC_SUB(var, val) rbimpl_atomic_sub(&(var), (val))
+#define RUBY_ATOMIC_SUB(var, val) rbimpl_atomic_sub(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomically increments the value pointed by `var`.
@@ -175,7 +211,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var + 1`.
*/
-#define RUBY_ATOMIC_INC(var) rbimpl_atomic_inc(&(var))
+#define RUBY_ATOMIC_INC(var) rbimpl_atomic_inc(&(var), RBIMPL_ATOMIC_SEQ_CST)
/**
* Atomically decrements the value pointed by `var`.
@@ -184,7 +220,19 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var - 1`.
*/
-#define RUBY_ATOMIC_DEC(var) rbimpl_atomic_dec(&(var))
+#define RUBY_ATOMIC_DEC(var) rbimpl_atomic_dec(&(var), RBIMPL_ATOMIC_SEQ_CST)
+
+/**
+ * Identical to #RUBY_ATOMIC_FETCH_ADD, except it expects its arguments to be `size_t`.
+ * There are cases where ::rb_atomic_t is 32bit while `size_t` is 64bit. This
+ * should be used for size related operations to support such platforms.
+ *
+ * @param var A variable of `size_t`.
+ * @param val Value to add.
+ * @return What was stored in `var` before the addition.
+ * @post `var` holds `var + val`.
+ */
+#define RUBY_ATOMIC_SIZE_FETCH_ADD(var, val) rbimpl_atomic_size_fetch_add(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_INC, except it expects its argument is `size_t`.
@@ -195,7 +243,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var + 1`.
*/
-#define RUBY_ATOMIC_SIZE_INC(var) rbimpl_atomic_size_inc(&(var))
+#define RUBY_ATOMIC_SIZE_INC(var) rbimpl_atomic_size_inc(&(var), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_DEC, except it expects its argument is `size_t`.
@@ -206,7 +254,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var - 1`.
*/
-#define RUBY_ATOMIC_SIZE_DEC(var) rbimpl_atomic_size_dec(&(var))
+#define RUBY_ATOMIC_SIZE_DEC(var) rbimpl_atomic_size_dec(&(var), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_EXCHANGE, except it expects its arguments are
@@ -220,7 +268,7 @@ typedef unsigned int rb_atomic_t;
* @post `var` holds `val`.
*/
#define RUBY_ATOMIC_SIZE_EXCHANGE(var, val) \
- rbimpl_atomic_size_exchange(&(var), (val))
+ rbimpl_atomic_size_exchange(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_CAS, except it expects its arguments are `size_t`.
@@ -234,7 +282,7 @@ typedef unsigned int rb_atomic_t;
* @retval otherwise Something else is at `var`; not updated.
*/
#define RUBY_ATOMIC_SIZE_CAS(var, oldval, newval) \
- rbimpl_atomic_size_cas(&(var), (oldval), (newval))
+ rbimpl_atomic_size_cas(&(var), (oldval), (newval), RBIMPL_ATOMIC_SEQ_CST, RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_ADD, except it expects its arguments are `size_t`.
@@ -246,7 +294,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var + val`.
*/
-#define RUBY_ATOMIC_SIZE_ADD(var, val) rbimpl_atomic_size_add(&(var), (val))
+#define RUBY_ATOMIC_SIZE_ADD(var, val) rbimpl_atomic_size_add(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_SUB, except it expects its arguments are `size_t`.
@@ -258,7 +306,7 @@ typedef unsigned int rb_atomic_t;
* @return void
* @post `var` holds `var - val`.
*/
-#define RUBY_ATOMIC_SIZE_SUB(var, val) rbimpl_atomic_size_sub(&(var), (val))
+#define RUBY_ATOMIC_SIZE_SUB(var, val) rbimpl_atomic_size_sub(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_EXCHANGE, except it expects its arguments are
@@ -277,7 +325,31 @@ typedef unsigned int rb_atomic_t;
* some pointers, most notably function pointers.
*/
#define RUBY_ATOMIC_PTR_EXCHANGE(var, val) \
- RBIMPL_CAST(rbimpl_atomic_ptr_exchange((void **)&(var), (void *)val))
+ RBIMPL_CAST(rbimpl_atomic_ptr_exchange((void **)&(var), (void *)val, RBIMPL_ATOMIC_SEQ_CST))
+
+/**
+ * Identical to #RUBY_ATOMIC_LOAD, except it expects its arguments are `void*`.
+ * There are cases where ::rb_atomic_t is 32bit while `void*` is 64bit. This
+ * should be used for size related operations to support such platforms.
+ *
+ * @param var A variable of `void*`
+ * @return The value of `var` (without tearing)
+ */
+#define RUBY_ATOMIC_PTR_LOAD(var) \
+ RBIMPL_CAST(rbimpl_atomic_ptr_load((void **)&var, RBIMPL_ATOMIC_SEQ_CST))
+
+/**
+* Identical to #RUBY_ATOMIC_SET, except it expects its arguments are
+* `void*`. There are cases where ::rb_atomic_t is 32bit while ::VALUE is
+* 64bit. This should be used for pointer related operations to support such
+* platforms.
+*
+* @param var A variable of `void*`.
+* @param val Value to set.
+* @post `var` holds `val`.
+*/
+#define RUBY_ATOMIC_PTR_SET(var, val) \
+ rbimpl_atomic_ptr_store((volatile void **)&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_CAS, except it expects its arguments are `void*`.
@@ -291,7 +363,20 @@ typedef unsigned int rb_atomic_t;
* @retval otherwise Something else is at `var`; not updated.
*/
#define RUBY_ATOMIC_PTR_CAS(var, oldval, newval) \
- RBIMPL_CAST(rbimpl_atomic_ptr_cas((void **)&(var), (oldval), (newval)))
+ RBIMPL_CAST(rbimpl_atomic_ptr_cas((void **)&(var), (void *)(oldval), (void *)(newval), RBIMPL_ATOMIC_SEQ_CST, RBIMPL_ATOMIC_SEQ_CST))
+
+/**
+ * Identical to #RUBY_ATOMIC_SET, except it expects its arguments are
+ * ::VALUE. There are cases where ::rb_atomic_t is 32bit while ::VALUE is
+ * 64bit. This should be used for pointer related operations to support such
+ * platforms.
+ *
+ * @param var A variable of ::VALUE.
+ * @param val Value to set.
+ * @post `var` holds `val`.
+ */
+#define RUBY_ATOMIC_VALUE_SET(var, val) \
+ rbimpl_atomic_value_store(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_EXCHANGE, except it expects its arguments are
@@ -305,7 +390,7 @@ typedef unsigned int rb_atomic_t;
* @post `var` holds `val`.
*/
#define RUBY_ATOMIC_VALUE_EXCHANGE(var, val) \
- rbimpl_atomic_value_exchange(&(var), (val))
+ rbimpl_atomic_value_exchange(&(var), (val), RBIMPL_ATOMIC_SEQ_CST)
/**
* Identical to #RUBY_ATOMIC_CAS, except it expects its arguments are ::VALUE.
@@ -319,19 +404,20 @@ typedef unsigned int rb_atomic_t;
* @retval otherwise Something else is at `var`; not updated.
*/
#define RUBY_ATOMIC_VALUE_CAS(var, oldval, newval) \
- rbimpl_atomic_value_cas(&(var), (oldval), (newval))
+ rbimpl_atomic_value_cas(&(var), (oldval), (newval), RBIMPL_ATOMIC_SEQ_CST, RBIMPL_ATOMIC_SEQ_CST)
/** @cond INTERNAL_MACRO */
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline rb_atomic_t
-rbimpl_atomic_fetch_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_fetch_add(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- return __atomic_fetch_add(ptr, val, __ATOMIC_SEQ_CST);
+ return __atomic_fetch_add(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_fetch_and_add(ptr, val);
@@ -348,6 +434,47 @@ rbimpl_atomic_fetch_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= INT_MAX);
return atomic_add_int_nv(ptr, val) - val;
+#elif defined(HAVE_STDATOMIC_H)
+ return atomic_fetch_add_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
+#else
+# error Unsupported platform.
+#endif
+}
+
+/** @cond INTERNAL_MACRO */
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+static inline size_t
+rbimpl_atomic_size_fetch_add(volatile size_t *ptr, size_t val, int memory_order)
+{
+ (void)memory_order;
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ return __atomic_fetch_add(ptr, val, memory_order);
+
+#elif defined(HAVE_GCC_SYNC_BUILTINS)
+ return __sync_fetch_and_add(ptr, val);
+
+#elif defined(_WIN32)
+ return InterlockedExchangeAdd64(ptr, val);
+
+#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
+ /* Ditto for `atomic_add_int_nv`. */
+ RBIMPL_ASSERT_OR_ASSUME(val <= LONG_MAX);
+ atomic_add_long(ptr, val);
+
+#elif defined(__sun) && defined(HAVE_ATOMIC_H)
+ RBIMPL_STATIC_ASSERT(size_of_rb_atomic_t, sizeof *ptr == sizeof(rb_atomic_t));
+
+ volatile rb_atomic_t *const tmp = RBIMPL_CAST((volatile rb_atomic_t *)ptr);
+ rbimpl_atomic_fetch_add(tmp, val, memory_order);
+
+#elif defined(HAVE_STDATOMIC_H)
+ return atomic_fetch_add_explicit((_Atomic volatile size_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
@@ -357,8 +484,9 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_add(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
@@ -367,7 +495,7 @@ rbimpl_atomic_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
* return value is not used, then compiles it into single `LOCK ADD`
* instruction.
*/
- __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST);
+ __atomic_add_fetch(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
__sync_add_and_fetch(ptr, val);
@@ -385,6 +513,9 @@ rbimpl_atomic_add(volatile rb_atomic_t *ptr, rb_atomic_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= INT_MAX);
atomic_add_int(ptr, val);
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_fetch_add_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
@@ -394,17 +525,18 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_size_add(volatile size_t *ptr, size_t val)
+rbimpl_atomic_size_add(volatile size_t *ptr, size_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST);
+ __atomic_add_fetch(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
__sync_add_and_fetch(ptr, val);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
/* Ditto for `InterlockeExchangedAdd`. */
InterlockedExchangeAdd64(ptr, val);
@@ -413,12 +545,17 @@ rbimpl_atomic_size_add(volatile size_t *ptr, size_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= LONG_MAX);
atomic_add_long(ptr, val);
-#else
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
RBIMPL_STATIC_ASSERT(size_of_rb_atomic_t, sizeof *ptr == sizeof(rb_atomic_t));
volatile rb_atomic_t *const tmp = RBIMPL_CAST((volatile rb_atomic_t *)ptr);
- rbimpl_atomic_add(tmp, val);
+ rbimpl_atomic_add(tmp, val, memory_order);
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_fetch_add_explicit((_Atomic volatile size_t *)ptr, val, memory_order);
+
+#else
+# error Unsupported platform.
#endif
}
@@ -426,12 +563,13 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_inc(volatile rb_atomic_t *ptr)
+rbimpl_atomic_inc(volatile rb_atomic_t *ptr, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
- rbimpl_atomic_add(ptr, 1);
+ rbimpl_atomic_add(ptr, 1, memory_order);
#elif defined(_WIN32)
InterlockedIncrement(ptr);
@@ -439,9 +577,11 @@ rbimpl_atomic_inc(volatile rb_atomic_t *ptr)
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
atomic_inc_uint(ptr);
-#else
- rbimpl_atomic_add(ptr, 1);
+#elif defined(HAVE_STDATOMIC_H)
+ rbimpl_atomic_add(ptr, 1, memory_order);
+#else
+# error Unsupported platform.
#endif
}
@@ -449,22 +589,30 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_size_inc(volatile size_t *ptr)
+rbimpl_atomic_size_inc(volatile size_t *ptr, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
- rbimpl_atomic_size_add(ptr, 1);
+ rbimpl_atomic_size_add(ptr, 1, memory_order);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
InterlockedIncrement64(ptr);
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
atomic_inc_ulong(ptr);
-#else
- rbimpl_atomic_size_add(ptr, 1);
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
+ RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
+
+ rbimpl_atomic_size_add(ptr, 1, memory_order);
+#elif defined(HAVE_STDATOMIC_H)
+ rbimpl_atomic_size_add(ptr, 1, memory_order);
+
+#else
+# error Unsupported platform.
#endif
}
@@ -472,12 +620,13 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline rb_atomic_t
-rbimpl_atomic_fetch_sub(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_fetch_sub(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- return __atomic_fetch_sub(ptr, val, __ATOMIC_SEQ_CST);
+ return __atomic_fetch_sub(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_fetch_and_sub(ptr, val);
@@ -492,6 +641,9 @@ rbimpl_atomic_fetch_sub(volatile rb_atomic_t *ptr, rb_atomic_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= INT_MAX);
return atomic_add_int_nv(ptr, neg * val) + val;
+#elif defined(HAVE_STDATOMIC_H)
+ return atomic_fetch_sub_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
@@ -501,12 +653,13 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_sub(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_sub(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- __atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST);
+ __atomic_sub_fetch(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
__sync_sub_and_fetch(ptr, val);
@@ -519,6 +672,9 @@ rbimpl_atomic_sub(volatile rb_atomic_t *ptr, rb_atomic_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= INT_MAX);
atomic_add_int(ptr, neg * val);
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_fetch_sub_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
@@ -528,17 +684,18 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_size_sub(volatile size_t *ptr, size_t val)
+rbimpl_atomic_size_sub(volatile size_t *ptr, size_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- __atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST);
+ __atomic_sub_fetch(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
__sync_sub_and_fetch(ptr, val);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
const ssize_t neg = -1;
InterlockedExchangeAdd64(ptr, neg * val);
@@ -547,12 +704,17 @@ rbimpl_atomic_size_sub(volatile size_t *ptr, size_t val)
RBIMPL_ASSERT_OR_ASSUME(val <= LONG_MAX);
atomic_add_long(ptr, neg * val);
-#else
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
RBIMPL_STATIC_ASSERT(size_of_rb_atomic_t, sizeof *ptr == sizeof(rb_atomic_t));
volatile rb_atomic_t *const tmp = RBIMPL_CAST((volatile rb_atomic_t *)ptr);
- rbimpl_atomic_sub(tmp, val);
+ rbimpl_atomic_sub(tmp, val, memory_order);
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_fetch_sub_explicit((_Atomic volatile size_t *)ptr, val, memory_order);
+
+#else
+# error Unsupported platform.
#endif
}
@@ -560,12 +722,13 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_dec(volatile rb_atomic_t *ptr)
+rbimpl_atomic_dec(volatile rb_atomic_t *ptr, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
- rbimpl_atomic_sub(ptr, 1);
+ rbimpl_atomic_sub(ptr, 1, memory_order);
#elif defined(_WIN32)
InterlockedDecrement(ptr);
@@ -573,9 +736,11 @@ rbimpl_atomic_dec(volatile rb_atomic_t *ptr)
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
atomic_dec_uint(ptr);
-#else
- rbimpl_atomic_sub(ptr, 1);
+#elif defined(HAVE_STDATOMIC_H)
+ rbimpl_atomic_sub(ptr, 1, memory_order);
+#else
+# error Unsupported platform.
#endif
}
@@ -583,22 +748,30 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_size_dec(volatile size_t *ptr)
+rbimpl_atomic_size_dec(volatile size_t *ptr, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_SYNC_BUILTINS)
- rbimpl_atomic_size_sub(ptr, 1);
+ rbimpl_atomic_size_sub(ptr, 1, memory_order);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
InterlockedDecrement64(ptr);
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
atomic_dec_ulong(ptr);
-#else
- rbimpl_atomic_size_sub(ptr, 1);
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
+ RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
+
+ rbimpl_atomic_size_sub(ptr, 1, memory_order);
+#elif defined(HAVE_STDATOMIC_H)
+ rbimpl_atomic_size_sub(ptr, 1, memory_order);
+
+#else
+# error Unsupported platform.
#endif
}
@@ -606,59 +779,42 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_or(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_or(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- __atomic_or_fetch(ptr, val, __ATOMIC_SEQ_CST);
+ __atomic_or_fetch(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
__sync_or_and_fetch(ptr, val);
-#elif RBIMPL_COMPILER_SINCE(MSVC, 13, 0, 0)
+#elif RBIMPL_COMPILER_IS(MSVC)
_InterlockedOr(ptr, val);
-#elif defined(_WIN32) && defined(__GNUC__)
- /* This was for old MinGW. Maybe not needed any longer? */
- __asm__(
- "lock\n\t"
- "orl\t%1, %0"
- : "=m"(ptr)
- : "Ir"(val));
-
-#elif defined(_WIN32) && defined(_M_IX86)
- __asm mov eax, ptr;
- __asm mov ecx, val;
- __asm lock or [eax], ecx;
-
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
atomic_or_uint(ptr, val);
+#elif !defined(_WIN32) && defined(HAVE_STDATOMIC_H)
+ atomic_fetch_or_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
}
-/* Nobody uses this but for theoretical backwards compatibility... */
-#if RBIMPL_COMPILER_BEFORE(MSVC, 13, 0, 0)
-static inline rb_atomic_t
-rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
-{
- return rbimpl_atomic_or(var, val);
-}
-#endif
-
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline rb_atomic_t
-rbimpl_atomic_exchange(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_exchange(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- return __atomic_exchange_n(ptr, val, __ATOMIC_SEQ_CST);
+ return __atomic_exchange_n(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_lock_test_and_set(ptr, val);
@@ -669,6 +825,9 @@ rbimpl_atomic_exchange(volatile rb_atomic_t *ptr, rb_atomic_t val)
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
return atomic_swap_uint(ptr, val);
+#elif defined(HAVE_STDATOMIC_H)
+ return atomic_exchange_explicit((_Atomic volatile rb_atomic_t *)ptr, val, memory_order);
+
#else
# error Unsupported platform.
#endif
@@ -678,29 +837,53 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline size_t
-rbimpl_atomic_size_exchange(volatile size_t *ptr, size_t val)
+rbimpl_atomic_size_exchange(volatile size_t *ptr, size_t val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- return __atomic_exchange_n(ptr, val, __ATOMIC_SEQ_CST);
+ return __atomic_exchange_n(ptr, val, memory_order);
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_lock_test_and_set(ptr, val);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
return InterlockedExchange64(ptr, val);
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
return atomic_swap_ulong(ptr, val);
-#else
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
volatile rb_atomic_t *const tmp = RBIMPL_CAST((volatile rb_atomic_t *)ptr);
- const rb_atomic_t ret = rbimpl_atomic_exchange(tmp, val);
+ const rb_atomic_t ret = rbimpl_atomic_exchange(tmp, val, memory_order);
return RBIMPL_CAST((size_t)ret);
+#elif defined(HAVE_STDATOMIC_H)
+ return atomic_exchange_explicit((_Atomic volatile size_t *)ptr, val, memory_order);
+
+#else
+# error Unsupported platform.
+#endif
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+static inline void
+rbimpl_atomic_size_store(volatile size_t *ptr, size_t val, int memory_order)
+{
+ (void)memory_order;
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ __atomic_store_n(ptr, val, memory_order);
+
+#else
+ rbimpl_atomic_size_exchange(ptr, val, memory_order);
+
#endif
}
@@ -708,8 +891,9 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void *
-rbimpl_atomic_ptr_exchange(void *volatile *ptr, const void *val)
+rbimpl_atomic_ptr_exchange(void *volatile *ptr, const void *val, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(InterlockedExchangePointer)
@@ -726,7 +910,7 @@ rbimpl_atomic_ptr_exchange(void *volatile *ptr, const void *val)
const size_t sval = RBIMPL_CAST((size_t)val);
volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
- const size_t sret = rbimpl_atomic_size_exchange(sptr, sval);
+ const size_t sret = rbimpl_atomic_size_exchange(sptr, sval, memory_order);
return RBIMPL_CAST((void *)sret);
#endif
@@ -735,14 +919,27 @@ rbimpl_atomic_ptr_exchange(void *volatile *ptr, const void *val)
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
+static inline void
+rbimpl_atomic_ptr_store(volatile void **ptr, void *val, int memory_order)
+{
+ RBIMPL_STATIC_ASSERT(sizeof_value, sizeof *ptr == sizeof(size_t));
+
+ const size_t sval = RBIMPL_CAST((size_t)val);
+ volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
+ rbimpl_atomic_size_store(sptr, sval, memory_order);
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
static inline VALUE
-rbimpl_atomic_value_exchange(volatile VALUE *ptr, VALUE val)
+rbimpl_atomic_value_exchange(volatile VALUE *ptr, VALUE val, int memory_order)
{
RBIMPL_STATIC_ASSERT(sizeof_value, sizeof *ptr == sizeof(size_t));
const size_t sval = RBIMPL_CAST((size_t)val);
volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
- const size_t sret = rbimpl_atomic_size_exchange(sptr, sval);
+ const size_t sret = rbimpl_atomic_size_exchange(sptr, sval, memory_order);
return RBIMPL_CAST((VALUE)sret);
}
@@ -750,16 +947,46 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void
-rbimpl_atomic_set(volatile rb_atomic_t *ptr, rb_atomic_t val)
+rbimpl_atomic_value_store(volatile VALUE *ptr, VALUE val, int memory_order)
+{
+ RBIMPL_STATIC_ASSERT(sizeof_value, sizeof *ptr == sizeof(size_t));
+
+ const size_t sval = RBIMPL_CAST((size_t)val);
+ volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
+ rbimpl_atomic_size_store(sptr, sval, memory_order);
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+static inline rb_atomic_t
+rbimpl_atomic_load(volatile rb_atomic_t *ptr, int memory_order)
{
+ (void)memory_order;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
- __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST);
+ return __atomic_load_n(ptr, memory_order);
+#else
+ return rbimpl_atomic_fetch_add(ptr, 0, memory_order);
+#endif
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+static inline void
+rbimpl_atomic_store(volatile rb_atomic_t *ptr, rb_atomic_t val, int memory_order)
+{
+ (void)memory_order;
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ __atomic_store_n(ptr, val, memory_order);
#else
/* Maybe std::atomic<rb_atomic_t>::store can be faster? */
- rbimpl_atomic_exchange(ptr, val);
+ rbimpl_atomic_exchange(ptr, val, memory_order);
#endif
}
@@ -768,73 +995,73 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline rb_atomic_t
-rbimpl_atomic_cas(volatile rb_atomic_t *ptr, rb_atomic_t oldval, rb_atomic_t newval)
+rbimpl_atomic_cas(volatile rb_atomic_t *ptr, rb_atomic_t oldval, rb_atomic_t newval, int success_memorder, int failure_memorder)
{
+ (void)success_memorder;
+ (void)failure_memorder;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
__atomic_compare_exchange_n(
- ptr, &oldval, newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ ptr, &oldval, newval, 0, success_memorder, failure_memorder);
return oldval;
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_val_compare_and_swap(ptr, oldval, newval);
-#elif RBIMPL_COMPILER_SINCE(MSVC, 13, 0, 0)
+#elif RBIMPL_COMPILER_IS(MSVC)
return InterlockedCompareExchange(ptr, newval, oldval);
-#elif defined(_WIN32)
- PVOID *pptr = RBIMPL_CAST((PVOID *)ptr);
- PVOID pold = RBIMPL_CAST((PVOID)oldval);
- PVOID pnew = RBIMPL_CAST((PVOID)newval);
- PVOID pret = InterlockedCompareExchange(pptr, pnew, pold);
- return RBIMPL_CAST((rb_atomic_t)pret);
-
#elif defined(__sun) && defined(HAVE_ATOMIC_H)
return atomic_cas_uint(ptr, oldval, newval);
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_compare_exchange_strong_explicit(
+ (_Atomic volatile rb_atomic_t *)ptr, &oldval, newval, success_memorder, failure_memorder);
+ return oldval;
+
#else
# error Unsupported platform.
#endif
}
-/* Nobody uses this but for theoretical backwards compatibility... */
-#if RBIMPL_COMPILER_BEFORE(MSVC, 13, 0, 0)
-static inline rb_atomic_t
-rb_w32_atomic_cas(volatile rb_atomic_t *var, rb_atomic_t oldval, rb_atomic_t newval)
-{
- return rbimpl_atomic_cas(var, oldval, newval);
-}
-#endif
-
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline size_t
-rbimpl_atomic_size_cas(volatile size_t *ptr, size_t oldval, size_t newval)
+rbimpl_atomic_size_cas(volatile size_t *ptr, size_t oldval, size_t newval, int success_memorder, int failure_memorder)
{
+ (void)success_memorder;
+ (void)failure_memorder;
#if 0
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
__atomic_compare_exchange_n(
- ptr, &oldval, newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ ptr, &oldval, newval, 0, success_memorder, failure_memorder);
return oldval;
#elif defined(HAVE_GCC_SYNC_BUILTINS)
return __sync_val_compare_and_swap(ptr, oldval, newval);
-#elif defined(_WIN32) && defined(_M_AMD64)
+#elif defined(_WIN64)
return InterlockedCompareExchange64(ptr, newval, oldval);
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
return atomic_cas_ulong(ptr, oldval, newval);
-#else
+#elif defined(_WIN32) || (defined(__sun) && defined(HAVE_ATOMIC_H))
RBIMPL_STATIC_ASSERT(size_of_size_t, sizeof *ptr == sizeof(rb_atomic_t));
volatile rb_atomic_t *tmp = RBIMPL_CAST((volatile rb_atomic_t *)ptr);
- return rbimpl_atomic_cas(tmp, oldval, newval);
+ return rbimpl_atomic_cas(tmp, oldval, newval, success_memorder, failure_memorder);
+
+#elif defined(HAVE_STDATOMIC_H)
+ atomic_compare_exchange_strong_explicit(
+ (_Atomic volatile size_t *)ptr, &oldval, newval, success_memorder, failure_memorder);
+ return oldval;
+#else
+# error Unsupported platform.
#endif
}
@@ -842,8 +1069,10 @@ RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
static inline void *
-rbimpl_atomic_ptr_cas(void **ptr, const void *oldval, const void *newval)
+rbimpl_atomic_ptr_cas(void **ptr, const void *oldval, const void *newval, int success_memorder, int failure_memorder)
{
+ (void)success_memorder;
+ (void)failure_memorder;
#if 0
#elif defined(InterlockedExchangePointer)
@@ -866,7 +1095,7 @@ rbimpl_atomic_ptr_cas(void **ptr, const void *oldval, const void *newval)
const size_t snew = RBIMPL_CAST((size_t)newval);
const size_t sold = RBIMPL_CAST((size_t)oldval);
volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
- const size_t sret = rbimpl_atomic_size_cas(sptr, sold, snew);
+ const size_t sret = rbimpl_atomic_size_cas(sptr, sold, snew, success_memorder, failure_memorder);
return RBIMPL_CAST((void *)sret);
#endif
@@ -875,15 +1104,41 @@ rbimpl_atomic_ptr_cas(void **ptr, const void *oldval, const void *newval)
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
+static inline void *
+rbimpl_atomic_ptr_load(void **ptr, int memory_order)
+{
+ (void)memory_order;
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ return __atomic_load_n(ptr, memory_order);
+#else
+ void *val = *ptr;
+ return rbimpl_atomic_ptr_cas(ptr, val, val, memory_order, memory_order);
+#endif
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
+static inline VALUE
+rbimpl_atomic_value_load(volatile VALUE *ptr, int memory_order)
+{
+ return RBIMPL_CAST((VALUE)rbimpl_atomic_ptr_load((void **)ptr, memory_order));
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
static inline VALUE
-rbimpl_atomic_value_cas(volatile VALUE *ptr, VALUE oldval, VALUE newval)
+rbimpl_atomic_value_cas(volatile VALUE *ptr, VALUE oldval, VALUE newval, int success_memorder, int failure_memorder)
{
RBIMPL_STATIC_ASSERT(sizeof_value, sizeof *ptr == sizeof(size_t));
const size_t snew = RBIMPL_CAST((size_t)newval);
const size_t sold = RBIMPL_CAST((size_t)oldval);
volatile size_t *const sptr = RBIMPL_CAST((volatile size_t *)ptr);
- const size_t sret = rbimpl_atomic_size_cas(sptr, sold, snew);
+ const size_t sret = rbimpl_atomic_size_cas(sptr, sold, snew, success_memorder, failure_memorder);
return RBIMPL_CAST((VALUE)sret);
}
/** @endcond */
diff --git a/include/ruby/backward.h b/include/ruby/backward.h
index f804c2c36e..6726102158 100644
--- a/include/ruby/backward.h
+++ b/include/ruby/backward.h
@@ -11,12 +11,6 @@
#include "ruby/internal/interpreter.h"
#include "ruby/backward/2/attributes.h"
-#define RBIMPL_ATTR_DEPRECATED_SINCE(ver) RBIMPL_ATTR_DEPRECATED(("since " #ver))
-#define RBIMPL_ATTR_DEPRECATED_INTERNAL(ver) RBIMPL_ATTR_DEPRECATED(("since "#ver", also internal"))
-#define RBIMPL_ATTR_DEPRECATED_INTERNAL_ONLY() RBIMPL_ATTR_DEPRECATED(("only for internal use"))
-
-RBIMPL_ATTR_DEPRECATED_INTERNAL_ONLY() void rb_clear_constant_cache(void);
-
/* from version.c */
#if defined(RUBY_SHOW_COPYRIGHT_TO_DIE) && !!(RUBY_SHOW_COPYRIGHT_TO_DIE+0)
# error RUBY_SHOW_COPYRIGHT_TO_DIE is deprecated
diff --git a/include/ruby/backward/2/rmodule.h b/include/ruby/backward/2/rmodule.h
index 53b37831c0..76c0936462 100644
--- a/include/ruby/backward/2/rmodule.h
+++ b/include/ruby/backward/2/rmodule.h
@@ -23,7 +23,7 @@
* who is implementing the internals) could have used those macros for a while.
* Kept public as-is here to keep some theoretical backwards compatibility.
*/
-#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
+#define RMODULE_IV_TBL(m) RCLASS_FIELDS(m)
#define RMODULE_CONST_TBL(m) RCLASS_CONST_TBL(m)
#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
#define RMODULE_SUPER(m) RCLASS_SUPER(m)
diff --git a/include/ruby/backward/cxxanyargs.hpp b/include/ruby/backward/cxxanyargs.hpp
index 2414b7ae6d..0ca2745c20 100644
--- a/include/ruby/backward/cxxanyargs.hpp
+++ b/include/ruby/backward/cxxanyargs.hpp
@@ -190,33 +190,6 @@ rb_define_hooked_variable(const char *q, VALUE *w, std::nullptr_t e, void_type *
/// @name Exceptions and tag jumps
/// @{
-// RUBY_CXX_DEPRECATED("by rb_block_call since 1.9")
-RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
-/// @brief Old way to implement iterators.
-/// @param[in] q A function that can yield.
-/// @param[in] w Passed to `q`.
-/// @param[in] e What is to be yielded.
-/// @param[in] r Passed to `e`.
-/// @return The return value of `q`.
-/// @note `e` can be nullptr.
-/// @deprecated This function is obsoleted since long before 2.x era. Do not
-/// use it any longer. rb_block_call() is provided instead.
-inline VALUE
-rb_iterate(onearg_type *q, VALUE w, type *e, VALUE r)
-{
- rb_block_call_func_t t = reinterpret_cast<rb_block_call_func_t>(e);
- return backward::rb_iterate_deprecated(q, w, t, r);
-}
-
-#ifdef HAVE_NULLPTR
-RUBY_CXX_DEPRECATED("by rb_block_call since 1.9")
-inline VALUE
-rb_iterate(onearg_type *q, VALUE w, std::nullptr_t e, VALUE r)
-{
- return backward::rb_iterate_deprecated(q, w, e, r);
-}
-#endif
-
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @brief Call a method with a block.
/// @param[in] q The self.
@@ -537,9 +510,7 @@ struct driver {
* this writing the version is 2.8. Let's warn this later, some time
* during 3.x. Hopefully codes in old (ANYARGS-ed) format should be
* less than now. */
-#if (RUBY_API_VERSION_MAJOR * 100 + RUBY_API_VERSION_MINOR) >= 301
RUBY_CXX_DEPRECATED("use of ANYARGS is deprecated")
-#endif
/// @copydoc define(VALUE klass, T mid, U func)
/// @deprecated Pass correctly typed function instead.
static inline void
diff --git a/include/ruby/debug.h b/include/ruby/debug.h
index f95acdb17e..27a7a5f2c1 100644
--- a/include/ruby/debug.h
+++ b/include/ruby/debug.h
@@ -10,6 +10,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
+#include "ruby/internal/attr/deprecated.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/attr/returns_nonnull.h"
#include "ruby/internal/dllexport.h"
@@ -51,6 +52,25 @@ RBIMPL_ATTR_NONNULL((3))
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines);
/**
+ * Queries mysterious "frame"s of the given range.
+ *
+ * A per-thread version of rb_profile_frames().
+ * Arguments and return values are the same with rb_profile_frames() with the
+ * exception of the first argument _thread_, which accepts the Thread to be
+ * profiled/queried.
+ *
+ * @param[in] thread The Ruby Thread to be profiled.
+ * @param[in] start Start position (0 means the topmost).
+ * @param[in] limit Number objects of `buff`.
+ * @param[out] buff Return buffer.
+ * @param[out] lines Return buffer.
+ * @return Number of objects filled into `buff`.
+ * @post `buff` is filled with backtrace pointers.
+ * @post `lines` is filled with `__LINE__` of each backtraces.
+ */
+int rb_profile_thread_frames(VALUE thread, int start, int limit, VALUE *buff, int *lines);
+
+/**
* Queries the path of the passed backtrace.
*
* @param[in] frame What rb_profile_frames() returned.
@@ -277,7 +297,7 @@ VALUE rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, long index)
#define RB_DEBUG_INSPECTOR_FRAME_DEPTH(dc, index) rb_debug_inspector_frame_depth(dc, index)
/**
- * Return current frmae depth.
+ * Return current frame depth.
*
* @retval The depth of the current frame in Integer.
*/
@@ -459,7 +479,7 @@ RBIMPL_ATTR_RETURNS_NONNULL()
*/
rb_trace_arg_t *rb_tracearg_from_tracepoint(VALUE tpval);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the event of the passed trace.
*
@@ -468,7 +488,7 @@ RBIMPL_ATTR_NONNULL(())
*/
rb_event_flag_t rb_tracearg_event_flag(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Identical to rb_tracearg_event_flag(), except it returns the name of the
* event in Ruby's symbol.
@@ -478,7 +498,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_event(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the line of the point where the trace is at.
*
@@ -488,7 +508,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_lineno(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the file name of the point where the trace is at.
*
@@ -498,7 +518,19 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_path(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
+/**
+ *
+ * Queries the parameters passed on a call or return event.
+ *
+ * @param[in] trace_arg A trace instance
+ * @exception rb_eRuntimeError The tracing event does not support querying parameters.
+ * @return Array of parameters in the format of `Method#parameters`.
+ *
+ */
+VALUE rb_tracearg_parameters(rb_trace_arg_t *trace_arg);
+
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the method name of the point where the trace is at.
*
@@ -508,7 +540,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_method_id(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Identical to rb_tracearg_method_id(), except it returns callee id like
* rb_frame_callee().
@@ -519,7 +551,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_callee_id(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the class that defines the method that the passed trace is at. This
* can be different from the class of rb_tracearg_self()'s return value because
@@ -531,7 +563,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_defined_class(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Creates a binding object of the point where the trace is at.
*
@@ -546,7 +578,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_binding(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the receiver of the point trace is at.
*
@@ -555,7 +587,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_self(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the return value that the trace represents.
*
@@ -565,7 +597,7 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_return_value(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the raised exception that the trace represents.
*
@@ -575,7 +607,33 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg);
-RBIMPL_ATTR_NONNULL(())
+RBIMPL_ATTR_NONNULL((1))
+/**
+ * Queries the compiled source code of the 'script_compiled' event.
+ * If loaded from a file, it will return nil.
+ *
+ * @param[in] trace_arg A trace instance
+ * @exception rb_eRuntimeError The tracing event is not 'script_compiled'.
+ * @retval RUBY_Qnil The script was loaded from a file.
+ * @retval otherwise The compiled source code.
+ *
+ */
+VALUE rb_tracearg_eval_script(rb_trace_arg_t *trace_arg);
+
+RBIMPL_ATTR_NONNULL((1))
+/**
+ *
+ * Queries the compiled instruction sequence on a 'script_compiled' event.
+ * Note that this method is MRI specific.
+ *
+ * @param[in] trace_arg A trace instance
+ * @exception rb_eRuntimeError The tracing event is not 'script_compiled'.
+ * @return The `RubyVM::InstructionSequence` object representing the instruction sequence.
+ *
+ */
+VALUE rb_tracearg_instruction_sequence(rb_trace_arg_t *trace_arg);
+
+RBIMPL_ATTR_NONNULL((1))
/**
* Queries the allocated/deallocated object that the trace represents.
*
@@ -596,49 +654,105 @@ VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg);
/*
* Postponed Job API
- * rb_postponed_job_register and rb_postponed_job_register_one are
- * async-signal-safe and used via SIGPROF by the "stackprof" RubyGem
+ *
+ * This API is designed to be called from contexts where it is not safe to run Ruby
+ * code (e.g. because they do not hold the GVL or because GC is in progress), and
+ * defer a callback to run in a context where it _is_ safe. The primary intended
+ * users of this API is for sampling profilers like the "stackprof" gem; these work
+ * by scheduling the periodic delivery of a SIGPROF signal, and inside the C-level
+ * signal handler, deferring a job to collect a Ruby backtrace when it is next safe
+ * to do so.
+ *
+ * Ruby maintains a small, fixed-size postponed job table. An extension using this
+ * API should first call `rb_postponed_job_preregister` to register a callback
+ * function in this table and obtain a handle of type `rb_postponed_job_handle_t`
+ * to it. Subsequently, the callback can be triggered by calling
+ * `rb_postponed_job_trigger` with that handle, or the `data` associated with the
+ * callback function can be changed by calling `rb_postponed_job_preregister` again.
+ *
+ * Because the postponed job table is quite small (it only has 32 entries on most
+ * common systems), extensions should generally only preregister one or two `func`
+ * values.
+ *
+ * Historically, this API provided two functions `rb_postponed_job_register` and
+ * `rb_postponed_job_register_one`, which claimed to be fully async-signal-safe and
+ * would call back the provided `func` and `data` at an appropriate time. However,
+ * these functions were subject to race conditions which could cause crashes when
+ * racing with Ruby's internal use of them. These two functions are still present,
+ * but are marked as deprecated and have slightly changed semantics:
+ *
+ * * rb_postponed_job_register now works like rb_postponed_job_register_one i.e.
+ * `func` will only be executed at most one time each time Ruby checks for
+ * interrupts, no matter how many times it is registered
+ * * They are also called with the last `data` to be registered, not the first
+ * (which is how rb_postponed_job_register_one previously worked)
*/
+
/**
* Type of postponed jobs.
*
- * @param[in,out] arg What was passed to rb_postponed_job_register().
+ * @param[in,out] arg What was passed to `rb_postponed_job_preregister`
*/
typedef void (*rb_postponed_job_func_t)(void *arg);
/**
- * Registers a postponed job.
+ * The type of a handle returned from `rb_postponed_job_preregister` and
+ * passed to `rb_postponed_job_trigger`
+ */
+typedef unsigned int rb_postponed_job_handle_t;
+#define POSTPONED_JOB_HANDLE_INVALID ((rb_postponed_job_handle_t)UINT_MAX)
+
+/**
+ * Pre-registers a func in Ruby's postponed job preregistration table,
+ * returning an opaque handle which can be used to trigger the job later. Generally,
+ * this function will be called during the initialization routine of an extension.
+ *
+ * The returned handle can be used later to call `rb_postponed_job_trigger`. This will
+ * cause Ruby to call back into the registered `func` with `data` at a later time, in
+ * a context where the GVL is held and it is safe to perform Ruby allocations.
*
- * There are situations when running a ruby program is not possible. For
- * instance when a program is in a signal handler; for another instance when
- * the GC is busy. On such situations however, there might be needs to do
- * something. We cannot but defer such operations until we are 100% sure it is
- * safe to execute them. This mechanism is called postponed jobs. This
- * function registers a new one. The registered job would eventually gets
- * executed.
+ * If the given `func` was already pre-registered, this function will overwrite the
+ * stored data with the newly passed data, and return the same handle instance as
+ * was previously returned.
*
- * @param[in] flags (Unused) reserved for future extensions.
- * @param[in] func Job body.
- * @param[in,out] data Passed as-is to `func`.
- * @retval 0 Postponed job buffer is full. Failed.
- * @retval otherwise Opaque return value.
- * @post The passed job is postponed.
+ * If this function is called concurrently with the same `func`, then the stored data
+ * could be the value from either call (but will definitely be one of them).
+ *
+ * If this function is called to update the data concurrently with a call to
+ * `rb_postponed_job_trigger` on the same handle, it's undefined whether `func` will
+ * be called with the old data or the new data.
+ *
+ * Although the current implementation of this function is in fact async-signal-safe and
+ * has defined semantics when called concurrently on the same `func`, a future Ruby
+ * version might require that this method be called under the GVL; thus, programs which
+ * aim to be forward-compatible should call this method whilst holding the GVL.
+ *
+ * @param[in] flags Unused and ignored
+ * @param[in] func The function to be pre-registered
+ * @param[in] data The data to be pre-registered
+ * @retval POSTPONED_JOB_HANDLE_INVALID The job table is full; this registration
+ * did not succeed and no further registration will do so for
+ * the lifetime of the program.
+ * @retval otherwise A handle which can be passed to `rb_postponed_job_trigger`
*/
-int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data);
+rb_postponed_job_handle_t rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, void *data);
/**
- * Identical to rb_postponed_job_register_one(), except it additionally checks
- * for duplicated registration. In case the passed job is already in the
- * postponed job buffer this function does nothing.
+ * Triggers a pre-registered job registered with rb_postponed_job_preregister,
+ * scheduling it for execution the next time the Ruby VM checks for interrupts.
+ * The context in which the job is called in holds the GVL and is safe to perform
+ * Ruby allocations within (i.e. it is not during GC).
+ *
+ * This method is async-signal-safe and can be called from any thread, at any
+ * time, including in signal handlers.
+ *
+ * If this method is called multiple times, Ruby will coalesce this into only
+ * one call to the job the next time it checks for interrupts.
*
- * @param[in] flags (Unused) reserved for future extensions.
- * @param[in] func Job body.
- * @param[in,out] data Passed as-is to `func`.
- * @retval 0 Postponed job buffer is full. Failed.
- * @retval otherwise Opaque return value.
+ * @params[in] h A handle returned from rb_postponed_job_preregister
*/
-int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data);
+void rb_postponed_job_trigger(rb_postponed_job_handle_t h);
/** @} */
diff --git a/include/ruby/fiber/scheduler.h b/include/ruby/fiber/scheduler.h
index 250b39b6df..4d764f68ae 100644
--- a/include/ruby/fiber/scheduler.h
+++ b/include/ruby/fiber/scheduler.h
@@ -23,9 +23,11 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
-#define RUBY_FIBER_SCHEDULER_VERSION 2
+// Version 3: Adds support for `fiber_interrupt`.
+#define RUBY_FIBER_SCHEDULER_VERSION 3
struct timeval;
+struct rb_thread_struct;
/**
* Wrap a `ssize_t` and `int errno` into a single `VALUE`. This interface should
@@ -97,7 +99,7 @@ VALUE rb_fiber_scheduler_get(void);
* current thread will call scheduler's `#close` method on finalisation
* (allowing the scheduler to properly manage all non-finished fibers).
* `scheduler` can be an object of any class corresponding to
- * `Fiber::SchedulerInterface`. Its implementation is up to the user.
+ * `Fiber::Scheduler` interface. Its implementation is up to the user.
*
* @param[in] scheduler The scheduler to set.
* @exception rb_eArgError `scheduler` does not conform the interface.
@@ -117,7 +119,7 @@ VALUE rb_fiber_scheduler_current(void);
/**
* Identical to rb_fiber_scheduler_current(), except it queries for that of the
- * passed thread instead of the implicit current one.
+ * passed thread value instead of the implicit current one.
*
* @param[in] thread Target thread.
* @exception rb_eTypeError `thread` is not a thread.
@@ -127,6 +129,17 @@ VALUE rb_fiber_scheduler_current(void);
VALUE rb_fiber_scheduler_current_for_thread(VALUE thread);
/**
+ * Identical to rb_fiber_scheduler_current_for_thread(), except it expects
+ * a threadptr instead of a thread value.
+ *
+ * @param[in] thread Target thread.
+ * @exception rb_eTypeError `thread` is not a thread.
+ * @retval RUBY_Qnil No scheduler is in effect in `thread`.
+ * @retval otherwise The scheduler that is in effect in `thread`.
+ */
+VALUE rb_fiber_scheduler_current_for_threadptr(struct rb_thread_struct *thread);
+
+/**
* Converts the passed timeout to an expression that rb_fiber_scheduler_block()
* etc. expects.
*
@@ -166,6 +179,14 @@ VALUE rb_fiber_scheduler_kernel_sleep(VALUE scheduler, VALUE duration);
*/
VALUE rb_fiber_scheduler_kernel_sleepv(VALUE scheduler, int argc, VALUE * argv);
+/**
+ * Yield to the scheduler, to be resumed on the next scheduling cycle.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @return What `scheduler.yield` returns.
+ */
+VALUE rb_fiber_scheduler_yield(VALUE scheduler);
+
/* Description TBW */
#if 0
VALUE rb_fiber_scheduler_timeout_after(VALUE scheduler, VALUE timeout, VALUE exception, VALUE message);
@@ -199,6 +220,8 @@ VALUE rb_fiber_scheduler_block(VALUE scheduler, VALUE blocker, VALUE timeout);
/**
* Wakes up a fiber previously blocked using rb_fiber_scheduler_block().
*
+ * This function may be called from a different thread.
+ *
* @param[in] scheduler Target scheduler.
* @param[in] blocker What was awaited for.
* @param[in] fiber What to unblock.
@@ -267,10 +290,10 @@ VALUE rb_fiber_scheduler_io_selectv(VALUE scheduler, int argc, VALUE *argv);
* Non-blocking read from the passed IO.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[out] buffer Return buffer.
- * @param[in] length Requested number of bytes to read.
- * @param[in] offset The offset in the buffer to read to.
+ * @param[in] io An io object to read from.
+ * @param[in] buffer The buffer to read to.
+ * @param[in] length The minimum number of bytes to read.
+ * @param[in] offset The offset in the buffer to read from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns `[-errno, size]`.
*/
@@ -280,9 +303,9 @@ VALUE rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t
* Non-blocking write to the passed IO.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] buffer What to write.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] buffer The buffer to write from.
+ * @param[in] length The minimum number of bytes to write.
* @param[in] offset The offset in the buffer to write from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns `[-errno, size]`.
@@ -293,10 +316,10 @@ VALUE rb_fiber_scheduler_io_write(VALUE scheduler, VALUE io, VALUE buffer, size_
* Non-blocking read from the passed IO at the specified offset.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[in] from The offset in the given IO to read the data from.
- * @param[out] buffer The buffer to read the data to.
- * @param[in] length Requested number of bytes to read.
+ * @param[in] io An io object to read from.
+ * @param[in] from The offset to read from.
+ * @param[in] buffer The buffer to read to.
+ * @param[in] length The minimum number of bytes to read.
* @param[in] offset The offset in the buffer to read to.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns.
@@ -307,10 +330,10 @@ VALUE rb_fiber_scheduler_io_pread(VALUE scheduler, VALUE io, rb_off_t from, VALU
* Non-blocking write to the passed IO at the specified offset.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] from The offset in the given IO to write the data to.
- * @param[in] buffer The buffer to write the data from.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] from The offset to write to.
+ * @param[in] buffer The buffer to write from.
+ * @param[in] length The minimum number of bytes to write.
* @param[in] offset The offset in the buffer to write from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns.
@@ -321,27 +344,55 @@ VALUE rb_fiber_scheduler_io_pwrite(VALUE scheduler, VALUE io, rb_off_t from, VAL
* Non-blocking read from the passed IO using a native buffer.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[out] buffer Return buffer.
- * @param[in] size Size of the return buffer.
- * @param[in] length Requested number of bytes to read.
+ * @param[in] io An io object to read from.
+ * @param[in] base The memory to read to.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to read.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns.
*/
-VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *buffer, size_t size, size_t length);
+VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *base, size_t size, size_t length);
/**
* Non-blocking write to the passed IO using a native buffer.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] buffer What to write.
- * @param[in] size Size of the buffer.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] base The memory to write from.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to write.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
+ * @return otherwise What `scheduler.io_write` returns.
+ */
+VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *base, size_t size, size_t length);
+
+/**
+ * Non-blocking pread from the passed IO using a native buffer.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] io An io object to read from.
+ * @param[in] from The offset to read from.
+ * @param[in] base The memory to read to.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to read.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
+ * @return otherwise What `scheduler.io_read` returns.
+ */
+VALUE rb_fiber_scheduler_io_pread_memory(VALUE scheduler, VALUE io, rb_off_t from, void *base, size_t size, size_t length);
+
+/**
+ * Non-blocking pwrite to the passed IO using a native buffer.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] io An io object to write to.
+ * @param[in] from The offset to write from.
+ * @param[in] base The memory to write from.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to write.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns.
*/
-VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *buffer, size_t size, size_t length);
+VALUE rb_fiber_scheduler_io_pwrite_memory(VALUE scheduler, VALUE io, rb_off_t from, const void *base, size_t size, size_t length);
/**
* Non-blocking close the given IO.
@@ -363,9 +414,89 @@ VALUE rb_fiber_scheduler_io_close(VALUE scheduler, VALUE io);
*/
VALUE rb_fiber_scheduler_address_resolve(VALUE scheduler, VALUE hostname);
+// The state of the blocking operation execution.
+struct rb_fiber_scheduler_blocking_operation_state {
+ void *result;
+ int saved_errno;
+};
+
+// The opaque handle for the blocking operation.
+typedef struct rb_fiber_scheduler_blocking_operation rb_fiber_scheduler_blocking_operation_t;
+
+/**
+ * Extract the blocking operation handle from a BlockingOperationRuby object.
+ *
+ * This function safely extracts the opaque handle from a BlockingOperation VALUE
+ * while holding the GVL. The returned pointer can be passed to worker threads
+ * and used with rb_fiber_scheduler_blocking_operation_execute.
+ *
+ * @param[in] self The BlockingOperation VALUE to extract from
+ * @return The opaque struct pointer on success, NULL on error
+ * @note Experimental.
+ */
+rb_fiber_scheduler_blocking_operation_t *rb_fiber_scheduler_blocking_operation_extract(VALUE self);
+
+/**
+ * Execute blocking operation from handle (GVL not required).
+ *
+ * This function executes a blocking operation using the opaque handle
+ * obtained from rb_fiber_scheduler_blocking_operation_extract.
+ * It can be called from native threads without holding the GVL.
+ *
+ * @param[in] blocking_operation The opaque handle.
+ * @return 0 on success, -1 on error.
+ * @note Experimental. Can be called from any thread without holding the GVL
+ */
+int rb_fiber_scheduler_blocking_operation_execute(rb_fiber_scheduler_blocking_operation_t *blocking_operation);
+
+/**
+ * Cancel a blocking operation.
+ *
+ * This function cancels a blocking operation. If the operation is queued,
+ * it just marks it as cancelled. If it's executing, it marks it as cancelled
+ * and calls the unblock function to interrupt the operation.
+ *
+ * @param blocking_operation The opaque struct pointer
+ * @return 1 if unblock function was called, 0 if just marked cancelled, -1 on error
+ * @note Experimental.
+ */
+int rb_fiber_scheduler_blocking_operation_cancel(rb_fiber_scheduler_blocking_operation_t *blocking_operation);
+
+/**
+ * Defer the execution of the passed function to the scheduler.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] function The function to run.
+ * @param[in] data The data to pass to the function.
+ * @param[in] unblock_function The unblock function to use to interrupt the operation.
+ * @param[in] data2 The data to pass to the unblock function.
+ * @param[in] flags Flags passed to `rb_nogvl`.
+ * @param[out] state The result and errno of the operation.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#blocking_operation_wait`.
+ * @return otherwise What `scheduler.blocking_operation_wait` returns.
+ */
+VALUE rb_fiber_scheduler_blocking_operation_wait(VALUE scheduler, void* (*function)(void *), void *data, rb_unblock_function_t *unblock_function, void *data2, int flags, struct rb_fiber_scheduler_blocking_operation_state *state);
+
+/**
+ * Interrupt a fiber by raising an exception. You can construct an exception using `rb_make_exception`.
+ *
+ * This hook may be invoked by a different thread.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] fiber The fiber to interrupt.
+ * @param[in] exception The exception to raise in the fiber.
+ * @return What `scheduler.fiber_interrupt` returns.
+ */
+VALUE rb_fiber_scheduler_fiber_interrupt(VALUE scheduler, VALUE fiber, VALUE exception);
+
/**
* Create and schedule a non-blocking fiber.
*
+ * @param[in] scheduler Target scheduler.
+ * @param[in] argc Number of arguments in argv.
+ * @param[in] argv Array of arguments to pass to the fiber.
+ * @param[in] kw_splat Whether to expand last argument as keywords.
+ * @return The created and scheduled fiber.
*/
VALUE rb_fiber_scheduler_fiber(VALUE scheduler, int argc, VALUE *argv, int kw_splat);
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 48e4cd546e..8718169ce2 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -51,6 +51,7 @@
#include "ruby/internal/intern/re.h"
#include "ruby/internal/intern/ruby.h"
#include "ruby/internal/intern/select.h"
+#include "ruby/internal/intern/set.h"
#include "ruby/internal/intern/signal.h"
#include "ruby/internal/intern/sprintf.h"
#include "ruby/internal/intern/string.h"
diff --git a/include/ruby/internal/abi.h b/include/ruby/internal/abi.h
index 8e1bbf3951..7ceb8c40b7 100644
--- a/include/ruby/internal/abi.h
+++ b/include/ruby/internal/abi.h
@@ -24,7 +24,7 @@
* In released versions of Ruby, this number is not defined since teeny
* versions of Ruby should guarantee ABI compatibility.
*/
-#define RUBY_ABI_VERSION 0
+#define RUBY_ABI_VERSION 3
/* Windows does not support weak symbols so ruby_abi_version will not exist
* in the shared library. */
@@ -33,7 +33,7 @@
#endif
#endif /* RUBY_ABI_VERSION */
-#ifdef RUBY_DLN_CHECK_ABI
+#if defined(RUBY_DLN_CHECK_ABI) && !defined(RUBY_EXPORT)
# ifdef __cplusplus
extern "C" {
diff --git a/include/ruby/internal/anyargs.h b/include/ruby/internal/anyargs.h
index e3e1b6166d..e4c6d155cc 100644
--- a/include/ruby/internal/anyargs.h
+++ b/include/ruby/internal/anyargs.h
@@ -84,12 +84,15 @@
#elif defined(_WIN32) || defined(__CYGWIN__)
# /* Skip due to [Bug #16134] */
+# define RBIMPL_CAST_FN_PTR 1
#elif ! RBIMPL_HAS_ATTRIBUTE(transparent_union)
# /* :TODO: improve here, please find a way to support. */
+# define RBIMPL_CAST_FN_PTR 1
#elif ! defined(HAVE_VA_ARGS_MACRO)
# /* :TODO: improve here, please find a way to support. */
+# define RBIMPL_CAST_FN_PTR 1
#else
# /** @cond INTERNAL_MACRO */
@@ -348,6 +351,25 @@ RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
#endif /* __cplusplus */
+#if defined(RBIMPL_CAST_FN_PTR) && !defined(__cplusplus)
+/* In C23, K&R style prototypes are gone and so `void foo(ANYARGS)` became
+ * equivalent to `void foo(void)` unlike in earlier versions. This is a problem
+ * for rb_define_* functions since that makes all valid functions one can pass
+ * trip -Wincompatible-pointer-types, which we treat as errors. This is mostly
+ * not a problem for the __builtin_choose_expr path, but outside of that we
+ * need to add a cast for compatibility.
+ */
+#define rb_define_method(klass, mid, func, arity) rb_define_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_method_id(klass, mid, func, arity) rb_define_method_id((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_singleton_method(obj, mid, func, arity) rb_define_singleton_method((obj), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_protected_method(klass, mid, func, arity) rb_define_protected_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_private_method(klass, mid, func, arity) rb_define_private_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_module_function(mod, mid, func, arity) rb_define_module_function((mod), (mid), (VALUE (*)(ANYARGS))(func), (arity))
+#define rb_define_global_function(mid, func, arity) rb_define_global_function((mid), (VALUE (*)(ANYARGS))(func), (arity))
+
+#undef RBIMPL_CAST_FN_PTR
+#endif /* defined(RBIMPL_CAST_FN_PTR) && !defined(__cplusplus) */
+
/**
* This macro is to properly cast a function parameter of *_define_method
* family. It has been around since 1.x era so you can maximise backwards
diff --git a/include/ruby/internal/arithmetic/int.h b/include/ruby/internal/arithmetic/int.h
index 6bd8ec2184..7b24d16887 100644
--- a/include/ruby/internal/arithmetic/int.h
+++ b/include/ruby/internal/arithmetic/int.h
@@ -254,7 +254,7 @@ static inline VALUE
rb_uint2num_inline(unsigned int v)
{
if (RB_POSFIXABLE(v))
- return RB_LONG2FIX(v);
+ return RB_LONG2FIX(RBIMPL_CAST((long)v));
else
return rb_uint2big(v);
}
diff --git a/include/ruby/internal/arithmetic/intptr_t.h b/include/ruby/internal/arithmetic/intptr_t.h
index a354f4469c..70090f88e6 100644
--- a/include/ruby/internal/arithmetic/intptr_t.h
+++ b/include/ruby/internal/arithmetic/intptr_t.h
@@ -32,6 +32,18 @@
#define rb_int_new rb_int2inum /**< @alias{rb_int2inum} */
#define rb_uint_new rb_uint2inum /**< @alias{rb_uint2inum} */
+// These definitions are same as fiddle/conversions.h
+#if SIZEOF_VOIDP <= SIZEOF_LONG
+# define PTR2NUM(x) (LONG2NUM((long)(x)))
+# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
+#elif SIZEOF_VOIDP <= SIZEOF_LONG_LONG
+# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x)))
+# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
+#else
+// should have been an error in ruby/internal/value.h
+# error Need integer for VALUE
+#endif
+
RBIMPL_SYMBOL_EXPORT_BEGIN()
/**
diff --git a/include/ruby/internal/arithmetic/long.h b/include/ruby/internal/arithmetic/long.h
index 6b8fd8ffc3..6c00dbceb7 100644
--- a/include/ruby/internal/arithmetic/long.h
+++ b/include/ruby/internal/arithmetic/long.h
@@ -114,11 +114,11 @@ RB_INT2FIX(long i)
/* :NOTE: VALUE can be wider than long. As j being unsigned, 2j+1 is fully
* defined. Also it can be compiled into a single LEA instruction. */
- const unsigned long j = i;
+ const unsigned long j = RBIMPL_CAST((unsigned long)i);
const unsigned long k = (j << 1) + RUBY_FIXNUM_FLAG;
- const long l = k;
+ const long l = RBIMPL_CAST((long)k);
const SIGNED_VALUE m = l; /* Sign extend */
- const VALUE n = m;
+ const VALUE n = RBIMPL_CAST((VALUE)m);
RBIMPL_ASSERT_OR_ASSUME(RB_FIXNUM_P(n));
return n;
@@ -166,7 +166,7 @@ rbimpl_fix2long_by_idiv(VALUE x)
/* :NOTE: VALUE can be wider than long. (x-1)/2 never overflows because
* RB_FIXNUM_P(x) holds. Also it has no portability issue like y>>1
* below. */
- const SIGNED_VALUE y = x - RUBY_FIXNUM_FLAG;
+ const SIGNED_VALUE y = RBIMPL_CAST((SIGNED_VALUE)(x - RUBY_FIXNUM_FLAG));
const SIGNED_VALUE z = y / 2;
const long w = RBIMPL_CAST((long)z);
@@ -193,7 +193,7 @@ rbimpl_fix2long_by_shift(VALUE x)
/* :NOTE: VALUE can be wider than long. If right shift is arithmetic, this
* is noticeably faster than above. */
- const SIGNED_VALUE y = x;
+ const SIGNED_VALUE y = RBIMPL_CAST((SIGNED_VALUE)x);
const SIGNED_VALUE z = y >> 1;
const long w = RBIMPL_CAST((long)z);
@@ -252,7 +252,7 @@ static inline unsigned long
rb_fix2ulong(VALUE x)
{
RBIMPL_ASSERT_OR_ASSUME(RB_FIXNUM_P(x));
- return rb_fix2long(x);
+ return RBIMPL_CAST((unsigned long)rb_fix2long(x));
}
/**
@@ -323,7 +323,7 @@ static inline VALUE
rb_ulong2num_inline(unsigned long v)
{
if (RB_POSFIXABLE(v))
- return RB_LONG2FIX(v);
+ return RB_LONG2FIX(RBIMPL_CAST((long)v));
else
return rb_uint2big(v);
}
diff --git a/include/ruby/internal/arithmetic/long_long.h b/include/ruby/internal/arithmetic/long_long.h
index 65dec8729d..aab455c830 100644
--- a/include/ruby/internal/arithmetic/long_long.h
+++ b/include/ruby/internal/arithmetic/long_long.h
@@ -127,7 +127,7 @@ static inline unsigned LONG_LONG
rb_num2ull_inline(VALUE x)
{
if (RB_FIXNUM_P(x))
- return RB_FIX2LONG(x);
+ return RBIMPL_CAST((unsigned LONG_LONG)RB_FIX2LONG(x));
else
return rb_num2ull(x);
}
diff --git a/include/ruby/internal/arithmetic/st_data_t.h b/include/ruby/internal/arithmetic/st_data_t.h
index 3bff4ffc0b..91776b3fce 100644
--- a/include/ruby/internal/arithmetic/st_data_t.h
+++ b/include/ruby/internal/arithmetic/st_data_t.h
@@ -58,7 +58,7 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline VALUE
RB_ST2FIX(st_data_t i)
{
- SIGNED_VALUE x = i;
+ SIGNED_VALUE x = RBIMPL_CAST((SIGNED_VALUE)i);
if (x >= 0) {
x &= RUBY_FIXNUM_MAX;
@@ -69,7 +69,7 @@ RB_ST2FIX(st_data_t i)
RBIMPL_ASSERT_OR_ASSUME(RB_FIXABLE(x));
unsigned long y = RBIMPL_CAST((unsigned long)x);
- return RB_LONG2FIX(y);
+ return RB_LONG2FIX(RBIMPL_CAST((long)y));
}
#endif /* RBIMPL_ARITHMETIC_ST_DATA_T_H */
diff --git a/include/ruby/internal/attr/deprecated.h b/include/ruby/internal/attr/deprecated.h
index e1bbdbd15a..a374ace868 100644
--- a/include/ruby/internal/attr/deprecated.h
+++ b/include/ruby/internal/attr/deprecated.h
@@ -48,7 +48,7 @@
#elif RBIMPL_HAS_ATTRIBUTE(deprecated) /* but not with message. */
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__))
-#elif RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0)
+#elif RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_ATTR_DEPRECATED(msg) __declspec(deprecated msg)
#elif RBIMPL_HAS_DECLSPEC_ATTRIBUTE(deprecated)
@@ -72,4 +72,11 @@
# define RBIMPL_ATTR_DEPRECATED_EXT(msg) RBIMPL_ATTR_DEPRECATED(msg)
#endif
+#define RBIMPL_ATTR_DEPRECATED_SINCE(ver) \
+ RBIMPL_ATTR_DEPRECATED(("since " #ver))
+#define RBIMPL_ATTR_DEPRECATED_INTERNAL(ver) \
+ RBIMPL_ATTR_DEPRECATED(("since "#ver", also internal"))
+#define RBIMPL_ATTR_DEPRECATED_INTERNAL_ONLY() \
+ RBIMPL_ATTR_DEPRECATED(("only for internal use"))
+
#endif /* RBIMPL_ATTR_DEPRECATED_H */
diff --git a/include/ruby/internal/attr/forceinline.h b/include/ruby/internal/attr/forceinline.h
index b7daafede7..5b9ae794af 100644
--- a/include/ruby/internal/attr/forceinline.h
+++ b/include/ruby/internal/attr/forceinline.h
@@ -29,7 +29,7 @@
* `__forceinline` are mutually exclusive. We have to mimic that behaviour for
* non-MSVC compilers.
*/
-#if RBIMPL_COMPILER_SINCE(MSVC, 12, 0, 0)
+#if RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_ATTR_FORCEINLINE() __forceinline
#elif RBIMPL_HAS_ATTRIBUTE(always_inline)
# define RBIMPL_ATTR_FORCEINLINE() __attribute__((__always_inline__)) inline
diff --git a/include/ruby/internal/attr/format.h b/include/ruby/internal/attr/format.h
index b3488ee00a..7feff1c846 100644
--- a/include/ruby/internal/attr/format.h
+++ b/include/ruby/internal/attr/format.h
@@ -22,6 +22,10 @@
*/
#include "ruby/internal/has/attribute.h"
+#if defined(__MINGW32__)
+#include <stdio.h> /* for __MINGW_PRINTF_FORMAT */
+#endif
+
/** Wraps (or simulates) `__attribute__((format))` */
#if RBIMPL_HAS_ATTRIBUTE(format)
# define RBIMPL_ATTR_FORMAT(x, y, z) __attribute__((__format__(x, y, z)))
diff --git a/include/ruby/internal/attr/noexcept.h b/include/ruby/internal/attr/noexcept.h
index ea3001df2a..dd4c667407 100644
--- a/include/ruby/internal/attr/noexcept.h
+++ b/include/ruby/internal/attr/noexcept.h
@@ -54,7 +54,7 @@
* get smarter and smarter. Today they can infer if it actually throws
* or not without any annotations by humans (correct me if I'm wrong).
*
- * - When an inline function attributed `noexcepr` actually _does_ throw an
+ * - When an inline function attributed `noexcept` actually _does_ throw an
* exception: they have to call `std::terminate` then (C++ standard
* mandates so). This means exception handling routines are actually
* enforced, not omitted. This doesn't impact runtime performance (The
@@ -78,7 +78,7 @@
#elif defined(__INTEL_CXX11_MODE__)
# define RBIMPL_ATTR_NOEXCEPT(_) noexcept(noexcept(_))
-#elif RBIMPL_COMPILER_SINCE(MSVC, 19, 0, 0)
+#elif RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_ATTR_NOEXCEPT(_) noexcept(noexcept(_))
#elif __cplusplus >= 201103L
diff --git a/include/ruby/internal/attr/nonstring.h b/include/ruby/internal/attr/nonstring.h
new file mode 100644
index 0000000000..da2501f7bf
--- /dev/null
+++ b/include/ruby/internal/attr/nonstring.h
@@ -0,0 +1,40 @@
+#ifndef RBIMPL_ATTR_NONSTRING_H /*-*-C++-*-vi:se ft=cpp:*/
+#define RBIMPL_ATTR_NONSTRING_H
+/**
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RBIMPL_ATTR_NONSTRING.
+ */
+#include "ruby/internal/has/attribute.h"
+
+/** Wraps (or simulates) `__attribute__((nonstring))` */
+#if RBIMPL_HAS_ATTRIBUTE(nonstring)
+# define RBIMPL_ATTR_NONSTRING() __attribute__((nonstring))
+# if RBIMPL_COMPILER_SINCE(GCC, 15, 0, 0)
+# define RBIMPL_ATTR_NONSTRING_ARRAY() RBIMPL_ATTR_NONSTRING()
+# elif defined(__clang_major__) && __clang_major__ >= 21
+# define RBIMPL_ATTR_NONSTRING_ARRAY() RBIMPL_ATTR_NONSTRING()
+# else
+# define RBIMPL_ATTR_NONSTRING_ARRAY() /* void */
+# endif
+#else
+# define RBIMPL_ATTR_NONSTRING() /* void */
+# define RBIMPL_ATTR_NONSTRING_ARRAY() /* void */
+#endif
+
+#endif /* RBIMPL_ATTR_NONSTRING_H */
diff --git a/include/ruby/internal/attr/restrict.h b/include/ruby/internal/attr/restrict.h
index e39104138c..b12fdc9dbc 100644
--- a/include/ruby/internal/attr/restrict.h
+++ b/include/ruby/internal/attr/restrict.h
@@ -28,7 +28,7 @@
* `__has_declspec_attribute()` which involves macro substitution. */
/** Wraps (or simulates) `__declspec(restrict)` */
-#if RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0)
+#if RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_ATTR_RESTRICT() __declspec(re ## strict)
#elif RBIMPL_HAS_ATTRIBUTE(malloc)
diff --git a/include/ruby/internal/compiler_is/msvc.h b/include/ruby/internal/compiler_is/msvc.h
index 8a864ea558..824f0ecc21 100644
--- a/include/ruby/internal/compiler_is/msvc.h
+++ b/include/ruby/internal/compiler_is/msvc.h
@@ -38,19 +38,8 @@
# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_FULL_VER % 10000000 / 100000)
# define RBIMPL_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 100000)
-#elif defined(_MSC_FULL_VER)
-# define RBIMPL_COMPILER_IS_MSVC 1
-# /* _MSC_FULL_VER = XXYYZZZZ */
-# define RBIMPL_COMPILER_VERSION_MAJOR (_MSC_FULL_VER / 1000000)
-# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_FULL_VER % 1000000 / 10000)
-# define RBIMPL_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 10000)
-
#else
-# define RBIMPL_COMPILER_IS_MSVC 1
-# /* _MSC_VER = XXYY */
-# define RBIMPL_COMPILER_VERSION_MAJOR (_MSC_VER / 100)
-# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_VER % 100)
-# define RBIMPL_COMPILER_VERSION_PATCH 0
+# error Unsupported MSVC version
#endif
#endif /* RBIMPL_COMPILER_IS_MSVC_H */
diff --git a/include/ruby/internal/config.h b/include/ruby/internal/config.h
index aa63376d7c..34862ded6e 100644
--- a/include/ruby/internal/config.h
+++ b/include/ruby/internal/config.h
@@ -50,7 +50,7 @@
# define HAVE_VA_ARGS_MACRO
# elif defined(__INTEL_CXX11_MODE__)
# define HAVE_VA_ARGS_MACRO
-# elif RBIMPL_COMPILER_SINCE(MSVC, 16, 0, 0)
+# elif RBIMPL_COMPILER_IS(MSVC)
# define HAVE_VA_ARGS_MACRO
# else
# /* NG, not known. */
@@ -148,8 +148,4 @@
# undef RBIMPL_TEST3
#endif /* HAVE_VA_ARGS_MACRO */
-#ifndef USE_RVARGC
-# define USE_RVARGC 1
-#endif
-
#endif /* RBIMPL_CONFIG_H */
diff --git a/include/ruby/internal/core/rarray.h b/include/ruby/internal/core/rarray.h
index 8fc3062f1b..b47b63d51b 100644
--- a/include/ruby/internal/core/rarray.h
+++ b/include/ruby/internal/core/rarray.h
@@ -36,18 +36,6 @@
#include "ruby/assert.h"
/**
- * @private
- * @warning Do not touch this macro.
- * @warning It is an implementation detail.
- * @warning The value of this macro must match for ruby itself and all
- * extension libraries, otherwise serious memory corruption shall
- * occur.
- */
-#ifndef USE_TRANSIENT_HEAP
-# define USE_TRANSIENT_HEAP 1
-#endif
-
-/**
* Convenient casting macro.
*
* @param obj An object, which is in fact an ::RArray.
@@ -59,15 +47,9 @@
#define RARRAY_EMBED_LEN_MASK RARRAY_EMBED_LEN_MASK
#define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
-#if USE_TRANSIENT_HEAP
-# define RARRAY_TRANSIENT_FLAG RARRAY_TRANSIENT_FLAG
-#else
-# define RARRAY_TRANSIENT_FLAG 0
-#endif
/** @endcond */
#define RARRAY_LEN rb_array_len /**< @alias{rb_array_len} */
#define RARRAY_CONST_PTR rb_array_const_ptr /**< @alias{rb_array_const_ptr} */
-#define RARRAY_CONST_PTR_TRANSIENT rb_array_const_ptr_transient /**< @alias{rb_array_const_ptr_transient} */
/** @cond INTERNAL_MACRO */
#if defined(__fcc__) || defined(__fcc_version) || \
@@ -80,7 +62,6 @@
#define RARRAY_EMBED_LEN RARRAY_EMBED_LEN
#define RARRAY_LENINT RARRAY_LENINT
-#define RARRAY_TRANSIENT_P RARRAY_TRANSIENT_P
#define RARRAY_ASET RARRAY_ASET
#define RARRAY_PTR RARRAY_PTR
/** @endcond */
@@ -99,6 +80,8 @@
* here is at least incomplete.
*/
enum ruby_rarray_flags {
+ /* RUBY_FL_USER0 is for ELTS_SHARED */
+
/**
* This flag has something to do with memory footprint. If the array is
* "small" enough, ruby tries to be creative to abuse padding bits of
@@ -118,8 +101,6 @@ enum ruby_rarray_flags {
*/
RARRAY_EMBED_FLAG = RUBY_FL_USER1,
- /* RUBY_FL_USER2 is for ELTS_SHARED */
-
/**
* When an array employs embedded strategy (see ::RARRAY_EMBED_FLAG), these
* bits are used to store the number of elements actually filled into
@@ -130,30 +111,8 @@ enum ruby_rarray_flags {
* 3rd parties must not be aware that there even is more than one way to
* store array elements. It was a bad idea to expose this to them.
*/
-#if USE_RVARGC
RARRAY_EMBED_LEN_MASK = RUBY_FL_USER9 | RUBY_FL_USER8 | RUBY_FL_USER7 | RUBY_FL_USER6 |
RUBY_FL_USER5 | RUBY_FL_USER4 | RUBY_FL_USER3
-#else
- RARRAY_EMBED_LEN_MASK = RUBY_FL_USER4 | RUBY_FL_USER3
-#endif
-
-#if USE_TRANSIENT_HEAP
- ,
-
- /**
- * This flag has something to do with an array's "transiency". A transient
- * array is an array of young generation (of generational GC), who stores
- * its elements inside of dedicated memory pages called a transient heap.
- * Not every young generation share that storage scheme, but elder
- * generations must no join.
- *
- * @internal
- *
- * 3rd parties must not be aware that there even is more than one way to
- * store array elements. It was a bad idea to expose this to them.
- */
- RARRAY_TRANSIENT_FLAG = RUBY_FL_USER13
-#endif
};
/**
@@ -163,13 +122,6 @@ enum ruby_rarray_flags {
enum ruby_rarray_consts {
/** Where ::RARRAY_EMBED_LEN_MASK resides. */
RARRAY_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 3
-
-#if !USE_RVARGC
- ,
-
- /** Max possible number elements that can be embedded. */
- RARRAY_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE)
-#endif
};
/** Ruby's array. */
@@ -228,16 +180,12 @@ struct RArray {
* to store its elements. In this case the length is encoded into the
* flags.
*/
-#if USE_RVARGC
/* This is a length 1 array because:
* 1. GCC has a bug that does not optimize C flexible array members
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
* 2. Zero length arrays are not supported by all compilers
*/
const VALUE ary[1];
-#else
- const VALUE ary[RARRAY_EMBED_LEN_MAX];
-#endif
} as;
};
@@ -264,16 +212,6 @@ VALUE *rb_ary_ptr_use_start(VALUE ary);
*/
void rb_ary_ptr_use_end(VALUE a);
-#if USE_TRANSIENT_HEAP
-/**
- * Destructively converts an array of transient backend into ordinal one.
- *
- * @param[out] a An object of ::RArray.
- * @pre `a` must be a transient array.
- * @post `a` gets out of transient heap, destructively.
- */
-void rb_ary_detransient(VALUE a);
-#endif
RBIMPL_SYMBOL_EXPORT_END()
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
@@ -346,33 +284,6 @@ RARRAY_LENINT(VALUE ary)
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * Queries if the array is a transient array.
- *
- * @param[in] ary Array in question.
- * @retval true Yes it is.
- * @retval false No it isn't.
- * @pre `ary` must be an instance of ::RArray.
- *
- * @internal
- *
- * @shyouhei doesn't understand the benefit of this function called from
- * extension libraries.
- */
-static inline bool
-RARRAY_TRANSIENT_P(VALUE ary)
-{
- RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- return RB_FL_ANY_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
/**
* @private
*
@@ -383,7 +294,7 @@ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
* @return Its backend storage.
*/
static inline const VALUE *
-rb_array_const_ptr_transient(VALUE a)
+rb_array_const_ptr(VALUE a)
{
RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
@@ -395,102 +306,21 @@ rb_array_const_ptr_transient(VALUE a)
}
}
-#if ! USE_TRANSIENT_HEAP
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-#endif
-/**
- * @private
- *
- * This is an implementation detail of RARRAY_PTR(). People do not use it
- * directly.
- *
- * @param[in] a An object of ::RArray.
- * @return Its backend storage.
- * @post `a` is not a transient array.
- */
-static inline const VALUE *
-rb_array_const_ptr(VALUE a)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- if (RARRAY_TRANSIENT_P(a)) {
- rb_ary_detransient(a);
- }
-#endif
- return rb_array_const_ptr_transient(a);
-}
-
/**
* @private
*
* This is an implementation detail of #RARRAY_PTR_USE. People do not use it
* directly.
- *
- * @param[in] a An object of ::RArray.
- * @param[in] allow_transient Whether `a` can be transient or not.
- * @return Its backend storage.
- * @post `a` is not a transient array unless `allow_transient`.
*/
-static inline VALUE *
-rb_array_ptr_use_start(VALUE a,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int allow_transient)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- if (!allow_transient) {
- if (RARRAY_TRANSIENT_P(a)) {
- rb_ary_detransient(a);
- }
- }
-#endif
-
- return rb_ary_ptr_use_start(a);
-}
-
-/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- *
- * @param[in] a An object of ::RArray.
- * @param[in] allow_transient Whether `a` can be transient or not.
- */
-static inline void
-rb_array_ptr_use_end(VALUE a,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int allow_transient)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
- rb_ary_ptr_use_end(a);
-}
-
-/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- */
-#define RBIMPL_RARRAY_STMT(flag, ary, var, expr) do { \
+#define RBIMPL_RARRAY_STMT(ary, var, expr) do { \
RBIMPL_ASSERT_TYPE((ary), RUBY_T_ARRAY); \
const VALUE rbimpl_ary = (ary); \
- VALUE *var = rb_array_ptr_use_start(rbimpl_ary, (flag)); \
+ VALUE *var = rb_ary_ptr_use_start(rbimpl_ary); \
expr; \
- rb_array_ptr_use_end(rbimpl_ary, (flag)); \
+ rb_ary_ptr_use_end(rbimpl_ary); \
} while (0)
/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- */
-#define RARRAY_PTR_USE_END(a) rb_array_ptr_use_end(a, 0)
-
-/**
* Declares a section of code where raw pointers are used. In case you need to
* touch the raw C array instead of polite CAPIs, then that operation shall be
* wrapped using this macro.
@@ -516,21 +346,11 @@ rb_array_ptr_use_end(VALUE a,
* them use it... Maybe some transition path can be implemented later.
*/
#define RARRAY_PTR_USE(ary, ptr_name, expr) \
- RBIMPL_RARRAY_STMT(0, ary, ptr_name, expr)
-
-/**
- * Identical to #RARRAY_PTR_USE, except the pointer can be a transient one.
- *
- * @param ary An object of ::RArray.
- * @param ptr_name A variable name which points the C array in `expr`.
- * @param expr The expression that touches `ptr_name`.
- */
-#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) \
- RBIMPL_RARRAY_STMT(1, ary, ptr_name, expr)
+ RBIMPL_RARRAY_STMT(ary, ptr_name, expr)
/**
* Wild use of a C pointer. This function accesses the backend storage
- * directly. This is slower than #RARRAY_PTR_USE_TRANSIENT. It exercises
+ * directly. This is slower than #RARRAY_PTR_USE. It exercises
* extra manoeuvres to protect our generational GC. Use of this function is
* considered archaic. Use a modern way instead.
*
@@ -547,7 +367,7 @@ RARRAY_PTR(VALUE ary)
{
RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
- VALUE tmp = RB_OBJ_WB_UNPROTECT_FOR(ARRAY, ary);
+ VALUE tmp = RB_OBJ_WB_UNPROTECT(ary);
return RBIMPL_CAST((VALUE *)RARRAY_CONST_PTR(tmp));
}
@@ -565,7 +385,7 @@ RARRAY_PTR(VALUE ary)
static inline void
RARRAY_ASET(VALUE ary, long i, VALUE v)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
RB_OBJ_WRITE(ary, &ptr[i], v));
}
@@ -580,6 +400,6 @@ RARRAY_ASET(VALUE ary, long i, VALUE v)
* remains as it is due to that. If we could warn such usages we can set a
* transition path, but currently no way is found to do so.
*/
-#define RARRAY_AREF(a, i) RARRAY_CONST_PTR_TRANSIENT(a)[i]
+#define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
#endif /* RBIMPL_RARRAY_H */
diff --git a/include/ruby/internal/core/rbasic.h b/include/ruby/internal/core/rbasic.h
index 4617f743a7..63cdff8e09 100644
--- a/include/ruby/internal/core/rbasic.h
+++ b/include/ruby/internal/core/rbasic.h
@@ -55,23 +55,27 @@ enum ruby_rvalue_flags {
RVALUE_EMBED_LEN_MAX = RBIMPL_RVALUE_EMBED_LEN_MAX
};
+#if (SIZEOF_VALUE < SIZEOF_UINT64_T)
+#define RBASIC_SHAPE_ID_FIELD 1
+#else
+#define RBASIC_SHAPE_ID_FIELD 0
+#endif
+
/**
- * Ruby's object's, base components. Every single ruby objects have them in
- * common.
+ * Ruby object's base components. All Ruby objects have them in common.
*/
struct
RUBY_ALIGNAS(SIZEOF_VALUE)
RBasic {
/**
- * Per-object flags. Each ruby objects have their own characteristics
- * apart from their classes. For instance whether an object is frozen or
- * not is not controlled by its class. This is where such properties are
- * stored.
+ * Per-object flags. Each Ruby object has its own characteristics apart
+ * from its class. For instance, whether an object is frozen or not is not
+ * controlled by its class. This is where such properties are stored.
*
* @see enum ::ruby_fl_type
*
- * @note This is ::VALUE rather than an enum for alignment purpose. Back
+ * @note This is ::VALUE rather than an enum for alignment purposes. Back
* in the 1990s there were no such thing like `_Alignas` in C.
*/
VALUE flags;
@@ -79,14 +83,18 @@ RBasic {
/**
* Class of an object. Every object has its class. Also, everything is an
* object in Ruby. This means classes are also objects. Classes have
- * their own classes, classes of classes have their classes, too ... and
- * it recursively continues forever.
+ * their own classes, classes of classes have their classes too, and it
+ * recursively continues forever.
*
- * Also note the `const` qualifier. In ruby an object cannot "change" its
+ * Also note the `const` qualifier. In Ruby, an object cannot "change" its
* class.
*/
const VALUE klass;
+#if RBASIC_SHAPE_ID_FIELD
+ VALUE shape_id;
+#endif
+
#ifdef __cplusplus
public:
RBIMPL_ATTR_CONSTEXPR(CXX11)
@@ -102,8 +110,14 @@ RBasic {
RBasic() :
flags(RBIMPL_VALUE_NULL),
klass(RBIMPL_VALUE_NULL)
+#if RBASIC_SHAPE_ID_FIELD
+ , shape_id(RBIMPL_VALUE_NULL)
+#endif
{
}
+# define RBASIC_INIT RBasic()
+#else
+# define RBASIC_INIT {RBIMPL_VALUE_NULL}
#endif
};
diff --git a/include/ruby/internal/core/rclass.h b/include/ruby/internal/core/rclass.h
index b0b6bfc80c..6f78cc569b 100644
--- a/include/ruby/internal/core/rclass.h
+++ b/include/ruby/internal/core/rclass.h
@@ -58,7 +58,7 @@ enum ruby_rmodule_flags {
* rb_mod_refine() has this flag set. This is the bit which controls
* difference between normal inclusion versus refinements.
*/
- RMODULE_IS_REFINEMENT = RUBY_FL_USER3
+ RMODULE_IS_REFINEMENT = RUBY_FL_USER1
};
struct RClass; /* Opaque, declared here for RCLASS() macro. */
diff --git a/include/ruby/internal/core/rdata.h b/include/ruby/internal/core/rdata.h
index 43ab3c01e7..d0a4dc7c83 100644
--- a/include/ruby/internal/core/rdata.h
+++ b/include/ruby/internal/core/rdata.h
@@ -37,40 +37,14 @@
#include "ruby/defines.h"
/** @cond INTERNAL_MACRO */
-#ifdef RUBY_UNTYPED_DATA_WARNING
-# /* Take that. */
-#elif defined(RUBY_EXPORT)
-# define RUBY_UNTYPED_DATA_WARNING 1
-#else
-# define RUBY_UNTYPED_DATA_WARNING 0
+#ifndef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 1
#endif
#define RBIMPL_DATA_FUNC(f) RBIMPL_CAST((void (*)(void *))(f))
-#define RBIMPL_ATTRSET_UNTYPED_DATA_FUNC() \
- RBIMPL_ATTR_WARNING(("untyped Data is unsafe; use TypedData instead")) \
- RBIMPL_ATTR_DEPRECATED(("by TypedData"))
-
-#define RBIMPL_MACRO_SELECT(x, y) x ## y
-#define RUBY_MACRO_SELECT(x, y) RBIMPL_MACRO_SELECT(x, y)
/** @endcond */
/**
- * Convenient casting macro.
- *
- * @param obj An object, which is in fact an ::RData.
- * @return The passed object casted to ::RData.
- */
-#define RDATA(obj) RBIMPL_CAST((struct RData *)(obj))
-
-/**
- * Convenient getter macro.
- *
- * @param obj An object, which is in fact an ::RData.
- * @return The passed object's ::RData::data field.
- */
-#define DATA_PTR(obj) RDATA(obj)->data
-
-/**
* This is a value you can set to ::RData::dfree. Setting this means the data
* was allocated using ::ruby_xmalloc() (or variants), and shall be freed using
* ::ruby_xfree().
@@ -89,19 +63,6 @@
#define RUBY_NEVER_FREE RBIMPL_DATA_FUNC(0)
/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- */
-#define RUBY_UNTYPED_DATA_FUNC(f) f RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()
-
-/*
-#define RUBY_DATA_FUNC(func) ((void (*)(void*))(func))
-*/
-
-/**
* This is the type of callbacks registered to ::RData. The argument is the
* `data` field.
*/
@@ -110,277 +71,16 @@ typedef void (*RUBY_DATA_FUNC)(void*);
/**
* @deprecated
*
- * Old "untyped" user data. It has roughly the same usage as struct
- * ::RTypedData, but lacked several features such as support for compaction GC.
- * Use of this struct is not recommended any longer. If it is dead necessary,
- * please inform the core devs about your usage.
- *
- * @internal
- *
- * @shyouhei tried to add RBIMPL_ATTR_DEPRECATED for this type but that yielded
- * too many warnings in the core. Maybe we want to retry later... Just add
- * deprecated document for now.
+ * DO NOT USE: Obsolete "untyped" user data, that is remained only for
+ * the backward compatibility for some wrapper generator gems.
*/
struct RData {
-
- /** Basic part, including flags and class. */
struct RBasic basic;
-
- /**
- * This function is called when the object is experiencing GC marks. If it
- * contains references to other Ruby objects, you need to mark them also.
- * Otherwise GC will smash your data.
- *
- * @see rb_gc_mark()
- * @warning This is called during GC runs. Object allocations are
- * impossible at that moment (that is why GC runs).
- */
+ VALUE fields_obj;
+ VALUE _reserved;
+ void *data;
RUBY_DATA_FUNC dmark;
-
- /**
- * This function is called when the object is no longer used. You need to
- * do whatever necessary to avoid memory leaks.
- *
- * @warning This is called during GC runs. Object allocations are
- * impossible at that moment (that is why GC runs).
- */
RUBY_DATA_FUNC dfree;
-
- /** Pointer to the actual C level struct that you want to wrap. */
- void *data;
};
-RBIMPL_SYMBOL_EXPORT_BEGIN()
-
-/**
- * This is the primitive way to wrap an existing C struct into ::RData.
- *
- * @param[in] klass Ruby level class of the returning object.
- * @param[in] datap Pointer to the target C struct.
- * @param[in] dmark Mark function.
- * @param[in] dfree Free function.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return An allocated object that wraps `datap`.
- */
-VALUE rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree);
-
-/**
- * Identical to rb_data_object_wrap(), except it allocates a new data region
- * internally instead of taking an existing one. The allocation is done using
- * ruby_calloc(). Hence it makes no sense to pass anything other than
- * ::RUBY_DEFAULT_FREE to the last argument.
- *
- * @param[in] klass Ruby level class of the returning object.
- * @param[in] size Requested size of memory to allocate.
- * @param[in] dmark Mark function.
- * @param[in] dfree Free function.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return An allocated object that wraps a new `size` byte region.
- */
-VALUE rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree);
-
-/**
- * @private
- * Documented in include/ruby/internal/globals.h
- */
-RUBY_EXTERN VALUE rb_cObject;
-RBIMPL_SYMBOL_EXPORT_END()
-
-/**
- * Converts sval, a pointer to your struct, into a Ruby object.
- *
- * @param klass A ruby level class.
- * @param mark Mark function.
- * @param free Free function.
- * @param sval A pointer to your struct.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return A created Ruby object.
- */
-#define Data_Wrap_Struct(klass, mark, free, sval) \
- rb_data_object_wrap( \
- (klass), \
- (sval), \
- RBIMPL_DATA_FUNC(mark), \
- RBIMPL_DATA_FUNC(free))
-
-/**
- * @private
- *
- * This is an implementation detail of #Data_Make_Struct. People don't use it
- * directly.
- *
- * @param result Variable name of created Ruby object.
- * @param klass Ruby level class of the object.
- * @param type Type name of the C struct.
- * @param size Size of the C struct.
- * @param mark Mark function.
- * @param free Free function.
- * @param sval Variable name of created C struct.
- */
-#define Data_Make_Struct0(result, klass, type, size, mark, free, sval) \
- VALUE result = rb_data_object_zalloc( \
- (klass), \
- (size), \
- RBIMPL_DATA_FUNC(mark), \
- RBIMPL_DATA_FUNC(free)); \
- (sval) = RBIMPL_CAST((type *)DATA_PTR(result)); \
- RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
-
-/**
- * Identical to #Data_Wrap_Struct, except it allocates a new data region
- * internally instead of taking an existing one. The allocation is done using
- * ruby_calloc(). Hence it makes no sense to pass anything other than
- * ::RUBY_DEFAULT_FREE to the `free` argument.
- *
- * @param klass Ruby level class of the returning object.
- * @param type Type name of the C struct.
- * @param mark Mark function.
- * @param free Free function.
- * @param sval Variable name of created C struct.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return A created Ruby object.
- */
-#ifdef HAVE_STMT_AND_DECL_IN_EXPR
-#define Data_Make_Struct(klass, type, mark, free, sval) \
- RB_GNUC_EXTENSION({ \
- Data_Make_Struct0( \
- data_struct_obj, \
- klass, \
- type, \
- sizeof(type), \
- mark, \
- free, \
- sval); \
- data_struct_obj; \
- })
-#else
-#define Data_Make_Struct(klass, type, mark, free, sval) \
- rb_data_object_make( \
- (klass), \
- RBIMPL_DATA_FUNC(mark), \
- RBIMPL_DATA_FUNC(free), \
- RBIMPL_CAST((void **)&(sval)), \
- sizeof(type))
-#endif
-
-/**
- * Obtains a C struct from inside of a wrapper Ruby object.
- *
- * @param obj An instance of ::RData.
- * @param type Type name of the C struct.
- * @param sval Variable name of obtained C struct.
- * @return Unwrapped C struct that `obj` holds.
- */
-#define Data_Get_Struct(obj, type, sval) \
- ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj)))
-
-RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()
-/**
- * @private
- *
- * This is an implementation detail of rb_data_object_wrap(). People don't use
- * it directly.
- *
- * @param[in] klass Ruby level class of the returning object.
- * @param[in] ptr Pointer to the target C struct.
- * @param[in] mark Mark function.
- * @param[in] free Free function.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return An allocated object that wraps `datap`.
- */
-static inline VALUE
-rb_data_object_wrap_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DATA_FUNC free)
-{
- return rb_data_object_wrap(klass, ptr, mark, free);
-}
-
-/**
- * @private
- *
- * This is an implementation detail of #Data_Get_Struct. People don't use it
- * directly.
- *
- * @param[in] obj An instance of ::RData.
- * @return Unwrapped C struct that `obj` holds.
- */
-static inline void *
-rb_data_object_get(VALUE obj)
-{
- Check_Type(obj, RUBY_T_DATA);
- return DATA_PTR(obj);
-}
-
-RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()
-/**
- * @private
- *
- * This is an implementation detail of #Data_Get_Struct. People don't use it
- * directly.
- *
- * @param[in] obj An instance of ::RData.
- * @return Unwrapped C struct that `obj` holds.
- */
-static inline void *
-rb_data_object_get_warning(VALUE obj)
-{
- return rb_data_object_get(obj);
-}
-
-#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
-# define rb_data_object_wrap_warning(klass, ptr, mark, free) \
- RB_GNUC_EXTENSION( \
- __builtin_choose_expr( \
- __builtin_constant_p(klass) && !(klass), \
- rb_data_object_wrap(klass, ptr, mark, free), \
- (rb_data_object_wrap_warning)(klass, ptr, mark, free)))
-#endif
-
-/**
- * This is an implementation detail of #Data_Make_Struct. People don't use it
- * directly.
- *
- * @param[in] klass Ruby level class of the returning object.
- * @param[in] mark_func Mark function.
- * @param[in] free_func Free function.
- * @param[in] datap Variable of created C struct.
- * @param[in] size Requested size of allocation.
- * @exception rb_eTypeError `klass` is not a class.
- * @exception rb_eNoMemError Out of memory.
- * @return A created Ruby object.
- * @post `*datap` holds the created C struct.
- */
-static inline VALUE
-rb_data_object_make(VALUE klass, RUBY_DATA_FUNC mark_func, RUBY_DATA_FUNC free_func, void **datap, size_t size)
-{
- Data_Make_Struct0(result, klass, void, size, mark_func, free_func, *datap);
- return result;
-}
-
-RBIMPL_ATTR_DEPRECATED(("by: rb_data_object_wrap"))
-/** @deprecated This function was renamed to rb_data_object_wrap(). */
-static inline VALUE
-rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
-{
- return rb_data_object_wrap(klass, data, dmark, dfree);
-}
-
-/** @cond INTERNAL_MACRO */
-#define rb_data_object_wrap_0 rb_data_object_wrap
-#define rb_data_object_wrap_1 rb_data_object_wrap_warning
-#define rb_data_object_wrap_2 rb_data_object_wrap_ /* Used here vvvv */
-#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_2, RUBY_UNTYPED_DATA_WARNING)
-#define rb_data_object_get_0 rb_data_object_get
-#define rb_data_object_get_1 rb_data_object_get_warning
-#define rb_data_object_get_2 rb_data_object_get_ /* Used here vvvv */
-#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_2, RUBY_UNTYPED_DATA_WARNING)
-#define rb_data_object_make_0 rb_data_object_make
-#define rb_data_object_make_1 rb_data_object_make_warning
-#define rb_data_object_make_2 rb_data_object_make_ /* Used here vvvv */
-#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_2, RUBY_UNTYPED_DATA_WARNING)
-/** @endcond */
#endif /* RBIMPL_RDATA_H */
diff --git a/include/ruby/internal/core/rfile.h b/include/ruby/internal/core/rfile.h
index f8dddde9e5..a0eb8cb833 100644
--- a/include/ruby/internal/core/rfile.h
+++ b/include/ruby/internal/core/rfile.h
@@ -25,7 +25,7 @@
/* rb_io_t is in ruby/io.h. The header file has historically not been included
* into ruby/ruby.h. We follow that tradition. */
-struct rb_io_t;
+struct rb_io;
/**
* Ruby's File and IO. Ruby's IO are not just file descriptors. They have
@@ -38,7 +38,7 @@ struct RFile {
struct RBasic basic;
/** IO's specific fields. */
- struct rb_io_t *fptr;
+ struct rb_io *fptr;
};
/**
diff --git a/include/ruby/internal/core/rmatch.h b/include/ruby/internal/core/rmatch.h
index 2d2fd897f5..ae93755531 100644
--- a/include/ruby/internal/core/rmatch.h
+++ b/include/ruby/internal/core/rmatch.h
@@ -67,21 +67,6 @@ struct rmatch_offset {
long end; /**< End of a group. */
};
-/** Represents a match. */
-struct rmatch {
- /**
- * "Registers" of a match. This is a quasi-opaque struct that holds
- * execution result of a match. Roughly resembles `&~`.
- */
- struct re_registers regs;
-
- /** Capture group offsets, in C array. */
- struct rmatch_offset *char_offset;
-
- /** Number of ::rmatch_offset that ::rmatch::char_offset holds. */
- int char_offset_num_allocated;
-};
-
/**
* Regular expression execution context. When a regular expression "matches"
* to a string, it generates capture groups etc. This struct holds that info.
@@ -102,18 +87,44 @@ struct RMatch {
VALUE str;
/**
- * The result of this match.
+ * The expression of this match.
*/
- struct rmatch *rmatch;
+ VALUE regexp; /* RRegexp */
+
+ /** Number of ::rmatch_offset that ::rmatch::char_offset holds. */
+ int char_offset_num_allocated;
+
+ /** Capture group offsets, in C array. */
+ struct rmatch_offset *char_offset;
+
+ /** Number of capture-group registers. */
+ int num_regs;
+
+ /** Capacity of `as.embed`, in OnigPosition slots. */
+ int capa;
/**
- * The expression of this match.
+ * "Registers" of a match. This is a quasi-opaque struct that holds
+ * execution result of a match. Roughly resembles `$~`.
*/
- VALUE regexp; /* RRegexp */
+ union {
+ OnigPosition embed[1];
+ struct re_registers onig;
+ } as;
};
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_SYMBOL_EXPORT_BEGIN()
+/**
+ * @private
+ *
+ * Converts an embedded match to onig form. This is an implementation
+ * detail of #RMATCH_REGS. People don't use it directly.
+ *
+ * @param[out] match A match object, possibly in embedded form.
+ */
+void rb_match_ensure_onig(VALUE match);
+RBIMPL_SYMBOL_EXPORT_END()
+
/**
* Queries the raw ::re_registers.
*
@@ -139,8 +150,8 @@ static inline struct re_registers *
RMATCH_REGS(VALUE match)
{
RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
- RBIMPL_ASSERT_OR_ASSUME(RMATCH(match)->rmatch != NULL);
- return &RMATCH(match)->rmatch->regs;
+ rb_match_ensure_onig(match);
+ return &RMATCH(match)->as.onig;
}
#endif /* RBIMPL_RMATCH_H */
diff --git a/include/ruby/internal/core/robject.h b/include/ruby/internal/core/robject.h
index b1c2e1b0a9..df1901eb1e 100644
--- a/include/ruby/internal/core/robject.h
+++ b/include/ruby/internal/core/robject.h
@@ -42,10 +42,10 @@
*/
#define ROBJECT(obj) RBIMPL_CAST((struct RObject *)(obj))
/** @cond INTERNAL_MACRO */
-#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
-#define ROBJECT_EMBED ROBJECT_EMBED
-#define ROBJECT_IV_CAPACITY ROBJECT_IV_CAPACITY
-#define ROBJECT_IVPTR ROBJECT_IVPTR
+#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
+#define ROBJECT_HEAP ROBJECT_HEAP
+#define ROBJECT_FIELDS_CAPACITY ROBJECT_FIELDS_CAPACITY
+#define ROBJECT_FIELDS ROBJECT_FIELDS
/** @endcond */
/**
@@ -55,10 +55,12 @@
*/
enum ruby_robject_flags {
/**
- * This flag has something to do with memory footprint. If the object is
- * "small" enough, ruby tries to be creative to abuse padding bits of
- * struct ::RObject for storing instance variables. This flag denotes that
- * situation.
+ * This flag marks that the object's instance variables are stored in an
+ * external heap buffer.
+ * Normally, instance variable references are stored inside the object slot,
+ * but if it overflow, Ruby may have to allocate a separate buffer and spills
+ * the instance variables there.
+ * This flag denotes that situation.
*
* @warning This bit has to be considered read-only. Setting/clearing
* this bit without corresponding fix up must cause immediate
@@ -71,20 +73,9 @@ enum ruby_robject_flags {
* 3rd parties must not be aware that there even is more than one way to
* store instance variables. Might better be hidden.
*/
- ROBJECT_EMBED = RUBY_FL_USER1
+ ROBJECT_HEAP = RUBY_FL_USER4
};
-#if !USE_RVARGC
-/**
- * This is an enum because GDB wants it (rather than a macro). People need not
- * bother.
- */
-enum ruby_robject_consts {
- /** Max possible number of instance variables that can be embedded. */
- ROBJECT_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE)
-};
-#endif
-
struct st_table;
/**
@@ -105,20 +96,14 @@ struct RObject {
*/
struct {
/** Pointer to a C array that holds instance variables. */
- VALUE *ivptr;
-
- /**
- * This is a table that holds instance variable name to index
- * mapping. Used when accessing instance variables using names.
- *
- * @internal
- *
- * This is a shortcut for `RCLASS_IV_INDEX_TBL(rb_obj_class(obj))`.
- */
- struct rb_id_table *iv_index_tbl;
+ VALUE *fields;
} heap;
-#if USE_RVARGC
+ /* When an object is too complex, it uses a st_table to store instance
+ * variable name to value mappings.
+ */
+ st_table *hash;
+
/* Embedded instance variables. When an object is small enough, it
* uses this area to store the instance variables.
*
@@ -128,23 +113,9 @@ struct RObject {
* 2. Zero length arrays are not supported by all compilers
*/
VALUE ary[1];
-#else
- /**
- * Embedded instance variables. When an object is small enough, it
- * uses this area to store the instance variables.
- */
- VALUE ary[ROBJECT_EMBED_LEN_MAX];
-#endif
} as;
};
-/* Offsets for YJIT */
-#ifndef __cplusplus
-static const int32_t ROBJECT_OFFSET_AS_HEAP_IVPTR = offsetof(struct RObject, as.heap.ivptr);
-static const int32_t ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL = offsetof(struct RObject, as.heap.iv_index_tbl);
-static const int32_t ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary);
-#endif
-
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
@@ -159,17 +130,17 @@ RBIMPL_ATTR_ARTIFICIAL()
* @shyouhei finds no reason for this to be visible from extension libraries.
*/
static inline VALUE *
-ROBJECT_IVPTR(VALUE obj)
+ROBJECT_FIELDS(VALUE obj)
{
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
struct RObject *const ptr = ROBJECT(obj);
- if (RB_FL_ANY_RAW(obj, ROBJECT_EMBED)) {
- return ptr->as.ary;
+ if (RB_UNLIKELY(RB_FL_ANY_RAW(obj, ROBJECT_HEAP))) {
+ return ptr->as.heap.fields;
}
else {
- return ptr->as.heap.ivptr;
+ return ptr->as.ary;
}
}
diff --git a/include/ruby/internal/core/rstring.h b/include/ruby/internal/core/rstring.h
index e394ab7dca..35175ea94a 100644
--- a/include/ruby/internal/core/rstring.h
+++ b/include/ruby/internal/core/rstring.h
@@ -42,13 +42,7 @@
/** @cond INTERNAL_MACRO */
#define RSTRING_NOEMBED RSTRING_NOEMBED
-#if !USE_RVARGC
-#define RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK
-#define RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT
-#define RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX
-#endif
#define RSTRING_FSTR RSTRING_FSTR
-#define RSTRING_EMBED_LEN RSTRING_EMBED_LEN
#define RSTRING_LEN RSTRING_LEN
#define RSTRING_LENINT RSTRING_LENINT
#define RSTRING_PTR RSTRING_PTR
@@ -162,21 +156,6 @@ enum ruby_rstring_flags {
*/
RSTRING_NOEMBED = RUBY_FL_USER1,
-#if !USE_RVARGC
- /**
- * When a string employs embedded strategy (see ::RSTRING_NOEMBED), these
- * bits are used to store the number of bytes actually filled into
- * ::RString::ary.
- *
- * @internal
- *
- * 3rd parties must not be aware that there even is more than one way to
- * store a string. Might better be hidden.
- */
- RSTRING_EMBED_LEN_MASK = RUBY_FL_USER2 | RUBY_FL_USER3 | RUBY_FL_USER4 |
- RUBY_FL_USER5 | RUBY_FL_USER6,
-#endif
-
/* Actually, string encodings are also encoded into the flags, using
* remaining bits.*/
@@ -202,20 +181,6 @@ enum ruby_rstring_flags {
RSTRING_FSTR = RUBY_FL_USER17
};
-#if !USE_RVARGC
-/**
- * This is an enum because GDB wants it (rather than a macro). People need not
- * bother.
- */
-enum ruby_rstring_consts {
- /** Where ::RSTRING_EMBED_LEN_MASK resides. */
- RSTRING_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 2,
-
- /** Max possible number of characters that can be embedded. */
- RSTRING_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(char) - 1
-};
-#endif
-
/**
* Ruby's String. A string in ruby conceptually has these information:
*
@@ -233,6 +198,13 @@ struct RString {
/** Basic part, including flags and class. */
struct RBasic basic;
+ /**
+ * Length of the string, not including terminating NUL character.
+ *
+ * @note This is in bytes.
+ */
+ long len;
+
/** String's specific fields. */
union {
@@ -241,14 +213,6 @@ struct RString {
* pattern.
*/
struct {
-
- /**
- * Length of the string, not including terminating NUL character.
- *
- * @note This is in bytes.
- */
- long len;
-
/**
* Pointer to the contents of the string. In the old days each
* string had dedicated memory regions. That is no longer true
@@ -279,24 +243,12 @@ struct RString {
/** Embedded contents. */
struct {
-#if USE_RVARGC
- long len;
/* This is a length 1 array because:
* 1. GCC has a bug that does not optimize C flexible array members
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
* 2. Zero length arrays are not supported by all compilers
*/
char ary[1];
-#else
- /**
- * When a string is short enough, it uses this area to store the
- * contents themselves. This was impractical in the 20th century,
- * but these days 64 bit machines can typically hold 24 bytes here.
- * Could be sufficiently large. In this case the length is encoded
- * into the flags.
- */
- char ary[RSTRING_EMBED_LEN_MAX + 1];
-#endif
} embed;
} as;
};
@@ -409,81 +361,12 @@ RBIMPL_ATTR_ARTIFICIAL()
*
* @param[in] str String in question.
* @return Its length, in bytes.
- * @pre `str` must be an instance of ::RString, and must has its
- * ::RSTRING_NOEMBED flag off.
- *
- * @internal
- *
- * This was a macro before. It was inevitable to be public, since macros are
- * global constructs. But should it be forever? Now that it is a function,
- * @shyouhei thinks it could just be eliminated, hidden into implementation
- * details.
- */
-static inline long
-RSTRING_EMBED_LEN(VALUE str)
-{
- RBIMPL_ASSERT_TYPE(str, RUBY_T_STRING);
- RBIMPL_ASSERT_OR_ASSUME(! RB_FL_ANY_RAW(str, RSTRING_NOEMBED));
-
-#if USE_RVARGC
- long f = RSTRING(str)->as.embed.len;
- return f;
-#else
- VALUE f = RBASIC(str)->flags;
- f &= RSTRING_EMBED_LEN_MASK;
- f >>= RSTRING_EMBED_LEN_SHIFT;
- return RBIMPL_CAST((long)f);
-#endif
-}
-
-RBIMPL_WARNING_PUSH()
-#if RBIMPL_COMPILER_IS(Intel)
-RBIMPL_WARNING_IGNORED(413)
-#endif
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * @private
- *
- * "Expands" an embedded string into an ordinal one. This is a function that
- * returns aggregated type. The returned struct always has its `as.heap.len`
- * an `as.heap.ptr` fields set appropriately.
- *
- * This is an implementation detail that 3rd parties should never bother.
- */
-static inline struct RString
-rbimpl_rstring_getmem(VALUE str)
-{
- RBIMPL_ASSERT_TYPE(str, RUBY_T_STRING);
-
- if (RB_FL_ANY_RAW(str, RSTRING_NOEMBED)) {
- return *RSTRING(str);
- }
- else {
- /* Expecting compilers to optimize this on-stack struct away. */
- struct RString retval;
- retval.as.heap.len = RSTRING_EMBED_LEN(str);
- retval.as.heap.ptr = RSTRING(str)->as.embed.ary;
- return retval;
- }
-}
-
-RBIMPL_WARNING_POP()
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * Queries the length of the string.
- *
- * @param[in] str String in question.
- * @return Its length, in bytes.
* @pre `str` must be an instance of ::RString.
*/
static inline long
RSTRING_LEN(VALUE str)
{
- return rbimpl_rstring_getmem(str).as.heap.len;
+ return RSTRING(str)->len;
}
RBIMPL_ATTR_ARTIFICIAL()
@@ -497,15 +380,13 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline char *
RSTRING_PTR(VALUE str)
{
- char *ptr = rbimpl_rstring_getmem(str).as.heap.ptr;
+ char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
+ RSTRING(str)->as.heap.ptr :
+ RSTRING(str)->as.embed.ary;
- if (RB_UNLIKELY(! ptr)) {
+ if (RUBY_DEBUG && RB_UNLIKELY(! ptr)) {
/* :BEWARE: @shyouhei thinks that currently, there are rooms for this
- * function to return NULL. In the 20th century that was a pointless
- * concern. However struct RString can hold fake strings nowadays. It
- * seems no check against NULL are exercised around handling of them
- * (one of such usages is located in marshal.c, which scares
- * @shyouhei). Better check here for maximum safety.
+ * function to return NULL. Better check here for maximum safety.
*
* Also, this is not rb_warn() because RSTRING_PTR() can be called
* during GC (see what obj_info() does). rb_warn() needs to allocate
@@ -527,14 +408,17 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline char *
RSTRING_END(VALUE str)
{
- struct RString buf = rbimpl_rstring_getmem(str);
+ char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
+ RSTRING(str)->as.heap.ptr :
+ RSTRING(str)->as.embed.ary;
+ long len = RSTRING_LEN(str);
- if (RB_UNLIKELY(! buf.as.heap.ptr)) {
+ if (RUBY_DEBUG && RB_UNLIKELY(!ptr)) {
/* Ditto. */
rb_debug_rstring_null_ptr("RSTRING_END");
}
- return &buf.as.heap.ptr[buf.as.heap.len];
+ return &ptr[len];
}
RBIMPL_ATTR_ARTIFICIAL()
@@ -563,16 +447,7 @@ RSTRING_LENINT(VALUE str)
* @param ptrvar Variable where its contents is stored.
* @param lenvar Variable where its length is stored.
*/
-#ifdef HAVE_STMT_AND_DECL_IN_EXPR
-# define RSTRING_GETMEM(str, ptrvar, lenvar) \
- __extension__ ({ \
- struct RString rbimpl_str = rbimpl_rstring_getmem(str); \
- (ptrvar) = rbimpl_str.as.heap.ptr; \
- (lenvar) = rbimpl_str.as.heap.len; \
- })
-#else
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
((ptrvar) = RSTRING_PTR(str), \
(lenvar) = RSTRING_LEN(str))
-#endif /* HAVE_STMT_AND_DECL_IN_EXPR */
#endif /* RBIMPL_RSTRING_H */
diff --git a/include/ruby/internal/core/rstruct.h b/include/ruby/internal/core/rstruct.h
index 69be487b59..0028a1bdcd 100644
--- a/include/ruby/internal/core/rstruct.h
+++ b/include/ruby/internal/core/rstruct.h
@@ -31,18 +31,6 @@
# include "ruby/backward.h"
#endif
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- *
- * @internal
- *
- * Declaration of rb_struct_ptr() is at include/ruby/backward.h.
- */
-#define RSTRUCT_PTR(st) rb_struct_ptr(st)
/** @cond INTERNAL_MACRO */
#define RSTRUCT_LEN RSTRUCT_LEN
#define RSTRUCT_SET RSTRUCT_SET
diff --git a/include/ruby/internal/core/rtypeddata.h b/include/ruby/internal/core/rtypeddata.h
index bbf208867d..eb8313f180 100644
--- a/include/ruby/internal/core/rtypeddata.h
+++ b/include/ruby/internal/core/rtypeddata.h
@@ -26,6 +26,7 @@
# include <stddef.h>
#endif
+#include "ruby/assert.h"
#include "ruby/internal/assume.h"
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/flag_enum.h"
@@ -37,6 +38,7 @@
#include "ruby/internal/dllexport.h"
#include "ruby/internal/error.h"
#include "ruby/internal/fl_type.h"
+#include "ruby/internal/static_assert.h"
#include "ruby/internal/stdbool.h"
#include "ruby/internal/value_type.h"
@@ -93,13 +95,15 @@
*/
#define RTYPEDDATA(obj) RBIMPL_CAST((struct RTypedData *)(obj))
+static inline VALUE rbimpl_check_external_typeddata(VALUE obj);
+
/**
* Convenient getter macro.
*
* @param v An object, which is in fact an ::RTypedData.
* @return The passed object's ::RTypedData::data field.
*/
-#define RTYPEDDATA_DATA(v) (RTYPEDDATA(v)->data)
+#define RTYPEDDATA_DATA(v) (RTYPEDDATA(rbimpl_check_external_typeddata(v))->data)
/** @old{rb_check_typeddata} */
#define Check_TypedStruct(v, t) \
@@ -108,11 +112,18 @@
/** @cond INTERNAL_MACRO */
#define RTYPEDDATA_P RTYPEDDATA_P
#define RTYPEDDATA_TYPE RTYPEDDATA_TYPE
+#define TYPED_DATA_EMBEDDED ((VALUE)1)
+#define TYPED_DATA_PTR_MASK (~(TYPED_DATA_EMBEDDED))
+/** @endcond */
+
+/**
+ * Macros to see if each corresponding flag is defined.
+ */
#define RUBY_TYPED_FREE_IMMEDIATELY RUBY_TYPED_FREE_IMMEDIATELY
#define RUBY_TYPED_FROZEN_SHAREABLE RUBY_TYPED_FROZEN_SHAREABLE
#define RUBY_TYPED_WB_PROTECTED RUBY_TYPED_WB_PROTECTED
+#define RUBY_TYPED_EMBEDDABLE RUBY_TYPED_EMBEDDABLE
#define RUBY_TYPED_PROMOTED1 RUBY_TYPED_PROMOTED1
-/** @endcond */
/**
* @private
@@ -138,6 +149,22 @@ rbimpl_typeddata_flags {
RUBY_TYPED_FREE_IMMEDIATELY = 1,
/**
+ * This flag indicate to Ruby that the associated C struct may be embedded
+ * inside the object slot, instead of being externally allocated
+ * with +malloc+.
+ *
+ * Embeddable types MUST NOT be accessed using the +DATA_PTR+ macro, only
+ * with +TypedData_Get_Struct+ or +RTYPEDDATA_GET_DATA+.
+ *
+ * Embeddable types MUST NOT free the associated C struct.
+ *
+ * Pointers into the associated C struct MUST NOT be used after the ruby
+ * object is not longer on the stack, as they become invalid when GC
+ * compaction occurs
+ */
+ RUBY_TYPED_EMBEDDABLE = 2,
+
+ /**
* This flag has something to do with Ractor. Multiple Ractors run without
* protecting each other. Sharing an object among Ractors is basically
* dangerous, disabled by default. This flag is used to bypass that
@@ -151,6 +178,12 @@ rbimpl_typeddata_flags {
*/
RUBY_TYPED_FROZEN_SHAREABLE = RUBY_FL_SHAREABLE,
+ // experimental flag
+ // Similar to RUBY_TYPED_FROZEN_SHAREABLE, but doesn't make shareable
+ // reachable objects from this T_DATA object on the Ractor.make_shareable.
+ // If it refers to unshareable objects, simply raise an error.
+ // RUBY_TYPED_FROZEN_SHAREABLE_NO_REC = RUBY_FL_FINALIZE,
+
/**
* This flag has something to do with our garbage collector. These days
* ruby objects are "generational". There are those who are young and
@@ -173,10 +206,11 @@ rbimpl_typeddata_flags {
RUBY_TYPED_WB_PROTECTED = RUBY_FL_WB_PROTECTED, /* THIS FLAG DEPENDS ON Ruby version */
/**
- * This flag is mysterious. It seems nobody is currently using it. The
- * intention of this flag is also unclear. We need further investigations.
+ * This flag determines whether marking and compaction should be carried out
+ * using the dmark/dcompact callback functions or whether we should mark
+ * declaratively using a list of references defined inside the data struct we're wrapping
*/
- RUBY_TYPED_PROMOTED1 = RUBY_FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
+ RUBY_TYPED_DECL_MARKING = RUBY_FL_USER2
};
/**
@@ -241,10 +275,15 @@ struct rb_data_type_struct {
RUBY_DATA_FUNC dcompact;
/**
- * This field is reserved for future extension. For now, it must be
- * filled with zeros.
+ * @internal
*/
- void *reserved[1]; /* For future extension.
+ void (*handle_weak_references)(void *);
+
+ /**
+ * This field is reserved for future extension. For now, it must be
+ * filled with zeros.
+ */
+ void *reserved[7]; /* For future extension.
This array *must* be filled with ZERO. */
} function;
@@ -342,26 +381,45 @@ struct RTypedData {
/** The part that all ruby objects have in common. */
struct RBasic basic;
- /**
- * This field stores various information about how Ruby should handle a
- * data. This roughly resembles a Ruby level class (apart from method
- * definition etc.)
- */
- const rb_data_type_t *type;
+ /** Direct reference to the slots that holds instance variables, if any **/
+ VALUE fields_obj;
/**
- * This has to be always 1.
+ * This is a `const rb_data_type_t *const` value, with the low bits set:
*
- * @internal
+ * 1: Set if object is embedded.
*
- * Why, then, this is not a const ::VALUE?
+ * This field stores various information about how Ruby should handle a
+ * data. This roughly resembles a Ruby level class (apart from method
+ * definition etc.)
*/
- VALUE typed_flag;
+ const VALUE type;
/** Pointer to the actual C level struct that you want to wrap. */
void *data;
};
+#if !defined(__cplusplus) || __cplusplus >= 201103L
+RBIMPL_STATIC_ASSERT(fields_obj_in_rdata, offsetof(struct RData, fields_obj) == offsetof(struct RTypedData, fields_obj));
+RBIMPL_STATIC_ASSERT(data_in_rtypeddata, offsetof(struct RData, data) == offsetof(struct RTypedData, data));
+#endif
+
+/**
+ * Convenient casting macro for backward compatibility.
+ *
+ * @param obj An object, which is in fact an ::RData.
+ * @return The passed object casted to ::RData.
+ */
+#define RDATA(obj) RTYPEDDATA(obj)
+
+/**
+ * Convenient casting macro for backward compatibility.
+ *
+ * @param obj An object, which is in fact an ::RData.
+ * @return The passed object's ::RTypedData::data field.
+ */
+#define DATA_PTR(obj) RTYPEDDATA_DATA(obj)
+
RBIMPL_SYMBOL_EXPORT_BEGIN()
RBIMPL_ATTR_NONNULL((3))
/**
@@ -376,11 +434,11 @@ RBIMPL_ATTR_NONNULL((3))
*/
VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type);
+RBIMPL_ATTR_NONNULL((3))
/**
* Identical to rb_data_typed_object_wrap(), except it allocates a new data
* region internally instead of taking an existing one. The allocation is done
- * using ruby_calloc(). Hence it makes no sense for `type->function.dfree` to
- * be anything other than ::RUBY_TYPED_DEFAULT_FREE.
+ * using ruby_calloc().
*
* @param[in] klass Ruby level class of the returning object.
* @param[in] size Requested size of memory to allocate.
@@ -391,6 +449,7 @@ VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *
*/
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type);
+RBIMPL_ATTR_NONNULL(())
/**
* Checks for the domestic relationship between the two.
*
@@ -405,6 +464,7 @@ VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t
*/
int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
+RBIMPL_ATTR_NONNULL((2))
/**
* Checks if the given object is of given kind.
*
@@ -415,6 +475,7 @@ int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *
*/
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type);
+RBIMPL_ATTR_NONNULL((2))
/**
* Identical to rb_typeddata_is_kind_of(), except it raises exceptions instead
* of returning false.
@@ -426,8 +487,49 @@ int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type);
* @post Upon successful return `obj`'s type is guaranteed `data_type`.
*/
void *rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((2))
+/**
+ * @private
+ *
+ * Fails with the given object's type incompatibility to the type.
+ *
+ * This is an implementation detail of Check_Type. People don't use it
+ * directly.
+ *
+ * @param[in] obj The object in question.
+ * @param[in] expected Name of expected data type of `obj`.
+ */
+void rb_unexpected_object_type(VALUE obj, const char *expected);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL(())
+/**
+ * @private
+ *
+ * Fails with the given object's type incompatibility to the type.
+ *
+ * This is an implementation detail of #TypedData_Make_Struct. People don't
+ * use it directly.
+ *
+ * @param[in] actual Actual data type.
+ * @param[in] expected Expected data type.
+ */
+void rb_unexpected_typeddata(const rb_data_type_t *actual, const rb_data_type_t *expected);
RBIMPL_SYMBOL_EXPORT_END()
+#if RUBY_DEBUG
+# define RBIMPL_TYPEDDATA_PRECONDITION(obj, unreachable) \
+ while (RB_UNLIKELY(!RB_TYPE_P(obj, RUBY_T_DATA))) { \
+ rb_unexpected_object_type(obj, "Data"); \
+ unreachable; \
+ }
+#else
+# define RBIMPL_TYPEDDATA_PRECONDITION(obj, unreachable) \
+ RBIMPL_ASSERT_NOTHING
+#endif
+
/**
* Converts sval, a pointer to your struct, into a Ruby object.
*
@@ -456,14 +558,13 @@ RBIMPL_SYMBOL_EXPORT_END()
*/
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval) \
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
- (sval) = RBIMPL_CAST((type *)RTYPEDDATA_DATA(result)); \
+ (sval) = RBIMPL_CAST((type *)rbimpl_typeddata_get_data(result)); \
RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
/**
* Identical to #TypedData_Wrap_Struct, except it allocates a new data region
* internally instead of taking an existing one. The allocation is done using
- * ruby_calloc(). Hence it makes no sense for `data_type->function.dfree` to
- * be anything other than ::RUBY_TYPED_DEFAULT_FREE.
+ * ruby_calloc().
*
* @param klass Ruby level class of the object.
* @param type Type name of the C struct.
@@ -494,64 +595,78 @@ RBIMPL_SYMBOL_EXPORT_END()
sizeof(type))
#endif
-/**
- * Obtains a C struct from inside of a wrapper Ruby object.
- *
- * @param obj An instance of ::RTypedData.
- * @param type Type name of the C struct.
- * @param data_type The data type describing `type`.
- * @param sval Variable name of obtained C struct.
- * @exception rb_eTypeError `obj` is not a kind of `data_type`.
- * @return Unwrapped C struct that `obj` holds.
- */
-#define TypedData_Get_Struct(obj,type,data_type,sval) \
- ((sval) = RBIMPL_CAST((type *)rb_check_typeddata((obj), (data_type))))
+static inline bool
+rbimpl_typeddata_embedded_p(VALUE obj)
+{
+ return (RTYPEDDATA(obj)->type) & TYPED_DATA_EMBEDDED;
+}
+
+RBIMPL_ATTR_DEPRECATED_INTERNAL_ONLY()
+static inline bool
+RTYPEDDATA_EMBEDDED_P(VALUE obj)
+{
+ RBIMPL_TYPEDDATA_PRECONDITION(obj, RBIMPL_UNREACHABLE_RETURN(false));
+
+ return rbimpl_typeddata_embedded_p(obj);
+}
+
+static inline void *
+rbimpl_typeddata_get_data(VALUE obj)
+{
+ /* We reuse the data pointer in embedded TypedData. */
+ return rbimpl_typeddata_embedded_p(obj) ?
+ RBIMPL_CAST((void *)&RTYPEDDATA(obj)->data) :
+ RTYPEDDATA_DATA(obj);
+}
+
+static inline void *
+RTYPEDDATA_GET_DATA(VALUE obj)
+{
+ RBIMPL_TYPEDDATA_PRECONDITION(obj, RBIMPL_UNREACHABLE_RETURN(NULL));
+
+ return rbimpl_typeddata_get_data(obj);
+}
RBIMPL_ATTR_PURE()
RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implementation detail of Check_Type(). People don't use it
- * directly.
+ * Checks whether the passed object is ::RTypedData.
+ *
+ * This is an implementation detail of inline functions defined in this file.
+ * People don't use it directly.
*
* @param[in] obj Object in question
* @retval true `obj` is an instance of ::RTypedData.
- * @retval false `obj` is an instance of ::RData.
- * @pre `obj` must be a Ruby object of ::RUBY_T_DATA.
+ * @retval false `obj` is not an instance of ::RTypedData
*/
static inline bool
-rbimpl_rtypeddata_p(VALUE obj)
+rbimpl_obj_typeddata_p(VALUE obj)
{
- return RTYPEDDATA(obj)->typed_flag == 1;
+ return RB_TYPE_P(obj, RUBY_T_DATA);
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * Checks whether the passed object is ::RTypedData or ::RData.
+ * Checks whether the passed object is ::RTypedData.
*
* @param[in] obj Object in question
- * @retval true `obj` is an instance of ::RTypedData.
- * @retval false `obj` is an instance of ::RData.
+ * @retval true
* @pre `obj` must be a Ruby object of ::RUBY_T_DATA.
*/
static inline bool
RTYPEDDATA_P(VALUE obj)
{
-#if RUBY_DEBUG
- if (RB_UNLIKELY(! RB_TYPE_P(obj, RUBY_T_DATA))) {
- Check_Type(obj, RUBY_T_DATA);
- RBIMPL_UNREACHABLE_RETURN(false);
- }
-#endif
+ RBIMPL_TYPEDDATA_PRECONDITION(obj, RBIMPL_UNREACHABLE_RETURN(false));
- return rbimpl_rtypeddata_p(obj);
+ return true;
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
-/* :TODO: can this function be __attribute__((returns_nonnull)) or not? */
+RBIMPL_ATTR_RETURNS_NONNULL()
/**
* Queries for the type of given object.
*
@@ -559,19 +674,92 @@ RBIMPL_ATTR_ARTIFICIAL()
* @return Data type struct that corresponds to `obj`.
* @pre `obj` must be an instance of ::RTypedData.
*/
-static inline const struct rb_data_type_struct *
+static inline const rb_data_type_t *
RTYPEDDATA_TYPE(VALUE obj)
{
-#if RUBY_DEBUG
- if (RB_UNLIKELY(! RTYPEDDATA_P(obj))) {
- rb_unexpected_type(obj, RUBY_T_DATA);
- RBIMPL_UNREACHABLE_RETURN(NULL);
+ RBIMPL_TYPEDDATA_PRECONDITION(obj, RBIMPL_UNREACHABLE_RETURN(NULL));
+
+ VALUE type = RTYPEDDATA(obj)->type & TYPED_DATA_PTR_MASK;
+ const rb_data_type_t *ptr = RBIMPL_CAST((const rb_data_type_t *)type);
+ RBIMPL_ASSERT_OR_ASSUME(ptr);
+ return ptr;
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NONNULL(())
+static inline bool
+rbimpl_typeddata_inherited_p_inline(const rb_data_type_t *child, const rb_data_type_t *parent)
+{
+ do {
+ if (RB_LIKELY(child == parent)) return true;
+ } while ((child = child->parent) != NULL);
+ return false;
+}
+#define rb_typeddata_inherited_p rbimpl_typeddata_inherited_p_inline
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NONNULL((2))
+static inline bool
+rbimpl_typeddata_is_kind_of_inline(VALUE obj, const rb_data_type_t *data_type)
+{
+ if (RB_UNLIKELY(!rbimpl_obj_typeddata_p(obj))) return false;
+ return rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type);
+}
+#define rb_typeddata_is_kind_of rbimpl_typeddata_is_kind_of_inline
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NONNULL((2))
+/**
+ * @private
+ *
+ * This is an implementation detail of TypedData_Get_Struct(). Don't use it
+ * directly.
+ */
+static inline void *
+rbimpl_check_typeddata(VALUE obj, const rb_data_type_t *expected_type)
+{
+ if (RB_UNLIKELY(!rbimpl_obj_typeddata_p(obj))) {
+ rb_unexpected_object_type(obj, expected_type->wrap_struct_name);
+ }
+
+ const rb_data_type_t *actual_type = RTYPEDDATA_TYPE(obj);
+ if (RB_UNLIKELY(!rb_typeddata_inherited_p(actual_type, expected_type))){
+ rb_unexpected_typeddata(actual_type, expected_type);
}
-#endif
- return RTYPEDDATA(obj)->type;
+ return RTYPEDDATA_GET_DATA(obj);
}
+RBIMPL_ATTR_PURE_UNLESS_DEBUG()
+RBIMPL_ATTR_ARTIFICIAL()
+/**
+ * @private
+ *
+ * This is an implementation detail of RTYPEDDATA_DATA(). Don't use it
+ * directly.
+ */
+static inline VALUE
+rbimpl_check_external_typeddata(VALUE obj)
+{
+ RBIMPL_TYPEDDATA_PRECONDITION(obj, RBIMPL_UNREACHABLE_RETURN(false));
+ RUBY_ASSERT(!rbimpl_typeddata_embedded_p(obj));
+ return obj;
+}
+
+/**
+ * Obtains a C struct from inside of a wrapper Ruby object.
+ *
+ * @param obj An instance of ::RTypedData.
+ * @param type Type name of the C struct.
+ * @param data_type The data type describing `type`.
+ * @param sval Variable name of obtained C struct.
+ * @exception rb_eTypeError `obj` is not a kind of `data_type`.
+ * @return Unwrapped C struct that `obj` holds.
+ */
+#define TypedData_Get_Struct(obj,type,data_type,sval) \
+ ((sval) = RBIMPL_CAST((type *)rbimpl_check_typeddata((obj), (data_type))))
+
+RBIMPL_ATTR_NONNULL((2))
/**
* While we don't stop you from using this function, it seems to be an
* implementation detail of #TypedData_Make_Struct, which is preferred over
@@ -593,12 +781,4 @@ rb_data_typed_object_make(VALUE klass, const rb_data_type_t *type, void **datap,
return result;
}
-RBIMPL_ATTR_DEPRECATED(("by: rb_data_typed_object_wrap"))
-/** @deprecated This function was renamed to rb_data_typed_object_wrap(). */
-static inline VALUE
-rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
-{
- return rb_data_typed_object_wrap(klass, datap, type);
-}
-
#endif /* RBIMPL_RTYPEDDATA_H */
diff --git a/include/ruby/internal/ctype.h b/include/ruby/internal/ctype.h
index 0f7ca6c516..8b24026311 100644
--- a/include/ruby/internal/ctype.h
+++ b/include/ruby/internal/ctype.h
@@ -498,8 +498,8 @@ RBIMPL_ATTR_ARTIFICIAL()
* Our own locale-insensitive version of `tolower(3)`.
*
* @param[in] c Byte in question to convert.
- * @retval c The byte is not listed in in IEEE 1003.1 section
- * 7.3.1.1 "upper".
+ * @retval c The byte is not listed in IEEE 1003.1 section 7.3.1.1
+ * "upper".
* @retval otherwise Byte converted using the map defined in IEEE 1003.1
* section 7.3.1 "tolower".
* @note Not only does this function works under the POSIX Locale, but
diff --git a/include/ruby/internal/encoding/coderange.h b/include/ruby/internal/encoding/coderange.h
index 7a81208c9e..c89f871518 100644
--- a/include/ruby/internal/encoding/coderange.h
+++ b/include/ruby/internal/encoding/coderange.h
@@ -79,7 +79,7 @@ RBIMPL_ATTR_CONST()
static inline bool
RB_ENC_CODERANGE_CLEAN_P(enum ruby_coderange_type cr)
{
- return rb_enc_coderange_clean_p(cr);
+ return rb_enc_coderange_clean_p(RBIMPL_CAST((int)cr));
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
diff --git a/include/ruby/internal/encoding/encoding.h b/include/ruby/internal/encoding/encoding.h
index dc3e0151f0..a58f9f2b15 100644
--- a/include/ruby/internal/encoding/encoding.h
+++ b/include/ruby/internal/encoding/encoding.h
@@ -28,6 +28,7 @@
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/attr/returns_nonnull.h"
#include "ruby/internal/dllexport.h"
+#include "ruby/internal/encoding/coderange.h"
#include "ruby/internal/value.h"
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/fl_type.h"
@@ -79,7 +80,7 @@ enum ruby_encoding_consts {
static inline void
RB_ENCODING_SET_INLINED(VALUE obj, int encindex)
{
- VALUE f = /* upcast */ encindex;
+ VALUE f = /* upcast */ RBIMPL_CAST((VALUE)encindex);
f <<= RUBY_ENCODING_SHIFT;
RB_FL_UNSET_RAW(obj, RUBY_ENCODING_MASK);
diff --git a/include/ruby/internal/encoding/string.h b/include/ruby/internal/encoding/string.h
index 6ed7ca1c90..ea78cf23f3 100644
--- a/include/ruby/internal/encoding/string.h
+++ b/include/ruby/internal/encoding/string.h
@@ -30,7 +30,7 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
/**
- * Identical to rb_enc_str_new(), except it additionally takes an encoding.
+ * Identical to rb_str_new(), except it additionally takes an encoding.
*
* @param[in] ptr A memory region of `len` bytes length.
* @param[in] len Length of `ptr`, in bytes, not including the
@@ -264,6 +264,14 @@ VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
/**
+ * @private
+ *
+ * This is an implementation detail of rb_enc_str_coderange(). Don't use this
+ * directly.
+ **/
+int rbimpl_enc_str_coderange_scan(VALUE str);
+
+/**
* Scans the passed string to collect its code range. Because a Ruby's string
* is mutable, its contents change from time to time; so does its code range.
* A long-lived string tends to fall back to ::RUBY_ENC_CODERANGE_UNKNOWN.
@@ -275,6 +283,27 @@ VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ec
int rb_enc_str_coderange(VALUE str);
/**
+ * Scans the passed string to collect its code range. Because a Ruby's string
+ * is mutable, its contents change from time to time; so does its code range.
+ * A long-lived string tends to fall back to ::RUBY_ENC_CODERANGE_UNKNOWN.
+ * This API scans it and re-assigns a fine-grained code range constant.
+ *
+ * @param[out] str A string.
+ * @return An enum ::ruby_coderange_type.
+ */
+static inline int
+rb_enc_str_coderange_inline(VALUE str)
+{
+ int cr = ENC_CODERANGE(str);
+ if (cr == ENC_CODERANGE_UNKNOWN) {
+ cr = rbimpl_enc_str_coderange_scan(str);
+ }
+ return cr;
+}
+
+#define rb_enc_str_coderange rb_enc_str_coderange_inline
+
+/**
* Scans the passed string until it finds something odd. Returns the number of
* bytes scanned. As the name implies this is suitable for repeated call. One
* of its application is `IO#readlines`. The method reads from its receiver's
@@ -307,13 +336,13 @@ RBIMPL_ATTR_NONNULL(())
/**
* Looks for the passed string in the passed buffer.
*
- * @param[in] x Buffer that potentially includes `y`.
+ * @param[in] x Query string.
* @param[in] m Number of bytes of `x`.
- * @param[in] y Query string.
+ * @param[in] y Buffer that potentially includes `x`.
* @param[in] n Number of bytes of `y`.
* @param[in] enc Encoding of both `x` and `y`.
* @retval -1 Not found.
- * @retval otherwise Found index in `x`.
+ * @retval otherwise Found index in `y`.
* @note This API can match at a non-character-boundary.
*/
long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc);
diff --git a/include/ruby/internal/error.h b/include/ruby/internal/error.h
index 49e2276cb9..5bf82bfe7d 100644
--- a/include/ruby/internal/error.h
+++ b/include/ruby/internal/error.h
@@ -50,7 +50,23 @@ typedef enum {
/** Warning is for experimental features. */
RB_WARN_CATEGORY_EXPERIMENTAL,
- RB_WARN_CATEGORY_ALL_BITS = 0x6 /* no RB_WARN_CATEGORY_NONE bit */
+ /** Warning is for performance issues (not enabled by -w). */
+ RB_WARN_CATEGORY_PERFORMANCE,
+
+ /** Warning is for checking unused block strictly */
+ RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK,
+
+ RB_WARN_CATEGORY_DEFAULT_BITS = (
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
+ 0),
+
+ RB_WARN_CATEGORY_ALL_BITS = (
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
+ (1U << RB_WARN_CATEGORY_PERFORMANCE) |
+ (1U << RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK) |
+ 0)
} rb_warning_category_t;
/** for rb_readwrite_sys_fail first argument */
@@ -405,11 +421,12 @@ void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int err, const
RBIMPL_ATTR_COLD()
RBIMPL_ATTR_NORETURN()
/**
+ * @private
+ *
* Fails with the given object's type incompatibility to the type.
*
- * It seems this function is visible from extension libraries only because
- * RTYPEDDATA_TYPE() uses it on RUBY_DEBUG. So you can basically ignore it;
- * use some other fine-grained method instead.
+ * This is an implementation detail of Check_Type. People don't use it
+ * directly.
*
* @param[in] self The object in question.
* @param[in] t Expected type of the object.
@@ -469,7 +486,7 @@ VALUE *rb_ruby_debug_ptr(void);
*/
#define ruby_debug (*rb_ruby_debug_ptr())
-/* reports if `-W' specified */
+/* reports if $VERBOSE is true */
RBIMPL_ATTR_NONNULL((1))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
/**
@@ -484,7 +501,8 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
* default, the method just emits its passed contents to ::rb_stderr using
* rb_io_write().
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE, it does
+ * nothing unless $VERBOSE is true.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*
* @internal
@@ -509,7 +527,7 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
* Issues a compile-time warning that happens at `__file__:__line__`. Purpose
* of this function being exposed to CAPI is unclear.
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE.
* @param[in] file The path corresponding to Ruby level `__FILE__`.
* @param[in] line The number corresponding to Ruby level `__LINE__`.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
@@ -522,19 +540,20 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
* Identical to rb_sys_fail(), except it does not raise an exception to render
* a warning instead.
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*/
void rb_sys_warning(const char *fmt, ...);
-/* reports always */
+/* reports if $VERBOSE is not nil (so if it is true or false) */
RBIMPL_ATTR_COLD()
RBIMPL_ATTR_NONNULL((1))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
/**
- * Identical to rb_warning(), except it reports always regardless of runtime
- * `-W` flag.
+ * Identical to rb_warning(), except it reports unless $VERBOSE is nil.
*
+ * @note This function is affected by the value of $VERBOSE, it does
+ * nothing if $VERBOSE is nil.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*/
void rb_warn(const char *fmt, ...);
@@ -543,8 +562,7 @@ RBIMPL_ATTR_COLD()
RBIMPL_ATTR_NONNULL((2))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
/**
- * Identical to rb_category_warning(), except it reports always regardless of
- * runtime `-W` flag.
+ * Identical to rb_category_warning(), except it reports unless $VERBOSE is nil.
*
* @param[in] cat Category e.g. deprecated.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
@@ -554,8 +572,7 @@ void rb_category_warn(rb_warning_category_t cat, const char *fmt, ...);
RBIMPL_ATTR_NONNULL((1, 3))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
/**
- * Identical to rb_compile_warning(), except it reports always regardless of
- * runtime `-W` flag.
+ * Identical to rb_compile_warning(), except it reports unless $VERBOSE is nil.
*
* @param[in] file The path corresponding to Ruby level `__FILE__`.
* @param[in] line The number corresponding to Ruby level `__LINE__`.
diff --git a/include/ruby/internal/eval.h b/include/ruby/internal/eval.h
index 5bcbb97746..23aa1d9580 100644
--- a/include/ruby/internal/eval.h
+++ b/include/ruby/internal/eval.h
@@ -155,7 +155,8 @@ VALUE rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eNoMethodError No such method.
* @exception rb_eException Any exceptions happen inside.
* @return What the method evaluates to.
@@ -189,7 +190,8 @@ VALUE rb_funcallv_public(VALUE recv, ID mid, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eNoMethodError No such method.
* @exception rb_eNoMethodError The method is private or protected.
* @exception rb_eException Any exceptions happen inside.
@@ -261,7 +263,8 @@ VALUE rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eNoMethodError No such method.
* @exception rb_eNoMethodError The method is private or protected.
* @exception rb_eException Any exceptions happen inside.
@@ -307,7 +310,8 @@ VALUE rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VAL
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eNoMethodError No such method.
* @exception rb_eNoMethodError The method is private or protected.
* @exception rb_eException Any exceptions happen inside.
@@ -335,7 +339,8 @@ VALUE rb_call_super(int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eNoMethodError No super method are there.
* @exception rb_eException Any exceptions happen inside.
* @return What the super method evaluates to.
diff --git a/include/ruby/internal/event.h b/include/ruby/internal/event.h
index 04b137a193..1d194ed618 100644
--- a/include/ruby/internal/event.h
+++ b/include/ruby/internal/event.h
@@ -23,6 +23,10 @@
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* These macros are not enums because they are wider than int.*/
/**
@@ -54,6 +58,7 @@
#define RUBY_EVENT_THREAD_END 0x0800 /**< Encountered an end of a thread. */
#define RUBY_EVENT_FIBER_SWITCH 0x1000 /**< Encountered a `Fiber#yield`. */
#define RUBY_EVENT_SCRIPT_COMPILED 0x2000 /**< Encountered an `eval`. */
+#define RUBY_EVENT_RESCUE 0x4000 /**< Encountered a `rescue` statement. */
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff /**< Bitmask of extended events. */
/** @} */
diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h
index 555f23a5a5..f7ec742422 100644
--- a/include/ruby/internal/fl_type.h
+++ b/include/ruby/internal/fl_type.h
@@ -57,13 +57,10 @@
#define FL_SINGLETON RBIMPL_CAST((VALUE)RUBY_FL_SINGLETON) /**< @old{RUBY_FL_SINGLETON} */
#define FL_WB_PROTECTED RBIMPL_CAST((VALUE)RUBY_FL_WB_PROTECTED) /**< @old{RUBY_FL_WB_PROTECTED} */
-#define FL_PROMOTED0 RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED0) /**< @old{RUBY_FL_PROMOTED0} */
-#define FL_PROMOTED1 RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED1) /**< @old{RUBY_FL_PROMOTED1} */
+#define FL_PROMOTED RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED) /**< @old{RUBY_FL_PROMOTED} */
#define FL_FINALIZE RBIMPL_CAST((VALUE)RUBY_FL_FINALIZE) /**< @old{RUBY_FL_FINALIZE} */
-#define FL_TAINT RBIMPL_CAST((VALUE)RUBY_FL_TAINT) /**< @old{RUBY_FL_TAINT} */
#define FL_SHAREABLE RBIMPL_CAST((VALUE)RUBY_FL_SHAREABLE) /**< @old{RUBY_FL_SHAREABLE} */
#define FL_UNTRUSTED RBIMPL_CAST((VALUE)RUBY_FL_UNTRUSTED) /**< @old{RUBY_FL_UNTRUSTED} */
-#define FL_SEEN_OBJ_ID RBIMPL_CAST((VALUE)RUBY_FL_SEEN_OBJ_ID) /**< @old{RUBY_FL_SEEN_OBJ_ID} */
#define FL_EXIVAR RBIMPL_CAST((VALUE)RUBY_FL_EXIVAR) /**< @old{RUBY_FL_EXIVAR} */
#define FL_FREEZE RBIMPL_CAST((VALUE)RUBY_FL_FREEZE) /**< @old{RUBY_FL_FREEZE} */
@@ -111,15 +108,6 @@
#define RB_OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW
#define RB_OBJ_FROZEN RB_OBJ_FROZEN
#define RB_OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW
-#define RB_OBJ_INFECT RB_OBJ_INFECT
-#define RB_OBJ_INFECT_RAW RB_OBJ_INFECT_RAW
-#define RB_OBJ_TAINT RB_OBJ_TAINT
-#define RB_OBJ_TAINTABLE RB_OBJ_TAINTABLE
-#define RB_OBJ_TAINTED RB_OBJ_TAINTED
-#define RB_OBJ_TAINTED_RAW RB_OBJ_TAINTED_RAW
-#define RB_OBJ_TAINT_RAW RB_OBJ_TAINT_RAW
-#define RB_OBJ_UNTRUST RB_OBJ_TAINT
-#define RB_OBJ_UNTRUSTED RB_OBJ_TAINTED
/** @endcond */
/**
@@ -144,15 +132,6 @@
#define OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW /**< @old{RB_OBJ_FREEZE_RAW} */
#define OBJ_FROZEN RB_OBJ_FROZEN /**< @old{RB_OBJ_FROZEN} */
#define OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW /**< @old{RB_OBJ_FROZEN_RAW} */
-#define OBJ_INFECT RB_OBJ_INFECT /**< @old{RB_OBJ_INFECT} */
-#define OBJ_INFECT_RAW RB_OBJ_INFECT_RAW /**< @old{RB_OBJ_INFECT_RAW} */
-#define OBJ_TAINT RB_OBJ_TAINT /**< @old{RB_OBJ_TAINT} */
-#define OBJ_TAINTABLE RB_OBJ_TAINTABLE /**< @old{RB_OBJ_TAINT_RAW} */
-#define OBJ_TAINTED RB_OBJ_TAINTED /**< @old{RB_OBJ_TAINTED} */
-#define OBJ_TAINTED_RAW RB_OBJ_TAINTED_RAW /**< @old{RB_OBJ_TAINTED_RAW} */
-#define OBJ_TAINT_RAW RB_OBJ_TAINT_RAW /**< @old{RB_OBJ_TAINT_RAW} */
-#define OBJ_UNTRUST RB_OBJ_UNTRUST /**< @old{RB_OBJ_TAINT} */
-#define OBJ_UNTRUSTED RB_OBJ_UNTRUSTED /**< @old{RB_OBJ_TAINTED} */
/** @} */
/**
@@ -207,12 +186,15 @@ ruby_fl_type {
RUBY_FL_WB_PROTECTED = (1<<5),
/**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced promotion i.e. survived a garbage collection.
+ * Ruby objects are "generational". There are young objects & old objects.
+ * Young objects are prone to die & monitored relatively extensively by the
+ * garbage collector. Old objects tend to live longer & are monitored less
+ * frequently. When an object survives a GC, its age is incremented. When
+ * age is equal to RVALUE_OLD_AGE, the object becomes Old. This flag is set
+ * when an object becomes old, and is used by the write barrier to check if
+ * an old object should be considered for marking more frequently - as old
+ * objects that have references added between major GCs need to be remarked
+ * to prevent the referred object being mistakenly swept.
*
* @internal
*
@@ -220,41 +202,14 @@ ruby_fl_type {
* 3rd parties. It must be an implementation detail that they should never
* know. Might better be hidden.
*/
- RUBY_FL_PROMOTED0 = (1<<5),
+ RUBY_FL_PROMOTED = (1<<5),
/**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced two promotions i.e. survived garbage collections
- * twice.
+ * This flag is no longer in use
*
* @internal
- *
- * But honestly, @shyouhei doesn't think this flag should be visible from
- * 3rd parties. It must be an implementation detail that they should never
- * know. Might better be hidden.
- */
- RUBY_FL_PROMOTED1 = (1<<6),
-
- /**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced promotions i.e. survived more than one garbage
- * collections.
- *
- * @internal
- *
- * But honestly, @shyouhei doesn't think this flag should be visible from
- * 3rd parties. It must be an implementation detail that they should never
- * know. Might better be hidden.
*/
- RUBY_FL_PROMOTED = RUBY_FL_PROMOTED0 | RUBY_FL_PROMOTED1,
+ RUBY_FL_UNUSED6 = (1<<6),
/**
* This flag has something to do with finalisers. A ruby object can have
@@ -271,19 +226,19 @@ ruby_fl_type {
RUBY_FL_FINALIZE = (1<<7),
/**
- * @deprecated This flag once was a thing back in the old days, but makes
- * no sense any longer today. Exists here for backwards
+ * @deprecated This flag was an implementation detail that should never have
+ * no been exposed. Exists here for backwards
* compatibility only. You can safely forget about it.
*/
- RUBY_FL_TAINT
+ RUBY_FL_EXIVAR
#if defined(RBIMPL_HAVE_ENUM_ATTRIBUTE)
- RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
+ RBIMPL_ATTR_DEPRECATED(("FL_EXIVAR is an outdated implementation detail, it should not be used."))
#elif defined(_MSC_VER)
-# pragma deprecated(RUBY_FL_TAINT)
+# pragma deprecated(RUBY_FL_EXIVAR)
#endif
- = (1<<8),
+ = 0,
/**
* This flag has something to do with Ractor. Multiple Ractors run without
@@ -297,52 +252,19 @@ ruby_fl_type {
*/
RUBY_FL_SHAREABLE = (1<<8),
- /**
- * @deprecated This flag once was a thing back in the old days, but makes
- * no sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- */
- RUBY_FL_UNTRUSTED
-
-#if defined(RBIMPL_HAVE_ENUM_ATTRIBUTE)
- RBIMPL_ATTR_DEPRECATED(("trustedness turned out to be a wrong idea."))
-#elif defined(_MSC_VER)
-# pragma deprecated(RUBY_FL_UNTRUSTED)
-#endif
-
- = (1<<8),
-
- /**
- * This flag has something to do with object IDs. Unlike in the old days,
- * an object's object ID (that a user can query using `Object#object_id`)
- * is no longer its physical address represented using Ruby level integers.
- * It is now a monotonic-increasing integer unrelated to the underlying
- * memory arrangement. Object IDs are assigned when necessary; objects are
- * born without one, and will eventually have such property when queried.
- * The interpreter has to manage which one is which. This is the flag that
- * helps the management. Objects with this flag set are the ones with
- * object IDs assigned.
- *
- * @internal
- *
- * But honestly, @shyouhei doesn't think this flag should be visible from
- * 3rd parties. It must be an implementation detail that they should never
- * know. Might better be hidden.
- */
- RUBY_FL_SEEN_OBJ_ID = (1<<9),
+ /**
+ * This object weakly refers to other objects.
+ *
+ * @internal
+ */
+ RUBY_FL_WEAK_REFERENCE = (1<<9),
- /**
- * This flag has something to do with instance variables. 3rd parties need
- * not know, but there are several ways to store an object's instance
- * variables. Objects with this flag use so-called "generic" backend
- * storage. This distinction is purely an implementation detail. People
- * need not be aware of this working behind-the-scene.
- *
- * @internal
- *
- * As of writing everything except ::RObject and RModule use this scheme.
- */
- RUBY_FL_EXIVAR = (1<<10),
+ /**
+ * This flag is no longer in use
+ *
+ * @internal
+ */
+ RUBY_FL_UNUSED10 = (1<<10),
/**
* This flag has something to do with data immutability. When this flag is
@@ -402,7 +324,7 @@ ruby_fl_type {
* 3rd parties. It must be an implementation detail that they should never
* know. Might better be hidden.
*/
- RUBY_ELTS_SHARED = RUBY_FL_USER2,
+ RUBY_ELTS_SHARED = RUBY_FL_USER0,
/**
* This flag has something to do with an object's class. There are kind of
@@ -427,24 +349,7 @@ ruby_fl_type {
* 3rd parties. It must be an implementation detail that they should never
* know. Might better be hidden.
*/
- RUBY_FL_SINGLETON = RUBY_FL_USER0,
-};
-
-enum {
- /**
- * @deprecated This flag once was a thing back in the old days, but makes
- * no sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- */
- RUBY_FL_DUPPED
-
-#if defined(RBIMPL_HAVE_ENUM_ATTRIBUTE)
- RBIMPL_ATTR_DEPRECATED(("It seems there is no actual usage of this enum."))
-#elif defined(_MSC_VER)
-# pragma deprecated(RUBY_FL_DUPPED)
-#endif
-
- = (int)RUBY_T_MASK | (int)RUBY_FL_EXIVAR
+ RUBY_FL_SINGLETON = RUBY_FL_USER1,
};
#undef RBIMPL_HAVE_ENUM_ATTRIBUTE
@@ -478,10 +383,8 @@ RB_FL_ABLE(VALUE obj)
if (RB_SPECIAL_CONST_P(obj)) {
return false;
}
- else if (RB_TYPE_P(obj, RUBY_T_NODE)) {
- return false;
- }
else {
+ RBIMPL_ASSERT_OR_ASSUME(!RB_TYPE_P(obj, RUBY_T_NODE));
return true;
}
}
@@ -489,7 +392,7 @@ RB_FL_ABLE(VALUE obj)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_TEST(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_TEST(). 3rd parties need not use
* this. Just always use RB_FL_TEST().
*
* @param[in] obj Object in question.
@@ -537,7 +440,7 @@ RB_FL_TEST(VALUE obj, VALUE flags)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_ANY(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_ANY(). 3rd parties need not use
* this. Just always use RB_FL_ANY().
*
* @param[in] obj Object in question.
@@ -571,7 +474,7 @@ RB_FL_ANY(VALUE obj, VALUE flags)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_ALL(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_ALL(). 3rd parties need not use
* this. Just always use RB_FL_ALL().
*
* @param[in] obj Object in question.
@@ -607,7 +510,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_SET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_SET(). 3rd parties need not use
* this. Just always use RB_FL_SET().
*
* @param[out] obj Object in question.
@@ -627,7 +530,7 @@ rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_SET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_SET(). 3rd parties need not use
* this. Just always use RB_FL_SET().
*
* @param[out] obj Object in question.
@@ -667,7 +570,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_UNSET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_UNSET(). 3rd parties need not use
* this. Just always use RB_FL_UNSET().
*
* @param[out] obj Object in question.
@@ -687,7 +590,7 @@ rbimpl_fl_unset_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_UNSET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_UNSET(). 3rd parties need not use
* this. Just always use RB_FL_UNSET().
*
* @param[out] obj Object in question.
@@ -722,7 +625,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_REVERSE(). 3rd parties need not
+ * This is an implementation detail of RB_FL_REVERSE(). 3rd parties need not
* use this. Just always use RB_FL_REVERSE().
*
* @param[out] obj Object in question.
@@ -742,7 +645,7 @@ rbimpl_fl_reverse_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_REVERSE(). 3rd parties need not
+ * This is an implementation detail of RB_FL_REVERSE(). 3rd parties need not
* use this. Just always use RB_FL_REVERSE().
*
* @param[out] obj Object in question.
@@ -775,130 +678,8 @@ RB_FL_REVERSE(VALUE obj, VALUE flags)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] obj Object in question.
- * @return false always.
- */
-static inline bool
-RB_OBJ_TAINTABLE(VALUE obj)
-{
- (void)obj;
- return false;
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] obj Object in question.
- * @return false always.
- */
-static inline VALUE
-RB_OBJ_TAINTED_RAW(VALUE obj)
-{
- (void)obj;
- return false;
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] obj Object in question.
- * @return false always.
- */
-static inline bool
-RB_OBJ_TAINTED(VALUE obj)
-{
- (void)obj;
- return false;
-}
-
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] obj Object in question.
- */
-static inline void
-RB_OBJ_TAINT_RAW(VALUE obj)
-{
- (void)obj;
- return;
-}
-
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] obj Object in question.
- */
-static inline void
-RB_OBJ_TAINT(VALUE obj)
-{
- (void)obj;
- return;
-}
-
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] dst Victim object.
- * @param[in] src Infectant object.
- */
-static inline void
-RB_OBJ_INFECT_RAW(VALUE dst, VALUE src)
-{
- (void)dst;
- (void)src;
- return;
-}
-
-RBIMPL_ATTR_ARTIFICIAL()
-RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
-/**
- * @deprecated This function once was a thing in the old days, but makes no
- * sense any longer today. Exists here for backwards
- * compatibility only. You can safely forget about it.
- *
- * @param[in] dst Victim object.
- * @param[in] src Infectant object.
- */
-static inline void
-RB_OBJ_INFECT(VALUE dst, VALUE src)
-{
- (void)dst;
- (void)src;
- return;
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * This is an implenentation detail of RB_OBJ_FROZEN(). 3rd parties need not
+ * This is an implementation detail of RB_OBJ_FROZEN(). 3rd parties need not
* use this. Just always use RB_OBJ_FROZEN().
*
* @param[in] obj Object in question.
@@ -937,9 +718,21 @@ RB_OBJ_FROZEN(VALUE obj)
}
}
+RUBY_SYMBOL_EXPORT_BEGIN
+/**
+ * Prevents further modifications to the given object. ::rb_eFrozenError shall
+ * be raised if modification is attempted.
+ *
+ * @param[out] x Object in question.
+ * @exception rb_eNoMemError Failed to allocate memory for the frozen
+ * representation of the object.
+ */
+void rb_obj_freeze_inline(VALUE obj);
+RUBY_SYMBOL_EXPORT_END
+
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_OBJ_FREEZE(). 3rd parties need not
+ * This is an implementation detail of RB_OBJ_FREEZE(). 3rd parties need not
* use this. Just always use RB_OBJ_FREEZE().
*
* @param[out] obj Object in question.
@@ -947,11 +740,7 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline void
RB_OBJ_FREEZE_RAW(VALUE obj)
{
- RB_FL_SET_RAW(obj, RUBY_FL_FREEZE);
+ rb_obj_freeze_inline(obj);
}
-RUBY_SYMBOL_EXPORT_BEGIN
-void rb_obj_freeze_inline(VALUE obj);
-RUBY_SYMBOL_EXPORT_END
-
#endif /* RBIMPL_FL_TYPE_H */
diff --git a/include/ruby/internal/gc.h b/include/ruby/internal/gc.h
index fb14b34211..1900b48a75 100644
--- a/include/ruby/internal/gc.h
+++ b/include/ruby/internal/gc.h
@@ -44,6 +44,13 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
+#define RUBY_REF_EDGE(s, p) offsetof(s, p)
+#define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(uintptr_t)(l)
+#define RUBY_REF_END SIZE_MAX
+#define RUBY_REFERENCES(t) static const size_t t[]
+#define RUBY_REFERENCES_START(t) RUBY_REFERENCES(t) = {
+#define RUBY_REFERENCES_END RUBY_REF_END, };
+
/* gc.c */
RBIMPL_ATTR_COLD()
@@ -203,22 +210,6 @@ void rb_gc_mark_movable(VALUE obj);
VALUE rb_gc_location(VALUE obj);
/**
- * Asserts that the passed object is no longer needed. Such objects are
- * reclaimed sooner or later so this function is not mandatory. But sometimes
- * you can know from your application knowledge that an object is surely dead
- * at some point. Calling this as a hint can be a polite way.
- *
- * @param[out] obj Object, dead.
- * @pre `obj` have never been passed to this function before.
- * @post `obj` could be invalidated.
- * @warning It is a failure to pass an object multiple times to this
- * function.
- * @deprecated This is now a no-op function.
- */
-RBIMPL_ATTR_DEPRECATED(("this is now a no-op function"))
-void rb_gc_force_recycle(VALUE obj);
-
-/**
* Triggers a GC process. This was the only GC entry point that we had at the
* beginning. Over time our GC evolved. Now what this function does is just a
* very simplified variation of the entire GC algorithms. A series of
@@ -393,10 +384,15 @@ VALUE rb_gc_latest_gc_info(VALUE key_or_buf);
void rb_gc_adjust_memory_usage(ssize_t diff);
/**
- * Inform the garbage collector that `valptr` points to a live Ruby object that
- * should not be moved. Note that extensions should use this API on global
- * constants instead of assuming constants defined in Ruby are always alive.
- * Ruby code can remove global constants.
+ * Inform the garbage collector that the global or static variable pointed by
+ * `valptr` stores a live Ruby object that should not be moved. Note that
+ * extensions should use this API on global constants instead of assuming
+ * constants defined in Ruby are always alive. Ruby code can remove global
+ * constants.
+ *
+ * Because this registration itself has a possibility to trigger a GC, this
+ * function must be called before any GC-able objects is assigned to the
+ * address pointed by `valptr`.
*/
void rb_gc_register_address(VALUE *valptr);
@@ -432,18 +428,6 @@ RBIMPL_SYMBOL_EXPORT_END()
#define USE_RGENGC 1
/**
- * @private
- *
- * This is a compile-time flag to enable/disable incremental GC feature. It
- * has to be set at the time ruby itself compiles. Makes no sense for 3rd
- * parties. It is safe for them to set this though; that just doesn't change
- * anything.
- */
-#ifndef USE_RINCGC
-# define USE_RINCGC 1
-#endif
-
-/**
* @deprecated This macro seems broken. Setting this to anything other than
* zero just doesn't compile. We need to KonMari.
*/
@@ -452,153 +436,6 @@ RBIMPL_SYMBOL_EXPORT_END()
#endif
/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RArray. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_ARRAY
-# define RGENGC_WB_PROTECTED_ARRAY 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RHash. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_HASH
-# define RGENGC_WB_PROTECTED_HASH 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RStruct. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_STRUCT
-# define RGENGC_WB_PROTECTED_STRUCT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RString. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_STRING
-# define RGENGC_WB_PROTECTED_STRING 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RObject. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_OBJECT
-# define RGENGC_WB_PROTECTED_OBJECT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RRegexp. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_REGEXP
-# define RGENGC_WB_PROTECTED_REGEXP 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RMatch. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_MATCH
-# define RGENGC_WB_PROTECTED_MATCH 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RClass. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_CLASS
-# define RGENGC_WB_PROTECTED_CLASS 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RFloat. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_FLOAT
-# define RGENGC_WB_PROTECTED_FLOAT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RComplex. It has to be set at the time ruby itself compiles.
- * Makes no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_COMPLEX
-# define RGENGC_WB_PROTECTED_COMPLEX 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RRational. It has to be set at the time ruby itself compiles.
- * Makes no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_RATIONAL
-# define RGENGC_WB_PROTECTED_RATIONAL 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RBignum. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_BIGNUM
-# define RGENGC_WB_PROTECTED_BIGNUM 1
-#endif
-
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- *
- * @internal
- *
- * @shyouhei doesn't think anybody uses this right now.
- */
-#ifndef RGENGC_WB_PROTECTED_NODE_CREF
-# define RGENGC_WB_PROTECTED_NODE_CREF 1
-#endif
-
-/**
* @defgroup rgengc Write barrier (WB) interfaces:
*
* @note The following core interfaces can be changed in the future. Please
@@ -637,11 +474,11 @@ RBIMPL_SYMBOL_EXPORT_END()
#define OBJ_WB_UNPROTECT RB_OBJ_WB_UNPROTECT /**< @old{RB_OBJ_WB_UNPROTECT} */
/**
- * Asserts that the passed object is not fenced by write barriers. Objects of
- * such property do not contribute to generational GCs. They are scanned
- * always.
+ * Marks the object as not protected by write barriers. These objects do not
+ * participate in generational GCs which means that, as long as the object is
+ * alive, they will be scanned on every GC cycle.
*
- * @param[out] x An object that would not be protected by the barrier.
+ * @param[out] x An object that is not protected by the write barrier.
*/
#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
@@ -656,8 +493,7 @@ RBIMPL_SYMBOL_EXPORT_END()
*
* @shyouhei doesn't understand why this has to be visible from extensions.
*/
-#define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
- (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
+#define RB_OBJ_WB_UNPROTECT_FOR(type, obj) OBJ_WB_UNPROTECT(obj)
/**
* @private
diff --git a/include/ruby/internal/globals.h b/include/ruby/internal/globals.h
index 5a414fc472..9beb215c0c 100644
--- a/include/ruby/internal/globals.h
+++ b/include/ruby/internal/globals.h
@@ -68,6 +68,7 @@ RUBY_EXTERN VALUE rb_cBasicObject; /**< `BasicObject` class. */
RUBY_EXTERN VALUE rb_cObject; /**< `Object` class. */
RUBY_EXTERN VALUE rb_cArray; /**< `Array` class. */
RUBY_EXTERN VALUE rb_cBinding; /**< `Binding` class. */
+RUBY_EXTERN VALUE rb_cBox; /**< `Ruby::Box` class. */
RUBY_EXTERN VALUE rb_cClass; /**< `Class` class. */
RUBY_EXTERN VALUE rb_cDir; /**< `Dir` class. */
RUBY_EXTERN VALUE rb_cEncoding; /**< `Encoding` class. */
@@ -91,10 +92,11 @@ RUBY_EXTERN VALUE rb_cRandom; /**< `Random` class. */
RUBY_EXTERN VALUE rb_cRange; /**< `Range` class. */
RUBY_EXTERN VALUE rb_cRational; /**< `Rational` class. */
RUBY_EXTERN VALUE rb_cRegexp; /**< `Regexp` class. */
+RUBY_EXTERN VALUE rb_cSet; /**< `Set` class. */
RUBY_EXTERN VALUE rb_cStat; /**< `File::Stat` class. */
RUBY_EXTERN VALUE rb_cString; /**< `String` class. */
RUBY_EXTERN VALUE rb_cStruct; /**< `Struct` class. */
-RUBY_EXTERN VALUE rb_cSymbol; /**< `Sumbol` class. */
+RUBY_EXTERN VALUE rb_cSymbol; /**< `Symbol` class. */
RUBY_EXTERN VALUE rb_cThread; /**< `Thread` class. */
RUBY_EXTERN VALUE rb_cTime; /**< `Time` class. */
RUBY_EXTERN VALUE rb_cTrueClass; /**< `TrueClass` class. */
diff --git a/include/ruby/internal/has/builtin.h b/include/ruby/internal/has/builtin.h
index 243ba2a34c..8e7fb173d8 100644
--- a/include/ruby/internal/has/builtin.h
+++ b/include/ruby/internal/has/builtin.h
@@ -48,6 +48,7 @@
# /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970 */
# define RBIMPL_HAS_BUILTIN(_) (RBIMPL_HAS_BUILTIN_ ## _)
# define RBIMPL_HAS_BUILTIN___builtin_add_overflow RBIMPL_COMPILER_SINCE(GCC, 5, 1, 0)
+# define RBIMPL_HAS_BUILTIN___builtin_add_overflow_p RBIMPL_COMPILER_SINCE(GCC, 7, 0, 0)
# define RBIMPL_HAS_BUILTIN___builtin_alloca RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
# define RBIMPL_HAS_BUILTIN___builtin_alloca_with_align RBIMPL_COMPILER_SINCE(GCC, 6, 1, 0)
# define RBIMPL_HAS_BUILTIN___builtin_assume 0
@@ -75,6 +76,7 @@
# define RBIMPL_HAS_BUILTIN___builtin_rotateright32 0
# define RBIMPL_HAS_BUILTIN___builtin_rotateright64 0
# define RBIMPL_HAS_BUILTIN___builtin_sub_overflow RBIMPL_COMPILER_SINCE(GCC, 5, 1, 0)
+# define RBIMPL_HAS_BUILTIN___builtin_sub_overflow_p RBIMPL_COMPILER_SINCE(GCC, 7, 0, 0)
# define RBIMPL_HAS_BUILTIN___builtin_unreachable RBIMPL_COMPILER_SINCE(GCC, 4, 5, 0)
# /* Note that "0, 0, 0" might be inaccurate. */
@@ -82,6 +84,7 @@
# /* Take config.h definition when available */
# define RBIMPL_HAS_BUILTIN(_) ((RBIMPL_HAS_BUILTIN_ ## _)+0)
# define RBIMPL_HAS_BUILTIN___builtin_add_overflow HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
+# define RBIMPL_HAS_BUILTIN___builtin_add_overflow_p HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW_P
# define RBIMPL_HAS_BUILTIN___builtin_alloca 0
# define RBIMPL_HAS_BUILTIN___builtin_alloca_with_align HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
# define RBIMPL_HAS_BUILTIN___builtin_assume 0
@@ -107,6 +110,7 @@
# define RBIMPL_HAS_BUILTIN___builtin_rotateright64 0
# define RBIMPL_HAS_BUILTIN___builtin_popcountll HAVE_BUILTIN___BUILTIN_POPCOUNTLL
# define RBIMPL_HAS_BUILTIN___builtin_sub_overflow HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW
+# define RBIMPL_HAS_BUILTIN___builtin_sub_overflow_p HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW_P
# if defined(HAVE___BUILTIN_UNREACHABLE)
# define RBIMPL_HAS_BUILTIN___builtin_unreachable 1
# else
diff --git a/include/ruby/internal/has/c_attribute.h b/include/ruby/internal/has/c_attribute.h
index c5c48867bf..69b0f402cd 100644
--- a/include/ruby/internal/has/c_attribute.h
+++ b/include/ruby/internal/has/c_attribute.h
@@ -21,11 +21,23 @@
* @brief Defines #RBIMPL_HAS_C_ATTRIBUTE.
*/
+#include "ruby/internal/has/extension.h"
+#include "ruby/internal/has/warning.h"
+
/** Wraps (or simulates) `__has_c_attribute`. */
#if defined(__cplusplus)
# /* Makes no sense. */
# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+#elif RBIMPL_HAS_EXTENSION(c_attributes)
+# /* Hmm. It seems Clang 17 has this macro defined even when -std=c99 mode,
+# * _and_ fails to compile complaining that attributes are C2X feature. We
+# * need to work around this nonsense. */
+# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
+
+#elif RBIMPL_HAS_WARNING("-Wc2x-extensions")
+# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+
#elif defined(__has_c_attribute)
# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
diff --git a/include/ruby/internal/intern/array.h b/include/ruby/internal/intern/array.h
index 2262c6f0c6..b2cc6b132d 100644
--- a/include/ruby/internal/intern/array.h
+++ b/include/ruby/internal/intern/array.h
@@ -144,7 +144,13 @@ void rb_ary_free(VALUE ary);
*/
void rb_ary_modify(VALUE ary);
-/** @alias{rb_obj_freeze} */
+/**
+ * Freeze an array, preventing further modifications. The underlying buffer may
+ * be shrunk before freezing to conserve memory.
+ *
+ * @param[out] obj Object assumed to be an array to freeze.
+ * @see RB_OBJ_FREEZE()
+ */
VALUE rb_ary_freeze(VALUE obj);
RBIMPL_ATTR_PURE()
@@ -187,7 +193,7 @@ VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs);
* : (int i) -> T?
* | (int beg, int len) -> ::Array[T]?
* | (Range[int] r) -> ::Array[T]?
- * | (ArithmeticSequence as) -> ::Array[T]? # This also raises RagneError.
+ * | (ArithmeticSequence as) -> ::Array[T]? # This also raises RangeError.
* end
* ```
*/
diff --git a/include/ruby/internal/intern/bignum.h b/include/ruby/internal/intern/bignum.h
index 43d68018de..6ab26fef71 100644
--- a/include/ruby/internal/intern/bignum.h
+++ b/include/ruby/internal/intern/bignum.h
@@ -26,6 +26,10 @@
# include <stddef.h>
#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h> /* for ssize_t (note: on Windows ssize_t is */
+#endif /* `#define`d in ruby/config.h) */
+
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
@@ -51,7 +55,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
VALUE rb_big_new(size_t len, int sign);
/**
- * Queries if the passed bignum instance is a "bigzro". What is a bigzero?
+ * Queries if the passed bignum instance is a "bigzero". What is a bigzero?
* Well, bignums are for very big integers, but can also represent tiny ones
* like -1, 0, 1. Bigzero are instances of bignums whose values are zero.
* Knowing if a bignum is bigzero can be handy on occasions, like for instance
@@ -793,7 +797,7 @@ size_t rb_absint_size(VALUE val, int *nlz_bits_ret);
* @exception rb_eTypeError `val` doesn't respond to `#to_int`.
* @retval (size_t)-1 Overflowed.
* @retval otherwise
- `((val_numbits * CHAR_BIT + word_numbits - 1) / word_numbits)`,
+ * `((val_numbits * CHAR_BIT + word_numbits - 1) / word_numbits)`,
* where val_numbits is the number of bits of `abs(val)`.
* @post If `nlz_bits_ret` is not `NULL` and there is no overflow,
* `(return_value * word_numbits - val_numbits)` is stored in
@@ -841,6 +845,47 @@ size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret);
*/
int rb_absint_singlebit_p(VALUE val);
+/**
+ * @name Flags for rb_int_parse_cstr()
+ * @{
+ */
+
+/** Allows a leading sign (`+` or `-`). */
+#define RB_INT_PARSE_SIGN 0x01
+
+/** Allows underscores between digits. */
+#define RB_INT_PARSE_UNDERSCORE 0x02
+
+/** Allows a base prefix (`0x`, `0b`, `0o`, `0d`). */
+#define RB_INT_PARSE_PREFIX 0x04
+
+/** Shorthand for all of the above flags combined. */
+#define RB_INT_PARSE_ALL 0x07
+
+/** Default flags (all features enabled). */
+#define RB_INT_PARSE_DEFAULT 0x07
+
+/** @} */
+
+/**
+ * Parses a C string to convert into a Ruby integer, with detailed control over
+ * parsing behaviour. Unlike rb_cstr_to_inum(), this function can report the
+ * end position of the parsed integer and the number of parsed digits.
+ *
+ * @param[in] str Pointer to the string to parse.
+ * @param[in] len Length of `str` in bytes, or `-1` to use `strlen(str)`.
+ * @param[out] endp If not `NULL`, the pointer to the first unparsed
+ * character is stored here on return.
+ * @param[out] ndigits If not `NULL`, the number of parsed digits (excluding
+ * prefix, sign, and underscores) is stored here.
+ * @param[in] base Base of conversion. `0` means auto-detect from
+ * prefix. `2..36` for explicit base.
+ * @param[in] flags Bitwise or of `RB_INT_PARSE_*` macros.
+ * @return A Ruby Integer (Fixnum or Bignum), or `Qnil` on parse failure
+ * (when no digits are found).
+ */
+VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RBIMPL_INTERN_BIGNUM_H */
diff --git a/include/ruby/internal/intern/class.h b/include/ruby/internal/intern/class.h
index 0fb2d001bc..357af5d176 100644
--- a/include/ruby/internal/intern/class.h
+++ b/include/ruby/internal/intern/class.h
@@ -88,8 +88,8 @@ VALUE rb_define_class_id(ID id, VALUE super);
* @post `outer::id` refers the returned class.
* @note If a class named `id` is already defined and its superclass is
* `super`, the function just returns the defined class.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*/
VALUE rb_define_class_id_under(VALUE outer, ID id, VALUE super);
@@ -127,8 +127,8 @@ VALUE rb_define_module_id(ID id);
* constant is not a module.
* @return The created module.
* @post `outer::id` refers the returned module.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*/
VALUE rb_define_module_id_under(VALUE outer, ID id);
diff --git a/include/ruby/internal/intern/complex.h b/include/ruby/internal/intern/complex.h
index e111bd8ced..1efc093631 100644
--- a/include/ruby/internal/intern/complex.h
+++ b/include/ruby/internal/intern/complex.h
@@ -87,10 +87,6 @@ VALUE rb_complex_new(VALUE real, VALUE imag);
*/
VALUE rb_complex_new_polar(VALUE abs, VALUE arg);
-RBIMPL_ATTR_DEPRECATED(("by: rb_complex_new_polar"))
-/** @old{rb_complex_new_polar} */
-VALUE rb_complex_polar(VALUE abs, VALUE arg);
-
RBIMPL_ATTR_PURE()
/**
* Queries the real part of the passed Complex.
diff --git a/include/ruby/internal/intern/cont.h b/include/ruby/internal/intern/cont.h
index 32647f48aa..2d813ceb9d 100644
--- a/include/ruby/internal/intern/cont.h
+++ b/include/ruby/internal/intern/cont.h
@@ -148,7 +148,8 @@ VALUE rb_fiber_resume(VALUE fiber, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eFiberError `fiber` is terminated etc.
* @exception rb_eException Any exceptions happen in `fiber`.
* @return Either what was yielded or the last value of the fiber body.
@@ -192,7 +193,8 @@ VALUE rb_fiber_yield(int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eException What was raised using `Fiber#raise`.
* @return (See rb_fiber_resume() for details)
*/
@@ -247,7 +249,8 @@ VALUE rb_fiber_transfer(VALUE fiber, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eFiberError (See above)
* @exception rb_eException What was raised using `Fiber#raise`.
* @return (See rb_fiber_resume() for details)
@@ -275,7 +278,7 @@ VALUE rb_fiber_transfer_kw(VALUE fiber, int argc, const VALUE *argv, int kw_spla
* @exception rb_eFiberError `fiber` is terminated etc.
* @return (See rb_fiber_resume() for details)
*/
-VALUE rb_fiber_raise(VALUE fiber, int argc, const VALUE *argv);
+VALUE rb_fiber_raise(VALUE fiber, int argc, VALUE *argv);
RBIMPL_SYMBOL_EXPORT_END()
diff --git a/include/ruby/internal/intern/enumerator.h b/include/ruby/internal/intern/enumerator.h
index 20e5d7c6fc..00804d786a 100644
--- a/include/ruby/internal/intern/enumerator.h
+++ b/include/ruby/internal/intern/enumerator.h
@@ -100,7 +100,8 @@ VALUE rb_enumeratorize_with_size(VALUE recv, VALUE meth, int argc, const VALUE *
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eTypeError `meth` is not an instance of ::rb_cSymbol.
* @return A new instance of ::rb_cEnumerator which, when yielded,
* enumerates by calling `meth` on `recv` with `argv`.
@@ -186,7 +187,8 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @return A new instance of ::rb_cEnumerator which, when yielded,
* enumerates by calling the current method on `recv` with `argv`.
*/
@@ -220,7 +222,8 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @note This macro may return inside.
*/
#define RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) do { \
@@ -250,7 +253,8 @@ RBIMPL_SYMBOL_EXPORT_END()
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @note This macro may return inside.
*/
#define RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) \
diff --git a/include/ruby/internal/intern/error.h b/include/ruby/internal/intern/error.h
index bf8daadd3e..1fd9ec2f51 100644
--- a/include/ruby/internal/intern/error.h
+++ b/include/ruby/internal/intern/error.h
@@ -237,6 +237,8 @@ RBIMPL_ATTR_NORETURN()
*/
void rb_error_arity(int argc, int min, int max);
+void rb_str_modify(VALUE str);
+
RBIMPL_SYMBOL_EXPORT_END()
/**
@@ -244,12 +246,7 @@ RBIMPL_SYMBOL_EXPORT_END()
*
* Does anyone use this? Remain not deleted for compatibility.
*/
-#define rb_check_frozen_internal(obj) do { \
- VALUE frozen_obj = (obj); \
- if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
- rb_error_frozen_object(frozen_obj); \
- } \
- } while (0)
+#define rb_check_frozen_internal rb_check_frozen
/** @alias{rb_check_frozen} */
static inline void
@@ -258,9 +255,16 @@ rb_check_frozen_inline(VALUE obj)
if (RB_UNLIKELY(RB_OBJ_FROZEN(obj))) {
rb_error_frozen_object(obj);
}
+
+ /* ref: internal CHILLED_STRING_P()
+ This is an implementation detail subject to change. */
+ if (RB_UNLIKELY(RB_TYPE_P(obj, T_STRING) && FL_TEST_RAW(obj, RUBY_FL_USER2 | RUBY_FL_USER3))) { // STR_CHILLED
+ rb_str_modify(obj);
+ }
}
-/** @alias{rb_check_frozen} */
+/* rb_check_frozen() is available as a symbol, but have
+ * the inline version take priority for native consumers. */
#define rb_check_frozen rb_check_frozen_inline
/**
diff --git a/include/ruby/internal/intern/file.h b/include/ruby/internal/intern/file.h
index 79820fdc61..8508b7ab9e 100644
--- a/include/ruby/internal/intern/file.h
+++ b/include/ruby/internal/intern/file.h
@@ -24,6 +24,9 @@
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
+#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
+# include "ruby/backward.h"
+#endif
RBIMPL_SYMBOL_EXPORT_BEGIN()
diff --git a/include/ruby/internal/intern/hash.h b/include/ruby/internal/intern/hash.h
index af8dfd5d8f..504770fa5f 100644
--- a/include/ruby/internal/intern/hash.h
+++ b/include/ruby/internal/intern/hash.h
@@ -284,20 +284,6 @@ typedef VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value);
*/
VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func);
-/* file.c */
-
-/**
- * This function is mysterious. What it does is not immediately obvious. Also
- * what it does seems platform dependent.
- *
- * @param[in] path A local path.
- * @retval 0 The "check" succeeded.
- * @retval otherwise The "check" failed.
- */
-int rb_path_check(const char *path);
-
-/* hash.c */
-
/**
* Destructively removes every environment variables of the running process.
*
diff --git a/include/ruby/internal/intern/io.h b/include/ruby/internal/intern/io.h
index 02c249723e..b9eb258cc1 100644
--- a/include/ruby/internal/intern/io.h
+++ b/include/ruby/internal/intern/io.h
@@ -385,7 +385,7 @@ VALUE rb_io_puts(int argc, const VALUE *argv, VALUE io);
* @param[in] fd Target file descriptor.
* @param[in] flags Flags, e.g. `O_CREAT|O_EXCL`
* @param[in] path The path of the file that backs `fd`, for diagnostics.
- * @return An allocated instance of ::rb_cIO.
+ * @return An allocated instance of ::rb_cIO with the autoclose flag set.
* @note Leave `path` NULL if you don't know.
*/
VALUE rb_io_fdopen(int fd, int flags, const char *path);
diff --git a/include/ruby/internal/intern/load.h b/include/ruby/internal/intern/load.h
index 288a16c2ec..9ceb98c2e4 100644
--- a/include/ruby/internal/intern/load.h
+++ b/include/ruby/internal/intern/load.h
@@ -177,6 +177,43 @@ VALUE rb_f_require(VALUE self, VALUE feature);
VALUE rb_require_string(VALUE feature);
/**
+ * Resolves and returns a symbol of a function in the native extension
+ * specified by the feature and symbol names. Extensions will use this function
+ * to access the symbols provided by other native extensions.
+ *
+ * @param[in] feature Name of a feature, e.g. `"json"`.
+ * @param[in] symbol Name of a symbol defined by the feature.
+ * @return The resolved symbol of a function, defined and externed by the
+ * specified feature. It may be NULL if the feature is not loaded,
+ * the feature is not extension, or the symbol is not found.
+ */
+void *rb_ext_resolve_symbol(const char *feature, const char *symbol);
+
+/**
+ * This macro is to provide backwards compatibility. It provides a way to
+ * define function prototypes and resolving function symbols in a safe way.
+ *
+ * ```CXX
+ * // prototypes
+ * #ifdef HAVE_RB_EXT_RESOLVE_SYMBOL
+ * VALUE *(*other_extension_func)(VALUE,VALUE);
+ * #else
+ * VALUE other_extension_func(VALUE);
+ * #endif
+ *
+ * // in Init_xxx()
+ * #ifdef HAVE_RB_EXT_RESOLVE_SYMBOL
+ * other_extension_func = \
+ * (VALUE(*)(VALUE,VALUE))rb_ext_resolve_symbol(fname, sym_name);
+ * if (other_extension_func == NULL) {
+ * // raise your own error
+ * }
+ * #endif
+ * ```
+ */
+#define HAVE_RB_EXT_RESOLVE_SYMBOL 1
+
+/**
* @name extension configuration
* @{
*/
diff --git a/include/ruby/internal/intern/object.h b/include/ruby/internal/intern/object.h
index b9ffa57c06..3897639a0a 100644
--- a/include/ruby/internal/intern/object.h
+++ b/include/ruby/internal/intern/object.h
@@ -80,7 +80,8 @@ VALUE rb_class_new_instance(int argc, const VALUE *argv, VALUE klass);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eTypeError `klass`'s allocator is undefined.
* @exception rb_eException Any exceptions can happen inside.
* @return An allocated new instance of `klass`.
@@ -151,13 +152,12 @@ VALUE rb_obj_is_kind_of(VALUE obj, VALUE klass);
* @return An allocated, not yet initialised instance of `klass`.
* @note It calls the allocator defined by rb_define_alloc_func(). You
* cannot use this function to define an allocator. Use
- * rb_newobj_of(), #TypedData_Make_Struct or others, instead.
+ * TypedData_Make_Struct or others, instead.
* @note Usually prefer rb_class_new_instance() to rb_obj_alloc() and
* rb_obj_call_init().
* @see rb_class_new_instance()
* @see rb_obj_call_init()
* @see rb_define_alloc_func()
- * @see rb_newobj_of()
* @see #TypedData_Make_Struct
*/
VALUE rb_obj_alloc(VALUE klass);
diff --git a/include/ruby/internal/intern/proc.h b/include/ruby/internal/intern/proc.h
index b8c3c5e146..2635d672eb 100644
--- a/include/ruby/internal/intern/proc.h
+++ b/include/ruby/internal/intern/proc.h
@@ -101,7 +101,8 @@ VALUE rb_proc_call(VALUE recv, VALUE args);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `args`' last is not a keyword argument.
* - RB_PASS_KEYWORDS `args`' last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eException Any exceptions happen inside.
* @return What the proc evaluates to.
*/
@@ -141,7 +142,8 @@ VALUE rb_proc_call_with_block(VALUE recv, int argc, const VALUE *argv, VALUE pro
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `args`' last is not a keyword argument.
* - RB_PASS_KEYWORDS `args`' last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eException Any exceptions happen inside.
* @return What the proc evaluates to.
*/
@@ -245,7 +247,8 @@ VALUE rb_method_call(int argc, const VALUE *argv, VALUE recv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `args`' last is not a keyword argument.
* - RB_PASS_KEYWORDS `args`' last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eTypeError `recv` is not a method.
* @exception rb_eException Any exceptions happen inside.
* @return What the method returns.
@@ -279,7 +282,8 @@ VALUE rb_method_call_with_block(int argc, const VALUE *argv, VALUE recv, VALUE p
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `args`' last is not a keyword argument.
* - RB_PASS_KEYWORDS `args`' last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @exception rb_eTypeError `recv` is not a method.
* @exception rb_eException Any exceptions happen inside.
* @return What the method returns.
diff --git a/include/ruby/internal/intern/process.h b/include/ruby/internal/intern/process.h
index 7a7b24ed4b..cfa5e13162 100644
--- a/include/ruby/internal/intern/process.h
+++ b/include/ruby/internal/intern/process.h
@@ -31,6 +31,15 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
/* process.c */
/**
+ * Wait for the specified process to terminate, reap it, and return its status.
+ *
+ * @param[in] pid The process ID to wait for.
+ * @param[in] flags The flags to pass to waitpid(2).
+ * @return VALUE An instance of Process::Status.
+ */
+VALUE rb_process_status_wait(rb_pid_t pid, int flags);
+
+/**
* Sets the "last status", or the `$?`.
*
* @param[in] status The termination status, as defined in `waitpid(3posix)`.
@@ -247,7 +256,7 @@ rb_pid_t rb_spawn_err(int argc, const VALUE *argv, char *errbuf, size_t buflen);
*
* @internal
*
- * This function might or might not exist depending on `./confiugre` result.
+ * This function might or might not exist depending on `./configure` result.
* It must be a portability hell. Better not use.
*/
VALUE rb_proc_times(VALUE _);
diff --git a/include/ruby/internal/intern/re.h b/include/ruby/internal/intern/re.h
index 31f5593275..4dd58b469b 100644
--- a/include/ruby/internal/intern/re.h
+++ b/include/ruby/internal/intern/re.h
@@ -87,11 +87,6 @@ void rb_match_busy(VALUE md);
* @retval RUBY_Qfalse There is a `n`-th capture and is empty.
* @retval RUBY_Qtrue There is a `n`-th capture that has something.
*
- * @internal
- *
- * @shyouhei wonders: why there are both rb_reg_match_defined() and
- * rb_match_nth_defined, which are largely the same things, but do not share
- * their implementations at all?
*/
VALUE rb_reg_nth_defined(int n, VALUE md);
diff --git a/include/ruby/internal/intern/select.h b/include/ruby/internal/intern/select.h
index fabc287cd1..ba75213618 100644
--- a/include/ruby/internal/intern/select.h
+++ b/include/ruby/internal/intern/select.h
@@ -72,11 +72,13 @@ struct timeval;
* someone else, vastly varies among operating systems. You would better avoid
* touching an fd from more than one threads.
*
+ * NOTE: this function is used in native extensions, so change its API with care.
+ *
* @internal
*
* Although any file descriptors are possible here, it makes completely no
* sense to pass a descriptor that is not `O_NONBLOCK`. If you want to know
- * the reason for this limitatuon in detail, you might find this thread super
+ * the reason for this limitation in detail, you might find this thread super
* interesting: https://lkml.org/lkml/2004/10/6/117
*/
int rb_thread_fd_select(int nfds, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout);
diff --git a/include/ruby/internal/intern/select/win32.h b/include/ruby/internal/intern/select/win32.h
index edaf7a8523..b7301e63f3 100644
--- a/include/ruby/internal/intern/select/win32.h
+++ b/include/ruby/internal/intern/select/win32.h
@@ -206,7 +206,7 @@ rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
* property we heavily touch the internals of MSVCRT. We `CreateFile` a
* `"NUL"` alongside of a socket and directly manipulate its `struct ioinfo`.
* This is of course a very dirty hack. If we could design the API today we
- * could use `CancellIoEx`. But we are older than that Win32 API.
+ * could use `CancelIoEx`. But we are older than that Win32 API.
*/
static inline int
rb_fd_select(int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
@@ -253,7 +253,7 @@ rb_fd_max(const rb_fdset_t *f)
const fd_set *p = f->fdset;
RBIMPL_ASSERT_OR_ASSUME(p);
- return p->fd_count;
+ return RBIMPL_CAST((int)p->fd_count);
}
#endif /* RBIMPL_INTERN_SELECT_WIN32_H */
diff --git a/include/ruby/internal/intern/set.h b/include/ruby/internal/intern/set.h
new file mode 100644
index 0000000000..f4ff8665e2
--- /dev/null
+++ b/include/ruby/internal/intern/set.h
@@ -0,0 +1,111 @@
+#ifndef RBIMPL_INTERN_SET_H /*-*-C++-*-vi:se ft=cpp:*/
+#define RBIMPL_INTERN_SET_H
+/**
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Public APIs related to ::rb_cSet.
+ */
+#include "ruby/internal/attr/nonnull.h"
+#include "ruby/internal/dllexport.h"
+#include "ruby/internal/value.h"
+
+RBIMPL_SYMBOL_EXPORT_BEGIN()
+
+/* set.c */
+
+RBIMPL_ATTR_NONNULL(())
+/**
+ * Iterates over a set. Calls func with each element of the set and the
+ * argument given. func should return ST_CONTINUE, ST_STOP, or ST_DELETE.
+ *
+ * @param[in] set An instance of ::rb_cSet to iterate over.
+ * @param[in] func Callback function to yield.
+ * @param[in] arg Passed as-is to `func`.
+ * @exception rb_eRuntimeError `set` was tampered during iterating.
+ */
+void rb_set_foreach(VALUE set, int (*func)(VALUE element, VALUE arg), VALUE arg);
+
+/**
+ * Creates a new, empty set object.
+ *
+ * @return An allocated new instance of ::rb_cSet.
+ */
+VALUE rb_set_new(void);
+
+/**
+ * Identical to rb_set_new(), except it additionally specifies how many elements
+ * it is expected to contain. This way you can create a set that is large enough
+ * for your need. For large sets, it means it won't need to be reallocated
+ * much, improving performance.
+ *
+ * @param[in] capa Designed capacity of the set.
+ * @return An empty Set, whose capacity is `capa`.
+ */
+VALUE rb_set_new_capa(size_t capa);
+
+/**
+ * Whether the set contains the given element.
+ *
+ * @param[in] set Set to look into.
+ * @param[in] element Set element to look for.
+ * @return true if element is in the set, falst otherwise.
+ */
+bool rb_set_lookup(VALUE set, VALUE element);
+
+/**
+ * Adds element to set.
+ *
+ * @param[in] set Target set table to modify.
+ * @param[in] element Arbitrary Ruby object.
+ * @exception rb_eFrozenError `set` is frozen.
+ * @return true if element was not already in set, false otherwise
+ * @post `element` is in `set`.
+ */
+bool rb_set_add(VALUE set, VALUE element);
+
+/**
+ * Removes all entries from set.
+ *
+ * @param[out] set Target to clear.
+ * @exception rb_eFrozenError `set`is frozen.
+ * @return The passed `set`
+ * @post `set` has no elements.
+ */
+VALUE rb_set_clear(VALUE set);
+
+/**
+ * Removes the element from from set.
+ *
+ * @param[in] set Target set to modify.
+ * @param[in] element Key to delete.
+ * @retval true if element was already in set, false otherwise
+ * @post `set` does not have `element` as an element.
+ */
+bool rb_set_delete(VALUE set, VALUE element);
+
+/**
+ * Returns the number of elements in the set.
+ *
+ * @param[in] set A set object.
+ * @return The size of the set.
+ */
+size_t rb_set_size(VALUE set);
+
+RBIMPL_SYMBOL_EXPORT_END()
+
+#endif /* RBIMPL_INTERN_SET_H */
diff --git a/include/ruby/internal/intern/signal.h b/include/ruby/internal/intern/signal.h
index 84f7558404..4773788651 100644
--- a/include/ruby/internal/intern/signal.h
+++ b/include/ruby/internal/intern/signal.h
@@ -97,7 +97,7 @@ RBIMPL_ATTR_NONNULL(())
* - Case #11: When signo and PID are both negative, the behaviour of this
* function depends on how `killpg(3)` works. On Linux, it seems such
* attempt is strictly prohibited and `Errno::EINVAL` is raised. But on
- * macOS, it seems it tries to to send the signal actually to the process
+ * macOS, it seems it tries to send the signal actually to the process
* group.
*
* @note Above description is in fact different from how `kill(2)` works.
@@ -113,12 +113,6 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_f_kill(int argc, const VALUE *argv);
-/* This must be private, @shyouhei guesses. */
-#ifdef POSIX_SIGNAL
-#define posix_signal ruby_posix_signal
-void (*posix_signal(int, void (*)(int)))(int);
-#endif
-
RBIMPL_ATTR_PURE()
/**
* Queries the name of the signal. It returns for instance `"KILL"` for
diff --git a/include/ruby/internal/intern/string.h b/include/ruby/internal/intern/string.h
index 3083125e56..8bd1ffcfb4 100644
--- a/include/ruby/internal/intern/string.h
+++ b/include/ruby/internal/intern/string.h
@@ -412,8 +412,8 @@ VALUE rb_utf8_str_new_static(const char *ptr, long len);
/**
* Identical to rb_interned_str(), except it takes a Ruby's string instead of
- * C's. It can also be seen as a routine identical to to rb_str_new_shared(),
- * except it returns an infamous "f"string.
+ * C's and preserves its encoding. It can also be seen as a routine identical
+ * to rb_str_new_shared(), except it returns an infamous "f"string.
*
* @param[in] str An object of ::RString.
* @return An instance of ::rb_cString, either cached or allocated, which
@@ -444,8 +444,9 @@ VALUE rb_str_to_interned_str(VALUE str);
* terminating NUL character.
* @exception rb_eArgError `len` is negative.
* @return A found or created instance of ::rb_cString, of `len` bytes
- * length, of "binary" encoding, whose contents are identical to
- * that of `ptr`.
+ * length, whose contents are identical to that of `ptr`. Its
+ * encoding will be US-ASCII if all bytes are lower ASCII, BINARY
+ * otherwise.
* @pre At least `len` bytes of continuous memory region shall be
* accessible via `ptr`.
*/
@@ -454,15 +455,16 @@ VALUE rb_interned_str(const char *ptr, long len);
RBIMPL_ATTR_NONNULL(())
/**
* Identical to rb_interned_str(), except it assumes the passed pointer is a
- * pointer to a C's string. It can also be seen as a routine identical to to
+ * pointer to a C's string. It can also be seen as a routine identical to
* rb_str_to_interned_str(), except it takes a C's string instead of Ruby's.
* Or it can also be seen as a routine identical to rb_str_new_cstr(), except
* it returns an infamous "f"string.
*
* @param[in] ptr A C string.
* @exception rb_eNoMemError Failed to allocate memory.
- * @return An instance of ::rb_cString, of "binary" encoding, whose
- * contents are verbatim copy of `ptr`.
+ * @return An instance of ::rb_cString, whose contents are verbatim copy
+ * of `ptr`. Its encoding will be US-ASCII if all bytes are lower
+ * ASCII, BINARY otherwise.
* @pre `ptr` must not be a null pointer.
*/
VALUE rb_interned_str_cstr(const char *ptr);
@@ -591,10 +593,9 @@ void rb_must_asciicompat(VALUE obj);
VALUE rb_str_dup(VALUE str);
/**
- * I guess there is no use case of this function in extension libraries, but
- * this is a routine identical to rb_str_dup(), except it always creates an
- * instance of ::rb_cString regardless of the given object's class. This makes
- * the most sense when the passed string is formerly hidden by rb_obj_hide().
+ * Like rb_str_dup(), but always create an instance of ::rb_cString
+ * regardless of the given object's class. This makes the most sense
+ * when the passed string is formerly hidden by rb_obj_hide().
*
* @param[in] str A string, possibly hidden.
* @return A duplicated new instance of ::rb_cString.
@@ -970,8 +971,8 @@ st_index_t rb_str_hash(VALUE str);
*
* @param[in] str1 A string.
* @param[in] str2 Another string.
- * @retval 1 They have identical contents, length, and encodings.
- * @retval 0 Otherwise.
+ * @retval 0 They have identical contents, length, and encodings.
+ * @retval 1 Otherwise.
* @pre Both objects must not be any arbitrary objects except
* ::RString.
*
@@ -1686,10 +1687,10 @@ rbimpl_exc_new_cstr(VALUE exc, const char *str)
* Length of a string literal.
*
* @param[in] str A C String literal.
- * @return An integer constant expression that represents `str`'s length,
- * in bytes, not including the terminating NUL character.
+ * @return An integer constant expression that represents the number of
+ * `str`'s elements, not including the terminating NUL character.
*/
-#define rb_strlen_lit(str) (sizeof(str "") - 1)
+#define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
/**
* Identical to rb_str_new_static(), except it cannot take string variables.
diff --git a/include/ruby/internal/intern/struct.h b/include/ruby/internal/intern/struct.h
index 312cf444e2..16b3fad4e0 100644
--- a/include/ruby/internal/intern/struct.h
+++ b/include/ruby/internal/intern/struct.h
@@ -46,14 +46,16 @@ VALUE rb_struct_new(VALUE klass, ...);
*
* @param[in] name Name of the class.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post Global toplevel constant `name` is defined.
* @note `name` is allowed to be a null pointer. This function creates
* an anonymous struct class then.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*
* @internal
*
@@ -70,14 +72,16 @@ RBIMPL_ATTR_NONNULL((2))
* @param[out] space Namespace that the defining class shall reside.
* @param[in] name Name of the class.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post `name` is a constant under `space`.
* @note In contrast to rb_struct_define(), it doesn't make any sense to
* pass a null pointer to this function.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*/
VALUE rb_struct_define_under(VALUE space, const char *name, ...);
@@ -164,10 +168,10 @@ VALUE rb_struct_alloc_noinit(VALUE klass);
* @param[in] super Superclass of the defining class.
* @param[in] func Must be 0 for extension libraries.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post Global toplevel constant `name` is defined.
* @note `name` is allowed to be a null pointer. This function creates
@@ -187,17 +191,35 @@ RBIMPL_ATTR_NONNULL((2))
* @param[in] super Superclass of the defining class.
* @param[in] alloc Must be 0 for extension libraries.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `class_name` is not a constant name.
* @exception rb_eTypeError `class_name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post `class_name` is a constant under `outer`.
* @note In contrast to rb_struct_define_without_accessor(), it doesn't
* make any sense to pass a null name.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*/
VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc, ...);
+/**
+ * Defines an anonymous data class.
+ *
+ * @endinternal
+ *
+ * @param[in] super Superclass of the defining class. Must be a
+ * descendant of ::rb_cData, or 0 as ::rb_cData.
+ * @param[in] ... Arbitrary number of `const char*`, terminated by
+ * NULL. Each of which are the name of fields.
+ * @exception rb_eArgError Duplicated field name.
+ * @return The defined class.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
+ */
+VALUE rb_data_define(VALUE super, ...);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RBIMPL_INTERN_STRUCT_H */
diff --git a/include/ruby/internal/intern/thread.h b/include/ruby/internal/intern/thread.h
index 716375acd7..4d87452745 100644
--- a/include/ruby/internal/intern/thread.h
+++ b/include/ruby/internal/intern/thread.h
@@ -61,10 +61,10 @@ int rb_thread_wait_fd(int fd);
int rb_thread_fd_writable(int fd);
/**
- * Notifies a closing of a file descriptor to other threads. Multiple threads
- * can wait for the given file descriptor at once. If such file descriptor is
- * closed, threads need to start propagating their exceptions. This is the API
- * to kick that process.
+ * This funciton is now a no-op. It was previously used to interrupt threads
+ * that were using the given file descriptor and wait for them to finish.
+ *
+ * @deprecated Use IO with RUBY_IO_MODE_EXTERNAL and `rb_io_close` instead.
*
* @param[in] fd A file descriptor.
* @note This function blocks until all the threads waiting for such fd
diff --git a/include/ruby/internal/intern/variable.h b/include/ruby/internal/intern/variable.h
index 479c3950c1..315584790c 100644
--- a/include/ruby/internal/intern/variable.h
+++ b/include/ruby/internal/intern/variable.h
@@ -48,6 +48,7 @@ VALUE rb_mod_name(VALUE mod);
*/
VALUE rb_class_path(VALUE mod);
+RBIMPL_ATTR_DEPRECATED(("rb_mod_name"))
/**
* @alias{rb_mod_name}
*
diff --git a/include/ruby/internal/intern/vm.h b/include/ruby/internal/intern/vm.h
index 76af796b54..f0b54c702c 100644
--- a/include/ruby/internal/intern/vm.h
+++ b/include/ruby/internal/intern/vm.h
@@ -89,7 +89,8 @@ VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv);
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @retval RUBY_Qundef `recv` doesn't respond to `mid`.
* @retval otherwise What the method evaluates to.
*/
@@ -106,9 +107,11 @@ VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int k
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `arg`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `arg`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @return What the command evaluates to.
*/
+RBIMPL_ATTR_DEPRECATED_INTERNAL(4.0)
VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat);
/**
@@ -229,8 +232,7 @@ void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func);
* restrict creation of an instance of a class. For example it rarely makes
* sense for a DB adaptor class to allow programmers creating DB row objects
* without querying the DB itself. You can kill sporadic creation of such
- * objects then, by nullifying the allocator function using this API. Your
- * object shall be allocated using #RB_NEWOBJ_OF() directly.
+ * objects then, by nullifying the allocator function using this API.
*
* @param[out] klass The class to modify.
* @pre `klass` must be an instance of Class.
diff --git a/include/ruby/internal/interpreter.h b/include/ruby/internal/interpreter.h
index 662d39c0ec..a10e7ad2d8 100644
--- a/include/ruby/internal/interpreter.h
+++ b/include/ruby/internal/interpreter.h
@@ -141,7 +141,7 @@ void ruby_show_copyright(void);
*
* @param[in] addr A pointer somewhere on the stack, near its bottom.
*/
-void ruby_init_stack(volatile VALUE *addr);
+void ruby_init_stack(void *addr);
/**
* Initializes the VM and builtin libraries.
diff --git a/include/ruby/internal/iterator.h b/include/ruby/internal/iterator.h
index 5f706460f8..891045363e 100644
--- a/include/ruby/internal/iterator.h
+++ b/include/ruby/internal/iterator.h
@@ -265,48 +265,6 @@ int rb_block_given_p(void);
*/
void rb_need_block(void);
-#ifndef __cplusplus
-RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
-#endif
-/**
- * Old way to iterate a block.
- *
- * @deprecated This is an old API. Use rb_block_call() instead.
- * @warning The passed function must at least once call a ruby method
- * (to handle interrupts etc.)
- * @param[in] func1 A function that could yield a value.
- * @param[in,out] data1 Passed to `func1`
- * @param[in] proc A function acts as a block.
- * @param[in,out] data2 Passed to `proc` as the data2 parameter.
- * @return What `func1` returns.
- */
-VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
-
-#ifdef __cplusplus
-namespace ruby {
-namespace backward {
-/**
- * Old way to iterate a block.
- *
- * @deprecated This is an old API. Use rb_block_call() instead.
- * @warning The passed function must at least once call a ruby method
- * (to handle interrupts etc.)
- * @param[in] iter A function that could yield a value.
- * @param[in,out] data1 Passed to `func1`
- * @param[in] bl A function acts as a block.
- * @param[in,out] data2 Passed to `proc` as the data2 parameter.
- * @return What `func1` returns.
- */
-static inline VALUE
-rb_iterate_deprecated(VALUE (*iter)(VALUE), VALUE data1, rb_block_call_func_t bl, VALUE data2)
-{
- return ::rb_iterate(iter, data1, bl, data2);
-}}}
-
-RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
-VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
-#endif
-
/**
* Identical to rb_funcallv(), except it additionally passes a function as a
* block. When the method yields, `proc` is called with the yielded value as
@@ -337,7 +295,8 @@ VALUE rb_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_cal
* @param[in] kw_splat Handling of keyword parameters:
* - RB_NO_KEYWORDS `argv`'s last is not a keyword argument.
* - RB_PASS_KEYWORDS `argv`'s last is a keyword argument.
- * - RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
+ * - RB_PASS_CALLED_KEYWORDS Pass keyword arguments if the current method
+ * was called with keyword arguments.
* @return What `obj.mid` returns.
*/
VALUE rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t proc, VALUE data2, int kw_splat);
diff --git a/include/ruby/internal/memory.h b/include/ruby/internal/memory.h
index 6884db195d..eb9c1d2525 100644
--- a/include/ruby/internal/memory.h
+++ b/include/ruby/internal/memory.h
@@ -40,7 +40,12 @@
#if defined(_MSC_VER) && defined(_WIN64)
# include <intrin.h>
+# if defined(_M_AMD64)
# pragma intrinsic(_umul128)
+# endif
+# if defined(_M_ARM64)
+# pragma intrinsic(__umulh)
+# endif
#endif
#include "ruby/internal/attr/alloc_size.h"
@@ -56,13 +61,14 @@
#include "ruby/internal/has/builtin.h"
#include "ruby/internal/stdalign.h"
#include "ruby/internal/stdbool.h"
+#include "ruby/internal/stdckdint.h"
#include "ruby/internal/xmalloc.h"
#include "ruby/backward/2/limits.h"
#include "ruby/backward/2/long_long.h"
#include "ruby/backward/2/assume.h"
#include "ruby/defines.h"
-/** @cond INTENAL_MACRO */
+/** @cond INTERNAL_MACRO */
/* Make alloca work the best possible way. */
#if defined(alloca)
@@ -402,7 +408,8 @@ typedef uint128_t DSIZE_T;
/**
* @private
*
- * This is an implementation detail of rbimpl_size_mul_overflow().
+ * This is an implementation detail of rbimpl_size_mul_overflow() and
+ * rbimpl_size_add_overflow().
*
* @internal
*
@@ -410,9 +417,9 @@ typedef uint128_t DSIZE_T;
* nothing more than std::variant<std::size_t> if we could use recent C++, but
* reality is we cannot.
*/
-struct rbimpl_size_mul_overflow_tag {
- bool left; /**< Whether overflow happened or not. */
- size_t right; /**< Multiplication result. */
+struct rbimpl_size_overflow_tag {
+ bool overflowed; /**< Whether overflow happened or not. */
+ size_t result; /**< Calculation result. */
};
RBIMPL_SYMBOL_EXPORT_BEGIN()
@@ -482,6 +489,18 @@ RBIMPL_ATTR_NORETURN()
*/
void ruby_malloc_size_overflow(size_t x, size_t y);
+RBIMPL_ATTR_NORETURN()
+/**
+ * @private
+ *
+ * This is an implementation detail. People don't use this directly.
+ *
+ * @param[in] x Arbitrary value.
+ * @param[in] y Arbitrary value.
+ * @exception rb_eArgError `x` + `y` would integer overflow.
+ */
+void ruby_malloc_add_size_overflow(size_t x, size_t y);
+
#ifdef HAVE_RB_GC_GUARDED_PTR_VAL
volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val);
#endif
@@ -554,39 +573,46 @@ RBIMPL_ATTR_CONST()
*
* @param[in] x Arbitrary value.
* @param[in] y Arbitrary value.
- * @return `{ left, right }`, where `left` is whether there is an integer
- * overflow or not, and `right` is a (possibly overflowed) result
- * of `x` * `y`.
+ * @return `{ overflowed, result }`, where `overflowed` is whether there is
+ * an integer overflow or not, and `result` is a (possibly
+ * overflowed) result of `x` * `y`.
*
* @internal
*
* This is in fact also an implementation detail of ruby_xmalloc2() etc.
*/
-static inline struct rbimpl_size_mul_overflow_tag
+static inline struct rbimpl_size_overflow_tag
rbimpl_size_mul_overflow(size_t x, size_t y)
{
- struct rbimpl_size_mul_overflow_tag ret = { false, 0, };
+ struct rbimpl_size_overflow_tag ret = { false, 0, };
+
+#if defined(ckd_mul)
+ ret.overflowed = ckd_mul(&ret.result, x, y);
-#if RBIMPL_HAS_BUILTIN(__builtin_mul_overflow)
- ret.left = __builtin_mul_overflow(x, y, &ret.right);
+#elif RBIMPL_HAS_BUILTIN(__builtin_mul_overflow)
+ ret.overflowed = __builtin_mul_overflow(x, y, &ret.result);
#elif defined(DSIZE_T)
RB_GNUC_EXTENSION DSIZE_T dx = x;
RB_GNUC_EXTENSION DSIZE_T dy = y;
RB_GNUC_EXTENSION DSIZE_T dz = dx * dy;
- ret.left = dz > SIZE_MAX;
- ret.right = RBIMPL_CAST((size_t)dz);
+ ret.overflowed = dz > SIZE_MAX;
+ ret.result = RBIMPL_CAST((size_t)dz);
-#elif defined(_MSC_VER) && defined(_WIN64)
+#elif defined(_MSC_VER) && defined(_M_AMD64)
unsigned __int64 dp = 0;
unsigned __int64 dz = _umul128(x, y, &dp);
- ret.left = RBIMPL_CAST((bool)dp);
- ret.right = RBIMPL_CAST((size_t)dz);
+ ret.overflowed = RBIMPL_CAST((bool)dp);
+ ret.result = RBIMPL_CAST((size_t)dz);
+
+#elif defined(_MSC_VER) && defined(_M_ARM64)
+ ret.overflowed = __umulh(x, y) != 0;
+ ret.result = x * y;
#else
/* https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap */
- ret.left = (y != 0) && (x > SIZE_MAX / y);
- ret.right = x * y;
+ ret.overflowed = (y != 0) && (x > SIZE_MAX / y);
+ ret.result = x * y;
#endif
return ret;
@@ -610,11 +636,11 @@ rbimpl_size_mul_overflow(size_t x, size_t y)
static inline size_t
rbimpl_size_mul_or_raise(size_t x, size_t y)
{
- struct rbimpl_size_mul_overflow_tag size =
+ struct rbimpl_size_overflow_tag size =
rbimpl_size_mul_overflow(x, y);
- if (RB_LIKELY(! size.left)) {
- return size.right;
+ if (RB_LIKELY(! size.overflowed)) {
+ return size.result;
}
else {
ruby_malloc_size_overflow(x, y);
@@ -622,6 +648,81 @@ rbimpl_size_mul_or_raise(size_t x, size_t y)
}
}
+#if defined(__DOXYGEN__)
+RBIMPL_ATTR_CONSTEXPR(CXX14)
+#elif RBIMPL_COMPILER_SINCE(GCC, 7, 0, 0)
+RBIMPL_ATTR_CONSTEXPR(CXX14) /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70507 */
+#elif RBIMPL_COMPILER_SINCE(Clang, 7, 0, 0)
+RBIMPL_ATTR_CONSTEXPR(CXX14) /* https://bugs.llvm.org/show_bug.cgi?id=37633 */
+#endif
+RBIMPL_ATTR_CONST()
+/**
+ * @private
+ *
+ * This is an implementation detail. People don't use this directly.
+ *
+ * @param[in] x Arbitrary value.
+ * @param[in] y Arbitrary value.
+ * @return `{ overflowed, result }`, where `overflowed` is whether there is
+ * an integer overflow or not, and `result` is a (possibly
+ * overflowed) result of `x` + `y`.
+ *
+ * @internal
+ */
+static inline struct rbimpl_size_overflow_tag
+rbimpl_size_add_overflow(size_t x, size_t y)
+{
+ struct rbimpl_size_overflow_tag ret = { false, 0, };
+
+#if defined(ckd_add)
+ ret.overflowed = ckd_add(&ret.result, x, y);
+
+#elif RBIMPL_HAS_BUILTIN(__builtin_add_overflow)
+ ret.overflowed = __builtin_add_overflow(x, y, &ret.result);
+
+#elif defined(DSIZE_T)
+ RB_GNUC_EXTENSION DSIZE_T dx = x;
+ RB_GNUC_EXTENSION DSIZE_T dy = y;
+ RB_GNUC_EXTENSION DSIZE_T dz = dx + dy;
+ ret.overflowed = dz > SIZE_MAX;
+ ret.result = (size_t)dz;
+
+#else
+ ret.result = x + y;
+ ret.overflowed = ret.result < y;
+
+#endif
+
+ return ret;
+}
+
+/**
+ * @private
+ *
+ * This is an implementation detail. People don't use this directly.
+ *
+ * @param[in] x Arbitrary value.
+ * @param[in] y Arbitrary value.
+ * @exception rb_eArgError Multiplication could integer overflow.
+ * @return `x` + `y`.
+ *
+ * @internal
+ */
+static inline size_t
+rbimpl_size_add_or_raise(size_t x, size_t y)
+{
+ struct rbimpl_size_overflow_tag size =
+ rbimpl_size_add_overflow(x, y);
+
+ if (RB_LIKELY(!size.overflowed)) {
+ return size.result;
+ }
+ else {
+ ruby_malloc_add_size_overflow(x, y);
+ RBIMPL_UNREACHABLE_RETURN(0);
+ }
+}
+
/**
* This is an implementation detail of #RB_ALLOCV_N(). People don't use this
* directly.
@@ -639,9 +740,8 @@ rbimpl_size_mul_or_raise(size_t x, size_t y)
static inline void *
rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
{
- const size_t total_size = rbimpl_size_mul_or_raise(count, elsize);
- const size_t cnt = (total_size + sizeof(VALUE) - 1) / sizeof(VALUE);
- return rb_alloc_tmp_buffer_with_count(store, total_size, cnt);
+ const size_t total_size = rbimpl_size_mul_or_raise(RBIMPL_CAST((size_t)count), elsize);
+ return rb_alloc_tmp_buffer(store, (long)total_size);
}
RBIMPL_SYMBOL_EXPORT_BEGIN()
diff --git a/include/ruby/internal/module.h b/include/ruby/internal/module.h
index d678dd2102..97b0b2b8b0 100644
--- a/include/ruby/internal/module.h
+++ b/include/ruby/internal/module.h
@@ -56,8 +56,8 @@ RBIMPL_ATTR_NONNULL(())
* @post Top-level constant named `name` refers the returned class.
* @note If a class named `name` is already defined and its superclass is
* `super`, the function just returns the defined class.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*
* @internal
*
@@ -75,8 +75,8 @@ RBIMPL_ATTR_NONNULL(())
* constant is not a module.
* @return The created module.
* @post Top-level constant named `name` refers the returned module.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move modules returned by this
+ * function. They are immortal.
*
* @internal
*
@@ -103,8 +103,8 @@ RBIMPL_ATTR_NONNULL(())
* @post `outer::name` refers the returned class.
* @note If a class named `name` is already defined and its superclass
* is `super`, the function just returns the defined class.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move classes returned by this
+ * function. They are immortal.
*/
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super);
@@ -118,8 +118,8 @@ RBIMPL_ATTR_NONNULL(())
* the constant is not a class.
* @return The created module.
* @post `outer::name` refers the returned module.
- * @note The compaction GC does not move classes returned by this
- * function.
+ * @note The GC does not collect nor move modules returned by this
+ * function. They are immortal.
*/
VALUE rb_define_module_under(VALUE outer, const char *name);
diff --git a/include/ruby/internal/newobj.h b/include/ruby/internal/newobj.h
index ba1d7cbe59..13030ae279 100644
--- a/include/ruby/internal/newobj.h
+++ b/include/ruby/internal/newobj.h
@@ -29,63 +29,14 @@
#include "ruby/internal/value.h"
#include "ruby/assert.h"
-/**
- * Declares, allocates, then assigns a new object to the given variable.
- *
- * @param obj Variable name.
- * @param type Variable type.
- * @exception rb_eNoMemError No space left.
- * @return An allocated object, not initialised.
- * @note Modern programs tend to use #NEWOBJ_OF instead.
- *
- * @internal
- *
- * :FIXME: Should we deprecate it?
- */
-#define RB_NEWOBJ(obj,type) type *(obj) = RBIMPL_CAST((type *)rb_newobj())
-
-/**
- * Identical to #RB_NEWOBJ, except it also accepts the allocating object's
- * class and flags.
- *
- * @param obj Variable name.
- * @param type Variable type.
- * @param klass Object's class.
- * @param flags Object's flags.
- * @exception rb_eNoMemError No space left.
- * @return An allocated object, filled with the arguments.
- */
-#define RB_NEWOBJ_OF(obj,type,klass,flags) type *(obj) = RBIMPL_CAST((type *)rb_newobj_of(klass, flags))
-
-#define NEWOBJ RB_NEWOBJ /**< @old{RB_NEWOBJ} */
-#define NEWOBJ_OF RB_NEWOBJ_OF /**< @old{RB_NEWOBJ_OF} */
#define OBJSETUP rb_obj_setup /**< @old{rb_obj_setup} */
#define CLONESETUP rb_clone_setup /**< @old{rb_clone_setup} */
#define DUPSETUP rb_dup_setup /**< @old{rb_dup_setup} */
RBIMPL_SYMBOL_EXPORT_BEGIN()
/**
- * This is the implementation detail of #RB_NEWOBJ.
- *
- * @exception rb_eNoMemError No space left.
- * @return An allocated object, not initialised.
- */
-VALUE rb_newobj(void);
-
-/**
- * This is the implementation detail of #RB_NEWOBJ_OF.
- *
- * @param klass Object's class.
- * @param flags Object's flags.
- * @exception rb_eNoMemError No space left.
- * @return An allocated object, filled with the arguments.
- */
-VALUE rb_newobj_of(VALUE klass, VALUE flags);
-
-/**
* Fills common fields in the object.
*
- * @note Prefer rb_newobj_of() to this function.
* @param[in,out] obj A Ruby object to be set up.
* @param[in] klass `obj` will belong to this class.
* @param[in] type One of ::ruby_value_type.
@@ -158,42 +109,4 @@ void rb_singleton_class_attached(VALUE klass, VALUE obj);
void rb_copy_generic_ivar(VALUE clone, VALUE obj);
RBIMPL_SYMBOL_EXPORT_END()
-RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#clone works."))
-/**
- * @deprecated Not sure exactly when but at some time, the implementation of
- * `Object#clone` stopped using this function. It remained
- * untouched for a while, and then @shyouhei realised that they
- * are no longer doing the same thing. It seems nobody seriously
- * uses this function any longer. Let's just abandon it.
- *
- * @param[out] clone The destination object.
- * @param[in] obj The source object.
- */
-static inline void
-rb_clone_setup(VALUE clone, VALUE obj)
-{
- (void)clone;
- (void)obj;
- return;
-}
-
-RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#dup works."))
-/**
- * @deprecated Not sure exactly when but at some time, the implementation of
- * `Object#dup` stopped using this function. It remained
- * untouched for a while, and then @shyouhei realised that they
- * are no longer the same thing. It seems nobody seriously uses
- * this function any longer. Let's just abandon it.
- *
- * @param[out] dup The destination object.
- * @param[in] obj The source object.
- */
-static inline void
-rb_dup_setup(VALUE dup, VALUE obj)
-{
- (void)dup;
- (void)obj;
- return;
-}
-
#endif /* RBIMPL_NEWOBJ_H */
diff --git a/include/ruby/internal/scan_args.h b/include/ruby/internal/scan_args.h
index 1ed2bf6368..da64678db5 100644
--- a/include/ruby/internal/scan_args.h
+++ b/include/ruby/internal/scan_args.h
@@ -49,11 +49,11 @@
/** Same behaviour as rb_scan_args(). */
#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0
-/** The final argument should be a hash treated as keywords.*/
+/** The final argument must be a hash, which will be treated as keywords. */
#define RB_SCAN_ARGS_KEYWORDS 1
/**
- * Treat a final argument as keywords if it is a hash, and not as keywords
+ * Treat a final argument as keywords if it is a hash, and not as keywords
* otherwise.
*/
#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3
@@ -68,14 +68,14 @@
/** Do not pass keywords. */
#define RB_NO_KEYWORDS 0
-/** Pass keywords, final argument should be a hash of keywords. */
+/** Pass keywords, final argument must be a hash of keywords. */
#define RB_PASS_KEYWORDS 1
/**
* Pass keywords if current method is called with keywords, useful for argument
* delegation
*/
-#define RB_PASS_CALLED_KEYWORDS rb_keyword_given_p()
+#define RB_PASS_CALLED_KEYWORDS !!rb_keyword_given_p()
/** @} */
diff --git a/include/ruby/internal/special_consts.h b/include/ruby/internal/special_consts.h
index dc0a6b41d6..1e2636da48 100644
--- a/include/ruby/internal/special_consts.h
+++ b/include/ruby/internal/special_consts.h
@@ -156,7 +156,7 @@ RB_TEST(VALUE obj)
*
* RTEST(v) can be 0 if and only if (v == Qfalse || v == Qnil).
*/
- return obj & ~RUBY_Qnil;
+ return obj & RBIMPL_CAST((VALUE)~RUBY_Qnil);
}
RBIMPL_ATTR_CONST()
@@ -226,7 +226,7 @@ RB_NIL_OR_UNDEF_P(VALUE obj)
*
* NIL_OR_UNDEF_P(v) can be true only when v is Qundef or Qnil.
*/
- const VALUE mask = ~(RUBY_Qundef ^ RUBY_Qnil);
+ const VALUE mask = RBIMPL_CAST((VALUE)~(RUBY_Qundef ^ RUBY_Qnil));
const VALUE common_bits = RUBY_Qundef & RUBY_Qnil;
return (obj & mask) == common_bits;
}
@@ -326,7 +326,7 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline bool
RB_SPECIAL_CONST_P(VALUE obj)
{
- return RB_IMMEDIATE_P(obj) || obj == RUBY_Qfalse;
+ return (obj == RUBY_Qfalse) || RB_IMMEDIATE_P(obj);
}
RBIMPL_ATTR_CONST()
@@ -346,7 +346,7 @@ RBIMPL_ATTR_CONSTEXPR(CXX11)
static inline VALUE
rb_special_const_p(VALUE obj)
{
- return RB_SPECIAL_CONST_P(obj) * RUBY_Qtrue;
+ return (unsigned int)RB_SPECIAL_CONST_P(obj) * RUBY_Qtrue;
}
/**
diff --git a/include/ruby/internal/static_assert.h b/include/ruby/internal/static_assert.h
index 594c2b2917..30bfd3bb79 100644
--- a/include/ruby/internal/static_assert.h
+++ b/include/ruby/internal/static_assert.h
@@ -23,13 +23,14 @@
#include <assert.h>
#include "ruby/internal/has/extension.h"
#include "ruby/internal/compiler_since.h"
+#include "ruby/internal/attr/maybe_unused.h"
/** @cond INTERNAL_MACRO */
#if defined(__cplusplus) && defined(__cpp_static_assert)
# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
# define RBIMPL_STATIC_ASSERT0 static_assert
-#elif defined(__cplusplus) && RBIMPL_COMPILER_SINCE(MSVC, 16, 0, 0)
+#elif defined(__cplusplus) && RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_STATIC_ASSERT0 static_assert
#elif defined(__INTEL_CXX11_MODE__)
@@ -71,7 +72,7 @@
#else
# define RBIMPL_STATIC_ASSERT(name, expr) \
- typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
+ RBIMPL_ATTR_MAYBE_UNUSED() typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
#endif
#endif /* RBIMPL_STATIC_ASSERT_H */
diff --git a/include/ruby/internal/stdbool.h b/include/ruby/internal/stdbool.h
index 1ca61136ba..5d9026434b 100644
--- a/include/ruby/internal/stdbool.h
+++ b/include/ruby/internal/stdbool.h
@@ -27,25 +27,13 @@
#elif defined(__cplusplus)
# /* bool is a keyword in C++. */
-# if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
-# include <cstdbool>
-# endif
-#
# ifndef __bool_true_false_are_defined
# define __bool_true_false_are_defined
# endif
-#elif defined(HAVE_STDBOOL_H)
-# /* Take stdbool.h definition. */
+#else
+# /* Take stdbool.h definition. It exists since GCC 3.0 and VS 2015. */
# include <stdbool.h>
-
-#elif !defined(HAVE__BOOL)
-typedef unsigned char _Bool;
-# /* See also http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2229.htm */
-# define bool _Bool
-# define true ((_Bool)+1)
-# define false ((_Bool)+0)
-# define __bool_true_false_are_defined
#endif
#endif /* RBIMPL_STDBOOL_H */
diff --git a/include/ruby/internal/stdckdint.h b/include/ruby/internal/stdckdint.h
new file mode 100644
index 0000000000..e5b5b8b751
--- /dev/null
+++ b/include/ruby/internal/stdckdint.h
@@ -0,0 +1,68 @@
+#ifndef RBIMPL_STDCKDINT_H /*-*-C++-*-vi:se ft=cpp:*/
+#define RBIMPL_STDCKDINT_H
+/**
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief C23 shim for <stdckdint.h>
+ */
+#include "ruby/internal/config.h"
+#include "ruby/internal/cast.h"
+#include "ruby/internal/has/builtin.h"
+#include "ruby/internal/stdbool.h"
+
+#ifdef __has_include
+# if __has_include(<stdckdint.h>)
+# /* Conforming C23 situation; e.g. recent clang */
+# define RBIMPL_HAVE_STDCKDINT_H
+# endif
+#endif
+
+#ifdef HAVE_STDCKDINT_H
+# /* Some OSes (most notably FreeBSD) have this file. */
+# define RBIMPL_HAVE_STDCKDINT_H
+#endif
+
+#ifdef __cplusplus
+# /* It seems OS/Compiler provided stdckdint.h tend not support C++ yet.
+# * Situations could improve someday but in a meantime let us work around.
+# */
+# undef RBIMPL_HAVE_STDCKDINT_H
+#endif
+
+#ifdef RBIMPL_HAVE_STDCKDINT_H
+# /* Take that. */
+# include <stdckdint.h>
+
+#elif RBIMPL_HAS_BUILTIN(__builtin_add_overflow)
+# define ckd_add(x, y, z) RBIMPL_CAST((bool)__builtin_add_overflow((y), (z), (x)))
+# define ckd_sub(x, y, z) RBIMPL_CAST((bool)__builtin_sub_overflow((y), (z), (x)))
+# define ckd_mul(x, y, z) RBIMPL_CAST((bool)__builtin_mul_overflow((y), (z), (x)))
+# define __STDC_VERSION_STDCKDINT_H__ 202311L
+
+#/* elif defined(__cplusplus) */
+#/* :TODO: if we assume C++11 we can use `<type_traits>` to implement them. */
+
+#else
+# /* intentionally leave them undefined */
+# /* to make `#ifdef ckd_add` etc. work as intended. */
+# undef ckd_add
+# undef ckd_sub
+# undef ckd_mul
+# undef __STDC_VERSION_STDCKDINT_H__
+#endif
+
+#endif /* RBIMPL_STDCKDINT_H */
diff --git a/include/ruby/internal/symbol.h b/include/ruby/internal/symbol.h
index 869a31115c..8bfd686fbe 100644
--- a/include/ruby/internal/symbol.h
+++ b/include/ruby/internal/symbol.h
@@ -101,12 +101,11 @@ ID rb_intern(const char *name);
ID rb_intern2(const char *name, long len);
/**
- * Identical to rb_intern(), except it takes an instance of ::rb_cString.
+ * Identical to rb_intern(), except it takes a `T_STRING` object.
*
* @param[in] str The name of the id.
- * @pre `str` must either be an instance of ::rb_cSymbol, or an instance
- * of ::rb_cString, or responds to `#to_str` method.
- * @exception rb_eTypeError Can't convert `str` into ::rb_cString.
+ * @pre `rb_type(str)` must be `T_STRING`.
+ * @exception rb_eEncodingError `str` contains invalid character(s).
* @exception rb_eRuntimeError Too many symbols.
* @return A (possibly new) id whose value is the given str.
* @note These days Ruby internally has two kinds of symbols
@@ -121,10 +120,17 @@ ID rb_intern_str(VALUE str);
* Retrieves the name mapped to the given id.
*
* @param[in] id An id to query.
- * @retval NULL No such id ever existed in the history.
+ * @retval NULL Unknown id.
* @retval otherwise A name that the id represents.
* @note The return value is managed by the interpreter. Don't pass it
* to free().
+ * @note The underlying name can contain internal NUL bytes, so the return
+ * value might be a truncated representation due to the nature of C
+ * strings.
+ * @note This C string is backed by an underlying Ruby string. The Ruby
+ * string may move during GC compaction which would make this
+ * C string point to invalid memory. Do not use the return value
+ * of this function after a potential GC entry point.
*/
const char *rb_id2name(ID id);
@@ -159,34 +165,40 @@ RBIMPL_ATTR_NONNULL(())
* of ::rb_cSymbol, or an instance of ::rb_cString, or responds
* to `#to_str` method.
* @exception rb_eTypeError Can't convert `*namep` into ::rb_cString.
- * @exception rb_eEncodingError Given string is non-ASCII.
+ * @exception rb_eEncodingError Given string contains invalid character(s).
* @retval 0 No such id ever existed in the history.
* @retval otherwise The id that represents the given name.
* @post The object that `*namep` points to is a converted result
* object, which is always an instance of either ::rb_cSymbol
* or ::rb_cString.
+ * @see rb_str_to_str
* @see https://bugs.ruby-lang.org/issues/5072
- *
- * @internal
- *
- * @shyouhei doesn't know why this has to raise rb_eEncodingError.
*/
ID rb_check_id(volatile VALUE *namep);
/**
- * @copydoc rb_intern_str()
- *
- * @internal
+ * Identical to rb_intern_str(), except it tries to convert the parameter object
+ * to an instance of ::rb_cString or its subclasses.
*
- * :FIXME: Can anyone tell us what is the difference between this one and
- * rb_intern_str()? As far as @shyouhei reads the implementation it seems what
- * rb_to_id() does is is just waste some CPU time, then call rb_intern_str().
- * He hopes he is wrong.
+ * @param[in] str The name of the id.
+ * @pre `str` must either be an instance of ::rb_cSymbol, or an instance
+ * of ::rb_cString, or responds to `#to_str` method.
+ * @exception rb_eTypeError Can't convert `str` into ::rb_cString.
+ * @exception rb_eEncodingError Given string contains invalid character(s).
+ * @exception rb_eRuntimeError Too many symbols.
+ * @return A (possibly new) id whose value is the given str.
+ * @note These days Ruby internally has two kinds of symbols
+ * (static/dynamic). Symbols created using this function would
+ * become static ones; i.e. would never be garbage collected. It
+ * is up to you to avoid memory leaks. Think twice before using
+ * it.
+ * @see rb_str_to_str
*/
ID rb_to_id(VALUE str);
/**
- * Identical to rb_id2name(), except it returns a Ruby's String instead of C's.
+ * Identical to rb_id2name(), except it returns a frozen Ruby String instead of
+ * a C String.
*
* @param[in] id An id to query.
* @retval RUBY_Qfalse No such id ever existed in the history.
@@ -201,14 +213,14 @@ ID rb_to_id(VALUE str);
VALUE rb_id2str(ID id);
/**
- * Identical to rb_id2str(), except it takes an instance of ::rb_cSymbol rather
- * than an ::ID.
+ * Obtain a frozen string representation of a symbol (not including the leading
+ * colon). Done without any object allocations.
*
- * @param[in] id An id to query.
- * @retval RUBY_Qfalse No such id ever existed in the history.
- * @retval otherwise An instance of ::rb_cString with the name of id.
+ * @param[in] symbol A ::rb_cSymbol instance to query.
+ * @return A frozen instance of ::rb_cString with the name of `symbol`.
+ * @note This does not create a permanent ::ID using the symbol.
*/
-VALUE rb_sym2str(VALUE id);
+VALUE rb_sym2str(VALUE symbol);
/**
* Identical to rb_intern_str(), except it generates a dynamic symbol if
@@ -237,17 +249,14 @@ RBIMPL_ATTR_NONNULL(())
* of ::rb_cSymbol, or an instance of ::rb_cString, or responds
* to `#to_str` method.
* @exception rb_eTypeError Can't convert `*namep` into ::rb_cString.
- * @exception rb_eEncodingError Given string is non-ASCII.
+ * @exception rb_eEncodingError Given string contains invalid character(s).
* @retval RUBY_Qnil No such id ever existed in the history.
* @retval otherwise The id that represents the given name.
* @post The object that `*namep` points to is a converted result
* object, which is always an instance of either ::rb_cSymbol
* or ::rb_cString.
* @see https://bugs.ruby-lang.org/issues/5072
- *
- * @internal
- *
- * @shyouhei doesn't know why this has to raise rb_eEncodingError.
+ * @see rb_str_to_str
*/
VALUE rb_check_symbol(volatile VALUE *namep);
RBIMPL_SYMBOL_EXPORT_END()
@@ -308,8 +317,9 @@ rbimpl_intern_const(ID *ptr, const char *str)
}
/**
- * Old implementation detail of rb_intern().
- * @deprecated Does anyone use it? Preserved for backward compat.
+ * Returns the cached ID for the given str in var, in compiler
+ * independent manner. Use this instead of GCC specific rb_intern()
+ * when you want to cache the ID on all platforms certainly.
*/
#define RUBY_CONST_ID(var, str) \
do { \
@@ -318,7 +328,8 @@ rbimpl_intern_const(ID *ptr, const char *str)
} while (0)
#if defined(HAVE_STMT_AND_DECL_IN_EXPR)
-/* __builtin_constant_p and statement expression is available
+/* GCC specific shorthand for RUBY_CONST_ID().
+ * __builtin_constant_p and statement expression is available
* since gcc-2.7.2.3 at least. */
#define rb_intern(str) \
(RBIMPL_CONSTANT_P(str) ? \
diff --git a/include/ruby/internal/value_type.h b/include/ruby/internal/value_type.h
index 977f60a009..77cb38bc7d 100644
--- a/include/ruby/internal/value_type.h
+++ b/include/ruby/internal/value_type.h
@@ -96,10 +96,11 @@
#define RB_TYPE_P RB_TYPE_P
#define Check_Type Check_Type
-#if !RUBY_DEBUG
-# define RBIMPL_ASSERT_TYPE(v, t) RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P((v), (t)))
+#ifdef RBIMPL_VA_OPT_ARGS
+# define RBIMPL_ASSERT_TYPE(v, t) \
+ RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(v, t), "actual type: %d", rb_type(v))
#else
-# define RBIMPL_ASSERT_TYPE Check_Type
+# define RBIMPL_ASSERT_TYPE(v, t) RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(v, t))
#endif
/** @endcond */
@@ -129,8 +130,8 @@ ruby_value_type {
RUBY_T_RATIONAL = 0x0f, /**< @see struct ::RRational */
RUBY_T_NIL = 0x11, /**< @see ::RUBY_Qnil */
- RUBY_T_TRUE = 0x12, /**< @see ::RUBY_Qfalse */
- RUBY_T_FALSE = 0x13, /**< @see ::RUBY_Qtrue */
+ RUBY_T_TRUE = 0x12, /**< @see ::RUBY_Qtrue */
+ RUBY_T_FALSE = 0x13, /**< @see ::RUBY_Qfalse */
RUBY_T_SYMBOL = 0x14, /**< @see struct ::RSymbol */
RUBY_T_FIXNUM = 0x15, /**< Integers formerly known as Fixnums. */
RUBY_T_UNDEF = 0x16, /**< @see ::RUBY_Qundef */
@@ -409,14 +410,6 @@ RB_TYPE_P(VALUE obj, enum ruby_value_type t)
#endif
/** @endcond */
-RBIMPL_ATTR_PURE()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * @private
- * Defined in ruby/internal/core/rtypeddata.h
- */
-static inline bool rbimpl_rtypeddata_p(VALUE obj);
-
RBIMPL_ATTR_ARTIFICIAL()
/**
* Identical to RB_TYPE_P(), except it raises exceptions on predication
@@ -431,19 +424,11 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline void
Check_Type(VALUE v, enum ruby_value_type t)
{
+ /* Typed data is not simple `T_DATA`, see `rb_check_type` */
+ RUBY_ASSERT_ALWAYS(t != RUBY_T_DATA);
if (RB_UNLIKELY(! RB_TYPE_P(v, t))) {
- goto unexpected_type;
+ rb_unexpected_type(v, RBIMPL_CAST((int)t));
}
- else if (t == RUBY_T_DATA && rbimpl_rtypeddata_p(v)) {
- /* Typed data is not simple `T_DATA`, see `rb_check_type` */
- goto unexpected_type;
- }
- else {
- return;
- }
-
- unexpected_type:
- rb_unexpected_type(v, t);
}
#endif /* RBIMPL_VALUE_TYPE_H */
diff --git a/include/ruby/internal/warning_push.h b/include/ruby/internal/warning_push.h
index f5981633f8..91d62cb00d 100644
--- a/include/ruby/internal/warning_push.h
+++ b/include/ruby/internal/warning_push.h
@@ -79,7 +79,7 @@
*/
#define RBIMPL_WARNING_IGNORED(flag) __pragma(warning(disable: flag))
-#elif RBIMPL_COMPILER_SINCE(MSVC, 12, 0, 0)
+#elif RBIMPL_COMPILER_IS(MSVC)
# /* Not sure exactly when but it seems VC++ 6.0 is a version with it.*/
# define RBIMPL_WARNING_PUSH() __pragma(warning(push))
# define RBIMPL_WARNING_POP() __pragma(warning(pop))
diff --git a/include/ruby/internal/xmalloc.h b/include/ruby/internal/xmalloc.h
index 57552e4e7d..2551609123 100644
--- a/include/ruby/internal/xmalloc.h
+++ b/include/ruby/internal/xmalloc.h
@@ -57,6 +57,10 @@
#define xrealloc2 ruby_xrealloc2 /**< @old{ruby_xrealloc2} */
#define xfree ruby_xfree /**< @old{ruby_xfree} */
+#define xfree_sized ruby_xfree_sized
+#define xrealloc_sized ruby_xrealloc_sized
+#define xrealloc2_sized ruby_xrealloc2_sized
+
RBIMPL_SYMBOL_EXPORT_BEGIN()
RBIMPL_ATTR_NODISCARD()
@@ -196,6 +200,58 @@ RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newsiz))
RBIMPL_ATTR_NODISCARD()
RBIMPL_ATTR_RETURNS_NONNULL()
+RBIMPL_ATTR_ALLOC_SIZE((2))
+/**
+ * Identical to ruby_xrealloc(), except that it takes the old storage size
+ * as third argument.
+ *
+ * @param[in] ptr A valid pointer to a storage instance that was
+ * previously returned from either:
+ * - ruby_xmalloc(),
+ * - ruby_xmalloc2(),
+ * - ruby_xcalloc(),
+ * - ruby_xrealloc(), or
+ * - ruby_xrealloc2().
+ * @param[in] newsiz Requested new amount of memory.
+ * @param[in] oldsiz Existing amount of memory.
+ * @exception rb_eNoMemError No space left for `newsiz` bytes allocation.
+ * @return A valid pointer to a (possibly newly allocated) storage
+ * instance; which has at least `newsiz` bytes width, with
+ * appropriate alignment detected by the underlying realloc()
+ * routine.
+ * @pre The passed pointer must point to a valid live storage instance.
+ * It is a failure to pass an already freed pointer.
+ * @pre The passed oldsiz must be exactly equal to the size the pointer
+ * was allocated with.
+ * Passing an incorrect oldsiz is undefined behavior, which may
+ * cause memory leaks or crashes.
+ * @post In case the function returns the passed pointer as-is, the
+ * storage instance that the pointer holds is either grown or
+ * shrunken to have at least `newsiz` bytes. Otherwise a valid
+ * pointer to a newly allocated storage instance is returned. In
+ * this case `ptr` is invalidated as if it was passed to
+ * ruby_xfree().
+ * @note It doesn't return NULL.
+ * @warning Unlike some realloc() implementations, passing zero to `newsiz`
+ * is not the same as calling ruby_xfree(), because this function
+ * never returns NULL. Something meaningful still returns then.
+ * @warning It is a failure not to check the return value. Do not assume
+ * anything on it. It could be either identical to, or distinct
+ * form the passed argument.
+ * @warning Do not assume anything on the alignment of the return value.
+ * There is no guarantee that it inherits the passed argument's
+ * one.
+ * @warning The return value shall be invalidated exactly once by either
+ * ruby_xfree(), ruby_xrealloc(), or ruby_xrealloc2(). It is a
+ * failure to pass it to system free(), because the system and Ruby
+ * might or might not share the same malloc() implementation.
+ */
+void *ruby_xrealloc_sized(void *ptr, size_t newsiz, size_t oldsiz)
+RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newsiz))
+;
+
+RBIMPL_ATTR_NODISCARD()
+RBIMPL_ATTR_RETURNS_NONNULL()
RBIMPL_ATTR_ALLOC_SIZE((2,3))
/**
* Identical to ruby_xrealloc(), except it resizes the given storage instance
@@ -251,6 +307,64 @@ void *ruby_xrealloc2(void *ptr, size_t newelems, size_t newsiz)
RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newelems * newsiz))
;
+RBIMPL_ATTR_NODISCARD()
+RBIMPL_ATTR_RETURNS_NONNULL()
+RBIMPL_ATTR_ALLOC_SIZE((2,3))
+/**
+ * Identical to ruby_xrealloc2(), except it takes the old elements count.
+ *
+ * This is roughly the same as reallocarray() function that OpenBSD
+ * etc. provides, but also interacts with our GC.
+ *
+ * @param[in] ptr A valid pointer to a storage instance that was
+ * previously returned from either:
+ * - ruby_xmalloc(),
+ * - ruby_xmalloc2(),
+ * - ruby_xcalloc(),
+ * - ruby_xrealloc(), or
+ * - ruby_xrealloc2().
+ * @param[in] newelems Requested new number of elements.
+ * @param[in] newsiz Requested new size of each element.
+ * @param[in] oldelems The number of elements the pointer was
+ * previously allocated with.
+ * @exception rb_eNoMemError No space left for allocation.
+ * @exception rb_eArgError `newelems` * `newsiz` would overflow.
+ * @return A valid pointer to a (possibly newly allocated) storage
+ * instance; which has at least `newelems` * `newsiz` bytes width,
+ * with appropriate alignment detected by the underlying realloc()
+ * routine.
+ * @pre The passed pointer must point to a valid live storage instance.
+ * It is a failure to pass an already freed pointer.
+ * @pre The passed oldelems must be exactly equal to the number of
+ * elements the pointer was allocated with.
+ * Passing an incorrect oldelems is undefined behavior, which may
+ * cause memory leaks or crashes.
+ * @post In case the function returns the passed pointer as-is, the
+ * storage instance that the pointer holds is either grown or
+ * shrunken to have at least `newelems` * `newsiz` bytes.
+ * Otherwise a valid pointer to a newly allocated storage instance
+ * is returned. In this case `ptr` is invalidated as if it was
+ * passed to ruby_xfree().
+ * @note It doesn't return NULL.
+ * @warning Unlike some realloc() implementations, passing zero to either
+ * `newelems` or `elemsiz` are not the same as calling
+ * ruby_xfree(), because this function never returns NULL.
+ * Something meaningful still returns then.
+ * @warning It is a failure not to check the return value. Do not assume
+ * anything on it. It could be either identical to, or distinct
+ * form the passed argument.
+ * @warning Do not assume anything on the alignment of the return value.
+ * There is no guarantee that it inherits the passed argument's
+ * one.
+ * @warning The return value shall be invalidated exactly once by either
+ * ruby_xfree(), ruby_xrealloc(), or ruby_xrealloc2(). It is a
+ * failure to pass it to system free(), because the system and Ruby
+ * might or might not share the same malloc() implementation.
+ */
+void *ruby_xrealloc2_sized(void *ptr, size_t newelems, size_t newsiz, size_t oldelems)
+RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newelems * newsiz))
+;
+
/**
* Deallocates a storage instance.
*
@@ -283,109 +397,42 @@ void ruby_xfree(void *ptr)
RBIMPL_ATTR_NOEXCEPT(free(ptr))
;
-#if USE_GC_MALLOC_OBJ_INFO_DETAILS
-# define ruby_xmalloc(s1) ruby_xmalloc_with_location(s1, __FILE__, __LINE__)
-# define ruby_xmalloc2(s1, s2) ruby_xmalloc2_with_location(s1, s2, __FILE__, __LINE__)
-# define ruby_xcalloc(s1, s2) ruby_xcalloc_with_location(s1, s2, __FILE__, __LINE__)
-# define ruby_xrealloc(ptr, s1) ruby_xrealloc_with_location(ptr, s1, __FILE__, __LINE__)
-# define ruby_xrealloc2(ptr, s1, s2) ruby_xrealloc2_with_location(ptr, s1, s2, __FILE__, __LINE__)
-
-RBIMPL_ATTR_NODISCARD()
-RBIMPL_ATTR_RESTRICT()
-RBIMPL_ATTR_RETURNS_NONNULL()
-RBIMPL_ATTR_ALLOC_SIZE((1))
-void *ruby_xmalloc_body(size_t size)
-RBIMPL_ATTR_NOEXCEPT(malloc(size))
-;
-
-RBIMPL_ATTR_NODISCARD()
-RBIMPL_ATTR_RESTRICT()
-RBIMPL_ATTR_RETURNS_NONNULL()
-RBIMPL_ATTR_ALLOC_SIZE((1,2))
-void *ruby_xmalloc2_body(size_t nelems, size_t elemsiz)
-RBIMPL_ATTR_NOEXCEPT(malloc(nelems * elemsiz))
-;
-
-RBIMPL_ATTR_NODISCARD()
-RBIMPL_ATTR_RESTRICT()
-RBIMPL_ATTR_RETURNS_NONNULL()
-RBIMPL_ATTR_ALLOC_SIZE((1,2))
-void *ruby_xcalloc_body(size_t nelems, size_t elemsiz)
-RBIMPL_ATTR_NOEXCEPT(calloc(nelems, elemsiz))
-;
-
-RBIMPL_ATTR_NODISCARD()
-RBIMPL_ATTR_RETURNS_NONNULL()
-RBIMPL_ATTR_ALLOC_SIZE((2))
-void *ruby_xrealloc_body(void *ptr, size_t newsiz)
-RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newsiz))
-;
-
-RBIMPL_ATTR_NODISCARD()
-RBIMPL_ATTR_RETURNS_NONNULL()
-RBIMPL_ATTR_ALLOC_SIZE((2,3))
-void *ruby_xrealloc2_body(void *ptr, size_t newelems, size_t newsiz)
-RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newelems * newsiz))
+/**
+ * Deallocates a storage instance of a specific ssize.
+ *
+ * @param[out] ptr Either
+ * - NULL, or
+ * - a valid pointer previously returned from one of:
+ * - ruby_xmalloc(),
+ * - ruby_xmalloc2(),
+ * - ruby_xcalloc(),
+ * - ruby_xrealloc(), or
+ * - ruby_xrealloc2().
+ * @pre The passed pointer must point to a valid live storage instance.
+ * It is a failure to pass an already freed pointer.
+ * @pre The passed size must be exactly equal to the size the pointer
+ * was allocated with.
+ * Passing an incorrect size is undefined behavior, which may
+ * cause memory leaks or crashes.
+ * @post The storage instance pointed by the passed pointer gets
+ * invalidated; it is no longer addressable.
+ * @warning Every single storage instance that was previously allocated by
+ * either ruby_xmalloc(), ruby_xmalloc2(), ruby_xcalloc(),
+ * ruby_xrealloc(), or ruby_xrealloc2() shall be invalidated
+ * exactly once by either passing it to ruby_xfree(), or passing
+ * it to either ruby_xrealloc(), ruby_xrealloc2() then check the
+ * return value for invalidation.
+ * @warning Do not pass anything other than pointers described above. For
+ * instance pointers returned from malloc() or mmap() shall not be
+ * passed to this function, because the underlying memory
+ * management mechanism could differ.
+ * @warning Do not pass any invalid pointers to this function e.g. by
+ * calling it twice with a same argument.
+ */
+void ruby_xfree_sized(void *ptr, size_t size)
+RBIMPL_ATTR_NOEXCEPT(free(ptr))
;
-RUBY_EXTERN const char *ruby_malloc_info_file;
-RUBY_EXTERN int ruby_malloc_info_line;
-
-static inline void *
-ruby_xmalloc_with_location(size_t s, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xmalloc_body(s);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xmalloc2_with_location(size_t s1, size_t s2, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xmalloc2_body(s1, s2);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xcalloc_with_location(size_t s1, size_t s2, const char *file, int line)
-{
- void *ptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- ptr = ruby_xcalloc_body(s1, s2);
- ruby_malloc_info_file = NULL;
- return ptr;
-}
-
-static inline void *
-ruby_xrealloc_with_location(void *ptr, size_t s, const char *file, int line)
-{
- void *rptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- rptr = ruby_xrealloc_body(ptr, s);
- ruby_malloc_info_file = NULL;
- return rptr;
-}
-
-static inline void *
-ruby_xrealloc2_with_location(void *ptr, size_t s1, size_t s2, const char *file, int line)
-{
- void *rptr;
- ruby_malloc_info_file = file;
- ruby_malloc_info_line = line;
- rptr = ruby_xrealloc2_body(ptr, s1, s2);
- ruby_malloc_info_file = NULL;
- return rptr;
-}
-#endif
RBIMPL_SYMBOL_EXPORT_END()
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 8be83a215c..ed0967abad 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -66,6 +66,21 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
struct stat;
struct timeval;
+#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
+# define RUBY_USE_STATX 0
+#elif defined(HAVE_STRUCT_STATX_STX_BTIME)
+# define RUBY_USE_STATX 1
+struct statx;
+#else
+# define RUBY_USE_STATX 0
+#endif
+
+#if RUBY_USE_STATX
+typedef struct statx rb_io_stat_data;
+#else
+typedef struct stat rb_io_stat_data;
+#endif
+
/**
* Indicates that a timeout has occurred while performing an IO operation.
*/
@@ -78,18 +93,20 @@ RUBY_EXTERN VALUE rb_eIOTimeoutError;
*
* This is visible from extension libraries because `io/wait` wants it.
*/
-typedef enum {
+enum rb_io_event {
RUBY_IO_READABLE = RB_WAITFD_IN, /**< `IO::READABLE` */
RUBY_IO_WRITABLE = RB_WAITFD_OUT, /**< `IO::WRITABLE` */
RUBY_IO_PRIORITY = RB_WAITFD_PRI, /**< `IO::PRIORITY` */
-} rb_io_event_t;
+};
+
+typedef enum rb_io_event rb_io_event_t;
/**
* IO buffers. This is an implementation detail of ::rb_io_t::wbuf and
* ::rb_io_t::rbuf. People don't manipulate it directly.
*/
RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
-struct rb_io_buffer_t {
+struct rb_io_internal_buffer {
/** Pointer to the underlying memory region, of at least `capa` bytes. */
char *ptr; /* off + len <= capa */
@@ -105,7 +122,7 @@ struct rb_io_buffer_t {
} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
/** @alias{rb_io_buffer_t} */
-typedef struct rb_io_buffer_t rb_io_buffer_t;
+typedef struct rb_io_internal_buffer rb_io_buffer_t;
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
/*
@@ -114,7 +131,7 @@ typedef struct rb_io_buffer_t rb_io_buffer_t;
* e1 NULL force_encoding(e1) convert str.encoding to e1
* e1 e2 convert from e2 to e1 convert str.encoding to e2
*/
-struct rb_io_enc_t {
+struct rb_io_encoding {
/** Internal encoding. */
rb_encoding *enc;
/** External encoding. */
@@ -135,113 +152,6 @@ struct rb_io_enc_t {
VALUE ecopts;
};
-/** Ruby's IO, metadata and buffers. */
-typedef struct rb_io_t {
-
- /** The IO's Ruby level counterpart. */
- VALUE self;
-
- /** stdio ptr for read/write, if available. */
- FILE *stdio_file;
-
- /** file descriptor. */
- int fd;
-
- /** mode flags: FMODE_XXXs */
- int mode;
-
- /** child's pid (for pipes) */
- rb_pid_t pid;
-
- /** number of lines read */
- int lineno;
-
- /** pathname for file */
- VALUE pathv;
-
- /** finalize proc */
- void (*finalize)(struct rb_io_t*,int);
-
- /** Write buffer. */
- rb_io_buffer_t wbuf;
-
- /**
- * (Byte) read buffer. Note also that there is a field called
- * ::rb_io_t::cbuf, which also concerns read IO.
- */
- rb_io_buffer_t rbuf;
-
- /**
- * Duplex IO object, if set.
- *
- * @see rb_io_set_write_io()
- */
- VALUE tied_io_for_writing;
-
- struct rb_io_enc_t encs; /**< Decomposed encoding flags. */
-
- /** Encoding converter used when reading from this IO. */
- rb_econv_t *readconv;
-
- /**
- * rb_io_ungetc() destination. This buffer is read before checking
- * ::rb_io_t::rbuf
- */
- rb_io_buffer_t cbuf;
-
- /** Encoding converter used when writing to this IO. */
- rb_econv_t *writeconv;
-
- /**
- * This is, when set, an instance of ::rb_cString which holds the "common"
- * encoding. Write conversion can convert strings twice... In case
- * conversion from encoding X to encoding Y does not exist, Ruby finds an
- * encoding Z that bridges the two, so that X to Z to Y conversion happens.
- */
- VALUE writeconv_asciicompat;
-
- /** Whether ::rb_io_t::writeconv is already set up. */
- int writeconv_initialized;
-
- /**
- * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
- * initialising ::rb_io_t::writeconv.
- */
- int writeconv_pre_ecflags;
-
- /**
- * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
- * ::rb_io_t::writeconv.
- */
- VALUE writeconv_pre_ecopts;
-
- /**
- * This is a Ruby level mutex. It avoids multiple threads to write to an
- * IO at once; helps for instance rb_io_puts() to ensure newlines right
- * next to its arguments.
- *
- * This of course doesn't help inter-process IO interleaves, though.
- */
- VALUE write_lock;
-
- /**
- * The timeout associated with this IO when performing blocking operations.
- */
- VALUE timeout;
-} rb_io_t;
-
-/** @alias{rb_io_enc_t} */
-typedef struct rb_io_enc_t rb_io_enc_t;
-
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- */
-#define HAVE_RB_IO_T 1
-
/**
* @name Possible flags for ::rb_io_t::mode
*
@@ -331,7 +241,16 @@ typedef struct rb_io_enc_t rb_io_enc_t;
* Setting this one and #FMODE_BINMODE at the same time is a contradiction.
*/
#define FMODE_TEXTMODE 0x00001000
-/* #define FMODE_PREP 0x00010000 */
+/**
+ * This flag means that an IO object is wrapping an "external" file descriptor,
+ * which is owned by something outside the Ruby interpreter (usually a C extension).
+ * Ruby will not close this file when the IO object is garbage collected.
+ * If this flag is set, then IO#autoclose? is false, and vice-versa.
+ *
+ * This flag was previously called FMODE_PREP internally.
+ */
+#define FMODE_EXTERNAL 0x00010000
+
/* #define FMODE_SIGNAL_ON_EPIPE 0x00020000 */
/**
@@ -345,6 +264,166 @@ typedef struct rb_io_enc_t rb_io_enc_t;
/** @} */
+enum rb_io_mode {
+ RUBY_IO_MODE_EXTERNAL = FMODE_EXTERNAL,
+
+ RUBY_IO_MODE_READABLE = FMODE_READABLE,
+ RUBY_IO_MODE_WRITABLE = FMODE_WRITABLE,
+ RUBY_IO_MODE_READABLE_WRITABLE = (RUBY_IO_MODE_READABLE|RUBY_IO_MODE_WRITABLE),
+
+ RUBY_IO_MODE_BINARY = FMODE_BINMODE,
+ RUBY_IO_MODE_TEXT = FMODE_TEXTMODE,
+ RUBY_IO_MODE_TEXT_SET_ENCODING_FROM_BOM = FMODE_SETENC_BY_BOM,
+
+ RUBY_IO_MODE_SYNCHRONISED = FMODE_SYNC,
+
+ RUBY_IO_MODE_TTY = FMODE_TTY,
+
+ RUBY_IO_MODE_DUPLEX = FMODE_DUPLEX,
+
+ RUBY_IO_MODE_APPEND = FMODE_APPEND,
+ RUBY_IO_MODE_CREATE = FMODE_CREATE,
+ RUBY_IO_MODE_EXCLUSIVE = FMODE_EXCL,
+ RUBY_IO_MODE_TRUNCATE = FMODE_TRUNC,
+};
+
+typedef enum rb_io_mode rb_io_mode_t;
+
+#ifndef HAVE_RB_IO_T
+#define HAVE_RB_IO_T 1
+/** Ruby's IO, metadata and buffers. */
+struct rb_io {
+ /** The IO's Ruby level counterpart. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ VALUE self;
+
+ /** stdio ptr for read/write, if available. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ FILE *stdio_file;
+
+ /** file descriptor. */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_descriptor"))
+ int fd;
+
+ /** mode flags: FMODE_XXXs */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_mode"))
+ enum rb_io_mode mode;
+
+ /** child's pid (for pipes) */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_pid_t pid;
+
+ /** number of lines read */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ int lineno;
+
+ /** pathname for file */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_path"))
+ VALUE pathv;
+
+ /** finalize proc */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ void (*finalize)(struct rb_io*,int);
+
+ /** Write buffer. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_io_buffer_t wbuf;
+
+ /**
+ * (Byte) read buffer. Note also that there is a field called
+ * ::rb_io_t::cbuf, which also concerns read IO.
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_io_buffer_t rbuf;
+
+ /**
+ * Duplex IO object, if set.
+ *
+ * @see rb_io_set_write_io()
+ */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_get_write_io"))
+ VALUE tied_io_for_writing;
+
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
+
+ /** Encoding converter used when reading from this IO. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_econv_t *readconv;
+
+ /**
+ * rb_io_ungetc() destination. This buffer is read before checking
+ * ::rb_io_t::rbuf
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_io_buffer_t cbuf;
+
+ /** Encoding converter used when writing to this IO. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ rb_econv_t *writeconv;
+
+ /**
+ * This is, when set, an instance of ::rb_cString which holds the "common"
+ * encoding. Write conversion can convert strings twice... In case
+ * conversion from encoding X to encoding Y does not exist, Ruby finds an
+ * encoding Z that bridges the two, so that X to Z to Y conversion happens.
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ VALUE writeconv_asciicompat;
+
+ /** Whether ::rb_io_t::writeconv is already set up. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ int writeconv_initialized;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
+ * initialising ::rb_io_t::writeconv.
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ int writeconv_pre_ecflags;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
+ * ::rb_io_t::writeconv.
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ VALUE writeconv_pre_ecopts;
+
+ /**
+ * This is a Ruby level mutex. It avoids multiple threads to write to an
+ * IO at once; helps for instance rb_io_puts() to ensure newlines right
+ * next to its arguments.
+ *
+ * This of course doesn't help inter-process IO interleaves, though.
+ */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ VALUE write_lock;
+
+ /**
+ * The timeout associated with this IO when performing blocking operations.
+ */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_timeout/rb_io_set_timeout"))
+ VALUE timeout;
+};
+#endif
+
+typedef struct rb_io rb_io_t;
+
+/** @alias{rb_io_enc_t} */
+typedef struct rb_io_encoding rb_io_enc_t;
+
+/**
+ * Allocate a new IO object, with the given file descriptor.
+ */
+VALUE rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding);
+
+/**
+ * Returns whether or not the underlying IO is closed.
+ *
+ * @return Whether the underlying IO is closed.
+ */
+VALUE rb_io_closed_p(VALUE io);
+
/**
* Queries the underlying IO pointer.
*
@@ -415,14 +494,14 @@ rb_io_t *rb_io_make_open_file(VALUE obj);
* like this:
*
* ```CXX
- * typedef struct rb_io_t {
+ * typedef struct rb_io {
* 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
+ * void (*finalize) _((struct rb_io*,int)); // finalize proc
* } rb_io_t;
*```
*
@@ -486,7 +565,7 @@ FILE *rb_fdopen(int fd, const char *modestr);
*
* rb_io_modestr_fmode() is not a pure function because it raises.
*/
-int rb_io_modestr_fmode(const char *modestr);
+enum rb_io_mode rb_io_modestr_fmode(const char *modestr);
/**
* Identical to rb_io_modestr_fmode(), except it returns a mixture of `O_`
@@ -704,6 +783,12 @@ VALUE rb_io_set_write_io(VALUE io, VALUE w);
void rb_io_set_nonblock(rb_io_t *fptr);
/**
+ * Returns the path for the given IO.
+ *
+ */
+VALUE rb_io_path(VALUE io);
+
+/**
* Returns an integer representing the numeric file descriptor for
* <em>io</em>.
*
@@ -713,6 +798,12 @@ void rb_io_set_nonblock(rb_io_t *fptr);
int rb_io_descriptor(VALUE io);
/**
+ * Get the mode of the IO.
+ *
+ */
+int rb_io_mode(VALUE io);
+
+/**
* This function breaks down the option hash that `IO#initialize` takes into
* components. This is an implementation detail of rb_io_extract_modeenc()
* today. People prefer that API instead.
@@ -729,7 +820,7 @@ int rb_io_descriptor(VALUE io);
* @post `enc2_p` is the specified external encoding.
* @post `fmode_p` is the specified set of `FMODE_` modes.
*/
-int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p);
+int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, enum rb_io_mode *fmode_p);
/**
* This function can be seen as an extended version of
@@ -798,7 +889,7 @@ int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **
* ) -> void
* ```
*/
-void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_p);
+void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, enum rb_io_mode *fmode_p, rb_io_enc_t *convconfig_p);
/* :TODO: can this function be __attribute__((warn_unused_result)) or not? */
/**
@@ -913,6 +1004,9 @@ VALUE rb_io_wait(VALUE io, VALUE events, VALUE timeout);
* }
* ```
*
+ * On timeout, ::RUBY_Qfalse is returned. Unless you are specifically handling
+ * the timeouts, you should typically raise ::rb_eIOTimeoutError in this case.
+ *
* @param[in] error System errno.
* @param[in] io An IO object to wait.
* @param[in] events An integer set of interests.
@@ -921,19 +1015,19 @@ VALUE rb_io_wait(VALUE io, VALUE events, VALUE timeout);
* @exception rb_eRangeError `timeout` is out of range.
* @exception rb_eSystemCallError `select(2)` failed for some reason.
* @retval RUBY_Qfalse Operation timed out.
+ * @retval RUBY_Qnil Operation failed for some other reason (errno).
* @retval Otherwise Actual events reached.
*
- * @internal
- *
- * This function to return ::RUBY_Qfalse on timeout could be unintended. It
- * seems timeout feature has some rough edge.
*/
VALUE rb_io_maybe_wait(int error, VALUE io, VALUE events, VALUE timeout);
/**
* Blocks until the passed IO is ready for reading, if that makes sense for the
- * passed errno. This is a special case of rb_io_maybe_wait() that only
- * concerns for reading.
+ * passed errno. This is a special case of rb_io_maybe_wait() that is
+ * only concerned with reading and handles the timeout.
+ *
+ * If you do not want the default timeout handling, consider using
+ * ::rb_io_maybe_wait directly.
*
* @param[in] error System errno.
* @param[in] io An IO object to wait.
@@ -941,15 +1035,18 @@ VALUE rb_io_maybe_wait(int error, VALUE io, VALUE events, VALUE timeout);
* @exception rb_eIOError `io` is not open.
* @exception rb_eRangeError `timeout` is out of range.
* @exception rb_eSystemCallError `select(2)` failed for some reason.
- * @retval 0 Operation timed out.
+ * @exception rb_eIOTimeoutError The wait operation timed out.
* @retval Otherwise Always returns ::RUBY_IO_READABLE.
*/
int rb_io_maybe_wait_readable(int error, VALUE io, VALUE timeout);
/**
* Blocks until the passed IO is ready for writing, if that makes sense for the
- * passed errno. This is a special case of rb_io_maybe_wait() that only
- * concernsfor writing.
+ * passed errno. This is a special case of rb_io_maybe_wait() that is
+ * only concerned with writing, and handles the timeout.
+ *
+ * If you do not want the default timeout handling, consider using
+ * ::rb_io_maybe_wait directly.
*
* @param[in] error System errno.
* @param[in] io An IO object to wait.
@@ -957,7 +1054,7 @@ int rb_io_maybe_wait_readable(int error, VALUE io, VALUE timeout);
* @exception rb_eIOError `io` is not open.
* @exception rb_eRangeError `timeout` is out of range.
* @exception rb_eSystemCallError `select(2)` failed for some reason.
- * @retval 0 Operation timed out.
+ * @exception rb_eIOTimeoutError The wait operation timed out.
* @retval Otherwise Always returns ::RUBY_IO_WRITABLE.
*/
int rb_io_maybe_wait_writable(int error, VALUE io, VALUE timeout);
@@ -1016,6 +1113,18 @@ int rb_io_read_pending(rb_io_t *fptr);
*/
VALUE rb_stat_new(const struct stat *st);
+#if RUBY_USE_STATX
+/**
+ * Constructs an instance of ::rb_cStat from the passed information.
+ *
+ * @param[in] st A stat.
+ * @return Allocated new instance of ::rb_cStat.
+ */
+VALUE rb_statx_new(const rb_io_stat_data *st);
+#else
+# define rb_statx_new rb_stat_new
+#endif
+
/* gc.c */
RBIMPL_SYMBOL_EXPORT_END()
diff --git a/include/ruby/io/buffer.h b/include/ruby/io/buffer.h
index 88e5598066..e4d98bf051 100644
--- a/include/ruby/io/buffer.h
+++ b/include/ruby/io/buffer.h
@@ -23,10 +23,18 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
#define RUBY_IO_BUFFER_VERSION 2
+// The `IO::Buffer` class.
RUBY_EXTERN VALUE rb_cIOBuffer;
+
+// The operating system page size.
RUBY_EXTERN size_t RUBY_IO_BUFFER_PAGE_SIZE;
+
+// The default buffer size, usually a (small) multiple of the page size.
+// Can be overridden by the RUBY_IO_BUFFER_DEFAULT_SIZE environment variable.
RUBY_EXTERN size_t RUBY_IO_BUFFER_DEFAULT_SIZE;
+// Represents the internal state of the buffer.
+// More than one flag can be set at a time.
enum rb_io_buffer_flags {
// The memory in the buffer is owned by someone else.
// More specifically, it means that someone else owns the buffer and we shouldn't try to resize it.
@@ -49,21 +57,22 @@ enum rb_io_buffer_flags {
RB_IO_BUFFER_PRIVATE = 64,
// The buffer is read-only and cannot be modified.
- RB_IO_BUFFER_READONLY = 128
+ RB_IO_BUFFER_READONLY = 128,
+
+ // The buffer is backed by a file.
+ RB_IO_BUFFER_FILE = 256,
};
+// Represents the endian of the data types.
enum rb_io_buffer_endian {
+ // The least significant units are put first.
RB_IO_BUFFER_LITTLE_ENDIAN = 4,
RB_IO_BUFFER_BIG_ENDIAN = 8,
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if defined(WORDS_BIGENDIAN)
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
-#elif REG_DWORD == REG_DWORD_LITTLE_ENDIAN
+#else
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
-#elif REG_DWORD == REG_DWORD_BIG_ENDIAN
- RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
#endif
RB_IO_BUFFER_NETWORK_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN
@@ -75,9 +84,14 @@ VALUE rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer
VALUE rb_io_buffer_lock(VALUE self);
VALUE rb_io_buffer_unlock(VALUE self);
int rb_io_buffer_try_unlock(VALUE self);
+
VALUE rb_io_buffer_free(VALUE self);
+VALUE rb_io_buffer_free_locked(VALUE self);
-int rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
+// Access the internal buffer and flags. Validates the pointers.
+// The points may not remain valid if the source buffer is manipulated.
+// Consider using rb_io_buffer_lock if needed.
+enum rb_io_buffer_flags rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
void rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size);
void rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size);
diff --git a/include/ruby/memory_view.h b/include/ruby/memory_view.h
index 1ddca2d46f..42309d5afc 100644
--- a/include/ruby/memory_view.h
+++ b/include/ruby/memory_view.h
@@ -47,10 +47,10 @@ typedef struct {
char format;
/** :FIXME: what is a "native" size is unclear. */
- unsigned native_size_p: 1;
+ bool native_size_p;
/** Endian of the component */
- unsigned little_endian_p: 1;
+ bool little_endian_p;
/** The component's offset. */
size_t offset;
diff --git a/include/ruby/onigmo.h b/include/ruby/onigmo.h
index 8d7c601703..5c2ebe55fe 100644
--- a/include/ruby/onigmo.h
+++ b/include/ruby/onigmo.h
@@ -4,8 +4,8 @@
onigmo.h - Onigmo (Oniguruma-mod) (regular expression library)
**********************************************************************/
/*-
- * Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * Copyright (c) 2011-2017 K.Takata <kentkt AT csc DOT jp>
+ * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2019 K.Takata <kentkt AT csc DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,8 +38,8 @@ extern "C" {
#endif
#define ONIGMO_VERSION_MAJOR 6
-#define ONIGMO_VERSION_MINOR 1
-#define ONIGMO_VERSION_TEENY 3
+#define ONIGMO_VERSION_MINOR 2
+#define ONIGMO_VERSION_TEENY 0
#ifndef ONIG_EXTERN
# ifdef RUBY_EXTERN
@@ -636,6 +636,7 @@ ONIG_EXTERN const OnigSyntaxType* OnigDefaultSyntax;
#define ONIGERR_PARSE_DEPTH_LIMIT_OVER -16
#define ONIGERR_DEFAULT_ENCODING_IS_NOT_SET -21
#define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR -22
+#define ONIGERR_TIMEOUT -23
/* general error */
#define ONIGERR_INVALID_ARGUMENT -30
/* syntax error */
@@ -686,6 +687,8 @@ ONIG_EXTERN const OnigSyntaxType* OnigDefaultSyntax;
#define ONIGERR_NEVER_ENDING_RECURSION -221
#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222
#define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223
+#define ONIGERR_TOO_MANY_RANGE_REPEAT -224
+#define ONIGERR_TOO_MANY_NULL_CHECK -225
#define ONIGERR_INVALID_CODE_POINT_VALUE -400
#define ONIGERR_INVALID_WIDE_CHAR_VALUE -400
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401
@@ -744,8 +747,6 @@ typedef struct {
typedef struct {
int lower;
int upper;
- long base_num;
- long inner_num;
} OnigRepeatRange;
typedef void (*OnigWarnFunc)(const char* s);
@@ -790,8 +791,8 @@ typedef struct re_pattern_buffer {
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 */
+ int *reserved1;
+ int *reserved2;
OnigDistance dmin; /* min-distance of exact or map */
OnigDistance dmax; /* max-distance of exact or map */
@@ -846,6 +847,8 @@ void onig_free(OnigRegex);
ONIG_EXTERN
void onig_free_body(OnigRegex);
ONIG_EXTERN
+int onig_reg_copy(OnigRegex* reg, OnigRegex orig_reg);
+ONIG_EXTERN
OnigPosition onig_scan(OnigRegex reg, const OnigUChar* str, const OnigUChar* end, OnigRegion* region, OnigOptionType option, int (*scan_callback)(OnigPosition, OnigPosition, OnigRegion*, void*), void* callback_arg);
ONIG_EXTERN
OnigPosition onig_search(OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option);
diff --git a/include/ruby/ractor.h b/include/ruby/ractor.h
index 7811616f6d..8cfca21621 100644
--- a/include/ruby/ractor.h
+++ b/include/ruby/ractor.h
@@ -217,7 +217,7 @@ VALUE rb_ractor_make_shareable(VALUE obj);
*
* @param[in] obj Arbitrary ruby object to duplicate.
* @exception rb_eRactorError Ractors cannot share `obj` by nature.
- * @return A deep copy of `obj` which is sharable among Ractors.
+ * @return A deep copy of `obj` which is shareable among Ractors.
*/
VALUE rb_ractor_make_shareable_copy(VALUE obj);
@@ -261,4 +261,18 @@ rb_ractor_shareable_p(VALUE obj)
}
}
+// TODO: optimize on interpreter core
+#ifndef RB_OBJ_SET_SHAREABLE
+VALUE rb_obj_set_shareable(VALUE obj); // ractor.c
+#define RB_OBJ_SET_SHAREABLE(obj) rb_obj_set_shareable(obj)
+#endif
+
+static inline VALUE
+RB_OBJ_SET_FROZEN_SHAREABLE(VALUE obj)
+{
+ RB_OBJ_FREEZE(obj);
+ RB_OBJ_SET_SHAREABLE(obj);
+ return obj;
+}
+
#endif /* RUBY_RACTOR_H */
diff --git a/include/ruby/random.h b/include/ruby/random.h
index 39bdb6f3e3..3b63a23334 100644
--- a/include/ruby/random.h
+++ b/include/ruby/random.h
@@ -11,7 +11,7 @@
*
* This is a set of APIs to roll your own subclass of ::rb_cRandom. An
* illustrative example of such PRNG can be found at
- * `ext/-test-/ramdom/loop.c`.
+ * `ext/-test-/random/loop.c`.
*/
#include "ruby/ruby.h"
@@ -332,7 +332,8 @@ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
static inline const rb_random_interface_t *
rb_rand_if(VALUE obj)
{
- RBIMPL_ASSERT_OR_ASSUME(RTYPEDDATA_P(obj));
+ RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(obj, T_DATA));
+ RUBY_ASSERT(rb_typeddata_is_kind_of(obj, &rb_random_data_type));
const struct rb_data_type_struct *t = RTYPEDDATA_TYPE(obj);
const void *ret = t->data;
return RBIMPL_CAST((const rb_random_interface_t *)ret);
diff --git a/include/ruby/re.h b/include/ruby/re.h
index 3892d6e7f2..f86d6f26cf 100644
--- a/include/ruby/re.h
+++ b/include/ruby/re.h
@@ -18,6 +18,7 @@
#include <stdio.h>
+#include "ruby/onigmo.h"
#include "ruby/regex.h"
#include "ruby/internal/core/rmatch.h"
#include "ruby/internal/dllexport.h"
@@ -126,6 +127,30 @@ VALUE rb_reg_quote(VALUE str);
regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
/**
+ * Runs a regular expression match using function `match`. Performs preparation,
+ * error handling, and memory cleanup.
+ *
+ * @param[in] re Target regular expression.
+ * @param[in] str What `re` is about to run on.
+ * @param[in] match The function to run to match `str` against `re`.
+ * @param[in] args Pointer to arguments to pass into `match`.
+ * @param[out] regs Registers on a successful match.
+ * @exception rb_eArgError `re` does not fit for `str`.
+ * @exception rb_eEncCompatError `re` and `str` are incompatible.
+ * @exception rb_eRegexpError `re` is malformed.
+ * @return Match position on a successful match, `ONIG_MISMATCH` otherwise.
+ *
+ * @internal
+ *
+ * The type `regex_t *` is defined in `<ruby/onigmo.h>`, _and_
+ * _conflicts_ with POSIX's `<regex.h>`. We can no longer save the situation
+ * at this point. Just don't mix the two.
+ */
+OnigPosition rb_reg_onig_match(VALUE re, VALUE str,
+ OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args),
+ void *args, struct re_registers *regs);
+
+/**
* Duplicates a match data. This is roughly the same as `onig_region_copy()`,
* except it tries to GC when there is not enough memory.
*
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index eb9a7e4d0f..ca794bcaeb 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -97,8 +97,10 @@ VALUE rb_get_path(VALUE obj);
VALUE rb_get_path_no_checksafe(VALUE);
/**
- * @deprecated This macro is an alias of #FilePathValue now. The part that did
- * "String" was deleted. It remains here because of no harm.
+ * This macro actually does the same thing as #FilePathValue now. The "String"
+ * part indicates that this is for when a string is treated like a pathname,
+ * rather than the actual pathname on the file systems. For examples:
+ * `Dir.fnmatch?`, `File.join`, `File.basename`, etc.
*/
#define FilePathStringValue(v) ((v) = rb_get_path(v))
@@ -270,6 +272,124 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 0)
*/
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
+#include <errno.h>
+
+/**
+ * @name Errno handling routines for userland threads
+ * @note POSIX chapter 2 section 3 states that for each thread of a process,
+ * the value of `errno` shall not be affected by function calls or
+ * assignments to `errno` by other threads.
+ *
+ * Soooo this `#define errno` below seems like a noob mistake at first sight.
+ * If you look at its actual implementation, the functions are just adding one
+ * level of indirection. It doesn't make any sense sorry? But yes! @ko1 told
+ * @shyouhei that this is inevitable.
+ *
+ * The ultimate reason is because Ruby now has N:M threads implemented.
+ * Threads of that sort change their context in user land. A function can be
+ * "transferred" between threads in middle of their executions. Let us for
+ * instance consider:
+ *
+ * ```cxx
+ * void foo()
+ * {
+ * auto i = errno;
+ * close(0);
+ * errno = i;
+ * }
+ * ```
+ *
+ * This function (if ran under our Ractor) could change its running thread at
+ * the `close` function. But the two `errno` invocations are different! Look
+ * how the source code above is compiled by clang 17 with `-O3` flag @ Linux:
+ *
+ * ```
+ * foo(int): # @foo(int)
+ * push rbp
+ * push r14
+ * push rbx
+ * mov ebx, edi
+ * call __errno_location@PLT
+ * mov r14, rax
+ * mov ebp, dword ptr [rax]
+ * mov edi, ebx
+ * call close@PLT
+ * mov dword ptr [r14], ebp
+ * pop rbx
+ * pop r14
+ * pop rbp
+ * ret
+ * ```
+ *
+ * Notice how `__errno_location@PLT` is `call`-ed only once. The compiler
+ * assumes that the location of `errno` does not change during a function call.
+ * Sadly this is no longer true for us. The `close@PLT` now changes threads,
+ * which should also change where `errno` is stored.
+ *
+ * With the `#define errno` below the compilation result changes to this:
+ *
+ * ```
+ * foo(int): # @foo(int)
+ * push rbp
+ * push rbx
+ * push rax
+ * mov ebx, edi
+ * call rb_errno_ptr()@PLT
+ * mov ebp, dword ptr [rax]
+ * mov edi, ebx
+ * call close@PLT
+ * call rb_errno_ptr()@PLT
+ * mov dword ptr [rax], ebp
+ * add rsp, 8
+ * pop rbx
+ * pop rbp
+ * ret
+ * ```
+ *
+ * Which fixes the problem.
+ */
+
+/**
+ * Identical to system `errno`.
+ *
+ * @return The last set `errno` number.
+ */
+int rb_errno(void);
+
+/**
+ * Set the errno.
+ *
+ * @param err New `errno`.
+ * @post `errno` is now set to `err`.
+ */
+void rb_errno_set(int err);
+
+/**
+ * The location of `errno`
+ *
+ * @return The (thread-specific) location of `errno`.
+ */
+int *rb_errno_ptr(void);
+
+/**
+ * Not sure if it is necessary for extension libraries but this is where the
+ * "bare" errno is located.
+ *
+ * @return The location of `errno`.
+ */
+static inline int *
+rb_orig_errno_ptr(void)
+{
+ return &errno;
+}
+
+#define rb_orig_errno errno /**< System-provided original `errno`. */
+#undef errno
+#define errno (*rb_errno_ptr()) /**< Ractor-aware version of `errno`. */
+
+/** @} */
+
+
/** @cond INTERNAL_MACRO */
#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
# /* Skip it; clang -pedantic doesn't like the following */
@@ -306,6 +426,21 @@ __extension__({ \
# include "ruby/backward.h"
#endif
+#ifndef RUBY__ASAN_DEFAULT_OPTIONS
+# define RUBY__ASAN_DEFAULT_OPTIONS
+#endif
+
+#define RUBY_GLOBAL_SETUP \
+ RUBY__ASAN_DEFAULT_OPTIONS \
+ /* RUBY_GLOBAL_SETUP end */
+
+#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
+int rb_wasm_rt_start(int (*)(int, char **), int, char **);
+# define ruby_start_main rb_wasm_rt_start
+#else
+# define ruby_start_main(main, argc, argv) main(argc, argv)
+#endif
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RUBY_RUBY_H */
diff --git a/include/ruby/st.h b/include/ruby/st.h
index 1e4bb80686..b510989b6b 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -84,13 +84,12 @@ struct st_table {
const struct st_hash_type *type;
/* Number of entries currently in the table. */
st_index_t num_entries;
- /* Array of bins used for access by keys. */
- st_index_t *bins;
/* Start and bound index of entries in array entries.
entries_starts and entries_bound are in interval
[0,allocated_entries]. */
st_index_t entries_start, entries_bound;
- /* Array of size 2^entry_power. */
+ /* Array of size 2^entry_power.
+ Optionnally followed by an array of bins used for access by keys. */
st_table_entry *entries;
};
@@ -98,6 +97,8 @@ struct st_table {
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK, ST_REPLACE};
+size_t rb_st_table_size(const struct st_table *tbl);
+#define st_table_size rb_st_table_size
st_table *rb_st_init_table(const struct st_hash_type *);
#define st_init_table rb_st_init_table
st_table *rb_st_init_table_with_size(const struct st_hash_type *, st_index_t);
diff --git a/include/ruby/thread.h b/include/ruby/thread.h
index 0b5b1ca0f3..2fa01229e2 100644
--- a/include/ruby/thread.h
+++ b/include/ruby/thread.h
@@ -59,6 +59,19 @@
*/
#define RB_NOGVL_UBF_ASYNC_SAFE (0x2)
+/**
+ * Passing this flag to rb_nogvl() indicates that the passed function
+ * is safe to offload to a background thread or work pool. In other words, the
+ * function is safe to run using a fiber scheduler's `blocking_operation_wait`.
+ * hook.
+ *
+ * If your function depends on thread-local storage, or thread-specific data
+ * operations/data structures, you should not set this flag, as
+ * these operations may behave differently (or fail) when run in a different
+ * thread/context (e.g. unlocking a mutex).
+ */
+#define RB_NOGVL_OFFLOAD_SAFE (0x4)
+
/** @} */
RBIMPL_SYMBOL_EXPORT_BEGIN()
@@ -190,14 +203,59 @@ void *rb_nogvl(void *(*func)(void *), void *data1,
*/
#define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_
-#define RUBY_INTERNAL_THREAD_EVENT_STARTED 1 << 0 /** thread started */
+/**
+ * Declare the current Ruby thread should acquire a dedicated
+ * native thread on M:N thread scheduler.
+ *
+ * If a C extension (or a library which the extension relies on) should
+ * keep to run on a native thread (e.g. using thread-local-storage),
+ * this function allocates a dedicated native thread for the thread.
+ *
+ * @return `false` if the thread already running on a dedicated native
+ * thread. Otherwise `true`.
+ */
+bool rb_thread_lock_native_thread(void);
+
+/**
+ * Triggered when a new thread is started.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
+#define RUBY_INTERNAL_THREAD_EVENT_STARTED 1 << 0
+
+/**
+* Triggered when a thread attempt to acquire the GVL.
+*
+* @note The callback will be called *without* the GVL held.
+*/
#define RUBY_INTERNAL_THREAD_EVENT_READY 1 << 1 /** acquiring GVL */
+
+/**
+ * Triggered when a thread successfully acquired the GVL.
+ *
+ * @note The callback will be called *with* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_RESUMED 1 << 2 /** acquired GVL */
+
+/**
+ * Triggered when a thread released the GVL.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_SUSPENDED 1 << 3 /** released GVL */
+
+/**
+ * Triggered when a thread exits.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_EXITED 1 << 4 /** thread terminated */
+
#define RUBY_INTERNAL_THREAD_EVENT_MASK 0xff /** All Thread events */
-typedef void rb_internal_thread_event_data_t; // for future extension.
+typedef struct rb_internal_thread_event_data {
+ VALUE thread;
+} rb_internal_thread_event_data_t;
typedef void (*rb_internal_thread_event_callback)(rb_event_flag_t event,
const rb_internal_thread_event_data_t *event_data,
@@ -211,7 +269,12 @@ typedef struct rb_internal_thread_event_hook rb_internal_thread_event_hook_t;
* @param[in] events A set of events that `func` should run.
* @param[in] data Passed as-is to `func`.
* @return An opaque pointer to the hook, to unregister it later.
- * @note This functionality is a noop on Windows.
+ * @note This functionality is a noop on Windows and WebAssembly.
+ * @note The callback will be called without the GVL held, except for the
+ * RESUMED event.
+ * @note Callbacks are not guaranteed to be executed on the native threads
+ * that corresponds to the Ruby thread. To identify which Ruby thread
+ * the event refers to, you must use `event_data->thread`.
* @warning This function MUST not be called from a thread event callback.
*/
rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook(
@@ -223,13 +286,60 @@ rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook(
* Unregister the passed hook.
*
* @param[in] hook. The hook to unregister.
- * @return Wether the hook was found and unregistered.
- * @note This functionality is a noop on Windows.
+ * @return Whether the hook was found and unregistered.
+ * @note This functionality is a noop on Windows and WebAssembly.
* @warning This function MUST not be called from a thread event callback.
*/
bool rb_internal_thread_remove_event_hook(
rb_internal_thread_event_hook_t * hook);
+
+typedef int rb_internal_thread_specific_key_t;
+#define RB_INTERNAL_THREAD_SPECIFIC_KEY_MAX 8
+/**
+ * Create a key to store thread specific data.
+ *
+ * These APIs are designed for tools using
+ * rb_internal_thread_event_hook APIs.
+ *
+ * Note that only `RB_INTERNAL_THREAD_SPECIFIC_KEY_MAX` keys
+ * can be created. raises `ThreadError` if exceeded.
+ *
+ * Usage:
+ * // at initialize time:
+ * int tool_key; // gvar
+ * Init_tool() {
+ * tool_key = rb_internal_thread_specific_key_create();
+ * }
+ *
+ * // at any timing:
+ * rb_internal_thread_specific_set(thread, tool_key, per_thread_data);
+ * ...
+ * per_thread_data = rb_internal_thread_specific_get(thread, tool_key);
+ */
+rb_internal_thread_specific_key_t rb_internal_thread_specific_key_create(void);
+
+/**
+ * Get thread and tool specific data.
+ *
+ * This function is async signal safe and thread safe.
+ */
+void *rb_internal_thread_specific_get(VALUE thread_val, rb_internal_thread_specific_key_t key);
+
+/**
+ * Set thread and tool specific data.
+ *
+ * This function is async signal safe and thread safe.
+ */
+void rb_internal_thread_specific_set(VALUE thread_val, rb_internal_thread_specific_key_t key, void *data);
+
+/**
+ * Whether the current thread is holding the GVL.
+ *
+ * @return true if the current thread is holding the GVL, false otherwise.
+ */
+int ruby_thread_has_gvl_p(void);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RUBY_THREAD_H */
diff --git a/include/ruby/thread_native.h b/include/ruby/thread_native.h
index c23b15e133..8217a67514 100644
--- a/include/ruby/thread_native.h
+++ b/include/ruby/thread_native.h
@@ -28,6 +28,11 @@ typedef union rb_thread_lock_union {
CRITICAL_SECTION crit;
} rb_nativethread_lock_t;
+struct rb_thread_cond_struct {
+ struct cond_event_entry *next;
+ struct cond_event_entry *prev;
+};
+
typedef struct rb_thread_cond_struct rb_nativethread_cond_t;
#elif defined(HAVE_PTHREAD_H)
diff --git a/include/ruby/util.h b/include/ruby/util.h
index ee11bc940a..12e69c4b80 100644
--- a/include/ruby/util.h
+++ b/include/ruby/util.h
@@ -33,7 +33,9 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
-/** an approximation of ceil(n * log10(2)), up to 65536 at least */
+/** an approximation of ceil(n * log10(2)), up to 1,048,576 (1<<20)
+ * without overflow within 32-bit calculation
+ */
#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
/** an approximation of decimal representation size for n-bytes */
diff --git a/include/ruby/version.h b/include/ruby/version.h
index 08c0aadb07..5bb381cea2 100644
--- a/include/ruby/version.h
+++ b/include/ruby/version.h
@@ -61,13 +61,13 @@
* doesn't mean a total rewrite. Practically when it comes to API versioning,
* major and minor version changes are equally catastrophic.
*/
-#define RUBY_API_VERSION_MAJOR 3
+#define RUBY_API_VERSION_MAJOR 4
/**
* Minor version. As of writing this version changes annually. Greater
* version doesn't mean "better"; they just mean years passed.
*/
-#define RUBY_API_VERSION_MINOR 3
+#define RUBY_API_VERSION_MINOR 1
/**
* Teeny version. This digit is kind of reserved these days. Kept 0 for the
diff --git a/include/ruby/vm.h b/include/ruby/vm.h
index 3458c28be7..8779780952 100644
--- a/include/ruby/vm.h
+++ b/include/ruby/vm.h
@@ -49,6 +49,13 @@ int ruby_vm_destruct(ruby_vm_t *vm);
*/
void ruby_vm_at_exit(void(*func)(ruby_vm_t *));
+/**
+ * Returns whether the Ruby VM will free all memory at shutdown.
+ *
+ * @return true if free-at-exit is enabled, false otherwise.
+ */
+bool ruby_free_at_exit_p(void);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RUBY_VM_H */
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 197eb8a802..ae11a61481 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -30,14 +30,10 @@ extern "C++" { /* template without extern "C++" */
#if !defined(_WIN64) && !defined(WIN32)
#define WIN32
#endif
-#if defined(_MSC_VER) && _MSC_VER <= 1200
-#include <windows.h>
-#endif
#include <winsock2.h>
#include <ws2tcpip.h>
-#if !defined(_MSC_VER) || _MSC_VER >= 1400
+#include <mswsock.h>
#include <iphlpapi.h>
-#endif
#if defined(__cplusplus) && defined(_MSC_VER)
}
#endif
@@ -58,13 +54,7 @@ extern "C++" { /* template without extern "C++" */
#include <direct.h>
#include <process.h>
#include <time.h>
-#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
-extern "C++" { /* template without extern "C++" */
-#endif
#include <math.h>
-#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
-}
-#endif
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -125,8 +115,30 @@ typedef unsigned int uintptr_t;
#define O_SHARE_DELETE 0x20000000 /* for rb_w32_open(), rb_w32_wopen() */
typedef int clockid_t;
-#define CLOCK_REALTIME 0
-#define CLOCK_MONOTONIC 1
+
+/*
+ * Since we use our versions in win32/win32.c, not to depend on yet
+ * another DLL, prefix our versions not to conflict with inline
+ * versions provided in time.h.
+ */
+#define clock_gettime rb_w32_clock_gettime
+#define clock_getres rb_w32_clock_getres
+
+#ifndef CLOCK_REALTIME
+# define CLOCK_REALTIME 0
+#endif
+#ifndef CLOCK_MONOTONIC
+# define CLOCK_MONOTONIC 1
+#endif
+#ifndef CLOCK_PROCESS_CPUTIME_ID
+# define CLOCK_PROCESS_CPUTIME_ID 2
+#endif
+#ifndef CLOCK_THREAD_CPUTIME_ID
+# define CLOCK_THREAD_CPUTIME_ID 3
+#endif
+#ifndef CLOCK_REALTIME_COARSE
+# define CLOCK_REALTIME_COARSE 4
+#endif
#undef utime
#undef lseek
@@ -147,8 +159,10 @@ typedef int clockid_t;
#define open rb_w32_uopen
#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 read(f, b, s) rb_w32_read(f, b, s)
+#define write(f, b, s) rb_w32_write(f, b, s)
+#define pread(f, b, s, o) rb_w32_pread(f, b, s, o)
+#define pwrite(f, b, s, o) rb_w32_pwrite(f, b, s, o)
#define getpid() rb_w32_getpid()
#undef HAVE_GETPPID
#define HAVE_GETPPID 1
@@ -248,7 +262,6 @@ struct ifaddrs {
#endif
extern void rb_w32_sysinit(int *, char ***);
-extern DWORD rb_w32_osid(void);
extern int flock(int fd, int oper);
extern int rb_w32_io_cancelable_p(int);
extern int rb_w32_is_socket(int);
@@ -292,7 +305,11 @@ extern void rb_w32_free_environ(char **);
extern int rb_w32_map_errno(DWORD);
extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
-extern DWORD rb_w32_osver(void);
+
+RBIMPL_ATTR_DEPRECATED(("as Windows 9x is not supported already"))
+static inline DWORD rb_w32_osid(void) {return VER_PLATFORM_WIN32_NT;}
+RBIMPL_ATTR_DEPRECATED(("by Windows Version Helper APIs"))
+extern DWORD rb_w32_osver(void);
extern int rb_w32_uchown(const char *, int, int);
extern int rb_w32_ulink(const char *, const char *);
@@ -328,7 +345,7 @@ extern int rb_w32_dup2(int, int);
#include <float.h>
-#if defined _MSC_VER && _MSC_VER >= 1800 && defined INFINITY
+#if defined _MSC_VER && defined INFINITY
#pragma warning(push)
#pragma warning(disable:4756)
static inline float
@@ -411,11 +428,6 @@ extern int rb_w32_utruncate(const char *path, rb_off_t length);
#define HAVE_TRUNCATE 1
#define truncate rb_w32_utruncate
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1800
-#define strtoll _strtoi64
-#define strtoull _strtoui64
-#endif
-
/*
* stubs
*/
@@ -716,6 +728,8 @@ int rb_w32_fclose(FILE*);
int rb_w32_pipe(int[2]);
ssize_t rb_w32_read(int, void *, size_t);
ssize_t rb_w32_write(int, const void *, size_t);
+ssize_t rb_w32_pread(int, void *, size_t, rb_off_t offset);
+ssize_t rb_w32_pwrite(int, const void *, size_t, rb_off_t offset);
rb_off_t rb_w32_lseek(int, rb_off_t, int);
int rb_w32_uutime(const char *, const struct utimbuf *);
int rb_w32_uutimes(const char *, const struct timeval *);
diff --git a/inits.c b/inits.c
index 8b66334a4d..4988fa09d0 100644
--- a/inits.c
+++ b/inits.c
@@ -22,11 +22,6 @@ rb_call_inits(void)
{
CALL(default_shapes);
CALL(Thread_Mutex);
-#if USE_TRANSIENT_HEAP
- CALL(TransientHeap);
-#endif
- CALL(vm_postponed_job);
- CALL(Method);
CALL(RandomSeedCore);
CALL(encodings);
CALL(sym);
@@ -56,8 +51,9 @@ rb_call_inits(void)
CALL(Dir);
CALL(Time);
CALL(Random);
- CALL(signal);
CALL(load);
+ CALL(Ruby_module);
+ CALL(Box);
CALL(Proc);
CALL(Binding);
CALL(Math);
@@ -68,18 +64,22 @@ rb_call_inits(void)
CALL(VM);
CALL(ISeq);
CALL(Thread);
+ CALL(signal);
+ CALL(Cont);
CALL(Fiber_Scheduler);
CALL(process);
- CALL(Cont);
CALL(Rational);
CALL(Complex);
CALL(MemoryView);
+ CALL(pathname);
CALL(version);
CALL(vm_trace);
CALL(vm_stack_canary);
CALL(ast);
- CALL(gc_stress);
CALL(shape);
+ CALL(Prism);
+ CALL(unicode_version);
+ CALL(Set);
// enable builtin loading
CALL(builtin);
@@ -89,6 +89,10 @@ void
rb_call_builtin_inits(void)
{
#define BUILTIN(n) CALL(builtin_##n)
+ BUILTIN(jit_hook);
+ BUILTIN(yjit);
+ BUILTIN(zjit);
+ BUILTIN(kernel);
BUILTIN(gc);
BUILTIN(ractor);
BUILTIN(numeric);
@@ -97,19 +101,16 @@ rb_call_builtin_inits(void)
BUILTIN(ast);
BUILTIN(trace_point);
BUILTIN(pack);
+ BUILTIN(pathname_builtin);
BUILTIN(warning);
BUILTIN(array);
- BUILTIN(kernel);
+ BUILTIN(hash);
BUILTIN(symbol);
BUILTIN(timev);
BUILTIN(thread_sync);
- BUILTIN(yjit);
BUILTIN(nilclass);
BUILTIN(marshal);
-#if USE_RJIT
- BUILTIN(rjit_c);
- BUILTIN(rjit);
-#endif
+ BUILTIN(jit_undef);
Init_builtin_prelude();
}
#undef CALL
diff --git a/insns.def b/insns.def
index ba16d6365c..3ad378081a 100644
--- a/insns.def
+++ b/insns.def
@@ -145,6 +145,7 @@ getblockparamproxy
(lindex_t idx, rb_num_t level)
()
(VALUE val)
+// attr bool zjit_profile = true;
{
const VALUE *ep = vm_get_ep(GET_EP(), level);
VM_ASSERT(VM_ENV_LOCAL_P(ep));
@@ -212,6 +213,7 @@ getinstancevariable
(VALUE val)
/* Ractor crashes when it accesses class/module-level instances variables. */
// attr bool leaf = false; /* has IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR() */
+// attr bool zjit_profile = true;
{
val = vm_getinstancevariable(GET_ISEQ(), GET_SELF(), id, ic);
}
@@ -222,7 +224,8 @@ setinstancevariable
(ID id, IVC ic)
(VALUE val)
()
-// attr bool leaf = false; /* has rb_check_frozen_internal() */
+// attr bool leaf = false; /* has rb_check_frozen() */
+// attr bool zjit_profile = true;
{
vm_setinstancevariable(GET_ISEQ(), GET_SELF(), id, val, ic);
}
@@ -260,20 +263,7 @@ opt_getconstant_path
(VALUE val)
// attr bool leaf = false; /* may autoload or raise */
{
- const ID *segments = ic->segments;
- struct iseq_inline_constant_cache_entry *ice = ic->entry;
- if (ice && vm_ic_hit_p(ice, GET_EP())) {
- val = ice->value;
-
- VM_ASSERT(val == vm_get_ev_const_chain(ec, segments));
- } else {
- ruby_vm_constant_cache_misses++;
- val = vm_get_ev_const_chain(ec, segments);
- vm_ic_track_const_chain(GET_CFP(), ic, segments);
- // Because leaf=false, we need to undo the PC increment to get the address to this instruction
- // INSN_ATTR(width) == 2
- vm_ic_update(GET_ISEQ(), ic, val, GET_EP(), GET_PC() - 2);
- }
+ val = rb_vm_opt_getconstant_path(ec, GET_CFP(), ic);
}
/* Get constant variable id. If klass is Qnil and allow_nil is Qtrue, constants
@@ -383,12 +373,22 @@ putspecialobject
/* put string val. string will be copied. */
DEFINE_INSN
-putstring
+dupstring
(VALUE str)
()
(VALUE val)
{
- val = rb_ec_str_resurrect(ec, str);
+ val = rb_ec_str_resurrect(ec, str, false);
+}
+
+/* put chilled string val. string will be copied but frozen in the future. */
+DEFINE_INSN
+dupchilledstring
+(VALUE str)
+()
+(VALUE val)
+{
+ val = rb_ec_str_resurrect(ec, str, true);
}
/* put concatenate strings */
@@ -429,9 +429,7 @@ toregexp
// attr bool leaf = false;
// attr rb_snum_t sp_inc = 1 - (rb_snum_t)cnt;
{
- const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, STACK_ADDR_FROM_TOP(cnt));
- val = rb_reg_new_ary(ary, (int)opt);
- rb_ary_clear(ary);
+ val = rb_reg_new_from_values(cnt, STACK_ADDR_FROM_TOP(cnt), (int)opt);
}
/* intern str to Symbol and push it. */
@@ -455,23 +453,17 @@ newarray
val = rb_ec_ary_new_from_values(ec, num, STACK_ADDR_FROM_TOP(num));
}
-/* put new array initialized with num values on the stack. There
- should be at least one element on the stack, and the top element
- should be a hash. If the top element is empty, it is not
- included in the array.
+/* push hash onto array unless the hash is empty (as empty keyword
+ splats should be ignored).
*/
DEFINE_INSN
-newarraykwsplat
-(rb_num_t num)
-(...)
-(VALUE val)
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
+pushtoarraykwsplat
+()
+(VALUE ary, VALUE hash)
+(VALUE ary)
{
- if (RHASH_EMPTY_P(*STACK_ADDR_FROM_TOP(1))) {
- val = rb_ary_new4(num-1, STACK_ADDR_FROM_TOP(num));
- }
- else {
- val = rb_ary_new4(num, STACK_ADDR_FROM_TOP(num));
+ if (!RHASH_EMPTY_P(hash)) {
+ rb_ary_push(ary, hash);
}
}
@@ -511,13 +503,16 @@ expandarray
(rb_num_t num, rb_num_t flag)
(..., VALUE ary)
(...)
+// attr bool handles_sp = true;
// attr bool leaf = false; /* has rb_check_array_type() */
// attr rb_snum_t sp_inc = (rb_snum_t)num - 1 + (flag & 1 ? 1 : 0);
{
- vm_expandarray(GET_SP(), ary, num, (int)flag);
+ vm_expandarray(GET_CFP(), ary, num, (int)flag);
}
-/* concat two arrays */
+/* concat two arrays, without modifying first array.
+ * attempts to convert both objects to arrays using to_a.
+ */
DEFINE_INSN
concatarray
()
@@ -528,6 +523,32 @@ concatarray
ary = vm_concat_array(ary1, ary2);
}
+/* concat second array to first array.
+ * first argument must already be an array.
+ * attempts to convert second object to array using to_a.
+ */
+DEFINE_INSN
+concattoarray
+()
+(VALUE ary1, VALUE ary2)
+(VALUE ary)
+// attr bool leaf = false; /* has rb_check_array_type() */
+{
+ ary = vm_concat_to_array(ary1, ary2);
+}
+
+/* push given number of objects to array directly before. */
+DEFINE_INSN
+pushtoarray
+(rb_num_t num)
+(...)
+(VALUE val)
+// attr rb_snum_t sp_inc = -(rb_snum_t)num;
+{
+ const VALUE *objp = STACK_ADDR_FROM_TOP(num);
+ val = rb_ary_cat(*(objp-1), objp, num);
+}
+
/* call to_a on array ary to splat */
DEFINE_INSN
splatarray
@@ -539,6 +560,23 @@ splatarray
obj = vm_splat_array(flag, ary);
}
+/* call to_hash on hash to keyword splat before converting block */
+DEFINE_INSN
+splatkw
+()
+(VALUE hash, VALUE block)
+(VALUE obj, VALUE block)
+// attr bool leaf = false; /* has rb_to_hash_type() */
+// attr bool zjit_profile = true;
+{
+ if (NIL_P(hash)) {
+ obj = Qnil;
+ }
+ else {
+ obj = rb_to_hash_type(hash);
+ }
+}
+
/* put new Hash from n elements. n must be an even number. */
DEFINE_INSN
newhash
@@ -551,8 +589,7 @@ newhash
RUBY_DTRACE_CREATE_HOOK(HASH, num);
if (num) {
- val = rb_hash_new_with_size(num / 2);
- rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
+ val = rb_hash_new_with_bulk_insert(num, STACK_ADDR_FROM_TOP(num));
}
else {
val = rb_hash_new();
@@ -708,9 +745,10 @@ definedivar
()
(VALUE val)
// attr bool leaf = false;
+// attr bool zjit_profile = true;
{
val = Qnil;
- if (vm_getivar(GET_SELF(), id, GET_ISEQ(), ic, NULL, FALSE, Qundef) != Qundef) {
+ if (!UNDEF_P(vm_getivar(GET_SELF(), id, GET_ISEQ(), ic, NULL, FALSE, Qundef))) {
val = pushval;
}
}
@@ -766,13 +804,20 @@ defineclass
(VALUE val)
{
VALUE klass = vm_find_or_create_class_by_id(id, flags, cbase, super);
+ const rb_box_t *box = rb_current_box();
rb_iseq_check(class_iseq);
+ rb_cref_t *cref = vm_cref_push(ec, klass, NULL, FALSE, FALSE);
+
+ if (VM_DEFINECLASS_DYNAMIC_CREF_P(flags)) {
+ CREF_DYNAMIC_SET(cref);
+ }
+
/* enter scope */
vm_push_frame(ec, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass,
- GET_BLOCK_HANDLER(),
- (VALUE)vm_cref_push(ec, klass, NULL, FALSE, FALSE),
+ GC_GUARDED_PTR(box),
+ (VALUE)cref,
ISEQ_BODY(class_iseq)->iseq_encoded, GET_SP(),
ISEQ_BODY(class_iseq)->local_table_size,
ISEQ_BODY(class_iseq)->stack_max);
@@ -808,6 +853,7 @@ send
(CALL_DATA cd, ISEQ blockiseq)
(...)
(VALUE val)
+// attr bool zjit_profile = true;
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{
@@ -815,7 +861,34 @@ send
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
JIT_EXEC(ec, val);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
+ RESTORE_REGS();
+ NEXT_INSN();
+ }
+}
+
+/* invoke forward method. */
+DEFINE_INSN
+sendforward
+(CALL_DATA cd, ISEQ blockiseq)
+(...)
+(VALUE val)
+// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
+// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
+{
+ struct rb_forwarding_call_data adjusted_cd;
+ struct rb_callinfo adjusted_ci;
+
+ VALUE bh = vm_caller_setup_fwd_args(ec, GET_CFP(), cd, blockiseq, 0, &adjusted_cd, &adjusted_ci);
+
+ val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_method);
+ JIT_EXEC(ec, val);
+
+ if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
+ RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
+ }
+
+ if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
@@ -827,6 +900,7 @@ opt_send_without_block
(CALL_DATA cd)
(...)
(VALUE val)
+// attr bool zjit_profile = true;
// attr bool handles_sp = true;
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
@@ -835,12 +909,38 @@ opt_send_without_block
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
JIT_EXEC(ec, val);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
}
+/* Jump if "new" method has been defined by user */
+DEFINE_INSN
+opt_new
+(CALL_DATA cd, OFFSET dst)
+()
+()
+// attr bool leaf = false;
+{
+ VALUE argc = vm_ci_argc(cd->ci);
+ VALUE val = TOPN(argc);
+
+ // The bookkeeping slot should be empty.
+ RUBY_ASSERT(TOPN(argc + 1) == Qnil);
+
+ if (vm_method_cfunc_is(GET_CFP(), cd, val, rb_class_new_instance_pass_kw)) {
+ RB_DEBUG_COUNTER_INC(opt_new_hit);
+ val = rb_obj_alloc(val);
+ TOPN(argc) = val;
+ TOPN(argc + 1) = val;
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(opt_new_miss);
+ JUMP(dst);
+ }
+}
+
/* Convert object to string using to_s or equivalent. */
DEFINE_INSN
objtostring
@@ -848,10 +948,41 @@ objtostring
(VALUE recv)
(VALUE val)
// attr bool leaf = false;
+// attr bool zjit_profile = true;
{
- val = vm_objtostring(GET_ISEQ(), recv, cd);
+ val = vm_objtostring(GET_CFP(), recv, cd);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
+ CALL_SIMPLE_METHOD();
+ }
+}
+
+DEFINE_INSN
+opt_ary_freeze
+(VALUE ary, CALL_DATA cd)
+()
+(VALUE val)
+{
+ val = vm_opt_ary_freeze(ary, BOP_FREEZE, idFreeze);
+
+ if (UNDEF_P(val)) {
+ RUBY_DTRACE_CREATE_HOOK(ARRAY, RARRAY_LEN(ary));
+ PUSH(rb_ary_resurrect(ary));
+ CALL_SIMPLE_METHOD();
+ }
+}
+
+DEFINE_INSN
+opt_hash_freeze
+(VALUE hash, CALL_DATA cd)
+()
+(VALUE val)
+{
+ val = vm_opt_hash_freeze(hash, BOP_FREEZE, idFreeze);
+
+ if (UNDEF_P(val)) {
+ RUBY_DTRACE_CREATE_HOOK(HASH, RHASH_SIZE(hash) << 1);
+ PUSH(rb_hash_resurrect(hash));
CALL_SIMPLE_METHOD();
}
}
@@ -864,7 +995,7 @@ opt_str_freeze
{
val = vm_opt_str_freeze(str, BOP_FREEZE, idFreeze);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
PUSH(rb_str_resurrect(str));
CALL_SIMPLE_METHOD();
}
@@ -876,10 +1007,11 @@ opt_nil_p
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
- val = vm_opt_nil_p(GET_ISEQ(), cd, recv);
+ val = vm_opt_nil_p(GET_CFP(), cd, recv);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -892,15 +1024,37 @@ opt_str_uminus
{
val = vm_opt_str_freeze(str, BOP_UMINUS, idUMinus);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
PUSH(rb_str_resurrect(str));
CALL_SIMPLE_METHOD();
}
}
DEFINE_INSN
-opt_newarray_max
-(rb_num_t num)
+opt_duparray_send
+(VALUE ary, ID method, rb_num_t argc)
+(...)
+(VALUE val)
+/* This instruction typically has no funcalls. But it may compare array
+ * contents to each other which may call methods when necessary.
+ * No way to detect such method calls beforehand.
+ * We must mark it as not leaf. */
+// attr bool leaf = false; /* has rb_funcall() */
+// attr rb_snum_t sp_inc = 1 - (rb_snum_t)argc;
+// attr rb_snum_t comptime_sp_inc = 1 - (rb_snum_t)argc;
+{
+ switch (method) {
+ case idIncludeP:
+ val = vm_opt_duparray_include_p(ec, ary, TOPN(0));
+ break;
+ default:
+ rb_bug("unreachable");
+ }
+}
+
+DEFINE_INSN
+opt_newarray_send
+(rb_num_t num, rb_num_t method)
(...)
(VALUE val)
/* This instruction typically has no funcalls. But it compares array
@@ -909,36 +1063,89 @@ opt_newarray_max
* cannot but mark it being not leaf. */
// attr bool leaf = false; /* has rb_funcall() */
// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
-{
- val = vm_opt_newarray_max(ec, num, STACK_ADDR_FROM_TOP(num));
+// attr rb_snum_t comptime_sp_inc = 1 - (rb_snum_t)num;
+{
+ switch (method) {
+ case VM_OPT_NEWARRAY_SEND_HASH:
+ val = vm_opt_newarray_hash(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ case VM_OPT_NEWARRAY_SEND_MIN:
+ val = vm_opt_newarray_min(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ case VM_OPT_NEWARRAY_SEND_MAX:
+ val = vm_opt_newarray_max(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ case VM_OPT_NEWARRAY_SEND_INCLUDE_P:
+ val = vm_opt_newarray_include_p(ec, (long)num-1, STACK_ADDR_FROM_TOP(num), TOPN(0));
+ break;
+ case VM_OPT_NEWARRAY_SEND_PACK:
+ val = vm_opt_newarray_pack_buffer(ec, (long)num-1, STACK_ADDR_FROM_TOP(num), TOPN(0), Qundef);
+ break;
+ case VM_OPT_NEWARRAY_SEND_PACK_BUFFER:
+ val = vm_opt_newarray_pack_buffer(ec, (long)num-2, STACK_ADDR_FROM_TOP(num), TOPN(1), TOPN(0));
+ break;
+ default:
+ rb_bug("unreachable");
+ }
}
+/* super(args) # args.size => num */
DEFINE_INSN
-opt_newarray_min
-(rb_num_t num)
+invokesuper
+(CALL_DATA cd, ISEQ blockiseq)
(...)
(VALUE val)
-/* Same discussion as opt_newarray_max. */
-// attr bool leaf = false; /* has rb_funcall() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
-{
- val = vm_opt_newarray_min(ec, num, STACK_ADDR_FROM_TOP(num));
+// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
+// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
+// attr bool zjit_profile = true;
+{
+ struct rb_callinfo adjusted_ci = VM_CI_ON_STACK(vm_ci_mid(cd->ci),
+ vm_ci_flag(cd->ci),
+ vm_ci_argc(cd->ci),
+ vm_ci_kwarg(cd->ci));
+ const struct rb_callcache *original_cc = rbimpl_atomic_ptr_load((void **)&cd->cc, RBIMPL_ATOMIC_ACQUIRE);
+ struct rb_call_data adjusted_cd = {
+ .ci = &adjusted_ci,
+ .cc = original_cc,
+ };
+
+ VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), adjusted_cd.ci, blockiseq, true);
+ val = vm_sendish(ec, GET_CFP(), &adjusted_cd, bh, mexp_search_super);
+ JIT_EXEC(ec, val);
+
+ if (original_cc != adjusted_cd.cc && vm_cc_markable(adjusted_cd.cc)) {
+ rbimpl_atomic_ptr_store((volatile void **)&cd->cc, (void *)adjusted_cd.cc, RBIMPL_ATOMIC_RELEASE);
+ RB_OBJ_WRITTEN(GET_ISEQ(), Qundef, adjusted_cd.cc);
+ }
+
+ if (UNDEF_P(val)) {
+ RESTORE_REGS();
+ NEXT_INSN();
+ }
}
/* super(args) # args.size => num */
DEFINE_INSN
-invokesuper
+invokesuperforward
(CALL_DATA cd, ISEQ blockiseq)
(...)
(VALUE val)
// attr rb_snum_t sp_inc = sp_inc_of_sendish(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_sendish(ci);
{
- VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true);
- val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
+ struct rb_forwarding_call_data adjusted_cd;
+ struct rb_callinfo adjusted_ci;
+
+ VALUE bh = vm_caller_setup_fwd_args(ec, GET_CFP(), cd, blockiseq, 1, &adjusted_cd, &adjusted_ci);
+
+ val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_super);
JIT_EXEC(ec, val);
- if (val == Qundef) {
+ if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) {
+ RB_OBJ_WRITE(GET_ISEQ(), &cd->cc, adjusted_cd.cd.cc);
+ }
+
+ if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
@@ -953,12 +1160,13 @@ invokeblock
// attr bool handles_sp = true;
// attr rb_snum_t sp_inc = sp_inc_of_invokeblock(cd->ci);
// attr rb_snum_t comptime_sp_inc = sp_inc_of_invokeblock(ci);
+// attr bool zjit_profile = true;
{
VALUE bh = VM_BLOCK_HANDLER_NONE;
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_invokeblock);
JIT_EXEC(ec, val);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
RESTORE_REGS();
NEXT_INSN();
}
@@ -1025,7 +1233,7 @@ jump
()
()
/* Same discussion as leave. */
-// attr bool leaf = leafness_of_check_ints; /* has rb_threadptr_execute_interrupts() */
+// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
RUBY_VM_CHECK_INTS(ec);
JUMP(dst);
@@ -1038,7 +1246,7 @@ branchif
(VALUE val)
()
/* Same discussion as jump. */
-// attr bool leaf = leafness_of_check_ints; /* has rb_threadptr_execute_interrupts() */
+// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (RTEST(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -1053,7 +1261,7 @@ branchunless
(VALUE val)
()
/* Same discussion as jump. */
-// attr bool leaf = leafness_of_check_ints; /* has rb_threadptr_execute_interrupts() */
+// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (!RTEST(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -1068,7 +1276,7 @@ branchnil
(VALUE val)
()
/* Same discussion as jump. */
-// attr bool leaf = leafness_of_check_ints; /* has rb_threadptr_execute_interrupts() */
+// attr bool leaf = false; /* has rb_threadptr_execute_interrupts() */
{
if (NIL_P(val)) {
RUBY_VM_CHECK_INTS(ec);
@@ -1076,6 +1284,56 @@ branchnil
}
}
+/* same as jump, but without interrupt check */
+DEFINE_INSN
+jump_without_ints
+(OFFSET dst)
+()
+()
+// attr bool leaf = true;
+{
+ JUMP(dst);
+}
+
+/* same as branchif, but without interrupt check */
+DEFINE_INSN
+branchif_without_ints
+(OFFSET dst)
+(VALUE val)
+()
+// attr bool leaf = true;
+{
+ if (RTEST(val)) {
+ JUMP(dst);
+ }
+}
+
+/* same as branchunless, but without interrupt check */
+DEFINE_INSN
+branchunless_without_ints
+(OFFSET dst)
+(VALUE val)
+()
+// attr bool leaf = true;
+{
+ if (!RTEST(val)) {
+ JUMP(dst);
+ }
+}
+
+/* same as branchnil, but without interrupt check */
+DEFINE_INSN
+branchnil_without_ints
+(OFFSET dst)
+(VALUE val)
+()
+// attr bool leaf = true;
+{
+ if (NIL_P(val)) {
+ JUMP(dst);
+ }
+}
+
/**********************************************************/
/* for optimize */
/**********************************************************/
@@ -1113,10 +1371,11 @@ opt_plus
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_plus(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1127,10 +1386,11 @@ opt_minus
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_minus(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1141,10 +1401,11 @@ opt_mult
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_mult(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1158,10 +1419,11 @@ opt_div
/* In case of division by zero, it raises. Thus
* ZeroDivisionError#initialize is called. */
// attr bool leaf = false;
+// attr bool zjit_profile = true;
{
val = vm_opt_div(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1174,10 +1436,11 @@ opt_mod
(VALUE val)
/* Same discussion as opt_div. */
// attr bool leaf = false;
+// attr bool zjit_profile = true;
{
val = vm_opt_mod(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1188,10 +1451,11 @@ opt_eq
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
- val = opt_equality(GET_ISEQ(), recv, obj, cd);
+ val = opt_equality(GET_CFP(), recv, obj, cd);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1202,10 +1466,11 @@ opt_neq
(CALL_DATA cd_eq, CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
- val = vm_opt_neq(GET_ISEQ(), cd, cd_eq, recv, obj);
+ val = vm_opt_neq(GET_CFP(), cd, cd_eq, recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1216,10 +1481,11 @@ opt_lt
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_lt(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1230,10 +1496,11 @@ opt_le
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_le(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1244,10 +1511,11 @@ opt_gt
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_gt(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1258,10 +1526,11 @@ opt_ge
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_ge(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1276,10 +1545,11 @@ opt_ltlt
* string. Then what happens if that codepoint does not exist in the
* string's encoding? Of course an exception. That's not a leaf. */
// attr bool leaf = false; /* has "invalid codepoint" exception */
+// attr bool zjit_profile = true;
{
val = vm_opt_ltlt(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1290,10 +1560,11 @@ opt_and
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_and(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1304,10 +1575,11 @@ opt_or
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_or(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1323,10 +1595,11 @@ opt_aref
* default_proc. This is a method call. So opt_aref is
* (surprisingly) not leaf. */
// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
+// attr bool zjit_profile = true;
{
val = vm_opt_aref(recv, obj);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1340,48 +1613,11 @@ opt_aset
/* This is another story than opt_aref. When vm_opt_aset() resorts
* to rb_hash_aset(), which should call #hash for `obj`. */
// attr bool leaf = false; /* has rb_funcall() */ /* calls #hash */
+// attr bool zjit_profile = true;
{
val = vm_opt_aset(recv, obj, set);
- if (val == Qundef) {
- CALL_SIMPLE_METHOD();
- }
-}
-
-/* recv[str] = set */
-DEFINE_INSN
-opt_aset_with
-(VALUE key, CALL_DATA cd)
-(VALUE recv, VALUE val)
-(VALUE val)
-/* Same discussion as opt_aset. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #hash */
-{
- VALUE tmp = vm_opt_aset_with(recv, key, val);
-
- if (tmp != Qundef) {
- val = tmp;
- }
- else {
- TOPN(0) = rb_str_resurrect(key);
- PUSH(val);
- CALL_SIMPLE_METHOD();
- }
-}
-
-/* recv[str] */
-DEFINE_INSN
-opt_aref_with
-(VALUE key, CALL_DATA cd)
-(VALUE recv)
-(VALUE val)
-/* Same discussion as opt_aref. */
-// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
-{
- val = vm_opt_aref_with(recv, key);
-
- if (val == Qundef) {
- PUSH(rb_str_resurrect(key));
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1392,10 +1628,11 @@ opt_length
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_length(recv, BOP_LENGTH);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1406,10 +1643,11 @@ opt_size
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_length(recv, BOP_SIZE);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1420,10 +1658,11 @@ opt_empty_p
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_empty_p(recv);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1434,10 +1673,11 @@ opt_succ
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
val = vm_opt_succ(recv);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1448,10 +1688,11 @@ opt_not
(CALL_DATA cd)
(VALUE recv)
(VALUE val)
+// attr bool zjit_profile = true;
{
- val = vm_opt_not(GET_ISEQ(), cd, recv);
+ val = vm_opt_not(GET_CFP(), cd, recv);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
@@ -1463,35 +1704,15 @@ opt_regexpmatch2
(VALUE obj2, VALUE obj1)
(VALUE val)
// attr bool leaf = false; /* match_at() has rb_thread_check_ints() */
+// attr bool zjit_profile = true;
{
val = vm_opt_regexpmatch2(obj2, obj1);
- if (val == Qundef) {
+ if (UNDEF_P(val)) {
CALL_SIMPLE_METHOD();
}
}
-/* call native compiled method */
-DEFINE_INSN_IF(SUPPORT_CALL_C_FUNCTION)
-opt_call_c_function
-(rb_insn_func_t funcptr)
-()
-()
-// attr bool leaf = false; /* anything can happen inside */
-// attr bool handles_sp = true;
-{
- reg_cfp = (funcptr)(ec, reg_cfp);
-
- if (reg_cfp == 0) {
- VALUE err = ec->errinfo;
- ec->errinfo = Qnil;
- THROW_EXCEPTION(err);
- }
-
- RESTORE_REGS();
- NEXT_INSN();
-}
-
/* call specific function with args */
DEFINE_INSN
invokebuiltin
diff --git a/internal.h b/internal.h
index c66e057f60..002044cfa1 100644
--- a/internal.h
+++ b/internal.h
@@ -40,10 +40,6 @@
#undef RClass
#undef RCLASS_SUPER
-/* internal/gc.h */
-#undef NEWOBJ_OF
-#undef RB_NEWOBJ_OF
-
/* internal/hash.h */
#undef RHASH_IFNONE
#undef RHASH_SIZE
@@ -62,9 +58,6 @@
/* internal/array.h */
#define rb_ary_new_from_args(...) rb_nonexistent_symbol(__VA_ARGS__)
-/* internal/io.h */
-#define rb_io_fptr_finalize(...) rb_nonexistent_symbol(__VA_ARGS__)
-
/* internal/string.h */
#define rb_fstring_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
diff --git a/internal/array.h b/internal/array.h
index 3aeb1be2dd..a2cd06f2e3 100644
--- a/internal/array.h
+++ b/internal/array.h
@@ -23,6 +23,7 @@
#define RARRAY_PTR_IN_USE_FLAG FL_USER14
/* array.c */
+VALUE rb_ary_hash_values(long len, const VALUE *elements);
VALUE rb_ary_last(int, const VALUE *, VALUE);
void rb_ary_set_len(VALUE, long);
void rb_ary_delete_same(VALUE, VALUE);
@@ -36,11 +37,11 @@ size_t rb_ary_size_as_embedded(VALUE ary);
void rb_ary_make_embedded(VALUE ary);
bool rb_ary_embeddable_p(VALUE ary);
VALUE rb_ary_diff(VALUE ary1, VALUE ary2);
+VALUE rb_ary_compact_bang(VALUE ary);
+RUBY_EXTERN VALUE rb_cArray_empty_frozen;
static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
static inline bool ARY_PTR_USING_P(VALUE ary);
-static inline void RARY_TRANSIENT_SET(VALUE ary);
-static inline void RARY_TRANSIENT_UNSET(VALUE ary);
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
VALUE rb_check_to_array(VALUE ary);
@@ -55,7 +56,7 @@ static inline VALUE
rb_ary_entry_internal(VALUE ary, long offset)
{
long len = RARRAY_LEN(ary);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
if (len == 0) return Qnil;
if (offset < 0) {
offset += len;
@@ -117,22 +118,6 @@ ARY_SHARED_ROOT_REFCNT(VALUE ary)
return RARRAY(ary)->as.heap.aux.capa;
}
-static inline void
-RARY_TRANSIENT_SET(VALUE ary)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-RARY_TRANSIENT_UNSET(VALUE ary)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#endif
-}
-
#undef rb_ary_new_from_args
#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
# /* Skip it; clang -pedantic doesn't like the following */
@@ -153,9 +138,18 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline VALUE
RARRAY_AREF(VALUE ary, long i)
{
+ VALUE val;
RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
- return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
+ RUBY_ASSERT(i < RARRAY_LEN(ary));
+
+ RBIMPL_WARNING_PUSH();
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13
+ RBIMPL_WARNING_IGNORED(-Warray-bounds);
+#endif
+ val = RARRAY_CONST_PTR(ary)[i];
+ RBIMPL_WARNING_POP();
+ return val;
}
#endif /* INTERNAL_ARRAY_H */
diff --git a/internal/basic_operators.h b/internal/basic_operators.h
index 12a0475990..493d2fa7f7 100644
--- a/internal/basic_operators.h
+++ b/internal/basic_operators.h
@@ -24,6 +24,7 @@ enum ruby_basic_operators {
BOP_SUCC,
BOP_GT,
BOP_GE,
+ BOP_GTGT,
BOP_NOT,
BOP_NEQ,
BOP_MATCH,
@@ -31,11 +32,14 @@ enum ruby_basic_operators {
BOP_UMINUS,
BOP_MAX,
BOP_MIN,
+ BOP_HASH,
BOP_CALL,
BOP_AND,
BOP_OR,
BOP_CMP,
BOP_DEFAULT,
+ BOP_PACK,
+ BOP_INCLUDE_P,
BOP_LAST_
};
diff --git a/internal/bignum.h b/internal/bignum.h
index db8d3aee83..7389a17c74 100644
--- a/internal/bignum.h
+++ b/internal/bignum.h
@@ -9,6 +9,7 @@
* @brief Internal header for Bignums.
*/
#include "ruby/internal/config.h" /* for HAVE_LIBGMP */
+#include "internal/compilers.h" /* for FLEX_ARY_LEN */
#include <stddef.h> /* for size_t */
#ifdef HAVE_SYS_TYPES_H
@@ -76,26 +77,17 @@
#define RBIGNUM(obj) ((struct RBignum *)(obj))
#define BIGNUM_SIGN_BIT FL_USER1
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
-#define BIGNUM_EMBED_LEN_NUMBITS 3
+
+/* This is likely more bits than we need today and will also need adjustment if
+ * we change GC slot sizes.
+ */
+#define BIGNUM_EMBED_LEN_NUMBITS 9
#define BIGNUM_EMBED_LEN_MASK \
- (~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
+ (RUBY_FL_USER11 | RUBY_FL_USER10 | RUBY_FL_USER9 | RUBY_FL_USER8 | RUBY_FL_USER7 | \
+ RUBY_FL_USER6 | RUBY_FL_USER5 | RUBY_FL_USER4 | RUBY_FL_USER3)
#define BIGNUM_EMBED_LEN_SHIFT \
(FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
-#ifndef BIGNUM_EMBED_LEN_MAX
-# if (SIZEOF_VALUE*RBIMPL_RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
-# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RBIMPL_RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
-# else
-# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
-# endif
-#endif
-
-enum rb_int_parse_flags {
- RB_INT_PARSE_SIGN = 0x01,
- RB_INT_PARSE_UNDERSCORE = 0x02,
- RB_INT_PARSE_PREFIX = 0x04,
- RB_INT_PARSE_ALL = 0x07,
- RB_INT_PARSE_DEFAULT = 0x07,
-};
+#define BIGNUM_EMBED_LEN_MAX (BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)
struct RBignum {
struct RBasic basic;
@@ -104,12 +96,18 @@ struct RBignum {
size_t len;
BDIGIT *digits;
} heap;
- BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
+ /* This is a length 1 array because:
+ * 1. GCC has a bug that does not optimize C flexible array members
+ * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
+ * 2. Zero length arrays are not supported by all compilers
+ */
+ BDIGIT ary[1];
} as;
};
/* bignum.c */
extern const char ruby_digitmap[];
+extern const char ruby_decimal_digit_pairs[];
double rb_big_fdiv_double(VALUE x, VALUE y);
VALUE rb_big_uminus(VALUE x);
VALUE rb_big_hash(VALUE);
@@ -121,6 +119,7 @@ VALUE rb_integer_float_eq(VALUE x, VALUE y);
VALUE rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception);
VALUE rb_big_comp(VALUE x);
VALUE rb_big_aref(VALUE x, VALUE y);
+VALUE rb_big_aref2(VALUE num, VALUE beg, VALUE len);
VALUE rb_big_abs(VALUE x);
VALUE rb_big_size_m(VALUE big);
VALUE rb_big_bit_length(VALUE big);
@@ -160,10 +159,15 @@ VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
VALUE rb_big2str_gmp(VALUE x, int base);
VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
#endif
-VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
RUBY_SYMBOL_EXPORT_END
+#if HAVE_LONG_LONG
+VALUE rb_ull2big(unsigned LONG_LONG n);
+VALUE rb_ll2big(LONG_LONG n);
+#endif
+
#if defined(HAVE_INT128_T)
+VALUE rb_uint128t2big(uint128_t n);
VALUE rb_int128t2big(int128_t n);
#endif
diff --git a/internal/bits.h b/internal/bits.h
index 6248e4cfa9..698ab3e219 100644
--- a/internal/bits.h
+++ b/internal/bits.h
@@ -30,13 +30,13 @@
#include <stdint.h> /* for uintptr_t */
#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
-#if MSC_VERSION_SINCE(1310)
+#ifdef _MSC_VER
# include <stdlib.h> /* for _byteswap_uint64 */
#endif
#if defined(HAVE_X86INTRIN_H)
# include <x86intrin.h> /* for _lzcnt_u64 */
-#elif MSC_VERSION_SINCE(1310)
+#elif defined(_MSC_VER)
# include <intrin.h> /* for the following intrinsics */
#endif
@@ -50,16 +50,13 @@
# pragma intrinsic(__lzcnt64)
#endif
-#if MSC_VERSION_SINCE(1310)
+#if defined(_MSC_VER)
# pragma intrinsic(_rotl)
# pragma intrinsic(_rotr)
# ifdef _WIN64
# pragma intrinsic(_rotl64)
# pragma intrinsic(_rotr64)
# endif
-#endif
-
-#if MSC_VERSION_SINCE(1400)
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# ifdef _WIN64
@@ -90,6 +87,7 @@
#define UNSIGNED_INTEGER_MAX(T) ((T)~(T)0)
+#ifndef MUL_OVERFLOW_SIGNED_INTEGER_P
#if __has_builtin(__builtin_mul_overflow_p)
# define MUL_OVERFLOW_P(a, b) \
__builtin_mul_overflow_p((a), (b), (__typeof__(a * b))0)
@@ -118,15 +116,100 @@
MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
#endif
-#ifdef MUL_OVERFLOW_P
+#if defined(MUL_OVERFLOW_P) && defined(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG)
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
+#else
+# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef MUL_OVERFLOW_P
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
#else
-# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
#endif
+#endif
+
+#ifndef ADD_OVERFLOW_SIGNED_INTEGER_P
+#if __has_builtin(__builtin_add_overflow_p)
+# define ADD_OVERFLOW_P(a, b) \
+ __builtin_add_overflow_p((a), (b), (__typeof__(a * b))0)
+#elif __has_builtin(__builtin_add_overflow)
+# define ADD_OVERFLOW_P(a, b) \
+ __extension__ ({ __typeof__(a) c; __builtin_add_overflow((a), (b), &c); })
+#endif
+
+#define ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (a) > 0 ? (b) > (max) - (a) : (b) < (min) - (a))
+
+#if __has_builtin(__builtin_add_overflow_p)
+/* __builtin_add_overflow_p can take bitfield */
+/* and GCC permits bitfields for integers other than int */
+# define ADD_OVERFLOW_FIXNUM_P(a, b) \
+ __extension__ ({ \
+ struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
+ __builtin_add_overflow_p((a), (b), c.fixnum); \
+ })
+#else
+# define ADD_OVERFLOW_FIXNUM_P(a, b) \
+ ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
+#endif
+
+#if defined(ADD_OVERFLOW_P) && defined(USE___BUILTIN_ADD_OVERFLOW_LONG_LONG)
+# define ADD_OVERFLOW_LONG_LONG_P(a, b) ADD_OVERFLOW_P(a, b)
+#else
+# define ADD_OVERFLOW_LONG_LONG_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef ADD_OVERFLOW_P
+# define ADD_OVERFLOW_LONG_P(a, b) ADD_OVERFLOW_P(a, b)
+# define ADD_OVERFLOW_INT_P(a, b) ADD_OVERFLOW_P(a, b)
+#else
+# define ADD_OVERFLOW_LONG_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
+# define ADD_OVERFLOW_INT_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
+#endif
+#endif
+
+#ifndef SUB_OVERFLOW_SIGNED_INTEGER_P
+#if __has_builtin(__builtin_sub_overflow_p)
+# define SUB_OVERFLOW_P(a, b) \
+ __builtin_sub_overflow_p((a), (b), (__typeof__(a * b))0)
+#elif __has_builtin(__builtin_sub_overflow)
+# define SUB_OVERFLOW_P(a, b) \
+ __extension__ ({ __typeof__(a) c; __builtin_sub_overflow((a), (b), &c); })
+#endif
+
+#define SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (b) > 0 ? (a) < (min) + (b) : (a) > (max) + (b))
+
+#if __has_builtin(__builtin_sub_overflow_p)
+/* __builtin_sub_overflow_p can take bitfield */
+/* and GCC permits bitfields for integers other than int */
+# define SUB_OVERFLOW_FIXNUM_P(a, b) \
+ __extension__ ({ \
+ struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
+ __builtin_sub_overflow_p((a), (b), c.fixnum); \
+ })
+#else
+# define SUB_OVERFLOW_FIXNUM_P(a, b) \
+ SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
+#endif
+
+#if defined(SUB_OVERFLOW_P) && defined(USE___BUILTIN_SUB_OVERFLOW_LONG_LONG)
+# define SUB_OVERFLOW_LONG_LONG_P(a, b) SUB_OVERFLOW_P(a, b)
+#else
+# define SUB_OVERFLOW_LONG_LONG_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef SUB_OVERFLOW_P
+# define SUB_OVERFLOW_LONG_P(a, b) SUB_OVERFLOW_P(a, b)
+# define SUB_OVERFLOW_INT_P(a, b) SUB_OVERFLOW_P(a, b)
+#else
+# define SUB_OVERFLOW_LONG_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
+# define SUB_OVERFLOW_INT_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
+#endif
+#endif
#ifdef HAVE_UINT128_T
# define bit_length(x) \
@@ -180,7 +263,7 @@ ruby_swap16(uint16_t x)
#if __has_builtin(__builtin_bswap16)
return __builtin_bswap16(x);
-#elif MSC_VERSION_SINCE(1310)
+#elif defined(_MSC_VER)
return _byteswap_ushort(x);
#else
@@ -195,7 +278,7 @@ ruby_swap32(uint32_t x)
#if __has_builtin(__builtin_bswap32)
return __builtin_bswap32(x);
-#elif MSC_VERSION_SINCE(1310)
+#elif defined(_MSC_VER)
return _byteswap_ulong(x);
#else
@@ -212,7 +295,7 @@ ruby_swap64(uint64_t x)
#if __has_builtin(__builtin_bswap64)
return __builtin_bswap64(x);
-#elif MSC_VERSION_SINCE(1310)
+#elif defined(_MSC_VER)
return _byteswap_uint64(x);
#else
@@ -237,7 +320,7 @@ nlz_int32(uint32_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u32(x);
-#elif MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
+#elif defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
@@ -266,7 +349,7 @@ nlz_int64(uint64_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u64(x);
-#elif defined(_WIN64) && MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
+#elif defined(_WIN64) && defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
@@ -394,9 +477,9 @@ rb_popcount32(uint32_t x)
#else
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
- x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
- x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
- x = (x & 0x0000003f) + (x >>16 & 0x0000003f);
+ x = (x & 0x07070707) + (x >> 4 & 0x07070707);
+ x = (x & 0x000f000f) + (x >> 8 & 0x000f000f);
+ x = (x & 0x0000001f) + (x >>16 & 0x0000001f);
return (unsigned int)x;
#endif
@@ -424,9 +507,9 @@ rb_popcount64(uint64_t x)
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
- x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
- x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
- x = (x & 0x000000000000007f) + (x >>32 & 0x000000000000007f);
+ x = (x & 0x000f000f000f000f) + (x >> 8 & 0x000f000f000f000f);
+ x = (x & 0x0000001f0000001f) + (x >>16 & 0x0000001f0000001f);
+ x = (x & 0x000000000000003f) + (x >>32 & 0x000000000000003f);
return (unsigned int)x;
#endif
@@ -452,7 +535,7 @@ ntz_int32(uint32_t x)
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u32(x);
-#elif MSC_VERSION_SINCE(1400)
+#elif defined(_MSC_VER)
/* :FIXME: Is there any way to issue TZCNT instead of BSF, apart from using
* assembly? Because issuing LZCNT seems possible (see nlz.h). */
unsigned long r;
@@ -474,7 +557,7 @@ ntz_int64(uint64_t x)
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u64(x);
-#elif defined(_WIN64) && MSC_VERSION_SINCE(1400)
+#elif defined(_WIN64) && defined(_MSC_VER)
unsigned long r;
return _BitScanForward64(&r, x) ? (int)r : 64;
@@ -522,10 +605,10 @@ RUBY_BIT_ROTL(VALUE v, int n)
#elif __has_builtin(__builtin_rotateleft64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateleft64(v, n);
-#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotl(v, n);
-#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotl64(v, n);
#elif defined(_lrotl) && (SIZEOF_VALUE == SIZEOF_LONG)
@@ -546,10 +629,10 @@ RUBY_BIT_ROTR(VALUE v, int n)
#elif __has_builtin(__builtin_rotateright64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateright64(v, n);
-#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotr(v, n);
-#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotr64(v, n);
#elif defined(_lrotr) && (SIZEOF_VALUE == SIZEOF_LONG)
diff --git a/internal/box.h b/internal/box.h
new file mode 100644
index 0000000000..c717dc4e24
--- /dev/null
+++ b/internal/box.h
@@ -0,0 +1,96 @@
+#ifndef INTERNAL_BOX_H /*-*-C-*-vi:se ft=c:*/
+#define INTERNAL_BOX_H
+
+#include "ruby/ruby.h" /* for VALUE */
+
+/**
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @brief Internal header for Ruby Box.
+ */
+struct rb_box_struct {
+ /*
+ * To retrieve Ruby::Box object that provides #require and so on.
+ * That is used from load.c, etc., that uses rb_box_t internally.
+ */
+ VALUE box_object;
+ long box_id; // box_id to generate ext filenames
+
+ VALUE top_self;
+
+ VALUE load_path;
+ VALUE load_path_snapshot;
+ VALUE load_path_check_cache;
+ VALUE expanded_load_path;
+ VALUE loaded_features;
+ VALUE loaded_features_snapshot;
+ VALUE loaded_features_realpaths;
+ VALUE loaded_features_realpath_map;
+ struct st_table *loaded_features_index;
+ struct st_table *loading_table;
+ VALUE ruby_dln_libmap;
+
+ VALUE gvar_tbl;
+ struct st_table *classext_cow_classes;
+
+ bool is_root;
+ bool is_user;
+ bool is_optional;
+};
+typedef struct rb_box_struct rb_box_t;
+
+struct rb_box_gem_flags {
+ bool gem;
+ bool error_highlight;
+ bool did_you_mean;
+ bool syntax_suggest;
+};
+typedef struct rb_box_gem_flags rb_box_gem_flags_t;
+
+#define BOX_OBJ_P(obj) (rb_obj_class(obj) == rb_cBox)
+
+#define BOX_MASTER_P(box) (box && !box->is_root && !box->is_user)
+#define BOX_MUTABLE_P(box) (box && (box->is_root || box->is_user))
+#define BOX_ROOT_P(box) (box && box->is_root)
+#define BOX_USER_P(box) (box && box->is_user)
+#define BOX_OPTIONAL_P(box) (box && box->is_optional)
+#define BOX_MAIN_P(box) (box && box->is_user && !box->is_optional)
+
+#define BOX_METHOD_DEFINITION(mdef) (mdef ? mdef->ns : NULL)
+#define BOX_METHOD_ENTRY(me) (me ? BOX_METHOD_DEFINITION(me->def) : NULL)
+#define BOX_CC(cc) (cc ? BOX_METHOD_ENTRY(cc->cme_) : NULL)
+#define BOX_CC_ENTRIES(ccs) (ccs ? BOX_METHOD_ENTRY(ccs->cme) : NULL)
+
+RUBY_EXTERN bool ruby_box_enabled;
+RUBY_EXTERN bool ruby_box_init_done;
+RUBY_EXTERN bool ruby_box_crashed;
+
+static inline bool
+rb_box_available(void)
+{
+ return ruby_box_enabled;
+}
+
+const rb_box_t * rb_master_box(void);
+const rb_box_t * rb_root_box(void);
+const rb_box_t * rb_main_box(void);
+const rb_box_t * rb_current_box(void);
+const rb_box_t * rb_loading_box(void);
+const rb_box_t * rb_current_box_in_crash_report(void);
+
+void rb_box_entry_mark(void *);
+void rb_box_gc_update_references(void *ptr);
+
+rb_box_t * rb_get_box_t(VALUE ns);
+VALUE rb_get_box_object(rb_box_t *ns);
+
+VALUE rb_box_local_extension(VALUE box, VALUE fname, VALUE path, VALUE *cleanup);
+void rb_box_cleanup_local_extension(VALUE cleanup);
+
+void rb_initialize_mandatory_boxes(void);
+void rb_box_init_done(void);
+void rb_box_set_gem_flags(rb_box_gem_flags_t *);
+#endif /* INTERNAL_BOX_H */
diff --git a/internal/class.h b/internal/class.h
index 9e47a339c1..0773dbad95 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -10,6 +10,7 @@
*/
#include "id.h"
#include "id_table.h" /* for struct rb_id_table */
+#include "internal/box.h"
#include "internal/serial.h" /* for rb_serial_t */
#include "internal/static_assert.h"
#include "internal/variable.h" /* for rb_class_ivar_set */
@@ -17,40 +18,40 @@
#include "ruby/intern.h" /* for rb_alloc_func_t */
#include "ruby/ruby.h" /* for struct RBasic */
#include "shape.h"
+#include "ruby_assert.h"
+#include "vm_core.h"
+#include "vm_sync.h"
+#include "method.h" /* for rb_cref_t */
#ifdef RCLASS_SUPER
# undef RCLASS_SUPER
#endif
-struct rb_subclass_entry {
- VALUE klass;
- struct rb_subclass_entry *next;
- struct rb_subclass_entry *prev;
-};
-typedef struct rb_subclass_entry rb_subclass_entry_t;
-
struct rb_cvar_class_tbl_entry {
+ VALUE imemo_flags;
uint32_t index;
rb_serial_t global_cvar_state;
+ const rb_cref_t *cref;
VALUE class_value;
};
struct rb_classext_struct {
- VALUE *iv_ptr;
+ const rb_box_t *box;
+ VALUE super;
+ VALUE fields_obj; // Fields are either ivar or other internal properties stored inline
+ VALUE classpath;
+ struct rb_id_table *m_tbl;
struct rb_id_table *const_tbl;
struct rb_id_table *callable_m_tbl;
- struct rb_id_table *cc_tbl; /* ID -> [[ci, cc1], cc2, ...] */
- struct rb_id_table *cvc_tbl;
- size_t superclass_depth;
+ VALUE cc_tbl; /* { ID => { cme, [cc1, cc2, ...] }, ... } */
+ VALUE cvc_tbl;
VALUE *superclasses;
- struct rb_subclass_entry *subclasses;
- struct rb_subclass_entry *subclass_entry;
/**
- * In the case that this is an `ICLASS`, `module_subclasses` points to the link
- * in the module's `subclasses` list that indicates that the klass has been
- * included. Hopefully that makes sense.
+ * imemo_subclasses VALUE tracking this class's subclasses.
+ * Only used in prime classext. Lazily allocated on first subclass addition.
*/
- struct rb_subclass_entry *module_subclass_entry;
+ VALUE subclasses;
+
const VALUE origin_;
const VALUE refined_class;
union {
@@ -60,15 +61,19 @@ struct rb_classext_struct {
struct {
VALUE attached_object;
} singleton_class;
+ struct {
+ const VALUE includer;
+ } iclass;
} as;
- const VALUE includer;
-#if !SHAPE_IN_BASIC_FLAGS
- shape_id_t shape_id;
-#endif
- uint32_t max_iv_count;
- unsigned char variation_count;
- bool permanent_classpath;
- VALUE classpath;
+ uint16_t superclass_depth;
+ attr_index_t max_iv_count;
+ uint8_t variation_count;
+ bool permanent_classpath : 1;
+ bool shared_const_tbl : 1;
+ bool iclass_is_origin : 1;
+ bool iclass_origin_shared_mtbl : 1;
+ bool superclasses_with_self : 1;
+ bool expect_no_ivar : 1;
};
typedef struct rb_classext_struct rb_classext_t;
@@ -76,62 +81,366 @@ STATIC_ASSERT(shape_max_variations, SHAPE_MAX_VARIATIONS < (1 << (sizeof(((rb_cl
struct RClass {
struct RBasic basic;
- VALUE super;
- struct rb_id_table *m_tbl;
-#if !RCLASS_EXT_EMBEDDED
- struct rb_classext_struct *ptr;
-#endif
+ VALUE object_id;
+ /*
+ * If box_classext_tbl is NULL, then the prime classext is readable (because no other classext exists).
+ * For the check whether writable or not, check flag RCLASS_PRIME_CLASSEXT_WRITABLE
+ */
};
-#if RCLASS_EXT_EMBEDDED
-// Assert that classes can be embedded in size_pools[2] (which has 160B slot size)
-STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass) + sizeof(rb_classext_t) <= 4 * RVALUE_SIZE);
-#endif
+struct RClass_and_rb_classext_t {
+ struct RClass rclass;
+ rb_classext_t classext;
+};
-#if RCLASS_EXT_EMBEDDED
-# define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
-#else
-# define RCLASS_EXT(c) (RCLASS(c)->ptr)
+#if SIZEOF_VALUE >= SIZEOF_LONG_LONG
+// Assert that classes can be embedded in heaps[3] (256B slot size on 64-bit).
+// On 32bit platforms there is no variable width allocation so it doesn't matter.
+STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass_and_rb_classext_t) <= 256);
#endif
-#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
-#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
-#define RCLASS_IVPTR(c) (RCLASS_EXT(c)->iv_ptr)
-#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
-#define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
-#define RCLASS_CVC_TBL(c) (RCLASS_EXT(c)->cvc_tbl)
-#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
-#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
-#define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
-#define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
-#define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
-#define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
-#define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT(c)->superclass_depth)
-#define RCLASS_SUPERCLASSES(c) (RCLASS_EXT(c)->superclasses)
-#define RCLASS_ATTACHED_OBJECT(c) (RCLASS_EXT(c)->as.singleton_class.attached_object)
-
-#define RICLASS_IS_ORIGIN FL_USER0
-#define RCLASS_CLONED FL_USER1
-#define RCLASS_SUPERCLASSES_INCLUDE_SELF FL_USER2
-#define RICLASS_ORIGIN_SHARED_MTBL FL_USER3
+
+struct RClass_boxable {
+ struct RClass_and_rb_classext_t base;
+ st_table *box_classext_tbl; // box_object -> (rb_classext_t *)
+};
+
+static const uint16_t RCLASS_MAX_SUPERCLASS_DEPTH = ((uint16_t)-1);
+
+static inline bool RCLASS_SINGLETON_P(VALUE klass);
+
+static inline bool RCLASS_PRIME_CLASSEXT_READABLE_P(VALUE obj);
+static inline bool RCLASS_PRIME_CLASSEXT_WRITABLE_P(VALUE obj);
+static inline void RCLASS_SET_PRIME_CLASSEXT_WRITABLE(VALUE obj, bool writable);
+
+#define RCLASS_EXT_PRIME(c) (&((struct RClass_and_rb_classext_t*)(c))->classext)
+#define RCLASS_EXT_PRIME_P(ext, c) (&((struct RClass_and_rb_classext_t*)(c))->classext == ext)
+
+static inline rb_classext_t * RCLASS_EXT_READABLE_IN_BOX(VALUE obj, const rb_box_t *box);
+static inline rb_classext_t * RCLASS_EXT_READABLE(VALUE obj);
+static inline rb_classext_t * RCLASS_EXT_WRITABLE_IN_BOX(VALUE obj, const rb_box_t *box);
+static inline rb_classext_t * RCLASS_EXT_WRITABLE(VALUE obj);
+
+// Raw accessor
+#define RCLASSEXT_BOX(ext) (ext->box)
+#define RCLASSEXT_SUPER(ext) (ext->super)
+#define RCLASSEXT_FIELDS(ext) (ext->fields_obj ? ROBJECT_FIELDS(ext->fields_obj) : NULL)
+#define RCLASSEXT_FIELDS_OBJ(ext) (ext->fields_obj)
+#define RCLASSEXT_M_TBL(ext) (ext->m_tbl)
+#define RCLASSEXT_CONST_TBL(ext) (ext->const_tbl)
+#define RCLASSEXT_CALLABLE_M_TBL(ext) (ext->callable_m_tbl)
+#define RCLASSEXT_CC_TBL(ext) (ext->cc_tbl)
+#define RCLASSEXT_CVC_TBL(ext) (ext->cvc_tbl)
+#define RCLASSEXT_SUPERCLASS_DEPTH(ext) (ext->superclass_depth)
+#define RCLASSEXT_SUPERCLASSES(ext) (ext->superclasses)
+#define RCLASSEXT_SUBCLASSES(ext) (ext->subclasses)
+#define RCLASSEXT_ORIGIN(ext) (ext->origin_)
+#define RCLASSEXT_REFINED_CLASS(ext) (ext->refined_class)
+// class.allocator/singleton_class.attached_object are not accessed directly via RCLASSEXT_*
+#define RCLASSEXT_INCLUDER(ext) (ext->as.iclass.includer)
+#define RCLASSEXT_PERMANENT_CLASSPATH(ext) (ext->permanent_classpath)
+#define RCLASSEXT_SHARED_CONST_TBL(ext) (ext->shared_const_tbl)
+#define RCLASSEXT_ICLASS_IS_ORIGIN(ext) (ext->iclass_is_origin)
+#define RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext) (ext->iclass_origin_shared_mtbl)
+#define RCLASSEXT_SUPERCLASSES_WITH_SELF(ext) (ext->superclasses_with_self)
+#define RCLASSEXT_CLASSPATH(ext) (ext->classpath)
+
+static inline void RCLASSEXT_SET_ORIGIN(rb_classext_t *ext, VALUE klass, VALUE origin);
+static inline void RCLASSEXT_SET_INCLUDER(rb_classext_t *ext, VALUE klass, VALUE includer);
+
+/* Prime classext entry accessor for very specific reason */
+#define RCLASS_PRIME_BOX(c) (RCLASS_EXT_PRIME(c)->box)
+// To invalidate CC by inserting&invalidating method entry into tables containing the target cme
+// See clear_method_cache_by_id_in_class()
+#define RCLASS_PRIME_FIELDS_OBJ(c) (RCLASS_EXT_PRIME(c)->fields_obj)
+#define RCLASS_PRIME_M_TBL(c) (RCLASS_EXT_PRIME(c)->m_tbl)
+#define RCLASS_PRIME_CONST_TBL(c) (RCLASS_EXT_PRIME(c)->const_tbl)
+#define RCLASS_PRIME_CALLABLE_M_TBL(c) (RCLASS_EXT_PRIME(c)->callable_m_tbl)
+#define RCLASS_PRIME_CC_TBL(c) (RCLASS_EXT_PRIME(c)->cc_tbl)
+#define RCLASS_M_TBL_NOT_PRIME_P(c, tbl) (RCLASS_EXT_PRIME(c)->m_tbl != tbl)
+#define RCLASS_CALLABLE_M_TBL_NOT_PRIME_P(c, tbl) (RCLASS_EXT_PRIME(c)->callable_m_tbl != tbl)
+#define RCLASS_CC_TBL_NOT_PRIME_P(c, tbl) (RCLASS_EXT_PRIME(c)->cc_tbl != tbl)
+
+// Read accessor, regarding box
+#define RCLASS_SUPER(c) (RCLASS_EXT_READABLE(c)->super)
+#define RCLASS_M_TBL(c) (RCLASS_EXT_READABLE(c)->m_tbl)
+#define RCLASS_CONST_TBL(c) (RCLASS_EXT_READABLE(c)->const_tbl)
+/*
+ * Both cc_tbl/callable_m_tbl are cache-like and always be changed when referreed,
+ * so always those should be writable.
+ */
+#define RCLASS_CVC_TBL(c) (RCLASS_EXT_READABLE(c)->cvc_tbl)
+#define RCLASS_SUBCLASSES(c) (RCLASS_EXT_PRIME(c)->subclasses)
+#define RCLASS_ORIGIN(c) (RCLASS_EXT_READABLE(c)->origin_)
+#define RICLASS_IS_ORIGIN_P(c) (RCLASS_EXT_READABLE(c)->iclass_is_origin)
+#define RCLASS_PERMANENT_CLASSPATH_P(c) (RCLASS_EXT_READABLE(c)->permanent_classpath)
+#define RCLASS_CLASSPATH(c) (RCLASS_EXT_READABLE(c)->classpath)
+
+// Superclasses can't be changed after initialization
+#define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT_PRIME(c)->superclass_depth)
+#define RCLASS_SUPERCLASSES(c) (RCLASS_EXT_PRIME(c)->superclasses)
+#define RCLASS_SUPERCLASSES_WITH_SELF_P(c) (RCLASS_EXT_PRIME(c)->superclasses_with_self)
+
+// Ruby Box doesn't make changes on these refined_class/attached_object/includer
+#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT_PRIME(c)->refined_class)
+#define RCLASS_ATTACHED_OBJECT(c) (RCLASS_EXT_PRIME(c)->as.singleton_class.attached_object)
+#define RCLASS_INCLUDER(c) (RCLASS_EXT_PRIME(c)->as.iclass.includer)
+
+// max IV count and variation count are just hints, so they don't need to be per-box
+#define RCLASS_MAX_IV_COUNT(ext) (RCLASS_EXT_PRIME(ext)->max_iv_count)
+#define RCLASS_VARIATION_COUNT(ext) (RCLASS_EXT_PRIME(ext)->variation_count)
+
+// Writable classext entries (instead of RCLASS_SET_*) because member data will be operated directly
+#define RCLASS_WRITABLE_M_TBL(c) (RCLASS_EXT_WRITABLE(c)->m_tbl)
+#define RCLASS_WRITABLE_CONST_TBL(c) (RCLASS_EXT_WRITABLE(c)->const_tbl)
+#define RCLASS_WRITABLE_CALLABLE_M_TBL(c) (RCLASS_EXT_WRITABLE(c)->callable_m_tbl)
+#define RCLASS_WRITABLE_CC_TBL(c) (RCLASS_EXT_WRITABLE(c)->cc_tbl)
+#define RCLASS_WRITABLE_CVC_TBL(c) (RCLASS_EXT_WRITABLE(c)->cvc_tbl)
+// Subclasses are only in the prime classext (box-invariant)
+#define RCLASS_WRITABLE_SUBCLASSES(c) (RCLASS_EXT_PRIME(c)->subclasses)
+
+static inline void RCLASS_SET_SUPER(VALUE klass, VALUE super);
+static inline void RCLASS_WRITE_SUPER(VALUE klass, VALUE super);
+static inline void RCLASS_SET_CONST_TBL(VALUE klass, struct rb_id_table *table, bool shared);
+static inline void RCLASS_WRITE_CONST_TBL(VALUE klass, struct rb_id_table *table, bool shared);
+static inline void RCLASS_WRITE_CALLABLE_M_TBL(VALUE klass, struct rb_id_table *table);
+static inline void RCLASS_WRITE_CC_TBL(VALUE klass, VALUE table);
+static inline void RCLASS_SET_CVC_TBL(VALUE klass, VALUE table);
+static inline void RCLASS_WRITE_CVC_TBL(VALUE klass, VALUE table);
+
+static inline void RCLASS_WRITE_SUPERCLASSES(VALUE klass, size_t depth, VALUE *superclasses, bool with_self);
+static inline void RCLASS_SET_SUBCLASSES(VALUE klass, VALUE subclasses);
+
+static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
+static inline void RCLASS_WRITE_ORIGIN(VALUE klass, VALUE origin);
+static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass);
+static inline void RICLASS_WRITE_ORIGIN_SHARED_MTBL(VALUE iclass);
+static inline bool RICLASS_OWNS_M_TBL_P(VALUE iclass);
+
+static inline void RCLASS_SET_REFINED_CLASS(VALUE klass, VALUE refined);
+static inline rb_alloc_func_t RCLASS_ALLOCATOR(VALUE klass);
+static inline void RCLASS_SET_ALLOCATOR(VALUE klass, rb_alloc_func_t allocator);
+static inline VALUE RCLASS_SET_ATTACHED_OBJECT(VALUE klass, VALUE attached_object);
+
+static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
+static inline void RCLASS_SET_MAX_IV_COUNT(VALUE klass, attr_index_t count);
+static inline void RCLASS_SET_CLASSPATH(VALUE klass, VALUE classpath, bool permanent);
+static inline void RCLASS_WRITE_CLASSPATH(VALUE klass, VALUE classpath, bool permanent);
+
+#define RCLASS_IS_ROOT FL_USER0
+// 1 is for RUBY_FL_SINGLETON or RMODULE_IS_REFINEMENT
+#define RCLASS_PRIME_CLASSEXT_WRITABLE FL_USER2
+#define RCLASS_IS_INITIALIZED FL_USER3
+// 3 is RMODULE_IS_REFINEMENT for RMODULE
+#define RCLASS_BOXABLE FL_USER4
+#define RCLASS_ALLOCATOR_DEFINED FL_USER5
+#define RCLASS_HAS_SUBCLASSES FL_USER6
+
+static inline st_table *
+RCLASS_CLASSEXT_TBL(VALUE klass)
+{
+ if (FL_TEST_RAW(klass, RCLASS_BOXABLE)) {
+ struct RClass_boxable *box_klass = (struct RClass_boxable *)klass;
+ return box_klass->box_classext_tbl;
+ }
+ return NULL;
+}
+
+static inline void
+RCLASS_SET_CLASSEXT_TBL(VALUE klass, st_table *tbl)
+{
+ RUBY_ASSERT(FL_TEST_RAW(klass, RCLASS_BOXABLE));
+ struct RClass_boxable *box_klass = (struct RClass_boxable *)klass;
+ box_klass->box_classext_tbl = tbl;
+}
+
+/* class.c */
+rb_classext_t * rb_class_duplicate_classext(rb_classext_t *orig, VALUE obj, const rb_box_t *box);
+void rb_class_ensure_writable(VALUE obj);
+
+void rb_class_set_box_classext(VALUE obj, const rb_box_t *box, rb_classext_t *ext);
+
+static inline int
+RCLASS_SET_BOX_CLASSEXT(VALUE obj, const rb_box_t *box, rb_classext_t *ext)
+{
+ int first_set = 0;
+ st_table *tbl = RCLASS_CLASSEXT_TBL(obj);
+ VM_ASSERT(BOX_MUTABLE_P(box)); // Setting non-prime classext never happens on the master box
+ VM_ASSERT(box->box_object);
+ VM_ASSERT(RCLASSEXT_BOX(ext) == box);
+ if (!tbl) {
+ tbl = st_init_numtable_with_size(1);
+ RCLASS_SET_CLASSEXT_TBL(obj, tbl);
+ }
+ if (rb_st_table_size(tbl) == 0) {
+ first_set = 1;
+ }
+
+ rb_class_set_box_classext(obj, box, ext);
+
+ return first_set;
+}
+
+#define VM_ASSERT_BOXABLE_TYPE(klass) \
+ VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS), "%s is not boxable type", rb_type_str(BUILTIN_TYPE(klass)))
+
+static inline bool
+RCLASS_PRIME_CLASSEXT_READABLE_P(VALUE klass)
+{
+ VM_ASSERT(klass != 0, "klass should be a valid object");
+ VM_ASSERT_BOXABLE_TYPE(klass);
+ // if the lookup table exists, then it means the prime classext is NOT directly readable.
+ return !FL_TEST_RAW(klass, RCLASS_BOXABLE) || RCLASS_CLASSEXT_TBL(klass) == NULL;
+}
+
+static inline bool
+RCLASS_PRIME_CLASSEXT_WRITABLE_P(VALUE klass)
+{
+ VM_ASSERT(klass != 0, "klass should be a valid object");
+ VM_ASSERT_BOXABLE_TYPE(klass);
+ RBIMPL_ASSUME(klass != 0);
+ return FL_TEST_RAW(klass, RCLASS_PRIME_CLASSEXT_WRITABLE);
+}
+
+static inline void
+RCLASS_SET_PRIME_CLASSEXT_WRITABLE(VALUE klass, bool writable)
+{
+ VM_ASSERT(klass != 0, "klass should be a valid object");
+ VM_ASSERT_BOXABLE_TYPE(klass);
+ if (writable) {
+ FL_SET_RAW(klass, RCLASS_PRIME_CLASSEXT_WRITABLE);
+ }
+ else {
+ FL_UNSET_RAW(klass, RCLASS_PRIME_CLASSEXT_WRITABLE);
+ }
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_TABLE_LOOKUP_INTERNAL(VALUE obj, const rb_box_t *box)
+{
+ st_data_t classext_ptr;
+ st_table *classext_tbl = RCLASS_CLASSEXT_TBL(obj);
+ if (classext_tbl) {
+ if (rb_st_lookup(classext_tbl, (st_data_t)box->box_object, &classext_ptr)) {
+ return (rb_classext_t *)classext_ptr;
+ }
+ }
+ return NULL;
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_READABLE_LOOKUP(VALUE obj, const rb_box_t *box)
+{
+ rb_classext_t *ext = RCLASS_EXT_TABLE_LOOKUP_INTERNAL(obj, box);
+ if (ext)
+ return ext;
+ // Classext for the ns not found. Refer the prime one instead.
+ return RCLASS_EXT_PRIME(obj);
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_READABLE_IN_BOX(VALUE obj, const rb_box_t *box)
+{
+ if (BOX_MASTER_P(box)
+ || RCLASS_PRIME_CLASSEXT_READABLE_P(obj)) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ return RCLASS_EXT_READABLE_LOOKUP(obj, box);
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_READABLE(VALUE obj)
+{
+ const rb_box_t *box;
+ if (RCLASS_PRIME_CLASSEXT_READABLE_P(obj)) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ // delay determining the current box to optimize for unmodified classes
+ box = rb_current_box();
+ if (BOX_MASTER_P(box)) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ return RCLASS_EXT_READABLE_LOOKUP(obj, box);
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_WRITABLE_LOOKUP(VALUE obj, const rb_box_t *box)
+{
+ rb_classext_t *ext;
+ int first_set = 0;
+
+ ext = RCLASS_EXT_TABLE_LOOKUP_INTERNAL(obj, box);
+ if (ext)
+ return ext;
+
+ RB_VM_LOCKING() {
+ // re-check the classext is not created to avoid the multi-thread race
+ ext = RCLASS_EXT_TABLE_LOOKUP_INTERNAL(obj, box);
+ if (!ext) {
+ ext = rb_class_duplicate_classext(RCLASS_EXT_PRIME(obj), obj, box);
+ first_set = RCLASS_SET_BOX_CLASSEXT(obj, box, ext);
+ if (first_set) {
+ // TODO: are there any case that a class/module become non-writable after its birthtime?
+ RCLASS_SET_PRIME_CLASSEXT_WRITABLE(obj, false);
+ }
+ }
+ }
+ return ext;
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_WRITABLE_IN_BOX(VALUE obj, const rb_box_t *box)
+{
+ if (BOX_MASTER_P(box)
+ || RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj)) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ return RCLASS_EXT_WRITABLE_LOOKUP(obj, box);
+}
+
+static inline rb_classext_t *
+RCLASS_EXT_WRITABLE(VALUE obj)
+{
+ const rb_box_t *box;
+ if (LIKELY(RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj))) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ // delay determining the current box to optimize for unmodified classes
+ box = rb_current_box();
+ if (BOX_MASTER_P(box)) {
+ return RCLASS_EXT_PRIME(obj);
+ }
+ return RCLASS_EXT_WRITABLE_LOOKUP(obj, box);
+}
+
+static inline void
+RCLASSEXT_SET_ORIGIN(rb_classext_t *ext, VALUE klass, VALUE origin)
+{
+ RB_OBJ_WRITE(klass, &(RCLASSEXT_ORIGIN(ext)), origin);
+}
+
+static inline void
+RCLASSEXT_SET_INCLUDER(rb_classext_t *ext, VALUE klass, VALUE includer)
+{
+ RUBY_ASSERT(RB_TYPE_P(klass, T_ICLASS));
+ RB_OBJ_WRITE(klass, &(RCLASSEXT_INCLUDER(ext)), includer);
+}
/* class.c */
+typedef void rb_class_classext_foreach_callback_func(rb_classext_t *classext, bool is_prime, VALUE box_value, void *arg);
+void rb_class_classext_foreach(VALUE klass, rb_class_classext_foreach_callback_func *func, void *arg);
void rb_class_subclass_add(VALUE super, VALUE klass);
-void rb_class_remove_from_super_subclasses(VALUE);
+void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
void rb_class_update_superclasses(VALUE);
-size_t rb_class_superclasses_memsize(VALUE);
-void rb_class_remove_subclass_head(VALUE);
int rb_singleton_class_internal_p(VALUE sklass);
+VALUE rb_class_set_super(VALUE klass, VALUE super);
VALUE rb_class_boot(VALUE);
VALUE rb_class_s_alloc(VALUE klass);
VALUE rb_module_s_alloc(VALUE klass);
-void rb_module_set_initialized(VALUE module);
+void rb_class_set_initialized(VALUE klass);
void rb_module_check_initializable(VALUE module);
VALUE rb_make_metaclass(VALUE, VALUE);
VALUE rb_include_class_new(VALUE, VALUE);
-void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
-void rb_class_detach_subclasses(VALUE);
-void rb_class_detach_module_subclasses(VALUE);
-void rb_class_remove_from_module_subclasses(VALUE);
+VALUE rb_define_class_id_under_no_pin(VALUE outer, ID id, VALUE super);
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
@@ -141,93 +450,295 @@ VALUE rb_special_singleton_class(VALUE);
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
VALUE rb_singleton_class_get(VALUE obj);
void rb_undef_methods_from(VALUE klass, VALUE super);
-
-static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
-static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass);
-static inline VALUE RCLASS_SUPER(VALUE klass);
-static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
-static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
-
VALUE rb_class_inherited(VALUE, VALUE);
VALUE rb_keyword_error_new(const char *, VALUE);
+rb_classext_t *rb_class_unlink_classext(VALUE klass, const rb_box_t *box);
+void rb_class_classext_free(VALUE klass, rb_classext_t *ext, bool is_prime);
+void rb_iclass_classext_free(VALUE klass, rb_classext_t *ext, bool is_prime);
+
+RUBY_SYMBOL_EXPORT_BEGIN
+
+/* for objspace */
+VALUE rb_class_super_of(VALUE klass);
+VALUE rb_class_singleton_p(VALUE klass);
+unsigned char rb_class_variation_count(VALUE klass);
+
+RUBY_SYMBOL_EXPORT_END
+
+static inline bool
+RCLASS_SINGLETON_P(VALUE klass)
+{
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS));
+ return RB_BUILTIN_TYPE(klass) == T_CLASS && FL_TEST_RAW(klass, FL_SINGLETON);
+}
+
+static inline void
+RCLASS_SET_SUPER(VALUE klass, VALUE super)
+{
+ RB_OBJ_WRITE(klass, &RCLASSEXT_SUPER(RCLASS_EXT_PRIME(klass)), super);
+}
+
+static inline void
+RCLASS_WRITE_SUPER(VALUE klass, VALUE super)
+{
+ RB_OBJ_WRITE(klass, &RCLASSEXT_SUPER(RCLASS_EXT_WRITABLE(klass)), super);
+}
+
+static inline VALUE
+RCLASS_WRITABLE_ENSURE_FIELDS_OBJ(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ rb_classext_t *ext = RCLASS_EXT_WRITABLE(obj);
+ if (!ext->fields_obj) {
+ RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(obj, ROOT_SHAPE_ID, true));
+ }
+ return ext->fields_obj;
+}
+
+static inline VALUE
+RCLASS_WRITABLE_FIELDS_OBJ(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ return RCLASSEXT_FIELDS_OBJ(RCLASS_EXT_WRITABLE(obj));
+}
+
+static inline void
+RCLASSEXT_SET_FIELDS_OBJ(VALUE obj, rb_classext_t *ext, VALUE fields_obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+
+ RB_OBJ_ATOMIC_WRITE(obj, &ext->fields_obj, fields_obj);
+}
+
+static inline void
+RCLASS_WRITABLE_SET_FIELDS_OBJ(VALUE obj, VALUE fields_obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+
+ RCLASSEXT_SET_FIELDS_OBJ(obj, RCLASS_EXT_WRITABLE(obj), fields_obj);
+}
+
+static inline uint32_t
+RCLASS_FIELDS_COUNT(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+
+ VALUE fields_obj = RCLASS_WRITABLE_FIELDS_OBJ(obj);
+ if (fields_obj) {
+ if (rb_obj_shape_complex_p(fields_obj)) {
+ return (uint32_t)rb_st_table_size(rb_imemo_fields_complex_tbl(fields_obj));
+ }
+ else {
+ return RSHAPE_LEN(RBASIC_SHAPE_ID(fields_obj));
+ }
+ }
+ return 0;
+}
+
+static inline void
+RCLASS_SET_M_TBL(VALUE klass, struct rb_id_table *table)
+{
+ RCLASSEXT_M_TBL(RCLASS_EXT_PRIME(klass)) = table;
+}
+
+static inline void
+RCLASS_WRITE_M_TBL(VALUE klass, struct rb_id_table *table)
+{
+ RCLASSEXT_M_TBL(RCLASS_EXT_WRITABLE(klass)) = table;
+}
+
+static inline void
+RCLASS_SET_CONST_TBL(VALUE klass, struct rb_id_table *table, bool shared)
+{
+ rb_classext_t *ext = RCLASS_EXT_PRIME(klass);
+ RCLASSEXT_CONST_TBL(ext) = table;
+ if (shared)
+ RCLASSEXT_SHARED_CONST_TBL(ext) = true;
+}
+
+static inline void
+RCLASS_WRITE_CONST_TBL(VALUE klass, struct rb_id_table *table, bool shared)
+{
+ rb_classext_t *ext = RCLASS_EXT_WRITABLE(klass);
+ RCLASSEXT_CONST_TBL(ext) = table;
+ if (shared)
+ RCLASSEXT_SHARED_CONST_TBL(ext) = true;
+}
+
+static inline void
+RCLASS_WRITE_CALLABLE_M_TBL(VALUE klass, struct rb_id_table *table)
+{
+ RCLASSEXT_CALLABLE_M_TBL(RCLASS_EXT_WRITABLE(klass)) = table;
+}
+
+static inline void
+RCLASS_WRITE_CC_TBL(VALUE klass, VALUE table)
+{
+ RB_OBJ_ATOMIC_WRITE(klass, &RCLASSEXT_CC_TBL(RCLASS_EXT_WRITABLE(klass)), table);
+}
+
+static inline void
+RCLASS_SET_CVC_TBL(VALUE klass, VALUE table)
+{
+ RB_OBJ_ATOMIC_WRITE(klass, &RCLASSEXT_CVC_TBL(RCLASS_EXT_PRIME(klass)), table);
+}
+
+static inline void
+RCLASS_WRITE_CVC_TBL(VALUE klass, VALUE table)
+{
+ RB_OBJ_ATOMIC_WRITE(klass, &RCLASSEXT_CVC_TBL(RCLASS_EXT_WRITABLE(klass)), table);
+}
+
+static inline void
+RCLASS_SET_REFINED_CLASS(VALUE klass, VALUE refined)
+{
+ RB_OBJ_WRITE(klass, &RCLASSEXT_REFINED_CLASS(RCLASS_EXT_PRIME(klass)), refined);
+}
+
static inline rb_alloc_func_t
RCLASS_ALLOCATOR(VALUE klass)
{
- if (FL_TEST_RAW(klass, FL_SINGLETON)) {
- return NULL;
- }
- return RCLASS_EXT(klass)->as.class.allocator;
+ RBIMPL_ASSERT_TYPE(klass, T_CLASS);
+ RUBY_ASSERT(!RCLASS_SINGLETON_P(klass));
+ return RCLASS_EXT_PRIME(klass)->as.class.allocator;
}
static inline void
RCLASS_SET_ALLOCATOR(VALUE klass, rb_alloc_func_t allocator)
{
- assert(!FL_TEST(klass, FL_SINGLETON));
- RCLASS_EXT(klass)->as.class.allocator = allocator;
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
+ RUBY_ASSERT(!RCLASS_SINGLETON_P(klass));
+ RCLASS_EXT_PRIME(klass)->as.class.allocator = allocator; // Allocator is set only on the initial definition
}
static inline void
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
{
- RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
- if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
+ rb_classext_t *ext = RCLASS_EXT_PRIME(klass);
+ RB_OBJ_WRITE(klass, &RCLASSEXT_ORIGIN(ext), origin);
+ if (klass != origin) RCLASSEXT_ICLASS_IS_ORIGIN(RCLASS_EXT_WRITABLE(origin)) = true;
+}
+
+static inline void
+RCLASS_WRITE_ORIGIN(VALUE klass, VALUE origin)
+{
+ rb_classext_t *ext = RCLASS_EXT_WRITABLE(klass);
+ RB_OBJ_WRITE(klass, &RCLASSEXT_ORIGIN(ext), origin);
+ if (klass != origin) RCLASSEXT_ICLASS_IS_ORIGIN(RCLASS_EXT_WRITABLE(origin)) = true;
}
static inline void
RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass)
{
- FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
+ RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(RCLASS_EXT_PRIME(iclass)) = true;
+}
+
+static inline void
+RICLASS_WRITE_ORIGIN_SHARED_MTBL(VALUE iclass)
+{
+ RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(RCLASS_EXT_WRITABLE(iclass)) = true;
}
static inline bool
RICLASS_OWNS_M_TBL_P(VALUE iclass)
{
- return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
+ rb_classext_t *ext = RCLASS_EXT_READABLE(iclass);
+ return RCLASSEXT_ICLASS_IS_ORIGIN(ext) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(ext);
+}
+
+static inline bool
+RICLASS_FOR_REFINEMENT_P(VALUE iclass)
+{
+ return BUILTIN_TYPE(iclass) == T_ICLASS &&
+ RB_TYPE_P(RBASIC(iclass)->klass, T_MODULE) &&
+ FL_TEST_RAW(RBASIC(iclass)->klass, RMODULE_IS_REFINEMENT);
}
static inline void
RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
{
+ RUBY_ASSERT(RB_TYPE_P(iclass, T_ICLASS));
RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
}
-static inline VALUE
-RCLASS_SUPER(VALUE klass)
+static inline void
+RCLASS_WRITE_SUPERCLASSES(VALUE klass, size_t depth, VALUE *superclasses, bool with_self)
{
- return RCLASS(klass)->super;
+ RUBY_ASSERT(depth <= RCLASS_MAX_SUPERCLASS_DEPTH);
+
+ rb_classext_t *ext = RCLASS_EXT_PRIME(klass);
+ RCLASSEXT_SUPERCLASS_DEPTH(ext) = depth;
+ RCLASSEXT_SUPERCLASSES(ext) = superclasses;
+ RCLASSEXT_SUPERCLASSES_WITH_SELF(ext) = with_self;
}
-static inline VALUE
-RCLASS_SET_SUPER(VALUE klass, VALUE super)
+static inline void
+RCLASS_SET_SUBCLASSES(VALUE klass, VALUE subclasses)
{
- if (super) {
- rb_class_remove_from_super_subclasses(klass);
- rb_class_subclass_add(super, klass);
- }
- RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
- rb_class_update_superclasses(klass);
- return super;
+ rb_classext_t *ext = RCLASS_EXT_PRIME(klass);
+ RB_OBJ_WRITE(klass, &RCLASSEXT_SUBCLASSES(ext), subclasses);
}
static inline void
RCLASS_SET_CLASSPATH(VALUE klass, VALUE classpath, bool permanent)
{
+ rb_classext_t *ext = RCLASS_EXT_READABLE(klass);
assert(BUILTIN_TYPE(klass) == T_CLASS || BUILTIN_TYPE(klass) == T_MODULE);
assert(classpath == 0 || BUILTIN_TYPE(classpath) == T_STRING);
+ assert(FL_TEST_RAW(classpath, RUBY_FL_SHAREABLE));
- RB_OBJ_WRITE(klass, &(RCLASS_EXT(klass)->classpath), classpath);
- RCLASS_EXT(klass)->permanent_classpath = permanent;
+ RB_OBJ_WRITE(klass, &(RCLASSEXT_CLASSPATH(ext)), classpath);
+ RCLASSEXT_PERMANENT_CLASSPATH(ext) = permanent;
+}
+
+static inline void
+RCLASS_WRITE_CLASSPATH(VALUE klass, VALUE classpath, bool permanent)
+{
+ rb_classext_t *ext = RCLASS_EXT_WRITABLE(klass);
+ assert(BUILTIN_TYPE(klass) == T_CLASS || BUILTIN_TYPE(klass) == T_MODULE);
+ assert(classpath == 0 || BUILTIN_TYPE(classpath) == T_STRING);
+ assert(!RB_FL_ABLE(classpath) || FL_TEST_RAW(classpath, RUBY_FL_SHAREABLE));
+
+ RB_OBJ_WRITE(klass, &(RCLASSEXT_CLASSPATH(ext)), classpath);
+ RCLASSEXT_PERMANENT_CLASSPATH(ext) = permanent;
}
static inline VALUE
RCLASS_SET_ATTACHED_OBJECT(VALUE klass, VALUE attached_object)
{
- assert(BUILTIN_TYPE(klass) == T_CLASS);
- assert(FL_TEST_RAW(klass, FL_SINGLETON));
+ assert(RCLASS_SINGLETON_P(klass));
- RB_OBJ_WRITE(klass, &RCLASS_EXT(klass)->as.singleton_class.attached_object, attached_object);
+ RB_OBJ_WRITE(klass, &RCLASS_EXT_PRIME(klass)->as.singleton_class.attached_object, attached_object);
return attached_object;
}
+static inline void
+RCLASS_SET_MAX_IV_COUNT(VALUE klass, attr_index_t count)
+{
+ RUBY_ASSERT(klass != rb_cObject);
+ RUBY_ASSERT(klass != rb_cBasicObject);
+
+ RCLASS_MAX_IV_COUNT(klass) = count;
+}
+
+static inline void
+RCLASS_SET_EXPECT_NO_IVAR(VALUE klass)
+{
+ RCLASS_EXT_PRIME(klass)->expect_no_ivar = true;
+}
+
+static inline bool
+RCLASS_EXPECT_NO_IVAR(VALUE klass)
+{
+ return RCLASS_EXT_PRIME(klass)->expect_no_ivar;
+}
+
+static inline bool
+RCLASS_INITIALIZED_P(VALUE klass)
+{
+ VM_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE));
+ return FL_TEST_RAW(klass, RCLASS_IS_INITIALIZED);
+}
+
#endif /* INTERNAL_CLASS_H */
diff --git a/internal/cmdlineopt.h b/internal/cmdlineopt.h
index 914bb77661..aed209e2a2 100644
--- a/internal/cmdlineopt.h
+++ b/internal/cmdlineopt.h
@@ -1,7 +1,6 @@
#ifndef INTERNAL_CMDLINEOPT_H /*-*-C-*-vi:se ft=c:*/
#define INTERNAL_CMDLINEOPT_H
-#include "rjit.h"
#include "yjit.h"
typedef struct {
@@ -23,11 +22,12 @@ typedef struct ruby_cmdline_options {
ruby_features_t features;
ruby_features_t warn;
unsigned int dump;
-#if USE_RJIT
- struct rjit_options rjit;
-#endif
+ long backtrace_length_limit;
+
+ const char *crash_report;
- int sflag, xflag;
+ signed int sflag: 2;
+ unsigned int xflag: 1;
unsigned int warning: 1;
unsigned int verbose: 1;
unsigned int do_loop: 1;
@@ -39,6 +39,9 @@ typedef struct ruby_cmdline_options {
#if USE_YJIT
unsigned int yjit: 1;
#endif
+#if USE_ZJIT
+ unsigned int zjit: 1;
+#endif
} ruby_cmdline_options_t;
struct ruby_opt_message {
diff --git a/internal/compar.h b/internal/compar.h
index 9115e4bd63..5eb5e8714e 100644
--- a/internal/compar.h
+++ b/internal/compar.h
@@ -25,5 +25,6 @@
/* compar.c */
VALUE rb_invcmp(VALUE, VALUE);
+NORETURN(void rb_cmperr_reason(VALUE, VALUE, const char*));
#endif /* INTERNAL_COMPAR_H */
diff --git a/internal/compile.h b/internal/compile.h
index eebb7605cd..2ece5396f6 100644
--- a/internal/compile.h
+++ b/internal/compile.h
@@ -17,7 +17,6 @@ struct rb_iseq_struct; /* in vm_core.h */
/* compile.c */
int rb_dvar_defined(ID, const struct rb_iseq_struct *);
int rb_local_defined(ID, const struct rb_iseq_struct *);
-bool rb_insns_leaf_p(int i);
int rb_insn_len(VALUE insn);
const char *rb_insns_name(int i);
VALUE rb_insns_name_array(void);
diff --git a/internal/concurrent_set.h b/internal/concurrent_set.h
new file mode 100644
index 0000000000..76cbefab04
--- /dev/null
+++ b/internal/concurrent_set.h
@@ -0,0 +1,21 @@
+#ifndef RUBY_RACTOR_SAFE_TABLE_H
+#define RUBY_RACTOR_SAFE_TABLE_H
+
+#include "ruby/atomic.h"
+#include "ruby/ruby.h"
+
+struct rb_concurrent_set_funcs {
+ VALUE (*hash)(VALUE key);
+ bool (*cmp)(VALUE a, VALUE b);
+ VALUE (*create)(VALUE key, void *data);
+ void (*free)(VALUE key);
+};
+
+VALUE rb_concurrent_set_new(const struct rb_concurrent_set_funcs *funcs, int capacity);
+rb_atomic_t rb_concurrent_set_size(VALUE set_obj);
+VALUE rb_concurrent_set_find(VALUE *set_obj_ptr, VALUE key);
+VALUE rb_concurrent_set_find_or_insert(VALUE *set_obj_ptr, VALUE key, void *data);
+VALUE rb_concurrent_set_delete_by_identity(VALUE set_obj, VALUE key);
+void rb_concurrent_set_foreach_with_replace(VALUE set_obj, int (*callback)(VALUE *key, void *data), void *data);
+
+#endif
diff --git a/internal/cont.h b/internal/cont.h
index c3b091668a..dcf6f820a3 100644
--- a/internal/cont.h
+++ b/internal/cont.h
@@ -22,11 +22,13 @@ void rb_jit_cont_init(void);
void rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data);
void rb_jit_cont_finish(void);
+/* vm.c */
+void rb_free_shared_fiber_pool(void);
+
// Copy locals from the current execution to the specified fiber.
VALUE rb_fiber_inherit_storage(struct rb_execution_context_struct *ec, struct rb_fiber_struct *fiber);
VALUE rb_fiberptr_self(struct rb_fiber_struct *fiber);
unsigned int rb_fiberptr_blocking(struct rb_fiber_struct *fiber);
struct rb_execution_context_struct * rb_fiberptr_get_ec(struct rb_fiber_struct *fiber);
-
#endif /* INTERNAL_CONT_H */
diff --git a/internal/encoding.h b/internal/encoding.h
index a3b81bd388..38bf8fc9da 100644
--- a/internal/encoding.h
+++ b/internal/encoding.h
@@ -11,22 +11,29 @@
#include "ruby/ruby.h" /* for ID */
#include "ruby/encoding.h" /* for rb_encoding */
-#define rb_enc_autoload_p(enc) (!rb_enc_mbmaxlen(enc))
#define rb_is_usascii_enc(enc) ((enc) == rb_usascii_encoding())
#define rb_is_ascii8bit_enc(enc) ((enc) == rb_ascii8bit_encoding())
#define rb_is_locale_enc(enc) ((enc) == rb_locale_encoding())
/* encoding.c */
ID rb_id_encoding(void);
+const char * rb_enc_inspect_name(rb_encoding *enc);
rb_encoding *rb_enc_get_from_index(int index);
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
int rb_encdb_replicate(const char *alias, const char *orig);
int rb_encdb_alias(const char *alias, const char *orig);
int rb_enc_autoload(rb_encoding *enc);
+bool rb_enc_autoload_p(rb_encoding *enc);
int rb_encdb_dummy(const char *name);
void rb_encdb_declare(const char *name);
void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
+void rb_enc_raw_set(VALUE obj, rb_encoding *enc);
+int rb_enc_registered(const char *name);
+
PUREFUNC(int rb_data_is_encoding(VALUE obj));
+/* vm.c */
+void rb_free_global_enc_table(void);
+
#endif /* INTERNAL_ENCODING_H */
diff --git a/internal/error.h b/internal/error.h
index 11601858f4..fead2aee95 100644
--- a/internal/error.h
+++ b/internal/error.h
@@ -29,15 +29,37 @@
#define rb_raise_static(e, m) \
rb_raise_cstr_i((e), rb_str_new_static((m), rb_strlen_lit(m)))
#ifdef RUBY_FUNCTION_NAME_STRING
-# define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
# define rb_syserr_new_path(err, path) rb_syserr_new_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
#else
-# define rb_sys_fail_path(path) rb_sys_fail_str(path)
# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
# define rb_syserr_new_path(err, path) rb_syserr_new_str((err), (path))
#endif
+#define rb_sys_fail(mesg) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail(errno_to_fail, (mesg)); \
+} while (0)
+
+#define rb_sys_fail_str(mesg) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_str(errno_to_fail, (mesg)); \
+} while (0)
+
+#define rb_sys_fail_path(path) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_path(errno_to_fail, (path)); \
+} while (0)
+
+#define rb_sys_fail_sprintf(...) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_str(errno_to_fail, rb_sprintf("" __VA_ARGS__)); \
+} while (0)
+
/* error.c */
extern long rb_backtrace_length_limit;
extern VALUE rb_eEAGAIN;
@@ -50,13 +72,14 @@ const char *rb_builtin_type_name(int t);
const char *rb_builtin_class_name(VALUE x);
PRINTF_ARGS(void rb_warn_deprecated(const char *fmt, const char *suggest, ...), 1, 3);
PRINTF_ARGS(void rb_warn_deprecated_to_remove(const char *removal, const char *fmt, const char *suggest, ...), 2, 4);
+PRINTF_ARGS(void rb_warn_reserved_name(const char *removal, const char *fmt, ...), 2, 3);
#if RUBY_DEBUG
# include "ruby/version.h"
-# define RUBY_VERSION_SINCE(major, minor) (RUBY_API_VERSION_CODE >= (major * 10000) + (minor) * 100)
-# define RUBY_VERSION_BEFORE(major, minor) (RUBY_API_VERSION_CODE < (major * 10000) + (minor) * 100)
+# define RUBY_VERSION_SINCE(major, minor) (RUBY_API_VERSION_CODE >= (major) * 10000 + (minor) * 100)
+# define RUBY_VERSION_BEFORE(major, minor) (RUBY_API_VERSION_CODE < (major) * 10000 + (minor) * 100)
# if defined(RBIMPL_WARNING_PRAGMA0)
# define RBIMPL_TODO0(x) RBIMPL_WARNING_PRAGMA0(message(x))
-# elif RBIMPL_COMPILER_SINCE(MSVC, 12, 0, 0)
+# elif RBIMPL_COMPILER_IS(MSVC)
# define RBIMPL_TODO0(x) __pragma(message(x))
# endif
@@ -88,6 +111,14 @@ rb_deprecated_method_to_be_removed(const char *removal)
RBIMPL_ATTR_DIAGNOSE_IF(RUBY_VERSION_STRING_SINCE(removal), "deprecated method to be removed", "error")
{
}
+
+RBIMPL_ATTR_FORCEINLINE()
+static void
+rb_diagnose_reserved_name_at(const char *coming)
+ RBIMPL_ATTR_DIAGNOSE_IF(!RUBY_VERSION_isdigit(coming[0]), "malformed version number", "error")
+ RBIMPL_ATTR_DIAGNOSE_IF(RUBY_VERSION_STRING_SINCE(coming), "reserved name already in use", "error")
+{
+}
# else
RBIMPL_ATTR_ERROR(("deprecated"))
void rb_deprecated_method_to_be_removed(const char *);
@@ -95,16 +126,32 @@ void rb_deprecated_method_to_be_removed(const char *);
(sizeof(char[1-2*(!RUBY_VERSION_isdigit(removal[0]) || RUBY_VERSION_STRING_SINCE(removal))])!=1 ? \
rb_deprecated_method_to_be_removed(removal) : \
RBIMPL_ASSERT_NOTHING)
+
+RBIMPL_ATTR_ERROR(("deprecated"))
+void rb_diagnose_reserved_name_at(const char *);
+# define rb_diagnose_reserved_name_at(coming) \
+ (sizeof(char[1-2*(!RUBY_VERSION_isdigit(coming[0]) || RUBY_VERSION_STRING_SINCE(coming))])!=1 ? \
+ rb_diagnose_reserved_name_at(coming) : \
+ RBIMPL_ASSERT_NOTHING)
+
# endif
# define rb_warn_deprecated_to_remove_at(removal, ...) \
(rb_deprecated_method_to_be_removed(#removal), \
rb_warn_deprecated_to_remove(#removal, __VA_ARGS__))
+
+# define rb_warn_reserved_name_at(coming, ...) \
+ (rb_diagnose_reserved_name_at(#coming), \
+ rb_warn_reserved_name(#coming, __VA_ARGS__))
# endif
#endif
#ifndef rb_warn_deprecated_to_remove_at
# define rb_warn_deprecated_to_remove_at(removal, ...) \
rb_warn_deprecated_to_remove(#removal, __VA_ARGS__)
#endif
+#ifndef rb_warn_reserved_name_at
+# define rb_warn_reserved_name_at(removal, ...) \
+ rb_warn_reserved_name(#removal, __VA_ARGS__)
+#endif
#ifndef RUBY_VERSION_SINCE
# define RUBY_VERSION_SINCE(major, minor) 0
#endif
@@ -120,6 +167,8 @@ VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*,
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
+PRINTF_ARGS(void rb_enc_compile_warning(rb_encoding *enc, const char *file, int line, const char *fmt, ...), 4, 5);
+PRINTF_ARGS(void rb_enc_compile_warn(rb_encoding *enc, const char *file, int line, const char *fmt, ...), 4, 5);
rb_warning_category_t rb_warning_category_from_name(VALUE category);
bool rb_warning_category_enabled_p(rb_warning_category_t category);
VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
@@ -136,6 +185,10 @@ NORETURN(static inline void rb_key_err_raise(VALUE mesg, VALUE recv, VALUE name)
static inline void Check_Type(VALUE v, enum ruby_value_type t);
static inline bool rb_typeddata_is_instance_of_inline(VALUE obj, const rb_data_type_t *data_type);
#define rb_typeddata_is_instance_of rb_typeddata_is_instance_of_inline
+void rb_bug_without_die(const char *fmt, ...);
+NORETURN(void rb_no_implicit_conversion(VALUE val, const char *tname));
+NORETURN(void rb_cant_convert(VALUE val, const char *tname));
+NORETURN(void rb_cant_convert_invalid_return(VALUE val, const char *tname, const char *method_name, VALUE ret));
RUBY_SYMBOL_EXPORT_BEGIN
/* error.c (export) */
@@ -147,6 +200,9 @@ VALUE rb_syserr_new_path_in(const char *func_name, int n, VALUE path);
#endif
RUBY_SYMBOL_EXPORT_END
+/* vm.c */
+void rb_free_warning(void);
+
static inline void
rb_raise_cstr_i(VALUE etype, VALUE mesg)
{
@@ -182,10 +238,18 @@ rb_key_err_raise(VALUE mesg, VALUE recv, VALUE name)
rb_exc_raise(exc);
}
+RBIMPL_ATTR_NONNULL((2))
static inline bool
rb_typeddata_is_instance_of_inline(VALUE obj, const rb_data_type_t *data_type)
{
- return RB_TYPE_P(obj, T_DATA) && RTYPEDDATA_P(obj) && (RTYPEDDATA_TYPE(obj) == data_type);
+ return rbimpl_obj_typeddata_p(obj) && (RTYPEDDATA_TYPE(obj) == data_type);
}
+typedef enum {
+ rb_stack_overflow_prevention = 0, // VM stack overflow or about to machine stack overflow
+ rb_stack_overflow_signal = 1, // machine stack overflow but may be recoverable
+ rb_stack_overflow_fatal = 2, // fatal machine stack overflow
+} ruby_stack_overflow_critical_level;
+NORETURN(void rb_ec_stack_overflow(struct rb_execution_context_struct *ec, ruby_stack_overflow_critical_level crit));
+
#endif /* INTERNAL_ERROR_H */
diff --git a/internal/eval.h b/internal/eval.h
index 73bb656d96..17ade0a7f1 100644
--- a/internal/eval.h
+++ b/internal/eval.h
@@ -11,16 +11,27 @@
* header (related to this file, but not the same role).
*/
#include "ruby/ruby.h" /* for ID */
+#include "vm_core.h" /* for ID */
#define id_signo ruby_static_id_signo
#define id_status ruby_static_id_status
/* eval.c */
+struct rb_refinements_data {
+ VALUE refinement;
+ VALUE refinements;
+};
+
extern ID ruby_static_id_signo;
extern ID ruby_static_id_status;
VALUE rb_refinement_module_get_refined_class(VALUE module);
void rb_class_modify_check(VALUE);
NORETURN(VALUE rb_f_raise(int argc, VALUE *argv));
+VALUE rb_exception_setup(int argc, VALUE *argv);
+void rb_refinement_setup(struct rb_refinements_data *data, VALUE module, VALUE klass);
+void rb_vm_using_module(VALUE module);
+VALUE rb_top_main_class(const char *method);
+VALUE rb_ec_ensure(rb_execution_context_t *ec, VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
/* eval_error.c */
VALUE rb_get_backtrace(VALUE info);
diff --git a/internal/file.h b/internal/file.h
index 9c192ff4d1..1aa4c67043 100644
--- a/internal/file.h
+++ b/internal/file.h
@@ -23,7 +23,9 @@ VALUE rb_file_expand_path_fast(VALUE, VALUE);
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
VALUE rb_get_path_check_to_string(VALUE);
VALUE rb_get_path_check_convert(VALUE);
+VALUE rb_get_path_check_no_convert(VALUE);
int ruby_is_fd_loadable(int fd);
+char *rb_enc_path_skip_prefix_root(const char *path, const char *end, rb_encoding *enc);
RUBY_SYMBOL_EXPORT_BEGIN
/* file.c (export) */
diff --git a/internal/fixnum.h b/internal/fixnum.h
index 8c251adef1..b78e31460e 100644
--- a/internal/fixnum.h
+++ b/internal/fixnum.h
@@ -10,6 +10,7 @@
*/
#include "ruby/internal/config.h" /* for HAVE_LONG_LONG */
#include <limits.h> /* for CHAR_BIT */
+#include "internal/bits.h" /* for MUL_OVERFLOW_FIXNUM_P */
#include "internal/compilers.h" /* for __has_builtin */
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/intern.h" /* for rb_big_mul */
diff --git a/internal/gc.h b/internal/gc.h
index 0abdb22ffd..8b136e6572 100644
--- a/internal/gc.h
+++ b/internal/gc.h
@@ -14,6 +14,11 @@
#include "internal/compilers.h" /* for __has_attribute */
#include "ruby/ruby.h" /* for rb_event_flag_t */
+#include "vm_core.h" /* for GET_EC() */
+
+#ifndef USE_MODULAR_GC
+# define USE_MODULAR_GC 0
+#endif
#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
@@ -78,16 +83,6 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#define RUBY_GC_INFO if(0)printf
#endif
-#define RUBY_MARK_MOVABLE_UNLESS_NULL(ptr) do { \
- VALUE markobj = (ptr); \
- if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
-} while (0)
-#define RUBY_MARK_UNLESS_NULL(ptr) do { \
- VALUE markobj = (ptr); \
- if (RTEST(markobj)) {rb_gc_mark(markobj);} \
-} while (0)
-#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
-
#if STACK_GROW_DIRECTION > 0
# define STACK_UPPER(x, a, b) (a)
#elif STACK_GROW_DIRECTION < 0
@@ -122,37 +117,23 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
const char *rb_obj_info(VALUE obj);
const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
-size_t rb_size_pool_slot_size(unsigned char pool_id);
-
struct rb_execution_context_struct; /* in vm_core.h */
struct rb_objspace; /* in vm_core.h */
-#ifdef NEWOBJ_OF
-# undef NEWOBJ_OF
-# undef RB_NEWOBJ_OF
+#define EC_NEWOBJ_OF(var, T, c, f, s, ec) \
+ T *(var) = (T *)rb_ec_newobj_of((ec), (c), (f), s)
+#define NEWOBJ_OF(var, T, c, f, s) EC_NEWOBJ_OF(var, T, c, f, s, GET_EC())
+#define UNPROTECTED_NEWOBJ_OF(var, T, c, f, s) \
+ T *(var) = (T *)rb_newobj((GET_EC()), (c), (f), ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER, false, s)
+
+#ifndef RB_GC_OBJECT_METADATA_ENTRY_DEFINED
+# define RB_GC_OBJECT_METADATA_ENTRY_DEFINED
+struct rb_gc_object_metadata_entry {
+ ID name;
+ VALUE val;
+};
#endif
-#define RVALUE_SIZE (sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]))
-
-#define RB_RVARGC_NEWOBJ_OF(var, T, c, f, s) \
- T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
- rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED, s) : \
- rb_wb_unprotected_newobj_of((c), (f), s))
-
-#define RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, s) \
- T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
- rb_ec_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, s) : \
- rb_wb_unprotected_newobj_of((c), (f), s))
-
-/* optimized version of NEWOBJ() */
-#define RB_NEWOBJ_OF(var, T, c, f) RB_RVARGC_NEWOBJ_OF(var, T, c, f, RVALUE_SIZE)
-
-#define RB_EC_NEWOBJ_OF(ec, var, T, c, f) RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, RVALUE_SIZE)
-
-#define NEWOBJ_OF(var, T, c, f) RB_NEWOBJ_OF((var), T, (c), (f))
-#define RVARGC_NEWOBJ_OF(var, T, c, f, s) RB_RVARGC_NEWOBJ_OF((var), T, (c), (f), (s))
-#define RB_OBJ_GC_FLAGS_MAX 6 /* used in ext/objspace */
-
#ifndef USE_UNALIGNED_MEMBER_ACCESS
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
#elif ! USE_UNALIGNED_MEMBER_ACCESS
@@ -187,61 +168,58 @@ struct rb_objspace; /* in vm_core.h */
RB_OBJ_WRITE(old, _slot, young); \
} while (0)
-// We use SIZE_POOL_COUNT number of shape IDs for transitions out of different size pools
-// The next available shape ID will be the SPECIAL_CONST_SHAPE_ID
-#if USE_RVARGC && (SIZEOF_UINT64_T == SIZEOF_VALUE)
-# define SIZE_POOL_COUNT 5
-#else
-# define SIZE_POOL_COUNT 1
-#endif
-
-#define RCLASS_EXT_EMBEDDED (SIZE_POOL_COUNT > 1)
-
-typedef struct ractor_newobj_size_pool_cache {
- struct RVALUE *freelist;
- struct heap_page *using_page;
-} rb_ractor_newobj_size_pool_cache_t;
+/* Used in places that could malloc during, which can cause the GC to run. We
+ * need to temporarily disable the GC to allow the malloc to happen.
+ * Allocating memory during GC is a bad idea, so use this only when absolutely
+ * necessary. */
+#define DURING_GC_COULD_MALLOC_REGION_START() \
+ assert(rb_during_gc()); \
+ VALUE _already_disabled = rb_gc_disable_no_rest()
-typedef struct ractor_newobj_cache {
- size_t incremental_mark_step_allocated_slots;
- rb_ractor_newobj_size_pool_cache_t size_pool_caches[SIZE_POOL_COUNT];
-} rb_ractor_newobj_cache_t;
+#define DURING_GC_COULD_MALLOC_REGION_END() \
+ if (_already_disabled == Qfalse) rb_gc_enable()
/* gc.c */
-extern VALUE *ruby_initial_gc_stress_ptr;
-extern int ruby_disable_gc;
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
+RUBY_ATTR_MALLOC void *ruby_mimcalloc(size_t num, size_t size);
void ruby_mimfree(void *ptr);
+void rb_gc_prepare_heap(void);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
-VALUE rb_objspace_gc_enable(struct rb_objspace *);
-VALUE rb_objspace_gc_disable(struct rb_objspace *);
+VALUE rb_objspace_gc_enable(void *objspace);
+VALUE rb_objspace_gc_disable(void *objspace);
void ruby_gc_set_params(void);
-void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
-#if __has_attribute(alloc_align)
-__attribute__((__alloc_align__(1)))
-#endif
-RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((2));
+void rb_gc_copy_attributes(VALUE dest, VALUE obj);
size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
+size_t rb_malloc_grow_capa(size_t current_capacity, size_t type_size);
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add(size_t, size_t, size_t);
void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t);
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t);
-static inline void *ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
-static inline void *ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
-static inline void ruby_sized_xfree_inlined(void *ptr, size_t size);
-VALUE rb_class_allocate_instance(VALUE klass);
-void rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache);
-size_t rb_gc_obj_slot_size(VALUE obj);
+void rb_gc_obj_id_moved(VALUE obj);
+void rb_gc_register_pinning_obj(VALUE obj);
+rb_execution_context_t *rb_gc_get_ec(void);
+
+void *rb_gc_ractor_cache_alloc(rb_ractor_t *ractor);
+void rb_gc_ractor_cache_free(void *cache);
+
bool rb_gc_size_allocatable_p(size_t size);
-int rb_objspace_garbage_object_p(VALUE obj);
-bool rb_gc_is_ptr_to_obj(void *ptr);
-VALUE rb_gc_id2ref_obj_tbl(VALUE objid);
-VALUE rb_define_finalizer_no_check(VALUE obj, VALUE block);
+size_t *rb_gc_heap_sizes(void);
+size_t rb_gc_heap_id_for_size(size_t size);
void rb_gc_mark_and_move(VALUE *ptr);
+void rb_gc_declare_weak_references(VALUE obj);
+bool rb_gc_handle_weak_references_alive_p(VALUE obj);
+
+void rb_gc_ref_update_table_values_only(st_table *tbl);
+
+void rb_gc_initial_stress_set(VALUE flag);
+
+void rb_gc_before_fork(void);
+void rb_gc_after_fork(rb_pid_t pid);
+
#define rb_gc_mark_and_move_ptr(ptr) do { \
VALUE _obj = (VALUE)*(ptr); \
rb_gc_mark_and_move(&_obj); \
@@ -250,93 +228,80 @@ void rb_gc_mark_and_move(VALUE *ptr);
RUBY_SYMBOL_EXPORT_BEGIN
/* exports for objspace module */
-size_t rb_objspace_data_type_memsize(VALUE obj);
void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
-int rb_objspace_markable_object_p(VALUE obj);
int rb_objspace_internal_object_p(VALUE obj);
-int rb_objspace_marked_object_p(VALUE obj);
+int rb_objspace_garbage_object_p(VALUE obj);
+bool rb_gc_pointer_to_heap_p(VALUE obj);
void rb_objspace_each_objects(
int (*callback)(void *start, void *end, size_t stride, void *data),
void *data);
-void rb_objspace_each_objects_without_setup(
- int (*callback)(void *, void *, size_t, void *),
- void *data);
-
size_t rb_gc_obj_slot_size(VALUE obj);
VALUE rb_gc_disable_no_rest(void);
+#define RB_GC_MAX_NAME_LEN 20
/* gc.c (export) */
const char *rb_objspace_data_type_name(VALUE obj);
-VALUE rb_wb_protected_newobj_of(VALUE, VALUE, size_t);
-VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE, size_t);
-VALUE rb_ec_wb_protected_newobj_of(struct rb_execution_context_struct *ec, VALUE klass, VALUE flags, size_t);
+VALUE rb_newobj(struct rb_execution_context_struct *, VALUE, VALUE, uint32_t /* shape_id_t */, bool, size_t);
+VALUE rb_newobj_of(VALUE, VALUE, size_t);
+VALUE rb_ec_newobj_of(struct rb_execution_context_struct *, VALUE, VALUE, size_t);
size_t rb_obj_memsize_of(VALUE);
-void rb_gc_verify_internal_consistency(void);
-size_t rb_obj_gc_flags(VALUE, ID[], size_t);
+struct rb_gc_object_metadata_entry *rb_gc_object_metadata(VALUE obj);
void rb_gc_mark_values(long n, const VALUE *values);
void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
-void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
-void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
-void ruby_sized_xfree(void *x, size_t size);
-RUBY_SYMBOL_EXPORT_END
+void rb_gc_update_values(long n, VALUE *values);
+void rb_gc_mark_set_no_pin(st_table *);
+void rb_gc_update_set_refs(st_table *);
-int rb_ec_stack_check(struct rb_execution_context_struct *ec);
-void rb_gc_writebarrier_remember(VALUE obj);
-const char *rb_obj_info(VALUE obj);
+#if USE_MODULAR_GC
+const char *rb_gc_active_gc_name(void);
+int rb_gc_modular_gc_loaded_p(void);
+#endif
-#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
+RUBY_SYMBOL_EXPORT_END
-static inline void *
-ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
+static inline VALUE
+rb_obj_atomic_write(
+ VALUE a, VALUE *slot, VALUE b,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ const char *filename,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ int line)
{
- return ruby_xrealloc(ptr, new_size);
-}
+#ifdef RGENGC_LOGGING_WRITE
+ RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
+#endif
-static inline void *
-ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
-{
- return ruby_xrealloc2(ptr, new_count, elemsiz);
-}
+ RUBY_ATOMIC_VALUE_SET(*slot, b);
-static inline void
-ruby_sized_xfree_inlined(void *ptr, size_t size)
-{
- ruby_xfree(ptr);
+ rb_obj_written(a, RUBY_Qundef /* ignore `oldv' now */, b, filename, line);
+ return a;
}
+#define RB_OBJ_ATOMIC_WRITE(old, slot, young) \
+ RBIMPL_CAST(rb_obj_atomic_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
-# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
+int rb_ec_stack_check(struct rb_execution_context_struct *ec);
+void rb_gc_writebarrier_remember(VALUE obj);
+const char *rb_obj_info(VALUE obj);
+void ruby_annotate_mmap(const void *addr, unsigned long size, const char *name);
-#else
+# define SIZED_REALLOC_N(v, T, m, n) \
+ ((v) = (T *)ruby_xrealloc2_sized((void *)(v), (m), sizeof(T), (n)))
-static inline void *
-ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
-{
- return ruby_sized_xrealloc(ptr, new_size, old_size);
-}
+# define SIZED_FREE(v) ruby_xfree_sized((void *)(v), sizeof(*(v)))
+# define SIZED_FREE_N(v, n) ruby_xfree_sized((void *)(v), sizeof(*(v)) * (n))
static inline void *
-ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
+ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
{
- return ruby_sized_xrealloc2(ptr, new_count, elemsiz, old_count);
+ return ruby_xrealloc2_sized(ptr, new_count, element_size, old_count);
}
-static inline void
-ruby_sized_xfree_inlined(void *ptr, size_t size)
-{
- ruby_sized_xfree(ptr, size);
-}
-
-# define SIZED_REALLOC_N(v, T, m, n) \
- ((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
-
-#endif /* HAVE_MALLOC_USABLE_SIZE */
+void rb_gc_verify_shareable(VALUE);
+bool rb_gc_checking_shareable(void);
-#define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
-#define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined
-#define ruby_sized_xfree ruby_sized_xfree_inlined
#endif /* INTERNAL_GC_H */
diff --git a/internal/hash.h b/internal/hash.h
index 275c5167e4..0386a5009c 100644
--- a/internal/hash.h
+++ b/internal/hash.h
@@ -28,10 +28,6 @@ enum ruby_rhash_flags {
RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
-#if USE_TRANSIENT_HEAP
- RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
-#endif
-
// we can not put it in "enum" because it can exceed "int" range.
#define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
@@ -40,17 +36,23 @@ enum ruby_rhash_flags {
RHASH_LEV_MAX = 127, /* 7 bits */
};
-struct RHash {
- struct RBasic basic;
- union {
- st_table *st;
- struct ar_table_struct *ar; /* possibly 0 */
- } as;
- const VALUE ifnone;
+typedef struct ar_table_pair_struct {
+ VALUE key;
+ VALUE val;
+} ar_table_pair;
+
+typedef struct ar_table_struct {
union {
ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
VALUE word;
} ar_hint;
+ /* 64bit CPU: 8B * 2 * 8 = 128B */
+ ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
+} ar_table;
+
+struct RHash {
+ struct RBasic basic;
+ const VALUE ifnone;
};
#define RHASH(obj) ((struct RHash *)(obj))
@@ -68,8 +70,8 @@ struct RHash {
#endif
/* hash.c */
-void rb_hash_st_table_set(VALUE hash, st_table *st);
VALUE rb_hash_default_value(VALUE hash, VALUE key);
+VALUE rb_hash_set_default(VALUE hash, VALUE ifnone);
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
long rb_dbl_long_hash(double d);
st_table *rb_init_identtable(void);
@@ -84,7 +86,11 @@ VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
+bool rb_hash_default_unredefined(VALUE hash);
+VALUE rb_hash_alloc_fixed_size(VALUE klass, st_index_t size);
VALUE rb_ident_hash_new_with_size(st_index_t size);
+void rb_hash_free(VALUE hash);
+RUBY_EXTERN VALUE rb_cHash_empty_frozen;
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
static inline VALUE RHASH_IFNONE(VALUE h);
@@ -96,9 +102,6 @@ static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
static inline st_table *RHASH_ST_TABLE(VALUE h);
static inline size_t RHASH_ST_SIZE(VALUE h);
static inline void RHASH_ST_CLEAR(VALUE h);
-static inline bool RHASH_TRANSIENT_P(VALUE h);
-static inline void RHASH_SET_TRANSIENT_FLAG(VALUE h);
-static inline void RHASH_UNSET_TRANSIENT_FLAG(VALUE h);
RUBY_SYMBOL_EXPORT_BEGIN
/* hash.c (export) */
@@ -108,6 +111,7 @@ int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t
RUBY_SYMBOL_EXPORT_END
VALUE rb_hash_new_with_size(st_index_t size);
+VALUE rb_hash_new_with_bulk_insert(long argc, const VALUE *argv);
VALUE rb_hash_resurrect(VALUE hash);
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
VALUE rb_hash_keys(VALUE hash);
@@ -125,16 +129,18 @@ RHASH_AR_TABLE_P(VALUE h)
return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
}
+RBIMPL_ATTR_RETURNS_NONNULL()
static inline struct ar_table_struct *
RHASH_AR_TABLE(VALUE h)
{
- return RHASH(h)->as.ar;
+ return (struct ar_table_struct *)((uintptr_t)h + sizeof(struct RHash));
}
+RBIMPL_ATTR_RETURNS_NONNULL()
static inline st_table *
RHASH_ST_TABLE(VALUE h)
{
- return RHASH(h)->as.st;
+ return (st_table *)((uintptr_t)h + sizeof(struct RHash));
}
static inline VALUE
@@ -175,8 +181,7 @@ RHASH_ST_SIZE(VALUE h)
static inline void
RHASH_ST_CLEAR(VALUE h)
{
- RHASH(h)->as.st = NULL;
- FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG);
+ memset(RHASH_ST_TABLE(h), 0, sizeof(st_table));
}
static inline unsigned
@@ -187,30 +192,19 @@ RHASH_AR_TABLE_SIZE_RAW(VALUE h)
return (unsigned)ret;
}
-static inline bool
-RHASH_TRANSIENT_P(VALUE h)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(h, RHASH_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
+#define RHASH_AR_TABLE_BOUND_RAW(h) \
+ ((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
+ (RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
-static inline void
-RHASH_SET_TRANSIENT_FLAG(VALUE h)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(h, RHASH_TRANSIENT_FLAG);
-#endif
-}
+#define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
-static inline void
-RHASH_UNSET_TRANSIENT_FLAG(VALUE h)
+static inline unsigned int
+RHASH_AR_TABLE_BOUND(VALUE h)
{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG);
-#endif
+ RUBY_ASSERT(RHASH_AR_TABLE_P(h));
+ const unsigned int bound = RHASH_AR_TABLE_BOUND_RAW(h);
+ RUBY_ASSERT(bound <= RHASH_AR_TABLE_MAX_SIZE);
+ return bound;
}
#endif /* INTERNAL_HASH_H */
diff --git a/internal/imemo.h b/internal/imemo.h
index 57a705ce77..e8a5f0fc8e 100644
--- a/internal/imemo.h
+++ b/internal/imemo.h
@@ -10,14 +10,11 @@
*/
#include "ruby/internal/config.h"
#include <stddef.h> /* for size_t */
+#include "id_table.h"
#include "internal/array.h" /* for rb_ary_hidden_new_fill */
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for rb_block_call_func_t */
-#ifndef IMEMO_DEBUG
-# define IMEMO_DEBUG 0
-#endif
-
#define IMEMO_MASK 0x0f
/* FL_USER0 to FL_USER3 is for type */
@@ -28,6 +25,7 @@
#define IMEMO_FL_USER3 FL_USER7
#define IMEMO_FL_USER4 FL_USER8
#define IMEMO_FL_USER5 FL_USER9
+#define IMEMO_FL_USER6 FL_USER10
enum imemo_type {
imemo_env = 0,
@@ -39,11 +37,13 @@ enum imemo_type {
imemo_ment = 6,
imemo_iseq = 7,
imemo_tmpbuf = 8,
- imemo_ast = 9,
- imemo_parser_strterm = 10,
- imemo_callinfo = 11,
- imemo_callcache = 12,
- imemo_constcache = 13,
+ imemo_cvar_entry = 9,
+ imemo_callinfo = 10,
+ imemo_callcache = 11,
+ imemo_constcache = 12,
+ imemo_fields = 13,
+ imemo_subclasses = 14,
+ imemo_cdhash = 15,
};
/* CREF (Class REFerence) is defined in method.h */
@@ -60,7 +60,6 @@ struct vm_svar {
/*! THROW_DATA */
struct vm_throw_data {
VALUE flags;
- VALUE reserved;
const VALUE throw_obj;
const struct rb_control_frame_struct *catch_frame;
int throw_state;
@@ -79,7 +78,12 @@ struct vm_ifunc_argc {
#endif
};
-/*! IFUNC (Internal FUNCtion) */
+/*! IFUNC (Internal FUNCtion)
+ *
+ * Bookkeeping for converting a C function and some closed-over data into a
+ * block passable to methods. Like Ruby Proc, but not directly accessible at
+ * Ruby level since this is an imemo. See rb_block_call() and friends.
+ */
struct vm_ifunc {
VALUE flags;
VALUE *svar_lep;
@@ -87,37 +91,45 @@ struct vm_ifunc {
const void *data;
struct vm_ifunc_argc argc;
};
+#define IFUNC_YIELD_OPTIMIZABLE IMEMO_FL_USER0
struct rb_imemo_tmpbuf_struct {
VALUE flags;
- VALUE reserved;
VALUE *ptr; /* malloc'ed buffer */
- struct rb_imemo_tmpbuf_struct *next; /* next imemo */
- size_t cnt; /* buffer size in VALUE */
+ size_t size; /* buffer size in bytes */
};
+struct rb_imemo_cdhash {
+ VALUE flags;
+ st_table tbl;
+};
+
+/* Set on imemo_memo when u3 holds a VALUE that GC must mark.
+ * When unset, u3 is a non-VALUE (cnt/state). */
+#define MEMO_U3_IS_VALUE IMEMO_FL_USER0
+
/*! MEMO
*
* @see imemo_type
* */
struct MEMO {
VALUE flags;
- VALUE reserved;
const VALUE v1;
const VALUE v2;
union {
long cnt;
long state;
const VALUE value;
- void (*func)(void);
} u3;
};
+#define IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), false))
+#define SHAREABLE_IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), true))
+
/* ment is in method.h */
#define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
#define MEMO_CAST(m) ((struct MEMO *)(m))
-#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
#define NEW_MEMO_FOR(type, value) \
((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
@@ -126,28 +138,27 @@ struct MEMO {
rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
MEMO_FOR(type, value))
+#ifndef RUBY_RUBYPARSER_H
typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
-rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
+#endif
+VALUE rb_imemo_new(enum imemo_type type, VALUE v0, size_t size, bool is_shareable);
+VALUE rb_imemo_tmpbuf_new(void);
+struct MEMO *rb_imemo_memo_new(VALUE a, VALUE b, long c);
+struct MEMO *rb_imemo_memo_new_value(VALUE a, VALUE b, VALUE c);
struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
-void rb_strterm_mark(VALUE obj);
static inline enum imemo_type imemo_type(VALUE imemo);
static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
static inline bool imemo_throw_data_p(VALUE imemo);
static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
-static inline VALUE rb_imemo_tmpbuf_auto_free_pointer(void);
static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
-static inline void *rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr);
-static inline VALUE rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str);
static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
+size_t rb_imemo_memsize(VALUE obj);
+void rb_imemo_mark_and_move(VALUE obj, bool reference_updating);
+void rb_imemo_free(VALUE obj);
+
RUBY_SYMBOL_EXPORT_BEGIN
-#if IMEMO_DEBUG
-VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
-#define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
-#else
-VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
-#endif
const char *rb_imemo_name(enum imemo_type type);
RUBY_SYMBOL_EXPORT_END
@@ -172,7 +183,7 @@ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
}
}
-#define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)v, t)
+#define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)(v), t)
static inline bool
imemo_throw_data_p(VALUE imemo)
@@ -186,12 +197,6 @@ rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
}
-static inline VALUE
-rb_imemo_tmpbuf_auto_free_pointer(void)
-{
- return rb_imemo_new(imemo_tmpbuf, 0, 0, 0, 0);
-}
-
static inline void *
RB_IMEMO_TMPBUF_PTR(VALUE v)
{
@@ -199,30 +204,16 @@ RB_IMEMO_TMPBUF_PTR(VALUE v)
return p->ptr;
}
-static inline void *
-rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
-{
- return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
-}
-
static inline VALUE
-rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
+rb_imemo_tmpbuf_new_from_an_RString(VALUE str)
{
- const void *src;
VALUE imemo;
- rb_imemo_tmpbuf_t *tmpbuf;
- void *dst;
size_t len;
- SafeStringValue(str);
- /* create tmpbuf to keep the pointer before xmalloc */
- imemo = rb_imemo_tmpbuf_auto_free_pointer();
- tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
+ StringValue(str);
len = RSTRING_LEN(str);
- src = RSTRING_PTR(str);
- dst = ruby_xmalloc(len);
- memcpy(dst, src, len);
- tmpbuf->ptr = dst;
+ rb_alloc_tmp_buffer(&imemo, len);
+ memcpy(RB_IMEMO_TMPBUF_PTR(imemo), RSTRING_PTR(str), len);
return imemo;
}
@@ -238,4 +229,108 @@ MEMO_V2_SET(struct MEMO *m, VALUE v)
RB_OBJ_WRITE(m, &m->v2, v);
}
+VALUE rb_imemo_cdhash_new(size_t size, const struct st_hash_type *type);
+
+static inline st_table *
+rb_imemo_cdhash_tbl(VALUE obj)
+{
+ RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_cdhash));
+ return &((struct rb_imemo_cdhash *)obj)->tbl;
+}
+
+struct rb_fields {
+ struct RBasic basic;
+ union {
+ struct {
+ VALUE fields[1];
+ } embed;
+ struct {
+ VALUE *ptr;
+ } external;
+ struct {
+ // Note: the st_table could be embedded, but complex T_CLASS should be rare to
+ // non-existent, so not really worth the trouble.
+ st_table *table;
+ } complex;
+ } as;
+};
+
+// IMEMO/fields and T_OBJECT have exactly the same layout.
+// This is useful for JIT and common codepaths.
+#define OBJ_FIELD_HEAP ROBJECT_HEAP
+STATIC_ASSERT(imemo_fields_flags, OBJ_FIELD_HEAP == IMEMO_FL_USER0);
+STATIC_ASSERT(imemo_fields_embed_offset, offsetof(struct RObject, as.ary) == offsetof(struct rb_fields, as.embed.fields));
+STATIC_ASSERT(imemo_fields_external_offset, offsetof(struct RObject, as.heap.fields) == offsetof(struct rb_fields, as.external.ptr));
+STATIC_ASSERT(imemo_fields_complex_offset, offsetof(struct RObject, as.heap.fields) == offsetof(struct rb_fields, as.complex.table));
+
+#define IMEMO_OBJ_FIELDS(fields) ((struct rb_fields *)fields)
+
+#define IMEMO_SUBCLASSES_HEAP IMEMO_FL_USER0
+
+struct rb_subclasses {
+ VALUE flags;
+ uint32_t count;
+ uint32_t capacity;
+ union {
+ VALUE *external;
+ VALUE embed[1];
+ } as;
+};
+
+static inline VALUE *
+rb_imemo_subclasses_entries(VALUE v)
+{
+ struct rb_subclasses *s = (struct rb_subclasses *)v;
+ return FL_TEST_RAW(v, IMEMO_SUBCLASSES_HEAP) ? s->as.external : s->as.embed;
+}
+
+VALUE rb_imemo_fields_new(VALUE owner, /* shape_id_t */ uint32_t shape_id, bool shareable);
+VALUE rb_imemo_subclasses_new(uint32_t capacity);
+VALUE rb_imemo_fields_new_complex(VALUE owner, /* shape_id_t */ uint32_t shape_id, size_t capa, bool shareable);
+VALUE rb_imemo_fields_new_complex_tbl(VALUE owner, /* shape_id_t */ uint32_t shape_id, st_table *tbl, bool shareable);
+VALUE rb_imemo_fields_clone(VALUE fields_obj);
+void rb_imemo_fields_clear(VALUE fields_obj);
+
+static inline VALUE
+rb_imemo_fields_owner(VALUE fields_obj)
+{
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields));
+
+ return CLASS_OF(fields_obj);
+}
+
+static inline VALUE *
+rb_imemo_fields_ptr(VALUE fields_obj)
+{
+ if (!fields_obj) {
+ return NULL;
+ }
+
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields) || RB_TYPE_P(fields_obj, T_OBJECT));
+
+ if (UNLIKELY(FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP))) {
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.external.ptr;
+ }
+ else {
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.embed.fields;
+ }
+}
+
+static inline st_table *
+rb_imemo_fields_complex_tbl(VALUE fields_obj)
+{
+ if (!fields_obj) {
+ return NULL;
+ }
+
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields) || RB_TYPE_P(fields_obj, T_OBJECT));
+ RUBY_ASSERT(FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP));
+
+ // Some codepaths unconditionally access the fields_ptr, and assume it can be used as st_table if the
+ // shape is complex.
+ RUBY_ASSERT((st_table *)rb_imemo_fields_ptr(fields_obj) == IMEMO_OBJ_FIELDS(fields_obj)->as.complex.table);
+
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.complex.table;
+}
+
#endif /* INTERNAL_IMEMO_H */
diff --git a/internal/inits.h b/internal/inits.h
index 03e180f77b..be73dac1dc 100644
--- a/internal/inits.h
+++ b/internal/inits.h
@@ -9,6 +9,10 @@
* @brief Internal header aggregating init functions.
*/
+/* box.c */
+void Init_enable_box(void);
+void Init_master_box(void);
+
/* class.c */
void Init_class_hierarchy(void);
@@ -19,9 +23,6 @@ void Init_ext(void);
/* file.c */
void Init_File(void);
-/* gc.c */
-void Init_heap(void);
-
/* localeinit.c */
int Init_enc_set_filesystem_encoding(void);
diff --git a/internal/io.h b/internal/io.h
index b5f15499d7..2110f0b087 100644
--- a/internal/io.h
+++ b/internal/io.h
@@ -9,7 +9,132 @@
* @brief Internal header for IO.
*/
#include "ruby/ruby.h" /* for VALUE */
+
+#define HAVE_RB_IO_T
+struct rb_io;
+
#include "ruby/io.h" /* for rb_io_t */
+#include "ccan/list/list.h"
+#include "serial.h"
+
+#define IO_WITHOUT_GVL(func, arg) rb_nogvl(func, arg, RUBY_UBF_IO, 0, RB_NOGVL_OFFLOAD_SAFE)
+#define IO_WITHOUT_GVL_INT(func, arg) (int)(VALUE)IO_WITHOUT_GVL(func, arg)
+
+// Represents an in-flight blocking operation:
+struct rb_io_blocking_operation {
+ // The linked list data structure.
+ struct ccan_list_node list;
+
+ // The execution context of the blocking operation.
+ struct rb_execution_context_struct *ec;
+};
+
+/** Ruby's IO, metadata and buffers. */
+struct rb_io {
+
+ /** The IO's Ruby level counterpart. */
+ VALUE self;
+
+ /** stdio ptr for read/write, if available. */
+ FILE *stdio_file;
+
+ /** file descriptor. */
+ int fd;
+
+ /** mode flags: FMODE_XXXs */
+ enum rb_io_mode mode;
+
+ /** child's pid (for pipes) */
+ rb_pid_t pid;
+
+ /** number of lines read */
+ int lineno;
+
+ /** pathname for file */
+ VALUE pathv;
+
+ /** finalize proc */
+ void (*finalize)(struct rb_io*,int);
+
+ /** Write buffer. */
+ rb_io_buffer_t wbuf;
+
+ /**
+ * (Byte) read buffer. Note also that there is a field called
+ * ::rb_io_t::cbuf, which also concerns read IO.
+ */
+ rb_io_buffer_t rbuf;
+
+ /**
+ * Duplex IO object, if set.
+ *
+ * @see rb_io_set_write_io()
+ */
+ VALUE tied_io_for_writing;
+
+ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
+
+ /** Encoding converter used when reading from this IO. */
+ rb_econv_t *readconv;
+
+ /**
+ * rb_io_ungetc() destination. This buffer is read before checking
+ * ::rb_io_t::rbuf
+ */
+ rb_io_buffer_t cbuf;
+
+ /** Encoding converter used when writing to this IO. */
+ rb_econv_t *writeconv;
+
+ /**
+ * This is, when set, an instance of ::rb_cString which holds the "common"
+ * encoding. Write conversion can convert strings twice... In case
+ * conversion from encoding X to encoding Y does not exist, Ruby finds an
+ * encoding Z that bridges the two, so that X to Z to Y conversion happens.
+ */
+ VALUE writeconv_asciicompat;
+
+ /** Whether ::rb_io_t::writeconv is already set up. */
+ int writeconv_initialized;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
+ * initialising ::rb_io_t::writeconv.
+ */
+ int writeconv_pre_ecflags;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
+ * ::rb_io_t::writeconv.
+ */
+ VALUE writeconv_pre_ecopts;
+
+ /**
+ * This is a Ruby level mutex. It avoids multiple threads to write to an
+ * IO at once; helps for instance rb_io_puts() to ensure newlines right
+ * next to its arguments.
+ *
+ * This of course doesn't help inter-process IO interleaves, though.
+ */
+ VALUE write_lock;
+
+ /**
+ * The timeout associated with this IO when performing blocking operations.
+ */
+ VALUE timeout;
+
+ /**
+ * Threads that are performing a blocking operation without the GVL using
+ * this IO. On calling IO#close, these threads will be interrupted so that
+ * the operation can be cancelled.
+ */
+ struct ccan_list_head blocking_operations;
+ struct rb_execution_context_struct *closing_ec;
+ VALUE wakeup_mutex;
+
+ // The fork generation of the blocking operations list.
+ rb_serial_t fork_generation;
+};
/* io.c */
void ruby_set_inplace_mode(const char *);
@@ -17,22 +142,23 @@ void rb_stdio_set_default_encoding(void);
VALUE rb_io_flush_raw(VALUE, int);
size_t rb_io_memsize(const rb_io_t *);
int rb_stderr_tty_p(void);
-void rb_io_fptr_finalize_internal(void *ptr);
-#ifdef rb_io_fptr_finalize
-# undef rb_io_fptr_finalize
-#endif
-#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
VALUE rb_io_prep_stdin(void);
VALUE rb_io_prep_stdout(void);
VALUE rb_io_prep_stderr(void);
+int rb_io_notify_close(struct rb_io *fptr);
+bool rb_io_fptr_finalize_closed(struct rb_io *fptr);
+
RUBY_SYMBOL_EXPORT_BEGIN
/* io.c (export) */
void rb_maygvl_fd_fix_cloexec(int fd);
int rb_gc_for_fd(int err);
void rb_write_error_str(VALUE mesg);
+
+VALUE rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events);
+VALUE rb_io_blocking_region(struct rb_io *io, rb_blocking_function_t *function, void *argument);
RUBY_SYMBOL_EXPORT_END
#endif /* INTERNAL_IO_H */
diff --git a/internal/load.h b/internal/load.h
index d4c0bb91ba..6cffe0ce64 100644
--- a/internal/load.h
+++ b/internal/load.h
@@ -12,6 +12,8 @@
/* load.c */
VALUE rb_get_expanded_load_path(void);
+VALUE rb_load_entrypoint(VALUE fname, VALUE wrap);
+VALUE rb_require_relative_entrypoint(VALUE fname);
int rb_require_internal(VALUE fname);
NORETURN(void rb_load_fail(VALUE, const char*));
diff --git a/internal/missing.h b/internal/missing.h
index c0992a151a..6ca508c8f9 100644
--- a/internal/missing.h
+++ b/internal/missing.h
@@ -13,6 +13,7 @@
/* missing/setproctitle.c */
#ifndef HAVE_SETPROCTITLE
extern void ruby_init_setproctitle(int argc, char *argv[]);
+extern void ruby_free_proctitle(void);
#endif
#endif /* INTERNAL_MISSING_H */
diff --git a/internal/numeric.h b/internal/numeric.h
index f7b8d0ad2d..a24432df1e 100644
--- a/internal/numeric.h
+++ b/internal/numeric.h
@@ -10,9 +10,9 @@
*/
#include "internal/bignum.h" /* for BIGNUM_POSITIVE_P */
#include "internal/bits.h" /* for RUBY_BIT_ROTL */
+#include "internal/compar.h" /* for rb_cmperr_reason */
#include "internal/fixnum.h" /* for FIXNUM_POSITIVE_P */
#include "internal/vm.h" /* for rb_method_basic_definition_p */
-#include "ruby/intern.h" /* for rb_cmperr */
#include "ruby/ruby.h" /* for USE_FLONUM */
#define ROUND_TO(mode, even, up, down) \
@@ -70,6 +70,7 @@ VALUE rb_float_minus(VALUE x, VALUE y);
VALUE rb_int_mul(VALUE x, VALUE y);
VALUE rb_float_mul(VALUE x, VALUE y);
VALUE rb_float_div(VALUE x, VALUE y);
+VALUE rb_flo_to_i(VALUE num);
VALUE rb_int_idiv(VALUE x, VALUE y);
VALUE rb_int_modulo(VALUE x, VALUE y);
VALUE rb_int2str(VALUE num, int base);
@@ -78,6 +79,7 @@ VALUE rb_int_gt(VALUE x, VALUE y);
VALUE rb_float_gt(VALUE x, VALUE y);
VALUE rb_int_ge(VALUE x, VALUE y);
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
+VALUE rb_int_fdiv(VALUE x, VALUE y);
double rb_int_fdiv_double(VALUE x, VALUE y);
VALUE rb_int_pow(VALUE x, VALUE y);
VALUE rb_float_pow(VALUE x, VALUE y);
@@ -85,7 +87,9 @@ VALUE rb_int_cmp(VALUE x, VALUE y);
VALUE rb_int_equal(VALUE x, VALUE y);
VALUE rb_int_divmod(VALUE x, VALUE y);
VALUE rb_int_and(VALUE x, VALUE y);
+VALUE rb_int_xor(VALUE x, VALUE y);
VALUE rb_int_lshift(VALUE x, VALUE y);
+VALUE rb_int_rshift(VALUE x, VALUE y);
VALUE rb_int_div(VALUE x, VALUE y);
int rb_int_positive_p(VALUE num);
int rb_int_negative_p(VALUE num);
@@ -125,6 +129,54 @@ VALUE rb_int_bit_length(VALUE num);
VALUE rb_int_uminus(VALUE num);
VALUE rb_int_comp(VALUE num);
+// Unified 128-bit integer structures that work with or without native support:
+union rb_uint128 {
+#ifdef WORDS_BIGENDIAN
+ struct {
+ uint64_t high;
+ uint64_t low;
+ } parts;
+#else
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } parts;
+#endif
+#ifdef HAVE_UINT128_T
+ uint128_t value;
+#endif
+};
+typedef union rb_uint128 rb_uint128_t;
+
+union rb_int128 {
+#ifdef WORDS_BIGENDIAN
+ struct {
+ uint64_t high;
+ uint64_t low;
+ } parts;
+#else
+ struct {
+ uint64_t low;
+ uint64_t high;
+ } parts;
+#endif
+#ifdef HAVE_UINT128_T
+ int128_t value;
+#endif
+};
+typedef union rb_int128 rb_int128_t;
+
+union uint128_int128_conversion {
+ rb_uint128_t uint128;
+ rb_int128_t int128;
+};
+
+// Conversion functions for 128-bit integers:
+rb_uint128_t rb_numeric_to_uint128(VALUE x);
+rb_int128_t rb_numeric_to_int128(VALUE x);
+VALUE rb_uint128_to_numeric(rb_uint128_t n);
+VALUE rb_int128_to_numeric(rb_int128_t n);
+
static inline bool
INT_POSITIVE_P(VALUE num)
{
@@ -158,8 +210,8 @@ rb_num_compare_with_zero(VALUE num, ID mid)
{
VALUE zero = INT2FIX(0);
VALUE r = rb_check_funcall(num, mid, 1, &zero);
- if (r == Qundef) {
- rb_cmperr(num, zero);
+ if (RB_UNDEF_P(r)) {
+ rb_cmperr_reason(num, zero, "unable to compare with zero");
}
return r;
}
diff --git a/internal/object.h b/internal/object.h
index 58e989562a..99aa1f524b 100644
--- a/internal/object.h
+++ b/internal/object.h
@@ -11,10 +11,14 @@
#include "ruby/ruby.h" /* for VALUE */
/* object.c */
+
+VALUE rb_class_allocate_instance(VALUE klass);
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
NORETURN(void rb_undefined_alloc(VALUE klass));
double rb_num_to_dbl(VALUE val);
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
+VALUE rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze);
+VALUE rb_obj_dup_setup(VALUE obj, VALUE dup);
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
int rb_bool_expected(VALUE, const char *, int raise);
@@ -56,4 +60,13 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
RBASIC_SET_CLASS_RAW(obj, klass);
RB_OBJ_WRITTEN(obj, oldv, klass);
}
+
+static inline size_t
+rb_obj_embedded_size(uint32_t fields_count)
+{
+ size_t size = offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count);
+ // Ensure enough room for the heap pointer if this expands
+ if (size < sizeof(struct RObject)) size = sizeof(struct RObject);
+ return size;
+}
#endif /* INTERNAL_OBJECT_H */
diff --git a/internal/parse.h b/internal/parse.h
index f242c384ad..8e04664ae8 100644
--- a/internal/parse.h
+++ b/internal/parse.h
@@ -8,18 +8,124 @@
* file COPYING are met. Consult the file for details.
* @brief Internal header for the parser.
*/
-#include "ruby/ruby.h" /* for VALUE */
+#include <limits.h>
+#include "rubyparser.h"
+#include "internal/static_assert.h"
+
+// The default parser to use for Ruby code.
+typedef enum {
+ RB_DEFAULT_PARSER_PARSE_Y,
+ RB_DEFAULT_PARSER_PRISM,
+} ruby_default_parser_enum;
+
+ruby_default_parser_enum rb_ruby_default_parser(void);
+void rb_ruby_default_parser_set(ruby_default_parser_enum parser);
+
+#define rb_ruby_prism_p() (rb_ruby_default_parser() == RB_DEFAULT_PARSER_PRISM)
+
+#ifdef UNIVERSAL_PARSER
+#define rb_encoding const void
+#endif
+
struct rb_iseq_struct; /* in vm_core.h */
+/* structs for managing terminator of string literal and heredocment */
+typedef struct rb_strterm_literal_struct {
+ long nest;
+ int func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
+ int paren; /* '(' of `%q(...)` */
+ int term; /* ')' of `%q(...)` */
+} rb_strterm_literal_t;
+
+typedef struct rb_strterm_heredoc_struct {
+ rb_parser_string_t *lastline; /* the string of line that contains `<<"END"` */
+ long offset; /* the column of END in `<<"END"` */
+ int sourceline; /* lineno of the line that contains `<<"END"` */
+ unsigned length; /* the length of END in `<<"END"` */
+ uint8_t quote;
+ uint8_t func;
+} rb_strterm_heredoc_t;
+
+#define HERETERM_LENGTH_MAX UINT_MAX
+
+typedef struct rb_strterm_struct {
+ bool heredoc;
+ union {
+ rb_strterm_literal_t literal;
+ rb_strterm_heredoc_t heredoc;
+ } u;
+} rb_strterm_t;
+
/* parse.y */
-VALUE rb_parser_set_yydebug(VALUE, VALUE);
-void *rb_parser_load_file(VALUE parser, VALUE name);
-void rb_parser_keep_script_lines(VALUE vparser);
-void rb_parser_error_tolerant(VALUE vparser);
-void rb_parser_keep_tokens(VALUE vparser);
+void rb_ruby_parser_mark(void *ptr);
+size_t rb_ruby_parser_memsize(const void *ptr);
+
+void rb_ruby_parser_set_options(rb_parser_t *p, int print, int loop, int chomp, int split);
+rb_parser_t *rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main);
+void rb_ruby_parser_set_script_lines(rb_parser_t *p);
+void rb_ruby_parser_error_tolerant(rb_parser_t *p);
+void rb_ruby_parser_keep_tokens(rb_parser_t *p);
+typedef rb_parser_string_t*(rb_parser_lex_gets_func)(struct parser_params*, rb_parser_input_data, int);
+rb_ast_t *rb_parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, VALUE fname, rb_parser_input_data input, int line);
RUBY_SYMBOL_EXPORT_BEGIN
-VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
+
+rb_encoding *rb_ruby_parser_encoding(rb_parser_t *p);
+int rb_ruby_parser_end_seen_p(rb_parser_t *p);
+int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
+rb_parser_string_t *rb_str_to_parser_string(rb_parser_t *p, VALUE str);
+void rb_parser_string_free(rb_parser_t *p, rb_parser_string_t *str);
+
+int rb_parser_dvar_defined_ref(struct parser_params*, ID, ID**);
+ID rb_parser_internal_id(struct parser_params*);
+typedef void (*rb_parser_reg_fragment_error_func)(struct parser_params *, VALUE);
+int rb_parser_reg_fragment_check(struct parser_params*, rb_parser_string_t*, int, rb_parser_reg_fragment_error_func);
+int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc, rb_parser_assignable_func assignable);
+int rb_parser_local_defined(struct parser_params *p, ID id, const struct rb_iseq_struct *iseq);
+NODE *rb_parser_assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc);
+
RUBY_SYMBOL_EXPORT_END
+#ifndef UNIVERSAL_PARSER
+rb_parser_t *rb_ruby_parser_allocate(void);
+rb_parser_t *rb_ruby_parser_new(void);
+#endif
+
+#ifdef RIPPER
+void ripper_parser_mark(void *ptr);
+void ripper_parser_free(void *ptr);
+size_t ripper_parser_memsize(const void *ptr);
+void ripper_error(struct parser_params *p);
+VALUE ripper_value(struct parser_params *p);
+int rb_ruby_parser_get_yydebug(rb_parser_t *p);
+void rb_ruby_parser_set_value(rb_parser_t *p, VALUE value);
+int rb_ruby_parser_error_p(rb_parser_t *p);
+VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
+void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
+VALUE rb_ruby_parser_parsing_thread(rb_parser_t *p);
+void rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread);
+void rb_ruby_parser_ripper_initialize(rb_parser_t *p, rb_parser_lex_gets_func *gets, rb_parser_input_data input, VALUE sourcefile_string, const char *sourcefile, int sourceline);
+VALUE rb_ruby_parser_result(rb_parser_t *p);
+rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
+VALUE rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p);
+int rb_ruby_parser_ruby_sourceline(rb_parser_t *p);
+int rb_ruby_parser_lex_state(rb_parser_t *p);
+void rb_ruby_ripper_parse0(rb_parser_t *p);
+int rb_ruby_ripper_dedent_string(rb_parser_t *p, rb_parser_string_t *string, int width);
+int rb_ruby_ripper_initialized_p(rb_parser_t *p);
+void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
+long rb_ruby_ripper_column(rb_parser_t *p);
+long rb_ruby_ripper_token_len(rb_parser_t *p);
+rb_parser_string_t *rb_ruby_ripper_lex_lastline(rb_parser_t *p);
+VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
+#ifdef UNIVERSAL_PARSER
+rb_parser_t *rb_ripper_parser_params_allocate(const rb_parser_config_t *config);
+#endif
+struct parser_params *rb_ruby_ripper_parser_allocate(void);
+#endif
+
+#ifdef UNIVERSAL_PARSER
+#undef rb_encoding
+#endif
+
#endif /* INTERNAL_PARSE_H */
diff --git a/internal/proc.h b/internal/proc.h
index c75f15b283..24a077ca6d 100644
--- a/internal/proc.h
+++ b/internal/proc.h
@@ -22,7 +22,7 @@ int rb_block_min_max_arity(int *max);
VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
VALUE rb_callable_receiver(VALUE);
-VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
+VALUE rb_func_proc_dup(VALUE src_obj);
VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
VALUE rb_iseq_location(const struct rb_iseq_struct *iseq);
VALUE rb_sym_to_proc(VALUE sym);
diff --git a/internal/process.h b/internal/process.h
index b9c52aebaa..fd4994cb4b 100644
--- a/internal/process.h
+++ b/internal/process.h
@@ -22,7 +22,6 @@
#include "ruby/ruby.h" /* for VALUE */
#include "internal/compilers.h" /* for __has_warning */
#include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
-#include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */
#define RB_MAX_GROUPS (65536)
@@ -122,17 +121,4 @@ ARGVSTR2ARGC(VALUE argv_str)
return i - 1;
}
-#ifdef HAVE_WORKING_FORK
-COMPILER_WARNING_PUSH
-#if __has_warning("-Wdeprecated-declarations") || RBIMPL_COMPILER_IS(GCC)
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
-static inline rb_pid_t
-rb_fork(void)
-{
- return fork();
-}
-COMPILER_WARNING_POP
-#endif
-
#endif /* INTERNAL_PROCESS_H */
diff --git a/internal/ractor.h b/internal/ractor.h
index eef5ffdb89..a65907a05a 100644
--- a/internal/ractor.h
+++ b/internal/ractor.h
@@ -3,4 +3,8 @@
void rb_ractor_ensure_main_ractor(const char *msg);
+RUBY_SYMBOL_EXPORT_BEGIN
+void rb_ractor_setup_belonging(VALUE obj);
+RUBY_SYMBOL_EXPORT_END
+
#endif /* INTERNAL_RACTOR_H */
diff --git a/internal/random.h b/internal/random.h
index 231e2d5d7e..127b908e16 100644
--- a/internal/random.h
+++ b/internal/random.h
@@ -12,5 +12,6 @@
/* random.c */
int ruby_fill_random_bytes(void *, size_t, int);
+void rb_free_default_rand_key(void);
#endif /* INTERNAL_RANDOM_H */
diff --git a/internal/range.h b/internal/range.h
index 8daba0ecab..80493ce13e 100644
--- a/internal/range.h
+++ b/internal/range.h
@@ -18,19 +18,19 @@ static inline VALUE RANGE_EXCL(VALUE r);
static inline VALUE
RANGE_BEG(VALUE r)
{
- return RSTRUCT(r)->as.ary[0];
+ return RSTRUCT_GET_RAW(r, 0);
}
static inline VALUE
RANGE_END(VALUE r)
{
- return RSTRUCT(r)->as.ary[1];
+ return RSTRUCT_GET_RAW(r, 1);
}
static inline VALUE
RANGE_EXCL(VALUE r)
{
- return RSTRUCT(r)->as.ary[2];
+ return RSTRUCT_GET_RAW(r, 2);
}
VALUE
diff --git a/internal/rational.h b/internal/rational.h
index f11fab4583..6861a90130 100644
--- a/internal/rational.h
+++ b/internal/rational.h
@@ -28,6 +28,7 @@ VALUE rb_rational_plus(VALUE self, VALUE other);
VALUE rb_rational_minus(VALUE self, VALUE other);
VALUE rb_rational_mul(VALUE self, VALUE other);
VALUE rb_rational_div(VALUE self, VALUE other);
+VALUE rb_rational_fdiv(VALUE self, VALUE other);
VALUE rb_lcm(VALUE x, VALUE y);
VALUE rb_rational_reciprocal(VALUE x);
VALUE rb_cstr_to_rat(const char *, int);
@@ -37,7 +38,9 @@ VALUE rb_rational_cmp(VALUE self, VALUE other);
VALUE rb_rational_pow(VALUE self, VALUE other);
VALUE rb_rational_floor(VALUE self, int ndigits);
VALUE rb_numeric_quo(VALUE x, VALUE y);
-VALUE rb_flo_round_by_rational(int argc, VALUE *argv, VALUE num);
+VALUE rb_flo_round_by_rational(VALUE num, int ndigits, enum ruby_num_rounding_mode mode);
+VALUE rb_flo_ceil_by_rational(VALUE num, int ndigits);
+VALUE rb_flo_floor_by_rational(VALUE num, int ndigits);
VALUE rb_float_numerator(VALUE x);
VALUE rb_float_denominator(VALUE x);
@@ -68,4 +71,22 @@ RATIONAL_SET_DEN(VALUE r, VALUE d)
RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d);
}
+inline static bool
+f_zero_p(VALUE x)
+{
+ if (RB_INTEGER_TYPE_P(x)) {
+ return FIXNUM_ZERO_P(x);
+ }
+ else if (RB_FLOAT_TYPE_P(x)) {
+ return FLOAT_ZERO_P(x);
+ }
+ else if (RB_TYPE_P(x, T_RATIONAL)) {
+ const VALUE num = RRATIONAL(x)->num;
+ return FIXNUM_ZERO_P(num);
+ }
+ return rb_equal(x, INT2FIX(0)) != 0;
+}
+
+#define f_nonzero_p(x) (!f_zero_p(x))
+
#endif /* INTERNAL_RATIONAL_H */
diff --git a/internal/re.h b/internal/re.h
index 7b2505b9a8..6c0aee6d06 100644
--- a/internal/re.h
+++ b/internal/re.h
@@ -10,19 +10,70 @@
*/
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */
+#include "ruby/re.h" /* for struct RMatch and struct re_registers */
+
+#define RMATCH_ONIG FL_USER1
+#define RMATCH_OFFSETS_EXTERNAL FL_USER2
+
+static inline OnigPosition *
+RMATCH_BEG_PTR(VALUE match)
+{
+ if (FL_TEST_RAW(match, RMATCH_ONIG)) {
+ return RMATCH(match)->as.onig.beg;
+ }
+ else {
+ return &RMATCH(match)->as.embed[0];
+ }
+}
+
+static inline OnigPosition *
+RMATCH_END_PTR(VALUE match)
+{
+ if (FL_TEST_RAW(match, RMATCH_ONIG)) {
+ return RMATCH(match)->as.onig.end;
+ }
+ else {
+ return &RMATCH(match)->as.embed[RMATCH(match)->num_regs];
+ }
+}
+
+static inline long
+RMATCH_BEG(VALUE match, int i)
+{
+ return RMATCH_BEG_PTR(match)[i];
+}
+
+static inline long
+RMATCH_END(VALUE match, int i)
+{
+ return RMATCH_END_PTR(match)[i];
+}
+
+static inline int
+RMATCH_NREGS(VALUE match)
+{
+ return RMATCH(match)->num_regs;
+}
/* re.c */
+VALUE rb_reg_s_alloc(VALUE klass);
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
VALUE rb_reg_check_preprocess(VALUE);
-long rb_reg_search0(VALUE, VALUE, long, int, int);
+long rb_reg_search0(VALUE, VALUE, long, int, int, VALUE *);
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
+VALUE rb_reg_regsub_match(VALUE str, VALUE src, VALUE match);
bool rb_reg_start_with_p(VALUE re, VALUE str);
VALUE rb_reg_hash(VALUE re);
VALUE rb_reg_equal(VALUE re1, VALUE re2);
-void rb_backref_set_string(VALUE string, long pos, long len);
+VALUE rb_backref_set_string(VALUE string, long pos, long len);
void rb_match_unbusy(VALUE);
int rb_match_count(VALUE match);
-int rb_match_nth_defined(int nth, VALUE match);
-VALUE rb_reg_new_ary(VALUE ary, int options);
+VALUE rb_reg_new_from_values(long cnt, const VALUE *elements, int opt);
+VALUE rb_reg_last_defined(VALUE match);
+
+#define ARG_REG_OPTION_MASK \
+ (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND)
+#define ARG_ENCODING_FIXED 16
+#define ARG_ENCODING_NONE 32
#endif /* INTERNAL_RE_H */
diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h
new file mode 100644
index 0000000000..8e306d18de
--- /dev/null
+++ b/internal/ruby_parser.h
@@ -0,0 +1,102 @@
+#ifndef INTERNAL_RUBY_PARSE_H
+#define INTERNAL_RUBY_PARSE_H
+
+#include "internal.h"
+#include "internal/bignum.h"
+#include "internal/compilers.h"
+#include "internal/complex.h"
+#include "internal/parse.h"
+#include "internal/rational.h"
+#include "rubyparser.h"
+#include "vm.h"
+
+struct lex_pointer_string {
+ VALUE str;
+ long ptr;
+};
+
+RUBY_SYMBOL_EXPORT_BEGIN
+#ifdef UNIVERSAL_PARSER
+const rb_parser_config_t *rb_ruby_parser_config(void);
+rb_parser_t *rb_parser_params_new(void);
+#endif
+VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
+VALUE rb_parser_new(void);
+VALUE rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
+VALUE rb_str_new_parser_string(rb_parser_string_t *str);
+VALUE rb_str_new_mutable_parser_string(rb_parser_string_t *str);
+rb_parser_string_t *rb_parser_lex_get_str(struct parser_params *p, struct lex_pointer_string *ptr_str);
+
+VALUE rb_node_str_string_val(const NODE *);
+VALUE rb_node_sym_string_val(const NODE *);
+VALUE rb_node_dstr_string_val(const NODE *);
+VALUE rb_node_regx_string_val(const NODE *);
+VALUE rb_node_dregx_string_val(const NODE *);
+VALUE rb_node_line_lineno_val(const NODE *);
+VALUE rb_node_file_path_val(const NODE *);
+VALUE rb_node_encoding_val(const NODE *);
+
+VALUE rb_node_integer_literal_val(const NODE *);
+VALUE rb_node_float_literal_val(const NODE *);
+VALUE rb_node_rational_literal_val(const NODE *);
+VALUE rb_node_imaginary_literal_val(const NODE *);
+RUBY_SYMBOL_EXPORT_END
+
+VALUE rb_parser_end_seen_p(VALUE);
+VALUE rb_parser_encoding(VALUE);
+VALUE rb_parser_set_yydebug(VALUE, VALUE);
+VALUE rb_parser_build_script_lines_from(rb_parser_ary_t *script_lines);
+void rb_parser_set_options(VALUE, int, int, int, int);
+VALUE rb_parser_load_file(VALUE parser, VALUE name);
+void rb_parser_set_script_lines(VALUE vparser);
+void rb_parser_error_tolerant(VALUE vparser);
+void rb_parser_keep_tokens(VALUE vparser);
+
+VALUE rb_parser_compile_string(VALUE, const char*, VALUE, int);
+VALUE rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
+VALUE rb_parser_compile_generic(VALUE vparser, rb_parser_lex_gets_func *lex_gets, VALUE fname, VALUE input, int line);
+VALUE rb_parser_compile_array(VALUE vparser, VALUE fname, VALUE array, int start);
+
+enum lex_state_bits {
+ EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
+ EXPR_END_bit, /* newline significant, +/- is an operator. */
+ EXPR_ENDARG_bit, /* ditto, and unbound braces. */
+ EXPR_ENDFN_bit, /* ditto, and unbound braces. */
+ EXPR_ARG_bit, /* newline significant, +/- is an operator. */
+ EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
+ EXPR_MID_bit, /* newline significant, +/- is an operator. */
+ EXPR_FNAME_bit, /* ignore newline, no reserved words. */
+ EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
+ EXPR_CLASS_bit, /* immediate after `class', no here document. */
+ EXPR_LABEL_bit, /* flag bit, label is allowed. */
+ EXPR_LABELED_bit, /* flag bit, just after a label. */
+ EXPR_FITEM_bit, /* symbol literal as FNAME. */
+ EXPR_MAX_STATE
+};
+/* examine combinations */
+enum lex_state_e {
+#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
+ DEF_EXPR(BEG),
+ DEF_EXPR(END),
+ DEF_EXPR(ENDARG),
+ DEF_EXPR(ENDFN),
+ DEF_EXPR(ARG),
+ DEF_EXPR(CMDARG),
+ DEF_EXPR(MID),
+ DEF_EXPR(FNAME),
+ DEF_EXPR(DOT),
+ DEF_EXPR(CLASS),
+ DEF_EXPR(LABEL),
+ DEF_EXPR(LABELED),
+ DEF_EXPR(FITEM),
+ EXPR_VALUE = EXPR_BEG,
+ EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
+ EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
+ EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
+ EXPR_NONE = 0
+};
+
+VALUE rb_ruby_ast_new(const NODE *const root);
+rb_ast_t *rb_ruby_ast_data_get(VALUE ast_value);
+
+#endif /* INTERNAL_RUBY_PARSE_H */
diff --git a/internal/sanitizers.h b/internal/sanitizers.h
index 7b7d166c74..feafb4e616 100644
--- a/internal/sanitizers.h
+++ b/internal/sanitizers.h
@@ -16,25 +16,42 @@
#endif
#ifdef HAVE_SANITIZER_ASAN_INTERFACE_H
-# include <sanitizer/asan_interface.h>
+# if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+# define RUBY_ASAN_ENABLED
+# include <sanitizer/asan_interface.h>
+# endif
#endif
#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
# if __has_feature(memory_sanitizer)
+# define RUBY_MSAN_ENABLED
# include <sanitizer/msan_interface.h>
# endif
#endif
+#ifdef HAVE_SANITIZER_TSAN_INTERFACE_H
+# if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
+# define RUBY_TSAN_ENABLED
+# include <sanitizer/tsan_interface.h>
+# endif
+#endif
+
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */
#if 0
-#elif __has_feature(memory_sanitizer) && __has_feature(address_sanitizer)
+#elif defined(RUBY_ASAN_ENABLED) && defined(RUBY_MSAN_ENABLED)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
__attribute__((__no_sanitize__("memory, address"), __noinline__)) x
-#elif __has_feature(address_sanitizer)
+#elif defined(RUBY_ASAN_ENABLED)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
__attribute__((__no_sanitize__("address"), __noinline__)) x
+#elif defined(RUBY_MSAN_ENABLED)
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
+ __attribute__((__no_sanitize__("memory"), __noinline__)) x
+#elif defined(RUBY_TSAN_ENABLED)
+# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
+ __attribute__((__no_sanitize__("thread"), __noinline__)) x
#elif defined(NO_SANITIZE_ADDRESS)
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
NO_SANITIZE_ADDRESS(NOINLINE(x))
@@ -50,23 +67,26 @@
# include "internal/warnings.h"
# undef NO_SANITIZE
# define NO_SANITIZE(x, y) \
- COMPILER_WARNING_PUSH; \
- COMPILER_WARNING_IGNORED(-Wattributes); \
+ COMPILER_WARNING_PUSH \
+ COMPILER_WARNING_IGNORED(-Wattributes) \
__attribute__((__no_sanitize__(x))) y; \
- COMPILER_WARNING_POP
+ COMPILER_WARNING_POP \
+ y
#endif
#ifndef NO_SANITIZE
# define NO_SANITIZE(x, y) y
#endif
-#if !__has_feature(address_sanitizer)
+#ifndef RUBY_ASAN_ENABLED
# define __asan_poison_memory_region(x, y)
# define __asan_unpoison_memory_region(x, y)
# define __asan_region_is_poisoned(x, y) 0
+# define __asan_get_current_fake_stack() NULL
+# define __asan_addr_is_in_fake_stack(fake_stack, slot, start, end) NULL
#endif
-#if !__has_feature(memory_sanitizer)
+#ifndef RUBY_MSAN_ENABLED
# define __msan_allocated_memory(x, y) ((void)(x), (void)(y))
# define __msan_poison(x, y) ((void)(x), (void)(y))
# define __msan_unpoison(x, y) ((void)(x), (void)(y))
@@ -89,7 +109,7 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
-/*!
+/**
* This function asserts that a (continuous) memory region from ptr to size
* being "poisoned". Both read / write access to such memory region are
* prohibited until properly unpoisoned. The region must be previously
@@ -99,8 +119,8 @@
* region to reuse later: poison when you keep it unused, and unpoison when you
* reuse.
*
- * \param[in] ptr pointer to the beginning of the memory region to poison.
- * \param[in] size the length of the memory region to poison.
+ * @param[in] ptr pointer to the beginning of the memory region to poison.
+ * @param[in] size the length of the memory region to poison.
*/
static inline void
asan_poison_memory_region(const volatile void *ptr, size_t size)
@@ -109,41 +129,48 @@ asan_poison_memory_region(const volatile void *ptr, size_t size)
__asan_poison_memory_region(ptr, size);
}
-/*!
- * This is a variant of asan_poison_memory_region that takes a VALUE.
- *
- * \param[in] obj target object.
- */
-static inline void
-asan_poison_object(VALUE obj)
-{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- asan_poison_memory_region(ptr, SIZEOF_VALUE);
-}
-
-#if !__has_feature(address_sanitizer)
-#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
-#else
+#ifdef RUBY_ASAN_ENABLED
#define asan_poison_object_if(ptr, obj) do { \
- if (ptr) asan_poison_object(obj); \
+ if (ptr) rb_asan_poison_object(obj); \
} while (0)
+#else
+#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
#endif
-/*!
+#ifdef RUBY_ASAN_ENABLED
+RUBY_SYMBOL_EXPORT_BEGIN
+/**
+ * This is a variant of asan_poison_memory_region that takes a VALUE.
+ *
+ * @param[in] obj target object.
+ */
+void rb_asan_poison_object(VALUE obj);
+
+/**
* This function predicates if the given object is fully addressable or not.
*
- * \param[in] obj target object.
- * \retval 0 the given object is fully addressable.
- * \retval otherwise pointer to first such byte who is poisoned.
+ * @param[in] obj target object.
+ * @retval 0 the given object is fully addressable.
+ * @retval otherwise pointer to first such byte who is poisoned.
*/
-static inline void *
-asan_poisoned_object_p(VALUE obj)
-{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- return __asan_region_is_poisoned(ptr, SIZEOF_VALUE);
-}
+void *rb_asan_poisoned_object_p(VALUE obj);
-/*!
+/**
+ * This is a variant of asan_unpoison_memory_region that takes a VALUE.
+ *
+ * @param[in] obj target object.
+ * @param[in] malloc_p if the memory region is like a malloc's return value or not.
+ */
+void rb_asan_unpoison_object(VALUE obj, bool newobj_p);
+
+RUBY_SYMBOL_EXPORT_END
+#else
+# define rb_asan_poison_object(obj) ((void)obj)
+# define rb_asan_poisoned_object_p(obj) ((void)obj, NULL)
+# define rb_asan_unpoison_object(obj, newobj_p) ((void)obj, (void)newobj_p)
+#endif
+
+/**
* This function asserts that a (formally poisoned) memory region from ptr to
* size is now addressable. Write access to such memory region gets allowed.
* However read access might or might not be possible depending on situations,
@@ -154,9 +181,9 @@ asan_poisoned_object_p(VALUE obj)
* the other hand, that memory region is fully defined and can be read
* immediately.
*
- * \param[in] ptr pointer to the beginning of the memory region to unpoison.
- * \param[in] size the length of the memory region.
- * \param[in] malloc_p if the memory region is like a malloc's return value or not.
+ * @param[in] ptr pointer to the beginning of the memory region to unpoison.
+ * @param[in] size the length of the memory region.
+ * @param[in] malloc_p if the memory region is like a malloc's return value or not.
*/
static inline void
asan_unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
@@ -170,17 +197,150 @@ asan_unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p
}
}
-/*!
- * This is a variant of asan_unpoison_memory_region that takes a VALUE.
+static inline void *
+asan_unpoison_object_temporary(VALUE obj)
+{
+ void *ptr = rb_asan_poisoned_object_p(obj);
+ rb_asan_unpoison_object(obj, false);
+ return ptr;
+}
+
+static inline void *
+asan_poison_object_restore(VALUE obj, void *ptr)
+{
+ if (ptr) {
+ rb_asan_poison_object(obj);
+ }
+ return NULL;
+}
+
+#define asan_unpoisoning_object(obj) \
+ for (void *poisoned = asan_unpoison_object_temporary(obj), \
+ *unpoisoning = &poisoned; /* flag to loop just once */ \
+ unpoisoning; \
+ unpoisoning = asan_poison_object_restore(obj, poisoned))
+
+
+static inline void *
+asan_unpoison_memory_region_temporary(void *ptr, size_t len)
+{
+ void *poisoned_ptr = __asan_region_is_poisoned(ptr, len);
+ asan_unpoison_memory_region(ptr, len, false);
+ return poisoned_ptr;
+}
+
+static inline void *
+asan_poison_memory_region_restore(void *ptr, size_t len, void *poisoned_ptr)
+{
+ if (poisoned_ptr) {
+ asan_poison_memory_region(ptr, len);
+ }
+ return NULL;
+}
+
+#define asan_unpoisoning_memory_region(ptr, len) \
+ for (void *poisoned = asan_unpoison_memory_region_temporary(ptr, len), \
+ *unpoisoning = &poisoned; /* flag to loop just once */ \
+ unpoisoning; \
+ unpoisoning = asan_poison_memory_region_restore(ptr, len, poisoned))
+
+/**
+ * Checks if the given pointer is on an ASAN fake stack. If so, it returns the
+ * address this variable has on the real frame; if not, it returns the origin
+ * address unmodified.
+ *
+ * n.b. - _dereferencing_ the returned address is meaningless and should not
+ * be done; even though ASAN reserves space for the variable in both the real and
+ * fake stacks, the _value_ of that variable is only in the fake stack.
*
- * \param[in] obj target object.
- * \param[in] malloc_p if the memory region is like a malloc's return value or not.
+ * n.b. - this only works for addresses passed in from local variables on the same
+ * thread, because the ASAN fake stacks are threadlocal.
+ *
+ * @param[in] slot the address of some local variable
+ * @retval a pointer to something from that frame on the _real_ machine stack
*/
-static inline void
-asan_unpoison_object(VALUE obj, bool newobj_p)
+static inline void *
+asan_get_real_stack_addr(void* slot)
+{
+ VALUE *addr;
+ addr = __asan_addr_is_in_fake_stack(__asan_get_current_fake_stack(), slot, NULL, NULL);
+ return addr ? addr : slot;
+}
+
+/**
+ * Gets the current thread's fake stack handle, which can be passed into get_fake_stack_extents
+ *
+ * @retval An opaque value which can be passed to asan_get_fake_stack_extents
+ */
+static inline void *
+asan_get_thread_fake_stack_handle(void)
{
- MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
- asan_unpoison_memory_region(ptr, SIZEOF_VALUE, newobj_p);
+ return __asan_get_current_fake_stack();
}
+/**
+ * Checks if the given VALUE _actually_ represents a pointer to an ASAN fake stack.
+ *
+ * If the given slot _is_ actually a reference to an ASAN fake stack, and that fake stack
+ * contains the real values for the passed-in range of machine stack addresses, returns true
+ * and the range of the fake stack through the outparams.
+ *
+ * Otherwise, returns false, and sets the outparams to NULL.
+ *
+ * Note that this function expects "start" to be > "end" on downward-growing stack architectures;
+ *
+ * @param[in] thread_fake_stack_handle The asan fake stack reference for the thread we're scanning
+ * @param[in] slot The value on the machine stack we want to inspect
+ * @param[in] machine_stack_start The extents of the real machine stack on which slot lives
+ * @param[in] machine_stack_end The extents of the real machine stack on which slot lives
+ * @param[out] fake_stack_start_out The extents of the fake stack which contains real VALUEs
+ * @param[out] fake_stack_end_out The extents of the fake stack which contains real VALUEs
+ * @return Whether slot is a pointer to a fake stack for the given machine stack range
+*/
+
+static inline bool
+asan_get_fake_stack_extents(void *thread_fake_stack_handle, VALUE slot,
+ void *machine_stack_start, void *machine_stack_end,
+ void **fake_stack_start_out, void **fake_stack_end_out)
+{
+ /* the ifdef is needed here to suppress a warning about fake_frame_{start/end} being
+ uninitialized if __asan_addr_is_in_fake_stack is an empty macro */
+#ifdef RUBY_ASAN_ENABLED
+ void *fake_frame_start;
+ void *fake_frame_end;
+ void *real_stack_frame = __asan_addr_is_in_fake_stack(
+ thread_fake_stack_handle, (void *)slot, &fake_frame_start, &fake_frame_end
+ );
+ if (real_stack_frame) {
+ bool in_range;
+#if STACK_GROW_DIRECTION < 0
+ in_range = machine_stack_start >= real_stack_frame && real_stack_frame >= machine_stack_end;
+#else
+ in_range = machine_stack_start <= real_stack_frame && real_stack_frame <= machine_stack_end;
+#endif
+ if (in_range) {
+ *fake_stack_start_out = fake_frame_start;
+ *fake_stack_end_out = fake_frame_end;
+ return true;
+ }
+ }
+#endif
+ *fake_stack_start_out = 0;
+ *fake_stack_end_out = 0;
+ return false;
+}
+
+extern const char ruby_asan_default_options[];
+
+#ifdef RUBY_ASAN_ENABLED
+/* Compile in the ASAN options Ruby needs, rather than relying on environment variables, so
+ * that even tests which fork ruby with a clean environment will run ASAN with the right
+ * settings */
+# undef RUBY__ASAN_DEFAULT_OPTIONS
+# define RUBY__ASAN_DEFAULT_OPTIONS \
+ RBIMPL_SYMBOL_EXPORT_BEGIN() \
+ const char * __asan_default_options(void) {return ruby_asan_default_options;} \
+ RBIMPL_SYMBOL_EXPORT_END()
+#endif
+
#endif /* INTERNAL_SANITIZERS_H */
diff --git a/internal/set_table.h b/internal/set_table.h
new file mode 100644
index 0000000000..3876a8935e
--- /dev/null
+++ b/internal/set_table.h
@@ -0,0 +1,74 @@
+#ifndef INTERNAL_SET_TABLE_H
+#define INTERNAL_SET_TABLE_H
+
+#include "ruby/st.h"
+
+struct set_table_entry;
+
+typedef struct set_table_entry set_table_entry;
+
+struct set_table {
+ /* Cached features of the table -- see st.c for more details. */
+ unsigned char entry_power, bin_power, size_ind;
+ /* How many times the table was rebuilt. */
+ unsigned int rebuilds_num;
+ const struct st_hash_type *type;
+ /* Number of entries currently in the table. */
+ st_index_t num_entries;
+
+ /* Start and bound index of entries in array entries.
+ entries_starts and entries_bound are in interval
+ [0,allocated_entries]. */
+ st_index_t entries_start, entries_bound;
+
+ /**
+ * Array of size 2^entry_power.
+ * Followed by st_index_t *bins, Array of bins used for access by keys.
+ */
+ set_table_entry *entries;
+};
+
+typedef struct set_table set_table;
+
+typedef int set_foreach_callback_func(st_data_t, st_data_t);
+typedef int set_foreach_check_callback_func(st_data_t, st_data_t, int);
+typedef int set_update_callback_func(st_data_t *key, st_data_t arg, int existing);
+
+#define set_table_size rb_set_table_size
+size_t rb_set_table_size(const struct set_table *tbl);
+#define set_init_table_with_size rb_set_init_table_with_size
+set_table *rb_set_init_table_with_size(set_table *tab, const struct st_hash_type *, st_index_t);
+#define set_init_numtable rb_set_init_numtable
+set_table *rb_set_init_numtable(void);
+#define set_init_numtable_with_size rb_set_init_numtable_with_size
+set_table *rb_set_init_numtable_with_size(st_index_t size);
+#define set_init_embedded_numtable_with_size rb_set_init_embedded_numtable_with_size
+set_table *rb_set_init_embedded_numtable_with_size(struct set_table *tbl, st_index_t size);
+#define set_table_delete rb_set_table_delete
+int rb_set_table_delete(set_table *, st_data_t *); /* returns 0:notfound 1:deleted */
+#define set_insert rb_set_insert
+int rb_set_insert(set_table *, st_data_t);
+#define set_table_lookup rb_set_table_lookup
+int rb_set_table_lookup(set_table *, st_data_t);
+#define set_foreach_with_replace rb_set_foreach_with_replace
+int rb_set_foreach_with_replace(set_table *tab, set_foreach_check_callback_func *func, set_update_callback_func *replace, st_data_t arg);
+#define set_table_foreach rb_set_table_foreach
+int rb_set_table_foreach(set_table *, set_foreach_callback_func *, st_data_t);
+#define set_foreach_check rb_set_foreach_check
+int rb_set_foreach_check(set_table *, set_foreach_check_callback_func *, st_data_t, st_data_t);
+#define set_keys rb_set_keys
+st_index_t rb_set_keys(set_table *table, st_data_t *keys, st_index_t size);
+#define set_free_table rb_set_free_table
+void rb_set_free_table(set_table *);
+#define set_free_embedded_table rb_set_free_embedded_table
+void set_free_embedded_table(set_table *tab);
+#define set_table_clear rb_set_table_clear
+void rb_set_table_clear(set_table *);
+#define set_copy rb_set_copy
+set_table *rb_set_copy(set_table *new_table, set_table *old_table);
+#define set_memsize rb_set_memsize
+PUREFUNC(size_t rb_set_memsize(const set_table *));
+#define set_compact_table rb_set_compact_table
+void set_compact_table(set_table *tab);
+
+#endif
diff --git a/internal/signal.h b/internal/signal.h
index 86fb54e949..904747e226 100644
--- a/internal/signal.h
+++ b/internal/signal.h
@@ -13,9 +13,13 @@
extern int ruby_enable_coredump;
int rb_get_next_signal(void);
+#ifdef POSIX_SIGNAL
+void (*ruby_posix_signal(int, void (*)(int)))(int);
+#endif
+
RUBY_SYMBOL_EXPORT_BEGIN
/* signal.c (export) */
-int rb_grantpt(int fd);
+void rb_signal_atfork(void);
RUBY_SYMBOL_EXPORT_END
#endif /* INTERNAL_SIGNAL_H */
diff --git a/internal/st.h b/internal/st.h
new file mode 100644
index 0000000000..14dcb25511
--- /dev/null
+++ b/internal/st.h
@@ -0,0 +1,20 @@
+#ifndef INTERNAL_ST_H
+#define INTERNAL_ST_H
+
+#include "ruby/st.h"
+
+st_table *rb_st_replace(st_table *new_tab, st_table *old_tab);
+#define st_replace rb_st_replace
+st_table *rb_st_init_existing_table_with_size(st_table *tab, const struct st_hash_type *type, st_index_t size);
+#define st_init_existing_table_with_size rb_st_init_existing_table_with_size
+
+st_table *rb_st_init_existing_numtable_with_size(st_table *tab, st_index_t size);
+#define st_init_existing_numtable_with_size rb_st_init_existing_numtable_with_size
+
+st_table *rb_st_init_existing_strtable_with_size(st_table *tab, st_index_t size);
+#define st_init_existing_strtable_with_size rb_st_init_existing_strtable_with_size
+
+void rb_st_free_embedded_table(st_table *tab);
+#define st_free_embedded_table rb_st_free_embedded_table
+
+#endif
diff --git a/internal/string.h b/internal/string.h
index 5f59d9621b..94a46a9657 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -14,15 +14,57 @@
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/encoding.h" /* for rb_encoding */
#include "ruby/ruby.h" /* for VALUE */
+#include "encindex.h"
-#define STR_NOEMBED FL_USER1
-#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
+#define STR_SHARED FL_USER0 /* = ELTS_SHARED */
+#define STR_NOEMBED FL_USER1
+#define STR_CHILLED (FL_USER2 | FL_USER3)
+#define STR_CHILLED_LITERAL FL_USER2
+#define STR_CHILLED_SYMBOL_TO_S FL_USER3
+
+enum ruby_rstring_private_flags {
+ RSTRING_CHILLED = STR_CHILLED,
+};
#ifdef rb_fstring_cstr
# undef rb_fstring_cstr
#endif
+static inline bool
+rb_str_encindex_fastpath(int encindex)
+{
+ // The overwhelming majority of strings are in one of these 3 encodings,
+ // which are all either ASCII or perfect ASCII supersets.
+ // Hence you can use fast, single byte algorithms on them, such as `memchr` etc,
+ // without all the overhead of fetching the rb_encoding and using functions such as
+ // rb_enc_mbminlen etc.
+ // Many other encodings could qualify, but they are expected to be rare occurrences,
+ // so it's better to keep that list small.
+ switch (encindex) {
+ case ENCINDEX_ASCII_8BIT:
+ case ENCINDEX_UTF_8:
+ case ENCINDEX_US_ASCII:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool
+rb_str_enc_fastpath(VALUE str)
+{
+ return rb_str_encindex_fastpath(ENCODING_GET_INLINED(str));
+}
+
+static inline rb_encoding *
+rb_str_enc_get(VALUE str)
+{
+ RUBY_ASSERT(RB_TYPE_P(str, T_STRING));
+ return rb_enc_from_index(ENCODING_GET(str));
+}
+
/* string.c */
+VALUE rb_str_dup_m(VALUE str);
VALUE rb_fstring(VALUE);
VALUE rb_fstring_cstr(const char *str);
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
@@ -45,6 +87,22 @@ void rb_str_make_independent(VALUE str);
int rb_enc_str_coderange_scan(VALUE str, rb_encoding *enc);
int rb_ascii8bit_appendable_encoding_index(rb_encoding *enc, unsigned int code);
VALUE rb_str_include(VALUE str, VALUE arg);
+VALUE rb_str_byte_substr(VALUE str, VALUE beg, VALUE len);
+VALUE rb_str_substr_two_fixnums(VALUE str, VALUE beg, VALUE len, int empty);
+VALUE rb_str_tmp_frozen_no_embed_acquire(VALUE str);
+void rb_str_make_embedded(VALUE);
+VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
+size_t rb_str_size_as_embedded(VALUE);
+bool rb_str_reembeddable_p(VALUE);
+VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
+VALUE rb_str_with_debug_created_info(VALUE, VALUE, int);
+VALUE rb_str_frozen_bare_string(VALUE);
+const char *rb_str_null_check(VALUE);
+VALUE rb_str_casecmp(VALUE str1, VALUE str2);
+
+/* error.c */
+void rb_warn_unchilled_literal(VALUE str);
+void rb_warn_unchilled_symbol_to_s(VALUE str);
static inline bool STR_EMBED_P(VALUE str);
static inline bool STR_SHARED_P(VALUE str);
@@ -59,24 +117,22 @@ RUBY_SYMBOL_EXPORT_BEGIN
VALUE rb_str_tmp_frozen_acquire(VALUE str);
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
-VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
-VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
-void rb_str_make_embedded(VALUE);
-size_t rb_str_size_as_embedded(VALUE);
-bool rb_str_reembeddable_p(VALUE);
-void rb_str_update_shared_ary(VALUE str, VALUE old_root, VALUE new_root);
RUBY_SYMBOL_EXPORT_END
VALUE rb_fstring_new(const char *ptr, long len);
+void rb_gc_free_fstring(VALUE obj);
+bool rb_obj_is_fstring_table(VALUE obj);
+void Init_fstring_table();
VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
VALUE rb_str_opt_plus(VALUE x, VALUE y);
VALUE rb_str_concat_literals(size_t num, const VALUE *strary);
VALUE rb_str_eql(VALUE str1, VALUE str2);
VALUE rb_id_quote_unprintable(ID);
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc);
+VALUE rb_enc_literal_str(const char *ptr, long len, rb_encoding *enc);
struct rb_execution_context_struct;
-VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str);
+VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str, bool chilled);
#define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
#define rb_fstring_literal(str) rb_fstring_lit(str)
@@ -108,6 +164,29 @@ STR_SHARED_P(VALUE str)
}
static inline bool
+CHILLED_STRING_P(VALUE obj)
+{
+ return RB_TYPE_P(obj, T_STRING) && FL_TEST_RAW(obj, STR_CHILLED);
+}
+
+static inline void
+CHILLED_STRING_MUTATED(VALUE str)
+{
+ VALUE chilled_reason = RB_FL_TEST_RAW(str, STR_CHILLED);
+ FL_UNSET_RAW(str, STR_CHILLED);
+ switch (chilled_reason) {
+ case STR_CHILLED_SYMBOL_TO_S:
+ rb_warn_unchilled_symbol_to_s(str);
+ break;
+ case STR_CHILLED_LITERAL:
+ rb_warn_unchilled_literal(str);
+ break;
+ default:
+ rb_bug("RString was chilled for multiple reasons");
+ }
+}
+
+static inline bool
is_ascii_string(VALUE str)
{
return rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT;
@@ -119,6 +198,21 @@ is_broken_string(VALUE str)
return rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN;
}
+static inline bool
+at_char_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
+{
+ return rb_enc_left_char_head(s, p, e, enc) == p;
+}
+
+static inline bool
+at_char_right_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
+{
+ RUBY_ASSERT(s <= p);
+ RUBY_ASSERT(p <= e);
+
+ return rb_enc_right_char_head(s, p, e, enc) == p;
+}
+
/* expect tail call optimization */
// YJIT needs this function to never allocate and never raise
static inline VALUE
diff --git a/internal/struct.h b/internal/struct.h
index 5b00e52262..d3c8157393 100644
--- a/internal/struct.h
+++ b/internal/struct.h
@@ -11,11 +11,23 @@
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for struct RBasic */
+/* Flags of RStruct
+ *
+ * 1-7: RSTRUCT_EMBED_LEN
+ * If non-zero, the struct is embedded (its contents follow the
+ * header, rather than being on a separately allocated buffer) and
+ * these bits are the length of the Struct.
+ * 8: RSTRUCT_GEN_FIELDS
+ * The struct is embedded and has no space left to store the
+ * IMEMO/fields reference. Any ivar this struct may have will be in
+ * the generic_fields_tbl. This flag doesn't imply the struct has
+ * ivars.
+ */
enum {
- RSTRUCT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
- RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
+ RSTRUCT_EMBED_LEN_MASK = RUBY_FL_USER7 | RUBY_FL_USER6 | RUBY_FL_USER5 | RUBY_FL_USER4 |
+ RUBY_FL_USER3 | RUBY_FL_USER2 | RUBY_FL_USER1,
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
- RSTRUCT_TRANSIENT_FLAG = FL_USER3,
+ RSTRUCT_GEN_FIELDS = RUBY_FL_USER8,
};
struct RStruct {
@@ -24,73 +36,29 @@ struct RStruct {
struct {
long len;
const VALUE *ptr;
+ VALUE fields_obj;
} heap;
- const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
+ /* This is a length 1 array because:
+ * 1. GCC has a bug that does not optimize C flexible array members
+ * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
+ * 2. Zero length arrays are not supported by all compilers
+ */
+ const VALUE ary[1];
} as;
};
#define RSTRUCT(obj) ((struct RStruct *)(obj))
-#ifdef RSTRUCT_LEN
-# undef RSTRUCT_LEN
-#endif
-
-#ifdef RSTRUCT_PTR
-# undef RSTRUCT_PTR
-#endif
-
-#ifdef RSTRUCT_SET
-# undef RSTRUCT_SET
-#endif
-
-#ifdef RSTRUCT_GET
-# undef RSTRUCT_GET
-#endif
-
-#define RSTRUCT_LEN internal_RSTRUCT_LEN
-#define RSTRUCT_SET internal_RSTRUCT_SET
-#define RSTRUCT_GET internal_RSTRUCT_GET
-
/* struct.c */
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
VALUE rb_struct_lookup(VALUE s, VALUE idx);
VALUE rb_struct_s_keyword_init(VALUE klass);
-static inline const VALUE *rb_struct_const_heap_ptr(VALUE st);
-static inline bool RSTRUCT_TRANSIENT_P(VALUE st);
-static inline void RSTRUCT_TRANSIENT_SET(VALUE st);
-static inline void RSTRUCT_TRANSIENT_UNSET(VALUE st);
static inline long RSTRUCT_EMBED_LEN(VALUE st);
-static inline long RSTRUCT_LEN(VALUE st);
+static inline long RSTRUCT_LEN_RAW(VALUE st);
static inline int RSTRUCT_LENINT(VALUE st);
static inline const VALUE *RSTRUCT_CONST_PTR(VALUE st);
-static inline void RSTRUCT_SET(VALUE st, long k, VALUE v);
-static inline VALUE RSTRUCT_GET(VALUE st, long k);
-
-static inline bool
-RSTRUCT_TRANSIENT_P(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-static inline void
-RSTRUCT_TRANSIENT_SET(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-RSTRUCT_TRANSIENT_UNSET(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#endif
-}
+static inline void RSTRUCT_SET_RAW(VALUE st, long k, VALUE v);
+static inline VALUE RSTRUCT_GET_RAW(VALUE st, long k);
static inline long
RSTRUCT_EMBED_LEN(VALUE st)
@@ -101,7 +69,7 @@ RSTRUCT_EMBED_LEN(VALUE st)
}
static inline long
-RSTRUCT_LEN(VALUE st)
+RSTRUCT_LEN_RAW(VALUE st)
{
if (FL_TEST_RAW(st, RSTRUCT_EMBED_LEN_MASK)) {
return RSTRUCT_EMBED_LEN(st);
@@ -114,7 +82,7 @@ RSTRUCT_LEN(VALUE st)
static inline int
RSTRUCT_LENINT(VALUE st)
{
- return rb_long2int(RSTRUCT_LEN(st));
+ return rb_long2int(RSTRUCT_LEN_RAW(st));
}
static inline const VALUE *
@@ -131,22 +99,42 @@ RSTRUCT_CONST_PTR(VALUE st)
}
static inline void
-RSTRUCT_SET(VALUE st, long k, VALUE v)
+RSTRUCT_SET_RAW(VALUE st, long k, VALUE v)
{
RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[k], v);
}
static inline VALUE
-RSTRUCT_GET(VALUE st, long k)
+RSTRUCT_GET_RAW(VALUE st, long k)
{
return RSTRUCT_CONST_PTR(st)[k];
}
-static inline const VALUE *
-rb_struct_const_heap_ptr(VALUE st)
+static inline VALUE
+RSTRUCT_FIELDS_OBJ(VALUE st)
{
- /* TODO: check embed on debug mode */
- return RSTRUCT(st)->as.heap.ptr;
+ const long embed_len = RSTRUCT_EMBED_LEN(st);
+ VALUE fields_obj;
+ if (embed_len) {
+ RUBY_ASSERT(!FL_TEST_RAW(st, RSTRUCT_GEN_FIELDS));
+ fields_obj = RSTRUCT_GET_RAW(st, embed_len);
+ }
+ else {
+ fields_obj = RSTRUCT(st)->as.heap.fields_obj;
+ }
+ return fields_obj;
}
+static inline void
+RSTRUCT_SET_FIELDS_OBJ(VALUE st, VALUE fields_obj)
+{
+ const long embed_len = RSTRUCT_EMBED_LEN(st);
+ if (embed_len) {
+ RUBY_ASSERT(!FL_TEST_RAW(st, RSTRUCT_GEN_FIELDS));
+ RSTRUCT_SET_RAW(st, embed_len, fields_obj);
+ }
+ else {
+ RB_OBJ_WRITE(st, &RSTRUCT(st)->as.heap.fields_obj, fields_obj);
+ }
+}
#endif /* INTERNAL_STRUCT_H */
diff --git a/internal/symbol.h b/internal/symbol.h
index 30c81ea004..b9109b1347 100644
--- a/internal/symbol.h
+++ b/internal/symbol.h
@@ -17,6 +17,7 @@
#endif
/* symbol.c */
+void rb_sym_global_symbols_mark_and_move(void);
VALUE rb_to_symbol_type(VALUE obj);
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
VALUE rb_sym_intern_ascii(const char *ptr, long len);
@@ -29,8 +30,11 @@ PUREFUNC(int rb_is_const_sym(VALUE sym));
PUREFUNC(int rb_is_attrset_sym(VALUE sym));
ID rb_make_internal_id(void);
ID rb_make_temporary_id(size_t n);
+bool rb_obj_is_symbol_table(VALUE obj);
+void rb_sym_global_symbol_table_foreach_weak_reference(int (*callback)(VALUE *key, void *data), void *data);
void rb_gc_free_dsymbol(VALUE);
int rb_static_id_valid_p(ID id);
+void rb_free_global_symbol_table(void);
#if __has_builtin(__builtin_constant_p)
#define rb_sym_intern_ascii_cstr(ptr) \
diff --git a/internal/thread.h b/internal/thread.h
index 7bb4b77a86..ea891b4372 100644
--- a/internal/thread.h
+++ b/internal/thread.h
@@ -10,8 +10,10 @@
*/
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/intern.h" /* for rb_blocking_function_t */
+#include "ccan/list/list.h" /* for list in rb_io_close_wait_list */
struct rb_thread_struct; /* in vm_core.h */
+struct rb_io;
#define RB_VM_SAVE_MACHINE_CONTEXT(th) \
do { \
@@ -29,6 +31,10 @@ struct rb_thread_struct; /* in vm_core.h */
#define COVERAGE_TARGET_ONESHOT_LINES 8
#define COVERAGE_TARGET_EVAL 16
+#define RUBY_FATAL_THREAD_KILLED INT2FIX(0)
+#define RUBY_FATAL_THREAD_TERMINATED INT2FIX(1)
+#define RUBY_FATAL_FIBER_KILLED RB_INT2FIX(2)
+
VALUE rb_obj_is_mutex(VALUE obj);
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
void rb_thread_execute_interrupts(VALUE th);
@@ -41,21 +47,66 @@ VALUE rb_thread_shield_wait(VALUE self);
VALUE rb_thread_shield_release(VALUE self);
VALUE rb_thread_shield_destroy(VALUE self);
int rb_thread_to_be_killed(VALUE thread);
+void rb_thread_acquire_fork_lock(void);
+void rb_thread_release_fork_lock(void);
+void rb_thread_reset_fork_lock(void);
void rb_mutex_allow_trap(VALUE self, int val);
VALUE rb_uninterruptible(VALUE (*b_proc)(VALUE), VALUE data);
VALUE rb_mutex_owned_p(VALUE self);
VALUE rb_exec_recursive_outer_mid(VALUE (*f)(VALUE g, VALUE h, int r), VALUE g, VALUE h, ID mid);
+void ruby_mn_threads_params(void);
+
+int rb_thread_io_wait(struct rb_thread_struct *th, struct rb_io *io, int events, struct timeval * timeout);
+int rb_thread_wait_for_single_fd(struct rb_thread_struct *th, int fd, int events, struct timeval * timeout);
+
+size_t rb_thread_io_close_interrupt(struct rb_io *);
+void rb_thread_io_close_wait(struct rb_io *);
+
+void rb_ec_check_ints(struct rb_execution_context_struct *ec);
-int rb_thread_wait_for_single_fd(int fd, int events, struct timeval * timeout);
+void rb_thread_free_native_thread(void *th_ptr);
RUBY_SYMBOL_EXPORT_BEGIN
+
+void *rb_thread_prevent_fork(void *(*func)(void *), void *data); /* for ext/socket/raddrinfo.c */
+
/* Temporary. This API will be removed (renamed). */
-VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
+VALUE rb_thread_io_blocking_region(struct rb_io *io, rb_blocking_function_t *func, void *data1);
+VALUE rb_thread_io_blocking_call(struct rb_io *io, rb_blocking_function_t *func, void *data1, int events);
+
+// Invoke the given function, with the specified argument, in a way that `IO#close` from another execution context can interrupt it.
+VALUE rb_thread_io_blocking_operation(VALUE self, VALUE(*function)(VALUE), VALUE argument);
/* thread.c (export) */
int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
+
RUBY_SYMBOL_EXPORT_END
int rb_threadptr_execute_interrupts(struct rb_thread_struct *th, int blocking_timing);
+bool rb_thread_mn_schedulable(VALUE thread);
+
+bool rb_thread_resolve_unblock_function(rb_unblock_function_t **unblock_function, void **data2, struct rb_thread_struct *thread);
+
+// interrupt exec
+
+typedef VALUE (rb_interrupt_exec_func_t)(void *data);
+
+enum rb_interrupt_exec_flag {
+ rb_interrupt_exec_flag_none = 0x00,
+ rb_interrupt_exec_flag_value_data = 0x01,
+ rb_interrupt_exec_flag_new_thread = 0x02,
+};
+
+// interrupt the target_th and run func.
+struct rb_ractor_struct;
+
+void rb_threadptr_interrupt_exec(struct rb_thread_struct *target_th,
+ rb_interrupt_exec_func_t *func, void *data, enum rb_interrupt_exec_flag flags);
+
+// create a thread in the target_r and run func on the created thread.
+void rb_ractor_interrupt_exec(struct rb_ractor_struct *target_r,
+ rb_interrupt_exec_func_t *func, void *data, enum rb_interrupt_exec_flag flags);
+
+void rb_threadptr_interrupt_exec_task_mark(struct rb_thread_struct *th);
#endif /* INTERNAL_THREAD_H */
diff --git a/internal/time.h b/internal/time.h
index a3bf0587ec..1f3505f5bc 100644
--- a/internal/time.h
+++ b/internal/time.h
@@ -27,8 +27,8 @@ struct timeval rb_time_timeval(VALUE);
RUBY_SYMBOL_EXPORT_BEGIN
/* time.c (export) */
-void ruby_reset_leap_second_info(void);
-void ruby_reset_timezone(void);
RUBY_SYMBOL_EXPORT_END
+void ruby_reset_timezone(const char *);
+
#endif /* INTERNAL_TIME_H */
diff --git a/internal/transcode.h b/internal/transcode.h
index 9922332ea9..ce4f2341be 100644
--- a/internal/transcode.h
+++ b/internal/transcode.h
@@ -17,4 +17,7 @@
extern VALUE rb_cEncodingConverter;
size_t rb_econv_memsize(rb_econv_t *);
+/* vm.c */
+void rb_free_transcoder_table(void);
+
#endif /* INTERNAL_TRANSCODE_H */
diff --git a/internal/variable.h b/internal/variable.h
index 4436cd789c..58364941c1 100644
--- a/internal/variable.h
+++ b/internal/variable.h
@@ -13,40 +13,57 @@
#include "constant.h" /* for rb_const_entry_t */
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */
-#include "shape.h" /* for rb_shape_t */
-
-/* global variable */
-
-#define ROBJECT_TRANSIENT_FLAG FL_USER2
+#include "shape.h" /* for shape_id_t */
/* variable.c */
void rb_gc_mark_global_tbl(void);
void rb_gc_update_global_tbl(void);
-size_t rb_generic_ivar_memsize(VALUE);
VALUE rb_search_class_path(VALUE);
VALUE rb_attr_delete(VALUE, ID);
void rb_autoload_str(VALUE mod, ID id, VALUE file);
VALUE rb_autoload_at_p(VALUE, ID, int);
+void rb_autoload_copy_table_for_box(st_table *, const rb_box_t *);
NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
rb_gvar_getter_t *rb_gvar_getter_function_of(ID);
rb_gvar_setter_t *rb_gvar_setter_function_of(ID);
void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_);
void rb_gvar_ractor_local(const char *name);
-static inline bool ROBJ_TRANSIENT_P(VALUE obj);
-static inline void ROBJ_TRANSIENT_SET(VALUE obj);
-static inline void ROBJ_TRANSIENT_UNSET(VALUE obj);
+void rb_gvar_box_ready(const char *name);
+void rb_gvar_box_dynamic(const char *name);
+
+/**
+ * Sets the name of a module.
+ *
+ * Non-permanently named classes can have a temporary name assigned (or
+ * cleared). In that case the name will be used for `#inspect` and `#to_s`, and
+ * nested classes/modules will be named with the temporary name as a prefix.
+ *
+ * After the module is assigned to a constant, the temporary name will be
+ * discarded, and the name will be computed based on the nesting.
+ *
+ * @param[in] mod An instance of ::rb_cModule.
+ * @param[in] name An instance of ::rb_cString.
+ * @retval mod
+ */
+VALUE rb_mod_set_temporary_name(VALUE, VALUE);
-struct gen_ivtbl;
-int rb_gen_ivtbl_get(VALUE obj, ID id, struct gen_ivtbl **ivtbl);
-int rb_obj_evacuate_ivs_to_hash_table(ID key, VALUE val, st_data_t arg);
+void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table);
+void rb_obj_init_complex(VALUE obj, st_table *table);
+void rb_evict_ivars_to_hash(VALUE obj);
+VALUE rb_obj_field_get(VALUE obj, shape_id_t target_shape_id);
+void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
+void rb_ivar_foreach_buffered(VALUE obj, int (*func)(ID name, VALUE val, st_data_t arg), st_data_t arg);
+attr_index_t rb_ivar_set_index(VALUE obj, ID id, VALUE val);
+attr_index_t rb_obj_field_set(VALUE obj, shape_id_t target_shape_id, ID field_name, VALUE val);
+VALUE rb_ivar_get_at(VALUE obj, attr_index_t index, ID id);
+VALUE rb_ivar_get_at_no_ractor_check(VALUE obj, attr_index_t index);
RUBY_SYMBOL_EXPORT_BEGIN
/* variable.c (export) */
-void rb_mark_and_update_generic_ivar(VALUE);
-void rb_mv_generic_ivar(VALUE src, VALUE dst);
+void rb_mark_generic_ivar(VALUE obj);
VALUE rb_const_missing(VALUE klass, VALUE name);
-int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
-void rb_iv_tbl_copy(VALUE dst, VALUE src);
+bool rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
+void rb_fields_tbl_copy(VALUE dst, VALUE src);
RUBY_SYMBOL_EXPORT_END
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
@@ -54,35 +71,6 @@ VALUE rb_gvar_get(ID);
VALUE rb_gvar_set(ID, VALUE);
VALUE rb_gvar_defined(ID);
void rb_const_warn_if_deprecated(const rb_const_entry_t *, VALUE, ID);
-rb_shape_t * rb_grow_iv_list(VALUE obj);
-void rb_ensure_iv_list_size(VALUE obj, uint32_t len, uint32_t newsize);
-struct gen_ivtbl *rb_ensure_generic_iv_list_size(VALUE obj, rb_shape_t *shape, uint32_t newsize);
-attr_index_t rb_obj_ivar_set(VALUE obj, ID id, VALUE val);
-
-static inline bool
-ROBJ_TRANSIENT_P(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-static inline void
-ROBJ_TRANSIENT_SET(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-ROBJ_TRANSIENT_UNSET(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#endif
-}
+void rb_ensure_iv_list_size(VALUE obj, uint32_t current_len, uint32_t newsize);
#endif /* INTERNAL_VARIABLE_H */
diff --git a/internal/vm.h b/internal/vm.h
index 7943027946..4e50ec2710 100644
--- a/internal/vm.h
+++ b/internal/vm.h
@@ -45,36 +45,51 @@ VALUE rb_vm_push_frame_fname(struct rb_execution_context_struct *ec, VALUE fname
/* vm.c */
VALUE rb_obj_is_thread(VALUE obj);
void rb_vm_mark(void *ptr);
+void rb_vm_register_global_object(VALUE obj);
void rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx);
PUREFUNC(VALUE rb_vm_top_self(void));
const void **rb_vm_get_insns_address_table(void);
VALUE rb_source_location(int *pline);
const char *rb_source_location_cstr(int *pline);
void rb_vm_pop_cfunc_frame(void);
-int rb_vm_add_root_module(VALUE module);
void rb_vm_check_redefinition_by_prepend(VALUE klass);
int rb_vm_check_optimizable_mid(VALUE mid);
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
VALUE ruby_vm_special_exception_copy(VALUE);
-PUREFUNC(st_table *rb_vm_fstring_table(void));
+
+void rb_lastline_set_up(VALUE val, unsigned int up);
/* vm_eval.c */
VALUE rb_current_realfilepath(void);
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
-VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
- rb_check_funcall_hook *hook, VALUE arg);
VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv,
rb_check_funcall_hook *hook, VALUE arg, int kw_splat);
const char *rb_type_str(enum ruby_value_type type);
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE*, int);
VALUE rb_yield_1(VALUE val);
+VALUE rb_ec_yield(struct rb_execution_context_struct *ec, VALUE val);
VALUE rb_yield_force_blockarg(VALUE values);
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
rb_block_call_func_t bl_proc, int min_argc, int max_argc,
VALUE data2);
void rb_check_stack_overflow(void);
+#define RB_BLOCK_NO_USE_PACKED_ARGS 2
+VALUE rb_block_call2(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2, long flags);
+struct vm_ifunc *rb_current_ifunc(void);
+VALUE rb_gccct_clear_table(void);
+VALUE rb_eval_cmd_call_kw(VALUE cmd, int argc, const VALUE *argv, int kw_splat);
+
+#if USE_YJIT || USE_ZJIT
+/* vm_exec.c */
+extern uint64_t rb_vm_insn_count;
+#endif
+
+extern bool rb_free_at_exit;
+
+/* miniinit.c and builtin.c */
+void rb_free_loaded_builtin_table(void);
/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
@@ -84,13 +99,10 @@ struct rb_iseq_struct;
const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
/* vm_method.c */
-struct rb_execution_context_struct;
int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
-void rb_clear_constant_cache(void);
-
/* vm_dump.c */
-void rb_print_backtrace(void);
+void rb_print_backtrace(FILE *);
/* vm_backtrace.c */
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
@@ -98,17 +110,17 @@ VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
VALUE rb_vm_backtrace(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
VALUE rb_vm_backtrace_locations(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
VALUE rb_make_backtrace(void);
-void rb_backtrace_print_as_bugreport(void);
+void rb_backtrace_print_as_bugreport(FILE*);
int rb_backtrace_p(VALUE obj);
VALUE rb_backtrace_to_str_ary(VALUE obj);
VALUE rb_backtrace_to_location_ary(VALUE obj);
+VALUE rb_location_ary_to_backtrace(VALUE ary);
void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
int rb_frame_info_p(VALUE obj);
int rb_get_node_id_from_frame_info(VALUE obj);
const struct rb_iseq_struct *rb_get_iseq_from_frame_info(VALUE obj);
VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec);
-void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self);
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
RUBY_DTRACE_HOOK(name##_CREATE, arg)
diff --git a/io.c b/io.c
index a3dfa027d4..effcb349c3 100644
--- a/io.c
+++ b/io.c
@@ -16,11 +16,6 @@
#include "ruby/fiber/scheduler.h"
#include "ruby/io/buffer.h"
-#ifdef _WIN32
-# include "ruby/ruby.h"
-# include "ruby/io.h"
-#endif
-
#include <ctype.h>
#include <errno.h>
#include <stddef.h>
@@ -109,6 +104,16 @@
#ifdef HAVE_COPYFILE_H
# include <copyfile.h>
+
+# ifndef COPYFILE_STATE_COPIED
+/*
+ * Some OSes (e.g., OSX < 10.6) implement fcopyfile() but not
+ * COPYFILE_STATE_COPIED. Since the only use of the former here
+ * requires the latter, we disable the former when the latter is undefined.
+ */
+# undef HAVE_FCOPYFILE
+# endif
+
#endif
#include "ruby/internal/stdbool.h"
@@ -117,6 +122,7 @@
#include "encindex.h"
#include "id.h"
#include "internal.h"
+#include "internal/class.h"
#include "internal/encoding.h"
#include "internal/error.h"
#include "internal/inits.h"
@@ -175,6 +181,7 @@ off_t __syscall(quad_t number, ...);
#define open rb_w32_uopen
#undef rename
#define rename(f, t) rb_w32_urename((f), (t))
+#include "win32/file.h"
#endif
VALUE rb_cIO;
@@ -213,7 +220,18 @@ static VALUE sym_DATA;
static VALUE sym_HOLE;
#endif
-static VALUE prep_io(int fd, int fmode, VALUE klass, const char *path);
+static VALUE prep_io(int fd, enum rb_io_mode fmode, VALUE klass, const char *path);
+
+VALUE
+rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events)
+{
+ return rb_thread_io_blocking_call(io, function, argument, events);
+}
+
+VALUE rb_io_blocking_region(struct rb_io *io, rb_blocking_function_t *function, void *argument)
+{
+ return rb_io_blocking_region_wait(io, function, argument, 0);
+}
struct argf {
VALUE filename, current_file;
@@ -221,7 +239,7 @@ struct argf {
long lineno;
VALUE argv;
VALUE inplace;
- struct rb_io_enc_t encs;
+ struct rb_io_encoding encs;
int8_t init_p, next_p, binmode;
};
@@ -482,6 +500,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
#define argf_of(obj) (*(struct argf *)DATA_PTR(obj))
#define ARGF argf_of(argf)
+#define ARGF_SET(field, value) RB_OBJ_WRITE(argf, &ARGF.field, value)
#define GetWriteIO(io) rb_io_get_write_io(io)
@@ -523,9 +542,9 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
#endif
static int io_fflush(rb_io_t *);
-static rb_io_t *flush_before_seek(rb_io_t *fptr);
+static rb_io_t *flush_before_seek(rb_io_t *fptr, bool discard_rbuf);
+static void clear_codeconv(rb_io_t *fptr);
-#define FMODE_PREP (1<<16)
#define FMODE_SIGNAL_ON_EPIPE (1<<17)
#define fptr_signal_on_epipe(fptr) \
@@ -538,10 +557,12 @@ static rb_io_t *flush_before_seek(rb_io_t *fptr);
extern ID ruby_static_id_signo;
-NORETURN(static void raise_on_write(rb_io_t *fptr, int e, VALUE errinfo));
+NORETURN(static void rb_sys_fail_on_write(rb_io_t *fptr));
static void
-raise_on_write(rb_io_t *fptr, int e, VALUE errinfo)
+rb_sys_fail_on_write(rb_io_t *fptr)
{
+ int e = errno;
+ VALUE errinfo = rb_syserr_new_path(e, (fptr)->pathv);
#if defined EPIPE
if (fptr_signal_on_epipe(fptr) && (e == EPIPE)) {
const VALUE sig =
@@ -555,12 +576,6 @@ raise_on_write(rb_io_t *fptr, int e, VALUE errinfo)
rb_exc_raise(errinfo);
}
-#define rb_sys_fail_on_write(fptr) \
- do { \
- int e = errno; \
- raise_on_write(fptr, e, rb_syserr_new_path(e, (fptr)->pathv)); \
- } while (0)
-
#define NEED_NEWLINE_DECORATOR_ON_READ(fptr) ((fptr)->mode & FMODE_TEXTMODE)
#define NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) ((fptr)->mode & FMODE_TEXTMODE)
#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
@@ -613,7 +628,7 @@ raise_on_write(rb_io_t *fptr, int e, VALUE errinfo)
* IO unread with taking care of removed '\r' in text mode.
*/
static void
-io_unread(rb_io_t *fptr)
+io_unread(rb_io_t *fptr, bool discard_rbuf)
{
rb_off_t r, pos;
ssize_t read_size;
@@ -634,19 +649,17 @@ io_unread(rb_io_t *fptr)
if (r < 0 && errno) {
if (errno == ESPIPE)
fptr->mode |= FMODE_DUPLEX;
- return;
+ if (!discard_rbuf) return;
}
- fptr->rbuf.off = 0;
- fptr->rbuf.len = 0;
- return;
+ goto end;
}
pos = lseek(fptr->fd, 0, SEEK_CUR);
if (pos < 0 && errno) {
if (errno == ESPIPE)
fptr->mode |= FMODE_DUPLEX;
- return;
+ if (!discard_rbuf) goto end;
}
/* add extra offset for removed '\r' in rbuf */
@@ -687,8 +700,10 @@ io_unread(rb_io_t *fptr)
}
}
free(buf);
+ end:
fptr->rbuf.off = 0;
fptr->rbuf.len = 0;
+ clear_codeconv(fptr);
return;
}
@@ -707,7 +722,7 @@ set_binary_mode_with_seek_cur(rb_io_t *fptr)
if (fptr->rbuf.len == 0 || fptr->mode & FMODE_DUPLEX) {
return setmode(fptr->fd, O_BINARY);
}
- flush_before_seek(fptr);
+ flush_before_seek(fptr, false);
return setmode(fptr->fd, O_BINARY);
}
#define SET_BINARY_MODE_WITH_SEEK_CUR(fptr) set_binary_mode_with_seek_cur(fptr)
@@ -852,7 +867,7 @@ rb_io_timeout(VALUE self)
* timeout = duration -> duration
* timeout = nil -> nil
*
- * \Set the internal timeout to the specified duration or nil. The timeout
+ * Sets the internal timeout to the specified duration or nil. The timeout
* applies to all blocking operations where possible.
*
* When the operation performs longer than the timeout set, IO::TimeoutError
@@ -903,7 +918,7 @@ rb_io_s_try_convert(VALUE dummy, VALUE io)
#if !RUBY_CRLF_ENVIRONMENT
static void
-io_unread(rb_io_t *fptr)
+io_unread(rb_io_t *fptr, bool discard_rbuf)
{
rb_off_t r;
rb_io_check_closed(fptr);
@@ -915,10 +930,11 @@ io_unread(rb_io_t *fptr)
if (r < 0 && errno) {
if (errno == ESPIPE)
fptr->mode |= FMODE_DUPLEX;
- return;
+ if (!discard_rbuf) return;
}
fptr->rbuf.off = 0;
fptr->rbuf.len = 0;
+ clear_codeconv(fptr);
return;
}
#endif
@@ -959,17 +975,17 @@ io_ungetbyte(VALUE str, rb_io_t *fptr)
}
static rb_io_t *
-flush_before_seek(rb_io_t *fptr)
+flush_before_seek(rb_io_t *fptr, bool discard_rbuf)
{
if (io_fflush(fptr) < 0)
rb_sys_fail_on_write(fptr);
- io_unread(fptr);
+ io_unread(fptr, discard_rbuf);
errno = 0;
return fptr;
}
-#define io_seek(fptr, ofs, whence) (errno = 0, 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) (errno = 0, lseek(flush_before_seek(fptr, true)->fd, (ofs), (whence)))
+#define io_tell(fptr) lseek(flush_before_seek(fptr, false)->fd, 0, SEEK_CUR)
#ifndef SEEK_CUR
# define SEEK_SET 0
@@ -1037,7 +1053,7 @@ rb_io_check_writable(rb_io_t *fptr)
rb_raise(rb_eIOError, "not opened for writing");
}
if (fptr->rbuf.len) {
- io_unread(fptr);
+ io_unread(fptr, true);
}
}
@@ -1069,20 +1085,24 @@ rb_gc_for_fd(int err)
return 0;
}
+/* try `expr` upto twice while it returns false and `errno`
+ * is to GC. Each `errno`s are available as `first_errno` and
+ * `retried_errno` respectively */
+#define TRY_WITH_GC(expr) \
+ for (int first_errno, retried_errno = 0, retried = 0; \
+ (!retried && \
+ !(expr) && \
+ (!rb_gc_for_fd(first_errno = errno) || !(expr)) && \
+ (retried_errno = errno, 1)); \
+ (void)retried_errno, retried = 1)
+
static int
ruby_dup(int orig)
{
- int fd;
+ int fd = -1;
- fd = rb_cloexec_dup(orig);
- if (fd < 0) {
- int e = errno;
- if (rb_gc_for_fd(e)) {
- fd = rb_cloexec_dup(orig);
- }
- if (fd < 0) {
- rb_syserr_fail(e, 0);
- }
+ TRY_WITH_GC((fd = rb_cloexec_dup(orig)) >= 0) {
+ rb_syserr_fail(first_errno, 0);
}
rb_update_max_fd(fd);
return fd;
@@ -1091,7 +1111,7 @@ ruby_dup(int orig)
static VALUE
io_alloc(VALUE klass)
{
- NEWOBJ_OF(io, struct RFile, klass, T_FILE);
+ UNPROTECTED_NEWOBJ_OF(io, struct RFile, klass, T_FILE, sizeof(struct RFile));
io->fptr = 0;
@@ -1147,6 +1167,11 @@ static int nogvl_wait_for(VALUE th, rb_io_t *fptr, short events, struct timeval
static inline int
io_internal_wait(VALUE thread, rb_io_t *fptr, int error, int events, struct timeval *timeout)
{
+ if (!timeout && rb_thread_mn_schedulable(thread)) {
+ RUBY_ASSERT(errno == EWOULDBLOCK || errno == EAGAIN);
+ return -1;
+ }
+
int ready = nogvl_wait_for(thread, fptr, events, timeout);
if (ready > 0) {
@@ -1157,8 +1182,15 @@ io_internal_wait(VALUE thread, rb_io_t *fptr, int error, int events, struct time
return -1;
}
- errno = error;
- return -1;
+ // If there was an error BEFORE we started waiting, return it:
+ if (error) {
+ errno = error;
+ return -1;
+ }
+ else {
+ // Otherwise, whatever error was generated by `nogvl_wait_for` is the one we want:
+ return ready;
+ }
}
static VALUE
@@ -1260,7 +1292,8 @@ internal_writev_func(void *ptr)
static ssize_t
rb_io_read_memory(rb_io_t *fptr, void *buf, size_t count)
{
- VALUE scheduler = rb_fiber_scheduler_current();
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
if (scheduler != Qnil) {
VALUE result = rb_fiber_scheduler_io_read_memory(scheduler, fptr->self, buf, count, 0);
@@ -1270,7 +1303,7 @@ rb_io_read_memory(rb_io_t *fptr, void *buf, size_t count)
}
struct io_internal_read_struct iis = {
- .th = rb_thread_current(),
+ .th = th->self,
.fptr = fptr,
.nonblock = 0,
.fd = fptr->fd,
@@ -1287,13 +1320,14 @@ rb_io_read_memory(rb_io_t *fptr, void *buf, size_t count)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_read_func, &iis, fptr->fd);
+ return (ssize_t)rb_io_blocking_region_wait(fptr, internal_read_func, &iis, RUBY_IO_READABLE);
}
static ssize_t
rb_io_write_memory(rb_io_t *fptr, const void *buf, size_t count)
{
- VALUE scheduler = rb_fiber_scheduler_current();
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
if (scheduler != Qnil) {
VALUE result = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, buf, count, 0);
@@ -1303,7 +1337,7 @@ rb_io_write_memory(rb_io_t *fptr, const void *buf, size_t count)
}
struct io_internal_write_struct iis = {
- .th = rb_thread_current(),
+ .th = th->self,
.fptr = fptr,
.nonblock = 0,
.fd = fptr->fd,
@@ -1320,26 +1354,29 @@ rb_io_write_memory(rb_io_t *fptr, const void *buf, size_t count)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_write_func, &iis, fptr->fd);
+ return (ssize_t)rb_io_blocking_region_wait(fptr, internal_write_func, &iis, RUBY_IO_WRITABLE);
}
#ifdef HAVE_WRITEV
static ssize_t
rb_writev_internal(rb_io_t *fptr, const struct iovec *iov, int iovcnt)
{
- VALUE scheduler = rb_fiber_scheduler_current();
+ if (!iovcnt) return 0;
+
+ rb_thread_t *th = GET_THREAD();
+
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
if (scheduler != Qnil) {
- for (int i = 0; i < iovcnt; i += 1) {
- VALUE result = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, iov[i].iov_base, iov[i].iov_len, 0);
+ // This path assumes at least one `iov`:
+ VALUE result = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, iov[0].iov_base, iov[0].iov_len, 0);
- if (!UNDEF_P(result)) {
- return rb_fiber_scheduler_io_result_apply(result);
- }
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
}
}
struct io_internal_writev_struct iis = {
- .th = rb_thread_current(),
+ .th = th->self,
.fptr = fptr,
.nonblock = 0,
.fd = fptr->fd,
@@ -1356,7 +1393,7 @@ rb_writev_internal(rb_io_t *fptr, const struct iovec *iov, int iovcnt)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_writev_func, &iis, fptr->fd);
+ return (ssize_t)rb_io_blocking_region_wait(fptr, internal_writev_func, &iis, RUBY_IO_WRITABLE);
}
#endif
@@ -1382,11 +1419,35 @@ io_flush_buffer_sync(void *arg)
return (VALUE)-1;
}
+static inline VALUE
+io_flush_buffer_fiber_scheduler(VALUE scheduler, rb_io_t *fptr)
+{
+ VALUE ret = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, fptr->wbuf.ptr+fptr->wbuf.off, fptr->wbuf.len, 0);
+ if (!UNDEF_P(ret)) {
+ ssize_t result = rb_fiber_scheduler_io_result_apply(ret);
+ if (result > 0) {
+ fptr->wbuf.off += result;
+ fptr->wbuf.len -= result;
+ }
+ return result >= 0 ? (VALUE)0 : (VALUE)-1;
+ }
+ return ret;
+}
+
static VALUE
io_flush_buffer_async(VALUE arg)
{
rb_io_t *fptr = (rb_io_t *)arg;
- return rb_thread_io_blocking_region(io_flush_buffer_sync, fptr, fptr->fd);
+
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ VALUE result = io_flush_buffer_fiber_scheduler(scheduler, fptr);
+ if (!UNDEF_P(result)) {
+ return result;
+ }
+ }
+
+ return rb_io_blocking_region_wait(fptr, io_flush_buffer_sync, fptr, RUBY_IO_WRITABLE);
}
static inline int
@@ -1421,7 +1482,8 @@ io_fflush(rb_io_t *fptr)
VALUE
rb_io_wait(VALUE io, VALUE events, VALUE timeout)
{
- VALUE scheduler = rb_fiber_scheduler_current();
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
if (scheduler != Qnil) {
return rb_fiber_scheduler_io_wait(scheduler, io, events, timeout);
@@ -1442,7 +1504,7 @@ rb_io_wait(VALUE io, VALUE events, VALUE timeout)
tv = &tv_storage;
}
- int ready = rb_thread_wait_for_single_fd(fptr->fd, RB_NUM2INT(events), tv);
+ int ready = rb_thread_io_wait(th, fptr, RB_NUM2INT(events), tv);
if (ready < 0) {
rb_sys_fail(0);
@@ -1462,21 +1524,19 @@ rb_io_wait(VALUE io, VALUE events, VALUE timeout)
static VALUE
io_from_fd(int fd)
{
- return prep_io(fd, FMODE_PREP, rb_cIO, NULL);
+ return prep_io(fd, FMODE_EXTERNAL, rb_cIO, NULL);
}
static int
-io_wait_for_single_fd(int fd, int events, struct timeval *timeout)
+io_wait_for_single_fd(int fd, int events, struct timeval *timeout, rb_thread_t *th, VALUE scheduler)
{
- VALUE scheduler = rb_fiber_scheduler_current();
-
if (scheduler != Qnil) {
return RTEST(
rb_fiber_scheduler_io_wait(scheduler, io_from_fd(fd), RB_INT2NUM(events), rb_fiber_scheduler_make_timeout(timeout))
);
}
- return rb_thread_wait_for_single_fd(fd, events, timeout);
+ return rb_thread_wait_for_single_fd(th, fd, events, timeout);
}
int
@@ -1484,7 +1544,8 @@ rb_io_wait_readable(int f)
{
io_fd_check_closed(f);
- VALUE scheduler = rb_fiber_scheduler_current();
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
switch (errno) {
case EINTR:
@@ -1504,7 +1565,7 @@ rb_io_wait_readable(int f)
);
}
else {
- io_wait_for_single_fd(f, RUBY_IO_READABLE, NULL);
+ io_wait_for_single_fd(f, RUBY_IO_READABLE, NULL, th, scheduler);
}
return TRUE;
@@ -1518,7 +1579,8 @@ rb_io_wait_writable(int f)
{
io_fd_check_closed(f);
- VALUE scheduler = rb_fiber_scheduler_current();
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
switch (errno) {
case EINTR:
@@ -1547,7 +1609,7 @@ rb_io_wait_writable(int f)
);
}
else {
- io_wait_for_single_fd(f, RUBY_IO_WRITABLE, NULL);
+ io_wait_for_single_fd(f, RUBY_IO_WRITABLE, NULL, th, scheduler);
}
return TRUE;
@@ -1559,7 +1621,9 @@ rb_io_wait_writable(int f)
int
rb_wait_for_single_fd(int fd, int events, struct timeval *timeout)
{
- return io_wait_for_single_fd(fd, events, timeout);
+ rb_thread_t *th = GET_THREAD();
+ VALUE scheduler = rb_fiber_scheduler_current_for_threadptr(th);
+ return io_wait_for_single_fd(fd, events, timeout, th, scheduler);
}
int
@@ -1611,7 +1675,7 @@ rb_io_maybe_wait(int error, VALUE io, VALUE events, VALUE timeout)
default:
// Non-specific error, no event is ready:
- return Qfalse;
+ return Qnil;
}
}
@@ -1623,9 +1687,11 @@ rb_io_maybe_wait_readable(int error, VALUE io, VALUE timeout)
if (RTEST(result)) {
return RB_NUM2INT(result);
}
- else {
- return 0;
+ else if (result == RUBY_Qfalse) {
+ rb_raise(rb_eIOTimeoutError, "Timed out waiting for IO to become readable!");
}
+
+ return 0;
}
int
@@ -1636,9 +1702,11 @@ rb_io_maybe_wait_writable(int error, VALUE io, VALUE timeout)
if (RTEST(result)) {
return RB_NUM2INT(result);
}
- else {
- return 0;
+ else if (result == RUBY_Qfalse) {
+ rb_raise(rb_eIOTimeoutError, "Timed out waiting for IO to become writable!");
}
+
+ return 0;
}
static void
@@ -1699,7 +1767,6 @@ make_writeconv(rb_io_t *fptr)
/* writing functions */
struct binwrite_arg {
rb_io_t *fptr;
- VALUE str;
const char *ptr;
long length;
};
@@ -1795,13 +1862,11 @@ io_binwrite_string(VALUE arg)
// Write as much as possible:
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);
- // If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
- // should try again.
if (result == 0) {
- errno = EWOULDBLOCK;
+ // If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
+ // should try again immediately.
}
-
- if (result > 0) {
+ else if (result > 0) {
if ((size_t)result == remaining) break;
ptr += result;
remaining -= result;
@@ -1851,7 +1916,7 @@ io_binwrite_requires_flush_write(rb_io_t *fptr, long len, int nosync)
}
static long
-io_binwrite(VALUE str, const char *ptr, long len, rb_io_t *fptr, int nosync)
+io_binwrite(const char *ptr, long len, rb_io_t *fptr, int nosync)
{
if (len <= 0) return len;
@@ -1864,7 +1929,6 @@ io_binwrite(VALUE str, const char *ptr, long len, rb_io_t *fptr, int nosync)
struct binwrite_arg arg;
arg.fptr = fptr;
- arg.str = str;
arg.ptr = ptr;
arg.length = len;
@@ -1972,9 +2036,9 @@ io_fwrite(VALUE str, rb_io_t *fptr, int nosync)
if (converted)
OBJ_FREEZE(str);
- tmp = rb_str_tmp_frozen_acquire(str);
+ tmp = rb_str_tmp_frozen_no_embed_acquire(str);
RSTRING_GETMEM(tmp, ptr, len);
- n = io_binwrite(tmp, ptr, len, fptr, nosync);
+ n = io_binwrite(ptr, len, fptr, nosync);
rb_str_tmp_frozen_release(str, tmp);
return n;
@@ -1987,7 +2051,7 @@ rb_io_bufwrite(VALUE io, const void *buf, size_t size)
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
- return (ssize_t)io_binwrite(0, buf, (long)size, fptr, 0);
+ return (ssize_t)io_binwrite(buf, (long)size, fptr, 0);
}
static VALUE
@@ -2041,7 +2105,7 @@ io_binwritev_internal(VALUE arg)
while (remaining) {
long result = rb_writev_internal(fptr, iov, iovcnt);
- if (result > 0) {
+ if (result >= 0) {
offset += result;
if (fptr->wbuf.ptr && fptr->wbuf.len) {
if (offset < (size_t)fptr->wbuf.len) {
@@ -2279,7 +2343,7 @@ rb_io_writev(VALUE io, int argc, const VALUE *argv)
if (argc > 1 && rb_obj_method_arity(io, id_write) == 1) {
if (io != rb_ractor_stderr() && RTEST(ruby_verbose)) {
VALUE klass = CLASS_OF(io);
- char sep = FL_TEST(klass, FL_SINGLETON) ? (klass = io, '.') : '#';
+ char sep = RCLASS_SINGLETON_P(klass) ? (klass = io, '.') : '#';
rb_category_warning(
RB_WARN_CATEGORY_DEPRECATED, "%+"PRIsVALUE"%c""write is outdated interface"
" which accepts just one argument",
@@ -2353,7 +2417,7 @@ rb_io_flush_raw(VALUE io, int sync)
rb_sys_fail_on_write(fptr);
}
if (fptr->mode & FMODE_READABLE) {
- io_unread(fptr);
+ io_unread(fptr, true);
}
return io;
@@ -2472,7 +2536,7 @@ interpret_seek_whence(VALUE vwhence)
* f.tell # => 12
* f.close
*
- * - +:SET+ or <tt>IO:SEEK_SET</tt>:
+ * - +:SET+ or <tt>IO::SEEK_SET</tt>:
* Repositions the stream to the given +offset+:
*
* f = File.open('t.txt')
@@ -2596,9 +2660,6 @@ io_fillbuf(rb_io_t *fptr)
fptr->rbuf.len = 0;
fptr->rbuf.capa = IO_RBUF_CAPA_FOR(fptr);
fptr->rbuf.ptr = ALLOC_N(char, fptr->rbuf.capa);
-#ifdef _WIN32
- fptr->rbuf.capa--;
-#endif
}
if (fptr->rbuf.len == 0) {
retry:
@@ -2673,7 +2734,7 @@ rb_io_eof(VALUE io)
READ_CHECK(fptr);
#if RUBY_CRLF_ENVIRONMENT
if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) {
- return RBOOL(eof(fptr->fd));;
+ return RBOOL(eof(fptr->fd));
}
#endif
return RBOOL(io_fillbuf(fptr) < 0);
@@ -2776,8 +2837,10 @@ rb_io_fsync(VALUE io)
if (io_fflush(fptr) < 0)
rb_sys_fail_on_write(fptr);
- if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0)
+
+ if ((int)rb_io_blocking_region(fptr, nogvl_fsync, fptr))
rb_sys_fail_path(fptr->pathv);
+
return INT2FIX(0);
}
#else
@@ -2826,7 +2889,7 @@ rb_io_fdatasync(VALUE io)
if (io_fflush(fptr) < 0)
rb_sys_fail_on_write(fptr);
- if ((int)rb_thread_io_blocking_region(nogvl_fdatasync, fptr, fptr->fd) == 0)
+ if ((int)rb_io_blocking_region(fptr, nogvl_fdatasync, fptr) == 0)
return INT2FIX(0);
/* fall back */
@@ -2870,8 +2933,23 @@ rb_io_descriptor(VALUE io)
return fptr->fd;
}
else {
- return RB_NUM2INT(rb_funcall(io, id_fileno, 0));
+ VALUE fileno = rb_check_funcall(io, id_fileno, 0, NULL);
+ if (!UNDEF_P(fileno)) {
+ return RB_NUM2INT(fileno);
+ }
}
+
+ rb_raise(rb_eTypeError, "expected IO or #fileno, %"PRIsVALUE" given", rb_obj_class(io));
+
+ UNREACHABLE_RETURN(-1);
+}
+
+int
+rb_io_mode(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->mode;
}
/*
@@ -2920,7 +2998,7 @@ rb_io_pid(VALUE io)
* File.open("testfile") {|f| f.path} # => "testfile"
*/
-static VALUE
+VALUE
rb_io_path(VALUE io)
{
rb_io_t *fptr = RFILE(io)->fptr;
@@ -3107,8 +3185,6 @@ io_enc_str(VALUE str, rb_io_t *fptr)
return str;
}
-static rb_encoding *io_read_encoding(rb_io_t *fptr);
-
static void
make_readconv(rb_io_t *fptr, int size)
{
@@ -3251,19 +3327,16 @@ io_shift_cbuf(rb_io_t *fptr, int len, VALUE *strp)
static int
io_setstrbuf(VALUE *str, long len)
{
-#ifdef _WIN32
- if (len > 0)
- len = (len + 1) & ~1L; /* round up for wide char */
-#endif
if (NIL_P(*str)) {
*str = rb_str_new(0, len);
return TRUE;
}
else {
VALUE s = StringValue(*str);
+ rb_str_modify(s);
+
long clen = RSTRING_LEN(s);
if (clen >= len) {
- rb_str_modify(s);
return FALSE;
}
len -= clen;
@@ -3394,7 +3467,12 @@ io_read_memory_call(VALUE arg)
}
}
- return rb_thread_io_blocking_region(internal_read_func, iis, iis->fptr->fd);
+ if (iis->nonblock) {
+ return rb_io_blocking_region(iis->fptr, internal_read_func, iis);
+ }
+ else {
+ return rb_io_blocking_region_wait(iis->fptr, internal_read_func, iis, RUBY_IO_READABLE);
+ }
}
static long
@@ -3801,8 +3879,33 @@ rscheck(const char *rsptr, long rslen, VALUE rs)
rb_raise(rb_eRuntimeError, "rs modified");
}
+static const char *
+search_delim(const char *p, long len, int delim, rb_encoding *enc)
+{
+ if (rb_enc_mbminlen(enc) == 1) {
+ p = memchr(p, delim, len);
+ if (p) return p + 1;
+ }
+ else {
+ const char *end = p + len;
+ while (p < end) {
+ int r = rb_enc_precise_mbclen(p, end, enc);
+ if (!MBCLEN_CHARFOUND_P(r)) {
+ p += rb_enc_mbminlen(enc);
+ continue;
+ }
+ int n = MBCLEN_CHARFOUND_LEN(r);
+ if (rb_enc_mbc_to_codepoint(p, end, enc) == (unsigned int)delim) {
+ return p + n;
+ }
+ p += n;
+ }
+ }
+ return NULL;
+}
+
static int
-appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
+appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp, rb_encoding *enc)
{
VALUE str = *strp;
long limit = *lp;
@@ -3817,9 +3920,9 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
p = READ_CHAR_PENDING_PTR(fptr);
if (0 < limit && limit < searchlen)
searchlen = (int)limit;
- e = memchr(p, delim, searchlen);
+ e = search_delim(p, searchlen, delim, enc);
if (e) {
- int len = (int)(e-p+1);
+ int len = (int)(e-p);
if (NIL_P(str))
*strp = str = rb_str_new(p, len);
else
@@ -3859,8 +3962,8 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
long last;
if (limit > 0 && pending > limit) pending = limit;
- e = memchr(p, delim, pending);
- if (e) pending = e - p + 1;
+ e = search_delim(p, pending, delim, enc);
+ if (e) pending = e - p;
if (!NIL_P(str)) {
last = RSTRING_LEN(str);
rb_str_resize(str, last + pending);
@@ -4115,21 +4218,31 @@ rb_io_getline_0(VALUE rs, long limit, int chomp, rb_io_t *fptr)
rs = 0;
if (!rb_enc_asciicompat(enc)) {
rs = rb_usascii_str_new(rsptr, rslen);
- rs = rb_str_encode(rs, rb_enc_from_encoding(enc), 0, Qnil);
+ rs = rb_str_conv_enc(rs, 0, enc);
OBJ_FREEZE(rs);
rsptr = RSTRING_PTR(rs);
rslen = RSTRING_LEN(rs);
}
+ newline = '\n';
+ }
+ else if (rb_enc_mbminlen(enc) == 1) {
+ rsptr = RSTRING_PTR(rs);
+ newline = (unsigned char)rsptr[rslen - 1];
}
else {
+ rs = rb_str_conv_enc(rs, 0, enc);
rsptr = RSTRING_PTR(rs);
+ const char *e = rsptr + rslen;
+ const char *last = rb_enc_prev_char(rsptr, e, e, enc);
+ int n;
+ newline = rb_enc_codepoint_len(last, e, &n, enc);
+ if (last + n != e) rb_raise(rb_eArgError, "broken separator");
}
- newline = (unsigned char)rsptr[rslen - 1];
- chomp_cr = chomp && rslen == 1 && newline == '\n';
+ chomp_cr = chomp && newline == '\n' && rslen == rb_enc_mbminlen(enc);
}
/* MS - Optimization */
- while ((c = appendline(fptr, newline, &str, &limit)) != EOF) {
+ while ((c = appendline(fptr, newline, &str, &limit, enc)) != EOF) {
const char *s, *p, *pp, *e;
if (c == newline) {
@@ -4137,8 +4250,7 @@ rb_io_getline_0(VALUE rs, long limit, int chomp, rb_io_t *fptr)
s = RSTRING_PTR(str);
e = RSTRING_END(str);
p = e - rslen;
- pp = rb_enc_left_char_head(s, p, e, enc);
- if (pp != p) continue;
+ if (!at_char_boundary(s, p, e, enc)) continue;
if (!rspara) rscheck(rsptr, rslen, rs);
if (memcmp(p, rsptr, rslen) == 0) {
if (chomp) {
@@ -4151,8 +4263,8 @@ rb_io_getline_0(VALUE rs, long limit, int chomp, rb_io_t *fptr)
if (limit == 0) {
s = RSTRING_PTR(str);
p = RSTRING_END(str);
- pp = rb_enc_left_char_head(s, p-1, p, enc);
- if (extra_limit &&
+ pp = rb_enc_prev_char(s, p, p, enc);
+ if (extra_limit && pp &&
MBCLEN_NEEDMORE_P(rb_enc_precise_mbclen(pp, p, enc))) {
/* relax the limit while incomplete character.
* extra_limit limits the relax length */
@@ -4218,11 +4330,17 @@ rb_io_gets(VALUE io)
}
VALUE
-rb_io_gets_internal(VALUE io)
+rb_io_gets_limit_internal(VALUE io, long limit)
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
- return rb_io_getline_0(rb_default_rs, -1, FALSE, fptr);
+ return rb_io_getline_0(rb_default_rs, limit, FALSE, fptr);
+}
+
+VALUE
+rb_io_gets_internal(VALUE io)
+{
+ return rb_io_gets_limit_internal(io, -1);
}
/*
@@ -4279,11 +4397,8 @@ rb_io_gets_internal(VALUE io)
* File.open('t.txt') {|f| f.gets(12) } # => "First line\n"
*
* With arguments +sep+ and +limit+ given,
- * combines the two behaviors:
- *
- * - Returns the next line as determined by line separator +sep+,
- * or +nil+ if none.
- * - But returns no more bytes than are allowed by the limit.
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword argument +chomp+ specifies whether line separators
* are to be omitted:
@@ -4350,22 +4465,36 @@ rb_io_set_lineno(VALUE io, VALUE lineno)
return lineno;
}
-/*
- * call-seq:
- * readline(sep = $/, chomp: false) -> string
- * readline(limit, chomp: false) -> string
- * readline(sep, limit, chomp: false) -> string
- *
- * Reads a line as with IO#gets, but raises EOFError if already at end-of-stream.
- *
- * Optional keyword argument +chomp+ specifies whether line separators
- * are to be omitted.
- */
-
+/* :nodoc: */
static VALUE
-rb_io_readline(int argc, VALUE *argv, VALUE io)
+io_readline(rb_execution_context_t *ec, VALUE io, VALUE sep, VALUE lim, VALUE chomp)
{
- VALUE line = rb_io_gets_m(argc, argv, io);
+ long limit = -1;
+ if (NIL_P(lim)) {
+ VALUE tmp = Qnil;
+ // If sep is specified, but it's not a string and not nil, then assume
+ // it's the limit (it should be an integer)
+ if (!NIL_P(sep) && NIL_P(tmp = rb_check_string_type(sep))) {
+ // If the user has specified a non-nil / non-string value
+ // for the separator, we assume it's the limit and set the
+ // separator to default: rb_rs.
+ lim = sep;
+ limit = NUM2LONG(lim);
+ sep = rb_rs;
+ }
+ else {
+ sep = tmp;
+ }
+ }
+ else {
+ if (!NIL_P(sep)) StringValue(sep);
+ limit = NUM2LONG(lim);
+ }
+
+ check_getline_args(&sep, &limit, io);
+
+ VALUE line = rb_io_getline_1(sep, limit, RTEST(chomp), io);
+ rb_lastline_set_up(line, 1);
if (NIL_P(line)) {
rb_eof_error();
@@ -4426,10 +4555,8 @@ static VALUE io_readlines(const struct getline_arg *arg, VALUE io);
* f.close
*
* With arguments +sep+ and +limit+ given,
- * combines the two behaviors:
- *
- * - Returns lines as determined by line separator +sep+.
- * - But returns no more bytes in a line than are allowed by the limit.
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword argument +chomp+ specifies whether line separators
* are to be omitted:
@@ -4549,10 +4676,8 @@ io_readlines(const struct getline_arg *arg, VALUE io)
* "ne\n"
*
* With arguments +sep+ and +limit+ given,
- * combines the two behaviors:
- *
- * - Calls with the next line as determined by line separator +sep+.
- * - But returns no more bytes than are allowed by the limit.
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword argument +chomp+ specifies whether line separators
* are to be omitted:
@@ -4596,10 +4721,11 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
* Calls the given block with each byte (0..255) in the stream; returns +self+.
* See {Byte IO}[rdoc-ref:IO@Byte+IO].
*
- * f = File.new('t.rus')
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.new('t.ja')
* a = []
* f.each_byte {|b| a << b }
- * a # => [209, 130, 208, 181, 209, 129, 209, 130]
+ * a # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
* f.close
*
* Returns an Enumerator if no block is given.
@@ -4744,10 +4870,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
* Calls the given block with each character in the stream; returns +self+.
* See {Character IO}[rdoc-ref:IO@Character+IO].
*
- * f = File.new('t.rus')
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.new('t.ja')
* a = []
* f.each_char {|c| a << c.ord }
- * a # => [1090, 1077, 1089, 1090]
+ * a # => [12371, 12435, 12395, 12385, 12399]
* f.close
*
* Returns an Enumerator if no block is given.
@@ -4782,10 +4909,11 @@ rb_io_each_char(VALUE io)
*
* Calls the given block with each codepoint in the stream; returns +self+:
*
- * f = File.new('t.rus')
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.new('t.ja')
* a = []
* f.each_codepoint {|c| a << c }
- * a # => [1090, 1077, 1089, 1090]
+ * a # => [12371, 12435, 12395, 12385, 12399]
* f.close
*
* Returns an Enumerator if no block is given.
@@ -4807,6 +4935,7 @@ rb_io_each_codepoint(VALUE io)
rb_io_check_char_readable(fptr);
READ_CHECK(fptr);
+ enc = io_read_encoding(fptr);
if (NEED_READCONV(fptr)) {
SET_BINARY_MODE(fptr);
r = 1; /* no invalid char yet */
@@ -4814,12 +4943,9 @@ rb_io_each_codepoint(VALUE io)
make_readconv(fptr, 0);
for (;;) {
if (fptr->cbuf.len) {
- if (fptr->encs.enc)
- r = rb_enc_precise_mbclen(fptr->cbuf.ptr+fptr->cbuf.off,
- fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len,
- fptr->encs.enc);
- else
- r = ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1);
+ r = rb_enc_precise_mbclen(fptr->cbuf.ptr+fptr->cbuf.off,
+ fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len,
+ enc);
if (!MBCLEN_NEEDMORE_P(r))
break;
if (fptr->cbuf.len == fptr->cbuf.capa) {
@@ -4829,33 +4955,25 @@ rb_io_each_codepoint(VALUE io)
if (more_char(fptr) == MORE_CHAR_FINISHED) {
clear_readconv(fptr);
if (!MBCLEN_CHARFOUND_P(r)) {
- enc = fptr->encs.enc;
goto invalid;
}
return io;
}
}
if (MBCLEN_INVALID_P(r)) {
- enc = fptr->encs.enc;
goto invalid;
}
n = MBCLEN_CHARFOUND_LEN(r);
- if (fptr->encs.enc) {
- c = rb_enc_codepoint(fptr->cbuf.ptr+fptr->cbuf.off,
- fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len,
- fptr->encs.enc);
- }
- else {
- c = (unsigned char)fptr->cbuf.ptr[fptr->cbuf.off];
- }
+ c = rb_enc_codepoint(fptr->cbuf.ptr+fptr->cbuf.off,
+ fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len,
+ enc);
fptr->cbuf.off += n;
fptr->cbuf.len -= n;
rb_yield(UINT2NUM(c));
- rb_io_check_byte_readable(fptr);
+ rb_io_check_char_readable(fptr);
}
}
NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr);
- enc = io_input_encoding(fptr);
while (io_fillbuf(fptr) >= 0) {
r = rb_enc_precise_mbclen(fptr->rbuf.ptr+fptr->rbuf.off,
fptr->rbuf.ptr+fptr->rbuf.off+fptr->rbuf.len, enc);
@@ -4909,8 +5027,9 @@ rb_io_each_codepoint(VALUE io)
* f = File.open('t.txt')
* f.getc # => "F"
* f.close
- * f = File.open('t.rus')
- * f.getc.ord # => 1090
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.open('t.ja')
+ * f.getc.ord # => 12371
* f.close
*
* Related: IO#readchar (may raise EOFError).
@@ -4942,8 +5061,9 @@ rb_io_getc(VALUE io)
* f = File.open('t.txt')
* f.readchar # => "F"
* f.close
- * f = File.open('t.rus')
- * f.readchar.ord # => 1090
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.open('t.ja')
+ * f.readchar.ord # => 12371
* f.close
*
* Related: IO#getc (will not raise EOFError).
@@ -4972,8 +5092,9 @@ rb_io_readchar(VALUE io)
* f = File.open('t.txt')
* f.getbyte # => 70
* f.close
- * f = File.open('t.rus')
- * f.getbyte # => 209
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.open('t.ja')
+ * f.getbyte # => 227
* f.close
*
* Related: IO#readbyte (may raise EOFError).
@@ -5016,8 +5137,9 @@ rb_io_getbyte(VALUE io)
* f = File.open('t.txt')
* f.readbyte # => 70
* f.close
- * f = File.open('t.rus')
- * f.readbyte # => 209
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * f = File.open('t.ja')
+ * f.readbyte # => 227
* f.close
*
* Related: IO#getbyte (will not raise EOFError).
@@ -5090,7 +5212,7 @@ rb_io_ungetbyte(VALUE io, VALUE b)
b = rb_str_new((const char *)&c, 1);
break;
default:
- SafeStringValue(b);
+ StringValue(b);
}
io_ungetbyte(b, fptr);
return Qnil;
@@ -5152,7 +5274,7 @@ rb_io_ungetc(VALUE io, VALUE c)
c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr));
}
else {
- SafeStringValue(c);
+ StringValue(c);
}
if (NEED_READCONV(fptr)) {
SET_BINARY_MODE(fptr);
@@ -5253,7 +5375,7 @@ rb_io_close_on_exec_p(VALUE io)
*
* Sets a close-on-exec flag.
*
- * f = open("/dev/null")
+ * f = File.open(File::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
@@ -5304,7 +5426,7 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
#define rb_io_set_close_on_exec rb_f_notimplement
#endif
-#define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
+#define RUBY_IO_EXTERNAL_P(f) ((f)->mode & FMODE_EXTERNAL)
#define PREP_STDIO_NAME(f) (RSTRING_PTR((f)->pathv))
static VALUE
@@ -5398,7 +5520,7 @@ maygvl_close(int fd, int keepgvl)
* close() may block for certain file types (NFS, SO_LINGER sockets,
* inotify), so let other threads run.
*/
- return (int)(intptr_t)rb_thread_call_without_gvl(nogvl_close, &fd, RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL_INT(nogvl_close, &fd);
}
static void*
@@ -5415,15 +5537,13 @@ maygvl_fclose(FILE *file, int keepgvl)
if (keepgvl)
return fclose(file);
- return (int)(intptr_t)rb_thread_call_without_gvl(nogvl_fclose, file, RUBY_UBF_IO, 0);
+ return IO_WITHOUT_GVL_INT(nogvl_fclose, file);
}
static void free_io_buffer(rb_io_buffer_t *buf);
-static void clear_codeconv(rb_io_t *fptr);
static void
-fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
- struct ccan_list_head *busy)
+fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl)
{
VALUE error = Qnil;
int fd = fptr->fd;
@@ -5454,7 +5574,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
int done = 0;
- if (IS_PREP_STDIO(fptr) || fd <= 2) {
+ if (RUBY_IO_EXTERNAL_P(fptr) || fd <= 2) {
// Need to keep FILE objects of stdin, stdout and stderr, so we are done:
done = 1;
}
@@ -5463,20 +5583,8 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
fptr->stdio_file = 0;
fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
- // Ensure waiting_fd users do not hit EBADF.
- if (busy) {
- // Wait for them to exit before we call close().
- do rb_thread_schedule(); while (!ccan_list_empty(busy));
- }
-
- // Disable for now.
- // if (!done && fd >= 0) {
- // VALUE scheduler = rb_fiber_scheduler_current();
- // if (scheduler != Qnil) {
- // VALUE result = rb_fiber_scheduler_io_close(scheduler, fptr->self);
- // if (!UNDEF_P(result)) done = 1;
- // }
- // }
+ // Wait for blocking operations to ensure they do not hit EBADF:
+ rb_thread_io_close_wait(fptr);
if (!done && stdio_file) {
// stdio_file is deallocated anyway even if fclose failed.
@@ -5489,6 +5597,15 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
done = 1;
}
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (!done && fd >= 0 && scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_io_close(scheduler, RB_INT2NUM(fd));
+
+ if (!UNDEF_P(result)) {
+ done = RTEST(result);
+ }
+ }
+
if (!done && fd >= 0) {
// fptr->fd may be closed even if close fails. POSIX doesn't specify it.
// We assumes it is closed.
@@ -5515,7 +5632,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
static void
fptr_finalize(rb_io_t *fptr, int noraise)
{
- fptr_finalize_flush(fptr, noraise, FALSE, 0);
+ fptr_finalize_flush(fptr, noraise, FALSE);
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
@@ -5536,7 +5653,7 @@ static void
free_io_buffer(rb_io_buffer_t *buf)
{
if (buf->ptr) {
- ruby_sized_xfree(buf->ptr, (size_t)buf->capa);
+ ruby_xfree_sized(buf->ptr, (size_t)buf->capa);
buf->ptr = NULL;
}
}
@@ -5568,12 +5685,9 @@ clear_codeconv(rb_io_t *fptr)
clear_writeconv(fptr);
}
-void
-rb_io_fptr_finalize_internal(void *ptr)
+static void
+rb_io_fptr_cleanup_all(rb_io_t *fptr)
{
- rb_io_t *fptr = ptr;
-
- if (!ptr) return;
fptr->pathv = Qnil;
if (0 <= fptr->fd)
rb_io_fptr_cleanup(fptr, TRUE);
@@ -5581,32 +5695,47 @@ rb_io_fptr_finalize_internal(void *ptr)
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
- free(fptr);
}
-#undef rb_io_fptr_finalize
int
-rb_io_fptr_finalize(rb_io_t *fptr)
+rb_io_fptr_finalize(struct rb_io *io)
{
- if (!fptr) {
- return 0;
- }
- else {
- rb_io_fptr_finalize_internal(fptr);
- return 1;
- }
+ if (!io) return 0;
+ rb_io_fptr_cleanup_all(io);
+ free(io);
+
+ return 1;
+}
+
+bool
+rb_io_fptr_finalize_closed(struct rb_io *io)
+{
+ if (!io) return true;
+ if (io->fd >= 0) return false;
+ rb_io_fptr_finalize(io);
+ return true;
}
-#define rb_io_fptr_finalize(fptr) rb_io_fptr_finalize_internal(fptr)
-RUBY_FUNC_EXPORTED size_t
-rb_io_memsize(const rb_io_t *fptr)
+size_t
+rb_io_memsize(const rb_io_t *io)
{
size_t size = sizeof(rb_io_t);
- size += fptr->rbuf.capa;
- size += fptr->wbuf.capa;
- size += fptr->cbuf.capa;
- if (fptr->readconv) size += rb_econv_memsize(fptr->readconv);
- if (fptr->writeconv) size += rb_econv_memsize(fptr->writeconv);
+ size += io->rbuf.capa;
+ size += io->wbuf.capa;
+ size += io->cbuf.capa;
+ if (io->readconv) size += rb_econv_memsize(io->readconv);
+ if (io->writeconv) size += rb_econv_memsize(io->writeconv);
+
+ struct rb_io_blocking_operation *blocking_operation = 0;
+
+ // Validate the fork generation of the IO object. If the IO object fork generation is different, the list of blocking operations is not valid memory. See `rb_io_blocking_operations` for the exact semantics.
+ rb_serial_t fork_generation = GET_VM()->fork_gen;
+ if (io->fork_generation == fork_generation) {
+ ccan_list_for_each(&io->blocking_operations, blocking_operation, list) {
+ size += sizeof(struct rb_io_blocking_operation);
+ }
+ }
+
return size;
}
@@ -5617,16 +5746,13 @@ rb_io_memsize(const rb_io_t *fptr)
# define KEEPGVL FALSE
#endif
-int rb_notify_fd_close(int fd, struct ccan_list_head *);
static rb_io_t *
io_close_fptr(VALUE io)
{
rb_io_t *fptr;
VALUE write_io;
rb_io_t *write_fptr;
- struct ccan_list_head busy;
- ccan_list_head_init(&busy);
write_io = GetWriteIO(io);
if (io != write_io) {
write_fptr = RFILE(write_io)->fptr;
@@ -5639,10 +5765,12 @@ io_close_fptr(VALUE io)
if (!fptr) return 0;
if (fptr->fd < 0) return 0;
- if (rb_notify_fd_close(fptr->fd, &busy)) {
+ // This guards against multiple threads closing the same IO object:
+ if (rb_thread_io_close_interrupt(fptr)) {
/* calls close(fptr->fd): */
- fptr_finalize_flush(fptr, FALSE, KEEPGVL, &busy);
+ fptr_finalize_flush(fptr, FALSE, KEEPGVL);
}
+
rb_io_fptr_cleanup(fptr, FALSE);
return fptr;
}
@@ -5680,6 +5808,9 @@ rb_io_close(VALUE io)
* If the stream was opened by IO.popen, sets global variable <tt>$?</tt>
* (child exit status).
*
+ * It is not an error to close an IO object that has already been closed.
+ * It just returns nil.
+ *
* Example:
*
* IO.popen('ruby', 'r+') do |pipe|
@@ -5763,10 +5894,8 @@ io_close(VALUE io)
*
* Related: IO#close_read, IO#close_write, IO#close.
*/
-
-
-static VALUE
-rb_io_closed(VALUE io)
+VALUE
+rb_io_closed_p(VALUE io)
{
rb_io_t *fptr;
VALUE write_io;
@@ -6064,28 +6193,37 @@ rb_io_sysread(int argc, VALUE *argv, VALUE io)
return str;
}
-#if defined(HAVE_PREAD) || defined(HAVE_PWRITE)
struct prdwr_internal_arg {
+ struct rb_io *io;
int fd;
void *buf;
size_t count;
rb_off_t offset;
};
-#endif /* HAVE_PREAD || HAVE_PWRITE */
-#if defined(HAVE_PREAD)
static VALUE
-internal_pread_func(void *arg)
+internal_pread_func(void *_arg)
{
- struct prdwr_internal_arg *p = arg;
- return (VALUE)pread(p->fd, p->buf, p->count, p->offset);
+ struct prdwr_internal_arg *arg = _arg;
+
+ return (VALUE)pread(arg->fd, arg->buf, arg->count, arg->offset);
}
static VALUE
-pread_internal_call(VALUE arg)
+pread_internal_call(VALUE _arg)
{
- struct prdwr_internal_arg *p = (struct prdwr_internal_arg *)arg;
- return rb_thread_io_blocking_region(internal_pread_func, p, p->fd);
+ struct prdwr_internal_arg *arg = (struct prdwr_internal_arg *)_arg;
+
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_io_pread_memory(scheduler, arg->io->self, arg->offset, arg->buf, arg->count, 0);
+
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
+ }
+ }
+
+ return rb_io_blocking_region_wait(arg->io, internal_pread_func, arg, RUBY_IO_READABLE);
}
/*
@@ -6136,6 +6274,7 @@ rb_io_pread(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
+ arg.io = fptr;
arg.fd = fptr->fd;
rb_io_check_closed(fptr);
@@ -6152,19 +6291,32 @@ rb_io_pread(int argc, VALUE *argv, VALUE io)
return str;
}
-#else
-# define rb_io_pread rb_f_notimplement
-#endif /* HAVE_PREAD */
-#if defined(HAVE_PWRITE)
static VALUE
-internal_pwrite_func(void *ptr)
+internal_pwrite_func(void *_arg)
{
- struct prdwr_internal_arg *arg = ptr;
+ struct prdwr_internal_arg *arg = _arg;
return (VALUE)pwrite(arg->fd, arg->buf, arg->count, arg->offset);
}
+static VALUE
+pwrite_internal_call(VALUE _arg)
+{
+ struct prdwr_internal_arg *arg = (struct prdwr_internal_arg *)_arg;
+
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_io_pwrite_memory(scheduler, arg->io->self, arg->offset, arg->buf, arg->count, 0);
+
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
+ }
+ }
+
+ return rb_io_blocking_region_wait(arg->io, internal_pwrite_func, arg, RUBY_IO_WRITABLE);
+}
+
/*
* call-seq:
* pwrite(object, offset) -> integer
@@ -6206,21 +6358,20 @@ rb_io_pwrite(VALUE io, VALUE str, VALUE offset)
io = GetWriteIO(io);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
+
+ arg.io = fptr;
arg.fd = fptr->fd;
tmp = rb_str_tmp_frozen_acquire(str);
arg.buf = RSTRING_PTR(tmp);
arg.count = (size_t)RSTRING_LEN(tmp);
- n = (ssize_t)rb_thread_io_blocking_region(internal_pwrite_func, &arg, fptr->fd);
+ n = (ssize_t)pwrite_internal_call((VALUE)&arg);
if (n < 0) rb_sys_fail_path(fptr->pathv);
rb_str_tmp_frozen_release(str, tmp);
return SSIZET2NUM(n);
}
-#else
-# define rb_io_pwrite rb_f_notimplement
-#endif /* HAVE_PWRITE */
VALUE
rb_io_binmode(VALUE io)
@@ -6320,7 +6471,7 @@ rb_io_binmode_p(VALUE io)
}
static const char*
-rb_io_fmode_modestr(int fmode)
+rb_io_fmode_modestr(enum rb_io_mode fmode)
{
if (fmode & FMODE_APPEND) {
if ((fmode & FMODE_READWRITE) == FMODE_READWRITE) {
@@ -6354,10 +6505,10 @@ io_encname_bom_p(const char *name, long len)
return len > bom_prefix_len && STRNCASECMP(name, bom_prefix, bom_prefix_len) == 0;
}
-int
+enum rb_io_mode
rb_io_modestr_fmode(const char *modestr)
{
- int fmode = 0;
+ enum rb_io_mode fmode = 0;
const char *m = modestr, *p = NULL;
switch (*m++) {
@@ -6414,7 +6565,7 @@ rb_io_modestr_fmode(const char *modestr)
int
rb_io_oflags_fmode(int oflags)
{
- int fmode = 0;
+ enum rb_io_mode fmode = 0;
switch (oflags & O_ACCMODE) {
case O_RDONLY:
@@ -6450,7 +6601,7 @@ rb_io_oflags_fmode(int oflags)
}
static int
-rb_io_fmode_oflags(int fmode)
+rb_io_fmode_oflags(enum rb_io_mode fmode)
{
int oflags = 0;
@@ -6535,7 +6686,7 @@ rb_io_oflags_modestr(int oflags)
* Qnil => no encoding specified (internal only)
*/
static void
-rb_io_ext_int_to_encs(rb_encoding *ext, rb_encoding *intern, rb_encoding **enc, rb_encoding **enc2, int fmode)
+rb_io_ext_int_to_encs(rb_encoding *ext, rb_encoding *intern, rb_encoding **enc, rb_encoding **enc2, enum rb_io_mode fmode)
{
int default_ext = 0;
@@ -6570,12 +6721,12 @@ unsupported_encoding(const char *name, rb_encoding *enc)
static void
parse_mode_enc(const char *estr, rb_encoding *estr_enc,
- rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
+ rb_encoding **enc_p, rb_encoding **enc2_p, enum rb_io_mode *fmode_p)
{
const char *p;
char encname[ENCODING_MAXNAMELEN+1];
int idx, idx2;
- int fmode = fmode_p ? *fmode_p : 0;
+ enum rb_io_mode fmode = fmode_p ? *fmode_p : 0;
rb_encoding *ext_enc, *int_enc;
long len;
@@ -6637,7 +6788,7 @@ parse_mode_enc(const char *estr, rb_encoding *estr_enc,
}
int
-rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
+rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, enum rb_io_mode *fmode_p)
{
VALUE encoding=Qnil, extenc=Qundef, intenc=Qundef, tmp;
int extracted = 0;
@@ -6705,12 +6856,10 @@ rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2
return extracted;
}
-typedef struct rb_io_enc_t convconfig_t;
-
static void
-validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *enc2)
+validate_enc_binmode(enum rb_io_mode *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *enc2)
{
- int fmode = *fmode_p;
+ enum rb_io_mode fmode = *fmode_p;
if ((fmode & FMODE_READABLE) &&
!enc2 &&
@@ -6735,7 +6884,7 @@ validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *e
}
static void
-extract_binmode(VALUE opthash, int *fmode)
+extract_binmode(VALUE opthash, enum rb_io_mode *fmode)
{
if (!NIL_P(opthash)) {
VALUE v;
@@ -6765,10 +6914,11 @@ extract_binmode(VALUE opthash, int *fmode)
void
rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
- int *oflags_p, int *fmode_p, convconfig_t *convconfig_p)
+ int *oflags_p, enum rb_io_mode *fmode_p, struct rb_io_encoding *convconfig_p)
{
VALUE vmode;
- int oflags, fmode;
+ int oflags;
+ enum rb_io_mode fmode;
rb_encoding *enc, *enc2;
int ecflags;
VALUE ecopts;
@@ -6793,7 +6943,7 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
else {
const char *p;
- SafeStringValue(vmode);
+ StringValue(vmode);
p = StringValueCStr(vmode);
fmode = rb_io_modestr_fmode(p);
oflags = rb_io_fmode_oflags(fmode);
@@ -6927,7 +7077,9 @@ static inline int
rb_sysopen_internal(struct sysopen_struct *data)
{
int fd;
- fd = (int)(VALUE)rb_thread_call_without_gvl(sysopen_func, data, RUBY_UBF_IO, 0);
+ do {
+ fd = IO_WITHOUT_GVL_INT(sysopen_func, data);
+ } while (fd < 0 && errno == EINTR);
if (0 <= fd)
rb_update_max_fd(fd);
return fd;
@@ -6936,7 +7088,7 @@ rb_sysopen_internal(struct sysopen_struct *data)
static int
rb_sysopen(VALUE fname, int oflags, mode_t perm)
{
- int fd;
+ int fd = -1;
struct sysopen_struct data;
data.fname = rb_str_encode_ospath(fname);
@@ -6944,21 +7096,14 @@ rb_sysopen(VALUE fname, int oflags, mode_t perm)
data.oflags = oflags;
data.perm = perm;
- fd = rb_sysopen_internal(&data);
- if (fd < 0) {
- int e = errno;
- if (rb_gc_for_fd(e)) {
- fd = rb_sysopen_internal(&data);
- }
- if (fd < 0) {
- rb_syserr_fail_path(e, fname);
- }
+ TRY_WITH_GC((fd = rb_sysopen_internal(&data)) >= 0) {
+ rb_syserr_fail_path(first_errno, fname);
}
return fd;
}
-FILE *
-rb_fdopen(int fd, const char *modestr)
+static inline FILE *
+fdopen_internal(int fd, const char *modestr)
{
FILE *file;
@@ -6967,26 +7112,22 @@ rb_fdopen(int fd, const char *modestr)
#endif
file = fdopen(fd, modestr);
if (!file) {
- int e = errno;
-#if defined(__sun)
- if (e == 0) {
- rb_gc();
- errno = 0;
- file = fdopen(fd, modestr);
- }
- else
-#endif
- if (rb_gc_for_fd(e)) {
- file = fdopen(fd, modestr);
- }
- if (!file) {
#ifdef _WIN32
- if (e == 0) e = EINVAL;
+ if (errno == 0) errno = EINVAL;
#elif defined(__sun)
- if (e == 0) e = EMFILE;
+ if (errno == 0) errno = EMFILE;
#endif
- rb_syserr_fail(e, 0);
- }
+ }
+ return file;
+}
+
+FILE *
+rb_fdopen(int fd, const char *modestr)
+{
+ FILE *file = 0;
+
+ TRY_WITH_GC((file = fdopen_internal(fd, modestr)) != 0) {
+ rb_syserr_fail(first_errno, 0);
}
/* xxx: should be _IONBF? A buffer in FILE may have trouble. */
@@ -7092,12 +7233,12 @@ io_set_encoding_by_bom(VALUE io)
}
static VALUE
-rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode,
- const convconfig_t *convconfig, mode_t perm)
+rb_file_open_generic(VALUE io, VALUE filename, int oflags, enum rb_io_mode fmode,
+ const struct rb_io_encoding *convconfig, mode_t perm)
{
VALUE pathv;
rb_io_t *fptr;
- convconfig_t cc;
+ struct rb_io_encoding cc;
if (!convconfig) {
/* Set to default encodings */
rb_io_ext_int_to_encs(NULL, NULL, &cc.enc, &cc.enc2, fmode);
@@ -7129,15 +7270,13 @@ rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode,
static VALUE
rb_file_open_internal(VALUE io, VALUE filename, const char *modestr)
{
- int fmode = rb_io_modestr_fmode(modestr);
+ enum rb_io_mode fmode = rb_io_modestr_fmode(modestr);
const char *p = strchr(modestr, ':');
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
if (p) {
parse_mode_enc(p+1, rb_usascii_encoding(),
&convconfig.enc, &convconfig.enc2, &fmode);
- convconfig.ecflags = 0;
- convconfig.ecopts = Qnil;
}
else {
rb_encoding *e;
@@ -7145,10 +7284,19 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr)
e = (fmode & FMODE_BINMODE) ? rb_ascii8bit_encoding() : NULL;
rb_io_ext_int_to_encs(e, NULL, &convconfig.enc, &convconfig.enc2, fmode);
- convconfig.ecflags = 0;
- convconfig.ecopts = Qnil;
}
+ convconfig.ecflags = (fmode & FMODE_READABLE) ?
+ MODE_BTMODE(ECONV_DEFAULT_NEWLINE_DECORATOR,
+ 0, ECONV_UNIVERSAL_NEWLINE_DECORATOR) : 0;
+#ifdef TEXTMODE_NEWLINE_DECORATOR_ON_WRITE
+ convconfig.ecflags |= (fmode & FMODE_WRITABLE) ?
+ MODE_BTMODE(TEXTMODE_NEWLINE_DECORATOR_ON_WRITE,
+ 0, TEXTMODE_NEWLINE_DECORATOR_ON_WRITE) : 0;
+#endif
+ SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(convconfig.enc2, convconfig.ecflags);
+ convconfig.ecopts = Qnil;
+
return rb_file_open_generic(io, filename,
rb_io_fmode_oflags(fmode),
fmode,
@@ -7239,7 +7387,7 @@ static void
fptr_copy_finalizer(rb_io_t *fptr, const rb_io_t *orig)
{
#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK)
- void (*const old_finalize)(struct rb_io_t*,int) = fptr->finalize;
+ void (*const old_finalize)(struct rb_io*,int) = fptr->finalize;
if (old_finalize == orig->finalize) return;
#endif
@@ -7277,12 +7425,7 @@ int
rb_pipe(int *pipes)
{
int ret;
- ret = rb_cloexec_pipe(pipes);
- if (ret < 0) {
- if (rb_gc_for_fd(errno)) {
- ret = rb_cloexec_pipe(pipes);
- }
- }
+ TRY_WITH_GC((ret = rb_cloexec_pipe(pipes)) >= 0);
if (ret == 0) {
rb_update_max_fd(pipes[0]);
rb_update_max_fd(pipes[1]);
@@ -7443,8 +7586,8 @@ char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog);
#ifndef __EMSCRIPTEN__
static VALUE
-pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+pipe_open(VALUE execarg_obj, const char *modestr, enum rb_io_mode fmode,
+ const struct rb_io_encoding *convconfig)
{
struct rb_execarg *eargp = NIL_P(execarg_obj) ? NULL : rb_execarg_get(execarg_obj);
VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ;
@@ -7672,8 +7815,8 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
}
#else
static VALUE
-pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+pipe_open(VALUE execarg_obj, const char *modestr, enum rb_io_mode fmode,
+ const struct rb_io_encoding *convconfig)
{
rb_raise(rb_eNotImpError, "popen() is not available");
}
@@ -7694,8 +7837,8 @@ is_popen_fork(VALUE prog)
}
static VALUE
-pipe_open_s(VALUE prog, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+pipe_open_s(VALUE prog, const char *modestr, enum rb_io_mode fmode,
+ const struct rb_io_encoding *convconfig)
{
int argc = 1;
VALUE *argv = &prog;
@@ -7727,7 +7870,7 @@ static VALUE popen_finish(VALUE port, VALUE klass);
* whose $stdin and $stdout are connected to a new stream +io+.
*
* This method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
+ * see {Command Injection}[rdoc-ref:security/command_injection.rdoc].
*
* If no block is given, returns the new stream,
* which depending on given +mode+ may be open for reading, writing, or both.
@@ -7736,7 +7879,8 @@ static VALUE popen_finish(VALUE port, VALUE klass);
* If a block is given, the stream is passed to the block
* (again, open for reading, writing, or both);
* when the block exits, the stream is closed,
- * and the block's value is assigned to global variable <tt>$?</tt> and returned.
+ * the block's value is returned,
+ * and the global variable <tt>$?</tt> is set to the child's exit status.
*
* Optional argument +mode+ may be any valid \IO mode.
* See {Access Modes}[rdoc-ref:File@Access+Modes].
@@ -7765,7 +7909,7 @@ static VALUE popen_finish(VALUE port, VALUE klass);
* - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
* - Options for Kernel#spawn.
*
- * <b>Forked \Process</b>
+ * <b>Forked Process</b>
*
* When argument +cmd+ is the 1-character string <tt>'-'</tt>, causes the process to fork:
* IO.popen('-') do |pipe|
@@ -7903,8 +8047,9 @@ rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt)
{
const char *modestr;
VALUE tmp, execarg_obj = Qnil;
- int oflags, fmode;
- convconfig_t convconfig;
+ int oflags;
+ enum rb_io_mode fmode;
+ struct rb_io_encoding convconfig;
tmp = rb_check_array_type(pname);
if (!NIL_P(tmp)) {
@@ -7918,7 +8063,7 @@ rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt)
RB_GC_GUARD(tmp);
}
else {
- SafeStringValue(pname);
+ StringValue(pname);
execarg_obj = Qnil;
if (!is_popen_fork(pname))
execarg_obj = rb_execarg_new(1, &pname, TRUE, FALSE);
@@ -7941,10 +8086,10 @@ popen_finish(VALUE port, VALUE klass)
if (NIL_P(port)) {
/* child */
if (rb_block_given_p()) {
- rb_yield(Qnil);
+ rb_protect(rb_yield, Qnil, NULL);
rb_io_flush(rb_ractor_stdout());
rb_io_flush(rb_ractor_stderr());
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
return Qnil;
}
@@ -7955,37 +8100,78 @@ popen_finish(VALUE port, VALUE klass)
return port;
}
-static void
-rb_scan_open_args(int argc, const VALUE *argv,
- VALUE *fname_p, int *oflags_p, int *fmode_p,
- convconfig_t *convconfig_p, mode_t *perm_p)
-{
- VALUE opt, fname, vmode, vperm;
- int oflags, fmode;
- mode_t perm;
+#if defined(HAVE_WORKING_FORK) && !defined(__EMSCRIPTEN__)
+struct popen_writer_arg {
+ char *const *argv;
+ struct popen_arg popen;
+};
- argc = rb_scan_args(argc, argv, "12:", &fname, &vmode, &vperm, &opt);
- FilePathValue(fname);
+static int
+exec_popen_writer(void *arg, char *errmsg, size_t buflen)
+{
+ struct popen_writer_arg *pw = arg;
+ pw->popen.modef = FMODE_WRITABLE;
+ popen_redirect(&pw->popen);
+ execv(pw->argv[0], pw->argv);
+ strlcpy(errmsg, strerror(errno), buflen);
+ return -1;
+}
+#endif
- rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p);
+FILE *
+ruby_popen_writer(char *const *argv, rb_pid_t *pid)
+{
+#if (defined(HAVE_WORKING_FORK) && !defined(__EMSCRIPTEN__)) || defined(_WIN32)
+# ifdef HAVE_WORKING_FORK
+ struct popen_writer_arg pw;
+ int *const write_pair = pw.popen.pair;
+# else
+ int write_pair[2];
+# endif
- perm = NIL_P(vperm) ? 0666 : NUM2MODET(vperm);
+#ifdef HAVE_PIPE2
+ int result = pipe2(write_pair, O_CLOEXEC);
+#else
+ int result = pipe(write_pair);
+#endif
- *fname_p = fname;
- *oflags_p = oflags;
- *fmode_p = fmode;
- *perm_p = perm;
+ *pid = -1;
+ if (result == 0) {
+# ifdef HAVE_WORKING_FORK
+ pw.argv = argv;
+ int status;
+ char errmsg[80] = {'\0'};
+ *pid = rb_fork_async_signal_safe(&status, exec_popen_writer, &pw, Qnil, errmsg, sizeof(errmsg));
+# else
+ *pid = rb_w32_uspawn_process(P_NOWAIT, argv[0], argv, write_pair[0], -1, -1, 0);
+ const char *errmsg = (*pid < 0) ? strerror(errno) : NULL;
+# endif
+ close(write_pair[0]);
+ if (*pid < 0) {
+ close(write_pair[1]);
+ fprintf(stderr, "ruby_popen_writer(%s): %s\n", argv[0], errmsg);
+ }
+ else {
+ return fdopen(write_pair[1], "w");
+ }
+ }
+#endif
+ return NULL;
}
static VALUE
-rb_open_file(int argc, const VALUE *argv, VALUE io)
+rb_open_file(VALUE io, VALUE fname, VALUE vmode, VALUE vperm, VALUE opt)
{
- VALUE fname;
- int oflags, fmode;
- convconfig_t convconfig;
+ int oflags;
+ enum rb_io_mode fmode;
+ struct rb_io_encoding convconfig;
mode_t perm;
- rb_scan_open_args(argc, argv, &fname, &oflags, &fmode, &convconfig, &perm);
+ FilePathValue(fname);
+
+ rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, &convconfig);
+ perm = NIL_P(vperm) ? 0666 : NUM2MODET(vperm);
+
rb_file_open_generic(io, fname, oflags, fmode, &convconfig, perm);
return io;
@@ -7998,11 +8184,11 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* File.open(path, mode = 'r', perm = 0666, **opts) -> file
* File.open(path, mode = 'r', perm = 0666, **opts) {|f| ... } -> object
*
- * Creates a new \File object, via File.new with the given arguments.
+ * Creates a new File object, via File.new with the given arguments.
*
- * With no block given, returns the \File object.
+ * With no block given, returns the File object.
*
- * With a block given, calls the block with the \File object
+ * With a block given, calls the block with the File object
* and returns the block's value.
*
*/
@@ -8069,7 +8255,7 @@ rb_io_s_sysopen(int argc, VALUE *argv, VALUE _)
else if (!NIL_P(intmode = rb_check_to_integer(vmode, "to_int")))
oflags = NUM2INT(intmode);
else {
- SafeStringValue(vmode);
+ StringValue(vmode);
oflags = rb_io_modestr_oflags(StringValueCStr(vmode));
}
if (NIL_P(vperm)) perm = 0666;
@@ -8080,40 +8266,12 @@ rb_io_s_sysopen(int argc, VALUE *argv, VALUE _)
return INT2NUM(fd);
}
-static VALUE
-check_pipe_command(VALUE filename_or_command)
-{
- char *s = RSTRING_PTR(filename_or_command);
- long l = RSTRING_LEN(filename_or_command);
- char *e = s + l;
- int chlen;
-
- if (rb_enc_ascget(s, e, &chlen, rb_enc_get(filename_or_command)) == '|') {
- VALUE cmd = rb_str_new(s+chlen, l-chlen);
- return cmd;
- }
- return Qnil;
-}
-
/*
* call-seq:
* open(path, mode = 'r', perm = 0666, **opts) -> io or nil
* open(path, mode = 'r', perm = 0666, **opts) {|io| ... } -> obj
*
- * Creates an IO object connected to the given stream, file, or subprocess.
- *
- * Required string argument +path+ determines which of the following occurs:
- *
- * - The file at the specified +path+ is opened.
- * - The process forks.
- * - A subprocess is created.
- *
- * Each of these is detailed below.
- *
- * <b>File Opened</b>
-
- * If +path+ does _not_ start with a pipe character (<tt>'|'</tt>),
- * a file stream is opened with <tt>File.open(path, mode, perm, **opts)</tt>.
+ * Creates an IO object connected to the given file.
*
* With no block given, file stream is returned:
*
@@ -8130,67 +8288,6 @@ check_pipe_command(VALUE filename_or_command)
*
* See File.open for details.
*
- * <b>Process Forked</b>
- *
- * If +path+ is the 2-character string <tt>'|-'</tt>, the process forks
- * and the child process is connected to the parent.
- *
- * With no block given:
- *
- * io = open('|-')
- * if io
- * $stderr.puts "In parent, child pid is #{io.pid}."
- * else
- * $stderr.puts "In child, pid is #{$$}."
- * end
- *
- * Output:
- *
- * In parent, child pid is 27903.
- * In child, pid is 27903.
- *
- * With a block given:
- *
- * open('|-') do |io|
- * if io
- * $stderr.puts "In parent, child pid is #{io.pid}."
- * else
- * $stderr.puts "In child, pid is #{$$}."
- * end
- * end
- *
- * Output:
- *
- * In parent, child pid is 28427.
- * In child, pid is 28427.
- *
- * <b>Subprocess Created</b>
- *
- * If +path+ is <tt>'|command'</tt> (<tt>'command' != '-'</tt>),
- * a new subprocess runs the command; its open stream is returned.
- * Note that the command may be processed by shell if it contains
- * shell metacharacters.
- *
- * With no block given:
- *
- * io = open('|echo "Hi!"') # => #<IO:fd 12>
- * print io.gets
- * io.close
- *
- * Output:
- *
- * "Hi!"
- *
- * With a block given, calls the block with the stream, then closes the stream:
- *
- * open('|echo "Hi!"') do |io|
- * print io.gets
- * end
- *
- * Output:
- *
- * "Hi!"
- *
*/
static VALUE
@@ -8211,11 +8308,7 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
redirect = TRUE;
}
else {
- VALUE cmd = check_pipe_command(tmp);
- if (!NIL_P(cmd)) {
- argv[0] = cmd;
- return rb_io_s_popen(argc, argv, rb_cIO);
- }
+ argv[0] = tmp;
}
}
}
@@ -8230,13 +8323,20 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
return rb_io_s_open(argc, argv, rb_cFile);
}
-static VALUE rb_io_open_generic(VALUE, VALUE, int, int, const convconfig_t *, mode_t);
+static VALUE
+rb_io_open_generic(VALUE klass, VALUE filename, int oflags, enum rb_io_mode fmode,
+ const struct rb_io_encoding *convconfig, mode_t perm)
+{
+ return rb_file_open_generic(io_alloc(klass), filename,
+ oflags, fmode, convconfig, perm);
+}
static VALUE
rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
{
- int oflags, fmode;
- convconfig_t convconfig;
+ int oflags;
+ enum rb_io_mode fmode;
+ struct rb_io_encoding convconfig;
mode_t perm;
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, &convconfig);
@@ -8245,20 +8345,6 @@ rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
}
static VALUE
-rb_io_open_generic(VALUE klass, VALUE filename, int oflags, int fmode,
- const convconfig_t *convconfig, mode_t perm)
-{
- VALUE cmd;
- if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
- return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
- }
- else {
- return rb_file_open_generic(io_alloc(klass), filename,
- oflags, fmode, convconfig, perm);
- }
-}
-
-static VALUE
io_reopen(VALUE io, VALUE nfile)
{
rb_io_t *fptr, *orig;
@@ -8270,7 +8356,7 @@ io_reopen(VALUE io, VALUE nfile)
GetOpenFile(nfile, orig);
if (fptr == orig) return io;
- if (IS_PREP_STDIO(fptr)) {
+ if (RUBY_IO_EXTERNAL_P(fptr)) {
if ((fptr->stdio_file == stdin && !(orig->mode & FMODE_READABLE)) ||
(fptr->stdio_file == stdout && !(orig->mode & FMODE_WRITABLE)) ||
(fptr->stdio_file == stderr && !(orig->mode & FMODE_WRITABLE))) {
@@ -8285,7 +8371,7 @@ io_reopen(VALUE io, VALUE nfile)
rb_sys_fail_on_write(fptr);
}
else {
- flush_before_seek(fptr);
+ flush_before_seek(fptr, true);
}
if (orig->mode & FMODE_READABLE) {
pos = io_tell(orig);
@@ -8296,17 +8382,22 @@ io_reopen(VALUE io, VALUE nfile)
}
/* copy rb_io_t structure */
- fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
+ fptr->mode = orig->mode | (fptr->mode & FMODE_EXTERNAL);
+ fptr->encs = orig->encs;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (RTEST(orig->pathv)) fptr->pathv = orig->pathv;
- else if (!IS_PREP_STDIO(fptr)) fptr->pathv = Qnil;
+ else if (!RUBY_IO_EXTERNAL_P(fptr)) fptr->pathv = Qnil;
fptr_copy_finalizer(fptr, orig);
fd = fptr->fd;
fd2 = orig->fd;
if (fd != fd2) {
- if (IS_PREP_STDIO(fptr) || fd <= 2 || !fptr->stdio_file) {
+ // Interrupt all usage of the old file descriptor:
+ rb_thread_io_close_interrupt(fptr);
+ rb_thread_io_close_wait(fptr);
+
+ if (RUBY_IO_EXTERNAL_P(fptr) || fd <= 2 || !fptr->stdio_file) {
/* need to keep FILE objects of stdin, stdout and stderr */
if (rb_cloexec_dup2(fd2, fd) < 0)
rb_sys_fail_path(orig->pathv);
@@ -8321,7 +8412,7 @@ io_reopen(VALUE io, VALUE nfile)
rb_update_max_fd(fd);
fptr->fd = fd;
}
- rb_thread_fd_close(fd);
+
if ((orig->mode & FMODE_READABLE) && pos >= 0) {
if (io_seek(fptr, pos, SEEK_SET) < 0 && errno) {
rb_sys_fail_path(fptr->pathv);
@@ -8410,11 +8501,11 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
}
if (!NIL_P(nmode) || !NIL_P(opt)) {
- int fmode;
- convconfig_t convconfig;
+ enum rb_io_mode fmode;
+ struct rb_io_encoding convconfig;
rb_io_extract_modeenc(&nmode, 0, opt, &oflags, &fmode, &convconfig);
- if (IS_PREP_STDIO(fptr) &&
+ if (RUBY_IO_EXTERNAL_P(fptr) &&
((fptr->mode & FMODE_READWRITE) & (fmode & FMODE_READWRITE)) !=
(fptr->mode & FMODE_READWRITE)) {
rb_raise(rb_eArgError,
@@ -8493,11 +8584,17 @@ rb_io_init_copy(VALUE dest, VALUE io)
rb_io_flush(io);
/* copy rb_io_t structure */
- fptr->mode = orig->mode & ~FMODE_PREP;
+ fptr->mode = orig->mode & ~FMODE_EXTERNAL;
fptr->encs = orig->encs;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
fptr->timeout = orig->timeout;
+
+ ccan_list_head_init(&fptr->blocking_operations);
+ fptr->closing_ec = NULL;
+ fptr->wakeup_mutex = Qnil;
+ fptr->fork_generation = GET_VM()->fork_gen;
+
if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv;
fptr_copy_finalizer(fptr, orig);
@@ -8527,7 +8624,7 @@ rb_io_init_copy(VALUE dest, VALUE io)
* Formats and writes +objects+ to the stream.
*
* For details on +format_string+, see
- * {Format Specifications}[rdoc-ref:format_specifications.rdoc].
+ * {Format Specifications}[rdoc-ref:language/format_specifications.rdoc].
*
*/
@@ -8548,7 +8645,7 @@ rb_io_printf(int argc, const VALUE *argv, VALUE out)
* io.write(sprintf(format_string, *objects))
*
* For details on +format_string+, see
- * {Format Specifications}[rdoc-ref:format_specifications.rdoc].
+ * {Format Specifications}[rdoc-ref:language/format_specifications.rdoc].
*
* With the single argument +format_string+, formats +objects+ into the string,
* then writes the formatted string to $stdout:
@@ -8591,12 +8688,19 @@ rb_f_printf(int argc, VALUE *argv, VALUE _)
return Qnil;
}
+extern void rb_deprecated_str_setter(VALUE val, ID id, VALUE *var);
+
static void
-deprecated_str_setter(VALUE val, ID id, VALUE *var)
+deprecated_rs_setter(VALUE val, ID id, VALUE *var)
{
- rb_str_setter(val, id, &val);
+ rb_deprecated_str_setter(val, id, &val);
if (!NIL_P(val)) {
- rb_warn_deprecated("`%s'", NULL, rb_id2name(id));
+ if (rb_str_equal(val, rb_default_rs)) {
+ val = rb_default_rs;
+ }
+ else {
+ val = rb_str_frozen_bare_string(val);
+ }
}
*var = val;
}
@@ -8857,9 +8961,9 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
*
* Treatment for each object:
*
- * - \String: writes the string.
+ * - String: writes the string.
* - Neither string nor array: writes <tt>object.to_s</tt>.
- * - \Array: writes each element of the array; arrays may be nested.
+ * - Array: writes each element of the array; arrays may be nested.
*
* To keep these examples brief, we define this helper method:
*
@@ -8892,7 +8996,6 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
VALUE
rb_io_puts(int argc, const VALUE *argv, VALUE out)
{
- int i, n;
VALUE line, args[2];
/* if no argument given, print newline. */
@@ -8900,22 +9003,30 @@ rb_io_puts(int argc, const VALUE *argv, VALUE out)
rb_io_write(out, rb_default_rs);
return Qnil;
}
- for (i=0; i<argc; i++) {
+ for (int i = 0; i < argc; i++) {
+ // Convert the argument to a string:
if (RB_TYPE_P(argv[i], T_STRING)) {
line = argv[i];
- goto string;
}
- if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
+ else if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
continue;
}
- line = rb_obj_as_string(argv[i]);
- string:
- n = 0;
- args[n++] = line;
- if (RSTRING_LEN(line) == 0 ||
- !rb_str_end_with_asciichar(line, '\n')) {
+ else {
+ line = rb_obj_as_string(argv[i]);
+ }
+
+ // Write the line:
+ int n = 0;
+ if (RSTRING_LEN(line) == 0) {
args[n++] = rb_default_rs;
}
+ else {
+ args[n++] = line;
+ if (!rb_str_end_with_asciichar(line, '\n')) {
+ args[n++] = rb_default_rs;
+ }
+ }
+
rb_io_writev(out, n, args);
}
@@ -9008,6 +9119,10 @@ rb_p_result(int argc, const VALUE *argv)
* 0..4
* [0..4, 0..4, 0..4]
*
+ * Kernel#p is designed for debugging purposes.
+ * Ruby implementations may define Kernel#p to be uninterruptible
+ * in whole or in part.
+ * On CRuby, Kernel#p's writing of data is uninterruptible.
*/
static VALUE
@@ -9161,26 +9276,99 @@ stderr_getter(ID id, VALUE *ptr)
}
static VALUE
-prep_io(int fd, int fmode, VALUE klass, const char *path)
+allocate_and_open_new_file(VALUE klass)
{
- rb_io_t *fp;
- VALUE io = io_alloc(klass);
+ VALUE self = io_alloc(klass);
+ rb_io_make_open_file(self);
+ return self;
+}
- MakeOpenFile(io, fp);
- fp->self = io;
- fp->fd = fd;
- fp->mode = fmode;
- fp->timeout = Qnil;
- if (!io_check_tty(fp)) {
+VALUE
+rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding)
+{
+ int state;
+ VALUE self = rb_protect(allocate_and_open_new_file, klass, &state);
+ if (state) {
+ /* if we raised an exception allocating an IO object, but the caller
+ intended to transfer ownership of this FD to us, close the fd before
+ raising the exception. Otherwise, we would leak a FD - the caller
+ expects GC to close the file, but we never got around to assigning
+ it to a rb_io. */
+ if (!(mode & FMODE_EXTERNAL)) {
+ maygvl_close(descriptor, 0);
+ }
+ rb_jump_tag(state);
+ }
+
+
+ rb_io_t *io = RFILE(self)->fptr;
+ io->self = self;
+ io->fd = descriptor;
+ io->mode = mode;
+
+ /* At this point, Ruby fully owns the descriptor, and will close it when
+ the IO gets GC'd (unless FMODE_EXTERNAL was set), no matter what happens
+ in the rest of this method. */
+
+ if (NIL_P(path)) {
+ io->pathv = Qnil;
+ }
+ else {
+ StringValue(path);
+ io->pathv = rb_str_new_frozen(path);
+ }
+
+ io->timeout = timeout;
+
+ ccan_list_head_init(&io->blocking_operations);
+ io->closing_ec = NULL;
+ io->wakeup_mutex = Qnil;
+ io->fork_generation = GET_VM()->fork_gen;
+
+ if (encoding) {
+ io->encs = *encoding;
+ }
+
+ rb_update_max_fd(descriptor);
+
+ return self;
+}
+
+static VALUE
+prep_io(int fd, enum rb_io_mode fmode, VALUE klass, const char *path)
+{
+ VALUE path_value = Qnil;
+ rb_encoding *e;
+ struct rb_io_encoding convconfig;
+
+ if (path) {
+ path_value = rb_obj_freeze(rb_str_new_cstr(path));
+ }
+
+ e = (fmode & FMODE_BINMODE) ? rb_ascii8bit_encoding() : NULL;
+ rb_io_ext_int_to_encs(e, NULL, &convconfig.enc, &convconfig.enc2, fmode);
+ convconfig.ecflags = (fmode & FMODE_READABLE) ?
+ MODE_BTMODE(ECONV_DEFAULT_NEWLINE_DECORATOR,
+ 0, ECONV_UNIVERSAL_NEWLINE_DECORATOR) : 0;
+#ifdef TEXTMODE_NEWLINE_DECORATOR_ON_WRITE
+ convconfig.ecflags |= (fmode & FMODE_WRITABLE) ?
+ MODE_BTMODE(TEXTMODE_NEWLINE_DECORATOR_ON_WRITE,
+ 0, TEXTMODE_NEWLINE_DECORATOR_ON_WRITE) : 0;
+#endif
+ SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(convconfig.enc2, convconfig.ecflags);
+ convconfig.ecopts = Qnil;
+
+ VALUE self = rb_io_open_descriptor(klass, fd, fmode, path_value, Qnil, &convconfig);
+ rb_io_t*io = RFILE(self)->fptr;
+
+ if (!io_check_tty(io)) {
#ifdef __CYGWIN__
- fp->mode |= FMODE_BINMODE;
+ io->mode |= FMODE_BINMODE;
setmode(fd, O_BINARY);
#endif
}
- if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path));
- rb_update_max_fd(fd);
- return io;
+ return self;
}
VALUE
@@ -9193,10 +9381,10 @@ rb_io_fdopen(int fd, int oflags, const char *path)
}
static VALUE
-prep_stdio(FILE *f, int fmode, VALUE klass, const char *path)
+prep_stdio(FILE *f, enum rb_io_mode fmode, VALUE klass, const char *path)
{
rb_io_t *fptr;
- VALUE io = prep_io(fileno(f), fmode|FMODE_PREP|DEFAULT_TEXTMODE, klass, path);
+ VALUE io = prep_io(fileno(f), fmode|FMODE_EXTERNAL|DEFAULT_TEXTMODE, klass, path);
GetOpenFile(io, fptr);
fptr->encs.ecflags |= ECONV_DEFAULT_NEWLINE_DECORATOR;
@@ -9240,7 +9428,7 @@ rb_io_stdio_file(rb_io_t *fptr)
}
static inline void
-rb_io_buffer_init(rb_io_buffer_t *buf)
+rb_io_buffer_init(struct rb_io_internal_buffer *buf)
{
buf->ptr = NULL;
buf->off = 0;
@@ -9276,6 +9464,10 @@ rb_io_fptr_new(void)
fp->encs.ecopts = Qnil;
fp->write_lock = Qnil;
fp->timeout = Qnil;
+ ccan_list_head_init(&fp->blocking_operations);
+ fp->closing_ec = NULL;
+ fp->wakeup_mutex = Qnil;
+ fp->fork_generation = GET_VM()->fork_gen;
return fp;
}
@@ -9296,6 +9488,8 @@ rb_io_make_open_file(VALUE obj)
return fp;
}
+static VALUE io_initialize(VALUE io, VALUE fnum, VALUE vmode, VALUE opt);
+
/*
* call-seq:
* IO.new(fd, mode = 'r', **opts) -> io
@@ -9315,7 +9509,8 @@ rb_io_make_open_file(VALUE obj)
* The new \IO object does not inherit encoding
* (because the integer file descriptor does not have an encoding):
*
- * fd = IO.sysopen('t.rus', 'rb')
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * fd = IO.sysopen('t.ja', 'rb')
* io = IO.new(fd)
* io.external_encoding # => #<Encoding:UTF-8> # Not ASCII-8BIT.
*
@@ -9341,18 +9536,25 @@ static VALUE
rb_io_initialize(int argc, VALUE *argv, VALUE io)
{
VALUE fnum, vmode;
- rb_io_t *fp;
- int fd, fmode, oflags = O_RDONLY;
- convconfig_t convconfig;
VALUE opt;
+
+ rb_scan_args(argc, argv, "11:", &fnum, &vmode, &opt);
+ return io_initialize(io, fnum, vmode, opt);
+}
+
+static VALUE
+io_initialize(VALUE io, VALUE fnum, VALUE vmode, VALUE opt)
+{
+ rb_io_t *fp;
+ int fd, oflags = O_RDONLY;
+ enum rb_io_mode fmode;
+ struct rb_io_encoding convconfig;
#if defined(HAVE_FCNTL) && defined(F_GETFL)
int ofmode;
#else
struct stat st;
#endif
-
- argc = rb_scan_args(argc, argv, "11:", &fnum, &vmode, &opt);
rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &fmode, &convconfig);
fd = NUM2INT(fnum);
@@ -9380,7 +9582,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
if (!NIL_P(opt)) {
if (rb_hash_aref(opt, sym_autoclose) == Qfalse) {
- fmode |= FMODE_PREP;
+ fmode |= FMODE_EXTERNAL;
}
path = rb_hash_aref(opt, RB_ID2SYM(idPath));
@@ -9397,6 +9599,10 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
fp->encs = convconfig;
fp->pathv = path;
fp->timeout = Qnil;
+ ccan_list_head_init(&fp->blocking_operations);
+ fp->closing_ec = NULL;
+ fp->wakeup_mutex = Qnil;
+ fp->fork_generation = GET_VM()->fork_gen;
clear_codeconv(fp);
io_check_tty(fp);
if (fileno(stdin) == fd)
@@ -9459,9 +9665,9 @@ rb_io_set_encoding_by_bom(VALUE io)
* File.new(path, mode = 'r', perm = 0666, **opts) -> file
*
* Opens the file at the given +path+ according to the given +mode+;
- * creates and returns a new \File object for that file.
+ * creates and returns a new File object for that file.
*
- * The new \File object is buffered mode (or non-sync mode), unless
+ * The new File object is buffered mode (or non-sync mode), unless
* +filename+ is a tty.
* See IO#flush, IO#fsync, IO#fdatasync, and IO#sync=.
*
@@ -9501,17 +9707,16 @@ rb_file_initialize(int argc, VALUE *argv, VALUE io)
if (RFILE(io)->fptr) {
rb_raise(rb_eRuntimeError, "reinitializing File");
}
- if (0 < argc && argc < 3) {
- VALUE fd = rb_check_to_int(argv[0]);
+ VALUE fname, vmode, vperm, opt;
+ int posargc = rb_scan_args(argc, argv, "12:", &fname, &vmode, &vperm, &opt);
+ if (posargc < 3) { /* perm is File only */
+ VALUE fd = rb_check_to_int(fname);
if (!NIL_P(fd)) {
- argv[0] = fd;
- return rb_io_initialize(argc, argv, io);
+ return io_initialize(io, fd, vmode, opt);
}
}
- rb_open_file(argc, argv, io);
-
- return io;
+ return rb_open_file(io, fname, vmode, vperm, opt);
}
/* :nodoc: */
@@ -9557,7 +9762,7 @@ rb_io_autoclose_p(VALUE io)
{
rb_io_t *fptr = RFILE(io)->fptr;
rb_io_check_closed(fptr);
- return RBOOL(!(fptr->mode & FMODE_PREP));
+ return RBOOL(!(fptr->mode & FMODE_EXTERNAL));
}
/*
@@ -9566,11 +9771,11 @@ rb_io_autoclose_p(VALUE io)
*
* Sets auto-close flag.
*
- * f = open("/dev/null")
+ * f = File.open(File::NULL)
* IO.for_fd(f.fileno).close
* f.gets # raises Errno::EBADF
*
- * f = open("/dev/null")
+ * f = File.open(File::NULL)
* g = IO.for_fd(f.fileno)
* g.autoclose = false
* g.close
@@ -9583,9 +9788,9 @@ rb_io_set_autoclose(VALUE io, VALUE autoclose)
rb_io_t *fptr;
GetOpenFile(io, fptr);
if (!RTEST(autoclose))
- fptr->mode |= FMODE_PREP;
+ fptr->mode |= FMODE_EXTERNAL;
else
- fptr->mode &= ~FMODE_PREP;
+ fptr->mode &= ~FMODE_EXTERNAL;
return autoclose;
}
@@ -9627,7 +9832,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr;
RB_IO_POINTER(io, fptr);
- rb_io_check_readable(fptr);
+ rb_io_check_char_readable(fptr);
if (rb_io_read_pending(fptr)) return Qtrue;
@@ -9674,7 +9879,7 @@ io_wait_priority(int argc, VALUE *argv, VALUE io)
rb_io_t *fptr = NULL;
RB_IO_POINTER(io, fptr);
- rb_io_check_readable(fptr);
+ rb_io_check_char_readable(fptr);
if (rb_io_read_pending(fptr)) return Qtrue;
@@ -9718,7 +9923,7 @@ wait_mode_sym(VALUE mode)
rb_raise(rb_eArgError, "unsupported mode: %"PRIsVALUE, mode);
}
-static inline rb_io_event_t
+static inline enum rb_io_event
io_event_from_value(VALUE value)
{
int events = RB_NUM2INT(value);
@@ -9731,7 +9936,7 @@ io_event_from_value(VALUE value)
/*
* call-seq:
* io.wait(events, timeout) -> event mask, false or nil
- * io.wait(timeout = nil, mode = :read) -> self, true, or false
+ * io.wait(*event_symbols[, timeout]) -> self, true, or false
*
* Waits until the IO becomes ready for the specified events and returns the
* subset of events that become ready, or a falsy value when times out.
@@ -9739,23 +9944,23 @@ io_event_from_value(VALUE value)
* The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or
* +IO::PRIORITY+.
*
- * Returns an event mask (truthy value) immediately when buffered data is available.
+ * Returns an event mask (truthy value) immediately when buffered data is
+ * available.
*
- * Optional parameter +mode+ is one of +:read+, +:write+, or
- * +:read_write+.
+ * The second form: if one or more event symbols (+:read+, +:write+, or
+ * +:read_write+) are passed, the event mask is the bit OR of the bitmask
+ * corresponding to those symbols. In this form, +timeout+ is optional, the
+ * order of the arguments is arbitrary, and returns +io+ if any of the
+ * events is ready.
*/
static VALUE
io_wait(int argc, VALUE *argv, VALUE io)
{
VALUE timeout = Qundef;
- rb_io_event_t events = 0;
+ enum rb_io_event events = 0;
int return_io = 0;
- // The documented signature for this method is actually incorrect.
- // A single timeout is allowed in any position, and multiple symbols can be given.
- // Whether this is intentional or not, I don't know, and as such I consider this to
- // be a legacy/slow path.
if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) {
// We'd prefer to return the actual mask, but this form would return the io itself:
return_io = 1;
@@ -9801,14 +10006,14 @@ io_wait(int argc, VALUE *argv, VALUE io)
}
static void
-argf_mark(void *ptr)
+argf_mark_and_move(void *ptr)
{
struct argf *p = ptr;
- rb_gc_mark(p->filename);
- rb_gc_mark(p->current_file);
- rb_gc_mark(p->argv);
- rb_gc_mark(p->inplace);
- rb_gc_mark(p->encs.ecopts);
+ rb_gc_mark_and_move(&p->filename);
+ rb_gc_mark_and_move(&p->current_file);
+ rb_gc_mark_and_move(&p->argv);
+ rb_gc_mark_and_move(&p->inplace);
+ rb_gc_mark_and_move(&p->encs.ecopts);
}
static size_t
@@ -9821,17 +10026,17 @@ argf_memsize(const void *ptr)
static const rb_data_type_t argf_type = {
"ARGF",
- {argf_mark, RUBY_TYPED_DEFAULT_FREE, argf_memsize},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ {argf_mark_and_move, RUBY_TYPED_DEFAULT_FREE, argf_memsize, argf_mark_and_move},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static inline void
-argf_init(struct argf *p, VALUE v)
+argf_init(VALUE argf, struct argf *p, VALUE v)
{
p->filename = Qnil;
p->current_file = Qnil;
p->lineno = 0;
- p->argv = v;
+ RB_OBJ_WRITE(argf, &p->argv, v);
}
static VALUE
@@ -9840,7 +10045,7 @@ argf_alloc(VALUE klass)
struct argf *p;
VALUE argf = TypedData_Make_Struct(klass, struct argf, &argf_type, p);
- argf_init(p, Qnil);
+ argf_init(argf, p, Qnil);
return argf;
}
@@ -9851,7 +10056,7 @@ static VALUE
argf_initialize(VALUE argf, VALUE argv)
{
memset(&ARGF, 0, sizeof(ARGF));
- argf_init(&ARGF, argv);
+ argf_init(argf, &ARGF, argv);
return argf;
}
@@ -9862,7 +10067,8 @@ argf_initialize_copy(VALUE argf, VALUE orig)
{
if (!OBJ_INIT_COPY(argf, orig)) return argf;
ARGF = argf_of(orig);
- ARGF.argv = rb_obj_dup(ARGF.argv);
+ rb_gc_writebarrier_remember(argf);
+ ARGF_SET(argv, rb_obj_dup(ARGF.argv));
return argf;
}
@@ -9947,7 +10153,7 @@ argf_next_argv(VALUE argf)
char *fn;
rb_io_t *fptr;
int stdout_binmode = 0;
- int fmode;
+ enum rb_io_mode fmode;
VALUE r_stdout = rb_ractor_stdout();
@@ -9981,11 +10187,11 @@ argf_next_argv(VALUE argf)
if (RARRAY_LEN(ARGF.argv) > 0) {
VALUE filename = rb_ary_shift(ARGF.argv);
FilePathValue(filename);
- ARGF.filename = filename;
+ ARGF_SET(filename, filename);
filename = rb_str_encode_ospath(filename);
fn = StringValueCStr(filename);
if (RSTRING_LEN(filename) == 1 && fn[0] == '-') {
- ARGF.current_file = rb_stdin;
+ ARGF_SET(current_file, rb_stdin);
if (ARGF.inplace) {
rb_warn("Can't do inplace edit for stdio; skipping");
goto retry;
@@ -10080,7 +10286,7 @@ argf_next_argv(VALUE argf)
if (!ARGF.binmode) {
fmode |= DEFAULT_TEXTMODE;
}
- ARGF.current_file = prep_io(fr, fmode, rb_cFile, fn);
+ ARGF_SET(current_file, prep_io(fr, fmode, rb_cFile, fn));
if (!NIL_P(write_io)) {
rb_io_set_write_io(ARGF.current_file, write_io);
}
@@ -10109,8 +10315,8 @@ argf_next_argv(VALUE argf)
}
}
else if (ARGF.next_p == -1) {
- ARGF.current_file = rb_stdin;
- ARGF.filename = rb_str_new2("-");
+ ARGF_SET(current_file, rb_stdin);
+ ARGF_SET(filename, rb_str_new2("-"));
if (ARGF.inplace) {
rb_warn("Can't do inplace edit for stdio");
rb_ractor_stdout_set(orig_stdout);
@@ -10378,8 +10584,9 @@ static VALUE argf_readlines(int, VALUE *, VALUE);
* $cat t.txt | ruby -e "p readlines 12"
* ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
*
- * With arguments +sep+ and +limit+ given, combines the two behaviors;
- * see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit].
+ * With arguments +sep+ and +limit+ given,
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword argument +chomp+ specifies whether line separators
* are to be omitted:
@@ -10403,19 +10610,21 @@ rb_f_readlines(int argc, VALUE *argv, VALUE recv)
/*
* call-seq:
- * ARGF.readlines(sep = $/) -> array
- * ARGF.readlines(limit) -> array
- * ARGF.readlines(sep, limit) -> array
+ * ARGF.readlines(sep = $/, chomp: false) -> array
+ * ARGF.readlines(limit, chomp: false) -> array
+ * ARGF.readlines(sep, limit, chomp: false) -> array
*
- * ARGF.to_a(sep = $/) -> array
- * ARGF.to_a(limit) -> array
- * ARGF.to_a(sep, limit) -> array
+ * ARGF.to_a(sep = $/, chomp: false) -> array
+ * ARGF.to_a(limit, chomp: false) -> array
+ * ARGF.to_a(sep, limit, chomp: false) -> array
*
* Reads each file in ARGF in its entirety, returning an Array containing
* lines from the files. Lines are assumed to be separated by _sep_.
*
* lines = ARGF.readlines
* lines[0] #=> "This is line one\n"
+ *
+ * See +IO.readlines+ for a full description of all options.
*/
static VALUE
argf_readlines(int argc, VALUE *argv, VALUE argf)
@@ -10449,14 +10658,14 @@ argf_readlines(int argc, VALUE *argv, VALUE argf)
* sets global variable <tt>$?</tt> to the process status.
*
* This method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
+ * see {Command Injection}[rdoc-ref:security/command_injection.rdoc].
*
* Examples:
*
* $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
* $ `echo oops && exit 99` # => "oops\n"
* $ $? # => #<Process::Status: pid 17088 exit 99>
- * $ $?.status # => 99>
+ * $ $?.exitstatus # => 99
*
* The built-in syntax <tt>%x{...}</tt> uses this method.
*
@@ -10469,7 +10678,7 @@ rb_f_backquote(VALUE obj, VALUE str)
VALUE result;
rb_io_t *fptr;
- SafeStringValue(str);
+ StringValue(str);
rb_last_status_clear();
port = pipe_open_s(str, "r", FMODE_READABLE|DEFAULT_TEXTMODE, NULL);
if (NIL_P(port)) return rb_str_new(0,0);
@@ -10477,8 +10686,7 @@ rb_f_backquote(VALUE obj, VALUE str)
GetOpenFile(port, fptr);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
- RFILE(port)->fptr = NULL;
- rb_io_fptr_finalize(fptr);
+ rb_io_fptr_cleanup_all(fptr);
RB_GC_GUARD(port);
return result;
@@ -10561,9 +10769,9 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
if (!pending && n == 0) return Qnil; /* returns nil on timeout */
res = rb_ary_new2(3);
- rb_ary_push(res, rp?rb_ary_new():rb_ary_new2(0));
- rb_ary_push(res, wp?rb_ary_new():rb_ary_new2(0));
- rb_ary_push(res, ep?rb_ary_new():rb_ary_new2(0));
+ rb_ary_push(res, rp ? rb_ary_new_capa(RARRAY_LEN(read)) : rb_ary_new());
+ rb_ary_push(res, wp ? rb_ary_new_capa(RARRAY_LEN(write)) : rb_ary_new());
+ rb_ary_push(res, ep ? rb_ary_new_capa(RARRAY_LEN(except)) : rb_ary_new());
if (rp) {
list = RARRAY_AREF(res, 0);
@@ -10713,7 +10921,7 @@ do_io_advise(rb_io_t *fptr, VALUE advice, rb_off_t offset, rb_off_t len)
ias.offset = offset;
ias.len = len;
- rv = (int)rb_thread_io_blocking_region(io_advise_internal, &ias, fptr->fd);
+ rv = (int)rb_io_blocking_region(fptr, io_advise_internal, &ias);
if (rv && rv != ENOSYS) {
/* posix_fadvise(2) doesn't set errno. On success it returns 0; otherwise
it returns the error code. */
@@ -10751,7 +10959,7 @@ advice_arg_check(VALUE advice)
* advise(advice, offset = 0, len = 0) -> nil
*
* Invokes Posix system call
- * {posix_fadvise(2)}[https://linux.die.net/man/2/posix_fadvise],
+ * {posix_fadvise(2)}[https://man7.org/linux/man-pages/man2/posix_fadvise.2.html],
* which announces an intention to access data from the current file
* in a particular manner.
*
@@ -10803,11 +11011,21 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
#endif
}
+static int
+is_pos_inf(VALUE x)
+{
+ double f;
+ if (!RB_FLOAT_TYPE_P(x))
+ return 0;
+ f = RFLOAT_VALUE(x);
+ return isinf(f) && 0 < f;
+}
+
/*
* call-seq:
* IO.select(read_ios, write_ios = [], error_ios = [], timeout = nil) -> array or nil
*
- * Invokes system call {select(2)}[https://linux.die.net/man/2/select],
+ * Invokes system call {select(2)}[https://man7.org/linux/man-pages/man2/select.2.html],
* which monitors multiple file descriptors,
* waiting until one or more of the file descriptors
* becomes ready for some class of I/O operation.
@@ -10817,7 +11035,10 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* Each of the arguments +read_ios+, +write_ios+, and +error_ios+
* is an array of IO objects.
*
- * Argument +timeout+ is an integer timeout interval in seconds.
+ * Argument +timeout+ is a numeric value (such as integer or float) timeout
+ * interval in seconds.
+ * +timeout+ can also be +nil+ or +Float::INFINITY+.
+ * +nil+ and +Float::INFINITY+ means no timeout.
*
* The method monitors the \IO objects given in all three arrays,
* waiting for some to be ready;
@@ -10891,7 +11112,7 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* Finally, Linux kernel developers don't guarantee that
* readability of select(2) means readability of following read(2) even
* for a single process;
- * see {select(2)}[https://linux.die.net/man/2/select]
+ * see {select(2)}[https://man7.org/linux/man-pages/man2/select.2.html]
*
* Invoking \IO.select before IO#readpartial works well as usual.
* However it is not the best way to use \IO.select.
@@ -10968,7 +11189,7 @@ rb_f_select(int argc, VALUE *argv, VALUE obj)
int i;
rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout);
- if (NIL_P(timeout)) {
+ if (NIL_P(timeout) || is_pos_inf(timeout)) {
args.timeout = 0;
}
else {
@@ -11005,16 +11226,16 @@ nogvl_ioctl(void *ptr)
}
static int
-do_ioctl(int fd, ioctl_req_t cmd, long narg)
+do_ioctl(struct rb_io *io, ioctl_req_t cmd, long narg)
{
int retval;
struct ioctl_arg arg;
- arg.fd = fd;
+ arg.fd = io->fd;
arg.cmd = cmd;
arg.narg = narg;
- retval = (int)rb_thread_io_blocking_region(nogvl_ioctl, &arg, fd);
+ retval = (int)rb_io_blocking_region(io, nogvl_ioctl, &arg);
return retval;
}
@@ -11277,7 +11498,7 @@ rb_ioctl(VALUE io, VALUE req, VALUE arg)
narg = setup_narg(cmd, &arg, ioctl_narg_len);
GetOpenFile(io, fptr);
- retval = do_ioctl(fptr->fd, cmd, narg);
+ retval = do_ioctl(fptr, cmd, narg);
return finish_narg(retval, arg, fptr);
}
@@ -11285,7 +11506,7 @@ rb_ioctl(VALUE io, VALUE req, VALUE arg)
* call-seq:
* ioctl(integer_cmd, argument) -> integer
*
- * Invokes Posix system call {ioctl(2)}[https://linux.die.net/man/2/ioctl],
+ * Invokes Posix system call {ioctl(2)}[https://man7.org/linux/man-pages/man2/ioctl.2.html],
* which issues a low-level command to an I/O device.
*
* Issues a low-level command to an I/O device.
@@ -11331,16 +11552,16 @@ nogvl_fcntl(void *ptr)
}
static int
-do_fcntl(int fd, int cmd, long narg)
+do_fcntl(struct rb_io *io, int cmd, long narg)
{
int retval;
struct fcntl_arg arg;
- arg.fd = fd;
+ arg.fd = io->fd;
arg.cmd = cmd;
arg.narg = narg;
- retval = (int)rb_thread_io_blocking_region(nogvl_fcntl, &arg, fd);
+ retval = (int)rb_io_blocking_region(io, nogvl_fcntl, &arg);
if (retval != -1) {
switch (cmd) {
#if defined(F_DUPFD)
@@ -11366,7 +11587,7 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
narg = setup_narg(cmd, &arg, fcntl_narg_len);
GetOpenFile(io, fptr);
- retval = do_fcntl(fptr->fd, cmd, narg);
+ retval = do_fcntl(fptr, cmd, narg);
return finish_narg(retval, arg, fptr);
}
@@ -11374,12 +11595,12 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
* call-seq:
* fcntl(integer_cmd, argument) -> integer
*
- * Invokes Posix system call {fcntl(2)}[https://linux.die.net/man/2/fcntl],
+ * Invokes Posix system call {fcntl(2)}[https://man7.org/linux/man-pages/man2/fcntl.2.html],
* which provides a mechanism for issuing low-level commands to control or query
* a file-oriented I/O stream. Arguments and results are platform
* dependent.
*
- * If +argument is a number, its value is passed directly;
+ * If +argument+ is a number, its value is passed directly;
* if it is a string, it is interpreted as a binary sequence of bytes.
* (Array#pack might be a useful way to build this string.)
*
@@ -11404,7 +11625,7 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io)
* call-seq:
* syscall(integer_callno, *arguments) -> integer
*
- * Invokes Posix system call {syscall(2)}[https://linux.die.net/man/2/syscall],
+ * Invokes Posix system call {syscall(2)}[https://man7.org/linux/man-pages/man2/syscall.2.html],
* which calls a specified function.
*
* Calls the operating system function identified by +integer_callno+;
@@ -11476,7 +11697,7 @@ rb_f_syscall(int argc, VALUE *argv, VALUE _)
VALUE v = rb_check_string_type(argv[i]);
if (!NIL_P(v)) {
- SafeStringValue(v);
+ StringValue(v);
rb_str_modify(v);
arg[i] = (VALUE)StringValueCStr(v);
}
@@ -11632,9 +11853,9 @@ pipe_pair_close(VALUE rw)
* IO.pipe(**opts) -> [read_io, write_io]
* IO.pipe(enc, **opts) -> [read_io, write_io]
* IO.pipe(ext_enc, int_enc, **opts) -> [read_io, write_io]
- * IO.pipe(**opts) {|read_io, write_io] ...} -> object
- * IO.pipe(enc, **opts) {|read_io, write_io] ...} -> object
- * IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io] ...} -> object
+ * IO.pipe(**opts) {|read_io, write_io| ...} -> object
+ * IO.pipe(enc, **opts) {|read_io, write_io| ...} -> object
+ * IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io| ...} -> object
*
* Creates a pair of pipe endpoints, +read_io+ and +write_io+,
* connected to each other.
@@ -11714,7 +11935,7 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
VALUE opt;
rb_io_t *fptr, *fptr2;
struct io_encoding_set_args ies_args;
- int fmode = 0;
+ enum rb_io_mode fmode = 0;
VALUE ret;
argc = rb_scan_args(argc, argv, "02:", &v1, &v2, &opt);
@@ -11845,27 +12066,11 @@ io_s_foreach(VALUE v)
* IO.foreach(path, sep = $/, **opts) {|line| block } -> nil
* IO.foreach(path, limit, **opts) {|line| block } -> nil
* IO.foreach(path, sep, limit, **opts) {|line| block } -> nil
- * IO.foreach(command, sep = $/, **opts) {|line| block } -> nil
- * IO.foreach(command, limit, **opts) {|line| block } -> nil
- * IO.foreach(command, sep, limit, **opts) {|line| block } -> nil
* IO.foreach(...) -> an_enumerator
*
* Calls the block with each successive line read from the stream.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
- * The first argument must be a string that is one of the following:
- *
- * - Path: if +self+ is a subclass of \IO (\File, for example),
- * or if the string _does_ _not_ start with the pipe character (<tt>'|'</tt>),
- * the string is the path to a file.
- * - Command: if +self+ is the class \IO,
- * and if the string starts with the pipe character,
- * the rest of the string is a command to be executed as a subprocess.
- * This usage has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, parses lines from the file at the given +path+,
* as determined by the default line separator,
@@ -11901,7 +12106,7 @@ io_s_foreach(VALUE v)
*
* With argument +limit+ given, parses lines as determined by the default
* line separator and the given line-length limit
- * (see {Line Limit}[rdoc-ref:IO@Line+Limit]):
+ * (see {Line Separator}[rdoc-ref:IO@Line+Separator] and {Line Limit}[rdoc-ref:IO@Line+Limit]):
*
* File.foreach('t.txt', 7) {|line| p line }
*
@@ -11917,16 +12122,15 @@ io_s_foreach(VALUE v)
* "Fourth l"
* "line\n"
*
- * With arguments +sep+ and +limit+ given,
- * parses lines as determined by the given
- * line separator and the given line-length limit
- * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]):
+ * With arguments +sep+ and +limit+ given,
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword arguments +opts+ specify:
*
* - {Open Options}[rdoc-ref:IO@Open+Options].
* - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
- * - {Line Options}[rdoc-ref:IO@Line+Options].
+ * - {Line Options}[rdoc-ref:IO@Line+IO].
*
* Returns an Enumerator if no block is given.
*
@@ -11959,32 +12163,13 @@ io_s_readlines(VALUE v)
/*
* call-seq:
- * IO.readlines(command, sep = $/, **opts) -> array
- * IO.readlines(command, limit, **opts) -> array
- * IO.readlines(command, sep, limit, **opts) -> array
* IO.readlines(path, sep = $/, **opts) -> array
* IO.readlines(path, limit, **opts) -> array
* IO.readlines(path, sep, limit, **opts) -> array
*
* Returns an array of all lines read from the stream.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
- *
- * With only argument +command+ given, executes the command in a shell,
- * parses its $stdout into lines, as determined by the default line separator,
- * and returns those lines in an array:
- *
- * IO.readlines('| cat t.txt')
- * # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, parses lines from the file at the given +path+,
* as determined by the default line separator,
@@ -11993,8 +12178,6 @@ io_s_readlines(VALUE v)
* IO.readlines('t.txt')
* # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
*
- * For both forms, command and path, the remaining arguments are the same.
- *
* With argument +sep+ given, parses lines as determined by that line separator
* (see {Line Separator}[rdoc-ref:IO@Line+Separator]):
*
@@ -12010,21 +12193,20 @@ io_s_readlines(VALUE v)
*
* With argument +limit+ given, parses lines as determined by the default
* line separator and the given line-length limit
- * (see {Line Limit}[rdoc-ref:IO@Line+Limit]):
+ * (see {Line Separator}[rdoc-ref:IO@Line+Separator] and {Line Limit}[rdoc-ref:IO@Line+Limit]:
*
* IO.readlines('t.txt', 7)
* # => ["First l", "ine\n", "Second ", "line\n", "\n", "Third l", "ine\n", "Fourth ", "line\n"]
*
- * With arguments +sep+ and +limit+ given,
- * parses lines as determined by the given
- * line separator and the given line-length limit
- * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]):
+ * With arguments +sep+ and +limit+ given,
+ * combines the two behaviors
+ * (see {Line Separator and Line Limit}[rdoc-ref:IO@Line+Separator+and+Line+Limit]).
*
* Optional keyword arguments +opts+ specify:
*
* - {Open Options}[rdoc-ref:IO@Open+Options].
* - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
- * - {Line Options}[rdoc-ref:IO@Line+Options].
+ * - {Line Options}[rdoc-ref:IO@Line+IO].
*
*/
@@ -12067,52 +12249,59 @@ seek_before_access(VALUE argp)
/*
* call-seq:
- * IO.read(command, length = nil, offset = 0, **opts) -> string or nil
* IO.read(path, length = nil, offset = 0, **opts) -> string or nil
*
* Opens the stream, reads and returns some or all of its content,
* and closes the stream; returns +nil+ if no bytes were read.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
- *
- * With only argument +command+ given, executes the command in a shell,
- * returns its entire $stdout:
- *
- * IO.read('| cat t.txt')
- * # => "First line\nSecond line\n\nThird line\nFourth line\n"
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, reads in text mode and returns the entire content
* of the file at the given path:
*
- * IO.read('t.txt')
- * # => "First line\nSecond line\n\nThird line\nFourth line\n"
+ * File.read('t.txt')
+ * # => "First line\nSecond line\n\nFourth line\nFifth line\n"
+ * File.read('t.ja')
+ * # => "ã“ã‚“ã«ã¡ã¯"
+ * File.read('t.dat')
+ * # => "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
*
* On Windows, text mode can terminate reading and leave bytes in the file
* unread when encountering certain special bytes. Consider using
* IO.binread if all bytes in the file should be read.
*
- * For both forms, command and path, the remaining arguments are the same.
- *
* With argument +length+, returns +length+ bytes if available:
*
- * IO.read('t.txt', 7) # => "First l"
- * IO.read('t.txt', 700)
+ * File.read('t.txt', 7)
+ * # => "First l"
+ * File.read('t.ja', 7)
+ * # => "\xE3\x81\x93\xE3\x82\x93\xE3"
+ * File.read('t.dat', 7)
+ * # => "\xFE\xFF\x99\x90\x99\x91\x99"
+ *
+ * Returns all bytes if +length+ is larger than the files size:
+ *
+ * File.read('t.txt', 700)
* # => "First line\r\nSecond line\r\n\r\nFourth line\r\nFifth line\r\n"
+ * File.read('t.ja', 700)
+ * # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ * File.read('t.dat', 700)
+ * # => "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
*
* With arguments +length+ and +offset+, returns +length+ bytes
* if available, beginning at the given +offset+:
*
- * IO.read('t.txt', 10, 2) # => "rst line\nS"
- * IO.read('t.txt', 10, 200) # => nil
+ * File.read('t.txt', 10, 2)
+ * # => "rst line\r\n"
+ * File.read('t.ja', 10, 2)
+ * # => "\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1"
+ * File.read('t.dat', 10, 2)
+ * # => "\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
+ *
+ * Returns +nil+ if +offset+ is past the end of the stream:
+ *
+ * File.read('t.txt', 10, 200)
+ * # => nil
*
* Optional keyword arguments +opts+ specify:
*
@@ -12125,9 +12314,13 @@ static VALUE
rb_io_s_read(int argc, VALUE *argv, VALUE io)
{
VALUE opt, offset;
+ long off;
struct foreach_arg arg;
argc = rb_scan_args(argc, argv, "13:", NULL, NULL, &offset, NULL, &opt);
+ if (!NIL_P(offset) && (off = NUM2LONG(offset)) < 0) {
+ rb_raise(rb_eArgError, "negative offset %ld given", off);
+ }
open_key_args(io, argc, argv, opt, &arg);
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
@@ -12148,16 +12341,11 @@ rb_io_s_read(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * IO.binread(command, length = nil, offset = 0) -> string or nil
* IO.binread(path, length = nil, offset = 0) -> string or nil
*
* Behaves like IO.read, except that the stream is opened in binary mode
* with ASCII-8BIT encoding.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
*/
static VALUE
@@ -12165,14 +12353,14 @@ rb_io_s_binread(int argc, VALUE *argv, VALUE io)
{
VALUE offset;
struct foreach_arg arg;
+ enum rb_io_mode fmode = FMODE_READABLE|FMODE_BINMODE;
enum {
- fmode = FMODE_READABLE|FMODE_BINMODE,
oflags = O_RDONLY
#ifdef O_BINARY
|O_BINARY
#endif
};
- convconfig_t convconfig = {NULL, NULL, 0, Qnil};
+ struct rb_io_encoding convconfig = {NULL, NULL, 0, Qnil};
rb_scan_args(argc, argv, "12", NULL, NULL, &offset);
FilePathValue(argv[0]);
@@ -12253,57 +12441,50 @@ io_s_write(int argc, VALUE *argv, VALUE klass, int binary)
/*
* call-seq:
- * IO.write(command, data, **opts) -> integer
- * IO.write(path, data, offset = 0, **opts) -> integer
+ * IO.write(path, data, offset = 0, **opts) -> nonnegative_integer
*
* Opens the stream, writes the given +data+ to it,
* and closes the stream; returns the number of bytes written.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
- *
- * With argument +command+ given, executes the command in a shell,
- * passes +data+ through standard input, writes its output to $stdout,
- * and returns the length of the given +data+:
+ * The first argument must be a string that is the path to a file.
*
- * IO.write('| cat', 'Hello World!') # => 12
+ * With only arguments +path+ and +data+ given,
+ * writes the given data to the file at that path:
*
- * Output:
- *
- * Hello World!
+ * path = 't.tmp'
+ * File.write(path, "First line\nSecond line\n\nFourth line\nFifth line\n") # => 47
+ * File.write(path, 'ã“ã‚“ã«ã¡ã¯') # => 15
+ * File.write(path, "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94") # => 12
*
- * With argument +path+ given, writes the given +data+ to the file
- * at that path:
+ * When +offset+ is zero (the default), the entire file content is overwritten:
*
- * IO.write('t.tmp', 'abc') # => 3
- * File.read('t.tmp') # => "abc"
+ * File.read(path) # => "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
+ * File.write(path, 'foo')
+ * File.read(path) # => "foo"
*
- * If +offset+ is zero (the default), the file is overwritten:
+ * When +offset+ in within the file content, the file content is partly overwritten,
+ * beginning at byte +offset+:
*
- * IO.write('t.tmp', 'A') # => 1
- * File.read('t.tmp') # => "A"
+ * File.write(path, "First line\nSecond line\n\nFourth line\nFifth line\n")
+ * File.write(path, 'LINE', 6)
+ * File.read(path) # => "First LINE\nSecond line\n\nFourth line\nFifth line\n"
*
- * If +offset+ in within the file content, the file is partly overwritten:
+ * When the file contains multi-byte characters,
+ * the effect of writing may disturb some characters:
*
- * IO.write('t.tmp', 'abcdef') # => 3
- * File.read('t.tmp') # => "abcdef"
- * # Offset within content.
- * IO.write('t.tmp', '012', 2) # => 3
- * File.read('t.tmp') # => "ab012f"
+ * File.write(path, "ã“ã‚“ã«ã¡ã¯")
+ * File.write(path, 'FOO', 3) # Replace one 3-byte character.
+ * File.read(path) # => "ã“FOOã«ã¡ã¯"
+ * File.write(path, 'BAR', 7) # Replace bytes in two different 3-byte characters.
+ * File.read(path) # => "ã“FOO\xE3BAR\x81\xA1ã¯"
*
* If +offset+ is outside the file content,
* the file is padded with null characters <tt>"\u0000"</tt>:
*
- * IO.write('t.tmp', 'xyz', 10) # => 3
- * File.read('t.tmp') # => "ab012f\u0000\u0000\u0000\u0000xyz"
+ * File.write(path, "First line\nSecond line\n\nFourth line\nFifth line\n")
+ * File.write(path, 'FOO', 55)
+ * File.read(path)
+ * # => "First line\nSecond line\n\nFourth line\nFifth line\n\u0000\u0000\u0000FOO"
*
* Optional keyword arguments +opts+ specify:
*
@@ -12320,16 +12501,11 @@ rb_io_s_write(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * IO.binwrite(command, string, offset = 0) -> integer
- * IO.binwrite(path, string, offset = 0) -> integer
+ * IO.binwrite(path, string, offset = 0, **opts) -> integer
*
* Behaves like IO.write, except that the stream is opened in binary mode
* with ASCII-8BIT encoding.
*
- * When called from class \IO (but not subclasses of \IO),
- * this method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
- *
*/
static VALUE
@@ -12877,12 +13053,7 @@ maygvl_copy_stream_read(int has_gvl, struct copy_stream_struct *stp, char *buf,
ss = maygvl_read(has_gvl, stp->src_fptr, buf, len);
}
else {
-#ifdef HAVE_PREAD
ss = pread(stp->src_fptr->fd, buf, len, offset);
-#else
- stp->notimp = "pread";
- return -1;
-#endif
}
if (ss == 0) {
return 0;
@@ -13049,6 +13220,7 @@ copy_stream_fallback_body(VALUE arg)
while (1) {
long numwrote;
long l;
+ rb_str_make_independent(buf);
if (stp->copy_length < (rb_off_t)0) {
l = buflen;
}
@@ -13202,7 +13374,7 @@ copy_stream_body(VALUE arg)
rb_str_resize(str,len);
read_buffered_data(RSTRING_PTR(str), len, stp->src_fptr);
if (stp->dst_fptr) { /* IO or filename */
- if (io_binwrite(str, RSTRING_PTR(str), RSTRING_LEN(str), stp->dst_fptr, 0) < 0)
+ if (io_binwrite(RSTRING_PTR(str), RSTRING_LEN(str), stp->dst_fptr, 0) < 0)
rb_sys_fail_on_write(stp->dst_fptr);
}
else /* others such as StringIO */
@@ -13224,7 +13396,7 @@ copy_stream_body(VALUE arg)
return copy_stream_fallback(stp);
}
- rb_thread_call_without_gvl(nogvl_copy_stream_func, (void*)stp, RUBY_UBF_IO, 0);
+ IO_WITHOUT_GVL(nogvl_copy_stream_func, stp);
return Qnil;
}
@@ -13552,6 +13724,7 @@ argf_set_encoding(int argc, VALUE *argv, VALUE argf)
rb_io_set_encoding(argc, argv, ARGF.current_file);
GetOpenFile(ARGF.current_file, fptr);
ARGF.encs = fptr->encs;
+ RB_OBJ_WRITTEN(argf, Qundef, ARGF.encs.ecopts);
return argf;
}
@@ -14416,7 +14589,7 @@ argf_closed(VALUE argf)
{
next_argv();
ARGF_FORWARD(0, 0);
- return rb_io_closed(ARGF.current_file);
+ return rb_io_closed_p(ARGF.current_file);
}
/*
@@ -14484,7 +14657,7 @@ argf_inplace_mode_set(VALUE argf, VALUE val)
ARGF.inplace = Qnil;
}
else {
- ARGF.inplace = rb_str_new_frozen(val);
+ ARGF_SET(inplace, rb_str_new_frozen(val));
}
return argf;
}
@@ -14498,7 +14671,7 @@ opt_i_set(VALUE val, ID id, VALUE *var)
void
ruby_set_inplace_mode(const char *suffix)
{
- ARGF.inplace = !suffix ? Qfalse : !*suffix ? Qnil : rb_str_new(suffix, strlen(suffix));
+ ARGF_SET(inplace, !suffix ? Qfalse : !*suffix ? Qnil : rb_str_new(suffix, strlen(suffix)));
}
/*
@@ -14551,14 +14724,14 @@ argf_write_io(VALUE argf)
/*
* call-seq:
- * ARGF.write(string) -> integer
+ * ARGF.write(*objects) -> integer
*
- * Writes _string_ if inplace mode.
+ * Writes each of the given +objects+ if inplace mode.
*/
static VALUE
-argf_write(VALUE argf, VALUE str)
+argf_write(int argc, VALUE *argv, VALUE argf)
{
- return rb_io_write(argf_write_io(argf), str);
+ return rb_io_writev(argf_write_io(argf), argc, argv);
}
void
@@ -14664,50 +14837,259 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
/*
* Document-class: ARGF
*
- * ARGF is a stream designed for use in scripts that process files given as
- * command-line arguments or passed in via STDIN.
+ * == \ARGF and +ARGV+
+ *
+ * The \ARGF object works with the array at global variable +ARGV+
+ * to make <tt>$stdin</tt> and file streams available in the Ruby program:
+ *
+ * - **ARGV** may be thought of as the <b>argument vector</b> array.
+ *
+ * Initially, it contains the command-line arguments and options
+ * that are passed to the Ruby program;
+ * the program can modify that array as it likes.
+ *
+ * - **ARGF** may be thought of as the <b>argument files</b> object.
+ *
+ * It can access file streams and/or the <tt>$stdin</tt> stream,
+ * based on what it finds in +ARGV+.
+ * This provides a convenient way for the command line
+ * to specify streams for a Ruby program to read.
+ *
+ * == Reading
+ *
+ * \ARGF may read from _source_ streams,
+ * which at any particular time are determined by the content of +ARGV+.
+ *
+ * === Simplest Case
+ *
+ * When the <i>very first</i> \ARGF read occurs with an empty +ARGV+ (<tt>[]</tt>),
+ * the source is <tt>$stdin</tt>:
+ *
+ * - \File +t.rb+:
+ *
+ * p ['ARGV', ARGV]
+ * p ['ARGF.read', ARGF.read]
+ *
+ * - Commands and outputs
+ * (see below for the content of files +foo.txt+ and +bar.txt+):
+ *
+ * $ echo "Open the pod bay doors, Hal." | ruby t.rb
+ * ["ARGV", []]
+ * ["ARGF.read", "Open the pod bay doors, Hal.\n"]
+ *
+ * $ cat foo.txt bar.txt | ruby t.rb
+ * ["ARGV", []]
+ * ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
+ *
+ * === About the Examples
+ *
+ * Many examples here assume the existence of files +foo.txt+ and +bar.txt+:
+ *
+ * $ cat foo.txt
+ * Foo 0
+ * Foo 1
+ * $ cat bar.txt
+ * Bar 0
+ * Bar 1
+ * Bar 2
+ * Bar 3
+ *
+ * === Sources in +ARGV+
+ *
+ * For any \ARGF read _except_ the {simplest case}[rdoc-ref:ARGF@Simplest+Case]
+ * (that is, _except_ for the <i>very first</i> \ARGF read with an empty +ARGV+),
+ * the sources are found in +ARGV+.
+ *
+ * \ARGF assumes that each element in array +ARGV+ is a potential source,
+ * and is one of:
+ *
+ * - The string path to a file that may be opened as a stream.
+ * - The character <tt>'-'</tt>, meaning stream <tt>$stdin</tt>.
+ *
+ * Each element that is _not_ one of these
+ * should be removed from +ARGV+ before \ARGF accesses that source.
+ *
+ * In the following example:
+ *
+ * - Filepaths +foo.txt+ and +bar.txt+ may be retained as potential sources.
+ * - Options <tt>--xyzzy</tt> and <tt>--mojo</tt> should be removed.
+ *
+ * Example:
+ *
+ * - \File +t.rb+:
+ *
+ * # Print arguments (and options, if any) found on command line.
+ * p ['ARGV', ARGV]
+ *
+ * - Command and output:
+ *
+ * $ ruby t.rb --xyzzy --mojo foo.txt bar.txt
+ * ["ARGV", ["--xyzzy", "--mojo", "foo.txt", "bar.txt"]]
+ *
+ * \ARGF's stream access considers the elements of +ARGV+, left to right:
+ *
+ * - \File +t.rb+:
+ *
+ * p "ARGV: #{ARGV}"
+ * p "Read: #{ARGF.read}" # Read everything from all specified streams.
+ *
+ * - Command and output:
+ *
+ * $ ruby t.rb foo.txt bar.txt
+ * "ARGV: [\"foo.txt\", \"bar.txt\"]"
+ * "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
+ *
+ * Because the value at +ARGV+ is an ordinary array,
+ * you can manipulate it to control which sources \ARGF considers:
+ *
+ * - If you remove an element from +ARGV+, \ARGF will not consider the corresponding source.
+ * - If you add an element to +ARGV+, \ARGF will consider the corresponding source.
+ *
+ * Each element in +ARGV+ is removed when its corresponding source is accessed;
+ * when all sources have been accessed, the array is empty:
+ *
+ * - \File +t.rb+:
+ *
+ * until ARGV.empty? && ARGF.eof?
+ * p "ARGV: #{ARGV}"
+ * p "Line: #{ARGF.readline}" # Read each line from each specified stream.
+ * end
+ *
+ * - Command and output:
+ *
+ * $ ruby t.rb foo.txt bar.txt
+ * "ARGV: [\"foo.txt\", \"bar.txt\"]"
+ * "Line: Foo 0\n"
+ * "ARGV: [\"bar.txt\"]"
+ * "Line: Foo 1\n"
+ * "ARGV: [\"bar.txt\"]"
+ * "Line: Bar 0\n"
+ * "ARGV: []"
+ * "Line: Bar 1\n"
+ * "ARGV: []"
+ * "Line: Bar 2\n"
+ * "ARGV: []"
+ * "Line: Bar 3\n"
+ *
+ * ==== Filepaths in +ARGV+
+ *
+ * The +ARGV+ array may contain filepaths the specify sources for \ARGF reading.
+ *
+ * This program prints what it reads from files at the paths specified
+ * on the command line:
+ *
+ * - \File +t.rb+:
+ *
+ * p ['ARGV', ARGV]
+ * # Read and print all content from the specified sources.
+ * p ['ARGF.read', ARGF.read]
*
- * The arguments passed to your script are stored in the +ARGV+ Array, one
- * argument per element. ARGF assumes that any arguments that aren't
- * filenames have been removed from +ARGV+. For example:
+ * - Command and output:
*
- * $ ruby argf.rb --verbose file1 file2
+ * $ ruby t.rb foo.txt bar.txt
+ * ["ARGV", [foo.txt, bar.txt]
+ * ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
*
- * ARGV #=> ["--verbose", "file1", "file2"]
- * option = ARGV.shift #=> "--verbose"
- * ARGV #=> ["file1", "file2"]
+ * ==== Specifying <tt>$stdin</tt> in +ARGV+
*
- * You can now use ARGF to work with a concatenation of each of these named
- * files. For instance, ARGF.read will return the contents of _file1_
- * followed by the contents of _file2_.
+ * To specify stream <tt>$stdin</tt> in +ARGV+, us the character <tt>'-'</tt>:
*
- * After a file in +ARGV+ has been read ARGF removes it from the Array.
- * Thus, after all files have been read +ARGV+ will be empty.
+ * - \File +t.rb+:
*
- * You can manipulate +ARGV+ yourself to control what ARGF operates on. If
- * you remove a file from +ARGV+, it is ignored by ARGF; if you add files to
- * +ARGV+, they are treated as if they were named on the command line. For
- * example:
+ * p ['ARGV', ARGV]
+ * p ['ARGF.read', ARGF.read]
*
- * ARGV.replace ["file1"]
- * ARGF.readlines # Returns the contents of file1 as an Array
- * ARGV #=> []
- * ARGV.replace ["file2", "file3"]
- * ARGF.read # Returns the contents of file2 and file3
+ * - Command and output:
*
- * If +ARGV+ is empty, ARGF acts as if it contained STDIN, i.e. the data
- * piped to your script. For example:
+ * $ echo "Open the pod bay doors, Hal." | ruby t.rb -
+ * ["ARGV", ["-"]]
+ * ["ARGF.read", "Open the pod bay doors, Hal.\n"]
+ *
+ * When no character <tt>'-'</tt> is given, stream <tt>$stdin</tt> is ignored.
+ *
+ * - Command and output:
+ *
+ * $ echo "Open the pod bay doors, Hal." | ruby t.rb foo.txt bar.txt
+ * "ARGV: [\"foo.txt\", \"bar.txt\"]"
+ * "Read: Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"
+ *
+ * ==== Mixtures and Repetitions in +ARGV+
+ *
+ * For an \ARGF reader, +ARGV+ may contain any mixture of filepaths
+ * and character <tt>'-'</tt>, including repetitions.
+ *
+ * ==== Modifications to +ARGV+
+ *
+ * The running Ruby program may make any modifications to the +ARGV+ array;
+ * the current value of +ARGV+ affects \ARGF reading.
+ *
+ * ==== Empty +ARGV+
+ *
+ * For an empty +ARGV+, an \ARGF read method either returns +nil+
+ * or raises an exception, depending on the specific method.
+ *
+ * === More Read Methods
+ *
+ * As seen above, method ARGF#read reads the content of all sources
+ * into a single string.
+ * Other \ARGF methods provide other ways to access that content;
+ * these include:
+ *
+ * - Byte access: #each_byte, #getbyte, #readbyte.
+ * - Character access: #each_char, #getc, #readchar.
+ * - Codepoint access: #each_codepoint.
+ * - Line access: #each_line, #gets, #readline, #readlines.
+ * - Source access: #read, #read_nonblock, #readpartial.
+ *
+ * === About \Enumerable
+ *
+ * \ARGF includes module Enumerable.
+ * Virtually all methods in \Enumerable call method <tt>#each</tt> in the including class.
+ *
+ * <b>Note well</b>: In \ARGF, method #each returns data from the _sources_,
+ * _not_ from +ARGV+;
+ * therefore, for example, <tt>ARGF#entries</tt> returns an array of lines from the sources,
+ * not an array of the strings from +ARGV+:
+ *
+ * - \File +t.rb+:
+ *
+ * p ['ARGV', ARGV]
+ * p ['ARGF.entries', ARGF.entries]
+ *
+ * - Command and output:
+ *
+ * $ ruby t.rb foo.txt bar.txt
+ * ["ARGV", ["foo.txt", "bar.txt"]]
+ * ["ARGF.entries", ["Foo 0\n", "Foo 1\n", "Bar 0\n", "Bar 1\n", "Bar 2\n", "Bar 3\n"]]
+ *
+ * == Writing
+ *
+ * If <i>inplace mode</i> is in effect,
+ * \ARGF may write to target streams,
+ * which at any particular time are determined by the content of ARGV.
+ *
+ * Methods about inplace mode:
+ *
+ * - #inplace_mode
+ * - #inplace_mode=
+ * - #to_write_io
+ *
+ * Methods for writing:
+ *
+ * - #print
+ * - #printf
+ * - #putc
+ * - #puts
+ * - #write
*
- * $ echo "glark" | ruby -e 'p ARGF.read'
- * "glark\n"
*/
/*
* An instance of class \IO (commonly called a _stream_)
* represents an input/output stream in the underlying operating system.
- * \Class \IO is the basis for input and output in Ruby.
+ * Class \IO is the basis for input and output in Ruby.
*
- * \Class File is the only class in the Ruby core that is a subclass of \IO.
+ * Class File is the only class in the Ruby core that is a subclass of \IO.
* Some classes in the Ruby standard library are also subclasses of \IO;
* these include TCPSocket and UDPSocket.
*
@@ -14716,8 +15098,8 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* found in ARGV (or found in STDIN if ARGV is empty).
* ARGF is not itself a subclass of \IO.
*
- * \Class StringIO provides an IO-like stream that handles a String.
- * \StringIO is not itself a subclass of \IO.
+ * Class StringIO provides an IO-like stream that handles a String.
+ * StringIO is not itself a subclass of \IO.
*
* Important objects based on \IO include:
*
@@ -14735,10 +15117,10 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* - Kernel#open: Returns a new \IO object connected to a given source:
* stream, file, or subprocess.
*
- * Like a \File stream, an \IO stream has:
+ * Like a File stream, an \IO stream has:
*
* - A read/write mode, which may be read-only, write-only, or read/write;
- * see {Read/Write Mode}[rdoc-ref:File@Read-2FWrite+Mode].
+ * see {Read/Write Mode}[rdoc-ref:File@ReadWrite+Mode].
* - A data mode, which may be text-only or binary;
* see {Data Mode}[rdoc-ref:File@Data+Mode].
* - Internal and external encodings;
@@ -14771,7 +15153,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* that determine how a new stream is to be opened:
*
* - +:mode+: Stream mode.
- * - +:flags+: \Integer file open flags;
+ * - +:flags+: Integer file open flags;
* If +mode+ is also given, the two are bitwise-ORed.
* - +:external_encoding+: External encoding for the stream.
* - +:internal_encoding+: Internal encoding for the stream.
@@ -14782,11 +15164,11 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* - +:binmode+: If a truthy value, specifies the mode as binary, text-only otherwise.
* - +:autoclose+: If a truthy value, specifies that the +fd+ will close
* when the stream closes; otherwise it remains open.
- * - +:path:+ If a string value is provided, it is used in #inspect and is available as
+ * - +:path+: If a string value is provided, it is used in #inspect and is available as
* #path method.
*
* Also available are the options offered in String#encode,
- * which may control conversion between external internal encoding.
+ * which may control conversion between external and internal encoding.
*
* == Basic \IO
*
@@ -14804,6 +15186,9 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* A new stream has position zero (and line number zero);
* method +rewind+ resets the position (and line number) to zero.
*
+ * These methods discard {buffers}[rdoc-ref:IO@Buffering] and the
+ * Encoding::Converter instances used for that \IO.
+ *
* The relevant methods:
*
* - IO#tell (aliased as +#pos+): Returns the current position (in bytes) in the stream.
@@ -14851,56 +15236,64 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
*
* == Line \IO
*
- * You can read an \IO stream line-by-line using these methods:
+ * Class \IO supports line-oriented
+ * {input}[rdoc-ref:IO@Line+Input] and {output}[rdoc-ref:IO@Line+Output]
*
- * - IO#each_line: Reads each remaining line, passing it to the given block.
- * - IO#gets: Returns the next line.
- * - IO#readline: Like #gets, but raises an exception at end-of-stream.
- * - IO#readlines: Returns all remaining lines in an array.
+ * === Line Input
+ *
+ * Class \IO supports line-oriented input for
+ * {files}[rdoc-ref:IO@File+Line+Input] and {IO streams}[rdoc-ref:IO@Stream+Line+Input]
+ *
+ * ==== \File Line Input
*
- * Each of these reader methods accepts:
+ * You can read lines from a file using these methods:
*
- * - An optional line separator, +sep+;
+ * - IO.foreach: Reads each line and passes it to the given block.
+ * - IO.readlines: Reads and returns all lines in an array.
+ *
+ * For each of these methods:
+ *
+ * - You can specify {open options}[rdoc-ref:IO@Open+Options].
+ * - Line parsing depends on the effective <i>line separator</i>;
* see {Line Separator}[rdoc-ref:IO@Line+Separator].
- * - An optional line-size limit, +limit+;
+ * - The length of each returned line depends on the effective <i>line limit</i>;
* see {Line Limit}[rdoc-ref:IO@Line+Limit].
*
- * For each of these reader methods, reading may begin mid-line,
- * depending on the stream's position;
- * see {Position}[rdoc-ref:IO@Position]:
- *
- * f = File.new('t.txt')
- * f.pos = 27
- * f.each_line {|line| p line }
- * f.close
+ * ==== Stream Line Input
*
- * Output:
+ * You can read lines from an \IO stream using these methods:
*
- * "rth line\n"
- * "Fifth line\n"
+ * - IO#each_line: Reads each remaining line, passing it to the given block.
+ * - IO#gets: Returns the next line.
+ * - IO#readline: Like #gets, but raises an exception at end-of-stream.
+ * - IO#readlines: Returns all remaining lines in an array.
*
- * You can write to an \IO stream line-by-line using this method:
+ * For each of these methods:
*
- * - IO#puts: Writes objects to the stream.
+ * - Reading may begin mid-line,
+ * depending on the stream's _position_;
+ * see {Position}[rdoc-ref:IO@Position].
+ * - Line parsing depends on the effective <i>line separator</i>;
+ * see {Line Separator}[rdoc-ref:IO@Line+Separator].
+ * - The length of each returned line depends on the effective <i>line limit</i>;
+ * see {Line Limit}[rdoc-ref:IO@Line+Limit].
*
- * === Line Separator
+ * ===== Line Separator
*
- * Each of these methods uses a <i>line separator</i>,
- * which is the string that delimits lines:
+ * Each of the {line input methods}[rdoc-ref:IO@Line+Input] uses a <i>line separator</i>:
+ * the string that determines what is considered a line;
+ * it is sometimes called the <i>input record separator</i>.
*
- * - IO.foreach.
- * - IO.readlines.
- * - IO#each_line.
- * - IO#gets.
- * - IO#readline.
- * - IO#readlines.
+ * The default line separator is taken from global variable <tt>$/</tt>,
+ * whose initial value is <tt>"\n"</tt>.
*
- * The default line separator is the given by the global variable <tt>$/</tt>,
- * whose value is by default <tt>"\n"</tt>.
- * The line to be read next is all data from the current position
- * to the next line separator:
+ * Generally, the line to be read next is all data
+ * from the current {position}[rdoc-ref:IO@Position]
+ * to the next line separator
+ * (but see {Special Line Separator Values}[rdoc-ref:IO@Special+Line+Separator+Values]):
*
* f = File.new('t.txt')
+ * # Method gets with no sep argument returns the next line, according to $/.
* f.gets # => "First line\n"
* f.gets # => "Second line\n"
* f.gets # => "\n"
@@ -14908,7 +15301,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* f.gets # => "Fifth line\n"
* f.close
*
- * You can specify a different line separator:
+ * You can use a different line separator by passing argument +sep+:
*
* f = File.new('t.txt')
* f.gets('l') # => "First l"
@@ -14917,15 +15310,27 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* f.gets # => "e\n"
* f.close
*
- * There are two special line separators:
+ * Or by setting global variable <tt>$/</tt>:
+ *
+ * f = File.new('t.txt')
+ * $/ = 'l'
+ * f.gets # => "First l"
+ * f.gets # => "ine\nSecond l"
+ * f.gets # => "ine\n\nFourth l"
+ * f.close
+ *
+ * ===== Special Line Separator Values
*
- * - +nil+: The entire stream is read into a single string:
+ * Each of the {line input methods}[rdoc-ref:IO@Line+Input]
+ * accepts two special values for parameter +sep+:
+ *
+ * - +nil+: The entire stream is to be read ("slurped") into a single string:
*
* f = File.new('t.txt')
* f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n"
* f.close
*
- * - <tt>''</tt> (the empty string): The next "paragraph" is read
+ * - <tt>''</tt> (the empty string): The next "paragraph" is to be read
* (paragraphs being separated by two consecutive line separators):
*
* f = File.new('t.txt')
@@ -14933,23 +15338,18 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* f.gets('') # => "Fourth line\nFifth line\n"
* f.close
*
- * === Line Limit
- *
- * Each of these methods uses a <i>line limit</i>,
- * which specifies that the number of bytes returned may not be (much) longer
- * than the given +limit+;
+ * ===== Line Limit
*
- * - IO.foreach.
- * - IO.readlines.
- * - IO#each_line.
- * - IO#gets.
- * - IO#readline.
- * - IO#readlines.
+ * Each of the {line input methods}[rdoc-ref:IO@Line+Input]
+ * uses an integer <i>line limit</i>,
+ * which restricts the number of bytes that may be returned.
+ * (A multi-byte character will not be split, and so a returned line may be slightly longer
+ * than the limit).
*
- * A multi-byte character will not be split, and so a line may be slightly longer
- * than the given limit.
+ * The default limit value is <tt>-1</tt>;
+ * any negative limit value means that there is no limit.
*
- * If +limit+ is not given, the line is determined only by +sep+.
+ * If there is no limit, the line is determined only by +sep+.
*
* # Text with 1-byte characters.
* File.open('t.txt') {|f| f.gets(1) } # => "F"
@@ -14961,30 +15361,29 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* File.open('t.txt') {|f| f.gets(11) } # => "First line\n"
* File.open('t.txt') {|f| f.gets(12) } # => "First line\n"
*
- * # Text with 2-byte characters, which will not be split.
- * File.open('t.rus') {|f| f.gets(1).size } # => 1
- * File.open('t.rus') {|f| f.gets(2).size } # => 1
- * File.open('t.rus') {|f| f.gets(3).size } # => 2
- * File.open('t.rus') {|f| f.gets(4).size } # => 2
+ * # Text with 3-byte characters, which will not be split.
+ * File.read('t.ja') # => "ã“ã‚“ã«ã¡ã¯"
+ * File.open('t.ja') {|f| f.gets(1).size } # => 1
+ * File.open('t.ja') {|f| f.gets(2).size } # => 1
+ * File.open('t.ja') {|f| f.gets(3).size } # => 1
+ * File.open('t.ja') {|f| f.gets(4).size } # => 2
+ * File.open('t.ja') {|f| f.gets(5).size } # => 2
*
- * === Line Separator and Line Limit
+ * ===== Line Separator and Line Limit
*
- * With arguments +sep+ and +limit+ given,
- * combines the two behaviors:
+ * With arguments +sep+ and +limit+ given, combines the two behaviors:
*
* - Returns the next line as determined by line separator +sep+.
- * - But returns no more bytes than are allowed by the limit.
+ * - But returns no more bytes than are allowed by the limit +limit+.
*
* Example:
*
* File.open('t.txt') {|f| f.gets('li', 20) } # => "First li"
* File.open('t.txt') {|f| f.gets('li', 2) } # => "Fi"
*
- * === Line Number
+ * ===== Line Number
*
- * A readable \IO stream has a non-negative integer <i>line number</i>.
- *
- * The relevant methods:
+ * A readable \IO stream has a non-negative integer <i>line number</i>:
*
* - IO#lineno: Returns the line number.
* - IO#lineno=: Resets and returns the line number.
@@ -14992,7 +15391,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* Unless modified by a call to method IO#lineno=,
* the line number is the number of lines read
* by certain line-oriented methods,
- * according to the given line separator +sep+:
+ * according to the effective {line separator}[rdoc-ref:IO@Line+Separator]:
*
* - IO.foreach: Increments the line number on each call to the block.
* - IO#each_line: Increments the line number on each call to the block.
@@ -15061,7 +15460,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* # => 41
* f.close
*
- * - When a stream is read, <tt>#.</tt> is set to the line number for that stream:
+ * - When a stream is read, <tt>$.</tt> is set to the line number for that stream:
*
* f0 = File.new('t.txt')
* f1 = File.new('t.dat')
@@ -15082,6 +15481,12 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* $. # => 5
* f.close
*
+ * === Line Output
+ *
+ * You can write to an \IO stream line-by-line using this method:
+ *
+ * - IO#puts: Writes objects to the stream.
+ *
* == Character \IO
*
* You can process an \IO stream character-by-character using these methods:
@@ -15092,6 +15497,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* - IO#putc: Writes a character to the stream.
* - IO#each_char: Reads each remaining character in the stream,
* passing the character to the given block.
+ *
* == Byte \IO
*
* You can process an \IO stream byte-by-byte using these methods:
@@ -15110,10 +15516,10 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
*
* == What's Here
*
- * First, what's elsewhere. \Class \IO:
+ * First, what's elsewhere. Class \IO:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Includes {module Enumerable}[rdoc-ref:Enumerable@Whats+Here],
* which provides dozens of additional methods.
*
* Here, class \IO provides methods that are useful for:
@@ -15313,8 +15719,11 @@ Init_IO(void)
/* Can be raised by IO operations when IO#timeout= is set. */
rb_eIOTimeoutError = rb_define_class_under(rb_cIO, "TimeoutError", rb_eIOError);
+ /* Readable event mask for IO#wait. */
rb_define_const(rb_cIO, "READABLE", INT2NUM(RUBY_IO_READABLE));
+ /* Writable event mask for IO#wait. */
rb_define_const(rb_cIO, "WRITABLE", INT2NUM(RUBY_IO_WRITABLE));
+ /* Priority event mask for IO#wait. */
rb_define_const(rb_cIO, "PRIORITY", INT2NUM(RUBY_IO_PRIORITY));
/* exception to wait for reading. see IO.select. */
@@ -15374,18 +15783,21 @@ Init_IO(void)
rb_define_method(rb_cIO, "initialize", rb_io_initialize, -1);
rb_output_fs = Qnil;
- rb_define_hooked_variable("$,", &rb_output_fs, 0, deprecated_str_setter);
+ rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_deprecated_str_setter);
rb_default_rs = rb_fstring_lit("\n"); /* avoid modifying RS_default */
- rb_gc_register_mark_object(rb_default_rs);
+ rb_vm_register_global_object(rb_default_rs);
rb_rs = rb_default_rs;
rb_output_rs = Qnil;
- rb_define_hooked_variable("$/", &rb_rs, 0, deprecated_str_setter);
- rb_define_hooked_variable("$-0", &rb_rs, 0, deprecated_str_setter);
- rb_define_hooked_variable("$\\", &rb_output_rs, 0, deprecated_str_setter);
+ rb_define_hooked_variable("$/", &rb_rs, 0, deprecated_rs_setter);
+ rb_gvar_ractor_local("$/"); // not local but ractor safe
+ rb_define_hooked_variable("$-0", &rb_rs, 0, deprecated_rs_setter);
+ rb_gvar_ractor_local("$-0"); // not local but ractor safe
+ rb_define_hooked_variable("$\\", &rb_output_rs, 0, rb_deprecated_str_setter);
rb_define_virtual_variable("$_", get_LAST_READ_LINE, set_LAST_READ_LINE);
rb_gvar_ractor_local("$_");
+ rb_gvar_box_dynamic("$_");
rb_define_method(rb_cIO, "initialize_copy", rb_io_init_copy, 1);
rb_define_method(rb_cIO, "reopen", rb_io_reopen, -1);
@@ -15428,7 +15840,6 @@ Init_IO(void)
rb_define_method(rb_cIO, "read", io_read, -1);
rb_define_method(rb_cIO, "write", io_write_m, -1);
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, "readchar", rb_io_readchar, 0);
@@ -15463,7 +15874,7 @@ Init_IO(void)
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, "closed?", rb_io_closed_p, 0);
rb_define_method(rb_cIO, "close_read", rb_io_close_read, 0);
rb_define_method(rb_cIO, "close_write", rb_io_close_write, 0);
@@ -15507,13 +15918,12 @@ Init_IO(void)
rb_gvar_ractor_local("$>");
rb_gvar_ractor_local("$stderr");
- rb_stdin = rb_io_prep_stdin();
- rb_stdout = rb_io_prep_stdout();
- rb_stderr = rb_io_prep_stderr();
-
rb_global_variable(&rb_stdin);
+ rb_stdin = rb_io_prep_stdin();
rb_global_variable(&rb_stdout);
+ rb_stdout = rb_io_prep_stdout();
rb_global_variable(&rb_stderr);
+ rb_stderr = rb_io_prep_stderr();
orig_stdout = rb_stdout;
orig_stderr = rb_stderr;
@@ -15573,7 +15983,7 @@ Init_IO(void)
rb_define_method(rb_cARGF, "binmode", argf_binmode_m, 0);
rb_define_method(rb_cARGF, "binmode?", argf_binmode_p, 0);
- rb_define_method(rb_cARGF, "write", argf_write, 1);
+ rb_define_method(rb_cARGF, "write", argf_write, -1);
rb_define_method(rb_cARGF, "print", rb_io_print, -1);
rb_define_method(rb_cARGF, "putc", rb_io_putc, 1);
rb_define_method(rb_cARGF, "puts", rb_io_puts, -1);
@@ -15609,7 +16019,7 @@ Init_IO(void)
rb_define_hooked_variable("$.", &argf, argf_lineno_getter, argf_lineno_setter);
rb_define_hooked_variable("$FILENAME", &argf, argf_filename_getter, rb_gvar_readonly_setter);
- ARGF.filename = rb_str_new2("-");
+ ARGF_SET(filename, rb_str_new2("-"));
rb_define_hooked_variable("$-i", &argf, opt_i_get, opt_i_set);
rb_gvar_ractor_local("$-i");
diff --git a/io.rb b/io.rb
index 40873ea4fd..549c5e62bd 100644
--- a/io.rb
+++ b/io.rb
@@ -120,4 +120,17 @@ class IO
def write_nonblock(buf, exception: true)
Primitive.io_write_nonblock(buf, exception)
end
+
+ # call-seq:
+ # readline(sep = $/, chomp: false) -> string
+ # readline(limit, chomp: false) -> string
+ # readline(sep, limit, chomp: false) -> string
+ #
+ # Reads a line as with IO#gets, but raises EOFError if already at end-of-stream.
+ #
+ # Optional keyword argument +chomp+ specifies whether line separators
+ # are to be omitted.
+ def readline(sep = $/, limit = nil, chomp: false)
+ Primitive.io_readline(sep, limit, chomp)
+ end
end
diff --git a/io_buffer.c b/io_buffer.c
index 91083cd7e4..faa5304248 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -6,17 +6,20 @@
**********************************************************************/
-#include "ruby/io.h"
#include "ruby/io/buffer.h"
#include "ruby/fiber/scheduler.h"
+// For `rb_nogvl`.
+#include "ruby/thread.h"
+
#include "internal.h"
#include "internal/array.h"
#include "internal/bits.h"
#include "internal/error.h"
+#include "internal/gc.h"
#include "internal/numeric.h"
#include "internal/string.h"
-#include "internal/thread.h"
+#include "internal/io.h"
VALUE rb_cIOBuffer;
VALUE rb_eIOBufferLockedError;
@@ -34,6 +37,19 @@ size_t RUBY_IO_BUFFER_DEFAULT_SIZE;
#include <sys/mman.h>
#endif
+enum {
+ RB_IO_BUFFER_HEXDUMP_DEFAULT_WIDTH = 16,
+ RB_IO_BUFFER_HEXDUMP_MAXIMUM_WIDTH = 1024,
+
+ RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE = 256,
+ RB_IO_BUFFER_INSPECT_HEXDUMP_WIDTH = 16,
+
+ // This is used to validate the flags given by the user.
+ RB_IO_BUFFER_FLAGS_MASK = RB_IO_BUFFER_EXTERNAL | RB_IO_BUFFER_INTERNAL | RB_IO_BUFFER_MAPPED | RB_IO_BUFFER_SHARED | RB_IO_BUFFER_LOCKED | RB_IO_BUFFER_PRIVATE | RB_IO_BUFFER_READONLY,
+
+ RB_IO_BUFFER_DEBUG = 0,
+};
+
struct rb_io_buffer {
void *base;
size_t size;
@@ -69,13 +85,15 @@ io_buffer_map_memory(size_t size, int flags)
if (base == MAP_FAILED) {
rb_sys_fail("io_buffer_map_memory:mmap");
}
+
+ ruby_annotate_mmap(base, size, "Ruby:io_buffer_map_memory");
#endif
return base;
}
static void
-io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags)
+io_buffer_map_file(struct rb_io_buffer *buffer, int descriptor, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags)
{
#if defined(_WIN32)
HANDLE file = (HANDLE)_get_osfhandle(descriptor);
@@ -84,26 +102,28 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
DWORD protect = PAGE_READONLY, access = FILE_MAP_READ;
if (flags & RB_IO_BUFFER_READONLY) {
- data->flags |= RB_IO_BUFFER_READONLY;
+ buffer->flags |= RB_IO_BUFFER_READONLY;
}
else {
protect = PAGE_READWRITE;
access = FILE_MAP_WRITE;
}
- HANDLE mapping = CreateFileMapping(file, NULL, protect, 0, 0, NULL);
- if (!mapping) rb_sys_fail("io_buffer_map_descriptor:CreateFileMapping");
-
if (flags & RB_IO_BUFFER_PRIVATE) {
- access |= FILE_MAP_COPY;
- data->flags |= RB_IO_BUFFER_PRIVATE;
+ protect = PAGE_WRITECOPY;
+ access = FILE_MAP_COPY;
+ buffer->flags |= RB_IO_BUFFER_PRIVATE;
}
else {
- // This buffer refers to external data.
- data->flags |= RB_IO_BUFFER_EXTERNAL;
- data->flags |= RB_IO_BUFFER_SHARED;
+ // This buffer refers to external buffer.
+ buffer->flags |= RB_IO_BUFFER_EXTERNAL;
+ buffer->flags |= RB_IO_BUFFER_SHARED;
}
+ HANDLE mapping = CreateFileMapping(file, NULL, protect, 0, 0, NULL);
+ if (RB_IO_BUFFER_DEBUG) fprintf(stderr, "io_buffer_map_file:CreateFileMapping -> %p\n", mapping);
+ if (!mapping) rb_sys_fail("io_buffer_map_descriptor:CreateFileMapping");
+
void *base = MapViewOfFile(mapping, access, (DWORD)(offset >> 32), (DWORD)(offset & 0xFFFFFFFF), size);
if (!base) {
@@ -111,24 +131,25 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
rb_sys_fail("io_buffer_map_file:MapViewOfFile");
}
- data->mapping = mapping;
+ buffer->mapping = mapping;
#else
int protect = PROT_READ, access = 0;
if (flags & RB_IO_BUFFER_READONLY) {
- data->flags |= RB_IO_BUFFER_READONLY;
+ buffer->flags |= RB_IO_BUFFER_READONLY;
}
else {
protect |= PROT_WRITE;
}
if (flags & RB_IO_BUFFER_PRIVATE) {
- data->flags |= RB_IO_BUFFER_PRIVATE;
+ buffer->flags |= RB_IO_BUFFER_PRIVATE;
+ access |= MAP_PRIVATE;
}
else {
- // This buffer refers to external data.
- data->flags |= RB_IO_BUFFER_EXTERNAL;
- data->flags |= RB_IO_BUFFER_SHARED;
+ // This buffer refers to external buffer.
+ buffer->flags |= RB_IO_BUFFER_EXTERNAL;
+ buffer->flags |= RB_IO_BUFFER_SHARED;
access |= MAP_SHARED;
}
@@ -139,20 +160,11 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
}
#endif
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
- data->flags |= RB_IO_BUFFER_MAPPED;
-}
-
-static inline void
-io_buffer_unmap(void* base, size_t size)
-{
-#ifdef _WIN32
- VirtualFree(base, 0, MEM_RELEASE);
-#else
- munmap(base, size);
-#endif
+ buffer->flags |= RB_IO_BUFFER_MAPPED;
+ buffer->flags |= RB_IO_BUFFER_FILE;
}
static void
@@ -172,18 +184,18 @@ io_buffer_experimental(void)
}
static void
-io_buffer_zero(struct rb_io_buffer *data)
+io_buffer_zero(struct rb_io_buffer *buffer)
{
- data->base = NULL;
- data->size = 0;
+ buffer->base = NULL;
+ buffer->size = 0;
#if defined(_WIN32)
- data->mapping = NULL;
+ buffer->mapping = NULL;
#endif
- data->source = Qnil;
+ buffer->source = Qnil;
}
static void
-io_buffer_initialize(struct rb_io_buffer *data, void *base, size_t size, enum rb_io_buffer_flags flags, VALUE source)
+io_buffer_initialize(VALUE self, struct rb_io_buffer *buffer, void *base, size_t size, enum rb_io_buffer_flags flags, VALUE source)
{
if (base) {
// If we are provided a pointer, we use it.
@@ -206,73 +218,106 @@ io_buffer_initialize(struct rb_io_buffer *data, void *base, size_t size, enum rb
return;
}
- data->base = base;
- data->size = size;
- data->flags = flags;
- data->source = source;
+ buffer->base = base;
+ buffer->size = size;
+ buffer->flags = flags;
+ RB_OBJ_WRITE(self, &buffer->source, source);
+
+#if defined(_WIN32)
+ buffer->mapping = NULL;
+#endif
}
-static int
-io_buffer_free(struct rb_io_buffer *data)
+static void
+io_buffer_free(struct rb_io_buffer *buffer)
{
- if (data->base) {
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
- free(data->base);
+ if (buffer->base) {
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
+ free(buffer->base);
}
- if (data->flags & RB_IO_BUFFER_MAPPED) {
- io_buffer_unmap(data->base, data->size);
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
+#ifdef _WIN32
+ if (buffer->flags & RB_IO_BUFFER_FILE) {
+ UnmapViewOfFile(buffer->base);
+ }
+ else {
+ VirtualFree(buffer->base, 0, MEM_RELEASE);
+ }
+#else
+ munmap(buffer->base, buffer->size);
+#endif
}
// Previously we had this, but we found out due to the way GC works, we
// can't refer to any other Ruby objects here.
- // if (RB_TYPE_P(data->source, T_STRING)) {
- // rb_str_unlocktmp(data->source);
+ // if (RB_TYPE_P(buffer->source, T_STRING)) {
+ // rb_str_unlocktmp(buffer->source);
// }
- data->base = NULL;
+ buffer->base = NULL;
+
+ buffer->size = 0;
+ buffer->flags = 0;
+ buffer->source = Qnil;
+ }
#if defined(_WIN32)
- if (data->mapping) {
- CloseHandle(data->mapping);
- data->mapping = NULL;
+ if (buffer->mapping) {
+ if (RB_IO_BUFFER_DEBUG) fprintf(stderr, "io_buffer_free:CloseHandle -> %p\n", buffer->mapping);
+ if (!CloseHandle(buffer->mapping)) {
+ fprintf(stderr, "io_buffer_free:GetLastError -> %lu\n", GetLastError());
}
+ buffer->mapping = NULL;
+ }
#endif
- data->size = 0;
- data->flags = 0;
- data->source = Qnil;
+}
- return 1;
+static void
+rb_io_buffer_type_mark(void *_buffer)
+{
+ struct rb_io_buffer *buffer = _buffer;
+ if (buffer->source != Qnil) {
+ if (RB_TYPE_P(buffer->source, T_STRING)) {
+ // The `source` String has to be pinned, because the `base` may point to the embedded String content,
+ // which can be otherwise moved by GC compaction.
+ rb_gc_mark(buffer->source);
+ } else {
+ rb_gc_mark_movable(buffer->source);
+ }
}
-
- return 0;
}
-void
-rb_io_buffer_type_mark(void *_data)
-{
- struct rb_io_buffer *data = _data;
- rb_gc_mark(data->source);
+static void
+rb_io_buffer_type_compact(void *_buffer)
+{
+ struct rb_io_buffer *buffer = _buffer;
+ if (buffer->source != Qnil) {
+ if (RB_TYPE_P(buffer->source, T_STRING)) {
+ // The `source` String has to be pinned, because the `base` may point to the embedded String content,
+ // which can be otherwise moved by GC compaction.
+ } else {
+ buffer->source = rb_gc_location(buffer->source);
+ }
+ }
}
-void
-rb_io_buffer_type_free(void *_data)
+static void
+rb_io_buffer_type_free(void *_buffer)
{
- struct rb_io_buffer *data = _data;
-
- io_buffer_free(data);
+ struct rb_io_buffer *buffer = _buffer;
- free(data);
+ io_buffer_free(buffer);
}
-size_t
-rb_io_buffer_type_size(const void *_data)
+static size_t
+rb_io_buffer_type_size(const void *_buffer)
{
- const struct rb_io_buffer *data = _data;
+ const struct rb_io_buffer *buffer = _buffer;
size_t total = sizeof(struct rb_io_buffer);
- if (data->flags) {
- total += data->size;
+ if (buffer->flags) {
+ total += buffer->size;
}
return total;
@@ -284,36 +329,187 @@ static const rb_data_type_t rb_io_buffer_type = {
.dmark = rb_io_buffer_type_mark,
.dfree = rb_io_buffer_type_free,
.dsize = rb_io_buffer_type_size,
+ .dcompact = rb_io_buffer_type_compact,
},
.data = NULL,
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
};
+static inline enum rb_io_buffer_flags
+io_buffer_extract_flags(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Flags can't be negative!");
+ }
+
+ enum rb_io_buffer_flags flags = RB_NUM2UINT(argument);
+
+ // We deliberately ignore unknown flags. Any future flags which are exposed this way should be safe to ignore.
+ return flags & RB_IO_BUFFER_FLAGS_MASK;
+}
+
+// Extract an offset argument, which must be a non-negative integer.
+static inline size_t
+io_buffer_extract_offset(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Offset can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a length argument, which must be a non-negative integer.
+// Length is generally considered a mutable property of an object and
+// semantically should be considered a subset of "size" as a concept.
+static inline size_t
+io_buffer_extract_length(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Length can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a size argument, which must be a non-negative integer.
+// Size is generally considered an immutable property of an object.
+static inline size_t
+io_buffer_extract_size(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Size can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a width argument, which must be a non-negative integer, and must be
+// at least the given minimum and at most RB_IO_BUFFER_HEXDUMP_MAXIMUM_WIDTH.
+static inline size_t
+io_buffer_extract_width(VALUE argument, size_t minimum)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Width can't be negative!");
+ }
+
+ size_t width = NUM2SIZET(argument);
+
+ if (width < minimum) {
+ rb_raise(rb_eArgError, "Width must be at least %" PRIuSIZE "!", minimum);
+ }
+
+ if (width > RB_IO_BUFFER_HEXDUMP_MAXIMUM_WIDTH) {
+ rb_raise(rb_eArgError, "Width must be at most %" PRIuSIZE "!", (size_t)RB_IO_BUFFER_HEXDUMP_MAXIMUM_WIDTH);
+ }
+
+ return width;
+}
+
+// Compute the default length for a buffer, given an offset into that buffer.
+// The default length is the size of the buffer minus the offset. The offset
+// must be less than the size of the buffer otherwise the length will be
+// invalid; in that case, an ArgumentError exception will be raised.
+static inline size_t
+io_buffer_default_length(const struct rb_io_buffer *buffer, size_t offset)
+{
+ if (offset > buffer->size) {
+ rb_raise(rb_eArgError, "The given offset is bigger than the buffer size!");
+ }
+
+ // Note that the "length" is computed by the size the offset.
+ return buffer->size - offset;
+}
+
+// Extract the optional length and offset arguments, returning the buffer.
+// The length and offset are optional, but if they are provided, they must be
+// positive integers. If the length is not provided, the default length is
+// computed from the buffer size and offset. If the offset is not provided, it
+// defaults to zero.
+static inline struct rb_io_buffer *
+io_buffer_extract_length_offset(VALUE self, int argc, VALUE argv[], size_t *length, size_t *offset)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (argc >= 2 && !NIL_P(argv[1])) {
+ *offset = io_buffer_extract_offset(argv[1]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 1 && !NIL_P(argv[0])) {
+ *length = io_buffer_extract_length(argv[0]);
+ }
+ else {
+ *length = io_buffer_default_length(buffer, *offset);
+ }
+
+ return buffer;
+}
+
+// Extract the optional offset and length arguments, returning the buffer.
+// Similar to `io_buffer_extract_length_offset` but with the order of arguments
+// reversed.
+//
+// After much consideration, I decided to accept both forms.
+// The `(offset, length)` order is more natural when referring about data,
+// while the `(length, offset)` order is more natural when referring to
+// read/write operations. In many cases, with the latter form, `offset`
+// is usually not supplied.
+static inline struct rb_io_buffer *
+io_buffer_extract_offset_length(VALUE self, int argc, VALUE argv[], size_t *offset, size_t *length)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (argc >= 1 && !NIL_P(argv[0])) {
+ *offset = io_buffer_extract_offset(argv[0]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 2 && !NIL_P(argv[1])) {
+ *length = io_buffer_extract_length(argv[1]);
+ }
+ else {
+ *length = io_buffer_default_length(buffer, *offset);
+ }
+
+ return buffer;
+}
+
VALUE
rb_io_buffer_type_allocate(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- VALUE instance = TypedData_Make_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ io_buffer_experimental();
+
+ struct rb_io_buffer *buffer = NULL;
+ VALUE instance = TypedData_Make_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_zero(data);
+ io_buffer_zero(buffer);
return instance;
}
-static VALUE
-io_buffer_for_make_instance(VALUE klass, VALUE string)
+static VALUE io_buffer_for_make_instance(VALUE klass, VALUE string, enum rb_io_buffer_flags flags)
{
VALUE instance = rb_io_buffer_type_allocate(klass);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- enum rb_io_buffer_flags flags = RB_IO_BUFFER_EXTERNAL;
+ flags |= RB_IO_BUFFER_EXTERNAL;
if (RB_OBJ_FROZEN(string))
flags |= RB_IO_BUFFER_READONLY;
- io_buffer_initialize(data, RSTRING_PTR(string), RSTRING_LEN(string), flags, string);
+ if (!(flags & RB_IO_BUFFER_READONLY))
+ rb_str_modify(string);
+
+ io_buffer_initialize(instance, buffer, RSTRING_PTR(string), RSTRING_LEN(string), flags, string);
return instance;
}
@@ -322,6 +518,7 @@ struct io_buffer_for_yield_instance_arguments {
VALUE klass;
VALUE string;
VALUE instance;
+ enum rb_io_buffer_flags flags;
};
static VALUE
@@ -329,9 +526,11 @@ io_buffer_for_yield_instance(VALUE _arguments)
{
struct io_buffer_for_yield_instance_arguments *arguments = (struct io_buffer_for_yield_instance_arguments *)_arguments;
- rb_str_locktmp(arguments->string);
+ arguments->instance = io_buffer_for_make_instance(arguments->klass, arguments->string, arguments->flags);
- arguments->instance = io_buffer_for_make_instance(arguments->klass, arguments->string);
+ if (!RB_OBJ_FROZEN(arguments->string)) {
+ rb_str_locktmp(arguments->string);
+ }
return rb_yield(arguments->instance);
}
@@ -345,7 +544,9 @@ io_buffer_for_yield_instance_ensure(VALUE _arguments)
rb_io_buffer_free(arguments->instance);
}
- rb_str_unlocktmp(arguments->string);
+ if (!RB_OBJ_FROZEN(arguments->string)) {
+ rb_str_unlocktmp(arguments->string);
+ }
return Qnil;
}
@@ -355,17 +556,18 @@ io_buffer_for_yield_instance_ensure(VALUE _arguments)
* IO::Buffer.for(string) -> readonly io_buffer
* IO::Buffer.for(string) {|io_buffer| ... read/write io_buffer ...}
*
- * Creates a IO::Buffer from the given string's memory. Without a block a
- * frozen internal copy of the string is created efficiently and used as the
- * buffer source. When a block is provided, the buffer is associated directly
- * with the string's internal data and updating the buffer will update the
- * string.
+ * Creates a zero-copy IO::Buffer from the given string's memory. Without a
+ * block a frozen internal copy of the string is created efficiently and used
+ * as the buffer source. When a block is provided, the buffer is associated
+ * directly with the string's internal buffer and updating the buffer will
+ * update the string.
*
* Until #free is invoked on the buffer, either explicitly or via the garbage
* collector, the source string will be locked and cannot be modified.
*
* If the string is frozen, it will create a read-only buffer which cannot be
- * modified.
+ * modified. If the string is shared, it may trigger a copy-on-write when
+ * using the block form.
*
* string = 'test'
* buffer = IO::Buffer.for(string)
@@ -374,7 +576,7 @@ io_buffer_for_yield_instance_ensure(VALUE _arguments)
* buffer.get_string(0, 1)
* # => "t"
* string
- * # => "best"
+ * # => "test"
*
* buffer.resize(100)
* # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError)
@@ -397,6 +599,7 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
.klass = klass,
.string = string,
.instance = Qnil,
+ .flags = 0,
};
return rb_ensure(io_buffer_for_yield_instance, (VALUE)&arguments, io_buffer_for_yield_instance_ensure, (VALUE)&arguments);
@@ -404,7 +607,7 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
else {
// This internally returns the source string if it's already frozen.
string = rb_str_tmp_frozen_acquire(string);
- return io_buffer_for_make_instance(klass, string);
+ return io_buffer_for_make_instance(klass, string, RB_IO_BUFFER_READONLY);
}
}
@@ -412,9 +615,9 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
* call-seq:
* IO::Buffer.string(length) {|io_buffer| ... read/write io_buffer ...} -> string
*
- * Creates a new string of the given length and yields a IO::Buffer instance
- * to the block which uses the string as a source. The block is expected to
- * write to the buffer and the string will be returned.
+ * Creates a new string of the given length and yields a zero-copy IO::Buffer
+ * instance to the block which uses the string as a source. The block is
+ * expected to write to the buffer and the string will be returned.
*
* IO::Buffer.string(4) do |buffer|
* buffer.set_string("Ruby")
@@ -442,10 +645,10 @@ rb_io_buffer_new(void *base, size_t size, enum rb_io_buffer_flags flags)
{
VALUE instance = rb_io_buffer_type_allocate(rb_cIOBuffer);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_initialize(data, base, size, flags, Qnil);
+ io_buffer_initialize(instance, buffer, base, size, flags, Qnil);
return instance;
}
@@ -453,16 +656,14 @@ rb_io_buffer_new(void *base, size_t size, enum rb_io_buffer_flags flags)
VALUE
rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags)
{
- io_buffer_experimental();
-
VALUE instance = rb_io_buffer_type_allocate(rb_cIOBuffer);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
int descriptor = rb_io_descriptor(io);
- io_buffer_map_file(data, descriptor, size, offset, flags);
+ io_buffer_map_file(buffer, descriptor, size, offset, flags);
return instance;
}
@@ -471,20 +672,25 @@ rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags
* call-seq: IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
*
* Create an IO::Buffer for reading from +file+ by memory-mapping the file.
- * +file_io+ should be a +File+ instance, opened for reading.
+ * +file+ should be a +File+ instance, opened for reading or reading and writing.
*
* Optional +size+ and +offset+ of mapping can be specified.
+ * Trying to map an empty file or specify +size+ of 0 will raise an error.
+ * Valid values for +offset+ are system-dependent.
*
- * By default, the buffer would be immutable (read only); to create a writable
- * mapping, you need to open a file in read-write mode, and explicitly pass
- * +flags+ argument without IO::Buffer::IMMUTABLE.
+ * By default, the buffer is writable and expects the file to be writable.
+ * It is also shared, so several processes can use the same mapping.
*
- * Example:
+ * You can pass IO::Buffer::READONLY in +flags+ argument to make a read-only buffer;
+ * this allows to work with files opened only for reading.
+ * Specifying IO::Buffer::PRIVATE in +flags+ creates a private mapping,
+ * which will not impact other processes or the underlying file.
+ * It also allows updating a buffer created from a read-only file.
*
* File.write('test.txt', 'test')
*
* buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
- * # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
+ * # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
*
* buffer.readonly? # => true
*
@@ -492,7 +698,7 @@ rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags
* # => "test"
*
* buffer.set_string('b', 0)
- * # `set_string': Buffer is not writable! (IO::Buffer::AccessError)
+ * # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
*
* # create read/write mapping: length 4 bytes, offset 0, flags 0
* buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
@@ -514,35 +720,53 @@ io_buffer_map(int argc, VALUE *argv, VALUE klass)
// We might like to handle a string path?
VALUE io = argv[0];
- size_t size;
- if (argc >= 2 && !RB_NIL_P(argv[1])) {
- size = RB_NUM2SIZE(argv[1]);
+ rb_off_t file_size = rb_file_size(io);
+ // Compiler can confirm that we handled file_size <= 0 case:
+ if (UNLIKELY(file_size <= 0)) {
+ rb_raise(rb_eArgError, "Invalid negative or zero file size!");
+ }
+ // Here, we assume that file_size is positive:
+ else if (UNLIKELY((uintmax_t)file_size > SIZE_MAX)) {
+ rb_raise(rb_eArgError, "File larger than address space!");
}
- else {
- rb_off_t file_size = rb_file_size(io);
- // Compiler can confirm that we handled file_size < 0 case:
- if (file_size < 0) {
- rb_raise(rb_eArgError, "Invalid negative file size!");
+ size_t size;
+ if (argc >= 2 && !RB_NIL_P(argv[1])) {
+ size = io_buffer_extract_size(argv[1]);
+ if (UNLIKELY(size == 0)) {
+ rb_raise(rb_eArgError, "Size can't be zero!");
}
- // Here, we assume that file_size is positive:
- else if ((uintmax_t)file_size > SIZE_MAX) {
- rb_raise(rb_eArgError, "File larger than address space!");
- }
- else {
- // This conversion should be safe:
- size = (size_t)file_size;
+ if (UNLIKELY(size > (size_t)file_size)) {
+ rb_raise(rb_eArgError, "Size can't be larger than file size!");
}
}
+ else {
+ // This conversion should be safe:
+ size = (size_t)file_size;
+ }
+ // This is the file offset, not the buffer offset:
rb_off_t offset = 0;
if (argc >= 3) {
offset = NUM2OFFT(argv[2]);
+ if (UNLIKELY(offset < 0)) {
+ rb_raise(rb_eArgError, "Offset can't be negative!");
+ }
+ if (UNLIKELY(offset >= file_size)) {
+ rb_raise(rb_eArgError, "Offset too large!");
+ }
+ if (RB_NIL_P(argv[1])) {
+ // Decrease size if it's set from the actual file size:
+ size = (size_t)(file_size - offset);
+ }
+ else if (UNLIKELY((size_t)(file_size - offset) < size)) {
+ rb_raise(rb_eArgError, "Offset too large!");
+ }
}
enum rb_io_buffer_flags flags = 0;
if (argc >= 4) {
- flags = RB_NUM2UINT(argv[3]);
+ flags = io_buffer_extract_flags(argv[3]);
}
return rb_io_buffer_map(io, size, offset, flags);
@@ -570,8 +794,6 @@ io_flags_for_size(size_t size)
* on Windows). The behavior can be forced by passing IO::Buffer::MAPPED
* as a second parameter.
*
- * Examples
- *
* buffer = IO::Buffer.new(4)
* # =>
* # #<IO::Buffer 0x000055b34497ea10+4 INTERNAL>
@@ -588,17 +810,14 @@ io_flags_for_size(size_t size)
VALUE
rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self)
{
- io_buffer_experimental();
-
rb_check_arity(argc, 0, 2);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
size_t size;
-
if (argc > 0) {
- size = RB_NUM2SIZE(argv[0]);
+ size = io_buffer_extract_size(argv[0]);
}
else {
size = RUBY_IO_BUFFER_DEFAULT_SIZE;
@@ -606,13 +825,13 @@ rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self)
enum rb_io_buffer_flags flags = 0;
if (argc >= 2) {
- flags = RB_NUM2UINT(argv[1]);
+ flags = io_buffer_extract_flags(argv[1]);
}
else {
flags |= io_flags_for_size(size);
}
- io_buffer_initialize(data, NULL, size, flags, Qnil);
+ io_buffer_initialize(self, buffer, NULL, size, flags, Qnil);
return self;
}
@@ -647,17 +866,94 @@ io_buffer_validate_slice(VALUE source, void *base, size_t size)
}
static int
-io_buffer_validate(struct rb_io_buffer *data)
+io_buffer_validate(struct rb_io_buffer *buffer)
{
- if (data->source != Qnil) {
+ if (buffer->source != Qnil) {
// Only slices incur this overhead, unfortunately... better safe than sorry!
- return io_buffer_validate_slice(data->source, data->base, data->size);
+ return io_buffer_validate_slice(buffer->source, buffer->base, buffer->size);
}
else {
return 1;
}
}
+enum rb_io_buffer_flags
+rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (io_buffer_validate(buffer)) {
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+
+ return buffer->flags;
+ }
+ }
+
+ *base = NULL;
+ *size = 0;
+
+ return 0;
+}
+
+// Internal function for accessing bytes for writing, wil
+static inline void
+io_buffer_get_bytes_for_writing(struct rb_io_buffer *buffer, void **base, size_t *size)
+{
+ if (buffer->flags & RB_IO_BUFFER_READONLY ||
+ (!NIL_P(buffer->source) && OBJ_FROZEN(buffer->source))) {
+ rb_raise(rb_eIOBufferAccessError, "Buffer is not writable!");
+ }
+
+ if (!io_buffer_validate(buffer)) {
+ rb_raise(rb_eIOBufferInvalidatedError, "Buffer is invalid!");
+ }
+
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+ } else {
+ *base = NULL;
+ *size = 0;
+ }
+}
+
+void
+rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_get_bytes_for_writing(buffer, base, size);
+}
+
+static void
+io_buffer_get_bytes_for_reading(struct rb_io_buffer *buffer, const void **base, size_t *size)
+{
+ if (!io_buffer_validate(buffer)) {
+ rb_raise(rb_eIOBufferInvalidatedError, "Buffer has been invalidated!");
+ }
+
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+ } else {
+ *base = NULL;
+ *size = 0;
+ }
+}
+
+void
+rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_get_bytes_for_reading(buffer, base, size);
+}
+
/*
* call-seq: to_s -> string
*
@@ -670,60 +966,93 @@ io_buffer_validate(struct rb_io_buffer *data)
VALUE
rb_io_buffer_to_s(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE result = rb_str_new_cstr("#<");
rb_str_append(result, rb_class_name(CLASS_OF(self)));
- rb_str_catf(result, " %p+%"PRIdSIZE, data->base, data->size);
+ rb_str_catf(result, " %p+%"PRIdSIZE, buffer->base, buffer->size);
- if (data->base == NULL) {
+ if (buffer->base == NULL) {
rb_str_cat2(result, " NULL");
}
- if (data->flags & RB_IO_BUFFER_EXTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_EXTERNAL) {
rb_str_cat2(result, " EXTERNAL");
}
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
rb_str_cat2(result, " INTERNAL");
}
- if (data->flags & RB_IO_BUFFER_MAPPED) {
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
rb_str_cat2(result, " MAPPED");
}
- if (data->flags & RB_IO_BUFFER_SHARED) {
+ if (buffer->flags & RB_IO_BUFFER_FILE) {
+ rb_str_cat2(result, " FILE");
+ }
+
+ if (buffer->flags & RB_IO_BUFFER_SHARED) {
rb_str_cat2(result, " SHARED");
}
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_str_cat2(result, " LOCKED");
}
- if (data->flags & RB_IO_BUFFER_READONLY) {
+ if (buffer->flags & RB_IO_BUFFER_PRIVATE) {
+ rb_str_cat2(result, " PRIVATE");
+ }
+
+ if (buffer->flags & RB_IO_BUFFER_READONLY) {
rb_str_cat2(result, " READONLY");
}
- if (data->source != Qnil) {
+ if (buffer->source != Qnil) {
rb_str_cat2(result, " SLICE");
}
- if (!io_buffer_validate(data)) {
+ if (!io_buffer_validate(buffer)) {
rb_str_cat2(result, " INVALID");
}
return rb_str_cat2(result, ">");
}
+// Compute the output size of a hexdump of the given width (bytes per line), total size, and whether it is the first line in the output.
+// This is used to preallocate the output string.
+inline static size_t
+io_buffer_hexdump_output_size(size_t width, size_t size, int first)
+{
+ // The preview on the right hand side is 1:1:
+ size_t total = size;
+
+ size_t whole_lines = (size / width);
+ size_t partial_line = (size % width) ? 1 : 0;
+
+ // For each line:
+ // 1 byte 10 bytes 1 byte width*3 bytes 1 byte size bytes
+ // (newline) (address) (space) (hexdump ) (space) (preview)
+ total += (whole_lines + partial_line) * (1 + 10 + width*3 + 1 + 1);
+
+ // If the hexdump is the first line, one less newline will be emitted:
+ if (size && first) total -= 1;
+
+ return total;
+}
+
+// Append a hexdump of the given width (bytes per line), base address, size, and whether it is the first line in the output.
+// If the hexdump is not the first line, it will prepend a newline if there is any output at all.
+// If formatting here is adjusted, please update io_buffer_hexdump_output_size accordingly.
static VALUE
-io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first)
+io_buffer_hexdump(VALUE string, size_t width, const char *base, size_t length, size_t offset, int first)
{
char *text = alloca(width+1);
text[width] = '\0';
- for (size_t offset = 0; offset < size; offset += width) {
+ for (; offset < length; offset += width) {
memset(text, '\0', width);
if (first) {
rb_str_catf(string, "0x%08" PRIxSIZE " ", offset);
@@ -734,7 +1063,7 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
}
for (size_t i = 0; i < width; i += 1) {
- if (offset+i < size) {
+ if (offset+i < length) {
unsigned char value = ((unsigned char*)base)[offset+i];
if (value < 127 && isprint(value)) {
@@ -757,35 +1086,40 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
return string;
}
-static VALUE
-rb_io_buffer_hexdump(VALUE self)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- VALUE result = Qnil;
-
- if (io_buffer_validate(data) && data->base) {
- result = rb_str_buf_new(data->size*3 + (data->size/16)*12 + 1);
-
- io_buffer_hexdump(result, 16, data->base, data->size, 1);
- }
-
- return result;
-}
-
+/*
+ * call-seq: inspect -> string
+ *
+ * Inspect the buffer and report useful information about it's internal state.
+ * Only a limited portion of the buffer will be displayed in a hexdump style
+ * format.
+ *
+ * buffer = IO::Buffer.for("Hello World")
+ * puts buffer.inspect
+ * # #<IO::Buffer 0x000000010198ccd8+11 EXTERNAL READONLY SLICE>
+ * # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
+ */
VALUE
rb_io_buffer_inspect(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE result = rb_io_buffer_to_s(self);
- if (io_buffer_validate(data)) {
- // Limit the maximum size generated by inspect.
- if (data->size <= 256) {
- io_buffer_hexdump(result, 16, data->base, data->size, 0);
+ if (io_buffer_validate(buffer)) {
+ // Limit the maximum size generated by inspect:
+ size_t size = buffer->size;
+ int clamped = 0;
+
+ if (size > RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE) {
+ size = RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE;
+ clamped = 1;
+ }
+
+ io_buffer_hexdump(result, RB_IO_BUFFER_INSPECT_HEXDUMP_WIDTH, buffer->base, size, 0, 0);
+
+ if (clamped) {
+ rb_str_catf(result, "\n(and %" PRIuSIZE " more bytes not printed)", buffer->size - size);
}
}
@@ -801,42 +1135,50 @@ rb_io_buffer_inspect(VALUE self)
VALUE
rb_io_buffer_size(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return SIZET2NUM(data->size);
+ return SIZET2NUM(buffer->size);
}
/*
* call-seq: valid? -> true or false
*
- * Returns whether the buffer data is accessible.
+ * Returns whether the buffer buffer is accessible.
*
- * A buffer becomes invalid if it is a slice of another buffer which has been
- * freed.
+ * A buffer becomes invalid if it is a slice of another buffer (or string)
+ * which has been freed or re-allocated at a different address.
*/
static VALUE
rb_io_buffer_valid_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(io_buffer_validate(data));
+ return RBOOL(io_buffer_validate(buffer));
}
/*
* call-seq: null? -> true or false
*
- * If the buffer was freed with #free or was never allocated in the first
- * place.
+ * If the buffer was freed with #free, transferred with #transfer, or was
+ * never allocated in the first place.
+ *
+ * buffer = IO::Buffer.new(0)
+ * buffer.null? #=> true
+ *
+ * buffer = IO::Buffer.new(4)
+ * buffer.null? #=> false
+ * buffer.free
+ * buffer.null? #=> true
*/
static VALUE
rb_io_buffer_null_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->base == NULL);
+ return RBOOL(buffer->base == NULL);
}
/*
@@ -849,10 +1191,10 @@ rb_io_buffer_null_p(VALUE self)
static VALUE
rb_io_buffer_empty_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->size == 0);
+ return RBOOL(buffer->size == 0);
}
/*
@@ -869,10 +1211,10 @@ rb_io_buffer_empty_p(VALUE self)
static VALUE
rb_io_buffer_external_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_EXTERNAL);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_EXTERNAL);
}
/*
@@ -894,10 +1236,10 @@ rb_io_buffer_external_p(VALUE self)
static VALUE
rb_io_buffer_internal_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_INTERNAL);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_INTERNAL);
}
/*
@@ -916,10 +1258,10 @@ rb_io_buffer_internal_p(VALUE self)
static VALUE
rb_io_buffer_mapped_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_MAPPED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_MAPPED);
}
/*
@@ -928,14 +1270,30 @@ rb_io_buffer_mapped_p(VALUE self)
* If the buffer is _shared_, meaning it references memory that can be shared
* with other processes (and thus might change without being modified
* locally).
+ *
+ * # Create a test file:
+ * File.write('test.txt', 'test')
+ *
+ * # Create a shared mapping from the given file, the file must be opened in
+ * # read-write mode unless we also specify IO::Buffer::READONLY:
+ * buffer = IO::Buffer.map(File.open('test.txt', 'r+'), nil, 0)
+ * # => #<IO::Buffer 0x00007f1bffd5e000+4 EXTERNAL MAPPED SHARED>
+ *
+ * # Write to the buffer, which will modify the mapped file:
+ * buffer.set_string('b', 0)
+ * # => 1
+ *
+ * # The file itself is modified:
+ * File.read('test.txt')
+ * # => "best"
*/
static VALUE
rb_io_buffer_shared_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_SHARED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_SHARED);
}
/*
@@ -948,8 +1306,6 @@ rb_io_buffer_shared_p(VALUE self)
* Locking is not thread safe, but is a semantic used to ensure buffers don't
* move while being used by a system call.
*
- * Example:
- *
* buffer.locked do
* buffer.write(io) # theoretical system call interface
* end
@@ -957,19 +1313,50 @@ rb_io_buffer_shared_p(VALUE self)
static VALUE
rb_io_buffer_locked_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_LOCKED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_LOCKED);
+}
+
+/* call-seq: private? -> true or false
+ *
+ * If the buffer is _private_, meaning modifications to the buffer will not
+ * be replicated to the underlying file mapping.
+ *
+ * # Create a test file:
+ * File.write('test.txt', 'test')
+ *
+ * # Create a private mapping from the given file. Note that the file here
+ * # is opened in read-only mode, but it doesn't matter due to the private
+ * # mapping:
+ * buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::PRIVATE)
+ * # => #<IO::Buffer 0x00007fce63f11000+4 MAPPED PRIVATE>
+ *
+ * # Write to the buffer (invoking CoW of the underlying file buffer):
+ * buffer.set_string('b', 0)
+ * # => 1
+ *
+ * # The file itself is not modified:
+ * File.read('test.txt')
+ * # => "test"
+ */
+static VALUE
+rb_io_buffer_private_p(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ return RBOOL(buffer->flags & RB_IO_BUFFER_PRIVATE);
}
int
rb_io_buffer_readonly_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return data->flags & RB_IO_BUFFER_READONLY;
+ return buffer->flags & RB_IO_BUFFER_READONLY;
}
/*
@@ -986,32 +1373,44 @@ io_buffer_readonly_p(VALUE self)
return RBOOL(rb_io_buffer_readonly_p(self));
}
-VALUE
-rb_io_buffer_lock(VALUE self)
+static void
+io_buffer_lock(struct rb_io_buffer *buffer)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer already locked!");
}
- data->flags |= RB_IO_BUFFER_LOCKED;
-
- return self;
+ buffer->flags |= RB_IO_BUFFER_LOCKED;
}
VALUE
-rb_io_buffer_unlock(VALUE self)
+rb_io_buffer_lock(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_lock(buffer);
- if (!(data->flags & RB_IO_BUFFER_LOCKED)) {
+ return self;
+}
+
+static void
+io_buffer_unlock(struct rb_io_buffer *buffer)
+{
+ if (!(buffer->flags & RB_IO_BUFFER_LOCKED)) {
rb_raise(rb_eIOBufferLockedError, "Buffer not locked!");
}
- data->flags &= ~RB_IO_BUFFER_LOCKED;
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
+}
+
+VALUE
+rb_io_buffer_unlock(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_unlock(buffer);
return self;
}
@@ -1019,17 +1418,28 @@ rb_io_buffer_unlock(VALUE self)
int
rb_io_buffer_try_unlock(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
- data->flags &= ~RB_IO_BUFFER_LOCKED;
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
return 1;
}
return 0;
}
+static VALUE
+rb_io_buffer_locked_ensure(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
+
+ return Qnil;
+}
+
/*
* call-seq: locked { ... }
*
@@ -1044,8 +1454,6 @@ rb_io_buffer_try_unlock(VALUE self)
* non-blocking system calls. You can only share a buffer between threads with
* appropriate synchronisation techniques.
*
- * Example:
- *
* buffer = IO::Buffer.new(4)
* buffer.locked? #=> false
*
@@ -1065,20 +1473,16 @@ rb_io_buffer_try_unlock(VALUE self)
VALUE
rb_io_buffer_locked(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer already locked!");
}
- data->flags |= RB_IO_BUFFER_LOCKED;
-
- VALUE result = rb_yield(self);
+ buffer->flags |= RB_IO_BUFFER_LOCKED;
- data->flags &= ~RB_IO_BUFFER_LOCKED;
-
- return result;
+ return rb_ensure(rb_yield, self, rb_io_buffer_locked_ensure, self);
}
/*
@@ -1089,12 +1493,10 @@ rb_io_buffer_locked(VALUE self)
* * for a buffer created from scratch: free memory.
* * for a buffer created from string: undo the association.
*
- * After the buffer is freed, no further operations can't be performed on it.
+ * After the buffer is freed, no further operations can be performed on it.
*
* You can resize a freed buffer to re-allocate it.
*
- * Example:
- *
* buffer = IO::Buffer.for('test')
* buffer.free
* # => #<IO::Buffer 0x0000000000000000+0 NULL>
@@ -1111,51 +1513,115 @@ rb_io_buffer_locked(VALUE self)
VALUE
rb_io_buffer_free(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer is locked!");
}
- io_buffer_free(data);
+ io_buffer_free(buffer);
return self;
}
+VALUE rb_io_buffer_free_locked(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_unlock(buffer);
+ io_buffer_free(buffer);
+
+ return self;
+}
+
+static bool
+size_sum_is_bigger_than(size_t a, size_t b, size_t x)
+{
+ struct rbimpl_size_overflow_tag size = rbimpl_size_add_overflow(a, b);
+ return size.overflowed || size.result > x;
+}
+
// Validate that access to the buffer is within bounds, assuming you want to
// access length bytes from the specified offset.
static inline void
-io_buffer_validate_range(struct rb_io_buffer *data, size_t offset, size_t length)
+io_buffer_validate_range(struct rb_io_buffer *buffer, size_t offset, size_t length)
{
- if (offset + length > data->size) {
- rb_raise(rb_eArgError, "Specified offset+length exceeds data size!");
+ if (size_sum_is_bigger_than(offset, length, buffer->size)) {
+ rb_raise(rb_eArgError, "Specified offset+length is bigger than the buffer size!");
}
}
+/*
+ * call-seq: hexdump([offset, [length, [width]]]) -> string
+ *
+ * Returns a human-readable string representation of the buffer. The exact
+ * format is subject to change.
+ *
+ * buffer = IO::Buffer.for("Hello World")
+ * puts buffer.hexdump
+ * # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
+ *
+ * As buffers are usually fairly big, you may want to limit the output by
+ * specifying the offset and length:
+ *
+ * puts buffer.hexdump(6, 5)
+ * # 0x00000006 57 6f 72 6c 64 World
+ */
+static VALUE
+rb_io_buffer_hexdump(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 0, 3);
+
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
+
+ size_t width = RB_IO_BUFFER_HEXDUMP_DEFAULT_WIDTH;
+ if (argc >= 3) {
+ width = io_buffer_extract_width(argv[2], 1);
+ }
+
+ // This may raise an exception if the offset/length is invalid:
+ io_buffer_validate_range(buffer, offset, length);
+
+ VALUE result = Qnil;
+
+ if (io_buffer_validate(buffer) && buffer->base) {
+ result = rb_str_buf_new(io_buffer_hexdump_output_size(width, length, 1));
+
+ io_buffer_hexdump(result, width, buffer->base, offset+length, offset, 1);
+ }
+
+ return result;
+}
+
static VALUE
-rb_io_buffer_slice(struct rb_io_buffer *data, VALUE self, size_t offset, size_t length)
+rb_io_buffer_slice(struct rb_io_buffer *buffer, VALUE self, size_t offset, size_t length)
{
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
VALUE instance = rb_io_buffer_type_allocate(rb_class_of(self));
struct rb_io_buffer *slice = NULL;
TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, slice);
- slice->base = (char*)data->base + offset;
+ slice->flags |= (buffer->flags & RB_IO_BUFFER_READONLY);
+ slice->base = (char*)buffer->base + offset;
slice->size = length;
// The source should be the root buffer:
- if (data->source != Qnil)
- slice->source = data->source;
- else
- slice->source = self;
+ if (buffer->source != Qnil) {
+ RB_OBJ_WRITE(instance, &slice->source, buffer->source);
+ }
+ else {
+ RB_OBJ_WRITE(instance, &slice->source, self);
+ }
return instance;
}
/*
- * call-seq: slice([offset = 0, [length]]) -> io_buffer
+ * call-seq: slice([offset, [length]]) -> io_buffer
*
* Produce another IO::Buffer which is a slice (or view into) the current one
* starting at +offset+ bytes and going for +length+ bytes.
@@ -1173,10 +1639,8 @@ rb_io_buffer_slice(struct rb_io_buffer *data, VALUE self, size_t offset, size_t
* Raises RuntimeError if the <tt>offset+length</tt> is out of the current
* buffer's bounds.
*
- * Example:
- *
* string = 'test'
- * buffer = IO::Buffer.for(string)
+ * buffer = IO::Buffer.for(string).dup
*
* slice = buffer.slice
* # =>
@@ -1203,128 +1667,25 @@ rb_io_buffer_slice(struct rb_io_buffer *data, VALUE self, size_t offset, size_t
* # it is also visible at position 1 of the original buffer
* buffer
* # =>
- * # #<IO::Buffer 0x00007fc3d31e2d80+4 SLICE>
+ * # #<IO::Buffer 0x00007fc3d31e2d80+4 INTERNAL>
* # 0x00000000 74 6f 73 74 tost
- *
- * # ...and original string
- * string
- * # => tost
*/
static VALUE
io_buffer_slice(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 2);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- size_t offset = 0, length = 0;
-
- if (argc > 0) {
- if (rb_int_negative_p(argv[0])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
- offset = NUM2SIZET(argv[0]);
- }
-
- if (argc > 1) {
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
-
- length = NUM2SIZET(argv[1]);
- }
- else {
- length = data->size - offset;
- }
-
- return rb_io_buffer_slice(data, self, offset, length);
-}
-
-int
-rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- if (io_buffer_validate(data)) {
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return data->flags;
- }
- }
-
- *base = NULL;
- *size = 0;
-
- return 0;
-}
-
-static inline void
-io_buffer_get_bytes_for_writing(struct rb_io_buffer *data, void **base, size_t *size)
-{
- if (data->flags & RB_IO_BUFFER_READONLY) {
- rb_raise(rb_eIOBufferAccessError, "Buffer is not writable!");
- }
-
- if (!io_buffer_validate(data)) {
- rb_raise(rb_eIOBufferInvalidatedError, "Buffer is invalid!");
- }
-
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return;
- }
-
- rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
-}
-
-void
-rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- io_buffer_get_bytes_for_writing(data, base, size);
-}
-
-static void
-io_buffer_get_bytes_for_reading(struct rb_io_buffer *data, const void **base, size_t *size)
-{
- if (!io_buffer_validate(data)) {
- rb_raise(rb_eIOBufferInvalidatedError, "Buffer has been invalidated!");
- }
-
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return;
- }
-
- rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
-}
-
-void
-rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- io_buffer_get_bytes_for_reading(data, base, size);
+ return rb_io_buffer_slice(buffer, self, offset, length);
}
/*
* call-seq: transfer -> new_io_buffer
*
- * Transfers ownership to a new buffer, deallocating the current one.
- *
- * Example:
+ * Transfers ownership of the underlying memory to a new buffer, causing the
+ * current buffer to become uninitialized.
*
* buffer = IO::Buffer.new('test')
* other = buffer.transfer
@@ -1341,10 +1702,10 @@ rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
VALUE
rb_io_buffer_transfer(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Cannot transfer ownership of locked buffer!");
}
@@ -1352,91 +1713,96 @@ rb_io_buffer_transfer(VALUE self)
struct rb_io_buffer *transferred;
TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, transferred);
- *transferred = *data;
- io_buffer_zero(data);
+ *transferred = *buffer;
+ io_buffer_zero(buffer);
return instance;
}
static void
-io_buffer_resize_clear(struct rb_io_buffer *data, void* base, size_t size)
+io_buffer_resize_clear(struct rb_io_buffer *buffer, void* base, size_t size)
{
- if (size > data->size) {
- memset((unsigned char*)base+data->size, 0, size - data->size);
+ if (size > buffer->size) {
+ memset((unsigned char*)base+buffer->size, 0, size - buffer->size);
}
}
static void
-io_buffer_resize_copy(struct rb_io_buffer *data, size_t size)
+io_buffer_resize_copy(VALUE self, struct rb_io_buffer *buffer, size_t size)
{
// Slow path:
struct rb_io_buffer resized;
- io_buffer_initialize(&resized, NULL, size, io_flags_for_size(size), Qnil);
+ io_buffer_initialize(self, &resized, NULL, size, io_flags_for_size(size), Qnil);
- if (data->base) {
- size_t preserve = data->size;
+ if (buffer->base) {
+ size_t preserve = buffer->size;
if (preserve > size) preserve = size;
- memcpy(resized.base, data->base, preserve);
+ memcpy(resized.base, buffer->base, preserve);
- io_buffer_resize_clear(data, resized.base, size);
+ io_buffer_resize_clear(buffer, resized.base, size);
}
- io_buffer_free(data);
- *data = resized;
+ io_buffer_free(buffer);
+ *buffer = resized;
}
void
rb_io_buffer_resize(VALUE self, size_t size)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Cannot resize locked buffer!");
}
- if (data->base == NULL) {
- io_buffer_initialize(data, NULL, size, io_flags_for_size(size), Qnil);
+ if (buffer->base == NULL) {
+ io_buffer_initialize(self, buffer, NULL, size, io_flags_for_size(size), Qnil);
return;
}
- if (data->flags & RB_IO_BUFFER_EXTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_EXTERNAL) {
rb_raise(rb_eIOBufferAccessError, "Cannot resize external buffer!");
}
#if defined(HAVE_MREMAP) && defined(MREMAP_MAYMOVE)
- if (data->flags & RB_IO_BUFFER_MAPPED) {
- void *base = mremap(data->base, data->size, size, MREMAP_MAYMOVE);
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
+ void *base = mremap(buffer->base, buffer->size, size, MREMAP_MAYMOVE);
if (base == MAP_FAILED) {
rb_sys_fail("rb_io_buffer_resize:mremap");
}
- io_buffer_resize_clear(data, base, size);
+ io_buffer_resize_clear(buffer, base, size);
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
return;
}
#endif
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
- void *base = realloc(data->base, size);
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
+ if (size == 0) {
+ io_buffer_free(buffer);
+ return;
+ }
+
+ void *base = realloc(buffer->base, size);
if (!base) {
rb_sys_fail("rb_io_buffer_resize:realloc");
}
- io_buffer_resize_clear(data, base, size);
+ io_buffer_resize_clear(buffer, base, size);
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
return;
}
- io_buffer_resize_copy(data, size);
+ io_buffer_resize_copy(self, buffer, size);
}
/*
@@ -1460,7 +1826,7 @@ rb_io_buffer_resize(VALUE self, size_t size)
static VALUE
io_buffer_resize(VALUE self, VALUE size)
{
- rb_io_buffer_resize(self, NUM2SIZET(size));
+ rb_io_buffer_resize(self, io_buffer_extract_size(size));
return self;
}
@@ -1492,9 +1858,9 @@ rb_io_buffer_compare(VALUE self, VALUE other)
}
static void
-io_buffer_validate_type(size_t size, size_t offset)
+io_buffer_validate_type(size_t size, size_t offset, size_t extend)
{
- if (offset > size) {
+ if (size_sum_is_bigger_than(offset, extend, size)) {
rb_raise(rb_eArgError, "Type extends beyond end of buffer! (offset=%"PRIdSIZE" > size=%"PRIdSIZE")", offset, size);
}
}
@@ -1514,6 +1880,9 @@ io_buffer_validate_type(size_t size, size_t offset)
// :u64, :U64 | unsigned 64-bit integer.
// :s64, :S64 | signed 64-bit integer.
//
+// :u128, :U128 | unsigned 128-bit integer.
+// :s128, :S128 | signed 128-bit integer.
+//
// :f32, :F32 | 32-bit floating point number.
// :f64, :F64 | 64-bit floating point number.
@@ -1545,13 +1914,53 @@ ruby_swapf64(double value)
return swap.value;
}
+// Structures and conversion functions are now in numeric.h/numeric.c
+// Unified swap function for 128-bit integers (works with both signed and unsigned)
+// Since both rb_uint128_t and rb_int128_t have the same memory layout,
+// we can use a union to make the swap function work with both types
+static inline rb_uint128_t
+ruby_swap128_uint(rb_uint128_t x)
+{
+ rb_uint128_t result;
+#ifdef HAVE_UINT128_T
+#if __has_builtin(__builtin_bswap128)
+ result.value = __builtin_bswap128(x.value);
+#else
+ // Manual byte swap for 128-bit integers
+ uint64_t low = (uint64_t)x.value;
+ uint64_t high = (uint64_t)(x.value >> 64);
+ low = ruby_swap64(low);
+ high = ruby_swap64(high);
+ result.value = ((uint128_t)low << 64) | high;
+#endif
+#else
+ // Fallback swap function using two 64-bit integers
+ // For big-endian data on little-endian host (or vice versa):
+ // 1. Swap bytes within each 64-bit part
+ // 2. Swap the order of the parts (since big-endian stores high first, little-endian stores low first)
+ result.parts.low = ruby_swap64(x.parts.high);
+ result.parts.high = ruby_swap64(x.parts.low);
+#endif
+ return result;
+}
+
+static inline rb_int128_t
+ruby_swap128_int(rb_int128_t x)
+{
+ union uint128_int128_conversion conversion = {
+ .int128 = x
+ };
+ conversion.uint128 = ruby_swap128_uint(conversion.uint128);
+ return conversion.int128;
+}
+
#define IO_BUFFER_DECLARE_TYPE(name, type, endian, wrap, unwrap, swap) \
static ID RB_IO_BUFFER_DATA_TYPE_##name; \
\
static VALUE \
io_buffer_read_##name(const void* base, size_t size, size_t *offset) \
{ \
- io_buffer_validate_type(size, *offset + sizeof(type)); \
+ io_buffer_validate_type(size, *offset, sizeof(type)); \
type value; \
memcpy(&value, (char*)base + *offset, sizeof(type)); \
if (endian != RB_IO_BUFFER_HOST_ENDIAN) value = swap(value); \
@@ -1562,7 +1971,7 @@ io_buffer_read_##name(const void* base, size_t size, size_t *offset) \
static void \
io_buffer_write_##name(const void* base, size_t size, size_t *offset, VALUE _value) \
{ \
- io_buffer_validate_type(size, *offset + sizeof(type)); \
+ io_buffer_validate_type(size, *offset, sizeof(type)); \
type value = unwrap(_value); \
if (endian != RB_IO_BUFFER_HOST_ENDIAN) value = swap(value); \
memcpy((char*)base + *offset, &value, sizeof(type)); \
@@ -1591,6 +2000,11 @@ IO_BUFFER_DECLARE_TYPE(U64, uint64_t, RB_IO_BUFFER_BIG_ENDIAN, RB_ULL2NUM, RB_NU
IO_BUFFER_DECLARE_TYPE(s64, int64_t, RB_IO_BUFFER_LITTLE_ENDIAN, RB_LL2NUM, RB_NUM2LL, ruby_swap64)
IO_BUFFER_DECLARE_TYPE(S64, int64_t, RB_IO_BUFFER_BIG_ENDIAN, RB_LL2NUM, RB_NUM2LL, ruby_swap64)
+IO_BUFFER_DECLARE_TYPE(u128, rb_uint128_t, RB_IO_BUFFER_LITTLE_ENDIAN, rb_uint128_to_numeric, rb_numeric_to_uint128, ruby_swap128_uint)
+IO_BUFFER_DECLARE_TYPE(U128, rb_uint128_t, RB_IO_BUFFER_BIG_ENDIAN, rb_uint128_to_numeric, rb_numeric_to_uint128, ruby_swap128_uint)
+IO_BUFFER_DECLARE_TYPE(s128, rb_int128_t, RB_IO_BUFFER_LITTLE_ENDIAN, rb_int128_to_numeric, rb_numeric_to_int128, ruby_swap128_int)
+IO_BUFFER_DECLARE_TYPE(S128, rb_int128_t, RB_IO_BUFFER_BIG_ENDIAN, rb_int128_to_numeric, rb_numeric_to_int128, ruby_swap128_int)
+
IO_BUFFER_DECLARE_TYPE(f32, float, RB_IO_BUFFER_LITTLE_ENDIAN, DBL2NUM, NUM2DBL, ruby_swapf32)
IO_BUFFER_DECLARE_TYPE(F32, float, RB_IO_BUFFER_BIG_ENDIAN, DBL2NUM, NUM2DBL, ruby_swapf32)
IO_BUFFER_DECLARE_TYPE(f64, double, RB_IO_BUFFER_LITTLE_ENDIAN, DBL2NUM, NUM2DBL, ruby_swapf64)
@@ -1598,9 +2012,9 @@ IO_BUFFER_DECLARE_TYPE(F64, double, RB_IO_BUFFER_BIG_ENDIAN, DBL2NUM, NUM2DBL, r
#undef IO_BUFFER_DECLARE_TYPE
static inline size_t
-io_buffer_data_type_size(ID data_type)
+io_buffer_buffer_type_size(ID buffer_type)
{
-#define IO_BUFFER_DATA_TYPE_SIZE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) return RB_IO_BUFFER_DATA_TYPE_##name##_SIZE;
+#define IO_BUFFER_DATA_TYPE_SIZE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) return RB_IO_BUFFER_DATA_TYPE_##name##_SIZE;
IO_BUFFER_DATA_TYPE_SIZE(U8)
IO_BUFFER_DATA_TYPE_SIZE(S8)
IO_BUFFER_DATA_TYPE_SIZE(u16)
@@ -1615,6 +2029,10 @@ io_buffer_data_type_size(ID data_type)
IO_BUFFER_DATA_TYPE_SIZE(U64)
IO_BUFFER_DATA_TYPE_SIZE(s64)
IO_BUFFER_DATA_TYPE_SIZE(S64)
+ IO_BUFFER_DATA_TYPE_SIZE(u128)
+ IO_BUFFER_DATA_TYPE_SIZE(U128)
+ IO_BUFFER_DATA_TYPE_SIZE(s128)
+ IO_BUFFER_DATA_TYPE_SIZE(S128)
IO_BUFFER_DATA_TYPE_SIZE(f32)
IO_BUFFER_DATA_TYPE_SIZE(F32)
IO_BUFFER_DATA_TYPE_SIZE(f64)
@@ -1626,35 +2044,33 @@ io_buffer_data_type_size(ID data_type)
/*
* call-seq:
- * size_of(data_type) -> byte size
- * size_of(array of data_type) -> byte size
- *
- * Returns the size of the given data type(s) in bytes.
+ * size_of(buffer_type) -> byte size
+ * size_of(array of buffer_type) -> byte size
*
- * Example:
+ * Returns the size of the given buffer type(s) in bytes.
*
* IO::Buffer.size_of(:u32) # => 4
* IO::Buffer.size_of([:u32, :u32]) # => 8
*/
static VALUE
-io_buffer_size_of(VALUE klass, VALUE data_type)
+io_buffer_size_of(VALUE klass, VALUE buffer_type)
{
- if (RB_TYPE_P(data_type, T_ARRAY)) {
+ if (RB_TYPE_P(buffer_type, T_ARRAY)) {
size_t total = 0;
- for (long i = 0; i < RARRAY_LEN(data_type); i++) {
- total += io_buffer_data_type_size(RB_SYM2ID(RARRAY_AREF(data_type, i)));
+ for (long i = 0; i < RARRAY_LEN(buffer_type); i++) {
+ total += io_buffer_buffer_type_size(RB_SYM2ID(RARRAY_AREF(buffer_type, i)));
}
return SIZET2NUM(total);
}
else {
- return SIZET2NUM(io_buffer_data_type_size(RB_SYM2ID(data_type)));
+ return SIZET2NUM(io_buffer_buffer_type_size(RB_SYM2ID(buffer_type)));
}
}
static inline VALUE
-rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offset)
+rb_io_buffer_get_value(const void* base, size_t size, ID buffer_type, size_t *offset)
{
-#define IO_BUFFER_GET_VALUE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) return io_buffer_read_##name(base, size, offset);
+#define IO_BUFFER_GET_VALUE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) return io_buffer_read_##name(base, size, offset);
IO_BUFFER_GET_VALUE(U8)
IO_BUFFER_GET_VALUE(S8)
@@ -1673,6 +2089,11 @@ rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offs
IO_BUFFER_GET_VALUE(s64)
IO_BUFFER_GET_VALUE(S64)
+ IO_BUFFER_GET_VALUE(u128)
+ IO_BUFFER_GET_VALUE(U128)
+ IO_BUFFER_GET_VALUE(s128)
+ IO_BUFFER_GET_VALUE(S128)
+
IO_BUFFER_GET_VALUE(f32)
IO_BUFFER_GET_VALUE(F32)
IO_BUFFER_GET_VALUE(f64)
@@ -1683,9 +2104,9 @@ rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offs
}
/*
- * call-seq: get_value(data_type, offset) -> numeric
+ * call-seq: get_value(buffer_type, offset) -> numeric
*
- * Read from buffer a value of +type+ at +offset+. +data_type+ should be one
+ * Read from buffer a value of +type+ at +offset+. +buffer_type+ should be one
* of symbols:
*
* * +:U8+: unsigned integer, 1 byte
@@ -1702,17 +2123,19 @@ rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offs
* * +:U64+: unsigned integer, 8 bytes, big-endian
* * +:s64+: signed integer, 8 bytes, little-endian
* * +:S64+: signed integer, 8 bytes, big-endian
+ * * +:u128+: unsigned integer, 16 bytes, little-endian
+ * * +:U128+: unsigned integer, 16 bytes, big-endian
+ * * +:s128+: signed integer, 16 bytes, little-endian
+ * * +:S128+: signed integer, 16 bytes, big-endian
* * +:f32+: float, 4 bytes, little-endian
* * +:F32+: float, 4 bytes, big-endian
* * +:f64+: double, 8 bytes, little-endian
* * +:F64+: double, 8 bytes, big-endian
*
- * A data type refers specifically to the type of binary data that is stored
- * in the buffer. For example, a +:u32+ data type is a 32-bit unsigned
+ * A buffer type refers specifically to the type of binary buffer that is stored
+ * in the buffer. For example, a +:u32+ buffer type is a 32-bit unsigned
* integer in little-endian format.
*
- * Example:
- *
* string = [1.5].pack('f')
* # => "\x00\x00\xC0?"
* IO::Buffer.for(string).get_value(:f32, 0)
@@ -1723,7 +2146,7 @@ io_buffer_get_value(VALUE self, VALUE type, VALUE _offset)
{
const void *base;
size_t size;
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
@@ -1731,34 +2154,32 @@ io_buffer_get_value(VALUE self, VALUE type, VALUE _offset)
}
/*
- * call-seq: get_values(data_types, offset) -> array
+ * call-seq: get_values(buffer_types, offset) -> array
*
- * Similar to #get_value, except that it can handle multiple data types and
+ * Similar to #get_value, except that it can handle multiple buffer types and
* returns an array of values.
*
- * Example:
- *
* string = [1.5, 2.5].pack('ff')
* IO::Buffer.for(string).get_values([:f32, :f32], 0)
* # => [1.5, 2.5]
*/
static VALUE
-io_buffer_get_values(VALUE self, VALUE data_types, VALUE _offset)
+io_buffer_get_values(VALUE self, VALUE buffer_types, VALUE _offset)
{
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
const void *base;
size_t size;
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- if (!RB_TYPE_P(data_types, T_ARRAY)) {
- rb_raise(rb_eArgError, "Argument data_types should be an array!");
+ if (!RB_TYPE_P(buffer_types, T_ARRAY)) {
+ rb_raise(rb_eArgError, "Argument buffer_types should be an array!");
}
- VALUE array = rb_ary_new_capa(RARRAY_LEN(data_types));
+ VALUE array = rb_ary_new_capa(RARRAY_LEN(buffer_types));
- for (long i = 0; i < RARRAY_LEN(data_types); i++) {
- VALUE type = rb_ary_entry(data_types, i);
+ for (long i = 0; i < RARRAY_LEN(buffer_types); i++) {
+ VALUE type = rb_ary_entry(buffer_types, i);
VALUE value = rb_io_buffer_get_value(base, size, RB_SYM2ID(type), &offset);
rb_ary_push(array, value);
}
@@ -1766,18 +2187,50 @@ io_buffer_get_values(VALUE self, VALUE data_types, VALUE _offset)
return array;
}
+// Extract a count argument, which must be a positive integer.
+// Count is generally considered relative to the number of things.
+static inline size_t
+io_buffer_extract_count(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Count can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+static inline void
+io_buffer_extract_offset_count(ID buffer_type, size_t size, int argc, VALUE *argv, size_t *offset, size_t *count)
+{
+ if (argc >= 1) {
+ *offset = io_buffer_extract_offset(argv[0]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 2) {
+ *count = io_buffer_extract_count(argv[1]);
+ }
+ else {
+ if (*offset > size) {
+ rb_raise(rb_eArgError, "The given offset is bigger than the buffer size!");
+ }
+
+ *count = (size - *offset) / io_buffer_buffer_type_size(buffer_type);
+ }
+}
+
/*
* call-seq:
- * each(data_type, [offset, [count]]) {|offset, value| ...} -> self
- * each(data_type, [offset, [count]]) -> enumerator
+ * each(buffer_type, [offset, [count]]) {|offset, value| ...} -> self
+ * each(buffer_type, [offset, [count]]) -> enumerator
*
- * Iterates over the buffer, yielding each +value+ of +data_type+ starting
+ * Iterates over the buffer, yielding each +value+ of +buffer_type+ starting
* from +offset+.
*
* If +count+ is given, only +count+ values will be yielded.
*
- * Example:
- *
* IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value|
* puts "#{offset}: #{value}"
* end
@@ -1794,33 +2247,20 @@ io_buffer_each(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- ID data_type;
+ ID buffer_type;
if (argc >= 1) {
- data_type = RB_SYM2ID(argv[0]);
+ buffer_type = RB_SYM2ID(argv[0]);
}
else {
- data_type = RB_IO_BUFFER_DATA_TYPE_U8;
+ buffer_type = RB_IO_BUFFER_DATA_TYPE_U8;
}
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- }
- else {
- offset = 0;
- }
-
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- }
- else {
- count = (size - offset) / io_buffer_data_type_size(data_type);
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(buffer_type, size, argc-1, argv+1, &offset, &count);
for (size_t i = 0; i < count; i++) {
size_t current_offset = offset;
- VALUE value = rb_io_buffer_get_value(base, size, data_type, &offset);
+ VALUE value = rb_io_buffer_get_value(base, size, buffer_type, &offset);
rb_yield_values(2, SIZET2NUM(current_offset), value);
}
@@ -1828,14 +2268,12 @@ io_buffer_each(int argc, VALUE *argv, VALUE self)
}
/*
- * call-seq: values(data_type, [offset, [count]]) -> array
+ * call-seq: values(buffer_type, [offset, [count]]) -> array
*
- * Returns an array of values of +data_type+ starting from +offset+.
+ * Returns an array of values of +buffer_type+ starting from +offset+.
*
* If +count+ is given, only +count+ values will be returned.
*
- * Example:
- *
* IO::Buffer.for("Hello World").values(:U8, 2, 2)
* # => [108, 108]
*/
@@ -1847,34 +2285,21 @@ io_buffer_values(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- ID data_type;
+ ID buffer_type;
if (argc >= 1) {
- data_type = RB_SYM2ID(argv[0]);
- }
- else {
- data_type = RB_IO_BUFFER_DATA_TYPE_U8;
- }
-
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
+ buffer_type = RB_SYM2ID(argv[0]);
}
else {
- offset = 0;
+ buffer_type = RB_IO_BUFFER_DATA_TYPE_U8;
}
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- }
- else {
- count = (size - offset) / io_buffer_data_type_size(data_type);
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(buffer_type, size, argc-1, argv+1, &offset, &count);
VALUE array = rb_ary_new_capa(count);
for (size_t i = 0; i < count; i++) {
- VALUE value = rb_io_buffer_get_value(base, size, data_type, &offset);
+ VALUE value = rb_io_buffer_get_value(base, size, buffer_type, &offset);
rb_ary_push(array, value);
}
@@ -1883,15 +2308,13 @@ io_buffer_values(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * each_byte([offset, [count]]) {|offset, byte| ...} -> self
+ * each_byte([offset, [count]]) {|byte| ...} -> self
* each_byte([offset, [count]]) -> enumerator
*
* Iterates over the buffer, yielding each byte starting from +offset+.
*
* If +count+ is given, only +count+ bytes will be yielded.
*
- * Example:
- *
* IO::Buffer.for("Hello World").each_byte(2, 2) do |offset, byte|
* puts "#{offset}: #{byte}"
* end
@@ -1908,20 +2331,11 @@ io_buffer_each_byte(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- }
- else {
- offset = 0;
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(RB_IO_BUFFER_DATA_TYPE_U8, size, argc, argv, &offset, &count);
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- }
- else {
- count = (size - offset);
+ if (size_sum_is_bigger_than(offset, count, size)) {
+ rb_raise(rb_eArgError, "Specified offset+count is bigger than the buffer size!");
}
for (size_t i = 0; i < count; i++) {
@@ -1933,9 +2347,9 @@ io_buffer_each_byte(int argc, VALUE *argv, VALUE self)
}
static inline void
-rb_io_buffer_set_value(const void* base, size_t size, ID data_type, size_t *offset, VALUE value)
+rb_io_buffer_set_value(const void* base, size_t size, ID buffer_type, size_t *offset, VALUE value)
{
-#define IO_BUFFER_SET_VALUE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) {io_buffer_write_##name(base, size, offset, value); return;}
+#define IO_BUFFER_SET_VALUE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) {io_buffer_write_##name(base, size, offset, value); return;}
IO_BUFFER_SET_VALUE(U8);
IO_BUFFER_SET_VALUE(S8);
@@ -1954,6 +2368,11 @@ rb_io_buffer_set_value(const void* base, size_t size, ID data_type, size_t *offs
IO_BUFFER_SET_VALUE(s64);
IO_BUFFER_SET_VALUE(S64);
+ IO_BUFFER_SET_VALUE(u128);
+ IO_BUFFER_SET_VALUE(U128);
+ IO_BUFFER_SET_VALUE(s128);
+ IO_BUFFER_SET_VALUE(S128);
+
IO_BUFFER_SET_VALUE(f32);
IO_BUFFER_SET_VALUE(F32);
IO_BUFFER_SET_VALUE(f64);
@@ -1998,7 +2417,7 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
{
void *base;
size_t size;
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
rb_io_buffer_get_bytes_for_writing(self, &base, &size);
@@ -2008,14 +2427,12 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
}
/*
- * call-seq: set_values(data_types, offset, values) -> offset
+ * call-seq: set_values(buffer_types, offset, values) -> offset
*
- * Write +values+ of +data_types+ at +offset+ to the buffer. +data_types+
+ * Write +values+ of +buffer_types+ at +offset+ to the buffer. +buffer_types+
* should be an array of symbols as described in #get_value. +values+ should
* be an array of values to write.
*
- * Example:
- *
* buffer = IO::Buffer.new(8)
* buffer.set_values([:U8, :U16], 0, [1, 2])
* buffer
@@ -2024,28 +2441,28 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
* # 0x00000000 01 00 02 00 00 00 00 00 ........
*/
static VALUE
-io_buffer_set_values(VALUE self, VALUE data_types, VALUE _offset, VALUE values)
+io_buffer_set_values(VALUE self, VALUE buffer_types, VALUE _offset, VALUE values)
{
- if (!RB_TYPE_P(data_types, T_ARRAY)) {
- rb_raise(rb_eArgError, "Argument data_types should be an array!");
+ if (!RB_TYPE_P(buffer_types, T_ARRAY)) {
+ rb_raise(rb_eArgError, "Argument buffer_types should be an array!");
}
if (!RB_TYPE_P(values, T_ARRAY)) {
rb_raise(rb_eArgError, "Argument values should be an array!");
}
- if (RARRAY_LEN(data_types) != RARRAY_LEN(values)) {
- rb_raise(rb_eArgError, "Argument data_types and values should have the same length!");
+ if (RARRAY_LEN(buffer_types) != RARRAY_LEN(values)) {
+ rb_raise(rb_eArgError, "Argument buffer_types and values should have the same length!");
}
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
void *base;
size_t size;
rb_io_buffer_get_bytes_for_writing(self, &base, &size);
- for (long i = 0; i < RARRAY_LEN(data_types); i++) {
- VALUE type = rb_ary_entry(data_types, i);
+ for (long i = 0; i < RARRAY_LEN(buffer_types); i++) {
+ VALUE type = rb_ary_entry(buffer_types, i);
VALUE value = rb_ary_entry(values, i);
rb_io_buffer_set_value(base, size, RB_SYM2ID(type), &offset, value);
}
@@ -2053,41 +2470,72 @@ io_buffer_set_values(VALUE self, VALUE data_types, VALUE _offset, VALUE values)
return SIZET2NUM(offset);
}
+static size_t IO_BUFFER_BLOCKING_SIZE = 1024*1024;
+
+struct io_buffer_memmove_arguments {
+ unsigned char * destination;
+ const unsigned char * source;
+ size_t length;
+};
+
+static void *
+io_buffer_memmove_blocking(void *data)
+{
+ struct io_buffer_memmove_arguments *arguments = (struct io_buffer_memmove_arguments *)data;
+
+ memmove(arguments->destination, arguments->source, arguments->length);
+
+ return NULL;
+}
+
static void
-io_buffer_memcpy(struct rb_io_buffer *data, size_t offset, const void *source_base, size_t source_offset, size_t source_size, size_t length)
+io_buffer_memmove_unblock(void *data)
+{
+ // No safe way to interrupt.
+}
+
+static void
+io_buffer_memmove(struct rb_io_buffer *buffer, size_t offset, const void *source_base, size_t source_offset, size_t source_size, size_t length)
{
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
- if (source_offset + length > source_size) {
- rb_raise(rb_eArgError, "The computed source range exceeds the size of the source!");
+ if (size_sum_is_bigger_than(source_offset, length, source_size)) {
+ rb_raise(rb_eArgError, "The computed source range exceeds the size of the source buffer!");
}
- memcpy((unsigned char*)base+offset, (unsigned char*)source_base+source_offset, length);
+ struct io_buffer_memmove_arguments arguments = {
+ .destination = (unsigned char*)base+offset,
+ .source = (unsigned char*)source_base+source_offset,
+ .length = length
+ };
+
+ if (arguments.length >= IO_BUFFER_BLOCKING_SIZE) {
+ rb_nogvl(io_buffer_memmove_blocking, &arguments, io_buffer_memmove_unblock, &arguments, RB_NOGVL_OFFLOAD_SAFE);
+ } else if (arguments.length != 0) {
+ memmove(arguments.destination, arguments.source, arguments.length);
+ }
}
// (offset, length, source_offset) -> length
static VALUE
-io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t source_size, int argc, VALUE *argv)
+io_buffer_copy_from(struct rb_io_buffer *buffer, const void *source_base, size_t source_size, int argc, VALUE *argv)
{
- size_t offset;
+ size_t offset = 0;
size_t length;
size_t source_offset;
// The offset we copy into the buffer:
if (argc >= 1) {
- offset = NUM2SIZET(argv[0]);
- }
- else {
- offset = 0;
+ offset = io_buffer_extract_offset(argv[0]);
}
// The offset we start from within the string:
if (argc >= 3) {
- source_offset = NUM2SIZET(argv[2]);
+ source_offset = io_buffer_extract_offset(argv[2]);
if (source_offset > source_size) {
rb_raise(rb_eArgError, "The given source offset is bigger than the source itself!");
@@ -2099,14 +2547,14 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
// The length we are going to copy:
if (argc >= 2 && !RB_NIL_P(argv[1])) {
- length = NUM2SIZET(argv[1]);
+ length = io_buffer_extract_length(argv[1]);
}
else {
// Default to the source offset -> source size:
length = source_size - source_offset;
}
- io_buffer_memcpy(data, offset, source_base, source_offset, source_size, length);
+ io_buffer_memmove(buffer, offset, source_base, source_offset, source_size, length);
return SIZET2NUM(length);
}
@@ -2131,25 +2579,27 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
static VALUE
rb_io_buffer_initialize_copy(VALUE self, VALUE source)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
const void *source_base;
size_t source_size;
rb_io_buffer_get_bytes_for_reading(source, &source_base, &source_size);
- io_buffer_initialize(data, NULL, source_size, io_flags_for_size(source_size), Qnil);
+ io_buffer_initialize(self, buffer, NULL, source_size, io_flags_for_size(source_size), Qnil);
- return io_buffer_copy_from(data, source_base, source_size, 0, NULL);
+ VALUE result = io_buffer_copy_from(buffer, source_base, source_size, 0, NULL);
+ RB_GC_GUARD(source);
+ return result;
}
/*
* call-seq:
* copy(source, [offset, [length, [source_offset]]]) -> size
*
- * Efficiently copy data from a source IO::Buffer into the buffer,
- * at +offset+ using +memcpy+. For copying String instances, see #set_string.
+ * Efficiently copy from a source IO::Buffer into the buffer, at +offset+
+ * using +memmove+. For copying String instances, see #set_string.
*
* buffer = IO::Buffer.new(32)
* # =>
@@ -2158,19 +2608,20 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
* # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *
*
* buffer.copy(IO::Buffer.for("test"), 8)
- * # => 4 -- size of data copied
+ * # => 4 -- size of buffer copied
* buffer
* # =>
* # #<IO::Buffer 0x0000555f5cf8fe40+32 INTERNAL>
* # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test....
* # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *
*
- * #copy can be used to put data into strings associated with buffer:
+ * #copy can be used to put buffer into strings associated with buffer:
*
- * string= "data: "
+ * string = "data: "
* # => "data: "
- * buffer = IO::Buffer.for(string)
- * buffer.copy(IO::Buffer.for("test"), 5)
+ * buffer = IO::Buffer.for(string) do |buffer|
+ * buffer.copy(IO::Buffer.for("test"), 5)
+ * end
* # => 4
* string
* # => "data:test"
@@ -2191,20 +2642,33 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
* File.read('test.txt')
* # => "boom"
*
- * Attempt to copy the data which will need place outside of buffer's
+ * Attempt to copy the buffer which will need place outside of buffer's
* bounds will fail:
*
* buffer = IO::Buffer.new(2)
* buffer.copy(IO::Buffer.for('test'), 0)
- * # in `copy': Specified offset+length exceeds source size! (ArgumentError)
+ * # in `copy': Specified offset+length is bigger than the buffer size! (ArgumentError)
+ *
+ * It is safe to copy between memory regions that overlaps each other.
+ * In such case, the data is copied as if the data was first copied from the source buffer to
+ * a temporary buffer, and then copied from the temporary buffer to the destination buffer.
+ *
+ * buffer = IO::Buffer.new(10)
+ * buffer.set_string("0123456789")
+ * buffer.copy(buffer, 3, 7)
+ * # => 7
+ * buffer
+ * # =>
+ * # #<IO::Buffer 0x000056494f8ce440+10 INTERNAL>
+ * # 0x00000000 30 31 32 30 31 32 33 34 35 36 0120123456
*/
static VALUE
io_buffer_copy(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, 4);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE source = argv[0];
const void *source_base;
@@ -2212,7 +2676,9 @@ io_buffer_copy(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(source, &source_base, &source_size);
- return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1);
+ VALUE result = io_buffer_copy_from(buffer, source_base, source_size, argc-1, argv+1);
+ RB_GC_GUARD(source);
+ return result;
}
/*
@@ -2234,33 +2700,22 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 3);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
const void *base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
-
- size_t offset = 0;
- size_t length = size;
- rb_encoding *encoding = rb_ascii8bit_encoding();
-
- if (argc >= 1) {
- offset = NUM2SIZET(argv[0]);
- }
-
- if (argc >= 2 && !RB_NIL_P(argv[1])) {
- length = NUM2SIZET(argv[1]);
- }
- else {
- length = size - offset;
- }
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+ rb_encoding *encoding;
if (argc >= 3) {
encoding = rb_find_encoding(argv[2]);
}
+ else {
+ encoding = rb_ascii8bit_encoding();
+ }
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
return rb_enc_str_new((const char*)base + offset, length, encoding);
}
@@ -2268,15 +2723,15 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self)
/*
* call-seq: set_string(string, [offset, [length, [source_offset]]]) -> size
*
- * Efficiently copy data from a source String into the buffer,
- * at +offset+ using +memcpy+.
+ * Efficiently copy from a source String into the buffer, at +offset+ using
+ * +memmove+.
*
* buf = IO::Buffer.new(8)
* # =>
* # #<IO::Buffer 0x0000557412714a20+8 INTERNAL>
* # 0x00000000 00 00 00 00 00 00 00 00 ........
*
- * # set data starting from offset 1, take 2 bytes starting from string's
+ * # set buffer starting from offset 1, take 2 bytes starting from string's
* # second
* buf.set_string('test', 1, 2, 1)
* # => 2
@@ -2293,28 +2748,30 @@ io_buffer_set_string(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, 4);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE string = rb_str_to_str(argv[0]);
const void *source_base = RSTRING_PTR(string);
size_t source_size = RSTRING_LEN(string);
- return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1);
+ VALUE result = io_buffer_copy_from(buffer, source_base, source_size, argc-1, argv+1);
+ RB_GC_GUARD(string);
+ return result;
}
void
rb_io_buffer_clear(VALUE self, uint8_t value, size_t offset, size_t length)
{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
void *base;
size_t size;
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- rb_io_buffer_get_bytes_for_writing(self, &base, &size);
-
- if (offset + length > size) {
- rb_raise(rb_eArgError, "The given offset + length out of bounds!");
- }
+ io_buffer_validate_range(buffer, offset, length);
memset((char*)base + offset, value, length);
}
@@ -2325,29 +2782,29 @@ rb_io_buffer_clear(VALUE self, uint8_t value, size_t offset, size_t length)
* Fill buffer with +value+, starting with +offset+ and going for +length+
* bytes.
*
- * buffer = IO::Buffer.for('test')
+ * buffer = IO::Buffer.for('test').dup
* # =>
- * # <IO::Buffer 0x00007fca40087c38+4 SLICE>
+ * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 74 65 73 74 test
*
* buffer.clear
* # =>
- * # <IO::Buffer 0x00007fca40087c38+4 SLICE>
+ * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 00 00 00 00 ....
*
* buf.clear(1) # fill with 1
* # =>
- * # <IO::Buffer 0x00007fca40087c38+4 SLICE>
+ * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 01 01 01 ....
*
* buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes
* # =>
- * # <IO::Buffer 0x00007fca40087c38+4 SLICE>
+ * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 02 02 01 ....
*
* buffer.clear(2, 1) # fill with 2, starting from offset 1
* # =>
- * # <IO::Buffer 0x00007fca40087c38+4 SLICE>
+ * # <IO::Buffer 0x00007fca40087c38+4 INTERNAL>
* # 0x00000000 01 02 02 02 ....
*/
static VALUE
@@ -2355,26 +2812,13 @@ io_buffer_clear(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 3);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
uint8_t value = 0;
if (argc >= 1) {
value = NUM2UINT(argv[0]);
}
- size_t offset = 0;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- }
-
- size_t length;
- if (argc >= 3) {
- length = NUM2SIZET(argv[2]);
- }
- else {
- length = data->size - offset;
- }
+ size_t offset, length;
+ io_buffer_extract_offset_length(self, argc-1, argv+1, &offset, &length);
rb_io_buffer_clear(self, value, offset, length);
@@ -2406,65 +2850,146 @@ io_buffer_default_size(size_t page_size)
return platform_agnostic_default_size;
}
+struct io_buffer_blocking_region_argument {
+ struct rb_io *io;
+ struct rb_io_buffer *buffer;
+ rb_blocking_function_t *function;
+ void *data;
+};
+
+static VALUE
+io_buffer_blocking_region_begin(VALUE _argument)
+{
+ struct io_buffer_blocking_region_argument *argument = (void*)_argument;
+
+ return rb_io_blocking_region(argument->io, argument->function, argument->data);
+}
+
+static VALUE
+io_buffer_blocking_region_ensure(VALUE _argument)
+{
+ struct io_buffer_blocking_region_argument *argument = (void*)_argument;
+
+ io_buffer_unlock(argument->buffer);
+
+ return Qnil;
+}
+
+static VALUE
+io_buffer_blocking_region(VALUE io, struct rb_io_buffer *buffer, rb_blocking_function_t *function, void *data)
+{
+ struct rb_io *ioptr;
+ RB_IO_POINTER(io, ioptr);
+
+ struct io_buffer_blocking_region_argument argument = {
+ .io = ioptr,
+ .buffer = buffer,
+ .function = function,
+ .data = data,
+ };
+
+ // If the buffer is already locked, we can skip the ensure (unlock):
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
+ return io_buffer_blocking_region_begin((VALUE)&argument);
+ }
+ else {
+ // The buffer should be locked for the duration of the blocking region:
+ io_buffer_lock(buffer);
+
+ return rb_ensure(io_buffer_blocking_region_begin, (VALUE)&argument, io_buffer_blocking_region_ensure, (VALUE)&argument);
+ }
+}
+
struct io_buffer_read_internal_argument {
+ // The file descriptor to read from:
int descriptor;
- void *base;
+ // The base pointer to read from:
+ char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum number of bytes to read:
+ size_t length;
};
static VALUE
io_buffer_read_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_read_internal_argument *argument = _argument;
- ssize_t result = read(argument->descriptor, argument->base, argument->size);
- return rb_fiber_scheduler_io_result(result, errno);
+
+ while (true) {
+ ssize_t result = read(argument->descriptor, argument->base, argument->size);
+
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
+
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ }
+ }
}
VALUE
rb_io_buffer_read(VALUE self, VALUE io, size_t length, size_t offset)
{
+ io = rb_io_get_io(io);
+
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_read(scheduler, io, self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_read(scheduler, io, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
void * base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_read_internal_argument argument = {
.descriptor = descriptor,
.base = base,
- .size = length,
+ .size = size,
+ .length = length,
};
- return rb_thread_io_blocking_region(io_buffer_read_internal, &argument, descriptor);
+ return io_buffer_blocking_region(io, buffer, io_buffer_read_internal, &argument);
}
/*
- * call-seq: read(io, length, [offset]) -> read length or -errno
+ * call-seq: read(io, [length, [offset]]) -> read length or -errno
*
- * Read at most +length+ bytes from +io+ into the buffer, starting at
+ * Read at least +length+ bytes from the +io+, into the buffer starting at
* +offset+. If an error occurs, return <tt>-errno</tt>.
*
- * If +offset+ is not given, read from the beginning of the buffer.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * If +length+ is 0, read nothing.
+ * If +length+ is zero, exactly one <tt>read</tt> operation will occur.
*
- * Example:
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* IO::Buffer.for('test') do |buffer|
* p buffer
@@ -2481,108 +3006,111 @@ rb_io_buffer_read(VALUE self, VALUE io, size_t length, size_t offset)
static VALUE
io_buffer_read(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 2, 3);
+ rb_check_arity(argc, 1, 3);
VALUE io = argv[0];
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- size_t length = NUM2SIZET(argv[1]);
-
- size_t offset = 0;
- if (argc >= 3) {
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[2]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-1, argv+1, &length, &offset);
return rb_io_buffer_read(self, io, length, offset);
}
struct io_buffer_pread_internal_argument {
+ // The file descriptor to read from:
int descriptor;
- void *base;
+ // The base pointer to read from:
+ char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum number of bytes to read:
+ size_t length;
+ // The offset to read from:
off_t offset;
};
static VALUE
io_buffer_pread_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_pread_internal_argument *argument = _argument;
-#if defined(HAVE_PREAD)
- ssize_t result = pread(argument->descriptor, argument->base, argument->size, argument->offset);
-#else
- // This emulation is not thread safe.
- rb_off_t offset = lseek(argument->descriptor, 0, SEEK_CUR);
- if (offset == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-
- if (lseek(argument->descriptor, argument->offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
+ while (true) {
+ ssize_t result = pread(argument->descriptor, argument->base, argument->size, argument->offset);
- ssize_t result = read(argument->descriptor, argument->base, argument->size);
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
- if (lseek(argument->descriptor, offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-#endif
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
- return rb_fiber_scheduler_io_result(result, errno);
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ argument->offset = argument->offset + result;
+ }
+ }
}
VALUE
rb_io_buffer_pread(VALUE self, VALUE io, rb_off_t from, size_t length, size_t offset)
{
+ io = rb_io_get_io(io);
+
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_pread(scheduler, io, OFFT2NUM(from), self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_pread(scheduler, io, from, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
void * base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
+
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_pread_internal_argument argument = {
.descriptor = descriptor,
-
- // Move the base pointer to the offset:
- .base = (unsigned char*)base + offset,
-
- // And the size to the length of data we want to read:
- .size = length,
-
- // From the offset in the file we want to read from:
+ .base = base,
+ .size = size,
+ .length = length,
.offset = from,
};
- return rb_thread_io_blocking_region(io_buffer_pread_internal, &argument, descriptor);
+ return io_buffer_blocking_region(io, buffer, io_buffer_pread_internal, &argument);
}
/*
- * call-seq: pread(io, from, length, [offset]) -> read length or -errno
+ * call-seq: pread(io, from, [length, [offset]]) -> read length or -errno
*
- * Read at most +length+ bytes from +io+ into the buffer, starting at
- * +from+, and put it in buffer starting from specified +offset+.
- * If an error occurs, return <tt>-errno</tt>.
+ * Read at least +length+ bytes from the +io+ starting at the specified +from+
+ * position, into the buffer starting at +offset+. If an error occurs,
+ * return <tt>-errno</tt>.
*
- * If +offset+ is not given, put it at the beginning of the buffer.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * Example:
+ * If +length+ is zero, exactly one <tt>pread</tt> operation will occur.
+ *
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* IO::Buffer.for('test') do |buffer|
* p buffer
@@ -2602,85 +3130,107 @@ rb_io_buffer_pread(VALUE self, VALUE io, rb_off_t from, size_t length, size_t of
static VALUE
io_buffer_pread(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 3, 4);
+ rb_check_arity(argc, 2, 4);
VALUE io = argv[0];
rb_off_t from = NUM2OFFT(argv[1]);
- size_t length;
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- length = NUM2SIZET(argv[2]);
-
- size_t offset = 0;
- if (argc >= 4) {
- if (rb_int_negative_p(argv[3])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[3]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-2, argv+2, &length, &offset);
return rb_io_buffer_pread(self, io, from, length, offset);
}
struct io_buffer_write_internal_argument {
+ // The file descriptor to write to:
int descriptor;
- const void *base;
+ // The base pointer to write from:
+ const char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum length to write:
+ size_t length;
};
static VALUE
io_buffer_write_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_write_internal_argument *argument = _argument;
- ssize_t result = write(argument->descriptor, argument->base, argument->size);
- return rb_fiber_scheduler_io_result(result, errno);
+
+ while (true) {
+ ssize_t result = write(argument->descriptor, argument->base, argument->size);
+
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
+
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ }
+ }
}
VALUE
rb_io_buffer_write(VALUE self, VALUE io, size_t length, size_t offset)
{
+ io = rb_io_get_write_io(rb_io_get_io(io));
+
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_write(scheduler, io, self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_write(scheduler, io, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
const void * base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
- base = (unsigned char *)base + offset;
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_write_internal_argument argument = {
.descriptor = descriptor,
.base = base,
- .size = length,
+ .size = size,
+ .length = length,
};
- return rb_thread_io_blocking_region(io_buffer_write_internal, &argument, descriptor);
+ return io_buffer_blocking_region(io, buffer, io_buffer_write_internal, &argument);
}
/*
- * call-seq: write(io, length, [offset]) -> written length or -errno
+ * call-seq: write(io, [length, [offset]]) -> written length or -errno
*
- * Writes +length+ bytes from buffer into +io+, starting at
- * +offset+ in the buffer. If an error occurs, return <tt>-errno</tt>.
+ * Write at least +length+ bytes from the buffer starting at +offset+, into the +io+.
+ * If an error occurs, return <tt>-errno</tt>.
*
- * If +offset+ is not given, the bytes are taken from the beginning
- * of the buffer.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
+ *
+ * If +length+ is zero, exactly one <tt>write</tt> operation will occur.
+ *
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* out = File.open('output.txt', 'wb')
* IO::Buffer.for('1234567').write(out, 3)
@@ -2690,107 +3240,122 @@ rb_io_buffer_write(VALUE self, VALUE io, size_t length, size_t offset)
static VALUE
io_buffer_write(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 2, 3);
+ rb_check_arity(argc, 1, 3);
VALUE io = argv[0];
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- size_t length = NUM2SIZET(argv[1]);
-
- size_t offset = 0;
- if (argc >= 3) {
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[2]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-1, argv+1, &length, &offset);
return rb_io_buffer_write(self, io, length, offset);
}
struct io_buffer_pwrite_internal_argument {
+ // The file descriptor to write to:
int descriptor;
- const void *base;
+ // The base pointer to write from:
+ const char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum length to write:
+ size_t length;
+ // The offset to write to:
off_t offset;
};
static VALUE
io_buffer_pwrite_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_pwrite_internal_argument *argument = _argument;
-#if defined(HAVE_PWRITE)
- ssize_t result = pwrite(argument->descriptor, argument->base, argument->size, argument->offset);
-#else
- // This emulation is not thread safe.
- rb_off_t offset = lseek(argument->descriptor, 0, SEEK_CUR);
- if (offset == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-
- if (lseek(argument->descriptor, argument->offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
+ while (true) {
+ ssize_t result = pwrite(argument->descriptor, argument->base, argument->size, argument->offset);
- ssize_t result = write(argument->descriptor, argument->base, argument->size);
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
- if (lseek(argument->descriptor, offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-#endif
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
- return rb_fiber_scheduler_io_result(result, errno);
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ argument->offset = argument->offset + result;
+ }
+ }
}
VALUE
rb_io_buffer_pwrite(VALUE self, VALUE io, rb_off_t from, size_t length, size_t offset)
{
+ io = rb_io_get_write_io(rb_io_get_io(io));
+
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_pwrite(scheduler, io, OFFT2NUM(from), self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_pwrite(scheduler, io, from, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
const void * base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_pwrite_internal_argument argument = {
.descriptor = descriptor,
// Move the base pointer to the offset:
- .base = (unsigned char *)base + offset,
+ .base = base,
- // And the size to the length of data we want to read:
- .size = length,
+ // And the size to the length of buffer we want to read:
+ .size = size,
+
+ // And the length of the buffer we want to write:
+ .length = length,
// And the offset in the file we want to write from:
.offset = from,
};
- return rb_thread_io_blocking_region(io_buffer_pwrite_internal, &argument, descriptor);
+ return io_buffer_blocking_region(io, buffer, io_buffer_pwrite_internal, &argument);
}
/*
- * call-seq: pwrite(io, from, length, [offset]) -> written length or -errno
+ * call-seq: pwrite(io, from, [length, [offset]]) -> written length or -errno
+ *
+ * Write at least +length+ bytes from the buffer starting at +offset+, into
+ * the +io+ starting at the specified +from+ position. If an error occurs,
+ * return <tt>-errno</tt>.
+ *
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * Writes +length+ bytes from buffer into +io+, starting at
- * +offset+ in the buffer. If an error occurs, return <tt>-errno</tt>.
+ * If +length+ is zero, exactly one <tt>pwrite</tt> operation will occur.
*
- * If +offset+ is not given, the bytes are taken from the beginning of the
- * buffer. If the +offset+ is given and is beyond the end of the file, the
- * gap will be filled with null (0 value) bytes.
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
+ *
+ * If the +from+ position is beyond the end of the file, the gap will be
+ * filled with null (0 value) bytes.
*
* out = File.open('output.txt', File::RDWR) # open for read/write, no truncation
* IO::Buffer.for('1234567').pwrite(out, 2, 3, 1)
@@ -2801,38 +3366,26 @@ rb_io_buffer_pwrite(VALUE self, VALUE io, rb_off_t from, size_t length, size_t o
static VALUE
io_buffer_pwrite(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 3, 4);
+ rb_check_arity(argc, 2, 4);
VALUE io = argv[0];
rb_off_t from = NUM2OFFT(argv[1]);
- size_t length;
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- length = NUM2SIZET(argv[2]);
-
- size_t offset = 0;
- if (argc >= 4) {
- if (rb_int_negative_p(argv[3])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[3]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-2, argv+2, &length, &offset);
return rb_io_buffer_pwrite(self, io, from, length, offset);
}
static inline void
-io_buffer_check_mask(const struct rb_io_buffer *buffer)
+io_buffer_check_mask_size(size_t size)
{
- if (buffer->size == 0)
+ if (size == 0)
rb_raise(rb_eIOBufferMaskError, "Zero-length mask given!");
}
static void
-memory_and(unsigned char * restrict output, unsigned char * restrict base, size_t size, unsigned char * restrict mask, size_t mask_size)
+memory_and(unsigned char * restrict output, const unsigned char * restrict base, size_t size, const unsigned char * restrict mask, size_t mask_size)
{
for (size_t offset = 0; offset < size; offset += 1) {
output[offset] = base[offset] & mask[offset % mask_size];
@@ -2854,25 +3407,33 @@ memory_and(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_and(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
+ const void *base;
+ size_t size;
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+
+ const void *mask_base;
+ size_t mask_size;
+ io_buffer_get_bytes_for_reading(mask_buffer, &mask_base, &mask_size);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ io_buffer_check_mask_size(mask_size);
- memory_and(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ VALUE output = rb_io_buffer_new(NULL, size, io_flags_for_size(size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
+
+ memory_and(output_buffer->base, base, size, mask_base, mask_size);
return output;
}
static void
-memory_or(unsigned char * restrict output, unsigned char * restrict base, size_t size, unsigned char * restrict mask, size_t mask_size)
+memory_or(unsigned char * restrict output, const unsigned char * restrict base, size_t size, const unsigned char * restrict mask, size_t mask_size)
{
for (size_t offset = 0; offset < size; offset += 1) {
output[offset] = base[offset] | mask[offset % mask_size];
@@ -2894,25 +3455,33 @@ memory_or(unsigned char * restrict output, unsigned char * restrict base, size_t
static VALUE
io_buffer_or(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
+ const void *base;
+ size_t size;
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+
+ const void *mask_base;
+ size_t mask_size;
+ io_buffer_get_bytes_for_reading(mask_buffer, &mask_base, &mask_size);
+
+ io_buffer_check_mask_size(mask_size);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ VALUE output = rb_io_buffer_new(NULL, size, io_flags_for_size(size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
- memory_or(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ memory_or(output_buffer->base, base, size, mask_base, mask_size);
return output;
}
static void
-memory_xor(unsigned char * restrict output, unsigned char * restrict base, size_t size, unsigned char * restrict mask, size_t mask_size)
+memory_xor(unsigned char * restrict output, const unsigned char * restrict base, size_t size, const unsigned char * restrict mask, size_t mask_size)
{
for (size_t offset = 0; offset < size; offset += 1) {
output[offset] = base[offset] ^ mask[offset % mask_size];
@@ -2934,25 +3503,33 @@ memory_xor(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_xor(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
+
+ const void *base;
+ size_t size;
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
- io_buffer_check_mask(mask_data);
+ const void *mask_base;
+ size_t mask_size;
+ io_buffer_get_bytes_for_reading(mask_buffer, &mask_base, &mask_size);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ io_buffer_check_mask_size(mask_size);
- memory_xor(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ VALUE output = rb_io_buffer_new(NULL, size, io_flags_for_size(size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
+
+ memory_xor(output_buffer->base, base, size, mask_base, mask_size);
return output;
}
static void
-memory_not(unsigned char * restrict output, unsigned char * restrict base, size_t size)
+memory_not(unsigned char * restrict output, const unsigned char * restrict base, size_t size)
{
for (size_t offset = 0; offset < size; offset += 1) {
output[offset] = ~base[offset];
@@ -2963,7 +3540,7 @@ memory_not(unsigned char * restrict output, unsigned char * restrict base, size_
* call-seq:
* ~source -> io_buffer
*
- * Generate a new buffer the same size as the source by applying the binary NOT
+ * Generate a new buffer the same size as the source by applying the unary NOT
* operation to the source.
*
* ~IO::Buffer.for("1234567890")
@@ -2974,14 +3551,18 @@ memory_not(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_not(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ const void *base;
+ size_t size;
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
- memory_not(output_data->base, data->base, data->size);
+ VALUE output = rb_io_buffer_new(NULL, size, io_flags_for_size(size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
+
+ memory_not(output_buffer->base, base, size);
return output;
}
@@ -2993,14 +3574,14 @@ io_buffer_overlaps(const struct rb_io_buffer *a, const struct rb_io_buffer *b)
return io_buffer_overlaps(b, a);
}
- return (b->base >= a->base) && (b->base <= (void*)((unsigned char *)a->base + a->size));
+ return (b->base >= a->base) && (b->base < (void*)((unsigned char *)a->base + a->size));
}
static inline void
io_buffer_check_overlaps(struct rb_io_buffer *a, struct rb_io_buffer *b)
{
if (io_buffer_overlaps(a, b))
- rb_raise(rb_eIOBufferMaskError, "Mask overlaps source data!");
+ rb_raise(rb_eIOBufferMaskError, "Mask overlaps source buffer!");
}
static void
@@ -3031,20 +3612,20 @@ memory_and_inplace(unsigned char * restrict base, size_t size, unsigned char * r
static VALUE
io_buffer_and_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask_size(mask_buffer->size);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_and_inplace(base, size, mask_data->base, mask_data->size);
+ memory_and_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3077,20 +3658,20 @@ memory_or_inplace(unsigned char * restrict base, size_t size, unsigned char * re
static VALUE
io_buffer_or_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask_size(mask_buffer->size);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_or_inplace(base, size, mask_data->base, mask_data->size);
+ memory_or_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3123,20 +3704,20 @@ memory_xor_inplace(unsigned char * restrict base, size_t size, unsigned char * r
static VALUE
io_buffer_xor_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask_size(mask_buffer->size);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_xor_inplace(base, size, mask_data->base, mask_data->size);
+ memory_xor_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3153,7 +3734,7 @@ memory_not_inplace(unsigned char * restrict base, size_t size)
* call-seq:
* source.not! -> io_buffer
*
- * Modify the source buffer in place by applying the binary NOT
+ * Modify the source buffer in place by applying the unary NOT
* operation to the source.
*
* source = IO::Buffer.for("1234567890").dup # Make a read/write copy.
@@ -3169,39 +3750,97 @@ memory_not_inplace(unsigned char * restrict base, size_t size)
static VALUE
io_buffer_not_inplace(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
memory_not_inplace(base, size);
return self;
}
+static size_t
+memory_bit_count(const unsigned char *base, size_t size)
+{
+ size_t count = 0;
+
+ // Process 8 bytes at a time for efficiency:
+ const uint64_t *base64 = (const uint64_t *)base;
+ size_t count64 = size / 8;
+ for (size_t i = 0; i < count64; i += 1) {
+ count += rb_popcount64(base64[i]);
+ }
+
+ // Process any remaining bytes:
+ size_t remaining = size % 8;
+ const unsigned char *tail = base + (count64 * 8);
+ for (size_t i = 0; i < remaining; i += 1) {
+ count += rb_popcount32(tail[i]);
+ }
+
+ return count;
+}
+
+/*
+ * call-seq: bit_count([offset, [length]]) -> integer
+ *
+ * Returns the number of set bits (1s) in the buffer, also known as the
+ * Hamming weight or population count. An optional +offset+ and +length+
+ * can be provided to count bits in a subrange of the buffer.
+ *
+ * IO::Buffer.for("\xFF\x00\x0F").bit_count
+ * # => 12
+ *
+ * IO::Buffer.for("\xFF\x00\x0F").bit_count(1, 2)
+ * # => 4
+ */
+static VALUE
+io_buffer_bit_count(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 0, 2);
+
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
+
+ io_buffer_validate_range(buffer, offset, length);
+
+ const void *base;
+ size_t size;
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+
+ size_t count = memory_bit_count((const unsigned char *)base + offset, length);
+
+ return SIZET2NUM(count);
+}
+
/*
* Document-class: IO::Buffer
*
- * IO::Buffer is a low-level efficient buffer for input/output. There are three
- * ways of using buffer:
+ * IO::Buffer is a efficient zero-copy buffer for input/output. There are
+ * typical use cases:
*
- * * Create an empty buffer with ::new, fill it with data using #copy or
- * #set_value, #set_string, get data with #get_string;
+ * * Create an empty buffer with ::new, fill it with buffer using #copy or
+ * #set_value, #set_string, get buffer with #get_string or write it directly
+ * to some file with #write.
* * Create a buffer mapped to some string with ::for, then it could be used
* both for reading with #get_string or #get_value, and writing (writing will
- * change the source string, too);
+ * change the source string, too).
* * Create a buffer mapped to some file with ::map, then it could be used for
* reading and writing the underlying file.
+ * * Create a string of a fixed size with ::string, then #read into it, or
+ * modify it using #set_value.
*
* Interaction with string and file memory is performed by efficient low-level
* C mechanisms like `memcpy`.
*
* The class is meant to be an utility for implementing more high-level mechanisms
- * like Fiber::SchedulerInterface#io_read and Fiber::SchedulerInterface#io_write.
+ * like Fiber::Scheduler#io_read and Fiber::Scheduler#io_write and parsing binary
+ * protocols.
*
- * <b>Examples of usage:</b>
+ * == Examples of Usage
*
* Empty buffer:
*
@@ -3221,33 +3860,31 @@ io_buffer_not_inplace(VALUE self)
* \Buffer from string:
*
* string = 'data'
- * buffer = IO::Buffer.for(string)
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # ...
- * buffer
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # 0x00000000 64 61 74 61 data
- *
- * buffer.get_string(2) # read content starting from offset 2
- * # => "ta"
- * buffer.set_string('---', 1) # write content, starting from offset 1
- * # => 3
- * buffer
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # 0x00000000 64 2d 2d 2d d---
- * string # original string changed, too
- * # => "d---"
+ * IO::Buffer.for(string) do |buffer|
+ * buffer
+ * # =>
+ * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
+ * # 0x00000000 64 61 74 61 data
+ *
+ * buffer.get_string(2) # read content starting from offset 2
+ * # => "ta"
+ * buffer.set_string('---', 1) # write content, starting from offset 1
+ * # => 3
+ * buffer
+ * # =>
+ * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
+ * # 0x00000000 64 2d 2d 2d d---
+ * string # original string changed, too
+ * # => "d---"
+ * end
*
* \Buffer from file:
*
* File.write('test.txt', 'test data')
* # => 9
- * buffer = IO::Buffer.map(File.open('test.txt'))
+ * buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
* # =>
- * # #<IO::Buffer 0x00007f3f0768c000+9 MAPPED IMMUTABLE>
+ * # #<IO::Buffer 0x00007f3f0768c000+9 EXTERNAL MAPPED FILE SHARED READONLY>
* # ...
* buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
* # => "da"
@@ -3262,16 +3899,28 @@ io_buffer_not_inplace(VALUE self)
* File.read('test.txt')
* # => "t--- data"
*
- * <b>The class is experimental and the interface is subject to change.</b>
+ * <b>The class is experimental and the interface is subject to change, this
+ * is especially true of file mappings which may be removed entirely in
+ * the future.</b>
*/
void
Init_IO_Buffer(void)
{
rb_cIOBuffer = rb_define_class_under(rb_cIO, "Buffer", rb_cObject);
+
+ /* Raised when an operation would resize or re-allocate a locked buffer. */
rb_eIOBufferLockedError = rb_define_class_under(rb_cIOBuffer, "LockedError", rb_eRuntimeError);
+
+ /* Raised when the buffer cannot be allocated for some reason, or you try to use a buffer that's not allocated. */
rb_eIOBufferAllocationError = rb_define_class_under(rb_cIOBuffer, "AllocationError", rb_eRuntimeError);
+
+ /* Raised when you try to write to a read-only buffer, or resize an external buffer. */
rb_eIOBufferAccessError = rb_define_class_under(rb_cIOBuffer, "AccessError", rb_eRuntimeError);
+
+ /* Raised if you try to access a buffer slice which no longer references a valid memory range of the underlying source. */
rb_eIOBufferInvalidatedError = rb_define_class_under(rb_cIOBuffer, "InvalidatedError", rb_eRuntimeError);
+
+ /* Raised if the mask given to a binary operation is invalid, e.g. zero length or overlaps the target buffer. */
rb_eIOBufferMaskError = rb_define_class_under(rb_cIOBuffer, "MaskError", rb_eArgError);
rb_define_alloc_func(rb_cIOBuffer, rb_io_buffer_type_allocate);
@@ -3288,37 +3937,57 @@ Init_IO_Buffer(void)
RUBY_IO_BUFFER_DEFAULT_SIZE = io_buffer_default_size(RUBY_IO_BUFFER_PAGE_SIZE);
- // Efficient sizing of mapped buffers:
+ /* The operating system page size. Used for efficient page-aligned memory allocations. */
rb_define_const(rb_cIOBuffer, "PAGE_SIZE", SIZET2NUM(RUBY_IO_BUFFER_PAGE_SIZE));
+
+ /* The default buffer size, typically a (small) multiple of the PAGE_SIZE.
+ Can be explicitly specified by setting the RUBY_IO_BUFFER_DEFAULT_SIZE
+ environment variable. */
rb_define_const(rb_cIOBuffer, "DEFAULT_SIZE", SIZET2NUM(RUBY_IO_BUFFER_DEFAULT_SIZE));
rb_define_singleton_method(rb_cIOBuffer, "map", io_buffer_map, -1);
- // General use:
rb_define_method(rb_cIOBuffer, "initialize", rb_io_buffer_initialize, -1);
rb_define_method(rb_cIOBuffer, "initialize_copy", rb_io_buffer_initialize_copy, 1);
rb_define_method(rb_cIOBuffer, "inspect", rb_io_buffer_inspect, 0);
- rb_define_method(rb_cIOBuffer, "hexdump", rb_io_buffer_hexdump, 0);
+ rb_define_method(rb_cIOBuffer, "hexdump", rb_io_buffer_hexdump, -1);
rb_define_method(rb_cIOBuffer, "to_s", rb_io_buffer_to_s, 0);
rb_define_method(rb_cIOBuffer, "size", rb_io_buffer_size, 0);
rb_define_method(rb_cIOBuffer, "valid?", rb_io_buffer_valid_p, 0);
- // Ownership:
rb_define_method(rb_cIOBuffer, "transfer", rb_io_buffer_transfer, 0);
- // Flags:
+ /* Indicates that the memory in the buffer is owned by someone else. See #external? for more details. */
rb_define_const(rb_cIOBuffer, "EXTERNAL", RB_INT2NUM(RB_IO_BUFFER_EXTERNAL));
+
+ /* Indicates that the memory in the buffer is owned by the buffer. See #internal? for more details. */
rb_define_const(rb_cIOBuffer, "INTERNAL", RB_INT2NUM(RB_IO_BUFFER_INTERNAL));
+
+ /* Indicates that the memory in the buffer is mapped by the operating system. See #mapped? for more details. */
rb_define_const(rb_cIOBuffer, "MAPPED", RB_INT2NUM(RB_IO_BUFFER_MAPPED));
+
+ /* Indicates that the memory in the buffer is also mapped such that it can be shared with other processes. See #shared? for more details. */
rb_define_const(rb_cIOBuffer, "SHARED", RB_INT2NUM(RB_IO_BUFFER_SHARED));
+
+ /* Indicates that the memory in the buffer is locked and cannot be resized or freed. See #locked? and #locked for more details. */
rb_define_const(rb_cIOBuffer, "LOCKED", RB_INT2NUM(RB_IO_BUFFER_LOCKED));
+
+ /* Indicates that the memory in the buffer is mapped privately and changes won't be replicated to the underlying file. See #private? for more details. */
rb_define_const(rb_cIOBuffer, "PRIVATE", RB_INT2NUM(RB_IO_BUFFER_PRIVATE));
+
+ /* Indicates that the memory in the buffer is read only, and attempts to modify it will fail. See #readonly? for more details.*/
rb_define_const(rb_cIOBuffer, "READONLY", RB_INT2NUM(RB_IO_BUFFER_READONLY));
- // Endian:
+ /* Refers to little endian byte order, where the least significant byte is stored first. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "LITTLE_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_LITTLE_ENDIAN));
+
+ /* Refers to big endian byte order, where the most significant byte is stored first. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "BIG_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_BIG_ENDIAN));
+
+ /* Refers to the byte order of the host machine. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "HOST_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_HOST_ENDIAN));
+
+ /* Refers to network byte order, which is the same as big endian. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "NETWORK_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_NETWORK_ENDIAN));
rb_define_method(rb_cIOBuffer, "null?", rb_io_buffer_null_p, 0);
@@ -3328,6 +3997,7 @@ Init_IO_Buffer(void)
rb_define_method(rb_cIOBuffer, "mapped?", rb_io_buffer_mapped_p, 0);
rb_define_method(rb_cIOBuffer, "shared?", rb_io_buffer_shared_p, 0);
rb_define_method(rb_cIOBuffer, "locked?", rb_io_buffer_locked_p, 0);
+ rb_define_method(rb_cIOBuffer, "private?", rb_io_buffer_private_p, 0);
rb_define_method(rb_cIOBuffer, "readonly?", io_buffer_readonly_p, 0);
// Locking to prevent changes while using pointer:
@@ -3363,6 +4033,11 @@ Init_IO_Buffer(void)
IO_BUFFER_DEFINE_DATA_TYPE(s64);
IO_BUFFER_DEFINE_DATA_TYPE(S64);
+ IO_BUFFER_DEFINE_DATA_TYPE(u128);
+ IO_BUFFER_DEFINE_DATA_TYPE(U128);
+ IO_BUFFER_DEFINE_DATA_TYPE(s128);
+ IO_BUFFER_DEFINE_DATA_TYPE(S128);
+
IO_BUFFER_DEFINE_DATA_TYPE(f32);
IO_BUFFER_DEFINE_DATA_TYPE(F32);
IO_BUFFER_DEFINE_DATA_TYPE(f64);
@@ -3385,7 +4060,7 @@ Init_IO_Buffer(void)
rb_define_method(rb_cIOBuffer, "get_string", io_buffer_get_string, -1);
rb_define_method(rb_cIOBuffer, "set_string", io_buffer_set_string, -1);
- // Binary data manipulations:
+ // Binary buffer manipulations:
rb_define_method(rb_cIOBuffer, "&", io_buffer_and, 1);
rb_define_method(rb_cIOBuffer, "|", io_buffer_or, 1);
rb_define_method(rb_cIOBuffer, "^", io_buffer_xor, 1);
@@ -3396,6 +4071,8 @@ Init_IO_Buffer(void)
rb_define_method(rb_cIOBuffer, "xor!", io_buffer_xor_inplace, 1);
rb_define_method(rb_cIOBuffer, "not!", io_buffer_not_inplace, 0);
+ rb_define_method(rb_cIOBuffer, "bit_count", io_buffer_bit_count, -1);
+
// IO operations:
rb_define_method(rb_cIOBuffer, "read", io_buffer_read, -1);
rb_define_method(rb_cIOBuffer, "pread", io_buffer_pread, -1);
diff --git a/iseq.c b/iseq.c
index 2e072f9ac2..b90fcb4334 100644
--- a/iseq.c
+++ b/iseq.c
@@ -19,6 +19,7 @@
#endif
#include "eval_intern.h"
+#include "id.h"
#include "id_table.h"
#include "internal.h"
#include "internal/bits.h"
@@ -28,21 +29,24 @@
#include "internal/file.h"
#include "internal/gc.h"
#include "internal/hash.h"
-#include "internal/parse.h"
+#include "internal/io.h"
+#include "internal/ruby_parser.h"
#include "internal/sanitizers.h"
+#include "internal/set_table.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
-#include "rjit.h"
#include "ruby/util.h"
#include "vm_core.h"
+#include "ractor_core.h"
#include "vm_callinfo.h"
#include "yjit.h"
#include "ruby/ractor.h"
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
+#include "zjit.h"
VALUE rb_cISeq;
static VALUE iseqw_new(const rb_iseq_t *iseq);
@@ -84,7 +88,7 @@ free_arena(struct iseq_compile_data_storage *cur)
while (cur) {
next = cur->next;
- ruby_xfree(cur);
+ ruby_xfree_sized(cur, offsetof(struct iseq_compile_data_storage, buff) + cur->size * sizeof(char));
cur = next;
}
}
@@ -98,7 +102,7 @@ compile_data_free(struct iseq_compile_data *compile_data)
if (compile_data->ivar_cache_table) {
rb_id_table_free(compile_data->ivar_cache_table);
}
- ruby_xfree(compile_data);
+ SIZED_FREE(compile_data);
}
}
@@ -109,13 +113,15 @@ remove_from_constant_cache(ID id, IC ic)
VALUE lookup_result;
st_data_t ic_data = (st_data_t)ic;
- if (rb_id_table_lookup(vm->constant_cache, id, &lookup_result)) {
- st_table *ics = (st_table *)lookup_result;
- st_delete(ics, &ic_data, NULL);
+ if (rb_id_table_lookup(&vm->constant_cache, id, &lookup_result)) {
+ set_table *ics = (set_table *)lookup_result;
+ set_table_delete(ics, &ic_data);
- if (ics->num_entries == 0) {
- rb_id_table_delete(vm->constant_cache, id);
- st_free_table(ics);
+ if (ics->num_entries == 0 &&
+ // See comment in vm_track_constant_cache on why we need this check
+ id != vm->inserting_constant_cache_id) {
+ rb_id_table_delete(&vm->constant_cache, id);
+ set_free_table(ics);
}
}
}
@@ -146,14 +152,33 @@ iseq_clear_ic_references(const rb_iseq_t *iseq)
if (segments == NULL)
continue;
- for (int i = 0; segments[i]; i++) {
+ int i;
+ for (i = 0; segments[i]; i++) {
ID id = segments[i];
if (id == idNULL) continue;
remove_from_constant_cache(id, ic);
}
- ruby_xfree((void *)segments);
+ SIZED_FREE_N(segments, i + 1);
+ }
+}
+
+
+rb_hook_list_t *
+rb_iseq_local_hooks(const rb_iseq_t *iseq, rb_ractor_t *r, bool create)
+{
+ rb_hook_list_t *hook_list = NULL;
+ st_data_t val;
+ if (st_lookup(rb_ractor_targeted_hooks(r), (st_data_t)iseq, &val)) {
+ hook_list = (rb_hook_list_t*)val;
+ RUBY_ASSERT(hook_list->type == hook_list_type_targeted_iseq);
+ }
+ else if (create) {
+ hook_list = RB_ZALLOC(rb_hook_list_t);
+ hook_list->type = hook_list_type_targeted_iseq;
+ st_insert(rb_ractor_targeted_hooks(r), (st_data_t)iseq, (st_data_t)hook_list);
}
+ return hook_list;
}
void
@@ -164,40 +189,51 @@ rb_iseq_free(const rb_iseq_t *iseq)
if (iseq && ISEQ_BODY(iseq)) {
iseq_clear_ic_references(iseq);
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- rb_rjit_free_iseq(iseq); /* Notify RJIT */
#if USE_YJIT
- rb_yjit_iseq_free(body->yjit_payload);
+ rb_yjit_iseq_free(iseq);
+ if (FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED)) {
+ RUBY_ASSERT(rb_yjit_live_iseq_count > 0);
+ rb_yjit_live_iseq_count--;
+ }
+#endif
+#if USE_ZJIT
+ rb_zjit_iseq_free(iseq);
#endif
- ruby_xfree((void *)body->iseq_encoded);
- ruby_xfree((void *)body->insns_info.body);
- if (body->insns_info.positions) ruby_xfree((void *)body->insns_info.positions);
+ SIZED_FREE_N(body->iseq_encoded, body->iseq_size);
+ SIZED_FREE_N(body->insns_info.body, body->insns_info.size);
+ SIZED_FREE_N(body->insns_info.positions, body->insns_info.size);
#if VM_INSN_INFO_TABLE_IMPL == 2
- if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table);
+ ruby_xfree(body->insns_info.succ_index_table);
#endif
- if (LIKELY(body->local_table != rb_iseq_shared_exc_local_tbl))
- ruby_xfree((void *)body->local_table);
- ruby_xfree((void *)body->is_entries);
-
- if (body->call_data) {
- ruby_xfree(body->call_data);
+ SIZED_FREE_N(body->is_entries, ISEQ_IS_SIZE(body));
+ SIZED_FREE_N(body->call_data, body->ci_size);
+ if (body->catch_table) {
+ ruby_xfree_sized(body->catch_table, iseq_catch_table_bytes(body->catch_table->size));
}
- ruby_xfree((void *)body->catch_table);
- ruby_xfree((void *)body->param.opt_table);
+ SIZED_FREE_N(body->param.opt_table, body->param.opt_num + 1);
if (ISEQ_MBITS_BUFLEN(body->iseq_size) > 1 && body->mark_bits.list) {
- ruby_xfree((void *)body->mark_bits.list);
+ SIZED_FREE_N(body->mark_bits.list, ISEQ_MBITS_BUFLEN(body->iseq_size));
}
- if (body->param.keyword != NULL) {
- ruby_xfree((void *)body->param.keyword->default_values);
- ruby_xfree((void *)body->param.keyword);
+ ISEQ_ORIGINAL_ISEQ_CLEAR(iseq);
+
+ struct rb_iseq_param_keyword *pkw = (struct rb_iseq_param_keyword *)body->param.keyword;
+ if (pkw != NULL) {
+ if (pkw->table != &body->local_table[pkw->bits_start - pkw->num])
+ SIZED_FREE_N(pkw->table, pkw->required_num);
+ if (pkw->default_values) {
+ SIZED_FREE_N(pkw->default_values, pkw->num - pkw->required_num);
+ }
+ SIZED_FREE(pkw);
}
+ if (LIKELY(body->local_table != rb_iseq_shared_exc_local_tbl)) {
+ SIZED_FREE_N(body->local_table, body->local_table_size);
+ }
+ SIZED_FREE_N(body->lvar_states, body->local_table_size);
+
compile_data_free(ISEQ_COMPILE_DATA(iseq));
if (body->outer_variables) rb_id_table_free(body->outer_variables);
- ruby_xfree(body);
- }
-
- if (iseq && ISEQ_EXECUTABLE_P(iseq) && iseq->aux.exec.local_hooks) {
- rb_hook_list_free(iseq->aux.exec.local_hooks);
+ SIZED_FREE(body);
}
RUBY_FREE_LEAVE("iseq");
@@ -224,7 +260,30 @@ iseq_scan_bits(unsigned int page, iseq_bits_t bits, VALUE *code, VALUE *original
}
static void
-rb_iseq_mark_and_move_each_value(const rb_iseq_t *iseq, VALUE *original_iseq)
+rb_iseq_mark_and_move_each_compile_data_value(const rb_iseq_t *iseq, VALUE *original_iseq)
+{
+ unsigned int size;
+ VALUE *code;
+ const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
+
+ size = compile_data->iseq_size;
+ code = compile_data->iseq_encoded;
+
+ // Embedded VALUEs
+ if (compile_data->mark_bits.list) {
+ if(compile_data->is_single_mark_bit) {
+ iseq_scan_bits(0, compile_data->mark_bits.single, code, original_iseq);
+ }
+ else {
+ for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
+ iseq_bits_t bits = compile_data->mark_bits.list[i];
+ iseq_scan_bits(i, bits, code, original_iseq);
+ }
+ }
+ }
+}
+static void
+rb_iseq_mark_and_move_each_body_value(const rb_iseq_t *iseq, VALUE *original_iseq)
{
unsigned int size;
VALUE *code;
@@ -243,9 +302,7 @@ rb_iseq_mark_and_move_each_value(const rb_iseq_t *iseq, VALUE *original_iseq)
for (unsigned int i = 0; i < body->icvarc_size; i++, is_entries++) {
ICVARC icvarc = (ICVARC)is_entries;
if (icvarc->entry) {
- RUBY_ASSERT(!RB_TYPE_P(icvarc->entry->class_value, T_NONE));
-
- rb_gc_mark_and_move(&icvarc->entry->class_value);
+ rb_gc_mark_and_move((VALUE *)&icvarc->entry);
}
}
@@ -272,14 +329,37 @@ rb_iseq_mark_and_move_each_value(const rb_iseq_t *iseq, VALUE *original_iseq)
iseq_scan_bits(0, body->mark_bits.single, code, original_iseq);
}
else {
- if (body->mark_bits.list) {
- for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
- iseq_bits_t bits = body->mark_bits.list[i];
- iseq_scan_bits(i, bits, code, original_iseq);
- }
+ for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) {
+ iseq_bits_t bits = body->mark_bits.list[i];
+ iseq_scan_bits(i, bits, code, original_iseq);
+ }
+ }
+ }
+}
+
+static bool
+cc_is_active(const struct rb_callcache *cc, bool reference_updating)
+{
+ if (cc) {
+ if (cc == rb_vm_empty_cc() || rb_vm_empty_cc_for_super()) {
+ return false;
+ }
+
+ if (reference_updating) {
+ cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc);
+ }
+
+ if (vm_cc_markable(cc) && vm_cc_valid(cc)) {
+ const struct rb_callable_method_entry_struct *cme = vm_cc_cme(cc);
+ if (reference_updating) {
+ cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cme);
+ }
+ if (!METHOD_ENTRY_INVALIDATED(cme)) {
+ return true;
}
}
}
+ return false;
}
void
@@ -292,10 +372,8 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
if (ISEQ_BODY(iseq)) {
struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
- rb_iseq_mark_and_move_each_value(iseq, reference_updating ? ISEQ_ORIGINAL_ISEQ(iseq) : NULL);
+ rb_iseq_mark_and_move_each_body_value(iseq, reference_updating ? ISEQ_ORIGINAL_ISEQ(iseq) : NULL);
- rb_gc_mark_and_move(&body->variable.coverage);
- rb_gc_mark_and_move(&body->variable.pc2branchindex);
rb_gc_mark_and_move(&body->variable.script_lines);
rb_gc_mark_and_move(&body->location.label);
rb_gc_mark_and_move(&body->location.base_label);
@@ -310,36 +388,22 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
if (cds[i].ci) rb_gc_mark_and_move_ptr(&cds[i].ci);
- const struct rb_callcache *cc = cds[i].cc;
- if (cc) {
- if (reference_updating) {
- cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc);
- }
-
- if (vm_cc_markable(cc)) {
- VM_ASSERT((cc->flags & VM_CALLCACHE_ON_STACK) == 0);
-
- const struct rb_callable_method_entry_struct *cme = vm_cc_cme(cc);
- if (reference_updating) {
- cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cme);
- }
-
- if (cc->klass && !METHOD_ENTRY_INVALIDATED(cme)) {
- rb_gc_mark_and_move_ptr(&cds[i].cc);
- }
- else {
- cds[i].cc = rb_vm_empty_cc();
- }
- }
+ if (cc_is_active(cds[i].cc, reference_updating)) {
+ rb_gc_mark_and_move_ptr(&cds[i].cc);
+ }
+ else if (cds[i].cc != rb_vm_empty_cc()) {
+ cds[i].cc = rb_vm_empty_cc();
}
}
}
- if (body->param.flags.has_kw && ISEQ_COMPILE_DATA(iseq) == NULL) {
+ if (body->param.flags.has_kw && body->param.keyword != NULL) {
const struct rb_iseq_param_keyword *const keyword = body->param.keyword;
- for (int j = 0, i = keyword->required_num; i < keyword->num; i++, j++) {
- rb_gc_mark_and_move(&keyword->default_values[j]);
+ if (keyword->default_values != NULL) {
+ for (int j = 0, i = keyword->required_num; i < keyword->num; i++, j++) {
+ rb_gc_mark_and_move(&keyword->default_values[j]);
+ }
}
}
@@ -356,41 +420,51 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
}
if (reference_updating) {
-#if USE_RJIT
- rb_rjit_iseq_update_references(body);
-#endif
#if USE_YJIT
- rb_yjit_iseq_update_references(body->yjit_payload);
+ rb_yjit_iseq_update_references(iseq);
+#endif
+#if USE_ZJIT
+ rb_zjit_iseq_update_references(body->zjit_payload);
#endif
}
else {
-#if USE_RJIT
- rb_rjit_iseq_mark(body->rjit_blocks);
-#endif
+ // TODO: check jit payload
+ if (!rb_gc_checking_shareable()) {
#if USE_YJIT
- rb_yjit_iseq_mark(body->yjit_payload);
+ rb_yjit_iseq_mark(body->yjit_payload);
+#endif
+#if USE_ZJIT
+ rb_zjit_iseq_mark(body->zjit_payload);
#endif
+ }
+ }
+
+ // TODO: ractor aware coverage
+ if (!rb_gc_checking_shareable()) {
+ rb_gc_mark_and_move(&body->variable.coverage);
+ rb_gc_mark_and_move(&body->variable.pc2branchindex);
}
}
if (FL_TEST_RAW((VALUE)iseq, ISEQ_NOT_LOADED_YET)) {
- rb_gc_mark_and_move(&iseq->aux.loader.obj);
+ if (!rb_gc_checking_shareable()) {
+ rb_gc_mark_and_move(&iseq->aux.loader.obj);
+ }
}
else if (FL_TEST_RAW((VALUE)iseq, ISEQ_USE_COMPILE_DATA)) {
- const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
+ if (!rb_gc_checking_shareable()) {
+ const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
- rb_iseq_mark_and_move_insn_storage(compile_data->insn.storage_head);
+ rb_iseq_mark_and_move_insn_storage(compile_data->insn.storage_head);
+ rb_iseq_mark_and_move_each_compile_data_value(iseq, reference_updating ? ISEQ_ORIGINAL_ISEQ(iseq) : NULL);
- rb_gc_mark_and_move((VALUE *)&compile_data->err_info);
- rb_gc_mark_and_move((VALUE *)&compile_data->catch_table_ary);
+ rb_gc_mark_and_move((VALUE *)&compile_data->err_info);
+ rb_gc_mark_and_move((VALUE *)&compile_data->catch_table_ary);
+ }
}
else {
/* executable */
VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));
-
- if (iseq->aux.exec.local_hooks) {
- rb_hook_list_mark_and_update(iseq->aux.exec.local_hooks);
- }
}
RUBY_MARK_LEAVE("iseq");
@@ -495,9 +569,14 @@ rb_iseq_pathobj_new(VALUE path, VALUE realpath)
pathobj = rb_fstring(path);
}
else {
- if (!NIL_P(realpath)) realpath = rb_fstring(realpath);
- pathobj = rb_ary_new_from_args(2, rb_fstring(path), realpath);
- rb_obj_freeze(pathobj);
+ if (!NIL_P(realpath)) {
+ realpath = rb_fstring(realpath);
+ }
+ VALUE fpath = rb_fstring(path);
+
+ pathobj = rb_ary_new_from_args(2, fpath, realpath);
+ rb_ary_freeze(pathobj);
+ RB_OBJ_SET_SHAREABLE(pathobj);
}
return pathobj;
}
@@ -509,6 +588,24 @@ rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath)
rb_iseq_pathobj_new(path, realpath));
}
+// Make a dummy iseq for a dummy frame that exposes a path for profilers to inspect
+rb_iseq_t *
+rb_iseq_alloc_with_dummy_path(VALUE fname)
+{
+ rb_iseq_t *dummy_iseq = iseq_alloc();
+
+ ISEQ_BODY(dummy_iseq)->type = ISEQ_TYPE_TOP;
+
+ if (!RB_OBJ_SHAREABLE_P(fname)) {
+ RB_OBJ_SET_FROZEN_SHAREABLE(fname);
+ }
+
+ RB_OBJ_WRITE(dummy_iseq, &ISEQ_BODY(dummy_iseq)->location.pathobj, fname);
+ RB_OBJ_WRITE(dummy_iseq, &ISEQ_BODY(dummy_iseq)->location.label, fname);
+
+ return dummy_iseq;
+}
+
static rb_iseq_location_t *
iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_code_location_t *code_location, const int node_id)
{
@@ -518,6 +615,11 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, int
RB_OBJ_WRITE(iseq, &loc->label, name);
RB_OBJ_WRITE(iseq, &loc->base_label, name);
loc->first_lineno = first_lineno;
+
+ if (ISEQ_BODY(iseq)->local_iseq == iseq && strcmp(RSTRING_PTR(name), "initialize") == 0) {
+ ISEQ_BODY(iseq)->param.flags.use_block = 1;
+ }
+
if (code_location) {
loc->node_id = node_id;
loc->code_location = *code_location;
@@ -546,11 +648,11 @@ set_relation(rb_iseq_t *iseq, const rb_iseq_t *piseq)
body->local_iseq = iseq;
}
else if (piseq) {
- body->local_iseq = ISEQ_BODY(piseq)->local_iseq;
+ RB_OBJ_WRITE(iseq, &body->local_iseq, ISEQ_BODY(piseq)->local_iseq);
}
if (piseq) {
- body->parent_iseq = piseq;
+ RB_OBJ_WRITE(iseq, &body->parent_iseq, piseq);
}
if (type == ISEQ_TYPE_MAIN) {
@@ -573,6 +675,18 @@ new_arena(void)
return new_arena;
}
+static int
+prepare_node_id(const NODE *node)
+{
+ if (!node) return -1;
+
+ if (nd_type(node) == NODE_SCOPE && RNODE_SCOPE(node)->nd_parent) {
+ return nd_node_id(RNODE_SCOPE(node)->nd_parent);
+ }
+
+ return nd_node_id(node);
+}
+
static VALUE
prepare_iseq_build(rb_iseq_t *iseq,
VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_code_location_t *code_location, const int node_id,
@@ -646,7 +760,7 @@ rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq)
if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table);
body->insns_info.succ_index_table = succ_index_table_create(max_pos, data, size);
#if VM_CHECK_MODE == 0
- ruby_xfree(body->insns_info.positions);
+ SIZED_FREE_N(body->insns_info.positions, body->insns_info.size);
body->insns_info.positions = NULL;
#endif
#endif
@@ -700,19 +814,26 @@ finish_iseq_build(rb_iseq_t *iseq)
}
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_FROZEN_STRING_LITERAL,
- OPT_DEBUG_FROZEN_STRING_LITERAL,
- TRUE, /* coverage_enabled */
+ .inline_const_cache = OPT_INLINE_CONST_CACHE,
+ .peephole_optimization = OPT_PEEPHOLE_OPTIMIZATION,
+ .tailcall_optimization = OPT_TAILCALL_OPTIMIZATION,
+ .specialized_instruction = OPT_SPECIALISED_INSTRUCTION,
+ .operands_unification = OPT_OPERANDS_UNIFICATION,
+ .instructions_unification = OPT_INSTRUCTIONS_UNIFICATION,
+ .frozen_string_literal = OPT_FROZEN_STRING_LITERAL,
+ .debug_frozen_string_literal = OPT_DEBUG_FROZEN_STRING_LITERAL,
+ .coverage_enabled = TRUE,
+};
+
+static const rb_compile_option_t COMPILE_OPTION_FALSE = {
+ .frozen_string_literal = -1, // unspecified
};
-static const rb_compile_option_t COMPILE_OPTION_FALSE = {0};
+int
+rb_iseq_opt_frozen_string_literal(void)
+{
+ return COMPILE_OPTION_DEFAULT.frozen_string_literal;
+}
static void
set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
@@ -723,7 +844,7 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
else if (flag == Qfalse) { (o)->mem = 0; } \
}
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
- { VALUE num = rb_hash_aref(opt, ID2SYM(rb_intern(#mem))); \
+ { VALUE num = rb_hash_aref((h), ID2SYM(rb_intern(#mem))); \
if (!NIL_P(num)) (o)->mem = NUM2INT(num); \
}
SET_COMPILE_OPTION(option, opt, inline_const_cache);
@@ -732,7 +853,6 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
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, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
SET_COMPILE_OPTION(option, opt, coverage_enabled);
@@ -741,11 +861,13 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
#undef SET_COMPILE_OPTION_NUM
}
-static void
-rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
+static rb_compile_option_t *
+set_compile_option_from_ast(rb_compile_option_t *option, const rb_ast_body_t *ast)
{
- Check_Type(opt, T_HASH);
- set_compile_option_from_hash(option, opt);
+ if (ast->frozen_string_literal >= 0) {
+ option->frozen_string_literal = ast->frozen_string_literal;
+ }
+ return option;
}
static void
@@ -786,43 +908,36 @@ make_compile_option_value(rb_compile_option_t *option)
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, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
SET_COMPILE_OPTION(option, opt, coverage_enabled);
SET_COMPILE_OPTION_NUM(option, opt, debug_level);
}
#undef SET_COMPILE_OPTION
#undef SET_COMPILE_OPTION_NUM
+ VALUE frozen_string_literal = option->frozen_string_literal == -1 ? Qnil : RBOOL(option->frozen_string_literal);
+ rb_hash_aset(opt, ID2SYM(rb_intern("frozen_string_literal")), frozen_string_literal);
return opt;
}
rb_iseq_t *
-rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
+rb_iseq_new(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath,
const rb_iseq_t *parent, enum rb_iseq_type type)
{
- return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent,
- 0, type, &COMPILE_OPTION_DEFAULT);
+ return rb_iseq_new_with_opt(ast_value, name, path, realpath, 0, parent,
+ 0, type, &COMPILE_OPTION_DEFAULT,
+ Qnil);
}
static int
-ast_line_count(const rb_ast_body_t *ast)
+ast_line_count(const VALUE ast_value)
{
- if (ast->script_lines == Qfalse) {
- // this occurs when failed to parse the source code with a syntax error
- return 0;
- }
- if (RB_TYPE_P(ast->script_lines, T_ARRAY)){
- return (int)RARRAY_LEN(ast->script_lines);
- }
- return FIX2INT(ast->script_lines);
+ rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
+ return ast->body.line_count;
}
static VALUE
-iseq_setup_coverage(VALUE coverages, VALUE path, const rb_ast_body_t *ast, int line_offset)
+iseq_setup_coverage(VALUE coverages, VALUE path, int line_count)
{
- int line_count = line_offset + ast_line_count(ast);
-
if (line_count >= 0) {
int len = (rb_get_coverage_mode() & COVERAGE_TARGET_ONESHOT_LINES) ? 0 : line_count;
@@ -836,46 +951,95 @@ iseq_setup_coverage(VALUE coverages, VALUE path, const rb_ast_body_t *ast, int l
}
static inline void
-iseq_new_setup_coverage(VALUE path, const rb_ast_body_t *ast, int line_offset)
+iseq_new_setup_coverage(VALUE path, int line_count)
{
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
- iseq_setup_coverage(coverages, path, ast, line_offset);
+ iseq_setup_coverage(coverages, path, line_count);
}
}
rb_iseq_t *
-rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+{
+ iseq_new_setup_coverage(path, ast_line_count(ast_value));
+
+ return rb_iseq_new_with_opt(ast_value, name, path, realpath, 0, parent, 0,
+ ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT,
+ Qnil);
+}
+
+/**
+ * The main entry-point into the prism compiler when a file is required.
+ */
+rb_iseq_t *
+pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state)
+{
+ iseq_new_setup_coverage(path, (int) (pm_parser_line_offsets(node->parser)->size - 1));
+
+ return pm_iseq_new_with_opt(node, name, path, realpath, 0, parent, 0,
+ ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT, error_state);
+}
+
+rb_iseq_t *
+rb_iseq_new_main(const VALUE ast_value, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
{
- iseq_new_setup_coverage(path, ast, 0);
+ iseq_new_setup_coverage(path, ast_line_count(ast_value));
- return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent, 0,
- ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT);
+ return rb_iseq_new_with_opt(ast_value, rb_fstring_lit("<main>"),
+ path, realpath, 0,
+ parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE,
+ Qnil);
}
+/**
+ * The main entry-point into the prism compiler when a file is executed as the
+ * main file in the program.
+ */
rb_iseq_t *
-rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
+pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state)
{
- iseq_new_setup_coverage(path, ast, 0);
+ iseq_new_setup_coverage(path, (int) (pm_parser_line_offsets(node->parser)->size - 1));
- return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
+ return pm_iseq_new_with_opt(node, rb_fstring_lit("<main>"),
path, realpath, 0,
- parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);
+ parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE, error_state);
}
rb_iseq_t *
-rb_iseq_new_eval(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth)
+rb_iseq_new_eval(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth)
{
if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
- iseq_setup_coverage(coverages, path, ast, first_lineno - 1);
+ iseq_setup_coverage(coverages, path, ast_line_count(ast_value) + first_lineno - 1);
}
}
- return rb_iseq_new_with_opt(ast, name, path, realpath, first_lineno,
- parent, isolated_depth, ISEQ_TYPE_EVAL, &COMPILE_OPTION_DEFAULT);
+ rb_compile_option_t option = COMPILE_OPTION_DEFAULT;
+ rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
+ if (ast->body.coverage_enabled >= 0) {
+ option.coverage_enabled = ast->body.coverage_enabled;
+ }
+ return rb_iseq_new_with_opt(ast_value, name, path, realpath, first_lineno,
+ parent, isolated_depth, ISEQ_TYPE_EVAL, &option,
+ Qnil);
+}
+
+rb_iseq_t *
+pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
+ int first_lineno, const rb_iseq_t *parent, int isolated_depth, int *error_state)
+{
+ if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
+ VALUE coverages = rb_get_coverages();
+ if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
+ iseq_setup_coverage(coverages, path, ((int) (pm_parser_line_offsets(node->parser)->size - 1)) + first_lineno - 1);
+ }
+ }
+
+ return pm_iseq_new_with_opt(node, name, path, realpath, first_lineno,
+ parent, isolated_depth, ISEQ_TYPE_EVAL, &COMPILE_OPTION_DEFAULT, error_state);
}
static inline rb_iseq_t *
@@ -893,41 +1057,134 @@ iseq_translate(rb_iseq_t *iseq)
}
rb_iseq_t *
-rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
+rb_iseq_new_with_opt(VALUE ast_value, VALUE name, VALUE path, VALUE realpath,
int first_lineno, const rb_iseq_t *parent, int isolated_depth,
- enum rb_iseq_type type, const rb_compile_option_t *option)
+ enum rb_iseq_type type, const rb_compile_option_t *option,
+ VALUE script_lines)
{
- const NODE *node = ast ? ast->root : 0;
+ rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
+ rb_ast_body_t *body = ast ? &ast->body : NULL;
+ const NODE *node = body ? body->root : 0;
/* TODO: argument check */
rb_iseq_t *iseq = iseq_alloc();
rb_compile_option_t new_opt;
- if (option) {
+ if (!option) option = &COMPILE_OPTION_DEFAULT;
+ if (body) {
new_opt = *option;
+ option = set_compile_option_from_ast(&new_opt, body);
}
- else {
- new_opt = COMPILE_OPTION_DEFAULT;
- }
- if (ast && ast->compile_option) rb_iseq_make_compile_option(&new_opt, ast->compile_option);
- VALUE script_lines = Qnil;
-
- if (ast && !FIXNUM_P(ast->script_lines) && ast->script_lines) {
- script_lines = ast->script_lines;
+ if (!NIL_P(script_lines)) {
+ // noop
+ }
+ else if (body && body->script_lines) {
+ script_lines = rb_parser_build_script_lines_from(body->script_lines);
}
else if (parent) {
script_lines = ISEQ_BODY(parent)->variable.script_lines;
}
- prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, node ? nd_node_id(node) : -1,
- parent, isolated_depth, type, script_lines, &new_opt);
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, prepare_node_id(node),
+ parent, isolated_depth, type, script_lines, option);
rb_iseq_compile_node(iseq, node);
finish_iseq_build(iseq);
+ RB_GC_GUARD(ast_value);
+
+ return iseq_translate(iseq);
+}
+
+/**
+ * Core implementation for building a prism iseq. This does not use rb_protect,
+ * so any exceptions (e.g. from finish_iseq_build) propagate normally up the
+ * call stack — matching the parse.y compiler's behavior.
+ */
+rb_iseq_t *
+pm_iseq_build(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
+ int first_lineno, const rb_iseq_t *parent, int isolated_depth,
+ enum rb_iseq_type type, const rb_compile_option_t *option)
+{
+ rb_iseq_t *iseq = iseq_alloc();
+ ISEQ_BODY(iseq)->prism = true;
+
+ rb_compile_option_t next_option;
+ if (!option) option = &COMPILE_OPTION_DEFAULT;
+
+ next_option = *option;
+ next_option.coverage_enabled = node->coverage_enabled < 0 ? 0 : node->coverage_enabled > 0;
+ option = &next_option;
+
+ pm_location_t *location = &node->base.location;
+ int32_t start_line = pm_parser_start_line(node->parser);
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(node->parser);
+
+ pm_line_column_t start = pm_line_offset_list_line_column(line_offsets, location->start, start_line);
+ pm_line_column_t end = pm_line_offset_list_line_column(line_offsets, location->start + location->length, start_line);
+
+ rb_code_location_t code_location = (rb_code_location_t) {
+ .beg_pos = { .lineno = (int) start.line, .column = (int) start.column },
+ .end_pos = { .lineno = (int) end.line, .column = (int) end.column }
+ };
+
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, &code_location, node->ast_node->node_id,
+ parent, isolated_depth, type, node->script_lines == NULL ? Qnil : *node->script_lines, option);
+
+ pm_iseq_compile_node(iseq, node);
+ finish_iseq_build(iseq);
return iseq_translate(iseq);
}
+struct pm_iseq_new_with_opt_data {
+ rb_iseq_t *iseq;
+ pm_scope_node_t *node;
+ VALUE name, path, realpath;
+ int first_lineno, isolated_depth;
+ const rb_iseq_t *parent;
+ enum rb_iseq_type type;
+ const rb_compile_option_t *option;
+};
+
+static VALUE
+pm_iseq_new_with_opt_try(VALUE d)
+{
+ struct pm_iseq_new_with_opt_data *data = (struct pm_iseq_new_with_opt_data *)d;
+ data->iseq = pm_iseq_build(data->node, data->name, data->path, data->realpath,
+ data->first_lineno, data->parent, data->isolated_depth,
+ data->type, data->option);
+ return Qundef;
+}
+
+/**
+ * This is a step in the prism compiler that is called once all of the various
+ * options have been established. It is called from one of the pm_iseq_new_*
+ * functions or from the RubyVM::InstructionSequence APIs.
+ *
+ * This function uses rb_protect to catch exceptions, storing the error state
+ * in the provided out parameter. This is only needed at top-level entry points
+ * where the caller wants to handle errors gracefully. Child iseqs compiled
+ * during the compilation process do NOT go through this function — they use
+ * pm_iseq_build directly, letting exceptions propagate naturally (matching
+ * the parse.y compiler's behavior).
+ */
+rb_iseq_t *
+pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
+ int first_lineno, const rb_iseq_t *parent, int isolated_depth,
+ enum rb_iseq_type type, const rb_compile_option_t *option, int *error_state)
+{
+ struct pm_iseq_new_with_opt_data data = {
+ .node = node, .name = name, .path = path, .realpath = realpath,
+ .first_lineno = first_lineno, .parent = parent,
+ .isolated_depth = isolated_depth, .type = type, .option = option
+ };
+ rb_protect(pm_iseq_new_with_opt_try, (VALUE)&data, error_state);
+
+ if (*error_state) return NULL;
+
+ return data.iseq;
+}
+
rb_iseq_t *
rb_iseq_new_with_callback(
const struct rb_iseq_new_with_callback_callback_func * ifunc,
@@ -953,7 +1210,22 @@ rb_iseq_load_iseq(VALUE fname)
VALUE iseqv = rb_check_funcall(rb_cISeq, rb_intern("load_iseq"), 1, &fname);
if (!SPECIAL_CONST_P(iseqv) && RBASIC_CLASS(iseqv) == rb_cISeq) {
- return iseqw_check(iseqv);
+ return iseqw_check(iseqv);
+ }
+
+ return NULL;
+}
+
+const rb_iseq_t *
+rb_iseq_compile_iseq(VALUE str, VALUE fname)
+{
+ VALUE args[] = {
+ str, fname
+ };
+ VALUE iseqv = rb_check_funcall(rb_cISeq, rb_intern("compile"), 2, args);
+
+ if (!SPECIAL_CONST_P(iseqv) && RBASIC_CLASS(iseqv) == rb_cISeq) {
+ return iseqw_check(iseqv);
}
return NULL;
@@ -1049,6 +1321,10 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
tmp_loc.end_pos.column = NUM2INT(rb_ary_entry(code_location, 3));
}
+ if (SYM2ID(rb_hash_aref(misc, ID2SYM(rb_intern("parser")))) == rb_intern("prism")) {
+ ISEQ_BODY(iseq)->prism = true;
+ }
+
make_compile_option(&option, opt);
option.peephole_optimization = FALSE; /* because peephole optimization can modify original iseq */
prepare_iseq_build(iseq, name, path, realpath, first_lineno, &tmp_loc, NUM2INT(node_id),
@@ -1088,9 +1364,10 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
#else
# define INITIALIZED /* volatile */
#endif
- rb_ast_t *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
+ VALUE (*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
int ln;
- rb_ast_t *INITIALIZED ast;
+ VALUE INITIALIZED ast_value;
+ rb_ast_t *ast;
VALUE name = rb_fstring_lit("<compiled>");
/* safe results first */
@@ -1106,26 +1383,105 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
}
{
const VALUE parser = rb_parser_new();
- const rb_iseq_t *outer_scope = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP);
+ const rb_iseq_t *outer_scope = rb_iseq_new(Qnil, name, name, Qnil, 0, ISEQ_TYPE_TOP);
VALUE outer_scope_v = (VALUE)outer_scope;
rb_parser_set_context(parser, outer_scope, FALSE);
+ if (ruby_vm_keep_script_lines) rb_parser_set_script_lines(parser);
RB_GC_GUARD(outer_scope_v);
- ast = (*parse)(parser, file, src, ln);
+ ast_value = (*parse)(parser, file, src, ln);
}
- if (!ast->body.root) {
+ ast = rb_ruby_ast_data_get(ast_value);
+
+ if (!ast || !ast->body.root) {
rb_ast_dispose(ast);
rb_exc_raise(GET_EC()->errinfo);
}
else {
- iseq = rb_iseq_new_with_opt(&ast->body, name, file, realpath, ln,
- NULL, 0, ISEQ_TYPE_TOP, &option);
+ iseq_new_setup_coverage(file, ast_line_count(ast_value));
+ iseq = rb_iseq_new_with_opt(ast_value, name, file, realpath, ln,
+ NULL, 0, ISEQ_TYPE_TOP, &option,
+ Qnil);
rb_ast_dispose(ast);
}
return iseq;
}
+static rb_iseq_t *
+pm_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, VALUE opt)
+{
+ rb_iseq_t *iseq = NULL;
+ rb_compile_option_t option;
+ int ln;
+ VALUE name = rb_fstring_lit("<compiled>");
+
+ /* safe results first */
+ make_compile_option(&option, opt);
+ ln = NUM2INT(line);
+ StringValueCStr(file);
+
+ bool parse_file = false;
+ if (RB_TYPE_P(src, T_FILE)) {
+ parse_file = true;
+ src = rb_io_path(src);
+ }
+ else {
+ src = StringValue(src);
+ }
+
+ pm_parse_result_t result;
+ pm_parse_result_init(&result);
+ pm_options_line_set(result.options, NUM2INT(line));
+ pm_options_scopes_init(result.options, 1);
+ result.node.coverage_enabled = 1;
+
+ switch (option.frozen_string_literal) {
+ case ISEQ_FROZEN_STRING_LITERAL_UNSET:
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
+ pm_options_frozen_string_literal_set(result.options, false);
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
+ pm_options_frozen_string_literal_set(result.options, true);
+ break;
+ default:
+ rb_bug("pm_iseq_compile_with_option: invalid frozen_string_literal=%d", option.frozen_string_literal);
+ break;
+ }
+
+ VALUE script_lines;
+ VALUE error;
+
+ if (parse_file) {
+ error = pm_load_parse_file(&result, src, ruby_vm_keep_script_lines ? &script_lines : NULL);
+ }
+ else {
+ error = pm_parse_string(&result, src, file, ruby_vm_keep_script_lines ? &script_lines : NULL);
+ }
+
+ RB_GC_GUARD(src);
+
+ if (error == Qnil) {
+ int error_state;
+ iseq_new_setup_coverage(file, (int) (pm_parser_line_offsets(result.node.parser)->size - 1));
+ iseq = pm_iseq_new_with_opt(&result.node, name, file, realpath, ln, NULL, 0, ISEQ_TYPE_TOP, &option, &error_state);
+
+ pm_parse_result_free(&result);
+
+ if (error_state) {
+ RUBY_ASSERT(iseq == NULL);
+ rb_jump_tag(error_state);
+ }
+ }
+ else {
+ pm_parse_result_free(&result);
+ rb_exc_raise(error);
+ }
+
+ return iseq;
+}
+
VALUE
rb_iseq_path(const rb_iseq_t *iseq)
{
@@ -1210,8 +1566,8 @@ remove_coverage_i(void *vstart, void *vend, size_t stride, void *data)
{
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
if (rb_obj_is_iseq(v)) {
rb_iseq_t *iseq = (rb_iseq_t *)v;
@@ -1232,20 +1588,25 @@ rb_iseq_remove_coverage_all(void)
/* define wrapper class methods (RubyVM::InstructionSequence) */
static void
-iseqw_mark(void *ptr)
+iseqw_mark_and_move(void *ptr)
{
- rb_gc_mark((VALUE)ptr);
+ rb_gc_mark_and_move((VALUE *)ptr);
}
static size_t
iseqw_memsize(const void *ptr)
{
- return rb_iseq_memsize((const rb_iseq_t *)ptr);
+ return rb_iseq_memsize(*(const rb_iseq_t **)ptr);
}
static const rb_data_type_t iseqw_data_type = {
"T_IMEMO/iseq",
- {iseqw_mark, NULL, iseqw_memsize,},
+ {
+ iseqw_mark_and_move,
+ RUBY_TYPED_DEFAULT_FREE,
+ iseqw_memsize,
+ iseqw_mark_and_move,
+ },
0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
};
@@ -1253,18 +1614,20 @@ static VALUE
iseqw_new(const rb_iseq_t *iseq)
{
if (iseq->wrapper) {
+ if (*(const rb_iseq_t **)rb_check_typeddata(iseq->wrapper, &iseqw_data_type) != iseq) {
+ rb_raise(rb_eTypeError, "wrong iseq wrapper: %" PRIsVALUE " for %p",
+ iseq->wrapper, (void *)iseq);
+ }
return iseq->wrapper;
}
else {
- union { const rb_iseq_t *in; void *out; } deconst;
- VALUE obj;
- deconst.in = iseq;
- obj = TypedData_Wrap_Struct(rb_cISeq, &iseqw_data_type, deconst.out);
- RB_OBJ_WRITTEN(obj, Qundef, iseq);
+ rb_iseq_t **ptr;
+ VALUE obj = TypedData_Make_Struct(rb_cISeq, rb_iseq_t *, &iseqw_data_type, ptr);
+ RB_OBJ_WRITE(obj, ptr, iseq);
/* cache a wrapper object */
+ RB_OBJ_SET_FROZEN_SHAREABLE((VALUE)obj);
RB_OBJ_WRITE((VALUE)iseq, &iseq->wrapper, obj);
- RB_OBJ_FREEZE((VALUE)iseq);
return obj;
}
@@ -1276,19 +1639,57 @@ rb_iseqw_new(const rb_iseq_t *iseq)
return iseqw_new(iseq);
}
+/**
+ * Accept the options given to InstructionSequence.compile and
+ * InstructionSequence.compile_prism and share the logic for creating the
+ * instruction sequence.
+ */
+static VALUE
+iseqw_s_compile_parser(int argc, VALUE *argv, VALUE self, bool prism)
+{
+ VALUE src, file = Qnil, path = Qnil, line = Qnil, opt = Qnil;
+ int i;
+
+ i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
+ if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
+ switch (i) {
+ case 5: opt = argv[--i];
+ case 4: line = argv[--i];
+ case 3: path = argv[--i];
+ case 2: file = argv[--i];
+ }
+
+ if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
+ if (NIL_P(path)) path = file;
+ if (NIL_P(line)) line = INT2FIX(1);
+
+ Check_Type(path, T_STRING);
+ Check_Type(file, T_STRING);
+
+ rb_iseq_t *iseq;
+ if (prism) {
+ iseq = pm_iseq_compile_with_option(src, file, path, line, opt);
+ }
+ else {
+ iseq = rb_iseq_compile_with_option(src, file, path, line, opt);
+ }
+
+ return iseqw_new(iseq);
+}
+
/*
* call-seq:
* InstructionSequence.compile(source[, file[, path[, line[, options]]]]) -> iseq
* InstructionSequence.new(source[, file[, path[, line[, options]]]]) -> iseq
*
- * Takes +source+, a String of Ruby code and compiles it to an
- * InstructionSequence.
+ * Takes +source+, which can be a string of Ruby code, or an open +File+ object.
+ * that contains Ruby source code.
*
* Optionally takes +file+, +path+, and +line+ which describe the file path,
* real path and first line number of the ruby code in +source+ which are
* metadata attached to the returned +iseq+.
*
- * +file+ is used for `__FILE__` and exception backtrace. +path+ is used for
+ * +file+ is used for +__FILE__+ and exception backtrace. +path+ is used for
* +require_relative+ base. It is recommended these should be the same full
* path.
*
@@ -1304,6 +1705,10 @@ rb_iseqw_new(const rb_iseq_t *iseq)
* RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path))
* #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
*
+ * file = File.open("test.rb")
+ * RubyVM::InstructionSequence.compile(file)
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1>
+ *
* path = File.expand_path("test.rb")
* RubyVM::InstructionSequence.compile(File.read(path), path, path)
* #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
@@ -1312,28 +1717,95 @@ rb_iseqw_new(const rb_iseq_t *iseq)
static VALUE
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
{
- VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil;
- int i;
-
- i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
- if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
- switch (i) {
- case 5: opt = argv[--i];
- case 4: line = argv[--i];
- case 3: path = argv[--i];
- case 2: file = argv[--i];
- }
-
- if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
- if (NIL_P(path)) path = file;
- if (NIL_P(line)) line = INT2FIX(1);
+ return iseqw_s_compile_parser(argc, argv, self, rb_ruby_prism_p());
+}
- Check_Type(path, T_STRING);
- Check_Type(file, T_STRING);
+/*
+ * call-seq:
+ * InstructionSequence.compile_parsey(source[, file[, path[, line[, options]]]]) -> iseq
+ *
+ * Takes +source+, which can be a string of Ruby code, or an open +File+ object.
+ * that contains Ruby source code. It parses and compiles using parse.y.
+ *
+ * Optionally takes +file+, +path+, and +line+ which describe the file path,
+ * real path and first line number of the ruby code in +source+ which are
+ * metadata attached to the returned +iseq+.
+ *
+ * +file+ is used for +__FILE__+ and exception backtrace. +path+ is used for
+ * +require_relative+ base. It is recommended these should be the same full
+ * path.
+ *
+ * +options+, which can be +true+, +false+ or a +Hash+, is used to
+ * modify the default behavior of the Ruby iseq compiler.
+ *
+ * For details regarding valid compile options see ::compile_option=.
+ *
+ * RubyVM::InstructionSequence.compile_parsey("a = 1 + 2")
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
+ *
+ * path = "test.rb"
+ * RubyVM::InstructionSequence.compile_parsey(File.read(path), path, File.expand_path(path))
+ * #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
+ *
+ * file = File.open("test.rb")
+ * RubyVM::InstructionSequence.compile_parsey(file)
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1>
+ *
+ * path = File.expand_path("test.rb")
+ * RubyVM::InstructionSequence.compile_parsey(File.read(path), path, path)
+ * #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
+ *
+ */
+static VALUE
+iseqw_s_compile_parsey(int argc, VALUE *argv, VALUE self)
+{
+ return iseqw_s_compile_parser(argc, argv, self, false);
+}
- return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, opt));
+/*
+ * call-seq:
+ * InstructionSequence.compile_prism(source[, file[, path[, line[, options]]]]) -> iseq
+ *
+ * Takes +source+, which can be a string of Ruby code, or an open +File+ object.
+ * that contains Ruby source code. It parses and compiles using prism.
+ *
+ * Optionally takes +file+, +path+, and +line+ which describe the file path,
+ * real path and first line number of the ruby code in +source+ which are
+ * metadata attached to the returned +iseq+.
+ *
+ * +file+ is used for +__FILE__+ and exception backtrace. +path+ is used for
+ * +require_relative+ base. It is recommended these should be the same full
+ * path.
+ *
+ * +options+, which can be +true+, +false+ or a +Hash+, is used to
+ * modify the default behavior of the Ruby iseq compiler.
+ *
+ * For details regarding valid compile options see ::compile_option=.
+ *
+ * RubyVM::InstructionSequence.compile_prism("a = 1 + 2")
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
+ *
+ * path = "test.rb"
+ * RubyVM::InstructionSequence.compile_prism(File.read(path), path, File.expand_path(path))
+ * #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
+ *
+ * file = File.open("test.rb")
+ * RubyVM::InstructionSequence.compile_prism(file)
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1>
+ *
+ * path = File.expand_path("test.rb")
+ * RubyVM::InstructionSequence.compile_prism(File.read(path), path, path)
+ * #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
+ *
+ */
+static VALUE
+iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
+{
+ return iseqw_s_compile_parser(argc, argv, self, true);
}
+static VALUE iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self);
+
/*
* call-seq:
* InstructionSequence.compile_file(file[, options]) -> iseq
@@ -1357,9 +1829,14 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
static VALUE
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
{
+ if (rb_ruby_prism_p()) {
+ return iseqw_s_compile_file_prism(argc, argv, self);
+ }
+
VALUE file, opt = Qnil;
VALUE parser, f, exc = Qnil, ret;
rb_ast_t *ast;
+ VALUE ast_value;
rb_compile_option_t option;
int i;
@@ -1378,7 +1855,9 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
- ast = (rb_ast_t *)rb_parser_load_file(parser, file);
+ ast_value = rb_parser_load_file(parser, file);
+ iseq_new_setup_coverage(file, ast_line_count(ast_value));
+ ast = rb_ruby_ast_data_get(ast_value);
if (!ast->body.root) exc = GET_EC()->errinfo;
rb_io_close(f);
@@ -1389,11 +1868,13 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
make_compile_option(&option, opt);
- ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("<main>"),
+ ret = iseqw_new(rb_iseq_new_with_opt(ast_value, rb_fstring_lit("<main>"),
file,
rb_realpath_internal(Qnil, file, 1),
- 1, NULL, 0, ISEQ_TYPE_TOP, &option));
+ 1, NULL, 0, ISEQ_TYPE_TOP, &option,
+ Qnil));
rb_ast_dispose(ast);
+ RB_GC_GUARD(ast_value);
rb_vm_pop_frame(ec);
RB_GC_GUARD(v);
@@ -1402,6 +1883,96 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
+ * InstructionSequence.compile_file_prism(file[, options]) -> iseq
+ *
+ * Takes +file+, a String with the location of a Ruby source file, reads,
+ * parses and compiles the file, and returns +iseq+, the compiled
+ * InstructionSequence with source location metadata set. It parses and
+ * compiles using prism.
+ *
+ * Optionally takes +options+, which can be +true+, +false+ or a +Hash+, to
+ * modify the default behavior of the Ruby iseq compiler.
+ *
+ * For details regarding valid compile options see ::compile_option=.
+ *
+ * # /tmp/hello.rb
+ * puts "Hello, world!"
+ *
+ * # elsewhere
+ * RubyVM::InstructionSequence.compile_file_prism("/tmp/hello.rb")
+ * #=> <RubyVM::InstructionSequence:<main>@/tmp/hello.rb>
+ */
+static VALUE
+iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self)
+{
+ VALUE file, opt = Qnil, ret;
+ rb_compile_option_t option;
+ int i;
+
+ i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt);
+ if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2);
+ switch (i) {
+ case 2: opt = argv[--i];
+ }
+ FilePathValue(file);
+ file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
+
+ rb_execution_context_t *ec = GET_EC();
+ VALUE v = rb_vm_push_frame_fname(ec, file);
+
+ make_compile_option(&option, opt);
+
+ pm_parse_result_t result;
+ pm_parse_result_init(&result);
+ result.node.coverage_enabled = 1;
+
+ switch (option.frozen_string_literal) {
+ case ISEQ_FROZEN_STRING_LITERAL_UNSET:
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
+ pm_options_frozen_string_literal_set(result.options, false);
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
+ pm_options_frozen_string_literal_set(result.options, true);
+ break;
+ default:
+ rb_bug("iseqw_s_compile_file_prism: invalid frozen_string_literal=%d", option.frozen_string_literal);
+ break;
+ }
+
+ VALUE script_lines;
+ VALUE error = pm_load_parse_file(&result, file, ruby_vm_keep_script_lines ? &script_lines : NULL);
+
+ if (error == Qnil) {
+ int error_state;
+ iseq_new_setup_coverage(file, (int) (pm_parser_line_offsets(result.node.parser)->size - 1));
+ rb_iseq_t *iseq = pm_iseq_new_with_opt(&result.node, rb_fstring_lit("<main>"),
+ file,
+ rb_realpath_internal(Qnil, file, 1),
+ 1, NULL, 0, ISEQ_TYPE_TOP, &option, &error_state);
+
+ pm_parse_result_free(&result);
+
+ if (error_state) {
+ RUBY_ASSERT(iseq == NULL);
+ rb_jump_tag(error_state);
+ }
+
+ ret = iseqw_new(iseq);
+ rb_vm_pop_frame(ec);
+ RB_GC_GUARD(v);
+ return ret;
+ }
+ else {
+ pm_parse_result_free(&result);
+ rb_vm_pop_frame(ec);
+ RB_GC_GUARD(v);
+ rb_exc_raise(error);
+ }
+}
+
+/*
+ * call-seq:
* InstructionSequence.compile_option = options
*
* Sets the default values for various optimizations in the Ruby iseq
@@ -1422,7 +1993,6 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
* * +:operands_unification+
* * +:peephole_optimization+
* * +:specialized_instruction+
- * * +:stack_caching+
* * +:tailcall_optimization+
*
* Additionally, +:debug_level+ can be set to an integer.
@@ -1457,7 +2027,9 @@ iseqw_s_compile_option_get(VALUE self)
static const rb_iseq_t *
iseqw_check(VALUE iseqw)
{
- rb_iseq_t *iseq = DATA_PTR(iseqw);
+ rb_iseq_t **iseq_ptr;
+ TypedData_Get_Struct(iseqw, rb_iseq_t *, &iseqw_data_type, iseq_ptr);
+ rb_iseq_t *iseq = *iseq_ptr;
if (!ISEQ_BODY(iseq)) {
rb_ibf_load_iseq_complete(iseq);
@@ -1486,7 +2058,11 @@ rb_iseqw_to_iseq(VALUE iseqw)
static VALUE
iseqw_eval(VALUE self)
{
- return rb_iseq_eval(iseqw_check(self));
+ const rb_iseq_t *iseq = iseqw_check(self);
+ if (0 == ISEQ_BODY(iseq)->iseq_size) {
+ rb_raise(rb_eTypeError, "attempt to evaluate dummy InstructionSequence");
+ }
+ return rb_iseq_eval(iseq, rb_current_box());
}
/*
@@ -1920,15 +2496,22 @@ rb_iseq_event_flags(const rb_iseq_t *iseq, size_t pos)
}
}
+static void rb_iseq_trace_flag_cleared(const rb_iseq_t *iseq, size_t pos);
+
+// Clear tracing event flags and turn off tracing for a given instruction as needed.
+// This is currently used after updating a one-shot line coverage for the current instruction.
void
rb_iseq_clear_event_flags(const rb_iseq_t *iseq, size_t pos, rb_event_flag_t reset)
{
- struct iseq_insn_info_entry *entry = (struct iseq_insn_info_entry *)get_insn_info(iseq, pos);
- if (entry) {
- entry->events &= ~reset;
- if (!(entry->events & iseq->aux.exec.global_trace_events)) {
- void rb_iseq_trace_flag_cleared(const rb_iseq_t *iseq, size_t pos);
- rb_iseq_trace_flag_cleared(iseq, pos);
+ RB_VM_LOCKING() {
+ rb_vm_barrier();
+
+ struct iseq_insn_info_entry *entry = (struct iseq_insn_info_entry *)get_insn_info(iseq, pos);
+ if (entry) {
+ entry->events &= ~reset;
+ if (!(entry->events & iseq->aux.exec.global_trace_events)) {
+ rb_iseq_trace_flag_cleared(iseq, pos);
+ }
}
}
}
@@ -1950,7 +2533,7 @@ local_var_name(const rb_iseq_t *diseq, VALUE level, VALUE op)
if (!name) {
name = rb_str_new_cstr("?");
}
- else if (!rb_str_symname_p(name)) {
+ else if (!rb_is_local_id(lid)) {
name = rb_str_inspect(name);
}
else {
@@ -2100,17 +2683,18 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
VALUE flags = rb_ary_new();
# define CALL_FLAG(n) if (vm_ci_flag(ci) & VM_CALL_##n) rb_ary_push(flags, rb_str_new2(#n))
CALL_FLAG(ARGS_SPLAT);
+ CALL_FLAG(ARGS_SPLAT_MUT);
CALL_FLAG(ARGS_BLOCKARG);
CALL_FLAG(FCALL);
CALL_FLAG(VCALL);
CALL_FLAG(ARGS_SIMPLE);
- CALL_FLAG(BLOCKISEQ);
CALL_FLAG(TAILCALL);
CALL_FLAG(SUPER);
CALL_FLAG(ZSUPER);
CALL_FLAG(KWARG);
CALL_FLAG(KW_SPLAT);
CALL_FLAG(KW_SPLAT_MUT);
+ CALL_FLAG(FORWARDING);
CALL_FLAG(OPT_SEND); /* maybe not reachable */
rb_ary_push(ary, rb_ary_join(flags, rb_str_new2("|")));
}
@@ -2208,7 +2792,7 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
{
rb_event_flag_t events = rb_iseq_event_flags(iseq, pos);
if (events) {
- str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s%s%s]",
+ str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s%s%s%s]",
events & RUBY_EVENT_LINE ? "Li" : "",
events & RUBY_EVENT_CLASS ? "Cl" : "",
events & RUBY_EVENT_END ? "En" : "",
@@ -2218,6 +2802,7 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
events & RUBY_EVENT_C_RETURN ? "Cr" : "",
events & RUBY_EVENT_B_CALL ? "Bc" : "",
events & RUBY_EVENT_B_RETURN ? "Br" : "",
+ events & RUBY_EVENT_RESCUE ? "Rs" : "",
events & RUBY_EVENT_COVERAGE_LINE ? "Cli" : "",
events & RUBY_EVENT_COVERAGE_BRANCH ? "Cbr" : "");
}
@@ -2307,11 +2892,20 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
rb_str_cat2(str, "== disasm: ");
rb_str_append(str, iseq_inspect(iseq));
- rb_str_catf(str, " (catch: %s)", body->catch_except_p ? "true" : "false");
if ((l = RSTRING_LEN(str) - indent_len) < header_minlen) {
rb_str_modify_expand(str, header_minlen - l);
memset(RSTRING_END(str), '=', header_minlen - l);
}
+ if (iseq->body->builtin_attrs) {
+#define disasm_builtin_attr(str, iseq, attr) \
+ if (iseq->body->builtin_attrs & BUILTIN_ATTR_ ## attr) { \
+ rb_str_cat2(str, " " #attr); \
+ }
+ disasm_builtin_attr(str, iseq, LEAF);
+ disasm_builtin_attr(str, iseq, SINGLE_NOARG_LEAF);
+ disasm_builtin_attr(str, iseq, INLINE_BLOCK);
+ disasm_builtin_attr(str, iseq, C_TRACE);
+ }
rb_str_cat2(str, "\n");
/* show catch table information */
@@ -2384,11 +2978,11 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
}
snprintf(argi, sizeof(argi), "%s%s%s%s%s%s", /* arg, opts, rest, post, kwrest, block */
- body->param.lead_num > li ? "Arg" : "",
+ (body->param.lead_num > li) ? (body->param.flags.ambiguous_param0 ? "AmbiguousArg" : "Arg") : "",
opti,
- (body->param.flags.has_rest && body->param.rest_start == li) ? "Rest" : "",
+ (body->param.flags.has_rest && body->param.rest_start == li) ? (body->param.flags.anon_rest ? "AnonRest" : "Rest") : "",
(body->param.flags.has_post && body->param.post_start <= li && li < body->param.post_start + body->param.post_num) ? "Post" : "",
- (body->param.flags.has_kwrest && keyword->rest_start == li) ? "Kwrest" : "",
+ (body->param.flags.has_kwrest && keyword->rest_start == li) ? (body->param.flags.anon_kwrest ? "AnonKwrest" : "Kwrest") : "",
(body->param.flags.has_block && body->param.block_start == li) ? "Block" : "");
rb_str_cat(str, indent_str, indent_len);
@@ -2436,24 +3030,31 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
attr_index_t
rb_estimate_iv_count(VALUE klass, const rb_iseq_t * initialize_iseq)
{
- struct rb_id_table * iv_names = rb_id_table_create(0);
+ set_table iv_names = { 0 };
+ set_init_embedded_numtable_with_size(&iv_names, 0);
for (unsigned int i = 0; i < ISEQ_BODY(initialize_iseq)->ivc_size; i++) {
IVC cache = (IVC)&ISEQ_BODY(initialize_iseq)->is_entries[i];
if (cache->iv_set_name) {
- rb_id_table_insert(iv_names, cache->iv_set_name, Qtrue);
+ set_insert(&iv_names, cache->iv_set_name);
}
}
- attr_index_t count = (attr_index_t)rb_id_table_size(iv_names);
+ size_t count = iv_names.num_entries;
VALUE superclass = rb_class_superclass(klass);
- count += RCLASS_EXT(superclass)->max_iv_count;
+ if (!NIL_P(superclass)) { // BasicObject doesn't have a superclass
+ count += RCLASS_MAX_IV_COUNT(superclass);
+ }
- rb_id_table_free(iv_names);
+ set_free_embedded_table(&iv_names);
- return count;
+ if (count > (attr_index_t)-1) {
+ return (attr_index_t)-1;
+ }
+
+ return (attr_index_t)count;
}
/*
@@ -2563,6 +3164,7 @@ push_event_info(const rb_iseq_t *iseq, rb_event_flag_t events, int line, VALUE a
C(RUBY_EVENT_END, "end", INT2FIX(line));
C(RUBY_EVENT_RETURN, "return", INT2FIX(line));
C(RUBY_EVENT_B_RETURN, "b_return", INT2FIX(line));
+ C(RUBY_EVENT_RESCUE, "rescue", INT2FIX(line));
#undef C
}
@@ -2630,7 +3232,10 @@ iseqw_s_of(VALUE klass, VALUE body)
{
const rb_iseq_t *iseq = NULL;
- if (rb_obj_is_proc(body)) {
+ if (rb_frame_info_p(body)) {
+ iseq = rb_get_iseq_from_frame_info(body);
+ }
+ else if (rb_obj_is_proc(body)) {
iseq = vm_proc_iseq(body);
if (!rb_obj_is_iseq((VALUE)iseq)) {
@@ -2652,10 +3257,10 @@ iseqw_s_of(VALUE klass, VALUE body)
* InstructionSequence.disasm(body) -> str
* InstructionSequence.disassemble(body) -> str
*
- * Takes +body+, a Method or Proc object, and returns a String with the
- * human readable instructions for +body+.
+ * Takes +body+, a +Method+ or +Proc+ object, and returns a +String+
+ * with the human readable instructions for +body+.
*
- * For a Method object:
+ * For a +Method+ object:
*
* # /tmp/method.rb
* def hello
@@ -2670,12 +3275,12 @@ iseqw_s_of(VALUE klass, VALUE body)
* 0000 trace 8 ( 1)
* 0002 trace 1 ( 2)
* 0004 putself
- * 0005 putstring "hello, world"
+ * 0005 dupstring "hello, world"
* 0007 send :puts, 1, nil, 8, <ic:0>
* 0013 trace 16 ( 3)
* 0015 leave ( 2)
*
- * For a Proc:
+ * For a +Proc+ object:
*
* # /tmp/proc.rb
* p = proc { num = 1 + 2 }
@@ -2706,17 +3311,6 @@ iseqw_s_disasm(VALUE klass, VALUE body)
return NIL_P(iseqw) ? Qnil : rb_iseq_disasm(iseqw_check(iseqw));
}
-const char *
-ruby_node_name(int node)
-{
- switch (node) {
-#include "node_name.inc"
- default:
- rb_bug("unknown node: %d", node);
- return 0;
- }
-}
-
static VALUE
register_label(struct st_table *table, unsigned long idx)
{
@@ -2746,7 +3340,7 @@ static int
cdhash_each(VALUE key, VALUE value, VALUE ary)
{
rb_ary_push(ary, obj_resurrect(key));
- rb_ary_push(ary, value);
+ rb_ary_push(ary, INT2FIX(value));
return ST_CONTINUE;
}
@@ -2805,6 +3399,7 @@ iseq_type_id(enum rb_iseq_type type)
static VALUE
iseq_data_to_ary(const rb_iseq_t *iseq)
{
+ VALUE iseq_value = (VALUE)iseq;
unsigned int i;
long l;
const struct rb_iseq_constant_body *const iseq_body = ISEQ_BODY(iseq);
@@ -2822,7 +3417,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
VALUE exception = rb_ary_new(); /* [[....]] */
VALUE misc = rb_hash_new();
- static ID insn_syms[VM_INSTRUCTION_SIZE/2]; /* w/o-trace only */
+ static ID insn_syms[VM_BARE_INSTRUCTION_SIZE]; /* w/o-trace only */
struct st_table *labels_table = st_init_numtable();
VALUE labels_wrapper = TypedData_Wrap_Struct(0, &label_wrapper, labels_table);
@@ -2840,7 +3435,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
for (i=0; i<iseq_body->local_table_size; i++) {
ID lid = iseq_body->local_table[i];
if (lid) {
- if (rb_id2str(lid)) {
+ if (lid != idItImplicit && rb_id2str(lid)) {
rb_ary_push(locals, ID2SYM(lid));
}
else { /* hidden variable from id_internal() */
@@ -2894,6 +3489,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
}
if (iseq_body->param.flags.has_kwrest) rb_hash_aset(params, ID2SYM(rb_intern("kwrest")), INT2FIX(keyword->rest_start));
if (iseq_body->param.flags.ambiguous_param0) rb_hash_aset(params, ID2SYM(rb_intern("ambiguous_param0")), Qtrue);
+ if (iseq_body->param.flags.use_block) rb_hash_aset(params, ID2SYM(rb_intern("use_block")), Qtrue);
}
/* body */
@@ -2985,11 +3581,11 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
break;
case TS_CDHASH:
{
- VALUE hash = *seq;
+ VALUE cdhash = *seq;
VALUE val = rb_ary_new();
int i;
- rb_hash_foreach(hash, cdhash_each, val);
+ st_foreach(rb_imemo_cdhash_tbl(cdhash), cdhash_each, val);
for (i=0; i<RARRAY_LEN(val); i+=2) {
VALUE pos = FIX2INT(rb_ary_entry(val, i+1));
@@ -3091,6 +3687,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
CHECK_EVENT(RUBY_EVENT_RETURN);
CHECK_EVENT(RUBY_EVENT_B_CALL);
CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_RESCUE);
#undef CHECK_EVENT
prev_insn_info = info;
}
@@ -3114,6 +3711,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
#ifdef USE_ISEQ_NODE_ID
rb_hash_aset(misc, ID2SYM(rb_intern("node_ids")), node_ids);
#endif
+ rb_hash_aset(misc, ID2SYM(rb_intern("parser")), iseq_body->prism ? ID2SYM(rb_intern("prism")) : ID2SYM(rb_intern("parse.y")));
/*
* [:magic, :major_version, :minor_version, :format_type, :misc,
@@ -3134,6 +3732,9 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(val, params);
rb_ary_push(val, exception);
rb_ary_push(val, body);
+
+ RB_GC_GUARD(iseq_value);
+
return val;
}
@@ -3147,19 +3748,28 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
ID req, opt, rest, block, key, keyrest;
#define PARAM_TYPE(type) rb_ary_push(a = rb_ary_new2(2), ID2SYM(type))
#define PARAM_ID(i) body->local_table[(i)]
-#define PARAM(i, type) ( \
- PARAM_TYPE(type), \
- rb_id2str(PARAM_ID(i)) ? \
- rb_ary_push(a, ID2SYM(PARAM_ID(i))) : \
+#define PARAM(i, type) ( \
+ PARAM_TYPE(type), \
+ PARAM_ID(i) != idItImplicit && rb_id2str(PARAM_ID(i)) ? \
+ rb_ary_push(a, ID2SYM(PARAM_ID(i))) : \
a)
CONST_ID(req, "req");
CONST_ID(opt, "opt");
+
+ if (body->param.flags.forwardable) {
+ // [[:rest, :*], [:keyrest, :**], [:block, :&]]
+ CONST_ID(rest, "rest");
+ CONST_ID(keyrest, "keyrest");
+ CONST_ID(block, "block");
+ rb_ary_push(args, rb_ary_new_from_args(2, ID2SYM(rest), ID2SYM(idMULT)));
+ rb_ary_push(args, rb_ary_new_from_args(2, ID2SYM(keyrest), ID2SYM(idPow)));
+ rb_ary_push(args, rb_ary_new_from_args(2, ID2SYM(block), ID2SYM(idAnd)));
+ }
+
if (is_proc) {
for (i = 0; i < body->param.lead_num; i++) {
- PARAM_TYPE(opt);
- rb_ary_push(a, rb_id2str(PARAM_ID(i)) ? ID2SYM(PARAM_ID(i)) : Qnil);
- rb_ary_push(args, a);
+ rb_ary_push(args, PARAM(i, opt));
}
}
else {
@@ -3169,11 +3779,7 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
}
r = body->param.lead_num + body->param.opt_num;
for (; i < r; i++) {
- PARAM_TYPE(opt);
- if (rb_id2str(PARAM_ID(i))) {
- rb_ary_push(a, ID2SYM(PARAM_ID(i)));
- }
- rb_ary_push(args, a);
+ rb_ary_push(args, PARAM(i, opt));
}
if (body->param.flags.has_rest) {
CONST_ID(rest, "rest");
@@ -3182,9 +3788,7 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
r = body->param.post_start + body->param.post_num;
if (is_proc) {
for (i = body->param.post_start; i < r; i++) {
- PARAM_TYPE(opt);
- rb_ary_push(a, rb_id2str(PARAM_ID(i)) ? ID2SYM(PARAM_ID(i)) : Qnil);
- rb_ary_push(args, a);
+ rb_ary_push(args, PARAM(i, opt));
}
}
else {
@@ -3233,7 +3837,13 @@ rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
}
rb_ary_push(args, a);
}
- if (body->param.flags.has_block) {
+ if (body->param.flags.accepts_no_block) {
+ ID noblock;
+ CONST_ID(noblock, "noblock");
+ PARAM_TYPE(noblock);
+ rb_ary_push(args, a);
+ }
+ else if (body->param.flags.has_block) {
CONST_ID(block, "block");
rb_ary_push(args, PARAM(body->param.block_start, block));
}
@@ -3266,51 +3876,73 @@ rb_iseq_defined_string(enum defined_type type)
return rb_fstring_cstr(estr);
}
-/* A map from encoded_insn to insn_data: decoded insn number, its len,
- * non-trace version of encoded insn, and trace version. */
-
+// A map from encoded_insn to insn_data: decoded insn number, its len,
+// decoded ZJIT insn number, non-trace version of encoded insn,
+// trace version, and zjit version.
static st_table *encoded_insn_data;
typedef struct insn_data_struct {
int insn;
int insn_len;
void *notrace_encoded_insn;
void *trace_encoded_insn;
+#if USE_ZJIT
+ int zjit_insn;
+ void *zjit_encoded_insn;
+#endif
} insn_data_t;
-static insn_data_t insn_data[VM_INSTRUCTION_SIZE/2];
+static insn_data_t insn_data[VM_BARE_INSTRUCTION_SIZE];
void
+rb_free_encoded_insn_data(void)
+{
+ st_free_table(encoded_insn_data);
+}
+
+// Initialize a table to decode bare, trace, and zjit instructions.
+// This function also determines which instructions are used when TracePoint is enabled.
+void
rb_vm_encoded_insn_data_table_init(void)
{
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
const void * const *table = rb_vm_get_insns_address_table();
#define INSN_CODE(insn) ((VALUE)table[insn])
#else
-#define INSN_CODE(insn) (insn)
+#define INSN_CODE(insn) ((VALUE)(insn))
#endif
- st_data_t insn;
- encoded_insn_data = st_init_numtable_with_size(VM_INSTRUCTION_SIZE / 2);
-
- for (insn = 0; insn < VM_INSTRUCTION_SIZE/2; insn++) {
- st_data_t key1 = (st_data_t)INSN_CODE(insn);
- st_data_t key2 = (st_data_t)INSN_CODE(insn + VM_INSTRUCTION_SIZE/2);
+ encoded_insn_data = st_init_numtable_with_size(VM_BARE_INSTRUCTION_SIZE);
- insn_data[insn].insn = (int)insn;
+ for (int insn = 0; insn < VM_BARE_INSTRUCTION_SIZE; insn++) {
+ insn_data[insn].insn = insn;
insn_data[insn].insn_len = insn_len(insn);
- if (insn != BIN(opt_invokebuiltin_delegate_leave)) {
- insn_data[insn].notrace_encoded_insn = (void *) key1;
- insn_data[insn].trace_encoded_insn = (void *) key2;
- }
- else {
- insn_data[insn].notrace_encoded_insn = (void *) INSN_CODE(BIN(opt_invokebuiltin_delegate));
- insn_data[insn].trace_encoded_insn = (void *) INSN_CODE(BIN(opt_invokebuiltin_delegate) + VM_INSTRUCTION_SIZE/2);
- }
+ // When tracing :return events, we convert opt_invokebuiltin_delegate_leave + leave into
+ // opt_invokebuiltin_delegate + trace_leave, presumably because we don't want to fire
+ // :return events before invokebuiltin. https://github.com/ruby/ruby/pull/3256
+ int notrace_insn = (insn != BIN(opt_invokebuiltin_delegate_leave)) ? insn : BIN(opt_invokebuiltin_delegate);
+ insn_data[insn].notrace_encoded_insn = (void *)INSN_CODE(notrace_insn);
+ insn_data[insn].trace_encoded_insn = (void *)INSN_CODE(notrace_insn + VM_BARE_INSTRUCTION_SIZE);
+ st_data_t key1 = (st_data_t)INSN_CODE(insn);
+ st_data_t key2 = (st_data_t)INSN_CODE(insn + VM_BARE_INSTRUCTION_SIZE);
st_add_direct(encoded_insn_data, key1, (st_data_t)&insn_data[insn]);
st_add_direct(encoded_insn_data, key2, (st_data_t)&insn_data[insn]);
+
+#if USE_ZJIT
+ int zjit_insn = vm_bare_insn_to_zjit_insn(insn);
+ insn_data[insn].zjit_insn = zjit_insn;
+ insn_data[insn].zjit_encoded_insn = (insn != zjit_insn) ? (void *)INSN_CODE(zjit_insn) : 0;
+
+ if (insn != zjit_insn) {
+ st_data_t key3 = (st_data_t)INSN_CODE(zjit_insn);
+ st_add_direct(encoded_insn_data, key3, (st_data_t)&insn_data[insn]);
+ }
+#endif
}
}
+// Decode an insn address to an insn. This returns bare instructions
+// even if they're trace/zjit instructions. Use rb_vm_insn_addr2opcode
+// to decode trace/zjit instructions as is.
int
rb_vm_insn_addr2insn(const void *addr)
{
@@ -3325,7 +3957,8 @@ rb_vm_insn_addr2insn(const void *addr)
rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr);
}
-// Unlike rb_vm_insn_addr2insn, this function can return trace opcode variants.
+// Decode an insn address to an insn. Unlike rb_vm_insn_addr2insn,
+// this function can return trace/zjit opcode variants.
int
rb_vm_insn_addr2opcode(const void *addr)
{
@@ -3336,15 +3969,22 @@ rb_vm_insn_addr2opcode(const void *addr)
insn_data_t *e = (insn_data_t *)val;
int opcode = e->insn;
if (addr == e->trace_encoded_insn) {
- opcode += VM_INSTRUCTION_SIZE/2;
+ opcode += VM_BARE_INSTRUCTION_SIZE;
+ }
+#if USE_ZJIT
+ else if (addr == e->zjit_encoded_insn) {
+ opcode = e->zjit_insn;
}
+#endif
return opcode;
}
rb_bug("rb_vm_insn_addr2opcode: invalid insn address: %p", addr);
}
-// Decode `ISEQ_BODY(iseq)->iseq_encoded[i]` to an insn.
+// Decode `ISEQ_BODY(iseq)->iseq_encoded[i]` to an insn. This returns
+// bare instructions even if they're trace/zjit instructions. Use
+// rb_vm_insn_addr2opcode to decode trace/zjit instructions as is.
int
rb_vm_insn_decode(const VALUE encoded)
{
@@ -3356,15 +3996,16 @@ rb_vm_insn_decode(const VALUE encoded)
return insn;
}
+// Turn on or off tracing for a given instruction address
static inline int
-encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon, bool remain_current_trace)
+encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon, bool remain_traced)
{
st_data_t key = (st_data_t)*iseq_encoded_insn;
st_data_t val;
if (st_lookup(encoded_insn_data, key, &val)) {
insn_data_t *e = (insn_data_t *)val;
- if (remain_current_trace && key == (st_data_t)e->trace_encoded_insn) {
+ if (remain_traced && key == (st_data_t)e->trace_encoded_insn) {
turnon = 1;
}
*iseq_encoded_insn = (VALUE) (turnon ? e->trace_encoded_insn : e->notrace_encoded_insn);
@@ -3374,7 +4015,8 @@ encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon,
rb_bug("trace_instrument: invalid insn address: %p", (void *)*iseq_encoded_insn);
}
-void
+// Turn off tracing for an instruction at pos after tracing event flags are cleared
+static void
rb_iseq_trace_flag_cleared(const rb_iseq_t *iseq, size_t pos)
{
const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
@@ -3400,14 +4042,16 @@ add_bmethod_events(rb_event_flag_t events)
// Note, to support call/return events for bmethods, turnon_event can have more events than tpval.
static int
-iseq_add_local_tracepoint(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line)
+iseq_add_local_tracepoint(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line, rb_ractor_t *r)
{
unsigned int pc;
int n = 0;
const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
+ rb_iseq_t *iseq_mut = (rb_iseq_t*)iseq;
VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));
+ ASSERT_vm_locking_with_barrier();
for (pc=0; pc<body->iseq_size;) {
const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pc);
@@ -3429,11 +4073,9 @@ iseq_add_local_tracepoint(const rb_iseq_t *iseq, rb_event_flag_t turnon_events,
}
if (n > 0) {
- if (iseq->aux.exec.local_hooks == NULL) {
- ((rb_iseq_t *)iseq)->aux.exec.local_hooks = RB_ZALLOC(rb_hook_list_t);
- iseq->aux.exec.local_hooks->is_local = true;
- }
- rb_hook_list_connect_tracepoint((VALUE)iseq, iseq->aux.exec.local_hooks, tpval, target_line);
+ rb_hook_list_t *hook_list = rb_iseq_local_hooks(iseq, r, true);
+ rb_hook_list_connect_local_tracepoint(hook_list, tpval, target_line);
+ iseq_mut->aux.exec.local_hooks_cnt++;
}
return n;
@@ -3444,19 +4086,21 @@ struct trace_set_local_events_struct {
VALUE tpval;
unsigned int target_line;
int n;
+ rb_ractor_t *r;
};
static void
iseq_add_local_tracepoint_i(const rb_iseq_t *iseq, void *p)
{
struct trace_set_local_events_struct *data = (struct trace_set_local_events_struct *)p;
- data->n += iseq_add_local_tracepoint(iseq, data->turnon_events, data->tpval, data->target_line);
+ data->n += iseq_add_local_tracepoint(iseq, data->turnon_events, data->tpval, data->target_line, data->r);
iseq_iterate_children(iseq, iseq_add_local_tracepoint_i, p);
}
int
rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line, bool target_bmethod)
{
+ ASSERT_vm_locking_with_barrier();
struct trace_set_local_events_struct data;
if (target_bmethod) {
turnon_events = add_bmethod_events(turnon_events);
@@ -3465,35 +4109,52 @@ rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t
data.tpval = tpval;
data.target_line = target_line;
data.n = 0;
+ data.r = GET_RACTOR();
iseq_add_local_tracepoint_i(iseq, (void *)&data);
- if (0) rb_funcall(Qnil, rb_intern("puts"), 1, rb_iseq_disasm(iseq)); /* for debug */
+ if (0) fprintf(stderr, "Iseq disasm:\n:%s", RSTRING_PTR(rb_iseq_disasm(iseq))); /* for debug */
return data.n;
}
static int
-iseq_remove_local_tracepoint(const rb_iseq_t *iseq, VALUE tpval)
+iseq_remove_local_tracepoint(const rb_iseq_t *iseq, VALUE tpval, rb_ractor_t *r)
{
int n = 0;
+ unsigned int num_hooks_left;
+ unsigned int pc;
+ const struct rb_iseq_constant_body *body;
+ rb_iseq_t *iseq_mut = (rb_iseq_t*)iseq;
+ rb_hook_list_t *hook_list;
+ VALUE *iseq_encoded;
+ ASSERT_vm_locking_with_barrier();
- if (iseq->aux.exec.local_hooks) {
- unsigned int pc;
- const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
+ hook_list = rb_iseq_local_hooks(iseq, r, false);
+
+ if (hook_list) {
rb_event_flag_t local_events = 0;
- rb_hook_list_remove_tracepoint(iseq->aux.exec.local_hooks, tpval);
- local_events = iseq->aux.exec.local_hooks->events;
+ rb_event_flag_t prev_events = hook_list->events;
+ if (rb_hook_list_remove_local_tracepoint(hook_list, tpval)) {
+ RUBY_ASSERT(iseq->aux.exec.local_hooks_cnt > 0);
+ iseq_mut->aux.exec.local_hooks_cnt--;
+ local_events = hook_list->events; // remaining events for this ractor
+ num_hooks_left = rb_hook_list_count(hook_list);
+ if (local_events == 0 && prev_events != 0) {
+ st_delete(rb_ractor_targeted_hooks(r), (st_data_t*)&iseq, NULL);
+ rb_hook_list_free(hook_list);
+ }
- if (local_events == 0) {
- rb_hook_list_free(iseq->aux.exec.local_hooks);
- ((rb_iseq_t *)iseq)->aux.exec.local_hooks = NULL;
- }
+ if (iseq->aux.exec.local_hooks_cnt == num_hooks_left) {
+ body = ISEQ_BODY(iseq);
+ iseq_encoded = (VALUE *)body->iseq_encoded;
+ local_events = add_bmethod_events(local_events);
+ for (pc = 0; pc<body->iseq_size;) {
+ rb_event_flag_t pc_events = rb_iseq_event_flags(iseq, pc);
+ pc += encoded_iseq_trace_instrument(&iseq_encoded[pc], pc_events & (local_events | iseq->aux.exec.global_trace_events), false);
+ }
+ }
- local_events = add_bmethod_events(local_events);
- for (pc = 0; pc<body->iseq_size;) {
- rb_event_flag_t pc_events = rb_iseq_event_flags(iseq, pc);
- pc += encoded_iseq_trace_instrument(&iseq_encoded[pc], pc_events & (local_events | iseq->aux.exec.global_trace_events), false);
+ n++;
}
}
return n;
@@ -3502,22 +4163,25 @@ iseq_remove_local_tracepoint(const rb_iseq_t *iseq, VALUE tpval)
struct trace_clear_local_events_struct {
VALUE tpval;
int n;
+ rb_ractor_t *r;
};
static void
iseq_remove_local_tracepoint_i(const rb_iseq_t *iseq, void *p)
{
struct trace_clear_local_events_struct *data = (struct trace_clear_local_events_struct *)p;
- data->n += iseq_remove_local_tracepoint(iseq, data->tpval);
+ data->n += iseq_remove_local_tracepoint(iseq, data->tpval, data->r);
iseq_iterate_children(iseq, iseq_remove_local_tracepoint_i, p);
}
int
-rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval)
+rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval, rb_ractor_t *r)
{
struct trace_clear_local_events_struct data;
+ ASSERT_vm_locking_with_barrier();
data.tpval = tpval;
data.n = 0;
+ data.r = r;
iseq_remove_local_tracepoint_i(iseq, (void *)&data);
return data.n;
@@ -3535,11 +4199,14 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
return;
}
else {
+ // NOTE: this does not need VM barrier if it's a new ISEQ
unsigned int pc;
const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
+
VALUE *iseq_encoded = (VALUE *)body->iseq_encoded;
rb_event_flag_t enabled_events;
- rb_event_flag_t local_events = iseq->aux.exec.local_hooks ? iseq->aux.exec.local_hooks->events : 0;
+ rb_hook_list_t *local_hooks = rb_iseq_local_hooks(iseq, GET_RACTOR(), false);
+ rb_event_flag_t local_events = local_hooks ? local_hooks->events : 0;
((rb_iseq_t *)iseq)->aux.exec.global_trace_events = turnon_events;
enabled_events = add_bmethod_events(turnon_events | local_events);
@@ -3550,30 +4217,74 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
}
}
-bool rb_vm_call_ivar_attrset_p(const vm_call_handler ch);
void rb_vm_cc_general(const struct rb_callcache *cc);
+static bool
+clear_attr_cc(VALUE v)
+{
+ ASSERT_vm_locking_with_barrier();
+ if (imemo_type_p(v, imemo_callcache) && vm_cc_ivar_p((const struct rb_callcache *)v)) {
+ rb_vm_cc_general((struct rb_callcache *)v);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+static bool
+clear_bf_cc(VALUE v)
+{
+ ASSERT_vm_locking_with_barrier();
+ if (imemo_type_p(v, imemo_callcache) && vm_cc_bf_p((const struct rb_callcache *)v)) {
+ rb_vm_cc_general((struct rb_callcache *)v);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
static int
clear_attr_ccs_i(void *vstart, void *vend, size_t stride, void *data)
{
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
+ clear_attr_cc(v);
+ asan_poison_object_if(ptr, v);
+ }
+ return 0;
+}
- if (imemo_type_p(v, imemo_callcache) && rb_vm_call_ivar_attrset_p(((const struct rb_callcache *)v)->call_)) {
- rb_vm_cc_general((struct rb_callcache *)v);
- }
+void
+rb_clear_attr_ccs(void)
+{
+ RB_VM_LOCKING() {
+ rb_vm_barrier();
+ rb_objspace_each_objects(clear_attr_ccs_i, NULL);
+ }
+}
+static int
+clear_bf_ccs_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
+ clear_bf_cc(v);
asan_poison_object_if(ptr, v);
}
return 0;
}
void
-rb_clear_attr_ccs(void)
+rb_clear_bf_ccs(void)
{
- rb_objspace_each_objects(clear_attr_ccs_i, NULL);
+ ASSERT_vm_locking_with_barrier();
+ rb_objspace_each_objects(clear_bf_ccs_i, NULL);
}
static int
@@ -3583,14 +4294,15 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
- void *ptr = asan_poisoned_object_p(v);
- asan_unpoison_object(v, false);
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
if (rb_obj_is_iseq(v)) {
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
}
- else if (imemo_type_p(v, imemo_callcache) && rb_vm_call_ivar_attrset_p(((const struct rb_callcache *)v)->call_)) {
- rb_vm_cc_general((struct rb_callcache *)v);
+ else if (clear_attr_cc(v)) {
+ }
+ else if (clear_bf_cc(v)) {
}
asan_poison_object_if(ptr, v);
@@ -3601,7 +4313,10 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
void
rb_iseq_trace_set_all(rb_event_flag_t turnon_events)
{
- rb_objspace_each_objects(trace_set_i, &turnon_events);
+ RB_VM_LOCKING() {
+ rb_vm_barrier();
+ rb_objspace_each_objects(trace_set_i, &turnon_events);
+ }
}
VALUE
@@ -3878,6 +4593,9 @@ Init_ISeq(void)
(void)iseq_s_load;
rb_define_singleton_method(rb_cISeq, "compile", iseqw_s_compile, -1);
+ rb_define_singleton_method(rb_cISeq, "compile_parsey", iseqw_s_compile_parsey, -1);
+ rb_define_singleton_method(rb_cISeq, "compile_prism", iseqw_s_compile_prism, -1);
+ rb_define_singleton_method(rb_cISeq, "compile_file_prism", iseqw_s_compile_file_prism, -1);
rb_define_singleton_method(rb_cISeq, "new", iseqw_s_compile, -1);
rb_define_singleton_method(rb_cISeq, "compile_file", iseqw_s_compile_file, -1);
rb_define_singleton_method(rb_cISeq, "compile_option", iseqw_s_compile_option_get, 0);
diff --git a/iseq.h b/iseq.h
index fafa5a518e..b9bc03c23c 100644
--- a/iseq.h
+++ b/iseq.h
@@ -11,7 +11,9 @@
**********************************************************************/
#include "internal/gc.h"
+#include "shape.h"
#include "vm_core.h"
+#include "prism_compile.h"
RUBY_EXTERN const int ruby_api_version[];
#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
@@ -45,6 +47,10 @@ extern const ID rb_iseq_shared_exc_local_tbl[];
#define ISEQ_FLIP_CNT(iseq) ISEQ_BODY(iseq)->variable.flip_count
+#define ISEQ_FROZEN_STRING_LITERAL_ENABLED 1
+#define ISEQ_FROZEN_STRING_LITERAL_DISABLED 0
+#define ISEQ_FROZEN_STRING_LITERAL_UNSET -1
+
static inline rb_snum_t
ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
{
@@ -62,10 +68,10 @@ ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
static inline void
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
{
- void *ptr = ISEQ_BODY(iseq)->variable.original_iseq;
- ISEQ_BODY(iseq)->variable.original_iseq = NULL;
+ VALUE *ptr = (VALUE *)ISEQ_BODY(iseq)->variable.original_iseq;
if (ptr) {
- ruby_xfree(ptr);
+ ISEQ_BODY(iseq)->variable.original_iseq = NULL;
+ SIZED_FREE_N(ptr, ISEQ_BODY(iseq)->iseq_size);
}
}
@@ -82,9 +88,10 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
RUBY_EVENT_CALL | \
RUBY_EVENT_RETURN| \
RUBY_EVENT_C_CALL| \
- RUBY_EVENT_C_RETURN| \
- RUBY_EVENT_B_CALL| \
- RUBY_EVENT_B_RETURN| \
+ RUBY_EVENT_C_RETURN | \
+ RUBY_EVENT_B_CALL | \
+ RUBY_EVENT_B_RETURN | \
+ RUBY_EVENT_RESCUE | \
RUBY_EVENT_COVERAGE_LINE| \
RUBY_EVENT_COVERAGE_BRANCH)
@@ -99,6 +106,16 @@ struct iseq_compile_data {
const VALUE err_info;
const VALUE catch_table_ary; /* Array */
+ /* Mirror fields from ISEQ_BODY so they are accessible during iseq setup */
+ unsigned int iseq_size;
+ VALUE *iseq_encoded; /* half-encoded iseq (insn addr and operands) */
+ bool is_single_mark_bit; /* identifies whether mark bits are single or a list */
+
+ union {
+ iseq_bits_t * list; /* Find references for GC */
+ iseq_bits_t single;
+ } mark_bits;
+
/* GC is not needed */
struct iseq_label_data *start_label;
struct iseq_label_data *end_label;
@@ -125,6 +142,7 @@ struct iseq_compile_data {
struct rb_id_table *ivar_cache_table;
const struct rb_builtin_function *builtin_function_table;
const NODE *root_node;
+ bool catch_except_p; // If a frame of this ISeq may catch exception, set true.
#if OPT_SUPPORT_JOKE
st_table *labels_table;
#endif
@@ -158,7 +176,12 @@ ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq)
static inline rb_iseq_t *
iseq_imemo_alloc(void)
{
- return (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
+ rb_iseq_t *iseq = SHAREABLE_IMEMO_NEW(rb_iseq_t, imemo_iseq, 0);
+
+ // Clear out the whole iseq except for the flags.
+ memset((char *)iseq + sizeof(VALUE), 0, sizeof(rb_iseq_t) - sizeof(VALUE));
+
+ return iseq;
}
VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
@@ -168,8 +191,12 @@ const rb_iseq_t *rb_iseq_ibf_load_bytes(const char *cstr, size_t);
VALUE rb_iseq_ibf_load_extra_data(VALUE str);
void rb_iseq_init_trace(rb_iseq_t *iseq);
int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line, bool target_bmethod);
-int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
+int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval, rb_ractor_t *r);
const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
+const rb_iseq_t *rb_iseq_compile_iseq(VALUE str, VALUE fname);
+int rb_iseq_opt_frozen_string_literal(void);
+rb_hook_list_t *rb_iseq_local_hooks(const rb_iseq_t *iseq, rb_ractor_t *r, bool create);
+
#if VM_INSN_INFO_TABLE_IMPL == 2
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
@@ -224,8 +251,7 @@ struct rb_compile_option_struct {
unsigned int specialized_instruction: 1;
unsigned int operands_unification: 1;
unsigned int instructions_unification: 1;
- unsigned int stack_caching: 1;
- unsigned int frozen_string_literal: 1;
+ signed int frozen_string_literal: 2; /* -1: not specified, 0: false, 1: true */
unsigned int debug_frozen_string_literal: 1;
unsigned int coverage_enabled: 1;
int debug_level;
@@ -325,6 +351,10 @@ VALUE rb_iseq_defined_string(enum defined_type type);
/* vm.c */
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
+attr_index_t rb_estimate_iv_count(VALUE klass, const rb_iseq_t * initialize_iseq);
+
+void rb_free_encoded_insn_data(void);
+
RUBY_SYMBOL_EXPORT_END
#endif /* RUBY_ISEQ_H */
diff --git a/jit.c b/jit.c
new file mode 100644
index 0000000000..9bd16eab84
--- /dev/null
+++ b/jit.c
@@ -0,0 +1,844 @@
+// Glue code shared between YJIT and ZJIT for use from Rust.
+// For FFI safety and bindgen compatibility reasons, certain types of C
+// functions require wrapping before they can be called from Rust. Those show
+// up here.
+//
+// Code specific to YJIT and ZJIT should go to yjit.c and zjit.c respectively.
+
+#include "internal.h"
+#include "vm_core.h"
+#include "vm_callinfo.h"
+#include "builtin.h"
+#include "insns.inc"
+#include "insns_info.inc"
+#include "iseq.h"
+#include "internal/compile.h"
+#include "internal/gc.h"
+#include "vm_sync.h"
+#include "internal/fixnum.h"
+#include "internal/string.h"
+#include "internal/class.h"
+#include "internal/imemo.h"
+#include "ruby/internal/core/rtypeddata.h"
+#include "zjit.h"
+
+#ifndef _WIN32
+#include <sys/mman.h>
+#endif
+
+enum jit_bindgen_constants {
+ // Field offsets for the RObject struct
+ ROBJECT_OFFSET_AS_HEAP_FIELDS = offsetof(struct RObject, as.heap.fields),
+ ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary),
+
+ // Field offset for prime classext's fields_obj from a class pointer
+ RCLASS_OFFSET_PRIME_FIELDS_OBJ = offsetof(struct RClass_and_rb_classext_t, classext.fields_obj),
+
+ // Field offset for fields_obj in T_DATA
+ TDATA_OFFSET_FIELDS_OBJ = offsetof(struct RTypedData, fields_obj),
+
+ // Field offsets for the RString struct
+ RUBY_OFFSET_RSTRING_LEN = offsetof(struct RString, len),
+
+ // Shape constant related to RBasic::flags. (See RBASIC_SET_SHAPE_ID())
+ RB_SHAPE_FLAG_SHIFT = SHAPE_FLAG_SHIFT,
+
+ // Field offsets for rb_execution_context_t
+ RUBY_OFFSET_EC_CFP = offsetof(rb_execution_context_t, cfp),
+ RUBY_OFFSET_EC_INTERRUPT_FLAG = offsetof(rb_execution_context_t, interrupt_flag),
+ RUBY_OFFSET_EC_INTERRUPT_MASK = offsetof(rb_execution_context_t, interrupt_mask),
+ RUBY_OFFSET_EC_THREAD_PTR = offsetof(rb_execution_context_t, thread_ptr),
+ RUBY_OFFSET_EC_RACTOR_ID = offsetof(rb_execution_context_t, ractor_id),
+};
+
+// Manually bound in rust since this is out-of-range of `int`,
+// so this can't be in a `enum`, and we avoid `static const`
+// to avoid allocating storage for the constant.
+const shape_id_t rb_invalid_shape_id = INVALID_SHAPE_ID;
+
+unsigned int
+rb_iseq_encoded_size(const rb_iseq_t *iseq)
+{
+ return iseq->body->iseq_size;
+}
+
+// Get the PC for a given index in an iseq
+VALUE *
+rb_iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx)
+{
+ RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
+ RUBY_ASSERT_ALWAYS(insn_idx < iseq->body->iseq_size);
+ VALUE *encoded = iseq->body->iseq_encoded;
+ VALUE *pc = &encoded[insn_idx];
+ return pc;
+}
+
+// Get the opcode given a program counter. Can return trace opcode variants.
+int
+rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
+{
+ // YJIT should only use iseqs after AST to bytecode compilation.
+ // (Certain non-default interpreter configurations never set ISEQ_TRANSLATED)
+ if (OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE) {
+ RUBY_ASSERT_ALWAYS(FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED));
+ }
+
+ const VALUE at_pc = *pc;
+ return rb_vm_insn_addr2opcode((const void *)at_pc);
+}
+
+// Get the bare opcode given a program counter. Always returns the base
+// instruction, stripping trace/zjit variants.
+int
+rb_iseq_bare_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
+{
+ if (OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE) {
+ RUBY_ASSERT_ALWAYS(FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED));
+ }
+
+ const VALUE at_pc = *pc;
+ return rb_vm_insn_addr2insn((const void *)at_pc);
+}
+
+unsigned long
+rb_RSTRING_LEN(VALUE str)
+{
+ return RSTRING_LEN(str);
+}
+
+char *
+rb_RSTRING_PTR(VALUE str)
+{
+ return RSTRING_PTR(str);
+}
+
+const char *
+rb_insn_name(VALUE insn)
+{
+ return insn_name(insn);
+}
+
+unsigned int
+rb_vm_ci_argc(const struct rb_callinfo *ci)
+{
+ return vm_ci_argc(ci);
+}
+
+ID
+rb_vm_ci_mid(const struct rb_callinfo *ci)
+{
+ return vm_ci_mid(ci);
+}
+
+unsigned int
+rb_vm_ci_flag(const struct rb_callinfo *ci)
+{
+ return vm_ci_flag(ci);
+}
+
+const struct rb_callinfo_kwarg *
+rb_vm_ci_kwarg(const struct rb_callinfo *ci)
+{
+ return vm_ci_kwarg(ci);
+}
+
+int
+rb_get_cikw_keyword_len(const struct rb_callinfo_kwarg *cikw)
+{
+ return cikw->keyword_len;
+}
+
+VALUE
+rb_get_cikw_keywords_idx(const struct rb_callinfo_kwarg *cikw, int idx)
+{
+ return cikw->keywords[idx];
+}
+
+rb_method_visibility_t
+rb_METHOD_ENTRY_VISI(const rb_callable_method_entry_t *me)
+{
+ return METHOD_ENTRY_VISI(me);
+}
+
+rb_method_type_t
+rb_get_cme_def_type(const rb_callable_method_entry_t *cme)
+{
+ if (UNDEFINED_METHOD_ENTRY_P(cme)) {
+ return VM_METHOD_TYPE_UNDEF;
+ }
+ else {
+ return cme->def->type;
+ }
+}
+
+ID
+rb_get_cme_def_body_attr_id(const rb_callable_method_entry_t *cme)
+{
+ return cme->def->body.attr.id;
+}
+
+enum method_optimized_type
+rb_get_cme_def_body_optimized_type(const rb_callable_method_entry_t *cme)
+{
+ return cme->def->body.optimized.type;
+}
+
+unsigned int
+rb_get_cme_def_body_optimized_index(const rb_callable_method_entry_t *cme)
+{
+ return cme->def->body.optimized.index;
+}
+
+rb_method_cfunc_t *
+rb_get_cme_def_body_cfunc(const rb_callable_method_entry_t *cme)
+{
+ return UNALIGNED_MEMBER_PTR(cme->def, body.cfunc);
+}
+
+uintptr_t
+rb_get_def_method_serial(const rb_method_definition_t *def)
+{
+ return def->method_serial;
+}
+
+ID
+rb_get_def_original_id(const rb_method_definition_t *def)
+{
+ return def->original_id;
+}
+
+VALUE
+rb_get_def_bmethod_proc(rb_method_definition_t *def)
+{
+ RUBY_ASSERT(def->type == VM_METHOD_TYPE_BMETHOD);
+ return def->body.bmethod.proc;
+}
+
+rb_proc_t *
+rb_jit_get_proc_ptr(VALUE procv)
+{
+ rb_proc_t *proc;
+ GetProcPtr(procv, proc);
+ return proc;
+}
+
+VALUE
+rb_optimized_call(VALUE recv, rb_execution_context_t *ec, int argc, VALUE *argv, int kw_splat, VALUE block_handler)
+{
+ rb_proc_t *proc;
+ GetProcPtr(recv, proc);
+ return rb_vm_invoke_proc(ec, proc, argc, argv, kw_splat, block_handler);
+}
+
+unsigned int
+rb_jit_iseq_builtin_attrs(const rb_iseq_t *iseq)
+{
+ return iseq->body->builtin_attrs;
+}
+
+int
+rb_get_mct_argc(const rb_method_cfunc_t *mct)
+{
+ return mct->argc;
+}
+
+void *
+rb_get_mct_func(const rb_method_cfunc_t *mct)
+{
+ return (void*)(uintptr_t)mct->func; // this field is defined as type VALUE (*func)(ANYARGS)
+}
+
+const rb_iseq_t *
+rb_get_def_iseq_ptr(rb_method_definition_t *def)
+{
+ return def_iseq_ptr(def);
+}
+
+const rb_iseq_t *
+rb_get_iseq_body_local_iseq(const rb_iseq_t *iseq)
+{
+ return iseq->body->local_iseq;
+}
+
+const rb_iseq_t *
+rb_get_iseq_body_parent_iseq(const rb_iseq_t *iseq)
+{
+ return iseq->body->parent_iseq;
+}
+
+unsigned int
+rb_get_iseq_body_local_table_size(const rb_iseq_t *iseq)
+{
+ return iseq->body->local_table_size;
+}
+
+VALUE *
+rb_get_iseq_body_iseq_encoded(const rb_iseq_t *iseq)
+{
+ return iseq->body->iseq_encoded;
+}
+
+unsigned
+rb_get_iseq_body_stack_max(const rb_iseq_t *iseq)
+{
+ return iseq->body->stack_max;
+}
+
+enum rb_iseq_type
+rb_get_iseq_body_type(const rb_iseq_t *iseq)
+{
+ return iseq->body->type;
+}
+
+bool
+rb_get_iseq_flags_has_lead(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_lead;
+}
+
+bool
+rb_get_iseq_flags_has_opt(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_opt;
+}
+
+bool
+rb_get_iseq_flags_has_kw(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_kw;
+}
+
+bool
+rb_get_iseq_flags_has_post(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_post;
+}
+
+bool
+rb_get_iseq_flags_has_kwrest(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_kwrest;
+}
+
+bool
+rb_get_iseq_flags_anon_kwrest(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.anon_kwrest;
+}
+
+bool
+rb_get_iseq_flags_has_rest(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_rest;
+}
+
+bool
+rb_get_iseq_flags_ruby2_keywords(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.ruby2_keywords;
+}
+
+bool
+rb_get_iseq_flags_has_block(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.has_block;
+}
+
+bool
+rb_get_iseq_flags_ambiguous_param0(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.ambiguous_param0;
+}
+
+bool
+rb_get_iseq_flags_accepts_no_kwarg(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.accepts_no_kwarg;
+}
+
+bool
+rb_get_iseq_flags_forwardable(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.flags.forwardable;
+}
+
+// This is defined only as a named struct inside rb_iseq_constant_body.
+// By giving it a separate typedef, we make it nameable by rust-bindgen.
+// Bindgen's temp/anon name isn't guaranteed stable.
+typedef struct rb_iseq_param_keyword rb_iseq_param_keyword_struct;
+
+const rb_iseq_param_keyword_struct *
+rb_get_iseq_body_param_keyword(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.keyword;
+}
+
+unsigned
+rb_get_iseq_body_param_size(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.size;
+}
+
+int
+rb_get_iseq_body_param_lead_num(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.lead_num;
+}
+
+int
+rb_get_iseq_body_param_opt_num(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.opt_num;
+}
+
+const VALUE *
+rb_get_iseq_body_param_opt_table(const rb_iseq_t *iseq)
+{
+ return iseq->body->param.opt_table;
+}
+
+struct rb_control_frame_struct *
+rb_get_ec_cfp(const rb_execution_context_t *ec)
+{
+ return ec->cfp;
+}
+
+const rb_iseq_t *
+rb_get_cfp_iseq(struct rb_control_frame_struct *cfp)
+{
+ return CFP_ISEQ(cfp);
+}
+
+VALUE *
+rb_get_cfp_pc(struct rb_control_frame_struct *cfp)
+{
+ return (VALUE*)cfp->pc;
+}
+
+VALUE *
+rb_get_cfp_sp(struct rb_control_frame_struct *cfp)
+{
+ return cfp->sp;
+}
+
+VALUE
+rb_get_cfp_self(struct rb_control_frame_struct *cfp)
+{
+ return cfp->self;
+}
+
+VALUE *
+rb_get_cfp_ep(struct rb_control_frame_struct *cfp)
+{
+ return (VALUE*)cfp->ep;
+}
+
+const VALUE *
+rb_get_cfp_ep_level(struct rb_control_frame_struct *cfp, uint32_t lv)
+{
+ uint32_t i;
+ const VALUE *ep = (VALUE*)cfp->ep;
+ for (i = 0; i < lv; i++) {
+ ep = VM_ENV_PREV_EP(ep);
+ }
+ return ep;
+}
+
+VALUE
+rb_yarv_class_of(VALUE obj)
+{
+ return rb_class_of(obj);
+}
+
+// The FL_TEST() macro
+VALUE
+rb_FL_TEST(VALUE obj, VALUE flags)
+{
+ return RB_FL_TEST(obj, flags);
+}
+
+// The FL_TEST_RAW() macro, normally an internal implementation detail
+VALUE
+rb_FL_TEST_RAW(VALUE obj, VALUE flags)
+{
+ return FL_TEST_RAW(obj, flags);
+}
+
+// The RB_TYPE_P macro
+bool
+rb_RB_TYPE_P(VALUE obj, enum ruby_value_type t)
+{
+ return RB_TYPE_P(obj, t);
+}
+
+long
+rb_RSTRUCT_LEN(VALUE st)
+{
+ return RSTRUCT_LEN(st);
+}
+
+const struct rb_callinfo *
+rb_get_call_data_ci(const struct rb_call_data *cd)
+{
+ return cd->ci;
+}
+
+bool
+rb_BASIC_OP_UNREDEFINED_P(enum ruby_basic_operators bop, uint32_t klass)
+{
+ return BASIC_OP_UNREDEFINED_P(bop, klass);
+}
+
+VALUE
+rb_RCLASS_ORIGIN(VALUE c)
+{
+ return RCLASS_ORIGIN(c);
+}
+
+// For debug builds
+void
+rb_assert_iseq_handle(VALUE handle)
+{
+ RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_iseq));
+}
+
+// Assert that we have the VM lock. Relevant mostly for multi ractor situations.
+// The GC takes the lock before calling us, and this asserts that it indeed happens.
+void
+rb_assert_holding_vm_lock(void)
+{
+ ASSERT_vm_locking();
+}
+
+int
+rb_IMEMO_TYPE_P(VALUE imemo, enum imemo_type imemo_type)
+{
+ return IMEMO_TYPE_P(imemo, imemo_type);
+}
+
+void
+rb_assert_cme_handle(VALUE handle)
+{
+ RUBY_ASSERT_ALWAYS(!rb_objspace_garbage_object_p(handle));
+ RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_ment));
+}
+
+// YJIT and ZJIT need this function to never allocate and never raise
+VALUE
+rb_yarv_ary_entry_internal(VALUE ary, long offset)
+{
+ return rb_ary_entry_internal(ary, offset);
+}
+
+long
+rb_jit_array_len(VALUE a)
+{
+ return rb_array_len(a);
+}
+
+void
+rb_set_cfp_pc(struct rb_control_frame_struct *cfp, const VALUE *pc)
+{
+ cfp->pc = pc;
+}
+
+void
+rb_set_cfp_sp(struct rb_control_frame_struct *cfp, VALUE *sp)
+{
+ cfp->sp = sp;
+}
+
+bool
+rb_jit_shape_complex_p(shape_id_t shape_id)
+{
+ return rb_shape_complex_p(shape_id);
+}
+
+bool
+rb_jit_multi_ractor_p(void)
+{
+ return rb_multi_ractor_p();
+}
+
+bool
+rb_jit_class_fields_embedded_p(VALUE klass)
+{
+ VALUE fields_obj = RCLASS_EXT_PRIME(klass)->fields_obj;
+ return !fields_obj || !FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP);
+}
+
+bool
+rb_jit_data_fields_embedded_p(VALUE obj)
+{
+ VALUE fields_obj = RTYPEDDATA(obj)->fields_obj;
+ return !fields_obj || !FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP);
+}
+
+// Acquire the VM lock and then signal all other Ruby threads (ractors) to
+// contend for the VM lock, putting them to sleep. ZJIT and YJIT use this to
+// evict threads running inside generated code so among other things, it can
+// safely change memory protection of regions housing generated code.
+void
+rb_jit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file, int line)
+{
+ rb_vm_lock_enter(recursive_lock_level, file, line);
+ rb_vm_barrier();
+}
+
+// Release the VM lock. The lock level must point to the same integer used to
+// acquire the lock.
+void
+rb_jit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line)
+{
+ rb_vm_lock_leave(recursive_lock_level, file, line);
+}
+
+void
+rb_iseq_reset_jit_func(const rb_iseq_t *iseq)
+{
+ RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
+ iseq->body->jit_entry = NULL;
+ iseq->body->jit_exception = NULL;
+ // Enable re-compiling this ISEQ. Event when it's invalidated for TracePoint,
+ // we'd like to re-compile ISEQs that haven't been converted to trace_* insns.
+ iseq->body->jit_entry_calls = 0;
+ iseq->body->jit_exception_calls = 0;
+}
+
+// Callback data for rb_jit_for_each_iseq
+struct iseq_callback_data {
+ rb_iseq_callback callback;
+ void *data;
+};
+
+// Heap-walking callback for rb_jit_for_each_iseq
+static int
+for_each_iseq_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ const struct iseq_callback_data *callback_data = (struct iseq_callback_data *)data;
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ void *ptr = rb_asan_poisoned_object_p(v);
+ rb_asan_unpoison_object(v, false);
+
+ if (rb_obj_is_iseq(v)) {
+ rb_iseq_t *iseq = (rb_iseq_t *)v;
+ callback_data->callback(iseq, callback_data->data);
+ }
+
+ if (ptr) {
+ rb_asan_poison_object(v);
+ }
+ }
+ return 0;
+}
+
+uint32_t
+rb_jit_get_page_size(void)
+{
+#if defined(_SC_PAGESIZE)
+ long page_size = sysconf(_SC_PAGESIZE);
+ if (page_size <= 0) rb_bug("jit: failed to get page size");
+
+ // 1 GiB limit. x86 CPUs with PDPE1GB can do this and anything larger is unexpected.
+ // Though our design sort of assume we have fine grained control over memory protection
+ // which require small page sizes.
+ if (page_size > 0x40000000l) rb_bug("jit page size too large");
+
+ return (uint32_t)page_size;
+#else
+#error "JIT supports POSIX only for now"
+#endif
+}
+
+#if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE)
+// Align the current write position to a multiple of bytes
+static uint8_t *
+align_ptr(uint8_t *ptr, uint32_t multiple)
+{
+ // Compute the pointer modulo the given alignment boundary
+ uint32_t rem = ((uint32_t)(uintptr_t)ptr) % multiple;
+
+ // If the pointer is already aligned, stop
+ if (rem == 0)
+ return ptr;
+
+ // Pad the pointer by the necessary amount to align it
+ uint32_t pad = multiple - rem;
+
+ return ptr + pad;
+}
+#endif
+
+// Address space reservation. Memory pages are mapped on an as needed basis.
+// See the Rust mm module for details.
+uint8_t *
+rb_jit_reserve_addr_space(uint32_t mem_size)
+{
+#ifndef _WIN32
+ uint8_t *mem_block;
+
+ // On Linux
+ #if defined(MAP_FIXED_NOREPLACE) && defined(_SC_PAGESIZE)
+ uint32_t const page_size = (uint32_t)sysconf(_SC_PAGESIZE);
+ uint8_t *const cfunc_sample_addr = (void *)(uintptr_t)&rb_jit_reserve_addr_space;
+ uint8_t *const probe_region_end = cfunc_sample_addr + INT32_MAX;
+ // Align the requested address to page size
+ uint8_t *req_addr = align_ptr(cfunc_sample_addr, page_size);
+
+ // Probe for addresses close to this function using MAP_FIXED_NOREPLACE
+ // to improve odds of being in range for 32-bit relative call instructions.
+ do {
+ mem_block = mmap(
+ req_addr,
+ mem_size,
+ PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE,
+ -1,
+ 0
+ );
+
+ // If we succeeded, stop
+ if (mem_block != MAP_FAILED) {
+ ruby_annotate_mmap(mem_block, mem_size, "Ruby:rb_jit_reserve_addr_space");
+ break;
+ }
+
+ // -4MiB. Downwards to probe away from the heap. (On x86/A64 Linux
+ // main_code_addr < heap_addr, and in case we are in a shared
+ // library mapped higher than the heap, downwards is still better
+ // since it's towards the end of the heap rather than the stack.)
+ req_addr -= 4 * 1024 * 1024;
+ } while (req_addr < probe_region_end);
+
+ // On MacOS and other platforms
+ #else
+ // Try to map a chunk of memory as executable
+ mem_block = mmap(
+ (void *)rb_jit_reserve_addr_space,
+ mem_size,
+ PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1,
+ 0
+ );
+ #endif
+
+ // Fallback
+ if (mem_block == MAP_FAILED) {
+ // Try again without the address hint (e.g., valgrind)
+ mem_block = mmap(
+ NULL,
+ mem_size,
+ PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1,
+ 0
+ );
+
+ if (mem_block != MAP_FAILED) {
+ ruby_annotate_mmap(mem_block, mem_size, "Ruby:rb_jit_reserve_addr_space:fallback");
+ }
+ }
+
+ // Check that the memory mapping was successful
+ if (mem_block == MAP_FAILED) {
+ perror("ruby: jit: mmap:");
+ if(errno == ENOMEM) {
+ // No crash report if it's only insufficient memory
+ exit(EXIT_FAILURE);
+ }
+ rb_bug("mmap failed");
+ }
+
+ return mem_block;
+#else
+ // Windows not supported for now
+ return NULL;
+#endif
+}
+
+// Walk all ISEQs in the heap and invoke the callback - shared between YJIT and ZJIT
+void
+rb_jit_for_each_iseq(rb_iseq_callback callback, void *data)
+{
+ struct iseq_callback_data callback_data = { .callback = callback, .data = data };
+ rb_objspace_each_objects(for_each_iseq_i, (void *)&callback_data);
+}
+
+bool
+rb_jit_mark_writable(void *mem_block, uint32_t mem_size)
+{
+ return mprotect(mem_block, mem_size, PROT_READ | PROT_WRITE) == 0;
+}
+
+void
+rb_jit_mark_executable(void *mem_block, uint32_t mem_size)
+{
+ // Do not call mprotect when mem_size is zero. Some platforms may return
+ // an error for it. https://github.com/Shopify/ruby/issues/450
+ if (mem_size == 0) {
+ return;
+ }
+ if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
+ rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s",
+ mem_block, (unsigned long)mem_size, strerror(errno));
+ }
+}
+
+// Free the specified memory block.
+bool
+rb_jit_mark_unused(void *mem_block, uint32_t mem_size)
+{
+ // On Linux, you need to use madvise MADV_DONTNEED to free memory.
+ // We might not need to call this on macOS, but it's not really documented.
+ // We generally prefer to do the same thing on both to ease testing too.
+ madvise(mem_block, mem_size, MADV_DONTNEED);
+
+ // On macOS, mprotect PROT_NONE seems to reduce RSS.
+ // We also call this on Linux to avoid executing unused pages.
+ return mprotect(mem_block, mem_size, PROT_NONE) == 0;
+}
+
+// Invalidate icache for arm64.
+// `start` is inclusive and `end` is exclusive.
+void
+rb_jit_icache_invalidate(void *start, void *end)
+{
+ // Clear/invalidate the instruction cache. Compiles to nothing on x86_64
+ // but required on ARM before running freshly written code.
+ // On Darwin it's the same as calling sys_icache_invalidate().
+#ifdef __GNUC__
+ __builtin___clear_cache(start, end);
+#elif defined(__aarch64__)
+#error No instruction cache clear available with this compiler on Aarch64!
+#endif
+}
+
+VALUE
+rb_jit_fix_mod_fix(VALUE recv, VALUE obj)
+{
+ return rb_fix_mod_fix(recv, obj);
+}
+
+VALUE
+rb_jit_fix_div_fix(VALUE recv, VALUE obj)
+{
+ return rb_fix_div_fix(recv, obj);
+}
+
+// YJIT/ZJIT need this function to never allocate and never raise
+VALUE
+rb_yarv_str_eql_internal(VALUE str1, VALUE str2)
+{
+ // We wrap this since it's static inline
+ return rb_str_eql_internal(str1, str2);
+}
+
+void rb_jit_str_concat_codepoint(VALUE str, VALUE codepoint);
+
+attr_index_t
+rb_jit_shape_capacity(shape_id_t shape_id)
+{
+ return RSHAPE_CAPACITY(shape_id);
+}
diff --git a/jit/Cargo.toml b/jit/Cargo.toml
new file mode 100644
index 0000000000..530fe3674b
--- /dev/null
+++ b/jit/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "jit"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/jit/src/lib.rs b/jit/src/lib.rs
new file mode 100644
index 0000000000..c0f043131e
--- /dev/null
+++ b/jit/src/lib.rs
@@ -0,0 +1,38 @@
+//! Shared code between YJIT and ZJIT.
+#![warn(unsafe_op_in_unsafe_fn)] // Adopt 2024 edition default when targeting 2021 editions
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+use std::alloc::{GlobalAlloc, Layout, System};
+
+#[global_allocator]
+pub static GLOBAL_ALLOCATOR: StatsAlloc = StatsAlloc { alloc_size: AtomicUsize::new(0) };
+
+pub struct StatsAlloc {
+ pub alloc_size: AtomicUsize,
+}
+
+unsafe impl GlobalAlloc for StatsAlloc {
+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+ self.alloc_size.fetch_add(layout.size(), Ordering::SeqCst);
+ unsafe { System.alloc(layout) }
+ }
+
+ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
+ self.alloc_size.fetch_sub(layout.size(), Ordering::SeqCst);
+ unsafe { System.dealloc(ptr, layout) }
+ }
+
+ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
+ self.alloc_size.fetch_add(layout.size(), Ordering::SeqCst);
+ unsafe { System.alloc_zeroed(layout) }
+ }
+
+ unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
+ if new_size > layout.size() {
+ self.alloc_size.fetch_add(new_size - layout.size(), Ordering::SeqCst);
+ } else if new_size < layout.size() {
+ self.alloc_size.fetch_sub(layout.size() - new_size, Ordering::SeqCst);
+ }
+ unsafe { System.realloc(ptr, layout, new_size) }
+ }
+}
diff --git a/jit_hook.rb b/jit_hook.rb
new file mode 100644
index 0000000000..c605d6e26d
--- /dev/null
+++ b/jit_hook.rb
@@ -0,0 +1,12 @@
+class Module
+ # Internal helper for built-in initializations to define methods only when JIT is enabled.
+ # This method is removed in jit_undef.rb.
+ private def with_jit(&block) # :nodoc:
+ if defined?(RubyVM::ZJIT)
+ RubyVM::ZJIT.send(:add_jit_hook, block)
+ end
+ if defined?(RubyVM::YJIT)
+ RubyVM::YJIT.send(:add_jit_hook, block)
+ end
+ end
+end
diff --git a/jit_undef.rb b/jit_undef.rb
new file mode 100644
index 0000000000..0e855fe7a2
--- /dev/null
+++ b/jit_undef.rb
@@ -0,0 +1,4 @@
+# Remove the helper defined in jit_hook.rb
+class Module
+ undef :with_jit
+end
diff --git a/kernel.rb b/kernel.rb
index c8cbc99175..dc5cea1515 100644
--- a/kernel.rb
+++ b/kernel.rb
@@ -17,7 +17,7 @@ module Kernel
#
def class
Primitive.attr! :leaf
- Primitive.cexpr! 'rb_obj_class(self)'
+ Primitive.cexpr! 'rb_obj_class_must(self)'
end
#
@@ -40,7 +40,7 @@ module Kernel
# s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
# s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
#
- # This method may have class-specific behavior. If so, that
+ # This method may have class-specific behavior. If so, that
# behavior will be documented under the #+initialize_copy+ method of
# the class.
#
@@ -58,10 +58,10 @@ module Kernel
# a.freeze #=> ["a", "b", "c"]
# a.frozen? #=> true
#--
- # Determines if the object is frozen. Equivalent to \c Object\#frozen? in Ruby.
- # \param[in] obj the object to be determines
- # \retval Qtrue if frozen
- # \retval Qfalse if not frozen
+ # Determines if the object is frozen. Equivalent to `Object#frozen?` in Ruby.
+ # @param[in] obj the object to be determines
+ # @retval Qtrue if frozen
+ # @retval Qfalse if not frozen
#++
#
def frozen?
@@ -73,7 +73,7 @@ module Kernel
# call-seq:
# obj.tap {|x| block } -> obj
#
- # Yields self to the block, and then returns self.
+ # Yields self to the block and then returns self.
# The primary purpose of this method is to "tap into" a method chain,
# in order to perform operations on intermediate results within the chain.
#
@@ -87,6 +87,7 @@ module Kernel
#++
#
def tap
+ Primitive.attr! :inline_block
yield(self)
self
end
@@ -99,54 +100,33 @@ module Kernel
#
# 3.next.then {|x| x**x }.to_s #=> "256"
#
- # Good usage for +then+ is value piping in method chains:
+ # A good use of +then+ is value piping in method chains:
#
# require 'open-uri'
# require 'json'
#
- # construct_url(arguments).
- # then {|url| URI(url).read }.
- # then {|response| JSON.parse(response) }
+ # construct_url(arguments)
+ # .then {|url| URI(url).read }
+ # .then {|response| JSON.parse(response) }
#
- # When called without block, the method returns +Enumerator+,
+ # When called without a block, the method returns an +Enumerator+,
# which can be used, for example, for conditional
# circuit-breaking:
#
- # # meets condition, no-op
+ # # Meets condition, no-op
# 1.then.detect(&:odd?) # => 1
- # # does not meet condition, drop value
+ # # Does not meet condition, drop value
# 2.then.detect(&:odd?) # => nil
#
def then
- unless block_given?
+ Primitive.attr! :inline_block
+ unless defined?(yield)
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
end
yield(self)
end
- #
- # call-seq:
- # obj.yield_self {|x| block } -> an_object
- #
- # Yields self to the block and returns the result of the block.
- #
- # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
- #
- # Good usage for +then+ is value piping in method chains:
- #
- # require 'open-uri'
- # require 'json'
- #
- # construct_url(arguments).
- # then {|url| URI(url).read }.
- # then {|response| JSON.parse(response) }
- #
- def yield_self
- unless block_given?
- return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
- end
- yield(self)
- end
+ alias yield_self then
module_function
@@ -161,11 +141,12 @@ module Kernel
# loop do
# print "Input: "
# line = gets
+ # # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
# break if !line or line =~ /^q/i
# # ...
# end
#
- # StopIteration raised in the block breaks the loop. In this case,
+ # A StopIteration raised in the block breaks the loop. In this case,
# loop returns the "result" value stored in the exception.
#
# enum = Enumerator.new { |y|
@@ -178,8 +159,9 @@ module Kernel
# puts enum.next
# } #=> :ok
def loop
- unless block_given?
- return enum_for(:loop) { Float::INFINITY }
+ Primitive.attr! :inline_block
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_f_loop_size)'
end
begin
@@ -197,10 +179,10 @@ module Kernel
#
# Returns <i>arg</i> converted to a float. Numeric types are
# converted directly, and with exception to String and
- # <code>nil</code> the rest are converted using
- # <i>arg</i><code>.to_f</code>. Converting a String with invalid
- # characters will result in a ArgumentError. Converting
- # <code>nil</code> generates a TypeError. Exceptions can be
+ # <code>nil</code>, the rest are converted using
+ # <i>arg</i><code>.to_f</code>. Converting a String with invalid
+ # characters will result in an ArgumentError. Converting
+ # <code>nil</code> generates a TypeError. Exceptions can be
# suppressed by passing <code>exception: false</code>.
#
# Float(1) #=> 1.0
@@ -216,4 +198,97 @@ module Kernel
Primitive.rb_f_float(arg, exception)
end
end
+
+ # call-seq:
+ # Integer(object, base = 0, exception: true) -> integer or nil
+ #
+ # Returns an integer converted from +object+.
+ #
+ # Tries to convert +object+ to an integer
+ # using +to_int+ first and +to_i+ second;
+ # see below for exceptions.
+ #
+ # With a non-zero +base+, +object+ must be a string or convertible
+ # to a string.
+ #
+ # ==== \Numeric objects
+ #
+ # With an integer argument +object+ given, returns +object+:
+ #
+ # Integer(1) # => 1
+ # Integer(-1) # => -1
+ #
+ # With a floating-point argument +object+ given,
+ # returns +object+ truncated to an integer:
+ #
+ # Integer(1.9) # => 1 # Rounds toward zero.
+ # Integer(-1.9) # => -1 # Rounds toward zero.
+ #
+ # ==== \String objects
+ #
+ # With a string argument +object+ and zero +base+ given,
+ # returns +object+ converted to an integer in base 10:
+ #
+ # Integer('100') # => 100
+ # Integer('-100') # => -100
+ #
+ # With +base+ zero, string +object+ may contain leading characters
+ # to specify the actual base (radix indicator):
+ #
+ # Integer('0100') # => 64 # Leading '0' specifies base 8.
+ # Integer('0b100') # => 4 # Leading '0b' specifies base 2.
+ # Integer('0x100') # => 256 # Leading '0x' specifies base 16.
+ #
+ # With a positive +base+ (in range 2..36) given, returns +object+
+ # converted to an integer in the given base:
+ #
+ # Integer('100', 2) # => 4
+ # Integer('100', 8) # => 64
+ # Integer('-100', 16) # => -256
+ #
+ # With a negative +base+ (in range -36..-2) given, returns +object+
+ # converted to the radix indicator if it exists or
+ # +base+:
+ #
+ # Integer('0x100', -2) # => 256
+ # Integer('100', -2) # => 4
+ # Integer('0b100', -8) # => 4
+ # Integer('100', -8) # => 64
+ # Integer('0o100', -10) # => 64
+ # Integer('100', -10) # => 100
+ #
+ # +base+ -1 is equivalent to the -10 case.
+ #
+ # When converting strings, surrounding whitespace and embedded underscores
+ # are allowed and ignored:
+ #
+ # Integer(' 100 ') # => 100
+ # Integer('-1_0_0', 16) # => -256
+ #
+ # ==== Other classes
+ #
+ # Examples with +object+ of various other classes:
+ #
+ # Integer(Rational(9, 10)) # => 0 # Rounds toward zero.
+ # Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero.
+ # Integer(Time.now) # => 1650974042
+ #
+ # ==== Keywords
+ #
+ # With the optional keyword argument +exception+ given as +true+ (the default):
+ #
+ # - Raises TypeError if +object+ does not respond to +to_int+ or +to_i+.
+ # - Raises TypeError if +object+ is +nil+.
+ # - Raises ArgumentError if +object+ is an invalid string.
+ #
+ # With +exception+ given as +false+, an exception of any kind is suppressed
+ # and +nil+ is returned.
+ #
+ def Integer(arg, base = 0, exception: true)
+ if Primitive.mandatory_only?
+ Primitive.rb_f_integer1(arg)
+ else
+ Primitive.rb_f_integer(arg, base, exception)
+ end
+ end
end
diff --git a/lex.c.blt b/lex.c.blt
index 85727ed00f..de0719b014 100644
--- a/lex.c.blt
+++ b/lex.c.blt
@@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */
+/* Command-line: gperf -C -L ANSI-C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,7 +28,6 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
-#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
#line 1 "defs/keywords"
struct kwtable {short name, id[2], state;};
@@ -196,88 +195,88 @@ rb_reserved_word (register const char *str, register size_t len)
{
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 19 "defs/keywords"
- {gperf_offsetof(stringpool, 8), {keyword_break, keyword_break}, EXPR_MID},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8, {keyword_break, keyword_break}, EXPR_MID},
#line 25 "defs/keywords"
- {gperf_offsetof(stringpool, 9), {keyword_else, keyword_else}, EXPR_BEG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, {keyword_else, keyword_else}, EXPR_BEG},
#line 35 "defs/keywords"
- {gperf_offsetof(stringpool, 10), {keyword_nil, keyword_nil}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, {keyword_nil, keyword_nil}, EXPR_END},
#line 28 "defs/keywords"
- {gperf_offsetof(stringpool, 11), {keyword_ensure, keyword_ensure}, EXPR_BEG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, {keyword_ensure, keyword_ensure}, EXPR_BEG},
#line 27 "defs/keywords"
- {gperf_offsetof(stringpool, 12), {keyword_end, keyword_end}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, {keyword_end, keyword_end}, EXPR_END},
#line 44 "defs/keywords"
- {gperf_offsetof(stringpool, 13), {keyword_then, keyword_then}, EXPR_BEG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, {keyword_then, keyword_then}, EXPR_BEG},
#line 36 "defs/keywords"
- {gperf_offsetof(stringpool, 14), {keyword_not, keyword_not}, EXPR_ARG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, {keyword_not, keyword_not}, EXPR_ARG},
#line 29 "defs/keywords"
- {gperf_offsetof(stringpool, 15), {keyword_false, keyword_false}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, {keyword_false, keyword_false}, EXPR_END},
#line 42 "defs/keywords"
- {gperf_offsetof(stringpool, 16), {keyword_self, keyword_self}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, {keyword_self, keyword_self}, EXPR_END},
#line 26 "defs/keywords"
- {gperf_offsetof(stringpool, 17), {keyword_elsif, keyword_elsif}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, {keyword_elsif, keyword_elsif}, EXPR_VALUE},
#line 39 "defs/keywords"
- {gperf_offsetof(stringpool, 18), {keyword_rescue, modifier_rescue}, EXPR_MID},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, {keyword_rescue, modifier_rescue}, EXPR_MID},
#line 45 "defs/keywords"
- {gperf_offsetof(stringpool, 19), {keyword_true, keyword_true}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, {keyword_true, keyword_true}, EXPR_END},
#line 48 "defs/keywords"
- {gperf_offsetof(stringpool, 20), {keyword_until, modifier_until}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, {keyword_until, modifier_until}, EXPR_VALUE},
#line 47 "defs/keywords"
- {gperf_offsetof(stringpool, 21), {keyword_unless, modifier_unless}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, {keyword_unless, modifier_unless}, EXPR_VALUE},
#line 41 "defs/keywords"
- {gperf_offsetof(stringpool, 22), {keyword_return, keyword_return}, EXPR_MID},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, {keyword_return, keyword_return}, EXPR_MID},
#line 22 "defs/keywords"
- {gperf_offsetof(stringpool, 23), {keyword_def, keyword_def}, EXPR_FNAME},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, {keyword_def, keyword_def}, EXPR_FNAME},
#line 17 "defs/keywords"
- {gperf_offsetof(stringpool, 24), {keyword_and, keyword_and}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, {keyword_and, keyword_and}, EXPR_VALUE},
#line 24 "defs/keywords"
- {gperf_offsetof(stringpool, 25), {keyword_do, keyword_do}, EXPR_BEG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, {keyword_do, keyword_do}, EXPR_BEG},
#line 51 "defs/keywords"
- {gperf_offsetof(stringpool, 26), {keyword_yield, keyword_yield}, EXPR_ARG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, {keyword_yield, keyword_yield}, EXPR_ARG},
#line 30 "defs/keywords"
- {gperf_offsetof(stringpool, 27), {keyword_for, keyword_for}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, {keyword_for, keyword_for}, EXPR_VALUE},
#line 46 "defs/keywords"
- {gperf_offsetof(stringpool, 28), {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM},
#line 37 "defs/keywords"
- {gperf_offsetof(stringpool, 29), {keyword_or, keyword_or}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, {keyword_or, keyword_or}, EXPR_VALUE},
#line 32 "defs/keywords"
- {gperf_offsetof(stringpool, 30), {keyword_in, keyword_in}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, {keyword_in, keyword_in}, EXPR_VALUE},
#line 49 "defs/keywords"
- {gperf_offsetof(stringpool, 31), {keyword_when, keyword_when}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, {keyword_when, keyword_when}, EXPR_VALUE},
#line 40 "defs/keywords"
- {gperf_offsetof(stringpool, 32), {keyword_retry, keyword_retry}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, {keyword_retry, keyword_retry}, EXPR_END},
#line 31 "defs/keywords"
- {gperf_offsetof(stringpool, 33), {keyword_if, modifier_if}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, {keyword_if, modifier_if}, EXPR_VALUE},
#line 20 "defs/keywords"
- {gperf_offsetof(stringpool, 34), {keyword_case, keyword_case}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, {keyword_case, keyword_case}, EXPR_VALUE},
#line 38 "defs/keywords"
- {gperf_offsetof(stringpool, 35), {keyword_redo, keyword_redo}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, {keyword_redo, keyword_redo}, EXPR_END},
#line 34 "defs/keywords"
- {gperf_offsetof(stringpool, 36), {keyword_next, keyword_next}, EXPR_MID},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, {keyword_next, keyword_next}, EXPR_MID},
#line 43 "defs/keywords"
- {gperf_offsetof(stringpool, 37), {keyword_super, keyword_super}, EXPR_ARG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, {keyword_super, keyword_super}, EXPR_ARG},
#line 33 "defs/keywords"
- {gperf_offsetof(stringpool, 38), {keyword_module, keyword_module}, EXPR_VALUE},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, {keyword_module, keyword_module}, EXPR_VALUE},
#line 18 "defs/keywords"
- {gperf_offsetof(stringpool, 39), {keyword_begin, keyword_begin}, EXPR_BEG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, {keyword_begin, keyword_begin}, EXPR_BEG},
#line 12 "defs/keywords"
- {gperf_offsetof(stringpool, 40), {keyword__LINE__, keyword__LINE__}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, {keyword__LINE__, keyword__LINE__}, EXPR_END},
#line 13 "defs/keywords"
- {gperf_offsetof(stringpool, 41), {keyword__FILE__, keyword__FILE__}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, {keyword__FILE__, keyword__FILE__}, EXPR_END},
#line 11 "defs/keywords"
- {gperf_offsetof(stringpool, 42), {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
#line 15 "defs/keywords"
- {gperf_offsetof(stringpool, 43), {keyword_END, keyword_END}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, {keyword_END, keyword_END}, EXPR_END},
#line 16 "defs/keywords"
- {gperf_offsetof(stringpool, 44), {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM},
#line 14 "defs/keywords"
- {gperf_offsetof(stringpool, 45), {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
#line 23 "defs/keywords"
- {gperf_offsetof(stringpool, 46), {keyword_defined, keyword_defined}, EXPR_ARG},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, {keyword_defined, keyword_defined}, EXPR_ARG},
#line 21 "defs/keywords"
- {gperf_offsetof(stringpool, 47), {keyword_class, keyword_class}, EXPR_CLASS},
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, {keyword_class, keyword_class}, EXPR_CLASS},
{-1}, {-1},
#line 50 "defs/keywords"
- {gperf_offsetof(stringpool, 50), {keyword_while, modifier_while}, EXPR_VALUE}
+ {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, {keyword_while, modifier_while}, EXPR_VALUE}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/lib/English.gemspec b/lib/English.gemspec
index a08542bcda..9c09555ca1 100644
--- a/lib/English.gemspec
+++ b/lib/English.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "english"
- spec.version = "0.7.2"
+ spec.version = "0.8.1"
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -15,8 +15,13 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ excludes = %W[
+ :^/test :^/spec :^/feature :^/bin
+ :^/Rakefile :^/Gemfile\* :^/.git*
+ :^/#{File.basename(__FILE__)}
+ ]
+ spec.files = IO.popen(%W[git ls-files -z --] + excludes, err: IO::NULL) do |f|
+ f.readlines("\x0", chomp: true)
end
spec.require_paths = ["lib"]
end
diff --git a/lib/English.rb b/lib/English.rb
index da50dfdc29..bf7896dcd6 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -9,7 +9,7 @@
# "waterbuffalo" =~ /buff/
# print $', $$, "\n"
#
-# With English:
+# With 'English':
#
# require "English"
#
@@ -20,31 +20,30 @@
# Below is a full list of descriptive aliases and their associated global
# variable:
#
-# $ERROR_INFO:: $!
-# $ERROR_POSITION:: $@
-# $FS:: $;
-# $FIELD_SEPARATOR:: $;
-# $OFS:: $,
-# $OUTPUT_FIELD_SEPARATOR:: $,
-# $RS:: $/
-# $INPUT_RECORD_SEPARATOR:: $/
-# $ORS:: $\
-# $OUTPUT_RECORD_SEPARATOR:: $\
-# $INPUT_LINE_NUMBER:: $.
-# $NR:: $.
-# $LAST_READ_LINE:: $_
-# $DEFAULT_OUTPUT:: $>
-# $DEFAULT_INPUT:: $<
-# $PID:: $$
-# $PROCESS_ID:: $$
-# $CHILD_STATUS:: $?
-# $LAST_MATCH_INFO:: $~
-# $IGNORECASE:: $=
-# $ARGV:: $*
-# $MATCH:: $&
-# $PREMATCH:: $`
-# $POSTMATCH:: $'
-# $LAST_PAREN_MATCH:: $+
+# <tt>$ERROR_INFO</tt>:: <tt>$!</tt>
+# <tt>$ERROR_POSITION</tt>:: <tt>$@</tt>
+# <tt>$FS</tt>:: <tt>$;</tt>
+# <tt>$FIELD_SEPARATOR</tt>:: <tt>$;</tt>
+# <tt>$OFS</tt>:: <tt>$,</tt>
+# <tt>$OUTPUT_FIELD_SEPARATOR</tt>:: <tt>$,</tt>
+# <tt>$RS</tt>:: <tt>$/</tt>
+# <tt>$INPUT_RECORD_SEPARATOR</tt>:: <tt>$/</tt>
+# <tt>$ORS</tt>:: <tt>$\</tt>
+# <tt>$OUTPUT_RECORD_SEPARATOR</tt>:: <tt>$\</tt>
+# <tt>$NR</tt>:: <tt>$.</tt>
+# <tt>$INPUT_LINE_NUMBER</tt>:: <tt>$.</tt>
+# <tt>$LAST_READ_LINE</tt>:: <tt>$_</tt>
+# <tt>$DEFAULT_OUTPUT</tt>:: <tt>$></tt>
+# <tt>$DEFAULT_INPUT</tt>:: <tt>$<</tt>
+# <tt>$PID</tt>:: <tt>$$</tt>
+# <tt>$PROCESS_ID</tt>:: <tt>$$</tt>
+# <tt>$CHILD_STATUS</tt>:: <tt>$?</tt>
+# <tt>$LAST_MATCH_INFO</tt>:: <tt>$~</tt>
+# <tt>$ARGV</tt>:: <tt>$*</tt>
+# <tt>$MATCH</tt>:: <tt>$&</tt>
+# <tt>$PREMATCH</tt>:: <tt>$`</tt>
+# <tt>$POSTMATCH</tt>:: <tt>$'</tt>
+# <tt>$LAST_PAREN_MATCH</tt>:: <tt>$+</tt>
#
module English end if false
@@ -58,44 +57,32 @@ alias $ERROR_POSITION $@
# The default separator pattern used by String#split. May be set from
# the command line using the <code>-F</code> flag.
alias $FS $;
-
-# The default separator pattern used by String#split. May be set from
-# the command line using the <code>-F</code> flag.
alias $FIELD_SEPARATOR $;
# The separator string output between the parameters to methods such
# as Kernel#print and Array#join. Defaults to +nil+, which adds no
# text.
-alias $OFS $,
# The separator string output between the parameters to methods such
# as Kernel#print and Array#join. Defaults to +nil+, which adds no
# text.
+alias $OFS $,
alias $OUTPUT_FIELD_SEPARATOR $,
# The input record separator (newline by default). This is the value
# that routines such as Kernel#gets use to determine record
# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $RS $/
-
-# The input record separator (newline by default). This is the value
-# that routines such as Kernel#gets use to determine record
-# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $INPUT_RECORD_SEPARATOR $/
# The string appended to the output of every call to methods such as
# Kernel#print and IO#write. The default value is +nil+.
alias $ORS $\
-
-# The string appended to the output of every call to methods such as
-# Kernel#print and IO#write. The default value is +nil+.
alias $OUTPUT_RECORD_SEPARATOR $\
# The number of the last line read from the current input file.
-alias $INPUT_LINE_NUMBER $.
-
-# The number of the last line read from the current input file.
alias $NR $.
+alias $INPUT_LINE_NUMBER $.
# The last line read by Kernel#gets or
# Kernel#readline. Many string-related functions in the
@@ -135,8 +122,6 @@ alias $DEFAULT_INPUT $<
# The process number of the program being executed. Read only.
alias $PID $$
-
-# The process number of the program being executed. Read only.
alias $PROCESS_ID $$
# The exit status of the last child process to terminate. Read
@@ -151,9 +136,6 @@ alias $CHILD_STATUS $?
# scope.
alias $LAST_MATCH_INFO $~
-# This variable is no longer effective. Deprecated.
-alias $IGNORECASE $=
-
# An array of strings containing the command-line
# options from the invocation of the program. Options
# used by the Ruby interpreter will have been
diff --git a/lib/abbrev.gemspec b/lib/abbrev.gemspec
deleted file mode 100644
index c28b960c8c..0000000000
--- a/lib/abbrev.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "abbrev"
- spec.version = "0.1.1"
- spec.authors = ["Akinori MUSHA"]
- spec.email = ["knu@idaemons.org"]
-
- spec.summary = %q{Calculates a set of unique abbreviations for a given set of strings}
- spec.description = %q{Calculates a set of unique abbreviations for a given set of strings}
- spec.homepage = "https://github.com/ruby/abbrev"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = []
- spec.require_paths = ["lib"]
-end
diff --git a/lib/abbrev.rb b/lib/abbrev.rb
deleted file mode 100644
index 2af01d2eae..0000000000
--- a/lib/abbrev.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-# frozen_string_literal: true
-#--
-# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org>
-#
-# All rights reserved. You can redistribute and/or modify it under
-# the same terms as Ruby.
-#
-# $Idaemons: /home/cvs/rb/abbrev.rb,v 1.2 2001/05/30 09:37:45 knu Exp $
-# $RoughId: abbrev.rb,v 1.4 2003/10/14 19:45:42 knu Exp $
-# $Id$
-#++
-
-##
-# Calculates the set of unambiguous abbreviations for a given set of strings.
-#
-# require 'abbrev'
-# require 'pp'
-#
-# pp Abbrev.abbrev(['ruby'])
-# #=> {"ruby"=>"ruby", "rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby"}
-#
-# pp Abbrev.abbrev(%w{ ruby rules })
-#
-# _Generates:_
-# { "ruby" => "ruby",
-# "rub" => "ruby",
-# "rules" => "rules",
-# "rule" => "rules",
-# "rul" => "rules" }
-#
-# It also provides an array core extension, Array#abbrev.
-#
-# pp %w{ summer winter }.abbrev
-#
-# _Generates:_
-# { "summer" => "summer",
-# "summe" => "summer",
-# "summ" => "summer",
-# "sum" => "summer",
-# "su" => "summer",
-# "s" => "summer",
-# "winter" => "winter",
-# "winte" => "winter",
-# "wint" => "winter",
-# "win" => "winter",
-# "wi" => "winter",
-# "w" => "winter" }
-
-module Abbrev
-
- # Given a set of strings, calculate the set of unambiguous abbreviations for
- # those strings, and return a hash where the keys are all the possible
- # abbreviations and the values are the full strings.
- #
- # Thus, given +words+ is "car" and "cone", the keys pointing to "car" would
- # be "ca" and "car", while those pointing to "cone" would be "co", "con", and
- # "cone".
- #
- # require 'abbrev'
- #
- # Abbrev.abbrev(%w{ car cone })
- # #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"}
- #
- # The optional +pattern+ parameter is a pattern or a string. Only input
- # strings that match the pattern or start with the string are included in the
- # output hash.
- #
- # Abbrev.abbrev(%w{car box cone crab}, /b/)
- # #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"}
- #
- # Abbrev.abbrev(%w{car box cone}, 'ca')
- # #=> {"car"=>"car", "ca"=>"car"}
- def abbrev(words, pattern = nil)
- table = {}
- seen = Hash.new(0)
-
- if pattern.is_a?(String)
- pattern = /\A#{Regexp.quote(pattern)}/ # regard as a prefix
- end
-
- words.each do |word|
- next if word.empty?
- word.size.downto(1) { |len|
- abbrev = word[0...len]
-
- next if pattern && pattern !~ abbrev
-
- case seen[abbrev] += 1
- when 1
- table[abbrev] = word
- when 2
- table.delete(abbrev)
- else
- break
- end
- }
- end
-
- words.each do |word|
- next if pattern && pattern !~ word
-
- table[word] = word
- end
-
- table
- end
-
- module_function :abbrev
-end
-
-class Array
- # Calculates the set of unambiguous abbreviations for the strings in +self+.
- #
- # require 'abbrev'
- # %w{ car cone }.abbrev
- # #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"}
- #
- # The optional +pattern+ parameter is a pattern or a string. Only input
- # strings that match the pattern or start with the string are included in the
- # output hash.
- #
- # %w{ fast boat day }.abbrev(/^.a/)
- # #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"}
- #
- # Abbrev.abbrev(%w{car box cone}, "ca")
- # #=> {"car"=>"car", "ca"=>"car"}
- #
- # See also Abbrev.abbrev
- def abbrev(pattern = nil)
- Abbrev::abbrev(self, pattern)
- end
-end
diff --git a/lib/base64.gemspec b/lib/base64.gemspec
deleted file mode 100644
index daa0b7fa14..0000000000
--- a/lib/base64.gemspec
+++ /dev/null
@@ -1,20 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "base64"
- spec.version = "0.1.1"
- spec.authors = ["Yusuke Endoh"]
- spec.email = ["mame@ruby-lang.org"]
-
- spec.summary = %q{Support for encoding and decoding binary data using a Base64 representation.}
- spec.description = %q{Support for encoding and decoding binary data using a Base64 representation.}
- spec.homepage = "https://github.com/ruby/base64"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = ["README.md", "LICENSE.txt", "lib/base64.rb"]
- spec.bindir = "exe"
- spec.executables = []
- spec.require_paths = ["lib"]
-end
diff --git a/lib/base64.rb b/lib/base64.rb
deleted file mode 100644
index 693aa1f519..0000000000
--- a/lib/base64.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-# frozen_string_literal: true
-#
-# = base64.rb: methods for base64-encoding and -decoding strings
-#
-
-# The Base64 module provides for the encoding (#encode64, #strict_encode64,
-# #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
-# #urlsafe_decode64) of binary data using a Base64 representation.
-#
-# == 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.
-
-module Base64
- module_function
-
- # Returns the Base64-encoded version of +bin+.
- # This method complies with RFC 2045.
- # Line feeds are added to every 60 encoded characters.
- #
- # require 'base64'
- # Base64.encode64("Now is the time for all good coders\nto learn Ruby")
- #
- # <i>Generates:</i>
- #
- # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
- # UnVieQ==
- def encode64(bin)
- [bin].pack("m")
- end
-
- # Returns the Base64-decoded version of +str+.
- # This method complies with RFC 2045.
- # Characters outside the base alphabet are ignored.
- #
- # 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.unpack1("m")
- end
-
- # Returns the Base64-encoded version of +bin+.
- # This method complies with RFC 4648.
- # No line feeds are added.
- def strict_encode64(bin)
- [bin].pack("m0")
- end
-
- # Returns the Base64-decoded version of +str+.
- # This method complies with RFC 4648.
- # ArgumentError is raised if +str+ is incorrectly padded or contains
- # non-alphabet characters. Note that CR or LF are also rejected.
- def strict_decode64(str)
- str.unpack1("m0")
- end
-
- # Returns the Base64-encoded version of +bin+.
- # This method complies with ``Base 64 Encoding with URL and Filename Safe
- # Alphabet'' in RFC 4648.
- # The alphabet uses '-' instead of '+' and '_' instead of '/'.
- # Note that the result can still contain '='.
- # You can remove the padding by setting +padding+ as false.
- def urlsafe_encode64(bin, padding: true)
- str = strict_encode64(bin)
- str.chomp!("==") or str.chomp!("=") unless padding
- str.tr!("+/", "-_")
- str
- end
-
- # Returns the Base64-decoded version of +str+.
- # This method complies with ``Base 64 Encoding with URL and Filename Safe
- # Alphabet'' in RFC 4648.
- # The alphabet uses '-' instead of '+' and '_' instead of '/'.
- #
- # The padding character is optional.
- # This method accepts both correctly-padded and unpadded input.
- # Note that it still rejects incorrectly-padded input.
- def urlsafe_decode64(str)
- # NOTE: RFC 4648 does say nothing about unpadded input, but says that
- # "the excess pad characters MAY also be ignored", so it is inferred that
- # unpadded input is also acceptable.
- if !str.end_with?("=") && str.length % 4 != 0
- str = str.ljust((str.length + 3) & ~3, "=")
- str.tr!("-_", "+/")
- else
- str = str.tr("-_", "+/")
- end
- strict_decode64(str)
- end
-end
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
deleted file mode 100644
index 79c782e262..0000000000
--- a/lib/benchmark.rb
+++ /dev/null
@@ -1,582 +0,0 @@
-# frozen_string_literal: true
-#--
-# benchmark.rb - a performance benchmarking library
-#
-# $Id$
-#
-# Created by Gotoken (gotoken@notwork.org).
-#
-# Documentation by Gotoken (original RD), Lyle Johnson (RDoc conversion), and
-# Gavin Sinclair (editing).
-#++
-#
-# == Overview
-#
-# The Benchmark module provides methods for benchmarking Ruby code, giving
-# detailed reports on the time taken for each task.
-#
-
-# The Benchmark module provides methods to measure and report the time
-# used to execute Ruby code.
-#
-# * Measure the time to construct the string given by the expression
-# <code>"a"*1_000_000_000</code>:
-#
-# require 'benchmark'
-#
-# puts Benchmark.measure { "a"*1_000_000_000 }
-#
-# On my machine (OSX 10.8.3 on i5 1.7 GHz) this generates:
-#
-# 0.350000 0.400000 0.750000 ( 0.835234)
-#
-# This report shows the user CPU time, system CPU time, the sum of
-# the user and system CPU times, and the elapsed real time. The unit
-# of time is seconds.
-#
-# * Do some experiments sequentially using the #bm method:
-#
-# require 'benchmark'
-#
-# n = 5000000
-# Benchmark.bm do |x|
-# x.report { for i in 1..n; a = "1"; end }
-# x.report { n.times do ; a = "1"; end }
-# x.report { 1.upto(n) do ; a = "1"; end }
-# end
-#
-# The result:
-#
-# user system total real
-# 1.010000 0.000000 1.010000 ( 1.014479)
-# 1.000000 0.000000 1.000000 ( 0.998261)
-# 0.980000 0.000000 0.980000 ( 0.981335)
-#
-# * Continuing the previous example, put a label in each report:
-#
-# require 'benchmark'
-#
-# n = 5000000
-# Benchmark.bm(7) do |x|
-# x.report("for:") { for i in 1..n; a = "1"; end }
-# x.report("times:") { n.times do ; a = "1"; end }
-# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
-# end
-#
-# The result:
-#
-# user system total real
-# for: 1.010000 0.000000 1.010000 ( 1.015688)
-# times: 1.000000 0.000000 1.000000 ( 1.003611)
-# upto: 1.030000 0.000000 1.030000 ( 1.028098)
-#
-# * The times for some benchmarks depend on the order in which items
-# are run. These differences are due to the cost of memory
-# allocation and garbage collection. To avoid these discrepancies,
-# the #bmbm method is provided. For example, to compare ways to
-# sort an array of floats:
-#
-# require 'benchmark'
-#
-# array = (1..1000000).map { rand }
-#
-# Benchmark.bmbm do |x|
-# x.report("sort!") { array.dup.sort! }
-# x.report("sort") { array.dup.sort }
-# end
-#
-# The result:
-#
-# Rehearsal -----------------------------------------
-# sort! 1.490000 0.010000 1.500000 ( 1.490520)
-# sort 1.460000 0.000000 1.460000 ( 1.463025)
-# -------------------------------- total: 2.960000sec
-#
-# user system total real
-# sort! 1.460000 0.000000 1.460000 ( 1.460465)
-# sort 1.450000 0.010000 1.460000 ( 1.448327)
-#
-# * Report statistics of sequential experiments with unique labels,
-# using the #benchmark method:
-#
-# require 'benchmark'
-# include Benchmark # we need the CAPTION and FORMAT constants
-#
-# n = 5000000
-# Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
-# tf = x.report("for:") { for i in 1..n; a = "1"; end }
-# tt = x.report("times:") { n.times do ; a = "1"; end }
-# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
-# [tf+tt+tu, (tf+tt+tu)/3]
-# end
-#
-# The result:
-#
-# user system total real
-# for: 0.950000 0.000000 0.950000 ( 0.952039)
-# times: 0.980000 0.000000 0.980000 ( 0.984938)
-# upto: 0.950000 0.000000 0.950000 ( 0.946787)
-# >total: 2.880000 0.000000 2.880000 ( 2.883764)
-# >avg: 0.960000 0.000000 0.960000 ( 0.961255)
-
-module Benchmark
-
- BENCHMARK_VERSION = "2002-04-25" # :nodoc:
-
- # Invokes the block with a Benchmark::Report object, which
- # may be used to collect and report on the results of individual
- # benchmark tests. Reserves +label_width+ leading spaces for
- # labels on each line. Prints +caption+ at the top of the
- # report, and uses +format+ to format each line.
- # (Note: +caption+ must contain a terminating newline character,
- # see the default Benchmark::Tms::CAPTION for an example.)
- #
- # Returns an array of Benchmark::Tms objects.
- #
- # If the block returns an array of
- # Benchmark::Tms objects, these will be used to format
- # additional lines of output. If +labels+ parameter are
- # given, these are used to label these extra lines.
- #
- # _Note_: Other methods provide a simpler interface to this one, and are
- # suitable for nearly all benchmarking requirements. See the examples in
- # Benchmark, and the #bm and #bmbm methods.
- #
- # Example:
- #
- # require 'benchmark'
- # include Benchmark # we need the CAPTION and FORMAT constants
- #
- # n = 5000000
- # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
- # tf = x.report("for:") { for i in 1..n; a = "1"; end }
- # tt = x.report("times:") { n.times do ; a = "1"; end }
- # tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
- # [tf+tt+tu, (tf+tt+tu)/3]
- # end
- #
- # Generates:
- #
- # user system total real
- # for: 0.970000 0.000000 0.970000 ( 0.970493)
- # times: 0.990000 0.000000 0.990000 ( 0.989542)
- # upto: 0.970000 0.000000 0.970000 ( 0.972854)
- # >total: 2.930000 0.000000 2.930000 ( 2.932889)
- # >avg: 0.976667 0.000000 0.976667 ( 0.977630)
- #
-
- def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report
- sync = $stdout.sync
- $stdout.sync = true
- label_width ||= 0
- label_width += 1
- format ||= FORMAT
- print ' '*label_width + caption unless caption.empty?
- report = Report.new(label_width, format)
- results = yield(report)
- Array === results and results.grep(Tms).each {|t|
- print((labels.shift || t.label || "").ljust(label_width), t.format(format))
- }
- report.list
- ensure
- $stdout.sync = sync unless sync.nil?
- end
-
-
- # A simple interface to the #benchmark method, #bm generates sequential
- # reports with labels. +label_width+ and +labels+ parameters have the same
- # meaning as for #benchmark.
- #
- # require 'benchmark'
- #
- # n = 5000000
- # Benchmark.bm(7) do |x|
- # x.report("for:") { for i in 1..n; a = "1"; end }
- # x.report("times:") { n.times do ; a = "1"; end }
- # x.report("upto:") { 1.upto(n) do ; a = "1"; end }
- # end
- #
- # Generates:
- #
- # user system total real
- # for: 0.960000 0.000000 0.960000 ( 0.957966)
- # times: 0.960000 0.000000 0.960000 ( 0.960423)
- # upto: 0.950000 0.000000 0.950000 ( 0.954864)
- #
-
- def bm(label_width = 0, *labels, &blk) # :yield: report
- benchmark(CAPTION, label_width, FORMAT, *labels, &blk)
- end
-
-
- # Sometimes benchmark results are skewed because code executed
- # earlier encounters different garbage collection overheads than
- # that run later. #bmbm attempts to minimize this effect by running
- # the tests twice, the first time as a rehearsal in order to get the
- # runtime environment stable, the second time for
- # real. GC.start is executed before the start of each of
- # the real timings; the cost of this is not included in the
- # timings. In reality, though, there's only so much that #bmbm can
- # do, and the results are not guaranteed to be isolated from garbage
- # collection and other effects.
- #
- # Because #bmbm takes two passes through the tests, it can
- # calculate the required label width.
- #
- # require 'benchmark'
- #
- # array = (1..1000000).map { rand }
- #
- # Benchmark.bmbm do |x|
- # x.report("sort!") { array.dup.sort! }
- # x.report("sort") { array.dup.sort }
- # end
- #
- # Generates:
- #
- # Rehearsal -----------------------------------------
- # sort! 1.440000 0.010000 1.450000 ( 1.446833)
- # sort 1.440000 0.000000 1.440000 ( 1.448257)
- # -------------------------------- total: 2.890000sec
- #
- # user system total real
- # sort! 1.460000 0.000000 1.460000 ( 1.458065)
- # sort 1.450000 0.000000 1.450000 ( 1.455963)
- #
- # #bmbm yields a Benchmark::Job object and returns an array of
- # Benchmark::Tms objects.
- #
- def bmbm(width = 0) # :yield: job
- job = Job.new(width)
- yield(job)
- width = job.width + 1
- sync = $stdout.sync
- $stdout.sync = true
-
- # rehearsal
- puts 'Rehearsal '.ljust(width+CAPTION.length,'-')
- ets = job.list.inject(Tms.new) { |sum,(label,item)|
- print label.ljust(width)
- res = Benchmark.measure(&item)
- print res.format
- sum + res
- }.format("total: %tsec")
- print " #{ets}\n\n".rjust(width+CAPTION.length+2,'-')
-
- # take
- print ' '*width + CAPTION
- job.list.map { |label,item|
- GC.start
- print label.ljust(width)
- Benchmark.measure(label, &item).tap { |res| print res }
- }
- ensure
- $stdout.sync = sync unless sync.nil?
- end
-
- #
- # Returns the time used to execute the given block as a
- # Benchmark::Tms object. Takes +label+ option.
- #
- # require 'benchmark'
- #
- # n = 1000000
- #
- # time = Benchmark.measure do
- # n.times { a = "1" }
- # end
- # puts time
- #
- # Generates:
- #
- # 0.220000 0.000000 0.220000 ( 0.227313)
- #
- def measure(label = "") # :yield:
- t0, r0 = Process.times, Process.clock_gettime(Process::CLOCK_MONOTONIC)
- yield
- t1, r1 = Process.times, Process.clock_gettime(Process::CLOCK_MONOTONIC)
- Benchmark::Tms.new(t1.utime - t0.utime,
- t1.stime - t0.stime,
- t1.cutime - t0.cutime,
- t1.cstime - t0.cstime,
- r1 - r0,
- label)
- end
-
- #
- # Returns the elapsed real time used to execute the given block.
- #
- def realtime # :yield:
- r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- yield
- Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0
- end
-
- module_function :benchmark, :measure, :realtime, :bm, :bmbm
-
- #
- # A Job is a sequence of labelled blocks to be processed by the
- # Benchmark.bmbm method. It is of little direct interest to the user.
- #
- class Job # :nodoc:
- #
- # Returns an initialized Job instance.
- # Usually, one doesn't call this method directly, as new
- # Job objects are created by the #bmbm method.
- # +width+ is a initial value for the label offset used in formatting;
- # the #bmbm method passes its +width+ argument to this constructor.
- #
- def initialize(width)
- @width = width
- @list = []
- end
-
- #
- # Registers the given label and block pair in the job list.
- #
- def item(label = "", &blk) # :yield:
- raise ArgumentError, "no block" unless block_given?
- label = label.to_s
- w = label.length
- @width = w if @width < w
- @list << [label, blk]
- self
- end
-
- alias report item
-
- # An array of 2-element arrays, consisting of label and block pairs.
- attr_reader :list
-
- # Length of the widest label in the #list.
- attr_reader :width
- end
-
- #
- # This class is used by the Benchmark.benchmark and Benchmark.bm methods.
- # It is of little direct interest to the user.
- #
- class Report # :nodoc:
- #
- # Returns an initialized Report instance.
- # Usually, one doesn't call this method directly, as new
- # Report objects are created by the #benchmark and #bm methods.
- # +width+ and +format+ are the label offset and
- # format string used by Tms#format.
- #
- def initialize(width = 0, format = nil)
- @width, @format, @list = width, format, []
- end
-
- #
- # Prints the +label+ and measured time for the block,
- # formatted by +format+. See Tms#format for the
- # formatting rules.
- #
- def item(label = "", *format, &blk) # :yield:
- print label.to_s.ljust(@width)
- @list << res = Benchmark.measure(label, &blk)
- print res.format(@format, *format)
- res
- end
-
- alias report item
-
- # An array of Benchmark::Tms objects representing each item.
- attr_reader :list
- end
-
-
-
- #
- # A data object, representing the times associated with a benchmark
- # measurement.
- #
- class Tms
-
- # Default caption, see also Benchmark::CAPTION
- CAPTION = " user system total real\n"
-
- # Default format string, see also Benchmark::FORMAT
- FORMAT = "%10.6u %10.6y %10.6t %10.6r\n"
-
- # User CPU time
- attr_reader :utime
-
- # System CPU time
- attr_reader :stime
-
- # User CPU time of children
- attr_reader :cutime
-
- # System CPU time of children
- attr_reader :cstime
-
- # Elapsed real time
- attr_reader :real
-
- # Total time, that is +utime+ + +stime+ + +cutime+ + +cstime+
- attr_reader :total
-
- # Label
- attr_reader :label
-
- #
- # Returns an initialized Tms object which has
- # +utime+ as the user CPU time, +stime+ as the system CPU time,
- # +cutime+ as the children's user CPU time, +cstime+ as the children's
- # system CPU time, +real+ as the elapsed real time and +label+ as the label.
- #
- def initialize(utime = 0.0, stime = 0.0, cutime = 0.0, cstime = 0.0, real = 0.0, label = nil)
- @utime, @stime, @cutime, @cstime, @real, @label = utime, stime, cutime, cstime, real, label.to_s
- @total = @utime + @stime + @cutime + @cstime
- end
-
- #
- # Returns a new Tms object whose times are the sum of the times for this
- # Tms object, plus the time required to execute the code block (+blk+).
- #
- def add(&blk) # :yield:
- self + Benchmark.measure(&blk)
- end
-
- #
- # An in-place version of #add.
- # Changes the times of this Tms object by making it the sum of the times
- # for this Tms object, plus the time required to execute
- # the code block (+blk+).
- #
- def add!(&blk)
- t = Benchmark.measure(&blk)
- @utime = utime + t.utime
- @stime = stime + t.stime
- @cutime = cutime + t.cutime
- @cstime = cstime + t.cstime
- @real = real + t.real
- self
- end
-
- #
- # Returns a new Tms object obtained by memberwise summation
- # of the individual times for this Tms object with those of the +other+
- # Tms object.
- # This method and #/() are useful for taking statistics.
- #
- def +(other); memberwise(:+, other) end
-
- #
- # Returns a new Tms object obtained by memberwise subtraction
- # of the individual times for the +other+ Tms object from those of this
- # Tms object.
- #
- def -(other); memberwise(:-, other) end
-
- #
- # Returns a new Tms object obtained by memberwise multiplication
- # of the individual times for this Tms object by +x+.
- #
- def *(x); memberwise(:*, x) end
-
- #
- # Returns a new Tms object obtained by memberwise division
- # of the individual times for this Tms object by +x+.
- # This method and #+() are useful for taking statistics.
- #
- def /(x); memberwise(:/, x) end
-
- #
- # Returns the contents of this Tms object as
- # a formatted string, according to a +format+ string
- # like that passed to Kernel.format. In addition, #format
- # accepts the following extensions:
- #
- # <tt>%u</tt>:: Replaced by the user CPU time, as reported by Tms#utime.
- # <tt>%y</tt>:: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
- # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
- # <tt>%Y</tt>:: Replaced by the children's system CPU time, as reported by Tms#cstime
- # <tt>%t</tt>:: Replaced by the total CPU time, as reported by Tms#total
- # <tt>%r</tt>:: Replaced by the elapsed real time, as reported by Tms#real
- # <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
- #
- # If +format+ is not given, FORMAT is used as default value, detailing the
- # user, system and real elapsed time.
- #
- def format(format = nil, *args)
- str = (format || FORMAT).dup
- str.gsub!(/(%[-+.\d]*)n/) { "#{$1}s" % label }
- str.gsub!(/(%[-+.\d]*)u/) { "#{$1}f" % utime }
- str.gsub!(/(%[-+.\d]*)y/) { "#{$1}f" % stime }
- str.gsub!(/(%[-+.\d]*)U/) { "#{$1}f" % cutime }
- str.gsub!(/(%[-+.\d]*)Y/) { "#{$1}f" % cstime }
- str.gsub!(/(%[-+.\d]*)t/) { "#{$1}f" % total }
- str.gsub!(/(%[-+.\d]*)r/) { "(#{$1}f)" % real }
- format ? str % args : str
- end
-
- #
- # Same as #format.
- #
- def to_s
- format
- end
-
- #
- # Returns a new 6-element array, consisting of the
- # label, user CPU time, system CPU time, children's
- # user CPU time, children's system CPU time and elapsed
- # real time.
- #
- def to_a
- [@label, @utime, @stime, @cutime, @cstime, @real]
- end
-
- #
- # Returns a hash containing the same data as `to_a`.
- #
- def to_h
- {
- label: @label,
- utime: @utime,
- stime: @stime,
- cutime: @cutime,
- cstime: @cstime,
- real: @real
- }
- end
-
- protected
-
- #
- # Returns a new Tms object obtained by memberwise operation +op+
- # of the individual times for this Tms object with those of the other
- # Tms object (+x+).
- #
- # +op+ can be a mathematical operation such as <tt>+</tt>, <tt>-</tt>,
- # <tt>*</tt>, <tt>/</tt>
- #
- def memberwise(op, x)
- case x
- when Benchmark::Tms
- Benchmark::Tms.new(utime.__send__(op, x.utime),
- stime.__send__(op, x.stime),
- cutime.__send__(op, x.cutime),
- cstime.__send__(op, x.cstime),
- real.__send__(op, x.real)
- )
- else
- Benchmark::Tms.new(utime.__send__(op, x),
- stime.__send__(op, x),
- cutime.__send__(op, x),
- cstime.__send__(op, x),
- real.__send__(op, x)
- )
- end
- end
- end
-
- # The default caption string (heading above the output times).
- CAPTION = Benchmark::Tms::CAPTION
-
- # The default format string used to display times. See also Benchmark::Tms#format.
- FORMAT = Benchmark::Tms::FORMAT
-end
diff --git a/lib/benchmark/benchmark.gemspec b/lib/benchmark/benchmark.gemspec
deleted file mode 100644
index 58b47d95e1..0000000000
--- a/lib/benchmark/benchmark.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/benchmark/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "benchmark"
- spec.version = Benchmark::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{a performance benchmarking library}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/benchmark"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = []
- spec.require_paths = ["lib"]
-end
diff --git a/lib/benchmark/version.rb b/lib/benchmark/version.rb
deleted file mode 100644
index 645966fd80..0000000000
--- a/lib/benchmark/version.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-module Benchmark
- VERSION = "0.2.1"
-end
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
new file mode 100644
index 0000000000..a287c49a34
--- /dev/null
+++ b/lib/bundled_gems.rb
@@ -0,0 +1,275 @@
+# -*- frozen-string-literal: true -*-
+
+module Gem # :nodoc:
+ # TODO: the nodoc above is a workaround for RDoc's Prism parser handling stopdoc differently, we may want to use
+ # stopdoc/startdoc pair like before
+end
+
+module Gem::BUNDLED_GEMS # :nodoc:
+ SINCE = {
+ "racc" => "3.3.0",
+ "abbrev" => "3.4.0",
+ "base64" => "3.4.0",
+ "bigdecimal" => "3.4.0",
+ "csv" => "3.4.0",
+ "drb" => "3.4.0",
+ "getoptlong" => "3.4.0",
+ "mutex_m" => "3.4.0",
+ "nkf" => "3.4.0",
+ "observer" => "3.4.0",
+ "resolv-replace" => "3.4.0",
+ "rinda" => "3.4.0",
+ "syslog" => "3.4.0",
+ "ostruct" => "4.0.0",
+ "pstore" => "4.0.0",
+ "rdoc" => "4.0.0",
+ "win32ole" => "4.0.0",
+ "fiddle" => "4.0.0",
+ "logger" => "4.0.0",
+ "benchmark" => "4.0.0",
+ "irb" => "4.0.0",
+ "reline" => "4.0.0",
+ # "readline" => "4.0.0", # This is wrapper for reline. We don't warn for this.
+ "tsort" => "4.1.0",
+ }.freeze
+
+ EXACT = {
+ "kconv" => "nkf",
+ }.freeze
+
+ WARNED = {} # unfrozen
+
+ conf = ::RbConfig::CONFIG
+ LIBDIR = (conf["rubylibdir"] + "/").freeze
+ ARCHDIR = (conf["rubyarchdir"] + "/").freeze
+ dlext = [conf["DLEXT"], "so"].uniq
+ DLEXT = /\.#{Regexp.union(dlext)}\z/
+ LIBEXT = /\.#{Regexp.union("rb", *dlext)}\z/
+
+ def self.replace_require(specs)
+ return if [::Kernel.singleton_class, ::Kernel].any? {|klass| klass.respond_to?(:no_warning_require) }
+
+ spec_names = specs.to_a.each_with_object({}) {|spec, h| h[spec.name] = true }
+
+ [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
+ kernel_class.send(:alias_method, :no_warning_require, :require)
+ kernel_class.send(:define_method, :require) do |name|
+ if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names)
+ Kernel.warn message, uplevel: ::Gem::BUNDLED_GEMS.uplevel
+ end
+ kernel_class.send(:no_warning_require, name)
+ end
+ if kernel_class == ::Kernel
+ kernel_class.send(:private, :require)
+ else
+ kernel_class.send(:public, :require)
+ end
+ end
+ end
+
+ def self.uplevel
+ frame_count = 0
+ require_labels = ["replace_require", "require"]
+ uplevel = 0
+ require_found = false
+ Thread.each_caller_location do |cl|
+ frame_count += 1
+
+ if require_found
+ unless require_labels.include?(cl.base_label)
+ return uplevel
+ end
+ else
+ if require_labels.include?(cl.base_label)
+ require_found = true
+ end
+ end
+ uplevel += 1
+ # Don't show script name when bundle exec and call ruby script directly.
+ if cl.path.end_with?("bundle")
+ return
+ end
+ end
+ require_found ? 1 : (frame_count - 1).nonzero?
+ end
+
+ def self.warning?(name, specs: nil)
+ # name can be a feature name or a file path with String or Pathname
+ feature = File.path(name).sub(LIBEXT, "")
+
+ # The actual checks needed to properly identify the gem being required
+ # are costly (see [Bug #20641]), so we first do a much cheaper check
+ # to exclude the vast majority of candidates.
+ subfeature = if feature.include?("/")
+ # bootsnap expands `require "csv"` to `require "#{LIBDIR}/csv.rb"`,
+ # and `require "syslog"` to `require "#{ARCHDIR}/syslog.so"`.
+ feature.delete_prefix!(ARCHDIR)
+ feature.delete_prefix!(LIBDIR)
+ # 1. A segment for the EXACT mapping and SINCE check
+ # 2. A segment for the SINCE check for dashed names
+ # 3. A segment to check if there's a subfeature
+ segments = feature.split("/", 3)
+ name = segments.shift
+ name = EXACT[name] || name
+ if !SINCE[name]
+ name = "#{name}-#{segments.shift}"
+ return unless SINCE[name]
+ end
+ segments.any?
+ else
+ name = EXACT[feature] || feature
+ return unless SINCE[name]
+ false
+ end
+
+ if suppress_list = Thread.current[:__bundled_gems_warning_suppression]
+ return if suppress_list.include?(name) || suppress_list.include?(feature)
+ end
+
+ return if specs.include?(name)
+
+ # Don't warn if a hyphenated gem provides this feature
+ # (e.g., benchmark-ips provides benchmark/ips, benchmark/timing, etc.)
+ if subfeature
+ prefix = feature.split("/").first + "-"
+ return if specs.any? { |spec, _| spec.start_with?(prefix) }
+
+ # Don't warn if the feature is found outside the standard library
+ # (e.g., benchmark-ips's lib dir is on $LOAD_PATH but not in specs)
+ resolved = $LOAD_PATH.resolve_feature_path(feature) rescue nil
+ if resolved && !resolved[1].start_with?(LIBDIR, ARCHDIR)
+ return
+ end
+ end
+
+ return if WARNED[name]
+ WARNED[name] = true
+
+ level = RUBY_VERSION < SINCE[name] ? :warning : :error
+
+ if subfeature
+ "#{feature} is found in #{name}, which"
+ else
+ "#{feature} #{level == :warning ? "was loaded" : "used to be loaded"} from the standard library, but"
+ end + build_message(name, level)
+ end
+
+ def self.build_message(name, level)
+ msg = if level == :warning
+ " will no longer be part of the default gems starting from Ruby #{SINCE[name]}"
+ else
+ " is not part of the default gems since Ruby #{SINCE[name]}."
+ end
+
+ if defined?(Bundler)
+ motivation = level == :warning ? "silence this warning" : "fix this error"
+ msg += "\nYou can add #{name} to your Gemfile or gemspec to #{motivation}."
+
+ # We detect the gem name from caller_locations. First we walk until we find `require`
+ # then take the first frame that's not from `require`.
+ #
+ # Additionally, we need to skip Bootsnap and Zeitwerk if present, these
+ # gems decorate Kernel#require, so they are not really the ones issuing
+ # the require call users should be warned about. Those are upwards.
+ frames_to_skip = 3
+ location = nil
+ require_found = false
+ Thread.each_caller_location do |cl|
+ if frames_to_skip >= 1
+ frames_to_skip -= 1
+ next
+ end
+
+ if require_found
+ if cl.base_label != "require"
+ location = cl.path
+ break
+ end
+ else
+ if cl.base_label == "require"
+ require_found = true
+ end
+ end
+ end
+
+ if location && File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
+ caller_gem = nil
+ Gem.path.each do |path|
+ if location =~ %r{#{path}/gems/([\w\-\.]+)}
+ caller_gem = $1
+ break
+ end
+ end
+ if caller_gem
+ msg += "\nAlso please contact the author of #{caller_gem} to request adding #{name} into its gemspec."
+ end
+ end
+ else
+ msg += " Install #{name} from RubyGems."
+ end
+
+ msg
+ end
+
+ def self.force_activate(gem)
+ require "bundler"
+ Bundler.reset!
+
+ # Build and activate a temporary definition containing the original gems + the requested gem
+ builder = Bundler::Dsl.new
+
+ lockfile = nil
+ if Bundler::SharedHelpers.in_bundle? && Bundler.definition.gemfiles.size > 0
+ Bundler.definition.gemfiles.each {|gemfile| builder.eval_gemfile(gemfile) }
+ lockfile = begin
+ Bundler.default_lockfile
+ rescue Bundler::GemfileNotFound
+ nil
+ end
+ else
+ # Fake BUNDLE_GEMFILE and BUNDLE_LOCKFILE to let checks pass
+ orig_gemfile = ENV["BUNDLE_GEMFILE"]
+ orig_lockfile = ENV["BUNDLE_LOCKFILE"]
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
+ Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", "Gemfile.lock"
+ end
+
+ builder.gem gem
+
+ definition = builder.to_definition(lockfile, nil)
+ definition.validate_runtime!
+
+ begin
+ orig_ui = Bundler.ui
+ orig_no_lock = Bundler::Definition.no_lock
+
+ ui = Bundler::UI::Shell.new
+ ui.level = "silent"
+ Bundler.ui = ui
+ Bundler::Definition.no_lock = true
+
+ Bundler::Runtime.new(nil, definition).setup
+ rescue Bundler::GemNotFound
+ warn "Failed to activate #{gem}, please install it with 'gem install #{gem}'"
+ ensure
+ ENV['BUNDLE_GEMFILE'] = orig_gemfile if orig_gemfile
+ ENV['BUNDLE_LOCKFILE'] = orig_lockfile if orig_lockfile
+ Bundler.ui = orig_ui
+ Bundler::Definition.no_lock = orig_no_lock
+ end
+ end
+end
+
+# for RubyGems without Bundler environment.
+# If loading library is not part of the default gems and the bundled gems, warn it.
+class LoadError
+ def message # :nodoc:
+ return super unless path
+
+ name = path.tr("/", "-")
+ if !defined?(Bundler) && Gem::BUNDLED_GEMS::SINCE[name] && !Gem::BUNDLED_GEMS::WARNED[name]
+ warn name + Gem::BUNDLED_GEMS.build_message(name, :error), uplevel: Gem::BUNDLED_GEMS.uplevel
+ end
+ super
+ end
+end
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 1598397bca..12dde90fc5 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -1,23 +1,22 @@
# frozen_string_literal: true
+require_relative "bundler/rubygems_ext"
require_relative "bundler/vendored_fileutils"
-require "pathname"
+autoload :Pathname, "pathname" unless defined?(Pathname)
require "rbconfig"
require_relative "bundler/errors"
require_relative "bundler/environment_preserver"
require_relative "bundler/plugin"
-require_relative "bundler/rubygems_ext"
require_relative "bundler/rubygems_integration"
require_relative "bundler/version"
-require_relative "bundler/constants"
require_relative "bundler/current_ruby"
require_relative "bundler/build_metadata"
# Bundler provides a consistent environment for Ruby projects by
# tracking and installing the exact gems and versions that are needed.
#
-# Since Ruby 2.6, Bundler is a part of Ruby's standard library.
+# Bundler is a part of Ruby's standard library.
#
# Bundler is used by creating _gemfiles_ listing all the project dependencies
# and (optionally) their versions and then using
@@ -39,16 +38,10 @@ module Bundler
environment_preserver.replace_with_backup
SUDO_MUTEX = Thread::Mutex.new
- SAFE_MARSHAL_CLASSES = [Symbol, TrueClass, String, Array, Hash, Gem::Version, Gem::Specification].freeze
- SAFE_MARSHAL_ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
- SAFE_MARSHAL_PROC = proc do |object|
- object.tap do
- unless SAFE_MARSHAL_CLASSES.include?(object.class)
- raise TypeError, format(SAFE_MARSHAL_ERROR, object.class, SAFE_MARSHAL_CLASSES.join(", "))
- end
- end
- end
-
+ autoload :Checksum, File.expand_path("bundler/checksum", __dir__)
+ autoload :CLI, File.expand_path("bundler/cli", __dir__)
+ autoload :CIDetector, File.expand_path("bundler/ci_detector", __dir__)
+ autoload :CompactIndexClient, File.expand_path("bundler/compact_index_client", __dir__)
autoload :Definition, File.expand_path("bundler/definition", __dir__)
autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
@@ -58,16 +51,18 @@ module Bundler
autoload :Env, File.expand_path("bundler/env", __dir__)
autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
+ autoload :FREEBSD, File.expand_path("bundler/constants", __dir__)
autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
- autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
- autoload :Graph, File.expand_path("bundler/graph", __dir__)
autoload :Index, File.expand_path("bundler/index", __dir__)
autoload :Injector, File.expand_path("bundler/injector", __dir__)
autoload :Installer, File.expand_path("bundler/installer", __dir__)
autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
autoload :MatchRemoteMetadata, File.expand_path("bundler/match_remote_metadata", __dir__)
+ autoload :Materialization, File.expand_path("bundler/materialization", __dir__)
+ autoload :NULL, File.expand_path("bundler/constants", __dir__)
+ autoload :Override, File.expand_path("bundler/override", __dir__)
autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
@@ -85,10 +80,13 @@ module Bundler
autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
autoload :UI, File.expand_path("bundler/ui", __dir__)
autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
+ autoload :URINormalizer, File.expand_path("bundler/uri_normalizer", __dir__)
+ autoload :WINDOWS, File.expand_path("bundler/constants", __dir__)
+ autoload :SafeMarshal, File.expand_path("bundler/safe_marshal", __dir__)
class << self
def configure
- @configured ||= configure_gem_home_and_path
+ @configure ||= configure_gem_home_and_path
end
def ui
@@ -106,9 +104,7 @@ module Bundler
end
def create_bundle_path
- SharedHelpers.filesystem_access(bundle_path.to_s) do |p|
- mkdir_p(p)
- end unless bundle_path.exist?
+ mkdir_p(bundle_path) unless bundle_path.exist?
@bundle_path = bundle_path.realpath
rescue Errno::EEXIST
@@ -117,15 +113,15 @@ module Bundler
end
def configured_bundle_path
- @configured_bundle_path ||= settings.path.tap(&:validate!)
+ @configured_bundle_path ||= Bundler.settings.path.tap(&:validate!)
end
# Returns absolute location of where binstubs are installed to.
def bin_path
@bin_path ||= begin
- path = settings[:bin] || "bin"
+ path = Bundler.settings[:bin] || "bin"
path = Pathname.new(path).expand_path(root).expand_path
- SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
+ mkdir_p(path)
path
end
end
@@ -161,6 +157,7 @@ module Bundler
# Return if all groups are already loaded
return @setup if defined?(@setup) && @setup
+ configure_custom_gemfile
definition.validate_runtime!
SharedHelpers.print_major_deprecations!
@@ -173,6 +170,29 @@ module Bundler
end
end
+ def auto_switch
+ self_manager.restart_with_locked_bundler_if_needed
+ end
+
+ # Automatically install dependencies if <tt>settings[:auto_install]</tt> exists.
+ # This is set through config cmd `bundle config set --global auto_install 1`.
+ #
+ # Note that this method `nil`s out the global Definition object, so it
+ # should be called first, before you instantiate anything like an
+ # `Installer` that'll keep a reference to the old one instead.
+ def auto_install
+ return unless Bundler.settings[:auto_install]
+
+ begin
+ definition.specs
+ rescue GemNotFound, GitError
+ ui.info "Automatically installing missing gems."
+ reset!
+ CLI::Install.new({}).run
+ reset!
+ end
+ end
+
# Setups Bundler environment (see Bundler.setup) if it is not already set,
# and loads all gems from groups specified. Unlike ::setup, can be called
# multiple times with different groups (if they were allowed by setup).
@@ -200,27 +220,28 @@ module Bundler
end
def environment
- SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true
- load
+ SharedHelpers.feature_removed! "Bundler.environment has been removed in favor of Bundler.load"
end
# Returns an instance of Bundler::Definition for given Gemfile and lockfile
#
# @param unlock [Hash, Boolean, nil] Gems that have been requested
# to be updated or true if all gems should be updated
+ # @param lockfile [Pathname] Path to Gemfile.lock
# @return [Bundler::Definition]
- def definition(unlock = nil)
+ def definition(unlock = nil, lockfile = default_lockfile)
@definition = nil if unlock
@definition ||= begin
configure
- Definition.build(default_gemfile, default_lockfile, unlock)
+ Definition.build(default_gemfile, lockfile, unlock)
end
end
def frozen_bundle?
- frozen = settings[:deployment]
- frozen ||= settings[:frozen]
- frozen
+ frozen = Bundler.settings[:frozen]
+ return frozen unless frozen.nil?
+
+ Bundler.settings[:deployment]
end
def locked_gems
@@ -233,12 +254,6 @@ module Bundler
end
end
- def most_specific_locked_platform?(platform)
- return false unless defined?(@definition) && @definition
-
- definition.most_specific_locked_platform == platform
- end
-
def ruby_scope
"#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}"
end
@@ -327,7 +342,7 @@ module Bundler
def app_cache(custom_path = nil)
path = custom_path || root
- Pathname.new(path).join(settings.app_cache_path)
+ Pathname.new(path).join(Bundler.settings.app_cache_path)
end
def tmp(name = Process.pid.to_s)
@@ -337,20 +352,12 @@ module Bundler
def rm_rf(path)
FileUtils.remove_entry_secure(path) if path && File.exist?(path)
- rescue ArgumentError
- message = <<EOF
-It is a security vulnerability to allow your home directory to be world-writable, and bundler cannot continue.
-You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
-Please refer to https://ruby-doc.org/stdlib-3.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
-EOF
- File.world_writable?(path) ? Bundler.ui.warn(message) : raise
- raise PathError, "Please fix the world-writable issue with your #{path} directory"
end
def settings
@settings ||= Settings.new(app_config_path)
rescue GemfileNotFound
- @settings = Settings.new(Pathname.new(".bundle").expand_path)
+ @settings = Settings.new
end
# @return [Hash] Environment present before Bundler was activated
@@ -358,42 +365,21 @@ EOF
ORIGINAL_ENV.clone
end
- # @deprecated Use `unbundled_env` instead
def clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`",
- :print_caller_location => true
- )
-
- unbundled_env
+ removed_message =
+ "`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
+ Bundler::SharedHelpers.feature_removed!(removed_message)
end
# @return [Hash] Environment with all bundler-related variables removed
def unbundled_env
- env = original_env
-
- if env.key?("BUNDLER_ORIG_MANPATH")
- env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
- end
-
- env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
-
- if env.key?("RUBYOPT")
- rubyopt = env["RUBYOPT"].split(" ")
- rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
- rubyopt.delete("-rbundler/setup")
- env["RUBYOPT"] = rubyopt.join(" ")
- end
-
- if env.key?("RUBYLIB")
- rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
- rubylib.delete(__dir__)
- env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
- end
+ unbundle_env(original_env)
+ end
- env
+ # Remove all bundler-related variables from ENV
+ def unbundle_env!
+ ENV.replace(unbundle_env(ENV))
end
# Run block with environment present before Bundler was activated
@@ -401,16 +387,11 @@ EOF
with_env(original_env) { yield }
end
- # @deprecated Use `with_unbundled_env` instead
def with_clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { yield }
+ removed_message =
+ "`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ Bundler::SharedHelpers.feature_removed!(removed_message)
end
# Run block with all bundler-related variables removed
@@ -423,16 +404,11 @@ EOF
with_original_env { Kernel.system(*args) }
end
- # @deprecated Use `unbundled_system` instead
def clean_system(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
- "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { Kernel.system(*args) }
+ removed_message =
+ "`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ Bundler::SharedHelpers.feature_removed!(removed_message)
end
# Run subcommand in an environment with all bundler related variables removed
@@ -445,16 +421,11 @@ EOF
with_original_env { Kernel.exec(*args) }
end
- # @deprecated Use `unbundled_exec` instead
def clean_exec(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
- "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
- "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`",
- :print_caller_location => true
- )
-
- with_env(unbundled_env) { Kernel.exec(*args) }
+ removed_message =
+ "`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ Bundler::SharedHelpers.feature_removed!(removed_message)
end
# Run a `Kernel.exec` to a subcommand in an environment with all bundler related variables removed
@@ -463,10 +434,14 @@ EOF
end
def local_platform
- return Gem::Platform::RUBY if settings[:force_ruby_platform]
+ return Gem::Platform::RUBY if Bundler.settings[:force_ruby_platform]
Gem::Platform.local
end
+ def generic_local_platform
+ Gem::Platform.generic(local_platform)
+ end
+
def default_gemfile
SharedHelpers.default_gemfile
end
@@ -496,25 +471,34 @@ EOF
configured_bundle_path.use_system_gems?
end
- def mkdir_p(path, options = {})
- SharedHelpers.filesystem_access(path, :write) do |p|
+ def mkdir_p(path)
+ SharedHelpers.filesystem_access(path, :create) do |p|
FileUtils.mkdir_p(p)
end
end
def which(executable)
- if File.file?(executable) && File.executable?(executable)
- executable
- elsif paths = ENV["PATH"]
+ executable_path = find_executable(executable)
+ return executable_path if executable_path
+
+ if (paths = ENV["PATH"])
quote = '"'
paths.split(File::PATH_SEPARATOR).find do |path|
path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
- executable_path = File.expand_path(executable, path)
- return executable_path if File.file?(executable_path) && File.executable?(executable_path)
+ executable_path = find_executable(File.expand_path(executable, path))
+ return executable_path if executable_path
end
end
end
+ def find_executable(path)
+ extensions = RbConfig::CONFIG["EXECUTABLE_EXTS"]&.split
+ extensions = [RbConfig::CONFIG["EXEEXT"]] unless extensions&.any?
+ candidates = extensions.map {|ext| "#{path}#{ext}" }
+
+ candidates.find {|candidate| File.file?(candidate) && File.executable?(candidate) }
+ end
+
def read_file(file)
SharedHelpers.filesystem_access(file, :read) do
File.open(file, "r:UTF-8", &:read)
@@ -522,7 +506,16 @@ EOF
end
def safe_load_marshal(data)
- load_marshal(data, :marshal_proc => SAFE_MARSHAL_PROC)
+ if Gem.respond_to?(:load_safe_marshal)
+ Gem.load_safe_marshal
+ begin
+ Gem::SafeMarshal.safe_load(data)
+ rescue Gem::SafeMarshal::Reader::Error, Gem::SafeMarshal::Visitors::ToRuby::Error => e
+ raise MarshalError, "#{e.class}: #{e.message}"
+ end
+ else
+ load_marshal(data, marshal_proc: SafeMarshal.proc)
+ end
end
def load_gemspec(file, validate = false)
@@ -537,15 +530,7 @@ EOF
def load_gemspec_uncached(file, validate = false)
path = Pathname.new(file)
contents = read_file(file)
- spec = if contents.start_with?("---") # YAML header
- eval_yaml_gemspec(path, contents)
- else
- # Eval the gemspec from its parent directory, because some gemspecs
- # depend on "./" relative paths.
- SharedHelpers.chdir(path.dirname.to_s) do
- eval_gemspec(path, contents)
- end
- end
+ spec = eval_gemspec(path, contents)
return unless spec
spec.loaded_from = path.expand_path.to_s
Bundler.rubygems.validate(spec) if validate
@@ -558,11 +543,11 @@ EOF
def git_present?
return @git_present if defined?(@git_present)
- @git_present = Bundler.which("git#{RbConfig::CONFIG["EXEEXT"]}")
+ @git_present = Bundler.which("git")
end
def feature_flag
- @feature_flag ||= FeatureFlag.new(VERSION)
+ @feature_flag ||= FeatureFlag.new(Bundler.settings[:simulate_version] || VERSION)
end
def reset!
@@ -578,9 +563,8 @@ EOF
def reset_paths!
@bin_path = nil
- @bundler_major_version = nil
@bundle_path = nil
- @configured = nil
+ @configure = nil
@configured_bundle_path = nil
@definition = nil
@load = nil
@@ -604,6 +588,15 @@ EOF
Bundler.rubygems.clear_paths
end
+ def configure_custom_gemfile(custom_gemfile = nil)
+ custom_gemfile ||= Bundler.settings[:gemfile]
+
+ if custom_gemfile && !custom_gemfile.empty?
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
+ reset_settings_and_root!
+ end
+ end
+
def self_manager
@self_manager ||= begin
require_relative "bundler/self_manager"
@@ -613,6 +606,30 @@ EOF
private
+ def unbundle_env(env)
+ if env.key?("BUNDLER_ORIG_MANPATH")
+ env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
+ end
+
+ env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
+ env.delete("BUNDLER_SETUP")
+
+ if env.key?("RUBYOPT")
+ rubyopt = env["RUBYOPT"].split(" ")
+ rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
+ rubyopt.delete("-rbundler/setup")
+ env["RUBYOPT"] = rubyopt.join(" ")
+ end
+
+ if env.key?("RUBYLIB")
+ rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
+ rubylib.delete(__dir__)
+ env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
+ end
+
+ env
+ end
+
def load_marshal(data, marshal_proc: nil)
Marshal.load(data, marshal_proc)
rescue TypeError => e
@@ -623,16 +640,22 @@ EOF
Kernel.require "psych"
Gem::Specification.from_yaml(contents)
- rescue ::Psych::SyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
- eval_gemspec(path, contents)
end
def eval_gemspec(path, contents)
- eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
+ if contents.start_with?("---") # YAML header
+ eval_yaml_gemspec(path, contents)
+ else
+ # Eval the gemspec from its parent directory, because some gemspecs
+ # depend on "./" relative paths.
+ SharedHelpers.chdir(path.dirname.to_s) do
+ eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
+ end
+ end
rescue ScriptError, StandardError => e
msg = "There was an error while loading `#{path.basename}`: #{e.message}"
- raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
+ raise GemspecError, Dsl::DSLError.new(msg, path.to_s, e.backtrace, contents)
end
def configure_gem_path
diff --git a/lib/bundler/build_metadata.rb b/lib/bundler/build_metadata.rb
index 8bffb2fae7..49d2518078 100644
--- a/lib/bundler/build_metadata.rb
+++ b/lib/bundler/build_metadata.rb
@@ -4,21 +4,26 @@ module Bundler
# Represents metadata from when the Bundler gem was built.
module BuildMetadata
# begin ivars
- @release = false
+ @built_at = nil
# end ivars
# A hash representation of the build metadata.
def self.to_h
{
- "Built At" => built_at,
+ "Timestamp" => timestamp,
"Git SHA" => git_commit_sha,
- "Released Version" => release?,
}
end
+ # A timestamp representing the date the bundler gem was built, or the
+ # current time if never built
+ def self.timestamp
+ @timestamp ||= @built_at || Time.now.utc.strftime("%Y-%m-%d").freeze
+ end
+
# A string representing the date the bundler gem was built.
def self.built_at
- @built_at ||= Time.now.utc.strftime("%Y-%m-%d").freeze
+ @built_at
end
# The SHA for the git commit the bundler gem was built from.
@@ -29,15 +34,10 @@ module Bundler
# commit instance variable then we can't determine its commits SHA.
git_dir = File.expand_path("../../../.git", __dir__)
if File.directory?(git_dir)
- return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
+ return @git_commit_sha = IO.popen(%w[git rev-parse --short HEAD], { chdir: git_dir }, &:read).strip.freeze
end
@git_commit_sha ||= "unknown"
end
-
- # Whether this is an official release build of Bundler.
- def self.release?
- @release
- end
end
end
diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec
index da50b46225..49319e81b4 100644
--- a/lib/bundler/bundler.gemspec
+++ b/lib/bundler/bundler.gemspec
@@ -23,21 +23,23 @@ Gem::Specification.new do |s|
s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
s.metadata = {
- "bug_tracker_uri" => "https://github.com/rubygems/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
- "changelog_uri" => "https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md",
+ "bug_tracker_uri" => "https://github.com/ruby/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
+ "changelog_uri" => "https://github.com/ruby/rubygems/blob/master/bundler/CHANGELOG.md",
"homepage_uri" => "https://bundler.io/",
- "source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
+ "source_code_uri" => "https://github.com/ruby/rubygems/tree/master/bundler",
}
- s.required_ruby_version = ">= 2.6.0"
- s.required_rubygems_version = ">= 3.0.1"
+ s.required_ruby_version = ">= 3.2.0"
+
+ # It should match the RubyGems version shipped with `required_ruby_version` above
+ s.required_rubygems_version = ">= 3.4.1"
s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
# include the gemspec itself because warbler breaks w/o it
s.files += %w[lib/bundler/bundler.gemspec]
- s.bindir = "libexec"
+ s.bindir = "exe"
s.executables = %w[bundle bundler]
s.require_paths = ["lib"]
end
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
index 1f3712d48e..6d2437d895 100644
--- a/lib/bundler/capistrano.rb
+++ b/lib/bundler/capistrano.rb
@@ -1,22 +1,4 @@
# frozen_string_literal: true
require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2,
- "The Bundler task for Capistrano. Please use https://github.com/capistrano/bundler"
-
-# Capistrano task for Bundler.
-#
-# Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
-# Bundler will be activated after each new deployment.
-require_relative "deployment"
-require "capistrano/version"
-
-if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
- raise "For Capistrano 3.x integration, please use https://github.com/capistrano/bundler"
-end
-
-Capistrano::Configuration.instance(:must_exist).load do
- before "deploy:finalize_update", "bundle:install"
- Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
- set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
-end
+Bundler::SharedHelpers.feature_removed! "The Bundler task for Capistrano. Please use https://github.com/capistrano/bundler"
diff --git a/lib/bundler/checksum.rb b/lib/bundler/checksum.rb
new file mode 100644
index 0000000000..ce05818bb0
--- /dev/null
+++ b/lib/bundler/checksum.rb
@@ -0,0 +1,270 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Checksum
+ ALGO_SEPARATOR = "="
+ DEFAULT_ALGORITHM = "sha256"
+ private_constant :DEFAULT_ALGORITHM
+ DEFAULT_BLOCK_SIZE = 16_384
+ private_constant :DEFAULT_BLOCK_SIZE
+
+ class << self
+ def from_gem_package(gem_package, algo = DEFAULT_ALGORITHM)
+ return if Bundler.settings[:disable_checksum_validation]
+ return unless source = gem_package.instance_variable_get(:@gem)
+ return unless source.respond_to?(:with_read_io)
+
+ source.with_read_io do |io|
+ from_gem(io, source.path)
+ ensure
+ io.rewind
+ end
+ end
+
+ def from_gem(io, pathname, algo = DEFAULT_ALGORITHM)
+ digest = Bundler::SharedHelpers.digest(algo.upcase).new
+ buf = String.new(capacity: DEFAULT_BLOCK_SIZE)
+ digest << io.readpartial(DEFAULT_BLOCK_SIZE, buf) until io.eof?
+ Checksum.new(algo, digest.hexdigest!, Source.new(:gem, pathname))
+ end
+
+ def from_api(digest, source_uri, algo = DEFAULT_ALGORITHM)
+ return if Bundler.settings[:disable_checksum_validation]
+
+ Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:api, source_uri))
+ end
+
+ def from_lock(lock_checksum, lockfile_location)
+ algo, digest = lock_checksum.strip.split(ALGO_SEPARATOR, 2)
+ Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:lock, lockfile_location))
+ end
+
+ def to_hexdigest(digest, algo = DEFAULT_ALGORITHM)
+ return digest unless algo == DEFAULT_ALGORITHM
+ return digest if digest.match?(/\A[0-9a-f]{64}\z/i)
+
+ if digest.match?(%r{\A[-0-9a-z_+/]{43}={0,2}\z}i)
+ digest = digest.tr("-_", "+/") # fix urlsafe base64
+ digest.unpack1("m0").unpack1("H*")
+ else
+ raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
+ end
+ end
+ end
+
+ attr_reader :algo, :digest, :sources
+
+ def initialize(algo, digest, source)
+ @algo = algo
+ @digest = digest
+ @sources = [source]
+ end
+
+ def ==(other)
+ match?(other) && other.sources == sources
+ end
+
+ alias_method :eql?, :==
+
+ def same_source?(other)
+ sources.include?(other.sources.first)
+ end
+
+ def match?(other)
+ other.is_a?(self.class) && other.digest == digest && other.algo == algo
+ end
+
+ def hash
+ digest.hash
+ end
+
+ def to_s
+ "#{to_lock} (from #{sources.first}#{", ..." if sources.size > 1})"
+ end
+
+ def to_lock
+ "#{algo}#{ALGO_SEPARATOR}#{digest}"
+ end
+
+ def merge!(other)
+ return nil unless match?(other)
+
+ @sources.concat(other.sources).uniq!
+ self
+ end
+
+ def formatted_sources
+ sources.join("\n and ").concat("\n")
+ end
+
+ def removable?
+ sources.all?(&:removable?)
+ end
+
+ def removal_instructions
+ msg = +""
+ i = 1
+ sources.each do |source|
+ msg << " #{i}. #{source.removal}\n"
+ i += 1
+ end
+ msg << " #{i}. run `bundle install`\n"
+ end
+
+ def inspect
+ abbr = "#{algo}#{ALGO_SEPARATOR}#{digest[0, 8]}"
+ from = "from #{sources.join(" and ")}"
+ "#<#{self.class}:#{object_id} #{abbr} #{from}>"
+ end
+
+ class Source
+ attr_reader :type, :location
+
+ def initialize(type, location)
+ @type = type
+ @location = location
+ end
+
+ def removable?
+ [:lock, :gem].include?(type)
+ end
+
+ def ==(other)
+ other.is_a?(self.class) && other.type == type && other.location == location
+ end
+
+ # phrased so that the usual string format is grammatically correct
+ # rake (10.3.2) sha256=abc123 from #{to_s}
+ def to_s
+ case type
+ when :lock
+ "the lockfile CHECKSUMS at #{location}"
+ when :gem
+ "the gem at #{location}"
+ when :api
+ "the API at #{location}"
+ else
+ "#{location} (#{type})"
+ end
+ end
+
+ # A full sentence describing how to remove the checksum
+ def removal
+ case type
+ when :lock
+ "remove the matching checksum in #{location}"
+ when :gem
+ "remove the gem at #{location}"
+ when :api
+ "checksums from #{location} cannot be locally modified, you may need to update your sources"
+ else
+ "remove #{location} (#{type})"
+ end
+ end
+ end
+
+ class Store
+ attr_reader :store
+ protected :store
+
+ def initialize
+ @store = {}
+ @store_mutex = Mutex.new
+ end
+
+ def inspect
+ "#<#{self.class}:#{object_id} size=#{store.size}>"
+ end
+
+ # Replace when the new checksum is from the same source.
+ # The primary purpose is registering checksums from gems where there are
+ # duplicates of the same gem (according to full_name) in the index.
+ #
+ # In particular, this is when 2 gems have two similar platforms, e.g.
+ # "darwin20" and "darwin-20", both of which resolve to darwin-20.
+ # In the Index, the later gem replaces the former, so we do that here.
+ #
+ # However, if the new checksum is from a different source, we register like normal.
+ # This ensures a mismatch error where there are multiple top level sources
+ # that contain the same gem with different checksums.
+ def replace(spec, checksum)
+ return unless checksum
+
+ lock_name = spec.lock_name
+ @store_mutex.synchronize do
+ existing = fetch_checksum(lock_name, checksum.algo)
+ if !existing || existing.same_source?(checksum)
+ store_checksum(lock_name, checksum)
+ else
+ merge_checksum(lock_name, checksum, existing)
+ end
+ end
+ end
+
+ def missing?(spec)
+ @store[spec.lock_name].nil?
+ end
+
+ def empty?(spec)
+ return false unless spec.source.is_a?(Bundler::Source::Rubygems)
+
+ @store[spec.lock_name].empty?
+ end
+
+ def register(spec, checksum)
+ register_checksum(spec.lock_name, checksum)
+ end
+
+ def merge!(other)
+ other.store.each do |lock_name, checksums|
+ checksums.each do |_algo, checksum|
+ register_checksum(lock_name, checksum)
+ end
+ end
+ end
+
+ def to_lock(spec)
+ lock_name = spec.lock_name
+ checksums = @store[lock_name]
+ if checksums&.any?
+ "#{lock_name} #{checksums.values.map(&:to_lock).sort.join(",")}"
+ else
+ lock_name
+ end
+ end
+
+ private
+
+ def register_checksum(lock_name, checksum)
+ @store_mutex.synchronize do
+ if checksum
+ existing = fetch_checksum(lock_name, checksum.algo)
+ if existing
+ merge_checksum(lock_name, checksum, existing)
+ else
+ store_checksum(lock_name, checksum)
+ end
+ else
+ init_checksum(lock_name)
+ end
+ end
+ end
+
+ def merge_checksum(lock_name, checksum, existing)
+ existing.merge!(checksum) || raise(ChecksumMismatchError.new(lock_name, existing, checksum))
+ end
+
+ def store_checksum(lock_name, checksum)
+ init_checksum(lock_name)[checksum.algo] = checksum
+ end
+
+ def init_checksum(lock_name)
+ @store[lock_name] ||= {}
+ end
+
+ def fetch_checksum(lock_name, algo)
+ @store[lock_name]&.fetch(algo, nil)
+ end
+ end
+ end
+end
diff --git a/lib/bundler/ci_detector.rb b/lib/bundler/ci_detector.rb
new file mode 100644
index 0000000000..e5fedbdea8
--- /dev/null
+++ b/lib/bundler/ci_detector.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module Bundler
+ module CIDetector
+ # NOTE: Any changes made here will need to be made to both lib/rubygems/ci_detector.rb and
+ # bundler/lib/bundler/ci_detector.rb (which are enforced duplicates).
+ # TODO: Drop that duplication once bundler drops support for RubyGems 3.4
+ #
+ # ## Recognized CI providers, their signifiers, and the relevant docs ##
+ #
+ # Travis CI - CI, TRAVIS https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
+ # Cirrus CI - CI, CIRRUS_CI https://cirrus-ci.org/guide/writing-tasks/#environment-variables
+ # Circle CI - CI, CIRCLECI https://circleci.com/docs/variables/#built-in-environment-variables
+ # Gitlab CI - CI, GITLAB_CI https://docs.gitlab.com/ee/ci/variables/
+ # AppVeyor - CI, APPVEYOR https://www.appveyor.com/docs/environment-variables/
+ # CodeShip - CI_NAME https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables#_default_environment_variables
+ # dsari - CI, DSARI https://github.com/rfinnie/dsari#running
+ # Jenkins - BUILD_NUMBER https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
+ # TeamCity - TEAMCITY_VERSION https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
+ # Appflow - CI_BUILD_ID https://ionic.io/docs/appflow/automation/environments#predefined-environments
+ # TaskCluster - TASKCLUSTER_ROOT_URL https://docs.taskcluster.net/docs/manual/design/env-vars
+ # Semaphore - CI, SEMAPHORE https://docs.semaphoreci.com/ci-cd-environment/environment-variables/
+ # BuildKite - CI, BUILDKITE https://buildkite.com/docs/pipelines/environment-variables
+ # GoCD - GO_SERVER_URL https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html
+ # GH Actions - CI, GITHUB_ACTIONS https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
+ #
+ # ### Some "standard" ENVs that multiple providers may set ###
+ #
+ # * CI - this is set by _most_ (but not all) CI providers now; it's approaching a standard.
+ # * CI_NAME - Not as frequently used, but some providers set this to specify their own name
+
+ # Any of these being set is a reasonably reliable indicator that we are
+ # executing in a CI environment.
+ ENV_INDICATORS = [
+ "CI",
+ "CI_NAME",
+ "CONTINUOUS_INTEGRATION",
+ "BUILD_NUMBER",
+ "CI_APP_ID",
+ "CI_BUILD_ID",
+ "CI_BUILD_NUMBER",
+ "RUN_ID",
+ "TASKCLUSTER_ROOT_URL",
+ ].freeze
+
+ # For each CI, this env suffices to indicate that we're on _that_ CI's
+ # containers. (A few of them only supply a CI_NAME variable, which is also
+ # nice). And if they set "CI" but we can't tell which one they are, we also
+ # want to know that - a bare "ci" without another token tells us as much.
+ ENV_DESCRIPTORS = {
+ "TRAVIS" => "travis",
+ "CIRCLECI" => "circle",
+ "CIRRUS_CI" => "cirrus",
+ "DSARI" => "dsari",
+ "SEMAPHORE" => "semaphore",
+ "JENKINS_URL" => "jenkins",
+ "BUILDKITE" => "buildkite",
+ "GO_SERVER_URL" => "go",
+ "GITLAB_CI" => "gitlab",
+ "GITHUB_ACTIONS" => "github",
+ "TASKCLUSTER_ROOT_URL" => "taskcluster",
+ "CI" => "ci",
+ }.freeze
+
+ def self.ci?
+ ENV_INDICATORS.any? {|var| ENV.include?(var) }
+ end
+
+ def self.ci_strings
+ matching_names = ENV_DESCRIPTORS.select {|env, _| ENV[env] }.values
+ matching_names << ENV["CI_NAME"].downcase if ENV["CI_NAME"]
+ matching_names.reject(&:empty?).sort.uniq
+ end
+ end
+end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index dd91038d64..9d8a68fff9 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -5,12 +5,13 @@ require_relative "vendored_thor"
module Bundler
class CLI < Thor
require_relative "cli/common"
+ require_relative "cli/install"
package_name "Bundler"
AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
PARSEABLE_COMMANDS = %w[check config help exec platform show version].freeze
- EXTENSIONS = ["c", "rust"].freeze
+ EXTENSIONS = ["c", "rust", "go"].freeze
COMMAND_ALIASES = {
"check" => "c",
@@ -23,7 +24,7 @@ module Bundler
}.freeze
def self.start(*)
- check_deprecated_ext_option(ARGV) if ARGV.include?("--ext")
+ check_invalid_ext_option(ARGV) if ARGV.include?("--ext")
super
ensure
@@ -58,32 +59,44 @@ module Bundler
def initialize(*args)
super
- custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
- if custom_gemfile && !custom_gemfile.empty?
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile)
- Bundler.reset_settings_and_root!
+ current_cmd = args.last[:current_command].name
+
+ # `bundle config` manages stored settings, so avoid promoting settings
+ # like `gemfile` or `lockfile` to environment variables before it runs.
+ unless current_cmd == "config"
+ Bundler.configure_custom_gemfile(options[:gemfile])
+
+ # lock --lockfile works differently than install --lockfile
+ unless current_cmd == "lock"
+ custom_lockfile = options[:lockfile] || ENV["BUNDLE_LOCKFILE"] || Bundler.settings[:lockfile]
+ if custom_lockfile && !custom_lockfile.empty?
+ Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", File.expand_path(custom_lockfile)
+ reset_settings = true
+ end
+ end
end
- Bundler.self_manager.restart_with_locked_bundler_if_needed
+ Bundler.reset_settings_and_root! if reset_settings
+
+ Bundler.auto_switch
Bundler.settings.set_command_option_if_given :retry, options[:retry]
- current_cmd = args.last[:current_command].name
- auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
+ Bundler.auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
rescue UnknownArgumentError => e
raise InvalidOption, e.message
ensure
self.options ||= {}
unprinted_warnings = Bundler.ui.unprinted_warnings
Bundler.ui = UI::Shell.new(options)
- Bundler.ui.level = "debug" if options["verbose"]
+ Bundler.ui.level = "debug" if options[:verbose] || Bundler.settings[:verbose]
unprinted_warnings.each {|w| Bundler.ui.warn(w) }
end
- check_unknown_options!(:except => [:config, :exec])
+ check_unknown_options!(except: [:config, :exec])
stop_on_unknown_option! :exec
- desc "cli_help", "Prints a summary of bundler commands", :hide => true
+ desc "cli_help", "Prints a summary of bundler commands", hide: true
def cli_help
version
Bundler.ui.info "\n"
@@ -91,7 +104,7 @@ module Bundler
primary_commands = ["install", "update", "cache", "exec", "config", "help"]
list = self.class.printable_commands(true)
- by_name = list.group_by {|name, _message| name.match(/^bundle (\w+)/)[1] }
+ by_name = list.group_by {|name, _message| name.match(/^bundler? (\w+)/)[1] }
utilities = by_name.keys.sort - primary_commands
primary_commands.map! {|name| (by_name[name] || raise("no primary command #{name}")).first }
utilities.map! {|name| by_name[name].first }
@@ -99,21 +112,53 @@ module Bundler
shell.say "Bundler commands:\n\n"
shell.say " Primary commands:\n"
- shell.print_table(primary_commands, :indent => 4, :truncate => true)
+ shell.print_table(primary_commands, indent: 4, truncate: true)
shell.say
shell.say " Utilities:\n"
- shell.print_table(utilities, :indent => 4, :truncate => true)
+ shell.print_table(utilities, indent: 4, truncate: true)
shell.say
self.class.send(:class_options_help, shell)
end
- default_task(Bundler.feature_flag.default_cli_command)
- class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
- class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
- :desc => "Specify the number of times you wish to attempt network commands"
- class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
+ desc "install_or_cli_help", "Deprecated alias of install", hide: true
+ def install_or_cli_help
+ Bundler.ui.warn <<~MSG
+ `bundle install_or_cli_help` is a deprecated alias of `bundle install`.
+ It might be called due to the 'default_cli_command' being set to 'install_or_cli_help',
+ if so fix that by running `bundle config set default_cli_command install --global`.
+ MSG
+ invoke_other_command("install")
+ end
+
+ def self.default_command(meth = nil)
+ return super if meth
+
+ unless Bundler.settings[:default_cli_command]
+ Bundler.ui.info <<~MSG
+ In a future version of Bundler, running `bundle` without argument will no longer run `bundle install`.
+ Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
+ You can use the future behavior now with `bundle config set default_cli_command cli_help --global`,
+ or you can continue to use the current behavior with `bundle config set default_cli_command install --global`.
+ This message will be removed after a default_cli_command value is set.
+
+ MSG
+ end
+
+ Bundler.settings[:default_cli_command] || "install"
+ end
+
+ class_option "no-color", type: :boolean, desc: "Disable colorization in output"
+ class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
+ desc: "Specify the number of times you wish to attempt network commands"
+ class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
def help(cli = nil)
+ cli = self.class.all_aliases[cli] if self.class.all_aliases[cli]
+
+ if Bundler.settings[:plugins] && Bundler::Plugin.command?(cli) && !self.class.all_commands.key?(cli)
+ return Bundler::Plugin.exec_command(cli, ["--help"])
+ end
+
case cli
when "gemfile" then command = "gemfile"
when nil then command = "bundle"
@@ -127,8 +172,8 @@ module Bundler
if man_pages.include?(command)
man_page = man_pages[command]
- if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
- Kernel.exec "man #{man_page}"
+ if Bundler.which("man") && !man_path.match?(%r{^(?:file:/.+!|uri:classloader:)/META-INF/jruby.home/.+})
+ Kernel.exec("man", man_page)
else
puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
end
@@ -140,7 +185,7 @@ module Bundler
end
def self.handle_no_command_error(command, has_namespace = $thor_runner)
- if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
+ if Bundler.settings[:plugins] && Bundler::Plugin.command?(command)
return Bundler::Plugin.exec_command(command, ARGV[1..-1])
end
@@ -155,8 +200,8 @@ module Bundler
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
dependency listed in the gemspec file to the newly created Gemfile.
D
- method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
- method_option "gemfile", :type => :string, :banner => "Use the specified name for the gemfile instead of 'Gemfile'"
+ method_option "gemspec", type: :string, banner: "Use the specified .gemspec to create the Gemfile"
+ method_option "gemfile", type: :string, banner: "Use the specified name for the gemfile instead of 'Gemfile'"
def init
require_relative "cli/init"
Init.new(options.dup).run
@@ -168,12 +213,9 @@ module Bundler
all gems are found, Bundler prints a success message and exits with a status of 0.
If not, the first missing gem is listed and Bundler exits status 1.
D
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Lock the Gemfile"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
+ method_option "dry-run", type: :boolean, default: false, banner: "Lock the Gemfile"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)"
def check
remembered_flag_deprecation("path")
@@ -187,10 +229,13 @@ module Bundler
long_desc <<-D
Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
D
- method_option "install", :type => :boolean, :banner =>
- "Runs 'bundle install' after removing the gems from the Gemfile"
+ method_option "install", type: :boolean, banner: "Runs 'bundle install' after removing the gems from the Gemfile (removed)"
def remove(*gems)
- SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
+ if ARGV.include?("--install")
+ removed_message = "The `--install` flag has been removed. `bundle install` is triggered by default."
+ raise InvalidOption, removed_message
+ end
+
require_relative "cli/remove"
Remove.new(gems, options).run
end
@@ -206,60 +251,53 @@ module Bundler
If the bundle has already been installed, bundler will tell you so and then exit.
D
- method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
- "Generate bin stubs for bundled gems to ./bin"
- method_option "clean", :type => :boolean, :banner =>
- "Run bundle clean automatically after install"
- method_option "deployment", :type => :boolean, :banner =>
- "Install using defaults tuned for deployment environments"
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this install"
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "prefer-local", :type => :boolean, :banner =>
- "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
- method_option "no-cache", :type => :boolean, :banner =>
- "Don't update the existing gem cache."
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "no-prune", :type => :boolean, :banner =>
- "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :array, :lazy_default => [], :banner =>
- "Make a bundle that can work without the Bundler runtime"
- method_option "system", :type => :boolean, :banner =>
- "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
- method_option "trust-policy", :alias => "P", :type => :string, :banner =>
- "Gem trust policy (like gem install -P). Must be one of " +
- Bundler.rubygems.security_policy_keys.join("|")
- method_option "without", :type => :array, :banner =>
- "Exclude gems that are part of the specified named group."
- method_option "with", :type => :array, :banner =>
- "Include gems that are part of the specified named group."
+ method_option "binstubs", type: :string, lazy_default: "bin", banner: "Generate bin stubs for bundled gems to ./bin (removed)"
+ method_option "clean", type: :boolean, banner: "Run bundle clean automatically after install (removed)"
+ method_option "deployment", type: :boolean, banner: "Install using defaults tuned for deployment environments (removed)"
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this install (removed)"
+ method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "lockfile", type: :string, banner: "Use the specified lockfile instead of the default."
+ method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
+ method_option "no-cache", type: :boolean, banner: "Don't update the existing gem cache."
+ method_option "no-lock", type: :boolean, banner: "Don't create a lockfile."
+ method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default, usually 'ruby' (removed)"
+ method_option "standalone", type: :array, lazy_default: [], banner: "Make a bundle that can work without the Bundler runtime"
+ method_option "system", type: :boolean, banner: "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application (removed)"
+ method_option "trust-policy", alias: "P", type: :string, banner: "Gem trust policy (like gem install -P). Must be one of #{Bundler.rubygems.security_policy_keys.join("|")}"
+ method_option "target-rbconfig", type: :string, banner: "Path to rbconfig.rb for the deployment target platform"
+ method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group (removed)."
+ method_option "with", type: :array, banner: "Include gems that are part of the specified named group (removed)."
+ method_option "cooldown", type: :numeric, banner: "Only consider gem versions published at least N days ago. Use 0 to disable."
def install
- SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
-
- %w[clean deployment frozen no-prune path shebang system without with].each do |option|
+ %w[clean deployment frozen no-prune path shebang without with].each do |option|
remembered_flag_deprecation(option)
end
- remembered_negative_flag_deprecation("no-deployment")
+ print_remembered_flag_deprecation("--system", "path.system", "true") if ARGV.include?("--system")
+
+ remembered_flag_deprecation("deployment", negative: true)
+
+ if ARGV.include?("--binstubs")
+ removed_message = "The --binstubs option has been removed in favor of `bundle binstubs --all`"
+ raise InvalidOption, removed_message
+ end
require_relative "cli/install"
- Bundler.settings.temporary(:no_install => false) do
- Install.new(options.dup).run
+ options = self.options.dup
+ options["lockfile"] ||= ENV["BUNDLE_LOCKFILE"]
+ Bundler.settings.temporary(no_install: false) do
+ Install.new(options).run
end
+ rescue GemfileNotFound => error
+ invoke_other_command("cli_help")
+ raise error # re-raise to show the error and get a failing exit status
end
map aliases_for("install")
@@ -270,44 +308,27 @@ module Bundler
update when you have changed the Gemfile, or if you want to get the newest
possible versions of the gems in the bundle.
D
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "group", :aliases => "-g", :type => :array, :banner =>
- "Update a specific group"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "source", :type => :array, :banner =>
- "Update a specific source (and all gems associated with it)"
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "ruby", :type => :boolean, :banner =>
- "Update ruby specified in Gemfile.lock"
- method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
- "Update the locked version of bundler"
- method_option "patch", :type => :boolean, :banner =>
- "Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "Prefer updating to next major version (default)"
- method_option "pre", :type => :boolean, :banner =>
- "Always choose the highest allowed version when updating gems, regardless of prerelease status"
- method_option "strict", :type => :boolean, :banner =>
- "Do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
- method_option "all", :type => :boolean, :banner =>
- "Update everything."
+ method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "group", aliases: "-g", type: :array, banner: "Update a specific group"
+ method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
+ method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
+ method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
+ method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
+ method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
+ method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
+ method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
+ method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
+ method_option "all", type: :boolean, banner: "Update everything."
+ method_option "cooldown", type: :numeric, banner: "Only consider gem versions published at least N days ago. Use 0 to disable."
def update(*gems)
- SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require_relative "cli/update"
- Bundler.settings.temporary(:no_install => false) do
+ Bundler.settings.temporary(no_install: false) do
Update.new(options, gems).run
end
end
@@ -317,21 +338,23 @@ module Bundler
Show lists the names and versions of all gems that are required by your Gemfile.
Calling show with [GEM] will list the exact location of that gem on your machine.
D
- method_option "paths", :type => :boolean,
- :banner => "List the paths of all gems that are required by your Gemfile."
- method_option "outdated", :type => :boolean,
- :banner => "Show verbose output including whether gems are outdated."
+ method_option "paths", type: :boolean, banner: "List the paths of all gems that are required by your Gemfile."
+ method_option "outdated", type: :boolean, banner: "Show verbose output including whether gems are outdated (removed)."
def show(gem_name = nil)
- SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated")
+ if ARGV.include?("--outdated")
+ removed_message = "the `--outdated` flag to `bundle show` has been removed in favor of `bundle show --verbose`"
+ raise InvalidOption, removed_message
+ end
require_relative "cli/show"
Show.new(options, gem_name).run
end
desc "list", "List all gems in the bundle"
- method_option "name-only", :type => :boolean, :banner => "print only the gem names"
- method_option "only-group", :type => :array, :default => [], :banner => "print gems from a given set of groups"
- method_option "without-group", :type => :array, :default => [], :banner => "print all gems except from a given set of groups"
- method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
+ method_option "name-only", type: :boolean, banner: "print only the gem names"
+ method_option "only-group", type: :array, default: [], banner: "print gems from a given set of groups"
+ method_option "without-group", type: :array, default: [], banner: "print all gems except from a given set of groups"
+ method_option "format", type: :string, banner: "format output ('json' is the only supported format)"
+ method_option "paths", type: :boolean, banner: "print the path to each gem in the bundle"
def list
require_relative "cli/list"
List.new(options).run
@@ -340,8 +363,8 @@ module Bundler
map aliases_for("list")
desc "info GEM [OPTIONS]", "Show information for the given gem"
- method_option "path", :type => :boolean, :banner => "Print full path to gem"
- method_option "version", :type => :boolean, :banner => "Print gem version"
+ method_option "path", type: :boolean, banner: "Print full path to gem"
+ method_option "version", type: :boolean, banner: "Print gem version"
def info(gem_name)
require_relative "cli/info"
Info.new(options, gem_name).run
@@ -353,19 +376,15 @@ module Bundler
or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
will create binstubs for all given gems.
D
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Overwrite existing binstubs if they exist"
- method_option "path", :type => :string, :lazy_default => "bin", :banner =>
- "Binstub destination directory (default bin)"
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :boolean, :banner =>
- "Make binstubs that can work without the Bundler runtime"
- method_option "all", :type => :boolean, :banner =>
- "Install binstubs for all gems"
- method_option "all-platforms", :type => :boolean, :default => false, :banner =>
- "Install binstubs for all platforms"
+ method_option "force", type: :boolean, default: false, banner: "Overwrite existing binstubs if they exist"
+ method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory, `bin` by default (removed)"
+ method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
+ method_option "standalone", type: :boolean, banner: "Make binstubs that can work without the Bundler runtime"
+ method_option "all", type: :boolean, banner: "Install binstubs for all gems"
+ method_option "all-platforms", type: :boolean, default: false, banner: "Install binstubs for all platforms"
def binstubs(*gems)
+ remembered_flag_deprecation("path", option_name: "bin")
+
require_relative "cli/binstubs"
Binstubs.new(options, gems).run
end
@@ -374,19 +393,22 @@ module Bundler
long_desc <<-D
Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
D
- method_option "version", :aliases => "-v", :type => :string
- method_option "group", :aliases => "-g", :type => :string
- method_option "source", :aliases => "-s", :type => :string
- method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
- method_option "path", :type => :string
- method_option "git", :type => :string
- method_option "github", :type => :string
- method_option "branch", :type => :string
- method_option "ref", :type => :string
- method_option "skip-install", :type => :boolean, :banner =>
- "Adds gem to the Gemfile but does not install it"
- method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
- method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
+ method_option "version", aliases: "-v", type: :string
+ method_option "group", aliases: "-g", type: :string
+ method_option "source", aliases: "-s", type: :string
+ method_option "require", aliases: "-r", type: :string, banner: "Adds require path to gem. Provide false, or a path as a string."
+ method_option "path", type: :string
+ method_option "git", type: :string
+ method_option "github", type: :string
+ method_option "branch", type: :string
+ method_option "ref", type: :string
+ method_option "glob", type: :string, banner: "The location of a dependency's .gemspec, expanded within Ruby (single quotes recommended)"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it"
+ method_option "optimistic", type: :boolean, banner: "Ignored (now default behavior)"
+ method_option "pessimistic", type: :boolean, banner: "Adds pessimistic declaration of version to gem"
+ method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem"
+ method_option "cooldown", type: :numeric, banner: "Only consider gem versions published at least N days ago. Use 0 to disable."
def add(*gems)
require_relative "cli/add"
Add.new(options.dup, gems).run
@@ -402,54 +424,44 @@ module Bundler
For more information on patch level options (--major, --minor, --patch,
--strict) see documentation on the same options on the update command.
D
- method_option "group", :type => :string, :banner => "List gems from a specific group"
- method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
- method_option "source", :type => :array, :banner => "Check against a specific source"
- method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
- "Only list newer versions allowed by your Gemfile requirements"
- method_option "update-strict", :type => :boolean, :banner =>
- "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
- method_option "patch", :type => :boolean, :banner => "Prefer updating only to next patch version"
- method_option "filter-major", :type => :boolean, :banner => "Only list major newer versions"
- method_option "filter-minor", :type => :boolean, :banner => "Only list minor newer versions"
- method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
- method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
- "Use minimal formatting for more parseable output"
- method_option "only-explicit", :type => :boolean, :banner =>
- "Only list gems specified in your Gemfile, not their dependencies"
+ method_option "group", type: :string, banner: "List gems from a specific group"
+ method_option "groups", type: :boolean, banner: "List gems organized by groups"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "pre", type: :boolean, banner: "Check for newer pre-release gems"
+ method_option "source", type: :array, banner: "Check against a specific source"
+ method_option "filter-strict", type: :boolean, aliases: "--strict", banner: "Only list newer versions allowed by your Gemfile requirements"
+ method_option "update-strict", type: :boolean, banner: "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
+ method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
+ method_option "filter-major", type: :boolean, banner: "Only list major newer versions"
+ method_option "filter-minor", type: :boolean, banner: "Only list minor newer versions"
+ method_option "filter-patch", type: :boolean, banner: "Only list patch newer versions"
+ method_option "parseable", aliases: "--porcelain", type: :boolean, banner: "Use minimal formatting for more parseable output"
+ method_option "only-explicit", type: :boolean, banner: "Only list gems specified in your Gemfile, not their dependencies"
+ method_option "cooldown", type: :numeric, banner: "Only consider gem versions published at least N days ago. Use 0 to disable."
def outdated(*gems)
require_relative "cli/outdated"
Outdated.new(options, gems).run
end
desc "fund [OPTIONS]", "Lists information about gems seeking funding assistance"
- method_option "group", :aliases => "-g", :type => :array, :banner =>
- "Fetch funding information for a specific group"
+ method_option "group", aliases: "-g", type: :array, banner: "Fetch funding information for a specific group"
def fund
require_relative "cli/fund"
Fund.new(options).run
end
desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
- method_option "all", :type => :boolean,
- :default => Bundler.feature_flag.cache_all?,
- :banner => "Include all sources (including path and git)."
- method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
- method_option "cache-path", :type => :string, :banner =>
- "Specify a different cache path than the default (vendor/cache)."
- method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
- method_option "no-install", :type => :boolean, :banner => "Don't install the gems, only update the cache."
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
+ method_option "all", type: :boolean, default: Bundler.settings[:cache_all], banner: "Include all sources (including path and git) (removed)."
+ method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
+ method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install (removed)"
long_desc <<-D
The cache command will copy the .gem files for every gem in the bundle into the
directory ./vendor/cache. If you then check that directory into your source
@@ -457,17 +469,21 @@ module Bundler
bundle without having to download any additional gems.
D
def cache
- SharedHelpers.major_deprecation 2,
- "The `--all` flag is deprecated because it relies on being " \
- "remembered across bundler invocations, which bundler will no longer " \
- "do in future versions. Instead please use `bundle config set cache_all true`, " \
- "and stop using this flag" if ARGV.include?("--all")
-
- SharedHelpers.major_deprecation 2,
- "The `--path` flag is deprecated because its semantics are unclear. " \
- "Use `bundle config cache_path` to configure the path of your cache of gems, " \
- "and `bundle config path` to configure the path where your gems are installed, " \
- "and stop using this flag" if ARGV.include?("--path")
+ print_remembered_flag_deprecation("--all", "cache_all", "true") if ARGV.include?("--all")
+ print_remembered_flag_deprecation("--no-all", "cache_all", "false") if ARGV.include?("--no-all")
+
+ %w[frozen no-prune].each do |option|
+ remembered_flag_deprecation(option)
+ end
+
+ if flag_passed?("--path")
+ removed_message =
+ "The `--path` flag has been removed because its semantics were unclear. " \
+ "Use `bundle config cache_path` to configure the path of your cache of gems, " \
+ "and `bundle config path` to configure the path where your gems are installed, " \
+ "and stop using this flag"
+ raise InvalidOption, removed_message
+ end
require_relative "cli/cache"
Cache.new(options).run
@@ -476,8 +492,8 @@ module Bundler
map aliases_for("cache")
desc "exec [OPTIONS]", "Run the command in context of the bundle"
- method_option :keep_file_descriptors, :type => :boolean, :default => true
- method_option :gemfile, :type => :string, :required => false
+ method_option :keep_file_descriptors, type: :boolean, default: true, banner: "Passes all file descriptors to the new processes. Default is true, and setting it to false is not permitted (removed)."
+ method_option :gemfile, type: :string, required: false, banner: "Use the specified gemfile instead of Gemfile"
long_desc <<-D
Exec runs a command, providing it access to the gems in the bundle. While using
bundle exec you can require and call the bundled gems as if they were installed
@@ -485,7 +501,8 @@ module Bundler
D
def exec(*args)
if ARGV.include?("--no-keep-file-descriptors")
- SharedHelpers.major_deprecation(2, "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to")
+ removed_message = "The `--no-keep-file-descriptors` has been removed. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to"
+ raise InvalidOption, removed_message
end
require_relative "cli/exec"
@@ -510,31 +527,29 @@ module Bundler
subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem"
- method_option "path", :type => :string, :lazy_default => "", :banner => "Open relative path of the gem source."
+ method_option "path", type: :string, lazy_default: "", banner: "Open relative path of the gem source."
def open(name)
require_relative "cli/open"
Open.new(options, name).run
end
- unless Bundler.feature_flag.bundler_3_mode?
- desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
- def console(group = nil)
- require_relative "cli/console"
- Console.new(options, group).run
- end
+ desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
+ def console(group = nil)
+ require_relative "cli/console"
+ Console.new(options, group).run
end
desc "version", "Prints Bundler version information"
def version
cli_help = current_command.name == "cli_help"
if cli_help || ARGV.include?("version")
- build_info = " (#{BuildMetadata.built_at} commit #{BuildMetadata.git_commit_sha})"
+ build_info = " (#{BuildMetadata.timestamp} commit #{BuildMetadata.git_commit_sha})"
end
- if !cli_help && Bundler.feature_flag.print_only_version_number?
- Bundler.ui.info "#{Bundler::VERSION}#{build_info}"
+ if !cli_help
+ Bundler.ui.info "#{Bundler.verbose_version}#{build_info}"
else
- Bundler.ui.info "Bundler version #{Bundler::VERSION}#{build_info}"
+ Bundler.ui.info "Bundler version #{Bundler.verbose_version}#{build_info}"
end
end
@@ -554,135 +569,80 @@ module Bundler
end
end
- unless Bundler.feature_flag.bundler_3_mode?
- desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
- long_desc <<-D
- Viz generates a PNG file of the current Gemfile as a dependency graph.
- Viz requires the ruby-graphviz gem (and its dependencies).
- The associated gems must also be installed via 'bundle install'.
- D
- method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
- method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
- method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
- method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
- method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
- def viz
- SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
- require_relative "cli/viz"
- Viz.new(options.dup).run
- end
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", hide: true
+ def viz
+ SharedHelpers.feature_removed! "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
end
- old_gem = instance_method(:gem)
-
desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
- method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
- method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
- method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
- :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
- :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
- method_option :ext, :type => :string, :desc => "Generate the boilerplate for C extension code.", :enum => EXTENSIONS
- method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
- method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
- method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
- method_option :changelog, :type => :boolean, :desc => "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
- method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
- :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
- method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
- :desc => "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
- method_option :linter, :type => :string, :lazy_default => Bundler.settings["gem.linter"] || "",
- :desc => "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
- method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
+ method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], banner: "Generate a binary executable for your library."
+ method_option :coc, type: :boolean, banner: "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
+ method_option :edit, type: :string, aliases: "-e", required: false, lazy_default: [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }, banner: "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
+ method_option :ext, type: :string, banner: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
+ method_option :git, type: :boolean, default: true, banner: "Initialize a git repo inside your library."
+ method_option :mit, type: :boolean, banner: "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
+ method_option :rubocop, type: :boolean, banner: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true` (removed)."
+ method_option :changelog, type: :boolean, banner: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
+ method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library", enum: %w[rspec minitest test-unit], desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
+ method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "", enum: %w[github gitlab circle], banner: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
+ method_option :linter, type: :string, lazy_default: Bundler.settings["gem.linter"] || "", enum: %w[rubocop standard], banner: "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
+ method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
+ method_option :bundle, type: :boolean, default: Bundler.settings["gem.bundle"], banner: "Automatically run `bundle install` after creation. Set a default with `bundle config set --global gem.bundle true`"
def gem(name)
- end
-
- commands["gem"].tap do |gem_command|
- def gem_command.run(instance, args = [])
- arity = 1 # name
+ require_relative "cli/gem"
- require_relative "cli/gem"
- cmd_args = args + [instance]
- cmd_args.unshift(instance.options)
+ raise InvalidOption, "--rubocop has been removed, use --linter=rubocop" if ARGV.include?("--rubocop")
+ raise InvalidOption, "--no-rubocop has been removed, use --no-linter" if ARGV.include?("--no-rubocop")
- cmd = begin
- Gem.new(*cmd_args)
- rescue ArgumentError => e
- instance.class.handle_argument_error(self, e, args, arity)
- end
+ cmd_args = args + [self]
+ cmd_args.unshift(options)
- cmd.run
- end
+ Gem.new(*cmd_args).run
end
- undef_method(:gem)
- define_method(:gem, old_gem)
- private :gem
-
def self.source_root
File.expand_path("templates", __dir__)
end
- desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Only print out changes, do not clean gems"
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
+ desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory"
+ method_option "dry-run", type: :boolean, default: false, banner: "Only print out changes, do not clean gems"
+ method_option "force", type: :boolean, default: false, banner: "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
def clean
require_relative "cli/clean"
Clean.new(options.dup).run
end
desc "platform [OPTIONS]", "Displays platform compatibility information"
- method_option "ruby", :type => :boolean, :default => false, :banner =>
- "only display ruby related platform information"
+ method_option "ruby", type: :boolean, default: false, banner: "only display ruby related platform information"
def platform
require_relative "cli/platform"
Platform.new(options).run
end
- desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", :hide => true
- method_option "source", :type => :string, :banner =>
- "Install gem from the given source"
- method_option "group", :type => :string, :banner =>
- "Install gem into a bundler group"
- def inject(name, version)
- SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
- require_relative "cli/inject"
- Inject.new(options.dup, name, version).run
+ desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
+ def inject(*)
+ SharedHelpers.feature_removed! "The `inject` command has been replaced by the `add` command"
end
desc "lock", "Creates a lockfile without installing"
- method_option "update", :type => :array, :lazy_default => true, :banner =>
- "ignore the existing lockfile, update all gems by default, or update list of given gems"
- method_option "local", :type => :boolean, :default => false, :banner =>
- "do not attempt to fetch remote gemspecs and use the local gem cache only"
- method_option "print", :type => :boolean, :default => false, :banner =>
- "print the lockfile to STDOUT instead of writing to the file system"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "lockfile", :type => :string, :default => nil, :banner =>
- "the path the lockfile should be written to"
- method_option "full-index", :type => :boolean, :default => false, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "add-platform", :type => :array, :default => [], :banner =>
- "Add a new platform to the lockfile"
- method_option "remove-platform", :type => :array, :default => [], :banner =>
- "Remove a platform from the lockfile"
- method_option "patch", :type => :boolean, :banner =>
- "If updating, prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "If updating, prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "If updating, prefer updating to next major version (default)"
- method_option "pre", :type => :boolean, :banner =>
- "If updating, always choose the highest allowed version, regardless of prerelease status"
- method_option "strict", :type => :boolean, :banner =>
- "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
- method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
- "Update the locked version of bundler"
+ method_option "update", type: :array, lazy_default: true, banner: "ignore the existing lockfile, update all gems by default, or update list of given gems"
+ method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
+ method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "lockfile", type: :string, default: nil, banner: "the path the lockfile should be written to"
+ method_option "full-index", type: :boolean, default: false, banner: "Fall back to using the single-file index of all gems"
+ method_option "add-checksums", type: :boolean, default: false, banner: "Adds checksums to the lockfile"
+ method_option "add-platform", type: :array, default: [], banner: "Add a new platform to the lockfile"
+ method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
+ method_option "normalize-platforms", type: :boolean, default: false, banner: "Normalize lockfile platforms"
+ method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
+ method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
+ method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
+ method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
+ method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
def lock
require_relative "cli/lock"
Lock.new(options).run
@@ -694,19 +654,8 @@ module Bundler
end
desc "doctor [OPTIONS]", "Checks the bundle for common problems"
- long_desc <<-D
- Doctor scans the OS dependencies of each of the gems requested in the Gemfile. If
- missing dependencies are detected, Bundler prints them and exits status 1.
- Otherwise, Bundler prints a success message and exits with a status of 0.
- D
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- def doctor
- require_relative "cli/doctor"
- Doctor.new(options).run
- end
+ require_relative "cli/doctor"
+ subcommand("doctor", Doctor)
desc "issue", "Learn how to report an issue in Bundler"
def issue
@@ -722,10 +671,12 @@ module Bundler
D
def pristine(*gems)
require_relative "cli/pristine"
- Pristine.new(gems).run
+ Bundler.settings.temporary(no_install: false) do
+ Pristine.new(gems).run
+ end
end
- if Bundler.feature_flag.plugins?
+ if Bundler.settings[:plugins]
require_relative "cli/plugin"
desc "plugin", "Manage the bundler plugins"
subcommand "plugin", Plugin
@@ -743,7 +694,6 @@ module Bundler
exec_used = args.index {|a| exec_commands.include? a }
command = args.find {|a| bundler_commands.include? a }
- command = all_aliases[command] if all_aliases[command]
if exec_used && help_used
if exec_used + help_used == 1
@@ -760,16 +710,15 @@ module Bundler
end
end
- def self.check_deprecated_ext_option(arguments)
- # when deprecated version of `--ext` is called
- # print out deprecation warning and pretend `--ext=c` was provided
- if deprecated_ext_value?(arguments)
- SharedHelpers.major_deprecation 2, "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used."
- arguments[arguments.index("--ext")] = "--ext=c"
+ def self.check_invalid_ext_option(arguments)
+ # when invalid version of `--ext` is called
+ if invalid_ext_value?(arguments)
+ removed_message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension."
+ raise InvalidOption, removed_message
end
end
- def self.deprecated_ext_value?(arguments)
+ def self.invalid_ext_value?(arguments)
index = arguments.index("--ext")
next_argument = arguments[index + 1]
@@ -777,15 +726,15 @@ module Bundler
# for example `bundle gem hello --ext c`
return false if EXTENSIONS.include?(next_argument)
- # deprecated call when --ext is called with no value in last position
+ # invalid call when --ext is called with no value in last position
# for example `bundle gem hello_gem --ext`
return true if next_argument.nil?
- # deprecated call when --ext is followed by other parameter
+ # invalid call when --ext is followed by other parameter
# for example `bundle gem --ext --no-ci hello_gem`
return true if next_argument.start_with?("-")
- # deprecated call when --ext is followed by gem name
+ # invalid call when --ext is followed by gem name
# for example `bundle gem --ext hello_gem`
return true if next_argument
@@ -794,31 +743,24 @@ module Bundler
private
- # Automatically invoke `bundle install` and resume if
- # Bundler.settings[:auto_install] exists. This is set through config cmd
- # `bundle config set --global auto_install 1`.
- #
- # Note that this method `nil`s out the global Definition object, so it
- # should be called first, before you instantiate anything like an
- # `Installer` that'll keep a reference to the old one instead.
- def auto_install
- return unless Bundler.settings[:auto_install]
-
- begin
- Bundler.definition.specs
- rescue GemNotFound
- Bundler.ui.info "Automatically installing missing gems."
- Bundler.reset!
- invoke :install, []
- Bundler.reset!
- end
- end
-
def current_command
_, _, config = @_initializer
config[:current_command]
end
+ def invoke_other_command(name)
+ _, _, config = @_initializer
+ original_command = config[:current_command]
+ command = self.class.all_commands[name]
+ config[:current_command] = command
+ send(name)
+ ensure
+ config[:current_command] = original_command
+ end
+
+ def current_command=(command)
+ end
+
def print_command
return unless Bundler.ui.debug?
cmd = current_command
@@ -832,7 +774,7 @@ module Bundler
end
command << Thor::Options.to_switches(options_to_print.sort_by(&:first)).strip
command.reject!(&:empty?)
- Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
+ Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler.verbose_version}"
end
def warn_on_outdated_bundler
@@ -843,13 +785,10 @@ module Bundler
return unless SharedHelpers.md5_available?
- latest = Fetcher::CompactIndex.
- new(nil, Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")), nil).
- send(:compact_index_client).
- instance_variable_get(:@cache).
- dependencies("bundler").
- map {|d| Gem::Version.new(d.first) }.
- max
+ require_relative "vendored_uri"
+ remote = Source::Rubygems::Remote.new(Gem::URI("https://rubygems.org"))
+ cache_path = Bundler.user_cache.join("compact_index", remote.cache_slug)
+ latest = Bundler::CompactIndexClient.new(cache_path).latest_version("bundler")
return unless latest
current = Gem::Version.new(VERSION)
@@ -862,33 +801,30 @@ module Bundler
nil
end
- def remembered_negative_flag_deprecation(name)
- positive_name = name.gsub(/\Ano-/, "")
- option = current_command.options[positive_name]
- flag_name = "--no-" + option.switch_name.gsub(/\A--/, "")
-
- flag_deprecation(positive_name, flag_name, option)
- end
-
- def remembered_flag_deprecation(name)
+ def remembered_flag_deprecation(name, negative: false, option_name: nil)
option = current_command.options[name]
flag_name = option.switch_name
-
- flag_deprecation(name, flag_name, option)
- end
-
- def flag_deprecation(name, flag_name, option)
- name_index = ARGV.find {|arg| flag_name == arg.split("=")[0] }
- return unless name_index
+ flag_name = "--no-" + flag_name.gsub(/\A--/, "") if negative
+ return unless flag_passed?(flag_name)
value = options[name]
value = value.join(" ").to_s if option.type == :array
+ value = "'#{value}'" unless option.type == :boolean
+
+ print_remembered_flag_deprecation(flag_name, option_name || name.tr("-", "_"), value)
+ end
+
+ def print_remembered_flag_deprecation(flag_name, option_name, option_value)
+ removed_message =
+ "The `#{flag_name}` flag has been removed because it relied on being " \
+ "remembered across bundler invocations, which bundler no longer does. " \
+ "Instead please use `bundle config set #{option_name} #{option_value}`, " \
+ "and stop using this flag"
+ raise InvalidOption, removed_message
+ end
- Bundler::SharedHelpers.major_deprecation 2,
- "The `#{flag_name}` flag is deprecated because it relies on being " \
- "remembered across bundler invocations, which bundler will no longer " \
- "do in future versions. Instead please use `bundle config set --local #{name.tr("-", "_")} " \
- "'#{value}'`, and stop using this flag"
+ def flag_passed?(name)
+ ARGV.any? {|arg| name == arg.split("=")[0] }
end
end
end
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb
index 08fa6547fb..20f76b59d1 100644
--- a/lib/bundler/cli/add.rb
+++ b/lib/bundler/cli/add.rb
@@ -12,6 +12,11 @@ module Bundler
end
def run
+ Bundler.ui.level = "warn" if options[:quiet]
+
+ Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
+ Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
+
validate_options!
inject_dependencies
perform_bundle_install unless options["skip-install"]
@@ -28,13 +33,23 @@ module Bundler
dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
Injector.inject(dependencies,
- :conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
- :optimistic => options[:optimistic],
- :strict => options[:strict])
+ conservative_versioning: options[:version].nil?, # Perform conservative versioning only when version is not specified
+ pessimistic: options[:pessimistic],
+ strict: options[:strict])
end
def validate_options!
- raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
+ raise InvalidOption, "You cannot specify `--git` and `--github` at the same time." if options["git"] && options["github"]
+
+ unless options["git"] || options["github"]
+ raise InvalidOption, "You cannot specify `--branch` unless `--git` or `--github` is specified." if options["branch"]
+
+ raise InvalidOption, "You cannot specify `--ref` unless `--git` or `--github` is specified." if options["ref"]
+ end
+
+ raise InvalidOption, "You cannot specify `--branch` and `--ref` at the same time." if options["branch"] && options["ref"]
+
+ raise InvalidOption, "You cannot specify `--strict` and `--pessimistic` at the same time." if options[:strict] && options[:pessimistic]
# raise error when no gems are specified
raise InvalidOption, "Please specify gems to add." if gems.empty?
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index fc2fad47a5..8ce138df96 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -17,9 +17,9 @@ module Bundler
installer = Installer.new(Bundler.root, Bundler.definition)
installer_opts = {
- :force => options[:force],
- :binstubs_cmd => true,
- :all_platforms => options["all-platforms"],
+ force: options[:force],
+ binstubs_cmd: true,
+ all_platforms: options["all-platforms"],
}
if options[:all]
@@ -45,7 +45,7 @@ module Bundler
next
end
- Bundler.settings.temporary(:path => (Bundler.settings[:path] || Bundler.root)) do
+ Bundler.settings.temporary(path: Bundler.settings[:path] || Bundler.root) do
installer.generate_standalone_bundler_executable_stubs(spec, installer_opts)
end
else
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb
index c8698ed7e3..59605df847 100644
--- a/lib/bundler/cli/cache.rb
+++ b/lib/bundler/cli/cache.rb
@@ -10,17 +10,12 @@ module Bundler
def run
Bundler.ui.level = "warn" if options[:quiet]
- Bundler.settings.set_command_option_if_given :path, options[:path]
Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
- setup_cache_all
install
- # TODO: move cache contents here now that all bundles are locked
- custom_path = Bundler.settings[:path] if options[:path]
-
- Bundler.settings.temporary(:cache_all_platforms => options["all-platforms"]) do
- Bundler.load.cache(custom_path)
+ Bundler.settings.temporary(cache_all_platforms: options["all-platforms"]) do
+ Bundler.load.cache
end
end
@@ -33,11 +28,5 @@ module Bundler
options["no-cache"] = true
Bundler::CLI::Install.new(options).run
end
-
- def setup_cache_all
- all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)
-
- Bundler.settings.set_command_option_if_given :cache_all, all
- end
end
end
diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb
index cc1f37f0c3..493eb3ec6a 100644
--- a/lib/bundler/cli/check.rb
+++ b/lib/bundler/cli/check.rb
@@ -15,9 +15,9 @@ module Bundler
definition.validate_runtime!
begin
- definition.resolve_only_locally!
+ definition.check!
not_installed = definition.missing_specs
- rescue GemNotFound, SolveFailure
+ rescue GemNotFound, GitError, SolveFailure
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
Bundler.ui.warn "Install missing gems with `bundle install`."
exit 1
@@ -29,10 +29,10 @@ module Bundler
Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle?
- Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
+ Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present"
exit 1
else
- Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
+ definition.lock(true) unless options[:"dry-run"]
Bundler.ui.info "The Gemfile's dependencies are satisfied"
end
end
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index d654406f65..b44fbc3096 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -2,6 +2,12 @@
module Bundler
module CLI::Common
+ def self.validate_cooldown!(value)
+ return if value.nil?
+ return if value.is_a?(Integer) && value >= 0
+ raise InvalidOption, "Expected `--cooldown` to be a non-negative integer, got #{value.inspect}"
+ end
+
def self.output_post_install_messages(messages)
return if Bundler.settings["ignore_messages"]
messages.to_a.each do |name, msg|
@@ -54,9 +60,12 @@ module Bundler
Bundler.definition.specs.each do |spec|
return spec if spec.name == name
- specs << spec if regexp && spec.name =~ regexp
+ specs << spec if regexp && spec.name.match?(regexp)
end
+ default_spec = default_gem_spec(name)
+ specs << default_spec if default_spec
+
case specs.count
when 0
dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
@@ -75,6 +84,11 @@ module Bundler
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
end
+ def self.default_gem_spec(name)
+ gem_spec = Gem::Specification.find_all_by_name(name).last
+ gem_spec if gem_spec&.default_gem?
+ end
+
def self.ask_for_spec_from(specs)
specs.each_with_index do |spec, index|
Bundler.ui.info "#{index.succ} : #{spec.name}", true
@@ -86,11 +100,14 @@ module Bundler
end
def self.gem_not_found_message(missing_gem_name, alternatives)
- require_relative "../similarity_detector"
message = "Could not find gem '#{missing_gem_name}'."
alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
- suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
- message += "\nDid you mean #{suggestions}?" if suggestions
+ if alternate_names.include?(missing_gem_name.downcase)
+ message += "\nDid you mean '#{missing_gem_name.downcase}'?"
+ elsif defined?(DidYouMean::SpellChecker)
+ suggestions = DidYouMean::SpellChecker.new(dictionary: alternate_names).correct(missing_gem_name)
+ message += "\nDid you mean #{word_list(suggestions)}?" unless suggestions.empty?
+ end
message
end
@@ -122,9 +139,23 @@ module Bundler
def self.clean_after_install?
clean = Bundler.settings[:clean]
return clean unless clean.nil?
- clean ||= Bundler.feature_flag.auto_clean_without_path? && Bundler.settings[:path].nil?
+ clean ||= Bundler.feature_flag.bundler_5_mode? && Bundler.settings[:path].nil?
clean &&= !Bundler.use_system_gems?
clean
end
+
+ def self.word_list(words)
+ if words.empty?
+ return ""
+ end
+
+ words = words.map {|word| "'#{word}'" }
+
+ if words.length == 1
+ return words[0]
+ end
+
+ [words[0..-2].join(", "), words[-1]].join(" or ")
+ end
end
end
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index e1222c75dd..976cda7484 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -2,17 +2,17 @@
module Bundler
class CLI::Config < Thor
- class_option :parseable, :type => :boolean, :banner => "Use minimal formatting for more parseable output"
+ class_option :parseable, type: :boolean, banner: "Use minimal formatting for more parseable output"
def self.scope_options
- method_option :global, :type => :boolean, :banner => "Only change the global config"
- method_option :local, :type => :boolean, :banner => "Only change the local config"
+ method_option :global, type: :boolean, banner: "Only change the global config"
+ method_option :local, type: :boolean, banner: "Only change the local config"
end
private_class_method :scope_options
- desc "base NAME [VALUE]", "The Bundler 1 config interface", :hide => true
+ desc "base NAME [VALUE]", "The Bundler 1 config interface", hide: true
scope_options
- method_option :delete, :type => :boolean, :banner => "delete"
+ method_option :delete, type: :boolean, banner: "delete"
def base(name = nil, *value)
new_args =
if ARGV.size == 1
@@ -25,8 +25,8 @@ module Bundler
["config", "get", ARGV[1]]
end
- SharedHelpers.major_deprecation 3,
- "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
+ message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
+ SharedHelpers.feature_deprecated! message
Base.new(options, name, value, self).run
end
@@ -87,16 +87,21 @@ module Bundler
if value.nil?
warn_unused_scope "Ignoring --#{scope} since no value to set was given"
+ current_value = Bundler.settings[name]
if options[:parseable]
if value = Bundler.settings[name]
Bundler.ui.info("#{name}=#{value}")
end
- return
+ else
+ confirm(name)
end
- confirm(name)
- return
+ if current_value.nil?
+ exit 1
+ else
+ return
+ end
end
Bundler.ui.info(message) if message
diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb
index 1eb8ea8254..2d1a2ce458 100644
--- a/lib/bundler/cli/console.rb
+++ b/lib/bundler/cli/console.rb
@@ -9,9 +9,6 @@ module Bundler
end
def run
- Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
- "by `bin/console` generated by `bundle gem <name>`"
-
group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
ARGV.clear
@@ -23,9 +20,19 @@ module Bundler
require name
get_constant(name)
rescue LoadError
- Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
- require "irb"
- get_constant("irb")
+ if name == "irb"
+ if defined?(Gem::BUNDLED_GEMS) && Gem::BUNDLED_GEMS.respond_to?(:force_activate)
+ Gem::BUNDLED_GEMS.force_activate "irb"
+ require name
+ return get_constant(name)
+ end
+ Bundler.ui.error "#{name} is not available"
+ exit 1
+ else
+ Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
+ name = "irb"
+ retry
+ end
end
def get_constant(name)
@@ -35,9 +42,6 @@ module Bundler
"irb" => :IRB,
}[name]
Object.const_get(const_name)
- rescue NameError
- Bundler.ui.error "Could not find constant #{const_name}"
- exit 1
end
end
end
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
index e299a5a8c2..5fd6a73d91 100644
--- a/lib/bundler/cli/doctor.rb
+++ b/lib/bundler/cli/doctor.rb
@@ -1,157 +1,33 @@
# frozen_string_literal: true
-require "rbconfig"
-require "shellwords"
-require "fiddle"
-
module Bundler
- class CLI::Doctor
- DARWIN_REGEX = /\s+(.+) \(compatibility /.freeze
- LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/.freeze
-
- attr_reader :options
-
- def initialize(options)
- @options = options
- end
-
- def otool_available?
- Bundler.which("otool")
- end
-
- def ldd_available?
- Bundler.which("ldd")
- end
-
- def dylibs_darwin(path)
- output = `/usr/bin/otool -L #{path.shellescape}`.chomp
- dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
- # ignore @rpath and friends
- dylibs.reject {|dylib| dylib.start_with? "@" }
- end
-
- def dylibs_ldd(path)
- output = `/usr/bin/ldd #{path.shellescape}`.chomp
- output.split("\n").map do |l|
- match = l.match(LDD_REGEX)
- next if match.nil?
- match.captures[0]
- end.compact
- end
-
- def dylibs(path)
- case RbConfig::CONFIG["host_os"]
- when /darwin/
- return [] unless otool_available?
- dylibs_darwin(path)
- when /(linux|solaris|bsd)/
- return [] unless ldd_available?
- dylibs_ldd(path)
- else # Windows, etc.
- Bundler.ui.warn("Dynamic library check not supported on this platform.")
- []
- end
- end
-
- def bundles_for_gem(spec)
- Dir.glob("#{spec.full_gem_path}/**/*.bundle")
- end
-
- def check!
- require_relative "check"
- Bundler::CLI::Check.new({}).run
- end
-
- def run
- Bundler.ui.level = "warn" if options[:quiet]
- Bundler.settings.validate!
- check!
-
- definition = Bundler.definition
- broken_links = {}
-
- definition.specs.each do |spec|
- bundles_for_gem(spec).each do |bundle|
- bad_paths = dylibs(bundle).select do |f|
- Fiddle.dlopen(f)
- false
- rescue Fiddle::DLError
- true
- end
- if bad_paths.any?
- broken_links[spec] ||= []
- broken_links[spec].concat(bad_paths)
- end
- end
- end
-
- permissions_valid = check_home_permissions
-
- if broken_links.any?
- message = "The following gems are missing OS dependencies:"
- broken_links.map do |spec, paths|
- paths.uniq.map do |path|
- "\n * #{spec.name}: #{path}"
- end
- end.flatten.sort.each {|m| message += m }
- raise ProductionError, message
- elsif !permissions_valid
- Bundler.ui.info "No issues found with the installed bundle"
- end
- end
-
- private
-
- def check_home_permissions
- require "find"
- files_not_readable_or_writable = []
- files_not_rw_and_owned_by_different_user = []
- files_not_owned_by_current_user_but_still_rw = []
- broken_symlinks = []
- Find.find(Bundler.bundle_path.to_s).each do |f|
- if !File.exist?(f)
- broken_symlinks << f
- elsif !File.writable?(f) || !File.readable?(f)
- if File.stat(f).uid != Process.uid
- files_not_rw_and_owned_by_different_user << f
- else
- files_not_readable_or_writable << f
- end
- elsif File.stat(f).uid != Process.uid
- files_not_owned_by_current_user_but_still_rw << f
- end
- end
-
- ok = true
-
- if broken_symlinks.any?
- Bundler.ui.warn "Broken links exist in the Bundler home. Please report them to the offending gem's upstream repo. These files are:\n - #{broken_symlinks.join("\n - ")}"
-
- ok = false
- end
-
- if files_not_owned_by_current_user_but_still_rw.any?
- Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
- "user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}"
-
- ok = false
- end
-
- if files_not_rw_and_owned_by_different_user.any?
- Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
- "user, and are not readable/writable. These files are:\n - #{files_not_rw_and_owned_by_different_user.join("\n - ")}"
-
- ok = false
- end
-
- if files_not_readable_or_writable.any?
- Bundler.ui.warn "Files exist in the Bundler home that are not " \
- "readable/writable by the current user. These files are:\n - #{files_not_readable_or_writable.join("\n - ")}"
-
- ok = false
- end
-
- ok
+ class CLI::Doctor < Thor
+ default_command(:diagnose)
+
+ desc "diagnose [OPTIONS]", "Checks the bundle for common problems"
+ long_desc <<-D
+ Doctor scans the OS dependencies of each of the gems requested in the Gemfile. If
+ missing dependencies are detected, Bundler prints them and exits status 1.
+ Otherwise, Bundler prints a success message and exits with a status of 0.
+ D
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "ssl", type: :boolean, default: false, banner: "Diagnose SSL problems."
+ def diagnose
+ require_relative "doctor/diagnose"
+ Diagnose.new(options).run
+ end
+
+ desc "ssl [OPTIONS]", "Diagnose SSL problems"
+ long_desc <<-D
+ Diagnose SSL problems, especially related to certificates or TLS version while connecting to https://rubygems.org.
+ D
+ method_option "host", type: :string, banner: "The host to diagnose."
+ method_option "tls-version", type: :string, banner: "Specify the SSL/TLS version when running the diagnostic. Accepts either <1.1> or <1.2>"
+ method_option "verify-mode", type: :string, banner: "Specify the mode used for certification verification. Accepts either <peer> or <none>"
+ def ssl
+ require_relative "doctor/ssl"
+ SSL.new(options).run
end
end
end
diff --git a/lib/bundler/cli/doctor/diagnose.rb b/lib/bundler/cli/doctor/diagnose.rb
new file mode 100644
index 0000000000..a878025dda
--- /dev/null
+++ b/lib/bundler/cli/doctor/diagnose.rb
@@ -0,0 +1,167 @@
+# frozen_string_literal: true
+
+require "rbconfig"
+require "shellwords"
+
+module Bundler
+ class CLI::Doctor::Diagnose
+ DARWIN_REGEX = /\s+(.+) \(compatibility /
+ LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/
+
+ attr_reader :options
+
+ def initialize(options)
+ @options = options
+ end
+
+ def otool_available?
+ Bundler.which("otool")
+ end
+
+ def ldd_available?
+ Bundler.which("ldd")
+ end
+
+ def dylibs_darwin(path)
+ output = `/usr/bin/otool -L #{path.shellescape}`.chomp
+ dylibs = output.split("\n")[1..-1].filter_map {|l| l.match(DARWIN_REGEX)&.match(1) }.uniq
+ # ignore @rpath and friends
+ dylibs.reject {|dylib| dylib.start_with? "@" }
+ end
+
+ def dylibs_ldd(path)
+ output = `/usr/bin/ldd #{path.shellescape}`.chomp
+ output.split("\n").filter_map do |l|
+ match = l.match(LDD_REGEX)
+ next if match.nil?
+ match.captures[0]
+ end
+ end
+
+ def dylibs(path)
+ case RbConfig::CONFIG["host_os"]
+ when /darwin/
+ return [] unless otool_available?
+ dylibs_darwin(path)
+ when /(linux|solaris|bsd)/
+ return [] unless ldd_available?
+ dylibs_ldd(path)
+ else # Windows, etc.
+ Bundler.ui.warn("Dynamic library check not supported on this platform.")
+ []
+ end
+ end
+
+ def bundles_for_gem(spec)
+ Dir.glob("#{spec.full_gem_path}/**/*.bundle")
+ end
+
+ def lookup_with_fiddle(path)
+ require "fiddle"
+ Fiddle.dlopen(path)
+ false
+ rescue Fiddle::DLError
+ true
+ end
+
+ def check!
+ require_relative "../check"
+ Bundler::CLI::Check.new({}).run
+ end
+
+ def diagnose_ssl
+ require_relative "ssl"
+ Bundler::CLI::Doctor::SSL.new({}).run
+ end
+
+ def run
+ Bundler.ui.level = "warn" if options[:quiet]
+ Bundler.settings.validate!
+ check!
+ diagnose_ssl if options[:ssl]
+
+ definition = Bundler.definition
+ broken_links = {}
+
+ definition.specs.each do |spec|
+ bundles_for_gem(spec).each do |bundle|
+ bad_paths = dylibs(bundle).select do |f|
+ lookup_with_fiddle(f)
+ end
+ if bad_paths.any?
+ broken_links[spec] ||= []
+ broken_links[spec].concat(bad_paths)
+ end
+ end
+ end
+
+ permissions_valid = check_home_permissions
+
+ if broken_links.any?
+ message = "The following gems are missing OS dependencies:"
+ broken_links.flat_map do |spec, paths|
+ paths.uniq.map do |path|
+ "\n * #{spec.name}: #{path}"
+ end
+ end.sort.each {|m| message += m }
+ raise ProductionError, message
+ elsif permissions_valid
+ Bundler.ui.info "No issues found with the installed bundle"
+ end
+ end
+
+ private
+
+ def check_home_permissions
+ require "find"
+ files_not_readable = []
+ files_not_readable_and_owned_by_different_user = []
+ files_not_owned_by_current_user_but_still_readable = []
+ broken_symlinks = []
+ Find.find(Bundler.bundle_path.to_s).each do |f|
+ if !File.exist?(f)
+ broken_symlinks << f
+ elsif !File.readable?(f)
+ if File.stat(f).uid != Process.uid
+ files_not_readable_and_owned_by_different_user << f
+ else
+ files_not_readable << f
+ end
+ elsif File.stat(f).uid != Process.uid
+ files_not_owned_by_current_user_but_still_readable << f
+ end
+ end
+
+ ok = true
+
+ if broken_symlinks.any?
+ Bundler.ui.warn "Broken links exist in the Bundler home. Please report them to the offending gem's upstream repo. These files are:\n - #{broken_symlinks.join("\n - ")}"
+
+ ok = false
+ end
+
+ if files_not_owned_by_current_user_but_still_readable.any?
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
+ "user, but are still readable. These files are:\n - #{files_not_owned_by_current_user_but_still_readable.join("\n - ")}"
+
+ ok = false
+ end
+
+ if files_not_readable_and_owned_by_different_user.any?
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
+ "user, and are not readable. These files are:\n - #{files_not_readable_and_owned_by_different_user.join("\n - ")}"
+
+ ok = false
+ end
+
+ if files_not_readable.any?
+ Bundler.ui.warn "Files exist in the Bundler home that are not " \
+ "readable by the current user. These files are:\n - #{files_not_readable.join("\n - ")}"
+
+ ok = false
+ end
+
+ ok
+ end
+ end
+end
diff --git a/lib/bundler/cli/doctor/ssl.rb b/lib/bundler/cli/doctor/ssl.rb
new file mode 100644
index 0000000000..21fc4edf2d
--- /dev/null
+++ b/lib/bundler/cli/doctor/ssl.rb
@@ -0,0 +1,249 @@
+# frozen_string_literal: true
+
+require "rubygems/remote_fetcher"
+require "uri"
+
+module Bundler
+ class CLI::Doctor::SSL
+ attr_reader :options
+
+ def initialize(options)
+ @options = options
+ end
+
+ def run
+ return unless openssl_installed?
+
+ output_ssl_environment
+ bundler_success = bundler_connection_successful?
+ rubygem_success = rubygem_connection_successful?
+
+ return unless net_http_connection_successful?
+
+ Explanation.summarize(bundler_success, rubygem_success, host)
+ end
+
+ private
+
+ def host
+ @options[:host] || "rubygems.org"
+ end
+
+ def tls_version
+ @options[:"tls-version"].then do |version|
+ "TLS#{version.sub(".", "_")}".to_sym if version
+ end
+ end
+
+ def verify_mode
+ mode = @options[:"verify-mode"] || :peer
+
+ @verify_mode ||= mode.then {|mod| OpenSSL::SSL.const_get("verify_#{mod}".upcase) }
+ end
+
+ def uri
+ @uri ||= URI("https://#{host}")
+ end
+
+ def openssl_installed?
+ require "openssl"
+
+ true
+ rescue LoadError
+ Bundler.ui.warn(<<~MSG)
+ Oh no! Your Ruby doesn't have OpenSSL, so it can't connect to #{host}.
+ You'll need to recompile or reinstall Ruby with OpenSSL support and try again.
+ MSG
+
+ false
+ end
+
+ def output_ssl_environment
+ Bundler.ui.info(<<~MESSAGE)
+ Here's your OpenSSL environment:
+
+ OpenSSL: #{OpenSSL::VERSION}
+ Compiled with: #{OpenSSL::OPENSSL_VERSION}
+ Loaded with: #{OpenSSL::OPENSSL_LIBRARY_VERSION}
+ MESSAGE
+ end
+
+ def bundler_connection_successful?
+ Bundler.ui.info("\nTrying connections to #{uri}:\n")
+
+ bundler_uri = Gem::URI(uri.to_s)
+ Bundler::Fetcher.new(
+ Bundler::Source::Rubygems::Remote.new(bundler_uri)
+ ).send(:connection).request(bundler_uri)
+
+ Bundler.ui.info("Bundler: success")
+
+ true
+ rescue StandardError => error
+ Bundler.ui.warn("Bundler: failed (#{Explanation.explain_bundler_or_rubygems_error(error)})")
+
+ false
+ end
+
+ def rubygem_connection_successful?
+ Gem::RemoteFetcher.fetcher.fetch_path(uri)
+ Bundler.ui.info("RubyGems: success")
+
+ true
+ rescue StandardError => error
+ Bundler.ui.warn("RubyGems: failed (#{Explanation.explain_bundler_or_rubygems_error(error)})")
+
+ false
+ end
+
+ def net_http_connection_successful?
+ ::Gem::Net::HTTP.new(uri.host, uri.port).tap do |http|
+ http.use_ssl = true
+ http.min_version = tls_version
+ http.max_version = tls_version
+ http.verify_mode = verify_mode
+ end.start
+
+ Bundler.ui.info("Ruby net/http: success")
+ warn_on_unsupported_tls12
+
+ true
+ rescue StandardError => error
+ Bundler.ui.warn(<<~MSG)
+ Ruby net/http: failed
+
+ Unfortunately, this Ruby can't connect to #{host}.
+
+ #{Explanation.explain_net_http_error(error, host, tls_version)}
+ MSG
+
+ false
+ end
+
+ def warn_on_unsupported_tls12
+ ctx = OpenSSL::SSL::SSLContext.new
+ supported = true
+
+ if ctx.respond_to?(:min_version=)
+ begin
+ ctx.min_version = ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
+ rescue OpenSSL::SSL::SSLError, NameError
+ supported = false
+ end
+ else
+ supported = OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1_2) # rubocop:disable Naming/VariableNumber
+ end
+
+ Bundler.ui.warn(<<~EOM) unless supported
+
+ WARNING: Although your Ruby can connect to #{host} today, your OpenSSL is very old!
+ WARNING: You will need to upgrade OpenSSL to use #{host}.
+
+ EOM
+ end
+
+ module Explanation
+ extend self
+
+ def explain_bundler_or_rubygems_error(error)
+ case error.message
+ when /certificate verify failed/
+ "certificate verification"
+ when /read server hello A/
+ "SSL/TLS protocol version mismatch"
+ when /tlsv1 alert protocol version/
+ "requested TLS version is too old"
+ else
+ error.message
+ end
+ end
+
+ def explain_net_http_error(error, host, tls_version)
+ case error.message
+ # Check for certificate errors
+ when /certificate verify failed/
+ <<~MSG
+ #{show_ssl_certs}
+ Your Ruby can't connect to #{host} because you are missing the certificate files OpenSSL needs to verify you are connecting to the genuine #{host} servers.
+ MSG
+ # Check for TLS version errors
+ when /read server hello A/, /tlsv1 alert protocol version/
+ if tls_version.to_s == "TLS1_3"
+ "Your Ruby can't connect to #{host} because #{tls_version} isn't supported yet.\n"
+ else
+ <<~MSG
+ Your Ruby can't connect to #{host} because your version of OpenSSL is too old.
+ You'll need to upgrade your OpenSSL install and/or recompile Ruby to use a newer OpenSSL.
+ MSG
+ end
+ # OpenSSL doesn't support TLS version specified by argument
+ when /unknown SSL method/
+ "Your Ruby can't connect because #{tls_version} isn't supported by your version of OpenSSL."
+ else
+ <<~MSG
+ Even worse, we're not sure why.
+
+ Here's the full error information:
+ #{error.class}: #{error.message}
+ #{error.backtrace.join("\n ")}
+
+ You might have more luck using Mislav's SSL doctor.rb script. You can get it here:
+ https://github.com/mislav/ssl-tools/blob/8b3dec4/doctor.rb
+
+ Read more about the script and how to use it in this blog post:
+ https://mislav.net/2013/07/ruby-openssl/
+ MSG
+ end
+ end
+
+ def summarize(bundler_success, rubygems_success, host)
+ guide_url = "http://ruby.to/ssl-check-failed"
+
+ message = if bundler_success && rubygems_success
+ <<~MSG
+ Hooray! This Ruby can connect to #{host}.
+ You are all set to use Bundler and RubyGems.
+
+ MSG
+ elsif !bundler_success && !rubygems_success
+ <<~MSG
+ For some reason, your Ruby installation can connect to #{host}, but neither RubyGems nor Bundler can.
+ The most likely fix is to manually upgrade RubyGems by following the instructions at #{guide_url}.
+ After you've done that, run `gem install bundler` to upgrade Bundler, and then run this script again to make sure everything worked. â£
+
+ MSG
+ elsif !bundler_success
+ <<~MSG
+ Although your Ruby installation and RubyGems can both connect to #{host}, Bundler is having trouble.
+ The most likely way to fix this is to upgrade Bundler by running `gem install bundler`.
+ Run this script again after doing that to make sure everything is all set.
+ If you're still having trouble, check out the troubleshooting guide at #{guide_url}.
+
+ MSG
+ else
+ <<~MSG
+ It looks like Ruby and Bundler can connect to #{host}, but RubyGems itself cannot.
+ You can likely solve this by manually downloading and installing a RubyGems update.
+ Visit #{guide_url} for instructions on how to manually upgrade RubyGems.
+
+ MSG
+ end
+
+ Bundler.ui.info("\n#{message}")
+ end
+
+ private
+
+ def show_ssl_certs
+ ssl_cert_file = ENV["SSL_CERT_FILE"] || OpenSSL::X509::DEFAULT_CERT_FILE
+ ssl_cert_dir = ENV["SSL_CERT_DIR"] || OpenSSL::X509::DEFAULT_CERT_DIR
+
+ <<~MSG
+ Below affect only Ruby net/http connections:
+ SSL_CERT_FILE: #{File.exist?(ssl_cert_file) ? "exists #{ssl_cert_file}" : "is missing #{ssl_cert_file}"}
+ SSL_CERT_DIR: #{Dir.exist?(ssl_cert_dir) ? "exists #{ssl_cert_dir}" : "is missing #{ssl_cert_dir}"}
+ MSG
+ end
+ end
+ end
+end
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
index 42b602a055..2fdc416286 100644
--- a/lib/bundler/cli/exec.rb
+++ b/lib/bundler/cli/exec.rb
@@ -12,17 +12,20 @@ module Bundler
@options = options
@cmd = args.shift
@args = args
- @args << { :close_others => !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
+ @args << { close_others: !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
end
def run
validate_cmd!
SharedHelpers.set_bundle_environment
if bin_path = Bundler.which(cmd)
- if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path)
- return kernel_load(bin_path, *args)
+ if !Bundler.settings[:disable_exec_load] && directly_loadable?(bin_path)
+ bin_path.delete_suffix!(".bat") if Gem.win_platform?
+ kernel_load(bin_path, *args)
+ else
+ bin_path = "./" + bin_path unless File.absolute_path?(bin_path)
+ kernel_exec(bin_path, *args)
end
- kernel_exec(bin_path, *args)
else
# exec using the given command
kernel_exec(cmd, *args)
@@ -68,6 +71,29 @@ module Bundler
"#{file} #{args.join(" ")}".strip
end
+ def directly_loadable?(file)
+ if Gem.win_platform?
+ script_wrapper?(file)
+ else
+ ruby_shebang?(file)
+ end
+ end
+
+ def script_wrapper?(file)
+ script_file = file.delete_suffix(".bat")
+ return false unless File.exist?(script_file)
+
+ if File.zero?(script_file)
+ Bundler.ui.warn "#{script_file} is empty"
+ return false
+ end
+
+ header = File.open(file, "r") {|f| f.read(32) }
+ ruby_exe = "#{RbConfig::CONFIG["RUBY_INSTALL_NAME"]}#{RbConfig::CONFIG["EXEEXT"]}"
+ ruby_exe = "ruby.exe" if ruby_exe.empty?
+ header.include?(ruby_exe)
+ end
+
def ruby_shebang?(file)
possibilities = [
"#!/usr/bin/env ruby\n",
diff --git a/lib/bundler/cli/fund.rb b/lib/bundler/cli/fund.rb
index 52db5aef68..ad7f31f3d6 100644
--- a/lib/bundler/cli/fund.rb
+++ b/lib/bundler/cli/fund.rb
@@ -16,7 +16,7 @@ module Bundler
deps = if groups.any?
Bundler.definition.dependencies_for(groups)
else
- Bundler.definition.current_dependencies
+ Bundler.definition.requested_dependencies
end
fund_info = deps.each_with_object([]) do |dep, arr|
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 7f1200f4a0..c8c24c8e66 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "pathname"
-
module Bundler
class CLI
Bundler.require_thor_actions
@@ -9,11 +7,7 @@ module Bundler
end
class CLI::Gem
- TEST_FRAMEWORK_VERSIONS = {
- "rspec" => "3.0",
- "minitest" => "5.0",
- "test-unit" => "3.0",
- }.freeze
+ DEFAULT_GITHUB_USERNAME = "[USERNAME]"
attr_reader :options, :gem_name, :thor, :name, :target, :extension
@@ -26,13 +20,11 @@ module Bundler
thor.destination_root = nil
@name = @gem_name
- @target = SharedHelpers.pwd.join(gem_name)
+ @target = Pathname.new(SharedHelpers.pwd).join(gem_name)
@extension = options[:ext]
validate_ext_name if @extension
- validate_rust_builder_rubygems_version if @extension == "rust"
- travis_removal_info
end
def run
@@ -49,38 +41,46 @@ module Bundler
git_author_name = use_git ? `git config user.name`.chomp : ""
git_username = use_git ? `git config github.user`.chomp : ""
git_user_email = use_git ? `git config user.email`.chomp : ""
+ github_username = github_username(git_username)
- github_username = if options[:github_username].nil?
- git_username
- elsif options[:github_username] == false
- ""
+ if github_username.empty?
+ homepage_uri = "TODO: Put your gem's website or public repo URL here."
+ source_code_uri = "TODO: Put your gem's public repo URL here."
+ changelog_uri = "TODO: Put your gem's CHANGELOG.md URL here."
else
- options[:github_username]
+ homepage_uri = "https://github.com/#{github_username}/#{name}"
+ source_code_uri = "https://github.com/#{github_username}/#{name}"
+ changelog_uri = "https://github.com/#{github_username}/#{name}/blob/main/CHANGELOG.md"
end
config = {
- :name => name,
- :underscored_name => underscored_name,
- :namespaced_path => namespaced_path,
- :makefile_path => "#{underscored_name}/#{underscored_name}",
- :constant_name => constant_name,
- :constant_array => constant_array,
- :author => git_author_name.empty? ? "TODO: Write your name" : git_author_name,
- :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
- :test => options[:test],
- :ext => extension,
- :exe => options[:exe],
- :bundler_version => bundler_dependency_version,
- :git => use_git,
- :github_username => github_username.empty? ? "[USERNAME]" : github_username,
- :required_ruby_version => required_ruby_version,
- :rust_builder_required_rubygems_version => rust_builder_required_rubygems_version,
- :minitest_constant_name => minitest_constant_name,
+ name: name,
+ underscored_name: underscored_name,
+ namespaced_path: namespaced_path,
+ makefile_path: "#{underscored_name}/#{underscored_name}",
+ constant_name: constant_name,
+ constant_array: constant_array,
+ author: git_author_name.empty? ? "TODO: Write your name" : git_author_name,
+ email: git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
+ test: options[:test],
+ ext: extension,
+ exe: options[:exe],
+ bundle: options[:bundle],
+ bundler_version: bundler_dependency_version,
+ git: use_git,
+ github_username: github_username.empty? ? DEFAULT_GITHUB_USERNAME : github_username,
+ required_ruby_version: required_ruby_version,
+ rust_builder_required_rubygems_version: rust_builder_required_rubygems_version,
+ minitest_constant_name: minitest_constant_name,
+ ignore_paths: %w[bin/],
+ homepage_uri: homepage_uri,
+ source_code_uri: source_code_uri,
+ changelog_uri: changelog_uri,
}
ensure_safe_gem_name(name, constant_array)
templates = {
- "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
+ "Gemfile.tt" => Bundler.preferred_gemfile_name,
"lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
"lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
"sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
@@ -96,11 +96,21 @@ module Bundler
bin/setup
]
- templates.merge!("gitignore.tt" => ".gitignore") if use_git
+ case Bundler.preferred_gemfile_name
+ when "Gemfile"
+ config[:ignore_paths] << "Gemfile"
+ when "gems.rb"
+ config[:ignore_paths] << "gems.rb"
+ config[:ignore_paths] << "gems.locked"
+ end
+
+ if use_git
+ templates.merge!("gitignore.tt" => ".gitignore")
+ config[:ignore_paths] << ".gitignore"
+ end
if test_framework = ask_and_set_test_framework
config[:test] = test_framework
- config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
case test_framework
when "rspec"
@@ -110,6 +120,8 @@ module Bundler
"spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
)
config[:test_task] = :spec
+ config[:ignore_paths] << ".rspec"
+ config[:ignore_paths] << "spec/"
when "minitest"
# Generate path for minitest target file (FileList["test/**/test_*.rb"])
# foo => test/test_foo.rb
@@ -124,12 +136,14 @@ module Bundler
"test/minitest/test_newgem.rb.tt" => "test/#{minitest_namespaced_path}.rb"
)
config[:test_task] = :test
+ config[:ignore_paths] << "test/"
when "test-unit"
templates.merge!(
"test/test-unit/test_helper.rb.tt" => "test/test_helper.rb",
"test/test-unit/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
)
config[:test_task] = :test
+ config[:ignore_paths] << "test/"
end
end
@@ -137,16 +151,22 @@ module Bundler
case config[:ci]
when "github"
templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
+ if extension == "rust"
+ templates.merge!("github/workflows/build-gems.yml.tt" => ".github/workflows/build-gems.yml")
+ end
+ config[:ignore_paths] << ".github/"
when "gitlab"
templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
+ config[:ignore_paths] << ".gitlab-ci.yml"
when "circle"
templates.merge!("circleci/config.yml.tt" => ".circleci/config.yml")
+ config[:ignore_paths] << ".circleci/"
end
if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
- "This means that any other developer or company will be legally allowed to use your code " \
- "for free as long as they admit you created it. You can read more about the MIT license " \
- "at https://choosealicense.com/licenses/mit.")
+ "Using a MIT license means that any other developer or company will be legally allowed " \
+ "to use your code for free as long as they admit you created it. You can read more about " \
+ "the MIT license at https://choosealicense.com/licenses/mit.")
config[:mit] = true
Bundler.ui.info "MIT License enabled in config"
templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
@@ -154,12 +174,8 @@ module Bundler
if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
"Codes of conduct can increase contributions to your project by contributors who " \
- "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
- "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
- "of enforcing it, so be sure that you are prepared to do that. Be sure that your email " \
- "address is specified as a contact in the generated code of conduct so that people know " \
- "who to contact in case of a violation. For suggestions about " \
- "how to enforce codes of conduct, see https://bit.ly/coc-enforcement.")
+ "prefer safe, respectful, productive, and collaborative spaces. \n" \
+ "See https://github.com/ruby/rubygems/blob/master/CODE_OF_CONDUCT.md")
config[:coc] = true
Bundler.ui.info "Code of conduct enabled in config"
templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
@@ -180,16 +196,19 @@ module Bundler
config[:linter] = ask_and_set_linter
case config[:linter]
when "rubocop"
- config[:linter_version] = rubocop_version
Bundler.ui.info "RuboCop enabled in config"
templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
+ config[:ignore_paths] << ".rubocop.yml"
when "standard"
- config[:linter_version] = standard_version
Bundler.ui.info "Standard enabled in config"
templates.merge!("standard.yml.tt" => ".standard.yml")
+ config[:ignore_paths] << ".standard.yml"
end
- templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
+ if config[:exe]
+ templates.merge!("exe/newgem.tt" => "exe/#{name}")
+ executables.push("exe/#{name}")
+ end
if extension == "c"
templates.merge!(
@@ -203,18 +222,31 @@ module Bundler
templates.merge!(
"Cargo.toml.tt" => "Cargo.toml",
"ext/newgem/Cargo.toml.tt" => "ext/#{name}/Cargo.toml",
+ "ext/newgem/build.rs.tt" => "ext/#{name}/build.rs",
"ext/newgem/extconf-rust.rb.tt" => "ext/#{name}/extconf.rb",
"ext/newgem/src/lib.rs.tt" => "ext/#{name}/src/lib.rs",
)
end
+ if extension == "go"
+ templates.merge!(
+ "ext/newgem/go.mod.tt" => "ext/#{name}/go.mod",
+ "ext/newgem/extconf-go.rb.tt" => "ext/#{name}/extconf.rb",
+ "ext/newgem/newgem.h.tt" => "ext/#{name}/#{underscored_name}.h",
+ "ext/newgem/newgem.go.tt" => "ext/#{name}/#{underscored_name}.go",
+ "ext/newgem/newgem-go.c.tt" => "ext/#{name}/#{underscored_name}.c",
+ )
+
+ config[:go_module_username] = config[:github_username] == DEFAULT_GITHUB_USERNAME ? "username" : config[:github_username]
+ end
+
if target.exist? && !target.directory?
Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
end
if use_git
- Bundler.ui.info "Initializing git repo in #{target}"
+ Bundler.ui.info "\nInitializing git repo in #{target}"
require "shellwords"
`git init #{target.to_s.shellescape}`
@@ -233,31 +265,36 @@ module Bundler
end
if use_git
+ IO.popen(%w[git add .], { chdir: target }, &:read)
+ end
+
+ if config[:bundle]
+ Bundler.ui.info "Running bundle install in the new gem directory."
Dir.chdir(target) do
- `git add .`
+ system("bundle install")
end
end
# Open gemspec in editor
open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit]
- Bundler.ui.info "Gem '#{name}' was successfully created. " \
- "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
+ Bundler.ui.info "\nGem '#{name}' was successfully created. " \
+ "For more information on making a RubyGem visit https://guides.rubygems.org/make-your-own-gem/"
end
private
def resolve_name(name)
- SharedHelpers.pwd.join(name).basename.to_s
+ Pathname.new(SharedHelpers.pwd).join(name).basename.to_s
end
- def ask_and_set(key, header, message)
+ def ask_and_set(key, prompt, explanation)
choice = options[key]
choice = Bundler.settings["gem.#{key}"] if choice.nil?
if choice.nil?
- Bundler.ui.confirm header
- choice = Bundler.ui.yes? "#{message} y/(n):"
+ Bundler.ui.info "\n#{explanation}"
+ choice = Bundler.ui.yes? "#{prompt} y/(n):"
Bundler.settings.set_global("gem.#{key}", choice)
end
@@ -275,10 +312,11 @@ module Bundler
end
def ask_and_set_test_framework
+ return if skip?(:test)
test_framework = options[:test] || Bundler.settings["gem.test"]
if test_framework.to_s.empty?
- Bundler.ui.confirm "Do you want to generate tests with your gem?"
+ Bundler.ui.info "\nDo you want to generate tests with your gem?"
Bundler.ui.info hint_text("test")
result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
@@ -300,6 +338,10 @@ module Bundler
test_framework
end
+ def skip?(option)
+ options.key?(option) && options[option].nil?
+ end
+
def hint_text(setting)
if Bundler.settings["gem.#{setting}"] == false
"Your choice will only be applied to this gem."
@@ -310,15 +352,15 @@ module Bundler
end
def ask_and_set_ci
+ return if skip?(:ci)
ci_template = options[:ci] || Bundler.settings["gem.ci"]
if ci_template.to_s.empty?
- Bundler.ui.confirm "Do you want to set up continuous integration for your gem? " \
+ Bundler.ui.info "\nDo you want to set up continuous integration for your gem? " \
"Supported services:\n" \
"* CircleCI: https://circleci.com/\n" \
"* GitHub Actions: https://github.com/features/actions\n" \
- "* GitLab CI: https://docs.gitlab.com/ee/ci/\n" \
- "\n"
+ "* GitLab CI: https://docs.gitlab.com/ee/ci/\n"
Bundler.ui.info hint_text("ci")
result = Bundler.ui.ask "Enter a CI service. github/gitlab/circle/(none):"
@@ -341,15 +383,14 @@ module Bundler
end
def ask_and_set_linter
+ return if skip?(:linter)
linter_template = options[:linter] || Bundler.settings["gem.linter"]
- linter_template = deprecated_rubocop_option if linter_template.nil?
if linter_template.to_s.empty?
- Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
+ Bundler.ui.info "\nDo you want to add a code linter and formatter to your gem? " \
"Supported Linters:\n" \
"* RuboCop: https://rubocop.org\n" \
- "* Standard: https://github.com/testdouble/standard\n" \
- "\n"
+ "* Standard: https://github.com/standardrb/standard\n"
Bundler.ui.info hint_text("linter")
result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
@@ -376,22 +417,6 @@ module Bundler
linter_template
end
- def deprecated_rubocop_option
- if !options[:rubocop].nil?
- if options[:rubocop]
- Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
- "rubocop"
- else
- Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
- false
- end
- elsif !Bundler.settings["gem.rubocop"].nil?
- Bundler::SharedHelpers.major_deprecation 2,
- "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
- Bundler.settings["gem.rubocop"] ? "rubocop" : false
- end
- end
-
def bundler_dependency_version
v = Gem::Version.new(Bundler::VERSION)
req = v.segments[0..1]
@@ -405,6 +430,10 @@ module Bundler
exit 1
end
+ if /[A-Z]/.match?(name)
+ Bundler.ui.warn "Gem names with capital letters are not recommended. Please use only lowercase letters, numbers, and hyphens."
+ end
+
constant_name = constant_array.join("::")
existing_constant = constant_array.inject(Object) do |c, s|
@@ -431,34 +460,16 @@ module Bundler
end
def required_ruby_version
- "2.6.0"
- end
-
- def rubocop_version
- "1.21"
- end
-
- def standard_version
- "1.3"
- end
-
- # TODO: remove at next minor release
- def travis_removal_info
- if options[:ci] == "travis"
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator."
- exit 1
- end
-
- if Bundler.settings["gem.ci"] == "travis"
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator, but it is present in bundle config. Please configure another provider using `bundle config set gem.ci SERVICE` (where SERVICE is one of github/gitlab/circle) or unset configuration using `bundle config unset gem.ci`."
- exit 1
- end
+ "3.2.0"
end
- def validate_rust_builder_rubygems_version
- if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version
- Bundler.ui.error "Your RubyGems version (#{Gem.rubygems_version}) is too old to build Rust extension. Please update your RubyGems using `gem update --system` or any other way and try again."
- exit 1
+ def github_username(git_username)
+ if options[:github_username].nil?
+ git_username
+ elsif options[:github_username] == false
+ ""
+ else
+ options[:github_username]
end
end
end
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index 36c7a58f12..cd01d4949b 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -25,19 +25,8 @@ module Bundler
private
- def spec_for_gem(gem_name)
- spec = Bundler.definition.specs.find {|s| s.name == gem_name }
- spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match)
- end
-
- def default_gem_spec(gem_name)
- return unless Gem::Specification.respond_to?(:find_all_by_name)
- gem_spec = Gem::Specification.find_all_by_name(gem_name).last
- return gem_spec if gem_spec&.default_gem?
- end
-
- def spec_not_found(gem_name)
- raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
+ def spec_for_gem(name)
+ Bundler::CLI::Common.select_spec(name, :regex_match)
end
def print_gem_version(spec)
@@ -50,8 +39,8 @@ module Bundler
path = File.expand_path("../../..", __dir__)
else
path = spec.full_gem_path
- if spec.deleted_gem?
- return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}"
+ if spec.installation_missing?
+ return Bundler.ui.warn "The gem #{name} is missing. It should be installed at #{path}, but was not found"
end
end
@@ -76,19 +65,19 @@ module Bundler
gem_info << "\tDefault Gem: yes\n" if spec.respond_to?(:default_gem?) && spec.default_gem?
gem_info << "\tReverse Dependencies: \n\t\t#{gem_dependencies.join("\n\t\t")}" if gem_dependencies.any?
- if name != "bundler" && spec.deleted_gem?
- return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}"
+ if name != "bundler" && spec.installation_missing?
+ return Bundler.ui.warn "The gem #{name} is missing. Gemspec information is still available though:\n#{gem_info}"
end
Bundler.ui.info gem_info
end
def gem_dependencies
- @gem_dependencies ||= Bundler.definition.specs.map do |spec|
+ @gem_dependencies ||= Bundler.definition.specs.filter_map do |spec|
dependency = spec.dependencies.find {|dep| dep.name == gem_name }
next unless dependency
"#{spec.name} (#{spec.version}) depends on #{gem_name} (#{dependency.requirements_list.join(", ")})"
- end.compact.sort
+ end.sort
end
end
end
diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb
deleted file mode 100644
index 8093a85283..0000000000
--- a/lib/bundler/cli/inject.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Inject
- attr_reader :options, :name, :version, :group, :source, :gems
- def initialize(options, name, version)
- @options = options
- @name = name
- @version = version || last_version_number
- @group = options[:group].split(",") unless options[:group].nil?
- @source = options[:source]
- @gems = []
- end
-
- def run
- # The required arguments allow Thor to give useful feedback when the arguments
- # are incorrect. This adds those first two arguments onto the list as a whole.
- gems.unshift(source).unshift(group).unshift(version).unshift(name)
-
- # Build an array of Dependency objects out of the arguments
- deps = []
- # when `inject` support addition of more than one gem, then this loop will
- # help. Currently this loop is running once.
- gems.each_slice(4) do |gem_name, gem_version, gem_group, gem_source|
- ops = Gem::Requirement::OPS.map {|key, _val| key }
- has_op = ops.any? {|op| gem_version.start_with? op }
- gem_version = "~> #{gem_version}" unless has_op
- deps << Bundler::Dependency.new(gem_name, gem_version, "group" => gem_group, "source" => gem_source)
- end
-
- added = Injector.inject(deps, options)
-
- if added.any?
- Bundler.ui.confirm "Added to Gemfile:"
- Bundler.ui.confirm(added.map do |d|
- name = "'#{d.name}'"
- requirement = ", '#{d.requirement}'"
- group = ", :group => #{d.groups.inspect}" if d.groups != Array(:default)
- source = ", :source => '#{d.source}'" unless d.source.nil?
- %(gem #{name}#{requirement}#{group}#{source})
- end.join("\n"))
- else
- Bundler.ui.confirm "All gems were already present in the Gemfile"
- end
- end
-
- private
-
- def last_version_number
- definition = Bundler.definition(true)
- definition.resolve_remotely!
- specs = definition.index[name].sort_by(&:version)
- unless options[:pre]
- specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
- end
- spec = specs.last
- spec.version.to_s
- end
- end
-end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index c71bcf159f..69affd1a10 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -12,56 +12,44 @@ module Bundler
warn_if_root
- Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
-
- Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
+ if options[:local]
+ Bundler.self_manager.restart_with_locked_bundler_if_needed
+ else
+ Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
+ end
- # Disable color in deployment mode
- Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
+ Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
- check_for_options_conflicts
+ if target_rbconfig_path = options[:"target-rbconfig"]
+ Bundler.rubygems.set_target_rbconfig(target_rbconfig_path)
+ end
check_trust_policy
- if options[:deployment] || options[:frozen] || Bundler.frozen_bundle?
- unless Bundler.default_lockfile.exist?
- flag = "--deployment flag" if options[:deployment]
- flag ||= "--frozen flag" if options[:frozen]
- flag ||= "deployment setting"
- raise ProductionError, "The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \
- "sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control " \
- "before deploying."
- end
-
- options[:local] = true if Bundler.app_cache.exist?
-
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
- end
-
- # When install is called with --no-deployment, disable deployment mode
- if options[:deployment] == false
- Bundler.settings.set_command_option :frozen, nil
- options[:system] = true
+ if Bundler.frozen_bundle? && !Bundler.default_lockfile.exist?
+ flag = "deployment setting" if Bundler.settings[:deployment]
+ flag = "frozen setting" if Bundler.settings[:frozen]
+ raise ProductionError, "The #{flag} requires a lockfile. Please make " \
+ "sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
+ "before deploying."
end
normalize_settings
Bundler::Fetcher.disable_endpoint = options["full-index"]
- if options["binstubs"]
- Bundler::SharedHelpers.major_deprecation 2,
- "The --binstubs option will be removed in favor of `bundle binstubs --all`"
- end
-
- Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
+ Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.settings[:plugins]
- definition = Bundler.definition
+ # For install we want to enable strict validation
+ # (rather than some optimizations we perform at app runtime).
+ definition = Bundler.definition(strict: true)
definition.validate_runtime!
+ definition.lockfile = options["lockfile"] if options["lockfile"]
+ definition.lockfile = false if options["no-lock"]
installer = Installer.install(Bundler.root, definition, options)
- Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
+ Bundler.settings.temporary(cache_all_platforms: options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
end
@@ -77,8 +65,6 @@ module Bundler
Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
- warn_ambiguous_gems
-
if CLI::Common.clean_after_install?
require_relative "clean"
Bundler::CLI::Clean.new(options).run
@@ -95,7 +81,7 @@ module Bundler
def warn_if_root
return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
Bundler.ui.warn "Don't run Bundler as root. Installing your bundle as root " \
- "will break this application for all non-root users on this machine.", :wrap => true
+ "will break this application for all non-root users on this machine.", wrap: true
end
def dependencies_count_for(definition)
@@ -104,26 +90,10 @@ module Bundler
end
def gems_installed_for(definition)
- count = definition.specs.count
+ count = definition.specs.count {|spec| spec.name != "bundler" }
"#{count} #{count == 1 ? "gem" : "gems"} now installed"
end
- def check_for_group_conflicts_in_cli_options
- conflicting_groups = Array(options[:without]) & Array(options[:with])
- return if conflicting_groups.empty?
- raise InvalidOption, "You can't list a group in both with and without." \
- " The offending groups are: #{conflicting_groups.join(", ")}."
- end
-
- def check_for_options_conflicts
- if (options[:path] || options[:deployment]) && options[:system]
- error_message = String.new
- error_message << "You have specified both --path as well as --system. Please choose only one option.\n" if options[:path]
- error_message << "You have specified both --deployment as well as --system. Please choose only one option.\n" if options[:deployment]
- raise InvalidOption.new(error_message)
- end
- end
-
def check_trust_policy
trust_policy = options["trust-policy"]
unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy)
@@ -133,57 +103,25 @@ module Bundler
Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy
end
- def normalize_groups
- check_for_group_conflicts_in_cli_options
-
- # need to nil them out first to get around validation for backwards compatibility
- Bundler.settings.set_command_option :without, nil
- Bundler.settings.set_command_option :with, nil
- Bundler.settings.set_command_option :without, options[:without]
- Bundler.settings.set_command_option :with, options[:with]
- end
-
def normalize_settings
- Bundler.settings.set_command_option :path, nil if options[:system]
- Bundler.settings.set_command_option_if_given :path, options[:path]
-
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
- Bundler.settings.set_command_option :path, "bundle"
- end
+ Bundler.settings.set_command_option :path, "bundle"
end
- bin_option = options["binstubs"]
- bin_option = nil if bin_option&.empty?
- Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
-
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
Bundler.settings.set_command_option_if_given :jobs, options["jobs"]
+ Bundler::CLI::Common.validate_cooldown!(options["cooldown"])
+ Bundler.settings.set_command_option_if_given :cooldown, options["cooldown"]
+
Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"]
Bundler.settings.set_command_option_if_given :no_install, options["no-install"]
Bundler.settings.set_command_option_if_given :clean, options["clean"]
- normalize_groups if options[:without] || options[:with]
-
- options[:force] = options[:redownload]
- end
-
- def warn_ambiguous_gems
- # TODO: remove this when we drop Bundler 1.x support
- Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
- Bundler.ui.warn "Warning: the gem '#{name}' was found in multiple sources."
- Bundler.ui.warn "Installed from: #{installed_from_uri}"
- Bundler.ui.warn "Also found in:"
- also_found_in_uris.each {|uri| Bundler.ui.warn " * #{uri}" }
- Bundler.ui.warn "You should add a source requirement to restrict this gem to your preferred source."
- Bundler.ui.warn "For example:"
- Bundler.ui.warn " gem '#{name}', :source => '#{installed_from_uri}'"
- Bundler.ui.warn "Then uninstall the gem '#{name}' (or delete all bundled gems) and then install again."
- end
+ options[:force] = options[:redownload] if options[:redownload]
end
end
end
diff --git a/lib/bundler/cli/issue.rb b/lib/bundler/cli/issue.rb
index b891ecb1d2..cbfb7da2d8 100644
--- a/lib/bundler/cli/issue.rb
+++ b/lib/bundler/cli/issue.rb
@@ -5,12 +5,12 @@ require "rbconfig"
module Bundler
class CLI::Issue
def run
- Bundler.ui.info <<-EOS.gsub(/^ {8}/, "")
+ Bundler.ui.info <<~EOS
Did you find an issue with Bundler? Before filing a new issue,
be sure to check out these resources:
1. Check out our troubleshooting guide for quick fixes to common issues:
- https://github.com/rubygems/rubygems/blob/master/bundler/doc/TROUBLESHOOTING.md
+ https://github.com/ruby/rubygems/blob/master/doc/bundler/TROUBLESHOOTING.md
2. Instructions for common Bundler uses can be found on the documentation
site: https://bundler.io/
@@ -22,7 +22,7 @@ module Bundler
still aren't working the way you expect them to, please let us know so
that we can diagnose and help fix the problem you're having, by filling
in the new issue form located at
- https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
+ https://github.com/ruby/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
and copy and pasting the information below.
EOS
@@ -34,8 +34,8 @@ module Bundler
end
def doctor
- require_relative "doctor"
- Bundler::CLI::Doctor.new({}).run
+ require_relative "doctor/diagnose"
+ Bundler::CLI::Doctor::Diagnose.new({}).run
end
end
end
diff --git a/lib/bundler/cli/list.rb b/lib/bundler/cli/list.rb
index f56bf5b86a..6a467f45a9 100644
--- a/lib/bundler/cli/list.rb
+++ b/lib/bundler/cli/list.rb
@@ -1,11 +1,14 @@
# frozen_string_literal: true
+require "json"
+
module Bundler
class CLI::List
def initialize(options)
@options = options
@without_group = options["without-group"].map(&:to_sym)
@only_group = options["only-group"].map(&:to_sym)
+ @format = options["format"]
end
def run
@@ -25,6 +28,36 @@ module Bundler
end
end.reject {|s| s.name == "bundler" }.sort_by(&:name)
+ case @format
+ when "json"
+ print_json(specs: specs)
+ when nil
+ print_human(specs: specs)
+ else
+ raise InvalidOption, "Unknown option`--format=#{@format}`. Supported formats: `json`"
+ end
+ end
+
+ private
+
+ def print_json(specs:)
+ gems = if @options["name-only"]
+ specs.map {|s| { name: s.name } }
+ else
+ specs.map do |s|
+ {
+ name: s.name,
+ version: s.version.to_s,
+ git_version: s.git_version&.strip,
+ }.tap do |h|
+ h[:path] = s.full_gem_path if @options["paths"]
+ end
+ end
+ end
+ Bundler.ui.info({ gems: gems }.to_json)
+ end
+
+ def print_human(specs:)
return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
@@ -37,8 +70,6 @@ module Bundler
Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
end
- private
-
def verify_group_exists(groups)
(@without_group + @only_group).each do |group|
raise InvalidOption, "`#{group}` group could not be found." unless groups.include?(group)
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index cb3ed27138..2f78868936 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -14,9 +14,11 @@ module Bundler
exit 1
end
+ check_for_conflicting_options
+
print = options[:print]
- previous_ui_level = Bundler.ui.level
- Bundler.ui.level = "silent" if print
+ previous_output_stream = Bundler.ui.output_stream
+ Bundler.ui.output_stream = :stderr if print
Bundler::Fetcher.disable_endpoint = options["full-index"]
@@ -26,45 +28,67 @@ module Bundler
if update.is_a?(Array) # unlocking specific gems
Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
- update = { :gems => update, :conservative => conservative }
+ update = { gems: update, conservative: conservative }
elsif update && conservative
- update = { :conservative => conservative }
+ update = { conservative: conservative }
elsif update && bundler
- update = { :bundler => bundler }
+ update = { bundler: bundler }
end
- definition = Bundler.definition(update)
- Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
+ Bundler.settings.temporary(frozen: false) do
+ definition = Bundler.definition(update, Bundler.default_lockfile)
+ definition.add_checksums if options["add-checksums"]
- options["remove-platform"].each do |platform|
- definition.remove_platform(platform)
- end
+ Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
- options["add-platform"].each do |platform_string|
- platform = Gem::Platform.new(platform_string)
- if platform.to_s == "unknown"
- Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
- "and adding it will likely lead to resolution errors"
+ options["remove-platform"].each do |platform_string|
+ platform = Gem::Platform.new(platform_string)
+ definition.remove_platform(platform)
end
- definition.add_platform(platform)
- end
- if definition.platforms.empty?
- raise InvalidOption, "Removing all platforms from the bundle is not allowed"
+ options["add-platform"].each do |platform_string|
+ platform = Gem::Platform.new(platform_string)
+ if platform.to_s == "unknown"
+ Bundler.ui.error "The platform `#{platform_string}` is unknown to RubyGems and can't be added to the lockfile."
+ exit 1
+ end
+ definition.add_platform(platform)
+ end
+
+ if definition.platforms.empty?
+ raise InvalidOption, "Removing all platforms from the bundle is not allowed"
+ end
+
+ definition.remotely! unless options[:local]
+
+ if options["normalize-platforms"]
+ definition.normalize_platforms
+ end
+
+ if print
+ puts definition.to_lock
+ else
+ file = options[:lockfile]
+ file = file ? Pathname.new(file).expand_path : Bundler.default_lockfile
+
+ puts "Writing lockfile to #{file}"
+ definition.write_lock(file, false)
+ end
end
- definition.resolve_remotely! unless options[:local]
+ Bundler.ui.output_stream = previous_output_stream
+ end
+
+ private
- if print
- puts definition.to_lock
- else
- file = options[:lockfile]
- file = file ? File.expand_path(file) : Bundler.default_lockfile
- puts "Writing lockfile to #{file}"
- definition.lock(file)
+ def check_for_conflicting_options
+ if options["normalize-platforms"] && options["add-platform"].any?
+ raise InvalidOption, "--normalize-platforms can't be used with --add-platform"
end
- Bundler.ui.level = previous_ui_level
+ if options["normalize-platforms"] && options["remove-platform"].any?
+ raise InvalidOption, "--normalize-platforms can't be used with --remove-platform"
+ end
end
end
end
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb
index 8522ec92d6..f24693b843 100644
--- a/lib/bundler/cli/open.rb
+++ b/lib/bundler/cli/open.rb
@@ -18,13 +18,11 @@ module Bundler
Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist."
else
root_path = spec.full_gem_path
- Dir.chdir(root_path) do
- require "shellwords"
- command = Shellwords.split(editor) << File.join([root_path, path].compact)
- Bundler.with_original_env do
- system(*command)
- end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
- end
+ require "shellwords"
+ command = Shellwords.split(editor) << File.join([root_path, path].compact)
+ Bundler.with_original_env do
+ system(*command, { chdir: root_path })
+ end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
end
end
end
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 68c701aefb..465e56ada2 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -26,13 +26,18 @@ module Bundler
def run
check_for_deployment_mode!
- gems.each do |gem_name|
- Bundler::CLI::Common.select_spec(gem_name)
- end
+ Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
+ Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
Bundler.definition.validate_runtime!
current_specs = Bundler.ui.silence { Bundler.definition.resolve }
+ gems.each do |gem_name|
+ if current_specs[gem_name].empty?
+ raise GemNotFound, "Could not find gem '#{gem_name}'."
+ end
+ end
+
current_dependencies = Bundler.ui.silence do
Bundler.load.dependencies.map {|dep| [dep.name, dep] }.to_h
end
@@ -41,12 +46,12 @@ module Bundler
# We're doing a full update
Bundler.definition(true)
else
- Bundler.definition(:gems => gems, :sources => sources)
+ Bundler.definition(gems: gems, sources: sources)
end
Bundler::CLI::Common.configure_gem_version_promoter(
Bundler.definition,
- options.merge(:strict => @strict)
+ options.merge(strict: @strict)
)
definition_resolution = proc do
@@ -54,7 +59,7 @@ module Bundler
end
if options[:parseable]
- Bundler.ui.silence(&definition_resolution)
+ Bundler.ui.progress(&definition_resolution)
else
definition_resolution.call
end
@@ -90,35 +95,33 @@ module Bundler
end
outdated_gems << {
- :active_spec => active_spec,
- :current_spec => current_spec,
- :dependency => dependency,
- :groups => groups,
+ active_spec: active_spec,
+ current_spec: current_spec,
+ dependency: dependency,
+ groups: groups,
}
end
- if outdated_gems.empty?
+ relevant_outdated_gems = if options_include_groups
+ outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
+ contains_group = groups.split(", ").include?(options[:group])
+ next unless options[:groups] || contains_group
+
+ gems
+ end.compact
+ else
+ outdated_gems
+ end
+
+ if relevant_outdated_gems.empty?
unless options[:parseable]
Bundler.ui.info(nothing_outdated_message)
end
else
- if options_include_groups
- relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
- contains_group = groups.split(", ").include?(options[:group])
- next unless options[:groups] || contains_group
-
- gems
- end.compact
-
- if options[:parseable]
- print_gems(relevant_outdated_gems)
- else
- print_gems_table(relevant_outdated_gems)
- end
- elsif options[:parseable]
- print_gems(outdated_gems)
+ if options[:parseable]
+ print_gems(relevant_outdated_gems)
else
- print_gems_table(outdated_gems)
+ print_gems_table(relevant_outdated_gems)
end
exit 1
@@ -155,7 +158,7 @@ module Bundler
return active_spec if strict
- active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.installable_on_platform?(current_spec.platform) }.sort_by(&:version)
if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
end
@@ -199,7 +202,15 @@ module Bundler
end
spec_outdated_info = "#{active_spec.name} (newest #{spec_version}, " \
- "installed #{current_version}#{dependency_version})"
+ "installed #{current_version}#{dependency_version}"
+
+ release_date = release_date_for(active_spec)
+ spec_outdated_info += ", released #{release_date}" unless release_date.empty?
+
+ remaining = cooldown_days_remaining(active_spec)
+ spec_outdated_info += ", in cooldown for #{remaining} more day#{"s" if remaining > 1}" if remaining
+
+ spec_outdated_info += ")"
output_message = if options[:parseable]
spec_outdated_info.to_s
@@ -215,13 +226,25 @@ module Bundler
def gem_column_for(current_spec, active_spec, dependency, groups)
current_version = "#{current_spec.version}#{current_spec.git_version}"
spec_version = "#{active_spec.version}#{active_spec.git_version}"
+ remaining = cooldown_days_remaining(active_spec)
+ spec_version += " (cooldown #{remaining}d)" if remaining
dependency = dependency.requirement if dependency
ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s]
+ ret_val << release_date_for(active_spec)
ret_val << loaded_from_for(active_spec).to_s if Bundler.ui.debug?
ret_val
end
+ def cooldown_days_remaining(spec, now = Time.now)
+ return nil unless spec.respond_to?(:created_at) && spec.created_at
+ return nil unless spec.respond_to?(:remote) && spec.remote
+ days = spec.remote.effective_cooldown
+ return nil if days.nil? || days <= 0
+ remaining = days - ((now - spec.created_at) / 86_400.0)
+ remaining > 0 ? remaining.ceil : nil
+ end
+
def check_for_deployment_mode!
return unless Bundler.frozen_bundle?
suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
@@ -283,11 +306,28 @@ module Bundler
end
def table_header
- header = ["Gem", "Current", "Latest", "Requested", "Groups"]
+ header = ["Gem", "Current", "Latest", "Requested", "Groups", "Release Date"]
header << "Path" if Bundler.ui.debug?
header
end
+ def release_date_for(spec)
+ return "" unless spec.respond_to?(:date)
+
+ date = spec.date
+ return "" unless date
+
+ return "" unless Gem.const_defined?(:DEFAULT_SOURCE_DATE_EPOCH)
+ default_date = Time.at(Gem::DEFAULT_SOURCE_DATE_EPOCH).utc
+ default_date = Time.utc(default_date.year, default_date.month, default_date.day)
+
+ date = date.utc if date.respond_to?(:utc)
+
+ return "" if date == default_date
+
+ date.strftime("%Y-%m-%d")
+ end
+
def justify(row, sizes)
row.each_with_index.map do |element, index|
element.ljust(sizes[index])
diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb
index fe3f4412fa..32fa660fe0 100644
--- a/lib/bundler/cli/plugin.rb
+++ b/lib/bundler/cli/plugin.rb
@@ -5,21 +5,20 @@ module Bundler
class CLI::Plugin < Thor
desc "install PLUGINS", "Install the plugin from the source"
long_desc <<-D
- Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git (for remote repos) or --local_git (for local repos). If no sources are provided, it uses Gem.sources
+ Install plugins either from the rubygems source provided (with --source option), from a git source provided with --git, or a local path provided with --path. If no sources are provided, it uses Gem.sources
D
- method_option "source", :type => :string, :default => nil, :banner =>
- "URL of the RubyGems source to fetch the plugin from"
- method_option "version", :type => :string, :default => nil, :banner =>
- "The version of the plugin to fetch"
- method_option "git", :type => :string, :default => nil, :banner =>
- "URL of the git repo to fetch from"
- method_option "local_git", :type => :string, :default => nil, :banner =>
- "Path of the local git repo to fetch from"
- method_option "branch", :type => :string, :default => nil, :banner =>
- "The git branch to checkout"
- method_option "ref", :type => :string, :default => nil, :banner =>
- "The git revision to check out"
+ method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from"
+ method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch"
+ method_option "git", type: :string, default: nil, banner: "URL of the git repo to fetch from"
+ method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (removed)"
+ method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
+ method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
+ method_option "path", type: :string, default: nil, banner: "Path of a local gem to directly use"
def install(*plugins)
+ if options.key?(:local_git)
+ raise InvalidOption, "--local_git has been removed, use --git"
+ end
+
Bundler::Plugin.install(plugins, options)
end
@@ -27,8 +26,7 @@ module Bundler
long_desc <<-D
Uninstall given list of plugins. To uninstall all the plugins, use -all option.
D
- method_option "all", :type => :boolean, :default => nil, :banner =>
- "Uninstall all the installed plugins. If no plugin is installed, then it does nothing."
+ method_option "all", type: :boolean, default: nil, banner: "Uninstall all the installed plugins. If no plugin is installed, then it does nothing."
def uninstall(*plugins)
Bundler::Plugin.uninstall(plugins, options)
end
diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb
index d6654f8053..f463f0bce8 100644
--- a/lib/bundler/cli/pristine.rb
+++ b/lib/bundler/cli/pristine.rb
@@ -11,41 +11,53 @@ module Bundler
definition = Bundler.definition
definition.validate_runtime!
installer = Bundler::Installer.new(Bundler.root, definition)
+ git_sources = []
- Bundler.load.specs.each do |spec|
- next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
- next if !@gems.empty? && !@gems.include?(spec.name)
+ ProcessLock.lock do
+ installed_specs = definition.specs.reject do |spec|
+ next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
+ next if !@gems.empty? && !@gems.include?(spec.name)
- gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
- gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
+ gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
+ gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
- case source = spec.source
- when Source::Rubygems
- cached_gem = spec.cache_file
- unless File.exist?(cached_gem)
- Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
- next
- end
+ case source = spec.source
+ when Source::Rubygems
+ cached_gem = spec.cache_file
+ unless File.exist?(cached_gem)
+ Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
+ next
+ end
+
+ FileUtils.rm_rf spec.full_gem_path
+ when Source::Git
+ if source.local?
+ Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is locally overridden.")
+ next
+ end
- FileUtils.rm_rf spec.full_gem_path
- when Source::Git
- if source.local?
- Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is locally overridden.")
+ source.remote!
+ if extension_cache_path = source.extension_cache_path(spec)
+ FileUtils.rm_rf extension_cache_path
+ end
+ FileUtils.rm_rf spec.extension_dir
+ FileUtils.rm_rf spec.full_gem_path
+
+ next if git_sources.include?(source)
+ git_sources << source
+ else
+ Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
next
end
- source.remote!
- if extension_cache_path = source.extension_cache_path(spec)
- FileUtils.rm_rf extension_cache_path
- end
- FileUtils.rm_rf spec.extension_dir
- FileUtils.rm_rf spec.full_gem_path
- else
- Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
- next
- end
-
- Bundler::GemInstaller.new(spec, installer, false, 0, true).install_from_spec
+ true
+ end.map(&:name)
+
+ jobs = Bundler.settings.installation_parallelization
+ pristine_count = definition.specs.count - installed_specs.count
+ # allow a pristining a single gem to skip the parallel worker
+ jobs = [jobs, pristine_count].min
+ ParallelInstaller.call(installer, definition.specs, jobs, false, true, skip: installed_specs)
end
end
end
diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb
index 2df13db1fa..67fdcc797e 100644
--- a/lib/bundler/cli/show.rb
+++ b/lib/bundler/cli/show.rb
@@ -6,7 +6,7 @@ module Bundler
def initialize(options, gem_name)
@options = options
@gem_name = gem_name
- @verbose = options[:verbose] || options[:outdated]
+ @verbose = options[:verbose]
@latest_specs = fetch_latest_specs if @verbose
end
@@ -24,7 +24,7 @@ module Bundler
return unless spec
path = spec.full_gem_path
unless File.directory?(path)
- return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}"
+ return Bundler.ui.warn "The gem #{gem_name} is missing. It should be installed at #{path}, but was not found"
end
end
return Bundler.ui.info(path)
@@ -40,8 +40,8 @@ module Bundler
desc = " * #{s.name} (#{s.version}#{s.git_version})"
if @verbose
latest = latest_specs.find {|l| l.name == s.name }
- Bundler.ui.info <<-END.gsub(/^ +/, "")
- #{desc}
+ Bundler.ui.info <<~END
+ #{desc.lstrip}
\tSummary: #{s.summary || "No description available."}
\tHomepage: #{s.homepage || "No website available."}
\tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"}
@@ -57,12 +57,8 @@ module Bundler
def fetch_latest_specs
definition = Bundler.definition(true)
- if options[:outdated]
- Bundler.ui.info "Fetching remote specs for outdated check...\n\n"
- Bundler.ui.silence { definition.resolve_remotely! }
- else
- definition.resolve_with_cache!
- end
+ Bundler.ui.info "Fetching remote specs for outdated check...\n\n"
+ Bundler.ui.silence { definition.remotely! }
Bundler.reset!
definition.specs
end
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index b49182655b..d92ffd995f 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -15,7 +15,7 @@ module Bundler
Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
- Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
+ Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.settings[:plugins]
sources = Array(options[:source])
groups = Array(options[:group]).map(&:to_sym)
@@ -23,10 +23,10 @@ module Bundler
full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
if full_update && !options[:all]
- if Bundler.feature_flag.update_requires_all_flag?
+ if Bundler.settings[:update_requires_all_flag]
raise InvalidOption, "To update everything, pass the `--all` flag."
end
- SharedHelpers.major_deprecation 3, "Pass --all to `bundle update` to update everything"
+ SharedHelpers.feature_deprecated! "Pass --all to `bundle update` to update everything"
elsif !full_update && options[:all]
raise InvalidOption, "Cannot specify --all along with specific options."
end
@@ -35,7 +35,7 @@ module Bundler
if full_update
if conservative
- Bundler.definition(:conservative => conservative)
+ Bundler.definition(conservative: conservative)
else
Bundler.definition(true)
end
@@ -51,9 +51,9 @@ module Bundler
gems.concat(deps.map(&:name))
end
- Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
- :conservative => conservative,
- :bundler => update_bundler)
+ Bundler.definition(gems: gems, sources: sources, ruby: options[:ruby],
+ conservative: conservative,
+ bundler: update_bundler)
end
Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -63,14 +63,17 @@ module Bundler
opts = options.dup
opts["update"] = true
opts["local"] = options[:local]
+ opts["force"] = options[:redownload] if options[:redownload]
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
+ Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
+ Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
Bundler.definition.validate_runtime!
if locked_gems = Bundler.definition.locked_gems
previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.identifier }
+ h[s.name] = { spec: s, version: s.version, source: s.source.identifier }
h
end
end
@@ -91,7 +94,7 @@ module Bundler
locked_spec = locked_info[:spec]
new_spec = Bundler.definition.specs[name].first
unless new_spec
- unless locked_spec.match_platform(Bundler.local_platform)
+ unless locked_spec.installable_on_platform?(Bundler.local_platform)
Bundler.ui.warn "Bundler attempted to update #{name} but it was not considered because it is for a different platform from the current one"
end
diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb
deleted file mode 100644
index 5c09e00995..0000000000
--- a/lib/bundler/cli/viz.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Viz
- attr_reader :options, :gem_name
- def initialize(options)
- @options = options
- end
-
- def run
- # make sure we get the right `graphviz`. There is also a `graphviz`
- # gem we're not built to support
- gem "ruby-graphviz"
- require "graphviz"
-
- options[:without] = options[:without].join(":").tr(" ", ":").split(":")
- output_file = File.expand_path(options[:file])
-
- graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format], options[:without])
- graph.viz
- rescue LoadError => e
- Bundler.ui.error e.inspect
- Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
- Bundler.ui.warn "`gem install ruby-graphviz`"
- rescue StandardError => e
- raise unless e.message.to_s.include?("GraphViz not installed or dot not in PATH")
- Bundler.ui.error e.message
- Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`."
- end
- end
-end
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb
index 127a50e810..6865e30dbc 100644
--- a/lib/bundler/compact_index_client.rb
+++ b/lib/bundler/compact_index_client.rb
@@ -1,11 +1,42 @@
# frozen_string_literal: true
-require "pathname"
require "set"
module Bundler
+ # The CompactIndexClient is responsible for fetching and parsing the compact index.
+ #
+ # The compact index is a set of caching optimized files that are used to fetch gem information.
+ # The files are:
+ # - names: a list of all gem names
+ # - versions: a list of all gem versions
+ # - info/[gem]: a list of all versions of a gem
+ #
+ # The client is instantiated with:
+ # - `directory`: the root directory where the cache files are stored.
+ # - `fetcher`: (optional) an object that responds to #call(uri_path, headers) and returns an http response.
+ # If the `fetcher` is not provided, the client will only read cached files from disk.
+ #
+ # The client is organized into:
+ # - `Updater`: updates the cached files on disk using the fetcher.
+ # - `Cache`: calls the updater, caches files, read and return them from disk
+ # - `Parser`: parses the compact index file data
+ # - `CacheFile`: a concurrency safe file reader/writer that verifies checksums
+ #
+ # The client is intended to optimize memory usage and performance.
+ # It is called 100s or 1000s of times, parsing files with hundreds of thousands of lines.
+ # It may be called concurrently without global interpreter lock in some Rubies.
+ # As a result, some methods may look more complex than necessary to save memory or time.
class CompactIndexClient
+ SUPPORTED_DIGESTS = { "sha-256" => :SHA256 }.freeze
DEBUG_MUTEX = Thread::Mutex.new
+
+ # info returns an Array of INFO Arrays. Each INFO Array has the following indices:
+ INFO_NAME = 0
+ INFO_VERSION = 1
+ INFO_PLATFORM = 2
+ INFO_DEPS = 3
+ INFO_REQS = 4
+
def self.debug
return unless ENV["DEBUG_COMPACT_INDEX"]
DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") }
@@ -14,106 +45,48 @@ module Bundler
class Error < StandardError; end
require_relative "compact_index_client/cache"
+ require_relative "compact_index_client/cache_file"
+ require_relative "compact_index_client/parser"
require_relative "compact_index_client/updater"
- attr_reader :directory
-
- def initialize(directory, fetcher)
- @directory = Pathname.new(directory)
- @updater = Updater.new(fetcher)
- @cache = Cache.new(@directory)
- @endpoints = Set.new
- @info_checksums_by_name = {}
- @parsed_checksums = false
- @mutex = Thread::Mutex.new
- end
-
- def execution_mode=(block)
- Bundler::CompactIndexClient.debug { "execution_mode=" }
- @endpoints = Set.new
-
- @execution_mode = block
- end
-
- # @return [Lambda] A lambda that takes an array of inputs and a block, and
- # maps the inputs with the block in parallel.
- #
- def execution_mode
- @execution_mode || sequentially
- end
-
- def sequential_execution_mode!
- self.execution_mode = sequentially
- end
-
- def sequentially
- @sequentially ||= lambda do |inputs, &blk|
- inputs.map(&blk)
- end
+ def initialize(directory, fetcher = nil)
+ @cache = Cache.new(directory, fetcher)
+ @parser = Parser.new(@cache)
end
def names
- Bundler::CompactIndexClient.debug { "/names" }
- update(@cache.names_path, "names")
- @cache.names
+ Bundler::CompactIndexClient.debug { "names" }
+ @parser.names
end
def versions
- Bundler::CompactIndexClient.debug { "/versions" }
- update(@cache.versions_path, "versions")
- versions, @info_checksums_by_name = @cache.versions
- versions
+ Bundler::CompactIndexClient.debug { "versions" }
+ @parser.versions
end
def dependencies(names)
Bundler::CompactIndexClient.debug { "dependencies(#{names})" }
- execution_mode.call(names) do |name|
- update_info(name)
- @cache.dependencies(name).map {|d| d.unshift(name) }
- end.flatten(1)
+ names.map {|name| info(name) }
end
- def update_and_parse_checksums!
- Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
- return @info_checksums_by_name if @parsed_checksums
- update(@cache.versions_path, "versions")
- @info_checksums_by_name = @cache.checksums
- @parsed_checksums = true
- end
-
- private
-
- def update(local_path, remote_path)
- Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
- unless synchronize { @endpoints.add?(remote_path) }
- Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
- return
- end
- @updater.update(local_path, url(remote_path))
+ def info(name)
+ Bundler::CompactIndexClient.debug { "info(#{name})" }
+ @parser.info(name)
end
- def update_info(name)
- Bundler::CompactIndexClient.debug { "update_info(#{name})" }
- path = @cache.info_path(name)
- checksum = @updater.checksum_for_file(path)
- unless existing = @info_checksums_by_name[name]
- Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" }
- return
- end
- if checksum == existing
- Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since the versions checksum matches the local checksum" }
- return
- end
- Bundler::CompactIndexClient.debug { "updating info for #{name} since the versions checksum #{existing} != the local checksum #{checksum}" }
- update(path, "info/#{name}")
+ def latest_version(name)
+ Bundler::CompactIndexClient.debug { "latest_version(#{name})" }
+ @parser.info(name).map {|d| Gem::Version.new(d[INFO_VERSION]) }.max
end
- def url(path)
- path
+ def available?
+ Bundler::CompactIndexClient.debug { "available?" }
+ @parser.available?
end
- def synchronize
- @mutex.synchronize { yield }
+ def reset!
+ Bundler::CompactIndexClient.debug { "reset!" }
+ @cache.reset!
end
end
end
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb
index 0b43581c11..3bae6c9efd 100644
--- a/lib/bundler/compact_index_client/cache.rb
+++ b/lib/bundler/compact_index_client/cache.rb
@@ -1,100 +1,95 @@
# frozen_string_literal: true
-require_relative "gem_parser"
+require "rubygems/resolver/api_set/gem_parser"
module Bundler
class CompactIndexClient
class Cache
attr_reader :directory
- def initialize(directory)
+ def initialize(directory, fetcher = nil)
@directory = Pathname.new(directory).expand_path
- info_roots.each do |dir|
- SharedHelpers.filesystem_access(dir) do
- FileUtils.mkdir_p(dir)
- end
- end
- end
+ @updater = Updater.new(fetcher) if fetcher
+ @mutex = Thread::Mutex.new
+ @endpoints = Set.new
- def names
- lines(names_path)
+ @info_root = mkdir("info")
+ @special_characters_info_root = mkdir("info-special-characters")
+ @info_etag_root = mkdir("info-etags")
end
- def names_path
- directory.join("names")
+ def names
+ fetch("names", names_path, names_etag_path)
end
def versions
- versions_by_name = Hash.new {|hash, key| hash[key] = [] }
- info_checksums_by_name = {}
-
- lines(versions_path).each do |line|
- name, versions_string, info_checksum = line.split(" ", 3)
- info_checksums_by_name[name] = info_checksum || ""
- versions_string.split(",").each do |version|
- if version.start_with?("-")
- version = version[1..-1].split("-", 2).unshift(name)
- versions_by_name[name].delete(version)
- else
- version = version.split("-", 2).unshift(name)
- versions_by_name[name] << version
- end
- end
- end
-
- [versions_by_name, info_checksums_by_name]
- end
-
- def versions_path
- directory.join("versions")
+ fetch("versions", versions_path, versions_etag_path)
end
- def checksums
- checksums = {}
+ def info(name, remote_checksum = nil)
+ path = info_path(name)
- lines(versions_path).each do |line|
- name, _, checksum = line.split(" ", 3)
- checksums[name] = checksum
+ if remote_checksum && remote_checksum != SharedHelpers.checksum_for_file(path, :MD5)
+ fetch("info/#{name}", path, info_etag_path(name))
+ else
+ Bundler::CompactIndexClient.debug { "update skipped info/#{name} (#{remote_checksum ? "versions index checksum is nil" : "versions index checksum matches local"})" }
+ read(path)
end
-
- checksums
end
- def dependencies(name)
- lines(info_path(name)).map do |line|
- parse_gem(line)
- end
+ def reset!
+ @mutex.synchronize { @endpoints.clear }
end
+ private
+
+ def names_path = directory.join("names")
+ def names_etag_path = directory.join("names.etag")
+ def versions_path = directory.join("versions")
+ def versions_etag_path = directory.join("versions.etag")
+
def info_path(name)
name = name.to_s
+ # TODO: converge this into the info_root by hashing all filenames like info_etag_path
if /[^a-z0-9_-]/.match?(name)
name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
- info_roots.last.join(name)
+ @special_characters_info_root.join(name)
else
- info_roots.first.join(name)
+ @info_root.join(name)
end
end
- private
+ def info_etag_path(name)
+ name = name.to_s
+ @info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
+ end
+
+ def mkdir(name)
+ directory.join(name).tap do |dir|
+ SharedHelpers.filesystem_access(dir) do
+ FileUtils.mkdir_p(dir)
+ end
+ end
+ end
+
+ def fetch(remote_path, path, etag_path)
+ if already_fetched?(remote_path)
+ Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
+ else
+ Bundler::CompactIndexClient.debug { "fetching #{remote_path}" }
+ @updater&.update(remote_path, path, etag_path)
+ end
- def lines(path)
- return [] unless path.file?
- lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
- header = lines.index("---")
- header ? lines[header + 1..-1] : lines
+ read(path)
end
- def parse_gem(line)
- @dependency_parser ||= GemParser.new
- @dependency_parser.parse(line)
+ def already_fetched?(remote_path)
+ @mutex.synchronize { !@endpoints.add?(remote_path) }
end
- def info_roots
- [
- directory.join("info"),
- directory.join("info-special-characters"),
- ]
+ def read(path)
+ return unless path.file?
+ SharedHelpers.filesystem_access(path, :read, &:read)
end
end
end
diff --git a/lib/bundler/compact_index_client/cache_file.rb b/lib/bundler/compact_index_client/cache_file.rb
new file mode 100644
index 0000000000..299d683438
--- /dev/null
+++ b/lib/bundler/compact_index_client/cache_file.rb
@@ -0,0 +1,148 @@
+# frozen_string_literal: true
+
+require_relative "../vendored_fileutils"
+require "rubygems/package"
+
+module Bundler
+ class CompactIndexClient
+ # write cache files in a way that is robust to concurrent modifications
+ # if digests are given, the checksums will be verified
+ class CacheFile
+ DEFAULT_FILE_MODE = 0o644
+ private_constant :DEFAULT_FILE_MODE
+
+ class Error < RuntimeError; end
+ class ClosedError < Error; end
+
+ class DigestMismatchError < Error
+ def initialize(digests, expected_digests)
+ super "Calculated checksums #{digests.inspect} did not match expected #{expected_digests.inspect}."
+ end
+ end
+
+ # Initialize with a copy of the original file, then yield the instance.
+ def self.copy(path, &block)
+ new(path) do |file|
+ file.initialize_digests
+
+ SharedHelpers.filesystem_access(path, :read) do
+ path.open("rb") do |s|
+ file.open {|f| IO.copy_stream(s, f) }
+ end
+ end
+
+ yield file
+ end
+ end
+
+ # Write data to a temp file, then replace the original file with it verifying the digests if given.
+ def self.write(path, data, digests = nil)
+ return unless data
+ new(path) do |file|
+ file.digests = digests
+ file.write(data)
+ end
+ end
+
+ attr_reader :original_path, :path
+
+ def initialize(original_path, &block)
+ @original_path = original_path
+ @perm = original_path.file? ? original_path.stat.mode : DEFAULT_FILE_MODE
+ @path = original_path.sub(/$/, ".#{$$}.tmp")
+ return unless block_given?
+ begin
+ yield self
+ ensure
+ close
+ end
+ end
+
+ def size
+ path.size
+ end
+
+ # initialize the digests using CompactIndexClient::SUPPORTED_DIGESTS, or a subset based on keys.
+ def initialize_digests(keys = nil)
+ @digests = keys ? SUPPORTED_DIGESTS.slice(*keys) : SUPPORTED_DIGESTS.dup
+ @digests.transform_values! {|algo_class| SharedHelpers.digest(algo_class).new }
+ end
+
+ # reset the digests so they don't contain any previously read data
+ def reset_digests
+ @digests&.each_value(&:reset)
+ end
+
+ # set the digests that will be verified at the end
+ def digests=(expected_digests)
+ @expected_digests = expected_digests
+
+ if @expected_digests.nil?
+ @digests = nil
+ elsif @digests
+ @digests = @digests.slice(*@expected_digests.keys)
+ else
+ initialize_digests(@expected_digests.keys)
+ end
+ end
+
+ def digests?
+ @digests&.any?
+ end
+
+ # Open the temp file for writing, reusing original permissions, yielding the IO object.
+ def open(write_mode = "wb", perm = @perm, &block)
+ raise ClosedError, "Cannot reopen closed file" if @closed
+ SharedHelpers.filesystem_access(path, :write) do
+ path.open(write_mode, perm) do |f|
+ yield digests? ? Gem::Package::DigestIO.new(f, @digests) : f
+ end
+ end
+ end
+
+ # Returns false without appending when no digests since appending is too error prone to do without digests.
+ def append(data)
+ return false unless digests?
+ open("a") {|f| f.write data }
+ verify && commit
+ end
+
+ def write(data)
+ reset_digests
+ open {|f| f.write data }
+ commit!
+ end
+
+ def commit!
+ verify || raise(DigestMismatchError.new(@base64digests, @expected_digests))
+ commit
+ end
+
+ # Verify the digests, returning true on match, false on mismatch.
+ def verify
+ return true unless @expected_digests && digests?
+ @base64digests = @digests.transform_values!(&:base64digest)
+ @digests = nil
+ @base64digests.all? {|algo, digest| @expected_digests[algo] == digest }
+ end
+
+ # Replace the original file with the temp file without verifying digests.
+ # The file is permanently closed.
+ def commit
+ raise ClosedError, "Cannot commit closed file" if @closed
+ SharedHelpers.filesystem_access(original_path, :write) do
+ FileUtils.mv(path, original_path)
+ end
+ @closed = true
+ end
+
+ # Remove the temp file without replacing the original file.
+ # The file is permanently closed.
+ def close
+ return if @closed
+ FileUtils.remove_file(path) if @path&.file?
+ @closed = true
+ end
+ end
+ end
+end
diff --git a/lib/bundler/compact_index_client/gem_parser.rb b/lib/bundler/compact_index_client/gem_parser.rb
deleted file mode 100644
index e7bf4c6001..0000000000
--- a/lib/bundler/compact_index_client/gem_parser.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CompactIndexClient
- if defined?(Gem::Resolver::APISet::GemParser)
- GemParser = Gem::Resolver::APISet::GemParser
- else
- class GemParser
- def parse(line)
- version_and_platform, rest = line.split(" ", 2)
- version, platform = version_and_platform.split("-", 2)
- dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest
- dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : []
- requirements = requirements ? requirements.map {|d| parse_dependency(d) } : []
- [version, platform, dependencies, requirements]
- end
-
- private
-
- def parse_dependency(string)
- dependency = string.split(":")
- dependency[-1] = dependency[-1].split("&") if dependency.size > 1
- dependency
- end
- end
- end
- end
-end
diff --git a/lib/bundler/compact_index_client/parser.rb b/lib/bundler/compact_index_client/parser.rb
new file mode 100644
index 0000000000..ad0d17ed4a
--- /dev/null
+++ b/lib/bundler/compact_index_client/parser.rb
@@ -0,0 +1,87 @@
+# frozen_string_literal: true
+
+module Bundler
+ class CompactIndexClient
+ class Parser
+ # `compact_index` - an object responding to #names, #versions, #info(name, checksum),
+ # returning the file contents as a string
+ def initialize(compact_index)
+ @compact_index = compact_index
+ @info_checksums = nil
+ @versions_by_name = nil
+ @available = nil
+ @gem_parser = nil
+ end
+
+ def names
+ lines(@compact_index.names)
+ end
+
+ def versions
+ @versions_by_name ||= Hash.new {|hash, key| hash[key] = [] }
+ @info_checksums = {}
+
+ lines(@compact_index.versions).each do |line|
+ name, versions_string, checksum = line.split(" ", 3)
+ @info_checksums[name] = checksum || ""
+ versions_string.split(",") do |version|
+ delete = version.delete_prefix!("-")
+ version = version.split("-", 2).unshift(name)
+ if delete
+ @versions_by_name[name].delete(version)
+ else
+ @versions_by_name[name] << version
+ end
+ end
+ end
+
+ @versions_by_name
+ end
+
+ def info(name)
+ data = @compact_index.info(name, info_checksums[name])
+ lines(data).map {|line| gem_parser.parse(line).unshift(name) }
+ end
+
+ def available?
+ return @available unless @available.nil?
+ @available = !info_checksums.empty?
+ end
+
+ private
+
+ def info_checksums
+ @info_checksums ||= lines(@compact_index.versions).each_with_object({}) do |line, checksums|
+ parse_version_checksum(line, checksums)
+ end
+ end
+
+ def lines(data)
+ return [] if data.nil? || data.empty?
+ lines = data.split("\n")
+ header = lines.index("---")
+ header ? lines[header + 1..-1] : lines
+ end
+
+ def gem_parser
+ @gem_parser ||= Gem::Resolver::APISet::GemParser.new
+ end
+
+ # This is mostly the same as `split(" ", 3)` but it avoids allocating extra objects.
+ # This method gets called at least once for every gem when parsing versions.
+ def parse_version_checksum(line, checksums)
+ return unless (name_end = line.index(" ")) # Artifactory bug causes blank lines in artifactor index files
+ checksum_start = line.index(" ", name_end + 1)
+ return unless checksum_start
+ checksum_start += 1
+
+ checksum_end = line.size - checksum_start
+
+ line.freeze # allows slicing into the string to not allocate a copy of the line
+ name = line[0, name_end]
+ checksum = line[checksum_start, checksum_end]
+ checksums[name.freeze] = checksum # freeze name since it is used as a hash key
+ end
+ end
+ end
+end
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index 0f7bf9bb50..6066fdc7c4 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -1,20 +1,11 @@
# frozen_string_literal: true
-require_relative "../vendored_fileutils"
-
module Bundler
class CompactIndexClient
class Updater
- class MisMatchedChecksumError < Error
- def initialize(path, server_checksum, local_checksum)
- @path = path
- @server_checksum = server_checksum
- @local_checksum = local_checksum
- end
-
- def message
- "The checksum of /#{@path} does not match the checksum provided by the server! Something is wrong " \
- "(local checksum is #{@local_checksum.inspect}, was expecting #{@server_checksum.inspect})."
+ class MismatchedChecksumError < Error
+ def initialize(path, message)
+ super "The checksum of /#{path} does not match the checksum provided by the server! Something is wrong. #{message}"
end
end
@@ -22,95 +13,92 @@ module Bundler
@fetcher = fetcher
end
- def update(local_path, remote_path, retrying = nil)
- headers = {}
-
- local_temp_path = local_path.sub(/$/, ".#{$$}")
- local_temp_path = local_temp_path.sub(/$/, ".retrying") if retrying
- local_temp_path = local_temp_path.sub(/$/, ".tmp")
-
- # first try to fetch any new bytes on the existing file
- if retrying.nil? && local_path.file?
- copy_file local_path, local_temp_path
+ def update(remote_path, local_path, etag_path)
+ append(remote_path, local_path, etag_path) || replace(remote_path, local_path, etag_path)
+ rescue CacheFile::DigestMismatchError => e
+ raise MismatchedChecksumError.new(remote_path, e.message)
+ rescue Zlib::GzipFile::Error
+ raise Bundler::HTTPError
+ end
- headers["If-None-Match"] = etag_for(local_temp_path)
- headers["Range"] =
- if local_temp_path.size.nonzero?
- # Subtract a byte to ensure the range won't be empty.
- # Avoids 416 (Range Not Satisfiable) responses.
- "bytes=#{local_temp_path.size - 1}-"
- else
- "bytes=#{local_temp_path.size}-"
- end
- end
+ private
- response = @fetcher.call(remote_path, headers)
- return nil if response.is_a?(Net::HTTPNotModified)
+ def append(remote_path, local_path, etag_path)
+ return false unless local_path.file? && local_path.size.nonzero?
- content = response.body
+ CacheFile.copy(local_path) do |file|
+ etag = etag_path.read.tap(&:chomp!) if etag_path.file?
- etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
- correct_response = SharedHelpers.filesystem_access(local_temp_path) do
- if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
- local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
+ # Subtract a byte to ensure the range won't be empty.
+ # Avoids 416 (Range Not Satisfiable) responses.
+ response = @fetcher.call(remote_path, request_headers(etag, file.size - 1))
+ break true if response.is_a?(Gem::Net::HTTPNotModified)
- etag_for(local_temp_path) == etag
+ file.digests = parse_digests(response)
+ # server may ignore Range and return the full response
+ if response.is_a?(Gem::Net::HTTPPartialContent)
+ tail = response.body.byteslice(1..-1)
+ break false unless tail && file.append(tail)
else
- local_temp_path.open("wb") {|f| f << content }
-
- etag.length.zero? || etag_for(local_temp_path) == etag
+ file.write(response.body)
end
+ CacheFile.write(etag_path, etag_from_response(response))
+ true
end
+ end
- if correct_response
- SharedHelpers.filesystem_access(local_path) do
- FileUtils.mv(local_temp_path, local_path)
- end
- return nil
- end
-
- if retrying
- raise MisMatchedChecksumError.new(remote_path, etag, etag_for(local_temp_path))
- end
+ # request without range header to get the full file or a 304 Not Modified
+ def replace(remote_path, local_path, etag_path)
+ etag = etag_path.read.tap(&:chomp!) if etag_path.file?
+ response = @fetcher.call(remote_path, request_headers(etag))
+ return true if response.is_a?(Gem::Net::HTTPNotModified)
+ CacheFile.write(local_path, response.body, parse_digests(response))
+ CacheFile.write(etag_path, etag_from_response(response))
+ end
- update(local_path, remote_path, :retrying)
- rescue Zlib::GzipFile::Error
- raise Bundler::HTTPError
- ensure
- FileUtils.remove_file(local_temp_path) if File.exist?(local_temp_path)
+ def request_headers(etag, range_start = nil)
+ headers = {}
+ headers["Range"] = "bytes=#{range_start}-" if range_start
+ headers["If-None-Match"] = %("#{etag}") if etag
+ headers
end
- def etag_for(path)
- sum = checksum_for_file(path)
- sum ? %("#{sum}") : nil
+ def etag_for_request(etag_path)
+ etag_path.read.tap(&:chomp!) if etag_path.file?
end
- def slice_body(body, range)
- body.byteslice(range)
+ def etag_from_response(response)
+ return unless response["ETag"]
+ etag = response["ETag"].delete_prefix("W/")
+ return if etag.delete_prefix!('"') && !etag.delete_suffix!('"')
+ etag
end
- def checksum_for_file(path)
- return nil unless path.file?
- # This must use File.read instead of Digest.file().hexdigest
- # because we need to preserve \n line endings on windows when calculating
- # the checksum
- SharedHelpers.filesystem_access(path, :read) do
- SharedHelpers.digest(:MD5).hexdigest(File.read(path))
+ # Unwraps and returns a Hash of digest algorithms and base64 values
+ # according to RFC 8941 Structured Field Values for HTTP.
+ # https://www.rfc-editor.org/rfc/rfc8941#name-parsing-a-byte-sequence
+ # Ignores unsupported algorithms.
+ def parse_digests(response)
+ return unless header = response["Repr-Digest"] || response["Digest"]
+ digests = {}
+ header.split(",") do |param|
+ algorithm, value = param.split("=", 2)
+ algorithm.strip!
+ algorithm.downcase!
+ next unless SUPPORTED_DIGESTS.key?(algorithm)
+ next unless value = byte_sequence(value)
+ digests[algorithm] = value
end
+ digests.empty? ? nil : digests
end
- private
-
- def copy_file(source, dest)
- SharedHelpers.filesystem_access(source, :read) do
- File.open(source, "r") do |s|
- SharedHelpers.filesystem_access(dest, :write) do
- File.open(dest, "wb", s.stat.mode) do |f|
- IO.copy_stream(s, f)
- end
- end
- end
- end
+ # Unwrap surrounding colons (byte sequence)
+ # The wrapping characters must be matched or we return nil.
+ # Also handles quotes because right now rubygems.org sends them.
+ def byte_sequence(value)
+ return if value.delete_prefix!(":") && !value.delete_suffix!(":")
+ return if value.delete_prefix!('"') && !value.delete_suffix!('"')
+ value
end
end
end
diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb
index 8dd8a53815..9564771e78 100644
--- a/lib/bundler/constants.rb
+++ b/lib/bundler/constants.rb
@@ -1,7 +1,14 @@
# frozen_string_literal: true
+require "rbconfig"
+
module Bundler
WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
+ deprecate_constant :WINDOWS
+
FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd")
- NULL = WINDOWS ? "NUL" : "/dev/null"
+ deprecate_constant :FREEBSD
+
+ NULL = File::NULL
+ deprecate_constant :NULL
end
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index 1d2d8ff2fb..17c7655adb 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require_relative "rubygems_ext"
+
module Bundler
# Returns current version of Ruby
#
@@ -9,41 +11,28 @@ module Bundler
end
class CurrentRuby
- KNOWN_MINOR_VERSIONS = %w[
- 1.8
- 1.9
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- 3.2
- 3.3
- ].freeze
-
- KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
-
- KNOWN_PLATFORMS = %w[
- jruby
- maglev
- mingw
- mri
- mswin
- mswin64
- rbx
- ruby
- truffleruby
- windows
- x64_mingw
- ].freeze
+ ALL_RUBY_VERSIONS = [*18..27, *30..34, *40..41].freeze
+ KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
+ KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
+ PLATFORM_MAP = {
+ ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
+ mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
+ rbx: [Gem::Platform::RUBY],
+ truffleruby: [Gem::Platform::RUBY],
+ jruby: [Gem::Platform::JAVA, [18, 19]],
+ windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS],
+ # deprecated
+ mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS],
+ mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]],
+ mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
+ x64_mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
+ }.each_with_object({}) do |(platform, spec), hash|
+ hash[platform] = spec[0]
+ spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
+ end.freeze
def ruby?
- return true if Bundler::GemHelpers.generic_local_platform == Gem::Platform::RUBY
+ return true if Bundler::MatchPlatform.generic_local_platform_is_ruby?
!windows? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
end
@@ -61,7 +50,10 @@ module Bundler
end
def maglev?
- RUBY_ENGINE == "maglev"
+ removed_message =
+ "`CurrentRuby#maglev?` was removed with no replacement. Please use the " \
+ "built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
+ SharedHelpers.feature_removed!(removed_message)
end
def truffleruby?
@@ -82,11 +74,21 @@ module Bundler
RUBY_VERSION.start_with?("#{version}.")
end
- KNOWN_PLATFORMS.each do |platform|
+ PLATFORM_MAP.keys.each do |platform|
define_method(:"#{platform}_#{trimmed_version}?") do
send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
end
end
+
+ define_method(:"maglev_#{trimmed_version}?") do
+ removed_message =
+ "`CurrentRuby##{__method__}` was removed with no replacement. Please use the " \
+ "built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
+
+ SharedHelpers.feature_removed!(removed_message)
+
+ send(:"maglev?") && send(:"on_#{trimmed_version}?")
+ end
end
end
end
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 9763298504..7a95671471 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -1,24 +1,28 @@
# frozen_string_literal: true
require_relative "lockfile_parser"
+require_relative "worker"
module Bundler
class Definition
- include GemHelpers
-
class << self
# Do not create or modify a lockfile (Makes #lock a noop)
attr_accessor :no_lock
end
+ attr_writer :lockfile, :overrides
+
attr_reader(
:dependencies,
+ :locked_checksums,
:locked_deps,
:locked_gems,
+ :overrides,
:platforms,
:ruby_version,
:lockfile,
- :gemfiles
+ :gemfiles,
+ :sources
)
# Given a gemfile and lockfile creates a Bundler definition
@@ -34,7 +38,10 @@ module Bundler
raise GemfileNotFound, "#{gemfile} not found" unless gemfile.file?
- Dsl.evaluate(gemfile, lockfile, unlock)
+ Plugin.hook(Plugin::Events::GEM_BEFORE_EVAL, gemfile, lockfile)
+ Dsl.evaluate(gemfile, lockfile, unlock).tap do |definition|
+ Plugin.hook(Plugin::Events::GEM_AFTER_EVAL, definition)
+ end
end
#
@@ -55,136 +62,178 @@ module Bundler
# to be updated or true if all gems should be updated
# @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
# @param optional_groups [Array(String)] A list of optional groups
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
- if [true, false].include?(unlock)
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [], overrides = [])
+ unlock ||= {}
+
+ if unlock == true
+ @unlocking_all = true
+ strict = false
@unlocking_bundler = false
@unlocking = unlock
+ @sources_to_unlock = []
+ @unlocking_ruby = false
+ @explicit_unlocks = []
+ conservative = false
else
+ @unlocking_all = false
+ strict = unlock.delete(:strict)
@unlocking_bundler = unlock.delete(:bundler)
@unlocking = unlock.any? {|_k, v| !Array(v).empty? }
+ @sources_to_unlock = unlock.delete(:sources) || []
+ @unlocking_ruby = unlock.delete(:ruby)
+ @explicit_unlocks = unlock.delete(:gems) || []
+ conservative = unlock.delete(:conservative)
end
@dependencies = dependencies
@sources = sources
- @unlock = unlock
@optional_groups = optional_groups
- @remote = false
@prefer_local = false
@specs = nil
@ruby_version = ruby_version
@gemfiles = gemfiles
+ @overrides = overrides
@lockfile = lockfile
@lockfile_contents = String.new
+
@locked_bundler_version = nil
- @locked_ruby_version = nil
- @new_platform = nil
- @removed_platform = nil
+ @resolved_bundler_version = nil
+
+ @locked_ruby_version = nil
+ @new_platforms = []
+ @removed_platforms = []
+ @originally_invalid_platforms = []
- if lockfile && File.exist?(lockfile)
+ if lockfile_exists?
@lockfile_contents = Bundler.read_file(lockfile)
- @locked_gems = LockfileParser.new(@lockfile_contents)
+ @locked_gems = LockfileParser.new(@lockfile_contents, strict: strict)
@locked_platforms = @locked_gems.platforms
+ @most_specific_locked_platform = @locked_gems.most_specific_locked_platform
@platforms = @locked_platforms.dup
@locked_bundler_version = @locked_gems.bundler_version
@locked_ruby_version = @locked_gems.ruby_version
+ @locked_deps = @locked_gems.dependencies
+ Override.attach(@locked_gems.specs, @overrides)
@originally_locked_specs = SpecSet.new(@locked_gems.specs)
+ @originally_locked_sources = @locked_gems.sources
+ @locked_checksums = @locked_gems.checksums
- if unlock != true
- @locked_deps = @locked_gems.dependencies
- @locked_specs = @originally_locked_specs
- @locked_sources = @locked_gems.sources
- else
- @unlock = {}
- @locked_deps = {}
+ if @unlocking_all
@locked_specs = SpecSet.new([])
@locked_sources = []
+ else
+ @locked_specs = @originally_locked_specs
+ @locked_sources = @originally_locked_sources
end
- else
- @unlock = {}
- @platforms = []
- @locked_gems = nil
- @locked_deps = {}
- @locked_specs = SpecSet.new([])
- @originally_locked_specs = @locked_specs
- @locked_sources = []
- @locked_platforms = []
- end
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
- @multisource_allowed = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes? && Bundler.frozen_bundle?
+ locked_gem_sources = @originally_locked_sources.select {|s| s.is_a?(Source::Rubygems) }
+ multisource_lockfile = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes?
- if @multisource_allowed
- unless sources.aggregate_global_source?
+ if multisource_lockfile
msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
- Bundler::SharedHelpers.major_deprecation 2, msg
+ Bundler::SharedHelpers.feature_removed! msg
end
-
- @sources.merged_gem_lockfile_sections!(locked_gem_sources.first)
+ else
+ @locked_gems = nil
+ @locked_platforms = []
+ @most_specific_locked_platform = nil
+ @platforms = []
+ @locked_deps = {}
+ @locked_specs = SpecSet.new([])
+ @locked_sources = []
+ @originally_locked_specs = @locked_specs
+ @originally_locked_sources = @locked_sources
+ @locked_checksums = Bundler.settings[:lockfile_checksums]
end
- @unlock[:sources] ||= []
- @unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
+ @unlocking_ruby ||= if @ruby_version && locked_ruby_version_object
@ruby_version.diff(locked_ruby_version_object)
end
- @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
+ @unlocking ||= @unlocking_ruby ||= (!@locked_ruby_version ^ !@ruby_version)
- add_current_platform unless Bundler.frozen_bundle?
+ @current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
- converge_path_sources_to_gemspec_sources
- @path_changes = converge_paths
@source_changes = converge_sources
+ @path_changes = converge_paths
- if @unlock[:conservative]
- @unlock[:gems] ||= @dependencies.map(&:name)
+ if conservative
+ @gems_to_unlock = @explicit_unlocks.any? ? @explicit_unlocks : @dependencies.map(&:name)
else
- eager_unlock = (@unlock[:gems] || []).map {|name| Dependency.new(name, ">= 0") }
- @unlock[:gems] = @locked_specs.for(eager_unlock, false, platforms).map(&:name).uniq
+ eager_unlock = @explicit_unlocks.map {|name| Dependency.new(name, ">= 0") }
+ @gems_to_unlock = @locked_specs.for(eager_unlock, platforms).map(&:name).uniq
end
@dependency_changes = converge_dependencies
@local_changes = converge_locals
- @incomplete_lockfile = check_missing_lockfile_specs
+ check_lockfile
end
def gem_version_promoter
@gem_version_promoter ||= GemVersionPromoter.new
end
- def resolve_only_locally!
- @remote = false
+ def check!
+ # If dependencies have changed, we need to resolve remotely. Otherwise,
+ # since we'll be resolving with a single local source, we may end up
+ # locking gems under the wrong source in the lockfile, and missing lockfile
+ # checksums
+ resolve_remotely! if @dependency_changes
+
+ # Now do a local only resolve, to verify if any gems are missing locally
sources.local_only!
resolve
end
- def resolve_with_cache!
+ #
+ # Setup sources according to the given options and the state of the
+ # definition.
+ #
+ # @return [Boolean] Whether fetching remote information will be necessary or not
+ #
+ def setup_domain!(options = {})
+ prefer_local! if options[:"prefer-local"]
+
sources.cached!
+
+ if options[:add_checksums] || (!options[:local] && install_needed?)
+ sources.remote!
+ true
+ else
+ Bundler.settings.set_command_option(:jobs, 1) unless install_needed? # to avoid the overhead of Bundler::Worker
+ sources.local!
+ false
+ end
+ end
+
+ def resolve_with_cache!
+ with_cache!
+
resolve
end
+ def with_cache!
+ sources.local!
+ sources.cached!
+ end
+
def resolve_remotely!
- @remote = true
- sources.remote!
+ remotely!
+
resolve
end
- def resolution_mode=(options)
- if options["local"]
- @remote = false
- else
- @remote = true
- @prefer_local = options["prefer-local"]
- end
+ def remotely!
+ sources.cached!
+ sources.remote!
end
- def setup_sources_for_resolve
- if @remote == false
- sources.cached!
- else
- sources.remote!
- end
+ def prefer_local!
+ @prefer_local = true
+
+ sources.prefer_local!
end
# For given dependency list returns a SpecSet with Gemspec of all the required
@@ -206,7 +255,8 @@ module Bundler
end
def missing_specs
- resolve.materialize(requested_dependencies).missing_specs
+ preload_git_sources
+ resolve.missing_specs_for(requested_dependencies)
end
def missing_specs?
@@ -217,8 +267,9 @@ module Bundler
rescue BundlerError => e
@resolve = nil
@resolver = nil
+ @resolution_base = nil
+ @source_requirements = nil
@specs = nil
- @gem_version_promoter = nil
Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
true
@@ -233,11 +284,25 @@ module Bundler
end
def current_dependencies
+ filter_relevant(dependencies)
+ end
+
+ def current_locked_dependencies
+ filter_relevant(locked_dependencies)
+ end
+
+ def filter_relevant(dependencies)
dependencies.select do |d|
- d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
+ relevant_deps?(d)
end
end
+ def relevant_deps?(dep)
+ platforms_array = [Bundler.generic_local_platform].freeze
+
+ dep.should_include? && !dep.gem_platforms(platforms_array).empty?
+ end
+
def locked_dependencies
@locked_deps.values
end
@@ -258,9 +323,11 @@ module Bundler
def dependencies_for(groups)
groups.map!(&:to_sym)
- current_dependencies.reject do |d|
- (d.groups & groups).empty?
+ deps = current_dependencies # always returns a new array
+ deps.select! do |d|
+ d.groups.intersect?(groups)
end
+ deps
end
# Resolve all the dependencies specified in Gemfile. It ensures that
@@ -272,34 +339,57 @@ module Bundler
@resolve ||= if Bundler.frozen_bundle?
Bundler.ui.debug "Frozen, using resolution from the lockfile"
@locked_specs
- elsif !unlocking? && nothing_changed?
+ elsif no_resolve_needed?
if deleted_deps.any?
Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile"
SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
else
Bundler.ui.debug "Found no changes, using resolution from the lockfile"
- if @removed_platform || @locked_gems.may_include_redundant_platform_specific_gems?
+ if @removed_platforms.any? || @locked_gems.may_include_redundant_platform_specific_gems?
SpecSet.new(filter_specs(@locked_specs, @dependencies))
else
@locked_specs
end
end
else
- Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
+ Bundler.ui.debug resolve_needed_reason
+
start_resolution
end
end
def spec_git_paths
- sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact
+ sources.git_sources.filter_map {|s| File.realpath(s.path) if File.exist?(s.path) }
end
def groups
- dependencies.map(&:groups).flatten.uniq
+ dependencies.flat_map(&:groups).uniq
+ end
+
+ def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
+ if [true, false, nil].include?(file_or_preserve_unknown_sections)
+ target_lockfile = lockfile
+ preserve_unknown_sections = file_or_preserve_unknown_sections
+ else
+ target_lockfile = file_or_preserve_unknown_sections
+ preserve_unknown_sections = preserve_unknown_sections_or_unused
+
+ suggestion = if target_lockfile == lockfile
+ "To fix this warning, remove it from the `Definition#lock` call."
+ else
+ "Instead, instantiate a new definition passing `#{target_lockfile}`, and call `lock` without a file argument on that definition"
+ end
+
+ msg = "`Definition#lock` was passed a target file argument. #{suggestion}"
+
+ Bundler::SharedHelpers.feature_removed! msg
+ end
+
+ write_lock(target_lockfile, preserve_unknown_sections)
end
- def lock(file, preserve_unknown_sections = false)
- return if Definition.no_lock
+ def write_lock(file, preserve_unknown_sections)
+ return if Definition.no_lock || !lockfile || file.nil?
contents = to_lock
@@ -309,28 +399,36 @@ module Bundler
if @locked_bundler_version
locked_major = @locked_bundler_version.segments.first
- current_major = Bundler.gem_version.segments.first
+ current_major = bundler_version_to_lock.segments.first
updating_major = locked_major < current_major
end
preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
- return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
+ if File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
+ return if Bundler.frozen_bundle?
+ SharedHelpers.filesystem_access(file) { FileUtils.touch(file) }
+ return
+ end
if Bundler.frozen_bundle?
Bundler.ui.error "Cannot write a changed lockfile while frozen."
return
end
- SharedHelpers.filesystem_access(file) do |p|
- File.open(p, "wb") {|f| f.puts(contents) }
+ begin
+ SharedHelpers.filesystem_access(file) do |p|
+ File.open(p, "wb") {|f| f.puts(contents) }
+ end
+ rescue ReadOnlyFileSystemError
+ raise ProductionError, lockfile_changes_summary("file system is read-only")
end
end
def locked_ruby_version
return unless ruby_version
- if @unlock[:ruby] || !@locked_ruby_version
+ if @unlocking_ruby || !@locked_ruby_version
Bundler::RubyVersion.system
else
@locked_ruby_version
@@ -349,68 +447,32 @@ module Bundler
end
end
+ def bundler_version_to_lock
+ @resolved_bundler_version || Bundler.gem_version
+ end
+
def to_lock
require_relative "lockfile_generator"
LockfileGenerator.generate(self)
end
def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
- msg = String.new
- msg << "You are trying to install in deployment mode after changing\n" \
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
+ return unless Bundler.frozen_bundle?
- unless explicit_flag
- suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
- "bundle config unset frozen"
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
- "bundle config unset deployment"
- end
- msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
- "freeze \nby running `#{suggested_command}`." if suggested_command
- end
-
- added = []
- deleted = []
- changed = []
-
- new_platforms = @platforms - @locked_platforms
- deleted_platforms = @locked_platforms - @platforms
- added.concat new_platforms.map {|p| "* platform: #{p}" }
- deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
-
- added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
- deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
-
- both_sources = Hash.new {|h, k| h[k] = [] }
- @dependencies.each {|d| both_sources[d.name][0] = d }
-
- locked_dependencies.each do |d|
- next if !Bundler.feature_flag.bundler_3_mode? && @locked_specs[d.name].empty?
-
- both_sources[d.name][1] = d
- end
+ raise ProductionError, "Frozen mode is set, but there's no lockfile" unless lockfile_exists?
- both_sources.each do |name, (dep, lock_dep)|
- next if dep.nil? || lock_dep.nil?
-
- gemfile_source = dep.source || sources.default_source
- lock_source = lock_dep.source || sources.default_source
- next if lock_source.include?(gemfile_source)
+ msg = lockfile_changes_summary("frozen mode is set")
+ return unless msg
- gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
- lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
- changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
+ unless explicit_flag
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
+ "bundle config set frozen false"
+ end
+ msg << "\n\nIf this is a development machine, remove the #{SharedHelpers.relative_lockfile_path} " \
+ "freeze by running `#{suggested_command}`." if suggested_command
end
- reason = change_reason
- msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
- msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
- msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
- msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
- msg << "\n"
-
- raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
+ raise ProductionError, msg
end
def validate_runtime!
@@ -431,12 +493,6 @@ module Bundler
"Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
when :engine_version
"Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
- when :patchlevel
- if !expected.is_a?(String)
- "The Ruby patchlevel in your Gemfile must be a string"
- else
- "Your Ruby patchlevel is #{actual}, but your Gemfile specified #{expected}"
- end
end
raise RubyVersionMismatch, msg
@@ -444,77 +500,213 @@ module Bundler
end
def validate_platforms!
- return if current_platform_locked?
+ return if current_platform_locked? || @platforms.include?(Gem::Platform::RUBY)
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
"but your local platform is #{Bundler.local_platform}. " \
"Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
end
+ def normalize_platforms
+ resolve.normalize_platforms!(current_dependencies, platforms)
+
+ @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms))
+ end
+
def add_platform(platform)
- @new_platform ||= !@platforms.include?(platform)
- @platforms |= [platform]
+ return if @platforms.include?(platform)
+
+ @new_platforms << platform
+ @platforms << platform
end
def remove_platform(platform)
- removed_platform = @platforms.delete(Gem::Platform.new(platform))
- @removed_platform ||= removed_platform
- return if removed_platform
- raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}"
- end
+ raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}" unless @platforms.include?(platform)
- def most_specific_locked_platform
- @platforms.min_by do |bundle_platform|
- platform_specificity_match(bundle_platform, local_platform)
- end
+ @removed_platforms << platform
+ @platforms.delete(platform)
end
- attr_reader :sources
- private :sources
-
def nothing_changed?
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@incomplete_lockfile
+ !something_changed?
+ end
+
+ def no_resolve_needed?
+ !resolve_needed?
end
def unlocking?
@unlocking
end
+ def add_checksums
+ require "rubygems/package"
+
+ @locked_checksums = true
+
+ setup_domain!(add_checksums: true)
+
+ # force materialization to real specifications, so that checksums are fetched
+ specs.each do |spec|
+ next unless spec.source.is_a?(Bundler::Source::Rubygems)
+ # Checksum was fetched from the compact index API.
+ next if !spec.source.checksum_store.missing?(spec) && !spec.source.checksum_store.empty?(spec)
+ # The gem isn't installed, can't compute the checksum.
+ next unless spec.loaded_from
+
+ package = Gem::Package.new(spec.source.cached_built_in_gem(spec))
+ checksum = Checksum.from_gem_package(package)
+ spec.source.checksum_store.register(spec, checksum)
+ end
+ end
+
private
+ def lockfile_changes_summary(update_refused_reason)
+ added = []
+ deleted = []
+ changed = []
+
+ added.concat @new_platforms.map {|p| "* platform: #{p}" }
+ deleted.concat @removed_platforms.map {|p| "* platform: #{p}" }
+
+ added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
+ deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
+
+ both_sources = Hash.new {|h, k| h[k] = [] }
+ current_dependencies.each {|d| both_sources[d.name][0] = d }
+ current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
+
+ both_sources.each do |name, (dep, lock_dep)|
+ next if dep.nil? || lock_dep.nil?
+
+ gemfile_source = dep.source || default_source
+ lock_source = lock_dep.source || default_source
+ next if lock_source.include?(gemfile_source)
+
+ gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
+ lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
+ changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
+ end
+
+ return unless added.any? || deleted.any? || changed.any? || resolve_needed?
+
+ msg = String.new("#{change_reason[0].upcase}#{change_reason[1..-1].strip}, but ")
+ msg << "the lockfile " unless msg.start_with?("Your lockfile")
+ msg << "can't be updated because #{update_refused_reason}"
+ msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
+ msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
+ msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_lockfile_path} to version control.\n" unless unlocking?
+ msg
+ end
+
+ def install_needed?
+ resolve_needed? || missing_specs?
+ end
+
+ def something_changed?
+ return true unless lockfile_exists?
+
+ @source_changes ||
+ @dependency_changes ||
+ @current_platform_missing ||
+ @new_platforms.any? ||
+ @path_changes ||
+ @local_changes ||
+ @missing_lockfile_dep ||
+ @unlocking_bundler ||
+ @locked_spec_with_missing_checksums ||
+ @locked_spec_with_empty_checksums ||
+ @locked_spec_with_missing_deps ||
+ @locked_spec_with_invalid_deps
+ end
+
+ def resolve_needed?
+ unlocking? || something_changed?
+ end
+
+ def should_add_extra_platforms?
+ !lockfile_exists? && Bundler::MatchPlatform.generic_local_platform_is_ruby? && !Bundler.settings[:force_ruby_platform]
+ end
+
+ def lockfile_exists?
+ lockfile && File.exist?(lockfile)
+ end
+
def resolver
- @resolver ||= Resolver.new(resolution_packages, gem_version_promoter)
+ @resolver ||= new_resolver(resolution_base)
end
def expanded_dependencies
- dependencies + metadata_dependencies
+ apply_overrides_to(dependencies_with_bundler) + metadata_dependencies
end
- def resolution_packages
- @resolution_packages ||= begin
+ def apply_overrides_to(deps)
+ return deps if @overrides.empty?
+ deps.map {|dep| apply_override_to(dep) }
+ end
+
+ def apply_override_to(dep)
+ override = Override.find_for(@overrides, dep.name, :version)
+ return dep unless override
+ new_dep = dep.dup
+ new_dep.instance_variable_set(:@requirement, override.apply_to(dep.requirement))
+ new_dep
+ end
+
+ def dependencies_with_bundler
+ return dependencies unless @unlocking_bundler
+ return dependencies if dependencies.any? {|d| d.name == "bundler" }
+
+ [Dependency.new("bundler", @unlocking_bundler)] + dependencies
+ end
+
+ def resolution_base
+ @resolution_base ||= begin
last_resolve = converge_locked_specs
- remove_ruby_from_platforms_if_necessary!(current_dependencies)
- packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, :locked_specs => @originally_locked_specs, :unlock => @unlock[:gems], :prerelease => gem_version_promoter.pre?)
- additional_base_requirements_for_resolve(packages, last_resolve)
+ remove_invalid_platforms!
+ base = new_resolution_base(last_resolve: last_resolve, unlock: @unlocking_all || @gems_to_unlock)
+ base = additional_base_requirements_to_prevent_downgrades(base)
+ base = additional_base_requirements_to_force_updates(base)
+ base
end
end
- def filter_specs(specs, deps)
- SpecSet.new(specs).for(deps, false, platforms)
+ def filter_specs(specs, deps, skips: [])
+ SpecSet.new(specs).for(deps, platforms, skips: skips)
end
def materialize(dependencies)
- specs = resolve.materialize(dependencies)
- missing_specs = specs.missing_specs
+ specs = begin
+ resolve.materialize(dependencies)
+ rescue IncorrectLockfileDependencies => e
+ raise if Bundler.frozen_bundle?
+
+ reresolve_without([e.spec])
+ retry
+ end
+
+ missing_specs = resolve.missing_specs
if missing_specs.any?
missing_specs.each do |s|
locked_gem = @locked_specs[s.name].last
- next if locked_gem.nil? || locked_gem.version != s.version || !@remote
- raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
- "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
- "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
- "removed in order to install."
+ next if locked_gem.nil? || locked_gem.version != s.version || sources.local_mode?
+
+ message = if sources.implicit_global_source?
+ "Because your Gemfile specifies no global remote source, your bundle is locked to " \
+ "#{locked_gem} from #{locked_gem.source}. However, #{locked_gem} is not installed. You'll " \
+ "need to either add a global remote source to your Gemfile or make sure #{locked_gem} is " \
+ "available locally before rerunning Bundler."
+ else
+ "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
+ "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
+ "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
+ "removed in order to install."
+ end
+
+ raise GemNotFound, message
end
missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source|
@@ -524,93 +716,183 @@ module Bundler
raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}"
end
- incomplete_specs = specs.incomplete_specs
+ partially_missing_specs = resolve.partially_missing_specs
+
+ if partially_missing_specs.any? && !sources.local_mode?
+ Bundler.ui.warn "Some locked specs have possibly been yanked (#{partially_missing_specs.map(&:full_name).join(", ")}). Ignoring them..."
+
+ resolve.delete(partially_missing_specs)
+ end
+
+ incomplete_specs = resolve.incomplete_specs
loop do
break if incomplete_specs.empty?
Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
- setup_sources_for_resolve
- resolution_packages.delete(incomplete_specs)
- @resolve = start_resolution
+ sources.remote!
+ reresolve_without(incomplete_specs)
specs = resolve.materialize(dependencies)
- still_incomplete_specs = specs.incomplete_specs
+ still_incomplete_specs = resolve.incomplete_specs
if still_incomplete_specs == incomplete_specs
- package = resolution_packages.get_package(incomplete_specs.first.name)
- resolver.raise_not_found! package
+ resolver.raise_incomplete! incomplete_specs
end
incomplete_specs = still_incomplete_specs
end
+ insecurely_materialized_specs = resolve.insecurely_materialized_specs
+
+ if insecurely_materialized_specs.any?
+ Bundler.ui.warn "The following platform specific gems are getting installed, yet the lockfile includes only their generic ruby version:\n" \
+ " * #{insecurely_materialized_specs.map(&:full_name).join("\n * ")}\n" \
+ "Please run `bundle lock --normalize-platforms` and commit the resulting lockfile.\n" \
+ "Alternatively, you may run `bundle lock --add-platform <list-of-platforms-that-you-want-to-support>`"
+ end
+
bundler = sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
specs["bundler"] = bundler
specs
end
+ def reresolve_without(incomplete_specs)
+ resolution_base.delete(incomplete_specs)
+ @resolve = start_resolution
+ end
+
def start_resolution
- result = resolver.start
+ local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform)
+ @platforms << Bundler.local_platform if local_platform_needed_for_resolvability
- SpecSet.new(SpecSet.new(result).for(dependencies, false, @platforms))
- end
+ result = SpecSet.new(resolver.start)
- def precompute_source_requirements_for_indirect_dependencies?
- sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
- end
+ @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
- def pin_locally_available_names(source_requirements)
- source_requirements.each_with_object({}) do |(name, original_source), new_source_requirements|
- local_source = original_source.dup
- local_source.local_only!
+ @new_platforms.each do |platform|
+ incomplete_specs = result.incomplete_specs_for_platform(current_dependencies, platform)
- new_source_requirements[name] = if local_source.specs.search(name).any?
- local_source
- else
- original_source
+ if incomplete_specs.any?
+ resolver.raise_incomplete! incomplete_specs
+ end
+ end
+
+ if @most_specific_non_local_locked_platform
+ if result.incomplete_for_platform?(current_dependencies, @most_specific_non_local_locked_platform)
+ @platforms.delete(@most_specific_non_local_locked_platform)
+ elsif local_platform_needed_for_resolvability
+ @platforms.delete(Bundler.local_platform)
end
end
+
+ if should_add_extra_platforms?
+ result.add_extra_platforms!(platforms)
+ elsif @originally_invalid_platforms.any?
+ result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms)
+ end
+
+ SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY]))
+ end
+
+ def precompute_source_requirements_for_indirect_dependencies?
+ if sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
+ true
+ else
+ non_dependency_api_warning
+ false
+ end
end
- def current_ruby_platform_locked?
- return false unless generic_local_platform == Gem::Platform::RUBY
- return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
+ def non_dependency_api_warning
+ non_api_sources = sources.non_global_rubygems_sources.reject(&:dependency_api_available?)
+ non_api_source_names = non_api_sources.map {|d| " * #{d}" }.join("\n")
- current_platform_locked?
+ msg = String.new
+ msg << "Your Gemfile contains scoped sources that don't implement a dependency API, namely:\n\n"
+ msg << non_api_source_names
+ msg << "\n\nUsing the above gem servers may result in installing unexpected gems. " \
+ "To resolve this warning, make sure you use gem servers that implement dependency APIs, " \
+ "such as gemstash or geminabox gem servers."
+ Bundler.ui.warn msg
end
def current_platform_locked?
@platforms.any? do |bundle_platform|
- MatchPlatform.platforms_match?(bundle_platform, Bundler.local_platform)
+ Bundler.generic_local_platform == bundle_platform || Bundler.local_platform === bundle_platform
end
end
def add_current_platform
- return if current_ruby_platform_locked?
+ return if @platforms.include?(Bundler.local_platform)
+
+ @most_specific_non_local_locked_platform = find_most_specific_locked_platform
+ return if @most_specific_non_local_locked_platform
- add_platform(local_platform)
+ @platforms << Bundler.local_platform
+ true
+ end
+
+ def find_most_specific_locked_platform
+ return unless current_platform_locked?
+
+ @most_specific_locked_platform
+ end
+
+ def resolve_needed_reason
+ if lockfile_exists?
+ if unlocking?
+ "Re-resolving dependencies because #{unlocking_reason}"
+ else
+ "Found changes from the lockfile, re-resolving dependencies because #{lockfile_changed_reason}"
+ end
+ else
+ "Resolving dependencies because there's no lockfile"
+ end
end
def change_reason
- if unlocking?
- unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v|
- if v == true
- k.to_s
- else
- v = Array(v)
- "#{k}: (#{v.join(", ")})"
- end
- end.join(", ")
- return "bundler is unlocking #{unlock_reason}"
+ if resolve_needed?
+ if unlocking?
+ unlocking_reason
+ else
+ lockfile_changed_reason
+ end
+ else
+ "some dependencies were deleted from your gemfile"
end
+ end
+
+ def unlocking_reason
+ unlock_targets = if @gems_to_unlock.any?
+ ["gems", @gems_to_unlock]
+ elsif @sources_to_unlock.any?
+ ["sources", @sources_to_unlock]
+ end
+
+ unlock_reason = if unlock_targets
+ "#{unlock_targets.first}: (#{unlock_targets.last.join(", ")})"
+ else
+ @unlocking_ruby ? "ruby" : ""
+ end
+
+ "bundler is unlocking #{unlock_reason}"
+ end
+
+ def lockfile_changed_reason
[
[@source_changes, "the list of sources changed"],
[@dependency_changes, "the dependencies in your gemfile changed"],
- [@new_platform, "you added a new platform to your gemfile"],
+ [@current_platform_missing, "your lockfile is missing the current platform"],
+ [@new_platforms.any?, "you are adding a new platform to your lockfile"],
[@path_changes, "the gemspecs for path gems changed"],
[@local_changes, "the gemspecs for git local gems changed"],
- [@incomplete_lockfile, "your lock file is missing some gems"],
+ [@missing_lockfile_dep, "your lockfile is missing \"#{@missing_lockfile_dep}\""],
+ [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
+ [@locked_spec_with_missing_checksums, "your lockfile is missing a CHECKSUMS entry for \"#{@locked_spec_with_missing_checksums}\""],
+ [@locked_spec_with_empty_checksums, "your lockfile has an empty CHECKSUMS entry for \"#{@locked_spec_with_empty_checksums}\""],
+ [@locked_spec_with_missing_deps, "your lockfile includes \"#{@locked_spec_with_missing_deps}\" but not some of its dependencies"],
+ [@locked_spec_with_invalid_deps, "your lockfile does not satisfy dependencies of \"#{@locked_spec_with_invalid_deps}\""],
].select(&:first).map(&:last).join(", ")
end
@@ -626,8 +908,8 @@ module Bundler
!locked || dependencies_for_source_changed?(source, locked) || specs_for_source_changed?(source)
end
- def dependencies_for_source_changed?(source, locked_source = source)
- deps_for_source = @dependencies.select {|s| s.source == source }
+ def dependencies_for_source_changed?(source, locked_source)
+ deps_for_source = @dependencies.select {|dep| dep.source == source }
locked_deps_for_source = locked_dependencies.select {|dep| dep.source == locked_source }
deps_for_source.uniq.sort != locked_deps_for_source.sort
@@ -635,10 +917,9 @@ module Bundler
def specs_for_source_changed?(source)
locked_index = Index.new
- locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
+ locked_index.use(@locked_specs.select {|s| s.replace_source_with!(source) })
- # order here matters, since Index#== is checking source.specs.include?(locked_index)
- locked_index != source.specs
+ !locked_index.subset?(source.specs)
rescue PathError, GitError => e
Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
false
@@ -654,7 +935,7 @@ module Bundler
spec = @dependencies.find {|s| s.name == k }
source = spec&.source
if source&.respond_to?(:local_override!)
- source.unlock! if @unlock[:gems].include?(spec.name)
+ source.unlock! if @gems_to_unlock.include?(spec.name)
locals << [source, source.local_override!(v)]
end
end
@@ -662,38 +943,56 @@ module Bundler
sources_with_changes = locals.select do |source, changed|
changed || specs_changed?(source)
end.map(&:first)
- !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
+ !sources_with_changes.each {|source| @sources_to_unlock << source.name }.empty?
end
- def check_missing_lockfile_specs
- all_locked_specs = @locked_specs.map(&:name) << "bundler"
+ def check_lockfile
+ @locked_spec_with_invalid_deps = nil
+ @locked_spec_with_missing_deps = nil
+ @locked_spec_with_missing_checksums = nil
+ @locked_spec_with_empty_checksums = nil
- @locked_specs.any? do |s|
- s.dependencies.any? {|dep| !all_locked_specs.include?(dep.name) }
- end
- end
+ missing_deps = []
+ missing_checksums = []
+ empty_checksums = []
+ invalid = []
- def converge_paths
- sources.path_sources.any? do |source|
- specs_changed?(source)
+ @locked_specs.each do |s|
+ if @locked_checksums
+ checksum_store = s.source.checksum_store
+
+ if checksum_store.missing?(s)
+ missing_checksums << s
+ elsif checksum_store.empty?(s)
+ empty_checksums << s
+ end
+ end
+
+ validation = @locked_specs.validate_deps(s)
+
+ missing_deps << s if validation == :missing
+ invalid << s if validation == :invalid
end
- end
- def converge_path_source_to_gemspec_source(source)
- return source unless source.instance_of?(Source::Path)
- gemspec_source = sources.path_sources.find {|s| s.is_a?(Source::Gemspec) && s.as_path_source == source }
- gemspec_source || source
- end
+ @locked_spec_with_missing_checksums = missing_checksums.first.name if missing_checksums.any?
+ @locked_spec_with_empty_checksums = empty_checksums.first.name if empty_checksums.any?
+
+ if missing_deps.any?
+ @locked_specs.delete(missing_deps)
- def converge_path_sources_to_gemspec_sources
- @locked_sources.map! do |source|
- converge_path_source_to_gemspec_source(source)
+ @locked_spec_with_missing_deps = missing_deps.first.name
end
- @locked_specs.each do |spec|
- spec.source &&= converge_path_source_to_gemspec_source(spec.source)
+
+ if invalid.any?
+ @locked_specs.delete(invalid)
+
+ @locked_spec_with_invalid_deps = invalid.first.name
end
- @locked_deps.each do |_, dep|
- dep.source &&= converge_path_source_to_gemspec_source(dep.source)
+ end
+
+ def converge_paths
+ sources.path_sources.any? do |source|
+ specs_changed?(source)
end
end
@@ -704,47 +1003,85 @@ module Bundler
changes = sources.replace_sources!(@locked_sources)
sources.all_sources.each do |source|
+ # has to be done separately, because we want to keep the locked checksum
+ # store for a source, even when doing a full update
+ if @locked_checksums && @locked_gems && locked_source = @originally_locked_sources.find {|s| s == source && !s.equal?(source) }
+ source.checksum_store.merge!(locked_source.checksum_store)
+ end
# If the source is unlockable and the current command allows an unlock of
# the source (for example, you are doing a `bundle update <foo>` of a git-pinned
# gem), unlock it. For git sources, this means to unlock the revision, which
# will cause the `ref` used to be the most recent for the branch (or master) if
# an explicit `ref` is not used.
- if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
+ if source.respond_to?(:unlock!) && @sources_to_unlock.include?(source.name)
source.unlock!
changes = true
end
end
+ sources.metadata_source.checksum_store.merge!(@locked_gems.metadata_source.checksum_store) if @locked_gems
+
changes
end
def converge_dependencies
- changes = false
+ @missing_lockfile_dep = nil
+ @changed_dependencies = []
@dependencies.each do |dep|
if dep.source
dep.source = sources.get(dep.source)
end
+ next unless relevant_deps?(dep)
- unless locked_dep = @locked_deps[dep.name]
- changes = true
- next
- end
+ name = dep.name
+
+ dep_changed = @locked_deps[name].nil?
- # Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
- # doesn't carry a notion of the dependency type, if you use
- # add_development_dependency in a gemspec that's loaded with the gemspec
- # directive, the lockfile dependencies and resolved dependencies end up
- # with a mismatch on #type. Work around that by setting the type on the
- # dep from the lockfile.
- locked_dep.instance_variable_set(:@type, dep.type)
+ unless name == "bundler"
+ locked_specs = @originally_locked_specs[name]
- # We already know the name matches from the hash lookup
- # so we only need to check the requirement now
- changes ||= dep.requirement != locked_dep.requirement
+ if locked_specs.empty?
+ @missing_lockfile_dep = name if dep_changed == false
+ else
+ if locked_specs.map(&:source).uniq.size > 1
+ @locked_specs.delete(locked_specs.select {|s| s.source != dep.source })
+ end
+
+ unless apply_override_to(dep).matches_spec?(locked_specs.first)
+ @gems_to_unlock << name
+ dep_changed = true
+ end
+ end
+ end
+
+ @changed_dependencies << name if dep_changed
end
- changes
+ converge_overrides_outside_dependencies
+
+ @changed_dependencies.any?
+ end
+
+ def converge_overrides_outside_dependencies
+ @overrides.each do |override|
+ # :all overrides are intentionally not pre-unlocked. They take effect on
+ # fresh resolution (no lockfile) or when the user runs `bundle update`.
+ # Forcing a full re-resolve from a single :all directive would surprise
+ # users with unrelated dependency churn.
+ next unless override.target.is_a?(String)
+
+ name = override.target
+ next if @changed_dependencies.include?(name)
+ next if @originally_locked_specs[name].empty?
+ # version: overrides on direct deps are detected in the per-dep
+ # converge_dependencies loop via apply_override_to + matches_spec?.
+ # Other fields are not visible there, so they always reach here.
+ next if override.field == :version && @dependencies.any? {|d| d.name == name }
+
+ @gems_to_unlock << name
+ @changed_dependencies << name
+ end
end
# Remove elements from the locked specs that are expired. This will most
@@ -753,7 +1090,7 @@ module Bundler
def converge_locked_specs
converged = converge_specs(@locked_specs)
- resolve = SpecSet.new(converged.reject {|s| @unlock[:gems].include?(s.name) })
+ resolve = SpecSet.new(converged)
diff = nil
@@ -772,98 +1109,142 @@ module Bundler
def converge_specs(specs)
converged = []
-
- deps = @dependencies.select do |dep|
- specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
- end
-
- @specs_that_changed_sources = []
+ deps = []
specs.each do |s|
- dep = @dependencies.find {|d| s.satisfies?(d) }
+ name = s.name
+ next if @gems_to_unlock.include?(name)
- # Replace the locked dependency's source with the equivalent source from the Gemfile
- s.source = if dep&.source
- gemfile_source = dep.source
- lockfile_source = s.source
+ dep = @dependencies.find {|d| s.satisfies?(d) }
+ lockfile_source = s.source
- @specs_that_changed_sources << s if gemfile_source != lockfile_source
+ if dep
+ replacement_source = dep.source
- gemfile_source
+ deps << dep if !replacement_source || lockfile_source.include?(replacement_source) || new_deps.include?(dep)
else
- sources.get_with_fallback(s.source)
- end
+ parent_dep = @dependencies.find do |d|
+ next unless d.source && d.source != lockfile_source
+ next if d.source.is_a?(Source::Gemspec)
- next if @unlock[:sources].include?(s.source.name)
+ parent_locked_specs = @originally_locked_specs[d.name]
- # Path sources have special logic
- if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
- new_specs = begin
- s.source.specs
- rescue PathError, GitError
- # if we won't need the source (according to the lockfile),
- # don't error if the path/git source isn't available
- next if specs.
- for(requested_dependencies, false).
- none? {|locked_spec| locked_spec.source == s.source }
-
- raise
+ parent_locked_specs.any? do |parent_spec|
+ parent_spec.runtime_dependencies.any? {|rd| rd.name == s.name }
+ end
+ end
+
+ if parent_dep && parent_dep.source.is_a?(Source::Path) && parent_dep.source.specs[s]&.any?
+ replacement_source = parent_dep.source
+ else
+ replacement_source = sources.get(lockfile_source)
end
+ end
+
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
+ s.source = replacement_source || default_source
+ next if s.source_changed?
- new_spec = new_specs[s].first
+ source = s.source
+ next if @sources_to_unlock.include?(source.name)
+
+ # Path sources have special logic
+ if source.is_a?(Source::Path)
+ new_spec = source.specs[s].first
if new_spec
- s.dependencies.replace(new_spec.dependencies)
+ s.runtime_dependencies.replace(new_spec.runtime_dependencies)
else
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
- @unlock[:gems] << s.name
+ @gems_to_unlock << name
end
end
- if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
- @unlock[:gems] << s.name
- else
- converged << s
- end
+ converged << s
end
- filter_specs(converged, deps)
+ filter_specs(converged, deps, skips: @gems_to_unlock)
end
def metadata_dependencies
@metadata_dependencies ||= [
- Dependency.new("Ruby\0", Gem.ruby_version),
+ Dependency.new("Ruby\0", Bundler::RubyVersion.system.gem_version),
Dependency.new("RubyGems\0", Gem::VERSION),
]
end
def source_requirements
+ @source_requirements ||= find_source_requirements
+ end
+
+ def preload_git_source_worker
+ workers = Bundler.settings.installation_parallelization
+
+ @preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(source, _) { source.specs })
+ end
+
+ def preload_git_sources
+ if Gem.ruby_version < Gem::Version.new("3.3")
+ # Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to
+ # fetch git repositories one by one.
+ return
+ end
+
+ begin
+ needed_git_sources.each {|source| preload_git_source_worker.enq(source) }
+ ensure
+ preload_git_source_worker.stop
+ end
+ end
+
+ # Git sources needed for the requested groups (excludes sources only used by --without groups)
+ def needed_git_sources
+ needed_deps = dependencies_for(requested_groups)
+ sources.git_sources.select do |source|
+ needed_deps.any? {|d| d.source == source }
+ end
+ end
+
+ # Git sources that should be excluded (only used by --without groups)
+ def excluded_git_sources
+ sources.git_sources - needed_git_sources
+ end
+
+ def find_source_requirements
+ preload_git_sources
+
+ # Only safe to exclude when locked_requirements (merged below) backfills the gap.
+ nothing_changed = nothing_changed?
+ excluded = nothing_changed ? excluded_git_sources : []
+
# Record the specs available in each gem's source, so that those
# specs will be available later when the resolver knows where to
# look for that gemspec (or its dependencies)
source_requirements = if precompute_source_requirements_for_indirect_dependencies?
- all_requirements = source_map.all_requirements
- all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
- { :default => sources.default_source }.merge(all_requirements)
+ all_requirements = source_map.all_requirements(excluded)
+ { default: default_source }.merge(all_requirements)
else
- { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
+ { default: Source::RubygemsAggregate.new(sources, source_map, excluded) }.merge(source_map.direct_requirements)
end
- source_requirements.merge!(source_map.locked_requirements) unless @remote
+ source_requirements.merge!(source_map.locked_requirements) if nothing_changed
metadata_dependencies.each do |dep|
source_requirements[dep.name] = sources.metadata_source
end
- source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
- verify_changed_sources!
+
+ default_bundler_source = source_requirements["bundler"] || default_source
+
+ if @unlocking_bundler
+ default_bundler_source.add_dependency_names("bundler")
+ else
+ source_requirements[:default_bundler] = default_bundler_source
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
+ end
+
source_requirements
end
- def verify_changed_sources!
- @specs_that_changed_sources.each do |s|
- if s.source.specs.search(s.name).empty?
- raise GemNotFound, "Could not find gem '#{s.name}' in #{s.source}"
- end
- end
+ def default_source
+ sources.default_source
end
def requested_groups
@@ -876,7 +1257,8 @@ module Bundler
if preserve_unknown_sections
sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
+ sections_to_ignore << LockfileParser::RUBY
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
whitespace_cleanup = /\n{2,}/
current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
@@ -885,27 +1267,63 @@ module Bundler
current == proposed
end
- def additional_base_requirements_for_resolve(resolution_packages, last_resolve)
- return resolution_packages unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
- converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
- resolution_packages.base_requirements[locked_spec.name] = Gem::Requirement.new(">= #{locked_spec.version}")
+ def additional_base_requirements_to_prevent_downgrades(resolution_base)
+ return resolution_base unless @locked_gems
+ @originally_locked_specs.each do |locked_spec|
+ next if locked_spec.source.is_a?(Source::Path) || locked_spec.source_changed?
+
+ name = locked_spec.name
+ next if @changed_dependencies.include?(name)
+
+ resolution_base.base_requirements[name] = Gem::Requirement.new(">= #{locked_spec.version}")
+ end
+ resolution_base
+ end
+
+ def additional_base_requirements_to_force_updates(resolution_base)
+ return resolution_base if @explicit_unlocks.empty?
+ full_update = SpecSet.new(new_resolver_for_full_update.start)
+ @explicit_unlocks.each do |name|
+ version = full_update.version_for(name)
+ resolution_base.base_requirements[name] = Gem::Requirement.new("= #{version}") if version
end
- resolution_packages
+ resolution_base
end
- def remove_ruby_from_platforms_if_necessary!(dependencies)
- return if Bundler.frozen_bundle? ||
- Bundler.local_platform == Gem::Platform::RUBY ||
- !platforms.include?(Gem::Platform::RUBY) ||
- (@new_platform && platforms.last == Gem::Platform::RUBY) ||
- !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
+ def remove_invalid_platforms!
+ return if Bundler.frozen_bundle?
+
+ skips = (@new_platforms + [Bundler.local_platform]).uniq
- remove_platform(Gem::Platform::RUBY)
- add_current_platform
+ # We should probably avoid removing non-ruby platforms, since that means
+ # lockfile will no longer install on those platforms, so a error to give
+ # heads up to the user may be better. However, we have tests expecting
+ # non ruby platform autoremoval to work, so leaving that in place for
+ # now.
+ skips |= platforms - [Gem::Platform::RUBY] if @dependency_changes
+
+ @originally_invalid_platforms = @originally_locked_specs.remove_invalid_platforms!(current_dependencies, platforms, skips: skips)
end
def source_map
@source_map ||= SourceMap.new(sources, dependencies, @locked_specs)
end
+
+ def new_resolver_for_full_update
+ new_resolver(unlocked_resolution_base)
+ end
+
+ def unlocked_resolution_base
+ new_resolution_base(last_resolve: SpecSet.new([]), unlock: true)
+ end
+
+ def new_resolution_base(last_resolve:, unlock:)
+ new_resolution_platforms = @current_platform_missing ? @new_platforms + [Bundler.local_platform] : @new_platforms
+ Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms, overrides: @overrides)
+ end
+
+ def new_resolver(base)
+ Resolver.new(base, gem_version_promoter, @most_specific_locked_platform)
+ end
end
end
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 21a4564dcc..cb9c7a76ea 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -2,83 +2,136 @@
require "rubygems/dependency"
require_relative "shared_helpers"
-require_relative "rubygems_ext"
module Bundler
class Dependency < Gem::Dependency
- attr_reader :autorequire
- attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref
-
- ALL_RUBY_VERSIONS = ((18..27).to_a + (30..33).to_a).freeze
- PLATFORM_MAP = {
- :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
- :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
- :rbx => [Gem::Platform::RUBY],
- :truffleruby => [Gem::Platform::RUBY],
- :jruby => [Gem::Platform::JAVA, [18, 19]],
- :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
- # deprecated
- :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
- :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
- :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
- :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
- }.each_with_object({}) do |(platform, spec), hash|
- hash[platform] = spec[0]
- spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
- end.freeze
-
def initialize(name, version, options = {}, &blk)
type = options["type"] || :runtime
super(name, version, type)
- @autorequire = nil
- @groups = Array(options["group"] || :default).map(&:to_sym)
- @source = options["source"]
- @path = options["path"]
- @git = options["git"]
- @github = options["github"]
- @branch = options["branch"]
- @ref = options["ref"]
- @platforms = Array(options["platforms"])
- @env = options["env"]
- @should_include = options.fetch("should_include", true)
- @gemfile = options["gemfile"]
- @force_ruby_platform = options["force_ruby_platform"] if options.key?("force_ruby_platform")
+ @options = options
+ end
+
+ def groups
+ @groups ||= Array(@options["group"] || :default).map(&:to_sym)
+ end
+
+ def source
+ return @source if defined?(@source)
+
+ @source = @options["source"]
+ end
+
+ def path
+ return @path if defined?(@path)
+
+ @path = @options["path"]
+ end
+
+ def git
+ return @git if defined?(@git)
+
+ @git = @options["git"]
+ end
+
+ def github
+ return @github if defined?(@github)
+
+ @github = @options["github"]
+ end
+
+ def branch
+ return @branch if defined?(@branch)
+
+ @branch = @options["branch"]
+ end
+
+ def ref
+ return @ref if defined?(@ref)
+
+ @ref = @options["ref"]
+ end
+
+ def glob
+ return @glob if defined?(@glob)
+
+ @glob = @options["glob"]
+ end
+
+ def platforms
+ @platforms ||= Array(@options["platforms"])
+ end
+
+ def env
+ return @env if defined?(@env)
+
+ @env = @options["env"]
+ end
+
+ def should_include
+ @should_include ||= @options.fetch("should_include", true)
+ end
+
+ def gemfile
+ return @gemfile if defined?(@gemfile)
- @autorequire = Array(options["require"] || []) if options.key?("require")
+ @gemfile = @options["gemfile"]
end
+ def force_ruby_platform
+ return @force_ruby_platform if defined?(@force_ruby_platform)
+
+ @force_ruby_platform = @options["force_ruby_platform"]
+ end
+
+ def autorequire
+ return @autorequire if defined?(@autorequire)
+
+ @autorequire = Array(@options["require"] || []) if @options.key?("require")
+ end
+
+ RUBY_PLATFORM_ARRAY = [Gem::Platform::RUBY].freeze
+ private_constant :RUBY_PLATFORM_ARRAY
+
# Returns the platforms this dependency is valid for, in the same order as
# passed in the `valid_platforms` parameter
def gem_platforms(valid_platforms)
- return [Gem::Platform::RUBY] if force_ruby_platform
- return valid_platforms if @platforms.empty?
+ return RUBY_PLATFORM_ARRAY if force_ruby_platform
+ return valid_platforms if platforms.empty?
- valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
+ valid_platforms.select {|p| expanded_platforms.include?(Gem::Platform.generic(p)) }
end
def expanded_platforms
- @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
+ @expanded_platforms ||= platforms.filter_map {|pl| CurrentRuby::PLATFORM_MAP[pl] }.flatten.uniq
end
def should_include?
- @should_include && current_env? && current_platform?
+ should_include && current_env? && current_platform?
+ end
+
+ def gemspec_dev_dep?
+ @gemspec_dev_dep ||= @options.fetch("gemspec_dev_dep", false)
+ end
+
+ def gemfile_dep?
+ !gemspec_dev_dep?
end
def current_env?
- return true unless @env
- if @env.is_a?(Hash)
- @env.all? do |key, val|
+ return true unless env
+ if env.is_a?(Hash)
+ env.all? do |key, val|
ENV[key.to_s] && (val.is_a?(String) ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
end
else
- ENV[@env.to_s]
+ ENV[env.to_s]
end
end
def current_platform?
- return true if @platforms.empty?
- @platforms.any? do |p|
+ return true if platforms.empty?
+ platforms.any? do |p|
Bundler.current_ruby.send("#{p}?")
end
end
diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb
index b432ae6ae1..3344449e82 100644
--- a/lib/bundler/deployment.rb
+++ b/lib/bundler/deployment.rb
@@ -1,69 +1,6 @@
# frozen_string_literal: true
require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \
+Bundler::SharedHelpers.feature_removed! "Bundler no longer integrates with " \
"Capistrano, but Capistrano provides its own integration with " \
"Bundler via the capistrano-bundler gem. Use it instead."
-
-module Bundler
- class Deployment
- def self.define_task(context, task_method = :task, opts = {})
- if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
- context_name = "capistrano"
- role_default = "{:except => {:no_release => true}}"
- error_type = ::Capistrano::CommandError
- else
- context_name = "vlad"
- role_default = "[:app]"
- error_type = ::Rake::CommandFailedError
- end
-
- roles = context.fetch(:bundle_roles, false)
- opts[:roles] = roles if roles
-
- context.send :namespace, :bundle do
- send :desc, <<-DESC
- Install the current Bundler environment. By default, gems will be \
- installed to the shared/bundle path. Gems in the development and \
- test group will not be installed. The install command is executed \
- with the --deployment and --quiet flags. If the bundle cmd cannot \
- be found then you can override the bundle_cmd variable to specify \
- which one it should use. The base path to the app is fetched from \
- the :latest_release variable. Set it for custom deploy layouts.
-
- You can override any of these defaults by setting the variables shown below.
-
- N.B. bundle_roles must be defined before you require 'bundler/#{context_name}' \
- in your deploy.rb file.
-
- set :bundle_gemfile, "Gemfile"
- set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
- set :bundle_flags, "--deployment --quiet"
- set :bundle_without, [:development, :test]
- set :bundle_with, [:mysql]
- set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle"
- set :bundle_roles, #{role_default} # e.g. [:app, :batch]
- DESC
- send task_method, :install, opts do
- bundle_cmd = context.fetch(:bundle_cmd, "bundle")
- bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
- bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), "bundle"))
- bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
- bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
- bundle_with = [*context.fetch(:bundle_with, [])].compact
- app_path = context.fetch(:latest_release)
- if app_path.to_s.empty?
- raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
- end
- args = ["--gemfile #{File.join(app_path, bundle_gemfile)}"]
- args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
- args << bundle_flags.to_s
- args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
- args << "--with #{bundle_with.join(" ")}" unless bundle_with.empty?
-
- run "cd #{app_path} && #{bundle_cmd} install #{args.join(" ")}"
- end
- end
- end
- end
-end
diff --git a/lib/bundler/digest.rb b/lib/bundler/digest.rb
index 148e9f7788..158803033d 100644
--- a/lib/bundler/digest.rb
+++ b/lib/bundler/digest.rb
@@ -26,7 +26,7 @@ module Bundler
end
a, b, c, d, e = *words
(16..79).each do |i|
- w[i] = SHA1_MASK & rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1)
+ w[i] = SHA1_MASK & rotate(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1)
end
0.upto(79) do |i|
case i
@@ -50,7 +50,7 @@ module Bundler
words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
end
- words.pack("N*").unpack("H*").first
+ words.pack("N*").unpack1("H*")
end
private
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 03c80a408c..6e2638a8be 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -9,18 +9,20 @@ module Bundler
def self.evaluate(gemfile, lockfile, unlock)
builder = new
+ builder.lockfile(lockfile)
builder.eval_gemfile(gemfile)
- builder.to_definition(lockfile, unlock)
+ builder.to_definition(builder.lockfile_path, unlock)
end
- VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
+ VALID_PLATFORMS = Bundler::CurrentRuby::PLATFORM_MAP.keys.freeze
VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
- platform platforms type source install_if gemfile force_ruby_platform].freeze
+ platform platforms source install_if force_ruby_platform].freeze
- GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
+ GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}
+ GITLAB_MERGE_REQUEST_URL = %r{\Ahttps://gitlab\.com/([A-Za-z0-9_\-\./]+)/-/merge_requests/(\d+)\z}
- attr_reader :gemspecs
+ attr_reader :gemspecs, :gemfile, :overrides
attr_accessor :dependencies
def initialize
@@ -37,24 +39,26 @@ module Bundler
@gemspecs = []
@gemfile = nil
@gemfiles = []
+ @lockfile = nil
+ @overrides = []
add_git_sources
end
def eval_gemfile(gemfile, contents = nil)
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
- original_gemfile = @gemfile
- @gemfile = expanded_gemfile_path
- @gemfiles << expanded_gemfile_path
- contents ||= Bundler.read_file(@gemfile.to_s)
- instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
- rescue Exception => e # rubocop:disable Lint/RescueException
- message = "There was an error " \
- "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
- "`#{File.basename gemfile.to_s}`: #{e.message}"
-
- raise DSLError.new(message, gemfile, e.backtrace, contents)
- ensure
- @gemfile = original_gemfile
+ with_gemfile(gemfile) do |current_gemfile|
+ contents ||= Bundler.read_file(current_gemfile)
+ instance_eval(contents, current_gemfile, 1)
+ rescue GemfileEvalError => e
+ message = "There was an error evaluating `#{File.basename current_gemfile}`: #{e.message}"
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
+ rescue GemfileError, InvalidArgumentError, InvalidOption, DeprecatedError, ScriptError => e
+ message = "There was an error parsing `#{File.basename current_gemfile}`: #{e.message}"
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
+ rescue StandardError => e
+ raise unless e.backtrace_locations.first.path == current_gemfile
+ message = "There was an error parsing `#{File.basename current_gemfile}`: #{e.message}"
+ raise DSLError.new(message, current_gemfile, e.backtrace, contents)
+ end
end
def gemspec(opts = nil)
@@ -65,23 +69,23 @@ module Bundler
development_group = opts[:development_group] || :development
expanded_path = gemfile_root.join(path)
- gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).map {|g| Bundler.load_gemspec(g) }.compact
+ gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).filter_map {|g| Bundler.load_gemspec(g) }
gemspecs.reject! {|s| s.name != name } if name
specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
case specs_by_name_and_version.size
when 1
specs = specs_by_name_and_version.values.first
- spec = specs.find {|s| s.match_platform(Bundler.local_platform) } || specs.first
+ spec = specs.find {|s| s.installable_on_platform?(Bundler.local_platform) } || specs.first
@gemspecs << spec
- gem spec.name, :name => spec.name, :path => path, :glob => glob
+ path path, "glob" => glob, "name" => spec.name, "gemspec" => spec do
+ add_dependency spec.name
+ end
- group(development_group) do
- spec.development_dependencies.each do |dep|
- gem dep.name, *(dep.requirement.as_list + [:type => :development])
- end
+ spec.development_dependencies.each do |dep|
+ add_dependency dep.name, dep.requirement.as_list, "gemspec_dev_dep" => true, "group" => development_group
end
when 0
raise InvalidOption, "There are no gemspecs at #{expanded_path}"
@@ -93,57 +97,30 @@ module Bundler
def gem(name, *args)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
- options["gemfile"] = @gemfile
version = args || [">= 0"]
normalize_options(name, version, options)
- dep = Dependency.new(name, version, options)
-
- # if there's already a dependency with this name we try to prefer one
- if current = @dependencies.find {|d| d.name == dep.name }
- deleted_dep = @dependencies.delete(current) if current.type == :development
-
- unless deleted_dep
- if current.requirement != dep.requirement
- return if dep.type == :development
-
- update_prompt = ""
-
- if File.basename(@gemfile) == Injector::INJECTED_GEMS
- if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
- update_prompt = ". Gem already added"
- else
- update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
-
- update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current.requirements_list.include?(">= 0")
- end
- end
+ add_dependency(name, version, options)
+ end
- raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
- "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
- "#{update_prompt}"
- elsif current.source != dep.source
- return if dep.type == :development
- raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
- "You specified that #{dep.name} (#{dep.requirement}) should come from " \
- "#{current.source || "an unspecified source"} and #{dep.source}\n"
- else
- Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
- "You should probably keep only one of them.\n" \
- "Remove any duplicate entries and specify the gem only once.\n" \
- "While it's not a problem now, it could cause errors if you change the version of one of them later."
- end
- end
- end
+ # For usage in Dsl.evaluate, since lockfile is used as part of the Gemfile.
+ def lockfile_path
+ @lockfile
+ end
- @dependencies << dep
+ def lockfile(file)
+ @lockfile = file
end
def source(source, *args, &blk)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
options = normalize_hash(options)
source = normalize_source(source)
+ cooldown = options["cooldown"]
+ if cooldown && !(cooldown.is_a?(Integer) && cooldown >= 0)
+ raise InvalidOption, "Expected `cooldown` to be a non-negative integer, got #{cooldown.inspect}"
+ end
if options.key?("type")
options["type"] = options["type"].to_s
@@ -158,9 +135,9 @@ module Bundler
source_opts = options.merge("uri" => source)
with_source(@sources.add_plugin_source(options["type"], source_opts), &blk)
elsif block_given?
- with_source(@sources.add_rubygems_source("remotes" => source), &blk)
+ with_source(@sources.add_rubygems_source("remotes" => source, "cooldown" => cooldown), &blk)
else
- @sources.add_global_rubygems_remote(source)
+ @sources.add_global_rubygems_remote(source, cooldown: cooldown)
end
end
@@ -180,8 +157,7 @@ module Bundler
def path(path, options = {}, &blk)
source_options = normalize_hash(options).merge(
"path" => Pathname.new(path),
- "root_path" => gemfile_root,
- "gemspec" => gemspecs.find {|g| g.name == options["name"] }
+ "root_path" => gemfile_root
)
source_options["global"] = true unless block_given?
@@ -206,16 +182,39 @@ module Bundler
end
def github(repo, options = {})
- raise ArgumentError, "GitHub sources require a block" unless block_given?
+ raise InvalidArgumentError, "GitHub sources require a block" unless block_given?
github_uri = @git_sources["github"].call(repo)
git_options = normalize_hash(options).merge("uri" => github_uri)
git_source = @sources.add_git_source(git_options)
with_source(git_source) { yield }
end
+ SUPPORTED_OVERRIDE_FIELDS = [:version, :required_ruby_version, :required_rubygems_version].freeze
+ SUPPORTED_OVERRIDE_SYMBOL_OPERATIONS = [:ignore_upper].freeze
+
+ def override(target, **operations)
+ validate_override_target!(target)
+
+ if target == :all && operations.key?(:version)
+ raise ArgumentError, "`override :all, version:` is not allowed; version requirements are per-gem"
+ end
+
+ operations.each do |field, operation|
+ validate_override_field!(field)
+ validate_override_operation!(operation)
+ validate_override_uniqueness!(target, field)
+ end
+
+ source_location = caller_locations(1, 1)&.first
+ operations.each do |field, operation|
+ @overrides << Override.new(target, field, operation, source_location: source_location)
+ end
+ end
+
def to_definition(lockfile, unlock)
check_primary_source_safety
- Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles)
+ lockfile = @lockfile unless @lockfile.nil?
+ Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles, @overrides)
end
def group(*args, &blk)
@@ -272,6 +271,123 @@ module Bundler
private
+ def validate_override_target!(target)
+ return if target == :all
+ return if target.is_a?(String)
+ raise ArgumentError, "override target must be :all or a gem name string, got #{target.inspect}"
+ end
+
+ def validate_override_field!(field)
+ return if SUPPORTED_OVERRIDE_FIELDS.include?(field)
+ supported = SUPPORTED_OVERRIDE_FIELDS.map {|f| "`#{f}:`" }.join(", ")
+ raise ArgumentError, "unsupported override field `#{field}:`; supported fields: #{supported}"
+ end
+
+ def validate_override_operation!(operation)
+ case operation
+ when String
+ Gem::Requirement.new(operation)
+ when nil
+ # ok
+ when Symbol
+ return if SUPPORTED_OVERRIDE_SYMBOL_OPERATIONS.include?(operation)
+ raise ArgumentError, "unsupported override operation: #{operation.inspect}"
+ else
+ raise ArgumentError, "override operation must be a String, Symbol, or nil, got #{operation.inspect}"
+ end
+ rescue Gem::Requirement::BadRequirementError => e
+ raise ArgumentError, "invalid override version requirement #{operation.inspect}: #{e.message}"
+ end
+
+ def validate_override_uniqueness!(target, field)
+ return unless @overrides.any? {|o| o.target == target && o.field == field }
+ raise ArgumentError, "duplicate override for #{target.inspect} `#{field}:`"
+ end
+
+ def add_dependency(name, version = nil, options = {})
+ options["gemfile"] = @gemfile
+ options["source"] ||= @source
+ options["env"] ||= @env
+
+ dep = Dependency.new(name, version, options)
+
+ # if there's already a dependency with this name we try to prefer one
+ if current = @dependencies.find {|d| d.name == name }
+ if current.requirement != dep.requirement
+ current_requirement_open = current.requirements_list.include?(">= 0")
+
+ gemspec_dep = [dep, current].find(&:gemspec_dev_dep?)
+ if gemspec_dep
+ require_relative "vendor/pub_grub/lib/pub_grub/version_range"
+ require_relative "vendor/pub_grub/lib/pub_grub/version_constraint"
+ require_relative "vendor/pub_grub/lib/pub_grub/version_union"
+ require_relative "vendor/pub_grub/lib/pub_grub/rubygems"
+
+ current_gemspec_range = PubGrub::RubyGems.requirement_to_range(current.requirement)
+ next_gemspec_range = PubGrub::RubyGems.requirement_to_range(dep.requirement)
+
+ if current_gemspec_range.intersects?(next_gemspec_range)
+ dep = Dependency.new(name, current.requirement.as_list + dep.requirement.as_list, options)
+ else
+ gemfile_dep = [dep, current].find(&:gemfile_dep?)
+
+ if gemfile_dep
+ raise GemfileError, "The #{name} dependency has conflicting requirements in Gemfile (#{gemfile_dep.requirement}) and gemspec (#{gemspec_dep.requirement})"
+ else
+ raise GemfileError, "Two gemspec development dependencies have conflicting requirements on the same gem: #{dep} and #{current}"
+ end
+ end
+ else
+ update_prompt = ""
+
+ if File.basename(@gemfile) == Injector::INJECTED_GEMS
+ if dep.requirements_list.include?(">= 0") && !current_requirement_open
+ update_prompt = ". Gem already added"
+ else
+ update_prompt = ". If you want to update the gem version, run `bundle update #{name}`"
+
+ update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current_requirement_open
+ end
+ end
+
+ raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
+ "You specified: #{name} (#{current.requirement}) and #{name} (#{dep.requirement})" \
+ "#{update_prompt}"
+ end
+ end
+
+ unless current.gemspec_dev_dep? && dep.gemspec_dev_dep?
+ # Always prefer the dependency from the Gemfile
+ if current.gemspec_dev_dep?
+ @dependencies.delete(current)
+ elsif dep.gemspec_dev_dep?
+ return
+ elsif current.source.to_s != dep.source.to_s
+ raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
+ "You specified that #{name} (#{dep.requirement}) should come from " \
+ "#{current.source || "an unspecified source"} and #{dep.source}\n"
+ else
+ Bundler.ui.warn "Your Gemfile lists the gem #{name} (#{current.requirement}) more than once.\n" \
+ "You should probably keep only one of them.\n" \
+ "Remove any duplicate entries and specify the gem only once.\n" \
+ "While it's not a problem now, it could cause errors if you change the version of one of them later."
+ end
+ end
+ end
+
+ @dependencies << dep
+ end
+
+ def with_gemfile(gemfile)
+ expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
+ original_gemfile = @gemfile
+ @gemfile = expanded_gemfile_path
+ @gemfiles << expanded_gemfile_path
+ yield @gemfile.to_s
+ ensure
+ @gemfile = original_gemfile
+ end
+
def add_git_sources
git_source(:github) do |repo_name|
if repo_name =~ GITHUB_PULL_REQUEST_URL
@@ -296,6 +412,20 @@ module Bundler
repo_name ||= user_name
"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
end
+
+ git_source(:gitlab) do |repo_name|
+ if repo_name =~ GITLAB_MERGE_REQUEST_URL
+ {
+ "git" => "https://gitlab.com/#{$1}.git",
+ "branch" => nil,
+ "ref" => "refs/merge-requests/#{$2}/head",
+ "tag" => nil,
+ }
+ else
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
+ "https://gitlab.com/#{repo_name}.git"
+ end
+ end
end
def with_source(source)
@@ -354,6 +484,13 @@ module Bundler
raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
end
+ windows_platforms = platforms.select {|pl| pl.to_s.match?(/mingw|mswin/) }
+ if windows_platforms.any?
+ windows_platforms = windows_platforms.map! {|pl| ":#{pl}" }.join(", ")
+ deprecated_message = "Platform #{windows_platforms} will be removed in the future. Please use platform :windows instead."
+ Bundler::SharedHelpers.feature_deprecated! deprecated_message
+ end
+
# Save sources passed in a key
if opts.key?("source")
source = normalize_source(opts["source"])
@@ -380,8 +517,6 @@ module Bundler
opts["source"] = source
end
- opts["source"] ||= @source
- opts["env"] ||= @env
opts["platforms"] = platforms.dup
opts["group"] = groups
opts["should_include"] = install_if
@@ -397,13 +532,11 @@ module Bundler
end
def validate_keys(command, opts, valid_keys)
- invalid_keys = opts.keys - valid_keys
-
- git_source = opts.keys & @git_sources.keys.map(&:to_s)
- if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
+ if opts["branch"] && !(opts["git"] || opts["github"] || (opts.keys & @git_sources.keys.map(&:to_s)).any?)
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
end
+ invalid_keys = opts.keys - valid_keys
return true unless invalid_keys.any?
message = String.new
@@ -422,10 +555,10 @@ module Bundler
def normalize_source(source)
case source
when :gemcutter, :rubygems, :rubyforge
- Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \
- "requests are insecure.\nPlease change your source to 'https://" \
- "rubygems.org' if possible, or 'http://rubygems.org' if not."
- "http://rubygems.org"
+ removed_message =
+ "The source :#{source} is disallowed because HTTP requests are insecure.\n" \
+ "Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not."
+ Bundler::SharedHelpers.feature_removed! removed_message
when String
source
else
@@ -444,36 +577,18 @@ module Bundler
" gem 'rails'\n" \
" end\n\n"
- SharedHelpers.major_deprecation(2, msg.strip)
+ SharedHelpers.feature_removed! msg.strip
end
def check_rubygems_source_safety
- if @sources.implicit_global_source?
- implicit_global_source_warning
- elsif @sources.aggregate_global_source?
- multiple_global_source_warning
- end
- end
-
- def implicit_global_source_warning
- Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \
- "Not using an explicit global source may result in a different lockfile being generated depending on " \
- "the gems you have installed locally before bundler is run. " \
- "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"."
+ multiple_global_source_warning if @sources.aggregate_global_source?
end
def multiple_global_source_warning
- if Bundler.feature_flag.bundler_3_mode?
- msg = "This Gemfile contains multiple global sources. " \
- "Each source after the first must include a block to indicate which gems " \
- "should come from that source"
- raise GemfileEvalError, msg
- else
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
- "Using `source` more than once without a block is a security risk, and " \
- "may result in installing unexpected gems. To resolve this warning, use " \
- "a block to indicate which gems should come from the secondary source."
- end
+ msg = "This Gemfile contains multiple global sources. " \
+ "Each source after the first must include a block to indicate which gems " \
+ "should come from that source"
+ raise GemfileEvalError, msg
end
class DSLError < GemfileError
@@ -541,23 +656,23 @@ module Bundler
return m unless backtrace && dsl_path && contents
- trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line
+ trace_line = backtrace.find {|l| l.include?(dsl_path) } || trace_line
return m unless trace_line
- line_numer = trace_line.split(":")[1].to_i - 1
- return m unless line_numer
+ line_number = trace_line.split(":")[1].to_i - 1
+ return m unless line_number
lines = contents.lines.to_a
indent = " # "
indicator = indent.tr("#", ">")
- first_line = line_numer.zero?
- last_line = (line_numer == (lines.count - 1))
+ first_line = line_number.zero?
+ last_line = (line_number == (lines.count - 1))
m << "\n"
m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
m << "#{indent}-------------------------------------------\n"
- m << "#{indent}#{lines[line_numer - 1]}" unless first_line
- m << "#{indicator}#{lines[line_numer]}"
- m << "#{indent}#{lines[line_numer + 1]}" unless last_line
+ m << "#{indent}#{lines[line_number - 1]}" unless first_line
+ m << "#{indicator}#{lines[line_number]}"
+ m << "#{indent}#{lines[line_number + 1]}" unless last_line
m << "\n" unless m.end_with?("\n")
m << "#{indent}-------------------------------------------\n"
end
@@ -567,7 +682,7 @@ module Bundler
def parse_line_number_from_description
description = self.description
- if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
+ if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path}):\d+)/
trace_line = Regexp.last_match[1]
description = description.sub(/\n.*\n(\.\.\.)? *\^~+$/, "").sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ")
end
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb
index d315d1cc68..7c7ce107e2 100644
--- a/lib/bundler/endpoint_specification.rb
+++ b/lib/bundler/endpoint_specification.rb
@@ -5,8 +5,9 @@ module Bundler
class EndpointSpecification < Gem::Specification
include MatchRemoteMetadata
- attr_reader :name, :version, :platform, :checksum
- attr_accessor :source, :remote, :dependencies
+ attr_reader :name, :version, :platform, :checksum, :created_at
+ attr_writer :dependencies
+ attr_accessor :remote, :locked_platform
def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil)
super()
@@ -14,21 +15,28 @@ module Bundler
@version = Gem::Version.create version
@platform = Gem::Platform.new(platform)
@spec_fetcher = spec_fetcher
- @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
+ @dependencies = nil
+ @unbuilt_dependencies = dependencies
@loaded_from = nil
@remote_specification = nil
+ @locked_platform = nil
parse_metadata(metadata)
end
+ def insecurely_materialized?
+ @locked_platform.to_s != @platform.to_s
+ end
+
def fetch_platform
@platform
end
- def identifier
- @__identifier ||= [name, version, platform.to_s]
+ def dependencies
+ @dependencies ||= @unbuilt_dependencies.map! {|dep, reqs| build_dependency(dep, reqs) }
end
+ alias_method :runtime_dependencies, :dependencies
# needed for standalone, load required_paths from local gemspec
# after the gem is installed
@@ -96,9 +104,20 @@ module Bundler
end
end
+ # needed for `bundle fund`
+ def metadata
+ if @remote_specification
+ @remote_specification.metadata
+ elsif _local_specification
+ _local_specification.metadata
+ else
+ super
+ end
+ end
+
def _local_specification
return unless @loaded_from && File.exist?(local_specification_path)
- eval(File.read(local_specification_path)).tap do |spec|
+ eval(File.read(local_specification_path), nil, local_specification_path).tap do |spec|
spec.loaded_from = @loaded_from
end
end
@@ -108,6 +127,10 @@ module Bundler
@remote_specification = spec
end
+ def inspect
+ "#<#{self.class} @name=\"#{name}\" (#{full_name.delete_prefix("#{name}-")})>"
+ end
+
private
def _remote_specification
@@ -122,6 +145,7 @@ module Bundler
unless data
@required_ruby_version = nil
@required_rubygems_version = nil
+ @created_at = nil
return
end
@@ -129,11 +153,24 @@ module Bundler
next unless v
case k.to_s
when "checksum"
- @checksum = v.last
+ begin
+ @checksum = Checksum.from_api(v.last, @spec_fetcher.uri)
+ rescue ArgumentError => e
+ raise ArgumentError, "Invalid checksum for #{full_name}: #{e.message}"
+ end
when "rubygems"
@required_rubygems_version = Gem::Requirement.new(v)
when "ruby"
@required_ruby_version = Gem::Requirement.new(v)
+ when "created_at"
+ value = v.is_a?(Array) ? v.last : v
+ if value.is_a?(String)
+ @created_at = begin
+ Time.new(value)
+ rescue ArgumentError
+ nil
+ end
+ end
end
end
rescue StandardError => e
@@ -141,7 +178,7 @@ module Bundler
end
def build_dependency(name, requirements)
- Gem::Dependency.new(name, requirements)
+ Dependency.new(name, requirements)
end
end
end
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 4f8b6f605d..074bef6edc 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -40,11 +40,11 @@ module Bundler
out << "\n## Gemfile\n"
gemfiles.each do |gemfile|
- out << "\n### #{Pathname.new(gemfile).relative_path_from(SharedHelpers.pwd)}\n\n"
+ out << "\n### #{SharedHelpers.relative_path_to(gemfile)}\n\n"
out << "```ruby\n" << read_file(gemfile).chomp << "\n```\n"
end
- out << "\n### #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n"
+ out << "\n### #{SharedHelpers.relative_path_to(Bundler.default_lockfile)}\n\n"
out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n"
end
@@ -120,7 +120,7 @@ module Bundler
specs = Bundler.rubygems.find_name(name)
out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
end
- if (exe = caller.last.split(":").first)&.match? %r{(exe|bin)/bundler?\z}
+ if (exe = caller_locations.last.absolute_path)&.match? %r{(exe|bin)/bundler?\z}
shebang = File.read(exe).lines.first
shebang.sub!(/^#!\s*/, "")
unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
index 57013f5d50..bf9478a299 100644
--- a/lib/bundler/environment_preserver.rb
+++ b/lib/bundler/environment_preserver.rb
@@ -6,6 +6,7 @@ module Bundler
BUNDLER_KEYS = %w[
BUNDLE_BIN_PATH
BUNDLE_GEMFILE
+ BUNDLE_LOCKFILE
BUNDLER_VERSION
BUNDLER_SETUP
GEM_HOME
@@ -19,14 +20,7 @@ module Bundler
BUNDLER_PREFIX = "BUNDLER_ORIG_"
def self.from_env
- new(env_to_hash(ENV), BUNDLER_KEYS)
- end
-
- def self.env_to_hash(env)
- to_hash = env.to_hash
- return to_hash unless Gem.win_platform?
-
- to_hash.each_with_object({}) {|(k,v), a| a[k.upcase] = v }
+ new(ENV.to_hash, BUNDLER_KEYS)
end
# @param env [Hash]
@@ -39,18 +33,7 @@ module Bundler
# Replaces `ENV` with the bundler environment variables backed up
def replace_with_backup
- unless Gem.win_platform?
- ENV.replace(backup)
- return
- end
-
- # Fallback logic for Windows below to workaround
- # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
- # supported rubies include the fix for that.
-
- ENV.clear
-
- backup.each {|k, v| ENV[k] = v }
+ ENV.replace(backup)
end
# @return [Hash]
@@ -58,9 +41,9 @@ module Bundler
env = @original.clone
@keys.each do |key|
value = env[key]
- if !value.nil? && !value.empty?
+ if !value.nil?
env[@prefix + key] ||= value
- elsif value.nil?
+ else
env[@prefix + key] ||= INTENTIONALLY_NIL
end
end
@@ -72,7 +55,7 @@ module Bundler
env = @original.clone
@keys.each do |key|
value_original = env[@prefix + key]
- next if value_original.nil? || value_original.empty?
+ next if value_original.nil?
if value_original == INTENTIONALLY_NIL
env.delete(key)
else
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
index 5839fc6a73..dff5d93128 100644
--- a/lib/bundler/errors.rb
+++ b/lib/bundler/errors.rb
@@ -25,6 +25,7 @@ module Bundler
class GemNotFound < BundlerError; status_code(7); end
class InstallHookError < BundlerError; status_code(8); end
+ class RemovedError < BundlerError; status_code(9); end
class GemfileNotFound < BundlerError; status_code(10); end
class GitError < BundlerError; status_code(11); end
class DeprecatedError < BundlerError; status_code(12); end
@@ -52,6 +53,44 @@ module Bundler
class GemfileEvalError < GemfileError; end
class MarshalError < StandardError; end
+ class ChecksumMismatchError < SecurityError
+ def initialize(lock_name, existing, checksum)
+ @lock_name = lock_name
+ @existing = existing
+ @checksum = checksum
+ end
+
+ def message
+ <<~MESSAGE
+ Bundler found mismatched checksums. This is a potential security risk.
+ #{@lock_name} #{@existing.to_lock}
+ from #{@existing.sources.join("\n and ")}
+ #{@lock_name} #{@checksum.to_lock}
+ from #{@checksum.sources.join("\n and ")}
+
+ #{mismatch_resolution_instructions}
+ To ignore checksum security warnings, disable checksum validation with
+ `bundle config set --local disable_checksum_validation true`
+ MESSAGE
+ end
+
+ def mismatch_resolution_instructions
+ removable, remote = [@existing, @checksum].partition(&:removable?)
+ case removable.size
+ when 1
+ msg = +"If you trust #{remote.first.sources.first}, to resolve this issue you can:\n"
+ msg << removable.first.removal_instructions
+ when 2
+ msg = +"To resolve this issue you can either:\n"
+ msg << @checksum.removal_instructions
+ msg << "or if you are sure that the new checksum from #{@checksum.sources.first} is correct:\n"
+ msg << @existing.removal_instructions
+ end
+ end
+
+ status_code(37)
+ end
+
class PermissionError < BundlerError
def initialize(path, permission_type = :write)
@path = path
@@ -92,7 +131,8 @@ module Bundler
attr_reader :orig_exception
def initialize(orig_exception, msg)
- full_message = msg + "\nGem Load Error is: #{orig_exception.message}\n"\
+ full_message = msg + "\nGem Load Error is:
+ #{orig_exception.full_message(highlight: false)}\n"\
"Backtrace for gem load error is:\n"\
"#{orig_exception.backtrace.join("\n")}\n"\
"Bundler Error Backtrace:\n"
@@ -150,6 +190,24 @@ module Bundler
status_code(31)
end
+ class ReadOnlyFileSystemError < PermissionError
+ def message
+ "There was an error while trying to #{action} `#{@path}`. " \
+ "File system is read-only."
+ end
+
+ status_code(42)
+ end
+
+ class OperationNotPermittedError < PermissionError
+ def message
+ "There was an error while trying to #{action} `#{@path}`. " \
+ "Underlying OS system call raised an EPERM error."
+ end
+
+ status_code(43)
+ end
+
class GenericSystemCallError < BundlerError
attr_reader :underlying_error
@@ -164,7 +222,9 @@ module Bundler
class DirectoryRemovalError < BundlerError
def initialize(orig_exception, msg)
full_message = "#{msg}.\n" \
- "The underlying error was #{orig_exception.class}: #{orig_exception.message}, with backtrace:\n" \
+ "The underlying error was #{orig_exception.class}:
+ #{orig_exception.full_message(highlight: false)},
+ with backtrace:\n" \
" #{orig_exception.backtrace.join("\n ")}\n\n" \
"Bundler Error Backtrace:"
super(full_message)
@@ -172,4 +232,75 @@ module Bundler
status_code(36)
end
+
+ class InsecureInstallPathError < BundlerError
+ def initialize(name, path)
+ @name = name
+ @path = path
+ end
+
+ def message
+ "Bundler cannot reinstall #{@name} because there's a previous installation of it at #{@path} that is unsafe to remove.\n" \
+ "The parent of #{@path} is world-writable and does not have the sticky bit set, making it insecure to remove due to potential vulnerabilities.\n" \
+ "Please change the permissions of #{File.dirname(@path)} or choose a different install path."
+ end
+
+ status_code(38)
+ end
+
+ class CorruptBundlerInstallError < BundlerError
+ def initialize(loaded_spec)
+ @loaded_spec = loaded_spec
+ end
+
+ def message
+ "The running version of Bundler (#{Bundler::VERSION}) does not match the version of the specification installed for it (#{@loaded_spec.version}). " \
+ "This can be caused by reinstalling Ruby without removing previous installation, leaving around an upgraded default version of Bundler. " \
+ "Reinstalling Ruby from scratch should fix the problem."
+ end
+
+ status_code(39)
+ end
+
+ class InvalidArgumentError < BundlerError; status_code(40); end
+
+ class IncorrectLockfileDependencies < BundlerError
+ attr_reader :spec, :actual_dependencies, :lockfile_dependencies
+
+ def initialize(spec, actual_dependencies = nil, lockfile_dependencies = nil)
+ @spec = spec
+ @actual_dependencies = actual_dependencies
+ @lockfile_dependencies = lockfile_dependencies
+ end
+
+ def message
+ lines = ["Bundler found incorrect dependencies in the lockfile for #{spec.full_name}", ""]
+
+ if @actual_dependencies && @lockfile_dependencies
+ actual_by_name = @actual_dependencies.each_with_object({}) {|d, h| h[d.name] = d }
+ lockfile_by_name = @lockfile_dependencies.each_with_object({}) {|d, h| h[d.name] = d }
+
+ (actual_by_name.keys | lockfile_by_name.keys).sort.each do |name|
+ actual = actual_by_name[name]
+ lockfile = lockfile_by_name[name]
+ next if actual && lockfile && actual.requirement == lockfile.requirement
+
+ if actual && lockfile
+ lines << " #{name}: gemspec specifies #{actual.requirement}, lockfile has #{lockfile.requirement}"
+ elsif actual
+ lines << " #{name}: gemspec specifies #{actual.requirement}, not in lockfile"
+ else
+ lines << " #{name}: not in gemspec, lockfile has #{lockfile.requirement}"
+ end
+ end
+
+ lines << ""
+ end
+
+ lines << "Please run `bundle install` to regenerate the lockfile."
+ lines.join("\n")
+ end
+
+ status_code(41)
+ end
end
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 983de3137c..dea8abedba 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -2,53 +2,19 @@
module Bundler
class FeatureFlag
- def self.settings_flag(flag, &default)
- unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
- raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
- end
+ (1..10).each {|v| define_method("bundler_#{v}_mode?") { @major_version >= v } }
- settings_method("#{flag}?", flag, &default)
+ def removed_major?(target_major_version)
+ @major_version > target_major_version
end
- private_class_method :settings_flag
- def self.settings_option(key, &default)
- settings_method(key, key, &default)
+ def deprecated_major?(target_major_version)
+ @major_version >= target_major_version
end
- private_class_method :settings_option
-
- def self.settings_method(name, key, &default)
- define_method(name) do
- value = Bundler.settings[key]
- value = instance_eval(&default) if value.nil?
- value
- end
- end
- private_class_method :settings_method
-
- (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
-
- settings_flag(:allow_offline_install) { bundler_3_mode? }
- settings_flag(:auto_clean_without_path) { bundler_3_mode? }
- settings_flag(:cache_all) { bundler_3_mode? }
- settings_flag(:default_install_uses_path) { bundler_3_mode? }
- settings_flag(:forget_cli_options) { bundler_3_mode? }
- settings_flag(:global_gem_cache) { bundler_3_mode? }
- settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
- settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
- settings_flag(:print_only_version_number) { bundler_3_mode? }
- settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
- settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
- settings_flag(:update_requires_all_flag) { bundler_4_mode? }
-
- settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version)
+ @major_version = @bundler_version.segments.first
end
-
- def major_version
- @bundler_version.segments.first
- end
- private :major_version
end
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index e12c15af8a..0b6ced6f39 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
require_relative "vendored_persistent"
-require "cgi"
-require "securerandom"
+require_relative "vendored_timeout"
+require_relative "vendored_securerandom"
require "zlib"
-require "rubygems/request"
module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
+ autoload :Base, File.expand_path("fetcher/base", __dir__)
autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
@@ -36,8 +36,9 @@ module Bundler
# This is the error raised when a source is HTTPS and OpenSSL didn't load
class SSLError < HTTPError
def initialize(msg = nil)
- super msg || "Could not load OpenSSL.\n" \
- "You must recompile Ruby with OpenSSL support."
+ super "Could not load OpenSSL.\n" \
+ "You must recompile Ruby with OpenSSL support.\n" \
+ "original error: #{msg}\n"
end
end
@@ -61,19 +62,67 @@ module Bundler
end
end
+ # This error is raised if HTTP authentication is correct, but lacks
+ # necessary permissions.
+ class AuthenticationForbiddenError < HTTPError
+ def initialize(remote_uri)
+ remote_uri = filter_uri(remote_uri)
+ super "Access token could not be authenticated for #{remote_uri}.\n" \
+ "Make sure it's valid and has the necessary scopes configured."
+ end
+ end
+
+ HTTP_ERRORS = (Downloader::HTTP_RETRYABLE_ERRORS + Downloader::HTTP_NON_RETRYABLE_ERRORS).freeze
+ deprecate_constant :HTTP_ERRORS
+
+ NET_ERRORS = [
+ :HTTPBadGateway,
+ :HTTPBadRequest,
+ :HTTPFailedDependency,
+ :HTTPForbidden,
+ :HTTPInsufficientStorage,
+ :HTTPMethodNotAllowed,
+ :HTTPMovedPermanently,
+ :HTTPNoContent,
+ :HTTPNotFound,
+ :HTTPNotImplemented,
+ :HTTPPreconditionFailed,
+ :HTTPRequestEntityTooLarge,
+ :HTTPRequestURITooLong,
+ :HTTPUnauthorized,
+ :HTTPUnprocessableEntity,
+ :HTTPUnsupportedMediaType,
+ :HTTPVersionNotSupported,
+ ].freeze
+ deprecate_constant :NET_ERRORS
+
# Exceptions classes that should bypass retry attempts. If your password didn't work the
# first time, it's not going to the third time.
- NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
- :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed,
- :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound,
- :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge,
- :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
- :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
- FAIL_ERRORS = begin
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
- fail_errors << Gem::Requirement::BadRequirementError
- fail_errors.concat(NET_ERRORS.map {|e| Net.const_get(e) })
- end.freeze
+ FAIL_ERRORS = [
+ AuthenticationRequiredError,
+ BadAuthenticationError,
+ AuthenticationForbiddenError,
+ FallbackError,
+ SecurityError,
+ Gem::Requirement::BadRequirementError,
+ Gem::Net::HTTPBadGateway,
+ Gem::Net::HTTPBadRequest,
+ Gem::Net::HTTPFailedDependency,
+ Gem::Net::HTTPForbidden,
+ Gem::Net::HTTPInsufficientStorage,
+ Gem::Net::HTTPMethodNotAllowed,
+ Gem::Net::HTTPMovedPermanently,
+ Gem::Net::HTTPNoContent,
+ Gem::Net::HTTPNotFound,
+ Gem::Net::HTTPNotImplemented,
+ Gem::Net::HTTPPreconditionFailed,
+ Gem::Net::HTTPRequestEntityTooLarge,
+ Gem::Net::HTTPRequestURITooLong,
+ Gem::Net::HTTPUnauthorized,
+ Gem::Net::HTTPUnprocessableEntity,
+ Gem::Net::HTTPUnsupportedMediaType,
+ Gem::Net::HTTPVersionNotSupported,
+ ].freeze
class << self
attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries
@@ -84,6 +133,7 @@ module Bundler
self.max_retries = Bundler.settings[:retry] # How many retries for the API call
def initialize(remote)
+ @cis = nil
@remote = remote
Socket.do_not_reverse_lookup = true
@@ -99,15 +149,17 @@ module Bundler
spec -= [nil, "ruby", ""]
spec_file_name = "#{spec.join "-"}.gemspec"
- uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
- if uri.scheme == "file"
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
+ uri = Gem::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
+ spec = if uri.scheme == "file"
+ path = Gem::Util.correct_for_windows_path(uri.path)
Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else
Bundler.safe_load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
end
+ raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
+ spec
rescue MarshalError
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
"Your network or your gem server is probably having issues right now."
@@ -124,20 +176,11 @@ module Bundler
def specs(gem_names, source)
index = Bundler::Index.new
- if Bundler::Fetcher.disable_endpoint
- @use_api = false
- specs = fetchers.last.specs(gem_names)
- else
- specs = []
- @fetchers = fetchers.drop_while do |f|
- !f.available? || (f.api_fetcher? && !gem_names) || !specs = f.specs(gem_names)
- end
- @use_api = false if fetchers.none?(&:api_fetcher?)
- end
-
- specs.each do |name, version, platform, dependencies, metadata|
+ fetch_specs(gem_names).each do |name, version, platform, dependencies, metadata|
spec = if dependencies
- EndpointSpecification.new(name, version, platform, self, dependencies, metadata)
+ EndpointSpecification.new(name, version, platform, self, dependencies, metadata).tap do |es|
+ source.checksum_store.replace(es, es.checksum)
+ end
else
RemoteSpecification.new(name, version, platform, self)
end
@@ -148,22 +191,10 @@ module Bundler
index
rescue CertificateFailureError
- Bundler.ui.info "" if gem_names && use_api # newline after dots
+ Bundler.ui.info "" if gem_names && api_fetcher? # newline after dots
raise
end
- def use_api
- return @use_api if defined?(@use_api)
-
- fetchers.shift until fetchers.first.available?
-
- @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
- false
- else
- fetchers.first.api_fetcher?
- end
- end
-
def user_agent
@user_agent ||= begin
ruby = Bundler::RubyVersion.system
@@ -189,7 +220,7 @@ module Bundler
agent << " ci/#{cis.join(",")}" if cis.any?
# add a random ID so we can consolidate runs server-side
- agent << " " << SecureRandom.hex(8)
+ agent << " " << Gem::SecureRandom.hex(8)
# add any user agent strings set in the config
extra_ua = Bundler.settings[:user_agent]
@@ -199,10 +230,6 @@ module Bundler
end
end
- def fetchers
- @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
- end
-
def http_proxy
return unless uri = connection.proxy_uri
uri.to_s
@@ -212,25 +239,49 @@ module Bundler
"#<#{self.class}:0x#{object_id} uri=#{uri}>"
end
+ def api_fetcher?
+ fetchers.first.api_fetcher?
+ end
+
+ def gem_remote_fetcher
+ @gem_remote_fetcher ||= begin
+ require_relative "fetcher/gem_remote_fetcher"
+ fetcher = GemRemoteFetcher.new Gem.configuration[:http_proxy]
+ fetcher.headers["User-Agent"] = user_agent
+ fetcher.headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
+ fetcher
+ end
+ end
+
private
- FETCHERS = [CompactIndex, Dependency, Index].freeze
+ def available_fetchers
+ if Bundler::Fetcher.disable_endpoint
+ [Index]
+ elsif remote_uri.scheme == "file"
+ Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
+ [Index]
+ else
+ [CompactIndex, Dependency, Index]
+ end
+ end
+
+ def fetchers
+ @fetchers ||= available_fetchers.map {|f| f.new(downloader, @remote, uri, gem_remote_fetcher) }.drop_while {|f| !f.available? }
+ end
+
+ def fetch_specs(gem_names)
+ fetchers.reject!(&:api_fetcher?) unless gem_names
+ fetchers.reject! do |f|
+ specs = f.specs(gem_names)
+ return specs if specs
+ true
+ end
+ []
+ end
def cis
- env_cis = {
- "TRAVIS" => "travis",
- "CIRCLECI" => "circle",
- "SEMAPHORE" => "semaphore",
- "JENKINS_URL" => "jenkins",
- "BUILDBOX" => "buildbox",
- "GO_SERVER_URL" => "go",
- "SNAP_CI" => "snap",
- "GITLAB_CI" => "gitlab",
- "GITHUB_ACTIONS" => "github",
- "CI_NAME" => ENV["CI_NAME"],
- "CI" => "ci",
- }
- env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
+ @cis ||= Bundler::CIDetector.ci_strings
end
def connection
@@ -238,11 +289,17 @@ module Bundler
needs_ssl = remote_uri.scheme == "https" ||
Bundler.settings[:ssl_verify_mode] ||
Bundler.settings[:ssl_client_cert]
- raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
+ if needs_ssl
+ begin
+ require "openssl"
+ rescue StandardError, LoadError => e
+ raise SSLError.new(e.message)
+ end
+ end
- con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
+ con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
if gem_proxy = Gem.configuration[:http_proxy]
- con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy
+ con.proxy = Gem::URI.parse(gem_proxy) if gem_proxy != :no_proxy
end
if remote_uri.scheme == "https"
@@ -274,13 +331,6 @@ module Bundler
paths.find {|path| File.file? path }
end
- HTTP_ERRORS = [
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
- Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
- PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
- ].freeze
-
def bundler_cert_store
store = OpenSSL::X509::Store.new
ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
@@ -294,6 +344,7 @@ module Bundler
end
else
store.set_default_paths
+ require "rubygems/request"
Gem::Request.get_cert_files.each {|c| store.add_file c }
end
store
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb
index 62cc75add8..cfec2f8e94 100644
--- a/lib/bundler/fetcher/base.rb
+++ b/lib/bundler/fetcher/base.rb
@@ -6,12 +6,14 @@ module Bundler
attr_reader :downloader
attr_reader :display_uri
attr_reader :remote
+ attr_reader :gem_remote_fetcher
- def initialize(downloader, remote, display_uri)
+ def initialize(downloader, remote, display_uri, gem_remote_fetcher)
raise "Abstract class" if self.class == Base
@downloader = downloader
@remote = remote
@display_uri = display_uri
+ @gem_remote_fetcher = gem_remote_fetcher
end
def remote_uri
@@ -38,9 +40,9 @@ module Bundler
private
- def log_specs(debug_msg)
+ def log_specs(&block)
if Bundler.ui.debug?
- Bundler.ui.debug debug_msg
+ Bundler.ui.debug yield
else
Bundler.ui.info ".", false
end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 674d2b49f1..52168111fe 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -4,18 +4,16 @@ require_relative "base"
require_relative "../worker"
module Bundler
- autoload :CompactIndexClient, File.expand_path("../compact_index_client", __dir__)
-
class Fetcher
class CompactIndex < Base
def self.compact_index_request(method_name)
method = instance_method(method_name)
undef_method(method_name)
define_method(method_name) do |*args, &blk|
- method.bind(self).call(*args, &blk)
- rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
+ method.bind_call(self, *args, &blk)
+ rescue NetworkDownError, CompactIndexClient::Updater::MismatchedChecksumError => e
raise HTTPError, e.message
- rescue AuthenticationRequiredError
+ rescue AuthenticationRequiredError, BadAuthenticationError
# Fail since we got a 401 from the server.
raise
rescue HTTPError => e
@@ -35,16 +33,9 @@ module Bundler
remaining_gems = gem_names.dup
until remaining_gems.empty?
- log_specs "Looking up gems #{remaining_gems.inspect}"
-
- deps = begin
- parallel_compact_index_client.dependencies(remaining_gems)
- rescue TooManyRequestsError
- @bundle_worker&.stop
- @bundle_worker = nil # reset it. Not sure if necessary
- serial_compact_index_client.dependencies(remaining_gems)
- end
- next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
+ log_specs { "Looking up gems #{remaining_gems.inspect}" }
+ deps = fetch_gem_infos(remaining_gems).flatten(1)
+ next_gems = deps.flat_map {|d| d[CompactIndexClient::INFO_DEPS].flat_map(&:first) }.uniq
deps.each {|dep| gem_info << dep }
complete_gems.concat(deps.map(&:first)).uniq!
remaining_gems = next_gems - complete_gems
@@ -60,13 +51,9 @@ module Bundler
Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
return nil
end
- if fetch_uri.scheme == "file"
- Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
- return false
- end
# Read info file checksums out of /versions, so we can know if gems are up to date
- compact_index_client.update_and_parse_checksums!
- rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
+ compact_index_client.available?
+ rescue CompactIndexClient::Updater::MismatchedChecksumError => e
Bundler.ui.debug(e.message)
nil
end
@@ -85,20 +72,20 @@ module Bundler
end
end
- def parallel_compact_index_client
- compact_index_client.execution_mode = lambda do |inputs, &blk|
- func = lambda {|object, _index| blk.call(object) }
- worker = bundle_worker(func)
- inputs.each {|input| worker.enq(input) }
- inputs.map { worker.deq }
- end
-
- compact_index_client
+ def fetch_gem_infos(names)
+ in_parallel(names) {|name| compact_index_client.info(name) }
+ rescue TooManyRequestsError # rubygems.org is rate limiting us, slow down.
+ @bundle_worker&.stop
+ @bundle_worker = nil # reset it. Not sure if necessary
+ compact_index_client.reset!
+ names.map {|name| compact_index_client.info(name) }
end
- def serial_compact_index_client
- compact_index_client.sequential_execution_mode!
- compact_index_client
+ def in_parallel(inputs, &blk)
+ func = lambda {|object, _index| blk.call(object) }
+ worker = bundle_worker(func)
+ inputs.each {|input| worker.enq(input) }
+ inputs.map { worker.deq }
end
def bundle_worker(func = nil)
@@ -123,9 +110,9 @@ module Bundler
def call(path, headers)
fetcher.downloader.fetch(fetcher.fetch_uri + path, headers)
rescue NetworkDownError => e
- raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"]
+ raise unless headers["If-None-Match"]
ui.warn "Using the cached data for the new index because of a network error: #{e}"
- Net::HTTPNotModified.new(nil, nil, nil)
+ Gem::Net::HTTPNotModified.new(nil, nil, nil)
end
end
end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 332f86139d..4f2414e33d 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
require_relative "base"
-require "cgi"
+require "cgi/escape"
+require "cgi/util" unless defined?(CGI::EscapeExt)
module Bundler
class Fetcher
@@ -24,7 +25,7 @@ module Bundler
def specs(gem_names, full_dependency_list = [], last_spec_list = [])
query_list = gem_names.uniq - full_dependency_list
- log_specs "Query List: #{query_list.inspect}"
+ log_specs { "Query List: #{query_list.inspect}" }
return last_spec_list if query_list.empty?
@@ -34,14 +35,10 @@ module Bundler
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue MarshalError
+ rescue MarshalError, HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
- rescue HTTPError, GemspecError
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
- nil
end
def dependency_specs(gem_names)
@@ -53,7 +50,7 @@ module Bundler
def unmarshalled_dep_gems(gem_names)
gem_list = []
- gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
+ gem_names.each_slice(api_request_size) do |names|
marshalled_deps = downloader.fetch(dependency_api_uri(names)).body
gem_list.concat(Bundler.safe_load_marshal(marshalled_deps))
end
@@ -77,6 +74,12 @@ module Bundler
uri.query = "gems=#{CGI.escape(gem_names.sort.join(","))}" if gem_names.any?
uri
end
+
+ private
+
+ def api_request_size
+ Bundler.settings[:api_request_size]&.to_i || Source::Rubygems::API_REQUEST_SIZE
+ end
end
end
end
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index 28d33f1aed..179eed8340 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -3,6 +3,28 @@
module Bundler
class Fetcher
class Downloader
+ HTTP_NON_RETRYABLE_ERRORS = [
+ SocketError,
+ Errno::EADDRNOTAVAIL,
+ Errno::ENETDOWN,
+ Errno::ENETUNREACH,
+ Gem::Net::HTTP::Persistent::Error,
+ Errno::EHOSTUNREACH,
+ ].freeze
+
+ HTTP_RETRYABLE_ERRORS = [
+ Gem::Timeout::Error,
+ EOFError,
+ Errno::EINVAL,
+ Errno::ECONNRESET,
+ Errno::ETIMEDOUT,
+ Errno::EAGAIN,
+ Gem::Net::HTTPBadResponse,
+ Gem::Net::HTTPHeaderSyntaxError,
+ Gem::Net::ProtocolError,
+ Zlib::BufError,
+ ].freeze
+
attr_reader :connection
attr_reader :redirect_limit
@@ -20,31 +42,34 @@ module Bundler
Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}")
case response
- when Net::HTTPSuccess, Net::HTTPNotModified
+ when Gem::Net::HTTPSuccess, Gem::Net::HTTPNotModified
response
- when Net::HTTPRedirection
- new_uri = Bundler::URI.parse(response["location"])
+ when Gem::Net::HTTPRedirection
+ new_uri = Gem::URI.parse(response["location"])
if new_uri.host == uri.host
new_uri.user = uri.user
new_uri.password = uri.password
end
fetch(new_uri, headers, counter + 1)
- when Net::HTTPRequestedRangeNotSatisfiable
+ when Gem::Net::HTTPRequestedRangeNotSatisfiable
new_headers = headers.dup
new_headers.delete("Range")
- new_headers["Accept-Encoding"] = "gzip"
fetch(uri, new_headers)
- when Net::HTTPRequestEntityTooLarge
+ when Gem::Net::HTTPRequestEntityTooLarge
raise FallbackError, response.body
- when Net::HTTPTooManyRequests
+ when Gem::Net::HTTPTooManyRequests
raise TooManyRequestsError, response.body
- when Net::HTTPUnauthorized
+ when Gem::Net::HTTPUnauthorized
raise BadAuthenticationError, uri.host if uri.userinfo
raise AuthenticationRequiredError, uri.host
- when Net::HTTPNotFound
- raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}"
+ when Gem::Net::HTTPForbidden
+ raise AuthenticationForbiddenError, uri.host
+ when Gem::Net::HTTPNotFound
+ raise FallbackError, "Gem::Net::HTTPNotFound: #{filtered_uri}"
else
- raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
+ message = "Gem::#{response.class.name.gsub(/\AGem::/, "")}"
+ message += ": #{response.body}" unless response.body.empty?
+ raise HTTPError, message
end
end
@@ -54,7 +79,7 @@ module Bundler
filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
Bundler.ui.debug "HTTP GET #{filtered_uri}"
- req = Net::HTTP::Get.new uri.request_uri, headers
+ req = Gem::Net::HTTP::Get.new uri.request_uri, headers
if uri.user
user = CGI.unescape(uri.user)
password = uri.password ? CGI.unescape(uri.password) : nil
@@ -63,15 +88,19 @@ module Bundler
connection.request(uri, req)
rescue OpenSSL::SSL::SSLError
raise CertificateFailureError.new(uri)
- rescue *HTTP_ERRORS => e
+ rescue *HTTP_NON_RETRYABLE_ERRORS => e
Bundler.ui.trace e
- if e.is_a?(SocketError) || e.message.to_s.include?("host down:")
- raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
- "connection and try again."
- else
- raise HTTPError, "Network error while fetching #{filtered_uri}" \
+
+ host = uri.host
+ host_port = "#{host}:#{uri.port}"
+ host = host_port if filtered_uri.to_s.include?(host_port)
+ raise NetworkDownError, "Could not reach host #{host}. Check your network " \
+ "connection and try again."
+ rescue *HTTP_RETRYABLE_ERRORS => e
+ Bundler.ui.trace e
+
+ raise HTTPError, "Network error while fetching #{filtered_uri}" \
" (#{e})"
- end
end
private
diff --git a/lib/bundler/fetcher/gem_remote_fetcher.rb b/lib/bundler/fetcher/gem_remote_fetcher.rb
new file mode 100644
index 0000000000..3159e05688
--- /dev/null
+++ b/lib/bundler/fetcher/gem_remote_fetcher.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require "rubygems/remote_fetcher"
+
+module Bundler
+ class Fetcher
+ class GemRemoteFetcher < Gem::RemoteFetcher
+ def initialize(*)
+ super
+
+ @pool_size = Bundler.settings.installation_parallelization
+ end
+
+ def request(*args)
+ super do |req|
+ req.delete("User-Agent") if headers["User-Agent"]
+ yield req if block_given?
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
index 6bb9fcc193..6e37e1e5d1 100644
--- a/lib/bundler/fetcher/index.rb
+++ b/lib/bundler/fetcher/index.rb
@@ -6,7 +6,7 @@ module Bundler
class Fetcher
class Index < Base
def specs(_gem_names)
- Bundler.rubygems.fetch_all_remote_specs(remote)
+ Bundler.rubygems.fetch_all_remote_specs(remote, gem_remote_fetcher)
rescue Gem::RemoteFetcher::FetchError => e
case e.message
when /certificate verify failed/
@@ -15,8 +15,7 @@ module Bundler
raise BadAuthenticationError, remote_uri if remote_uri.userinfo
raise AuthenticationRequiredError, remote_uri
when /403/
- raise BadAuthenticationError, remote_uri if remote_uri.userinfo
- raise AuthenticationRequiredError, remote_uri
+ raise AuthenticationForbiddenError, remote_uri
else
raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
end
diff --git a/lib/bundler/force_platform.rb b/lib/bundler/force_platform.rb
index 249a24ecd1..7af33218cb 100644
--- a/lib/bundler/force_platform.rb
+++ b/lib/bundler/force_platform.rb
@@ -2,8 +2,6 @@
module Bundler
module ForcePlatform
- private
-
# The `:force_ruby_platform` value used by dependencies for resolution, and
# by locked specifications for materialization is `false` by default, except
# for TruffleRuby. TruffleRuby generally needs to force the RUBY platform
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 39afe8a071..5e8eaee6bb 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -32,7 +32,7 @@ module Bundler
if Bundler.ui.debug?
Bundler.ui.trace error
else
- Bundler.ui.error error.message, :wrap => true
+ Bundler.ui.error error.message, wrap: true
end
when Thor::Error
Bundler.ui.error error.message
@@ -40,7 +40,7 @@ module Bundler
Bundler.ui.error "\nQuitting..."
Bundler.ui.trace error
when Gem::InvalidSpecificationException
- Bundler.ui.error error.message, :wrap => true
+ Bundler.ui.error error.message, wrap: true
when SystemExit
when *[defined?(Java::JavaLang::OutOfMemoryError) && Java::JavaLang::OutOfMemoryError].compact
Bundler.ui.error "\nYour JVM has run out of memory, and Bundler cannot continue. " \
@@ -61,7 +61,7 @@ module Bundler
end
def request_issue_report_for(e)
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, nil
+ Bundler.ui.error <<~EOS, nil, nil
--- ERROR REPORT TEMPLATE -------------------------------------------------------
```
@@ -75,12 +75,12 @@ module Bundler
Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, :yellow
+ Bundler.ui.error <<~EOS, nil, :yellow
First, try this link to see if there are any existing issue reports for this error:
#{issues_url(e)}
- If there aren't any reports for this error yet, please fill in the new issue form located at #{new_issue_url}, and copy and paste the report template above in there.
+ If there aren't any reports for this error yet, please fill in the new issue form located at #{new_issue_url}. Make sure to copy and paste the full output of this command under the "What happened instead?" section.
EOS
end
@@ -93,7 +93,7 @@ module Bundler
end
def serialized_exception_for(e)
- <<-EOS.gsub(/^ {8}/, "")
+ <<~EOS
#{e.class}: #{e.message}
#{e.backtrace&.join("\n ")&.chomp}
EOS
@@ -102,13 +102,14 @@ module Bundler
def issues_url(exception)
message = exception.message.lines.first.tr(":", " ").chomp
message = message.split("-").first if exception.is_a?(Errno)
- require "cgi"
- "https://github.com/rubygems/rubygems/search?q=" \
+ require "cgi/escape"
+ require "cgi/util" unless defined?(CGI::EscapeExt)
+ "https://github.com/ruby/rubygems/search?q=" \
"#{CGI.escape(message)}&type=Issues"
end
def new_issue_url
- "https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md"
+ "https://github.com/ruby/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md"
end
end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index dcf759cded..5ce0ef6280 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -47,7 +47,7 @@ module Bundler
built_gem_path = build_gem
end
- desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory."
+ desc "Generate SHA512 checksum of #{name}-#{version}.gem into the checksums directory."
task "build:checksum" => "build" do
build_checksum(built_gem_path)
end
@@ -215,7 +215,7 @@ module Bundler
def sh_with_status(cmd, &block)
Bundler.ui.debug(cmd)
SharedHelpers.chdir(base) do
- outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
+ outbuf = IO.popen(cmd, err: [:child, :out], &:read)
status = $?
block&.call(outbuf) if status.success?
[outbuf, status]
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
deleted file mode 100644
index 2e6d788f9c..0000000000
--- a/lib/bundler/gem_helpers.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- module GemHelpers
- GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant
- GENERICS = [
- [Gem::Platform.new("java"), Gem::Platform.new("java")],
- [Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
- [Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
- [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
- [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
- [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
- [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")],
- [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
- ].freeze
-
- def generic(p)
- GENERIC_CACHE[p] ||= begin
- _, found = GENERICS.find do |match, _generic|
- p.os == match.os && (!match.cpu || p.cpu == match.cpu)
- end
- found || Gem::Platform::RUBY
- end
- end
- module_function :generic
-
- def generic_local_platform
- generic(local_platform)
- end
- module_function :generic_local_platform
-
- def local_platform
- Bundler.local_platform
- end
- module_function :local_platform
-
- def platform_specificity_match(spec_platform, user_platform)
- spec_platform = Gem::Platform.new(spec_platform)
-
- PlatformMatch.specificity_score(spec_platform, user_platform)
- end
- module_function :platform_specificity_match
-
- def select_best_platform_match(specs, platform)
- matching = specs.select {|spec| spec.match_platform(platform) }
-
- sort_best_platform_match(matching, platform)
- end
- module_function :select_best_platform_match
-
- def sort_best_platform_match(matching, platform)
- exact = matching.select {|spec| spec.platform == platform }
- return exact if exact.any?
-
- sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
- exemplary_spec = sorted_matching.first
-
- sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
- end
- module_function :sort_best_platform_match
-
- class PlatformMatch
- def self.specificity_score(spec_platform, user_platform)
- return -1 if spec_platform == user_platform
- return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
-
- os_match(spec_platform, user_platform) +
- cpu_match(spec_platform, user_platform) * 10 +
- platform_version_match(spec_platform, user_platform) * 100
- end
-
- def self.os_match(spec_platform, user_platform)
- if spec_platform.os == user_platform.os
- 0
- else
- 1
- end
- end
-
- def self.cpu_match(spec_platform, user_platform)
- if spec_platform.cpu == user_platform.cpu
- 0
- elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
- 0
- elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
- 1
- else
- 2
- end
- end
-
- def self.platform_version_match(spec_platform, user_platform)
- if spec_platform.version == user_platform.version
- 0
- elsif spec_platform.version.nil?
- 1
- else
- 2
- end
- end
- end
-
- def same_specificity(platform, spec, exemplary_spec)
- platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
- end
- module_function :same_specificity
-
- def same_deps(spec, exemplary_spec)
- same_runtime_deps = spec.dependencies.sort == exemplary_spec.dependencies.sort
- return same_runtime_deps unless spec.is_a?(Gem::Specification) && exemplary_spec.is_a?(Gem::Specification)
-
- same_metadata_deps = spec.required_ruby_version == exemplary_spec.required_ruby_version && spec.required_rubygems_version == exemplary_spec.required_rubygems_version
- same_runtime_deps && same_metadata_deps
- end
- module_function :same_deps
- end
-end
diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb
index f08fceb7e2..d64dbacfdb 100644
--- a/lib/bundler/gem_version_promoter.rb
+++ b/lib/bundler/gem_version_promoter.rb
@@ -45,17 +45,37 @@ module Bundler
# Given a Resolver::Package and an Array of Specifications of available
# versions for a gem, this method will return the Array of Specifications
- # sorted (and possibly truncated if strict is true) in an order to give
- # preference to the current level (:major, :minor or :patch) when resolution
- # is deciding what versions best resolve all dependencies in the bundle.
+ # sorted in an order to give preference to the current level (:major, :minor
+ # or :patch) when resolution is deciding what versions best resolve all
+ # dependencies in the bundle.
# @param package [Resolver::Package] The package being resolved.
# @param specs [Specification] An array of Specifications for the package.
- # @return [Specification] A new instance of the Specification Array sorted and
- # possibly filtered.
+ # @return [Specification] A new instance of the Specification Array sorted.
def sort_versions(package, specs)
- specs = filter_dep_specs(specs, package) if strict
+ locked_version = package.locked_version
+
+ result = specs.sort do |a, b|
+ unless package.prerelease_specified? || pre?
+ a_pre = a.prerelease?
+ b_pre = b.prerelease?
+
+ next 1 if a_pre && !b_pre
+ next -1 if b_pre && !a_pre
+ end
- sort_dep_specs(specs, package)
+ if major? || locked_version.nil?
+ b <=> a
+ elsif either_version_older_than_locked?(a, b, locked_version)
+ b <=> a
+ elsif segments_do_not_match?(a, b, :major)
+ a <=> b
+ elsif !minor? && segments_do_not_match?(a, b, :minor)
+ a <=> b
+ else
+ b <=> a
+ end
+ end
+ post_sort(result, package.unlock?, locked_version)
end
# @return [bool] Convenience method for testing value of level variable.
@@ -73,9 +93,18 @@ module Bundler
pre == true
end
- private
+ # Given a Resolver::Package and an Array of Specifications of available
+ # versions for a gem, this method will truncate the Array if strict
+ # is true. That means filtering out downgrades from the version currently
+ # locked, and filtering out upgrades that go past the selected level (major,
+ # minor, or patch).
+ # @param package [Resolver::Package] The package being resolved.
+ # @param specs [Specification] An array of Specifications for the package.
+ # @return [Specification] A new instance of the Specification Array
+ # truncated.
+ def filter_versions(package, specs)
+ return specs unless strict
- def filter_dep_specs(specs, package)
locked_version = package.locked_version
return specs if locked_version.nil? || major?
@@ -89,35 +118,10 @@ module Bundler
end
end
- def sort_dep_specs(specs, package)
- locked_version = package.locked_version
-
- result = specs.sort do |a, b|
- unless locked_version && (package.prerelease_specified? || pre?)
- a_pre = a.prerelease?
- b_pre = b.prerelease?
-
- next -1 if a_pre && !b_pre
- next 1 if b_pre && !a_pre
- end
-
- if major?
- a <=> b
- elsif either_version_older_than_locked?(a, b, locked_version)
- a <=> b
- elsif segments_do_not_match?(a, b, :major)
- b <=> a
- elsif !minor? && segments_do_not_match?(a, b, :minor)
- b <=> a
- else
- a <=> b
- end
- end
- post_sort(result, package.unlock?, locked_version)
- end
+ private
def either_version_older_than_locked?(a, b, locked_version)
- locked_version && (a.version < locked_version || b.version < locked_version)
+ a.version < locked_version || b.version < locked_version
end
def segments_do_not_match?(a, b, level)
@@ -128,18 +132,16 @@ module Bundler
# Specific version moves can't always reliably be done during sorting
# as not all elements are compared against each other.
def post_sort(result, unlock, locked_version)
- # default :major behavior in Bundler does not do this
- return result if major?
if unlock || locked_version.nil?
result
else
- move_version_to_end(result, locked_version)
+ move_version_to_beginning(result, locked_version)
end
end
- def move_version_to_end(result, version)
+ def move_version_to_beginning(result, version)
move, keep = result.partition {|s| s.version.to_s == version.to_s }
- keep.concat(move)
+ move.concat(keep)
end
end
end
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb
deleted file mode 100644
index 3c008e63e3..0000000000
--- a/lib/bundler/graph.rb
+++ /dev/null
@@ -1,152 +0,0 @@
-# frozen_string_literal: true
-
-require "set"
-module Bundler
- class Graph
- GRAPH_NAME = :Gemfile
-
- def initialize(env, output_file, show_version = false, show_requirements = false, output_format = "png", without = [])
- @env = env
- @output_file = output_file
- @show_version = show_version
- @show_requirements = show_requirements
- @output_format = output_format
- @without_groups = without.map(&:to_sym)
-
- @groups = []
- @relations = Hash.new {|h, k| h[k] = Set.new }
- @node_options = {}
- @edge_options = {}
-
- _populate_relations
- end
-
- attr_reader :groups, :relations, :node_options, :edge_options, :output_file, :output_format
-
- def viz
- GraphVizClient.new(self).run
- end
-
- private
-
- def _populate_relations
- parent_dependencies = _groups.values.to_set.flatten
- loop do
- break if parent_dependencies.empty?
-
- tmp = Set.new
- parent_dependencies.each do |dependency|
- child_dependencies = spec_for_dependency(dependency).runtime_dependencies.to_set
- @relations[dependency.name] += child_dependencies.map(&:name).to_set
- tmp += child_dependencies
-
- @node_options[dependency.name] = _make_label(dependency, :node)
- child_dependencies.each do |c_dependency|
- @edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge)
- end
- end
- parent_dependencies = tmp
- end
- end
-
- def _groups
- relations = Hash.new {|h, k| h[k] = Set.new }
- @env.current_dependencies.each do |dependency|
- dependency.groups.each do |group|
- next if @without_groups.include?(group)
-
- relations[group.to_s].add(dependency)
- @relations[group.to_s].add(dependency.name)
-
- @node_options[group.to_s] ||= _make_label(group, :node)
- @edge_options["#{group}_#{dependency.name}"] = _make_label(dependency, :edge)
- end
- end
- @groups = relations.keys
- relations
- end
-
- def _make_label(symbol_or_string_or_dependency, element_type)
- case element_type.to_sym
- when :node
- if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
- label = symbol_or_string_or_dependency.name.dup
- label << "\n#{spec_for_dependency(symbol_or_string_or_dependency).version}" if @show_version
- else
- label = symbol_or_string_or_dependency.to_s
- end
- when :edge
- label = nil
- if symbol_or_string_or_dependency.respond_to?(:requirements_list) && @show_requirements
- tmp = symbol_or_string_or_dependency.requirements_list.join(", ")
- label = tmp if tmp != ">= 0"
- end
- else
- raise ArgumentError, "2nd argument is invalid"
- end
- label.nil? ? {} : { :label => label }
- end
-
- def spec_for_dependency(dependency)
- @env.requested_specs.find {|s| s.name == dependency.name }
- end
-
- class GraphVizClient
- def initialize(graph_instance)
- @graph_name = graph_instance.class::GRAPH_NAME
- @groups = graph_instance.groups
- @relations = graph_instance.relations
- @node_options = graph_instance.node_options
- @edge_options = graph_instance.edge_options
- @output_file = graph_instance.output_file
- @output_format = graph_instance.output_format
- end
-
- def g
- @g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g|
- g.edge[:weight] = 2
- g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif"
- g.edge[:fontsize] = 12
- end
- end
-
- def run
- @groups.each do |group|
- g.add_nodes(
- group, {
- :style => "filled",
- :fillcolor => "#B9B9D5",
- :shape => "box3d",
- :fontsize => 16,
- }.merge(@node_options[group])
- )
- end
-
- @relations.each do |parent, children|
- children.each do |child|
- if @groups.include?(parent)
- g.add_nodes(child, { :style => "filled", :fillcolor => "#B9B9D5" }.merge(@node_options[child]))
- g.add_edges(parent, child, { :constraint => false }.merge(@edge_options["#{parent}_#{child}"]))
- else
- g.add_nodes(child, @node_options[child])
- g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
- end
- end
- end
-
- if @output_format.to_s == "debug"
- $stdout.puts g.output :none => String
- Bundler.ui.info "debugging bundle viz..."
- else
- begin
- g.output @output_format.to_sym => "#{@output_file}.#{@output_format}"
- Bundler.ui.info "#{@output_file}.#{@output_format}"
- rescue ArgumentError => e
- warn "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb"
- raise e
- end
- end
- end
- end
- end
-end
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index b8c599f63a..9aef2dfa12 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -10,8 +10,8 @@ module Bundler
i
end
- attr_reader :specs, :all_specs, :sources
- protected :specs, :all_specs
+ attr_reader :specs, :duplicates, :sources
+ protected :specs, :duplicates
RUBY = "ruby"
NULL = "\0"
@@ -19,21 +19,21 @@ module Bundler
def initialize
@sources = []
@cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
+ @specs = {}
+ @duplicates = {}
end
def initialize_copy(o)
@sources = o.sources.dup
@cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
+ @specs = {}
+ @duplicates = {}
o.specs.each do |name, hash|
@specs[name] = hash.dup
end
- o.all_specs.each do |name, array|
- @all_specs[name] = array.dup
+ o.duplicates.each do |name, array|
+ @duplicates[name] = array.dup
end
end
@@ -46,14 +46,6 @@ module Bundler
true
end
- def search_all(name)
- all_matches = local_search(name) + @all_specs[name]
- @sources.each do |source|
- all_matches.concat(source.search_all(name))
- end
- all_matches
- end
-
# Search this index's specs, and any source indexes that this index knows
# about, returning all of the results.
def search(query)
@@ -61,11 +53,14 @@ module Bundler
return results unless @sources.any?
@sources.each do |source|
- results.concat(source.search(query))
+ results = safe_concat(results, source.search(query))
end
- results.uniq(&:full_name)
+ results.uniq!(&:full_name) unless results.empty? # avoid modifying frozen EMPTY_SEARCH
+ results
end
+ alias_method :[], :search
+
def local_search(query)
case query
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
@@ -76,12 +71,10 @@ module Bundler
end
end
- alias_method :[], :search
-
- def <<(spec)
- @specs[spec.name][spec.full_name] = spec
- spec
+ def add(spec)
+ (@specs[spec.name] ||= {}).store(spec.full_name, spec)
end
+ alias_method :<<, :add
def each(&blk)
return enum_for(:each) unless blk
@@ -115,15 +108,30 @@ module Bundler
names.uniq
end
- def use(other, override_dupes = false)
+ # Combines indexes proritizing existing specs, like `Hash#reverse_merge!`
+ # Duplicate specs found in `other` are stored in `@duplicates`.
+ def use(other)
return unless other
- other.each do |s|
- if (dupes = search_by_spec(s)) && !dupes.empty?
- # safe to << since it's a new array when it has contents
- @all_specs[s.name] = dupes << s
- next unless override_dupes
+ other.each do |spec|
+ exist?(spec) ? add_duplicate(spec) : add(spec)
+ end
+ self
+ end
+
+ # Combines indexes proritizing specs from `other`, like `Hash#merge!`
+ # Duplicate specs found in `self` are saved in `@duplicates`.
+ def merge!(other)
+ return unless other
+ other.each do |spec|
+ if existing = find_by_spec(spec)
+ unless dependencies_eql?(existing, spec)
+ Bundler.ui.warn "Local specification for #{spec.full_name} has different dependencies than the remote gem, ignoring it"
+ next
+ end
+
+ add_duplicate(existing)
end
- self << s
+ add spec
end
self
end
@@ -135,8 +143,7 @@ module Bundler
end
# Whether all the specs in self are in other
- # TODO: rename to #include?
- def ==(other)
+ def subset?(other)
all? do |spec|
other_spec = other[spec].first
other_spec && dependencies_eql?(spec, other_spec) && spec.source == other_spec.source
@@ -144,8 +151,8 @@ module Bundler
end
def dependencies_eql?(spec, other_spec)
- deps = spec.dependencies.select {|d| d.type != :development }
- other_deps = other_spec.dependencies.select {|d| d.type != :development }
+ deps = spec.runtime_dependencies
+ other_deps = other_spec.runtime_dependencies
deps.sort == other_deps.sort
end
@@ -157,19 +164,40 @@ module Bundler
private
+ def safe_concat(a, b)
+ return a if b.empty?
+ return b if a.empty?
+ a.concat(b)
+ end
+
+ def add_duplicate(spec)
+ (@duplicates[spec.name] ||= []) << spec
+ end
+
def specs_by_name_and_version(name, version)
- specs_by_name(name).select {|spec| spec.version == version }
+ results = @specs[name]&.values
+ return EMPTY_SEARCH unless results
+ results.select! {|spec| spec.version == version }
+ results
end
def specs_by_name(name)
- @specs[name].values
+ @specs[name]&.values || EMPTY_SEARCH
end
EMPTY_SEARCH = [].freeze
def search_by_spec(spec)
- spec = @specs[spec.name][spec.full_name]
+ spec = find_by_spec(spec)
spec ? [spec] : EMPTY_SEARCH
end
+
+ def find_by_spec(spec)
+ @specs[spec.name]&.fetch(spec.full_name, nil)
+ end
+
+ def exist?(spec)
+ @specs[spec.name]&.key?(spec.full_name)
+ end
end
end
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index cb644a7f69..6aa9179024 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -23,13 +23,10 @@ module Bundler
# @param [Pathname] lockfile_path The lockfile in which to inject the new dependency.
# @return [Array]
def inject(gemfile_path, lockfile_path)
- if Bundler.frozen_bundle?
- # ensure the lock and Gemfile are synced
- Bundler.definition.ensure_equivalent_gemfile_and_lockfile(true)
- end
+ Bundler.definition.ensure_equivalent_gemfile_and_lockfile(true)
# temporarily unfreeze
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
+ Bundler.settings.temporary(deployment: false, frozen: false) do
# evaluate the Gemfile we have now
builder = Dsl.new
builder.eval_gemfile(gemfile_path)
@@ -44,13 +41,13 @@ module Bundler
# resolve to see if the new deps broke anything
@definition = builder.to_definition(lockfile_path, {})
- @definition.resolve_remotely!
+ @definition.remotely!
# since nothing broke, we can add those gems to the gemfile
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
# since we resolved successfully, write out the lockfile
- @definition.lock(Bundler.default_lockfile)
+ @definition.lock
# invalidate the cached Bundler.definition
Bundler.reset_paths!
@@ -83,20 +80,19 @@ module Bundler
def conservative_version(spec)
version = spec.version
return ">= 0" if version.nil?
- segments = version.segments
seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
- prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
- "#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
+ prerelease_suffix = version.to_s.delete_prefix(version.release.to_s) if version.prerelease?
+ "#{version_prefix}#{version.segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
end
def version_prefix
if @options[:strict]
"= "
- elsif @options[:optimistic]
- ">= "
- else
+ elsif @options[:pessimistic]
"~> "
+ else
+ ">= "
end
end
@@ -111,18 +107,19 @@ module Bundler
end
if d.groups != Array(:default)
- group = d.groups.size == 1 ? ", :group => #{d.groups.first.inspect}" : ", :groups => #{d.groups.inspect}"
+ group = d.groups.size == 1 ? ", group: #{d.groups.first.inspect}" : ", groups: #{d.groups.inspect}"
end
- source = ", :source => \"#{d.source}\"" unless d.source.nil?
- path = ", :path => \"#{d.path}\"" unless d.path.nil?
- git = ", :git => \"#{d.git}\"" unless d.git.nil?
- github = ", :github => \"#{d.github}\"" unless d.github.nil?
- branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
- ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
- require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
+ source = ", source: \"#{d.source}\"" unless d.source.nil?
+ path = ", path: \"#{d.path}\"" unless d.path.nil?
+ git = ", git: \"#{d.git}\"" unless d.git.nil?
+ github = ", github: \"#{d.github}\"" unless d.github.nil?
+ branch = ", branch: \"#{d.branch}\"" unless d.branch.nil?
+ ref = ", ref: \"#{d.ref}\"" unless d.ref.nil?
+ glob = ", glob: \"#{d.glob}\"" unless d.glob.nil?
+ require_path = ", require: #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
- %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{require_path})
+ %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{glob}#{require_path})
end.join("\n")
end
@@ -186,7 +183,7 @@ module Bundler
# @param [Array] gems Array of names of gems to be removed.
# @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
def remove_gems_from_gemfile(gems, gemfile_path)
- patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
+ patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2.*\)/
new_gemfile = []
multiline_removal = false
File.readlines(gemfile_path).each do |line|
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 5c184f67a1..a1b8e0475e 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -1,16 +1,20 @@
# frozen_string_literal: true
-# Allows for declaring a Gemfile inline in a ruby script, optionally installing
-# any gems that aren't already installed on the user's system.
+# Allows for declaring a Gemfile inline in a ruby script, installing any gems
+# that aren't already installed on the user's system.
#
# @note Every gem that is specified in this 'Gemfile' will be `require`d, as if
# the user had manually called `Bundler.require`. To avoid a requested gem
# being automatically required, add the `:require => false` option to the
# `gem` dependency declaration.
#
-# @param install [Boolean] whether gems that aren't already installed on the
-# user's system should be installed.
-# Defaults to `false`.
+# @param force_latest_compatible [Boolean] Force installing the *latest*
+# compatible versions of the gems,
+# even if compatible versions are
+# already installed locally.
+# This also logs output if the
+# `:quiet` option is not set.
+# Defaults to `false`.
#
# @param gemfile [Proc] a block that is evaluated as a `Gemfile`.
#
@@ -29,45 +33,114 @@
#
# puts Pod::VERSION # => "0.34.4"
#
-def gemfile(install = false, options = {}, &gemfile)
+def gemfile(force_latest_compatible = false, options = {}, &gemfile)
require_relative "../bundler"
Bundler.reset!
opts = options.dup
ui = opts.delete(:ui) { Bundler::UI::Shell.new }
- ui.level = "silent" if opts.delete(:quiet) || !install
+ ui.level = "silent" if opts.delete(:quiet) || !force_latest_compatible
Bundler.ui = ui
raise ArgumentError, "Unknown options: #{opts.keys.join(", ")}" unless opts.empty?
- Bundler.with_unbundled_env do
+ old_gemfile = ENV["BUNDLE_GEMFILE"]
+ old_lockfile = ENV["BUNDLE_LOCKFILE"]
+
+ Bundler.unbundle_env!
+
+ begin
Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
+ Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", "Gemfile.lock"
- Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
+ Bundler::Plugin.gemfile_install(&gemfile) if Bundler.settings[:plugins]
builder = Bundler::Dsl.new
builder.instance_eval(&gemfile)
- builder.check_primary_source_safety
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
+ Bundler.settings.temporary(deployment: false, frozen: false) do
definition = builder.to_definition(nil, true)
- def definition.lock(*); end
definition.validate_runtime!
- if install || definition.missing_specs?
- Bundler.settings.temporary(:inline => true, :no_install => false) do
- installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
- installer.post_install_messages.each do |name, message|
- Bundler.ui.info "Post-install message from #{name}:\n#{message}"
+ if force_latest_compatible || definition.missing_specs?
+ do_install = -> do
+ Bundler.settings.temporary(inline: true, no_install: false) do
+ installer = Bundler::Installer.install(Bundler.root, definition, system: true)
+ installer.post_install_messages.each do |name, message|
+ Bundler.ui.info "Post-install message from #{name}:\n#{message}"
+ end
end
end
+
+ # When possible we do the install in a subprocess because to install
+ # gems we need to require some default gems like `securerandom` etc
+ # which may later conflict with the Gemfile requirements.
+ installed_in_fork = false
+ if Process.respond_to?(:fork)
+ Gem.load_yaml # Avoid NameError on Ruby 3.2's safe_yaml.rb after Gem::Specification.reset
+ _, status = Process.waitpid2(Process.fork do
+ $VERBOSE = nil
+ do_install.call end)
+ exit(status.exitstatus || status.to_i) unless status.success?
+
+ installed_in_fork = true
+
+ Bundler.reset!
+ Gem::Specification.reset
+ Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
+
+ builder = Bundler::Dsl.new
+ builder.instance_eval(&gemfile)
+ builder.check_primary_source_safety
+
+ definition = builder.to_definition(nil, true)
+ definition.validate_runtime!
+ else
+ do_install.call
+ end
end
- runtime = Bundler::Runtime.new(nil, definition)
- runtime.setup.require
+ configure_forked_definition = ->(d) do
+ d.sources.rubygems_sources.each(&:remote!)
+ d.sources.git_sources.each do |source|
+ source.cached!
+ source.instance_variable_set(:@copied, true)
+ end
+ def d.lock(*); end
+ end
+ configure_forked_definition.call(definition) if installed_in_fork
+
+ begin
+ runtime = Bundler::Runtime.new(nil, definition).setup
+ rescue Gem::LoadError => e
+ name = e.name
+ version = e.requirement.requirements.first[1]
+ activated_version = Gem.loaded_specs[name].version
+
+ Bundler.ui.info \
+ "The #{name} gem was resolved to #{version}, but #{activated_version} was activated by Bundler while installing it, causing a conflict. " \
+ "Bundler will now retry resolving with #{activated_version} instead."
+
+ builder.dependencies.delete_if {|d| d.name == name }
+ builder.instance_eval { gem name, activated_version }
+ definition = builder.to_definition(nil, true)
+ configure_forked_definition.call(definition) if installed_in_fork
+
+ retry
+ end
+
+ runtime.require
+ end
+ ensure
+ if old_gemfile
+ ENV["BUNDLE_GEMFILE"] = old_gemfile
+ else
+ ENV["BUNDLE_GEMFILE"] = ""
end
- end
- if ENV["BUNDLE_GEMFILE"].nil?
- ENV["BUNDLE_GEMFILE"] = ""
+ if old_lockfile
+ ENV["BUNDLE_LOCKFILE"] = old_lockfile
+ else
+ ENV["BUNDLE_LOCKFILE"] = ""
+ end
end
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 680e812ac8..87d9a75627 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -7,12 +7,6 @@ require_relative "installer/gem_installer"
module Bundler
class Installer
- class << self
- attr_accessor :ambiguous_gems
-
- Installer.ambiguous_gems = []
- end
-
attr_reader :post_install_messages, :definition
# Begins the installation process for Bundler.
@@ -69,9 +63,12 @@ module Bundler
Bundler.create_bundle_path
ProcessLock.lock do
- if Bundler.frozen_bundle?
- @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
- end
+ # Invalidate any stale gem specification cache from before we acquired the lock.
+ # Another process may have installed gems while we were waiting.
+ Gem::Specification.reset
+ @definition.sources.clear_cache
+
+ @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
if @definition.dependencies.empty?
Bundler.ui.warn "The Gemfile specifies no dependencies"
@@ -79,23 +76,25 @@ module Bundler
return
end
- if resolve_if_needed(options)
+ if @definition.setup_domain!(options)
ensure_specs_are_compatible!
load_plugins
- options.delete(:jobs)
- else
- options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
end
install(options)
Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
- lock unless Bundler.frozen_bundle?
+ lock
Standalone.new(options[:standalone], @definition).generate if options[:standalone]
end
end
def generate_bundler_executable_stubs(spec, options = {})
+ if spec.name == "bundler"
+ Bundler.ui.warn "Bundler itself does not use binstubs because its version is selected by RubyGems"
+ return
+ end
+
if options[:binstubs_cmd] && spec.executables.empty?
options = {}
spec.runtime_dependencies.each do |dep|
@@ -120,10 +119,6 @@ module Bundler
ruby_command = Thor::Util.ruby_command
ruby_command = ruby_command
template_path = File.expand_path("templates/Executable", __dir__)
- if spec.name == "bundler"
- template_path += ".bundler"
- spec.executables = %(bundle)
- end
template = File.read(template_path)
exists = []
@@ -136,12 +131,12 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
- content = ERB.new(template, :trim_mode => "-").result(binding)
+ content = ERB.new(template, trim_mode: "-").result(binding)
- File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
+ File.write(binstub_path, content, mode: mode, perm: 0o777 & ~File.umask)
if Gem.win_platform? || options[:all_platforms]
prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
- File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
+ File.write("#{binstub_path}.cmd", prefix + content, mode: mode)
end
end
@@ -179,12 +174,12 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
- content = ERB.new(template, :trim_mode => "-").result(binding)
+ content = ERB.new(template, trim_mode: "-").result(binding)
- File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
+ File.write("#{bin_path}/#{executable}", content, mode: mode, perm: 0o755)
if Gem.win_platform? || options[:all_platforms]
prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
- File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
+ File.write("#{bin_path}/#{executable}.cmd", prefix + content, mode: mode)
end
end
end
@@ -196,72 +191,46 @@ module Bundler
# that said, it's a rare situation (other than rake), and parallel
# installation is SO MUCH FASTER. so we let people opt in.
def install(options)
- force = options["force"]
- jobs = installation_parallelization(options)
- install_in_parallel jobs, options[:standalone], force
- end
-
- def installation_parallelization(options)
- if jobs = options.delete(:jobs)
- return jobs
- end
-
- if jobs = Bundler.settings[:jobs]
- return jobs
+ standalone = options[:standalone]
+ force = options[:force]
+ local = options[:local] || options[:"prefer-local"]
+ jobs = Bundler.settings.installation_parallelization
+ spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
+ spec_installations.each do |installation|
+ post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
end
-
- Bundler.settings.processor_count
end
def load_plugins
- Bundler.rubygems.load_plugins
+ Gem.load_plugins
- requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
- path_plugin_files = requested_path_gems.map do |spec|
- Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
+ requested_path_gems = @definition.specs.select {|s| s.source.is_a?(Source::Path) }
+ path_plugin_files = requested_path_gems.flat_map do |spec|
+ spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
- end.flatten
- Bundler.rubygems.load_plugin_files(path_plugin_files)
- Bundler.rubygems.load_env_plugins
+ end
+ Gem.load_plugin_files(path_plugin_files)
+ Gem.load_env_plugins
end
def ensure_specs_are_compatible!
+ overrides = @definition.overrides
@definition.specs.each do |spec|
- unless spec.matches_current_ruby?
+ unless spec.matches_current_ruby_with_overrides?(overrides)
raise InstallError, "#{spec.full_name} requires ruby version #{spec.required_ruby_version}, " \
"which is incompatible with the current version, #{Gem.ruby_version}"
end
- unless spec.matches_current_rubygems?
+ unless spec.matches_current_rubygems_with_overrides?(overrides)
raise InstallError, "#{spec.full_name} requires rubygems version #{spec.required_rubygems_version}, " \
"which is incompatible with the current version, #{Gem.rubygems_version}"
end
end
end
- def install_in_parallel(size, standalone, force = false)
- spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
- spec_installations.each do |installation|
- post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
- end
- end
-
- # returns whether or not a re-resolve was needed
- def resolve_if_needed(options)
- @definition.resolution_mode = options
-
- if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
- return false if @definition.nothing_changed? && !@definition.missing_specs?
- end
-
- @definition.setup_sources_for_resolve
-
- true
- end
-
- def lock(opts = {})
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ def lock
+ @definition.lock
end
end
end
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb
index 9a013eea4d..f3b43c31ee 100644
--- a/lib/bundler/installer/gem_installer.rb
+++ b/lib/bundler/installer/gem_installer.rb
@@ -2,27 +2,41 @@
module Bundler
class GemInstaller
- attr_reader :spec, :standalone, :worker, :force, :installer
+ attr_reader :spec, :standalone, :worker, :force, :local, :installer
- def initialize(spec, installer, standalone = false, worker = 0, force = false)
+ def initialize(spec, installer, standalone = false, worker = 0, force = false, local = false)
@spec = spec
@installer = installer
@standalone = standalone
@worker = worker
@force = force
+ @local = local
end
def install_from_spec
post_install_message = install
Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
- generate_executable_stubs
- return true, post_install_message
- rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError
+ [true, post_install_message]
+ rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError, Bundler::InsecureInstallPathError
raise
rescue Errno::ENOSPC
- return false, out_of_space_message
- rescue Bundler::BundlerError, Gem::InstallError, Bundler::APIResponseInvalidDependenciesError => e
- return false, specific_failure_message(e)
+ [false, out_of_space_message]
+ rescue Bundler::BundlerError, Gem::InstallError => e
+ [false, specific_failure_message(e)]
+ end
+
+ def download
+ spec.source.download(
+ spec,
+ force: force,
+ local: local,
+ build_args: Array(spec_settings),
+ previous_spec: previous_spec,
+ )
+
+ [true, nil]
+ rescue Bundler::BundlerError => e
+ [false, specific_failure_message(e)]
end
private
@@ -53,10 +67,10 @@ module Bundler
def install
spec.source.install(
spec,
- :force => force,
- :ensure_builtin_gems_cached => standalone,
- :build_args => Array(spec_settings),
- :previous_spec => previous_spec,
+ force: force,
+ local: local,
+ build_args: Array(spec_settings),
+ previous_spec: previous_spec,
)
end
@@ -70,15 +84,5 @@ module Bundler
def out_of_space_message
"#{install_error_message}\nYour disk is out of space. Free some space to be able to install your bundle."
end
-
- def generate_executable_stubs
- return if Bundler.feature_flag.forget_cli_options?
- return if Bundler.settings[:inline]
- if Bundler.settings[:bin] && standalone
- installer.generate_standalone_bundler_executable_stubs(spec)
- elsif Bundler.settings[:bin]
- installer.generate_bundler_executable_stubs(spec, :force => true)
- end
- end
end
end
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 83a381f592..fef326ed0a 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -6,7 +6,7 @@ require_relative "gem_installer"
module Bundler
class ParallelInstaller
class SpecInstallation
- attr_accessor :spec, :name, :full_name, :post_install_message, :state, :error
+ attr_accessor :spec, :name, :full_name, :post_install_message, :state, :error, :dependencies
def initialize(spec)
@spec = spec
@name = spec.name
@@ -24,6 +24,10 @@ module Bundler
state == :enqueued
end
+ def enqueue_with_priority?
+ state == :installable && spec.extensions.any?
+ end
+
def failed?
state == :failed
end
@@ -32,30 +36,21 @@ module Bundler
state == :none
end
- def has_post_install_message?
- !post_install_message.empty?
- end
-
- def ignorable_dependency?(dep)
- dep.type == :development || dep.name == @name
- end
+ def ready_to_install?(installed_specs)
+ return false unless state == :downloaded
- # Checks installed dependencies against spec's dependencies to make
- # sure needed dependencies have been installed.
- def dependencies_installed?(all_specs)
- installed_specs = all_specs.select(&:installed?).map(&:name)
- dependencies.all? {|d| installed_specs.include? d.name }
+ spec.extensions.none? || dependencies_installed?(installed_specs)
end
- # Represents only the non-development dependencies, the ones that are
- # itself and are in the total list.
- def dependencies
- @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }
+ def has_post_install_message?
+ !post_install_message.empty?
end
- # Represents all dependencies
- def all_dependencies
- @spec.dependencies
+ # Recursively checks that all dependencies (direct and transitive) have been installed.
+ def dependencies_installed?(installed_specs)
+ dependencies.all? do |dep|
+ installed_specs.include?(dep.name) && dep.dependencies_installed?(installed_specs)
+ end
end
def to_s
@@ -63,24 +58,35 @@ module Bundler
end
end
- def self.call(*args)
- new(*args).call
+ def self.call(*args, **kwargs)
+ new(*args, **kwargs).call
end
attr_reader :size
- def initialize(installer, all_specs, size, standalone, force)
+ def initialize(installer, all_specs, size, standalone, force, local: false, skip: nil)
@installer = installer
@size = size
@standalone = standalone
@force = force
+ @local = local
@specs = all_specs.map {|s| SpecInstallation.new(s) }
+ specs_by_name = @specs.to_h {|s| [s.name, s] }
+ @specs.each do |spec_install|
+ spec_install.dependencies = spec_install.spec.dependencies.filter_map do |dep|
+ specs_by_name[dep.name] unless dep.type == :development || dep.name == spec_install.name
+ end
+ end
+ @specs.each do |spec_install|
+ spec_install.state = :installed if skip.include?(spec_install.name)
+ end if skip
@spec_set = all_specs
- @rake = @specs.find {|s| s.name == "rake" }
+ @rake = @specs.find {|s| s.name == "rake" unless s.installed? }
end
def call
if @rake
+ do_download(@rake, 0)
do_install(@rake, 0)
Gem::Specification.reset
end
@@ -91,38 +97,12 @@ module Bundler
install_serially
end
- check_for_unmet_dependencies
-
handle_error if failed_specs.any?
@specs
ensure
worker_pool&.stop
end
- def check_for_unmet_dependencies
- unmet_dependencies = @specs.map do |s|
- [
- s,
- s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
- ]
- end.reject {|a| a.last.empty? }
- return if unmet_dependencies.empty?
-
- warning = []
- warning << "Your lockfile doesn't include a valid resolution."
- warning << "You can fix this by regenerating your lockfile or manually editing the bad locked gems to a version that satisfies all dependencies."
- warning << "The unmet dependencies are:"
-
- unmet_dependencies.each do |spec, unmet_spec_dependencies|
- unmet_spec_dependencies.each do |unmet_spec_dependency|
- found = @specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }
- warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}"
- end
- end
-
- Bundler.ui.warn(warning.join("\n"))
- end
-
private
def failed_specs
@@ -130,28 +110,56 @@ module Bundler
end
def install_with_worker
- enqueue_specs
- process_specs until finished_installing?
+ installed_specs = {}
+ enqueue_specs(installed_specs)
+
+ process_specs(installed_specs) until finished_installing?
end
def install_serially
until finished_installing?
raise "failed to find a spec to enqueue while installing serially" unless spec_install = @specs.find(&:ready_to_enqueue?)
spec_install.state = :enqueued
+ do_download(spec_install, 0)
do_install(spec_install, 0)
end
end
def worker_pool
@worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda {|spec_install, worker_num|
- do_install(spec_install, worker_num)
+ case spec_install.state
+ when :enqueued
+ do_download(spec_install, worker_num)
+ when :installable
+ do_install(spec_install, worker_num)
+ else
+ spec_install
+ end
}
end
- def do_install(spec_install, worker_num)
+ def do_download(spec_install, worker_num)
Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
+
+ gem_installer = Bundler::GemInstaller.new(
+ spec_install.spec, @installer, @standalone, worker_num, @force, @local
+ )
+
+ success, message = gem_installer.download
+
+ if success
+ spec_install.state = :downloaded
+ else
+ spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
+ spec_install.state = :failed
+ end
+
+ spec_install
+ end
+
+ def do_install(spec_install, worker_num)
gem_installer = Bundler::GemInstaller.new(
- spec_install.spec, @installer, @standalone, worker_num, @force
+ spec_install.spec, @installer, @standalone, worker_num, @force, @local
)
success, message = gem_installer.install_from_spec
if success
@@ -170,9 +178,19 @@ module Bundler
# Some specs might've had to wait til this spec was installed to be
# processed so the call to `enqueue_specs` is important after every
# dequeue.
- def process_specs
- worker_pool.deq
- enqueue_specs
+ def process_specs(installed_specs)
+ spec = worker_pool.deq
+
+ if spec.installed?
+ installed_specs[spec.name] = true
+ return
+ elsif spec.failed?
+ return
+ elsif spec.ready_to_install?(installed_specs)
+ spec.state = :installable
+ end
+
+ worker_pool.enq(spec, priority: spec.enqueue_with_priority?)
end
def finished_installing?
@@ -208,12 +226,15 @@ module Bundler
# Later we call this lambda again to install specs that depended on
# previously installed specifications. We continue until all specs
# are installed.
- def enqueue_specs
- @specs.select(&:ready_to_enqueue?).each do |spec|
- if spec.dependencies_installed? @specs
- spec.state = :enqueued
- worker_pool.enq spec
+ def enqueue_specs(installed_specs)
+ @specs.each do |spec|
+ if spec.installed?
+ installed_specs[spec.name] = true
+ next
end
+
+ spec.state = :enqueued
+ worker_pool.enq spec
end
end
end
diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
index 2a8c9a432d..8b4de64df5 100644
--- a/lib/bundler/installer/standalone.rb
+++ b/lib/bundler/installer/standalone.rb
@@ -12,6 +12,7 @@ module Bundler
end
File.open File.join(bundler_path, "setup.rb"), "w" do |file|
file.puts "require 'rbconfig'"
+ file.puts prevent_gem_activation
file.puts define_path_helpers
file.puts reverse_rubygems_kernel_mixin
paths.each do |path|
@@ -27,7 +28,7 @@ module Bundler
private
def paths
- @specs.map do |spec|
+ @specs.flat_map do |spec|
next if spec.name == "bundler"
Array(spec.require_paths).map do |path|
gem_path(path, spec).
@@ -35,7 +36,7 @@ module Bundler
sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
# This is a static string intentionally. It's interpolated at a later time.
end
- end.flatten.compact
+ end.compact
end
def version_dir
@@ -55,11 +56,21 @@ module Bundler
if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
full_path
else
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
+ SharedHelpers.relative_path_to(full_path, from: Bundler.root.join(bundler_path))
end
- rescue TypeError
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
- raise Gem::InvalidSpecificationException.new(error_message)
+ end
+
+ def prevent_gem_activation
+ <<~'END'
+ module Kernel
+ remove_method(:gem) if private_method_defined?(:gem)
+
+ def gem(*)
+ end
+
+ private :gem
+ end
+ END
end
def define_path_helpers
@@ -87,8 +98,7 @@ module Bundler
if Gem.respond_to?(:discover_gems_on_require=)
Gem.discover_gems_on_require = false
else
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |k|
+ [::Kernel.singleton_class, ::Kernel].each do |k|
if k.private_method_defined?(:gem_original_require)
private_require = k.private_method_defined?(:require)
k.send(:remove_method, :require)
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 6749892930..0da621d21f 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -4,39 +4,91 @@ require_relative "force_platform"
module Bundler
class LazySpecification
+ include MatchMetadata
include MatchPlatform
include ForcePlatform
- attr_reader :name, :version, :dependencies, :platform
- attr_accessor :source, :remote, :force_ruby_platform
+ attr_reader :name, :version, :platform, :materialization
+ attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version, :overrides
- def initialize(name, version, platform, source = nil)
+ #
+ # For backwards compatibility with existing lockfiles, if the most specific
+ # locked platform is not a specific platform like x86_64-linux or
+ # universal-java-11, then we keep the previous behaviour of resolving the
+ # best platform variant at materiliazation time. For previous bundler
+ # versions (before 2.2.0) this was always the case (except when the lockfile
+ # only included non-ruby platforms), but we're also keeping this behaviour
+ # on newer bundlers unless users generate the lockfile from scratch or
+ # explicitly add a more specific platform.
+ #
+ attr_accessor :most_specific_locked_platform
+
+ alias_method :runtime_dependencies, :dependencies
+
+ def self.from_spec(s)
+ lazy_spec = new(s.name, s.version, s.platform, s.source)
+ lazy_spec.dependencies = s.runtime_dependencies
+ lazy_spec.required_ruby_version = s.required_ruby_version
+ lazy_spec.required_rubygems_version = s.required_rubygems_version
+ lazy_spec.overrides = s.overrides if s.is_a?(LazySpecification)
+ lazy_spec
+ end
+
+ def initialize(name, version, platform, source = nil, **materialization_options)
@name = name
@version = version
@dependencies = []
- @platform = platform || Gem::Platform::RUBY
- @source = source
+ @required_ruby_version = Gem::Requirement.default
+ @required_rubygems_version = Gem::Requirement.default
+ @platform = platform || Gem::Platform::RUBY
+
+ @original_source = source
+ @source = source
+ @materialization_options = materialization_options
+
@force_ruby_platform = default_force_ruby_platform
+ @most_specific_locked_platform = nil
+ @materialization = nil
+ end
+
+ def missing?
+ @materialization == self
+ end
+
+ def incomplete?
+ @materialization.nil?
+ end
+
+ def source_changed?
+ @original_source != source
end
def full_name
- if platform == Gem::Platform::RUBY
+ @full_name ||= if platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
end
end
+ def lock_name
+ @lock_name ||= name_tuple.lock_name
+ end
+
+ def name_tuple
+ Gem::NameTuple.new(@name, @version, @platform)
+ end
+
def ==(other)
- identifier == other.identifier
+ full_name == other.full_name
end
def eql?(other)
- identifier.eql?(other.identifier)
+ full_name.eql?(other.full_name)
end
def hash
- identifier.hash
+ full_name.hash
end
##
@@ -61,12 +113,7 @@ module Bundler
def to_lock
out = String.new
-
- if platform == Gem::Platform::RUBY
- out << " #{name} (#{version})\n"
- else
- out << " #{name} (#{version}-#{platform})\n"
- end
+ out << " #{lock_name}\n"
dependencies.sort_by(&:to_s).uniq.each do |dep|
next if dep.type == :development
@@ -76,88 +123,150 @@ module Bundler
out
end
+ def materialize_for_cache
+ source.remote!
+
+ materialize(self, &:first)
+ end
+
+ def materialized_for_installation
+ @materialization = materialize_for_installation
+
+ self unless incomplete?
+ end
+
def materialize_for_installation
source.local!
- matching_specs = source.specs.search(use_exact_resolved_specifications? ? self : [name, version])
- return self if matching_specs.empty?
+ if use_exact_resolved_specifications?
+ spec = materialize(self) {|specs| choose_compatible(specs, fallback_to_non_installable: false) }
+ return spec if spec
- candidates = if use_exact_resolved_specifications?
- matching_specs
+ # Exact spec is incompatible; in frozen mode, try to find a compatible platform variant
+ # In non-frozen mode, return nil to trigger re-resolution and lockfile update
+ if Bundler.frozen_bundle?
+ materialize([name, version]) {|specs| resolve_best_platform(specs) }
+ end
else
- target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
+ materialize([name, version]) {|specs| resolve_best_platform(specs) }
+ end
+ end
- installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
+ def inspect
+ "#<#{self.class} @name=\"#{name}\" (#{full_name.delete_prefix("#{name}-")})>"
+ end
- specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
- return specification unless specification.nil?
+ def to_s
+ lock_name
+ end
- if target_platform != platform
- installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
- end
+ def git_version
+ return unless source.is_a?(Bundler::Source::Git)
+ " #{source.revision[0..6]}"
+ end
+
+ def force_ruby_platform!
+ @force_ruby_platform = true
+ end
+
+ def replace_source_with!(gemfile_source)
+ return unless gemfile_source.can_lock?(self)
+
+ @source = gemfile_source
+
+ true
+ end
+
+ private
- installable_candidates
+ def use_exact_resolved_specifications?
+ !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
+ end
+
+ # Try platforms in order of preference until finding a compatible spec.
+ # Used for legacy lockfiles and as a fallback when the exact locked spec
+ # is incompatible. Falls back to frozen bundle behavior if none match.
+ def resolve_best_platform(specs)
+ find_compatible_platform_spec(specs) || frozen_bundle_fallback(specs)
+ end
+
+ def find_compatible_platform_spec(specs)
+ candidate_platforms.each do |plat|
+ candidates = MatchPlatform.select_best_platform_match(specs, plat)
+ spec = choose_compatible(candidates, fallback_to_non_installable: false)
+ return spec if spec
end
+ nil
+ end
+
+ # Platforms to try in order of preference. Ruby platform is last since it
+ # requires compilation, but works when precompiled gems are incompatible.
+ def candidate_platforms
+ target = source.is_a?(Source::Path) ? platform : Bundler.local_platform
+ [target, platform, Gem::Platform::RUBY].uniq
+ end
+
+ # In frozen mode, accept any candidate. Will error at install time.
+ # When target differs from locked platform, prefer locked platform's candidates
+ # to preserve lockfile integrity.
+ def frozen_bundle_fallback(specs)
+ target = source.is_a?(Source::Path) ? platform : Bundler.local_platform
+ fallback_platform = target == platform ? target : platform
+ candidates = MatchPlatform.select_best_platform_match(specs, fallback_platform)
+ choose_compatible(candidates)
+ end
- __materialize__(candidates)
+ def ruby_platform_materializes_to_ruby_platform?
+ generic_platform = Bundler.generic_local_platform == Gem::Platform::JAVA ? Gem::Platform::JAVA : Gem::Platform::RUBY
+
+ (most_specific_locked_platform != generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
+ end
+
+ def materialize(query)
+ matching_specs = source.specs.search(query)
+ return self if matching_specs.empty?
+
+ yield matching_specs
end
# If in frozen mode, we fallback to a non-installable candidate because by
# doing this we avoid re-resolving and potentially end up changing the
- # lock file, which is not allowed. In that case, we will give a proper error
+ # lockfile, which is not allowed. In that case, we will give a proper error
# about the mismatch higher up the stack, right before trying to install the
# bad gem.
- def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
+ def choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
+ override_list = overrides || []
search = candidates.reverse.find do |spec|
- spec.is_a?(StubSpecification) ||
- (spec.matches_current_ruby? &&
- spec.matches_current_rubygems?)
+ spec.is_a?(StubSpecification) || spec.matches_current_metadata_with_overrides?(override_list)
end
if search.nil? && fallback_to_non_installable
search = candidates.last
- else
- search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
- end
- search
- end
-
- def to_s
- @__to_s ||= if platform == Gem::Platform::RUBY
- "#{name} (#{version})"
- else
- "#{name} (#{version}-#{platform})"
end
- end
-
- def identifier
- @__identifier ||= [name, version, platform.to_s]
- end
- def git_version
- return unless source.is_a?(Bundler::Source::Git)
- " #{source.revision[0..6]}"
- end
+ if search
+ validate_dependencies(search) if search.platform == platform
- private
-
- def use_exact_resolved_specifications?
- @use_exact_resolved_specifications ||= !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
+ search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
+ end
+ search
end
+ # Validate dependencies of this locked spec are consistent with dependencies
+ # of the actual spec that was materialized.
#
- # For backwards compatibility with existing lockfiles, if the most specific
- # locked platform is not a specific platform like x86_64-linux or
- # universal-java-11, then we keep the previous behaviour of resolving the
- # best platform variant at materiliazation time. For previous bundler
- # versions (before 2.2.0) this was always the case (except when the lockfile
- # only included non-ruby platforms), but we're also keeping this behaviour
- # on newer bundlers unless users generate the lockfile from scratch or
- # explicitly add a more specific platform.
- #
- def ruby_platform_materializes_to_ruby_platform?
- generic_platform = generic_local_platform == Gem::Platform::JAVA ? Gem::Platform::JAVA : Gem::Platform::RUBY
-
- !Bundler.most_specific_locked_platform?(generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
+ # Note that unless we are in strict mode (which we set during installation)
+ # we don't validate dependencies of locally installed gems but
+ # accept what's in the lockfile instead for performance, since loading
+ # dependencies of locally installed gems would mean evaluating all gemspecs,
+ # which would affect `bundler/setup` performance.
+ def validate_dependencies(spec)
+ if !@materialization_options[:strict] && spec.is_a?(StubSpecification)
+ spec.dependencies = dependencies
+ else
+ if !source.is_a?(Source::Path) && spec.runtime_dependencies.sort != dependencies.sort
+ raise IncorrectLockfileDependencies.new(self, spec.runtime_dependencies, dependencies)
+ end
+ end
end
end
end
diff --git a/lib/bundler/lockfile_generator.rb b/lib/bundler/lockfile_generator.rb
index a7ee026f67..2a3ad22480 100644
--- a/lib/bundler/lockfile_generator.rb
+++ b/lib/bundler/lockfile_generator.rb
@@ -19,6 +19,7 @@ module Bundler
add_sources
add_platforms
add_dependencies
+ add_checksums
add_locked_ruby_version
add_bundled_with
@@ -28,7 +29,7 @@ module Bundler
private
def add_sources
- definition.send(:sources).lock_sources.each_with_index do |source, idx|
+ definition.sources.lock_sources.each_with_index do |source, idx|
out << "\n" unless idx.zero?
# Add the source header
@@ -65,13 +66,22 @@ module Bundler
end
end
+ def add_checksums
+ return unless definition.locked_checksums
+ checksums = definition.resolve.map do |spec|
+ spec.source.checksum_store.to_lock(spec)
+ end
+
+ add_section("CHECKSUMS", checksums + bundler_checksum)
+ end
+
def add_locked_ruby_version
return unless locked_ruby_version = definition.locked_ruby_version
add_section("RUBY VERSION", locked_ruby_version.to_s)
end
def add_bundled_with
- add_section("BUNDLED WITH", Bundler::VERSION)
+ add_section("BUNDLED WITH", definition.bundler_version_to_lock.to_s)
end
def add_section(name, value)
@@ -86,10 +96,24 @@ module Bundler
out << " #{key}: #{val}\n"
end
when String
- out << " #{value}\n"
+ out << " #{value}\n"
else
raise ArgumentError, "#{value.inspect} can't be serialized in a lockfile"
end
end
+
+ def bundler_checksum
+ return [] if Bundler.gem_version.to_s.end_with?(".dev") || ENV["SKIP_BUNDLER_CHECKSUM"]
+
+ bundler_spec = definition.sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
+ return [] unless File.exist?(bundler_spec.cache_file)
+
+ require "rubygems/package"
+
+ package = Gem::Package.new(bundler_spec.cache_file)
+ definition.sources.metadata_source.checksum_store.register(bundler_spec, Checksum.from_gem_package(package))
+
+ [definition.sources.metadata_source.checksum_store.to_lock(bundler_spec)]
+ end
end
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 237749c525..852fc631f3 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -1,11 +1,46 @@
# frozen_string_literal: true
+require_relative "shared_helpers"
+
module Bundler
class LockfileParser
- attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
+ class Position
+ attr_reader :line, :column
+ def initialize(line, column)
+ @line = line
+ @column = column
+ end
+
+ def advance!(string)
+ lines = string.count("\n")
+ if lines > 0
+ @line += lines
+ @column = string.length - string.rindex("\n")
+ else
+ @column += string.length
+ end
+ end
+
+ def to_s
+ "#{line}:#{column}"
+ end
+ end
+
+ attr_reader(
+ :sources,
+ :metadata_source,
+ :dependencies,
+ :specs,
+ :platforms,
+ :most_specific_locked_platform,
+ :bundler_version,
+ :ruby_version,
+ :checksums,
+ )
BUNDLED = "BUNDLED WITH"
DEPENDENCIES = "DEPENDENCIES"
+ CHECKSUMS = "CHECKSUMS"
PLATFORMS = "PLATFORMS"
RUBY = "RUBY VERSION"
GIT = "GIT"
@@ -13,7 +48,7 @@ module Bundler
PATH = "PATH"
PLUGIN = "PLUGIN SOURCE"
SPECS = " specs:"
- OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
+ OPTIONS = /^ ([a-z]+): (.*)$/i
SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
SECTIONS_BY_VERSION_INTRODUCED = {
@@ -21,14 +56,18 @@ module Bundler
Gem::Version.create("1.10") => [BUNDLED].freeze,
Gem::Version.create("1.12") => [RUBY].freeze,
Gem::Version.create("1.13") => [PLUGIN].freeze,
+ Gem::Version.create("2.5.0") => [CHECKSUMS].freeze,
}.freeze
- KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
+ KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten!.freeze
ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
def self.sections_in_lockfile(lockfile_contents)
- lockfile_contents.scan(/^\w[\w ]*$/).uniq
+ sections = lockfile_contents.scan(/^\w[\w ]*$/)
+ sections.uniq!
+ sections
end
def self.unknown_sections_in_lockfile(lockfile_contents)
@@ -37,7 +76,7 @@ module Bundler
def self.sections_to_ignore(base_version = nil)
base_version &&= base_version.release
- base_version ||= Gem::Version.create("1.0".dup)
+ base_version ||= Gem::Version.create("1.0")
attributes = []
SECTIONS_BY_VERSION_INTRODUCED.each do |version, introduced|
next if version <= base_version
@@ -56,47 +95,90 @@ module Bundler
lockfile_contents.split(BUNDLED).last.strip
end
- def initialize(lockfile)
+ def initialize(lockfile, strict: false, lockfile_path: nil)
@platforms = []
@sources = []
+ @metadata_source = Source::Metadata.new
@dependencies = {}
- @state = nil
+ @parse_method = nil
@specs = {}
+ @lockfile_path = lockfile_path || begin
+ SharedHelpers.relative_lockfile_path
+ rescue GemfileNotFound
+ "Gemfile.lock"
+ end
+ @pos = Position.new(1, 1)
+ @strict = strict
if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
- raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
- "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
+ raise LockfileError, "Your #{@lockfile_path} contains merge conflicts.\n" \
+ "Run `git checkout HEAD -- #{@lockfile_path}` first to get a clean lock."
end
- lockfile.split(/(?:\r?\n)+/).each do |line|
+ @valid = lockfile.strip.empty? ||
+ lockfile.split(/(?:\r?\n)+/).any? {|l| KNOWN_SECTIONS.include?(l) }
+
+ unless @valid
+ SharedHelpers.feature_deprecated!(
+ "Your #{@lockfile_path} does not appear to be a valid lockfile. " \
+ "Run `rm #{@lockfile_path}` and then `bundle install` to generate a new lockfile. " \
+ "This will raise a LockfileError in a future version of Bundler."
+ )
+ end
+
+ lockfile.split(/((?:\r?\n)+)/) do |line|
+ # split alternates between the line and the following whitespace
+ next @pos.advance!(line) if line.match?(/^\s*$/)
+
if SOURCE.include?(line)
- @state = :source
+ @parse_method = :parse_source
parse_source(line)
elsif line == DEPENDENCIES
- @state = :dependency
+ @parse_method = :parse_dependency
+ elsif line == CHECKSUMS
+ # This is a temporary solution to make this feature disabled by default
+ # for all gemfiles that don't already explicitly include the feature.
+ @checksums = true
+ @parse_method = :parse_checksum
elsif line == PLATFORMS
- @state = :platform
+ @parse_method = :parse_platform
elsif line == RUBY
- @state = :ruby
+ @parse_method = :parse_ruby
elsif line == BUNDLED
- @state = :bundled_with
+ @parse_method = :parse_bundled_with
elsif /^[^\s]/.match?(line)
- @state = nil
- elsif @state
- send("parse_#{@state}", line)
+ @parse_method = nil
+ elsif @parse_method
+ send(@parse_method, line)
end
+ @pos.advance!(line)
+ end
+
+ if @platforms.include?(Gem::Platform::X64_MINGW_LEGACY)
+ SharedHelpers.feature_deprecated!("Found x64-mingw32 in lockfile, which is deprecated and will be removed in the future.")
+ end
+
+ @most_specific_locked_platform = @platforms.min_by do |bundle_platform|
+ Gem::Platform.platform_specificity_match(bundle_platform, Bundler.local_platform)
+ end
+ @specs = @specs.values.sort_by!(&:full_name).each do |spec|
+ spec.most_specific_locked_platform = @most_specific_locked_platform
end
- @specs = @specs.values.sort_by(&:identifier)
rescue ArgumentError => e
Bundler.ui.debug(e)
- raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
- "and then `bundle install` to generate a new lockfile."
+ raise LockfileError, "Your lockfile is unreadable. Run `rm #{@lockfile_path}` " \
+ "and then `bundle install` to generate a new lockfile. The error occurred while " \
+ "evaluating #{@lockfile_path}:#{@pos}"
end
def may_include_redundant_platform_specific_gems?
bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
end
+ def valid?
+ @valid
+ end
+
private
TYPES = {
@@ -109,21 +191,9 @@ module Bundler
def parse_source(line)
case line
when SPECS
- case @type
- when PATH
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when GIT
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when GEM
- @opts["remotes"] = Array(@opts.delete("remote")).reverse
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when PLUGIN
- @current_source = Plugin.source_from_lock(@opts)
- @sources << @current_source
- end
+ return unless TYPES.key?(@type)
+ @current_source = TYPES[@type].from_lock(@opts)
+ @sources << @current_source
when OPTIONS
value = $2
value = true if value == "true"
@@ -153,18 +223,19 @@ module Bundler
(?:#{space}\(([^-]*) # Space, followed by version
(?:-(.*))?\))? # Optional platform
(!)? # Optional pinned marker
+ (?:#{space}([^ ]+))? # Optional checksum
$ # Line end
- /xo.freeze
+ /xo
def parse_dependency(line)
return unless line =~ NAME_VERSION
spaces = $1
return unless spaces.size == 2
- name = $2
+ name = -$2
version = $3
pinned = $5
- version = version.split(",").map(&:strip) if version
+ version = version.split(",").each(&:strip!) if version
dep = Bundler::Dependency.new(name, version)
@@ -185,40 +256,73 @@ module Bundler
@dependencies[dep.name] = dep
end
- def parse_spec(line)
+ def parse_checksum(line)
return unless line =~ NAME_VERSION
+
spaces = $1
+ return unless spaces.size == 2
+ checksums = $6
name = $2
version = $3
platform = $4
+ version = Gem::Version.new(version)
+ platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
+ full_name = Gem::NameTuple.new(name, version, platform).full_name
+ spec = @specs[full_name]
+
+ if name == "bundler"
+ spec ||= LazySpecification.new(name, version, platform, @metadata_source)
+ end
+ return unless spec
+
+ if checksums
+ checksums.split(",") do |lock_checksum|
+ column = line.index(lock_checksum) + 1
+ checksum = Checksum.from_lock(lock_checksum, "#{@lockfile_path}:#{@pos.line}:#{column}")
+ spec.source.checksum_store.register(spec, checksum)
+ end
+ else
+ spec.source.checksum_store.register(spec, nil)
+ end
+ end
+
+ def parse_spec(line)
+ return unless line =~ NAME_VERSION
+ spaces = $1
+ name = -$2
+ version = $3
+
if spaces.size == 4
+ # only load platform for non-dependency (spec) line
+ platform = $4
+
version = Gem::Version.new(version)
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
- @current_spec = LazySpecification.new(name, version, platform)
- @current_spec.source = @current_source
+ @current_spec = LazySpecification.new(name, version, platform, @current_source, strict: @strict)
@current_source.add_dependency_names(name)
- @specs[@current_spec.identifier] = @current_spec
+ @specs[@current_spec.full_name] = @current_spec
elsif spaces.size == 6
- version = version.split(",").map(&:strip) if version
+ version = version.split(",").each(&:strip!) if version
dep = Gem::Dependency.new(name, version)
@current_spec.dependencies << dep
end
end
def parse_platform(line)
- @platforms << Gem::Platform.new($1) if line =~ /^ (.*)$/
+ @platforms << Gem::Platform.new($1.strip) if line =~ /^ (.*)$/
end
def parse_bundled_with(line)
- line = line.strip
+ line.strip!
return unless Gem::Version.correct?(line)
@bundler_version = Gem::Version.create(line)
end
def parse_ruby(line)
- @ruby_version = line.strip
+ line.strip!
+ @ruby_version = line
end
end
end
diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1
index 0e21c75506..0956aa83f1 100644
--- a/lib/bundler/man/bundle-add.1
+++ b/lib/bundler/man/bundle-add.1
@@ -1,82 +1,82 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-ADD" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-ADD" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
-.
.SH "SYNOPSIS"
-\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
-.
+\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT|\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-cooldown=NUMBER] [\-\-quiet] [\-\-skip\-install] [\-\-strict|\-\-optimistic]
.SH "DESCRIPTION"
-Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
-.
-.P
-Example:
-.
-.P
-bundle add rails
-.
-.P
-bundle add rails \-\-version "< 3\.0, > 1\.1"
-.
-.P
-bundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"
-.
-.P
-bundle add rails \-\-skip\-install
-.
-.P
-bundle add rails \-\-group "development, test"
-.
+Adds the named gem to the [\fBGemfile(5)\fR][Gemfile(5)] and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
.SH "OPTIONS"
-.
.TP
-\fB\-\-version\fR, \fB\-v\fR
+\fB\-\-version=VERSION\fR, \fB\-v=VERSION\fR
Specify version requirements(s) for the added gem\.
-.
.TP
-\fB\-\-group\fR, \fB\-g\fR
+\fB\-\-group=GROUP\fR, \fB\-g=GROUP\fR
Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
-.
.TP
-\fB\-\-source\fR, \fB\-s\fR
+\fB\-\-source=SOURCE\fR, \fB\-s=SOURCE\fR
Specify the source for the added gem\.
-.
.TP
-\fB\-\-require\fR, \fB\-r\fR
+\fB\-\-require=REQUIRE\fR, \fB\-r=REQUIRE\fR
Adds require path to gem\. Provide false, or a path as a string\.
-.
.TP
-\fB\-\-path\fR
+\fB\-\-path=PATH\fR
Specify the file system path for the added gem\.
-.
.TP
-\fB\-\-git\fR
+\fB\-\-git=GIT\fR
Specify the git source for the added gem\.
-.
.TP
-\fB\-\-github\fR
+\fB\-\-github=GITHUB\fR
Specify the github source for the added gem\.
-.
.TP
-\fB\-\-branch\fR
+\fB\-\-branch=BRANCH\fR
Specify the git branch for the added gem\.
-.
.TP
-\fB\-\-ref\fR
+\fB\-\-ref=REF\fR
Specify the git ref for the added gem\.
-.
+.TP
+\fB\-\-glob=GLOB\fR
+Specify the location of a dependency's \.gemspec, expanded within Ruby (single quotes recommended)\.
+.TP
+\fB\-\-quiet\fR
+Do not print progress information to the standard output\.
.TP
\fB\-\-skip\-install\fR
Adds the gem to the Gemfile but does not install it\.
-.
.TP
\fB\-\-optimistic\fR
-Adds optimistic declaration of version\.
-.
+Ignored (now default behavior)
+.TP
+\fB\-\-pessimistic\fR
+Adds pessimistic declaration of version\.
.TP
\fB\-\-strict\fR
Adds strict declaration of version\.
-
+.TP
+\fB\-\-cooldown=<number>\fR
+Only consider gem versions published at least \fInumber\fR days ago when resolving\. Pass \fB0\fR to disable cooldown for this run\. See \fBcooldown\fR in bundle\-config(1) for precedence rules\.
+.SH "EXAMPLES"
+.IP "1." 4
+You can add the \fBrails\fR gem to the Gemfile without any version restriction\. The source of the gem will be the global source\.
+.IP
+\fBbundle add rails\fR
+.IP "2." 4
+You can add the \fBrails\fR gem with version greater than 1\.1 (not including 1\.1) and less than 3\.0\.
+.IP
+\fBbundle add rails \-\-version "> 1\.1, < 3\.0"\fR
+.IP "3." 4
+You can use the \fBhttps://gems\.example\.com\fR custom source and assign the gem to a group\.
+.IP
+\fBbundle add rails \-\-version ">= 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"\fR
+.IP "4." 4
+The following adds the \fBgem\fR entry to the Gemfile without installing the gem\. You can install gems later via \fBbundle install\fR\.
+.IP
+\fBbundle add rails \-\-skip\-install\fR
+.IP "5." 4
+You can assign the gem to more than one group\.
+.IP
+\fBbundle add rails \-\-group "development, test"\fR
+.IP "" 0
+.SH "SEE ALSO"
+Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR, bundle\-remove(1) \fIbundle\-remove\.1\.html\fR
diff --git a/lib/bundler/man/bundle-add.1.ronn b/lib/bundler/man/bundle-add.1.ronn
index 37c92e5fcd..8c65af0cc0 100644
--- a/lib/bundler/man/bundle-add.1.ronn
+++ b/lib/bundler/man/bundle-add.1.ronn
@@ -1,58 +1,95 @@
bundle-add(1) -- Add gem to the Gemfile and run bundle install
-================================================================
+==============================================================
## SYNOPSIS
-`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--path=PATH] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
+`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE]
+ [--path=PATH] [--git=GIT|--github=GITHUB] [--branch=BRANCH] [--ref=REF]
+ [--cooldown=NUMBER] [--quiet] [--skip-install] [--strict|--optimistic]
## DESCRIPTION
-Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
-Example:
-
-bundle add rails
-
-bundle add rails --version "< 3.0, > 1.1"
-
-bundle add rails --version "~> 5.0.0" --source "https://gems.example.com" --group "development"
-
-bundle add rails --skip-install
-
-bundle add rails --group "development, test"
+Adds the named gem to the [`Gemfile(5)`][Gemfile(5)] and run `bundle install`.
+`bundle install` can be avoided by using the flag `--skip-install`.
## OPTIONS
-* `--version`, `-v`:
+
+* `--version=VERSION`, `-v=VERSION`:
Specify version requirements(s) for the added gem.
-* `--group`, `-g`:
+* `--group=GROUP`, `-g=GROUP`:
Specify the group(s) for the added gem. Multiple groups should be separated by commas.
-* `--source`, `-s`:
+* `--source=SOURCE`, `-s=SOURCE`:
Specify the source for the added gem.
-* `--require`, `-r`:
+* `--require=REQUIRE`, `-r=REQUIRE`:
Adds require path to gem. Provide false, or a path as a string.
-* `--path`:
+* `--path=PATH`:
Specify the file system path for the added gem.
-* `--git`:
+* `--git=GIT`:
Specify the git source for the added gem.
-* `--github`:
+* `--github=GITHUB`:
Specify the github source for the added gem.
-* `--branch`:
+* `--branch=BRANCH`:
Specify the git branch for the added gem.
-* `--ref`:
+* `--ref=REF`:
Specify the git ref for the added gem.
+* `--glob=GLOB`:
+ Specify the location of a dependency's .gemspec, expanded within Ruby (single quotes recommended).
+
+* `--quiet`:
+ Do not print progress information to the standard output.
+
* `--skip-install`:
Adds the gem to the Gemfile but does not install it.
* `--optimistic`:
- Adds optimistic declaration of version.
+ Ignored (now default behavior)
+
+* `--pessimistic`:
+ Adds pessimistic declaration of version.
* `--strict`:
Adds strict declaration of version.
+
+* `--cooldown=<number>`:
+ Only consider gem versions published at least <number> days ago when
+ resolving. Pass `0` to disable cooldown for this run. See `cooldown`
+ in bundle-config(1) for precedence rules.
+
+## EXAMPLES
+
+1. You can add the `rails` gem to the Gemfile without any version restriction.
+ The source of the gem will be the global source.
+
+ `bundle add rails`
+
+2. You can add the `rails` gem with version greater than 1.1 (not including 1.1) and less than 3.0.
+
+ `bundle add rails --version "> 1.1, < 3.0"`
+
+3. You can use the `https://gems.example.com` custom source and assign the gem
+ to a group.
+
+ `bundle add rails --version ">= 5.0.0" --source "https://gems.example.com" --group "development"`
+
+4. The following adds the `gem` entry to the Gemfile without installing the
+ gem. You can install gems later via `bundle install`.
+
+ `bundle add rails --skip-install`
+
+5. You can assign the gem to more than one group.
+
+ `bundle add rails --group "development, test"`
+
+## SEE ALSO
+
+[Gemfile(5)](https://bundler.io/man/gemfile.5.html),
+[bundle-remove(1)](bundle-remove.1.html)
diff --git a/lib/bundler/man/bundle-binstubs.1 b/lib/bundler/man/bundle-binstubs.1
index 2774e9d28a..246daeae53 100644
--- a/lib/bundler/man/bundle-binstubs.1
+++ b/lib/bundler/man/bundle-binstubs.1
@@ -1,42 +1,30 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-BINSTUBS" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-BINSTUBS" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
-.
.SH "SYNOPSIS"
-\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone]
-.
+\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-standalone] [\-\-all\-platforms]
.SH "DESCRIPTION"
Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it into \fBbin/\fR\. Binstubs are a shortcut\-or alternative\- to always using \fBbundle exec\fR\. This gives you a file that can be run directly, and one that will always run the correct gem version used by the application\.
-.
.P
For example, if you run \fBbundle binstubs rspec\-core\fR, Bundler will create the file \fBbin/rspec\fR\. That file will contain enough code to load Bundler, tell it to load the bundled gems, and then run rspec\.
-.
.P
-This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the \fB\-\-path\fR directory if one has been set\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
-.
+This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the directory specified by \fBbin\fR setting if it has been configured\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
.SH "OPTIONS"
-.
.TP
\fB\-\-force\fR
Overwrite existing binstubs if they exist\.
-.
-.TP
-\fB\-\-path\fR
-The location to install the specified binstubs to\. This defaults to \fBbin\fR\.
-.
.TP
\fB\-\-standalone\fR
Makes binstubs that can work without depending on Rubygems or Bundler at runtime\.
-.
.TP
-\fB\-\-shebang\fR
-Specify a different shebang executable name than the default (default \'ruby\')
-.
+\fB\-\-shebang=SHEBANG\fR
+Specify a different shebang executable name than the default (default 'ruby')
.TP
\fB\-\-all\fR
Create binstubs for all gems in the bundle\.
+.TP
+\fB\-\-all\-platforms\fR
+Install binstubs for all platforms\.
diff --git a/lib/bundler/man/bundle-binstubs.1.ronn b/lib/bundler/man/bundle-binstubs.1.ronn
index a96186929f..cbe5983f4d 100644
--- a/lib/bundler/man/bundle-binstubs.1.ronn
+++ b/lib/bundler/man/bundle-binstubs.1.ronn
@@ -3,7 +3,7 @@ bundle-binstubs(1) -- Install the binstubs of the listed gems
## SYNOPSIS
-`bundle binstubs` <GEM_NAME> [--force] [--path PATH] [--standalone]
+`bundle binstubs` <GEM_NAME> [--force] [--standalone] [--all-platforms]
## DESCRIPTION
@@ -19,23 +19,24 @@ the file `bin/rspec`. That file will contain enough code to load Bundler,
tell it to load the bundled gems, and then run rspec.
This command generates binstubs for executables in `GEM_NAME`.
-Binstubs are put into `bin`, or the `--path` directory if one has been set.
-Calling binstubs with [GEM [GEM]] will create binstubs for all given gems.
+Binstubs are put into `bin`, or the directory specified by `bin` setting if it
+has been configured. Calling binstubs with [GEM [GEM]] will create binstubs for
+all given gems.
## OPTIONS
* `--force`:
Overwrite existing binstubs if they exist.
-* `--path`:
- The location to install the specified binstubs to. This defaults to `bin`.
-
* `--standalone`:
Makes binstubs that can work without depending on Rubygems or Bundler at
runtime.
-* `--shebang`:
+* `--shebang=SHEBANG`:
Specify a different shebang executable name than the default (default 'ruby')
* `--all`:
Create binstubs for all gems in the bundle.
+
+* `--all-platforms`:
+ Install binstubs for all platforms.
diff --git a/lib/bundler/man/bundle-cache.1 b/lib/bundler/man/bundle-cache.1
index f24b63c6fc..38ea047961 100644
--- a/lib/bundler/man/bundle-cache.1
+++ b/lib/bundler/man/bundle-cache.1
@@ -1,61 +1,56 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CACHE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-CACHE" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
-.
.SH "SYNOPSIS"
-\fBbundle cache\fR
-.
+\fBbundle cache\fR [\fIOPTIONS\fR]
.P
alias: \fBpackage\fR, \fBpack\fR
-.
.SH "DESCRIPTION"
-Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
-.
+Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR, use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
+.SH "OPTIONS"
+.TP
+\fB\-\-all\-platforms\fR
+Include gems for all platforms present in the lockfile, not only the current one\.
+.TP
+\fB\-\-cache\-path=CACHE\-PATH\fR
+Specify a different cache path than the default (vendor/cache)\.
+.TP
+\fB\-\-gemfile=GEMFILE\fR
+Use the specified gemfile instead of Gemfile\.
+.TP
+\fB\-\-no\-install\fR
+Don't install the gems, only update the cache\.
+.TP
+\fB\-\-quiet\fR
+Only output warnings and errors\.
.SH "GIT AND PATH GEMS"
-The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
-.
+The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This can be disabled setting \fBcache_all\fR to false\.
.SH "SUPPORT FOR MULTIPLE PLATFORMS"
When using gems that have different packages for different platforms, Bundler supports caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
-.
.SH "REMOTE FETCHING"
-By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
-.
+By default, if you run \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
.P
For instance, consider this Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.P
If you run \fBbundle cache\fR under C Ruby, bundler will retrieve the version of \fBnokogiri\fR for the \fB"ruby"\fR platform\. If you deploy to JRuby and run \fBbundle install\fR, bundler is forced to check to see whether a \fB"java"\fR platformed \fBnokogiri\fR exists\.
-.
.P
Even though the \fBnokogiri\fR gem for the Ruby platform is \fItechnically\fR acceptable on JRuby, it has a C extension that does not run on JRuby\. As a result, bundler will, by default, still connect to \fBrubygems\.org\fR to check whether it has a version of one of your gems more specific to your platform\.
-.
.P
This problem is also not limited to the \fB"java"\fR platform\. A similar (common) problem can happen when developing on Windows and deploying to Linux, or even when developing on OSX and deploying to Linux\.
-.
.P
If you know for sure that the gems packaged in \fBvendor/cache\fR are appropriate for the platform you are on, you can run \fBbundle install \-\-local\fR to skip checking for more appropriate gems, and use the ones in \fBvendor/cache\fR\.
-.
.P
One way to be sure that you have the right platformed versions of all your gems is to run \fBbundle cache\fR on an identical machine and check in the gems\. For instance, you can run \fBbundle cache\fR on an identical staging box during your staging process, and check in the \fBvendor/cache\fR before deploying to production\.
-.
.P
By default, bundle cache(1) \fIbundle\-cache\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle cache \-\-no\-install\fR\.
-.
.SH "HISTORY"
In Bundler 2\.1, \fBcache\fR took in the functionalities of \fBpackage\fR and now \fBpackage\fR and \fBpack\fR are aliases of \fBcache\fR\.
diff --git a/lib/bundler/man/bundle-cache.1.ronn b/lib/bundler/man/bundle-cache.1.ronn
index 46906d2b48..51846c96b4 100644
--- a/lib/bundler/man/bundle-cache.1.ronn
+++ b/lib/bundler/man/bundle-cache.1.ronn
@@ -1,23 +1,39 @@
bundle-cache(1) -- Package your needed `.gem` files into your application
-===========================================================================
+=========================================================================
## SYNOPSIS
-`bundle cache`
+`bundle cache` [*OPTIONS*]
alias: `package`, `pack`
## DESCRIPTION
Copy all of the `.gem` files needed to run the application into the
-`vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
+`vendor/cache` directory. In the future, when running [`bundle install(1)`](bundle-install.1.html),
use the gems in the cache in preference to the ones on `rubygems.org`.
+## OPTIONS
+
+* `--all-platforms`:
+ Include gems for all platforms present in the lockfile, not only the current one.
+
+* `--cache-path=CACHE-PATH`:
+ Specify a different cache path than the default (vendor/cache).
+
+* `--gemfile=GEMFILE`:
+ Use the specified gemfile instead of Gemfile.
+
+* `--no-install`:
+ Don't install the gems, only update the cache.
+
+* `--quiet`:
+ Only output warnings and errors.
+
## GIT AND PATH GEMS
The `bundle cache` command can also package `:git` and `:path` dependencies
-besides .gem files. This needs to be explicitly enabled via the `--all` option.
-Once used, the `--all` option will be remembered.
+besides .gem files. This can be disabled setting `cache_all` to false.
## SUPPORT FOR MULTIPLE PLATFORMS
@@ -29,7 +45,7 @@ bundler configuration.
## REMOTE FETCHING
-By default, if you run `bundle install(1)`](bundle-install.1.html) after running
+By default, if you run [`bundle install(1)`](bundle-install.1.html) after running
[bundle cache(1)](bundle-cache.1.html), bundler will still connect to `rubygems.org`
to check whether a platform-specific gem exists for any of the gems
in `vendor/cache`.
diff --git a/lib/bundler/man/bundle-check.1 b/lib/bundler/man/bundle-check.1
index 7679945c48..6cd474d90a 100644
--- a/lib/bundler/man/bundle-check.1
+++ b/lib/bundler/man/bundle-check.1
@@ -1,31 +1,21 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CHECK" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-CHECK" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
-.
.SH "SYNOPSIS"
-\fBbundle check\fR [\-\-dry\-run] [\-\-gemfile=FILE] [\-\-path=PATH]
-.
+\fBbundle check\fR [\-\-dry\-run] [\-\-gemfile=FILE]
.SH "DESCRIPTION"
\fBcheck\fR searches the local machine for each of the gems requested in the Gemfile\. If all gems are found, Bundler prints a success message and exits with a status of 0\.
-.
.P
If not, the first missing gem is listed and Bundler exits status 1\.
-.
+.P
+If the lockfile needs to be updated then it will be resolved using the gems installed on the local machine, if they satisfy the requirements\.
.SH "OPTIONS"
-.
.TP
\fB\-\-dry\-run\fR
Locks the [\fBGemfile(5)\fR][Gemfile(5)] before running the command\.
-.
.TP
-\fB\-\-gemfile\fR
+\fB\-\-gemfile=GEMFILE\fR
Use the specified gemfile instead of the [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
-.TP
-\fB\-\-path\fR
-Specify a different path than the system default (\fB$BUNDLE_PATH\fR or \fB$GEM_HOME\fR)\. Bundler will remember this value for future installs on this machine\.
diff --git a/lib/bundler/man/bundle-check.1.ronn b/lib/bundler/man/bundle-check.1.ronn
index f2846b8ff2..92589159c9 100644
--- a/lib/bundler/man/bundle-check.1.ronn
+++ b/lib/bundler/man/bundle-check.1.ronn
@@ -5,7 +5,6 @@ bundle-check(1) -- Verifies if dependencies are satisfied by installed gems
`bundle check` [--dry-run]
[--gemfile=FILE]
- [--path=PATH]
## DESCRIPTION
@@ -15,12 +14,13 @@ a status of 0.
If not, the first missing gem is listed and Bundler exits status 1.
+If the lockfile needs to be updated then it will be resolved using the gems
+installed on the local machine, if they satisfy the requirements.
+
## OPTIONS
* `--dry-run`:
Locks the [`Gemfile(5)`][Gemfile(5)] before running the command.
-* `--gemfile`:
+
+* `--gemfile=GEMFILE`:
Use the specified gemfile instead of the [`Gemfile(5)`][Gemfile(5)].
-* `--path`:
- Specify a different path than the system default (`$BUNDLE_PATH` or `$GEM_HOME`).
- Bundler will remember this value for future installs on this machine.
diff --git a/lib/bundler/man/bundle-clean.1 b/lib/bundler/man/bundle-clean.1
index 2eb745698c..eb90636c17 100644
--- a/lib/bundler/man/bundle-clean.1
+++ b/lib/bundler/man/bundle-clean.1
@@ -1,23 +1,16 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CLEAN" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-CLEAN" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
-.
.SH "SYNOPSIS"
\fBbundle clean\fR [\-\-dry\-run] [\-\-force]
-.
.SH "DESCRIPTION"
This command will remove all unused gems in your bundler directory\. This is useful when you have made many changes to your gem dependencies\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-dry\-run\fR
Print the changes, but do not clean the unused gems\.
-.
.TP
\fB\-\-force\fR
Forces cleaning up unused gems even if Bundler is configured to use globally installed gems\. As a consequence, removes all system gems except for the ones in the current application\.
diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1
index 493b57e1de..c055c8a415 100644
--- a/lib/bundler/man/bundle-config.1
+++ b/lib/bundler/man/bundle-config.1
@@ -1,515 +1,343 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CONFIG" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-CONFIG" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options
-.
.SH "SYNOPSIS"
-\fBbundle config\fR list
-.
+\fBbundle config\fR [list]
.br
-\fBbundle config\fR [get] NAME
-.
+\fBbundle config\fR [get [\-\-local|\-\-global]] NAME
.br
-\fBbundle config\fR [set] NAME VALUE
-.
+\fBbundle config\fR [set [\-\-local|\-\-global]] NAME VALUE
.br
-\fBbundle config\fR unset NAME
-.
+\fBbundle config\fR unset [\-\-local|\-\-global] NAME
.SH "DESCRIPTION"
-This command allows you to interact with Bundler\'s configuration system\.
-.
+This command allows you to interact with Bundler's configuration system\.
.P
Bundler loads configuration settings in this order:
-.
.IP "1." 4
Local config (\fB<project_root>/\.bundle/config\fR or \fB$BUNDLE_APP_CONFIG/config\fR)
-.
.IP "2." 4
Environmental variables (\fBENV\fR)
-.
.IP "3." 4
Global config (\fB~/\.bundle/config\fR)
-.
.IP "4." 4
Bundler default config
-.
.IP "" 0
-.
.P
+Executing \fBbundle\fR with the \fBBUNDLE_IGNORE_CONFIG\fR environment variable set will cause it to ignore all configuration\.
+.SH "SUB\-COMMANDS"
+.SS "list (default command)"
Executing \fBbundle config list\fR will print a list of all bundler configuration for the current bundle, and where that configuration was set\.
-.
+.SS "get"
+Executing \fBbundle config get <name>\fR will print the value of that configuration setting, and all locations where it was set\.
.P
-Executing \fBbundle config get <name>\fR will print the value of that configuration setting, and where it was set\.
-.
-.P
-Executing \fBbundle config set <name> <value>\fR defaults to setting \fBlocal\fR configuration if executing from within a local application, otherwise it will set \fBglobal\fR configuration\. See \fB\-\-local\fR and \fB\-\-global\fR options below\.
-.
+\fBOPTIONS\fR
+.TP
+\fB\-\-local\fR
+Get configuration from configuration file for the local application, namely, \fB<project_root>/\.bundle/config\fR, or \fB$BUNDLE_APP_CONFIG/config\fR if \fBBUNDLE_APP_CONFIG\fR is set\.
+.TP
+\fB\-\-global\fR
+Get configuration from configuration file global to all bundles executed as the current user, namely, from \fB~/\.bundle/config\fR\.
+.SS "set"
+Executing \fBbundle config set <name> <value>\fR defaults to setting \fBlocal\fR configuration if executing from within a local application, otherwise it will set \fBglobal\fR configuration\.
.P
+\fBOPTIONS\fR
+.TP
+\fB\-\-local\fR
Executing \fBbundle config set \-\-local <name> <value>\fR will set that configuration in the directory for the local application\. The configuration will be stored in \fB<project_root>/\.bundle/config\fR\. If \fBBUNDLE_APP_CONFIG\fR is set, the configuration will be stored in \fB$BUNDLE_APP_CONFIG/config\fR\.
-.
-.P
+.TP
+\fB\-\-global\fR
Executing \fBbundle config set \-\-global <name> <value>\fR will set that configuration to the value specified for all bundles executed as the current user\. The configuration will be stored in \fB~/\.bundle/config\fR\. If \fIname\fR already is set, \fIname\fR will be overridden and user will be warned\.
-.
-.P
+.SS "unset"
Executing \fBbundle config unset <name>\fR will delete the configuration in both local and global sources\.
-.
-.P
-Executing \fBbundle config unset \-\-global <name>\fR will delete the configuration only from the user configuration\.
-.
-.P
-Executing \fBbundle config unset \-\-local <name>\fR will delete the configuration only from the local application\.
-.
-.P
-Executing bundle with the \fBBUNDLE_IGNORE_CONFIG\fR environment variable set will cause it to ignore all configuration\.
-.
-.SH "REMEMBERING OPTIONS"
-Flags passed to \fBbundle install\fR or the Bundler runtime, such as \fB\-\-path foo\fR or \fB\-\-without production\fR, are remembered between commands and saved to your local application\'s configuration (normally, \fB\./\.bundle/config\fR)\.
-.
-.P
-However, this will be changed in bundler 3, so it\'s better not to rely on this behavior\. If these options must be remembered, it\'s better to set them using \fBbundle config\fR (e\.g\., \fBbundle config set \-\-local path foo\fR)\.
-.
.P
-The options that can be configured are:
-.
+\fBOPTIONS\fR
.TP
-\fBbin\fR
-Creates a directory (defaults to \fB~/bin\fR) and place any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
-.TP
-\fBdeployment\fR
-In deployment mode, Bundler will \'roll\-out\' the bundle for \fBproduction\fR use\. Please check carefully if you want to have this option enabled in \fBdevelopment\fR or \fBtest\fR environments\.
-.
-.TP
-\fBonly\fR
-A space\-separated list of groups to install only gems of the specified groups\.
-.
-.TP
-\fBpath\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
-.TP
-\fBwithout\fR
-A space\-separated list of groups referencing gems to skip during installation\.
-.
+\fB\-\-local\fR
+Executing \fBbundle config unset \-\-local <name>\fR will delete the configuration only from the local application\.
.TP
-\fBwith\fR
-A space\-separated list of \fBoptional\fR groups referencing gems to include during installation\.
-.
-.SH "BUILD OPTIONS"
-You can use \fBbundle config\fR to give Bundler the flags to pass to the gem installer every time bundler tries to install a particular gem\.
-.
-.P
-A very common example, the \fBmysql\fR gem, requires Snow Leopard users to pass configuration flags to \fBgem install\fR to specify where to find the \fBmysql_config\fR executable\.
-.
-.IP "" 4
-.
-.nf
-
-gem install mysql \-\- \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
-.fi
-.
-.IP "" 0
-.
-.P
-Since the specific location of that executable can change from machine to machine, you can specify these flags on a per\-machine basis\.
-.
-.IP "" 4
-.
-.nf
-
-bundle config set \-\-global build\.mysql \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
-.fi
-.
-.IP "" 0
-.
-.P
-After running this command, every time bundler needs to install the \fBmysql\fR gem, it will pass along the flags you specified\.
-.
+\fB\-\-global\fR
+Executing \fBbundle config unset \-\-global <name>\fR will delete the configuration only from the user configuration\.
.SH "CONFIGURATION KEYS"
Configuration keys in bundler have two forms: the canonical form and the environment variable form\.
-.
.P
-For instance, passing the \fB\-\-without\fR flag to bundle install(1) \fIbundle\-install\.1\.html\fR prevents Bundler from installing certain groups specified in the Gemfile(5)\. Bundler persists this value in \fBapp/\.bundle/config\fR so that calls to \fBBundler\.setup\fR do not try to find gems from the \fBGemfile\fR that you didn\'t install\. Additionally, subsequent calls to bundle install(1) \fIbundle\-install\.1\.html\fR remember this setting and skip those groups\.
-.
+For instance, passing the \fB\-\-without\fR flag to bundle install(1) \fIbundle\-install\.1\.html\fR prevents Bundler from installing certain groups specified in the Gemfile(5)\. Bundler persists this value in \fBapp/\.bundle/config\fR so that calls to \fBBundler\.setup\fR do not try to find gems from the \fBGemfile\fR that you didn't install\. Additionally, subsequent calls to bundle install(1) \fIbundle\-install\.1\.html\fR remember this setting and skip those groups\.
.P
The canonical form of this configuration is \fB"without"\fR\. To convert the canonical form to the environment variable form, capitalize it, and prepend \fBBUNDLE_\fR\. The environment variable form of \fB"without"\fR is \fBBUNDLE_WITHOUT\fR\.
-.
.P
Any periods in the configuration keys must be replaced with two underscores when setting it via environment variables\. The configuration key \fBlocal\.rack\fR becomes the environment variable \fBBUNDLE_LOCAL__RACK\fR\.
-.
.SH "LIST OF AVAILABLE KEYS"
The following is a list of all configuration keys and their purpose\. You can learn more about their operation in bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
-.IP "\(bu" 4
-\fBallow_deployment_source_credential_changes\fR (\fBBUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES\fR): When in deployment mode, allow changing the credentials to a gem\'s source\. Ex: \fBhttps://some\.host\.com/gems/path/\fR \-> \fBhttps://user_name:password@some\.host\.com/gems/path\fR
-.
.IP "\(bu" 4
-\fBallow_offline_install\fR (\fBBUNDLE_ALLOW_OFFLINE_INSTALL\fR): Allow Bundler to use cached data when installing without network access\.
-.
-.IP "\(bu" 4
-\fBauto_clean_without_path\fR (\fBBUNDLE_AUTO_CLEAN_WITHOUT_PATH\fR): Automatically run \fBbundle clean\fR after installing when an explicit \fBpath\fR has not been set and Bundler is not installing into the system gems\.
-.
+\fBapi_request_size\fR (\fBBUNDLE_API_REQUEST_SIZE\fR): Configure how many dependencies to fetch when resolving the specifications\. This configuration is only used when fetching specifications from RubyGems servers that didn't implement the Compact Index API\. Defaults to 100\.
.IP "\(bu" 4
\fBauto_install\fR (\fBBUNDLE_AUTO_INSTALL\fR): Automatically run \fBbundle install\fR when gems are missing\.
-.
.IP "\(bu" 4
-\fBbin\fR (\fBBUNDLE_BIN\fR): Install executables from gems in the bundle to the specified directory\. Defaults to \fBfalse\fR\.
-.
+\fBbin\fR (\fBBUNDLE_BIN\fR): If configured, \fBbundle binstubs\fR will install executables from gems in the bundle to the specified directory\. Otherwise it will create them in a \fBbin\fR directory relative to the Gemfile directory\. These executables run in Bundler's context\. If used, you might add this directory to your environment's \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, \fBbundle binstubs\fR will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
.IP "\(bu" 4
-\fBcache_all\fR (\fBBUNDLE_CACHE_ALL\fR): Cache all gems, including path and git gems\. This needs to be explicitly configured on bundler 1 and bundler 2, but will be the default on bundler 3\.
-.
+\fBcache_all\fR (\fBBUNDLE_CACHE_ALL\fR): Cache all gems, including path and git gems\. This needs to be explicitly before bundler 4, but will be the default on bundler 4\.
.IP "\(bu" 4
\fBcache_all_platforms\fR (\fBBUNDLE_CACHE_ALL_PLATFORMS\fR): Cache gems for all platforms\.
-.
.IP "\(bu" 4
\fBcache_path\fR (\fBBUNDLE_CACHE_PATH\fR): The directory that bundler will place cached gems in when running \fBbundle package\fR, and that bundler will look in when installing gems\. Defaults to \fBvendor/cache\fR\.
-.
.IP "\(bu" 4
-\fBclean\fR (\fBBUNDLE_CLEAN\fR): Whether Bundler should run \fBbundle clean\fR automatically after \fBbundle install\fR\.
-.
+\fBclean\fR (\fBBUNDLE_CLEAN\fR): Whether Bundler should run \fBbundle clean\fR automatically after \fBbundle install\fR\. Defaults to \fBtrue\fR in Bundler 4, as long as \fBpath\fR is not explicitly configured\.
.IP "\(bu" 4
\fBconsole\fR (\fBBUNDLE_CONSOLE\fR): The console that \fBbundle console\fR starts\. Defaults to \fBirb\fR\.
-.
.IP "\(bu" 4
-\fBdefault_install_uses_path\fR (\fBBUNDLE_DEFAULT_INSTALL_USES_PATH\fR): Whether a \fBbundle install\fR without an explicit \fB\-\-path\fR argument defaults to installing gems in \fB\.bundle\fR\.
-.
+\fBcooldown\fR (\fBBUNDLE_COOLDOWN\fR): Number of days a published gem version must age before bundler will resolve to it\. Defaults to unset (no cooldown)\. Pass \fB0\fR to disable cooldown for an individual run\.
+.IP
+The effective cooldown for any given gem is resolved from three layers, highest precedence first:
+.IP "1." 4
+CLI flag \fB\-\-cooldown N\fR on \fBinstall\fR, \fBupdate\fR, \fBadd\fR, and \fBoutdated\fR\.
+.IP "2." 4
+This setting (\fBbundle config set cooldown N\fR or \fBBUNDLE_COOLDOWN=N\fR)\.
+.IP "3." 4
+The per\-source \fBcooldown:\fR keyword in the Gemfile, such as \fBsource "https://rubygems\.org", cooldown: 7\fR\.
+.IP "" 0
+.IP
+The CLI flag and this setting apply uniformly to every source, including ones declared with their own \fBcooldown:\fR value\. To keep a private registry permanently exempt while still cooling down public gems, declare \fBsource "https://internal", cooldown: 0\fR in the Gemfile; remember that \fB\-\-cooldown N\fR on the command line will still override it for that single run\.
+.IP
+Cooldown filtering depends on the gem server providing a per\-version \fBcreated_at\fR timestamp in the v2 compact\-index format\. Versions without that metadata \- older gem servers, historical entries that predate the v2 cutover on \fBrubygems\.org\fR, or private registries that still emit the v1 format \- are treated as outside the cooldown window and remain resolvable\. If you rely on cooldown for supply\-chain protection, confirm that the gem server emits \fBcreated_at\fR in its \fB/info/<gem>\fR responses\.
+.IP "\(bu" 4
+\fBdefault_cli_command\fR (\fBBUNDLE_DEFAULT_CLI_COMMAND\fR): The command that running \fBbundle\fR without arguments should run\. Defaults to \fBcli_help\fR since Bundler 4, but can also be \fBinstall\fR which was the previous default\.
.IP "\(bu" 4
-\fBdeployment\fR (\fBBUNDLE_DEPLOYMENT\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\.
-.
+\fBdeployment\fR (\fBBUNDLE_DEPLOYMENT\fR): Equivalent to setting \fBfrozen\fR to \fBtrue\fR and \fBpath\fR to \fBvendor/bundle\fR\.
.IP "\(bu" 4
\fBdisable_checksum_validation\fR (\fBBUNDLE_DISABLE_CHECKSUM_VALIDATION\fR): Allow installing gems even if they do not match the checksum provided by RubyGems\.
-.
.IP "\(bu" 4
\fBdisable_exec_load\fR (\fBBUNDLE_DISABLE_EXEC_LOAD\fR): Stop Bundler from using \fBload\fR to launch an executable in\-process in \fBbundle exec\fR\.
-.
.IP "\(bu" 4
\fBdisable_local_branch_check\fR (\fBBUNDLE_DISABLE_LOCAL_BRANCH_CHECK\fR): Allow Bundler to use a local git override without a branch specified in the Gemfile\.
-.
.IP "\(bu" 4
\fBdisable_local_revision_check\fR (\fBBUNDLE_DISABLE_LOCAL_REVISION_CHECK\fR): Allow Bundler to use a local git override without checking if the revision present in the lockfile is present in the repository\.
-.
.IP "\(bu" 4
-\fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems\' normal location\.
-.
+\fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems' normal location\.
.IP "\(bu" 4
\fBdisable_version_check\fR (\fBBUNDLE_DISABLE_VERSION_CHECK\fR): Stop Bundler from checking if a newer Bundler version is available on rubygems\.org\.
-.
.IP "\(bu" 4
-\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine\'s platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
-.
+\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine's platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
.IP "\(bu" 4
-\fBfrozen\fR (\fBBUNDLE_FROZEN\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\. Defaults to \fBtrue\fR when \fB\-\-deployment\fR is used\.
-.
+\fBfrozen\fR (\fBBUNDLE_FROZEN\fR): Disallow any automatic changes to \fBGemfile\.lock\fR\. Bundler commands will be blocked unless the lockfile can be installed exactly as written\. Usually this will happen when changing the \fBGemfile\fR manually and forgetting to update the lockfile through \fBbundle lock\fR or \fBbundle install\fR\.
.IP "\(bu" 4
-\fBgem\.github_username\fR (\fBBUNDLE_GEM__GITHUB_USERNAME\fR): Sets a GitHub username or organization to be used in \fBREADME\fR file when you create a new gem via \fBbundle gem\fR command\. It can be overridden by passing an explicit \fB\-\-github\-username\fR flag to \fBbundle gem\fR\.
-.
+\fBgem\.github_username\fR (\fBBUNDLE_GEM__GITHUB_USERNAME\fR): Sets a GitHub username or organization to be used in the \fBREADME\fR and \fB\.gemspec\fR files when you create a new gem via \fBbundle gem\fR command\. It can be overridden by passing an explicit \fB\-\-github\-username\fR flag to \fBbundle gem\fR\.
.IP "\(bu" 4
\fBgem\.push_key\fR (\fBBUNDLE_GEM__PUSH_KEY\fR): Sets the \fB\-\-key\fR parameter for \fBgem push\fR when using the \fBrake release\fR command with a private gemstash server\.
-.
.IP "\(bu" 4
\fBgemfile\fR (\fBBUNDLE_GEMFILE\fR): The name of the file that bundler should use as the \fBGemfile\fR\. This location of this file also sets the root of the project, which is used to resolve relative paths in the \fBGemfile\fR, among other things\. By default, bundler will search up from the current working directory until it finds a \fBGemfile\fR\.
-.
.IP "\(bu" 4
-\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation\.
-.
+\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems and compiled extensions globally, rather than locally to the configured installation path\.
.IP "\(bu" 4
\fBignore_funding_requests\fR (\fBBUNDLE_IGNORE_FUNDING_REQUESTS\fR): When set, no funding requests will be printed\.
-.
.IP "\(bu" 4
\fBignore_messages\fR (\fBBUNDLE_IGNORE_MESSAGES\fR): When set, no post install messages will be printed\. To silence a single gem, use dot notation like \fBignore_messages\.httparty true\fR\.
-.
.IP "\(bu" 4
\fBinit_gems_rb\fR (\fBBUNDLE_INIT_GEMS_RB\fR): Generate a \fBgems\.rb\fR instead of a \fBGemfile\fR when running \fBbundle init\fR\.
-.
.IP "\(bu" 4
-\fBjobs\fR (\fBBUNDLE_JOBS\fR): The number of gems Bundler can install in parallel\. Defaults to the number of available processors\.
-.
+\fBjobs\fR (\fBBUNDLE_JOBS\fR): The number of gems Bundler can download and install in parallel\. Defaults to the number of available processors\.
+.IP "\(bu" 4
+\fBlockfile\fR (\fBBUNDLE_LOCKFILE\fR): The path to the lockfile that bundler should use\. By default, Bundler adds \fB\.lock\fR to the end of the \fBgemfile\fR entry\. Can be set to \fBfalse\fR in the Gemfile to disable lockfile creation entirely (see gemfile(5))\.
+.IP "\(bu" 4
+\fBlockfile_checksums\fR (\fBBUNDLE_LOCKFILE_CHECKSUMS\fR): Whether Bundler should include a checksums section in new lockfiles, to protect from compromised gem sources\. Defaults to true\.
+.IP "\(bu" 4
+\fBno_build_extension\fR (\fBBUNDLE_NO_BUILD_EXTENSION\fR): Whether Bundler should skip building native extensions during installation\. When set, gems are installed without compiling their C extensions\. To build extensions later, unset this setting and run \fBbundle pristine <gem>\fR\.
.IP "\(bu" 4
\fBno_install\fR (\fBBUNDLE_NO_INSTALL\fR): Whether \fBbundle package\fR should skip installing gems\.
-.
+.IP "\(bu" 4
+\fBno_install_plugin\fR (\fBBUNDLE_NO_INSTALL_PLUGIN\fR): Whether Bundler should skip installing RubyGems plugins during installation\. When set, plugin files are not written to the plugins directory\. To install plugins later, unset this setting and run \fBbundle pristine <gem>\fR\.
.IP "\(bu" 4
\fBno_prune\fR (\fBBUNDLE_NO_PRUNE\fR): Whether Bundler should leave outdated gems unpruned when caching\.
-.
.IP "\(bu" 4
-\fBonly\fR (\fBBUNDLE_ONLY\fR): A space\-separated list of groups to install only gems of the specified groups\.
-.
+\fBonly\fR (\fBBUNDLE_ONLY\fR): A space\-separated list of groups to install only gems of the specified groups\. Please check carefully if you want to install also gems without a group, because they get put inside \fBdefault\fR group\. For example \fBonly test:default\fR will install all gems specified in test group and without one\.
.IP "\(bu" 4
-\fBpath\fR (\fBBUNDLE_PATH\fR): The location on disk where all gems in your bundle will be located regardless of \fB$GEM_HOME\fR or \fB$GEM_PATH\fR values\. Bundle gems not found in this location will be installed by \fBbundle install\fR\. Defaults to \fBGem\.dir\fR\. When \-\-deployment is used, defaults to vendor/bundle\.
-.
+\fBpath\fR (\fBBUNDLE_PATH\fR): The location on disk where all gems in your bundle will be located regardless of \fB$GEM_HOME\fR or \fB$GEM_PATH\fR values\. Bundle gems not found in this location will be installed by \fBbundle install\fR\. When not set, Bundler install by default to a \fB\.bundle\fR directory relative to repository root in Bundler 4, and to the default system path (\fBGem\.dir\fR) before Bundler 4\. That means that before Bundler 4, Bundler shares this location with Rubygems, and \fBgem install \|\.\|\.\|\.\fR will have gems installed in the same location and therefore, gems installed without \fBpath\fR set will show up by calling \fBgem list\fR\. This will not be the case in Bundler 4\.
.IP "\(bu" 4
\fBpath\.system\fR (\fBBUNDLE_PATH__SYSTEM\fR): Whether Bundler will install gems into the default system path (\fBGem\.dir\fR)\.
-.
-.IP "\(bu" 4
-\fBpath_relative_to_cwd\fR (\fBBUNDLE_PATH_RELATIVE_TO_CWD\fR) Makes \fB\-\-path\fR relative to the CWD instead of the \fBGemfile\fR\.
-.
-.IP "\(bu" 4
-\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler\'s experimental plugin system\.
-.
.IP "\(bu" 4
-\fBprefer_patch\fR (BUNDLE_PREFER_PATCH): Prefer updating only to next patch version during updates\. Makes \fBbundle update\fR calls equivalent to \fBbundler update \-\-patch\fR\.
-.
+\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler's experimental plugin system\.
.IP "\(bu" 4
-\fBprint_only_version_number\fR (\fBBUNDLE_PRINT_ONLY_VERSION_NUMBER\fR): Print only version number from \fBbundler \-\-version\fR\.
-.
+\fBprefer_patch\fR (\fBBUNDLE_PREFER_PATCH\fR): Prefer updating only to next patch version during updates\. Makes \fBbundle update\fR calls equivalent to \fBbundler update \-\-patch\fR\.
.IP "\(bu" 4
\fBredirect\fR (\fBBUNDLE_REDIRECT\fR): The number of redirects allowed for network requests\. Defaults to \fB5\fR\.
-.
.IP "\(bu" 4
\fBretry\fR (\fBBUNDLE_RETRY\fR): The number of times to retry failed network requests\. Defaults to \fB3\fR\.
-.
-.IP "\(bu" 4
-\fBsetup_makes_kernel_gem_public\fR (\fBBUNDLE_SETUP_MAKES_KERNEL_GEM_PUBLIC\fR): Have \fBBundler\.setup\fR make the \fBKernel#gem\fR method public, even though RubyGems declares it as private\.
-.
.IP "\(bu" 4
\fBshebang\fR (\fBBUNDLE_SHEBANG\fR): The program name that should be invoked for generated binstubs\. Defaults to the ruby install name used to generate the binstub\.
-.
.IP "\(bu" 4
\fBsilence_deprecations\fR (\fBBUNDLE_SILENCE_DEPRECATIONS\fR): Whether Bundler should silence deprecation warnings for behavior that will be changed in the next major version\.
-.
.IP "\(bu" 4
\fBsilence_root_warning\fR (\fBBUNDLE_SILENCE_ROOT_WARNING\fR): Silence the warning Bundler prints when installing gems as root\.
-.
+.IP "\(bu" 4
+\fBsimulate_version\fR (\fBBUNDLE_SIMULATE_VERSION\fR): The virtual version Bundler should use for activating feature flags\. Can be used to simulate all the new functionality that will be enabled in a future major version\.
.IP "\(bu" 4
\fBssl_ca_cert\fR (\fBBUNDLE_SSL_CA_CERT\fR): Path to a designated CA certificate file or folder containing multiple certificates for trusted CAs in PEM format\.
-.
.IP "\(bu" 4
\fBssl_client_cert\fR (\fBBUNDLE_SSL_CLIENT_CERT\fR): Path to a designated file containing a X\.509 client certificate and key in PEM format\.
-.
.IP "\(bu" 4
\fBssl_verify_mode\fR (\fBBUNDLE_SSL_VERIFY_MODE\fR): The SSL verification mode Bundler uses when making HTTPS requests\. Defaults to verify peer\.
-.
-.IP "\(bu" 4
-\fBsuppress_install_using_messages\fR (\fBBUNDLE_SUPPRESS_INSTALL_USING_MESSAGES\fR): Avoid printing \fBUsing \.\.\.\fR messages during installation when the version of a gem has not changed\.
-.
.IP "\(bu" 4
\fBsystem_bindir\fR (\fBBUNDLE_SYSTEM_BINDIR\fR): The location where RubyGems installs binstubs\. Defaults to \fBGem\.bindir\fR\.
-.
.IP "\(bu" 4
\fBtimeout\fR (\fBBUNDLE_TIMEOUT\fR): The seconds allowed before timing out for network requests\. Defaults to \fB10\fR\.
-.
.IP "\(bu" 4
\fBupdate_requires_all_flag\fR (\fBBUNDLE_UPDATE_REQUIRES_ALL_FLAG\fR): Require passing \fB\-\-all\fR to \fBbundle update\fR when everything should be updated, and disallow passing no options to \fBbundle update\fR\.
-.
.IP "\(bu" 4
\fBuser_agent\fR (\fBBUNDLE_USER_AGENT\fR): The custom user agent fragment Bundler includes in API requests\.
-.
.IP "\(bu" 4
-\fBwith\fR (\fBBUNDLE_WITH\fR): A \fB:\fR\-separated list of groups whose gems bundler should install\.
-.
+\fBverbose\fR (\fBBUNDLE_VERBOSE\fR): Whether Bundler should print verbose output\. Defaults to \fBfalse\fR, unless the \fB\-\-verbose\fR CLI flag is used\.
.IP "\(bu" 4
-\fBwithout\fR (\fBBUNDLE_WITHOUT\fR): A \fB:\fR\-separated list of groups whose gems bundler should not install\.
-.
+\fBversion\fR (\fBBUNDLE_VERSION\fR): The version of Bundler to use when running under Bundler environment\. Defaults to \fBlockfile\fR\. You can also specify \fBsystem\fR or \fBx\.y\.z\fR\. \fBlockfile\fR will use the Bundler version specified in the \fBGemfile\.lock\fR, \fBsystem\fR will use the system version of Bundler, and \fBx\.y\.z\fR will use the specified version of Bundler\.
+.IP "\(bu" 4
+\fBwith\fR (\fBBUNDLE_WITH\fR): A space\-separated or \fB:\fR\-separated list of groups whose gems bundler should install\.
+.IP "\(bu" 4
+\fBwithout\fR (\fBBUNDLE_WITHOUT\fR): A space\-separated or \fB:\fR\-separated list of groups whose gems bundler should not install\.
+.IP "" 0
+.SH "BUILD OPTIONS"
+You can use \fBbundle config\fR to give Bundler the flags to pass to the gem installer every time bundler tries to install a particular gem\.
+.P
+A very common example, the \fBmysql\fR gem, requires Snow Leopard users to pass configuration flags to \fBgem install\fR to specify where to find the \fBmysql_config\fR executable\.
+.IP "" 4
+.nf
+gem install mysql \-\- \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
+.fi
.IP "" 0
-.
.P
-In general, you should set these settings per\-application by using the applicable flag to the bundle install(1) \fIbundle\-install\.1\.html\fR or bundle cache(1) \fIbundle\-cache\.1\.html\fR command\.
-.
+Since the specific location of that executable can change from machine to machine, you can specify these flags on a per\-machine basis\.
+.IP "" 4
+.nf
+bundle config set \-\-global build\.mysql \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
+.fi
+.IP "" 0
.P
-You can set them globally either via environment variables or \fBbundle config\fR, whichever is preferable for your setup\. If you use both, environment variables will take preference over global settings\.
-.
+After running this command, every time bundler needs to install the \fBmysql\fR gem, it will pass along the flags you specified\.
.SH "LOCAL GIT REPOS"
Bundler also allows you to work against a git repository locally instead of using the remote version\. This can be achieved by setting up a local override:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-local local\.GEM_NAME /path/to/local/git/repository
-.
.fi
-.
.IP "" 0
-.
.P
-For example, in order to use a local Rack repository, a developer could call:
-.
+Important: This feature only works for gems that are specified with a git source in your Gemfile\. It does not work for gems installed from RubyGems or other sources\. The gem must be defined with \fBgit:\fR option pointing to a remote repository\.
+.P
+For example, if your Gemfile contains:
+.IP "" 4
+.nf
+gem "rack", git: "https://github\.com/rack/rack\.git", branch: "main"
+.fi
+.IP "" 0
+.P
+Then you can use a local Rack repository by running:
.IP "" 4
-.
.nf
-
bundle config set \-\-local local\.rack ~/Work/git/rack
-.
.fi
-.
.IP "" 0
-.
.P
-Now instead of checking out the remote git repository, the local override will be used\. Similar to a path source, every time the local git repository change, changes will be automatically picked up by Bundler\. This means a commit in the local git repo will update the revision in the \fBGemfile\.lock\fR to the local git repo revision\. This requires the same attention as git submodules\. Before pushing to the remote, you need to ensure the local override was pushed, otherwise you may point to a commit that only exists in your local machine\. You\'ll also need to CGI escape your usernames and passwords as well\.
-.
+Now instead of checking out the remote git repository, the local override will be used\. Similar to a path source, every time the local git repository change, changes will be automatically picked up by Bundler\. This means a commit in the local git repo will update the revision in the \fBGemfile\.lock\fR to the local git repo revision\. This requires the same attention as git submodules\. Before pushing to the remote, you need to ensure the local override was pushed, otherwise you may point to a commit that only exists in your local machine\. You'll also need to CGI escape your usernames and passwords as well\.
.P
-Bundler does many checks to ensure a developer won\'t work with invalid references\. Particularly, we force a developer to specify a branch in the \fBGemfile\fR in order to use this feature\. If the branch specified in the \fBGemfile\fR and the current branch in the local git repository do not match, Bundler will abort\. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch\.
-.
+Bundler does many checks to ensure a developer won't work with invalid references\. Particularly, we force a developer to specify a branch in the \fBGemfile\fR in order to use this feature\. If the branch specified in the \fBGemfile\fR and the current branch in the local git repository do not match, Bundler will abort\. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch\.
.P
Finally, Bundler also ensures that the current revision in the \fBGemfile\.lock\fR exists in the local git repository\. By doing this, Bundler forces you to fetch the latest changes in the remotes\.
-.
+.P
+If you need to temporarily use a local version of a gem that is normally installed from RubyGems (not from git), use a path source instead:
+.IP "" 4
+.nf
+gem "rack", path: "~/Work/git/rack"
+.fi
+.IP "" 0
.SH "MIRRORS OF GEM SOURCES"
Bundler supports overriding gem sources with mirrors\. This allows you to configure rubygems\.org as the gem source in your Gemfile while still using your mirror to fetch gems\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.SOURCE_URL MIRROR_URL
-.
.fi
-.
.IP "" 0
-.
.P
For example, to use a mirror of https://rubygems\.org hosted at https://example\.org:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.https://rubygems\.org https://example\.org
-.
.fi
-.
.IP "" 0
-.
.P
Each mirror also provides a fallback timeout setting\. If the mirror does not respond within the fallback timeout, Bundler will try to use the original server instead of the mirror\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.SOURCE_URL\.fallback_timeout TIMEOUT
-.
.fi
-.
.IP "" 0
-.
.P
For example, to fall back to rubygems\.org after 3 seconds:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.https://rubygems\.org\.fallback_timeout 3
-.
.fi
-.
.IP "" 0
-.
.P
The default fallback timeout is 0\.1 seconds, but the setting can currently only accept whole seconds (for example, 1, 15, or 30)\.
-.
.SH "CREDENTIALS FOR GEM SOURCES"
Bundler allows you to configure credentials for any gem source, which allows you to avoid putting secrets into your Gemfile\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global SOURCE_HOSTNAME USERNAME:PASSWORD
-.
.fi
-.
.IP "" 0
-.
.P
For example, to save the credentials of user \fBclaudette\fR for the gem source at \fBgems\.longerous\.com\fR, you would run:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global gems\.longerous\.com claudette:s00pers3krit
-.
.fi
-.
.IP "" 0
-.
.P
Or you can set the credentials as an environment variable like this:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GEMS__LONGEROUS__COM="claudette:s00pers3krit"
-.
.fi
-.
.IP "" 0
-.
.P
For gems with a git source with HTTP(S) URL you can specify credentials like so:
-.
.IP "" 4
-.
.nf
-
-bundle config set \-\-global https://github\.com/rubygems/rubygems\.git username:password
-.
+bundle config set \-\-global https://github\.com/ruby/rubygems\.git username:password
.fi
-.
.IP "" 0
-.
.P
Or you can set the credentials as an environment variable like so:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GITHUB__COM=username:password
-.
.fi
-.
.IP "" 0
-.
.P
This is especially useful for private repositories on hosts such as GitHub, where you can use personal OAuth tokens:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x\-oauth\-basic
-.
.fi
-.
.IP "" 0
-.
.P
Note that any configured credentials will be redacted by informative commands such as \fBbundle config list\fR or \fBbundle config get\fR, unless you use the \fB\-\-parseable\fR flag\. This is to avoid unintentionally leaking credentials when copy\-pasting bundler output\.
-.
.P
Also note that to guarantee a sane mapping between valid environment variable names and valid host names, bundler makes the following transformations:
-.
.IP "\(bu" 4
-Any \fB\-\fR characters in a host name are mapped to a triple dash (\fB___\fR) in the corresponding environment variable\.
-.
+Any \fB\-\fR characters in a host name are mapped to a triple underscore (\fB___\fR) in the corresponding environment variable\.
.IP "\(bu" 4
-Any \fB\.\fR characters in a host name are mapped to a double dash (\fB__\fR) in the corresponding environment variable\.
-.
+Any \fB\.\fR characters in a host name are mapped to a double underscore (\fB__\fR) in the corresponding environment variable\.
.IP "" 0
-.
.P
-This means that if you have a gem server named \fBmy\.gem\-host\.com\fR, you\'ll need to use the \fBBUNDLE_MY__GEM___HOST__COM\fR variable to configure credentials for it through ENV\.
-.
+This means that if you have a gem server named \fBmy\.gem\-host\.com\fR, you'll need to use the \fBBUNDLE_MY__GEM___HOST__COM\fR variable to configure credentials for it through ENV\.
.SH "CONFIGURE BUNDLER DIRECTORIES"
-Bundler\'s home, config, cache and plugin directories are able to be configured through environment variables\. The default location for Bundler\'s home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values
-.
+Bundler's home, cache and plugin directories and config file can be configured through environment variables\. The default location for Bundler's home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values
.IP "" 4
-.
.nf
-
BUNDLE_USER_HOME : $HOME/\.bundle
BUNDLE_USER_CACHE : $BUNDLE_USER_HOME/cache
BUNDLE_USER_CONFIG : $BUNDLE_USER_HOME/config
BUNDLE_USER_PLUGIN : $BUNDLE_USER_HOME/plugin
-.
.fi
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn
index bc8b27cf89..72f891b428 100644
--- a/lib/bundler/man/bundle-config.1.ronn
+++ b/lib/bundler/man/bundle-config.1.ronn
@@ -3,10 +3,10 @@ bundle-config(1) -- Set bundler configuration options
## SYNOPSIS
-`bundle config` list<br>
-`bundle config` [get] NAME<br>
-`bundle config` [set] NAME VALUE<br>
-`bundle config` unset NAME
+`bundle config` [list]<br>
+`bundle config` [get [--local|--global]] NAME<br>
+`bundle config` [set [--local|--global]] NAME VALUE<br>
+`bundle config` unset [--local|--global] NAME
## DESCRIPTION
@@ -19,98 +19,67 @@ Bundler loads configuration settings in this order:
3. Global config (`~/.bundle/config`)
4. Bundler default config
-Executing `bundle config list` will print a list of all bundler
-configuration for the current bundle, and where that configuration
-was set.
-
-Executing `bundle config get <name>` will print the value of that configuration
-setting, and where it was set.
-
-Executing `bundle config set <name> <value>` defaults to setting `local`
-configuration if executing from within a local application, otherwise it will
-set `global` configuration. See `--local` and `--global` options below.
-
-Executing `bundle config set --local <name> <value>` will set that configuration
-in the directory for the local application. The configuration will be stored in
-`<project_root>/.bundle/config`. If `BUNDLE_APP_CONFIG` is set, the configuration
-will be stored in `$BUNDLE_APP_CONFIG/config`.
-
-Executing `bundle config set --global <name> <value>` will set that
-configuration to the value specified for all bundles executed as the current
-user. The configuration will be stored in `~/.bundle/config`. If <name> already
-is set, <name> will be overridden and user will be warned.
-
-Executing `bundle config unset <name>` will delete the configuration in both
-local and global sources.
-
-Executing `bundle config unset --global <name>` will delete the configuration
-only from the user configuration.
-
-Executing `bundle config unset --local <name>` will delete the configuration
-only from the local application.
-
-Executing bundle with the `BUNDLE_IGNORE_CONFIG` environment variable set will
+Executing `bundle` with the `BUNDLE_IGNORE_CONFIG` environment variable set will
cause it to ignore all configuration.
-## REMEMBERING OPTIONS
+## SUB-COMMANDS
-Flags passed to `bundle install` or the Bundler runtime, such as `--path foo` or
-`--without production`, are remembered between commands and saved to your local
-application's configuration (normally, `./.bundle/config`).
+### list (default command)
-However, this will be changed in bundler 3, so it's better not to rely on this
-behavior. If these options must be remembered, it's better to set them using
-`bundle config` (e.g., `bundle config set --local path foo`).
+Executing `bundle config list` will print a list of all bundler
+configuration for the current bundle, and where that configuration
+was set.
-The options that can be configured are:
+### get
-* `bin`:
- Creates a directory (defaults to `~/bin`) and place any executables from the
- gem there. These executables run in Bundler's context. If used, you might add
- this directory to your environment's `PATH` variable. For instance, if the
- `rails` gem comes with a `rails` executable, this flag will create a
- `bin/rails` executable that ensures that all referred dependencies will be
- resolved using the bundled gems.
+Executing `bundle config get <name>` will print the value of that configuration
+setting, and all locations where it was set.
-* `deployment`:
- In deployment mode, Bundler will 'roll-out' the bundle for
- `production` use. Please check carefully if you want to have this option
- enabled in `development` or `test` environments.
+**OPTIONS**
-* `only`:
- A space-separated list of groups to install only gems of the specified groups.
+* `--local`:
+ Get configuration from configuration file for the local application, namely,
+ `<project_root>/.bundle/config`, or `$BUNDLE_APP_CONFIG/config` if
+ `BUNDLE_APP_CONFIG` is set.
-* `path`:
- The location to install the specified gems to. This defaults to Rubygems'
- setting. Bundler shares this location with Rubygems, `gem install ...` will
- have gem installed there, too. Therefore, gems installed without a
- `--path ...` setting will show up by calling `gem list`. Accordingly, gems
- installed to other locations will not get listed.
+* `--global`:
+ Get configuration from configuration file global to all bundles executed as
+ the current user, namely, from `~/.bundle/config`.
-* `without`:
- A space-separated list of groups referencing gems to skip during installation.
+### set
-* `with`:
- A space-separated list of **optional** groups referencing gems to include during installation.
+Executing `bundle config set <name> <value>` defaults to setting `local`
+configuration if executing from within a local application, otherwise it will
+set `global` configuration.
-## BUILD OPTIONS
+**OPTIONS**
-You can use `bundle config` to give Bundler the flags to pass to the gem
-installer every time bundler tries to install a particular gem.
+* `--local`:
+ Executing `bundle config set --local <name> <value>` will set that configuration
+ in the directory for the local application. The configuration will be stored in
+ `<project_root>/.bundle/config`. If `BUNDLE_APP_CONFIG` is set, the configuration
+ will be stored in `$BUNDLE_APP_CONFIG/config`.
-A very common example, the `mysql` gem, requires Snow Leopard users to
-pass configuration flags to `gem install` to specify where to find the
-`mysql_config` executable.
+* `--global`:
+ Executing `bundle config set --global <name> <value>` will set that
+ configuration to the value specified for all bundles executed as the current
+ user. The configuration will be stored in `~/.bundle/config`. If <name> already
+ is set, <name> will be overridden and user will be warned.
- gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
+### unset
-Since the specific location of that executable can change from machine
-to machine, you can specify these flags on a per-machine basis.
+Executing `bundle config unset <name>` will delete the configuration in both
+local and global sources.
- bundle config set --global build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
+**OPTIONS**
-After running this command, every time bundler needs to install the
-`mysql` gem, it will pass along the flags you specified.
+* `--local`:
+ Executing `bundle config unset --local <name>` will delete the configuration
+ only from the local application.
+
+* `--global`:
+ Executing `bundle config unset --global <name>` will delete the configuration
+ only from the user configuration.
## CONFIGURATION KEYS
@@ -137,22 +106,25 @@ the environment variable `BUNDLE_LOCAL__RACK`.
The following is a list of all configuration keys and their purpose. You can
learn more about their operation in [bundle install(1)](bundle-install.1.html).
-* `allow_deployment_source_credential_changes` (`BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES`):
- When in deployment mode, allow changing the credentials to a gem's source.
- Ex: `https://some.host.com/gems/path/` -> `https://user_name:password@some.host.com/gems/path`
-* `allow_offline_install` (`BUNDLE_ALLOW_OFFLINE_INSTALL`):
- Allow Bundler to use cached data when installing without network access.
-* `auto_clean_without_path` (`BUNDLE_AUTO_CLEAN_WITHOUT_PATH`):
- Automatically run `bundle clean` after installing when an explicit `path`
- has not been set and Bundler is not installing into the system gems.
+* `api_request_size` (`BUNDLE_API_REQUEST_SIZE`):
+ Configure how many dependencies to fetch when resolving the specifications.
+ This configuration is only used when fetching specifications from RubyGems
+ servers that didn't implement the Compact Index API.
+ Defaults to 100.
* `auto_install` (`BUNDLE_AUTO_INSTALL`):
Automatically run `bundle install` when gems are missing.
* `bin` (`BUNDLE_BIN`):
- Install executables from gems in the bundle to the specified directory.
- Defaults to `false`.
+ If configured, `bundle binstubs` will install executables from gems in the
+ bundle to the specified directory. Otherwise it will create them in a `bin`
+ directory relative to the Gemfile directory. These executables run in
+ Bundler's context. If used, you might add this directory to your
+ environment's `PATH` variable. For instance, if the `rails` gem comes with a
+ `rails` executable, `bundle binstubs` will create a `bin/rails` executable
+ that ensures that all referred dependencies will be resolved using the
+ bundled gems.
* `cache_all` (`BUNDLE_CACHE_ALL`):
Cache all gems, including path and git gems. This needs to be explicitly
- configured on bundler 1 and bundler 2, but will be the default on bundler 3.
+ before bundler 4, but will be the default on bundler 4.
* `cache_all_platforms` (`BUNDLE_CACHE_ALL_PLATFORMS`):
Cache gems for all platforms.
* `cache_path` (`BUNDLE_CACHE_PATH`):
@@ -161,15 +133,46 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
Defaults to `vendor/cache`.
* `clean` (`BUNDLE_CLEAN`):
Whether Bundler should run `bundle clean` automatically after
- `bundle install`.
+ `bundle install`. Defaults to `true` in Bundler 4, as long as `path` is not
+ explicitly configured.
* `console` (`BUNDLE_CONSOLE`):
The console that `bundle console` starts. Defaults to `irb`.
-* `default_install_uses_path` (`BUNDLE_DEFAULT_INSTALL_USES_PATH`):
- Whether a `bundle install` without an explicit `--path` argument defaults
- to installing gems in `.bundle`.
+* `cooldown` (`BUNDLE_COOLDOWN`):
+ Number of days a published gem version must age before bundler will
+ resolve to it. Defaults to unset (no cooldown). Pass `0` to disable
+ cooldown for an individual run.
+
+ The effective cooldown for any given gem is resolved from three
+ layers, highest precedence first:
+
+ 1. CLI flag `--cooldown N` on `install`, `update`, `add`, and
+ `outdated`.
+ 2. This setting (`bundle config set cooldown N` or
+ `BUNDLE_COOLDOWN=N`).
+ 3. The per-source `cooldown:` keyword in the Gemfile, such as
+ `source "https://rubygems.org", cooldown: 7`.
+
+ The CLI flag and this setting apply uniformly to every source,
+ including ones declared with their own `cooldown:` value. To keep a
+ private registry permanently exempt while still cooling down public
+ gems, declare `source "https://internal", cooldown: 0` in the
+ Gemfile; remember that `--cooldown N` on the command line will
+ still override it for that single run.
+
+ Cooldown filtering depends on the gem server providing a per-version
+ `created_at` timestamp in the v2 compact-index format. Versions
+ without that metadata - older gem servers, historical entries that
+ predate the v2 cutover on `rubygems.org`, or private registries that
+ still emit the v1 format - are treated as outside the cooldown
+ window and remain resolvable. If you rely on cooldown for
+ supply-chain protection, confirm that the gem server emits
+ `created_at` in its `/info/<gem>` responses.
+* `default_cli_command` (`BUNDLE_DEFAULT_CLI_COMMAND`):
+ The command that running `bundle` without arguments should run. Defaults to
+ `cli_help` since Bundler 4, but can also be `install` which was the previous
+ default.
* `deployment` (`BUNDLE_DEPLOYMENT`):
- Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the
- lockfile has not been updated, running Bundler commands will be blocked.
+ Equivalent to setting `frozen` to `true` and `path` to `vendor/bundle`.
* `disable_checksum_validation` (`BUNDLE_DISABLE_CHECKSUM_VALIDATION`):
Allow installing gems even if they do not match the checksum provided by
RubyGems.
@@ -191,12 +194,13 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
Ignore the current machine's platform and install only `ruby` platform gems.
As a result, gems with native extensions will be compiled from source.
* `frozen` (`BUNDLE_FROZEN`):
- Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the
- lockfile has not been updated, running Bundler commands will be blocked.
- Defaults to `true` when `--deployment` is used.
+ Disallow any automatic changes to `Gemfile.lock`. Bundler commands will
+ be blocked unless the lockfile can be installed exactly as written.
+ Usually this will happen when changing the `Gemfile` manually and forgetting
+ to update the lockfile through `bundle lock` or `bundle install`.
* `gem.github_username` (`BUNDLE_GEM__GITHUB_USERNAME`):
- Sets a GitHub username or organization to be used in `README` file when you
- create a new gem via `bundle gem` command. It can be overridden by passing an
+ Sets a GitHub username or organization to be used in the `README` and `.gemspec` files
+ when you create a new gem via `bundle gem` command. It can be overridden by passing an
explicit `--github-username` flag to `bundle gem`.
* `gem.push_key` (`BUNDLE_GEM__PUSH_KEY`):
Sets the `--key` parameter for `gem push` when using the `rake release`
@@ -208,8 +212,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
will search up from the current working directory until it finds a
`Gemfile`.
* `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`):
- Whether Bundler should cache all gems globally, rather than locally to the
- installing Ruby installation.
+ Whether Bundler should cache all gems and compiled extensions globally,
+ rather than locally to the configured installation path.
* `ignore_funding_requests` (`BUNDLE_IGNORE_FUNDING_REQUESTS`):
When set, no funding requests will be printed.
* `ignore_messages` (`BUNDLE_IGNORE_MESSAGES`):
@@ -218,36 +222,51 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `init_gems_rb` (`BUNDLE_INIT_GEMS_RB`):
Generate a `gems.rb` instead of a `Gemfile` when running `bundle init`.
* `jobs` (`BUNDLE_JOBS`):
- The number of gems Bundler can install in parallel. Defaults to the number of
- available processors.
+ The number of gems Bundler can download and install in parallel.
+ Defaults to the number of available processors.
+* `lockfile` (`BUNDLE_LOCKFILE`):
+ The path to the lockfile that bundler should use. By default, Bundler adds
+ `.lock` to the end of the `gemfile` entry. Can be set to `false` in the
+ Gemfile to disable lockfile creation entirely (see gemfile(5)).
+* `lockfile_checksums` (`BUNDLE_LOCKFILE_CHECKSUMS`):
+ Whether Bundler should include a checksums section in new lockfiles, to protect from compromised gem sources. Defaults to true.
+* `no_build_extension` (`BUNDLE_NO_BUILD_EXTENSION`):
+ Whether Bundler should skip building native extensions during installation.
+ When set, gems are installed without compiling their C extensions.
+ To build extensions later, unset this setting and run `bundle pristine <gem>`.
* `no_install` (`BUNDLE_NO_INSTALL`):
Whether `bundle package` should skip installing gems.
+* `no_install_plugin` (`BUNDLE_NO_INSTALL_PLUGIN`):
+ Whether Bundler should skip installing RubyGems plugins during installation.
+ When set, plugin files are not written to the plugins directory.
+ To install plugins later, unset this setting and run `bundle pristine <gem>`.
* `no_prune` (`BUNDLE_NO_PRUNE`):
Whether Bundler should leave outdated gems unpruned when caching.
* `only` (`BUNDLE_ONLY`):
A space-separated list of groups to install only gems of the specified groups.
+ Please check carefully if you want to install also gems without a group, because
+ they get put inside `default` group. For example `only test:default` will install
+ all gems specified in test group and without one.
* `path` (`BUNDLE_PATH`):
The location on disk where all gems in your bundle will be located regardless
of `$GEM_HOME` or `$GEM_PATH` values. Bundle gems not found in this location
- will be installed by `bundle install`. Defaults to `Gem.dir`. When --deployment
- is used, defaults to vendor/bundle.
+ will be installed by `bundle install`. When not set, Bundler install by
+ default to a `.bundle` directory relative to repository root in Bundler 4,
+ and to the default system path (`Gem.dir`) before Bundler 4. That means that
+ before Bundler 4, Bundler shares this location with Rubygems, and `gem
+ install ...` will have gems installed in the same location and therefore,
+ gems installed without `path` set will show up by calling `gem list`. This
+ will not be the case in Bundler 4.
* `path.system` (`BUNDLE_PATH__SYSTEM`):
Whether Bundler will install gems into the default system path (`Gem.dir`).
-* `path_relative_to_cwd` (`BUNDLE_PATH_RELATIVE_TO_CWD`)
- Makes `--path` relative to the CWD instead of the `Gemfile`.
* `plugins` (`BUNDLE_PLUGINS`):
Enable Bundler's experimental plugin system.
-* `prefer_patch` (BUNDLE_PREFER_PATCH):
+* `prefer_patch` (`BUNDLE_PREFER_PATCH`):
Prefer updating only to next patch version during updates. Makes `bundle update` calls equivalent to `bundler update --patch`.
-* `print_only_version_number` (`BUNDLE_PRINT_ONLY_VERSION_NUMBER`):
- Print only version number from `bundler --version`.
* `redirect` (`BUNDLE_REDIRECT`):
The number of redirects allowed for network requests. Defaults to `5`.
* `retry` (`BUNDLE_RETRY`):
The number of times to retry failed network requests. Defaults to `3`.
-* `setup_makes_kernel_gem_public` (`BUNDLE_SETUP_MAKES_KERNEL_GEM_PUBLIC`):
- Have `Bundler.setup` make the `Kernel#gem` method public, even though
- RubyGems declares it as private.
* `shebang` (`BUNDLE_SHEBANG`):
The program name that should be invoked for generated binstubs. Defaults to
the ruby install name used to generate the binstub.
@@ -256,6 +275,10 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
be changed in the next major version.
* `silence_root_warning` (`BUNDLE_SILENCE_ROOT_WARNING`):
Silence the warning Bundler prints when installing gems as root.
+* `simulate_version` (`BUNDLE_SIMULATE_VERSION`):
+ The virtual version Bundler should use for activating feature flags. Can be
+ used to simulate all the new functionality that will be enabled in a future
+ major version.
* `ssl_ca_cert` (`BUNDLE_SSL_CA_CERT`):
Path to a designated CA certificate file or folder containing multiple
certificates for trusted CAs in PEM format.
@@ -265,9 +288,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `ssl_verify_mode` (`BUNDLE_SSL_VERIFY_MODE`):
The SSL verification mode Bundler uses when making HTTPS requests.
Defaults to verify peer.
-* `suppress_install_using_messages` (`BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES`):
- Avoid printing `Using ...` messages during installation when the version of
- a gem has not changed.
* `system_bindir` (`BUNDLE_SYSTEM_BINDIR`):
The location where RubyGems installs binstubs. Defaults to `Gem.bindir`.
* `timeout` (`BUNDLE_TIMEOUT`):
@@ -277,17 +297,38 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
and disallow passing no options to `bundle update`.
* `user_agent` (`BUNDLE_USER_AGENT`):
The custom user agent fragment Bundler includes in API requests.
+* `verbose` (`BUNDLE_VERBOSE`):
+ Whether Bundler should print verbose output. Defaults to `false`, unless the
+ `--verbose` CLI flag is used.
+* `version` (`BUNDLE_VERSION`):
+ The version of Bundler to use when running under Bundler environment.
+ Defaults to `lockfile`. You can also specify `system` or `x.y.z`.
+ `lockfile` will use the Bundler version specified in the `Gemfile.lock`,
+ `system` will use the system version of Bundler, and `x.y.z` will use
+ the specified version of Bundler.
* `with` (`BUNDLE_WITH`):
- A `:`-separated list of groups whose gems bundler should install.
+ A space-separated or `:`-separated list of groups whose gems bundler should install.
* `without` (`BUNDLE_WITHOUT`):
- A `:`-separated list of groups whose gems bundler should not install.
+ A space-separated or `:`-separated list of groups whose gems bundler should not install.
+
+## BUILD OPTIONS
+
+You can use `bundle config` to give Bundler the flags to pass to the gem
+installer every time bundler tries to install a particular gem.
+
+A very common example, the `mysql` gem, requires Snow Leopard users to
+pass configuration flags to `gem install` to specify where to find the
+`mysql_config` executable.
+
+ gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
-In general, you should set these settings per-application by using the applicable
-flag to the [bundle install(1)](bundle-install.1.html) or [bundle cache(1)](bundle-cache.1.html) command.
+Since the specific location of that executable can change from machine
+to machine, you can specify these flags on a per-machine basis.
-You can set them globally either via environment variables or `bundle config`,
-whichever is preferable for your setup. If you use both, environment variables
-will take preference over global settings.
+ bundle config set --global build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
+
+After running this command, every time bundler needs to install the
+`mysql` gem, it will pass along the flags you specified.
## LOCAL GIT REPOS
@@ -297,7 +338,16 @@ up a local override:
bundle config set --local local.GEM_NAME /path/to/local/git/repository
-For example, in order to use a local Rack repository, a developer could call:
+Important: This feature only works for gems that are specified with a git
+source in your Gemfile. It does not work for gems installed from RubyGems
+or other sources. The gem must be defined with `git:` option pointing to a
+remote repository.
+
+For example, if your Gemfile contains:
+
+ gem "rack", git: "https://github.com/rack/rack.git", branch: "main"
+
+Then you can use a local Rack repository by running:
bundle config set --local local.rack ~/Work/git/rack
@@ -323,6 +373,11 @@ Finally, Bundler also ensures that the current revision in the
`Gemfile.lock` exists in the local git repository. By doing this, Bundler
forces you to fetch the latest changes in the remotes.
+If you need to temporarily use a local version of a gem that is normally
+installed from RubyGems (not from git), use a path source instead:
+
+ gem "rack", path: "~/Work/git/rack"
+
## MIRRORS OF GEM SOURCES
Bundler supports overriding gem sources with mirrors. This allows you to
@@ -366,7 +421,7 @@ Or you can set the credentials as an environment variable like this:
For gems with a git source with HTTP(S) URL you can specify credentials like so:
- bundle config set --global https://github.com/rubygems/rubygems.git username:password
+ bundle config set --global https://github.com/ruby/rubygems.git username:password
Or you can set the credentials as an environment variable like so:
@@ -385,10 +440,10 @@ copy-pasting bundler output.
Also note that to guarantee a sane mapping between valid environment variable
names and valid host names, bundler makes the following transformations:
-* Any `-` characters in a host name are mapped to a triple dash (`___`) in the
+* Any `-` characters in a host name are mapped to a triple underscore (`___`) in the
corresponding environment variable.
-* Any `.` characters in a host name are mapped to a double dash (`__`) in the
+* Any `.` characters in a host name are mapped to a double underscore (`__`) in the
corresponding environment variable.
This means that if you have a gem server named `my.gem-host.com`, you'll need to
@@ -397,7 +452,7 @@ through ENV.
## CONFIGURE BUNDLER DIRECTORIES
-Bundler's home, config, cache and plugin directories are able to be configured
+Bundler's home, cache and plugin directories and config file can be configured
through environment variables. The default location for Bundler's home directory is
`~/.bundle`, which all directories inherit from by default. The following
outlines the available environment variables and their default values
diff --git a/lib/bundler/man/bundle-console.1 b/lib/bundler/man/bundle-console.1
index ff239004bf..5d3f65365f 100644
--- a/lib/bundler/man/bundle-console.1
+++ b/lib/bundler/man/bundle-console.1
@@ -1,53 +1,33 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CONSOLE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-CONSOLE" "1" "May 2026" ""
.SH "NAME"
-\fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded
-.
+\fBbundle\-console\fR \- Open an IRB session with the bundle pre\-loaded
.SH "SYNOPSIS"
\fBbundle console\fR [GROUP]
-.
.SH "DESCRIPTION"
Starts an interactive Ruby console session in the context of the current bundle\.
-.
.P
If no \fBGROUP\fR is specified, all gems in the \fBdefault\fR group in the Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR are preliminarily loaded\.
-.
.P
If \fBGROUP\fR is specified, all gems in the given group in the Gemfile in addition to the gems in \fBdefault\fR group are loaded\. Even if the given group does not exist in the Gemfile, IRB console starts without any warning or error\.
-.
.P
The environment variable \fBBUNDLE_CONSOLE\fR or \fBbundle config set console\fR can be used to change the shell from the following:
-.
.IP "\(bu" 4
\fBirb\fR (default)
-.
.IP "\(bu" 4
\fBpry\fR (https://github\.com/pry/pry)
-.
.IP "\(bu" 4
\fBripl\fR (https://github\.com/cldwalker/ripl)
-.
.IP "" 0
-.
.P
\fBbundle console\fR uses irb by default\. An alternative Pry or Ripl can be used with \fBbundle console\fR by adjusting the \fBconsole\fR Bundler setting\. Also make sure that \fBpry\fR or \fBripl\fR is in your Gemfile\.
-.
.SH "EXAMPLE"
-.
.nf
-
$ bundle config set console pry
$ bundle console
-Resolving dependencies\.\.\.
+Resolving dependencies\|\.\|\.\|\.
[1] pry(main)>
-.
.fi
-.
-.SH "NOTES"
-This command was deprecated in Bundler 2\.1 and will be removed in 3\.0\. Use \fBbin/console\fR script, which can be generated by \fBbundle gem <NAME>\fR\.
-.
.SH "SEE ALSO"
Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR
diff --git a/lib/bundler/man/bundle-console.1.ronn b/lib/bundler/man/bundle-console.1.ronn
index f9096d386a..ed842ae1c3 100644
--- a/lib/bundler/man/bundle-console.1.ronn
+++ b/lib/bundler/man/bundle-console.1.ronn
@@ -1,5 +1,5 @@
-bundle-console(1) -- Deprecated way to open an IRB session with the bundle pre-loaded
-=====================================================================================
+bundle-console(1) -- Open an IRB session with the bundle pre-loaded
+===================================================================
## SYNOPSIS
@@ -34,11 +34,6 @@ the shell from the following:
Resolving dependencies...
[1] pry(main)>
-## NOTES
-
-This command was deprecated in Bundler 2.1 and will be removed in 3.0.
-Use `bin/console` script, which can be generated by `bundle gem <NAME>`.
-
## SEE ALSO
[Gemfile(5)](https://bundler.io/man/gemfile.5.html)
diff --git a/lib/bundler/man/bundle-doctor.1 b/lib/bundler/man/bundle-doctor.1
index e463b67477..4c59871b66 100644
--- a/lib/bundler/man/bundle-doctor.1
+++ b/lib/bundler/man/bundle-doctor.1
@@ -1,44 +1,69 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-DOCTOR" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-DOCTOR" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems
-.
.SH "SYNOPSIS"
-\fBbundle doctor\fR [\-\-quiet] [\-\-gemfile=GEMFILE]
-.
+\fBbundle doctor [diagnose]\fR [\-\-quiet] [\-\-gemfile=GEMFILE] [\-\-ssl]
+.br
+\fBbundle doctor ssl\fR [\-\-host=HOST] [\-\-tls\-version=TLS\-VERSION] [\-\-verify\-mode=VERIFY\-MODE]
+.br
+\fBbundle doctor\fR help [COMMAND]
.SH "DESCRIPTION"
+You can diagnose common Bundler problems with this command such as checking gem environment or SSL/TLS issue\.
+.SH "SUB\-COMMANDS"
+.SS "diagnose (default command)"
Checks your Gemfile and gem environment for common problems\. If issues are detected, Bundler prints them and exits status 1\. Otherwise, Bundler prints a success message and exits status 0\.
-.
.P
-Examples of common problems caught by bundle\-doctor include:
-.
+Examples of common problems caught include:
.IP "\(bu" 4
Invalid Bundler settings
-.
.IP "\(bu" 4
Mismatched Ruby versions
-.
.IP "\(bu" 4
Mismatched platforms
-.
.IP "\(bu" 4
Uninstalled gems
-.
.IP "\(bu" 4
Missing dependencies
-.
.IP "" 0
-.
-.SH "OPTIONS"
-.
+.P
+\fBOPTIONS\fR
.TP
\fB\-\-quiet\fR
Only output warnings and errors\.
-.
.TP
-\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
+\fB\-\-gemfile=GEMFILE\fR
+The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project's root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
+.TP
+\fB\-\-ssl\fR
+Diagnose common SSL problems when connecting to https://rubygems\.org\.
+.IP
+This flag runs the \fBbundle doctor ssl\fR subcommand with default values underneath\.
+.SS "ssl"
+If you've experienced issues related to SSL certificates and/or TLS versions while connecting to https://rubygems\.org, this command can help troubleshoot common problems\. The diagnostic will perform a few checks such as:
+.IP "\(bu" 4
+Verify the Ruby OpenSSL version installed on your system\.
+.IP "\(bu" 4
+Check the OpenSSL library version used for compilation\.
+.IP "\(bu" 4
+Ensure CA certificates are correctly setup on your machine\.
+.IP "\(bu" 4
+Open a TLS connection and verify the outcome\.
+.IP "" 0
+.P
+\fBOPTIONS\fR
+.TP
+\fB\-\-host=HOST\fR
+Perform the diagnostic on HOST\. Defaults to \fBrubygems\.org\fR\.
+.TP
+\fB\-\-tls\-version=TLS\-VERSION\fR
+Specify the TLS version when opening the connection to HOST\.
+.IP
+Accepted values are: \fB1\.1\fR or \fB1\.2\fR\.
+.TP
+\fB\-\-verify\-mode=VERIFY\-MODE\fR
+Specify the TLS verify mode when opening the connection to HOST\. Defaults to \fBSSL_VERIFY_PEER\fR\.
+.IP
+Accepted values are: \fBCLIENT_ONCE\fR, \fBFAIL_IF_NO_PEER_CERT\fR, \fBNONE\fR, \fBPEER\fR\.
diff --git a/lib/bundler/man/bundle-doctor.1.ronn b/lib/bundler/man/bundle-doctor.1.ronn
index 271ee800ad..7495099ff5 100644
--- a/lib/bundler/man/bundle-doctor.1.ronn
+++ b/lib/bundler/man/bundle-doctor.1.ronn
@@ -3,16 +3,27 @@ bundle-doctor(1) -- Checks the bundle for common problems
## SYNOPSIS
-`bundle doctor` [--quiet]
- [--gemfile=GEMFILE]
+`bundle doctor [diagnose]` [--quiet]
+ [--gemfile=GEMFILE]
+ [--ssl]<br>
+`bundle doctor ssl` [--host=HOST]
+ [--tls-version=TLS-VERSION]
+ [--verify-mode=VERIFY-MODE]<br>
+`bundle doctor` help [COMMAND]
## DESCRIPTION
+You can diagnose common Bundler problems with this command such as checking gem environment or SSL/TLS issue.
+
+## SUB-COMMANDS
+
+### diagnose (default command)
+
Checks your Gemfile and gem environment for common problems. If issues
are detected, Bundler prints them and exits status 1. Otherwise,
Bundler prints a success message and exits status 0.
-Examples of common problems caught by bundle-doctor include:
+Examples of common problems caught include:
* Invalid Bundler settings
* Mismatched Ruby versions
@@ -20,14 +31,47 @@ Examples of common problems caught by bundle-doctor include:
* Uninstalled gems
* Missing dependencies
-## OPTIONS
+**OPTIONS**
* `--quiet`:
Only output warnings and errors.
-* `--gemfile=<gemfile>`:
+* `--gemfile=GEMFILE`:
The location of the Gemfile(5) which Bundler should use. This defaults
to a Gemfile(5) in the current working directory. In general, Bundler
will assume that the location of the Gemfile(5) is also the project's
root and will try to find `Gemfile.lock` and `vendor/cache` relative
to this location.
+
+* `--ssl`:
+ Diagnose common SSL problems when connecting to https://rubygems.org.
+
+ This flag runs the `bundle doctor ssl` subcommand with default values
+ underneath.
+
+### ssl
+
+If you've experienced issues related to SSL certificates and/or TLS versions while connecting
+to https://rubygems.org, this command can help troubleshoot common problems.
+The diagnostic will perform a few checks such as:
+
+* Verify the Ruby OpenSSL version installed on your system.
+* Check the OpenSSL library version used for compilation.
+* Ensure CA certificates are correctly setup on your machine.
+* Open a TLS connection and verify the outcome.
+
+**OPTIONS**
+
+* `--host=HOST`:
+ Perform the diagnostic on HOST. Defaults to `rubygems.org`.
+
+* `--tls-version=TLS-VERSION`:
+ Specify the TLS version when opening the connection to HOST.
+
+ Accepted values are: `1.1` or `1.2`.
+
+* `--verify-mode=VERIFY-MODE`:
+ Specify the TLS verify mode when opening the connection to HOST.
+ Defaults to `SSL_VERIFY_PEER`.
+
+ Accepted values are: `CLIENT_ONCE`, `FAIL_IF_NO_PEER_CERT`, `NONE`, `PEER`.
diff --git a/lib/bundler/man/bundle-env.1 b/lib/bundler/man/bundle-env.1
new file mode 100644
index 0000000000..25fcb64891
--- /dev/null
+++ b/lib/bundler/man/bundle-env.1
@@ -0,0 +1,9 @@
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-ENV" "1" "May 2026" ""
+.SH "NAME"
+\fBbundle\-env\fR \- Print information about the environment Bundler is running under
+.SH "SYNOPSIS"
+\fBbundle env\fR
+.SH "DESCRIPTION"
+Prints information about the environment Bundler is running under\.
diff --git a/lib/bundler/man/bundle-env.1.ronn b/lib/bundler/man/bundle-env.1.ronn
new file mode 100644
index 0000000000..c2df9c29c2
--- /dev/null
+++ b/lib/bundler/man/bundle-env.1.ronn
@@ -0,0 +1,10 @@
+bundle-env(1) -- Print information about the environment Bundler is running under
+=================================================================================
+
+## SYNOPSIS
+
+`bundle env`
+
+## DESCRIPTION
+
+Prints information about the environment Bundler is running under.
diff --git a/lib/bundler/man/bundle-exec.1 b/lib/bundler/man/bundle-exec.1
index 9e9efe8b6d..c3a6a09d57 100644
--- a/lib/bundler/man/bundle-exec.1
+++ b/lib/bundler/man/bundle-exec.1
@@ -1,165 +1,104 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-EXEC" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-EXEC" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle
-.
.SH "SYNOPSIS"
-\fBbundle exec\fR [\-\-keep\-file\-descriptors] \fIcommand\fR
-.
+\fBbundle exec\fR [\-\-gemfile=GEMFILE] \fIcommand\fR
.SH "DESCRIPTION"
This command executes the command, making all gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] available to \fBrequire\fR in Ruby programs\.
-.
.P
Essentially, if you would normally have run something like \fBrspec spec/my_spec\.rb\fR, and you want to use the gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] and installed via bundle install(1) \fIbundle\-install\.1\.html\fR, you should run \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
.P
-Note that \fBbundle exec\fR does not require that an executable is available on your shell\'s \fB$PATH\fR\.
-.
+Note that \fBbundle exec\fR does not require that an executable is available on your shell's \fB$PATH\fR\.
.SH "OPTIONS"
-.
.TP
-\fB\-\-keep\-file\-descriptors\fR
-Exec in Ruby 2\.0 began discarding non\-standard file descriptors\. When this flag is passed, exec will revert to the 1\.9 behaviour of passing all file descriptors to the new process\.
-.
+\fB\-\-gemfile=GEMFILE\fR
+Use the specified gemfile instead of [\fBGemfile(5)\fR][Gemfile(5)]\.
.SH "BUNDLE INSTALL \-\-BINSTUBS"
If you use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR, Bundler will automatically create a directory (which defaults to \fBapp_root/bin\fR) containing all of the executables available from gems in the bundle\.
-.
.P
After using \fB\-\-binstubs\fR, \fBbin/rspec spec/my_spec\.rb\fR is identical to \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
.SH "ENVIRONMENT MODIFICATIONS"
\fBbundle exec\fR makes a number of changes to the shell environment, then executes the command you specify in full\.
-.
.IP "\(bu" 4
-make sure that it\'s still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR)
-.
+make sure that it's still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR)
.IP "\(bu" 4
put the directory containing executables (like \fBrails\fR, \fBrspec\fR, \fBrackup\fR) for your bundle on \fB$PATH\fR
-.
.IP "\(bu" 4
make sure that if bundler is invoked in the subshell, it uses the same \fBGemfile\fR (by setting \fBBUNDLE_GEMFILE\fR)
-.
.IP "\(bu" 4
add \fB\-rbundler/setup\fR to \fB$RUBYOPT\fR, which makes sure that Ruby programs invoked in the subshell can see the gems in the bundle
-.
.IP "" 0
-.
.P
It also modifies Rubygems:
-.
.IP "\(bu" 4
disallow loading additional gems not in the bundle
-.
.IP "\(bu" 4
-modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it\'s not
-.
+modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it's not
.IP "\(bu" 4
Define \fBGem\.refresh\fR to be a no\-op, since the source index is always frozen when using bundler, and to prevent gems from the system leaking into the environment
-.
.IP "\(bu" 4
Override \fBGem\.bin_path\fR to use the gems in the bundle, making system executables work
-.
.IP "\(bu" 4
Add all gems in the bundle into Gem\.loaded_specs
-.
.IP "" 0
-.
.P
-Finally, \fBbundle exec\fR also implicitly modifies \fBGemfile\.lock\fR if the lockfile and the Gemfile do not match\. Bundler needs the Gemfile to determine things such as a gem\'s groups, \fBautorequire\fR, and platforms, etc\., and that information isn\'t stored in the lockfile\. The Gemfile and lockfile must be synced in order to \fBbundle exec\fR successfully, so \fBbundle exec\fR updates the lockfile beforehand\.
-.
+Finally, \fBbundle exec\fR also implicitly modifies \fBGemfile\.lock\fR if the lockfile and the Gemfile do not match\. Bundler needs the Gemfile to determine things such as a gem's groups, \fBautorequire\fR, and platforms, etc\., and that information isn't stored in the lockfile\. The Gemfile and lockfile must be synced in order to \fBbundle exec\fR successfully, so \fBbundle exec\fR updates the lockfile beforehand\.
.SS "Loading"
By default, when attempting to \fBbundle exec\fR to a file with a ruby shebang, Bundler will \fBKernel\.load\fR that file instead of using \fBKernel\.exec\fR\. For the vast majority of cases, this is a performance improvement\. In a rare few cases, this could cause some subtle side\-effects (such as dependence on the exact contents of \fB$0\fR or \fB__FILE__\fR) and the optimization can be disabled by enabling the \fBdisable_exec_load\fR setting\.
-.
.SS "Shelling out"
-Any Ruby code that opens a subshell (like \fBsystem\fR, backticks, or \fB%x{}\fR) will automatically use the current Bundler environment\. If you need to shell out to a Ruby command that is not part of your current bundle, use the \fBwith_unbundled_env\fR method with a block\. Any subshells created inside the block will be given the environment present before Bundler was activated\. For example, Homebrew commands run Ruby, but don\'t work inside a bundle:
-.
+Any Ruby code that opens a subshell (like \fBsystem\fR, backticks, or \fB%x{}\fR) will automatically use the current Bundler environment\. If you need to shell out to a Ruby command that is not part of your current bundle, use the \fBwith_unbundled_env\fR method with a block\. Any subshells created inside the block will be given the environment present before Bundler was activated\. For example, Homebrew commands run Ruby, but don't work inside a bundle:
.IP "" 4
-.
.nf
-
Bundler\.with_unbundled_env do
`brew install wget`
end
-.
.fi
-.
.IP "" 0
-.
.P
Using \fBwith_unbundled_env\fR is also necessary if you are shelling out to a different bundle\. Any Bundler commands run in a subshell will inherit the current Gemfile, so commands that need to run in the context of a different bundle also need to use \fBwith_unbundled_env\fR\.
-.
.IP "" 4
-.
.nf
-
Bundler\.with_unbundled_env do
Dir\.chdir "/other/bundler/project" do
`bundle exec \./script`
end
end
-.
.fi
-.
.IP "" 0
-.
.P
Bundler provides convenience helpers that wrap \fBsystem\fR and \fBexec\fR, and they can be used like this:
-.
.IP "" 4
-.
.nf
-
-Bundler\.clean_system(\'brew install wget\')
-Bundler\.clean_exec(\'brew install wget\')
-.
+Bundler\.unbundled_system('brew install wget')
+Bundler\.unbundled_exec('brew install wget')
.fi
-.
.IP "" 0
-.
.SH "RUBYGEMS PLUGINS"
At present, the Rubygems plugin system requires all files named \fBrubygems_plugin\.rb\fR on the load path of \fIany\fR installed gem when any Ruby code requires \fBrubygems\.rb\fR\. This includes executables installed into the system, like \fBrails\fR, \fBrackup\fR, and \fBrspec\fR\.
-.
.P
Since Rubygems plugins can contain arbitrary Ruby code, they commonly end up activating themselves or their dependencies\.
-.
.P
For instance, the \fBgemcutter 0\.5\fR gem depended on \fBjson_pure\fR\. If you had that version of gemcutter installed (even if you \fIalso\fR had a newer version without this problem), Rubygems would activate \fBgemcutter 0\.5\fR and \fBjson_pure <latest>\fR\.
-.
.P
If your Gemfile(5) also contained \fBjson_pure\fR (or a gem with a dependency on \fBjson_pure\fR), the latest version on your system might conflict with the version in your Gemfile(5), or the snapshot version in your \fBGemfile\.lock\fR\.
-.
.P
If this happens, bundler will say:
-.
.IP "" 4
-.
.nf
-
You have already activated json_pure 1\.4\.6 but your Gemfile
requires json_pure 1\.4\.3\. Consider using bundle exec\.
-.
.fi
-.
.IP "" 0
-.
.P
In this situation, you almost certainly want to remove the underlying gem with the problematic gem plugin\. In general, the authors of these plugins (in this case, the \fBgemcutter\fR gem) have released newer versions that are more careful in their plugins\.
-.
.P
You can find a list of all the gems containing gem plugins by running
-.
.IP "" 4
-.
.nf
-
-ruby \-e "puts Gem\.find_files(\'rubygems_plugin\.rb\')"
-.
+ruby \-e "puts Gem\.find_files('rubygems_plugin\.rb')"
.fi
-.
.IP "" 0
-.
.P
-At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren\'t using (\fBgem uninstall gem_name\fR)\.
+At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren't using (\fBgem uninstall gem_name\fR)\.
diff --git a/lib/bundler/man/bundle-exec.1.ronn b/lib/bundler/man/bundle-exec.1.ronn
index 05948095e2..e51a66a084 100644
--- a/lib/bundler/man/bundle-exec.1.ronn
+++ b/lib/bundler/man/bundle-exec.1.ronn
@@ -3,7 +3,7 @@ bundle-exec(1) -- Execute a command in the context of the bundle
## SYNOPSIS
-`bundle exec` [--keep-file-descriptors] <command>
+`bundle exec` [--gemfile=GEMFILE] <command>
## DESCRIPTION
@@ -20,10 +20,8 @@ available on your shell's `$PATH`.
## OPTIONS
-* `--keep-file-descriptors`:
- Exec in Ruby 2.0 began discarding non-standard file descriptors. When this
- flag is passed, exec will revert to the 1.9 behaviour of passing all file
- descriptors to the new process.
+* `--gemfile=GEMFILE`:
+ Use the specified gemfile instead of [`Gemfile(5)`][Gemfile(5)].
## BUNDLE INSTALL --BINSTUBS
@@ -106,8 +104,8 @@ need to use `with_unbundled_env`.
Bundler provides convenience helpers that wrap `system` and `exec`, and they
can be used like this:
- Bundler.clean_system('brew install wget')
- Bundler.clean_exec('brew install wget')
+ Bundler.unbundled_system('brew install wget')
+ Bundler.unbundled_exec('brew install wget')
## RUBYGEMS PLUGINS
diff --git a/lib/bundler/man/bundle-fund.1 b/lib/bundler/man/bundle-fund.1
new file mode 100644
index 0000000000..caee1f81dd
--- /dev/null
+++ b/lib/bundler/man/bundle-fund.1
@@ -0,0 +1,22 @@
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-FUND" "1" "May 2026" ""
+.SH "NAME"
+\fBbundle\-fund\fR \- Lists information about gems seeking funding assistance
+.SH "SYNOPSIS"
+\fBbundle fund\fR [\fIOPTIONS\fR]
+.SH "DESCRIPTION"
+\fBbundle fund\fR lists information about gems seeking funding assistance\.
+.SH "OPTIONS"
+.TP
+\fB\-\-group=<list>\fR, \fB\-g=<list>\fR
+Fetch funding information for a specific group\.
+.SH "EXAMPLES"
+.nf
+# Lists funding information for all gems
+bundle fund
+
+# Lists funding information for a specific group
+bundle fund \-\-group=security
+.fi
+
diff --git a/lib/bundler/man/bundle-fund.1.ronn b/lib/bundler/man/bundle-fund.1.ronn
new file mode 100644
index 0000000000..faf8b9c4a7
--- /dev/null
+++ b/lib/bundler/man/bundle-fund.1.ronn
@@ -0,0 +1,25 @@
+bundle-fund(1) -- Lists information about gems seeking funding assistance
+=========================================================================
+
+## SYNOPSIS
+
+`bundle fund` [*OPTIONS*]
+
+## DESCRIPTION
+
+**bundle fund** lists information about gems seeking funding assistance.
+
+## OPTIONS
+
+* `--group=<list>`, `-g=<list>`:
+ Fetch funding information for a specific group.
+
+## EXAMPLES
+
+```
+# Lists funding information for all gems
+bundle fund
+
+# Lists funding information for a specific group
+bundle fund --group=security
+```
diff --git a/lib/bundler/man/bundle-gem.1 b/lib/bundler/man/bundle-gem.1
index ea64871fb6..87d7568246 100644
--- a/lib/bundler/man/bundle-gem.1
+++ b/lib/bundler/man/bundle-gem.1
@@ -1,105 +1,107 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-GEM" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-GEM" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
-.
.SH "SYNOPSIS"
\fBbundle gem\fR \fIGEM_NAME\fR \fIOPTIONS\fR
-.
.SH "DESCRIPTION"
Generates a directory named \fBGEM_NAME\fR with a \fBRakefile\fR, \fBGEM_NAME\.gemspec\fR, and other supporting files and directories that can be used to develop a rubygem with that name\.
-.
.P
Run \fBrake \-T\fR in the resulting project for a list of Rake tasks that can be used to test and publish the gem to rubygems\.org\.
-.
.P
-The generated project skeleton can be customized with OPTIONS, as explained below\. Note that these options can also be specified via Bundler\'s global configuration file using the following names:
-.
+The generated project skeleton can be customized with OPTIONS, as explained below\. Note that these options can also be specified via Bundler's global configuration file using the following names:
.IP "\(bu" 4
\fBgem\.coc\fR
-.
.IP "\(bu" 4
\fBgem\.mit\fR
-.
.IP "\(bu" 4
\fBgem\.test\fR
-.
.IP "" 0
-.
.SH "OPTIONS"
-.
-.IP "\(bu" 4
-\fB\-\-exe\fR or \fB\-b\fR or \fB\-\-bin\fR: Specify that Bundler should create a binary executable (as \fBexe/GEM_NAME\fR) in the generated rubygem project\. This binary will also be added to the \fBGEM_NAME\.gemspec\fR manifest\. This behavior is disabled by default\.
-.
-.IP "\(bu" 4
-\fB\-\-no\-exe\fR: Do not create a binary (overrides \fB\-\-exe\fR specified in the global config)\.
-.
-.IP "\(bu" 4
-\fB\-\-coc\fR: Add a \fBCODE_OF_CONDUCT\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.IP "\(bu" 4
-\fB\-\-no\-coc\fR: Do not create a \fBCODE_OF_CONDUCT\.md\fR (overrides \fB\-\-coc\fR specified in the global config)\.
-.
-.IP "\(bu" 4
-\fB\-\-ext=c\fR, \fB\-\-ext=rust\fR Add boilerplate for C or Rust (currently magnus \fIhttps://docs\.rs/magnus\fR based) extension code to the generated project\. This behavior is disabled by default\.
-.
-.IP "\(bu" 4
-\fB\-\-no\-ext\fR: Do not add extension code (overrides \fB\-\-ext\fR specified in the global config)\.
-.
-.IP "\(bu" 4
-\fB\-\-mit\fR: Add an MIT license to a \fBLICENSE\.txt\fR file in the root of the generated project\. Your name from the global git config is used for the copyright statement\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.IP "\(bu" 4
-\fB\-\-no\-mit\fR: Do not create a \fBLICENSE\.txt\fR (overrides \fB\-\-mit\fR specified in the global config)\.
-.
-.IP "\(bu" 4
-\fB\-t\fR, \fB\-\-test=minitest\fR, \fB\-\-test=rspec\fR, \fB\-\-test=test\-unit\fR: Specify the test framework that Bundler should use when generating the project\. Acceptable values are \fBminitest\fR, \fBrspec\fR and \fBtest\-unit\fR\. The \fBGEM_NAME\.gemspec\fR will be configured and a skeleton test/spec directory will be created based on this option\. Given no option is specified:
-.
+.TP
+\fB\-\-exe\fR, \fB\-\-bin\fR, \fB\-b\fR
+Specify that Bundler should create a binary executable (as \fBexe/GEM_NAME\fR) in the generated rubygem project\. This binary will also be added to the \fBGEM_NAME\.gemspec\fR manifest\. This behavior is disabled by default\.
+.TP
+\fB\-\-no\-exe\fR
+Do not create a binary (overrides \fB\-\-exe\fR specified in the global config)\.
+.TP
+\fB\-\-coc\fR
+Add a \fBCODE_OF_CONDUCT\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
+.TP
+\fB\-\-no\-coc\fR
+Do not create a \fBCODE_OF_CONDUCT\.md\fR (overrides \fB\-\-coc\fR specified in the global config)\.
+.TP
+\fB\-\-changelog\fR
+Add a \fBCHANGELOG\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\. Update the default with \fBbundle config set \-\-global gem\.changelog <true|false>\fR\.
+.TP
+\fB\-\-no\-changelog\fR
+Do not create a \fBCHANGELOG\.md\fR (overrides \fB\-\-changelog\fR specified in the global config)\.
+.TP
+\fB\-\-ext=c\fR, \fB\-\-ext=go\fR, \fB\-\-ext=rust\fR
+Add boilerplate for C, Go (currently go\-gem\-wrapper \fIhttps://github\.com/ruby\-go\-gem/go\-gem\-wrapper\fR based) or Rust (currently magnus \fIhttps://docs\.rs/magnus\fR based) extension code to the generated project\. This behavior is disabled by default\.
+.TP
+\fB\-\-no\-ext\fR
+Do not add extension code (overrides \fB\-\-ext\fR specified in the global config)\.
+.TP
+\fB\-\-git\fR
+Initialize a git repo inside your library\.
+.TP
+\fB\-\-github\-username=GITHUB_USERNAME\fR
+Fill in GitHub username on README so that you don't have to do it manually\. Set a default with \fBbundle config set \-\-global gem\.github_username <your_username>\fR\.
+.TP
+\fB\-\-mit\fR
+Add an MIT license to a \fBLICENSE\.txt\fR file in the root of the generated project\. Your name from the global git config is used for the copyright statement\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
+.TP
+\fB\-\-no\-mit\fR
+Do not create a \fBLICENSE\.txt\fR (overrides \fB\-\-mit\fR specified in the global config)\.
+.TP
+\fB\-t\fR, \fB\-\-test=minitest\fR, \fB\-\-test=rspec\fR, \fB\-\-test=test\-unit\fR
+Specify the test framework that Bundler should use when generating the project\. Acceptable values are \fBminitest\fR, \fBrspec\fR and \fBtest\-unit\fR\. The \fBGEM_NAME\.gemspec\fR will be configured and a skeleton test/spec directory will be created based on this option\. Given no option is specified:
.IP
-When Bundler is configured to generate tests, this defaults to Bundler\'s global config setting \fBgem\.test\fR\.
-.
+When Bundler is configured to generate tests, this defaults to Bundler's global config setting \fBgem\.test\fR\.
.IP
When Bundler is configured to not generate tests, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.IP "\(bu" 4
-\fB\-\-ci\fR, \fB\-\-ci=github\fR, \fB\-\-ci=gitlab\fR, \fB\-\-ci=circle\fR: Specify the continuous integration service that Bundler should use when generating the project\. Acceptable values are \fBgithub\fR, \fBgitlab\fR and \fBcircle\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
+.TP
+\fB\-\-no\-test\fR
+Do not use a test framework (overrides \fB\-\-test\fR specified in the global config)\.
+.TP
+\fB\-\-ci\fR, \fB\-\-ci=circle\fR, \fB\-\-ci=github\fR, \fB\-\-ci=gitlab\fR
+Specify the continuous integration service that Bundler should use when generating the project\. Acceptable values are \fBgithub\fR, \fBgitlab\fR and \fBcircle\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
.IP
-When Bundler is configured to generate CI files, this defaults to Bundler\'s global config setting \fBgem\.ci\fR\.
-.
+When Bundler is configured to generate CI files, this defaults to Bundler's global config setting \fBgem\.ci\fR\.
.IP
When Bundler is configured to not generate CI files, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.IP "\(bu" 4
-\fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR: Specify the linter and code formatter that Bundler should add to the project\'s development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
+.TP
+\fB\-\-no\-ci\fR
+Do not use a continuous integration service (overrides \fB\-\-ci\fR specified in the global config)\.
+.TP
+\fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR
+Specify the linter and code formatter that Bundler should add to the project's development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
.IP
-When Bundler is configured to add a linter, this defaults to Bundler\'s global config setting \fBgem\.linter\fR\.
-.
+When Bundler is configured to add a linter, this defaults to Bundler's global config setting \fBgem\.linter\fR\.
.IP
When Bundler is configured not to add a linter, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
-.IP "\(bu" 4
-\fB\-e\fR, \fB\-\-edit[=EDITOR]\fR: Open the resulting GEM_NAME\.gemspec in EDITOR, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
-.
-.IP "" 0
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
+.TP
+\fB\-\-no\-linter\fR
+Do not add a linter (overrides \fB\-\-linter\fR specified in the global config)\.
+.TP
+\fB\-\-edit=EDIT\fR, \fB\-e=EDIT\fR
+Open the resulting GEM_NAME\.gemspec in EDIT, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
+.TP
+\fB\-\-bundle\fR
+Run \fBbundle install\fR after creating the gem\.
+.TP
+\fB\-\-no\-bundle\fR
+Do not run \fBbundle install\fR after creating the gem\.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
bundle config(1) \fIbundle\-config\.1\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-gem.1.ronn b/lib/bundler/man/bundle-gem.1.ronn
index 46fa2f179f..488c8113e4 100644
--- a/lib/bundler/man/bundle-gem.1.ronn
+++ b/lib/bundler/man/bundle-gem.1.ronn
@@ -1,5 +1,5 @@
bundle-gem(1) -- Generate a project skeleton for creating a rubygem
-====================================================================
+===================================================================
## SYNOPSIS
@@ -24,7 +24,7 @@ configuration file using the following names:
## OPTIONS
-* `--exe` or `-b` or `--bin`:
+* `--exe`, `--bin`, `-b`:
Specify that Bundler should create a binary executable (as `exe/GEM_NAME`)
in the generated rubygem project. This binary will also be added to the
`GEM_NAME.gemspec` manifest. This behavior is disabled by default.
@@ -41,14 +41,30 @@ configuration file using the following names:
Do not create a `CODE_OF_CONDUCT.md` (overrides `--coc` specified in the
global config).
-* `--ext=c`, `--ext=rust`
- Add boilerplate for C or Rust (currently [magnus](https://docs.rs/magnus) based) extension code to the generated project. This behavior
+* `--changelog`:
+ Add a `CHANGELOG.md` file to the root of the generated project. If
+ this option is unspecified, an interactive prompt will be displayed and the
+ answer will be saved in Bundler's global config for future `bundle gem` use.
+ Update the default with `bundle config set --global gem.changelog <true|false>`.
+
+* `--no-changelog`:
+ Do not create a `CHANGELOG.md` (overrides `--changelog` specified in the
+ global config).
+
+* `--ext=c`, `--ext=go`, `--ext=rust`:
+ Add boilerplate for C, Go (currently [go-gem-wrapper](https://github.com/ruby-go-gem/go-gem-wrapper) based) or Rust (currently [magnus](https://docs.rs/magnus) based) extension code to the generated project. This behavior
is disabled by default.
* `--no-ext`:
Do not add extension code (overrides `--ext` specified in the global
config).
+* `--git`:
+ Initialize a git repo inside your library.
+
+* `--github-username=GITHUB_USERNAME`:
+ Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`.
+
* `--mit`:
Add an MIT license to a `LICENSE.txt` file in the root of the generated
project. Your name from the global git config is used for the copyright
@@ -76,7 +92,11 @@ configuration file using the following names:
the answer will be saved in Bundler's global config for future `bundle gem`
use.
-* `--ci`, `--ci=github`, `--ci=gitlab`, `--ci=circle`:
+* `--no-test`:
+ Do not use a test framework (overrides `--test` specified in the global
+ config).
+
+* `--ci`, `--ci=circle`, `--ci=github`, `--ci=gitlab`:
Specify the continuous integration service that Bundler should use when
generating the project. Acceptable values are `github`, `gitlab`
and `circle`. A configuration file will be generated in the project directory.
@@ -92,6 +112,10 @@ configuration file using the following names:
the answer will be saved in Bundler's global config for future `bundle gem`
use.
+* `--no-ci`:
+ Do not use a continuous integration service (overrides `--ci` specified in
+ the global config).
+
* `--linter`, `--linter=rubocop`, `--linter=standard`:
Specify the linter and code formatter that Bundler should add to the
project's development dependencies. Acceptable values are `rubocop` and
@@ -108,10 +132,19 @@ configuration file using the following names:
the answer will be saved in Bundler's global config for future `bundle gem`
use.
-* `-e`, `--edit[=EDITOR]`:
- Open the resulting GEM_NAME.gemspec in EDITOR, or the default editor if not
+* `--no-linter`:
+ Do not add a linter (overrides `--linter` specified in the global config).
+
+* `--edit=EDIT`, `-e=EDIT`:
+ Open the resulting GEM_NAME.gemspec in EDIT, or the default editor if not
specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.
+* `--bundle`:
+ Run `bundle install` after creating the gem.
+
+* `--no-bundle`:
+ Do not run `bundle install` after creating the gem.
+
## SEE ALSO
* [bundle config(1)](bundle-config.1.html)
diff --git a/lib/bundler/man/bundle-help.1 b/lib/bundler/man/bundle-help.1
index a3b059ea07..3bcfd047e5 100644
--- a/lib/bundler/man/bundle-help.1
+++ b/lib/bundler/man/bundle-help.1
@@ -1,13 +1,9 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-HELP" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-HELP" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-help\fR \- Displays detailed help for each subcommand
-.
.SH "SYNOPSIS"
\fBbundle help\fR [COMMAND]
-.
.SH "DESCRIPTION"
Displays detailed help for the given subcommand\. You can specify a single \fBCOMMAND\fR at the same time\. When \fBCOMMAND\fR is omitted, help for \fBhelp\fR command will be displayed\.
diff --git a/lib/bundler/man/bundle-info.1 b/lib/bundler/man/bundle-info.1
index 5af60c6a77..49c2295f8c 100644
--- a/lib/bundler/man/bundle-info.1
+++ b/lib/bundler/man/bundle-info.1
@@ -1,20 +1,17 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INFO" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-INFO" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-info\fR \- Show information for the given gem in your bundle
-.
.SH "SYNOPSIS"
-\fBbundle info\fR [GEM] [\-\-path]
-.
+\fBbundle info\fR [GEM_NAME] [\-\-path] [\-\-version]
.SH "DESCRIPTION"
-Print the basic information about the provided GEM such as homepage, version, path and summary\.
-.
+Given a gem name present in your bundle, print the basic information about it such as homepage, version, path and summary\.
.SH "OPTIONS"
-.
.TP
\fB\-\-path\fR
Print the path of the given gem
+.TP
+\fB\-\-version\fR
+Print gem version
diff --git a/lib/bundler/man/bundle-info.1.ronn b/lib/bundler/man/bundle-info.1.ronn
index 47e457aa3c..e99db8c614 100644
--- a/lib/bundler/man/bundle-info.1.ronn
+++ b/lib/bundler/man/bundle-info.1.ronn
@@ -1,17 +1,21 @@
bundle-info(1) -- Show information for the given gem in your bundle
-=========================================================================
+===================================================================
## SYNOPSIS
-`bundle info` [GEM]
+`bundle info` [GEM_NAME]
[--path]
+ [--version]
## DESCRIPTION
-Print the basic information about the provided GEM such as homepage, version,
-path and summary.
+Given a gem name present in your bundle, print the basic information about it
+ such as homepage, version, path and summary.
## OPTIONS
* `--path`:
-Print the path of the given gem
+ Print the path of the given gem
+
+* `--version`:
+ Print gem version
diff --git a/lib/bundler/man/bundle-init.1 b/lib/bundler/man/bundle-init.1
index e93b4fd5e9..63e2376c3f 100644
--- a/lib/bundler/man/bundle-init.1
+++ b/lib/bundler/man/bundle-init.1
@@ -1,29 +1,20 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INIT" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-INIT" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-init\fR \- Generates a Gemfile into the current working directory
-.
.SH "SYNOPSIS"
\fBbundle init\fR [\-\-gemspec=FILE]
-.
.SH "DESCRIPTION"
Init generates a default [\fBGemfile(5)\fR][Gemfile(5)] in the current working directory\. When adding a [\fBGemfile(5)\fR][Gemfile(5)] to a gem with a gemspec, the \fB\-\-gemspec\fR option will automatically add each dependency listed in the gemspec file to the newly created [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
.SH "OPTIONS"
-.
.TP
-\fB\-\-gemspec\fR
+\fB\-\-gemspec=GEMSPEC\fR
Use the specified \.gemspec to create the [\fBGemfile(5)\fR][Gemfile(5)]
-.
.TP
-\fB\-\-gemfile\fR
+\fB\-\-gemfile=GEMFILE\fR
Use the specified name for the gemfile instead of \fBGemfile\fR
-.
.SH "FILES"
Included in the default [\fBGemfile(5)\fR][Gemfile(5)] generated is the line \fB# frozen_string_literal: true\fR\. This is a magic comment supported for the first time in Ruby 2\.3\. The presence of this line results in all string literals in the file being implicitly frozen\.
-.
.SH "SEE ALSO"
Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR
diff --git a/lib/bundler/man/bundle-init.1.ronn b/lib/bundler/man/bundle-init.1.ronn
index 7d3cede1f6..ab3c427b52 100644
--- a/lib/bundler/man/bundle-init.1.ronn
+++ b/lib/bundler/man/bundle-init.1.ronn
@@ -14,9 +14,10 @@ created [`Gemfile(5)`][Gemfile(5)].
## OPTIONS
-* `--gemspec`:
+* `--gemspec=GEMSPEC`:
Use the specified .gemspec to create the [`Gemfile(5)`][Gemfile(5)]
-* `--gemfile`:
+
+* `--gemfile=GEMFILE`:
Use the specified name for the gemfile instead of `Gemfile`
## FILES
diff --git a/lib/bundler/man/bundle-inject.1 b/lib/bundler/man/bundle-inject.1
deleted file mode 100644
index 657d5ef4a7..0000000000
--- a/lib/bundler/man/bundle-inject.1
+++ /dev/null
@@ -1,36 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INJECT" "1" "February 2023" "" ""
-.
-.SH "NAME"
-\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle inject\fR [GEM] [VERSION]
-.
-.SH "DESCRIPTION"
-Adds the named gem(s) with their version requirements to the resolved [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
-.P
-This command will add the gem to both your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock if it isn\'t listed yet\.
-.
-.P
-Example:
-.
-.IP "" 4
-.
-.nf
-
-bundle install
-bundle inject \'rack\' \'> 0\'
-.
-.fi
-.
-.IP "" 0
-.
-.P
-This will inject the \'rack\' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock\.
-.
-.P
-The \fBbundle inject\fR command was deprecated in Bundler 2\.1 and will be removed in Bundler 3\.0\.
diff --git a/lib/bundler/man/bundle-inject.1.ronn b/lib/bundler/man/bundle-inject.1.ronn
deleted file mode 100644
index 95704eddad..0000000000
--- a/lib/bundler/man/bundle-inject.1.ronn
+++ /dev/null
@@ -1,24 +0,0 @@
-bundle-inject(1) -- Add named gem(s) with version requirements to Gemfile
-=========================================================================
-
-## SYNOPSIS
-
-`bundle inject` [GEM] [VERSION]
-
-## DESCRIPTION
-
-Adds the named gem(s) with their version requirements to the resolved
-[`Gemfile(5)`][Gemfile(5)].
-
-This command will add the gem to both your [`Gemfile(5)`][Gemfile(5)] and Gemfile.lock if it
-isn't listed yet.
-
-Example:
-
- bundle install
- bundle inject 'rack' '> 0'
-
-This will inject the 'rack' gem with a version greater than 0 in your
-[`Gemfile(5)`][Gemfile(5)] and Gemfile.lock.
-
-The `bundle inject` command was deprecated in Bundler 2.1 and will be removed in Bundler 3.0.
diff --git a/lib/bundler/man/bundle-install.1 b/lib/bundler/man/bundle-install.1
index 8f144692f3..801768c7ec 100644
--- a/lib/bundler/man/bundle-install.1
+++ b/lib/bundler/man/bundle-install.1
@@ -1,313 +1,178 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INSTALL" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-INSTALL" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
-.
.SH "SYNOPSIS"
-\fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-quiet] [\-\-redownload] [\-\-retry=NUMBER] [\-\-shebang] [\-\-standalone[=GROUP[ GROUP\.\.\.]]] [\-\-system] [\-\-trust\-policy=POLICY] [\-\-with=GROUP[ GROUP\.\.\.]] [\-\-without=GROUP[ GROUP\.\.\.]]
-.
+\fBbundle install\fR [\-\-cooldown=NUMBER] [\-\-force] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-lockfile=LOCKFILE] [\-\-no\-cache] [\-\-no\-lock] [\-\-prefer\-local] [\-\-quiet] [\-\-retry=NUMBER] [\-\-standalone[=GROUP[ GROUP\|\.\|\.\|\.]]] [\-\-trust\-policy=TRUST\-POLICY] [\-\-target\-rbconfig=TARGET\-RBCONFIG]
.SH "DESCRIPTION"
Install the gems specified in your Gemfile(5)\. If this is the first time you run bundle install (and a \fBGemfile\.lock\fR does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems\.
-.
.P
If a \fBGemfile\.lock\fR does exist, and you have not updated your Gemfile(5), Bundler will fetch all remote sources, but use the dependencies specified in the \fBGemfile\.lock\fR instead of resolving dependencies\.
-.
.P
If a \fBGemfile\.lock\fR does exist, and you have updated your Gemfile(5), Bundler will use the dependencies in the \fBGemfile\.lock\fR for all gems that you did not update, but will re\-resolve the dependencies of gems that you did update\. You can find more information about this update process below under \fICONSERVATIVE UPDATING\fR\.
-.
.SH "OPTIONS"
-The \fB\-\-clean\fR, \fB\-\-deployment\fR, \fB\-\-frozen\fR, \fB\-\-no\-prune\fR, \fB\-\-path\fR, \fB\-\-shebang\fR, \fB\-\-system\fR, \fB\-\-without\fR and \fB\-\-with\fR options are deprecated because they only make sense if they are applied to every subsequent \fBbundle install\fR run automatically and that requires \fBbundler\fR to silently remember them\. Since \fBbundler\fR will no longer remember CLI flags in future versions, \fBbundle config\fR (see bundle\-config(1)) should be used to apply them permanently\.
-.
.TP
-\fB\-\-binstubs[=<directory>]\fR
-Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it in \fBbin/\fR\. This lets you link the binstub inside of an application to the exact gem version the application needs\.
-.
-.IP
-Creates a directory (defaults to \fB~/bin\fR) and places any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
-.TP
-\fB\-\-clean\fR
-On finishing the installation Bundler is going to remove any gems not present in the current Gemfile(5)\. Don\'t worry, gems currently in use will not be removed\.
-.
-.IP
-This option is deprecated in favor of the \fBclean\fR setting\.
-.
-.TP
-\fB\-\-deployment\fR
-In \fIdeployment mode\fR, Bundler will \'roll\-out\' the bundle for production or CI use\. Please check carefully if you want to have this option enabled in your development environment\.
-.
-.IP
-This option is deprecated in favor of the \fBdeployment\fR setting\.
-.
+\fB\-\-cooldown=<number>\fR
+Only consider gem versions published at least \fInumber\fR days ago when resolving\. Pass \fB0\fR to disable cooldown for this run, overriding any per\-source or global configuration\. See \fBcooldown\fR in bundle\-config(1) for details on the precedence between the CLI flag, Bundler config, and Gemfile per\-source settings\.
.TP
-\fB\-\-redownload\fR
-Force download every gem, even if the required versions are already available locally\.
-.
-.TP
-\fB\-\-frozen\fR
-Do not allow the Gemfile\.lock to be updated after this install\. Exits non\-zero if there are going to be changes to the Gemfile\.lock\.
-.
-.IP
-This option is deprecated in favor of the \fBfrozen\fR setting\.
-.
+\fB\-\-force\fR, \fB\-\-redownload\fR
+Force reinstalling every gem, even if already installed\.
.TP
\fB\-\-full\-index\fR
-Bundler will not call Rubygems\' API endpoint (default) but download and cache a (currently big) index file of all gems\. Performance can be improved for large bundles that seldom change by enabling this option\.
-.
+Bundler will not call Rubygems' API endpoint (default) but download and cache a (currently big) index file of all gems\. Performance can be improved for large bundles that seldom change by enabling this option\.
.TP
-\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
-.
+\fB\-\-gemfile=GEMFILE\fR
+The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project's root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
.TP
-\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
+\fB\-\-jobs=<number>\fR, \fB\-j=<number>\fR
The maximum number of parallel download and install jobs\. The default is the number of available processors\.
-.
.TP
\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if an appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
+Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems' cache or in \fBvendor/cache\fR\. Note that if an appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
+.TP
+\fB\-\-lockfile=LOCKFILE\fR
+The location of the lockfile which Bundler should use\. This defaults to the Gemfile location with \fB\.lock\fR appended\.
.TP
\fB\-\-prefer\-local\fR
-Force using locally installed gems, or gems already present in Rubygems\' cache or in \fBvendor/cache\fR, when resolving, even if newer versions are available remotely\. Only attempt to connect to \fBrubygems\.org\fR for gems that are not present locally\.
-.
+Force using locally installed gems, or gems already present in Rubygems' cache or in \fBvendor/cache\fR, when resolving, even if newer versions are available remotely\. Only attempt to connect to \fBrubygems\.org\fR for gems that are not present locally\.
.TP
\fB\-\-no\-cache\fR
Do not update the cache in \fBvendor/cache\fR with the newly bundled gems\. This does not remove any gems in the cache but keeps the newly bundled gems from being cached during the install\.
-.
-.TP
-\fB\-\-no\-prune\fR
-Don\'t remove stale gems from the cache when the installation finishes\.
-.
-.IP
-This option is deprecated in favor of the \fBno_prune\fR setting\.
-.
.TP
-\fB\-\-path=<path>\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
+\fB\-\-no\-lock\fR
+Do not create a lockfile\. Useful if you want to install dependencies but not lock versions of gems\. Recommended for library development, and other situations where the code is expected to work with a range of dependency versions\.
.IP
-This option is deprecated in favor of the \fBpath\fR setting\.
-.
+This has the same effect as using \fBlockfile false\fR in the Gemfile\. See gemfile(5) for more information\.
.TP
\fB\-\-quiet\fR
-Do not print progress information to the standard output\. Instead, Bundler will exit using a status code (\fB$?\fR)\.
-.
+Do not print progress information to the standard output\.
.TP
\fB\-\-retry=[<number>]\fR
Retry failed network or git requests for \fInumber\fR times\.
-.
-.TP
-\fB\-\-shebang=<ruby\-executable>\fR
-Uses the specified ruby executable (usually \fBruby\fR) to execute the scripts created with \fB\-\-binstubs\fR\. In addition, if you use \fB\-\-binstubs\fR together with \fB\-\-shebang jruby\fR these executables will be changed to execute \fBjruby\fR instead\.
-.
-.IP
-This option is deprecated in favor of the \fBshebang\fR setting\.
-.
.TP
\fB\-\-standalone[=<list>]\fR
-Makes a bundle that can work without depending on Rubygems or Bundler at runtime\. A space separated list of groups to install has to be specified\. Bundler creates a directory named \fBbundle\fR and installs the bundle there\. It also generates a \fBbundle/bundler/setup\.rb\fR file to replace Bundler\'s own setup in the manner required\. Using this option implicitly sets \fBpath\fR, which is a [remembered option][REMEMBERED OPTIONS]\.
-.
+Makes a bundle that can work without depending on Rubygems or Bundler at runtime\. A space separated list of groups to install can be specified\. Bundler creates a directory named \fBbundle\fR and installs the bundle there\. It also generates a \fBbundle/bundler/setup\.rb\fR file to replace Bundler's own setup in the manner required\.
.TP
-\fB\-\-system\fR
-Installs the gems specified in the bundle to the system\'s Rubygems location\. This overrides any previous configuration of \fB\-\-path\fR\.
-.
-.IP
-This option is deprecated in favor of the \fBsystem\fR setting\.
-.
-.TP
-\fB\-\-trust\-policy=[<policy>]\fR
+\fB\-\-trust\-policy=TRUST\-POLICY\fR
Apply the Rubygems security policy \fIpolicy\fR, where policy is one of \fBHighSecurity\fR, \fBMediumSecurity\fR, \fBLowSecurity\fR, \fBAlmostNoSecurity\fR, or \fBNoSecurity\fR\. For more details, please see the Rubygems signing documentation linked below in \fISEE ALSO\fR\.
-.
-.TP
-\fB\-\-with=<list>\fR
-A space\-separated list of groups referencing gems to install\. If an optional group is given it is installed\. If a group is given that is in the remembered list of groups given to \-\-without, it is removed from that list\.
-.
-.IP
-This option is deprecated in favor of the \fBwith\fR setting\.
-.
.TP
-\fB\-\-without=<list>\fR
-A space\-separated list of groups referencing gems to skip during installation\. If a group is given that is in the remembered list of groups given to \-\-with, it is removed from that list\.
-.
-.IP
-This option is deprecated in favor of the \fBwithout\fR setting\.
-.
+\fB\-\-target\-rbconfig=TARGET\-RBCONFIG\fR
+Path to rbconfig\.rb for the deployment target platform\.
.SH "DEPLOYMENT MODE"
-Bundler\'s defaults are optimized for development\. To switch to defaults optimized for deployment and for CI, use the \fB\-\-deployment\fR flag\. Do not activate deployment mode on development machines, as it will cause an error when the Gemfile(5) is modified\.
-.
+Bundler's defaults are optimized for development\. To switch to defaults optimized for deployment and for CI, use the \fBdeployment\fR setting\. Do not activate deployment mode on development machines, as it will cause an error when the Gemfile(5) is modified\.
.IP "1." 4
A \fBGemfile\.lock\fR is required\.
-.
.IP
To ensure that the same versions of the gems you developed with and tested with are also used in deployments, a \fBGemfile\.lock\fR is required\.
-.
.IP
This is mainly to ensure that you remember to check your \fBGemfile\.lock\fR into version control\.
-.
.IP "2." 4
The \fBGemfile\.lock\fR must be up to date
-.
.IP
In development, you can modify your Gemfile(5) and re\-run \fBbundle install\fR to \fIconservatively update\fR your \fBGemfile\.lock\fR snapshot\.
-.
.IP
In deployment, your \fBGemfile\.lock\fR should be up\-to\-date with changes made in your Gemfile(5)\.
-.
.IP "3." 4
Gems are installed to \fBvendor/bundle\fR not your default system location
-.
.IP
-In development, it\'s convenient to share the gems used in your application with other applications and other scripts that run on the system\.
-.
+In development, it's convenient to share the gems used in your application with other applications and other scripts that run on the system\.
.IP
In deployment, isolation is a more important default\. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them\.
-.
.IP
-As a result, \fBbundle install \-\-deployment\fR installs gems to the \fBvendor/bundle\fR directory in the application\. This may be overridden using the \fB\-\-path\fR option\.
-.
+As a result, when \fBdeployment\fR is configured, \fBbundle install\fR installs gems to the \fBvendor/bundle\fR directory in the application\. This may be overridden using the \fBpath\fR setting\.
.IP "" 0
-.
.SH "INSTALLING GROUPS"
By default, \fBbundle install\fR will install all gems in all groups in your Gemfile(5), except those declared for a different platform\.
-.
.P
-However, you can explicitly tell Bundler to skip installing certain groups with the \fB\-\-without\fR option\. This option takes a space\-separated list of groups\.
-.
+However, you can explicitly tell Bundler to skip installing certain groups with the \fBwithout\fR setting\. This setting takes a space\-separated list of groups\.
.P
-While the \fB\-\-without\fR option will skip \fIinstalling\fR the gems in the specified groups, it will still \fIdownload\fR those gems and use them to resolve the dependencies of every gem in your Gemfile(5)\.
-.
+While the \fBwithout\fR setting will skip \fIinstalling\fR the gems in the specified groups, \fBbundle install\fR will still \fIdownload\fR those gems and use them to resolve the dependencies of every gem in your Gemfile(5)\.
.P
This is so that installing a different set of groups on another machine (such as a production server) will not change the gems and versions that you have already developed and tested against\.
-.
.P
\fBBundler offers a rock\-solid guarantee that the third\-party code you are running in development and testing is also the third\-party code you are running in production\. You can choose to exclude some of that code in different environments, but you will never be caught flat\-footed by different versions of third\-party code being used in different environments\.\fR
-.
.P
For a simple illustration, consider the following Gemfile(5):
-.
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'sinatra\'
+gem 'sinatra'
group :production do
- gem \'rack\-perftools\-profiler\'
+ gem 'rack\-perftools\-profiler'
end
-.
.fi
-.
.IP "" 0
-.
.P
In this case, \fBsinatra\fR depends on any version of Rack (\fB>= 1\.0\fR), while \fBrack\-perftools\-profiler\fR depends on 1\.x (\fB~> 1\.0\fR)\.
-.
.P
-When you run \fBbundle install \-\-without production\fR in development, we look at the dependencies of \fBrack\-perftools\-profiler\fR as well\. That way, you do not spend all your time developing against Rack 2\.0, using new APIs unavailable in Rack 1\.x, only to have Bundler switch to Rack 1\.2 when the \fBproduction\fR group \fIis\fR used\.
-.
+When you configure \fBbundle config without production\fR in development, we look at the dependencies of \fBrack\-perftools\-profiler\fR as well\. That way, you do not spend all your time developing against Rack 2\.0, using new APIs unavailable in Rack 1\.x, only to have Bundler switch to Rack 1\.2 when the \fBproduction\fR group \fIis\fR used\.
.P
This should not cause any problems in practice, because we do not attempt to \fBinstall\fR the gems in the excluded groups, and only evaluate as part of the dependency resolution process\.
-.
.P
This also means that you cannot include different versions of the same gem in different groups, because doing so would result in different sets of dependencies used in development and production\. Because of the vagaries of the dependency resolution process, this usually affects more than the gems you list in your Gemfile(5), and can (surprisingly) radically change the gems you are using\.
-.
.SH "THE GEMFILE\.LOCK"
When you run \fBbundle install\fR, Bundler will persist the full names and versions of all gems that you used (including dependencies of the gems specified in the Gemfile(5)) into a file called \fBGemfile\.lock\fR\.
-.
.P
Bundler uses this file in all subsequent calls to \fBbundle install\fR, which guarantees that you always use the same exact code, even as your application moves across machines\.
-.
.P
Because of the way dependency resolution works, even a seemingly small change (for instance, an update to a point\-release of a dependency of a gem in your Gemfile(5)) can result in radically different gems being needed to satisfy all dependencies\.
-.
.P
As a result, you \fBSHOULD\fR check your \fBGemfile\.lock\fR into version control, in both applications and gems\. If you do not, every machine that checks out your repository (including your production server) will resolve all dependencies again, which will result in different versions of third\-party code being used if \fBany\fR of the gems in the Gemfile(5) or any of their dependencies have been updated\.
-.
.P
When Bundler first shipped, the \fBGemfile\.lock\fR was included in the \fB\.gitignore\fR file included with generated gems\. Over time, however, it became clear that this practice forces the pain of broken dependencies onto new contributors, while leaving existing contributors potentially unaware of the problem\. Since \fBbundle install\fR is usually the first step towards a contribution, the pain of broken dependencies would discourage new contributors from contributing\. As a result, we have revised our guidance for gem authors to now recommend checking in the lock for gems\.
-.
.SH "CONSERVATIVE UPDATING"
When you make a change to the Gemfile(5) and then run \fBbundle install\fR, Bundler will update only the gems that you modified\.
-.
.P
In other words, if a gem that you \fBdid not modify\fR worked before you called \fBbundle install\fR, it will continue to use the exact same versions of all dependencies as it used before the update\.
-.
.P
-Let\'s take a look at an example\. Here\'s your original Gemfile(5):
-.
+Let's take a look at an example\. Here's your original Gemfile(5):
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'2\.3\.8\'
-gem \'activemerchant\'
-.
+gem 'actionpack', '2\.3\.8'
+gem 'activemerchant'
.fi
-.
.IP "" 0
-.
.P
In this case, both \fBactionpack\fR and \fBactivemerchant\fR depend on \fBactivesupport\fR\. The \fBactionpack\fR gem depends on \fBactivesupport 2\.3\.8\fR and \fBrack ~> 1\.1\.0\fR, while the \fBactivemerchant\fR gem depends on \fBactivesupport >= 2\.3\.2\fR, \fBbraintree >= 2\.0\.0\fR, and \fBbuilder >= 2\.0\.0\fR\.
-.
.P
When the dependencies are first resolved, Bundler will select \fBactivesupport 2\.3\.8\fR, which satisfies the requirements of both gems in your Gemfile(5)\.
-.
.P
Next, you modify your Gemfile(5) to:
-.
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'3\.0\.0\.rc\'
-gem \'activemerchant\'
-.
+gem 'actionpack', '3\.0\.0\.rc'
+gem 'activemerchant'
.fi
-.
.IP "" 0
-.
.P
The \fBactionpack 3\.0\.0\.rc\fR gem has a number of new dependencies, and updates the \fBactivesupport\fR dependency to \fB= 3\.0\.0\.rc\fR and the \fBrack\fR dependency to \fB~> 1\.2\.1\fR\.
-.
.P
When you run \fBbundle install\fR, Bundler notices that you changed the \fBactionpack\fR gem, but not the \fBactivemerchant\fR gem\. It evaluates the gems currently being used to satisfy its requirements:
-.
.TP
\fBactivesupport 2\.3\.8\fR
also used to satisfy a dependency in \fBactivemerchant\fR, which is not being updated
-.
.TP
\fBrack ~> 1\.1\.0\fR
not currently being used to satisfy another dependency
-.
.P
Because you did not explicitly ask to update \fBactivemerchant\fR, you would not expect it to suddenly stop working after updating \fBactionpack\fR\. However, satisfying the new \fBactivesupport 3\.0\.0\.rc\fR dependency of actionpack requires updating one of its dependencies\.
-.
.P
Even though \fBactivemerchant\fR declares a very loose dependency that theoretically matches \fBactivesupport 3\.0\.0\.rc\fR, Bundler treats gems in your Gemfile(5) that have not changed as an atomic unit together with their dependencies\. In this case, the \fBactivemerchant\fR dependency is treated as \fBactivemerchant 1\.7\.1 + activesupport 2\.3\.8\fR, so \fBbundle install\fR will report that it cannot update \fBactionpack\fR\.
-.
.P
To explicitly update \fBactionpack\fR, including its dependencies which other gems in the Gemfile(5) still depend on, run \fBbundle update actionpack\fR (see \fBbundle update(1)\fR)\.
-.
.P
\fBSummary\fR: In general, after making a change to the Gemfile(5) , you should first try to run \fBbundle install\fR, which will guarantee that no other gem in the Gemfile(5) is impacted by the change\. If that does not work, run bundle update(1) \fIbundle\-update\.1\.html\fR\.
-.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
-Gem install docs \fIhttp://guides\.rubygems\.org/rubygems\-basics/#installing\-gems\fR
-.
+Gem install docs \fIhttps://guides\.rubygems\.org/rubygems\-basics/#installing\-gems\fR
.IP "\(bu" 4
-Rubygems signing docs \fIhttp://guides\.rubygems\.org/security/\fR
-.
+Rubygems signing docs \fIhttps://guides\.rubygems\.org/security/\fR
.IP "" 0
diff --git a/lib/bundler/man/bundle-install.1.ronn b/lib/bundler/man/bundle-install.1.ronn
index be9ed0f974..56fd8bdf42 100644
--- a/lib/bundler/man/bundle-install.1.ronn
+++ b/lib/bundler/man/bundle-install.1.ronn
@@ -3,26 +3,21 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
## SYNOPSIS
-`bundle install` [--binstubs[=DIRECTORY]]
- [--clean]
- [--deployment]
- [--frozen]
+`bundle install` [--cooldown=NUMBER]
+ [--force]
[--full-index]
[--gemfile=GEMFILE]
[--jobs=NUMBER]
[--local]
+ [--lockfile=LOCKFILE]
[--no-cache]
- [--no-prune]
- [--path PATH]
+ [--no-lock]
+ [--prefer-local]
[--quiet]
- [--redownload]
[--retry=NUMBER]
- [--shebang]
[--standalone[=GROUP[ GROUP...]]]
- [--system]
- [--trust-policy=POLICY]
- [--with=GROUP[ GROUP...]]
- [--without=GROUP[ GROUP...]]
+ [--trust-policy=TRUST-POLICY]
+ [--target-rbconfig=TARGET-RBCONFIG]
## DESCRIPTION
@@ -43,63 +38,29 @@ update process below under [CONSERVATIVE UPDATING][].
## OPTIONS
-The `--clean`, `--deployment`, `--frozen`, `--no-prune`, `--path`, `--shebang`,
-`--system`, `--without` and `--with` options are deprecated because they only
-make sense if they are applied to every subsequent `bundle install` run
-automatically and that requires `bundler` to silently remember them. Since
-`bundler` will no longer remember CLI flags in future versions, `bundle config`
-(see bundle-config(1)) should be used to apply them permanently.
+* `--cooldown=<number>`:
+ Only consider gem versions published at least <number> days ago when
+ resolving. Pass `0` to disable cooldown for this run, overriding any
+ per-source or global configuration. See `cooldown` in bundle-config(1)
+ for details on the precedence between the CLI flag, Bundler config,
+ and Gemfile per-source settings.
-* `--binstubs[=<directory>]`:
- Binstubs are scripts that wrap around executables. Bundler creates a small Ruby
- file (a binstub) that loads Bundler, runs the command, and puts it in `bin/`.
- This lets you link the binstub inside of an application to the exact gem
- version the application needs.
-
- Creates a directory (defaults to `~/bin`) and places any executables from the
- gem there. These executables run in Bundler's context. If used, you might add
- this directory to your environment's `PATH` variable. For instance, if the
- `rails` gem comes with a `rails` executable, this flag will create a
- `bin/rails` executable that ensures that all referred dependencies will be
- resolved using the bundled gems.
-
-* `--clean`:
- On finishing the installation Bundler is going to remove any gems not present
- in the current Gemfile(5). Don't worry, gems currently in use will not be
- removed.
-
- This option is deprecated in favor of the `clean` setting.
-
-* `--deployment`:
- In [deployment mode][DEPLOYMENT MODE], Bundler will 'roll-out' the bundle for
- production or CI use. Please check carefully if you want to have this option
- enabled in your development environment.
-
- This option is deprecated in favor of the `deployment` setting.
-
-* `--redownload`:
- Force download every gem, even if the required versions are already available
- locally.
-
-* `--frozen`:
- Do not allow the Gemfile.lock to be updated after this install. Exits
- non-zero if there are going to be changes to the Gemfile.lock.
-
- This option is deprecated in favor of the `frozen` setting.
+* `--force`, `--redownload`:
+ Force reinstalling every gem, even if already installed.
* `--full-index`:
Bundler will not call Rubygems' API endpoint (default) but download and cache
a (currently big) index file of all gems. Performance can be improved for
large bundles that seldom change by enabling this option.
-* `--gemfile=<gemfile>`:
+* `--gemfile=GEMFILE`:
The location of the Gemfile(5) which Bundler should use. This defaults
to a Gemfile(5) in the current working directory. In general, Bundler
will assume that the location of the Gemfile(5) is also the project's
root and will try to find `Gemfile.lock` and `vendor/cache` relative
to this location.
-* `--jobs=[<number>]`, `-j[<number>]`:
+* `--jobs=<number>`, `-j=<number>`:
The maximum number of parallel download and install jobs. The default is the
number of available processors.
@@ -109,6 +70,10 @@ automatically and that requires `bundler` to silently remember them. Since
appropriate platform-specific gem exists on `rubygems.org` it will not be
found.
+* `--lockfile=LOCKFILE`:
+ The location of the lockfile which Bundler should use. This defaults
+ to the Gemfile location with `.lock` appended.
+
* `--prefer-local`:
Force using locally installed gems, or gems already present in Rubygems' cache
or in `vendor/cache`, when resolving, even if newer versions are available
@@ -120,75 +85,42 @@ automatically and that requires `bundler` to silently remember them. Since
does not remove any gems in the cache but keeps the newly bundled gems from
being cached during the install.
-* `--no-prune`:
- Don't remove stale gems from the cache when the installation finishes.
+* `--no-lock`:
+ Do not create a lockfile. Useful if you want to install dependencies but not
+ lock versions of gems. Recommended for library development, and other
+ situations where the code is expected to work with a range of dependency
+ versions.
- This option is deprecated in favor of the `no_prune` setting.
-
-* `--path=<path>`:
- The location to install the specified gems to. This defaults to Rubygems'
- setting. Bundler shares this location with Rubygems, `gem install ...` will
- have gem installed there, too. Therefore, gems installed without a
- `--path ...` setting will show up by calling `gem list`. Accordingly, gems
- installed to other locations will not get listed.
-
- This option is deprecated in favor of the `path` setting.
+ This has the same effect as using `lockfile false` in the Gemfile.
+ See gemfile(5) for more information.
* `--quiet`:
- Do not print progress information to the standard output. Instead, Bundler
- will exit using a status code (`$?`).
+ Do not print progress information to the standard output.
* `--retry=[<number>]`:
Retry failed network or git requests for <number> times.
-* `--shebang=<ruby-executable>`:
- Uses the specified ruby executable (usually `ruby`) to execute the scripts
- created with `--binstubs`. In addition, if you use `--binstubs` together with
- `--shebang jruby` these executables will be changed to execute `jruby`
- instead.
-
- This option is deprecated in favor of the `shebang` setting.
-
* `--standalone[=<list>]`:
Makes a bundle that can work without depending on Rubygems or Bundler at
- runtime. A space separated list of groups to install has to be specified.
+ runtime. A space separated list of groups to install can be specified.
Bundler creates a directory named `bundle` and installs the bundle there. It
also generates a `bundle/bundler/setup.rb` file to replace Bundler's own setup
- in the manner required. Using this option implicitly sets `path`, which is a
- [remembered option][REMEMBERED OPTIONS].
-
-* `--system`:
- Installs the gems specified in the bundle to the system's Rubygems location.
- This overrides any previous configuration of `--path`.
+ in the manner required.
- This option is deprecated in favor of the `system` setting.
-
-* `--trust-policy=[<policy>]`:
+* `--trust-policy=TRUST-POLICY`:
Apply the Rubygems security policy <policy>, where policy is one of
`HighSecurity`, `MediumSecurity`, `LowSecurity`, `AlmostNoSecurity`, or
`NoSecurity`. For more details, please see the Rubygems signing documentation
linked below in [SEE ALSO][].
-* `--with=<list>`:
- A space-separated list of groups referencing gems to install. If an
- optional group is given it is installed. If a group is given that is
- in the remembered list of groups given to --without, it is removed
- from that list.
-
- This option is deprecated in favor of the `with` setting.
-
-* `--without=<list>`:
- A space-separated list of groups referencing gems to skip during installation.
- If a group is given that is in the remembered list of groups given
- to --with, it is removed from that list.
-
- This option is deprecated in favor of the `without` setting.
+* `--target-rbconfig=TARGET-RBCONFIG`:
+ Path to rbconfig.rb for the deployment target platform.
## DEPLOYMENT MODE
Bundler's defaults are optimized for development. To switch to
-defaults optimized for deployment and for CI, use the `--deployment`
-flag. Do not activate deployment mode on development machines, as it
+defaults optimized for deployment and for CI, use the `deployment`
+setting. Do not activate deployment mode on development machines, as it
will cause an error when the Gemfile(5) is modified.
1. A `Gemfile.lock` is required.
@@ -220,9 +152,9 @@ will cause an error when the Gemfile(5) is modified.
gems to the system, or the web server may not have permission to
read them.
- As a result, `bundle install --deployment` installs gems to
- the `vendor/bundle` directory in the application. This may be
- overridden using the `--path` option.
+ As a result, when `deployment` is configured, `bundle install` installs gems
+ to the `vendor/bundle` directory in the application. This may be
+ overridden using the `path` setting.
## INSTALLING GROUPS
@@ -230,12 +162,12 @@ By default, `bundle install` will install all gems in all groups
in your Gemfile(5), except those declared for a different platform.
However, you can explicitly tell Bundler to skip installing
-certain groups with the `--without` option. This option takes
+certain groups with the `without` setting. This setting takes
a space-separated list of groups.
-While the `--without` option will skip _installing_ the gems in the
-specified groups, it will still _download_ those gems and use them to
-resolve the dependencies of every gem in your Gemfile(5).
+While the `without` setting will skip _installing_ the gems in the
+specified groups, `bundle install` will still _download_ those gems and use them
+to resolve the dependencies of every gem in your Gemfile(5).
This is so that installing a different set of groups on another
machine (such as a production server) will not change the
@@ -261,7 +193,7 @@ For a simple illustration, consider the following Gemfile(5):
In this case, `sinatra` depends on any version of Rack (`>= 1.0`), while
`rack-perftools-profiler` depends on 1.x (`~> 1.0`).
-When you run `bundle install --without production` in development, we
+When you configure `bundle config without production` in development, we
look at the dependencies of `rack-perftools-profiler` as well. That way,
you do not spend all your time developing against Rack 2.0, using new
APIs unavailable in Rack 1.x, only to have Bundler switch to Rack 1.2
@@ -378,5 +310,5 @@ does not work, run [bundle update(1)](bundle-update.1.html).
## SEE ALSO
-* [Gem install docs](http://guides.rubygems.org/rubygems-basics/#installing-gems)
-* [Rubygems signing docs](http://guides.rubygems.org/security/)
+* [Gem install docs](https://guides.rubygems.org/rubygems-basics/#installing-gems)
+* [Rubygems signing docs](https://guides.rubygems.org/security/)
diff --git a/lib/bundler/man/bundle-issue.1 b/lib/bundler/man/bundle-issue.1
new file mode 100644
index 0000000000..3af277ef86
--- /dev/null
+++ b/lib/bundler/man/bundle-issue.1
@@ -0,0 +1,45 @@
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-ISSUE" "1" "May 2026" ""
+.SH "NAME"
+\fBbundle\-issue\fR \- Get help reporting Bundler issues
+.SH "SYNOPSIS"
+\fBbundle issue\fR
+.SH "DESCRIPTION"
+Provides guidance on reporting Bundler issues and outputs detailed system information that should be included when filing a bug report\. This command:
+.IP "1." 4
+Displays links to troubleshooting resources
+.IP "2." 4
+Shows instructions for reporting issues
+.IP "3." 4
+Outputs comprehensive environment information needed for debugging
+.IP "" 0
+.P
+The command helps ensure that bug reports include all necessary system details for effective troubleshooting\.
+.SH "OUTPUT"
+The command outputs several sections:
+.IP "\(bu" 4
+Troubleshooting links and resources
+.IP "\(bu" 4
+Link to the GitHub issue template
+.IP "\(bu" 4
+Environment information including: Bundler version and platforms, Ruby version and configuration, RubyGems version and paths, Development tool versions (Git, RVM, rbenv, chruby)
+.IP "\(bu" 4
+Bundler build metadata
+.IP "\(bu" 4
+Current Bundler settings
+.IP "\(bu" 4
+Bundle Doctor output
+.IP "" 0
+.SH "EXAMPLES"
+Get issue reporting information:
+.IP "" 4
+.nf
+$ bundle issue
+.fi
+.IP "" 0
+.SH "SEE ALSO"
+.IP "\(bu" 4
+bundle\-doctor(1)
+.IP "" 0
+
diff --git a/lib/bundler/man/bundle-issue.1.ronn b/lib/bundler/man/bundle-issue.1.ronn
new file mode 100644
index 0000000000..37f676a354
--- /dev/null
+++ b/lib/bundler/man/bundle-issue.1.ronn
@@ -0,0 +1,37 @@
+bundle-issue(1) -- Get help reporting Bundler issues
+====================================================
+
+## SYNOPSIS
+
+`bundle issue`
+
+## DESCRIPTION
+
+Provides guidance on reporting Bundler issues and outputs detailed system information that should be included when filing a bug report. This command:
+
+1. Displays links to troubleshooting resources
+2. Shows instructions for reporting issues
+3. Outputs comprehensive environment information needed for debugging
+
+The command helps ensure that bug reports include all necessary system details for effective troubleshooting.
+
+## OUTPUT
+
+The command outputs several sections:
+
+* Troubleshooting links and resources
+* Link to the GitHub issue template
+* Environment information including: Bundler version and platforms, Ruby version and configuration, RubyGems version and paths, Development tool versions (Git, RVM, rbenv, chruby)
+* Bundler build metadata
+* Current Bundler settings
+* Bundle Doctor output
+
+## EXAMPLES
+
+Get issue reporting information:
+
+ $ bundle issue
+
+## SEE ALSO
+
+* bundle-doctor(1)
diff --git a/lib/bundler/man/bundle-licenses.1 b/lib/bundler/man/bundle-licenses.1
new file mode 100644
index 0000000000..ab5996d2be
--- /dev/null
+++ b/lib/bundler/man/bundle-licenses.1
@@ -0,0 +1,9 @@
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-LICENSES" "1" "May 2026" ""
+.SH "NAME"
+\fBbundle\-licenses\fR \- Print the license of all gems in the bundle
+.SH "SYNOPSIS"
+\fBbundle licenses\fR
+.SH "DESCRIPTION"
+Prints the license of all gems in the bundle\.
diff --git a/lib/bundler/man/bundle-licenses.1.ronn b/lib/bundler/man/bundle-licenses.1.ronn
new file mode 100644
index 0000000000..91caba6c2a
--- /dev/null
+++ b/lib/bundler/man/bundle-licenses.1.ronn
@@ -0,0 +1,10 @@
+bundle-licenses(1) -- Print the license of all gems in the bundle
+=================================================================
+
+## SYNOPSIS
+
+`bundle licenses`
+
+## DESCRIPTION
+
+Prints the license of all gems in the bundle.
diff --git a/lib/bundler/man/bundle-list.1 b/lib/bundler/man/bundle-list.1
index f24f62dd38..e759e0d449 100644
--- a/lib/bundler/man/bundle-list.1
+++ b/lib/bundler/man/bundle-list.1
@@ -1,50 +1,40 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LIST" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-LIST" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-list\fR \- List all the gems in the bundle
-.
.SH "SYNOPSIS"
-\fBbundle list\fR [\-\-name\-only] [\-\-paths] [\-\-without\-group=GROUP[ GROUP\.\.\.]] [\-\-only\-group=GROUP[ GROUP\.\.\.]]
-.
+\fBbundle list\fR [\-\-name\-only] [\-\-paths] [\-\-without\-group=GROUP[ GROUP\|\.\|\.\|\.]] [\-\-only\-group=GROUP[ GROUP\|\.\|\.\|\.]]
.SH "DESCRIPTION"
Prints a list of all the gems in the bundle including their version\.
-.
.P
Example:
-.
.P
bundle list \-\-name\-only
-.
.P
bundle list \-\-paths
-.
.P
bundle list \-\-without\-group test
-.
.P
bundle list \-\-only\-group dev
-.
.P
bundle list \-\-only\-group dev test \-\-paths
-.
+.P
+bundle list \-\-format json
.SH "OPTIONS"
-.
.TP
\fB\-\-name\-only\fR
Print only the name of each gem\.
-.
.TP
\fB\-\-paths\fR
Print the path to each gem in the bundle\.
-.
.TP
\fB\-\-without\-group=<list>\fR
A space\-separated list of groups of gems to skip during printing\.
-.
.TP
\fB\-\-only\-group=<list>\fR
A space\-separated list of groups of gems to print\.
+.TP
+\fB\-\-format=FORMAT\fR
+Format output ('json' is the only supported format)
diff --git a/lib/bundler/man/bundle-list.1.ronn b/lib/bundler/man/bundle-list.1.ronn
index dc058ecd5f..9ec2b13282 100644
--- a/lib/bundler/man/bundle-list.1.ronn
+++ b/lib/bundler/man/bundle-list.1.ronn
@@ -1,5 +1,5 @@
bundle-list(1) -- List all the gems in the bundle
-=========================================================================
+=================================================
## SYNOPSIS
@@ -21,13 +21,21 @@ bundle list --only-group dev
bundle list --only-group dev test --paths
+bundle list --format json
+
## OPTIONS
* `--name-only`:
Print only the name of each gem.
+
* `--paths`:
Print the path to each gem in the bundle.
+
* `--without-group=<list>`:
A space-separated list of groups of gems to skip during printing.
+
* `--only-group=<list>`:
A space-separated list of groups of gems to print.
+
+* `--format=FORMAT`:
+ Format output ('json' is the only supported format)
diff --git a/lib/bundler/man/bundle-lock.1 b/lib/bundler/man/bundle-lock.1
index 55d1035d77..396c8ff6ca 100644
--- a/lib/bundler/man/bundle-lock.1
+++ b/lib/bundler/man/bundle-lock.1
@@ -1,84 +1,75 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LOCK" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-LOCK" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
-.
.SH "SYNOPSIS"
-\fBbundle lock\fR [\-\-update] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-add\-platform] [\-\-remove\-platform] [\-\-patch] [\-\-minor] [\-\-major] [\-\-strict] [\-\-conservative]
-.
+\fBbundle lock\fR [\-\-update] [\-\-bundler[=BUNDLER]] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-add\-checksums] [\-\-add\-platform] [\-\-remove\-platform] [\-\-normalize\-platforms] [\-\-patch] [\-\-minor] [\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative]
.SH "DESCRIPTION"
Lock the gems specified in Gemfile\.
-.
.SH "OPTIONS"
-.
.TP
-\fB\-\-update=<*gems>\fR
+\fB\-\-update[=<list>]\fR
Ignores the existing lockfile\. Resolve then updates lockfile\. Taking a list of gems or updating all gems if no list is given\.
-.
+.TP
+\fB\-\-bundler[=BUNDLER]\fR
+Update the locked version of bundler to the given version or the latest version if no version is given\.
.TP
\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
+Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
.TP
\fB\-\-print\fR
Prints the lockfile to STDOUT instead of writing to the file system\.
-.
.TP
-\fB\-\-lockfile=<path>\fR
+\fB\-\-lockfile=LOCKFILE\fR
The path where the lockfile should be written to\.
-.
.TP
\fB\-\-full\-index\fR
Fall back to using the single\-file index of all gems\.
-.
.TP
-\fB\-\-add\-platform\fR
+\fB\-\-gemfile=GEMFILE\fR
+Use the specified gemfile instead of [\fBGemfile(5)\fR][Gemfile(5)]\.
+.TP
+\fB\-\-add\-checksums\fR
+Add checksums to the lockfile\.
+.TP
+\fB\-\-add\-platform=<list>\fR
Add a new platform to the lockfile, re\-resolving for the addition of that platform\.
-.
.TP
-\fB\-\-remove\-platform\fR
+\fB\-\-remove\-platform=<list>\fR
Remove a platform from the lockfile\.
-.
+.TP
+\fB\-\-normalize\-platforms\fR
+Normalize lockfile platforms\.
.TP
\fB\-\-patch\fR
If updating, prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
If updating, prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
If updating, prefer updating to next major version (default)\.
-.
+.TP
+\fB\-\-pre\fR
+If updating, always choose the highest allowed version, regardless of prerelease status\.
.TP
\fB\-\-strict\fR
If updating, do not allow any gem to be updated past latest \-\-patch | \-\-minor | \-\-major\.
-.
.TP
\fB\-\-conservative\fR
If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated\.
-.
.SH "UPDATING ALL GEMS"
If you run \fBbundle lock\fR with \fB\-\-update\fR option without list of gems, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
.SH "UPDATING A LIST OF GEMS"
Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.P
For instance, you only want to update \fBnokogiri\fR, run \fBbundle lock \-\-update nokogiri\fR\.
-.
.P
Bundler will update \fBnokogiri\fR and any of its dependencies, but leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.SH "SUPPORTING OTHER PLATFORMS"
-If you want your bundle to support platforms other than the one you\'re running locally, you can run \fBbundle lock \-\-add\-platform PLATFORM\fR to add PLATFORM to the lockfile, force bundler to re\-resolve and consider the new platform when picking gems, all without needing to have a machine that matches PLATFORM handy to install those platform\-specific gems on\.
-.
+If you want your bundle to support platforms other than the one you're running locally, you can run \fBbundle lock \-\-add\-platform PLATFORM\fR to add PLATFORM to the lockfile, force bundler to re\-resolve and consider the new platform when picking gems, all without needing to have a machine that matches PLATFORM handy to install those platform\-specific gems on\.
.P
For a full explanation of gem platforms, see \fBgem help platform\fR\.
-.
.SH "PATCH LEVEL OPTIONS"
See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
diff --git a/lib/bundler/man/bundle-lock.1.ronn b/lib/bundler/man/bundle-lock.1.ronn
index 3aa5920f5a..6d3e63c982 100644
--- a/lib/bundler/man/bundle-lock.1.ronn
+++ b/lib/bundler/man/bundle-lock.1.ronn
@@ -4,15 +4,20 @@ bundle-lock(1) -- Creates / Updates a lockfile without installing
## SYNOPSIS
`bundle lock` [--update]
+ [--bundler[=BUNDLER]]
[--local]
[--print]
[--lockfile=PATH]
[--full-index]
+ [--gemfile=GEMFILE]
+ [--add-checksums]
[--add-platform]
[--remove-platform]
+ [--normalize-platforms]
[--patch]
[--minor]
[--major]
+ [--pre]
[--strict]
[--conservative]
@@ -22,10 +27,14 @@ Lock the gems specified in Gemfile.
## OPTIONS
-* `--update=<*gems>`:
+* `--update[=<list>]`:
Ignores the existing lockfile. Resolve then updates lockfile. Taking a list
of gems or updating all gems if no list is given.
+* `--bundler[=BUNDLER]`:
+ Update the locked version of bundler to the given version or the latest
+ version if no version is given.
+
* `--local`:
Do not attempt to connect to `rubygems.org`. Instead, Bundler will use the
gems already present in Rubygems' cache or in `vendor/cache`. Note that if a
@@ -35,19 +44,28 @@ Lock the gems specified in Gemfile.
* `--print`:
Prints the lockfile to STDOUT instead of writing to the file system.
-* `--lockfile=<path>`:
+* `--lockfile=LOCKFILE`:
The path where the lockfile should be written to.
* `--full-index`:
Fall back to using the single-file index of all gems.
-* `--add-platform`:
+* `--gemfile=GEMFILE`:
+ Use the specified gemfile instead of [`Gemfile(5)`][Gemfile(5)].
+
+* `--add-checksums`:
+ Add checksums to the lockfile.
+
+* `--add-platform=<list>`:
Add a new platform to the lockfile, re-resolving for the addition of that
platform.
-* `--remove-platform`:
+* `--remove-platform=<list>`:
Remove a platform from the lockfile.
+* `--normalize-platforms`:
+ Normalize lockfile platforms.
+
* `--patch`:
If updating, prefer updating only to next patch version.
@@ -57,6 +75,9 @@ Lock the gems specified in Gemfile.
* `--major`:
If updating, prefer updating to next major version (default).
+* `--pre`:
+ If updating, always choose the highest allowed version, regardless of prerelease status.
+
* `--strict`:
If updating, do not allow any gem to be updated past latest --patch | --minor | --major.
diff --git a/lib/bundler/man/bundle-open.1 b/lib/bundler/man/bundle-open.1
index ff44d1224f..2aab59f14b 100644
--- a/lib/bundler/man/bundle-open.1
+++ b/lib/bundler/man/bundle-open.1
@@ -1,52 +1,32 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OPEN" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-OPEN" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
-.
.SH "SYNOPSIS"
\fBbundle open\fR [GEM] [\-\-path=PATH]
-.
.SH "DESCRIPTION"
Opens the source directory of the provided GEM in your editor\.
-.
.P
For this to work the \fBEDITOR\fR or \fBBUNDLER_EDITOR\fR environment variable has to be set\.
-.
.P
Example:
-.
.IP "" 4
-.
.nf
-
-bundle open \'rack\'
-.
+bundle open 'rack'
.fi
-.
.IP "" 0
-.
.P
-Will open the source directory for the \'rack\' gem in your bundle\.
-.
+Will open the source directory for the 'rack' gem in your bundle\.
.IP "" 4
-.
.nf
-
-bundle open \'rack\' \-\-path \'README\.md\'
-.
+bundle open 'rack' \-\-path 'README\.md'
.fi
-.
.IP "" 0
-.
.P
-Will open the README\.md file of the \'rack\' gem source in your bundle\.
-.
+Will open the README\.md file of the 'rack' gem source in your bundle\.
.SH "OPTIONS"
-.
.TP
-\fB\-\-path\fR
+\fB\-\-path[=PATH]\fR
Specify GEM source relative path to open\.
diff --git a/lib/bundler/man/bundle-open.1.ronn b/lib/bundler/man/bundle-open.1.ronn
index a857f3a965..24dbe97e44 100644
--- a/lib/bundler/man/bundle-open.1.ronn
+++ b/lib/bundler/man/bundle-open.1.ronn
@@ -23,5 +23,6 @@ Will open the source directory for the 'rack' gem in your bundle.
Will open the README.md file of the 'rack' gem source in your bundle.
## OPTIONS
-* `--path`:
+
+* `--path[=PATH]`:
Specify GEM source relative path to open.
diff --git a/lib/bundler/man/bundle-outdated.1 b/lib/bundler/man/bundle-outdated.1
index 8455b71b45..c2f8086e24 100644
--- a/lib/bundler/man/bundle-outdated.1
+++ b/lib/bundler/man/bundle-outdated.1
@@ -1,148 +1,106 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OUTDATED" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-OUTDATED" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-outdated\fR \- List installed gems with newer versions available
-.
.SH "SYNOPSIS"
-\fBbundle outdated\fR [GEM] [\-\-local] [\-\-pre] [\-\-source] [\-\-strict] [\-\-parseable | \-\-porcelain] [\-\-group=GROUP] [\-\-groups] [\-\-patch|\-\-minor|\-\-major] [\-\-filter\-major] [\-\-filter\-minor] [\-\-filter\-patch] [\-\-only\-explicit]
-.
+\fBbundle outdated\fR [GEM] [\-\-local] [\-\-pre] [\-\-source] [\-\-filter\-strict | \-\-strict] [\-\-update\-strict] [\-\-parseable | \-\-porcelain] [\-\-group=GROUP] [\-\-groups] [\-\-patch|\-\-minor|\-\-major] [\-\-filter\-major] [\-\-filter\-minor] [\-\-filter\-patch] [\-\-only\-explicit] [\-\-cooldown=NUMBER]
.SH "DESCRIPTION"
Outdated lists the names and versions of gems that have a newer version available in the given source\. Calling outdated with [GEM [GEM]] will only check for newer versions of the given gems\. Prerelease gems are ignored by default\. If your gems are up to date, Bundler will exit with a status of 0\. Otherwise, it will exit 1\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-local\fR
Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
.TP
\fB\-\-pre\fR
Check for newer pre\-release gems\.
-.
.TP
-\fB\-\-source\fR
+\fB\-\-source=<list>\fR
Check against a specific source\.
-.
.TP
-\fB\-\-strict\fR
+\fB\-\-filter\-strict\fR, \fB\-\-strict\fR
Only list newer versions allowed by your Gemfile requirements, also respecting conservative update flags (\-\-patch, \-\-minor, \-\-major)\.
-.
+.TP
+\fB\-\-update\-strict\fR
+Strict conservative resolution, do not allow any gem to be updated past latest \-\-patch | \-\-minor | \-\-major\.
.TP
\fB\-\-parseable\fR, \fB\-\-porcelain\fR
Use minimal formatting for more parseable output\.
-.
.TP
-\fB\-\-group\fR
+\fB\-\-group=GROUP\fR
List gems from a specific group\.
-.
.TP
\fB\-\-groups\fR
List gems organized by groups\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-filter\-major\fR
Only list major newer versions\.
-.
.TP
\fB\-\-filter\-minor\fR
Only list minor newer versions\.
-.
.TP
\fB\-\-filter\-patch\fR
Only list patch newer versions\.
-.
.TP
\fB\-\-only\-explicit\fR
Only list gems specified in your Gemfile, not their dependencies\.
-.
+.TP
+\fB\-\-cooldown=<number>\fR
+Annotate (rather than hide) versions that are still inside the cooldown window of \fInumber\fR days\. The prose output appends "in cooldown for Nd more days" and the table form adds "(cooldown Nd)" to the Latest column\. See \fBcooldown\fR in bundle\-config(1)\.
.SH "PATCH LEVEL OPTIONS"
See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
-.
.SH "FILTERING OUTPUT"
The 3 filtering options do not affect the resolution of versions, merely what versions are shown in the output\.
-.
.P
If the regular output shows the following:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups Release Date
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test 2024\-02\-05
+* hashie 1\.2\.0 3\.4\.6 = 1\.2\.0 default 2023\-11\-10
+* headless 2\.2\.3 2\.3\.1 = 2\.2\.3 test 2022\-08\-19
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-major\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-.
+* Gem Current Latest Requested Groups Release Date
+* hashie 1\.2\.0 3\.4\.6 = 1\.2\.0 default 2023\-11\-10
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-minor\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups Release Date
+* headless 2\.2\.3 2\.3\.1 = 2\.2\.3 test 2022\-08\-19
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-patch\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-.
+* Gem Current Latest Requested Groups Release Date
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test 2024\-02\-05
.fi
-.
.IP "" 0
-.
.P
Filter options can be combined\. \fB\-\-filter\-minor\fR and \fB\-\-filter\-patch\fR would show:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups Release Date
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test 2024\-02\-05
.fi
-.
.IP "" 0
-.
.P
Combining all three \fBfilter\fR options would be the same result as providing none of them\.
diff --git a/lib/bundler/man/bundle-outdated.1.ronn b/lib/bundler/man/bundle-outdated.1.ronn
index 04096ffbb6..e5badac2e9 100644
--- a/lib/bundler/man/bundle-outdated.1.ronn
+++ b/lib/bundler/man/bundle-outdated.1.ronn
@@ -6,7 +6,8 @@ bundle-outdated(1) -- List installed gems with newer versions available
`bundle outdated` [GEM] [--local]
[--pre]
[--source]
- [--strict]
+ [--filter-strict | --strict]
+ [--update-strict]
[--parseable | --porcelain]
[--group=GROUP]
[--groups]
@@ -15,6 +16,7 @@ bundle-outdated(1) -- List installed gems with newer versions available
[--filter-minor]
[--filter-patch]
[--only-explicit]
+ [--cooldown=NUMBER]
## DESCRIPTION
@@ -31,16 +33,19 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
* `--pre`:
Check for newer pre-release gems.
-* `--source`:
+* `--source=<list>`:
Check against a specific source.
-* `--strict`:
+* `--filter-strict`, `--strict`:
Only list newer versions allowed by your Gemfile requirements, also respecting conservative update flags (--patch, --minor, --major).
+* `--update-strict`:
+ Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major.
+
* `--parseable`, `--porcelain`:
Use minimal formatting for more parseable output.
-* `--group`:
+* `--group=GROUP`:
List gems from a specific group.
* `--groups`:
@@ -67,6 +72,12 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
* `--only-explicit`:
Only list gems specified in your Gemfile, not their dependencies.
+* `--cooldown=<number>`:
+ Annotate (rather than hide) versions that are still inside the
+ cooldown window of <number> days. The prose output appends "in
+ cooldown for Nd more days" and the table form adds "(cooldown Nd)" to
+ the Latest column. See `cooldown` in bundle-config(1).
+
## PATCH LEVEL OPTIONS
See [bundle update(1)](bundle-update.1.html) for details.
@@ -78,25 +89,29 @@ in the output.
If the regular output shows the following:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups Release Date
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test 2024-02-05
+ * hashie 1.2.0 3.4.6 = 1.2.0 default 2023-11-10
+ * headless 2.2.3 2.3.1 = 2.2.3 test 2022-08-19
`--filter-major` would only show:
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
+ * Gem Current Latest Requested Groups Release Date
+ * hashie 1.2.0 3.4.6 = 1.2.0 default 2023-11-10
`--filter-minor` would only show:
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups Release Date
+ * headless 2.2.3 2.3.1 = 2.2.3 test 2022-08-19
`--filter-patch` would only show:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
+ * Gem Current Latest Requested Groups Release Date
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test 2024-02-05
Filter options can be combined. `--filter-minor` and `--filter-patch` would show:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups Release Date
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test 2024-02-05
Combining all three `filter` options would be the same result as providing none of them.
diff --git a/lib/bundler/man/bundle-platform.1 b/lib/bundler/man/bundle-platform.1
index 2794878719..39b7111263 100644
--- a/lib/bundler/man/bundle-platform.1
+++ b/lib/bundler/man/bundle-platform.1
@@ -1,41 +1,27 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PLATFORM" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-PLATFORM" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-platform\fR \- Displays platform compatibility information
-.
.SH "SYNOPSIS"
\fBbundle platform\fR [\-\-ruby]
-.
.SH "DESCRIPTION"
\fBplatform\fR displays information from your Gemfile, Gemfile\.lock, and Ruby VM about your platform\.
-.
.P
For instance, using this Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
ruby "3\.1\.2"
gem "rack"
-.
.fi
-.
.IP "" 0
-.
.P
If you run \fBbundle platform\fR on Ruby 3\.1\.2, it displays the following output:
-.
.IP "" 4
-.
.nf
-
Your platform is: x86_64\-linux
Your app has gems that work on these platforms:
@@ -48,24 +34,16 @@ Your Gemfile specifies a Ruby version requirement:
* ruby 3\.1\.2
Your current platform satisfies the Ruby version requirement\.
-.
.fi
-.
.IP "" 0
-.
.P
-\fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn\'t match the running Ruby VM, it tells you what part does not\.
-.
+\fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn't match the running Ruby VM, it tells you what part does not\.
.SH "OPTIONS"
-.
.TP
\fB\-\-ruby\fR
-It will display the ruby directive information, so you don\'t have to parse it from the Gemfile(5)\.
-.
+It will display the ruby directive information, so you don't have to parse it from the Gemfile(5)\.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
bundle\-lock(1) \fIbundle\-lock\.1\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-plugin.1 b/lib/bundler/man/bundle-plugin.1
index 39d3dfa04e..d182c7789b 100644
--- a/lib/bundler/man/bundle-plugin.1
+++ b/lib/bundler/man/bundle-plugin.1
@@ -1,81 +1,76 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PLUGIN" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-PLUGIN" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-plugin\fR \- Manage Bundler plugins
-.
.SH "SYNOPSIS"
-\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git|\-\-local_git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR]
-.
+\fBbundle plugin\fR install PLUGINS [\-\-source=SOURCE] [\-\-version=VERSION] [\-\-git=GIT] [\-\-branch=BRANCH|\-\-ref=REF] [\-\-path=PATH]
.br
-\fBbundle plugin\fR uninstall PLUGINS
-.
+\fBbundle plugin\fR uninstall PLUGINS [\-\-all]
.br
\fBbundle plugin\fR list
-.
.br
\fBbundle plugin\fR help [COMMAND]
-.
.SH "DESCRIPTION"
You can install, uninstall, and list plugin(s) with this command to extend functionalities of Bundler\.
-.
.SH "SUB\-COMMANDS"
-.
.SS "install"
Install the given plugin(s)\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph\fR: Install bundler\-graph gem from RubyGems\.org\. The global source, specified in source in Gemfile is ignored\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-source https://example\.com\fR: Install bundler\-graph gem from example\.com\. The global source, specified in source in Gemfile is not considered\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-version 0\.2\.1\fR: You can specify the version of the gem via \fB\-\-version\fR\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR: Install bundler\-graph gem from Git repository\. \fB\-\-git\fR can be replaced with \fB\-\-local\-git\fR\. You cannot use both \fB\-\-git\fR and \fB\-\-local\-git\fR\. You can use standard Git URLs like:
-.
-.IP "\(bu" 4
+.P
+For example, \fBbundle plugin install bundler\-graph\fR will install bundler\-graph gem from globally configured sources (defaults to RubyGems\.org)\. Note that the global source specified in Gemfile is ignored\.
+.P
+\fBOPTIONS\fR
+.TP
+\fB\-\-source=SOURCE\fR
+Install the plugin gem from a specific source, rather than from globally configured sources\.
+.IP
+Example: \fBbundle plugin install bundler\-graph \-\-source https://example\.com\fR
+.TP
+\fB\-\-version=VERSION\fR
+Specify a version of the plugin gem to install via \fB\-\-version\fR\.
+.IP
+Example: \fBbundle plugin install bundler\-graph \-\-version 0\.2\.1\fR
+.TP
+\fB\-\-git=GIT\fR
+Install the plugin gem from a Git repository\. You can use standard Git URLs like:
+.IP
\fBssh://[user@]host\.xz[:port]/path/to/repo\.git\fR
-.
-.IP "\(bu" 4
+.br
\fBhttp[s]://host\.xz[:port]/path/to/repo\.git\fR
-.
-.IP "\(bu" 4
+.br
\fB/path/to/repo\fR
-.
-.IP "\(bu" 4
+.br
\fBfile:///path/to/repo\fR
-.
-.IP "" 0
-.
.IP
-When you specify \fB\-\-git\fR/\fB\-\-local\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\.
-.
-.IP "" 0
-.
+Example: \fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR
+.TP
+\fB\-\-branch=BRANCH\fR
+When you specify \fB\-\-git\fR, you can use \fB\-\-branch\fR to use\.
+.TP
+\fB\-\-ref=REF\fR
+When you specify \fB\-\-git\fR, you can use \fB\-\-ref\fR to specify any tag, or commit hash (revision) to use\.
+.TP
+\fB\-\-path=PATH\fR
+Install the plugin gem from a local path\.
+.IP
+Example: \fBbundle plugin install bundler\-graph \-\-path \.\./bundler\-graph\fR
.SS "uninstall"
Uninstall the plugin(s) specified in PLUGINS\.
-.
+.P
+\fBOPTIONS\fR
+.TP
+\fB\-\-all\fR
+Uninstall all the installed plugins\. If no plugin is installed, then it does nothing\.
.SS "list"
List the installed plugins and available commands\.
-.
.P
No options\.
-.
.SS "help"
Describe subcommands or one specific subcommand\.
-.
.P
No options\.
-.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
How to write a Bundler plugin \fIhttps://bundler\.io/guides/bundler_plugins\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-plugin.1.ronn b/lib/bundler/man/bundle-plugin.1.ronn
index 4f234eeba7..b54e0c08b4 100644
--- a/lib/bundler/man/bundle-plugin.1.ronn
+++ b/lib/bundler/man/bundle-plugin.1.ronn
@@ -3,9 +3,10 @@ bundle-plugin(1) -- Manage Bundler plugins
## SYNOPSIS
-`bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>]
- [--git|--local_git=<git-url>] [--branch=<branch>|--ref=<rev>]<br>
-`bundle plugin` uninstall PLUGINS<br>
+`bundle plugin` install PLUGINS [--source=SOURCE] [--version=VERSION]
+ [--git=GIT] [--branch=BRANCH|--ref=REF]
+ [--path=PATH]<br>
+`bundle plugin` uninstall PLUGINS [--all]<br>
`bundle plugin` list<br>
`bundle plugin` help [COMMAND]
@@ -19,29 +20,53 @@ You can install, uninstall, and list plugin(s) with this command to extend funct
Install the given plugin(s).
-* `bundle plugin install bundler-graph`:
- Install bundler-graph gem from RubyGems.org. The global source, specified in source in Gemfile is ignored.
+For example, `bundle plugin install bundler-graph` will install bundler-graph
+gem from globally configured sources (defaults to RubyGems.org). Note that the
+global source specified in Gemfile is ignored.
-* `bundle plugin install bundler-graph --source https://example.com`:
- Install bundler-graph gem from example.com. The global source, specified in source in Gemfile is not considered.
+**OPTIONS**
-* `bundle plugin install bundler-graph --version 0.2.1`:
- You can specify the version of the gem via `--version`.
+* `--source=SOURCE`:
+ Install the plugin gem from a specific source, rather than from globally configured sources.
-* `bundle plugin install bundler-graph --git https://github.com/rubygems/bundler-graph`:
- Install bundler-graph gem from Git repository. `--git` can be replaced with `--local-git`. You cannot use both `--git` and `--local-git`. You can use standard Git URLs like:
+ Example: `bundle plugin install bundler-graph --source https://example.com`
- * `ssh://[user@]host.xz[:port]/path/to/repo.git`
- * `http[s]://host.xz[:port]/path/to/repo.git`
- * `/path/to/repo`
- * `file:///path/to/repo`
+* `--version=VERSION`:
+ Specify a version of the plugin gem to install via `--version`.
- When you specify `--git`/`--local-git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used.
+ Example: `bundle plugin install bundler-graph --version 0.2.1`
+
+* `--git=GIT`:
+ Install the plugin gem from a Git repository. You can use standard Git URLs like:
+
+ `ssh://[user@]host.xz[:port]/path/to/repo.git`<br>
+ `http[s]://host.xz[:port]/path/to/repo.git`<br>
+ `/path/to/repo`<br>
+ `file:///path/to/repo`
+
+ Example: `bundle plugin install bundler-graph --git https://github.com/rubygems/bundler-graph`
+
+* `--branch=BRANCH`:
+ When you specify `--git`, you can use `--branch` to use.
+
+* `--ref=REF`:
+ When you specify `--git`, you can use `--ref` to specify any tag, or commit
+ hash (revision) to use.
+
+* `--path=PATH`:
+ Install the plugin gem from a local path.
+
+ Example: `bundle plugin install bundler-graph --path ../bundler-graph`
### uninstall
Uninstall the plugin(s) specified in PLUGINS.
+**OPTIONS**
+
+* `--all`:
+ Uninstall all the installed plugins. If no plugin is installed, then it does nothing.
+
### list
List the installed plugins and available commands.
diff --git a/lib/bundler/man/bundle-pristine.1 b/lib/bundler/man/bundle-pristine.1
index f42c7ce156..f6cc066571 100644
--- a/lib/bundler/man/bundle-pristine.1
+++ b/lib/bundler/man/bundle-pristine.1
@@ -1,34 +1,23 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PRISTINE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-PRISTINE" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
-.
.SH "SYNOPSIS"
\fBbundle pristine\fR
-.
.SH "DESCRIPTION"
\fBpristine\fR restores the installed gems in the bundle to their pristine condition using the local gem cache from RubyGems\. For git gems, a forced checkout will be performed\.
-.
.P
-For further explanation, \fBbundle pristine\fR ignores unpacked files on disk\. In other words, this command utilizes the local \fB\.gem\fR cache or the gem\'s git repository as if one were installing from scratch\.
-.
+For further explanation, \fBbundle pristine\fR ignores unpacked files on disk\. In other words, this command utilizes the local \fB\.gem\fR cache or the gem's git repository as if one were installing from scratch\.
.P
-Note: the Bundler gem cannot be restored to its original state with \fBpristine\fR\. One also cannot use \fBbundle pristine\fR on gems with a \'path\' option in the Gemfile, because bundler has no original copy it can restore from\.
-.
+Note: the Bundler gem cannot be restored to its original state with \fBpristine\fR\. One also cannot use \fBbundle pristine\fR on gems with a 'path' option in the Gemfile, because bundler has no original copy it can restore from\.
.P
When is it practical to use \fBbundle pristine\fR?
-.
.P
It comes in handy when a developer is debugging a gem\. \fBbundle pristine\fR is a great way to get rid of experimental changes to a gem that one may not want\.
-.
.P
Why use \fBbundle pristine\fR over \fBgem pristine \-\-all\fR?
-.
.P
Both commands are very similar\. For context: \fBbundle pristine\fR, without arguments, cleans all gems from the lockfile\. Meanwhile, \fBgem pristine \-\-all\fR cleans all installed gems for that Ruby version\.
-.
.P
If a developer forgets which gems in their project they might have been debugging, the Rubygems \fBgem pristine [GEMNAME]\fR command may be inconvenient\. One can avoid waiting for \fBgem pristine \-\-all\fR, and instead run \fBbundle pristine\fR\.
diff --git a/lib/bundler/man/bundle-pristine.1.ronn b/lib/bundler/man/bundle-pristine.1.ronn
index e2d6b6a348..984debeb3d 100644
--- a/lib/bundler/man/bundle-pristine.1.ronn
+++ b/lib/bundler/man/bundle-pristine.1.ronn
@@ -1,5 +1,5 @@
bundle-pristine(1) -- Restores installed gems to their pristine condition
-===========================================================================
+=========================================================================
## SYNOPSIS
diff --git a/lib/bundler/man/bundle-remove.1 b/lib/bundler/man/bundle-remove.1
index b18d80554d..2ca40e74db 100644
--- a/lib/bundler/man/bundle-remove.1
+++ b/lib/bundler/man/bundle-remove.1
@@ -1,31 +1,15 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-REMOVE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-REMOVE" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-remove\fR \- Removes gems from the Gemfile
-.
.SH "SYNOPSIS"
-\fBbundle remove [GEM [GEM \.\.\.]] [\-\-install]\fR
-.
+`bundle remove [GEM [GEM \|\.\|\.\|\.]]
.SH "DESCRIPTION"
Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid\. If a gem cannot be removed, a warning is printed\. If a gem is already absent from the Gemfile, and error is raised\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-install\fR
-Runs \fBbundle install\fR after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s)\.
-.
.P
Example:
-.
.P
bundle remove rails
-.
.P
bundle remove rails rack
-.
-.P
-bundle remove rails rack \-\-install
diff --git a/lib/bundler/man/bundle-remove.1.ronn b/lib/bundler/man/bundle-remove.1.ronn
index 40a239b4a2..49cb4dc1fd 100644
--- a/lib/bundler/man/bundle-remove.1.ronn
+++ b/lib/bundler/man/bundle-remove.1.ronn
@@ -1,23 +1,16 @@
bundle-remove(1) -- Removes gems from the Gemfile
-===========================================================================
+=================================================
## SYNOPSIS
-`bundle remove [GEM [GEM ...]] [--install]`
+`bundle remove [GEM [GEM ...]]
## DESCRIPTION
Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If a gem cannot be removed, a warning is printed. If a gem is already absent from the Gemfile, and error is raised.
-## OPTIONS
-
-* `--install`:
- Runs `bundle install` after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s).
-
Example:
bundle remove rails
bundle remove rails rack
-
-bundle remove rails rack --install
diff --git a/lib/bundler/man/bundle-show.1 b/lib/bundler/man/bundle-show.1
index efd9ccb0e0..a2142694b8 100644
--- a/lib/bundler/man/bundle-show.1
+++ b/lib/bundler/man/bundle-show.1
@@ -1,22 +1,15 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-SHOW" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-SHOW" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
-.
.SH "SYNOPSIS"
\fBbundle show\fR [GEM] [\-\-paths]
-.
.SH "DESCRIPTION"
Without the [GEM] option, \fBshow\fR will print a list of the names and versions of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by name\.
-.
.P
Calling show with [GEM] will list the exact location of that gem on your machine\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-paths\fR
List the paths of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by gem name\.
diff --git a/lib/bundler/man/bundle-update.1 b/lib/bundler/man/bundle-update.1
index c67c44ff86..94161083fc 100644
--- a/lib/bundler/man/bundle-update.1
+++ b/lib/bundler/man/bundle-update.1
@@ -1,114 +1,90 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-UPDATE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-UPDATE" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-update\fR \- Update your gems to the latest available versions
-.
.SH "SYNOPSIS"
-\fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-full\-index] [\-\-jobs=JOBS] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-redownload] [\-\-strict] [\-\-conservative]
-.
+\fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-cooldown=NUMBER] [\-\-force] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative]
.SH "DESCRIPTION"
Update the gems specified (all gems, if \fB\-\-all\fR flag is used), ignoring the previously installed gems specified in the \fBGemfile\.lock\fR\. In general, you should use bundle install(1) \fIbundle\-install\.1\.html\fR to install the same exact gems and versions across machines\.
-.
.P
You would use \fBbundle update\fR to explicitly update the version of a gem\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-all\fR
Update all gems specified in Gemfile\.
-.
.TP
-\fB\-\-group=<name>\fR, \fB\-g=[<name>]\fR
+\fB\-\-group=<list>\fR, \fB\-g=<list>\fR
Only update the gems in the specified group\. For instance, you can update all gems in the development group with \fBbundle update \-\-group development\fR\. You can also call \fBbundle update rails \-\-group test\fR to update the rails gem and all gems in the test group, for example\.
-.
.TP
-\fB\-\-source=<name>\fR
+\fB\-\-source=<list>\fR
The name of a \fB:git\fR or \fB:path\fR source used in the Gemfile(5)\. For instance, with a \fB:git\fR source of \fBhttp://github\.com/rails/rails\.git\fR, you would call \fBbundle update \-\-source rails\fR
-.
.TP
\fB\-\-local\fR
Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
.TP
\fB\-\-ruby\fR
Update the locked version of Ruby to the current version of Ruby\.
-.
.TP
-\fB\-\-bundler\fR
+\fB\-\-bundler[=BUNDLER]\fR
Update the locked version of bundler to the invoked bundler version\.
-.
+.TP
+\fB\-\-force\fR, \fB\-\-redownload\fR
+Force reinstalling every gem, even if already installed\.
.TP
\fB\-\-full\-index\fR
Fall back to using the single\-file index of all gems\.
-.
.TP
-\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
+\fB\-\-gemfile=GEMFILE\fR
+Use the specified gemfile instead of [\fBGemfile(5)\fR][Gemfile(5)]\.
+.TP
+\fB\-\-jobs=<number>\fR, \fB\-j=<number>\fR
Specify the number of jobs to run in parallel\. The default is the number of available processors\.
-.
.TP
\fB\-\-retry=[<number>]\fR
Retry failed network or git requests for \fInumber\fR times\.
-.
.TP
\fB\-\-quiet\fR
Only output warnings and errors\.
-.
-.TP
-\fB\-\-redownload\fR
-Force downloading every gem\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
+.TP
+\fB\-\-pre\fR
+Always choose the highest allowed version, regardless of prerelease status\.
.TP
\fB\-\-strict\fR
Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
.TP
\fB\-\-conservative\fR
Use bundle install conservative update behavior and do not allow indirect dependencies to be updated\.
-.
+.TP
+\fB\-\-cooldown=<number>\fR
+Only consider gem versions published at least \fInumber\fR days ago when resolving\. Pass \fB0\fR to disable cooldown for this run, overriding any per\-source or global configuration\. Combine with \fB\-\-conservative\fR to minimize transitive churn when bypassing cooldown for an urgent update\. See \fBcooldown\fR in bundle\-config(1)\.
.SH "UPDATING ALL GEMS"
If you run \fBbundle update \-\-all\fR, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
.P
Consider the following Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "rails", "3\.0\.0\.rc"
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.P
When you run bundle install(1) \fIbundle\-install\.1\.html\fR the first time, bundler will resolve all of the dependencies, all the way down, and install what you need:
-.
.IP "" 4
-.
.nf
-
-Fetching gem metadata from https://rubygems\.org/\.\.\.\.\.\.\.\.\.
-Resolving dependencies\.\.\.
+Fetching gem metadata from https://rubygems\.org/\|\.\|\.\|\.\|\.\|\.\|\.\|\.\|\.\|\.
+Resolving dependencies\|\.\|\.\|\.
Installing builder 2\.1\.2
Installing abstract 1\.0\.0
Installing rack 1\.2\.8
@@ -138,55 +114,36 @@ Installing nokogiri 1\.6\.5
Bundle complete! 2 Gemfile dependencies, 26 gems total\.
Use `bundle show [gemname]` to see where a bundled gem is installed\.
-.
.fi
-.
.IP "" 0
-.
.P
As you can see, even though you have two gems in the Gemfile(5), your application needs 26 different gems in order to run\. Bundler remembers the exact versions it installed in \fBGemfile\.lock\fR\. The next time you run bundle install(1) \fIbundle\-install\.1\.html\fR, bundler skips the dependency resolution and installs the same gems as it installed last time\.
-.
.P
-After checking in the \fBGemfile\.lock\fR into version control and cloning it on another machine, running bundle install(1) \fIbundle\-install\.1\.html\fR will \fIstill\fR install the gems that you installed last time\. You don\'t need to worry that a new release of \fBerubis\fR or \fBmail\fR changes the gems you use\.
-.
+After checking in the \fBGemfile\.lock\fR into version control and cloning it on another machine, running bundle install(1) \fIbundle\-install\.1\.html\fR will \fIstill\fR install the gems that you installed last time\. You don't need to worry that a new release of \fBerubis\fR or \fBmail\fR changes the gems you use\.
.P
However, from time to time, you might want to update the gems you are using to the newest versions that still match the gems in your Gemfile(5)\.
-.
.P
To do this, run \fBbundle update \-\-all\fR, which will ignore the \fBGemfile\.lock\fR, and resolve all the dependencies again\. Keep in mind that this process can result in a significantly different set of the 25 gems, based on the requirements of new gems that the gem authors released since the last time you ran \fBbundle update \-\-all\fR\.
-.
.SH "UPDATING A LIST OF GEMS"
Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.P
For instance, in the scenario above, imagine that \fBnokogiri\fR releases version \fB1\.4\.4\fR, and you want to update it \fIwithout\fR updating Rails and all of its dependencies\. To do this, run \fBbundle update nokogiri\fR\.
-.
.P
Bundler will update \fBnokogiri\fR and any of its dependencies, but leave alone Rails and its dependencies\.
-.
.SH "OVERLAPPING DEPENDENCIES"
Sometimes, multiple gems declared in your Gemfile(5) are satisfied by the same second\-level dependency\. For instance, consider the case of \fBthin\fR and \fBrack\-perftools\-profiler\fR\.
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "thin"
gem "rack\-perftools\-profiler"
-.
.fi
-.
.IP "" 0
-.
.P
The \fBthin\fR gem depends on \fBrack >= 1\.0\fR, while \fBrack\-perftools\-profiler\fR depends on \fBrack ~> 1\.0\fR\. If you run bundle install, you get:
-.
.IP "" 4
-.
.nf
-
Fetching source index for https://rubygems\.org/
Installing daemons (1\.1\.0)
Installing eventmachine (0\.12\.10) with native extensions
@@ -196,199 +153,132 @@ Installing rack (1\.2\.1)
Installing rack\-perftools_profiler (0\.0\.2)
Installing thin (1\.2\.7) with native extensions
Using bundler (1\.0\.0\.rc\.3)
-.
.fi
-.
.IP "" 0
-.
.P
-In this case, the two gems have their own set of dependencies, but they share \fBrack\fR in common\. If you run \fBbundle update thin\fR, bundler will update \fBdaemons\fR, \fBeventmachine\fR and \fBrack\fR, which are dependencies of \fBthin\fR, but not \fBopen4\fR or \fBperftools\.rb\fR, which are dependencies of \fBrack\-perftools_profiler\fR\. Note that \fBbundle update thin\fR will update \fBrack\fR even though it\'s \fIalso\fR a dependency of \fBrack\-perftools_profiler\fR\.
-.
+In this case, the two gems have their own set of dependencies, but they share \fBrack\fR in common\. If you run \fBbundle update thin\fR, bundler will update \fBdaemons\fR, \fBeventmachine\fR and \fBrack\fR, which are dependencies of \fBthin\fR, but not \fBopen4\fR or \fBperftools\.rb\fR, which are dependencies of \fBrack\-perftools_profiler\fR\. Note that \fBbundle update thin\fR will update \fBrack\fR even though it's \fIalso\fR a dependency of \fBrack\-perftools_profiler\fR\.
.P
In short, by default, when you update a gem using \fBbundle update\fR, bundler will update all dependencies of that gem, including those that are also dependencies of another gem\.
-.
.P
To prevent updating indirect dependencies, prior to version 1\.14 the only option was the \fBCONSERVATIVE UPDATING\fR behavior in bundle install(1) \fIbundle\-install\.1\.html\fR:
-.
.P
In this scenario, updating the \fBthin\fR version manually in the Gemfile(5), and then running bundle install(1) \fIbundle\-install\.1\.html\fR will only update \fBdaemons\fR and \fBeventmachine\fR, but not \fBrack\fR\. For more information, see the \fBCONSERVATIVE UPDATING\fR section of bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
.P
Starting with 1\.14, specifying the \fB\-\-conservative\fR option will also prevent indirect dependencies from being updated\.
-.
.SH "PATCH LEVEL OPTIONS"
Version 1\.14 introduced 4 patch\-level options that will influence how gem versions are resolved\. One of the following options can be used: \fB\-\-patch\fR, \fB\-\-minor\fR or \fB\-\-major\fR\. \fB\-\-strict\fR can be added to further influence resolution\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
.TP
\fB\-\-strict\fR
Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
.P
-When Bundler is resolving what versions to use to satisfy declared requirements in the Gemfile or in parent gems, it looks up all available versions, filters out any versions that don\'t satisfy the requirement, and then, by default, sorts them from newest to oldest, considering them in that order\.
-.
+When Bundler is resolving what versions to use to satisfy declared requirements in the Gemfile or in parent gems, it looks up all available versions, filters out any versions that don't satisfy the requirement, and then, by default, sorts them from newest to oldest, considering them in that order\.
.P
Providing one of the patch level options (e\.g\. \fB\-\-patch\fR) changes the sort order of the satisfying versions, causing Bundler to consider the latest \fB\-\-patch\fR or \fB\-\-minor\fR version available before other versions\. Note that versions outside the stated patch level could still be resolved to if necessary to find a suitable dependency graph\.
-.
.P
-For example, if gem \'foo\' is locked at 1\.0\.2, with no gem requirement defined in the Gemfile, and versions 1\.0\.3, 1\.0\.4, 1\.1\.0, 1\.1\.1, 2\.0\.0 all exist, the default order of preference by default (\fB\-\-major\fR) will be "2\.0\.0, 1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
+For example, if gem 'foo' is locked at 1\.0\.2, with no gem requirement defined in the Gemfile, and versions 1\.0\.3, 1\.0\.4, 1\.1\.0, 1\.1\.1, 2\.0\.0 all exist, the default order of preference by default (\fB\-\-major\fR) will be "2\.0\.0, 1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
.P
If the \fB\-\-patch\fR option is used, the order of preference will change to "1\.0\.4, 1\.0\.3, 1\.0\.2, 1\.1\.1, 1\.1\.0, 2\.0\.0"\.
-.
.P
If the \fB\-\-minor\fR option is used, the order of preference will change to "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2, 2\.0\.0"\.
-.
.P
Combining the \fB\-\-strict\fR option with any of the patch level options will remove any versions beyond the scope of the patch level option, to ensure that no gem is updated that far\.
-.
.P
To continue the previous example, if both \fB\-\-patch\fR and \fB\-\-strict\fR options are used, the available versions for resolution would be "1\.0\.4, 1\.0\.3, 1\.0\.2"\. If \fB\-\-minor\fR and \fB\-\-strict\fR are used, it would be "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
.P
-Gem requirements as defined in the Gemfile will still be the first determining factor for what versions are available\. If the gem requirement for \fBfoo\fR in the Gemfile is \'~> 1\.0\', that will accomplish the same thing as providing the \fB\-\-minor\fR and \fB\-\-strict\fR options\.
-.
+Gem requirements as defined in the Gemfile will still be the first determining factor for what versions are available\. If the gem requirement for \fBfoo\fR in the Gemfile is '~> 1\.0', that will accomplish the same thing as providing the \fB\-\-minor\fR and \fB\-\-strict\fR options\.
.SH "PATCH LEVEL EXAMPLES"
Given the following gem specifications:
-.
.IP "" 4
-.
.nf
-
foo 1\.4\.3, requires: ~> bar 2\.0
foo 1\.4\.4, requires: ~> bar 2\.0
foo 1\.4\.5, requires: ~> bar 2\.1
foo 1\.5\.0, requires: ~> bar 2\.1
foo 1\.5\.1, requires: ~> bar 3\.0
bar with versions 2\.0\.3, 2\.0\.4, 2\.1\.0, 2\.1\.1, 3\.0\.0
-.
.fi
-.
.IP "" 0
-.
.P
Gemfile:
-.
.IP "" 4
-.
.nf
-
-gem \'foo\'
-.
+gem 'foo'
.fi
-.
.IP "" 0
-.
.P
Gemfile\.lock:
-.
.IP "" 4
-.
.nf
-
foo (1\.4\.3)
bar (~> 2\.0)
bar (2\.0\.3)
-.
.fi
-.
.IP "" 0
-.
.P
Cases:
-.
.IP "" 4
-.
.nf
-
# Command Line Result
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-1 bundle update \-\-patch \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-2 bundle update \-\-patch foo \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-3 bundle update \-\-minor \'foo 1\.5\.1\', \'bar 3\.0\.0\'
-4 bundle update \-\-minor \-\-strict \'foo 1\.5\.0\', \'bar 2\.1\.1\'
-5 bundle update \-\-patch \-\-strict \'foo 1\.4\.4\', \'bar 2\.0\.4\'
-.
+1 bundle update \-\-patch 'foo 1\.4\.5', 'bar 2\.1\.1'
+2 bundle update \-\-patch foo 'foo 1\.4\.5', 'bar 2\.1\.1'
+3 bundle update \-\-minor 'foo 1\.5\.1', 'bar 3\.0\.0'
+4 bundle update \-\-minor \-\-strict 'foo 1\.5\.0', 'bar 2\.1\.1'
+5 bundle update \-\-patch \-\-strict 'foo 1\.4\.4', 'bar 2\.0\.4'
.fi
-.
.IP "" 0
-.
.P
In case 1, bar is upgraded to 2\.1\.1, a minor version increase, because the dependency from foo 1\.4\.5 required it\.
-.
.P
-In case 2, only foo is requested to be unlocked, but bar is also allowed to move because it\'s not a declared dependency in the Gemfile\.
-.
+In case 2, only foo is requested to be unlocked, but bar is also allowed to move because it's not a declared dependency in the Gemfile\.
.P
In case 3, bar goes up a whole major release, because a minor increase is preferred now for foo, and when it goes to 1\.5\.1, it requires 3\.0\.0 of bar\.
-.
.P
-In case 4, foo is preferred up to a minor version, but 1\.5\.1 won\'t work because the \-\-strict flag removes bar 3\.0\.0 from consideration since it\'s a major increment\.
-.
+In case 4, foo is preferred up to a minor version, but 1\.5\.1 won't work because the \-\-strict flag removes bar 3\.0\.0 from consideration since it's a major increment\.
.P
In case 5, both foo and bar have any minor or major increments removed from consideration because of the \-\-strict flag, so the most they can move is up to 1\.4\.4 and 2\.0\.4\.
-.
.SH "RECOMMENDED WORKFLOW"
In general, when working with an application managed with bundler, you should use the following workflow:
-.
.IP "\(bu" 4
After you create your Gemfile(5) for the first time, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
Check the resulting \fBGemfile\.lock\fR into version control
-.
.IP
$ git add Gemfile\.lock
-.
.IP "\(bu" 4
When checking out this repository on another development machine, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
When checking out this repository on a deployment machine, run
-.
.IP
$ bundle install \-\-deployment
-.
.IP "\(bu" 4
After changing the Gemfile(5) to reflect a new or update dependency, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
Make sure to check the updated \fBGemfile\.lock\fR into version control
-.
.IP
$ git add Gemfile\.lock
-.
.IP "\(bu" 4
If bundle install(1) \fIbundle\-install\.1\.html\fR reports a conflict, manually update the specific gems that you changed in the Gemfile(5)
-.
.IP
$ bundle update rails thin
-.
.IP "\(bu" 4
If you want to update all the gems to the latest possible versions that still match the gems listed in the Gemfile(5), run
-.
.IP
$ bundle update \-\-all
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-update.1.ronn b/lib/bundler/man/bundle-update.1.ronn
index fe500cdc96..72fbf054d1 100644
--- a/lib/bundler/man/bundle-update.1.ronn
+++ b/lib/bundler/man/bundle-update.1.ronn
@@ -9,11 +9,14 @@ bundle-update(1) -- Update your gems to the latest available versions
[--local]
[--ruby]
[--bundler[=VERSION]]
+ [--cooldown=NUMBER]
+ [--force]
[--full-index]
- [--jobs=JOBS]
+ [--gemfile=GEMFILE]
+ [--jobs=NUMBER]
[--quiet]
[--patch|--minor|--major]
- [--redownload]
+ [--pre]
[--strict]
[--conservative]
@@ -32,13 +35,13 @@ gem.
* `--all`:
Update all gems specified in Gemfile.
-* `--group=<name>`, `-g=[<name>]`:
+* `--group=<list>`, `-g=<list>`:
Only update the gems in the specified group. For instance, you can update all gems
in the development group with `bundle update --group development`. You can also
call `bundle update rails --group test` to update the rails gem and all gems in
the test group, for example.
-* `--source=<name>`:
+* `--source=<list>`:
The name of a `:git` or `:path` source used in the Gemfile(5). For
instance, with a `:git` source of `http://github.com/rails/rails.git`,
you would call `bundle update --source rails`
@@ -49,13 +52,19 @@ gem.
* `--ruby`:
Update the locked version of Ruby to the current version of Ruby.
-* `--bundler`:
+* `--bundler[=BUNDLER]`:
Update the locked version of bundler to the invoked bundler version.
+* `--force`, `--redownload`:
+ Force reinstalling every gem, even if already installed.
+
* `--full-index`:
Fall back to using the single-file index of all gems.
-* `--jobs=[<number>]`, `-j[<number>]`:
+* `--gemfile=GEMFILE`:
+ Use the specified gemfile instead of [`Gemfile(5)`][Gemfile(5)].
+
+* `--jobs=<number>`, `-j=<number>`:
Specify the number of jobs to run in parallel. The default is the number of
available processors.
@@ -65,9 +74,6 @@ gem.
* `--quiet`:
Only output warnings and errors.
-* `--redownload`:
- Force downloading every gem.
-
* `--patch`:
Prefer updating only to next patch version.
@@ -77,12 +83,22 @@ gem.
* `--major`:
Prefer updating to next major version (default).
+* `--pre`:
+ Always choose the highest allowed version, regardless of prerelease status.
+
* `--strict`:
Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
* `--conservative`:
Use bundle install conservative update behavior and do not allow indirect dependencies to be updated.
+* `--cooldown=<number>`:
+ Only consider gem versions published at least <number> days ago when
+ resolving. Pass `0` to disable cooldown for this run, overriding any
+ per-source or global configuration. Combine with `--conservative` to
+ minimize transitive churn when bypassing cooldown for an urgent
+ update. See `cooldown` in bundle-config(1).
+
## UPDATING ALL GEMS
If you run `bundle update --all`, bundler will ignore
diff --git a/lib/bundler/man/bundle-version.1 b/lib/bundler/man/bundle-version.1
index 9a3820f3e6..751a408312 100644
--- a/lib/bundler/man/bundle-version.1
+++ b/lib/bundler/man/bundle-version.1
@@ -1,35 +1,22 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-VERSION" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE\-VERSION" "1" "May 2026" ""
.SH "NAME"
\fBbundle\-version\fR \- Prints Bundler version information
-.
.SH "SYNOPSIS"
\fBbundle version\fR
-.
.SH "DESCRIPTION"
Prints Bundler version information\.
-.
.SH "OPTIONS"
No options\.
-.
.SH "EXAMPLE"
Print the version of Bundler with build date and commit hash of the in the Git source\.
-.
.IP "" 4
-.
.nf
-
bundle version
-.
.fi
-.
.IP "" 0
-.
.P
shows \fBBundler version 2\.3\.21 (2022\-08\-24 commit d54be5fdd8)\fR for example\.
-.
.P
cf\. \fBbundle \-\-version\fR shows \fBBundler version 2\.3\.21\fR\.
diff --git a/lib/bundler/man/bundle-viz.1 b/lib/bundler/man/bundle-viz.1
deleted file mode 100644
index 3a07010309..0000000000
--- a/lib/bundler/man/bundle-viz.1
+++ /dev/null
@@ -1,42 +0,0 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-VIZ" "1" "February 2023" "" ""
-.
-.SH "NAME"
-\fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
-.
-.SH "SYNOPSIS"
-\fBbundle viz\fR [\-\-file=FILE] [\-\-format=FORMAT] [\-\-requirements] [\-\-version] [\-\-without=GROUP GROUP]
-.
-.SH "DESCRIPTION"
-\fBviz\fR generates a PNG file of the current \fBGemfile(5)\fR as a dependency graph\. \fBviz\fR requires the ruby\-graphviz gem (and its dependencies)\.
-.
-.P
-The associated gems must also be installed via \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR\.
-.
-.P
-\fBviz\fR command was deprecated in Bundler 2\.2\. Use bundler\-graph plugin \fIhttps://github\.com/rubygems/bundler\-graph\fR instead\.
-.
-.SH "OPTIONS"
-.
-.TP
-\fB\-\-file\fR, \fB\-f\fR
-The name to use for the generated file\. See \fB\-\-format\fR option
-.
-.TP
-\fB\-\-format\fR, \fB\-F\fR
-This is output format option\. Supported format is png, jpg, svg, dot \.\.\.
-.
-.TP
-\fB\-\-requirements\fR, \fB\-R\fR
-Set to show the version of each required dependency\.
-.
-.TP
-\fB\-\-version\fR, \fB\-v\fR
-Set to show each gem version\.
-.
-.TP
-\fB\-\-without\fR, \fB\-W\fR
-Exclude gems that are part of the specified named group\.
-
diff --git a/lib/bundler/man/bundle-viz.1.ronn b/lib/bundler/man/bundle-viz.1.ronn
deleted file mode 100644
index f220256943..0000000000
--- a/lib/bundler/man/bundle-viz.1.ronn
+++ /dev/null
@@ -1,32 +0,0 @@
-bundle-viz(1) -- Generates a visual dependency graph for your Gemfile
-=====================================================================
-
-## SYNOPSIS
-
-`bundle viz` [--file=FILE]
- [--format=FORMAT]
- [--requirements]
- [--version]
- [--without=GROUP GROUP]
-
-## DESCRIPTION
-
-`viz` generates a PNG file of the current `Gemfile(5)` as a dependency graph.
-`viz` requires the ruby-graphviz gem (and its dependencies).
-
-The associated gems must also be installed via [`bundle install(1)`](bundle-install.1.html).
-
-`viz` command was deprecated in Bundler 2.2. Use [bundler-graph plugin](https://github.com/rubygems/bundler-graph) instead.
-
-## OPTIONS
-
-* `--file`, `-f`:
- The name to use for the generated file. See `--format` option
-* `--format`, `-F`:
- This is output format option. Supported format is png, jpg, svg, dot ...
-* `--requirements`, `-R`:
- Set to show the version of each required dependency.
-* `--version`, `-v`:
- Set to show each gem version.
-* `--without`, `-W`:
- Exclude gems that are part of the specified named group.
diff --git a/lib/bundler/man/bundle.1 b/lib/bundler/man/bundle.1
index 873ba566b1..167815631a 100644
--- a/lib/bundler/man/bundle.1
+++ b/lib/bundler/man/bundle.1
@@ -1,141 +1,93 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE" "1" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "BUNDLE" "1" "May 2026" ""
.SH "NAME"
\fBbundle\fR \- Ruby Dependency Management
-.
.SH "SYNOPSIS"
\fBbundle\fR COMMAND [\-\-no\-color] [\-\-verbose] [ARGS]
-.
.SH "DESCRIPTION"
-Bundler manages an \fBapplication\'s dependencies\fR through its entire life across many machines systematically and repeatably\.
-.
+Bundler manages an \fBapplication's dependencies\fR through its entire life across many machines systematically and repeatably\.
.P
See the bundler website \fIhttps://bundler\.io\fR for information on getting started, and Gemfile(5) for more information on the \fBGemfile\fR format\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-no\-color\fR
Print all output without color
-.
.TP
\fB\-\-retry\fR, \fB\-r\fR
Specify the number of times you wish to attempt network commands
-.
.TP
\fB\-\-verbose\fR, \fB\-V\fR
Print out additional logging information
-.
.SH "BUNDLE COMMANDS"
We divide \fBbundle\fR subcommands into primary commands and utilities:
-.
.SH "PRIMARY COMMANDS"
-.
.TP
\fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR
Install the gems specified by the \fBGemfile\fR or \fBGemfile\.lock\fR
-.
.TP
\fBbundle update(1)\fR \fIbundle\-update\.1\.html\fR
Update dependencies to their latest versions
-.
.TP
\fBbundle cache(1)\fR \fIbundle\-cache\.1\.html\fR
Package the \.gem files required by your application into the \fBvendor/cache\fR directory (aliases: \fBbundle package\fR, \fBbundle pack\fR)
-.
.TP
\fBbundle exec(1)\fR \fIbundle\-exec\.1\.html\fR
Execute a script in the current bundle
-.
.TP
\fBbundle config(1)\fR \fIbundle\-config\.1\.html\fR
Specify and read configuration options for Bundler
-.
.TP
\fBbundle help(1)\fR \fIbundle\-help\.1\.html\fR
Display detailed help for each subcommand
-.
.SH "UTILITIES"
-.
.TP
\fBbundle add(1)\fR \fIbundle\-add\.1\.html\fR
Add the named gem to the Gemfile and run \fBbundle install\fR
-.
.TP
\fBbundle binstubs(1)\fR \fIbundle\-binstubs\.1\.html\fR
Generate binstubs for executables in a gem
-.
.TP
\fBbundle check(1)\fR \fIbundle\-check\.1\.html\fR
Determine whether the requirements for your application are installed and available to Bundler
-.
.TP
\fBbundle show(1)\fR \fIbundle\-show\.1\.html\fR
Show the source location of a particular gem in the bundle
-.
.TP
\fBbundle outdated(1)\fR \fIbundle\-outdated\.1\.html\fR
Show all of the outdated gems in the current bundle
-.
.TP
\fBbundle console(1)\fR (deprecated)
Start an IRB session in the current bundle
-.
.TP
\fBbundle open(1)\fR \fIbundle\-open\.1\.html\fR
Open an installed gem in the editor
-.
.TP
\fBbundle lock(1)\fR \fIbundle\-lock\.1\.html\fR
Generate a lockfile for your dependencies
-.
-.TP
-\fBbundle viz(1)\fR \fIbundle\-viz\.1\.html\fR (deprecated)
-Generate a visual representation of your dependencies
-.
.TP
\fBbundle init(1)\fR \fIbundle\-init\.1\.html\fR
Generate a simple \fBGemfile\fR, placed in the current directory
-.
.TP
\fBbundle gem(1)\fR \fIbundle\-gem\.1\.html\fR
Create a simple gem, suitable for development with Bundler
-.
.TP
\fBbundle platform(1)\fR \fIbundle\-platform\.1\.html\fR
Display platform compatibility information
-.
.TP
\fBbundle clean(1)\fR \fIbundle\-clean\.1\.html\fR
Clean up unused gems in your Bundler directory
-.
.TP
\fBbundle doctor(1)\fR \fIbundle\-doctor\.1\.html\fR
Display warnings about common problems
-.
.TP
\fBbundle remove(1)\fR \fIbundle\-remove\.1\.html\fR
Removes gems from the Gemfile
-.
.TP
\fBbundle plugin(1)\fR \fIbundle\-plugin\.1\.html\fR
Manage Bundler plugins
-.
.TP
\fBbundle version(1)\fR \fIbundle\-version\.1\.html\fR
Prints Bundler version information
-.
.SH "PLUGINS"
-When running a command that isn\'t listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\.
-.
-.SH "OBSOLETE"
-These commands are obsolete and should no longer be used:
-.
-.IP "\(bu" 4
-\fBbundle inject(1)\fR
-.
-.IP "" 0
-
+When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\.
diff --git a/lib/bundler/man/bundle.1.ronn b/lib/bundler/man/bundle.1.ronn
index 8245effabd..1c2b3df7af 100644
--- a/lib/bundler/man/bundle.1.ronn
+++ b/lib/bundler/man/bundle.1.ronn
@@ -76,9 +76,6 @@ We divide `bundle` subcommands into primary commands and utilities:
* [`bundle lock(1)`](bundle-lock.1.html):
Generate a lockfile for your dependencies
-* [`bundle viz(1)`](bundle-viz.1.html) (deprecated):
- Generate a visual representation of your dependencies
-
* [`bundle init(1)`](bundle-init.1.html):
Generate a simple `Gemfile`, placed in the current directory
@@ -108,9 +105,3 @@ We divide `bundle` subcommands into primary commands and utilities:
When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES,
Bundler will try to find an executable on your path named `bundler-<command>`
and execute it, passing down any extra arguments to it.
-
-## OBSOLETE
-
-These commands are obsolete and should no longer be used:
-
-* `bundle inject(1)`
diff --git a/lib/bundler/man/gemfile.5 b/lib/bundler/man/gemfile.5
index 8e56506c88..64e93c4b15 100644
--- a/lib/bundler/man/gemfile.5
+++ b/lib/bundler/man/gemfile.5
@@ -1,215 +1,143 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "GEMFILE" "5" "February 2023" "" ""
-.
+.\" generated with Ronn-NG/v0.10.1
+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
+.TH "GEMFILE" "5" "May 2026" ""
.SH "NAME"
\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
-.
.SH "SYNOPSIS"
A \fBGemfile\fR describes the gem dependencies required to execute associated Ruby code\.
-.
.P
Place the \fBGemfile\fR in the root of the directory containing the associated code\. For instance, in a Rails application, place the \fBGemfile\fR in the same directory as the \fBRakefile\fR\.
-.
.SH "SYNTAX"
A \fBGemfile\fR is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements\.
-.
.SH "GLOBAL SOURCE"
At the top of the \fBGemfile\fR, add a single line for the \fBRubyGems\fR source that contains the gems listed in the \fBGemfile\fR\.
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
-.
.fi
-.
.IP "" 0
-.
.P
You can add only one global source\. In Bundler 1\.13, adding multiple global sources was deprecated\. The \fBsource\fR \fBMUST\fR be a valid RubyGems repository\.
-.
.P
To use more than one source of RubyGems, you should use \fI\fBsource\fR block\fR\.
-.
.P
A source is checked for gems following the heuristics described in \fISOURCE PRIORITY\fR\.
-.
.P
\fBNote about a behavior of the feature deprecated in Bundler 1\.13\fR: If a gem is found in more than one global source, Bundler will print a warning after installing the gem indicating which source was used, and listing the other sources where the gem is available\. A specific source can be selected for gems that need to use a non\-standard repository, suppressing this warning, by using the \fI\fB:source\fR option\fR or \fBsource\fR block\.
-.
.SS "CREDENTIALS"
Some gem sources require a username and password\. Use bundle config(1) \fIbundle\-config\.1\.html\fR to set the username and password for any of the sources that need it\. The command must be run once on each computer that will install the Gemfile, but this keeps the credentials from being stored in plain text in version control\.
-.
.IP "" 4
-.
.nf
-
bundle config gems\.example\.com user:password
-.
.fi
-.
.IP "" 0
-.
.P
For some sources, like a company Gemfury account, it may be easier to include the credentials in the Gemfile as part of the source URL\.
-.
.IP "" 4
-.
.nf
-
source "https://user:password@gems\.example\.com"
-.
.fi
-.
.IP "" 0
-.
.P
Credentials in the source URL will take precedence over credentials set using \fBconfig\fR\.
-.
.SH "RUBY"
If your application requires a specific Ruby version or engine, specify your requirements using the \fBruby\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
.SS "VERSION (required)"
The version of Ruby that your application requires\. If your application requires an alternate Ruby engine, such as JRuby, TruffleRuby, etc\., this should be the Ruby version that the engine is compatible with\.
-.
.IP "" 4
-.
.nf
-
ruby "3\.1\.2"
-.
.fi
-.
.IP "" 0
-.
+.P
+If you wish to derive your Ruby version from a version file (ie \.ruby\-version), you can use the \fBfile\fR option instead\.
+.IP "" 4
+.nf
+ruby file: "\.ruby\-version"
+.fi
+.IP "" 0
+.P
+The version file should conform to any of the following formats:
+.IP "\(bu" 4
+\fB3\.1\.2\fR (\.ruby\-version)
+.IP "\(bu" 4
+\fBruby 3\.1\.2\fR (\.tool\-versions, read: https://asdf\-vm\.com/manage/configuration\.html#tool\-versions)
+.IP "" 0
.SS "ENGINE"
Each application \fImay\fR specify a Ruby engine\. If an engine is specified, an engine version \fImust\fR also be specified\.
-.
.P
-What exactly is an Engine? \- A Ruby engine is an implementation of the Ruby language\.
-.
+What exactly is an Engine?
+.IP "\(bu" 4
+A Ruby engine is an implementation of the Ruby language\.
.IP "\(bu" 4
-For background: the reference or original implementation of the Ruby programming language is called Matz\'s Ruby Interpreter \fIhttps://en\.wikipedia\.org/wiki/Ruby_MRI\fR, or MRI for short\. This is named after Ruby creator Yukihiro Matsumoto, also known as Matz\. MRI is also known as CRuby, because it is written in C\. MRI is the most widely used Ruby engine\.
-.
+For background: the reference or original implementation of the Ruby programming language is called Matz's Ruby Interpreter \fIhttps://en\.wikipedia\.org/wiki/Ruby_MRI\fR, or MRI for short\. This is named after Ruby creator Yukihiro Matsumoto, also known as Matz\. MRI is also known as CRuby, because it is written in C\. MRI is the most widely used Ruby engine\.
.IP "\(bu" 4
-Other implementations \fIhttps://www\.ruby\-lang\.org/en/about/\fR of Ruby exist\. Some of the more well\-known implementations include JRuby \fIhttp://jruby\.org/\fR and TruffleRuby \fIhttps://www\.graalvm\.org/ruby/\fR\. Rubinius is an alternative implementation of Ruby written in Ruby\. JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine\. TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM\.
-.
+Other implementations \fIhttps://www\.ruby\-lang\.org/en/about/\fR of Ruby exist\. Some of the more well\-known implementations include JRuby \fIhttps://www\.jruby\.org/\fR and TruffleRuby \fIhttps://www\.graalvm\.org/ruby/\fR\. Rubinius is an alternative implementation of Ruby written in Ruby\. JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine\. TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM\.
.IP "" 0
-.
.SS "ENGINE VERSION"
Each application \fImay\fR specify a Ruby engine version\. If an engine version is specified, an engine \fImust\fR also be specified\. If the engine is "ruby" the engine version specified \fImust\fR match the Ruby version\.
-.
.IP "" 4
-.
.nf
-
ruby "2\.6\.8", engine: "jruby", engine_version: "9\.3\.8\.0"
-.
.fi
-.
.IP "" 0
-.
.SS "PATCHLEVEL"
Each application \fImay\fR specify a Ruby patchlevel\. Specifying the patchlevel has been meaningless since Ruby 2\.1\.0 was released as the patchlevel is now uniquely determined by a combination of major, minor, and teeny version numbers\.
-.
.P
This option was implemented in Bundler 1\.4\.0 for Ruby 2\.0 or earlier\.
-.
.IP "" 4
-.
.nf
-
ruby "3\.1\.2", patchlevel: "20"
-.
.fi
-.
.IP "" 0
-.
.SH "GEMS"
Specify gem requirements using the \fBgem\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
.SS "NAME (required)"
For each gem requirement, list a single \fIgem\fR line\.
-.
.IP "" 4
-.
.nf
-
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.SS "VERSION"
Each \fIgem\fR \fBMAY\fR have one or more version specifiers\.
-.
.IP "" 4
-.
.nf
-
gem "nokogiri", ">= 1\.4\.2"
gem "RedCloth", ">= 4\.1\.0", "< 4\.2\.0"
-.
.fi
-.
.IP "" 0
-.
.SS "REQUIRE AS"
Each \fIgem\fR \fBMAY\fR specify files that should be used when autorequiring via \fBBundler\.require\fR\. You may pass an array with multiple files or \fBtrue\fR if the file you want \fBrequired\fR has the same name as \fIgem\fR or \fBfalse\fR to prevent any file from being autorequired\.
-.
.IP "" 4
-.
.nf
-
gem "redis", require: ["redis/connection/hiredis", "redis"]
gem "webmock", require: false
gem "byebug", require: true
-.
.fi
-.
.IP "" 0
-.
.P
The argument defaults to the name of the gem\. For example, these are identical:
-.
.IP "" 4
-.
.nf
-
gem "nokogiri"
gem "nokogiri", require: "nokogiri"
gem "nokogiri", require: true
-.
.fi
-.
.IP "" 0
-.
.SS "GROUPS"
Each \fIgem\fR \fBMAY\fR specify membership in one or more groups\. Any \fIgem\fR that does not specify membership in any group is placed in the \fBdefault\fR group\.
-.
.IP "" 4
-.
.nf
-
gem "rspec", group: :test
gem "wirble", groups: [:development, :test]
-.
.fi
-.
.IP "" 0
-.
.P
The Bundler runtime allows its two main methods, \fBBundler\.setup\fR and \fBBundler\.require\fR, to limit their impact to particular groups\.
-.
.IP "" 4
-.
.nf
-
-# setup adds gems to Ruby\'s load path
+# setup adds gems to Ruby's load path
Bundler\.setup # defaults to all groups
require "bundler/setup" # same as Bundler\.setup
Bundler\.setup(:default) # only set up the _default_ group
@@ -221,437 +149,271 @@ Bundler\.require # defaults to the _default_ group
Bundler\.require(:default) # identical
Bundler\.require(:default, :test) # requires the _default_ and _test_ groups
Bundler\.require(:test) # requires the _test_ group
-.
.fi
-.
.IP "" 0
-.
.P
The Bundler CLI allows you to specify a list of groups whose gems \fBbundle install\fR should not install with the \fBwithout\fR configuration\.
-.
.P
To specify multiple groups to ignore, specify a list of groups separated by spaces\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-local without test
bundle config set \-\-local without development test
-.
.fi
-.
.IP "" 0
-.
.P
Also, calling \fBBundler\.setup\fR with no parameters, or calling \fBrequire "bundler/setup"\fR will setup all groups except for the ones you excluded via \fB\-\-without\fR (since they are not available)\.
-.
.P
Note that on \fBbundle install\fR, bundler downloads and evaluates all gems, in order to create a single canonical list of all of the required gems and their dependencies\. This means that you cannot list different versions of the same gems in different groups\. For more details, see Understanding Bundler \fIhttps://bundler\.io/rationale\.html\fR\.
-.
.SS "PLATFORMS"
If a gem should only be used in a particular platform or set of platforms, you can specify them\. Platforms are essentially identical to groups, except that you do not need to use the \fB\-\-without\fR install\-time flag to exclude groups of gems for other platforms\.
-.
.P
There are a number of \fBGemfile\fR platforms:
-.
.TP
\fBruby\fR
C Ruby (MRI), Rubinius, or TruffleRuby, but not Windows
-.
.TP
\fBmri\fR
C Ruby (MRI) only, but not Windows
-.
.TP
\fBwindows\fR
Windows C Ruby (MRI), including RubyInstaller 32\-bit and 64\-bit versions
-.
.TP
\fBmswin\fR
Windows C Ruby (MRI), including RubyInstaller 32\-bit versions
-.
.TP
\fBmswin64\fR
Windows C Ruby (MRI), including RubyInstaller 64\-bit versions
-.
.TP
\fBrbx\fR
Rubinius
-.
.TP
\fBjruby\fR
JRuby
-.
.TP
\fBtruffleruby\fR
TruffleRuby
-.
.P
On platforms \fBruby\fR, \fBmri\fR, \fBmswin\fR, \fBmswin64\fR, and \fBwindows\fR, you may additionally specify a version by appending the major and minor version numbers without a delimiter\. For example, to specify that a gem should only be used on platform \fBruby\fR version 3\.1, use:
-.
.IP "" 4
-.
.nf
-
ruby_31
-.
.fi
-.
.IP "" 0
-.
.P
As with groups (above), you may specify one or more platforms:
-.
.IP "" 4
-.
.nf
-
gem "weakling", platforms: :jruby
gem "ruby\-debug", platforms: :mri_31
gem "nokogiri", platforms: [:windows_31, :jruby]
-.
.fi
-.
.IP "" 0
-.
.P
All operations involving groups (\fBbundle install\fR \fIbundle\-install\.1\.html\fR, \fBBundler\.setup\fR, \fBBundler\.require\fR) behave exactly the same as if any groups not matching the current platform were explicitly excluded\.
-.
.P
The following platform values are deprecated and should be replaced with \fBwindows\fR:
-.
.IP "\(bu" 4
\fBmswin\fR, \fBmswin64\fR, \fBmingw32\fR, \fBx64_mingw\fR
-.
.IP "" 0
-.
+.P
+Note that, while unfortunately using the same terminology, the values of this option are different from the values that \fBbundle lock \-\-add\-platform\fR can take\. The values of this option are more closer to "Ruby Implementation" while the values that \fBbundle lock \-\-add\-platform\fR understands are more related to OS and architecture of the different systems where your lockfile will be used\.
.SS "FORCE_RUBY_PLATFORM"
If you always want the pure ruby variant of a gem to be chosen over platform specific variants, you can use the \fBforce_ruby_platform\fR option:
-.
.IP "" 4
-.
.nf
-
gem "ffi", force_ruby_platform: true
-.
.fi
-.
.IP "" 0
-.
.P
This can be handy (assuming the pure ruby variant works fine) when:
-.
.IP "\(bu" 4
-You\'re having issues with the platform specific variant\.
-.
+You're having issues with the platform specific variant\.
.IP "\(bu" 4
The platform specific variant does not yet support a newer ruby (and thus has a \fBrequired_ruby_version\fR upper bound), but you still want your Gemfile{\.lock} files to resolve under that ruby\.
-.
.IP "" 0
-.
.SS "SOURCE"
-You can select an alternate RubyGems repository for a gem using the \':source\' option\.
-.
+You can select an alternate RubyGems repository for a gem using the ':source' option\.
.IP "" 4
-.
.nf
-
gem "some_internal_gem", source: "https://gems\.example\.com"
-.
.fi
-.
.IP "" 0
-.
.P
This forces the gem to be loaded from this source and ignores the global source declared at the top level of the file\. If the gem does not exist in this source, it will not be installed\.
-.
.P
Bundler will search for child dependencies of this gem by first looking in the source selected for the parent, but if they are not found there, it will fall back on the global source\.
-.
.P
\fBNote about a behavior of the feature deprecated in Bundler 1\.13\fR: Selecting a specific source repository this way also suppresses the ambiguous gem warning described above in \fIGLOBAL SOURCE\fR\.
-.
.P
Using the \fB:source\fR option for an individual gem will also make that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when adding gems with explicit sources, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources\.
-.
.SS "GIT"
If necessary, you can specify that a gem is located at a particular git repository using the \fB:git\fR parameter\. The repository can be accessed via several protocols:
-.
.TP
\fBHTTP(S)\fR
gem "rails", git: "https://github\.com/rails/rails\.git"
-.
.TP
\fBSSH\fR
gem "rails", git: "git@github\.com:rails/rails\.git"
-.
.TP
\fBgit\fR
gem "rails", git: "git://github\.com/rails/rails\.git"
-.
.P
If using SSH, the user that you use to run \fBbundle install\fR \fBMUST\fR have the appropriate keys available in their \fB$HOME/\.ssh\fR\.
-.
.P
\fBNOTE\fR: \fBhttp://\fR and \fBgit://\fR URLs should be avoided if at all possible\. These protocols are unauthenticated, so a man\-in\-the\-middle attacker can deliver malicious code and compromise your system\. HTTPS and SSH are strongly preferred\.
-.
.P
The \fBgroup\fR, \fBplatforms\fR, and \fBrequire\fR options are available and behave exactly the same as they would for a normal gem\.
-.
.P
A git repository \fBSHOULD\fR have at least one file, at the root of the directory containing the gem, with the extension \fB\.gemspec\fR\. This file \fBMUST\fR contain a valid gem specification, as expected by the \fBgem build\fR command\.
-.
.P
If a git repository does not have a \fB\.gemspec\fR, bundler will attempt to create one, but it will not contain any dependencies, executables, or C extension compilation instructions\. As a result, it may fail to properly integrate into your application\.
-.
.P
If a git repository does have a \fB\.gemspec\fR for the gem you attached it to, a version specifier, if provided, means that the git repository is only valid if the \fB\.gemspec\fR specifies a version matching the version specifier\. If not, bundler will print a warning\.
-.
.IP "" 4
-.
.nf
-
gem "rails", "2\.3\.8", git: "https://github\.com/rails/rails\.git"
# bundle install will fail, because the \.gemspec in the rails
-# repository\'s master branch specifies version 3\.0\.0
-.
+# repository's master branch specifies version 3\.0\.0
.fi
-.
.IP "" 0
-.
.P
If a git repository does \fBnot\fR have a \fB\.gemspec\fR for the gem you attached it to, a version specifier \fBMUST\fR be provided\. Bundler will use this version in the simple \fB\.gemspec\fR it creates\.
-.
.P
Git repositories support a number of additional options\.
-.
.TP
\fBbranch\fR, \fBtag\fR, and \fBref\fR
You \fBMUST\fR only specify at most one of these options\. The default is \fBbranch: "master"\fR\. For example:
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", branch: "5\-0\-stable"
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", tag: "v5\.0\.0"
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", ref: "4aded"
-.
.TP
\fBsubmodules\fR
For reference, a git submodule \fIhttps://git\-scm\.com/book/en/v2/Git\-Tools\-Submodules\fR lets you have another git repository within a subfolder of your repository\. Specify \fBsubmodules: true\fR to cause bundler to expand any submodules included in the git repository
-.
.P
If a git repository contains multiple \fB\.gemspecs\fR, each \fB\.gemspec\fR represents a gem located at the same place in the file system as the \fB\.gemspec\fR\.
-.
.IP "" 4
-.
.nf
-
|~rails [git root]
| |\-rails\.gemspec [rails gem located here]
|~actionpack
| |\-actionpack\.gemspec [actionpack gem located here]
|~activesupport
| |\-activesupport\.gemspec [activesupport gem located here]
-|\.\.\.
-.
+|\|\.\|\.\|\.
.fi
-.
.IP "" 0
-.
.P
To install a gem located in a git repository, bundler changes to the directory containing the gemspec, runs \fBgem build name\.gemspec\fR and then installs the resulting gem\. The \fBgem build\fR command, which comes standard with Rubygems, evaluates the \fB\.gemspec\fR in the context of the directory in which it is located\.
-.
.SS "GIT SOURCE"
-A custom git source can be defined via the \fBgit_source\fR method\. Provide the source\'s name as an argument, and a block which receives a single argument and interpolates it into a string to return the full repo address:
-.
+A custom git source can be defined via the \fBgit_source\fR method\. Provide the source's name as an argument, and a block which receives a single argument and interpolates it into a string to return the full repo address:
.IP "" 4
-.
.nf
-
git_source(:stash){ |repo_name| "https://stash\.corp\.acme\.pl/#{repo_name}\.git" }
-gem \'rails\', stash: \'forks/rails\'
-.
+gem 'rails', stash: 'forks/rails'
.fi
-.
.IP "" 0
-.
.P
In addition, if you wish to choose a specific branch:
-.
.IP "" 4
-.
.nf
-
gem "rails", stash: "forks/rails", branch: "branch_name"
-.
.fi
-.
.IP "" 0
-.
.SS "GITHUB"
\fBNOTE\fR: This shorthand should be avoided until Bundler 2\.0, since it currently expands to an insecure \fBgit://\fR URL\. This allows a man\-in\-the\-middle attacker to compromise your system\.
-.
.P
If the git repository you want to use is hosted on GitHub and is public, you can use the :github shorthand to specify the github username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "rails/rails"
gem "rails", github: "rails"
-.
.fi
-.
.IP "" 0
-.
.P
Are both equivalent to
-.
.IP "" 4
-.
.nf
-
gem "rails", git: "https://github\.com/rails/rails\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBgithub\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.P
You can also directly pass a pull request URL:
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "https://github\.com/rails/rails/pull/43753"
-.
.fi
-.
.IP "" 0
-.
.P
Which is equivalent to:
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "rails/rails", branch: "refs/pull/43753/head"
-.
.fi
-.
.IP "" 0
-.
.SS "GIST"
If the git repository you want to use is hosted as a GitHub Gist and is public, you can use the :gist shorthand to specify the gist identifier (without the trailing "\.git")\.
-.
.IP "" 4
-.
.nf
-
gem "the_hatch", gist: "4815162342"
-.
.fi
-.
.IP "" 0
-.
.P
Is equivalent to:
-.
.IP "" 4
-.
.nf
-
gem "the_hatch", git: "https://gist\.github\.com/4815162342\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBgist\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.SS "BITBUCKET"
If the git repository you want to use is hosted on Bitbucket and is public, you can use the :bitbucket shorthand to specify the bitbucket username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
.IP "" 4
-.
.nf
-
gem "rails", bitbucket: "rails/rails"
gem "rails", bitbucket: "rails"
-.
.fi
-.
.IP "" 0
-.
.P
Are both equivalent to
-.
.IP "" 4
-.
.nf
-
gem "rails", git: "https://rails@bitbucket\.org/rails/rails\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBbitbucket\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.SS "PATH"
You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\.
-.
.P
Similar to the semantics of the \fB:git\fR option, the \fB:path\fR option requires that the directory in question either contains a \fB\.gemspec\fR for the gem, or that you specify an explicit version that bundler should use\.
-.
.P
Unlike \fB:git\fR, bundler does not compile C extensions for gems specified as paths\.
-.
.IP "" 4
-.
.nf
-
gem "rails", path: "vendor/rails"
-.
.fi
-.
.IP "" 0
-.
.P
-If you would like to use multiple local gems directly from the filesystem, you can set a global \fBpath\fR option to the path containing the gem\'s files\. This will automatically load gemspec files from subdirectories\.
-.
+If you would like to use multiple local gems directly from the filesystem, you can set a global \fBpath\fR option to the path containing the gem's files\. This will automatically load gemspec files from subdirectories\.
.IP "" 4
-.
.nf
-
-path \'components\' do
- gem \'admin_ui\'
- gem \'public_ui\'
+path 'components' do
+ gem 'admin_ui'
+ gem 'public_ui'
end
-.
.fi
-.
.IP "" 0
-.
.SH "BLOCK FORM OF SOURCE, GIT, PATH, GROUP and PLATFORMS"
The \fB:source\fR, \fB:git\fR, \fB:path\fR, \fB:group\fR, and \fB:platforms\fR options may be applied to a group of gems by using block form\.
-.
.IP "" 4
-.
.nf
-
source "https://gems\.example\.com" do
gem "some_internal_gem"
gem "another_internal_gem"
@@ -671,61 +433,115 @@ group :development, optional: true do
gem "wirble"
gem "faker"
end
-.
.fi
-.
.IP "" 0
-.
.P
In the case of the group block form the :optional option can be given to prevent a group from being installed unless listed in the \fB\-\-with\fR option given to the \fBbundle install\fR command\.
-.
.P
In the case of the \fBgit\fR block form, the \fB:ref\fR, \fB:branch\fR, \fB:tag\fR, and \fB:submodules\fR options may be passed to the \fBgit\fR method, and all gems in the block will inherit those options\.
-.
.P
The presence of a \fBsource\fR block in a Gemfile also makes that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when defining source blocks, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources, either via source blocks or \fB:source\fR directives on individual gems\.
-.
.SH "INSTALL_IF"
The \fBinstall_if\fR method allows gems to be installed based on a proc or lambda\. This is especially useful for optional gems that can only be used if certain software is installed or some other conditions are met\.
-.
.IP "" 4
-.
.nf
-
install_if \-> { RUBY_PLATFORM =~ /darwin/ } do
gem "pasteboard"
end
-.
.fi
-.
.IP "" 0
-.
.SH "GEMSPEC"
-The \fB\.gemspec\fR \fIhttp://guides\.rubygems\.org/specification\-reference/\fR file is where you provide metadata about your gem to Rubygems\. Some required Gemspec attributes include the name, description, and homepage of your gem\. This is also where you specify the dependencies your gem needs to run\.
-.
+The \fB\.gemspec\fR \fIhttps://guides\.rubygems\.org/specification\-reference/\fR file is where you provide metadata about your gem to Rubygems\. Some required Gemspec attributes include the name, description, and homepage of your gem\. This is also where you specify the dependencies your gem needs to run\.
.P
If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the \fBgemspec\fR method to pull in the dependencies listed in the \fB\.gemspec\fR file\.
-.
.P
-The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fBpath: \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
-.
+The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fBpath: '\.'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
.P
-The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: "{,\fI,\fR/*}\.gemspec"), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
-.
+The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: \fB{,*,*/*}\.gemspec\fR), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
.P
When a \fBgemspec\fR dependency encounters version conflicts during resolution, the local version under development will always be selected \-\- even if there are remote versions that better match other requirements for the \fBgemspec\fR gem\.
-.
+.SH "OVERRIDE"
+The \fBoverride\fR directive rewrites a constraint on another gem before resolution runs\. It targets the common case where an upstream gem's published metadata is too narrow on the current project's machine \-\- a stale upper bound, an unwanted floor, or a transitive pin that has to be lifted\.
+.IP "" 4
+.nf
+override <target>, <field>: <operation>
+.fi
+.IP "" 0
+.P
+\fB<target>\fR is a gem name string or \fB:all\fR\. \fB<field>\fR is one of \fBversion:\fR, \fBrequired_ruby_version:\fR, or \fBrequired_rubygems_version:\fR\. \fB<operation>\fR is one of:
+.IP "\(bu" 4
+a version requirement string (e\.g\. \fB">= 8\.0"\fR), which \fBreplaces\fR the target's requirement absolutely\. The original requirement, both direct and transitive, is discarded in favour of the override\.
+.IP "\(bu" 4
+\fB:ignore_upper\fR, which removes upper\-bound operators (\fB<\fR and \fB<=\fR) from the existing requirement and folds \fB~>\fR into its lower bound (\fB~> 1\.5\fR becomes \fB>= 1\.5\fR)\. Other operators, including \fB!=\fR, are preserved\.
+.IP "\(bu" 4
+\fBnil\fR, which collapses the requirement to \fB>= 0\fR (no constraint at all)\.
+.IP "" 0
+.P
+\fB:all\fR only applies to \fBrequired_ruby_version:\fR and \fBrequired_rubygems_version:\fR\. A per\-gem override on the same field takes precedence over an \fB:all\fR override\. \fB:all + version:\fR is rejected: version requirements only make sense per gem\.
+.P
+Multiple \fBoverride\fR calls for distinct targets are allowed; declaring the same \fBtarget\fR and \fBfield\fR twice is an error\.
+.IP "" 4
+.nf
+source "https://rubygems\.org"
+
+# Force every reference to "rails" \-\- direct or transitive \-\- to >= 8\.0\.
+override "rails", version: ">= 8\.0"
+
+# Strip the upper bound on nokogiri\.
+override "nokogiri", version: :ignore_upper
+
+# Drop the version pin on legacy entirely\.
+override "legacy", version: nil
+
+# Loosen every gem's required_ruby_version upper bound\.
+override :all, required_ruby_version: :ignore_upper
+
+# Override one specific gem's required_rubygems_version\.
+override "tricky", required_rubygems_version: nil
+
+gem "rails", "~> 7\.0"
+.fi
+.IP "" 0
+.P
+The override only affects resolution and the install\-time Ruby/RubyGems compatibility checks; \fBGemfile\.lock\fR continues to reflect the resolved versions, not the rewritten requirements\. When resolution still fails, Bundler appends the active overrides (with their Gemfile location) to the error message so it is clear which override shaped the constraint set\.
.SH "SOURCE PRIORITY"
When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order:
-.
.IP "1." 4
The source explicitly attached to the gem (using \fB:source\fR, \fB:path\fR, or \fB:git\fR)
-.
.IP "2." 4
For implicit gems (dependencies of explicit gems), any source, git, or path repository declared on the parent\. This results in bundler prioritizing the ActiveSupport gem from the Rails git repository over ones from \fBrubygems\.org\fR
-.
.IP "3." 4
If neither of the above conditions are met, the global source will be used\. If multiple global sources are specified, they will be prioritized from last to first, but this is deprecated since Bundler 1\.13, so Bundler prints a warning and will abort with an error in the future\.
-.
+.IP "" 0
+.SH "LOCKFILE"
+By default, Bundler will create a lockfile by adding \fB\.lock\fR to the end of the Gemfile name\. To change this, use the \fBlockfile\fR method:
+.IP "" 4
+.nf
+lockfile "/path/to/lockfile\.lock"
+.fi
+.IP "" 0
+.P
+This is useful when you want to use different lockfiles per ruby version or platform\.
+.P
+To avoid writing a lock file, use \fBfalse\fR as the argument:
+.IP "" 4
+.nf
+lockfile false
+.fi
+.IP "" 0
+.P
+This is useful for library development and other situations where the code is expected to work with a range of dependency versions\.
+.SS "LOCKFILE PRECEDENCE"
+When determining path to the lockfile or whether to create a lockfile, the following precedence is used:
+.IP "1." 4
+The \fBbundle install\fR \fB\-\-no\-lock\fR option (which disables lockfile creation)\.
+.IP "2." 4
+The \fBbundle install\fR \fB\-\-lockfile\fR option\.
+.IP "3." 4
+The \fBBUNDLE_LOCKFILE\fR environment variable\.
+.IP "4." 4
+The \fBlockfile\fR method in the Gemfile\.
+.IP "5." 4
+The default behavior of adding \fB\.lock\fR to the end of the Gemfile name\.
.IP "" 0
diff --git a/lib/bundler/man/gemfile.5.ronn b/lib/bundler/man/gemfile.5.ronn
index a5d2288b96..69fef90654 100644
--- a/lib/bundler/man/gemfile.5.ronn
+++ b/lib/bundler/man/gemfile.5.ronn
@@ -69,6 +69,16 @@ should be the Ruby version that the engine is compatible with.
ruby "3.1.2"
+If you wish to derive your Ruby version from a version file (ie .ruby-version),
+you can use the `file` option instead.
+
+ ruby file: ".ruby-version"
+
+The version file should conform to any of the following formats:
+
+ - `3.1.2` (.ruby-version)
+ - `ruby 3.1.2` (.tool-versions, read: https://asdf-vm.com/manage/configuration.html#tool-versions)
+
### ENGINE
Each application _may_ specify a Ruby engine. If an engine is specified, an
@@ -86,7 +96,7 @@ What exactly is an Engine?
- [Other implementations](https://www.ruby-lang.org/en/about/) of Ruby exist.
Some of the more well-known implementations include
- [JRuby](http://jruby.org/) and [TruffleRuby](https://www.graalvm.org/ruby/).
+ [JRuby](https://www.jruby.org/) and [TruffleRuby](https://www.graalvm.org/ruby/).
Rubinius is an alternative implementation of Ruby written in Ruby.
JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine.
TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM.
@@ -232,6 +242,12 @@ The following platform values are deprecated and should be replaced with `window
* `mswin`, `mswin64`, `mingw32`, `x64_mingw`
+Note that, while unfortunately using the same terminology, the values of this
+option are different from the values that `bundle lock --add-platform` can take.
+The values of this option are more closer to "Ruby Implementation" while the
+values that `bundle lock --add-platform` understands are more related to OS and
+architecture of the different systems where your lockfile will be used.
+
### FORCE_RUBY_PLATFORM
If you always want the pure ruby variant of a gem to be chosen over platform
@@ -499,7 +515,7 @@ software is installed or some other conditions are met.
## GEMSPEC
-The [`.gemspec`](http://guides.rubygems.org/specification-reference/) file is where
+The [`.gemspec`](https://guides.rubygems.org/specification-reference/) file is where
you provide metadata about your gem to Rubygems. Some required Gemspec
attributes include the name, description, and homepage of your gem. This is
also where you specify the dependencies your gem needs to run.
@@ -518,13 +534,66 @@ paths.
The `gemspec` method supports optional `:path`, `:glob`, `:name`, and `:development_group`
options, which control where bundler looks for the `.gemspec`, the glob it uses to look
-for the gemspec (defaults to: "{,*,*/*}.gemspec"), what named `.gemspec` it uses
+for the gemspec (defaults to: `{,*,*/*}.gemspec`), what named `.gemspec` it uses
(if more than one is present), and which group development dependencies are included in.
When a `gemspec` dependency encounters version conflicts during resolution, the
local version under development will always be selected -- even if there are
remote versions that better match other requirements for the `gemspec` gem.
+## OVERRIDE
+
+The `override` directive rewrites a constraint on another gem before
+resolution runs. It targets the common case where an upstream gem's
+published metadata is too narrow on the current project's machine -- a stale
+upper bound, an unwanted floor, or a transitive pin that has to be lifted.
+
+ override <target>, <field>: <operation>
+
+`<target>` is a gem name string or `:all`. `<field>` is one of `version:`,
+`required_ruby_version:`, or `required_rubygems_version:`. `<operation>` is
+one of:
+
+ * a version requirement string (e.g. `">= 8.0"`), which **replaces** the
+ target's requirement absolutely. The original requirement, both direct
+ and transitive, is discarded in favour of the override.
+ * `:ignore_upper`, which removes upper-bound operators (`<` and `<=`) from
+ the existing requirement and folds `~>` into its lower bound (`~> 1.5`
+ becomes `>= 1.5`). Other operators, including `!=`, are preserved.
+ * `nil`, which collapses the requirement to `>= 0` (no constraint at all).
+
+`:all` only applies to `required_ruby_version:` and `required_rubygems_version:`.
+A per-gem override on the same field takes precedence over an `:all` override.
+`:all + version:` is rejected: version requirements only make sense per gem.
+
+Multiple `override` calls for distinct targets are allowed; declaring the
+same `target` and `field` twice is an error.
+
+ source "https://rubygems.org"
+
+ # Force every reference to "rails" -- direct or transitive -- to >= 8.0.
+ override "rails", version: ">= 8.0"
+
+ # Strip the upper bound on nokogiri.
+ override "nokogiri", version: :ignore_upper
+
+ # Drop the version pin on legacy entirely.
+ override "legacy", version: nil
+
+ # Loosen every gem's required_ruby_version upper bound.
+ override :all, required_ruby_version: :ignore_upper
+
+ # Override one specific gem's required_rubygems_version.
+ override "tricky", required_rubygems_version: nil
+
+ gem "rails", "~> 7.0"
+
+The override only affects resolution and the install-time Ruby/RubyGems
+compatibility checks; `Gemfile.lock` continues to reflect the resolved
+versions, not the rewritten requirements. When resolution still fails,
+Bundler appends the active overrides (with their Gemfile location) to the
+error message so it is clear which override shaped the constraint set.
+
## SOURCE PRIORITY
When attempting to locate a gem to satisfy a gem requirement,
@@ -540,3 +609,31 @@ bundler uses the following priority order:
If multiple global sources are specified, they will be prioritized from
last to first, but this is deprecated since Bundler 1.13, so Bundler prints
a warning and will abort with an error in the future.
+
+## LOCKFILE
+
+By default, Bundler will create a lockfile by adding `.lock` to the end of the
+Gemfile name. To change this, use the `lockfile` method:
+
+ lockfile "/path/to/lockfile.lock"
+
+This is useful when you want to use different lockfiles per ruby version or
+platform.
+
+To avoid writing a lock file, use `false` as the argument:
+
+ lockfile false
+
+This is useful for library development and other situations where the code is
+expected to work with a range of dependency versions.
+
+### LOCKFILE PRECEDENCE
+
+When determining path to the lockfile or whether to create a lockfile, the
+following precedence is used:
+
+1. The `bundle install` `--no-lock` option (which disables lockfile creation).
+1. The `bundle install` `--lockfile` option.
+1. The `BUNDLE_LOCKFILE` environment variable.
+1. The `lockfile` method in the Gemfile.
+1. The default behavior of adding `.lock` to the end of the Gemfile name.
diff --git a/lib/bundler/man/index.txt b/lib/bundler/man/index.txt
index 24f7633e66..f610ba852a 100644
--- a/lib/bundler/man/index.txt
+++ b/lib/bundler/man/index.txt
@@ -8,13 +8,16 @@ bundle-clean(1) bundle-clean.1
bundle-config(1) bundle-config.1
bundle-console(1) bundle-console.1
bundle-doctor(1) bundle-doctor.1
+bundle-env(1) bundle-env.1
bundle-exec(1) bundle-exec.1
+bundle-fund(1) bundle-fund.1
bundle-gem(1) bundle-gem.1
bundle-help(1) bundle-help.1
bundle-info(1) bundle-info.1
bundle-init(1) bundle-init.1
-bundle-inject(1) bundle-inject.1
bundle-install(1) bundle-install.1
+bundle-issue(1) bundle-issue.1
+bundle-licenses(1) bundle-licenses.1
bundle-list(1) bundle-list.1
bundle-lock(1) bundle-lock.1
bundle-open(1) bundle-open.1
@@ -26,4 +29,3 @@ bundle-remove(1) bundle-remove.1
bundle-show(1) bundle-show.1
bundle-update(1) bundle-update.1
bundle-version(1) bundle-version.1
-bundle-viz(1) bundle-viz.1
diff --git a/lib/bundler/match_metadata.rb b/lib/bundler/match_metadata.rb
index 499036ca93..92aeb2e893 100644
--- a/lib/bundler/match_metadata.rb
+++ b/lib/bundler/match_metadata.rb
@@ -2,6 +2,10 @@
module Bundler
module MatchMetadata
+ def matches_current_metadata?
+ matches_current_ruby? && matches_current_rubygems?
+ end
+
def matches_current_ruby?
@required_ruby_version.satisfied_by?(Gem.ruby_version)
end
@@ -9,5 +13,38 @@ module Bundler
def matches_current_rubygems?
@required_rubygems_version.satisfied_by?(Gem.rubygems_version)
end
+
+ def matches_current_metadata_with_overrides?(overrides)
+ matches_current_ruby_with_overrides?(overrides) && matches_current_rubygems_with_overrides?(overrides)
+ end
+
+ def matches_current_ruby_with_overrides?(overrides)
+ effective_required_version(@required_ruby_version, :required_ruby_version, overrides).satisfied_by?(Gem.ruby_version)
+ end
+
+ def matches_current_rubygems_with_overrides?(overrides)
+ effective_required_version(@required_rubygems_version, :required_rubygems_version, overrides).satisfied_by?(Gem.rubygems_version)
+ end
+
+ def expanded_dependencies
+ runtime_dependencies + [
+ metadata_dependency("Ruby", @required_ruby_version),
+ metadata_dependency("RubyGems", @required_rubygems_version),
+ ].compact
+ end
+
+ def metadata_dependency(name, requirement)
+ return if requirement.nil? || requirement.none?
+
+ Gem::Dependency.new("#{name}\0", requirement)
+ end
+
+ private
+
+ def effective_required_version(requirement, field, overrides)
+ return requirement if overrides.nil? || overrides.empty?
+ override = Override.find_for(overrides, name, field)
+ override ? override.apply_to(requirement) : requirement
+ end
end
end
diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb
index 7f7e8227f9..479818e5ec 100644
--- a/lib/bundler/match_platform.rb
+++ b/lib/bundler/match_platform.rb
@@ -1,23 +1,42 @@
# frozen_string_literal: true
-require_relative "gem_helpers"
-
module Bundler
module MatchPlatform
- include GemHelpers
+ def installable_on_platform?(target_platform) # :nodoc:
+ return true if [Gem::Platform::RUBY, nil, target_platform].include?(platform)
+ return true if Gem::Platform.new(platform) === target_platform
- def match_platform(p)
- MatchPlatform.platforms_match?(platform, p)
+ false
end
- def self.platforms_match?(gemspec_platform, local_platform)
- return true if gemspec_platform.nil?
- return true if Gem::Platform::RUBY == gemspec_platform
- return true if local_platform == gemspec_platform
- gemspec_platform = Gem::Platform.new(gemspec_platform)
- return true if gemspec_platform === local_platform
+ def self.select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
+ matching = select_all_platform_match(specs, platform, force_ruby: force_ruby, prefer_locked: prefer_locked)
- false
+ Gem::Platform.sort_and_filter_best_platform_match(matching, platform)
+ end
+
+ def self.select_best_local_platform_match(specs, force_ruby: false)
+ local = Bundler.local_platform
+ matching = select_all_platform_match(specs, local, force_ruby: force_ruby).filter_map(&:materialized_for_installation)
+
+ Gem::Platform.sort_best_platform_match(matching, local)
+ end
+
+ def self.select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
+ matching = specs.select {|spec| spec.installable_on_platform?(force_ruby ? Gem::Platform::RUBY : platform) }
+
+ specs.each(&:force_ruby_platform!) if force_ruby
+
+ if prefer_locked
+ locked_originally = matching.select {|spec| spec.is_a?(::Bundler::LazySpecification) }
+ return locked_originally if locked_originally.any?
+ end
+
+ matching
+ end
+
+ def self.generic_local_platform_is_ruby?
+ Bundler.generic_local_platform == Gem::Platform::RUBY
end
end
end
diff --git a/lib/bundler/match_remote_metadata.rb b/lib/bundler/match_remote_metadata.rb
index 5e46d52441..601af7e55d 100644
--- a/lib/bundler/match_remote_metadata.rb
+++ b/lib/bundler/match_remote_metadata.rb
@@ -6,19 +6,34 @@ module Bundler
# API didn't include that field, so some marshalled specs in the index have it
# set to +nil+.
def matches_current_ruby?
- @required_ruby_version ||= _remote_specification.required_ruby_version || Gem::Requirement.default
-
+ ensure_required_ruby_version_loaded
super
end
def matches_current_rubygems?
- # A fallback is included because the original version of the specification
- # API didn't include that field, so some marshalled specs in the index have it
- # set to +nil+.
- @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default
+ ensure_required_rubygems_version_loaded
+ super
+ end
+
+ def matches_current_ruby_with_overrides?(overrides)
+ ensure_required_ruby_version_loaded
+ super
+ end
+ def matches_current_rubygems_with_overrides?(overrides)
+ ensure_required_rubygems_version_loaded
super
end
+
+ private
+
+ def ensure_required_ruby_version_loaded
+ @required_ruby_version ||= _remote_specification.required_ruby_version || Gem::Requirement.default # rubocop:disable Naming/MemoizedInstanceVariableName
+ end
+
+ def ensure_required_rubygems_version_loaded
+ @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default # rubocop:disable Naming/MemoizedInstanceVariableName
+ end
end
module MatchRemoteMetadata
diff --git a/lib/bundler/materialization.rb b/lib/bundler/materialization.rb
new file mode 100644
index 0000000000..82e48464a7
--- /dev/null
+++ b/lib/bundler/materialization.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+module Bundler
+ #
+ # This class materializes a set of resolved specifications (`LazySpecification`)
+ # for a given gem into the most appropriate real specifications
+ # (`StubSepecification`, `EndpointSpecification`, etc), given a dependency and a
+ # target platform.
+ #
+ class Materialization
+ def initialize(dep, platform, candidates:)
+ @dep = dep
+ @platform = platform
+ @candidates = candidates
+ end
+
+ def complete?
+ specs.any?
+ end
+
+ def specs
+ @specs ||= if @candidates.nil?
+ []
+ elsif platform
+ MatchPlatform.select_best_platform_match(@candidates, platform, force_ruby: dep.force_ruby_platform)
+ else
+ MatchPlatform.select_best_local_platform_match(@candidates, force_ruby: dep.force_ruby_platform || dep.default_force_ruby_platform)
+ end
+ end
+
+ def dependencies
+ (materialized_spec || specs.first).runtime_dependencies.map {|d| [d, platform] }
+ end
+
+ def materialized_spec
+ specs.reject(&:missing?).first&.materialization
+ end
+
+ def completely_missing_specs
+ return [] unless specs.all?(&:missing?)
+
+ specs
+ end
+
+ def partially_missing_specs
+ specs.select(&:missing?)
+ end
+
+ def incomplete_specs
+ return [] if complete?
+
+ @candidates || LazySpecification.new(dep.name, nil, nil)
+ end
+
+ private
+
+ attr_reader :dep, :platform
+ end
+end
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb
index 9d437a0951..494a6d6aef 100644
--- a/lib/bundler/mirror.rb
+++ b/lib/bundler/mirror.rb
@@ -47,7 +47,7 @@ module Bundler
def fetch_valid_mirror_for(uri)
downcased = uri.to_s.downcase
- mirror = @mirrors[downcased] || @mirrors[Bundler::URI(downcased).host] || Mirror.new(uri)
+ mirror = @mirrors[downcased] || @mirrors[Gem::URI(downcased).host] || Mirror.new(uri)
mirror.validate!(@prober)
mirror = Mirror.new(uri) unless mirror.valid?
mirror
@@ -74,7 +74,7 @@ module Bundler
@uri = if uri.nil?
nil
else
- Bundler::URI(uri.to_s)
+ Gem::URI(uri.to_s)
end
@valid = nil
end
@@ -126,7 +126,7 @@ module Bundler
if uri == "all"
@all = true
else
- @uri = Bundler::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
+ @uri = Gem::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
end
@value = value
end
diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb
new file mode 100644
index 0000000000..0e0ec59fd7
--- /dev/null
+++ b/lib/bundler/override.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Override
+ UPPER_BOUND_OPERATORS = ["<", "<="].freeze
+
+ def self.find_for(overrides, name, field)
+ overrides.find {|o| o.target == name && o.field == field } ||
+ overrides.find {|o| o.target == :all && o.field == field }
+ end
+
+ # Attach the given overrides onto every LazySpecification in `specs` so
+ # downstream consumers (LazySpecification#choose_compatible, the install-
+ # time compatibility check, etc.) can read the override list off the spec
+ # itself. Non-LazySpec entries (StubSpecification, Gem::Specification, ...)
+ # are left untouched.
+ def self.attach(specs, overrides)
+ return if overrides.nil? || overrides.empty?
+ specs.each {|s| s.overrides = overrides if s.is_a?(LazySpecification) }
+ end
+
+ attr_reader :target, :field, :operation, :source_location
+
+ def initialize(target, field, operation, source_location: nil)
+ @target = target
+ @field = field
+ @operation = operation
+ @source_location = source_location
+ end
+
+ def source_location_label
+ return nil unless @source_location
+ "#{File.basename(@source_location.path)}:#{@source_location.lineno}"
+ end
+
+ def apply_to(requirement)
+ case operation
+ when nil
+ Gem::Requirement.default
+ when :ignore_upper
+ remove_upper_bounds(requirement)
+ when String
+ Gem::Requirement.new(operation)
+ else
+ raise ArgumentError, "unsupported override operation: #{operation.inspect}"
+ end
+ end
+
+ private
+
+ def remove_upper_bounds(requirement)
+ return Gem::Requirement.default if requirement.nil? || requirement.none?
+
+ preserved = requirement.requirements.filter_map do |op, version|
+ if UPPER_BOUND_OPERATORS.include?(op)
+ nil
+ elsif op == "~>"
+ [">=", version]
+ else
+ [op, version]
+ end
+ end
+
+ return Gem::Requirement.default if preserved.empty?
+
+ Gem::Requirement.new(preserved.map {|op, v| "#{op} #{v}" })
+ end
+ end
+end
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index f3caff8963..faca6bea53 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -62,7 +62,8 @@ module Bundler
if names.any?
names.each do |name|
if index.installed?(name)
- Bundler.rm_rf(index.plugin_path(name))
+ path = index.plugin_path(name).to_s
+ Bundler.rm_rf(path) if index.installed_in_plugin_root?(name)
index.unregister_plugin(name)
Bundler.ui.info "Uninstalled plugin #{name}"
else
@@ -100,7 +101,7 @@ module Bundler
# @param [Pathname] gemfile path
# @param [Proc] block that can be evaluated for (inline) Gemfile
def gemfile_install(gemfile = nil, &inline)
- Bundler.settings.temporary(:frozen => false, :deployment => false) do
+ Bundler.settings.temporary(frozen: false, deployment: false) do
builder = DSL.new
if block_given?
builder.instance_eval(&inline)
@@ -112,7 +113,7 @@ module Bundler
return if definition.dependencies.empty?
- plugins = definition.dependencies.map(&:name).reject {|p| index.installed? p }
+ plugins = definition.dependencies.map(&:name)
installed_specs = Installer.new.install_definition(definition)
save_plugins plugins, installed_specs, builder.inferred_plugins
@@ -194,10 +195,10 @@ module Bundler
@sources[name]
end
- # @param [Hash] The options that are present in the lock file
+ # @param [Hash] The options that are present in the lockfile
# @return [API::Source] the instance of the class that handles the source
# type passed in locked_opts
- def source_from_lock(locked_opts)
+ def from_lock(locked_opts)
src = source(locked_opts["type"])
src.new(locked_opts.merge("uri" => locked_opts["remote"]))
@@ -219,7 +220,7 @@ module Bundler
#
# @param [String] event
def hook(event, *args, &arg_blk)
- return unless Bundler.feature_flag.plugins?
+ return unless Bundler.settings[:plugins]
unless Events.defined_event?(event)
raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
end
@@ -227,7 +228,7 @@ module Bundler
plugins = index.hook_plugins(event)
return unless plugins.any?
- (plugins - @loaded_plugin_names).each {|name| load_plugin(name) }
+ plugins.each {|name| load_plugin(name) }
@hooks_by_event[event].each {|blk| blk.call(*args, &arg_blk) }
end
@@ -239,6 +240,11 @@ module Bundler
Index.new.installed?(plugin)
end
+ # @return [true, false] whether the plugin is loaded
+ def loaded?(plugin)
+ @loaded_plugin_names.include?(plugin)
+ end
+
# Post installation processing and registering with index
#
# @param [Array<String>] plugins list to be installed
@@ -247,10 +253,13 @@ module Bundler
# @param [Array<String>] names of inferred source plugins that can be ignored
def save_plugins(plugins, specs, optional_plugins = [])
plugins.each do |name|
- next if index.installed?(name)
-
spec = specs[name]
+ # It's possible that the `plugin` found in the Gemfile don't appear in the specs. For instance when
+ # calling `BUNDLE_WITHOUT=default bundle install`, the plugins will not get installed.
+ next if spec.nil?
+ next if index.up_to_date?(spec)
+
save_plugin(name, spec, optional_plugins.include?(name))
end
end
@@ -301,7 +310,7 @@ module Bundler
@hooks_by_event = Hash.new {|h, k| h[k] = [] }
load_paths = spec.load_paths
- Bundler.rubygems.add_to_load_path(load_paths)
+ Gem.add_to_load_path(*load_paths)
path = Pathname.new spec.full_gem_path
begin
@@ -329,13 +338,33 @@ module Bundler
# @param [String] name of the plugin
def load_plugin(name)
return unless name && !name.empty?
+ return if loaded?(name)
# Need to ensure before this that plugin root where the rest of gems
# are installed to be on load path to support plugin deps. Currently not
# done to avoid conflicts
path = index.plugin_path(name)
- Bundler.rubygems.add_to_load_path(index.load_paths(name))
+ paths = index.load_paths(name)
+ invalid_paths = paths.reject {|p| File.directory?(p) }
+
+ if invalid_paths.any?
+ Bundler.ui.warn <<~MESSAGE
+ The following plugin paths don't exist: #{invalid_paths.join(", ")}.
+
+ This can happen if the plugin was installed with a different version of Ruby that has since been uninstalled.
+
+ If you would like to reinstall the plugin, run:
+
+ bundler plugin uninstall #{name} && bundler plugin install #{name}
+
+ Continuing without installing plugin #{name}.
+ MESSAGE
+
+ return
+ end
+
+ Gem.add_to_load_path(*paths)
load path.join(PLUGIN_FILE_NAME)
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb
index 67c45bd204..798326673a 100644
--- a/lib/bundler/plugin/api/source.rb
+++ b/lib/bundler/plugin/api/source.rb
@@ -39,7 +39,7 @@ module Bundler
# is present to be compatible with `Definition` and is used by
# rubygems source.
module Source
- attr_reader :uri, :options, :name
+ attr_reader :uri, :options, :name, :checksum_store
attr_accessor :dependency_names
def initialize(opts)
@@ -48,6 +48,7 @@ module Bundler
@uri = opts["uri"]
@type = opts["type"]
@name = opts["name"] || "#{@type} at #{@uri}"
+ @checksum_store = Checksum::Store.new
end
# This is used by the default `spec` method to constructs the
@@ -66,13 +67,21 @@ module Bundler
# to check out same version of gem later.
#
# There options are passed when the source plugin is created from the
- # lock file.
+ # lockfile.
#
# @return [Hash]
def options_to_lock
{}
end
+ # Download the gem specified by the spec at appropriate path.
+ #
+ # A source plugin can implement this method to split the download and the
+ # installation of a gem.
+ #
+ # @return [Boolean] Whether the download of the gem succeeded.
+ def download(spec, opts); end
+
# Install the gem specified by the spec at appropriate path.
# `install_path` provides a sufficient default, if the source can only
# satisfy one gem, but is not binding.
@@ -95,7 +104,7 @@ module Bundler
#
# Note: Do not override if you don't know what you are doing.
def post_install(spec, disable_exts = false)
- opts = { :env_shebang => false, :disable_extensions => disable_exts }
+ opts = { env_shebang: false, disable_extensions: disable_exts }
installer = Bundler::Source::Path::Installer.new(spec, opts)
installer.post_install
end
@@ -106,7 +115,7 @@ module Bundler
def install_path
@install_path ||=
begin
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
+ base_name = File.basename(Gem::URI.parse(uri).normalize.path)
gem_install_dir.join("#{base_name}-#{uri_hash[0..11]}")
end
@@ -130,7 +139,7 @@ module Bundler
Bundler::Index.build do |index|
files.each do |file|
next unless spec = Bundler.load_gemspec(file)
- Bundler.rubygems.set_installed_by_version(spec)
+ spec.installed_by_version = Gem::VERSION
spec.source = self
Bundler.rubygems.validate(spec)
@@ -175,7 +184,7 @@ module Bundler
#
# This is used by `app_cache_path`
def app_cache_dirname
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
+ base_name = File.basename(Gem::URI.parse(uri).normalize.path)
"#{base_name}-#{uri_hash}"
end
@@ -195,6 +204,7 @@ module Bundler
FileUtils.rm_rf(new_cache_path)
FileUtils.cp_r(install_path, new_cache_path)
+ FileUtils.rm_rf(app_cache_path.join(".git"))
FileUtils.touch(app_cache_path.join(".bundlecache"))
end
diff --git a/lib/bundler/plugin/events.rb b/lib/bundler/plugin/events.rb
index bc037d1af5..3fbf60307e 100644
--- a/lib/bundler/plugin/events.rb
+++ b/lib/bundler/plugin/events.rb
@@ -31,6 +31,54 @@ module Bundler
end
# @!parse
+ # A hook called before the Gemfile is evaluated
+ # Includes the Gemfile path and the Lockfile path
+ # GEM_BEFORE_EVAL = "before-eval"
+ define :GEM_BEFORE_EVAL, "before-eval"
+
+ # @!parse
+ # A hook called after the Gemfile is evaluated
+ # Includes a Bundler::Definition
+ # GEM_AFTER_EVAL = "after-eval"
+ define :GEM_AFTER_EVAL, "after-eval"
+
+ # @!parse
+ # A hook called before any gems install
+ # Includes an Array of Bundler::Dependency objects
+ # GEM_BEFORE_INSTALL_ALL = "before-install-all"
+ define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
+
+ # @!parse
+ # A hook called before each individual gem is downloaded from a remote source.
+ # Includes a spec-like object responding to the Gem::Specification API
+ # (for example, a Bundler spec proxy such as Bundler::EndpointSpecification
+ # or Bundler::RemoteSpecification). Does not fire when the gem is already
+ # present at the initial download-cache check.
+ # GEM_BEFORE_FETCH = "before-fetch"
+ define :GEM_BEFORE_FETCH, "before-fetch"
+
+ # @!parse
+ # A hook called after each individual gem is downloaded from a remote source.
+ # Includes a spec-like object responding to the Gem::Specification API
+ # (for example, a Bundler spec proxy such as Bundler::EndpointSpecification
+ # or Bundler::RemoteSpecification). Does not fire when the gem is already
+ # present at the initial download-cache check.
+ # GEM_AFTER_FETCH = "after-fetch"
+ define :GEM_AFTER_FETCH, "after-fetch"
+
+ # @!parse
+ # A hook called before a git source is fetched or checked out.
+ # Includes a Bundler::Source::Git reference.
+ # GIT_BEFORE_FETCH = "before-git-fetch"
+ define :GIT_BEFORE_FETCH, "before-git-fetch"
+
+ # @!parse
+ # A hook called after a git source is fetched or checked out.
+ # Includes a Bundler::Source::Git reference.
+ # GIT_AFTER_FETCH = "after-git-fetch"
+ define :GIT_AFTER_FETCH, "after-git-fetch"
+
+ # @!parse
# A hook called before each individual gem is installed
# Includes a Bundler::ParallelInstaller::SpecInstallation.
# No state, error, post_install_message will be present as nothing has installed yet
@@ -46,16 +94,34 @@ module Bundler
define :GEM_AFTER_INSTALL, "after-install"
# @!parse
- # A hook called before any gems install
- # Includes an Array of Bundler::Dependency objects
- # GEM_BEFORE_INSTALL_ALL = "before-install-all"
- define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
-
- # @!parse
# A hook called after any gems install
# Includes an Array of Bundler::Dependency objects
# GEM_AFTER_INSTALL_ALL = "after-install-all"
define :GEM_AFTER_INSTALL_ALL, "after-install-all"
+
+ # @!parse
+ # A hook called before any gems require
+ # Includes an Array of Bundler::Dependency objects.
+ # GEM_BEFORE_REQUIRE_ALL = "before-require-all"
+ define :GEM_BEFORE_REQUIRE_ALL, "before-require-all"
+
+ # @!parse
+ # A hook called before each individual gem is required
+ # Includes a Bundler::Dependency.
+ # GEM_BEFORE_REQUIRE = "before-require"
+ define :GEM_BEFORE_REQUIRE, "before-require"
+
+ # @!parse
+ # A hook called after each individual gem is required
+ # Includes a Bundler::Dependency.
+ # GEM_AFTER_REQUIRE = "after-require"
+ define :GEM_AFTER_REQUIRE, "after-require"
+
+ # @!parse
+ # A hook called after all gems required
+ # Includes an Array of Bundler::Dependency objects.
+ # GEM_AFTER_REQUIRE_ALL = "after-require-all"
+ define :GEM_AFTER_REQUIRE_ALL, "after-require-all"
end
end
end
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index a2d5eaa38a..1dfb061304 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -31,9 +31,13 @@ module Bundler
begin
load_index(global_index_file, true)
- rescue GenericSystemCallError
+ rescue PermissionError
# no need to fail when on a read-only FS, for example
nil
+ rescue ArgumentError => e
+ # ruby 3.4 checks writability in Dir.tmpdir
+ raise unless e.message&.include?("could not find a temporary directory")
+ nil
end
load_index(local_index_file) if SharedHelpers.in_bundle?
end
@@ -115,6 +119,12 @@ module Bundler
@plugin_paths[name]
end
+ def up_to_date?(spec)
+ path = installed?(spec.name)
+
+ path == spec.full_gem_path
+ end
+
def installed_plugins
@plugin_paths.keys
end
@@ -136,6 +146,14 @@ module Bundler
@hooks[event] || []
end
+ # This plugin is installed inside the .bundle/plugin directory,
+ # and thus is managed solely by Bundler
+ def installed_in_plugin_root?(name)
+ return false unless (path = installed?(name))
+
+ path.start_with?("#{Plugin.root}/")
+ end
+
private
# Reads the index file from the directory and initializes the instance
@@ -145,6 +163,8 @@ module Bundler
# @param [Pathname] index file path
# @param [Boolean] is the index file global index
def load_index(index_file, global = false)
+ base = base_for_index(global)
+
SharedHelpers.filesystem_access(index_file, :read) do |index_f|
valid_file = index_f&.exist? && !index_f.size.zero?
break unless valid_file
@@ -156,8 +176,8 @@ module Bundler
@commands.merge!(index["commands"])
@hooks.merge!(index["hooks"])
- @load_paths.merge!(index["load_paths"])
- @plugin_paths.merge!(index["plugin_paths"])
+ @load_paths.merge!(transform_index_paths(index["load_paths"]) {|p| absolutize_path(p, base) })
+ @plugin_paths.merge!(transform_index_paths(index["plugin_paths"]) {|p| absolutize_path(p, base) })
@sources.merge!(index["sources"]) unless global
end
end
@@ -166,11 +186,13 @@ module Bundler
# instance variables in YAML format. (The instance variables are supposed
# to be only String key value pairs)
def save_index
+ base = base_for_index(false)
+
index = {
"commands" => @commands,
"hooks" => @hooks,
- "load_paths" => @load_paths,
- "plugin_paths" => @plugin_paths,
+ "load_paths" => transform_index_paths(@load_paths) {|p| relativize_path(p, base) },
+ "plugin_paths" => transform_index_paths(@plugin_paths) {|p| relativize_path(p, base) },
"sources" => @sources,
}
@@ -180,6 +202,40 @@ module Bundler
File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) }
end
end
+
+ def base_for_index(global)
+ global ? Plugin.global_root : Plugin.root
+ end
+
+ def transform_index_paths(paths)
+ return {} unless paths
+
+ paths.transform_values do |value|
+ if value.is_a?(Array)
+ value.map {|path| yield path }
+ else
+ yield value
+ end
+ end
+ end
+
+ def relativize_path(path, base)
+ pathname = Pathname.new(path)
+ return path unless pathname.absolute?
+
+ base_path = Pathname.new(base)
+ if pathname == base_path || pathname.to_s.start_with?(base_path.to_s + File::SEPARATOR)
+ pathname.relative_path_from(base_path).to_s
+ else
+ path
+ end
+ end
+
+ def absolutize_path(path, base)
+ pathname = Pathname.new(path)
+ pathname = Pathname.new(base).join(pathname) unless pathname.absolute?
+ pathname.to_s
+ end
end
end
end
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 81ecafa470..9be8b36843 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -10,6 +10,7 @@ module Bundler
class Installer
autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
autoload :Git, File.expand_path("installer/git", __dir__)
+ autoload :Path, File.expand_path("installer/path", __dir__)
def install(names, options)
check_sources_consistency!(options)
@@ -18,8 +19,8 @@ module Bundler
if options[:git]
install_git(names, version, options)
- elsif options[:local_git]
- install_local_git(names, version, options)
+ elsif options[:path]
+ install_path(names, version, options[:path])
else
sources = options[:source] || Gem.sources
install_rubygems(names, version, sources)
@@ -33,7 +34,7 @@ module Bundler
# @return [Hash] map of names to their specs they are installed with
def install_definition(definition)
def definition.lock(*); end
- definition.resolve_remotely!
+ definition.remotely!
specs = definition.specs
install_from_specs specs
@@ -42,23 +43,33 @@ module Bundler
private
def check_sources_consistency!(options)
- if options.key?(:git) && options.key?(:local_git)
- raise InvalidOption, "Remote and local plugin git sources can't be both specified"
+ if (options.keys & [:source, :git, :path]).length > 1
+ raise InvalidOption, "Only one of --source, --git, or --path may be specified"
+ end
+
+ if (options.key?(:branch) || options.key?(:ref)) && !options.key?(:git)
+ raise InvalidOption, "--#{options.key?(:branch) ? "branch" : "ref"} can only be used with git sources"
+ end
+
+ if options.key?(:branch) && options.key?(:ref)
+ raise InvalidOption, "--branch and --ref can't be both specified"
end
end
def install_git(names, version, options)
- uri = options.delete(:git)
- options["uri"] = uri
+ source_list = SourceList.new
+ source = source_list.add_git_source({ "uri" => options[:git],
+ "branch" => options[:branch],
+ "ref" => options[:ref] })
- install_all_sources(names, version, options, options[:source])
+ install_all_sources(names, version, source_list, source)
end
- def install_local_git(names, version, options)
- uri = options.delete(:local_git)
- options["uri"] = uri
+ def install_path(names, version, path)
+ source_list = SourceList.new
+ source = source_list.add_path_source({ "path" => path, "root_path" => SharedHelpers.pwd })
- install_all_sources(names, version, options, options[:source])
+ install_all_sources(names, version, source_list, source)
end
# Installs the plugin from rubygems source and returns the path where the
@@ -70,21 +81,23 @@ module Bundler
#
# @return [Hash] map of names to the specs of plugins installed
def install_rubygems(names, version, sources)
- install_all_sources(names, version, nil, sources)
- end
-
- def install_all_sources(names, version, git_source_options, rubygems_source)
source_list = SourceList.new
- source_list.add_git_source(git_source_options) if git_source_options
- Array(rubygems_source).each {|remote| source_list.add_global_rubygems_remote(remote) } if rubygems_source
+ Array(sources).each {|remote| source_list.add_global_rubygems_remote(remote) }
+
+ install_all_sources(names, version, source_list)
+ end
- deps = names.map {|name| Dependency.new name, version }
+ def install_all_sources(names, version, source_list, source = nil)
+ deps = names.map {|name| Dependency.new(name, version, { "source" => source }) }
Bundler.configure_gem_home_and_path(Plugin.root)
- definition = Definition.new(nil, deps, source_list, true)
- install_definition(definition)
+ Bundler.settings.temporary(deployment: false, frozen: false) do
+ definition = Definition.new(nil, deps, source_list, true)
+
+ install_definition(definition)
+ end
end
# Installs the plugins and deps from the provided specs and returns map of
@@ -97,7 +110,8 @@ module Bundler
paths = {}
specs.each do |spec|
- spec.source.install spec
+ spec.source.download(spec)
+ spec.source.install(spec)
paths[spec.name] = spec
end
diff --git a/lib/bundler/plugin/installer/path.rb b/lib/bundler/plugin/installer/path.rb
new file mode 100644
index 0000000000..58c4924eb0
--- /dev/null
+++ b/lib/bundler/plugin/installer/path.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module Bundler
+ module Plugin
+ class Installer
+ class Path < Bundler::Source::Path
+ def root
+ SharedHelpers.in_bundle? ? Bundler.root : Plugin.root
+ end
+
+ def eql?(other)
+ return unless other.class == self.class
+ expanded_original_path == other.expanded_original_path &&
+ version == other.version
+ end
+
+ alias_method :==, :eql?
+
+ def generate_bin(spec, disable_extensions = false)
+ # Need to find a way without code duplication
+ # For now, we can ignore this
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/plugin/source_list.rb b/lib/bundler/plugin/source_list.rb
index 547661cf2f..d929ade29e 100644
--- a/lib/bundler/plugin/source_list.rb
+++ b/lib/bundler/plugin/source_list.rb
@@ -9,6 +9,10 @@ module Bundler
add_source_to_list Plugin::Installer::Git.new(options), git_sources
end
+ def add_path_source(options = {})
+ add_source_to_list Plugin::Installer::Path.new(options), path_sources
+ end
+
def add_rubygems_source(options = {})
add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
end
@@ -17,13 +21,9 @@ module Bundler
path_sources + git_sources + rubygems_sources + [metadata_source]
end
- def default_source
- git_sources.first || global_rubygems_source
- end
-
private
- def rubygems_aggregate_class
+ def source_class
Plugin::Installer::Rubygems
end
end
diff --git a/lib/bundler/process_lock.rb b/lib/bundler/process_lock.rb
index 0297f80e2c..784b17e363 100644
--- a/lib/bundler/process_lock.rb
+++ b/lib/bundler/process_lock.rb
@@ -2,23 +2,19 @@
module Bundler
class ProcessLock
- def self.lock(bundle_path = Bundler.bundle_path)
+ def self.lock(bundle_path = Bundler.bundle_path, &block)
lock_file_path = File.join(bundle_path, "bundler.lock")
- has_lock = false
+ base_lock_file_path = lock_file_path.delete_suffix(".lock")
- File.open(lock_file_path, "w") do |f|
- f.flock(File::LOCK_EX)
- has_lock = true
- yield
- f.flock(File::LOCK_UN)
+ require "fileutils" if Bundler.rubygems.provides?("< 3.6.0")
+
+ begin
+ SharedHelpers.filesystem_access(lock_file_path, :write) do
+ Gem.open_file_with_lock(base_lock_file_path, &block)
+ end
+ rescue PermissionError
+ block.call
end
- rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP, Errno::EPERM, Errno::EROFS
- # In the case the user does not have access to
- # create the lock file or is using NFS where
- # locks are not available we skip locking.
- yield
- ensure
- FileUtils.rm_f(lock_file_path) if has_lock
end
end
end
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
index 34d7fd116c..dcaaf6af2e 100644
--- a/lib/bundler/remote_specification.rb
+++ b/lib/bundler/remote_specification.rb
@@ -12,7 +12,7 @@ module Bundler
attr_reader :name, :version, :platform
attr_writer :dependencies
- attr_accessor :source, :remote
+ attr_accessor :source, :remote, :locked_platform, :created_at
def initialize(name, version, platform, spec_fetcher)
@name = name
@@ -21,6 +21,11 @@ module Bundler
@platform = Gem::Platform.new(platform)
@spec_fetcher = spec_fetcher
@dependencies = nil
+ @locked_platform = nil
+ end
+
+ def insecurely_materialized?
+ @locked_platform.to_s != @platform.to_s
end
# Needed before installs, since the arch matters then and quick
@@ -29,12 +34,8 @@ module Bundler
@platform = _remote_specification.platform
end
- def identifier
- @__identifier ||= [name, version, @platform.to_s]
- end
-
def full_name
- if @platform == Gem::Platform::RUBY
+ @full_name ||= if @platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@platform}"
@@ -92,6 +93,10 @@ module Bundler
end
end
+ def runtime_dependencies
+ dependencies.select(&:runtime?)
+ end
+
def git_version
return unless loaded_from && source.is_a?(Bundler::Source::Git)
" #{source.revision[0..6]}"
@@ -106,7 +111,7 @@ module Bundler
def _remote_specification
@_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @original_platform])
@_remote_specification || raise(GemspecError, "Gemspec data for #{full_name} was" \
- " missing from the server! Try installing with `--full-index` as a workaround.")
+ " missing from the server!")
end
def method_missing(method, *args, &blk)
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index c17086ea78..422b726980 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -12,13 +12,13 @@ module Bundler
require_relative "resolver/candidate"
require_relative "resolver/incompatibility"
require_relative "resolver/root"
+ require_relative "resolver/strategy"
- include GemHelpers
-
- def initialize(base, gem_version_promoter)
+ def initialize(base, gem_version_promoter, most_specific_locked_platform = nil)
@source_requirements = base.source_requirements
@base = base
@gem_version_promoter = gem_version_promoter
+ @most_specific_locked_platform = most_specific_locked_platform
end
def start
@@ -29,7 +29,7 @@ module Bundler
Bundler.ui.info "Resolving dependencies...", true
- solve_versions(:root => root, :logger => logger)
+ solve_versions(root: root, logger: logger)
end
def setup_solver
@@ -37,31 +37,41 @@ module Bundler
root_version = Resolver::Candidate.new(0)
@all_specs = Hash.new do |specs, name|
- specs[name] = source_for(name).specs.search(name).reject do |s|
- s.dependencies.any? {|d| d.name == name && !d.requirement.satisfied_by?(s.version) } # ignore versions that depend on themselves incorrectly
- end.sort_by {|s| [s.version, s.platform.to_s] }
+ source = source_for(name)
+ matches = source.specs.search(name)
+
+ # Don't bother to check for circular deps when no dependency API are
+ # available, since it's too slow to be usable. That edge case won't work
+ # but resolution other than that should work fine and reasonably fast.
+ if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
+ matches = filter_invalid_self_dependencies(matches, name)
+ end
+
+ specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
+ end
+
+ @all_versions = Hash.new do |candidates, package|
+ candidates[package] = all_versions_for(package)
end
@sorted_versions = Hash.new do |candidates, package|
- candidates[package] = if package.root?
- [root_version]
- else
- all_versions_for(package).sort
- end
+ candidates[package] = filtered_versions_for(package).sort
end
+ @sorted_versions[root] = [root_version]
+
root_dependencies = prepare_dependencies(@requirements, @packages)
@cached_dependencies = Hash.new do |dependencies, package|
- dependencies[package] = if package.root?
- { root_version => root_dependencies }
- else
- Hash.new do |versions, version|
- versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
- end
+ dependencies[package] = Hash.new do |versions, version|
+ deps = version.dependencies.reject {|d| d.name == package.name }
+ deps = apply_metadata_overrides(deps, package.name)
+ versions[version] = to_dependency_hash(deps, @packages)
end
end
+ @cached_dependencies[root] = { root_version => root_dependencies }
+
logger = Bundler::UI::Shell.new
logger.level = debug? ? "debug" : "warn"
@@ -69,15 +79,17 @@ module Bundler
end
def solve_versions(root:, logger:)
- solver = PubGrub::VersionSolver.new(:source => self, :root => root, :logger => logger)
+ solver = PubGrub::VersionSolver.new(source: self, root: root, strategy: Strategy.new(self), logger: logger)
result = solver.solve
- result.map {|package, version| version.to_specs(package) }.flatten.uniq
+ resolved_specs = result.flat_map {|package, version| version.to_specs(package, @most_specific_locked_platform) }
+ Override.attach(resolved_specs, @base.overrides)
+ SpecSet.new(resolved_specs).specs_with_additional_variants_from(@base.locked_specs)
rescue PubGrub::SolveFailure => e
incompatibility = e.incompatibility
- names_to_unlock, names_to_allow_prereleases_for, extended_explanation = find_names_to_relax(incompatibility)
+ names_to_unlock, names_to_allow_prereleases_for, names_to_allow_remote_specs_for, extended_explanation = find_names_to_relax(incompatibility)
- names_to_relax = names_to_unlock + names_to_allow_prereleases_for
+ names_to_relax = names_to_unlock + names_to_allow_prereleases_for + names_to_allow_remote_specs_for
if names_to_relax.any?
if names_to_unlock.any?
@@ -87,11 +99,17 @@ module Bundler
end
if names_to_allow_prereleases_for.any?
- Bundler.ui.debug "Found conflicts with dependencies with prereleases. Will retrying considering prereleases for #{names_to_allow_prereleases_for.join(", ")}...", true
+ Bundler.ui.debug "Found conflicts with dependencies with prereleases. Will retry considering prereleases for #{names_to_allow_prereleases_for.join(", ")}...", true
@base.include_prereleases(names_to_allow_prereleases_for)
end
+ if names_to_allow_remote_specs_for.any?
+ Bundler.ui.debug "Found conflicts with local versions of #{names_to_allow_remote_specs_for.join(", ")}. Will retry considering remote versions...", true
+
+ @base.include_remote_specs(names_to_allow_remote_specs_for)
+ end
+
root, logger = setup_solver
Bundler.ui.debug "Retrying resolution...", true
@@ -105,12 +123,29 @@ module Bundler
explanation << extended_explanation
end
+ override_summary = override_diagnostic_summary
+ explanation << override_summary if override_summary
+
raise SolveFailure.new(explanation)
end
+ def override_diagnostic_summary
+ return nil if @base.overrides.empty?
+
+ lines = ["Bundler applied the following overrides while resolving:"]
+ @base.overrides.each do |override|
+ target = override.target == :all ? ":all" : override.target.inspect
+ location = override.source_location_label
+ lines << " override #{target}, #{override.field}: #{override.operation.inspect}" \
+ "#{location ? " (declared at #{location})" : ""}"
+ end
+ "\n\n#{lines.join("\n")}"
+ end
+
def find_names_to_relax(incompatibility)
names_to_unlock = []
names_to_allow_prereleases_for = []
+ names_to_allow_remote_specs_for = []
extended_explanation = nil
while incompatibility.conflict?
@@ -123,8 +158,10 @@ module Bundler
if base_requirements[name]
names_to_unlock << name
- elsif package.ignores_prereleases?
+ elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
names_to_allow_prereleases_for << name
+ elsif package.prefer_local? && @all_specs[name].any? {|s| !s.is_a?(StubSpecification) }
+ names_to_allow_remote_specs_for << name
end
no_versions_incompat = [cause.incompatibility, cause.satisfier].find {|incompat| incompat.cause.is_a?(PubGrub::Incompatibility::NoVersions) }
@@ -134,7 +171,7 @@ module Bundler
end
end
- [names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, extended_explanation]
+ [names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, names_to_allow_remote_specs_for.uniq, extended_explanation]
end
def parse_dependency(package, dependency)
@@ -144,13 +181,11 @@ module Bundler
requirement_to_range(dependency)
end
- PubGrub::VersionConstraint.new(package, :range => range)
+ PubGrub::VersionConstraint.new(package, range: range)
end
- def versions_for(package, range=VersionRange.any)
- versions = range.select_versions(@sorted_versions[package])
-
- sort_versions(package, versions)
+ def versions_for(package, range = VersionRange.any)
+ range.select_versions(@sorted_versions[package])
end
def no_versions_incompatibility_for(package, unsatisfied_term)
@@ -160,7 +195,7 @@ module Bundler
constraint_string = constraint.constraint_string
requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) }
- if name == "bundler"
+ if name == "bundler" && bundler_pinned_to_current_version?
custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}"
extended_explanation = bundler_not_found_message(requirements)
else
@@ -168,12 +203,15 @@ module Bundler
platforms_explanation = specs_matching_other_platforms.any? ? " for any resolution platforms (#{package.platforms.join(", ")})" : ""
custom_explanation = "#{constraint} could not be found in #{repository_for(package)}#{platforms_explanation}"
+ if hint = cooldown_hint(specs_matching_other_platforms)
+ custom_explanation += " (#{hint})"
+ end
label = "#{name} (#{constraint_string})"
extended_explanation = other_specs_matching_message(specs_matching_other_platforms, label) if specs_matching_other_platforms.any?
end
- Incompatibility.new([unsatisfied_term], :cause => cause, :custom_explanation => custom_explanation, :extended_explanation => extended_explanation)
+ Incompatibility.new([unsatisfied_term], cause: cause, custom_explanation: custom_explanation, extended_explanation: extended_explanation)
end
def debug?
@@ -212,9 +250,9 @@ module Bundler
sorted_versions[high]
end
- range = PubGrub::VersionRange.new(:min => low, :max => high, :include_min => true)
+ range = PubGrub::VersionRange.new(min: low, max: high, include_min: !low.nil?)
- self_constraint = PubGrub::VersionConstraint.new(package, :range => range)
+ self_constraint = PubGrub::VersionConstraint.new(package, range: range)
dep_term = PubGrub::Term.new(dep_constraint, false)
self_term = PubGrub::Term.new(self_constraint, true)
@@ -223,43 +261,87 @@ module Bundler
"current #{dep_package} version is #{dep_constraint.constraint_string}"
end
- PubGrub::Incompatibility.new([self_term, dep_term], :cause => :dependency, :custom_explanation => custom_explanation)
+ PubGrub::Incompatibility.new([self_term, dep_term], cause: :dependency, custom_explanation: custom_explanation)
end
end
def all_versions_for(package)
name = package.name
- results = (@base[name] + filter_prereleases(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
+ results = (@base[name] + filter_specs(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
+
+ if name == "bundler" && !bundler_pinned_to_current_version?
+ bundler_spec = Gem.loaded_specs["bundler"]
+ results << bundler_spec if bundler_spec
+ end
+
locked_requirement = base_requirements[name]
results = filter_matching_specs(results, locked_requirement) if locked_requirement
- versions = results.group_by(&:version).reduce([]) do |groups, (version, specs)|
- platform_specs = package.platforms.flat_map {|platform| select_best_platform_match(specs, platform) }
- next groups if platform_specs.empty?
+ results.group_by(&:version).reduce([]) do |groups, (version, specs)|
+ platform_specs = package.platform_specs(specs)
+
+ # If package is a top-level dependency,
+ # candidate is only valid if there are matching versions for all resolution platforms.
+ #
+ # If package is not a top-level deependency,
+ # then it's not necessary that it has matching versions for all platforms, since it may have been introduced only as
+ # a dependency for a platform specific variant, so it will only need to have a valid version for that platform.
+ #
+ if package.top_level?
+ next groups if platform_specs.any?(&:empty?)
+ else
+ next groups if platform_specs.all?(&:empty?)
+ end
+
+ ruby_specs = MatchPlatform.select_best_platform_match(specs, Gem::Platform::RUBY)
+ ruby_group = Resolver::SpecGroup.new(ruby_specs)
+
+ unless ruby_group.empty?
+ platform_specs.each do |s|
+ ruby_group.merge(Resolver::SpecGroup.new(s))
+ end
- ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
- groups << Resolver::Candidate.new(version, :specs => ruby_specs) if ruby_specs.any?
+ groups << Resolver::Candidate.new(version, group: ruby_group, priority: -1)
+ next groups if package.force_ruby_platform?
+ end
- next groups if platform_specs == ruby_specs
+ platform_group = Resolver::SpecGroup.new(platform_specs.flatten.uniq)
+ next groups if platform_group == ruby_group
- groups << Resolver::Candidate.new(version, :specs => platform_specs)
+ groups << Resolver::Candidate.new(version, group: platform_group, priority: 1)
groups
end
-
- sort_versions(package, versions)
end
def source_for(name)
@source_requirements[name] || @source_requirements[:default]
end
+ def default_bundler_source
+ @source_requirements[:default_bundler]
+ end
+
+ def bundler_pinned_to_current_version?
+ !default_bundler_source.nil?
+ end
+
def name_for_explicit_dependency_source
Bundler.default_gemfile.basename.to_s
rescue StandardError
"Gemfile"
end
+ def raise_incomplete!(incomplete_specs)
+ raise_not_found!(@base.get_package(incomplete_specs.first.name))
+ end
+
+ def sort_versions_by_preferred(package, versions)
+ @gem_version_promoter.sort_versions(package, versions)
+ end
+
+ private
+
def raise_not_found!(package)
name = package.name
source = source_for(name)
@@ -273,24 +355,65 @@ module Bundler
end
specs_matching_requirement = filter_matching_specs(specs, package.dependency.requirement)
- if specs_matching_requirement.any?
+ not_found_message = if specs_matching_requirement.any?
specs = specs_matching_requirement
matching_part = requirement_label
platforms = package.platforms
- platform_label = platforms.size == 1 ? "platform '#{platforms.first}" : "platforms '#{platforms.join("', '")}"
- requirement_label = "#{requirement_label}' with #{platform_label}"
+
+ if platforms.size == 1
+ "Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
+ else
+ "Could not find gems matching '#{requirement_label}' valid for all resolution platforms (#{platforms.join(", ")})"
+ end
+ else
+ "Could not find gem '#{requirement_label}'"
end
- message = String.new("Could not find gem '#{requirement_label}' in #{source}#{cache_message}.\n")
+ message = String.new("#{not_found_message} in #{source}#{cache_message}.\n")
if specs.any?
message << "\n#{other_specs_matching_message(specs, matching_part)}"
end
+ if hint = cooldown_hint(specs_matching_requirement)
+ message << "\n\n#{hint}."
+ end
+
+ if specs_matching_requirement.any? && (hint = platform_mismatch_hint)
+ message << "\n\n#{hint}"
+ end
+
raise GemNotFound, message
end
- private
+ def platform_mismatch_hint
+ locked_platforms = Bundler.locked_gems&.platforms
+ return unless locked_platforms
+
+ local_platform = Bundler.local_platform
+ return if locked_platforms.include?(local_platform)
+ return if locked_platforms.any? {|p| p == Gem::Platform::RUBY }
+
+ "Your current platform (#{local_platform}) is not included in the lockfile's platforms (#{locked_platforms.join(", ")}). " \
+ "Add the current platform to the lockfile with\n`bundle lock --add-platform #{local_platform}` and try again."
+ rescue GemfileNotFound
+ nil
+ end
+
+ def filtered_versions_for(package)
+ @gem_version_promoter.filter_versions(package, @all_versions[package])
+ end
+
+ def raise_all_versions_filtered_out!(package)
+ level = @gem_version_promoter.level
+ name = package.name
+ locked_version = package.locked_version
+ requirement = package.dependency
+
+ raise GemNotFound,
+ "#{name} is locked to #{locked_version}, while Gemfile is requesting #{requirement}. " \
+ "--strict --#{level} was specified, but there are no #{level} level upgrades from #{locked_version} satisfying #{requirement}, so version solving has failed"
+ end
def filter_matching_specs(specs, requirements)
Array(requirements).flat_map do |requirement|
@@ -298,24 +421,76 @@ module Bundler
end
end
+ def filter_specs(specs, package)
+ filter_remote_specs(filter_cooldown(filter_prereleases(specs, package)), package)
+ end
+
def filter_prereleases(specs, package)
- return specs unless package.ignores_prereleases?
+ return specs unless package.ignores_prereleases? && specs.size > 1
specs.reject {|s| s.version.prerelease? }
end
- def requirement_satisfied_by?(requirement, spec)
- requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
+ def filter_cooldown(specs)
+ return specs if specs.empty?
+ excluded_versions = cooldown_excluded_versions(specs)
+ return specs if excluded_versions.empty?
+ specs.reject {|s| excluded_versions.include?([s.name, s.version]) }
+ end
+
+ def cooldown_excluded_versions(specs)
+ excluded = {}
+ specs.each do |spec|
+ next unless cooldown_excluded?(spec)
+ excluded[[spec.name, spec.version]] = true
+ end
+ excluded
+ end
+
+ def cooldown_hint(specs)
+ excluded_versions = cooldown_excluded_versions(specs)
+ return nil if excluded_versions.empty?
+ "#{excluded_versions.size} version#{"s" if excluded_versions.size > 1} excluded by the cooldown setting; pass `--cooldown 0` to bypass"
+ end
+
+ def cooldown_excluded?(spec)
+ return false unless spec.respond_to?(:created_at) && spec.created_at
+ return false unless spec.respond_to?(:remote) && spec.remote
+ days = spec.remote.effective_cooldown
+ return false if days.nil? || days <= 0
+ (cooldown_now - spec.created_at) < (days * 86_400)
end
- def sort_versions(package, versions)
- if versions.size > 1
- @gem_version_promoter.sort_versions(package, versions).reverse
+ def cooldown_now
+ @cooldown_now ||= Time.now
+ end
+
+ def filter_remote_specs(specs, package)
+ if package.prefer_local?
+ local_specs = specs.select {|s| s.is_a?(StubSpecification) }
+
+ if local_specs.empty?
+ package.consider_remote_versions!
+ specs
+ else
+ local_specs
+ end
else
- versions
+ specs
+ end
+ end
+
+ # Ignore versions that depend on themselves incorrectly
+ def filter_invalid_self_dependencies(specs, name)
+ specs.reject do |s|
+ s.dependencies.any? {|d| d.name == name && !d.requirement.satisfied_by?(s.version) }
end
end
+ def requirement_satisfied_by?(requirement, spec)
+ requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
+ end
+
def repository_for(package)
source_for(package.name)
end
@@ -325,23 +500,37 @@ module Bundler
end
def prepare_dependencies(requirements, packages)
- to_dependency_hash(requirements, packages).map do |dep_package, dep_constraint|
+ to_dependency_hash(requirements, packages).filter_map do |dep_package, dep_constraint|
name = dep_package.name
next [dep_package, dep_constraint] if name == "bundler"
- versions = versions_for(dep_package, dep_constraint.range)
- if versions.empty? && dep_package.ignores_prereleases?
- @sorted_versions.delete(dep_package)
- dep_package.consider_prereleases!
- versions = versions_for(dep_package, dep_constraint.range)
+ dep_range = dep_constraint.range
+ versions = versions_for(dep_package, dep_range)
+ if versions.empty?
+ if dep_package.ignores_prereleases? || dep_package.prefer_local?
+ @all_versions.delete(dep_package)
+ @sorted_versions.delete(dep_package)
+ end
+ dep_package.consider_prereleases! if dep_package.ignores_prereleases?
+ dep_package.consider_remote_versions! if dep_package.prefer_local?
+ versions = versions_for(dep_package, dep_range)
+ end
+
+ if versions.empty? && select_all_versions(dep_package, dep_range).any?
+ raise_all_versions_filtered_out!(dep_package)
end
+
next [dep_package, dep_constraint] unless versions.empty?
next unless dep_package.current_platform?
raise_not_found!(dep_package)
- end.compact.to_h
+ end.to_h
+ end
+
+ def select_all_versions(package, range)
+ range.select_versions(@all_versions[package])
end
def other_specs_matching_message(specs, requirement)
@@ -352,26 +541,26 @@ module Bundler
def requirement_to_range(requirement)
ranges = requirement.requirements.map do |(op, version)|
- ver = Resolver::Candidate.new(version).generic!
- platform_ver = Resolver::Candidate.new(version).platform_specific!
+ ver = Resolver::Candidate.new(version, priority: -1)
+ platform_ver = Resolver::Candidate.new(version, priority: 1)
case op
when "~>"
name = "~> #{ver}"
bump = Resolver::Candidate.new(version.bump.to_s + ".A")
- PubGrub::VersionRange.new(:name => name, :min => ver, :max => bump, :include_min => true)
+ PubGrub::VersionRange.new(name: name, min: ver, max: bump, include_min: true)
when ">"
- PubGrub::VersionRange.new(:min => platform_ver)
+ PubGrub::VersionRange.new(min: platform_ver)
when ">="
- PubGrub::VersionRange.new(:min => ver, :include_min => true)
+ PubGrub::VersionRange.new(min: ver, include_min: true)
when "<"
- PubGrub::VersionRange.new(:max => ver)
+ PubGrub::VersionRange.new(max: ver)
when "<="
- PubGrub::VersionRange.new(:max => platform_ver, :include_max => true)
+ PubGrub::VersionRange.new(max: platform_ver, include_max: true)
when "="
- PubGrub::VersionRange.new(:min => ver, :max => platform_ver, :include_min => true, :include_max => true)
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true)
when "!="
- PubGrub::VersionRange.new(:min => ver, :max => platform_ver, :include_min => true, :include_max => true).invert
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true).invert
else
raise "bad version specifier: #{op}"
end
@@ -381,7 +570,7 @@ module Bundler
end
def to_dependency_hash(dependencies, packages)
- dependencies.inject({}) do |deps, dep|
+ apply_overrides(dependencies).inject({}) do |deps, dep|
package = packages[dep.name]
current_req = deps[package]
@@ -397,8 +586,35 @@ module Bundler
end
end
+ def apply_overrides(dependencies)
+ return dependencies if @base.overrides.empty?
+
+ dependencies.map do |dep|
+ override = Override.find_for(@base.overrides, dep.name, :version)
+ next dep unless override
+ Gem::Dependency.new(dep.name, override.apply_to(dep.requirement))
+ end
+ end
+
+ METADATA_DEP_FIELD = {
+ "Ruby\0" => :required_ruby_version,
+ "RubyGems\0" => :required_rubygems_version,
+ }.freeze
+
+ def apply_metadata_overrides(dependencies, name)
+ return dependencies if @base.overrides.empty?
+
+ dependencies.map do |dep|
+ field = METADATA_DEP_FIELD[dep.name]
+ next dep unless field
+ override = Override.find_for(@base.overrides, name, field)
+ next dep unless override
+ Gem::Dependency.new(dep.name, override.apply_to(dep.requirement))
+ end
+ end
+
def bundler_not_found_message(conflict_dependencies)
- candidate_specs = filter_matching_specs(source_for(:default_bundler).specs.search("bundler"), conflict_dependencies)
+ candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies)
if candidate_specs.any?
target_version = candidate_specs.last.version
diff --git a/lib/bundler/resolver/base.rb b/lib/bundler/resolver/base.rb
index 6921c047a7..00bdd08303 100644
--- a/lib/bundler/resolver/base.rb
+++ b/lib/bundler/resolver/base.rb
@@ -5,10 +5,12 @@ require_relative "package"
module Bundler
class Resolver
class Base
- attr_reader :packages, :requirements, :source_requirements
+ attr_reader :packages, :requirements, :source_requirements, :locked_specs, :overrides
def initialize(source_requirements, dependencies, base, platforms, options)
+ @overrides = options.delete(:overrides) || []
@source_requirements = source_requirements
+ @locked_specs = options[:locked_specs]
@base = base
@@ -16,7 +18,7 @@ module Bundler
hash[name] = Package.new(name, platforms, **options)
end
- @requirements = dependencies.map do |dep|
+ @requirements = dependencies.filter_map do |dep|
dep_platforms = dep.gem_platforms(platforms)
# Dependencies scoped to external platforms are ignored
@@ -24,10 +26,10 @@ module Bundler
name = dep.name
- @packages[name] = Package.new(name, dep_platforms, **options.merge(:dependency => dep))
+ @packages[name] = Package.new(name, dep_platforms, **options.merge(dependency: dep))
dep
- end.compact
+ end
end
def [](name)
@@ -35,9 +37,7 @@ module Bundler
end
def delete(specs)
- specs.each do |spec|
- @base.delete(spec)
- end
+ @base.delete(specs)
end
def get_package(name)
@@ -49,10 +49,18 @@ module Bundler
end
def unlock_names(names)
- names.each do |name|
- @base.delete_by_name(name)
-
- @base_requirements.delete(name)
+ indirect_pins = indirect_pins(names)
+
+ if indirect_pins.any?
+ loosen_names(indirect_pins)
+ else
+ pins = pins(names)
+
+ if pins.any?
+ loosen_names(pins)
+ else
+ unrestrict_names(names)
+ end
end
end
@@ -62,11 +70,45 @@ module Bundler
end
end
+ def include_remote_specs(names)
+ names.each do |name|
+ get_package(name).consider_remote_versions!
+ end
+ end
+
private
+ def indirect_pins(names)
+ names.select {|name| @base_requirements[name].exact? && @requirements.none? {|dep| dep.name == name } }
+ end
+
+ def pins(names)
+ names.select {|name| @base_requirements[name].exact? }
+ end
+
+ def loosen_names(names)
+ names.each do |name|
+ version = @base_requirements[name].requirements.first[1]
+
+ @base_requirements[name] = Gem::Requirement.new(">= #{version}")
+
+ @base.delete_by_name(name)
+ end
+ end
+
+ def unrestrict_names(names)
+ names.each do |name|
+ @base_requirements.delete(name)
+ end
+ end
+
def build_base_requirements
base_requirements = {}
@base.each do |ls|
+ if ls.source_changed? && ls.source.specs.search(ls.name).empty?
+ raise GemNotFound, "Could not find gem '#{ls.name}' in #{ls.source}"
+ end
+
req = Gem::Requirement.new(ls.version)
base_requirements[ls.name] = req
end
diff --git a/lib/bundler/resolver/candidate.rb b/lib/bundler/resolver/candidate.rb
index e695ef08ee..5298b2530f 100644
--- a/lib/bundler/resolver/candidate.rb
+++ b/lib/bundler/resolver/candidate.rb
@@ -15,41 +15,29 @@ module Bundler
# considered separately.
#
# Some candidates may also keep some information explicitly about the
- # package the refer to. These candidates are referred to as "canonical" and
+ # package they refer to. These candidates are referred to as "canonical" and
# are used when materializing resolution results back into RubyGems
- # specifications that can be installed, written to lock files, and so on.
+ # specifications that can be installed, written to lockfiles, and so on.
#
class Candidate
include Comparable
attr_reader :version
- def initialize(version, specs: [])
- @spec_group = Resolver::SpecGroup.new(specs)
+ def initialize(version, group: nil, priority: -1)
+ @spec_group = group || SpecGroup.new([])
@version = Gem::Version.new(version)
- @ruby_only = specs.map(&:platform).uniq == [Gem::Platform::RUBY]
+ @priority = priority
end
def dependencies
@spec_group.dependencies
end
- def to_specs(package)
+ def to_specs(package, most_specific_locked_platform)
return [] if package.meta?
- @spec_group.to_specs(package.force_ruby_platform?)
- end
-
- def generic!
- @ruby_only = true
-
- self
- end
-
- def platform_specific!
- @ruby_only = false
-
- self
+ @spec_group.to_specs(package.force_ruby_platform?, most_specific_locked_platform)
end
def prerelease?
@@ -60,35 +48,38 @@ module Bundler
@version.segments
end
- def sort_obj
- [@version, @ruby_only ? -1 : 1]
- end
-
def <=>(other)
return unless other.is_a?(self.class)
- sort_obj <=> other.sort_obj
+ version_comparison = version <=> other.version
+ return version_comparison unless version_comparison.zero?
+
+ priority <=> other.priority
end
def ==(other)
return unless other.is_a?(self.class)
- sort_obj == other.sort_obj
+ version == other.version && priority == other.priority
end
def eql?(other)
return unless other.is_a?(self.class)
- sort_obj.eql?(other.sort_obj)
+ version.eql?(other.version) && priority.eql?(other.priority)
end
def hash
- sort_obj.hash
+ [@version, @priority].hash
end
def to_s
@version.to_s
end
+
+ protected
+
+ attr_reader :priority
end
end
end
diff --git a/lib/bundler/resolver/incompatibility.rb b/lib/bundler/resolver/incompatibility.rb
index c61151fbeb..4ac1b2e1ea 100644
--- a/lib/bundler/resolver/incompatibility.rb
+++ b/lib/bundler/resolver/incompatibility.rb
@@ -8,7 +8,7 @@ module Bundler
def initialize(terms, cause:, custom_explanation: nil, extended_explanation: nil)
@extended_explanation = extended_explanation
- super(terms, :cause => cause, :custom_explanation => custom_explanation)
+ super(terms, cause: cause, custom_explanation: custom_explanation)
end
end
end
diff --git a/lib/bundler/resolver/package.rb b/lib/bundler/resolver/package.rb
index 7499a75006..3906be3f57 100644
--- a/lib/bundler/resolver/package.rb
+++ b/lib/bundler/resolver/package.rb
@@ -15,13 +15,24 @@ module Bundler
class Package
attr_reader :name, :platforms, :dependency, :locked_version
- def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil)
+ def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefer_local: false, dependency: nil, new_platforms: [])
@name = name
@platforms = platforms
- @locked_version = locked_specs[name].first&.version
+ @locked_version = locked_specs.version_for(name)
@unlock = unlock
@dependency = dependency || Dependency.new(name, @locked_version)
+ @platforms |= [Gem::Platform::RUBY] if @dependency.default_force_ruby_platform
+ @top_level = !dependency.nil?
@prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
+ @prefer_local = prefer_local
+ @new_platforms = new_platforms
+ end
+
+ def platform_specs(specs)
+ platforms.map do |platform|
+ prefer_locked = @new_platforms.include?(platform) ? false : !unlock?
+ MatchPlatform.select_best_platform_match(specs, platform, prefer_locked: prefer_locked)
+ end
end
def to_s
@@ -32,6 +43,10 @@ module Bundler
false
end
+ def top_level?
+ @top_level
+ end
+
def meta?
@name.end_with?("\0")
end
@@ -45,7 +60,7 @@ module Bundler
end
def unlock?
- @unlock.empty? || @unlock.include?(name)
+ @unlock == true || @unlock.include?(name)
end
def ignores_prereleases?
@@ -60,6 +75,14 @@ module Bundler
@prerelease = :consider_last
end
+ def prefer_local?
+ @prefer_local
+ end
+
+ def consider_remote_versions!
+ @prefer_local = false
+ end
+
def force_ruby_platform?
@dependency.force_ruby_platform
end
diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb
index b44c19a73f..ac6ba86c4c 100644
--- a/lib/bundler/resolver/spec_group.rb
+++ b/lib/bundler/resolver/spec_group.rb
@@ -3,6 +3,8 @@
module Bundler
class Resolver
class SpecGroup
+ attr_reader :specs
+
def initialize(specs)
@specs = specs
end
@@ -23,11 +25,11 @@ module Bundler
@source ||= exemplary_spec.source
end
- def to_specs(force_ruby_platform)
+ def to_specs(force_ruby_platform, most_specific_locked_platform)
@specs.map do |s|
- lazy_spec = LazySpecification.new(name, version, s.platform, source)
+ lazy_spec = LazySpecification.from_spec(s)
lazy_spec.force_ruby_platform = force_ruby_platform
- lazy_spec.dependencies.replace s.dependencies
+ lazy_spec.most_specific_locked_platform = most_specific_locked_platform
lazy_spec
end
end
@@ -37,45 +39,35 @@ module Bundler
end
def dependencies
- @dependencies ||= @specs.map do |spec|
- __dependencies(spec) + metadata_dependencies(spec)
- end.flatten.uniq
+ @dependencies ||= @specs.flat_map(&:expanded_dependencies).uniq.sort
end
- protected
-
- def sorted_spec_names
- @sorted_spec_names ||= @specs.map(&:full_name).sort
+ def ==(other)
+ sorted_spec_names == other.sorted_spec_names
end
- private
+ def merge(other)
+ return false unless equivalent?(other)
- def exemplary_spec
- @specs.first
- end
+ @specs |= other.specs
- def __dependencies(spec)
- dependencies = []
- spec.dependencies.each do |dep|
- next if dep.type == :development
- dependencies << Dependency.new(dep.name, dep.requirement)
- end
- dependencies
+ true
end
- def metadata_dependencies(spec)
- return [] if spec.is_a?(LazySpecification)
+ protected
- [
- metadata_dependency("Ruby", spec.required_ruby_version),
- metadata_dependency("RubyGems", spec.required_rubygems_version),
- ].compact
+ def sorted_spec_names
+ @specs.map(&:full_name).sort
end
- def metadata_dependency(name, requirement)
- return if requirement.nil? || requirement.none?
+ private
+
+ def equivalent?(other)
+ name == other.name && version == other.version && source == other.source && dependencies == other.dependencies
+ end
- Dependency.new("#{name}\0", requirement)
+ def exemplary_spec
+ @specs.first
end
end
end
diff --git a/lib/bundler/resolver/strategy.rb b/lib/bundler/resolver/strategy.rb
new file mode 100644
index 0000000000..7519d38968
--- /dev/null
+++ b/lib/bundler/resolver/strategy.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Resolver
+ class Strategy
+ def initialize(source)
+ @source = source
+ @package_priority_cache = {}
+ end
+
+ def next_package_and_version(unsatisfied)
+ package, range = next_term_to_try_from(unsatisfied)
+
+ [package, most_preferred_version_of(package, range).first]
+ end
+
+ private
+
+ def next_term_to_try_from(unsatisfied)
+ unsatisfied.min_by do |package, range|
+ @package_priority_cache[[package, range]] ||= begin
+ matching_versions = @source.versions_for(package, range)
+ higher_versions = @source.versions_for(package, range.upper_invert)
+
+ [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
+ end
+ end
+ end
+
+ def most_preferred_version_of(package, range)
+ versions = @source.versions_for(package, range)
+
+ # Conditional avoids (among other things) calling
+ # sort_versions_by_preferred with the root package
+ if versions.size > 1
+ @source.sort_versions_by_preferred(package, versions)
+ else
+ versions
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index 2415ade200..49b0f63838 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -6,6 +6,8 @@ module Bundler
attr_accessor :name, :total_runs, :current_run
class << self
+ attr_accessor :default_base_delay
+
def default_attempts
default_retries + 1
end
@@ -16,11 +18,17 @@ module Bundler
end
end
- def initialize(name, exceptions = nil, retries = self.class.default_retries)
+ # Set default base delay for exponential backoff
+ self.default_base_delay = 1.0
+
+ def initialize(name, exceptions = nil, retries = self.class.default_retries, opts = {})
@name = name
@retries = retries
@exceptions = Array(exceptions) || []
@total_runs = @retries + 1 # will run once, then upto attempts.times
+ @base_delay = opts[:base_delay] || self.class.default_base_delay
+ @max_delay = opts[:max_delay] || 60.0
+ @jitter = opts[:jitter] || 0.5
end
def attempt(&block)
@@ -48,15 +56,33 @@ module Bundler
Bundler.ui.info "" unless Bundler.ui.debug?
raise e
end
- return true unless name
- Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this
- Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
+ if name
+ Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this
+ Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", true
+ end
+ backoff_sleep if @base_delay > 0
+ true
+ end
+
+ def backoff_sleep
+ # Exponential backoff: delay = base_delay * 2^(attempt - 1)
+ # Add jitter to prevent thundering herd: random value between 0 and jitter seconds
+ delay = @base_delay * (2**(@current_run - 1))
+ delay = [@max_delay, delay].min
+ jitter_amount = rand * @jitter
+ total_delay = delay + jitter_amount
+ Bundler.ui.debug "Sleeping for #{total_delay.round(2)} seconds before retry"
+ sleep(total_delay)
+ end
+
+ def sleep(duration)
+ Kernel.sleep(duration)
end
def keep_trying?
return true if current_run.zero?
return false if last_attempt?
- return true if @failed
+ true if @failed
end
def last_attempt?
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
index 3b3a0583a5..5e52f38c8f 100644
--- a/lib/bundler/ruby_dsl.rb
+++ b/lib/bundler/ruby_dsl.rb
@@ -3,16 +3,65 @@
module Bundler
module RubyDsl
def ruby(*ruby_version)
- options = ruby_version.last.is_a?(Hash) ? ruby_version.pop : {}
+ options = ruby_version.pop if ruby_version.last.is_a?(Hash)
ruby_version.flatten!
- raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
- raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
- if options[:engine] == "ruby" && options[:engine_version] &&
- ruby_version != Array(options[:engine_version])
- raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
+ if options
+ patchlevel = options[:patchlevel]
+ engine = options[:engine]
+ engine_version = options[:engine_version]
+
+ raise GemfileError, "Please define :engine_version" if engine && engine_version.nil?
+ raise GemfileError, "Please define :engine" if engine_version && engine.nil?
+
+ if options[:file]
+ raise GemfileError, "Do not pass version argument when using :file option" unless ruby_version.empty?
+ ruby_version << normalize_ruby_file(options[:file])
+ end
+
+ if engine == "ruby" && engine_version && ruby_version != Array(engine_version)
+ raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
+ end
+ end
+
+ @ruby_version = RubyVersion.new(ruby_version, patchlevel, engine, engine_version)
+ end
+
+ # Support the various file formats found in .ruby-version files.
+ #
+ # 3.2.2
+ # ruby-3.2.2
+ #
+ # Also supports .tool-versions files for asdf. Lines not starting with "ruby" are ignored.
+ #
+ # ruby 2.5.1 # comment is ignored
+ # ruby 2.5.1# close comment and extra spaces doesn't confuse
+ #
+ # Intentionally does not support `3.2.1@gemset` since rvm recommends using .ruby-gemset instead
+ #
+ # Loads the file relative to the dirname of the Gemfile itself.
+ def normalize_ruby_file(filename)
+ file_content = Bundler.read_file(gemfile.dirname.join(filename))
+ # match "ruby-3.2.2", ruby = "3.2.2", ruby = '3.2.2' or "ruby 3.2.2" capturing version string up to the first space or comment
+ version_match = /^ # Start of line
+ ruby # Literal "ruby"
+ [\s-]* # Optional whitespace or hyphens (for "ruby-3.2.2" format)
+ (?:=\s*)? # Optional equals sign with whitespace (for ruby = "3.2.2" format)
+ (?:
+ "([^"]+)" # Double quoted version
+ |
+ '([^']+)' # Single quoted version
+ |
+ ([^\s#"']+) # Unquoted version
+ )
+ /x.match(file_content)
+ if version_match
+ version_match[1] || version_match[2] || version_match[3]
+ else
+ file_content.strip
end
- @ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
+ rescue Errno::ENOENT
+ raise GemfileError, "Could not find version file #{filename}"
end
end
end
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index b6bd24e41c..aeff07582e 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -23,7 +23,13 @@ module Bundler
# specified must match the version.
@versions = Array(versions).map do |v|
- op, v = Gem::Requirement.parse(v)
+ normalized_v = normalize_version(v)
+
+ unless Gem::Requirement::PATTERN.match?(normalized_v)
+ raise InvalidArgumentError, "#{v} is not a valid requirement on the Ruby version"
+ end
+
+ op, v = Gem::Requirement.parse(normalized_v)
op == "=" ? v.to_s : "#{op} #{v}"
end
@@ -37,7 +43,6 @@ module Bundler
def to_s(versions = self.versions)
output = String.new("ruby #{versions_string(versions)}")
- output << "p#{patchlevel}" if patchlevel && patchlevel != "-1"
output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
output
@@ -49,7 +54,7 @@ module Bundler
(\d+\.\d+\.\d+(?:\.\S+)?) # ruby version
(?:p(-?\d+))? # optional patchlevel
(?:\s\((\S+)\s(.+)\))? # optional engine info
- /xo.freeze
+ /xo
# Returns a RubyVersion from the given string.
# @param [String] the version string to match.
@@ -66,8 +71,7 @@ module Bundler
def ==(other)
versions == other.versions &&
engine == other.engine &&
- engine_versions == other.engine_versions &&
- patchlevel == other.patchlevel
+ engine_versions == other.engine_versions
end
def host
@@ -92,8 +96,6 @@ module Bundler
[:version, versions_string(versions), versions_string(other.versions)]
elsif @input_engine && !matches?(engine_versions, other.engine_gem_version)
[:engine_version, versions_string(engine_versions), versions_string(other.engine_versions)]
- elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
- [:patchlevel, patchlevel, other.patchlevel]
end
end
@@ -107,11 +109,18 @@ module Bundler
ruby_engine_version = RUBY_ENGINE == "ruby" ? ruby_version : RUBY_ENGINE_VERSION.dup
patchlevel = RUBY_PATCHLEVEL.to_s
- @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
+ @system ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
end
private
+ # Ruby's official preview version format uses a `-`: Example: 3.3.0-preview2
+ # However, RubyGems recognizes preview version format with a `.`: Example: 3.3.0.preview2
+ # Returns version string after replacing `-` with `.`
+ def normalize_version(version)
+ version.tr("-", ".")
+ end
+
def matches?(requirements, version)
# Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index d298a17672..4ad2bdf46f 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true
-require "pathname"
-
-require "rubygems/specification"
+require "rubygems" unless defined?(Gem)
# We can't let `Gem::Source` be autoloaded in the `Gem::Specification#source`
# redefinition below, so we need to load it upfront. The reason is that if
@@ -15,38 +13,199 @@ require "rubygems/specification"
# `Gem::Source` from the redefined `Gem::Specification#source`.
require "rubygems/source"
-require_relative "match_metadata"
-require_relative "force_platform"
-require_relative "match_platform"
-
-# Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler
-# versions and ignore patchlevels
-# (https://github.com/rubygems/rubygems/pull/5472,
-# https://github.com/rubygems/rubygems/pull/5486). May be removed once RubyGems
-# 3.3.12 support is dropped.
-unless Gem.ruby_version.to_s == RUBY_VERSION || RUBY_PATCHLEVEL == -1
- Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION))
-end
-
module Gem
+ # Can be removed once RubyGems 3.5.11 support is dropped
+ unless Gem.respond_to?(:freebsd_platform?)
+ def self.freebsd_platform?
+ RbConfig::CONFIG["host_os"].to_s.include?("bsd")
+ end
+ end
+
+ # Can be removed once RubyGems 3.5.18 support is dropped
+ unless Gem.respond_to?(:open_file_with_lock)
+ class << self
+ remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)
+
+ def open_file_with_flock(path, &block)
+ # read-write mode is used rather than read-only in order to support NFS
+ mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
+ mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
+
+ File.open(path, mode) do |io|
+ begin
+ io.flock(File::LOCK_EX)
+ rescue Errno::ENOSYS, Errno::ENOTSUP
+ end
+ yield io
+ end
+ end
+
+ def open_file_with_lock(path, &block)
+ file_lock = "#{path}.lock"
+ open_file_with_flock(file_lock, &block)
+ ensure
+ FileUtils.rm_f file_lock
+ end
+ end
+ end
+
+ require "rubygems/platform"
+
+ class Platform
+ # Can be removed once RubyGems 3.6.9 support is dropped
+ unless respond_to?(:generic)
+ JAVA = Gem::Platform.new("java") # :nodoc:
+ MSWIN = Gem::Platform.new("mswin32") # :nodoc:
+ MSWIN64 = Gem::Platform.new("mswin64") # :nodoc:
+ MINGW = Gem::Platform.new("x86-mingw32") # :nodoc:
+ X64_MINGW_LEGACY = Gem::Platform.new("x64-mingw32") # :nodoc:
+ X64_MINGW = Gem::Platform.new("x64-mingw-ucrt") # :nodoc:
+ UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw") # :nodoc:
+ WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].freeze # :nodoc:
+ X64_LINUX = Gem::Platform.new("x86_64-linux") # :nodoc:
+ X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") # :nodoc:
+
+ GENERICS = [JAVA, *WINDOWS].freeze # :nodoc:
+ private_constant :GENERICS
+
+ GENERIC_CACHE = GENERICS.each_with_object({}) {|g, h| h[g] = g } # :nodoc:
+ private_constant :GENERIC_CACHE
+
+ class << self
+ ##
+ # Returns the generic platform for the given platform.
+
+ def generic(platform)
+ return Gem::Platform::RUBY if platform.nil? || platform == Gem::Platform::RUBY
+
+ GENERIC_CACHE[platform] ||= begin
+ found = GENERICS.find do |match|
+ platform === match
+ end
+ found || Gem::Platform::RUBY
+ end
+ end
+
+ ##
+ # Returns the platform specificity match for the given spec platform and user platform.
+
+ def platform_specificity_match(spec_platform, user_platform)
+ return -1 if spec_platform == user_platform
+ return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
+
+ os_match(spec_platform, user_platform) +
+ cpu_match(spec_platform, user_platform) * 10 +
+ version_match(spec_platform, user_platform) * 100
+ end
+
+ ##
+ # Sorts and filters the best platform match for the given matching specs and platform.
+
+ def sort_and_filter_best_platform_match(matching, platform)
+ return matching if matching.one?
+
+ exact = matching.select {|spec| spec.platform == platform }
+ return exact if exact.any?
+
+ sorted_matching = sort_best_platform_match(matching, platform)
+ exemplary_spec = sorted_matching.first
+
+ sorted_matching.take_while {|spec| same_specificity?(platform, spec, exemplary_spec) && same_deps?(spec, exemplary_spec) }
+ end
+
+ ##
+ # Sorts the best platform match for the given matching specs and platform.
+
+ def sort_best_platform_match(matching, platform)
+ matching.sort_by.with_index do |spec, i|
+ [
+ platform_specificity_match(spec.platform, platform),
+ i, # for stable sort
+ ]
+ end
+ end
+
+ private
+
+ def same_specificity?(platform, spec, exemplary_spec)
+ platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
+ end
+
+ def same_deps?(spec, exemplary_spec)
+ spec.required_ruby_version == exemplary_spec.required_ruby_version &&
+ spec.required_rubygems_version == exemplary_spec.required_rubygems_version &&
+ spec.dependencies.sort == exemplary_spec.dependencies.sort
+ end
+
+ def os_match(spec_platform, user_platform)
+ if spec_platform.os == user_platform.os
+ 0
+ else
+ 1
+ end
+ end
+
+ def cpu_match(spec_platform, user_platform)
+ if spec_platform.cpu == user_platform.cpu
+ 0
+ elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
+ 0
+ elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
+ 1
+ else
+ 2
+ end
+ end
+
+ def version_match(spec_platform, user_platform)
+ if spec_platform.version == user_platform.version
+ 0
+ elsif spec_platform.version.nil?
+ 1
+ else
+ 2
+ end
+ end
+ end
+
+ end
+ end
+
+ require "rubygems/specification"
+
+ # Can be removed once RubyGems 3.5.14 support is dropped
+ VALIDATES_FOR_RESOLUTION = Specification.new.respond_to?(:validate_for_resolution).freeze
+
class Specification
+ # Can be removed once RubyGems 3.5.15 support is dropped
+ correct_array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
+ unless @@array_attributes == correct_array_attributes
+ @@array_attributes = correct_array_attributes # rubocop:disable Style/ClassVars
+ end
+
+ require_relative "match_metadata"
+ require_relative "match_platform"
+
include ::Bundler::MatchMetadata
- include ::Bundler::MatchPlatform
- attr_accessor :remote, :location, :relative_loaded_from
+ attr_accessor :remote, :relative_loaded_from
+
+ module AllowSettingSource
+ attr_writer :source
- remove_method :source
- attr_writer :source
- def source
- (defined?(@source) && @source) || Gem::Source::Installed.new
+ def source
+ (defined?(@source) && @source) || super
+ end
end
+ prepend AllowSettingSource
+
alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from
def full_gem_path
if source.respond_to?(:root)
- Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ File.expand_path(File.dirname(loaded_from), source.root)
else
rg_full_gem_path
end
@@ -66,7 +225,9 @@ module Gem
alias_method :rg_extension_dir, :extension_dir
def extension_dir
- @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
+ # following instance variable is already used in original method
+ # and that is the reason to prefix it with bundler_ and add rubocop exception
+ @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name) # rubocop:disable Naming/MemoizedInstanceVariableName
unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
File.expand_path(File.join(extensions_dir, unique_extension_dir))
else
@@ -74,44 +235,15 @@ module Gem
end
end
- alias_method :rg_missing_extensions?, :missing_extensions?
- def missing_extensions?
- # When we use this methods with local gemspec, we don't handle
- # build status of extension correctly. So We need to find extension
- # files in require_paths.
- # TODO: Gem::Specification couldn't access extension name from extconf.rb
- # so we find them with heuristic way. We should improve it.
- if source.respond_to?(:root)
- return false if raw_require_paths.any? do |path|
- ext_dir = File.join(full_gem_path, path)
- File.exist?(File.join(ext_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")) ||
- !Dir.glob(File.join(ext_dir, name, "*.#{RbConfig::CONFIG["DLEXT"]}")).empty?
- end
- end
-
- rg_missing_extensions?
- end
+ # Can be removed once RubyGems 3.5.21 support is dropped
+ remove_method :gem_dir if method_defined?(:gem_dir, false)
- remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
def gem_dir
full_gem_path
end
- unless const_defined?(:LATEST_RUBY_WITHOUT_PATCH_VERSIONS)
- LATEST_RUBY_WITHOUT_PATCH_VERSIONS = Gem::Version.new("2.1")
-
- alias_method :rg_required_ruby_version=, :required_ruby_version=
- def required_ruby_version=(req)
- self.rg_required_ruby_version = req
-
- @required_ruby_version.requirements.map! do |op, v|
- if v >= LATEST_RUBY_WITHOUT_PATCH_VERSIONS && v.release.segments.size == 4
- [op == "~>" ? "=" : op, Gem::Version.new(v.segments.tap {|s| s.delete_at(3) }.join("."))]
- else
- [op, v]
- end
- end
- end
+ def insecurely_materialized?
+ false
end
def groups
@@ -133,23 +265,34 @@ module Gem
gemfile
end
- # Backfill missing YAML require when not defined. Fixed since 3.1.0.pre1.
- module YamlBackfiller
- def to_yaml(opts = {})
- Gem.load_yaml unless defined?(::YAML)
+ def nondevelopment_dependencies
+ dependencies - development_dependencies
+ end
- super(opts)
- end
+ def installation_missing?
+ !default_gem? && !File.directory?(full_gem_path)
end
- prepend YamlBackfiller
+ def lock_name
+ @lock_name ||= name_tuple.lock_name
+ end
- def nondevelopment_dependencies
- dependencies - development_dependencies
+ unless VALIDATES_FOR_RESOLUTION
+ def validate_for_resolution
+ SpecificationPolicy.new(self).validate_for_resolution
+ end
end
- def deleted_gem?
- !default_gem? && !File.directory?(full_gem_path)
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
+ module FixPathSourceMissingExtensions
+ def missing_extensions?
+ return false if %w[Bundler::Source::Path Bundler::Source::Gemspec].include?(source.class.name)
+
+ super
+ end
+ end
+
+ prepend FixPathSourceMissingExtensions
end
private
@@ -171,29 +314,47 @@ module Gem
end
end
+ unless VALIDATES_FOR_RESOLUTION
+ class SpecificationPolicy
+ def validate_for_resolution
+ validate_required!
+ end
+ end
+ end
+
+ module BetterPermissionError
+ def data
+ super
+ rescue Errno::EACCES
+ raise Bundler::PermissionError.new(loaded_from, :read)
+ end
+ end
+
+ require "rubygems/stub_specification"
+
+ class StubSpecification
+ prepend BetterPermissionError
+ end
+
class Dependency
+ require_relative "force_platform"
+
include ::Bundler::ForcePlatform
+ attr_reader :force_ruby_platform
+
attr_accessor :source, :groups
alias_method :eql?, :==
- def force_ruby_platform
- return @force_ruby_platform if defined?(@force_ruby_platform) && !@force_ruby_platform.nil?
-
- @force_ruby_platform = default_force_ruby_platform
- end
-
- def encode_with(coder)
- to_yaml_properties.each do |ivar|
- coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
+ unless method_defined?(:encode_with, false)
+ def encode_with(coder)
+ [:@name, :@requirement, :@type, :@prerelease, :@version_requirements].each do |ivar|
+ coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
+ end
end
end
- def to_yaml_properties
- instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
- end
-
def to_lock
out = String.new(" #{name}")
unless requirement.none?
@@ -202,170 +363,141 @@ module Gem
end
out
end
- end
- # comparison is done order independently since rubygems 3.2.0.rc.2
- unless Gem::Requirement.new("> 1", "< 2") == Gem::Requirement.new("< 2", "> 1")
- class Requirement
- module OrderIndependentComparison
- def ==(other)
- return unless Gem::Requirement === other
-
- if _requirements_sorted? && other._requirements_sorted?
- super
- else
- _with_sorted_requirements == other._with_sorted_requirements
- end
- end
-
- protected
-
- def _requirements_sorted?
- return @_are_requirements_sorted if defined?(@_are_requirements_sorted)
- strings = as_list
- @_are_requirements_sorted = strings == strings.sort
- end
-
- def _with_sorted_requirements
- @_with_sorted_requirements ||= _requirements_sorted? ? self : self.class.new(as_list.sort)
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
+ module FilterIgnoredSpecs
+ def matching_specs(platform_only = false)
+ super.reject(&:ignored?)
end
end
- prepend OrderIndependentComparison
+ prepend FilterIgnoredSpecs
end
end
- if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash
- class Requirement
- module CorrectHashForLambdaOperator
- def hash
- if requirements.any? {|r| r.first == "~>" }
- requirements.map {|r| r.first == "~>" ? [r[0], r[1].to_s] : r }.sort.hash
- else
- super
- end
- end
- end
-
- prepend CorrectHashForLambdaOperator
- end
- end
+ # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
+ class BasicSpecification
+ if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
+ local_platform = Platform.local
+ if local_platform.cpu == "universal"
+ ORIGINAL_LOCAL_PLATFORM = local_platform.to_s.freeze
- require "rubygems/platform"
+ local_platform.cpu = if arch == "arm64e" # arm64e is only permitted for Apple system binaries
+ "arm64"
+ else
+ arch
+ end
- class Platform
- JAVA = Gem::Platform.new("java")
- MSWIN = Gem::Platform.new("mswin32")
- MSWIN64 = Gem::Platform.new("mswin64")
- MINGW = Gem::Platform.new("x86-mingw32")
- X64_MINGW = [Gem::Platform.new("x64-mingw32"),
- Gem::Platform.new("x64-mingw-ucrt")].freeze
- WINDOWS = [MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze
- X64_LINUX = Gem::Platform.new("x86_64-linux")
- X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")
-
- if X64_LINUX === X64_LINUX_MUSL
- remove_method :===
-
- def ===(other)
- return nil unless Gem::Platform === other
-
- # universal-mingw32 matches x64-mingw-ucrt
- return true if (@cpu == "universal" || other.cpu == "universal") &&
- @os.start_with?("mingw") && other.os.start_with?("mingw")
-
- # cpu
- ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
- (@cpu == "arm" && other.cpu.start_with?("arm"))) &&
-
- # os
- @os == other.os &&
-
- # version
- (
- (@os != "linux" && (@version.nil? || other.version.nil?)) ||
- (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || ["musl#{@version}", "musleabi#{@version}", "musleabihf#{@version}"].include?(other.version))) ||
- @version == other.version
- )
+ def extensions_dir
+ @extensions_dir ||=
+ Gem.default_ext_dir_for(base_dir) || File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM, Gem.extension_api_version)
+ end
end
+ end
- # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
- # Once only 3.3.23 is supported, we can use the method in RubyGems.
- def normalized_linux_version_ext
- return nil unless @version
-
- without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
- return nil if without_gnu_nor_abi_modifiers.empty?
+ # Can be removed once RubyGems 3.5.22 support is dropped
+ unless new.respond_to?(:ignored?)
+ def ignored?
+ return @ignored unless @ignored.nil?
- without_gnu_nor_abi_modifiers
+ @ignored = missing_extensions?
end
end
- if RUBY_ENGINE == "truffleruby" && !defined?(REUSE_AS_BINARY_ON_TRUFFLERUBY)
- REUSE_AS_BINARY_ON_TRUFFLERUBY = %w[libv8 libv8-node sorbet-static].freeze
+ # Can be removed once RubyGems 3.6.9 support is dropped
+ unless new.respond_to?(:installable_on_platform?)
+ include(::Bundler::MatchPlatform)
end
end
- Platform.singleton_class.module_eval do
- unless Platform.singleton_methods.include?(:match_spec?)
- def match_spec?(spec)
- match_gem?(spec.platform, spec.name)
- end
+ require "rubygems/name_tuple"
+
+ class NameTuple
+ # Versions of RubyGems before about 3.5.0 don't to_s the platform.
+ unless Gem::NameTuple.new("a", Gem::Version.new("1"), Gem::Platform.new("x86_64-linux")).platform.is_a?(String)
+ alias_method :initialize_with_platform, :initialize
- def match_gem?(platform, gem_name)
- match_platforms?(platform, Gem.platforms)
+ def initialize(name, version, platform = Gem::Platform::RUBY)
+ if Gem::Platform === platform
+ initialize_with_platform(name, version, platform.to_s)
+ else
+ initialize_with_platform(name, version, platform)
+ end
end
end
- match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
-
- if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
-
- private
-
- remove_method :match_platforms? if match_platforms_defined
-
- def match_platforms?(platform, platforms)
- platforms.any? do |local_platform|
- platform.nil? ||
- local_platform == platform ||
- (local_platform != Gem::Platform::RUBY && platform =~ local_platform)
- end
+ def lock_name
+ if platform == Gem::Platform::RUBY
+ "#{name} (#{version})"
+ else
+ "#{name} (#{version}-#{platform})"
end
end
end
- # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
- class Specification
- if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
- local_platform = Platform.local
- if local_platform.cpu == "universal"
- ORIGINAL_LOCAL_PLATFORM = local_platform.to_s.freeze
+ unless Gem.rubygems_version >= Gem::Version.new("3.5.19")
+ class Resolver::ActivationRequest
+ remove_method :installed?
- local_platform.cpu = if arch == "arm64e" # arm64e is only permitted for Apple system binaries
- "arm64"
+ def installed?
+ case @spec
+ when Gem::Resolver::VendorSpecification then
+ true
else
- arch
- end
+ this_spec = full_spec
- def extensions_dir
- Gem.default_ext_dir_for(base_dir) ||
- File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM,
- Gem.extension_api_version)
+ Gem::Specification.any? do |s|
+ s == this_spec && s.base_dir == this_spec.base_dir
+ end
end
end
end
end
- require "rubygems/util"
+ unless Gem.rubygems_version >= Gem::Version.new("3.6.7")
+ module UnfreezeCompactIndexParsedResponse
+ def parse(line)
+ version, platform, dependencies, requirements = super
+ [version, platform, dependencies.frozen? ? dependencies.dup : dependencies, requirements.frozen? ? requirements.dup : requirements]
+ end
+ end
- Util.singleton_class.module_eval do
- if Util.singleton_methods.include?(:glob_files_in_dir) # since 3.0.0.beta.2
- remove_method :glob_files_in_dir
+ Resolver::APISet::GemParser.prepend(UnfreezeCompactIndexParsedResponse)
+ end
+
+ # RubyGems before 4.0.13 split compact index dependency/requirement entries
+ # on every colon, which mangles metadata values that contain colons such as
+ # the `created_at` timestamps the cooldown feature relies on. Split only on
+ # the first colon so those values survive on older RubyGems.
+ #
+ # The module is defined unconditionally so it stays testable on any RubyGems,
+ # but only prepended when the host RubyGems still has the buggy behavior.
+ module SplitCompactIndexEntryOnFirstColon
+ private
+
+ def parse_dependency(string)
+ dependency = string.split(":", 2)
+ dependency[-1] = dependency[-1].split("&") if dependency.size > 1
+ dependency[0] = -dependency[0]
+ dependency
end
+ end
- def glob_files_in_dir(glob, base_path)
- Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
+ unless Gem.rubygems_version >= Gem::Version.new("4.0.13")
+ Resolver::APISet::GemParser.prepend(SplitCompactIndexEntryOnFirstColon)
+ end
+
+ if Gem.rubygems_version < Gem::Version.new("3.6.0")
+ class Package; end
+ require "rubygems/package/tar_reader"
+ require "rubygems/package/tar_reader/entry"
+
+ module FixFullNameEncoding
+ def full_name
+ super.force_encoding(Encoding::UTF_8)
+ end
end
+
+ Package::TarReader::Entry.prepend(FixFullNameEncoding)
end
end
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index 38035a00ac..fc019f54d2 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -20,17 +20,31 @@ module Bundler
strict_rm_rf spec.extension_dir
SharedHelpers.filesystem_access(gem_dir, :create) do
- FileUtils.mkdir_p gem_dir, :mode => 0o755
+ FileUtils.mkdir_p gem_dir
end
- extract_files
+ SharedHelpers.filesystem_access(gem_dir, :write) do
+ extract_files
+ end
- build_extensions if spec.extensions.any?
+ if options[:build_extension] == false
+ warn_skipped_extensions
+ elsif spec.extensions.any?
+ build_extensions
+ end
write_build_info_file
run_post_build_hooks
- generate_bin
- generate_plugins
+ SharedHelpers.filesystem_access(bin_dir, :write) do
+ generate_bin
+ end
+
+ if options[:install_plugin] == false
+ remove_stale_plugins
+ warn_skipped_plugins
+ else
+ generate_plugins
+ end
write_spec
@@ -45,11 +59,26 @@ module Bundler
spec
end
- def generate_plugins
- return unless Gem::Installer.instance_methods(false).include?(:generate_plugins)
+ if Bundler.rubygems.provides?("< 3.5")
+ def pre_install_checks
+ super
+ rescue Gem::FilePermissionError
+ # Ignore permission checks in RubyGems. Instead, go on, and try to write
+ # for real. We properly handle permission errors when they happen.
+ nil
+ end
+ end
- latest = Gem::Specification.stubs_for(spec.name).first
- return if latest && latest.version > spec.version
+ def ensure_writable_dir(dir)
+ super
+ rescue Gem::FilePermissionError
+ # Ignore permission checks in RubyGems. Instead, go on, and try to write
+ # for real. We properly handle permission errors when they happen.
+ nil
+ end
+
+ def generate_plugins
+ return unless Gem::Installer.method_defined?(:generate_plugins, false)
ensure_writable_dir @plugins_dir
@@ -60,8 +89,42 @@ module Bundler
end
end
- def pre_install_checks
- super && validate_bundler_checksum(options[:bundler_expected_checksum])
+ def warn_skipped_extensions
+ return if spec.extensions.empty?
+
+ Bundler.ui.warn "#{spec.full_name} contains native extensions that were not built.\n" \
+ "To build extensions, unset no_build_extension and run `bundle pristine #{spec.name}`."
+ end
+
+ def warn_skipped_plugins
+ return if spec.plugins.empty?
+
+ Bundler.ui.warn "#{spec.full_name} contains plugins that were not installed.\n" \
+ "To install plugins, unset no_install_plugin and run `bundle pristine #{spec.name}`."
+ end
+
+ if Bundler.rubygems.provides?("< 3.5.19")
+ def generate_bin_script(filename, bindir)
+ bin_script_path = File.join bindir, formatted_program_filename(filename)
+
+ Gem.open_file_with_lock(bin_script_path) do
+ require "fileutils"
+ FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
+
+ File.open(bin_script_path, "wb", 0o755) do |file|
+ file.write app_script_text(filename)
+ file.chmod(options[:prog_mode] || 0o755)
+ end
+ end
+
+ verbose bin_script_path
+
+ generate_windows_script filename, bindir
+ end
+ end
+
+ def build_jobs
+ Bundler.settings[:jobs] || super
end
def build_extensions
@@ -98,74 +161,35 @@ module Bundler
end
end
+ def gem_checksum
+ Checksum.from_gem_package(@package)
+ end
+
private
def prepare_extension_build(extension_dir)
SharedHelpers.filesystem_access(extension_dir, :create) do
FileUtils.mkdir_p extension_dir
end
- require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
end
def strict_rm_rf(dir)
- Bundler.rm_rf dir
- rescue StandardError => e
- raise unless File.exist?(dir)
+ return unless File.exist?(dir)
+ return if Dir.empty?(dir)
- raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
- end
+ parent = File.dirname(dir)
+ parent_st = File.stat(parent)
- def validate_bundler_checksum(checksum)
- return true if Bundler.settings[:disable_checksum_validation]
- return true unless checksum
- return true unless source = @package.instance_variable_get(:@gem)
- return true unless source.respond_to?(:with_read_io)
- digest = source.with_read_io do |io|
- digest = SharedHelpers.digest(:SHA256).new
- digest << io.read(16_384) until io.eof?
- io.rewind
- send(checksum_type(checksum), digest)
- end
- unless digest == checksum
- raise SecurityError, <<-MESSAGE
- Bundler cannot continue installing #{spec.name} (#{spec.version}).
- The checksum for the downloaded `#{spec.full_name}.gem` does not match \
- the checksum given by the server. This means the contents of the downloaded \
- gem is different from what was uploaded to the server, and could be a potential security issue.
-
- To resolve this issue:
- 1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
- 2. run `bundle install`
-
- If you wish to continue installing the downloaded gem, and are certain it does not pose a \
- security issue despite the mismatching checksum, do the following:
- 1. run `bundle config set --local disable_checksum_validation true` to turn off checksum verification
- 2. run `bundle install`
-
- (More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
- checksum for the downloaded gem was #{digest.inspect}.)
- MESSAGE
+ if parent_st.world_writable? && !parent_st.sticky?
+ raise InsecureInstallPathError.new(spec.full_name, dir)
end
- true
- end
- def checksum_type(checksum)
- case checksum.length
- when 64 then :hexdigest!
- when 44 then :base64digest!
- else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
- end
- end
-
- def hexdigest!(digest)
- digest.hexdigest!
- end
+ begin
+ FileUtils.remove_entry_secure(dir)
+ rescue StandardError => e
+ raise unless File.exist?(dir)
- def base64digest!(digest)
- if digest.respond_to?(:base64digest!)
- digest.base64digest!
- else
- [digest.digest!].pack("m0")
+ raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
end
end
end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index d8b7886af7..e04ef23259 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -4,17 +4,12 @@ require "rubygems" unless defined?(Gem)
module Bundler
class RubygemsIntegration
- if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
- EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
- else
- require "monitor"
+ require "monitor"
- EXT_LOCK = Monitor.new
- end
+ EXT_LOCK = Monitor.new
def initialize
@replaced_methods = {}
- backport_ext_builder_monitor
end
def version
@@ -25,10 +20,6 @@ module Bundler
Gem::Requirement.new(req_str).satisfied_by?(version)
end
- def supports_bundler_trampolining?
- provides?(">= 3.3.0.a")
- end
-
def build_args
require "rubygems/command"
Gem::Command.build_args
@@ -39,20 +30,12 @@ module Bundler
Gem::Command.build_args = args
end
- def loaded_specs(name)
- Gem.loaded_specs[name]
+ def set_target_rbconfig(path)
+ Gem.set_target_rbconfig(path)
end
- def add_to_load_path(paths)
- return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
-
- if insert_index = Gem.load_path_insert_index
- # Gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *paths)
- else
- # We are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*paths)
- end
+ def loaded_specs(name)
+ Gem.loaded_specs[name]
end
def mark_loaded(spec)
@@ -65,7 +48,7 @@ module Bundler
end
def validate(spec)
- Bundler.ui.silence { spec.validate(false) }
+ Bundler.ui.silence { spec.validate_for_resolution }
rescue Gem::InvalidSpecificationException => e
error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \
"The validation error was '#{e.message}'\n"
@@ -74,28 +57,6 @@ module Bundler
nil
end
- def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
- return unless spec.respond_to?(:installed_by_version=)
- spec.installed_by_version = Gem::Version.create(installed_by_version)
- end
-
- def spec_missing_extensions?(spec, default = true)
- return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
-
- return false if spec.default_gem?
- return false if spec.extensions.empty?
-
- default
- end
-
- def spec_matches_for_glob(spec, glob)
- return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
-
- spec.load_paths.map do |lp|
- Dir["#{lp}/#{glob}#{suffix_pattern}"]
- end.flatten(1)
- end
-
def stub_set_spec(stub, spec)
stub.instance_variable_set(:@spec, spec)
end
@@ -116,16 +77,6 @@ module Bundler
Gem::Util.inflate(obj)
end
- def correct_for_windows_path(path)
- if Gem::Util.respond_to?(:correct_for_windows_path)
- Gem::Util.correct_for_windows_path(path)
- elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
- path[1..-1]
- else
- path
- end
- end
-
def gem_dir
Gem.dir
end
@@ -161,7 +112,7 @@ module Bundler
def spec_cache_dirs
@spec_cache_dirs ||= begin
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
- dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
+ dirs << Gem.spec_cache_dir
dirs.uniq.select {|dir| File.directory? dir }
end
end
@@ -183,18 +134,6 @@ module Bundler
loaded_gem_paths.flatten
end
- def load_plugins
- Gem.load_plugins if Gem.respond_to?(:load_plugins)
- end
-
- def load_plugin_files(files)
- Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
- end
-
- def load_env_plugins
- Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
- end
-
def ui=(obj)
Gem::DefaultUserInteraction.ui = obj
end
@@ -230,8 +169,7 @@ module Bundler
if Gem.respond_to?(:discover_gems_on_require=)
Gem.discover_gems_on_require = false
else
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |k|
+ [::Kernel.singleton_class, ::Kernel].each do |k|
if k.private_method_defined?(:gem_original_require)
redefine_method(k, :require, k.instance_method(:gem_original_require))
end
@@ -239,15 +177,12 @@ module Bundler
end
end
- def replace_gem(specs, specs_by_name)
- reverse_rubygems_kernel_mixin
-
+ def replace_gem(specs_by_name)
executables = nil
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |kernel_class|
+ [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
redefine_method(kernel_class, :gem) do |dep, *reqs|
- if executables&.include?(File.basename(caller.first.split(":").first))
+ if executables&.include?(File.basename(caller_locations(1, 1).first.path))
break
end
@@ -279,18 +214,11 @@ module Bundler
e.requirement = dep.requirement
raise e
end
-
- # backwards compatibility shim, see https://github.com/rubygems/bundler/issues/5102
- kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
end
end
- # Used to make bin stubs that are not created by bundler work
- # under bundler. The new Gem.bin_path only considers gems in
- # +specs+
+ # Used to give better error messages when activating specs outside of the current bundle
def replace_bin_path(specs_by_name)
- gem_class = (class << Gem; self; end)
-
redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
exec_name = args.first
raise ArgumentError, "you must supply exec_name" unless exec_name
@@ -326,31 +254,6 @@ module Bundler
spec
end
-
- redefine_method(gem_class, :activate_bin_path) do |name, *args|
- exec_name = args.first
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
-
- # Copy of Rubygems activate_bin_path impl
- requirement = args.last
- spec = find_spec_for_exe name, exec_name, [requirement]
-
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
- end
-
- redefine_method(gem_class, :bin_path) do |name, *args|
- exec_name = args.first
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
-
- spec = find_spec_for_exe(name, *args)
- exec_name ||= spec.default_executable
-
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
- end
end
# Replace or hook into RubyGems to provide a bundlerized view
@@ -358,8 +261,16 @@ module Bundler
def replace_entrypoints(specs)
specs_by_name = add_default_gems_to(specs)
- replace_gem(specs, specs_by_name)
- stub_rubygems(specs)
+ reverse_rubygems_kernel_mixin
+ begin
+ # bundled_gems only provide with Ruby 3.3 or later
+ require "bundled_gems"
+ rescue LoadError
+ else
+ Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
+ end
+ replace_gem(specs_by_name)
+ stub_rubygems(specs_by_name.values)
replace_bin_path(specs_by_name)
Gem.clear_paths
@@ -377,7 +288,6 @@ module Bundler
default_spec_name = default_spec.name
next if specs_by_name.key?(default_spec_name)
- specs << default_spec
specs_by_name[default_spec_name] = default_spec
end
@@ -388,11 +298,7 @@ module Bundler
@replaced_methods.each do |(sym, klass), method|
redefine_method(klass, sym, method)
end
- if Binding.public_method_defined?(:source_location)
- post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
- else
- post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
- end
+ post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
@replaced_methods.clear
end
@@ -434,9 +340,13 @@ module Bundler
Gem::Specification.all = specs
end
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
+ redefine_method(gem_class, :finish_resolve) do |*|
[]
end
+
+ redefine_method(gem_class, :load_plugins) do |*|
+ load_plugin_files specs.flat_map(&:plugins)
+ end
end
def plain_specs
@@ -447,38 +357,37 @@ module Bundler
Gem::Specification.all = specs
end
- def fetch_specs(remote, name)
+ def fetch_specs(remote, name, fetcher)
require "rubygems/remote_fetcher"
path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
string = fetcher.fetch_path(path)
- Bundler.safe_load_marshal(string)
+ specs = Bundler.safe_load_marshal(string)
+ raise MarshalError, "Specs #{name} from #{remote} is expected to be an Array but was unexpected class #{specs.class}" unless specs.is_a?(Array)
+ specs
rescue Gem::RemoteFetcher::FetchError
# it's okay for prerelease to fail
raise unless name == "prerelease_specs"
end
- def fetch_all_remote_specs(remote)
- specs = fetch_specs(remote, "specs")
- pres = fetch_specs(remote, "prerelease_specs") || []
+ def fetch_all_remote_specs(remote, gem_remote_fetcher)
+ specs = fetch_specs(remote, "specs", gem_remote_fetcher)
+ pres = fetch_specs(remote, "prerelease_specs", gem_remote_fetcher) || []
specs.concat(pres)
end
- def download_gem(spec, uri, cache_dir)
+ def download_gem(spec, uri, cache_dir, fetcher)
require "rubygems/remote_fetcher"
uri = Bundler.settings.mirror_for(uri)
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
- Bundler::Retry.new("download gem from #{uri}").attempts do
+ redacted_uri = Gem::Uri.redact(uri)
+
+ Bundler::Retry.new("download gem from #{redacted_uri}").attempts do
gem_file_name = spec.file_name
local_gem_path = File.join cache_dir, gem_file_name
return if File.exist? local_gem_path
begin
remote_gem_path = uri + "gems/#{gem_file_name}"
- remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
SharedHelpers.filesystem_access(local_gem_path) do
fetcher.cache_update_path remote_gem_path, local_gem_path
@@ -494,13 +403,7 @@ module Bundler
end
end
rescue Gem::RemoteFetcher::FetchError => e
- raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
- end
-
- def gem_remote_fetcher
- require "rubygems/remote_fetcher"
- proxy = Gem.configuration[:http_proxy]
- Gem::RemoteFetcher.new(proxy)
+ raise Bundler::HTTPError, "Could not download gem from #{redacted_uri} due to underlying error <#{e.message}>"
end
def build(spec, skip_validation = false)
@@ -513,46 +416,37 @@ module Bundler
end
def all_specs
- Gem::Specification.stubs.map do |stub|
+ SharedHelpers.feature_removed! "Bundler.rubygems.all_specs has been removed in favor of Bundler.rubygems.installed_specs"
+ end
+
+ def installed_specs
+ Gem::Specification.stubs.reject(&:default_gem?).map do |stub|
StubSpecification.from_stub(stub)
end
end
- def backport_ext_builder_monitor
- # So we can avoid requiring "rubygems/ext" in its entirety
- Gem.module_eval <<-RUBY, __FILE__, __LINE__ + 1
- module Ext
- end
- RUBY
-
- require "rubygems/ext/builder"
-
- Gem::Ext::Builder.class_eval do
- unless const_defined?(:CHDIR_MONITOR)
- const_set(:CHDIR_MONITOR, EXT_LOCK)
- end
-
- remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
- const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
+ def default_specs
+ Gem::Specification.default_stubs.map do |stub|
+ StubSpecification.from_stub(stub)
end
end
def find_bundler(version)
- find_name("bundler").find {|s| s.version.to_s == version }
+ find_name("bundler").find {|s| s.version.to_s == version.to_s }
end
def find_name(name)
Gem::Specification.stubs_for(name).map(&:to_spec)
end
- if Gem::Specification.respond_to?(:default_stubs)
- def default_stubs
- Gem::Specification.default_stubs("*.gemspec")
- end
- else
- def default_stubs
- Gem::Specification.send(:default_stubs, "*.gemspec")
- end
+ def default_stubs
+ Gem::Specification.default_stubs("*.gemspec")
+ end
+
+ private
+
+ def gem_class
+ class << Gem; self; end
end
end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index bd38353d3c..5280e72aa2 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -10,7 +10,7 @@ module Bundler
end
def setup(*groups)
- @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
+ @definition.ensure_equivalent_gemfile_and_lockfile
# Has to happen first
clean_load_path
@@ -28,11 +28,11 @@ module Bundler
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
end.reverse.flatten
- Bundler.rubygems.add_to_load_path(load_paths)
+ Gem.add_to_load_path(*load_paths)
setup_manpath
- lock(:preserve_unknown_sections => true)
+ lock(preserve_unknown_sections: true)
self
end
@@ -41,42 +41,48 @@ module Bundler
groups.map!(&:to_sym)
groups = [:default] if groups.empty?
- @definition.dependencies.each do |dep|
- # Skip the dependency if it is not in any of the requested groups, or
- # not for the current platform, or doesn't match the gem constraints.
- next unless (dep.groups & groups).any? && dep.should_include?
-
- required_file = nil
+ dependencies = @definition.dependencies.select do |dep|
+ # Select the dependency if it is in any of the requested groups, and
+ # for the current platform, and matches the gem constraints.
+ (dep.groups & groups).any? && dep.should_include?
+ end
- begin
- # Loop through all the specified autorequires for the
- # dependency. If there are none, use the dependency's name
- # as the autorequire.
- Array(dep.autorequire || dep.name).each do |file|
- # Allow `require: true` as an alias for `require: <name>`
- file = dep.name if file == true
- required_file = file
- begin
- Kernel.require file
- rescue RuntimeError => e
- raise e if e.is_a?(LoadError) # we handle this a little later
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE_ALL, dependencies)
+
+ dependencies.each do |dep|
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)
+
+ # Loop through all the specified autorequires for the
+ # dependency. If there are none, use the dependency's name
+ # as the autorequire.
+ Array(dep.autorequire || dep.name).each do |file|
+ # Allow `require: true` as an alias for `require: <name>`
+ file = dep.name if file == true
+ required_file = file
+ begin
+ Kernel.require required_file
+ rescue LoadError => e
+ if dep.autorequire.nil? && e.path == required_file
+ if required_file.include?("-")
+ required_file = required_file.tr("-", "/")
+ retry
+ end
+ else
raise Bundler::GemRequireError.new e,
"There was an error while trying to load the gem '#{file}'."
end
- end
- rescue LoadError => e
- raise if dep.autorequire || e.path != required_file
-
- if dep.autorequire.nil? && dep.name.include?("-")
- begin
- namespaced_file = dep.name.tr("-", "/")
- Kernel.require namespaced_file
- rescue LoadError => e
- raise if e.path != namespaced_file
- end
+ rescue StandardError => e
+ raise Bundler::GemRequireError.new e,
+ "There was an error while trying to load the gem '#{file}'."
end
end
+
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE, dep)
end
+
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE_ALL, dependencies)
+
+ dependencies
end
def self.definition_method(meth)
@@ -94,8 +100,8 @@ module Bundler
definition_method :requires
def lock(opts = {})
- return if @definition.nothing_changed? && !@definition.unlocking?
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ return if @definition.no_resolve_needed?
+ @definition.lock(opts[:preserve_unknown_sections])
end
alias_method :gems, :specs
@@ -124,8 +130,15 @@ module Bundler
specs_to_cache.each do |spec|
next if spec.name == "bundler"
- next if spec.source.is_a?(Source::Gemspec)
- spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
+
+ source = spec.source
+ next if source.is_a?(Source::Gemspec)
+
+ if source.respond_to?(:migrate_cache)
+ source.migrate_cache(custom_path, local: local)
+ elsif source.respond_to?(:cache)
+ source.cache(spec, custom_path)
+ end
end
Dir[cache_path.join("*/.git")].each do |git_dir|
@@ -161,7 +174,14 @@ module Bundler
spec_cache_paths = []
spec_gemspec_paths = []
spec_extension_paths = []
- Bundler.rubygems.add_default_gems_to(specs).values.each do |spec|
+ specs_to_keep = Bundler.rubygems.add_default_gems_to(specs).values
+
+ current_bundler = Bundler.rubygems.find_bundler(Bundler.gem_version)
+ if current_bundler
+ specs_to_keep << current_bundler
+ end
+
+ specs_to_keep.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
@@ -227,7 +247,11 @@ module Bundler
cached.each do |path|
Bundler.ui.info " * #{File.basename(path)}"
- File.delete(path)
+
+ begin
+ File.delete(path)
+ rescue Errno::ENOENT
+ end
end
end
end
@@ -257,10 +281,10 @@ module Bundler
def setup_manpath
# Add man/ subdirectories from activated bundles to MANPATH for man(1)
- manuals = $LOAD_PATH.map do |path|
+ manuals = $LOAD_PATH.filter_map do |path|
man_subdir = path.sub(/lib$/, "man")
man_subdir unless Dir[man_subdir + "/man?/"].empty?
- end.compact
+ end
return if manuals.empty?
Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
diff --git a/lib/bundler/safe_marshal.rb b/lib/bundler/safe_marshal.rb
new file mode 100644
index 0000000000..50aa0f60a6
--- /dev/null
+++ b/lib/bundler/safe_marshal.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Bundler
+ module SafeMarshal
+ ALLOWED_CLASSES = [
+ Array,
+ FalseClass,
+ Gem::Specification,
+ Gem::Version,
+ Hash,
+ String,
+ Symbol,
+ Time,
+ TrueClass,
+ ].freeze
+
+ ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
+
+ PROC = proc do |object|
+ object.tap do
+ unless ALLOWED_CLASSES.include?(object.class)
+ raise TypeError, format(ERROR, object.class, ALLOWED_CLASSES.join(", "))
+ end
+ end
+ end
+
+ def self.proc
+ PROC
+ end
+ end
+end
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 827f3f9222..82efbf56a4 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -7,24 +7,30 @@ module Bundler
#
class SelfManager
def restart_with_locked_bundler_if_needed
- return unless needs_switching? && installed?
+ restart_version = find_restart_version
+ return unless restart_version && installed?(restart_version)
- restart_with(lockfile_version)
+ restart_with(restart_version)
end
def install_locked_bundler_and_restart_with_it_if_needed
- return unless needs_switching?
-
- Bundler.ui.info \
- "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
- "Installing Bundler #{lockfile_version} and restarting using that version."
+ restart_version = find_restart_version
+ return unless restart_version
+
+ if restart_version == lockfile_version
+ Bundler.ui.info \
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
+ "Installing Bundler #{lockfile_version} and restarting using that version."
+ else
+ Bundler.ui.info \
+ "Bundler #{current_version} is running, but your configuration was #{restart_version}. " \
+ "Installing Bundler #{restart_version} and restarting using that version."
+ end
- install_and_restart_with(lockfile_version)
+ install_and_restart_with(restart_version)
end
def update_bundler_and_restart_with_it_if_needed(target)
- return unless autoswitching_applies?
-
spec = resolve_update_version_from(target)
return unless spec
@@ -32,7 +38,7 @@ module Bundler
Bundler.ui.info "Updating bundler to #{version}."
- install(spec)
+ install(spec) unless installed?(version)
restart_with(version)
end
@@ -57,35 +63,43 @@ module Bundler
end
def install(spec)
+ spec.source.download(spec)
spec.source.install(spec)
end
def restart_with(version)
configured_gem_home = ENV["GEM_HOME"]
+ configured_orig_gem_home = ENV["BUNDLER_ORIG_GEM_HOME"]
configured_gem_path = ENV["GEM_PATH"]
+ configured_orig_gem_path = ENV["BUNDLER_ORIG_GEM_PATH"]
- cmd = [$PROGRAM_NAME, *ARGV]
- cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
+ argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0
+ cmd = [argv0, *ARGV]
+ cmd.unshift(Gem.ruby) unless File.executable?(argv0)
Bundler.with_original_env do
Kernel.exec(
- { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s },
+ {
+ "GEM_HOME" => configured_gem_home,
+ "BUNDLER_ORIG_GEM_HOME" => configured_orig_gem_home,
+ "GEM_PATH" => configured_gem_path,
+ "BUNDLER_ORIG_GEM_PATH" => configured_orig_gem_path,
+ "BUNDLER_VERSION" => version.to_s,
+ },
*cmd
)
end
end
- def needs_switching?
+ def needs_switching?(restart_version)
autoswitching_applies? &&
- released?(lockfile_version) &&
- !running?(lockfile_version) &&
- !updating?
+ released?(restart_version) &&
+ !running?(restart_version)
end
def autoswitching_applies?
- ENV["BUNDLER_VERSION"].nil? &&
- Bundler.rubygems.supports_bundler_trampolining? &&
- SharedHelpers.in_bundle? &&
+ (ENV["BUNDLER_VERSION"].nil? || ENV["BUNDLER_VERSION"].empty?) &&
+ ruby_can_restart_with_same_arguments? &&
lockfile_version
end
@@ -114,11 +128,12 @@ module Bundler
source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
source.remote!
source.add_dependency_names("bundler")
- source.specs
+ source.specs.select(&:matches_current_metadata?)
end
end
def find_latest_matching_spec(requirement)
+ Bundler.configure
local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
return local_result if local_result && requirement.specific?
@@ -144,18 +159,18 @@ module Bundler
!version.to_s.end_with?(".dev")
end
- def updating?
- "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
+ def ruby_can_restart_with_same_arguments?
+ $PROGRAM_NAME != "-e"
end
- def installed?
+ def installed?(restart_version)
Bundler.configure
- Bundler.rubygems.find_bundler(lockfile_version.to_s)
+ Bundler.rubygems.find_bundler(restart_version.to_s)
end
def current_version
- @current_version ||= Gem::Version.new(Bundler::VERSION)
+ @current_version ||= Bundler.gem_version
end
def lockfile_version
@@ -163,6 +178,20 @@ module Bundler
parsed_version = Bundler::LockfileParser.bundled_with
@lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
+ rescue ArgumentError
+ @lockfile_version = nil
+ end
+
+ def find_restart_version
+ return unless SharedHelpers.in_bundle?
+
+ configured_version = Bundler.settings[:version]
+ return if configured_version == "system"
+
+ restart_version = configured_version == "lockfile" ? lockfile_version : Gem::Version.new(configured_version)
+ return unless needs_switching?(restart_version)
+
+ restart_version
end
end
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index a76a792743..fd77c2f7fc 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -7,14 +7,10 @@ module Bundler
autoload :Validator, File.expand_path("settings/validator", __dir__)
BOOL_KEYS = %w[
- allow_deployment_source_credential_changes
- allow_offline_install
- auto_clean_without_path
auto_install
cache_all
cache_all_platforms
clean
- default_install_uses_path
deployment
disable_checksum_validation
disable_exec_load
@@ -23,31 +19,32 @@ module Bundler
disable_shared_gems
disable_version_check
force_ruby_platform
- forget_cli_options
frozen
gem.changelog
gem.coc
gem.mit
+ gem.bundle
git.allow_insecure
global_gem_cache
ignore_messages
init_gems_rb
inline
+ lockfile_checksums
+ no_build_extension
no_install
+ no_install_plugin
no_prune
- path_relative_to_cwd
path.system
plugins
prefer_patch
- print_only_version_number
- setup_makes_kernel_gem_public
silence_deprecations
silence_root_warning
- suppress_install_using_messages
update_requires_all_flag
+ verbose
].freeze
NUMBER_KEYS = %w[
+ cooldown
jobs
redirect
retry
@@ -65,16 +62,20 @@ module Bundler
bin
cache_path
console
+ default_cli_command
gem.ci
gem.github_username
gem.linter
gem.rubocop
gem.test
gemfile
+ lockfile
path
shebang
+ simulate_version
system_bindir
trust-policy
+ version
].freeze
DEFAULT_CONFIG = {
@@ -84,30 +85,45 @@ module Bundler
"BUNDLE_REDIRECT" => 5,
"BUNDLE_RETRY" => 3,
"BUNDLE_TIMEOUT" => 10,
+ "BUNDLE_VERSION" => "lockfile",
+ "BUNDLE_LOCKFILE_CHECKSUMS" => true,
+ "BUNDLE_CACHE_ALL" => true,
+ "BUNDLE_PLUGINS" => true,
+ "BUNDLE_GLOBAL_GEM_CACHE" => false,
+ "BUNDLE_UPDATE_REQUIRES_ALL_FLAG" => false,
}.freeze
def initialize(root = nil)
@root = root
@local_config = load_config(local_config_file)
- @env_config = ENV.to_h.select {|key, _value| key =~ /\ABUNDLE_.+/ }
+ @local_root = root || Pathname.new(".bundle").expand_path
+
+ @env_config = ENV.to_h
+ @env_config.select! {|key, _value| key.start_with?("BUNDLE_") }
+ @env_config.delete("BUNDLE_")
+
@global_config = load_config(global_config_file)
@temporary = {}
+
+ @key_cache = {}
end
def [](name)
key = key_for(name)
- value = configs.values.map {|config| config[key] }.compact.first
+
+ value = nil
+ configs.each do |_, config|
+ value = config[key]
+ next if value.nil?
+ break
+ end
converted_value(value, name)
end
def set_command_option(key, value)
- if Bundler.feature_flag.forget_cli_options?
- temporary(key => value)
- value
- else
- set_local(key, value)
- end
+ temporary(key => value)
+ value
end
def set_command_option_if_given(key, value)
@@ -116,7 +132,7 @@ module Bundler
end
def set_local(key, value)
- local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
+ local_config_file = @local_root.join("config")
set_key(key, value, @local_config, local_config_file)
end
@@ -139,17 +155,22 @@ module Bundler
end
def all
- keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
+ keys = @temporary.keys.union(@global_config.keys, @local_config.keys, @env_config.keys)
- keys.map do |key|
- key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase
- end.sort
+ keys.map! do |key|
+ key = key.delete_prefix("BUNDLE_")
+ key.gsub!("___", "-")
+ key.gsub!("__", ".")
+ key.downcase!
+ key
+ end.sort!
+ keys
end
def local_overrides
repos = {}
all.each do |k|
- repos[$'] = self[k] if k =~ /^local\./
+ repos[k.delete_prefix("local.")] = self[k] if k.start_with?("local.")
end
repos
end
@@ -157,7 +178,7 @@ module Bundler
def mirror_for(uri)
if uri.is_a?(String)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
end
gem_mirrors.for(uri.to_s).uri
@@ -219,7 +240,6 @@ module Bundler
def path
configs.each do |_level, settings|
path = value_for("path", settings)
- path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
path_system = value_for("path.system", settings)
disabled_shared_gems = value_for("disable_shared_gems", settings)
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@@ -227,7 +247,9 @@ module Bundler
return Path.new(path, system_path)
end
- Path.new(nil, false)
+ path = "vendor/bundle" if self[:deployment]
+
+ Path.new(path, false)
end
Path = Struct.new(:explicit_path, :system_path) do
@@ -240,7 +262,7 @@ module Bundler
def use_system_gems?
return true if system_path
return false if explicit_path
- !Bundler.feature_flag.default_install_uses_path?
+ !Bundler.feature_flag.bundler_5_mode?
end
def base_path
@@ -285,6 +307,10 @@ module Bundler
@app_cache_path ||= self[:cache_path] || "vendor/cache"
end
+ def installation_parallelization
+ self[:jobs] || processor_count
+ end
+
def validate!
all.each do |raw_key|
[@local_config, @env_config, @global_config].each do |settings|
@@ -295,18 +321,18 @@ module Bundler
end
def key_for(key)
- self.class.key_for(key)
+ @key_cache[key] ||= self.class.key_for(key)
end
private
def configs
- {
- :temporary => @temporary,
- :local => @local_config,
- :env => @env_config,
- :global => @global_config,
- :default => DEFAULT_CONFIG,
+ @configs ||= {
+ temporary: @temporary,
+ local: @local_config,
+ env: @env_config,
+ global: @global_config,
+ default: DEFAULT_CONFIG,
}
end
@@ -327,16 +353,20 @@ module Bundler
end
def is_bool(name)
- BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
+ name = self.class.key_to_s(name)
+ BOOL_KEYS.include?(name) || BOOL_KEYS.include?(parent_setting_for(name))
end
def is_string(name)
- STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.")
+ name = self.class.key_to_s(name)
+ STRING_KEYS.include?(name) || name.start_with?("local.") || name.start_with?("mirror.") || name.start_with?("build.")
end
def to_bool(value)
case value
- when nil, /\A(false|f|no|n|0|)\z/i, false
+ when String
+ value.match?(/\A(false|f|no|n|0|)\z/i) ? false : true
+ when nil, false
false
else
true
@@ -344,11 +374,11 @@ module Bundler
end
def is_num(key)
- NUMBER_KEYS.include?(key.to_s)
+ NUMBER_KEYS.include?(self.class.key_to_s(key))
end
def is_array(key)
- ARRAY_KEYS.include?(key.to_s)
+ ARRAY_KEYS.include?(self.class.key_to_s(key))
end
def is_credential(key)
@@ -371,7 +401,7 @@ module Bundler
end
def set_key(raw_key, value, hash, file)
- raw_key = raw_key.to_s
+ raw_key = self.class.key_to_s(raw_key)
value = array_to_s(value) if is_array(raw_key)
key = key_for(raw_key)
@@ -384,14 +414,19 @@ module Bundler
Validator.validate!(raw_key, converted_value(value, raw_key), hash)
return unless file
+
+ SharedHelpers.filesystem_access(file.dirname, :create) do |p|
+ FileUtils.mkdir_p(p)
+ end
+
SharedHelpers.filesystem_access(file) do |p|
- FileUtils.mkdir_p(p.dirname)
- require_relative "yaml_serializer"
- p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
+ p.open("w") {|f| f.write(serializer_class.dump(hash)) }
end
end
def converted_value(value, key)
+ key = self.class.key_to_s(key)
+
if is_array(key)
to_array(value)
elsif value.nil?
@@ -449,41 +484,57 @@ module Bundler
SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero?
return {} unless valid_file
- require_relative "yaml_serializer"
- YAMLSerializer.load(file.read).inject({}) do |config, (k, v)|
- new_k = k
-
- if k.include?("-")
- Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
- "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
- "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
-
- new_k = k.gsub("-", "___")
+ (serializer_class.load(file.read) || {}).inject({}) do |config, (k, v)|
+ k = k.dup
+ k << "/" if /https?:/i.match?(k) && !k.end_with?("/", "__#{FALLBACK_TIMEOUT_URI_OPTION.upcase}")
+ k.gsub!(".", "__")
+
+ unless k.start_with?("#")
+ if k.include?("-")
+ Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
+ "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
+
+ # string hash keys are frozen
+ k = k.gsub("-", "___")
+ end
+
+ config[k] = v
end
- config[new_k] = v
config
end
end
end
- PER_URI_OPTIONS = %w[
- fallback_timeout
- ].freeze
+ def serializer_class
+ require "rubygems/yaml_serializer"
+ Gem::YAMLSerializer
+ rescue LoadError
+ # TODO: Remove this when RubyGems 3.4 is EOL
+ require_relative "yaml_serializer"
+ YAMLSerializer
+ end
+
+ FALLBACK_TIMEOUT_URI_OPTION = "fallback_timeout"
NORMALIZE_URI_OPTIONS_PATTERN =
/
\A
(\w+\.)? # optional prefix key
(https?.*?) # URI
- (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
+ (\.#{FALLBACK_TIMEOUT_URI_OPTION})? # optional suffix key
\z
- /ix.freeze
+ /ix
def self.key_for(key)
- key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http")
- key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
- "BUNDLE_#{key}"
+ key = key_to_s(key)
+ key = normalize_uri(key) if key.start_with?("http", "mirror.http")
+ key = key.gsub(".", "__")
+ key.gsub!("-", "___")
+ key.upcase!
+
+ key.gsub(/\A([ #]*)/, '\1BUNDLE_')
end
# TODO: duplicates Rubygems#normalize_uri
@@ -495,13 +546,42 @@ module Bundler
uri = $2
suffix = $3
end
- uri = "#{uri}/" unless uri.end_with?("/")
+ uri = URINormalizer.normalize_suffix(uri)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
unless uri.absolute?
raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
end
"#{prefix}#{uri}#{suffix}"
end
+
+ # This is a hot method, so avoid respond_to? checks on every invocation
+ if :read.respond_to?(:name)
+ def self.key_to_s(key)
+ case key
+ when String
+ key
+ when Symbol
+ key.name
+ when Gem::URI::HTTP
+ key.to_s
+ else
+ raise ArgumentError, "Invalid key: #{key.inspect}"
+ end
+ end
+ else
+ def self.key_to_s(key)
+ case key
+ when String
+ key
+ when Symbol
+ key.to_s
+ when Gem::URI::HTTP
+ key.to_s
+ else
+ raise ArgumentError, "Invalid key: #{key.inspect}"
+ end
+ end
+ end
end
end
diff --git a/lib/bundler/settings/validator.rb b/lib/bundler/settings/validator.rb
index 0a57ea7f03..70a0ca36d4 100644
--- a/lib/bundler/settings/validator.rb
+++ b/lib/bundler/settings/validator.rb
@@ -75,27 +75,11 @@ module Bundler
end
end
- rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
- next if value.nil?
-
- path = Pathname.new(value)
- next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
-
- path = path.expand_path
-
- root = begin
- Bundler.root
- rescue GemfileNotFound
- Pathname.pwd.expand_path
- end
-
- path = begin
- path.relative_path_from(root)
- rescue ArgumentError
- path
- end
-
- set(settings, key, path.to_s)
+ rule %w[default_cli_command], "default_cli_command must be either 'install' or 'cli_help'" do |key, value, _settings|
+ valid_values = %w[install cli_help]
+ if !value.nil? && !valid_values.include?(value.to_s)
+ fail!(key, value, "must be one of: #{valid_values.join(", ")}")
+ end
end
end
end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
index 801fd5312a..5a0fd8e0e3 100644
--- a/lib/bundler/setup.rb
+++ b/lib/bundler/setup.rb
@@ -5,6 +5,12 @@ require_relative "shared_helpers"
if Bundler::SharedHelpers.in_bundle?
require_relative "../bundler"
+ # autoswitch to locked Bundler version if available
+ Bundler.auto_switch
+
+ # try to auto_install first before we get to the `Bundler.ui.silence`, so user knows what is happening
+ Bundler.auto_install
+
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
begin
Bundler.ui.silence { Bundler.setup }
@@ -12,7 +18,10 @@ if Bundler::SharedHelpers.in_bundle?
Bundler.ui.error e.message
Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
if e.is_a?(Bundler::GemNotFound)
- suggested_cmd = "bundle install"
+ default_bundle = Gem.bin_path("bundler", "bundle")
+ current_bundle = Bundler::SharedHelpers.bundle_bin_path
+ suggested_bundle = default_bundle == current_bundle ? "bundle" : current_bundle
+ suggested_cmd = "#{suggested_bundle} install"
original_gemfile = Bundler.original_env["BUNDLE_GEMFILE"]
suggested_cmd += " --gemfile #{original_gemfile}" if original_gemfile
Bundler.ui.warn "Run `#{suggested_cmd}` to install missing gems."
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 794a03e62d..2aa8abe0a0 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -1,34 +1,37 @@
# frozen_string_literal: true
-require "pathname"
-require "rbconfig"
-
require_relative "version"
-require_relative "constants"
require_relative "rubygems_integration"
require_relative "current_ruby"
module Bundler
+ autoload :WINDOWS, File.expand_path("constants", __dir__)
+ autoload :FREEBSD, File.expand_path("constants", __dir__)
+ autoload :NULL, File.expand_path("constants", __dir__)
+
module SharedHelpers
def root
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
+ Pathname.new(gemfile).expand_path.parent
end
def default_gemfile
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
+ Pathname.new(gemfile).expand_path
end
def default_lockfile
+ given = ENV["BUNDLE_LOCKFILE"]
+ return Pathname.new(given) if given && !given.empty?
+
gemfile = default_gemfile
case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock")
- end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ end
end
def default_bundle_dir
@@ -55,7 +58,7 @@ module Bundler
def pwd
Bundler.rubygems.ext_lock.synchronize do
- Pathname.pwd
+ Dir.pwd
end
end
@@ -94,14 +97,17 @@ module Bundler
# given block
#
# @example
- # filesystem_access("vendor/cache", :write) do
+ # filesystem_access("vendor/cache", :create) do
# FileUtils.mkdir_p("vendor/cache")
# end
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
- yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
- rescue Errno::EACCES
+ yield(path.dup)
+ rescue Errno::EACCES => e
+ path_basename = File.basename(path.to_s)
+ raise unless e.message.include?(path_basename) || action == :create
+
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
raise TemporaryResourceError.new(path, action)
@@ -111,28 +117,27 @@ module Bundler
raise NoSpaceOnDeviceError.new(path, action)
rescue Errno::ENOTSUP
raise OperationNotSupportedError.new(path, action)
+ rescue Errno::EPERM
+ raise OperationNotPermittedError.new(path, action)
+ rescue Errno::EROFS
+ raise ReadOnlyFileSystemError.new(path, action)
rescue Errno::EEXIST, Errno::ENOENT
raise
rescue SystemCallError => e
- raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
+ raise GenericSystemCallError.new(e, "There was an error #{[:create, :write].include?(action) ? "creating" : "accessing"} `#{path}`.")
end
- def major_deprecation(major_version, message, print_caller_location: false)
- if print_caller_location
- caller_location = caller_locations(2, 2).first
- message = "#{message} (called at #{caller_location.path}:#{caller_location.lineno})"
- end
-
- bundler_major_version = Bundler.bundler_major_version
- if bundler_major_version > major_version
- require_relative "errors"
- raise DeprecatedError, "[REMOVED] #{message}"
- end
+ def feature_deprecated!(message)
+ return unless prints_major_deprecations?
- return unless bundler_major_version >= major_version && prints_major_deprecations?
Bundler.ui.warn("[DEPRECATED] #{message}")
end
+ def feature_removed!(message)
+ require_relative "errors"
+ raise RemovedError, "[REMOVED] #{message}"
+ end
+
def print_major_deprecations!
multiple_gemfiles = search_up(".") do |dir|
gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
@@ -156,11 +161,11 @@ module Bundler
extra_deps = new_deps - old_deps
return if extra_deps.empty?
- Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has either corrupted API or lockfile dependencies" \
+ Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has corrupted API dependencies" \
" (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
raise APIResponseMismatchError,
- "Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
- "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
+ "Downloading #{spec.full_name} revealed dependencies not in the API (#{extra_deps.join(", ")})." \
+ "\nRunning `bundle update #{spec.name}` should fix the problem."
end
def pretty_dependency(dep)
@@ -193,10 +198,40 @@ module Bundler
Digest(name)
end
+ def checksum_for_file(path, digest)
+ return unless path.file?
+ # This must use File.read instead of Digest.file().hexdigest
+ # because we need to preserve \n line endings on windows when calculating
+ # the checksum
+ SharedHelpers.filesystem_access(path, :read) do
+ File.open(path, "rb") do |f|
+ digest = SharedHelpers.digest(digest).new
+ buf = String.new(capacity: 16_384, encoding: Encoding::BINARY)
+ digest << buf while f.read(16_384, buf)
+ digest.hexdigest
+ end
+ end
+ end
+
def write_to_gemfile(gemfile_path, contents)
filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
end
+ def relative_gemfile_path
+ relative_path_to(Bundler.default_gemfile)
+ end
+
+ def relative_lockfile_path
+ relative_path_to(Bundler.default_lockfile)
+ end
+
+ def relative_path_to(destination, from: pwd)
+ Pathname.new(destination).relative_path_from(from).to_s
+ rescue ArgumentError
+ # on Windows, if source and destination are on different drivers, there's no relative path from one to the other
+ destination
+ end
+
private
def validate_bundle_path
@@ -235,20 +270,12 @@ module Bundler
def search_up(*names)
previous = nil
- current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ current = File.expand_path(SharedHelpers.pwd)
until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"]
# avoid stepping above the tmp directory when testing
- gemspec = if ENV["GEM_COMMAND"]
- # for Ruby Core
- "lib/bundler/bundler.gemspec"
- else
- "bundler.gemspec"
- end
-
- # avoid stepping above the tmp directory when testing
- return nil if File.file?(File.join(current, gemspec))
+ return nil if File.directory?(File.join(current, "tmp"))
end
names.each do |name|
@@ -272,19 +299,43 @@ module Bundler
public :set_env
def set_bundle_variables
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", bundle_bin_path
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
+ Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", default_lockfile.to_s
+ Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
+ Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__)
+ end
+
+ def bundle_bin_path
# bundler exe & lib folders have same root folder, typical gem installation
- exe_file = File.expand_path("../../exe/bundle", __dir__)
+ exe_file = File.join(source_root, "exe/bundle")
# for Ruby core repository testing
- exe_file = File.expand_path("../../libexec/bundle", __dir__) unless File.exist?(exe_file)
+ exe_file = File.join(source_root, "libexec/bundle") unless File.exist?(exe_file)
# bundler is a default gem, exe path is separate
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
+ exe_file = Gem.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
- Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
- Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__) unless RUBY_VERSION < "2.7"
+ exe_file
+ end
+ public :bundle_bin_path
+
+ def gemspec_path
+ # inside a gem repository, typical gem installation
+ gemspec_file = File.join(source_root, "../../specifications/bundler-#{VERSION}.gemspec")
+
+ # for Ruby core repository testing
+ gemspec_file = File.expand_path("bundler.gemspec", __dir__) unless File.exist?(gemspec_file)
+
+ # bundler is a default gem
+ gemspec_file = File.join(Gem.default_specifications_dir, "bundler-#{VERSION}.gemspec") unless File.exist?(gemspec_file)
+
+ gemspec_file
+ end
+ public :gemspec_path
+
+ def source_root
+ File.expand_path("../..", __dir__)
end
def set_path
@@ -297,7 +348,7 @@ module Bundler
def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact
setup_require = "-r#{File.expand_path("setup", __dir__)}"
- return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
+ return if !rubyopt.empty? && rubyopt.first.include?(setup_require)
rubyopt.unshift setup_require
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end
@@ -331,7 +382,6 @@ module Bundler
end
def prints_major_deprecations?
- require_relative "../bundler"
return false if Bundler.settings[:silence_deprecations]
require_relative "deprecate"
return false if Bundler::Deprecate.skip
diff --git a/lib/bundler/similarity_detector.rb b/lib/bundler/similarity_detector.rb
deleted file mode 100644
index 50e66b9cab..0000000000
--- a/lib/bundler/similarity_detector.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class SimilarityDetector
- SimilarityScore = Struct.new(:string, :distance)
-
- # initialize with an array of words to be matched against
- def initialize(corpus)
- @corpus = corpus
- end
-
- # return an array of words similar to 'word' from the corpus
- def similar_words(word, limit = 3)
- words_by_similarity = @corpus.map {|w| SimilarityScore.new(w, levenshtein_distance(word, w)) }
- words_by_similarity.select {|s| s.distance <= limit }.sort_by(&:distance).map(&:string)
- end
-
- # return the result of 'similar_words', concatenated into a list
- # (eg "a, b, or c")
- def similar_word_list(word, limit = 3)
- words = similar_words(word, limit)
- if words.length == 1
- words[0]
- elsif words.length > 1
- [words[0..-2].join(", "), words[-1]].join(" or ")
- end
- end
-
- protected
-
- # https://www.informit.com/articles/article.aspx?p=683059&seqNum=36
- def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
- # ins, del, sub are weighted costs
- return nil if this.nil?
- return nil if that.nil?
- dm = [] # distance matrix
-
- # Initialize first row values
- dm[0] = (0..this.length).collect {|i| i * ins }
- fill = [0] * (this.length - 1)
-
- # Initialize first column values
- (1..that.length).each do |i|
- dm[i] = [i * del, fill.flatten]
- end
-
- # populate matrix
- (1..that.length).each do |i|
- (1..this.length).each do |j|
- # critical comparison
- dm[i][j] = [
- dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub),
- dm[i][j - 1] + ins,
- dm[i - 1][j] + del,
- ].min
- end
- end
-
- # The last value in matrix is the Levenshtein distance between the strings
- dm[that.length][this.length]
- end
- end
-end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 69804a2e63..cf71be8801 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -11,6 +11,8 @@ module Bundler
attr_accessor :dependency_names
+ attr_reader :checksum_store
+
def unmet_deps
specs.unmet_dependency_names
end
@@ -29,10 +31,14 @@ module Bundler
message
end
+ def download(*); end
+
def can_lock?(spec)
spec.source == self
end
+ def prefer_local!; end
+
def local!; end
def local_only!; end
@@ -75,7 +81,7 @@ module Bundler
end
def extension_cache_path(spec)
- return unless Bundler.feature_flag.global_gem_cache?
+ return unless Bundler.settings[:global_gem_cache]
return unless source_slug = extension_cache_slug(spec)
Bundler.user_cache.join(
"extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
@@ -100,7 +106,7 @@ module Bundler
end
def print_using_message(message)
- if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages?
+ if !message.include?("(was ")
Bundler.ui.debug message
else
Bundler.ui.info message
diff --git a/lib/bundler/source/gemspec.rb b/lib/bundler/source/gemspec.rb
index 7e3447e776..ed766dbe74 100644
--- a/lib/bundler/source/gemspec.rb
+++ b/lib/bundler/source/gemspec.rb
@@ -4,14 +4,15 @@ module Bundler
class Source
class Gemspec < Path
attr_reader :gemspec
+ attr_writer :checksum_store
def initialize(options)
super
@gemspec = options["gemspec"]
end
- def as_path_source
- Path.new(options)
+ def to_s
+ "gemspec at `#{@path}`"
end
end
end
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index cf8c417ca4..a002a2570a 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -11,6 +11,7 @@ module Bundler
def initialize(options)
@options = options
+ @checksum_store = Checksum::Store.new
@glob = options["glob"] || DEFAULT_GLOB
@allow_cached = false
@@ -19,7 +20,7 @@ module Bundler
# Stringify options that could be set as symbols
%w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
- @uri = options["uri"] || ""
+ @uri = URINormalizer.normalize_suffix(options["uri"] || "", trailing_slash: false)
@safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
@branch = options["branch"]
@ref = options["ref"] || options["branch"] || options["tag"]
@@ -31,6 +32,20 @@ module Bundler
@local = false
end
+ def remote!
+ return if @allow_remote
+
+ @local_specs = nil
+ @allow_remote = true
+ end
+
+ def cached!
+ return if @allow_cached
+
+ @local_specs = nil
+ @allow_cached = true
+ end
+
def self.from_lock(options)
new(options.merge("uri" => options.delete("remote")))
end
@@ -46,41 +61,53 @@ module Bundler
out << " specs:\n"
end
+ def to_gemfile
+ specifiers = %w[ref branch tag submodules glob].map do |opt|
+ "#{opt}: #{options[opt]}" if options[opt]
+ end
+
+ uri_with_specifiers(specifiers)
+ end
+
def hash
- [self.class, uri, ref, branch, name, version, glob, submodules].hash
+ [self.class, uri, ref, branch, name, glob, submodules].hash
end
def eql?(other)
other.is_a?(Git) && uri == other.uri && ref == other.ref &&
branch == other.branch && name == other.name &&
- version == other.version && glob == other.glob &&
+ glob == other.glob &&
submodules == other.submodules
end
alias_method :==, :eql?
+ def include?(other)
+ other.is_a?(Git) && uri == other.uri &&
+ name == other.name &&
+ glob == other.glob &&
+ submodules == other.submodules
+ end
+
def to_s
begin
- at = if local?
- path
- elsif user_ref = options["ref"]
- if /\A[a-z0-9]{4,}\z/i.match?(ref)
- shortref_for_display(user_ref)
- else
- user_ref
- end
- elsif ref
- ref
- else
- current_branch
- end
+ at = humanized_ref || current_branch
rev = "at #{at}@#{shortref_for_display(revision)}"
rescue GitError
""
end
- specifiers = [rev, glob_for_display].compact
+ uri_with_specifiers([rev, glob_for_display])
+ end
+
+ def identifier
+ uri_with_specifiers([humanized_ref, locked_revision, glob_for_display])
+ end
+
+ def uri_with_specifiers(specifiers)
+ specifiers.compact!
+
suffix =
if specifiers.any?
" (#{specifiers.join(", ")})"
@@ -137,7 +164,8 @@ module Bundler
"does not exist. Run `bundle config unset local.#{override_for(original_path)}` to remove the local override"
end
- set_local!(path)
+ @local = true
+ set_paths!(path)
# Create a new git proxy without the cached revision
# so the Gemfile.lock always picks up the new revision.
@@ -148,10 +176,10 @@ module Bundler
"#{current_branch} but Gemfile specifies #{branch}"
end
- changed = cached_revision && cached_revision != revision
+ changed = locked_revision && locked_revision != revision
- if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(cached_revision)
- raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
+ if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(locked_revision)
+ raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(locked_revision)} " \
"but the current branch in your local override for #{name} does not contain such commit. " \
"Please make sure your branch is up to date."
end
@@ -160,13 +188,16 @@ module Bundler
end
def specs(*)
- set_local!(app_cache_path) if has_app_cache? && !local?
+ set_cache_path!(app_cache_path) if use_app_cache?
if requires_checkout? && !@copied
- fetch
- git_proxy.copy_to(install_path, submodules)
- serialize_gemspecs_in(install_path)
- @copied = true
+ Plugin.hook(Plugin::Events::GIT_BEFORE_FETCH, self)
+ begin
+ fetch unless use_app_cache?
+ checkout
+ ensure
+ Plugin.hook(Plugin::Events::GIT_AFTER_FETCH, self)
+ end
end
local_specs
@@ -179,27 +210,25 @@ module Bundler
print_using_message "Using #{version_message(spec, options[:previous_spec])} from #{self}"
if (requires_checkout? && !@copied) || force
- Bundler.ui.debug " * Checking out revision: #{ref}"
- git_proxy.copy_to(install_path, submodules)
- serialize_gemspecs_in(install_path)
- @copied = true
+ checkout
end
- generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] }
+ generate_bin_options = { disable_extensions: !spec.missing_extensions?, build_args: options[:build_args] }
generate_bin(spec, generate_bin_options)
requires_checkout? ? spec.post_install_message : nil
end
+ def migrate_cache(custom_path = nil, local: false)
+ if local
+ cache_to(custom_path, try_migrate: false)
+ else
+ cache_to(custom_path, try_migrate: true)
+ end
+ end
+
def cache(spec, custom_path = nil)
- app_cache_path = app_cache_path(custom_path)
- return unless Bundler.feature_flag.cache_all?
- return if path == app_cache_path
- cached!
- FileUtils.rm_rf(app_cache_path)
- git_proxy.checkout if requires_checkout?
- git_proxy.copy_to(app_cache_path, @submodules)
- serialize_gemspecs_in(app_cache_path)
+ cache_to(custom_path, try_migrate: false)
end
def load_spec_files
@@ -214,7 +243,7 @@ module Bundler
# across different projects, this cache will be shared.
# When using local git repos, this is set to the local repo.
def cache_path
- @cache_path ||= if Bundler.feature_flag.global_gem_cache?
+ @cache_path ||= if Bundler.settings[:global_gem_cache]
Bundler.user_cache
else
Bundler.bundle_path.join("cache", "bundler")
@@ -222,7 +251,7 @@ module Bundler
end
def app_cache_dirname
- "#{base_name}-#{shortref_for_path(cached_revision || revision)}"
+ "#{base_name}-#{shortref_for_path(locked_revision || revision)}"
end
def revision
@@ -243,6 +272,57 @@ module Bundler
private
+ def cache_to(custom_path, try_migrate: false)
+ return unless Bundler.settings[:cache_all]
+
+ app_cache_path = app_cache_path(custom_path)
+
+ migrate = try_migrate ? bare_repo?(app_cache_path) : false
+
+ set_cache_path!(nil) if migrate
+
+ return if cache_path == app_cache_path
+
+ cached!
+ FileUtils.rm_rf(app_cache_path)
+ git_proxy.checkout if migrate || requires_checkout?
+ git_proxy.copy_to(app_cache_path, @submodules)
+ serialize_gemspecs_in(app_cache_path)
+ end
+
+ def checkout
+ Bundler.ui.debug " * Checking out revision: #{ref}"
+ if use_app_cache? && !bare_repo?(app_cache_path)
+ SharedHelpers.filesystem_access(install_path.dirname) do |p|
+ FileUtils.mkdir_p(p)
+ end
+ FileUtils.cp_r("#{app_cache_path}/.", install_path)
+ else
+ if use_app_cache? && bare_repo?(app_cache_path)
+ Bundler.ui.warn "Installing from cache in old \"bare repository\" format for compatibility. " \
+ "Please run `bundle cache` and commit the updated cache to migrate to the new format and get rid of this warning."
+ end
+
+ git_proxy.copy_to(install_path, submodules)
+ end
+ serialize_gemspecs_in(install_path)
+ @copied = true
+ end
+
+ def humanized_ref
+ if local?
+ path
+ elsif user_ref = options["ref"]
+ if /\A[a-z0-9]{4,}\z/i.match?(ref)
+ shortref_for_display(user_ref)
+ else
+ user_ref
+ end
+ elsif ref
+ ref
+ end
+ end
+
def serialize_gemspecs_in(destination)
destination = destination.expand_path(Bundler.root) if destination.relative?
Dir["#{destination}/#{@glob}"].each do |spec_path|
@@ -251,28 +331,45 @@ module Bundler
# The gemspecs we cache should already be evaluated.
spec = Bundler.load_gemspec(spec_path)
next unless spec
- Bundler.rubygems.set_installed_by_version(spec)
+ spec.installed_by_version = Gem::VERSION
Bundler.rubygems.validate(spec)
File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) }
end
end
- def set_local!(path)
- @local = true
- @local_specs = @git_proxy = nil
- @cache_path = @install_path = path
+ def set_paths!(path)
+ set_cache_path!(path)
+ set_install_path!(path)
+ end
+
+ def set_cache_path!(path)
+ @git_proxy = nil
+ @cache_path = path
+ end
+
+ def set_install_path!(path)
+ @local_specs = nil
+ @install_path = path
end
def has_app_cache?
- cached_revision && super
+ locked_revision && super
+ end
+
+ def use_app_cache?
+ has_app_cache? && !local?
end
def requires_checkout?
- allow_git_ops? && !local? && !cached_revision_checked_out?
+ allow_git_ops? && !local? && !locked_revision_checked_out?
+ end
+
+ def locked_revision_checked_out?
+ locked_revision && locked_revision == revision && installed?
end
- def cached_revision_checked_out?
- cached_revision && cached_revision == revision && install_path.exist?
+ def installed?
+ git_proxy.installed_to?(install_path)
end
def base_name
@@ -299,7 +396,7 @@ module Bundler
if %r{^\w+://(\w+@)?}.match?(uri)
# Downcase the domain component of the URI
# and strip off a trailing slash, if one is present
- input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
+ input = Gem::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
else
# If there is no URI scheme, assume it is an ssh/git URI
input = uri
@@ -309,7 +406,7 @@ module Bundler
Bundler::Digest.sha1(input)
end
- def cached_revision
+ def locked_revision
options["revision"]
end
@@ -318,13 +415,12 @@ module Bundler
end
def git_proxy
- @git_proxy ||= GitProxy.new(cache_path, uri, options, cached_revision, self)
+ @git_proxy ||= GitProxy.new(cache_path, uri, options, locked_revision, self)
end
def fetch
git_proxy.checkout
rescue GitError => e
- raise unless Bundler.feature_flag.allow_offline_install?
Bundler.ui.warn "Using cached git data because of network errors:\n#{e}"
end
@@ -332,9 +428,12 @@ module Bundler
def validate_spec(_spec); end
def load_gemspec(file)
- stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
- stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
- StubSpecification.from_stub(stub)
+ dirname = Pathname.new(file).dirname
+ SharedHelpers.chdir(dirname.to_s) do
+ stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
+ stub.full_gem_path = dirname.expand_path(root).to_s
+ StubSpecification.from_stub(stub)
+ end
end
def git_scope
@@ -348,6 +447,10 @@ module Bundler
def override_for(path)
Bundler.settings.local_overrides.key(path)
end
+
+ def bare_repo?(path)
+ File.exist?(path.join("objects")) && File.exist?(path.join("HEAD"))
+ end
end
end
end
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 3a6a666627..8094dcaa9d 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -16,7 +16,7 @@ module Bundler
def initialize(command)
msg = String.new
msg << "Bundler is trying to run `#{command}` at runtime. You probably need to run `bundle install`. However, "
- msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md "
+ msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/ruby/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md "
msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
super msg
end
@@ -43,6 +43,13 @@ module Bundler
end
end
+ class AmbiguousGitReference < GitError
+ def initialize(options)
+ msg = "Specification of branch or ref with tag is ambiguous. You specified #{options.inspect}"
+ super msg
+ end
+ end
+
# The GitProxy is responsible to interact with git repositories.
# All actions required by the Git source is encapsulated in this
# object.
@@ -50,13 +57,41 @@ module Bundler
attr_accessor :path, :uri, :branch, :tag, :ref, :explicit_ref
attr_writer :revision
+ def self.version
+ @version ||= full_version[/((\.?\d+)+).*/, 1]
+ end
+
+ def self.full_version
+ @full_version ||= begin
+ raise GitNotInstalledError.new unless Bundler.git_present?
+
+ require "open3"
+ out, err, status = Open3.capture3("git", "--version")
+
+ raise GitCommandError.new("--version", SharedHelpers.pwd, err) unless status.success?
+ Bundler.ui.warn err unless err.empty?
+
+ out.sub(/git version\s*/, "").strip
+ end
+ end
+
+ def self.reset
+ @version = nil
+ @full_version = nil
+ end
+
def initialize(path, uri, options = {}, revision = nil, git = nil)
@path = path
@uri = uri
- @branch = options["branch"]
@tag = options["tag"]
+ @branch = options["branch"]
@ref = options["ref"]
- @explicit_ref = branch || tag || ref
+ if @tag
+ raise AmbiguousGitReference.new(options) if @branch || @ref
+ @explicit_ref = @tag
+ else
+ @explicit_ref = @ref || @branch
+ end
@revision = revision
@git = git
@commit_ref = nil
@@ -67,24 +102,24 @@ module Bundler
end
def current_branch
- @current_branch ||= allowed_with_path do
- git("rev-parse", "--abbrev-ref", "HEAD", :dir => path).strip
+ @current_branch ||= with_path do
+ git_local("rev-parse", "--abbrev-ref", "HEAD", dir: path).strip
end
end
def contains?(commit)
allowed_with_path do
- result, status = git_null("branch", "--contains", commit, :dir => path)
- status.success? && result =~ /^\* (.*)$/
+ result, status = git_null("branch", "--contains", commit, dir: path)
+ status.success? && result.match?(/^\* (.*)$/)
end
end
def version
- @version ||= full_version.match(/((\.?\d+)+).*/)[1]
+ self.class.version
end
def full_version
- @full_version ||= git("--version").sub(/git version\s*/, "").strip
+ self.class.full_version
end
def checkout
@@ -109,7 +144,7 @@ module Bundler
FileUtils.rm_rf(p)
end
git "clone", "--no-checkout", "--quiet", path.to_s, destination.to_s
- File.chmod(((File.stat(destination).mode | 0o777) & ~File.umask), destination)
+ File.chmod((File.stat(destination).mode | 0o777) & ~File.umask, destination)
rescue Errno::EEXIST => e
file_path = e.message[%r{.*?((?:[a-zA-Z]:)?/.*)}, 1]
raise GitError, "Bundler could not install a gem because it needs to " \
@@ -118,22 +153,33 @@ module Bundler
end
end
- git "fetch", "--force", "--quiet", *extra_fetch_args, :dir => destination if @commit_ref
+ ref = @commit_ref || (locked_to_full_sha? && @revision)
+ if ref
+ git "config", "uploadpack.allowAnySHA1InWant", "true", dir: path.to_s if @commit_ref.nil? && needs_allow_any_sha1_in_want?
+
+ git "fetch", "--force", "--quiet", *extra_fetch_args(ref), dir: destination
+ end
- git "reset", "--hard", @revision, :dir => destination
+ git "reset", "--hard", revision, dir: destination
if submodules
- git_retry "submodule", "update", "--init", "--recursive", :dir => destination
+ git_retry "submodule", "update", "--init", "--recursive", dir: destination
elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
inner_command = "git -C $toplevel submodule deinit --force $sm_path"
- git_retry "submodule", "foreach", "--quiet", inner_command, :dir => destination
+ git_retry "submodule", "foreach", "--quiet", inner_command, dir: destination
end
end
+ def installed_to?(destination)
+ # if copy_to is interrupted, it may leave a partially installed directory that
+ # contains .git but no other files -- consider this not to be installed
+ Dir.exist?(destination) && (Dir.children(destination) - [".git"]).any?
+ end
+
private
def git_remote_fetch(args)
- command = ["fetch", "--force", "--quiet", "--no-tags", *args, "--", configured_uri, refspec].compact
+ command = fetch_command(args)
command_with_no_credentials = check_allowed(command)
Bundler::Retry.new("`#{command_with_no_credentials}` at #{path}", [MissingGitRevisionError]).attempts do
@@ -143,6 +189,11 @@ module Bundler
if err.include?("couldn't find remote ref") || err.include?("not our ref")
raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref, credential_filtered_uri)
else
+ if shallow?
+ args -= depth_args
+ command = fetch_command(args)
+ command_with_no_credentials = check_allowed(command)
+ end
raise GitCommandError.new(command_with_no_credentials, path, err)
end
end
@@ -155,16 +206,23 @@ module Bundler
FileUtils.mkdir_p(p)
end
- command = ["clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s]
+ clone_args = extra_clone_args
+ command = clone_command(clone_args)
command_with_no_credentials = check_allowed(command)
Bundler::Retry.new("`#{command_with_no_credentials}`", [MissingGitRevisionError]).attempts do
_, err, status = capture(command, nil)
return extra_ref if status.success?
- if err.include?("Could not find remote branch")
+ if err.include?("Could not find remote branch") || # git up to 2.49
+ err.include?("Remote branch #{branch_option} not found") # git 2.49 or higher
raise MissingGitRevisionError.new(command_with_no_credentials, nil, explicit_ref, credential_filtered_uri)
else
+ if shallow?
+ clone_args -= depth_args
+ command = clone_command(clone_args)
+ command_with_no_credentials = check_allowed(command)
+ end
raise GitCommandError.new(command_with_no_credentials, path, err)
end
end
@@ -172,14 +230,14 @@ module Bundler
def clone_needs_unshallow?
return false unless path.join("shallow").exist?
- return true if full_clone?
+ return true unless shallow?
@revision && @revision != head_revision
end
def extra_ref
return false if not_pinned?
- return true unless full_clone?
+ return true if shallow?
ref.start_with?("refs/")
end
@@ -231,42 +289,50 @@ module Bundler
end
def not_pinned?
- branch || tag || ref.nil?
+ branch_option || ref.nil?
end
def pinned_to_full_sha?
- ref =~ /\A\h{40}\z/
+ full_sha_revision?(ref)
+ end
+
+ def locked_to_full_sha?
+ full_sha_revision?(@revision)
+ end
+
+ def full_sha_revision?(ref)
+ ref&.match?(/\A\h{40}\z/)
end
def git_null(*command, dir: nil)
check_allowed(command)
- capture(command, dir, :ignore_err => true)
+ capture(command, dir, ignore_err: true)
end
def git_retry(*command, dir: nil)
command_with_no_credentials = check_allowed(command)
Bundler::Retry.new("`#{command_with_no_credentials}` at #{dir || SharedHelpers.pwd}").attempts do
- git(*command, :dir => dir)
+ git(*command, dir: dir)
end
end
def git(*command, dir: nil)
- command_with_no_credentials = check_allowed(command)
-
- out, err, status = capture(command, dir)
-
- raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, err) unless status.success?
-
- Bundler.ui.warn err unless err.empty?
+ run_command(*command, dir: dir) do |unredacted_command|
+ check_allowed(unredacted_command)
+ end
+ end
- out
+ def git_local(*command, dir: nil)
+ run_command(*command, dir: dir) do |unredacted_command|
+ redact_and_check_presence(unredacted_command)
+ end
end
def has_revision_cached?
- return unless @revision && path.exist?
- git("cat-file", "-e", @revision, :dir => path)
+ return unless commit && path.exist?
+ git("cat-file", "-e", commit, dir: path)
true
rescue GitError
false
@@ -289,18 +355,16 @@ module Bundler
end
def verify(reference)
- git("rev-parse", "--verify", reference, :dir => path).strip
+ git("rev-parse", "--verify", reference, dir: path).strip
end
# Adds credentials to the URI
def configured_uri
if /https?:/.match?(uri)
- remote = Bundler::URI(uri)
+ remote = Gem::URI(uri)
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
remote.userinfo ||= config_auth
remote.to_s
- elsif File.exist?(uri)
- "file://#{uri}"
else
uri.to_s
end
@@ -330,12 +394,30 @@ module Bundler
end
def check_allowed(command)
- require "shellwords"
- command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
+ command_with_no_credentials = redact_and_check_presence(command)
raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
command_with_no_credentials
end
+ def redact_and_check_presence(command)
+ raise GitNotInstalledError.new unless Bundler.git_present?
+
+ require "shellwords"
+ URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
+ end
+
+ def run_command(*command, dir: nil)
+ command_with_no_credentials = yield(command)
+
+ out, err, status = capture(command, dir)
+
+ raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, err) unless status.success?
+
+ Bundler.ui.warn err unless err.empty?
+
+ out
+ end
+
def capture(cmd, dir, ignore_err: false)
SharedHelpers.with_clean_git_env do
require "open3"
@@ -350,13 +432,14 @@ module Bundler
end
def capture3_args_for(cmd, dir)
- return ["git", *cmd] unless dir
+ # Disable automatic maintenance so a background commit-graph write in
+ # the source repo can't race the hardlinking local clone and fail with
+ # "hardlink different from source".
+ opts = ["-c", "gc.auto=0", "-c", "maintenance.auto=false"]
- if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
- ["git", "-C", dir.to_s, *cmd]
- else
- ["git", *cmd, { :chdir => dir.to_s }]
- end
+ return ["git", *opts, *cmd] unless dir
+
+ ["git", "-C", dir.to_s, *opts, *cmd]
end
def extra_clone_args
@@ -366,28 +449,45 @@ module Bundler
args += ["--single-branch"]
args.unshift("--no-tags") if supports_cloning_with_no_tags?
- args += ["--branch", branch || tag] if branch || tag
+ # If there's a locked revision, no need to clone any specific branch
+ # or tag, since we will end up checking out that locked revision
+ # anyways.
+ return args if @revision
+
+ args += ["--branch", branch_option] if branch_option
args
end
+ def fetch_command(args)
+ ["fetch", "--force", "--quiet", "--no-tags", *args, "--", configured_uri, refspec].compact
+ end
+
+ def clone_command(args)
+ ["clone", "--bare", "--no-hardlinks", "--quiet", *args, "--", configured_uri, path.to_s]
+ end
+
def depth_args
- return [] if full_clone?
+ return [] unless shallow?
["--depth", depth.to_s]
end
- def extra_fetch_args
+ def extra_fetch_args(ref)
extra_args = [path.to_s, *depth_args]
- extra_args.push(@commit_ref)
+ extra_args.push(ref)
extra_args
end
- def full_clone?
- depth.nil?
+ def branch_option
+ branch || tag
+ end
+
+ def shallow?
+ !depth.nil?
end
- def supports_minus_c?
- @supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
+ def needs_allow_any_sha1_in_want?
+ @needs_allow_any_sha1_in_want ||= Gem::Version.new(version) <= Gem::Version.new("2.13.7")
end
def supports_fetching_unreachable_refs?
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
index 593da6d1a7..ecf8895187 100644
--- a/lib/bundler/source/metadata.rb
+++ b/lib/bundler/source/metadata.rb
@@ -5,27 +5,28 @@ module Bundler
class Metadata < Source
def specs
@specs ||= Index.build do |idx|
- idx << Gem::Specification.new("Ruby\0", Gem.ruby_version)
+ idx << Gem::Specification.new("Ruby\0", Bundler::RubyVersion.system.gem_version)
idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
s.required_rubygems_version = Gem::Requirement.default
end
- idx << Gem::Specification.new do |s|
- s.name = "bundler"
- s.version = VERSION
- s.license = "MIT"
- s.platform = Gem::Platform::RUBY
- s.authors = ["bundler team"]
- s.bindir = "exe"
- s.homepage = "https://bundler.io"
- s.summary = "The best way to manage your application's dependencies"
- s.executables = %w[bundle]
- # can't point to the actual gemspec or else the require paths will be wrong
- s.loaded_from = __dir__
- end
+ if local_spec = Gem.loaded_specs["bundler"]
+ raise CorruptBundlerInstallError.new(local_spec) if local_spec.version.to_s != Bundler::VERSION
- if local_spec = Bundler.rubygems.find_bundler(VERSION)
idx << local_spec
+ else
+ idx << Gem::Specification.new do |s|
+ s.name = "bundler"
+ s.version = VERSION
+ s.license = "MIT"
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["bundler team"]
+ s.bindir = "exe"
+ s.homepage = "https://bundler.io"
+ s.summary = "The best way to manage your application's dependencies"
+ s.executables = %w[bundle bundler]
+ s.loaded_from = SharedHelpers.gemspec_path
+ end
end
idx.each {|s| s.source = self }
@@ -57,6 +58,10 @@ module Bundler
def version_message(spec)
"#{spec.name} #{spec.version}"
end
+
+ def checksum_store
+ @checksum_store ||= Checksum::Store.new
+ end
end
end
end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index bdfcf8274a..366a23aea7 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -14,19 +14,17 @@ module Bundler
DEFAULT_GLOB = "{,*,*/*}.gemspec"
def initialize(options)
+ @checksum_store = Checksum::Store.new
@options = options.dup
@glob = options["glob"] || DEFAULT_GLOB
- @allow_cached = false
- @allow_remote = false
-
@root_path = options["root_path"] || root
if options["path"]
@path = Pathname.new(options["path"])
expanded_path = expand(@path)
@path = if @path.relative?
- expanded_path.relative_path_from(root_path.expand_path)
+ expanded_path.relative_path_from(File.expand_path(root_path))
else
expanded_path
end
@@ -40,16 +38,6 @@ module Bundler
@original_path = @path
end
- def remote!
- @local_specs = nil
- @allow_remote = true
- end
-
- def cached!
- @local_specs = nil
- @allow_cached = true
- end
-
def self.from_lock(options)
new(options.merge("path" => options.delete("remote")))
end
@@ -65,13 +53,17 @@ module Bundler
"source at `#{@path}`"
end
+ alias_method :identifier, :to_s
+
+ alias_method :to_gemfile, :path
+
def hash
[self.class, expanded_path, version].hash
end
def eql?(other)
- return unless other.class == self.class
- expanded_original_path == other.expanded_original_path &&
+ [Gemspec, Path].include?(other.class) &&
+ expanded_original_path == other.expanded_original_path &&
version == other.version
end
@@ -85,13 +77,13 @@ module Bundler
using_message = "Using #{version_message(spec, options[:previous_spec])} from #{self}"
using_message += " and installing its executables" unless spec.executables.empty?
print_using_message using_message
- generate_bin(spec, :disable_extensions => true)
+ generate_bin(spec, disable_extensions: true)
nil # no post-install message
end
def cache(spec, custom_path = nil)
app_cache_path = app_cache_path(custom_path)
- return unless Bundler.feature_flag.cache_all?
+ return unless Bundler.settings[:cache_all]
return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0
unless @original_path.exist?
@@ -134,11 +126,7 @@ module Bundler
end
def expand(somepath)
- if Bundler.current_ruby.jruby? # TODO: Unify when https://github.com/rubygems/bundler/issues/7598 fixed upstream and all supported jrubies include the fix
- somepath.expand_path(root_path).expand_path
- else
- somepath.expand_path(root_path)
- end
+ somepath.expand_path(root_path)
rescue ArgumentError => e
Bundler.ui.debug(e)
raise PathError, "There was an error while trying to use the path " \
@@ -160,7 +148,7 @@ module Bundler
def load_gemspec(file)
return unless spec = Bundler.load_gemspec(file)
- Bundler.rubygems.set_installed_by_version(spec)
+ spec.installed_by_version = Gem::VERSION
spec
end
@@ -177,6 +165,13 @@ module Bundler
next unless spec = load_gemspec(file)
spec.source = self
+ # The ignore attribute is for ignoring installed gems that don't
+ # have extensions correctly compiled for activation. In the case of
+ # path sources, there's a single version of each gem in the path
+ # source available to Bundler, so we always certainly want to
+ # consider that for activation and never makes sense to ignore it.
+ spec.ignored = false
+
# Validation causes extension_dir to be calculated, which depends
# on #source, so we validate here instead of load_gemspec
validate_spec(spec)
@@ -224,22 +219,23 @@ module Bundler
# Some gem authors put absolute paths in their gemspec
# and we have to save them from themselves
- spec.files = spec.files.map do |path|
- next path unless /\A#{Pathname::SEPARATOR_PAT}/.match?(path)
+ spec.files = spec.files.filter_map do |path|
+ pathname = Pathname.new(path)
+ next path unless pathname.absolute?
next if File.directory?(path)
begin
- Pathname.new(path).relative_path_from(gem_dir).to_s
+ pathname.relative_path_from(gem_dir).to_s
rescue ArgumentError
path
end
- end.compact
+ end
installer = Path::Installer.new(
spec,
- :env_shebang => false,
- :disable_extensions => options[:disable_extensions],
- :build_args => options[:build_args],
- :bundler_extension_cache_path => extension_cache_path(spec)
+ env_shebang: false,
+ disable_extensions: options[:disable_extensions],
+ build_args: options[:build_args],
+ bundler_extension_cache_path: extension_cache_path(spec)
)
installer.post_install
rescue Gem::InvalidSpecificationException => e
diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb
index 0af28fe770..39765e5da2 100644
--- a/lib/bundler/source/path/installer.rb
+++ b/lib/bundler/source/path/installer.rb
@@ -24,7 +24,7 @@ module Bundler
def post_install
run_hooks(:pre_install)
- unless @disable_extensions
+ unless @disable_extensions || Bundler.settings[:no_build_extension]
build_extensions
run_hooks(:post_build)
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index c39071705a..ed864604fe 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -7,23 +7,37 @@ module Bundler
class Rubygems < Source
autoload :Remote, File.expand_path("rubygems/remote", __dir__)
- # Use the API when installing less than X gems
- API_REQUEST_LIMIT = 500
# Ask for X gems per API request
- API_REQUEST_SIZE = 50
+ API_REQUEST_SIZE = 100
+ REQUIRE_MUTEX = Mutex.new
- attr_reader :remotes, :caches
+ attr_accessor :remotes
def initialize(options = {})
@options = options
@remotes = []
+ @remote_cooldowns = {}
@dependency_names = []
@allow_remote = false
@allow_cached = false
@allow_local = options["allow_local"] || false
- @caches = [cache_path, *Bundler.rubygems.gem_cache]
+ @prefer_local = false
+ @checksum_store = Checksum::Store.new
+ @gem_installers = {}
+ @gem_installers_mutex = Mutex.new
- Array(options["remotes"]).reverse_each {|r| add_remote(r) }
+ cooldown = options["cooldown"]
+ Array(options["remotes"]).reverse_each {|r| add_remote(r, cooldown: cooldown) }
+
+ @lockfile_remotes = @remotes if options["from_lockfile"]
+ end
+
+ def caches
+ @caches ||= [cache_path, *Bundler.rubygems.gem_cache]
+ end
+
+ def prefer_local!
+ @prefer_local = true
end
def local_only!
@@ -33,6 +47,10 @@ module Bundler
@allow_remote = false
end
+ def local_only?
+ @allow_local && !@allow_remote
+ end
+
def local!
return if @allow_local
@@ -48,10 +66,11 @@ module Bundler
end
def cached!
+ return unless File.exist?(cache_path)
+
return if @allow_cached
@specs = nil
- @allow_local = true
@allow_cached = true
end
@@ -87,13 +106,14 @@ module Bundler
end
def self.from_lock(options)
- new(options)
+ options["remotes"] = Array(options.delete("remote")).reverse
+ new(options.merge("from_lockfile" => true))
end
def to_lock
out = String.new("GEM\n")
- remotes.reverse_each do |remote|
- out << " remote: #{suppress_configured_credentials remote}\n"
+ lockfile_remotes.reverse_each do |remote|
+ out << " remote: #{remote}\n"
end
out << " specs:\n"
end
@@ -122,85 +142,89 @@ module Bundler
end
end
alias_method :name, :identifier
+ alias_method :to_gemfile, :identifier
def specs
@specs ||= begin
# remote_specs usually generates a way larger Index than the other
- # sources, and large_idx.use small_idx is way faster than
- # small_idx.use large_idx.
- idx = @allow_remote ? remote_specs.dup : Index.new
- idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
- idx.use(installed_specs, :override_dupes) if @allow_local
- idx
- end
- end
+ # sources, and large_idx.merge! small_idx is way faster than
+ # small_idx.merge! large_idx.
+ index = @allow_remote ? remote_specs.dup : Index.new
+
+ # Snapshot per-version `created_at` from the remote info before installed
+ # / cached specs overwrite the EndpointSpecification objects that carry
+ # it. The cooldown filter consults `created_at` on every candidate, so
+ # local stubs need the published date back-filled to participate.
+ remote_created_at = collect_remote_created_at(index)
+
+ index.merge!(cached_specs) if @allow_cached
+ index.merge!(installed_specs) if @allow_local
+
+ if @allow_local
+ if @prefer_local
+ index.merge!(default_specs)
+ else
+ # complete with default specs, only if not already available in the
+ # index through remote, cached, or installed specs
+ index.use(default_specs)
+ end
+ end
- def install(spec, options = {})
- force = options[:force]
- ensure_builtin_gems_cached = options[:ensure_builtin_gems_cached]
+ backfill_created_at(index, remote_created_at) unless remote_created_at.empty?
- if ensure_builtin_gems_cached && spec.default_gem? && !cached_path(spec)
- cached_built_in_gem(spec) unless spec.remote
- force = true
- end
-
- if installed?(spec) && !force
- print_using_message "Using #{version_message(spec, options[:previous_spec])}"
- return nil # no post-install message
+ index
end
+ end
- if spec.remote
- # Check for this spec from other sources
- uris = [spec.remote, *remotes_for_spec(spec)].map(&:anonymized_uri).uniq
- Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
+ def download(spec, options = {})
+ if (spec.default_gem? && !cached_built_in_gem(spec, local: options[:local])) || (installed?(spec) && !options[:force])
+ return true
end
- path = fetch_gem_if_possible(spec, options[:previous_spec])
- raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
-
- return if Bundler.settings[:no_install]
-
- install_path = rubygems_dir
- bin_path = Bundler.system_bindir
-
- require_relative "../rubygems_gem_installer"
-
- installer = Bundler::RubyGemsGemInstaller.at(
- path,
- :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
- :install_dir => install_path.to_s,
- :bin_dir => bin_path.to_s,
- :ignore_dependencies => true,
- :wrappers => true,
- :env_shebang => true,
- :build_args => options[:build_args],
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
- :bundler_extension_cache_path => extension_cache_path(spec)
- )
+ installer = rubygems_gem_installer(spec, options)
if spec.remote
s = begin
installer.spec
rescue Gem::Package::FormatError
- Bundler.rm_rf(path)
+ Bundler.rm_rf(installer.gem)
raise
rescue Gem::Security::Exception => e
raise SecurityError,
- "The gem #{File.basename(path, ".gem")} can't be installed because " \
+ "The gem #{installer.gem} can't be installed because " \
"the security policy didn't allow it, with the message: #{e.message}"
end
spec.__swap__(s)
end
+ spec
+ end
+
+ def install(spec, options = {})
+ if (spec.default_gem? && !cached_built_in_gem(spec, local: options[:local])) || (installed?(spec) && !options[:force])
+ print_using_message "Using #{version_message(spec, options[:previous_spec])}"
+ return nil # no post-install message
+ end
+
+ return if Bundler.settings[:no_install]
+
+ installer = rubygems_gem_installer(spec, options)
+ spec.source.checksum_store.register(spec, installer.gem_checksum)
+
message = "Installing #{version_message(spec, options[:previous_spec])}"
message += " with native extensions" if spec.extensions.any?
Bundler.ui.confirm message
- installed_spec = installer.install
+ installed_spec = nil
+
+ Gem.time("Installed #{spec.name} in", 0, true) do
+ installed_spec = installer.install
+ end
spec.full_gem_path = installed_spec.full_gem_path
spec.loaded_from = installed_spec.loaded_from
+ spec.base_dir = installed_spec.base_dir
spec.post_install_message
end
@@ -216,12 +240,13 @@ module Bundler
raise InstallError, e.message
end
- def cached_built_in_gem(spec)
- cached_path = cached_path(spec)
- if cached_path.nil?
+ def cached_built_in_gem(spec, local: false)
+ cached_path = cached_gem(spec)
+ if cached_path.nil? && !local
remote_spec = remote_specs.search(spec).first
if remote_spec
cached_path = fetch_gem(remote_spec)
+ spec.remote = remote_spec.remote
else
Bundler.ui.warn "#{spec.full_name} is built in to Ruby, and can't be cached because your Gemfile doesn't have any sources that contain it."
end
@@ -229,13 +254,18 @@ module Bundler
cached_path
end
- def add_remote(source)
+ def add_remote(source, cooldown: nil)
uri = normalize_uri(source)
@remotes.unshift(uri) unless @remotes.include?(uri)
+ @remote_cooldowns[uri] = cooldown if cooldown
+ end
+
+ def cooldown_for(uri)
+ @remote_cooldowns[uri]
end
def spec_names
- if @allow_remote && dependency_api_available?
+ if dependency_api_available?
remote_specs.spec_names
else
[]
@@ -243,22 +273,25 @@ module Bundler
end
def unmet_deps
- if @allow_remote && dependency_api_available?
+ if dependency_api_available?
remote_specs.unmet_dependency_names
else
[]
end
end
+ def remote_fetchers
+ @remote_fetchers ||= remotes.to_h do |uri|
+ remote = Source::Rubygems::Remote.new(uri, cooldown: cooldown_for(uri))
+ [remote, Bundler::Fetcher.new(remote)]
+ end.freeze
+ end
+
def fetchers
- @fetchers ||= remotes.map do |uri|
- remote = Source::Rubygems::Remote.new(uri)
- Bundler::Fetcher.new(remote)
- end
+ @fetchers ||= remote_fetchers.values.freeze
end
def double_check_for(unmet_dependency_names)
- return unless @allow_remote
return unless dependency_api_available?
unmet_dependency_names = unmet_dependency_names.call
@@ -273,7 +306,9 @@ module Bundler
Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
- fetch_names(api_fetchers, unmet_dependency_names, specs, false)
+ fetch_names(api_fetchers, unmet_dependency_names, remote_specs)
+
+ specs.use remote_specs
end
def dependency_names_to_double_check
@@ -295,6 +330,13 @@ module Bundler
@allow_remote && api_fetchers.any?
end
+ def clear_cache
+ @specs = nil
+ @installed_specs = nil
+ @default_specs = nil
+ @cached_specs = nil
+ end
+
protected
def remote_names
@@ -302,33 +344,14 @@ module Bundler
end
def credless_remotes
- if Bundler.settings[:allow_deployment_source_credential_changes]
- remotes.map(&method(:remove_auth))
- else
- remotes.map(&method(:suppress_configured_credentials))
- end
- end
-
- def remotes_for_spec(spec)
- specs.search_all(spec.name).inject([]) do |uris, s|
- uris << s.remote if s.remote
- uris
- end
+ remotes.map(&method(:remove_auth))
end
def cached_gem(spec)
- if spec.default_gem?
- cached_built_in_gem(spec)
- else
- cached_path(spec)
- end
- end
-
- def cached_path(spec)
global_cache_path = download_cache_path(spec)
- @caches << global_cache_path if global_cache_path
+ caches << global_cache_path if global_cache_path
- possibilities = @caches.map {|p| package_path(p, spec) }
+ possibilities = caches.map {|p| package_path(p, spec) }
possibilities.find {|p| File.exist?(p) }
end
@@ -337,24 +360,14 @@ module Bundler
end
def normalize_uri(uri)
- uri = uri.to_s
- uri = "#{uri}/" unless %r{/$}.match?(uri)
+ uri = URINormalizer.normalize_suffix(uri.to_s)
require_relative "../vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
raise ArgumentError, "The source must be an absolute URI. For example:\n" \
- "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Bundler::URI::HTTP) && uri.host.nil?)
+ "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Gem::URI::HTTP) && uri.host.nil?)
uri
end
- def suppress_configured_credentials(remote)
- remote_nouser = remove_auth(remote)
- if remote.userinfo && remote.userinfo == Bundler.settings[remote_nouser]
- remote_nouser
- else
- remote
- end
- end
-
def remove_auth(remote)
if remote.user || remote.password
remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
@@ -365,12 +378,18 @@ module Bundler
def installed_specs
@installed_specs ||= Index.build do |idx|
- Bundler.rubygems.all_specs.reverse_each do |spec|
+ Bundler.rubygems.installed_specs.reverse_each do |spec|
+ spec.source = self
+ next if spec.ignored?
+ idx << spec
+ end
+ end
+ end
+
+ def default_specs
+ @default_specs ||= Index.build do |idx|
+ Bundler.rubygems.default_specs.each do |spec|
spec.source = self
- if Bundler.rubygems.spec_missing_extensions?(spec, false)
- Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
- next
- end
idx << spec
end
end
@@ -378,10 +397,9 @@ module Bundler
def cached_specs
@cached_specs ||= begin
- idx = @allow_local ? installed_specs.dup : Index.new
+ idx = Index.new
Dir["#{cache_path}/*.gem"].each do |gemfile|
- next if /^bundler\-[\d\.]+?\.gem/.match?(gemfile)
s ||= Bundler.rubygems.spec_from_gem(gemfile)
s.source = self
idx << s
@@ -392,36 +410,30 @@ module Bundler
end
def api_fetchers
- fetchers.select {|f| f.use_api && f.fetchers.first.api_fetcher? }
+ fetchers.select(&:api_fetcher?)
end
def remote_specs
@remote_specs ||= Index.build do |idx|
index_fetchers = fetchers - api_fetchers
- # gather lists from non-api sites
- fetch_names(index_fetchers, nil, idx, false)
-
- # because ensuring we have all the gems we need involves downloading
- # the gemspecs of those gems, if the non-api sites contain more than
- # about 500 gems, we treat all sites as non-api for speed.
- allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
- Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
- " Downloading full index instead..." unless allow_api
-
- fetch_names(api_fetchers, allow_api && dependency_names, idx, false)
+ if index_fetchers.empty?
+ fetch_names(api_fetchers, dependency_names, idx)
+ else
+ fetch_names(fetchers, nil, idx)
+ end
end
end
- def fetch_names(fetchers, dependency_names, index, override_dupes)
+ def fetch_names(fetchers, dependency_names, index)
fetchers.each do |f|
if dependency_names
Bundler.ui.info "Fetching gem metadata from #{URICredentialsFilter.credential_filtered_uri(f.uri)}", Bundler.ui.debug?
- index.use f.specs_with_retry(dependency_names, self), override_dupes
+ index.use f.specs_with_retry(dependency_names, self)
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
else
Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}"
- index.use f.specs_with_retry(nil, self), override_dupes
+ index.use f.specs_with_retry(nil, self)
end
end
end
@@ -450,7 +462,7 @@ module Bundler
end
def installed?(spec)
- installed_specs[spec].any? && !spec.deleted_gem?
+ installed_specs[spec].any? && !spec.installation_missing?
end
def rubygems_dir
@@ -467,6 +479,35 @@ module Bundler
private
+ def collect_remote_created_at(index)
+ return {} unless @allow_remote
+
+ snapshot = {}
+ index.each do |spec|
+ next unless spec.respond_to?(:created_at) && spec.created_at
+ # Remember the remote that supplied the date too: when a source has
+ # several remotes with different per-URI cooldown settings we must
+ # restore the same one during backfill so `effective_cooldown` agrees.
+ snapshot[[spec.name, spec.version]] = [spec.created_at, spec.remote]
+ end
+ snapshot
+ end
+
+ def backfill_created_at(index, snapshot)
+ index.each do |spec|
+ next unless spec.respond_to?(:created_at=)
+ next if spec.created_at
+ remote_created_at, remote = snapshot[[spec.name, spec.version]]
+ next unless remote_created_at
+ spec.created_at = remote_created_at
+ spec.remote ||= remote if remote && spec.respond_to?(:remote=)
+ end
+ end
+
+ def lockfile_remotes
+ @lockfile_remotes || credless_remotes
+ end
+
# Checks if the requested spec exists in the global cache. If it does,
# we copy it to the download path, and if it does not, we download it.
#
@@ -482,7 +523,16 @@ module Bundler
def download_gem(spec, download_cache_path, previous_spec = nil)
uri = spec.remote.uri
Bundler.ui.confirm("Fetching #{version_message(spec, previous_spec)}")
- Bundler.rubygems.download_gem(spec, uri, download_cache_path)
+ gem_remote_fetcher = remote_fetchers.fetch(spec.remote).gem_remote_fetcher
+
+ Plugin.hook(Plugin::Events::GEM_BEFORE_FETCH, spec)
+ begin
+ Gem.time("Downloaded #{spec.name} in", 0, true) do
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path, gem_remote_fetcher)
+ end
+ ensure
+ Plugin.hook(Plugin::Events::GEM_AFTER_FETCH, spec)
+ end
end
# Returns the global cache path of the calling Rubygems::Source object.
@@ -497,17 +547,52 @@ module Bundler
# @return [Pathname] The global cache path.
#
def download_cache_path(spec)
- return unless Bundler.feature_flag.global_gem_cache?
+ return unless Bundler.settings[:global_gem_cache]
return unless remote = spec.remote
return unless cache_slug = remote.cache_slug
- Bundler.user_cache.join("gems", cache_slug)
+ if Gem.respond_to?(:global_gem_cache_path)
+ Pathname.new(Gem.global_gem_cache_path).join(cache_slug)
+ else
+ # Fall back to old location for older RubyGems versions
+ Bundler.user_cache.join("gems", cache_slug)
+ end
end
def extension_cache_slug(spec)
return unless remote = spec.remote
remote.cache_slug
end
+
+ # We are using a mutex to read and write from/to the hash.
+ # The reason this double synchronization was added is for performance
+ # and to lock the mutex for the shortest possible amount of time. Otherwise,
+ # all threads are fighting over this mutex and when it gets acquired it gets locked
+ # until a thread finishes downloading a gem, leaving the other threads waiting
+ # doing nothing.
+ def rubygems_gem_installer(spec, options)
+ @gem_installers_mutex.synchronize { @gem_installers[spec.name] } || begin
+ path = fetch_gem_if_possible(spec, options[:previous_spec])
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
+
+ REQUIRE_MUTEX.synchronize { require_relative "../rubygems_gem_installer" }
+
+ installer = Bundler::RubyGemsGemInstaller.at(
+ path,
+ security_policy: Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
+ install_dir: rubygems_dir.to_s,
+ bin_dir: Bundler.system_bindir.to_s,
+ ignore_dependencies: true,
+ wrappers: true,
+ env_shebang: true,
+ build_args: options[:build_args],
+ bundler_extension_cache_path: extension_cache_path(spec),
+ build_extension: Bundler.settings[:no_build_extension] ? false : nil,
+ install_plugin: Bundler.settings[:no_install_plugin] ? false : nil
+ )
+ @gem_installers_mutex.synchronize { @gem_installers[spec.name] ||= installer }
+ end
+ end
end
end
end
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
index 82c850ffbb..3d847424b7 100644
--- a/lib/bundler/source/rubygems/remote.rb
+++ b/lib/bundler/source/rubygems/remote.rb
@@ -4,9 +4,9 @@ module Bundler
class Source
class Rubygems
class Remote
- attr_reader :uri, :anonymized_uri, :original_uri
+ attr_reader :uri, :anonymized_uri, :original_uri, :cooldown
- def initialize(uri)
+ def initialize(uri, cooldown: nil)
orig_uri = uri
uri = Bundler.settings.mirror_for(uri)
@original_uri = orig_uri if orig_uri != uri
@@ -14,8 +14,21 @@ module Bundler
@uri = apply_auth(uri, fallback_auth).freeze
@anonymized_uri = remove_auth(@uri).freeze
+ @cooldown = cooldown
end
+ # Returns the cooldown days that apply to this remote, resolving the
+ # precedence CLI > config > Gemfile per-source. Returns nil if no
+ # cooldown applies.
+ def effective_cooldown
+ override = Bundler.settings[:cooldown]
+ return override if override
+ @cooldown
+ end
+
+ MAX_CACHE_SLUG_HOST_SIZE = 255 - 1 - 32 # 255 minus dot minus MD5 length
+ private_constant :MAX_CACHE_SLUG_HOST_SIZE
+
# @return [String] A slug suitable for use as a cache key for this
# remote.
#
@@ -28,10 +41,15 @@ module Bundler
host = cache_uri.to_s.start_with?("file://") ? nil : cache_uri.host
uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path]
- uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join("."))
+ uri_parts.compact!
+ uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.join("."))
+
+ uri_parts.pop
+ host_parts = uri_parts.join(".")
+ return uri_digest if host_parts.empty?
- uri_parts[-1] = uri_digest
- uri_parts.compact.join(".")
+ shortened_host_parts = host_parts[0...MAX_CACHE_SLUG_HOST_SIZE]
+ [shortened_host_parts, uri_digest].join(".")
end
end
@@ -48,7 +66,7 @@ module Bundler
end
uri
- rescue Bundler::URI::InvalidComponentError
+ rescue Gem::URI::InvalidComponentError
error_message = "Please CGI escape your usernames and passwords before " \
"setting them for authentication."
raise HTTPError.new(error_message)
diff --git a/lib/bundler/source/rubygems_aggregate.rb b/lib/bundler/source/rubygems_aggregate.rb
index 99ef81ad54..8aeaa375fa 100644
--- a/lib/bundler/source/rubygems_aggregate.rb
+++ b/lib/bundler/source/rubygems_aggregate.rb
@@ -5,9 +5,10 @@ module Bundler
class RubygemsAggregate
attr_reader :source_map, :sources
- def initialize(sources, source_map)
+ def initialize(sources, source_map, excluded_sources = [])
@sources = sources
@source_map = source_map
+ @excluded_sources = excluded_sources
@index = build_index
end
@@ -31,6 +32,8 @@ module Bundler
dependency_names = source_map.pinned_spec_names
sources.all_sources.each do |source|
+ next if @excluded_sources.include?(source)
+
source.dependency_names = dependency_names - source_map.pinned_spec_names(source)
idx.add_source source.specs
dependency_names.concat(source.unmet_deps).uniq!
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index 63798db941..ab7002d6e5 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -9,7 +9,7 @@ module Bundler
:metadata_source
def global_rubygems_source
- @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
+ @global_rubygems_source ||= source_class.new("allow_local" => true)
end
def initialize
@@ -21,16 +21,7 @@ module Bundler
@rubygems_sources = []
@metadata_source = Source::Metadata.new
- @merged_gem_lockfile_sections = false
- end
-
- def merged_gem_lockfile_sections?
- @merged_gem_lockfile_sections
- end
-
- def merged_gem_lockfile_sections!(replacement_source)
- @merged_gem_lockfile_sections = true
- @global_rubygems_source = replacement_source
+ @local_mode = true
end
def aggregate_global_source?
@@ -68,11 +59,15 @@ module Bundler
add_source_to_list Plugin.source(source).new(options), @plugin_sources
end
- def add_global_rubygems_remote(uri)
- global_rubygems_source.add_remote(uri)
+ def add_global_rubygems_remote(uri, cooldown: nil)
+ global_rubygems_source.add_remote(uri, cooldown: cooldown)
global_rubygems_source
end
+ def local_mode?
+ @local_mode
+ end
+
def default_source
global_path_source || global_rubygems_source
end
@@ -85,10 +80,6 @@ module Bundler
@rubygems_sources
end
- def rubygems_remotes
- rubygems_sources.map(&:remotes).flatten.uniq
- end
-
def all_sources
path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
end
@@ -98,11 +89,7 @@ module Bundler
end
def get(source)
- source_list_for(source).find {|s| equivalent_source?(source, s) }
- end
-
- def get_with_fallback(source)
- get(source) || default_source
+ source_list_for(source).find {|s| s.include?(source) }
end
def lock_sources
@@ -114,11 +101,7 @@ module Bundler
end
def lock_rubygems_sources
- if merged_gem_lockfile_sections?
- [combine_rubygems_sources]
- else
- rubygems_sources.sort_by(&:identifier)
- end
+ rubygems_sources.sort_by(&:identifier)
end
# Returns true if there are changes
@@ -128,65 +111,91 @@ module Bundler
@rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
@global_rubygems_source = global_replacement_source(replacement_sources)
- different_sources?(lock_sources, replacement_sources)
+ !equivalent_sources?(lock_sources, replacement_sources)
end
- # Returns true if there are changes
- def expired_sources?(replacement_sources)
- return false if replacement_sources.empty?
-
- lock_sources = dup_with_replaced_sources(replacement_sources).lock_sources
-
- different_sources?(lock_sources, replacement_sources)
+ def prefer_local!
+ all_sources.each(&:prefer_local!)
end
def local_only!
all_sources.each(&:local_only!)
end
+ def local!
+ all_sources.each(&:local!)
+ end
+
def cached!
all_sources.each(&:cached!)
end
def remote!
+ @local_mode = false
+
all_sources.each(&:remote!)
end
- private
-
- def dup_with_replaced_sources(replacement_sources)
- new_source_list = dup
- new_source_list.replace_sources!(replacement_sources)
- new_source_list
+ def clear_cache
+ rubygems_sources.each(&:clear_cache)
end
+ private
+
def map_sources(replacement_sources)
- rubygems, git, plugin = [@rubygems_sources, @git_sources, @plugin_sources].map do |sources|
+ rubygems = @rubygems_sources.map do |source|
+ replace_rubygems_source(replacement_sources, source)
+ end
+
+ git, plugin = [@git_sources, @plugin_sources].map do |sources|
sources.map do |source|
- replacement_sources.find {|s| s == source } || source
+ replace_source(replacement_sources, source)
end
end
path = @path_sources.map do |source|
- replacement_sources.find {|s| s == (source.is_a?(Source::Gemspec) ? source.as_path_source : source) } || source
+ replace_path_source(replacement_sources, source)
end
[rubygems, path, git, plugin]
end
def global_replacement_source(replacement_sources)
- replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
- return global_rubygems_source unless replacement_source
+ replace_rubygems_source(replacement_sources, global_rubygems_source, &:local!)
+ end
+
+ def replace_rubygems_source(replacement_sources, gemfile_source)
+ replace_source(replacement_sources, gemfile_source) do |replacement_source|
+ # locked sources never include credentials so always prefer remotes from the gemfile
+ replacement_source.remotes = gemfile_source.remotes
+
+ yield replacement_source if block_given?
+
+ replacement_source
+ end
+ end
+
+ def replace_source(replacement_sources, gemfile_source)
+ replacement_source = replacement_sources.find {|s| s == gemfile_source }
+ return gemfile_source unless replacement_source
+
+ replacement_source = yield(replacement_source) if block_given?
- replacement_source.local!
replacement_source
end
- def different_sources?(lock_sources, replacement_sources)
- !equivalent_sources?(lock_sources, replacement_sources)
+ def replace_path_source(replacement_sources, gemfile_source)
+ replace_source(replacement_sources, gemfile_source) do |replacement_source|
+ if gemfile_source.is_a?(Source::Gemspec)
+ gemfile_source.checksum_store = replacement_source.checksum_store
+ gemfile_source
+ else
+ replacement_source
+ end
+ end
end
- def rubygems_aggregate_class
+ def source_class
Source::Rubygems
end
@@ -205,10 +214,6 @@ module Bundler
end
end
- def combine_rubygems_sources
- Source::Rubygems.new("remotes" => rubygems_remotes)
- end
-
def warn_on_git_protocol(source)
return if Bundler.settings["git.allow_insecure"]
@@ -223,9 +228,5 @@ module Bundler
def equivalent_sources?(lock_sources, replacement_sources)
lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
end
-
- def equivalent_source?(source, other_source)
- source == other_source
- end
end
end
diff --git a/lib/bundler/source_map.rb b/lib/bundler/source_map.rb
index ca73e01f9d..513eb37f8b 100644
--- a/lib/bundler/source_map.rb
+++ b/lib/bundler/source_map.rb
@@ -14,24 +14,25 @@ module Bundler
direct_requirements.reject {|_, source| source == skip }.keys
end
- def all_requirements
+ def all_requirements(excluded_sources = [])
requirements = direct_requirements.dup
- unmet_deps = sources.non_default_explicit_sources.map do |source|
+ explicit_sources = sources.non_default_explicit_sources.reject do |source|
+ excluded_sources.include?(source)
+ end
+
+ unmet_deps = explicit_sources.map do |source|
(source.spec_names - pinned_spec_names).each do |indirect_dependency_name|
previous_source = requirements[indirect_dependency_name]
if previous_source.nil?
requirements[indirect_dependency_name] = source
else
- no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
-
msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
- msg << "You #{no_ambiguous_sources ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
+ msg << "You must add this gem to the source block for the source you wish it to be installed from."
msg = msg.join("\n")
- raise SecurityError, msg if no_ambiguous_sources
- Bundler.ui.warn "Warning: #{msg}"
+ raise SecurityError, msg
end
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 08f523312c..ae5e5cbaa9 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -7,66 +7,107 @@ module Bundler
include Enumerable
include TSort
- attr_reader :incomplete_specs
-
- def initialize(specs, incomplete_specs = [])
+ def initialize(specs)
@specs = specs
- @incomplete_specs = incomplete_specs
end
- def for(dependencies, check = false, platforms = [nil])
- handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
- deps = dependencies.product(platforms)
- specs = []
-
- loop do
- break unless dep = deps.shift
+ def for(dependencies, platforms = [nil], legacy_platforms = [nil], skips: [])
+ if [true, false].include?(platforms)
+ Bundler::SharedHelpers.feature_removed! \
+ "SpecSet#for received a `check` parameter, but that's no longer used and deprecated. " \
+ "SpecSet#for always implicitly performs validation. Please remove this parameter"
+ end
- name = dep[0].name
- platform = dep[1]
- incomplete = false
+ materialize_dependencies(dependencies, platforms, skips: skips)
- key = [name, platform]
- next if handled.key?(key)
+ @materializations.flat_map(&:specs).uniq
+ end
- handled[key] = true
+ def normalize_platforms!(deps, platforms)
+ remove_invalid_platforms!(deps, platforms)
+ add_extra_platforms!(platforms)
- specs_for_dep = specs_for_dependency(*dep)
- if specs_for_dep.any?
- specs.concat(specs_for_dep)
+ platforms.map! do |platform|
+ next platform if platform == Gem::Platform::RUBY
- specs_for_dep.first.dependencies.each do |d|
- next if d.type == :development
- incomplete = true if d.name != "bundler" && lookup[d.name].empty?
- deps << [d, dep[1]]
- end
- else
- incomplete = true
+ begin
+ Integer(platform.version)
+ rescue ArgumentError, TypeError
+ next platform
end
- if incomplete && check
- @incomplete_specs += lookup[name].any? ? lookup[name] : [LazySpecification.new(name, nil, nil)]
- end
+ less_specific_platform = Gem::Platform.new([platform.cpu, platform.os, nil])
+ next platform if incomplete_for_platform?(deps, less_specific_platform)
+
+ less_specific_platform
+ end.uniq!
+ end
+
+ def add_originally_invalid_platforms!(platforms, originally_invalid_platforms)
+ originally_invalid_platforms.each do |originally_invalid_platform|
+ platforms << originally_invalid_platform if complete_platform(originally_invalid_platform)
+ end
+ end
+
+ def remove_invalid_platforms!(deps, platforms, skips: [])
+ invalid_platforms = []
+
+ platforms.reject! do |platform|
+ next false if skips.include?(platform)
+
+ invalid = incomplete_for_platform?(deps, platform)
+ invalid_platforms << platform if invalid
+ invalid
end
- specs.uniq
+ invalid_platforms
+ end
+
+ def add_extra_platforms!(platforms)
+ if @specs.empty?
+ platforms.concat([Gem::Platform::RUBY]).uniq
+ return
+ end
+
+ new_platforms = all_platforms.select do |platform|
+ next if platforms.include?(platform)
+ next unless Gem::Platform.generic(platform) == Gem::Platform::RUBY
+
+ complete_platform(platform)
+ end
+ return if new_platforms.empty?
+
+ platforms.concat(new_platforms)
+ return if new_platforms.include?(Bundler.local_platform)
+
+ less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && Bundler.local_platform === platform && platform === Bundler.local_platform }
+ platforms.delete(Bundler.local_platform) if less_specific_platform
+ end
+
+ def validate_deps(s)
+ s.runtime_dependencies.each do |dep|
+ next if dep.name == "bundler"
+
+ return :missing unless names.include?(dep.name)
+ return :invalid if none? {|spec| dep.matches_spec?(spec) }
+ end
+
+ :valid
end
def [](key)
key = key.name if key.respond_to?(:name)
- lookup[key].reverse
+ lookup[key]&.reverse || []
end
def []=(key, value)
- @specs << value
- @lookup = nil
- @sorted = nil
+ delete_by_name(key)
+
+ add_spec(value)
end
- def delete(spec)
- @specs.delete(spec)
- @lookup = nil
- @sorted = nil
+ def delete(specs)
+ Array(specs).each {|spec| remove_spec(spec) }
end
def sort!
@@ -82,67 +123,89 @@ module Bundler
end
def materialize(deps)
- materialized = self.for(deps, true)
+ materialize_dependencies(deps)
- SpecSet.new(materialized, incomplete_specs)
+ SpecSet.new(materialized_specs)
end
# Materialize for all the specs in the spec set, regardless of what platform they're for
- # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
# @return [Array<Gem::Specification>]
def materialized_for_all_platforms
@specs.map do |s|
next s unless s.is_a?(LazySpecification)
- s.source.remote!
- spec = s.materialize_for_installation
+ spec = s.materialize_for_cache
raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
spec
end
end
- def incomplete_ruby_specs?(deps)
- self.for(deps, true, [Gem::Platform::RUBY])
+ def incomplete_for_platform?(deps, platform)
+ incomplete_specs_for_platform(deps, platform).any?
+ end
- @incomplete_specs.any?
+ def incomplete_specs_for_platform(deps, platform)
+ return [] if @specs.empty?
+
+ validation_set = self.class.new(@specs)
+ validation_set.for(deps, [platform])
+ validation_set.incomplete_specs
+ end
+
+ def missing_specs_for(deps)
+ materialize_dependencies(deps)
+
+ missing_specs
end
def missing_specs
- @specs.select {|s| s.is_a?(LazySpecification) }
+ @materializations.flat_map(&:completely_missing_specs)
end
- def merge(set)
- arr = sorted.dup
- set.each do |set_spec|
- full_name = set_spec.full_name
- next if arr.any? {|spec| spec.full_name == full_name }
- arr << set_spec
- end
- SpecSet.new(arr)
+ def partially_missing_specs
+ @materializations.flat_map(&:partially_missing_specs)
+ end
+
+ def incomplete_specs
+ @materializations.flat_map(&:incomplete_specs)
+ end
+
+ def insecurely_materialized_specs
+ materialized_specs.select(&:insecurely_materialized?)
end
def -(other)
- SpecSet.new(to_a - other.to_a)
+ SharedHelpers.feature_removed! "SpecSet#- has been removed with no replacement"
end
def find_by_name_and_platform(name, platform)
- @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
+ lookup[name]&.detect {|spec| spec.installable_on_platform?(platform) }
+ end
+
+ def specs_with_additional_variants_from(other)
+ sorted | additional_variants_from(other)
end
def delete_by_name(name)
@specs.reject! {|spec| spec.name == name }
- @lookup = nil
- @sorted = nil
+ @sorted&.reject! {|spec| spec.name == name }
+ return if @lookup.nil?
+
+ @lookup[name] = nil
+ end
+
+ def version_for(name)
+ exemplary_spec(name)&.version
end
def what_required(spec)
- unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } }
+ unless req = find {|s| s.runtime_dependencies.any? {|d| d.name == spec.name } }
return [spec]
end
what_required(req) << spec
end
def <<(spec)
- @specs << spec
+ SharedHelpers.feature_removed! "SpecSet#<< has been removed with no replacement"
end
def length
@@ -161,29 +224,125 @@ module Bundler
sorted.each(&b)
end
+ def names
+ lookup.keys
+ end
+
+ def valid?(s)
+ s.matches_current_metadata? && valid_dependencies?(s)
+ end
+
+ def to_s
+ map(&:full_name).to_s
+ end
+
private
- def sorted
- rake = @specs.find {|s| s.name == "rake" }
- begin
- @sorted ||= ([rake] + tsort).compact.uniq
- rescue TSort::Cyclic => error
- cgems = extract_circular_gems(error)
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
- " on each other, creating an infinite loop. Please remove either" \
- " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
+ def materialize_dependencies(dependencies, platforms = [nil], skips: [])
+ handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
+ deps = dependencies.product(platforms)
+ @materializations = []
+
+ loop do
+ break unless dep = deps.shift
+
+ dependency = dep[0]
+ platform = dep[1]
+ name = dependency.name
+
+ key = [name, platform]
+ next if handled.key?(key)
+
+ handled[key] = true
+
+ materialization = Materialization.new(dependency, platform, candidates: lookup[name])
+
+ deps.concat(materialization.dependencies) if materialization.complete?
+
+ @materializations << materialization unless skips.include?(name)
+ end
+
+ @materializations
+ end
+
+ def materialized_specs
+ @materializations.filter_map(&:materialized_spec)
+ end
+
+ def complete_platform(platform)
+ new_specs = []
+
+ valid_platform = lookup.all? do |_, specs|
+ spec = specs.first
+ # The matching candidates returned by source.specs.search are remote
+ # specs that do not carry the override list themselves. Borrow it from
+ # the LazySpec we are validating so platform-variant validation honors
+ # the same overrides the install/resolve path already applies.
+ overrides = spec.is_a?(LazySpecification) ? Array(spec.overrides) : []
+ matching_specs = spec.source.specs.search([spec.name, spec.version])
+ platform_spec = MatchPlatform.select_best_platform_match(matching_specs, platform).find do |s|
+ s.matches_current_metadata_with_overrides?(overrides) && valid_dependencies?(s)
+ end
+
+ if platform_spec
+ unless specs.include?(platform_spec)
+ new_lazy = LazySpecification.from_spec(platform_spec)
+ # Carry the overrides forward so a follow-up complete_platform
+ # call that picks this synthesized variant as its exemplar still
+ # honors the user's override list.
+ new_lazy.overrides = overrides if overrides.any?
+ new_specs << new_lazy
+ end
+ true
+ else
+ false
+ end
+ end
+
+ if valid_platform && new_specs.any?
+ new_specs.each {|spec| add_spec(spec) }
+ end
+
+ valid_platform
+ end
+
+ def all_platforms
+ @specs.flat_map {|spec| spec.source.specs.search([spec.name, spec.version]).map(&:platform) }.uniq
+ end
+
+ def additional_variants_from(other)
+ other.select do |other_spec|
+ spec = exemplary_spec(other_spec.name)
+ next unless spec
+
+ selected = spec.version == other_spec.version && valid_dependencies?(other_spec)
+ other_spec.source = spec.source if selected
+ selected
end
end
+ def valid_dependencies?(s)
+ validate_deps(s) == :valid
+ end
+
+ def sorted
+ @sorted ||= ([lookup["rake"]&.first] + tsort).compact.uniq
+ rescue TSort::Cyclic => error
+ cgems = extract_circular_gems(error)
+ raise CyclicDependencyError, "Your bundle requires gems that depend" \
+ " on each other, creating an infinite loop. Please remove either" \
+ " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
+ end
+
def extract_circular_gems(error)
error.message.scan(/@name="(.*?)"/).flatten
end
def lookup
@lookup ||= begin
- lookup = Hash.new {|h, k| h[k] = [] }
+ lookup = {}
@specs.each do |s|
- lookup[s.name] << s
+ index_spec(lookup, s.name, s)
end
lookup
end
@@ -194,19 +353,50 @@ module Bundler
@specs.sort_by(&:name).each {|s| yield s }
end
- def specs_for_dependency(dep, platform)
- specs_for_name = lookup[dep.name]
- target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
- matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
- matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
- matching_specs
- end
-
def tsort_each_child(s)
s.dependencies.sort_by(&:name).each do |d|
next if d.type == :development
- lookup[d.name].each {|s2| yield s2 }
+
+ specs_for_name = lookup[d.name]
+ next unless specs_for_name
+
+ specs_for_name.each {|s2| yield s2 }
+ end
+ end
+
+ def add_spec(spec)
+ @specs << spec
+
+ name = spec.name
+
+ @sorted&.insert(@sorted.bsearch_index {|s| s.name >= name } || @sorted.size, spec)
+ return if @lookup.nil?
+
+ index_spec(@lookup, name, spec)
+ end
+
+ def remove_spec(spec)
+ @specs.delete(spec)
+ @sorted&.delete(spec)
+ return if @lookup.nil?
+
+ indexed_specs = @lookup[spec.name]
+ return unless indexed_specs
+
+ if indexed_specs.size > 1
+ @lookup[spec.name].delete(spec)
+ else
+ @lookup[spec.name] = nil
end
end
+
+ def index_spec(hash, key, value)
+ hash[key] ||= []
+ hash[key] << value
+ end
+
+ def exemplary_spec(name)
+ self[name].first
+ end
end
end
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index 88a4257fa4..b353642b40 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -9,6 +9,11 @@ module Bundler
spec
end
+ def insecurely_materialized?
+ false
+ end
+
+ attr_reader :checksum
attr_accessor :stub, :ignored
def source=(source)
@@ -16,7 +21,8 @@ module Bundler
# Stub has no concept of source, which means that extension_dir may be wrong
# This is the case for git-based gems. So, instead manually assign the extension dir
return unless source.respond_to?(:extension_dir_name)
- path = File.join(stub.extensions_dir, source.extension_dir_name)
+ unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
+ path = File.join(stub.extensions_dir, unique_extension_dir)
stub.extension_dir = File.expand_path(path)
end
@@ -26,6 +32,17 @@ module Bundler
# @!group Stub Delegates
+ def ignored?
+ return @ignored unless @ignored.nil?
+
+ @ignored = missing_extensions?
+ return false unless @ignored
+
+ warn "Source #{source} is ignoring #{self} because it is missing extensions"
+
+ true
+ end
+
def manually_installed?
# This is for manually installed gems which are gems that were fixed in place after a
# failed installation. Once the issue was resolved, the user then manually created
@@ -35,6 +52,7 @@ module Bundler
# This is defined directly to avoid having to loading the full spec
def missing_extensions?
+ return false if RUBY_ENGINE == "jruby"
return false if default_gem?
return false if extensions.empty?
return false if File.exist? gem_build_complete_path
@@ -43,8 +61,8 @@ module Bundler
true
end
- def activated
- stub.activated
+ def activated?
+ stub.activated?
end
def activated=(activated)
@@ -56,7 +74,7 @@ module Bundler
end
def gem_build_complete_path
- File.join(extension_dir, "gem.build_complete")
+ stub.gem_build_complete_path
end
def default_gem?
@@ -75,6 +93,14 @@ module Bundler
stub.full_require_paths
end
+ def require_paths
+ stub.require_paths
+ end
+
+ def base_dir=(path)
+ stub.base_dir = path
+ end
+
def load_paths
full_require_paths
end
@@ -91,6 +117,10 @@ module Bundler
stub.raw_require_paths
end
+ def inspect
+ "#<#{self.class} @name=\"#{name}\" (#{full_name.delete_prefix("#{name}-")})>"
+ end
+
private
def _remote_specification
@@ -108,6 +138,7 @@ module Bundler
end
rs.source = source
+ rs.base_dir = stub.base_dir
rs
end
diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable
index 9ff6f00898..b085c24da6 100644
--- a/lib/bundler/templates/Executable
+++ b/lib/bundler/templates/Executable
@@ -10,17 +10,6 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir__)
-bundle_binstub = File.expand_path("bundle", __dir__)
-
-if File.file?(bundle_binstub)
- if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
- load(bundle_binstub)
- else
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
-Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
- end
-end
-
require "rubygems"
require "bundler/setup"
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
deleted file mode 100644
index e290fe91eb..0000000000
--- a/lib/bundler/templates/Executable.bundler
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
-# frozen_string_literal: true
-
-#
-# This file was generated by Bundler.
-#
-# The application '<%= executable %>' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "rubygems"
-
-m = Module.new do
- module_function
-
- def invoked_as_script?
- File.expand_path($0) == File.expand_path(__FILE__)
- end
-
- def env_var_version
- ENV["BUNDLER_VERSION"]
- end
-
- def cli_arg_version
- return unless invoked_as_script? # don't want to hijack other binstubs
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
- bundler_version = nil
- update_index = nil
- ARGV.each_with_index do |a, i|
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
- bundler_version = a
- end
- next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
- bundler_version = $1
- update_index = i
- end
- bundler_version
- end
-
- def gemfile
- gemfile = ENV["BUNDLE_GEMFILE"]
- return gemfile if gemfile && !gemfile.empty?
-
- File.expand_path("<%= relative_gemfile_path %>", __dir__)
- end
-
- def lockfile
- lockfile =
- case File.basename(gemfile)
- when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
- else "#{gemfile}.lock"
- end
- File.expand_path(lockfile)
- end
-
- def lockfile_version
- return unless File.file?(lockfile)
- lockfile_contents = File.read(lockfile)
- return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
- Regexp.last_match(1)
- end
-
- def bundler_requirement
- @bundler_requirement ||=
- env_var_version ||
- cli_arg_version ||
- bundler_requirement_for(lockfile_version)
- end
-
- def bundler_requirement_for(version)
- return "#{Gem::Requirement.default}.a" unless version
-
- bundler_gem_version = Gem::Version.new(version)
-
- bundler_gem_version.approximate_recommendation
- end
-
- def load_bundler!
- ENV["BUNDLE_GEMFILE"] ||= gemfile
-
- activate_bundler
- end
-
- def activate_bundler
- gem_error = activation_error_handling do
- gem "bundler", bundler_requirement
- end
- return if gem_error.nil?
- require_error = activation_error_handling do
- require "bundler/version"
- end
- return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
- warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
- exit 42
- end
-
- def activation_error_handling
- yield
- nil
- rescue StandardError, LoadError => e
- e
- end
-end
-
-m.load_bundler!
-
-if m.invoked_as_script?
- load Gem.bin_path("<%= spec.name %>", "<%= executable %>")
-end
diff --git a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
index 175b821a62..633baebdd5 100644
--- a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
+++ b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
@@ -1,84 +1,10 @@
-# Contributor Covenant Code of Conduct
+# Code of Conduct
-## Our Pledge
+<%= config[:name].inspect %> follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
-We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
+* Participants will be tolerant of opposing views.
+* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
+* When interpreting the words and actions of others, participants should always assume good intentions.
+* Behaviour which can be reasonably considered harassment will not be tolerated.
-We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
-
-## Our Standards
-
-Examples of behavior that contributes to a positive environment for our community include:
-
-* Demonstrating empathy and kindness toward other people
-* Being respectful of differing opinions, viewpoints, and experiences
-* Giving and gracefully accepting constructive feedback
-* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
-* Focusing on what is best not just for us as individuals, but for the overall community
-
-Examples of unacceptable behavior include:
-
-* The use of sexualized language or imagery, and sexual attention or
- advances of any kind
-* Trolling, insulting or derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or email
- address, without their explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Enforcement Responsibilities
-
-Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
-
-Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
-
-## Scope
-
-This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <%= config[:email] %>. All complaints will be reviewed and investigated promptly and fairly.
-
-All community leaders are obligated to respect the privacy and security of the reporter of any incident.
-
-## Enforcement Guidelines
-
-Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
-
-### 1. Correction
-
-**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
-
-**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
-
-### 2. Warning
-
-**Community Impact**: A violation through a single incident or series of actions.
-
-**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
-
-### 3. Temporary Ban
-
-**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
-
-**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
-
-### 4. Permanent Ban
-
-**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
-
-**Consequence**: A permanent ban from any sort of public interaction within the community.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
-available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
-
-Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
-
-[homepage]: https://www.contributor-covenant.org
-
-For answers to common questions about this code of conduct, see the FAQ at
-https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
+If you have any concerns about behaviour within this project, please contact us at [<%= config[:email].inspect %>](mailto:<%= config[:email].inspect %>).
diff --git a/lib/bundler/templates/newgem/Cargo.toml.tt b/lib/bundler/templates/newgem/Cargo.toml.tt
index f5a460c9bb..cd00f97e5a 100644
--- a/lib/bundler/templates/newgem/Cargo.toml.tt
+++ b/lib/bundler/templates/newgem/Cargo.toml.tt
@@ -5,3 +5,9 @@
[workspace]
members = ["./ext/<%= config[:name] %>"]
resolver = "2"
+
+[profile.release]
+# By default, debug symbols are stripped from the final binary which makes it
+# harder to debug if something goes wrong. It's recommended to keep debug
+# symbols in the release build so that you can debug the final binary if needed.
+debug = true
diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt
index a0d2ac2826..85dc593b8f 100644
--- a/lib/bundler/templates/newgem/Gemfile.tt
+++ b/lib/bundler/templates/newgem/Gemfile.tt
@@ -5,22 +5,20 @@ source "https://rubygems.org"
# Specify your gem's dependencies in <%= config[:name] %>.gemspec
gemspec
-gem "rake", "~> 13.0"
+gem "irb"
+gem "rake", ">= 13.0"
<%- if config[:ext] -%>
gem "rake-compiler"
-<%- if config[:ext] == 'rust' -%>
-gem "rb_sys", "~> 0.9.63"
-<%- end -%>
<%- end -%>
<%- if config[:test] -%>
-gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
+gem "<%= config[:test] %>"
<%- end -%>
<%- if config[:linter] == "rubocop" -%>
-gem "rubocop", "~> <%= config[:linter_version] %>"
+gem "rubocop"
<%- elsif config[:linter] == "standard" -%>
-gem "standard", "~> <%= config[:linter_version] %>"
+gem "standard"
<%- end -%>
diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt
index 5bf36378e8..0ec6a12fa7 100644
--- a/lib/bundler/templates/newgem/README.md.tt
+++ b/lib/bundler/templates/newgem/README.md.tt
@@ -10,11 +10,15 @@ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_O
Install the gem and add to the application's Gemfile by executing:
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+```bash
+bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+```
If bundler is not being used to manage dependencies, install the gem by executing:
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+```bash
+gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+```
## Usage
@@ -22,7 +26,7 @@ TODO: Write usage instructions here
## Development
-After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %>
+After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test_task] %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %>
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
<% if config[:git] -%>
diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt
index b5a5c4e392..83f10009c7 100644
--- a/lib/bundler/templates/newgem/Rakefile.tt
+++ b/lib/bundler/templates/newgem/Rakefile.tt
@@ -4,13 +4,9 @@ require "bundler/gem_tasks"
<% default_task_names = [config[:test_task]].compact -%>
<% case config[:test] -%>
<% when "minitest" -%>
-require "rake/testtask"
+require "minitest/test_task"
-Rake::TestTask.new(:test) do |t|
- t.libs << "test"
- t.libs << "lib"
- t.test_files = FileList["test/**/test_*.rb"]
-end
+Minitest::TestTask.create
<% when "test-unit" -%>
require "rake/testtask"
@@ -46,7 +42,9 @@ require "rb_sys/extensiontask"
task build: :compile
-RbSys::ExtensionTask.new(<%= config[:name].inspect %>) do |ext|
+GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
+
+RbSys::ExtensionTask.new(<%= config[:name].inspect %>, GEMSPEC) do |ext|
ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
<% else -%>
@@ -54,11 +52,18 @@ require "rake/extensiontask"
task build: :compile
-Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
+GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
+
+Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
<% end -%>
+<% if config[:ext] == "go" -%>
+require "go_gem/rake_task"
+
+GoGem::RakeTask.new("<%= config[:underscored_name] %>")
+<% end -%>
<% end -%>
<% if default_task_names.size == 1 -%>
task default: <%= default_task_names.first.inspect %>
diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt
index 08dfaaef69..c91ee65f93 100644
--- a/lib/bundler/templates/newgem/bin/console.tt
+++ b/lib/bundler/templates/newgem/bin/console.tt
@@ -7,9 +7,5 @@ require "<%= config[:namespaced_path] %>"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
-# (If you use this, don't forget to add pry to your Gemfile!)
-# require "pry"
-# Pry.start
-
require "irb"
IRB.start(__FILE__)
diff --git a/lib/bundler/templates/newgem/circleci/config.yml.tt b/lib/bundler/templates/newgem/circleci/config.yml.tt
index f40f029bf1..c4dd9d0647 100644
--- a/lib/bundler/templates/newgem/circleci/config.yml.tt
+++ b/lib/bundler/templates/newgem/circleci/config.yml.tt
@@ -7,6 +7,10 @@ jobs:
environment:
RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ environment:
+ GO_VERSION: '1.23.0'
+<%- end -%>
steps:
- checkout
<%- if config[:ext] == 'rust' -%>
@@ -17,6 +21,14 @@ jobs:
name: Install a RubyGems version that can compile rust extensions
command: gem update --system '<%= ::Gem.rubygems_version %>'
<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ - run:
+ name: Install Go
+ command: |
+ wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
+ tar -C /usr/local -xzf /tmp/go.tar.gz
+ echo 'export PATH=/usr/local/go/bin:"$PATH"' >> "$BASH_ENV"
+<%- end -%>
- run:
name: Run the default task
command: |
diff --git a/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt b/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
index 4b6e9587f7..a06166aee7 100644
--- a/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
@@ -12,4 +12,11 @@ publish = false
crate-type = ["cdylib"]
[dependencies]
-magnus = { version = "0.4" }
+magnus = { version = "0.8.2" }
+rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
+
+[build-dependencies]
+rb-sys-env = "0.2.2"
+
+[dev-dependencies]
+rb-sys-test-helpers = { version = "0.2.2" }
diff --git a/lib/bundler/templates/newgem/ext/newgem/build.rs.tt b/lib/bundler/templates/newgem/ext/newgem/build.rs.tt
new file mode 100644
index 0000000000..80a7842753
--- /dev/null
+++ b/lib/bundler/templates/newgem/ext/newgem/build.rs.tt
@@ -0,0 +1,5 @@
+pub fn main() -> Result<(), Box<dyn std::error::Error>> {
+ let _ = rb_sys_env::activate()?;
+
+ Ok(())
+}
diff --git a/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt b/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
index e918063ddf..0a0c5a3d09 100644
--- a/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
@@ -2,4 +2,9 @@
require "mkmf"
+# Makes all symbols private by default to avoid unintended conflict
+# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
+# selectively, or entirely remove this flag.
+append_cflags("-fvisibility=hidden")
+
create_makefile(<%= config[:makefile_path].inspect %>)
diff --git a/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt b/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt
new file mode 100644
index 0000000000..a689e21ebe
--- /dev/null
+++ b/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require "mkmf"
+require "go_gem/mkmf"
+
+# Makes all symbols private by default to avoid unintended conflict
+# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
+# selectively, or entirely remove this flag.
+append_cflags("-fvisibility=hidden")
+
+create_go_makefile(<%= config[:makefile_path].inspect %>)
diff --git a/lib/bundler/templates/newgem/ext/newgem/go.mod.tt b/lib/bundler/templates/newgem/ext/newgem/go.mod.tt
new file mode 100644
index 0000000000..3f4819d004
--- /dev/null
+++ b/lib/bundler/templates/newgem/ext/newgem/go.mod.tt
@@ -0,0 +1,5 @@
+module github.com/<%= config[:go_module_username] %>/<%= config[:underscored_name] %>
+
+go 1.23
+
+require github.com/ruby-go-gem/go-gem-wrapper latest
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt b/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt
new file mode 100644
index 0000000000..119c0c96ea
--- /dev/null
+++ b/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt
@@ -0,0 +1,2 @@
+#include "<%= config[:underscored_name] %>.h"
+#include "_cgo_export.h"
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
index 8177c4d202..bcd5148569 100644
--- a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
@@ -2,7 +2,7 @@
VALUE rb_m<%= config[:constant_array].join %>;
-void
+RUBY_FUNC_EXPORTED void
Init_<%= config[:underscored_name] %>(void)
{
rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>);
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt
new file mode 100644
index 0000000000..f19b750e58
--- /dev/null
+++ b/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt
@@ -0,0 +1,31 @@
+package main
+
+/*
+#include "<%= config[:underscored_name] %>.h"
+
+VALUE rb_<%= config[:underscored_name] %>_sum(VALUE self, VALUE a, VALUE b);
+*/
+import "C"
+
+import (
+ "github.com/ruby-go-gem/go-gem-wrapper/ruby"
+)
+
+//export rb_<%= config[:underscored_name] %>_sum
+func rb_<%= config[:underscored_name] %>_sum(_ C.VALUE, a C.VALUE, b C.VALUE) C.VALUE {
+ longA := ruby.NUM2LONG(ruby.VALUE(a))
+ longB := ruby.NUM2LONG(ruby.VALUE(b))
+
+ sum := longA + longB
+
+ return C.VALUE(ruby.LONG2NUM(sum))
+}
+
+//export Init_<%= config[:underscored_name] %>
+func Init_<%= config[:underscored_name] %>() {
+ rb_m<%= config[:constant_array].join %> := ruby.RbDefineModule(<%= config[:constant_name].inspect %>)
+ ruby.RbDefineSingletonMethod(rb_m<%= config[:constant_array].join %>, "sum", C.rb_<%= config[:underscored_name] %>_sum, 2)
+}
+
+func main() {
+}
diff --git a/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt b/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
index b311283997..09ce97682d 100644
--- a/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
@@ -1,12 +1,23 @@
-use magnus::{define_module, function, prelude::*, Error};
+use magnus::{function, prelude::*, Error, Ruby};
-fn hello(subject: String) -> String {
- format!("Hello from Rust, {}!", subject)
+pub fn hello(subject: String) -> String {
+ format!("Hello {subject}, from Rust!")
}
#[magnus::init]
-fn init() -> Result<(), Error> {
- let module = <%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
+fn init(ruby: &Ruby) -> Result<(), Error> {
+ let module = ruby.<%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
module.define_singleton_method("hello", function!(hello, 1))?;
Ok(())
}
+
+#[cfg(test)]
+mod tests {
+ use rb_sys_test_helpers::ruby_test;
+ use super::hello;
+
+ #[ruby_test]
+ fn test_hello() {
+ assert_eq!("Hello world, from Rust!", hello("world".to_string()));
+ }
+}
diff --git a/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt b/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt
new file mode 100644
index 0000000000..d49954d2cd
--- /dev/null
+++ b/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt
@@ -0,0 +1,69 @@
+---
+name: Build gems
+
+on:
+ push:
+ tags:
+ - "v*"
+ - "cross-gem/*"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ packages: write
+
+jobs:
+ ci-data:
+ runs-on: ubuntu-latest
+ outputs:
+ result: ${{ steps.fetch.outputs.result }}
+ steps:
+ - uses: oxidize-rb/actions/fetch-ci-data@v1
+ id: fetch
+ with:
+ supported-ruby-platforms: |
+ exclude: ["arm-linux", "x64-mingw32"]
+ stable-ruby-versions: |
+ exclude: ["head"]
+
+ source-gem:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+
+ - uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Build gem
+ run: bundle exec rake build
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: source-gem
+ path: pkg/*.gem
+
+ cross-gem:
+ name: Compile native gem for ${{ matrix.platform }}
+ runs-on: ubuntu-latest
+ needs: ci-data
+ strategy:
+ matrix:
+ platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
+ steps:
+ - uses: actions/checkout@v6
+
+ - uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - uses: oxidize-rb/actions/cross-gem@v1
+ id: cross-gem
+ with:
+ platform: ${{ matrix.platform }}
+ ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: cross-gem
+ path: ${{ steps.cross-gem.outputs.gem-path }}
diff --git a/lib/bundler/templates/newgem/github/workflows/main.yml.tt b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
index be58dd8156..cc8f04dd33 100644
--- a/lib/bundler/templates/newgem/github/workflows/main.yml.tt
+++ b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
@@ -7,6 +7,9 @@ on:
pull_request:
+permissions:
+ contents: read
+
jobs:
build:
runs-on: ubuntu-latest
@@ -17,21 +20,29 @@ jobs:
- '<%= RUBY_VERSION %>'
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v6
+ with:
+ persist-credentials: false
<%- if config[:ext] == 'rust' -%>
- - name: Set up Ruby & Rust
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
- with:
- ruby-version: ${{ matrix.ruby }}
- bundler-cache: true
- cargo-cache: true
- rubygems: '<%= ::Gem.rubygems_version %>'
+ - name: Set up Ruby & Rust
+ uses: oxidize-rb/actions/setup-ruby-and-rust@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true
+ cargo-cache: true
+ rubygems: '<%= ::Gem.rubygems_version %>'
<%- else -%>
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: ${{ matrix.ruby }}
- bundler-cache: true
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true
+<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ - name: Setup Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: ext/<%= config[:underscored_name] %>/go.mod
<%- end -%>
- - name: Run the default task
- run: bundle exec rake
+ - name: Run the default task
+ run: bundle exec rake
diff --git a/lib/bundler/templates/newgem/gitlab-ci.yml.tt b/lib/bundler/templates/newgem/gitlab-ci.yml.tt
index d2e1f33736..adbd70cbc0 100644
--- a/lib/bundler/templates/newgem/gitlab-ci.yml.tt
+++ b/lib/bundler/templates/newgem/gitlab-ci.yml.tt
@@ -6,6 +6,11 @@ default:
- apt-get update && apt-get install -y clang
- gem update --system '<%= ::Gem.rubygems_version %>'
<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ - wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
+ - tar -C /usr/local -xzf /tmp/go.tar.gz
+ - export PATH=/usr/local/go/bin:$PATH
+<%- end -%>
- gem install bundler -v <%= Bundler::VERSION %>
- bundle install
@@ -14,5 +19,9 @@ example_job:
variables:
RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ variables:
+ GO_VERSION: '1.23.0'
+<%- end -%>
script:
- bundle exec rake
diff --git a/lib/bundler/templates/newgem/lib/newgem.rb.tt b/lib/bundler/templates/newgem/lib/newgem.rb.tt
index caf6e32f4a..3aedee0d25 100644
--- a/lib/bundler/templates/newgem/lib/newgem.rb.tt
+++ b/lib/bundler/templates/newgem/lib/newgem.rb.tt
@@ -2,7 +2,7 @@
require_relative "<%= File.basename(config[:namespaced_path]) %>/version"
<%- if config[:ext] -%>
-require_relative "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
+require "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
<%- end -%>
<%- config[:constant_array].each_with_index do |c, i| -%>
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index da81f046d4..1ab1c28f46 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -10,41 +10,49 @@ Gem::Specification.new do |spec|
spec.summary = "TODO: Write a short summary, because RubyGems requires one."
spec.description = "TODO: Write a longer description or delete this line."
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
+ spec.homepage = "<%= config[:homepage_uri] %>"
<%- if config[:mit] -%>
spec.license = "MIT"
<%- end -%>
spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>"
-<%- if config[:ext] == 'rust' -%>
- spec.required_rubygems_version = ">= <%= config[:rust_builder_required_rubygems_version] %>"
-<%- end -%>
-
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
-
spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
+ spec.metadata["source_code_uri"] = "<%= config[:source_code_uri] %>"
+<%- if config[:changelog] -%>
+ spec.metadata["changelog_uri"] = "<%= config[:changelog_uri] %>"
+<%- end -%>
+
+ # Uncomment the line below to require MFA for gem pushes.
+ # This helps protect your gem from supply chain attacks by ensuring
+ # no one can publish a new version without multi-factor authentication.
+ # See: https://guides.rubygems.org/mfa-requirement-opt-in/
+ # spec.metadata["rubygems_mfa_required"] = "true"
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(__dir__) do
- `git ls-files -z`.split("\x0").reject do |f|
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
+ gemspec = File.basename(__FILE__)
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
+ ls.readlines("\x0", chomp: true).reject do |f|
+ (f == gemspec) ||
+ f.start_with?(*%w[<%= config[:ignore_paths].join(" ") %>])
end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
-<%- if config[:ext] == 'c' -%>
+<%- if %w(c rust go).include?(config[:ext]) -%>
spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
<%- end -%>
-<%- if config[:ext] == 'rust' -%>
- spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"]
-<%- end -%>
# Uncomment to register a new dependency of your gem
- # spec.add_dependency "example-gem", "~> 1.0"
+ # spec.add_dependency "example-gem", ">= 1.0"
+<%- if config[:ext] == 'rust' -%>
+ spec.add_dependency "rb_sys", ">= 0.9.128"
+<%- end -%>
+<%- if config[:ext] == 'go' -%>
+ spec.add_dependency "go_gem", ">= 0.2"
+<%- end -%>
# For more information and examples about making a new gem, check out our
- # guide at: https://bundler.io/guides/creating_gem.html
+ # guide at: https://guides.rubygems.org/make-your-own-gem/
end
diff --git a/lib/bundler/templates/newgem/rubocop.yml.tt b/lib/bundler/templates/newgem/rubocop.yml.tt
index 9ecec78807..3d1c4ee7b2 100644
--- a/lib/bundler/templates/newgem/rubocop.yml.tt
+++ b/lib/bundler/templates/newgem/rubocop.yml.tt
@@ -2,12 +2,7 @@ AllCops:
TargetRubyVersion: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
Style/StringLiterals:
- Enabled: true
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
- Enabled: true
EnforcedStyle: double_quotes
-
-Layout/LineLength:
- Max: 120
diff --git a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt
index 82cada988c..7c6cde170b 100644
--- a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt
+++ b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt
@@ -5,7 +5,15 @@ RSpec.describe <%= config[:constant_name] %> do
expect(<%= config[:constant_name] %>::VERSION).not_to be nil
end
+<%- if config[:ext] == 'rust' -%>
+ it "can call into Rust" do
+ result = <%= config[:constant_name] %>.hello("world")
+
+ expect(result).to eq("Hello world, from Rust!")
+ end
+<%- else -%>
it "does something useful" do
expect(false).to eq(true)
end
+<%- end -%>
end
diff --git a/lib/bundler/templates/newgem/standard.yml.tt b/lib/bundler/templates/newgem/standard.yml.tt
index 934b0b2c37..a0696cd2e9 100644
--- a/lib/bundler/templates/newgem/standard.yml.tt
+++ b/lib/bundler/templates/newgem/standard.yml.tt
@@ -1,3 +1,3 @@
# For available configuration options, see:
-# https://github.com/testdouble/standard
+# https://github.com/standardrb/standard
ruby_version: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
diff --git a/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt b/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt
index 4b35a63071..844d3aff81 100644
--- a/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt
+++ b/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt
@@ -7,7 +7,13 @@ class <%= config[:minitest_constant_name] %> < Minitest::Test
refute_nil ::<%= config[:constant_name] %>::VERSION
end
+<%- if config[:ext] == 'rust' -%>
+ def test_hello_world
+ assert_equal "Hello world, from Rust!", <%= config[:constant_name] %>.hello("world")
+ end
+<%- else -%>
def test_it_does_something_useful
assert false
end
+<%- end -%>
end
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 4139585c47..b836208da8 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -6,14 +6,18 @@ module Bundler
module UI
class Shell
LEVELS = %w[silent error warn confirm info debug].freeze
+ OUTPUT_STREAMS = [:stdout, :stderr].freeze
attr_writer :shell
+ attr_reader :output_stream
def initialize(options = {})
Thor::Base.shell = options["no-color"] ? Thor::Shell::Basic : nil
@shell = Thor::Base.shell.new
@level = ENV["DEBUG"] ? "debug" : "info"
@warning_history = []
+ @output_stream = :stdout
+ @thread_safe_logger_key = "logger_level_#{object_id}"
end
def add_color(string, *color)
@@ -77,14 +81,14 @@ module Bundler
end
def ask(msg)
- @shell.ask(msg)
+ @shell.ask(msg, :green)
end
def yes?(msg)
- @shell.yes?(msg)
+ @shell.yes?(msg, :green)
end
- def no?
+ def no?(msg)
@shell.no?(msg)
end
@@ -94,11 +98,18 @@ module Bundler
end
def level(name = nil)
- return @level unless name
+ current_level = Thread.current.thread_variable_get(@thread_safe_logger_key) || @level
+ return current_level unless name
+
unless index = LEVELS.index(name)
raise "#{name.inspect} is not a valid level"
end
- index <= LEVELS.index(@level)
+ index <= LEVELS.index(current_level)
+ end
+
+ def output_stream=(symbol)
+ raise ArgumentError unless OUTPUT_STREAMS.include?(symbol)
+ @output_stream = symbol
end
def trace(e, newline = nil, force = false)
@@ -111,6 +122,10 @@ module Bundler
with_level("silent", &blk)
end
+ def progress(&blk)
+ with_output_stream(:stderr, &blk)
+ end
+
def unprinted_warnings
[]
end
@@ -119,6 +134,8 @@ module Bundler
# valimism
def tell_me(msg, color = nil, newline = nil)
+ return tell_err(msg, color, newline) if output_stream == :stderr
+
msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap]
if newline.nil?
@shell.say(msg, color)
@@ -130,7 +147,7 @@ module Bundler
def tell_err(message, color = nil, newline = nil)
return if @shell.send(:stderr).closed?
- newline ||= message.to_s !~ /( |\t)\Z/
+ newline = !message.to_s.match?(/( |\t)\Z/) if newline.nil?
message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
color = nil if color && !$stderr.tty?
@@ -147,18 +164,27 @@ module Bundler
spaces ? text.gsub(/#{spaces}/, "") : text
end
- def word_wrap(text, line_width = @shell.terminal_width)
+ def word_wrap(text, line_width = Thor::Terminal.terminal_width)
strip_leading_spaces(text).split("\n").collect do |line|
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
end * "\n"
end
- def with_level(level)
- original = @level
- @level = level
+ def with_level(desired_level)
+ old_level = level
+ Thread.current.thread_variable_set(@thread_safe_logger_key, desired_level)
+
+ yield
+ ensure
+ Thread.current.thread_variable_set(@thread_safe_logger_key, old_level)
+ end
+
+ def with_output_stream(symbol)
+ original = output_stream
+ self.output_stream = symbol
yield
ensure
- @level = original
+ @output_stream = original
end
end
end
diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb
index fa3292bdc9..83d31d4b55 100644
--- a/lib/bundler/ui/silent.rb
+++ b/lib/bundler/ui/silent.rb
@@ -53,6 +53,13 @@ module Bundler
false
end
+ def output_stream=(_symbol)
+ end
+
+ def output_stream
+ nil
+ end
+
def ask(message)
end
@@ -60,7 +67,7 @@ module Bundler
raise "Cannot ask yes? with a silent shell"
end
- def no?
+ def no?(msg)
raise "Cannot ask no? with a silent shell"
end
@@ -77,6 +84,10 @@ module Bundler
yield
end
+ def progress
+ yield
+ end
+
def unprinted_warnings
@warnings
end
diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb
index ccfaf0bc5d..6804187433 100644
--- a/lib/bundler/uri_credentials_filter.rb
+++ b/lib/bundler/uri_credentials_filter.rb
@@ -11,12 +11,12 @@ module Bundler
return uri if File.exist?(uri)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
end
if uri.userinfo
# oauth authentication
- if uri.password == "x-oauth-basic" || uri.password == "x"
+ if uri.password == "x-oauth-basic" || uri.password == "x" || uri.password.nil?
# URI as string does not display with password if no user is set
oauth_designation = uri.password
uri.user = oauth_designation
@@ -25,7 +25,7 @@ module Bundler
end
return uri.to_s if uri_to_anonymize.is_a?(String)
uri
- rescue Bundler::URI::InvalidURIError # uri is not canonical uri scheme
+ rescue Gem::URI::InvalidURIError # uri is not canonical uri scheme
uri
end
diff --git a/lib/bundler/uri_normalizer.rb b/lib/bundler/uri_normalizer.rb
new file mode 100644
index 0000000000..ad08593256
--- /dev/null
+++ b/lib/bundler/uri_normalizer.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Bundler
+ module URINormalizer
+ module_function
+
+ # Normalizes uri to a consistent version, either with or without trailing
+ # slash.
+ #
+ # TODO: Currently gem sources are locked with a trailing slash, while git
+ # sources are locked without a trailing slash. This should be normalized but
+ # the inconsistency is there for now to avoid changing all lockfiles
+ # including GIT sources. We could normalize this on the next major.
+ #
+ def normalize_suffix(uri, trailing_slash: true)
+ if trailing_slash
+ uri.end_with?("/") ? uri : "#{uri}/"
+ else
+ uri.end_with?("/") ? uri.delete_suffix("/") : uri
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
index 455319efe3..e8aaf70016 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
@@ -1,4 +1,4 @@
-require "timeout"
+require_relative "../../../vendored_timeout"
require_relative "connection_pool/version"
class Bundler::ConnectionPool
@@ -6,7 +6,7 @@ class Bundler::ConnectionPool
class PoolShuttingDownError < ::Bundler::ConnectionPool::Error; end
- class TimeoutError < ::Timeout::Error; end
+ class TimeoutError < ::Gem::Timeout::Error; end
end
# Generic connection pool class for sharing a limited number of objects or network connections
@@ -36,14 +36,57 @@ end
# Accepts the following options:
# - :size - number of connections to pool, defaults to 5
# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
+# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
#
class Bundler::ConnectionPool
- DEFAULTS = {size: 5, timeout: 5}
+ DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}.freeze
def self.wrap(options, &block)
Wrapper.new(options, &block)
end
+ if Process.respond_to?(:fork)
+ INSTANCES = ObjectSpace::WeakMap.new
+ private_constant :INSTANCES
+
+ def self.after_fork
+ INSTANCES.values.each do |pool|
+ next unless pool.auto_reload_after_fork
+
+ # We're on after fork, so we know all other threads are dead.
+ # All we need to do is to ensure the main thread doesn't have a
+ # checked out connection
+ pool.checkin(force: true)
+ pool.reload do |connection|
+ # Unfortunately we don't know what method to call to close the connection,
+ # so we try the most common one.
+ connection.close if connection.respond_to?(:close)
+ end
+ end
+ nil
+ end
+
+ if ::Process.respond_to?(:_fork) # MRI 3.1+
+ module ForkTracker
+ def _fork
+ pid = super
+ if pid == 0
+ Bundler::ConnectionPool.after_fork
+ end
+ pid
+ end
+ end
+ Process.singleton_class.prepend(ForkTracker)
+ end
+ else
+ INSTANCES = nil
+ private_constant :INSTANCES
+
+ def self.after_fork
+ # noop
+ end
+ end
+
def initialize(options = {}, &block)
raise ArgumentError, "Connection pool requires a block" unless block
@@ -51,13 +94,19 @@ class Bundler::ConnectionPool
@size = Integer(options.fetch(:size))
@timeout = options.fetch(:timeout)
+ @auto_reload_after_fork = options.fetch(:auto_reload_after_fork)
@available = TimedStack.new(@size, &block)
@key = :"pool-#{@available.object_id}"
@key_count = :"pool-#{@available.object_id}-count"
+ @discard_key = :"pool-#{@available.object_id}-discard"
+ INSTANCES[self] = self if @auto_reload_after_fork && INSTANCES
end
def with(options = {})
+ # We need to manage exception handling manually here in order
+ # to work correctly with `Gem::Timeout.timeout` and `Thread#raise`.
+ # Otherwise an interrupted Thread can leak connections.
Thread.handle_interrupt(Exception => :never) do
conn = checkout(options)
begin
@@ -71,26 +120,71 @@ class Bundler::ConnectionPool
end
alias_method :then, :with
+ ##
+ # Marks the current thread's checked-out connection for discard.
+ #
+ # When a connection is marked for discard, it will not be returned to the pool
+ # when checked in. Instead, the connection will be discarded.
+ # This is useful when a connection has become invalid or corrupted
+ # and should not be reused.
+ #
+ # Takes an optional block that will be called with the connection to be discarded.
+ # The block should perform any necessary clean-up on the connection.
+ #
+ # @yield [conn]
+ # @yieldparam conn [Object] The connection to be discarded.
+ # @yieldreturn [void]
+ #
+ #
+ # Note: This only affects the connection currently checked out by the calling thread.
+ # The connection will be discarded when +checkin+ is called.
+ #
+ # @return [void]
+ #
+ # @example
+ # pool.with do |conn|
+ # begin
+ # conn.execute("SELECT 1")
+ # rescue SomeConnectionError
+ # pool.discard_current_connection # Mark connection as bad
+ # raise
+ # end
+ # end
+ def discard_current_connection(&block)
+ ::Thread.current[@discard_key] = block || proc { |conn| conn }
+ end
+
def checkout(options = {})
if ::Thread.current[@key]
::Thread.current[@key_count] += 1
::Thread.current[@key]
else
::Thread.current[@key_count] = 1
- ::Thread.current[@key] = @available.pop(options[:timeout] || @timeout)
+ ::Thread.current[@key] = @available.pop(options[:timeout] || @timeout, options)
end
end
- def checkin
+ def checkin(force: false)
if ::Thread.current[@key]
- if ::Thread.current[@key_count] == 1
- @available.push(::Thread.current[@key])
+ if ::Thread.current[@key_count] == 1 || force
+ if ::Thread.current[@discard_key]
+ begin
+ @available.decrement_created
+ ::Thread.current[@discard_key].call(::Thread.current[@key])
+ rescue
+ nil
+ ensure
+ ::Thread.current[@discard_key] = nil
+ end
+ else
+ @available.push(::Thread.current[@key])
+ end
::Thread.current[@key] = nil
::Thread.current[@key_count] = nil
else
::Thread.current[@key_count] -= 1
end
- else
+ elsif !force
raise Bundler::ConnectionPool::Error, "no connections are checked out"
end
@@ -101,7 +195,6 @@ class Bundler::ConnectionPool
# Shuts down the Bundler::ConnectionPool by passing each connection to +block+ and
# then removing it from the pool. Attempting to checkout a connection after
# shutdown will raise +Bundler::ConnectionPool::PoolShuttingDownError+.
-
def shutdown(&block)
@available.shutdown(&block)
end
@@ -110,18 +203,30 @@ class Bundler::ConnectionPool
# Reloads the Bundler::ConnectionPool by passing each connection to +block+ and then
# removing it the pool. Subsequent checkouts will create new connections as
# needed.
-
def reload(&block)
@available.shutdown(reload: true, &block)
end
+ ## Reaps idle connections that have been idle for over +idle_seconds+.
+ # +idle_seconds+ defaults to 60.
+ def reap(idle_seconds = 60, &block)
+ @available.reap(idle_seconds, &block)
+ end
+
# Size of this connection pool
attr_reader :size
+ # Automatically drop all connections after fork
+ attr_reader :auto_reload_after_fork
# Number of pool entries available for checkout at this instant.
def available
@available.length
end
+
+ # Number of pool entries created and idle in the pool.
+ def idle
+ @available.idle
+ end
end
require_relative "connection_pool/timed_stack"
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
index 35d1d7cc35..026d2c5be2 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
@@ -1,8 +1,8 @@
##
# The TimedStack manages a pool of homogeneous connections (or any resource
-# you wish to manage). Connections are created lazily up to a given maximum
+# you wish to manage). Connections are created lazily up to a given maximum
# number.
-
+#
# Examples:
#
# ts = TimedStack.new(1) { MyConnection.new }
@@ -16,14 +16,12 @@
# conn = ts.pop
# ts.pop timeout: 5
# #=> raises Bundler::ConnectionPool::TimeoutError after 5 seconds
-
class Bundler::ConnectionPool::TimedStack
attr_reader :max
##
# Creates a new pool with +size+ connections that are created from the given
# +block+.
-
def initialize(size = 0, &block)
@create_block = block
@created = 0
@@ -35,12 +33,12 @@ class Bundler::ConnectionPool::TimedStack
end
##
- # Returns +obj+ to the stack. +options+ is ignored in TimedStack but may be
+ # Returns +obj+ to the stack. +options+ is ignored in TimedStack but may be
# used by subclasses that extend TimedStack.
-
def push(obj, options = {})
@mutex.synchronize do
if @shutdown_block
+ @created -= 1 unless @created == 0
@shutdown_block.call(obj)
else
store_connection obj, options
@@ -52,14 +50,16 @@ class Bundler::ConnectionPool::TimedStack
alias_method :<<, :push
##
- # Retrieves a connection from the stack. If a connection is available it is
- # immediately returned. If no connection is available within the given
+ # Retrieves a connection from the stack. If a connection is available it is
+ # immediately returned. If no connection is available within the given
# timeout a Bundler::ConnectionPool::TimeoutError is raised.
#
- # +:timeout+ is the only checked entry in +options+ and is preferred over
- # the +timeout+ argument (which will be removed in a future release). Other
- # options may be used by subclasses that extend TimedStack.
-
+ # @option options [Float] :timeout (0.5) Wait this many seconds for an available entry
+ # @option options [Class] :exception (Bundler::ConnectionPool::TimeoutError) Exception class to raise
+ # if an entry was not available within the timeout period. Use `exception: false` to return nil.
+ #
+ # The +timeout+ argument will be removed in 3.0.
+ # Other options may be used by subclasses that extend TimedStack.
def pop(timeout = 0.5, options = {})
options, timeout = timeout, 0.5 if Hash === timeout
timeout = options.fetch :timeout, timeout
@@ -68,13 +68,22 @@ class Bundler::ConnectionPool::TimedStack
@mutex.synchronize do
loop do
raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
- return fetch_connection(options) if connection_stored?(options)
+ if (conn = try_fetch_connection(options))
+ return conn
+ end
connection = try_create(options)
return connection if connection
to_wait = deadline - current_time
- raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
+ if to_wait <= 0
+ exc = options.fetch(:exception, Bundler::ConnectionPool::TimeoutError)
+ if exc
+ raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available"
+ else
+ return nil
+ end
+ end
@resource.wait(@mutex, to_wait)
end
end
@@ -85,7 +94,6 @@ class Bundler::ConnectionPool::TimedStack
# removing it from the pool. Attempting to checkout a connection after
# shutdown will raise +Bundler::ConnectionPool::PoolShuttingDownError+ unless
# +:reload+ is +true+.
-
def shutdown(reload: false, &block)
raise ArgumentError, "shutdown must receive a block" unless block
@@ -99,19 +107,49 @@ class Bundler::ConnectionPool::TimedStack
end
##
- # Returns +true+ if there are no available connections.
+ # Reaps connections that were checked in more than +idle_seconds+ ago.
+ def reap(idle_seconds, &block)
+ raise ArgumentError, "reap must receive a block" unless block
+ raise ArgumentError, "idle_seconds must be a number" unless idle_seconds.is_a?(Numeric)
+ raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
+
+ idle.times do
+ conn =
+ @mutex.synchronize do
+ raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
+
+ reserve_idle_connection(idle_seconds)
+ end
+ break unless conn
+
+ block.call(conn)
+ end
+ end
+ ##
+ # Returns +true+ if there are no available connections.
def empty?
(@created - @que.length) >= @max
end
##
# The number of connections available on the stack.
-
def length
@max - @created + @que.length
end
+ ##
+ # The number of connections created and available on the stack.
+ def idle
+ @que.length
+ end
+
+ ##
+ # Reduce the created count
+ def decrement_created
+ @created -= 1 unless @created == 0
+ end
+
private
def current_time
@@ -121,8 +159,17 @@ class Bundler::ConnectionPool::TimedStack
##
# This is an extension point for TimedStack and is called with a mutex.
#
- # This method must returns true if a connection is available on the stack.
+ # This method must returns a connection from the stack if one exists. Allows
+ # subclasses with expensive match/search algorithms to avoid double-handling
+ # their stack.
+ def try_fetch_connection(options = nil)
+ connection_stored?(options) && fetch_connection(options)
+ end
+ ##
+ # This is an extension point for TimedStack and is called with a mutex.
+ #
+ # This method must returns true if a connection is available on the stack.
def connection_stored?(options = nil)
!@que.empty?
end
@@ -131,31 +178,48 @@ class Bundler::ConnectionPool::TimedStack
# This is an extension point for TimedStack and is called with a mutex.
#
# This method must return a connection from the stack.
-
def fetch_connection(options = nil)
- @que.pop
+ @que.pop&.first
end
##
# This is an extension point for TimedStack and is called with a mutex.
#
# This method must shut down all connections on the stack.
-
def shutdown_connections(options = nil)
- while connection_stored?(options)
- conn = fetch_connection(options)
+ while (conn = try_fetch_connection(options))
+ @created -= 1 unless @created == 0
@shutdown_block.call(conn)
end
- @created = 0
end
##
# This is an extension point for TimedStack and is called with a mutex.
#
- # This method must return +obj+ to the stack.
+ # This method returns the oldest idle connection if it has been idle for more than idle_seconds.
+ # This requires that the stack is kept in order of checked in time (oldest first).
+ def reserve_idle_connection(idle_seconds)
+ return unless idle_connections?(idle_seconds)
+
+ @created -= 1 unless @created == 0
+
+ @que.shift.first
+ end
+ ##
+ # This is an extension point for TimedStack and is called with a mutex.
+ #
+ # Returns true if the first connection in the stack has been idle for more than idle_seconds
+ def idle_connections?(idle_seconds)
+ connection_stored? && (current_time - @que.first.last > idle_seconds)
+ end
+
+ ##
+ # This is an extension point for TimedStack and is called with a mutex.
+ #
+ # This method must return +obj+ to the stack.
def store_connection(obj, options = nil)
- @que.push obj
+ @que.push [obj, current_time]
end
##
@@ -163,7 +227,6 @@ class Bundler::ConnectionPool::TimedStack
#
# This method must create a connection if and only if the total number of
# connections allowed has not been met.
-
def try_create(options = nil)
unless @created == @max
object = @create_block.call
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
index 56ebf69902..2e9eebdbb6 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
@@ -1,3 +1,3 @@
class Bundler::ConnectionPool
- VERSION = "2.3.0"
+ VERSION = "2.5.5"
end
diff --git a/lib/bundler/vendor/fileutils/lib/fileutils.rb b/lib/bundler/vendor/fileutils/lib/fileutils.rb
index 211311c069..a11fdc7176 100644
--- a/lib/bundler/vendor/fileutils/lib/fileutils.rb
+++ b/lib/bundler/vendor/fileutils/lib/fileutils.rb
@@ -180,7 +180,8 @@ end
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
#
module Bundler::FileUtils
- VERSION = "1.7.0"
+ # The version number.
+ VERSION = "1.8.0"
def self.private_module_function(name) #:nodoc:
module_function name
@@ -192,8 +193,6 @@ module Bundler::FileUtils
#
# Bundler::FileUtils.pwd # => "/rdoc/fileutils"
#
- # Bundler::FileUtils.getwd is an alias for Bundler::FileUtils.pwd.
- #
# Related: Bundler::FileUtils.cd.
#
def pwd
@@ -235,8 +234,6 @@ module Bundler::FileUtils
# cd ..
# cd fileutils
#
- # Bundler::FileUtils.chdir is an alias for Bundler::FileUtils.cd.
- #
# Related: Bundler::FileUtils.pwd.
#
def cd(dir, verbose: nil, &block) # :yield: dir
@@ -515,8 +512,6 @@ module Bundler::FileUtils
# Raises an exception if +dest+ is the path to an existing file
# and keyword argument +force+ is not +true+.
#
- # Bundler::FileUtils#link is an alias for Bundler::FileUtils#ln.
- #
# Related: Bundler::FileUtils.link_entry (has different options).
#
def ln(src, dest, force: nil, noop: nil, verbose: nil)
@@ -707,17 +702,16 @@ module Bundler::FileUtils
# ln -sf src2.txt dest2.txt
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
#
- # Bundler::FileUtils.symlink is an alias for Bundler::FileUtils.ln_s.
- #
# Related: Bundler::FileUtils.ln_sf.
#
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
if relative
- return ln_sr(src, dest, force: force, noop: noop, verbose: verbose)
+ return ln_sr(src, dest, force: force, target_directory: target_directory, noop: noop, verbose: verbose)
end
- fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
+ fu_output_message "ln -s#{force ? 'f' : ''}#{
+ target_directory ? '' : 'T'} #{[src,dest].flatten.join ' '}" if verbose
return if noop
- fu_each_src_dest0(src, dest) do |s,d|
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
remove_file d, true if force
File.symlink s, d
end
@@ -737,42 +731,37 @@ module Bundler::FileUtils
# Like Bundler::FileUtils.ln_s, but create links relative to +dest+.
#
def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
- options = "#{force ? 'f' : ''}#{target_directory ? '' : 'T'}"
- dest = File.path(dest)
- srcs = Array(src)
- link = proc do |s, target_dir_p = true|
- s = File.path(s)
- if target_dir_p
- d = File.join(destdirs = dest, File.basename(s))
+ cmd = "ln -s#{force ? 'f' : ''}#{target_directory ? '' : 'T'}" if verbose
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
+ if target_directory
+ parent = File.dirname(d)
+ destdirs = fu_split_path(parent)
+ real_ddirs = fu_split_path(File.realpath(parent))
else
- destdirs = File.dirname(d = dest)
+ destdirs ||= fu_split_path(dest)
+ real_ddirs ||= fu_split_path(File.realdirpath(dest))
end
- destdirs = fu_split_path(File.realpath(destdirs))
- if fu_starting_path?(s)
- srcdirs = fu_split_path((File.realdirpath(s) rescue File.expand_path(s)))
- base = fu_relative_components_from(srcdirs, destdirs)
- s = File.join(*base)
+ srcdirs = fu_split_path(s)
+ i = fu_common_components(srcdirs, destdirs)
+ n = destdirs.size - i
+ n -= 1 unless target_directory
+ link1 = fu_clean_components(*Array.new([n, 0].max, '..'), *srcdirs[i..-1])
+ begin
+ real_sdirs = fu_split_path(File.realdirpath(s)) rescue nil
+ rescue
else
- srcdirs = fu_clean_components(*fu_split_path(s))
- base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs)
- while srcdirs.first&. == ".." and base.last&.!=("..") and !fu_starting_path?(base.last)
- srcdirs.shift
- base.pop
- end
- s = File.join(*base, *srcdirs)
+ i = fu_common_components(real_sdirs, real_ddirs)
+ n = real_ddirs.size - i
+ n -= 1 unless target_directory
+ link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
+ link1 = link2 if link1.size > link2.size
end
- fu_output_message "ln -s#{options} #{s} #{d}" if verbose
+ s = File.join(link1)
+ fu_output_message [cmd, s, d].flatten.join(' ') if verbose
next if noop
remove_file d, true if force
File.symlink s, d
end
- case srcs.size
- when 0
- when 1
- link[srcs[0], target_directory && File.directory?(dest)]
- else
- srcs.each(&link)
- end
end
module_function :ln_sr
@@ -807,13 +796,13 @@ module Bundler::FileUtils
# File.file?('dest1/dir1/t2.txt') # => true
# File.file?('dest1/dir1/t3.txt') # => true
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference_root: true</tt> - dereferences +src+ if it is a symbolic link.
- # - <tt>remove_destination: true</tt> - removes +dest+ before creating links.
+ # - +dereference_root+ - dereferences +src+ if it is a symbolic link (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before creating links (+false+ by default).
#
# Raises an exception if +dest+ is the path to an existing file or directory
- # and keyword argument <tt>remove_destination: true</tt> is not given.
+ # and optional argument +remove_destination+ is not given.
#
# Related: Bundler::FileUtils.ln (has different options).
#
@@ -876,8 +865,6 @@ module Bundler::FileUtils
#
# Raises an exception if +src+ is a directory.
#
- # Bundler::FileUtils.copy is an alias for Bundler::FileUtils.cp.
- #
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
@@ -1038,12 +1025,12 @@ module Bundler::FileUtils
# directories, and symbolic links;
# other file types (FIFO streams, device files, etc.) are not supported.
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference_root: true</tt> - if +src+ is a symbolic link,
- # follows the link.
- # - <tt>preserve: true</tt> - preserves file times.
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
+ # - +dereference_root+ - if +src+ is a symbolic link,
+ # follows the link (+false+ by default).
+ # - +preserve+ - preserves file times (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
#
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
@@ -1074,12 +1061,12 @@ module Bundler::FileUtils
# Bundler::FileUtils.copy_file('src0.txt', 'dest0.txt')
# File.file?('dest0.txt') # => true
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference: false</tt> - if +src+ is a symbolic link,
- # does not follow the link.
- # - <tt>preserve: true</tt> - preserves file times.
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
+ # - +dereference+ - if +src+ is a symbolic link,
+ # follows the link (+true+ by default).
+ # - +preserve+ - preserves file times (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
#
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
@@ -1164,8 +1151,6 @@ module Bundler::FileUtils
# mv src0 dest0
# mv src1.txt src1 dest1
#
- # Bundler::FileUtils.move is an alias for Bundler::FileUtils.mv.
- #
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
@@ -1223,8 +1208,6 @@ module Bundler::FileUtils
#
# rm src0.dat src0.txt
#
- # Bundler::FileUtils.remove is an alias for Bundler::FileUtils.rm.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm(list, force: nil, noop: nil, verbose: nil)
@@ -1250,8 +1233,6 @@ module Bundler::FileUtils
#
# See Bundler::FileUtils.rm for keyword arguments.
#
- # Bundler::FileUtils.safe_unlink is an alias for Bundler::FileUtils.rm_f.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_f(list, noop: nil, verbose: nil)
@@ -1339,8 +1320,6 @@ module Bundler::FileUtils
#
# See Bundler::FileUtils.rm_r for keyword arguments.
#
- # Bundler::FileUtils.rmtree is an alias for Bundler::FileUtils.rm_rf.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
@@ -1508,7 +1487,8 @@ module Bundler::FileUtils
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def remove_dir(path, force = false)
- remove_entry path, force # FIXME?? check if it is a directory
+ raise Errno::ENOTDIR, path unless force or File.directory?(path)
+ remove_entry path, force
end
module_function :remove_dir
@@ -1642,7 +1622,13 @@ module Bundler::FileUtils
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
- copy_file s, d
+ if d.end_with?('/')
+ mkdir_p d
+ copy_file s, d + File.basename(s)
+ else
+ mkdir_p File.expand_path('..', d)
+ copy_file s, d
+ end
File.utime st.atime, st.mtime, d if preserve
File.chmod fu_mode(mode, st), d if mode
File.chown uid, gid, d if uid or gid
@@ -1663,7 +1649,7 @@ module Bundler::FileUtils
when "a"
mask | 07777
else
- raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
+ raise ArgumentError, "invalid 'who' symbol in file mode: #{chr}"
end
end
end
@@ -1717,7 +1703,7 @@ module Bundler::FileUtils
copy_mask = user_mask(chr)
(current_mode & copy_mask) / (copy_mask & 0111) * (user_mask & 0111)
else
- raise ArgumentError, "invalid `perm' symbol in file mode: #{chr}"
+ raise ArgumentError, "invalid 'perm' symbol in file mode: #{chr}"
end
end
@@ -2040,21 +2026,22 @@ module Bundler::FileUtils
private
- module StreamUtils_
+ module StreamUtils_ # :nodoc:
+
private
case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
when /mswin|mingw/
- def fu_windows?; true end
+ def fu_windows?; true end #:nodoc:
else
- def fu_windows?; false end
+ def fu_windows?; false end #:nodoc:
end
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
IO.copy_stream(src, dest)
end
- def fu_stream_blksize(*streams)
+ def fu_stream_blksize(*streams) #:nodoc:
streams.each do |s|
next unless s.respond_to?(:stat)
size = fu_blksize(s.stat)
@@ -2063,14 +2050,14 @@ module Bundler::FileUtils
fu_default_blksize()
end
- def fu_blksize(st)
+ def fu_blksize(st) #:nodoc:
s = st.blksize
return nil unless s
return nil if s == 0
s
end
- def fu_default_blksize
+ def fu_default_blksize #:nodoc:
1024
end
end
@@ -2485,6 +2472,10 @@ module Bundler::FileUtils
def fu_each_src_dest0(src, dest, target_directory = true) #:nodoc:
if tmp = Array.try_convert(src)
+ unless target_directory or tmp.size <= 1
+ tmp = tmp.map {|f| File.path(f)} # A workaround for RBS
+ raise ArgumentError, "extra target #{tmp}"
+ end
tmp.each do |s|
s = File.path(s)
yield s, (target_directory ? File.join(dest, File.basename(s)) : dest)
@@ -2515,11 +2506,15 @@ module Bundler::FileUtils
end
private_module_function :fu_output_message
- def fu_split_path(path)
+ def fu_split_path(path) #:nodoc:
path = File.path(path)
list = []
until (parent, base = File.split(path); parent == path or parent == ".")
- list << base
+ if base != '..' and list.last == '..' and !(fu_have_symlink? && File.symlink?(path))
+ list.pop
+ else
+ list << base
+ end
path = parent
end
list << path
@@ -2527,16 +2522,16 @@ module Bundler::FileUtils
end
private_module_function :fu_split_path
- def fu_relative_components_from(target, base) #:nodoc:
+ def fu_common_components(target, base) #:nodoc:
i = 0
while target[i]&.== base[i]
i += 1
end
- Array.new(base.size-i, '..').concat(target[i..-1])
+ i
end
- private_module_function :fu_relative_components_from
+ private_module_function :fu_common_components
- def fu_clean_components(*comp)
+ def fu_clean_components(*comp) #:nodoc:
comp.shift while comp.first == "."
return comp if comp.empty?
clean = [comp.shift]
@@ -2544,7 +2539,7 @@ module Bundler::FileUtils
while c = comp.shift
if c == ".." and clean.last != ".." and !(fu_have_symlink? && File.symlink?(path))
clean.pop
- path.chomp!(%r((?<=\A|/)[^/]+/\z), "")
+ path.sub!(%r((?<=\A|/)[^/]+/\z), "")
else
clean << c
path << c << "/"
@@ -2555,11 +2550,11 @@ module Bundler::FileUtils
private_module_function :fu_clean_components
if fu_windows?
- def fu_starting_path?(path)
+ def fu_starting_path?(path) #:nodoc:
path&.start_with?(%r(\w:|/))
end
else
- def fu_starting_path?(path)
+ def fu_starting_path?(path) #:nodoc:
path&.start_with?("/")
end
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
index a4e1c5a750..93e403a5bb 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
@@ -1,14 +1,18 @@
-require 'net/http'
-require_relative '../../../../uri/lib/uri'
-require 'cgi' # for escaping
+require_relative '../../../../../vendored_net_http'
+require_relative '../../../../../vendored_uri'
+begin
+ require 'cgi/escape'
+rescue LoadError
+ require 'cgi/util' # for escaping
+end
require_relative '../../../../connection_pool/lib/connection_pool'
autoload :OpenSSL, 'openssl'
##
-# Persistent connections for Net::HTTP
+# Persistent connections for Gem::Net::HTTP
#
-# Bundler::Persistent::Net::HTTP::Persistent maintains persistent connections across all the
+# Gem::Net::HTTP::Persistent maintains persistent connections across all the
# servers you wish to talk to. For each host:port you communicate with a
# single persistent connection is created.
#
@@ -22,34 +26,33 @@ autoload :OpenSSL, 'openssl'
#
# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
#
-# uri = Bundler::URI 'http://example.com/awesome/web/service'
+# uri = Gem::URI 'http://example.com/awesome/web/service'
#
-# http = Bundler::Persistent::Net::HTTP::Persistent.new
+# http = Gem::Net::HTTP::Persistent.new
#
# # perform a GET
# response = http.request uri
#
# # or
#
-# get = Net::HTTP::Get.new uri.request_uri
+# get = Gem::Net::HTTP::Get.new uri.request_uri
# response = http.request get
#
# # create a POST
# post_uri = uri + 'create'
-# post = Net::HTTP::Post.new post_uri.path
+# post = Gem::Net::HTTP::Post.new post_uri.path
# post.set_form_data 'some' => 'cool data'
#
-# # perform the POST, the Bundler::URI is always required
+# # perform the POST, the Gem::URI is always required
# response http.request post_uri, post
#
-# Note that for GET, HEAD and other requests that do not have a body you want
-# to use Bundler::URI#request_uri not Bundler::URI#path. The request_uri contains the query
-# params which are sent in the body for other requests.
+# âš  Note that for GET, HEAD and other requests that do not have a body,
+# it uses Gem::URI#request_uri as default to send query params
#
# == TLS/SSL
#
# TLS connections are automatically created depending upon the scheme of the
-# Bundler::URI. TLS connections are automatically verified against the default
+# Gem::URI. TLS connections are automatically verified against the default
# certificate store for your computer. You can override this by changing
# verify_mode or by specifying an alternate cert_store.
#
@@ -60,6 +63,7 @@ autoload :OpenSSL, 'openssl'
# #ca_path :: Directory with certificate-authorities
# #cert_store :: An SSL certificate store
# #ciphers :: List of SSl ciphers allowed
+# #extra_chain_cert :: Extra certificates to be added to the certificate chain
# #private_key :: The client's SSL private key
# #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
# connection
@@ -68,11 +72,13 @@ autoload :OpenSSL, 'openssl'
# #verify_callback :: For server certificate verification
# #verify_depth :: Depth of certificate verification
# #verify_mode :: How connections should be verified
+# #verify_hostname :: Use hostname verification for server certificate
+# during the handshake
#
# == Proxies
#
# A proxy can be set through #proxy= or at initialization time by providing a
-# second argument to ::new. The proxy may be the Bundler::URI of the proxy server or
+# second argument to ::new. The proxy may be the Gem::URI of the proxy server or
# <code>:ENV</code> which will consult environment variables.
#
# See #proxy= and #proxy_from_env for details.
@@ -92,7 +98,7 @@ autoload :OpenSSL, 'openssl'
#
# === Segregation
#
-# Each Bundler::Persistent::Net::HTTP::Persistent instance has its own pool of connections. There
+# Each Gem::Net::HTTP::Persistent instance has its own pool of connections. There
# is no sharing with other instances (as was true in earlier versions).
#
# === Idle Timeout
@@ -131,7 +137,7 @@ autoload :OpenSSL, 'openssl'
#
# === Connection Termination
#
-# If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
+# If you are done using the Gem::Net::HTTP::Persistent instance you may shut down
# all the connections in the current thread with #shutdown. This is not
# recommended for normal use, it should only be used when it will be several
# minutes before you make another HTTP request.
@@ -141,7 +147,7 @@ autoload :OpenSSL, 'openssl'
# Ruby will automatically garbage collect and shutdown your HTTP connections
# when the thread terminates.
-class Bundler::Persistent::Net::HTTP::Persistent
+class Gem::Net::HTTP::Persistent
##
# The beginning of Time
@@ -172,12 +178,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
+ # The version of Gem::Net::HTTP::Persistent you are using
- VERSION = '4.0.1'
+ VERSION = '4.0.6'
##
- # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
+ # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
# SystemCallErrors are re-raised with a human-readable message under this
# class.
@@ -197,10 +203,10 @@ class Bundler::Persistent::Net::HTTP::Persistent
# NOTE: This may not work on ruby > 1.9.
def self.detect_idle_timeout uri, max = 10
- uri = Bundler::URI uri unless Bundler::URI::Generic === uri
+ uri = Gem::URI uri unless Gem::URI::Generic === uri
uri += '/'
- req = Net::HTTP::Head.new uri.request_uri
+ req = Gem::Net::HTTP::Head.new uri.request_uri
http = new 'net-http-persistent detect_idle_timeout'
@@ -214,7 +220,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
$stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
- unless Net::HTTPOK === response then
+ unless Gem::Net::HTTPOK === response then
raise Error, "bad response code #{response.code} detecting idle timeout"
end
@@ -238,7 +244,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :certificate
##
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias cert certificate
@@ -266,7 +272,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :ciphers
##
- # Sends debug_output to this IO via Net::HTTP#set_debug_output.
+ # Extra certificates to be added to the certificate chain
+
+ attr_reader :extra_chain_cert
+
+ ##
+ # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
#
# Never use this method in production code, it causes a serious security
# hole.
@@ -279,7 +290,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :generation # :nodoc:
##
- # Headers that are added to every request using Net::HTTP#add_field
+ # Headers that are added to every request using Gem::Net::HTTP#add_field
attr_reader :headers
@@ -304,7 +315,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
##
# Number of retries to perform if a request fails.
#
- # See also #max_retries=, Net::HTTP#max_retries=.
+ # See also #max_retries=, Gem::Net::HTTP#max_retries=.
attr_reader :max_retries
@@ -325,12 +336,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :name
##
- # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
+ # Seconds to wait until a connection is opened. See Gem::Net::HTTP#open_timeout
attr_accessor :open_timeout
##
- # Headers that are added to every request using Net::HTTP#[]=
+ # Headers that are added to every request using Gem::Net::HTTP#[]=
attr_reader :override_headers
@@ -340,7 +351,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :private_key
##
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias key private_key
@@ -360,12 +371,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :pool # :nodoc:
##
- # Seconds to wait until reading one block. See Net::HTTP#read_timeout
+ # Seconds to wait until reading one block. See Gem::Net::HTTP#read_timeout
attr_accessor :read_timeout
##
- # Seconds to wait until writing one block. See Net::HTTP#write_timeout
+ # Seconds to wait until writing one block. See Gem::Net::HTTP#write_timeout
attr_accessor :write_timeout
@@ -450,18 +461,33 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :verify_mode
##
- # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
+ # HTTPS verify_hostname.
+ #
+ # If a client sets this to true and enables SNI with SSLSocket#hostname=,
+ # the hostname verification on the server certificate is performed
+ # automatically during the handshake using
+ # OpenSSL::SSL.verify_certificate_identity().
+ #
+ # You can set +verify_hostname+ as true to use hostname verification
+ # during the handshake.
+ #
+ # NOTE: This works with Ruby > 3.0.
+
+ attr_reader :verify_hostname
+
+ ##
+ # Creates a new Gem::Net::HTTP::Persistent.
#
# Set a +name+ for fun. Your library name should be good enough, but this
# otherwise has no purpose.
#
- # +proxy+ may be set to a Bundler::URI::HTTP or :ENV to pick up proxy options from
+ # +proxy+ may be set to a Gem::URI::HTTP or :ENV to pick up proxy options from
# the environment. See proxy_from_env for details.
#
- # In order to use a Bundler::URI for the proxy you may need to do some extra work
- # beyond Bundler::URI parsing if the proxy requires a password:
+ # In order to use a Gem::URI for the proxy you may need to do some extra work
+ # beyond Gem::URI parsing if the proxy requires a password:
#
- # proxy = Bundler::URI 'http://proxy.example'
+ # proxy = Gem::URI 'http://proxy.example'
# proxy.user = 'AzureDiamond'
# proxy.password = 'hunter2'
#
@@ -492,8 +518,8 @@ class Bundler::Persistent::Net::HTTP::Persistent
@socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
Socket.const_defined? :TCP_NODELAY
- @pool = Bundler::Persistent::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
- Bundler::Persistent::Net::HTTP::Persistent::Connection.new Net::HTTP, http_args, @ssl_generation
+ @pool = Gem::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
+ Gem::Net::HTTP::Persistent::Connection.new Gem::Net::HTTP, http_args, @ssl_generation
end
@certificate = nil
@@ -508,9 +534,10 @@ class Bundler::Persistent::Net::HTTP::Persistent
@verify_callback = nil
@verify_depth = nil
@verify_mode = nil
+ @verify_hostname = nil
@cert_store = nil
- @generation = 0 # incremented when proxy Bundler::URI changes
+ @generation = 0 # incremented when proxy Gem::URI changes
if HAVE_OPENSSL then
@verify_mode = OpenSSL::SSL::VERIFY_PEER
@@ -529,7 +556,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
reconnect_ssl
end
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias cert= certificate=
##
@@ -569,6 +596,21 @@ class Bundler::Persistent::Net::HTTP::Persistent
reconnect_ssl
end
+ if Gem::Net::HTTP.method_defined?(:extra_chain_cert=)
+ ##
+ # Extra certificates to be added to the certificate chain.
+ # It is only supported starting from Gem::Net::HTTP version 0.1.1
+ def extra_chain_cert= extra_chain_cert
+ @extra_chain_cert = extra_chain_cert
+
+ reconnect_ssl
+ end
+ else
+ def extra_chain_cert= _extra_chain_cert
+ raise "extra_chain_cert= is not supported by this version of Gem::Net::HTTP"
+ end
+ end
+
##
# Creates a new connection for +uri+
@@ -587,37 +629,49 @@ class Bundler::Persistent::Net::HTTP::Persistent
connection = @pool.checkout net_http_args
- http = connection.http
+ begin
+ http = connection.http
- connection.ressl @ssl_generation if
- connection.ssl_generation != @ssl_generation
+ connection.ressl @ssl_generation if
+ connection.ssl_generation != @ssl_generation
- if not http.started? then
- ssl http if use_ssl
- start http
- elsif expired? connection then
- reset connection
- end
-
- http.keep_alive_timeout = @idle_timeout if @idle_timeout
- http.max_retries = @max_retries if http.respond_to?(:max_retries=)
- http.read_timeout = @read_timeout if @read_timeout
- http.write_timeout = @write_timeout if
- @write_timeout && http.respond_to?(:write_timeout=)
+ if not http.started? then
+ ssl http if use_ssl
+ start http
+ elsif expired? connection then
+ reset connection
+ end
- return yield connection
- rescue Errno::ECONNREFUSED
- address = http.proxy_address || http.address
- port = http.proxy_port || http.port
+ http.keep_alive_timeout = @idle_timeout if @idle_timeout
+ http.max_retries = @max_retries if http.respond_to?(:max_retries=)
+ http.read_timeout = @read_timeout if @read_timeout
+ http.write_timeout = @write_timeout if
+ @write_timeout && http.respond_to?(:write_timeout=)
+
+ return yield connection
+ rescue Errno::ECONNREFUSED
+ if http.proxy?
+ address = http.proxy_address
+ port = http.proxy_port
+ else
+ address = http.address
+ port = http.port
+ end
- raise Error, "connection refused: #{address}:#{port}"
- rescue Errno::EHOSTDOWN
- address = http.proxy_address || http.address
- port = http.proxy_port || http.port
+ raise Error, "connection refused: #{address}:#{port}"
+ rescue Errno::EHOSTDOWN
+ if http.proxy?
+ address = http.proxy_address
+ port = http.proxy_port
+ else
+ address = http.address
+ port = http.port
+ end
- raise Error, "host down: #{address}:#{port}"
- ensure
- @pool.checkin net_http_args
+ raise Error, "host down: #{address}:#{port}"
+ ensure
+ @pool.checkin net_http_args
+ end
end
##
@@ -648,7 +702,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Starts the Net::HTTP +connection+
+ # Starts the Gem::Net::HTTP +connection+
def start http
http.set_debug_output @debug_output if @debug_output
@@ -666,7 +720,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Finishes the Net::HTTP +connection+
+ # Finishes the Gem::Net::HTTP +connection+
def finish connection
connection.finish
@@ -716,16 +770,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
reconnect_ssl
end
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias key= private_key=
##
- # Sets the proxy server. The +proxy+ may be the Bundler::URI of the proxy server,
+ # Sets the proxy server. The +proxy+ may be the Gem::URI of the proxy server,
# the symbol +:ENV+ which will read the proxy from the environment or nil to
# disable use of a proxy. See #proxy_from_env for details on setting the
# proxy from the environment.
#
- # If the proxy Bundler::URI is set after requests have been made, the next request
+ # If the proxy Gem::URI is set after requests have been made, the next request
# will shut-down and re-open all connections.
#
# The +no_proxy+ query parameter can be used to specify hosts which shouldn't
@@ -736,9 +790,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
def proxy= proxy
@proxy_uri = case proxy
when :ENV then proxy_from_env
- when Bundler::URI::HTTP then proxy
+ when Gem::URI::HTTP then proxy
when nil then # ignore
- else raise ArgumentError, 'proxy must be :ENV or a Bundler::URI::HTTP'
+ else raise ArgumentError, 'proxy must be :ENV or a Gem::URI::HTTP'
end
@no_proxy.clear
@@ -754,7 +808,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
@proxy_connection_id = [nil, *@proxy_args].join ':'
if @proxy_uri.query then
- @no_proxy = CGI.parse(@proxy_uri.query)['no_proxy'].join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
+ @no_proxy = Gem::URI.decode_www_form(@proxy_uri.query).filter_map { |k, v| v if k == 'no_proxy' }.join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
end
end
@@ -763,13 +817,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Creates a Bundler::URI for an HTTP proxy server from ENV variables.
+ # Creates a Gem::URI for an HTTP proxy server from ENV variables.
#
# If +HTTP_PROXY+ is set a proxy will be returned.
#
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Bundler::URI is given the
+ # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Gem::URI is given the
# indicated user and password unless HTTP_PROXY contains either of these in
- # the Bundler::URI.
+ # the Gem::URI.
#
# The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
# be reached via proxy; if set it should be a comma separated list of
@@ -785,7 +839,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
return nil if env_proxy.nil? or env_proxy.empty?
- uri = Bundler::URI normalize_uri env_proxy
+ uri = Gem::URI normalize_uri env_proxy
env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
@@ -835,7 +889,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Finishes then restarts the Net::HTTP +connection+
+ # Finishes then restarts the Gem::Net::HTTP +connection+
def reset connection
http = connection.http
@@ -854,16 +908,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
+ # Makes a request on +uri+. If +req+ is nil a Gem::Net::HTTP::Get is performed
# against +uri+.
#
- # If a block is passed #request behaves like Net::HTTP#request (the body of
+ # If a block is passed #request behaves like Gem::Net::HTTP#request (the body of
# the response will not have been read).
#
- # +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
+ # +req+ must be a Gem::Net::HTTPGenericRequest subclass (see Gem::Net::HTTP for a list).
def request uri, req = nil, &block
- uri = Bundler::URI uri
+ uri = Gem::URI uri
req = request_setup req || uri
response = nil
@@ -896,14 +950,14 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Creates a GET request if +req_or_uri+ is a Bundler::URI and adds headers to the
+ # Creates a GET request if +req_or_uri+ is a Gem::URI and adds headers to the
# request.
#
# Returns the request.
def request_setup req_or_uri # :nodoc:
req = if req_or_uri.respond_to? 'request_uri' then
- Net::HTTP::Get.new req_or_uri.request_uri
+ Gem::Net::HTTP::Get.new req_or_uri.request_uri
else
req_or_uri
end
@@ -925,7 +979,8 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Shuts down all connections
+ # Shuts down all connections. Attempting to checkout a connection after
+ # shutdown will raise an error.
#
# *NOTE*: Calling shutdown for can be dangerous!
#
@@ -937,6 +992,17 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
+ # Discard all existing connections. Subsequent checkouts will create
+ # new connections as needed.
+ #
+ # If any thread is still using a connection it may cause an error! Call
+ # #reload when you are completely done making requests!
+
+ def reload
+ @pool.reload { |http| http.finish }
+ end
+
+ ##
# Enables SSL on +connection+
def ssl connection
@@ -948,8 +1014,10 @@ class Bundler::Persistent::Net::HTTP::Persistent
connection.min_version = @min_version if @min_version
connection.max_version = @max_version if @max_version
- connection.verify_depth = @verify_depth
- connection.verify_mode = @verify_mode
+ connection.verify_depth = @verify_depth
+ connection.verify_mode = @verify_mode
+ connection.verify_hostname = @verify_hostname if
+ @verify_hostname != nil && connection.respond_to?(:verify_hostname=)
if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
@@ -991,6 +1059,10 @@ application:
connection.key = @private_key
end
+ if defined?(@extra_chain_cert) and @extra_chain_cert
+ connection.extra_chain_cert = @extra_chain_cert
+ end
+
connection.cert_store = if @cert_store then
@cert_store
else
@@ -1059,6 +1131,15 @@ application:
end
##
+ # Sets the HTTPS verify_hostname.
+
+ def verify_hostname= verify_hostname
+ @verify_hostname = verify_hostname
+
+ reconnect_ssl
+ end
+
+ ##
# SSL verification callback.
def verify_callback= callback
@@ -1070,4 +1151,3 @@ end
require_relative 'persistent/connection'
require_relative 'persistent/pool'
-
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
index a57a5d1352..8b9ab5cc78 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
@@ -1,8 +1,8 @@
##
-# A Net::HTTP connection wrapper that holds extra information for managing the
+# A Gem::Net::HTTP connection wrapper that holds extra information for managing the
# connection's lifetime.
-class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
+class Gem::Net::HTTP::Persistent::Connection # :nodoc:
attr_accessor :http
@@ -25,9 +25,10 @@ class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
ensure
reset
end
+ alias_method :close, :finish
def reset
- @last_use = Bundler::Persistent::Net::HTTP::Persistent::EPOCH
+ @last_use = Gem::Net::HTTP::Persistent::EPOCH
@requests = 0
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
index 9dfa6ffdb1..04a1e754bf 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
@@ -1,4 +1,4 @@
-class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
+class Gem::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
attr_reader :available # :nodoc:
attr_reader :key # :nodoc:
@@ -6,25 +6,37 @@ class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool
def initialize(options = {}, &block)
super
- @available = Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
+ @available = Gem::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
@key = "current-#{@available.object_id}"
end
def checkin net_http_args
- stack = Thread.current[@key][net_http_args] ||= []
+ if net_http_args.is_a?(Hash) && net_http_args.size == 1 && net_http_args[:force]
+ # Bundler::ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
+ # When this happens, we should remove all connections from Thread.current
+ if stacks = Thread.current[@key]
+ stacks.each do |http_args, connections|
+ connections.each do |conn|
+ @available.push conn, connection_args: http_args
+ end
+ connections.clear
+ end
+ end
+ else
+ stack = Thread.current[@key][net_http_args] ||= []
- raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
- stack.empty?
+ raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
+ stack.empty?
- conn = stack.pop
+ conn = stack.pop
- if stack.empty?
- @available.push conn, connection_args: net_http_args
+ if stack.empty?
+ @available.push conn, connection_args: net_http_args
- Thread.current[@key].delete(net_http_args)
- Thread.current[@key] = nil if Thread.current[@key].empty?
+ Thread.current[@key].delete(net_http_args)
+ Thread.current[@key] = nil if Thread.current[@key].empty?
+ end
end
-
nil
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
index 2da881c554..034fbe39b8 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
@@ -1,4 +1,4 @@
-class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
+class Gem::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
##
# Returns a new hash that has arrays for keys
@@ -63,7 +63,8 @@ class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::Con
if @created >= @max && @enqueued >= 1
oldest, = @lru.first
@lru.delete oldest
- @ques[oldest].pop
+ connection = @ques[oldest].pop
+ connection.close if connection.respond_to?(:close)
@created -= 1
end
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
index dce20d37ad..491151ec0b 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
@@ -79,29 +79,17 @@ module Bundler::PubGrub
dependencies_for(@root_package, @root_version)
end
- # Override me (maybe)
- #
- # If not overridden, the order returned by all_versions_for will be used
- #
- # Returns: Array of versions in preferred order
- def sort_versions_by_preferred(package, sorted_versions)
- indexes = @version_indexes[package]
- sorted_versions.sort_by { |version| indexes[version] }
- end
-
def initialize
@root_package = Package.root
@root_version = Package.root_version
- @cached_versions = Hash.new do |h,k|
+ @sorted_versions = Hash.new do |h,k|
if k == @root_package
h[k] = [@root_version]
else
- h[k] = all_versions_for(k)
+ h[k] = all_versions_for(k).sort
end
end
- @sorted_versions = Hash.new { |h,k| h[k] = @cached_versions[k].sort }
- @version_indexes = Hash.new { |h,k| h[k] = @cached_versions[k].each.with_index.to_h }
@cached_dependencies = Hash.new do |packages, package|
if package == @root_package
@@ -117,15 +105,7 @@ module Bundler::PubGrub
end
def versions_for(package, range=VersionRange.any)
- versions = range.select_versions(@sorted_versions[package])
-
- # Conditional avoids (among other things) calling
- # sort_versions_by_preferred with the root package
- if versions.size > 1
- sort_versions_by_preferred(package, versions)
- else
- versions
- end
+ range.select_versions(@sorted_versions[package])
end
def no_versions_incompatibility_for(_package, unsatisfied_term)
@@ -164,7 +144,7 @@ module Bundler::PubGrub
sorted_versions[high]
end
- range = VersionRange.new(min: low, max: high, include_min: true)
+ range = VersionRange.new(min: low, max: high, include_min: !low.nil?)
self_constraint = VersionConstraint.new(package, range: range)
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
index 4bf61461b2..36ab06254d 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
@@ -1,4 +1,5 @@
require_relative 'package'
+require_relative 'rubygems'
require_relative 'version_constraint'
require_relative 'incompatibility'
require_relative 'basic_package_source'
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb
new file mode 100644
index 0000000000..6955655ba4
--- /dev/null
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb
@@ -0,0 +1,42 @@
+module Bundler::PubGrub
+ class Strategy
+ def initialize(source)
+ @source = source
+
+ @root_package = Package.root
+ @root_version = Package.root_version
+
+ @version_indexes = Hash.new do |h,k|
+ if k == @root_package
+ h[k] = { @root_version => 0 }
+ else
+ h[k] = @source.all_versions_for(k).each.with_index.to_h
+ end
+ end
+ end
+
+ def next_package_and_version(unsatisfied)
+ package, range = next_term_to_try_from(unsatisfied)
+
+ [package, most_preferred_version_of(package, range)]
+ end
+
+ private
+
+ def most_preferred_version_of(package, range)
+ versions = @source.versions_for(package, range)
+
+ indexes = @version_indexes[package]
+ versions.min_by { |version| indexes[version] }
+ end
+
+ def next_term_to_try_from(unsatisfied)
+ unsatisfied.min_by do |package, range|
+ matching_versions = @source.versions_for(package, range)
+ higher_versions = @source.versions_for(package, range.upper_invert)
+
+ [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
index 8d73c3f7b5..49dcf716a3 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
@@ -76,6 +76,9 @@ module Bundler::PubGrub
end
def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
+ raise ArgumentError, "Ranges without a lower bound cannot have include_min == true" if !min && include_min == true
+ raise ArgumentError, "Ranges without an upper bound cannot have include_max == true" if !max && include_max == true
+
@min = min
@max = max
@include_min = include_min
@@ -311,10 +314,19 @@ module Bundler::PubGrub
def contiguous_to?(other)
return false if other.empty?
+ return true if any?
+
+ intersects?(other) || contiguous_below?(other) || contiguous_above?(other)
+ end
+
+ def contiguous_below?(other)
+ return false if !max || !other.min
+
+ max == other.min && (include_max || other.include_min)
+ end
- intersects?(other) ||
- (min == other.max && (include_min || other.include_max)) ||
- (max == other.min && (include_max || other.include_min))
+ def contiguous_above?(other)
+ other.contiguous_below?(self)
end
def allows_all?(other)
@@ -375,15 +387,15 @@ module Bundler::PubGrub
def invert
return self.class.empty if any?
- low = VersionRange.new(max: min, include_max: !include_min)
- high = VersionRange.new(min: max, include_min: !include_max)
+ low = -> { VersionRange.new(max: min, include_max: !include_min) }
+ high = -> { VersionRange.new(min: max, include_min: !include_max) }
if !min
- high
+ high.call
elsif !max
- low
+ low.call
else
- low.union(high)
+ low.call.union(high.call)
end
end
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
index 2cb8412cf3..000923e99a 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
@@ -2,17 +2,20 @@ require_relative 'partial_solution'
require_relative 'term'
require_relative 'incompatibility'
require_relative 'solve_failure'
+require_relative 'strategy'
module Bundler::PubGrub
class VersionSolver
attr_reader :logger
attr_reader :source
attr_reader :solution
+ attr_reader :strategy
- def initialize(source:, root: Package.root, logger: Bundler::PubGrub.logger)
+ def initialize(source:, root: Package.root, strategy: Strategy.new(source), logger: Bundler::PubGrub.logger)
@logger = logger
@source = source
+ @strategy = strategy
# { package => [incompatibility, ...]}
@incompatibilities = Hash.new do |h, k|
@@ -36,26 +39,25 @@ module Bundler::PubGrub
# Returns true if there is more work to be done, false otherwise
def work
- return false if solved?
-
- next_package = choose_package_version
- propagate(next_package)
-
- if solved?
+ unsatisfied_terms = solution.unsatisfied
+ if unsatisfied_terms.empty?
logger.info { "Solution found after #{solution.attempted_solutions} attempts:" }
solution.decisions.each do |package, version|
next if Package.root?(package)
logger.info { "* #{package} #{version}" }
end
- false
- else
- true
+ return false
end
+
+ next_package = choose_package_version_from(unsatisfied_terms)
+ propagate(next_package)
+
+ true
end
def solve
- work until solved?
+ while work; end
solution.decisions
end
@@ -105,29 +107,15 @@ module Bundler::PubGrub
unsatisfied.package
end
- def next_package_to_try
- solution.unsatisfied.min_by do |term|
- package = term.package
- range = term.constraint.range
- matching_versions = source.versions_for(package, range)
- higher_versions = source.versions_for(package, range.upper_invert)
-
- [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
- end.package
- end
+ def choose_package_version_from(unsatisfied_terms)
+ remaining = unsatisfied_terms.map { |t| [t.package, t.constraint.range] }.to_h
- def choose_package_version
- if solution.unsatisfied.empty?
- logger.info "No packages unsatisfied. Solving complete!"
- return nil
- end
+ package, version = strategy.next_package_and_version(remaining)
- package = next_package_to_try
- unsatisfied_term = solution.unsatisfied.find { |t| t.package == package }
- version = source.versions_for(package, unsatisfied_term.constraint.range).first
logger.debug { "attempting #{package} #{version}" }
if version.nil?
+ unsatisfied_term = unsatisfied_terms.find { |t| t.package == package }
add_incompatibility source.no_versions_incompatibility_for(package, unsatisfied_term)
return package
end
@@ -162,7 +150,7 @@ module Bundler::PubGrub
def resolve_conflict(incompatibility)
logger.info { "conflict: #{incompatibility}" }
- new_incompatibility = false
+ new_incompatibility = nil
while !incompatibility.failure?
most_recent_term = nil
@@ -204,7 +192,7 @@ module Bundler::PubGrub
solution.backtrack(previous_level)
if new_incompatibility
- add_incompatibility(incompatibility)
+ add_incompatibility(new_incompatibility)
end
return incompatibility
@@ -219,9 +207,14 @@ module Bundler::PubGrub
new_terms << difference.invert
end
- incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
+ new_incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
+
+ if incompatibility.to_s == new_incompatibility.to_s
+ logger.info { "!! failed to resolve conflicts, this shouldn't have happened" }
+ break
+ end
- new_incompatibility = true
+ incompatibility = new_incompatibility
partially = difference ? " partially" : ""
logger.info { "! #{most_recent_term} is#{partially} satisfied by #{most_recent_satisfier.term}" }
diff --git a/lib/bundler/vendor/securerandom/lib/securerandom.rb b/lib/bundler/vendor/securerandom/lib/securerandom.rb
new file mode 100644
index 0000000000..01b7fa15a6
--- /dev/null
+++ b/lib/bundler/vendor/securerandom/lib/securerandom.rb
@@ -0,0 +1,102 @@
+# -*- coding: us-ascii -*-
+# frozen_string_literal: true
+
+require 'random/formatter'
+
+# == Secure random number generator interface.
+#
+# This library is an interface to secure random number generators which are
+# suitable for generating session keys in HTTP cookies, etc.
+#
+# You can use this library in your application by requiring it:
+#
+# require 'bundler/vendor/securerandom/lib/securerandom'
+#
+# It supports the following secure random number generators:
+#
+# * openssl
+# * /dev/urandom
+# * Win32
+#
+# Bundler::SecureRandom is extended by the Random::Formatter module which
+# defines the following methods:
+#
+# * alphanumeric
+# * base64
+# * choose
+# * gen_random
+# * hex
+# * rand
+# * random_bytes
+# * random_number
+# * urlsafe_base64
+# * uuid
+#
+# These methods are usable as class methods of Bundler::SecureRandom such as
+# +Bundler::SecureRandom.hex+.
+#
+# If a secure random number generator is not available,
+# +NotImplementedError+ is raised.
+
+module Bundler::SecureRandom
+
+ # The version
+ VERSION = "0.4.1"
+
+ class << self
+ # Returns a random binary string containing +size+ bytes.
+ #
+ # See Random.bytes
+ def bytes(n)
+ return gen_random(n)
+ end
+
+ # Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
+ def alphanumeric(n = nil, chars: ALPHANUMERIC)
+ n = 16 if n.nil?
+ choose(chars, n)
+ end if RUBY_VERSION < '3.3'
+
+ private
+
+ # :stopdoc:
+
+ # Implementation using OpenSSL
+ def gen_random_openssl(n)
+ return OpenSSL::Random.random_bytes(n)
+ end
+
+ # Implementation using system random device
+ def gen_random_urandom(n)
+ ret = Random.urandom(n)
+ unless ret
+ raise NotImplementedError, "No random device"
+ end
+ unless ret.length == n
+ raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
+ end
+ ret
+ end
+
+ begin
+ # Check if Random.urandom is available
+ Random.urandom(1)
+ alias gen_random gen_random_urandom
+ rescue RuntimeError
+ begin
+ require 'openssl'
+ rescue NoMethodError
+ raise NotImplementedError, "No random device"
+ else
+ alias gen_random gen_random_openssl
+ end
+ end
+
+ # :startdoc:
+
+ # Generate random data bytes for Random::Formatter
+ public :gen_random
+ end
+end
+
+Bundler::SecureRandom.extend(Random::Formatter)
diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb
index 0794dbb522..945bdbd551 100644
--- a/lib/bundler/vendor/thor/lib/thor.rb
+++ b/lib/bundler/vendor/thor/lib/thor.rb
@@ -65,8 +65,15 @@ class Bundler::Thor
# Defines the long description of the next command.
#
+ # Long description is by default indented, line-wrapped and repeated whitespace merged.
+ # In order to print long description verbatim, with indentation and spacing exactly
+ # as found in the code, use the +wrap+ option
+ #
+ # long_desc 'your very long description', wrap: false
+ #
# ==== Parameters
# long description<String>
+ # options<Hash>
#
def long_desc(long_description, options = {})
if options[:for]
@@ -74,6 +81,7 @@ class Bundler::Thor
command.long_description = long_description if long_description
else
@long_desc = long_description
+ @long_desc_wrap = options[:wrap] != false
end
end
@@ -133,7 +141,7 @@ class Bundler::Thor
# # magic
# end
#
- # method_option :foo => :bar, :for => :previous_command
+ # method_option :foo, :for => :previous_command
#
# def next_command
# # magic
@@ -153,6 +161,9 @@ class Bundler::Thor
# :hide - If you want to hide this option from the help.
#
def method_option(name, options = {})
+ unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
+ raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
+ end
scope = if options[:for]
find_and_refresh_command(options[:for]).options
else
@@ -163,6 +174,81 @@ class Bundler::Thor
end
alias_method :option, :method_option
+ # Adds and declares option group for exclusive options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # If :for is given as option, it allows you to change the options from
+ # a previous defined command.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ # options<Hash>:: :for is applied for previous defined command.
+ #
+ # ==== Examples
+ #
+ # exclusive do
+ # option :one
+ # option :two
+ # end
+ #
+ # Or
+ #
+ # option :one
+ # option :two
+ # exclusive :one, :two
+ #
+ # If you give "--one" and "--two" at the same time ExclusiveArgumentsError
+ # will be raised.
+ #
+ def method_exclusive(*args, &block)
+ register_options_relation_for(:method_options,
+ :method_exclusive_option_names, *args, &block)
+ end
+ alias_method :exclusive, :method_exclusive
+
+ # Adds and declares option group for required at least one of options in the
+ # block of arguments. You can declare options as the outside of the block.
+ #
+ # If :for is given as option, it allows you to change the options from
+ # a previous defined command.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ # options<Hash>:: :for is applied for previous defined command.
+ #
+ # ==== Examples
+ #
+ # at_least_one do
+ # option :one
+ # option :two
+ # end
+ #
+ # Or
+ #
+ # option :one
+ # option :two
+ # at_least_one :one, :two
+ #
+ # If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError
+ # will be raised.
+ #
+ # You can use at_least_one and exclusive at the same time.
+ #
+ # exclusive do
+ # at_least_one do
+ # option :one
+ # option :two
+ # end
+ # end
+ #
+ # Then it is required either only one of "--one" or "--two".
+ #
+ def method_at_least_one(*args, &block)
+ register_options_relation_for(:method_options,
+ :method_at_least_one_option_names, *args, &block)
+ end
+ alias_method :at_least_one, :method_at_least_one
+
# Prints help information for the given command.
#
# ==== Parameters
@@ -178,9 +264,16 @@ class Bundler::Thor
shell.say " #{banner(command).split("\n").join("\n ")}"
shell.say
class_options_help(shell, nil => command.options.values)
+ print_exclusive_options(shell, command)
+ print_at_least_one_required_options(shell, command)
+
if command.long_description
shell.say "Description:"
- shell.print_wrapped(command.long_description, :indent => 2)
+ if command.wrap_long_description
+ shell.print_wrapped(command.long_description, indent: 2)
+ else
+ shell.say command.long_description
+ end
else
shell.say command.description
end
@@ -197,7 +290,7 @@ class Bundler::Thor
Bundler::Thor::Util.thor_classes_in(self).each do |klass|
list += klass.printable_commands(false)
end
- list.sort! { |a, b| a[0] <=> b[0] }
+ sort_commands!(list)
if defined?(@package_name) && @package_name
shell.say "#{@package_name} commands:"
@@ -205,9 +298,11 @@ class Bundler::Thor
shell.say "Commands:"
end
- shell.print_table(list, :indent => 2, :truncate => true)
+ shell.print_table(list, indent: 2, truncate: true)
shell.say
class_options_help(shell)
+ print_exclusive_options(shell)
+ print_at_least_one_required_options(shell)
end
# Returns commands ready to be printed.
@@ -238,7 +333,7 @@ class Bundler::Thor
define_method(subcommand) do |*args|
args, opts = Bundler::Thor::Arguments.split(args)
- invoke_args = [args, opts, {:invoked_via_subcommand => true, :class_options => options}]
+ invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]
invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
invoke subcommand_class, *invoke_args
end
@@ -344,8 +439,37 @@ class Bundler::Thor
command && disable_required_check.include?(command.name.to_sym)
end
+ # Checks if a specified command exists.
+ #
+ # ==== Parameters
+ # command_name<String>:: The name of the command to check for existence.
+ #
+ # ==== Returns
+ # Boolean:: +true+ if the command exists, +false+ otherwise.
+ def command_exists?(command_name) #:nodoc:
+ commands.keys.include?(normalize_command_name(command_name))
+ end
+
protected
+ # Returns this class exclusive options array set.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def method_exclusive_option_names #:nodoc:
+ @method_exclusive_option_names ||= []
+ end
+
+ # Returns this class at least one of required options array set.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def method_at_least_one_option_names #:nodoc:
+ @method_at_least_one_option_names ||= []
+ end
+
def stop_on_unknown_option #:nodoc:
@stop_on_unknown_option ||= []
end
@@ -355,8 +479,30 @@ class Bundler::Thor
@disable_required_check ||= [:help]
end
+ def print_exclusive_options(shell, command = nil) # :nodoc:
+ opts = []
+ opts = command.method_exclusive_option_names unless command.nil?
+ opts += class_exclusive_option_names
+ unless opts.empty?
+ shell.say "Exclusive Options:"
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
+ shell.say
+ end
+ end
+
+ def print_at_least_one_required_options(shell, command = nil) # :nodoc:
+ opts = []
+ opts = command.method_at_least_one_option_names unless command.nil?
+ opts += class_at_least_one_option_names
+ unless opts.empty?
+ shell.say "Required At Least One:"
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
+ shell.say
+ end
+ end
+
# The method responsible for dispatching given the args.
- def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
+ def dispatch(meth, given_args, given_opts, config) #:nodoc:
meth ||= retrieve_command_name(given_args)
command = all_commands[normalize_command_name(meth)]
@@ -415,12 +561,16 @@ class Bundler::Thor
@usage ||= nil
@desc ||= nil
@long_desc ||= nil
+ @long_desc_wrap ||= nil
@hide ||= nil
if @usage && @desc
base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command
- commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
- @usage, @desc, @long_desc, @method_options, @hide = nil
+ relations = {exclusive_option_names: method_exclusive_option_names,
+ at_least_one_option_names: method_at_least_one_option_names}
+ commands[meth] = base_class.new(meth, @desc, @long_desc, @long_desc_wrap, @usage, method_options, relations)
+ @usage, @desc, @long_desc, @long_desc_wrap, @method_options, @hide = nil
+ @method_exclusive_option_names, @method_at_least_one_option_names = nil
true
elsif all_commands[meth] || meth == "method_missing"
true
@@ -475,7 +625,7 @@ class Bundler::Thor
# alias name.
def find_command_possibilities(meth)
len = meth.to_s.length
- possibilities = all_commands.merge(map).keys.select { |n| meth == n[0, len] }.sort
+ possibilities = all_commands.reject { |_k, c| c.hidden? }.merge(map).keys.select { |n| meth == n[0, len] }.sort
unique_possibilities = possibilities.map { |k| map[k] || k }.uniq
if possibilities.include?(meth)
@@ -495,6 +645,14 @@ class Bundler::Thor
"
end
alias_method :subtask_help, :subcommand_help
+
+ # Sort the commands, lexicographically by default.
+ #
+ # Can be overridden in the subclass to change the display order of the
+ # commands.
+ def sort_commands!(list)
+ list.sort! { |a, b| a[0] <=> b[0] }
+ end
end
include Bundler::Thor::Base
diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
index de9b3b4c86..ca58182691 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions.rb
@@ -46,17 +46,17 @@ class Bundler::Thor
# Add runtime options that help actions execution.
#
def add_runtime_options!
- class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
- :desc => "Overwrite files that already exist"
+ class_option :force, type: :boolean, aliases: "-f", group: :runtime,
+ desc: "Overwrite files that already exist"
- class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
- :desc => "Run but do not make any changes"
+ class_option :pretend, type: :boolean, aliases: "-p", group: :runtime,
+ desc: "Run but do not make any changes"
- class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
- :desc => "Suppress status output"
+ class_option :quiet, type: :boolean, aliases: "-q", group: :runtime,
+ desc: "Suppress status output"
- class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
- :desc => "Skip files that already exist"
+ class_option :skip, type: :boolean, aliases: "-s", group: :runtime,
+ desc: "Skip files that already exist"
end
end
@@ -113,9 +113,9 @@ class Bundler::Thor
#
def relative_to_original_destination_root(path, remove_dot = true)
root = @destination_stack[0]
- if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ''].include?(path[root.size..root.size])
+ if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ""].include?(path[root.size..root.size])
path = path.dup
- path[0...root.size] = '.'
+ path[0...root.size] = "."
remove_dot ? (path[2..-1] || "") : path
else
path
@@ -175,7 +175,7 @@ class Bundler::Thor
shell.padding += 1 if verbose
@destination_stack.push File.expand_path(dir, destination_root)
- # If the directory doesnt exist and we're not pretending
+ # If the directory doesn't exist and we're not pretending
if !File.exist?(destination_root) && !pretend
require "fileutils"
FileUtils.mkdir_p(destination_root)
@@ -225,7 +225,7 @@ class Bundler::Thor
require "open-uri"
URI.open(path, "Accept" => "application/x-thor-template", &:read)
else
- open(path, &:read)
+ File.open(path, &:read)
end
instance_eval(contents, path)
@@ -284,7 +284,7 @@ class Bundler::Thor
#
def run_ruby_script(command, config = {})
return unless behavior == :invoke
- run command, config.merge(:with => Bundler::Thor::Util.ruby_command)
+ run command, config.merge(with: Bundler::Thor::Util.ruby_command)
end
# Run a thor command. A hash of options can be given and it's converted to
@@ -315,7 +315,7 @@ class Bundler::Thor
args.push Bundler::Thor::Options.to_switches(config)
command = args.join(" ").strip
- run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
+ run command, with: :thor, verbose: verbose, pretend: pretend, capture: capture
end
protected
@@ -323,7 +323,7 @@ class Bundler::Thor
# Allow current root to be shared between invocations.
#
def _shared_configuration #:nodoc:
- super.merge!(:destination_root => destination_root)
+ super.merge!(destination_root: destination_root)
end
def _cleanup_options_and_set(options, key) #:nodoc:
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
index 330fc08cae..6724835b01 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
@@ -43,7 +43,8 @@ class Bundler::Thor
# Boolean:: true if it is identical, false otherwise.
#
def identical?
- exists? && File.binread(destination) == render
+ # binread uses ASCII-8BIT, so to avoid false negatives, the string must use the same
+ exists? && File.binread(destination) == String.new(render).force_encoding("ASCII-8BIT")
end
# Holds the content to be added to the file.
@@ -60,7 +61,7 @@ class Bundler::Thor
invoke_with_conflict_check do
require "fileutils"
FileUtils.mkdir_p(File.dirname(destination))
- File.open(destination, "wb") { |f| f.write render }
+ File.open(destination, "wb", config[:perm]) { |f| f.write render }
end
given_destination
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
index d37327a139..2f9687c0a5 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
@@ -58,7 +58,7 @@ class Bundler::Thor
def initialize(base, source, destination = nil, config = {}, &block)
@source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
@block = block
- super(base, destination, {:recursive => true}.merge(config))
+ super(base, destination, {recursive: true}.merge(config))
end
def invoke!
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
index 284d92c19a..c0bca78525 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
@@ -33,7 +33,7 @@ class Bundler::Thor
#
def initialize(base, destination, config = {})
@base = base
- @config = {:verbose => true}.merge(config)
+ @config = {verbose: true}.merge(config)
self.destination = destination
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
index bf2a737c84..d8c9863054 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
@@ -10,7 +10,6 @@ class Bundler::Thor
# destination<String>:: the relative path to the destination root.
# config<Hash>:: give :verbose => false to not log the status, and
# :mode => :preserve, to preserve the file mode from the source.
-
#
# ==== Examples
#
@@ -66,12 +65,15 @@ class Bundler::Thor
# ==== Parameters
# source<String>:: the address of the given content.
# destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
+ # config<Hash>:: give :verbose => false to not log the status, and
+ # :http_headers => <Hash> to add headers to an http request.
#
# ==== Examples
#
# get "http://gist.github.com/103208", "doc/README"
#
+ # get "http://gist.github.com/103208", "doc/README", :http_headers => {"Content-Type" => "application/json"}
+ #
# get "http://gist.github.com/103208" do |content|
# content.split("\n").first
# end
@@ -82,10 +84,10 @@ class Bundler::Thor
render = if source =~ %r{^https?\://}
require "open-uri"
- URI.send(:open, source) { |input| input.binmode.read }
+ URI.send(:open, source, config.fetch(:http_headers, {})) { |input| input.binmode.read }
else
source = File.expand_path(find_in_source_paths(source.to_s))
- open(source) { |input| input.binmode.read }
+ File.open(source) { |input| input.binmode.read }
end
destination ||= if block_given?
@@ -120,12 +122,7 @@ class Bundler::Thor
context = config.delete(:context) || instance_eval("binding")
create_file destination, nil, config do
- match = ERB.version.match(/(\d+\.\d+\.\d+)/)
- capturable_erb = if match && match[1] >= "2.2.0" # Ruby 2.6+
- CapturableERB.new(::File.binread(source), :trim_mode => "-", :eoutvar => "@output_buffer")
- else
- CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer")
- end
+ capturable_erb = CapturableERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer")
content = capturable_erb.tap do |erb|
erb.filename = source
end.result(context)
@@ -245,6 +242,35 @@ class Bundler::Thor
insert_into_file(path, *(args << config), &block)
end
+ # Run a regular expression replacement on a file, raising an error if the
+ # contents of the file are not changed.
+ #
+ # ==== Parameters
+ # path<String>:: path of the file to be changed
+ # flag<Regexp|String>:: the regexp or string to be replaced
+ # replacement<String>:: the replacement, can be also given as a block
+ # config<Hash>:: give :verbose => false to not log the status, and
+ # :force => true, to force the replacement regardless of runner behavior.
+ #
+ # ==== Example
+ #
+ # gsub_file! 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
+ #
+ # gsub_file! 'README', /rake/, :green do |match|
+ # match << " no more. Use thor!"
+ # end
+ #
+ def gsub_file!(path, flag, *args, &block)
+ config = args.last.is_a?(Hash) ? args.pop : {}
+
+ return unless behavior == :invoke || config.fetch(:force, false)
+
+ path = File.expand_path(path, destination_root)
+ say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
+
+ actually_gsub_file(path, flag, args, true, &block) unless options[:pretend]
+ end
+
# Run a regular expression replacement on a file.
#
# ==== Parameters
@@ -252,7 +278,7 @@ class Bundler::Thor
# flag<Regexp|String>:: the regexp or string to be replaced
# replacement<String>:: the replacement, can be also given as a block
# config<Hash>:: give :verbose => false to not log the status, and
- # :force => true, to force the replacement regardles of runner behavior.
+ # :force => true, to force the replacement regardless of runner behavior.
#
# ==== Example
#
@@ -270,16 +296,11 @@ class Bundler::Thor
path = File.expand_path(path, destination_root)
say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- unless options[:pretend]
- content = File.binread(path)
- content.gsub!(flag, *args, &block)
- File.open(path, "wb") { |file| file.write(content) }
- end
+ actually_gsub_file(path, flag, args, false, &block) unless options[:pretend]
end
- # Uncomment all lines matching a given regex. It will leave the space
- # which existed before the comment hash in tact but will remove any spacing
- # between the comment hash and the beginning of the line.
+ # Uncomment all lines matching a given regex. Preserves indentation before
+ # the comment hash and removes the hash and any immediate following space.
#
# ==== Parameters
# path<String>:: path of the file to be changed
@@ -293,7 +314,7 @@ class Bundler::Thor
def uncomment_lines(path, flag, *args)
flag = flag.respond_to?(:source) ? flag.source : flag
- gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args)
+ gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args)
end
# Comment all lines matching a given regex. It will leave the space
@@ -352,7 +373,7 @@ class Bundler::Thor
end
def with_output_buffer(buf = "".dup) #:nodoc:
- raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
+ raise ArgumentError, "Buffer cannot be a frozen object" if buf.frozen?
old_buffer = output_buffer
self.output_buffer = buf
yield
@@ -361,6 +382,17 @@ class Bundler::Thor
self.output_buffer = old_buffer
end
+ def actually_gsub_file(path, flag, args, error_on_no_change, &block)
+ content = File.binread(path)
+ success = content.gsub!(flag, *args, &block)
+
+ if success.nil? && error_on_no_change
+ raise Bundler::Thor::Error, "The content of #{path} did not change"
+ end
+
+ File.open(path, "wb") { |file| file.write(content) }
+ end
+
# Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
# Thus CapturableERB fixes ERB to use String buffer.
class CapturableERB < ERB
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
index bf013307f1..70526e615f 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
@@ -21,7 +21,7 @@ class Bundler::Thor
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
- WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
+ WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"}
def insert_into_file(destination, *args, &block)
data = block_given? ? block : args.shift
@@ -37,7 +37,7 @@ class Bundler::Thor
attr_reader :replacement, :flag, :behavior
def initialize(base, destination, data, config)
- super(base, destination, {:verbose => true}.merge(config))
+ super(base, destination, {verbose: true}.merge(config))
@behavior, @flag = if @config.key?(:after)
[:after, @config.delete(:after)]
@@ -59,6 +59,8 @@ class Bundler::Thor
if exists?
if replace!(/#{flag}/, content, config[:force])
say_status(:invoke)
+ elsif replacement_present?
+ say_status(:unchanged, color: :blue)
else
say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
end
@@ -96,6 +98,8 @@ class Bundler::Thor
end
elsif warning
warning
+ elsif behavior == :unchanged
+ :unchanged
else
:subtract
end
@@ -103,11 +107,18 @@ class Bundler::Thor
super(status, (color || config[:verbose]))
end
+ def content
+ @content ||= File.read(destination)
+ end
+
+ def replacement_present?
+ content.include?(replacement)
+ end
+
# Adds the content to the file.
#
def replace!(regexp, string, force)
- content = File.read(destination)
- if force || !content.include?(replacement)
+ if force || !replacement_present?
success = content.gsub!(regexp, string)
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
index 8487f9590a..b156899c1e 100644
--- a/lib/bundler/vendor/thor/lib/thor/base.rb
+++ b/lib/bundler/vendor/thor/lib/thor/base.rb
@@ -24,9 +24,9 @@ class Bundler::Thor
class << self
def deprecation_warning(message) #:nodoc:
- unless ENV['THOR_SILENCE_DEPRECATION']
+ unless ENV["THOR_SILENCE_DEPRECATION"]
warn "Deprecation warning: #{message}\n" +
- 'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
+ "You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION."
end
end
end
@@ -60,6 +60,7 @@ class Bundler::Thor
command_options = config.delete(:command_options) # hook for start
parse_options = parse_options.merge(command_options) if command_options
+
if local_options.is_a?(Array)
array_options = local_options
hash_options = {}
@@ -73,9 +74,24 @@ class Bundler::Thor
# Let Bundler::Thor::Options parse the options first, so it can remove
# declared options from the array. This will leave us with
# a list of arguments that weren't declared.
- stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command]
- disable_required_check = self.class.disable_required_check? config[:current_command]
- opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check)
+ current_command = config[:current_command]
+ stop_on_unknown = self.class.stop_on_unknown_option? current_command
+
+ # Give a relation of options.
+ # After parsing, Bundler::Thor::Options check whether right relations are kept
+ relations = if current_command.nil?
+ {exclusive_option_names: [], at_least_one_option_names: []}
+ else
+ current_command.options_relation
+ end
+
+ self.class.class_exclusive_option_names.map { |n| relations[:exclusive_option_names] << n }
+ self.class.class_at_least_one_option_names.map { |n| relations[:at_least_one_option_names] << n }
+
+ disable_required_check = self.class.disable_required_check? current_command
+
+ opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check, relations)
+
self.options = opts.parse(array_options)
self.options = config[:class_options].merge(options) if config[:class_options]
@@ -310,9 +326,92 @@ class Bundler::Thor
# :hide:: -- If you want to hide this option from the help.
#
def class_option(name, options = {})
+ unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
+ raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
+ end
build_option(name, options, class_options)
end
+ # Adds and declares option group for exclusive options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ #
+ # ==== Examples
+ #
+ # class_exclusive do
+ # class_option :one
+ # class_option :two
+ # end
+ #
+ # Or
+ #
+ # class_option :one
+ # class_option :two
+ # class_exclusive :one, :two
+ #
+ # If you give "--one" and "--two" at the same time ExclusiveArgumentsError
+ # will be raised.
+ #
+ def class_exclusive(*args, &block)
+ register_options_relation_for(:class_options,
+ :class_exclusive_option_names, *args, &block)
+ end
+
+ # Adds and declares option group for required at least one of options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # ==== Examples
+ #
+ # class_at_least_one do
+ # class_option :one
+ # class_option :two
+ # end
+ #
+ # Or
+ #
+ # class_option :one
+ # class_option :two
+ # class_at_least_one :one, :two
+ #
+ # If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError
+ # will be raised.
+ #
+ # You can use class_at_least_one and class_exclusive at the same time.
+ #
+ # class_exclusive do
+ # class_at_least_one do
+ # class_option :one
+ # class_option :two
+ # end
+ # end
+ #
+ # Then it is required either only one of "--one" or "--two".
+ #
+ def class_at_least_one(*args, &block)
+ register_options_relation_for(:class_options,
+ :class_at_least_one_option_names, *args, &block)
+ end
+
+ # Returns this class exclusive options array set, looking up in the ancestors chain.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def class_exclusive_option_names
+ @class_exclusive_option_names ||= from_superclass(:class_exclusive_option_names, [])
+ end
+
+ # Returns this class at least one of required options array set, looking up in the ancestors chain.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def class_at_least_one_option_names
+ @class_at_least_one_option_names ||= from_superclass(:class_at_least_one_option_names, [])
+ end
+
# Removes a previous defined argument. If :undefine is given, undefine
# accessors as well.
#
@@ -506,7 +605,7 @@ class Bundler::Thor
#
def public_command(*names)
names.each do |name|
- class_eval "def #{name}(*); super end"
+ class_eval "def #{name}(*); super end", __FILE__, __LINE__
end
end
alias_method :public_task, :public_command
@@ -558,20 +657,19 @@ class Bundler::Thor
return if options.empty?
list = []
- padding = options.map { |o| o.aliases.size }.max.to_i * 4
-
+ padding = options.map { |o| o.aliases_for_usage.size }.max.to_i
options.each do |option|
next if option.hide
item = [option.usage(padding)]
item.push(option.description ? "# #{option.description}" : "")
list << item
- list << ["", "# Default: #{option.default}"] if option.show_default?
- list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
+ list << ["", "# Default: #{option.print_default}"] if option.show_default?
+ list << ["", "# Possible values: #{option.enum_to_s}"] if option.enum
end
shell.say(group_name ? "#{group_name} options:" : "Options:")
- shell.print_table(list, :indent => 2)
+ shell.print_table(list, indent: 2)
shell.say ""
end
@@ -588,7 +686,7 @@ class Bundler::Thor
# options<Hash>:: Described in both class_option and method_option.
# scope<Hash>:: Options hash that is being built up
def build_option(name, options, scope) #:nodoc:
- scope[name] = Bundler::Thor::Option.new(name, {:check_default_type => check_default_type}.merge!(options))
+ scope[name] = Bundler::Thor::Option.new(name, {check_default_type: check_default_type}.merge!(options))
end
# Receives a hash of options, parse them and add to the scope. This is a
@@ -610,7 +708,7 @@ class Bundler::Thor
def find_and_refresh_command(name) #:nodoc:
if commands[name.to_s]
commands[name.to_s]
- elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
+ elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
commands[name.to_s] = command.clone
else
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
@@ -618,7 +716,7 @@ class Bundler::Thor
end
alias_method :find_and_refresh_task, :find_and_refresh_command
- # Everytime someone inherits from a Bundler::Thor class, register the klass
+ # Every time someone inherits from a Bundler::Thor class, register the klass
# and file into baseclass.
def inherited(klass)
super(klass)
@@ -694,6 +792,34 @@ class Bundler::Thor
def dispatch(command, given_args, given_opts, config) #:nodoc:
raise NotImplementedError
end
+
+ # Register a relation of options for target(method_option/class_option)
+ # by args and block.
+ def register_options_relation_for(target, relation, *args, &block) # :nodoc:
+ opt = args.pop if args.last.is_a? Hash
+ opt ||= {}
+ names = args.map{ |arg| arg.to_s }
+ names += built_option_names(target, opt, &block) if block_given?
+ command_scope_member(relation, opt) << names
+ end
+
+ # Get target(method_options or class_options) options
+ # of before and after by block evaluation.
+ def built_option_names(target, opt = {}, &block) # :nodoc:
+ before = command_scope_member(target, opt).map{ |k,v| v.name }
+ instance_eval(&block)
+ after = command_scope_member(target, opt).map{ |k,v| v.name }
+ after - before
+ end
+
+ # Get command scope member by name.
+ def command_scope_member(name, options = {}) # :nodoc:
+ if options[:for]
+ find_and_refresh_command(options[:for]).send(name)
+ else
+ send(name)
+ end
+ end
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb
index 040c971c0c..68c8fffedb 100644
--- a/lib/bundler/vendor/thor/lib/thor/command.rb
+++ b/lib/bundler/vendor/thor/lib/thor/command.rb
@@ -1,14 +1,15 @@
class Bundler::Thor
- class Command < Struct.new(:name, :description, :long_description, :usage, :options, :ancestor_name)
+ class Command < Struct.new(:name, :description, :long_description, :wrap_long_description, :usage, :options, :options_relation, :ancestor_name)
FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
- def initialize(name, description, long_description, usage, options = nil)
- super(name.to_s, description, long_description, usage, options || {})
+ def initialize(name, description, long_description, wrap_long_description, usage, options = nil, options_relation = nil)
+ super(name.to_s, description, long_description, wrap_long_description, usage, options || {}, options_relation || {})
end
def initialize_copy(other) #:nodoc:
super(other)
self.options = other.options.dup if other.options
+ self.options_relation = other.options_relation.dup if other.options_relation
end
def hidden?
@@ -62,6 +63,14 @@ class Bundler::Thor
end.join("\n")
end
+ def method_exclusive_option_names #:nodoc:
+ self.options_relation[:exclusive_option_names] || []
+ end
+
+ def method_at_least_one_option_names #:nodoc:
+ self.options_relation[:at_least_one_option_names] || []
+ end
+
protected
# Add usage with required arguments
@@ -127,7 +136,7 @@ class Bundler::Thor
# A dynamic command that handles method missing scenarios.
class DynamicCommand < Command
def initialize(name, options = nil)
- super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
+ super(name.to_s, "A dynamically-generated command", name.to_s, nil, name.to_s, options)
end
def run(instance, args = [])
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
index 3c4483e5dd..b16a98f782 100644
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
@@ -38,6 +38,10 @@ class Bundler::Thor
super(convert_key(key), *args)
end
+ def slice(*keys)
+ super(*keys.map{ |key| convert_key(key) })
+ end
+
def key?(key)
super(convert_key(key))
end
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index 03f2ce85bb..928646e501 100644
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
@@ -1,18 +1,15 @@
class Bundler::Thor
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- end
+ Module.new do
+ def to_s
+ super + DidYouMean.formatter.message_for(corrections)
+ end
+
+ def corrections
+ @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
+ end
+ end
+ end
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
# errors have their backtrace suppressed and are nicely shown to the user.
@@ -37,7 +34,7 @@ class Bundler::Thor
end
def spell_checker
- NoKwargSpellChecker.new(error.all_commands)
+ DidYouMean::SpellChecker.new(dictionary: error.all_commands)
end
end
@@ -79,7 +76,7 @@ class Bundler::Thor
end
def spell_checker
- @spell_checker ||= NoKwargSpellChecker.new(error.switches)
+ @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)
end
end
@@ -101,15 +98,9 @@ class Bundler::Thor
class MalformattedArgumentError < InvocationError
end
- if Correctable
- if DidYouMean.respond_to?(:correct_error)
- DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
- DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
- else
- DidYouMean::SPELL_CHECKERS.merge!(
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
- )
- end
+ class ExclusiveArgumentError < InvocationError
+ end
+
+ class AtLeastOneRequiredArgumentError < InvocationError
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/group.rb b/lib/bundler/vendor/thor/lib/thor/group.rb
index 7861d05345..30bc311294 100644
--- a/lib/bundler/vendor/thor/lib/thor/group.rb
+++ b/lib/bundler/vendor/thor/lib/thor/group.rb
@@ -169,7 +169,7 @@ class Bundler::Thor::Group
# options are added to group_options hash. Options that already exists
# in base_options are not added twice.
#
- def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
+ def get_options_from_invocations(group_options, base_options) #:nodoc:
invocations.each do |name, from_option|
value = if from_option
option = class_options[name]
@@ -211,6 +211,17 @@ class Bundler::Thor::Group
raise error, msg
end
+ # Checks if a specified command exists.
+ #
+ # ==== Parameters
+ # command_name<String>:: The name of the command to check for existence.
+ #
+ # ==== Returns
+ # Boolean:: +true+ if the command exists, +false+ otherwise.
+ def command_exists?(command_name) #:nodoc:
+ commands.keys.include?(command_name)
+ end
+
protected
# The method responsible for dispatching given the args.
diff --git a/lib/bundler/vendor/thor/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb
index 248a466f8e..5ce74710ba 100644
--- a/lib/bundler/vendor/thor/lib/thor/invocation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/invocation.rb
@@ -143,7 +143,7 @@ class Bundler::Thor
# Configuration values that are shared between invocations.
def _shared_configuration #:nodoc:
- {:invocations => @_invocations}
+ {invocations: @_invocations}
end
# This method simply retrieves the class and command to be invoked.
diff --git a/lib/bundler/vendor/thor/lib/thor/nested_context.rb b/lib/bundler/vendor/thor/lib/thor/nested_context.rb
index fd36b9d43f..7d60cb1c12 100644
--- a/lib/bundler/vendor/thor/lib/thor/nested_context.rb
+++ b/lib/bundler/vendor/thor/lib/thor/nested_context.rb
@@ -13,10 +13,10 @@ class Bundler::Thor
end
def entered?
- @depth > 0
+ @depth.positive?
end
- private
+ private
def push
@depth += 1
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
index dfe7398583..ee9db4ad8a 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
@@ -24,6 +24,14 @@ class Bundler::Thor
validate! # Trigger specific validations
end
+ def print_default
+ if @type == :array and @default.is_a?(Array)
+ @default.map(&:dump).join(" ")
+ else
+ @default
+ end
+ end
+
def usage
required? ? banner : "[#{banner}]"
end
@@ -41,11 +49,19 @@ class Bundler::Thor
end
end
+ def enum_to_s
+ if enum.respond_to? :join
+ enum.join(", ")
+ else
+ "#{enum.first}..#{enum.last}"
+ end
+ end
+
protected
def validate!
raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
- raise ArgumentError, "An argument cannot have an enum other than an array." if @enum && !@enum.is_a?(Array)
+ raise ArgumentError, "An argument cannot have an enum other than an enumerable." if @enum && !@enum.is_a?(Enumerable)
end
def valid_type?(type)
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
index 3a5d82cf29..b6f9c9a37a 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
@@ -1,5 +1,5 @@
class Bundler::Thor
- class Arguments #:nodoc: # rubocop:disable ClassLength
+ class Arguments #:nodoc:
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
# Receives an array of args and returns two arrays, one with arguments
@@ -30,11 +30,7 @@ class Bundler::Thor
arguments.each do |argument|
if !argument.default.nil?
- begin
- @assigns[argument.human_name] = argument.default.dup
- rescue TypeError # Compatibility shim for un-dup-able Fixnum in Ruby < 2.4
- @assigns[argument.human_name] = argument.default
- end
+ @assigns[argument.human_name] = argument.default.dup
elsif argument.required?
@non_assigned_required << argument
end
@@ -121,8 +117,18 @@ class Bundler::Thor
#
def parse_array(name)
return shift if peek.is_a?(Array)
+
array = []
- array << shift while current_is_value?
+
+ while current_is_value?
+ value = shift
+
+ if !value.empty?
+ validate_enum_value!(name, value, "Expected all values of '%s' to be one of %s; got %s")
+ end
+
+ array << value
+ end
array
end
@@ -138,11 +144,9 @@ class Bundler::Thor
end
value = $&.index(".") ? shift.to_f : shift.to_i
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
+
+ validate_enum_value!(name, value, "Expected '%s' to be one of %s; got %s")
+
value
end
@@ -156,15 +160,27 @@ class Bundler::Thor
nil
else
value = shift
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
+
+ validate_enum_value!(name, value, "Expected '%s' to be one of %s; got %s")
+
value
end
end
+ # Raises an error if the switch is an enum and the values aren't included on it.
+ #
+ def validate_enum_value!(name, value, message)
+ return unless @switches.is_a?(Hash)
+
+ switch = @switches[name]
+
+ return unless switch
+
+ if switch.enum && !switch.enum.include?(value)
+ raise MalformattedArgumentError, message % [name, switch.enum_to_s, value]
+ end
+ end
+
# Raises an error if @non_assigned_required array is not empty.
#
def check_requirement!
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
index 5a5af6f888..72617c7e34 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
@@ -11,7 +11,7 @@ class Bundler::Thor
super
@lazy_default = options[:lazy_default]
@group = options[:group].to_s.capitalize if options[:group]
- @aliases = Array(options[:aliases])
+ @aliases = normalize_aliases(options[:aliases])
@hide = options[:hide]
end
@@ -58,7 +58,7 @@ class Bundler::Thor
default = nil
if VALID_TYPES.include?(value)
value
- elsif required = (value == :required) # rubocop:disable AssignmentInCondition
+ elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
:string
end
when TrueClass, FalseClass
@@ -69,7 +69,7 @@ class Bundler::Thor
value.class.name.downcase.to_sym
end
- new(name.to_s, :required => required, :type => type, :default => default, :aliases => aliases)
+ new(name.to_s, required: required, type: type, default: default, aliases: aliases)
end
def switch_name
@@ -89,14 +89,27 @@ class Bundler::Thor
sample = "[#{sample}]".dup unless required?
- if boolean?
- sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
+ if boolean? && name != "force" && !name.match(/\A(no|skip)[\-_]/)
+ sample << ", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]"
end
+ aliases_for_usage.ljust(padding) + sample
+ end
+
+ def aliases_for_usage
if aliases.empty?
- (" " * padding) << sample
+ ""
+ else
+ "#{aliases.join(', ')}, "
+ end
+ end
+
+ def show_default?
+ case default
+ when TrueClass, FalseClass
+ true
else
- "#{aliases.join(', ')}, #{sample}"
+ super
end
end
@@ -138,8 +151,8 @@ class Bundler::Thor
raise ArgumentError, err
elsif @check_default_type == nil
Bundler::Thor.deprecation_warning "#{err}.\n" +
- 'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
- ' or call `allow_incompatible_default_type!` in your code'
+ "This will be rejected in the future unless you explicitly pass the options `check_default_type: false`" +
+ " or call `allow_incompatible_default_type!` in your code"
end
end
end
@@ -155,5 +168,11 @@ class Bundler::Thor
def dasherize(str)
(str.length > 1 ? "--" : "-") + str.tr("_", "-")
end
+
+ private
+
+ def normalize_aliases(aliases)
+ Array(aliases).map { |short| short.to_s.sub(/^(?!\-)/, "-") }
+ end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
index 5bd97aba6f..fe22d989e5 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
@@ -1,5 +1,5 @@
class Bundler::Thor
- class Options < Arguments #:nodoc: # rubocop:disable ClassLength
+ class Options < Arguments #:nodoc:
LONG_RE = /^(--\w+(?:-\w+)*)$/
SHORT_RE = /^(-[a-z])$/i
EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
@@ -29,8 +29,10 @@ class Bundler::Thor
#
# If +stop_on_unknown+ is true, #parse will stop as soon as it encounters
# an unknown option or a regular argument.
- def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false)
+ def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {})
@stop_on_unknown = stop_on_unknown
+ @exclusives = (relations[:exclusive_option_names] || []).select{|array| !array.empty?}
+ @at_least_ones = (relations[:at_least_one_option_names] || []).select{|array| !array.empty?}
@disable_required_check = disable_required_check
options = hash_options.values
super(options)
@@ -50,8 +52,7 @@ class Bundler::Thor
options.each do |option|
@switches[option.switch_name] = option
- option.aliases.each do |short|
- name = short.to_s.sub(/^(?!\-)/, "-")
+ option.aliases.each do |name|
@shorts[name] ||= option.switch_name
end
end
@@ -85,7 +86,7 @@ class Bundler::Thor
super(arg)
end
- def parse(args) # rubocop:disable MethodLength
+ def parse(args) # rubocop:disable Metrics/MethodLength
@pile = args.dup
@is_treated_as_value = false
@parsing_options = true
@@ -132,12 +133,38 @@ class Bundler::Thor
end
check_requirement! unless @disable_required_check
+ check_exclusive!
+ check_at_least_one!
assigns = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new(@assigns)
assigns.freeze
assigns
end
+ def check_exclusive!
+ opts = @assigns.keys
+ # When option A and B are exclusive, if A and B are given at the same time,
+ # the difference of argument array size will decrease.
+ found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }
+ if found
+ names = names_to_switch_names(found & opts).map{|n| "'#{n}'"}
+ class_name = self.class.name.split("::").last.downcase
+ fail ExclusiveArgumentError, "Found exclusive #{class_name} #{names.join(", ")}"
+ end
+ end
+
+ def check_at_least_one!
+ opts = @assigns.keys
+ # When at least one is required of the options A and B,
+ # if the both options were not given, none? would be true.
+ found = @at_least_ones.find{ |one_reqs| one_reqs.none?{ |o| opts.include? o} }
+ if found
+ names = names_to_switch_names(found).map{|n| "'#{n}'"}
+ class_name = self.class.name.split("::").last.downcase
+ fail AtLeastOneRequiredArgumentError, "Not found at least one of required #{class_name} #{names.join(", ")}"
+ end
+ end
+
def check_unknown!
to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra
@@ -148,6 +175,17 @@ class Bundler::Thor
protected
+ # Option names changes to swith name or human name
+ def names_to_switch_names(names = [])
+ @switches.map do |_, o|
+ if names.include? o.name
+ o.respond_to?(:switch_name) ? o.switch_name : o.human_name
+ else
+ nil
+ end
+ end.compact
+ end
+
def assign_result!(option, result)
if option.repeatable && option.type == :hash
(@assigns[option.human_name] ||= {}).merge!(result)
@@ -194,7 +232,7 @@ class Bundler::Thor
end
def switch_option(arg)
- if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition
+ if match = no_or_skip?(arg) # rubocop:disable Lint/AssignmentInCondition
@switches[arg] || @switches["--#{match}"]
else
@switches[arg]
@@ -212,7 +250,8 @@ class Bundler::Thor
@parsing_options
end
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
+ # Parse boolean values which can be given as --foo=true or --foo for true values, or
+ # --foo=false, --no-foo or --skip-foo for false values.
#
def parse_boolean(switch)
if current_is_value?
diff --git a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
index f8f86372cc..c6a4653fc1 100644
--- a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
+++ b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
@@ -41,7 +41,7 @@ instance_eval do
def task(*)
task = super
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
+ if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
non_namespaced_name = task.name.split(":").last
description = non_namespaced_name
@@ -59,7 +59,7 @@ instance_eval do
end
def namespace(name)
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
+ if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
const_name = Bundler::Thor::Util.camel_case(name.to_s).to_sym
klass.const_set(const_name, Class.new(Bundler::Thor))
new_klass = klass.const_get(const_name)
diff --git a/lib/bundler/vendor/thor/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
index 54c5525093..f0ce6df96c 100644
--- a/lib/bundler/vendor/thor/lib/thor/runner.rb
+++ b/lib/bundler/vendor/thor/lib/thor/runner.rb
@@ -1,13 +1,10 @@
require_relative "../thor"
require_relative "group"
-require "yaml"
-require "digest/md5"
-require "pathname"
-
-class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
- autoload :OpenURI, "open-uri"
+require "digest/sha2"
+require "pathname" unless defined?(Pathname)
+class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
def self.banner(command, all = false, subcommand = false)
@@ -25,7 +22,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
initialize_thorfiles(meth)
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
self.class.handle_no_command_error(command, false) if klass.nil?
- klass.start(["-h", command].compact, :shell => shell)
+ klass.start(["-h", command].compact, shell: shell)
else
super
end
@@ -40,30 +37,42 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
self.class.handle_no_command_error(command, false) if klass.nil?
args.unshift(command) if command
- klass.start(args, :shell => shell)
+ klass.start(args, shell: shell)
end
desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
- method_options :as => :string, :relative => :boolean, :force => :boolean
- def install(name) # rubocop:disable MethodLength
+ method_options as: :string, relative: :boolean, force: :boolean
+ def install(name) # rubocop:disable Metrics/MethodLength
initialize_thorfiles
- # If a directory name is provided as the argument, look for a 'main.thor'
- # command in said directory.
- begin
- if File.directory?(File.expand_path(name))
- base = File.join(name, "main.thor")
- package = :directory
- contents = open(base, &:read)
- else
- base = name
- package = :file
- contents = open(name, &:read)
+ is_uri = name =~ %r{^https?\://}
+
+ if is_uri
+ base = name
+ package = :file
+ require "open-uri"
+ begin
+ contents = URI.open(name, &:read)
+ rescue OpenURI::HTTPError
+ raise Error, "Error opening URI '#{name}'"
+ end
+ else
+ # If a directory name is provided as the argument, look for a 'main.thor'
+ # command in said directory.
+ begin
+ if File.directory?(File.expand_path(name))
+ base = File.join(name, "main.thor")
+ package = :directory
+ contents = File.open(base, &:read)
+ else
+ base = name
+ package = :file
+ require "open-uri"
+ contents = URI.open(name, &:read)
+ end
+ rescue Errno::ENOENT
+ raise Error, "Error opening file '#{name}'"
end
- rescue OpenURI::HTTPError
- raise Error, "Error opening URI '#{name}'"
- rescue Errno::ENOENT
- raise Error, "Error opening file '#{name}'"
end
say "Your Thorfile contains:"
@@ -84,16 +93,16 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
as = basename if as.empty?
end
- location = if options[:relative] || name =~ %r{^https?://}
+ location = if options[:relative] || is_uri
name
else
File.expand_path(name)
end
thor_yaml[as] = {
- :filename => Digest::MD5.hexdigest(name + as),
- :location => location,
- :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
+ filename: Digest::SHA256.hexdigest(name + as),
+ location: location,
+ namespaces: Bundler::Thor::Util.namespaces_in_content(contents, base)
}
save_yaml(thor_yaml)
@@ -154,14 +163,14 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
end
desc "installed", "List the installed Bundler::Thor modules and commands"
- method_options :internal => :boolean
+ method_options internal: :boolean
def installed
initialize_thorfiles(nil, true)
display_klasses(true, options["internal"])
end
desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
- method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
+ method_options substring: :boolean, group: :string, all: :boolean, debug: :boolean
def list(search = "")
initialize_thorfiles
@@ -185,6 +194,7 @@ private
def thor_yaml
@thor_yaml ||= begin
yaml_file = File.join(thor_root, "thor.yml")
+ require "yaml"
yaml = YAML.load_file(yaml_file) if File.exist?(yaml_file)
yaml || {}
end
@@ -303,7 +313,7 @@ private
say shell.set_color(namespace, :blue, true)
say "-" * namespace.size
- print_table(list, :truncate => true)
+ print_table(list, truncate: true)
say
end
alias_method :display_tasks, :display_commands
diff --git a/lib/bundler/vendor/thor/lib/thor/shell.rb b/lib/bundler/vendor/thor/lib/thor/shell.rb
index a4137d1bde..265f3ba046 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell.rb
@@ -75,7 +75,7 @@ class Bundler::Thor
# Allow shell to be shared between invocations.
#
def _shared_configuration #:nodoc:
- super.merge!(:shell => shell)
+ super.merge!(shell: shell)
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
index ef97d52ae7..da02b94227 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
@@ -1,8 +1,10 @@
+require_relative "column_printer"
+require_relative "table_printer"
+require_relative "wrapped_printer"
+
class Bundler::Thor
module Shell
class Basic
- DEFAULT_TERMINAL_WIDTH = 80
-
attr_accessor :base
attr_reader :padding
@@ -65,15 +67,15 @@ class Bundler::Thor
# Readline.
#
# ==== Example
- # ask("What is your name?")
+ # ask("What is your name?")
#
- # ask("What is the planet furthest from the sun?", :default => "Pluto")
+ # ask("What is the planet furthest from the sun?", :default => "Neptune")
#
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
#
- # ask("What is your password?", :echo => false)
+ # ask("What is your password?", :echo => false)
#
- # ask("Where should the file be saved?", :path => true)
+ # ask("Where should the file be saved?", :path => true)
#
def ask(statement, *args)
options = args.last.is_a?(Hash) ? args.pop : {}
@@ -91,7 +93,7 @@ class Bundler::Thor
# are passed straight to puts (behavior got from Highline).
#
# ==== Example
- # say("I know you knew that.")
+ # say("I know you knew that.")
#
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
return if quiet?
@@ -108,7 +110,7 @@ class Bundler::Thor
# are passed straight to puts (behavior got from Highline).
#
# ==== Example
- # say_error("error: something went wrong")
+ # say_error("error: something went wrong")
#
def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
return if quiet?
@@ -141,18 +143,18 @@ class Bundler::Thor
stdout.flush
end
- # Make a question the to user and returns true if the user replies "y" or
+ # Asks the user a question and returns true if the user replies "y" or
# "yes".
#
def yes?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:yes))
+ !!(ask(statement, color, add_to_history: false) =~ is?(:yes))
end
- # Make a question the to user and returns true if the user replies "n" or
+ # Asks the user a question and returns true if the user replies "n" or
# "no".
#
def no?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:no))
+ !!(ask(statement, color, add_to_history: false) =~ is?(:no))
end
# Prints values in columns
@@ -161,16 +163,8 @@ class Bundler::Thor
# Array[String, String, ...]
#
def print_in_columns(array)
- return if array.empty?
- colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
- array.each_with_index do |value, index|
- # Don't output trailing spaces when printing the last column
- if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
- stdout.puts value
- else
- stdout.printf("%-#{colwidth}s", value)
- end
- end
+ printer = ColumnPrinter.new(stdout)
+ printer.print(array)
end
# Prints a table.
@@ -181,58 +175,11 @@ class Bundler::Thor
# ==== Options
# indent<Integer>:: Indent the first column by indent value.
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
+ # borders<Boolean>:: Adds ascii borders.
#
- def print_table(array, options = {}) # rubocop:disable MethodLength
- return if array.empty?
-
- formats = []
- indent = options[:indent].to_i
- colwidth = options[:colwidth]
- options[:truncate] = terminal_width if options[:truncate] == true
-
- formats << "%-#{colwidth + 2}s".dup if colwidth
- start = colwidth ? 1 : 0
-
- colcount = array.max { |a, b| a.size <=> b.size }.size
-
- maximas = []
-
- start.upto(colcount - 1) do |index|
- maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
- maximas << maxima
- formats << if index == colcount - 1
- # Don't output 2 trailing spaces when printing the last column
- "%-s".dup
- else
- "%-#{maxima + 2}s".dup
- end
- end
-
- formats[0] = formats[0].insert(0, " " * indent)
- formats << "%s"
-
- array.each do |row|
- sentence = "".dup
-
- row.each_with_index do |column, index|
- maxima = maximas[index]
-
- f = if column.is_a?(Numeric)
- if index == row.size - 1
- # Don't output 2 trailing spaces when printing the last column
- "%#{maxima}s"
- else
- "%#{maxima}s "
- end
- else
- formats[index]
- end
- sentence << f % column.to_s
- end
-
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
- stdout.puts sentence
- end
+ def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
+ printer = TablePrinter.new(stdout, options)
+ printer.print(array)
end
# Prints a long string, word-wrapping the text to the current width of the
@@ -245,33 +192,8 @@ class Bundler::Thor
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
#
def print_wrapped(message, options = {})
- indent = options[:indent] || 0
- width = terminal_width - indent
- paras = message.split("\n\n")
-
- paras.map! do |unwrapped|
- words = unwrapped.split(" ")
- counter = words.first.length
- words.inject do |memo, word|
- word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
- counter = 0 if word.include? "\n"
- if (counter + word.length + 1) < width
- memo = "#{memo} #{word}"
- counter += (word.length + 1)
- else
- memo = "#{memo}\n#{word}"
- counter = word.length
- end
- memo
- end
- end.compact!
-
- paras.each do |para|
- para.split("\n").each do |line|
- stdout.puts line.insert(0, " " * indent)
- end
- stdout.puts unless para == paras.last
- end
+ printer = WrappedPrinter.new(stdout, options)
+ printer.print(message)
end
# Deals with file collision and returns true if the file should be
@@ -289,7 +211,7 @@ class Bundler::Thor
loop do
answer = ask(
%[Overwrite #{destination}? (enter "h" for help) #{options}],
- :add_to_history => false
+ add_to_history: false
)
case answer
@@ -316,24 +238,11 @@ class Bundler::Thor
say "Please specify merge tool to `THOR_MERGE` env."
else
- say file_collision_help
+ say file_collision_help(block_given?)
end
end
end
- # This code was copied from Rake, available under MIT-LICENSE
- # Copyright (c) 2003, 2004 Jim Weirich
- def terminal_width
- result = if ENV["THOR_COLUMNS"]
- ENV["THOR_COLUMNS"].to_i
- else
- unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
- end
- result < 10 ? DEFAULT_TERMINAL_WIDTH : result
- rescue
- DEFAULT_TERMINAL_WIDTH
- end
-
# Called if something goes wrong during the execution. This is used by Bundler::Thor
# internally and should not be used inside your scripts. If something went
# wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
@@ -384,23 +293,28 @@ class Bundler::Thor
end
end
- def file_collision_help #:nodoc:
- <<-HELP
+ def file_collision_help(block_given) #:nodoc:
+ help = <<-HELP
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
- d - diff, show the differences between the old and the new
h - help, show this help
- m - merge, run merge tool
HELP
+ if block_given
+ help << <<-HELP
+ d - diff, show the differences between the old and the new
+ m - merge, run merge tool
+ HELP
+ end
+ help
end
def show_diff(destination, content) #:nodoc:
diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
require "tempfile"
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
+ Tempfile.open(File.basename(destination), File.dirname(destination), binmode: true) do |temp|
temp.write content
temp.rewind
system %(#{diff_cmd} "#{destination}" "#{temp.path}")
@@ -411,46 +325,8 @@ class Bundler::Thor
mute? || (base && base.options[:quiet])
end
- # Calculate the dynamic width of the terminal
- def dynamic_width
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
- end
-
- def dynamic_width_stty
- `stty size 2>/dev/null`.split[1].to_i
- end
-
- def dynamic_width_tput
- `tput cols 2>/dev/null`.to_i
- end
-
def unix?
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
- end
-
- def truncate(string, width)
- as_unicode do
- chars = string.chars.to_a
- if chars.length <= width
- chars.join
- else
- chars[0, width - 3].join + "..."
- end
- end
- end
-
- if "".respond_to?(:encode)
- def as_unicode
- yield
- end
- else
- def as_unicode
- old = $KCODE
- $KCODE = "U"
- yield
- ensure
- $KCODE = old
- end
+ Terminal.unix?
end
def ask_simply(statement, color, options)
@@ -496,16 +372,12 @@ class Bundler::Thor
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
temp.write content
temp.rewind
- system %(#{merge_tool} "#{temp.path}" "#{destination}")
+ system(merge_tool, temp.path, destination)
end
end
def merge_tool #:nodoc:
- @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
- end
-
- def git_merge_tool #:nodoc:
- `git config merge.tool`.rstrip rescue ""
+ @merge_tool ||= ENV["THOR_MERGE"] || "git difftool --no-index"
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/color.rb b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
index dc167ed3cc..5d708fadca 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/color.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
@@ -105,52 +105,7 @@ class Bundler::Thor
end
def are_colors_disabled?
- !ENV['NO_COLOR'].nil?
- end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
+ !ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty?
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb
new file mode 100644
index 0000000000..56a9e6181b
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb
@@ -0,0 +1,29 @@
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class ColumnPrinter
+ attr_reader :stdout, :options
+
+ def initialize(stdout, options = {})
+ @stdout = stdout
+ @options = options
+ @indent = options[:indent].to_i
+ end
+
+ def print(array)
+ return if array.empty?
+ colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
+ array.each_with_index do |value, index|
+ # Don't output trailing spaces when printing the last column
+ if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
+ stdout.puts value
+ else
+ stdout.printf("%-#{colwidth}s", value)
+ end
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/html.rb b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
index 77a6d13a23..a0a8520e5c 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/html.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
@@ -64,7 +64,7 @@ class Bundler::Thor
# Ask something to the user and receives a response.
#
# ==== Example
- # ask("What is your name?")
+ # ask("What is your name?")
#
# TODO: Implement #ask for Bundler::Thor::Shell::HTML
def ask(statement, color = nil)
@@ -76,51 +76,6 @@ class Bundler::Thor
def can_display_colors?
true
end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
- end
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb
new file mode 100644
index 0000000000..dee3614753
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb
@@ -0,0 +1,118 @@
+require_relative "column_printer"
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class TablePrinter < ColumnPrinter
+ BORDER_SEPARATOR = :separator
+
+ def initialize(stdout, options = {})
+ super
+ @formats = []
+ @maximas = []
+ @colwidth = options[:colwidth]
+ @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]
+ @padding = 1
+ end
+
+ def print(array)
+ return if array.empty?
+
+ prepare(array)
+
+ print_border_separator if options[:borders]
+
+ array.each do |row|
+ if options[:borders] && row == BORDER_SEPARATOR
+ print_border_separator
+ next
+ end
+
+ sentence = "".dup
+
+ row.each_with_index do |column, index|
+ sentence << format_cell(column, row.size, index)
+ end
+
+ sentence = truncate(sentence)
+ sentence << "|" if options[:borders]
+ stdout.puts indentation + sentence
+
+ end
+ print_border_separator if options[:borders]
+ end
+
+ private
+
+ def prepare(array)
+ array = array.reject{|row| row == BORDER_SEPARATOR }
+
+ @formats << "%-#{@colwidth + 2}s".dup if @colwidth
+ start = @colwidth ? 1 : 0
+
+ colcount = array.max { |a, b| a.size <=> b.size }.size
+
+ start.upto(colcount - 1) do |index|
+ maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
+
+ @maximas << maxima
+ @formats << if options[:borders]
+ "%-#{maxima}s".dup
+ elsif index == colcount - 1
+ # Don't output 2 trailing spaces when printing the last column
+ "%-s".dup
+ else
+ "%-#{maxima + 2}s".dup
+ end
+ end
+
+ @formats << "%s"
+ end
+
+ def format_cell(column, row_size, index)
+ maxima = @maximas[index]
+
+ f = if column.is_a?(Numeric)
+ if options[:borders]
+ # With borders we handle padding separately
+ "%#{maxima}s"
+ elsif index == row_size - 1
+ # Don't output 2 trailing spaces when printing the last column
+ "%#{maxima}s"
+ else
+ "%#{maxima}s "
+ end
+ else
+ @formats[index]
+ end
+
+ cell = "".dup
+ cell << "|" + " " * @padding if options[:borders]
+ cell << f % column.to_s
+ cell << " " * @padding if options[:borders]
+ cell
+ end
+
+ def print_border_separator
+ separator = @maximas.map do |maxima|
+ "+" + "-" * (maxima + 2 * @padding)
+ end
+ stdout.puts indentation + separator.join + "+"
+ end
+
+ def truncate(string)
+ return string unless @truncate
+ chars = string.chars.to_a
+ if chars.length <= @truncate
+ chars.join
+ else
+ chars[0, @truncate - 3 - @indent].join + "..."
+ end
+ end
+
+ def indentation
+ " " * @indent
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb b/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
new file mode 100644
index 0000000000..2c60684308
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
@@ -0,0 +1,42 @@
+class Bundler::Thor
+ module Shell
+ module Terminal
+ DEFAULT_TERMINAL_WIDTH = 80
+
+ class << self
+ # This code was copied from Rake, available under MIT-LICENSE
+ # Copyright (c) 2003, 2004 Jim Weirich
+ def terminal_width
+ result = if ENV["THOR_COLUMNS"]
+ ENV["THOR_COLUMNS"].to_i
+ else
+ unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
+ end
+ result < 10 ? DEFAULT_TERMINAL_WIDTH : result
+ rescue
+ DEFAULT_TERMINAL_WIDTH
+ end
+
+ def unix?
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
+ end
+
+ private
+
+ # Calculate the dynamic width of the terminal
+ def dynamic_width
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
+ end
+
+ def dynamic_width_stty
+ `stty size 2>/dev/null`.split[1].to_i
+ end
+
+ def dynamic_width_tput
+ `tput cols 2>/dev/null`.to_i
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb
new file mode 100644
index 0000000000..ba88e952db
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb
@@ -0,0 +1,38 @@
+require_relative "column_printer"
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class WrappedPrinter < ColumnPrinter
+ def print(message)
+ width = Terminal.terminal_width - @indent
+ paras = message.split("\n\n")
+
+ paras.map! do |unwrapped|
+ words = unwrapped.split(" ")
+ counter = words.first.length
+ words.inject do |memo, word|
+ word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
+ counter = 0 if word.include? "\n"
+ if (counter + word.length + 1) < width
+ memo = "#{memo} #{word}"
+ counter += (word.length + 1)
+ else
+ memo = "#{memo}\n#{word}"
+ counter = word.length
+ end
+ memo
+ end
+ end.compact!
+
+ paras.each do |para|
+ para.split("\n").each do |line|
+ stdout.puts line.insert(0, " " * @indent)
+ end
+ stdout.puts unless para == paras.last
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/bundler/vendor/thor/lib/thor/util.rb b/lib/bundler/vendor/thor/lib/thor/util.rb
index d2572a4249..cd8f9ece87 100644
--- a/lib/bundler/vendor/thor/lib/thor/util.rb
+++ b/lib/bundler/vendor/thor/lib/thor/util.rb
@@ -90,7 +90,7 @@ class Bundler::Thor
def snake_case(str)
return str.downcase if str =~ /^[A-Z_]+$/
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
- $+.downcase
+ Regexp.last_match(-1).downcase
end
# Receives a string and convert it to camel case. camel_case returns CamelCase.
@@ -130,9 +130,10 @@ class Bundler::Thor
#
def find_class_and_command_by_namespace(namespace, fallback = true)
if namespace.include?(":") # look for a namespaced command
- pieces = namespace.split(":")
- command = pieces.pop
- klass = Bundler::Thor::Util.find_by_namespace(pieces.join(":"))
+ *pieces, command = namespace.split(":")
+ namespace = pieces.join(":")
+ namespace = "default" if namespace.empty?
+ klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.command_exists?(command) }
end
unless klass # look for a Bundler::Thor::Group with the right name
klass = Bundler::Thor::Util.find_by_namespace(namespace)
@@ -150,7 +151,7 @@ class Bundler::Thor
# inside the sandbox to avoid namespacing conflicts.
#
def load_thorfile(path, content = nil, debug = false)
- content ||= File.binread(path)
+ content ||= File.read(path)
begin
Bundler::Thor::Sandbox.class_eval(content, path)
@@ -189,7 +190,7 @@ class Bundler::Thor
# Returns the root where thor files are located, depending on the OS.
#
def thor_root
- File.join(user_home, ".thor").tr('\\', "/")
+ File.join(user_home, ".thor").tr("\\", "/")
end
# Returns the files in the thor root. On Windows thor_root will be something
@@ -236,7 +237,7 @@ class Bundler::Thor
# symlink points to 'ruby_install_name'
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
end
- rescue NotImplementedError # rubocop:disable HandleExceptions
+ rescue NotImplementedError # rubocop:disable Lint/HandleExceptions
# just ignore on windows
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/version.rb b/lib/bundler/vendor/thor/lib/thor/version.rb
index 48a4788b3b..5474a2f71b 100644
--- a/lib/bundler/vendor/thor/lib/thor/version.rb
+++ b/lib/bundler/vendor/thor/lib/thor/version.rb
@@ -1,3 +1,3 @@
class Bundler::Thor
- VERSION = "1.2.1"
+ VERSION = "1.4.0"
end
diff --git a/lib/bundler/vendor/tsort/lib/tsort.rb b/lib/bundler/vendor/tsort/lib/tsort.rb
index 4a0e1a4e25..cf8731f760 100644
--- a/lib/bundler/vendor/tsort/lib/tsort.rb
+++ b/lib/bundler/vendor/tsort/lib/tsort.rb
@@ -122,6 +122,9 @@
#
module Bundler::TSort
+
+ VERSION = "0.2.0"
+
class Cyclic < StandardError
end
diff --git a/lib/bundler/vendor/uri/lib/uri.rb b/lib/bundler/vendor/uri/lib/uri.rb
index 976320f6bd..57b380c480 100644
--- a/lib/bundler/vendor/uri/lib/uri.rb
+++ b/lib/bundler/vendor/uri/lib/uri.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
# Bundler::URI is a module providing classes to handle Uniform Resource Identifiers
-# (RFC2396[http://tools.ietf.org/html/rfc2396]).
+# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
#
# == Features
#
@@ -47,14 +47,14 @@
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
#
# Here is a list of all related RFC's:
-# - RFC822[http://tools.ietf.org/html/rfc822]
-# - RFC1738[http://tools.ietf.org/html/rfc1738]
-# - RFC2255[http://tools.ietf.org/html/rfc2255]
-# - RFC2368[http://tools.ietf.org/html/rfc2368]
-# - RFC2373[http://tools.ietf.org/html/rfc2373]
-# - RFC2396[http://tools.ietf.org/html/rfc2396]
-# - RFC2732[http://tools.ietf.org/html/rfc2732]
-# - RFC3986[http://tools.ietf.org/html/rfc3986]
+# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
+# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
+# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
+# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
+# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
+# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
+# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
+# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
#
# == Class tree
#
diff --git a/lib/bundler/vendor/uri/lib/uri/common.rb b/lib/bundler/vendor/uri/lib/uri/common.rb
index 914a4c7581..38339119c5 100644
--- a/lib/bundler/vendor/uri/lib/uri/common.rb
+++ b/lib/bundler/vendor/uri/lib/uri/common.rb
@@ -13,24 +13,54 @@ require_relative "rfc2396_parser"
require_relative "rfc3986_parser"
module Bundler::URI
- include RFC2396_REGEXP
+ # The default parser instance for RFC 2396.
+ RFC2396_PARSER = RFC2396_Parser.new
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
- REGEXP = RFC2396_REGEXP
- Parser = RFC2396_Parser
+ # The default parser instance for RFC 3986.
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
- # Bundler::URI::Parser.new
- DEFAULT_PARSER = Parser.new
- DEFAULT_PARSER.pattern.each_pair do |sym, str|
- unless REGEXP::PATTERN.const_defined?(sym)
- REGEXP::PATTERN.const_set(sym, str)
+ # The default parser instance.
+ DEFAULT_PARSER = RFC3986_PARSER
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
+
+ # Set the default parser instance.
+ def self.parser=(parser = RFC3986_PARSER)
+ remove_const(:Parser) if defined?(::Bundler::URI::Parser)
+ const_set("Parser", parser.class)
+
+ remove_const(:PARSER) if defined?(::Bundler::URI::PARSER)
+ const_set("PARSER", parser)
+
+ remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
+ remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
+ if Parser == RFC2396_Parser
+ const_set("REGEXP", Bundler::URI::RFC2396_REGEXP)
+ const_set("PATTERN", Bundler::URI::RFC2396_REGEXP::PATTERN)
+ end
+
+ Parser.new.regexp.each_pair do |sym, str|
+ remove_const(sym) if const_defined?(sym, false)
+ const_set(sym, str)
end
end
- DEFAULT_PARSER.regexp.each_pair do |sym, str|
- const_set(sym, str)
+ self.parser = RFC3986_PARSER
+
+ def self.const_missing(const) # :nodoc:
+ if const == :REGEXP
+ warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
+ Bundler::URI::RFC2396_REGEXP
+ elsif value = RFC2396_PARSER.regexp[const]
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
+ value
+ elsif value = RFC2396_Parser.const_get(const)
+ warn "Bundler::URI::#{const} is obsolete. Use Bundler::URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
+ value
+ else
+ super
+ end
end
- Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
module Util # :nodoc:
def make_components_hash(klass, array_hash)
@@ -64,41 +94,101 @@ module Bundler::URI
module_function :make_components_hash
end
- module Schemes
+ module Schemes # :nodoc:
+ class << self
+ ReservedChars = ".+-"
+ EscapedChars = "\u01C0\u01C1\u01C2"
+ # Use Lo category chars as escaped chars for TruffleRuby, which
+ # does not allow Symbol categories as identifiers.
+
+ def escape(name)
+ unless name and name.ascii_only?
+ return nil
+ end
+ name.upcase.tr(ReservedChars, EscapedChars)
+ end
+
+ def unescape(name)
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
+ end
+
+ def find(name)
+ const_get(name, false) if name and const_defined?(name, false)
+ end
+
+ def register(name, klass)
+ unless scheme = escape(name)
+ raise ArgumentError, "invalid character as scheme - #{name}"
+ end
+ const_set(scheme, klass)
+ end
+
+ def list
+ constants.map { |name|
+ [unescape(name.to_s), const_get(name)]
+ }.to_h
+ end
+ end
end
private_constant :Schemes
+ # Registers the given +klass+ as the class to be instantiated
+ # when parsing a \Bundler::URI with the given +scheme+:
#
- # Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+.
- # Note that currently only schemes which after .upcase are valid constant names
- # can be registered (no -/+/. allowed).
+ # Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
+ # Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
#
+ # Note that after calling String#upcase on +scheme+, it must be a valid
+ # constant name.
def self.register_scheme(scheme, klass)
- Schemes.const_set(scheme.to_s.upcase, klass)
+ Schemes.register(scheme, klass)
end
- # Returns a Hash of the defined schemes.
+ # Returns a hash of the defined schemes:
+ #
+ # Bundler::URI.scheme_list
+ # # =>
+ # {"MAILTO"=>Bundler::URI::MailTo,
+ # "LDAPS"=>Bundler::URI::LDAPS,
+ # "WS"=>Bundler::URI::WS,
+ # "HTTP"=>Bundler::URI::HTTP,
+ # "HTTPS"=>Bundler::URI::HTTPS,
+ # "LDAP"=>Bundler::URI::LDAP,
+ # "FILE"=>Bundler::URI::File,
+ # "FTP"=>Bundler::URI::FTP}
+ #
+ # Related: Bundler::URI.register_scheme.
def self.scheme_list
- Schemes.constants.map { |name|
- [name.to_s.upcase, Schemes.const_get(name)]
- }.to_h
+ Schemes.list
end
+ # :stopdoc:
INITIAL_SCHEMES = scheme_list
private_constant :INITIAL_SCHEMES
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
+ # :startdoc:
+ # Returns a new object constructed from the given +scheme+, +arguments+,
+ # and +default+:
#
- # Construct a Bundler::URI instance, using the scheme to detect the appropriate class
- # from +Bundler::URI.scheme_list+.
+ # - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
+ # - The object is initialized by calling the class initializer
+ # using +scheme+ and +arguments+.
+ # See Bundler::URI::Generic.new.
+ #
+ # Examples:
+ #
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
+ # Bundler::URI.for('https', *values)
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
+ # # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
def self.for(scheme, *arguments, default: Generic)
- const_name = scheme.to_s.upcase
+ const_name = Schemes.escape(scheme)
uri_class = INITIAL_SCHEMES[const_name]
- uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
- Schemes.const_get(const_name, false)
- end
+ uri_class ||= Schemes.find(const_name)
uri_class ||= default
return uri_class.new(scheme, *arguments)
@@ -121,95 +211,49 @@ module Bundler::URI
#
class BadURIError < Error; end
- #
- # == Synopsis
- #
- # Bundler::URI::split(uri)
- #
- # == Args
- #
- # +uri+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Splits the string on following parts and returns array with result:
- #
- # * Scheme
- # * Userinfo
- # * Host
- # * Port
- # * Registry
- # * Path
- # * Opaque
- # * Query
- # * Fragment
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # Bundler::URI.split("http://www.ruby-lang.org/")
- # # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
+ # Returns a 9-element array representing the parts of the \Bundler::URI
+ # formed from the string +uri+;
+ # each array element is a string or +nil+:
+ #
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
+ # values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # names.zip(values)
+ # # =>
+ # [["scheme", "https"],
+ # ["userinfo", "john.doe"],
+ # ["host", "www.example.com"],
+ # ["port", "123"],
+ # ["registry", nil],
+ # ["path", "/forum/questions/"],
+ # ["opaque", nil],
+ # ["query", "tag=networking&order=newest"],
+ # ["fragment", "top"]]
#
def self.split(uri)
- RFC3986_PARSER.split(uri)
+ PARSER.split(uri)
end
+ # Returns a new \Bundler::URI object constructed from the given string +uri+:
#
- # == Synopsis
- #
- # Bundler::URI::parse(uri_str)
- #
- # == Args
+ # Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
- # +uri_str+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Creates one of the Bundler::URI's subclasses instance from the string.
- #
- # == Raises
- #
- # Bundler::URI::InvalidURIError::
- # Raised if Bundler::URI given is not a correct one.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://www.ruby-lang.org/")
- # # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
- # uri.scheme
- # # => "http"
- # uri.host
- # # => "www.ruby-lang.org"
- #
- # It's recommended to first ::escape the provided +uri_str+ if there are any
- # invalid Bundler::URI characters.
+ # It's recommended to first Bundler::URI::RFC2396_PARSER.escape string +uri+
+ # if it may contain invalid Bundler::URI characters.
#
def self.parse(uri)
- RFC3986_PARSER.parse(uri)
+ PARSER.parse(uri)
end
+ # Merges the given Bundler::URI strings +str+
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
#
- # == Synopsis
- #
- # Bundler::URI::join(str[, str, ...])
- #
- # == Args
- #
- # +str+::
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
- #
- # == Description
- #
- # Joins URIs.
+ # Each string in +str+ is converted to an
+ # {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
#
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
+ # Examples:
#
# Bundler::URI.join("http://example.com/","main.rbx")
# # => #<Bundler::URI::HTTP http://example.com/main.rbx>
@@ -227,7 +271,7 @@ module Bundler::URI
# # => #<Bundler::URI::HTTP http://example.com/foo/bar>
#
def self.join(*str)
- RFC3986_PARSER.join(*str)
+ DEFAULT_PARSER.join(*str)
end
#
@@ -254,9 +298,9 @@ module Bundler::URI
# Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
#
- def self.extract(str, schemes = nil, &block)
+ def self.extract(str, schemes = nil, &block) # :nodoc:
warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.extract(str, schemes, &block)
+ PARSER.extract(str, schemes, &block)
end
#
@@ -291,16 +335,16 @@ module Bundler::URI
# p $&
# end
#
- def self.regexp(schemes = nil)
+ def self.regexp(schemes = nil)# :nodoc:
warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.make_regexp(schemes)
+ PARSER.make_regexp(schemes)
end
TBLENCWWWCOMP_ = {} # :nodoc:
256.times do |i|
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
end
- TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc:
TBLENCWWWCOMP_[' '] = '+'
TBLENCWWWCOMP_.freeze
TBLDECWWWCOMP_ = {} # :nodoc:
@@ -314,44 +358,92 @@ module Bundler::URI
TBLDECWWWCOMP_['+'] = ' '
TBLDECWWWCOMP_.freeze
- # Encodes given +str+ to URL-encoded form data.
+ # Returns a URL-encoded string derived from the given string +str+.
+ #
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
+ # - Any other character to "percent notation";
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
#
- # This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
- # (ASCII space) to + and converts others to %XX.
+ # Encoding:
#
- # If +enc+ is given, convert +str+ to the encoding before percent encoding.
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
+ # (with suitable character replacements),
+ # and then to encoding +enc+.
#
- # This is an implementation of
- # https://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
#
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
+ # Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
def self.encode_www_form_component(str, enc=nil)
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
end
- # Decodes given +str+ of URL-encoded form data.
+ # Returns a string decoded from the given \URL-encoded string +str+.
#
- # This decodes + to SP.
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
#
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # Bundler::URI.decode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
+ # - Each "percent notation" to an ASCII character.
+ #
+ # Example:
+ #
+ # Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
+ # # => "Here are some punctuation characters: ,;?:"
+ #
+ # Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
_decode_uri_component(/\+|%\h\h/, str, enc)
end
- # Encodes +str+ using URL encoding
- #
- # This encodes SP to %20 instead of +.
+ # Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
def self.encode_uri_component(str, enc=nil)
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
end
- # Decodes given +str+ of URL-encoded data.
- #
- # This does not decode + to SP.
+ # Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
def self.decode_uri_component(str, enc=Encoding::UTF_8)
_decode_uri_component(/%\h\h/, str, enc)
end
+ # Returns a string derived from the given string +str+ with
+ # Bundler::URI-encoded characters matching +regexp+ according to +table+.
def self._encode_uri_component(regexp, table, str, enc)
str = str.to_s.dup
if str.encoding != Encoding::ASCII_8BIT
@@ -366,39 +458,112 @@ module Bundler::URI
end
private_class_method :_encode_uri_component
+ # Returns a string decoding characters matching +regexp+ from the
+ # given \URL-encoded string +str+.
def self._decode_uri_component(regexp, str, enc)
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
end
private_class_method :_decode_uri_component
- # Generates URL-encoded form data from given +enum+.
+ # Returns a URL-encoded string derived from the given
+ # {Enumerable}[rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes]
+ # +enum+.
+ #
+ # The result is suitable for use as form data
+ # for an \HTTP request whose <tt>Content-Type</tt> is
+ # <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned string consists of the elements of +enum+,
+ # each converted to one or more URL-encoded strings,
+ # and all joined with character <tt>'&'</tt>.
+ #
+ # Simple examples:
+ #
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
+ # # => "foo=0&bar=1&baz=2"
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
#
- # This generates application/x-www-form-urlencoded data defined in HTML5
- # from given an Enumerable object.
+ # The returned string is formed using method Bundler::URI.encode_www_form_component,
+ # which converts certain characters:
#
- # This internally uses Bundler::URI.encode_www_form_component(str).
+ # Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
#
- # This method doesn't convert the encoding of given items, so convert them
- # before calling this method if you want to send data as other than original
- # encoding or mixed encoding data. (Strings which are encoded in an HTML5
- # ASCII incompatible encoding are converted to UTF-8.)
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
#
- # This method doesn't handle files. When you send a file, use
- # multipart/form-data.
+ # - If +ele+ is an array of two or more elements,
+ # the field is formed from its first two elements
+ # (and any additional elements are ignored):
#
- # This refers https://url.spec.whatwg.org/#concept-urlencoded-serializer
+ # name = Bundler::URI.encode_www_form_component(ele[0], enc)
+ # value = Bundler::URI.encode_www_form_component(ele[1], enc)
+ # "#{name}=#{value}"
#
- # Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
- # #=> "q=ruby&q=perl&lang=en"
- # Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
- # #=> "q=ruby&q=perl&lang=en"
+ # Examples:
+ #
+ # Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
+ # # => "foo=bar&baz=bat"
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
+ # # => "foo=0&bar=baz"
+ #
+ # - If +ele+ is an array of one element,
+ # the field is formed from <tt>ele[0]</tt>:
+ #
+ # Bundler::URI.encode_www_form_component(ele[0])
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
+ # # => "foo&bar&0"
+ #
+ # - Otherwise the field is formed from +ele+:
+ #
+ # Bundler::URI.encode_www_form_component(ele)
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form(['foo', :bar, 0])
+ # # => "foo&bar&0"
+ #
+ # The elements of an Array-like +enum+ may be mixture:
+ #
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
+ # # => "foo=0&bar=1&baz&bat"
+ #
+ # When +enum+ is Hash-like,
+ # each +key+/+value+ pair is converted to one or more fields:
+ #
+ # - If +value+ is
+ # {Array-convertible}[rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects],
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
+ #
+ # name = Bundler::URI.encode_www_form_component(key, enc)
+ # value = Bundler::URI.encode_www_form_component(ele, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
+ #
+ # - Otherwise, +key+ and +value+ are paired to form a field:
+ #
+ # name = Bundler::URI.encode_www_form_component(key, enc)
+ # value = Bundler::URI.encode_www_form_component(value, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
+ #
+ # The elements of a Hash-like +enum+ may be mixture:
+ #
+ # Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
+ # # => "foo=0&foo=1&bar=2"
#
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
def self.encode_www_form(enum, enc=nil)
enum.map do |k,v|
if v.nil?
@@ -419,22 +584,39 @@ module Bundler::URI
end.join('&')
end
- # Decodes URL-encoded form data from given +str+.
+ # Returns name/value pairs derived from the given string +str+,
+ # which must be an ASCII string.
+ #
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned data is an array of 2-element subarrays;
+ # each subarray is a name/value pair (both are strings).
+ # Each returned string has encoding +enc+,
+ # and has had invalid characters removed via
+ # {String#scrub}[rdoc-ref:String#scrub].
#
- # This decodes application/x-www-form-urlencoded data
- # and returns an array of key-value arrays.
+ # A simple example:
#
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
- # so this supports only &-separator, and doesn't support ;-separator.
+ # Bundler::URI.decode_www_form('foo=0&bar=1&baz')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
#
- # ary = Bundler::URI.decode_www_form("a=1&a=2&b=3")
- # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
- # ary.assoc('a').last #=> '1'
- # ary.assoc('b').last #=> '3'
- # ary.rassoc('a').last #=> '2'
- # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
+ # The returned strings have certain conversions,
+ # similar to those performed in Bundler::URI.decode_www_form_component:
+ #
+ # Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
+ #
+ # The given string may contain consecutive separators:
+ #
+ # Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
+ #
+ # A different separator may be specified:
+ #
+ # Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
#
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
ary = []
@@ -713,7 +895,18 @@ end # module Bundler::URI
module Bundler
#
- # Returns +uri+ converted to an Bundler::URI object.
+ # Returns a \Bundler::URI object derived from the given +uri+,
+ # which may be a \Bundler::URI string or an existing \Bundler::URI object:
+ #
+ # require 'bundler/vendor/uri/lib/uri'
+ # # Returns a new Bundler::URI.
+ # uri = Bundler::URI('http://github.com/ruby/ruby')
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
+ # # Returns the given Bundler::URI.
+ # Bundler::URI(uri)
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
+ #
+ # You must require 'bundler/vendor/uri/lib/uri' to use this method.
#
def URI(uri)
if uri.is_a?(Bundler::URI::Generic)
diff --git a/lib/bundler/vendor/uri/lib/uri/file.rb b/lib/bundler/vendor/uri/lib/uri/file.rb
index 8d75a9de7a..21dd9ee535 100644
--- a/lib/bundler/vendor/uri/lib/uri/file.rb
+++ b/lib/bundler/vendor/uri/lib/uri/file.rb
@@ -47,7 +47,7 @@ module Bundler::URI
# :path => '/ruby/src'})
# uri2.to_s # => "file://host.example.com/ruby/src"
#
- # uri3 = Bundler::URI::File.build({:path => Bundler::URI::escape('/path/my file.txt')})
+ # uri3 = Bundler::URI::File.build({:path => Bundler::URI::RFC2396_PARSER.escape('/path/my file.txt')})
# uri3.to_s # => "file:///path/my%20file.txt"
#
def self.build(args)
@@ -70,17 +70,17 @@ module Bundler::URI
# raise InvalidURIError
def check_userinfo(user)
- raise Bundler::URI::InvalidURIError, "can not set userinfo for file Bundler::URI"
+ raise Bundler::URI::InvalidURIError, "cannot set userinfo for file Bundler::URI"
end
# raise InvalidURIError
def check_user(user)
- raise Bundler::URI::InvalidURIError, "can not set user for file Bundler::URI"
+ raise Bundler::URI::InvalidURIError, "cannot set user for file Bundler::URI"
end
# raise InvalidURIError
def check_password(user)
- raise Bundler::URI::InvalidURIError, "can not set password for file Bundler::URI"
+ raise Bundler::URI::InvalidURIError, "cannot set password for file Bundler::URI"
end
# do nothing
diff --git a/lib/bundler/vendor/uri/lib/uri/ftp.rb b/lib/bundler/vendor/uri/lib/uri/ftp.rb
index 48b4c6718d..f83985fd3d 100644
--- a/lib/bundler/vendor/uri/lib/uri/ftp.rb
+++ b/lib/bundler/vendor/uri/lib/uri/ftp.rb
@@ -17,7 +17,7 @@ module Bundler::URI
# This class will be redesigned because of difference of implementations;
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
# is a good summary about the de facto spec.
- # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
+ # https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
# A Default port of 21 for Bundler::URI::FTP.
diff --git a/lib/bundler/vendor/uri/lib/uri/generic.rb b/lib/bundler/vendor/uri/lib/uri/generic.rb
index 9ae6915826..30dab60903 100644
--- a/lib/bundler/vendor/uri/lib/uri/generic.rb
+++ b/lib/bundler/vendor/uri/lib/uri/generic.rb
@@ -73,7 +73,7 @@ module Bundler::URI
#
# At first, tries to create a new Bundler::URI::Generic instance using
# Bundler::URI::Generic::build. But, if exception Bundler::URI::InvalidComponentError is raised,
- # then it does Bundler::URI::Escape.escape all Bundler::URI components and tries again.
+ # then it does Bundler::URI::RFC2396_PARSER.escape all Bundler::URI components and tries again.
#
def self.build2(args)
begin
@@ -82,7 +82,7 @@ module Bundler::URI
if args.kind_of?(Array)
return self.build(args.collect{|x|
if x.is_a?(String)
- DEFAULT_PARSER.escape(x)
+ Bundler::URI::RFC2396_PARSER.escape(x)
else
x
end
@@ -91,7 +91,7 @@ module Bundler::URI
tmp = {}
args.each do |key, value|
tmp[key] = if value
- DEFAULT_PARSER.escape(value)
+ Bundler::URI::RFC2396_PARSER.escape(value)
else
value
end
@@ -126,9 +126,9 @@ module Bundler::URI
end
end
else
- component = self.class.component rescue ::Bundler::URI::Generic::COMPONENT
+ component = self.component rescue ::Bundler::URI::Generic::COMPONENT
raise ArgumentError,
- "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
+ "expected Array of or Hash of components of #{self} (#{component.join(', ')})"
end
tmp << nil
@@ -186,18 +186,18 @@ module Bundler::URI
if arg_check
self.scheme = scheme
- self.userinfo = userinfo
self.hostname = host
self.port = port
+ self.userinfo = userinfo
self.path = path
self.query = query
self.opaque = opaque
self.fragment = fragment
else
self.set_scheme(scheme)
- self.set_userinfo(userinfo)
self.set_host(host)
self.set_port(port)
+ self.set_userinfo(userinfo)
self.set_path(path)
self.query = query
self.set_opaque(opaque)
@@ -284,7 +284,7 @@ module Bundler::URI
# Returns the parser to be used.
#
- # Unless a Bundler::URI::Parser is defined, DEFAULT_PARSER is used.
+ # Unless the +parser+ is defined, DEFAULT_PARSER is used.
#
def parser
if !defined?(@parser) || !@parser
@@ -315,7 +315,7 @@ module Bundler::URI
end
#
- # Checks the scheme +v+ component against the Bundler::URI::Parser Regexp for :SCHEME.
+ # Checks the scheme +v+ component against the +parser+ Regexp for :SCHEME.
#
def check_scheme(v)
if v && parser.regexp[:SCHEME] !~ v
@@ -385,7 +385,7 @@ module Bundler::URI
#
# Checks the user +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :USERINFO.
+ # and against the +parser+ Regexp for :USERINFO.
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -393,7 +393,7 @@ module Bundler::URI
def check_user(v)
if @opaque
raise InvalidURIError,
- "can not set user with opaque"
+ "cannot set user with opaque"
end
return v unless v
@@ -409,7 +409,7 @@ module Bundler::URI
#
# Checks the password +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :USERINFO.
+ # and against the +parser+ Regexp for :USERINFO.
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -417,7 +417,7 @@ module Bundler::URI
def check_password(v, user = @user)
if @opaque
raise InvalidURIError,
- "can not set password with opaque"
+ "cannot set password with opaque"
end
return v unless v
@@ -511,7 +511,7 @@ module Bundler::URI
user, password = split_userinfo(user)
end
@user = user
- @password = password if password
+ @password = password
[@user, @password]
end
@@ -522,7 +522,7 @@ module Bundler::URI
# See also Bundler::URI::Generic.user=.
#
def set_user(v)
- set_userinfo(v, @password)
+ set_userinfo(v, nil)
v
end
protected :set_user
@@ -574,6 +574,12 @@ module Bundler::URI
@password
end
+ # Returns the authority info (array of user, password, host and
+ # port), if any is set. Or returns +nil+.
+ def authority
+ return @user, @password, @host, @port if @user || @password || @host || @port
+ end
+
# Returns the user component after Bundler::URI decoding.
def decoded_user
Bundler::URI.decode_uri_component(@user) if @user
@@ -586,7 +592,7 @@ module Bundler::URI
#
# Checks the host +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :HOST.
+ # and against the +parser+ Regexp for :HOST.
#
# Can not have a registry or opaque component defined,
# with a host component defined.
@@ -596,7 +602,7 @@ module Bundler::URI
if @opaque
raise InvalidURIError,
- "can not set host with registry or opaque"
+ "cannot set host with registry or opaque"
elsif parser.regexp[:HOST] !~ v
raise InvalidComponentError,
"bad component(expected host component): #{v}"
@@ -615,6 +621,13 @@ module Bundler::URI
end
protected :set_host
+ # Protected setter for the authority info (+user+, +password+, +host+
+ # and +port+). If +port+ is +nil+, +default_port+ will be set.
+ #
+ protected def set_authority(user, password, host, port = nil)
+ @user, @password, @host, @port = user, password, host, port || self.default_port
+ end
+
#
# == Args
#
@@ -639,6 +652,7 @@ module Bundler::URI
def host=(v)
check_host(v)
set_host(v)
+ set_userinfo(nil)
v
end
@@ -675,7 +689,7 @@ module Bundler::URI
#
# Checks the port +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp for :PORT.
+ # and against the +parser+ Regexp for :PORT.
#
# Can not have a registry or opaque component defined,
# with a port component defined.
@@ -685,7 +699,7 @@ module Bundler::URI
if @opaque
raise InvalidURIError,
- "can not set port with registry or opaque"
+ "cannot set port with registry or opaque"
elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
raise InvalidComponentError,
"bad component(expected port component): #{v.inspect}"
@@ -729,26 +743,27 @@ module Bundler::URI
def port=(v)
check_port(v)
set_port(v)
+ set_userinfo(nil)
port
end
def check_registry(v) # :nodoc:
- raise InvalidURIError, "can not set registry"
+ raise InvalidURIError, "cannot set registry"
end
private :check_registry
- def set_registry(v) #:nodoc:
- raise InvalidURIError, "can not set registry"
+ def set_registry(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
end
protected :set_registry
- def registry=(v)
- raise InvalidURIError, "can not set registry"
+ def registry=(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
end
#
# Checks the path +v+ component for RFC2396 compliance
- # and against the Bundler::URI::Parser Regexp
+ # and against the +parser+ Regexp
# for :ABS_PATH and :REL_PATH.
#
# Can not have a opaque component defined,
@@ -853,7 +868,7 @@ module Bundler::URI
#
# Checks the opaque +v+ component for RFC2396 compliance and
- # against the Bundler::URI::Parser Regexp for :OPAQUE.
+ # against the +parser+ Regexp for :OPAQUE.
#
# Can not have a host, port, user, or path component defined,
# with an opaque component defined.
@@ -866,7 +881,7 @@ module Bundler::URI
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
raise InvalidURIError,
- "can not set opaque with host, port, userinfo or path"
+ "cannot set opaque with host, port, userinfo or path"
elsif v && parser.regexp[:OPAQUE] !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
@@ -905,7 +920,7 @@ module Bundler::URI
end
#
- # Checks the fragment +v+ component against the Bundler::URI::Parser Regexp for :FRAGMENT.
+ # Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT.
#
#
# == Args
@@ -945,7 +960,7 @@ module Bundler::URI
# == Description
#
# Bundler::URI has components listed in order of decreasing significance from left to right,
- # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
+ # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
#
# == Usage
#
@@ -1121,7 +1136,7 @@ module Bundler::URI
base = self.dup
- authority = rel.userinfo || rel.host || rel.port
+ authority = rel.authority
# RFC2396, Section 5.2, 2)
if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1133,17 +1148,14 @@ module Bundler::URI
base.fragment=(nil)
# RFC2396, Section 5.2, 4)
- if !authority
- base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
- else
- # RFC2396, Section 5.2, 4)
- base.set_path(rel.path) if rel.path
+ if authority
+ base.set_authority(*authority)
+ base.set_path(rel.path)
+ elsif base.path && rel.path
+ base.set_path(merge_path(base.path, rel.path))
end
# RFC2396, Section 5.2, 7)
- base.set_userinfo(rel.userinfo) if rel.userinfo
- base.set_host(rel.host) if rel.host
- base.set_port(rel.port) if rel.port
base.query = rel.query if rel.query
base.fragment=(rel.fragment) if rel.fragment
@@ -1235,7 +1247,7 @@ module Bundler::URI
return rel, rel
end
- # you can modify `rel', but can not `oth'.
+ # you can modify `rel', but cannot `oth'.
return oth, rel
end
private :route_from0
@@ -1260,7 +1272,7 @@ module Bundler::URI
# #=> #<Bundler::URI::Generic /main.rbx?page=1>
#
def route_from(oth)
- # you can modify `rel', but can not `oth'.
+ # you can modify `rel', but cannot `oth'.
begin
oth, rel = route_from0(oth)
rescue
@@ -1364,6 +1376,9 @@ module Bundler::URI
str << ':'
str << @port.to_s
end
+ if (@host || @port) && !@path.empty? && !@path.start_with?('/')
+ str << '/'
+ end
str << @path
if @query
str << '?'
@@ -1376,6 +1391,7 @@ module Bundler::URI
end
str
end
+ alias to_str to_s
#
# Compares two URIs.
@@ -1388,29 +1404,18 @@ module Bundler::URI
end
end
+ # Returns the hash value.
def hash
self.component_ary.hash
end
+ # Compares with _oth_ for Hash.
def eql?(oth)
self.class == oth.class &&
parser == oth.parser &&
self.component_ary.eql?(oth.component_ary)
end
-=begin
-
---- Bundler::URI::Generic#===(oth)
-
-=end
-# def ===(oth)
-# raise NotImplementedError
-# end
-
-=begin
-=end
-
-
# Returns an Array of the components defined from the COMPONENT Array.
def component_ary
component.collect do |x|
@@ -1447,7 +1452,7 @@ module Bundler::URI
end
end
- def inspect
+ def inspect # :nodoc:
"#<#{self.class} #{self}>"
end
@@ -1535,7 +1540,7 @@ module Bundler::URI
else
unless proxy_uri = env[name]
if proxy_uri = env[name.upcase]
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
+ warn 'The environment variable HTTP_PROXY is discouraged. Please use http_proxy instead.', uplevel: 1
end
end
end
diff --git a/lib/bundler/vendor/uri/lib/uri/http.rb b/lib/bundler/vendor/uri/lib/uri/http.rb
index 2c44810644..9b217ee266 100644
--- a/lib/bundler/vendor/uri/lib/uri/http.rb
+++ b/lib/bundler/vendor/uri/lib/uri/http.rb
@@ -61,6 +61,18 @@ module Bundler::URI
super(tmp)
end
+ # Do not allow empty host names, as they are not allowed by RFC 3986.
+ def check_host(v)
+ ret = super
+
+ if ret && v.empty?
+ raise InvalidComponentError,
+ "bad component(expected host component): #{v}"
+ end
+
+ ret
+ end
+
#
# == Description
#
@@ -85,7 +97,7 @@ module Bundler::URI
# == Description
#
# Returns the authority for an HTTP uri, as defined in
- # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
+ # https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
#
#
# Example:
@@ -106,7 +118,7 @@ module Bundler::URI
# == Description
#
# Returns the origin for an HTTP uri, as defined in
- # https://datatracker.ietf.org/doc/html/rfc6454.
+ # https://www.rfc-editor.org/rfc/rfc6454.
#
#
# Example:
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
index 2f8d55353b..522113fe67 100644
--- a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
+++ b/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
@@ -67,7 +67,7 @@ module Bundler::URI
#
# == Synopsis
#
- # Bundler::URI::Parser.new([opts])
+ # Bundler::URI::RFC2396_Parser.new([opts])
#
# == Args
#
@@ -86,7 +86,7 @@ module Bundler::URI
#
# == Examples
#
- # p = Bundler::URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
+ # p = Bundler::URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
# u = p.parse("http://example.jp/%uABCD") #=> #<Bundler::URI::HTTP http://example.jp/%uABCD>
# Bundler::URI.parse(u.to_s) #=> raises Bundler::URI::InvalidURIError
#
@@ -108,12 +108,12 @@ module Bundler::URI
# The Hash of patterns.
#
- # See also Bundler::URI::Parser.initialize_pattern.
+ # See also #initialize_pattern.
attr_reader :pattern
# The Hash of Regexp.
#
- # See also Bundler::URI::Parser.initialize_regexp.
+ # See also #initialize_regexp.
attr_reader :regexp
# Returns a split Bundler::URI against +regexp[:ABS_URI]+.
@@ -140,11 +140,11 @@ module Bundler::URI
if !scheme
raise InvalidURIError,
- "bad Bundler::URI(absolute but no scheme): #{uri}"
+ "bad Bundler::URI (absolute but no scheme): #{uri}"
end
if !opaque && (!path && (!host && !registry))
raise InvalidURIError,
- "bad Bundler::URI(absolute but no path): #{uri}"
+ "bad Bundler::URI (absolute but no path): #{uri}"
end
when @regexp[:REL_URI]
@@ -173,7 +173,7 @@ module Bundler::URI
# server = [ [ userinfo "@" ] hostport ]
else
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri}"
+ raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri}"
end
path = '' if !path && !opaque # (see RFC2396 Section 5.2)
@@ -202,8 +202,7 @@ module Bundler::URI
#
# == Usage
#
- # p = Bundler::URI::Parser.new
- # p.parse("ldap://ldap.example.com/dc=example?user=john")
+ # Bundler::URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john")
# #=> #<Bundler::URI::LDAP ldap://ldap.example.com/dc=example?user=john>
#
def parse(uri)
@@ -244,7 +243,7 @@ module Bundler::URI
# If no +block+ given, then returns the result,
# else it calls +block+ for each element in result.
#
- # See also Bundler::URI::Parser.make_regexp.
+ # See also #make_regexp.
#
def extract(str, schemes = nil)
if block_given?
@@ -263,7 +262,7 @@ module Bundler::URI
unless schemes
@regexp[:ABS_URI_REF]
else
- /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
+ /(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
end
end
@@ -321,14 +320,14 @@ module Bundler::URI
str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
end
- @@to_s = Kernel.instance_method(:to_s)
- if @@to_s.respond_to?(:bind_call)
- def inspect
- @@to_s.bind_call(self)
+ TO_S = Kernel.instance_method(:to_s) # :nodoc:
+ if TO_S.respond_to?(:bind_call)
+ def inspect # :nodoc:
+ TO_S.bind_call(self)
end
else
- def inspect
- @@to_s.bind(self).call
+ def inspect # :nodoc:
+ TO_S.bind(self).call
end
end
@@ -497,8 +496,8 @@ module Bundler::URI
ret = {}
# for Bundler::URI::split
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
# for Bundler::URI::extract
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
@@ -524,6 +523,8 @@ module Bundler::URI
ret
end
+ # Returns +uri+ as-is if it is Bundler::URI, or convert it to Bundler::URI if it is
+ # a String.
def convert_to_uri(uri)
if uri.is_a?(Bundler::URI::Generic)
uri
@@ -536,4 +537,11 @@ module Bundler::URI
end
end # class Parser
+
+ # Backward compatibility for Bundler::URI::REGEXP::PATTERN::*
+ RFC2396_Parser.new.pattern.each_pair do |sym, str|
+ unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false)
+ RFC2396_REGEXP::PATTERN.const_set(sym, str)
+ end
+ end
end # module Bundler::URI
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
index 1307e8e474..d1ff28df23 100644
--- a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
+++ b/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
@@ -1,9 +1,73 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Bundler::URI
class RFC3986_Parser # :nodoc:
# Bundler::URI defined in RFC3986
- RFC3986_URI = /\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
+ HOST = %r[
+ (?<IP-literal>\[(?:
+ (?<IPv6address>
+ (?:\h{1,4}:){6}
+ (?<ls32>\h{1,4}:\h{1,4}
+ | (?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)
+ \.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>)
+ )
+ | ::(?:\h{1,4}:){5}\g<ls32>
+ | \h{1,4}?::(?:\h{1,4}:){4}\g<ls32>
+ | (?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>
+ | (?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>
+ | (?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>
+ | (?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>
+ | (?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}
+ | (?:(?:\h{1,4}:){,6}\h{1,4})?::
+ )
+ | (?<IPvFuture>v\h++\.[!$&-.0-9:;=A-Z_a-z~]++)
+ )\])
+ | \g<IPv4address>
+ | (?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+)
+ ]x
+
+ USERINFO = /(?:%\h\h|[!$&-.0-9:;=A-Z_a-z~])*+/
+
+ SCHEME = %r[[A-Za-z][+\-.0-9A-Za-z]*+].source
+ SEG = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/])].source
+ SEG_NC = %r[(?:%\h\h|[!$&-.0-9;=@A-Z_a-z~])].source
+ FRAGMENT = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+].source
+
+ RFC3986_URI = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<Bundler::URI>
+ (?<scheme>#{SCHEME}):
+ (?<hier-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")})
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/((?!/)\g<seg>++)?)
+ | (?<path-rootless>(?!/)\g<seg>++)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^\#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
+
+ RFC3986_relative_ref = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<relative-ref>
+ (?<relative-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")}(?<!/))?
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/\g<seg>*+)
+ | (?<path-noscheme>#{SEG_NC}++(?:/\g<seg>*+)?)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
attr_reader :regexp
def initialize
@@ -14,14 +78,14 @@ module Bundler::URI
begin
uri = uri.to_str
rescue NoMethodError
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
end
uri.ascii_only? or
raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
if m = RFC3986_URI.match(uri)
- query = m["query".freeze]
- scheme = m["scheme".freeze]
- opaque = m["path-rootless".freeze]
+ query = m["query"]
+ scheme = m["scheme"]
+ opaque = m["path-rootless"]
if opaque
opaque << "?#{query}" if query
[ scheme,
@@ -32,38 +96,38 @@ module Bundler::URI
nil, # path
opaque,
nil, # query
- m["fragment".freeze]
+ m["fragment"]
]
else # normal
[ scheme,
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-empty"]),
nil, # opaque
query,
- m["fragment".freeze]
+ m["fragment"]
]
end
elsif m = RFC3986_relative_ref.match(uri)
[ nil, # scheme
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry,
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-noscheme".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-noscheme"] ||
+ m["path-empty"]),
nil, # opaque
- m["query".freeze],
- m["fragment".freeze]
+ m["query"],
+ m["fragment"]
]
else
- raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
end
end
@@ -71,12 +135,35 @@ module Bundler::URI
Bundler::URI.for(*self.split(uri), self)
end
-
def join(*uris) # :nodoc:
uris[0] = convert_to_uri(uris[0])
uris.inject :merge
end
+ # Compatibility for RFC2396 parser
+ def extract(str, schemes = nil, &block) # :nodoc:
+ warn "Bundler::URI::RFC3986_PARSER.extract is obsolete. Use Bundler::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.extract(str, schemes, &block)
+ end
+
+ # Compatibility for RFC2396 parser
+ def make_regexp(schemes = nil) # :nodoc:
+ warn "Bundler::URI::RFC3986_PARSER.make_regexp is obsolete. Use Bundler::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.make_regexp(schemes)
+ end
+
+ # Compatibility for RFC2396 parser
+ def escape(str, unsafe = nil) # :nodoc:
+ warn "Bundler::URI::RFC3986_PARSER.escape is obsolete. Use Bundler::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
+ unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
+ end
+
+ # Compatibility for RFC2396 parser
+ def unescape(str, escaped = nil) # :nodoc:
+ warn "Bundler::URI::RFC3986_PARSER.unescape is obsolete. Use Bundler::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
+ escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
+ end
+
@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
def inspect
@@ -92,15 +179,15 @@ module Bundler::URI
def default_regexp # :nodoc:
{
- SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
- USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
- HOST: /\A(?:(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{,4}::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))\z/,
- ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- OPAQUE: /\A(?:[^\/].*)?\z/,
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
+ SCHEME: %r[\A#{SCHEME}\z]o,
+ USERINFO: %r[\A#{USERINFO}\z]o,
+ HOST: %r[\A#{HOST}\z]o,
+ ABS_PATH: %r[\A/#{SEG}*+\z]o,
+ REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
+ QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
+ FRAGMENT: %r[\A#{FRAGMENT}\z]o,
+ OPAQUE: %r[\A(?:[^/].*)?\z],
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
}
end
diff --git a/lib/bundler/vendor/uri/lib/uri/version.rb b/lib/bundler/vendor/uri/lib/uri/version.rb
index 02fa367735..ad76308e81 100644
--- a/lib/bundler/vendor/uri/lib/uri/version.rb
+++ b/lib/bundler/vendor/uri/lib/uri/version.rb
@@ -1,6 +1,6 @@
module Bundler::URI
# :stopdoc:
- VERSION_CODE = '001200'.freeze
- VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
+ VERSION = '1.1.1'.freeze
+ VERSION_CODE = VERSION.split('.').map{|s| s.rjust(2, '0')}.join.freeze
# :startdoc:
end
diff --git a/lib/bundler/vendored_net_http.rb b/lib/bundler/vendored_net_http.rb
new file mode 100644
index 0000000000..8ff2ccd1fe
--- /dev/null
+++ b/lib/bundler/vendored_net_http.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+# This defined? guard can be removed once RubyGems 3.4 support is dropped.
+#
+# Bundler specs load this code from `spec/support/vendored_net_http.rb` to avoid
+# activating the Bundler gem too early. Without this guard, we get redefinition
+# warnings once Bundler is actually activated and
+# `lib/bundler/vendored_net_http.rb` is required. This is not an issue in
+# RubyGems versions including `rubygems/vendored_net_http` since `require` takes
+# care of avoiding the double load.
+#
+unless defined?(Gem::Net)
+ begin
+ require "rubygems/vendored_net_http"
+ rescue LoadError
+ begin
+ require "rubygems/net/http"
+ rescue LoadError
+ require "net/http"
+ Gem::Net = Net
+ end
+ end
+end
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb
index e29f27cdfd..ab985c267f 100644
--- a/lib/bundler/vendored_persistent.rb
+++ b/lib/bundler/vendored_persistent.rb
@@ -9,7 +9,3 @@ module Bundler
end
end
require_relative "vendor/net-http-persistent/lib/net/http/persistent"
-
-module Bundler
- PersistentHTTP = Persistent::Net::HTTP::Persistent
-end
diff --git a/lib/bundler/vendored_securerandom.rb b/lib/bundler/vendored_securerandom.rb
new file mode 100644
index 0000000000..6a704dbd40
--- /dev/null
+++ b/lib/bundler/vendored_securerandom.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+# Use RubyGems vendored copy when available. Otherwise fallback to Bundler
+# vendored copy. The vendored copy in Bundler can be removed once support for
+# RubyGems 3.5.18 is dropped.
+
+begin
+ require "rubygems/vendored_securerandom"
+rescue LoadError
+ require_relative "vendor/securerandom/lib/securerandom"
+ Gem::SecureRandom = Bundler::SecureRandom
+end
diff --git a/lib/bundler/vendored_timeout.rb b/lib/bundler/vendored_timeout.rb
new file mode 100644
index 0000000000..9b2507c0cc
--- /dev/null
+++ b/lib/bundler/vendored_timeout.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+begin
+ require "rubygems/vendored_timeout"
+rescue LoadError
+ begin
+ require "rubygems/timeout"
+ rescue LoadError
+ require "timeout"
+ Gem::Timeout = Timeout
+ end
+end
diff --git a/lib/bundler/vendored_uri.rb b/lib/bundler/vendored_uri.rb
index 905e8158e8..2efddc65f9 100644
--- a/lib/bundler/vendored_uri.rb
+++ b/lib/bundler/vendored_uri.rb
@@ -1,4 +1,21 @@
# frozen_string_literal: true
module Bundler; end
-require_relative "vendor/uri/lib/uri"
+
+# Use RubyGems vendored copy when available. Otherwise fallback to Bundler
+# vendored copy. The vendored copy in Bundler can be removed once support for
+# RubyGems 3.5 is dropped.
+
+begin
+ require "rubygems/vendor/uri/lib/uri"
+rescue LoadError
+ require_relative "vendor/uri/lib/uri"
+ Gem::URI = Bundler::URI
+
+ module Gem
+ def URI(uri) # rubocop:disable Naming/MethodName
+ Bundler::URI(uri)
+ end
+ module_function :URI
+ end
+end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 7c03d8687f..ca7bb0719a 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,13 +1,21 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.5.0.dev".freeze
+ VERSION = "4.1.0.dev".freeze
def self.bundler_major_version
- @bundler_major_version ||= VERSION.split(".").first.to_i
+ @bundler_major_version ||= gem_version.segments.first
end
def self.gem_version
@gem_version ||= Gem::Version.create(VERSION)
end
+
+ def self.verbose_version
+ @verbose_version ||= "#{VERSION}#{simulated_version ? " (simulating Bundler #{simulated_version})" : ""}"
+ end
+
+ def self.simulated_version
+ @simulated_version ||= Bundler.settings[:simulate_version]
+ end
end
diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb
index 538e8c3e74..c3a3d949a6 100644
--- a/lib/bundler/vlad.rb
+++ b/lib/bundler/vlad.rb
@@ -1,17 +1,4 @@
# frozen_string_literal: true
require_relative "shared_helpers"
-Bundler::SharedHelpers.major_deprecation 2,
- "The Bundler task for Vlad"
-
-# Vlad task for Bundler.
-#
-# Add "require 'bundler/vlad'" in your Vlad deploy.rb, and
-# include the vlad:bundle:install task in your vlad:deploy task.
-require_relative "deployment"
-
-include Rake::DSL if defined? Rake::DSL
-
-namespace :vlad do
- Bundler::Deployment.define_task(Rake::RemoteTask, :remote_task, :roles => :app)
-end
+Bundler::SharedHelpers.feature_removed! "The Bundler task for Vlad"
diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb
index 3ebd6f01db..77f4f004aa 100644
--- a/lib/bundler/worker.rb
+++ b/lib/bundler/worker.rb
@@ -22,6 +22,7 @@ module Bundler
def initialize(size, name, func)
@name = name
@request_queue = Thread::Queue.new
+ @request_queue_with_priority = Thread::Queue.new
@response_queue = Thread::Queue.new
@func = func
@size = size
@@ -32,9 +33,10 @@ module Bundler
# Enqueue a request to be executed in the worker pool
#
# @param obj [String] mostly it is name of spec that should be downloaded
- def enq(obj)
+ def enq(obj, priority: false)
+ queue = priority ? @request_queue_with_priority : @request_queue
create_threads unless @threads
- @request_queue.enq obj
+ queue.enq obj
end
# Retrieves results of job function being executed in worker pool
@@ -52,7 +54,13 @@ module Bundler
def process_queue(i)
loop do
- obj = @request_queue.deq
+ obj = begin
+ @request_queue_with_priority.deq(true)
+ rescue ThreadError
+ @request_queue.deq(false, timeout: 0.05)
+ end
+
+ next if obj.nil?
break if obj.equal? POISON
@response_queue.enq apply_func(obj, i)
end
@@ -88,7 +96,7 @@ module Bundler
@threads = Array.new(@size) do |i|
Thread.start { process_queue(i) }.tap do |thread|
- thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=)
+ thread.name = "#{name} Worker ##{i}"
end
rescue ThreadError => e
creation_errors << e
diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb
index d5ecbd4aef..ab1eb6dbcf 100644
--- a/lib/bundler/yaml_serializer.rb
+++ b/lib/bundler/yaml_serializer.rb
@@ -17,7 +17,11 @@ module Bundler
if v.is_a?(Hash)
yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
elsif v.is_a?(Array) # Expected to be array of strings
- yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
+ if v.empty?
+ yaml << " []\n"
+ else
+ yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
+ end
else
yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
end
@@ -32,30 +36,31 @@ module Bundler
(.*) # value
\1 # matching closing quote
$
- /xo.freeze
+ /xo
HASH_REGEX = /
^
([ ]*) # indentations
- (.+) # key
+ ([^#]+) # key excludes comment char '#'
(?::(?=(?:\s|$))) # : (without the lookahead the #key includes this when : is present in value)
[ ]?
(['"]?) # optional opening quote
(.*) # value
\3 # matching closing quote
$
- /xo.freeze
+ /xo
def load(str)
res = {}
stack = [res]
last_hash = nil
last_empty_key = nil
- str.split(/\r?\n/).each do |line|
+ str.split(/\r?\n/) do |line|
if match = HASH_REGEX.match(line)
indent, key, quote, val = match.captures
- key = convert_to_backward_compatible_key(key)
- depth = indent.scan(/ /).length
+ val = strip_comment(val)
+
+ depth = indent.size / 2
if quote.empty? && val.empty?
new_hash = {}
stack[depth][key] = new_hash
@@ -63,10 +68,13 @@ module Bundler
last_empty_key = key
last_hash = stack[depth]
else
+ val = [] if val == "[]" # empty array
stack[depth][key] = val
end
elsif match = ARRAY_REGEX.match(line)
_, val = match.captures
+ val = strip_comment(val)
+
last_hash[last_empty_key] = [] unless last_hash[last_empty_key].is_a?(Array)
last_hash[last_empty_key].push(val)
@@ -75,15 +83,16 @@ module Bundler
res
end
- # for settings' keys
- def convert_to_backward_compatible_key(key)
- key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z}
- key = key.gsub(".", "__") if key.include?(".")
- key
+ def strip_comment(val)
+ if val.include?("#") && !val.start_with?("#")
+ val.split("#", 2).first.strip
+ else
+ val
+ end
end
class << self
- private :dump_hash, :convert_to_backward_compatible_key
+ private :dump_hash
end
end
end
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 4cd6b3bd8e..0c403bd19c 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1,297 +1,9 @@
# frozen_string_literal: true
-#
-# cgi.rb - cgi support library
-#
-# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-#
-# Copyright (C) 2000 Information-technology Promotion Agency, Japan
-#
-# Author: Wakou Aoyama <wakou@ruby-lang.org>
-#
-# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
-#
-# == Overview
-#
-# The Common Gateway Interface (CGI) is a simple protocol for passing an HTTP
-# request from a web server to a standalone program, and returning the output
-# to the web browser. Basically, a CGI program is called with the parameters
-# of the request passed in either in the environment (GET) or via $stdin
-# (POST), and everything it prints to $stdout is returned to the client.
-#
-# This file holds the CGI class. This class provides functionality for
-# retrieving HTTP request parameters, managing cookies, and generating HTML
-# output.
-#
-# The file CGI::Session provides session management functionality; see that
-# class for more details.
-#
-# See http://www.w3.org/CGI/ for more information on the CGI protocol.
-#
-# == Introduction
-#
-# CGI is a large class, providing several categories of methods, many of which
-# are mixed in from other modules. Some of the documentation is in this class,
-# some in the modules CGI::QueryExtension and CGI::HtmlExtension. See
-# CGI::Cookie for specific information on handling cookies, and cgi/session.rb
-# (CGI::Session) for information on sessions.
-#
-# For queries, CGI provides methods to get at environmental variables,
-# parameters, cookies, and multipart request data. For responses, CGI provides
-# methods for writing output and generating HTML.
-#
-# Read on for more details. Examples are provided at the bottom.
-#
-# == Queries
-#
-# The CGI class dynamically mixes in parameter and cookie-parsing
-# functionality, environmental variable access, and support for
-# parsing multipart requests (including uploaded files) from the
-# CGI::QueryExtension module.
-#
-# === Environmental Variables
-#
-# The standard CGI environmental variables are available as read-only
-# attributes of a CGI object. The following is a list of these variables:
-#
-#
-# AUTH_TYPE HTTP_HOST REMOTE_IDENT
-# CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
-# CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
-# GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
-# HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
-# HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
-# HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
-# HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
-# HTTP_CACHE_CONTROL REMOTE_ADDR
-# HTTP_FROM REMOTE_HOST
-#
-#
-# For each of these variables, there is a corresponding attribute with the
-# same name, except all lower case and without a preceding HTTP_.
-# +content_length+ and +server_port+ are integers; the rest are strings.
-#
-# === Parameters
-#
-# The method #params() returns a hash of all parameters in the request as
-# name/value-list pairs, where the value-list is an Array of one or more
-# values. The CGI object itself also behaves as a hash of parameter names
-# to values, but only returns a single value (as a String) for each
-# parameter name.
-#
-# For instance, suppose the request contains the parameter
-# "favourite_colours" with the multiple values "blue" and "green". The
-# following behavior would occur:
-#
-# cgi.params["favourite_colours"] # => ["blue", "green"]
-# cgi["favourite_colours"] # => "blue"
-#
-# If a parameter does not exist, the former method will return an empty
-# array, the latter an empty string. The simplest way to test for existence
-# of a parameter is by the #has_key? method.
-#
-# === Cookies
-#
-# HTTP Cookies are automatically parsed from the request. They are available
-# from the #cookies() accessor, which returns a hash from cookie name to
-# CGI::Cookie object.
-#
-# === Multipart requests
-#
-# If a request's method is POST and its content type is multipart/form-data,
-# then it may contain uploaded files. These are stored by the QueryExtension
-# module in the parameters of the request. The parameter name is the name
-# attribute of the file input field, as usual. However, the value is not
-# a string, but an IO object, either an IOString for small files, or a
-# Tempfile for larger ones. This object also has the additional singleton
-# methods:
-#
-# #local_path():: the path of the uploaded file on the local filesystem
-# #original_filename():: the name of the file on the client computer
-# #content_type():: the content type of the file
-#
-# == Responses
-#
-# The CGI class provides methods for sending header and content output to
-# the HTTP client, and mixes in methods for programmatic HTML generation
-# from CGI::HtmlExtension and CGI::TagMaker modules. The precise version of HTML
-# to use for HTML generation is specified at object creation time.
-#
-# === Writing output
-#
-# The simplest way to send output to the HTTP client is using the #out() method.
-# This takes the HTTP headers as a hash parameter, and the body content
-# via a block. The headers can be generated as a string using the #http_header()
-# method. The output stream can be written directly to using the #print()
-# method.
-#
-# === Generating HTML
-#
-# Each HTML element has a corresponding method for generating that
-# element as a String. The name of this method is the same as that
-# of the element, all lowercase. The attributes of the element are
-# passed in as a hash, and the body as a no-argument block that evaluates
-# to a String. The HTML generation module knows which elements are
-# always empty, and silently drops any passed-in body. It also knows
-# which elements require matching closing tags and which don't. However,
-# it does not know what attributes are legal for which elements.
-#
-# There are also some additional HTML generation methods mixed in from
-# the CGI::HtmlExtension module. These include individual methods for the
-# different types of form inputs, and methods for elements that commonly
-# take particular attributes where the attributes can be directly specified
-# as arguments, rather than via a hash.
-#
-# === Utility HTML escape and other methods like a function.
-#
-# There are some utility tool defined in cgi/util.rb .
-# And when include, you can use utility methods like a function.
-#
-# == Examples of use
-#
-# === Get form values
-#
-# require "cgi"
-# cgi = CGI.new
-# value = cgi['field_name'] # <== value string for 'field_name'
-# # if not 'field_name' included, then return "".
-# fields = cgi.keys # <== array of field names
-#
-# # returns true if form has 'field_name'
-# cgi.has_key?('field_name')
-# cgi.has_key?('field_name')
-# cgi.include?('field_name')
-#
-# CAUTION! <code>cgi['field_name']</code> returned an Array with the old
-# cgi.rb(included in Ruby 1.6)
-#
-# === Get form values as hash
-#
-# require "cgi"
-# cgi = CGI.new
-# params = cgi.params
-#
-# cgi.params is a hash.
-#
-# cgi.params['new_field_name'] = ["value"] # add new param
-# cgi.params['field_name'] = ["new_value"] # change value
-# cgi.params.delete('field_name') # delete param
-# cgi.params.clear # delete all params
-#
-#
-# === Save form values to file
-#
-# require "pstore"
-# db = PStore.new("query.db")
-# db.transaction do
-# db["params"] = cgi.params
-# end
-#
-#
-# === Restore form values from file
-#
-# require "pstore"
-# db = PStore.new("query.db")
-# db.transaction do
-# cgi.params = db["params"]
-# end
-#
-#
-# === Get multipart form values
-#
-# require "cgi"
-# cgi = CGI.new
-# value = cgi['field_name'] # <== value string for 'field_name'
-# value.read # <== body of value
-# value.local_path # <== path to local file of value
-# value.original_filename # <== original filename of value
-# value.content_type # <== content_type of value
-#
-# and value has StringIO or Tempfile class methods.
-#
-# === Get cookie values
-#
-# require "cgi"
-# cgi = CGI.new
-# values = cgi.cookies['name'] # <== array of 'name'
-# # if not 'name' included, then return [].
-# names = cgi.cookies.keys # <== array of cookie names
-#
-# and cgi.cookies is a hash.
-#
-# === Get cookie objects
-#
-# require "cgi"
-# cgi = CGI.new
-# for name, cookie in cgi.cookies
-# cookie.expires = Time.now + 30
-# end
-# cgi.out("cookie" => cgi.cookies) {"string"}
-#
-# cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
-#
-# require "cgi"
-# cgi = CGI.new
-# cgi.cookies['name'].expires = Time.now + 30
-# cgi.out("cookie" => cgi.cookies['name']) {"string"}
-#
-# === Print http header and html string to $DEFAULT_OUTPUT ($>)
-#
-# require "cgi"
-# cgi = CGI.new("html4") # add HTML generation methods
-# cgi.out do
-# cgi.html do
-# cgi.head do
-# cgi.title { "TITLE" }
-# end +
-# cgi.body do
-# cgi.form("ACTION" => "uri") do
-# cgi.p do
-# cgi.textarea("get_text") +
-# cgi.br +
-# cgi.submit
-# end
-# end +
-# cgi.pre do
-# CGI.escapeHTML(
-# "params: #{cgi.params.inspect}\n" +
-# "cookies: #{cgi.cookies.inspect}\n" +
-# ENV.collect do |key, value|
-# "#{key} --> #{value}\n"
-# end.join("")
-# )
-# end
-# end
-# end
-# end
-#
-# # add HTML generation methods
-# CGI.new("html3") # html3.2
-# CGI.new("html4") # html4.01 (Strict)
-# CGI.new("html4Tr") # html4.01 Transitional
-# CGI.new("html4Fr") # html4.01 Frameset
-# CGI.new("html5") # html5
-#
-# === Some utility methods
-#
-# require 'cgi/util'
-# CGI.escapeHTML('Usage: foo "bar" <baz>')
-#
-#
-# === Some utility methods like a function
-#
-# require 'cgi/util'
-# include CGI::Util
-# escapeHTML('Usage: foo "bar" <baz>')
-# h('Usage: foo "bar" <baz>') # alias
-#
-#
+require "cgi/escape"
+warn <<-WARNING, uplevel: Gem::BUNDLED_GEMS.uplevel if $VERBOSE
+CGI library is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
-class CGI
- VERSION = "0.3.6"
-end
-
-require 'cgi/core'
-require 'cgi/cookie'
-require 'cgi/util'
-CGI.autoload(:HtmlExtension, 'cgi/html')
+If you need to use the full features of CGI library, please add 'gem "cgi"' to your script
+or use Bundler to ensure you are using the cgi gem instead of this file.
+WARNING
diff --git a/lib/cgi/cgi.gemspec b/lib/cgi/cgi.gemspec
deleted file mode 100644
index 381c55a5ca..0000000000
--- a/lib/cgi/cgi.gemspec
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Support for the Common Gateway Interface protocol.}
- spec.description = %q{Support for the Common Gateway Interface protocol.}
- spec.homepage = "https://github.com/ruby/cgi"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = ">= 2.5.0"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.executables = []
-
- spec.files = [
- "LICENSE.txt",
- "README.md",
- *Dir["lib{.rb,/**/*.rb}", "bin/*"] ]
-
- spec.require_paths = ["lib"]
-
- if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
- spec.platform = 'java'
- spec.require_paths << "ext/java/org/jruby/ext/cgi/escape/lib"
- spec.files += Dir["ext/java/**/*.{rb}", "lib/cgi/escape.jar"]
- else
- spec.files += Dir["ext/cgi/**/*.{rb,c,h,sh}", "ext/cgi/escape/depend", "lib/cgi/escape.so"]
- spec.extensions = ["ext/cgi/escape/extconf.rb"]
- end
-end
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb
deleted file mode 100644
index 9498e2f9fa..0000000000
--- a/lib/cgi/cookie.rb
+++ /dev/null
@@ -1,209 +0,0 @@
-# frozen_string_literal: true
-require_relative 'util'
-class CGI
- # Class representing an HTTP cookie.
- #
- # In addition to its specific fields and methods, a Cookie instance
- # is a delegator to the array of its values.
- #
- # See RFC 2965.
- #
- # == Examples of use
- # cookie1 = CGI::Cookie.new("name", "value1", "value2", ...)
- # cookie1 = CGI::Cookie.new("name" => "name", "value" => "value")
- # cookie1 = CGI::Cookie.new('name' => 'name',
- # 'value' => ['value1', 'value2', ...],
- # 'path' => 'path', # optional
- # 'domain' => 'domain', # optional
- # 'expires' => Time.now, # optional
- # 'secure' => true, # optional
- # 'httponly' => true # optional
- # )
- #
- # cgi.out("cookie" => [cookie1, cookie2]) { "string" }
- #
- # name = cookie1.name
- # values = cookie1.value
- # path = cookie1.path
- # domain = cookie1.domain
- # expires = cookie1.expires
- # secure = cookie1.secure
- # httponly = cookie1.httponly
- #
- # cookie1.name = 'name'
- # cookie1.value = ['value1', 'value2', ...]
- # cookie1.path = 'path'
- # cookie1.domain = 'domain'
- # cookie1.expires = Time.now + 30
- # cookie1.secure = true
- # cookie1.httponly = true
- class Cookie < Array
- @@accept_charset="UTF-8" unless defined?(@@accept_charset)
-
- TOKEN_RE = %r"\A[[!-~]&&[^()<>@,;:\\\"/?=\[\]{}]]+\z"
- PATH_VALUE_RE = %r"\A[[ -~]&&[^;]]*\z"
- DOMAIN_VALUE_RE = %r"\A\.?(?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\.\g<label>)*\z"
-
- # Create a new CGI::Cookie object.
- #
- # :call-seq:
- # Cookie.new(name_string,*value)
- # Cookie.new(options_hash)
- #
- # +name_string+::
- # The name of the cookie; in this form, there is no #domain or
- # #expiration. The #path is gleaned from the +SCRIPT_NAME+ environment
- # variable, and #secure is false.
- # <tt>*value</tt>::
- # value or list of values of the cookie
- # +options_hash+::
- # A Hash of options to initialize this Cookie. Possible options are:
- #
- # name:: the name of the cookie. Required.
- # value:: the cookie's value or list of values.
- # path:: the path for which this cookie applies. Defaults to
- # the value of the +SCRIPT_NAME+ environment variable.
- # domain:: the domain for which this cookie applies.
- # expires:: the time at which this cookie expires, as a +Time+ object.
- # secure:: whether this cookie is a secure cookie or not (default to
- # false). Secure cookies are only transmitted to HTTPS
- # servers.
- # httponly:: whether this cookie is a HttpOnly cookie or not (default to
- # false). HttpOnly cookies are not available to javascript.
- #
- # These keywords correspond to attributes of the cookie object.
- def initialize(name = "", *value)
- @domain = nil
- @expires = nil
- if name.kind_of?(String)
- self.name = name
- self.path = (%r|\A(.*/)| =~ ENV["SCRIPT_NAME"] ? $1 : "")
- @secure = false
- @httponly = false
- return super(value)
- end
-
- options = name
- unless options.has_key?("name")
- raise ArgumentError, "`name' required"
- end
-
- self.name = options["name"]
- value = Array(options["value"])
- # simple support for IE
- self.path = options["path"] || (%r|\A(.*/)| =~ ENV["SCRIPT_NAME"] ? $1 : "")
- self.domain = options["domain"]
- @expires = options["expires"]
- @secure = options["secure"] == true
- @httponly = options["httponly"] == true
-
- super(value)
- end
-
- # Name of this cookie, as a +String+
- attr_reader :name
- # Set name of this cookie
- def name=(str)
- if str and !TOKEN_RE.match?(str)
- raise ArgumentError, "invalid name: #{str.dump}"
- end
- @name = str
- end
-
- # Path for which this cookie applies, as a +String+
- attr_reader :path
- # Set path for which this cookie applies
- def path=(str)
- if str and !PATH_VALUE_RE.match?(str)
- raise ArgumentError, "invalid path: #{str.dump}"
- end
- @path = str
- end
-
- # Domain for which this cookie applies, as a +String+
- attr_reader :domain
- # Set domain for which this cookie applies
- def domain=(str)
- if str and ((str = str.b).bytesize > 255 or !DOMAIN_VALUE_RE.match?(str))
- raise ArgumentError, "invalid domain: #{str.dump}"
- end
- @domain = str
- end
-
- # Time at which this cookie expires, as a +Time+
- attr_accessor :expires
- # True if this cookie is secure; false otherwise
- attr_reader :secure
- # True if this cookie is httponly; false otherwise
- attr_reader :httponly
-
- # Returns the value or list of values for this cookie.
- def value
- self
- end
-
- # Replaces the value of this cookie with a new value or list of values.
- def value=(val)
- replace(Array(val))
- end
-
- # Set whether the Cookie is a secure cookie or not.
- #
- # +val+ must be a boolean.
- def secure=(val)
- @secure = val if val == true or val == false
- @secure
- end
-
- # Set whether the Cookie is a httponly cookie or not.
- #
- # +val+ must be a boolean.
- def httponly=(val)
- @httponly = !!val
- end
-
- # Convert the Cookie to its string representation.
- def to_s
- val = collect{|v| CGI.escape(v) }.join("&")
- buf = "#{@name}=#{val}".dup
- buf << "; domain=#{@domain}" if @domain
- buf << "; path=#{@path}" if @path
- buf << "; expires=#{CGI.rfc1123_date(@expires)}" if @expires
- buf << "; secure" if @secure
- buf << "; HttpOnly" if @httponly
- buf
- end
-
- # Parse a raw cookie string into a hash of cookie-name=>Cookie
- # pairs.
- #
- # cookies = CGI::Cookie.parse("raw_cookie_string")
- # # { "name1" => cookie1, "name2" => cookie2, ... }
- #
- def self.parse(raw_cookie)
- cookies = Hash.new([])
- return cookies unless raw_cookie
-
- raw_cookie.split(/;\s?/).each do |pairs|
- name, values = pairs.split('=',2)
- next unless name and values
- values ||= ""
- values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) }
- if cookies.has_key?(name)
- values = cookies[name].value + values
- end
- cookies[name] = Cookie.new(name, *values)
- end
-
- cookies
- end
-
- # A summary of cookie string.
- def inspect
- "#<CGI::Cookie: #{self.to_s.inspect}>"
- end
-
- end # class Cookie
-end
-
-
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
deleted file mode 100644
index 62e606837a..0000000000
--- a/lib/cgi/core.rb
+++ /dev/null
@@ -1,900 +0,0 @@
-# frozen_string_literal: true
-#--
-# Methods for generating HTML, parsing CGI-related parameters, and
-# generating HTTP responses.
-#++
-class CGI
- unless const_defined?(:Util)
- module Util
- @@accept_charset = "UTF-8" # :nodoc:
- end
- include Util
- extend Util
- end
-
- $CGI_ENV = ENV # for FCGI support
-
- # String for carriage return
- CR = "\015"
-
- # String for linefeed
- LF = "\012"
-
- # Standard internet newline sequence
- EOL = CR + LF
-
- REVISION = '$Id$' #:nodoc:
-
- # Whether processing will be required in binary vs text
- NEEDS_BINMODE = File::BINARY != 0
-
- # Path separators in different environments.
- PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
-
- # HTTP status codes.
- HTTP_STATUS = {
- "OK" => "200 OK",
- "PARTIAL_CONTENT" => "206 Partial Content",
- "MULTIPLE_CHOICES" => "300 Multiple Choices",
- "MOVED" => "301 Moved Permanently",
- "REDIRECT" => "302 Found",
- "NOT_MODIFIED" => "304 Not Modified",
- "BAD_REQUEST" => "400 Bad Request",
- "AUTH_REQUIRED" => "401 Authorization Required",
- "FORBIDDEN" => "403 Forbidden",
- "NOT_FOUND" => "404 Not Found",
- "METHOD_NOT_ALLOWED" => "405 Method Not Allowed",
- "NOT_ACCEPTABLE" => "406 Not Acceptable",
- "LENGTH_REQUIRED" => "411 Length Required",
- "PRECONDITION_FAILED" => "412 Precondition Failed",
- "SERVER_ERROR" => "500 Internal Server Error",
- "NOT_IMPLEMENTED" => "501 Method Not Implemented",
- "BAD_GATEWAY" => "502 Bad Gateway",
- "VARIANT_ALSO_VARIES" => "506 Variant Also Negotiates"
- }
-
- # :startdoc:
-
- # Synonym for ENV.
- def env_table
- ENV
- end
-
- # Synonym for $stdin.
- def stdinput
- $stdin
- end
-
- # Synonym for $stdout.
- def stdoutput
- $stdout
- end
-
- private :env_table, :stdinput, :stdoutput
-
- # Create an HTTP header block as a string.
- #
- # :call-seq:
- # http_header(content_type_string="text/html")
- # http_header(headers_hash)
- #
- # Includes the empty line that ends the header block.
- #
- # +content_type_string+::
- # If this form is used, this string is the <tt>Content-Type</tt>
- # +headers_hash+::
- # A Hash of header values. The following header keys are recognized:
- #
- # type:: The Content-Type header. Defaults to "text/html"
- # charset:: The charset of the body, appended to the Content-Type header.
- # nph:: A boolean value. If true, prepend protocol string and status
- # code, and date; and sets default values for "server" and
- # "connection" if not explicitly set.
- # status::
- # The HTTP status code as a String, returned as the Status header. The
- # values are:
- #
- # OK:: 200 OK
- # PARTIAL_CONTENT:: 206 Partial Content
- # MULTIPLE_CHOICES:: 300 Multiple Choices
- # MOVED:: 301 Moved Permanently
- # REDIRECT:: 302 Found
- # NOT_MODIFIED:: 304 Not Modified
- # BAD_REQUEST:: 400 Bad Request
- # AUTH_REQUIRED:: 401 Authorization Required
- # FORBIDDEN:: 403 Forbidden
- # NOT_FOUND:: 404 Not Found
- # METHOD_NOT_ALLOWED:: 405 Method Not Allowed
- # NOT_ACCEPTABLE:: 406 Not Acceptable
- # LENGTH_REQUIRED:: 411 Length Required
- # PRECONDITION_FAILED:: 412 Precondition Failed
- # SERVER_ERROR:: 500 Internal Server Error
- # NOT_IMPLEMENTED:: 501 Method Not Implemented
- # BAD_GATEWAY:: 502 Bad Gateway
- # VARIANT_ALSO_VARIES:: 506 Variant Also Negotiates
- #
- # server:: The server software, returned as the Server header.
- # connection:: The connection type, returned as the Connection header (for
- # instance, "close".
- # length:: The length of the content that will be sent, returned as the
- # Content-Length header.
- # language:: The language of the content, returned as the Content-Language
- # header.
- # expires:: The time on which the current content expires, as a +Time+
- # object, returned as the Expires header.
- # cookie::
- # A cookie or cookies, returned as one or more Set-Cookie headers. The
- # value can be the literal string of the cookie; a CGI::Cookie object;
- # an Array of literal cookie strings or Cookie objects; or a hash all of
- # whose values are literal cookie strings or Cookie objects.
- #
- # These cookies are in addition to the cookies held in the
- # @output_cookies field.
- #
- # Other headers can also be set; they are appended as key: value.
- #
- # Examples:
- #
- # http_header
- # # Content-Type: text/html
- #
- # http_header("text/plain")
- # # Content-Type: text/plain
- #
- # http_header("nph" => true,
- # "status" => "OK", # == "200 OK"
- # # "status" => "200 GOOD",
- # "server" => ENV['SERVER_SOFTWARE'],
- # "connection" => "close",
- # "type" => "text/html",
- # "charset" => "iso-2022-jp",
- # # Content-Type: text/html; charset=iso-2022-jp
- # "length" => 103,
- # "language" => "ja",
- # "expires" => Time.now + 30,
- # "cookie" => [cookie1, cookie2],
- # "my_header1" => "my_value",
- # "my_header2" => "my_value")
- #
- # This method does not perform charset conversion.
- def http_header(options='text/html')
- if options.is_a?(String)
- content_type = options
- buf = _header_for_string(content_type)
- elsif options.is_a?(Hash)
- if options.size == 1 && options.has_key?('type')
- content_type = options['type']
- buf = _header_for_string(content_type)
- else
- buf = _header_for_hash(options.dup)
- end
- else
- raise ArgumentError.new("expected String or Hash but got #{options.class}")
- end
- if defined?(MOD_RUBY)
- _header_for_modruby(buf)
- return ''
- else
- buf << EOL # empty line of separator
- return buf
- end
- end # http_header()
-
- # This method is an alias for #http_header, when HTML5 tag maker is inactive.
- #
- # NOTE: use #http_header to create HTTP header blocks, this alias is only
- # provided for backwards compatibility.
- #
- # Using #header with the HTML5 tag maker will create a <header> element.
- alias :header :http_header
-
- def _no_crlf_check(str)
- if str
- str = str.to_s
- raise "A HTTP status or header field must not include CR and LF" if str =~ /[\r\n]/
- str
- else
- nil
- end
- end
- private :_no_crlf_check
-
- def _header_for_string(content_type) #:nodoc:
- buf = ''.dup
- if nph?()
- buf << "#{_no_crlf_check($CGI_ENV['SERVER_PROTOCOL']) || 'HTTP/1.0'} 200 OK#{EOL}"
- buf << "Date: #{CGI.rfc1123_date(Time.now)}#{EOL}"
- buf << "Server: #{_no_crlf_check($CGI_ENV['SERVER_SOFTWARE'])}#{EOL}"
- buf << "Connection: close#{EOL}"
- end
- buf << "Content-Type: #{_no_crlf_check(content_type)}#{EOL}"
- if @output_cookies
- @output_cookies.each {|cookie| buf << "Set-Cookie: #{_no_crlf_check(cookie)}#{EOL}" }
- end
- return buf
- end # _header_for_string
- private :_header_for_string
-
- def _header_for_hash(options) #:nodoc:
- buf = ''.dup
- ## add charset to option['type']
- options['type'] ||= 'text/html'
- charset = options.delete('charset')
- options['type'] += "; charset=#{charset}" if charset
- ## NPH
- options.delete('nph') if defined?(MOD_RUBY)
- if options.delete('nph') || nph?()
- protocol = _no_crlf_check($CGI_ENV['SERVER_PROTOCOL']) || 'HTTP/1.0'
- status = options.delete('status')
- status = HTTP_STATUS[status] || _no_crlf_check(status) || '200 OK'
- buf << "#{protocol} #{status}#{EOL}"
- buf << "Date: #{CGI.rfc1123_date(Time.now)}#{EOL}"
- options['server'] ||= $CGI_ENV['SERVER_SOFTWARE'] || ''
- options['connection'] ||= 'close'
- end
- ## common headers
- status = options.delete('status')
- buf << "Status: #{HTTP_STATUS[status] || _no_crlf_check(status)}#{EOL}" if status
- server = options.delete('server')
- buf << "Server: #{_no_crlf_check(server)}#{EOL}" if server
- connection = options.delete('connection')
- buf << "Connection: #{_no_crlf_check(connection)}#{EOL}" if connection
- type = options.delete('type')
- buf << "Content-Type: #{_no_crlf_check(type)}#{EOL}" #if type
- length = options.delete('length')
- buf << "Content-Length: #{_no_crlf_check(length)}#{EOL}" if length
- language = options.delete('language')
- buf << "Content-Language: #{_no_crlf_check(language)}#{EOL}" if language
- expires = options.delete('expires')
- buf << "Expires: #{CGI.rfc1123_date(expires)}#{EOL}" if expires
- ## cookie
- if cookie = options.delete('cookie')
- case cookie
- when String, Cookie
- buf << "Set-Cookie: #{_no_crlf_check(cookie)}#{EOL}"
- when Array
- arr = cookie
- arr.each {|c| buf << "Set-Cookie: #{_no_crlf_check(c)}#{EOL}" }
- when Hash
- hash = cookie
- hash.each_value {|c| buf << "Set-Cookie: #{_no_crlf_check(c)}#{EOL}" }
- end
- end
- if @output_cookies
- @output_cookies.each {|c| buf << "Set-Cookie: #{_no_crlf_check(c)}#{EOL}" }
- end
- ## other headers
- options.each do |key, value|
- buf << "#{_no_crlf_check(key)}: #{_no_crlf_check(value)}#{EOL}"
- end
- return buf
- end # _header_for_hash
- private :_header_for_hash
-
- def nph? #:nodoc:
- return /IIS\/(\d+)/ =~ $CGI_ENV['SERVER_SOFTWARE'] && $1.to_i < 5
- end
-
- def _header_for_modruby(buf) #:nodoc:
- request = Apache::request
- buf.scan(/([^:]+): (.+)#{EOL}/o) do |name, value|
- $stderr.printf("name:%s value:%s\n", name, value) if $DEBUG
- case name
- when 'Set-Cookie'
- request.headers_out.add(name, value)
- when /^status$/i
- request.status_line = value
- request.status = value.to_i
- when /^content-type$/i
- request.content_type = value
- when /^content-encoding$/i
- request.content_encoding = value
- when /^location$/i
- request.status = 302 if request.status == 200
- request.headers_out[name] = value
- else
- request.headers_out[name] = value
- end
- end
- request.send_http_header
- return ''
- end
- private :_header_for_modruby
-
- # Print an HTTP header and body to $DEFAULT_OUTPUT ($>)
- #
- # :call-seq:
- # cgi.out(content_type_string='text/html')
- # cgi.out(headers_hash)
- #
- # +content_type_string+::
- # If a string is passed, it is assumed to be the content type.
- # +headers_hash+::
- # This is a Hash of headers, similar to that used by #http_header.
- # +block+::
- # A block is required and should evaluate to the body of the response.
- #
- # <tt>Content-Length</tt> is automatically calculated from the size of
- # the String returned by the content block.
- #
- # If <tt>ENV['REQUEST_METHOD'] == "HEAD"</tt>, then only the header
- # is output (the content block is still required, but it is ignored).
- #
- # If the charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then the
- # content is converted to this charset, and the language is set to "ja".
- #
- # Example:
- #
- # cgi = CGI.new
- # cgi.out{ "string" }
- # # Content-Type: text/html
- # # Content-Length: 6
- # #
- # # string
- #
- # cgi.out("text/plain") { "string" }
- # # Content-Type: text/plain
- # # Content-Length: 6
- # #
- # # string
- #
- # cgi.out("nph" => true,
- # "status" => "OK", # == "200 OK"
- # "server" => ENV['SERVER_SOFTWARE'],
- # "connection" => "close",
- # "type" => "text/html",
- # "charset" => "iso-2022-jp",
- # # Content-Type: text/html; charset=iso-2022-jp
- # "language" => "ja",
- # "expires" => Time.now + (3600 * 24 * 30),
- # "cookie" => [cookie1, cookie2],
- # "my_header1" => "my_value",
- # "my_header2" => "my_value") { "string" }
- # # HTTP/1.1 200 OK
- # # Date: Sun, 15 May 2011 17:35:54 GMT
- # # Server: Apache 2.2.0
- # # Connection: close
- # # Content-Type: text/html; charset=iso-2022-jp
- # # Content-Length: 6
- # # Content-Language: ja
- # # Expires: Tue, 14 Jun 2011 17:35:54 GMT
- # # Set-Cookie: foo
- # # Set-Cookie: bar
- # # my_header1: my_value
- # # my_header2: my_value
- # #
- # # string
- def out(options = "text/html") # :yield:
-
- options = { "type" => options } if options.kind_of?(String)
- content = yield
- options["length"] = content.bytesize.to_s
- output = stdoutput
- output.binmode if defined? output.binmode
- output.print http_header(options)
- output.print content unless "HEAD" == env_table['REQUEST_METHOD']
- end
-
-
- # Print an argument or list of arguments to the default output stream
- #
- # cgi = CGI.new
- # cgi.print # default: cgi.print == $DEFAULT_OUTPUT.print
- def print(*options)
- stdoutput.print(*options)
- end
-
- # Parse an HTTP query string into a hash of key=>value pairs.
- #
- # params = CGI.parse("query_string")
- # # {"name1" => ["value1", "value2", ...],
- # # "name2" => ["value1", "value2", ...], ... }
- #
- def self.parse(query)
- params = {}
- query.split(/[&;]/).each do |pairs|
- key, value = pairs.split('=',2).collect{|v| CGI.unescape(v) }
-
- next unless key
-
- params[key] ||= []
- params[key].push(value) if value
- end
-
- params.default=[].freeze
- params
- end
-
- # Maximum content length of post data
- ##MAX_CONTENT_LENGTH = 2 * 1024 * 1024
-
- # Maximum number of request parameters when multipart
- MAX_MULTIPART_COUNT = 128
-
- # Mixin module that provides the following:
- #
- # 1. Access to the CGI environment variables as methods. See
- # documentation to the CGI class for a list of these variables. The
- # methods are exposed by removing the leading +HTTP_+ (if it exists) and
- # downcasing the name. For example, +auth_type+ will return the
- # environment variable +AUTH_TYPE+, and +accept+ will return the value
- # for +HTTP_ACCEPT+.
- #
- # 2. Access to cookies, including the cookies attribute.
- #
- # 3. Access to parameters, including the params attribute, and overloading
- # #[] to perform parameter value lookup by key.
- #
- # 4. The initialize_query method, for initializing the above
- # mechanisms, handling multipart forms, and allowing the
- # class to be used in "offline" mode.
- #
- module QueryExtension
-
- %w[ CONTENT_LENGTH SERVER_PORT ].each do |env|
- define_method(env.delete_prefix('HTTP_').downcase) do
- (val = env_table[env]) && Integer(val)
- end
- end
-
- %w[ AUTH_TYPE CONTENT_TYPE GATEWAY_INTERFACE PATH_INFO
- PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST
- REMOTE_IDENT REMOTE_USER REQUEST_METHOD SCRIPT_NAME
- SERVER_NAME SERVER_PROTOCOL SERVER_SOFTWARE
-
- HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
- HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST
- HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
- define_method(env.delete_prefix('HTTP_').downcase) do
- env_table[env]
- end
- end
-
- # Get the raw cookies as a string.
- def raw_cookie
- env_table["HTTP_COOKIE"]
- end
-
- # Get the raw RFC2965 cookies as a string.
- def raw_cookie2
- env_table["HTTP_COOKIE2"]
- end
-
- # Get the cookies as a hash of cookie-name=>Cookie pairs.
- attr_accessor :cookies
-
- # Get the parameters as a hash of name=>values pairs, where
- # values is an Array.
- attr_reader :params
-
- # Get the uploaded files as a hash of name=>values pairs
- attr_reader :files
-
- # Set all the parameters.
- def params=(hash)
- @params.clear
- @params.update(hash)
- end
-
- ##
- # Parses multipart form elements according to
- # http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
- #
- # Returns a hash of multipart form parameters with bodies of type StringIO or
- # Tempfile depending on whether the multipart form element exceeds 10 KB
- #
- # params[name => body]
- #
- def read_multipart(boundary, content_length)
- ## read first boundary
- stdin = stdinput
- first_line = "--#{boundary}#{EOL}"
- content_length -= first_line.bytesize
- status = stdin.read(first_line.bytesize)
- raise EOFError.new("no content body") unless status
- raise EOFError.new("bad content body") unless first_line == status
- ## parse and set params
- params = {}
- @files = {}
- boundary_rexp = /--#{Regexp.quote(boundary)}(#{EOL}|--)/
- boundary_size = "#{EOL}--#{boundary}#{EOL}".bytesize
- buf = ''.dup
- bufsize = 10 * 1024
- max_count = MAX_MULTIPART_COUNT
- n = 0
- tempfiles = []
- while true
- (n += 1) < max_count or raise StandardError.new("too many parameters.")
- ## create body (StringIO or Tempfile)
- body = create_body(bufsize < content_length)
- tempfiles << body if defined?(Tempfile) && body.kind_of?(Tempfile)
- class << body
- if method_defined?(:path)
- alias local_path path
- else
- def local_path
- nil
- end
- end
- attr_reader :original_filename, :content_type
- end
- ## find head and boundary
- head = nil
- separator = EOL * 2
- until head && matched = boundary_rexp.match(buf)
- if !head && pos = buf.index(separator)
- len = pos + EOL.bytesize
- head = buf[0, len]
- buf = buf[(pos+separator.bytesize)..-1]
- else
- if head && buf.size > boundary_size
- len = buf.size - boundary_size
- body.print(buf[0, len])
- buf[0, len] = ''
- end
- c = stdin.read(bufsize < content_length ? bufsize : content_length)
- raise EOFError.new("bad content body") if c.nil? || c.empty?
- buf << c
- content_length -= c.bytesize
- end
- end
- ## read to end of boundary
- m = matched
- len = m.begin(0)
- s = buf[0, len]
- if s =~ /(\r?\n)\z/
- s = buf[0, len - $1.bytesize]
- end
- body.print(s)
- buf = buf[m.end(0)..-1]
- boundary_end = m[1]
- content_length = -1 if boundary_end == '--'
- ## reset file cursor position
- body.rewind
- ## original filename
- /Content-Disposition:.* filename=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
- filename = $1 || $2 || ''.dup
- filename = CGI.unescape(filename) if unescape_filename?()
- body.instance_variable_set(:@original_filename, filename)
- ## content type
- /Content-Type: (.*)/i.match(head)
- (content_type = $1 || ''.dup).chomp!
- body.instance_variable_set(:@content_type, content_type)
- ## query parameter name
- /Content-Disposition:.* name=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
- name = $1 || $2 || ''
- if body.original_filename.empty?
- value=body.read.dup.force_encoding(@accept_charset)
- body.close! if defined?(Tempfile) && body.kind_of?(Tempfile)
- (params[name] ||= []) << value
- unless value.valid_encoding?
- if @accept_charset_error_block
- @accept_charset_error_block.call(name,value)
- else
- raise InvalidEncoding,"Accept-Charset encoding error"
- end
- end
- class << params[name].last;self;end.class_eval do
- define_method(:read){self}
- define_method(:original_filename){""}
- define_method(:content_type){""}
- end
- else
- (params[name] ||= []) << body
- @files[name]=body
- end
- ## break loop
- break if content_length == -1
- end
- raise EOFError, "bad boundary end of body part" unless boundary_end =~ /--/
- params.default = []
- params
- rescue Exception
- if tempfiles
- tempfiles.each {|t|
- if t.path
- t.close!
- end
- }
- end
- raise
- end # read_multipart
- private :read_multipart
- def create_body(is_large) #:nodoc:
- if is_large
- require 'tempfile'
- body = Tempfile.new('CGI', encoding: Encoding::ASCII_8BIT)
- else
- begin
- require 'stringio'
- body = StringIO.new("".b)
- rescue LoadError
- require 'tempfile'
- body = Tempfile.new('CGI', encoding: Encoding::ASCII_8BIT)
- end
- end
- body.binmode if defined? body.binmode
- return body
- end
- def unescape_filename? #:nodoc:
- user_agent = $CGI_ENV['HTTP_USER_AGENT']
- return false unless user_agent
- return /Mac/i.match(user_agent) && /Mozilla/i.match(user_agent) && !/MSIE/i.match(user_agent)
- end
-
- # offline mode. read name=value pairs on standard input.
- def read_from_cmdline
- require "shellwords"
-
- string = unless ARGV.empty?
- ARGV.join(' ')
- else
- if STDIN.tty?
- STDERR.print(
- %|(offline mode: enter name=value pairs on standard input)\n|
- )
- end
- array = readlines rescue nil
- if not array.nil?
- array.join(' ').gsub(/\n/n, '')
- else
- ""
- end
- end.gsub(/\\=/n, '%3D').gsub(/\\&/n, '%26')
-
- words = Shellwords.shellwords(string)
-
- if words.find{|x| /=/n.match(x) }
- words.join('&')
- else
- words.join('+')
- end
- 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.
- # Initialize the data from the query.
- #
- # Handles multipart forms (in particular, forms that involve file uploads).
- # Reads query parameters in the @params field, and cookies into @cookies.
- def initialize_query()
- if ("POST" == env_table['REQUEST_METHOD']) and
- %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?| =~ env_table['CONTENT_TYPE']
- current_max_multipart_length = @max_multipart_length.respond_to?(:call) ? @max_multipart_length.call : @max_multipart_length
- raise StandardError.new("too large multipart data.") if env_table['CONTENT_LENGTH'].to_i > current_max_multipart_length
- boundary = $1.dup
- @multipart = true
- @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
- else
- @multipart = false
- @params = CGI.parse(
- case env_table['REQUEST_METHOD']
- when "GET", "HEAD"
- if defined?(MOD_RUBY)
- Apache::request.args or ""
- else
- env_table['QUERY_STRING'] or ""
- end
- when "POST"
- stdinput.binmode if defined? stdinput.binmode
- stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or ''
- else
- read_from_cmdline
- end.dup.force_encoding(@accept_charset)
- )
- unless Encoding.find(@accept_charset) == Encoding::ASCII_8BIT
- @params.each do |key,values|
- values.each do |value|
- unless value.valid_encoding?
- if @accept_charset_error_block
- @accept_charset_error_block.call(key,value)
- else
- raise InvalidEncoding,"Accept-Charset encoding error"
- end
- end
- end
- end
- end
- end
-
- @cookies = CGI::Cookie.parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
- end
- private :initialize_query
-
- # Returns whether the form contained multipart/form-data
- def multipart?
- @multipart
- end
-
- # Get the value for the parameter with a given key.
- #
- # If the parameter has multiple values, only the first will be
- # retrieved; use #params to get the array of values.
- def [](key)
- params = @params[key]
- return '' unless params
- value = params[0]
- if @multipart
- if value
- return value
- elsif defined? StringIO
- StringIO.new("".b)
- else
- Tempfile.new("CGI",encoding: Encoding::ASCII_8BIT)
- end
- else
- str = if value then value.dup else "" end
- str
- end
- end
-
- # Return all query parameter names as an array of String.
- def keys(*args)
- @params.keys(*args)
- end
-
- # Returns true if a given query string parameter exists.
- def has_key?(*args)
- @params.has_key?(*args)
- end
- alias key? has_key?
- alias include? has_key?
-
- end # QueryExtension
-
- # Exception raised when there is an invalid encoding detected
- class InvalidEncoding < Exception; end
-
- # @@accept_charset is default accept character set.
- # This default value default is "UTF-8"
- # If you want to change the default accept character set
- # when create a new CGI instance, set this:
- #
- # CGI.accept_charset = "EUC-JP"
- #
- @@accept_charset="UTF-8" if false # needed for rdoc?
-
- # Return the accept character set for all new CGI instances.
- def self.accept_charset
- @@accept_charset
- end
-
- # Set the accept character set for all new CGI instances.
- def self.accept_charset=(accept_charset)
- @@accept_charset=accept_charset
- end
-
- # Return the accept character set for this CGI instance.
- attr_reader :accept_charset
-
- # @@max_multipart_length is the maximum length of multipart data.
- # The default value is 128 * 1024 * 1024 bytes
- #
- # The default can be set to something else in the CGI constructor,
- # via the :max_multipart_length key in the option hash.
- #
- # See CGI.new documentation.
- #
- @@max_multipart_length= 128 * 1024 * 1024
-
- # Create a new CGI instance.
- #
- # :call-seq:
- # CGI.new(tag_maker) { block }
- # CGI.new(options_hash = {}) { block }
- #
- #
- # <tt>tag_maker</tt>::
- # This is the same as using the +options_hash+ form with the value <tt>{
- # :tag_maker => tag_maker }</tt> Note that it is recommended to use the
- # +options_hash+ form, since it also allows you specify the charset you
- # will accept.
- # <tt>options_hash</tt>::
- # A Hash that recognizes three options:
- #
- # <tt>:accept_charset</tt>::
- # specifies encoding of received query string. If omitted,
- # <tt>@@accept_charset</tt> is used. If the encoding is not valid, a
- # CGI::InvalidEncoding will be raised.
- #
- # Example. Suppose <tt>@@accept_charset</tt> is "UTF-8"
- #
- # when not specified:
- #
- # cgi=CGI.new # @accept_charset # => "UTF-8"
- #
- # when specified as "EUC-JP":
- #
- # cgi=CGI.new(:accept_charset => "EUC-JP") # => "EUC-JP"
- #
- # <tt>:tag_maker</tt>::
- # String that specifies which version of the HTML generation methods to
- # use. If not specified, no HTML generation methods will be loaded.
- #
- # The following values are supported:
- #
- # "html3":: HTML 3.x
- # "html4":: HTML 4.0
- # "html4Tr":: HTML 4.0 Transitional
- # "html4Fr":: HTML 4.0 with Framesets
- # "html5":: HTML 5
- #
- # <tt>:max_multipart_length</tt>::
- # Specifies maximum length of multipart data. Can be an Integer scalar or
- # a lambda, that will be evaluated when the request is parsed. This
- # allows more complex logic to be set when determining whether to accept
- # multipart data (e.g. consult a registered users upload allowance)
- #
- # Default is 128 * 1024 * 1024 bytes
- #
- # cgi=CGI.new(:max_multipart_length => 268435456) # simple scalar
- #
- # cgi=CGI.new(:max_multipart_length => -> {check_filesystem}) # lambda
- #
- # <tt>block</tt>::
- # If provided, the block is called when an invalid encoding is
- # encountered. For example:
- #
- # encoding_errors={}
- # cgi=CGI.new(:accept_charset=>"EUC-JP") do |name,value|
- # encoding_errors[name] = value
- # end
- #
- # Finally, if the CGI object is not created in a standard CGI call
- # environment (that is, it can't locate REQUEST_METHOD in its environment),
- # then it will run in "offline" mode. In this mode, it reads its parameters
- # from the command line or (failing that) from standard input. Otherwise,
- # cookies and other parameters are parsed automatically from the standard
- # CGI locations, which varies according to the REQUEST_METHOD.
- def initialize(options = {}, &block) # :yields: name, value
- @accept_charset_error_block = block_given? ? block : nil
- @options={
- :accept_charset=>@@accept_charset,
- :max_multipart_length=>@@max_multipart_length
- }
- case options
- when Hash
- @options.merge!(options)
- when String
- @options[:tag_maker]=options
- end
- @accept_charset=@options[:accept_charset]
- @max_multipart_length=@options[:max_multipart_length]
- if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE")
- Apache.request.setup_cgi_env
- end
-
- extend QueryExtension
- @multipart = false
-
- initialize_query() # set @params, @cookies
- @output_cookies = nil
- @output_hidden = nil
-
- case @options[:tag_maker]
- when "html3"
- require_relative 'html'
- extend Html3
- extend HtmlExtension
- when "html4"
- require_relative 'html'
- extend Html4
- extend HtmlExtension
- when "html4Tr"
- require_relative 'html'
- extend Html4Tr
- extend HtmlExtension
- when "html4Fr"
- require_relative 'html'
- extend Html4Tr
- extend Html4Fr
- extend HtmlExtension
- when "html5"
- require_relative 'html'
- extend Html5
- extend HtmlExtension
- end
- end
-
-end # class CGI
diff --git a/lib/cgi/escape.rb b/lib/cgi/escape.rb
new file mode 100644
index 0000000000..555d24a5da
--- /dev/null
+++ b/lib/cgi/escape.rb
@@ -0,0 +1,232 @@
+# frozen_string_literal: true
+
+# Since Ruby 4.0, \CGI is a small holder for various escaping methods, included from CGI::Escape
+#
+# require 'cgi/escape'
+#
+# CGI.escape("Ruby programming language")
+# #=> "Ruby+programming+language"
+# CGI.escapeURIComponent("Ruby programming language")
+# #=> "Ruby%20programming%20language"
+#
+# See CGI::Escape module for methods list and their description.
+class CGI
+ module Escape; end
+ include Escape
+ extend Escape
+ module EscapeExt; end # :nodoc:
+end
+
+# Web-related escape/unescape functionality.
+module CGI::Escape
+ @@accept_charset = Encoding::UTF_8 unless defined?(@@accept_charset)
+
+ # URL-encode a string into application/x-www-form-urlencoded.
+ # Space characters (<tt>" "</tt>) are encoded with plus signs (<tt>"+"</tt>)
+ # url_encoded_string = CGI.escape("'Stop!' said Fred")
+ # # => "%27Stop%21%27+said+Fred"
+ def escape(string)
+ encoding = string.encoding
+ buffer = string.b
+ buffer.gsub!(/([^ a-zA-Z0-9_.\-~]+)/) do |m|
+ '%' + m.unpack('H2' * m.bytesize).join('%').upcase
+ end
+ buffer.tr!(' ', '+')
+ buffer.force_encoding(encoding)
+ end
+
+ # URL-decode an application/x-www-form-urlencoded string with encoding(optional).
+ # string = CGI.unescape("%27Stop%21%27+said+Fred")
+ # # => "'Stop!' said Fred"
+ def unescape(string, encoding = @@accept_charset)
+ str = string.tr('+', ' ')
+ str = str.b
+ str.gsub!(/((?:%[0-9a-fA-F]{2})+)/) do |m|
+ [m.delete('%')].pack('H*')
+ end
+ str.force_encoding(encoding)
+ str.valid_encoding? ? str : str.force_encoding(string.encoding)
+ end
+
+ # URL-encode a string following RFC 3986
+ # Space characters (<tt>" "</tt>) are encoded with (<tt>"%20"</tt>)
+ # url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
+ # # => "%27Stop%21%27%20said%20Fred"
+ def escapeURIComponent(string)
+ encoding = string.encoding
+ buffer = string.b
+ buffer.gsub!(/([^a-zA-Z0-9_.\-~]+)/) do |m|
+ '%' + m.unpack('H2' * m.bytesize).join('%').upcase
+ end
+ buffer.force_encoding(encoding)
+ end
+ alias escape_uri_component escapeURIComponent
+
+ # URL-decode a string following RFC 3986 with encoding(optional).
+ # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
+ # # => "'Stop!'+said Fred"
+ def unescapeURIComponent(string, encoding = @@accept_charset)
+ str = string.b
+ str.gsub!(/((?:%[0-9a-fA-F]{2})+)/) do |m|
+ [m.delete('%')].pack('H*')
+ end
+ str.force_encoding(encoding)
+ str.valid_encoding? ? str : str.force_encoding(string.encoding)
+ end
+
+ alias unescape_uri_component unescapeURIComponent
+
+ # The set of special characters and their escaped values
+ TABLE_FOR_ESCAPE_HTML__ = { # :nodoc:
+ "'" => '&#39;',
+ '&' => '&amp;',
+ '"' => '&quot;',
+ '<' => '&lt;',
+ '>' => '&gt;',
+ }
+
+ # \Escape special characters in HTML, namely <tt>'&\"<></tt>
+ # CGI.escapeHTML('Usage: foo "bar" <baz>')
+ # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
+ def escapeHTML(string)
+ enc = string.encoding
+ unless enc.ascii_compatible?
+ if enc.dummy?
+ origenc = enc
+ enc = Encoding::Converter.asciicompat_encoding(enc)
+ string = enc ? string.encode(enc) : string.b
+ end
+ table = Hash[TABLE_FOR_ESCAPE_HTML__.map {|pair|pair.map {|s|s.encode(enc)}}]
+ string = string.gsub(/#{"['&\"<>]".encode(enc)}/, table)
+ string.encode!(origenc) if origenc
+ string
+ else
+ string = string.b
+ string.gsub!(/['&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
+ string.force_encoding(enc)
+ end
+ end
+
+ # Unescape a string that has been HTML-escaped
+ # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
+ # # => "Usage: foo \"bar\" <baz>"
+ def unescapeHTML(string)
+ enc = string.encoding
+ unless enc.ascii_compatible?
+ if enc.dummy?
+ origenc = enc
+ enc = Encoding::Converter.asciicompat_encoding(enc)
+ string = enc ? string.encode(enc) : string.b
+ end
+ string = string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do
+ case $1.encode(Encoding::US_ASCII)
+ when 'apos' then "'".encode(enc)
+ when 'amp' then '&'.encode(enc)
+ when 'quot' then '"'.encode(enc)
+ when 'gt' then '>'.encode(enc)
+ when 'lt' then '<'.encode(enc)
+ when /\A#0*(\d+)\z/ then $1.to_i.chr(enc)
+ when /\A#x([0-9a-f]+)\z/i then $1.hex.chr(enc)
+ end
+ end
+ string.encode!(origenc) if origenc
+ return string
+ end
+ return string unless string.include? '&'
+ charlimit = case enc
+ when Encoding::UTF_8; 0x10ffff
+ when Encoding::ISO_8859_1; 256
+ else 128
+ end
+ string = string.b
+ string.gsub!(/&(apos|amp|quot|gt|lt|\#[0-9]+|\#[xX][0-9A-Fa-f]+);/) do
+ match = $1.dup
+ case match
+ when 'apos' then "'"
+ when 'amp' then '&'
+ when 'quot' then '"'
+ when 'gt' then '>'
+ when 'lt' then '<'
+ when /\A#0*(\d+)\z/
+ n = $1.to_i
+ if n < charlimit
+ n.chr(enc)
+ else
+ "&##{$1};"
+ end
+ when /\A#x([0-9a-f]+)\z/i
+ n = $1.hex
+ if n < charlimit
+ n.chr(enc)
+ else
+ "&#x#{$1};"
+ end
+ else
+ "&#{match};"
+ end
+ end
+ string.force_encoding enc
+ end
+
+ alias escape_html escapeHTML
+ alias h escapeHTML
+
+ alias unescape_html unescapeHTML
+
+ # TruffleRuby runs the pure-Ruby variant faster, do not use the C extension there
+ unless RUBY_ENGINE == 'truffleruby'
+ begin
+ require 'cgi/escape.so'
+ rescue LoadError
+ end
+ end
+
+ # \Escape only the tags of certain HTML elements in +string+.
+ #
+ # Takes an element or elements or array of elements. Each element
+ # is specified by the name of the element, without angle brackets.
+ # This matches both the start and the end tag of that element.
+ # The attribute list of the open tag will also be escaped (for
+ # instance, the double-quotes surrounding attribute values).
+ #
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
+ #
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
+ def escapeElement(string, *elements)
+ elements = elements[0] if elements[0].kind_of?(Array)
+ unless elements.empty?
+ string.gsub(/<\/?(?:#{elements.join("|")})\b[^<>]*+>?/im) do
+ CGI.escapeHTML($&)
+ end
+ else
+ string
+ end
+ end
+
+ # Undo escaping such as that done by CGI.escapeElement
+ #
+ # print CGI.unescapeElement(
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
+ # # "&lt;BR&gt;<A HREF="url"></A>"
+ #
+ # print CGI.unescapeElement(
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
+ # # "&lt;BR&gt;<A HREF="url"></A>"
+ def unescapeElement(string, *elements)
+ elements = elements[0] if elements[0].kind_of?(Array)
+ unless elements.empty?
+ string.gsub(/&lt;\/?(?:#{elements.join("|")})\b(?>[^&]+|&(?![gl]t;)\w+;)*(?:&gt;)?/im) do
+ unescapeHTML($&)
+ end
+ else
+ string
+ end
+ end
+
+ alias escape_element escapeElement
+
+ alias unescape_element unescapeElement
+
+end
diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb
deleted file mode 100644
index 1543943320..0000000000
--- a/lib/cgi/html.rb
+++ /dev/null
@@ -1,1035 +0,0 @@
-# frozen_string_literal: true
-class CGI
- # Base module for HTML-generation mixins.
- #
- # Provides methods for code generation for tags following
- # the various DTD element types.
- module TagMaker # :nodoc:
-
- # Generate code for an element with required start and end tags.
- #
- # - -
- def nn_element(element, attributes = {})
- s = nOE_element(element, attributes)
- if block_given?
- s << yield.to_s
- end
- s << "</#{element.upcase}>"
- end
-
- def nn_element_def(attributes = {}, &block)
- nn_element(__callee__, attributes, &block)
- end
-
- # Generate code for an empty element.
- #
- # - O EMPTY
- def nOE_element(element, attributes = {})
- attributes={attributes=>nil} if attributes.kind_of?(String)
- s = "<#{element.upcase}".dup
- attributes.each do|name, value|
- next unless value
- s << " "
- s << CGI.escapeHTML(name.to_s)
- if value != true
- s << '="'
- s << CGI.escapeHTML(value.to_s)
- s << '"'
- end
- end
- s << ">"
- end
-
- def nOE_element_def(attributes = {}, &block)
- nOE_element(__callee__, attributes, &block)
- end
-
-
- # Generate code for an element for which the end (and possibly the
- # start) tag is optional.
- #
- # O O or - O
- def nO_element(element, attributes = {})
- s = nOE_element(element, attributes)
- if block_given?
- s << yield.to_s
- s << "</#{element.upcase}>"
- end
- s
- end
-
- def nO_element_def(attributes = {}, &block)
- nO_element(__callee__, attributes, &block)
- end
-
- end # TagMaker
-
-
- # Mixin module providing HTML generation methods.
- #
- # For example,
- # cgi.a("http://www.example.com") { "Example" }
- # # => "<A HREF=\"http://www.example.com\">Example</A>"
- #
- # Modules Html3, Html4, etc., contain more basic HTML-generation methods
- # (+#title+, +#h1+, etc.).
- #
- # See class CGI for a detailed example.
- #
- module HtmlExtension
-
-
- # Generate an Anchor element as a string.
- #
- # +href+ can either be a string, giving the URL
- # for the HREF attribute, or it can be a hash of
- # the element's attributes.
- #
- # The body of the element is the string returned by the no-argument
- # block passed in.
- #
- # a("http://www.example.com") { "Example" }
- # # => "<A HREF=\"http://www.example.com\">Example</A>"
- #
- # a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" }
- # # => "<A HREF=\"http://www.example.com\" TARGET=\"_top\">Example</A>"
- #
- def a(href = "") # :yield:
- attributes = if href.kind_of?(String)
- { "HREF" => href }
- else
- href
- end
- super(attributes)
- end
-
- # Generate a Document Base URI element as a String.
- #
- # +href+ can either by a string, giving the base URL for the HREF
- # attribute, or it can be a has of the element's attributes.
- #
- # The passed-in no-argument block is ignored.
- #
- # base("http://www.example.com/cgi")
- # # => "<BASE HREF=\"http://www.example.com/cgi\">"
- def base(href = "") # :yield:
- attributes = if href.kind_of?(String)
- { "HREF" => href }
- else
- href
- end
- super(attributes)
- end
-
- # Generate a BlockQuote element as a string.
- #
- # +cite+ can either be a string, give the URI for the source of
- # the quoted text, or a hash, giving all attributes of the element,
- # or it can be omitted, in which case the element has no attributes.
- #
- # The body is provided by the passed-in no-argument block
- #
- # blockquote("http://www.example.com/quotes/foo.html") { "Foo!" }
- # #=> "<BLOCKQUOTE CITE=\"http://www.example.com/quotes/foo.html\">Foo!</BLOCKQUOTE>
- def blockquote(cite = {}) # :yield:
- attributes = if cite.kind_of?(String)
- { "CITE" => cite }
- else
- cite
- end
- super(attributes)
- end
-
-
- # Generate a Table Caption element as a string.
- #
- # +align+ can be a string, giving the alignment of the caption
- # (one of top, bottom, left, or right). It can be a hash of
- # all the attributes of the element. Or it can be omitted.
- #
- # The body of the element is provided by the passed-in no-argument block.
- #
- # caption("left") { "Capital Cities" }
- # # => <CAPTION ALIGN=\"left\">Capital Cities</CAPTION>
- def caption(align = {}) # :yield:
- attributes = if align.kind_of?(String)
- { "ALIGN" => align }
- else
- align
- end
- super(attributes)
- end
-
-
- # Generate a Checkbox Input element as a string.
- #
- # The attributes of the element can be specified as three arguments,
- # +name+, +value+, and +checked+. +checked+ is a boolean value;
- # if true, the CHECKED attribute will be included in the element.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # checkbox("name")
- # # = checkbox("NAME" => "name")
- #
- # checkbox("name", "value")
- # # = checkbox("NAME" => "name", "VALUE" => "value")
- #
- # checkbox("name", "value", true)
- # # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true)
- def checkbox(name = "", value = nil, checked = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "checkbox", "NAME" => name,
- "VALUE" => value, "CHECKED" => checked }
- else
- name["TYPE"] = "checkbox"
- name
- end
- input(attributes)
- end
-
- # Generate a sequence of checkbox elements, as a String.
- #
- # The checkboxes will all have the same +name+ attribute.
- # Each checkbox is followed by a label.
- # There will be one checkbox for each value. Each value
- # can be specified as a String, which will be used both
- # as the value of the VALUE attribute and as the label
- # for that checkbox. A single-element array has the
- # same effect.
- #
- # Each value can also be specified as a three-element array.
- # The first element is the VALUE attribute; the second is the
- # label; and the third is a boolean specifying whether this
- # checkbox is CHECKED.
- #
- # Each value can also be specified as a two-element
- # array, by omitting either the value element (defaults
- # to the same as the label), or the boolean checked element
- # (defaults to false).
- #
- # checkbox_group("name", "foo", "bar", "baz")
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
- #
- # checkbox_group("name", ["foo"], ["bar", true], "baz")
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
- # # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
- #
- # checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
- # # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar
- # # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
- #
- # checkbox_group("NAME" => "name",
- # "VALUES" => ["foo", "bar", "baz"])
- #
- # checkbox_group("NAME" => "name",
- # "VALUES" => [["foo"], ["bar", true], "baz"])
- #
- # checkbox_group("NAME" => "name",
- # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
- def checkbox_group(name = "", *values)
- if name.kind_of?(Hash)
- values = name["VALUES"]
- name = name["NAME"]
- end
- values.collect{|value|
- if value.kind_of?(String)
- checkbox(name, value) + value
- else
- if value[-1] == true || value[-1] == false
- checkbox(name, value[0], value[-1]) +
- value[-2]
- else
- checkbox(name, value[0]) +
- value[-1]
- end
- end
- }.join
- end
-
-
- # Generate an File Upload Input element as a string.
- #
- # The attributes of the element can be specified as three arguments,
- # +name+, +size+, and +maxlength+. +maxlength+ is the maximum length
- # of the file's _name_, not of the file's _contents_.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # See #multipart_form() for forms that include file uploads.
- #
- # file_field("name")
- # # <INPUT TYPE="file" NAME="name" SIZE="20">
- #
- # file_field("name", 40)
- # # <INPUT TYPE="file" NAME="name" SIZE="40">
- #
- # file_field("name", 40, 100)
- # # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">
- #
- # file_field("NAME" => "name", "SIZE" => 40)
- # # <INPUT TYPE="file" NAME="name" SIZE="40">
- def file_field(name = "", size = 20, maxlength = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "file", "NAME" => name,
- "SIZE" => size.to_s }
- else
- name["TYPE"] = "file"
- name
- end
- attributes["MAXLENGTH"] = maxlength.to_s if maxlength
- input(attributes)
- end
-
-
- # Generate a Form element as a string.
- #
- # +method+ should be either "get" or "post", and defaults to the latter.
- # +action+ defaults to the current CGI script name. +enctype+
- # defaults to "application/x-www-form-urlencoded".
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # See also #multipart_form() for forms that include file uploads.
- #
- # form{ "string" }
- # # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
- # form("get") { "string" }
- # # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
- # form("get", "url") { "string" }
- # # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
- # form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
- # # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
- def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
- attributes = if method.kind_of?(String)
- { "METHOD" => method, "ACTION" => action,
- "ENCTYPE" => enctype }
- else
- unless method.has_key?("METHOD")
- method["METHOD"] = "post"
- end
- unless method.has_key?("ENCTYPE")
- method["ENCTYPE"] = enctype
- end
- method
- end
- if block_given?
- body = yield
- else
- body = ""
- end
- if @output_hidden
- body << @output_hidden.collect{|k,v|
- "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
- }.join
- end
- super(attributes){body}
- end
-
- # Generate a Hidden Input element as a string.
- #
- # The attributes of the element can be specified as two arguments,
- # +name+ and +value+.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # hidden("name")
- # # <INPUT TYPE="hidden" NAME="name">
- #
- # hidden("name", "value")
- # # <INPUT TYPE="hidden" NAME="name" VALUE="value">
- #
- # hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
- # # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
- def hidden(name = "", value = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "hidden", "NAME" => name, "VALUE" => value }
- else
- name["TYPE"] = "hidden"
- name
- end
- input(attributes)
- end
-
- # Generate a top-level HTML element as a string.
- #
- # The attributes of the element are specified as a hash. The
- # pseudo-attribute "PRETTY" can be used to specify that the generated
- # HTML string should be indented. "PRETTY" can also be specified as
- # a string as the sole argument to this method. The pseudo-attribute
- # "DOCTYPE", if given, is used as the leading DOCTYPE SGML tag; it
- # should include the entire text of this tag, including angle brackets.
- #
- # The body of the html element is supplied as a block.
- #
- # html{ "string" }
- # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
- #
- # html("LANG" => "ja") { "string" }
- # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
- #
- # html("DOCTYPE" => false) { "string" }
- # # <HTML>string</HTML>
- #
- # html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">') { "string" }
- # # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
- #
- # html("PRETTY" => " ") { "<BODY></BODY>" }
- # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
- # # <HTML>
- # # <BODY>
- # # </BODY>
- # # </HTML>
- #
- # html("PRETTY" => "\t") { "<BODY></BODY>" }
- # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
- # # <HTML>
- # # <BODY>
- # # </BODY>
- # # </HTML>
- #
- # html("PRETTY") { "<BODY></BODY>" }
- # # = html("PRETTY" => " ") { "<BODY></BODY>" }
- #
- # html(if $VERBOSE then "PRETTY" end) { "HTML string" }
- #
- def html(attributes = {}) # :yield:
- if nil == attributes
- attributes = {}
- elsif "PRETTY" == attributes
- attributes = { "PRETTY" => true }
- end
- pretty = attributes.delete("PRETTY")
- pretty = " " if true == pretty
- buf = "".dup
-
- if attributes.has_key?("DOCTYPE")
- if attributes["DOCTYPE"]
- buf << attributes.delete("DOCTYPE")
- else
- attributes.delete("DOCTYPE")
- end
- else
- buf << doctype
- end
-
- buf << super(attributes)
-
- if pretty
- CGI.pretty(buf, pretty)
- else
- buf
- end
-
- end
-
- # Generate an Image Button Input element as a string.
- #
- # +src+ is the URL of the image to use for the button. +name+
- # is the input name. +alt+ is the alternative text for the image.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # image_button("url")
- # # <INPUT TYPE="image" SRC="url">
- #
- # image_button("url", "name", "string")
- # # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">
- #
- # image_button("SRC" => "url", "ALT" => "string")
- # # <INPUT TYPE="image" SRC="url" ALT="string">
- def image_button(src = "", name = nil, alt = nil)
- attributes = if src.kind_of?(String)
- { "TYPE" => "image", "SRC" => src, "NAME" => name,
- "ALT" => alt }
- else
- src["TYPE"] = "image"
- src["SRC"] ||= ""
- src
- end
- input(attributes)
- end
-
-
- # Generate an Image element as a string.
- #
- # +src+ is the URL of the image. +alt+ is the alternative text for
- # the image. +width+ is the width of the image, and +height+ is
- # its height.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # img("src", "alt", 100, 50)
- # # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
- #
- # img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50)
- # # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
- def img(src = "", alt = "", width = nil, height = nil)
- attributes = if src.kind_of?(String)
- { "SRC" => src, "ALT" => alt }
- else
- src
- end
- attributes["WIDTH"] = width.to_s if width
- attributes["HEIGHT"] = height.to_s if height
- super(attributes)
- end
-
-
- # Generate a Form element with multipart encoding as a String.
- #
- # Multipart encoding is used for forms that include file uploads.
- #
- # +action+ is the action to perform. +enctype+ is the encoding
- # type, which defaults to "multipart/form-data".
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # multipart_form{ "string" }
- # # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
- #
- # multipart_form("url") { "string" }
- # # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
- def multipart_form(action = nil, enctype = "multipart/form-data")
- attributes = if action == nil
- { "METHOD" => "post", "ENCTYPE" => enctype }
- elsif action.kind_of?(String)
- { "METHOD" => "post", "ACTION" => action,
- "ENCTYPE" => enctype }
- else
- unless action.has_key?("METHOD")
- action["METHOD"] = "post"
- end
- unless action.has_key?("ENCTYPE")
- action["ENCTYPE"] = enctype
- end
- action
- end
- if block_given?
- form(attributes){ yield }
- else
- form(attributes)
- end
- end
-
-
- # Generate a Password Input element as a string.
- #
- # +name+ is the name of the input field. +value+ is its default
- # value. +size+ is the size of the input field display. +maxlength+
- # is the maximum length of the inputted password.
- #
- # Alternatively, attributes can be specified as a hash.
- #
- # password_field("name")
- # # <INPUT TYPE="password" NAME="name" SIZE="40">
- #
- # password_field("name", "value")
- # # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">
- #
- # password_field("password", "value", 80, 200)
- # # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
- #
- # password_field("NAME" => "name", "VALUE" => "value")
- # # <INPUT TYPE="password" NAME="name" VALUE="value">
- def password_field(name = "", value = nil, size = 40, maxlength = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "password", "NAME" => name,
- "VALUE" => value, "SIZE" => size.to_s }
- else
- name["TYPE"] = "password"
- name
- end
- attributes["MAXLENGTH"] = maxlength.to_s if maxlength
- input(attributes)
- end
-
- # Generate a Select element as a string.
- #
- # +name+ is the name of the element. The +values+ are the options that
- # can be selected from the Select menu. Each value can be a String or
- # a one, two, or three-element Array. If a String or a one-element
- # Array, this is both the value of that option and the text displayed for
- # it. If a three-element Array, the elements are the option value, displayed
- # text, and a boolean value specifying whether this option starts as selected.
- # The two-element version omits either the option value (defaults to the same
- # as the display text) or the boolean selected specifier (defaults to false).
- #
- # The attributes and options can also be specified as a hash. In this
- # case, options are specified as an array of values as described above,
- # with the hash key of "VALUES".
- #
- # popup_menu("name", "foo", "bar", "baz")
- # # <SELECT NAME="name">
- # # <OPTION VALUE="foo">foo</OPTION>
- # # <OPTION VALUE="bar">bar</OPTION>
- # # <OPTION VALUE="baz">baz</OPTION>
- # # </SELECT>
- #
- # popup_menu("name", ["foo"], ["bar", true], "baz")
- # # <SELECT NAME="name">
- # # <OPTION VALUE="foo">foo</OPTION>
- # # <OPTION VALUE="bar" SELECTED>bar</OPTION>
- # # <OPTION VALUE="baz">baz</OPTION>
- # # </SELECT>
- #
- # popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # # <SELECT NAME="name">
- # # <OPTION VALUE="1">Foo</OPTION>
- # # <OPTION SELECTED VALUE="2">Bar</OPTION>
- # # <OPTION VALUE="Baz">Baz</OPTION>
- # # </SELECT>
- #
- # popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
- # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
- # # <SELECT NAME="name" MULTIPLE SIZE="2">
- # # <OPTION VALUE="1">Foo</OPTION>
- # # <OPTION SELECTED VALUE="2">Bar</OPTION>
- # # <OPTION VALUE="Baz">Baz</OPTION>
- # # </SELECT>
- def popup_menu(name = "", *values)
-
- if name.kind_of?(Hash)
- values = name["VALUES"]
- size = name["SIZE"].to_s if name["SIZE"]
- multiple = name["MULTIPLE"]
- name = name["NAME"]
- else
- size = nil
- multiple = nil
- end
-
- select({ "NAME" => name, "SIZE" => size,
- "MULTIPLE" => multiple }){
- values.collect{|value|
- if value.kind_of?(String)
- option({ "VALUE" => value }){ value }
- else
- if value[value.size - 1] == true
- option({ "VALUE" => value[0], "SELECTED" => true }){
- value[value.size - 2]
- }
- else
- option({ "VALUE" => value[0] }){
- value[value.size - 1]
- }
- end
- end
- }.join
- }
-
- end
-
- # Generates a radio-button Input element.
- #
- # +name+ is the name of the input field. +value+ is the value of
- # the field if checked. +checked+ specifies whether the field
- # starts off checked.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # radio_button("name", "value")
- # # <INPUT TYPE="radio" NAME="name" VALUE="value">
- #
- # radio_button("name", "value", true)
- # # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED>
- #
- # radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo")
- # # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
- def radio_button(name = "", value = nil, checked = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "radio", "NAME" => name,
- "VALUE" => value, "CHECKED" => checked }
- else
- name["TYPE"] = "radio"
- name
- end
- input(attributes)
- end
-
- # Generate a sequence of radio button Input elements, as a String.
- #
- # This works the same as #checkbox_group(). However, it is not valid
- # to have more than one radiobutton in a group checked.
- #
- # radio_group("name", "foo", "bar", "baz")
- # # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
- # # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
- # # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
- #
- # radio_group("name", ["foo"], ["bar", true], "baz")
- # # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
- # # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="bar">bar
- # # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
- #
- # radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
- # # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar
- # # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz
- #
- # radio_group("NAME" => "name",
- # "VALUES" => ["foo", "bar", "baz"])
- #
- # radio_group("NAME" => "name",
- # "VALUES" => [["foo"], ["bar", true], "baz"])
- #
- # radio_group("NAME" => "name",
- # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
- def radio_group(name = "", *values)
- if name.kind_of?(Hash)
- values = name["VALUES"]
- name = name["NAME"]
- end
- values.collect{|value|
- if value.kind_of?(String)
- radio_button(name, value) + value
- else
- if value[-1] == true || value[-1] == false
- radio_button(name, value[0], value[-1]) +
- value[-2]
- else
- radio_button(name, value[0]) +
- value[-1]
- end
- end
- }.join
- end
-
- # Generate a reset button Input element, as a String.
- #
- # This resets the values on a form to their initial values. +value+
- # is the text displayed on the button. +name+ is the name of this button.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # reset
- # # <INPUT TYPE="reset">
- #
- # reset("reset")
- # # <INPUT TYPE="reset" VALUE="reset">
- #
- # reset("VALUE" => "reset", "ID" => "foo")
- # # <INPUT TYPE="reset" VALUE="reset" ID="foo">
- def reset(value = nil, name = nil)
- attributes = if (not value) or value.kind_of?(String)
- { "TYPE" => "reset", "VALUE" => value, "NAME" => name }
- else
- value["TYPE"] = "reset"
- value
- end
- input(attributes)
- end
-
- alias scrolling_list popup_menu
-
- # Generate a submit button Input element, as a String.
- #
- # +value+ is the text to display on the button. +name+ is the name
- # of the input.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # submit
- # # <INPUT TYPE="submit">
- #
- # submit("ok")
- # # <INPUT TYPE="submit" VALUE="ok">
- #
- # submit("ok", "button1")
- # # <INPUT TYPE="submit" VALUE="ok" NAME="button1">
- #
- # submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo")
- # # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
- def submit(value = nil, name = nil)
- attributes = if (not value) or value.kind_of?(String)
- { "TYPE" => "submit", "VALUE" => value, "NAME" => name }
- else
- value["TYPE"] = "submit"
- value
- end
- input(attributes)
- end
-
- # Generate a text field Input element, as a String.
- #
- # +name+ is the name of the input field. +value+ is its initial
- # value. +size+ is the size of the input area. +maxlength+
- # is the maximum length of input accepted.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # text_field("name")
- # # <INPUT TYPE="text" NAME="name" SIZE="40">
- #
- # text_field("name", "value")
- # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">
- #
- # text_field("name", "value", 80)
- # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80">
- #
- # text_field("name", "value", 80, 200)
- # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
- #
- # text_field("NAME" => "name", "VALUE" => "value")
- # # <INPUT TYPE="text" NAME="name" VALUE="value">
- def text_field(name = "", value = nil, size = 40, maxlength = nil)
- attributes = if name.kind_of?(String)
- { "TYPE" => "text", "NAME" => name, "VALUE" => value,
- "SIZE" => size.to_s }
- else
- name["TYPE"] = "text"
- name
- end
- attributes["MAXLENGTH"] = maxlength.to_s if maxlength
- input(attributes)
- end
-
- # Generate a TextArea element, as a String.
- #
- # +name+ is the name of the textarea. +cols+ is the number of
- # columns and +rows+ is the number of rows in the display.
- #
- # Alternatively, the attributes can be specified as a hash.
- #
- # The body is provided by the passed-in no-argument block
- #
- # textarea("name")
- # # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10)
- #
- # textarea("name", 40, 5)
- # # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5)
- def textarea(name = "", cols = 70, rows = 10) # :yield:
- attributes = if name.kind_of?(String)
- { "NAME" => name, "COLS" => cols.to_s,
- "ROWS" => rows.to_s }
- else
- name
- end
- super(attributes)
- end
-
- end # HtmlExtension
-
-
- # Mixin module for HTML version 3 generation methods.
- module Html3 # :nodoc:
- include TagMaker
-
- # The DOCTYPE declaration for this version of HTML
- def doctype
- %|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">|
- end
-
- instance_method(:nn_element_def).tap do |m|
- # - -
- for element in %w[ A TT I B U STRIKE BIG SMALL SUB SUP EM STRONG
- DFN CODE SAMP KBD VAR CITE FONT ADDRESS DIV CENTER MAP
- APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT TABLE TITLE
- STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
- CAPTION ]
- define_method(element.downcase, m)
- end
- end
-
- instance_method(:nOE_element_def).tap do |m|
- # - O EMPTY
- for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
- ISINDEX META ]
- define_method(element.downcase, m)
- end
- end
-
- instance_method(:nO_element_def).tap do |m|
- # O O or - O
- for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION TR
- TH TD ]
- define_method(element.downcase, m)
- end
- end
-
- end # Html3
-
-
- # Mixin module for HTML version 4 generation methods.
- module Html4 # :nodoc:
- include TagMaker
-
- # The DOCTYPE declaration for this version of HTML
- def doctype
- %|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">|
- end
-
- # Initialize the HTML generation methods for this version.
- # - -
- instance_method(:nn_element_def).tap do |m|
- for element in %w[ TT I B BIG SMALL EM STRONG DFN CODE SAMP KBD
- VAR CITE ABBR ACRONYM SUB SUP SPAN BDO ADDRESS DIV MAP OBJECT
- H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
- FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
- TEXTAREA FORM A BLOCKQUOTE CAPTION ]
- define_method(element.downcase, m)
- end
- end
-
- # - O EMPTY
- instance_method(:nOE_element_def).tap do |m|
- for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ]
- define_method(element.downcase, m)
- end
- end
-
- # O O or - O
- instance_method(:nO_element_def).tap do |m|
- for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
- COLGROUP TR TH TD HEAD ]
- define_method(element.downcase, m)
- end
- end
-
- end # Html4
-
-
- # Mixin module for HTML version 4 transitional generation methods.
- module Html4Tr # :nodoc:
- include TagMaker
-
- # The DOCTYPE declaration for this version of HTML
- def doctype
- %|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">|
- end
-
- # Initialise the HTML generation methods for this version.
- # - -
- instance_method(:nn_element_def).tap do |m|
- for element in %w[ TT I B U S STRIKE BIG SMALL EM STRONG DFN
- CODE SAMP KBD VAR CITE ABBR ACRONYM FONT SUB SUP SPAN BDO
- ADDRESS DIV CENTER MAP OBJECT APPLET H1 H2 H3 H4 H5 H6 PRE Q
- INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
- LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
- NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
- define_method(element.downcase, m)
- end
- end
-
- # - O EMPTY
- instance_method(:nOE_element_def).tap do |m|
- for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
- COL ISINDEX META ]
- define_method(element.downcase, m)
- end
- end
-
- # O O or - O
- instance_method(:nO_element_def).tap do |m|
- for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
- COLGROUP TR TH TD HEAD ]
- define_method(element.downcase, m)
- end
- end
-
- end # Html4Tr
-
-
- # Mixin module for generating HTML version 4 with framesets.
- module Html4Fr # :nodoc:
- include TagMaker
-
- # The DOCTYPE declaration for this version of HTML
- def doctype
- %|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">|
- end
-
- # Initialise the HTML generation methods for this version.
- # - -
- instance_method(:nn_element_def).tap do |m|
- for element in %w[ FRAMESET ]
- define_method(element.downcase, m)
- end
- end
-
- # - O EMPTY
- instance_method(:nOE_element_def).tap do |m|
- for element in %w[ FRAME ]
- define_method(element.downcase, m)
- end
- end
-
- end # Html4Fr
-
-
- # Mixin module for HTML version 5 generation methods.
- module Html5 # :nodoc:
- include TagMaker
-
- # The DOCTYPE declaration for this version of HTML
- def doctype
- %|<!DOCTYPE HTML>|
- end
-
- # Initialise the HTML generation methods for this version.
- # - -
- instance_method(:nn_element_def).tap do |m|
- for element in %w[ SECTION NAV ARTICLE ASIDE HGROUP HEADER
- FOOTER FIGURE FIGCAPTION S TIME U MARK RUBY BDI IFRAME
- VIDEO AUDIO CANVAS DATALIST OUTPUT PROGRESS METER DETAILS
- SUMMARY MENU DIALOG I B SMALL EM STRONG DFN CODE SAMP KBD
- VAR CITE ABBR SUB SUP SPAN BDO ADDRESS DIV MAP OBJECT
- H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT
- FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
- TEXTAREA FORM A BLOCKQUOTE CAPTION ]
- define_method(element.downcase, m)
- end
- end
-
- # - O EMPTY
- instance_method(:nOE_element_def).tap do |m|
- for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META
- COMMAND EMBED KEYGEN SOURCE TRACK WBR ]
- define_method(element.downcase, m)
- end
- end
-
- # O O or - O
- instance_method(:nO_element_def).tap do |m|
- for element in %w[ HTML HEAD BODY P DT DD LI OPTION THEAD TFOOT TBODY
- OPTGROUP COLGROUP RT RP TR TH TD ]
- define_method(element.downcase, m)
- end
- end
-
- end # Html5
-
- class HTML3
- include Html3
- include HtmlExtension
- end
-
- class HTML4
- include Html4
- include HtmlExtension
- end
-
- class HTML4Tr
- include Html4Tr
- include HtmlExtension
- end
-
- class HTML4Fr
- include Html4Tr
- include Html4Fr
- include HtmlExtension
- end
-
- class HTML5
- include Html5
- include HtmlExtension
- end
-
-end
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
deleted file mode 100644
index aab60869bb..0000000000
--- a/lib/cgi/session.rb
+++ /dev/null
@@ -1,562 +0,0 @@
-# frozen_string_literal: true
-#
-# cgi/session.rb - session support for cgi scripts
-#
-# Copyright (C) 2001 Yukihiro "Matz" Matsumoto
-# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-# Copyright (C) 2000 Information-technology Promotion Agency, Japan
-#
-# Author: Yukihiro "Matz" Matsumoto
-#
-# Documentation: William Webber (william@williamwebber.com)
-
-require 'cgi'
-require 'tmpdir'
-
-class CGI
-
- # == Overview
- #
- # This file provides the CGI::Session class, which provides session
- # support for CGI scripts. A session is a sequence of HTTP requests
- # and responses linked together and associated with a single client.
- # Information associated with the session is stored
- # on the server between requests. A session id is passed between client
- # and server with every request and response, transparently
- # to the user. This adds state information to the otherwise stateless
- # HTTP request/response protocol.
- #
- # == Lifecycle
- #
- # A CGI::Session instance is created from a CGI object. By default,
- # this CGI::Session instance will start a new session if none currently
- # exists, or continue the current session for this client if one does
- # exist. The +new_session+ option can be used to either always or
- # never create a new session. See #new() for more details.
- #
- # #delete() deletes a session from session storage. It
- # does not however remove the session id from the client. If the client
- # makes another request with the same id, the effect will be to start
- # a new session with the old session's id.
- #
- # == Setting and retrieving session data.
- #
- # The Session class associates data with a session as key-value pairs.
- # This data can be set and retrieved by indexing the Session instance
- # using '[]', much the same as hashes (although other hash methods
- # are not supported).
- #
- # When session processing has been completed for a request, the
- # session should be closed using the close() method. This will
- # store the session's state to persistent storage. If you want
- # to store the session's state to persistent storage without
- # finishing session processing for this request, call the update()
- # method.
- #
- # == Storing session state
- #
- # The caller can specify what form of storage to use for the session's
- # data with the +database_manager+ option to CGI::Session::new. The
- # following storage classes are provided as part of the standard library:
- #
- # CGI::Session::FileStore:: stores data as plain text in a flat file. Only
- # works with String data. This is the default
- # storage type.
- # CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
- # only persists for as long as the current Ruby
- # interpreter instance does.
- # CGI::Session::PStore:: stores data in Marshalled format. Provided by
- # cgi/session/pstore.rb. Supports data of any type,
- # and provides file-locking and transaction support.
- #
- # Custom storage types can also be created by defining a class with
- # the following methods:
- #
- # new(session, options)
- # restore # returns hash of session data.
- # update
- # close
- # delete
- #
- # Changing storage type mid-session does not work. Note in particular
- # that by default the FileStore and PStore session data files have the
- # same name. If your application switches from one to the other without
- # making sure that filenames will be different
- # and clients still have old sessions lying around in cookies, then
- # things will break nastily!
- #
- # == Maintaining the session id.
- #
- # Most session state is maintained on the server. However, a session
- # id must be passed backwards and forwards between client and server
- # to maintain a reference to this session state.
- #
- # The simplest way to do this is via cookies. The CGI::Session class
- # provides transparent support for session id communication via cookies
- # if the client has cookies enabled.
- #
- # If the client has cookies disabled, the session id must be included
- # as a parameter of all requests sent by the client to the server. The
- # CGI::Session class in conjunction with the CGI class will transparently
- # add the session id as a hidden input field to all forms generated
- # using the CGI#form() HTML generation method. No built-in support is
- # provided for other mechanisms, such as URL re-writing. The caller is
- # responsible for extracting the session id from the session_id
- # attribute and manually encoding it in URLs and adding it as a hidden
- # input to HTML forms created by other mechanisms. Also, session expiry
- # is not automatically handled.
- #
- # == Examples of use
- #
- # === Setting the user's name
- #
- # require 'cgi'
- # require 'cgi/session'
- # require 'cgi/session/pstore' # provides CGI::Session::PStore
- #
- # cgi = CGI.new("html4")
- #
- # session = CGI::Session.new(cgi,
- # 'database_manager' => CGI::Session::PStore, # use PStore
- # 'session_key' => '_rb_sess_id', # custom session key
- # 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
- # 'prefix' => 'pstore_sid_') # PStore option
- # if cgi.has_key?('user_name') and cgi['user_name'] != ''
- # # coerce to String: cgi[] returns the
- # # string-like CGI::QueryExtension::Value
- # session['user_name'] = cgi['user_name'].to_s
- # elsif !session['user_name']
- # session['user_name'] = "guest"
- # end
- # session.close
- #
- # === Creating a new session safely
- #
- # require 'cgi'
- # require 'cgi/session'
- #
- # cgi = CGI.new("html4")
- #
- # # We make sure to delete an old session if one exists,
- # # not just to free resources, but to prevent the session
- # # from being maliciously hijacked later on.
- # begin
- # session = CGI::Session.new(cgi, 'new_session' => false)
- # session.delete
- # rescue ArgumentError # if no old session
- # end
- # session = CGI::Session.new(cgi, 'new_session' => true)
- # session.close
- #
- class Session
-
- class NoSession < RuntimeError #:nodoc:
- end
-
- # The id of this session.
- attr_reader :session_id, :new_session
-
- def Session::callback(dbman) #:nodoc:
- Proc.new{
- dbman[0].close unless dbman.empty?
- }
- end
-
- # Create a new session id.
- #
- # The session id is a secure random number by SecureRandom
- # if possible, otherwise an SHA512 hash based upon the time,
- # a random number, and a constant string. This routine is
- # used internally for automatically generated session ids.
- def create_new_id
- require 'securerandom'
- begin
- # by OpenSSL, or system provided entropy pool
- session_id = SecureRandom.hex(16)
- rescue NotImplementedError
- # never happens on modern systems
- require 'digest'
- d = Digest('SHA512').new
- now = Time::now
- d.update(now.to_s)
- d.update(String(now.usec))
- d.update(String(rand(0)))
- d.update(String($$))
- d.update('foobar')
- session_id = d.hexdigest[0, 32]
- end
- session_id
- end
- private :create_new_id
-
-
- # Create a new file to store the session data.
- #
- # This file will be created if it does not exist, or opened if it
- # does.
- #
- # This path is generated under _tmpdir_ from _prefix_, the
- # digested session id, and _suffix_.
- #
- # +option+ is a hash of options for the initializer. The
- # following options are recognised:
- #
- # tmpdir:: the directory to use for storing the FileStore
- # file. Defaults to Dir::tmpdir (generally "/tmp"
- # on Unix systems).
- # prefix:: the prefix to add to the session id when generating
- # the filename for this session's FileStore file.
- # Defaults to "cgi_sid_".
- # suffix:: the prefix to add to the session id when generating
- # the filename for this session's FileStore file.
- # Defaults to the empty string.
- def new_store_file(option={}) # :nodoc:
- dir = option['tmpdir'] || Dir::tmpdir
- prefix = option['prefix']
- suffix = option['suffix']
- require 'digest/md5'
- md5 = Digest::MD5.hexdigest(session_id)[0,16]
- path = dir+"/"
- path << prefix if prefix
- path << md5
- path << suffix if suffix
- if File::exist? path
- hash = nil
- elsif new_session
- hash = {}
- else
- raise NoSession, "uninitialized session"
- end
- return path, hash
- end
-
- # Create a new CGI::Session object for +request+.
- #
- # +request+ is an instance of the +CGI+ class (see cgi.rb).
- # +option+ is a hash of options for initialising this
- # CGI::Session instance. The following options are
- # recognised:
- #
- # session_key:: the parameter name used for the session id.
- # Defaults to '_session_id'.
- # session_id:: the session id to use. If not provided, then
- # it is retrieved from the +session_key+ parameter
- # of the request, or automatically generated for
- # a new session.
- # new_session:: if true, force creation of a new session. If not set,
- # a new session is only created if none currently
- # exists. If false, a new session is never created,
- # and if none currently exists and the +session_id+
- # option is not set, an ArgumentError is raised.
- # database_manager:: the name of the class providing storage facilities
- # for session state persistence. Built-in support
- # is provided for +FileStore+ (the default),
- # +MemoryStore+, and +PStore+ (from
- # cgi/session/pstore.rb). See the documentation for
- # these classes for more details.
- #
- # The following options are also recognised, but only apply if the
- # session id is stored in a cookie.
- #
- # session_expires:: the time the current session expires, as a
- # +Time+ object. If not set, the session will terminate
- # when the user's browser is closed.
- # session_domain:: the hostname domain for which this session is valid.
- # If not set, defaults to the hostname of the server.
- # session_secure:: if +true+, this session will only work over HTTPS.
- # session_path:: the path for which this session applies. Defaults
- # to the directory of the CGI script.
- #
- # +option+ is also passed on to the session storage class initializer; see
- # the documentation for each session storage class for the options
- # they support.
- #
- # The retrieved or created session is automatically added to +request+
- # as a cookie, and also to its +output_hidden+ table, which is used
- # to add hidden input elements to forms.
- #
- # *WARNING* the +output_hidden+
- # fields are surrounded by a <fieldset> tag in HTML 4 generation, which
- # is _not_ invisible on many browsers; you may wish to disable the
- # use of fieldsets with code similar to the following
- # (see https://blade.ruby-lang.org/ruby-list/37805)
- #
- # cgi = CGI.new("html4")
- # class << cgi
- # undef_method :fieldset
- # end
- #
- def initialize(request, option={})
- @new_session = false
- session_key = option['session_key'] || '_session_id'
- session_id = option['session_id']
- unless session_id
- if option['new_session']
- session_id = create_new_id
- @new_session = true
- end
- end
- unless session_id
- if request.key?(session_key)
- session_id = request[session_key]
- session_id = session_id.read if session_id.respond_to?(:read)
- end
- unless session_id
- session_id, = request.cookies[session_key]
- end
- unless session_id
- unless option.fetch('new_session', true)
- raise ArgumentError, "session_key `%s' should be supplied"%session_key
- end
- session_id = create_new_id
- @new_session = true
- end
- end
- @session_id = session_id
- dbman = option['database_manager'] || FileStore
- begin
- @dbman = dbman::new(self, option)
- rescue NoSession
- unless option.fetch('new_session', true)
- raise ArgumentError, "invalid session_id `%s'"%session_id
- end
- session_id = @session_id = create_new_id unless session_id
- @new_session=true
- retry
- end
- request.instance_eval do
- @output_hidden = {session_key => session_id} unless option['no_hidden']
- @output_cookies = [
- Cookie::new("name" => session_key,
- "value" => session_id,
- "expires" => option['session_expires'],
- "domain" => option['session_domain'],
- "secure" => option['session_secure'],
- "path" =>
- if option['session_path']
- option['session_path']
- elsif ENV["SCRIPT_NAME"]
- File::dirname(ENV["SCRIPT_NAME"])
- else
- ""
- end)
- ] unless option['no_cookies']
- end
- @dbprot = [@dbman]
- ObjectSpace::define_finalizer(self, Session::callback(@dbprot))
- end
-
- # Retrieve the session data for key +key+.
- def [](key)
- @data ||= @dbman.restore
- @data[key]
- end
-
- # Set the session data for key +key+.
- def []=(key, val)
- @write_lock ||= true
- @data ||= @dbman.restore
- @data[key] = val
- end
-
- # Store session data on the server. For some session storage types,
- # this is a no-op.
- def update
- @dbman.update
- end
-
- # Store session data on the server and close the session storage.
- # For some session storage types, this is a no-op.
- def close
- @dbman.close
- @dbprot.clear
- end
-
- # Delete the session from storage. Also closes the storage.
- #
- # Note that the session's data is _not_ automatically deleted
- # upon the session expiring.
- def delete
- @dbman.delete
- @dbprot.clear
- end
-
- # File-based session storage class.
- #
- # Implements session storage as a flat file of 'key=value' values.
- # This storage type only works directly with String values; the
- # user is responsible for converting other types to Strings when
- # storing and from Strings when retrieving.
- class FileStore
- # Create a new FileStore instance.
- #
- # This constructor is used internally by CGI::Session. The
- # user does not generally need to call it directly.
- #
- # +session+ is the session for which this instance is being
- # created. The session id must only contain alphanumeric
- # characters; automatically generated session ids observe
- # this requirement.
- #
- # +option+ is a hash of options for the initializer. The
- # following options are recognised:
- #
- # tmpdir:: the directory to use for storing the FileStore
- # file. Defaults to Dir::tmpdir (generally "/tmp"
- # on Unix systems).
- # prefix:: the prefix to add to the session id when generating
- # the filename for this session's FileStore file.
- # Defaults to "cgi_sid_".
- # suffix:: the prefix to add to the session id when generating
- # the filename for this session's FileStore file.
- # Defaults to the empty string.
- #
- # This session's FileStore file will be created if it does
- # not exist, or opened if it does.
- def initialize(session, option={})
- option = {'prefix' => 'cgi_sid_'}.update(option)
- @path, @hash = session.new_store_file(option)
- end
-
- # Restore session state from the session's FileStore file.
- #
- # Returns the session state as a hash.
- def restore
- unless @hash
- @hash = {}
- begin
- lockf = File.open(@path+".lock", "r")
- lockf.flock File::LOCK_SH
- f = File.open(@path, 'r')
- for line in f
- line.chomp!
- k, v = line.split('=',2)
- @hash[CGI.unescape(k)] = Marshal.restore(CGI.unescape(v))
- end
- ensure
- f&.close
- lockf&.close
- end
- end
- @hash
- end
-
- # Save session state to the session's FileStore file.
- def update
- return unless @hash
- begin
- lockf = File.open(@path+".lock", File::CREAT|File::RDWR, 0600)
- lockf.flock File::LOCK_EX
- f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
- for k,v in @hash
- f.printf "%s=%s\n", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))
- end
- f.close
- File.rename @path+".new", @path
- ensure
- f&.close
- lockf&.close
- end
- end
-
- # Update and close the session's FileStore file.
- def close
- update
- end
-
- # Close and delete the session's FileStore file.
- def delete
- File::unlink @path+".lock" rescue nil
- File::unlink @path+".new" rescue nil
- File::unlink @path rescue nil
- end
- end
-
- # In-memory session storage class.
- #
- # Implements session storage as a global in-memory hash. Session
- # data will only persist for as long as the Ruby interpreter
- # instance does.
- class MemoryStore
- GLOBAL_HASH_TABLE = {} #:nodoc:
-
- # Create a new MemoryStore instance.
- #
- # +session+ is the session this instance is associated with.
- # +option+ is a list of initialisation options. None are
- # currently recognized.
- def initialize(session, option=nil)
- @session_id = session.session_id
- unless GLOBAL_HASH_TABLE.key?(@session_id)
- unless session.new_session
- raise CGI::Session::NoSession, "uninitialized session"
- end
- GLOBAL_HASH_TABLE[@session_id] = {}
- end
- end
-
- # Restore session state.
- #
- # Returns session data as a hash.
- def restore
- GLOBAL_HASH_TABLE[@session_id]
- end
-
- # Update session state.
- #
- # A no-op.
- def update
- # don't need to update; hash is shared
- end
-
- # Close session storage.
- #
- # A no-op.
- def close
- # don't need to close
- end
-
- # Delete the session state.
- def delete
- GLOBAL_HASH_TABLE.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
deleted file mode 100644
index 45d0d8ae2c..0000000000
--- a/lib/cgi/session/pstore.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: true
-#
-# cgi/session/pstore.rb - persistent storage of marshalled session data
-#
-# Documentation: William Webber (william@williamwebber.com)
-#
-# == Overview
-#
-# This file provides the CGI::Session::PStore class, which builds
-# persistent of session data on top of the pstore library. See
-# cgi/session.rb for more details on session storage managers.
-
-require_relative '../session'
-require 'pstore'
-
-class CGI
- class Session
- # PStore-based session storage class.
- #
- # This builds upon the top-level PStore class provided by the
- # library file pstore.rb. Session data is marshalled and stored
- # in a file. File locking and transaction services are provided.
- class PStore
- # Create a new CGI::Session::PStore instance
- #
- # This constructor is used internally by CGI::Session. The
- # user does not generally need to call it directly.
- #
- # +session+ is the session for which this instance is being
- # created. The session id must only contain alphanumeric
- # characters; automatically generated session ids observe
- # this requirement.
- #
- # +option+ is a hash of options for the initializer. The
- # following options are recognised:
- #
- # tmpdir:: the directory to use for storing the PStore
- # file. Defaults to Dir::tmpdir (generally "/tmp"
- # on Unix systems).
- # prefix:: the prefix to add to the session id when generating
- # the filename for this session's PStore file.
- # Defaults to the empty string.
- #
- # This session's PStore file will be created if it does
- # not exist, or opened if it does.
- def initialize(session, option={})
- option = {'suffix'=>''}.update(option)
- path, @hash = session.new_store_file(option)
- @p = ::PStore.new(path)
- @p.transaction do |p|
- File.chmod(0600, p.path)
- end
- end
-
- # Restore session state from the session's PStore file.
- #
- # Returns the session state as a hash.
- def restore
- unless @hash
- @p.transaction do
- @hash = @p['hash'] || {}
- end
- end
- @hash
- end
-
- # Save session state to the session's PStore file.
- def update
- @p.transaction do
- @p['hash'] = @hash
- end
- end
-
- # Update and close the session's PStore file.
- def close
- update
- end
-
- # Close and delete the session's PStore file.
- def delete
- path = @p.path
- File::unlink path
- end
-
- end
- end
-end
-# :enddoc:
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index 5a5c77ac97..50a2e91665 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -1,252 +1,7 @@
# frozen_string_literal: true
-class CGI
- module Util; end
- include Util
- extend Util
-end
-module CGI::Util
- @@accept_charset = Encoding::UTF_8 unless defined?(@@accept_charset)
- # URL-encode a string into application/x-www-form-urlencoded.
- # Space characters (+" "+) are encoded with plus signs (+"+"+)
- # url_encoded_string = CGI.escape("'Stop!' said Fred")
- # # => "%27Stop%21%27+said+Fred"
- def escape(string)
- encoding = string.encoding
- buffer = string.b
- buffer.gsub!(/([^ a-zA-Z0-9_.\-~]+)/) do |m|
- '%' + m.unpack('H2' * m.bytesize).join('%').upcase
- end
- buffer.tr!(' ', '+')
- buffer.force_encoding(encoding)
- end
-
- # URL-decode an application/x-www-form-urlencoded string with encoding(optional).
- # string = CGI.unescape("%27Stop%21%27+said+Fred")
- # # => "'Stop!' said Fred"
- def unescape(string, encoding = @@accept_charset)
- str = string.tr('+', ' ')
- str = str.b
- str.gsub!(/((?:%[0-9a-fA-F]{2})+)/) do |m|
- [m.delete('%')].pack('H*')
- end
- str.force_encoding(encoding)
- str.valid_encoding? ? str : str.force_encoding(string.encoding)
- end
-
- # URL-encode a string following RFC 3986
- # Space characters (+" "+) are encoded with (+"%20"+)
- # url_encoded_string = CGI.escape("'Stop!' said Fred")
- # # => "%27Stop%21%27%20said%20Fred"
- def escapeURIComponent(string)
- encoding = string.encoding
- buffer = string.b
- buffer.gsub!(/([^a-zA-Z0-9_.\-~]+)/) do |m|
- '%' + m.unpack('H2' * m.bytesize).join('%').upcase
- end
- buffer.force_encoding(encoding)
- end
-
- # URL-decode a string following RFC 3986 with encoding(optional).
- # string = CGI.unescape("%27Stop%21%27+said%20Fred")
- # # => "'Stop!'+said Fred"
- def unescapeURIComponent(string, encoding = @@accept_charset)
- str = string.b
- str.gsub!(/((?:%[0-9a-fA-F]{2})+)/) do |m|
- [m.delete('%')].pack('H*')
- end
- str.force_encoding(encoding)
- str.valid_encoding? ? str : str.force_encoding(string.encoding)
- end
-
- # The set of special characters and their escaped values
- TABLE_FOR_ESCAPE_HTML__ = {
- "'" => '&#39;',
- '&' => '&amp;',
- '"' => '&quot;',
- '<' => '&lt;',
- '>' => '&gt;',
- }
-
- # Escape special characters in HTML, namely '&\"<>
- # CGI.escapeHTML('Usage: foo "bar" <baz>')
- # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
- def escapeHTML(string)
- enc = string.encoding
- unless enc.ascii_compatible?
- if enc.dummy?
- origenc = enc
- enc = Encoding::Converter.asciicompat_encoding(enc)
- string = enc ? string.encode(enc) : string.b
- end
- table = Hash[TABLE_FOR_ESCAPE_HTML__.map {|pair|pair.map {|s|s.encode(enc)}}]
- string = string.gsub(/#{"['&\"<>]".encode(enc)}/, table)
- string.encode!(origenc) if origenc
- string
- else
- string = string.b
- string.gsub!(/['&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
- string.force_encoding(enc)
- end
- end
-
- begin
- require 'cgi/escape'
- rescue LoadError
- end
-
- # Unescape a string that has been HTML-escaped
- # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
- # # => "Usage: foo \"bar\" <baz>"
- def unescapeHTML(string)
- enc = string.encoding
- unless enc.ascii_compatible?
- if enc.dummy?
- origenc = enc
- enc = Encoding::Converter.asciicompat_encoding(enc)
- string = enc ? string.encode(enc) : string.b
- end
- string = string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do
- case $1.encode(Encoding::US_ASCII)
- when 'apos' then "'".encode(enc)
- when 'amp' then '&'.encode(enc)
- when 'quot' then '"'.encode(enc)
- when 'gt' then '>'.encode(enc)
- when 'lt' then '<'.encode(enc)
- when /\A#0*(\d+)\z/ then $1.to_i.chr(enc)
- when /\A#x([0-9a-f]+)\z/i then $1.hex.chr(enc)
- end
- end
- string.encode!(origenc) if origenc
- return string
- end
- return string unless string.include? '&'
- charlimit = case enc
- when Encoding::UTF_8; 0x10ffff
- when Encoding::ISO_8859_1; 256
- else 128
- end
- string = string.b
- string.gsub!(/&(apos|amp|quot|gt|lt|\#[0-9]+|\#[xX][0-9A-Fa-f]+);/) do
- match = $1.dup
- case match
- when 'apos' then "'"
- when 'amp' then '&'
- when 'quot' then '"'
- when 'gt' then '>'
- when 'lt' then '<'
- when /\A#0*(\d+)\z/
- n = $1.to_i
- if n < charlimit
- n.chr(enc)
- else
- "&##{$1};"
- end
- when /\A#x([0-9a-f]+)\z/i
- n = $1.hex
- if n < charlimit
- n.chr(enc)
- else
- "&#x#{$1};"
- end
- else
- "&#{match};"
- end
- end
- string.force_encoding enc
- end
-
- # Synonym for CGI.escapeHTML(str)
- alias escape_html escapeHTML
-
- # Synonym for CGI.unescapeHTML(str)
- alias unescape_html unescapeHTML
-
- # Escape only the tags of certain HTML elements in +string+.
- #
- # Takes an element or elements or array of elements. Each element
- # is specified by the name of the element, without angle brackets.
- # This matches both the start and the end tag of that element.
- # The attribute list of the open tag will also be escaped (for
- # instance, the double-quotes surrounding attribute values).
- #
- # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
- #
- # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
- def escapeElement(string, *elements)
- elements = elements[0] if elements[0].kind_of?(Array)
- unless elements.empty?
- string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/i) do
- CGI.escapeHTML($&)
- end
- else
- string
- end
- end
-
- # Undo escaping such as that done by CGI.escapeElement()
- #
- # print CGI.unescapeElement(
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
- # # "&lt;BR&gt;<A HREF="url"></A>"
- #
- # print CGI.unescapeElement(
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
- # # "&lt;BR&gt;<A HREF="url"></A>"
- def unescapeElement(string, *elements)
- elements = elements[0] if elements[0].kind_of?(Array)
- unless elements.empty?
- string.gsub(/&lt;\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?&gt;/i) do
- unescapeHTML($&)
- end
- else
- string
- end
- end
-
- # Synonym for CGI.escapeElement(str)
- alias escape_element escapeElement
-
- # Synonym for CGI.unescapeElement(str)
- alias unescape_element unescapeElement
-
- # Format a +Time+ object as a String using the format specified by RFC 1123.
- #
- # CGI.rfc1123_date(Time.now)
- # # Sat, 01 Jan 2000 00:00:00 GMT
- def rfc1123_date(time)
- time.getgm.strftime("%a, %d %b %Y %T GMT")
- end
-
- # Prettify (indent) an HTML string.
- #
- # +string+ is the HTML string to indent. +shift+ is the indentation
- # unit to use; it defaults to two spaces.
- #
- # print CGI.pretty("<HTML><BODY></BODY></HTML>")
- # # <HTML>
- # # <BODY>
- # # </BODY>
- # # </HTML>
- #
- # print CGI.pretty("<HTML><BODY></BODY></HTML>", "\t")
- # # <HTML>
- # # <BODY>
- # # </BODY>
- # # </HTML>
- #
- def pretty(string, shift = " ")
- lines = string.gsub(/(?!\A)<.*?>/m, "\n\\0").gsub(/<.*?>(?!\n)/m, "\\0\n")
- end_pos = 0
- while end_pos = lines.index(/^<\/(\w+)/, end_pos)
- element = $1.dup
- start_pos = lines.rindex(/^\s*<#{element}/i, end_pos)
- lines[start_pos ... end_pos] = "__" + lines[start_pos ... end_pos].gsub(/\n(?!\z)/, "\n" + shift) + "__"
- end
- lines.gsub(/^((?:#{Regexp::quote(shift)})*)__(?=<\/?\w)/, '\1')
- end
-
- alias h escapeHTML
-end
+require "cgi/escape"
+warn <<-WARNING, uplevel: Gem::BUNDLED_GEMS.uplevel if $VERBOSE
+CGI::Util is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
+If you are using CGI.parse, please install and use the cgi gem instead.
+WARNING
diff --git a/lib/csv.rb b/lib/csv.rb
deleted file mode 100644
index d4dc569b83..0000000000
--- a/lib/csv.rb
+++ /dev/null
@@ -1,2881 +0,0 @@
-# encoding: US-ASCII
-# frozen_string_literal: true
-# = csv.rb -- CSV Reading and Writing
-#
-# Created by James Edward Gray II on 2005-10-31.
-#
-# 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 as of Ruby 1.9. If you are migrating code from 1.8 or
-# earlier, you may have to change your code to comply with the new interface.
-#
-# == What's the 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 parser is m17n aware. See CSV for full details.
-# * 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 keyword 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}[https://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 to 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 consumes 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 "date"
-require "stringio"
-
-require_relative "csv/fields_converter"
-require_relative "csv/input_record_separator"
-require_relative "csv/parser"
-require_relative "csv/row"
-require_relative "csv/table"
-require_relative "csv/writer"
-
-# == \CSV
-#
-# === In a Hurry?
-#
-# If you are familiar with \CSV data and have a particular task in mind,
-# you may want to go directly to the:
-# - {Recipes for CSV}[doc/csv/recipes/recipes_rdoc.html].
-#
-# Otherwise, read on here, about the API: classes, methods, and constants.
-#
-# === \CSV Data
-#
-# \CSV (comma-separated values) data is a text representation of a table:
-# - A _row_ _separator_ delimits table rows.
-# A common row separator is the newline character <tt>"\n"</tt>.
-# - A _column_ _separator_ delimits fields in a row.
-# A common column separator is the comma character <tt>","</tt>.
-#
-# This \CSV \String, with row separator <tt>"\n"</tt>
-# and column separator <tt>","</tt>,
-# has three rows and two columns:
-# "foo,0\nbar,1\nbaz,2\n"
-#
-# Despite the name \CSV, a \CSV representation can use different separators.
-#
-# For more about tables, see the Wikipedia article
-# "{Table (information)}[https://en.wikipedia.org/wiki/Table_(information)]",
-# especially its section
-# "{Simple table}[https://en.wikipedia.org/wiki/Table_(information)#Simple_table]"
-#
-# == \Class \CSV
-#
-# Class \CSV provides methods for:
-# - Parsing \CSV data from a \String object, a \File (via its file path), or an \IO object.
-# - Generating \CSV data to a \String object.
-#
-# To make \CSV available:
-# require 'csv'
-#
-# All examples here assume that this has been done.
-#
-# == Keeping It Simple
-#
-# A \CSV object has dozens of instance methods that offer fine-grained control
-# of parsing and generating \CSV data.
-# For many needs, though, simpler approaches will do.
-#
-# This section summarizes the singleton methods in \CSV
-# that allow you to parse and generate without explicitly
-# creating \CSV objects.
-# For details, follow the links.
-#
-# === Simple Parsing
-#
-# Parsing methods commonly return either of:
-# - An \Array of Arrays of Strings:
-# - The outer \Array is the entire "table".
-# - Each inner \Array is a row.
-# - Each \String is a field.
-# - A CSV::Table object. For details, see
-# {\CSV with Headers}[#class-CSV-label-CSV+with+Headers].
-#
-# ==== Parsing a \String
-#
-# The input to be parsed can be a string:
-# string = "foo,0\nbar,1\nbaz,2\n"
-#
-# \Method CSV.parse returns the entire \CSV data:
-# CSV.parse(string) # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# \Method CSV.parse_line returns only the first row:
-# CSV.parse_line(string) # => ["foo", "0"]
-#
-# \CSV extends class \String with instance method String#parse_csv,
-# which also returns only the first row:
-# string.parse_csv # => ["foo", "0"]
-#
-# ==== Parsing Via a \File Path
-#
-# The input to be parsed can be in a file:
-# string = "foo,0\nbar,1\nbaz,2\n"
-# path = 't.csv'
-# File.write(path, string)
-#
-# \Method CSV.read returns the entire \CSV data:
-# CSV.read(path) # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# \Method CSV.foreach iterates, passing each row to the given block:
-# CSV.foreach(path) do |row|
-# p row
-# end
-# Output:
-# ["foo", "0"]
-# ["bar", "1"]
-# ["baz", "2"]
-#
-# \Method CSV.table returns the entire \CSV data as a CSV::Table object:
-# CSV.table(path) # => #<CSV::Table mode:col_or_row row_count:3>
-#
-# ==== Parsing from an Open \IO Stream
-#
-# The input to be parsed can be in an open \IO stream:
-#
-# \Method CSV.read returns the entire \CSV data:
-# File.open(path) do |file|
-# CSV.read(file)
-# end # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# As does method CSV.parse:
-# File.open(path) do |file|
-# CSV.parse(file)
-# end # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# \Method CSV.parse_line returns only the first row:
-# File.open(path) do |file|
-# CSV.parse_line(file)
-# end # => ["foo", "0"]
-#
-# \Method CSV.foreach iterates, passing each row to the given block:
-# File.open(path) do |file|
-# CSV.foreach(file) do |row|
-# p row
-# end
-# end
-# Output:
-# ["foo", "0"]
-# ["bar", "1"]
-# ["baz", "2"]
-#
-# \Method CSV.table returns the entire \CSV data as a CSV::Table object:
-# File.open(path) do |file|
-# CSV.table(file)
-# end # => #<CSV::Table mode:col_or_row row_count:3>
-#
-# === Simple Generating
-#
-# \Method CSV.generate returns a \String;
-# this example uses method CSV#<< to append the rows
-# that are to be generated:
-# output_string = CSV.generate do |csv|
-# csv << ['foo', 0]
-# csv << ['bar', 1]
-# csv << ['baz', 2]
-# end
-# output_string # => "foo,0\nbar,1\nbaz,2\n"
-#
-# \Method CSV.generate_line returns a \String containing the single row
-# constructed from an \Array:
-# CSV.generate_line(['foo', '0']) # => "foo,0\n"
-#
-# \CSV extends class \Array with instance method <tt>Array#to_csv</tt>,
-# which forms an \Array into a \String:
-# ['foo', '0'].to_csv # => "foo,0\n"
-#
-# === "Filtering" \CSV
-#
-# \Method CSV.filter provides a Unix-style filter for \CSV data.
-# The input data is processed to form the output data:
-# in_string = "foo,0\nbar,1\nbaz,2\n"
-# out_string = ''
-# CSV.filter(in_string, out_string) do |row|
-# row[0] = row[0].upcase
-# row[1] *= 4
-# end
-# out_string # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
-#
-# == \CSV Objects
-#
-# There are three ways to create a \CSV object:
-# - \Method CSV.new returns a new \CSV object.
-# - \Method CSV.instance returns a new or cached \CSV object.
-# - \Method \CSV() also returns a new or cached \CSV object.
-#
-# === Instance Methods
-#
-# \CSV has three groups of instance methods:
-# - Its own internally defined instance methods.
-# - Methods included by module Enumerable.
-# - Methods delegated to class IO. See below.
-#
-# ==== Delegated Methods
-#
-# For convenience, a CSV object will delegate to many methods in class IO.
-# (A few have wrapper "guard code" in \CSV.) You may call:
-# * IO#binmode
-# * #binmode?
-# * IO#close
-# * IO#close_read
-# * IO#close_write
-# * IO#closed?
-# * #eof
-# * #eof?
-# * IO#external_encoding
-# * IO#fcntl
-# * IO#fileno
-# * #flock
-# * IO#flush
-# * IO#fsync
-# * IO#internal_encoding
-# * #ioctl
-# * IO#isatty
-# * #path
-# * IO#pid
-# * IO#pos
-# * IO#pos=
-# * IO#reopen
-# * #rewind
-# * IO#seek
-# * #stat
-# * IO#string
-# * IO#sync
-# * IO#sync=
-# * IO#tell
-# * #to_i
-# * #to_io
-# * IO#truncate
-# * IO#tty?
-#
-# === Options
-#
-# The default values for options are:
-# DEFAULT_OPTIONS = {
-# # For both parsing and generating.
-# col_sep: ",",
-# row_sep: :auto,
-# quote_char: '"',
-# # For parsing.
-# field_size_limit: nil,
-# converters: nil,
-# unconverted_fields: nil,
-# headers: false,
-# return_headers: false,
-# header_converters: nil,
-# skip_blanks: false,
-# skip_lines: nil,
-# liberal_parsing: false,
-# nil_value: nil,
-# empty_value: "",
-# strip: false,
-# # For generating.
-# write_headers: nil,
-# quote_empty: true,
-# force_quotes: false,
-# write_converters: nil,
-# write_nil_value: nil,
-# write_empty_value: "",
-# }
-#
-# ==== Options for Parsing
-#
-# Options for parsing, described in detail below, include:
-# - +row_sep+: Specifies the row separator; used to delimit rows.
-# - +col_sep+: Specifies the column separator; used to delimit fields.
-# - +quote_char+: Specifies the quote character; used to quote fields.
-# - +field_size_limit+: Specifies the maximum field size + 1 allowed.
-# Deprecated since 3.2.3. Use +max_field_size+ instead.
-# - +max_field_size+: Specifies the maximum field size allowed.
-# - +converters+: Specifies the field converters to be used.
-# - +unconverted_fields+: Specifies whether unconverted fields are to be available.
-# - +headers+: Specifies whether data contains headers,
-# or specifies the headers themselves.
-# - +return_headers+: Specifies whether headers are to be returned.
-# - +header_converters+: Specifies the header converters to be used.
-# - +skip_blanks+: Specifies whether blanks lines are to be ignored.
-# - +skip_lines+: Specifies how comments lines are to be recognized.
-# - +strip+: Specifies whether leading and trailing whitespace are to be
-# stripped from fields. This must be compatible with +col_sep+; if it is not,
-# then an +ArgumentError+ exception will be raised.
-# - +liberal_parsing+: Specifies whether \CSV should attempt to parse
-# non-compliant data.
-# - +nil_value+: Specifies the object that is to be substituted for each null (no-text) field.
-# - +empty_value+: Specifies the object that is to be substituted for each empty field.
-#
-# :include: ../doc/csv/options/common/row_sep.rdoc
-#
-# :include: ../doc/csv/options/common/col_sep.rdoc
-#
-# :include: ../doc/csv/options/common/quote_char.rdoc
-#
-# :include: ../doc/csv/options/parsing/field_size_limit.rdoc
-#
-# :include: ../doc/csv/options/parsing/converters.rdoc
-#
-# :include: ../doc/csv/options/parsing/unconverted_fields.rdoc
-#
-# :include: ../doc/csv/options/parsing/headers.rdoc
-#
-# :include: ../doc/csv/options/parsing/return_headers.rdoc
-#
-# :include: ../doc/csv/options/parsing/header_converters.rdoc
-#
-# :include: ../doc/csv/options/parsing/skip_blanks.rdoc
-#
-# :include: ../doc/csv/options/parsing/skip_lines.rdoc
-#
-# :include: ../doc/csv/options/parsing/strip.rdoc
-#
-# :include: ../doc/csv/options/parsing/liberal_parsing.rdoc
-#
-# :include: ../doc/csv/options/parsing/nil_value.rdoc
-#
-# :include: ../doc/csv/options/parsing/empty_value.rdoc
-#
-# ==== Options for Generating
-#
-# Options for generating, described in detail below, include:
-# - +row_sep+: Specifies the row separator; used to delimit rows.
-# - +col_sep+: Specifies the column separator; used to delimit fields.
-# - +quote_char+: Specifies the quote character; used to quote fields.
-# - +write_headers+: Specifies whether headers are to be written.
-# - +force_quotes+: Specifies whether each output field is to be quoted.
-# - +quote_empty+: Specifies whether each empty output field is to be quoted.
-# - +write_converters+: Specifies the field converters to be used in writing.
-# - +write_nil_value+: Specifies the object that is to be substituted for each +nil+-valued field.
-# - +write_empty_value+: Specifies the object that is to be substituted for each empty field.
-#
-# :include: ../doc/csv/options/common/row_sep.rdoc
-#
-# :include: ../doc/csv/options/common/col_sep.rdoc
-#
-# :include: ../doc/csv/options/common/quote_char.rdoc
-#
-# :include: ../doc/csv/options/generating/write_headers.rdoc
-#
-# :include: ../doc/csv/options/generating/force_quotes.rdoc
-#
-# :include: ../doc/csv/options/generating/quote_empty.rdoc
-#
-# :include: ../doc/csv/options/generating/write_converters.rdoc
-#
-# :include: ../doc/csv/options/generating/write_nil_value.rdoc
-#
-# :include: ../doc/csv/options/generating/write_empty_value.rdoc
-#
-# === \CSV with Headers
-#
-# CSV allows to specify column names of CSV file, whether they are in data, or
-# provided separately. If headers are specified, reading methods return an instance
-# of CSV::Table, consisting of CSV::Row.
-#
-# # Headers are part of data
-# data = CSV.parse(<<~ROWS, headers: true)
-# Name,Department,Salary
-# Bob,Engineering,1000
-# Jane,Sales,2000
-# John,Management,5000
-# ROWS
-#
-# data.class #=> CSV::Table
-# data.first #=> #<CSV::Row "Name":"Bob" "Department":"Engineering" "Salary":"1000">
-# data.first.to_h #=> {"Name"=>"Bob", "Department"=>"Engineering", "Salary"=>"1000"}
-#
-# # Headers provided by developer
-# data = CSV.parse('Bob,Engineering,1000', headers: %i[name department salary])
-# data.first #=> #<CSV::Row name:"Bob" department:"Engineering" salary:"1000">
-#
-# === \Converters
-#
-# By default, each value (field or header) parsed by \CSV is formed into a \String.
-# You can use a _field_ _converter_ or _header_ _converter_
-# to intercept and modify the parsed values:
-# - See {Field Converters}[#class-CSV-label-Field+Converters].
-# - See {Header Converters}[#class-CSV-label-Header+Converters].
-#
-# Also by default, each value to be written during generation is written 'as-is'.
-# You can use a _write_ _converter_ to modify values before writing.
-# - See {Write Converters}[#class-CSV-label-Write+Converters].
-#
-# ==== Specifying \Converters
-#
-# You can specify converters for parsing or generating in the +options+
-# argument to various \CSV methods:
-# - Option +converters+ for converting parsed field values.
-# - Option +header_converters+ for converting parsed header values.
-# - Option +write_converters+ for converting values to be written (generated).
-#
-# There are three forms for specifying converters:
-# - A converter proc: executable code to be used for conversion.
-# - A converter name: the name of a stored converter.
-# - A converter list: an array of converter procs, converter names, and converter lists.
-#
-# ===== Converter Procs
-#
-# This converter proc, +strip_converter+, accepts a value +field+
-# and returns <tt>field.strip</tt>:
-# strip_converter = proc {|field| field.strip }
-# In this call to <tt>CSV.parse</tt>,
-# the keyword argument <tt>converters: string_converter</tt>
-# specifies that:
-# - \Proc +string_converter+ is to be called for each parsed field.
-# - The converter's return value is to replace the +field+ value.
-# Example:
-# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
-# array = CSV.parse(string, converters: strip_converter)
-# array # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# A converter proc can receive a second argument, +field_info+,
-# that contains details about the field.
-# This modified +strip_converter+ displays its arguments:
-# strip_converter = proc do |field, field_info|
-# p [field, field_info]
-# field.strip
-# end
-# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
-# array = CSV.parse(string, converters: strip_converter)
-# array # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-# Output:
-# [" foo ", #<struct CSV::FieldInfo index=0, line=1, header=nil>]
-# [" 0 ", #<struct CSV::FieldInfo index=1, line=1, header=nil>]
-# [" bar ", #<struct CSV::FieldInfo index=0, line=2, header=nil>]
-# [" 1 ", #<struct CSV::FieldInfo index=1, line=2, header=nil>]
-# [" baz ", #<struct CSV::FieldInfo index=0, line=3, header=nil>]
-# [" 2 ", #<struct CSV::FieldInfo index=1, line=3, header=nil>]
-# Each CSV::FieldInfo object shows:
-# - The 0-based field index.
-# - The 1-based line index.
-# - The field header, if any.
-#
-# ===== Stored \Converters
-#
-# A converter may be given a name and stored in a structure where
-# the parsing methods can find it by name.
-#
-# The storage structure for field converters is the \Hash CSV::Converters.
-# It has several built-in converter procs:
-# - <tt>:integer</tt>: converts each \String-embedded integer into a true \Integer.
-# - <tt>:float</tt>: converts each \String-embedded float into a true \Float.
-# - <tt>:date</tt>: converts each \String-embedded date into a true \Date.
-# - <tt>:date_time</tt>: converts each \String-embedded date-time into a true \DateTime
-# .
-# This example creates a converter proc, then stores it:
-# strip_converter = proc {|field| field.strip }
-# CSV::Converters[:strip] = strip_converter
-# Then the parsing method call can refer to the converter
-# by its name, <tt>:strip</tt>:
-# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
-# array = CSV.parse(string, converters: :strip)
-# array # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# The storage structure for header converters is the \Hash CSV::HeaderConverters,
-# which works in the same way.
-# It also has built-in converter procs:
-# - <tt>:downcase</tt>: Downcases each header.
-# - <tt>:symbol</tt>: Converts each header to a \Symbol.
-#
-# There is no such storage structure for write headers.
-#
-# In order for the parsing methods to access stored converters in non-main-Ractors, the
-# storage structure must be made shareable first.
-# Therefore, <tt>Ractor.make_shareable(CSV::Converters)</tt> and
-# <tt>Ractor.make_shareable(CSV::HeaderConverters)</tt> must be called before the creation
-# of Ractors that use the converters stored in these structures. (Since making the storage
-# structures shareable involves freezing them, any custom converters that are to be used
-# must be added first.)
-#
-# ===== Converter Lists
-#
-# A _converter_ _list_ is an \Array that may include any assortment of:
-# - Converter procs.
-# - Names of stored converters.
-# - Nested converter lists.
-#
-# Examples:
-# numeric_converters = [:integer, :float]
-# date_converters = [:date, :date_time]
-# [numeric_converters, strip_converter]
-# [strip_converter, date_converters, :float]
-#
-# Like a converter proc, a converter list may be named and stored in either
-# \CSV::Converters or CSV::HeaderConverters:
-# CSV::Converters[:custom] = [strip_converter, date_converters, :float]
-# CSV::HeaderConverters[:custom] = [:downcase, :symbol]
-#
-# There are two built-in converter lists:
-# CSV::Converters[:numeric] # => [:integer, :float]
-# CSV::Converters[:all] # => [:date_time, :numeric]
-#
-# ==== Field \Converters
-#
-# With no conversion, all parsed fields in all rows become Strings:
-# string = "foo,0\nbar,1\nbaz,2\n"
-# ary = CSV.parse(string)
-# ary # => # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# When you specify a field converter, each parsed field is passed to the converter;
-# its return value becomes the stored value for the field.
-# A converter might, for example, convert an integer embedded in a \String
-# into a true \Integer.
-# (In fact, that's what built-in field converter +:integer+ does.)
-#
-# There are three ways to use field \converters.
-#
-# - Using option {converters}[#class-CSV-label-Option+converters] with a parsing method:
-# ary = CSV.parse(string, converters: :integer)
-# ary # => [0, 1, 2] # => [["foo", 0], ["bar", 1], ["baz", 2]]
-# - Using option {converters}[#class-CSV-label-Option+converters] with a new \CSV instance:
-# csv = CSV.new(string, converters: :integer)
-# # Field converters in effect:
-# csv.converters # => [:integer]
-# csv.read # => [["foo", 0], ["bar", 1], ["baz", 2]]
-# - Using method #convert to add a field converter to a \CSV instance:
-# csv = CSV.new(string)
-# # Add a converter.
-# csv.convert(:integer)
-# csv.converters # => [:integer]
-# csv.read # => [["foo", 0], ["bar", 1], ["baz", 2]]
-#
-# Installing a field converter does not affect already-read rows:
-# csv = CSV.new(string)
-# csv.shift # => ["foo", "0"]
-# # Add a converter.
-# csv.convert(:integer)
-# csv.converters # => [:integer]
-# csv.read # => [["bar", 1], ["baz", 2]]
-#
-# There are additional built-in \converters, and custom \converters are also supported.
-#
-# ===== Built-In Field \Converters
-#
-# The built-in field converters are in \Hash CSV::Converters:
-# - Each key is a field converter name.
-# - Each value is one of:
-# - A \Proc field converter.
-# - An \Array of field converter names.
-#
-# Display:
-# CSV::Converters.each_pair do |name, value|
-# if value.kind_of?(Proc)
-# p [name, value.class]
-# else
-# p [name, value]
-# end
-# end
-# Output:
-# [:integer, Proc]
-# [:float, Proc]
-# [:numeric, [:integer, :float]]
-# [:date, Proc]
-# [:date_time, Proc]
-# [:all, [:date_time, :numeric]]
-#
-# Each of these converters transcodes values to UTF-8 before attempting conversion.
-# If a value cannot be transcoded to UTF-8 the conversion will
-# fail and the value will remain unconverted.
-#
-# Converter +:integer+ converts each field that Integer() accepts:
-# data = '0,1,2,x'
-# # Without the converter
-# csv = CSV.parse_line(data)
-# csv # => ["0", "1", "2", "x"]
-# # With the converter
-# csv = CSV.parse_line(data, converters: :integer)
-# csv # => [0, 1, 2, "x"]
-#
-# Converter +:float+ converts each field that Float() accepts:
-# data = '1.0,3.14159,x'
-# # Without the converter
-# csv = CSV.parse_line(data)
-# csv # => ["1.0", "3.14159", "x"]
-# # With the converter
-# csv = CSV.parse_line(data, converters: :float)
-# csv # => [1.0, 3.14159, "x"]
-#
-# Converter +:numeric+ converts with both +:integer+ and +:float+..
-#
-# Converter +:date+ converts each field that Date::parse accepts:
-# data = '2001-02-03,x'
-# # Without the converter
-# csv = CSV.parse_line(data)
-# csv # => ["2001-02-03", "x"]
-# # With the converter
-# csv = CSV.parse_line(data, converters: :date)
-# csv # => [#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, "x"]
-#
-# Converter +:date_time+ converts each field that DateTime::parse accepts:
-# data = '2020-05-07T14:59:00-05:00,x'
-# # Without the converter
-# csv = CSV.parse_line(data)
-# csv # => ["2020-05-07T14:59:00-05:00", "x"]
-# # With the converter
-# csv = CSV.parse_line(data, converters: :date_time)
-# csv # => [#<DateTime: 2020-05-07T14:59:00-05:00 ((2458977j,71940s,0n),-18000s,2299161j)>, "x"]
-#
-# Converter +:numeric+ converts with both +:date_time+ and +:numeric+..
-#
-# As seen above, method #convert adds \converters to a \CSV instance,
-# and method #converters returns an \Array of the \converters in effect:
-# csv = CSV.new('0,1,2')
-# csv.converters # => []
-# csv.convert(:integer)
-# csv.converters # => [:integer]
-# csv.convert(:date)
-# csv.converters # => [:integer, :date]
-#
-# ===== Custom Field \Converters
-#
-# You can define a custom field converter:
-# strip_converter = proc {|field| field.strip }
-# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
-# array = CSV.parse(string, converters: strip_converter)
-# array # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-# You can register the converter in \Converters \Hash,
-# which allows you to refer to it by name:
-# CSV::Converters[:strip] = strip_converter
-# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
-# array = CSV.parse(string, converters: :strip)
-# array # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
-#
-# ==== Header \Converters
-#
-# Header converters operate only on headers (and not on other rows).
-#
-# There are three ways to use header \converters;
-# these examples use built-in header converter +:downcase+,
-# which downcases each parsed header.
-#
-# - Option +header_converters+ with a singleton parsing method:
-# string = "Name,Count\nFoo,0\n,Bar,1\nBaz,2"
-# tbl = CSV.parse(string, headers: true, header_converters: :downcase)
-# tbl.class # => CSV::Table
-# tbl.headers # => ["name", "count"]
-#
-# - Option +header_converters+ with a new \CSV instance:
-# csv = CSV.new(string, header_converters: :downcase)
-# # Header converters in effect:
-# csv.header_converters # => [:downcase]
-# tbl = CSV.parse(string, headers: true)
-# tbl.headers # => ["Name", "Count"]
-#
-# - Method #header_convert adds a header converter to a \CSV instance:
-# csv = CSV.new(string)
-# # Add a header converter.
-# csv.header_convert(:downcase)
-# csv.header_converters # => [:downcase]
-# tbl = CSV.parse(string, headers: true)
-# tbl.headers # => ["Name", "Count"]
-#
-# ===== Built-In Header \Converters
-#
-# The built-in header \converters are in \Hash CSV::HeaderConverters.
-# The keys there are the names of the \converters:
-# CSV::HeaderConverters.keys # => [:downcase, :symbol]
-#
-# Converter +:downcase+ converts each header by downcasing it:
-# string = "Name,Count\nFoo,0\n,Bar,1\nBaz,2"
-# tbl = CSV.parse(string, headers: true, header_converters: :downcase)
-# tbl.class # => CSV::Table
-# tbl.headers # => ["name", "count"]
-#
-# Converter +:symbol+ converts each header by making it into a \Symbol:
-# string = "Name,Count\nFoo,0\n,Bar,1\nBaz,2"
-# tbl = CSV.parse(string, headers: true, header_converters: :symbol)
-# tbl.headers # => [:name, :count]
-# Details:
-# - Strips leading and trailing whitespace.
-# - Downcases the header.
-# - Replaces embedded spaces with underscores.
-# - Removes non-word characters.
-# - Makes the string into a \Symbol.
-#
-# ===== Custom Header \Converters
-#
-# You can define a custom header converter:
-# upcase_converter = proc {|header| header.upcase }
-# string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
-# table = CSV.parse(string, headers: true, header_converters: upcase_converter)
-# table # => #<CSV::Table mode:col_or_row row_count:4>
-# table.headers # => ["NAME", "VALUE"]
-# You can register the converter in \HeaderConverters \Hash,
-# which allows you to refer to it by name:
-# CSV::HeaderConverters[:upcase] = upcase_converter
-# table = CSV.parse(string, headers: true, header_converters: :upcase)
-# table # => #<CSV::Table mode:col_or_row row_count:4>
-# table.headers # => ["NAME", "VALUE"]
-#
-# ===== Write \Converters
-#
-# When you specify a write converter for generating \CSV,
-# each field to be written is passed to the converter;
-# its return value becomes the new value for the field.
-# A converter might, for example, strip whitespace from a field.
-#
-# Using no write converter (all fields unmodified):
-# output_string = CSV.generate do |csv|
-# csv << [' foo ', 0]
-# csv << [' bar ', 1]
-# csv << [' baz ', 2]
-# end
-# output_string # => " foo ,0\n bar ,1\n baz ,2\n"
-# Using option +write_converters+ with two custom write converters:
-# strip_converter = proc {|field| field.respond_to?(:strip) ? field.strip : field }
-# upcase_converter = proc {|field| field.respond_to?(:upcase) ? field.upcase : field }
-# write_converters = [strip_converter, upcase_converter]
-# output_string = CSV.generate(write_converters: write_converters) do |csv|
-# csv << [' foo ', 0]
-# csv << [' bar ', 1]
-# csv << [' baz ', 2]
-# end
-# output_string # => "FOO,0\nBAR,1\nBAZ,2\n"
-#
-# === Character Encodings (M17n or Multilingualization)
-#
-# This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
-# or String object being read from or written to. Your data is never transcoded
-# (unless you ask Ruby to transcode it for you) and will literally be parsed in
-# the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
-# Encoding of your data. This is accomplished by transcoding the parser itself
-# into your Encoding.
-#
-# Some transcoding must take place, of course, to accomplish this multiencoding
-# support. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and
-# <tt>:quote_char</tt> must be transcoded to match your data. Hopefully this
-# makes the entire process feel transparent, since CSV's defaults should just
-# magically work for your data. However, you can set these values manually in
-# the target Encoding to avoid the translation.
-#
-# It's also important to note that while all of CSV's core parser is now
-# Encoding agnostic, some features are not. For example, the built-in
-# converters will try to transcode data to UTF-8 before making conversions.
-# Again, you can provide custom converters that are aware of your Encodings to
-# avoid this translation. It's just too hard for me to support native
-# conversions in all of Ruby's Encodings.
-#
-# Anyway, the practical side of this is simple: make sure IO and String objects
-# passed into CSV have the proper Encoding set and everything should just work.
-# CSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(),
-# CSV::read(), and CSV::readlines()) do allow you to specify the Encoding.
-#
-# One minor exception comes when generating CSV into a String with an Encoding
-# that is not ASCII compatible. There's no existing data for CSV to use to
-# prepare itself and thus you will probably need to manually specify the desired
-# Encoding for most of those cases. It will try to guess using the fields in a
-# row of output though, when using CSV::generate_line() or Array#to_csv().
-#
-# I try to point out any other Encoding issues in the documentation of methods
-# as they come up.
-#
-# This has been tested to the best of my ability with all non-"dummy" Encodings
-# Ruby ships with. However, it is brave new code and may have some bugs.
-# Please feel free to {report}[mailto:james@grayproductions.net] any issues you
-# find with it.
-#
-class CSV
-
- # The error thrown when the parser encounters illegal CSV formatting.
- class MalformedCSVError < RuntimeError
- attr_reader :line_number
- alias_method :lineno, :line_number
- def initialize(message, line_number)
- @line_number = line_number
- super("#{message} in line #{line_number}.")
- end
- 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.
- # <b><tt>quoted?</tt></b>:: True or false, whether the original value is quoted or not.
- #
- FieldInfo = Struct.new(:index, :line, :header, :quoted?)
-
- # 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} |
- # ISO-8601 and RFC-3339 (space instead of T) recognized by DateTime.parse
- \d{4}-\d{2}-\d{2}
- (?:[T\s]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?(?:[+-]\d{2}(?::\d{2})|Z)?)?)?
- )\z /x
-
- # The encoding used by all converters.
- ConverterEncoding = Encoding.find("UTF-8")
-
- # A \Hash containing the names and \Procs for the built-in field converters.
- # See {Built-In Field Converters}[#class-CSV-label-Built-In+Field+Converters].
- #
- # This \Hash is intentionally left unfrozen, and may be extended with
- # custom field converters.
- # See {Custom Field Converters}[#class-CSV-label-Custom+Field+Converters].
- Converters = {
- integer: lambda { |f|
- Integer(f.encode(ConverterEncoding)) rescue f
- },
- float: lambda { |f|
- Float(f.encode(ConverterEncoding)) rescue f
- },
- numeric: [:integer, :float],
- date: lambda { |f|
- begin
- e = f.encode(ConverterEncoding)
- e.match?(DateMatcher) ? Date.parse(e) : f
- rescue # encoding conversion or date parse errors
- f
- end
- },
- date_time: lambda { |f|
- begin
- e = f.encode(ConverterEncoding)
- e.match?(DateTimeMatcher) ? DateTime.parse(e) : f
- rescue # encoding conversion or date parse errors
- f
- end
- },
- all: [:date_time, :numeric],
- }
-
- # A \Hash containing the names and \Procs for the built-in header converters.
- # See {Built-In Header Converters}[#class-CSV-label-Built-In+Header+Converters].
- #
- # This \Hash is intentionally left unfrozen, and may be extended with
- # custom field converters.
- # See {Custom Header Converters}[#class-CSV-label-Custom+Header+Converters].
- HeaderConverters = {
- downcase: lambda { |h| h.encode(ConverterEncoding).downcase },
- symbol: lambda { |h|
- h.encode(ConverterEncoding).downcase.gsub(/[^\s\w]+/, "").strip.
- gsub(/\s+/, "_").to_sym
- },
- symbol_raw: lambda { |h| h.encode(ConverterEncoding).to_sym }
- }
-
- # Default values for method options.
- DEFAULT_OPTIONS = {
- # For both parsing and generating.
- col_sep: ",",
- row_sep: :auto,
- quote_char: '"',
- # For parsing.
- field_size_limit: nil,
- max_field_size: nil,
- converters: nil,
- unconverted_fields: nil,
- headers: false,
- return_headers: false,
- header_converters: nil,
- skip_blanks: false,
- skip_lines: nil,
- liberal_parsing: false,
- nil_value: nil,
- empty_value: "",
- strip: false,
- # For generating.
- write_headers: nil,
- quote_empty: true,
- force_quotes: false,
- write_converters: nil,
- write_nil_value: nil,
- write_empty_value: "",
- }.freeze
-
- class << self
- # :call-seq:
- # instance(string, **options)
- # instance(io = $stdout, **options)
- # instance(string, **options) {|csv| ... }
- # instance(io = $stdout, **options) {|csv| ... }
- #
- # Creates or retrieves cached \CSV objects.
- # For arguments and options, see CSV.new.
- #
- # This API is not Ractor-safe.
- #
- # ---
- #
- # With no block given, returns a \CSV object.
- #
- # The first call to +instance+ creates and caches a \CSV object:
- # s0 = 's0'
- # csv0 = CSV.instance(s0)
- # csv0.class # => CSV
- #
- # Subsequent calls to +instance+ with that _same_ +string+ or +io+
- # retrieve that same cached object:
- # csv1 = CSV.instance(s0)
- # csv1.class # => CSV
- # csv1.equal?(csv0) # => true # Same CSV object
- #
- # A subsequent call to +instance+ with a _different_ +string+ or +io+
- # creates and caches a _different_ \CSV object.
- # s1 = 's1'
- # csv2 = CSV.instance(s1)
- # csv2.equal?(csv0) # => false # Different CSV object
- #
- # All the cached objects remains available:
- # csv3 = CSV.instance(s0)
- # csv3.equal?(csv0) # true # Same CSV object
- # csv4 = CSV.instance(s1)
- # csv4.equal?(csv2) # true # Same CSV object
- #
- # ---
- #
- # When a block is given, calls the block with the created or retrieved
- # \CSV object; returns the block's return value:
- # CSV.instance(s0) {|csv| :foo } # => :foo
- def instance(data = $stdout, **options)
- # create a _signature_ for this method call, data object and options
- sig = [data.object_id] +
- options.values_at(*DEFAULT_OPTIONS.keys)
-
- # fetch or create the instance for this signature
- @@instances ||= Hash.new
- instance = (@@instances[sig] ||= new(data, **options))
-
- if block_given?
- yield instance # run block, if given, returning result
- else
- instance # or return the instance
- end
- end
-
- # :call-seq:
- # filter(in_string_or_io, **options) {|row| ... } -> array_of_arrays or csv_table
- # filter(in_string_or_io, out_string_or_io, **options) {|row| ... } -> array_of_arrays or csv_table
- # filter(**options) {|row| ... } -> array_of_arrays or csv_table
- #
- # - Parses \CSV from a source (\String, \IO stream, or ARGF).
- # - Calls the given block with each parsed row:
- # - Without headers, each row is an \Array.
- # - With headers, each row is a CSV::Row.
- # - Generates \CSV to an output (\String, \IO stream, or STDOUT).
- # - Returns the parsed source:
- # - Without headers, an \Array of \Arrays.
- # - With headers, a CSV::Table.
- #
- # When +in_string_or_io+ is given, but not +out_string_or_io+,
- # parses from the given +in_string_or_io+
- # and generates to STDOUT.
- #
- # \String input without headers:
- #
- # in_string = "foo,0\nbar,1\nbaz,2"
- # CSV.filter(in_string) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end # => [["FOO", 0], ["BAR", -1], ["BAZ", -2]]
- #
- # Output (to STDOUT):
- #
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # \String input with headers:
- #
- # in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2"
- # CSV.filter(in_string, headers: true) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # Output (to STDOUT):
- #
- # Name,Value
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # \IO stream input without headers:
- #
- # File.write('t.csv', "foo,0\nbar,1\nbaz,2")
- # File.open('t.csv') do |in_io|
- # CSV.filter(in_io) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # end # => [["FOO", 0], ["BAR", -1], ["BAZ", -2]]
- #
- # Output (to STDOUT):
- #
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # \IO stream input with headers:
- #
- # File.write('t.csv', "Name,Value\nfoo,0\nbar,1\nbaz,2")
- # File.open('t.csv') do |in_io|
- # CSV.filter(in_io, headers: true) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # end # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # Output (to STDOUT):
- #
- # Name,Value
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # When both +in_string_or_io+ and +out_string_or_io+ are given,
- # parses from +in_string_or_io+ and generates to +out_string_or_io+.
- #
- # \String output without headers:
- #
- # in_string = "foo,0\nbar,1\nbaz,2"
- # out_string = ''
- # CSV.filter(in_string, out_string) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end # => [["FOO", 0], ["BAR", -1], ["BAZ", -2]]
- # out_string # => "FOO,0\nBAR,-1\nBAZ,-2\n"
- #
- # \String output with headers:
- #
- # in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2"
- # out_string = ''
- # CSV.filter(in_string, out_string, headers: true) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end # => #<CSV::Table mode:col_or_row row_count:4>
- # out_string # => "Name,Value\nFOO,0\nBAR,-1\nBAZ,-2\n"
- #
- # \IO stream output without headers:
- #
- # in_string = "foo,0\nbar,1\nbaz,2"
- # File.open('t.csv', 'w') do |out_io|
- # CSV.filter(in_string, out_io) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # end # => [["FOO", 0], ["BAR", -1], ["BAZ", -2]]
- # File.read('t.csv') # => "FOO,0\nBAR,-1\nBAZ,-2\n"
- #
- # \IO stream output with headers:
- #
- # in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2"
- # File.open('t.csv', 'w') do |out_io|
- # CSV.filter(in_string, out_io, headers: true) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # end # => #<CSV::Table mode:col_or_row row_count:4>
- # File.read('t.csv') # => "Name,Value\nFOO,0\nBAR,-1\nBAZ,-2\n"
- #
- # When neither +in_string_or_io+ nor +out_string_or_io+ given,
- # parses from {ARGF}[rdoc-ref:ARGF]
- # and generates to STDOUT.
- #
- # Without headers:
- #
- # # Put Ruby code into a file.
- # ruby = <<-EOT
- # require 'csv'
- # CSV.filter do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # EOT
- # File.write('t.rb', ruby)
- # # Put some CSV into a file.
- # File.write('t.csv', "foo,0\nbar,1\nbaz,2")
- # # Run the Ruby code with CSV filename as argument.
- # system(Gem.ruby, "t.rb", "t.csv")
- #
- # Output (to STDOUT):
- #
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # With headers:
- #
- # # Put Ruby code into a file.
- # ruby = <<-EOT
- # require 'csv'
- # CSV.filter(headers: true) do |row|
- # row[0].upcase!
- # row[1] = - row[1].to_i
- # end
- # EOT
- # File.write('t.rb', ruby)
- # # Put some CSV into a file.
- # File.write('t.csv', "Name,Value\nfoo,0\nbar,1\nbaz,2")
- # # Run the Ruby code with CSV filename as argument.
- # system(Gem.ruby, "t.rb", "t.csv")
- #
- # Output (to STDOUT):
- #
- # Name,Value
- # FOO,0
- # BAR,-1
- # BAZ,-2
- #
- # Arguments:
- #
- # * Argument +in_string_or_io+ must be a \String or an \IO stream.
- # * Argument +out_string_or_io+ must be a \String or an \IO stream.
- # * Arguments <tt>**options</tt> must be keyword options.
- # See {Options for Parsing}[#class-CSV-label-Options+for+Parsing].
- def filter(input=nil, output=nil, **options)
- # parse options for input, output, or both
- in_options, out_options = Hash.new, {row_sep: InputRecordSeparator.value}
- options.each do |key, value|
- case key
- 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
- end
- end
-
- # build input and output wrappers
- input = new(input || ARGF, **in_options)
- output = new(output || $stdout, **out_options)
-
- # process headers
- need_manual_header_output =
- (in_options[:headers] and
- out_options[:headers] == true and
- out_options[:write_headers])
- if need_manual_header_output
- first_row = input.shift
- if first_row
- if first_row.is_a?(Row)
- headers = first_row.headers
- yield headers
- output << headers
- end
- yield first_row
- output << first_row
- end
- end
-
- # read, yield, write
- input.each do |row|
- yield row
- output << row
- end
- end
-
- #
- # :call-seq:
- # foreach(path_or_io, mode='r', **options) {|row| ... )
- # foreach(path_or_io, mode='r', **options) -> new_enumerator
- #
- # Calls the block with each row read from source +path_or_io+.
- #
- # \Path input without headers:
- #
- # string = "foo,0\nbar,1\nbaz,2\n"
- # in_path = 't.csv'
- # File.write(in_path, string)
- # CSV.foreach(in_path) {|row| p row }
- #
- # Output:
- #
- # ["foo", "0"]
- # ["bar", "1"]
- # ["baz", "2"]
- #
- # \Path input with headers:
- #
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # in_path = 't.csv'
- # File.write(in_path, string)
- # CSV.foreach(in_path, headers: true) {|row| p row }
- #
- # Output:
- #
- # <CSV::Row "Name":"foo" "Value":"0">
- # <CSV::Row "Name":"bar" "Value":"1">
- # <CSV::Row "Name":"baz" "Value":"2">
- #
- # \IO stream input without headers:
- #
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # File.open('t.csv') do |in_io|
- # CSV.foreach(in_io) {|row| p row }
- # end
- #
- # Output:
- #
- # ["foo", "0"]
- # ["bar", "1"]
- # ["baz", "2"]
- #
- # \IO stream input with headers:
- #
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # File.open('t.csv') do |in_io|
- # CSV.foreach(in_io, headers: true) {|row| p row }
- # end
- #
- # Output:
- #
- # <CSV::Row "Name":"foo" "Value":"0">
- # <CSV::Row "Name":"bar" "Value":"1">
- # <CSV::Row "Name":"baz" "Value":"2">
- #
- # With no block given, returns an \Enumerator:
- #
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.foreach(path) # => #<Enumerator: CSV:foreach("t.csv", "r")>
- #
- # Arguments:
- # * Argument +path_or_io+ must be a file path or an \IO stream.
- # * Argument +mode+, if given, must be a \File mode
- # See {Open Mode}[https://ruby-doc.org/core/IO.html#method-c-new-label-Open+Mode].
- # * Arguments <tt>**options</tt> must be keyword options.
- # See {Options for Parsing}[#class-CSV-label-Options+for+Parsing].
- # * This method optionally accepts an additional <tt>:encoding</tt> option
- # that you can use to specify the Encoding of the data read from +path+ or +io+.
- # You must provide this unless your data is in the encoding
- # given by <tt>Encoding::default_external</tt>.
- # Parsing will use this to determine how to parse the data.
- # You may provide a second Encoding to
- # have the data transcoded as it is read. For example,
- # encoding: 'UTF-32BE:UTF-8'
- # would read +UTF-32BE+ data from the file
- # but transcode it to +UTF-8+ before parsing.
- def foreach(path, mode="r", **options, &block)
- return to_enum(__method__, path, mode, **options) unless block_given?
- open(path, mode, **options) do |csv|
- csv.each(&block)
- end
- end
-
- #
- # :call-seq:
- # generate(csv_string, **options) {|csv| ... }
- # generate(**options) {|csv| ... }
- #
- # * Argument +csv_string+, if given, must be a \String object;
- # defaults to a new empty \String.
- # * Arguments +options+, if given, should be generating options.
- # See {Options for Generating}[#class-CSV-label-Options+for+Generating].
- #
- # ---
- #
- # Creates a new \CSV object via <tt>CSV.new(csv_string, **options)</tt>;
- # calls the block with the \CSV object, which the block may modify;
- # returns the \String generated from the \CSV object.
- #
- # Note that a passed \String *is* modified by this method.
- # Pass <tt>csv_string</tt>.dup if the \String must be preserved.
- #
- # This method has one additional option: <tt>:encoding</tt>,
- # which sets the base Encoding for the output if no no +str+ is specified.
- # CSV needs this hint if you plan to output non-ASCII compatible data.
- #
- # ---
- #
- # Add lines:
- # input_string = "foo,0\nbar,1\nbaz,2\n"
- # output_string = CSV.generate(input_string) do |csv|
- # csv << ['bat', 3]
- # csv << ['bam', 4]
- # end
- # output_string # => "foo,0\nbar,1\nbaz,2\nbat,3\nbam,4\n"
- # input_string # => "foo,0\nbar,1\nbaz,2\nbat,3\nbam,4\n"
- # output_string.equal?(input_string) # => true # Same string, modified
- #
- # Add lines into new string, preserving old string:
- # input_string = "foo,0\nbar,1\nbaz,2\n"
- # output_string = CSV.generate(input_string.dup) do |csv|
- # csv << ['bat', 3]
- # csv << ['bam', 4]
- # end
- # output_string # => "foo,0\nbar,1\nbaz,2\nbat,3\nbam,4\n"
- # input_string # => "foo,0\nbar,1\nbaz,2\n"
- # output_string.equal?(input_string) # => false # Different strings
- #
- # Create lines from nothing:
- # output_string = CSV.generate do |csv|
- # csv << ['foo', 0]
- # csv << ['bar', 1]
- # csv << ['baz', 2]
- # end
- # output_string # => "foo,0\nbar,1\nbaz,2\n"
- #
- # ---
- #
- # Raises an exception if +csv_string+ is not a \String object:
- # # Raises TypeError (no implicit conversion of Integer into String)
- # CSV.generate(0)
- #
- def generate(str=nil, **options)
- encoding = options[:encoding]
- # add a default empty String, if none was given
- if str
- str = StringIO.new(str)
- str.seek(0, IO::SEEK_END)
- str.set_encoding(encoding) if encoding
- else
- str = +""
- str.force_encoding(encoding) if encoding
- end
- csv = new(str, **options) # wrap
- yield csv # yield for appending
- csv.string # return final String
- end
-
- # :call-seq:
- # CSV.generate_line(ary)
- # CSV.generate_line(ary, **options)
- #
- # Returns the \String created by generating \CSV from +ary+
- # using the specified +options+.
- #
- # Argument +ary+ must be an \Array.
- #
- # Special options:
- # * Option <tt>:row_sep</tt> defaults to <tt>"\n"> on Ruby 3.0 or later
- # and <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>) otherwise.:
- # $INPUT_RECORD_SEPARATOR # => "\n"
- # * This method accepts an additional option, <tt>:encoding</tt>, which sets the base
- # Encoding for the output. This method will try to guess your Encoding from
- # the first non-+nil+ field in +row+, if possible, but you may need to use
- # this parameter as a backup plan.
- #
- # For other +options+,
- # see {Options for Generating}[#class-CSV-label-Options+for+Generating].
- #
- # ---
- #
- # Returns the \String generated from an \Array:
- # CSV.generate_line(['foo', '0']) # => "foo,0\n"
- #
- # ---
- #
- # Raises an exception if +ary+ is not an \Array:
- # # Raises NoMethodError (undefined method `find' for :foo:Symbol)
- # CSV.generate_line(:foo)
- #
- def generate_line(row, **options)
- options = {row_sep: InputRecordSeparator.value}.merge(options)
- str = +""
- if options[:encoding]
- str.force_encoding(options[:encoding])
- else
- fallback_encoding = nil
- output_encoding = nil
- row.each do |field|
- next unless field.is_a?(String)
- fallback_encoding ||= field.encoding
- next if field.ascii_only?
- output_encoding = field.encoding
- break
- end
- output_encoding ||= fallback_encoding
- if output_encoding
- str.force_encoding(output_encoding)
- end
- end
- (new(str, **options) << row).string
- end
-
- # :call-seq:
- # CSV.generate_lines(rows)
- # CSV.generate_lines(rows, **options)
- #
- # Returns the \String created by generating \CSV from
- # using the specified +options+.
- #
- # Argument +rows+ must be an \Array of row. Row is \Array of \String or \CSV::Row.
- #
- # Special options:
- # * Option <tt>:row_sep</tt> defaults to <tt>"\n"</tt> on Ruby 3.0 or later
- # and <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>) otherwise.:
- # $INPUT_RECORD_SEPARATOR # => "\n"
- # * This method accepts an additional option, <tt>:encoding</tt>, which sets the base
- # Encoding for the output. This method will try to guess your Encoding from
- # the first non-+nil+ field in +row+, if possible, but you may need to use
- # this parameter as a backup plan.
- #
- # For other +options+,
- # see {Options for Generating}[#class-CSV-label-Options+for+Generating].
- #
- # ---
- #
- # Returns the \String generated from an
- # CSV.generate_lines([['foo', '0'], ['bar', '1'], ['baz', '2']]) # => "foo,0\nbar,1\nbaz,2\n"
- #
- # ---
- #
- # Raises an exception
- # # Raises NoMethodError (undefined method `each' for :foo:Symbol)
- # CSV.generate_lines(:foo)
- #
- def generate_lines(rows, **options)
- self.generate(**options) do |csv|
- rows.each do |row|
- csv << row
- end
- end
- end
-
- #
- # :call-seq:
- # open(file_path, mode = "rb", **options ) -> new_csv
- # open(io, mode = "rb", **options ) -> new_csv
- # open(file_path, mode = "rb", **options ) { |csv| ... } -> object
- # open(io, mode = "rb", **options ) { |csv| ... } -> object
- #
- # possible options elements:
- # keyword form:
- # :invalid => nil # raise error on invalid byte sequence (default)
- # :invalid => :replace # replace invalid byte sequence
- # :undef => :replace # replace undefined conversion
- # :replace => string # replacement string ("?" or "\uFFFD" if not specified)
- #
- # * Argument +path+, if given, must be the path to a file.
- # :include: ../doc/csv/arguments/io.rdoc
- # * Argument +mode+, if given, must be a \File mode
- # See {Open Mode}[IO.html#method-c-new-label-Open+Mode].
- # * Arguments <tt>**options</tt> must be keyword options.
- # See {Options for Generating}[#class-CSV-label-Options+for+Generating].
- # * This method optionally accepts an additional <tt>:encoding</tt> option
- # that you can use to specify the Encoding of the data read from +path+ or +io+.
- # You must provide this unless your data is in the encoding
- # given by <tt>Encoding::default_external</tt>.
- # Parsing will use this to determine how to parse the data.
- # You may provide a second Encoding to
- # have the data transcoded as it is read. For example,
- # encoding: 'UTF-32BE:UTF-8'
- # would read +UTF-32BE+ data from the file
- # but transcode it to +UTF-8+ before parsing.
- #
- # ---
- #
- # These examples assume prior execution of:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # ---
- #
- # With no block given, returns a new \CSV object.
- #
- # Create a \CSV object using a file path:
- # csv = CSV.open(path)
- # csv # => #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # Create a \CSV object using an open \File:
- # csv = CSV.open(File.open(path))
- # csv # => #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # ---
- #
- # With a block given, calls the block with the created \CSV object;
- # returns the block's return value:
- #
- # Using a file path:
- # csv = CSV.open(path) {|csv| p csv}
- # csv # => #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- # Output:
- # #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # Using an open \File:
- # csv = CSV.open(File.open(path)) {|csv| p csv}
- # csv # => #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- # Output:
- # #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # ---
- #
- # Raises an exception if the argument is not a \String object or \IO object:
- # # Raises TypeError (no implicit conversion of Symbol into String)
- # CSV.open(:foo)
- def open(filename, mode="r", **options)
- # wrap a File opened with the remaining +args+ with no newline
- # decorator
- file_opts = options.dup
- unless file_opts.key?(:newline)
- file_opts[:universal_newline] ||= false
- end
- options.delete(:invalid)
- options.delete(:undef)
- options.delete(:replace)
- options.delete_if {|k, _| /newline\z/.match?(k)}
-
- begin
- f = File.open(filename, mode, **file_opts)
- rescue ArgumentError => e
- raise unless /needs binmode/.match?(e.message) and mode == "r"
- mode = "rb"
- file_opts = {encoding: Encoding.default_external}.merge(file_opts)
- retry
- end
- begin
- csv = new(f, **options)
- rescue Exception
- f.close
- raise
- end
-
- # handle blocks like Ruby's open(), not like the CSV library
- if block_given?
- begin
- yield csv
- ensure
- csv.close
- end
- else
- csv
- end
- end
-
- #
- # :call-seq:
- # parse(string) -> array_of_arrays
- # parse(io) -> array_of_arrays
- # parse(string, headers: ..., **options) -> csv_table
- # parse(io, headers: ..., **options) -> csv_table
- # parse(string, **options) {|row| ... }
- # parse(io, **options) {|row| ... }
- #
- # Parses +string+ or +io+ using the specified +options+.
- #
- # - Argument +string+ should be a \String object;
- # it will be put into a new StringIO object positioned at the beginning.
- # :include: ../doc/csv/arguments/io.rdoc
- # - Argument +options+: see {Options for Parsing}[#class-CSV-label-Options+for+Parsing]
- #
- # ====== Without Option +headers+
- #
- # Without {option +headers+}[#class-CSV-label-Option+headers] case.
- #
- # These examples assume prior execution of:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # ---
- #
- # With no block given, returns an \Array of Arrays formed from the source.
- #
- # Parse a \String:
- # a_of_a = CSV.parse(string)
- # a_of_a # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # Parse an open \File:
- # a_of_a = File.open(path) do |file|
- # CSV.parse(file)
- # end
- # a_of_a # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # ---
- #
- # With a block given, calls the block with each parsed row:
- #
- # Parse a \String:
- # CSV.parse(string) {|row| p row }
- #
- # Output:
- # ["foo", "0"]
- # ["bar", "1"]
- # ["baz", "2"]
- #
- # Parse an open \File:
- # File.open(path) do |file|
- # CSV.parse(file) {|row| p row }
- # end
- #
- # Output:
- # ["foo", "0"]
- # ["bar", "1"]
- # ["baz", "2"]
- #
- # ====== With Option +headers+
- #
- # With {option +headers+}[#class-CSV-label-Option+headers] case.
- #
- # These examples assume prior execution of:
- # string = "Name,Count\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # ---
- #
- # With no block given, returns a CSV::Table object formed from the source.
- #
- # Parse a \String:
- # csv_table = CSV.parse(string, headers: ['Name', 'Count'])
- # csv_table # => #<CSV::Table mode:col_or_row row_count:5>
- #
- # Parse an open \File:
- # csv_table = File.open(path) do |file|
- # CSV.parse(file, headers: ['Name', 'Count'])
- # end
- # csv_table # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # ---
- #
- # With a block given, calls the block with each parsed row,
- # which has been formed into a CSV::Row object:
- #
- # Parse a \String:
- # CSV.parse(string, headers: ['Name', 'Count']) {|row| p row }
- #
- # Output:
- # # <CSV::Row "Name":"foo" "Count":"0">
- # # <CSV::Row "Name":"bar" "Count":"1">
- # # <CSV::Row "Name":"baz" "Count":"2">
- #
- # Parse an open \File:
- # File.open(path) do |file|
- # CSV.parse(file, headers: ['Name', 'Count']) {|row| p row }
- # end
- #
- # Output:
- # # <CSV::Row "Name":"foo" "Count":"0">
- # # <CSV::Row "Name":"bar" "Count":"1">
- # # <CSV::Row "Name":"baz" "Count":"2">
- #
- # ---
- #
- # Raises an exception if the argument is not a \String object or \IO object:
- # # Raises NoMethodError (undefined method `close' for :foo:Symbol)
- # CSV.parse(:foo)
- def parse(str, **options, &block)
- csv = new(str, **options)
-
- return csv.each(&block) if block_given?
-
- # slurp contents, if no block is given
- begin
- csv.read
- ensure
- csv.close
- end
- end
-
- # :call-seq:
- # CSV.parse_line(string) -> new_array or nil
- # CSV.parse_line(io) -> new_array or nil
- # CSV.parse_line(string, **options) -> new_array or nil
- # CSV.parse_line(io, **options) -> new_array or nil
- # CSV.parse_line(string, headers: true, **options) -> csv_row or nil
- # CSV.parse_line(io, headers: true, **options) -> csv_row or nil
- #
- # Returns the data created by parsing the first line of +string+ or +io+
- # using the specified +options+.
- #
- # - Argument +string+ should be a \String object;
- # it will be put into a new StringIO object positioned at the beginning.
- # :include: ../doc/csv/arguments/io.rdoc
- # - Argument +options+: see {Options for Parsing}[#class-CSV-label-Options+for+Parsing]
- #
- # ====== Without Option +headers+
- #
- # Without option +headers+, returns the first row as a new \Array.
- #
- # These examples assume prior execution of:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # Parse the first line from a \String object:
- # CSV.parse_line(string) # => ["foo", "0"]
- #
- # Parse the first line from a File object:
- # File.open(path) do |file|
- # CSV.parse_line(file) # => ["foo", "0"]
- # end # => ["foo", "0"]
- #
- # Returns +nil+ if the argument is an empty \String:
- # CSV.parse_line('') # => nil
- #
- # ====== With Option +headers+
- #
- # With {option +headers+}[#class-CSV-label-Option+headers],
- # returns the first row as a CSV::Row object.
- #
- # These examples assume prior execution of:
- # string = "Name,Count\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # Parse the first line from a \String object:
- # CSV.parse_line(string, headers: true) # => #<CSV::Row "Name":"foo" "Count":"0">
- #
- # Parse the first line from a File object:
- # File.open(path) do |file|
- # CSV.parse_line(file, headers: true)
- # end # => #<CSV::Row "Name":"foo" "Count":"0">
- #
- # ---
- #
- # Raises an exception if the argument is +nil+:
- # # Raises ArgumentError (Cannot parse nil as CSV):
- # CSV.parse_line(nil)
- #
- def parse_line(line, **options)
- new(line, **options).each.first
- end
-
- #
- # :call-seq:
- # read(source, **options) -> array_of_arrays
- # read(source, headers: true, **options) -> csv_table
- #
- # Opens the given +source+ with the given +options+ (see CSV.open),
- # reads the source (see CSV#read), and returns the result,
- # which will be either an \Array of Arrays or a CSV::Table.
- #
- # Without headers:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.read(path) # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # With headers:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.read(path, headers: true) # => #<CSV::Table mode:col_or_row row_count:4>
- def read(path, **options)
- open(path, **options) { |csv| csv.read }
- end
-
- # :call-seq:
- # CSV.readlines(source, **options)
- #
- # Alias for CSV.read.
- def readlines(path, **options)
- read(path, **options)
- end
-
- # :call-seq:
- # CSV.table(source, **options)
- #
- # Calls CSV.read with +source+, +options+, and certain default options:
- # - +headers+: +true+
- # - +converters+: +:numeric+
- # - +header_converters+: +:symbol+
- #
- # Returns a CSV::Table object.
- #
- # Example:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.table(path) # => #<CSV::Table mode:col_or_row row_count:4>
- def table(path, **options)
- default_options = {
- headers: true,
- converters: :numeric,
- header_converters: :symbol,
- }
- options = default_options.merge(options)
- read(path, **options)
- end
- end
-
- # :call-seq:
- # CSV.new(string)
- # CSV.new(io)
- # CSV.new(string, **options)
- # CSV.new(io, **options)
- #
- # Returns the new \CSV object created using +string+ or +io+
- # and the specified +options+.
- #
- # - Argument +string+ should be a \String object;
- # it will be put into a new StringIO object positioned at the beginning.
- # :include: ../doc/csv/arguments/io.rdoc
- # - Argument +options+: See:
- # * {Options for Parsing}[#class-CSV-label-Options+for+Parsing]
- # * {Options for Generating}[#class-CSV-label-Options+for+Generating]
- # For performance reasons, the options cannot be overridden
- # in a \CSV object, so those specified here will endure.
- #
- # In addition to the \CSV instance methods, several \IO methods are delegated.
- # See {Delegated Methods}[#class-CSV-label-Delegated+Methods].
- #
- # ---
- #
- # Create a \CSV object from a \String object:
- # csv = CSV.new('foo,0')
- # csv # => #<CSV io_type:StringIO encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # Create a \CSV object from a \File object:
- # File.write('t.csv', 'foo,0')
- # csv = CSV.new(File.open('t.csv'))
- # csv # => #<CSV io_type:File io_path:"t.csv" encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"">
- #
- # ---
- #
- # Raises an exception if the argument is +nil+:
- # # Raises ArgumentError (Cannot parse nil as CSV):
- # CSV.new(nil)
- #
- def initialize(data,
- col_sep: ",",
- row_sep: :auto,
- quote_char: '"',
- field_size_limit: nil,
- max_field_size: nil,
- converters: nil,
- unconverted_fields: nil,
- headers: false,
- return_headers: false,
- write_headers: nil,
- header_converters: nil,
- skip_blanks: false,
- force_quotes: false,
- skip_lines: nil,
- liberal_parsing: false,
- internal_encoding: nil,
- external_encoding: nil,
- encoding: nil,
- nil_value: nil,
- empty_value: "",
- strip: false,
- quote_empty: true,
- write_converters: nil,
- write_nil_value: nil,
- write_empty_value: "")
- raise ArgumentError.new("Cannot parse nil as CSV") if data.nil?
-
- if data.is_a?(String)
- if encoding
- if encoding.is_a?(String)
- data_external_encoding, data_internal_encoding = encoding.split(":", 2)
- if data_internal_encoding
- data = data.encode(data_internal_encoding, data_external_encoding)
- else
- data = data.dup.force_encoding(data_external_encoding)
- end
- else
- data = data.dup.force_encoding(encoding)
- end
- end
- @io = StringIO.new(data)
- else
- @io = data
- end
- @encoding = determine_encoding(encoding, internal_encoding)
-
- @base_fields_converter_options = {
- nil_value: nil_value,
- empty_value: empty_value,
- }
- @write_fields_converter_options = {
- nil_value: write_nil_value,
- empty_value: write_empty_value,
- }
- @initial_converters = converters
- @initial_header_converters = header_converters
- @initial_write_converters = write_converters
-
- if max_field_size.nil? and field_size_limit
- max_field_size = field_size_limit - 1
- end
- @parser_options = {
- column_separator: col_sep,
- row_separator: row_sep,
- quote_character: quote_char,
- max_field_size: max_field_size,
- unconverted_fields: unconverted_fields,
- headers: headers,
- return_headers: return_headers,
- skip_blanks: skip_blanks,
- skip_lines: skip_lines,
- liberal_parsing: liberal_parsing,
- encoding: @encoding,
- nil_value: nil_value,
- empty_value: empty_value,
- strip: strip,
- }
- @parser = nil
- @parser_enumerator = nil
- @eof_error = nil
-
- @writer_options = {
- encoding: @encoding,
- force_encoding: (not encoding.nil?),
- force_quotes: force_quotes,
- headers: headers,
- write_headers: write_headers,
- column_separator: col_sep,
- row_separator: row_sep,
- quote_character: quote_char,
- quote_empty: quote_empty,
- }
-
- @writer = nil
- writer if @writer_options[:write_headers]
- end
-
- # :call-seq:
- # csv.col_sep -> string
- #
- # Returns the encoded column separator; used for parsing and writing;
- # see {Option +col_sep+}[#class-CSV-label-Option+col_sep]:
- # CSV.new('').col_sep # => ","
- def col_sep
- parser.column_separator
- end
-
- # :call-seq:
- # csv.row_sep -> string
- #
- # Returns the encoded row separator; used for parsing and writing;
- # see {Option +row_sep+}[#class-CSV-label-Option+row_sep]:
- # CSV.new('').row_sep # => "\n"
- def row_sep
- parser.row_separator
- end
-
- # :call-seq:
- # csv.quote_char -> character
- #
- # Returns the encoded quote character; used for parsing and writing;
- # see {Option +quote_char+}[#class-CSV-label-Option+quote_char]:
- # CSV.new('').quote_char # => "\""
- def quote_char
- parser.quote_character
- end
-
- # :call-seq:
- # csv.field_size_limit -> integer or nil
- #
- # Returns the limit for field size; used for parsing;
- # see {Option +field_size_limit+}[#class-CSV-label-Option+field_size_limit]:
- # CSV.new('').field_size_limit # => nil
- #
- # Deprecated since 3.2.3. Use +max_field_size+ instead.
- def field_size_limit
- parser.field_size_limit
- end
-
- # :call-seq:
- # csv.max_field_size -> integer or nil
- #
- # Returns the limit for field size; used for parsing;
- # see {Option +max_field_size+}[#class-CSV-label-Option+max_field_size]:
- # CSV.new('').max_field_size # => nil
- #
- # Since 3.2.3.
- def max_field_size
- parser.max_field_size
- end
-
- # :call-seq:
- # csv.skip_lines -> regexp or nil
- #
- # Returns the \Regexp used to identify comment lines; used for parsing;
- # see {Option +skip_lines+}[#class-CSV-label-Option+skip_lines]:
- # CSV.new('').skip_lines # => nil
- def skip_lines
- parser.skip_lines
- end
-
- # :call-seq:
- # csv.converters -> array
- #
- # Returns an \Array containing field converters;
- # see {Field Converters}[#class-CSV-label-Field+Converters]:
- # csv = CSV.new('')
- # csv.converters # => []
- # csv.convert(:integer)
- # csv.converters # => [:integer]
- # csv.convert(proc {|x| x.to_s })
- # csv.converters
- #
- # Notes that you need to call
- # +Ractor.make_shareable(CSV::Converters)+ on the main Ractor to use
- # this method.
- def converters
- parser_fields_converter.map do |converter|
- name = Converters.rassoc(converter)
- name ? name.first : converter
- end
- end
-
- # :call-seq:
- # csv.unconverted_fields? -> object
- #
- # Returns the value that determines whether unconverted fields are to be
- # available; used for parsing;
- # see {Option +unconverted_fields+}[#class-CSV-label-Option+unconverted_fields]:
- # CSV.new('').unconverted_fields? # => nil
- def unconverted_fields?
- parser.unconverted_fields?
- end
-
- # :call-seq:
- # csv.headers -> object
- #
- # Returns the value that determines whether headers are used; used for parsing;
- # see {Option +headers+}[#class-CSV-label-Option+headers]:
- # CSV.new('').headers # => nil
- def headers
- if @writer
- @writer.headers
- else
- parsed_headers = parser.headers
- return parsed_headers if parsed_headers
- raw_headers = @parser_options[:headers]
- raw_headers = nil if raw_headers == false
- raw_headers
- end
- end
-
- # :call-seq:
- # csv.return_headers? -> true or false
- #
- # Returns the value that determines whether headers are to be returned; used for parsing;
- # see {Option +return_headers+}[#class-CSV-label-Option+return_headers]:
- # CSV.new('').return_headers? # => false
- def return_headers?
- parser.return_headers?
- end
-
- # :call-seq:
- # csv.write_headers? -> true or false
- #
- # Returns the value that determines whether headers are to be written; used for generating;
- # see {Option +write_headers+}[#class-CSV-label-Option+write_headers]:
- # CSV.new('').write_headers? # => nil
- def write_headers?
- @writer_options[:write_headers]
- end
-
- # :call-seq:
- # csv.header_converters -> array
- #
- # Returns an \Array containing header converters; used for parsing;
- # see {Header Converters}[#class-CSV-label-Header+Converters]:
- # CSV.new('').header_converters # => []
- #
- # Notes that you need to call
- # +Ractor.make_shareable(CSV::HeaderConverters)+ on the main Ractor
- # to use this method.
- def header_converters
- header_fields_converter.map do |converter|
- name = HeaderConverters.rassoc(converter)
- name ? name.first : converter
- end
- end
-
- # :call-seq:
- # csv.skip_blanks? -> true or false
- #
- # Returns the value that determines whether blank lines are to be ignored; used for parsing;
- # see {Option +skip_blanks+}[#class-CSV-label-Option+skip_blanks]:
- # CSV.new('').skip_blanks? # => false
- def skip_blanks?
- parser.skip_blanks?
- end
-
- # :call-seq:
- # csv.force_quotes? -> true or false
- #
- # Returns the value that determines whether all output fields are to be quoted;
- # used for generating;
- # see {Option +force_quotes+}[#class-CSV-label-Option+force_quotes]:
- # CSV.new('').force_quotes? # => false
- def force_quotes?
- @writer_options[:force_quotes]
- end
-
- # :call-seq:
- # csv.liberal_parsing? -> true or false
- #
- # Returns the value that determines whether illegal input is to be handled; used for parsing;
- # see {Option +liberal_parsing+}[#class-CSV-label-Option+liberal_parsing]:
- # CSV.new('').liberal_parsing? # => false
- def liberal_parsing?
- parser.liberal_parsing?
- end
-
- # :call-seq:
- # csv.encoding -> encoding
- #
- # Returns the encoding used for parsing and generating;
- # see {Character Encodings (M17n or Multilingualization)}[#class-CSV-label-Character+Encodings+-28M17n+or+Multilingualization-29]:
- # CSV.new('').encoding # => #<Encoding:UTF-8>
- attr_reader :encoding
-
- # :call-seq:
- # csv.line_no -> integer
- #
- # Returns the count of the rows parsed or generated.
- #
- # Parsing:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.open(path) do |csv|
- # csv.each do |row|
- # p [csv.lineno, row]
- # end
- # end
- # Output:
- # [1, ["foo", "0"]]
- # [2, ["bar", "1"]]
- # [3, ["baz", "2"]]
- #
- # Generating:
- # CSV.generate do |csv|
- # p csv.lineno; csv << ['foo', 0]
- # p csv.lineno; csv << ['bar', 1]
- # p csv.lineno; csv << ['baz', 2]
- # end
- # Output:
- # 0
- # 1
- # 2
- def lineno
- if @writer
- @writer.lineno
- else
- parser.lineno
- end
- end
-
- # :call-seq:
- # csv.line -> array
- #
- # Returns the line most recently read:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # CSV.open(path) do |csv|
- # csv.each do |row|
- # p [csv.lineno, csv.line]
- # end
- # end
- # Output:
- # [1, "foo,0\n"]
- # [2, "bar,1\n"]
- # [3, "baz,2\n"]
- def line
- parser.line
- end
-
- ### IO and StringIO Delegation ###
-
- extend Forwardable
- def_delegators :@io, :binmode, :close, :close_read, :close_write,
- :closed?, :external_encoding, :fcntl,
- :fileno, :flush, :fsync, :internal_encoding,
- :isatty, :pid, :pos, :pos=, :reopen,
- :seek, :string, :sync, :sync=, :tell,
- :truncate, :tty?
-
- def binmode?
- if @io.respond_to?(:binmode?)
- @io.binmode?
- else
- false
- end
- end
-
- def flock(*args)
- raise NotImplementedError unless @io.respond_to?(:flock)
- @io.flock(*args)
- end
-
- def ioctl(*args)
- raise NotImplementedError unless @io.respond_to?(:ioctl)
- @io.ioctl(*args)
- end
-
- def path
- @io.path if @io.respond_to?(:path)
- end
-
- def stat(*args)
- raise NotImplementedError unless @io.respond_to?(:stat)
- @io.stat(*args)
- end
-
- def to_i
- raise NotImplementedError unless @io.respond_to?(:to_i)
- @io.to_i
- end
-
- def to_io
- @io.respond_to?(:to_io) ? @io.to_io : @io
- end
-
- def eof?
- return false if @eof_error
- begin
- parser_enumerator.peek
- false
- rescue MalformedCSVError => error
- @eof_error = error
- false
- rescue StopIteration
- true
- end
- end
- alias_method :eof, :eof?
-
- # Rewinds the underlying IO object and resets CSV's lineno() counter.
- def rewind
- @parser = nil
- @parser_enumerator = nil
- @eof_error = nil
- @writer.rewind if @writer
- @io.rewind
- end
-
- ### End Delegation ###
-
- # :call-seq:
- # csv << row -> self
- #
- # Appends a row to +self+.
- #
- # - Argument +row+ must be an \Array object or a CSV::Row object.
- # - The output stream must be open for writing.
- #
- # ---
- #
- # Append Arrays:
- # CSV.generate do |csv|
- # csv << ['foo', 0]
- # csv << ['bar', 1]
- # csv << ['baz', 2]
- # end # => "foo,0\nbar,1\nbaz,2\n"
- #
- # Append CSV::Rows:
- # headers = []
- # CSV.generate do |csv|
- # csv << CSV::Row.new(headers, ['foo', 0])
- # csv << CSV::Row.new(headers, ['bar', 1])
- # csv << CSV::Row.new(headers, ['baz', 2])
- # end # => "foo,0\nbar,1\nbaz,2\n"
- #
- # Headers in CSV::Row objects are not appended:
- # headers = ['Name', 'Count']
- # CSV.generate do |csv|
- # csv << CSV::Row.new(headers, ['foo', 0])
- # csv << CSV::Row.new(headers, ['bar', 1])
- # csv << CSV::Row.new(headers, ['baz', 2])
- # end # => "foo,0\nbar,1\nbaz,2\n"
- #
- # ---
- #
- # Raises an exception if +row+ is not an \Array or \CSV::Row:
- # CSV.generate do |csv|
- # # Raises NoMethodError (undefined method `collect' for :foo:Symbol)
- # csv << :foo
- # end
- #
- # Raises an exception if the output stream is not opened for writing:
- # path = 't.csv'
- # File.write(path, '')
- # File.open(path) do |file|
- # CSV.open(file) do |csv|
- # # Raises IOError (not opened for writing)
- # csv << ['foo', 0]
- # end
- # end
- def <<(row)
- writer << row
- self
- end
- alias_method :add_row, :<<
- alias_method :puts, :<<
-
- # :call-seq:
- # convert(converter_name) -> array_of_procs
- # convert {|field, field_info| ... } -> array_of_procs
- #
- # - With no block, installs a field converter (a \Proc).
- # - With a block, defines and installs a custom field converter.
- # - Returns the \Array of installed field converters.
- #
- # - Argument +converter_name+, if given, should be the name
- # of an existing field converter.
- #
- # See {Field Converters}[#class-CSV-label-Field+Converters].
- # ---
- #
- # With no block, installs a field converter:
- # csv = CSV.new('')
- # csv.convert(:integer)
- # csv.convert(:float)
- # csv.convert(:date)
- # csv.converters # => [:integer, :float, :date]
- #
- # ---
- #
- # The block, if given, is called for each field:
- # - Argument +field+ is the field value.
- # - Argument +field_info+ is a CSV::FieldInfo object
- # containing details about the field.
- #
- # The examples here assume the prior execution of:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # Example giving a block:
- # csv = CSV.open(path)
- # csv.convert {|field, field_info| p [field, field_info]; field.upcase }
- # csv.read # => [["FOO", "0"], ["BAR", "1"], ["BAZ", "2"]]
- #
- # Output:
- # ["foo", #<struct CSV::FieldInfo index=0, line=1, header=nil>]
- # ["0", #<struct CSV::FieldInfo index=1, line=1, header=nil>]
- # ["bar", #<struct CSV::FieldInfo index=0, line=2, header=nil>]
- # ["1", #<struct CSV::FieldInfo index=1, line=2, header=nil>]
- # ["baz", #<struct CSV::FieldInfo index=0, line=3, header=nil>]
- # ["2", #<struct CSV::FieldInfo index=1, line=3, header=nil>]
- #
- # The block need not return a \String object:
- # csv = CSV.open(path)
- # csv.convert {|field, field_info| field.to_sym }
- # csv.read # => [[:foo, :"0"], [:bar, :"1"], [:baz, :"2"]]
- #
- # If +converter_name+ is given, the block is not called:
- # csv = CSV.open(path)
- # csv.convert(:integer) {|field, field_info| fail 'Cannot happen' }
- # csv.read # => [["foo", 0], ["bar", 1], ["baz", 2]]
- #
- # ---
- #
- # Raises a parse-time exception if +converter_name+ is not the name of a built-in
- # field converter:
- # csv = CSV.open(path)
- # csv.convert(:nosuch) => [nil]
- # # Raises NoMethodError (undefined method `arity' for nil:NilClass)
- # csv.read
- def convert(name = nil, &converter)
- parser_fields_converter.add_converter(name, &converter)
- end
-
- # :call-seq:
- # header_convert(converter_name) -> array_of_procs
- # header_convert {|header, field_info| ... } -> array_of_procs
- #
- # - With no block, installs a header converter (a \Proc).
- # - With a block, defines and installs a custom header converter.
- # - Returns the \Array of installed header converters.
- #
- # - Argument +converter_name+, if given, should be the name
- # of an existing header converter.
- #
- # See {Header Converters}[#class-CSV-label-Header+Converters].
- # ---
- #
- # With no block, installs a header converter:
- # csv = CSV.new('')
- # csv.header_convert(:symbol)
- # csv.header_convert(:downcase)
- # csv.header_converters # => [:symbol, :downcase]
- #
- # ---
- #
- # The block, if given, is called for each header:
- # - Argument +header+ is the header value.
- # - Argument +field_info+ is a CSV::FieldInfo object
- # containing details about the header.
- #
- # The examples here assume the prior execution of:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- #
- # Example giving a block:
- # csv = CSV.open(path, headers: true)
- # csv.header_convert {|header, field_info| p [header, field_info]; header.upcase }
- # table = csv.read
- # table # => #<CSV::Table mode:col_or_row row_count:4>
- # table.headers # => ["NAME", "VALUE"]
- #
- # Output:
- # ["Name", #<struct CSV::FieldInfo index=0, line=1, header=nil>]
- # ["Value", #<struct CSV::FieldInfo index=1, line=1, header=nil>]
-
- # The block need not return a \String object:
- # csv = CSV.open(path, headers: true)
- # csv.header_convert {|header, field_info| header.to_sym }
- # table = csv.read
- # table.headers # => [:Name, :Value]
- #
- # If +converter_name+ is given, the block is not called:
- # csv = CSV.open(path, headers: true)
- # csv.header_convert(:downcase) {|header, field_info| fail 'Cannot happen' }
- # table = csv.read
- # table.headers # => ["name", "value"]
- # ---
- #
- # Raises a parse-time exception if +converter_name+ is not the name of a built-in
- # field converter:
- # csv = CSV.open(path, headers: true)
- # csv.header_convert(:nosuch)
- # # Raises NoMethodError (undefined method `arity' for nil:NilClass)
- # csv.read
- def header_convert(name = nil, &converter)
- header_fields_converter.add_converter(name, &converter)
- end
-
- include Enumerable
-
- # :call-seq:
- # csv.each -> enumerator
- # csv.each {|row| ...}
- #
- # Calls the block with each successive row.
- # The data source must be opened for reading.
- #
- # Without headers:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.each do |row|
- # p row
- # end
- # Output:
- # ["foo", "0"]
- # ["bar", "1"]
- # ["baz", "2"]
- #
- # With headers:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string, headers: true)
- # csv.each do |row|
- # p row
- # end
- # Output:
- # <CSV::Row "Name":"foo" "Value":"0">
- # <CSV::Row "Name":"bar" "Value":"1">
- # <CSV::Row "Name":"baz" "Value":"2">
- #
- # ---
- #
- # Raises an exception if the source is not opened for reading:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.close
- # # Raises IOError (not opened for reading)
- # csv.each do |row|
- # p row
- # end
- def each(&block)
- return to_enum(__method__) unless block_given?
- begin
- while true
- yield(parser_enumerator.next)
- end
- rescue StopIteration
- end
- end
-
- # :call-seq:
- # csv.read -> array or csv_table
- #
- # Forms the remaining rows from +self+ into:
- # - A CSV::Table object, if headers are in use.
- # - An \Array of Arrays, otherwise.
- #
- # The data source must be opened for reading.
- #
- # Without headers:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # csv = CSV.open(path)
- # csv.read # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # With headers:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # path = 't.csv'
- # File.write(path, string)
- # csv = CSV.open(path, headers: true)
- # csv.read # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # ---
- #
- # Raises an exception if the source is not opened for reading:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.close
- # # Raises IOError (not opened for reading)
- # csv.read
- def read
- rows = to_a
- if parser.use_headers?
- Table.new(rows, headers: parser.headers)
- else
- rows
- end
- end
- alias_method :readlines, :read
-
- # :call-seq:
- # csv.header_row? -> true or false
- #
- # Returns +true+ if the next row to be read is a header row\;
- # +false+ otherwise.
- #
- # Without headers:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.header_row? # => false
- #
- # With headers:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string, headers: true)
- # csv.header_row? # => true
- # csv.shift # => #<CSV::Row "Name":"foo" "Value":"0">
- # csv.header_row? # => false
- #
- # ---
- #
- # Raises an exception if the source is not opened for reading:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.close
- # # Raises IOError (not opened for reading)
- # csv.header_row?
- def header_row?
- parser.header_row?
- end
-
- # :call-seq:
- # csv.shift -> array, csv_row, or nil
- #
- # Returns the next row of data as:
- # - An \Array if no headers are used.
- # - A CSV::Row object if headers are used.
- #
- # The data source must be opened for reading.
- #
- # Without headers:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.shift # => ["foo", "0"]
- # csv.shift # => ["bar", "1"]
- # csv.shift # => ["baz", "2"]
- # csv.shift # => nil
- #
- # With headers:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string, headers: true)
- # csv.shift # => #<CSV::Row "Name":"foo" "Value":"0">
- # csv.shift # => #<CSV::Row "Name":"bar" "Value":"1">
- # csv.shift # => #<CSV::Row "Name":"baz" "Value":"2">
- # csv.shift # => nil
- #
- # ---
- #
- # Raises an exception if the source is not opened for reading:
- # string = "foo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string)
- # csv.close
- # # Raises IOError (not opened for reading)
- # csv.shift
- def shift
- if @eof_error
- eof_error, @eof_error = @eof_error, nil
- raise eof_error
- end
- begin
- parser_enumerator.next
- rescue StopIteration
- nil
- end
- end
- alias_method :gets, :shift
- alias_method :readline, :shift
-
- # :call-seq:
- # csv.inspect -> string
- #
- # Returns a \String showing certain properties of +self+:
- # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # csv = CSV.new(string, headers: true)
- # s = csv.inspect
- # s # => "#<CSV io_type:StringIO encoding:UTF-8 lineno:0 col_sep:\",\" row_sep:\"\\n\" quote_char:\"\\\"\" headers:true>"
- def inspect
- str = ["#<", self.class.to_s, " io_type:"]
- # show type of wrapped IO
- if @io == $stdout then str << "$stdout"
- elsif @io == $stdin then str << "$stdin"
- elsif @io == $stderr then str << "$stderr"
- else str << @io.class.to_s
- end
- # show IO.path(), if available
- if @io.respond_to?(:path) and (p = @io.path)
- str << " io_path:" << p.inspect
- end
- # show encoding
- str << " encoding:" << @encoding.name
- # show other attributes
- ["lineno", "col_sep", "row_sep", "quote_char"].each do |attr_name|
- if a = __send__(attr_name)
- str << " " << attr_name << ":" << a.inspect
- end
- end
- ["skip_blanks", "liberal_parsing"].each do |attr_name|
- if a = __send__("#{attr_name}?")
- str << " " << attr_name << ":" << a.inspect
- end
- end
- _headers = headers
- str << " headers:" << _headers.inspect if _headers
- str << ">"
- begin
- str.join('')
- rescue # any encoding error
- str.map do |s|
- e = Encoding::Converter.asciicompat_encoding(s.encoding)
- e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
- end.join('')
- end
- end
-
- private
-
- def determine_encoding(encoding, internal_encoding)
- # honor the IO encoding if we can, otherwise default to ASCII-8BIT
- io_encoding = raw_encoding
- return io_encoding if io_encoding
-
- return Encoding.find(internal_encoding) if internal_encoding
-
- if encoding
- encoding, = encoding.split(":", 2) if encoding.is_a?(String)
- return Encoding.find(encoding)
- end
-
- Encoding.default_internal || Encoding.default_external
- end
-
- def normalize_converters(converters)
- converters ||= []
- unless converters.is_a?(Array)
- converters = [converters]
- end
- converters.collect do |converter|
- case converter
- when Proc # custom code block
- [nil, converter]
- else # by name
- [converter, nil]
- end
- 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)
- if headers
- header_fields_converter.convert(fields, nil, 0)
- else
- parser_fields_converter.convert(fields, @headers, lineno)
- end
- end
-
- #
- # Returns the encoding of the internal IO object.
- #
- def raw_encoding
- if @io.respond_to? :internal_encoding
- @io.internal_encoding || @io.external_encoding
- elsif @io.respond_to? :encoding
- @io.encoding
- else
- nil
- end
- end
-
- def parser_fields_converter
- @parser_fields_converter ||= build_parser_fields_converter
- end
-
- def build_parser_fields_converter
- specific_options = {
- builtin_converters_name: :Converters,
- }
- options = @base_fields_converter_options.merge(specific_options)
- build_fields_converter(@initial_converters, options)
- end
-
- def header_fields_converter
- @header_fields_converter ||= build_header_fields_converter
- end
-
- def build_header_fields_converter
- specific_options = {
- builtin_converters_name: :HeaderConverters,
- accept_nil: true,
- }
- options = @base_fields_converter_options.merge(specific_options)
- build_fields_converter(@initial_header_converters, options)
- end
-
- def writer_fields_converter
- @writer_fields_converter ||= build_writer_fields_converter
- end
-
- def build_writer_fields_converter
- build_fields_converter(@initial_write_converters,
- @write_fields_converter_options)
- end
-
- def build_fields_converter(initial_converters, options)
- fields_converter = FieldsConverter.new(options)
- normalize_converters(initial_converters).each do |name, converter|
- fields_converter.add_converter(name, &converter)
- end
- fields_converter
- end
-
- def parser
- @parser ||= Parser.new(@io, parser_options)
- end
-
- def parser_options
- @parser_options.merge(header_fields_converter: header_fields_converter,
- fields_converter: parser_fields_converter)
- end
-
- def parser_enumerator
- @parser_enumerator ||= parser.parse
- end
-
- def writer
- @writer ||= Writer.new(@io, writer_options)
- end
-
- def writer_options
- @writer_options.merge(header_fields_converter: header_fields_converter,
- fields_converter: writer_fields_converter)
- end
-end
-
-# Passes +args+ to CSV::instance.
-#
-# CSV("CSV,data").read
-# #=> [["CSV", "data"]]
-#
-# If a block is given, the instance is passed the block and the return value
-# becomes the return value of the block.
-#
-# CSV("CSV,data") { |c|
-# c.read.any? { |a| a.include?("data") }
-# } #=> true
-#
-# CSV("CSV,data") { |c|
-# c.read.any? { |a| a.include?("zombies") }
-# } #=> false
-#
-# CSV options may also be given.
-#
-# io = StringIO.new
-# CSV(io, col_sep: ";") { |csv| csv << ["a", "b", "c"] }
-#
-# This API is not Ractor-safe.
-#
-def CSV(*args, **options, &block)
- CSV.instance(*args, **options, &block)
-end
-
-require_relative "csv/version"
-require_relative "csv/core_ext/array"
-require_relative "csv/core_ext/string"
diff --git a/lib/csv/core_ext/array.rb b/lib/csv/core_ext/array.rb
deleted file mode 100644
index 8beb06b082..0000000000
--- a/lib/csv/core_ext/array.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Array # :nodoc:
- # Equivalent to CSV::generate_line(self, options)
- #
- # ["CSV", "data"].to_csv
- # #=> "CSV,data\n"
- def to_csv(**options)
- CSV.generate_line(self, **options)
- end
-end
diff --git a/lib/csv/core_ext/string.rb b/lib/csv/core_ext/string.rb
deleted file mode 100644
index 9b1d31c2a4..0000000000
--- a/lib/csv/core_ext/string.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class String # :nodoc:
- # Equivalent to CSV::parse_line(self, options)
- #
- # "CSV,data".parse_csv
- # #=> ["CSV", "data"]
- def parse_csv(**options)
- CSV.parse_line(self, **options)
- end
-end
diff --git a/lib/csv/csv.gemspec b/lib/csv/csv.gemspec
deleted file mode 100644
index 11c5b0f2a6..0000000000
--- a/lib/csv/csv.gemspec
+++ /dev/null
@@ -1,64 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require_relative "lib/csv/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "csv"
- spec.version = CSV::VERSION
- spec.authors = ["James Edward Gray II", "Kouhei Sutou"]
- spec.email = [nil, "kou@cozmixng.org"]
-
- spec.summary = "CSV Reading and Writing"
- spec.description = "The CSV library 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."
- spec.homepage = "https://github.com/ruby/csv"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- lib_path = "lib"
- spec.require_paths = [lib_path]
- files = []
- lib_dir = File.join(__dir__, lib_path)
- if File.exist?(lib_dir)
- Dir.chdir(lib_dir) do
- Dir.glob("**/*.rb").each do |file|
- files << "lib/#{file}"
- end
- end
- end
- doc_dir = File.join(__dir__, "doc")
- if File.exist?(doc_dir)
- Dir.chdir(doc_dir) do
- Dir.glob("**/*.rdoc").each do |rdoc_file|
- files << "doc/#{rdoc_file}"
- end
- end
- end
- spec.files = files
- spec.rdoc_options.concat(["--main", "README.md"])
- rdoc_files = [
- "LICENSE.txt",
- "NEWS.md",
- "README.md",
- ]
- recipes_dir = File.join(doc_dir, "csv", "recipes")
- if File.exist?(recipes_dir)
- Dir.chdir(recipes_dir) do
- Dir.glob("**/*.rdoc").each do |recipe_file|
- rdoc_files << "doc/csv/recipes/#{recipe_file}"
- end
- end
- end
- spec.extra_rdoc_files = rdoc_files
-
- spec.required_ruby_version = ">= 2.5.0"
-
- # spec.add_dependency "stringio", ">= 0.1.3"
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "benchmark_driver"
- spec.add_development_dependency "test-unit", ">= 3.4.8"
-end
diff --git a/lib/csv/delete_suffix.rb b/lib/csv/delete_suffix.rb
deleted file mode 100644
index d457718997..0000000000
--- a/lib/csv/delete_suffix.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#delete_suffix? for Ruby 2.4.
-unless String.method_defined?(:delete_suffix)
- class CSV
- module DeleteSuffix
- refine String do
- def delete_suffix(suffix)
- if end_with?(suffix)
- self[0...-suffix.size]
- else
- self
- end
- end
- end
- end
- end
-end
diff --git a/lib/csv/fields_converter.rb b/lib/csv/fields_converter.rb
deleted file mode 100644
index d15977d379..0000000000
--- a/lib/csv/fields_converter.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: true
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class FieldsConverter
- include Enumerable
- #
- # A CSV::FieldsConverter is a data structure for storing the
- # fields converter properties to be passed as a parameter
- # when parsing a new file (e.g. CSV::Parser.new(@io, parser_options))
- #
-
- def initialize(options={})
- @converters = []
- @nil_value = options[:nil_value]
- @empty_value = options[:empty_value]
- @empty_value_is_empty_string = (@empty_value == "")
- @accept_nil = options[:accept_nil]
- @builtin_converters_name = options[:builtin_converters_name]
- @need_static_convert = need_static_convert?
- end
-
- def add_converter(name=nil, &converter)
- if name.nil? # custom converter
- @converters << converter
- else # named converter
- combo = builtin_converters[name]
- case combo
- when Array # combo converter
- combo.each do |sub_name|
- add_converter(sub_name)
- end
- else # individual named converter
- @converters << combo
- end
- end
- end
-
- def each(&block)
- @converters.each(&block)
- end
-
- def empty?
- @converters.empty?
- end
-
- def convert(fields, headers, lineno, quoted_fields)
- return fields unless need_convert?
-
- fields.collect.with_index do |field, index|
- if field.nil?
- field = @nil_value
- elsif field.is_a?(String) and field.empty?
- field = @empty_value unless @empty_value_is_empty_string
- end
- @converters.each do |converter|
- break if field.nil? and @accept_nil
- if converter.arity == 1 # straight field converter
- field = converter[field]
- else # FieldInfo converter
- if headers
- header = headers[index]
- else
- header = nil
- end
- quoted = quoted_fields[index]
- field = converter[field, FieldInfo.new(index, lineno, header, quoted)]
- end
- break unless field.is_a?(String) # short-circuit pipeline for speed
- end
- field # final state of each field, converted or original
- end
- end
-
- private
- def need_static_convert?
- not (@nil_value.nil? and @empty_value_is_empty_string)
- end
-
- def need_convert?
- @need_static_convert or
- (not @converters.empty?)
- end
-
- def builtin_converters
- @builtin_converters ||= ::CSV.const_get(@builtin_converters_name)
- end
- end
-end
diff --git a/lib/csv/input_record_separator.rb b/lib/csv/input_record_separator.rb
deleted file mode 100644
index 7a99343c0c..0000000000
--- a/lib/csv/input_record_separator.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "English"
-require "stringio"
-
-class CSV
- module InputRecordSeparator
- class << self
- if RUBY_VERSION >= "3.0.0"
- def value
- "\n"
- end
- else
- def value
- $INPUT_RECORD_SEPARATOR
- end
- end
- end
- end
-end
diff --git a/lib/csv/match_p.rb b/lib/csv/match_p.rb
deleted file mode 100644
index 775559a3eb..0000000000
--- a/lib/csv/match_p.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#match? and Regexp#match? for Ruby 2.3.
-unless String.method_defined?(:match?)
- class CSV
- module MatchP
- refine String do
- def match?(pattern)
- self =~ pattern
- end
- end
-
- refine Regexp do
- def match?(string)
- self =~ string
- end
- end
- end
- end
-end
diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb
deleted file mode 100644
index 1f8b150e19..0000000000
--- a/lib/csv/parser.rb
+++ /dev/null
@@ -1,1288 +0,0 @@
-# frozen_string_literal: true
-
-require "strscan"
-
-require_relative "input_record_separator"
-require_relative "row"
-require_relative "table"
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class Parser
- #
- # A CSV::Parser is m17n aware. The parser works in the Encoding of the IO
- # or String object being read from or written to. Your data is never transcoded
- # (unless you ask Ruby to transcode it for you) and will literally be parsed in
- # the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
- # Encoding of your data. This is accomplished by transcoding the parser itself
- # into your Encoding.
- #
-
- # Raised when encoding is invalid.
- class InvalidEncoding < StandardError
- end
-
- # Raised when unexpected case is happen.
- class UnexpectedError < StandardError
- end
-
- #
- # CSV::Scanner receives a CSV output, scans it and return the content.
- # It also controls the life cycle of the object with its methods +keep_start+,
- # +keep_end+, +keep_back+, +keep_drop+.
- #
- # Uses StringScanner (the official strscan gem). Strscan provides lexical
- # scanning operations on a String. We inherit its object and take advantage
- # on the methods. For more information, please visit:
- # https://ruby-doc.org/stdlib-2.6.1/libdoc/strscan/rdoc/StringScanner.html
- #
- class Scanner < StringScanner
- alias_method :scan_all, :scan
-
- def initialize(*args)
- super
- @keeps = []
- end
-
- def each_line(row_separator)
- position = pos
- rest.each_line(row_separator) do |line|
- position += line.bytesize
- self.pos = position
- yield(line)
- end
- end
-
- def keep_start
- @keeps.push(pos)
- end
-
- def keep_end
- start = @keeps.pop
- string.byteslice(start, pos - start)
- end
-
- def keep_back
- self.pos = @keeps.pop
- end
-
- def keep_drop
- @keeps.pop
- end
- end
-
- #
- # CSV::InputsScanner receives IO inputs, encoding and the chunk_size.
- # It also controls the life cycle of the object with its methods +keep_start+,
- # +keep_end+, +keep_back+, +keep_drop+.
- #
- # CSV::InputsScanner.scan() tries to match with pattern at the current position.
- # If there's a match, the scanner advances the "scan pointer" and returns the matched string.
- # Otherwise, the scanner returns nil.
- #
- # CSV::InputsScanner.rest() returns the "rest" of the string (i.e. everything after the scan pointer).
- # If there is no more data (eos? = true), it returns "".
- #
- class InputsScanner
- def initialize(inputs, encoding, row_separator, chunk_size: 8192)
- @inputs = inputs.dup
- @encoding = encoding
- @row_separator = row_separator
- @chunk_size = chunk_size
- @last_scanner = @inputs.empty?
- @keeps = []
- read_chunk
- end
-
- def each_line(row_separator)
- return enum_for(__method__, row_separator) unless block_given?
- buffer = nil
- input = @scanner.rest
- position = @scanner.pos
- offset = 0
- n_row_separator_chars = row_separator.size
- # trace(__method__, :start, line, input)
- while true
- input.each_line(row_separator) do |line|
- @scanner.pos += line.bytesize
- if buffer
- if n_row_separator_chars == 2 and
- buffer.end_with?(row_separator[0]) and
- line.start_with?(row_separator[1])
- buffer << line[0]
- line = line[1..-1]
- position += buffer.bytesize + offset
- @scanner.pos = position
- offset = 0
- yield(buffer)
- buffer = nil
- next if line.empty?
- else
- buffer << line
- line = buffer
- buffer = nil
- end
- end
- if line.end_with?(row_separator)
- position += line.bytesize + offset
- @scanner.pos = position
- offset = 0
- yield(line)
- else
- buffer = line
- end
- end
- break unless read_chunk
- input = @scanner.rest
- position = @scanner.pos
- offset = -buffer.bytesize if buffer
- end
- yield(buffer) if buffer
- end
-
- def scan(pattern)
- # trace(__method__, pattern, :start)
- value = @scanner.scan(pattern)
- # trace(__method__, pattern, :done, :last, value) if @last_scanner
- return value if @last_scanner
-
- read_chunk if value and @scanner.eos?
- # trace(__method__, pattern, :done, value)
- value
- end
-
- def scan_all(pattern)
- # trace(__method__, pattern, :start)
- value = @scanner.scan(pattern)
- # trace(__method__, pattern, :done, :last, value) if @last_scanner
- return value if @last_scanner
-
- return nil if value.nil?
- while @scanner.eos? and read_chunk and (sub_value = @scanner.scan(pattern))
- # trace(__method__, pattern, :sub, sub_value)
- value << sub_value
- end
- # trace(__method__, pattern, :done, value)
- value
- end
-
- def eos?
- @scanner.eos?
- end
-
- def keep_start
- # trace(__method__, :start)
- adjust_last_keep
- @keeps.push([@scanner, @scanner.pos, nil])
- # trace(__method__, :done)
- end
-
- def keep_end
- # trace(__method__, :start)
- scanner, start, buffer = @keeps.pop
- if scanner == @scanner
- keep = @scanner.string.byteslice(start, @scanner.pos - start)
- else
- keep = @scanner.string.byteslice(0, @scanner.pos)
- end
- if buffer
- buffer << keep
- keep = buffer
- end
- # trace(__method__, :done, keep)
- keep
- end
-
- def keep_back
- # trace(__method__, :start)
- scanner, start, buffer = @keeps.pop
- if buffer
- # trace(__method__, :rescan, start, buffer)
- string = @scanner.string
- if scanner == @scanner
- keep = string.byteslice(start, string.bytesize - start)
- else
- keep = string
- end
- if keep and not keep.empty?
- @inputs.unshift(StringIO.new(keep))
- @last_scanner = false
- end
- @scanner = StringScanner.new(buffer)
- else
- if @scanner != scanner
- message = "scanners are different but no buffer: "
- message += "#{@scanner.inspect}(#{@scanner.object_id}): "
- message += "#{scanner.inspect}(#{scanner.object_id})"
- raise UnexpectedError, message
- end
- # trace(__method__, :repos, start, buffer)
- @scanner.pos = start
- end
- read_chunk if @scanner.eos?
- end
-
- def keep_drop
- _, _, buffer = @keeps.pop
- # trace(__method__, :done, :empty) unless buffer
- return unless buffer
-
- last_keep = @keeps.last
- # trace(__method__, :done, :no_last_keep) unless last_keep
- return unless last_keep
-
- if last_keep[2]
- last_keep[2] << buffer
- else
- last_keep[2] = buffer
- end
- # trace(__method__, :done)
- end
-
- def rest
- @scanner.rest
- end
-
- def check(pattern)
- @scanner.check(pattern)
- end
-
- private
- def trace(*args)
- pp([*args, @scanner, @scanner&.string, @scanner&.pos, @keeps])
- end
-
- def adjust_last_keep
- # trace(__method__, :start)
-
- keep = @keeps.last
- # trace(__method__, :done, :empty) if keep.nil?
- return if keep.nil?
-
- scanner, start, buffer = keep
- string = @scanner.string
- if @scanner != scanner
- start = 0
- end
- if start == 0 and @scanner.eos?
- keep_data = string
- else
- keep_data = string.byteslice(start, @scanner.pos - start)
- end
- if keep_data
- if buffer
- buffer << keep_data
- else
- keep[2] = keep_data.dup
- end
- end
-
- # trace(__method__, :done)
- end
-
- def read_chunk
- return false if @last_scanner
-
- adjust_last_keep
-
- input = @inputs.first
- case input
- when StringIO
- string = input.read
- raise InvalidEncoding unless string.valid_encoding?
- # trace(__method__, :stringio, string)
- @scanner = StringScanner.new(string)
- @inputs.shift
- @last_scanner = @inputs.empty?
- true
- else
- chunk = input.gets(@row_separator, @chunk_size)
- if chunk
- raise InvalidEncoding unless chunk.valid_encoding?
- # trace(__method__, :chunk, chunk)
- @scanner = StringScanner.new(chunk)
- if input.respond_to?(:eof?) and input.eof?
- @inputs.shift
- @last_scanner = @inputs.empty?
- end
- true
- else
- # trace(__method__, :no_chunk)
- @scanner = StringScanner.new("".encode(@encoding))
- @inputs.shift
- @last_scanner = @inputs.empty?
- if @last_scanner
- false
- else
- read_chunk
- end
- end
- end
- end
- end
-
- def initialize(input, options)
- @input = input
- @options = options
- @samples = []
-
- prepare
- end
-
- def column_separator
- @column_separator
- end
-
- def row_separator
- @row_separator
- end
-
- def quote_character
- @quote_character
- end
-
- def field_size_limit
- @max_field_size&.succ
- end
-
- def max_field_size
- @max_field_size
- end
-
- def skip_lines
- @skip_lines
- end
-
- def unconverted_fields?
- @unconverted_fields
- end
-
- def headers
- @headers
- end
-
- def header_row?
- @use_headers and @headers.nil?
- end
-
- def return_headers?
- @return_headers
- end
-
- def skip_blanks?
- @skip_blanks
- end
-
- def liberal_parsing?
- @liberal_parsing
- end
-
- def lineno
- @lineno
- end
-
- def line
- last_line
- end
-
- def parse(&block)
- return to_enum(__method__) unless block_given?
-
- if @return_headers and @headers and @raw_headers
- headers = Row.new(@headers, @raw_headers, true)
- if @unconverted_fields
- headers = add_unconverted_fields(headers, [])
- end
- yield headers
- end
-
- begin
- @scanner ||= build_scanner
- if quote_character.nil?
- parse_no_quote(&block)
- elsif @need_robust_parsing
- parse_quotable_robust(&block)
- else
- parse_quotable_loose(&block)
- end
- rescue InvalidEncoding
- if @scanner
- ignore_broken_line
- lineno = @lineno
- else
- lineno = @lineno + 1
- end
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, lineno)
- rescue UnexpectedError => error
- if @scanner
- ignore_broken_line
- lineno = @lineno
- else
- lineno = @lineno + 1
- end
- message = "This should not be happen: #{error.message}: "
- message += "Please report this to https://github.com/ruby/csv/issues"
- raise MalformedCSVError.new(message, lineno)
- end
- end
-
- def use_headers?
- @use_headers
- end
-
- private
- # A set of tasks to prepare the file in order to parse it
- def prepare
- prepare_variable
- prepare_quote_character
- prepare_backslash
- prepare_skip_lines
- prepare_strip
- prepare_separators
- validate_strip_and_col_sep_options
- prepare_quoted
- prepare_unquoted
- prepare_line
- prepare_header
- prepare_parser
- end
-
- def prepare_variable
- @need_robust_parsing = false
- @encoding = @options[:encoding]
- liberal_parsing = @options[:liberal_parsing]
- if liberal_parsing
- @liberal_parsing = true
- if liberal_parsing.is_a?(Hash)
- @double_quote_outside_quote =
- liberal_parsing[:double_quote_outside_quote]
- @backslash_quote = liberal_parsing[:backslash_quote]
- else
- @double_quote_outside_quote = false
- @backslash_quote = false
- end
- @need_robust_parsing = true
- else
- @liberal_parsing = false
- @backslash_quote = false
- end
- @unconverted_fields = @options[:unconverted_fields]
- @max_field_size = @options[:max_field_size]
- @skip_blanks = @options[:skip_blanks]
- @fields_converter = @options[:fields_converter]
- @header_fields_converter = @options[:header_fields_converter]
- end
-
- def prepare_quote_character
- @quote_character = @options[:quote_character]
- if @quote_character.nil?
- @escaped_quote_character = nil
- @escaped_quote = nil
- else
- @quote_character = @quote_character.to_s.encode(@encoding)
- if @quote_character.length != 1
- message = ":quote_char has to be nil or a single character String"
- raise ArgumentError, message
- end
- @escaped_quote_character = Regexp.escape(@quote_character)
- @escaped_quote = Regexp.new(@escaped_quote_character)
- end
- end
-
- def prepare_backslash
- return unless @backslash_quote
-
- @backslash_character = "\\".encode(@encoding)
-
- @escaped_backslash_character = Regexp.escape(@backslash_character)
- @escaped_backslash = Regexp.new(@escaped_backslash_character)
- if @quote_character.nil?
- @backslash_quote_character = nil
- else
- @backslash_quote_character =
- @backslash_character + @escaped_quote_character
- end
- end
-
- def prepare_skip_lines
- skip_lines = @options[:skip_lines]
- case skip_lines
- when String
- @skip_lines = skip_lines.encode(@encoding)
- when Regexp, nil
- @skip_lines = skip_lines
- else
- unless skip_lines.respond_to?(:match)
- message =
- ":skip_lines has to respond to \#match: #{skip_lines.inspect}"
- raise ArgumentError, message
- end
- @skip_lines = skip_lines
- end
- end
-
- def prepare_strip
- @strip = @options[:strip]
- @escaped_strip = nil
- @strip_value = nil
- @rstrip_value = nil
- if @strip.is_a?(String)
- case @strip.length
- when 0
- raise ArgumentError, ":strip must not be an empty String"
- when 1
- # ok
- else
- raise ArgumentError, ":strip doesn't support 2 or more characters yet"
- end
- @strip = @strip.encode(@encoding)
- @escaped_strip = Regexp.escape(@strip)
- if @quote_character
- @strip_value = Regexp.new(@escaped_strip +
- "+".encode(@encoding))
- @rstrip_value = Regexp.new(@escaped_strip +
- "+\\z".encode(@encoding))
- end
- @need_robust_parsing = true
- elsif @strip
- strip_values = " \t\f\v"
- @escaped_strip = strip_values.encode(@encoding)
- if @quote_character
- @strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding))
- @rstrip_value = Regexp.new("[#{strip_values}]+\\z".encode(@encoding))
- end
- @need_robust_parsing = true
- end
- end
-
- begin
- StringScanner.new("x").scan("x")
- rescue TypeError
- STRING_SCANNER_SCAN_ACCEPT_STRING = false
- else
- STRING_SCANNER_SCAN_ACCEPT_STRING = true
- end
-
- def prepare_separators
- column_separator = @options[:column_separator]
- @column_separator = column_separator.to_s.encode(@encoding)
- if @column_separator.size < 1
- message = ":col_sep must be 1 or more characters: "
- message += column_separator.inspect
- raise ArgumentError, message
- end
- @row_separator =
- resolve_row_separator(@options[:row_separator]).encode(@encoding)
-
- @escaped_column_separator = Regexp.escape(@column_separator)
- @escaped_first_column_separator = Regexp.escape(@column_separator[0])
- if @column_separator.size > 1
- @column_end = Regexp.new(@escaped_column_separator)
- @column_ends = @column_separator.each_char.collect do |char|
- Regexp.new(Regexp.escape(char))
- end
- @first_column_separators = Regexp.new(@escaped_first_column_separator +
- "+".encode(@encoding))
- else
- if STRING_SCANNER_SCAN_ACCEPT_STRING
- @column_end = @column_separator
- else
- @column_end = Regexp.new(@escaped_column_separator)
- end
- @column_ends = nil
- @first_column_separators = nil
- end
-
- escaped_row_separator = Regexp.escape(@row_separator)
- @row_end = Regexp.new(escaped_row_separator)
- if @row_separator.size > 1
- @row_ends = @row_separator.each_char.collect do |char|
- Regexp.new(Regexp.escape(char))
- end
- else
- @row_ends = nil
- end
-
- @cr = "\r".encode(@encoding)
- @lf = "\n".encode(@encoding)
- @line_end = Regexp.new("\r\n|\n|\r".encode(@encoding))
- @not_line_end = Regexp.new("[^\r\n]+".encode(@encoding))
- end
-
- # This method verifies that there are no (obvious) ambiguities with the
- # provided +col_sep+ and +strip+ parsing options. For example, if +col_sep+
- # and +strip+ were both equal to +\t+, then there would be no clear way to
- # parse the input.
- def validate_strip_and_col_sep_options
- return unless @strip
-
- if @strip.is_a?(String)
- if @column_separator.start_with?(@strip) || @column_separator.end_with?(@strip)
- raise ArgumentError,
- "The provided strip (#{@escaped_strip}) and " \
- "col_sep (#{@escaped_column_separator}) options are incompatible."
- end
- else
- if Regexp.new("\\A[#{@escaped_strip}]|[#{@escaped_strip}]\\z").match?(@column_separator)
- raise ArgumentError,
- "The provided strip (true) and " \
- "col_sep (#{@escaped_column_separator}) options are incompatible."
- end
- end
- end
-
- def prepare_quoted
- if @quote_character
- @quotes = Regexp.new(@escaped_quote_character +
- "+".encode(@encoding))
- no_quoted_values = @escaped_quote_character.dup
- if @backslash_quote
- no_quoted_values << @escaped_backslash_character
- end
- @quoted_value = Regexp.new("[^".encode(@encoding) +
- no_quoted_values +
- "]+".encode(@encoding))
- end
- if @escaped_strip
- @split_column_separator = Regexp.new(@escaped_strip +
- "*".encode(@encoding) +
- @escaped_column_separator +
- @escaped_strip +
- "*".encode(@encoding))
- else
- if @column_separator == " ".encode(@encoding)
- @split_column_separator = Regexp.new(@escaped_column_separator)
- else
- @split_column_separator = @column_separator
- end
- end
- end
-
- def prepare_unquoted
- return if @quote_character.nil?
-
- no_unquoted_values = "\r\n".encode(@encoding)
- no_unquoted_values << @escaped_first_column_separator
- unless @liberal_parsing
- no_unquoted_values << @escaped_quote_character
- end
- @unquoted_value = Regexp.new("[^".encode(@encoding) +
- no_unquoted_values +
- "]+".encode(@encoding))
- end
-
- def resolve_row_separator(separator)
- if separator == :auto
- cr = "\r".encode(@encoding)
- lf = "\n".encode(@encoding)
- if @input.is_a?(StringIO)
- pos = @input.pos
- separator = detect_row_separator(@input.read, cr, lf)
- @input.seek(pos)
- elsif @input.respond_to?(:gets)
- if @input.is_a?(File)
- chunk_size = 32 * 1024
- else
- chunk_size = 1024
- end
- begin
- while separator == :auto
- #
- # if we run out of data, it's probably a single line
- # (ensure will set default value)
- #
- break unless sample = @input.gets(nil, chunk_size)
-
- # extend sample if we're unsure of the line ending
- if sample.end_with?(cr)
- sample << (@input.gets(nil, 1) || "")
- end
-
- @samples << sample
-
- separator = detect_row_separator(sample, cr, lf)
- end
- rescue IOError
- # do nothing: ensure will set default
- end
- end
- separator = InputRecordSeparator.value if separator == :auto
- end
- separator.to_s.encode(@encoding)
- end
-
- def detect_row_separator(sample, cr, lf)
- lf_index = sample.index(lf)
- if lf_index
- cr_index = sample[0, lf_index].index(cr)
- else
- cr_index = sample.index(cr)
- end
- if cr_index and lf_index
- if cr_index + 1 == lf_index
- cr + lf
- elsif cr_index < lf_index
- cr
- else
- lf
- end
- elsif cr_index
- cr
- elsif lf_index
- lf
- else
- :auto
- end
- end
-
- def prepare_line
- @lineno = 0
- @last_line = nil
- @scanner = nil
- end
-
- def last_line
- if @scanner
- @last_line ||= @scanner.keep_end
- else
- @last_line
- end
- end
-
- def prepare_header
- @return_headers = @options[:return_headers]
-
- headers = @options[:headers]
- case headers
- when Array
- @raw_headers = headers
- quoted_fields = [false] * @raw_headers.size
- @use_headers = true
- when String
- @raw_headers, quoted_fields = parse_headers(headers)
- @use_headers = true
- when nil, false
- @raw_headers = nil
- @use_headers = false
- else
- @raw_headers = nil
- @use_headers = true
- end
- if @raw_headers
- @headers = adjust_headers(@raw_headers, quoted_fields)
- else
- @headers = nil
- end
- end
-
- def parse_headers(row)
- quoted_fields = []
- converter = lambda do |field, info|
- quoted_fields << info.quoted?
- field
- end
- headers = CSV.parse_line(row,
- col_sep: @column_separator,
- row_sep: @row_separator,
- quote_char: @quote_character,
- converters: [converter])
- [headers, quoted_fields]
- end
-
- def adjust_headers(headers, quoted_fields)
- adjusted_headers = @header_fields_converter.convert(headers, nil, @lineno, quoted_fields)
- adjusted_headers.each {|h| h.freeze if h.is_a? String}
- adjusted_headers
- end
-
- def prepare_parser
- @may_quoted = may_quoted?
- end
-
- def may_quoted?
- return false if @quote_character.nil?
-
- if @input.is_a?(StringIO)
- pos = @input.pos
- sample = @input.read
- @input.seek(pos)
- else
- return false if @samples.empty?
- sample = @samples.first
- end
- sample[0, 128].index(@quote_character)
- end
-
- class UnoptimizedStringIO # :nodoc:
- def initialize(string)
- @io = StringIO.new(string, "rb:#{string.encoding}")
- end
-
- def gets(*args)
- @io.gets(*args)
- end
-
- def each_line(*args, &block)
- @io.each_line(*args, &block)
- end
-
- def eof?
- @io.eof?
- end
- end
-
- SCANNER_TEST = (ENV["CSV_PARSER_SCANNER_TEST"] == "yes")
- if SCANNER_TEST
- SCANNER_TEST_CHUNK_SIZE_NAME = "CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"
- SCANNER_TEST_CHUNK_SIZE_VALUE = ENV[SCANNER_TEST_CHUNK_SIZE_NAME]
- def build_scanner
- inputs = @samples.collect do |sample|
- UnoptimizedStringIO.new(sample)
- end
- if @input.is_a?(StringIO)
- inputs << UnoptimizedStringIO.new(@input.read)
- else
- inputs << @input
- end
- begin
- chunk_size_value = ENV[SCANNER_TEST_CHUNK_SIZE_NAME]
- rescue # Ractor::IsolationError
- # Ractor on Ruby 3.0 can't read ENV value.
- chunk_size_value = SCANNER_TEST_CHUNK_SIZE_VALUE
- end
- chunk_size = Integer((chunk_size_value || "1"), 10)
- InputsScanner.new(inputs,
- @encoding,
- @row_separator,
- chunk_size: chunk_size)
- end
- else
- def build_scanner
- string = nil
- if @samples.empty? and @input.is_a?(StringIO)
- string = @input.read
- elsif @samples.size == 1 and
- @input != ARGF and
- @input.respond_to?(:eof?) and
- @input.eof?
- string = @samples[0]
- end
- if string
- unless string.valid_encoding?
- index = string.lines(@row_separator).index do |line|
- !line.valid_encoding?
- end
- if index
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, @lineno + index + 1)
- end
- end
- Scanner.new(string)
- else
- inputs = @samples.collect do |sample|
- StringIO.new(sample)
- end
- inputs << @input
- InputsScanner.new(inputs, @encoding, @row_separator)
- end
- end
- end
-
- def skip_needless_lines
- return unless @skip_lines
-
- until @scanner.eos?
- @scanner.keep_start
- line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
- line << @row_separator if parse_row_end
- if skip_line?(line)
- @lineno += 1
- @scanner.keep_drop
- else
- @scanner.keep_back
- return
- end
- end
- end
-
- def skip_line?(line)
- line = line.delete_suffix(@row_separator)
- case @skip_lines
- when String
- line.include?(@skip_lines)
- when Regexp
- @skip_lines.match?(line)
- else
- @skip_lines.match(line)
- end
- end
-
- def validate_field_size(field)
- return unless @max_field_size
- return if field.size <= @max_field_size
- ignore_broken_line
- message = "Field size exceeded: #{field.size} > #{@max_field_size}"
- raise MalformedCSVError.new(message, @lineno)
- end
-
- def parse_no_quote(&block)
- @scanner.each_line(@row_separator) do |line|
- next if @skip_lines and skip_line?(line)
- original_line = line
- line = line.delete_suffix(@row_separator)
-
- if line.empty?
- next if @skip_blanks
- row = []
- quoted_fields = []
- else
- line = strip_value(line)
- row = line.split(@split_column_separator, -1)
- quoted_fields = [false] * row.size
- if @max_field_size
- row.each do |column|
- validate_field_size(column)
- end
- end
- n_columns = row.size
- i = 0
- while i < n_columns
- row[i] = nil if row[i].empty?
- i += 1
- end
- end
- @last_line = original_line
- emit_row(row, quoted_fields, &block)
- end
- end
-
- def parse_quotable_loose(&block)
- @scanner.keep_start
- @scanner.each_line(@row_separator) do |line|
- if @skip_lines and skip_line?(line)
- @scanner.keep_drop
- @scanner.keep_start
- next
- end
- original_line = line
- line = line.delete_suffix(@row_separator)
-
- if line.empty?
- if @skip_blanks
- @scanner.keep_drop
- @scanner.keep_start
- next
- end
- row = []
- quoted_fields = []
- elsif line.include?(@cr) or line.include?(@lf)
- @scanner.keep_back
- @need_robust_parsing = true
- return parse_quotable_robust(&block)
- else
- row = line.split(@split_column_separator, -1)
- quoted_fields = []
- n_columns = row.size
- i = 0
- while i < n_columns
- column = row[i]
- if column.empty?
- quoted_fields << false
- row[i] = nil
- else
- n_quotes = column.count(@quote_character)
- if n_quotes.zero?
- quoted_fields << false
- # no quote
- elsif n_quotes == 2 and
- column.start_with?(@quote_character) and
- column.end_with?(@quote_character)
- quoted_fields << true
- row[i] = column[1..-2]
- else
- @scanner.keep_back
- @need_robust_parsing = true
- return parse_quotable_robust(&block)
- end
- validate_field_size(row[i])
- end
- i += 1
- end
- end
- @scanner.keep_drop
- @scanner.keep_start
- @last_line = original_line
- emit_row(row, quoted_fields, &block)
- end
- @scanner.keep_drop
- end
-
- def parse_quotable_robust(&block)
- row = []
- quoted_fields = []
- skip_needless_lines
- start_row
- while true
- @quoted_column_value = false
- @unquoted_column_value = false
- @scanner.scan_all(@strip_value) if @strip_value
- value = parse_column_value
- if value
- @scanner.scan_all(@strip_value) if @strip_value
- validate_field_size(value)
- end
- if parse_column_end
- row << value
- quoted_fields << @quoted_column_value
- elsif parse_row_end
- if row.empty? and value.nil?
- emit_row([], [], &block) unless @skip_blanks
- else
- row << value
- quoted_fields << @quoted_column_value
- emit_row(row, quoted_fields, &block)
- row = []
- quoted_fields = []
- end
- skip_needless_lines
- start_row
- elsif @scanner.eos?
- break if row.empty? and value.nil?
- row << value
- quoted_fields << @quoted_column_value
- emit_row(row, quoted_fields, &block)
- break
- else
- if @quoted_column_value
- if liberal_parsing? and (new_line = @scanner.check(@line_end))
- message =
- "Illegal end-of-line sequence outside of a quoted field " +
- "<#{new_line.inspect}>"
- else
- message = "Any value after quoted field isn't allowed"
- end
- ignore_broken_line
- raise MalformedCSVError.new(message, @lineno)
- elsif @unquoted_column_value and
- (new_line = @scanner.scan(@line_end))
- ignore_broken_line
- message = "Unquoted fields do not allow new line " +
- "<#{new_line.inspect}>"
- raise MalformedCSVError.new(message, @lineno)
- elsif @scanner.rest.start_with?(@quote_character)
- ignore_broken_line
- message = "Illegal quoting"
- raise MalformedCSVError.new(message, @lineno)
- elsif (new_line = @scanner.scan(@line_end))
- ignore_broken_line
- message = "New line must be <#{@row_separator.inspect}> " +
- "not <#{new_line.inspect}>"
- raise MalformedCSVError.new(message, @lineno)
- else
- ignore_broken_line
- raise MalformedCSVError.new("TODO: Meaningful message",
- @lineno)
- end
- end
- end
- end
-
- def parse_column_value
- if @liberal_parsing
- quoted_value = parse_quoted_column_value
- if quoted_value
- @scanner.scan_all(@strip_value) if @strip_value
- unquoted_value = parse_unquoted_column_value
- if unquoted_value
- if @double_quote_outside_quote
- unquoted_value = unquoted_value.gsub(@quote_character * 2,
- @quote_character)
- if quoted_value.empty? # %Q{""...} case
- return @quote_character + unquoted_value
- end
- end
- @quote_character + quoted_value + @quote_character + unquoted_value
- else
- quoted_value
- end
- else
- parse_unquoted_column_value
- end
- elsif @may_quoted
- parse_quoted_column_value ||
- parse_unquoted_column_value
- else
- parse_unquoted_column_value ||
- parse_quoted_column_value
- end
- end
-
- def parse_unquoted_column_value
- value = @scanner.scan_all(@unquoted_value)
- return nil unless value
-
- @unquoted_column_value = true
- if @first_column_separators
- while true
- @scanner.keep_start
- is_column_end = @column_ends.all? do |column_end|
- @scanner.scan(column_end)
- end
- @scanner.keep_back
- break if is_column_end
- sub_separator = @scanner.scan_all(@first_column_separators)
- break if sub_separator.nil?
- value << sub_separator
- sub_value = @scanner.scan_all(@unquoted_value)
- break if sub_value.nil?
- value << sub_value
- end
- end
- value.gsub!(@backslash_quote_character, @quote_character) if @backslash_quote
- if @rstrip_value
- value.gsub!(@rstrip_value, "")
- end
- value
- end
-
- def parse_quoted_column_value
- quotes = @scanner.scan_all(@quotes)
- return nil unless quotes
-
- @quoted_column_value = true
- n_quotes = quotes.size
- if (n_quotes % 2).zero?
- quotes[0, (n_quotes - 2) / 2]
- else
- value = quotes[0, n_quotes / 2]
- while true
- quoted_value = @scanner.scan_all(@quoted_value)
- value << quoted_value if quoted_value
- if @backslash_quote
- if @scanner.scan(@escaped_backslash)
- if @scanner.scan(@escaped_quote)
- value << @quote_character
- else
- value << @backslash_character
- end
- next
- end
- end
-
- quotes = @scanner.scan_all(@quotes)
- unless quotes
- ignore_broken_line
- message = "Unclosed quoted field"
- raise MalformedCSVError.new(message, @lineno)
- end
- n_quotes = quotes.size
- if n_quotes == 1
- break
- else
- value << quotes[0, n_quotes / 2]
- break if (n_quotes % 2) == 1
- end
- end
- value
- end
- end
-
- def parse_column_end
- return true if @scanner.scan(@column_end)
- return false unless @column_ends
-
- @scanner.keep_start
- if @column_ends.all? {|column_end| @scanner.scan(column_end)}
- @scanner.keep_drop
- true
- else
- @scanner.keep_back
- false
- end
- end
-
- def parse_row_end
- return true if @scanner.scan(@row_end)
- return false unless @row_ends
- @scanner.keep_start
- if @row_ends.all? {|row_end| @scanner.scan(row_end)}
- @scanner.keep_drop
- true
- else
- @scanner.keep_back
- false
- end
- end
-
- def strip_value(value)
- return value unless @strip
- return value if value.nil?
-
- case @strip
- when String
- while value.delete_prefix!(@strip)
- # do nothing
- end
- while value.delete_suffix!(@strip)
- # do nothing
- end
- else
- value.strip!
- end
- value
- end
-
- def ignore_broken_line
- @scanner.scan_all(@not_line_end)
- @scanner.scan_all(@line_end)
- @lineno += 1
- end
-
- def start_row
- if @last_line
- @last_line = nil
- else
- @scanner.keep_drop
- end
- @scanner.keep_start
- end
-
- def emit_row(row, quoted_fields, &block)
- @lineno += 1
-
- raw_row = row
- if @use_headers
- if @headers.nil?
- @headers = adjust_headers(row, quoted_fields)
- return unless @return_headers
- row = Row.new(@headers, row, true)
- else
- row = Row.new(@headers,
- @fields_converter.convert(raw_row, @headers, @lineno, quoted_fields))
- end
- else
- # convert fields, if needed...
- row = @fields_converter.convert(raw_row, nil, @lineno, quoted_fields)
- end
-
- # inject unconverted fields and accessor, if requested...
- if @unconverted_fields and not row.respond_to?(:unconverted_fields)
- add_unconverted_fields(row, raw_row)
- end
-
- yield(row)
- end
-
- # This method injects an instance variable <tt>unconverted_fields</tt> into
- # +row+ and an accessor method for +row+ called unconverted_fields(). The
- # variable is set to the contents of +fields+.
- def add_unconverted_fields(row, fields)
- class << row
- attr_reader :unconverted_fields
- end
- row.instance_variable_set(:@unconverted_fields, fields)
- row
- end
- end
-end
diff --git a/lib/csv/row.rb b/lib/csv/row.rb
deleted file mode 100644
index 86323f7d0a..0000000000
--- a/lib/csv/row.rb
+++ /dev/null
@@ -1,757 +0,0 @@
-# frozen_string_literal: true
-
-require "forwardable"
-
-class CSV
- # = \CSV::Row
- # A \CSV::Row instance represents a \CSV table row.
- # (see {class CSV}[../CSV.html]).
- #
- # The instance may have:
- # - Fields: each is an object, not necessarily a \String.
- # - Headers: each serves a key, and also need not be a \String.
- #
- # === Instance Methods
- #
- # \CSV::Row has three groups of instance methods:
- # - Its own internally defined instance methods.
- # - Methods included by module Enumerable.
- # - Methods delegated to class Array.:
- # * Array#empty?
- # * Array#length
- # * Array#size
- #
- # == Creating a \CSV::Row Instance
- #
- # Commonly, a new \CSV::Row instance is created by parsing \CSV source
- # that has headers:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.each {|row| p row }
- # Output:
- # #<CSV::Row "Name":"foo" "Value":"0">
- # #<CSV::Row "Name":"bar" "Value":"1">
- # #<CSV::Row "Name":"baz" "Value":"2">
- #
- # You can also create a row directly. See ::new.
- #
- # == Headers
- #
- # Like a \CSV::Table, a \CSV::Row has headers.
- #
- # A \CSV::Row that was created by parsing \CSV source
- # inherits its headers from the table:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table.first
- # row.headers # => ["Name", "Value"]
- #
- # You can also create a new row with headers;
- # like the keys in a \Hash, the headers need not be Strings:
- # row = CSV::Row.new([:name, :value], ['foo', 0])
- # row.headers # => [:name, :value]
- #
- # The new row retains its headers even if added to a table
- # that has headers:
- # table << row # => #<CSV::Table mode:col_or_row row_count:5>
- # row.headers # => [:name, :value]
- # row[:name] # => "foo"
- # row['Name'] # => nil
- #
- #
- #
- # == Accessing Fields
- #
- # You may access a field in a \CSV::Row with either its \Integer index
- # (\Array-style) or its header (\Hash-style).
- #
- # Fetch a field using method #[]:
- # row = CSV::Row.new(['Name', 'Value'], ['foo', 0])
- # row[1] # => 0
- # row['Value'] # => 0
- #
- # Set a field using method #[]=:
- # row = CSV::Row.new(['Name', 'Value'], ['foo', 0])
- # row # => #<CSV::Row "Name":"foo" "Value":0>
- # row[0] = 'bar'
- # row['Value'] = 1
- # row # => #<CSV::Row "Name":"bar" "Value":1>
- #
- class Row
- # :call-seq:
- # CSV::Row.new(headers, fields, header_row = false) -> csv_row
- #
- # Returns the new \CSV::Row instance constructed from
- # arguments +headers+ and +fields+; both should be Arrays;
- # note that the fields need not be Strings:
- # row = CSV::Row.new(['Name', 'Value'], ['foo', 0])
- # row # => #<CSV::Row "Name":"foo" "Value":0>
- #
- # If the \Array lengths are different, the shorter is +nil+-filled:
- # row = CSV::Row.new(['Name', 'Value', 'Date', 'Size'], ['foo', 0])
- # row # => #<CSV::Row "Name":"foo" "Value":0 "Date":nil "Size":nil>
- #
- # Each \CSV::Row object is either a <i>field row</i> or a <i>header row</i>;
- # by default, a new row is a field row; for the row created above:
- # row.field_row? # => true
- # row.header_row? # => false
- #
- # If the optional argument +header_row+ is given as +true+,
- # the created row is a header row:
- # row = CSV::Row.new(['Name', 'Value'], ['foo', 0], header_row = true)
- # row # => #<CSV::Row "Name":"foo" "Value":0>
- # row.field_row? # => false
- # row.header_row? # => true
- def initialize(headers, fields, header_row = false)
- @header_row = header_row
- headers.each { |h| h.freeze if h.is_a? String }
-
- # handle extra headers or fields
- @row = if headers.size >= fields.size
- headers.zip(fields)
- else
- fields.zip(headers).each(&:reverse!)
- end
- end
-
- # Internal data format used to compare equality.
- attr_reader :row
- protected :row
-
- ### Array Delegation ###
-
- extend Forwardable
- def_delegators :@row, :empty?, :length, :size
-
- # :call-seq:
- # row.initialize_copy(other_row) -> self
- #
- # Calls superclass method.
- def initialize_copy(other)
- super_return_value = super
- @row = @row.collect(&:dup)
- super_return_value
- end
-
- # :call-seq:
- # row.header_row? -> true or false
- #
- # Returns +true+ if this is a header row, +false+ otherwise.
- def header_row?
- @header_row
- end
-
- # :call-seq:
- # row.field_row? -> true or false
- #
- # Returns +true+ if this is a field row, +false+ otherwise.
- def field_row?
- not header_row?
- end
-
- # :call-seq:
- # row.headers -> array_of_headers
- #
- # Returns the headers for this row:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table.first
- # row.headers # => ["Name", "Value"]
- def headers
- @row.map(&:first)
- end
-
- # :call-seq:
- # field(index) -> value
- # field(header) -> value
- # field(header, offset) -> value
- #
- # Returns the field value for the given +index+ or +header+.
- #
- # ---
- #
- # Fetch field value by \Integer index:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.field(0) # => "foo"
- # row.field(1) # => "bar"
- #
- # Counts backward from the last column if +index+ is negative:
- # row.field(-1) # => "0"
- # row.field(-2) # => "foo"
- #
- # Returns +nil+ if +index+ is out of range:
- # row.field(2) # => nil
- # row.field(-3) # => nil
- #
- # ---
- #
- # Fetch field value by header (first found):
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.field('Name') # => "Foo"
- #
- # Fetch field value by header, ignoring +offset+ leading fields:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.field('Name', 2) # => "Baz"
- #
- # Returns +nil+ if the header does not exist.
- def field(header_or_index, minimum_index = 0)
- # locate the pair
- finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
- pair = @row[minimum_index..-1].public_send(finder, header_or_index)
-
- # return the field if we have a pair
- if pair.nil?
- nil
- else
- header_or_index.is_a?(Range) ? pair.map(&:last) : pair.last
- end
- end
- alias_method :[], :field
-
- #
- # :call-seq:
- # fetch(header) -> value
- # fetch(header, default) -> value
- # fetch(header) {|row| ... } -> value
- #
- # Returns the field value as specified by +header+.
- #
- # ---
- #
- # With the single argument +header+, returns the field value
- # for that header (first found):
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.fetch('Name') # => "Foo"
- #
- # Raises exception +KeyError+ if the header does not exist.
- #
- # ---
- #
- # With arguments +header+ and +default+ given,
- # returns the field value for the header (first found)
- # if the header exists, otherwise returns +default+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.fetch('Name', '') # => "Foo"
- # row.fetch(:nosuch, '') # => ""
- #
- # ---
- #
- # With argument +header+ and a block given,
- # returns the field value for the header (first found)
- # if the header exists; otherwise calls the block
- # and returns its return value:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.fetch('Name') {|header| fail 'Cannot happen' } # => "Foo"
- # row.fetch(:nosuch) {|header| "Header '#{header} not found'" } # => "Header 'nosuch not found'"
- def fetch(header, *varargs)
- raise ArgumentError, "Too many arguments" if varargs.length > 1
- pair = @row.assoc(header)
- if pair
- pair.last
- else
- if block_given?
- yield header
- elsif varargs.empty?
- raise KeyError, "key not found: #{header}"
- else
- varargs.first
- end
- end
- end
-
- # :call-seq:
- # row.has_key?(header) -> true or false
- #
- # Returns +true+ if there is a field with the given +header+,
- # +false+ otherwise.
- def has_key?(header)
- !!@row.assoc(header)
- end
- alias_method :include?, :has_key?
- alias_method :key?, :has_key?
- alias_method :member?, :has_key?
- alias_method :header?, :has_key?
-
- #
- # :call-seq:
- # row[index] = value -> value
- # row[header, offset] = value -> value
- # row[header] = value -> value
- #
- # Assigns the field value for the given +index+ or +header+;
- # returns +value+.
- #
- # ---
- #
- # Assign field value by \Integer index:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row[0] = 'Bat'
- # row[1] = 3
- # row # => #<CSV::Row "Name":"Bat" "Value":3>
- #
- # Counts backward from the last column if +index+ is negative:
- # row[-1] = 4
- # row[-2] = 'Bam'
- # row # => #<CSV::Row "Name":"Bam" "Value":4>
- #
- # Extends the row with <tt>nil:nil</tt> if positive +index+ is not in the row:
- # row[4] = 5
- # row # => #<CSV::Row "Name":"bad" "Value":4 nil:nil nil:nil nil:5>
- #
- # Raises IndexError if negative +index+ is too small (too far from zero).
- #
- # ---
- #
- # Assign field value by header (first found):
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row['Name'] = 'Bat'
- # row # => #<CSV::Row "Name":"Bat" "Name":"Bar" "Name":"Baz">
- #
- # Assign field value by header, ignoring +offset+ leading fields:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row['Name', 2] = 4
- # row # => #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":4>
- #
- # Append new field by (new) header:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row['New'] = 6
- # row# => #<CSV::Row "Name":"foo" "Value":"0" "New":6>
- 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
- end
- end
-
- #
- # :call-seq:
- # row << [header, value] -> self
- # row << hash -> self
- # row << value -> self
- #
- # Adds a field to +self+; returns +self+:
- #
- # If the argument is a 2-element \Array <tt>[header, value]</tt>,
- # a field is added with the given +header+ and +value+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row << ['NAME', 'Bat']
- # row # => #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz" "NAME":"Bat">
- #
- # If the argument is a \Hash, each <tt>key-value</tt> pair is added
- # as a field with header +key+ and value +value+.
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row << {NAME: 'Bat', name: 'Bam'}
- # row # => #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz" NAME:"Bat" name:"Bam">
- #
- # Otherwise, the given +value+ is added as a field with no header.
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row << 'Bag'
- # row # => #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz" nil:"Bag">
- 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
-
- # :call-seq:
- # row.push(*values) -> self
- #
- # Appends each of the given +values+ to +self+ as a field; returns +self+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.push('Bat', 'Bam')
- # row # => #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz" nil:"Bat" nil:"Bam">
- def push(*args)
- args.each { |arg| self << arg }
-
- self # for chaining
- end
-
- #
- # :call-seq:
- # delete(index) -> [header, value] or nil
- # delete(header) -> [header, value] or empty_array
- # delete(header, offset) -> [header, value] or empty_array
- #
- # Removes a specified field from +self+; returns the 2-element \Array
- # <tt>[header, value]</tt> if the field exists.
- #
- # If an \Integer argument +index+ is given,
- # removes and returns the field at offset +index+,
- # or returns +nil+ if the field does not exist:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.delete(1) # => ["Name", "Bar"]
- # row.delete(50) # => nil
- #
- # Otherwise, if the single argument +header+ is given,
- # removes and returns the first-found field with the given header,
- # of returns a new empty \Array if the field does not exist:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.delete('Name') # => ["Name", "Foo"]
- # row.delete('NAME') # => []
- #
- # If argument +header+ and \Integer argument +offset+ are given,
- # removes and returns the first-found field with the given header
- # whose +index+ is at least as large as +offset+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.delete('Name', 1) # => ["Name", "Bar"]
- # row.delete('NAME', 1) # => []
- def delete(header_or_index, minimum_index = 0)
- if header_or_index.is_a? Integer # by index
- @row.delete_at(header_or_index)
- elsif i = index(header_or_index, minimum_index) # by header
- @row.delete_at(i)
- else
- [ ]
- end
- end
-
- # :call-seq:
- # row.delete_if {|header, value| ... } -> self
- #
- # Removes fields from +self+ as selected by the block; returns +self+.
- #
- # Removes each field for which the block returns a truthy value:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.delete_if {|header, value| value.start_with?('B') } # => true
- # row # => #<CSV::Row "Name":"Foo">
- # row.delete_if {|header, value| header.start_with?('B') } # => false
- #
- # If no block is given, returns a new Enumerator:
- # row.delete_if # => #<Enumerator: #<CSV::Row "Name":"Foo">:delete_if>
- def delete_if(&block)
- return enum_for(__method__) { size } unless block_given?
-
- @row.delete_if(&block)
-
- self # for chaining
- end
-
- # :call-seq:
- # self.fields(*specifiers) -> array_of_fields
- #
- # Returns field values per the given +specifiers+, which may be any mixture of:
- # - \Integer index.
- # - \Range of \Integer indexes.
- # - 2-element \Array containing a header and offset.
- # - Header.
- # - \Range of headers.
- #
- # For +specifier+ in one of the first four cases above,
- # returns the result of <tt>self.field(specifier)</tt>; see #field.
- #
- # Although there may be any number of +specifiers+,
- # the examples here will illustrate one at a time.
- #
- # When the specifier is an \Integer +index+,
- # returns <tt>self.field(index)</tt>L
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.fields(1) # => ["Bar"]
- #
- # When the specifier is a \Range of \Integers +range+,
- # returns <tt>self.field(range)</tt>:
- # row.fields(1..2) # => ["Bar", "Baz"]
- #
- # When the specifier is a 2-element \Array +array+,
- # returns <tt>self.field(array)</tt>L
- # row.fields('Name', 1) # => ["Foo", "Bar"]
- #
- # When the specifier is a header +header+,
- # returns <tt>self.field(header)</tt>L
- # row.fields('Name') # => ["Foo"]
- #
- # When the specifier is a \Range of headers +range+,
- # forms a new \Range +new_range+ from the indexes of
- # <tt>range.start</tt> and <tt>range.end</tt>,
- # and returns <tt>self.field(new_range)</tt>:
- # source = "Name,NAME,name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.fields('Name'..'NAME') # => ["Foo", "Bar"]
- #
- # Returns all fields if no argument given:
- # row.fields # => ["Foo", "Bar", "Baz"]
- def fields(*headers_and_or_indices)
- if headers_and_or_indices.empty? # return all fields--no arguments
- @row.map(&:last)
- else # or work like values_at()
- all = []
- headers_and_or_indices.each do |h_or_i|
- 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)
- all.concat(fields.values_at(new_range))
- else
- all << field(*Array(h_or_i))
- end
- end
- return all
- end
- end
- alias_method :values_at, :fields
-
- # :call-seq:
- # index(header) -> index
- # index(header, offset) -> index
- #
- # Returns the index for the given header, if it exists;
- # otherwise returns +nil+.
- #
- # With the single argument +header+, returns the index
- # of the first-found field with the given +header+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.index('Name') # => 0
- # row.index('NAME') # => nil
- #
- # With arguments +header+ and +offset+,
- # returns the index of the first-found field with given +header+,
- # but ignoring the first +offset+ fields:
- # row.index('Name', 1) # => 1
- # row.index('Name', 3) # => nil
- 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
-
- # :call-seq:
- # row.field?(value) -> true or false
- #
- # Returns +true+ if +value+ is a field in this row, +false+ otherwise:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.field?('Bar') # => true
- # row.field?('BAR') # => false
- def field?(data)
- fields.include? data
- end
-
- include Enumerable
-
- # :call-seq:
- # row.each {|header, value| ... } -> self
- #
- # Calls the block with each header-value pair; returns +self+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.each {|header, value| p [header, value] }
- # Output:
- # ["Name", "Foo"]
- # ["Name", "Bar"]
- # ["Name", "Baz"]
- #
- # If no block is given, returns a new Enumerator:
- # row.each # => #<Enumerator: #<CSV::Row "Name":"Foo" "Name":"Bar" "Name":"Baz">:each>
- def each(&block)
- return enum_for(__method__) { size } unless block_given?
-
- @row.each(&block)
-
- self # for chaining
- end
-
- alias_method :each_pair, :each
-
- # :call-seq:
- # row == other -> true or false
- #
- # Returns +true+ if +other+ is a /CSV::Row that has the same
- # fields (headers and values) in the same order as +self+;
- # otherwise returns +false+:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # other_row = table[0]
- # row == other_row # => true
- # other_row = table[1]
- # row == other_row # => false
- def ==(other)
- return @row == other.row if other.is_a? CSV::Row
- @row == other
- end
-
- # :call-seq:
- # row.to_h -> hash
- #
- # Returns the new \Hash formed by adding each header-value pair in +self+
- # as a key-value pair in the \Hash.
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.to_h # => {"Name"=>"foo", "Value"=>"0"}
- #
- # Header order is preserved, but repeated headers are ignored:
- # source = "Name,Name,Name\nFoo,Bar,Baz\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.to_h # => {"Name"=>"Foo"}
- def to_h
- hash = {}
- each do |key, _value|
- hash[key] = self[key] unless hash.key?(key)
- end
- hash
- end
- alias_method :to_hash, :to_h
-
- # :call-seq:
- # row.deconstruct_keys(keys) -> hash
- #
- # Returns the new \Hash suitable for pattern matching containing only the
- # keys specified as an argument.
- def deconstruct_keys(keys)
- if keys.nil?
- to_h
- else
- keys.to_h { |key| [key, self[key]] }
- end
- end
-
- alias_method :to_ary, :to_a
-
- # :call-seq:
- # row.deconstruct -> array
- #
- # Returns the new \Array suitable for pattern matching containing the values
- # of the row.
- def deconstruct
- fields
- end
-
- # :call-seq:
- # row.to_csv -> csv_string
- #
- # Returns the row as a \CSV String. Headers are not included:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.to_csv # => "foo,0\n"
- def to_csv(**options)
- fields.to_csv(**options)
- end
- alias_method :to_s, :to_csv
-
- # :call-seq:
- # row.dig(index_or_header, *identifiers) -> object
- #
- # Finds and returns the object in nested object that is specified
- # by +index_or_header+ and +specifiers+.
- #
- # The nested objects may be instances of various classes.
- # See {Dig Methods}[rdoc-ref:dig_methods.rdoc].
- #
- # Examples:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.dig(1) # => "0"
- # row.dig('Value') # => "0"
- # row.dig(5) # => nil
- def dig(index_or_header, *indexes)
- value = field(index_or_header)
- if value.nil?
- nil
- elsif indexes.empty?
- value
- else
- unless value.respond_to?(:dig)
- raise TypeError, "#{value.class} does not have \#dig method"
- end
- value.dig(*indexes)
- end
- end
-
- # :call-seq:
- # row.inspect -> string
- #
- # Returns an ASCII-compatible \String showing:
- # - Class \CSV::Row.
- # - Header-value pairs.
- # Example:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # row = table[0]
- # row.inspect # => "#<CSV::Row \"Name\":\"foo\" \"Value\":\"0\">"
- def inspect
- str = ["#<", self.class.to_s]
- each do |header, field|
- str << " " << (header.is_a?(Symbol) ? header.to_s : header.inspect) <<
- ":" << field.inspect
- end
- str << ">"
- begin
- str.join('')
- rescue # any encoding error
- str.map do |s|
- e = Encoding::Converter.asciicompat_encoding(s.encoding)
- e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
- end.join('')
- end
- end
- end
-end
diff --git a/lib/csv/table.rb b/lib/csv/table.rb
deleted file mode 100644
index fb19f5453f..0000000000
--- a/lib/csv/table.rb
+++ /dev/null
@@ -1,1055 +0,0 @@
-# frozen_string_literal: true
-
-require "forwardable"
-
-class CSV
- # = \CSV::Table
- # A \CSV::Table instance represents \CSV data.
- # (see {class CSV}[../CSV.html]).
- #
- # The instance may have:
- # - Rows: each is a Table::Row object.
- # - Headers: names for the columns.
- #
- # === Instance Methods
- #
- # \CSV::Table has three groups of instance methods:
- # - Its own internally defined instance methods.
- # - Methods included by module Enumerable.
- # - Methods delegated to class Array.:
- # * Array#empty?
- # * Array#length
- # * Array#size
- #
- # == Creating a \CSV::Table Instance
- #
- # Commonly, a new \CSV::Table instance is created by parsing \CSV source
- # using headers:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.class # => CSV::Table
- #
- # You can also create an instance directly. See ::new.
- #
- # == Headers
- #
- # If a table has headers, the headers serve as labels for the columns of data.
- # Each header serves as the label for its column.
- #
- # The headers for a \CSV::Table object are stored as an \Array of Strings.
- #
- # Commonly, headers are defined in the first row of \CSV source:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.headers # => ["Name", "Value"]
- #
- # If no headers are defined, the \Array is empty:
- # table = CSV::Table.new([])
- # table.headers # => []
- #
- # == Access Modes
- #
- # \CSV::Table provides three modes for accessing table data:
- # - \Row mode.
- # - Column mode.
- # - Mixed mode (the default for a new table).
- #
- # The access mode for a\CSV::Table instance affects the behavior
- # of some of its instance methods:
- # - #[]
- # - #[]=
- # - #delete
- # - #delete_if
- # - #each
- # - #values_at
- #
- # === \Row Mode
- #
- # Set a table to row mode with method #by_row!:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- #
- # Specify a single row by an \Integer index:
- # # Get a row.
- # table[1] # => #<CSV::Row "Name":"bar" "Value":"1">
- # # Set a row, then get it.
- # table[1] = CSV::Row.new(['Name', 'Value'], ['bam', 3])
- # table[1] # => #<CSV::Row "Name":"bam" "Value":3>
- #
- # Specify a sequence of rows by a \Range:
- # # Get rows.
- # table[1..2] # => [#<CSV::Row "Name":"bam" "Value":3>, #<CSV::Row "Name":"baz" "Value":"2">]
- # # Set rows, then get them.
- # table[1..2] = [
- # CSV::Row.new(['Name', 'Value'], ['bat', 4]),
- # CSV::Row.new(['Name', 'Value'], ['bad', 5]),
- # ]
- # table[1..2] # => [["Name", #<CSV::Row "Name":"bat" "Value":4>], ["Value", #<CSV::Row "Name":"bad" "Value":5>]]
- #
- # === Column Mode
- #
- # Set a table to column mode with method #by_col!:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- #
- # Specify a column by an \Integer index:
- # # Get a column.
- # table[0]
- # # Set a column, then get it.
- # table[0] = ['FOO', 'BAR', 'BAZ']
- # table[0] # => ["FOO", "BAR", "BAZ"]
- #
- # Specify a column by its \String header:
- # # Get a column.
- # table['Name'] # => ["FOO", "BAR", "BAZ"]
- # # Set a column, then get it.
- # table['Name'] = ['Foo', 'Bar', 'Baz']
- # table['Name'] # => ["Foo", "Bar", "Baz"]
- #
- # === Mixed Mode
- #
- # In mixed mode, you can refer to either rows or columns:
- # - An \Integer index refers to a row.
- # - A \Range index refers to multiple rows.
- # - A \String index refers to a column.
- #
- # Set a table to mixed mode with method #by_col_or_row!:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # Specify a single row by an \Integer index:
- # # Get a row.
- # table[1] # => #<CSV::Row "Name":"bar" "Value":"1">
- # # Set a row, then get it.
- # table[1] = CSV::Row.new(['Name', 'Value'], ['bam', 3])
- # table[1] # => #<CSV::Row "Name":"bam" "Value":3>
- #
- # Specify a sequence of rows by a \Range:
- # # Get rows.
- # table[1..2] # => [#<CSV::Row "Name":"bam" "Value":3>, #<CSV::Row "Name":"baz" "Value":"2">]
- # # Set rows, then get them.
- # table[1] = CSV::Row.new(['Name', 'Value'], ['bat', 4])
- # table[2] = CSV::Row.new(['Name', 'Value'], ['bad', 5])
- # table[1..2] # => [["Name", #<CSV::Row "Name":"bat" "Value":4>], ["Value", #<CSV::Row "Name":"bad" "Value":5>]]
- #
- # Specify a column by its \String header:
- # # Get a column.
- # table['Name'] # => ["foo", "bat", "bad"]
- # # Set a column, then get it.
- # table['Name'] = ['Foo', 'Bar', 'Baz']
- # table['Name'] # => ["Foo", "Bar", "Baz"]
- class Table
- # :call-seq:
- # CSV::Table.new(array_of_rows, headers = nil) -> csv_table
- #
- # Returns a new \CSV::Table object.
- #
- # - Argument +array_of_rows+ must be an \Array of CSV::Row objects.
- # - Argument +headers+, if given, may be an \Array of Strings.
- #
- # ---
- #
- # Create an empty \CSV::Table object:
- # table = CSV::Table.new([])
- # table # => #<CSV::Table mode:col_or_row row_count:1>
- #
- # Create a non-empty \CSV::Table object:
- # rows = [
- # CSV::Row.new([], []),
- # CSV::Row.new([], []),
- # CSV::Row.new([], []),
- # ]
- # table = CSV::Table.new(rows)
- # table # => #<CSV::Table mode:col_or_row row_count:4>
- #
- # ---
- #
- # If argument +headers+ is an \Array of Strings,
- # those Strings become the table's headers:
- # table = CSV::Table.new([], headers: ['Name', 'Age'])
- # table.headers # => ["Name", "Age"]
- #
- # If argument +headers+ is not given and the table has rows,
- # the headers are taken from the first row:
- # rows = [
- # CSV::Row.new(['Foo', 'Bar'], []),
- # CSV::Row.new(['foo', 'bar'], []),
- # CSV::Row.new(['FOO', 'BAR'], []),
- # ]
- # table = CSV::Table.new(rows)
- # table.headers # => ["Foo", "Bar"]
- #
- # If argument +headers+ is not given and the table is empty (has no rows),
- # the headers are also empty:
- # table = CSV::Table.new([])
- # table.headers # => []
- #
- # ---
- #
- # Raises an exception if argument +array_of_rows+ is not an \Array object:
- # # Raises NoMethodError (undefined method `first' for :foo:Symbol):
- # CSV::Table.new(:foo)
- #
- # Raises an exception if an element of +array_of_rows+ is not a \CSV::Table object:
- # # Raises NoMethodError (undefined method `headers' for :foo:Symbol):
- # CSV::Table.new([:foo])
- def initialize(array_of_rows, headers: nil)
- @table = array_of_rows
- @headers = headers
- unless @headers
- if @table.empty?
- @headers = []
- else
- @headers = @table.first.headers
- end
- end
-
- @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 ###
-
- extend Forwardable
- def_delegators :@table, :empty?, :length, :size
-
- # :call-seq:
- # table.by_col -> table_dup
- #
- # Returns a duplicate of +self+, in column mode
- # (see {Column Mode}[#class-CSV::Table-label-Column+Mode]):
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.mode # => :col_or_row
- # dup_table = table.by_col
- # dup_table.mode # => :col
- # dup_table.equal?(table) # => false # It's a dup
- #
- # This may be used to chain method calls without changing the mode
- # (but also will affect performance and memory usage):
- # dup_table.by_col['Name']
- #
- # Also note that changes to the duplicate table will not affect the original.
- def by_col
- self.class.new(@table.dup).by_col!
- end
-
- # :call-seq:
- # table.by_col! -> self
- #
- # Sets the mode for +self+ to column mode
- # (see {Column Mode}[#class-CSV::Table-label-Column+Mode]); returns +self+:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.mode # => :col_or_row
- # table1 = table.by_col!
- # table.mode # => :col
- # table1.equal?(table) # => true # Returned self
- def by_col!
- @mode = :col
-
- self
- end
-
- # :call-seq:
- # table.by_col_or_row -> table_dup
- #
- # Returns a duplicate of +self+, in mixed mode
- # (see {Mixed Mode}[#class-CSV::Table-label-Mixed+Mode]):
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true).by_col!
- # table.mode # => :col
- # dup_table = table.by_col_or_row
- # dup_table.mode # => :col_or_row
- # dup_table.equal?(table) # => false # It's a dup
- #
- # This may be used to chain method calls without changing the mode
- # (but also will affect performance and memory usage):
- # dup_table.by_col_or_row['Name']
- #
- # Also note that changes to the duplicate table will not affect the original.
- def by_col_or_row
- self.class.new(@table.dup).by_col_or_row!
- end
-
- # :call-seq:
- # table.by_col_or_row! -> self
- #
- # Sets the mode for +self+ to mixed mode
- # (see {Mixed Mode}[#class-CSV::Table-label-Mixed+Mode]); returns +self+:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true).by_col!
- # table.mode # => :col
- # table1 = table.by_col_or_row!
- # table.mode # => :col_or_row
- # table1.equal?(table) # => true # Returned self
- def by_col_or_row!
- @mode = :col_or_row
-
- self
- end
-
- # :call-seq:
- # table.by_row -> table_dup
- #
- # Returns a duplicate of +self+, in row mode
- # (see {Row Mode}[#class-CSV::Table-label-Row+Mode]):
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.mode # => :col_or_row
- # dup_table = table.by_row
- # dup_table.mode # => :row
- # dup_table.equal?(table) # => false # It's a dup
- #
- # This may be used to chain method calls without changing the mode
- # (but also will affect performance and memory usage):
- # dup_table.by_row[1]
- #
- # Also note that changes to the duplicate table will not affect the original.
- def by_row
- self.class.new(@table.dup).by_row!
- end
-
- # :call-seq:
- # table.by_row! -> self
- #
- # Sets the mode for +self+ to row mode
- # (see {Row Mode}[#class-CSV::Table-label-Row+Mode]); returns +self+:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.mode # => :col_or_row
- # table1 = table.by_row!
- # table.mode # => :row
- # table1.equal?(table) # => true # Returned self
- def by_row!
- @mode = :row
-
- self
- end
-
- # :call-seq:
- # table.headers -> array_of_headers
- #
- # Returns a new \Array containing the \String headers for the table.
- #
- # If the table is not empty, returns the headers from the first row:
- # rows = [
- # CSV::Row.new(['Foo', 'Bar'], []),
- # CSV::Row.new(['FOO', 'BAR'], []),
- # CSV::Row.new(['foo', 'bar'], []),
- # ]
- # table = CSV::Table.new(rows)
- # table.headers # => ["Foo", "Bar"]
- # table.delete(0)
- # table.headers # => ["FOO", "BAR"]
- # table.delete(0)
- # table.headers # => ["foo", "bar"]
- #
- # If the table is empty, returns a copy of the headers in the table itself:
- # table.delete(0)
- # table.headers # => ["Foo", "Bar"]
- def headers
- if @table.empty?
- @headers.dup
- else
- @table.first.headers
- end
- end
-
- # :call-seq:
- # table[n] -> row or column_data
- # table[range] -> array_of_rows or array_of_column_data
- # table[header] -> array_of_column_data
- #
- # Returns data from the table; does not modify the table.
- #
- # ---
- #
- # Fetch a \Row by Its \Integer Index::
- # - Form: <tt>table[n]</tt>, +n+ an integer.
- # - Access mode: <tt>:row</tt> or <tt>:col_or_row</tt>.
- # - Return value: _nth_ row of the table, if that row exists;
- # otherwise +nil+.
- #
- # Returns the _nth_ row of the table if that row exists:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # table[1] # => #<CSV::Row "Name":"bar" "Value":"1">
- # table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
- # table[1] # => #<CSV::Row "Name":"bar" "Value":"1">
- #
- # Counts backward from the last row if +n+ is negative:
- # table[-1] # => #<CSV::Row "Name":"baz" "Value":"2">
- #
- # Returns +nil+ if +n+ is too large or too small:
- # table[4] # => nil
- # table[-4] # => nil
- #
- # Raises an exception if the access mode is <tt>:row</tt>
- # and +n+ is not an \Integer:
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # # Raises TypeError (no implicit conversion of String into Integer):
- # table['Name']
- #
- # ---
- #
- # Fetch a Column by Its \Integer Index::
- # - Form: <tt>table[n]</tt>, +n+ an \Integer.
- # - Access mode: <tt>:col</tt>.
- # - Return value: _nth_ column of the table, if that column exists;
- # otherwise an \Array of +nil+ fields of length <tt>self.size</tt>.
- #
- # Returns the _nth_ column of the table if that column exists:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # table[1] # => ["0", "1", "2"]
- #
- # Counts backward from the last column if +n+ is negative:
- # table[-2] # => ["foo", "bar", "baz"]
- #
- # Returns an \Array of +nil+ fields if +n+ is too large or too small:
- # table[4] # => [nil, nil, nil]
- # table[-4] # => [nil, nil, nil]
- #
- # ---
- #
- # Fetch Rows by \Range::
- # - Form: <tt>table[range]</tt>, +range+ a \Range object.
- # - Access mode: <tt>:row</tt> or <tt>:col_or_row</tt>.
- # - Return value: rows from the table, beginning at row <tt>range.start</tt>,
- # if those rows exists.
- #
- # Returns rows from the table, beginning at row <tt>range.first</tt>,
- # if those rows exist:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # rows = table[1..2] # => #<CSV::Row "Name":"bar" "Value":"1">
- # rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
- # table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
- # rows = table[1..2] # => #<CSV::Row "Name":"bar" "Value":"1">
- # rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
- #
- # If there are too few rows, returns all from <tt>range.start</tt> to the end:
- # rows = table[1..50] # => #<CSV::Row "Name":"bar" "Value":"1">
- # rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
- #
- # Special case: if <tt>range.start == table.size</tt>, returns an empty \Array:
- # table[table.size..50] # => []
- #
- # If <tt>range.end</tt> is negative, calculates the ending index from the end:
- # rows = table[0..-1]
- # rows # => [#<CSV::Row "Name":"foo" "Value":"0">, #<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
- #
- # If <tt>range.start</tt> is negative, calculates the starting index from the end:
- # rows = table[-1..2]
- # rows # => [#<CSV::Row "Name":"baz" "Value":"2">]
- #
- # If <tt>range.start</tt> is larger than <tt>table.size</tt>, returns +nil+:
- # table[4..4] # => nil
- #
- # ---
- #
- # Fetch Columns by \Range::
- # - Form: <tt>table[range]</tt>, +range+ a \Range object.
- # - Access mode: <tt>:col</tt>.
- # - Return value: column data from the table, beginning at column <tt>range.start</tt>,
- # if those columns exist.
- #
- # Returns column values from the table, if the column exists;
- # the values are arranged by row:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col!
- # table[0..1] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # Special case: if <tt>range.start == headers.size</tt>,
- # returns an \Array (size: <tt>table.size</tt>) of empty \Arrays:
- # table[table.headers.size..50] # => [[], [], []]
- #
- # If <tt>range.end</tt> is negative, calculates the ending index from the end:
- # table[0..-1] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # If <tt>range.start</tt> is negative, calculates the starting index from the end:
- # table[-2..2] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
- #
- # If <tt>range.start</tt> is larger than <tt>table.size</tt>,
- # returns an \Array of +nil+ values:
- # table[4..4] # => [nil, nil, nil]
- #
- # ---
- #
- # Fetch a Column by Its \String Header::
- # - Form: <tt>table[header]</tt>, +header+ a \String header.
- # - Access mode: <tt>:col</tt> or <tt>:col_or_row</tt>
- # - Return value: column data from the table, if that +header+ exists.
- #
- # Returns column values from the table, if the column exists:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # table['Name'] # => ["foo", "bar", "baz"]
- # table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
- # col = table['Name']
- # col # => ["foo", "bar", "baz"]
- #
- # Modifying the returned column values does not modify the table:
- # col[0] = 'bat'
- # col # => ["bat", "bar", "baz"]
- # table['Name'] # => ["foo", "bar", "baz"]
- #
- # Returns an \Array of +nil+ values if there is no such column:
- # table['Nosuch'] # => [nil, nil, nil]
- def [](index_or_header)
- if @mode == :row or # by index
- (@mode == :col_or_row and (index_or_header.is_a?(Integer) or index_or_header.is_a?(Range)))
- @table[index_or_header]
- else # by header
- @table.map { |row| row[index_or_header] }
- end
- end
-
- # :call-seq:
- # table[n] = row -> row
- # table[n] = field_or_array_of_fields -> field_or_array_of_fields
- # table[header] = field_or_array_of_fields -> field_or_array_of_fields
- #
- # Puts data onto the table.
- #
- # ---
- #
- # Set a \Row by Its \Integer Index::
- # - Form: <tt>table[n] = row</tt>, +n+ an \Integer,
- # +row+ a \CSV::Row instance or an \Array of fields.
- # - Access mode: <tt>:row</tt> or <tt>:col_or_row</tt>.
- # - Return value: +row+.
- #
- # If the row exists, it is replaced:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # new_row = CSV::Row.new(['Name', 'Value'], ['bat', 3])
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # return_value = table[0] = new_row
- # return_value.equal?(new_row) # => true # Returned the row
- # table[0].to_h # => {"Name"=>"bat", "Value"=>3}
- #
- # With access mode <tt>:col_or_row</tt>:
- # table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
- # table[0] = CSV::Row.new(['Name', 'Value'], ['bam', 4])
- # table[0].to_h # => {"Name"=>"bam", "Value"=>4}
- #
- # With an \Array instead of a \CSV::Row, inherits headers from the table:
- # array = ['bad', 5]
- # return_value = table[0] = array
- # return_value.equal?(array) # => true # Returned the array
- # table[0].to_h # => {"Name"=>"bad", "Value"=>5}
- #
- # If the row does not exist, extends the table by adding rows:
- # assigns rows with +nil+ as needed:
- # table.size # => 3
- # table[5] = ['bag', 6]
- # table.size # => 6
- # table[3] # => nil
- # table[4]# => nil
- # table[5].to_h # => {"Name"=>"bag", "Value"=>6}
- #
- # Note that the +nil+ rows are actually +nil+, not a row of +nil+ fields.
- #
- # ---
- #
- # Set a Column by Its \Integer Index::
- # - Form: <tt>table[n] = array_of_fields</tt>, +n+ an \Integer,
- # +array_of_fields+ an \Array of \String fields.
- # - Access mode: <tt>:col</tt>.
- # - Return value: +array_of_fields+.
- #
- # If the column exists, it is replaced:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # new_col = [3, 4, 5]
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # return_value = table[1] = new_col
- # return_value.equal?(new_col) # => true # Returned the column
- # table[1] # => [3, 4, 5]
- # # The rows, as revised:
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # table[0].to_h # => {"Name"=>"foo", "Value"=>3}
- # table[1].to_h # => {"Name"=>"bar", "Value"=>4}
- # table[2].to_h # => {"Name"=>"baz", "Value"=>5}
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- #
- # If there are too few values, fills with +nil+ values:
- # table[1] = [0]
- # table[1] # => [0, nil, nil]
- #
- # If there are too many values, ignores the extra values:
- # table[1] = [0, 1, 2, 3, 4]
- # table[1] # => [0, 1, 2]
- #
- # If a single value is given, replaces all fields in the column with that value:
- # table[1] = 'bat'
- # table[1] # => ["bat", "bat", "bat"]
- #
- # ---
- #
- # Set a Column by Its \String Header::
- # - Form: <tt>table[header] = field_or_array_of_fields</tt>,
- # +header+ a \String header, +field_or_array_of_fields+ a field value
- # or an \Array of \String fields.
- # - Access mode: <tt>:col</tt> or <tt>:col_or_row</tt>.
- # - Return value: +field_or_array_of_fields+.
- #
- # If the column exists, it is replaced:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # new_col = [3, 4, 5]
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # return_value = table['Value'] = new_col
- # return_value.equal?(new_col) # => true # Returned the column
- # table['Value'] # => [3, 4, 5]
- # # The rows, as revised:
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # table[0].to_h # => {"Name"=>"foo", "Value"=>3}
- # table[1].to_h # => {"Name"=>"bar", "Value"=>4}
- # table[2].to_h # => {"Name"=>"baz", "Value"=>5}
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- #
- # If there are too few values, fills with +nil+ values:
- # table['Value'] = [0]
- # table['Value'] # => [0, nil, nil]
- #
- # If there are too many values, ignores the extra values:
- # table['Value'] = [0, 1, 2, 3, 4]
- # table['Value'] # => [0, 1, 2]
- #
- # If the column does not exist, extends the table by adding columns:
- # table['Note'] = ['x', 'y', 'z']
- # table['Note'] # => ["x", "y", "z"]
- # # The rows, as revised:
- # table.by_row!
- # table[0].to_h # => {"Name"=>"foo", "Value"=>0, "Note"=>"x"}
- # table[1].to_h # => {"Name"=>"bar", "Value"=>1, "Note"=>"y"}
- # table[2].to_h # => {"Name"=>"baz", "Value"=>2, "Note"=>"z"}
- # table.by_col!
- #
- # If a single value is given, replaces all fields in the column with that value:
- # table['Value'] = 'bat'
- # table['Value'] # => ["bat", "bat", "bat"]
- 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
- end
- else # set column
- unless index_or_header.is_a? Integer
- index = @headers.index(index_or_header) || @headers.size
- @headers[index] = index_or_header
- end
- 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]
- end
- end
- else # repeated value
- @table.each do |row|
- if row.header_row?
- row[index_or_header] = index_or_header
- else
- row[index_or_header] = value
- end
- end
- end
- end
- end
-
- # :call-seq:
- # table.values_at(*indexes) -> array_of_rows
- # table.values_at(*headers) -> array_of_columns_data
- #
- # If the access mode is <tt>:row</tt> or <tt>:col_or_row</tt>,
- # and each argument is either an \Integer or a \Range,
- # returns rows.
- # Otherwise, returns columns data.
- #
- # In either case, the returned values are in the order
- # specified by the arguments. Arguments may be repeated.
- #
- # ---
- #
- # Returns rows as an \Array of \CSV::Row objects.
- #
- # No argument:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.values_at # => []
- #
- # One index:
- # values = table.values_at(0)
- # values # => [#<CSV::Row "Name":"foo" "Value":"0">]
- #
- # Two indexes:
- # values = table.values_at(2, 0)
- # values # => [#<CSV::Row "Name":"baz" "Value":"2">, #<CSV::Row "Name":"foo" "Value":"0">]
- #
- # One \Range:
- # values = table.values_at(1..2)
- # values # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
- #
- # \Ranges and indexes:
- # values = table.values_at(0..1, 1..2, 0, 2)
- # pp values
- # Output:
- # [#<CSV::Row "Name":"foo" "Value":"0">,
- # #<CSV::Row "Name":"bar" "Value":"1">,
- # #<CSV::Row "Name":"bar" "Value":"1">,
- # #<CSV::Row "Name":"baz" "Value":"2">,
- # #<CSV::Row "Name":"foo" "Value":"0">,
- # #<CSV::Row "Name":"baz" "Value":"2">]
- #
- # ---
- #
- # Returns columns data as row Arrays,
- # each consisting of the specified columns data for that row:
- # values = table.values_at('Name')
- # values # => [["foo"], ["bar"], ["baz"]]
- # values = table.values_at('Value', 'Name')
- # values # => [["0", "foo"], ["1", "bar"], ["2", "baz"]]
- 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
-
- # :call-seq:
- # table << row_or_array -> self
- #
- # If +row_or_array+ is a \CSV::Row object,
- # it is appended to the table:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table << CSV::Row.new(table.headers, ['bat', 3])
- # table[3] # => #<CSV::Row "Name":"bat" "Value":3>
- #
- # If +row_or_array+ is an \Array, it is used to create a new
- # \CSV::Row object which is then appended to the table:
- # table << ['bam', 4]
- # table[4] # => #<CSV::Row "Name":"bam" "Value":4>
- 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
-
- #
- # :call-seq:
- # table.push(*rows_or_arrays) -> self
- #
- # A shortcut for appending multiple rows. Equivalent to:
- # rows.each {|row| self << row }
- #
- # Each argument may be either a \CSV::Row object or an \Array:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # rows = [
- # CSV::Row.new(table.headers, ['bat', 3]),
- # ['bam', 4]
- # ]
- # table.push(*rows)
- # table[3..4] # => [#<CSV::Row "Name":"bat" "Value":3>, #<CSV::Row "Name":"bam" "Value":4>]
- def push(*rows)
- rows.each { |row| self << row }
-
- self # for chaining
- end
-
- # :call-seq:
- # table.delete(*indexes) -> deleted_values
- # table.delete(*headers) -> deleted_values
- #
- # If the access mode is <tt>:row</tt> or <tt>:col_or_row</tt>,
- # and each argument is either an \Integer or a \Range,
- # returns deleted rows.
- # Otherwise, returns deleted columns data.
- #
- # In either case, the returned values are in the order
- # specified by the arguments. Arguments may be repeated.
- #
- # ---
- #
- # Returns rows as an \Array of \CSV::Row objects.
- #
- # One index:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # deleted_values = table.delete(0)
- # deleted_values # => [#<CSV::Row "Name":"foo" "Value":"0">]
- #
- # Two indexes:
- # table = CSV.parse(source, headers: true)
- # deleted_values = table.delete(2, 0)
- # deleted_values # => [#<CSV::Row "Name":"baz" "Value":"2">, #<CSV::Row "Name":"foo" "Value":"0">]
- #
- # ---
- #
- # Returns columns data as column Arrays.
- #
- # One header:
- # table = CSV.parse(source, headers: true)
- # deleted_values = table.delete('Name')
- # deleted_values # => ["foo", "bar", "baz"]
- #
- # Two headers:
- # table = CSV.parse(source, headers: true)
- # deleted_values = table.delete('Value', 'Name')
- # deleted_values # => [["0", "1", "2"], ["foo", "bar", "baz"]]
- def delete(*indexes_or_headers)
- if indexes_or_headers.empty?
- raise ArgumentError, "wrong number of arguments (given 0, expected 1+)"
- end
- deleted_values = indexes_or_headers.map do |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
- if index_or_header.is_a? Integer
- @headers.delete_at(index_or_header)
- else
- @headers.delete(index_or_header)
- end
- @table.map { |row| row.delete(index_or_header).last }
- end
- end
- if indexes_or_headers.size == 1
- deleted_values[0]
- else
- deleted_values
- end
- end
-
- # :call-seq:
- # table.delete_if {|row_or_column| ... } -> self
- #
- # Removes rows or columns for which the block returns a truthy value;
- # returns +self+.
- #
- # Removes rows when the access mode is <tt>:row</tt> or <tt>:col_or_row</tt>;
- # calls the block with each \CSV::Row object:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # table.size # => 3
- # table.delete_if {|row| row['Name'].start_with?('b') }
- # table.size # => 1
- #
- # Removes columns when the access mode is <tt>:col</tt>;
- # calls the block with each column as a 2-element array
- # containing the header and an \Array of column fields:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # table.headers.size # => 2
- # table.delete_if {|column_data| column_data[1].include?('2') }
- # table.headers.size # => 1
- #
- # Returns a new \Enumerator if no block is given:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.delete_if # => #<Enumerator: #<CSV::Table mode:col_or_row row_count:4>:delete_if>
- def delete_if(&block)
- return enum_for(__method__) { @mode == :row or @mode == :col_or_row ? size : headers.size } unless block_given?
-
- if @mode == :row or @mode == :col_or_row # by index
- @table.delete_if(&block)
- else # by header
- headers.each do |header|
- delete(header) if yield([header, self[header]])
- end
- end
-
- self # for chaining
- end
-
- include Enumerable
-
- # :call-seq:
- # table.each {|row_or_column| ... ) -> self
- #
- # Calls the block with each row or column; returns +self+.
- #
- # When the access mode is <tt>:row</tt> or <tt>:col_or_row</tt>,
- # calls the block with each \CSV::Row object:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.by_row! # => #<CSV::Table mode:row row_count:4>
- # table.each {|row| p row }
- # Output:
- # #<CSV::Row "Name":"foo" "Value":"0">
- # #<CSV::Row "Name":"bar" "Value":"1">
- # #<CSV::Row "Name":"baz" "Value":"2">
- #
- # When the access mode is <tt>:col</tt>,
- # calls the block with each column as a 2-element array
- # containing the header and an \Array of column fields:
- # table.by_col! # => #<CSV::Table mode:col row_count:4>
- # table.each {|column_data| p column_data }
- # Output:
- # ["Name", ["foo", "bar", "baz"]]
- # ["Value", ["0", "1", "2"]]
- #
- # Returns a new \Enumerator if no block is given:
- # table.each # => #<Enumerator: #<CSV::Table mode:col row_count:4>:each>
- def each(&block)
- return enum_for(__method__) { @mode == :col ? headers.size : size } unless block_given?
-
- if @mode == :col
- headers.each.with_index do |header, i|
- yield([header, @table.map {|row| row[header, i]}])
- end
- else
- @table.each(&block)
- end
-
- self # for chaining
- end
-
- # :call-seq:
- # table == other_table -> true or false
- #
- # Returns +true+ if all each row of +self+ <tt>==</tt>
- # the corresponding row of +other_table+, otherwise, +false+.
- #
- # The access mode does no affect the result.
- #
- # Equal tables:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # other_table = CSV.parse(source, headers: true)
- # table == other_table # => true
- #
- # Different row count:
- # other_table.delete(2)
- # table == other_table # => false
- #
- # Different last row:
- # other_table << ['bat', 3]
- # table == other_table # => false
- def ==(other)
- return @table == other.table if other.is_a? CSV::Table
- @table == other
- end
-
- # :call-seq:
- # table.to_a -> array_of_arrays
- #
- # Returns the table as an \Array of \Arrays;
- # the headers are in the first row:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.to_a # => [["Name", "Value"], ["foo", "0"], ["bar", "1"], ["baz", "2"]]
- def to_a
- array = [headers]
- @table.each do |row|
- array.push(row.fields) unless row.header_row?
- end
-
- array
- end
-
- # :call-seq:
- # table.to_csv(**options) -> csv_string
- #
- # Returns the table as \CSV string.
- # See {Options for Generating}[../CSV.html#class-CSV-label-Options+for+Generating].
- #
- # Defaults option +write_headers+ to +true+:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.to_csv # => "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- #
- # Omits the headers if option +write_headers+ is given as +false+
- # (see {Option +write_headers+}[../CSV.html#class-CSV-label-Option+write_headers]):
- # table.to_csv(write_headers: false) # => "foo,0\nbar,1\nbaz,2\n"
- #
- # Limit rows if option +limit+ is given like +2+:
- # table.to_csv(limit: 2) # => "Name,Value\nfoo,0\nbar,1\n"
- def to_csv(write_headers: true, limit: nil, **options)
- array = write_headers ? [headers.to_csv(**options)] : []
- limit ||= @table.size
- limit = @table.size + 1 + limit if limit < 0
- limit = 0 if limit < 0
- @table.first(limit).each do |row|
- array.push(row.fields.to_csv(**options)) unless row.header_row?
- end
-
- array.join("")
- end
- alias_method :to_s, :to_csv
-
- #
- # Extracts the nested value specified by the sequence of +index+ or +header+ objects by calling dig at each step,
- # returning nil if any intermediate step is nil.
- #
- def dig(index_or_header, *index_or_headers)
- value = self[index_or_header]
- if value.nil?
- nil
- elsif index_or_headers.empty?
- value
- else
- unless value.respond_to?(:dig)
- raise TypeError, "#{value.class} does not have \#dig method"
- end
- value.dig(*index_or_headers)
- end
- end
-
- # :call-seq:
- # table.inspect => string
- #
- # Returns a <tt>US-ASCII</tt>-encoded \String showing table:
- # - Class: <tt>CSV::Table</tt>.
- # - Access mode: <tt>:row</tt>, <tt>:col</tt>, or <tt>:col_or_row</tt>.
- # - Size: Row count, including the header row.
- #
- # Example:
- # source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
- # table = CSV.parse(source, headers: true)
- # table.inspect # => "#<CSV::Table mode:col_or_row row_count:4>\nName,Value\nfoo,0\nbar,1\nbaz,2\n"
- #
- def inspect
- inspected = +"#<#{self.class} mode:#{@mode} row_count:#{to_a.size}>"
- summary = to_csv(limit: 5)
- inspected << "\n" << summary if summary.encoding.ascii_compatible?
- inspected
- end
- end
-end
diff --git a/lib/csv/version.rb b/lib/csv/version.rb
deleted file mode 100644
index edafc6f128..0000000000
--- a/lib/csv/version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-class CSV
- # The version of the installed library.
- VERSION = "3.2.7"
-end
diff --git a/lib/csv/writer.rb b/lib/csv/writer.rb
deleted file mode 100644
index 030a295bc9..0000000000
--- a/lib/csv/writer.rb
+++ /dev/null
@@ -1,210 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "input_record_separator"
-require_relative "row"
-
-class CSV
- # Note: Don't use this class directly. This is an internal class.
- class Writer
- #
- # A CSV::Writer receives an output, prepares the header, format and output.
- # It allows us to write new rows in the object and rewind it.
- #
- attr_reader :lineno
- attr_reader :headers
-
- def initialize(output, options)
- @output = output
- @options = options
- @lineno = 0
- @fields_converter = nil
- prepare
- if @options[:write_headers] and @headers
- self << @headers
- end
- @fields_converter = @options[:fields_converter]
- end
-
- #
- # Adds a new row
- #
- def <<(row)
- case row
- when Row
- row = row.fields
- when Hash
- row = @headers.collect {|header| row[header]}
- end
-
- @headers ||= row if @use_headers
- @lineno += 1
-
- if @fields_converter
- quoted_fields = [false] * row.size
- row = @fields_converter.convert(row, nil, lineno, quoted_fields)
- end
-
- i = -1
- converted_row = row.collect do |field|
- i += 1
- quote(field, i)
- end
- line = converted_row.join(@column_separator) + @row_separator
- if @output_encoding
- line = line.encode(@output_encoding)
- end
- @output << line
-
- self
- end
-
- #
- # Winds back to the beginning
- #
- def rewind
- @lineno = 0
- @headers = nil if @options[:headers].nil?
- end
-
- private
- def prepare
- @encoding = @options[:encoding]
-
- prepare_header
- prepare_format
- prepare_output
- end
-
- def prepare_header
- headers = @options[:headers]
- case headers
- when Array
- @headers = headers
- @use_headers = true
- when String
- @headers = CSV.parse_line(headers,
- col_sep: @options[:column_separator],
- row_sep: @options[:row_separator],
- quote_char: @options[:quote_character])
- @use_headers = true
- when true
- @headers = nil
- @use_headers = true
- else
- @headers = nil
- @use_headers = false
- end
- return unless @headers
-
- converter = @options[:header_fields_converter]
- @headers = converter.convert(@headers, nil, 0, [])
- @headers.each do |header|
- header.freeze if header.is_a?(String)
- end
- end
-
- def prepare_force_quotes_fields(force_quotes)
- @force_quotes_fields = {}
- force_quotes.each do |name_or_index|
- case name_or_index
- when Integer
- index = name_or_index
- @force_quotes_fields[index] = true
- when String, Symbol
- name = name_or_index.to_s
- if @headers.nil?
- message = ":headers is required when you use field name " +
- "in :force_quotes: " +
- "#{name_or_index.inspect}: #{force_quotes.inspect}"
- raise ArgumentError, message
- end
- index = @headers.index(name)
- next if index.nil?
- @force_quotes_fields[index] = true
- else
- message = ":force_quotes element must be " +
- "field index or field name: " +
- "#{name_or_index.inspect}: #{force_quotes.inspect}"
- raise ArgumentError, message
- end
- end
- end
-
- def prepare_format
- @column_separator = @options[:column_separator].to_s.encode(@encoding)
- row_separator = @options[:row_separator]
- if row_separator == :auto
- @row_separator = InputRecordSeparator.value.encode(@encoding)
- else
- @row_separator = row_separator.to_s.encode(@encoding)
- end
- @quote_character = @options[:quote_character]
- force_quotes = @options[:force_quotes]
- if force_quotes.is_a?(Array)
- prepare_force_quotes_fields(force_quotes)
- @force_quotes = false
- elsif force_quotes
- @force_quotes_fields = nil
- @force_quotes = true
- else
- @force_quotes_fields = nil
- @force_quotes = false
- end
- unless @force_quotes
- @quotable_pattern =
- Regexp.new("[\r\n".encode(@encoding) +
- Regexp.escape(@column_separator) +
- Regexp.escape(@quote_character.encode(@encoding)) +
- "]".encode(@encoding))
- end
- @quote_empty = @options.fetch(:quote_empty, true)
- end
-
- def prepare_output
- @output_encoding = nil
- return unless @output.is_a?(StringIO)
-
- output_encoding = @output.internal_encoding || @output.external_encoding
- if @encoding != output_encoding
- if @options[:force_encoding]
- @output_encoding = output_encoding
- else
- compatible_encoding = Encoding.compatible?(@encoding, output_encoding)
- if compatible_encoding
- @output.set_encoding(compatible_encoding)
- @output.seek(0, IO::SEEK_END)
- end
- end
- end
- end
-
- def quote_field(field)
- field = String(field)
- encoded_quote_character = @quote_character.encode(field.encoding)
- encoded_quote_character +
- field.gsub(encoded_quote_character,
- encoded_quote_character * 2) +
- encoded_quote_character
- end
-
- def quote(field, i)
- if @force_quotes
- quote_field(field)
- elsif @force_quotes_fields and @force_quotes_fields[i]
- quote_field(field)
- else
- if field.nil? # represent +nil+ fields as empty unquoted fields
- ""
- else
- field = String(field) # Stringify fields
- # represent empty fields as empty quoted fields
- if (@quote_empty and field.empty?) or (field.valid_encoding? and @quotable_pattern.match?(field))
- quote_field(field)
- else
- field # unquoted field
- end
- end
- end
- end
- end
-end
diff --git a/lib/delegate.gemspec b/lib/delegate.gemspec
new file mode 100644
index 0000000000..f7fcc1ceb9
--- /dev/null
+++ b/lib/delegate.gemspec
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Provides three abilities to delegate method calls to an object.}
+ spec.description = %q{Provides three abilities to delegate method calls to an object.}
+ spec.homepage = "https://github.com/ruby/delegate"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.require_paths = ["lib"]
+ spec.required_ruby_version = '>= 3.0'
+end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 387a5f063d..0ff9797bdb 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -39,7 +39,8 @@
# Be advised, RDoc will not detect delegated methods.
#
class Delegator < BasicObject
- VERSION = "0.3.0"
+ # The version string
+ VERSION = "0.6.1"
kernel = ::Kernel.dup
kernel.class_eval do
@@ -77,7 +78,7 @@ class Delegator < BasicObject
end
#
- # Handles the magic of delegation through \_\_getobj\_\_.
+ # Handles the magic of delegation through +__getobj__+.
#
ruby2_keywords def method_missing(m, *args, &block)
r = true
@@ -94,7 +95,7 @@ class Delegator < BasicObject
#
# Checks for a method provided by this the delegate object by forwarding the
- # call through \_\_getobj\_\_.
+ # call through +__getobj__+.
#
def respond_to_missing?(m, include_private)
r = true
@@ -107,7 +108,7 @@ class Delegator < BasicObject
r
end
- KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
+ KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?) # :nodoc:
private_constant :KERNEL_RESPOND_TO
# Handle BasicObject instances
@@ -126,7 +127,7 @@ class Delegator < BasicObject
#
# Returns the methods available to this delegate object as the union
- # of this object's and \_\_getobj\_\_ methods.
+ # of this object's and +__getobj__+ methods.
#
def methods(all=true)
__getobj__.methods(all) | super
@@ -134,7 +135,7 @@ class Delegator < BasicObject
#
# Returns the methods available to this delegate object as the union
- # of this object's and \_\_getobj\_\_ public methods.
+ # of this object's and +__getobj__+ public methods.
#
def public_methods(all=true)
__getobj__.public_methods(all) | super
@@ -142,7 +143,7 @@ class Delegator < BasicObject
#
# Returns the methods available to this delegate object as the union
- # of this object's and \_\_getobj\_\_ protected methods.
+ # of this object's and +__getobj__+ protected methods.
#
def protected_methods(all=true)
__getobj__.protected_methods(all) | super
@@ -175,7 +176,7 @@ class Delegator < BasicObject
end
#
- # Delegates ! to the \_\_getobj\_\_
+ # Delegates ! to the +__getobj__+
#
def !
!__getobj__
@@ -186,7 +187,7 @@ class Delegator < BasicObject
# method calls are being delegated to.
#
def __getobj__
- __raise__ ::NotImplementedError, "need to define `__getobj__'"
+ __raise__ ::NotImplementedError, "need to define '__getobj__'"
end
#
@@ -194,11 +195,11 @@ class Delegator < BasicObject
# to _obj_.
#
def __setobj__(obj)
- __raise__ ::NotImplementedError, "need to define `__setobj__'"
+ __raise__ ::NotImplementedError, "need to define '__setobj__'"
end
#
- # Serialization support for the object returned by \_\_getobj\_\_.
+ # Serialization support for the object returned by +__getobj__+.
#
def marshal_dump
ivars = instance_variables.reject {|var| /\A@delegate_/ =~ var}
@@ -232,7 +233,7 @@ class Delegator < BasicObject
##
# :method: freeze
- # Freeze both the object returned by \_\_getobj\_\_ and self.
+ # Freeze both the object returned by +__getobj__+ and self.
#
def freeze
__getobj__.freeze
@@ -343,13 +344,6 @@ class SimpleDelegator < Delegator
end
end
-def Delegator.delegating_block(mid) # :nodoc:
- lambda do |*args, &block|
- target = self.__getobj__
- target.__send__(mid, *args, &block)
- end.ruby2_keywords
-end
-
#
# The primary interface to this library. Use to setup delegation when defining
# your class.
@@ -398,6 +392,32 @@ def DelegateClass(superclass, &block)
protected_instance_methods -= ignores
public_instance_methods = superclass.public_instance_methods
public_instance_methods -= ignores
+
+ methods_to_define =
+ public_instance_methods.map { |x| [x, false] } +
+ protected_instance_methods.map { |x| [x, true] }
+
+ source = []
+
+ methods_to_define.each do |target_name, is_protected|
+ unless target_name.match?(/\A[_a-zA-Z]\w*[!\?]?\z/)
+ placeholder_name = :__delegate
+ end
+
+ send_source =
+ if is_protected || placeholder_name
+ "__getobj__.__send__(#{target_name.inspect}, ...)"
+ else
+ "__getobj__.#{target_name}(...)"
+ end
+ source << "def #{placeholder_name || target_name}(...); #{send_source}; end"
+
+ if placeholder_name
+ source << "alias_method #{target_name.inspect}, :#{placeholder_name}"
+ source << "remove_method :#{placeholder_name}"
+ end
+ end
+
klass.module_eval do
def __getobj__ # :nodoc:
unless defined?(@delegate_dc_obj)
@@ -406,18 +426,17 @@ def DelegateClass(superclass, &block)
end
@delegate_dc_obj
end
+
def __setobj__(obj) # :nodoc:
__raise__ ::ArgumentError, "cannot delegate to self" if self.equal?(obj)
@delegate_dc_obj = obj
end
- protected_instance_methods.each do |method|
- define_method(method, Delegator.delegating_block(method))
- protected method
- end
- public_instance_methods.each do |method|
- define_method(method, Delegator.delegating_block(method))
- end
+
+ class_eval(source.join(";"), __FILE__, __LINE__)
+
+ protected(*protected_instance_methods)
end
+
klass.define_singleton_method :public_instance_methods do |all=true|
super(all) | superclass.public_instance_methods
end
diff --git a/lib/delegate/delegate.gemspec b/lib/delegate/delegate.gemspec
deleted file mode 100644
index 1cfacfeb2f..0000000000
--- a/lib/delegate/delegate.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides three abilities to delegate method calls to an object.}
- spec.description = %q{Provides three abilities to delegate method calls to an object.}
- spec.homepage = "https://github.com/ruby/delegate"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
- spec.required_ruby_version = '>= 2.7'
-end
diff --git a/lib/did_you_mean.rb b/lib/did_you_mean.rb
index e177665099..640d910389 100644
--- a/lib/did_you_mean.rb
+++ b/lib/did_you_mean.rb
@@ -47,9 +47,9 @@ require_relative 'did_you_mean/tree_spell_checker'
# # Did you mean? :foo
#
#
-# == Disabling +did_you_mean+
+# == Disabling \DidYouMean
#
-# Occasionally, you may want to disable the +did_you_mean+ gem for e.g.
+# Occasionally, you may want to disable the \DidYouMean gem for e.g.
# debugging issues in the error object itself. You can disable it entirely by
# specifying +--disable-did_you_mean+ option to the +ruby+ command:
#
@@ -113,30 +113,6 @@ module DidYouMean
correct_error LoadError, RequirePathChecker if RUBY_VERSION >= '2.8.0'
correct_error NoMatchingPatternKeyError, PatternKeyNameChecker if defined?(::NoMatchingPatternKeyError)
- # TODO: Remove on the 3.4 development start:
- class DeprecatedMapping # :nodoc:
- def []=(key, value)
- warn "Calling `DidYouMean::SPELL_CHECKERS[#{key.to_s}] = #{value.to_s}' has been deprecated. " \
- "Please call `DidYouMean.correct_error(#{key.to_s}, #{value.to_s})' instead."
-
- DidYouMean.correct_error(key, value)
- end
-
- def merge!(hash)
- warn "Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. " \
- "Please call `DidYouMean.correct_error(error_name, spell_checker)' instead."
-
- hash.each do |error_class, spell_checker|
- DidYouMean.correct_error(error_class, spell_checker)
- end
- end
- end
-
- # TODO: Remove on the 3.4 development start:
- SPELL_CHECKERS = DeprecatedMapping.new
- deprecate_constant :SPELL_CHECKERS
- private_constant :DeprecatedMapping
-
# Returns the currently set formatter. By default, it is set to +DidYouMean::Formatter+.
def self.formatter
if defined?(Ractor)
diff --git a/lib/did_you_mean/did_you_mean.gemspec b/lib/did_you_mean/did_you_mean.gemspec
index 8fe5723129..be4ac76b4b 100644
--- a/lib/did_you_mean/did_you_mean.gemspec
+++ b/lib/did_you_mean/did_you_mean.gemspec
@@ -22,6 +22,4 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.required_ruby_version = '>= 2.5.0'
-
- spec.add_development_dependency "rake"
end
diff --git a/lib/did_you_mean/jaro_winkler.rb b/lib/did_you_mean/jaro_winkler.rb
index 56db130af4..9a3e57f6d7 100644
--- a/lib/did_you_mean/jaro_winkler.rb
+++ b/lib/did_you_mean/jaro_winkler.rb
@@ -8,8 +8,7 @@ module DidYouMean
m = 0.0
t = 0.0
- range = (length2 / 2).floor - 1
- range = 0 if range < 0
+ range = length2 > 3 ? length2 / 2 - 1 : 0
flags1 = 0
flags2 = 0
@@ -72,10 +71,8 @@ module DidYouMean
codepoints2 = str2.codepoints
prefix_bonus = 0
- i = 0
str1.each_codepoint do |char1|
- char1 == codepoints2[i] && i < 4 ? prefix_bonus += 1 : break
- i += 1
+ char1 == codepoints2[prefix_bonus] && prefix_bonus < 4 ? prefix_bonus += 1 : break
end
jaro_distance + (prefix_bonus * WEIGHT * (1 - jaro_distance))
diff --git a/lib/did_you_mean/spell_checkers/key_error_checker.rb b/lib/did_you_mean/spell_checkers/key_error_checker.rb
index be4bea7789..955bff1be6 100644
--- a/lib/did_you_mean/spell_checkers/key_error_checker.rb
+++ b/lib/did_you_mean/spell_checkers/key_error_checker.rb
@@ -14,7 +14,15 @@ module DidYouMean
private
def exact_matches
- @exact_matches ||= @keys.select { |word| @key == word.to_s }.map(&:inspect)
+ @exact_matches ||= @keys.select { |word| @key == word.to_s }.map { |obj| format_object(obj) }
+ end
+
+ def format_object(symbol_or_object)
+ if symbol_or_object.is_a?(Symbol)
+ ":#{symbol_or_object}"
+ else
+ symbol_or_object.to_s
+ end
end
end
end
diff --git a/lib/did_you_mean/spell_checkers/pattern_key_name_checker.rb b/lib/did_you_mean/spell_checkers/pattern_key_name_checker.rb
index ed263c8f93..622d4dee25 100644
--- a/lib/did_you_mean/spell_checkers/pattern_key_name_checker.rb
+++ b/lib/did_you_mean/spell_checkers/pattern_key_name_checker.rb
@@ -14,7 +14,15 @@ module DidYouMean
private
def exact_matches
- @exact_matches ||= @keys.select { |word| @key == word.to_s }.map(&:inspect)
+ @exact_matches ||= @keys.select { |word| @key == word.to_s }.map { |obj| format_object(obj) }
+ end
+
+ def format_object(symbol_or_object)
+ if symbol_or_object.is_a?(Symbol)
+ ":#{symbol_or_object}"
+ else
+ symbol_or_object.to_s
+ end
end
end
end
diff --git a/lib/did_you_mean/version.rb b/lib/did_you_mean/version.rb
index 5745ca1efd..85d80e4230 100644
--- a/lib/did_you_mean/version.rb
+++ b/lib/did_you_mean/version.rb
@@ -1,3 +1,3 @@
module DidYouMean
- VERSION = "1.6.3".freeze
+ VERSION = "2.0.0".freeze
end
diff --git a/lib/drb.rb b/lib/drb.rb
deleted file mode 100644
index 2bb4716fa2..0000000000
--- a/lib/drb.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: false
-require 'drb/drb'
-
diff --git a/lib/drb/acl.rb b/lib/drb/acl.rb
deleted file mode 100644
index b004656f09..0000000000
--- a/lib/drb/acl.rb
+++ /dev/null
@@ -1,239 +0,0 @@
-# frozen_string_literal: false
-# Copyright (c) 2000,2002,2003 Masatoshi SEKI
-#
-# acl.rb is copyrighted free software by Masatoshi SEKI.
-# You can redistribute it and/or modify it under the same terms as Ruby.
-
-require 'ipaddr'
-
-##
-# Simple Access Control Lists.
-#
-# Access control lists are composed of "allow" and "deny" halves to control
-# access. Use "all" or "*" to match any address. To match a specific address
-# use any address or address mask that IPAddr can understand.
-#
-# Example:
-#
-# list = %w[
-# deny all
-# allow 192.168.1.1
-# allow ::ffff:192.168.1.2
-# allow 192.168.1.3
-# ]
-#
-# # From Socket#peeraddr, see also ACL#allow_socket?
-# addr = ["AF_INET", 10, "lc630", "192.168.1.3"]
-#
-# acl = ACL.new
-# p acl.allow_addr?(addr) # => true
-#
-# acl = ACL.new(list, ACL::DENY_ALLOW)
-# p acl.allow_addr?(addr) # => true
-
-class ACL
-
- ##
- # The current version of ACL
-
- VERSION=["2.0.0"]
-
- ##
- # An entry in an ACL
-
- class ACLEntry
-
- ##
- # Creates a new entry using +str+.
- #
- # +str+ may be "*" or "all" to match any address, an IP address string
- # to match a specific address, an IP address mask per IPAddr, or one
- # containing "*" to match part of an IPv4 address.
- #
- # IPAddr::InvalidPrefixError may be raised when an IP network
- # address with an invalid netmask/prefix is given.
-
- def initialize(str)
- if str == '*' or str == 'all'
- @pat = [:all]
- elsif str.include?('*')
- @pat = [:name, dot_pat(str)]
- else
- begin
- @pat = [:ip, IPAddr.new(str)]
- rescue IPAddr::InvalidPrefixError
- # In this case, `str` shouldn't be a host name pattern
- # because it contains a slash.
- raise
- rescue ArgumentError
- @pat = [:name, dot_pat(str)]
- end
- end
- end
-
- private
-
- ##
- # Creates a regular expression to match IPv4 addresses
-
- def dot_pat_str(str)
- list = str.split('.').collect { |s|
- (s == '*') ? '.+' : s
- }
- list.join("\\.")
- end
-
- private
-
- ##
- # Creates a Regexp to match an address.
-
- def dot_pat(str)
- /\A#{dot_pat_str(str)}\z/
- end
-
- public
-
- ##
- # Matches +addr+ against this entry.
-
- def match(addr)
- case @pat[0]
- when :all
- true
- when :ip
- begin
- ipaddr = IPAddr.new(addr[3])
- ipaddr = ipaddr.ipv4_mapped if @pat[1].ipv6? && ipaddr.ipv4?
- rescue ArgumentError
- return false
- end
- (@pat[1].include?(ipaddr)) ? true : false
- when :name
- (@pat[1] =~ addr[2]) ? true : false
- else
- false
- end
- end
- end
-
- ##
- # A list of ACLEntry objects. Used to implement the allow and deny halves
- # of an ACL
-
- class ACLList
-
- ##
- # Creates an empty ACLList
-
- def initialize
- @list = []
- end
-
- public
-
- ##
- # Matches +addr+ against each ACLEntry in this list.
-
- def match(addr)
- @list.each do |e|
- return true if e.match(addr)
- end
- false
- end
-
- public
-
- ##
- # Adds +str+ as an ACLEntry in this list
-
- def add(str)
- @list.push(ACLEntry.new(str))
- end
-
- end
-
- ##
- # Default to deny
-
- DENY_ALLOW = 0
-
- ##
- # Default to allow
-
- ALLOW_DENY = 1
-
- ##
- # Creates a new ACL from +list+ with an evaluation +order+ of DENY_ALLOW or
- # ALLOW_DENY.
- #
- # An ACL +list+ is an Array of "allow" or "deny" and an address or address
- # mask or "all" or "*" to match any address:
- #
- # %w[
- # deny all
- # allow 192.0.2.2
- # allow 192.0.2.128/26
- # ]
-
- def initialize(list=nil, order = DENY_ALLOW)
- @order = order
- @deny = ACLList.new
- @allow = ACLList.new
- install_list(list) if list
- end
-
- public
-
- ##
- # Allow connections from Socket +soc+?
-
- def allow_socket?(soc)
- allow_addr?(soc.peeraddr)
- end
-
- public
-
- ##
- # Allow connections from addrinfo +addr+? It must be formatted like
- # Socket#peeraddr:
- #
- # ["AF_INET", 10, "lc630", "192.0.2.1"]
-
- def allow_addr?(addr)
- case @order
- when DENY_ALLOW
- return true if @allow.match(addr)
- return false if @deny.match(addr)
- return true
- when ALLOW_DENY
- return false if @deny.match(addr)
- return true if @allow.match(addr)
- return false
- else
- false
- end
- end
-
- public
-
- ##
- # Adds +list+ of ACL entries to this ACL.
-
- def install_list(list)
- i = 0
- while i < list.size
- permission, domain = list.slice(i,2)
- case permission.downcase
- when 'allow'
- @allow.add(domain)
- when 'deny'
- @deny.add(domain)
- else
- raise "Invalid ACL entry #{list}"
- end
- i += 2
- end
- end
-
-end
diff --git a/lib/drb/drb.gemspec b/lib/drb/drb.gemspec
deleted file mode 100644
index c9d7e40a51..0000000000
--- a/lib/drb/drb.gemspec
+++ /dev/null
@@ -1,43 +0,0 @@
-begin
- require_relative "lib/drb/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "drb"
- spec.version = DRb::VERSION
- spec.authors = ["Masatoshi SEKI"]
- spec.email = ["seki@ruby-lang.org"]
-
- spec.summary = %q{Distributed object system for Ruby}
- spec.description = %q{Distributed object system for Ruby}
- spec.homepage = "https://github.com/ruby/drb"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = %w[
- LICENSE.txt
- drb.gemspec
- lib/drb.rb
- lib/drb/acl.rb
- lib/drb/drb.rb
- lib/drb/eq.rb
- lib/drb/extserv.rb
- lib/drb/extservm.rb
- lib/drb/gw.rb
- lib/drb/invokemethod.rb
- lib/drb/observer.rb
- lib/drb/ssl.rb
- lib/drb/timeridconv.rb
- lib/drb/unix.rb
- lib/drb/version.rb
- lib/drb/weakidconv.rb
- ]
- spec.require_paths = ["lib"]
-
- spec.add_dependency "ruby2_keywords"
-end
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
deleted file mode 100644
index 23181bb834..0000000000
--- a/lib/drb/drb.rb
+++ /dev/null
@@ -1,1942 +0,0 @@
-# frozen_string_literal: false
-#
-# = drb/drb.rb
-#
-# Distributed Ruby: _dRuby_ version 2.0.4
-#
-# Copyright (c) 1999-2003 Masatoshi SEKI. You can redistribute it and/or
-# modify it under the same terms as Ruby.
-#
-# Author:: Masatoshi SEKI
-#
-# Documentation:: William Webber (william@williamwebber.com)
-#
-# == Overview
-#
-# dRuby is a distributed object system for Ruby. It allows an object in one
-# Ruby process to invoke methods on an object in another Ruby process on the
-# same or a different machine.
-#
-# The Ruby standard library contains the core classes of the dRuby package.
-# However, the full package also includes access control lists and the
-# Rinda tuple-space distributed task management system, as well as a
-# large number of samples. The full dRuby package can be downloaded from
-# the dRuby home page (see *References*).
-#
-# For an introduction and examples of usage see the documentation to the
-# DRb module.
-#
-# == References
-#
-# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.html]
-# The dRuby home page, in Japanese. Contains the full dRuby package
-# and links to other Japanese-language sources.
-#
-# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.en.html]
-# The English version of the dRuby home page.
-#
-# [http://pragprog.com/book/sidruby/the-druby-book]
-# The dRuby Book: Distributed and Parallel Computing with Ruby
-# by Masatoshi Seki and Makoto Inoue
-#
-# [http://www.ruby-doc.org/docs/ProgrammingRuby/html/ospace.html]
-# The chapter from *Programming* *Ruby* by Dave Thomas and Andy Hunt
-# which discusses dRuby.
-#
-# [http://www.clio.ne.jp/home/web-i31s/Flotuard/Ruby/PRC2K_seki/dRuby.en.html]
-# Translation of presentation on Ruby by Masatoshi Seki.
-
-require 'socket'
-require 'io/wait'
-require 'monitor'
-require_relative 'eq'
-
-#
-# == Overview
-#
-# dRuby is a distributed object system for Ruby. It is written in
-# pure Ruby and uses its own protocol. No add-in services are needed
-# beyond those provided by the Ruby runtime, such as TCP sockets. It
-# does not rely on or interoperate with other distributed object
-# systems such as CORBA, RMI, or .NET.
-#
-# dRuby allows methods to be called in one Ruby process upon a Ruby
-# object located in another Ruby process, even on another machine.
-# References to objects can be passed between processes. Method
-# arguments and return values are dumped and loaded in marshalled
-# format. All of this is done transparently to both the caller of the
-# remote method and the object that it is called upon.
-#
-# An object in a remote process is locally represented by a
-# DRb::DRbObject instance. This acts as a sort of proxy for the
-# remote object. Methods called upon this DRbObject instance are
-# forwarded to its remote object. This is arranged dynamically at run
-# time. There are no statically declared interfaces for remote
-# objects, such as CORBA's IDL.
-#
-# dRuby calls made into a process are handled by a DRb::DRbServer
-# instance within that process. This reconstitutes the method call,
-# invokes it upon the specified local object, and returns the value to
-# the remote caller. Any object can receive calls over dRuby. There
-# is no need to implement a special interface, or mixin special
-# functionality. Nor, in the general case, does an object need to
-# explicitly register itself with a DRbServer in order to receive
-# dRuby calls.
-#
-# One process wishing to make dRuby calls upon another process must
-# somehow obtain an initial reference to an object in the remote
-# process by some means other than as the return value of a remote
-# method call, as there is initially no remote object reference it can
-# invoke a method upon. This is done by attaching to the server by
-# URI. Each DRbServer binds itself to a URI such as
-# 'druby://example.com:8787'. A DRbServer can have an object attached
-# to it that acts as the server's *front* *object*. A DRbObject can
-# be explicitly created from the server's URI. This DRbObject's
-# remote object will be the server's front object. This front object
-# can then return references to other Ruby objects in the DRbServer's
-# process.
-#
-# Method calls made over dRuby behave largely the same as normal Ruby
-# method calls made within a process. Method calls with blocks are
-# supported, as are raising exceptions. In addition to a method's
-# standard errors, a dRuby call may also raise one of the
-# dRuby-specific errors, all of which are subclasses of DRb::DRbError.
-#
-# Any type of object can be passed as an argument to a dRuby call or
-# returned as its return value. By default, such objects are dumped
-# or marshalled at the local end, then loaded or unmarshalled at the
-# remote end. The remote end therefore receives a copy of the local
-# object, not a distributed reference to it; methods invoked upon this
-# copy are executed entirely in the remote process, not passed on to
-# the local original. This has semantics similar to pass-by-value.
-#
-# However, if an object cannot be marshalled, a dRuby reference to it
-# is passed or returned instead. This will turn up at the remote end
-# as a DRbObject instance. All methods invoked upon this remote proxy
-# are forwarded to the local object, as described in the discussion of
-# DRbObjects. This has semantics similar to the normal Ruby
-# pass-by-reference.
-#
-# The easiest way to signal that we want an otherwise marshallable
-# object to be passed or returned as a DRbObject reference, rather
-# than marshalled and sent as a copy, is to include the
-# DRb::DRbUndumped mixin module.
-#
-# dRuby supports calling remote methods with blocks. As blocks (or
-# rather the Proc objects that represent them) are not marshallable,
-# the block executes in the local, not the remote, context. Each
-# value yielded to the block is passed from the remote object to the
-# local block, then the value returned by each block invocation is
-# passed back to the remote execution context to be collected, before
-# the collected values are finally returned to the local context as
-# the return value of the method invocation.
-#
-# == Examples of usage
-#
-# For more dRuby samples, see the +samples+ directory in the full
-# dRuby distribution.
-#
-# === dRuby in client/server mode
-#
-# This illustrates setting up a simple client-server drb
-# system. Run the server and client code in different terminals,
-# starting the server code first.
-#
-# ==== Server code
-#
-# require 'drb/drb'
-#
-# # The URI for the server to connect to
-# URI="druby://localhost:8787"
-#
-# class TimeServer
-#
-# def get_current_time
-# return Time.now
-# end
-#
-# end
-#
-# # The object that handles requests on the server
-# FRONT_OBJECT=TimeServer.new
-#
-# DRb.start_service(URI, FRONT_OBJECT)
-# # Wait for the drb server thread to finish before exiting.
-# DRb.thread.join
-#
-# ==== Client code
-#
-# require 'drb/drb'
-#
-# # The URI to connect to
-# SERVER_URI="druby://localhost:8787"
-#
-# # Start a local DRbServer to handle callbacks.
-# #
-# # Not necessary for this small example, but will be required
-# # as soon as we pass a non-marshallable object as an argument
-# # to a dRuby call.
-# #
-# # Note: this must be called at least once per process to take any effect.
-# # This is particularly important if your application forks.
-# DRb.start_service
-#
-# timeserver = DRbObject.new_with_uri(SERVER_URI)
-# puts timeserver.get_current_time
-#
-# === Remote objects under dRuby
-#
-# This example illustrates returning a reference to an object
-# from a dRuby call. The Logger instances live in the server
-# process. References to them are returned to the client process,
-# where methods can be invoked upon them. These methods are
-# executed in the server process.
-#
-# ==== Server code
-#
-# require 'drb/drb'
-#
-# URI="druby://localhost:8787"
-#
-# class Logger
-#
-# # Make dRuby send Logger instances as dRuby references,
-# # not copies.
-# include DRb::DRbUndumped
-#
-# def initialize(n, fname)
-# @name = n
-# @filename = fname
-# end
-#
-# def log(message)
-# File.open(@filename, "a") do |f|
-# f.puts("#{Time.now}: #{@name}: #{message}")
-# end
-# end
-#
-# end
-#
-# # We have a central object for creating and retrieving loggers.
-# # This retains a local reference to all loggers created. This
-# # is so an existing logger can be looked up by name, but also
-# # to prevent loggers from being garbage collected. A dRuby
-# # reference to an object is not sufficient to prevent it being
-# # garbage collected!
-# class LoggerFactory
-#
-# def initialize(bdir)
-# @basedir = bdir
-# @loggers = {}
-# end
-#
-# def get_logger(name)
-# if !@loggers.has_key? name
-# # make the filename safe, then declare it to be so
-# fname = name.gsub(/[.\/\\\:]/, "_")
-# @loggers[name] = Logger.new(name, @basedir + "/" + fname)
-# end
-# return @loggers[name]
-# end
-#
-# end
-#
-# FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
-#
-# DRb.start_service(URI, FRONT_OBJECT)
-# DRb.thread.join
-#
-# ==== Client code
-#
-# require 'drb/drb'
-#
-# SERVER_URI="druby://localhost:8787"
-#
-# DRb.start_service
-#
-# log_service=DRbObject.new_with_uri(SERVER_URI)
-#
-# ["loga", "logb", "logc"].each do |logname|
-#
-# logger=log_service.get_logger(logname)
-#
-# logger.log("Hello, world!")
-# logger.log("Goodbye, world!")
-# logger.log("=== EOT ===")
-#
-# end
-#
-# == Security
-#
-# As with all network services, security needs to be considered when
-# using dRuby. By allowing external access to a Ruby object, you are
-# not only allowing outside clients to call the methods you have
-# defined for that object, but by default to execute arbitrary Ruby
-# code on your server. Consider the following:
-#
-# # !!! UNSAFE CODE !!!
-# ro = DRbObject::new_with_uri("druby://your.server.com:8989")
-# class << ro
-# undef :instance_eval # force call to be passed to remote object
-# end
-# ro.instance_eval("`rm -rf *`")
-#
-# The dangers posed by instance_eval and friends are such that a
-# DRbServer should only be used when clients are trusted.
-#
-# A DRbServer can be configured with an access control list to
-# selectively allow or deny access from specified IP addresses. The
-# main druby distribution provides the ACL class for this purpose. In
-# general, this mechanism should only be used alongside, rather than
-# as a replacement for, a good firewall.
-#
-# == dRuby internals
-#
-# dRuby is implemented using three main components: a remote method
-# call marshaller/unmarshaller; a transport protocol; and an
-# ID-to-object mapper. The latter two can be directly, and the first
-# indirectly, replaced, in order to provide different behaviour and
-# capabilities.
-#
-# Marshalling and unmarshalling of remote method calls is performed by
-# a DRb::DRbMessage instance. This uses the Marshal module to dump
-# the method call before sending it over the transport layer, then
-# reconstitute it at the other end. There is normally no need to
-# replace this component, and no direct way is provided to do so.
-# However, it is possible to implement an alternative marshalling
-# scheme as part of an implementation of the transport layer.
-#
-# The transport layer is responsible for opening client and server
-# network connections and forwarding dRuby request across them.
-# Normally, it uses DRb::DRbMessage internally to manage marshalling
-# and unmarshalling. The transport layer is managed by
-# DRb::DRbProtocol. Multiple protocols can be installed in
-# DRbProtocol at the one time; selection between them is determined by
-# the scheme of a dRuby URI. The default transport protocol is
-# selected by the scheme 'druby:', and implemented by
-# DRb::DRbTCPSocket. This uses plain TCP/IP sockets for
-# communication. An alternative protocol, using UNIX domain sockets,
-# is implemented by DRb::DRbUNIXSocket in the file drb/unix.rb, and
-# selected by the scheme 'drbunix:'. A sample implementation over
-# HTTP can be found in the samples accompanying the main dRuby
-# distribution.
-#
-# The ID-to-object mapping component maps dRuby object ids to the
-# objects they refer to, and vice versa. The implementation to use
-# can be specified as part of a DRb::DRbServer's configuration. The
-# default implementation is provided by DRb::DRbIdConv. It uses an
-# object's ObjectSpace id as its dRuby id. This means that the dRuby
-# reference to that object only remains meaningful for the lifetime of
-# the object's process and the lifetime of the object within that
-# process. A modified implementation is provided by DRb::TimerIdConv
-# in the file drb/timeridconv.rb. This implementation retains a local
-# reference to all objects exported over dRuby for a configurable
-# period of time (defaulting to ten minutes), to prevent them being
-# garbage-collected within this time. Another sample implementation
-# is provided in sample/name.rb in the main dRuby distribution. This
-# allows objects to specify their own id or "name". A dRuby reference
-# can be made persistent across processes by having each process
-# register an object using the same dRuby name.
-#
-module DRb
-
- # Superclass of all errors raised in the DRb module.
- class DRbError < RuntimeError; end
-
- # Error raised when an error occurs on the underlying communication
- # protocol.
- class DRbConnError < DRbError; end
-
- # Class responsible for converting between an object and its id.
- #
- # This, the default implementation, uses an object's local ObjectSpace
- # __id__ as its id. This means that an object's identification over
- # drb remains valid only while that object instance remains alive
- # within the server runtime.
- #
- # For alternative mechanisms, see DRb::TimerIdConv in drb/timeridconv.rb
- # and DRbNameIdConv in sample/name.rb in the full drb distribution.
- class DRbIdConv
-
- # Convert an object reference id to an object.
- #
- # This implementation looks up the reference id in the local object
- # space and returns the object it refers to.
- def to_obj(ref)
- ObjectSpace._id2ref(ref)
- end
-
- # Convert an object into a reference id.
- #
- # This implementation returns the object's __id__ in the local
- # object space.
- def to_id(obj)
- case obj
- when Object
- obj.nil? ? nil : obj.__id__
- when BasicObject
- obj.__id__
- end
- end
- end
-
- # Mixin module making an object undumpable or unmarshallable.
- #
- # If an object which includes this module is returned by method
- # called over drb, then the object remains in the server space
- # and a reference to the object is returned, rather than the
- # object being marshalled and moved into the client space.
- module DRbUndumped
- def _dump(dummy) # :nodoc:
- raise TypeError, 'can\'t dump'
- end
- end
-
- # Error raised by the DRb module when an attempt is made to refer to
- # the context's current drb server but the context does not have one.
- # See #current_server.
- class DRbServerNotFound < DRbError; end
-
- # Error raised by the DRbProtocol module when it cannot find any
- # protocol implementation support the scheme specified in a URI.
- class DRbBadURI < DRbError; end
-
- # Error raised by a dRuby protocol when it doesn't support the
- # scheme specified in a URI. See DRb::DRbProtocol.
- class DRbBadScheme < DRbError; end
-
- # An exception wrapping a DRb::DRbUnknown object
- class DRbUnknownError < DRbError
-
- # Create a new DRbUnknownError for the DRb::DRbUnknown object +unknown+
- def initialize(unknown)
- @unknown = unknown
- super(unknown.name)
- end
-
- # Get the wrapped DRb::DRbUnknown object.
- attr_reader :unknown
-
- def self._load(s) # :nodoc:
- Marshal::load(s)
- end
-
- def _dump(lv) # :nodoc:
- Marshal::dump(@unknown)
- end
- end
-
- # An exception wrapping an error object
- class DRbRemoteError < DRbError
-
- # Creates a new remote error that wraps the Exception +error+
- def initialize(error)
- @reason = error.class.to_s
- super("#{error.message} (#{error.class})")
- set_backtrace(error.backtrace)
- end
-
- # the class of the error, as a string.
- attr_reader :reason
- end
-
- # Class wrapping a marshalled object whose type is unknown locally.
- #
- # If an object is returned by a method invoked over drb, but the
- # class of the object is unknown in the client namespace, or
- # the object is a constant unknown in the client namespace, then
- # the still-marshalled object is returned wrapped in a DRbUnknown instance.
- #
- # If this object is passed as an argument to a method invoked over
- # drb, then the wrapped object is passed instead.
- #
- # The class or constant name of the object can be read from the
- # +name+ attribute. The marshalled object is held in the +buf+
- # attribute.
- class DRbUnknown
-
- # Create a new DRbUnknown object.
- #
- # +buf+ is a string containing a marshalled object that could not
- # be unmarshalled. +err+ is the error message that was raised
- # when the unmarshalling failed. It is used to determine the
- # name of the unmarshalled object.
- def initialize(err, buf)
- case err.to_s
- when /uninitialized constant (\S+)/
- @name = $1
- when /undefined class\/module (\S+)/
- @name = $1
- else
- @name = nil
- end
- @buf = buf
- end
-
- # The name of the unknown thing.
- #
- # Class name for unknown objects; variable name for unknown
- # constants.
- attr_reader :name
-
- # Buffer contained the marshalled, unknown object.
- attr_reader :buf
-
- def self._load(s) # :nodoc:
- begin
- Marshal::load(s)
- rescue NameError, ArgumentError
- DRbUnknown.new($!, s)
- end
- end
-
- def _dump(lv) # :nodoc:
- @buf
- end
-
- # Attempt to load the wrapped marshalled object again.
- #
- # If the class of the object is now known locally, the object
- # will be unmarshalled and returned. Otherwise, a new
- # but identical DRbUnknown object will be returned.
- def reload
- self.class._load(@buf)
- end
-
- # Create a DRbUnknownError exception containing this object.
- def exception
- DRbUnknownError.new(self)
- end
- end
-
- # An Array wrapper that can be sent to another server via DRb.
- #
- # All entries in the array will be dumped or be references that point to
- # the local server.
-
- class DRbArray
-
- # Creates a new DRbArray that either dumps or wraps all the items in the
- # Array +ary+ so they can be loaded by a remote DRb server.
-
- def initialize(ary)
- @ary = ary.collect { |obj|
- if obj.kind_of? DRbUndumped
- DRbObject.new(obj)
- else
- begin
- Marshal.dump(obj)
- obj
- rescue
- DRbObject.new(obj)
- end
- end
- }
- end
-
- def self._load(s) # :nodoc:
- Marshal::load(s)
- end
-
- def _dump(lv) # :nodoc:
- Marshal.dump(@ary)
- end
- end
-
- # Handler for sending and receiving drb messages.
- #
- # This takes care of the low-level marshalling and unmarshalling
- # of drb requests and responses sent over the wire between server
- # and client. This relieves the implementor of a new drb
- # protocol layer with having to deal with these details.
- #
- # The user does not have to directly deal with this object in
- # normal use.
- class DRbMessage
- def initialize(config) # :nodoc:
- @load_limit = config[:load_limit]
- @argc_limit = config[:argc_limit]
- end
-
- def dump(obj, error=false) # :nodoc:
- case obj
- when DRbUndumped
- obj = make_proxy(obj, error)
- when Object
- # nothing
- else
- obj = make_proxy(obj, error)
- end
- begin
- str = Marshal::dump(obj)
- rescue
- str = Marshal::dump(make_proxy(obj, error))
- end
- [str.size].pack('N') + str
- end
-
- def load(soc) # :nodoc:
- begin
- sz = soc.read(4) # sizeof (N)
- rescue
- raise(DRbConnError, $!.message, $!.backtrace)
- end
- raise(DRbConnError, 'connection closed') if sz.nil?
- raise(DRbConnError, 'premature header') if sz.size < 4
- sz = sz.unpack('N')[0]
- raise(DRbConnError, "too large packet #{sz}") if @load_limit < sz
- begin
- str = soc.read(sz)
- rescue
- raise(DRbConnError, $!.message, $!.backtrace)
- end
- raise(DRbConnError, 'connection closed') if str.nil?
- raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
- DRb.mutex.synchronize do
- begin
- Marshal::load(str)
- rescue NameError, ArgumentError
- DRbUnknown.new($!, str)
- end
- end
- end
-
- def send_request(stream, ref, msg_id, arg, b) # :nodoc:
- ary = []
- ary.push(dump(ref.__drbref))
- ary.push(dump(msg_id.id2name))
- ary.push(dump(arg.length))
- arg.each do |e|
- ary.push(dump(e))
- end
- ary.push(dump(b))
- stream.write(ary.join(''))
- rescue
- raise(DRbConnError, $!.message, $!.backtrace)
- end
-
- def recv_request(stream) # :nodoc:
- ref = load(stream)
- ro = DRb.to_obj(ref)
- msg = load(stream)
- argc = load(stream)
- raise(DRbConnError, "too many arguments") if @argc_limit < argc
- argv = Array.new(argc, nil)
- argc.times do |n|
- argv[n] = load(stream)
- end
- block = load(stream)
- return ro, msg, argv, block
- end
-
- def send_reply(stream, succ, result) # :nodoc:
- stream.write(dump(succ) + dump(result, !succ))
- rescue
- raise(DRbConnError, $!.message, $!.backtrace)
- end
-
- def recv_reply(stream) # :nodoc:
- succ = load(stream)
- result = load(stream)
- [succ, result]
- end
-
- private
- def make_proxy(obj, error=false) # :nodoc:
- if error
- DRbRemoteError.new(obj)
- else
- DRbObject.new(obj)
- end
- end
- end
-
- # Module managing the underlying network protocol(s) used by drb.
- #
- # By default, drb uses the DRbTCPSocket protocol. Other protocols
- # can be defined. A protocol must define the following class methods:
- #
- # [open(uri, config)] Open a client connection to the server at +uri+,
- # using configuration +config+. Return a protocol
- # instance for this connection.
- # [open_server(uri, config)] Open a server listening at +uri+,
- # using configuration +config+. Return a
- # protocol instance for this listener.
- # [uri_option(uri, config)] Take a URI, possibly containing an option
- # component (e.g. a trailing '?param=val'),
- # and return a [uri, option] tuple.
- #
- # All of these methods should raise a DRbBadScheme error if the URI
- # does not identify the protocol they support (e.g. "druby:" for
- # the standard Ruby protocol). This is how the DRbProtocol module,
- # given a URI, determines which protocol implementation serves that
- # protocol.
- #
- # The protocol instance returned by #open_server must have the
- # following methods:
- #
- # [accept] Accept a new connection to the server. Returns a protocol
- # instance capable of communicating with the client.
- # [close] Close the server connection.
- # [uri] Get the URI for this server.
- #
- # The protocol instance returned by #open must have the following methods:
- #
- # [send_request (ref, msg_id, arg, b)]
- # Send a request to +ref+ with the given message id and arguments.
- # This is most easily implemented by calling DRbMessage.send_request,
- # providing a stream that sits on top of the current protocol.
- # [recv_reply]
- # Receive a reply from the server and return it as a [success-boolean,
- # reply-value] pair. This is most easily implemented by calling
- # DRb.recv_reply, providing a stream that sits on top of the
- # current protocol.
- # [alive?]
- # Is this connection still alive?
- # [close]
- # Close this connection.
- #
- # The protocol instance returned by #open_server().accept() must have
- # the following methods:
- #
- # [recv_request]
- # Receive a request from the client and return a [object, message,
- # args, block] tuple. This is most easily implemented by calling
- # DRbMessage.recv_request, providing a stream that sits on top of
- # the current protocol.
- # [send_reply(succ, result)]
- # Send a reply to the client. This is most easily implemented
- # by calling DRbMessage.send_reply, providing a stream that sits
- # on top of the current protocol.
- # [close]
- # Close this connection.
- #
- # A new protocol is registered with the DRbProtocol module using
- # the add_protocol method.
- #
- # For examples of other protocols, see DRbUNIXSocket in drb/unix.rb,
- # and HTTP0 in sample/http0.rb and sample/http0serv.rb in the full
- # drb distribution.
- module DRbProtocol
-
- # Add a new protocol to the DRbProtocol module.
- def add_protocol(prot)
- @protocol.push(prot)
- end
- module_function :add_protocol
-
- # Open a client connection to +uri+ with the configuration +config+.
- #
- # The DRbProtocol module asks each registered protocol in turn to
- # try to open the URI. Each protocol signals that it does not handle that
- # URI by raising a DRbBadScheme error. If no protocol recognises the
- # URI, then a DRbBadURI error is raised. If a protocol accepts the
- # URI, but an error occurs in opening it, a DRbConnError is raised.
- def open(uri, config, first=true)
- @protocol.each do |prot|
- begin
- return prot.open(uri, config)
- rescue DRbBadScheme
- rescue DRbConnError
- raise($!)
- rescue
- raise(DRbConnError, "#{uri} - #{$!.inspect}")
- end
- end
- if first && (config[:auto_load] != false)
- auto_load(uri)
- return open(uri, config, false)
- end
- raise DRbBadURI, 'can\'t parse uri:' + uri
- end
- module_function :open
-
- # Open a server listening for connections at +uri+ with
- # configuration +config+.
- #
- # The DRbProtocol module asks each registered protocol in turn to
- # try to open a server at the URI. Each protocol signals that it does
- # not handle that URI by raising a DRbBadScheme error. If no protocol
- # recognises the URI, then a DRbBadURI error is raised. If a protocol
- # accepts the URI, but an error occurs in opening it, the underlying
- # error is passed on to the caller.
- def open_server(uri, config, first=true)
- @protocol.each do |prot|
- begin
- return prot.open_server(uri, config)
- rescue DRbBadScheme
- end
- end
- if first && (config[:auto_load] != false)
- auto_load(uri)
- return open_server(uri, config, false)
- end
- raise DRbBadURI, 'can\'t parse uri:' + uri
- end
- module_function :open_server
-
- # Parse +uri+ into a [uri, option] pair.
- #
- # The DRbProtocol module asks each registered protocol in turn to
- # try to parse the URI. Each protocol signals that it does not handle that
- # URI by raising a DRbBadScheme error. If no protocol recognises the
- # URI, then a DRbBadURI error is raised.
- def uri_option(uri, config, first=true)
- @protocol.each do |prot|
- begin
- uri, opt = prot.uri_option(uri, config)
- # opt = nil if opt == ''
- return uri, opt
- rescue DRbBadScheme
- end
- end
- if first && (config[:auto_load] != false)
- auto_load(uri)
- return uri_option(uri, config, false)
- end
- raise DRbBadURI, 'can\'t parse uri:' + uri
- end
- module_function :uri_option
-
- def auto_load(uri) # :nodoc:
- if /\Adrb([a-z0-9]+):/ =~ uri
- require("drb/#{$1}") rescue nil
- end
- end
- module_function :auto_load
- end
-
- # The default drb protocol which communicates over a TCP socket.
- #
- # The DRb TCP protocol URI looks like:
- # <code>druby://<host>:<port>?<option></code>. The option is optional.
-
- class DRbTCPSocket
- # :stopdoc:
- private
- def self.parse_uri(uri)
- if /\Adruby:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
- host = $1
- port = $2.to_i
- option = $4
- [host, port, option]
- else
- raise(DRbBadScheme, uri) unless uri.start_with?('druby:')
- raise(DRbBadURI, 'can\'t parse uri:' + uri)
- end
- end
-
- public
-
- # Open a client connection to +uri+ (DRb URI string) using configuration
- # +config+.
- #
- # This can raise DRb::DRbBadScheme or DRb::DRbBadURI if +uri+ is not for a
- # recognized protocol. See DRb::DRbServer.new for information on built-in
- # URI protocols.
- def self.open(uri, config)
- host, port, = parse_uri(uri)
- soc = TCPSocket.open(host, port)
- self.new(uri, soc, config)
- end
-
- # Returns the hostname of this server
- def self.getservername
- host = Socket::gethostname
- begin
- Socket::getaddrinfo(host, nil,
- Socket::AF_UNSPEC,
- Socket::SOCK_STREAM,
- 0,
- Socket::AI_PASSIVE)[0][3]
- rescue
- 'localhost'
- end
- end
-
- # For the families available for +host+, returns a TCPServer on +port+.
- # If +port+ is 0 the first available port is used. IPv4 servers are
- # preferred over IPv6 servers.
- def self.open_server_inaddr_any(host, port)
- infos = Socket::getaddrinfo(host, nil,
- Socket::AF_UNSPEC,
- Socket::SOCK_STREAM,
- 0,
- Socket::AI_PASSIVE)
- families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
- return TCPServer.open('0.0.0.0', port) if families.has_key?('AF_INET')
- return TCPServer.open('::', port) if families.has_key?('AF_INET6')
- return TCPServer.open(port)
- # :stopdoc:
- end
-
- # Open a server listening for connections at +uri+ using
- # configuration +config+.
- def self.open_server(uri, config)
- uri = 'druby://:0' unless uri
- host, port, _ = parse_uri(uri)
- config = {:tcp_original_host => host}.update(config)
- if host.size == 0
- host = getservername
- soc = open_server_inaddr_any(host, port)
- else
- soc = TCPServer.open(host, port)
- end
- port = soc.addr[1] if port == 0
- config[:tcp_port] = port
- uri = "druby://#{host}:#{port}"
- self.new(uri, soc, config)
- end
-
- # Parse +uri+ into a [uri, option] pair.
- def self.uri_option(uri, config)
- host, port, option = parse_uri(uri)
- return "druby://#{host}:#{port}", option
- end
-
- # Create a new DRbTCPSocket instance.
- #
- # +uri+ is the URI we are connected to.
- # +soc+ is the tcp socket we are bound to. +config+ is our
- # configuration.
- def initialize(uri, soc, config={})
- @uri = uri
- @socket = soc
- @config = config
- @acl = config[:tcp_acl]
- @msg = DRbMessage.new(config)
- set_sockopt(@socket)
- @shutdown_pipe_r, @shutdown_pipe_w = IO.pipe
- end
-
- # Get the URI that we are connected to.
- attr_reader :uri
-
- # Get the address of our TCP peer (the other end of the socket
- # we are bound to.
- def peeraddr
- @socket.peeraddr
- end
-
- # Get the socket.
- def stream; @socket; end
-
- # On the client side, send a request to the server.
- def send_request(ref, msg_id, arg, b)
- @msg.send_request(stream, ref, msg_id, arg, b)
- end
-
- # On the server side, receive a request from the client.
- def recv_request
- @msg.recv_request(stream)
- end
-
- # On the server side, send a reply to the client.
- def send_reply(succ, result)
- @msg.send_reply(stream, succ, result)
- end
-
- # On the client side, receive a reply from the server.
- def recv_reply
- @msg.recv_reply(stream)
- end
-
- public
-
- # Close the connection.
- #
- # If this is an instance returned by #open_server, then this stops
- # listening for new connections altogether. If this is an instance
- # returned by #open or by #accept, then it closes this particular
- # client-server session.
- def close
- shutdown
- if @socket
- @socket.close
- @socket = nil
- end
- close_shutdown_pipe
- end
-
- def close_shutdown_pipe
- @shutdown_pipe_w.close
- @shutdown_pipe_r.close
- end
- private :close_shutdown_pipe
-
- # On the server side, for an instance returned by #open_server,
- # accept a client connection and return a new instance to handle
- # the server's side of this client-server session.
- def accept
- while true
- s = accept_or_shutdown
- return nil unless s
- break if (@acl ? @acl.allow_socket?(s) : true)
- s.close
- end
- if @config[:tcp_original_host].to_s.size == 0
- uri = "druby://#{s.addr[3]}:#{@config[:tcp_port]}"
- else
- uri = @uri
- end
- self.class.new(uri, s, @config)
- end
-
- def accept_or_shutdown
- readables, = IO.select([@socket, @shutdown_pipe_r])
- if readables.include? @shutdown_pipe_r
- return nil
- end
- @socket.accept
- end
- private :accept_or_shutdown
-
- # Graceful shutdown
- def shutdown
- @shutdown_pipe_w.close
- end
-
- # Check to see if this connection is alive.
- def alive?
- return false unless @socket
- if @socket.to_io.wait_readable(0)
- close
- return false
- end
- true
- end
-
- def set_sockopt(soc) # :nodoc:
- soc.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
- rescue IOError, Errno::ECONNRESET, Errno::EINVAL
- # closed/shutdown socket, ignore error
- end
- end
-
- module DRbProtocol
- @protocol = [DRbTCPSocket] # default
- end
-
- class DRbURIOption # :nodoc: I don't understand the purpose of this class...
- def initialize(option)
- @option = option.to_s
- end
- attr_reader :option
- def to_s; @option; end
-
- def ==(other)
- return false unless DRbURIOption === other
- @option == other.option
- end
-
- def hash
- @option.hash
- end
-
- alias eql? ==
- end
-
- # Object wrapping a reference to a remote drb object.
- #
- # Method calls on this object are relayed to the remote
- # object that this object is a stub for.
- class DRbObject
-
- # Unmarshall a marshalled DRbObject.
- #
- # If the referenced object is located within the local server, then
- # the object itself is returned. Otherwise, a new DRbObject is
- # created to act as a stub for the remote referenced object.
- def self._load(s)
- uri, ref = Marshal.load(s)
-
- if DRb.here?(uri)
- obj = DRb.to_obj(ref)
- return obj
- end
-
- self.new_with(uri, ref)
- end
-
- # Creates a DRb::DRbObject given the reference information to the remote
- # host +uri+ and object +ref+.
-
- def self.new_with(uri, ref)
- it = self.allocate
- it.instance_variable_set(:@uri, uri)
- it.instance_variable_set(:@ref, ref)
- it
- end
-
- # Create a new DRbObject from a URI alone.
- def self.new_with_uri(uri)
- self.new(nil, uri)
- end
-
- # Marshall this object.
- #
- # The URI and ref of the object are marshalled.
- def _dump(lv)
- Marshal.dump([@uri, @ref])
- end
-
- # Create a new remote object stub.
- #
- # +obj+ is the (local) object we want to create a stub for. Normally
- # this is +nil+. +uri+ is the URI of the remote object that this
- # will be a stub for.
- def initialize(obj, uri=nil)
- @uri = nil
- @ref = nil
- case obj
- when Object
- is_nil = obj.nil?
- when BasicObject
- is_nil = false
- end
-
- if is_nil
- return if uri.nil?
- @uri, option = DRbProtocol.uri_option(uri, DRb.config)
- @ref = DRbURIOption.new(option) unless option.nil?
- else
- @uri = uri ? uri : (DRb.uri rescue nil)
- @ref = obj ? DRb.to_id(obj) : nil
- end
- end
-
- # Get the URI of the remote object.
- def __drburi
- @uri
- end
-
- # Get the reference of the object, if local.
- def __drbref
- @ref
- end
-
- undef :to_s
- undef :to_a if respond_to?(:to_a)
-
- # Routes respond_to? to the referenced remote object.
- def respond_to?(msg_id, priv=false)
- case msg_id
- when :_dump
- true
- when :marshal_dump
- false
- else
- method_missing(:respond_to?, msg_id, priv)
- end
- end
-
- # Routes method calls to the referenced remote object.
- ruby2_keywords def method_missing(msg_id, *a, &b)
- if DRb.here?(@uri)
- obj = DRb.to_obj(@ref)
- DRb.current_server.check_insecure_method(obj, msg_id)
- return obj.__send__(msg_id, *a, &b)
- end
-
- succ, result = self.class.with_friend(@uri) do
- DRbConn.open(@uri) do |conn|
- conn.send_message(self, msg_id, a, b)
- end
- end
-
- if succ
- return result
- elsif DRbUnknown === result
- raise result
- else
- bt = self.class.prepare_backtrace(@uri, result)
- result.set_backtrace(bt + caller)
- raise result
- end
- end
-
- # Given the +uri+ of another host executes the block provided.
- def self.with_friend(uri) # :nodoc:
- friend = DRb.fetch_server(uri)
- return yield() unless friend
-
- save = Thread.current['DRb']
- Thread.current['DRb'] = { 'server' => friend }
- return yield
- ensure
- Thread.current['DRb'] = save if friend
- end
-
- # Returns a modified backtrace from +result+ with the +uri+ where each call
- # in the backtrace came from.
- def self.prepare_backtrace(uri, result) # :nodoc:
- prefix = "(#{uri}) "
- bt = []
- result.backtrace.each do |x|
- break if /`__send__'$/ =~ x
- if /\A\(druby:\/\// =~ x
- bt.push(x)
- else
- bt.push(prefix + x)
- end
- end
- bt
- end
-
- def pretty_print(q) # :nodoc:
- q.pp_object(self)
- end
-
- def pretty_print_cycle(q) # :nodoc:
- q.object_address_group(self) {
- q.breakable
- q.text '...'
- }
- end
- end
-
- class ThreadObject
- include MonitorMixin
-
- def initialize(&blk)
- super()
- @wait_ev = new_cond
- @req_ev = new_cond
- @res_ev = new_cond
- @status = :wait
- @req = nil
- @res = nil
- @thread = Thread.new(self, &blk)
- end
-
- def alive?
- @thread.alive?
- end
-
- def kill
- @thread.kill
- @thread.join
- end
-
- def method_missing(msg, *arg, &blk)
- synchronize do
- @wait_ev.wait_until { @status == :wait }
- @req = [msg] + arg
- @status = :req
- @req_ev.broadcast
- @res_ev.wait_until { @status == :res }
- value = @res
- @req = @res = nil
- @status = :wait
- @wait_ev.broadcast
- return value
- end
- end
-
- def _execute()
- synchronize do
- @req_ev.wait_until { @status == :req }
- @res = yield(@req)
- @status = :res
- @res_ev.signal
- end
- end
- end
-
- # Class handling the connection between a DRbObject and the
- # server the real object lives on.
- #
- # This class maintains a pool of connections, to reduce the
- # overhead of starting and closing down connections for each
- # method call.
- #
- # This class is used internally by DRbObject. The user does
- # not normally need to deal with it directly.
- class DRbConn
- POOL_SIZE = 16 # :nodoc:
-
- def self.make_pool
- ThreadObject.new do |queue|
- pool = []
- while true
- queue._execute do |message|
- case(message[0])
- when :take then
- remote_uri = message[1]
- conn = nil
- new_pool = []
- pool.each do |c|
- if conn.nil? and c.uri == remote_uri
- conn = c if c.alive?
- else
- new_pool.push c
- end
- end
- pool = new_pool
- conn
- when :store then
- conn = message[1]
- pool.unshift(conn)
- pool.pop.close while pool.size > POOL_SIZE
- conn
- else
- nil
- end
- end
- end
- end
- end
- @pool_proxy = nil
-
- def self.stop_pool
- @pool_proxy&.kill
- @pool_proxy = nil
- end
-
- def self.open(remote_uri) # :nodoc:
- begin
- @pool_proxy = make_pool unless @pool_proxy&.alive?
-
- conn = @pool_proxy.take(remote_uri)
- conn = self.new(remote_uri) unless conn
- succ, result = yield(conn)
- return succ, result
-
- ensure
- if conn
- if succ
- @pool_proxy.store(conn)
- else
- conn.close
- end
- end
- end
- end
-
- def initialize(remote_uri) # :nodoc:
- @uri = remote_uri
- @protocol = DRbProtocol.open(remote_uri, DRb.config)
- end
- attr_reader :uri # :nodoc:
-
- def send_message(ref, msg_id, arg, block) # :nodoc:
- @protocol.send_request(ref, msg_id, arg, block)
- @protocol.recv_reply
- end
-
- def close # :nodoc:
- @protocol.close
- @protocol = nil
- end
-
- def alive? # :nodoc:
- return false unless @protocol
- @protocol.alive?
- end
- end
-
- # Class representing a drb server instance.
- #
- # A DRbServer must be running in the local process before any incoming
- # dRuby calls can be accepted, or any local objects can be passed as
- # dRuby references to remote processes, even if those local objects are
- # never actually called remotely. You do not need to start a DRbServer
- # in the local process if you are only making outgoing dRuby calls
- # passing marshalled parameters.
- #
- # Unless multiple servers are being used, the local DRbServer is normally
- # started by calling DRb.start_service.
- class DRbServer
- @@acl = nil
- @@idconv = DRbIdConv.new
- @@secondary_server = nil
- @@argc_limit = 256
- @@load_limit = 0xffffffff
- @@verbose = false
-
- # Set the default value for the :argc_limit option.
- #
- # See #new(). The initial default value is 256.
- def self.default_argc_limit(argc)
- @@argc_limit = argc
- end
-
- # Set the default value for the :load_limit option.
- #
- # See #new(). The initial default value is 25 MB.
- def self.default_load_limit(sz)
- @@load_limit = sz
- end
-
- # Set the default access control list to +acl+. The default ACL is +nil+.
- #
- # See also DRb::ACL and #new()
- def self.default_acl(acl)
- @@acl = acl
- end
-
- # Set the default value for the :id_conv option.
- #
- # See #new(). The initial default value is a DRbIdConv instance.
- def self.default_id_conv(idconv)
- @@idconv = idconv
- end
-
- # Set the default value of the :verbose option.
- #
- # See #new(). The initial default value is false.
- def self.verbose=(on)
- @@verbose = on
- end
-
- # Get the default value of the :verbose option.
- def self.verbose
- @@verbose
- end
-
- def self.make_config(hash={}) # :nodoc:
- default_config = {
- :idconv => @@idconv,
- :verbose => @@verbose,
- :tcp_acl => @@acl,
- :load_limit => @@load_limit,
- :argc_limit => @@argc_limit,
- }
- default_config.update(hash)
- end
-
- # Create a new DRbServer instance.
- #
- # +uri+ is the URI to bind to. This is normally of the form
- # 'druby://<hostname>:<port>' where <hostname> is a hostname of
- # the local machine. If nil, then the system's default hostname
- # will be bound to, on a port selected by the system; these value
- # can be retrieved from the +uri+ attribute. 'druby:' specifies
- # the default dRuby transport protocol: another protocol, such
- # as 'drbunix:', can be specified instead.
- #
- # +front+ is the front object for the server, that is, the object
- # to which remote method calls on the server will be passed. If
- # nil, then the server will not accept remote method calls.
- #
- # If +config_or_acl+ is a hash, it is the configuration to
- # use for this server. The following options are recognised:
- #
- # :idconv :: an id-to-object conversion object. This defaults
- # to an instance of the class DRb::DRbIdConv.
- # :verbose :: if true, all unsuccessful remote calls on objects
- # in the server will be logged to $stdout. false
- # by default.
- # :tcp_acl :: the access control list for this server. See
- # the ACL class from the main dRuby distribution.
- # :load_limit :: the maximum message size in bytes accepted by
- # the server. Defaults to 25 MB (26214400).
- # :argc_limit :: the maximum number of arguments to a remote
- # method accepted by the server. Defaults to
- # 256.
- # The default values of these options can be modified on
- # a class-wide basis by the class methods #default_argc_limit,
- # #default_load_limit, #default_acl, #default_id_conv,
- # and #verbose=
- #
- # If +config_or_acl+ is not a hash, but is not nil, it is
- # assumed to be the access control list for this server.
- # See the :tcp_acl option for more details.
- #
- # If no other server is currently set as the primary server,
- # this will become the primary server.
- #
- # The server will immediately start running in its own thread.
- def initialize(uri=nil, front=nil, config_or_acl=nil)
- if Hash === config_or_acl
- config = config_or_acl.dup
- else
- acl = config_or_acl || @@acl
- config = {
- :tcp_acl => acl
- }
- end
-
- @config = self.class.make_config(config)
-
- @protocol = DRbProtocol.open_server(uri, @config)
- @uri = @protocol.uri
- @exported_uri = [@uri]
-
- @front = front
- @idconv = @config[:idconv]
-
- @grp = ThreadGroup.new
- @thread = run
-
- DRb.regist_server(self)
- end
-
- # The URI of this DRbServer.
- attr_reader :uri
-
- # The main thread of this DRbServer.
- #
- # This is the thread that listens for and accepts connections
- # from clients, not that handles each client's request-response
- # session.
- attr_reader :thread
-
- # The front object of the DRbServer.
- #
- # This object receives remote method calls made on the server's
- # URI alone, with an object id.
- attr_reader :front
-
- # The configuration of this DRbServer
- attr_reader :config
-
- # Set whether to operate in verbose mode.
- #
- # In verbose mode, failed calls are logged to stdout.
- def verbose=(v); @config[:verbose]=v; end
-
- # Get whether the server is in verbose mode.
- #
- # In verbose mode, failed calls are logged to stdout.
- def verbose; @config[:verbose]; end
-
- # Is this server alive?
- def alive?
- @thread.alive?
- end
-
- # Is +uri+ the URI for this server?
- def here?(uri)
- @exported_uri.include?(uri)
- end
-
- # Stop this server.
- def stop_service
- DRb.remove_server(self)
- if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
- Thread.current['DRb']['stop_service'] = true
- else
- shutdown
- end
- end
-
- # Convert a dRuby reference to the local object it refers to.
- def to_obj(ref)
- return front if ref.nil?
- return front[ref.to_s] if DRbURIOption === ref
- @idconv.to_obj(ref)
- end
-
- # Convert a local object to a dRuby reference.
- def to_id(obj)
- return nil if obj.__id__ == front.__id__
- @idconv.to_id(obj)
- end
-
- private
-
- def shutdown
- current = Thread.current
- if @protocol.respond_to? :shutdown
- @protocol.shutdown
- else
- [@thread, *@grp.list].each { |thread|
- thread.kill unless thread == current # xxx: Thread#kill
- }
- end
- @thread.join unless @thread == current
- end
-
- ##
- # Starts the DRb main loop in a new thread.
-
- def run
- Thread.start do
- begin
- while main_loop
- end
- ensure
- @protocol.close if @protocol
- end
- end
- end
-
- # List of insecure methods.
- #
- # These methods are not callable via dRuby.
- INSECURE_METHOD = [
- :__send__
- ]
-
- # Has a method been included in the list of insecure methods?
- def insecure_method?(msg_id)
- INSECURE_METHOD.include?(msg_id)
- end
-
- # Coerce an object to a string, providing our own representation if
- # to_s is not defined for the object.
- def any_to_s(obj)
- "#{obj}:#{obj.class}"
- rescue
- Kernel.instance_method(:to_s).bind_call(obj)
- end
-
- # Check that a method is callable via dRuby.
- #
- # +obj+ is the object we want to invoke the method on. +msg_id+ is the
- # method name, as a Symbol.
- #
- # If the method is an insecure method (see #insecure_method?) a
- # SecurityError is thrown. If the method is private or undefined,
- # a NameError is thrown.
- def check_insecure_method(obj, msg_id)
- return true if Proc === obj && msg_id == :__drb_yield
- raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
- raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
-
- case obj
- when Object
- if obj.private_methods.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
- elsif obj.protected_methods.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
- else
- true
- end
- else
- if Kernel.instance_method(:private_methods).bind(obj).call.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
- elsif Kernel.instance_method(:protected_methods).bind(obj).call.include?(msg_id)
- desc = any_to_s(obj)
- raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
- else
- true
- end
- end
- end
- public :check_insecure_method
-
- class InvokeMethod # :nodoc:
- def initialize(drb_server, client)
- @drb_server = drb_server
- @client = client
- end
-
- def perform
- begin
- setup_message
- ensure
- @result = nil
- @succ = false
- end
-
- if @block
- @result = perform_with_block
- else
- @result = perform_without_block
- end
- @succ = true
- case @result
- when Array
- if @msg_id == :to_ary
- @result = DRbArray.new(@result)
- end
- end
- return @succ, @result
- rescue NoMemoryError, SystemExit, SystemStackError, SecurityError
- raise
- rescue Exception
- @result = $!
- return @succ, @result
- end
-
- private
- def init_with_client
- obj, msg, argv, block = @client.recv_request
- @obj = obj
- @msg_id = msg.intern
- @argv = argv
- @block = block
- end
-
- def check_insecure_method
- @drb_server.check_insecure_method(@obj, @msg_id)
- end
-
- def setup_message
- init_with_client
- check_insecure_method
- end
-
- def perform_without_block
- if Proc === @obj && @msg_id == :__drb_yield
- if @argv.size == 1
- ary = @argv
- else
- ary = [@argv]
- end
- ary.collect(&@obj)[0]
- else
- @obj.__send__(@msg_id, *@argv)
- end
- end
-
- end
-
- require_relative 'invokemethod'
- class InvokeMethod
- include InvokeMethod18Mixin
- end
-
- def error_print(exception)
- exception.backtrace.inject(true) do |first, x|
- if first
- $stderr.puts "#{x}: #{exception} (#{exception.class})"
- else
- $stderr.puts "\tfrom #{x}"
- end
- false
- end
- end
-
- # The main loop performed by a DRbServer's internal thread.
- #
- # Accepts a connection from a client, and starts up its own
- # thread to handle it. This thread loops, receiving requests
- # from the client, invoking them on a local object, and
- # returning responses, until the client closes the connection
- # or a local method call fails.
- def main_loop
- client0 = @protocol.accept
- return nil if !client0
- Thread.start(client0) do |client|
- @grp.add Thread.current
- Thread.current['DRb'] = { 'client' => client ,
- 'server' => self }
- DRb.mutex.synchronize do
- client_uri = client.uri
- @exported_uri << client_uri unless @exported_uri.include?(client_uri)
- end
- _last_invoke_method = nil
- loop do
- begin
- succ = false
- invoke_method = InvokeMethod.new(self, client)
- succ, result = invoke_method.perform
- error_print(result) if !succ && verbose
- unless DRbConnError === result && result.message == 'connection closed'
- client.send_reply(succ, result)
- end
- rescue Exception => e
- error_print(e) if verbose
- ensure
- _last_invoke_method = invoke_method
- client.close unless succ
- if Thread.current['DRb']['stop_service']
- shutdown
- break
- end
- break unless succ
- end
- end
- end
- end
- end
-
- @primary_server = nil
-
- # Start a dRuby server locally.
- #
- # The new dRuby server will become the primary server, even
- # if another server is currently the primary server.
- #
- # +uri+ is the URI for the server to bind to. If nil,
- # the server will bind to random port on the default local host
- # name and use the default dRuby protocol.
- #
- # +front+ is the server's front object. This may be nil.
- #
- # +config+ is the configuration for the new server. This may
- # be nil.
- #
- # See DRbServer::new.
- def start_service(uri=nil, front=nil, config=nil)
- @primary_server = DRbServer.new(uri, front, config)
- end
- module_function :start_service
-
- # The primary local dRuby server.
- #
- # This is the server created by the #start_service call.
- attr_accessor :primary_server
- module_function :primary_server=, :primary_server
-
- # Get the 'current' server.
- #
- # In the context of execution taking place within the main
- # thread of a dRuby server (typically, as a result of a remote
- # call on the server or one of its objects), the current
- # server is that server. Otherwise, the current server is
- # the primary server.
- #
- # If the above rule fails to find a server, a DRbServerNotFound
- # error is raised.
- def current_server
- drb = Thread.current['DRb']
- server = (drb && drb['server']) ? drb['server'] : @primary_server
- raise DRbServerNotFound unless server
- return server
- end
- module_function :current_server
-
- # Stop the local dRuby server.
- #
- # This operates on the primary server. If there is no primary
- # server currently running, it is a noop.
- def stop_service
- @primary_server.stop_service if @primary_server
- @primary_server = nil
- end
- module_function :stop_service
-
- # Get the URI defining the local dRuby space.
- #
- # This is the URI of the current server. See #current_server.
- def uri
- drb = Thread.current['DRb']
- client = (drb && drb['client'])
- if client
- uri = client.uri
- return uri if uri
- end
- current_server.uri
- end
- module_function :uri
-
- # Is +uri+ the URI for the current local server?
- def here?(uri)
- current_server.here?(uri) rescue false
- # (current_server.uri rescue nil) == uri
- end
- module_function :here?
-
- # Get the configuration of the current server.
- #
- # If there is no current server, this returns the default configuration.
- # See #current_server and DRbServer::make_config.
- def config
- current_server.config
- rescue
- DRbServer.make_config
- end
- module_function :config
-
- # Get the front object of the current server.
- #
- # This raises a DRbServerNotFound error if there is no current server.
- # See #current_server.
- def front
- current_server.front
- end
- module_function :front
-
- # Convert a reference into an object using the current server.
- #
- # This raises a DRbServerNotFound error if there is no current server.
- # See #current_server.
- def to_obj(ref)
- current_server.to_obj(ref)
- end
-
- # Get a reference id for an object using the current server.
- #
- # This raises a DRbServerNotFound error if there is no current server.
- # See #current_server.
- def to_id(obj)
- current_server.to_id(obj)
- end
- module_function :to_id
- module_function :to_obj
-
- # Get the thread of the primary server.
- #
- # This returns nil if there is no primary server. See #primary_server.
- def thread
- @primary_server ? @primary_server.thread : nil
- end
- module_function :thread
-
- # Set the default id conversion object.
- #
- # This is expected to be an instance such as DRb::DRbIdConv that responds to
- # #to_id and #to_obj that can convert objects to and from DRb references.
- #
- # See DRbServer#default_id_conv.
- def install_id_conv(idconv)
- DRbServer.default_id_conv(idconv)
- end
- module_function :install_id_conv
-
- # Set the default ACL to +acl+.
- #
- # See DRb::DRbServer.default_acl.
- def install_acl(acl)
- DRbServer.default_acl(acl)
- end
- module_function :install_acl
-
- @mutex = Thread::Mutex.new
- def mutex # :nodoc:
- @mutex
- end
- module_function :mutex
-
- @server = {}
- # Registers +server+ with DRb.
- #
- # This is called when a new DRb::DRbServer is created.
- #
- # If there is no primary server then +server+ becomes the primary server.
- #
- # Example:
- #
- # require 'drb'
- #
- # s = DRb::DRbServer.new # automatically calls regist_server
- # DRb.fetch_server s.uri #=> #<DRb::DRbServer:0x...>
- def regist_server(server)
- @server[server.uri] = server
- mutex.synchronize do
- @primary_server = server unless @primary_server
- end
- end
- module_function :regist_server
-
- # Removes +server+ from the list of registered servers.
- def remove_server(server)
- @server.delete(server.uri)
- mutex.synchronize do
- if @primary_server == server
- @primary_server = nil
- end
- end
- end
- module_function :remove_server
-
- # Retrieves the server with the given +uri+.
- #
- # See also regist_server and remove_server.
- def fetch_server(uri)
- @server[uri]
- end
- module_function :fetch_server
-end
-
-# :stopdoc:
-DRbObject = DRb::DRbObject
-DRbUndumped = DRb::DRbUndumped
-DRbIdConv = DRb::DRbIdConv
diff --git a/lib/drb/eq.rb b/lib/drb/eq.rb
deleted file mode 100644
index 15ca5cae42..0000000000
--- a/lib/drb/eq.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: false
-module DRb
- class DRbObject # :nodoc:
- def ==(other)
- return false unless DRbObject === other
- (@ref == other.__drbref) && (@uri == other.__drburi)
- end
-
- def hash
- [@uri, @ref].hash
- end
-
- alias eql? ==
- end
-end
diff --git a/lib/drb/extserv.rb b/lib/drb/extserv.rb
deleted file mode 100644
index 9523fe84e3..0000000000
--- a/lib/drb/extserv.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: false
-=begin
- external service
- Copyright (c) 2000,2002 Masatoshi SEKI
-=end
-
-require_relative '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.register(name, DRbObject.new(self, @server.uri))
- end
- end
- attr_reader :server
-
- def front
- DRbObject.new(nil, @server.uri)
- end
-
- def stop_service
- synchronize do
- @invoker.unregister(@name)
- server = @server
- @server = nil
- server.stop_service
- true
- end
- end
-
- def alive?
- @server ? @server.alive? : false
- end
- end
-end
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
deleted file mode 100644
index 9333a108e5..0000000000
--- a/lib/drb/extservm.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# frozen_string_literal: false
-=begin
- external service manager
- Copyright (c) 2000 Masatoshi SEKI
-=end
-
-require_relative 'drb'
-require 'monitor'
-
-module DRb
- class ExtServManager
- include DRbUndumped
- include MonitorMixin
-
- @@command = {}
-
- def self.command
- @@command
- end
-
- def self.command=(cmd)
- @@command = cmd
- end
-
- def initialize
- super()
- @cond = new_cond
- @servers = {}
- @waiting = []
- @queue = Thread::Queue.new
- @thread = invoke_thread
- @uri = nil
- end
- attr_accessor :uri
-
- def service(name)
- synchronize do
- while true
- server = @servers[name]
- return server if server && server.alive? # server may be `false'
- invoke_service(name)
- @cond.wait
- end
- end
- end
-
- def register(name, ro)
- synchronize do
- @servers[name] = ro
- @cond.signal
- end
- self
- end
- alias regist register
-
- def unregister(name)
- synchronize do
- @servers.delete(name)
- end
- end
- alias unregist unregister
-
- private
- def invoke_thread
- Thread.new do
- while name = @queue.pop
- invoke_service_command(name, @@command[name])
- end
- end
- end
-
- def invoke_service(name)
- @queue.push(name)
- end
-
- def invoke_service_command(name, command)
- raise "invalid command. name: #{name}" unless command
- synchronize do
- return if @servers.include?(name)
- @servers[name] = false
- end
- uri = @uri || DRb.uri
- if command.respond_to? :to_ary
- command = command.to_ary + [uri, name]
- pid = spawn(*command)
- else
- pid = spawn("#{command} #{uri} #{name}")
- end
- th = Process.detach(pid)
- th[:drb_service] = name
- th
- end
- end
-end
diff --git a/lib/drb/gw.rb b/lib/drb/gw.rb
deleted file mode 100644
index 65a525476e..0000000000
--- a/lib/drb/gw.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-# frozen_string_literal: false
-require_relative 'drb'
-require 'monitor'
-
-module DRb
-
- # Gateway id conversion forms a gateway between different DRb protocols or
- # networks.
- #
- # The gateway needs to install this id conversion and create servers for
- # each of the protocols or networks it will be a gateway between. It then
- # needs to create a server that attaches to each of these networks. For
- # example:
- #
- # require 'drb/drb'
- # require 'drb/unix'
- # require 'drb/gw'
- #
- # DRb.install_id_conv DRb::GWIdConv.new
- # gw = DRb::GW.new
- # s1 = DRb::DRbServer.new 'drbunix:/path/to/gateway', gw
- # s2 = DRb::DRbServer.new 'druby://example:10000', gw
- #
- # s1.thread.join
- # s2.thread.join
- #
- # Each client must register services with the gateway, for example:
- #
- # DRb.start_service 'drbunix:', nil # an anonymous server
- # gw = DRbObject.new nil, 'drbunix:/path/to/gateway'
- # gw[:unix] = some_service
- # DRb.thread.join
-
- class GWIdConv < DRbIdConv
- def to_obj(ref) # :nodoc:
- if Array === ref && ref[0] == :DRbObject
- return DRbObject.new_with(ref[1], ref[2])
- end
- super(ref)
- end
- end
-
- # The GW provides a synchronized store for participants in the gateway to
- # communicate.
-
- class GW
- include MonitorMixin
-
- # Creates a new GW
-
- def initialize
- super()
- @hash = {}
- end
-
- # Retrieves +key+ from the GW
-
- def [](key)
- synchronize do
- @hash[key]
- end
- end
-
- # Stores value +v+ at +key+ in the GW
-
- def []=(key, v)
- synchronize do
- @hash[key] = v
- end
- end
- end
-
- class DRbObject # :nodoc:
- def self._load(s)
- uri, ref = Marshal.load(s)
- if DRb.uri == uri
- return ref ? DRb.to_obj(ref) : DRb.front
- end
-
- self.new_with(DRb.uri, [:DRbObject, uri, ref])
- end
-
- def _dump(lv)
- if DRb.uri == @uri
- if Array === @ref && @ref[0] == :DRbObject
- Marshal.dump([@ref[1], @ref[2]])
- else
- Marshal.dump([@uri, @ref]) # ??
- end
- else
- Marshal.dump([DRb.uri, [:DRbObject, @uri, @ref]])
- end
- end
- end
-end
-
-=begin
-DRb.install_id_conv(DRb::GWIdConv.new)
-
-front = DRb::GW.new
-
-s1 = DRb::DRbServer.new('drbunix:/tmp/gw_b_a', front)
-s2 = DRb::DRbServer.new('drbunix:/tmp/gw_b_c', front)
-
-s1.thread.join
-s2.thread.join
-=end
-
-=begin
-# foo.rb
-
-require 'drb/drb'
-
-class Foo
- include DRbUndumped
- def initialize(name, peer=nil)
- @name = name
- @peer = peer
- end
-
- def ping(obj)
- puts "#{@name}: ping: #{obj.inspect}"
- @peer.ping(self) if @peer
- end
-end
-=end
-
-=begin
-# gw_a.rb
-require 'drb/unix'
-require 'foo'
-
-obj = Foo.new('a')
-DRb.start_service("drbunix:/tmp/gw_a", obj)
-
-robj = DRbObject.new_with_uri('drbunix:/tmp/gw_b_a')
-robj[:a] = obj
-
-DRb.thread.join
-=end
-
-=begin
-# gw_c.rb
-require 'drb/unix'
-require 'foo'
-
-foo = Foo.new('c', nil)
-
-DRb.start_service("drbunix:/tmp/gw_c", nil)
-
-robj = DRbObject.new_with_uri("drbunix:/tmp/gw_b_c")
-
-puts "c->b"
-a = robj[:a]
-sleep 2
-
-a.ping(foo)
-
-DRb.thread.join
-=end
-
diff --git a/lib/drb/invokemethod.rb b/lib/drb/invokemethod.rb
deleted file mode 100644
index 0fae6d52b6..0000000000
--- a/lib/drb/invokemethod.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: false
-# for ruby-1.8.0
-
-module DRb # :nodoc: all
- class DRbServer
- module InvokeMethod18Mixin
- def block_yield(x)
- if x.size == 1 && x[0].class == Array
- x[0] = DRbArray.new(x[0])
- end
- @block.call(*x)
- end
-
- def perform_with_block
- @obj.__send__(@msg_id, *@argv) do |*x|
- jump_error = nil
- begin
- block_value = block_yield(x)
- rescue LocalJumpError
- jump_error = $!
- end
- if jump_error
- case jump_error.reason
- when :break
- break(jump_error.exit_value)
- else
- raise jump_error
- end
- end
- block_value
- end
- end
- end
- end
-end
diff --git a/lib/drb/observer.rb b/lib/drb/observer.rb
deleted file mode 100644
index 0fb7301edf..0000000000
--- a/lib/drb/observer.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: false
-require 'observer'
-
-module DRb
- # The Observable module extended to DRb. See Observable for details.
- module DRbObservable
- include Observable
-
- # Notifies observers of a change in state. See also
- # Observable#notify_observers
- def notify_observers(*arg)
- if defined? @observer_state and @observer_state
- if defined? @observer_peers
- @observer_peers.each do |observer, method|
- begin
- observer.__send__(method, *arg)
- rescue
- delete_observer(observer)
- end
- end
- end
- @observer_state = false
- end
- end
- end
-end
diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb
deleted file mode 100644
index 54ab1ef395..0000000000
--- a/lib/drb/ssl.rb
+++ /dev/null
@@ -1,344 +0,0 @@
-# frozen_string_literal: false
-require 'socket'
-require 'openssl'
-require_relative 'drb'
-require 'singleton'
-
-module DRb
-
- # The protocol for DRb over an SSL socket
- #
- # The URI for a DRb socket over SSL is:
- # <code>drbssl://<host>:<port>?<option></code>. The option is optional
- class DRbSSLSocket < DRbTCPSocket
-
- # SSLConfig handles the needed SSL information for establishing a
- # DRbSSLSocket connection, including generating the X509 / RSA pair.
- #
- # An instance of this config can be passed to DRbSSLSocket.new,
- # DRbSSLSocket.open and DRbSSLSocket.open_server
- #
- # See DRb::DRbSSLSocket::SSLConfig.new for more details
- class SSLConfig
-
- # Default values for a SSLConfig instance.
- #
- # See DRb::DRbSSLSocket::SSLConfig.new for more details
- DEFAULT = {
- :SSLCertificate => nil,
- :SSLPrivateKey => nil,
- :SSLClientCA => nil,
- :SSLCACertificatePath => nil,
- :SSLCACertificateFile => nil,
- :SSLTmpDhCallback => nil,
- :SSLVerifyMode => ::OpenSSL::SSL::VERIFY_NONE,
- :SSLVerifyDepth => nil,
- :SSLVerifyCallback => nil, # custom verification
- :SSLCertificateStore => nil,
- # Must specify if you use auto generated certificate.
- :SSLCertName => nil, # e.g. [["CN","fqdn.example.com"]]
- :SSLCertComment => "Generated by Ruby/OpenSSL"
- }
-
- # Create a new DRb::DRbSSLSocket::SSLConfig instance
- #
- # The DRb::DRbSSLSocket will take either a +config+ Hash or an instance
- # of SSLConfig, and will setup the certificate for its session for the
- # configuration. If want it to generate a generic certificate, the bare
- # minimum is to provide the :SSLCertName
- #
- # === Config options
- #
- # From +config+ Hash:
- #
- # :SSLCertificate ::
- # An instance of OpenSSL::X509::Certificate. If this is not provided,
- # then a generic X509 is generated, with a correspond :SSLPrivateKey
- #
- # :SSLPrivateKey ::
- # A private key instance, like OpenSSL::PKey::RSA. This key must be
- # the key that signed the :SSLCertificate
- #
- # :SSLClientCA ::
- # An OpenSSL::X509::Certificate, or Array of certificates that will
- # used as ClientCAs in the SSL Context
- #
- # :SSLCACertificatePath ::
- # A path to the directory of CA certificates. The certificates must
- # be in PEM format.
- #
- # :SSLCACertificateFile ::
- # A path to a CA certificate file, in PEM format.
- #
- # :SSLTmpDhCallback ::
- # A DH callback. See OpenSSL::SSL::SSLContext.tmp_dh_callback
- #
- # :SSLVerifyMode ::
- # This is the SSL verification mode. See OpenSSL::SSL::VERIFY_* for
- # available modes. The default is OpenSSL::SSL::VERIFY_NONE
- #
- # :SSLVerifyDepth ::
- # Number of CA certificates to walk, when verifying a certificate
- # chain.
- #
- # :SSLVerifyCallback ::
- # A callback to be used for additional verification. See
- # OpenSSL::SSL::SSLContext.verify_callback
- #
- # :SSLCertificateStore ::
- # A OpenSSL::X509::Store used for verification of certificates
- #
- # :SSLCertName ::
- # Issuer name for the certificate. This is required when generating
- # the certificate (if :SSLCertificate and :SSLPrivateKey were not
- # given). The value of this is to be an Array of pairs:
- #
- # [["C", "Raleigh"], ["ST","North Carolina"],
- # ["CN","fqdn.example.com"]]
- #
- # See also OpenSSL::X509::Name
- #
- # :SSLCertComment ::
- # A comment to be used for generating the certificate. The default is
- # "Generated by Ruby/OpenSSL"
- #
- #
- # === Example
- #
- # These values can be added after the fact, like a Hash.
- #
- # require 'drb/ssl'
- # c = DRb::DRbSSLSocket::SSLConfig.new {}
- # c[:SSLCertificate] =
- # OpenSSL::X509::Certificate.new(File.read('mycert.crt'))
- # c[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.read('mycert.key'))
- # c[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER
- # c[:SSLCACertificatePath] = "/etc/ssl/certs/"
- # c.setup_certificate
- #
- # or
- #
- # require 'drb/ssl'
- # c = DRb::DRbSSLSocket::SSLConfig.new({
- # :SSLCertName => [["CN" => DRb::DRbSSLSocket.getservername]]
- # })
- # c.setup_certificate
- #
- def initialize(config)
- @config = config
- @cert = config[:SSLCertificate]
- @pkey = config[:SSLPrivateKey]
- @ssl_ctx = nil
- end
-
- # A convenience method to access the values like a Hash
- def [](key);
- @config[key] || DEFAULT[key]
- end
-
- # Connect to IO +tcp+, with context of the current certificate
- # configuration
- def connect(tcp)
- ssl = ::OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
- ssl.sync = true
- ssl.connect
- ssl
- end
-
- # Accept connection to IO +tcp+, with context of the current certificate
- # configuration
- def accept(tcp)
- ssl = OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
- ssl.sync = true
- ssl.accept
- ssl
- end
-
- # Ensures that :SSLCertificate and :SSLPrivateKey have been provided
- # or that a new certificate is generated with the other parameters
- # provided.
- def setup_certificate
- if @cert && @pkey
- return
- end
-
- rsa = OpenSSL::PKey::RSA.new(2048){|p, n|
- next unless self[:verbose]
- case p
- when 0; $stderr.putc "." # BN_generate_prime
- when 1; $stderr.putc "+" # BN_generate_prime
- when 2; $stderr.putc "*" # searching good prime,
- # n = #of try,
- # but also data from BN_generate_prime
- when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
- # but also data from BN_generate_prime
- else; $stderr.putc "*" # BN_generate_prime
- end
- }
-
- cert = OpenSSL::X509::Certificate.new
- cert.version = 3
- cert.serial = 0
- name = OpenSSL::X509::Name.new(self[:SSLCertName])
- cert.subject = name
- cert.issuer = name
- cert.not_before = Time.now
- cert.not_after = Time.now + (365*24*60*60)
- cert.public_key = rsa.public_key
-
- ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
- cert.extensions = [
- ef.create_extension("basicConstraints","CA:FALSE"),
- ef.create_extension("subjectKeyIdentifier", "hash") ]
- ef.issuer_certificate = cert
- cert.add_extension(ef.create_extension("authorityKeyIdentifier",
- "keyid:always,issuer:always"))
- if comment = self[:SSLCertComment]
- cert.add_extension(ef.create_extension("nsComment", comment))
- end
- cert.sign(rsa, "SHA256")
-
- @cert = cert
- @pkey = rsa
- end
-
- # Establish the OpenSSL::SSL::SSLContext with the configuration
- # parameters provided.
- def setup_ssl_context
- ctx = ::OpenSSL::SSL::SSLContext.new
- ctx.cert = @cert
- ctx.key = @pkey
- ctx.client_ca = self[:SSLClientCA]
- ctx.ca_path = self[:SSLCACertificatePath]
- ctx.ca_file = self[:SSLCACertificateFile]
- ctx.tmp_dh_callback = self[:SSLTmpDhCallback]
- ctx.verify_mode = self[:SSLVerifyMode]
- ctx.verify_depth = self[:SSLVerifyDepth]
- ctx.verify_callback = self[:SSLVerifyCallback]
- ctx.cert_store = self[:SSLCertificateStore]
- @ssl_ctx = ctx
- end
- end
-
- # Parse the dRuby +uri+ for an SSL connection.
- #
- # Expects drbssl://...
- #
- # Raises DRbBadScheme or DRbBadURI if +uri+ is not matching or malformed
- def self.parse_uri(uri) # :nodoc:
- if /\Adrbssl:\/\/(.*?):(\d+)(\?(.*))?\z/ =~ uri
- host = $1
- port = $2.to_i
- option = $4
- [host, port, option]
- else
- raise(DRbBadScheme, uri) unless uri.start_with?('drbssl:')
- raise(DRbBadURI, 'can\'t parse uri:' + uri)
- end
- end
-
- # Return an DRb::DRbSSLSocket instance as a client-side connection,
- # with the SSL connected. This is called from DRb::start_service or while
- # connecting to a remote object:
- #
- # DRb.start_service 'drbssl://localhost:0', front, config
- #
- # +uri+ is the URI we are connected to,
- # <code>'drbssl://localhost:0'</code> above, +config+ is our
- # configuration. Either a Hash or DRb::DRbSSLSocket::SSLConfig
- def self.open(uri, config)
- host, port, = parse_uri(uri)
- soc = TCPSocket.open(host, port)
- ssl_conf = SSLConfig::new(config)
- ssl_conf.setup_ssl_context
- ssl = ssl_conf.connect(soc)
- self.new(uri, ssl, ssl_conf, true)
- end
-
- # Returns a DRb::DRbSSLSocket instance as a server-side connection, with
- # the SSL connected. This is called from DRb::start_service or while
- # connecting to a remote object:
- #
- # DRb.start_service 'drbssl://localhost:0', front, config
- #
- # +uri+ is the URI we are connected to,
- # <code>'drbssl://localhost:0'</code> above, +config+ is our
- # configuration. Either a Hash or DRb::DRbSSLSocket::SSLConfig
- def self.open_server(uri, config)
- uri = 'drbssl://:0' unless uri
- host, port, = parse_uri(uri)
- if host.size == 0
- host = getservername
- soc = open_server_inaddr_any(host, port)
- else
- soc = TCPServer.open(host, port)
- end
- port = soc.addr[1] if port == 0
- @uri = "drbssl://#{host}:#{port}"
-
- ssl_conf = SSLConfig.new(config)
- ssl_conf.setup_certificate
- ssl_conf.setup_ssl_context
- self.new(@uri, soc, ssl_conf, false)
- end
-
- # This is a convenience method to parse +uri+ and separate out any
- # additional options appended in the +uri+.
- #
- # Returns an option-less uri and the option => [uri,option]
- #
- # The +config+ is completely unused, so passing nil is sufficient.
- def self.uri_option(uri, config) # :nodoc:
- host, port, option = parse_uri(uri)
- return "drbssl://#{host}:#{port}", option
- end
-
- # Create a DRb::DRbSSLSocket instance.
- #
- # +uri+ is the URI we are connected to.
- # +soc+ is the tcp socket we are bound to.
- # +config+ is our configuration. Either a Hash or SSLConfig
- # +is_established+ is a boolean of whether +soc+ is currently established
- #
- # This is called automatically based on the DRb protocol.
- def initialize(uri, soc, config, is_established)
- @ssl = is_established ? soc : nil
- super(uri, soc.to_io, config)
- end
-
- # Returns the SSL stream
- def stream; @ssl; end # :nodoc:
-
- # Closes the SSL stream before closing the dRuby connection.
- def close # :nodoc:
- if @ssl
- @ssl.close
- @ssl = nil
- end
- super
- end
-
- def accept # :nodoc:
- begin
- while true
- soc = accept_or_shutdown
- return nil unless soc
- break if (@acl ? @acl.allow_socket?(soc) : true)
- soc.close
- end
- begin
- ssl = @config.accept(soc)
- rescue Exception
- soc.close
- raise
- end
- self.class.new(uri, ssl, @config, true)
- rescue OpenSSL::SSL::SSLError
- warn("#{$!.message} (#{$!.class})", uplevel: 0) if @config[:verbose]
- retry
- end
- end
- end
-
- DRbProtocol.add_protocol(DRbSSLSocket)
-end
diff --git a/lib/drb/timeridconv.rb b/lib/drb/timeridconv.rb
deleted file mode 100644
index 3ead98a7f2..0000000000
--- a/lib/drb/timeridconv.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-# frozen_string_literal: false
-require_relative 'drb'
-require 'monitor'
-
-module DRb
-
- # Timer id conversion keeps objects alive for a certain amount of time after
- # their last access. The default time period is 600 seconds and can be
- # changed upon initialization.
- #
- # To use TimerIdConv:
- #
- # DRb.install_id_conv TimerIdConv.new 60 # one minute
-
- class TimerIdConv < DRbIdConv
- class TimerHolder2 # :nodoc:
- include MonitorMixin
-
- class InvalidIndexError < RuntimeError; end
-
- def initialize(keeping=600)
- super()
- @sentinel = Object.new
- @gc = {}
- @renew = {}
- @keeping = keeping
- @expires = nil
- end
-
- def add(obj)
- synchronize do
- rotate
- key = obj.__id__
- @renew[key] = obj
- invoke_keeper
- return key
- end
- end
-
- def fetch(key)
- synchronize do
- rotate
- obj = peek(key)
- raise InvalidIndexError if obj == @sentinel
- @renew[key] = obj # KeepIt
- return obj
- end
- end
-
- private
- def peek(key)
- return @renew.fetch(key) { @gc.fetch(key, @sentinel) }
- end
-
- def invoke_keeper
- return if @expires
- @expires = Time.now + @keeping
- on_gc
- end
-
- def on_gc
- return unless Thread.main.alive?
- return if @expires.nil?
- Thread.new { rotate } if @expires < Time.now
- ObjectSpace.define_finalizer(Object.new) {on_gc}
- end
-
- def rotate
- synchronize do
- if @expires &.< Time.now
- @gc = @renew # GCed
- @renew = {}
- @expires = @gc.empty? ? nil : Time.now + @keeping
- end
- end
- end
- end
-
- # Creates a new TimerIdConv which will hold objects for +keeping+ seconds.
- def initialize(keeping=600)
- @holder = TimerHolder2.new(keeping)
- end
-
- def to_obj(ref) # :nodoc:
- return super if ref.nil?
- @holder.fetch(ref)
- rescue TimerHolder2::InvalidIndexError
- raise "invalid reference"
- end
-
- def to_id(obj) # :nodoc:
- return @holder.add(obj)
- end
- end
-end
-
-# DRb.install_id_conv(TimerIdConv.new)
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
deleted file mode 100644
index 1629ad3bcd..0000000000
--- a/lib/drb/unix.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-# frozen_string_literal: false
-require 'socket'
-require_relative 'drb'
-require 'tmpdir'
-
-raise(LoadError, "UNIXServer is required") unless defined?(UNIXServer)
-
-module DRb
-
- # Implements DRb over a UNIX socket
- #
- # DRb UNIX socket URIs look like <code>drbunix:<path>?<option></code>. The
- # option is optional.
-
- class DRbUNIXSocket < DRbTCPSocket
- # :stopdoc:
- def self.parse_uri(uri)
- if /\Adrbunix:(.*?)(\?(.*))?\z/ =~ uri
- filename = $1
- option = $3
- [filename, option]
- else
- raise(DRbBadScheme, uri) unless uri.start_with?('drbunix:')
- raise(DRbBadURI, 'can\'t parse uri:' + uri)
- end
- end
-
- def self.open(uri, config)
- filename, = parse_uri(uri)
- soc = UNIXSocket.open(filename)
- self.new(uri, soc, config)
- end
-
- def self.open_server(uri, config)
- filename, = parse_uri(uri)
- if filename.size == 0
- soc = temp_server
- filename = soc.path
- uri = 'drbunix:' + soc.path
- else
- soc = UNIXServer.open(filename)
- end
- owner = config[:UNIXFileOwner]
- group = config[:UNIXFileGroup]
- if owner || group
- require 'etc'
- owner = Etc.getpwnam( owner ).uid if owner
- group = Etc.getgrnam( group ).gid if group
- File.chown owner, group, filename
- end
- mode = config[:UNIXFileMode]
- File.chmod(mode, filename) if mode
-
- self.new(uri, soc, config, true)
- end
-
- def self.uri_option(uri, config)
- filename, option = parse_uri(uri)
- return "drbunix:#{filename}", option
- end
-
- def initialize(uri, soc, config={}, server_mode = false)
- super(uri, soc, config)
- set_sockopt(@socket)
- @server_mode = server_mode
- @acl = nil
- end
-
- # import from tempfile.rb
- Max_try = 10
- private
- def self.temp_server
- tmpdir = Dir::tmpdir
- n = 0
- while true
- begin
- tmpname = sprintf('%s/druby%d.%d', tmpdir, $$, n)
- lock = tmpname + '.lock'
- unless File.exist?(tmpname) or File.exist?(lock)
- Dir.mkdir(lock)
- break
- end
- rescue
- raise "cannot generate tempfile `%s'" % tmpname if n >= Max_try
- #sleep(1)
- end
- n += 1
- end
- soc = UNIXServer.new(tmpname)
- Dir.rmdir(lock)
- soc
- end
-
- public
- def close
- return unless @socket
- shutdown # DRbProtocol#shutdown
- path = @socket.path if @server_mode
- @socket.close
- File.unlink(path) if @server_mode
- @socket = nil
- close_shutdown_pipe
- end
-
- def accept
- s = accept_or_shutdown
- return nil unless s
- self.class.new(nil, s, @config)
- end
-
- def set_sockopt(soc)
- # no-op for now
- end
- end
-
- DRbProtocol.add_protocol(DRbUNIXSocket)
- # :startdoc:
-end
diff --git a/lib/drb/version.rb b/lib/drb/version.rb
deleted file mode 100644
index 10d33445b6..0000000000
--- a/lib/drb/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module DRb
- VERSION = "2.1.1"
-end
diff --git a/lib/drb/weakidconv.rb b/lib/drb/weakidconv.rb
deleted file mode 100644
index ecf0bf515f..0000000000
--- a/lib/drb/weakidconv.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: false
-require_relative 'drb'
-require 'monitor'
-
-module DRb
-
- # To use WeakIdConv:
- #
- # DRb.start_service(nil, nil, {:idconv => DRb::WeakIdConv.new})
-
- class WeakIdConv < DRbIdConv
- class WeakSet
- include MonitorMixin
- def initialize
- super()
- @immutable = {}
- @map = ObjectSpace::WeakMap.new
- end
-
- def add(obj)
- synchronize do
- begin
- @map[obj] = self
- rescue ArgumentError
- @immutable[obj.__id__] = obj
- end
- return obj.__id__
- end
- end
-
- def fetch(ref)
- synchronize do
- @immutable.fetch(ref) {
- @map.each { |key, _|
- return key if key.__id__ == ref
- }
- raise RangeError.new("invalid reference")
- }
- end
- end
- end
-
- def initialize()
- super()
- @weak_set = WeakSet.new
- end
-
- def to_obj(ref) # :nodoc:
- return super if ref.nil?
- @weak_set.fetch(ref)
- end
-
- def to_id(obj) # :nodoc:
- return @weak_set.add(obj)
- end
- end
-end
-
-# DRb.install_id_conv(WeakIdConv.new)
diff --git a/lib/erb.gemspec b/lib/erb.gemspec
deleted file mode 100644
index 94a8fd5c3e..0000000000
--- a/lib/erb.gemspec
+++ /dev/null
@@ -1,38 +0,0 @@
-begin
- require_relative 'lib/erb/version'
-rescue LoadError
- # for Ruby core repository
- require_relative 'erb/version'
-end
-
-Gem::Specification.new do |spec|
- spec.name = 'erb'
- spec.version = ERB.const_get(:VERSION, false)
- spec.authors = ['Masatoshi SEKI', 'Takashi Kokubun']
- spec.email = ['seki@ruby-lang.org', 'k0kubun@ruby-lang.org']
-
- spec.summary = %q{An easy to use but powerful templating system for Ruby.}
- spec.description = %q{An easy to use but powerful templating system for Ruby.}
- spec.homepage = 'https://github.com/ruby/erb'
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
- spec.licenses = ['Ruby', 'BSD-2-Clause']
-
- spec.metadata['homepage_uri'] = spec.homepage
- spec.metadata['source_code_uri'] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = 'libexec'
- spec.executables = ['erb']
- spec.require_paths = ['lib']
-
- if RUBY_ENGINE == 'jruby'
- spec.platform = 'java'
- else
- spec.required_ruby_version = '>= 2.7.0'
- spec.extensions = ['ext/erb/escape/extconf.rb']
- end
-
- spec.add_dependency 'cgi', '>= 0.3.3'
-end
diff --git a/lib/erb.rb b/lib/erb.rb
index 754419f819..bde90de841 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -12,395 +12,963 @@
#
# You can redistribute it and/or modify it under the same terms as Ruby.
-require 'cgi/util'
+# A NOTE ABOUT TERMS:
+#
+# Formerly: The documentation in this file used the term _template_ to refer to an ERB object.
+#
+# Now: The documentation in this file uses the term _template_
+# to refer to the string input to ERB.new.
+#
+# The reason for the change: When documenting the ERB executable erb,
+# we need a term that refers to its string input;
+# _source_ is not a good idea, because ERB#src means something entirely different;
+# the two different sorts of sources would bring confusion.
+#
+# Therefore we use the term _template_ to refer to:
+#
+# - The string input to ERB.new
+# - The string input to executable erb.
+#
+
require 'erb/version'
require 'erb/compiler'
require 'erb/def_method'
require 'erb/util'
+# :markup: markdown
#
-# = ERB -- Ruby Templating
+# Class **ERB** (the name stands for **Embedded Ruby**)
+# is an easy-to-use, but also very powerful, [template processor][template processor].
#
-# == Introduction
+# ## Usage
#
-# ERB provides an easy to use but powerful templating system for Ruby. Using
-# ERB, actual Ruby code can be added to any plain text document for the
-# purposes of generating document information details and/or flow control.
+# Before you can use \ERB, you must first require it
+# (examples on this page assume that this has been done):
#
-# A very simple example is this:
+# ```
+# require 'erb'
+# ```
#
-# require 'erb'
+# ## In Brief
#
-# x = 42
-# template = ERB.new <<-EOF
-# The value of x is: <%= x %>
-# EOF
-# puts template.result(binding)
+# Here's how \ERB works:
#
-# <em>Prints:</em> The value of x is: 42
+# - You can create a *template*: a plain-text string that includes specially formatted *tags*..
+# - You can create an \ERB object to store the template.
+# - You can call instance method ERB#result to get the *result*.
#
-# More complex examples are given below.
+# \ERB supports tags of three kinds:
#
+# - [Expression tags][expression tags]:
+# each begins with `'<%='`, ends with `'%>'`; contains a Ruby expression;
+# in the result, the value of the expression replaces the entire tag:
#
-# == Recognized Tags
+# template = 'The magic word is <%= magic_word %>.'
+# erb = ERB.new(template)
+# magic_word = 'xyzzy'
+# erb.result(binding) # => "The magic word is xyzzy."
#
-# ERB recognizes certain tags in the provided template and converts them based
-# on the rules below:
+# The above call to #result passes argument `binding`,
+# which contains the binding of variable `magic_word` to its string value `'xyzzy'`.
#
-# <% Ruby code -- inline with output %>
-# <%= Ruby expression -- replace with result %>
-# <%# comment -- ignored -- useful in testing %> (`<% #` doesn't work. Don't use Ruby comments.)
-# % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
-# %% replaced with % if first thing on a line and % processing is used
-# <%% or %%> -- replace with <% or %> respectively
+# The below call to #result need not pass a binding,
+# because its expression `Date::DAYNAMES` is globally defined.
#
-# All other text is passed through ERB filtering unchanged.
+# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday."
#
+# - [Execution tags][execution tags]:
+# each begins with `'<%'`, ends with `'%>'`; contains Ruby code to be executed:
#
-# == Options
+# template = '<% File.write("t.txt", "Some stuff.") %>'
+# ERB.new(template).result
+# File.read('t.txt') # => "Some stuff."
#
-# There are several settings you can change when you use ERB:
-# * the nature of the tags that are recognized;
-# * the binding used to resolve local variables in the template.
+# - [Comment tags][comment tags]:
+# each begins with `'<%#'`, ends with `'%>'`; contains comment text;
+# in the result, the entire tag is omitted.
#
-# See the ERB.new and ERB#result methods for more detail.
+# template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
+# ERB.new(template).result # => "Some stuff; more stuff."
#
-# == Character encodings
+# ## Some Simple Examples
#
-# ERB (or Ruby code generated by ERB) returns a string in the same
-# character encoding as the input string. When the input string has
-# a magic comment, however, it returns a string in the encoding specified
-# by the magic comment.
+# Here's a simple example of \ERB in action:
#
-# # -*- coding: utf-8 -*-
-# require 'erb'
+# ```
+# template = 'The time is <%= Time.now %>.'
+# erb = ERB.new(template)
+# erb.result
+# # => "The time is 2025-09-09 10:49:26 -0500."
+# ```
#
-# template = ERB.new <<EOF
-# <%#-*- coding: Big5 -*-%>
-# \_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
-# EOF
-# puts template.result
+# Details:
#
-# <em>Prints:</em> \_\_ENCODING\_\_ is Big5.
+# 1. A plain-text string is assigned to variable `template`.
+# Its embedded [expression tag][expression tags] `'<%= Time.now %>'` includes a Ruby expression, `Time.now`.
+# 2. The string is put into a new \ERB object, and stored in variable `erb`.
+# 4. Method call `erb.result` generates a string that contains the run-time value of `Time.now`,
+# as computed at the time of the call.
#
+# The
+# \ERB object may be re-used:
#
-# == Examples
+# ```
+# erb.result
+# # => "The time is 2025-09-09 10:49:33 -0500."
+# ```
#
-# === Plain Text
+# Another example:
#
-# ERB is useful for any generic templating situation. Note that in this example, we use the
-# convenient "% at start of line" tag, and we quote the template literally with
-# <tt>%q{...}</tt> to avoid trouble with the backslash.
+# ```
+# template = 'The magic word is <%= magic_word %>.'
+# erb = ERB.new(template)
+# magic_word = 'abracadabra'
+# erb.result(binding)
+# # => "The magic word is abracadabra."
+# ```
#
-# require "erb"
+# Details:
#
-# # Create template.
-# template = %q{
-# From: James Edward Gray II <james@grayproductions.net>
-# To: <%= to %>
-# Subject: Addressing Needs
+# 1. As before, a plain-text string is assigned to variable `template`.
+# Its embedded [expression tag][expression tags] `'<%= magic_word %>'` has a variable *name*, `magic_word`.
+# 2. The string is put into a new \ERB object, and stored in variable `erb`;
+# note that `magic_word` need not be defined before the \ERB object is created.
+# 3. `magic_word = 'abracadabra'` assigns a value to variable `magic_word`.
+# 4. Method call `erb.result(binding)` generates a string
+# that contains the *value* of `magic_word`.
#
-# <%= to[/\w+/] %>:
+# As before, the \ERB object may be re-used:
#
-# Just wanted to send a quick note assuring that your needs are being
-# addressed.
+# ```
+# magic_word = 'xyzzy'
+# erb.result(binding)
+# # => "The magic word is xyzzy."
+# ```
#
-# I want you to know that my team will keep working on the issues,
-# especially:
+# ## Bindings
#
-# <%# ignore numerous minor requests -- focus on priorities %>
-# % priorities.each do |priority|
-# * <%= priority %>
-# % end
+# A call to method #result, which produces the formatted result string,
+# requires a [Binding object][binding object] as its argument.
+#
+# The binding object provides the bindings for expressions in [expression tags][expression tags].
+#
+# There are three ways to provide the required binding:
+#
+# - [Default binding][default binding].
+# - [Local binding][local binding].
+# - [Augmented binding][augmented binding]
+#
+# ### Default Binding
+#
+# When you pass no `binding` argument to method #result,
+# the method uses its default binding: the one returned by method #new_toplevel.
+# This binding has the bindings defined by Ruby itself,
+# which are those for Ruby's constants and variables.
+#
+# That binding is sufficient for an expression tag that refers only to Ruby's constants and variables;
+# these expression tags refer only to Ruby's global constant `RUBY_COPYRIGHT` and global variable `$0`:
#
-# Thanks for your patience.
+# ```
+# template = <<TEMPLATE
+# The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
+# The current process is <%= $0 %>.
+# TEMPLATE
+# puts ERB.new(template).result
+# The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
+# The current process is irb.
+# ```
+#
+# (The current process is `irb` because that's where we're doing these examples!)
+#
+# ### Local Binding
+#
+# The default binding is *not* sufficient for an expression
+# that refers to a a constant or variable that is not defined there:
+#
+# ```
+# Foo = 1 # Defines local constant Foo.
+# foo = 2 # Defines local variable foo.
+# template = <<TEMPLATE
+# The current value of constant Foo is <%= Foo %>.
+# The current value of variable foo is <%= foo %>.
+# The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
+# The current process is <%= $0 %>.
+# TEMPLATE
+# erb = ERB.new(template)
+# ```
+#
+# This call below raises `NameError` because although `Foo` and `foo` are defined locally,
+# they are not defined in the default binding:
+#
+# ```
+# erb.result # Raises NameError.
+# ```
+#
+# To make the locally-defined constants and variables available,
+# you can call #result with the local binding:
+#
+# ```
+# puts erb.result(binding)
+# The current value of constant Foo is 1.
+# The current value of variable foo is 2.
+# The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
+# The current process is irb.
+# ```
+#
+# ### Augmented Binding
+#
+# Another way to make variable bindings (but not constant bindings) available
+# is to use method #result_with_hash(hash);
+# the passed hash has name/value pairs that are to be used to define and assign variables
+# in a copy of the default binding:
+#
+# ```
+# template = <<TEMPLATE
+# The current value of variable bar is <%= bar %>.
+# The current value of variable baz is <%= baz %>.
+# The Ruby copyright is <%= RUBY_COPYRIGHT.inspect %>.
+# The current process is <%= $0 %>.
+# TEMPLATE
+# erb = ERB.new(template)
+# ```
+#
+# Both of these calls raise `NameError`, because `bar` and `baz`
+# are not defined in either the default binding or the local binding.
+#
+# ```
+# puts erb.result # Raises NameError.
+# puts erb.result(binding) # Raises NameError.
+# ```
+#
+# This call passes a hash that causes `bar` and `baz` to be defined
+# in a new binding (derived from #new_toplevel):
+#
+# ```
+# hash = {bar: 3, baz: 4}
+# puts erb.result_with_hash(hash)
+# The current value of variable bar is 3.
+# The current value of variable baz is 4.
+# The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto".
+# The current process is irb.
+# ```
+#
+# ## Tags
+#
+# The examples above use expression tags.
+# These are the tags available in \ERB:
+#
+# - [Expression tag][expression tags]: the tag contains a Ruby expression;
+# in the result, the entire tag is to be replaced with the run-time value of the expression.
+# - [Execution tag][execution tags]: the tag contains Ruby code;
+# in the result, the entire tag is to be replaced with the run-time value of the code.
+# - [Comment tag][comment tags]: the tag contains comment code;
+# in the result, the entire tag is to be omitted.
+#
+# ### Expression Tags
+#
+# You can embed a Ruby expression in a template using an *expression tag*.
+#
+# Its syntax is `<%= _expression_ %>`,
+# where *expression* is any valid Ruby expression.
+#
+# When you call method #result,
+# the method evaluates the expression and replaces the entire expression tag with the expression's value:
+#
+# ```
+# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result
+# # => "Today is Monday."
+# ERB.new('Tomorrow will be <%= Date::DAYNAMES[Date.today.wday + 1] %>.').result
+# # => "Tomorrow will be Tuesday."
+# ERB.new('Yesterday was <%= Date::DAYNAMES[Date.today.wday - 1] %>.').result
+# # => "Yesterday was Sunday."
+# ```
+#
+# Note that whitespace before and after the expression
+# is allowed but not required,
+# and that such whitespace is stripped from the result.
+#
+# ```
+# ERB.new('My appointment is on <%=Date::DAYNAMES[Date.today.wday + 2]%>.').result
+# # => "My appointment is on Wednesday."
+# ERB.new('My appointment is on <%= Date::DAYNAMES[Date.today.wday + 2] %>.').result
+# # => "My appointment is on Wednesday."
+# ```
+#
+# ### Execution Tags
+#
+# You can embed Ruby executable code in template using an *execution tag*.
+#
+# Its syntax is `<% _code_ %>`,
+# where *code* is any valid Ruby code.
+#
+# When you call method #result,
+# the method executes the code and removes the entire execution tag
+# (generating no text in the result):
+#
+# ```
+# ERB.new('foo <% Dir.chdir("C:/") %> bar').result # => "foo bar"
+# ```
+#
+# Whitespace before and after the embedded code is optional:
+#
+# ```
+# ERB.new('foo <%Dir.chdir("C:/")%> bar').result # => "foo bar"
+# ```
+#
+# You can interleave text with execution tags to form a control structure
+# such as a conditional, a loop, or a `case` statements.
+#
+# Conditional:
+#
+# ```
+# template = <<TEMPLATE
+# <% if verbosity %>
+# An error has occurred.
+# <% else %>
+# Oops!
+# <% end %>
+# TEMPLATE
+# erb = ERB.new(template)
+# verbosity = true
+# erb.result(binding)
+# # => "\nAn error has occurred.\n\n"
+# verbosity = false
+# erb.result(binding)
+# # => "\nOops!\n\n"
+# ```
+#
+# Note that the interleaved text may itself contain expression tags:
+#
+# Loop:
+#
+# ```
+# template = <<TEMPLATE
+# <% Date::ABBR_DAYNAMES.each do |dayname| %>
+# <%= dayname %>
+# <% end %>
+# TEMPLATE
+# ERB.new(template).result
+# # => "\nSun\n\nMon\n\nTue\n\nWed\n\nThu\n\nFri\n\nSat\n\n"
+# ```
+#
+# Other, non-control, lines of Ruby code may be interleaved with the text,
+# and the Ruby code may itself contain regular Ruby comments:
+#
+# ```
+# template = <<TEMPLATE
+# <% 3.times do %>
+# <%= Time.now %>
+# <% sleep(1) # Let's make the times different. %>
+# <% end %>
+# TEMPLATE
+# ERB.new(template).result
+# # => "\n2025-09-09 11:36:02 -0500\n\n\n2025-09-09 11:36:03 -0500\n\n\n2025-09-09 11:36:04 -0500\n\n\n"
+# ```
+#
+# The execution tag may also contain multiple lines of code:
+#
+# ```
+# template = <<TEMPLATE
+# <%
+# (0..2).each do |i|
+# (0..2).each do |j|
+# %>
+# * <%=i%>,<%=j%>
+# <%
+# end
+# end
+# %>
+# TEMPLATE
+# ERB.new(template).result
+# # => "\n* 0,0\n\n* 0,1\n\n* 0,2\n\n* 1,0\n\n* 1,1\n\n* 1,2\n\n* 2,0\n\n* 2,1\n\n* 2,2\n\n"
+# ```
+#
+# #### Shorthand Format for Execution Tags
+#
+# You can use keyword argument `trim_mode: '%'` to enable a shorthand format for execution tags;
+# this example uses the shorthand format `% _code_` instead of `<% _code_ %>`:
+#
+# ```
+# template = <<TEMPLATE
+# % priorities.each do |priority|
+# * <%= priority %>
+# % end
+# TEMPLATE
+# erb = ERB.new(template, trim_mode: '%')
+# priorities = [ 'Run Ruby Quiz',
+# 'Document Modules',
+# 'Answer Questions on Ruby Talk' ]
+# puts erb.result(binding)
+# * Run Ruby Quiz
+# * Document Modules
+# * Answer Questions on Ruby Talk
+# ```
+#
+# Note that in the shorthand format, the character `'%'` must be the first character in the code line
+# (no leading whitespace).
+#
+# #### Suppressing Unwanted Blank Lines
+#
+# With keyword argument `trim_mode` not given,
+# all blank lines go into the result:
+#
+# ```
+# template = <<TEMPLATE
+# <% if true %>
+# <%= RUBY_VERSION %>
+# <% end %>
+# TEMPLATE
+# ERB.new(template).result.lines.each {|line| puts line.inspect }
+# "\n"
+# "3.4.5\n"
+# "\n"
+# ```
+#
+# You can give `trim_mode: '-'`, you can suppress each blank line
+# whose source line ends with `-%>` (instead of `%>`):
+#
+# ```
+# template = <<TEMPLATE
+# <% if true -%>
+# <%= RUBY_VERSION %>
+# <% end -%>
+# TEMPLATE
+# ERB.new(template, trim_mode: '-').result.lines.each {|line| puts line.inspect }
+# "3.4.5\n"
+# ```
+#
+# It is an error to use the trailing `'-%>'` notation without `trim_mode: '-'`:
+#
+# ```
+# ERB.new(template).result.lines.each {|line| puts line.inspect } # Raises SyntaxError.
+# ```
+#
+# #### Suppressing Unwanted Newlines
+#
+# Consider this template:
+#
+# ```
+# template = <<TEMPLATE
+# <% RUBY_VERSION %>
+# <%= RUBY_VERSION %>
+# foo <% RUBY_VERSION %>
+# foo <%= RUBY_VERSION %>
+# TEMPLATE
+# ```
+#
+# With keyword argument `trim_mode` not given, all newlines go into the result:
+#
+# ```
+# ERB.new(template).result.lines.each {|line| puts line.inspect }
+# "\n"
+# "3.4.5\n"
+# "foo \n"
+# "foo 3.4.5\n"
+# ```
+#
+# You can give `trim_mode: '>'` to suppress the trailing newline
+# for each line that ends with `'%>'` (regardless of its beginning):
+#
+# ```
+# ERB.new(template, trim_mode: '>').result.lines.each {|line| puts line.inspect }
+# "3.4.5foo foo 3.4.5"
+# ```
+#
+# You can give `trim_mode: '<>'` to suppress the trailing newline
+# for each line that both begins with `'<%'` and ends with `'%>'`:
+#
+# ```
+# ERB.new(template, trim_mode: '<>').result.lines.each {|line| puts line.inspect }
+# "3.4.5foo \n"
+# "foo 3.4.5\n"
+# ```
+#
+# #### Combining Trim Modes
+#
+# You can combine certain trim modes:
+#
+# - `'%-'`: Enable shorthand and omit each blank line ending with `'-%>'`.
+# - `'%>'`: Enable shorthand and omit newline for each line ending with `'%>'`.
+# - `'%<>'`: Enable shorthand and omit newline for each line starting with `'<%'` and ending with `'%>'`.
+#
+# ### Comment Tags
+#
+# You can embed a comment in a template using a *comment tag*;
+# its syntax is `<%# _text_ %>`,
+# where *text* is the text of the comment.
+#
+# When you call method #result,
+# it removes the entire comment tag
+# (generating no text in the result).
+#
+# Example:
+#
+# ```
+# template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.'
+# ERB.new(template).result # => "Some stuff; more stuff."
+# ```
+#
+# A comment tag may appear anywhere in the template.
+#
+# Note that the beginning of the tag must be `'<%#'`, not `'<% #'`.
+#
+# In this example, the tag begins with `'<% #'`, and so is an execution tag, not a comment tag;
+# the cited code consists entirely of a Ruby-style comment (which is of course ignored):
+#
+# ```
+# ERB.new('Some stuff;<% # Note to self: figure out what the stuff is. %> more stuff.').result
+# # => "Some stuff;"
+# ```
+#
+# ## Encodings
+#
+# An \ERB object has an [encoding][encoding],
+# which is by default the encoding of the template string;
+# the result string will also have that encoding.
#
-# James Edward Gray II
-# }.gsub(/^ /, '')
+# ```
+# template = <<TEMPLATE
+# <%# Comment. %>
+# TEMPLATE
+# erb = ERB.new(template)
+# template.encoding # => #<Encoding:UTF-8>
+# erb.encoding # => #<Encoding:UTF-8>
+# erb.result.encoding # => #<Encoding:UTF-8>
+# ```
#
-# message = ERB.new(template, trim_mode: "%<>")
+# You can specify a different encoding by adding a [magic comment][magic comments]
+# at the top of the given template:
#
-# # Set up template data.
-# to = "Community Spokesman <spokesman@ruby_community.org>"
-# priorities = [ "Run Ruby Quiz",
-# "Document Modules",
-# "Answer Questions on Ruby Talk" ]
+# ```
+# template = <<TEMPLATE
+# <%#-*- coding: Big5 -*-%>
+# <%# Comment. %>
+# TEMPLATE
+# erb = ERB.new(template)
+# template.encoding # => #<Encoding:UTF-8>
+# erb.encoding # => #<Encoding:Big5>
+# erb.result.encoding # => #<Encoding:Big5>
+# ```
#
-# # Produce result.
-# email = message.result
-# puts email
+# ## Error Reporting
#
-# <i>Generates:</i>
+# Consider this template (containing an error):
#
-# From: James Edward Gray II <james@grayproductions.net>
-# To: Community Spokesman <spokesman@ruby_community.org>
-# Subject: Addressing Needs
+# ```
+# template = '<%= nosuch %>'
+# erb = ERB.new(template)
+# ```
#
-# Community:
+# When \ERB reports an error,
+# it includes a file name (if available) and a line number;
+# the file name comes from method #filename, the line number from method #lineno.
#
-# Just wanted to send a quick note assuring that your needs are being addressed.
+# Initially, those values are `nil` and `0`, respectively;
+# these initial values are reported as `'(erb)'` and `1`, respectively:
#
-# I want you to know that my team will keep working on the issues, especially:
+# ```
+# erb.filename # => nil
+# erb.lineno # => 0
+# erb.result
+# (erb):1:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
+# ```
#
-# * Run Ruby Quiz
-# * Document Modules
-# * Answer Questions on Ruby Talk
+# You can use methods #filename= and #lineno= to assign values
+# that are more meaningful in your context:
#
-# Thanks for your patience.
+# ```
+# erb.filename = 't.txt'
+# erb.lineno = 555
+# erb.result
+# t.txt:556:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
+# ```
#
-# James Edward Gray II
+# You can use method #location= to set both values:
#
-# === Ruby in HTML
+# ```
+# erb.location = ['u.txt', 999]
+# erb.result
+# u.txt:1000:in '<main>': undefined local variable or method 'nosuch' for main (NameError)
+# ```
#
-# ERB is often used in <tt>.rhtml</tt> files (HTML with embedded Ruby). Notice the need in
-# this example to provide a special binding when the template is run, so that the instance
-# variables in the Product object can be resolved.
+# ## Plain Text with Embedded Ruby
#
-# require "erb"
+# Here's a plain-text template;
+# it uses the literal notation `'%q{ ... }'` to define the template
+# (see [%q literals][%q literals]);
+# this avoids problems with backslashes.
#
-# # Build template data class.
-# class Product
-# def initialize( code, name, desc, cost )
-# @code = code
-# @name = name
-# @desc = desc
-# @cost = cost
+# ```
+# template = %q{
+# From: James Edward Gray II <james@grayproductions.net>
+# To: <%= to %>
+# Subject: Addressing Needs
#
-# @features = [ ]
-# end
+# <%= to[/\w+/] %>:
#
-# def add_feature( feature )
-# @features << feature
-# end
+# Just wanted to send a quick note assuring that your needs are being
+# addressed.
#
-# # Support templating of member data.
-# def get_binding
-# binding
-# end
+# I want you to know that my team will keep working on the issues,
+# especially:
#
-# # ...
-# end
+# <%# ignore numerous minor requests -- focus on priorities %>
+# % priorities.each do |priority|
+# * <%= priority %>
+# % end
+#
+# Thanks for your patience.
#
-# # Create template.
-# template = %{
-# <html>
-# <head><title>Ruby Toys -- <%= @name %></title></head>
-# <body>
+# James Edward Gray II
+# }
+# ```
#
-# <h1><%= @name %> (<%= @code %>)</h1>
-# <p><%= @desc %></p>
+# The template will need these:
#
-# <ul>
-# <% @features.each do |f| %>
-# <li><b><%= f %></b></li>
-# <% end %>
-# </ul>
+# ```
+# to = 'Community Spokesman <spokesman@ruby_community.org>'
+# priorities = [ 'Run Ruby Quiz',
+# 'Document Modules',
+# 'Answer Questions on Ruby Talk' ]
+# ```
#
-# <p>
-# <% if @cost < 10 %>
-# <b>Only <%= @cost %>!!!</b>
-# <% else %>
-# Call for a price, today!
-# <% end %>
-# </p>
+# Finally, create the \ERB object and get the result
#
-# </body>
-# </html>
-# }.gsub(/^ /, '')
+# ```
+# erb = ERB.new(template, trim_mode: '%<>')
+# puts erb.result(binding)
#
-# rhtml = ERB.new(template)
+# From: James Edward Gray II <james@grayproductions.net>
+# To: Community Spokesman <spokesman@ruby_community.org>
+# Subject: Addressing Needs
#
-# # Set up template data.
-# toy = Product.new( "TZ-1002",
-# "Rubysapien",
-# "Geek's Best Friend! Responds to Ruby commands...",
-# 999.95 )
-# toy.add_feature("Listens for verbal commands in the Ruby language!")
-# toy.add_feature("Ignores Perl, Java, and all C variants.")
-# toy.add_feature("Karate-Chop Action!!!")
-# toy.add_feature("Matz signature on left leg.")
-# toy.add_feature("Gem studded eyes... Rubies, of course!")
+# Community:
#
-# # Produce result.
-# rhtml.run(toy.get_binding)
+# Just wanted to send a quick note assuring that your needs are being
+# addressed.
#
-# <i>Generates (some blank lines removed):</i>
+# I want you to know that my team will keep working on the issues,
+# especially:
#
-# <html>
-# <head><title>Ruby Toys -- Rubysapien</title></head>
-# <body>
+# * Run Ruby Quiz
+# * Document Modules
+# * Answer Questions on Ruby Talk
#
-# <h1>Rubysapien (TZ-1002)</h1>
-# <p>Geek's Best Friend! Responds to Ruby commands...</p>
+# Thanks for your patience.
#
-# <ul>
-# <li><b>Listens for verbal commands in the Ruby language!</b></li>
-# <li><b>Ignores Perl, Java, and all C variants.</b></li>
-# <li><b>Karate-Chop Action!!!</b></li>
-# <li><b>Matz signature on left leg.</b></li>
-# <li><b>Gem studded eyes... Rubies, of course!</b></li>
-# </ul>
+# James Edward Gray II
+# ```
#
-# <p>
-# Call for a price, today!
-# </p>
+# ## HTML with Embedded Ruby
#
-# </body>
-# </html>
+# This example shows an HTML template.
#
+# First, here's a custom class, `Product`:
#
-# == Notes
+# ```
+# class Product
+# def initialize(code, name, desc, cost)
+# @code = code
+# @name = name
+# @desc = desc
+# @cost = cost
+# @features = []
+# end
#
-# There are a variety of templating solutions available in various Ruby projects.
-# For example, RDoc, distributed with Ruby, uses its own template engine, which
-# can be reused elsewhere.
+# def add_feature(feature)
+# @features << feature
+# end
#
-# Other popular engines could be found in the corresponding
-# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of
-# The Ruby Toolbox.
+# # Support templating of member data.
+# def get_binding
+# binding
+# end
+#
+# end
+# ```
+#
+# The template below will need these values:
+#
+# ```
+# toy = Product.new('TZ-1002',
+# 'Rubysapien',
+# "Geek's Best Friend! Responds to Ruby commands...",
+# 999.95
+# )
+# toy.add_feature('Listens for verbal commands in the Ruby language!')
+# toy.add_feature('Ignores Perl, Java, and all C variants.')
+# toy.add_feature('Karate-Chop Action!!!')
+# toy.add_feature('Matz signature on left leg.')
+# toy.add_feature('Gem studded eyes... Rubies, of course!')
+# ```
+#
+# Here's the HTML:
+#
+# ```
+# template = <<TEMPLATE
+# <html>
+# <head><title>Ruby Toys -- <%= @name %></title></head>
+# <body>
+# <h1><%= @name %> (<%= @code %>)</h1>
+# <p><%= @desc %></p>
+# <ul>
+# <% @features.each do |f| %>
+# <li><b><%= f %></b></li>
+# <% end %>
+# </ul>
+# <p>
+# <% if @cost < 10 %>
+# <b>Only <%= @cost %>!!!</b>
+# <% else %>
+# Call for a price, today!
+# <% end %>
+# </p>
+# </body>
+# </html>
+# TEMPLATE
+# ```
+#
+# Finally, create the \ERB object and get the result (omitting some blank lines):
+#
+# ```
+# erb = ERB.new(template)
+# puts erb.result(toy.get_binding)
+# <html>
+# <head><title>Ruby Toys -- Rubysapien</title></head>
+# <body>
+# <h1>Rubysapien (TZ-1002)</h1>
+# <p>Geek's Best Friend! Responds to Ruby commands...</p>
+# <ul>
+# <li><b>Listens for verbal commands in the Ruby language!</b></li>
+# <li><b>Ignores Perl, Java, and all C variants.</b></li>
+# <li><b>Karate-Chop Action!!!</b></li>
+# <li><b>Matz signature on left leg.</b></li>
+# <li><b>Gem studded eyes... Rubies, of course!</b></li>
+# </ul>
+# <p>
+# Call for a price, today!
+# </p>
+# </body>
+# </html>
+# ```
+#
+#
+# ## Other Template Processors
+#
+# Various Ruby projects have their own template processors.
+# The Ruby Processing System [RDoc][rdoc], for example, has one that can be used elsewhere.
+#
+# Other popular template processors may found in the [Template Engines][template engines] page
+# of the Ruby Toolbox.
+#
+# [%q literals]: https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-25q-3A+Non-Interpolable+String+Literals
+# [augmented binding]: rdoc-ref:ERB@Augmented+Binding
+# [binding object]: https://docs.ruby-lang.org/en/master/Binding.html
+# [comment tags]: rdoc-ref:ERB@Comment+Tags
+# [default binding]: rdoc-ref:ERB@Default+Binding
+# [encoding]: https://docs.ruby-lang.org/en/master/Encoding.html
+# [execution tags]: rdoc-ref:ERB@Execution+Tags
+# [expression tags]: rdoc-ref:ERB@Expression+Tags
+# [kernel#binding]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-binding
+# [local binding]: rdoc-ref:ERB@Local+Binding
+# [magic comments]: https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-Magic+Comments
+# [rdoc]: https://ruby.github.io/rdoc
+# [sprintf]: https://docs.ruby-lang.org/en/master/Kernel.html#method-i-sprintf
+# [template engines]: https://www.ruby-toolbox.com/categories/template_engines
+# [template processor]: https://en.wikipedia.org/wiki/Template_processor
#
class ERB
- Revision = '$Date:: $' # :nodoc: #'
- deprecate_constant :Revision
-
- # Returns revision information for the erb.rb module.
+ # :markup: markdown
+ #
+ # :call-seq:
+ # self.version -> string
+ #
+ # Returns the string \ERB version.
def self.version
VERSION
end
+ # :markup: markdown
#
- # Constructs a new ERB object with the template specified in _str_.
- #
- # An ERB object works by building a chunk of Ruby code that will output
- # the completed template when run.
+ # :call-seq:
+ # ERB.new(template, trim_mode: nil, eoutvar: '_erbout')
#
- # If _trim_mode_ is passed a String containing one or more of the following
- # modifiers, ERB will adjust its code generation as listed:
+ # Returns a new \ERB object containing the given string +template+.
#
- # % enables Ruby code processing for lines beginning with %
- # <> omit newline for lines starting with <% and ending in %>
- # > omit newline for lines ending in %>
- # - omit blank lines ending in -%>
+ # For details about `template`, its embedded tags, and generated results, see ERB.
#
- # _eoutvar_ can be used to set the name of the variable ERB will build up
- # its output in. This is useful when you need to run multiple ERB
- # templates through the same binding and/or when you want to control where
- # output ends up. Pass the name of the variable to be used inside a String.
+ # **Keyword Argument `trim_mode`**
#
- # === Example
+ # You can use keyword argument `trim_mode: '%'`
+ # to enable the [shorthand format][shorthand format] for execution tags.
#
- # require "erb"
+ # This value allows [blank line control][blank line control]:
#
- # # build data class
- # class Listings
- # PRODUCT = { :name => "Chicken Fried Steak",
- # :desc => "A well messages pattie, breaded and fried.",
- # :cost => 9.95 }
+ # - `'-'`: Omit each blank line ending with `'%>'`.
#
- # attr_reader :product, :price
+ # Other values allow [newline control][newline control]:
#
- # def initialize( product = "", price = "" )
- # @product = product
- # @price = price
- # end
+ # - `'>'`: Omit newline for each line ending with `'%>'`.
+ # - `'<>'`: Omit newline for each line starting with `'<%'` and ending with `'%>'`.
#
- # def build
- # b = binding
- # # create and run templates, filling member data variables
- # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
- # <%= PRODUCT[:name] %>
- # <%= PRODUCT[:desc] %>
- # END_PRODUCT
- # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
- # <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
- # <%= PRODUCT[:desc] %>
- # END_PRICE
- # end
- # end
+ # You can also [combine trim modes][combine trim modes].
#
- # # setup template data
- # listings = Listings.new
- # listings.build
+ # **Keyword Argument `eoutvar`**
#
- # puts listings.product + "\n" + listings.price
+ # The string value of keyword argument `eoutvar` specifies the name of the variable
+ # that method #result uses to construct its result string;
+ # see #src.
#
- # _Generates_
+ # This is useful when you need to run multiple \ERB templates through the same binding
+ # and/or when you want to control where output ends up.
#
- # Chicken Fried Steak
- # A well messages pattie, breaded and fried.
+ # It's good practice to choose a variable name that begins with an underscore: `'_'`.
#
- # Chicken Fried Steak -- 9.95
- # A well messages pattie, breaded and fried.
+ # [blank line control]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
+ # [combine trim modes]: rdoc-ref:ERB@Combining+Trim+Modes
+ # [newline control]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
+ # [shorthand format]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
#
- def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
- # Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
- if safe_level != NOT_GIVEN
- warn 'Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.', uplevel: 1
- end
- if legacy_trim_mode != NOT_GIVEN
- warn 'Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.', uplevel: 1
- trim_mode = legacy_trim_mode
- end
- if legacy_eoutvar != NOT_GIVEN
- warn 'Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.', uplevel: 1
- eoutvar = legacy_eoutvar
- end
-
+ def initialize(str, trim_mode: nil, eoutvar: '_erbout')
compiler = make_compiler(trim_mode)
set_eoutvar(compiler, eoutvar)
@src, @encoding, @frozen_string = *compiler.compile(str)
+ @src.freeze
@filename = nil
@lineno = 0
@_init = self.class.singleton_class
end
- NOT_GIVEN = Object.new
- private_constant :NOT_GIVEN
-
- ##
- # Creates a new compiler for ERB. See ERB::Compiler.new for details
+ # :markup: markdown
+ #
+ # :call-seq:
+ # make_compiler -> erb_compiler
+ #
+ # Returns a new ERB::Compiler with the given `trim_mode`;
+ # for `trim_mode` values, see ERB.new:
+ #
+ # ```
+ # ERB.new('').make_compiler(nil)
+ # # => #<ERB::Compiler:0x000001cff9467678 @insert_cmd="print", @percent=false, @post_cmd=[], @pre_cmd=[], @put_cmd="print", @trim_mode=nil>
+ # ```
+ #
def make_compiler(trim_mode)
ERB::Compiler.new(trim_mode)
end
- # The Ruby code generated by ERB
+ # :markup: markdown
+ #
+ # Returns the Ruby code that, when executed, generates the result;
+ # the code is executed by method #result,
+ # and by its wrapper methods #result_with_hash and #run:
+ #
+ # ```
+ # template = 'The time is <%= Time.now %>.'
+ # erb = ERB.new(template)
+ # erb.src
+ # # => "#coding:UTF-8\n_erbout = +''; _erbout.<< \"The time is \".freeze; _erbout.<<(( Time.now ).to_s); _erbout.<< \".\".freeze; _erbout"
+ # erb.result
+ # # => "The time is 2025-09-18 15:58:08 -0500."
+ # ```
+ #
+ # In a more readable format:
+ #
+ # ```
+ # # puts erb.src.split('; ')
+ # # #coding:UTF-8
+ # # _erbout = +''
+ # # _erbout.<< "The time is ".freeze
+ # # _erbout.<<(( Time.now ).to_s)
+ # # _erbout.<< ".".freeze
+ # # _erbout
+ # ```
+ #
+ # Variable `_erbout` is used to store the intermediate results in the code;
+ # the name `_erbout` is the default in ERB.new,
+ # and can be changed via keyword argument `eoutvar`:
+ #
+ # ```
+ # erb = ERB.new(template, eoutvar: '_foo')
+ # puts template.src.split('; ')
+ # #coding:UTF-8
+ # _foo = +''
+ # _foo.<< "The time is ".freeze
+ # _foo.<<(( Time.now ).to_s)
+ # _foo.<< ".".freeze
+ # _foo
+ # ```
+ #
attr_reader :src
- # The encoding to eval
+ # :markup: markdown
+ #
+ # Returns the encoding of `self`;
+ # see [Encodings][encodings]:
+ #
+ # [encodings]: rdoc-ref:ERB@Encodings
+ #
attr_reader :encoding
- # The optional _filename_ argument passed to Kernel#eval when the ERB code
- # is run
+ # :markup: markdown
+ #
+ # Sets or returns the file name to be used in reporting errors;
+ # see [Error Reporting][error reporting].
+ #
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
attr_accessor :filename
- # The optional _lineno_ argument passed to Kernel#eval when the ERB code
- # is run
+ # :markup: markdown
+ #
+ # Sets or returns the line number to be used in reporting errors;
+ # see [Error Reporting][error reporting].
+ #
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
attr_accessor :lineno
+ # :markup: markdown
#
- # Sets optional filename and line number that will be used in ERB code
- # evaluation and error reporting. See also #filename= and #lineno=
- #
- # erb = ERB.new('<%= some_x %>')
- # erb.render
- # # undefined local variable or method `some_x'
- # # from (erb):1
+ # :call-seq:
+ # location = [filename, lineno] => [filename, lineno]
+ # location = filename -> filename
#
- # erb.location = ['file.erb', 3]
- # # All subsequent error reporting would use new location
- # erb.render
- # # undefined local variable or method `some_x'
- # # from file.erb:4
+ # Sets the values of #filename and, if given, #lineno;
+ # see [Error Reporting][error reporting].
#
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
def location=((filename, lineno))
@filename = filename
@lineno = lineno if lineno
end
+ # :markup: markdown
+ #
+ # :call-seq:
+ # set_eoutvar(compiler, eoutvar = '_erbout') -> [eoutvar]
#
- # Can be used to set _eoutvar_ as described in ERB::new. It's probably
- # easier to just use the constructor though, since calling this method
- # requires the setup of an ERB _compiler_ object.
+ # Sets the `eoutvar` value in the ERB::Compiler object `compiler`;
+ # returns a 1-element array containing the value of `eoutvar`:
+ #
+ # ```
+ # template = ERB.new('')
+ # compiler = template.make_compiler(nil)
+ # pp compiler
+ # #<ERB::Compiler:0x000001cff8a9aa00
+ # @insert_cmd="print",
+ # @percent=false,
+ # @post_cmd=[],
+ # @pre_cmd=[],
+ # @put_cmd="print",
+ # @trim_mode=nil>
+ # template.set_eoutvar(compiler, '_foo') # => ["_foo"]
+ # pp compiler
+ # #<ERB::Compiler:0x000001cff8a9aa00
+ # @insert_cmd="_foo.<<",
+ # @percent=false,
+ # @post_cmd=["_foo"],
+ # @pre_cmd=["_foo = +''"],
+ # @put_cmd="_foo.<<",
+ # @trim_mode=nil>
+ # ```
#
def set_eoutvar(compiler, eoutvar = '_erbout')
compiler.put_cmd = "#{eoutvar}.<<"
@@ -409,18 +977,34 @@ class ERB
compiler.post_cmd = [eoutvar]
end
- # Generate results and print them. (see ERB#result)
+ # :markup: markdown
+ #
+ # :call-seq:
+ # run(binding = new_toplevel) -> nil
+ #
+ # Like #result, but prints the result string (instead of returning it);
+ # returns `nil`.
def run(b=new_toplevel)
print self.result(b)
end
+ # :markup: markdown
#
- # Executes the generated ERB code to produce a completed template, returning
- # the results of that code. (See ERB::new for details on how this process
- # can be affected by _safe_level_.)
+ # :call-seq:
+ # result(binding = new_toplevel) -> new_string
#
- # _b_ accepts a Binding object which is used to set the context of
- # code evaluation.
+ # Returns the string result formed by processing \ERB tags found in the stored template in `self`.
+ #
+ # With no argument given, uses the default binding;
+ # see [Default Binding][default binding].
+ #
+ # With argument `binding` given, uses the local binding;
+ # see [Local Binding][local binding].
+ #
+ # See also #result_with_hash.
+ #
+ # [default binding]: rdoc-ref:ERB@Default+Binding
+ # [local binding]: rdoc-ref:ERB@Local+Binding
#
def result(b=new_toplevel)
unless @_init.equal?(self.class.singleton_class)
@@ -429,8 +1013,18 @@ class ERB
eval(@src, b, (@filename || '(erb)'), @lineno)
end
- # Render a template on a new toplevel binding with local variables specified
- # by a Hash object.
+ # :markup: markdown
+ #
+ # :call-seq:
+ # result_with_hash(hash) -> new_string
+ #
+ # Returns the string result formed by processing \ERB tags found in the stored string in `self`;
+ # see [Augmented Binding][augmented binding].
+ #
+ # See also #result.
+ #
+ # [augmented binding]: rdoc-ref:ERB@Augmented+Binding
+ #
def result_with_hash(hash)
b = new_toplevel(hash.keys)
hash.each_pair do |key, value|
@@ -439,10 +1033,22 @@ class ERB
result(b)
end
- ##
- # Returns a new binding each time *near* TOPLEVEL_BINDING for runs that do
- # not specify a binding.
-
+ # :markup: markdown
+ #
+ # :call-seq:
+ # new_toplevel(symbols) -> new_binding
+ #
+ # Returns a new binding based on `TOPLEVEL_BINDING`;
+ # used to create a default binding for a call to #result.
+ #
+ # See [Default Binding][default binding].
+ #
+ # Argument `symbols` is an array of symbols;
+ # each symbol `symbol` is defined as a new variable to hide and
+ # prevent it from overwriting a variable of the same name already
+ # defined within the binding.
+ #
+ # [default binding]: rdoc-ref:ERB@Default+Binding
def new_toplevel(vars = nil)
b = TOPLEVEL_BINDING
if vars
@@ -455,49 +1061,116 @@ class ERB
end
private :new_toplevel
- # Define _methodname_ as instance method of _mod_ from compiled Ruby source.
+ # :markup: markdown
+ #
+ # :call-seq:
+ # def_method(module, method_signature, filename = '(ERB)') -> method_name
+ #
+ # Creates and returns a new instance method in the given module `module`;
+ # returns the method name as a symbol.
+ #
+ # The method is created from the given `method_signature`,
+ # which consists of the method name and its argument names (if any).
+ #
+ # The `filename` sets the value of #filename;
+ # see [Error Reporting][error reporting].
+ #
+ # [error reporting]: rdoc-ref:ERB@Error+Reporting
+ #
+ # ```
+ # template = '<%= arg1 %> <%= arg2 %>'
+ # erb = ERB.new(template)
+ # MyModule = Module.new
+ # erb.def_method(MyModule, 'render(arg1, arg2)') # => :render
+ # class MyClass; include MyModule; end
+ # MyClass.new.render('foo', 123) # => "foo 123"
+ # ```
#
- # 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)')
+ unless @_init.equal?(self.class.singleton_class)
+ raise ArgumentError, "not initialized"
+ end
src = self.src.sub(/^(?!#|$)/) {"def #{methodname}\n"} << "\nend\n"
mod.module_eval do
eval(src, binding, fname, -1)
end
end
- # 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
+ # :markup: markdown
+ #
+ # :call-seq:
+ # def_module(method_name = 'erb') -> new_module
+ #
+ # Returns a new nameless module that has instance method `method_name`.
+ #
+ # ```
+ # template = '<%= arg1 %> <%= arg2 %>'
+ # erb = ERB.new(template)
+ # MyModule = template.def_module('render(arg1, arg2)')
+ # class MyClass
+ # include MyModule
+ # end
+ # MyClass.new.render('foo', 123)
+ # # => "foo 123"
+ # ```
+ #
def def_module(methodname='erb')
mod = Module.new
def_method(mod, methodname, @filename || '(ERB)')
mod
end
- # Define unnamed class which has _methodname_ as instance method, and return it.
+ # :markup: markdown
+ #
+ # :call-seq:
+ # def_class(super_class = Object, method_name = 'result') -> new_class
+ #
+ # Returns a new nameless class whose superclass is `super_class`,
+ # and which has instance method `method_name`.
+ #
+ # Create a template from HTML that has embedded expression tags that use `@arg1` and `@arg2`:
+ #
+ # ```
+ # html = <<TEMPLATE
+ # <html>
+ # <body>
+ # <p><%= @arg1 %></p>
+ # <p><%= @arg2 %></p>
+ # </body>
+ # </html>
+ # TEMPLATE
+ # template = ERB.new(html)
+ # ```
+ #
+ # Create a base class that has `@arg1` and `@arg2`:
#
- # example:
- # class MyClass_
- # def initialize(arg1, arg2)
- # @arg1 = arg1; @arg2 = arg2
- # end
+ # ```
+ # class MyBaseClass
+ # def initialize(arg1, arg2)
+ # @arg1 = arg1
+ # @arg2 = arg2
# 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()
+ # end
+ # ```
+ #
+ # Use method #def_class to create a subclass that has method `:render`:
+ #
+ # ```
+ # MySubClass = template.def_class(MyBaseClass, :render)
+ # ```
+ #
+ # Generate the result:
+ #
+ # ```
+ # puts MySubClass.new('foo', 123).render
+ # <html>
+ # <body>
+ # <p>foo</p>
+ # <p>123</p>
+ # </body>
+ # </html>
+ # ```
+ #
def def_class(superklass=Object, methodname='result')
cls = Class.new(superklass)
def_method(cls, methodname, @filename || '(ERB)')
diff --git a/lib/erb/compiler.rb b/lib/erb/compiler.rb
index 547d2c4c44..6d70288b4f 100644
--- a/lib/erb/compiler.rb
+++ b/lib/erb/compiler.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
#--
# ERB::Compiler
#
@@ -79,10 +80,16 @@ class ERB::Compiler # :nodoc:
end
class Scanner # :nodoc:
- @scanner_map = {}
+ @scanner_map = defined?(Ractor) ? Ractor.make_shareable({}) : {}
class << self
- def register_scanner(klass, trim_mode, percent)
- @scanner_map[[trim_mode, percent]] = klass
+ if defined?(Ractor)
+ def register_scanner(klass, trim_mode, percent)
+ @scanner_map = Ractor.make_shareable({ **@scanner_map, [trim_mode, percent] => klass })
+ end
+ else
+ def register_scanner(klass, trim_mode, percent)
+ @scanner_map[[trim_mode, percent]] = klass
+ end
end
alias :regist_scanner :register_scanner
end
@@ -218,7 +225,7 @@ class ERB::Compiler # :nodoc:
end
end
- ERB_STAG = %w(<%= <%# <%)
+ ERB_STAG = %w(<%= <%# <%).freeze
def is_erb_stag?(s)
ERB_STAG.member?(s)
end
@@ -465,7 +472,16 @@ class ERB::Compiler # :nodoc:
return enc, frozen
end
+ # :stopdoc:
+ WARNING_UPLEVEL = Class.new {
+ attr_reader :c
+ def initialize from
+ @c = caller.length - from.length
+ end
+ }.new(caller(0)).c
+ private_constant :WARNING_UPLEVEL
+
def warn_invalid_trim_mode(mode, uplevel:)
- warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + 1
+ warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + WARNING_UPLEVEL
end
end
diff --git a/lib/erb/def_method.rb b/lib/erb/def_method.rb
index 17f9c0f9fa..e503b37140 100644
--- a/lib/erb/def_method.rb
+++ b/lib/erb/def_method.rb
@@ -1,4 +1,5 @@
-#--
+# frozen_string_literal: true
+
# ERB::DefMethod
#
# Utility module to define eRuby script as instance method.
diff --git a/lib/erb/erb.gemspec b/lib/erb/erb.gemspec
new file mode 100644
index 0000000000..70113a2a04
--- /dev/null
+++ b/lib/erb/erb.gemspec
@@ -0,0 +1,37 @@
+begin
+ require_relative 'lib/erb/version'
+rescue LoadError
+ # for Ruby core repository
+ require_relative 'version'
+end
+
+Gem::Specification.new do |spec|
+ spec.name = 'erb'
+ spec.version = ERB::VERSION
+ spec.authors = ['Masatoshi SEKI', 'Takashi Kokubun']
+ spec.email = ['seki@ruby-lang.org', 'k0kubun@ruby-lang.org']
+
+ spec.summary = %q{An easy to use but powerful templating system for Ruby.}
+ spec.description = %q{An easy to use but powerful templating system for Ruby.}
+ spec.homepage = 'https://github.com/ruby/erb'
+ spec.licenses = ['Ruby', 'BSD-2-Clause']
+
+ spec.metadata['homepage_uri'] = spec.homepage
+ spec.metadata['source_code_uri'] = spec.homepage
+ spec.metadata['changelog_uri'] = "https://github.com/ruby/erb/blob/v#{spec.version}/NEWS.md"
+
+ spec.files = Dir.chdir(__dir__) do
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|\.git|\.github)/}) }
+ end
+ spec.bindir = 'libexec'
+ spec.executables = ['erb']
+ spec.require_paths = ['lib']
+
+ spec.required_ruby_version = '>= 3.2.0'
+
+ if RUBY_ENGINE == 'jruby'
+ spec.platform = 'java'
+ else
+ spec.extensions = ['ext/erb/escape/extconf.rb']
+ end
+end
diff --git a/lib/erb/util.rb b/lib/erb/util.rb
index 0c1e7482a8..d7d69eb4f1 100644
--- a/lib/erb/util.rb
+++ b/lib/erb/util.rb
@@ -1,17 +1,25 @@
-#--
-# ERB::Escape
-#
-# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
-# Rails will not monkey-patch ERB::Escape#html_escape.
+# frozen_string_literal: true
+
+# Load CGI.escapeHTML and CGI.escapeURIComponent.
+# CRuby:
+# cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 4.0+ stdlib have 'cgi/escape' and CGI.escapeHTML.
+# cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 4.0+ stdlib have CGI.escapeURIComponent.
+# JRuby: cgi.gem has a Java extension 'cgi/escape'.
+# TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
+require 'cgi/escape'
+
+# Load or define ERB::Escape#html_escape.
+# We don't build the C extension 'cgi/escape' for JRuby, TruffleRuby, and WASM.
+# miniruby (used by CRuby build scripts) also fails to load erb/escape.so.
begin
- # We don't build the C extension for JRuby, TruffleRuby, and WASM
- if $LOAD_PATH.resolve_feature_path('erb/escape')
- require 'erb/escape'
- end
-rescue LoadError # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
-end
-unless defined?(ERB::Escape)
+ require 'erb/escape'
+rescue LoadError
+ # ERB::Escape
+ #
+ # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
+ # Rails will not monkey-patch ERB::Escape#html_escape.
module ERB::Escape
+ # :stopdoc:
def html_escape(s)
CGI.escapeHTML(s.to_s)
end
@@ -19,7 +27,6 @@ unless defined?(ERB::Escape)
end
end
-#--
# ERB::Util
#
# A utility module for conversion routines, often handy in HTML generation.
@@ -41,20 +48,28 @@ module ERB::Util
alias h html_escape
module_function :h
- #
- # A utility method for encoding the String _s_ as a URL.
- #
- # require "erb"
- # include ERB::Util
- #
- # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
- #
- # _Generates_
- #
- # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
- #
- def url_encode(s)
- CGI.escapeURIComponent(s.to_s)
+ if CGI.respond_to?(:escapeURIComponent)
+ #
+ # A utility method for encoding the String _s_ as a URL.
+ #
+ # require "erb"
+ # include ERB::Util
+ #
+ # puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
+ #
+ # _Generates_
+ #
+ # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
+ #
+ def url_encode(s)
+ CGI.escapeURIComponent(s.to_s)
+ end
+ else # cgi.gem <= v0.3.2
+ def url_encode(s)
+ s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) do |m|
+ sprintf("%%%02X", m.unpack1("C"))
+ end
+ end
end
alias u url_encode
module_function :u
diff --git a/lib/erb/version.rb b/lib/erb/version.rb
index 38e1b76ff4..fde4a2776a 100644
--- a/lib/erb/version.rb
+++ b/lib/erb/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class ERB
- VERSION = '4.0.2'
- private_constant :VERSION
+ # The string \ERB version.
+ VERSION = '6.0.4'
end
diff --git a/lib/error_highlight/base.rb b/lib/error_highlight/base.rb
index 7d2ff0c889..5fffe5ec34 100644
--- a/lib/error_highlight/base.rb
+++ b/lib/error_highlight/base.rb
@@ -1,13 +1,13 @@
require_relative "version"
module ErrorHighlight
- # Identify the code fragment at that a given exception occurred.
+ # Identify the code fragment where a given exception occurred.
#
# Options:
#
# point_type: :name | :args
- # :name (default) points the method/variable name that the exception occurred.
- # :args points the arguments of the method call that the exception occurred.
+ # :name (default) points to the method/variable name where the exception occurred.
+ # :args points to the arguments of the method call where the exception occurred.
#
# backtrace_location: Thread::Backtrace::Location
# It locates the code fragment of the given backtrace_location.
@@ -28,7 +28,7 @@ module ErrorHighlight
# Currently, ErrorHighlight.spot only supports a single-line code fragment.
# Therefore, if the return value is not nil, first_lineno and last_lineno will have
# the same value. If the relevant code fragment spans multiple lines
- # (e.g., Array#[] of +ary[(newline)expr(newline)]+), the method will return nil.
+ # (e.g., Array#[] of <tt>ary[(newline)expr(newline)]</tt>), the method will return nil.
# This restriction may be removed in the future.
def self.spot(obj, **opts)
case obj
@@ -54,11 +54,20 @@ module ErrorHighlight
return nil unless Thread::Backtrace::Location === loc
- node = RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
+ node =
+ begin
+ RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
+ rescue RuntimeError => error
+ # RubyVM::AbstractSyntaxTree.of raises an error with a message that
+ # includes "prism" when the ISEQ was compiled with the prism compiler.
+ # In this case, we'll try to parse again with prism instead.
+ raise unless error.message.include?("prism")
+ prism_find(loc)
+ end
Spotter.new(node, **opts).spot
- when RubyVM::AbstractSyntaxTree::Node
+ when RubyVM::AbstractSyntaxTree::Node, Prism::Node
Spotter.new(obj, **opts).spot
else
@@ -72,6 +81,21 @@ module ErrorHighlight
return nil
end
+ # Accepts a Thread::Backtrace::Location object and returns a Prism::Node
+ # corresponding to the backtrace location in the source code.
+ def self.prism_find(location)
+ require "prism"
+ return nil if Prism::VERSION < "1.0.0"
+
+ absolute_path = location.absolute_path
+ return unless absolute_path
+
+ node_id = RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(location)
+ Prism.parse_file(absolute_path).value.breadth_first_search { |node| node.node_id == node_id }
+ end
+
+ private_class_method :prism_find
+
class Spotter
class NonAscii < Exception; end
private_constant :NonAscii
@@ -89,7 +113,7 @@ module ErrorHighlight
snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("")
snippet += "\n" unless snippet.end_with?("\n")
- # It require some work to support Unicode (or multibyte) characters.
+ # It requires some work to support Unicode (or multibyte) characters.
# Tentatively, we stop highlighting if the code snippet has non-ascii characters.
# See https://github.com/ruby/error_highlight/issues/4
raise NonAscii unless snippet.ascii_only?
@@ -98,19 +122,17 @@ module ErrorHighlight
end
end
- OPT_GETCONSTANT_PATH = (RUBY_VERSION.split(".").map {|s| s.to_i } <=> [3, 2]) >= 0
- private_constant :OPT_GETCONSTANT_PATH
-
def spot
return nil unless @node
- if OPT_GETCONSTANT_PATH && @node.type == :COLON2
- # In Ruby 3.2 or later, a nested constant access (like `Foo::Bar::Baz`)
- # is compiled to one instruction (opt_getconstant_path).
- # @node points to the node of the whole `Foo::Bar::Baz` even if `Foo`
- # or `Foo::Bar` causes NameError.
- # So we try to spot the sub-node that causes the NameError by using
- # `NameError#name`.
+ # In Ruby 3.2 or later, a nested constant access (like `Foo::Bar::Baz`)
+ # is compiled to one instruction (opt_getconstant_path).
+ # @node points to the node of the whole `Foo::Bar::Baz` even if `Foo`
+ # or `Foo::Bar` causes NameError.
+ # So we try to spot the sub-node that causes the NameError by using
+ # `NameError#name`.
+ case @node.type
+ when :COLON2
subnodes = []
node = @node
while node.type == :COLON2
@@ -130,6 +152,21 @@ module ErrorHighlight
# Do nothing; opt_getconstant_path is used only when the const base is
# NODE_CONST (`Foo`) or NODE_COLON3 (`::Foo`)
end
+ when :constant_path_node
+ subnodes = []
+ node = @node
+
+ begin
+ subnodes << node if node.name == @name
+ end while (node = node.parent).is_a?(Prism::ConstantPathNode)
+
+ if node.is_a?(Prism::ConstantReadNode) && node.name == @name
+ subnodes << node
+ end
+
+ # If we found only one sub-node whose name is equal to @name, use it
+ return nil if subnodes.size != 1
+ @node = subnodes.first
end
case @node.type
@@ -196,6 +233,86 @@ module ErrorHighlight
when :OP_CDECL
spot_op_cdecl
+
+ when :DEFN
+ raise NotImplementedError if @point_type != :name
+ spot_defn
+
+ when :DEFS
+ raise NotImplementedError if @point_type != :name
+ spot_defs
+
+ when :LAMBDA
+ spot_lambda
+
+ when :ITER
+ spot_iter
+
+ when :call_node
+ case @point_type
+ when :name
+ prism_spot_call_for_name
+ when :args
+ prism_spot_call_for_args
+ end
+
+ when :local_variable_operator_write_node
+ case @point_type
+ when :name
+ prism_spot_local_variable_operator_write_for_name
+ when :args
+ prism_spot_local_variable_operator_write_for_args
+ end
+
+ when :call_operator_write_node
+ case @point_type
+ when :name
+ prism_spot_call_operator_write_for_name
+ when :args
+ prism_spot_call_operator_write_for_args
+ end
+
+ when :index_operator_write_node
+ case @point_type
+ when :name
+ prism_spot_index_operator_write_for_name
+ when :args
+ prism_spot_index_operator_write_for_args
+ end
+
+ when :constant_read_node
+ prism_spot_constant_read
+
+ when :constant_path_node
+ prism_spot_constant_path
+
+ when :constant_path_operator_write_node
+ prism_spot_constant_path_operator_write
+
+ when :def_node
+ case @point_type
+ when :name
+ prism_spot_def_for_name
+ when :args
+ raise NotImplementedError
+ end
+
+ when :lambda_node
+ case @point_type
+ when :name
+ prism_spot_lambda_for_name
+ when :args
+ raise NotImplementedError
+ end
+
+ when :block_node
+ case @point_type
+ when :name
+ prism_spot_block_for_name
+ when :args
+ raise NotImplementedError
+ end
+
end
if @snippet && @beg_column && @end_column && @beg_column < @end_column
@@ -260,6 +377,7 @@ module ErrorHighlight
end
elsif mid.to_s =~ /\A\W+\z/ && lines.match(/\G\s*(#{ Regexp.quote(mid) })=.*\n/, nd_recv.last_column)
@snippet = $` + $&
+ @beg_lineno = @end_lineno = lineno
@beg_column = $~.begin(1)
@end_column = $~.end(1)
end
@@ -386,7 +504,6 @@ module ErrorHighlight
def spot_fcall_for_args
_mid, nd_args = @node.children
if nd_args && nd_args.first_lineno == nd_args.last_lineno
- # binary operator
fetch_line(nd_args.first_lineno)
@beg_column = nd_args.first_column
@end_column = nd_args.last_column
@@ -498,8 +615,9 @@ module ErrorHighlight
@beg_column = nd_parent.last_column
@end_column = @node.last_column
else
- @snippet = @fetch[@node.last_lineno]
+ fetch_line(@node.last_lineno)
if @snippet[...@node.last_column].match(/#{ Regexp.quote(const) }\z/)
+ @beg_lineno = @end_lineno = @node.last_lineno
@beg_column = $~.begin(0)
@end_column = $~.end(0)
end
@@ -513,7 +631,7 @@ module ErrorHighlight
nd_lhs, op, _nd_rhs = @node.children
*nd_parent_lhs, _const = nd_lhs.children
if @name == op
- @snippet = @fetch[nd_lhs.last_lineno]
+ fetch_line(nd_lhs.last_lineno)
if @snippet.match(/\G\s*(#{ Regexp.quote(op) })=/, nd_lhs.last_column)
@beg_column = $~.begin(1)
@end_column = $~.end(1)
@@ -523,22 +641,297 @@ module ErrorHighlight
@end_column = nd_lhs.last_column
if nd_parent_lhs.empty? # example: ::C += 1
if nd_lhs.first_lineno == nd_lhs.last_lineno
- @snippet = @fetch[nd_lhs.last_lineno]
+ fetch_line(nd_lhs.last_lineno)
@beg_column = nd_lhs.first_column
end
else # example: Foo::Bar::C += 1
if nd_parent_lhs.last.last_lineno == nd_lhs.last_lineno
- @snippet = @fetch[nd_lhs.last_lineno]
+ fetch_line(nd_lhs.last_lineno)
@beg_column = nd_parent_lhs.last.last_column
end
end
end
end
+ # Example:
+ # def bar; end
+ # ^^^
+ def spot_defn
+ mid, = @node.children
+ fetch_line(@node.first_lineno)
+ if @snippet.match(/\Gdef\s+(#{ Regexp.quote(mid) }\b)/, @node.first_column)
+ @beg_column = $~.begin(1)
+ @end_column = $~.end(1)
+ end
+ end
+
+ # Example:
+ # def Foo.bar; end
+ # ^^^^
+ def spot_defs
+ nd_recv, mid, = @node.children
+ fetch_line(nd_recv.last_lineno)
+ if @snippet.match(/\G\s*(\.\s*#{ Regexp.quote(mid) }\b)/, nd_recv.last_column)
+ @beg_column = $~.begin(1)
+ @end_column = $~.end(1)
+ end
+ end
+
+ # Example:
+ # -> { ... }
+ # ^^
+ def spot_lambda
+ fetch_line(@node.first_lineno)
+ if @snippet.match(/\G->/, @node.first_column)
+ @beg_column = $~.begin(0)
+ @end_column = $~.end(0)
+ end
+ end
+
+ # Example:
+ # lambda { ... }
+ # ^
+ # define_method :foo do
+ # ^^
+ def spot_iter
+ _nd_fcall, nd_scope = @node.children
+ fetch_line(nd_scope.first_lineno)
+ if @snippet.match(/\G(?:do\b|\{)/, nd_scope.first_column)
+ @beg_column = $~.begin(0)
+ @end_column = $~.end(0)
+ end
+ end
+
def fetch_line(lineno)
@beg_lineno = @end_lineno = lineno
@snippet = @fetch[lineno]
end
+
+ # Take a location from the prism parser and set the necessary instance
+ # variables.
+ def prism_location(location)
+ @beg_lineno = location.start_line
+ @beg_column = location.start_column
+ @end_lineno = location.end_line
+ @end_column = location.end_column
+ @snippet = @fetch[@beg_lineno, @end_lineno]
+ end
+
+ # Example:
+ # x.foo
+ # ^^^^
+ # x.foo(42)
+ # ^^^^
+ # x&.foo
+ # ^^^^^
+ # x[42]
+ # ^^^^
+ # x.foo = 1
+ # ^^^^^^
+ # x[42] = 1
+ # ^^^^^^
+ # x + 1
+ # ^
+ # +x
+ # ^
+ # foo(42)
+ # ^^^
+ # foo 42
+ # ^^^
+ # foo
+ # ^^^
+ def prism_spot_call_for_name
+ # Explicitly turn off foo.() syntax because error_highlight expects this
+ # to not work.
+ return nil if @node.name == :call && @node.message_loc.nil?
+
+ location = @node.message_loc || @node.call_operator_loc || @node.location
+ location = @node.call_operator_loc.join(location) if @node.call_operator_loc&.start_line == location.start_line
+
+ # If the method name ends with "=" but the message does not, then this is
+ # a method call using the "attribute assignment" syntax
+ # (e.g., foo.bar = 1). In this case we need to go retrieve the = sign and
+ # add it to the location.
+ if (name = @node.name).end_with?("=") && !@node.message.end_with?("=")
+ location = location.adjoin("=")
+ end
+
+ prism_location(location)
+
+ if !name.end_with?("=") && !name.match?(/[[:alpha:]_\[]/)
+ # If the method name is an operator, then error_highlight only
+ # highlights the first line.
+ fetch_line(location.start_line)
+ end
+ end
+
+ # Example:
+ # x.foo(42)
+ # ^^
+ # x[42]
+ # ^^
+ # x.foo = 1
+ # ^
+ # x[42] = 1
+ # ^^^^^^^
+ # x[] = 1
+ # ^^^^^
+ # x + 1
+ # ^
+ # foo(42)
+ # ^^
+ # foo 42
+ # ^^
+ def prism_spot_call_for_args
+ # Disallow highlighting arguments if there are no arguments.
+ return if @node.arguments.nil?
+
+ # Explicitly turn off foo.() syntax because error_highlight expects this
+ # to not work.
+ return nil if @node.name == :call && @node.message_loc.nil?
+
+ if @node.name == :[]= && @node.opening == "[" && (@node.arguments&.arguments || []).length == 1
+ prism_location(@node.opening_loc.copy(start_offset: @node.opening_loc.start_offset + 1).join(@node.arguments.location))
+ else
+ prism_location(@node.arguments.location)
+ end
+ end
+
+ # Example:
+ # x += 1
+ # ^
+ def prism_spot_local_variable_operator_write_for_name
+ prism_location(@node.binary_operator_loc.chop)
+ end
+
+ # Example:
+ # x += 1
+ # ^
+ def prism_spot_local_variable_operator_write_for_args
+ prism_location(@node.value.location)
+ end
+
+ # Example:
+ # x.foo += 42
+ # ^^^ (for foo)
+ # x.foo += 42
+ # ^ (for +)
+ # x.foo += 42
+ # ^^^^^^^ (for foo=)
+ def prism_spot_call_operator_write_for_name
+ if !@name.start_with?(/[[:alpha:]_]/)
+ prism_location(@node.binary_operator_loc.chop)
+ else
+ location = @node.message_loc
+ if @node.call_operator_loc.start_line == location.start_line
+ location = @node.call_operator_loc.join(location)
+ end
+
+ location = location.adjoin("=") if @name.end_with?("=")
+ prism_location(location)
+ end
+ end
+
+ # Example:
+ # x.foo += 42
+ # ^^
+ def prism_spot_call_operator_write_for_args
+ prism_location(@node.value.location)
+ end
+
+ # Example:
+ # x[1] += 42
+ # ^^^ (for [])
+ # x[1] += 42
+ # ^ (for +)
+ # x[1] += 42
+ # ^^^^^^ (for []=)
+ def prism_spot_index_operator_write_for_name
+ case @name
+ when :[]
+ prism_location(@node.opening_loc.join(@node.closing_loc))
+ when :[]=
+ prism_location(@node.opening_loc.join(@node.closing_loc).adjoin("="))
+ else
+ # Explicitly turn off foo[] += 1 syntax when the operator is not on
+ # the same line because error_highlight expects this to not work.
+ return nil if @node.binary_operator_loc.start_line != @node.opening_loc.start_line
+
+ prism_location(@node.binary_operator_loc.chop)
+ end
+ end
+
+ # Example:
+ # x[1] += 42
+ # ^^^^^^^^
+ def prism_spot_index_operator_write_for_args
+ opening_loc =
+ if @node.arguments.nil?
+ @node.opening_loc.copy(start_offset: @node.opening_loc.start_offset + 1)
+ else
+ @node.arguments.location
+ end
+
+ prism_location(opening_loc.join(@node.value.location))
+ end
+
+ # Example:
+ # Foo
+ # ^^^
+ def prism_spot_constant_read
+ prism_location(@node.location)
+ end
+
+ # Example:
+ # Foo::Bar
+ # ^^^^^
+ def prism_spot_constant_path
+ if @node.parent && @node.parent.location.end_line == @node.location.end_line
+ fetch_line(@node.parent.location.end_line)
+ prism_location(@node.delimiter_loc.join(@node.name_loc))
+ else
+ fetch_line(@node.location.end_line)
+ location = @node.name_loc
+ location = @node.delimiter_loc.join(location) if @node.delimiter_loc.end_line == location.start_line
+ prism_location(location)
+ end
+ end
+
+ # Example:
+ # Foo::Bar += 1
+ # ^^^^^^^^
+ def prism_spot_constant_path_operator_write
+ if @name == (target = @node.target).name
+ prism_location(target.delimiter_loc.join(target.name_loc))
+ else
+ prism_location(@node.binary_operator_loc.chop)
+ end
+ end
+
+ # Example:
+ # def foo()
+ # ^^^
+ def prism_spot_def_for_name
+ location = @node.name_loc
+ location = @node.operator_loc.join(location) if @node.operator_loc
+ prism_location(location)
+ end
+
+ # Example:
+ # -> x, y { }
+ # ^^
+ def prism_spot_lambda_for_name
+ prism_location(@node.operator_loc)
+ end
+
+ # Example:
+ # lambda { }
+ # ^
+ # define_method :foo do |x, y|
+ # ^
+ def prism_spot_block_for_name
+ prism_location(@node.opening_loc)
+ end
end
private_constant :Spotter
diff --git a/lib/error_highlight/core_ext.rb b/lib/error_highlight/core_ext.rb
index b69093f74e..c3354f46cd 100644
--- a/lib/error_highlight/core_ext.rb
+++ b/lib/error_highlight/core_ext.rb
@@ -3,9 +3,38 @@ require_relative "formatter"
module ErrorHighlight
module CoreExt
private def generate_snippet
- spot = ErrorHighlight.spot(self)
- return "" unless spot
- return ErrorHighlight.formatter.message_for(spot)
+ if ArgumentError === self && message =~ /\A(?:wrong number of arguments|missing keyword[s]?|unknown keyword[s]?|no keywords accepted)\b/
+ locs = self.backtrace_locations
+ return "" if locs.size < 2
+ callee_loc, caller_loc = locs
+ callee_spot = ErrorHighlight.spot(self, backtrace_location: callee_loc, point_type: :name)
+ caller_spot = ErrorHighlight.spot(self, backtrace_location: caller_loc, point_type: :name)
+ if caller_spot && callee_spot &&
+ caller_loc.path == callee_loc.path &&
+ caller_loc.lineno == callee_loc.lineno &&
+ caller_spot == callee_spot
+ callee_loc = callee_spot = nil
+ end
+ ret = +"\n"
+ [["caller", caller_loc, caller_spot], ["callee", callee_loc, callee_spot]].each do |header, loc, spot|
+ out = nil
+ if loc
+ out = " #{ header }: #{ loc.path }:#{ loc.lineno }"
+ if spot
+ _, _, snippet, highlight = ErrorHighlight.formatter.message_for(spot).lines
+ out += "\n | #{ snippet } #{ highlight }"
+ else
+ # do nothing
+ end
+ end
+ ret << "\n" + out if out
+ end
+ ret
+ else
+ spot = ErrorHighlight.spot(self)
+ return "" unless spot
+ return ErrorHighlight.formatter.message_for(spot)
+ end
end
if Exception.method_defined?(:detailed_message)
diff --git a/lib/error_highlight/error_highlight.gemspec b/lib/error_highlight/error_highlight.gemspec
index b2da18df83..edfc4b776f 100644
--- a/lib/error_highlight/error_highlight.gemspec
+++ b/lib/error_highlight/error_highlight.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/error_highlight"
spec.license = "MIT"
- spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0.dev")
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
diff --git a/lib/error_highlight/formatter.rb b/lib/error_highlight/formatter.rb
index 20ca78d468..d2fad9e75c 100644
--- a/lib/error_highlight/formatter.rb
+++ b/lib/error_highlight/formatter.rb
@@ -1,15 +1,66 @@
module ErrorHighlight
class DefaultFormatter
+ MIN_SNIPPET_WIDTH = 20
+
def self.message_for(spot)
# currently only a one-line code snippet is supported
- if spot[:first_lineno] == spot[:last_lineno]
- indent = spot[:snippet][0...spot[:first_column]].gsub(/[^\t]/, " ")
- marker = indent + "^" * (spot[:last_column] - spot[:first_column])
+ return "" unless spot[:first_lineno] == spot[:last_lineno]
+
+ snippet = spot[:snippet]
+ first_column = spot[:first_column]
+ last_column = spot[:last_column]
+ ellipsis = "..."
+
+ # truncate snippet to fit in the viewport
+ if max_snippet_width && snippet.size > max_snippet_width
+ available_width = max_snippet_width - ellipsis.size
+ center = first_column - max_snippet_width / 2
+
+ visible_start = last_column < available_width ? 0 : [center, 0].max
+ visible_end = visible_start + max_snippet_width
+ visible_start = snippet.size - max_snippet_width if visible_end > snippet.size
+
+ prefix = visible_start.positive? ? ellipsis : ""
+ suffix = visible_end < snippet.size ? ellipsis : ""
- "\n\n#{ spot[:snippet] }#{ marker }"
- else
- ""
+ snippet = prefix + snippet[(visible_start + prefix.size)...(visible_end - suffix.size)] + suffix
+ snippet << "\n" unless snippet.end_with?("\n")
+
+ first_column -= visible_start
+ last_column = [last_column - visible_start, snippet.size - 1].min
end
+
+ indent = snippet[0...first_column].gsub(/[^\t]/, " ")
+ marker = indent + "^" * (last_column - first_column)
+
+ "\n\n#{ snippet }#{ marker }"
+ end
+
+ def self.max_snippet_width
+ return if Ractor.current[:__error_highlight_max_snippet_width__] == :disabled
+
+ Ractor.current[:__error_highlight_max_snippet_width__] ||= terminal_width
+ end
+
+ def self.max_snippet_width=(width)
+ return Ractor.current[:__error_highlight_max_snippet_width__] = :disabled if width.nil?
+
+ width = width.to_i
+
+ if width < MIN_SNIPPET_WIDTH
+ warn "'max_snippet_width' adjusted to minimum value of #{MIN_SNIPPET_WIDTH}."
+ width = MIN_SNIPPET_WIDTH
+ end
+
+ Ractor.current[:__error_highlight_max_snippet_width__] = width
+ end
+
+ def self.terminal_width
+ # lazy load io/console to avoid loading it when 'max_snippet_width' is manually set
+ require "io/console"
+ $stderr.winsize[1] if $stderr.tty?
+ rescue LoadError, NoMethodError, SystemCallError
+ # skip truncation when terminal window size is unavailable
end
end
diff --git a/lib/error_highlight/version.rb b/lib/error_highlight/version.rb
index 5afe5f06d6..f0a5376b14 100644
--- a/lib/error_highlight/version.rb
+++ b/lib/error_highlight/version.rb
@@ -1,3 +1,3 @@
module ErrorHighlight
- VERSION = "0.5.1"
+ VERSION = "0.7.1"
end
diff --git a/lib/fileutils.gemspec b/lib/fileutils.gemspec
index 76baea3039..2603d664da 100644
--- a/lib/fileutils.gemspec
+++ b/lib/fileutils.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.description = "Several file utility methods for copying, moving, removing, etc."
s.require_path = %w{lib}
- s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb"]
+ s.files = ["COPYING", "BSDL", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb"]
s.required_ruby_version = ">= 2.5.0"
s.authors = ["Minero Aoki"]
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 3e698a7372..0706e007ca 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -180,7 +180,8 @@ end
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
#
module FileUtils
- VERSION = "1.7.0"
+ # The version number.
+ VERSION = "1.8.0"
def self.private_module_function(name) #:nodoc:
module_function name
@@ -705,11 +706,12 @@ module FileUtils
#
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
if relative
- return ln_sr(src, dest, force: force, noop: noop, verbose: verbose)
+ return ln_sr(src, dest, force: force, target_directory: target_directory, noop: noop, verbose: verbose)
end
- fu_output_message "ln -s#{force ? 'f' : ''} #{[src,dest].flatten.join ' '}" if verbose
+ fu_output_message "ln -s#{force ? 'f' : ''}#{
+ target_directory ? '' : 'T'} #{[src,dest].flatten.join ' '}" if verbose
return if noop
- fu_each_src_dest0(src, dest) do |s,d|
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
remove_file d, true if force
File.symlink s, d
end
@@ -729,42 +731,37 @@ module FileUtils
# Like FileUtils.ln_s, but create links relative to +dest+.
#
def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
- options = "#{force ? 'f' : ''}#{target_directory ? '' : 'T'}"
- dest = File.path(dest)
- srcs = Array(src)
- link = proc do |s, target_dir_p = true|
- s = File.path(s)
- if target_dir_p
- d = File.join(destdirs = dest, File.basename(s))
+ cmd = "ln -s#{force ? 'f' : ''}#{target_directory ? '' : 'T'}" if verbose
+ fu_each_src_dest0(src, dest, target_directory) do |s,d|
+ if target_directory
+ parent = File.dirname(d)
+ destdirs = fu_split_path(parent)
+ real_ddirs = fu_split_path(File.realpath(parent))
else
- destdirs = File.dirname(d = dest)
+ destdirs ||= fu_split_path(dest)
+ real_ddirs ||= fu_split_path(File.realdirpath(dest))
end
- destdirs = fu_split_path(File.realpath(destdirs))
- if fu_starting_path?(s)
- srcdirs = fu_split_path((File.realdirpath(s) rescue File.expand_path(s)))
- base = fu_relative_components_from(srcdirs, destdirs)
- s = File.join(*base)
+ srcdirs = fu_split_path(s)
+ i = fu_common_components(srcdirs, destdirs)
+ n = destdirs.size - i
+ n -= 1 unless target_directory
+ link1 = fu_clean_components(*Array.new([n, 0].max, '..'), *srcdirs[i..-1])
+ begin
+ real_sdirs = fu_split_path(File.realdirpath(s)) rescue nil
+ rescue
else
- srcdirs = fu_clean_components(*fu_split_path(s))
- base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs)
- while srcdirs.first&. == ".." and base.last&.!=("..") and !fu_starting_path?(base.last)
- srcdirs.shift
- base.pop
- end
- s = File.join(*base, *srcdirs)
+ i = fu_common_components(real_sdirs, real_ddirs)
+ n = real_ddirs.size - i
+ n -= 1 unless target_directory
+ link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
+ link1 = link2 if link1.size > link2.size
end
- fu_output_message "ln -s#{options} #{s} #{d}" if verbose
+ s = File.join(link1)
+ fu_output_message [cmd, s, d].flatten.join(' ') if verbose
next if noop
remove_file d, true if force
File.symlink s, d
end
- case srcs.size
- when 0
- when 1
- link[srcs[0], target_directory && File.directory?(dest)]
- else
- srcs.each(&link)
- end
end
module_function :ln_sr
@@ -799,13 +796,13 @@ module FileUtils
# File.file?('dest1/dir1/t2.txt') # => true
# File.file?('dest1/dir1/t3.txt') # => true
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference_root: true</tt> - dereferences +src+ if it is a symbolic link.
- # - <tt>remove_destination: true</tt> - removes +dest+ before creating links.
+ # - +dereference_root+ - dereferences +src+ if it is a symbolic link (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before creating links (+false+ by default).
#
# Raises an exception if +dest+ is the path to an existing file or directory
- # and keyword argument <tt>remove_destination: true</tt> is not given.
+ # and optional argument +remove_destination+ is not given.
#
# Related: FileUtils.ln (has different options).
#
@@ -1028,12 +1025,12 @@ module FileUtils
# directories, and symbolic links;
# other file types (FIFO streams, device files, etc.) are not supported.
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference_root: true</tt> - if +src+ is a symbolic link,
- # follows the link.
- # - <tt>preserve: true</tt> - preserves file times.
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
+ # - +dereference_root+ - if +src+ is a symbolic link,
+ # follows the link (+false+ by default).
+ # - +preserve+ - preserves file times (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
#
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
@@ -1064,12 +1061,12 @@ module FileUtils
# FileUtils.copy_file('src0.txt', 'dest0.txt')
# File.file?('dest0.txt') # => true
#
- # Keyword arguments:
+ # Optional arguments:
#
- # - <tt>dereference: false</tt> - if +src+ is a symbolic link,
- # does not follow the link.
- # - <tt>preserve: true</tt> - preserves file times.
- # - <tt>remove_destination: true</tt> - removes +dest+ before copying files.
+ # - +dereference+ - if +src+ is a symbolic link,
+ # follows the link (+true+ by default).
+ # - +preserve+ - preserves file times (+false+ by default).
+ # - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
#
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
@@ -1490,7 +1487,8 @@ module FileUtils
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def remove_dir(path, force = false)
- remove_entry path, force # FIXME?? check if it is a directory
+ raise Errno::ENOTDIR, path unless force or File.directory?(path)
+ remove_entry path, force
end
module_function :remove_dir
@@ -1651,7 +1649,7 @@ module FileUtils
when "a"
mask | 07777
else
- raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
+ raise ArgumentError, "invalid 'who' symbol in file mode: #{chr}"
end
end
end
@@ -1705,7 +1703,7 @@ module FileUtils
copy_mask = user_mask(chr)
(current_mode & copy_mask) / (copy_mask & 0111) * (user_mask & 0111)
else
- raise ArgumentError, "invalid `perm' symbol in file mode: #{chr}"
+ raise ArgumentError, "invalid 'perm' symbol in file mode: #{chr}"
end
end
@@ -2028,21 +2026,22 @@ module FileUtils
private
- module StreamUtils_
+ module StreamUtils_ # :nodoc:
+
private
case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
when /mswin|mingw/
- def fu_windows?; true end
+ def fu_windows?; true end #:nodoc:
else
- def fu_windows?; false end
+ def fu_windows?; false end #:nodoc:
end
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
IO.copy_stream(src, dest)
end
- def fu_stream_blksize(*streams)
+ def fu_stream_blksize(*streams) #:nodoc:
streams.each do |s|
next unless s.respond_to?(:stat)
size = fu_blksize(s.stat)
@@ -2051,14 +2050,14 @@ module FileUtils
fu_default_blksize()
end
- def fu_blksize(st)
+ def fu_blksize(st) #:nodoc:
s = st.blksize
return nil unless s
return nil if s == 0
s
end
- def fu_default_blksize
+ def fu_default_blksize #:nodoc:
1024
end
end
@@ -2473,6 +2472,10 @@ module FileUtils
def fu_each_src_dest0(src, dest, target_directory = true) #:nodoc:
if tmp = Array.try_convert(src)
+ unless target_directory or tmp.size <= 1
+ tmp = tmp.map {|f| File.path(f)} # A workaround for RBS
+ raise ArgumentError, "extra target #{tmp}"
+ end
tmp.each do |s|
s = File.path(s)
yield s, (target_directory ? File.join(dest, File.basename(s)) : dest)
@@ -2503,11 +2506,15 @@ module FileUtils
end
private_module_function :fu_output_message
- def fu_split_path(path)
+ def fu_split_path(path) #:nodoc:
path = File.path(path)
list = []
until (parent, base = File.split(path); parent == path or parent == ".")
- list << base
+ if base != '..' and list.last == '..' and !(fu_have_symlink? && File.symlink?(path))
+ list.pop
+ else
+ list << base
+ end
path = parent
end
list << path
@@ -2515,16 +2522,16 @@ module FileUtils
end
private_module_function :fu_split_path
- def fu_relative_components_from(target, base) #:nodoc:
+ def fu_common_components(target, base) #:nodoc:
i = 0
while target[i]&.== base[i]
i += 1
end
- Array.new(base.size-i, '..').concat(target[i..-1])
+ i
end
- private_module_function :fu_relative_components_from
+ private_module_function :fu_common_components
- def fu_clean_components(*comp)
+ def fu_clean_components(*comp) #:nodoc:
comp.shift while comp.first == "."
return comp if comp.empty?
clean = [comp.shift]
@@ -2532,7 +2539,7 @@ module FileUtils
while c = comp.shift
if c == ".." and clean.last != ".." and !(fu_have_symlink? && File.symlink?(path))
clean.pop
- path.chomp!(%r((?<=\A|/)[^/]+/\z), "")
+ path.sub!(%r((?<=\A|/)[^/]+/\z), "")
else
clean << c
path << c << "/"
@@ -2543,11 +2550,11 @@ module FileUtils
private_module_function :fu_clean_components
if fu_windows?
- def fu_starting_path?(path)
+ def fu_starting_path?(path) #:nodoc:
path&.start_with?(%r(\w:|/))
end
else
- def fu_starting_path?(path)
+ def fu_starting_path?(path) #:nodoc:
path&.start_with?("/")
end
end
diff --git a/lib/find.gemspec b/lib/find.gemspec
index 3f0aadcdae..aef24a5028 100644
--- a/lib/find.gemspec
+++ b/lib/find.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "find"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ['Kazuki Tsujimoto']
spec.email = ['kazuki@callcc.net']
@@ -18,7 +25,5 @@ Gem::Specification.new do |spec|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
end
diff --git a/lib/find.rb b/lib/find.rb
index 9bee99c66d..d9b81eb92d 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -3,38 +3,50 @@
# find.rb: the Find module for processing all files under a given directory.
#
+# :markup: markdown
#
-# The +Find+ module supports the top-down traversal of a set of file paths.
-#
-# For example, to total the size of all files under your home directory,
-# ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
-#
-# require 'find'
-#
-# total_size = 0
-#
-# Find.find(ENV["HOME"]) do |path|
-# if FileTest.directory?(path)
-# if File.basename(path).start_with?('.')
-# Find.prune # Don't look any further into this directory.
-# else
-# next
-# end
-# else
-# total_size += FileTest.size(path)
-# end
-# end
-#
+# \Module \Find supports the top-down traversal of entries in the file system.
module Find
+ # The version string
+ VERSION = "0.2.0"
+
+ # :markup: markdown
#
- # Calls the associated block with the name of every file and directory listed
- # as arguments, then recursively on their subdirectories, and so on.
+ # With a block given, performs a depth-first traversal of each given path in `paths`;
+ # calls the block with each found file or directory path:
#
- # Returns an enumerator if no block is given.
+ # ```ruby
+ # paths = []
+ # Find.find('bin', 'jit') {|path| paths << path }
+ # paths
+ # # =>
+ # # ["bin",
+ # # "bin/gem",
+ # # "jit",
+ # # "jit/Cargo.toml",
+ # # "jit/src",
+ # # "jit/src/lib.rs"]
+ # ```
#
- # See the +Find+ module documentation for an example.
+ # Raises an exception if a given path cannot be read.
#
+ # When keyword argument `ignore_error` is given as `true` (the default),
+ # certain exceptions during traversal are ignored (i.e., silently rescued):
+ # Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG, Errno::EINVAL;
+ # when given as `false`, no exceptions are rescued.
+ #
+ # Note that these exceptions may be ignored only in `Find` traversal code;
+ # an exception raised before traversal begins,
+ # or raised while in the block is not ignored.
+ # Each of the calls below raises an Errno::ENOENT exception that is not ignored:
+ #
+ # ```ruby
+ # Find.find('nosuch') { }
+ # Find.find('lib') {|entry| raise Errno::ENOENT }
+ # ```
+ #
+ # With no block given, returns a new Enumerator.
def find(*paths, ignore_error: true) # :yield: path
block_given? or return enum_for(__method__, *paths, ignore_error: ignore_error)
@@ -72,13 +84,26 @@ module Find
nil
end
+ # :markup: markdown
+ #
+ # call-seq:
+ # Find.prune
+ #
+ # This method is meaningful only within a block given with Find.find.
#
- # Skips the current file or directory, restarting the loop with the next
- # entry. If the current file is a directory, that directory will not be
- # recursively entered. Meaningful only within the block associated with
- # Find::find.
+ # Inside such a block,
+ # "prunes" the traversed file tree by not descending into the current directory:
#
- # See the +Find+ module documentation for an example.
+ # ```ruby
+ # files = []
+ # Find.find('.') do |path|
+ # Find.prune if File.basename(path) == 'test'
+ # next unless File.file?(path) && File.extname(path) == '.rb'
+ # files << path
+ # end
+ # files.size # => 6690
+ # files.take(3) # => ["./KNOWNBUGS.rb", "./array.rb", "./ast.rb"]
+ # ```
#
def prune
throw :prune
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 71b4e6adad..175d6d9c6b 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -109,11 +109,11 @@
# +delegate.rb+.
#
module Forwardable
- require 'forwardable/impl'
-
# Version of +forwardable.rb+
- VERSION = "1.3.3"
+ VERSION = "1.4.0"
VERSION.freeze
+
+ # Version for backward compatibility
FORWARDABLE_VERSION = VERSION
FORWARDABLE_VERSION.freeze
@@ -190,9 +190,7 @@ module Forwardable
# If it's not a class or module, it's an instance
mod = Module === self ? self : singleton_class
- ret = mod.module_eval(&gen)
- mod.__send__(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
- ret
+ mod.module_eval(&gen)
end
alias delegate instance_delegate
@@ -206,36 +204,33 @@ module Forwardable
if Module === obj ?
obj.method_defined?(accessor) || obj.private_method_defined?(accessor) :
obj.respond_to?(accessor, true)
- accessor = "#{accessor}()"
+ accessor = "(#{accessor}())"
end
- method_call = ".__send__(:#{method}, *args, &block)"
- if _valid_method?(method)
+ args = RUBY_VERSION >= '2.7' ? '...' : '*args, &block'
+ method_call = ".__send__(:#{method}, #{args})"
+ if method.match?(/\A[_a-zA-Z]\w*[?!]?\z/)
loc, = caller_locations(2,1)
pre = "_ ="
mesg = "#{Module === obj ? obj : obj.class}\##{ali} at #{loc.path}:#{loc.lineno} forwarding to private method "
- method_call = "#{<<-"begin;"}\n#{<<-"end;".chomp}"
- begin;
- unless defined? _.#{method}
- ::Kernel.warn #{mesg.dump}"\#{_.class}"'##{method}', uplevel: 1
- _#{method_call}
- else
- _.#{method}(*args, &block)
- end
- end;
+ method_call = <<~RUBY.chomp
+ if defined?(_.#{method})
+ _.#{method}(#{args})
+ else
+ ::Kernel.warn #{mesg.dump}"\#{_.class}"'##{method}', uplevel: 1
+ _#{method_call}
+ end
+ RUBY
end
- _compile_method("#{<<-"begin;"}\n#{<<-"end;"}", __FILE__, __LINE__+1)
- begin;
+ eval(<<~RUBY, nil, __FILE__, __LINE__ + 1)
proc do
- def #{ali}(*args, &block)
- #{pre}
- begin
- #{accessor}
- end#{method_call}
+ def #{ali}(#{args})
+ #{pre}#{accessor}
+ #{method_call}
end
end
- end;
+ RUBY
end
end
@@ -310,9 +305,7 @@ module SingleForwardable
def def_single_delegator(accessor, method, ali = method)
gen = Forwardable._delegator_method(self, accessor, method, ali)
- ret = instance_eval(&gen)
- singleton_class.__send__(:ruby2_keywords, ali) if RUBY_VERSION >= '2.7'
- ret
+ instance_eval(&gen)
end
alias delegate single_delegate
diff --git a/lib/forwardable/forwardable.gemspec b/lib/forwardable/forwardable.gemspec
index 9ad59c5f8a..1b539bcfcb 100644
--- a/lib/forwardable/forwardable.gemspec
+++ b/lib/forwardable/forwardable.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.required_ruby_version = '>= 2.4.0'
- spec.files = ["forwardable.gemspec", "lib/forwardable.rb", "lib/forwardable/impl.rb"]
+ spec.files = ["forwardable.gemspec", "lib/forwardable.rb"]
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
diff --git a/lib/forwardable/impl.rb b/lib/forwardable/impl.rb
deleted file mode 100644
index 0322c136db..0000000000
--- a/lib/forwardable/impl.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Forwardable
- # :stopdoc:
-
- def self._valid_method?(method)
- catch {|tag|
- eval("BEGIN{throw tag}; ().#{method}", binding, __FILE__, __LINE__)
- }
- rescue SyntaxError
- false
- else
- true
- end
-
- def self._compile_method(src, file, line)
- eval(src, nil, file, line)
- end
-end
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
deleted file mode 100644
index 5ae0e1497c..0000000000
--- a/lib/getoptlong.rb
+++ /dev/null
@@ -1,867 +0,0 @@
-# frozen_string_literal: true
-#
-# GetoptLong for Ruby
-#
-# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara.
-#
-# You may redistribute and/or modify this library under the same license
-# terms as Ruby.
-
-# \Class \GetoptLong provides parsing both for options
-# and for regular arguments.
-#
-# Using \GetoptLong, you can define options for your program.
-# The program can then capture and respond to whatever options
-# are included in the command that executes the program.
-#
-# A simple example: file <tt>simple.rb</tt>:
-#
-# :include: ../sample/getoptlong/simple.rb
-#
-# If you are somewhat familiar with options,
-# you may want to skip to this
-# {full example}[#class-GetoptLong-label-Full+Example].
-#
-# == Options
-#
-# A \GetoptLong option has:
-#
-# - A string <em>option name</em>.
-# - Zero or more string <em>aliases</em> for the name.
-# - An <em>option type</em>.
-#
-# Options may be defined by calling singleton method GetoptLong.new,
-# which returns a new \GetoptLong object.
-# Options may then be processed by calling other methods
-# such as GetoptLong#each.
-#
-# === Option Name and Aliases
-#
-# In the array that defines an option,
-# the first element is the string option name.
-# Often the name takes the 'long' form, beginning with two hyphens.
-#
-# The option name may have any number of aliases,
-# which are defined by additional string elements.
-#
-# The name and each alias must be of one of two forms:
-#
-# - Two hyphens, followed by one or more letters.
-# - One hyphen, followed by a single letter.
-#
-# File <tt>aliases.rb</tt>:
-#
-# :include: ../sample/getoptlong/aliases.rb
-#
-# An option may be cited by its name,
-# or by any of its aliases;
-# the parsed option always reports the name, not an alias:
-#
-# $ ruby aliases.rb -a -p --xxx --aaa -x
-#
-# Output:
-#
-# ["--xxx", ""]
-# ["--xxx", ""]
-# ["--xxx", ""]
-# ["--xxx", ""]
-# ["--xxx", ""]
-#
-#
-# An option may also be cited by an abbreviation of its name or any alias,
-# as long as that abbreviation is unique among the options.
-#
-# File <tt>abbrev.rb</tt>:
-#
-# :include: ../sample/getoptlong/abbrev.rb
-#
-# Command line:
-#
-# $ ruby abbrev.rb --xxx --xx --xyz --xy
-#
-# Output:
-#
-# ["--xxx", ""]
-# ["--xxx", ""]
-# ["--xyz", ""]
-# ["--xyz", ""]
-#
-# This command line raises GetoptLong::AmbiguousOption:
-#
-# $ ruby abbrev.rb --x
-#
-# === Repetition
-#
-# An option may be cited more than once:
-#
-# $ ruby abbrev.rb --xxx --xyz --xxx --xyz
-#
-# Output:
-#
-# ["--xxx", ""]
-# ["--xyz", ""]
-# ["--xxx", ""]
-# ["--xyz", ""]
-#
-# === Treating Remaining Options as Arguments
-#
-# A option-like token that appears
-# anywhere after the token <tt>--</tt> is treated as an ordinary argument,
-# and is not processed as an option:
-#
-# $ ruby abbrev.rb --xxx --xyz -- --xxx --xyz
-#
-# Output:
-#
-# ["--xxx", ""]
-# ["--xyz", ""]
-#
-# === Option Types
-#
-# Each option definition includes an option type,
-# which controls whether the option takes an argument.
-#
-# File <tt>types.rb</tt>:
-#
-# :include: ../sample/getoptlong/types.rb
-#
-# Note that an option type has to do with the <em>option argument</em>
-# (whether it is required, optional, or forbidden),
-# not with whether the option itself is required.
-#
-# ==== Option with Required Argument
-#
-# An option of type <tt>GetoptLong::REQUIRED_ARGUMENT</tt>
-# must be followed by an argument, which is associated with that option:
-#
-# $ ruby types.rb --xxx foo
-#
-# Output:
-#
-# ["--xxx", "foo"]
-#
-# If the option is not last, its argument is whatever follows it
-# (even if the argument looks like another option):
-#
-# $ ruby types.rb --xxx --yyy
-#
-# Output:
-#
-# ["--xxx", "--yyy"]
-#
-# If the option is last, an exception is raised:
-#
-# $ ruby types.rb
-# # Raises GetoptLong::MissingArgument
-#
-# ==== Option with Optional Argument
-#
-# An option of type <tt>GetoptLong::OPTIONAL_ARGUMENT</tt>
-# may be followed by an argument, which if given is associated with that option.
-#
-# If the option is last, it does not have an argument:
-#
-# $ ruby types.rb --yyy
-#
-# Output:
-#
-# ["--yyy", ""]
-#
-# If the option is followed by another option, it does not have an argument:
-#
-# $ ruby types.rb --yyy --zzz
-#
-# Output:
-#
-# ["--yyy", ""]
-# ["--zzz", ""]
-#
-# Otherwise the option is followed by its argument, which is associated
-# with that option:
-#
-# $ ruby types.rb --yyy foo
-#
-# Output:
-#
-# ["--yyy", "foo"]
-#
-# ==== Option with No Argument
-#
-# An option of type <tt>GetoptLong::NO_ARGUMENT</tt> takes no argument:
-#
-# ruby types.rb --zzz foo
-#
-# Output:
-#
-# ["--zzz", ""]
-#
-# === ARGV
-#
-# You can process options either with method #each and a block,
-# or with method #get.
-#
-# During processing, each found option is removed, along with its argument
-# if there is one.
-# After processing, each remaining element was neither an option
-# nor the argument for an option.
-#
-# File <tt>argv.rb</tt>:
-#
-# :include: ../sample/getoptlong/argv.rb
-#
-# Command line:
-#
-# $ ruby argv.rb --xxx Foo --yyy Bar Baz --zzz Bat Bam
-#
-# Output:
-#
-# Original ARGV: ["--xxx", "Foo", "--yyy", "Bar", "Baz", "--zzz", "Bat", "Bam"]
-# ["--xxx", "Foo"]
-# ["--yyy", "Bar"]
-# ["--zzz", ""]
-# Remaining ARGV: ["Baz", "Bat", "Bam"]
-#
-# === Ordering
-#
-# There are three settings that control the way the options
-# are interpreted:
-#
-# - +PERMUTE+.
-# - +REQUIRE_ORDER+.
-# - +RETURN_IN_ORDER+.
-#
-# The initial setting for a new \GetoptLong object is +REQUIRE_ORDER+
-# if environment variable +POSIXLY_CORRECT+ is defined, +PERMUTE+ otherwise.
-#
-# ==== PERMUTE Ordering
-#
-# In the +PERMUTE+ ordering, options and other, non-option,
-# arguments may appear in any order and any mixture.
-#
-# File <tt>permute.rb</tt>:
-#
-# :include: ../sample/getoptlong/permute.rb
-#
-# Command line:
-#
-# $ ruby permute.rb Foo --zzz Bar --xxx Baz --yyy Bat Bam --xxx Bag Bah
-#
-# Output:
-#
-# Original ARGV: ["Foo", "--zzz", "Bar", "--xxx", "Baz", "--yyy", "Bat", "Bam", "--xxx", "Bag", "Bah"]
-# ["--zzz", ""]
-# ["--xxx", "Baz"]
-# ["--yyy", "Bat"]
-# ["--xxx", "Bag"]
-# Remaining ARGV: ["Foo", "Bar", "Bam", "Bah"]
-#
-# ==== REQUIRE_ORDER Ordering
-#
-# In the +REQUIRE_ORDER+ ordering, all options precede all non-options;
-# that is, each word after the first non-option word
-# is treated as a non-option word (even if it begins with a hyphen).
-#
-# File <tt>require_order.rb</tt>:
-#
-# :include: ../sample/getoptlong/require_order.rb
-#
-# Command line:
-#
-# $ ruby require_order.rb --xxx Foo Bar --xxx Baz --yyy Bat -zzz
-#
-# Output:
-#
-# Original ARGV: ["--xxx", "Foo", "Bar", "--xxx", "Baz", "--yyy", "Bat", "-zzz"]
-# ["--xxx", "Foo"]
-# Remaining ARGV: ["Bar", "--xxx", "Baz", "--yyy", "Bat", "-zzz"]
-#
-# ==== RETURN_IN_ORDER Ordering
-#
-# In the +RETURN_IN_ORDER+ ordering, every word is treated as an option.
-# A word that begins with a hyphen (or two) is treated in the usual way;
-# a word +word+ that does not so begin is treated as an option
-# whose name is an empty string, and whose value is +word+.
-#
-# File <tt>return_in_order.rb</tt>:
-#
-# :include: ../sample/getoptlong/return_in_order.rb
-#
-# Command line:
-#
-# $ ruby return_in_order.rb Foo --xxx Bar Baz --zzz Bat Bam
-#
-# Output:
-#
-# Original ARGV: ["Foo", "--xxx", "Bar", "Baz", "--zzz", "Bat", "Bam"]
-# ["", "Foo"]
-# ["--xxx", "Bar"]
-# ["", "Baz"]
-# ["--zzz", ""]
-# ["", "Bat"]
-# ["", "Bam"]
-# Remaining ARGV: []
-#
-# === Full Example
-#
-# File <tt>fibonacci.rb</tt>:
-#
-# :include: ../sample/getoptlong/fibonacci.rb
-#
-# Command line:
-#
-# $ ruby fibonacci.rb
-#
-# Output:
-#
-# Option --number is required.
-# Usage:
-#
-# -n n, --number n:
-# Compute Fibonacci number for n.
-# -v [boolean], --verbose [boolean]:
-# Show intermediate results; default is 'false'.
-# -h, --help:
-# Show this help.
-#
-# Command line:
-#
-# $ ruby fibonacci.rb --number
-#
-# Raises GetoptLong::MissingArgument:
-#
-# fibonacci.rb: option `--number' requires an argument
-#
-# Command line:
-#
-# $ ruby fibonacci.rb --number 6
-#
-# Output:
-#
-# 8
-#
-# Command line:
-#
-# $ ruby fibonacci.rb --number 6 --verbose
-#
-# Output:
-# 1
-# 2
-# 3
-# 5
-# 8
-#
-# Command line:
-#
-# $ ruby fibonacci.rb --number 6 --verbose yes
-#
-# Output:
-#
-# --verbose argument must be true or false
-# Usage:
-#
-# -n n, --number n:
-# Compute Fibonacci number for n.
-# -v [boolean], --verbose [boolean]:
-# Show intermediate results; default is 'false'.
-# -h, --help:
-# Show this help.
-#
-class GetoptLong
- # Version.
- VERSION = "0.2.0"
-
- #
- # Orderings.
- #
- ORDERINGS = [REQUIRE_ORDER = 0, PERMUTE = 1, RETURN_IN_ORDER = 2]
-
- #
- # Argument flags.
- #
- ARGUMENT_FLAGS = [NO_ARGUMENT = 0, REQUIRED_ARGUMENT = 1,
- OPTIONAL_ARGUMENT = 2]
-
- #
- # Status codes.
- #
- STATUS_YET, STATUS_STARTED, STATUS_TERMINATED = 0, 1, 2
-
- #
- # Error types.
- #
- class Error < StandardError; end
- class AmbiguousOption < Error; end
- class NeedlessArgument < Error; end
- class MissingArgument < Error; end
- class InvalidOption < Error; end
-
- #
- # Returns a new \GetoptLong object based on the given +arguments+.
- # See {Options}[#class-GetoptLong-label-Options].
- #
- # Example:
- #
- # :include: ../sample/getoptlong/simple.rb
- #
- # Raises an exception if:
- #
- # - Any of +arguments+ is not an array.
- # - Any option name or alias is not a string.
- # - Any option type is invalid.
- #
- def initialize(*arguments)
- #
- # Current ordering.
- #
- if ENV.include?('POSIXLY_CORRECT')
- @ordering = REQUIRE_ORDER
- else
- @ordering = PERMUTE
- end
-
- #
- # Hash table of option names.
- # Keys of the table are option names, and their values are canonical
- # names of the options.
- #
- @canonical_names = Hash.new
-
- #
- # Hash table of argument flags.
- # Keys of the table are option names, and their values are argument
- # flags of the options.
- #
- @argument_flags = Hash.new
-
- #
- # Whether error messages are output to $stderr.
- #
- @quiet = false
-
- #
- # Status code.
- #
- @status = STATUS_YET
-
- #
- # Error code.
- #
- @error = nil
-
- #
- # Error message.
- #
- @error_message = nil
-
- #
- # Rest of catenated short options.
- #
- @rest_singles = ''
-
- #
- # List of non-option-arguments.
- # Append them to ARGV when option processing is terminated.
- #
- @non_option_arguments = Array.new
-
- if 0 < arguments.length
- set_options(*arguments)
- end
- end
-
- # Sets the ordering; see {Ordering}[#class-GetoptLong-label-Ordering];
- # returns the new ordering.
- #
- # If the given +ordering+ is +PERMUTE+ and environment variable
- # +POSIXLY_CORRECT+ is defined, sets the ordering to +REQUIRE_ORDER+;
- # otherwise sets the ordering to +ordering+:
- #
- # options = GetoptLong.new
- # options.ordering == GetoptLong::PERMUTE # => true
- # options.ordering = GetoptLong::RETURN_IN_ORDER
- # options.ordering == GetoptLong::RETURN_IN_ORDER # => true
- # ENV['POSIXLY_CORRECT'] = 'true'
- # options.ordering = GetoptLong::PERMUTE
- # options.ordering == GetoptLong::REQUIRE_ORDER # => true
- #
- # Raises an exception if +ordering+ is invalid.
- #
- def ordering=(ordering)
- #
- # The method is failed if option processing has already started.
- #
- if @status != STATUS_YET
- set_error(ArgumentError, "argument error")
- raise RuntimeError,
- "invoke ordering=, but option processing has already started"
- end
-
- #
- # Check ordering.
- #
- if !ORDERINGS.include?(ordering)
- raise ArgumentError, "invalid ordering `#{ordering}'"
- end
- if ordering == PERMUTE && ENV.include?('POSIXLY_CORRECT')
- @ordering = REQUIRE_ORDER
- else
- @ordering = ordering
- end
- end
-
- #
- # Returns the ordering setting.
- #
- attr_reader :ordering
-
- #
- # Replaces existing options with those given by +arguments+,
- # which have the same form as the arguments to ::new;
- # returns +self+.
- #
- # Raises an exception if option processing has begun.
- #
- def set_options(*arguments)
- #
- # The method is failed if option processing has already started.
- #
- if @status != STATUS_YET
- raise RuntimeError,
- "invoke set_options, but option processing has already started"
- end
-
- #
- # Clear tables of option names and argument flags.
- #
- @canonical_names.clear
- @argument_flags.clear
-
- arguments.each do |arg|
- 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'.
- #
- argument_flag = nil
- arg.each do |i|
- if ARGUMENT_FLAGS.include?(i)
- if argument_flag != nil
- raise ArgumentError, "too many argument-flags"
- end
- argument_flag = i
- end
- end
-
- raise ArgumentError, "no argument-flag" if argument_flag == nil
-
- canonical_name = nil
- arg.each do |i|
- #
- # Check an option name.
- #
- next if i == argument_flag
- begin
- if !i.is_a?(String) || i !~ /\A-([^-]|-.+)\z/
- raise ArgumentError, "an invalid option `#{i}'"
- end
- if (@canonical_names.include?(i))
- raise ArgumentError, "option redefined `#{i}'"
- end
- rescue
- @canonical_names.clear
- @argument_flags.clear
- raise
- end
-
- #
- # Register the option (`i') to the `@canonical_names' and
- # `@canonical_names' Hashes.
- #
- if canonical_name == nil
- canonical_name = i
- end
- @canonical_names[i] = canonical_name
- @argument_flags[i] = argument_flag
- end
- raise ArgumentError, "no option name" if canonical_name == nil
- end
- return self
- end
-
- #
- # Sets quiet mode and returns the given argument:
- #
- # - When +false+ or +nil+, error messages are written to <tt>$stdout</tt>.
- # - Otherwise, error messages are not written.
- #
- attr_writer :quiet
-
- #
- # Returns the quiet mode setting.
- #
- attr_reader :quiet
- alias quiet? quiet
-
- #
- # Terminate option processing;
- # returns +nil+ if processing has already terminated;
- # otherwise returns +self+.
- #
- def terminate
- return nil if @status == STATUS_TERMINATED
- raise RuntimeError, "an error has occurred" if @error != nil
-
- @status = STATUS_TERMINATED
- @non_option_arguments.reverse_each do |argument|
- ARGV.unshift(argument)
- end
-
- @canonical_names = nil
- @argument_flags = nil
- @rest_singles = nil
- @non_option_arguments = nil
-
- return self
- end
-
- #
- # Returns +true+ if option processing has terminated, +false+ otherwise.
- #
- def terminated?
- return @status == STATUS_TERMINATED
- end
-
- #
- # \Set an error (a protected method).
- #
- def set_error(type, message)
- $stderr.print("#{$0}: #{message}\n") if !@quiet
-
- @error = type
- @error_message = message
- @canonical_names = nil
- @argument_flags = nil
- @rest_singles = nil
- @non_option_arguments = nil
-
- raise type, message
- end
- protected :set_error
-
- #
- # Returns whether option processing has failed.
- #
- attr_reader :error
- alias error? error
-
- # Return the appropriate error message in POSIX-defined format.
- # If no error has occurred, returns +nil+.
- #
- def error_message
- return @error_message
- end
-
- #
- # Returns the next option as a 2-element array containing:
- #
- # - The option name (the name itself, not an alias).
- # - The option value.
- #
- # Returns +nil+ if there are no more options.
- #
- def get
- option_name, option_argument = nil, ''
-
- #
- # Check status.
- #
- return nil if @error != nil
- case @status
- when STATUS_YET
- @status = STATUS_STARTED
- when STATUS_TERMINATED
- return nil
- end
-
- #
- # Get next option argument.
- #
- if 0 < @rest_singles.length
- argument = '-' + @rest_singles
- elsif (ARGV.length == 0)
- terminate
- return nil
- elsif @ordering == PERMUTE
- while 0 < ARGV.length && ARGV[0] !~ /\A-./
- @non_option_arguments.push(ARGV.shift)
- end
- if ARGV.length == 0
- terminate
- return nil
- end
- argument = ARGV.shift
- elsif @ordering == REQUIRE_ORDER
- if (ARGV[0] !~ /\A-./)
- terminate
- return nil
- end
- argument = ARGV.shift
- else
- argument = ARGV.shift
- end
-
- #
- # Check the special argument `--'.
- # `--' indicates the end of the option list.
- #
- if argument == '--' && @rest_singles.length == 0
- terminate
- return nil
- end
-
- #
- # Check for long and short options.
- #
- if argument =~ /\A(--[^=]+)/ && @rest_singles.length == 0
- #
- # This is a long style option, which start with `--'.
- #
- pattern = $1
- if @canonical_names.include?(pattern)
- option_name = pattern
- else
- #
- # The option `option_name' is not registered in `@canonical_names'.
- # It may be an abbreviated.
- #
- matches = []
- @canonical_names.each_key do |key|
- if key.index(pattern) == 0
- option_name = key
- matches << key
- end
- end
- if 2 <= matches.length
- set_error(AmbiguousOption, "option `#{argument}' is ambiguous between #{matches.join(', ')}")
- elsif matches.length == 0
- set_error(InvalidOption, "unrecognized option `#{argument}'")
- end
- end
-
- #
- # Check an argument to the option.
- #
- if @argument_flags[option_name] == REQUIRED_ARGUMENT
- if argument =~ /=(.*)/m
- option_argument = $1
- elsif 0 < ARGV.length
- option_argument = ARGV.shift
- else
- set_error(MissingArgument,
- "option `#{argument}' requires an argument")
- end
- elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
- if argument =~ /=(.*)/m
- option_argument = $1
- elsif 0 < ARGV.length && ARGV[0] !~ /\A-./
- option_argument = ARGV.shift
- else
- option_argument = ''
- end
- elsif argument =~ /=(.*)/m
- set_error(NeedlessArgument,
- "option `#{option_name}' doesn't allow an argument")
- end
-
- elsif argument =~ /\A(-(.))(.*)/m
- #
- # This is a short style option, which start with `-' (not `--').
- # Short options may be catenated (e.g. `-l -g' is equivalent to
- # `-lg').
- #
- option_name, ch, @rest_singles = $1, $2, $3
-
- if @canonical_names.include?(option_name)
- #
- # The option `option_name' is found in `@canonical_names'.
- # Check its argument.
- #
- if @argument_flags[option_name] == REQUIRED_ARGUMENT
- if 0 < @rest_singles.length
- option_argument = @rest_singles
- @rest_singles = ''
- elsif 0 < ARGV.length
- option_argument = ARGV.shift
- else
- # 1003.2 specifies the format of this message.
- set_error(MissingArgument, "option requires an argument -- #{ch}")
- end
- elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
- if 0 < @rest_singles.length
- option_argument = @rest_singles
- @rest_singles = ''
- elsif 0 < ARGV.length && ARGV[0] !~ /\A-./
- option_argument = ARGV.shift
- else
- option_argument = ''
- end
- end
- else
- #
- # This is an invalid option.
- # 1003.2 specifies the format of this message.
- #
- if ENV.include?('POSIXLY_CORRECT')
- set_error(InvalidOption, "invalid option -- #{ch}")
- else
- set_error(InvalidOption, "invalid option -- #{ch}")
- end
- end
- else
- #
- # This is a non-option argument.
- # Only RETURN_IN_ORDER fell into here.
- #
- return '', argument
- end
-
- return @canonical_names[option_name], option_argument
- end
- alias get_option get
-
- #
- # Calls the given block with each option;
- # each option is a 2-element array containing:
- #
- # - The option name (the name itself, not an alias).
- # - The option value.
- #
- # Example:
- #
- # :include: ../sample/getoptlong/each.rb
- #
- # Command line:
- #
- # ruby each.rb -xxx Foo -x Bar --yyy Baz -y Bat --zzz
- #
- # Output:
- #
- # Original ARGV: ["-xxx", "Foo", "-x", "Bar", "--yyy", "Baz", "-y", "Bat", "--zzz"]
- # ["--xxx", "xx"]
- # ["--xxx", "Bar"]
- # ["--yyy", "Baz"]
- # ["--yyy", "Bat"]
- # ["--zzz", ""]
- # Remaining ARGV: ["Foo"]
- #
- def each
- loop do
- option_name, option_argument = get_option
- break if option_name == nil
- yield option_name, option_argument
- end
- end
- alias each_option each
-end
diff --git a/lib/getoptlong/getoptlong.gemspec b/lib/getoptlong/getoptlong.gemspec
deleted file mode 100644
index dfe087b886..0000000000
--- a/lib/getoptlong/getoptlong.gemspec
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{GetoptLong for Ruby}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/getoptlong"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
-end
diff --git a/lib/ipaddr.gemspec b/lib/ipaddr.gemspec
index 1f4798e43a..cabc9161ba 100644
--- a/lib/ipaddr.gemspec
+++ b/lib/ipaddr.gemspec
@@ -29,8 +29,8 @@ Both IPv4 and IPv6 are supported.
spec.homepage = "https://github.com/ruby/ipaddr"
spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.files = ["LICENSE.txt", "README.md", "ipaddr.gemspec", "lib/ipaddr.rb"]
+ spec.files = ["LICENSE.txt", "README.md", "lib/ipaddr.rb"]
spec.require_paths = ["lib"]
- spec.required_ruby_version = ">= 2.3"
+ spec.required_ruby_version = ">= 2.4"
end
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 7a5cf94830..70b804f642 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -40,7 +40,8 @@ require 'socket'
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
class IPAddr
- VERSION = "1.2.5"
+ # The version string
+ VERSION = "1.2.9"
# 32 bit mask for IPv4
IN4MASK = 0xffffffff
@@ -52,7 +53,7 @@ class IPAddr
# Regexp _internally_ used for parsing IPv4 address.
RE_IPV4ADDRLIKE = %r{
\A
- (\d+) \. (\d+) \. (\d+) \. (\d+)
+ \d+ \. \d+ \. \d+ \. \d+
\z
}x
@@ -110,8 +111,13 @@ class IPAddr
# Convert a network byte ordered string form of an IP address into
# human readable form.
+ # It expects the string to be encoded in Encoding::ASCII_8BIT (BINARY).
def self.ntop(addr)
- case addr.size
+ if addr.is_a?(String) && addr.encoding != Encoding::BINARY
+ raise InvalidAddressError, "invalid encoding (given #{addr.encoding}, expected BINARY)"
+ end
+
+ case addr.bytesize
when 4
addr.unpack('C4').join('.')
when 16
@@ -146,8 +152,22 @@ class IPAddr
return self.clone.set(addr_mask(~@addr))
end
+ # Returns a new ipaddr greater than the original address by offset
+ def +(offset)
+ self.clone.set(@addr + offset, @family)
+ end
+
+ # Returns a new ipaddr less than the original address by offset
+ def -(offset)
+ self.clone.set(@addr - offset, @family)
+ end
+
# Returns true if two ipaddrs are equal.
def ==(other)
+ if other.nil?
+ return false
+ end
+
other = coerce_other(other)
rescue
false
@@ -176,9 +196,7 @@ class IPAddr
def include?(other)
other = coerce_other(other)
return false unless other.family == family
- range = to_range
- other = other.to_range
- range.begin <= other.begin && range.end >= other.end
+ begin_addr <= other.begin_addr && end_addr >= other.end_addr
end
alias === include?
@@ -224,6 +242,28 @@ class IPAddr
return str
end
+ # Returns a string containing the IP address representation with prefix.
+ def as_json(*)
+ if ipv4? && prefix == 32
+ to_s
+ elsif ipv6? && prefix == 128
+ to_s
+ else
+ cidr
+ end
+ end
+
+ # Returns a json string containing the IP address representation.
+ def to_json(*a)
+ %Q{"#{as_json(*a)}"}
+ end
+
+ # Returns a string containing the IP address representation in
+ # cidr notation
+ def cidr
+ "#{to_s}/#{prefix}"
+ end
+
# Returns a network byte ordered string form of the IP address.
def hton
case @family
@@ -249,12 +289,17 @@ class IPAddr
end
# Returns true if the ipaddr is a loopback address.
+ # Loopback IPv4 addresses in the IPv4-mapped IPv6
+ # address range are also considered as loopback addresses.
def loopback?
case @family
when Socket::AF_INET
- @addr & 0xff000000 == 0x7f000000
+ @addr & 0xff000000 == 0x7f000000 # 127.0.0.1/8
when Socket::AF_INET6
- @addr == 1
+ @addr == 1 || # ::1
+ (@addr >> 32 == 0xffff && (
+ @addr & 0xff000000 == 0x7f000000 # ::ffff:127.0.0.1/8
+ ))
else
raise AddressFamilyError, "unsupported address family"
end
@@ -263,7 +308,8 @@ class IPAddr
# Returns true if the ipaddr is a private address. IPv4 addresses
# in 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC
# 1918 and IPv6 Unique Local Addresses in fc00::/7 as defined in RFC
- # 4193 are considered private.
+ # 4193 are considered private. Private IPv4 addresses in the
+ # IPv4-mapped IPv6 address range are also considered private.
def private?
case @family
when Socket::AF_INET
@@ -271,22 +317,31 @@ class IPAddr
@addr & 0xfff00000 == 0xac100000 || # 172.16.0.0/12
@addr & 0xffff0000 == 0xc0a80000 # 192.168.0.0/16
when Socket::AF_INET6
- @addr & 0xfe00_0000_0000_0000_0000_0000_0000_0000 == 0xfc00_0000_0000_0000_0000_0000_0000_0000
+ @addr & 0xfe00_0000_0000_0000_0000_0000_0000_0000 == 0xfc00_0000_0000_0000_0000_0000_0000_0000 ||
+ (@addr >> 32 == 0xffff && (
+ @addr & 0xff000000 == 0x0a000000 || # ::ffff:10.0.0.0/8
+ @addr & 0xfff00000 == 0xac100000 || # ::ffff:172.16.0.0/12
+ @addr & 0xffff0000 == 0xc0a80000 # ::ffff:192.168.0.0/16
+ ))
else
raise AddressFamilyError, "unsupported address family"
end
end
# Returns true if the ipaddr is a link-local address. IPv4
- # addresses in 169.254.0.0/16 reserved by RFC 3927 and Link-Local
+ # addresses in 169.254.0.0/16 reserved by RFC 3927 and link-local
# IPv6 Unicast Addresses in fe80::/10 reserved by RFC 4291 are
- # considered link-local.
+ # considered link-local. Link-local IPv4 addresses in the
+ # IPv4-mapped IPv6 address range are also considered link-local.
def link_local?
case @family
when Socket::AF_INET
@addr & 0xffff0000 == 0xa9fe0000 # 169.254.0.0/16
when Socket::AF_INET6
- @addr & 0xffc0_0000_0000_0000_0000_0000_0000_0000 == 0xfe80_0000_0000_0000_0000_0000_0000_0000
+ @addr & 0xffc0_0000_0000_0000_0000_0000_0000_0000 == 0xfe80_0000_0000_0000_0000_0000_0000_0000 || # fe80::/10
+ (@addr >> 32 == 0xffff && (
+ @addr & 0xffff0000 == 0xa9fe0000 # ::ffff:169.254.0.0/16
+ ))
else
raise AddressFamilyError, "unsupported address family"
end
@@ -303,7 +358,7 @@ class IPAddr
_ipv4_compat?
end
- def _ipv4_compat?
+ def _ipv4_compat? # :nodoc:
if !ipv6? || (@addr >> 32) != 0
return false
end
@@ -317,7 +372,7 @@ class IPAddr
# into an IPv4-mapped IPv6 address.
def ipv4_mapped
if !ipv4?
- raise InvalidAddressError, "not an IPv4 address: #{@addr}"
+ raise InvalidAddressError, "not an IPv4 address: #{to_s}"
end
clone = self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
clone.instance_variable_set(:@mask_addr, @mask_addr | 0xffffffffffffffffffffffff00000000)
@@ -329,9 +384,11 @@ class IPAddr
def ipv4_compat
warn "IPAddr\##{__callee__} is obsolete", uplevel: 1 if $VERBOSE
if !ipv4?
- raise InvalidAddressError, "not an IPv4 address: #{@addr}"
+ raise InvalidAddressError, "not an IPv4 address: #{to_s}"
end
- return self.clone.set(@addr, Socket::AF_INET6)
+ clone = self.clone.set(@addr, Socket::AF_INET6)
+ clone.instance_variable_set(:@mask_addr, @mask_addr | 0xffffffffffffffffffffffff00000000)
+ clone
end
# Returns a new ipaddr built by converting the IPv6 address into a
@@ -360,7 +417,7 @@ class IPAddr
# Returns a string for DNS reverse lookup compatible with RFC3172.
def ip6_arpa
if !ipv6?
- raise InvalidAddressError, "not an IPv6 address: #{@addr}"
+ raise InvalidAddressError, "not an IPv6 address: #{to_s}"
end
return _reverse + ".ip6.arpa"
end
@@ -368,7 +425,7 @@ class IPAddr
# Returns a string for DNS reverse lookup compatible with RFC1886.
def ip6_int
if !ipv6?
- raise InvalidAddressError, "not an IPv6 address: #{@addr}"
+ raise InvalidAddressError, "not an IPv6 address: #{to_s}"
end
return _reverse + ".ip6.int"
end
@@ -400,17 +457,6 @@ class IPAddr
# Creates a Range object for the network address.
def to_range
- begin_addr = (@addr & @mask_addr)
-
- case @family
- when Socket::AF_INET
- end_addr = (@addr | (IN4MASK ^ @mask_addr))
- when Socket::AF_INET6
- end_addr = (@addr | (IN6MASK ^ @mask_addr))
- else
- raise AddressFamilyError, "unsupported address family"
- end
-
self.class.new(begin_addr, @family)..self.class.new(end_addr, @family)
end
@@ -439,7 +485,7 @@ class IPAddr
when Integer
mask!(prefix)
else
- raise InvalidPrefixError, "prefix must be an integer: #{@addr}"
+ raise InvalidPrefixError, "prefix must be an integer"
end
end
@@ -464,6 +510,20 @@ class IPAddr
_to_string(@mask_addr)
end
+ # Returns the wildcard mask in string format e.g. 0.0.255.255
+ def wildcard_mask
+ case @family
+ when Socket::AF_INET
+ mask = IN4MASK ^ @mask_addr
+ when Socket::AF_INET6
+ mask = IN6MASK ^ @mask_addr
+ else
+ raise AddressFamilyError, "unsupported address family"
+ end
+
+ _to_string(mask)
+ end
+
# Returns the IPv6 zone identifier, if present.
# Raises InvalidAddressError if not an IPv6 address.
def zone_id
@@ -490,6 +550,23 @@ class IPAddr
end
protected
+ # :stopdoc:
+
+ def begin_addr
+ @addr & @mask_addr
+ end
+
+ def end_addr
+ case @family
+ when Socket::AF_INET
+ @addr | (IN4MASK ^ @mask_addr)
+ when Socket::AF_INET6
+ @addr | (IN6MASK ^ @mask_addr)
+ else
+ raise AddressFamilyError, "unsupported address family"
+ end
+ end
+ #:startdoc:
# Set +@addr+, the internal stored ip address, to given +addr+. The
# parameter +addr+ is validated using the first +family+ member,
@@ -498,11 +575,11 @@ class IPAddr
case family[0] ? family[0] : @family
when Socket::AF_INET
if addr < 0 || addr > IN4MASK
- raise InvalidAddressError, "invalid address: #{@addr}"
+ raise InvalidAddressError, "invalid address: #{addr}"
end
when Socket::AF_INET6
if addr < 0 || addr > IN6MASK
- raise InvalidAddressError, "invalid address: #{@addr}"
+ raise InvalidAddressError, "invalid address: #{addr}"
end
else
raise AddressFamilyError, "unsupported address family"
@@ -529,12 +606,12 @@ class IPAddr
else
m = IPAddr.new(mask)
if m.family != @family
- raise InvalidPrefixError, "address family is not same: #{@addr}"
+ raise InvalidPrefixError, "address family is not same"
end
@mask_addr = m.to_i
n = @mask_addr ^ m.instance_variable_get(:@mask_addr)
unless ((n + 1) & n).zero?
- raise InvalidPrefixError, "invalid mask #{mask}: #{@addr}"
+ raise InvalidPrefixError, "invalid mask #{mask}"
end
@addr &= @mask_addr
return self
@@ -545,13 +622,13 @@ class IPAddr
case @family
when Socket::AF_INET
if prefixlen < 0 || prefixlen > 32
- raise InvalidPrefixError, "invalid length: #{@addr}"
+ raise InvalidPrefixError, "invalid length"
end
masklen = 32 - prefixlen
@mask_addr = ((IN4MASK >> masklen) << masklen)
when Socket::AF_INET6
if prefixlen < 0 || prefixlen > 128
- raise InvalidPrefixError, "invalid length: #{@addr}"
+ raise InvalidPrefixError, "invalid length"
end
masklen = 128 - prefixlen
@mask_addr = ((IN6MASK >> masklen) << masklen)
@@ -631,6 +708,7 @@ class IPAddr
end
end
+ # :stopdoc:
def coerce_other(other)
case other
when IPAddr
@@ -647,12 +725,12 @@ class IPAddr
when Array
octets = addr
else
- m = RE_IPV4ADDRLIKE.match(addr) or return nil
- octets = m.captures
+ RE_IPV4ADDRLIKE.match?(addr) or return nil
+ octets = addr.split('.')
end
octets.inject(0) { |i, s|
- (n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{@addr}"
- s.match(/\A0./) and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{@addr}"
+ (n = s.to_i) < 256 or raise InvalidAddressError, "invalid address: #{addr}"
+ (s != '0') && s.start_with?('0') and raise InvalidAddressError, "zero-filled number in IPv4 address is ambiguous: #{addr}"
i << 8 | n
}
end
@@ -669,19 +747,19 @@ class IPAddr
right = ''
when RE_IPV6ADDRLIKE_COMPRESSED
if $4
- left.count(':') <= 6 or raise InvalidAddressError, "invalid address: #{@addr}"
+ left.count(':') <= 6 or raise InvalidAddressError, "invalid address: #{left}"
addr = in_addr($~[4,4])
left = $1
right = $3 + '0:0'
else
left.count(':') <= ($1.empty? || $2.empty? ? 8 : 7) or
- raise InvalidAddressError, "invalid address: #{@addr}"
+ raise InvalidAddressError, "invalid address: #{left}"
left = $1
right = $2
addr = 0
end
else
- raise InvalidAddressError, "invalid address: #{@addr}"
+ raise InvalidAddressError, "invalid address: #{left}"
end
l = left.split(':')
r = right.split(':')
@@ -742,7 +820,7 @@ unless Socket.const_defined? :AF_INET6
class << IPSocket
private
- def valid_v6?(addr)
+ def valid_v6?(addr) # :nodoc:
case addr
when IPAddr::RE_IPV6ADDRLIKE_FULL
if $2
diff --git a/lib/irb.rb b/lib/irb.rb
deleted file mode 100644
index cef6ebc952..0000000000
--- a/lib/irb.rb
+++ /dev/null
@@ -1,997 +0,0 @@
-# frozen_string_literal: false
-#
-# irb.rb - irb main module
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require "ripper"
-require "reline"
-
-require_relative "irb/init"
-require_relative "irb/context"
-require_relative "irb/extend-command"
-
-require_relative "irb/ruby-lex"
-require_relative "irb/input-method"
-require_relative "irb/locale"
-require_relative "irb/color"
-
-require_relative "irb/version"
-require_relative "irb/easter-egg"
-
-# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
-# expressions read from the standard input.
-#
-# The +irb+ command from your shell will start the interpreter.
-#
-# == Usage
-#
-# Use of irb is easy if you know Ruby.
-#
-# When executing irb, prompts are displayed as follows. Then, enter the Ruby
-# expression. An input is executed when it is syntactically complete.
-#
-# $ irb
-# irb(main):001:0> 1+2
-# #=> 3
-# irb(main):002:0> class Foo
-# irb(main):003:1> def foo
-# irb(main):004:2> print 1
-# irb(main):005:2> end
-# irb(main):006:1> end
-# #=> nil
-#
-# The singleline editor module or multiline editor module can be used with irb.
-# Use of multiline editor is default if it's installed.
-#
-# == Command line options
-#
-# :include: ./irb/lc/help-message
-#
-# == Commands
-#
-# The following commands are available on IRB.
-#
-# * cwws
-# * Show the current workspace.
-# * cb, cws, chws
-# * Change the current workspace to an object.
-# * bindings, workspaces
-# * Show workspaces.
-# * pushb, pushws
-# * Push an object to the workspace stack.
-# * popb, popws
-# * Pop a workspace from the workspace stack.
-# * load
-# * Load a Ruby file.
-# * require
-# * Require a Ruby file.
-# * source
-# * Loads a given file in the current session.
-# * irb
-# * Start a child IRB.
-# * jobs
-# * List of current sessions.
-# * fg
-# * Switches to the session of the given number.
-# * kill
-# * Kills the session with the given number.
-# * help
-# * Enter the mode to look up RI documents.
-# * irb_info
-# * Show information about IRB.
-# * ls
-# * Show methods, constants, and variables.
-# -g [query] or -G [query] allows you to filter out the output.
-# * measure
-# * measure enables the mode to measure processing time. measure :off disables it.
-# * $, show_source
-# * Show the source code of a given method or constant.
-# * @, whereami
-# * Show the source code around binding.irb again.
-# * debug
-# * Start the debugger of debug.gem.
-# * break, delete, next, step, continue, finish, backtrace, info, catch
-# * Start the debugger of debug.gem and run the command on it.
-#
-# == Configuration
-#
-# IRB reads a personal initialization file when it's invoked.
-# IRB searches a file in the following order and loads the first one found.
-#
-# * <tt>$IRBRC</tt> (if <tt>$IRBRC</tt> is set)
-# * <tt>$XDG_CONFIG_HOME/irb/irbrc</tt> (if <tt>$XDG_CONFIG_HOME</tt> is set)
-# * <tt>~/.irbrc</tt>
-# * +.config/irb/irbrc+
-# * +.irbrc+
-# * +irb.rc+
-# * +_irbrc+
-# * <code>$irbrc</code>
-#
-# The following are alternatives to the command line options. To use them type
-# as follows in an +irb+ session:
-#
-# IRB.conf[:IRB_NAME]="irb"
-# IRB.conf[:INSPECT_MODE]=nil
-# IRB.conf[:IRB_RC] = nil
-# IRB.conf[:BACK_TRACE_LIMIT]=16
-# IRB.conf[:USE_LOADER] = false
-# IRB.conf[:USE_MULTILINE] = nil
-# IRB.conf[:USE_SINGLELINE] = nil
-# IRB.conf[:USE_COLORIZE] = true
-# IRB.conf[:USE_TRACER] = false
-# IRB.conf[:USE_AUTOCOMPLETE] = true
-# IRB.conf[:IGNORE_SIGINT] = true
-# IRB.conf[:IGNORE_EOF] = false
-# IRB.conf[:PROMPT_MODE] = :DEFAULT
-# IRB.conf[:PROMPT] = {...}
-#
-# === Auto indentation
-#
-# To disable auto-indent mode in irb, add the following to your +.irbrc+:
-#
-# IRB.conf[:AUTO_INDENT] = false
-#
-# === Autocompletion
-#
-# To disable autocompletion for irb, add the following to your +.irbrc+:
-#
-# IRB.conf[:USE_AUTOCOMPLETE] = false
-#
-# === History
-#
-# By default, irb will store the last 1000 commands you used in
-# <code>IRB.conf[:HISTORY_FILE]</code> (<code>~/.irb_history</code> by default).
-#
-# If you want to disable history, add the following to your +.irbrc+:
-#
-# IRB.conf[:SAVE_HISTORY] = nil
-#
-# See IRB::Context#save_history= for more information.
-#
-# The history of _results_ of commands evaluated is not stored by default,
-# but can be turned on to be stored with this +.irbrc+ setting:
-#
-# IRB.conf[:EVAL_HISTORY] = <number>
-#
-# See IRB::Context#eval_history= and History class. The history of command
-# results is not permanently saved in any file.
-#
-# == Customizing the IRB Prompt
-#
-# In order to customize the prompt, you can change the following Hash:
-#
-# IRB.conf[:PROMPT]
-#
-# This example can be used in your +.irbrc+
-#
-# IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
-# :AUTO_INDENT => false, # disables auto-indent mode
-# :PROMPT_I => ">> ", # simple prompt
-# :PROMPT_S => nil, # prompt for continuated strings
-# :PROMPT_C => nil, # prompt for continuated statement
-# :RETURN => " ==>%s\n" # format to return value
-# }
-#
-# IRB.conf[:PROMPT_MODE] = :MY_PROMPT
-#
-# Or, invoke irb with the above prompt mode by:
-#
-# irb --prompt my-prompt
-#
-# Constants +PROMPT_I+, +PROMPT_S+ and +PROMPT_C+ specify the format. In the
-# prompt specification, some special strings are available:
-#
-# %N # command name which is running
-# %m # to_s of main object (self)
-# %M # inspect of main object (self)
-# %l # type of string(", ', /, ]), `]' is inner %w[...]
-# %NNi # indent level. NN is digits and means as same as printf("%NNd").
-# # It can be omitted
-# %NNn # line number.
-# %% # %
-#
-# For instance, the default prompt mode is defined as follows:
-#
-# IRB.conf[:PROMPT_MODE][:DEFAULT] = {
-# :PROMPT_I => "%N(%m):%03n:%i> ",
-# :PROMPT_N => "%N(%m):%03n:%i> ",
-# :PROMPT_S => "%N(%m):%03n:%i%l ",
-# :PROMPT_C => "%N(%m):%03n:%i* ",
-# :RETURN => "%s\n" # used to printf
-# }
-#
-# irb comes with a number of available modes:
-#
-# # :NULL:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :DEFAULT:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # => %s
-# # :CLASSIC:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # %s
-# # :SIMPLE:
-# # :PROMPT_I: ! '>> '
-# # :PROMPT_N: ! '>> '
-# # :PROMPT_S:
-# # :PROMPT_C: ! '?> '
-# # :RETURN: |
-# # => %s
-# # :INF_RUBY:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :AUTO_INDENT: true
-# # :XMP:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |2
-# # ==>%s
-#
-# == Restrictions
-#
-# Because irb evaluates input immediately after it is syntactically complete,
-# the results may be slightly different than directly using Ruby.
-#
-# == IRB Sessions
-#
-# IRB has a special feature, that allows you to manage many sessions at once.
-#
-# You can create new sessions with Irb.irb, and get a list of current sessions
-# with the +jobs+ command in the prompt.
-#
-# === Commands
-#
-# JobManager provides commands to handle the current sessions:
-#
-# jobs # List of current sessions
-# fg # Switches to the session of the given number
-# kill # Kills the session with the given number
-#
-# The +exit+ command, or ::irb_exit, will quit the current session and call any
-# exit hooks with IRB.irb_at_exit.
-#
-# A few commands for loading files within the session are also available:
-#
-# +source+::
-# Loads a given file in the current session and displays the source lines,
-# see IrbLoader#source_file
-# +irb_load+::
-# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
-# +irb_require+::
-# Loads the given file similarly to Kernel#require
-#
-# === Configuration
-#
-# The command line options, or IRB.conf, specify the default behavior of
-# Irb.irb.
-#
-# On the other hand, each conf in IRB@Command+line+options is used to
-# individually configure IRB.irb.
-#
-# If a proc is set for <code>IRB.conf[:IRB_RC]</code>, its will be invoked after execution
-# of that proc with the context of the current session as its argument. Each
-# session can be configured using this mechanism.
-#
-# === Session variables
-#
-# There are a few variables in every Irb session that can come in handy:
-#
-# <code>_</code>::
-# The value command executed, as a local variable
-# <code>__</code>::
-# The history of evaluated commands. Available only if
-# <code>IRB.conf[:EVAL_HISTORY]</code> is not +nil+ (which is the default).
-# See also IRB::Context#eval_history= and IRB::History.
-# <code>__[line_no]</code>::
-# Returns the evaluation value at the given line number, +line_no+.
-# If +line_no+ is a negative, the return value +line_no+ many lines before
-# the most recent return value.
-#
-# === Example using IRB Sessions
-#
-# # invoke a new session
-# irb(main):001:0> irb
-# # list open sessions
-# irb.1(main):001:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : stop)
-# #1->irb#1 on main (#<Thread:0x40125d64> : running)
-#
-# # change the active session
-# irb.1(main):002:0> fg 0
-# # define class Foo in top-level session
-# irb(main):002:0> class Foo;end
-# # invoke a new session with the context of Foo
-# irb(main):003:0> irb Foo
-# # define Foo#foo
-# irb.2(Foo):001:0> def foo
-# irb.2(Foo):002:1> print 1
-# irb.2(Foo):003:1> end
-#
-# # change the active session
-# irb.2(Foo):004:0> fg 0
-# # list open sessions
-# irb(main):004:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : running)
-# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
-# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
-# # check if Foo#foo is available
-# irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
-#
-# # change the active session
-# irb(main):006:0> fg 2
-# # define Foo#bar in the context of Foo
-# irb.2(Foo):005:0> def bar
-# irb.2(Foo):006:1> print "bar"
-# irb.2(Foo):007:1> end
-# irb.2(Foo):010:0> Foo.instance_methods #=> [:bar, :foo, ...]
-#
-# # change the active session
-# irb.2(Foo):011:0> fg 0
-# irb(main):007:0> f = Foo.new #=> #<Foo:0x4010af3c>
-# # invoke a new session with the context of f (instance of Foo)
-# irb(main):008:0> irb f
-# # list open sessions
-# irb.3(<Foo:0x4010af3c>):001:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : stop)
-# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
-# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
-# #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
-# # evaluate f.foo
-# irb.3(<Foo:0x4010af3c>):002:0> foo #=> 1 => nil
-# # evaluate f.bar
-# irb.3(<Foo:0x4010af3c>):003:0> bar #=> bar => nil
-# # kill jobs 1, 2, and 3
-# irb.3(<Foo:0x4010af3c>):004:0> kill 1, 2, 3
-# # list open sessions, should only include main session
-# irb(main):009:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : running)
-# # quit irb
-# irb(main):010:0> exit
-module IRB
-
- # An exception raised by IRB.irb_abort
- class Abort < Exception;end
-
- @CONF = {}
-
-
- # Displays current configuration.
- #
- # Modifying the configuration is achieved by sending a message to IRB.conf.
- #
- # See IRB@Configuration for more information.
- def IRB.conf
- @CONF
- end
-
- # Returns the current version of IRB, including release version and last
- # updated date.
- def IRB.version
- if v = @CONF[:VERSION] then return v end
-
- @CONF[:VERSION] = format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
- end
-
- # The current IRB::Context of the session, see IRB.conf
- #
- # irb
- # irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
- # foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
- def IRB.CurrentContext
- IRB.conf[:MAIN_CONTEXT]
- end
-
- # Initializes IRB and creates a new Irb.irb object at the +TOPLEVEL_BINDING+
- def IRB.start(ap_path = nil)
- STDOUT.sync = true
- $0 = File::basename(ap_path, ".rb") if ap_path
-
- IRB.setup(ap_path)
-
- if @CONF[:SCRIPT]
- irb = Irb.new(nil, @CONF[:SCRIPT])
- else
- irb = Irb.new
- end
- irb.run(@CONF)
- end
-
- # Calls each event hook of <code>IRB.conf[:AT_EXIT]</code> when the current session quits.
- def IRB.irb_at_exit
- @CONF[:AT_EXIT].each{|hook| hook.call}
- end
-
- # Quits irb
- def IRB.irb_exit(irb, ret)
- throw :IRB_EXIT, ret
- end
-
- # Aborts then interrupts irb.
- #
- # Will raise an Abort exception, or the given +exception+.
- def IRB.irb_abort(irb, exception = Abort)
- irb.context.thread.raise exception, "abort then interrupt!"
- end
-
- class Irb
- ASSIGNMENT_NODE_TYPES = [
- # Local, instance, global, class, constant, instance, and index assignment:
- # "foo = bar",
- # "@foo = bar",
- # "$foo = bar",
- # "@@foo = bar",
- # "::Foo = bar",
- # "a::Foo = bar",
- # "Foo = bar"
- # "foo.bar = 1"
- # "foo[1] = bar"
- :assign,
-
- # Operation assignment:
- # "foo += bar"
- # "foo -= bar"
- # "foo ||= bar"
- # "foo &&= bar"
- :opassign,
-
- # Multiple assignment:
- # "foo, bar = 1, 2
- :massign,
- ]
- # Note: instance and index assignment expressions could also be written like:
- # "foo.bar=(1)" and "foo.[]=(1, bar)", when expressed that way, the former
- # be parsed as :assign and echo will be suppressed, but the latter is
- # parsed as a :method_add_arg and the output won't be suppressed
-
- PROMPT_MAIN_TRUNCATE_LENGTH = 32
- PROMPT_MAIN_TRUNCATE_OMISSION = '...'.freeze
- CONTROL_CHARACTERS_PATTERN = "\x00-\x1F".freeze
-
- # Creates a new irb session
- def initialize(workspace = nil, input_method = nil)
- @context = Context.new(self, workspace, input_method)
- @context.main.extend ExtendCommandBundle
- @signal_status = :IN_IRB
- @scanner = RubyLex.new(@context)
- end
-
- # A hook point for `debug` command's TracePoint after :IRB_EXIT as well as its clean-up
- def debug_break
- # it means the debug command is executed
- if defined?(DEBUGGER__) && DEBUGGER__.respond_to?(:capture_frames_without_irb)
- # after leaving this initial breakpoint, revert the capture_frames patch
- DEBUGGER__.singleton_class.send(:alias_method, :capture_frames, :capture_frames_without_irb)
- # and remove the redundant method
- DEBUGGER__.singleton_class.send(:undef_method, :capture_frames_without_irb)
- end
- end
-
- def run(conf = IRB.conf)
- conf[:IRB_RC].call(context) if conf[:IRB_RC]
- conf[:MAIN_CONTEXT] = context
-
- prev_trap = trap("SIGINT") do
- signal_handle
- end
-
- begin
- catch(:IRB_EXIT) do
- eval_input
- end
- ensure
- trap("SIGINT", prev_trap)
- conf[:AT_EXIT].each{|hook| hook.call}
- end
- end
-
- # Returns the current context of this irb session
- attr_reader :context
- # The lexer used by this irb session
- attr_accessor :scanner
-
- # Evaluates input for this session.
- def eval_input
- exc = nil
-
- @scanner.set_prompt do
- |ltype, indent, continue, line_no|
- if ltype
- f = @context.prompt_s
- elsif continue
- f = @context.prompt_c
- elsif indent > 0
- f = @context.prompt_n
- else
- f = @context.prompt_i
- end
- f = "" unless f
- if @context.prompting?
- @context.io.prompt = p = prompt(f, ltype, indent, line_no)
- else
- @context.io.prompt = p = ""
- end
- if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent)
- unless ltype
- prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i
- ind = prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size +
- indent * 2 - p.size
- ind += 2 if continue
- @context.io.prompt = p + " " * ind if ind > 0
- end
- end
- @context.io.prompt
- end
-
- @scanner.set_input(@context.io) do
- signal_status(:IN_INPUT) do
- if l = @context.io.gets
- print l if @context.verbose?
- else
- if @context.ignore_eof? and @context.io.readable_after_eof?
- l = "\n"
- if @context.verbose?
- printf "Use \"exit\" to leave %s\n", @context.ap_name
- end
- else
- print "\n" if @context.prompting?
- end
- end
- l
- end
- end
-
- @scanner.set_auto_indent
-
- @scanner.each_top_level_statement do |line, line_no|
- signal_status(:IN_EVAL) do
- begin
- line.untaint if RUBY_VERSION < '2.7'
- if IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
- IRB.set_measure_callback
- end
- # Assignment expression check should be done before @context.evaluate to handle code like `a /2#/ if false; a = 1`
- is_assignment = assignment_expression?(line)
- if IRB.conf[:MEASURE] && !IRB.conf[:MEASURE_CALLBACKS].empty?
- result = nil
- last_proc = proc{ result = @context.evaluate(line, line_no, exception: exc) }
- IRB.conf[:MEASURE_CALLBACKS].inject(last_proc) { |chain, item|
- _name, callback, arg = item
- proc {
- callback.(@context, line, line_no, arg, exception: exc) do
- chain.call
- end
- }
- }.call
- @context.set_last_value(result)
- else
- @context.evaluate(line, line_no, exception: exc)
- end
- if @context.echo?
- if is_assignment
- if @context.echo_on_assignment?
- output_value(@context.echo_on_assignment? == :truncate)
- end
- else
- output_value
- end
- end
- rescue Interrupt => exc
- rescue SystemExit, SignalException
- raise
- rescue Exception => exc
- else
- exc = nil
- next
- end
- handle_exception(exc)
- @context.workspace.local_variable_set(:_, exc)
- exc = nil
- end
- end
- end
-
- def convert_invalid_byte_sequence(str, enc)
- str.force_encoding(enc)
- str.scrub { |c|
- c.bytes.map{ |b| "\\x#{b.to_s(16).upcase}" }.join
- }
- end
-
- def encode_with_invalid_byte_sequence(str, enc)
- conv = Encoding::Converter.new(str.encoding, enc)
- dst = String.new
- begin
- ret = conv.primitive_convert(str, dst)
- case ret
- when :invalid_byte_sequence
- conv.insert_output(conv.primitive_errinfo[3].dump[1..-2])
- redo
- when :undefined_conversion
- c = conv.primitive_errinfo[3].dup.force_encoding(conv.primitive_errinfo[1])
- conv.insert_output(c.dump[1..-2])
- redo
- when :incomplete_input
- conv.insert_output(conv.primitive_errinfo[3].dump[1..-2])
- when :finished
- end
- break
- end while nil
- dst
- end
-
- def handle_exception(exc)
- if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
- !(SyntaxError === exc) && !(EncodingError === exc)
- # The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
- irb_bug = true
- else
- irb_bug = false
- end
-
- if exc.backtrace
- order = nil
- if RUBY_VERSION < '3.0.0'
- if STDOUT.tty?
- message = exc.full_message(order: :bottom)
- order = :bottom
- else
- message = exc.full_message(order: :top)
- order = :top
- end
- else # '3.0.0' <= RUBY_VERSION
- message = exc.full_message(order: :top)
- order = :top
- end
- message = convert_invalid_byte_sequence(message, exc.message.encoding)
- message = encode_with_invalid_byte_sequence(message, IRB.conf[:LC_MESSAGES].encoding) unless message.encoding.to_s.casecmp?(IRB.conf[:LC_MESSAGES].encoding.to_s)
- message = message.gsub(/((?:^\t.+$\n)+)/) { |m|
- case order
- when :top
- lines = m.split("\n")
- when :bottom
- lines = m.split("\n").reverse
- end
- unless irb_bug
- lines = lines.map { |l| @context.workspace.filter_backtrace(l) }.compact
- if lines.size > @context.back_trace_limit
- omit = lines.size - @context.back_trace_limit
- lines = lines[0..(@context.back_trace_limit - 1)]
- lines << "\t... %d levels..." % omit
- end
- end
- lines = lines.reverse if order == :bottom
- lines.map{ |l| l + "\n" }.join
- }
- # The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
- message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
- puts message
- end
- print "Maybe IRB bug!\n" if irb_bug
- end
-
- # Evaluates the given block using the given +path+ as the Context#irb_path
- # and +name+ as the Context#irb_name.
- #
- # Used by the irb command +source+, see IRB@IRB+Sessions for more
- # information.
- def suspend_name(path = nil, name = nil)
- @context.irb_path, back_path = path, @context.irb_path if path
- @context.irb_name, back_name = name, @context.irb_name if name
- begin
- yield back_path, back_name
- ensure
- @context.irb_path = back_path if path
- @context.irb_name = back_name if name
- end
- end
-
- # Evaluates the given block using the given +workspace+ as the
- # Context#workspace.
- #
- # Used by the irb command +irb_load+, see IRB@IRB+Sessions for more
- # information.
- def suspend_workspace(workspace)
- @context.workspace, back_workspace = workspace, @context.workspace
- begin
- yield back_workspace
- ensure
- @context.workspace = back_workspace
- end
- end
-
- # Evaluates the given block using the given +input_method+ as the
- # Context#io.
- #
- # Used by the irb commands +source+ and +irb_load+, see IRB@IRB+Sessions
- # for more information.
- def suspend_input_method(input_method)
- back_io = @context.io
- @context.instance_eval{@io = input_method}
- begin
- yield back_io
- ensure
- @context.instance_eval{@io = back_io}
- end
- end
-
- # Evaluates the given block using the given +context+ as the Context.
- def suspend_context(context)
- @context, back_context = context, @context
- begin
- yield back_context
- ensure
- @context = back_context
- end
- end
-
- # Handler for the signal SIGINT, see Kernel#trap for more information.
- def signal_handle
- unless @context.ignore_sigint?
- print "\nabort!\n" if @context.verbose?
- exit
- end
-
- case @signal_status
- when :IN_INPUT
- print "^C\n"
- raise RubyLex::TerminateLineInput
- when :IN_EVAL
- IRB.irb_abort(self)
- when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
- when :IN_IRB
- # ignore
- else
- # ignore other cases as well
- end
- end
-
- # Evaluates the given block using the given +status+.
- def signal_status(status)
- return yield if @signal_status == :IN_LOAD
-
- signal_status_back = @signal_status
- @signal_status = status
- begin
- yield
- ensure
- @signal_status = signal_status_back
- end
- end
-
- def truncate_prompt_main(str) # :nodoc:
- str = str.tr(CONTROL_CHARACTERS_PATTERN, ' ')
- if str.size <= PROMPT_MAIN_TRUNCATE_LENGTH
- str
- else
- str[0, PROMPT_MAIN_TRUNCATE_LENGTH - PROMPT_MAIN_TRUNCATE_OMISSION.size] + PROMPT_MAIN_TRUNCATE_OMISSION
- end
- end
-
- def prompt(prompt, ltype, indent, line_no) # :nodoc:
- p = prompt.dup
- p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
- case $2
- when "N"
- @context.irb_name
- when "m"
- truncate_prompt_main(@context.main.to_s)
- when "M"
- truncate_prompt_main(@context.main.inspect)
- when "l"
- ltype
- when "i"
- if indent < 0
- if $1
- "-".rjust($1.to_i)
- else
- "-"
- end
- else
- if $1
- format("%" + $1 + "d", indent)
- else
- indent.to_s
- end
- end
- when "n"
- if $1
- format("%" + $1 + "d", line_no)
- else
- line_no.to_s
- end
- when "%"
- "%"
- end
- end
- p
- end
-
- def output_value(omit = false) # :nodoc:
- str = @context.inspect_last_value
- multiline_p = str.include?("\n")
- if omit
- winwidth = @context.io.winsize.last
- if multiline_p
- first_line = str.split("\n").first
- result = @context.newline_before_multiline_output? ? (@context.return_format % first_line) : first_line
- output_width = Reline::Unicode.calculate_width(result, true)
- diff_size = output_width - Reline::Unicode.calculate_width(first_line, true)
- if diff_size.positive? and output_width > winwidth
- lines, _ = Reline::Unicode.split_by_width(first_line, winwidth - diff_size - 3)
- str = "%s..." % lines.first
- str += "\e[0m" if Color.colorable?
- multiline_p = false
- else
- str = str.gsub(/(\A.*?\n).*/m, "\\1...")
- str += "\e[0m" if Color.colorable?
- end
- else
- output_width = Reline::Unicode.calculate_width(@context.return_format % str, true)
- diff_size = output_width - Reline::Unicode.calculate_width(str, true)
- if diff_size.positive? and output_width > winwidth
- lines, _ = Reline::Unicode.split_by_width(str, winwidth - diff_size - 3)
- str = "%s..." % lines.first
- str += "\e[0m" if Color.colorable?
- end
- end
- end
- if multiline_p && @context.newline_before_multiline_output?
- printf @context.return_format, "\n#{str}"
- else
- printf @context.return_format, str
- end
- end
-
- # Outputs the local variables to this current session, including
- # #signal_status and #context, using IRB::Locale.
- def inspect
- ary = []
- for iv in instance_variables
- case (iv = iv.to_s)
- when "@signal_status"
- ary.push format("%s=:%s", iv, @signal_status.id2name)
- when "@context"
- ary.push format("%s=%s", iv, eval(iv).__to_s__)
- else
- ary.push format("%s=%s", iv, eval(iv))
- end
- end
- format("#<%s: %s>", self.class, ary.join(", "))
- end
-
- def assignment_expression?(line)
- # Try to parse the line and check if the last of possibly multiple
- # expressions is an assignment type.
-
- # If the expression is invalid, Ripper.sexp should return nil which will
- # result in false being returned. Any valid expression should return an
- # s-expression where the second element of the top level array is an
- # array of parsed expressions. The first element of each expression is the
- # expression's type.
- verbose, $VERBOSE = $VERBOSE, nil
- code = "#{RubyLex.generate_local_variables_assign_code(@context.local_variables) || 'nil;'}\n#{line}"
- # Get the last node_type of the line. drop(1) is to ignore the local_variables_assign_code part.
- node_type = Ripper.sexp(code)&.dig(1)&.drop(1)&.dig(-1, 0)
- ASSIGNMENT_NODE_TYPES.include?(node_type)
- ensure
- $VERBOSE = verbose
- end
-
- ATTR_TTY = "\e[%sm"
- def ATTR_TTY.[](*a) self % a.join(";"); end
- ATTR_PLAIN = ""
- def ATTR_PLAIN.[](*) self; end
- end
-
- def @CONF.inspect
- IRB.version unless self[:VERSION]
-
- array = []
- for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
- case k
- when :MAIN_CONTEXT, :__TMP__EHV__
- array.push format("CONF[:%s]=...myself...", k.id2name)
- when :PROMPT
- s = v.collect{
- |kk, vv|
- ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
- format(":%s=>{%s}", kk.id2name, ss.join(", "))
- }
- array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
- else
- array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
- end
- end
- array.join("\n")
- end
-end
-
-class Binding
- # Opens an IRB session where +binding.irb+ is called which allows for
- # interactive debugging. You can call any methods or variables available in
- # the current scope, and mutate state if you need to.
- #
- #
- # Given a Ruby file called +potato.rb+ containing the following code:
- #
- # class Potato
- # def initialize
- # @cooked = false
- # binding.irb
- # puts "Cooked potato: #{@cooked}"
- # end
- # end
- #
- # Potato.new
- #
- # Running <code>ruby potato.rb</code> will open an IRB session where
- # +binding.irb+ is called, and you will see the following:
- #
- # $ ruby potato.rb
- #
- # From: potato.rb @ line 4 :
- #
- # 1: class Potato
- # 2: def initialize
- # 3: @cooked = false
- # => 4: binding.irb
- # 5: puts "Cooked potato: #{@cooked}"
- # 6: end
- # 7: end
- # 8:
- # 9: Potato.new
- #
- # irb(#<Potato:0x00007feea1916670>):001:0>
- #
- # You can type any valid Ruby code and it will be evaluated in the current
- # context. This allows you to debug without having to run your code repeatedly:
- #
- # irb(#<Potato:0x00007feea1916670>):001:0> @cooked
- # => false
- # irb(#<Potato:0x00007feea1916670>):002:0> self.class
- # => Potato
- # irb(#<Potato:0x00007feea1916670>):003:0> caller.first
- # => ".../2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'"
- # irb(#<Potato:0x00007feea1916670>):004:0> @cooked = true
- # => true
- #
- # You can exit the IRB session with the +exit+ command. Note that exiting will
- # resume execution where +binding.irb+ had paused it, as you can see from the
- # output printed to standard output in this example:
- #
- # irb(#<Potato:0x00007feea1916670>):005:0> exit
- # Cooked potato: true
- #
- #
- # See IRB@IRB+Usage for more information.
- def irb(show_code: true)
- IRB.setup(source_location[0], argv: [])
- workspace = IRB::WorkSpace.new(self)
- STDOUT.print(workspace.code_around_binding) if show_code
- binding_irb = IRB::Irb.new(workspace)
- binding_irb.context.irb_path = File.expand_path(source_location[0])
- binding_irb.run(IRB.conf)
- binding_irb.debug_break
- end
-end
diff --git a/lib/irb/.document b/lib/irb/.document
deleted file mode 100644
index 3b0d6fa4ed..0000000000
--- a/lib/irb/.document
+++ /dev/null
@@ -1 +0,0 @@
-**/*.rb
diff --git a/lib/irb/cmd/backtrace.rb b/lib/irb/cmd/backtrace.rb
deleted file mode 100644
index f632894618..0000000000
--- a/lib/irb/cmd/backtrace.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Backtrace < DebugCommand
- def self.transform_args(args)
- args&.dump
- end
-
- def execute(*args)
- super(pre_cmds: ["backtrace", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/break.rb b/lib/irb/cmd/break.rb
deleted file mode 100644
index df259a90ca..0000000000
--- a/lib/irb/cmd/break.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Break < DebugCommand
- def self.transform_args(args)
- args&.dump
- end
-
- def execute(args = nil)
- super(pre_cmds: "break #{args}")
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/catch.rb b/lib/irb/cmd/catch.rb
deleted file mode 100644
index 40b62c7533..0000000000
--- a/lib/irb/cmd/catch.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Catch < DebugCommand
- def self.transform_args(args)
- args&.dump
- end
-
- def execute(*args)
- super(pre_cmds: ["catch", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
deleted file mode 100644
index 44712fa445..0000000000
--- a/lib/irb/cmd/chws.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: false
-#
-# change-ws.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-require_relative "../ext/change-ws"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
-
- class CurrentWorkingWorkspace < Nop
- category "IRB"
- description "Show the current workspace."
-
- def execute(*obj)
- irb_context.main
- end
- end
-
- class ChangeWorkspace < Nop
- category "IRB"
- description "Change the current workspace to an object."
-
- def execute(*obj)
- irb_context.change_workspace(*obj)
- irb_context.main
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/continue.rb b/lib/irb/cmd/continue.rb
deleted file mode 100644
index 9136177eef..0000000000
--- a/lib/irb/cmd/continue.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Continue < DebugCommand
- def execute(*args)
- super(do_cmds: ["continue", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/debug.rb b/lib/irb/cmd/debug.rb
deleted file mode 100644
index 7d39b9fa27..0000000000
--- a/lib/irb/cmd/debug.rb
+++ /dev/null
@@ -1,136 +0,0 @@
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Debug < Nop
- category "Debugging"
- description "Start the debugger of debug.gem."
-
- BINDING_IRB_FRAME_REGEXPS = [
- '<internal:prelude>',
- binding.method(:irb).source_location.first,
- ].map { |file| /\A#{Regexp.escape(file)}:\d+:in `irb'\z/ }
- IRB_DIR = File.expand_path('..', __dir__)
-
- def execute(pre_cmds: nil, do_cmds: nil)
- unless binding_irb?
- puts "`debug` command is only available when IRB is started with binding.irb"
- return
- end
-
- unless setup_debugger
- puts <<~MSG
- You need to install the debug gem before using this command.
- If you use `bundle exec`, please add `gem "debug"` into your Gemfile.
- MSG
- return
- end
-
- options = { oneshot: true, hook_call: false }
- if pre_cmds || do_cmds
- options[:command] = ['irb', pre_cmds, do_cmds]
- end
- if DEBUGGER__::LineBreakpoint.instance_method(:initialize).parameters.include?([:key, :skip_src])
- options[:skip_src] = true
- end
-
- # To make debugger commands like `next` or `continue` work without asking
- # the user to quit IRB after that, we need to exit IRB first and then hit
- # a TracePoint on #debug_break.
- file, lineno = IRB::Irb.instance_method(:debug_break).source_location
- DEBUGGER__::SESSION.add_line_breakpoint(file, lineno + 1, **options)
- # exit current Irb#run call
- throw :IRB_EXIT
- end
-
- private
-
- def binding_irb?
- caller.any? do |frame|
- BINDING_IRB_FRAME_REGEXPS.any? do |regexp|
- frame.match?(regexp)
- end
- end
- end
-
- module SkipPathHelperForIRB
- def skip_internal_path?(path)
- # The latter can be removed once https://github.com/ruby/debug/issues/866 is resolved
- super || path.match?(IRB_DIR) || path.match?('<internal:prelude>')
- end
- end
-
- def setup_debugger
- unless defined?(DEBUGGER__::SESSION)
- begin
- require "debug/session"
- rescue LoadError # debug.gem is not written in Gemfile
- return false unless load_bundled_debug_gem
- end
- DEBUGGER__.start(nonstop: true)
- end
-
- unless DEBUGGER__.respond_to?(:capture_frames_without_irb)
- DEBUGGER__.singleton_class.send(:alias_method, :capture_frames_without_irb, :capture_frames)
-
- def DEBUGGER__.capture_frames(*args)
- frames = capture_frames_without_irb(*args)
- frames.reject! do |frame|
- frame.realpath&.start_with?(IRB_DIR) || frame.path == "<internal:prelude>"
- end
- frames
- end
-
- DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB)
- end
-
- true
- end
-
- # This is used when debug.gem is not written in Gemfile. Even if it's not
- # installed by `bundle install`, debug.gem is installed by default because
- # it's a bundled gem. This method tries to activate and load that.
- def load_bundled_debug_gem
- # Discover latest debug.gem under GEM_PATH
- debug_gem = Gem.paths.path.flat_map { |path| Dir.glob("#{path}/gems/debug-*") }.select do |path|
- File.basename(path).match?(/\Adebug-\d+\.\d+\.\d+(\w+)?\z/)
- end.sort_by do |path|
- Gem::Version.new(File.basename(path).delete_prefix('debug-'))
- end.last
- return false unless debug_gem
-
- # Discover debug/debug.so under extensions for Ruby 3.2+
- ext_name = "/debug/debug.#{RbConfig::CONFIG['DLEXT']}"
- ext_path = Gem.paths.path.flat_map do |path|
- Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}#{ext_name}")
- end.first
-
- # Attempt to forcibly load the bundled gem
- if ext_path
- $LOAD_PATH << ext_path.delete_suffix(ext_name)
- end
- $LOAD_PATH << "#{debug_gem}/lib"
- begin
- require "debug/session"
- puts "Loaded #{File.basename(debug_gem)}"
- true
- rescue LoadError
- false
- end
- end
- end
-
- class DebugCommand < Debug
- def self.category
- "Debugging"
- end
-
- def self.description
- command_name = self.name.split("::").last.downcase
- "Start the debugger of debug.gem and run its `#{command_name}` command."
- end
- end
- end
-end
diff --git a/lib/irb/cmd/delete.rb b/lib/irb/cmd/delete.rb
deleted file mode 100644
index aeb26d2572..0000000000
--- a/lib/irb/cmd/delete.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Delete < DebugCommand
- def execute(*args)
- super(pre_cmds: ["delete", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/edit.rb b/lib/irb/cmd/edit.rb
deleted file mode 100644
index 0103891cf4..0000000000
--- a/lib/irb/cmd/edit.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'shellwords'
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Edit < Nop
- category "Misc"
- description 'Open a file with the editor command defined with `ENV["EDITOR"]`.'
-
- class << self
- def transform_args(args)
- # Return a string literal as is for backward compatibility
- if args.nil? || args.empty? || string_literal?(args)
- args
- else # Otherwise, consider the input as a String for convenience
- args.strip.dump
- end
- end
- end
-
- def execute(*args)
- path = args.first
-
- if path.nil? && (irb_path = @irb_context.irb_path)
- path = irb_path
- end
-
- if !File.exist?(path)
- require_relative "show_source"
-
- source =
- begin
- ShowSource.find_source(path, @irb_context)
- rescue NameError
- # if user enters a path that doesn't exist, it'll cause NameError when passed here because find_source would try to evaluate it as well
- # in this case, we should just ignore the error
- end
-
- if source && File.exist?(source.file)
- path = source.file
- else
- puts "Can not find file: #{path}"
- return
- end
- end
-
- if editor = ENV['EDITOR']
- puts "command: '#{editor}'"
- puts " path: #{path}"
- system(*Shellwords.split(editor), path)
- else
- puts "Can not find editor setting: ENV['EDITOR']"
- end
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/finish.rb b/lib/irb/cmd/finish.rb
deleted file mode 100644
index 29f100feb5..0000000000
--- a/lib/irb/cmd/finish.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Finish < DebugCommand
- def execute(*args)
- super(do_cmds: ["finish", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
deleted file mode 100644
index 1cd235997f..0000000000
--- a/lib/irb/cmd/fork.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: false
-#
-# fork.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Fork < Nop
- def execute
- pid = __send__ ExtendCommand.irb_original_method_name("fork")
- unless pid
- class << self
- alias_method :exit, ExtendCommand.irb_original_method_name('exit')
- end
- if block_given?
- begin
- yield
- ensure
- exit
- end
- end
- end
- pid
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
deleted file mode 100644
index 9896fa9db1..0000000000
--- a/lib/irb/cmd/help.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: false
-#
-# help.rb - helper using ri
-#
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Help < Nop
- class << self
- def transform_args(args)
- # Return a string literal as is for backward compatibility
- if args.empty? || string_literal?(args)
- args
- else # Otherwise, consider the input as a String for convenience
- args.strip.dump
- end
- end
- end
-
- category "Context"
- description "Enter the mode to look up RI documents."
-
- def execute(*names)
- require 'rdoc/ri/driver'
- opts = RDoc::RI::Driver.process_args([])
- IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new(opts))
- rescue LoadError, SystemExit
- IRB::ExtendCommand::Help.remove_method(:execute)
- # raise NoMethodError in ensure
- else
- def execute(*names)
- if names.empty?
- Ri.interactive
- return
- end
- names.each do |name|
- begin
- Ri.display_name(name.to_s)
- rescue RDoc::RI::Error
- puts $!.message
- end
- end
- nil
- end
- nil
- ensure
- execute(*names)
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb
deleted file mode 100644
index 2c0a32b34f..0000000000
--- a/lib/irb/cmd/info.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Info < DebugCommand
- def self.transform_args(args)
- args&.dump
- end
-
- def execute(*args)
- super(pre_cmds: ["info", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/irb_info.rb b/lib/irb/cmd/irb_info.rb
deleted file mode 100644
index da11e8d40b..0000000000
--- a/lib/irb/cmd/irb_info.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class IrbInfo < Nop
- category "IRB"
- description "Show information about IRB."
-
- def execute
- Class.new {
- def inspect
- str = "Ruby version: #{RUBY_VERSION}\n"
- str += "IRB version: #{IRB.version}\n"
- str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
- str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
- str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
- str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
- str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
- str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
- if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
- codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
- str += "Code page: #{codepage}\n"
- end
- str
- end
- alias_method :to_s, :inspect
- }.new
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
deleted file mode 100644
index a3e797a7e0..0000000000
--- a/lib/irb/cmd/load.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: false
-#
-# load.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-require_relative "../ext/loader"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class LoaderCommand < Nop
- include IrbLoader
-
- def raise_cmd_argument_error
- raise CommandArgumentError.new("Please specify the file name.")
- end
- end
-
- class Load < LoaderCommand
- category "IRB"
- description "Load a Ruby file."
-
- def execute(file_name = nil, priv = nil)
- raise_cmd_argument_error unless file_name
- irb_load(file_name, priv)
- end
- end
-
- class Require < LoaderCommand
- category "IRB"
- description "Require a Ruby file."
- def execute(file_name = nil)
- raise_cmd_argument_error unless file_name
-
- rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
- return false if $".find{|f| f =~ rex}
-
- case file_name
- when /\.rb$/
- begin
- if irb_load(file_name)
- $".push file_name
- return true
- end
- rescue LoadError
- end
- when /\.(so|o|sl)$/
- return ruby_require(file_name)
- end
-
- begin
- irb_load(f = file_name + ".rb")
- $".push f
- return true
- rescue LoadError
- return ruby_require(file_name)
- end
- end
- end
-
- class Source < LoaderCommand
- category "IRB"
- description "Loads a given file in the current session."
-
- def execute(file_name = nil)
- raise_cmd_argument_error unless file_name
-
- source_file(file_name)
- end
- end
- end
- # :startdoc:
-end
diff --git a/lib/irb/cmd/ls.rb b/lib/irb/cmd/ls.rb
deleted file mode 100644
index d5a371a4d6..0000000000
--- a/lib/irb/cmd/ls.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-# frozen_string_literal: true
-
-require "reline"
-require_relative "nop"
-require_relative "../color"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Ls < Nop
- category "Context"
- description "Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output."
-
- def self.transform_args(args)
- if match = args&.match(/\A(?<args>.+\s|)(-g|-G)\s+(?<grep>[^\s]+)\s*\n\z/)
- args = match[:args]
- "#{args}#{',' unless args.chomp.empty?} grep: /#{match[:grep]}/"
- else
- args
- end
- end
-
- def execute(*arg, grep: nil)
- o = Output.new(grep: grep)
-
- obj = arg.empty? ? irb_context.workspace.main : arg.first
- locals = arg.empty? ? irb_context.workspace.binding.local_variables : []
- klass = (obj.class == Class || obj.class == Module ? obj : obj.class)
-
- o.dump("constants", obj.constants) if obj.respond_to?(:constants)
- dump_methods(o, klass, obj)
- o.dump("instance variables", obj.instance_variables)
- o.dump("class variables", klass.class_variables)
- o.dump("locals", locals)
- nil
- end
-
- def dump_methods(o, klass, obj)
- singleton_class = begin obj.singleton_class; rescue TypeError; nil end
- dumped_mods = Array.new
- # singleton_class' ancestors should be at the front
- maps = class_method_map(singleton_class&.ancestors || [], dumped_mods) + class_method_map(klass.ancestors, dumped_mods)
- maps.each do |mod, methods|
- name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"
- o.dump(name, methods)
- end
- end
-
- def class_method_map(classes, dumped_mods)
- dumped_methods = Array.new
- classes = classes.reject { |mod| mod >= Object }
- classes.map do |mod|
- next if dumped_mods.include? mod
-
- dumped_mods << mod
-
- methods = mod.public_instance_methods(false).select do |method|
- if dumped_methods.include? method
- false
- else
- dumped_methods << method
- true
- end
- end
-
- [mod, methods]
- end.compact
- end
-
- class Output
- MARGIN = " "
-
- def initialize(grep: nil)
- @grep = grep
- @line_width = screen_width - MARGIN.length # right padding
- end
-
- def dump(name, strs)
- strs = strs.grep(@grep) if @grep
- strs = strs.sort
- return if strs.empty?
-
- # Attempt a single line
- print "#{Color.colorize(name, [:BOLD, :BLUE])}: "
- if fits_on_line?(strs, cols: strs.size, offset: "#{name}: ".length)
- puts strs.join(MARGIN)
- return
- end
- puts
-
- # Dump with the largest # of columns that fits on a line
- cols = strs.size
- until fits_on_line?(strs, cols: cols, offset: MARGIN.length) || cols == 1
- cols -= 1
- end
- widths = col_widths(strs, cols: cols)
- strs.each_slice(cols) do |ss|
- puts ss.map.with_index { |s, i| "#{MARGIN}%-#{widths[i]}s" % s }.join
- end
- end
-
- private
-
- def fits_on_line?(strs, cols:, offset: 0)
- width = col_widths(strs, cols: cols).sum + MARGIN.length * (cols - 1)
- width <= @line_width - offset
- end
-
- def col_widths(strs, cols:)
- cols.times.map do |col|
- (col...strs.size).step(cols).map do |i|
- strs[i].length
- end.max
- end
- end
-
- def screen_width
- Reline.get_screen_size.last
- rescue Errno::EINVAL # in `winsize': Invalid argument - <STDIN>
- 80
- end
- end
- private_constant :Output
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/measure.rb b/lib/irb/cmd/measure.rb
deleted file mode 100644
index 9122e2dac9..0000000000
--- a/lib/irb/cmd/measure.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Measure < Nop
- category "Misc"
- description "`measure` enables the mode to measure processing time. `measure :off` disables it."
-
- def initialize(*args)
- super(*args)
- end
-
- def execute(type = nil, arg = nil, &block)
- # Please check IRB.init_config in lib/irb/init.rb that sets
- # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
- # "measure :time" (abbreviated as "measure") and "measure :stackprof".
- case type
- when :off
- IRB.conf[:MEASURE] = nil
- IRB.unset_measure_callback(arg)
- when :list
- IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _, arg_val|
- puts "- #{type_name}" + (arg_val ? "(#{arg_val.inspect})" : '')
- end
- when :on
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(type, arg)
- puts "#{added[0]} is added." if added
- else
- if block_given?
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(&block)
- puts "#{added[0]} is added." if added
- else
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(type, arg)
- puts "#{added[0]} is added." if added
- end
- end
- nil
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/next.rb b/lib/irb/cmd/next.rb
deleted file mode 100644
index d29c82e7fc..0000000000
--- a/lib/irb/cmd/next.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Next < DebugCommand
- def execute(*args)
- super(do_cmds: ["next", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
deleted file mode 100644
index 34facc7578..0000000000
--- a/lib/irb/cmd/nop.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: false
-#
-# nop.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class CommandArgumentError < StandardError; end
-
- class Nop
- class << self
- def category(category = nil)
- @category = category if category
- @category
- end
-
- def description(description = nil)
- @description = description if description
- @description
- end
-
- private
-
- def string_literal?(args)
- sexp = Ripper.sexp(args)
- sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
- end
- end
-
- if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
- def self.execute(conf, *opts, **kwargs, &block)
- command = new(conf)
- command.execute(*opts, **kwargs, &block)
- rescue CommandArgumentError => e
- puts e.message
- end
- else
- def self.execute(conf, *opts, &block)
- command = new(conf)
- command.execute(*opts, &block)
- rescue CommandArgumentError => e
- puts e.message
- end
- end
-
- def initialize(conf)
- @irb_context = conf
- end
-
- attr_reader :irb_context
-
- def irb
- @irb_context.irb
- end
-
- def execute(*opts)
- #nop
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
deleted file mode 100644
index d64d822182..0000000000
--- a/lib/irb/cmd/pushws.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: false
-#
-# change-ws.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-require_relative "../ext/workspaces"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Workspaces < Nop
- category "IRB"
- description "Show workspaces."
-
- def execute(*obj)
- irb_context.workspaces.collect{|ws| ws.main}
- end
- end
-
- class PushWorkspace < Workspaces
- category "IRB"
- description "Push an object to the workspace stack."
-
- def execute(*obj)
- irb_context.push_workspace(*obj)
- super
- end
- end
-
- class PopWorkspace < Workspaces
- category "IRB"
- description "Pop a workspace from the workspace stack."
-
- def execute(*obj)
- irb_context.pop_workspace(*obj)
- super
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/cmd/show_cmds.rb
deleted file mode 100644
index acced27d48..0000000000
--- a/lib/irb/cmd/show_cmds.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require "stringio"
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class ShowCmds < Nop
- category "IRB"
- description "List all available commands and their description."
-
- def execute(*args)
- commands_info = IRB::ExtendCommandBundle.all_commands_info
- commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
- longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
-
- output = StringIO.new
-
- commands_grouped_by_categories.each do |category, cmds|
- output.puts Color.colorize(category, [:BOLD])
-
- cmds.each do |cmd|
- output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}"
- end
-
- output.puts
- end
-
- puts output.string
-
- nil
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/show_source.rb b/lib/irb/cmd/show_source.rb
deleted file mode 100644
index eb21533b56..0000000000
--- a/lib/irb/cmd/show_source.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "nop"
-require_relative "../color"
-require_relative "../ruby-lex"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class ShowSource < Nop
- category "Context"
- description "Show the source code of a given method or constant."
-
- class << self
- def transform_args(args)
- # Return a string literal as is for backward compatibility
- if args.empty? || string_literal?(args)
- args
- else # Otherwise, consider the input as a String for convenience
- args.strip.dump
- end
- end
-
- def find_source(str, irb_context)
- case str
- when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
- eval(str, irb_context.workspace.binding) # trigger autoload
- base = irb_context.workspace.binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
- file, line = base.const_source_location(str) if base.respond_to?(:const_source_location) # Ruby 2.7+
- when /\A(?<owner>[A-Z]\w*(::[A-Z]\w*)*)#(?<method>[^ :.]+)\z/ # Class#method
- owner = eval(Regexp.last_match[:owner], irb_context.workspace.binding)
- method = Regexp.last_match[:method]
- if owner.respond_to?(:instance_method) && owner.instance_methods.include?(method.to_sym)
- file, line = owner.instance_method(method).source_location
- end
- when /\A((?<receiver>.+)(\.|::))?(?<method>[^ :.]+)\z/ # method, receiver.method, receiver::method
- receiver = eval(Regexp.last_match[:receiver] || 'self', irb_context.workspace.binding)
- method = Regexp.last_match[:method]
- file, line = receiver.method(method).source_location if receiver.respond_to?(method)
- end
- if file && line
- Source.new(file: file, first_line: line, last_line: find_end(file, line, irb_context))
- end
- end
-
- private
-
- def find_end(file, first_line, irb_context)
- return first_line unless File.exist?(file)
- lex = RubyLex.new(irb_context)
- lines = File.read(file).lines[(first_line - 1)..-1]
- tokens = RubyLex.ripper_lex_without_warning(lines.join)
- prev_tokens = []
-
- # chunk with line number
- tokens.chunk { |tok| tok.pos[0] }.each do |lnum, chunk|
- code = lines[0..lnum].join
- prev_tokens.concat chunk
- continue = lex.process_continue(prev_tokens)
- code_block_open = lex.check_code_block(code, prev_tokens)
- if !continue && !code_block_open
- return first_line + lnum
- end
- end
- first_line
- end
- end
-
- def execute(str = nil)
- unless str.is_a?(String)
- puts "Error: Expected a string but got #{str.inspect}"
- return
- end
-
- source = self.class.find_source(str, @irb_context)
- if source && File.exist?(source.file)
- show_source(source)
- else
- puts "Error: Couldn't locate a definition for #{str}"
- end
- nil
- end
-
- private
-
- # @param [IRB::ExtendCommand::ShowSource::Source] source
- def show_source(source)
- puts
- puts "#{bold("From")}: #{source.file}:#{source.first_line}"
- puts
- code = IRB::Color.colorize_code(File.read(source.file))
- puts code.lines[(source.first_line - 1)...source.last_line].join
- puts
- end
-
- def bold(str)
- Color.colorize(str, [:BOLD])
- end
-
- Source = Struct.new(
- :file, # @param [String] - file name
- :first_line, # @param [String] - first line
- :last_line, # @param [String] - last line
- keyword_init: true,
- )
- private_constant :Source
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/step.rb b/lib/irb/cmd/step.rb
deleted file mode 100644
index 2bc74a9d79..0000000000
--- a/lib/irb/cmd/step.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "debug"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Step < DebugCommand
- def execute(*args)
- super(do_cmds: ["step", *args].join(" "))
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
deleted file mode 100644
index 5f3e02c988..0000000000
--- a/lib/irb/cmd/subirb.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: false
-#
-# multi.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class MultiIRBCommand < Nop
- def initialize(conf)
- super
- extend_irb_context
- end
-
- private
-
- def extend_irb_context
- # this extension patches IRB context like IRB.CurrentContext
- require_relative "../ext/multi-irb"
- end
- end
-
- class IrbCommand < MultiIRBCommand
- category "IRB"
- description "Start a child IRB."
-
- def execute(*obj)
- IRB.irb(nil, *obj)
- end
- end
-
- class Jobs < MultiIRBCommand
- category "IRB"
- description "List of current sessions."
-
- def execute
- IRB.JobManager
- end
- end
-
- class Foreground < MultiIRBCommand
- category "IRB"
- description "Switches to the session of the given number."
-
- def execute(key = nil)
- raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
- IRB.JobManager.switch(key)
- end
- end
-
- class Kill < MultiIRBCommand
- category "IRB"
- description "Kills the session with the given number."
-
- def execute(*keys)
- IRB.JobManager.kill(*keys)
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/whereami.rb b/lib/irb/cmd/whereami.rb
deleted file mode 100644
index 8f56ba073d..0000000000
--- a/lib/irb/cmd/whereami.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Whereami < Nop
- category "Context"
- description "Show the source code around binding.irb again."
-
- def execute(*)
- code = irb_context.workspace.code_around_binding
- if code
- puts code
- else
- puts "The current context doesn't have code."
- end
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
deleted file mode 100644
index 52d6240910..0000000000
--- a/lib/irb/color.rb
+++ /dev/null
@@ -1,266 +0,0 @@
-# frozen_string_literal: true
-require 'reline'
-require 'ripper'
-require_relative 'ruby-lex'
-
-module IRB # :nodoc:
- module Color
- CLEAR = 0
- BOLD = 1
- UNDERLINE = 4
- REVERSE = 7
- RED = 31
- GREEN = 32
- YELLOW = 33
- BLUE = 34
- MAGENTA = 35
- CYAN = 36
-
- TOKEN_KEYWORDS = {
- on_kw: ['nil', 'self', 'true', 'false', '__FILE__', '__LINE__', '__ENCODING__'],
- on_const: ['ENV'],
- }
- private_constant :TOKEN_KEYWORDS
-
- # A constant of all-bit 1 to match any Ripper's state in #dispatch_seq
- ALL = -1
- private_constant :ALL
-
- begin
- # Following pry's colors where possible, but sometimes having a compromise like making
- # backtick and regexp as red (string's color, because they're sharing tokens).
- TOKEN_SEQ_EXPRS = {
- on_CHAR: [[BLUE, BOLD], ALL],
- on_backtick: [[RED, BOLD], ALL],
- on_comment: [[BLUE, BOLD], ALL],
- on_const: [[BLUE, BOLD, UNDERLINE], ALL],
- on_embexpr_beg: [[RED], ALL],
- on_embexpr_end: [[RED], ALL],
- on_embvar: [[RED], ALL],
- on_float: [[MAGENTA, BOLD], ALL],
- on_gvar: [[GREEN, BOLD], ALL],
- on_heredoc_beg: [[RED], ALL],
- on_heredoc_end: [[RED], ALL],
- on_ident: [[BLUE, BOLD], Ripper::EXPR_ENDFN],
- on_imaginary: [[BLUE, BOLD], ALL],
- on_int: [[BLUE, BOLD], ALL],
- on_kw: [[GREEN], ALL],
- on_label: [[MAGENTA], ALL],
- on_label_end: [[RED, BOLD], ALL],
- on_qsymbols_beg: [[RED, BOLD], ALL],
- on_qwords_beg: [[RED, BOLD], ALL],
- on_rational: [[BLUE, BOLD], ALL],
- on_regexp_beg: [[RED, BOLD], ALL],
- on_regexp_end: [[RED, BOLD], ALL],
- on_symbeg: [[YELLOW], ALL],
- on_symbols_beg: [[RED, BOLD], ALL],
- on_tstring_beg: [[RED, BOLD], ALL],
- on_tstring_content: [[RED], ALL],
- on_tstring_end: [[RED, BOLD], ALL],
- on_words_beg: [[RED, BOLD], ALL],
- on_parse_error: [[RED, REVERSE], ALL],
- compile_error: [[RED, REVERSE], ALL],
- on_assign_error: [[RED, REVERSE], ALL],
- on_alias_error: [[RED, REVERSE], ALL],
- on_class_name_error:[[RED, REVERSE], ALL],
- on_param_error: [[RED, REVERSE], ALL],
- on___end__: [[GREEN], ALL],
- }
- rescue NameError
- # Give up highlighting Ripper-incompatible older Ruby
- TOKEN_SEQ_EXPRS = {}
- end
- private_constant :TOKEN_SEQ_EXPRS
-
- ERROR_TOKENS = TOKEN_SEQ_EXPRS.keys.select { |k| k.to_s.end_with?('error') }
- private_constant :ERROR_TOKENS
-
- class << self
- def colorable?
- supported = $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
-
- # because ruby/debug also uses irb's color module selectively,
- # irb won't be activated in that case.
- if IRB.respond_to?(:conf)
- supported && IRB.conf.fetch(:USE_COLORIZE, true)
- else
- supported
- end
- end
-
- def inspect_colorable?(obj, seen: {}.compare_by_identity)
- case obj
- when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass
- true
- when Hash
- without_circular_ref(obj, seen: seen) do
- obj.all? { |k, v| inspect_colorable?(k, seen: seen) && inspect_colorable?(v, seen: seen) }
- end
- when Array
- without_circular_ref(obj, seen: seen) do
- obj.all? { |o| inspect_colorable?(o, seen: seen) }
- end
- when Range
- inspect_colorable?(obj.begin, seen: seen) && inspect_colorable?(obj.end, seen: seen)
- when Module
- !obj.name.nil?
- else
- false
- end
- end
-
- def clear(colorable: colorable?)
- return '' unless colorable
- "\e[#{CLEAR}m"
- end
-
- def colorize(text, seq, colorable: colorable?)
- return text unless colorable
- seq = seq.map { |s| "\e[#{const_get(s)}m" }.join('')
- "#{seq}#{text}#{clear(colorable: colorable)}"
- end
-
- # If `complete` is false (code is incomplete), this does not warn compile_error.
- # This option is needed to avoid warning a user when the compile_error is happening
- # because the input is not wrong but just incomplete.
- def colorize_code(code, complete: true, ignore_error: false, colorable: colorable?, local_variables: [])
- return code unless colorable
-
- symbol_state = SymbolState.new
- colored = +''
- lvars_code = RubyLex.generate_local_variables_assign_code(local_variables)
- code_with_lvars = lvars_code ? "#{lvars_code}\n#{code}" : code
-
- scan(code_with_lvars, allow_last_error: !complete) do |token, str, expr|
- # handle uncolorable code
- if token.nil?
- colored << Reline::Unicode.escape_for_print(str)
- next
- end
-
- # IRB::ColorPrinter skips colorizing fragments with any invalid token
- if ignore_error && ERROR_TOKENS.include?(token)
- return Reline::Unicode.escape_for_print(code)
- end
-
- in_symbol = symbol_state.scan_token(token)
- str.each_line do |line|
- line = Reline::Unicode.escape_for_print(line)
- if seq = dispatch_seq(token, expr, line, in_symbol: in_symbol)
- colored << seq.map { |s| "\e[#{s}m" }.join('')
- colored << line.sub(/\Z/, clear(colorable: colorable))
- else
- colored << line
- end
- end
- end
-
- if lvars_code
- raise "#{lvars_code.dump} should have no \\n" if lvars_code.include?("\n")
- colored.sub!(/\A.+\n/, '') # delete_prefix lvars_code with colors
- end
- colored
- end
-
- private
-
- def without_circular_ref(obj, seen:, &block)
- return false if seen.key?(obj)
- seen[obj] = true
- block.call
- ensure
- seen.delete(obj)
- end
-
- def scan(code, allow_last_error:)
- verbose, $VERBOSE = $VERBOSE, nil
- RubyLex.compile_with_errors_suppressed(code) do |inner_code, line_no|
- lexer = Ripper::Lexer.new(inner_code, '(ripper)', line_no)
- byte_pos = 0
- line_positions = [0]
- inner_code.lines.each do |line|
- line_positions << line_positions.last + line.bytesize
- end
-
- on_scan = proc do |elem|
- start_pos = line_positions[elem.pos[0] - 1] + elem.pos[1]
-
- # yield uncolorable code
- if byte_pos < start_pos
- yield(nil, inner_code.byteslice(byte_pos...start_pos), nil)
- end
-
- if byte_pos <= start_pos
- str = elem.tok
- yield(elem.event, str, elem.state)
- byte_pos = start_pos + str.bytesize
- end
- end
-
- if lexer.respond_to?(:scan) # Ruby 2.7+
- lexer.scan.each do |elem|
- next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
- on_scan.call(elem)
- end
- else
- lexer.parse.sort_by(&:pos).each do |elem|
- on_scan.call(elem)
- end
- end
- # yield uncolorable DATA section
- yield(nil, inner_code.byteslice(byte_pos...inner_code.bytesize), nil) if byte_pos < inner_code.bytesize
- end
- ensure
- $VERBOSE = verbose
- end
-
- def dispatch_seq(token, expr, str, in_symbol:)
- if ERROR_TOKENS.include?(token)
- TOKEN_SEQ_EXPRS[token][0]
- elsif in_symbol
- [YELLOW]
- elsif TOKEN_KEYWORDS.fetch(token, []).include?(str)
- [CYAN, BOLD]
- elsif (seq, exprs = TOKEN_SEQ_EXPRS[token]; (expr & (exprs || 0)) != 0)
- seq
- else
- nil
- end
- end
- end
-
- # A class to manage a state to know whether the current token is for Symbol or not.
- class SymbolState
- def initialize
- # Push `true` to detect Symbol. `false` to increase the nest level for non-Symbol.
- @stack = []
- end
-
- # Return true if the token is a part of Symbol.
- def scan_token(token)
- prev_state = @stack.last
- case token
- when :on_symbeg, :on_symbols_beg, :on_qsymbols_beg
- @stack << true
- when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw, :on_backtick
- if @stack.last # Pop only when it's Symbol
- @stack.pop
- return prev_state
- end
- when :on_tstring_beg
- @stack << false
- when :on_embexpr_beg
- @stack << false
- return prev_state
- when :on_tstring_end # :on_tstring_end may close Symbol
- @stack.pop
- return prev_state
- when :on_embexpr_end
- @stack.pop
- end
- @stack.last
- end
- end
- private_constant :SymbolState
- end
-end
diff --git a/lib/irb/color_printer.rb b/lib/irb/color_printer.rb
deleted file mode 100644
index 31644aa7f9..0000000000
--- a/lib/irb/color_printer.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-require 'pp'
-require_relative 'color'
-
-module IRB
- class ColorPrinter < ::PP
- METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
- METHOD_INSPECT = Object.instance_method(:inspect)
-
- class << self
- def pp(obj, out = $>, width = screen_width)
- q = ColorPrinter.new(out, width)
- q.guard_inspect_key {q.pp obj}
- q.flush
- out << "\n"
- end
-
- private
-
- def screen_width
- Reline.get_screen_size.last
- rescue Errno::EINVAL # in `winsize': Invalid argument - <STDIN>
- 79
- end
- end
-
- def pp(obj)
- if String === obj
- # Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
- text(obj.inspect)
- elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
- text(METHOD_INSPECT.bind(obj).call)
- else
- super
- end
- end
-
- def text(str, width = nil)
- unless str.is_a?(String)
- str = str.inspect
- end
- width ||= str.length
-
- case str
- when ''
- when ',', '=>', '[', ']', '{', '}', '..', '...', /\A@\w+\z/
- super(str, width)
- when /\A#</, '=', '>'
- super(Color.colorize(str, [:GREEN]), width)
- else
- super(Color.colorize_code(str, ignore_error: true), width)
- end
- end
- end
-end
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
deleted file mode 100644
index c21ebfbdbd..0000000000
--- a/lib/irb/completion.rb
+++ /dev/null
@@ -1,479 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/completion.rb -
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-# From Original Idea of shugo@ruby-lang.org
-#
-
-require_relative 'ruby-lex'
-
-module IRB
- module InputCompletor # :nodoc:
- using Module.new {
- refine ::Binding do
- def eval_methods
- ::Kernel.instance_method(:methods).bind(eval("self")).call
- end
-
- def eval_private_methods
- ::Kernel.instance_method(:private_methods).bind(eval("self")).call
- end
-
- def eval_instance_variables
- ::Kernel.instance_method(:instance_variables).bind(eval("self")).call
- end
-
- def eval_global_variables
- ::Kernel.instance_method(:global_variables).bind(eval("self")).call
- end
-
- def eval_class_constants
- ::Module.instance_method(:constants).bind(eval("self.class")).call
- end
- end
- }
-
- # Set of reserved words used by Ruby, you should not use these for
- # constants or variables
- ReservedWords = %w[
- __ENCODING__ __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
- ]
-
- BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
-
- def self.absolute_path?(p) # TODO Remove this method after 2.6 EOL.
- if File.respond_to?(:absolute_path?)
- File.absolute_path?(p)
- else
- File.absolute_path(p) == p
- end
- end
-
- GEM_PATHS =
- if defined?(Gem::Specification)
- Gem::Specification.latest_specs(true).map { |s|
- s.require_paths.map { |p|
- if absolute_path?(p)
- p
- else
- File.join(s.full_gem_path, p)
- end
- }
- }.flatten
- else
- []
- end.freeze
-
- def self.retrieve_gem_and_system_load_path
- candidates = (GEM_PATHS | $LOAD_PATH)
- candidates.map do |p|
- if p.respond_to?(:to_path)
- p.to_path
- else
- String(p) rescue nil
- end
- end.compact.sort
- end
-
- def self.retrieve_files_to_require_from_load_path
- @@files_from_load_path ||=
- (
- shortest = []
- rest = retrieve_gem_and_system_load_path.each_with_object([]) { |path, result|
- begin
- names = Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
- rescue Errno::ENOENT
- nil
- end
- next if names.empty?
- names.map! { |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort!
- shortest << names.shift
- result.concat(names)
- }
- shortest.sort! | rest
- )
- end
-
- def self.retrieve_files_to_require_relative_from_current_dir
- @@files_from_current_dir ||= Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: '.').map { |path|
- path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
- }
- end
-
- CompletionRequireProc = lambda { |target, preposing = nil, postposing = nil|
- if target =~ /\A(['"])([^'"]+)\Z/
- quote = $1
- actual_target = $2
- else
- return nil # It's not String literal
- end
- tokens = RubyLex.ripper_lex_without_warning(preposing.gsub(/\s*\z/, ''))
- tok = nil
- tokens.reverse_each do |t|
- unless [:on_lparen, :on_sp, :on_ignored_sp, :on_nl, :on_ignored_nl, :on_comment].include?(t.event)
- tok = t
- break
- end
- end
- result = []
- if tok && tok.event == :on_ident && tok.state == Ripper::EXPR_CMDARG
- case tok.tok
- when 'require'
- result = retrieve_files_to_require_from_load_path.select { |path|
- path.start_with?(actual_target)
- }.map { |path|
- quote + path
- }
- when 'require_relative'
- result = retrieve_files_to_require_relative_from_current_dir.select { |path|
- path.start_with?(actual_target)
- }.map { |path|
- quote + path
- }
- end
- end
- result
- }
-
- CompletionProc = lambda { |target, preposing = nil, postposing = nil|
- if preposing && postposing
- result = CompletionRequireProc.(target, preposing, postposing)
- unless result
- result = retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
- end
- result
- else
- retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
- end
- }
-
- def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
- case input
- # this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
- # details are described in: https://github.com/ruby/irb/pull/523
- when /^(.*["'`])\.([^.]*)$/
- # String
- receiver = $1
- message = $2
-
- if doc_namespace
- "String.#{message}"
- else
- candidates = String.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates)
- end
-
- # this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
- # details are described in: https://github.com/ruby/irb/pull/523
- when /^(.*\/)\.([^.]*)$/
- # Regexp
- receiver = $1
- message = $2
-
- if doc_namespace
- "Regexp.#{message}"
- else
- candidates = Regexp.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates)
- end
-
- when /^([^\]]*\])\.([^.]*)$/
- # Array
- receiver = $1
- message = $2
-
- if doc_namespace
- "Array.#{message}"
- else
- candidates = Array.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates)
- end
-
- when /^([^\}]*\})\.([^.]*)$/
- # Proc or Hash
- receiver = $1
- message = $2
-
- if doc_namespace
- ["Proc.#{message}", "Hash.#{message}"]
- else
- proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
- hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, proc_candidates | hash_candidates)
- end
-
- when /^(:[^:.]+)$/
- # Symbol
- if doc_namespace
- nil
- else
- sym = $1
- candidates = Symbol.all_symbols.collect do |s|
- ":" + s.id2name.encode(Encoding.default_external)
- rescue EncodingError
- # ignore
- end
- candidates.grep(/^#{Regexp.quote(sym)}/)
- end
- when /^::([A-Z][^:\.\(\)]*)$/
- # Absolute Constant or class methods
- receiver = $1
-
- candidates = Object.constants.collect{|m| m.to_s}
-
- if doc_namespace
- candidates.find { |i| i == receiver }
- else
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
- end
-
- when /^([A-Z].*)::([^:.]*)$/
- # Constant or class methods
- receiver = $1
- message = $2
-
- if doc_namespace
- "#{receiver}::#{message}"
- else
- begin
- candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
- candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
- rescue Exception
- candidates = []
- end
-
- select_message(receiver, message, candidates.sort, "::")
- end
-
- when /^(:[^:.]+)(\.|::)([^.]*)$/
- # Symbol
- receiver = $1
- sep = $2
- message = $3
-
- if doc_namespace
- "Symbol.#{message}"
- else
- candidates = Symbol.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates, sep)
- end
-
- when /^(?<num>-?(?:0[dbo])?[0-9_]+(?:\.[0-9_]+)?(?:(?:[eE][+-]?[0-9]+)?i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
- # Numeric
- receiver = $~[:num]
- sep = $~[:sep]
- message = $~[:mes]
-
- begin
- instance = eval(receiver, bind)
-
- if doc_namespace
- "#{instance.class.name}.#{message}"
- else
- candidates = instance.methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates, sep)
- end
- rescue Exception
- if doc_namespace
- nil
- else
- []
- end
- end
-
- when /^(-?0x[0-9a-fA-F_]+)(\.|::)([^.]*)$/
- # Numeric(0xFFFF)
- receiver = $1
- sep = $2
- message = $3
-
- begin
- instance = eval(receiver, bind)
- if doc_namespace
- "#{instance.class.name}.#{message}"
- else
- candidates = instance.methods.collect{|m| m.to_s}
- select_message(receiver, message, candidates, sep)
- end
- rescue Exception
- if doc_namespace
- nil
- else
- []
- end
- end
-
- when /^(\$[^.]*)$/
- # global var
- gvar = $1
- all_gvars = global_variables.collect{|m| m.to_s}
-
- if doc_namespace
- all_gvars.find{ |i| i == gvar }
- else
- all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
- end
-
- when /^([^.:"].*)(\.|::)([^.]*)$/
- # variable.func or func.func
- receiver = $1
- sep = $2
- message = $3
-
- gv = bind.eval_global_variables.collect{|m| m.to_s}.push("true", "false", "nil")
- lv = bind.local_variables.collect{|m| m.to_s}
- iv = bind.eval_instance_variables.collect{|m| m.to_s}
- cv = bind.eval_class_constants.collect{|m| m.to_s}
-
- if (gv | lv | iv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
- # foo.func and foo is var. OR
- # foo::func and foo is var. OR
- # foo::Const and foo is var. OR
- # Foo::Bar.func
- begin
- candidates = []
- rec = eval(receiver, bind)
- if sep == "::" and rec.kind_of?(Module)
- candidates = rec.constants.collect{|m| m.to_s}
- end
- candidates |= rec.methods.collect{|m| m.to_s}
- rescue Exception
- candidates = []
- end
- else
- # func1.func2
- candidates = []
- end
-
- if doc_namespace
- rec_class = rec.is_a?(Module) ? rec : rec.class
- "#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
- else
- select_message(receiver, message, candidates, sep)
- end
-
- when /^\.([^.]*)$/
- # unknown(maybe String)
-
- receiver = ""
- message = $1
-
- candidates = String.instance_methods(true).collect{|m| m.to_s}
-
- if doc_namespace
- "String.#{candidates.find{ |i| i == message }}"
- else
- select_message(receiver, message, candidates.sort)
- end
-
- else
- if doc_namespace
- vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
- perfect_match_var = vars.find{|m| m.to_s == input}
- if perfect_match_var
- eval("#{perfect_match_var}.class.name", bind)
- else
- candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
- candidates |= ReservedWords
- candidates.find{ |i| i == input }
- end
- else
- candidates = (bind.eval_methods | bind.eval_private_methods | bind.local_variables | bind.eval_instance_variables | bind.eval_class_constants).collect{|m| m.to_s}
- candidates |= ReservedWords
- candidates.grep(/^#{Regexp.quote(input)}/).sort
- end
- end
- end
-
- PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
- begin
- require 'rdoc'
- rescue LoadError
- return
- end
-
- RDocRIDriver ||= RDoc::RI::Driver.new
-
- if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
- IRB.__send__(:easter_egg)
- return
- end
-
- namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
- return unless namespace
-
- if namespace.is_a?(Array)
- out = RDoc::Markup::Document.new
- namespace.each do |m|
- begin
- RDocRIDriver.add_method(out, m)
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
- RDocRIDriver.display(out)
- else
- begin
- RDocRIDriver.display_names([namespace])
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
- }
-
- # Set of available operators in Ruby
- Operators = %w[% & * ** + - / < << <= <=> == === =~ > >= >> [] []= ^ ! != !~]
-
- def self.select_message(receiver, message, candidates, sep = ".")
- candidates.grep(/^#{Regexp.quote(message)}/).collect do |e|
- case e
- when /^[a-zA-Z_]/
- receiver + sep + e
- when /^[0-9]/
- when *Operators
- #receiver + " " + e
- end
- end
- end
-
- def self.ignored_modules
- # We could cache the result, but this is very fast already.
- # By using this approach, we avoid Module#name calls, which are
- # relatively slow when there are a lot of anonymous modules defined.
- s = {}
-
- scanner = lambda do |m|
- next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
- s[m] = true
- m.constants(false).each do |c|
- value = m.const_get(c)
- scanner.call(value) if value.is_a?(Module)
- end
- end
-
- %i(IRB RubyLex).each do |sym|
- next unless Object.const_defined?(sym)
- scanner.call(Object.const_get(sym))
- end
-
- s.delete(IRB::Context) if defined?(IRB::Context)
-
- s
- end
- end
-end
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
deleted file mode 100644
index f398c6f75d..0000000000
--- a/lib/irb/context.rb
+++ /dev/null
@@ -1,555 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/context.rb - irb context
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "workspace"
-require_relative "inspector"
-require_relative "input-method"
-require_relative "output-method"
-
-module IRB
- # A class that wraps the current state of the irb session, including the
- # configuration of IRB.conf.
- class Context
- # Creates a new IRB context.
- #
- # The optional +input_method+ argument:
- #
- # +nil+:: uses stdin or Reline or Readline
- # +String+:: uses a File
- # +other+:: uses this as InputMethod
- def initialize(irb, workspace = nil, input_method = nil)
- @irb = irb
- if workspace
- @workspace = workspace
- else
- @workspace = WorkSpace.new
- end
- @thread = Thread.current
-
- # copy of default configuration
- @ap_name = IRB.conf[:AP_NAME]
- @rc = IRB.conf[:RC]
- @load_modules = IRB.conf[:LOAD_MODULES]
-
- if IRB.conf.has_key?(:USE_SINGLELINE)
- @use_singleline = IRB.conf[:USE_SINGLELINE]
- elsif IRB.conf.has_key?(:USE_READLINE) # backward compatibility
- @use_singleline = IRB.conf[:USE_READLINE]
- else
- @use_singleline = nil
- end
- if IRB.conf.has_key?(:USE_MULTILINE)
- @use_multiline = IRB.conf[:USE_MULTILINE]
- elsif IRB.conf.has_key?(:USE_RELINE) # backward compatibility
- warn <<~MSG.strip
- USE_RELINE is deprecated, please use USE_MULTILINE instead.
- MSG
- @use_multiline = IRB.conf[:USE_RELINE]
- elsif IRB.conf.has_key?(:USE_REIDLINE)
- warn <<~MSG.strip
- USE_REIDLINE is deprecated, please use USE_MULTILINE instead.
- MSG
- @use_multiline = IRB.conf[:USE_REIDLINE]
- else
- @use_multiline = nil
- end
- @use_autocomplete = IRB.conf[:USE_AUTOCOMPLETE]
- @verbose = IRB.conf[:VERBOSE]
- @io = nil
-
- self.inspect_mode = IRB.conf[:INSPECT_MODE]
- self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
- self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
- self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
-
- @ignore_sigint = IRB.conf[:IGNORE_SIGINT]
- @ignore_eof = IRB.conf[:IGNORE_EOF]
-
- @back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
-
- self.prompt_mode = IRB.conf[:PROMPT_MODE]
-
- if IRB.conf[:SINGLE_IRB] or !defined?(IRB::JobManager)
- @irb_name = IRB.conf[:IRB_NAME]
- else
- @irb_name = IRB.conf[:IRB_NAME]+"#"+IRB.JobManager.n_jobs.to_s
- end
- @irb_path = "(" + @irb_name + ")"
-
- case input_method
- when nil
- @io = nil
- case use_multiline?
- when nil
- if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
- # Both of multiline mode and singleline mode aren't specified.
- @io = RelineInputMethod.new
- else
- @io = nil
- end
- when false
- @io = nil
- when true
- @io = RelineInputMethod.new
- end
- unless @io
- case use_singleline?
- when nil
- if (defined?(ReadlineInputMethod) && STDIN.tty? &&
- IRB.conf[:PROMPT_MODE] != :INF_RUBY)
- @io = ReadlineInputMethod.new
- else
- @io = nil
- end
- when false
- @io = nil
- when true
- if defined?(ReadlineInputMethod)
- @io = ReadlineInputMethod.new
- else
- @io = nil
- end
- else
- @io = nil
- end
- end
- @io = StdioInputMethod.new unless @io
-
- when '-'
- @io = FileInputMethod.new($stdin)
- @irb_name = '-'
- @irb_path = '-'
- when String
- @io = FileInputMethod.new(input_method)
- @irb_name = File.basename(input_method)
- @irb_path = input_method
- else
- @io = input_method
- end
- self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
-
- @extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]
-
- @echo = IRB.conf[:ECHO]
- if @echo.nil?
- @echo = true
- end
-
- @echo_on_assignment = IRB.conf[:ECHO_ON_ASSIGNMENT]
- if @echo_on_assignment.nil?
- @echo_on_assignment = :truncate
- end
-
- @newline_before_multiline_output = IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]
- if @newline_before_multiline_output.nil?
- @newline_before_multiline_output = true
- end
-
- @command_aliases = IRB.conf[:COMMAND_ALIASES]
- end
-
- # The top-level workspace, see WorkSpace#main
- def main
- @workspace.main
- end
-
- # The toplevel workspace, see #home_workspace
- attr_reader :workspace_home
- # WorkSpace in the current context.
- attr_accessor :workspace
- # The current thread in this context.
- attr_reader :thread
- # The current input method.
- #
- # Can be either StdioInputMethod, ReadlineInputMethod,
- # RelineInputMethod, FileInputMethod or other specified when the
- # context is created. See ::new for more # information on +input_method+.
- attr_accessor :io
-
- # Current irb session.
- attr_accessor :irb
- # A copy of the default <code>IRB.conf[:AP_NAME]</code>
- attr_accessor :ap_name
- # A copy of the default <code>IRB.conf[:RC]</code>
- attr_accessor :rc
- # A copy of the default <code>IRB.conf[:LOAD_MODULES]</code>
- attr_accessor :load_modules
- # Can be either name from <code>IRB.conf[:IRB_NAME]</code>, or the number of
- # the current job set by JobManager, such as <code>irb#2</code>
- attr_accessor :irb_name
- # Can be either the #irb_name surrounded by parenthesis, or the
- # +input_method+ passed to Context.new
- attr_accessor :irb_path
-
- # Whether multiline editor mode is enabled or not.
- #
- # A copy of the default <code>IRB.conf[:USE_MULTILINE]</code>
- attr_reader :use_multiline
- # Whether singleline editor mode is enabled or not.
- #
- # A copy of the default <code>IRB.conf[:USE_SINGLELINE]</code>
- attr_reader :use_singleline
- # Whether colorization is enabled or not.
- #
- # A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
- attr_reader :use_autocomplete
- # A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
- attr_reader :inspect_mode
-
- # A copy of the default <code>IRB.conf[:PROMPT_MODE]</code>
- attr_reader :prompt_mode
- # Standard IRB prompt.
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_i
- # IRB prompt for continuated strings.
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_s
- # IRB prompt for continuated statement. (e.g. immediately after an +if+)
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_c
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_n
- # Can be either the default <code>IRB.conf[:AUTO_INDENT]</code>, or the
- # mode set by #prompt_mode=
- #
- # To disable auto-indentation in irb:
- #
- # IRB.conf[:AUTO_INDENT] = false
- #
- # or
- #
- # irb_context.auto_indent_mode = false
- #
- # or
- #
- # IRB.CurrentContext.auto_indent_mode = false
- #
- # See IRB@Configuration for more information.
- attr_accessor :auto_indent_mode
- # The format of the return statement, set by #prompt_mode= using the
- # +:RETURN+ of the +mode+ passed to set the current #prompt_mode.
- attr_accessor :return_format
-
- # Whether <code>^C</code> (+control-c+) will be ignored or not.
- #
- # If set to +false+, <code>^C</code> will quit irb.
- #
- # If set to +true+,
- #
- # * during input: cancel input then return to top level.
- # * during execute: abandon current execution.
- attr_accessor :ignore_sigint
- # Whether <code>^D</code> (+control-d+) will be ignored or not.
- #
- # If set to +false+, <code>^D</code> will quit irb.
- attr_accessor :ignore_eof
- # Specify the installation locations of the ri file to be displayed in the
- # document dialog.
- attr_accessor :extra_doc_dirs
- # Whether to echo the return value to output or not.
- #
- # Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.
- #
- # puts "hello"
- # # hello
- # #=> nil
- # IRB.CurrentContext.echo = false
- # puts "omg"
- # # omg
- attr_accessor :echo
- # Whether to echo for assignment expressions.
- #
- # If set to +false+, the value of assignment will not be shown.
- #
- # If set to +true+, the value of assignment will be shown.
- #
- # If set to +:truncate+, the value of assignment will be shown and truncated.
- #
- # It defaults to +:truncate+.
- #
- # a = "omg"
- # #=> omg
- #
- # a = "omg" * 10
- # #=> omgomgomgomgomgomgomg...
- #
- # IRB.CurrentContext.echo_on_assignment = false
- # a = "omg"
- #
- # IRB.CurrentContext.echo_on_assignment = true
- # a = "omg" * 10
- # #=> omgomgomgomgomgomgomgomgomgomg
- #
- # To set the behaviour of showing on assignment in irb:
- #
- # IRB.conf[:ECHO_ON_ASSIGNMENT] = :truncate or true or false
- #
- # or
- #
- # irb_context.echo_on_assignment = :truncate or true or false
- #
- # or
- #
- # IRB.CurrentContext.echo_on_assignment = :truncate or true or false
- attr_accessor :echo_on_assignment
- # Whether a newline is put before multiline output.
- #
- # Uses <code>IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]</code> if available,
- # or defaults to +true+.
- #
- # "abc\ndef"
- # #=>
- # abc
- # def
- # IRB.CurrentContext.newline_before_multiline_output = false
- # "abc\ndef"
- # #=> abc
- # def
- attr_accessor :newline_before_multiline_output
- # Whether verbose messages are displayed or not.
- #
- # A copy of the default <code>IRB.conf[:VERBOSE]</code>
- attr_accessor :verbose
-
- # The limit of backtrace lines displayed as top +n+ and tail +n+.
- #
- # The default value is 16.
- #
- # Can also be set using the +--back-trace-limit+ command line option.
- #
- # See IRB@Command+line+options for more command line options.
- attr_accessor :back_trace_limit
-
- # User-defined IRB command aliases
- attr_accessor :command_aliases
-
- # Alias for #use_multiline
- alias use_multiline? use_multiline
- # Alias for #use_singleline
- alias use_singleline? use_singleline
- # backward compatibility
- alias use_reline use_multiline
- # backward compatibility
- alias use_reline? use_multiline
- # backward compatibility
- alias use_readline use_singleline
- # backward compatibility
- alias use_readline? use_singleline
- # Alias for #use_autocomplete
- alias use_autocomplete? use_autocomplete
- # Alias for #rc
- alias rc? rc
- alias ignore_sigint? ignore_sigint
- alias ignore_eof? ignore_eof
- alias echo? echo
- alias echo_on_assignment? echo_on_assignment
- alias newline_before_multiline_output? newline_before_multiline_output
-
- # Returns whether messages are displayed or not.
- def verbose?
- if @verbose.nil?
- if @io.kind_of?(RelineInputMethod)
- false
- elsif defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
- false
- elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
- true
- else
- false
- end
- else
- @verbose
- end
- end
-
- # Whether #verbose? is +true+, and +input_method+ is either
- # StdioInputMethod or RelineInputMethod or ReadlineInputMethod, see #io
- # for more information.
- def prompting?
- verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
- @io.kind_of?(RelineInputMethod) ||
- (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
- end
-
- # The return value of the last statement evaluated.
- attr_reader :last_value
-
- # Sets the return value from the last statement evaluated in this context
- # to #last_value.
- def set_last_value(value)
- @last_value = value
- @workspace.local_variable_set :_, value
- end
-
- # Sets the +mode+ of the prompt in this context.
- #
- # See IRB@Customizing+the+IRB+Prompt for more information.
- def prompt_mode=(mode)
- @prompt_mode = mode
- pconf = IRB.conf[:PROMPT][mode]
- @prompt_i = pconf[:PROMPT_I]
- @prompt_s = pconf[:PROMPT_S]
- @prompt_c = pconf[:PROMPT_C]
- @prompt_n = pconf[:PROMPT_N]
- @return_format = pconf[:RETURN]
- @return_format = "%s\n" if @return_format == nil
- if ai = pconf.include?(:AUTO_INDENT)
- @auto_indent_mode = ai
- else
- @auto_indent_mode = IRB.conf[:AUTO_INDENT]
- end
- end
-
- # Whether #inspect_mode is set or not, see #inspect_mode= for more detail.
- def inspect?
- @inspect_mode.nil? or @inspect_mode
- end
-
- # Whether #io uses a File for the +input_method+ passed when creating the
- # current context, see ::new
- def file_input?
- @io.class == FileInputMethod
- end
-
- # Specifies the inspect mode with +opt+:
- #
- # +true+:: display +inspect+
- # +false+:: display +to_s+
- # +nil+:: inspect mode in non-math mode,
- # non-inspect mode in math mode
- #
- # See IRB::Inspector for more information.
- #
- # Can also be set using the +--inspect+ and +--noinspect+ command line
- # options.
- #
- # See IRB@Command+line+options for more command line options.
- def inspect_mode=(opt)
-
- if i = Inspector::INSPECTORS[opt]
- @inspect_mode = opt
- @inspect_method = i
- i.init
- else
- case opt
- when nil
- if Inspector.keys_with_inspector(Inspector::INSPECTORS[true]).include?(@inspect_mode)
- self.inspect_mode = false
- elsif Inspector.keys_with_inspector(Inspector::INSPECTORS[false]).include?(@inspect_mode)
- self.inspect_mode = true
- else
- puts "Can't switch inspect mode."
- return
- end
- when /^\s*\{.*\}\s*$/
- begin
- inspector = eval "proc#{opt}"
- rescue Exception
- puts "Can't switch inspect mode(#{opt})."
- return
- end
- self.inspect_mode = inspector
- when Proc
- self.inspect_mode = IRB::Inspector(opt)
- when Inspector
- prefix = "usr%d"
- i = 1
- while Inspector::INSPECTORS[format(prefix, i)]; i += 1; end
- @inspect_mode = format(prefix, i)
- @inspect_method = opt
- Inspector.def_inspector(format(prefix, i), @inspect_method)
- else
- puts "Can't switch inspect mode(#{opt})."
- return
- end
- end
- print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
- @inspect_mode
- end
-
- def evaluate(line, line_no, exception: nil) # :nodoc:
- @line_no = line_no
- if exception
- line_no -= 1
- line = "begin ::Kernel.raise _; rescue _.class\n#{line}\n""end"
- @workspace.local_variable_set(:_, exception)
- end
-
- # Transform a non-identifier alias (@, $) or keywords (next, break)
- command, args = line.split(/\s/, 2)
- if original = command_aliases[command.to_sym]
- line = line.gsub(/\A#{Regexp.escape(command)}/, original.to_s)
- command = original
- end
-
- # Hook command-specific transformation
- command_class = ExtendCommandBundle.load_command(command)
- if command_class&.respond_to?(:transform_args)
- line = "#{command} #{command_class.transform_args(args)}"
- end
-
- set_last_value(@workspace.evaluate(line, irb_path, line_no))
- end
-
- def inspect_last_value # :nodoc:
- @inspect_method.inspect_value(@last_value)
- end
-
- alias __exit__ exit
- # Exits the current session, see IRB.irb_exit
- def exit(ret = 0)
- IRB.irb_exit(@irb, ret)
- rescue UncaughtThrowError
- super
- end
-
- NOPRINTING_IVARS = ["@last_value"] # :nodoc:
- NO_INSPECTING_IVARS = ["@irb", "@io"] # :nodoc:
- IDNAME_IVARS = ["@prompt_mode"] # :nodoc:
-
- alias __inspect__ inspect
- def inspect # :nodoc:
- array = []
- for ivar in instance_variables.sort{|e1, e2| e1 <=> e2}
- ivar = ivar.to_s
- name = ivar.sub(/^@(.*)$/, '\1')
- val = instance_eval(ivar)
- case ivar
- when *NOPRINTING_IVARS
- array.push format("conf.%s=%s", name, "...")
- when *NO_INSPECTING_IVARS
- array.push format("conf.%s=%s", name, val.to_s)
- when *IDNAME_IVARS
- array.push format("conf.%s=:%s", name, val.id2name)
- else
- array.push format("conf.%s=%s", name, val.inspect)
- end
- end
- array.join("\n")
- end
- alias __to_s__ to_s
- alias to_s inspect
-
- def local_variables # :nodoc:
- workspace.binding.local_variables
- end
-
- # Return true if it's aliased from the argument and it's not an identifier.
- def symbol_alias?(command)
- return nil if command.match?(/\A\w+\z/)
- command_aliases.key?(command.to_sym)
- end
-
- # Return true if the command supports transforming args
- def transform_args?(command)
- command = command_aliases.fetch(command.to_sym, command)
- ExtendCommandBundle.load_command(command)&.respond_to?(:transform_args)
- end
- end
-end
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb
deleted file mode 100644
index 3e79692de9..0000000000
--- a/lib/irb/easter-egg.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-require "reline"
-
-module IRB
- class << self
- class Vec
- def initialize(x, y, z)
- @x, @y, @z = x, y, z
- end
-
- attr_reader :x, :y, :z
-
- def sub(other)
- Vec.new(@x - other.x, @y - other.y, @z - other.z)
- end
-
- def dot(other)
- @x*other.x + @y*other.y + @z*other.z
- end
-
- def cross(other)
- ox, oy, oz = other.x, other.y, other.z
- Vec.new(@y*oz-@z*oy, @z*ox-@x*oz, @x*oy-@y*ox)
- end
-
- def normalize
- r = Math.sqrt(self.dot(self))
- Vec.new(@x / r, @y / r, @z / r)
- end
- end
-
- class Canvas
- def initialize((h, w))
- @data = (0..h-2).map { [0] * w }
- @scale = [w / 2.0, h-2].min
- @center = Complex(w / 2, h-2)
- end
-
- def line((x1, y1), (x2, y2))
- p1 = Complex(x1, y1) / 2 * @scale + @center
- p2 = Complex(x2, y2) / 2 * @scale + @center
- line0(p1, p2)
- end
-
- private def line0(p1, p2)
- mid = (p1 + p2) / 2
- if (p1 - p2).abs < 1
- x, y = mid.rect
- @data[y / 2][x] |= (y % 2 > 1 ? 2 : 1)
- else
- line0(p1, mid)
- line0(p2, mid)
- end
- end
-
- def draw
- @data.each {|row| row.fill(0) }
- yield
- @data.map {|row| row.map {|n| " ',;"[n] }.join }.join("\n")
- end
- end
-
- class RubyModel
- def initialize
- @faces = init_ruby_model
- end
-
- def init_ruby_model
- cap_vertices = (0..5).map {|i| Vec.new(*Complex.polar(1, i * Math::PI / 3).rect, 1) }
- middle_vertices = (0..5).map {|i| Vec.new(*Complex.polar(2, (i + 0.5) * Math::PI / 3).rect, 0) }
- bottom_vertex = Vec.new(0, 0, -2)
-
- faces = [cap_vertices]
- 6.times do |j|
- i = j-1
- faces << [cap_vertices[i], middle_vertices[i], cap_vertices[j]]
- faces << [cap_vertices[j], middle_vertices[i], middle_vertices[j]]
- faces << [middle_vertices[i], bottom_vertex, middle_vertices[j]]
- end
-
- faces
- end
-
- def render_frame(i)
- angle = i / 10.0
- dir = Vec.new(*Complex.polar(1, angle).rect, Math.sin(angle)).normalize
- dir2 = Vec.new(*Complex.polar(1, angle - Math::PI/2).rect, 0)
- up = dir.cross(dir2)
- nm = dir.cross(up)
- @faces.each do |vertices|
- v0, v1, v2, = vertices
- if v1.sub(v0).cross(v2.sub(v0)).dot(dir) > 0
- points = vertices.map {|p| [nm.dot(p), up.dot(p)] }
- (points + [points[0]]).each_cons(2) do |p1, p2|
- yield p1, p2
- end
- end
- end
- end
- end
-
- private def easter_egg(type = nil)
- type ||= [:logo, :dancing].sample
- case type
- when :logo
- File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
- require "rdoc"
- RDoc::RI::Driver.new.page do |io|
- IO.copy_stream(f, io)
- end
- end
- when :dancing
- begin
- canvas = Canvas.new(Reline.get_screen_size)
- Reline::IOGate.set_winch_handler do
- canvas = Canvas.new(Reline.get_screen_size)
- end
- ruby_model = RubyModel.new
- print "\e[?1049h"
- 0.step do |i| # TODO (0..).each needs Ruby 2.6 or later
- buff = canvas.draw do
- ruby_model.render_frame(i) do |p1, p2|
- canvas.line(p1, p2)
- end
- end
- buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
- print "\e[H" + buff
- sleep 0.05
- end
- rescue Interrupt
- ensure
- print "\e[0m\e[?1049l"
- end
- end
- end
- end
-end
-
-IRB.__send__(:easter_egg, ARGV[0]&.to_sym) if $0 == __FILE__
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
deleted file mode 100644
index c0f810a4c8..0000000000
--- a/lib/irb/ext/change-ws.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/ext/cb.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
- class Context
-
- # Inherited from +TOPLEVEL_BINDING+.
- def home_workspace
- if defined? @home_workspace
- @home_workspace
- else
- @home_workspace = @workspace
- end
- end
-
- # Changes the current workspace to given object or binding.
- #
- # If the optional argument is omitted, the workspace will be
- # #home_workspace which is inherited from +TOPLEVEL_BINDING+ or the main
- # object, <code>IRB.conf[:MAIN_CONTEXT]</code> when irb was initialized.
- #
- # See IRB::WorkSpace.new for more information.
- def change_workspace(*_main)
- if _main.empty?
- @workspace = home_workspace
- return main
- end
-
- @workspace = WorkSpace.new(_main[0])
-
- if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
- main.extend ExtendCommandBundle
- end
- end
- end
-end
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
deleted file mode 100644
index 5243504efa..0000000000
--- a/lib/irb/ext/history.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-# frozen_string_literal: false
-#
-# history.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
-
- class Context
-
- NOPRINTING_IVARS.push "@eval_history_values"
-
- # See #set_last_value
- alias _set_last_value set_last_value
-
- def set_last_value(value)
- _set_last_value(value)
-
- if defined?(@eval_history) && @eval_history
- @eval_history_values.push @line_no, @last_value
- @workspace.evaluate "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
- end
-
- @last_value
- end
-
- remove_method :eval_history= if method_defined?(:eval_history=)
- # The command result history limit. This method is not available until
- # #eval_history= was called with non-nil value (directly or via
- # setting <code>IRB.conf[:EVAL_HISTORY]</code> in <code>.irbrc</code>).
- attr_reader :eval_history
- # Sets command result history limit. Default value is set from
- # <code>IRB.conf[:EVAL_HISTORY]</code>.
- #
- # +no+ is an Integer or +nil+.
- #
- # Returns +no+ of history items if greater than 0.
- #
- # If +no+ is 0, the number of history items is unlimited.
- #
- # If +no+ is +nil+, execution result history isn't used (default).
- #
- # History values are available via <code>__</code> variable, see
- # IRB::History.
- def eval_history=(no)
- if no
- if defined?(@eval_history) && @eval_history
- @eval_history_values.size(no)
- else
- @eval_history_values = History.new(no)
- IRB.conf[:__TMP__EHV__] = @eval_history_values
- @workspace.evaluate("__ = IRB.conf[:__TMP__EHV__]")
- IRB.conf.delete(:__TMP_EHV__)
- end
- else
- @eval_history_values = nil
- end
- @eval_history = no
- end
- end
-
- # Represents history of results of previously evaluated commands.
- #
- # Available via <code>__</code> variable, only if <code>IRB.conf[:EVAL_HISTORY]</code>
- # or <code>IRB::CurrentContext().eval_history</code> is non-nil integer value
- # (by default it is +nil+).
- #
- # Example (in `irb`):
- #
- # # Initialize history
- # IRB::CurrentContext().eval_history = 10
- # # => 10
- #
- # # Perform some commands...
- # 1 + 2
- # # => 3
- # puts 'x'
- # # x
- # # => nil
- # raise RuntimeError
- # # ...error raised
- #
- # # Inspect history (format is "<item number> <evaluated value>":
- # __
- # # => 1 10
- # # 2 3
- # # 3 nil
- #
- # __[1]
- # # => 10
- #
- class History
-
- def initialize(size = 16) # :nodoc:
- @size = size
- @contents = []
- end
-
- def size(size) # :nodoc:
- if size != 0 && size < @size
- @contents = @contents[@size - size .. @size]
- end
- @size = size
- end
-
- # Get one item of the content (both positive and negative indexes work).
- def [](idx)
- begin
- if idx >= 0
- @contents.find{|no, val| no == idx}[1]
- else
- @contents[idx][1]
- end
- rescue NameError
- nil
- end
- end
-
- def push(no, val) # :nodoc:
- @contents.push [no, val]
- @contents.shift if @size != 0 && @contents.size > @size
- end
-
- alias real_inspect inspect
-
- def inspect # :nodoc:
- if @contents.empty?
- return real_inspect
- end
-
- unless (last = @contents.pop)[1].equal?(self)
- @contents.push last
- last = nil
- end
- str = @contents.collect{|no, val|
- if val.equal?(self)
- "#{no} ...self-history..."
- else
- "#{no} #{val.inspect}"
- end
- }.join("\n")
- if str == ""
- str = "Empty."
- end
- @contents.push last if last
- str
- end
- end
-end
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
deleted file mode 100644
index 0a599ee802..0000000000
--- a/lib/irb/ext/loader.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-# frozen_string_literal: false
-#
-# loader.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
- # Raised in the event of an exception in a file loaded from an Irb session
- class LoadAbort < Exception;end
-
- # Provides a few commands for loading files within an irb session.
- #
- # See ExtendCommandBundle for more information.
- module IrbLoader
-
- alias ruby_load load
- alias ruby_require require
-
- # Loads the given file similarly to Kernel#load
- def irb_load(fn, priv = nil)
- path = search_file_from_ruby_path(fn)
- raise LoadError, "No such file to load -- #{fn}" unless path
-
- load_file(path, priv)
- end
-
- if File.respond_to?(:absolute_path?)
- def absolute_path?(path)
- File.absolute_path?(path)
- end
- else
- separator =
- if File::ALT_SEPARATOR
- "[#{Regexp.quote(File::SEPARATOR + File::ALT_SEPARATOR)}]"
- else
- File::SEPARATOR
- end
- ABSOLUTE_PATH_PATTERN = # :nodoc:
- case Dir.pwd
- when /\A\w:/, /\A#{separator}{2}/
- /\A(?:\w:|#{separator})#{separator}/
- else
- /\A#{separator}/
- end
- def absolute_path?(path)
- ABSOLUTE_PATH_PATTERN =~ path
- end
- end
-
- def search_file_from_ruby_path(fn) # :nodoc:
- if absolute_path?(fn)
- return fn if File.exist?(fn)
- return nil
- end
-
- for path in $:
- if File.exist?(f = File.join(path, fn))
- return f
- end
- end
- return nil
- end
-
- # Loads a given file in the current session and displays the source lines
- #
- # See Irb#suspend_input_method for more information.
- def source_file(path)
- irb.suspend_name(path, File.basename(path)) do
- FileInputMethod.open(path) do |io|
- irb.suspend_input_method(io) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
- end
- end
- end
-
- # Loads the given file in the current session's context and evaluates it.
- #
- # See Irb#suspend_input_method for more information.
- def load_file(path, priv = nil)
- irb.suspend_name(path, File.basename(path)) do
-
- if priv
- ws = WorkSpace.new(Module.new)
- else
- ws = WorkSpace.new
- end
- irb.suspend_workspace(ws) do
- FileInputMethod.open(path) do |io|
- irb.suspend_input_method(io) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
- end
- end
- end
- end
-
- def old # :nodoc:
- back_io = @io
- back_path = @irb_path
- back_name = @irb_name
- back_scanner = @irb.scanner
- begin
- @io = FileInputMethod.new(path)
- @irb_name = File.basename(path)
- @irb_path = path
- @irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- @irb.eval_input
- else
- begin
- @irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- ensure
- @io = back_io
- @irb_name = back_name
- @irb_path = back_path
- @irb.scanner = back_scanner
- end
- end
- end
-end
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
deleted file mode 100644
index 1c20489137..0000000000
--- a/lib/irb/ext/multi-irb.rb
+++ /dev/null
@@ -1,258 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/multi-irb.rb - multiple irb module
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- class JobManager
-
- # Creates a new JobManager object
- def initialize
- @jobs = []
- @current_job = nil
- end
-
- # The active irb session
- attr_accessor :current_job
-
- # The total number of irb sessions, used to set +irb_name+ of the current
- # Context.
- def n_jobs
- @jobs.size
- end
-
- # Returns the thread for the given +key+ object, see #search for more
- # information.
- def thread(key)
- th, = search(key)
- th
- end
-
- # Returns the irb session for the given +key+ object, see #search for more
- # information.
- def irb(key)
- _, irb = search(key)
- irb
- end
-
- # Returns the top level thread.
- def main_thread
- @jobs[0][0]
- end
-
- # Returns the top level irb session.
- def main_irb
- @jobs[0][1]
- end
-
- # Add the given +irb+ session to the jobs Array.
- def insert(irb)
- @jobs.push [Thread.current, irb]
- end
-
- # Changes the current active irb session to the given +key+ in the jobs
- # Array.
- #
- # Raises an IrbAlreadyDead exception if the given +key+ is no longer alive.
- #
- # If the given irb session is already active, an IrbSwitchedToCurrentThread
- # exception is raised.
- def switch(key)
- th, irb = search(key)
- fail IrbAlreadyDead unless th.alive?
- fail IrbSwitchedToCurrentThread if th == Thread.current
- @current_job = irb
- th.run
- Thread.stop
- @current_job = irb(Thread.current)
- end
-
- # Terminates the irb sessions specified by the given +keys+.
- #
- # Raises an IrbAlreadyDead exception if one of the given +keys+ is already
- # terminated.
- #
- # See Thread#exit for more information.
- def kill(*keys)
- for key in keys
- th, _ = search(key)
- fail IrbAlreadyDead unless th.alive?
- th.exit
- end
- end
-
- # Returns the associated job for the given +key+.
- #
- # If given an Integer, it will return the +key+ index for the jobs Array.
- #
- # When an instance of Irb is given, it will return the irb session
- # associated with +key+.
- #
- # If given an instance of Thread, it will return the associated thread
- # +key+ using Object#=== on the jobs Array.
- #
- # Otherwise returns the irb session with the same top-level binding as the
- # given +key+.
- #
- # Raises a NoSuchJob exception if no job can be found with the given +key+.
- def search(key)
- job = case key
- when Integer
- @jobs[key]
- when Irb
- @jobs.find{|k, v| v.equal?(key)}
- when Thread
- @jobs.assoc(key)
- else
- @jobs.find{|k, v| v.context.main.equal?(key)}
- end
- fail NoSuchJob, key if job.nil?
- job
- end
-
- # Deletes the job at the given +key+.
- def delete(key)
- case key
- when Integer
- fail NoSuchJob, key unless @jobs[key]
- @jobs[key] = nil
- else
- catch(:EXISTS) do
- @jobs.each_index do
- |i|
- if @jobs[i] and (@jobs[i][0] == key ||
- @jobs[i][1] == key ||
- @jobs[i][1].context.main.equal?(key))
- @jobs[i] = nil
- throw :EXISTS
- end
- end
- fail NoSuchJob, key
- end
- end
- until assoc = @jobs.pop; end unless @jobs.empty?
- @jobs.push assoc
- end
-
- # Outputs a list of jobs, see the irb command +irb_jobs+, or +jobs+.
- def inspect
- ary = []
- @jobs.each_index do
- |i|
- th, irb = @jobs[i]
- next if th.nil?
-
- if th.alive?
- if th.stop?
- t_status = "stop"
- else
- t_status = "running"
- end
- else
- t_status = "exited"
- end
- ary.push format("#%d->%s on %s (%s: %s)",
- i,
- irb.context.irb_name,
- irb.context.main,
- th,
- t_status)
- end
- ary.join("\n")
- end
- end
-
- @JobManager = JobManager.new
-
- # The current JobManager in the session
- def IRB.JobManager
- @JobManager
- end
-
- # The current Context in this session
- def IRB.CurrentContext
- IRB.JobManager.irb(Thread.current).context
- end
-
- # Creates a new IRB session, see Irb.new.
- #
- # The optional +file+ argument is given to Context.new, along with the
- # workspace created with the remaining arguments, see WorkSpace.new
- def IRB.irb(file = nil, *main)
- workspace = WorkSpace.new(*main)
- parent_thread = Thread.current
- Thread.start do
- begin
- irb = Irb.new(workspace, file)
- rescue
- print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
- print "return to main irb\n"
- Thread.pass
- Thread.main.wakeup
- Thread.exit
- end
- @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
- @JobManager.insert(irb)
- @JobManager.current_job = irb
- begin
- system_exit = false
- catch(:IRB_EXIT) do
- irb.eval_input
- end
- rescue SystemExit
- system_exit = true
- raise
- #fail
- ensure
- unless system_exit
- @JobManager.delete(irb)
- if @JobManager.current_job == irb
- if parent_thread.alive?
- @JobManager.current_job = @JobManager.irb(parent_thread)
- parent_thread.run
- else
- @JobManager.current_job = @JobManager.main_irb
- @JobManager.main_thread.run
- end
- end
- end
- end
- end
- Thread.stop
- @JobManager.current_job = @JobManager.irb(Thread.current)
- end
-
- @CONF[:SINGLE_IRB_MODE] = false
- @JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
- @JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
-
- class Irb
- def signal_handle
- unless @context.ignore_sigint?
- print "\nabort!!\n" if @context.verbose?
- exit
- end
-
- case @signal_status
- when :IN_INPUT
- print "^C\n"
- IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
- when :IN_EVAL
- IRB.irb_abort(self)
- when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
- when :IN_IRB
- # ignore
- else
- # ignore other cases as well
- end
- end
- end
-
- trap("SIGINT") do
- @JobManager.current_job.signal_handle
- Thread.stop
- end
-
-end
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
deleted file mode 100644
index b1987ea646..0000000000
--- a/lib/irb/ext/save-history.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# frozen_string_literal: false
-#
-# save-history.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- module HistorySavingAbility # :nodoc:
- end
-
- class Context
- def init_save_history# :nodoc:
- unless (class<<@io;self;end).include?(HistorySavingAbility)
- @io.extend(HistorySavingAbility)
- end
- end
-
- # A copy of the default <code>IRB.conf[:SAVE_HISTORY]</code>
- def save_history
- IRB.conf[:SAVE_HISTORY]
- end
-
- remove_method(:save_history=) if method_defined?(:save_history=)
- # Sets <code>IRB.conf[:SAVE_HISTORY]</code> to the given +val+ and calls
- # #init_save_history with this context.
- #
- # Will store the number of +val+ entries of history in the #history_file
- #
- # Add the following to your +.irbrc+ to change the number of history
- # entries stored to 1000:
- #
- # IRB.conf[:SAVE_HISTORY] = 1000
- def save_history=(val)
- IRB.conf[:SAVE_HISTORY] = val
- if val
- main_context = IRB.conf[:MAIN_CONTEXT]
- main_context = self unless main_context
- main_context.init_save_history
- end
- end
-
- # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
- def history_file
- IRB.conf[:HISTORY_FILE]
- end
-
- # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
- def history_file=(hist)
- IRB.conf[:HISTORY_FILE] = hist
- end
- end
-
- module HistorySavingAbility # :nodoc:
- def HistorySavingAbility.extended(obj)
- IRB.conf[:AT_EXIT].push proc{obj.save_history}
- obj.load_history
- obj
- end
-
- def load_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
- if File.exist?(history_file)
- File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
- f.each { |l|
- l = l.chomp
- if self.class == RelineInputMethod and history.last&.end_with?("\\")
- history.last.delete_suffix!("\\")
- history.last << "\n" << l
- else
- history << l
- end
- }
- end
- @loaded_history_lines = history.size
- @loaded_history_mtime = File.mtime(history_file)
- end
- end
-
- def save_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
- if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) != 0
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
-
- # Change the permission of a file that already exists[BUG #7694]
- begin
- if File.stat(history_file).mode & 066 != 0
- File.chmod(0600, history_file)
- end
- rescue Errno::ENOENT
- rescue Errno::EPERM
- return
- rescue
- raise
- end
-
- if File.exist?(history_file) &&
- File.mtime(history_file) != @loaded_history_mtime
- history = history[@loaded_history_lines..-1] if @loaded_history_lines
- append_history = true
- end
-
- File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
- hist = history.map{ |l| l.split("\n").join("\\\n") }
- unless append_history
- begin
- hist = hist.last(num) if hist.size > num and num > 0
- rescue RangeError # bignum too big to convert into `long'
- # Do nothing because the bignum should be treated as inifinity
- end
- end
- f.puts(hist)
- end
- end
- end
- end
-end
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
deleted file mode 100644
index 2d20cd3821..0000000000
--- a/lib/irb/ext/tracer.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/lib/tracer.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-begin
- require "tracer"
-rescue LoadError
- $stderr.puts "Tracer extension of IRB is enabled but tracer gem doesn't found."
- module IRB
- TracerLoadError = true
- class Context
- def use_tracer=(opt)
- # do nothing
- end
- end
- end
- return # This is about to disable loading below
-end
-
-module IRB
-
- # initialize tracing function
- def IRB.initialize_tracer
- Tracer.verbose = false
- Tracer.add_filter {
- |event, file, line, id, binding, *rests|
- /^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
- File::basename(file) != "irb.rb"
- }
- end
-
- class Context
- # Whether Tracer is used when evaluating statements in this context.
- #
- # See +lib/tracer.rb+ for more information.
- attr_reader :use_tracer
- alias use_tracer? use_tracer
-
- # Sets whether or not to use the Tracer library when evaluating statements
- # in this context.
- #
- # See +lib/tracer.rb+ for more information.
- def use_tracer=(opt)
- if opt
- Tracer.set_get_line_procs(@irb_path) {
- |line_no, *rests|
- @io.line(line_no)
- }
- elsif !opt && @use_tracer
- Tracer.off
- end
- @use_tracer=opt
- end
- end
-
- class WorkSpace
- alias __evaluate__ evaluate
- # Evaluate the context of this workspace and use the Tracer library to
- # output the exact lines of code are being executed in chronological order.
- #
- # See +lib/tracer.rb+ for more information.
- def evaluate(context, statements, file = nil, line = nil)
- if context.use_tracer? && file != nil && line != nil
- Tracer.on
- begin
- __evaluate__(statements, file, line)
- ensure
- Tracer.off
- end
- else
- __evaluate__(statements, file || __FILE__, line || __LINE__)
- end
- end
- end
-
- IRB.initialize_tracer
-end
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
deleted file mode 100644
index d0b8c2d4f4..0000000000
--- a/lib/irb/ext/use-loader.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: false
-#
-# use-loader.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "../cmd/load"
-require_relative "loader"
-
-class Object
- alias __original__load__IRB_use_loader__ load
- alias __original__require__IRB_use_loader__ require
-end
-
-module IRB
- module ExtendCommandBundle
- remove_method :irb_load if method_defined?(:irb_load)
- # Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
- def irb_load(*opts, &b)
- ExtendCommand::Load.execute(irb_context, *opts, &b)
- end
- remove_method :irb_require if method_defined?(:irb_require)
- # Loads the given file similarly to Kernel#require
- def irb_require(*opts, &b)
- ExtendCommand::Require.execute(irb_context, *opts, &b)
- end
- end
-
- class Context
-
- IRB.conf[:USE_LOADER] = false
-
- # Returns whether +irb+'s own file reader method is used by
- # +load+/+require+ or not.
- #
- # This mode is globally affected (irb-wide).
- def use_loader
- IRB.conf[:USE_LOADER]
- end
-
- alias use_loader? use_loader
-
- remove_method :use_loader= if method_defined?(:use_loader=)
- # Sets <code>IRB.conf[:USE_LOADER]</code>
- #
- # See #use_loader for more information.
- def use_loader=(opt)
-
- if IRB.conf[:USE_LOADER] != opt
- IRB.conf[:USE_LOADER] = opt
- if opt
- if !$".include?("irb/cmd/load")
- end
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :irb_load
- alias_method :require, :irb_require
- }
- else
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :__original__load__IRB_use_loader__
- alias_method :require, :__original__require__IRB_use_loader__
- }
- end
- end
- print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
- opt
- end
- end
-end
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
deleted file mode 100644
index 9defc3e17b..0000000000
--- a/lib/irb/ext/workspaces.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: false
-#
-# push-ws.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
- class Context
-
- # Size of the current WorkSpace stack
- def irb_level
- workspace_stack.size
- end
-
- # WorkSpaces in the current stack
- def workspaces
- if defined? @workspaces
- @workspaces
- else
- @workspaces = []
- end
- end
-
- # Creates a new workspace with the given object or binding, and appends it
- # onto the current #workspaces stack.
- #
- # See IRB::Context#change_workspace and IRB::WorkSpace.new for more
- # information.
- def push_workspace(*_main)
- if _main.empty?
- if workspaces.empty?
- print "No other workspace\n"
- return nil
- end
- ws = workspaces.pop
- workspaces.push @workspace
- @workspace = ws
- return workspaces
- end
-
- workspaces.push @workspace
- @workspace = WorkSpace.new(@workspace.binding, _main[0])
- if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
- main.extend ExtendCommandBundle
- end
- end
-
- # Removes the last element from the current #workspaces stack and returns
- # it, or +nil+ if the current workspace stack is empty.
- #
- # Also, see #push_workspace.
- def pop_workspace
- if workspaces.empty?
- print "workspace stack empty\n"
- return
- end
- @workspace = workspaces.pop
- end
- end
-end
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
deleted file mode 100644
index 5020b1e5cd..0000000000
--- a/lib/irb/extend-command.rb
+++ /dev/null
@@ -1,428 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/extend-command.rb - irb extend command
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
- # Installs the default irb extensions command bundle.
- module ExtendCommandBundle
- EXCB = ExtendCommandBundle # :nodoc:
-
- # See #install_alias_method.
- NO_OVERRIDE = 0
- # See #install_alias_method.
- OVERRIDE_PRIVATE_ONLY = 0x01
- # See #install_alias_method.
- OVERRIDE_ALL = 0x02
-
- # Quits the current irb context
- #
- # +ret+ is the optional signal or message to send to Context#exit
- #
- # Same as <code>IRB.CurrentContext.exit</code>.
- def irb_exit(ret = 0)
- irb_context.exit(ret)
- end
-
- # Displays current configuration.
- #
- # Modifying the configuration is achieved by sending a message to IRB.conf.
- def irb_context
- IRB.CurrentContext
- end
-
- @ALIASES = [
- [:context, :irb_context, NO_OVERRIDE],
- [:conf, :irb_context, NO_OVERRIDE],
- [:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- ]
-
-
- @EXTEND_COMMANDS = [
- [
- :irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
- [:cwws, NO_OVERRIDE],
- [:pwws, NO_OVERRIDE],
- [:irb_print_working_workspace, OVERRIDE_ALL],
- [:irb_cwws, OVERRIDE_ALL],
- [:irb_pwws, OVERRIDE_ALL],
- [:irb_current_working_binding, OVERRIDE_ALL],
- [:irb_print_working_binding, OVERRIDE_ALL],
- [:irb_cwb, OVERRIDE_ALL],
- [:irb_pwb, OVERRIDE_ALL],
- ],
- [
- :irb_change_workspace, :ChangeWorkspace, "cmd/chws",
- [:chws, NO_OVERRIDE],
- [:cws, NO_OVERRIDE],
- [:irb_chws, OVERRIDE_ALL],
- [:irb_cws, OVERRIDE_ALL],
- [:irb_change_binding, OVERRIDE_ALL],
- [:irb_cb, OVERRIDE_ALL],
- [:cb, NO_OVERRIDE],
- ],
-
- [
- :irb_workspaces, :Workspaces, "cmd/pushws",
- [:workspaces, NO_OVERRIDE],
- [:irb_bindings, OVERRIDE_ALL],
- [:bindings, NO_OVERRIDE],
- ],
- [
- :irb_push_workspace, :PushWorkspace, "cmd/pushws",
- [:pushws, NO_OVERRIDE],
- [:irb_pushws, OVERRIDE_ALL],
- [:irb_push_binding, OVERRIDE_ALL],
- [:irb_pushb, OVERRIDE_ALL],
- [:pushb, NO_OVERRIDE],
- ],
- [
- :irb_pop_workspace, :PopWorkspace, "cmd/pushws",
- [:popws, NO_OVERRIDE],
- [:irb_popws, OVERRIDE_ALL],
- [:irb_pop_binding, OVERRIDE_ALL],
- [:irb_popb, OVERRIDE_ALL],
- [:popb, NO_OVERRIDE],
- ],
-
- [
- :irb_load, :Load, "cmd/load"],
- [
- :irb_require, :Require, "cmd/load"],
- [
- :irb_source, :Source, "cmd/load",
- [:source, NO_OVERRIDE],
- ],
-
- [
- :irb, :IrbCommand, "cmd/subirb"],
- [
- :irb_jobs, :Jobs, "cmd/subirb",
- [:jobs, NO_OVERRIDE],
- ],
- [
- :irb_fg, :Foreground, "cmd/subirb",
- [:fg, NO_OVERRIDE],
- ],
- [
- :irb_kill, :Kill, "cmd/subirb",
- [:kill, OVERRIDE_PRIVATE_ONLY],
- ],
-
- [
- :irb_debug, :Debug, "cmd/debug",
- [:debug, NO_OVERRIDE],
- ],
- [
- :irb_edit, :Edit, "cmd/edit",
- [:edit, NO_OVERRIDE],
- ],
- [
- :irb_break, :Break, "cmd/break",
- ],
- [
- :irb_catch, :Catch, "cmd/catch",
- ],
- [
- :irb_next, :Next, "cmd/next"
- ],
- [
- :irb_delete, :Delete, "cmd/delete",
- [:delete, NO_OVERRIDE],
- ],
- [
- :irb_step, :Step, "cmd/step",
- [:step, NO_OVERRIDE],
- ],
- [
- :irb_continue, :Continue, "cmd/continue",
- [:continue, NO_OVERRIDE],
- ],
- [
- :irb_finish, :Finish, "cmd/finish",
- [:finish, NO_OVERRIDE],
- ],
- [
- :irb_backtrace, :Backtrace, "cmd/backtrace",
- [:backtrace, NO_OVERRIDE],
- [:bt, NO_OVERRIDE],
- ],
- [
- :irb_debug_info, :Info, "cmd/info",
- [:info, NO_OVERRIDE],
- ],
-
- [
- :irb_help, :Help, "cmd/help",
- [:show_doc, NO_OVERRIDE],
- [:help, NO_OVERRIDE],
- ],
-
- [
- :irb_info, :IrbInfo, "cmd/irb_info"
- ],
-
- [
- :irb_ls, :Ls, "cmd/ls",
- [:ls, NO_OVERRIDE],
- ],
-
- [
- :irb_measure, :Measure, "cmd/measure",
- [:measure, NO_OVERRIDE],
- ],
-
- [
- :irb_show_source, :ShowSource, "cmd/show_source",
- [:show_source, NO_OVERRIDE],
- ],
-
- [
- :irb_whereami, :Whereami, "cmd/whereami",
- [:whereami, NO_OVERRIDE],
- ],
- [
- :irb_show_cmds, :ShowCmds, "cmd/show_cmds",
- [:show_cmds, NO_OVERRIDE],
- ]
- ]
-
-
- @@commands = []
-
- def self.all_commands_info
- return @@commands unless @@commands.empty?
- user_aliases = IRB.CurrentContext.command_aliases.each_with_object({}) do |(alias_name, target), result|
- result[target] ||= []
- result[target] << alias_name
- end
-
- @EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
- if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
- require_relative load_file
- end
-
- klass = ExtendCommand.const_get(cmd_class, false)
- aliases = aliases.map { |a| a.first }
-
- if additional_aliases = user_aliases[cmd_name]
- aliases += additional_aliases
- end
-
- display_name = aliases.shift || cmd_name
- @@commands << { display_name: display_name, description: klass.description, category: klass.category }
- end
-
- @@commands
- end
-
- # Convert a command name to its implementation class if such command exists
- def self.load_command(command)
- command = command.to_sym
- @EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
- next if cmd_name != command && aliases.all? { |alias_name, _| alias_name != command }
-
- if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
- require_relative load_file
- end
- return ExtendCommand.const_get(cmd_class, false)
- end
- nil
- end
-
- # Installs the default irb commands.
- def self.install_extend_commands
- for args in @EXTEND_COMMANDS
- def_extend_command(*args)
- end
- end
-
- # Evaluate the given +cmd_name+ on the given +cmd_class+ Class.
- #
- # Will also define any given +aliases+ for the method.
- #
- # The optional +load_file+ parameter will be required within the method
- # definition.
- def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
- case cmd_class
- when Symbol
- cmd_class = cmd_class.id2name
- when String
- when Class
- cmd_class = cmd_class.name
- end
-
- if load_file
- kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
- line = __LINE__; eval %[
- def #{cmd_name}(*opts#{kwargs}, &b)
- Kernel.require_relative "#{load_file}"
- arity = ::IRB::ExtendCommand::#{cmd_class}.instance_method(:execute).arity
- args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
- args << "*opts#{kwargs}" if arity < 0
- args << "&block"
- args = args.join(", ")
- line = __LINE__; eval %[
- unless singleton_class.class_variable_defined?(:@@#{cmd_name}_)
- singleton_class.class_variable_set(:@@#{cmd_name}_, true)
- def self.#{cmd_name}_(\#{args})
- ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
- end
- end
- ], nil, __FILE__, line
- __send__ :#{cmd_name}_, *opts#{kwargs}, &b
- end
- ], nil, __FILE__, line
- else
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
- end
- ], nil, __FILE__, line
- end
-
- for ali, flag in aliases
- @ALIASES.push [ali, cmd_name, flag]
- end
- end
-
- # Installs alias methods for the default irb commands, see
- # ::install_extend_commands.
- def install_alias_method(to, from, override = NO_OVERRIDE)
- to = to.id2name unless to.kind_of?(String)
- from = from.id2name unless from.kind_of?(String)
-
- if override == OVERRIDE_ALL or
- (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
- (override == NO_OVERRIDE) && !respond_to?(to, true)
- target = self
- (class << self; self; end).instance_eval{
- if target.respond_to?(to, true) &&
- !target.respond_to?(EXCB.irb_original_method_name(to), true)
- alias_method(EXCB.irb_original_method_name(to), to)
- end
- alias_method to, from
- }
- else
- Kernel.print "irb: warn: can't alias #{to} from #{from}.\n"
- end
- end
-
- def self.irb_original_method_name(method_name) # :nodoc:
- "irb_" + method_name + "_org"
- end
-
- # Installs alias methods for the default irb commands on the given object
- # using #install_alias_method.
- def self.extend_object(obj)
- unless (class << obj; ancestors; end).include?(EXCB)
- super
- for ali, com, flg in @ALIASES
- obj.install_alias_method(ali, com, flg)
- end
- end
- end
-
- install_extend_commands
- end
-
- # Extends methods for the Context module
- module ContextExtender
- CE = ContextExtender # :nodoc:
-
- @EXTEND_COMMANDS = [
- [:eval_history=, "ext/history.rb"],
- [:use_tracer=, "ext/tracer.rb"],
- [:use_loader=, "ext/use-loader.rb"],
- [:save_history=, "ext/save-history.rb"],
- ]
-
- # Installs the default context extensions as irb commands:
- #
- # Context#eval_history=:: +irb/ext/history.rb+
- # Context#use_tracer=:: +irb/ext/tracer.rb+
- # Context#use_loader=:: +irb/ext/use-loader.rb+
- # Context#save_history=:: +irb/ext/save-history.rb+
- def self.install_extend_commands
- for args in @EXTEND_COMMANDS
- def_extend_command(*args)
- end
- end
-
- # Evaluate the given +command+ from the given +load_file+ on the Context
- # module.
- #
- # Will also define any given +aliases+ for the method.
- def self.def_extend_command(cmd_name, load_file, *aliases)
- line = __LINE__; Context.module_eval %[
- def #{cmd_name}(*opts, &b)
- Context.module_eval {remove_method(:#{cmd_name})}
- require_relative "#{load_file}"
- __send__ :#{cmd_name}, *opts, &b
- end
- for ali in aliases
- alias_method ali, cmd_name
- end
- ], __FILE__, line
- end
-
- CE.install_extend_commands
- end
-
- # A convenience module for extending Ruby methods.
- module MethodExtender
- # Extends the given +base_method+ with a prefix call to the given
- # +extend_method+.
- def def_pre_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- __send__ :#{extend_method}, *opts
- __send__ :#{alias_name}, *opts
- end
- ]
- end
-
- # Extends the given +base_method+ with a postfix call to the given
- # +extend_method+.
- def def_post_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- __send__ :#{alias_name}, *opts
- __send__ :#{extend_method}, *opts
- end
- ]
- end
-
- # Returns a unique method name to use as an alias for the given +name+.
- #
- # Usually returns <code>#{prefix}#{name}#{postfix}<num></code>, example:
- #
- # new_alias_name('foo') #=> __alias_of__foo__
- # def bar; end
- # new_alias_name('bar') #=> __alias_of__bar__2
- def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
- base_name = "#{prefix}#{name}#{postfix}"
- all_methods = instance_methods(true) + private_instance_methods(true)
- same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
- return base_name if same_methods.empty?
- no = same_methods.size
- while !same_methods.include?(alias_name = base_name + no)
- no += 1
- end
- alias_name
- end
- end
-end
diff --git a/lib/irb/frame.rb b/lib/irb/frame.rb
deleted file mode 100644
index 14768bd8f6..0000000000
--- a/lib/irb/frame.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: false
-#
-# frame.rb -
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
-#
-
-module IRB
- class Frame
- class FrameOverflow < StandardError
- def initialize
- super("frame overflow")
- end
- end
- class FrameUnderflow < StandardError
- def initialize
- super("frame underflow")
- end
- end
-
- # Default number of stack frames
- INIT_STACK_TIMES = 3
- # Default number of frames offset
- CALL_STACK_OFFSET = 3
-
- # Creates a new stack frame
- def initialize
- @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
- end
-
- # Used by Kernel#set_trace_func to register each event in the call stack
- def trace_func(event, file, line, id, binding)
- case event
- when 'call', 'class'
- @frames.push binding
- when 'return', 'end'
- @frames.pop
- end
- end
-
- # Returns the +n+ number of frames on the call stack from the last frame
- # initialized.
- #
- # Raises FrameUnderflow if there are no frames in the given stack range.
- def top(n = 0)
- bind = @frames[-(n + CALL_STACK_OFFSET)]
- fail FrameUnderflow unless bind
- bind
- end
-
- # Returns the +n+ number of frames on the call stack from the first frame
- # initialized.
- #
- # Raises FrameOverflow if there are no frames in the given stack range.
- def bottom(n = 0)
- bind = @frames[n]
- fail FrameOverflow unless bind
- bind
- end
-
- # Convenience method for Frame#bottom
- def Frame.bottom(n = 0)
- @backtrace.bottom(n)
- end
-
- # Convenience method for Frame#top
- def Frame.top(n = 0)
- @backtrace.top(n)
- end
-
- # Returns the binding context of the caller from the last frame initialized
- def Frame.sender
- eval "self", @backtrace.top
- end
-
- @backtrace = Frame.new
- set_trace_func proc{|event, file, line, id, binding, klass|
- @backtrace.trace_func(event, file, line, id, binding)
- }
- end
-end
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
deleted file mode 100644
index 7624d05dd4..0000000000
--- a/lib/irb/help.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/help.rb - print usage module
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-#
-
-require_relative 'magic-file'
-
-module IRB
- # Outputs the irb help message, see IRB@Command+line+options.
- def IRB.print_usage
- lc = IRB.conf[:LC_MESSAGES]
- path = lc.find("irb/help-message")
- space_line = false
- IRB::MagicFile.open(path){|f|
- f.each_line do |l|
- if /^\s*$/ =~ l
- lc.puts l unless space_line
- space_line = true
- next
- end
- space_line = false
-
- l.sub!(/#.*$/, "")
- next if /^\s*$/ =~ l
- lc.puts l
- end
- }
- end
-end
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
deleted file mode 100644
index 75a7f8d74c..0000000000
--- a/lib/irb/init.rb
+++ /dev/null
@@ -1,442 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/init.rb - irb initialize module
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
-
- # initialize config
- def IRB.setup(ap_path, argv: ::ARGV)
- IRB.init_config(ap_path)
- IRB.init_error
- IRB.parse_opts(argv: argv)
- IRB.run_config
- IRB.load_modules
-
- unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
- fail UndefinedPromptMode, @CONF[:PROMPT_MODE]
- end
- end
-
- # @CONF default setting
- def IRB.init_config(ap_path)
- # class instance variables
- @TRACER_INITIALIZED = false
-
- # default configurations
- unless ap_path and @CONF[:AP_NAME]
- ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
- end
- @CONF[:AP_NAME] = File::basename(ap_path, ".rb")
-
- @CONF[:IRB_NAME] = "irb"
- @CONF[:IRB_LIB_PATH] = File.dirname(__FILE__)
-
- @CONF[:RC] = true
- @CONF[:LOAD_MODULES] = []
- @CONF[:IRB_RC] = nil
-
- @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
- @CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
- @CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
- @CONF[:INSPECT_MODE] = true
- @CONF[:USE_TRACER] = false
- @CONF[:USE_LOADER] = false
- @CONF[:IGNORE_SIGINT] = true
- @CONF[:IGNORE_EOF] = false
- @CONF[:EXTRA_DOC_DIRS] = []
- @CONF[:ECHO] = nil
- @CONF[:ECHO_ON_ASSIGNMENT] = nil
- @CONF[:VERBOSE] = nil
-
- @CONF[:EVAL_HISTORY] = nil
- @CONF[:SAVE_HISTORY] = 1000
-
- @CONF[:BACK_TRACE_LIMIT] = 16
-
- @CONF[:PROMPT] = {
- :NULL => {
- :PROMPT_I => nil,
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n"
- },
- :DEFAULT => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "=> %s\n"
- },
- :CLASSIC => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "%s\n"
- },
- :SIMPLE => {
- :PROMPT_I => ">> ",
- :PROMPT_N => ">> ",
- :PROMPT_S => "%l> ",
- :PROMPT_C => "?> ",
- :RETURN => "=> %s\n"
- },
- :INF_RUBY => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n",
- :AUTO_INDENT => true
- },
- :XMP => {
- :PROMPT_I => nil,
- :PROMPT_N => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => " ==>%s\n"
- }
- }
-
- @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
- @CONF[:AUTO_INDENT] = true
-
- @CONF[:CONTEXT_MODE] = 4 # use a copy of TOPLEVEL_BINDING
- @CONF[:SINGLE_IRB] = false
-
- @CONF[:MEASURE] = false
- @CONF[:MEASURE_PROC] = {}
- @CONF[:MEASURE_PROC][:TIME] = proc { |context, code, line_no, &block|
- time = Time.now
- result = block.()
- now = Time.now
- puts 'processing time: %fs' % (now - time) if IRB.conf[:MEASURE]
- result
- }
- # arg can be either a symbol for the mode (:cpu, :wall, ..) or a hash for
- # a more complete configuration.
- # See https://github.com/tmm1/stackprof#all-options.
- @CONF[:MEASURE_PROC][:STACKPROF] = proc { |context, code, line_no, arg, &block|
- return block.() unless IRB.conf[:MEASURE]
- success = false
- begin
- require 'stackprof'
- success = true
- rescue LoadError
- puts 'Please run "gem install stackprof" before measuring by StackProf.'
- end
- if success
- result = nil
- arg = { mode: arg || :cpu } unless arg.is_a?(Hash)
- stackprof_result = StackProf.run(**arg) do
- result = block.()
- end
- case stackprof_result
- when File
- puts "StackProf report saved to #{stackprof_result.path}"
- when Hash
- StackProf::Report.new(stackprof_result).print_text
- else
- puts "Stackprof ran with #{arg.inspect}"
- end
- result
- else
- block.()
- end
- }
- @CONF[:MEASURE_CALLBACKS] = []
-
- @CONF[:LC_MESSAGES] = Locale.new
-
- @CONF[:AT_EXIT] = []
-
- @CONF[:COMMAND_ALIASES] = {
- # Symbol aliases
- :'$' => :show_source,
- :'@' => :whereami,
- # Keyword aliases
- :break => :irb_break,
- :catch => :irb_catch,
- :next => :irb_next,
- }
- end
-
- def IRB.set_measure_callback(type = nil, arg = nil, &block)
- added = nil
- if type
- type_sym = type.upcase.to_sym
- if IRB.conf[:MEASURE_PROC][type_sym]
- added = [type_sym, IRB.conf[:MEASURE_PROC][type_sym], arg]
- end
- elsif IRB.conf[:MEASURE_PROC][:CUSTOM]
- added = [:CUSTOM, IRB.conf[:MEASURE_PROC][:CUSTOM], arg]
- elsif block_given?
- added = [:BLOCK, block, arg]
- found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
- if found
- found[1] = block
- return added
- else
- IRB.conf[:MEASURE_CALLBACKS] << added
- return added
- end
- else
- added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
- end
- if added
- found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
- if found
- # already added
- nil
- else
- IRB.conf[:MEASURE_CALLBACKS] << added if added
- added
- end
- else
- nil
- end
- end
-
- def IRB.unset_measure_callback(type = nil)
- if type.nil?
- IRB.conf[:MEASURE_CALLBACKS].clear
- else
- type_sym = type.upcase.to_sym
- IRB.conf[:MEASURE_CALLBACKS].reject!{ |t, | t == type_sym }
- end
- end
-
- def IRB.init_error
- @CONF[:LC_MESSAGES].load("irb/error.rb")
- end
-
- # option analyzing
- def IRB.parse_opts(argv: ::ARGV)
- load_path = []
- while opt = argv.shift
- case opt
- when "-f"
- @CONF[:RC] = false
- when "-d"
- $DEBUG = true
- $VERBOSE = true
- when "-w"
- Warning[:deprecated] = $VERBOSE = true
- when /^-W(.+)?/
- opt = $1 || argv.shift
- case opt
- when "0"
- $VERBOSE = nil
- when "1"
- $VERBOSE = false
- else
- Warning[:deprecated] = $VERBOSE = true
- end
- when /^-r(.+)?/
- opt = $1 || argv.shift
- @CONF[:LOAD_MODULES].push opt if opt
- when /^-I(.+)?/
- opt = $1 || argv.shift
- load_path.concat(opt.split(File::PATH_SEPARATOR)) if opt
- when '-U'
- set_encoding("UTF-8", "UTF-8")
- when /^-E(.+)?/, /^--encoding(?:=(.+))?/
- opt = $1 || argv.shift
- set_encoding(*opt.split(':', 2))
- when "--inspect"
- if /^-/ !~ argv.first
- @CONF[:INSPECT_MODE] = argv.shift
- else
- @CONF[:INSPECT_MODE] = true
- end
- when "--noinspect"
- @CONF[:INSPECT_MODE] = false
- when "--singleline", "--readline", "--legacy"
- @CONF[:USE_SINGLELINE] = true
- when "--nosingleline", "--noreadline"
- @CONF[:USE_SINGLELINE] = false
- when "--multiline", "--reidline"
- if opt == "--reidline"
- warn <<~MSG.strip
- --reidline is deprecated, please use --multiline instead.
- MSG
- end
-
- @CONF[:USE_MULTILINE] = true
- when "--nomultiline", "--noreidline"
- if opt == "--noreidline"
- warn <<~MSG.strip
- --noreidline is deprecated, please use --nomultiline instead.
- MSG
- end
-
- @CONF[:USE_MULTILINE] = false
- when /^--extra-doc-dir(?:=(.+))?/
- opt = $1 || argv.shift
- @CONF[:EXTRA_DOC_DIRS] << opt
- when "--echo"
- @CONF[:ECHO] = true
- when "--noecho"
- @CONF[:ECHO] = false
- when "--echo-on-assignment"
- @CONF[:ECHO_ON_ASSIGNMENT] = true
- when "--noecho-on-assignment"
- @CONF[:ECHO_ON_ASSIGNMENT] = false
- when "--truncate-echo-on-assignment"
- @CONF[:ECHO_ON_ASSIGNMENT] = :truncate
- when "--verbose"
- @CONF[:VERBOSE] = true
- when "--noverbose"
- @CONF[:VERBOSE] = false
- when "--colorize"
- @CONF[:USE_COLORIZE] = true
- when "--nocolorize"
- @CONF[:USE_COLORIZE] = false
- when "--autocomplete"
- @CONF[:USE_AUTOCOMPLETE] = true
- when "--noautocomplete"
- @CONF[:USE_AUTOCOMPLETE] = false
- when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
- opt = $1 || argv.shift
- prompt_mode = opt.upcase.tr("-", "_").intern
- @CONF[:PROMPT_MODE] = prompt_mode
- when "--noprompt"
- @CONF[:PROMPT_MODE] = :NULL
- when "--script"
- noscript = false
- when "--noscript"
- noscript = true
- when "--inf-ruby-mode"
- @CONF[:PROMPT_MODE] = :INF_RUBY
- when "--sample-book-mode", "--simple-prompt"
- @CONF[:PROMPT_MODE] = :SIMPLE
- when "--tracer"
- @CONF[:USE_TRACER] = true
- when /^--back-trace-limit(?:=(.+))?/
- @CONF[:BACK_TRACE_LIMIT] = ($1 || argv.shift).to_i
- when /^--context-mode(?:=(.+))?/
- @CONF[:CONTEXT_MODE] = ($1 || argv.shift).to_i
- when "--single-irb"
- @CONF[:SINGLE_IRB] = true
- when "-v", "--version"
- print IRB.version, "\n"
- exit 0
- when "-h", "--help"
- require_relative "help"
- IRB.print_usage
- exit 0
- when "--"
- if !noscript && (opt = argv.shift)
- @CONF[:SCRIPT] = opt
- $0 = opt
- end
- break
- when /^-./
- fail UnrecognizedSwitch, opt
- else
- if noscript
- argv.unshift(opt)
- else
- @CONF[:SCRIPT] = opt
- $0 = opt
- end
- break
- end
- end
-
- load_path.collect! do |path|
- /\A\.\// =~ path ? path : File.expand_path(path)
- end
- $LOAD_PATH.unshift(*load_path)
- end
-
- # running config
- def IRB.run_config
- if @CONF[:RC]
- begin
- load rc_file
- rescue LoadError, Errno::ENOENT
- rescue # StandardError, ScriptError
- print "load error: #{rc_file}\n"
- print $!.class, ": ", $!, "\n"
- for err in $@[0, $@.size - 2]
- print "\t", err, "\n"
- end
- end
- end
- end
-
- IRBRC_EXT = "rc"
- def IRB.rc_file(ext = IRBRC_EXT)
- if !@CONF[:RC_NAME_GENERATOR]
- rc_file_generators do |rcgen|
- @CONF[:RC_NAME_GENERATOR] ||= rcgen
- if File.exist?(rcgen.call(IRBRC_EXT))
- @CONF[:RC_NAME_GENERATOR] = rcgen
- break
- end
- end
- end
- case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
- when String
- return rc_file
- else
- fail IllegalRCNameGenerator
- end
- end
-
- # enumerate possible rc-file base name generators
- def IRB.rc_file_generators
- if irbrc = ENV["IRBRC"]
- yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
- end
- if xdg_config_home = ENV["XDG_CONFIG_HOME"]
- irb_home = File.join(xdg_config_home, "irb")
- if File.directory?(irb_home)
- yield proc{|rc| irb_home + "/irb#{rc}"}
- end
- end
- if home = ENV["HOME"]
- yield proc{|rc| home+"/.irb#{rc}"}
- yield proc{|rc| home+"/.config/irb/irb#{rc}"}
- end
- current_dir = Dir.pwd
- yield proc{|rc| current_dir+"/.irb#{rc}"}
- yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
- yield proc{|rc| current_dir+"/_irb#{rc}"}
- yield proc{|rc| current_dir+"/$irb#{rc}"}
- end
-
- # loading modules
- def IRB.load_modules
- for m in @CONF[:LOAD_MODULES]
- begin
- require m
- rescue LoadError => err
- warn "#{err.class}: #{err}", uplevel: 0
- end
- end
- end
-
- class << IRB
- private
- def set_encoding(extern, intern = nil, override: true)
- verbose, $VERBOSE = $VERBOSE, nil
- Encoding.default_external = extern unless extern.nil? || extern.empty?
- Encoding.default_internal = intern unless intern.nil? || intern.empty?
- [$stdin, $stdout, $stderr].each do |io|
- io.set_encoding(extern, intern)
- end
- if override
- @CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
- else
- @CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
- end
- ensure
- $VERBOSE = verbose
- end
- end
-end
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
deleted file mode 100644
index bc61805ebb..0000000000
--- a/lib/irb/input-method.rb
+++ /dev/null
@@ -1,478 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/input-method.rb - input methods used irb
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative 'src_encoding'
-require_relative 'magic-file'
-require_relative 'completion'
-require 'io/console'
-require 'reline'
-
-module IRB
- STDIN_FILE_NAME = "(line)" # :nodoc:
- class InputMethod
-
- # Creates a new input method object
- def initialize(file = STDIN_FILE_NAME)
- @file_name = file
- end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
-
- # The irb prompt associated with this input method
- attr_accessor :prompt
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- fail NotImplementedError, "gets"
- end
- public :gets
-
- def winsize
- if instance_variable_defined?(:@stdout) && @stdout.tty?
- @stdout.winsize
- else
- [24, 80]
- end
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- false
- end
-
- # For debug message
- def inspect
- 'Abstract InputMethod'
- end
- end
-
- class StdioInputMethod < InputMethod
- # Creates a new input method object
- def initialize
- super
- @line_no = 0
- @line = []
- @stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- print @prompt
- line = @stdin.gets
- @line[@line_no += 1] = line
- end
-
- # Whether the end of this input method has been reached, returns +true+ if
- # there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- if @stdin.wait_readable(0.00001)
- c = @stdin.getc
- result = c.nil? ? true : false
- @stdin.ungetc(c) unless c.nil?
- result
- else # buffer is empty
- false
- end
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
-
- # For debug message
- def inspect
- 'StdioInputMethod'
- end
- end
-
- # Use a File for IO with irb, see InputMethod
- class FileInputMethod < InputMethod
- class << self
- def open(file, &block)
- begin
- io = new(file)
- block.call(io)
- ensure
- io&.close
- end
- end
- end
-
- # Creates a new input method object
- def initialize(file)
- super
- @io = file.is_a?(IO) ? file : IRB::MagicFile.open(file)
- @external_encoding = @io.external_encoding
- end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
-
- # Whether the end of this input method has been reached, returns +true+ if
- # there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @io.closed? || @io.eof?
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- print @prompt
- @io.gets
- end
-
- # The external encoding for standard input.
- def encoding
- @external_encoding
- end
-
- # For debug message
- def inspect
- 'FileInputMethod'
- end
-
- def close
- @io.close
- end
- end
-
- begin
- class ReadlineInputMethod < InputMethod
- def self.initialize_readline
- require "readline"
- rescue LoadError
- else
- include ::Readline
- end
-
- # Creates a new input method object using Readline
- def initialize
- self.class.initialize_readline
- if Readline.respond_to?(:encoding_system_needs)
- IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
- end
- super
-
- @line_no = 0
- @line = []
- @eof = false
-
- @stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
-
- if Readline.respond_to?("basic_word_break_characters=")
- Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
- Readline.completion_append_character = nil
- Readline.completion_proc = IRB::InputCompletor::CompletionProc
- end
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- Readline.input = @stdin
- Readline.output = @stdout
- if l = readline(@prompt, false)
- HISTORY.push(l) if !l.empty?
- @line[@line_no += 1] = l + "\n"
- else
- @eof = true
- l
- end
- end
-
- # Whether the end of this input method has been reached, returns +true+
- # if there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @eof
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
-
- # For debug message
- def inspect
- readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
- str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- str += " and #{inputrc_path}" if File.exist?(inputrc_path)
- str
- end
- end
- end
-
- class RelineInputMethod < InputMethod
- include Reline
-
- # Creates a new input method object using Reline
- def initialize
- IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
- super
-
- @line_no = 0
- @line = []
- @eof = false
-
- @stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
-
- if Reline.respond_to?("basic_word_break_characters=")
- Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
- Reline.completion_append_character = nil
- Reline.completer_quote_characters = ''
- Reline.completion_proc = IRB::InputCompletor::CompletionProc
- Reline.output_modifier_proc =
- if IRB.conf[:USE_COLORIZE]
- proc do |output, complete: |
- next unless IRB::Color.colorable?
- lvars = IRB.CurrentContext&.local_variables || []
- IRB::Color.colorize_code(output, complete: complete, local_variables: lvars)
- end
- else
- proc do |output|
- Reline::Unicode.escape_for_print(output)
- end
- end
- Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
- Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
-
- if IRB.conf[:USE_AUTOCOMPLETE]
- begin
- require 'rdoc'
- Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
- rescue LoadError
- end
- end
- end
-
- def check_termination(&block)
- @check_termination_proc = block
- end
-
- def dynamic_prompt(&block)
- @prompt_proc = block
- end
-
- def auto_indent(&block)
- @auto_indent_proc = block
- end
-
- SHOW_DOC_DIALOG = ->() {
- dialog.trap_key = nil
- alt_d = [
- [Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
- [27, 100], # Normal Alt+d when convert-meta isn't used.
- [195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
- [226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
- ]
-
- if just_cursor_moving and completion_journey_data.nil?
- return nil
- end
- cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
- return nil if result.nil? or pointer.nil? or pointer < 0
- name = result[pointer]
- name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
-
- options = {}
- options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
- driver = RDoc::RI::Driver.new(options)
-
- if key.match?(dialog.name)
- begin
- driver.display_names([name])
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
-
- begin
- name = driver.expand_name(name)
- rescue RDoc::RI::Driver::NotFoundError
- return nil
- rescue
- return nil # unknown error
- end
- doc = nil
- used_for_class = false
- if not name =~ /#|\./
- found, klasses, includes, extends = driver.classes_and_includes_and_extends_for(name)
- if not found.empty?
- doc = driver.class_document(name, found, klasses, includes, extends)
- used_for_class = true
- end
- end
- unless used_for_class
- doc = RDoc::Markup::Document.new
- begin
- driver.add_method(doc, name)
- rescue RDoc::RI::Driver::NotFoundError
- doc = nil
- rescue
- return nil # unknown error
- end
- end
- return nil if doc.nil?
- width = 40
-
- right_x = cursor_pos_to_render.x + autocomplete_dialog.width
- if right_x + width > screen_width
- right_width = screen_width - (right_x + 1)
- left_x = autocomplete_dialog.column - width
- left_x = 0 if left_x < 0
- left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
- if right_width.positive? and left_width.positive?
- if right_width >= left_width
- width = right_width
- x = right_x
- else
- width = left_width
- x = left_x
- end
- elsif right_width.positive? and left_width <= 0
- width = right_width
- x = right_x
- elsif right_width <= 0 and left_width.positive?
- width = left_width
- x = left_x
- else # Both are negative width.
- return nil
- end
- else
- x = right_x
- end
- formatter = RDoc::Markup::ToAnsi.new
- formatter.width = width
- dialog.trap_key = alt_d
- message = 'Press Alt+d to read the full document'
- contents = [message] + doc.accept(formatter).split("\n")
-
- y = cursor_pos_to_render.y
- DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
- }
-
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- Reline.input = @stdin
- Reline.output = @stdout
- Reline.prompt_proc = @prompt_proc
- Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
- if l = readmultiline(@prompt, false, &@check_termination_proc)
- HISTORY.push(l) if !l.empty?
- @line[@line_no += 1] = l + "\n"
- else
- @eof = true
- l
- end
- end
-
- # Whether the end of this input method has been reached, returns +true+
- # if there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @eof
- end
-
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
-
- # For debug message
- def inspect
- config = Reline::Config.new
- str = "RelineInputMethod with Reline #{Reline::VERSION}"
- if config.respond_to?(:inputrc_path)
- inputrc_path = File.expand_path(config.inputrc_path)
- else
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- end
- str += " and #{inputrc_path}" if File.exist?(inputrc_path)
- str
- end
- end
-
- class ReidlineInputMethod < RelineInputMethod
- def initialize
- warn <<~MSG.strip
- IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
- MSG
- super
- end
- end
-end
diff --git a/lib/irb/inspector.rb b/lib/irb/inspector.rb
deleted file mode 100644
index bdfa282f0d..0000000000
--- a/lib/irb/inspector.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/inspector.rb - inspect methods
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
-
-
- # Convenience method to create a new Inspector, using the given +inspect+
- # proc, and optional +init+ proc and passes them to Inspector.new
- #
- # irb(main):001:0> ins = IRB::Inspector(proc{ |v| "omg! #{v}" })
- # irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! #<IRB::Inspector:0x007f46f7ba7d28>
- # irb(main):001:0> "what?" #=> omg! what?
- #
- def IRB::Inspector(inspect, init = nil)
- Inspector.new(inspect, init)
- end
-
- # An irb inspector
- #
- # In order to create your own custom inspector there are two things you
- # should be aware of:
- #
- # Inspector uses #inspect_value, or +inspect_proc+, for output of return values.
- #
- # This also allows for an optional #init+, or +init_proc+, which is called
- # when the inspector is activated.
- #
- # Knowing this, you can create a rudimentary inspector as follows:
- #
- # irb(main):001:0> ins = IRB::Inspector.new(proc{ |v| "omg! #{v}" })
- # irb(main):001:0> IRB.CurrentContext.inspect_mode = ins # => omg! #<IRB::Inspector:0x007f46f7ba7d28>
- # irb(main):001:0> "what?" #=> omg! what?
- #
- class Inspector
- KERNEL_INSPECT = Object.instance_method(:inspect)
- # Default inspectors available to irb, this includes:
- #
- # +:pp+:: Using Kernel#pretty_inspect
- # +:yaml+:: Using YAML.dump
- # +:marshal+:: Using Marshal.dump
- INSPECTORS = {}
-
- # Determines the inspector to use where +inspector+ is one of the keys passed
- # during inspector definition.
- def self.keys_with_inspector(inspector)
- INSPECTORS.select{|k,v| v == inspector}.collect{|k, v| k}
- end
-
- # Example
- #
- # Inspector.def_inspector(key, init_p=nil){|v| v.inspect}
- # Inspector.def_inspector([key1,..], init_p=nil){|v| v.inspect}
- # Inspector.def_inspector(key, inspector)
- # Inspector.def_inspector([key1,...], inspector)
- def self.def_inspector(key, arg=nil, &block)
- if block_given?
- inspector = IRB::Inspector(block, arg)
- else
- inspector = arg
- end
-
- case key
- when Array
- for k in key
- def_inspector(k, inspector)
- end
- when Symbol
- INSPECTORS[key] = inspector
- INSPECTORS[key.to_s] = inspector
- when String
- INSPECTORS[key] = inspector
- INSPECTORS[key.intern] = inspector
- else
- INSPECTORS[key] = inspector
- end
- end
-
- # Creates a new inspector object, using the given +inspect_proc+ when
- # output return values in irb.
- def initialize(inspect_proc, init_proc = nil)
- @init = init_proc
- @inspect = inspect_proc
- end
-
- # Proc to call when the inspector is activated, good for requiring
- # dependent libraries.
- def init
- @init.call if @init
- end
-
- # Proc to call when the input is evaluated and output in irb.
- def inspect_value(v)
- @inspect.call(v)
- rescue => e
- puts "An error occurred when inspecting the object: #{e.inspect}"
-
- begin
- # TODO: change this to bind_call when we drop support for Ruby 2.6
- puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind(v).call}"
- ''
- rescue => e
- puts "An error occurred when running Kernel#inspect: #{e.inspect}"
- puts e.backtrace.join("\n")
- ''
- end
- end
- end
-
- Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
- Inspector.def_inspector([:p, :inspect]){|v|
- Color.colorize_code(v.inspect, colorable: Color.colorable? && Color.inspect_colorable?(v))
- }
- Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require_relative "color_printer"}){|v|
- IRB::ColorPrinter.pp(v, '').chomp
- }
- Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
- begin
- YAML.dump(v)
- rescue
- puts "(can't dump yaml. use inspect)"
- v.inspect
- end
- }
-
- Inspector.def_inspector([:marshal, :Marshal, :MARSHAL, Marshal]){|v|
- Marshal.dump(v)
- }
-end
diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec
deleted file mode 100644
index 20c187f37f..0000000000
--- a/lib/irb/irb.gemspec
+++ /dev/null
@@ -1,45 +0,0 @@
-begin
- require_relative "lib/irb/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "irb"
- spec.version = IRB::VERSION
- spec.authors = ["aycabta", "Keiju ISHITSUKA"]
- spec.email = ["aycabta@gmail.com", "keiju@ruby-lang.org"]
-
- spec.summary = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
- spec.description = %q{Interactive Ruby command-line tool for REPL (Read Eval Print Loop).}
- spec.homepage = "https://github.com/ruby/irb"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
- spec.metadata["documentation_uri"] = spec.homepage
- spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
-
- spec.files = [
- ".document",
- "Gemfile",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "bin/console",
- "bin/setup",
- "doc/irb/irb-tools.rd.ja",
- "doc/irb/irb.rd.ja",
- "exe/irb",
- "irb.gemspec",
- "man/irb.1",
- ] + Dir.glob("lib/**/*")
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
-
- spec.add_dependency "reline", ">= 0.3.0"
-end
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
deleted file mode 100644
index a5ec150865..0000000000
--- a/lib/irb/lc/error.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/lc/error.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- # :stopdoc:
-
- class UnrecognizedSwitch < StandardError
- def initialize(val)
- super("Unrecognized switch: #{val}")
- end
- end
- class NotImplementedError < StandardError
- def initialize(val)
- super("Need to define `#{val}'")
- end
- end
- class CantReturnToNormalMode < StandardError
- def initialize
- super("Can't return to normal mode.")
- end
- end
- class IllegalParameter < StandardError
- def initialize(val)
- super("Invalid parameter(#{val}).")
- end
- end
- class IrbAlreadyDead < StandardError
- def initialize
- super("Irb is already dead.")
- end
- end
- class IrbSwitchedToCurrentThread < StandardError
- def initialize
- super("Switched to current thread.")
- end
- end
- class NoSuchJob < StandardError
- def initialize(val)
- super("No such job(#{val}).")
- end
- end
- class CantChangeBinding < StandardError
- def initialize(val)
- super("Can't change binding to (#{val}).")
- end
- end
- class UndefinedPromptMode < StandardError
- def initialize(val)
- super("Undefined prompt mode(#{val}).")
- end
- end
- class IllegalRCGenerator < StandardError
- def initialize
- super("Define illegal RC_NAME_GENERATOR.")
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
deleted file mode 100644
index 7e66100be9..0000000000
--- a/lib/irb/lc/help-message
+++ /dev/null
@@ -1,51 +0,0 @@
-Usage: irb.rb [options] [programfile] [arguments]
- -f Don't initialize from configuration file.
- -d Set $DEBUG and $VERBOSE to true (same as 'ruby -d').
- -r load-module Require load-module (same as 'ruby -r').
- -I path Specify $LOAD_PATH directory (same as 'ruby -I').
- -U Set external and internal encodings to UTF-8.
- -E ex[:in] Set default external (ex) and internal (in) encodings
- (same as 'ruby -E').
- -w Suppress warnings (same as 'ruby -w').
- -W[level=2] Set warning level: 0=silence, 1=medium, 2=verbose
- (same as 'ruby -W').
- --context-mode n Set n[0-4] to method to create Binding Object,
- when new workspace was created.
- --extra-doc-dir Add an extra doc dir for the doc dialog.
- --echo Show result (default).
- --noecho Don't show result.
- --echo-on-assignment
- Show result on assignment.
- --noecho-on-assignment
- Don't show result on assignment.
- --truncate-echo-on-assignment
- Show truncated result on assignment (default).
- --inspect Use 'inspect' for output.
- --noinspect Don't use 'inspect' for output.
- --multiline Use multiline editor module (default).
- --nomultiline Don't use multiline editor module.
- --singleline Use single line editor module.
- --nosingleline Don't use single line editor module (default).
- --colorize Use color-highlighting (default).
- --nocolorize Don't use color-highlighting.
- --autocomplete Use auto-completion (default).
- --noautocomplete Don't use auto-completion.
- --prompt prompt-mode, --prompt-mode prompt-mode
- Set prompt mode. Pre-defined prompt modes are:
- 'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
- --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
- Suppresses --multiline and --singleline.
- --sample-book-mode, --simple-prompt
- Set prompt mode to 'simple'.
- --noprompt Don't output prompt.
- --script Script mode (default, treat first argument as script)
- --noscript No script mode (leave arguments in argv)
- --single-irb Share self with sub-irb.
- --tracer Show stack trace for each command.
- --back-trace-limit n[=16]
- Display backtrace top n and bottom n.
- --verbose Show details.
- --noverbose Don't show details.
- -v, --version Print the version of irb.
- -h, --help Print help.
- -- Separate options of irb from the list of command-line args.
diff --git a/lib/irb/lc/ja/encoding_aliases.rb b/lib/irb/lc/ja/encoding_aliases.rb
deleted file mode 100644
index 08180c3ec2..0000000000
--- a/lib/irb/lc/ja/encoding_aliases.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: false
-module IRB
- # :stopdoc:
-
- class Locale
- @@legacy_encoding_alias_map = {
- 'ujis' => Encoding::EUC_JP,
- 'euc' => Encoding::EUC_JP
- }.freeze
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
deleted file mode 100644
index 50d72c4a10..0000000000
--- a/lib/irb/lc/ja/error.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/lc/ja/error.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- # :stopdoc:
-
- class UnrecognizedSwitch < StandardError
- def initialize(val)
- super("スイッãƒ(#{val})ãŒåˆ†ã‚Šã¾ã›ã‚“")
- end
- end
- class NotImplementedError < StandardError
- def initialize(val)
- super("`#{val}'ã®å®šç¾©ãŒå¿…è¦ã§ã™")
- end
- end
- class CantReturnToNormalMode < StandardError
- def initialize
- super("Normalãƒ¢ãƒ¼ãƒ‰ã«æˆ»ã‚Œã¾ã›ã‚“.")
- end
- end
- class IllegalParameter < StandardError
- def initialize(val)
- super("パラメータ(#{val})ãŒé–“é•ã£ã¦ã„ã¾ã™.")
- end
- end
- class IrbAlreadyDead < StandardError
- def initialize
- super("Irbã¯æ—¢ã«æ­»ã‚“ã§ã„ã¾ã™.")
- end
- end
- class IrbSwitchedToCurrentThread < StandardError
- def initialize
- super("カレントスレッドã«åˆ‡ã‚Šæ›¿ã‚りã¾ã—ãŸ.")
- end
- end
- class NoSuchJob < StandardError
- def initialize(val)
- super("ãã®ã‚ˆã†ãªã‚¸ãƒ§ãƒ–(#{val})ã¯ã‚りã¾ã›ã‚“.")
- end
- end
- class CantChangeBinding < StandardError
- def initialize(val)
- super("ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°(#{val})ã«å¤‰æ›´ã§ãã¾ã›ã‚“.")
- end
- end
- class UndefinedPromptMode < StandardError
- def initialize(val)
- super("プロンプトモード(#{val})ã¯å®šç¾©ã•れã¦ã„ã¾ã›ã‚“.")
- end
- end
- class IllegalRCGenerator < StandardError
- def initialize
- super("RC_NAME_GENERATORãŒæ­£ã—ã定義ã•れã¦ã„ã¾ã›ã‚“.")
- end
- end
-
- # :startdoc:
-end
-# vim:fileencoding=utf-8
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
deleted file mode 100644
index 1c15d331ea..0000000000
--- a/lib/irb/lc/ja/help-message
+++ /dev/null
@@ -1,45 +0,0 @@
-Usage: irb.rb [options] [programfile] [arguments]
- -f ~/.irbrc を読ã¿è¾¼ã¾ãªã„.
- -d $DEBUG ã‚’trueã«ã™ã‚‹(ruby -d ã¨åŒã˜)
- -r load-module ruby -r ã¨åŒã˜.
- -I path $LOAD_PATH ã« path を追加ã™ã‚‹.
- -U ruby -U ã¨åŒã˜.
- -E enc ruby -E ã¨åŒã˜.
- -w ruby -w ã¨åŒã˜.
- -W[level=2] ruby -W ã¨åŒã˜.
- --context-mode n æ–°ã—ã„ワークスペースを作æˆã—ãŸæ™‚ã«é–¢é€£ã™ã‚‹ Binding
- オブジェクトã®ä½œæˆæ–¹æ³•ã‚’ 0 ã‹ã‚‰ 3 ã®ã„ãšã‚Œã‹ã«è¨­å®šã™ã‚‹.
- --echo å®Ÿè¡Œçµæžœã‚’表示ã™ã‚‹(デフォルト).
- --noecho å®Ÿè¡Œçµæžœã‚’表示ã—ãªã„.
- --inspect çµæžœå‡ºåŠ›ã«inspectを用ã„ã‚‹.
- --noinspect çµæžœå‡ºåŠ›ã«inspectを用ã„ãªã„.
- --multiline マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã™ã‚‹.
- --nomultiline マルãƒãƒ©ã‚¤ãƒ³ã‚¨ãƒ‡ã‚£ã‚¿ã‚’利用ã—ãªã„.
- --singleline シングルラインエディタを利用ã™ã‚‹.
- --nosingleline シングルラインエディタを利用ã—ãªã„.
- --colorize 色付ã‘を利用ã™ã‚‹.
- --nocolorize 色付ã‘を利用ã—ãªã„.
- --autocomplete オートコンプリートを利用ã™ã‚‹.
- --noautocomplete オートコンプリートを利用ã—ãªã„.
- --prompt prompt-mode/--prompt-mode prompt-mode
- プロンプトモードを切替ãˆã¾ã™. ç¾åœ¨å®šç¾©ã•れã¦ã„るプ
- ロンプトモードã¯, default, simple, xmp, inf-rubyãŒ
- 用æ„ã•れã¦ã„ã¾ã™.
- --inf-ruby-mode emacsã®inf-ruby-mode用ã®ãƒ—ロンプト表示を行ãªã†. 特
- ã«æŒ‡å®šãŒãªã„é™ã‚Š, シングルラインエディタã¨ãƒžãƒ«ãƒãƒ©
- インエディタã¯ä½¿ã‚ãªããªã‚‹.
- --sample-book-mode/--simple-prompt
- éžå¸¸ã«ã‚·ãƒ³ãƒ—ルãªãƒ—ロンプトを用ã„るモードã§ã™.
- --noprompt プロンプト表示を行ãªã‚ãªã„.
- --single-irb irb 中㧠self を実行ã—ã¦å¾—られるオブジェクトをサ
- ブ irb ã¨å…±æœ‰ã™ã‚‹.
- --tracer コマンド実行時ã«ãƒˆãƒ¬ãƒ¼ã‚¹ã‚’行ãªã†.
- --back-trace-limit n
- ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹è¡¨ç¤ºã‚’ãƒãƒƒã‚¯ãƒˆãƒ¬ãƒ¼ã‚¹ã®é ­ã‹ã‚‰ n, 後ã‚
- ã‹ã‚‰nã ã‘行ãªã†. デフォルトã¯16
-
- --verbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã™ã‚‹.
- --noverbose 詳細ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’出力ã—ãªã„(デフォルト).
- -v, --version irbã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã‚’表示ã™ã‚‹.
- -h, --help irb ã®ãƒ˜ãƒ«ãƒ—を表示ã™ã‚‹.
- -- 以é™ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å¼•数をオプションã¨ã—ã¦æ‰±ã‚ãªã„.
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
deleted file mode 100644
index eb3028616d..0000000000
--- a/lib/irb/locale.rb
+++ /dev/null
@@ -1,186 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/locale.rb - internationalization module
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
- class Locale
-
- LOCALE_NAME_RE = %r[
- (?<language>[[:alpha:]]{2,3})
- (?:_ (?<territory>[[:alpha:]]{2,3}) )?
- (?:\. (?<codeset>[^@]+) )?
- (?:@ (?<modifier>.*) )?
- ]x
- LOCALE_DIR = "/lc/"
-
- @@legacy_encoding_alias_map = {}.freeze
- @@loaded = []
-
- def initialize(locale = nil)
- @override_encoding = nil
- @lang = @territory = @encoding_name = @modifier = nil
- @locale = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
- if m = LOCALE_NAME_RE.match(@locale)
- @lang, @territory, @encoding_name, @modifier = m[:language], m[:territory], m[:codeset], m[:modifier]
-
- if @encoding_name
- begin load 'irb/encoding_aliases.rb'; rescue LoadError; end
- if @encoding = @@legacy_encoding_alias_map[@encoding_name]
- warn(("%s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]), uplevel: 1)
- end
- @encoding = Encoding.find(@encoding_name) rescue nil
- end
- end
- @encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
- end
-
- attr_reader :lang, :territory, :modifier
-
- def encoding
- @override_encoding || @encoding
- end
-
- def String(mes)
- mes = super(mes)
- if encoding
- mes.encode(encoding, undef: :replace)
- else
- mes
- end
- end
-
- def format(*opts)
- String(super(*opts))
- end
-
- def gets(*rs)
- String(super(*rs))
- end
-
- def readline(*rs)
- String(super(*rs))
- end
-
- def print(*opts)
- ary = opts.collect{|opt| String(opt)}
- super(*ary)
- end
-
- def printf(*opts)
- s = format(*opts)
- print s
- end
-
- def puts(*opts)
- ary = opts.collect{|opt| String(opt)}
- super(*ary)
- end
-
- def require(file, priv = nil)
- rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
- return false if $".find{|f| f =~ rex}
-
- case file
- when /\.rb$/
- begin
- load(file, priv)
- $".push file
- return true
- rescue LoadError
- end
- when /\.(so|o|sl)$/
- return super
- end
-
- begin
- load(f = file + ".rb")
- $".push f #"
- return true
- rescue LoadError
- return ruby_require(file)
- end
- end
-
- alias toplevel_load load
-
- def load(file, priv=nil)
- found = find(file)
- if found
- unless @@loaded.include?(found)
- @@loaded << found # cache
- return real_load(found, priv)
- end
- else
- raise LoadError, "No such file to load -- #{file}"
- end
- end
-
- def find(file , paths = $:)
- dir = File.dirname(file)
- dir = "" if dir == "."
- base = File.basename(file)
-
- if dir.start_with?('/')
- return each_localized_path(dir, base).find{|full_path| File.readable? full_path}
- else
- return search_file(paths, dir, base)
- end
- end
-
- private
- def real_load(path, priv)
- src = MagicFile.open(path){|f| f.read}
- if priv
- eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)})
- else
- eval(src, TOPLEVEL_BINDING, path)
- end
- end
-
- # @param paths load paths in which IRB find a localized file.
- # @param dir directory
- # @param file basename to be localized
- #
- # typically, for the parameters and a <path> in paths, it searches
- # <path>/<dir>/<locale>/<file>
- def search_file(lib_paths, dir, file)
- each_localized_path(dir, file) do |lc_path|
- lib_paths.each do |libpath|
- full_path = File.join(libpath, lc_path)
- return full_path if File.readable?(full_path)
- end
- redo if defined?(Gem) and Gem.try_activate(lc_path)
- end
- nil
- end
-
- def each_localized_path(dir, file)
- return enum_for(:each_localized_path) unless block_given?
- each_sublocale do |lc|
- yield lc.nil? ? File.join(dir, LOCALE_DIR, file) : File.join(dir, LOCALE_DIR, lc, file)
- end
- end
-
- def each_sublocale
- if @lang
- if @territory
- if @encoding_name
- yield "#{@lang}_#{@territory}.#{@encoding_name}@#{@modifier}" if @modifier
- yield "#{@lang}_#{@territory}.#{@encoding_name}"
- end
- yield "#{@lang}_#{@territory}@#{@modifier}" if @modifier
- yield "#{@lang}_#{@territory}"
- end
- if @encoding_name
- yield "#{@lang}.#{@encoding_name}@#{@modifier}" if @modifier
- yield "#{@lang}.#{@encoding_name}"
- end
- yield "#{@lang}@#{@modifier}" if @modifier
- yield "#{@lang}"
- end
- yield nil
- end
- end
-end
diff --git a/lib/irb/magic-file.rb b/lib/irb/magic-file.rb
deleted file mode 100644
index 34e06d64b3..0000000000
--- a/lib/irb/magic-file.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: false
-module IRB
- class << (MagicFile = Object.new)
- # see parser_magic_comment in parse.y
- ENCODING_SPEC_RE = %r"coding\s*[=:]\s*([[:alnum:]\-_]+)"
-
- def open(path)
- io = File.open(path, 'rb')
- line = io.gets
- line = io.gets if line[0,2] == "#!"
- encoding = detect_encoding(line)
- internal_encoding = encoding
- encoding ||= IRB.default_src_encoding
- io.rewind
- io.set_encoding(encoding, internal_encoding)
-
- if block_given?
- begin
- return (yield io)
- ensure
- io.close
- end
- else
- return io
- end
- end
-
- private
- def detect_encoding(line)
- return unless line[0] == ?#
- line = line[1..-1]
- line = $1 if line[/-\*-\s*(.*?)\s*-*-$/]
- return nil unless ENCODING_SPEC_RE =~ line
- encoding = $1
- return encoding.sub(/-(?:mac|dos|unix)/i, '')
- end
- end
-end
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
deleted file mode 100644
index 612de3df16..0000000000
--- a/lib/irb/notifier.rb
+++ /dev/null
@@ -1,230 +0,0 @@
-# frozen_string_literal: false
-#
-# notifier.rb - output methods used by irb
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "output-method"
-
-module IRB
- # An output formatter used internally by the lexer.
- module Notifier
- class ErrUndefinedNotifier < StandardError
- def initialize(val)
- super("undefined notifier level: #{val} is specified")
- end
- end
- class ErrUnrecognizedLevel < StandardError
- def initialize(val)
- super("unrecognized notifier level: #{val} is specified")
- end
- end
-
- # Define a new Notifier output source, returning a new CompositeNotifier
- # with the given +prefix+ and +output_method+.
- #
- # The optional +prefix+ will be appended to all objects being inspected
- # during output, using the given +output_method+ as the output source. If
- # no +output_method+ is given, StdioOutputMethod will be used, and all
- # expressions will be sent directly to STDOUT without any additional
- # formatting.
- def def_notifier(prefix = "", output_method = StdioOutputMethod.new)
- CompositeNotifier.new(prefix, output_method)
- end
- module_function :def_notifier
-
- # An abstract class, or superclass, for CompositeNotifier and
- # LeveledNotifier to inherit. It provides several wrapper methods for the
- # OutputMethod object used by the Notifier.
- class AbstractNotifier
- # Creates a new Notifier object
- def initialize(prefix, base_notifier)
- @prefix = prefix
- @base_notifier = base_notifier
- end
-
- # The +prefix+ for this Notifier, which is appended to all objects being
- # inspected during output.
- attr_reader :prefix
-
- # A wrapper method used to determine whether notifications are enabled.
- #
- # Defaults to +true+.
- def notify?
- true
- end
-
- # See OutputMethod#print for more detail.
- def print(*opts)
- @base_notifier.print prefix, *opts if notify?
- end
-
- # See OutputMethod#printn for more detail.
- def printn(*opts)
- @base_notifier.printn prefix, *opts if notify?
- end
-
- # See OutputMethod#printf for more detail.
- def printf(format, *opts)
- @base_notifier.printf(prefix + format, *opts) if notify?
- end
-
- # See OutputMethod#puts for more detail.
- def puts(*objs)
- if notify?
- @base_notifier.puts(*objs.collect{|obj| prefix + obj.to_s})
- end
- end
-
- # Same as #ppx, except it uses the #prefix given during object
- # initialization.
- # See OutputMethod#ppx for more detail.
- def pp(*objs)
- if notify?
- @base_notifier.ppx @prefix, *objs
- end
- end
-
- # Same as #pp, except it concatenates the given +prefix+ with the #prefix
- # given during object initialization.
- #
- # See OutputMethod#ppx for more detail.
- def ppx(prefix, *objs)
- if notify?
- @base_notifier.ppx @prefix+prefix, *objs
- end
- end
-
- # Execute the given block if notifications are enabled.
- def exec_if
- yield(@base_notifier) if notify?
- end
- end
-
- # A class that can be used to create a group of notifier objects with the
- # intent of representing a leveled notification system for irb.
- #
- # This class will allow you to generate other notifiers, and assign them
- # the appropriate level for output.
- #
- # The Notifier class provides a class-method Notifier.def_notifier to
- # create a new composite notifier. Using the first composite notifier
- # object you create, sibling notifiers can be initialized with
- # #def_notifier.
- class CompositeNotifier < AbstractNotifier
- # Create a new composite notifier object with the given +prefix+, and
- # +base_notifier+ to use for output.
- def initialize(prefix, base_notifier)
- super
-
- @notifiers = [D_NOMSG]
- @level_notifier = D_NOMSG
- end
-
- # List of notifiers in the group
- attr_reader :notifiers
-
- # Creates a new LeveledNotifier in the composite #notifiers group.
- #
- # The given +prefix+ will be assigned to the notifier, and +level+ will
- # be used as the index of the #notifiers Array.
- #
- # This method returns the newly created instance.
- def def_notifier(level, prefix = "")
- notifier = LeveledNotifier.new(self, level, prefix)
- @notifiers[level] = notifier
- notifier
- end
-
- # Returns the leveled notifier for this object
- attr_reader :level_notifier
- alias level level_notifier
-
- # Sets the leveled notifier for this object.
- #
- # When the given +value+ is an instance of AbstractNotifier,
- # #level_notifier is set to the given object.
- #
- # When an Integer is given, #level_notifier is set to the notifier at the
- # index +value+ in the #notifiers Array.
- #
- # If no notifier exists at the index +value+ in the #notifiers Array, an
- # ErrUndefinedNotifier exception is raised.
- #
- # An ErrUnrecognizedLevel exception is raised if the given +value+ is not
- # found in the existing #notifiers Array, or an instance of
- # AbstractNotifier
- def level_notifier=(value)
- case value
- when AbstractNotifier
- @level_notifier = value
- when Integer
- l = @notifiers[value]
- raise ErrUndefinedNotifier, value unless l
- @level_notifier = l
- else
- raise ErrUnrecognizedLevel, value unless l
- end
- end
-
- alias level= level_notifier=
- end
-
- # A leveled notifier is comparable to the composite group from
- # CompositeNotifier#notifiers.
- class LeveledNotifier < AbstractNotifier
- include Comparable
-
- # Create a new leveled notifier with the given +base+, and +prefix+ to
- # send to AbstractNotifier.new
- #
- # The given +level+ is used to compare other leveled notifiers in the
- # CompositeNotifier group to determine whether or not to output
- # notifications.
- def initialize(base, level, prefix)
- super(prefix, base)
-
- @level = level
- end
-
- # The current level of this notifier object
- attr_reader :level
-
- # Compares the level of this notifier object with the given +other+
- # notifier.
- #
- # See the Comparable module for more information.
- def <=>(other)
- @level <=> other.level
- end
-
- # Whether to output messages to the output method, depending on the level
- # of this notifier object.
- def notify?
- @base_notifier.level >= self
- end
- end
-
- # NoMsgNotifier is a LeveledNotifier that's used as the default notifier
- # when creating a new CompositeNotifier.
- #
- # This notifier is used as the +zero+ index, or level +0+, for
- # CompositeNotifier#notifiers, and will not output messages of any sort.
- class NoMsgNotifier < LeveledNotifier
- # Creates a new notifier that should not be used to output messages.
- def initialize
- @base_notifier = nil
- @level = 0
- @prefix = ""
- end
-
- # Ensures notifications are ignored, see AbstractNotifier#notify? for
- # more information.
- def notify?
- false
- end
- end
-
- D_NOMSG = NoMsgNotifier.new # :nodoc:
- end
-end
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
deleted file mode 100644
index f5ea57111d..0000000000
--- a/lib/irb/output-method.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-# frozen_string_literal: false
-#
-# output-method.rb - output methods used by irb
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- # An abstract output class for IO in irb. This is mainly used internally by
- # IRB::Notifier. You can define your own output method to use with Irb.new,
- # or Context.new
- class OutputMethod
- class NotImplementedError < StandardError
- def initialize(val)
- super("Need to define `#{val}'")
- end
- end
-
- # Open this method to implement your own output method, raises a
- # NotImplementedError if you don't define #print in your own class.
- def print(*opts)
- raise NotImplementedError, "print"
- end
-
- # Prints the given +opts+, with a newline delimiter.
- def printn(*opts)
- print opts.join(" "), "\n"
- end
-
- # Extends IO#printf to format the given +opts+ for Kernel#sprintf using
- # #parse_printf_format
- def printf(format, *opts)
- if /(%*)%I/ =~ format
- format, opts = parse_printf_format(format, opts)
- end
- print sprintf(format, *opts)
- end
-
- # Returns an array of the given +format+ and +opts+ to be used by
- # Kernel#sprintf, if there was a successful Regexp match in the given
- # +format+ from #printf
- #
- # %
- # <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%]
- def parse_printf_format(format, opts)
- return format, opts if $1.size % 2 == 1
- end
-
- # Calls #print on each element in the given +objs+, followed by a newline
- # character.
- def puts(*objs)
- for obj in objs
- print(*obj)
- print "\n"
- end
- end
-
- # Prints the given +objs+ calling Object#inspect on each.
- #
- # See #puts for more detail.
- def pp(*objs)
- puts(*objs.collect{|obj| obj.inspect})
- end
-
- # Prints the given +objs+ calling Object#inspect on each and appending the
- # given +prefix+.
- #
- # See #puts for more detail.
- def ppx(prefix, *objs)
- puts(*objs.collect{|obj| prefix+obj.inspect})
- end
-
- end
-
- # A standard output printer
- class StdioOutputMethod < OutputMethod
- # Prints the given +opts+ to standard output, see IO#print for more
- # information.
- def print(*opts)
- STDOUT.print(*opts)
- end
- end
-end
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
deleted file mode 100644
index 9e4a7b28fa..0000000000
--- a/lib/irb/ruby-lex.rb
+++ /dev/null
@@ -1,851 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/ruby-lex.rb - ruby lexcal analyzer
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require "ripper"
-require "jruby" if RUBY_ENGINE == "jruby"
-
-# :stopdoc:
-class RubyLex
-
- class TerminateLineInput < StandardError
- def initialize
- super("Terminate Line Input")
- end
- end
-
- def initialize(context)
- @context = context
- @exp_line_no = @line_no = 1
- @indent = 0
- @continue = false
- @line = ""
- @prompt = nil
- end
-
- def self.compile_with_errors_suppressed(code, line_no: 1)
- begin
- result = yield code, line_no
- rescue ArgumentError
- # Ruby can issue an error for the code if there is an
- # incomplete magic comment for encoding in it. Force an
- # expression with a new line before the code in this
- # case to prevent magic comment handling. To make sure
- # line numbers in the lexed code remain the same,
- # decrease the line number by one.
- code = ";\n#{code}"
- line_no -= 1
- result = yield code, line_no
- end
- result
- end
-
- # io functions
- def set_input(io, &block)
- @io = io
- if @io.respond_to?(:check_termination)
- @io.check_termination do |code|
- if Reline::IOGate.in_pasting?
- lex = RubyLex.new(@context)
- rest = lex.check_termination_in_prev_line(code)
- if rest
- Reline.delete_text
- rest.bytes.reverse_each do |c|
- Reline.ungetc(c)
- end
- true
- else
- false
- end
- else
- # Accept any single-line input for symbol aliases or commands that transform args
- command = code.split(/\s/, 2).first
- if @context.symbol_alias?(command) || @context.transform_args?(command)
- next true
- end
-
- code.gsub!(/\s*\z/, '').concat("\n")
- tokens = self.class.ripper_lex_without_warning(code, context: @context)
- ltype, indent, continue, code_block_open = check_state(code, tokens)
- if ltype or indent > 0 or continue or code_block_open
- false
- else
- true
- end
- end
- end
- end
- if @io.respond_to?(:dynamic_prompt)
- @io.dynamic_prompt do |lines|
- lines << '' if lines.empty?
- result = []
- tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, context: @context)
- code = String.new
- partial_tokens = []
- unprocessed_tokens = []
- line_num_offset = 0
- tokens.each do |t|
- partial_tokens << t
- unprocessed_tokens << t
- if t.tok.include?("\n")
- t_str = t.tok
- t_str.each_line("\n") do |s|
- code << s
- next unless s.include?("\n")
- ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
- line_num_offset += 1
- end
- unprocessed_tokens = []
- else
- code << t.tok
- end
- end
-
- unless unprocessed_tokens.empty?
- ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens)
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
- end
- result
- end
- end
-
- if block_given?
- @input = block
- else
- @input = Proc.new{@io.gets}
- end
- end
-
- def set_prompt(&block)
- @prompt = block
- end
-
- ERROR_TOKENS = [
- :on_parse_error,
- :compile_error,
- :on_assign_error,
- :on_alias_error,
- :on_class_name_error,
- :on_param_error
- ]
-
- def self.generate_local_variables_assign_code(local_variables)
- "#{local_variables.join('=')}=nil;" unless local_variables.empty?
- end
-
- def self.ripper_lex_without_warning(code, context: nil)
- verbose, $VERBOSE = $VERBOSE, nil
- lvars_code = generate_local_variables_assign_code(context&.local_variables || [])
- if lvars_code
- code = "#{lvars_code}\n#{code}"
- line_no = 0
- else
- line_no = 1
- end
-
- compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
- lexer = Ripper::Lexer.new(inner_code, '-', line_no)
- if lexer.respond_to?(:scan) # Ruby 2.7+
- lexer.scan.each_with_object([]) do |t, tokens|
- next if t.pos.first == 0
- prev_tk = tokens.last
- position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize
- if position_overlapped
- tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event)
- else
- tokens << t
- end
- end
- else
- lexer.parse.reject { |it| it.pos.first == 0 }.sort_by(&:pos)
- end
- end
- ensure
- $VERBOSE = verbose
- end
-
- def find_prev_spaces(line_index)
- return 0 if @tokens.size == 0
- md = @tokens[0].tok.match(/(\A +)/)
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
- line_count = 0
- @tokens.each_with_index do |t, i|
- if t.tok.include?("\n")
- line_count += t.tok.count("\n")
- if line_count >= line_index
- return prev_spaces
- end
- next if t.event == :on_tstring_content || t.event == :on_words_sep
- if (@tokens.size - 1) > i
- md = @tokens[i + 1].tok.match(/(\A +)/)
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
- end
- end
- end
- prev_spaces
- end
-
- def set_auto_indent
- if @io.respond_to?(:auto_indent) and @context.auto_indent_mode
- @io.auto_indent do |lines, line_index, byte_pointer, is_newline|
- if is_newline
- @tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"), context: @context)
- prev_spaces = find_prev_spaces(line_index)
- depth_difference = check_newline_depth_difference
- depth_difference = 0 if depth_difference < 0
- prev_spaces + depth_difference * 2
- else
- code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
- last_line = lines[line_index]&.byteslice(0, byte_pointer)
- code += last_line if last_line
- @tokens = self.class.ripper_lex_without_warning(code, context: @context)
- check_corresponding_token_depth(lines, line_index)
- end
- end
- end
- end
-
- def check_state(code, tokens)
- ltype = process_literal_type(tokens)
- indent = process_nesting_level(tokens)
- continue = process_continue(tokens)
- lvars_code = self.class.generate_local_variables_assign_code(@context.local_variables)
- code = "#{lvars_code}\n#{code}" if lvars_code
- code_block_open = check_code_block(code, tokens)
- [ltype, indent, continue, code_block_open]
- end
-
- def prompt
- if @prompt
- @prompt.call(@ltype, @indent, @continue, @line_no)
- end
- end
-
- def initialize_input
- @ltype = nil
- @indent = 0
- @continue = false
- @line = ""
- @exp_line_no = @line_no
- @code_block_open = false
- end
-
- def each_top_level_statement
- initialize_input
- catch(:TERM_INPUT) do
- loop do
- begin
- prompt
- unless l = lex
- throw :TERM_INPUT if @line == ''
- else
- @line_no += l.count("\n")
- if l == "\n"
- @exp_line_no += 1
- next
- end
- @line.concat l
- if @code_block_open or @ltype or @continue or @indent > 0
- next
- end
- end
- if @line != "\n"
- @line.force_encoding(@io.encoding)
- yield @line, @exp_line_no
- end
- raise TerminateLineInput if @io.eof?
- @line = ''
- @exp_line_no = @line_no
-
- @indent = 0
- rescue TerminateLineInput
- initialize_input
- prompt
- end
- end
- end
- end
-
- def lex
- line = @input.call
- if @io.respond_to?(:check_termination)
- return line # multiline
- end
- code = @line + (line.nil? ? '' : line)
- code.gsub!(/\s*\z/, '').concat("\n")
- @tokens = self.class.ripper_lex_without_warning(code, context: @context)
- @ltype, @indent, @continue, @code_block_open = check_state(code, @tokens)
- line
- end
-
- def process_continue(tokens)
- # last token is always newline
- if tokens.size >= 2 and tokens[-2].event == :on_regexp_end
- # end of regexp literal
- return false
- elsif tokens.size >= 2 and tokens[-2].event == :on_semicolon
- return false
- elsif tokens.size >= 2 and tokens[-2].event == :on_kw and ['begin', 'else', 'ensure'].include?(tokens[-2].tok)
- return false
- elsif !tokens.empty? and tokens.last.tok == "\\\n"
- return true
- elsif tokens.size >= 1 and tokens[-1].event == :on_heredoc_end # "EOH\n"
- return false
- elsif tokens.size >= 2 and tokens[-2].state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME) and tokens[-2].tok !~ /\A\.\.\.?\z/
- # end of literal except for regexp
- # endless range at end of line is not a continue
- return true
- end
- false
- end
-
- def check_code_block(code, tokens)
- return true if tokens.empty?
- if tokens.last.event == :on_heredoc_beg
- return true
- end
-
- begin # check if parser error are available
- verbose, $VERBOSE = $VERBOSE, nil
- case RUBY_ENGINE
- when 'ruby'
- self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
- RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
- end
- when 'jruby'
- JRuby.compile_ir(code)
- else
- catch(:valid) do
- eval("BEGIN { throw :valid, true }\n#{code}")
- false
- end
- end
- rescue EncodingError
- # This is for a hash with invalid encoding symbol, {"\xAE": 1}
- rescue SyntaxError => e
- case e.message
- when /unterminated (?:string|regexp) meets end of file/
- # "unterminated regexp meets end of file"
- #
- # example:
- # /
- #
- # "unterminated string meets end of file"
- #
- # example:
- # '
- return true
- when /syntax error, unexpected end-of-input/
- # "syntax error, unexpected end-of-input, expecting keyword_end"
- #
- # example:
- # if true
- # hoge
- # if false
- # fuga
- # end
- return true
- when /syntax error, unexpected keyword_end/
- # "syntax error, unexpected keyword_end"
- #
- # example:
- # if (
- # end
- #
- # example:
- # end
- return false
- when /syntax error, unexpected '\.'/
- # "syntax error, unexpected '.'"
- #
- # example:
- # .
- return false
- when /unexpected tREGEXP_BEG/
- # "syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '('"
- #
- # example:
- # method / f /
- return false
- end
- ensure
- $VERBOSE = verbose
- end
-
- last_lex_state = tokens.last.state
-
- if last_lex_state.allbits?(Ripper::EXPR_BEG)
- return false
- elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
- return false
- end
-
- false
- end
-
- def process_nesting_level(tokens)
- indent = 0
- in_oneliner_def = nil
- tokens.each_with_index { |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
- else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
- end
- else
- if in_oneliner_def == :BODY
- # one-liner method definition
- indent -= 1
- end
- in_oneliner_def = nil
- end
- end
-
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- indent += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- indent -= 1
- when :on_kw
- next if index > 0 and tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(tokens, index)
- indent += 1 if syntax_of_do == :method_calling
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- indent += 1
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- indent += 1 unless t.state.allbits?(Ripper::EXPR_LABEL)
- when 'end'
- indent -= 1
- end
- end
- # percent literals are not indented
- }
- indent
- end
-
- def is_method_calling?(tokens, index)
- tk = tokens[index]
- if tk.state.anybits?(Ripper::EXPR_CMDARG) and tk.event == :on_ident
- # The target method call to pass the block with "do".
- return true
- elsif tk.state.anybits?(Ripper::EXPR_ARG) and tk.event == :on_ident
- non_sp_index = tokens[0..(index - 1)].rindex{ |t| t.event != :on_sp }
- if non_sp_index
- prev_tk = tokens[non_sp_index]
- if prev_tk.state.anybits?(Ripper::EXPR_DOT) and prev_tk.event == :on_period
- # The target method call with receiver to pass the block with "do".
- return true
- end
- end
- end
- false
- end
-
- def take_corresponding_syntax_to_kw_do(tokens, index)
- syntax_of_do = nil
- # Finding a syntax corresponding to "do".
- index.downto(0) do |i|
- tk = tokens[i]
- # In "continue", the token isn't the corresponding syntax to "do".
- non_sp_index = tokens[0..(i - 1)].rindex{ |t| t.event != :on_sp }
- first_in_fomula = false
- if non_sp_index.nil?
- first_in_fomula = true
- elsif [:on_ignored_nl, :on_nl, :on_comment].include?(tokens[non_sp_index].event)
- first_in_fomula = true
- end
- if is_method_calling?(tokens, i)
- syntax_of_do = :method_calling
- break if first_in_fomula
- elsif tk.event == :on_kw && %w{while until for}.include?(tk.tok)
- # A loop syntax in front of "do" found.
- #
- # while cond do # also "until" or "for"
- # end
- #
- # This "do" doesn't increment indent because the loop syntax already
- # incremented.
- syntax_of_do = :loop_syntax
- break if first_in_fomula
- end
- end
- syntax_of_do
- end
-
- def is_the_in_correspond_to_a_for(tokens, index)
- syntax_of_in = nil
- # Finding a syntax corresponding to "do".
- index.downto(0) do |i|
- tk = tokens[i]
- # In "continue", the token isn't the corresponding syntax to "do".
- non_sp_index = tokens[0..(i - 1)].rindex{ |t| t.event != :on_sp }
- first_in_fomula = false
- if non_sp_index.nil?
- first_in_fomula = true
- elsif [:on_ignored_nl, :on_nl, :on_comment].include?(tokens[non_sp_index].event)
- first_in_fomula = true
- end
- if tk.event == :on_kw && tk.tok == 'for'
- # A loop syntax in front of "do" found.
- #
- # while cond do # also "until" or "for"
- # end
- #
- # This "do" doesn't increment indent because the loop syntax already
- # incremented.
- syntax_of_in = :for
- end
- break if first_in_fomula
- end
- syntax_of_in
- end
-
- def check_newline_depth_difference
- depth_difference = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
- else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
- end
- else
- if in_oneliner_def == :BODY
- # one-liner method definition
- depth_difference -= 1
- end
- in_oneliner_def = nil
- end
- end
-
- case t.event
- when :on_ignored_nl, :on_nl, :on_comment
- if index != (@tokens.size - 1) and in_oneliner_def != :BODY
- depth_difference = 0
- open_brace_on_line = 0
- end
- next
- when :on_sp
- next
- end
-
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- depth_difference += 1
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- depth_difference -= 1 if open_brace_on_line > 0
- when :on_kw
- next if index > 0 and @tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
- depth_difference += 1 if syntax_of_do == :method_calling
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- depth_difference += 1
- when 'if', 'unless', 'while', 'until', 'rescue'
- # postfix if/unless/while/until/rescue must be Ripper::EXPR_LABEL
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- depth_difference += 1
- end
- when 'else', 'elsif', 'ensure', 'when'
- depth_difference += 1
- when 'in'
- unless is_the_in_correspond_to_a_for(@tokens, index)
- depth_difference += 1
- end
- when 'end'
- depth_difference -= 1
- end
- end
- end
- depth_difference
- end
-
- def check_corresponding_token_depth(lines, line_index)
- corresponding_token_depth = nil
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- spaces_of_nest = []
- spaces_at_line_head = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
-
- if heredoc_scope?
- return lines[line_index][/^ */].length
- end
-
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
- else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
- end
- else
- if in_oneliner_def == :BODY
- # one-liner method definition
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
- else
- spaces_of_nest.pop
- corresponding_token_depth = nil
- end
- end
- in_oneliner_def = nil
- end
- end
-
- case t.event
- when :on_ignored_nl, :on_nl, :on_comment, :on_heredoc_end, :on_embdoc_end
- if in_oneliner_def != :BODY
- corresponding_token_depth = nil
- spaces_at_line_head = 0
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- open_brace_on_line = 0
- end
- next
- when :on_sp
- spaces_at_line_head = t.tok.count(' ') if is_first_spaces_of_line
- is_first_spaces_of_line = false
- next
- end
-
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- spaces_of_nest.push(spaces_at_line_head + open_brace_on_line * 2)
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
- else
- spaces_of_nest.pop
- corresponding_token_depth = nil
- end
- open_brace_on_line -= 1
- when :on_kw
- next if index > 0 and @tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
- if syntax_of_do == :method_calling
- spaces_of_nest.push(spaces_at_line_head)
- end
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- spaces_of_nest.push(spaces_at_line_head)
- when 'rescue'
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- corresponding_token_depth = spaces_of_nest.last
- end
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- spaces_of_nest.push(spaces_at_line_head)
- end
- when 'else', 'elsif', 'ensure', 'when'
- corresponding_token_depth = spaces_of_nest.last
- when 'in'
- if in_keyword_case_scope?
- corresponding_token_depth = spaces_of_nest.last
- end
- when 'end'
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
- else
- spaces_of_nest.pop
- corresponding_token_depth = nil
- end
- end
- end
- is_first_spaces_of_line = false
- is_first_printable_of_line = false
- end
- corresponding_token_depth
- end
-
- def check_string_literal(tokens)
- i = 0
- start_token = []
- end_type = []
- pending_heredocs = []
- while i < tokens.size
- t = tokens[i]
- case t.event
- when *end_type.last
- start_token.pop
- end_type.pop
- when :on_tstring_beg
- start_token << t
- end_type << [:on_tstring_end, :on_label_end]
- when :on_regexp_beg
- start_token << t
- end_type << :on_regexp_end
- when :on_symbeg
- acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int on_backtick}
- if (i + 1) < tokens.size
- if acceptable_single_tokens.all?{ |st| tokens[i + 1].event != st }
- start_token << t
- end_type << :on_tstring_end
- else
- i += 1
- end
- end
- when :on_backtick
- if t.state.allbits?(Ripper::EXPR_BEG)
- start_token << t
- end_type << :on_tstring_end
- end
- when :on_qwords_beg, :on_words_beg, :on_qsymbols_beg, :on_symbols_beg
- start_token << t
- end_type << :on_tstring_end
- when :on_heredoc_beg
- pending_heredocs << t
- end
-
- if pending_heredocs.any? && t.tok.include?("\n")
- pending_heredocs.reverse_each do |t|
- start_token << t
- end_type << :on_heredoc_end
- end
- pending_heredocs = []
- end
- i += 1
- end
- pending_heredocs.first || start_token.last
- end
-
- def process_literal_type(tokens)
- start_token = check_string_literal(tokens)
- return nil if start_token == ""
-
- case start_token&.event
- when :on_tstring_beg
- case start_token&.tok
- when ?" then ?"
- when /^%.$/ then ?"
- when /^%Q.$/ then ?"
- when ?' then ?'
- when /^%q.$/ then ?'
- end
- when :on_regexp_beg then ?/
- when :on_symbeg then ?:
- when :on_backtick then ?`
- when :on_qwords_beg then ?]
- when :on_words_beg then ?]
- when :on_qsymbols_beg then ?]
- when :on_symbols_beg then ?]
- when :on_heredoc_beg
- start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
- $1 || ?"
- else
- nil
- end
- end
-
- def check_termination_in_prev_line(code)
- tokens = self.class.ripper_lex_without_warning(code, context: @context)
- past_first_newline = false
- index = tokens.rindex do |t|
- # traverse first token before last line
- if past_first_newline
- if t.tok.include?("\n")
- true
- end
- elsif t.tok.include?("\n")
- past_first_newline = true
- false
- else
- false
- end
- end
-
- if index
- first_token = nil
- last_line_tokens = tokens[(index + 1)..(tokens.size - 1)]
- last_line_tokens.each do |t|
- unless [:on_sp, :on_ignored_sp, :on_comment].include?(t.event)
- first_token = t
- break
- end
- end
-
- if first_token.nil?
- return false
- elsif first_token && first_token.state == Ripper::EXPR_DOT
- return false
- else
- tokens_without_last_line = tokens[0..index]
- ltype = process_literal_type(tokens_without_last_line)
- indent = process_nesting_level(tokens_without_last_line)
- continue = process_continue(tokens_without_last_line)
- code_block_open = check_code_block(tokens_without_last_line.map(&:tok).join(''), tokens_without_last_line)
- if ltype or indent > 0 or continue or code_block_open
- return false
- else
- return last_line_tokens.map(&:tok).join('')
- end
- end
- end
- false
- end
-
- private
-
- def heredoc_scope?
- heredoc_tokens = @tokens.select { |t| [:on_heredoc_beg, :on_heredoc_end].include?(t.event) }
- heredoc_tokens[-1]&.event == :on_heredoc_beg
- end
-
- def in_keyword_case_scope?
- kw_tokens = @tokens.select { |t| t.event == :on_kw && ['case', 'for', 'end'].include?(t.tok) }
- counter = 0
- kw_tokens.reverse.each do |t|
- if t.tok == 'case'
- return true if counter.zero?
- counter += 1
- elsif t.tok == 'for'
- counter += 1
- elsif t.tok == 'end'
- counter -= 1
- end
- end
- false
- end
-end
-# :startdoc:
diff --git a/lib/irb/ruby_logo.aa b/lib/irb/ruby_logo.aa
deleted file mode 100644
index a34a3e2f28..0000000000
--- a/lib/irb/ruby_logo.aa
+++ /dev/null
@@ -1,37 +0,0 @@
-
- -+smJYYN?mm-
- HB"BBYT TQg NggT
- 9Q+g Nm,T 8g NJW
- YS+ N2NJ"Sg N?
- BQg #( gT Nggggk J
- 5j NJ NJ NNge
- #Q #JJ NgT N(
- @j bj mT J
- Bj @/d NJ (
- #q #(( NgT #J
- 5d #(t mT $d
- #q @(@J NJB;
- @( 5d ? HHH H HQmgggggggmN qD
- 5d #uN 2QdH E O
- 5 5JSd Nd NJH @d j
- Fd @J4d s NQH #d (
- #( #o6d Nd NgH #d #d
- 4 B&Od v NgT #d F
- #( 9JGd NH NgUd F
- #d #GJQ d NP $
- #J #U+#Q N Q # j
- j /W BQ+ BQ d NJ NJ
- - NjJH HBIjTQggPJQgW N W k #J
- #J b HYWgggN j s Nag d NN b #d
- #J 5- D s Ngg N d Nd F
- Fd BKH2 #+ s NNgg J Q J ]
- F H @ J N y K(d P I
- F4 E N? #d y #Q NJ E j
- F W Nd q m Bg NxW N(H-
- F d b @ m Hd gW vKJ
- NJ d K d s Bg aT FDd
- b # d N m BQ mV N>
- e5 Nd #d NggggggQWH HHHH NJ -
- m7 NW H N HSVO1z=?11-
- NgTH bB kH WBHWWHBHWmQgg&gggggNNN
- NNggggggNN
diff --git a/lib/irb/src_encoding.rb b/lib/irb/src_encoding.rb
deleted file mode 100644
index 99aea2b43e..0000000000
--- a/lib/irb/src_encoding.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: false
-# DO NOT WRITE ANY MAGIC COMMENT HERE.
-module IRB
- def self.default_src_encoding
- return __ENCODING__
- end
-end
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
deleted file mode 100644
index 217e1210c8..0000000000
--- a/lib/irb/version.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/version.rb - irb version definition file
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-#
-
-module IRB # :nodoc:
- VERSION = "1.6.3"
- @RELEASE_VERSION = VERSION
- @LAST_UPDATE_DATE = "2023-03-06"
-end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
deleted file mode 100644
index d6fa67053d..0000000000
--- a/lib/irb/workspace.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/workspace-binding.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require "delegate"
-
-IRB::TOPLEVEL_BINDING = binding
-module IRB # :nodoc:
- class WorkSpace
- # Creates a new workspace.
- #
- # set self to main if specified, otherwise
- # inherit main from TOPLEVEL_BINDING.
- def initialize(*main)
- if main[0].kind_of?(Binding)
- @binding = main.shift
- elsif IRB.conf[:SINGLE_IRB]
- @binding = TOPLEVEL_BINDING
- else
- case IRB.conf[:CONTEXT_MODE]
- when 0 # binding in proc on TOPLEVEL_BINDING
- @binding = eval("proc{binding}.call",
- TOPLEVEL_BINDING,
- __FILE__,
- __LINE__)
- when 1 # binding in loaded file
- require "tempfile"
- f = Tempfile.open("irb-binding")
- f.print <<EOF
- $binding = binding
-EOF
- f.close
- load f.path
- @binding = $binding
-
- when 2 # binding in loaded file(thread use)
- unless defined? BINDING_QUEUE
- IRB.const_set(:BINDING_QUEUE, Thread::SizedQueue.new(1))
- Thread.abort_on_exception = true
- Thread.start do
- eval "require \"irb/ws-for-case-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
- end
- Thread.pass
- end
- @binding = BINDING_QUEUE.pop
-
- when 3 # binding in function on TOPLEVEL_BINDING
- @binding = eval("self.class.remove_method(:irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
- TOPLEVEL_BINDING,
- __FILE__,
- __LINE__ - 3)
- when 4 # binding is a copy of TOPLEVEL_BINDING (default)
- # Note that this will typically be IRB::TOPLEVEL_BINDING
- # This is to avoid RubyGems' local variables (see issue #17623)
- @binding = TOPLEVEL_BINDING.dup
- end
- end
-
- if main.empty?
- @main = eval("self", @binding)
- else
- @main = main[0]
- end
- IRB.conf[:__MAIN__] = @main
-
- unless main.empty?
- case @main
- when Module
- @binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
- else
- begin
- @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
- rescue TypeError
- fail CantChangeBinding, @main.inspect
- end
- end
- end
-
- case @main
- when Object
- use_delegator = @main.frozen?
- else
- use_delegator = true
- end
-
- if use_delegator
- @main = SimpleDelegator.new(@main)
- IRB.conf[:__MAIN__] = @main
- @main.singleton_class.class_eval do
- private
- define_method(:exit) do |*a, &b|
- # Do nothing, will be overridden
- end
- define_method(:binding, Kernel.instance_method(:binding))
- define_method(:local_variables, Kernel.instance_method(:local_variables))
- end
- @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
- end
-
- @binding.local_variable_set(:_, nil)
- end
-
- # The Binding of this workspace
- attr_reader :binding
- # The top-level workspace of this context, also available as
- # <code>IRB.conf[:__MAIN__]</code>
- attr_reader :main
-
- # Evaluate the given +statements+ within the context of this workspace.
- def evaluate(statements, file = __FILE__, line = __LINE__)
- eval(statements, @binding, file, line)
- end
-
- def local_variable_set(name, value)
- @binding.local_variable_set(name, value)
- end
-
- def local_variable_get(name)
- @binding.local_variable_get(name)
- end
-
- # error message manipulator
- # WARN: Rails patches this method to filter its own backtrace. Be cautious when changing it.
- # See: https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/console_command.rb#L8:~:text=def,filter_backtrace
- def filter_backtrace(bt)
- return nil if bt =~ /\/irb\/.*\.rb/
- return nil if bt =~ /\/irb\.rb/
- return nil if bt =~ /tool\/lib\/.*\.rb|runner\.rb/ # for tests in Ruby repository
- case IRB.conf[:CONTEXT_MODE]
- when 1
- return nil if bt =~ %r!/tmp/irb-binding!
- when 3
- bt = bt.sub(/:\s*in `irb_binding'/, '')
- end
- bt
- end
-
- def code_around_binding
- file, pos = @binding.source_location
-
- if defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
- code = ::SCRIPT_LINES__[file].join('')
- else
- begin
- code = File.read(file)
- rescue SystemCallError
- return
- end
- end
-
- lines = Color.colorize_code(code).lines
- pos -= 1
-
- start_pos = [pos - 5, 0].max
- end_pos = [pos + 5, lines.size - 1].min
-
- line_number_fmt = Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])
- fmt = " %2s #{line_number_fmt}: %s"
-
- body = (start_pos..end_pos).map do |current_pos|
- sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
- end.join("")
-
- "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
- end
- end
-end
diff --git a/lib/irb/ws-for-case-2.rb b/lib/irb/ws-for-case-2.rb
deleted file mode 100644
index a0f617e4ed..0000000000
--- a/lib/irb/ws-for-case-2.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: false
-#
-# irb/ws-for-case-2.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-while true
- IRB::BINDING_QUEUE.push _ = binding
-end
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
deleted file mode 100644
index 94c700b484..0000000000
--- a/lib/irb/xmp.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-# frozen_string_literal: false
-#
-# xmp.rb - irb version of gotoken xmp
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
-#
-
-require_relative "../irb"
-require_relative "frame"
-
-# An example printer for irb.
-#
-# It's much like the standard library PrettyPrint, that shows the value of each
-# expression as it runs.
-#
-# In order to use this library, you must first require it:
-#
-# require 'irb/xmp'
-#
-# Now, you can take advantage of the Object#xmp convenience method.
-#
-# xmp <<END
-# foo = "bar"
-# baz = 42
-# END
-# #=> foo = "bar"
-# #==>"bar"
-# #=> baz = 42
-# #==>42
-#
-# You can also create an XMP object, with an optional binding to print
-# expressions in the given binding:
-#
-# ctx = binding
-# x = XMP.new ctx
-# x.puts
-# #=> today = "a good day"
-# #==>"a good day"
-# ctx.eval 'today # is what?'
-# #=> "a good day"
-class XMP
-
- # Creates a new XMP object.
- #
- # The top-level binding or, optional +bind+ parameter will be used when
- # creating the workspace. See WorkSpace.new for more information.
- #
- # This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for
- # full detail.
- def initialize(bind = nil)
- IRB.init_config(nil)
-
- IRB.conf[:PROMPT_MODE] = :XMP
-
- bind = IRB::Frame.top(1) unless bind
- ws = IRB::WorkSpace.new(bind)
- @io = StringInputMethod.new
- @irb = IRB::Irb.new(ws, @io)
- @irb.context.ignore_sigint = false
-
- IRB.conf[:MAIN_CONTEXT] = @irb.context
- end
-
- # Evaluates the given +exps+, for example:
- #
- # require 'irb/xmp'
- # x = XMP.new
- #
- # x.puts '{:a => 1, :b => 2, :c => 3}'
- # #=> {:a => 1, :b => 2, :c => 3}
- # # ==>{:a=>1, :b=>2, :c=>3}
- # x.puts 'foo = "bar"'
- # # => foo = "bar"
- # # ==>"bar"
- def puts(exps)
- @io.puts exps
-
- if @irb.context.ignore_sigint
- begin
- trap_proc_b = trap("SIGINT"){@irb.signal_handle}
- catch(:IRB_EXIT) do
- @irb.eval_input
- end
- ensure
- trap("SIGINT", trap_proc_b)
- end
- else
- catch(:IRB_EXIT) do
- @irb.eval_input
- end
- end
- end
-
- # A custom InputMethod class used by XMP for evaluating string io.
- class StringInputMethod < IRB::InputMethod
- # Creates a new StringInputMethod object
- def initialize
- super
- @exps = []
- end
-
- # Whether there are any expressions left in this printer.
- def eof?
- @exps.empty?
- end
-
- # Reads the next expression from this printer.
- #
- # See IO#gets for more information.
- def gets
- while l = @exps.shift
- next if /^\s+$/ =~ l
- l.concat "\n"
- print @prompt, l
- break
- end
- l
- end
-
- # Concatenates all expressions in this printer, separated by newlines.
- #
- # An Encoding::CompatibilityError is raised of the given +exps+'s encoding
- # doesn't match the previous expression evaluated.
- def puts(exps)
- if @encoding and exps.encoding != @encoding
- enc = Encoding.compatible?(@exps.join("\n"), exps)
- if enc.nil?
- raise Encoding::CompatibilityError, "Encoding in which the passed expression is encoded is not compatible to the preceding's one"
- else
- @encoding = enc
- end
- else
- @encoding = exps.encoding
- end
- @exps.concat exps.split(/\n/)
- end
-
- # Returns the encoding of last expression printed by #puts.
- attr_reader :encoding
- end
-end
-
-# A convenience method that's only available when the you require the IRB::XMP standard library.
-#
-# Creates a new XMP object, using the given expressions as the +exps+
-# parameter, and optional binding as +bind+ or uses the top-level binding. Then
-# evaluates the given expressions using the +:XMP+ prompt mode.
-#
-# For example:
-#
-# require 'irb/xmp'
-# ctx = binding
-# xmp 'foo = "bar"', ctx
-# #=> foo = "bar"
-# #==>"bar"
-# ctx.eval 'foo'
-# #=> "bar"
-#
-# See XMP.new for more information.
-def xmp(exps, bind = nil)
- bind = IRB::Frame.top(1) unless bind
- xmp = XMP.new(bind)
- xmp.puts exps
- xmp
-end
diff --git a/lib/logger.rb b/lib/logger.rb
deleted file mode 100644
index acc65ac8bb..0000000000
--- a/lib/logger.rb
+++ /dev/null
@@ -1,748 +0,0 @@
-# frozen_string_literal: true
-# logger.rb - simple logging utility
-# Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
-#
-# Documentation:: NAKAMURA, Hiroshi and Gavin Sinclair
-# License::
-# You can redistribute it and/or modify it under the same terms of Ruby's
-# license; either the dual license version in 2003, or any later version.
-# Revision:: $Id$
-#
-# A simple system for logging messages. See Logger for more documentation.
-
-require 'fiber'
-require 'monitor'
-require 'rbconfig'
-
-require_relative 'logger/version'
-require_relative 'logger/formatter'
-require_relative 'logger/log_device'
-require_relative 'logger/severity'
-require_relative 'logger/errors'
-
-# \Class \Logger provides a simple but sophisticated logging utility that
-# you can use to create one or more
-# {event logs}[https://en.wikipedia.org/wiki/Logging_(software)#Event_logs]
-# for your program.
-# Each such log contains a chronological sequence of entries
-# that provides a record of the program's activities.
-#
-# == About the Examples
-#
-# All examples on this page assume that \Logger has been required:
-#
-# require 'logger'
-#
-# == Synopsis
-#
-# Create a log with Logger.new:
-#
-# # Single log file.
-# logger = Logger.new('t.log')
-# # Size-based rotated logging: 3 10-megabyte files.
-# logger = Logger.new('t.log', 3, 10485760)
-# # Period-based rotated logging: daily (also allowed: 'weekly', 'monthly').
-# logger = Logger.new('t.log', 'daily')
-# # Log to an IO stream.
-# logger = Logger.new($stdout)
-#
-# Add entries (level, message) with Logger#add:
-#
-# logger.add(Logger::DEBUG, 'Maximal debugging info')
-# logger.add(Logger::INFO, 'Non-error information')
-# logger.add(Logger::WARN, 'Non-error warning')
-# logger.add(Logger::ERROR, 'Non-fatal error')
-# logger.add(Logger::FATAL, 'Fatal error')
-# logger.add(Logger::UNKNOWN, 'Most severe')
-#
-# Close the log with Logger#close:
-#
-# logger.close
-#
-# == Entries
-#
-# You can add entries with method Logger#add:
-#
-# logger.add(Logger::DEBUG, 'Maximal debugging info')
-# logger.add(Logger::INFO, 'Non-error information')
-# logger.add(Logger::WARN, 'Non-error warning')
-# logger.add(Logger::ERROR, 'Non-fatal error')
-# logger.add(Logger::FATAL, 'Fatal error')
-# logger.add(Logger::UNKNOWN, 'Most severe')
-#
-# These shorthand methods also add entries:
-#
-# logger.debug('Maximal debugging info')
-# logger.info('Non-error information')
-# logger.warn('Non-error warning')
-# logger.error('Non-fatal error')
-# logger.fatal('Fatal error')
-# logger.unknown('Most severe')
-#
-# When you call any of these methods,
-# the entry may or may not be written to the log,
-# depending on the entry's severity and on the log level;
-# see {Log Level}[rdoc-ref:Logger@Log+Level]
-#
-# An entry always has:
-#
-# - A severity (the required argument to #add).
-# - An automatically created timestamp.
-#
-# And may also have:
-#
-# - A message.
-# - A program name.
-#
-# Example:
-#
-# logger = Logger.new($stdout)
-# logger.add(Logger::INFO, 'My message.', 'mung')
-# # => I, [2022-05-07T17:21:46.536234 #20536] INFO -- mung: My message.
-#
-# The default format for an entry is:
-#
-# "%s, [%s #%d] %5s -- %s: %s\n"
-#
-# where the values to be formatted are:
-#
-# - \Severity (one letter).
-# - Timestamp.
-# - Process id.
-# - \Severity (word).
-# - Program name.
-# - Message.
-#
-# You can use a different entry format by:
-#
-# - Setting a custom format proc (affects following entries);
-# see {formatter=}[Logger.html#attribute-i-formatter].
-# - Calling any of the methods above with a block
-# (affects only the one entry).
-# Doing so can have two benefits:
-#
-# - Context: the block can evaluate the entire program context
-# and create a context-dependent message.
-# - Performance: the block is not evaluated unless the log level
-# permits the entry actually to be written:
-#
-# logger.error { my_slow_message_generator }
-#
-# Contrast this with the string form, where the string is
-# always evaluated, regardless of the log level:
-#
-# logger.error("#{my_slow_message_generator}")
-#
-# === \Severity
-#
-# The severity of a log entry has two effects:
-#
-# - Determines whether the entry is selected for inclusion in the log;
-# see {Log Level}[rdoc-ref:Logger@Log+Level].
-# - Indicates to any log reader (whether a person or a program)
-# the relative importance of the entry.
-#
-# === Timestamp
-#
-# The timestamp for a log entry is generated automatically
-# when the entry is created.
-#
-# The logged timestamp is formatted by method
-# {Time#strftime}[rdoc-ref:Time#strftime]
-# using this format string:
-#
-# '%Y-%m-%dT%H:%M:%S.%6N'
-#
-# Example:
-#
-# logger = Logger.new($stdout)
-# logger.add(Logger::INFO)
-# # => I, [2022-05-07T17:04:32.318331 #20536] INFO -- : nil
-#
-# You can set a different format using method #datetime_format=.
-#
-# === Message
-#
-# The message is an optional argument to an entry method:
-#
-# logger = Logger.new($stdout)
-# logger.add(Logger::INFO, 'My message')
-# # => I, [2022-05-07T18:15:37.647581 #20536] INFO -- : My message
-#
-# For the default entry formatter, <tt>Logger::Formatter</tt>,
-# the message object may be:
-#
-# - A string: used as-is.
-# - An Exception: <tt>message.message</tt> is used.
-# - Anything else: <tt>message.inspect</tt> is used.
-#
-# *Note*: Logger::Formatter does not escape or sanitize
-# the message passed to it.
-# Developers should be aware that malicious data (user input)
-# may be in the message, and should explicitly escape untrusted data.
-#
-# You can use a custom formatter to escape message data;
-# see the example at {formatter=}[Logger.html#attribute-i-formatter].
-#
-# === Program Name
-#
-# The program name is an optional argument to an entry method:
-#
-# logger = Logger.new($stdout)
-# logger.add(Logger::INFO, 'My message', 'mung')
-# # => I, [2022-05-07T18:17:38.084716 #20536] INFO -- mung: My message
-#
-# The default program name for a new logger may be set in the call to
-# Logger.new via optional keyword argument +progname+:
-#
-# logger = Logger.new('t.log', progname: 'mung')
-#
-# The default program name for an existing logger may be set
-# by a call to method #progname=:
-#
-# logger.progname = 'mung'
-#
-# The current program name may be retrieved with method
-# {progname}[Logger.html#attribute-i-progname]:
-#
-# logger.progname # => "mung"
-#
-# == Log Level
-#
-# The log level setting determines whether an entry is actually
-# written to the log, based on the entry's severity.
-#
-# These are the defined severities (least severe to most severe):
-#
-# logger = Logger.new($stdout)
-# logger.add(Logger::DEBUG, 'Maximal debugging info')
-# # => D, [2022-05-07T17:57:41.776220 #20536] DEBUG -- : Maximal debugging info
-# logger.add(Logger::INFO, 'Non-error information')
-# # => I, [2022-05-07T17:59:14.349167 #20536] INFO -- : Non-error information
-# logger.add(Logger::WARN, 'Non-error warning')
-# # => W, [2022-05-07T18:00:45.337538 #20536] WARN -- : Non-error warning
-# logger.add(Logger::ERROR, 'Non-fatal error')
-# # => E, [2022-05-07T18:02:41.592912 #20536] ERROR -- : Non-fatal error
-# logger.add(Logger::FATAL, 'Fatal error')
-# # => F, [2022-05-07T18:05:24.703931 #20536] FATAL -- : Fatal error
-# logger.add(Logger::UNKNOWN, 'Most severe')
-# # => A, [2022-05-07T18:07:54.657491 #20536] ANY -- : Most severe
-#
-# The default initial level setting is Logger::DEBUG, the lowest level,
-# which means that all entries are to be written, regardless of severity:
-#
-# logger = Logger.new($stdout)
-# logger.level # => 0
-# logger.add(0, "My message")
-# # => D, [2022-05-11T15:10:59.773668 #20536] DEBUG -- : My message
-#
-# You can specify a different setting in a new logger
-# using keyword argument +level+ with an appropriate value:
-#
-# logger = Logger.new($stdout, level: Logger::ERROR)
-# logger = Logger.new($stdout, level: 'error')
-# logger = Logger.new($stdout, level: :error)
-# logger.level # => 3
-#
-# With this level, entries with severity Logger::ERROR and higher
-# are written, while those with lower severities are not written:
-#
-# logger = Logger.new($stdout, level: Logger::ERROR)
-# logger.add(3)
-# # => E, [2022-05-11T15:17:20.933362 #20536] ERROR -- : nil
-# logger.add(2) # Silent.
-#
-# You can set the log level for an existing logger
-# with method #level=:
-#
-# logger.level = Logger::ERROR
-#
-# These shorthand methods also set the level:
-#
-# logger.debug! # => 0
-# logger.info! # => 1
-# logger.warn! # => 2
-# logger.error! # => 3
-# logger.fatal! # => 4
-#
-# You can retrieve the log level with method
-# {level}[Logger.html#attribute-i-level]:
-#
-# logger.level = Logger::ERROR
-# logger.level # => 3
-#
-# These methods return whether a given
-# level is to be written:
-#
-# logger.level = Logger::ERROR
-# logger.debug? # => false
-# logger.info? # => false
-# logger.warn? # => false
-# logger.error? # => true
-# logger.fatal? # => true
-#
-# == Log File Rotation
-#
-# By default, a log file is a single file that grows indefinitely
-# (until explicitly closed); there is no file rotation.
-#
-# To keep log files to a manageable size,
-# you can use _log_ _file_ _rotation_, which uses multiple log files:
-#
-# - Each log file has entries for a non-overlapping
-# time interval.
-# - Only the most recent log file is open and active;
-# the others are closed and inactive.
-#
-# === Size-Based Rotation
-#
-# For size-based log file rotation, call Logger.new with:
-#
-# - Argument +logdev+ as a file path.
-# - Argument +shift_age+ with a positive integer:
-# the number of log files to be in the rotation.
-# - Argument +shift_size+ as a positive integer:
-# the maximum size (in bytes) of each log file;
-# defaults to 1048576 (1 megabyte).
-#
-# Examples:
-#
-# logger = Logger.new('t.log', 3) # Three 1-megabyte files.
-# logger = Logger.new('t.log', 5, 10485760) # Five 10-megabyte files.
-#
-# For these examples, suppose:
-#
-# logger = Logger.new('t.log', 3)
-#
-# Logging begins in the new log file, +t.log+;
-# the log file is "full" and ready for rotation
-# when a new entry would cause its size to exceed +shift_size+.
-#
-# The first time +t.log+ is full:
-#
-# - +t.log+ is closed and renamed to +t.log.0+.
-# - A new file +t.log+ is opened.
-#
-# The second time +t.log+ is full:
-#
-# - +t.log.0 is renamed as +t.log.1+.
-# - +t.log+ is closed and renamed to +t.log.0+.
-# - A new file +t.log+ is opened.
-#
-# Each subsequent time that +t.log+ is full,
-# the log files are rotated:
-#
-# - +t.log.1+ is removed.
-# - +t.log.0 is renamed as +t.log.1+.
-# - +t.log+ is closed and renamed to +t.log.0+.
-# - A new file +t.log+ is opened.
-#
-# === Periodic Rotation
-#
-# For periodic rotation, call Logger.new with:
-#
-# - Argument +logdev+ as a file path.
-# - Argument +shift_age+ as a string period indicator.
-#
-# Examples:
-#
-# logger = Logger.new('t.log', 'daily') # Rotate log files daily.
-# logger = Logger.new('t.log', 'weekly') # Rotate log files weekly.
-# logger = Logger.new('t.log', 'monthly') # Rotate log files monthly.
-#
-# Example:
-#
-# logger = Logger.new('t.log', 'daily')
-#
-# When the given period expires:
-#
-# - The base log file, +t.log+ is closed and renamed
-# with a date-based suffix such as +t.log.20220509+.
-# - A new log file +t.log+ is opened.
-# - Nothing is removed.
-#
-# The default format for the suffix is <tt>'%Y%m%d'</tt>,
-# which produces a suffix similar to the one above.
-# You can set a different format using create-time option
-# +shift_period_suffix+;
-# see details and suggestions at
-# {Time#strftime}[rdoc-ref:Time#strftime].
-#
-class Logger
- _, name, rev = %w$Id$
- if name
- name = name.chomp(",v")
- else
- name = File.basename(__FILE__)
- end
- rev ||= "v#{VERSION}"
- ProgName = "#{name}/#{rev}"
-
- include Severity
-
- # Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
- def level
- @level_override[Fiber.current] || @level
- end
-
- # Sets the log level; returns +severity+.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- # Argument +severity+ may be an integer, a string, or a symbol:
- #
- # logger.level = Logger::ERROR # => 3
- # logger.level = 3 # => 3
- # logger.level = 'error' # => "error"
- # logger.level = :error # => :error
- #
- # Logger#sev_threshold= is an alias for Logger#level=.
- #
- def level=(severity)
- @level = Severity.coerce(severity)
- end
-
- # Adjust the log level during the block execution for the current Fiber only
- #
- # logger.with_level(:debug) do
- # logger.debug { "Hello" }
- # end
- def with_level(severity)
- prev, @level_override[Fiber.current] = level, Severity.coerce(severity)
- begin
- yield
- ensure
- if prev
- @level_override[Fiber.current] = prev
- else
- @level_override.delete(Fiber.current)
- end
- end
- end
-
- # Program name to include in log messages.
- attr_accessor :progname
-
- # Sets the date-time format.
- #
- # Argument +datetime_format+ should be either of these:
- #
- # - A string suitable for use as a format for method
- # {Time#strftime}[rdoc-ref:Time#strftime].
- # - +nil+: the logger uses <tt>'%Y-%m-%dT%H:%M:%S.%6N'</tt>.
- #
- def datetime_format=(datetime_format)
- @default_formatter.datetime_format = datetime_format
- end
-
- # Returns the date-time format; see #datetime_format=.
- #
- def datetime_format
- @default_formatter.datetime_format
- end
-
- # Sets or retrieves the logger entry formatter proc.
- #
- # When +formatter+ is +nil+, the logger uses Logger::Formatter.
- #
- # When +formatter+ is a proc, a new entry is formatted by the proc,
- # which is called with four arguments:
- #
- # - +severity+: The severity of the entry.
- # - +time+: A Time object representing the entry's timestamp.
- # - +progname+: The program name for the entry.
- # - +msg+: The message for the entry (string or string-convertible object).
- #
- # The proc should return a string containing the formatted entry.
- #
- # This custom formatter uses
- # {String#dump}[rdoc-ref:String#dump]
- # to escape the message string:
- #
- # logger = Logger.new($stdout, progname: 'mung')
- # original_formatter = logger.formatter || Logger::Formatter.new
- # logger.formatter = proc { |severity, time, progname, msg|
- # original_formatter.call(severity, time, progname, msg.dump)
- # }
- # logger.add(Logger::INFO, "hello \n ''")
- # logger.add(Logger::INFO, "\f\x00\xff\\\"")
- #
- # Output:
- #
- # I, [2022-05-13T13:16:29.637488 #8492] INFO -- mung: "hello \n ''"
- # I, [2022-05-13T13:16:29.637610 #8492] INFO -- mung: "\f\x00\xFF\\\""
- #
- attr_accessor :formatter
-
- alias sev_threshold level
- alias sev_threshold= level=
-
- # Returns +true+ if the log level allows entries with severity
- # Logger::DEBUG to be written, +false+ otherwise.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def debug?; level <= DEBUG; end
-
- # Sets the log level to Logger::DEBUG.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def debug!; self.level = DEBUG; end
-
- # Returns +true+ if the log level allows entries with severity
- # Logger::INFO to be written, +false+ otherwise.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def info?; level <= INFO; end
-
- # Sets the log level to Logger::INFO.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def info!; self.level = INFO; end
-
- # Returns +true+ if the log level allows entries with severity
- # Logger::WARN to be written, +false+ otherwise.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def warn?; level <= WARN; end
-
- # Sets the log level to Logger::WARN.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def warn!; self.level = WARN; end
-
- # Returns +true+ if the log level allows entries with severity
- # Logger::ERROR to be written, +false+ otherwise.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def error?; level <= ERROR; end
-
- # Sets the log level to Logger::ERROR.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def error!; self.level = ERROR; end
-
- # Returns +true+ if the log level allows entries with severity
- # Logger::FATAL to be written, +false+ otherwise.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def fatal?; level <= FATAL; end
-
- # Sets the log level to Logger::FATAL.
- # See {Log Level}[rdoc-ref:Logger@Log+Level].
- #
- def fatal!; self.level = FATAL; end
-
- # :call-seq:
- # Logger.new(logdev, shift_age = 0, shift_size = 1048576, **options)
- #
- # With the single argument +logdev+,
- # returns a new logger with all default options:
- #
- # Logger.new('t.log') # => #<Logger:0x000001e685dc6ac8>
- #
- # Argument +logdev+ must be one of:
- #
- # - A string filepath: entries are to be written
- # to the file at that path; if the file at that path exists,
- # new entries are appended.
- # - An IO stream (typically +$stdout+, +$stderr+. or an open file):
- # entries are to be written to the given stream.
- # - +nil+ or +File::NULL+: no entries are to be written.
- #
- # Examples:
- #
- # Logger.new('t.log')
- # Logger.new($stdout)
- #
- # The keyword options are:
- #
- # - +level+: sets the log level; default value is Logger::DEBUG.
- # See {Log Level}[rdoc-ref:Logger@Log+Level]:
- #
- # Logger.new('t.log', level: Logger::ERROR)
- #
- # - +progname+: sets the default program name; default is +nil+.
- # See {Program Name}[rdoc-ref:Logger@Program+Name]:
- #
- # Logger.new('t.log', progname: 'mung')
- #
- # - +formatter+: sets the entry formatter; default is +nil+.
- # See {formatter=}[Logger.html#attribute-i-formatter].
- # - +datetime_format+: sets the format for entry timestamp;
- # default is +nil+.
- # See #datetime_format=.
- # - +binmode+: sets whether the logger writes in binary mode;
- # default is +false+.
- # - +shift_period_suffix+: sets the format for the filename suffix
- # for periodic log file rotation; default is <tt>'%Y%m%d'</tt>.
- # See {Periodic Rotation}[rdoc-ref:Logger@Periodic+Rotation].
- #
- def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG,
- progname: nil, formatter: nil, datetime_format: nil,
- binmode: false, shift_period_suffix: '%Y%m%d')
- self.level = level
- self.progname = progname
- @default_formatter = Formatter.new
- self.datetime_format = datetime_format
- self.formatter = formatter
- @logdev = nil
- @level_override = {}
- if logdev && logdev != File::NULL
- @logdev = LogDevice.new(logdev, shift_age: shift_age,
- shift_size: shift_size,
- shift_period_suffix: shift_period_suffix,
- binmode: binmode)
- end
- end
-
- # Sets the logger's output stream:
- #
- # - If +logdev+ is +nil+, reopens the current output stream.
- # - If +logdev+ is a filepath, opens the indicated file for append.
- # - If +logdev+ is an IO stream
- # (usually <tt>$stdout</tt>, <tt>$stderr</tt>, or an open File object),
- # opens the stream for append.
- #
- # Example:
- #
- # logger = Logger.new('t.log')
- # logger.add(Logger::ERROR, 'one')
- # logger.close
- # logger.add(Logger::ERROR, 'two') # Prints 'log writing failed. closed stream'
- # logger.reopen
- # logger.add(Logger::ERROR, 'three')
- # logger.close
- # File.readlines('t.log')
- # # =>
- # # ["# Logfile created on 2022-05-12 14:21:19 -0500 by logger.rb/v1.5.0\n",
- # # "E, [2022-05-12T14:21:27.596726 #22428] ERROR -- : one\n",
- # # "E, [2022-05-12T14:23:05.847241 #22428] ERROR -- : three\n"]
- #
- def reopen(logdev = nil)
- @logdev&.reopen(logdev)
- self
- end
-
- # Creates a log entry, which may or may not be written to the log,
- # depending on the entry's severity and on the log level.
- # See {Log Level}[rdoc-ref:Logger@Log+Level]
- # and {Entries}[rdoc-ref:Logger@Entries] for details.
- #
- # Examples:
- #
- # logger = Logger.new($stdout, progname: 'mung')
- # logger.add(Logger::INFO)
- # logger.add(Logger::ERROR, 'No good')
- # logger.add(Logger::ERROR, 'No good', 'gnum')
- #
- # Output:
- #
- # I, [2022-05-12T16:25:31.469726 #36328] INFO -- mung: mung
- # E, [2022-05-12T16:25:55.349414 #36328] ERROR -- mung: No good
- # E, [2022-05-12T16:26:35.841134 #36328] ERROR -- gnum: No good
- #
- # These convenience methods have implicit severity:
- #
- # - #debug.
- # - #info.
- # - #warn.
- # - #error.
- # - #fatal.
- # - #unknown.
- #
- def add(severity, message = nil, progname = nil)
- severity ||= UNKNOWN
- if @logdev.nil? or severity < level
- return true
- end
- if progname.nil?
- progname = @progname
- end
- if message.nil?
- if block_given?
- message = yield
- else
- message = progname
- progname = @progname
- end
- end
- @logdev.write(
- format_message(format_severity(severity), Time.now, progname, message))
- true
- end
- alias log add
-
- # Writes the given +msg+ to the log with no formatting;
- # returns the number of characters written,
- # or +nil+ if no log device exists:
- #
- # logger = Logger.new($stdout)
- # logger << 'My message.' # => 10
- #
- # Output:
- #
- # My message.
- #
- def <<(msg)
- @logdev&.write(msg)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::DEBUG</tt>.
- #
- def debug(progname = nil, &block)
- add(DEBUG, nil, progname, &block)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::INFO</tt>.
- #
- def info(progname = nil, &block)
- add(INFO, nil, progname, &block)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::WARN</tt>.
- #
- def warn(progname = nil, &block)
- add(WARN, nil, progname, &block)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::ERROR</tt>.
- #
- def error(progname = nil, &block)
- add(ERROR, nil, progname, &block)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::FATAL</tt>.
- #
- def fatal(progname = nil, &block)
- add(FATAL, nil, progname, &block)
- end
-
- # Equivalent to calling #add with severity <tt>Logger::UNKNOWN</tt>.
- #
- def unknown(progname = nil, &block)
- add(UNKNOWN, nil, progname, &block)
- end
-
- # Closes the logger; returns +nil+:
- #
- # logger = Logger.new('t.log')
- # logger.close # => nil
- # logger.info('foo') # Prints "log writing failed. closed stream"
- #
- # Related: Logger#reopen.
- def close
- @logdev&.close
- end
-
-private
-
- # \Severity label for logging (max 5 chars).
- SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY).freeze
-
- def format_severity(severity)
- SEV_LABEL[severity] || 'ANY'
- end
-
- def format_message(severity, datetime, progname, msg)
- (@formatter || @default_formatter).call(severity, datetime, progname, msg)
- end
-end
diff --git a/lib/logger/errors.rb b/lib/logger/errors.rb
deleted file mode 100644
index 88581793f0..0000000000
--- a/lib/logger/errors.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- # not used after 1.2.7. just for compat.
- class Error < RuntimeError # :nodoc:
- end
- class ShiftingError < Error # :nodoc:
- end
-end
diff --git a/lib/logger/formatter.rb b/lib/logger/formatter.rb
deleted file mode 100644
index c634dbf34d..0000000000
--- a/lib/logger/formatter.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- # Default formatter for log messages.
- class Formatter
- Format = "%.1s, [%s #%d] %5s -- %s: %s\n"
- DatetimeFormat = "%Y-%m-%dT%H:%M:%S.%6N"
-
- attr_accessor :datetime_format
-
- def initialize
- @datetime_format = nil
- end
-
- def call(severity, time, progname, msg)
- sprintf(Format, severity, format_datetime(time), Process.pid, severity, progname, msg2str(msg))
- end
-
- private
-
- def format_datetime(time)
- time.strftime(@datetime_format || DatetimeFormat)
- end
-
- def msg2str(msg)
- case msg
- when ::String
- msg
- when ::Exception
- "#{ msg.message } (#{ msg.class })\n#{ msg.backtrace.join("\n") if msg.backtrace }"
- else
- msg.inspect
- end
- end
- end
-end
diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb
deleted file mode 100644
index 84277a2656..0000000000
--- a/lib/logger/log_device.rb
+++ /dev/null
@@ -1,207 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'period'
-
-class Logger
- # Device used for logging messages.
- class LogDevice
- include Period
-
- attr_reader :dev
- attr_reader :filename
- include MonitorMixin
-
- def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false)
- @dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
- @binmode = binmode
- mon_initialize
- set_dev(log)
- if @filename
- @shift_age = shift_age || 7
- @shift_size = shift_size || 1048576
- @shift_period_suffix = shift_period_suffix || '%Y%m%d'
-
- unless @shift_age.is_a?(Integer)
- base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now
- @next_rotate_time = next_rotate_time(base_time, @shift_age)
- end
- end
- end
-
- def write(message)
- begin
- synchronize do
- if @shift_age and @dev.respond_to?(:stat)
- begin
- check_shift_log
- rescue
- warn("log shifting failed. #{$!}")
- end
- end
- begin
- @dev.write(message)
- rescue
- warn("log writing failed. #{$!}")
- end
- end
- rescue Exception => ignored
- warn("log writing failed. #{ignored}")
- end
- end
-
- def close
- begin
- synchronize do
- @dev.close rescue nil
- end
- rescue Exception
- @dev.close rescue nil
- end
- end
-
- def reopen(log = nil)
- # reopen the same filename if no argument, do nothing for IO
- log ||= @filename if @filename
- if log
- synchronize do
- if @filename and @dev
- @dev.close rescue nil # close only file opened by Logger
- @filename = nil
- end
- set_dev(log)
- end
- end
- self
- end
-
- private
-
- def set_dev(log)
- if log.respond_to?(:write) and log.respond_to?(:close)
- @dev = log
- if log.respond_to?(:path) and path = log.path
- if File.exist?(path)
- @filename = path
- end
- end
- else
- @dev = open_logfile(log)
- @dev.sync = true
- @dev.binmode if @binmode
- @filename = log
- end
- end
-
- def open_logfile(filename)
- begin
- File.open(filename, (File::WRONLY | File::APPEND))
- rescue Errno::ENOENT
- create_logfile(filename)
- end
- end
-
- def create_logfile(filename)
- begin
- logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
- logdev.flock(File::LOCK_EX)
- logdev.sync = true
- logdev.binmode if @binmode
- add_log_header(logdev)
- logdev.flock(File::LOCK_UN)
- rescue Errno::EEXIST
- # file is created by another process
- logdev = open_logfile(filename)
- logdev.sync = true
- end
- logdev
- end
-
- def add_log_header(file)
- file.write(
- "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
- ) if file.size == 0
- end
-
- def check_shift_log
- if @shift_age.is_a?(Integer)
- # Note: always returns false if '0'.
- if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
- lock_shift_log { shift_log_age }
- end
- else
- now = Time.now
- if now >= @next_rotate_time
- @next_rotate_time = next_rotate_time(now, @shift_age)
- lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
- end
- end
- end
-
- if /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
- def lock_shift_log
- yield
- end
- else
- def lock_shift_log
- retry_limit = 8
- retry_sleep = 0.1
- begin
- File.open(@filename, File::WRONLY | File::APPEND) do |lock|
- lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
- if File.identical?(@filename, lock) and File.identical?(lock, @dev)
- yield # log shifting
- else
- # log shifted by another process (i-node before locking and i-node after locking are different)
- @dev.close rescue nil
- @dev = open_logfile(@filename)
- @dev.sync = true
- end
- end
- rescue Errno::ENOENT
- # @filename file would not exist right after #rename and before #create_logfile
- if retry_limit <= 0
- warn("log rotation inter-process lock failed. #{$!}")
- else
- sleep retry_sleep
- retry_limit -= 1
- retry_sleep *= 2
- retry
- end
- end
- rescue
- warn("log rotation inter-process lock failed. #{$!}")
- end
- end
-
- def shift_log_age
- (@shift_age-3).downto(0) do |i|
- if FileTest.exist?("#{@filename}.#{i}")
- File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", "#{@filename}.0")
- @dev = create_logfile(@filename)
- return true
- end
-
- def shift_log_period(period_end)
- suffix = period_end.strftime(@shift_period_suffix)
- age_file = "#{@filename}.#{suffix}"
- if FileTest.exist?(age_file)
- # try to avoid filename crash caused by Timestamp change.
- idx = 0
- # .99 can be overridden; avoid too much file search with 'loop do'
- while idx < 100
- idx += 1
- age_file = "#{@filename}.#{suffix}.#{idx}"
- break unless FileTest.exist?(age_file)
- end
- end
- @dev.close rescue nil
- File.rename("#{@filename}", age_file)
- @dev = create_logfile(@filename)
- return true
- end
- end
-end
diff --git a/lib/logger/logger.gemspec b/lib/logger/logger.gemspec
deleted file mode 100644
index d12db625d9..0000000000
--- a/lib/logger/logger.gemspec
+++ /dev/null
@@ -1,26 +0,0 @@
-begin
- require_relative "lib/logger/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "logger"
- spec.version = Logger::VERSION
- spec.authors = ["Naotoshi Seo", "SHIBATA Hiroshi"]
- spec.email = ["sonots@gmail.com", "hsbt@ruby-lang.org"]
-
- spec.summary = %q{Provides a simple logging utility for outputting messages.}
- spec.description = %q{Provides a simple logging utility for outputting messages.}
- spec.homepage = "https://github.com/ruby/logger"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
- spec.require_paths = ["lib"]
-
- spec.required_ruby_version = ">= 2.3.0"
-
- spec.add_development_dependency "bundler", ">= 0"
- spec.add_development_dependency "rake", ">= 12.3.3"
- spec.add_development_dependency "test-unit"
-end
diff --git a/lib/logger/period.rb b/lib/logger/period.rb
deleted file mode 100644
index 0a291dbbbe..0000000000
--- a/lib/logger/period.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- module Period
- module_function
-
- SiD = 24 * 60 * 60
-
- def next_rotate_time(now, shift_age)
- case shift_age
- when 'daily'
- t = Time.mktime(now.year, now.month, now.mday) + SiD
- when 'weekly'
- t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
- when 'monthly'
- t = Time.mktime(now.year, now.month, 1) + SiD * 32
- return Time.mktime(t.year, t.month, 1)
- when 'now', 'everytime'
- return now
- else
- raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
- end
- if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
- hour = t.hour
- t = Time.mktime(t.year, t.month, t.mday)
- t += SiD if hour > 12
- end
- t
- end
-
- def previous_period_end(now, shift_age)
- case shift_age
- when 'daily'
- t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
- when 'weekly'
- t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
- when 'monthly'
- t = Time.mktime(now.year, now.month, 1) - SiD / 2
- when 'now', 'everytime'
- return now
- else
- raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
- end
- Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
- end
- end
-end
diff --git a/lib/logger/severity.rb b/lib/logger/severity.rb
deleted file mode 100644
index e96fb0d320..0000000000
--- a/lib/logger/severity.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- # Logging severity.
- module Severity
- # Low-level information, mostly for developers.
- DEBUG = 0
- # Generic (useful) information about system operation.
- INFO = 1
- # A warning.
- WARN = 2
- # A handleable error condition.
- ERROR = 3
- # An unhandleable error that results in a program crash.
- FATAL = 4
- # An unknown message that should always be logged.
- UNKNOWN = 5
-
- LEVELS = {
- "debug" => DEBUG,
- "info" => INFO,
- "warn" => WARN,
- "error" => ERROR,
- "fatal" => FATAL,
- "unknown" => UNKNOWN,
- }
- private_constant :LEVELS
-
- def self.coerce(severity)
- if severity.is_a?(Integer)
- severity
- else
- key = severity.to_s.downcase
- LEVELS[key] || raise(ArgumentError, "invalid log level: #{severity}")
- end
- end
- end
-end
diff --git a/lib/logger/version.rb b/lib/logger/version.rb
deleted file mode 100644
index f85c72eed3..0000000000
--- a/lib/logger/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Logger
- VERSION = "1.5.3"
-end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 245b0a44ce..37ee4a70d9 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -40,10 +40,27 @@ class Array # :nodoc:
end
##
-# mkmf.rb is used by Ruby C extensions to generate a Makefile which will
+# \Module \MakeMakefile is used by Ruby C extensions to generate a Makefile which will
# correctly compile and link the C extension to Ruby and a third-party
# library.
module MakeMakefile
+
+ target_rbconfig = nil
+ ARGV.delete_if do |arg|
+ opt = arg.delete_prefix("--target-rbconfig=")
+ unless opt == arg
+ target_rbconfig = opt
+ end
+ end
+ if target_rbconfig
+ # Load the RbConfig for the target platform into this module.
+ # Cross-compiling needs the same version of Ruby.
+ Kernel.load target_rbconfig, self
+ else
+ # The RbConfig for the target platform where the built extension runs.
+ RbConfig = ::RbConfig
+ end
+
#### defer until this module become global-state free.
# def self.extended(obj)
# obj.init_mkmf
@@ -59,6 +76,9 @@ module MakeMakefile
# The makefile configuration using the defaults from when Ruby was built.
CONFIG = RbConfig::MAKEFILE_CONFIG
+
+ ##
+ # The saved original value of +LIB+ environment variable
ORIG_LIBPATH = ENV['LIB']
##
@@ -245,12 +265,16 @@ MESSAGE
CSRCFLAG = CONFIG['CSRCFLAG']
CPPOUTFILE = config_string('CPPOUTFILE') {|str| str.sub(/\bconftest\b/, CONFTEST)}
+ # :startdoc:
+
+ # Removes _files_.
def rm_f(*files)
opt = (Hash === files.last ? [files.pop] : [])
FileUtils.rm_f(Dir[*files.flatten], *opt)
end
module_function :rm_f
+ # Removes _files_ recursively.
def rm_rf(*files)
opt = (Hash === files.last ? [files.pop] : [])
FileUtils.rm_rf(Dir[*files.flatten], *opt)
@@ -265,6 +289,8 @@ MESSAGE
t if times.all? {|n| n <= t}
end
+ # :stopdoc:
+
def split_libs(*strs)
sep = $mswin ? /\s+/ : /\s+(?=-|\z)/
strs.flat_map {|s| s.lstrip.split(sep)}
@@ -390,6 +416,11 @@ MESSAGE
env, *commands = commands if Hash === commands.first
envs.merge!(env) if env
end
+
+ # disable ASAN leak reporting - conftest programs almost always don't bother
+ # to free their memory.
+ envs['LSAN_OPTIONS'] = "detect_leaks=0" unless ENV.key?('LSAN_OPTIONS')
+
return envs, expand[commands]
end
@@ -397,11 +428,19 @@ MESSAGE
envs.map {|e, v| "#{e}=#{v.quote}"}
end
- def xsystem command, opts = nil
+ # :startdoc:
+
+ # call-seq:
+ # xsystem(command, werror: false) -> true or false
+ #
+ # Executes _command_ with expanding variables, and returns the exit
+ # status like as Kernel#system. If _werror_ is true and the error
+ # output is not empty, returns +false+. The output will logged.
+ def xsystem(command, werror: false)
env, command = expand_command(command)
Logging::open do
puts [env_quote(env), command.quote].join(' ')
- if opts and opts[:werror]
+ if werror
result = nil
Logging.postpone do |log|
output = IO.popen(env, command, &:read)
@@ -415,6 +454,7 @@ MESSAGE
end
end
+ # Executes _command_ similarly to xsystem, but yields opened pipe.
def xpopen command, *mode, &block
env, commands = expand_command(command)
command = [env_quote(env), command].join(' ')
@@ -429,6 +469,7 @@ MESSAGE
end
end
+ # Logs _src_
def log_src(src, heading="checked program was")
src = src.split(/^/)
fmt = "%#{src.size.to_s.size}d: %s"
@@ -443,10 +484,15 @@ EOM
EOM
end
+ # Returns the language-dependent source file name for configuration
+ # checks.
def conftest_source
CONFTEST_C
end
+ # Creats temporary source file from +COMMON_HEADERS+ and _src_.
+ # Yields the created source string and uses the returned string as
+ # the source code, if the block is given.
def create_tmpsrc(src)
src = "#{COMMON_HEADERS}\n#{src}"
src = yield(src) if block_given?
@@ -467,6 +513,8 @@ EOM
src
end
+ # :stopdoc:
+
def have_devel?
unless defined? $have_devel
$have_devel = true
@@ -475,7 +523,7 @@ EOM
$have_devel
end
- def try_do(src, command, *opts, &b)
+ def try_do(src, command, **opts, &b)
unless have_devel?
raise <<MSG
The compiler failed to generate an executable file.
@@ -484,7 +532,7 @@ MSG
end
begin
src = create_tmpsrc(src, &b)
- xsystem(command, *opts)
+ xsystem(command, **opts)
ensure
log_src(src)
end
@@ -525,52 +573,57 @@ MSG
conf)
end
- def cpp_command(outfile, opt="")
+ def cpp_config(opt)
conf = cc_config(opt)
if $universal and (arch_flag = conf['ARCH_FLAG']) and !arch_flag.empty?
conf['ARCH_FLAG'] = arch_flag.gsub(/(?:\G|\s)-arch\s+\S+/, '')
end
+ conf
+ end
+
+ def cpp_command(outfile, opt="")
+ conf = cpp_config(opt)
RbConfig::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
conf)
end
def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
+ libpathflags = nil
libpath.map{|x|
case x
when "$(topdir)", /\A\./
LIBPATHFLAG
else
- LIBPATHFLAG+RPATHFLAG
+ libpathflags ||= [LIBPATHFLAG, RPATHFLAG].grep(/\S/).join(" ")
end % x.quote
- }.join
+ }.join(" ")
+ end
+
+ def werror_flag(opt = nil)
+ config_string("WERRORFLAG") {|flag| opt = opt && !opt.empty? ? "#{opt} #{flag}" : flag}
+ opt
end
def with_werror(opt, opts = nil)
- if opts
- if opts[:werror] and config_string("WERRORFLAG") {|flag| opt = opt ? "#{opt} #{flag}" : flag}
- (opts = opts.dup).delete(:werror)
- end
- yield(opt, opts)
- else
- yield(opt)
- end
+ opt = werror_flag(opt) if opts and (opts = opts.dup).delete(:werror)
+ yield(opt, opts)
end
- def try_link0(src, opt="", *opts, &b) # :nodoc:
+ def try_link0(src, opt = "", ldflags: "", **opts, &b) # :nodoc:
exe = CONFTEST+$EXEEXT
- cmd = link_command("", opt)
+ cmd = link_command(ldflags, opt)
if $universal
require 'tmpdir'
Dir.mktmpdir("mkmf_", oldtmpdir = ENV["TMPDIR"]) do |tmpdir|
begin
ENV["TMPDIR"] = tmpdir
- try_do(src, cmd, *opts, &b)
+ try_do(src, cmd, **opts, &b)
ensure
ENV["TMPDIR"] = oldtmpdir
end
end
else
- try_do(src, cmd, *opts, &b)
+ try_do(src, cmd, **opts, &b)
end and File.executable?(exe) or return nil
exe
ensure
@@ -579,31 +632,32 @@ MSG
# Returns whether or not the +src+ can be compiled as a C source and linked
# with its depending libraries successfully. +opt+ is passed to the linker
- # as options. Note that +$CFLAGS+ and +$LDFLAGS+ are also passed to the
- # linker.
+ # as options. Note that <tt>$CFLAGS</tt> and <tt>$LDFLAGS</tt> are also
+ # passed to the linker.
#
# If a block given, it is called with the source before compilation. You can
# modify the source in the block.
#
# [+src+] a String which contains a C source
# [+opt+] a String which contains linker options
- def try_link(src, opt="", *opts, &b)
- exe = try_link0(src, opt, *opts, &b) or return false
+ def try_link(src, opt = "", **opts, &b)
+ exe = try_link0(src, opt, **opts, &b) or return false
MakeMakefile.rm_f exe
true
end
# Returns whether or not the +src+ can be compiled as a C source. +opt+ is
- # passed to the C compiler as options. Note that +$CFLAGS+ is also passed to
- # the compiler.
+ # passed to the C compiler as options. Note that <tt>$CFLAGS</tt> is also
+ # passed to the compiler.
#
# If a block given, it is called with the source before compilation. You can
# modify the source in the block.
#
# [+src+] a String which contains a C source
# [+opt+] a String which contains compiler options
- def try_compile(src, opt="", *opts, &b)
- with_werror(opt, *opts) {|_opt, *| try_do(src, cc_command(_opt), *opts, &b)} and
+ def try_compile(src, opt = "", werror: nil, **opts, &b)
+ opt = werror_flag(opt) if werror
+ try_do(src, cc_command(opt), werror: werror, **opts, &b) and
File.file?("#{CONFTEST}.#{$OBJEXT}")
ensure
MakeMakefile.rm_f "#{CONFTEST}*"
@@ -611,15 +665,15 @@ MSG
# Returns whether or not the +src+ can be preprocessed with the C
# preprocessor. +opt+ is passed to the preprocessor as options. Note that
- # +$CFLAGS+ is also passed to the preprocessor.
+ # <tt>$CFLAGS</tt> is also passed to the preprocessor.
#
# If a block given, it is called with the source before preprocessing. You
# can modify the source in the block.
#
# [+src+] a String which contains a C source
# [+opt+] a String which contains preprocessor options
- def try_cpp(src, opt="", *opts, &b)
- try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) and
+ def try_cpp(src, opt = "", **opts, &b)
+ try_do(src, cpp_command(CPPOUTFILE, opt), **opts, &b) and
File.file?("#{CONFTEST}.i")
ensure
MakeMakefile.rm_f "#{CONFTEST}*"
@@ -636,6 +690,14 @@ MSG
end
end
+ # :startdoc:
+
+ # Sets <tt>$CPPFLAGS</tt> to _flags_ and yields. If the block returns a
+ # falsy value, <tt>$CPPFLAGS</tt> is reset to its previous value, remains
+ # set to _flags_ otherwise.
+ #
+ # [+flags+] a C preprocessor flag as a +String+
+ #
def with_cppflags(flags)
cppflags = $CPPFLAGS
$CPPFLAGS = flags.dup
@@ -644,20 +706,29 @@ MSG
$CPPFLAGS = cppflags unless ret
end
- def try_cppflags(flags, opts = {})
- try_header(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
+ # :nodoc:
+ def try_cppflags(flags, werror: true, **opts)
+ try_header(MAIN_DOES_NOTHING, flags, werror: werror, **opts)
end
- def append_cppflags(flags, *opts)
+ # Check whether each given C preprocessor flag is acceptable and append it
+ # to <tt>$CPPFLAGS</tt> if so.
+ #
+ # [+flags+] a C preprocessor flag as a +String+ or an +Array+ of them
+ #
+ def append_cppflags(flags, **opts)
Array(flags).each do |flag|
if checking_for("whether #{flag} is accepted as CPPFLAGS") {
- try_cppflags(flag, *opts)
+ try_cppflags(flag, **opts)
}
$CPPFLAGS << " " << flag
end
end
end
+ # Sets <tt>$CFLAGS</tt> to _flags_ and yields. If the block returns a falsy
+ # value, <tt>$CFLAGS</tt> is reset to its previous value, remains set to
+ # _flags_ otherwise.
def with_cflags(flags)
cflags = $CFLAGS
$CFLAGS = flags.dup
@@ -666,10 +737,14 @@ MSG
$CFLAGS = cflags unless ret
end
- def try_cflags(flags, opts = {})
- try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
+ # :nodoc:
+ def try_cflags(flags, werror: true, **opts)
+ try_compile(MAIN_DOES_NOTHING, flags, werror: werror, **opts)
end
+ # Sets <tt>$LDFLAGS</tt> to _flags_ and yields. If the block returns a
+ # falsy value, <tt>$LDFLAGS</tt> is reset to its previous value, remains set
+ # to _flags_ otherwise.
def with_ldflags(flags)
ldflags = $LDFLAGS
$LDFLAGS = flags.dup
@@ -678,21 +753,30 @@ MSG
$LDFLAGS = ldflags unless ret
end
- def try_ldflags(flags, opts = {})
- opts = {:werror => true}.update(opts) if $mswin
- try_link(MAIN_DOES_NOTHING, flags, opts)
+ # :nodoc:
+ def try_ldflags(flags, werror: $mswin, **opts)
+ try_link(MAIN_DOES_NOTHING, "", ldflags: flags, werror: werror, **opts)
end
- def append_ldflags(flags, *opts)
+ # :startdoc:
+
+ # Check whether each given linker flag is acceptable and append it to
+ # <tt>$LDFLAGS</tt> if so.
+ #
+ # [+flags+] a linker flag as a +String+ or an +Array+ of them
+ #
+ def append_ldflags(flags, **opts)
Array(flags).each do |flag|
if checking_for("whether #{flag} is accepted as LDFLAGS") {
- try_ldflags(flag, *opts)
+ try_ldflags(flag, **opts)
}
$LDFLAGS << " " << flag
end
end
end
+ # :stopdoc:
+
def try_static_assert(expr, headers = nil, opt = "", &b)
headers = cpp_include(headers)
try_compile(<<SRC, opt, &b)
@@ -781,7 +865,7 @@ int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const
v
}
unless strvars.empty?
- prepare << "char " << strvars.map {|v| "#{v}[1024]"}.join(", ") << "; "
+ prepare << "char " << strvars.map {|v| %[#{v}[1024] = ""]}.join(", ") << "; "
end
when nil
call = ""
@@ -828,6 +912,8 @@ int t(void) { const volatile void *volatile p; p = &(&#{var})[0]; return !p; }
SRC
end
+ # :startdoc:
+
# Returns whether or not the +src+ can be preprocessed with the C
# preprocessor and matches with +pat+.
#
@@ -845,20 +931,12 @@ SRC
xpopen(cpp_command('', opt)) do |f|
if Regexp === pat
puts(" ruby -ne 'print if #{pat.inspect}'")
- f.grep(pat) {|l|
+ !f.grep(pat) {|l|
puts "#{f.lineno}: #{l}"
- return true
- }
- false
+ }.empty?
else
puts(" egrep '#{pat}'")
- begin
- stdin = $stdin.dup
- $stdin.reopen(f)
- system("egrep", pat)
- ensure
- $stdin.reopen(stdin)
- end
+ system("egrep", pat, in: f)
end
end
ensure
@@ -866,6 +944,8 @@ SRC
log_src(src)
end
+ # :stopdoc:
+
# This is used internally by the have_macro? method.
def macro_defined?(macro, src, opt = "", &b)
src = src.sub(/[^\n]\z/, "\\&\n")
@@ -885,8 +965,8 @@ SRC
# * the linked file can be invoked as an executable
# * and the executable exits successfully
#
- # +opt+ is passed to the linker as options. Note that +$CFLAGS+ and
- # +$LDFLAGS+ are also passed to the linker.
+ # +opt+ is passed to the linker as options. Note that <tt>$CFLAGS</tt> and
+ # <tt>$LDFLAGS</tt> are also passed to the linker.
#
# If a block given, it is called with the source before compilation. You can
# modify the source in the block.
@@ -958,6 +1038,10 @@ SRC
format(LIBARG, lib) + " " + libs
end
+ # Prints messages to $stdout, if verbose mode.
+ #
+ # Internal use only.
+ #
def message(*s)
unless Logging.quiet and not $VERBOSE
printf(*s)
@@ -989,6 +1073,10 @@ SRC
r
end
+ # Build a message for checking.
+ #
+ # Internal use only.
+ #
def checking_message(target, place = nil, opt = nil)
[["in", place], ["with", opt]].inject("#{target}") do |msg, (pre, noun)|
if noun
@@ -1013,10 +1101,10 @@ SRC
#
# [+flags+] a C compiler flag as a +String+ or an +Array+ of them
#
- def append_cflags(flags, *opts)
+ def append_cflags(flags, **opts)
Array(flags).each do |flag|
if checking_for("whether #{flag} is accepted as CFLAGS") {
- try_cflags(flag, *opts)
+ try_cflags(flag, **opts)
}
$CFLAGS << " " << flag
end
@@ -1250,6 +1338,7 @@ SRC
end
end
+ # :nodoc:
# Returns whether or not the static type +type+ is defined.
#
# See also +have_type+
@@ -1307,6 +1396,7 @@ SRC
end
end
+ # :nodoc:
# Returns whether or not the constant +const+ is defined.
#
# See also +have_const+
@@ -1466,7 +1556,7 @@ SRC
u = "unsigned " if signed > 0
prelude << "extern rbcv_typedef_ foo();"
compat = UNIVERSAL_INTS.find {|t|
- try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b)
+ try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, werror: true, &b)
}
end
if compat
@@ -1490,7 +1580,7 @@ SRC
# 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
+ try_compile(<<"SRC", &b)
#{cpp_include(headers)}
/*top*/
volatile #{type} conftestval;
@@ -1503,7 +1593,7 @@ SRC
# 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
+ try_compile(<<"SRC", &b)
#{cpp_include(headers)}
/*top*/
volatile #{type} conftestval;
@@ -1525,6 +1615,10 @@ SRC
end
end
+ # :startdoc:
+
+ # Returns a string represents the type of _type_, or _member_ of
+ # _type_ if _member_ is not +nil+.
def what_type?(type, member = nil, headers = nil, &b)
m = "#{type}"
var = val = "*rbcv_var_"
@@ -1584,6 +1678,8 @@ SRC
end
end
+ # :nodoc:
+ #
# This method is used internally by the find_executable method.
#
# Internal use only.
@@ -1622,8 +1718,6 @@ SRC
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.
@@ -1792,7 +1886,8 @@ SRC
# application.
#
def dir_config(target, idefault=nil, ldefault=nil)
- if conf = $config_dirs[target]
+ key = [target, idefault, ldefault].compact.join("\0")
+ if conf = $config_dirs[key]
return conf
end
@@ -1802,9 +1897,13 @@ SRC
end
idir = with_config(target + "-include", idefault)
- $arg_config.last[1] ||= "${#{target}-dir}/include"
+ if conf = $arg_config.assoc("--with-#{target}-include")
+ conf[1] ||= "${#{target}-dir}/include"
+ end
ldir = with_config(target + "-lib", ldefault)
- $arg_config.last[1] ||= "${#{target}-dir}/#{_libdir_basename}"
+ if conf = $arg_config.assoc("--with-#{target}-lib")
+ conf[1] ||= "${#{target}-dir}/#{_libdir_basename}"
+ end
idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
if defaults
@@ -1826,7 +1925,7 @@ SRC
end
$LIBPATH = ldirs | $LIBPATH
- $config_dirs[target] = [idir, ldir]
+ $config_dirs[key] = [idir, ldir]
end
# Returns compile/link information about an installed library in a tuple of <code>[cflags,
@@ -1866,7 +1965,7 @@ SRC
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
# if and only if package specific config command is given
elsif ($PKGCONFIG ||=
- (pkgconfig = with_config("pkg-config") {config_string("PKG_CONFIG") || "pkg-config"}) &&
+ (pkgconfig = with_config("pkg-config") {config_string("PKG_CONFIG") || ENV["PKG_CONFIG"] || "pkg-config"}) &&
find_executable0(pkgconfig) && pkgconfig) and
xsystem([*envs, $PKGCONFIG, "--exists", pkg])
# default to pkg-config command
@@ -1882,7 +1981,20 @@ SRC
opts = Array(opts).map { |o| "--#{o}" }
opts = xpopen([*envs, pkgconfig, *opts, *args], err:[:child, :out], &:read)
Logging.open {puts opts.each_line.map{|s|"=> #{s.inspect}"}}
- opts.strip if $?.success?
+ if $?.success?
+ opts = opts.strip
+ libarg, libpath = LIBARG, LIBPATHFLAG.strip
+ opts = opts.shellsplit.map { |s|
+ if s.start_with?('-l')
+ libarg % s[2..]
+ elsif s.start_with?('-L')
+ libpath % s[2..]
+ else
+ s
+ end
+ }.quote.join(" ")
+ opts
+ end
}
end
orig_ldflags = $LDFLAGS
@@ -1965,14 +2077,14 @@ SRC
def configuration(srcdir)
mk = []
- CONFIG['MKMF_VERBOSE'] ||= "0"
+ verbose = with_config('verbose') ? "1" : (CONFIG['MKMF_VERBOSE'] || "0")
vpath = $VPATH.dup
CONFIG["hdrdir"] ||= $hdrdir
mk << %{
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
-V = #{CONFIG['MKMF_VERBOSE']}
+V = #{verbose}
V0 = $(V:0=)
Q1 = $(V:1=)
Q = $(Q1:0=@)
@@ -2064,7 +2176,9 @@ ARCH_FLAG = #{$ARCH_FLAG}
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
LDSHARED = #{CONFIG['LDSHARED']}
LDSHAREDXX = #{config_string('LDSHAREDXX') || '$(LDSHARED)'}
+POSTLINK = #{config_string('POSTLINK', RbConfig::CONFIG)}
AR = #{CONFIG['AR']}
+LD = #{CONFIG['LD']}
EXEEXT = #{CONFIG['EXEEXT']}
}
@@ -2264,6 +2378,19 @@ RULES
# directory, i.e. the current directory. It is included as part of the
# +VPATH+ and added to the list of +INCFLAGS+.
#
+ # Yields the configuration part of the makefile to be generated, as an array
+ # of strings, if the block is given. The returned value will be used the
+ # new configuration part.
+ #
+ # create_makefile('foo') {|conf|
+ # [
+ # *conf,
+ # "MACRO_YOU_NEED = something",
+ # ]
+ # }
+ #
+ # If "depend" file exist in the source directory, that content will be
+ # included in the generated makefile, with formatted by depend_rules method.
def create_makefile(target, srcprefix = nil)
$target = target
libpath = $DEFLIBPATH|$LIBPATH
@@ -2372,7 +2499,7 @@ TARGET_ENTRY = #{EXPORT_PREFIX || ''}Init_$(TARGET_NAME)
DLLIB = #{dllib}
EXTSTATIC = #{$static || ""}
STATIC_LIB = #{staticlib unless $static.nil?}
-#{!$extout && defined?($installed_list) ? "INSTALLED_LIST = #{$installed_list}\n" : ""}
+#{!$extout && defined?($installed_list) ? %[INSTALLED_LIST = #{$installed_list}\n] : ""}
TIMESTAMP_DIR = #{$extout && $extmk ? '$(extout)/.timestamp' : '.'}
" #"
# TODO: fixme
@@ -2380,16 +2507,19 @@ TIMESTAMP_DIR = #{$extout && $extmk ? '$(extout)/.timestamp' : '.'}
sodir = $extout ? '$(TARGET_SO_DIR)' : '$(RUBYARCHDIR)'
n = '$(TARGET_SO_DIR)$(TARGET)'
cleanobjs = ["$(OBJS)"]
+ cleanlibs = []
if $extmk
%w[bc i s].each {|ex| cleanobjs << "$(OBJS:.#{$OBJEXT}=.#{ex})"}
end
if target
config_string('cleanobjs') {|t| cleanobjs << t.gsub(/\$\*/, "$(TARGET)#{deffile ? '-$(arch)': ''}")}
+ cleanlibs << '$(TARGET_SO)'
end
+ config_string('cleanlibs') {|t| cleanlibs << t.gsub(/\$\*/) {n}}
conf << "\
TARGET_SO_DIR =#{$extout ? " $(RUBYARCHDIR)/" : ''}
TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
-CLEANLIBS = #{'$(TARGET_SO) ' if target}#{config_string('cleanlibs') {|t| t.gsub(/\$\*/) {n}}}
+CLEANLIBS = #{cleanlibs.join(' ')}
CLEANOBJS = #{cleanobjs.join(' ')} *.bak
TARGET_SO_DIR_TIMESTAMP = #{timestamp_file(sodir, target_prefix)}
" #"
@@ -2399,7 +2529,7 @@ TARGET_SO_DIR_TIMESTAMP = #{timestamp_file(sodir, target_prefix)}
mfile.puts(conf)
mfile.print "
all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"}
-static: #{$extmk && !$static ? "all" : "$(STATIC_LIB)#{$extout ? " install-rb" : ""}"}
+static: #{$extmk && !$static ? "all" : %[$(STATIC_LIB)#{$extout ? " install-rb" : ""}]}
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-static clean-rb
" #"
@@ -2430,6 +2560,7 @@ static: #{$extmk && !$static ? "all" : "$(STATIC_LIB)#{$extout ? " install-rb" :
mfile.puts dest
mfile.print "clean-so::\n"
mfile.print "\t-$(Q)$(RM) #{fseprepl[dest]} #{fseprepl[stamp]}\n"
+ mfile.print "\t-$(Q)$(RM_RF) #{fseprepl['$(CLEANLIBS)']}\n"
mfile.print "\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n"
else
mfile.print "#{f} #{stamp}\n"
@@ -2460,7 +2591,7 @@ static: #{$extmk && !$static ? "all" : "$(STATIC_LIB)#{$extout ? " install-rb" :
dest = "#{dir}/#{File.basename(f)}"
mfile.print("do-install-rb#{sfx}: #{dest}\n")
mfile.print("#{dest}: #{f} #{timestamp_file(dir, target_prefix)}\n")
- mfile.print("\t$(Q) $(#{$extout ? 'COPY' : 'INSTALL_DATA'}) #{f} $(@D)\n")
+ mfile.print("\t$(Q) $(#{$extout ? 'COPY' : 'INSTALL_DATA'}) #{f} $@\n")
if defined?($installed_list) and !$extout
mfile.print("\t@echo #{dest}>>$(INSTALLED_LIST)\n")
end
@@ -2699,7 +2830,7 @@ MESSAGE
when $mswin
$nmake = ?m if /nmake/i =~ make
end
- $ignore_error = $nmake ? '' : ' 2> /dev/null || true'
+ $ignore_error = " 2> #{File::NULL} || #{$mswin ? 'exit /b0' : 'true'}"
RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] =
$srcdir = arg_config("--srcdir", File.dirname($0))
@@ -2722,6 +2853,9 @@ MESSAGE
split = Shellwords.method(:shellwords).to_proc
+ ##
+ # The prefix added to exported symbols automatically
+
EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip}
hdr = ['#include "ruby.h"' "\n"]
@@ -2751,6 +2885,10 @@ MESSAGE
# make compile rules
COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
+
+ ##
+ # Substitution in rules for NMake
+
RULE_SUBST = config_string('RULE_SUBST')
##
@@ -2795,7 +2933,11 @@ MESSAGE
##
# Argument which will add a library path to the linker
- LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L%s'
+ LIBPATHFLAG = config_string('LIBPATHFLAG') || '-L%s'
+
+ ##
+ # Argument which will add a runtime library path to the linker
+
RPATHFLAG = config_string('RPATHFLAG') || ''
##
@@ -2807,6 +2949,10 @@ MESSAGE
# A C main function which does no work
MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || "int main(int argc, char **argv)\n{\n return !!argv[argc];\n}"
+
+ ##
+ # The type names for convertible_int
+
UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} ||
%w[int short long long\ long]
@@ -2837,18 +2983,32 @@ realclean: distclean
@lang = Hash.new(self)
+ ##
+ # Retrieves the module for _name_ language.
def self.[](name)
@lang.fetch(name)
end
+ ##
+ # Defines the module for _name_ language.
def self.[]=(name, mod)
@lang[name] = mod
end
- self["C++"] = Module.new do
+ ##
+ # The language that this module is for
+ LANGUAGE = -"C"
+
+ self[self::LANGUAGE] = self
+
+ cxx = Module.new do
+ # Module for C++
+
include MakeMakefile
extend self
+ # :stopdoc:
+
CONFTEST_CXX = "#{CONFTEST}.#{config_string('CXX_EXT') || CXX_EXT[0]}"
TRY_LINK_CXX = config_string('TRY_LINK_CXX') ||
@@ -2870,15 +3030,37 @@ realclean: distclean
def cc_command(opt="")
conf = cc_config(opt)
+ cxx_command(opt, conf)
RbConfig::expand("$(CXX) #$INCFLAGS #$CPPFLAGS #$CXXFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_CXX}",
conf)
end
+ def cpp_command(outfile, opt="")
+ conf = cpp_config(opt)
+ cxx = cxx_command(opt, conf)
+ cpp = conf['CPP'].sub(/(\A|\s)#{Regexp.quote(conf['CC'])}(?=\z|\s)/) {
+ "#$1#{cxx}"
+ }
+ RbConfig::expand("#{cpp} #$INCFLAGS #$CPPFLAGS #$CXXFLAGS #{opt} #{CONFTEST_CXX} #{outfile}",
+ conf)
+ end
+
def link_command(ldflags, *opts)
conf = link_config(ldflags, *opts)
RbConfig::expand(TRY_LINK_CXX.dup, conf)
end
+
+ def cxx_command(opt="", conf = cc_config(opt))
+ cxx = conf['CXX']
+ raise Errno::ENOENT, "C++ compiler not found" if !cxx or cxx == 'false'
+ cxx
+ end
+
+ # :startdoc:
end
+
+ cxx::LANGUAGE = -"C++"
+ self[cxx::LANGUAGE] = cxx
end
# MakeMakefile::Global = #
diff --git a/lib/monitor.rb b/lib/monitor.rb
new file mode 100644
index 0000000000..21329a5de7
--- /dev/null
+++ b/lib/monitor.rb
@@ -0,0 +1,216 @@
+# frozen_string_literal: false
+# = monitor.rb
+#
+# Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
+#
+# This library is distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+#
+# In concurrent programming, a monitor is an object or module intended to be
+# used safely by more than one thread. The defining characteristic of a
+# monitor is that its methods are executed with mutual exclusion. That is, at
+# each point in time, at most one thread may be executing any of its methods.
+# This mutual exclusion greatly simplifies reasoning about the implementation
+# of monitors compared to reasoning about parallel code that updates a data
+# structure.
+#
+# You can read more about the general principles on the Wikipedia page for
+# Monitors[https://en.wikipedia.org/wiki/Monitor_%28synchronization%29].
+#
+# == Examples
+#
+# === Simple object.extend
+#
+# require 'monitor.rb'
+#
+# buf = []
+# buf.extend(MonitorMixin)
+# empty_cond = buf.new_cond
+#
+# # consumer
+# Thread.start do
+# loop do
+# buf.synchronize do
+# empty_cond.wait_while { buf.empty? }
+# print buf.shift
+# end
+# end
+# end
+#
+# # producer
+# while line = ARGF.gets
+# buf.synchronize do
+# buf.push(line)
+# empty_cond.signal
+# end
+# end
+#
+# The consumer thread waits for the producer thread to push a line to buf
+# while <tt>buf.empty?</tt>. The producer thread (main thread) reads a
+# line from ARGF and pushes it into buf then calls <tt>empty_cond.signal</tt>
+# to notify the consumer thread of new data.
+#
+# === Simple Class include
+#
+# require 'monitor'
+#
+# class SynchronizedArray < Array
+#
+# include MonitorMixin
+#
+# def initialize(*args)
+# super(*args)
+# end
+#
+# alias :old_shift :shift
+# alias :old_unshift :unshift
+#
+# def shift(n=1)
+# self.synchronize do
+# self.old_shift(n)
+# end
+# end
+#
+# def unshift(item)
+# self.synchronize do
+# self.old_unshift(item)
+# end
+# end
+#
+# # other methods ...
+# end
+#
+# +SynchronizedArray+ implements an Array with synchronized access to items.
+# This Class is implemented as subclass of Array which includes the
+# MonitorMixin module.
+#
+module MonitorMixin
+ ConditionVariable = Monitor::ConditionVariable # :nodoc:
+
+ #
+ # FIXME: This isn't documented in Nutshell.
+ #
+ # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
+ # above calls while_wait and signal, this class should be documented.
+ #
+
+ def self.extend_object(obj) # :nodoc:
+ super(obj)
+ obj.__send__(:mon_initialize)
+ end
+
+ #
+ # Attempts to enter exclusive section. Returns +false+ if lock fails.
+ #
+ def mon_try_enter
+ @mon_data.try_enter
+ end
+ # For backward compatibility
+ alias try_mon_enter mon_try_enter
+
+ #
+ # Enters exclusive section.
+ #
+ def mon_enter
+ @mon_data.enter
+ end
+
+ #
+ # Leaves exclusive section.
+ #
+ def mon_exit
+ mon_check_owner
+ @mon_data.exit
+ end
+
+ #
+ # Returns true if this monitor is locked by any thread
+ #
+ def mon_locked?
+ @mon_data.mon_locked?
+ end
+
+ #
+ # Returns true if this monitor is locked by current thread.
+ #
+ def mon_owned?
+ @mon_data.mon_owned?
+ end
+
+ #
+ # Enters exclusive section and executes the block. Leaves the exclusive
+ # section automatically when the block exits. See example under
+ # +MonitorMixin+.
+ #
+ def mon_synchronize(&b)
+ @mon_data.synchronize(&b)
+ end
+ alias synchronize mon_synchronize
+
+ #
+ # Creates a new MonitorMixin::ConditionVariable associated with the
+ # Monitor object.
+ #
+ def new_cond
+ unless defined?(@mon_data)
+ mon_initialize
+ @mon_initialized_by_new_cond = true
+ end
+ return ConditionVariable.new(@mon_data)
+ end
+
+ private
+
+ # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead
+ # of this constructor. Have look at the examples above to understand how to
+ # use this module.
+ def initialize(...)
+ super
+ mon_initialize
+ end
+
+ # Initializes the MonitorMixin after being included in a class or when an
+ # object has been extended with the MonitorMixin
+ def mon_initialize
+ if defined?(@mon_data)
+ if defined?(@mon_initialized_by_new_cond)
+ return # already initialized.
+ elsif @mon_data_owner_object_id == self.object_id
+ raise ThreadError, "already initialized"
+ end
+ end
+ @mon_data = ::Monitor.new
+ @mon_data_owner_object_id = self.object_id
+ end
+
+ # Ensures that the MonitorMixin is owned by the current thread,
+ # otherwise raises an exception.
+ def mon_check_owner
+ @mon_data.mon_check_owner
+ end
+end
+
+class Monitor # :nodoc:
+ alias try_mon_enter try_enter
+ alias mon_try_enter try_enter
+ alias mon_enter enter
+ alias mon_exit exit
+ alias mon_synchronize synchronize
+end
+
+# Documentation comments:
+# - All documentation comes from Nutshell.
+# - MonitorMixin.new_cond appears in the example, but is not documented in
+# Nutshell.
+# - All the internals (internal modules Accessible and Initializable, class
+# ConditionVariable) appear in RDoc. It might be good to hide them, by
+# making them private, or marking them :nodoc:, etc.
+# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
+# not synchronize.
+# - mon_owner is in Nutshell, but appears as an accessor in a separate module
+# here, so is hard/impossible to RDoc. Some other useful accessors
+# (mon_count and some queue stuff) are also in this module, and don't appear
+# directly in the RDoc output.
+# - in short, it may be worth changing the code layout in this file to make the
+# documentation easier
diff --git a/lib/mutex_m.gemspec b/lib/mutex_m.gemspec
deleted file mode 100644
index ebbda2606c..0000000000
--- a/lib/mutex_m.gemspec
+++ /dev/null
@@ -1,28 +0,0 @@
-begin
- require_relative "lib/mutex_m"
-rescue LoadError
- # for Ruby core repository
- require_relative "mutex_m"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "mutex_m"
- spec.version = Mutex_m::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Mixin to extend objects to be handled like a Mutex.}
- spec.description = %q{Mixin to extend objects to be handled like a Mutex.}
- spec.homepage = "https://github.com/ruby/mutex_m"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.files = ["Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/mutex_m.rb", "mutex_m.gemspec"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
- spec.required_ruby_version = '>= 2.5'
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "test-unit"
-end
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
deleted file mode 100644
index 4c888d6a17..0000000000
--- a/lib/mutex_m.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-# frozen_string_literal: false
-#
-# mutex_m.rb -
-# $Release Version: 3.0$
-# $Revision: 1.7 $
-# Original from mutex.rb
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-# modified by matz
-# patched by akira yamada
-#
-# --
-
-# = mutex_m.rb
-#
-# When 'mutex_m' is required, any object that extends or includes Mutex_m will
-# be treated like a Mutex.
-#
-# Start by requiring the standard library Mutex_m:
-#
-# require "mutex_m.rb"
-#
-# From here you can extend an object with Mutex instance methods:
-#
-# obj = Object.new
-# obj.extend Mutex_m
-#
-# Or mixin Mutex_m into your module to your class inherit Mutex instance
-# methods --- remember to call super() in your class initialize method.
-#
-# class Foo
-# include Mutex_m
-# def initialize
-# # ...
-# super()
-# end
-# # ...
-# end
-# obj = Foo.new
-# # this obj can be handled like Mutex
-#
-module Mutex_m
-
- VERSION = "0.1.2"
- Ractor.make_shareable(VERSION) if defined?(Ractor)
-
- def Mutex_m.define_aliases(cl) # :nodoc:
- cl.alias_method(:locked?, :mu_locked?)
- cl.alias_method(:lock, :mu_lock)
- cl.alias_method(:unlock, :mu_unlock)
- cl.alias_method(:try_lock, :mu_try_lock)
- cl.alias_method(:synchronize, :mu_synchronize)
- end
-
- def Mutex_m.append_features(cl) # :nodoc:
- super
- define_aliases(cl) unless cl.instance_of?(Module)
- end
-
- def Mutex_m.extend_object(obj) # :nodoc:
- super
- obj.mu_extended
- end
-
- def mu_extended # :nodoc:
- unless (defined? locked? and
- defined? lock and
- defined? unlock and
- defined? try_lock and
- defined? synchronize)
- Mutex_m.define_aliases(singleton_class)
- end
- mu_initialize
- end
-
- # See Thread::Mutex#synchronize
- def mu_synchronize(&block)
- @_mutex.synchronize(&block)
- end
-
- # See Thread::Mutex#locked?
- def mu_locked?
- @_mutex.locked?
- end
-
- # See Thread::Mutex#try_lock
- def mu_try_lock
- @_mutex.try_lock
- end
-
- # See Thread::Mutex#lock
- def mu_lock
- @_mutex.lock
- end
-
- # See Thread::Mutex#unlock
- def mu_unlock
- @_mutex.unlock
- end
-
- # See Thread::Mutex#sleep
- def sleep(timeout = nil)
- @_mutex.sleep(timeout)
- end
-
- private
-
- def mu_initialize # :nodoc:
- @_mutex = Thread::Mutex.new
- end
-
- def initialize(*args) # :nodoc:
- mu_initialize
- super
- end
- ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
-end
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 89277ca49d..53295fe90c 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# = net/http.rb
#
@@ -37,7 +37,7 @@ module Net #:nodoc:
# For information about \HTTP, see:
#
# - {Hypertext Transfer Protocol}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol].
- # - {Technical overview}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Technical_overview].
+ # - {Technology}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Technology].
#
# == About the Examples
#
@@ -67,10 +67,12 @@ module Net #:nodoc:
# Net::HTTP.post(uri, data)
# params = {title: 'foo', body: 'bar', userId: 1}
# Net::HTTP.post_form(uri, params)
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # Net::HTTP.put(uri, data)
#
# - If performance is important, consider using sessions, which lower request overhead.
# This {session}[rdoc-ref:Net::HTTP@Sessions] has multiple requests for
- # {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]
+ # {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Method]
# and {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]:
#
# Net::HTTP.start(hostname) do |http|
@@ -196,7 +198,7 @@ module Net #:nodoc:
# In the block, you can use these instance methods,
# each of which that sends a single request:
#
- # - {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]:
+ # - {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Method]:
#
# - #get, #request_get: GET.
# - #head, #request_head: HEAD.
@@ -445,7 +447,7 @@ module Net #:nodoc:
# if the response has header <tt>'Content-Range'</tt>.
#
# Otherwise decompression (or not) depends on the value of header
- # {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]:
+ # {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Content-Encoding_2]:
#
# - <tt>'deflate'</tt>, <tt>'gzip'</tt>, or <tt>'x-gzip'</tt>:
# decompresses the body and deletes the header.
@@ -456,6 +458,10 @@ module Net #:nodoc:
#
# == What's Here
#
+ # First, what's elsewhere. Class Net::HTTP:
+ #
+ # - Inherits from {class Object}[rdoc-ref:Object#class-object-whats-here].
+ #
# This is a categorized summary of methods and attributes.
#
# === \Net::HTTP Objects
@@ -469,8 +475,7 @@ module Net #:nodoc:
#
# - {::start}[rdoc-ref:Net::HTTP.start]:
# Begins a new session in a new \Net::HTTP object.
- # - {#started?}[rdoc-ref:Net::HTTP#started?]
- # (aliased as {#active?}[rdoc-ref:Net::HTTP#active?]):
+ # - {#started?}[rdoc-ref:Net::HTTP#started?]:
# Returns whether in a session.
# - {#finish}[rdoc-ref:Net::HTTP#finish]:
# Ends an active session.
@@ -520,6 +525,8 @@ module Net #:nodoc:
# Sends a POST request with form data and returns a response object.
# - {::post}[rdoc-ref:Net::HTTP.post]:
# Sends a POST request with data and returns a response object.
+ # - {::put}[rdoc-ref:Net::HTTP.put]:
+ # Sends a PUT request with data and returns a response object.
# - {#copy}[rdoc-ref:Net::HTTP#copy]:
# Sends a COPY request and returns a response object.
# - {#delete}[rdoc-ref:Net::HTTP#delete]:
@@ -548,18 +555,15 @@ module Net #:nodoc:
# Sends a PUT request and returns a response object.
# - {#request}[rdoc-ref:Net::HTTP#request]:
# Sends a request and returns a response object.
- # - {#request_get}[rdoc-ref:Net::HTTP#request_get]
- # (aliased as {#get2}[rdoc-ref:Net::HTTP#get2]):
+ # - {#request_get}[rdoc-ref:Net::HTTP#request_get]:
# Sends a GET request and forms a response object;
# if a block given, calls the block with the object,
# otherwise returns the object.
- # - {#request_head}[rdoc-ref:Net::HTTP#request_head]
- # (aliased as {#head2}[rdoc-ref:Net::HTTP#head2]):
+ # - {#request_head}[rdoc-ref:Net::HTTP#request_head]:
# Sends a HEAD request and forms a response object;
# if a block given, calls the block with the object,
# otherwise returns the object.
- # - {#request_post}[rdoc-ref:Net::HTTP#request_post]
- # (aliased as {#post2}[rdoc-ref:Net::HTTP#post2]):
+ # - {#request_post}[rdoc-ref:Net::HTTP#request_post]:
# Sends a POST request and forms a response object;
# if a block given, calls the block with the object,
# otherwise returns the object.
@@ -597,8 +601,7 @@ module Net #:nodoc:
# Returns whether +self+ is a proxy class.
# - {#proxy?}[rdoc-ref:Net::HTTP#proxy?]:
# Returns whether +self+ has a proxy.
- # - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]
- # (aliased as {#proxyaddr}[rdoc-ref:Net::HTTP#proxyaddr]):
+ # - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]:
# Returns the proxy address.
# - {#proxy_from_env?}[rdoc-ref:Net::HTTP#proxy_from_env?]:
# Returns whether the proxy is taken from an environment variable.
@@ -710,8 +713,7 @@ module Net #:nodoc:
# === \HTTP Version
#
# - {::version_1_2?}[rdoc-ref:Net::HTTP.version_1_2?]
- # (aliased as {::is_version_1_2?}[rdoc-ref:Net::HTTP.is_version_1_2?]
- # and {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
+ # (aliased as {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
# Returns true; retained for compatibility.
#
# === Debugging
@@ -722,8 +724,7 @@ module Net #:nodoc:
class HTTP < Protocol
# :stopdoc:
- VERSION = "0.3.2"
- Revision = %q$Revision$.split[1]
+ VERSION = "0.9.1"
HTTPVersion = '1.1'
begin
require 'zlib'
@@ -890,6 +891,39 @@ module Net #:nodoc:
}
end
+ # Sends a PUT request to the server; returns a Net::HTTPResponse object.
+ #
+ # Argument +url+ must be a URL;
+ # argument +data+ must be a string:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # headers = {'content-type': 'application/json'}
+ # res = Net::HTTP.put(_uri, data, headers) # => #<Net::HTTPCreated 201 Created readbody=true>
+ # puts res.body
+ #
+ # Output:
+ #
+ # {
+ # "title": "foo",
+ # "body": "bar",
+ # "userId": 1,
+ # "id": 101
+ # }
+ #
+ # Related:
+ #
+ # - Net::HTTP::Put: request class for \HTTP method +PUT+.
+ # - Net::HTTP#put: convenience method for \HTTP method +PUT+.
+ #
+ def HTTP.put(url, data, header = nil)
+ start(url.hostname, url.port,
+ :use_ssl => url.scheme == 'https' ) {|http|
+ http.put(url, data, header)
+ }
+ end
+
#
# \HTTP session management
#
@@ -1063,7 +1097,7 @@ module Net #:nodoc:
# For proxy-defining arguments +p_addr+ through +p_no_proxy+,
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
#
- def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
+ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil, p_use_ssl = nil)
http = super address, port
if proxy_class? then # from Net::HTTP::Proxy()
@@ -1072,10 +1106,11 @@ module Net #:nodoc:
http.proxy_port = @proxy_port
http.proxy_user = @proxy_user
http.proxy_pass = @proxy_pass
+ http.proxy_use_ssl = @proxy_use_ssl
elsif p_addr == :ENV then
http.proxy_from_env = true
else
- if p_addr && p_no_proxy && !URI::Generic.use_proxy?(p_addr, p_addr, p_port, p_no_proxy)
+ if p_addr && p_no_proxy && !URI::Generic.use_proxy?(address, address, port, p_no_proxy)
p_addr = nil
p_port = nil
end
@@ -1083,34 +1118,68 @@ module Net #:nodoc:
http.proxy_port = p_port || default_port
http.proxy_user = p_user
http.proxy_pass = p_pass
+ http.proxy_use_ssl = p_use_ssl
end
http
end
+ class << HTTP
+ # Allows to set the default configuration that will be used
+ # when creating a new connection.
+ #
+ # Example:
+ #
+ # Net::HTTP.default_configuration = {
+ # read_timeout: 1,
+ # write_timeout: 1
+ # }
+ # http = Net::HTTP.new(hostname)
+ # http.open_timeout # => 60
+ # http.read_timeout # => 1
+ # http.write_timeout # => 1
+ #
+ attr_accessor :default_configuration
+ end
+
# Creates a new \Net::HTTP object for the specified server address,
# without opening the TCP connection or initializing the \HTTP session.
# The +address+ should be a DNS hostname or IP address.
def initialize(address, port = nil) # :nodoc:
+ defaults = {
+ keep_alive_timeout: 2,
+ close_on_empty_response: false,
+ open_timeout: 60,
+ read_timeout: 60,
+ write_timeout: 60,
+ continue_timeout: nil,
+ max_retries: 1,
+ debug_output: nil,
+ response_body_encoding: false,
+ ignore_eof: true
+ }
+ options = defaults.merge(self.class.default_configuration || {})
+
@address = address
@port = (port || HTTP.default_port)
@ipaddr = nil
@local_host = nil
@local_port = nil
@curr_http_version = HTTPVersion
- @keep_alive_timeout = 2
+ @keep_alive_timeout = options[:keep_alive_timeout]
@last_communicated = nil
- @close_on_empty_response = false
+ @close_on_empty_response = options[:close_on_empty_response]
@socket = nil
@started = false
- @open_timeout = 60
- @read_timeout = 60
- @write_timeout = 60
- @continue_timeout = nil
- @max_retries = 1
- @debug_output = nil
- @response_body_encoding = false
- @ignore_eof = true
+ @open_timeout = options[:open_timeout]
+ @read_timeout = options[:read_timeout]
+ @write_timeout = options[:write_timeout]
+ @continue_timeout = options[:continue_timeout]
+ @max_retries = options[:max_retries]
+ @debug_output = options[:debug_output]
+ @response_body_encoding = options[:response_body_encoding]
+ @ignore_eof = options[:ignore_eof]
+ @tcpsocket_supports_open_timeout = nil
@proxy_from_env = false
@proxy_uri = nil
@@ -1118,6 +1187,7 @@ module Net #:nodoc:
@proxy_port = nil
@proxy_user = nil
@proxy_pass = nil
+ @proxy_use_ssl = nil
@use_ssl = false
@ssl_context = nil
@@ -1234,7 +1304,7 @@ module Net #:nodoc:
# Sets whether to determine the proxy from environment variable
# '<tt>ENV['http_proxy']</tt>';
- # see {Proxy Using ENV['http_proxy']}[rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D-27].
+ # see {Proxy Using ENV['http_proxy']}[rdoc-ref:Net::HTTP@Proxy+Using+ENVHTTPProxy].
attr_writer :proxy_from_env
# Sets the proxy address;
@@ -1253,6 +1323,10 @@ module Net #:nodoc:
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
attr_writer :proxy_pass
+ # Sets whether the proxy uses SSL;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
+ attr_writer :proxy_use_ssl
+
# Returns the IP address for the connection.
#
# If the session has not been started,
@@ -1441,23 +1515,6 @@ module Net #:nodoc:
@use_ssl = flag
end
- SSL_IVNAMES = [
- :@ca_file,
- :@ca_path,
- :@cert,
- :@cert_store,
- :@ciphers,
- :@extra_chain_cert,
- :@key,
- :@ssl_timeout,
- :@ssl_version,
- :@min_version,
- :@max_version,
- :@verify_callback,
- :@verify_depth,
- :@verify_mode,
- :@verify_hostname,
- ] # :nodoc:
SSL_ATTRIBUTES = [
:ca_file,
:ca_path,
@@ -1474,7 +1531,9 @@ module Net #:nodoc:
:verify_depth,
:verify_mode,
:verify_hostname,
- ] # :nodoc:
+ ].freeze # :nodoc:
+
+ SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:
# Sets or returns the path to a CA certification file in PEM format.
attr_accessor :ca_file
@@ -1491,11 +1550,11 @@ module Net #:nodoc:
attr_accessor :cert_store
# Sets or returns the available SSL ciphers.
- # See {OpenSSL::SSL::SSLContext#ciphers=}[rdoc-ref:OpenSSL::SSL::SSLContext#ciphers-3D].
+ # See {OpenSSL::SSL::SSLContext#ciphers=}[OpenSSL::SSL::SSL::Context#ciphers=].
attr_accessor :ciphers
# Sets or returns the extra X509 certificates to be added to the certificate chain.
- # See {OpenSSL::SSL::SSLContext#add_certificate}[rdoc-ref:OpenSSL::SSL::SSLContext#add_certificate].
+ # See {OpenSSL::SSL::SSLContext#add_certificate}[OpenSSL::SSL::SSL::Context#add_certificate].
attr_accessor :extra_chain_cert
# Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
@@ -1505,15 +1564,15 @@ module Net #:nodoc:
attr_accessor :ssl_timeout
# Sets or returns the SSL version.
- # See {OpenSSL::SSL::SSLContext#ssl_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#ssl_version-3D].
+ # See {OpenSSL::SSL::SSLContext#ssl_version=}[OpenSSL::SSL::SSL::Context#ssl_version=].
attr_accessor :ssl_version
# Sets or returns the minimum SSL version.
- # See {OpenSSL::SSL::SSLContext#min_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#min_version-3D].
+ # See {OpenSSL::SSL::SSLContext#min_version=}[OpenSSL::SSL::SSL::Context#min_version=].
attr_accessor :min_version
# Sets or returns the maximum SSL version.
- # See {OpenSSL::SSL::SSLContext#max_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#max_version-3D].
+ # See {OpenSSL::SSL::SSLContext#max_version=}[OpenSSL::SSL::SSL::Context#max_version=].
attr_accessor :max_version
# Sets or returns the callback for the server certification verification.
@@ -1529,7 +1588,7 @@ module Net #:nodoc:
# Sets or returns whether to verify that the server certificate is valid
# for the hostname.
- # See {OpenSSL::SSL::SSLContext#verify_hostname=}[rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_mode].
+ # See {OpenSSL::SSL::SSLContext#verify_hostname=}[OpenSSL::SSL::SSL::Context#verify_hostname=].
attr_accessor :verify_hostname
# Returns the X509 certificate chain (an array of strings)
@@ -1577,6 +1636,21 @@ module Net #:nodoc:
self
end
+ # Finishes the \HTTP session:
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.start
+ # http.started? # => true
+ # http.finish # => nil
+ # http.started? # => false
+ #
+ # Raises IOError if not in a session.
+ def finish
+ raise IOError, 'HTTP session not yet started' unless started?
+ do_finish
+ end
+
+ # :stopdoc:
def do_start
connect
@started = true
@@ -1599,31 +1673,38 @@ module Net #:nodoc:
end
debug "opening connection to #{conn_addr}:#{conn_port}..."
- s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
- begin
- TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
- rescue => e
- raise e, "Failed to open TCP connection to " +
- "#{conn_addr}:#{conn_port} (#{e.message})"
+ begin
+ s = timeouted_connect(conn_addr, conn_port)
+ rescue => e
+ if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
+ e = Net::OpenTimeout.new(e)
end
- }
+ raise e, "Failed to open TCP connection to " +
+ "#{conn_addr}:#{conn_port} (#{e.message})"
+ end
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
debug "opened"
if use_ssl?
if proxy?
- plain_sock = BufferedIO.new(s, read_timeout: @read_timeout,
+ if @proxy_use_ssl
+ proxy_sock = OpenSSL::SSL::SSLSocket.new(s)
+ ssl_socket_connect(proxy_sock, @open_timeout)
+ else
+ proxy_sock = s
+ end
+ proxy_sock = BufferedIO.new(proxy_sock, read_timeout: @read_timeout,
write_timeout: @write_timeout,
continue_timeout: @continue_timeout,
debug_output: @debug_output)
- buf = "CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n"
- buf << "Host: #{@address}:#{@port}\r\n"
+ buf = +"CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n" \
+ "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
buf << "Proxy-Authorization: Basic #{credential}\r\n"
end
buf << "\r\n"
- plain_sock.write(buf)
- HTTPResponse.read_new(plain_sock).value
+ proxy_sock.write(buf)
+ HTTPResponse.read_new(proxy_sock).value
# assuming nothing left in buffers after successful CONNECT response
end
@@ -1693,23 +1774,30 @@ module Net #:nodoc:
end
private :connect
- def on_connect
+ tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
+ TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
+ tcp_socket_parameters.include?([:key, :open_timeout])
+ else
+ # Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
+ # See discussion in https://github.com/ruby/net-http/pull/224
+ Socket.method(:tcp).parameters.include?([:key, :open_timeout])
end
- private :on_connect
+ private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
- # Finishes the \HTTP session:
- #
- # http = Net::HTTP.new(hostname)
- # http.start
- # http.started? # => true
- # http.finish # => nil
- # http.started? # => false
- #
- # Raises IOError if not in a session.
- def finish
- raise IOError, 'HTTP session not yet started' unless started?
- do_finish
+ def timeouted_connect(conn_addr, conn_port)
+ if TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
+ TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
+ else
+ Timeout.timeout(@open_timeout, Net::OpenTimeout) {
+ TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
+ }
+ end
+ end
+ private :timeouted_connect
+
+ def on_connect
end
+ private :on_connect
def do_finish
@started = false
@@ -1731,13 +1819,14 @@ module Net #:nodoc:
@proxy_port = nil
@proxy_user = nil
@proxy_pass = nil
+ @proxy_use_ssl = nil
# Creates an \HTTP proxy class which behaves like \Net::HTTP, but
# performs all access via the specified proxy.
#
# This class is obsolete. You may pass these same parameters directly to
# \Net::HTTP.new. See Net::HTTP.new for details of the arguments.
- def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil) #:nodoc:
+ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ssl = nil) #:nodoc:
return self unless p_addr
Class.new(self) {
@@ -1755,9 +1844,12 @@ module Net #:nodoc:
@proxy_user = p_user
@proxy_pass = p_pass
+ @proxy_use_ssl = p_use_ssl
}
end
+ # :startdoc:
+
class << HTTP
# Returns true if self is a class which was created by HTTP::Proxy.
def proxy_class?
@@ -1779,6 +1871,9 @@ module Net #:nodoc:
# Returns the password for accessing the proxy, or +nil+ if none;
# see Net::HTTP@Proxy+Server.
attr_reader :proxy_pass
+
+ # Use SSL when talking to the proxy. If Net::HTTP does not use a proxy, nil.
+ attr_reader :proxy_use_ssl
end
# Returns +true+ if a proxy server is defined, +false+ otherwise;
@@ -1798,7 +1893,7 @@ module Net #:nodoc:
def proxy_uri # :nodoc:
return if @proxy_uri == false
@proxy_uri ||= URI::HTTP.new(
- "http".freeze, nil, address, port, nil, nil, nil, nil, nil
+ "http", nil, address, port, nil, nil, nil, nil, nil
).find_proxy || false
@proxy_uri || nil
end
@@ -1849,9 +1944,11 @@ module Net #:nodoc:
alias proxyport proxy_port #:nodoc: obsolete
private
+ # :stopdoc:
def unescape(value)
- require 'cgi/util'
+ require 'cgi/escape'
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
CGI.unescape(value)
end
@@ -1876,6 +1973,7 @@ module Net #:nodoc:
path
end
end
+ # :startdoc:
#
# HTTP operations
@@ -2013,6 +2111,11 @@ module Net #:nodoc:
# http = Net::HTTP.new(hostname)
# http.put('/todos/1', data) # => #<Net::HTTPOK 200 OK readbody=true>
#
+ # Related:
+ #
+ # - Net::HTTP::Put: request class for \HTTP method PUT.
+ # - Net::HTTP.put: sends PUT request, returns response body.
+ #
def put(path, data, initheader = nil)
request(Put.new(path, initheader), data)
end
@@ -2325,7 +2428,9 @@ module Net #:nodoc:
res
end
- IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc:
+ # :stopdoc:
+
+ IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/.freeze # :nodoc:
def transport_request(req)
count = 0
@@ -2351,7 +2456,10 @@ module Net #:nodoc:
res
}
res.reading_body(@socket, req.response_body_permitted?) {
- yield res if block_given?
+ if block_given?
+ count = max_retries # Don't restart in the middle of a download
+ yield res
+ end
}
rescue Net::OpenTimeout
raise
@@ -2479,6 +2587,11 @@ module Net #:nodoc:
alias_method :D, :debug
end
+ # for backward compatibility until Ruby 4.0
+ # https://bugs.ruby-lang.org/issues/20900
+ # https://github.com/bblimke/webmock/pull/1081
+ HTTPSession = HTTP
+ deprecate_constant :HTTPSession
end
require_relative 'http/exceptions'
@@ -2493,5 +2606,3 @@ require_relative 'http/response'
require_relative 'http/responses'
require_relative 'http/proxy_delta'
-
-require_relative 'http/backward'
diff --git a/lib/net/http/backward.rb b/lib/net/http/backward.rb
deleted file mode 100644
index 691e41e4f1..0000000000
--- a/lib/net/http/backward.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: false
-# for backward compatibility
-
-# :enddoc:
-
-class Net::HTTP
- ProxyMod = ProxyDelta
- deprecate_constant :ProxyMod
-end
-
-module Net::NetPrivate
- HTTPRequest = ::Net::HTTPRequest
- deprecate_constant :HTTPRequest
-end
-
-module Net
- HTTPSession = HTTP
-
- HTTPInformationCode = HTTPInformation
- HTTPSuccessCode = HTTPSuccess
- HTTPRedirectionCode = HTTPRedirection
- HTTPRetriableCode = HTTPRedirection
- HTTPClientErrorCode = HTTPClientError
- HTTPFatalErrorCode = HTTPClientError
- HTTPServerErrorCode = HTTPServerError
- HTTPResponseReceiver = HTTPResponse
-
- HTTPResponceReceiver = HTTPResponse # Typo since 2001
-
- deprecate_constant :HTTPSession,
- :HTTPInformationCode,
- :HTTPSuccessCode,
- :HTTPRedirectionCode,
- :HTTPRetriableCode,
- :HTTPClientErrorCode,
- :HTTPFatalErrorCode,
- :HTTPServerErrorCode,
- :HTTPResponseReceiver,
- :HTTPResponceReceiver
-end
diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb
index 9c425cae16..4342cfc0ef 100644
--- a/lib/net/http/exceptions.rb
+++ b/lib/net/http/exceptions.rb
@@ -1,9 +1,9 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Net
# Net::HTTP exception class.
# You cannot use Net::HTTPExceptions directly; instead, you must use
# its subclasses.
- module HTTPExceptions
+ module HTTPExceptions # :nodoc:
def initialize(msg, res) #:nodoc:
super msg
@response = res
@@ -12,6 +12,7 @@ module Net
alias data response #:nodoc: obsolete
end
+ # :stopdoc:
class HTTPError < ProtocolError
include HTTPExceptions
end
diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb
index 8877cd04ae..5b01ea4abd 100644
--- a/lib/net/http/generic_request.rb
+++ b/lib/net/http/generic_request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# \HTTPGenericRequest is the parent of the Net::HTTPRequest class.
#
@@ -19,16 +19,13 @@ class Net::HTTPGenericRequest
if URI === uri_or_path then
raise ArgumentError, "not an HTTP URI" unless URI::HTTP === uri_or_path
- hostname = uri_or_path.hostname
+ hostname = uri_or_path.host
raise ArgumentError, "no host component for URI" unless (hostname && hostname.length > 0)
@uri = uri_or_path.dup
- host = @uri.hostname.dup
- host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
@path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless @path
else
@uri = nil
- host = nil
raise ArgumentError, "no HTTP request path given" unless uri_or_path
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
@path = uri_or_path.dup
@@ -51,7 +48,7 @@ class Net::HTTPGenericRequest
initialize_http_header initheader
self['Accept'] ||= '*/*'
self['User-Agent'] ||= 'Ruby'
- self['Host'] ||= host if host
+ self['Host'] ||= @uri.authority if @uri
@body = nil
@body_stream = nil
@body_data = nil
@@ -102,6 +99,31 @@ class Net::HTTPGenericRequest
"\#<#{self.class} #{@method}>"
end
+ # Returns a string representation of the request with the details for pp:
+ #
+ # require 'pp'
+ # post = Net::HTTP::Post.new(uri)
+ # post.inspect # => "#<Net::HTTP::Post POST>"
+ # post.pretty_inspect
+ # # => #<Net::HTTP::Post
+ # POST
+ # path="/"
+ # headers={"accept-encoding" => ["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
+ # "accept" => ["*/*"],
+ # "user-agent" => ["Ruby"],
+ # "host" => ["www.ruby-lang.org"]}>
+ #
+ def pretty_print(q)
+ q.object_group(self) {
+ q.breakable
+ q.text @method
+ q.breakable
+ q.text "path="; q.pp @path
+ q.breakable
+ q.text "headers="; q.pp to_hash
+ }
+ end
+
##
# Don't automatically decode response content-encoding if the user indicates
# they want to handle it.
@@ -212,15 +234,15 @@ class Net::HTTPGenericRequest
return unless @uri
if ssl
- scheme = 'https'.freeze
+ scheme = 'https'
klass = URI::HTTPS
else
- scheme = 'http'.freeze
+ scheme = 'http'
klass = URI::HTTP
end
if host = self['host']
- host.sub!(/:.*/m, ''.freeze)
+ host = URI.parse("//#{host}").host # Remove a port component from the existing Host header
elsif host = @uri.host
else
host = addr
@@ -239,6 +261,8 @@ class Net::HTTPGenericRequest
private
+ # :stopdoc:
+
class Chunker #:nodoc:
def initialize(sock)
@sock = sock
@@ -260,7 +284,6 @@ class Net::HTTPGenericRequest
def send_request_with_body(sock, ver, path, body)
self.content_length = body.bytesize
delete 'Transfer-Encoding'
- supply_default_content_type
write_header sock, ver, path
wait_for_continue sock, ver if sock.continue_timeout
sock.write body
@@ -271,7 +294,6 @@ class Net::HTTPGenericRequest
raise ArgumentError,
"Content-Length not given and Transfer-Encoding is not `chunked'"
end
- supply_default_content_type
write_header sock, ver, path
wait_for_continue sock, ver if sock.continue_timeout
if chunked?
@@ -316,7 +338,7 @@ class Net::HTTPGenericRequest
boundary ||= SecureRandom.urlsafe_base64(40)
chunked_p = chunked?
- buf = ''
+ buf = +''
params.each do |key, value, h={}|
key = quote_string(key, charset)
filename =
@@ -373,12 +395,6 @@ class Net::HTTPGenericRequest
buf.clear
end
- def supply_default_content_type
- return if content_type()
- warn 'net/http: Content-Type did not set; using application/x-www-form-urlencoded', uplevel: 1 if $VERBOSE
- set_content_type 'application/x-www-form-urlencoded'
- end
-
##
# Waits up to the continue timeout for a response from the server provided
# we're speaking HTTP 1.1 and are expecting a 100-continue response.
@@ -401,7 +417,7 @@ class Net::HTTPGenericRequest
if /[\r\n]/ =~ reqline
raise ArgumentError, "A Request-Line must not contain CR or LF"
end
- buf = ""
+ buf = +''
buf << reqline << "\r\n"
each_capitalized do |k,v|
buf << "#{k}: #{v}\r\n"
@@ -411,4 +427,3 @@ class Net::HTTPGenericRequest
end
end
-
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 1425b6b329..5dcdcc7d74 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# The \HTTPHeader module provides access to \HTTP headers.
#
@@ -179,6 +179,10 @@
# - #each_value: Passes each string field value to the block.
#
module Net::HTTPHeader
+ # The maximum length of HTTP header keys.
+ MAX_KEY_LENGTH = 1024
+ # The maximum length of HTTP header values.
+ MAX_FIELD_LENGTH = 65536
def initialize_http_header(initheader) #:nodoc:
@header = {}
@@ -189,6 +193,12 @@ module Net::HTTPHeader
warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
else
value = value.strip # raise error for invalid byte sequences
+ if key.to_s.bytesize > MAX_KEY_LENGTH
+ raise ArgumentError, "too long (#{key.bytesize} bytes) header: #{key[0, 30].inspect}..."
+ end
+ if value.to_s.bytesize > MAX_FIELD_LENGTH
+ raise ArgumentError, "header #{key} has too long field value: #{value.bytesize}"
+ end
if value.count("\r\n") > 0
raise ArgumentError, "header #{key} has field value #{value.inspect}, this cannot include CR/LF"
end
@@ -259,6 +269,7 @@ module Net::HTTPHeader
end
end
+ # :stopdoc:
private def set_field(key, val)
case val
when Enumerable
@@ -286,6 +297,7 @@ module Net::HTTPHeader
ary.push val
end
end
+ # :startdoc:
# Returns the array field value for the given +key+,
# or +nil+ if there is no such field;
@@ -482,8 +494,8 @@ module Net::HTTPHeader
alias canonical_each each_capitalized
- def capitalize(name)
- name.to_s.split(/-/).map {|s| s.capitalize }.join('-')
+ def capitalize(name) # :nodoc:
+ name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze)
end
private :capitalize
@@ -691,10 +703,14 @@ module Net::HTTPHeader
# res.content_type # => "application/json"
#
def content_type
- return nil unless main_type()
- if sub_type()
- then "#{main_type()}/#{sub_type()}"
- else main_type()
+ main = main_type()
+ return nil unless main
+
+ sub = sub_type()
+ if sub
+ "#{main}/#{sub}"
+ else
+ main
end
end
@@ -945,12 +961,12 @@ module Net::HTTPHeader
@header['proxy-authorization'] = [basic_encode(account, password)]
end
- def basic_encode(account, password)
+ def basic_encode(account, password) # :nodoc:
'Basic ' + ["#{account}:#{password}"].pack('m0')
end
private :basic_encode
-# Returns whether the HTTP session is to be closed.
+ # Returns whether the HTTP session is to be closed.
def connection_close?
token = /(?:\A|,)\s*close\s*(?:\z|,)/i
@header['connection']&.grep(token) {return true}
@@ -958,7 +974,7 @@ module Net::HTTPHeader
false
end
-# Returns whether the HTTP session is to be kept alive.
+ # Returns whether the HTTP session is to be kept alive.
def connection_keep_alive?
token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
@header['connection']&.grep(token) {return true}
diff --git a/lib/net/http/net-http.gemspec b/lib/net/http/net-http.gemspec
index b07a0b6039..d59d5c3b74 100644
--- a/lib/net/http/net-http.gemspec
+++ b/lib/net/http/net-http.gemspec
@@ -21,19 +21,19 @@ Gem::Specification.new do |spec|
spec.summary = %q{HTTP client api for Ruby.}
spec.description = %q{HTTP client api for Ruby.}
spec.homepage = "https://github.com/ruby/net-http"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.metadata["changelog_uri"] = spec.homepage + "/releases"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
- end
+ excludes = %W[/.git* /bin /test /test_sig /*file /#{File.basename(__FILE__)}]
+ spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0")
spec.bindir = "exe"
spec.require_paths = ["lib"]
- spec.add_dependency "uri"
+ spec.add_dependency "uri", ">= 0.11.1"
end
diff --git a/lib/net/http/proxy_delta.rb b/lib/net/http/proxy_delta.rb
index a2f770ebdb..e7d30def64 100644
--- a/lib/net/http/proxy_delta.rb
+++ b/lib/net/http/proxy_delta.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Net::HTTP::ProxyDelta #:nodoc: internal use only
private
diff --git a/lib/net/http/request.rb b/lib/net/http/request.rb
index e900b8a17a..4a138572e9 100644
--- a/lib/net/http/request.rb
+++ b/lib/net/http/request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# This class is the base class for \Net::HTTP request classes.
# The class should not be used directly;
diff --git a/lib/net/http/requests.rb b/lib/net/http/requests.rb
index 96cedcabcc..8dc79a9f66 100644
--- a/lib/net/http/requests.rb
+++ b/lib/net/http/requests.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# HTTP/1.1 methods --- RFC2616
@@ -19,9 +19,9 @@
#
# - Request body: optional.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
@@ -29,6 +29,7 @@
# - Net::HTTP#get: sends +GET+ request, returns response object.
#
class Net::HTTP::Get < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'GET'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -51,15 +52,16 @@ end
#
# - Request body: optional.
# - Response body: no.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
# - Net::HTTP#head: sends +HEAD+ request, returns response object.
#
class Net::HTTP::Head < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'HEAD'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = false
@@ -85,9 +87,9 @@ end
#
# - Request body: yes.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: no.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
@@ -95,6 +97,7 @@ end
# - Net::HTTP#post: sends +POST+ request, returns response object.
#
class Net::HTTP::Post < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'POST'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -120,11 +123,17 @@ end
#
# - Request body: yes.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
+#
+# Related:
+#
+# - Net::HTTP.put: sends +PUT+ request, returns response object.
+# - Net::HTTP#put: sends +PUT+ request, returns response object.
#
class Net::HTTP::Put < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'PUT'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -148,15 +157,16 @@ end
#
# - Request body: optional.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
# - Net::HTTP#delete: sends +DELETE+ request, returns response object.
#
class Net::HTTP::Delete < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'DELETE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -179,15 +189,16 @@ end
#
# - Request body: optional.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
# - Net::HTTP#options: sends +OPTIONS+ request, returns response object.
#
class Net::HTTP::Options < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'OPTIONS'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -210,15 +221,16 @@ end
#
# - Request body: no.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
# - Net::HTTP#trace: sends +TRACE+ request, returns response object.
#
class Net::HTTP::Trace < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'TRACE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -244,15 +256,16 @@ end
#
# - Request body: yes.
# - Response body: yes.
-# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
-# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
-# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: no.
+# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
# - Net::HTTP#patch: sends +PATCH+ request, returns response object.
#
class Net::HTTP::Patch < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'PATCH'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -280,6 +293,7 @@ end
# - Net::HTTP#propfind: sends +PROPFIND+ request, returns response object.
#
class Net::HTTP::Propfind < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'PROPFIND'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -303,6 +317,7 @@ end
# - Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object.
#
class Net::HTTP::Proppatch < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'PROPPATCH'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -326,6 +341,7 @@ end
# - Net::HTTP#mkcol: sends +MKCOL+ request, returns response object.
#
class Net::HTTP::Mkcol < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'MKCOL'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -349,6 +365,7 @@ end
# - Net::HTTP#copy: sends +COPY+ request, returns response object.
#
class Net::HTTP::Copy < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'COPY'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -372,6 +389,7 @@ end
# - Net::HTTP#move: sends +MOVE+ request, returns response object.
#
class Net::HTTP::Move < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'MOVE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@@ -395,6 +413,7 @@ end
# - Net::HTTP#lock: sends +LOCK+ request, returns response object.
#
class Net::HTTP::Lock < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'LOCK'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
@@ -418,8 +437,8 @@ end
# - Net::HTTP#unlock: sends +UNLOCK+ request, returns response object.
#
class Net::HTTP::Unlock < Net::HTTPRequest
+ # :stopdoc:
METHOD = 'UNLOCK'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
end
-
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 1d83935c10..8804a99c9e 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# This class is the base class for \Net::HTTP response classes.
#
@@ -153,6 +153,7 @@ class Net::HTTPResponse
end
private
+ # :stopdoc:
def read_status_line(sock)
str = sock.readline
@@ -259,7 +260,7 @@ class Net::HTTPResponse
# header.
attr_accessor :ignore_eof
- def inspect
+ def inspect # :nodoc:
"#<#{self.class} #{@code} #{@message} readbody=#{@read}>"
end
@@ -273,7 +274,7 @@ class Net::HTTPResponse
def error! #:nodoc:
message = @code
- message += ' ' + @message.dump if @message
+ message = "#{message} #{@message.dump}" if @message
raise error_type().new(message, self)
end
@@ -366,6 +367,7 @@ class Net::HTTPResponse
@body = nil
end
@read = true
+ return if @body.nil?
case enc = @body_encoding
when Encoding, false, nil
@@ -639,7 +641,7 @@ class Net::HTTPResponse
end
def stream_check
- raise IOError, 'attempt to read body out of block' if @socket.closed?
+ raise IOError, 'attempt to read body out of block' if @socket.nil? || @socket.closed?
end
def procdest(dest, block)
@@ -648,7 +650,7 @@ class Net::HTTPResponse
if block
Net::ReadAdapter.new(block)
else
- dest || ''
+ dest || +''
end
end
diff --git a/lib/net/http/responses.rb b/lib/net/http/responses.rb
index 6f6fb8d055..941a6fed80 100644
--- a/lib/net/http/responses.rb
+++ b/lib/net/http/responses.rb
@@ -4,7 +4,9 @@
module Net
+ # Unknown HTTP response
class HTTPUnknownResponse < HTTPResponse
+ # :stopdoc:
HAS_BODY = true
EXCEPTION_TYPE = HTTPError #
end
@@ -19,6 +21,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response].
#
class HTTPInformation < HTTPResponse
+ # :stopdoc:
HAS_BODY = false
EXCEPTION_TYPE = HTTPError #
end
@@ -34,6 +37,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success].
#
class HTTPSuccess < HTTPResponse
+ # :stopdoc:
HAS_BODY = true
EXCEPTION_TYPE = HTTPError #
end
@@ -49,6 +53,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection].
#
class HTTPRedirection < HTTPResponse
+ # :stopdoc:
HAS_BODY = true
EXCEPTION_TYPE = HTTPRetriableError #
end
@@ -63,6 +68,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors].
#
class HTTPClientError < HTTPResponse
+ # :stopdoc:
HAS_BODY = true
EXCEPTION_TYPE = HTTPClientException #
end
@@ -77,6 +83,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors].
#
class HTTPServerError < HTTPResponse
+ # :stopdoc:
HAS_BODY = true
EXCEPTION_TYPE = HTTPFatalError #
end
@@ -94,6 +101,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100].
#
class HTTPContinue < HTTPInformation
+ # :stopdoc:
HAS_BODY = false
end
@@ -111,6 +119,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101].
#
class HTTPSwitchProtocol < HTTPInformation
+ # :stopdoc:
HAS_BODY = false
end
@@ -127,6 +136,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102].
#
class HTTPProcessing < HTTPInformation
+ # :stopdoc:
HAS_BODY = false
end
@@ -145,6 +155,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103].
#
class HTTPEarlyHints < HTTPInformation
+ # :stopdoc:
HAS_BODY = false
end
@@ -162,6 +173,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200].
#
class HTTPOK < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -179,6 +191,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201].
#
class HTTPCreated < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -196,6 +209,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202].
#
class HTTPAccepted < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -215,6 +229,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203].
#
class HTTPNonAuthoritativeInformation < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -232,6 +247,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204].
#
class HTTPNoContent < HTTPSuccess
+ # :stopdoc:
HAS_BODY = false
end
@@ -250,6 +266,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205].
#
class HTTPResetContent < HTTPSuccess
+ # :stopdoc:
HAS_BODY = false
end
@@ -268,6 +285,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206].
#
class HTTPPartialContent < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -285,6 +303,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207].
#
class HTTPMultiStatus < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -304,6 +323,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208].
#
class HTTPAlreadyReported < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -321,6 +341,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226].
#
class HTTPIMUsed < HTTPSuccess
+ # :stopdoc:
HAS_BODY = true
end
@@ -338,6 +359,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300].
#
class HTTPMultipleChoices < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
HTTPMultipleChoice = HTTPMultipleChoices
@@ -356,6 +378,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301].
#
class HTTPMovedPermanently < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
@@ -373,6 +396,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302].
#
class HTTPFound < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
HTTPMovedTemporarily = HTTPFound
@@ -390,6 +414,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303].
#
class HTTPSeeOther < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
@@ -407,6 +432,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304].
#
class HTTPNotModified < HTTPRedirection
+ # :stopdoc:
HAS_BODY = false
end
@@ -423,6 +449,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305].
#
class HTTPUseProxy < HTTPRedirection
+ # :stopdoc:
HAS_BODY = false
end
@@ -440,6 +467,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307].
#
class HTTPTemporaryRedirect < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
@@ -456,6 +484,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308].
#
class HTTPPermanentRedirect < HTTPRedirection
+ # :stopdoc:
HAS_BODY = true
end
@@ -472,6 +501,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400].
#
class HTTPBadRequest < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -488,6 +518,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401].
#
class HTTPUnauthorized < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -504,6 +535,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402].
#
class HTTPPaymentRequired < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -521,6 +553,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403].
#
class HTTPForbidden < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -537,6 +570,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404].
#
class HTTPNotFound < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -553,6 +587,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405].
#
class HTTPMethodNotAllowed < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -570,6 +605,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406].
#
class HTTPNotAcceptable < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -586,6 +622,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407].
#
class HTTPProxyAuthenticationRequired < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -602,6 +639,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408].
#
class HTTPRequestTimeout < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
HTTPRequestTimeOut = HTTPRequestTimeout
@@ -619,6 +657,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409].
#
class HTTPConflict < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -636,6 +675,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410].
#
class HTTPGone < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -653,6 +693,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411].
#
class HTTPLengthRequired < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -670,6 +711,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412].
#
class HTTPPreconditionFailed < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -686,6 +728,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413].
#
class HTTPPayloadTooLarge < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
HTTPRequestEntityTooLarge = HTTPPayloadTooLarge
@@ -703,6 +746,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414].
#
class HTTPURITooLong < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
HTTPRequestURITooLong = HTTPURITooLong
@@ -721,6 +765,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415].
#
class HTTPUnsupportedMediaType < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -737,6 +782,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416].
#
class HTTPRangeNotSatisfiable < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable
@@ -754,6 +800,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417].
#
class HTTPExpectationFailed < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -774,6 +821,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421].
#
class HTTPMisdirectedRequest < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -790,6 +838,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422].
#
class HTTPUnprocessableEntity < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -805,6 +854,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423].
#
class HTTPLocked < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -821,6 +871,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424].
#
class HTTPFailedDependency < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -840,6 +891,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426].
#
class HTTPUpgradeRequired < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -856,6 +908,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428].
#
class HTTPPreconditionRequired < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -872,6 +925,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429].
#
class HTTPTooManyRequests < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -889,6 +943,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431].
#
class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
@@ -906,6 +961,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451].
#
class HTTPUnavailableForLegalReasons < HTTPClientError
+ # :stopdoc:
HAS_BODY = true
end
# 444 No Response - Nginx
@@ -926,6 +982,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500].
#
class HTTPInternalServerError < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -943,6 +1000,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501].
#
class HTTPNotImplemented < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -960,6 +1018,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502].
#
class HTTPBadGateway < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -977,6 +1036,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503].
#
class HTTPServiceUnavailable < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -994,6 +1054,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504].
#
class HTTPGatewayTimeout < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
HTTPGatewayTimeOut = HTTPGatewayTimeout
@@ -1011,6 +1072,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505].
#
class HTTPVersionNotSupported < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -1027,6 +1089,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506].
#
class HTTPVariantAlsoNegotiates < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -1043,6 +1106,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507].
#
class HTTPInsufficientStorage < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -1059,6 +1123,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508].
#
class HTTPLoopDetected < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
# 509 Bandwidth Limit Exceeded - Apache bw/limited extension
@@ -1076,6 +1141,7 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510].
#
class HTTPNotExtended < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
@@ -1092,19 +1158,21 @@ module Net
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511].
#
class HTTPNetworkAuthenticationRequired < HTTPServerError
+ # :stopdoc:
HAS_BODY = true
end
end
class Net::HTTPResponse
+ # :stopdoc:
CODE_CLASS_TO_OBJ = {
'1' => Net::HTTPInformation,
'2' => Net::HTTPSuccess,
'3' => Net::HTTPRedirection,
'4' => Net::HTTPClientError,
'5' => Net::HTTPServerError
- }
+ }.freeze
CODE_TO_OBJ = {
'100' => Net::HTTPContinue,
'101' => Net::HTTPSwitchProtocol,
@@ -1170,5 +1238,5 @@ class Net::HTTPResponse
'508' => Net::HTTPLoopDetected,
'510' => Net::HTTPNotExtended,
'511' => Net::HTTPNetworkAuthenticationRequired,
- }
+ }.freeze
end
diff --git a/lib/net/https.rb b/lib/net/https.rb
index d46721c82a..0f23e1fb13 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
=begin
= net/https -- SSL/TLS enhancement for Net::HTTP.
diff --git a/lib/net/net-protocol.gemspec b/lib/net/net-protocol.gemspec
index c03621cb0d..2d911a966c 100644
--- a/lib/net/net-protocol.gemspec
+++ b/lib/net/net-protocol.gemspec
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
+ spec.metadata["changelog_uri"] = spec.homepage + "/releases"
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
+ excludes = %W[/.git* /bin /test /*file /#{File.basename(__FILE__)}]
+ spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0")
spec.require_paths = ["lib"]
spec.add_dependency "timeout"
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index ea0752a971..8c81298c0e 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -26,7 +26,7 @@ require 'io/wait'
module Net # :nodoc:
class Protocol #:nodoc: internal use only
- VERSION = "0.2.1"
+ VERSION = "0.2.2"
private
def Protocol.protocol_param(name, val)
@@ -54,9 +54,20 @@ module Net # :nodoc:
s.connect
end
end
+
+ tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
+ TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
+ tcp_socket_parameters.include?([:key, :open_timeout])
+ else
+ # Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
+ # See discussion in https://github.com/ruby/net-http/pull/224
+ Socket.method(:tcp).parameters.include?([:key, :open_timeout])
+ end
+ private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
end
+ # :stopdoc:
class ProtocolError < StandardError; end
class ProtoSyntaxError < ProtocolError; end
class ProtoFatalError < ProtocolError; end
@@ -66,6 +77,7 @@ module Net # :nodoc:
class ProtoCommandError < ProtocolError; end
class ProtoRetriableError < ProtocolError; end
ProtocRetryError = ProtoRetriableError
+ # :startdoc:
##
# OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot
@@ -78,6 +90,7 @@ module Net # :nodoc:
# response cannot be read within the read_timeout.
class ReadTimeout < Timeout::Error
+ # :stopdoc:
def initialize(io = nil)
@io = io
end
@@ -97,6 +110,7 @@ module Net # :nodoc:
# response cannot be written within the write_timeout. Not raised on Windows.
class WriteTimeout < Timeout::Error
+ # :stopdoc:
def initialize(io = nil)
@io = io
end
@@ -484,6 +498,7 @@ module Net # :nodoc:
# The writer adapter class
#
class WriteAdapter
+ # :stopdoc:
def initialize(writer)
@writer = writer
end
diff --git a/lib/observer.rb b/lib/observer.rb
deleted file mode 100644
index ef70e39dd8..0000000000
--- a/lib/observer.rb
+++ /dev/null
@@ -1,229 +0,0 @@
-# frozen_string_literal: true
-#
-# Implementation of the _Observer_ object-oriented design pattern. The
-# following documentation is copied, with modifications, from "Programming
-# Ruby", by Hunt and Thomas; http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_patterns.html.
-#
-# See Observable for more info.
-
-# The Observer pattern (also known as publish/subscribe) provides a simple
-# mechanism for one object to inform a set of interested third-party objects
-# when its state changes.
-#
-# == Mechanism
-#
-# The notifying class mixes in the +Observable+
-# module, which provides the methods for managing the associated observer
-# objects.
-#
-# The observable object must:
-# * assert that it has +#changed+
-# * call +#notify_observers+
-#
-# An observer subscribes to updates using Observable#add_observer, which also
-# specifies the method called via #notify_observers. The default method for
-# #notify_observers is #update.
-#
-# === Example
-#
-# The following example demonstrates this nicely. A +Ticker+, when run,
-# continually receives the stock +Price+ for its <tt>@symbol</tt>. A +Warner+
-# is a general observer of the price, and two warners are demonstrated, a
-# +WarnLow+ and a +WarnHigh+, which print a warning if the price is below or
-# above their set limits, respectively.
-#
-# The +update+ callback allows the warners to run without being explicitly
-# called. The system is set up with the +Ticker+ and several observers, and the
-# observers do their duty without the top-level code having to interfere.
-#
-# Note that the contract between publisher and subscriber (observable and
-# observer) is not declared or enforced. The +Ticker+ publishes a time and a
-# price, and the warners receive that. But if you don't ensure that your
-# contracts are correct, nothing else can warn you.
-#
-# require "observer"
-#
-# class Ticker ### Periodically fetch a stock price.
-# include Observable
-#
-# def initialize(symbol)
-# @symbol = symbol
-# end
-#
-# def run
-# last_price = nil
-# loop do
-# price = Price.fetch(@symbol)
-# print "Current price: #{price}\n"
-# if price != last_price
-# changed # notify observers
-# last_price = price
-# notify_observers(Time.now, price)
-# end
-# sleep 1
-# end
-# end
-# end
-#
-# class Price ### A mock class to fetch a stock price (60 - 140).
-# def self.fetch(symbol)
-# 60 + rand(80)
-# end
-# end
-#
-# class Warner ### An abstract observer of Ticker objects.
-# def initialize(ticker, limit)
-# @limit = limit
-# ticker.add_observer(self)
-# end
-# end
-#
-# class WarnLow < Warner
-# def update(time, price) # callback for observer
-# if price < @limit
-# print "--- #{time.to_s}: Price below #@limit: #{price}\n"
-# end
-# end
-# end
-#
-# class WarnHigh < Warner
-# def update(time, price) # callback for observer
-# if price > @limit
-# print "+++ #{time.to_s}: Price above #@limit: #{price}\n"
-# end
-# end
-# end
-#
-# ticker = Ticker.new("MSFT")
-# WarnLow.new(ticker, 80)
-# WarnHigh.new(ticker, 120)
-# ticker.run
-#
-# Produces:
-#
-# Current price: 83
-# Current price: 75
-# --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 75
-# Current price: 90
-# Current price: 134
-# +++ Sun Jun 09 00:10:25 CDT 2002: Price above 120: 134
-# Current price: 134
-# Current price: 112
-# Current price: 79
-# --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 79
-#
-# === Usage with procs
-#
-# The +#notify_observers+ method can also be used with +proc+s by using
-# the +:call+ as +func+ parameter.
-#
-# The following example illustrates the use of a lambda:
-#
-# require 'observer'
-#
-# class Ticker
-# include Observable
-#
-# def run
-# # logic to retrieve the price (here 77.0)
-# changed
-# notify_observers(77.0)
-# end
-# end
-#
-# ticker = Ticker.new
-# warner = ->(price) { puts "New price received: #{price}" }
-# ticker.add_observer(warner, :call)
-# ticker.run
-module Observable
- VERSION = "0.1.1"
-
- #
- # Add +observer+ as an observer on this object. So that it will receive
- # notifications.
- #
- # +observer+:: the object that will be notified of changes.
- # +func+:: Symbol naming the method that will be called when this Observable
- # has changes.
- #
- # This method must return true for +observer.respond_to?+ and will
- # receive <tt>*arg</tt> when #notify_observers is called, where
- # <tt>*arg</tt> is the value passed to #notify_observers by this
- # Observable
- 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}'"
- end
- @observer_peers[observer] = func
- end
-
- #
- # Remove +observer+ as an observer on this object so that it will no longer
- # receive notifications.
- #
- # +observer+:: An observer of this Observable
- def delete_observer(observer)
- @observer_peers.delete observer if defined? @observer_peers
- end
-
- #
- # Remove all observers associated with this object.
- #
- def delete_observers
- @observer_peers.clear if defined? @observer_peers
- end
-
- #
- # Return the number of observers associated with this object.
- #
- def count_observers
- if defined? @observer_peers
- @observer_peers.size
- else
- 0
- end
- end
-
- #
- # Set the changed state of this object. Notifications will be sent only if
- # the changed +state+ is +true+.
- #
- # +state+:: Boolean indicating the changed state of this Observable.
- #
- def changed(state=true)
- @observer_state = state
- end
-
- #
- # Returns true if this object's state has been changed since the last
- # #notify_observers call.
- #
- def changed?
- if defined? @observer_state and @observer_state
- true
- else
- false
- end
- end
-
- #
- # Notify observers of a change in state *if* this object's changed state is
- # +true+.
- #
- # This will invoke the method named in #add_observer, passing <tt>*arg</tt>.
- # The changed state is then set to +false+.
- #
- # <tt>*arg</tt>:: Any arguments to pass to the observers.
- def notify_observers(*arg)
- if defined? @observer_state and @observer_state
- if defined? @observer_peers
- @observer_peers.each do |k, v|
- k.__send__(v, *arg)
- end
- end
- @observer_state = false
- end
- end
-
-end
diff --git a/lib/observer/observer.gemspec b/lib/observer/observer.gemspec
deleted file mode 100644
index 46538e881a..0000000000
--- a/lib/observer/observer.gemspec
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Implementation of the Observer object-oriented design pattern.}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/observer"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/open-uri.gemspec b/lib/open-uri.gemspec
index cad63e4d80..b6aaf35200 100644
--- a/lib/open-uri.gemspec
+++ b/lib/open-uri.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", "."].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "open-uri"
- spec.version = "0.3.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index 93e8cfcdb7..844865b13a 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -4,22 +4,25 @@ require 'stringio'
require 'time'
module URI
- # Allows the opening of various resources including URIs.
+ # Allows the opening of various resources including URIs. Example:
#
- # If the first argument responds to the 'open' method, 'open' is called on
+ # require "open-uri"
+ # URI.open("http://example.com") { |f| f.read }
+ #
+ # If the first argument responds to the +open+ method, +open+ is called on
# it with the rest of the arguments.
#
# If the first argument is a string that begins with <code>(protocol)://</code>, it is parsed by
- # URI.parse. If the parsed object responds to the 'open' method,
- # 'open' is called on it with the rest of the arguments.
+ # URI.parse. If the parsed object responds to the +open+ method,
+ # +open+ is called on it with the rest of the arguments.
#
# Otherwise, Kernel#open is called.
#
# OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and
# URI::FTP#open, Kernel#open.
#
- # We can accept URIs and strings that begin with http://, https:// and
- # ftp://. In these cases, the opened file object is extended by OpenURI::Meta.
+ # We can accept URIs and strings that begin with <code>http://</code>, <code>https://</code> and
+ # <code>ftp://</code>. In these cases, the opened file object is extended by OpenURI::Meta.
def self.open(name, *rest, &block)
if name.respond_to?(:open)
name.open(*rest, &block)
@@ -31,6 +34,7 @@ module URI
super
end
end
+ singleton_class.send(:ruby2_keywords, :open) if respond_to?(:ruby2_keywords, true)
end
# OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -89,6 +93,11 @@ end
# Author:: Tanaka Akira <akr@m17n.org>
module OpenURI
+
+ # The version string
+ VERSION = "0.5.0"
+
+ # The default options
Options = {
:proxy => true,
:proxy_http_basic_authentication => true,
@@ -104,6 +113,8 @@ module OpenURI
:ftp_active_mode => false,
:redirect => true,
:encoding => nil,
+ :max_redirects => 64,
+ :request_specific_fields => nil,
}
def OpenURI.check_options(options) # :nodoc:
@@ -143,7 +154,11 @@ module OpenURI
end
encoding = Encoding.find(options[:encoding])
end
-
+ if options.has_key? :request_specific_fields
+ if !(options[:request_specific_fields].is_a?(Hash) || options[:request_specific_fields].is_a?(Proc))
+ raise ArgumentError, "Invalid request_specific_fields option: #{options[:request_specific_fields].inspect}"
+ end
+ end
unless mode == nil ||
mode == 'r' || mode == 'rb' ||
mode == File::RDONLY
@@ -207,11 +222,20 @@ module OpenURI
end
uri_set = {}
+ max_redirects = options[:max_redirects] || Options.fetch(:max_redirects)
buf = nil
while true
+ request_specific_fields = {}
+ if options.has_key? :request_specific_fields
+ request_specific_fields = if options[:request_specific_fields].is_a?(Hash)
+ options[:request_specific_fields]
+ else options[:request_specific_fields].is_a?(Proc)
+ options[:request_specific_fields].call(uri)
+ end
+ end
redirect = catch(:open_uri_redirect) {
buf = Buffer.new
- uri.buffer_open(buf, find_proxy.call(uri), options)
+ uri.buffer_open(buf, find_proxy.call(uri), options.merge(request_specific_fields))
nil
}
if redirect
@@ -231,9 +255,14 @@ module OpenURI
options = options.dup
options.delete :http_basic_authentication
end
+ if options.include?(:request_specific_fields) && options[:request_specific_fields].is_a?(Hash)
+ # Send request specific headers only for the initial request.
+ options.delete :request_specific_fields
+ end
uri = redirect
raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
uri_set[uri.to_s] = true
+ raise TooManyRedirects.new("Too many redirects", buf.io) if max_redirects && uri_set.size > max_redirects
else
break
end
@@ -370,24 +399,31 @@ module OpenURI
end
end
+ # Raised on HTTP session failure
class HTTPError < StandardError
- def initialize(message, io)
+ def initialize(message, io) # :nodoc:
super(message)
@io = io
end
+ # StringIO having the received data
attr_reader :io
end
# Raised on redirection,
# only occurs when +redirect+ option for HTTP is +false+.
class HTTPRedirect < HTTPError
- def initialize(message, io, uri)
+ def initialize(message, io, uri) # :nodoc:
super(message, io)
@uri = uri
end
+ # URI to redirect
attr_reader :uri
end
+ # Raised on too many redirection,
+ class TooManyRedirects < HTTPError
+ end
+
class Buffer # :nodoc: all
def initialize
@io = StringIO.new
@@ -736,6 +772,44 @@ module OpenURI
# Using +true+ also means that redirections between http and ftp are
# permitted.
#
+ # [:max_redirects]
+ # Synopsis:
+ # :max_redirects=>int
+ #
+ # Number of HTTP redirects allowed before OpenURI::TooManyRedirects is raised.
+ # The default is 64.
+ #
+ # [:request_specific_fields]
+ # Synopsis:
+ # :request_specific_fields => {}
+ # :request_specific_fields => lambda {|url| ...}
+ #
+ # :request_specific_fields option allows specifying custom header fields that
+ # are sent with the HTTP request. It can be passed as a Hash or a Proc that
+ # gets evaluated on each request and returns a Hash of header fields.
+ #
+ # If a Hash is provided, it specifies the headers only for the initial
+ # request and these headers will not be sent on redirects.
+ #
+ # If a Proc is provided, it will be executed for each request including
+ # redirects, allowing dynamic header customization based on the request URL.
+ # It is important that the Proc returns a Hash. And this Hash specifies the
+ # headers to be sent with the request.
+ #
+ # For Example with Hash
+ # URI.open("http://...",
+ # request_specific_fields: {"Authorization" => "token dummy"}) {|f| ... }
+ #
+ # For Example with Proc:
+ # URI.open("http://...",
+ # request_specific_fields: lambda { |uri|
+ # if uri.host == "example.com"
+ # {"Authorization" => "token dummy"}
+ # else
+ # {}
+ # end
+ # }) {|f| ... }
+ #
def open(*rest, &block)
OpenURI.open_uri(self, *rest, &block)
end
diff --git a/lib/open3.rb b/lib/open3.rb
index 9652b27194..74d00b86d9 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -31,57 +31,189 @@
require 'open3/version'
+# \Module \Open3 supports creating child processes
+# with access to their $stdin, $stdout, and $stderr streams.
+#
+# == What's Here
+#
+# Each of these methods executes a given command in a new process or subshell,
+# or multiple commands in new processes and/or subshells:
+#
+# - Each of these methods executes a single command in a process or subshell,
+# accepts a string for input to $stdin,
+# and returns string output from $stdout, $stderr, or both:
+#
+# - Open3.capture2: Executes the command;
+# returns the string from $stdout.
+# - Open3.capture2e: Executes the command;
+# returns the string from merged $stdout and $stderr.
+# - Open3.capture3: Executes the command;
+# returns strings from $stdout and $stderr.
+#
+# - Each of these methods executes a single command in a process or subshell,
+# and returns pipes for $stdin, $stdout, and/or $stderr:
+#
+# - Open3.popen2: Executes the command;
+# returns pipes for $stdin and $stdout.
+# - Open3.popen2e: Executes the command;
+# returns pipes for $stdin and merged $stdout and $stderr.
+# - Open3.popen3: Executes the command;
+# returns pipes for $stdin, $stdout, and $stderr.
+#
+# - Each of these methods executes one or more commands in processes and/or subshells,
+# returns pipes for the first $stdin, the last $stdout, or both:
+#
+# - Open3.pipeline_r: Returns a pipe for the last $stdout.
+# - Open3.pipeline_rw: Returns pipes for the first $stdin and the last $stdout.
+# - Open3.pipeline_w: Returns a pipe for the first $stdin.
+# - Open3.pipeline_start: Does not wait for processes to complete.
+# - Open3.pipeline: Waits for processes to complete.
+#
+# Each of the methods above accepts:
+#
+# - An optional hash of environment variable names and values;
+# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+# - A required string argument that is a +command_line+ or +exe_path+;
+# see {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
+# - An optional hash of execution options;
+# see {Execution Options}[rdoc-ref:Process@Execution+Options].
+#
module Open3
- # Open stdin, stdout, and stderr streams and start external executable.
- # In addition, a thread to wait for the started process is created.
- # The thread has a pid method and a thread variable :pid which is the pid of
- # the started process.
+ # :call-seq:
+ # Open3.popen3([env, ] command_line, options = {}) -> [stdin, stdout, stderr, wait_thread]
+ # Open3.popen3([env, ] exe_path, *args, options = {}) -> [stdin, stdout, stderr, wait_thread]
+ # Open3.popen3([env, ] command_line, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
+ # Open3.popen3([env, ] exe_path, *args, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+, +stdout+, and +stderr+,
+ # which are the standard input, standard output, and standard error streams
+ # in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout, stderr, wait_thread]</tt>.
+ # The caller should close each of the three returned streams.
+ #
+ # stdin, stdout, stderr, wait_thread = Open3.popen3('echo')
+ # # => [#<IO:fd 8>, #<IO:fd 10>, #<IO:fd 12>, #<Process::Waiter:0x00007f58d5428f58 run>]
+ # stdin.close
+ # stdout.close
+ # stderr.close
+ # wait_thread.pid # => 2210481
+ # wait_thread.value # => #<Process::Status: pid 2210481 exit 0>
+ #
+ # With a block given, calls the block with the four variables
+ # (three streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen3('echo') do |stdin, stdout, stderr, wait_thread|
+ # p stdin
+ # p stdout
+ # p stderr
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen3([env,] cmd... [, opts]) {|stdin, stdout, stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<IO:fd 9>
+ # #<Process::Waiter:0x00007f58d53606e8 sleep>
+ # 2211047
+ # #<Process::Status: pid 2211047 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts])
- # pid = wait_thr[:pid] # pid of the started process
- # ...
- # stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
- # stdout.close
- # stderr.close
- # exit_status = wait_thr.value # Process::Status object returned.
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
#
- # The parameters env, cmd, and opts are passed to Process.spawn.
- # A commandline string and a list of argument strings can be accepted as follows:
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
#
- # Open3.popen3("echo abc") {|i, o, e, t| ... }
- # Open3.popen3("echo", "abc") {|i, o, e, t| ... }
- # Open3.popen3(["echo", "argv0"], "abc") {|i, o, e, t| ... }
+ # Open3.popen3('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen3('echo') {|*args| p args } # Built-in.
+ # Open3.popen3('date > date.tmp') {|*args| p args } # Contains meta character.
#
- # If the last parameter, opts, is a Hash, it is recognized as an option for Process.spawn.
+ # Output (similar for each call above):
#
- # Open3.popen3("pwd", :chdir=>"/") {|i,o,e,t|
- # p o.read.chomp #=> "/"
- # }
+ # [#<IO:(closed)>, #<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f58d52f28c8 dead>]
#
- # wait_thr.value waits for the termination of the process.
- # The block form also waits for the process when it returns.
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen3('echo "Foo"') { |i, o, e, t| o.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
+ #
+ # Example:
#
- # Closing stdin, stdout and stderr does not wait for the process to complete.
+ # Open3.popen3('/usr/bin/date') { |i, o, e, t| o.gets }
+ # # => "Wed Sep 27 02:56:44 PM CDT 2023\n"
#
- # You should be careful to avoid deadlocks.
- # Since pipes are fixed length buffers,
- # Open3.popen3("prog") {|i, o, e, t| o.read } deadlocks if
- # the program generates too much output on stderr.
- # You should read stdout and stderr simultaneously (using threads or IO.select).
- # However, if you don't need stderr output, you can use Open3.popen2.
- # If merged stdout and stderr output is not a problem, you can use Open3.popen2e.
- # If you really need stdout and stderr output as separate strings, you can consider Open3.capture3.
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen3('doesnt_exist') { |i, o, e, t| o.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen3('echo', 'C #') { |i, o, e, t| o.gets }
+ # # => "C #\n"
+ # Open3.popen3('echo', 'hello', 'world') { |i, o, e, t| o.gets }
+ # # => "hello world\n"
+ #
+ # Take care to avoid deadlocks.
+ # Output streams +stdout+ and +stderr+ have fixed-size buffers,
+ # so reading extensively from one but not the other can cause a deadlock
+ # when the unread buffer fills.
+ # To avoid that, +stdout+ and +stderr+ should be read simultaneously
+ # (using threads or IO.select).
+ #
+ # Related:
+ #
+ # - Open3.popen2: Makes the standard input and standard output streams
+ # of the child process available as separate streams,
+ # with no access to the standard error stream.
+ # - Open3.popen2e: Makes the standard input and the merge
+ # of the standard output and standard error streams
+ # of the child process available as separate streams.
#
def popen3(*cmd, &block)
if Hash === cmd.last
@@ -104,45 +236,131 @@ module Open3
end
module_function :popen3
- # Open3.popen2 is similar to Open3.popen3 except that it doesn't create a pipe for
- # the standard error stream.
+ # :call-seq:
+ # Open3.popen2([env, ] command_line, options = {}) -> [stdin, stdout, wait_thread]
+ # Open3.popen2([env, ] exe_path, *args, options = {}) -> [stdin, stdout, wait_thread]
+ # Open3.popen2([env, ] command_line, options = {}) {|stdin, stdout, wait_thread| ... } -> object
+ # Open3.popen2([env, ] exe_path, *args, options = {}) {|stdin, stdout, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+ and +stdout+,
+ # which are the standard input and standard output streams
+ # in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout, wait_thread]</tt>.
+ # The caller should close each of the two returned streams.
+ #
+ # stdin, stdout, wait_thread = Open3.popen2('echo')
+ # # => [#<IO:fd 6>, #<IO:fd 7>, #<Process::Waiter:0x00007f58d52dbe98 run>]
+ # stdin.close
+ # stdout.close
+ # wait_thread.pid # => 2263572
+ # wait_thread.value # => #<Process::Status: pid 2263572 exit 0>
+ #
+ # With a block given, calls the block with the three variables
+ # (two streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen2('echo') do |stdin, stdout, wait_thread|
+ # p stdin
+ # p stdout
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen2([env,] cmd... [, opts]) {|stdin, stdout, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<Process::Waiter:0x00007f58d59a34b0 sleep>
+ # 2263636
+ # #<Process::Status: pid 2263636 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout, wait_thr = Open3.popen2([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout should be closed explicitly in this form.
- # stdout.close
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
#
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.popen2('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen2('echo') {|*args| p args } # Built-in.
+ # Open3.popen2('date > date.tmp') {|*args| p args } # Contains meta character.
+ #
+ # Output (similar for each call above):
+ #
+ # # => [#<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f7577dfe410 dead>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen2('echo "Foo"') { |i, o, t| o.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # Open3.popen2("wc -c") {|i,o,t|
- # i.print "answer to life the universe and everything"
- # i.close
- # p o.gets #=> "42\n"
- # }
+ # Open3.popen2('/usr/bin/date') { |i, o, t| o.gets }
+ # # => "Thu Sep 28 09:41:06 AM CDT 2023\n"
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen2('doesnt_exist') { |i, o, t| o.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen2('echo', 'C #') { |i, o, t| o.gets }
+ # # => "C #\n"
+ # Open3.popen2('echo', 'hello', 'world') { |i, o, t| o.gets }
+ # # => "hello world\n"
#
- # Open3.popen2("bc -q") {|i,o,t|
- # i.puts "obase=13"
- # i.puts "6 * 9"
- # p o.gets #=> "42\n"
- # }
#
- # Open3.popen2("dc") {|i,o,t|
- # i.print "42P"
- # i.close
- # p o.read #=> "*"
- # }
+ # Related:
+ #
+ # - Open3.popen2e: Makes the standard input and the merge
+ # of the standard output and standard error streams
+ # of the child process available as separate streams.
+ # - Open3.popen3: Makes the standard input, standard output,
+ # and standard error streams
+ # of the child process available as separate streams.
#
def popen2(*cmd, &block)
if Hash === cmd.last
@@ -162,36 +380,130 @@ module Open3
end
module_function :popen2
- # Open3.popen2e is similar to Open3.popen3 except that it merges
- # the standard output stream and the standard error stream.
+ # :call-seq:
+ # Open3.popen2e([env, ] command_line, options = {}) -> [stdin, stdout_and_stderr, wait_thread]
+ # Open3.popen2e([env, ] exe_path, *args, options = {}) -> [stdin, stdout_and_stderr, wait_thread]
+ # Open3.popen2e([env, ] command_line, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
+ # Open3.popen2e([env, ] exe_path, *args, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+, +stdout_and_stderr+,
+ # which are the standard input and the merge of the standard output
+ # and standard error streams in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout_and_stderr, wait_thread]</tt>.
+ # The caller should close each of the two returned streams.
+ #
+ # stdin, stdout_and_stderr, wait_thread = Open3.popen2e('echo')
+ # # => [#<IO:fd 6>, #<IO:fd 7>, #<Process::Waiter:0x00007f7577da4398 run>]
+ # stdin.close
+ # stdout_and_stderr.close
+ # wait_thread.pid # => 2274600
+ # wait_thread.value # => #<Process::Status: pid 2274600 exit 0>
+ #
+ # With a block given, calls the block with the three variables
+ # (two streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen2e('echo') do |stdin, stdout_and_stderr, wait_thread|
+ # p stdin
+ # p stdout_and_stderr
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen2e([env,] cmd... [, opts]) {|stdin, stdout_and_stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<Process::Waiter:0x00007f75777578c8 sleep>
+ # 2274763
+ # #<Process::Status: pid 2274763 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout_and_stderr, wait_thr = Open3.popen2e([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout_and_stderr should be closed explicitly in this form.
- # stdout_and_stderr.close
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.popen2e('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen2e('echo') {|*args| p args } # Built-in.
+ # Open3.popen2e('date > date.tmp') {|*args| p args } # Contains meta character.
+ #
+ # Output (similar for each call above):
+ #
+ # # => [#<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f7577d8a1f0 dead>]
#
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen2e('echo "Foo"') { |i, o_and_e, t| o_and_e.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
- # # check gcc warnings
- # source = "foo.c"
- # Open3.popen2e("gcc", "-Wall", source) {|i,oe,t|
- # oe.each {|line|
- # if /warning/ =~ line
- # ...
- # end
- # }
- # }
+ #
+ # Open3.popen2e('/usr/bin/date') { |i, o_and_e, t| o_and_e.gets }
+ # # => "Thu Sep 28 01:58:45 PM CDT 2023\n"
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen2e('doesnt_exist') { |i, o_and_e, t| o_and_e.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen2e('echo', 'C #') { |i, o_and_e, t| o_and_e.gets }
+ # # => "C #\n"
+ # Open3.popen2e('echo', 'hello', 'world') { |i, o_and_e, t| o_and_e.gets }
+ # # => "hello world\n"
+ #
+ # Related:
+ #
+ # - Open3.popen2: Makes the standard input and standard output streams
+ # of the child process available as separate streams,
+ # with no access to the standard error stream.
+ # - Open3.popen3: Makes the standard input, standard output,
+ # and standard error streams
+ # of the child process available as separate streams.
#
def popen2e(*cmd, &block)
if Hash === cmd.last
@@ -238,44 +550,100 @@ module Open3
private :popen_run
end
- # Open3.capture3 captures the standard output and the standard error of a command.
+ # :call-seq:
+ # Open3.capture3([env, ] command_line, options = {}) -> [stdout_s, stderr_s, status]
+ # Open3.capture3([env, ] exe_path, *args, options = {}) -> [stdout_s, stderr_s, status]
#
- # stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts])
+ # Basically a wrapper for Open3.popen3 that:
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as strings +stdout_s+ and +stderr_s+ the standard output
+ # and standard error of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # Returns the array <tt>[stdout_s, stderr_s, status]</tt>:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # stdout_s, stderr_s, status = Open3.capture3('echo "Foo"')
+ # # => ["Foo\n", "", #<Process::Status: pid 2281954 exit 0>]
#
- # Examples:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # # dot is a command of graphviz.
- # graph = <<'End'
- # digraph g {
- # a -> b
- # }
- # End
- # drawn_graph, dot_log = Open3.capture3("dot -v", :stdin_data=>graph)
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
#
- # o, e, s = Open3.capture3("echo abc; sort >&2", :stdin_data=>"foo\nbar\nbaz\n")
- # p o #=> "abc\n"
- # p e #=> "bar\nbaz\nfoo\n"
- # p s #=> #<Process::Status: pid 32682 exit 0>
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
- # # generate a thumbnail image using the convert command of ImageMagick.
- # # However, if the image is really stored in a file,
- # # system("convert", "-thumbnail", "80", "png:#{filename}", "png:-") is better
- # # because of reduced memory consumption.
- # # But if the image is stored in a DB or generated by the gnuplot Open3.capture2 example,
- # # Open3.capture3 should be considered.
- # #
- # image = File.read("/usr/share/openclipart/png/animals/mammals/sheep-md-v0.1.png", :binmode=>true)
- # thumbnail, err, s = Open3.capture3("convert -thumbnail 80 png:- png:-", :stdin_data=>image, :binmode=>true)
- # if s.success?
- # STDOUT.binmode; print thumbnail
- # end
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture3:
+ #
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
+ #
+ # Open3.capture3('tee', stdin_data: 'Foo')
+ # # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
+ #
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", "", #<Process::Status: pid 2282025 exit 0>]
+ # Open3.capture3('echo') # Built-in.
+ # # => ["\n", "", #<Process::Status: pid 2282092 exit 0>]
+ # Open3.capture3('date > date.tmp') # Contains meta character.
+ # # => ["", "", #<Process::Status: pid 2282110 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture3('echo "Foo"')
+ # # => ["Foo\n", "", #<Process::Status: pid 2282092 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
+ #
+ # Example:
+ #
+ # Open3.capture3('/usr/bin/date')
+ # # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #<Process::Status: pid 2282300 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture3('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture3('echo', 'C #')
+ # # => ["C #\n", "", #<Process::Status: pid 2282368 exit 0>]
+ # Open3.capture3('echo', 'hello', 'world')
+ # # => ["hello world\n", "", #<Process::Status: pid 2282372 exit 0>]
#
def capture3(*cmd)
if Hash === cmd.last
@@ -309,34 +677,100 @@ module Open3
end
module_function :capture3
- # Open3.capture2 captures the standard output of a command.
+ # :call-seq:
+ # Open3.capture2([env, ] command_line, options = {}) -> [stdout_s, status]
+ # Open3.capture2([env, ] exe_path, *args, options = {}) -> [stdout_s, status]
+ #
+ # Basically a wrapper for Open3.popen3 that:
+ #
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as string +stdout_s+ the standard output of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
+ #
+ # Returns the array <tt>[stdout_s, status]</tt>:
+ #
+ # stdout_s, status = Open3.capture2('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326047 exit 0>]
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
#
- # stdout_str, status = Open3.capture2([env,] cmd... [, opts])
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture2:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
+ #
+ # Open3.capture2('tee', stdin_data: 'Foo')
+ #
+ # # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
+ #
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", #<Process::Status: pid 2326131 exit 0>]
+ # Open3.capture2('echo') # Built-in.
+ # # => ["\n", #<Process::Status: pid 2326139 exit 0>]
+ # Open3.capture2('date > date.tmp') # Contains meta character.
+ # # => ["", #<Process::Status: pid 2326174 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture2('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # # factor is a command for integer factorization.
- # o, s = Open3.capture2("factor", :stdin_data=>"42")
- # p o #=> "42: 2 3 7\n"
- #
- # # generate x**2 graph in png using gnuplot.
- # gnuplot_commands = <<"End"
- # set terminal png
- # plot x**2, "-" with lines
- # 1 14
- # 2 1
- # 3 8
- # 4 5
- # e
- # End
- # image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
+ # Open3.capture2('/usr/bin/date')
+ # # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #<Process::Status: pid 2326222 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture2('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture2('echo', 'C #')
+ # # => ["C #\n", #<Process::Status: pid 2326267 exit 0>]
+ # Open3.capture2('echo', 'hello', 'world')
+ # # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
#
def capture2(*cmd)
if Hash === cmd.last
@@ -370,21 +804,100 @@ module Open3
end
module_function :capture2
- # Open3.capture2e captures the standard output and the standard error of a command.
+ # :call-seq:
+ # Open3.capture2e([env, ] command_line, options = {}) -> [stdout_and_stderr_s, status]
+ # Open3.capture2e([env, ] exe_path, *args, options = {}) -> [stdout_and_stderr_s, status]
+ #
+ # Basically a wrapper for Open3.popen3 that:
+ #
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as string +stdout_and_stderr_s+ the merged standard output
+ # and standard error of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
+ #
+ # Returns the array <tt>[stdout_and_stderr_s, status]</tt>:
+ #
+ # stdout_and_stderr_s, status = Open3.capture2e('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2371692 exit 0>]
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture2e:
+ #
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
#
- # stdout_and_stderr_str, status = Open3.capture2e([env,] cmd... [, opts])
+ # Open3.capture2e('tee', stdin_data: 'Foo')
+ # # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # The single required argument is one of the following:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", #<Process::Status: pid 2371740 exit 0>]
+ # Open3.capture2e('echo') # Built-in.
+ # # => ["\n", #<Process::Status: pid 2371774 exit 0>]
+ # Open3.capture2e('date > date.tmp') # Contains meta character.
+ # # => ["", #<Process::Status: pid 2371812 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture2e('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # # capture make log
- # make_log, s = Open3.capture2e("make")
+ # Open3.capture2e('/usr/bin/date')
+ # # => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #<Process::Status: pid 2371820 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture2e('echo', 'C #')
+ # # => ["C #\n", #<Process::Status: pid 2371856 exit 0>]
+ # Open3.capture2e('echo', 'hello', 'world')
+ # # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
#
def capture2e(*cmd)
if Hash === cmd.last
@@ -418,48 +931,86 @@ module Open3
end
module_function :capture2e
- # Open3.pipeline_rw starts a list of commands as a pipeline with pipes
- # which connect to stdin of the first command and stdout of the last command.
- #
- # Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads|
- # ...
- # }
+ # :call-seq:
+ # Open3.pipeline_rw([env, ] *cmds, options = {}) -> [first_stdin, last_stdout, wait_threads]
#
- # first_stdin, last_stdout, wait_threads = Open3.pipeline_rw(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
- # last_stdout.close
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the first child, from the caller's +stdin+,
+ # or, for the last child, to the caller's +stdout+.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # Note that env and opts are optional, as for Process.spawn.
+ # With no block given, returns a 3-element array containing:
#
- # The options to pass to Process.spawn are constructed by merging
- # +opts+, the last hash element of the array, and
- # specifications for the pipes between each of the commands.
+ # - The +stdin+ stream of the first child process.
+ # - The +stdout+ stream of the last child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_rw("tr -dc A-Za-z", "wc -c") {|i, o, ts|
- # i.puts "All persons more than a mile high to leave the court."
- # i.close
- # p o.gets #=> "42\n"
- # }
- #
- # Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
- # stdin.puts "foo"
- # stdin.puts "bar"
- # stdin.puts "baz"
- # stdin.close # send EOF to sort.
- # p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
- # }
+ # first_stdin, last_stdout, wait_threads = Open3.pipeline_rw('sort', 'cat -n')
+ # # => [#<IO:fd 20>, #<IO:fd 21>, [#<Process::Waiter:0x000055e8de29ab40 sleep>, #<Process::Waiter:0x000055e8de29a690 sleep>]]
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # With a block given, calls the block with the +stdin+ stream of the first child,
+ # the +stdout+ stream of the last child,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_rw('sort', 'cat -n') do |first_stdin, last_stdout, wait_threads|
+ # first_stdin.puts "foo\nbar\nbaz"
+ # first_stdin.close # send EOF to sort.
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
+ #
def pipeline_rw(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
@@ -478,43 +1029,77 @@ module Open3
end
module_function :pipeline_rw
- # Open3.pipeline_r starts a list of commands as a pipeline with a pipe
- # which connects to stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline_r([env, ] *cmds, options = {}) -> [last_stdout, wait_threads]
#
- # Open3.pipeline_r(cmd1, cmd2, ... [, opts]) {|last_stdout, wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # last_stdout, wait_threads = Open3.pipeline_r(cmd1, cmd2, ... [, opts])
- # ...
- # last_stdout.close
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the last child, to the caller's +stdout+.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # With no block given, returns a 2-element array containing:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # - The +stdout+ stream of the last child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_r("zcat /var/log/apache2/access.log.*.gz",
- # [{"LANG"=>"C"}, "grep", "GET /favicon.ico"],
- # "logresolve") {|o, ts|
- # o.each_line {|line|
- # ...
- # }
- # }
+ # last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R')
+ # # => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]]
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # With a block given, calls the block with the +stdout+ stream
+ # of the last child process,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads|
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
- # Open3.pipeline_r("yes", "head -10") {|o, ts|
- # p o.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"
- # p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)>
- # p ts[1].value #=> #<Process::Status: pid 24913 exit 0>
- # }
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_r(*cmds, &block)
if Hash === cmds.last
@@ -530,33 +1115,82 @@ module Open3
end
module_function :pipeline_r
- # Open3.pipeline_w starts a list of commands as a pipeline with a pipe
- # which connects to stdin of the first command.
+
+ # :call-seq:
+ # Open3.pipeline_w([env, ] *cmds, options = {}) -> [first_stdin, wait_threads]
#
- # Open3.pipeline_w(cmd1, cmd2, ... [, opts]) {|first_stdin, wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # first_stdin, wait_threads = Open3.pipeline_w(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the first child, pipes the caller's +stdout+ to the child's +stdin+.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # With no block given, returns a 2-element array containing:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # - The +stdin+ stream of the first child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_w("bzip2 -c", :out=>"/tmp/hello.bz2") {|i, ts|
- # i.puts "hello"
- # }
+ # first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n')
+ # # => [#<IO:fd 7>, [#<Process::Waiter:0x000055e8de928278 run>, #<Process::Waiter:0x000055e8de923e80 run>]]
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # With a block given, calls the block with the +stdin+ stream
+ # of the first child process,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads|
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_w(*cmds, &block)
if Hash === cmds.last
@@ -573,49 +1207,67 @@ module Open3
end
module_function :pipeline_w
- # Open3.pipeline_start starts a list of commands as a pipeline.
- # No pipes are created for stdin of the first command and
- # stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline_start([env, ] *cmds, options = {}) -> [wait_threads]
#
- # Open3.pipeline_start(cmd1, cmd2, ... [, opts]) {|wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # wait_threads = Open3.pipeline_start(cmd1, cmd2, ... [, opts])
- # ...
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Does not wait for child processes to exit.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # With no block given, returns an array of the wait threads
+ # for all of the child processes.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # Example:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # wait_threads = Open3.pipeline_start('ls', 'grep R')
+ # # => [#<Process::Waiter:0x000055e8de9d2bb0 run>, #<Process::Waiter:0x000055e8de9d2890 run>]
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
#
- # Example:
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # With a block given, calls the block with an array of the wait processes:
+ #
+ # Open3.pipeline_start('ls', 'grep R') do |wait_threads|
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
#
- # # Run xeyes in 10 seconds.
- # Open3.pipeline_start("xeyes") {|ts|
- # sleep 10
- # t = ts[0]
- # Process.kill("TERM", t.pid)
- # p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)>
- # }
- #
- # # Convert pdf to ps and send it to a printer.
- # # Collect error message of pdftops and lpr.
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # err_r, err_w = IO.pipe
- # Open3.pipeline_start(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"],
- # :err=>err_w) {|ts|
- # err_w.close
- # p err_r.read # error messages of pdftops and lpr.
- # }
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_start(*cmds, &block)
if Hash === cmds.last
@@ -633,57 +1285,51 @@ module Open3
end
module_function :pipeline_start
- # Open3.pipeline starts a list of commands as a pipeline.
- # It waits for the completion of the commands.
- # No pipes are created for stdin of the first command and
- # stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline([env, ] *cmds, options = {}) -> array_of_statuses
#
- # status_list = Open3.pipeline(cmd1, cmd2, ... [, opts])
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the last child, to the caller's +stdout+.
+ # - Waits for the child processes to exit.
+ # - Returns an array of Process::Status objects (one for each child).
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # Example:
#
- # Note that env and opts are optional, as Process.spawn.
+ # wait_threads = Open3.pipeline('ls', 'grep R')
+ # # => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]
#
- # Example:
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn'
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
#
- # fname = "/usr/share/man/man1/ruby.1.gz"
- # p Open3.pipeline(["zcat", fname], "nroff -man", "less")
- # #=> [#<Process::Status: pid 11817 exit 0>,
- # # #<Process::Status: pid 11820 exit 0>,
- # # #<Process::Status: pid 11828 exit 0>]
- #
- # fname = "/usr/share/man/man1/ls.1.gz"
- # Open3.pipeline(["zcat", fname], "nroff -man", "colcrt")
- #
- # # convert PDF to PS and send to a printer by lpr
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # Open3.pipeline(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"])
- #
- # # count lines
- # Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count")
- #
- # # cyclic pipeline
- # r,w = IO.pipe
- # w.print "ibase=14\n10\n"
- # Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w)
- # #=> 14
- # # 18
- # # 22
- # # 30
- # # 42
- # # 58
- # # 78
- # # 106
- # # 202
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline(*cmds)
if Hash === cmds.last
diff --git a/lib/open3/open3.gemspec b/lib/open3/open3.gemspec
index a33fca7444..21980decac 100644
--- a/lib/open3/open3.gemspec
+++ b/lib/open3/open3.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/open3/version.rb b/lib/open3/version.rb
index b6b6ee2c9c..322dd71e2a 100644
--- a/lib/open3/version.rb
+++ b/lib/open3/version.rb
@@ -1,3 +1,4 @@
module Open3
- VERSION = "0.1.2"
+ # The version string
+ VERSION = "0.2.1"
end
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 7e0479bfff..97178e284b 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -7,7 +7,7 @@
#
# See OptionParser for documentation.
#
-
+require 'set' unless defined?(Set)
#--
# == Developer Documentation (not for RDoc output)
@@ -48,7 +48,7 @@
#
# == OptionParser
#
-# === New to \OptionParser?
+# === New to +OptionParser+?
#
# See the {Tutorial}[optparse/tutorial.rdoc].
#
@@ -143,7 +143,7 @@
# Used:
#
# $ ruby optparse-test.rb -r
-# optparse-test.rb:9:in `<main>': missing argument: -r (OptionParser::MissingArgument)
+# optparse-test.rb:9:in '<main>': missing argument: -r (OptionParser::MissingArgument)
# $ ruby optparse-test.rb -r my-library
# You required my-library!
#
@@ -152,14 +152,14 @@
# OptionParser supports the ability to coerce command line arguments
# into objects for us.
#
-# OptionParser comes with a few ready-to-use kinds of type
+# OptionParser comes with a few ready-to-use kinds of type
# coercion. They are:
#
-# - Date -- Anything accepted by +Date.parse+
-# - DateTime -- Anything accepted by +DateTime.parse+
-# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+
-# - URI -- Anything accepted by +URI.parse+
-# - Shellwords -- Anything accepted by +Shellwords.shellwords+
+# - Date -- Anything accepted by +Date.parse+ (need to require +optparse/date+)
+# - DateTime -- Anything accepted by +DateTime.parse+ (need to require +optparse/date+)
+# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+ (need to require +optparse/time+)
+# - URI -- Anything accepted by +URI.parse+ (need to require +optparse/uri+)
+# - Shellwords -- Anything accepted by +Shellwords.shellwords+ (need to require +optparse/shellwords+)
# - String -- Any non-empty string
# - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
# - Float -- Any float. (e.g. 10, 3.14, -100E+13)
@@ -236,7 +236,7 @@
# $ ruby optparse-test.rb --user 2
# #<struct User id=2, name="Gandalf">
# $ ruby optparse-test.rb --user 3
-# optparse-test.rb:15:in `block in find_user': No User Found for id 3 (RuntimeError)
+# optparse-test.rb:15:in 'block in find_user': No User Found for id 3 (RuntimeError)
#
# === Store options to a Hash
#
@@ -425,7 +425,10 @@
# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
#
class OptionParser
- OptionParser::Version = "0.4.0.pre.1"
+ # The version string
+ VERSION = "0.8.1"
+ # An alias for compatibility
+ Version = VERSION
# :stopdoc:
NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
@@ -438,6 +441,8 @@ class OptionParser
# and resolved against a list of acceptable values.
#
module Completion
+ # :nodoc:
+
def self.regexp(key, icase)
Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
end
@@ -459,11 +464,14 @@ class OptionParser
candidates
end
- def candidate(key, icase = false, pat = nil)
+ def self.completable?(key)
+ String.try_convert(key) or defined?(key.id2name)
+ end
+
+ def candidate(key, icase = false, pat = nil, &_)
Completion.candidate(key, icase, pat, &method(:each))
end
- public
def complete(key, icase = false, pat = nil)
candidates = candidate(key, icase, pat, &method(:each)).sort_by {|k, v, kn| kn.size}
if candidates.size == 1
@@ -494,7 +502,6 @@ class OptionParser
end
end
-
#
# Map from option/keyword string to object with completion.
#
@@ -502,7 +509,6 @@ class OptionParser
include Completion
end
-
#
# Individual switch class. Not important to the user.
#
@@ -510,6 +516,8 @@ class OptionParser
# RequiredArgument, etc.
#
class Switch
+ # :nodoc:
+
attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
#
@@ -542,18 +550,18 @@ class OptionParser
def initialize(pattern = nil, conv = nil,
short = nil, long = nil, arg = nil,
- desc = ([] if short or long), block = nil, &_block)
+ desc = ([] if short or long), block = nil, values = nil, &_block)
raise if Array === pattern
block ||= _block
- @pattern, @conv, @short, @long, @arg, @desc, @block =
- pattern, conv, short, long, arg, desc, block
+ @pattern, @conv, @short, @long, @arg, @desc, @block, @values =
+ pattern, conv, short, long, arg, desc, block, values
end
#
# Parses +arg+ and returns rest of +arg+ and matched portion to the
# argument pattern. Yields when the pattern doesn't match substring.
#
- def parse_arg(arg) # :nodoc:
+ private def parse_arg(arg) # :nodoc:
pattern or return nil, [arg]
unless m = pattern.match(arg)
yield(InvalidArgument, arg)
@@ -571,22 +579,24 @@ class OptionParser
yield(InvalidArgument, arg) # didn't match whole arg
return arg[s.length..-1], m
end
- private :parse_arg
#
# Parses argument, converts and returns +arg+, +block+ and result of
# conversion. Yields at semi-error condition instead of raising an
# exception.
#
- def conv_arg(arg, val = []) # :nodoc:
+ private def conv_arg(arg, val = []) # :nodoc:
+ v, = *val
if conv
val = conv.call(*val)
else
val = proc {|v| v}.call(*val)
end
+ if @values
+ @values.include?(val) or raise InvalidArgument, v
+ end
return arg, block, val
end
- private :conv_arg
#
# Produces the summary text. Each line of the summary is yielded to the
@@ -664,7 +674,7 @@ class OptionParser
(sopts+lopts).each do |opt|
# "(-x -c -r)-l[left justify]"
- if /^--\[no-\](.+)$/ =~ opt
+ if /\A--\[no-\](.+)$/ =~ opt
o = $1
yield("--#{o}", desc.join(""))
yield("--no-#{o}", desc.join(""))
@@ -697,6 +707,11 @@ class OptionParser
q.object_group(self) {pretty_print_contents(q)}
end
+ def omitted_argument(val) # :nodoc:
+ val.pop if val.size == 3 and val.last.nil?
+ val
+ end
+
#
# Switch that takes no arguments.
#
@@ -710,10 +725,10 @@ class OptionParser
conv_arg(arg)
end
- def self.incompatible_argument_styles(*)
+ def self.incompatible_argument_styles(*) # :nodoc:
end
- def self.pattern
+ def self.pattern # :nodoc:
Object
end
@@ -730,7 +745,7 @@ class OptionParser
#
# Raises an exception if argument is not present.
#
- def parse(arg, argv)
+ def parse(arg, argv, &_)
unless arg
raise MissingArgument if argv.empty?
arg = argv.shift
@@ -755,7 +770,7 @@ class OptionParser
if arg
conv_arg(*parse_arg(arg, &error))
else
- conv_arg(arg)
+ omitted_argument conv_arg(arg)
end
end
@@ -774,13 +789,14 @@ class OptionParser
#
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
- return nil, block, nil
+ return nil, block
end
opt = (val = parse_arg(val, &error))[1]
val = conv_arg(*val)
if opt and !arg
argv.shift
else
+ omitted_argument val
val[0] = nil
end
val
@@ -798,6 +814,8 @@ class OptionParser
# matching pattern and converter pair. Also provides summary feature.
#
class List
+ # :nodoc:
+
# Map from acceptable argument types to pattern and converter pairs.
attr_reader :atype
@@ -837,7 +855,7 @@ class OptionParser
def accept(t, pat = /.*/m, &block)
if pat
pat.respond_to?(:match) or
- raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
+ raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
else
pat = t if t.respond_to?(:match)
end
@@ -862,14 +880,13 @@ class OptionParser
# +lopts+:: Long style option list.
# +nlopts+:: Negated long style options list.
#
- def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
+ private def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
sopts.each {|o| @short[o] = sw} if sopts
lopts.each {|o| @long[o] = sw} if lopts
nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
used = @short.invert.update(@long.invert)
@list.delete_if {|o| Switch === o and !used[o]}
end
- private :update
#
# Inserts +switch+ at the head of the list, and associates short, long
@@ -1020,7 +1037,6 @@ class OptionParser
DefaultList.short['-'] = Switch::NoArgument.new {}
DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
-
COMPSYS_HEADER = <<'XXX' # :nodoc:
typeset -A opt_args
@@ -1033,11 +1049,31 @@ XXX
to << "#compdef #{name}\n"
to << COMPSYS_HEADER
visit(:compsys, {}, {}) {|o, d|
- to << %Q[ "#{o}[#{d.gsub(/[\"\[\]]/, '\\\\\&')}]" \\\n]
+ to << %Q[ "#{o}[#{d.gsub(/[\\\"\[\]]/, '\\\\\&')}]" \\\n]
}
to << " '*:file:_files' && return 0\n"
end
+ def help_exit
+ if $stdout.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?})
+ less = ENV["LESS"]
+ args = [{"LESS" => "#{less} -Fe"}, pager, "w"]
+ print = proc do |f|
+ f.puts help
+ rescue Errno::EPIPE
+ # pager terminated
+ end
+ if Process.respond_to?(:fork) and false
+ IO.popen("-") {|f| f ? Process.exec(*args, in: f) : print.call($stdout)}
+ # unreachable
+ end
+ IO.popen(*args, &print)
+ else
+ puts help
+ end
+ exit
+ end
+
#
# Default options for ARGV, which never appear in option summary.
#
@@ -1049,8 +1085,7 @@ XXX
#
Officious['help'] = proc do |parser|
Switch::NoArgument.new do |arg|
- puts parser.help
- exit
+ parser.help_exit
end
end
@@ -1071,7 +1106,7 @@ XXX
#
Officious['*-completion-zsh'] = proc do |parser|
Switch::OptionalArgument.new do |arg|
- parser.compsys(STDOUT, arg)
+ parser.compsys($stdout, arg)
exit
end
end
@@ -1084,7 +1119,7 @@ XXX
Switch::OptionalArgument.new do |pkg|
if pkg
begin
- require 'optparse/version'
+ require_relative 'optparse/version'
rescue LoadError
else
show_version(*pkg.split(/,/)) or
@@ -1129,6 +1164,10 @@ XXX
default.to_i + 1
end
end
+
+ #
+ # See self.inc
+ #
def inc(*args)
self.class.inc(*args)
end
@@ -1167,11 +1206,19 @@ XXX
def terminate(arg = nil)
self.class.terminate(arg)
end
+ #
+ # See #terminate.
+ #
def self.terminate(arg = nil)
throw :terminate, arg
end
@stack = [DefaultList]
+ #
+ # Returns the global top option list.
+ #
+ # Do not use directly.
+ #
def self.top() DefaultList end
#
@@ -1192,9 +1239,9 @@ XXX
#
# Directs to reject specified class argument.
#
- # +t+:: Argument class specifier, any object including Class.
+ # +type+:: Argument class specifier, any object including Class.
#
- # reject(t)
+ # reject(type)
#
def reject(*args, &blk) top.reject(*args, &blk) end
#
@@ -1245,7 +1292,15 @@ XXX
# to $0.
#
def program_name
- @program_name || File.basename($0, '.*')
+ @program_name || strip_ext(File.basename($0))
+ end
+
+ private def strip_ext(name) # :nodoc:
+ exts = /#{
+ require "rbconfig"
+ Regexp.union(*RbConfig::CONFIG["EXECUTABLE_EXTS"]&.split(" "))
+ }\z/o
+ name.sub(exts, "")
end
# for experimental cascading :-)
@@ -1284,10 +1339,24 @@ XXX
end
end
+ #
+ # Shows warning message with the program name
+ #
+ # +mesg+:: Message, defaulted to +$!+.
+ #
+ # See Kernel#warn.
+ #
def warn(mesg = $!)
super("#{program_name}: #{mesg}")
end
+ #
+ # Shows message with the program name then aborts.
+ #
+ # +mesg+:: Message, defaulted to +$!+.
+ #
+ # See Kernel#abort.
+ #
def abort(mesg = $!)
super("#{program_name}: #{mesg}")
end
@@ -1309,6 +1378,9 @@ XXX
#
# Pushes a new List.
#
+ # If a block is given, yields +self+ and returns the result of the
+ # block, otherwise returns +self+.
+ #
def new
@stack.push(List.new)
if block_given?
@@ -1383,14 +1455,13 @@ XXX
# +prv+:: Previously specified argument.
# +msg+:: Exception message.
#
- def notwice(obj, prv, msg) # :nodoc:
+ private def notwice(obj, prv, msg) # :nodoc:
unless !prv or prv == obj
raise(ArgumentError, "argument #{msg} given twice: #{obj}",
ParseError.filter_backtrace(caller(2)))
end
obj
end
- private :notwice
SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a} # :nodoc:
@@ -1407,6 +1478,7 @@ XXX
klass = nil
q, a = nil
has_arg = false
+ values = nil
opts.each do |o|
# argument class
@@ -1420,7 +1492,7 @@ XXX
end
# directly specified pattern(any object possible to match)
- if (!(String === o || Symbol === o)) and o.respond_to?(:match)
+ if !Completion.completable?(o) and o.respond_to?(:match)
pattern = notwice(o, pattern, 'pattern')
if pattern.respond_to?(:convert)
conv = pattern.method(:convert).to_proc
@@ -1434,7 +1506,12 @@ XXX
case o
when Proc, Method
block = notwice(o, block, 'block')
- when Array, Hash
+ when Array, Hash, Set
+ if Array === o
+ o, v = o.partition {|v,| Completion.completable?(v)}
+ values = notwice(v, values, 'values') unless v.empty?
+ next if o.empty?
+ end
case pattern
when CompletingHash
when nil
@@ -1444,11 +1521,13 @@ XXX
raise ArgumentError, "argument pattern given twice"
end
o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
+ when Range
+ values = notwice(o, values, 'values')
when Module
raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4))
when *ArgumentStyle.keys
style = notwice(ArgumentStyle[o], style, 'style')
- when /^--no-([^\[\]=\s]*)(.+)?/
+ when /\A--no-([^\[\]=\s]*)(.+)?/
q, a = $1, $2
o = notwice(a ? Object : TrueClass, klass, 'type')
not_pattern, not_conv = search(:atype, o) unless not_style
@@ -1459,7 +1538,7 @@ XXX
(q = q.downcase).tr!('_', '-')
long << "no-#{q}"
nolong << q
- when /^--\[no-\]([^\[\]=\s]*)(.+)?/
+ when /\A--\[no-\]([^\[\]=\s]*)(.+)?/
q, a = $1, $2
o = notwice(a ? Object : TrueClass, klass, 'type')
if a
@@ -1472,7 +1551,7 @@ XXX
not_pattern, not_conv = search(:atype, FalseClass) unless not_style
not_style = Switch::NoArgument
nolong << "no-#{o}"
- when /^--([^\[\]=\s]*)(.+)?/
+ when /\A--([^\[\]=\s]*)(.+)?/
q, a = $1, $2
if a
o = notwice(NilClass, klass, 'type')
@@ -1482,7 +1561,7 @@ XXX
ldesc << "--#{q}"
(o = q.downcase).tr!('_', '-')
long << o
- when /^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
+ when /\A-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
q, a = $1, $2
o = notwice(Object, klass, 'type')
if a
@@ -1493,7 +1572,7 @@ XXX
end
sdesc << "-#{q}"
short << Regexp.new(q)
- when /^-(.)(.+)?/
+ when /\A-(.)(.+)?/
q, a = $1, $2
if a
o = notwice(NilClass, klass, 'type')
@@ -1502,7 +1581,7 @@ XXX
end
sdesc << "-#{q}"
short << q
- when /^=/
+ when /\A=/
style = notwice(default_style.guess(arg = o), style, 'style')
default_pattern, conv = search(:atype, Object) unless default_pattern
else
@@ -1511,12 +1590,18 @@ XXX
end
default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
+ if Range === values and klass
+ unless (!values.begin or klass === values.begin) and
+ (!values.end or klass === values.end)
+ raise ArgumentError, "range does not match class"
+ end
+ end
if !(short.empty? and long.empty?)
if has_arg and default_style == Switch::NoArgument
default_style = Switch::RequiredArgument
end
s = (style || default_style).new(pattern || default_pattern,
- conv, sdesc, ldesc, arg, desc, block)
+ conv, sdesc, ldesc, arg, desc, block, values)
elsif !block
if style or pattern
raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller)
@@ -1525,13 +1610,19 @@ XXX
else
short << pattern
s = (style || default_style).new(pattern,
- conv, nil, nil, arg, desc, block)
+ conv, nil, nil, arg, desc, block, values)
end
return s, short, long,
(not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
nolong
end
+ # ----
+ # Option definition phase methods
+ #
+ # These methods are used to define options, or to construct an
+ # OptionParser instance in other words.
+
# :call-seq:
# define(*params, &block)
#
@@ -1607,6 +1698,13 @@ XXX
top.append(string, nil, nil)
end
+ # ----
+ # Arguments parse phase methods
+ #
+ # These methods parse +argv+, convert, and store the results by
+ # calling handlers. As these methods do not modify +self+, +self+
+ # can be frozen.
+
#
# Parses command line arguments +argv+ in order. When a block is given,
# each non-option argument is yielded. When optional +into+ keyword
@@ -1616,21 +1714,21 @@ XXX
#
# Returns the rest of +argv+ left unparsed.
#
- def order(*argv, into: nil, &nonopt)
+ def order(*argv, **keywords, &nonopt)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- order!(argv, into: into, &nonopt)
+ order!(argv, **keywords, &nonopt)
end
#
# Same as #order, but removes switches destructively.
# Non-option arguments remain in +argv+.
#
- def order!(argv = default_argv, into: nil, &nonopt)
+ def order!(argv = default_argv, into: nil, **keywords, &nonopt)
setter = ->(name, val) {into[name.to_sym] = val} if into
- parse_in_order(argv, setter, &nonopt)
+ parse_in_order(argv, setter, **keywords, &nonopt)
end
- def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
+ private def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
opt, arg, val, rest = nil
nonopt ||= proc {|a| throw :terminate, a}
argv.unshift(arg) if arg = catch(:terminate) {
@@ -1641,19 +1739,24 @@ XXX
opt, rest = $1, $2
opt.tr!('_', '-')
begin
- sw, = complete(:long, opt, true)
- if require_exact && !sw.long.include?(arg)
- throw :terminate, arg unless raise_unknown
- raise InvalidOption, arg
+ if exact
+ sw, = search(:long, opt)
+ else
+ sw, = complete(:long, opt, true)
end
rescue ParseError
throw :terminate, arg unless raise_unknown
raise $!.set_option(arg, true)
+ else
+ unless sw
+ throw :terminate, arg unless raise_unknown
+ raise InvalidOption, arg
+ end
end
begin
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
- val = cb.call(val) if cb
- setter.call(sw.switch_name, val) if setter
+ val = callback!(cb, 1, val) if cb
+ callback!(setter, 2, sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, rest)
end
@@ -1671,7 +1774,7 @@ XXX
val = arg.delete_prefix('-')
has_arg = true
rescue InvalidOption
- raise if require_exact
+ raise if exact
# if no short options match, try completion with long
# options.
sw, = complete(:long, opt)
@@ -1691,8 +1794,8 @@ XXX
end
begin
argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-')
- val = cb.call(val) if cb
- setter.call(sw.switch_name, val) if setter
+ val = callback!(cb, 1, val) if cb
+ callback!(setter, 2, sw.switch_name, val) if setter
rescue ParseError
raise $!.set_option(arg, arg.length > 2)
end
@@ -1716,7 +1819,18 @@ XXX
argv
end
- private :parse_in_order
+
+ # Calls callback with _val_.
+ private def callback!(cb, max_arity, *args) # :nodoc:
+ args.compact!
+
+ if (size = args.size) < max_arity and cb.to_proc.lambda?
+ (arity = cb.arity) < 0 and arity = (1-arity)
+ arity = max_arity if arity > max_arity
+ args[arity - 1] = nil if arity > size
+ end
+ cb.call(*args)
+ end
#
# Parses command line arguments +argv+ in permutation mode and returns
@@ -1725,18 +1839,18 @@ XXX
# <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
# similar object).
#
- def permute(*argv, into: nil)
+ def permute(*argv, **keywords)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- permute!(argv, into: into)
+ permute!(argv, **keywords)
end
#
# Same as #permute, but removes switches destructively.
# Non-option arguments remain in +argv+.
#
- def permute!(argv = default_argv, into: nil)
+ def permute!(argv = default_argv, **keywords)
nonopts = []
- order!(argv, into: into, &nonopts.method(:<<))
+ order!(argv, **keywords) {|nonopt| nonopts << nonopt}
argv[0, 0] = nonopts
argv
end
@@ -1748,20 +1862,20 @@ XXX
# values are stored there via <code>[]=</code> method (so it can be Hash,
# or OpenStruct, or other similar object).
#
- def parse(*argv, into: nil)
+ def parse(*argv, **keywords)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- parse!(argv, into: into)
+ parse!(argv, **keywords)
end
#
# Same as #parse, but removes switches destructively.
# Non-option arguments remain in +argv+.
#
- def parse!(argv = default_argv, into: nil)
+ def parse!(argv = default_argv, **keywords)
if ENV.include?('POSIXLY_CORRECT')
- order!(argv, into: into)
+ order!(argv, **keywords)
else
- permute!(argv, into: into)
+ permute!(argv, **keywords)
end
end
@@ -1784,18 +1898,21 @@ XXX
# # params[:bar] = "x" # --bar x
# # params[:zot] = "z" # --zot Z
#
- def getopts(*args, symbolize_names: false)
+ def getopts(*args, symbolize_names: false, **keywords)
argv = Array === args.first ? args.shift : default_argv
single_options, *long_options = *args
result = {}
+ setter = (symbolize_names ?
+ ->(name, val) {result[name.to_sym] = val}
+ : ->(name, val) {result[name] = val})
single_options.scan(/(.)(:)?/) do |opt, val|
if val
- result[opt] = nil
+ setter[opt, nil]
define("-#{opt} VAL")
else
- result[opt] = false
+ setter[opt, false]
define("-#{opt}")
end
end if single_options
@@ -1804,16 +1921,16 @@ XXX
arg, desc = arg.split(';', 2)
opt, val = arg.split(':', 2)
if val
- result[opt] = val.empty? ? nil : val
+ setter[opt, (val unless val.empty?)]
define("--#{opt}=#{result[opt] || "VAL"}", *[desc].compact)
else
- result[opt] = false
+ setter[opt, false]
define("--#{opt}", *[desc].compact)
end
end
- parse_in_order(argv, result.method(:[]=))
- symbolize_names ? result.transform_keys(&:to_sym) : result
+ parse_in_order(argv, setter, **keywords)
+ result
end
#
@@ -1827,24 +1944,22 @@ XXX
# Traverses @stack, sending each element method +id+ with +args+ and
# +block+.
#
- def visit(id, *args, &block) # :nodoc:
+ private def visit(id, *args, &block) # :nodoc:
@stack.reverse_each do |el|
el.__send__(id, *args, &block)
end
nil
end
- private :visit
#
# Searches +key+ in @stack for +id+ hash and returns or yields the result.
#
- def search(id, key) # :nodoc:
+ private def search(id, key) # :nodoc:
block_given = block_given?
visit(:search, id, key) do |k|
return block_given ? yield(k) : k
end
end
- private :search
#
# Completes shortened long style option switch and returns pair of
@@ -1855,7 +1970,7 @@ XXX
# +icase+:: Search case insensitive if true.
# +pat+:: Optional pattern for completion.
#
- def complete(typ, opt, icase = false, *pat) # :nodoc:
+ private def complete(typ, opt, icase = false, *pat) # :nodoc:
if pat.empty?
search(typ, opt) {|sw| return [sw, opt]} # exact match or...
end
@@ -1863,9 +1978,8 @@ XXX
visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
}
exc = ambiguous ? AmbiguousOption : InvalidOption
- raise exc.new(opt, additional: self.method(:additional_message).curry[typ])
+ raise exc.new(opt, additional: proc {|o| additional_message(typ, o)})
end
- private :complete
#
# Returns additional info.
@@ -1881,6 +1995,9 @@ XXX
DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
end
+ #
+ # Return candidates for +word+.
+ #
def candidate(word)
list = []
case word
@@ -1922,26 +2039,34 @@ XXX
# The optional +into+ keyword argument works exactly like that accepted in
# method #parse.
#
- def load(filename = nil, into: nil)
+ def load(filename = nil, **keywords)
unless filename
basename = File.basename($0, '.*')
- return true if load(File.expand_path(basename, '~/.options'), into: into) rescue nil
+ return true if load(File.expand_path("~/.options/#{basename}"), **keywords) rescue nil
basename << ".options"
+ if !(xdg = ENV['XDG_CONFIG_HOME']) or xdg.empty?
+ # https://specifications.freedesktop.org/basedir-spec/latest/#variables
+ #
+ # If $XDG_CONFIG_HOME is either not set or empty, a default
+ # equal to $HOME/.config should be used.
+ xdg = ['~/.config', true]
+ end
return [
- # XDG
- ENV['XDG_CONFIG_HOME'],
- '~/.config',
+ xdg,
+
*ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR),
# Haiku
- '~/config/settings',
- ].any? {|dir|
+ ['~/config/settings', true],
+ ].any? {|dir, expand|
next if !dir or dir.empty?
- load(File.expand_path(basename, dir), into: into) rescue nil
+ filename = File.join(dir, basename)
+ filename = File.expand_path(filename) if expand
+ load(filename, **keywords) rescue nil
}
end
begin
- parse(*File.readlines(filename, chomp: true), into: into)
+ parse(*File.readlines(filename, chomp: true), **keywords)
true
rescue Errno::ENOENT, Errno::ENOTDIR
false
@@ -1954,10 +2079,10 @@ XXX
#
# +env+ defaults to the basename of the program.
#
- def environment(env = File.basename($0, '.*'))
+ def environment(env = File.basename($0, '.*'), **keywords)
env = ENV[env] || ENV[env.upcase] or return
require 'shellwords'
- parse(*Shellwords.shellwords(env))
+ parse(*Shellwords.shellwords(env), **keywords)
end
#
@@ -2123,6 +2248,7 @@ XXX
# Reason which caused the error.
Reason = 'parse error'
+ # :nodoc:
def initialize(*args, additional: nil)
@additional = additional
@arg0, = args
@@ -2142,9 +2268,10 @@ XXX
argv
end
+ DIR = File.join(__dir__, '')
def self.filter_backtrace(array)
unless $DEBUG
- array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
+ array.delete_if {|bt| bt.start_with?(DIR)}
end
array
end
@@ -2187,42 +2314,42 @@ XXX
# Raises when ambiguously completable string is encountered.
#
class AmbiguousOption < ParseError
- const_set(:Reason, 'ambiguous option')
+ Reason = 'ambiguous option' # :nodoc:
end
#
# Raises when there is an argument for a switch which takes no argument.
#
class NeedlessArgument < ParseError
- const_set(:Reason, 'needless argument')
+ Reason = 'needless argument' # :nodoc:
end
#
# Raises when a switch with mandatory argument has no argument.
#
class MissingArgument < ParseError
- const_set(:Reason, 'missing argument')
+ Reason = 'missing argument' # :nodoc:
end
#
# Raises when switch is undefined.
#
class InvalidOption < ParseError
- const_set(:Reason, 'invalid option')
+ Reason = 'invalid option' # :nodoc:
end
#
# Raises when the given argument does not match required format.
#
class InvalidArgument < ParseError
- const_set(:Reason, 'invalid argument')
+ Reason = 'invalid argument' # :nodoc:
end
#
# Raises when the given argument word can't be completed uniquely.
#
class AmbiguousArgument < InvalidArgument
- const_set(:Reason, 'ambiguous argument')
+ Reason = 'ambiguous argument' # :nodoc:
end
#
@@ -2273,19 +2400,19 @@ XXX
# Parses +self+ destructively in order and returns +self+ containing the
# rest arguments left unparsed.
#
- def order!(&blk) options.order!(self, &blk) end
+ def order!(**keywords, &blk) options.order!(self, **keywords, &blk) end
#
# Parses +self+ destructively in permutation mode and returns +self+
# containing the rest arguments left unparsed.
#
- def permute!() options.permute!(self) end
+ def permute!(**keywords) options.permute!(self, **keywords) end
#
# Parses +self+ destructively and returns +self+ containing the
# rest arguments left unparsed.
#
- def parse!() options.parse!(self) end
+ def parse!(**keywords) options.parse!(self, **keywords) end
#
# Substitution of getopts is possible as follows. Also see
@@ -2298,8 +2425,8 @@ XXX
# rescue OptionParser::ParseError
# end
#
- def getopts(*args, symbolize_names: false)
- options.getopts(self, *args, symbolize_names: symbolize_names)
+ def getopts(*args, symbolize_names: false, **keywords)
+ options.getopts(self, *args, symbolize_names: symbolize_names, **keywords)
end
#
@@ -2309,7 +2436,8 @@ XXX
super
obj.instance_eval {@optparse = nil}
end
- def initialize(*args)
+
+ def initialize(*args) # :nodoc:
super
@optparse = nil
end
@@ -2320,9 +2448,11 @@ XXX
# and DecimalNumeric. See Acceptable argument classes (in source code).
#
module Acceptables
- const_set(:DecimalInteger, OptionParser::DecimalInteger)
- const_set(:OctalInteger, OptionParser::OctalInteger)
- const_set(:DecimalNumeric, OptionParser::DecimalNumeric)
+ # :stopdoc:
+ DecimalInteger = OptionParser::DecimalInteger
+ OctalInteger = OptionParser::OctalInteger
+ DecimalNumeric = OptionParser::DecimalNumeric
+ # :startdoc:
end
end
diff --git a/lib/optparse/ac.rb b/lib/optparse/ac.rb
index 0953725e46..23fc740d10 100644
--- a/lib/optparse/ac.rb
+++ b/lib/optparse/ac.rb
@@ -1,7 +1,11 @@
# frozen_string_literal: false
require_relative '../optparse'
+#
+# autoconf-like options.
+#
class OptionParser::AC < OptionParser
+ # :stopdoc:
private
def _check_ac_args(name, block)
@@ -14,6 +18,7 @@ class OptionParser::AC < OptionParser
end
ARG_CONV = proc {|val| val.nil? ? true : val}
+ private_constant :ARG_CONV
def _ac_arg_enable(prefix, name, help_string, block)
_check_ac_args(name, block)
@@ -29,16 +34,27 @@ class OptionParser::AC < OptionParser
enable
end
+ # :startdoc:
+
public
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
+ #
+ # Appears as <tt>--enable-<i>name</i></tt> in help message.
def ac_arg_enable(name, help_string, &block)
_ac_arg_enable("enable", name, help_string, block)
end
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
+ #
+ # Appears as <tt>--disable-<i>name</i></tt> in help message.
def ac_arg_disable(name, help_string, &block)
_ac_arg_enable("disable", name, help_string, block)
end
+ # Define <tt>--with</tt> / <tt>--without</tt> style option
+ #
+ # Appears as <tt>--with-<i>name</i></tt> in help message.
def ac_arg_with(name, help_string, &block)
_check_ac_args(name, block)
diff --git a/lib/optparse/kwargs.rb b/lib/optparse/kwargs.rb
index 992aca467e..59a2f61544 100644
--- a/lib/optparse/kwargs.rb
+++ b/lib/optparse/kwargs.rb
@@ -7,12 +7,17 @@ class OptionParser
#
# :include: ../../doc/optparse/creates_option.rdoc
#
- def define_by_keywords(options, meth, **opts)
- meth.parameters.each do |type, name|
+ # Defines options which set in to _options_ for keyword parameters
+ # of _method_.
+ #
+ # Parameters for each keywords are given as elements of _params_.
+ #
+ def define_by_keywords(options, method, **params)
+ method.parameters.each do |type, name|
case type
when :key, :keyreq
op, cl = *(type == :key ? %w"[ ]" : ["", ""])
- define("--#{name}=#{op}#{name.upcase}#{cl}", *opts[name]) do |o|
+ define("--#{name}=#{op}#{name.upcase}#{cl}", *params[name]) do |o|
options[name] = o
end
end
diff --git a/lib/optparse/optparse.gemspec b/lib/optparse/optparse.gemspec
index a4287ddeee..885b0ec380 100644
--- a/lib/optparse/optparse.gemspec
+++ b/lib/optparse/optparse.gemspec
@@ -3,7 +3,7 @@
name = File.basename(__FILE__, ".gemspec")
version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*OptionParser::Version\s*=\s*"(.*)"/ =~ line and break $1
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
end rescue nil
end
@@ -14,7 +14,10 @@ Gem::Specification.new do |spec|
spec.email = ["nobu@ruby-lang.org"]
spec.summary = %q{OptionParser is a class for command-line option analysis.}
- spec.description = %q{OptionParser is a class for command-line option analysis.}
+ spec.description = File.open(File.join(__dir__, "README.md")) do |readme|
+ readme.gets("") # heading
+ readme.gets("").chomp
+ end rescue spec.summary
spec.homepage = "https://github.com/ruby/optparse"
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
@@ -22,8 +25,9 @@ Gem::Specification.new do |spec|
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
- spec.files = Dir["{doc,lib,misc}/**/*"] + %w[README.md ChangeLog COPYING]
- spec.rdoc_options = ["--main=README.md", "--op=rdoc", "--page-dir=doc"]
+ dir, gemspec = File.split(__FILE__)
+ excludes = %W[#{gemspec} rakelib test/ Gemfile Rakefile .git* .editor*].map {|n| ":^"+n}
+ spec.files = IO.popen(%w[git ls-files -z --] + excludes, chdir: dir, &:read).split("\x0")
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
diff --git a/lib/optparse/version.rb b/lib/optparse/version.rb
index b869d8fe51..b5ed695146 100644
--- a/lib/optparse/version.rb
+++ b/lib/optparse/version.rb
@@ -2,6 +2,11 @@
# OptionParser internal utility
class << OptionParser
+ #
+ # Shows version string in packages if Version is defined.
+ #
+ # +pkgs+:: package list
+ #
def show_version(*pkgs)
progname = ARGV.options.program_name
result = false
@@ -47,6 +52,8 @@ class << OptionParser
result
end
+ # :stopdoc:
+
def each_const(path, base = ::Object)
path.split(/::|\//).inject(base) do |klass, name|
raise NameError, path unless Module === klass
@@ -68,4 +75,6 @@ class << OptionParser
end
end
end
+
+ # :startdoc:
end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
deleted file mode 100644
index a08561d6c9..0000000000
--- a/lib/ostruct.rb
+++ /dev/null
@@ -1,477 +0,0 @@
-# frozen_string_literal: true
-#
-# = ostruct.rb: OpenStruct implementation
-#
-# Author:: Yukihiro Matsumoto
-# Documentation:: Gavin Sinclair
-#
-# OpenStruct allows the creation of data objects with arbitrary attributes.
-# See OpenStruct for an example.
-#
-
-#
-# An OpenStruct is a data structure, similar to a Hash, that allows the
-# definition of arbitrary attributes with their accompanying values. This is
-# accomplished by using Ruby's metaprogramming to define methods on the class
-# itself.
-#
-# == Examples
-#
-# require "ostruct"
-#
-# person = OpenStruct.new
-# person.name = "John Smith"
-# person.age = 70
-#
-# person.name # => "John Smith"
-# person.age # => 70
-# person.address # => nil
-#
-# An OpenStruct employs a Hash internally to store the attributes and values
-# and can even be initialized with one:
-#
-# australia = OpenStruct.new(:country => "Australia", :capital => "Canberra")
-# # => #<OpenStruct country="Australia", capital="Canberra">
-#
-# Hash keys with spaces or characters that could normally not be used for
-# method calls (e.g. <code>()[]*</code>) will not be immediately available
-# on the OpenStruct object as a method for retrieval or assignment, but can
-# still be reached through the Object#send method or using [].
-#
-# measurements = OpenStruct.new("length (in inches)" => 24)
-# measurements[:"length (in inches)"] # => 24
-# measurements.send("length (in inches)") # => 24
-#
-# message = OpenStruct.new(:queued? => true)
-# message.queued? # => true
-# message.send("queued?=", false)
-# message.queued? # => false
-#
-# Removing the presence of an attribute requires the execution of the
-# delete_field method as setting the property value to +nil+ will not
-# remove the attribute.
-#
-# first_pet = OpenStruct.new(:name => "Rowdy", :owner => "John Smith")
-# second_pet = OpenStruct.new(:name => "Rowdy")
-#
-# first_pet.owner = nil
-# first_pet # => #<OpenStruct name="Rowdy", owner=nil>
-# first_pet == second_pet # => false
-#
-# first_pet.delete_field(:owner)
-# first_pet # => #<OpenStruct name="Rowdy">
-# first_pet == second_pet # => true
-#
-# Ractor compatibility: A frozen OpenStruct with shareable values is itself shareable.
-#
-# == Caveats
-#
-# An OpenStruct utilizes Ruby's method lookup structure to find and define the
-# necessary methods for properties. This is accomplished through the methods
-# method_missing and define_singleton_method.
-#
-# This should be a consideration if there is a concern about the performance of
-# the objects that are created, as there is much more overhead in the setting
-# of these properties compared to using a Hash or a Struct.
-# Creating an open struct from a small Hash and accessing a few of the
-# entries can be 200 times slower than accessing the hash directly.
-#
-# This is a potential security issue; building OpenStruct from untrusted user data
-# (e.g. JSON web request) may be susceptible to a "symbol denial of service" attack
-# since the keys create methods and names of methods are never garbage collected.
-#
-# This may also be the source of incompatibilities between Ruby versions:
-#
-# o = OpenStruct.new
-# o.then # => nil in Ruby < 2.6, enumerator for Ruby >= 2.6
-#
-# Builtin methods may be overwritten this way, which may be a source of bugs
-# or security issues:
-#
-# o = OpenStruct.new
-# o.methods # => [:to_h, :marshal_load, :marshal_dump, :each_pair, ...
-# o.methods = [:foo, :bar]
-# o.methods # => [:foo, :bar]
-#
-# To help remedy clashes, OpenStruct uses only protected/private methods ending with <code>!</code>
-# and defines aliases for builtin public methods by adding a <code>!</code>:
-#
-# o = OpenStruct.new(make: 'Bentley', class: :luxury)
-# o.class # => :luxury
-# o.class! # => OpenStruct
-#
-# It is recommended (but not enforced) to not use fields ending in <code>!</code>;
-# Note that a subclass' methods may not be overwritten, nor can OpenStruct's own methods
-# ending with <code>!</code>.
-#
-# For all these reasons, consider not using OpenStruct at all.
-#
-class OpenStruct
- VERSION = "0.5.5"
-
- #
- # Creates a new OpenStruct object. By default, the resulting OpenStruct
- # object will have no attributes.
- #
- # The optional +hash+, if given, will generate attributes and values
- # (can be a Hash, an OpenStruct or a Struct).
- # For example:
- #
- # require "ostruct"
- # hash = { "country" => "Australia", :capital => "Canberra" }
- # data = OpenStruct.new(hash)
- #
- # data # => #<OpenStruct country="Australia", capital="Canberra">
- #
- def initialize(hash=nil)
- if hash
- update_to_values!(hash)
- else
- @table = {}
- end
- end
-
- # Duplicates an OpenStruct object's Hash table.
- private def initialize_clone(orig) # :nodoc:
- super # clones the singleton class for us
- @table = @table.dup unless @table.frozen?
- end
-
- private def initialize_dup(orig) # :nodoc:
- super
- update_to_values!(@table)
- end
-
- private def update_to_values!(hash) # :nodoc:
- @table = {}
- hash.each_pair do |k, v|
- set_ostruct_member_value!(k, v)
- end
- end
-
- #
- # call-seq:
- # ostruct.to_h -> hash
- # ostruct.to_h {|name, value| block } -> hash
- #
- # Converts the OpenStruct to a hash with keys representing
- # each attribute (as symbols) and their corresponding values.
- #
- # If a block is given, the results of the block on each pair of
- # the receiver will be used as pairs.
- #
- # require "ostruct"
- # data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
- # data.to_h # => {:country => "Australia", :capital => "Canberra" }
- # data.to_h {|name, value| [name.to_s, value.upcase] }
- # # => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
- #
- if {test: :to_h}.to_h{ [:works, true] }[:works] # RUBY_VERSION < 2.6 compatibility
- def to_h(&block)
- if block
- @table.to_h(&block)
- else
- @table.dup
- end
- end
- else
- def to_h(&block)
- if block
- @table.map(&block).to_h
- else
- @table.dup
- end
- end
- end
-
- #
- # :call-seq:
- # ostruct.each_pair {|name, value| block } -> ostruct
- # ostruct.each_pair -> Enumerator
- #
- # Yields all attributes (as symbols) along with the corresponding values
- # or returns an enumerator if no block is given.
- #
- # require "ostruct"
- # data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
- # data.each_pair.to_a # => [[:country, "Australia"], [:capital, "Canberra"]]
- #
- def each_pair
- return to_enum(__method__) { @table.size } unless defined?(yield)
- @table.each_pair{|p| yield p}
- self
- end
-
- #
- # Provides marshalling support for use by the Marshal library.
- #
- def marshal_dump # :nodoc:
- @table
- end
-
- #
- # Provides marshalling support for use by the Marshal library.
- #
- alias_method :marshal_load, :update_to_values! # :nodoc:
-
- #
- # Used internally to defined properties on the
- # OpenStruct. It does this by using the metaprogramming function
- # define_singleton_method for both the getter method and the setter method.
- #
- def new_ostruct_member!(name) # :nodoc:
- unless @table.key?(name) || is_method_protected!(name)
- if defined?(::Ractor)
- getter_proc = nil.instance_eval{ Proc.new { @table[name] } }
- setter_proc = nil.instance_eval{ Proc.new {|x| @table[name] = x} }
- ::Ractor.make_shareable(getter_proc)
- ::Ractor.make_shareable(setter_proc)
- else
- getter_proc = Proc.new { @table[name] }
- setter_proc = Proc.new {|x| @table[name] = x}
- end
- define_singleton_method!(name, &getter_proc)
- define_singleton_method!("#{name}=", &setter_proc)
- end
- end
- private :new_ostruct_member!
-
- private def is_method_protected!(name) # :nodoc:
- if !respond_to?(name, true)
- false
- elsif name.match?(/!$/)
- true
- else
- owner = method!(name).owner
- if owner.class == ::Class
- owner < ::OpenStruct
- else
- self.class!.ancestors.any? do |mod|
- return false if mod == ::OpenStruct
- mod == owner
- end
- end
- end
- end
-
- def freeze
- @table.freeze
- super
- end
-
- private def method_missing(mid, *args) # :nodoc:
- len = args.length
- if mname = mid[/.*(?==\z)/m]
- if len != 1
- raise! ArgumentError, "wrong number of arguments (given #{len}, expected 1)", caller(1)
- end
- set_ostruct_member_value!(mname, args[0])
- elsif len == 0
- @table[mid]
- else
- begin
- super
- rescue NoMethodError => err
- err.backtrace.shift
- raise!
- end
- end
- end
-
- #
- # :call-seq:
- # ostruct[name] -> object
- #
- # Returns the value of an attribute, or +nil+ if there is no such attribute.
- #
- # require "ostruct"
- # person = OpenStruct.new("name" => "John Smith", "age" => 70)
- # person[:age] # => 70, same as person.age
- #
- def [](name)
- @table[name.to_sym]
- end
-
- #
- # :call-seq:
- # ostruct[name] = obj -> obj
- #
- # Sets the value of an attribute.
- #
- # require "ostruct"
- # person = OpenStruct.new("name" => "John Smith", "age" => 70)
- # person[:age] = 42 # equivalent to person.age = 42
- # person.age # => 42
- #
- def []=(name, value)
- name = name.to_sym
- new_ostruct_member!(name)
- @table[name] = value
- end
- alias_method :set_ostruct_member_value!, :[]=
- private :set_ostruct_member_value!
-
- # :call-seq:
- # ostruct.dig(name, *identifiers) -> object
- #
- # Finds and returns the object in nested objects
- # that is specified by +name+ and +identifiers+.
- # The nested objects may be instances of various classes.
- # See {Dig Methods}[rdoc-ref:dig_methods.rdoc].
- #
- # Examples:
- # require "ostruct"
- # address = OpenStruct.new("city" => "Anytown NC", "zip" => 12345)
- # person = OpenStruct.new("name" => "John Smith", "address" => address)
- # person.dig(:address, "zip") # => 12345
- # person.dig(:business_address, "zip") # => nil
- def dig(name, *names)
- begin
- name = name.to_sym
- rescue NoMethodError
- raise! TypeError, "#{name} is not a symbol nor a string"
- end
- @table.dig(name, *names)
- end
-
- #
- # Removes the named field from the object and returns the value the field
- # contained if it was defined. You may optionally provide a block.
- # If the field is not defined, the result of the block is returned,
- # or a NameError is raised if no block was given.
- #
- # require "ostruct"
- #
- # person = OpenStruct.new(name: "John", age: 70, pension: 300)
- #
- # person.delete_field!("age") # => 70
- # person # => #<OpenStruct name="John", pension=300>
- #
- # Setting the value to +nil+ will not remove the attribute:
- #
- # person.pension = nil
- # person # => #<OpenStruct name="John", pension=nil>
- #
- # person.delete_field('number') # => NameError
- #
- # person.delete_field('number') { 8675_309 } # => 8675309
- #
- def delete_field(name, &block)
- sym = name.to_sym
- begin
- singleton_class.remove_method(sym, "#{sym}=")
- rescue NameError
- end
- @table.delete(sym) do
- return yield if block
- raise! NameError.new("no field `#{sym}' in #{self}", sym)
- end
- end
-
- InspectKey = :__inspect_key__ # :nodoc:
-
- #
- # Returns a string containing a detailed summary of the keys and values.
- #
- def inspect
- ids = (Thread.current[InspectKey] ||= [])
- if ids.include?(object_id)
- detail = ' ...'
- else
- ids << object_id
- begin
- detail = @table.map do |key, value|
- " #{key}=#{value.inspect}"
- end.join(',')
- ensure
- ids.pop
- end
- end
- ['#<', self.class!, detail, '>'].join
- end
- alias :to_s :inspect
-
- attr_reader :table # :nodoc:
- alias table! table
- protected :table!
-
- #
- # Compares this object and +other+ for equality. An OpenStruct is equal to
- # +other+ when +other+ is an OpenStruct and the two objects' Hash tables are
- # equal.
- #
- # require "ostruct"
- # first_pet = OpenStruct.new("name" => "Rowdy")
- # second_pet = OpenStruct.new(:name => "Rowdy")
- # third_pet = OpenStruct.new("name" => "Rowdy", :age => nil)
- #
- # first_pet == second_pet # => true
- # first_pet == third_pet # => false
- #
- def ==(other)
- return false unless other.kind_of?(OpenStruct)
- @table == other.table!
- end
-
- #
- # Compares this object and +other+ for equality. An OpenStruct is eql? to
- # +other+ when +other+ is an OpenStruct and the two objects' Hash tables are
- # eql?.
- #
- def eql?(other)
- return false unless other.kind_of?(OpenStruct)
- @table.eql?(other.table!)
- end
-
- # Computes a hash code for this OpenStruct.
- def hash # :nodoc:
- @table.hash
- end
-
- #
- # Provides marshalling support for use by the YAML library.
- #
- def encode_with(coder) # :nodoc:
- @table.each_pair do |key, value|
- coder[key.to_s] = value
- end
- if @table.size == 1 && @table.key?(:table) # support for legacy format
- # in the very unlikely case of a single entry called 'table'
- coder['legacy_support!'] = true # add a bogus second entry
- end
- end
-
- #
- # Provides marshalling support for use by the YAML library.
- #
- def init_with(coder) # :nodoc:
- h = coder.map
- if h.size == 1 # support for legacy format
- key, val = h.first
- if key == 'table'
- h = val
- end
- end
- update_to_values!(h)
- end
-
- # Make all public methods (builtin or our own) accessible with <code>!</code>:
- give_access = instance_methods
- # See https://github.com/ruby/ostruct/issues/30
- give_access -= %i[instance_exec instance_eval eval] if RUBY_ENGINE == 'jruby'
- give_access.each do |method|
- next if method.match(/\W$/)
-
- new_name = "#{method}!"
- alias_method new_name, method
- end
- # Other builtin private methods we use:
- alias_method :raise!, :raise
- private :raise!
-
- # See https://github.com/ruby/ostruct/issues/40
- if RUBY_ENGINE != 'jruby'
- alias_method :block_given!, :block_given?
- private :block_given!
- end
-end
diff --git a/lib/ostruct/ostruct.gemspec b/lib/ostruct/ostruct.gemspec
deleted file mode 100644
index 31ecc312c3..0000000000
--- a/lib/ostruct/ostruct.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Marc-Andre Lafortune"]
- spec.email = ["ruby-core@marc-andre.ca"]
-
- spec.summary = %q{Class to build custom data structures, similar to a Hash.}
- spec.description = %q{Class to build custom data structures, similar to a Hash.}
- spec.homepage = "https://github.com/ruby/ostruct"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = ">= 2.5.0"
-
- spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "ostruct.gemspec"]
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/pathname.rb b/lib/pathname.rb
new file mode 100644
index 0000000000..5474fb6358
--- /dev/null
+++ b/lib/pathname.rb
@@ -0,0 +1,97 @@
+# frozen_string_literal: true
+#
+# = pathname.rb
+#
+# Object-Oriented Pathname Class
+#
+# Author:: Tanaka Akira <akr@m17n.org>
+# Documentation:: Author and Gavin Sinclair
+#
+# For documentation, see class Pathname.
+#
+class Pathname # * Find *
+ #
+ # Iterates over the directory tree in a depth first manner, yielding a
+ # Pathname for each file under "this" directory.
+ #
+ # Note that you need to require 'pathname' to use this method.
+ #
+ # Returns an Enumerator if no block is given.
+ #
+ # Since it is implemented by the standard library module Find, Find.prune can
+ # be used to control the traversal.
+ #
+ # If +self+ is +.+, yielded pathnames begin with a filename in the
+ # current directory, not +./+.
+ #
+ # See Find.find
+ #
+ def find(ignore_error: true) # :yield: pathname
+ return to_enum(__method__, ignore_error: ignore_error) unless block_given?
+ require 'find'
+ if @path == '.'
+ Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.delete_prefix('./')) }
+ else
+ Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f) }
+ end
+ end
+end
+
+
+class Pathname # * FileUtils *
+ # Recursively deletes a directory, including all directories beneath it.
+ #
+ # Note that you need to require 'pathname' to use this method.
+ #
+ # See FileUtils.rm_rf
+ def rmtree(noop: nil, verbose: nil, secure: nil)
+ # The name "rmtree" is borrowed from File::Path of Perl.
+ # File::Path provides "mkpath" and "rmtree".
+ require 'fileutils'
+ FileUtils.rm_rf(@path, noop: noop, verbose: verbose, secure: secure)
+ self
+ end
+end
+
+class Pathname # * tmpdir *
+ # call-seq:
+ # Pathname.mktmpdir -> new_pathname
+ # Pathname.mktmpdir {|pathname| ... } -> object
+ #
+ # Creates:
+ #
+ # - A temporary directory via Dir.mktmpdir.
+ # - A \Pathname object that contains the path to that directory.
+ #
+ # With no block given, returns the created pathname;
+ # the caller should delete the created directory when it is no longer needed
+ # (FileUtils.rm_r is a convenient method for the deletion):
+ #
+ # pathname = Pathname.mktmpdir
+ # dirpath = pathname.to_s
+ # Dir.exist?(dirpath) # => true
+ # # Do something with the directory.
+ # require 'fileutils'
+ # FileUtils.rm_r(dirpath)
+ #
+ # With a block given, calls the block with the created pathname;
+ # on block exit, automatically deletes the created directory and all its contents;
+ # returns the block's exit value:
+ #
+ # pathname = Pathname.mktmpdir do |p|
+ # # Do something with the directory.
+ # p
+ # end
+ # Dir.exist?(pathname.to_s) # => false
+ def self.mktmpdir
+ require 'tmpdir' unless defined?(Dir.mktmpdir)
+ if block_given?
+ Dir.mktmpdir do |dir|
+ dir = self.new(dir)
+ yield dir
+ end
+ else
+ self.new(Dir.mktmpdir)
+ end
+ end
+end
diff --git a/lib/pp.gemspec b/lib/pp.gemspec
index 3f08f400c4..15a3b4dc6c 100644
--- a/lib/pp.gemspec
+++ b/lib/pp.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "pp"
- spec.version = "0.4.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
@@ -15,7 +22,8 @@ Gem::Specification.new do |spec|
spec.metadata["source_code_uri"] = spec.homepage
spec.files = %w[
- LICENSE.txt
+ BSDL
+ COPYING
lib/pp.rb
pp.gemspec
]
diff --git a/lib/pp.rb b/lib/pp.rb
index 81551aa116..5fd29a373a 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -46,6 +46,7 @@ require 'prettyprint'
#
# To define a customized pretty printing function for your classes,
# redefine method <code>#pretty_print(pp)</code> in the class.
+# Note that <code>require 'pp'</code> is needed before redefining <code>#pretty_print(pp)</code>.
#
# <code>#pretty_print</code> takes the +pp+ argument, which is an instance of the PP class.
# The method uses #text, #breakable, #nest, #group and #pp to print the
@@ -61,6 +62,10 @@ require 'prettyprint'
# Tanaka Akira <akr@fsij.org>
class PP < PrettyPrint
+
+ # The version string
+ VERSION = "0.6.3"
+
# Returns the usable width for +out+.
# As the width of +out+:
# 1. If +out+ is assigned to a tty device, its width is used.
@@ -89,7 +94,7 @@ class PP < PrettyPrint
#
# PP.pp returns +out+.
def PP.pp(obj, out=$>, width=width_for(out))
- q = PP.new(out, width)
+ q = new(out, width)
q.guard_inspect_key {q.pp obj}
q.flush
#$pp = q
@@ -134,26 +139,19 @@ class PP < PrettyPrint
end
end
+ # Module that defines helper methods for pretty_print.
module PPMethods
# Yields to a block
# and preserves the previous set of objects being printed.
def guard_inspect_key
- if Thread.current[:__recursive_key__] == nil
- Thread.current[:__recursive_key__] = {}.compare_by_identity
- end
-
- if Thread.current[:__recursive_key__][:inspect] == nil
- Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
- end
-
- save = Thread.current[:__recursive_key__][:inspect]
-
+ recursive_state = Thread.current[:__recursive_key__] ||= {}.compare_by_identity
+ save = recursive_state[:inspect] ||= {}.compare_by_identity
begin
- Thread.current[:__recursive_key__][:inspect] = {}.compare_by_identity
+ recursive_state[:inspect] = {}.compare_by_identity
yield
ensure
- Thread.current[:__recursive_key__][:inspect] = save
+ recursive_state[:inspect] = save
end
end
@@ -161,9 +159,8 @@ class PP < PrettyPrint
# to be pretty printed. Used to break cycles in chains of objects to be
# pretty printed.
def check_inspect_key(id)
- Thread.current[:__recursive_key__] &&
- Thread.current[:__recursive_key__][:inspect] &&
- Thread.current[:__recursive_key__][:inspect].include?(id)
+ recursive_state = Thread.current[:__recursive_key__] or return false
+ recursive_state[:inspect]&.include?(id)
end
# Adds the object_id +id+ to the set of objects being pretty printed, so
@@ -177,6 +174,24 @@ class PP < PrettyPrint
Thread.current[:__recursive_key__][:inspect].delete id
end
+ private def guard_inspect(object) # :nodoc:
+ recursive_state = Thread.current[:__recursive_key__]
+
+ if recursive_state&.key?(:inspect)
+ begin
+ push_inspect_key(object)
+ yield
+ ensure
+ pop_inspect_key(object) unless PP.sharing_detection
+ end
+ else
+ guard_inspect_key do
+ push_inspect_key(object)
+ yield
+ end
+ end
+ end
+
# Adds +obj+ to the pretty printing buffer
# using Object#pretty_print or Object#pretty_print_cycle.
#
@@ -185,18 +200,19 @@ class PP < PrettyPrint
def pp(obj)
# If obj is a Delegator then use the object being delegated to for cycle
# detection
- obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator)
+ obj = obj.__getobj__ if defined?(::Delegator) and ::Delegator === obj
if check_inspect_key(obj)
group {obj.pretty_print_cycle self}
return
end
- begin
- push_inspect_key(obj)
- group {obj.pretty_print self}
- ensure
- pop_inspect_key(obj) unless PP.sharing_detection
+ guard_inspect(obj) do
+ group do
+ obj.pretty_print self
+ rescue NoMethodError
+ text Kernel.instance_method(:inspect).bind_call(obj)
+ end
end
end
@@ -251,15 +267,20 @@ class PP < PrettyPrint
def seplist(list, sep=nil, iter_method=:each) # :yield: element
sep ||= lambda { comma_breakable }
first = true
+ kwsplat = EMPTY_KWHASH
list.__send__(iter_method) {|*v|
if first
first = false
else
sep.call
end
- RUBY_VERSION >= "3.0" ? yield(*v, **{}) : yield(*v)
+ kwsplat ? yield(*v, **kwsplat) : yield(*v)
}
end
+ EMPTY_KWHASH = if RUBY_VERSION >= "3.0" # :nodoc:
+ {}.freeze
+ end
+ private_constant :EMPTY_KWHASH
# A present standard failsafe for pretty printing any given Object
def pp_object(obj)
@@ -282,16 +303,40 @@ class PP < PrettyPrint
group(1, '{', '}') {
seplist(obj, nil, :each_pair) {|k, v|
group {
- pp k
- text '=>'
- group(1) {
- breakable ''
- pp v
- }
+ pp_hash_pair k, v
}
}
}
end
+
+ if RUBY_VERSION >= '3.4.'
+ # A pretty print for a pair of Hash
+ def pp_hash_pair(k, v)
+ if Symbol === k
+ if k.inspect.match?(%r[\A:["$@!]|[%&*+\-\/<=>@\]^`|~]\z])
+ k = k.to_s.inspect
+ end
+ text "#{k}:"
+ else
+ pp k
+ text ' '
+ text '=>'
+ end
+ group(1) {
+ breakable
+ pp v
+ }
+ end
+ else
+ def pp_hash_pair(k, v)
+ pp k
+ text '=>'
+ group(1) {
+ breakable ''
+ pp v
+ }
+ end
+ end
end
include PPMethods
@@ -343,7 +388,8 @@ class PP < PrettyPrint
# This method should return an array of names of instance variables as symbols or strings as:
# +[:@a, :@b]+.
def pretty_print_instance_variables
- instance_variables.sort
+ ivars = respond_to?(:instance_variables_to_inspect, true) ? instance_variables_to_inspect || instance_variables : instance_variables
+ ivars.sort
end
# Is #inspect implementation using #pretty_print.
@@ -386,6 +432,28 @@ class Hash # :nodoc:
end
end
+if defined?(Set)
+ if set_pp = Set.instance_method(:initialize).source_location
+ set_pp = !set_pp.first.end_with?("/set.rb") # not defined in set.rb
+ else
+ set_pp = true # defined in C
+ end
+end
+class Set # :nodoc:
+ def pretty_print(pp) # :nodoc:
+ pp.group(1, "#{self.class.name}[", ']') {
+ pp.seplist(self) { |o|
+ pp.pp o
+ }
+ }
+ end
+
+ def pretty_print_cycle(pp) # :nodoc:
+ name = self.class.name
+ pp.text(empty? ? "#{name}[]" : "#{name}[...]")
+ end
+end if set_pp
+
class << ENV # :nodoc:
def pretty_print(q) # :nodoc:
h = {}
@@ -416,16 +484,37 @@ class Struct # :nodoc:
end
end
+verbose, $VERBOSE = $VERBOSE, nil
+begin
+ has_data_define = defined?(Data.define)
+ensure
+ $VERBOSE = verbose
+end
+
class Data # :nodoc:
def pretty_print(q) # :nodoc:
- q.group(1, sprintf("#<data %s", PP.mcall(self, Kernel, :class).name), '>') {
- q.seplist(PP.mcall(self, Data, :members), lambda { q.text "," }) {|member|
+ class_name = PP.mcall(self, Kernel, :class).name
+ class_name = " #{class_name}" if class_name
+ q.group(1, "#<data#{class_name}", '>') {
+
+ members = PP.mcall(self, Kernel, :class).members
+ values = []
+ members.select! do |member|
+ begin
+ values << __send__(member)
+ true
+ rescue NoMethodError
+ false
+ end
+ end
+
+ q.seplist(members.zip(values), lambda { q.text "," }) {|(member, value)|
q.breakable
q.text member.to_s
q.text '='
q.group(1) {
q.breakable ''
- q.pp public_send(member)
+ q.pp value
}
}
}
@@ -434,15 +523,17 @@ class Data # :nodoc:
def pretty_print_cycle(q) # :nodoc:
q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
end
-end if "3.2" <= RUBY_VERSION
+end if has_data_define
class Range # :nodoc:
def pretty_print(q) # :nodoc:
- q.pp self.begin
+ begin_nil = self.begin == nil
+ end_nil = self.end == nil
+ q.pp self.begin if !begin_nil || end_nil
q.breakable ''
q.text(self.exclude_end? ? '...' : '..')
q.breakable ''
- q.pp self.end if self.end
+ q.pp self.end if !end_nil || begin_nil
end
end
@@ -571,7 +662,7 @@ class MatchData # :nodoc:
end
if defined?(RubyVM::AbstractSyntaxTree)
- class RubyVM::AbstractSyntaxTree::Node
+ class RubyVM::AbstractSyntaxTree::Node # :nodoc:
def pretty_print_children(q, names = [])
children.zip(names) do |c, n|
if n
@@ -629,10 +720,6 @@ end
module Kernel
# Returns a pretty printed object as a string.
#
- # In order to use this method you must first require the PP module:
- #
- # require 'pp'
- #
# See the PP module for more information.
def pretty_inspect
PP.pp(self, ''.dup)
@@ -640,7 +727,7 @@ module Kernel
# prints arguments in pretty form.
#
- # pp returns argument(s).
+ # +#pp+ returns argument(s).
def pp(*objs)
objs.each {|obj|
PP.pp(obj)
diff --git a/lib/prettyprint.gemspec b/lib/prettyprint.gemspec
index eae2227d60..a18adb174b 100644
--- a/lib/prettyprint.gemspec
+++ b/lib/prettyprint.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "prettyprint"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 188c2e6db0..44ca5e816f 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -23,16 +23,19 @@
#
# == References
# Christian Lindig, Strictly Pretty, March 2000,
-# http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
+# https://lindig.github.io/papers/strictly-pretty-2000.pdf
#
# Philip Wadler, A prettier printer, March 1998,
-# http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
+# https://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
#
# == Author
# Tanaka Akira <akr@fsij.org>
#
class PrettyPrint
+ # The version string
+ VERSION = "0.2.0"
+
# This is a convenience method which is same as follows:
#
# begin
@@ -484,8 +487,10 @@ class PrettyPrint
# It is passed to be similar to a PrettyPrint object itself, by responding to:
# * #text
# * #breakable
+ # * #fill_breakable
# * #nest
# * #group
+ # * #group_sub
# * #flush
# * #first?
#
@@ -519,6 +524,13 @@ class PrettyPrint
@output << sep
end
+ # Appends +sep+ to the text to be output. By default +sep+ is ' '
+ #
+ # +width+ argument is here for compatibility. It is a noop argument.
+ def fill_breakable(sep=' ', width=nil)
+ @output << sep
+ end
+
# Takes +indent+ arg, but does nothing with it.
#
# Yields to a block.
@@ -542,6 +554,15 @@ class PrettyPrint
@first.pop
end
+ # Yields to a block for compatibility.
+ def group_sub # :nodoc:
+ yield
+ end
+
+ # Method present for compatibility, but is a noop
+ def break_outmost_groups # :nodoc:
+ end
+
# Method present for compatibility, but is a noop
def flush # :nodoc:
end
diff --git a/lib/prism.rb b/lib/prism.rb
new file mode 100644
index 0000000000..8f0342724a
--- /dev/null
+++ b/lib/prism.rb
@@ -0,0 +1,145 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+# The Prism Ruby parser.
+#
+# "Parsing Ruby is suddenly manageable!"
+# - You, hopefully
+#
+module Prism
+ # There are many files in prism that are templated to handle every node type,
+ # which means the files can end up being quite large. We autoload them to make
+ # our require speed faster since consuming libraries are unlikely to use all
+ # of these features.
+
+ autoload :BasicVisitor, "prism/visitor"
+ autoload :Compiler, "prism/compiler"
+ autoload :DesugarCompiler, "prism/desugar_compiler"
+ autoload :Dispatcher, "prism/dispatcher"
+ autoload :DotVisitor, "prism/dot_visitor"
+ autoload :DSL, "prism/dsl"
+ autoload :InspectVisitor, "prism/inspect_visitor"
+ autoload :LexCompat, "prism/lex_compat"
+ autoload :MutationCompiler, "prism/mutation_compiler"
+ autoload :NodeFind, "prism/node_find"
+ autoload :Pattern, "prism/pattern"
+ autoload :Reflection, "prism/reflection"
+ autoload :Relocation, "prism/relocation"
+ autoload :Serialize, "prism/serialize"
+ autoload :StringQuery, "prism/string_query"
+ autoload :Translation, "prism/translation"
+ autoload :Visitor, "prism/visitor"
+
+ # Some of these constants are not meant to be exposed, so marking them as
+ # private here.
+
+ if RUBY_ENGINE != "jruby"
+ private_constant :LexCompat
+ private_constant :NodeFind
+ end
+
+ # Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
+ class CurrentVersionError < ArgumentError
+ # Initialize a new exception for the given ruby version string.
+ #--
+ #: (String version) -> void
+ def initialize(version)
+ message = +"invalid version: Requested to parse as `version: 'current'`; "
+ major, minor, =
+ if version.match?(/\A\d+\.\d+.\d+\z/)
+ version.split(".").map(&:to_i)
+ end
+
+ if major && minor && ((major < 3) || (major == 3 && minor < 3))
+ message << " #{version} is below the minimum supported syntax."
+ else
+ message << " #{version} is unknown. Please update the `prism` gem."
+ end
+
+ super(message)
+ end
+ end
+
+ # :call-seq:
+ # lex_compat(source, **options) -> LexCompat::Result
+ #
+ # Returns a parse result whose value is an array of tokens that closely
+ # resembles the return value of Ripper.lex.
+ #
+ # For supported options, see Prism.parse.
+ #--
+ #: (String source, **untyped options) -> LexCompat::Result
+ def self.lex_compat(source, **options)
+ LexCompat.new(source, **options).result # steep:ignore
+ end
+
+ # :call-seq:
+ # load(source, serialized, freeze) -> ParseResult
+ #
+ # Load the serialized AST using the source as a reference into a tree.
+ #--
+ #: (String source, String serialized, ?bool freeze) -> ParseResult
+ def self.load(source, serialized, freeze = false)
+ Serialize.load_parse(source, serialized, freeze)
+ end
+
+ # Given a Method, UnboundMethod, Proc, or Thread::Backtrace::Location,
+ # returns the Prism node representing it. On CRuby, this uses node_id for
+ # an exact match. On other implementations, it falls back to best-effort
+ # matching by source location line number.
+ #--
+ #: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable, ?rubyvm: bool) -> Node?
+ def self.find(callable, rubyvm: !!defined?(RubyVM))
+ NodeFind.find(callable, rubyvm)
+ end
+
+ # @rbs!
+ # VERSION: String
+ # BACKEND: :CEXT | :FFI
+ #
+ # interface _Stream
+ # def gets: (?Integer integer) -> (String | nil)
+ # end
+ #
+ # def self.parse: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
+ # def self.profile: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void
+ # def self.lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
+ # def self.parse_lex: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
+ # def self.dump: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String
+ # def self.parse_comments: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
+ # def self.parse_success?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
+ # def self.parse_failure?: (String source, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
+ # def self.parse_stream: (_Stream stream, ?filepath: String, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
+ # def self.parse_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
+ # def self.profile_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> void
+ # def self.lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
+ # def self.parse_lex_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
+ # def self.dump_file: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> String
+ # def self.parse_file_comments: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
+ # def self.parse_file_success?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
+ # def self.parse_file_failure?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
+end
+
+require_relative "prism/polyfill/byteindex"
+require_relative "prism/polyfill/warn"
+require_relative "prism/node"
+require_relative "prism/node_ext"
+require_relative "prism/parse_result"
+
+# This is a Ruby implementation of the prism parser. If we're running on CRuby
+# and we haven't explicitly set the PRISM_FFI_BACKEND environment variable, then
+# it's going to require the built library. Otherwise, it's going to require a
+# module that uses FFI to call into the library.
+if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
+ # The C extension is the default backend on CRuby.
+ Prism::BACKEND = :CEXT
+
+ require "prism/prism"
+else
+ # The FFI backend is used on other Ruby implementations.
+ Prism::BACKEND = :FFI
+
+ require_relative "prism/ffi"
+end
diff --git a/lib/prism/desugar_compiler.rb b/lib/prism/desugar_compiler.rb
new file mode 100644
index 0000000000..c64d03f64a
--- /dev/null
+++ b/lib/prism/desugar_compiler.rb
@@ -0,0 +1,463 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ class DesugarAndWriteNode # :nodoc:
+ include DSL
+
+ attr_reader :node #: ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode
+ attr_reader :default_source #: Source
+ attr_reader :read_class, :write_class #: Symbol
+ attr_reader :arguments #: Hash[Symbol, untyped]
+
+ #: ((ClassVariableAndWriteNode | ConstantAndWriteNode | GlobalVariableAndWriteNode | InstanceVariableAndWriteNode | LocalVariableAndWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
+ def initialize(node, default_source, read_class, write_class, **arguments)
+ @node = node
+ @default_source = default_source
+ @read_class = read_class
+ @write_class = write_class
+ @arguments = arguments
+ end
+
+ # Desugar `x &&= y` to `x && x = y`
+ #--
+ #: () -> node
+ def compile
+ and_node(
+ location: node.location,
+ left: public_send(read_class, location: node.name_loc, **arguments),
+ right: public_send(
+ write_class,
+ location: node.location,
+ **arguments,
+ name_loc: node.name_loc,
+ value: node.value,
+ operator_loc: node.operator_loc
+ ),
+ operator_loc: node.operator_loc
+ )
+ end
+ end
+
+ class DesugarOrWriteDefinedNode # :nodoc:
+ include DSL
+
+ attr_reader :node #: ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode
+ attr_reader :default_source #: Source
+ attr_reader :read_class, :write_class #: Symbol
+ attr_reader :arguments #: Hash[Symbol, untyped]
+
+ #: ((ClassVariableOrWriteNode | ConstantOrWriteNode | GlobalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
+ def initialize(node, default_source, read_class, write_class, **arguments)
+ @node = node
+ @default_source = default_source
+ @read_class = read_class
+ @write_class = write_class
+ @arguments = arguments
+ end
+
+ # Desugar `x ||= y` to `defined?(x) ? x : x = y`
+ #--
+ #: () -> node
+ def compile
+ if_node(
+ location: node.location,
+ if_keyword_loc: node.operator_loc,
+ predicate: defined_node(
+ location: node.name_loc,
+ value: public_send(read_class, location: node.name_loc, **arguments),
+ keyword_loc: node.operator_loc
+ ),
+ then_keyword_loc: node.operator_loc,
+ statements: statements_node(
+ location: node.location,
+ body: [public_send(read_class, location: node.name_loc, **arguments)]
+ ),
+ subsequent: else_node(
+ location: node.location,
+ else_keyword_loc: node.operator_loc,
+ statements: statements_node(
+ location: node.location,
+ body: [
+ public_send(
+ write_class,
+ location: node.location,
+ **arguments,
+ name_loc: node.name_loc,
+ value: node.value,
+ operator_loc: node.operator_loc
+ )
+ ]
+ ),
+ end_keyword_loc: node.operator_loc
+ ),
+ end_keyword_loc: node.operator_loc
+ )
+ end
+ end
+
+ class DesugarOperatorWriteNode # :nodoc:
+ include DSL
+
+ attr_reader :node #: ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode
+ attr_reader :default_source #: Source
+ attr_reader :read_class, :write_class #: Symbol
+ attr_reader :arguments #: Hash[Symbol, untyped]
+
+ #: ((ClassVariableOperatorWriteNode | ConstantOperatorWriteNode | GlobalVariableOperatorWriteNode | InstanceVariableOperatorWriteNode | LocalVariableOperatorWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
+ def initialize(node, default_source, read_class, write_class, **arguments)
+ @node = node
+ @default_source = default_source
+ @read_class = read_class
+ @write_class = write_class
+ @arguments = arguments
+ end
+
+ # Desugar `x += y` to `x = x + y`
+ #--
+ #: () -> node
+ def compile
+ binary_operator_loc = node.binary_operator_loc.chop
+
+ public_send(
+ write_class,
+ location: node.location,
+ **arguments,
+ name_loc: node.name_loc,
+ value: call_node(
+ location: node.location,
+ receiver: public_send(
+ read_class,
+ location: node.name_loc,
+ **arguments
+ ),
+ name: binary_operator_loc.slice.to_sym,
+ message_loc: binary_operator_loc,
+ arguments: arguments_node(
+ location: node.value.location,
+ arguments: [node.value]
+ )
+ ),
+ operator_loc: node.binary_operator_loc.copy(
+ start_offset: node.binary_operator_loc.end_offset - 1,
+ length: 1
+ )
+ )
+ end
+ end
+
+ class DesugarOrWriteNode # :nodoc:
+ include DSL
+
+ attr_reader :node #: InstanceVariableOrWriteNode | LocalVariableOrWriteNode
+ attr_reader :default_source #: Source
+ attr_reader :read_class, :write_class #: Symbol
+ attr_reader :arguments #: Hash[Symbol, untyped]
+
+ #: ((InstanceVariableOrWriteNode | LocalVariableOrWriteNode) node, Source default_source, Symbol read_class, Symbol write_class, **untyped arguments) -> void
+ def initialize(node, default_source, read_class, write_class, **arguments)
+ @node = node
+ @default_source = default_source
+ @read_class = read_class
+ @write_class = write_class
+ @arguments = arguments
+ end
+
+ # Desugar `x ||= y` to `x || x = y`
+ #--
+ #: () -> node
+ def compile
+ or_node(
+ location: node.location,
+ left: public_send(read_class, location: node.name_loc, **arguments),
+ right: public_send(
+ write_class,
+ location: node.location,
+ **arguments,
+ name_loc: node.name_loc,
+ value: node.value,
+ operator_loc: node.operator_loc
+ ),
+ operator_loc: node.operator_loc
+ )
+ end
+ end
+
+ private_constant :DesugarAndWriteNode, :DesugarOrWriteNode, :DesugarOrWriteDefinedNode, :DesugarOperatorWriteNode
+
+ class ClassVariableAndWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarAndWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
+ end
+ end
+
+ class ClassVariableOrWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOrWriteDefinedNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
+ end
+ end
+
+ class ClassVariableOperatorWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOperatorWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
+ end
+ end
+
+ class ConstantAndWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarAndWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
+ end
+ end
+
+ class ConstantOrWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOrWriteDefinedNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
+ end
+ end
+
+ class ConstantOperatorWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOperatorWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
+ end
+ end
+
+ class GlobalVariableAndWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarAndWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
+ end
+ end
+
+ class GlobalVariableOrWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOrWriteDefinedNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
+ end
+ end
+
+ class GlobalVariableOperatorWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOperatorWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
+ end
+ end
+
+ class InstanceVariableAndWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarAndWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
+ end
+ end
+
+ class InstanceVariableOrWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOrWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
+ end
+ end
+
+ class InstanceVariableOperatorWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOperatorWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
+ end
+ end
+
+ class LocalVariableAndWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarAndWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
+ end
+ end
+
+ class LocalVariableOrWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOrWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
+ end
+ end
+
+ class LocalVariableOperatorWriteNode
+ #: () -> node
+ def desugar # :nodoc:
+ DesugarOperatorWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
+ end
+ end
+
+ # DesugarCompiler is a compiler that desugars Ruby code into a more primitive
+ # form. This is useful for consumers that want to deal with fewer node types.
+ class DesugarCompiler < MutationCompiler
+ # `@@foo &&= bar`
+ #
+ # becomes
+ #
+ # `@@foo && @@foo = bar`
+ #--
+ #: (ClassVariableAndWriteNode node) -> node
+ def visit_class_variable_and_write_node(node)
+ node.desugar
+ end
+
+ # `@@foo ||= bar`
+ #
+ # becomes
+ #
+ # `defined?(@@foo) ? @@foo : @@foo = bar`
+ #--
+ #: (ClassVariableOrWriteNode node) -> node
+ def visit_class_variable_or_write_node(node)
+ node.desugar
+ end
+
+ # `@@foo += bar`
+ #
+ # becomes
+ #
+ # `@@foo = @@foo + bar`
+ #--
+ #: (ClassVariableOperatorWriteNode node) -> node
+ def visit_class_variable_operator_write_node(node)
+ node.desugar
+ end
+
+ # `Foo &&= bar`
+ #
+ # becomes
+ #
+ # `Foo && Foo = bar`
+ #--
+ #: (ConstantAndWriteNode node) -> node
+ def visit_constant_and_write_node(node)
+ node.desugar
+ end
+
+ # `Foo ||= bar`
+ #
+ # becomes
+ #
+ # `defined?(Foo) ? Foo : Foo = bar`
+ #--
+ #: (ConstantOrWriteNode node) -> node
+ def visit_constant_or_write_node(node)
+ node.desugar
+ end
+
+ # `Foo += bar`
+ #
+ # becomes
+ #
+ # `Foo = Foo + bar`
+ #--
+ #: (ConstantOperatorWriteNode node) -> node
+ def visit_constant_operator_write_node(node)
+ node.desugar
+ end
+
+ # `$foo &&= bar`
+ #
+ # becomes
+ #
+ # `$foo && $foo = bar`
+ #--
+ #: (GlobalVariableAndWriteNode node) -> node
+ def visit_global_variable_and_write_node(node)
+ node.desugar
+ end
+
+ # `$foo ||= bar`
+ #
+ # becomes
+ #
+ # `defined?($foo) ? $foo : $foo = bar`
+ #--
+ #: (GlobalVariableOrWriteNode node) -> node
+ def visit_global_variable_or_write_node(node)
+ node.desugar
+ end
+
+ # `$foo += bar`
+ #
+ # becomes
+ #
+ # `$foo = $foo + bar`
+ #--
+ #: (GlobalVariableOperatorWriteNode node) -> node
+ def visit_global_variable_operator_write_node(node)
+ node.desugar
+ end
+
+ # `@foo &&= bar`
+ #
+ # becomes
+ #
+ # `@foo && @foo = bar`
+ #--
+ #: (InstanceVariableAndWriteNode node) -> node
+ def visit_instance_variable_and_write_node(node)
+ node.desugar
+ end
+
+ # `@foo ||= bar`
+ #
+ # becomes
+ #
+ # `@foo || @foo = bar`
+ #--
+ #: (InstanceVariableOrWriteNode node) -> node
+ def visit_instance_variable_or_write_node(node)
+ node.desugar
+ end
+
+ # `@foo += bar`
+ #
+ # becomes
+ #
+ # `@foo = @foo + bar`
+ #--
+ #: (InstanceVariableOperatorWriteNode node) -> node
+ def visit_instance_variable_operator_write_node(node)
+ node.desugar
+ end
+
+ # `foo &&= bar`
+ #
+ # becomes
+ #
+ # `foo && foo = bar`
+ #--
+ #: (LocalVariableAndWriteNode node) -> node
+ def visit_local_variable_and_write_node(node)
+ node.desugar
+ end
+
+ # `foo ||= bar`
+ #
+ # becomes
+ #
+ # `foo || foo = bar`
+ #--
+ #: (LocalVariableOrWriteNode node) -> node
+ def visit_local_variable_or_write_node(node)
+ node.desugar
+ end
+
+ # `foo += bar`
+ #
+ # becomes
+ #
+ # `foo = foo + bar`
+ #--
+ #: (LocalVariableOperatorWriteNode node) -> node
+ def visit_local_variable_operator_write_node(node)
+ node.desugar
+ end
+ end
+end
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb
new file mode 100644
index 0000000000..6b9bde51ea
--- /dev/null
+++ b/lib/prism/ffi.rb
@@ -0,0 +1,611 @@
+# frozen_string_literal: true
+# :markup: markdown
+# typed: ignore
+
+# This file is responsible for mirroring the API provided by the C extension by
+# using FFI to call into the shared library.
+
+require "rbconfig"
+require "ffi"
+
+# We want to eagerly load this file if there are Ractors so that it does not get
+# autoloaded from within a non-main Ractor.
+require "prism/serialize" if defined?(Ractor)
+
+module Prism # :nodoc:
+ module LibRubyParser # :nodoc:
+ extend FFI::Library
+
+ # Define the library that we will be pulling functions from. Note that this
+ # must align with the build shared library from make/rake.
+ libprism_in_build = File.expand_path("../../build/libprism.#{RbConfig::CONFIG["SOEXT"]}", __dir__)
+ libprism_in_libdir = "#{RbConfig::CONFIG["libdir"]}/prism/libprism.#{RbConfig::CONFIG["SOEXT"]}"
+
+ if File.exist?(libprism_in_build)
+ INCLUDE_DIR = File.expand_path("../../include", __dir__)
+ ffi_lib libprism_in_build
+ else
+ INCLUDE_DIR = "#{RbConfig::CONFIG["libdir"]}/prism/include"
+ ffi_lib libprism_in_libdir
+ end
+
+ # Convert a native C type declaration into a symbol that FFI understands.
+ # For example:
+ #
+ # const char * -> :pointer
+ # bool -> :bool
+ # size_t -> :size_t
+ # void -> :void
+ #
+ def self.resolve_type(type, callbacks)
+ type = type.strip
+
+ if !type.end_with?("*")
+ type.delete_prefix("const ").to_sym
+ else
+ type = type.delete_suffix("*").rstrip
+ callbacks.include?(type.to_sym) ? type.to_sym : :pointer
+ end
+ end
+
+ # Read through the given header file and find the declaration of each of the
+ # given functions. For each one, define a function with the same name and
+ # signature as the C function.
+ def self.load_exported_functions_from(header, *functions, callbacks)
+ File.foreach("#{INCLUDE_DIR}/#{header}") do |line|
+ # We only want to attempt to load exported functions.
+ next unless line.start_with?("PRISM_EXPORTED_FUNCTION ")
+
+ # We only want to load the functions that we are interested in.
+ next unless functions.any? { |function| line.include?(function) }
+
+ # Strip trailing attributes (PRISM_NODISCARD, PRISM_NONNULL(...), etc.)
+ line = line.sub(/\)(\s+PRISM_\w+(?:\([^)]*\))?)+\s*;/, ");")
+
+ # Parse the function declaration.
+ unless /^PRISM_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line
+ raise "Could not parse #{line}"
+ end
+
+ # Delete the function from the list of functions we are looking for to
+ # mark it as having been found.
+ functions.delete(name)
+
+ # Split up the argument types into an array, ensure we handle the case
+ # where there are no arguments (by explicit void).
+ arg_types = arg_types.split(",").map(&:strip)
+ arg_types = [] if arg_types == %w[void]
+
+ # Resolve the type of the argument by dropping the name of the argument
+ # first if it is present.
+ arg_types.map! { |type| resolve_type(type.sub(/\w+$/, ""), callbacks) }
+
+ # Attach the function using the FFI library.
+ attach_function name, arg_types, resolve_type(return_type, [])
+ end
+
+ # If we didn't find all of the functions, raise an error.
+ raise "Could not find functions #{functions.inspect}" unless functions.empty?
+ end
+
+ callback :pm_source_stream_fgets_t, [:pointer, :int, :pointer], :pointer
+ callback :pm_source_stream_feof_t, [:pointer], :int
+ pm_source_init_result_values = %i[PM_SOURCE_INIT_SUCCESS PM_SOURCE_INIT_ERROR_GENERIC PM_SOURCE_INIT_ERROR_DIRECTORY PM_SOURCE_INIT_ERROR_NON_REGULAR]
+ enum :pm_source_init_result_t, pm_source_init_result_values
+ enum :pm_string_query_t, [:PM_STRING_QUERY_ERROR, -1, :PM_STRING_QUERY_FALSE, :PM_STRING_QUERY_TRUE]
+
+ # Ractor-safe lookup table for pm_source_init_result_t, since FFI's
+ # enum_type accesses module instance variables that are not shareable.
+ SOURCE_INIT_RESULT = pm_source_init_result_values.freeze
+
+ load_exported_functions_from(
+ "prism/version.h",
+ "pm_version",
+ []
+ )
+
+ load_exported_functions_from(
+ "prism/serialize.h",
+ "pm_serialize_parse",
+ "pm_serialize_parse_stream",
+ "pm_serialize_parse_comments",
+ "pm_serialize_lex",
+ "pm_serialize_parse_lex",
+ "pm_serialize_parse_success_p",
+ []
+ )
+
+ load_exported_functions_from(
+ "prism/string_query.h",
+ "pm_string_query_local",
+ "pm_string_query_constant",
+ "pm_string_query_method_name",
+ []
+ )
+
+ load_exported_functions_from(
+ "prism/buffer.h",
+ "pm_buffer_new",
+ "pm_buffer_value",
+ "pm_buffer_length",
+ "pm_buffer_free",
+ []
+ )
+
+ load_exported_functions_from(
+ "prism/source.h",
+ "pm_source_file_new",
+ "pm_source_mapped_new",
+ "pm_source_stream_new",
+ "pm_source_free",
+ "pm_source_source",
+ "pm_source_length",
+ [:pm_source_stream_fgets_t, :pm_source_stream_feof_t]
+ )
+
+ # This object represents a pm_buffer_t. We only use it as an opaque pointer,
+ # so it doesn't need to know the fields of pm_buffer_t.
+ class PrismBuffer # :nodoc:
+ attr_reader :pointer
+
+ def initialize(pointer)
+ @pointer = pointer
+ end
+
+ def value
+ LibRubyParser.pm_buffer_value(pointer)
+ end
+
+ def length
+ LibRubyParser.pm_buffer_length(pointer)
+ end
+
+ def read
+ value.read_string(length)
+ end
+
+ # Initialize a new buffer and yield it to the block. The buffer will be
+ # automatically freed when the block returns.
+ def self.with
+ buffer = LibRubyParser.pm_buffer_new
+ raise unless buffer
+
+ begin
+ yield new(buffer)
+ ensure
+ LibRubyParser.pm_buffer_free(buffer)
+ end
+ end
+ end
+
+ # This object represents source code to be parsed. For strings it wraps a
+ # pointer directly; for files it uses a pm_source_t under the hood.
+ class PrismSource # :nodoc:
+ PLATFORM_EXPECTS_UTF8 =
+ RbConfig::CONFIG["host_os"].match?(/bccwin|cygwin|djgpp|mingw|mswin|wince|darwin/i)
+
+ attr_reader :pointer, :length
+
+ def initialize(pointer, length, from_string)
+ @pointer = pointer
+ @length = length
+ @from_string = from_string
+ end
+
+ def read
+ raise "should use the original String instead" if @from_string
+ @pointer.read_string(@length)
+ end
+
+ # Yields a PrismSource backed by the given string to the block.
+ def self.with_string(string)
+ raise TypeError unless string.is_a?(String)
+
+ length = string.bytesize
+ # + 1 to never get an address of 0, which pm_parser_init() asserts
+ FFI::MemoryPointer.new(:char, length + 1, false) do |pointer|
+ pointer.write_string(string)
+ # since we have the extra byte we might as well \0-terminate
+ pointer.put_char(length, 0)
+ return yield new(pointer, length, true)
+ end
+ end
+
+ # Yields a PrismSource to the given block, backed by a pm_source_t.
+ def self.with_file(filepath)
+ raise TypeError unless filepath.is_a?(String)
+
+ # On Windows and Mac, it's expected that filepaths will be encoded in
+ # UTF-8. If they are not, we need to convert them to UTF-8 before
+ # passing them into pm_source_mapped_new.
+ if PLATFORM_EXPECTS_UTF8 && (encoding = filepath.encoding) != Encoding::ASCII_8BIT && encoding != Encoding::UTF_8
+ filepath = filepath.encode(Encoding::UTF_8)
+ end
+
+ FFI::MemoryPointer.new(:int) do |result_ptr|
+ pm_source = LibRubyParser.pm_source_mapped_new(filepath, 0, result_ptr)
+
+ case SOURCE_INIT_RESULT[result_ptr.read_int]
+ when :PM_SOURCE_INIT_SUCCESS
+ pointer = LibRubyParser.pm_source_source(pm_source)
+ length = LibRubyParser.pm_source_length(pm_source)
+ return yield new(pointer, length, false)
+ when :PM_SOURCE_INIT_ERROR_GENERIC
+ raise SystemCallError.new(filepath, FFI.errno)
+ when :PM_SOURCE_INIT_ERROR_DIRECTORY
+ raise Errno::EISDIR.new(filepath)
+ when :PM_SOURCE_INIT_ERROR_NON_REGULAR
+ # Fall back to reading the file through Ruby IO for non-regular
+ # files (pipes, character devices, etc.)
+ return with_string(File.read(filepath)) { |string| yield string }
+ else
+ raise "Unknown error initializing pm_source_t: #{result_ptr.read_int}"
+ end
+ ensure
+ LibRubyParser.pm_source_free(pm_source) if pm_source && !pm_source.null?
+ end
+ end
+ end
+ end
+
+ # Mark the LibRubyParser module as private as it should only be called through
+ # the prism module.
+ private_constant :LibRubyParser
+
+ # The version constant is set by reading the result of calling pm_version.
+ VERSION = LibRubyParser.pm_version.read_string.freeze
+
+ class << self
+ # Mirror the Prism.dump API by using the serialization API.
+ def dump(source, **options)
+ LibRubyParser::PrismSource.with_string(source) { |string| dump_common(string, options) }
+ end
+
+ # Mirror the Prism.dump_file API by using the serialization API.
+ def dump_file(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| dump_common(string, options) }
+ end
+
+ # Mirror the Prism.lex API by using the serialization API.
+ def lex(code, **options)
+ LibRubyParser::PrismSource.with_string(code) { |string| lex_common(string, code, options) }
+ end
+
+ # Mirror the Prism.lex_file API by using the serialization API.
+ def lex_file(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| lex_common(string, string.read, options) }
+ end
+
+ # Mirror the Prism.parse API by using the serialization API.
+ def parse(code, **options)
+ LibRubyParser::PrismSource.with_string(code) { |string| parse_common(string, code, options) }
+ end
+
+ # Mirror the Prism.parse_file API by using the serialization API. This uses
+ # native strings instead of Ruby strings because it allows us to use mmap
+ # when it is available.
+ def parse_file(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| parse_common(string, string.read, options) }
+ end
+
+ # Mirror the Prism.parse_stream API by using the serialization API.
+ def parse_stream(stream, **options)
+ LibRubyParser::PrismBuffer.with do |buffer|
+ source = +""
+ callback = -> (string, size, _) {
+ raise "Expected size to be >= 0, got: #{size}" if size <= 0
+
+ if !(line = stream.gets(size - 1)).nil?
+ source << line
+ string.write_string("#{line}\x00", line.bytesize + 1)
+ end
+ }
+
+ eof_callback = -> (_) { stream.eof? }
+
+ pm_source = LibRubyParser.pm_source_stream_new(nil, callback, eof_callback)
+ begin
+ LibRubyParser.pm_serialize_parse_stream(buffer.pointer, pm_source, dump_options(options))
+ Prism.load(source, buffer.read, options.fetch(:freeze, false))
+ ensure
+ LibRubyParser.pm_source_free(pm_source) if pm_source && !pm_source.null?
+ end
+ end
+ end
+
+ # Mirror the Prism.parse_comments API by using the serialization API.
+ def parse_comments(code, **options)
+ LibRubyParser::PrismSource.with_string(code) { |string| parse_comments_common(string, code, options) }
+ end
+
+ # Mirror the Prism.parse_file_comments API by using the serialization
+ # API. This uses native strings instead of Ruby strings because it allows us
+ # to use mmap when it is available.
+ def parse_file_comments(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| parse_comments_common(string, string.read, options) }
+ end
+
+ # Mirror the Prism.parse_lex API by using the serialization API.
+ def parse_lex(code, **options)
+ LibRubyParser::PrismSource.with_string(code) { |string| parse_lex_common(string, code, options) }
+ end
+
+ # Mirror the Prism.parse_lex_file API by using the serialization API.
+ def parse_lex_file(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| parse_lex_common(string, string.read, options) }
+ end
+
+ # Mirror the Prism.parse_success? API by using the serialization API.
+ def parse_success?(code, **options)
+ LibRubyParser::PrismSource.with_string(code) { |string| parse_file_success_common(string, options) }
+ end
+
+ # Mirror the Prism.parse_failure? API by using the serialization API.
+ def parse_failure?(code, **options)
+ !parse_success?(code, **options)
+ end
+
+ # Mirror the Prism.parse_file_success? API by using the serialization API.
+ def parse_file_success?(filepath, **options)
+ options[:filepath] = filepath
+ LibRubyParser::PrismSource.with_file(filepath) { |string| parse_file_success_common(string, options) }
+ end
+
+ # Mirror the Prism.parse_file_failure? API by using the serialization API.
+ def parse_file_failure?(filepath, **options)
+ !parse_file_success?(filepath, **options)
+ end
+
+ # Mirror the Prism.profile API by using the serialization API.
+ def profile(source, **options)
+ LibRubyParser::PrismSource.with_string(source) do |string|
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
+ nil
+ end
+ end
+ end
+
+ # Mirror the Prism.profile_file API by using the serialization API.
+ def profile_file(filepath, **options)
+ LibRubyParser::PrismSource.with_file(filepath) do |string|
+ LibRubyParser::PrismBuffer.with do |buffer|
+ options[:filepath] = filepath
+ LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
+ nil
+ end
+ end
+ end
+
+ private
+
+ def dump_common(string, options) # :nodoc:
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
+
+ dumped = buffer.read
+ dumped.freeze if options.fetch(:freeze, false)
+
+ dumped
+ end
+ end
+
+ def lex_common(string, code, options) # :nodoc:
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_lex(buffer.pointer, string.pointer, string.length, dump_options(options))
+ Serialize.load_lex(code, buffer.read, options.fetch(:freeze, false))
+ end
+ end
+
+ def parse_common(string, code, options) # :nodoc:
+ serialized = dump_common(string, options)
+ Serialize.load_parse(code, serialized, options.fetch(:freeze, false))
+ end
+
+ def parse_comments_common(string, code, options) # :nodoc:
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse_comments(buffer.pointer, string.pointer, string.length, dump_options(options))
+ Serialize.load_parse_comments(code, buffer.read, options.fetch(:freeze, false))
+ end
+ end
+
+ def parse_lex_common(string, code, options) # :nodoc:
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse_lex(buffer.pointer, string.pointer, string.length, dump_options(options))
+ Serialize.load_parse_lex(code, buffer.read, options.fetch(:freeze, false))
+ end
+ end
+
+ def parse_file_success_common(string, options) # :nodoc:
+ LibRubyParser.pm_serialize_parse_success_p(string.pointer, string.length, dump_options(options))
+ end
+
+ # Return the value that should be dumped for the command_line option.
+ def dump_options_command_line(options)
+ command_line = options.fetch(:command_line, "")
+ raise ArgumentError, "command_line must be a string" unless command_line.is_a?(String)
+
+ command_line.each_char.inject(0) do |value, char|
+ case char
+ when "a" then value | 0b000001
+ when "e" then value | 0b000010
+ when "l" then value | 0b000100
+ when "n" then value | 0b001000
+ when "p" then value | 0b010000
+ when "x" then value | 0b100000
+ else raise ArgumentError, "invalid command_line option: #{char}"
+ end
+ end
+ end
+
+ # Return the value that should be dumped for the version option.
+ def dump_options_version(version)
+ case version
+ when "current"
+ version_string_to_number(RUBY_VERSION) || raise(CurrentVersionError, RUBY_VERSION)
+ when "latest", nil
+ 0 # Handled in pm_parser_init
+ when "nearest"
+ dump = version_string_to_number(RUBY_VERSION)
+ return dump if dump
+ if RUBY_VERSION < "3.3"
+ version_string_to_number("3.3")
+ else
+ 0 # Handled in pm_parser_init
+ end
+ else
+ version_string_to_number(version) || raise(ArgumentError, "invalid version: #{version}")
+ end
+ end
+
+ # Converts a version string like "4.0.0" or "4.0" into a number.
+ # Returns nil if the version is unknown.
+ def version_string_to_number(version)
+ case version
+ when /\A3\.3(\.\d+)?\z/
+ 1
+ when /\A3\.4(\.\d+)?\z/
+ 2
+ when /\A3\.5(\.\d+)?\z/, /\A4\.0(\.\d+)?\z/
+ 3
+ when /\A4\.1(\.\d+)?\z/
+ 4
+ end
+ end
+
+ # Convert the given options into a serialized options string.
+ def dump_options(options)
+ template = +""
+ values = []
+
+ template << "L"
+ if (filepath = options[:filepath])
+ values.push(filepath.bytesize, filepath.b)
+ template << "A*"
+ else
+ values << 0
+ end
+
+ template << "l"
+ values << options.fetch(:line, 1)
+
+ template << "L"
+ if (encoding = options[:encoding])
+ name = encoding.is_a?(Encoding) ? encoding.name : encoding
+ values.push(name.bytesize, name.b)
+ template << "A*"
+ else
+ values << 0
+ end
+
+ template << "C"
+ values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
+
+ template << "C"
+ values << dump_options_command_line(options)
+
+ template << "C"
+ values << dump_options_version(options[:version])
+
+ template << "C"
+ values << (options[:encoding] == false ? 1 : 0)
+
+ template << "C"
+ values << (options.fetch(:main_script, false) ? 1 : 0)
+
+ template << "C"
+ values << (options.fetch(:partial_script, false) ? 1 : 0)
+
+ template << "C"
+ values << (options.fetch(:freeze, false) ? 1 : 0)
+
+ template << "L"
+ if (scopes = options[:scopes])
+ values << scopes.length
+
+ scopes.each do |scope|
+ locals = nil
+ forwarding = 0
+
+ case scope
+ when Array
+ locals = scope
+ when Scope
+ locals = scope.locals
+
+ scope.forwarding.each do |forward|
+ case forward
+ when :* then forwarding |= 0x1
+ when :** then forwarding |= 0x2
+ when :& then forwarding |= 0x4
+ when :"..." then forwarding |= 0x8
+ else raise ArgumentError, "invalid forwarding value: #{forward}"
+ end
+ end
+ else
+ raise TypeError, "wrong argument type #{scope.class.inspect} (expected Array or Prism::Scope)"
+ end
+
+ template << "L"
+ values << locals.length
+
+ template << "C"
+ values << forwarding
+
+ locals.each do |local|
+ name = local.name
+ template << "L"
+ values << name.bytesize
+
+ template << "A*"
+ values << name.b
+ end
+ end
+ else
+ values << 0
+ end
+
+ values.pack(template)
+ end
+ end
+
+ # Here we are going to patch StringQuery to put in the class-level methods so
+ # that it can maintain a consistent interface
+ class StringQuery # :nodoc:
+ class << self
+ # Mirrors the C extension's StringQuery::local? method.
+ def local?(string)
+ query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name))
+ end
+
+ # Mirrors the C extension's StringQuery::constant? method.
+ def constant?(string)
+ query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name))
+ end
+
+ # Mirrors the C extension's StringQuery::method_name? method.
+ def method_name?(string)
+ query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name))
+ end
+
+ private
+
+ # Parse the enum result and return an appropriate boolean.
+ def query(result)
+ case result
+ when :PM_STRING_QUERY_ERROR
+ raise ArgumentError, "Invalid or non ascii-compatible encoding"
+ when :PM_STRING_QUERY_FALSE
+ false
+ when :PM_STRING_QUERY_TRUE
+ true
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb
new file mode 100644
index 0000000000..7aacec037d
--- /dev/null
+++ b/lib/prism/lex_compat.rb
@@ -0,0 +1,906 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # @rbs!
+ # module Translation
+ # class Ripper
+ # EXPR_NONE: Integer
+ # EXPR_BEG: Integer
+ # EXPR_MID: Integer
+ # EXPR_END: Integer
+ # EXPR_CLASS: Integer
+ # EXPR_VALUE: Integer
+ # EXPR_ARG: Integer
+ # EXPR_CMDARG: Integer
+ # EXPR_ENDARG: Integer
+ # EXPR_ENDFN: Integer
+ #
+ # class Lexer < Ripper
+ # class State
+ # def self.[]: (Integer value) -> State
+ # end
+ # end
+ #
+ # class LineAndColumnCache
+ # def initialize: (Source source) -> void
+ #
+ # def line_and_column: (Integer byte_offset) -> [Integer, Integer]
+ # end
+ # end
+ # end
+
+ # This class is responsible for lexing the source using prism and then
+ # converting those tokens to be compatible with Ripper. In the vast majority
+ # of cases, this is a one-to-one mapping of the token type. Everything else
+ # generally lines up. However, there are a few cases that require special
+ # handling.
+ class LexCompat # :nodoc:
+ # @rbs!
+ # # A token produced by the Ripper lexer that Prism is replicating.
+ # type lex_compat_token = [[Integer, Integer], Symbol, String, untyped]
+
+ # A result class specialized for holding tokens produced by the lexer.
+ class Result < Prism::Result
+ # The list of tokens that were produced by the lexer.
+ attr_reader :value #: Array[lex_compat_token]
+
+ # Create a new lex compat result object with the given values.
+ #--
+ #: (Array[lex_compat_token] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
+ def initialize(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ @value = value
+ super(comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ end
+
+ # Implement the hash pattern matching interface for Result.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ super.merge!(value: value)
+ end
+ end
+
+ # This is a mapping of prism token types to Ripper token types. This is a
+ # many-to-one mapping because we split up our token types, whereas Ripper
+ # tends to group them.
+ RIPPER = {
+ AMPERSAND: :on_op,
+ AMPERSAND_AMPERSAND: :on_op,
+ AMPERSAND_AMPERSAND_EQUAL: :on_op,
+ AMPERSAND_DOT: :on_op,
+ AMPERSAND_EQUAL: :on_op,
+ BACK_REFERENCE: :on_backref,
+ BACKTICK: :on_backtick,
+ BANG: :on_op,
+ BANG_EQUAL: :on_op,
+ BANG_TILDE: :on_op,
+ BRACE_LEFT: :on_lbrace,
+ BRACE_RIGHT: :on_rbrace,
+ BRACKET_LEFT: :on_lbracket,
+ BRACKET_LEFT_ARRAY: :on_lbracket,
+ BRACKET_LEFT_RIGHT: :on_op,
+ BRACKET_LEFT_RIGHT_EQUAL: :on_op,
+ BRACKET_RIGHT: :on_rbracket,
+ CARET: :on_op,
+ CARET_EQUAL: :on_op,
+ CHARACTER_LITERAL: :on_CHAR,
+ CLASS_VARIABLE: :on_cvar,
+ COLON: :on_op,
+ COLON_COLON: :on_op,
+ COMMA: :on_comma,
+ COMMENT: :on_comment,
+ CONSTANT: :on_const,
+ DOT: :on_period,
+ DOT_DOT: :on_op,
+ DOT_DOT_DOT: :on_op,
+ EMBDOC_BEGIN: :on_embdoc_beg,
+ EMBDOC_END: :on_embdoc_end,
+ EMBDOC_LINE: :on_embdoc,
+ EMBEXPR_BEGIN: :on_embexpr_beg,
+ EMBEXPR_END: :on_embexpr_end,
+ EMBVAR: :on_embvar,
+ EOF: :on_eof,
+ EQUAL: :on_op,
+ EQUAL_EQUAL: :on_op,
+ EQUAL_EQUAL_EQUAL: :on_op,
+ EQUAL_GREATER: :on_op,
+ EQUAL_TILDE: :on_op,
+ FLOAT: :on_float,
+ FLOAT_IMAGINARY: :on_imaginary,
+ FLOAT_RATIONAL: :on_rational,
+ FLOAT_RATIONAL_IMAGINARY: :on_imaginary,
+ GREATER: :on_op,
+ GREATER_EQUAL: :on_op,
+ GREATER_GREATER: :on_op,
+ GREATER_GREATER_EQUAL: :on_op,
+ GLOBAL_VARIABLE: :on_gvar,
+ HEREDOC_END: :on_heredoc_end,
+ HEREDOC_START: :on_heredoc_beg,
+ IDENTIFIER: :on_ident,
+ IGNORED_NEWLINE: :on_ignored_nl,
+ INTEGER: :on_int,
+ INTEGER_IMAGINARY: :on_imaginary,
+ INTEGER_RATIONAL: :on_rational,
+ INTEGER_RATIONAL_IMAGINARY: :on_imaginary,
+ INSTANCE_VARIABLE: :on_ivar,
+ INVALID: :INVALID,
+ KEYWORD___ENCODING__: :on_kw,
+ KEYWORD___LINE__: :on_kw,
+ KEYWORD___FILE__: :on_kw,
+ KEYWORD_ALIAS: :on_kw,
+ KEYWORD_AND: :on_kw,
+ KEYWORD_BEGIN: :on_kw,
+ KEYWORD_BEGIN_UPCASE: :on_kw,
+ KEYWORD_BREAK: :on_kw,
+ KEYWORD_CASE: :on_kw,
+ KEYWORD_CLASS: :on_kw,
+ KEYWORD_DEF: :on_kw,
+ KEYWORD_DEFINED: :on_kw,
+ KEYWORD_DO: :on_kw,
+ KEYWORD_DO_BLOCK: :on_kw,
+ KEYWORD_DO_LOOP: :on_kw,
+ KEYWORD_ELSE: :on_kw,
+ KEYWORD_ELSIF: :on_kw,
+ KEYWORD_END: :on_kw,
+ KEYWORD_END_UPCASE: :on_kw,
+ KEYWORD_ENSURE: :on_kw,
+ KEYWORD_FALSE: :on_kw,
+ KEYWORD_FOR: :on_kw,
+ KEYWORD_IF: :on_kw,
+ KEYWORD_IF_MODIFIER: :on_kw,
+ KEYWORD_IN: :on_kw,
+ KEYWORD_MODULE: :on_kw,
+ KEYWORD_NEXT: :on_kw,
+ KEYWORD_NIL: :on_kw,
+ KEYWORD_NOT: :on_kw,
+ KEYWORD_OR: :on_kw,
+ KEYWORD_REDO: :on_kw,
+ KEYWORD_RESCUE: :on_kw,
+ KEYWORD_RESCUE_MODIFIER: :on_kw,
+ KEYWORD_RETRY: :on_kw,
+ KEYWORD_RETURN: :on_kw,
+ KEYWORD_SELF: :on_kw,
+ KEYWORD_SUPER: :on_kw,
+ KEYWORD_THEN: :on_kw,
+ KEYWORD_TRUE: :on_kw,
+ KEYWORD_UNDEF: :on_kw,
+ KEYWORD_UNLESS: :on_kw,
+ KEYWORD_UNLESS_MODIFIER: :on_kw,
+ KEYWORD_UNTIL: :on_kw,
+ KEYWORD_UNTIL_MODIFIER: :on_kw,
+ KEYWORD_WHEN: :on_kw,
+ KEYWORD_WHILE: :on_kw,
+ KEYWORD_WHILE_MODIFIER: :on_kw,
+ KEYWORD_YIELD: :on_kw,
+ LABEL: :on_label,
+ LABEL_END: :on_label_end,
+ LAMBDA_BEGIN: :on_tlambeg,
+ LESS: :on_op,
+ LESS_EQUAL: :on_op,
+ LESS_EQUAL_GREATER: :on_op,
+ LESS_LESS: :on_op,
+ LESS_LESS_EQUAL: :on_op,
+ METHOD_NAME: :on_ident,
+ MINUS: :on_op,
+ MINUS_EQUAL: :on_op,
+ MINUS_GREATER: :on_tlambda,
+ NEWLINE: :on_nl,
+ NUMBERED_REFERENCE: :on_backref,
+ PARENTHESIS_LEFT: :on_lparen,
+ PARENTHESIS_LEFT_PARENTHESES: :on_lparen,
+ PARENTHESIS_RIGHT: :on_rparen,
+ PERCENT: :on_op,
+ PERCENT_EQUAL: :on_op,
+ PERCENT_LOWER_I: :on_qsymbols_beg,
+ PERCENT_LOWER_W: :on_qwords_beg,
+ PERCENT_LOWER_X: :on_backtick,
+ PERCENT_UPPER_I: :on_symbols_beg,
+ PERCENT_UPPER_W: :on_words_beg,
+ PIPE: :on_op,
+ PIPE_EQUAL: :on_op,
+ PIPE_PIPE: :on_op,
+ PIPE_PIPE_EQUAL: :on_op,
+ PLUS: :on_op,
+ PLUS_EQUAL: :on_op,
+ QUESTION_MARK: :on_op,
+ RATIONAL_FLOAT: :on_rational,
+ RATIONAL_INTEGER: :on_rational,
+ REGEXP_BEGIN: :on_regexp_beg,
+ REGEXP_END: :on_regexp_end,
+ SEMICOLON: :on_semicolon,
+ SLASH: :on_op,
+ SLASH_EQUAL: :on_op,
+ STAR: :on_op,
+ STAR_EQUAL: :on_op,
+ STAR_STAR: :on_op,
+ STAR_STAR_EQUAL: :on_op,
+ STRING_BEGIN: :on_tstring_beg,
+ STRING_CONTENT: :on_tstring_content,
+ STRING_END: :on_tstring_end,
+ SYMBOL_BEGIN: :on_symbeg,
+ TILDE: :on_op,
+ UAMPERSAND: :on_op,
+ UCOLON_COLON: :on_op,
+ UDOT_DOT: :on_op,
+ UDOT_DOT_DOT: :on_op,
+ UMINUS: :on_op,
+ UMINUS_NUM: :on_op,
+ UPLUS: :on_op,
+ USTAR: :on_op,
+ USTAR_STAR: :on_op,
+ WORDS_SEP: :on_words_sep,
+ "__END__": :on___end__
+ }.freeze
+
+ # A heredoc in this case is a list of tokens that belong to the body of the
+ # heredoc that should be appended onto the list of tokens when the heredoc
+ # closes.
+ module Heredoc # :nodoc:
+ # Heredocs that are no dash or tilde heredocs are just a list of tokens.
+ # We need to keep them around so that we can insert them in the correct
+ # order back into the token stream and set the state of the last token to
+ # the state that the heredoc was opened in.
+ class PlainHeredoc # :nodoc:
+ attr_reader :tokens #: Array[lex_compat_token]
+
+ #: () -> void
+ def initialize
+ @tokens = []
+ end
+
+ #: (lex_compat_token token) -> void
+ def <<(token)
+ tokens << token
+ end
+
+ #: () -> Array[lex_compat_token]
+ def to_a
+ tokens
+ end
+ end
+
+ # Dash heredocs are a little more complicated. They are a list of tokens
+ # that need to be split on "\\\n" to mimic Ripper's behavior. We also need
+ # to keep track of the state that the heredoc was opened in.
+ class DashHeredoc # :nodoc:
+ attr_reader :split #: bool
+ attr_reader :tokens #: Array[lex_compat_token]
+
+ #: (bool split) -> void
+ def initialize(split)
+ @split = split
+ @tokens = []
+ end
+
+ #: (lex_compat_token token) -> void
+ def <<(token)
+ tokens << token
+ end
+
+ #: () -> Array[lex_compat_token]
+ def to_a
+ embexpr_balance = 0
+
+ tokens.each_with_object([]) do |token, results| #$ Array[lex_compat_token]
+ case token[1]
+ when :on_embexpr_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ lineno = token[0][0]
+ column = token[0][1]
+
+ if split
+ # Split on "\\\n" to mimic Ripper's behavior. Use a lookbehind
+ # to keep the delimiter in the result.
+ token[2].split(/(?<=[^\\]\\\n)|(?<=[^\\]\\\r\n)/).each_with_index do |value, index|
+ column = 0 if index > 0
+ results << [[lineno, column], :on_tstring_content, value, token[3]]
+ lineno += value.count("\n")
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ end
+ end
+ end
+
+ # Heredocs that are dedenting heredocs are a little more complicated.
+ # Ripper outputs on_ignored_sp tokens for the whitespace that is being
+ # removed from the output. prism only modifies the node itself and keeps
+ # the token the same. This simplifies prism, but makes comparing against
+ # Ripper much harder because there is a length mismatch.
+ #
+ # Fortunately, we already have to pull out the heredoc tokens in order to
+ # insert them into the stream in the correct order. As such, we can do
+ # some extra manipulation on the tokens to make them match Ripper's
+ # output by mirroring the dedent logic that Ripper uses.
+ class DedentingHeredoc # :nodoc:
+ TAB_WIDTH = 8
+
+ attr_reader :tokens #: Array[lex_compat_token]
+ attr_reader :dedent_next #: bool
+ attr_reader :dedent #: Integer?
+ attr_reader :embexpr_balance #: Integer
+ # @rbs @ended_on_newline: bool
+
+ #: () -> void
+ def initialize
+ @tokens = []
+ @dedent_next = true
+ @dedent = nil
+ @embexpr_balance = 0
+ @ended_on_newline = false
+ end
+
+ # As tokens are coming in, we track the minimum amount of common leading
+ # whitespace on plain string content tokens. This allows us to later
+ # remove that amount of whitespace from the beginning of each line.
+ #
+ #: (lex_compat_token token) -> void
+ def <<(token)
+ case token[1]
+ when :on_embexpr_beg, :on_heredoc_beg
+ @embexpr_balance += 1
+ @dedent = 0 if @dedent_next && @ended_on_newline
+ when :on_embexpr_end, :on_heredoc_end
+ @embexpr_balance -= 1
+ when :on_tstring_content
+ if embexpr_balance == 0
+ line = token[2]
+
+ if dedent_next && !(line.strip.empty? && line.end_with?("\n"))
+ leading = line[/\A(\s*)\n?/, 1] #: String
+ next_dedent = 0
+
+ leading.each_char do |char|
+ if char == "\t"
+ next_dedent = next_dedent - (next_dedent % TAB_WIDTH) + TAB_WIDTH
+ else
+ next_dedent += 1
+ end
+ end
+
+ @dedent = [dedent, next_dedent].compact.min
+ @dedent_next = true
+ @ended_on_newline = line.end_with?("\n")
+ tokens << token
+ return
+ end
+ end
+ end
+
+ @dedent_next = token[1] == :on_tstring_content && embexpr_balance == 0
+ @ended_on_newline = false
+ tokens << token
+ end
+
+ #: () -> Array[lex_compat_token]
+ def to_a
+ # If every line in the heredoc is blank, we still need to split up the
+ # string content token into multiple tokens.
+ if dedent.nil?
+ results = [] #: Array[lex_compat_token]
+ embexpr_balance = 0
+
+ tokens.each do |token|
+ case token[1]
+ when :on_embexpr_beg, :on_heredoc_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end, :on_heredoc_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ lineno = token[0][0]
+ column = token[0][1]
+
+ token[2].split(/(?<=\n)/).each_with_index do |value, index|
+ column = 0 if index > 0
+ results << [[lineno, column], :on_tstring_content, value, token[3]]
+ lineno += 1
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ end
+
+ return results
+ end
+
+ # If the minimum common whitespace is 0, then we need to concatenate
+ # string nodes together that are immediately adjacent.
+ if dedent == 0
+ results = [] #: Array[lex_compat_token]
+ embexpr_balance = 0
+
+ index = 0
+ max_index = tokens.length
+
+ while index < max_index
+ token = tokens[index]
+ results << token
+ index += 1
+
+ case token[1]
+ when :on_embexpr_beg, :on_heredoc_beg
+ embexpr_balance += 1
+ when :on_embexpr_end, :on_heredoc_end
+ embexpr_balance -= 1
+ when :on_tstring_content
+ if embexpr_balance == 0
+ while index < max_index && tokens[index][1] == :on_tstring_content && !token[2].match?(/\\\r?\n\z/)
+ token[2] << tokens[index][2]
+ index += 1
+ end
+ end
+ end
+ end
+
+ return results
+ end
+
+ # Otherwise, we're going to run through each token in the list and
+ # insert on_ignored_sp tokens for the amount of dedent that we need to
+ # perform. We also need to remove the dedent from the beginning of
+ # each line of plain string content tokens.
+ results = [] #: Array[lex_compat_token]
+ dedent_next = true
+ embexpr_balance = 0
+
+ tokens.each do |token|
+ # Notice that the structure of this conditional largely matches the
+ # whitespace calculation we performed above. This is because
+ # checking if the subsequent token needs to be dedented is common to
+ # both the dedent calculation and the ignored_sp insertion.
+ case token[1]
+ when :on_embexpr_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ # Here we're going to split the string on newlines, but maintain
+ # the newlines in the resulting array. We'll do that with a look
+ # behind assertion.
+ splits = token[2].split(/(?<=\n)/)
+ index = 0
+
+ while index < splits.length
+ line = splits[index]
+ lineno = token[0][0] + index
+ column = token[0][1]
+
+ # Blank lines do not count toward common leading whitespace
+ # calculation and do not need to be dedented.
+ if dedent_next || index > 0
+ column = 0
+ end
+
+ # If the dedent is 0 and we're not supposed to dedent the next
+ # line or this line doesn't start with whitespace, then we
+ # should concatenate the rest of the string to match ripper.
+ if dedent == 0 && (!dedent_next || !line.start_with?(/\s/))
+ unjoined = splits[index..] #: Array[String]
+ line = unjoined.join
+ index = splits.length
+ end
+
+ # If we are supposed to dedent this line or if this is not the
+ # first line of the string and this line isn't entirely blank,
+ # then we need to insert an on_ignored_sp token and remove the
+ # dedent from the beginning of the line.
+ if (dedent > 0) && (dedent_next || index > 0)
+ deleting = 0
+ deleted_chars = [] #: Array[String]
+
+ # Gather up all of the characters that we're going to
+ # delete, stopping when you hit a character that would put
+ # you over the dedent amount.
+ line.each_char.with_index do |char, i|
+ case char
+ when "\r"
+ if line[i + 1] == "\n"
+ break
+ end
+ when "\n"
+ break
+ when "\t"
+ deleting = deleting - (deleting % TAB_WIDTH) + TAB_WIDTH
+ else
+ deleting += 1
+ end
+
+ break if deleting > dedent
+ deleted_chars << char
+ end
+
+ # If we have something to delete, then delete it from the
+ # string and insert an on_ignored_sp token.
+ if deleted_chars.any?
+ ignored = deleted_chars.join
+ line.delete_prefix!(ignored)
+
+ results << [[lineno, 0], :on_ignored_sp, ignored, token[3]]
+ column = ignored.length
+ end
+ end
+
+ results << [[lineno, column], token[1], line, token[3]] unless line.empty?
+ index += 1
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+
+ dedent_next =
+ ((token[1] == :on_tstring_content) || (token[1] == :on_heredoc_end)) &&
+ embexpr_balance == 0
+ end
+
+ results
+ end
+ end
+
+ # Here we will split between the two types of heredocs and return the
+ # object that will store their tokens.
+ #--
+ #: (lex_compat_token opening) -> (PlainHeredoc | DashHeredoc | DedentingHeredoc)
+ def self.build(opening)
+ case opening[2][2]
+ when "~"
+ DedentingHeredoc.new
+ when "-"
+ DashHeredoc.new(opening[2][3] != "'")
+ else
+ PlainHeredoc.new
+ end
+ end
+ end
+
+ private_constant :Heredoc
+
+ # In previous versions of Ruby, Ripper wouldn't flush the bom before the
+ # first token, so we had to have a hack in place to account for that.
+ BOM_FLUSHED = RUBY_VERSION >= "3.3.0"
+ private_constant :BOM_FLUSHED
+
+ attr_reader :options #: Hash[Symbol, untyped]
+ # @rbs @source: String
+
+ #: (String source, **untyped options) -> void
+ def initialize(source, **options)
+ @source = source
+ @options = options
+ end
+
+ #: () -> Result
+ def result
+ tokens = [] #: Array[lex_compat_token]
+
+ state = :default
+ heredoc_stack = [[]] #: Array[Array[Heredoc::PlainHeredoc | Heredoc::DashHeredoc | Heredoc::DedentingHeredoc]]
+
+ result = Prism.lex(@source, **options)
+ source = result.source
+ result_value = result.value
+ previous_state = nil #: Translation::Ripper::Lexer::State?
+ last_heredoc_end = nil #: Integer?
+ eof_token = nil #: Token?
+
+ bom = source.slice(0, 3) == "\xEF\xBB\xBF"
+
+ result_value.each_with_index do |(prism_token, prism_state), index|
+ lineno = prism_token.location.start_line
+ column = prism_token.location.start_column
+
+ event = RIPPER.fetch(prism_token.type)
+ value = prism_token.value
+ lex_state = Translation::Ripper::Lexer::State[prism_state]
+
+ # If there's a UTF-8 byte-order mark as the start of the file, then for
+ # certain tokens ripper sets the first token back by 3 bytes. It also
+ # keeps the byte order mark in the first token's value. This is weird,
+ # and I don't want to mirror that in our parser. So instead, we'll match
+ # up the columns and values here.
+ if bom && lineno == 1
+ column -= 3
+
+ if index == 0 && column == 0 && !BOM_FLUSHED
+ flushed =
+ case prism_token.type
+ when :BACK_REFERENCE, :INSTANCE_VARIABLE, :CLASS_VARIABLE,
+ :GLOBAL_VARIABLE, :NUMBERED_REFERENCE, :PERCENT_LOWER_I,
+ :PERCENT_LOWER_X, :PERCENT_LOWER_W, :PERCENT_UPPER_I,
+ :PERCENT_UPPER_W, :STRING_BEGIN
+ true
+ when :REGEXP_BEGIN, :SYMBOL_BEGIN
+ value.start_with?("%")
+ else
+ false
+ end
+
+ unless flushed
+ column -= 3
+ value.prepend(String.new("\xEF\xBB\xBF", encoding: value.encoding))
+ end
+ end
+ end
+
+ lex_compat_token =
+ case event
+ when :on___end__
+ # Ripper doesn't include the rest of the token in the event, so we need to
+ # trim it down to just the content on the first line.
+ value = value[0..value.index("\n")] #: String
+ [[lineno, column], event, value, lex_state]
+ when :on_comment
+ [[lineno, column], event, value, lex_state]
+ when :on_heredoc_end
+ # Heredoc end tokens can be emitted in an odd order, so we don't
+ # want to bother comparing the state on them.
+ last_heredoc_end = prism_token.location.end_offset
+ [[lineno, column], event, value, lex_state]
+ when :on_embexpr_end
+ [[lineno, column], event, value, lex_state]
+ when :on_words_sep
+ # Ripper emits one token each per line.
+ value.each_line.with_index do |line, index|
+ if index > 0
+ lineno += 1
+ column = 0
+ end
+ tokens << [[lineno, column], event, line, lex_state]
+ end
+ tokens.pop #: lex_compat_token
+ when :on_regexp_end
+ # On regex end, Ripper scans and then sets end state, so the ripper
+ # lexed output is begin, when it should be end. prism sets lex state
+ # correctly to end state, but we want to be able to compare against
+ # Ripper's lexed state. So here, if it's a regexp end token, we
+ # output the state as the previous state, solely for the sake of
+ # comparison.
+ previous_token = result_value[index - 1][0]
+ lex_state =
+ if RIPPER.fetch(previous_token.type) == :on_embexpr_end
+ # If the previous token is embexpr_end, then we have to do even
+ # more processing. The end of an embedded expression sets the
+ # state to the state that it had at the beginning of the
+ # embedded expression. So we have to go and find that state and
+ # set it here.
+ counter = 1
+ current_index = index - 1
+
+ until counter == 0
+ current_index -= 1
+ current_event = RIPPER.fetch(result_value[current_index][0].type)
+ counter += { on_embexpr_beg: -1, on_embexpr_end: 1 }[current_event] || 0
+ end
+
+ Translation::Ripper::Lexer::State[result_value[current_index][1]]
+ else
+ previous_state
+ end
+
+ [[lineno, column], event, value, lex_state]
+ when :on_eof
+ eof_token = prism_token
+ previous_token = result_value[index - 1][0]
+
+ # If we're at the end of the file and the previous token was a
+ # comment and there is still whitespace after the comment, then
+ # Ripper will append a on_nl token (even though there isn't
+ # necessarily a newline). We mirror that here.
+ if previous_token.type == :COMMENT
+ # If the comment is at the start of a heredoc: <<HEREDOC # comment
+ # then the comment's end_offset is up near the heredoc_beg.
+ # This is not the correct offset to use for figuring out if
+ # there is trailing whitespace after the last token.
+ # Use the greater offset of the two to determine the start of
+ # the trailing whitespace.
+ start_offset = [previous_token.location.end_offset, last_heredoc_end].compact.max
+ end_offset = prism_token.location.start_offset
+
+ if start_offset < end_offset
+ if bom
+ start_offset += 3
+ end_offset += 3
+ end
+
+ tokens << [[lineno, 0], :on_nl, source.slice(start_offset, end_offset - start_offset), lex_state]
+ end
+ end
+
+ [[lineno, column], event, value, lex_state]
+ else
+ [[lineno, column], event, value, lex_state]
+ end #: lex_compat_token
+
+ previous_state = lex_state
+
+ # The order in which tokens appear in our lexer is different from the
+ # order that they appear in Ripper. When we hit the declaration of a
+ # heredoc in prism, we skip forward and lex the rest of the content of
+ # the heredoc before going back and lexing at the end of the heredoc
+ # identifier.
+ #
+ # To match up to ripper, we keep a small state variable around here to
+ # track whether we're in the middle of a heredoc or not. In this way we
+ # can shuffle around the token to match Ripper's output.
+ case state
+ when :default
+ # The default state is when there are no heredocs at all. In this
+ # state we can append the token to the list of tokens and move on.
+ tokens << lex_compat_token
+
+ # If we get the declaration of a heredoc, then we open a new heredoc
+ # and move into the heredoc_opened state.
+ if event == :on_heredoc_beg
+ state = :heredoc_opened
+ heredoc_stack.last << Heredoc.build(lex_compat_token)
+ end
+ when :heredoc_opened
+ # The heredoc_opened state is when we've seen the declaration of a
+ # heredoc and are now lexing the body of the heredoc. In this state we
+ # push tokens onto the most recently created heredoc.
+ heredoc_stack.last.last << lex_compat_token
+
+ case event
+ when :on_heredoc_beg
+ # If we receive a heredoc declaration while lexing the body of a
+ # heredoc, this means we have nested heredocs. In this case we'll
+ # push a new heredoc onto the stack and stay in the heredoc_opened
+ # state since we're now lexing the body of the new heredoc.
+ heredoc_stack << [Heredoc.build(lex_compat_token)]
+ when :on_heredoc_end
+ # If we receive the end of a heredoc, then we're done lexing the
+ # body of the heredoc. In this case we now have a completed heredoc
+ # but need to wait for the next newline to push it into the token
+ # stream.
+ state = :heredoc_closed
+ end
+ when :heredoc_closed
+ if %i[on_nl on_ignored_nl on_comment].include?(event) || ((event == :on_tstring_content) && value.end_with?("\n"))
+ if heredoc_stack.size > 1
+ flushing = heredoc_stack.pop #: Array[Heredoc::PlainHeredoc | Heredoc::DashHeredoc | Heredoc::DedentingHeredoc]
+ heredoc_stack.last.last << lex_compat_token
+
+ flushing.each do |heredoc|
+ heredoc.to_a.each do |flushed_token|
+ heredoc_stack.last.last << flushed_token
+ end
+ end
+
+ state = :heredoc_opened
+ next
+ end
+ elsif event == :on_heredoc_beg
+ tokens << lex_compat_token
+ state = :heredoc_opened
+ heredoc_stack.last << Heredoc.build(lex_compat_token)
+ next
+ elsif heredoc_stack.size > 1
+ heredoc_stack[-2].last << lex_compat_token
+ next
+ end
+
+ heredoc_stack.last.each do |heredoc|
+ tokens.concat(heredoc.to_a)
+ end
+
+ heredoc_stack.last.clear
+ state = :default
+
+ tokens << lex_compat_token
+ end
+ end
+
+ # Drop the EOF token from the list. The EOF token may not be
+ # present if the source was syntax invalid
+ if tokens.dig(-1, 1) == :on_eof
+ tokens = tokens[0...-1] #: Array[lex_compat_token]
+ end
+
+ # We sort by location because Ripper.lex sorts.
+ tokens.sort_by! do |token|
+ line, column = token[0]
+ source.byte_offset(line, column)
+ end
+
+ tokens = post_process_tokens(tokens, source, result.data_loc, bom, eof_token)
+
+ Result.new(tokens, result.comments, result.magic_comments, result.data_loc, result.errors, result.warnings, result.continuable?, source)
+ end
+
+ private
+
+ #: (Array[lex_compat_token] tokens, Source source, Location? data_loc, bool bom, Token? eof_token) -> Array[lex_compat_token]
+ def post_process_tokens(tokens, source, data_loc, bom, eof_token)
+ new_tokens = [] #: Array[lex_compat_token]
+
+ prev_token_state = Translation::Ripper::Lexer::State[Translation::Ripper::EXPR_BEG]
+ prev_token_end = bom ? 3 : 0
+
+ cache = Translation::Ripper::LineAndColumnCache.new(source)
+
+ tokens.each do |token|
+ # Skip missing heredoc ends.
+ next if token[1] == :on_heredoc_end && token[2] == ""
+
+ # Add :on_sp tokens.
+ line, column = token[0]
+ start_offset = source.byte_offset(line, column)
+
+ # Ripper reports columns on line 1 without counting the BOM, so we
+ # adjust to get the real offset
+ start_offset += 3 if line == 1 && bom
+
+ if start_offset > prev_token_end
+ sp_value = source.slice(prev_token_end, start_offset - prev_token_end)
+ sp_line, sp_column = cache.line_and_column(prev_token_end)
+ # Ripper reports columns on line 1 without counting the BOM
+ sp_column -= 3 if sp_line == 1 && bom
+ continuation_index = sp_value.byteindex("\\")
+
+ # ripper emits up to three :on_sp tokens when line continuations are used
+ if continuation_index
+ next_whitespace_index = continuation_index + 1
+ next_whitespace_index += 1 if sp_value.byteslice(next_whitespace_index) == "\r"
+ next_whitespace_index += 1
+ first_whitespace = sp_value[0...continuation_index] #: String
+ continuation = sp_value[continuation_index...next_whitespace_index] #: String
+ second_whitespace = sp_value[next_whitespace_index..] || ""
+
+ new_tokens << [[sp_line, sp_column], :on_sp, first_whitespace, prev_token_state] unless first_whitespace.empty?
+ new_tokens << [[sp_line, sp_column + continuation_index], :on_sp, continuation, prev_token_state]
+ new_tokens << [[sp_line + 1, 0], :on_sp, second_whitespace, prev_token_state] unless second_whitespace.empty?
+ else
+ new_tokens << [[sp_line, sp_column], :on_sp, sp_value, prev_token_state]
+ end
+ end
+
+ new_tokens << token
+ prev_token_state = token[3]
+ prev_token_end = start_offset + token[2].bytesize
+ end
+
+ if !data_loc && eof_token # no trailing :on_sp with __END__ as it is always preceded by :on_nl
+ end_offset = eof_token.location.end_offset
+ if prev_token_end < end_offset
+ new_tokens << [
+ [source.line(prev_token_end), source.column(prev_token_end)],
+ :on_sp,
+ source.slice(prev_token_end, end_offset - prev_token_end),
+ prev_token_state
+ ]
+ end
+ end
+
+ new_tokens
+ end
+ end
+
+ private_constant :LexCompat
+end
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
new file mode 100644
index 0000000000..8a6624e76d
--- /dev/null
+++ b/lib/prism/node_ext.rb
@@ -0,0 +1,388 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+#--
+# Here we are reopening the prism module to provide methods on nodes that aren't
+# templated and are meant as convenience methods.
+#++
+module Prism
+ class Node
+ #: (*String replacements) -> void
+ def deprecated(*replacements) # :nodoc:
+ location = caller_locations(1, 1)&.[](0)&.label
+ suggest = replacements.map { |replacement| "#{self.class}##{replacement}" }
+
+ warn(<<~MSG, uplevel: 1, category: :deprecated)
+ [deprecation]: #{self.class}##{location} is deprecated and will be \
+ removed in the next major version. Use #{suggest.join("/")} instead.
+ #{(caller(1, 3) || []).join("\n")}
+ MSG
+ end
+ end
+
+ module RegularExpressionOptions # :nodoc:
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ #--
+ #: (Integer flags) -> Integer
+ def self.options(flags)
+ o = 0
+ o |= Regexp::IGNORECASE if flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
+ o |= Regexp::EXTENDED if flags.anybits?(RegularExpressionFlags::EXTENDED)
+ o |= Regexp::MULTILINE if flags.anybits?(RegularExpressionFlags::MULTI_LINE)
+ o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
+ o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
+ o
+ end
+ end
+
+ class InterpolatedMatchLastLineNode < Node
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ #--
+ #: () -> Integer
+ def options
+ RegularExpressionOptions.options(flags)
+ end
+ end
+
+ class InterpolatedRegularExpressionNode < Node
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ #--
+ #: () -> Integer
+ def options
+ RegularExpressionOptions.options(flags)
+ end
+ end
+
+ class MatchLastLineNode < Node
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ #--
+ #: () -> Integer
+ def options
+ RegularExpressionOptions.options(flags)
+ end
+ end
+
+ class RegularExpressionNode < Node
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ #--
+ #: () -> Integer
+ def options
+ RegularExpressionOptions.options(flags)
+ end
+ end
+
+ private_constant :RegularExpressionOptions
+
+ module HeredocQuery # :nodoc:
+ # Returns true if this node was represented as a heredoc in the source code.
+ #--
+ #: (String? opening) -> bool?
+ def self.heredoc?(opening)
+ # @type self: InterpolatedStringNode | InterpolatedXStringNode | StringNode | XStringNode
+ opening&.start_with?("<<")
+ end
+ end
+
+ class InterpolatedStringNode < Node
+ # Returns true if this node was represented as a heredoc in the source code.
+ #--
+ #: () -> bool?
+ def heredoc?
+ HeredocQuery.heredoc?(opening)
+ end
+ end
+
+ class InterpolatedXStringNode < Node
+ # Returns true if this node was represented as a heredoc in the source code.
+ #--
+ #: () -> bool?
+ def heredoc?
+ HeredocQuery.heredoc?(opening)
+ end
+ end
+
+ class StringNode < Node
+ # Returns true if this node was represented as a heredoc in the source code.
+ #--
+ #: () -> bool?
+ def heredoc?
+ HeredocQuery.heredoc?(opening)
+ end
+
+ # Occasionally it's helpful to treat a string as if it were interpolated so
+ # that there's a consistent interface for working with strings.
+ #--
+ #: () -> InterpolatedStringNode
+ def to_interpolated
+ InterpolatedStringNode.new(
+ source,
+ -1,
+ location,
+ frozen? ? InterpolatedStringNodeFlags::FROZEN : 0,
+ opening_loc,
+ [copy(location: content_loc, opening_loc: nil, closing_loc: nil)],
+ closing_loc
+ )
+ end
+ end
+
+ class XStringNode < Node
+ # Returns true if this node was represented as a heredoc in the source code.
+ #--
+ #: () -> bool?
+ def heredoc?
+ HeredocQuery.heredoc?(opening)
+ end
+
+ # Occasionally it's helpful to treat a string as if it were interpolated so
+ # that there's a consistent interface for working with strings.
+ #--
+ #: () -> InterpolatedXStringNode
+ def to_interpolated
+ InterpolatedXStringNode.new(
+ source,
+ -1,
+ location,
+ flags,
+ opening_loc,
+ [StringNode.new(source, node_id, content_loc, 0, nil, content_loc, nil, unescaped)],
+ closing_loc
+ )
+ end
+ end
+
+ private_constant :HeredocQuery
+
+ class ImaginaryNode < Node
+ # Returns the value of the node as a Ruby Complex.
+ #--
+ #: () -> Complex
+ def value
+ Complex(0, numeric.value)
+ end
+ end
+
+ class RationalNode < Node
+ # Returns the value of the node as a Ruby Rational.
+ #--
+ #: () -> Rational
+ def value
+ Rational(numerator, denominator)
+ end
+ end
+
+ class ConstantReadNode < Node
+ # Returns the list of parts for the full name of this constant.
+ # For example: [:Foo]
+ #--
+ #: () -> Array[Symbol]
+ def full_name_parts
+ [name]
+ end
+
+ # Returns the full name of this constant. For example: "Foo"
+ #--
+ #: () -> String
+ def full_name
+ name.to_s
+ end
+ end
+
+ class ConstantWriteNode < Node
+ # Returns the list of parts for the full name of this constant.
+ # For example: [:Foo]
+ #--
+ #: () -> Array[Symbol]
+ def full_name_parts
+ [name]
+ end
+
+ # Returns the full name of this constant. For example: "Foo"
+ #--
+ #: () -> String
+ def full_name
+ name.to_s
+ end
+ end
+
+ class ConstantPathNode < Node
+ # An error class raised when dynamic parts are found while computing a
+ # constant path's full name. For example:
+ # Foo::Bar::Baz -> does not raise because all parts of the constant path are
+ # simple constants
+ # var::Bar::Baz -> raises because the first part of the constant path is a
+ # local variable
+ class DynamicPartsInConstantPathError < StandardError; end
+
+ # An error class raised when error recovery nodes are found while computing a
+ # constant path's full name. For example:
+ # Foo:: -> raises because the constant path is missing the last part
+ class ErrorRecoveryNodesInConstantPathError < StandardError; end
+
+ # Returns the list of parts for the full name of this constant path.
+ # For example: [:Foo, :Bar]
+ #--
+ #: () -> Array[Symbol]
+ def full_name_parts
+ parts = [] #: Array[Symbol]
+ current = self #: node?
+
+ while current.is_a?(ConstantPathNode)
+ name = current.name
+ if name.nil?
+ raise ErrorRecoveryNodesInConstantPathError, "Constant path contains error recovery nodes. Cannot compute full name"
+ end
+
+ parts.unshift(name)
+ current = current.parent
+ end
+
+ if !current.is_a?(ConstantReadNode) && !current.nil?
+ raise DynamicPartsInConstantPathError, "Constant path contains dynamic parts. Cannot compute full name"
+ end
+
+ parts.unshift(current&.name || :"")
+ end
+
+ # Returns the full name of this constant path. For example: "Foo::Bar"
+ #--
+ #: () -> String
+ def full_name
+ full_name_parts.join("::")
+ end
+ end
+
+ class ConstantPathTargetNode < Node
+ # Returns the list of parts for the full name of this constant path.
+ # For example: [:Foo, :Bar]
+ #--
+ #: () -> Array[Symbol]
+ def full_name_parts
+ parts =
+ case (parent = self.parent)
+ when ConstantPathNode, ConstantReadNode
+ parent.full_name_parts
+ when nil
+ [:""]
+ else
+ # e.g. self::Foo, (var)::Bar = baz
+ raise ConstantPathNode::DynamicPartsInConstantPathError, "Constant target path contains dynamic parts. Cannot compute full name"
+ end
+
+ if (name = self.name).nil?
+ raise ConstantPathNode::ErrorRecoveryNodesInConstantPathError, "Constant target path contains error recovery nodes. Cannot compute full name"
+ end
+
+ parts.push(name)
+ end
+
+ # Returns the full name of this constant path. For example: "Foo::Bar"
+ #--
+ #: () -> String
+ def full_name
+ full_name_parts.join("::")
+ end
+ end
+
+ class ConstantTargetNode < Node
+ # Returns the list of parts for the full name of this constant.
+ # For example: [:Foo]
+ #--
+ #: () -> Array[Symbol]
+ def full_name_parts
+ [name]
+ end
+
+ # Returns the full name of this constant. For example: "Foo"
+ #--
+ #: () -> String
+ def full_name
+ name.to_s
+ end
+ end
+
+ class ParametersNode < Node
+ # Mirrors the Method#parameters method.
+ #--
+ #: () -> Array[[Symbol, Symbol] | [Symbol]]
+ def signature
+ names = [] #: Array[[Symbol, Symbol] | [Symbol]]
+
+ requireds.each do |param|
+ names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name])
+ end
+
+ optionals.each { |param| names << [:opt, param.name] }
+
+ if (rest = self.rest).is_a?(RestParameterNode)
+ names << [:rest, rest.name || :*]
+ end
+
+ posts.each do |param|
+ case param
+ when MultiTargetNode
+ names << [:req]
+ when ErrorRecoveryNode
+ raise "Invalid syntax"
+ else
+ names << [:req, param.name]
+ end
+ end
+
+ # Regardless of the order in which the keywords were defined, the required
+ # keywords always come first followed by the optional keywords.
+ keyopt = [] #: Array[OptionalKeywordParameterNode]
+ keywords.each do |param|
+ if param.is_a?(OptionalKeywordParameterNode)
+ keyopt << param
+ else
+ names << [:keyreq, param.name]
+ end
+ end
+
+ keyopt.each { |param| names << [:key, param.name] }
+
+ case (keyword_rest = self.keyword_rest)
+ when ForwardingParameterNode
+ names.concat([[:rest, :*], [:keyrest, :**], [:block, :&]])
+ when KeywordRestParameterNode
+ names << [:keyrest, keyword_rest.name || :**]
+ when NoKeywordsParameterNode
+ names << [:nokey]
+ end
+
+ case (block = self.block)
+ when BlockParameterNode
+ names << [:block, block.name || :&]
+ when NoBlockParameterNode
+ names << [:noblock]
+ end
+
+ names
+ end
+ end
+
+ class CallNode < Node
+ # When a call node has the attribute_write flag set, it means that the call
+ # is using the attribute write syntax. This is either a method call to []=
+ # or a method call to a method that ends with =. Either way, the = sign is
+ # present in the source.
+ #
+ # Prism returns the message_loc _without_ the = sign attached, because there
+ # can be any amount of space between the message and the = sign. However,
+ # sometimes you want the location of the full message including the inner
+ # space and the = sign. This method provides that.
+ #--
+ #: () -> Location?
+ def full_message_loc
+ attribute_write? ? message_loc&.adjoin("=") : message_loc
+ end
+ end
+end
diff --git a/lib/prism/node_find.rb b/lib/prism/node_find.rb
new file mode 100644
index 0000000000..697ee430e8
--- /dev/null
+++ b/lib/prism/node_find.rb
@@ -0,0 +1,185 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # Finds the Prism AST node corresponding to a given Method, UnboundMethod,
+ # Proc, or Thread::Backtrace::Location. On CRuby, uses node_id from the
+ # instruction sequence for an exact match. On other implementations, falls
+ # back to best-effort matching by source location line number.
+ #
+ # This module is autoloaded so that programs that don't use Prism.find don't
+ # pay for its definition.
+ module NodeFind # :nodoc:
+ # Find the node for the given callable or backtrace location.
+ #--
+ #: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable, bool rubyvm) -> Node?
+ def self.find(callable, rubyvm)
+ case callable
+ when Proc
+ if rubyvm
+ RubyVMCallableFind.new.find(callable)
+ elsif callable.lambda?
+ LineLambdaFind.new.find(callable)
+ else
+ LineProcFind.new.find(callable)
+ end
+ when Method, UnboundMethod
+ if rubyvm
+ RubyVMCallableFind.new.find(callable)
+ else
+ LineMethodFind.new.find(callable)
+ end
+ when Thread::Backtrace::Location
+ if rubyvm
+ RubyVMBacktraceLocationFind.new.find(callable)
+ else
+ LineBacktraceLocationFind.new.find(callable)
+ end
+ else
+ raise ArgumentError, "Expected a Method, UnboundMethod, Proc, or Thread::Backtrace::Location, got #{callable.class}"
+ end
+ end
+
+ # Base class that handles parsing a file.
+ class Find
+ private
+
+ # Parse the given file path, returning a ParseResult or nil.
+ #--
+ #: (String? file) -> ParseResult?
+ def parse_file(file)
+ return unless file && File.readable?(file)
+ result = Prism.parse_file(file)
+ result if result.success?
+ end
+ end
+
+ # Finds the AST node for a Method, UnboundMethod, or Proc using the node_id
+ # from the instruction sequence.
+ class RubyVMCallableFind < Find
+ # Find the node for the given callable using the ISeq node_id.
+ #--
+ #: (Method | UnboundMethod | Proc callable) -> Node?
+ def find(callable)
+ return unless (source_location = callable.source_location)
+ return unless (result = parse_file(source_location[0]))
+ return unless (iseq = RubyVM::InstructionSequence.of(callable))
+
+ header = iseq.to_a[4]
+ return unless header[:parser] == :prism
+
+ result.value.find { |node| node.node_id == header[:node_id] }
+ end
+ end
+
+ # Finds the AST node for a Thread::Backtrace::Location using the node_id
+ # from the backtrace location.
+ class RubyVMBacktraceLocationFind < Find
+ # Find the node for the given backtrace location using node_id.
+ #--
+ #: (Thread::Backtrace::Location location) -> Node?
+ def find(location)
+ file = location.absolute_path || location.path
+ return unless (result = parse_file(file))
+ return unless RubyVM::AbstractSyntaxTree.respond_to?(:node_id_for_backtrace_location)
+
+ node_id = RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(location)
+
+ result.value.find { |node| node.node_id == node_id }
+ end
+ end
+
+ # Finds the AST node for a Method or UnboundMethod using best-effort line
+ # matching. Used on non-CRuby implementations.
+ class LineMethodFind < Find
+ # Find the node for the given method by matching on name and line.
+ #--
+ #: (Method | UnboundMethod callable) -> Node?
+ def find(callable)
+ return unless (source_location = callable.source_location)
+ return unless (result = parse_file(source_location[0]))
+
+ name = callable.name
+ start_line = source_location[1]
+
+ result.value.find do |node|
+ case node
+ when DefNode
+ node.name == name && node.location.start_line == start_line
+ when CallNode
+ node.block.is_a?(BlockNode) && node.location.start_line == start_line
+ else
+ false
+ end
+ end
+ end
+ end
+
+ # Finds the AST node for a lambda using best-effort line matching. Used
+ # on non-CRuby implementations.
+ class LineLambdaFind < Find
+ # Find the node for the given lambda by matching on line.
+ #--
+ #: (Proc callable) -> Node?
+ def find(callable)
+ return unless (source_location = callable.source_location)
+ return unless (result = parse_file(source_location[0]))
+
+ start_line = source_location[1]
+
+ result.value.find do |node|
+ case node
+ when LambdaNode
+ node.location.start_line == start_line
+ when CallNode
+ node.block.is_a?(BlockNode) && node.location.start_line == start_line
+ else
+ false
+ end
+ end
+ end
+ end
+
+ # Finds the AST node for a non-lambda Proc using best-effort line
+ # matching. Used on non-CRuby implementations.
+ class LineProcFind < Find
+ # Find the node for the given proc by matching on line.
+ #--
+ #: (Proc callable) -> Node?
+ def find(callable)
+ return unless (source_location = callable.source_location)
+ return unless (result = parse_file(source_location[0]))
+
+ start_line = source_location[1]
+
+ result.value.find do |node|
+ case node
+ when ForNode
+ node.location.start_line == start_line
+ when CallNode
+ node.block.is_a?(BlockNode) && node.location.start_line == start_line
+ else
+ false
+ end
+ end
+ end
+ end
+
+ # Finds the AST node for a Thread::Backtrace::Location using best-effort
+ # line matching. Used on non-CRuby implementations.
+ class LineBacktraceLocationFind < Find
+ # Find the node for the given backtrace location by matching on line.
+ #--
+ #: (Thread::Backtrace::Location location) -> Node?
+ def find(location)
+ file = location.absolute_path || location.path
+ return unless (result = parse_file(file))
+
+ start_line = location.lineno
+ result.value.find { |node| node.location.start_line == start_line }
+ end
+ end
+ end
+end
diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb
new file mode 100644
index 0000000000..93d3c006b7
--- /dev/null
+++ b/lib/prism/parse_result.rb
@@ -0,0 +1,1211 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # @rbs!
+ # # An internal interface for a cache that can be used to compute code
+ # # units from byte offsets.
+ # interface _CodeUnitsCache
+ # def []: (Integer byte_offset) -> Integer
+ # end
+
+ # This represents a source of Ruby code that has been parsed. It is used in
+ # conjunction with locations to allow them to resolve line numbers and source
+ # ranges.
+ class Source
+ # Create a new source object with the given source code. This method should
+ # be used instead of `new` and it will return either a `Source` or a
+ # specialized and more performant `ASCIISource` if no multibyte characters
+ # are present in the source code.
+ #
+ # Note that if you are calling this method manually, you will need to supply
+ # the start_line and offsets parameters. start_line is the line number that
+ # the source starts on, which is typically 1 but can be different if this
+ # source is a subset of a larger source or if this is an eval. offsets is an
+ # array of byte offsets for the start of each line in the source code, which
+ # can be calculated by iterating through the source code and recording the
+ # byte offset whenever a newline character is encountered. The first
+ # element is always 0 to mark the first line.
+ #--
+ #: (String source, Integer start_line, Array[Integer] offsets) -> Source
+ def self.for(source, start_line, offsets)
+ if source.ascii_only?
+ ASCIISource.new(source, start_line, offsets)
+ elsif source.encoding == Encoding::BINARY
+ source.force_encoding(Encoding::UTF_8)
+
+ if source.valid_encoding?
+ new(source, start_line, offsets)
+ else
+ # This is an extremely niche use case where the file is marked as
+ # binary, contains multi-byte characters, and those characters are not
+ # valid UTF-8. In this case we'll mark it as binary and fall back to
+ # treating everything as a single-byte character. This _may_ cause
+ # problems when asking for code units, but it appears to be the
+ # cleanest solution at the moment.
+ source.force_encoding(Encoding::BINARY)
+ ASCIISource.new(source, start_line, offsets)
+ end
+ else
+ new(source, start_line, offsets)
+ end
+ end
+
+ # The source code that this source object represents.
+ attr_reader :source #: String
+
+ # The line number where this source starts.
+ attr_reader :start_line #: Integer
+
+ # The list of newline byte offsets in the source code. When initialized from
+ # the C extension, this may be a packed binary string of uint32_t values
+ # that is lazily unpacked on first access.
+ #--
+ #: () -> Array[Integer]
+ def offsets
+ offsets = @offsets
+ return offsets if offsets.is_a?(Array)
+ @offsets = offsets.unpack("L*")
+ end
+
+ # Create a new source object with the given source code. The offsets
+ # parameter can be either an Array of Integer byte offsets or a packed
+ # binary string of uint32_t values (from the C extension).
+ #--
+ #: (String source, Integer start_line, Array[Integer] | String offsets) -> void
+ def initialize(source, start_line, offsets)
+ @source = source
+ @start_line = start_line
+ @offsets = offsets
+ end
+
+ # Replace the value of start_line with the given value.
+ #--
+ #: (Integer start_line) -> void
+ def replace_start_line(start_line)
+ @start_line = start_line
+ end
+
+ # Replace the value of offsets with the given value.
+ #--
+ #: (Array[Integer] offsets) -> void
+ def replace_offsets(offsets)
+ @offsets = offsets
+ end
+
+ # Returns the encoding of the source code, which is set by parameters to the
+ # parser or by the encoding magic comment.
+ #--
+ #: () -> Encoding
+ def encoding
+ source.encoding
+ end
+
+ # Returns the lines of the source code as an array of strings.
+ #--
+ #: () -> Array[String]
+ def lines
+ source.lines
+ end
+
+ # Perform a byteslice on the source code using the given byte offset and
+ # byte length.
+ #--
+ #: (Integer byte_offset, Integer length) -> String
+ def slice(byte_offset, length)
+ source.byteslice(byte_offset, length) or raise
+ end
+
+ # Converts the line number and column in bytes to a byte offset.
+ #--
+ #: (Integer line, Integer column) -> Integer
+ def byte_offset(line, column)
+ normal = line - @start_line
+ raise IndexError if normal < 0
+ offsets.fetch(normal) + column
+ rescue IndexError
+ raise ArgumentError, "line #{line} is out of range"
+ end
+
+ # Binary search through the offsets to find the line number for the given
+ # byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def line(byte_offset)
+ start_line + find_line(byte_offset)
+ end
+
+ # Return the byte offset of the start of the line corresponding to the given
+ # byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def line_start(byte_offset)
+ offsets[find_line(byte_offset)]
+ end
+
+ # Returns the byte offset of the end of the line corresponding to the given
+ # byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def line_end(byte_offset)
+ offsets[find_line(byte_offset) + 1] || source.bytesize
+ end
+
+ # Return the column in bytes for the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def column(byte_offset)
+ byte_offset - line_start(byte_offset)
+ end
+
+ # Return the character offset for the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def character_offset(byte_offset)
+ (source.byteslice(0, byte_offset) or raise).length
+ end
+
+ # Return the column in characters for the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def character_column(byte_offset)
+ character_offset(byte_offset) - character_offset(line_start(byte_offset))
+ end
+
+ # Returns the offset from the start of the file for the given byte offset
+ # counting in code units for the given encoding.
+ #
+ # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the
+ # concept of code units that differs from the number of characters in other
+ # encodings, it is not captured here.
+ #
+ # We purposefully replace invalid and undefined characters with replacement
+ # characters in this conversion. This happens for two reasons. First, it's
+ # possible that the given byte offset will not occur on a character
+ # boundary. Second, it's possible that the source code will contain a
+ # character that has no equivalent in the given encoding.
+ #--
+ #: (Integer byte_offset, Encoding encoding) -> Integer
+ def code_units_offset(byte_offset, encoding)
+ return byte_offset if encoding == Encoding::UTF_8
+
+ byteslice = (source.byteslice(0, byte_offset) or raise).encode(encoding, invalid: :replace, undef: :replace)
+
+ if encoding == Encoding::UTF_16LE || encoding == Encoding::UTF_16BE
+ byteslice.bytesize / 2
+ else
+ byteslice.length
+ end
+ end
+
+ # Generate a cache that targets a specific encoding for calculating code
+ # unit offsets.
+ #--
+ #: (Encoding encoding) -> CodeUnitsCache
+ def code_units_cache(encoding)
+ CodeUnitsCache.new(source, encoding)
+ end
+
+ # Returns the column in code units for the given encoding for the
+ # given byte offset.
+ #--
+ #: (Integer byte_offset, Encoding encoding) -> Integer
+ def code_units_column(byte_offset, encoding)
+ code_units_offset(byte_offset, encoding) - code_units_offset(line_start(byte_offset), encoding)
+ end
+
+ # Freeze this object and the objects it contains.
+ #--
+ #: () -> void
+ def deep_freeze
+ source.freeze
+ offsets.freeze
+ freeze
+ end
+
+ # Binary search through the offsets to find the index for the given
+ # byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def find_line(byte_offset) # :nodoc:
+ index = offsets.bsearch_index { |offset| offset > byte_offset } || offsets.length
+ index - 1
+ end
+ end
+
+ # A cache that can be used to quickly compute code unit offsets from byte
+ # offsets. It purposefully provides only a single #[] method to access the
+ # cache in order to minimize surface area.
+ #
+ # Note that there are some known issues here that may or may not be addressed
+ # in the future:
+ #
+ # * The first is that there are issues when the cache computes values that are
+ # not on character boundaries. This can result in subsequent computations
+ # being off by one or more code units.
+ # * The second is that this cache is currently unbounded. In theory we could
+ # introduce some kind of LRU cache to limit the number of entries, but this
+ # has not yet been implemented.
+ #
+ class CodeUnitsCache
+ # Counter used for UTF-8, where one code unit equals one byte.
+ class UTF8Counter # :nodoc:
+ #: (Integer byte_offset, Integer byte_length) -> Integer
+ def count(byte_offset, byte_length)
+ byte_length
+ end
+ end
+
+ class UTF16Counter # :nodoc:
+ # @rbs @source: String
+ # @rbs @encoding: Encoding
+
+ #: (String source, Encoding encoding) -> void
+ def initialize(source, encoding)
+ @source = source
+ @encoding = encoding
+ end
+
+ #: (Integer byte_offset, Integer byte_length) -> Integer
+ def count(byte_offset, byte_length)
+ (@source.byteslice(byte_offset, byte_length) or raise).encode(@encoding, invalid: :replace, undef: :replace).bytesize / 2
+ end
+ end
+
+ # Counter used for UTF-32, where one code unit equals one code point and
+ # matches String#length. Also used as a best-effort fallback for any other
+ # encoding that does not have a dedicated counter.
+ class UTF32Counter # :nodoc:
+ # @rbs @source: String
+ # @rbs @encoding: Encoding
+
+ #: (String source, Encoding encoding) -> void
+ def initialize(source, encoding)
+ @source = source
+ @encoding = encoding
+ end
+
+ #: (Integer byte_offset, Integer byte_length) -> Integer
+ def count(byte_offset, byte_length)
+ (@source.byteslice(byte_offset, byte_length) or raise).encode(@encoding, invalid: :replace, undef: :replace).length
+ end
+ end
+
+ private_constant :UTF8Counter, :UTF16Counter, :UTF32Counter
+
+ # @rbs @source: String
+ # @rbs @counter: UTF8Counter | UTF16Counter | UTF32Counter
+ # @rbs @cache: Hash[Integer, Integer]
+ # @rbs @offsets: Array[Integer]
+
+ # Initialize a new cache with the given source and encoding.
+ #--
+ #: (String source, Encoding encoding) -> void
+ def initialize(source, encoding)
+ @source = source
+ @counter =
+ case encoding
+ when Encoding::UTF_8
+ UTF8Counter.new
+ when Encoding::UTF_16LE, Encoding::UTF_16BE
+ UTF16Counter.new(source, encoding)
+ else
+ UTF32Counter.new(source, encoding)
+ end
+
+ @cache = {} #: Hash[Integer, Integer]
+ @offsets = [] #: Array[Integer]
+ end
+
+ # Retrieve the code units offset from the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def [](byte_offset)
+ @cache[byte_offset] ||=
+ if (index = @offsets.bsearch_index { |offset| offset > byte_offset }).nil?
+ @offsets << byte_offset
+ @counter.count(0, byte_offset)
+ elsif index == 0
+ @offsets.unshift(byte_offset)
+ @counter.count(0, byte_offset)
+ else
+ @offsets.insert(index, byte_offset)
+ offset = @offsets[index - 1]
+ @cache[offset] + @counter.count(offset, byte_offset - offset)
+ end
+ end
+ end
+
+ # Specialized version of Prism::Source for source code that includes ASCII
+ # characters only. This class is used to apply performance optimizations that
+ # cannot be applied to sources that include multibyte characters.
+ #
+ # In the extremely rare case that a source includes multi-byte characters but
+ # is marked as binary because of a magic encoding comment and it cannot be
+ # eagerly converted to UTF-8, this class will be used as well. This is because
+ # at that point we will treat everything as single-byte characters.
+ class ASCIISource < Source
+ # Return the character offset for the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def character_offset(byte_offset)
+ byte_offset
+ end
+
+ # Return the column in characters for the given byte offset.
+ #--
+ #: (Integer byte_offset) -> Integer
+ def character_column(byte_offset)
+ byte_offset - line_start(byte_offset)
+ end
+
+ # Returns the offset from the start of the file for the given byte offset
+ # counting in code units for the given encoding.
+ #
+ # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the
+ # concept of code units that differs from the number of characters in other
+ # encodings, it is not captured here.
+ #--
+ #: (Integer byte_offset, Encoding encoding) -> Integer
+ def code_units_offset(byte_offset, encoding)
+ byte_offset
+ end
+
+ # Returns a cache that is the identity function in order to maintain the
+ # same interface. We can do this because code units are always equivalent to
+ # byte offsets for ASCII-only sources.
+ #--
+ #: (Encoding encoding) -> _CodeUnitsCache
+ def code_units_cache(encoding)
+ ->(byte_offset) { byte_offset }
+ end
+
+ # Specialized version of `code_units_column` that does not depend on
+ # `code_units_offset`, which is a more expensive operation. This is
+ # essentially the same as `Prism::Source#column`.
+ #--
+ #: (Integer byte_offset, Encoding encoding) -> Integer
+ def code_units_column(byte_offset, encoding)
+ byte_offset - line_start(byte_offset)
+ end
+ end
+
+ # This represents a location in the source.
+ class Location
+ # A Source object that is used to determine more information from the given
+ # offset and length.
+ attr_reader :source #: Source
+ protected :source
+
+ # The byte offset from the beginning of the source where this location
+ # starts.
+ attr_reader :start_offset #: Integer
+
+ # The length of this location in bytes.
+ attr_reader :length #: Integer
+
+ # @rbs @leading_comments: Array[Comment]?
+ # @rbs @trailing_comments: Array[Comment]?
+
+ # Create a new location object with the given source, start byte offset, and
+ # byte length.
+ #--
+ #: (Source source, Integer start_offset, Integer length) -> void
+ def initialize(source, start_offset, length)
+ @source = source
+ @start_offset = start_offset
+ @length = length
+
+ # These are used to store comments that are associated with this location.
+ # They are initialized to `nil` to save on memory when there are no
+ # comments to be attached and/or the comment-related APIs are not used.
+ @leading_comments = nil
+ @trailing_comments = nil
+ end
+
+ # These are the comments that are associated with this location that exist
+ # before the start of this location.
+ #--
+ #: () -> Array[Comment]
+ def leading_comments
+ @leading_comments ||= []
+ end
+
+ # Attach a comment to the leading comments of this location.
+ #--
+ #: (Comment comment) -> void
+ def leading_comment(comment)
+ leading_comments << comment
+ end
+
+ # These are the comments that are associated with this location that exist
+ # after the end of this location.
+ #--
+ #: () -> Array[Comment]
+ def trailing_comments
+ @trailing_comments ||= []
+ end
+
+ # Attach a comment to the trailing comments of this location.
+ #--
+ #: (Comment comment) -> void
+ def trailing_comment(comment)
+ trailing_comments << comment
+ end
+
+ # Returns all comments that are associated with this location (both leading
+ # and trailing comments).
+ #--
+ #: () -> Array[Comment]
+ def comments
+ [*@leading_comments, *@trailing_comments] #: Array[Comment]
+ end
+
+ # Create a new location object with the given options.
+ #--
+ #: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location
+ def copy(source: self.source, start_offset: self.start_offset, length: self.length)
+ Location.new(source, start_offset, length)
+ end
+
+ # Returns a new location that is the result of chopping off the last byte.
+ #--
+ #: () -> Location
+ def chop
+ copy(length: length == 0 ? length : length - 1)
+ end
+
+ # Returns a string representation of this location.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
+ end
+
+ # Returns all of the lines of the source code associated with this location.
+ #--
+ #: () -> Array[String]
+ def source_lines
+ source.lines
+ end
+
+ # The source code that this location represents.
+ #--
+ #: () -> String
+ def slice
+ source.slice(start_offset, length)
+ end
+
+ # The source code that this location represents starting from the beginning
+ # of the line that this location starts on to the end of the line that this
+ # location ends on.
+ #--
+ #: () -> String
+ def slice_lines
+ line_start = source.line_start(start_offset)
+ line_end = source.line_end(end_offset)
+ source.slice(line_start, line_end - line_start)
+ end
+
+ # The character offset from the beginning of the source where this location
+ # starts.
+ #--
+ #: () -> Integer
+ def start_character_offset
+ source.character_offset(start_offset)
+ end
+
+ # The offset from the start of the file in code units of the given encoding.
+ #--
+ #: (Encoding encoding) -> Integer
+ def start_code_units_offset(encoding = Encoding::UTF_16LE)
+ source.code_units_offset(start_offset, encoding)
+ end
+
+ # The start offset from the start of the file in code units using the given
+ # cache to fetch or calculate the value.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_start_code_units_offset(cache)
+ cache[start_offset]
+ end
+
+ # The byte offset from the beginning of the source where this location ends.
+ #--
+ #: () -> Integer
+ def end_offset
+ start_offset + length
+ end
+
+ # The character offset from the beginning of the source where this location
+ # ends.
+ #--
+ #: () -> Integer
+ def end_character_offset
+ source.character_offset(end_offset)
+ end
+
+ # The offset from the start of the file in code units of the given encoding.
+ #--
+ #: (Encoding encoding) -> Integer
+ def end_code_units_offset(encoding = Encoding::UTF_16LE)
+ source.code_units_offset(end_offset, encoding)
+ end
+
+ # The end offset from the start of the file in code units using the given
+ # cache to fetch or calculate the value.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_end_code_units_offset(cache)
+ cache[end_offset]
+ end
+
+ # The line number where this location starts.
+ #--
+ #: () -> Integer
+ def start_line
+ source.line(start_offset)
+ end
+
+ # The content of the line where this location starts before this location.
+ #--
+ #: () -> String
+ def start_line_slice
+ offset = source.line_start(start_offset)
+ source.slice(offset, start_offset - offset)
+ end
+
+ # The line number where this location ends.
+ #--
+ #: () -> Integer
+ def end_line
+ source.line(end_offset)
+ end
+
+ # The column in bytes where this location starts from the start of
+ # the line.
+ #--
+ #: () -> Integer
+ def start_column
+ source.column(start_offset)
+ end
+
+ # The column in characters where this location ends from the start of
+ # the line.
+ #--
+ #: () -> Integer
+ def start_character_column
+ source.character_column(start_offset)
+ end
+
+ # The column in code units of the given encoding where this location
+ # starts from the start of the line.
+ #--
+ #: (?Encoding encoding) -> Integer
+ def start_code_units_column(encoding = Encoding::UTF_16LE)
+ source.code_units_column(start_offset, encoding)
+ end
+
+ # The start column in code units using the given cache to fetch or calculate
+ # the value.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_start_code_units_column(cache)
+ cache[start_offset] - cache[source.line_start(start_offset)]
+ end
+
+ # The column in bytes where this location ends from the start of the
+ # line.
+ #--
+ #: () -> Integer
+ def end_column
+ source.column(end_offset)
+ end
+
+ # The column in characters where this location ends from the start of
+ # the line.
+ #--
+ #: () -> Integer
+ def end_character_column
+ source.character_column(end_offset)
+ end
+
+ # The column in code units of the given encoding where this location
+ # ends from the start of the line.
+ #--
+ #: (?Encoding encoding) -> Integer
+ def end_code_units_column(encoding = Encoding::UTF_16LE)
+ source.code_units_column(end_offset, encoding)
+ end
+
+ # The end column in code units using the given cache to fetch or calculate
+ # the value.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_end_code_units_column(cache)
+ cache[end_offset] - cache[source.line_start(end_offset)]
+ end
+
+ # Implement the hash pattern matching interface for Location.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { start_offset: start_offset, end_offset: end_offset }
+ end
+
+ # Implement the pretty print interface for Location.
+ #--
+ #: (PP q) -> void
+ def pretty_print(q) # :nodoc:
+ q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})")
+ end
+
+ # Returns true if the given other location is equal to this location.
+ #--
+ #: (untyped other) -> bool
+ def ==(other)
+ Location === other &&
+ other.start_offset == start_offset &&
+ other.end_offset == end_offset
+ end
+
+ # Returns a new location that stretches from this location to the given
+ # other location. Raises an error if this location is not before the other
+ # location or if they don't share the same source.
+ #--
+ #: (Location other) -> Location
+ def join(other)
+ raise "Incompatible sources" if source != other.source
+ raise "Incompatible locations" if start_offset > other.start_offset
+
+ Location.new(source, start_offset, other.end_offset - start_offset)
+ end
+
+ # Join this location with the first occurrence of the string in the source
+ # that occurs after this location on the same line, and return the new
+ # location. This will raise an error if the string does not exist.
+ #--
+ #: (String string) -> Location
+ def adjoin(string)
+ line_suffix = source.slice(end_offset, source.line_end(end_offset) - end_offset)
+
+ line_suffix_index = line_suffix.byteindex(string)
+ raise "Could not find #{string}" if line_suffix_index.nil?
+
+ Location.new(source, start_offset, length + line_suffix_index + string.bytesize)
+ end
+ end
+
+ # This represents a comment that was encountered during parsing. It is the
+ # base class for all comment types.
+ class Comment
+ # The Location of this comment in the source.
+ attr_reader :location #: Location
+
+ # Create a new comment object with the given location.
+ #--
+ #: (Location location) -> void
+ def initialize(location)
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for Comment.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { location: location }
+ end
+
+ # Returns the content of the comment by slicing it from the source code.
+ #--
+ #: () -> String
+ def slice
+ location.slice
+ end
+
+ # Returns true if this comment happens on the same line as other code and
+ # false if the comment is by itself. This can only be true for inline
+ # comments and should be false for block comments.
+ #--
+ #: () -> bool
+ def trailing?
+ raise NotImplementedError, "trailing? is not implemented for #{self.class}"
+ end
+ end
+
+ # InlineComment objects are the most common. They correspond to comments in
+ # the source file like this one that start with #.
+ class InlineComment < Comment
+ # Returns true if this comment happens on the same line as other code and
+ # false if the comment is by itself.
+ #--
+ #: () -> bool
+ def trailing?
+ !location.start_line_slice.strip.empty?
+ end
+
+ # Returns a string representation of this comment.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::InlineComment @location=#{location.inspect}>"
+ end
+ end
+
+ # EmbDocComment objects correspond to comments that are surrounded by =begin
+ # and =end.
+ class EmbDocComment < Comment
+ # Returns false. This can only be true for inline comments.
+ #--
+ #: () -> bool
+ def trailing?
+ false
+ end
+
+ # Returns a string representation of this comment.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::EmbDocComment @location=#{location.inspect}>"
+ end
+ end
+
+ # This represents a magic comment that was encountered during parsing.
+ class MagicComment
+ # A Location object representing the location of the key in the source.
+ attr_reader :key_loc #: Location
+
+ # A Location object representing the location of the value in the source.
+ attr_reader :value_loc #: Location
+
+ # Create a new magic comment object with the given key and value locations.
+ #--
+ #: (Location key_loc, Location value_loc) -> void
+ def initialize(key_loc, value_loc)
+ @key_loc = key_loc
+ @value_loc = value_loc
+ end
+
+ # Returns the key of the magic comment by slicing it from the source code.
+ #--
+ #: () -> String
+ def key
+ key_loc.slice
+ end
+
+ # Returns the value of the magic comment by slicing it from the source code.
+ #--
+ #: () -> String
+ def value
+ value_loc.slice
+ end
+
+ # Implement the hash pattern matching interface for MagicComment.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { key_loc: key_loc, value_loc: value_loc }
+ end
+
+ # Returns a string representation of this magic comment.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>"
+ end
+ end
+
+ # This represents an error that was encountered during parsing.
+ class ParseError
+ # The type of error. This is an _internal_ symbol that is used for
+ # communicating with translation layers. It is not meant to be public API.
+ attr_reader :type #: Symbol
+
+ # The message associated with this error.
+ attr_reader :message #: String
+
+ # A Location object representing the location of this error in the source.
+ attr_reader :location #: Location
+
+ # The level of this error.
+ attr_reader :level #: Symbol
+
+ # Create a new error object with the given message and location.
+ #--
+ #: (Symbol type, String message, Location location, Symbol level) -> void
+ def initialize(type, message, location, level)
+ @type = type
+ @message = message
+ @location = location
+ @level = level
+ end
+
+ # Implement the hash pattern matching interface for ParseError.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { type: type, message: message, location: location, level: level }
+ end
+
+ # Returns a string representation of this error.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::ParseError @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
+ end
+ end
+
+ # This represents a warning that was encountered during parsing.
+ class ParseWarning
+ # The type of warning. This is an _internal_ symbol that is used for
+ # communicating with translation layers. It is not meant to be public API.
+ attr_reader :type #: Symbol
+
+ # The message associated with this warning.
+ attr_reader :message #: String
+
+ # A Location object representing the location of this warning in the source.
+ attr_reader :location #: Location
+
+ # The level of this warning.
+ attr_reader :level #: Symbol
+
+ # Create a new warning object with the given message and location.
+ #--
+ #: (Symbol type, String message, Location location, Symbol level) -> void
+ def initialize(type, message, location, level)
+ @type = type
+ @message = message
+ @location = location
+ @level = level
+ end
+
+ # Implement the hash pattern matching interface for ParseWarning.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { type: type, message: message, location: location, level: level }
+ end
+
+ # Returns a string representation of this warning.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ "#<Prism::ParseWarning @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
+ end
+ end
+
+ # This represents the result of a call to Prism.parse or Prism.parse_file.
+ # It contains the requested structure, any comments that were encounters,
+ # and any errors that were encountered.
+ class Result
+ # The list of comments that were encountered during parsing.
+ attr_reader :comments #: Array[Comment]
+
+ # The list of magic comments that were encountered during parsing.
+ attr_reader :magic_comments #: Array[MagicComment]
+
+ # An optional location that represents the location of the __END__ marker
+ # and the rest of the content of the file. This content is loaded into the
+ # DATA constant when the file being parsed is the main file being executed.
+ attr_reader :data_loc #: Location?
+
+ # The list of errors that were generated during parsing.
+ attr_reader :errors #: Array[ParseError]
+
+ # The list of warnings that were generated during parsing.
+ attr_reader :warnings #: Array[ParseWarning]
+
+ # A Source instance that represents the source code that was parsed.
+ attr_reader :source #: Source
+
+ # Create a new result object with the given values.
+ #--
+ #: (Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
+ def initialize(comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ @comments = comments
+ @magic_comments = magic_comments
+ @data_loc = data_loc
+ @errors = errors
+ @warnings = warnings
+ @continuable = continuable
+ @source = source
+ end
+
+ # Implement the hash pattern matching interface for Result.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings }
+ end
+
+ # Returns the encoding of the source code that was parsed.
+ #--
+ #: () -> Encoding
+ def encoding
+ source.encoding
+ end
+
+ # Returns true if there were no errors during parsing and false if there
+ # were.
+ #--
+ #: () -> bool
+ def success?
+ errors.empty?
+ end
+
+ # Returns true if there were errors during parsing and false if there were
+ # not.
+ #--
+ #: () -> bool
+ def failure?
+ !success?
+ end
+
+ # Returns true if the parsed source is an incomplete expression that could
+ # become valid with additional input. This is useful for REPL contexts (such
+ # as IRB) where the user may be entering a multi-line expression one line at
+ # a time and the implementation needs to determine whether to wait for more
+ # input or to evaluate what has been entered so far.
+ #
+ # Concretely, this returns true when every error present is caused by the
+ # parser reaching the end of the input before a construct was closed (e.g.
+ # an unclosed string, array, block, or keyword), and returns false when any
+ # error is caused by a token that makes the input structurally invalid
+ # regardless of what might follow (e.g. a stray `end`, `]`, or `)` with no
+ # matching opener).
+ #
+ # Examples:
+ #
+ # Prism.parse("1 + [").continuable? #=> true (unclosed array)
+ # Prism.parse("1 + ]").continuable? #=> false (stray ])
+ # Prism.parse("tap do").continuable? #=> true (unclosed block)
+ # Prism.parse("end.tap do").continuable? #=> false (stray end)
+ #
+ #--
+ #: () -> bool
+ def continuable?
+ @continuable
+ end
+
+ # Create a code units cache for the given encoding.
+ #--
+ #: (Encoding encoding) -> _CodeUnitsCache
+ def code_units_cache(encoding)
+ source.code_units_cache(encoding)
+ end
+ end
+
+ # This is a result specific to the `parse` and `parse_file` methods.
+ class ParseResult < Result
+ autoload :Comments, "prism/parse_result/comments"
+ autoload :Errors, "prism/parse_result/errors"
+ autoload :Newlines, "prism/parse_result/newlines"
+
+ private_constant :Comments
+ private_constant :Errors
+ private_constant :Newlines
+
+ # The syntax tree that was parsed from the source code.
+ attr_reader :value #: ProgramNode
+
+ # Create a new parse result object with the given values.
+ #--
+ #: (ProgramNode value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
+ def initialize(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ @value = value
+ super(comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ end
+
+ # Implement the hash pattern matching interface for ParseResult.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ super.merge!(value: value)
+ end
+
+ # Attach the list of comments to their respective locations in the tree.
+ #--
+ #: () -> void
+ def attach_comments!
+ Comments.new(self).attach! # steep:ignore
+ end
+
+ # Walk the tree and mark nodes that are on a new line, loosely emulating
+ # the behavior of CRuby's `:line` tracepoint event.
+ #--
+ #: () -> void
+ def mark_newlines!
+ value.accept(Newlines.new(source.offsets.size)) # steep:ignore
+ end
+
+ # Returns a string representation of the syntax tree with the errors
+ # displayed inline.
+ #--
+ #: () -> String
+ def errors_format
+ Errors.new(self).format
+ end
+ end
+
+ # This is a result specific to the `lex` and `lex_file` methods.
+ class LexResult < Result
+ # The list of tokens that were parsed from the source code.
+ attr_reader :value #: Array[[Token, Integer]]
+
+ # Create a new lex result object with the given values.
+ #--
+ #: (Array[[Token, Integer]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
+ def initialize(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ @value = value
+ super(comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ end
+
+ # Implement the hash pattern matching interface for LexResult.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ super.merge!(value: value)
+ end
+ end
+
+ # This is a result specific to the `parse_lex` and `parse_lex_file` methods.
+ class ParseLexResult < Result
+ # A tuple of the syntax tree and the list of tokens that were parsed from
+ # the source code.
+ attr_reader :value #: [ProgramNode, Array[[Token, Integer]]]
+
+ # Create a new parse lex result object with the given values.
+ #--
+ #: ([ProgramNode, Array[[Token, Integer]]] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
+ def initialize(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ @value = value
+ super(comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ end
+
+ # Implement the hash pattern matching interface for ParseLexResult.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ super.merge!(value: value)
+ end
+ end
+
+ # This represents a token from the Ruby source.
+ class Token
+ # The Source object that represents the source this token came from.
+ attr_reader :source #: Source
+ private :source
+
+ # The type of token that this token is.
+ attr_reader :type #: Symbol
+
+ # A byteslice of the source that this token represents.
+ attr_reader :value #: String
+
+ # @rbs @location: Location | Integer
+
+ # Create a new token object with the given type, value, and location.
+ #--
+ #: (Source source, Symbol type, String value, Location | Integer location) -> void
+ def initialize(source, type, value, location)
+ @source = source
+ @type = type
+ @value = value
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for Token.
+ #--
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { type: type, value: value, location: location }
+ end
+
+ # A Location object representing the location of this token in the source.
+ #--
+ #: () -> Location
+ def location
+ location = @location
+ return location if location.is_a?(Location)
+ @location = Location.new(source, location >> 32, location & 0xFFFFFFFF)
+ end
+
+ # Implement the pretty print interface for Token.
+ #--
+ #: (PP q) -> void
+ def pretty_print(q) # :nodoc:
+ q.group do
+ q.text(type.to_s)
+ self.location.pretty_print(q)
+ q.text("(")
+ q.nest(2) do
+ q.breakable("")
+ q.pp(value)
+ end
+ q.breakable("")
+ q.text(")")
+ end
+ end
+
+ # Returns true if the given other token is equal to this token.
+ #--
+ #: (untyped other) -> bool
+ def ==(other)
+ Token === other &&
+ other.type == type &&
+ other.value == value
+ end
+
+ # Returns a string representation of this token.
+ #--
+ #: () -> String
+ def inspect # :nodoc:
+ location
+ super
+ end
+
+ # Freeze this object and the objects it contains.
+ #--
+ #: () -> void
+ def deep_freeze
+ value.freeze
+ location.freeze
+ freeze
+ end
+ end
+
+ # This object is passed to the various Prism.* methods that accept the
+ # `scopes` option as an element of the list. It defines both the local
+ # variables visible at that scope as well as the forwarding parameters
+ # available at that scope.
+ class Scope
+ # The list of local variables that are defined in this scope. This should be
+ # defined as an array of symbols.
+ attr_reader :locals #: Array[Symbol]
+
+ # The list of local variables that are forwarded to the next scope. This
+ # should by defined as an array of symbols containing the specific values of
+ # :*, :**, :&, or :"...".
+ attr_reader :forwarding #: Array[Symbol]
+
+ # Create a new scope object with the given locals and forwarding.
+ #--
+ #: (Array[Symbol] locals, Array[Symbol] forwarding) -> void
+ def initialize(locals, forwarding)
+ @locals = locals
+ @forwarding = forwarding
+ end
+ end
+
+ # Create a new scope with the given locals and forwarding options that is
+ # suitable for passing into one of the Prism.* methods that accepts the
+ # `scopes` option.
+ #--
+ #: (?locals: Array[Symbol], ?forwarding: Array[Symbol]) -> Scope
+ def self.scope(locals: [], forwarding: [])
+ Scope.new(locals, forwarding)
+ end
+end
diff --git a/lib/prism/parse_result/comments.rb b/lib/prism/parse_result/comments.rb
new file mode 100644
index 0000000000..df80792d39
--- /dev/null
+++ b/lib/prism/parse_result/comments.rb
@@ -0,0 +1,219 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ class ParseResult < Result
+ # When we've parsed the source, we have both the syntax tree and the list of
+ # comments that we found in the source. This class is responsible for
+ # walking the tree and finding the nearest location to attach each comment.
+ #
+ # It does this by first finding the nearest locations to each comment.
+ # Locations can either come from nodes directly or from location fields on
+ # nodes. For example, a `ClassNode` has an overall location encompassing the
+ # entire class, but it also has a location for the `class` keyword.
+ #
+ # Once the nearest locations are found, it determines which one to attach
+ # to. If it's a trailing comment (a comment on the same line as other source
+ # code), it will favor attaching to the nearest location that occurs before
+ # the comment. Otherwise it will favor attaching to the nearest location
+ # that is after the comment.
+ class Comments
+ # @rbs!
+ # # An internal interface for a target that comments can be attached
+ # # to. This is either going to be a NodeTarget or a CommentTarget.
+ # interface _CommentTarget
+ # def start_offset: () -> Integer
+ # def end_offset: () -> Integer
+ # def encloses?: (Comment) -> bool
+ # def leading_comment: (Comment) -> void
+ # def trailing_comment: (Comment) -> void
+ # end
+
+ # A target for attaching comments that is based on a specific node's
+ # location.
+ class NodeTarget # :nodoc:
+ attr_reader :node #: node
+
+ #: (node node) -> void
+ def initialize(node)
+ @node = node
+ end
+
+ #: () -> Integer
+ def start_offset
+ node.start_offset
+ end
+
+ #: () -> Integer
+ def end_offset
+ node.end_offset
+ end
+
+ #: (Comment comment) -> bool
+ def encloses?(comment)
+ start_offset <= comment.location.start_offset &&
+ comment.location.end_offset <= end_offset
+ end
+
+ #: (Comment comment) -> void
+ def leading_comment(comment)
+ node.location.leading_comment(comment)
+ end
+
+ #: (Comment comment) -> void
+ def trailing_comment(comment)
+ node.location.trailing_comment(comment)
+ end
+ end
+
+ # A target for attaching comments that is based on a location field on a
+ # node. For example, the `end` token of a ClassNode.
+ class LocationTarget # :nodoc:
+ attr_reader :location #: Location
+
+ #: (Location location) -> void
+ def initialize(location)
+ @location = location
+ end
+
+ #: () -> Integer
+ def start_offset
+ location.start_offset
+ end
+
+ #: () -> Integer
+ def end_offset
+ location.end_offset
+ end
+
+ #: (Comment comment) -> bool
+ def encloses?(comment)
+ false
+ end
+
+ #: (Comment comment) -> void
+ def leading_comment(comment)
+ location.leading_comment(comment)
+ end
+
+ #: (Comment comment) -> void
+ def trailing_comment(comment)
+ location.trailing_comment(comment)
+ end
+ end
+
+ # The parse result that we are attaching comments to.
+ attr_reader :parse_result #: ParseResult
+
+ # Create a new Comments object that will attach comments to the given
+ # parse result.
+ #--
+ #: (ParseResult parse_result) -> void
+ def initialize(parse_result)
+ @parse_result = parse_result
+ end
+
+ # Attach the comments to their respective locations in the tree by
+ # mutating the parse result.
+ #--
+ #: () -> void
+ def attach!
+ parse_result.comments.each do |comment|
+ preceding, enclosing, following = nearest_targets(parse_result.value, comment)
+
+ if comment.trailing?
+ if preceding
+ preceding.trailing_comment(comment)
+ else
+ (following || enclosing || NodeTarget.new(parse_result.value)).leading_comment(comment)
+ end
+ else
+ # If a comment exists on its own line, prefer a leading comment.
+ if following
+ following.leading_comment(comment)
+ elsif preceding
+ preceding.trailing_comment(comment)
+ else
+ (enclosing || NodeTarget.new(parse_result.value)).leading_comment(comment)
+ end
+ end
+ end
+ end
+
+ private
+
+ # Responsible for finding the nearest targets to the given comment within
+ # the context of the given encapsulating node.
+ #--
+ #: (node node, Comment comment) -> [_CommentTarget?, _CommentTarget?, _CommentTarget?]
+ def nearest_targets(node, comment)
+ comment_start = comment.location.start_offset
+ comment_end = comment.location.end_offset
+
+ targets = [] #: Array[_CommentTarget]
+ node.comment_targets.map do |value|
+ case value
+ when StatementsNode
+ targets.concat(value.body.map { |node| NodeTarget.new(node) })
+ when Node
+ targets << NodeTarget.new(value)
+ when Location
+ targets << LocationTarget.new(value)
+ end
+ end
+
+ targets.sort_by!(&:start_offset)
+ preceding = nil #: _CommentTarget?
+ following = nil #: _CommentTarget?
+
+ left = 0
+ right = targets.length
+
+ # This is a custom binary search that finds the nearest nodes to the
+ # given comment. When it finds a node that completely encapsulates the
+ # comment, it recurses downward into the tree.
+ while left < right
+ middle = (left + right) / 2
+ target = targets[middle]
+
+ target_start = target.start_offset
+ target_end = target.end_offset
+
+ if target.encloses?(comment)
+ # @type var target: NodeTarget
+ # The comment is completely contained by this target. Abandon the
+ # binary search at this level.
+ return nearest_targets(target.node, comment)
+ end
+
+ if target_end <= comment_start
+ # This target falls completely before the comment. Because we will
+ # never consider this target or any targets before it again, this
+ # target must be the closest preceding target we have encountered so
+ # far.
+ preceding = target
+ left = middle + 1
+ next
+ end
+
+ if comment_end <= target_start
+ # This target falls completely after the comment. Because we will
+ # never consider this target or any targets after it again, this
+ # target must be the closest following target we have encountered so
+ # far.
+ following = target
+ right = middle
+ next
+ end
+
+ # This should only happen if there is a bug in this parser.
+ raise "Comment location overlaps with a target location"
+ end
+
+ [preceding, NodeTarget.new(node), following]
+ end
+ end
+ end
+end
diff --git a/lib/prism/parse_result/errors.rb b/lib/prism/parse_result/errors.rb
new file mode 100644
index 0000000000..388309d23d
--- /dev/null
+++ b/lib/prism/parse_result/errors.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+require "stringio"
+
+module Prism
+ class ParseResult < Result
+ # An object to represent the set of errors on a parse result. This object
+ # can be used to format the errors in a human-readable way.
+ class Errors
+ # The parse result that contains the errors.
+ attr_reader :parse_result #: ParseResult
+
+ # Initialize a new set of errors from the given parse result.
+ #--
+ #: (ParseResult parse_result) -> void
+ def initialize(parse_result)
+ @parse_result = parse_result
+ end
+
+ # Formats the errors in a human-readable way and return them as a string.
+ #--
+ #: () -> String
+ def format
+ error_lines = {} #: Hash[Integer, Array[ParseError]]
+ parse_result.errors.each do |error|
+ location = error.location
+ (location.start_line..location.end_line).each do |line|
+ error_lines[line] ||= []
+ error_lines[line] << error
+ end
+ end
+
+ source_lines = parse_result.source.source.lines
+ source_lines << "" if error_lines.key?(source_lines.size + 1)
+
+ io = StringIO.new
+ source_lines.each.with_index(1) do |line, line_number|
+ io.puts(line)
+
+ (error_lines.delete(line_number) || []).each do |error|
+ location = error.location
+
+ case line_number
+ when location.start_line
+ io.print(" " * location.start_column + "^")
+
+ if location.start_line == location.end_line
+ if location.start_column != location.end_column
+ io.print("~" * (location.end_column - location.start_column - 1))
+ end
+
+ io.puts(" " + error.message)
+ else
+ io.puts("~" * (line.bytesize - location.start_column))
+ end
+ when location.end_line
+ io.puts("~" * location.end_column + " " + error.message)
+ else
+ io.puts("~" * line.bytesize)
+ end
+ end
+ end
+
+ io.puts
+ io.string
+ end
+ end
+ end
+end
diff --git a/lib/prism/parse_result/newlines.rb b/lib/prism/parse_result/newlines.rb
new file mode 100644
index 0000000000..450c790226
--- /dev/null
+++ b/lib/prism/parse_result/newlines.rb
@@ -0,0 +1,204 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ class ParseResult < Result
+ # The :line tracepoint event gets fired whenever the Ruby VM encounters an
+ # expression on a new line. The types of expressions that can trigger this
+ # event are:
+ #
+ # * if statements
+ # * unless statements
+ # * nodes that are children of statements lists
+ #
+ # In order to keep track of the newlines, we have a list of offsets that
+ # come back from the parser. We assign these offsets to the first nodes that
+ # we find in the tree that are on those lines.
+ #
+ # Note that the logic in this file should be kept in sync with the Java
+ # MarkNewlinesVisitor, since that visitor is responsible for marking the
+ # newlines for JRuby/TruffleRuby.
+ #
+ # This file is autoloaded only when `mark_newlines!` is called, so the
+ # re-opening of the various nodes in this file will only be performed in
+ # that case. We do that to avoid storing the extra `@newline` instance
+ # variable on every node if we don't need it.
+ class Newlines < Visitor
+ # The map of lines indices to whether or not they have been marked as
+ # emitting a newline event.
+ # @rbs @lines: Array[bool]
+
+ # Create a new Newlines visitor with the given newline offsets.
+ #--
+ #: (Integer lines) -> void
+ def initialize(lines)
+ @lines = Array.new(1 + lines, false)
+ end
+
+ # Permit block nodes to mark newlines within themselves.
+ #--
+ #: (BlockNode node) -> void
+ def visit_block_node(node)
+ old_lines = @lines
+ @lines = Array.new(old_lines.size, false)
+
+ begin
+ super(node)
+ ensure
+ @lines = old_lines
+ end
+ end
+
+ # Permit lambda nodes to mark newlines within themselves.
+ #--
+ #: (LambdaNode node) -> void
+ def visit_lambda_node(node)
+ old_lines = @lines
+ @lines = Array.new(old_lines.size, false)
+
+ begin
+ super(node)
+ ensure
+ @lines = old_lines
+ end
+ end
+
+ # Mark if nodes as newlines.
+ #--
+ #: (IfNode node) -> void
+ def visit_if_node(node)
+ node.newline_flag!(@lines)
+ super(node)
+ end
+
+ # Mark unless nodes as newlines.
+ #--
+ #: (UnlessNode node) -> void
+ def visit_unless_node(node)
+ node.newline_flag!(@lines)
+ super(node)
+ end
+
+ # Permit statements lists to mark newlines within themselves.
+ #--
+ #: (StatementsNode node) -> void
+ def visit_statements_node(node)
+ node.body.each do |child|
+ child.newline_flag!(@lines)
+ end
+ super(node)
+ end
+ end
+ end
+
+ class Node
+ # Tracks whether or not this node should emit a newline event when the
+ # instructions that it represents are executed.
+ # @rbs @newline_flag: bool
+
+ #: () -> bool
+ def newline_flag? # :nodoc:
+ !!defined?(@newline_flag)
+ end
+
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ line = location.start_line
+ unless lines[line]
+ lines[line] = true
+ @newline_flag = true
+ end
+ end
+ end
+
+ class BeginNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ # Never mark BeginNode with a newline flag, mark children instead.
+ end
+ end
+
+ class ParenthesesNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ # Never mark ParenthesesNode with a newline flag, mark children instead.
+ end
+ end
+
+ class IfNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ predicate.newline_flag!(lines)
+ end
+ end
+
+ class UnlessNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ predicate.newline_flag!(lines)
+ end
+ end
+
+ class UntilNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ predicate.newline_flag!(lines)
+ end
+ end
+
+ class WhileNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ predicate.newline_flag!(lines)
+ end
+ end
+
+ class RescueModifierNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ expression.newline_flag!(lines)
+ end
+ end
+
+ class InterpolatedMatchLastLineNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ first = parts.first
+ first.newline_flag!(lines) if first
+ end
+ end
+
+ class InterpolatedRegularExpressionNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ first = parts.first
+ first.newline_flag!(lines) if first
+ end
+ end
+
+ class InterpolatedStringNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ first = parts.first
+ first.newline_flag!(lines) if first
+ end
+ end
+
+ class InterpolatedSymbolNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ first = parts.first
+ first.newline_flag!(lines) if first
+ end
+ end
+
+ class InterpolatedXStringNode < Node
+ #: (Array[bool] lines) -> void
+ def newline_flag!(lines) # :nodoc:
+ first = parts.first
+ first.newline_flag!(lines) if first
+ end
+ end
+end
diff --git a/lib/prism/pattern.rb b/lib/prism/pattern.rb
new file mode 100644
index 0000000000..be0493df05
--- /dev/null
+++ b/lib/prism/pattern.rb
@@ -0,0 +1,314 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # A pattern is an object that wraps a Ruby pattern matching expression. The
+ # expression would normally be passed to an `in` clause within a `case`
+ # expression or a rightward assignment expression. For example, in the
+ # following snippet:
+ #
+ # case node
+ # in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]
+ # end
+ #
+ # the pattern is the <tt>ConstantPathNode[...]</tt> expression.
+ #
+ # The pattern gets compiled into an object that responds to #call by running
+ # the #compile method. This method itself will run back through Prism to
+ # parse the expression into a tree, then walk the tree to generate the
+ # necessary callable objects. For example, if you wanted to compile the
+ # expression above into a callable, you would:
+ #
+ # callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile
+ # callable.call(node)
+ #
+ # The callable object returned by #compile is guaranteed to respond to #call
+ # with a single argument, which is the node to match against. It also is
+ # guaranteed to respond to #===, which means it itself can be used in a `case`
+ # expression, as in:
+ #
+ # case node
+ # when callable
+ # end
+ #
+ # If the query given to the initializer cannot be compiled into a valid
+ # matcher (either because of a syntax error or because it is using syntax we
+ # do not yet support) then a Prism::Pattern::CompilationError will be
+ # raised.
+ class Pattern
+ # Raised when the query given to a pattern is either invalid Ruby syntax or
+ # is using syntax that we don't yet support.
+ class CompilationError < StandardError
+ # Create a new CompilationError with the given representation of the node
+ # that caused the error.
+ #--
+ #: (String repr) -> void
+ def initialize(repr) # :nodoc:
+ super(<<~ERROR)
+ prism was unable to compile the pattern you provided into a usable
+ expression. It failed on to understand the node represented by:
+
+ #{repr}
+
+ Note that not all syntax supported by Ruby's pattern matching syntax
+ is also supported by prism's patterns. If you're using some syntax
+ that you believe should be supported, please open an issue on
+ GitHub at https://github.com/ruby/prism/issues/new.
+ ERROR
+ end
+ end
+
+ # The query that this pattern was initialized with.
+ attr_reader :query #: String
+ # @rbs @compiled: Proc?
+
+ # Create a new pattern with the given query. The query should be a string
+ # containing a Ruby pattern matching expression.
+ #--
+ #: (String query) -> void
+ def initialize(query)
+ @query = query
+ @compiled = nil
+ end
+
+ # Compile the query into a callable object that can be used to match against
+ # nodes.
+ #--
+ #: () -> Proc
+ def compile
+ result = Prism.parse("case nil\nin #{query}\nend")
+
+ case_match_node = result.value.statements.body.last
+ raise CompilationError, case_match_node.inspect unless case_match_node.is_a?(CaseMatchNode)
+
+ in_node = case_match_node.conditions.last
+ raise CompilationError, in_node.inspect unless in_node.is_a?(InNode)
+
+ compile_node(in_node.pattern)
+ end
+
+ # Scan the given node and all of its children for nodes that match the
+ # pattern. If a block is given, it will be called with each node that
+ # matches the pattern. If no block is given, an enumerator will be returned
+ # that will yield each node that matches the pattern.
+ #--
+ #: (node root) -> Enumerator[node, void]
+ #: (node root) { (node) -> void } -> void
+ def scan(root, &blk)
+ return to_enum(:scan, root) unless block_given?
+
+ @compiled ||= compile
+ queue = [root]
+
+ while (node = queue.shift)
+ yield node if @compiled.call(node) # steep:ignore
+ queue.concat(node.compact_child_nodes)
+ end
+ end
+
+ private
+
+ # Shortcut for combining two procs into one that returns true if both return
+ # true.
+ #--
+ #: (Proc left, Proc right) -> Proc
+ def combine_and(left, right) # :nodoc:
+ ->(other) { left.call(other) && right.call(other) }
+ end
+
+ # Shortcut for combining two procs into one that returns true if either
+ # returns true.
+ #--
+ #: (Proc left, Proc right) -> Proc
+ def combine_or(left, right) # :nodoc:
+ ->(other) { left.call(other) || right.call(other) }
+ end
+
+ # Raise an error because the given node is not supported. Note purposefully
+ # not typing this method since it is a no return method that Steep does not
+ # understand.
+ #--
+ #: (node node) -> bot
+ def compile_error(node) # :nodoc:
+ raise CompilationError, node.inspect
+ end
+
+ # in [foo, bar, baz]
+ #--
+ #: (ArrayPatternNode node) -> Proc
+ def compile_array_pattern_node(node) # :nodoc:
+ compile_error(node) if !node.rest.nil? || node.posts.any?
+
+ constant = node.constant
+ compiled_constant = compile_node(constant) if constant
+
+ preprocessed = node.requireds.map { |required| compile_node(required) }
+
+ compiled_requireds = ->(other) do
+ deconstructed = other.deconstruct
+
+ deconstructed.length == preprocessed.length &&
+ preprocessed
+ .zip(deconstructed)
+ .all? { |(matcher, value)| matcher.call(value) }
+ end
+
+ if compiled_constant
+ combine_and(compiled_constant, compiled_requireds)
+ else
+ compiled_requireds
+ end
+ end
+
+ # in foo | bar
+ #--
+ #: (AlternationPatternNode node) -> Proc
+ def compile_alternation_pattern_node(node) # :nodoc:
+ combine_or(compile_node(node.left), compile_node(node.right))
+ end
+
+ # in Prism::ConstantReadNode
+ #--
+ #: (ConstantPathNode node) -> Proc
+ def compile_constant_path_node(node) # :nodoc:
+ parent = node.parent
+
+ if parent.is_a?(ConstantReadNode) && parent.slice == "Prism"
+ name = node.name
+ raise CompilationError, node.inspect if name.nil?
+
+ compile_constant_name(node, name)
+ else
+ compile_error(node)
+ end
+ end
+
+ # in ConstantReadNode
+ # in String
+ #--
+ #: (ConstantReadNode node) -> Proc
+ def compile_constant_read_node(node) # :nodoc:
+ compile_constant_name(node, node.name)
+ end
+
+ # Compile a name associated with a constant.
+ #--
+ #: ((ConstantPathNode | ConstantReadNode) node, Symbol name) -> Proc
+ def compile_constant_name(node, name) # :nodoc:
+ if Prism.const_defined?(name, false)
+ clazz = Prism.const_get(name)
+
+ ->(other) { clazz === other }
+ elsif Object.const_defined?(name, false)
+ clazz = Object.const_get(name)
+
+ ->(other) { clazz === other }
+ else
+ compile_error(node)
+ end
+ end
+
+ # in InstanceVariableReadNode[name: Symbol]
+ # in { name: Symbol }
+ #--
+ #: (HashPatternNode node) -> Proc
+ def compile_hash_pattern_node(node) # :nodoc:
+ compile_error(node) if node.rest
+
+ if (constant = node.constant)
+ compiled_constant = compile_node(constant)
+ end
+
+ preprocessed =
+ node.elements.to_h do |element|
+ key = element.key
+ if key.is_a?(SymbolNode)
+ [key.unescaped.to_sym, compile_node(element.value)]
+ else
+ raise CompilationError, element.inspect
+ end
+ end
+
+ compiled_keywords = ->(other) do
+ deconstructed = other.deconstruct_keys(preprocessed.keys)
+
+ preprocessed.all? do |keyword, matcher|
+ deconstructed.key?(keyword) && matcher.call(deconstructed[keyword])
+ end
+ end
+
+ if compiled_constant
+ combine_and(compiled_constant, compiled_keywords)
+ else
+ compiled_keywords
+ end
+ end
+
+ # in nil
+ #--
+ #: (NilNode node) -> Proc
+ def compile_nil_node(node) # :nodoc:
+ ->(attribute) { attribute.nil? }
+ end
+
+ # in /foo/
+ #--
+ #: (RegularExpressionNode node) -> Proc
+ def compile_regular_expression_node(node) # :nodoc:
+ regexp = Regexp.new(node.unescaped, node.closing[1..])
+
+ ->(attribute) { regexp === attribute }
+ end
+
+ # in ""
+ # in "foo"
+ #--
+ #: (StringNode node) -> Proc
+ def compile_string_node(node) # :nodoc:
+ string = node.unescaped
+
+ ->(attribute) { string === attribute }
+ end
+
+ # in :+
+ # in :foo
+ #--
+ #: (SymbolNode node) -> Proc
+ def compile_symbol_node(node) # :nodoc:
+ symbol = node.unescaped.to_sym
+
+ ->(attribute) { symbol === attribute }
+ end
+
+ # Compile any kind of node. Dispatch out to the individual compilation
+ # methods based on the type of node.
+ #--
+ #: (node node) -> Proc
+ def compile_node(node) # :nodoc:
+ case node
+ when AlternationPatternNode
+ compile_alternation_pattern_node(node)
+ when ArrayPatternNode
+ compile_array_pattern_node(node)
+ when ConstantPathNode
+ compile_constant_path_node(node)
+ when ConstantReadNode
+ compile_constant_read_node(node)
+ when HashPatternNode
+ compile_hash_pattern_node(node)
+ when NilNode
+ compile_nil_node(node)
+ when RegularExpressionNode
+ compile_regular_expression_node(node)
+ when StringNode
+ compile_string_node(node)
+ when SymbolNode
+ compile_symbol_node(node)
+ else
+ compile_error(node)
+ end
+ end
+ end
+end
diff --git a/lib/prism/polyfill/append_as_bytes.rb b/lib/prism/polyfill/append_as_bytes.rb
new file mode 100644
index 0000000000..24218bd171
--- /dev/null
+++ b/lib/prism/polyfill/append_as_bytes.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+# Polyfill for String#append_as_bytes, which didn't exist until Ruby 3.4.
+if !("".respond_to?(:append_as_bytes))
+ String.include(
+ Module.new {
+ def append_as_bytes(*args)
+ args.each do |arg|
+ arg = Integer === arg ? [arg].pack("C") : arg.b
+ self.<<(arg) # steep:ignore
+ end
+ end
+ }
+ )
+end
diff --git a/lib/prism/polyfill/byteindex.rb b/lib/prism/polyfill/byteindex.rb
new file mode 100644
index 0000000000..98c6089f14
--- /dev/null
+++ b/lib/prism/polyfill/byteindex.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+# Polyfill for String#byteindex, which didn't exist until Ruby 3.2.
+if !("".respond_to?(:byteindex))
+ String.include(
+ Module.new {
+ def byteindex(needle, offset = 0)
+ charindex = index(needle, offset)
+ slice(0...charindex).bytesize if charindex
+ end
+ }
+ )
+end
diff --git a/lib/prism/polyfill/scan_byte.rb b/lib/prism/polyfill/scan_byte.rb
new file mode 100644
index 0000000000..9276e509fc
--- /dev/null
+++ b/lib/prism/polyfill/scan_byte.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+require "strscan"
+
+# Polyfill for StringScanner#scan_byte, which didn't exist until Ruby 3.4.
+if !(StringScanner.method_defined?(:scan_byte))
+ StringScanner.include(
+ Module.new {
+ def scan_byte # :nodoc:
+ get_byte&.b&.ord
+ end
+ }
+ )
+end
diff --git a/lib/prism/polyfill/unpack1.rb b/lib/prism/polyfill/unpack1.rb
new file mode 100644
index 0000000000..3fa9b5a0c5
--- /dev/null
+++ b/lib/prism/polyfill/unpack1.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
+# have Method#parameters implemented, so we check the arity instead if
+# necessary.
+if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1)
+ String.prepend(
+ Module.new {
+ def unpack1(format, offset: 0) # :nodoc:
+ offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore
+ end
+ }
+ )
+end
diff --git a/lib/prism/polyfill/warn.rb b/lib/prism/polyfill/warn.rb
new file mode 100644
index 0000000000..76a4264623
--- /dev/null
+++ b/lib/prism/polyfill/warn.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+# Polyfill for Kernel#warn with the category parameter. Not all Ruby engines
+# have Method#parameters implemented, so we check the arity instead if
+# necessary.
+if (method = Kernel.instance_method(:warn)).respond_to?(:parameters) ? method.parameters.none? { |_, name| name == :category } : (method.arity == -1)
+ Kernel.prepend(
+ Module.new {
+ def warn(*msgs, uplevel: nil, category: nil) # :nodoc:
+ case uplevel
+ when nil
+ super(*msgs)
+ when Integer
+ super(*msgs, uplevel: uplevel + 1)
+ else
+ super(*msgs, uplevel: uplevel.to_int + 1)
+ end
+ end
+ }
+ )
+
+ Object.prepend(
+ Module.new {
+ def warn(*msgs, uplevel: nil, category: nil) # :nodoc:
+ case uplevel
+ when nil
+ super(*msgs)
+ when Integer
+ super(*msgs, uplevel: uplevel + 1)
+ else
+ super(*msgs, uplevel: uplevel.to_int + 1)
+ end
+ end
+ }
+ )
+end
diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec
new file mode 100644
index 0000000000..aac056b3f8
--- /dev/null
+++ b/lib/prism/prism.gemspec
@@ -0,0 +1,232 @@
+# frozen_string_literal: true
+
+Gem::Specification.new do |spec|
+ spec.name = "prism"
+ spec.version = "1.9.0"
+ spec.authors = ["Shopify"]
+ spec.email = ["ruby@shopify.com"]
+
+ spec.summary = "Prism Ruby parser"
+ spec.homepage = "https://github.com/ruby/prism"
+ spec.license = "MIT"
+
+ spec.required_ruby_version = ">= 2.7.0"
+
+ spec.require_paths = ["lib"]
+ spec.files = [
+ "BSDmakefile",
+ "CHANGELOG.md",
+ "CODE_OF_CONDUCT.md",
+ "CONTRIBUTING.md",
+ "LICENSE.md",
+ "Makefile",
+ "README.md",
+ "config.yml",
+ "docs/build_system.md",
+ "docs/configuration.md",
+ "docs/cruby_compilation.md",
+ "docs/design.md",
+ "docs/encoding.md",
+ "docs/fuzzing.md",
+ "docs/heredocs.md",
+ "docs/javascript.md",
+ "docs/local_variable_depth.md",
+ "docs/mapping.md",
+ "docs/parser_translation.md",
+ "docs/parsing_rules.md",
+ "docs/releasing.md",
+ "docs/relocation.md",
+ "docs/ripper_translation.md",
+ "docs/ruby_api.md",
+ "docs/ruby_parser_translation.md",
+ "docs/serialization.md",
+ "docs/testing.md",
+ "ext/prism/api_node.c",
+ "ext/prism/extconf.rb",
+ "ext/prism/extension.c",
+ "ext/prism/extension.h",
+ "include/prism.h",
+ "include/prism/compiler/accel.h",
+ "include/prism/compiler/align.h",
+ "include/prism/compiler/exported.h",
+ "include/prism/compiler/fallthrough.h",
+ "include/prism/compiler/filesystem.h",
+ "include/prism/compiler/flex_array.h",
+ "include/prism/compiler/force_inline.h",
+ "include/prism/compiler/format.h",
+ "include/prism/compiler/inline.h",
+ "include/prism/compiler/nodiscard.h",
+ "include/prism/compiler/nonnull.h",
+ "include/prism/compiler/unused.h",
+ "include/prism/internal/allocator.h",
+ "include/prism/internal/allocator_debug.h",
+ "include/prism/internal/arena.h",
+ "include/prism/internal/bit.h",
+ "include/prism/internal/buffer.h",
+ "include/prism/internal/char.h",
+ "include/prism/internal/comments.h",
+ "include/prism/internal/constant_pool.h",
+ "include/prism/internal/diagnostic.h",
+ "include/prism/internal/encoding.h",
+ "include/prism/internal/integer.h",
+ "include/prism/internal/isinf.h",
+ "include/prism/internal/line_offset_list.h",
+ "include/prism/internal/list.h",
+ "include/prism/internal/magic_comments.h",
+ "include/prism/internal/memchr.h",
+ "include/prism/internal/node.h",
+ "include/prism/internal/options.h",
+ "include/prism/internal/parser.h",
+ "include/prism/internal/regexp.h",
+ "include/prism/internal/serialize.h",
+ "include/prism/internal/source.h",
+ "include/prism/internal/static_literals.h",
+ "include/prism/internal/strncasecmp.h",
+ "include/prism/internal/stringy.h",
+ "include/prism/internal/strpbrk.h",
+ "include/prism/internal/tokens.h",
+ "include/prism/arena.h",
+ "include/prism/ast.h",
+ "include/prism/buffer.h",
+ "include/prism/comments.h",
+ "include/prism/constant_pool.h",
+ "include/prism/diagnostic.h",
+ "include/prism/excludes.h",
+ "include/prism/integer.h",
+ "include/prism/json.h",
+ "include/prism/line_offset_list.h",
+ "include/prism/magic_comments.h",
+ "include/prism/node.h",
+ "include/prism/options.h",
+ "include/prism/parser.h",
+ "include/prism/prettyprint.h",
+ "include/prism/serialize.h",
+ "include/prism/source.h",
+ "include/prism/stream.h",
+ "include/prism/string_query.h",
+ "include/prism/stringy.h",
+ "include/prism/version.h",
+ "lib/prism.rb",
+ "lib/prism/compiler.rb",
+ "lib/prism/desugar_compiler.rb",
+ "lib/prism/dispatcher.rb",
+ "lib/prism/dot_visitor.rb",
+ "lib/prism/dsl.rb",
+ "lib/prism/ffi.rb",
+ "lib/prism/inspect_visitor.rb",
+ "lib/prism/lex_compat.rb",
+ "lib/prism/mutation_compiler.rb",
+ "lib/prism/node_ext.rb",
+ "lib/prism/node_find.rb",
+ "lib/prism/node.rb",
+ "lib/prism/parse_result.rb",
+ "lib/prism/parse_result/comments.rb",
+ "lib/prism/parse_result/errors.rb",
+ "lib/prism/parse_result/newlines.rb",
+ "lib/prism/pattern.rb",
+ "lib/prism/polyfill/append_as_bytes.rb",
+ "lib/prism/polyfill/byteindex.rb",
+ "lib/prism/polyfill/scan_byte.rb",
+ "lib/prism/polyfill/unpack1.rb",
+ "lib/prism/polyfill/warn.rb",
+ "lib/prism/reflection.rb",
+ "lib/prism/relocation.rb",
+ "lib/prism/serialize.rb",
+ "lib/prism/string_query.rb",
+ "lib/prism/translation.rb",
+ "lib/prism/translation/parser.rb",
+ "lib/prism/translation/parser_current.rb",
+ "lib/prism/translation/parser_versions.rb",
+ "lib/prism/translation/parser/builder.rb",
+ "lib/prism/translation/parser/compiler.rb",
+ "lib/prism/translation/parser/lexer.rb",
+ "lib/prism/translation/ripper.rb",
+ "lib/prism/translation/ripper/filter.rb",
+ "lib/prism/translation/ripper/lexer.rb",
+ "lib/prism/translation/ripper/sexp.rb",
+ "lib/prism/translation/ripper/shim.rb",
+ "lib/prism/translation/ruby_parser.rb",
+ "lib/prism/visitor.rb",
+ "prism.gemspec",
+ "rbi/generated/prism.rbi",
+ "rbi/generated/prism/compiler.rbi",
+ "rbi/generated/prism/desugar_compiler.rbi",
+ "rbi/generated/prism/dispatcher.rbi",
+ "rbi/generated/prism/dot_visitor.rbi",
+ "rbi/generated/prism/dsl.rbi",
+ "rbi/generated/prism/inspect_visitor.rbi",
+ "rbi/generated/prism/lex_compat.rbi",
+ "rbi/generated/prism/mutation_compiler.rbi",
+ "rbi/generated/prism/node.rbi",
+ "rbi/generated/prism/node_ext.rbi",
+ "rbi/generated/prism/node_find.rbi",
+ "rbi/generated/prism/parse_result.rbi",
+ "rbi/generated/prism/pattern.rbi",
+ "rbi/generated/prism/reflection.rbi",
+ "rbi/generated/prism/relocation.rbi",
+ "rbi/generated/prism/serialize.rbi",
+ "rbi/generated/prism/string_query.rbi",
+ "rbi/generated/prism/translation.rbi",
+ "rbi/generated/prism/visitor.rbi",
+ "rbi/generated/prism/parse_result/comments.rbi",
+ "rbi/generated/prism/parse_result/errors.rbi",
+ "rbi/generated/prism/parse_result/newlines.rbi",
+ "rbi/prism/translation/parser.rbi",
+ "rbi/prism/translation/parser_versions.rbi",
+ "rbi/prism/translation/ripper.rbi",
+ "rbi/rubyvm/node_find.rbi",
+ "sig/generated/prism.rbs",
+ "sig/generated/prism/compiler.rbs",
+ "sig/generated/prism/desugar_compiler.rbs",
+ "sig/generated/prism/dispatcher.rbs",
+ "sig/generated/prism/dot_visitor.rbs",
+ "sig/generated/prism/dsl.rbs",
+ "sig/generated/prism/inspect_visitor.rbs",
+ "sig/generated/prism/lex_compat.rbs",
+ "sig/generated/prism/mutation_compiler.rbs",
+ "sig/generated/prism/node.rbs",
+ "sig/generated/prism/node_ext.rbs",
+ "sig/generated/prism/node_find.rbs",
+ "sig/generated/prism/parse_result.rbs",
+ "sig/generated/prism/pattern.rbs",
+ "sig/generated/prism/reflection.rbs",
+ "sig/generated/prism/relocation.rbs",
+ "sig/generated/prism/serialize.rbs",
+ "sig/generated/prism/string_query.rbs",
+ "sig/generated/prism/translation.rbs",
+ "sig/generated/prism/visitor.rbs",
+ "sig/generated/prism/parse_result/comments.rbs",
+ "sig/generated/prism/parse_result/errors.rbs",
+ "sig/generated/prism/parse_result/newlines.rbs",
+ "src/arena.c",
+ "src/buffer.c",
+ "src/char.c",
+ "src/constant_pool.c",
+ "src/diagnostic.c",
+ "src/encoding.c",
+ "src/integer.c",
+ "src/json.c",
+ "src/line_offset_list.c",
+ "src/list.c",
+ "src/memchr.c",
+ "src/node.c",
+ "src/options.c",
+ "src/parser.c",
+ "src/prettyprint.c",
+ "src/prism.c",
+ "src/regexp.c",
+ "src/serialize.c",
+ "src/source.c",
+ "src/static_literals.c",
+ "src/string_query.c",
+ "src/stringy.c",
+ "src/strncasecmp.c",
+ "src/strpbrk.c",
+ "src/tokens.c"
+ ]
+
+ spec.extensions = ["ext/prism/extconf.rb"]
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
+ spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
+end
diff --git a/lib/prism/relocation.rb b/lib/prism/relocation.rb
new file mode 100644
index 0000000000..af0f792827
--- /dev/null
+++ b/lib/prism/relocation.rb
@@ -0,0 +1,665 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # Prism parses deterministically for the same input. This provides a nice
+ # property that is exposed through the #node_id API on nodes. Effectively this
+ # means that for the same input, these values will remain consistent every
+ # time the source is parsed. This means we can reparse the source same with a
+ # #node_id value and find the exact same node again.
+ #
+ # The Relocation module provides an API around this property. It allows you to
+ # "save" nodes and locations using a minimal amount of memory (just the
+ # node_id and a field identifier) and then reify them later.
+ module Relocation
+ # @rbs!
+ # type entry_value = untyped
+ # type entry_values = Hash[Symbol, entry_value]
+ #
+ # interface _Value
+ # def start_line: () -> Integer
+ # def end_line: () -> Integer
+ # def start_offset: () -> Integer
+ # def end_offset: () -> Integer
+ # def start_character_offset: () -> Integer
+ # def end_character_offset: () -> Integer
+ # def cached_start_code_units_offset: (_CodeUnitsCache cache) -> Integer
+ # def cached_end_code_units_offset: (_CodeUnitsCache cache) -> Integer
+ # def start_column: () -> Integer
+ # def end_column: () -> Integer
+ # def start_character_column: () -> Integer
+ # def end_character_column: () -> Integer
+ # def cached_start_code_units_column: (_CodeUnitsCache cache) -> Integer
+ # def cached_end_code_units_column: (_CodeUnitsCache cache) -> Integer
+ # def leading_comments: () -> Array[Comment]
+ # def trailing_comments: () -> Array[Comment]
+ # end
+ #
+ # interface _Field
+ # def fields: (_Value value) -> entry_values
+ # end
+
+ # An entry in a repository that will lazily reify its values when they are
+ # first accessed.
+ class Entry
+ # Raised if a value that could potentially be on an entry is missing
+ # because it was either not configured on the repository or it has not yet
+ # been fetched.
+ class MissingValueError < StandardError
+ end
+
+ # @rbs @repository: Repository?
+ # @rbs @values: Hash[Symbol, untyped]?
+
+ # Initialize a new entry with the given repository.
+ #--
+ #: (Repository repository) -> void
+ def initialize(repository)
+ @repository = repository
+ @values = nil
+ end
+
+ # Fetch the filepath of the value.
+ #--
+ #: () -> String
+ def filepath
+ fetch_value(:filepath)
+ end
+
+ # Fetch the start line of the value.
+ #--
+ #: () -> Integer
+ def start_line
+ fetch_value(:start_line)
+ end
+
+ # Fetch the end line of the value.
+ #--
+ #: () -> Integer
+ def end_line
+ fetch_value(:end_line)
+ end
+
+ # Fetch the start byte offset of the value.
+ #--
+ #: () -> Integer
+ def start_offset
+ fetch_value(:start_offset)
+ end
+
+ # Fetch the end byte offset of the value.
+ #--
+ #: () -> Integer
+ def end_offset
+ fetch_value(:end_offset)
+ end
+
+ # Fetch the start character offset of the value.
+ #--
+ #: () -> Integer
+ def start_character_offset
+ fetch_value(:start_character_offset)
+ end
+
+ # Fetch the end character offset of the value.
+ #--
+ #: () -> Integer
+ def end_character_offset
+ fetch_value(:end_character_offset)
+ end
+
+ # Fetch the start code units offset of the value, for the encoding that
+ # was configured on the repository.
+ #--
+ #: () -> Integer
+ def start_code_units_offset
+ fetch_value(:start_code_units_offset)
+ end
+
+ # Fetch the end code units offset of the value, for the encoding that was
+ # configured on the repository.
+ #--
+ #: () -> Integer
+ def end_code_units_offset
+ fetch_value(:end_code_units_offset)
+ end
+
+ # Fetch the start byte column of the value.
+ #--
+ #: () -> Integer
+ def start_column
+ fetch_value(:start_column)
+ end
+
+ # Fetch the end byte column of the value.
+ #--
+ #: () -> Integer
+ def end_column
+ fetch_value(:end_column)
+ end
+
+ # Fetch the start character column of the value.
+ #--
+ #: () -> Integer
+ def start_character_column
+ fetch_value(:start_character_column)
+ end
+
+ # Fetch the end character column of the value.
+ #--
+ #: () -> Integer
+ def end_character_column
+ fetch_value(:end_character_column)
+ end
+
+ # Fetch the start code units column of the value, for the encoding that
+ # was configured on the repository.
+ #--
+ #: () -> Integer
+ def start_code_units_column
+ fetch_value(:start_code_units_column)
+ end
+
+ # Fetch the end code units column of the value, for the encoding that was
+ # configured on the repository.
+ #--
+ #: () -> Integer
+ def end_code_units_column
+ fetch_value(:end_code_units_column)
+ end
+
+ # Fetch the leading comments of the value.
+ #--
+ #: () -> Array[CommentsField::Comment]
+ def leading_comments
+ fetch_value(:leading_comments)
+ end
+
+ # Fetch the trailing comments of the value.
+ #--
+ #: () -> Array[CommentsField::Comment]
+ def trailing_comments
+ fetch_value(:trailing_comments)
+ end
+
+ # Fetch the leading and trailing comments of the value.
+ #--
+ #: () -> Array[CommentsField::Comment]
+ def comments
+ [*leading_comments, *trailing_comments]
+ end
+
+ # Reify the values on this entry with the given values. This is an
+ # internal-only API that is called from the repository when it is time to
+ # reify the values.
+ #--
+ #: (entry_values values) -> void
+ def reify!(values) # :nodoc:
+ @repository = nil
+ @values = values
+ end
+
+ private
+
+ # Fetch a value from the entry, raising an error if it is missing.
+ #--
+ #: (Symbol name) -> entry_value
+ def fetch_value(name)
+ values.fetch(name) do
+ raise MissingValueError, "No value for #{name}, make sure the " \
+ "repository has been properly configured"
+ end
+ end
+
+ # Return the values from the repository, reifying them if necessary.
+ #--
+ #: () -> entry_values
+ def values
+ @values || (@repository&.reify!; @values) #: entry_values
+ end
+ end
+
+ # Represents the source of a repository that will be reparsed.
+ class Source
+ # The value that will need to be reparsed.
+ attr_reader :value #: untyped
+
+ # Initialize the source with the given value.
+ #--
+ #: (untyped value) -> void
+ def initialize(value)
+ @value = value
+ end
+
+ # Reparse the value and return the parse result.
+ #--
+ #: () -> ParseResult
+ def result
+ raise NotImplementedError, "Subclasses must implement #result"
+ end
+
+ # Create a code units cache for the given encoding.
+ #--
+ #: (Encoding encoding) -> _CodeUnitsCache
+ def code_units_cache(encoding)
+ result.code_units_cache(encoding)
+ end
+ end
+
+ # A source that is represented by a file path.
+ class SourceFilepath < Source
+ # Reparse the file and return the parse result.
+ #--
+ #: () -> ParseResult
+ def result
+ Prism.parse_file(value)
+ end
+ end
+
+ # A source that is represented by a string.
+ class SourceString < Source
+ # Reparse the string and return the parse result.
+ #--
+ #: () -> ParseResult
+ def result
+ Prism.parse(value)
+ end
+ end
+
+ # A field that represents the file path.
+ class FilepathField
+ # The file path that this field represents.
+ attr_reader :value #: String
+
+ # Initialize a new field with the given file path.
+ #--
+ #: (String value) -> void
+ def initialize(value)
+ @value = value
+ end
+
+ # Fetch the file path.
+ #--
+ #: (_Value _value) -> entry_values
+ def fields(_value)
+ { filepath: value }
+ end
+ end
+
+ # A field representing the start and end lines.
+ class LinesField
+ # Fetches the start and end line of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ { start_line: value.start_line, end_line: value.end_line }
+ end
+ end
+
+ # A field representing the start and end byte offsets.
+ class OffsetsField
+ # Fetches the start and end byte offset of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ { start_offset: value.start_offset, end_offset: value.end_offset }
+ end
+ end
+
+ # A field representing the start and end character offsets.
+ class CharacterOffsetsField
+ # Fetches the start and end character offset of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ {
+ start_character_offset: value.start_character_offset,
+ end_character_offset: value.end_character_offset
+ }
+ end
+ end
+
+ # A field representing the start and end code unit offsets.
+ class CodeUnitOffsetsField
+ # A pointer to the repository object that is used for lazily creating a
+ # code units cache.
+ attr_reader :repository #: Repository
+
+ # The associated encoding for the code units.
+ attr_reader :encoding #: Encoding
+
+ # @rbs @cache: _CodeUnitsCache?
+
+ # Initialize a new field with the associated repository and encoding.
+ #--
+ #: (Repository repository, Encoding encoding) -> void
+ def initialize(repository, encoding)
+ @repository = repository
+ @encoding = encoding
+ @cache = nil
+ end
+
+ # Fetches the start and end code units offset of a value for a particular
+ # encoding.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ {
+ start_code_units_offset: value.cached_start_code_units_offset(cache),
+ end_code_units_offset: value.cached_end_code_units_offset(cache)
+ }
+ end
+
+ private
+
+ # Lazily create a code units cache for the associated encoding.
+ #--
+ #: () -> _CodeUnitsCache
+ def cache
+ @cache ||= repository.code_units_cache(encoding)
+ end
+ end
+
+ # A field representing the start and end byte columns.
+ class ColumnsField
+ # Fetches the start and end byte column of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ { start_column: value.start_column, end_column: value.end_column }
+ end
+ end
+
+ # A field representing the start and end character columns.
+ class CharacterColumnsField
+ # Fetches the start and end character column of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ {
+ start_character_column: value.start_character_column,
+ end_character_column: value.end_character_column
+ }
+ end
+ end
+
+ # A field representing the start and end code unit columns for a specific
+ # encoding.
+ class CodeUnitColumnsField
+ # The repository object that is used for lazily creating a code units
+ # cache.
+ attr_reader :repository #: Repository
+
+ # The associated encoding for the code units.
+ attr_reader :encoding #: Encoding
+
+ # @rbs @cache: _CodeUnitsCache?
+
+ # Initialize a new field with the associated repository and encoding.
+ #--
+ #: (Repository repository, Encoding encoding) -> void
+ def initialize(repository, encoding)
+ @repository = repository
+ @encoding = encoding
+ @cache = nil
+ end
+
+ # Fetches the start and end code units column of a value for a particular
+ # encoding.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ {
+ start_code_units_column: value.cached_start_code_units_column(cache),
+ end_code_units_column: value.cached_end_code_units_column(cache)
+ }
+ end
+
+ private
+
+ # Lazily create a code units cache for the associated encoding.
+ #--
+ #: () -> _CodeUnitsCache
+ def cache
+ @cache ||= repository.code_units_cache(encoding)
+ end
+ end
+
+ # An abstract field used as the parent class of the two comments fields.
+ class CommentsField
+ # An object that represents a slice of a comment.
+ class Comment
+ # The slice of the comment.
+ attr_reader :slice #: String
+
+ # Initialize a new comment with the given slice.
+ #
+ #: (String slice) -> void
+ def initialize(slice)
+ @slice = slice
+ end
+ end
+
+ private
+
+ # Create comment objects from the given values.
+ #--
+ #: (entry_value values) -> Array[Comment]
+ def comments(values)
+ values.map { |value| Comment.new(value.slice) }
+ end
+ end
+
+ # A field representing the leading comments.
+ class LeadingCommentsField < CommentsField
+ # Fetches the leading comments of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ { leading_comments: comments(value.leading_comments) }
+ end
+ end
+
+ # A field representing the trailing comments.
+ class TrailingCommentsField < CommentsField
+ # Fetches the trailing comments of a value.
+ #--
+ #: (_Value value) -> entry_values
+ def fields(value)
+ { trailing_comments: comments(value.trailing_comments) }
+ end
+ end
+
+ # A repository is a configured collection of fields and a set of entries
+ # that knows how to reparse a source and reify the values.
+ class Repository
+ # Raised when multiple fields of the same type are configured on the same
+ # repository.
+ class ConfigurationError < StandardError
+ end
+
+ # The source associated with this repository. This will be either a
+ # SourceFilepath (the most common use case) or a SourceString.
+ attr_reader :source #: Source
+
+ # The fields that have been configured on this repository.
+ attr_reader :fields #: Hash[Symbol, _Field]
+
+ # The entries that have been saved on this repository.
+ attr_reader :entries #: Hash[Integer, Hash[Symbol, Entry]]
+
+ # Initialize a new repository with the given source.
+ #--
+ #: (Source source) -> void
+ def initialize(source)
+ @source = source
+ @fields = {}
+ @entries = Hash.new { |hash, node_id| hash[node_id] = {} }
+ end
+
+ # Create a code units cache for the given encoding from the source.
+ #--
+ #: (Encoding encoding) -> _CodeUnitsCache
+ def code_units_cache(encoding)
+ source.code_units_cache(encoding)
+ end
+
+ # Configure the filepath field for this repository and return self.
+ #--
+ #: () -> self
+ def filepath
+ raise ConfigurationError, "Can only specify filepath for a filepath source" unless source.is_a?(SourceFilepath)
+ field(:filepath, FilepathField.new(source.value))
+ end
+
+ # Configure the lines field for this repository and return self.
+ #--
+ #: () -> self
+ def lines
+ field(:lines, LinesField.new)
+ end
+
+ # Configure the offsets field for this repository and return self.
+ #--
+ #: () -> self
+ def offsets
+ field(:offsets, OffsetsField.new)
+ end
+
+ # Configure the character offsets field for this repository and return
+ # self.
+ #--
+ #: () -> self
+ def character_offsets
+ field(:character_offsets, CharacterOffsetsField.new)
+ end
+
+ # Configure the code unit offsets field for this repository for a specific
+ # encoding and return self.
+ #--
+ #: (Encoding encoding) -> self
+ def code_unit_offsets(encoding)
+ field(:code_unit_offsets, CodeUnitOffsetsField.new(self, encoding))
+ end
+
+ # Configure the columns field for this repository and return self.
+ #--
+ #: () -> self
+ def columns
+ field(:columns, ColumnsField.new)
+ end
+
+ # Configure the character columns field for this repository and return
+ # self.
+ #--
+ #: () -> self
+ def character_columns
+ field(:character_columns, CharacterColumnsField.new)
+ end
+
+ # Configure the code unit columns field for this repository for a specific
+ # encoding and return self.
+ #--
+ #: (Encoding encoding) -> self
+ def code_unit_columns(encoding)
+ field(:code_unit_columns, CodeUnitColumnsField.new(self, encoding))
+ end
+
+ # Configure the leading comments field for this repository and return
+ # self.
+ #--
+ #: () -> self
+ def leading_comments
+ field(:leading_comments, LeadingCommentsField.new)
+ end
+
+ # Configure the trailing comments field for this repository and return
+ # self.
+ #--
+ #: () -> self
+ def trailing_comments
+ field(:trailing_comments, TrailingCommentsField.new)
+ end
+
+ # Configure both the leading and trailing comment fields for this
+ # repository and return self.
+ #--
+ #: () -> self
+ def comments
+ leading_comments.trailing_comments
+ end
+
+ # This method is called from nodes and locations when they want to enter
+ # themselves into the repository. It it internal-only and meant to be
+ # called from the #save* APIs.
+ #--
+ #: (Integer node_id, Symbol field_name) -> Entry
+ def enter(node_id, field_name) # :nodoc:
+ entry = Entry.new(self)
+ @entries[node_id][field_name] = entry
+ entry
+ end
+
+ # This method is called from the entries in the repository when they need
+ # to reify their values. It is internal-only and meant to be called from
+ # the various value APIs.
+ #--
+ #: () -> void
+ def reify! # :nodoc:
+ result = source.result
+
+ # Attach the comments if they have been requested as part of the
+ # configuration of this repository.
+ if fields.key?(:leading_comments) || fields.key?(:trailing_comments)
+ result.attach_comments!
+ end
+
+ queue = [result.value] #: Array[Prism::node]
+ while (node = queue.shift)
+ @entries[node.node_id].each do |field_name, entry|
+ value = node.public_send(field_name)
+ values = {} #: entry_values
+
+ fields.each_value do |field|
+ values.merge!(field.fields(value))
+ end
+
+ entry.reify!(values)
+ end
+
+ queue.concat(node.compact_child_nodes)
+ end
+
+ @entries.clear
+ end
+
+ private
+
+ # Append the given field to the repository and return the repository so
+ # that these calls can be chained.
+ #--
+ #: (Symbol name, _Field) -> self
+ def field(name, value)
+ raise ConfigurationError, "Cannot specify multiple #{name} fields" if @fields.key?(name)
+ @fields[name] = value
+ self
+ end
+ end
+
+ # Create a new repository for the given filepath.
+ #--
+ #: (String value) -> Repository
+ def self.filepath(value)
+ Repository.new(SourceFilepath.new(value))
+ end
+
+ # Create a new repository for the given string.
+ #--
+ #: (String value) -> Repository
+ def self.string(value)
+ Repository.new(SourceString.new(value))
+ end
+ end
+end
diff --git a/lib/prism/string_query.rb b/lib/prism/string_query.rb
new file mode 100644
index 0000000000..99ce57e5fe
--- /dev/null
+++ b/lib/prism/string_query.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # Query methods that allow categorizing strings based on their context for
+ # where they could be valid in a Ruby syntax tree.
+ class StringQuery
+ # @rbs!
+ # def self.local?: (String string) -> bool
+ # def self.constant?: (String string) -> bool
+ # def self.method_name?: (String string) -> bool
+
+ # The string that this query is wrapping.
+ attr_reader :string #: String
+
+ # Initialize a new query with the given string.
+ #--
+ #: (String string) -> void
+ def initialize(string)
+ @string = string
+ end
+
+ # Whether or not this string is a valid local variable name.
+ #--
+ #: () -> bool
+ def local?
+ StringQuery.local?(string)
+ end
+
+ # Whether or not this string is a valid constant name.
+ #--
+ #: () -> bool
+ def constant?
+ StringQuery.constant?(string)
+ end
+
+ # Whether or not this string is a valid method name.
+ #--
+ #: () -> bool
+ def method_name?
+ StringQuery.method_name?(string)
+ end
+ end
+end
diff --git a/lib/prism/translation.rb b/lib/prism/translation.rb
new file mode 100644
index 0000000000..5a086a7542
--- /dev/null
+++ b/lib/prism/translation.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# rbs_inline: enabled
+
+module Prism
+ # This module is responsible for converting the prism syntax tree into other
+ # syntax trees.
+ module Translation # steep:ignore
+ autoload :Parser, "prism/translation/parser"
+ autoload :ParserCurrent, "prism/translation/parser_current"
+ autoload :Parser33, "prism/translation/parser_versions"
+ autoload :Parser34, "prism/translation/parser_versions"
+ autoload :Parser35, "prism/translation/parser_versions"
+ autoload :Parser40, "prism/translation/parser_versions"
+ autoload :Parser41, "prism/translation/parser_versions"
+ autoload :Ripper, "prism/translation/ripper"
+ autoload :RubyParser, "prism/translation/ruby_parser"
+ end
+end
diff --git a/lib/prism/translation/parser.rb b/lib/prism/translation/parser.rb
new file mode 100644
index 0000000000..70031f133a
--- /dev/null
+++ b/lib/prism/translation/parser.rb
@@ -0,0 +1,376 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+begin
+ required_version = ">= 3.3.7.2"
+ gem "parser", required_version
+ require "parser"
+rescue LoadError
+ warn(<<~MSG)
+ Error: Unable to load parser #{required_version}. \
+ Add `gem "parser"` to your Gemfile or run `bundle update parser`.
+ MSG
+ exit(1)
+end
+
+module Prism
+ module Translation
+ # This class is the entry-point for converting a prism syntax tree into the
+ # whitequark/parser gem's syntax tree. It inherits from the base parser for
+ # the parser gem, and overrides the parse* methods to parse with prism and
+ # then translate.
+ #
+ # Note that this version of the parser always parses using the latest
+ # version of Ruby syntax supported by Prism. If you want specific version
+ # support, use one of the version-specific subclasses, such as
+ # `Prism::Translation::Parser34`. If you want to parse using the same
+ # version of Ruby syntax as the currently running version of Ruby, use
+ # `Prism::Translation::ParserCurrent`.
+ class Parser < ::Parser::Base
+ Diagnostic = ::Parser::Diagnostic # :nodoc:
+ private_constant :Diagnostic
+
+ # The parser gem has a list of diagnostics with a hard-coded set of error
+ # messages. We create our own diagnostic class in order to set our own
+ # error messages.
+ class PrismDiagnostic < Diagnostic # :nodoc:
+ # This is the cached message coming from prism.
+ attr_reader :message
+
+ # Initialize a new diagnostic with the given message and location.
+ def initialize(message, level, reason, location)
+ @message = message
+ super(level, reason, {}, location, [])
+ end
+ end
+
+ Racc_debug_parser = false # :nodoc:
+
+ # The `builder` argument is used to create the parser using our custom builder class by default.
+ #
+ # By using the `:parser` keyword argument, you can translate in a way that is compatible with
+ # the Parser gem using any parser.
+ #
+ # For example, in RuboCop for Ruby LSP, the following approach can be used to improve performance
+ # by reusing a pre-parsed `Prism::ParseLexResult`:
+ #
+ # class PrismPreparsed
+ # def initialize(prism_result)
+ # @prism_result = prism_result
+ # end
+ #
+ # def parse_lex(source, **options)
+ # @prism_result
+ # end
+ # end
+ #
+ # prism_preparsed = PrismPreparsed.new(prism_result)
+ #
+ # Prism::Translation::Ruby34.new(builder, parser: prism_preparsed)
+ #
+ # In an object passed to the `:parser` keyword argument, the `parse` and `parse_lex` methods
+ # should be implemented as needed.
+ #
+ def initialize(builder = Prism::Translation::Parser::Builder.new, parser: Prism)
+ if !builder.is_a?(Prism::Translation::Parser::Builder)
+ warn(<<~MSG, uplevel: 1, category: :deprecated)
+ [deprecation]: The builder passed to `Prism::Translation::Parser.new` is not a \
+ `Prism::Translation::Parser::Builder` subclass. This will raise in the next major version.
+ MSG
+ end
+ @parser = parser
+
+ super(builder)
+ end
+
+ def version # :nodoc:
+ 41
+ end
+
+ # The default encoding for Ruby files is UTF-8.
+ def default_encoding
+ Encoding::UTF_8
+ end
+
+ def yyerror # :nodoc:
+ end
+
+ # Parses a source buffer and returns the AST.
+ def parse(source_buffer)
+ @source_buffer = source_buffer
+ source = source_buffer.source
+
+ offset_cache = build_offset_cache(source)
+ result = unwrap(@parser.parse(source, **prism_options), offset_cache)
+
+ build_ast(result.value, offset_cache)
+ ensure
+ @source_buffer = nil
+ end
+
+ # Parses a source buffer and returns the AST and the source code comments.
+ def parse_with_comments(source_buffer)
+ @source_buffer = source_buffer
+ source = source_buffer.source
+
+ offset_cache = build_offset_cache(source)
+ result = unwrap(@parser.parse(source, **prism_options), offset_cache)
+
+ [
+ build_ast(result.value, offset_cache),
+ build_comments(result.comments, offset_cache)
+ ]
+ ensure
+ @source_buffer = nil
+ end
+
+ # Parses a source buffer and returns the AST, the source code comments,
+ # and the tokens emitted by the lexer.
+ def tokenize(source_buffer, recover = false)
+ @source_buffer = source_buffer
+ source = source_buffer.source
+
+ offset_cache = build_offset_cache(source)
+ result =
+ begin
+ unwrap(@parser.parse_lex(source, **prism_options), offset_cache)
+ rescue ::Parser::SyntaxError
+ raise if !recover
+ end
+
+ program, tokens = result.value
+ ast = build_ast(program, offset_cache) if result.success?
+
+ [
+ ast,
+ build_comments(result.comments, offset_cache),
+ build_tokens(tokens, offset_cache)
+ ]
+ ensure
+ @source_buffer = nil
+ end
+
+ # Since prism resolves num params for us, we don't need to support this
+ # kind of logic here.
+ def try_declare_numparam(node)
+ node.children[0].match?(/\A_[1-9]\z/)
+ end
+
+ private
+
+ # This is a hook to allow consumers to disable some errors if they don't
+ # want them to block creating the syntax tree.
+ def valid_error?(error)
+ true
+ end
+
+ # This is a hook to allow consumers to disable some warnings if they don't
+ # want them to block creating the syntax tree.
+ def valid_warning?(warning)
+ true
+ end
+
+ # Build a diagnostic from the given prism parse error.
+ def error_diagnostic(error, offset_cache)
+ location = error.location
+ diagnostic_location = build_range(location, offset_cache)
+
+ case error.type
+ when :argument_block_multi
+ Diagnostic.new(:error, :block_and_blockarg, {}, diagnostic_location, [])
+ when :argument_formal_constant
+ Diagnostic.new(:error, :argument_const, {}, diagnostic_location, [])
+ when :argument_formal_class
+ Diagnostic.new(:error, :argument_cvar, {}, diagnostic_location, [])
+ when :argument_formal_global
+ Diagnostic.new(:error, :argument_gvar, {}, diagnostic_location, [])
+ when :argument_formal_ivar
+ Diagnostic.new(:error, :argument_ivar, {}, diagnostic_location, [])
+ when :argument_no_forwarding_amp
+ Diagnostic.new(:error, :no_anonymous_blockarg, {}, diagnostic_location, [])
+ when :argument_no_forwarding_star
+ Diagnostic.new(:error, :no_anonymous_restarg, {}, diagnostic_location, [])
+ when :argument_no_forwarding_star_star
+ Diagnostic.new(:error, :no_anonymous_kwrestarg, {}, diagnostic_location, [])
+ when :begin_lonely_else
+ location = location.copy(length: 4)
+ diagnostic_location = build_range(location, offset_cache)
+ Diagnostic.new(:error, :useless_else, {}, diagnostic_location, [])
+ when :class_name, :module_name
+ Diagnostic.new(:error, :module_name_const, {}, diagnostic_location, [])
+ when :class_in_method
+ Diagnostic.new(:error, :class_in_def, {}, diagnostic_location, [])
+ when :def_endless_setter
+ Diagnostic.new(:error, :endless_setter, {}, diagnostic_location, [])
+ when :embdoc_term
+ Diagnostic.new(:error, :embedded_document, {}, diagnostic_location, [])
+ when :incomplete_variable_class, :incomplete_variable_class_3_3
+ location = location.copy(length: location.length + 1)
+ diagnostic_location = build_range(location, offset_cache)
+
+ Diagnostic.new(:error, :cvar_name, { name: location.slice }, diagnostic_location, [])
+ when :incomplete_variable_instance, :incomplete_variable_instance_3_3
+ location = location.copy(length: location.length + 1)
+ diagnostic_location = build_range(location, offset_cache)
+
+ Diagnostic.new(:error, :ivar_name, { name: location.slice }, diagnostic_location, [])
+ when :invalid_variable_global, :invalid_variable_global_3_3
+ Diagnostic.new(:error, :gvar_name, { name: location.slice }, diagnostic_location, [])
+ when :module_in_method
+ Diagnostic.new(:error, :module_in_def, {}, diagnostic_location, [])
+ when :numbered_parameter_ordinary
+ Diagnostic.new(:error, :ordinary_param_defined, {}, diagnostic_location, [])
+ when :numbered_parameter_outer_scope
+ Diagnostic.new(:error, :numparam_used_in_outer_scope, {}, diagnostic_location, [])
+ when :parameter_circular
+ Diagnostic.new(:error, :circular_argument_reference, { var_name: location.slice }, diagnostic_location, [])
+ when :parameter_name_repeat
+ Diagnostic.new(:error, :duplicate_argument, {}, diagnostic_location, [])
+ when :parameter_numbered_reserved
+ Diagnostic.new(:error, :reserved_for_numparam, { name: location.slice }, diagnostic_location, [])
+ when :regexp_unknown_options
+ Diagnostic.new(:error, :regexp_options, { options: location.slice[1..] }, diagnostic_location, [])
+ when :singleton_for_literals
+ Diagnostic.new(:error, :singleton_literal, {}, diagnostic_location, [])
+ when :string_literal_eof
+ Diagnostic.new(:error, :string_eof, {}, diagnostic_location, [])
+ when :unexpected_token_ignore
+ Diagnostic.new(:error, :unexpected_token, { token: location.slice }, diagnostic_location, [])
+ when :write_target_in_method
+ Diagnostic.new(:error, :dynamic_const, {}, diagnostic_location, [])
+ else
+ PrismDiagnostic.new(error.message, :error, error.type, diagnostic_location)
+ end
+ end
+
+ # Build a diagnostic from the given prism parse warning.
+ def warning_diagnostic(warning, offset_cache)
+ diagnostic_location = build_range(warning.location, offset_cache)
+
+ case warning.type
+ when :ambiguous_first_argument_plus
+ Diagnostic.new(:warning, :ambiguous_prefix, { prefix: "+" }, diagnostic_location, [])
+ when :ambiguous_first_argument_minus
+ Diagnostic.new(:warning, :ambiguous_prefix, { prefix: "-" }, diagnostic_location, [])
+ when :ambiguous_prefix_ampersand
+ Diagnostic.new(:warning, :ambiguous_prefix, { prefix: "&" }, diagnostic_location, [])
+ when :ambiguous_prefix_star
+ Diagnostic.new(:warning, :ambiguous_prefix, { prefix: "*" }, diagnostic_location, [])
+ when :ambiguous_prefix_star_star
+ Diagnostic.new(:warning, :ambiguous_prefix, { prefix: "**" }, diagnostic_location, [])
+ when :ambiguous_slash
+ Diagnostic.new(:warning, :ambiguous_regexp, {}, diagnostic_location, [])
+ when :dot_dot_dot_eol
+ Diagnostic.new(:warning, :triple_dot_at_eol, {}, diagnostic_location, [])
+ when :duplicated_hash_key
+ # skip, parser does this on its own
+ else
+ PrismDiagnostic.new(warning.message, :warning, warning.type, diagnostic_location)
+ end
+ end
+
+ # If there was a error generated during the parse, then raise an
+ # appropriate syntax error. Otherwise return the result.
+ def unwrap(result, offset_cache)
+ result.errors.each do |error|
+ next unless valid_error?(error)
+ diagnostics.process(error_diagnostic(error, offset_cache))
+ end
+
+ result.warnings.each do |warning|
+ next unless valid_warning?(warning)
+ diagnostic = warning_diagnostic(warning, offset_cache)
+ diagnostics.process(diagnostic) if diagnostic
+ end
+
+ result
+ end
+
+ # Prism deals with offsets in bytes, while the parser gem deals with
+ # offsets in characters. We need to handle this conversion in order to
+ # build the parser gem AST.
+ #
+ # If the bytesize of the source is the same as the length, then we can
+ # just use the offset directly. Otherwise, we build an array where the
+ # index is the byte offset and the value is the character offset.
+ def build_offset_cache(source)
+ if source.bytesize == source.length
+ -> (offset) { offset }
+ else
+ offset_cache = []
+ offset = 0
+
+ source.each_char do |char|
+ char.bytesize.times { offset_cache << offset }
+ offset += 1
+ end
+
+ offset_cache << offset
+ end
+ end
+
+ # Build the parser gem AST from the prism AST.
+ def build_ast(program, offset_cache)
+ program.accept(Compiler.new(self, offset_cache))
+ end
+
+ # Build the parser gem comments from the prism comments.
+ def build_comments(comments, offset_cache)
+ comments.map do |comment|
+ ::Parser::Source::Comment.new(build_range(comment.location, offset_cache))
+ end
+ end
+
+ # Build the parser gem tokens from the prism tokens.
+ def build_tokens(tokens, offset_cache)
+ Lexer.new(source_buffer, tokens, offset_cache).to_a
+ end
+
+ # Build a range from a prism location.
+ def build_range(location, offset_cache)
+ ::Parser::Source::Range.new(
+ source_buffer,
+ offset_cache[location.start_offset],
+ offset_cache[location.end_offset]
+ )
+ end
+
+ # Options for how prism should parse/lex the source.
+ def prism_options
+ options = {
+ filepath: @source_buffer.name,
+ version: convert_for_prism(version),
+ partial_script: true,
+ }
+ # The parser gem always encodes to UTF-8, unless it is binary.
+ # https://github.com/whitequark/parser/blob/v3.3.6.0/lib/parser/source/buffer.rb#L80-L107
+ options[:encoding] = false if @source_buffer.source.encoding != Encoding::BINARY
+
+ options
+ end
+
+ # Converts the version format handled by Parser to the format handled by Prism.
+ def convert_for_prism(version)
+ case version
+ when 33
+ "3.3.1"
+ when 34
+ "3.4.0"
+ when 35, 40
+ "4.0.0"
+ when 41
+ "4.1.0"
+ else
+ "latest"
+ end
+ end
+
+ require_relative "parser/builder"
+ require_relative "parser/compiler"
+ require_relative "parser/lexer"
+
+ private_constant :Compiler
+ private_constant :Lexer
+ end
+ end
+end
diff --git a/lib/prism/translation/parser/builder.rb b/lib/prism/translation/parser/builder.rb
new file mode 100644
index 0000000000..7fc3bba6b7
--- /dev/null
+++ b/lib/prism/translation/parser/builder.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+module Prism
+ module Translation
+ class Parser
+ # A builder that knows how to convert more modern Ruby syntax
+ # into whitequark/parser gem's syntax tree.
+ class Builder < ::Parser::Builders::Default
+ # It represents the `it` block argument, which is not yet implemented in
+ # the Parser gem.
+ def itarg
+ n(:itarg, [:it], nil)
+ end
+
+ # The following three lines have been added to support the `it` block
+ # parameter syntax in the source code below.
+ #
+ # if args.type == :itarg
+ # block_type = :itblock
+ # args = :it
+ #
+ # https://github.com/whitequark/parser/blob/v3.3.7.1/lib/parser/builders/default.rb#L1122-L1155
+ def block(method_call, begin_t, args, body, end_t)
+ _receiver, _selector, *call_args = *method_call
+
+ if method_call.type == :yield
+ diagnostic :error, :block_given_to_yield, nil, method_call.loc.keyword, [loc(begin_t)]
+ end
+
+ last_arg = call_args.last
+ if last_arg && (last_arg.type == :block_pass || last_arg.type == :forwarded_args)
+ diagnostic :error, :block_and_blockarg, nil, last_arg.loc.expression, [loc(begin_t)]
+ end
+
+ if args.type == :itarg
+ block_type = :itblock
+ args = :it
+ elsif args.type == :numargs
+ block_type = :numblock
+ args = args.children[0]
+ else
+ block_type = :block
+ end
+
+ if [:send, :csend, :index, :super, :zsuper, :lambda].include?(method_call.type)
+ n(block_type, [ method_call, args, body ],
+ block_map(method_call.loc.expression, begin_t, end_t))
+ else
+ # Code like "return foo 1 do end" is reduced in a weird sequence.
+ # Here, method_call is actually (return).
+ actual_send, = *method_call
+ block =
+ n(block_type, [ actual_send, args, body ],
+ block_map(actual_send.loc.expression, begin_t, end_t))
+
+ n(method_call.type, [ block ],
+ method_call.loc.with_expression(join_exprs(method_call, block)))
+ end
+ end
+
+ # def foo(&nil); end
+ # ^^^^
+ def blocknilarg(amper_t, nil_t)
+ n0(:blocknilarg, arg_prefix_map(amper_t, nil_t))
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
new file mode 100644
index 0000000000..d11db12ae6
--- /dev/null
+++ b/lib/prism/translation/parser/compiler.rb
@@ -0,0 +1,2219 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+module Prism
+ module Translation
+ class Parser
+ # A visitor that knows how to convert a prism syntax tree into the
+ # whitequark/parser gem's syntax tree.
+ class Compiler < ::Prism::Compiler # :nodoc:
+ # Raised when the tree is malformed or there is a bug in the compiler.
+ class CompilationError < StandardError # :nodoc:
+ end
+
+ # The Parser::Base instance that is being used to build the AST.
+ attr_reader :parser
+
+ # The Parser::Builders::Default instance that is being used to build the
+ # AST.
+ attr_reader :builder
+
+ # The Parser::Source::Buffer instance that is holding a reference to the
+ # source code.
+ attr_reader :source_buffer
+
+ # The offset cache that is used to map between byte and character
+ # offsets in the file.
+ attr_reader :offset_cache
+
+ # The types of values that can be forwarded in the current scope.
+ attr_reader :forwarding
+
+ # Whether or not the current node is in a destructure.
+ attr_reader :in_destructure
+
+ # Whether or not the current node is in a pattern.
+ attr_reader :in_pattern
+
+ # Initialize a new compiler with the given parser, offset cache, and
+ # options.
+ def initialize(parser, offset_cache, forwarding: [], in_destructure: false, in_pattern: false)
+ @parser = parser
+ @builder = parser.builder
+ @source_buffer = parser.source_buffer
+ @offset_cache = offset_cache
+
+ @forwarding = forwarding
+ @in_destructure = in_destructure
+ @in_pattern = in_pattern
+ end
+
+ # alias foo bar
+ # ^^^^^^^^^^^^^
+ def visit_alias_method_node(node)
+ builder.alias(token(node.keyword_loc), visit(node.new_name), visit(node.old_name))
+ end
+
+ # alias $foo $bar
+ # ^^^^^^^^^^^^^^^
+ def visit_alias_global_variable_node(node)
+ builder.alias(token(node.keyword_loc), visit(node.new_name), visit(node.old_name))
+ end
+
+ # foo => bar | baz
+ # ^^^^^^^^^
+ def visit_alternation_pattern_node(node)
+ builder.match_alt(visit(node.left), token(node.operator_loc), visit(node.right))
+ end
+
+ # a and b
+ # ^^^^^^^
+ def visit_and_node(node)
+ builder.logical_op(:and, visit(node.left), token(node.operator_loc), visit(node.right))
+ end
+
+ # []
+ # ^^
+ def visit_array_node(node)
+ if node.opening&.start_with?("%w", "%W", "%i", "%I")
+ elements = node.elements.flat_map do |element|
+ if element.is_a?(StringNode)
+ if element.content.include?("\n")
+ string_nodes_from_line_continuations(element.unescaped, element.content, element.content_loc.start_offset, node.opening)
+ else
+ [builder.string_internal([element.unescaped, srange(element.content_loc)])]
+ end
+ elsif element.is_a?(InterpolatedStringNode)
+ builder.string_compose(
+ token(element.opening_loc),
+ string_nodes_from_interpolation(element, node.opening),
+ token(element.closing_loc)
+ )
+ else
+ [visit(element)]
+ end
+ end
+ else
+ elements = visit_all(node.elements)
+ end
+
+ builder.array(token(node.opening_loc), elements, token(node.closing_loc))
+ end
+
+ # foo => [bar]
+ # ^^^^^
+ def visit_array_pattern_node(node)
+ elements = [*node.requireds]
+ elements << node.rest if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
+ elements.concat(node.posts)
+ visited = visit_all(elements)
+
+ if node.rest.is_a?(ImplicitRestNode)
+ visited[-1] = builder.match_with_trailing_comma(visited[-1], token(node.rest.location))
+ end
+
+ if node.constant
+ if visited.empty?
+ builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.array_pattern(token(node.opening_loc), visited, token(node.closing_loc)), token(node.closing_loc))
+ else
+ builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.array_pattern(nil, visited, nil), token(node.closing_loc))
+ end
+ else
+ builder.array_pattern(token(node.opening_loc), visited, token(node.closing_loc))
+ end
+ end
+
+ # foo(bar)
+ # ^^^
+ def visit_arguments_node(node)
+ visit_all(node.arguments)
+ end
+
+ # { a: 1 }
+ # ^^^^
+ def visit_assoc_node(node)
+ key = node.key
+
+ if node.value.is_a?(ImplicitNode)
+ if in_pattern
+ if key.is_a?(SymbolNode)
+ if key.opening.nil?
+ builder.match_hash_var([key.unescaped, srange(key.location)])
+ else
+ builder.match_hash_var_from_str(token(key.opening_loc), [builder.string_internal([key.unescaped, srange(key.value_loc)])], token(key.closing_loc))
+ end
+ else
+ builder.match_hash_var_from_str(token(key.opening_loc), visit_all(key.parts), token(key.closing_loc))
+ end
+ else
+ value = node.value.value
+
+ implicit_value = if value.is_a?(CallNode)
+ builder.call_method(nil, nil, [value.name, srange(value.message_loc)])
+ elsif value.is_a?(ConstantReadNode)
+ builder.const([value.name, srange(key.value_loc)])
+ else
+ builder.ident([value.name, srange(key.value_loc)]).updated(:lvar)
+ end
+
+ builder.pair_keyword([key.unescaped, srange(key)], implicit_value)
+ end
+ elsif node.operator_loc
+ builder.pair(visit(key), token(node.operator_loc), visit(node.value))
+ elsif key.is_a?(SymbolNode) && key.opening_loc.nil?
+ builder.pair_keyword([key.unescaped, srange(key.location)], visit(node.value))
+ else
+ parts =
+ if key.is_a?(SymbolNode)
+ [builder.string_internal([key.unescaped, srange(key.value_loc)])]
+ else
+ visit_all(key.parts)
+ end
+
+ builder.pair_quoted(token(key.opening_loc), parts, token(key.closing_loc), visit(node.value))
+ end
+ end
+
+ # def foo(**); bar(**); end
+ # ^^
+ #
+ # { **foo }
+ # ^^^^^
+ def visit_assoc_splat_node(node)
+ if in_pattern
+ builder.match_rest(token(node.operator_loc), token(node.value&.location))
+ elsif node.value.nil? && forwarding.include?(:**)
+ builder.forwarded_kwrestarg(token(node.operator_loc))
+ else
+ builder.kwsplat(token(node.operator_loc), visit(node.value))
+ end
+ end
+
+ # $+
+ # ^^
+ def visit_back_reference_read_node(node)
+ builder.back_ref(token(node.location))
+ end
+
+ # begin end
+ # ^^^^^^^^^
+ def visit_begin_node(node)
+ rescue_bodies = []
+
+ if (rescue_clause = node.rescue_clause)
+ begin
+ find_start_offset = (rescue_clause.reference&.location || rescue_clause.exceptions.last&.location || rescue_clause.keyword_loc).end_offset
+ find_end_offset = (
+ rescue_clause.statements&.location&.start_offset ||
+ rescue_clause.subsequent&.location&.start_offset ||
+ node.else_clause&.location&.start_offset ||
+ node.ensure_clause&.location&.start_offset ||
+ node.end_keyword_loc&.start_offset ||
+ find_start_offset + 1
+ )
+
+ rescue_bodies << builder.rescue_body(
+ token(rescue_clause.keyword_loc),
+ rescue_clause.exceptions.any? ? builder.array(nil, visit_all(rescue_clause.exceptions), nil) : nil,
+ token(rescue_clause.operator_loc),
+ visit(rescue_clause.reference),
+ srange_semicolon(find_start_offset, find_end_offset),
+ visit(rescue_clause.statements)
+ )
+ end until (rescue_clause = rescue_clause.subsequent).nil?
+ end
+
+ begin_body =
+ builder.begin_body(
+ visit(node.statements),
+ rescue_bodies,
+ token(node.else_clause&.else_keyword_loc),
+ visit(node.else_clause),
+ token(node.ensure_clause&.ensure_keyword_loc),
+ visit(node.ensure_clause&.statements)
+ )
+
+ if node.begin_keyword_loc
+ builder.begin_keyword(token(node.begin_keyword_loc), begin_body, token(node.end_keyword_loc))
+ else
+ begin_body
+ end
+ end
+
+ # foo(&bar)
+ # ^^^^
+ def visit_block_argument_node(node)
+ builder.block_pass(token(node.operator_loc), visit(node.expression))
+ end
+
+ # foo { |; bar| }
+ # ^^^
+ def visit_block_local_variable_node(node)
+ builder.shadowarg(token(node.location))
+ end
+
+ # A block on a keyword or method call.
+ def visit_block_node(node)
+ raise CompilationError, "Cannot directly compile block nodes"
+ end
+
+ # def foo(&bar); end
+ # ^^^^
+ def visit_block_parameter_node(node)
+ builder.blockarg(token(node.operator_loc), token(node.name_loc))
+ end
+
+ # A block's parameters.
+ def visit_block_parameters_node(node)
+ [*visit(node.parameters)].concat(visit_all(node.locals))
+ end
+
+ # break
+ # ^^^^^
+ #
+ # break foo
+ # ^^^^^^^^^
+ def visit_break_node(node)
+ builder.keyword_cmd(:break, token(node.keyword_loc), nil, visit(node.arguments) || [], nil)
+ end
+
+ # foo
+ # ^^^
+ #
+ # foo.bar
+ # ^^^^^^^
+ #
+ # foo.bar() {}
+ # ^^^^^^^^^^^^
+ def visit_call_node(node)
+ name = node.name
+ arguments = node.arguments&.arguments || []
+ block = node.block
+
+ if block.is_a?(BlockArgumentNode)
+ arguments = [*arguments, block]
+ block = nil
+ end
+
+ if node.call_operator_loc.nil?
+ case name
+ when :!
+ return visit_block(builder.not_op(token(node.message_loc), token(node.opening_loc), visit(node.receiver), token(node.closing_loc)), block)
+ when :=~
+ if (receiver = node.receiver).is_a?(RegularExpressionNode)
+ return builder.match_op(visit(receiver), token(node.message_loc), visit(node.arguments.arguments.first))
+ end
+ when :[]
+ return visit_block(builder.index(visit(node.receiver), token(node.opening_loc), visit_all(arguments), token(node.closing_loc)), block)
+ when :[]=
+ if node.message != "[]=" && node.arguments && block.nil? && !node.safe_navigation?
+ arguments = node.arguments.arguments[...-1]
+ arguments << node.block if node.block
+
+ return visit_block(
+ builder.assign(
+ builder.index_asgn(
+ visit(node.receiver),
+ token(node.opening_loc),
+ visit_all(arguments),
+ token(node.closing_loc),
+ ),
+ token(node.equal_loc),
+ visit(node.arguments.arguments.last)
+ ),
+ block
+ )
+ end
+ end
+ end
+
+ message_loc = node.message_loc
+ call_operator_loc = node.call_operator_loc
+ call_operator = [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)] if call_operator_loc
+
+ visit_block(
+ if name.end_with?("=") && !message_loc.slice.end_with?("=") && node.arguments && block.nil?
+ builder.assign(
+ builder.attr_asgn(visit(node.receiver), call_operator, token(message_loc)),
+ token(node.equal_loc),
+ visit(node.arguments.arguments.last)
+ )
+ else
+ builder.call_method(
+ visit(node.receiver),
+ call_operator,
+ message_loc ? [node.name, srange(message_loc)] : nil,
+ token(node.opening_loc),
+ visit_all(arguments),
+ token(node.closing_loc)
+ )
+ end,
+ block
+ )
+ end
+
+ # foo.bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_operator_write_node(node)
+ call_operator_loc = node.call_operator_loc
+
+ builder.op_assign(
+ builder.call_method(
+ visit(node.receiver),
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
+ node.message_loc ? [node.read_name, srange(node.message_loc)] : nil,
+ nil,
+ [],
+ nil
+ ),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo.bar &&= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_and_write_node(node)
+ call_operator_loc = node.call_operator_loc
+
+ builder.op_assign(
+ builder.call_method(
+ visit(node.receiver),
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
+ node.message_loc ? [node.read_name, srange(node.message_loc)] : nil,
+ nil,
+ [],
+ nil
+ ),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo.bar ||= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_or_write_node(node)
+ call_operator_loc = node.call_operator_loc
+
+ builder.op_assign(
+ builder.call_method(
+ visit(node.receiver),
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
+ node.message_loc ? [node.read_name, srange(node.message_loc)] : nil,
+ nil,
+ [],
+ nil
+ ),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo.bar, = 1
+ # ^^^^^^^
+ def visit_call_target_node(node)
+ call_operator_loc = node.call_operator_loc
+
+ builder.attr_asgn(
+ visit(node.receiver),
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
+ token(node.message_loc)
+ )
+ end
+
+ # foo => bar => baz
+ # ^^^^^^^^^^
+ def visit_capture_pattern_node(node)
+ builder.match_as(visit(node.value), token(node.operator_loc), visit(node.target))
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_node(node)
+ builder.case(
+ token(node.case_keyword_loc),
+ visit(node.predicate),
+ visit_all(node.conditions),
+ token(node.else_clause&.else_keyword_loc),
+ visit(node.else_clause),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_match_node(node)
+ builder.case_match(
+ token(node.case_keyword_loc),
+ visit(node.predicate),
+ visit_all(node.conditions),
+ token(node.else_clause&.else_keyword_loc),
+ visit(node.else_clause),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # class Foo; end
+ # ^^^^^^^^^^^^^^
+ def visit_class_node(node)
+ builder.def_class(
+ token(node.class_keyword_loc),
+ visit(node.constant_path),
+ token(node.inheritance_operator_loc),
+ visit(node.superclass),
+ node.body&.accept(copy_compiler(forwarding: [])),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # @@foo
+ # ^^^^^
+ def visit_class_variable_read_node(node)
+ builder.cvar(token(node.location))
+ end
+
+ # @@foo = 1
+ # ^^^^^^^^^
+ def visit_class_variable_write_node(node)
+ builder.assign(
+ builder.assignable(builder.cvar(token(node.name_loc))),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # @@foo += bar
+ # ^^^^^^^^^^^^
+ def visit_class_variable_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.cvar(token(node.name_loc))),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @@foo &&= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.cvar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @@foo ||= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.cvar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @@foo, = bar
+ # ^^^^^
+ def visit_class_variable_target_node(node)
+ builder.assignable(builder.cvar(token(node.location)))
+ end
+
+ # Foo
+ # ^^^
+ def visit_constant_read_node(node)
+ builder.const([node.name, srange(node.location)])
+ end
+
+ # Foo = 1
+ # ^^^^^^^
+ #
+ # Foo, Bar = 1
+ # ^^^ ^^^
+ def visit_constant_write_node(node)
+ builder.assign(builder.assignable(builder.const([node.name, srange(node.name_loc)])), token(node.operator_loc), visit(node.value))
+ end
+
+ # Foo += bar
+ # ^^^^^^^^^^^
+ def visit_constant_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.const([node.name, srange(node.name_loc)])),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.const([node.name, srange(node.name_loc)])),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.const([node.name, srange(node.name_loc)])),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo, = bar
+ # ^^^
+ def visit_constant_target_node(node)
+ builder.assignable(builder.const([node.name, srange(node.location)]))
+ end
+
+ # Foo::Bar
+ # ^^^^^^^^
+ def visit_constant_path_node(node)
+ if node.parent.nil?
+ builder.const_global(
+ token(node.delimiter_loc),
+ [node.name, srange(node.name_loc)]
+ )
+ else
+ builder.const_fetch(
+ visit(node.parent),
+ token(node.delimiter_loc),
+ [node.name, srange(node.name_loc)]
+ )
+ end
+ end
+
+ # Foo::Bar = 1
+ # ^^^^^^^^^^^^
+ #
+ # Foo::Foo, Bar::Bar = 1
+ # ^^^^^^^^ ^^^^^^^^
+ def visit_constant_path_write_node(node)
+ builder.assign(
+ builder.assignable(visit(node.target)),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # Foo::Bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_constant_path_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(visit(node.target)),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo::Bar &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(visit(node.target)),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo::Bar ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(visit(node.target)),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # Foo::Bar, = baz
+ # ^^^^^^^^
+ def visit_constant_path_target_node(node)
+ builder.assignable(visit_constant_path_node(node))
+ end
+
+ # def foo; end
+ # ^^^^^^^^^^^^
+ #
+ # def self.foo; end
+ # ^^^^^^^^^^^^^^^^^
+ def visit_def_node(node)
+ if node.equal_loc
+ if node.receiver
+ builder.def_endless_singleton(
+ token(node.def_keyword_loc),
+ visit(node.receiver.is_a?(ParenthesesNode) ? node.receiver.body : node.receiver),
+ token(node.operator_loc),
+ token(node.name_loc),
+ builder.args(token(node.lparen_loc), visit(node.parameters) || [], token(node.rparen_loc), false),
+ token(node.equal_loc),
+ node.body&.accept(copy_compiler(forwarding: find_forwarding(node.parameters)))
+ )
+ else
+ builder.def_endless_method(
+ token(node.def_keyword_loc),
+ token(node.name_loc),
+ builder.args(token(node.lparen_loc), visit(node.parameters) || [], token(node.rparen_loc), false),
+ token(node.equal_loc),
+ node.body&.accept(copy_compiler(forwarding: find_forwarding(node.parameters)))
+ )
+ end
+ elsif node.receiver
+ builder.def_singleton(
+ token(node.def_keyword_loc),
+ visit(node.receiver.is_a?(ParenthesesNode) ? node.receiver.body : node.receiver),
+ token(node.operator_loc),
+ token(node.name_loc),
+ builder.args(token(node.lparen_loc), visit(node.parameters) || [], token(node.rparen_loc), false),
+ node.body&.accept(copy_compiler(forwarding: find_forwarding(node.parameters))),
+ token(node.end_keyword_loc)
+ )
+ else
+ builder.def_method(
+ token(node.def_keyword_loc),
+ token(node.name_loc),
+ builder.args(token(node.lparen_loc), visit(node.parameters) || [], token(node.rparen_loc), false),
+ node.body&.accept(copy_compiler(forwarding: find_forwarding(node.parameters))),
+ token(node.end_keyword_loc)
+ )
+ end
+ end
+
+ # defined? a
+ # ^^^^^^^^^^
+ #
+ # defined?(a)
+ # ^^^^^^^^^^^
+ def visit_defined_node(node)
+ # Very weird circumstances here where something like:
+ #
+ # defined?
+ # (1)
+ #
+ # gets parsed in Ruby as having only the `1` expression but in parser
+ # it gets parsed as having a begin. In this case we need to synthesize
+ # that begin to match parser's behavior.
+ if node.lparen_loc && node.keyword_loc.join(node.lparen_loc).slice.include?("\n")
+ builder.keyword_cmd(
+ :defined?,
+ token(node.keyword_loc),
+ nil,
+ [
+ builder.begin(
+ token(node.lparen_loc),
+ visit(node.value),
+ token(node.rparen_loc)
+ )
+ ],
+ nil
+ )
+ else
+ builder.keyword_cmd(
+ :defined?,
+ token(node.keyword_loc),
+ token(node.lparen_loc),
+ [visit(node.value)],
+ token(node.rparen_loc)
+ )
+ end
+ end
+
+ # if foo then bar else baz end
+ # ^^^^^^^^^^^^
+ def visit_else_node(node)
+ visit(node.statements)
+ end
+
+ # "foo #{bar}"
+ # ^^^^^^
+ def visit_embedded_statements_node(node)
+ builder.begin(
+ token(node.opening_loc),
+ visit(node.statements),
+ token(node.closing_loc)
+ )
+ end
+
+ # "foo #@bar"
+ # ^^^^^
+ def visit_embedded_variable_node(node)
+ visit(node.variable)
+ end
+
+ # begin; foo; ensure; bar; end
+ # ^^^^^^^^^^^^
+ def visit_ensure_node(node)
+ raise CompilationError, "Cannot directly compile ensure nodes"
+ end
+
+ # false
+ # ^^^^^
+ def visit_false_node(node)
+ builder.false(token(node.location))
+ end
+
+ # foo => [*, bar, *]
+ # ^^^^^^^^^^^
+ def visit_find_pattern_node(node)
+ elements = [node.left, *node.requireds, node.right]
+
+ if node.constant
+ builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.find_pattern(nil, visit_all(elements), nil), token(node.closing_loc))
+ else
+ builder.find_pattern(token(node.opening_loc), visit_all(elements), token(node.closing_loc))
+ end
+ end
+
+ # 1.0
+ # ^^^
+ def visit_float_node(node)
+ visit_numeric(node, builder.float([node.value, srange(node.location)]))
+ end
+
+ # for foo in bar do end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_for_node(node)
+ builder.for(
+ token(node.for_keyword_loc),
+ visit(node.index),
+ token(node.in_keyword_loc),
+ visit(node.collection),
+ if (do_keyword_loc = node.do_keyword_loc)
+ token(do_keyword_loc)
+ else
+ srange_semicolon(node.collection.location.end_offset, (node.statements&.location || node.end_keyword_loc).start_offset)
+ end,
+ visit(node.statements),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # def foo(...); bar(...); end
+ # ^^^
+ def visit_forwarding_arguments_node(node)
+ builder.forwarded_args(token(node.location))
+ end
+
+ # def foo(...); end
+ # ^^^
+ def visit_forwarding_parameter_node(node)
+ builder.forward_arg(token(node.location))
+ end
+
+ # super
+ # ^^^^^
+ #
+ # super {}
+ # ^^^^^^^^
+ def visit_forwarding_super_node(node)
+ visit_block(
+ builder.keyword_cmd(
+ :zsuper,
+ ["super", srange_offsets(node.location.start_offset, node.location.start_offset + 5)]
+ ),
+ node.block
+ )
+ end
+
+ # $foo
+ # ^^^^
+ def visit_global_variable_read_node(node)
+ builder.gvar(token(node.location))
+ end
+
+ # $foo = 1
+ # ^^^^^^^^
+ def visit_global_variable_write_node(node)
+ builder.assign(
+ builder.assignable(builder.gvar(token(node.name_loc))),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # $foo += bar
+ # ^^^^^^^^^^^
+ def visit_global_variable_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.gvar(token(node.name_loc))),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # $foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.gvar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # $foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.gvar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # $foo, = bar
+ # ^^^^
+ def visit_global_variable_target_node(node)
+ builder.assignable(builder.gvar([node.slice, srange(node.location)]))
+ end
+
+ # {}
+ # ^^
+ def visit_hash_node(node)
+ builder.associate(
+ token(node.opening_loc),
+ visit_all(node.elements),
+ token(node.closing_loc)
+ )
+ end
+
+ # foo => {}
+ # ^^
+ def visit_hash_pattern_node(node)
+ elements = [*node.elements, *node.rest]
+
+ if node.constant
+ builder.const_pattern(visit(node.constant), token(node.opening_loc), builder.hash_pattern(nil, visit_all(elements), nil), token(node.closing_loc))
+ else
+ builder.hash_pattern(token(node.opening_loc), visit_all(elements), token(node.closing_loc))
+ end
+ end
+
+ # if foo then bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar if foo
+ # ^^^^^^^^^^
+ #
+ # foo ? bar : baz
+ # ^^^^^^^^^^^^^^^
+ def visit_if_node(node)
+ if !node.if_keyword_loc
+ builder.ternary(
+ visit(node.predicate),
+ token(node.then_keyword_loc),
+ visit(node.statements),
+ token(node.subsequent.else_keyword_loc),
+ visit(node.subsequent)
+ )
+ elsif node.if_keyword_loc.start_offset == node.location.start_offset
+ builder.condition(
+ token(node.if_keyword_loc),
+ visit(node.predicate),
+ if (then_keyword_loc = node.then_keyword_loc)
+ token(then_keyword_loc)
+ else
+ srange_semicolon(node.predicate.location.end_offset, (node.statements&.location || node.subsequent&.location || node.end_keyword_loc).start_offset)
+ end,
+ visit(node.statements),
+ case node.subsequent
+ when IfNode
+ token(node.subsequent.if_keyword_loc)
+ when ElseNode
+ token(node.subsequent.else_keyword_loc)
+ end,
+ visit(node.subsequent),
+ if node.if_keyword != "elsif"
+ token(node.end_keyword_loc)
+ end
+ )
+ else
+ builder.condition_mod(
+ visit(node.statements),
+ visit(node.subsequent),
+ token(node.if_keyword_loc),
+ visit(node.predicate)
+ )
+ end
+ end
+
+ # 1i
+ # ^^
+ def visit_imaginary_node(node)
+ visit_numeric(node, builder.complex([Complex(0, node.numeric.value), srange(node.location)]))
+ end
+
+ # { foo: }
+ # ^^^^
+ def visit_implicit_node(node)
+ raise CompilationError, "Cannot directly compile implicit nodes"
+ end
+
+ # foo { |bar,| }
+ # ^
+ def visit_implicit_rest_node(node)
+ raise CompilationError, "Cannot compile implicit rest nodes"
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_in_node(node)
+ pattern = nil
+ guard = nil
+
+ case node.pattern
+ when IfNode
+ pattern = within_pattern { |compiler| node.pattern.statements.accept(compiler) }
+ guard = builder.if_guard(token(node.pattern.if_keyword_loc), visit(node.pattern.predicate))
+ when UnlessNode
+ pattern = within_pattern { |compiler| node.pattern.statements.accept(compiler) }
+ guard = builder.unless_guard(token(node.pattern.keyword_loc), visit(node.pattern.predicate))
+ else
+ pattern = within_pattern { |compiler| node.pattern.accept(compiler) }
+ end
+
+ builder.in_pattern(
+ token(node.in_loc),
+ pattern,
+ guard,
+ if (then_loc = node.then_loc)
+ token(then_loc)
+ else
+ srange_semicolon(node.pattern.location.end_offset, node.statements&.location&.start_offset)
+ end,
+ visit(node.statements)
+ )
+ end
+
+ # foo[bar] += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_index_operator_write_node(node)
+ arguments = node.arguments&.arguments || []
+ arguments << node.block if node.block
+
+ builder.op_assign(
+ builder.index(
+ visit(node.receiver),
+ token(node.opening_loc),
+ visit_all(arguments),
+ token(node.closing_loc)
+ ),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo[bar] &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_and_write_node(node)
+ arguments = node.arguments&.arguments || []
+ arguments << node.block if node.block
+
+ builder.op_assign(
+ builder.index(
+ visit(node.receiver),
+ token(node.opening_loc),
+ visit_all(arguments),
+ token(node.closing_loc)
+ ),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo[bar] ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_or_write_node(node)
+ arguments = node.arguments&.arguments || []
+ arguments << node.block if node.block
+
+ builder.op_assign(
+ builder.index(
+ visit(node.receiver),
+ token(node.opening_loc),
+ visit_all(arguments),
+ token(node.closing_loc)
+ ),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo[bar], = 1
+ # ^^^^^^^^
+ def visit_index_target_node(node)
+ builder.index_asgn(
+ visit(node.receiver),
+ token(node.opening_loc),
+ visit_all(node.arguments&.arguments || []),
+ token(node.closing_loc),
+ )
+ end
+
+ # @foo
+ # ^^^^
+ def visit_instance_variable_read_node(node)
+ builder.ivar(token(node.location))
+ end
+
+ # @foo = 1
+ # ^^^^^^^^
+ def visit_instance_variable_write_node(node)
+ builder.assign(
+ builder.assignable(builder.ivar(token(node.name_loc))),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # @foo += bar
+ # ^^^^^^^^^^^
+ def visit_instance_variable_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ivar(token(node.name_loc))),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ivar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ivar(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # @foo, = bar
+ # ^^^^
+ def visit_instance_variable_target_node(node)
+ builder.assignable(builder.ivar(token(node.location)))
+ end
+
+ # 1
+ # ^
+ def visit_integer_node(node)
+ visit_numeric(node, builder.integer([node.value, srange(node.location)]))
+ end
+
+ # /foo #{bar}/
+ # ^^^^^^^^^^^^
+ def visit_interpolated_regular_expression_node(node)
+ builder.regexp_compose(
+ token(node.opening_loc),
+ string_nodes_from_interpolation(node, node.opening),
+ [node.closing[0], srange_offsets(node.closing_loc.start_offset, node.closing_loc.start_offset + 1)],
+ builder.regexp_options([node.closing[1..], srange_offsets(node.closing_loc.start_offset + 1, node.closing_loc.end_offset)])
+ )
+ end
+
+ # if /foo #{bar}/ then end
+ # ^^^^^^^^^^^^
+ alias visit_interpolated_match_last_line_node visit_interpolated_regular_expression_node
+
+ # "foo #{bar}"
+ # ^^^^^^^^^^^^
+ def visit_interpolated_string_node(node)
+ if node.heredoc?
+ return visit_heredoc(node) { |children, closing| builder.string_compose(token(node.opening_loc), children, closing) }
+ end
+
+ builder.string_compose(
+ token(node.opening_loc),
+ string_nodes_from_interpolation(node, node.opening),
+ token(node.closing_loc)
+ )
+ end
+
+ # :"foo #{bar}"
+ # ^^^^^^^^^^^^^
+ def visit_interpolated_symbol_node(node)
+ builder.symbol_compose(
+ token(node.opening_loc),
+ string_nodes_from_interpolation(node, node.opening),
+ token(node.closing_loc)
+ )
+ end
+
+ # `foo #{bar}`
+ # ^^^^^^^^^^^^
+ def visit_interpolated_x_string_node(node)
+ if node.heredoc?
+ return visit_heredoc(node) { |children, closing| builder.xstring_compose(token(node.opening_loc), children, closing) }
+ end
+
+ builder.xstring_compose(
+ token(node.opening_loc),
+ string_nodes_from_interpolation(node, node.opening),
+ token(node.closing_loc)
+ )
+ end
+
+ # -> { it }
+ # ^^
+ def visit_it_local_variable_read_node(node)
+ builder.ident([:it, srange(node.location)]).updated(:lvar)
+ end
+
+ # -> { it }
+ # ^^^^^^^^^
+ def visit_it_parameters_node(node)
+ # FIXME: The builder _should_ always be a subclass of the prism builder.
+ # Currently RuboCop passes in its own builder that always inherits from the
+ # parser builder (which is lacking the `itarg` method). Once rubocop-ast
+ # opts in to use the custom prism builder a warning can be emitted when
+ # it is not the expected class, and eventually raise.
+ # https://github.com/rubocop/rubocop-ast/pull/354
+ if builder.is_a?(Translation::Parser::Builder)
+ builder.itarg
+ else
+ builder.args(nil, [], nil, false)
+ end
+ end
+
+ # foo(bar: baz)
+ # ^^^^^^^^
+ def visit_keyword_hash_node(node)
+ builder.associate(nil, visit_all(node.elements), nil)
+ end
+
+ # def foo(**bar); end
+ # ^^^^^
+ #
+ # def foo(**); end
+ # ^^
+ def visit_keyword_rest_parameter_node(node)
+ builder.kwrestarg(
+ token(node.operator_loc),
+ node.name ? [node.name, srange(node.name_loc)] : nil
+ )
+ end
+
+ # -> {}
+ # ^^^^^
+ def visit_lambda_node(node)
+ parameters = node.parameters
+ implicit_parameters = parameters.is_a?(NumberedParametersNode) || parameters.is_a?(ItParametersNode)
+
+ builder.block(
+ builder.call_lambda(token(node.operator_loc)),
+ [node.opening, srange(node.opening_loc)],
+ if parameters.nil?
+ builder.args(nil, [], nil, false)
+ elsif implicit_parameters
+ visit(node.parameters)
+ else
+ builder.args(
+ token(node.parameters.opening_loc),
+ visit(node.parameters),
+ token(node.parameters.closing_loc),
+ false
+ )
+ end,
+ visit(node.body),
+ [node.closing, srange(node.closing_loc)]
+ )
+ end
+
+ # foo
+ # ^^^
+ def visit_local_variable_read_node(node)
+ builder.ident([node.name, srange(node.location)]).updated(:lvar)
+ end
+
+ # foo = 1
+ # ^^^^^^^
+ def visit_local_variable_write_node(node)
+ builder.assign(
+ builder.assignable(builder.ident(token(node.name_loc))),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # foo += bar
+ # ^^^^^^^^^^
+ def visit_local_variable_operator_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ident(token(node.name_loc))),
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo &&= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_and_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ident(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo ||= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_or_write_node(node)
+ builder.op_assign(
+ builder.assignable(builder.ident(token(node.name_loc))),
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
+ visit(node.value)
+ )
+ end
+
+ # foo, = bar
+ # ^^^
+ def visit_local_variable_target_node(node)
+ if in_pattern
+ builder.assignable(builder.match_var([node.name, srange(node.location)]))
+ else
+ builder.assignable(builder.ident(token(node.location)))
+ end
+ end
+
+ # foo in bar
+ # ^^^^^^^^^^
+ def visit_match_predicate_node(node)
+ builder.match_pattern_p(
+ visit(node.value),
+ token(node.operator_loc),
+ within_pattern { |compiler| node.pattern.accept(compiler) }
+ )
+ end
+
+ # foo => bar
+ # ^^^^^^^^^^
+ def visit_match_required_node(node)
+ builder.match_pattern(
+ visit(node.value),
+ token(node.operator_loc),
+ within_pattern { |compiler| node.pattern.accept(compiler) }
+ )
+ end
+
+ # /(?<foo>foo)/ =~ bar
+ # ^^^^^^^^^^^^^^^^^^^^
+ def visit_match_write_node(node)
+ builder.match_op(
+ visit(node.call.receiver),
+ token(node.call.message_loc),
+ visit(node.call.arguments.arguments.first)
+ )
+ end
+
+ # A node that is missing from the syntax tree. This is only used in the
+ # case of a syntax error. The parser gem doesn't have such a concept, so
+ # we invent our own here.
+ def visit_error_recovery_node(node)
+ ::AST::Node.new(:missing, [], location: ::Parser::Source::Map.new(srange(node.location)))
+ end
+
+ # module Foo; end
+ # ^^^^^^^^^^^^^^^
+ def visit_module_node(node)
+ builder.def_module(
+ token(node.module_keyword_loc),
+ visit(node.constant_path),
+ node.body&.accept(copy_compiler(forwarding: [])),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # foo, bar = baz
+ # ^^^^^^^^
+ def visit_multi_target_node(node)
+ builder.multi_lhs(
+ token(node.lparen_loc),
+ visit_all(multi_target_elements(node)),
+ token(node.rparen_loc)
+ )
+ end
+
+ # foo, bar = baz
+ # ^^^^^^^^^^^^^^
+ def visit_multi_write_node(node)
+ elements = multi_target_elements(node)
+
+ if elements.length == 1 && elements.first.is_a?(MultiTargetNode) && !node.rest
+ elements = multi_target_elements(elements.first)
+ end
+
+ builder.multi_assign(
+ builder.multi_lhs(
+ token(node.lparen_loc),
+ visit_all(elements),
+ token(node.rparen_loc)
+ ),
+ token(node.operator_loc),
+ visit(node.value)
+ )
+ end
+
+ # next
+ # ^^^^
+ #
+ # next foo
+ # ^^^^^^^^
+ def visit_next_node(node)
+ builder.keyword_cmd(
+ :next,
+ token(node.keyword_loc),
+ nil,
+ visit(node.arguments) || [],
+ nil
+ )
+ end
+
+ # nil
+ # ^^^
+ def visit_nil_node(node)
+ builder.nil(token(node.location))
+ end
+
+ # def foo(&nil); end
+ # ^^^^
+ def visit_no_block_parameter_node(node)
+ builder.blocknilarg(token(node.operator_loc), token(node.keyword_loc))
+ end
+
+ # def foo(**nil); end
+ # ^^^^^
+ def visit_no_keywords_parameter_node(node)
+ if in_pattern
+ builder.match_nil_pattern(token(node.operator_loc), token(node.keyword_loc))
+ else
+ builder.kwnilarg(token(node.operator_loc), token(node.keyword_loc))
+ end
+ end
+
+ # -> { _1 + _2 }
+ # ^^^^^^^^^^^^^^
+ def visit_numbered_parameters_node(node)
+ builder.numargs(node.maximum)
+ end
+
+ # $1
+ # ^^
+ def visit_numbered_reference_read_node(node)
+ builder.nth_ref([node.number, srange(node.location)])
+ end
+
+ # def foo(bar: baz); end
+ # ^^^^^^^^
+ def visit_optional_keyword_parameter_node(node)
+ builder.kwoptarg([node.name, srange(node.name_loc)], visit(node.value))
+ end
+
+ # def foo(bar = 1); end
+ # ^^^^^^^
+ def visit_optional_parameter_node(node)
+ builder.optarg(token(node.name_loc), token(node.operator_loc), visit(node.value))
+ end
+
+ # a or b
+ # ^^^^^^
+ def visit_or_node(node)
+ builder.logical_op(:or, visit(node.left), token(node.operator_loc), visit(node.right))
+ end
+
+ # def foo(bar, *baz); end
+ # ^^^^^^^^^
+ def visit_parameters_node(node)
+ params = []
+
+ if node.requireds.any?
+ node.requireds.each do |required|
+ params <<
+ if required.is_a?(RequiredParameterNode)
+ visit(required)
+ else
+ required.accept(copy_compiler(in_destructure: true))
+ end
+ end
+ end
+
+ params.concat(visit_all(node.optionals)) if node.optionals.any?
+ params << visit(node.rest) if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
+
+ if node.posts.any?
+ node.posts.each do |post|
+ params <<
+ if post.is_a?(RequiredParameterNode)
+ visit(post)
+ else
+ post.accept(copy_compiler(in_destructure: true))
+ end
+ end
+ end
+
+ params.concat(visit_all(node.keywords)) if node.keywords.any?
+ params << visit(node.keyword_rest) if !node.keyword_rest.nil?
+ params << visit(node.block) if !node.block.nil?
+ params
+ end
+
+ # ()
+ # ^^
+ #
+ # (1)
+ # ^^^
+ def visit_parentheses_node(node)
+ builder.begin(
+ token(node.opening_loc),
+ visit(node.body),
+ token(node.closing_loc)
+ )
+ end
+
+ # foo => ^(bar)
+ # ^^^^^^
+ def visit_pinned_expression_node(node)
+ parts = node.expression.accept(copy_compiler(in_pattern: false)) # Don't treat * and similar as match_rest
+ expression = builder.begin(token(node.lparen_loc), parts, token(node.rparen_loc))
+ builder.pin(token(node.operator_loc), expression)
+ end
+
+ # foo = 1 and bar => ^foo
+ # ^^^^
+ def visit_pinned_variable_node(node)
+ builder.pin(token(node.operator_loc), visit(node.variable))
+ end
+
+ # END {}
+ def visit_post_execution_node(node)
+ builder.postexe(
+ token(node.keyword_loc),
+ token(node.opening_loc),
+ visit(node.statements),
+ token(node.closing_loc)
+ )
+ end
+
+ # BEGIN {}
+ def visit_pre_execution_node(node)
+ builder.preexe(
+ token(node.keyword_loc),
+ token(node.opening_loc),
+ visit(node.statements),
+ token(node.closing_loc)
+ )
+ end
+
+ # The top-level program node.
+ def visit_program_node(node)
+ visit(node.statements)
+ end
+
+ # 0..5
+ # ^^^^
+ def visit_range_node(node)
+ if node.exclude_end?
+ builder.range_exclusive(
+ visit(node.left),
+ token(node.operator_loc),
+ visit(node.right)
+ )
+ else
+ builder.range_inclusive(
+ visit(node.left),
+ token(node.operator_loc),
+ visit(node.right)
+ )
+ end
+ end
+
+ # if foo .. bar; end
+ # ^^^^^^^^^^
+ alias visit_flip_flop_node visit_range_node
+
+ # 1r
+ # ^^
+ def visit_rational_node(node)
+ visit_numeric(node, builder.rational([node.value, srange(node.location)]))
+ end
+
+ # redo
+ # ^^^^
+ def visit_redo_node(node)
+ builder.keyword_cmd(:redo, token(node.location))
+ end
+
+ # /foo/
+ # ^^^^^
+ def visit_regular_expression_node(node)
+ parts =
+ if node.content == ""
+ []
+ elsif node.content.include?("\n")
+ string_nodes_from_line_continuations(node.unescaped, node.content, node.content_loc.start_offset, node.opening)
+ else
+ [builder.string_internal([node.unescaped, srange(node.content_loc)])]
+ end
+
+ builder.regexp_compose(
+ token(node.opening_loc),
+ parts,
+ [node.closing[0], srange_offsets(node.closing_loc.start_offset, node.closing_loc.start_offset + 1)],
+ builder.regexp_options([node.closing[1..], srange_offsets(node.closing_loc.start_offset + 1, node.closing_loc.end_offset)])
+ )
+ end
+
+ # if /foo/ then end
+ # ^^^^^
+ alias visit_match_last_line_node visit_regular_expression_node
+
+ # def foo(bar:); end
+ # ^^^^
+ def visit_required_keyword_parameter_node(node)
+ builder.kwarg([node.name, srange(node.name_loc)])
+ end
+
+ # def foo(bar); end
+ # ^^^
+ def visit_required_parameter_node(node)
+ builder.arg(token(node.location))
+ end
+
+ # foo rescue bar
+ # ^^^^^^^^^^^^^^
+ def visit_rescue_modifier_node(node)
+ builder.begin_body(
+ visit(node.expression),
+ [
+ builder.rescue_body(
+ token(node.keyword_loc),
+ nil,
+ nil,
+ nil,
+ nil,
+ visit(node.rescue_expression)
+ )
+ ]
+ )
+ end
+
+ # begin; rescue; end
+ # ^^^^^^^
+ def visit_rescue_node(node)
+ raise CompilationError, "Cannot directly compile rescue nodes"
+ end
+
+ # def foo(*bar); end
+ # ^^^^
+ #
+ # def foo(*); end
+ # ^
+ def visit_rest_parameter_node(node)
+ builder.restarg(token(node.operator_loc), token(node.name_loc))
+ end
+
+ # retry
+ # ^^^^^
+ def visit_retry_node(node)
+ builder.keyword_cmd(:retry, token(node.location))
+ end
+
+ # return
+ # ^^^^^^
+ #
+ # return 1
+ # ^^^^^^^^
+ def visit_return_node(node)
+ builder.keyword_cmd(
+ :return,
+ token(node.keyword_loc),
+ nil,
+ visit(node.arguments) || [],
+ nil
+ )
+ end
+
+ # self
+ # ^^^^
+ def visit_self_node(node)
+ builder.self(token(node.location))
+ end
+
+ # A shareable constant.
+ def visit_shareable_constant_node(node)
+ visit(node.write)
+ end
+
+ # class << self; end
+ # ^^^^^^^^^^^^^^^^^^
+ def visit_singleton_class_node(node)
+ builder.def_sclass(
+ token(node.class_keyword_loc),
+ token(node.operator_loc),
+ visit(node.expression),
+ node.body&.accept(copy_compiler(forwarding: [])),
+ token(node.end_keyword_loc)
+ )
+ end
+
+ # __ENCODING__
+ # ^^^^^^^^^^^^
+ def visit_source_encoding_node(node)
+ builder.accessible(builder.__ENCODING__(token(node.location)))
+ end
+
+ # __FILE__
+ # ^^^^^^^^
+ def visit_source_file_node(node)
+ builder.accessible(builder.__FILE__(token(node.location)))
+ end
+
+ # __LINE__
+ # ^^^^^^^^
+ def visit_source_line_node(node)
+ builder.accessible(builder.__LINE__(token(node.location)))
+ end
+
+ # foo(*bar)
+ # ^^^^
+ #
+ # def foo((bar, *baz)); end
+ # ^^^^
+ #
+ # def foo(*); bar(*); end
+ # ^
+ def visit_splat_node(node)
+ if node.expression.nil? && forwarding.include?(:*)
+ builder.forwarded_restarg(token(node.operator_loc))
+ elsif in_destructure
+ builder.restarg(token(node.operator_loc), token(node.expression&.location))
+ elsif in_pattern
+ builder.match_rest(token(node.operator_loc), token(node.expression&.location))
+ else
+ builder.splat(token(node.operator_loc), visit(node.expression))
+ end
+ end
+
+ # A list of statements.
+ def visit_statements_node(node)
+ builder.compstmt(visit_all(node.body))
+ end
+
+ # "foo"
+ # ^^^^^
+ def visit_string_node(node)
+ if node.heredoc?
+ visit_heredoc(node.to_interpolated) { |children, closing| builder.string_compose(token(node.opening_loc), children, closing) }
+ elsif node.opening == "?"
+ builder.character([node.unescaped, srange(node.location)])
+ elsif node.opening&.start_with?("%") && node.unescaped.empty?
+ builder.string_compose(token(node.opening_loc), [], token(node.closing_loc))
+ else
+ parts =
+ if node.content.include?("\n")
+ string_nodes_from_line_continuations(node.unescaped, node.content, node.content_loc.start_offset, node.opening)
+ else
+ [builder.string_internal([node.unescaped, srange(node.content_loc)])]
+ end
+
+ builder.string_compose(
+ token(node.opening_loc),
+ parts,
+ token(node.closing_loc)
+ )
+ end
+ end
+
+ # super(foo)
+ # ^^^^^^^^^^
+ def visit_super_node(node)
+ arguments = node.arguments&.arguments || []
+ block = node.block
+
+ if block.is_a?(BlockArgumentNode)
+ arguments = [*arguments, block]
+ block = nil
+ end
+
+ visit_block(
+ builder.keyword_cmd(
+ :super,
+ token(node.keyword_loc),
+ token(node.lparen_loc),
+ visit_all(arguments),
+ token(node.rparen_loc)
+ ),
+ block
+ )
+ end
+
+ # :foo
+ # ^^^^
+ def visit_symbol_node(node)
+ if node.closing_loc.nil?
+ if node.opening_loc.nil?
+ builder.symbol_internal([node.unescaped, srange(node.location)])
+ else
+ builder.symbol([node.unescaped, srange(node.location)])
+ end
+ else
+ parts =
+ if node.value_loc.nil?
+ []
+ elsif node.value.include?("\n")
+ string_nodes_from_line_continuations(node.unescaped, node.value, node.value_loc.start_offset, node.opening)
+ else
+ [builder.string_internal([node.unescaped, srange(node.value_loc)])]
+ end
+
+ builder.symbol_compose(
+ token(node.opening_loc),
+ parts,
+ token(node.closing_loc)
+ )
+ end
+ end
+
+ # true
+ # ^^^^
+ def visit_true_node(node)
+ builder.true(token(node.location))
+ end
+
+ # undef foo
+ # ^^^^^^^^^
+ def visit_undef_node(node)
+ builder.undef_method(token(node.keyword_loc), visit_all(node.names))
+ end
+
+ # unless foo; bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar unless foo
+ # ^^^^^^^^^^^^^^
+ def visit_unless_node(node)
+ if node.keyword_loc.start_offset == node.location.start_offset
+ builder.condition(
+ token(node.keyword_loc),
+ visit(node.predicate),
+ if (then_keyword_loc = node.then_keyword_loc)
+ token(then_keyword_loc)
+ else
+ srange_semicolon(node.predicate.location.end_offset, (node.statements&.location || node.else_clause&.location || node.end_keyword_loc).start_offset)
+ end,
+ visit(node.else_clause),
+ token(node.else_clause&.else_keyword_loc),
+ visit(node.statements),
+ token(node.end_keyword_loc)
+ )
+ else
+ builder.condition_mod(
+ visit(node.else_clause),
+ visit(node.statements),
+ token(node.keyword_loc),
+ visit(node.predicate)
+ )
+ end
+ end
+
+ # until foo; bar end
+ # ^^^^^^^^^^^^^^^^^^
+ #
+ # bar until foo
+ # ^^^^^^^^^^^^^
+ def visit_until_node(node)
+ if node.location.start_offset == node.keyword_loc.start_offset
+ builder.loop(
+ :until,
+ token(node.keyword_loc),
+ visit(node.predicate),
+ if (do_keyword_loc = node.do_keyword_loc)
+ token(do_keyword_loc)
+ else
+ srange_semicolon(node.predicate.location.end_offset, (node.statements&.location || node.closing_loc).start_offset)
+ end,
+ visit(node.statements),
+ token(node.closing_loc)
+ )
+ else
+ builder.loop_mod(
+ :until,
+ visit(node.statements),
+ token(node.keyword_loc),
+ visit(node.predicate)
+ )
+ end
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^
+ def visit_when_node(node)
+ builder.when(
+ token(node.keyword_loc),
+ visit_all(node.conditions),
+ if (then_keyword_loc = node.then_keyword_loc)
+ token(then_keyword_loc)
+ else
+ srange_semicolon(node.conditions.last.location.end_offset, node.statements&.location&.start_offset)
+ end,
+ visit(node.statements)
+ )
+ end
+
+ # while foo; bar end
+ # ^^^^^^^^^^^^^^^^^^
+ #
+ # bar while foo
+ # ^^^^^^^^^^^^^
+ def visit_while_node(node)
+ if node.location.start_offset == node.keyword_loc.start_offset
+ builder.loop(
+ :while,
+ token(node.keyword_loc),
+ visit(node.predicate),
+ if (do_keyword_loc = node.do_keyword_loc)
+ token(do_keyword_loc)
+ else
+ srange_semicolon(node.predicate.location.end_offset, (node.statements&.location || node.closing_loc).start_offset)
+ end,
+ visit(node.statements),
+ token(node.closing_loc)
+ )
+ else
+ builder.loop_mod(
+ :while,
+ visit(node.statements),
+ token(node.keyword_loc),
+ visit(node.predicate)
+ )
+ end
+ end
+
+ # `foo`
+ # ^^^^^
+ def visit_x_string_node(node)
+ if node.heredoc?
+ return visit_heredoc(node.to_interpolated) { |children, closing| builder.xstring_compose(token(node.opening_loc), children, closing) }
+ end
+
+ parts =
+ if node.content == ""
+ []
+ elsif node.content.include?("\n")
+ string_nodes_from_line_continuations(node.unescaped, node.content, node.content_loc.start_offset, node.opening)
+ else
+ [builder.string_internal([node.unescaped, srange(node.content_loc)])]
+ end
+
+ builder.xstring_compose(
+ token(node.opening_loc),
+ parts,
+ token(node.closing_loc)
+ )
+ end
+
+ # yield
+ # ^^^^^
+ #
+ # yield 1
+ # ^^^^^^^
+ def visit_yield_node(node)
+ builder.keyword_cmd(
+ :yield,
+ token(node.keyword_loc),
+ token(node.lparen_loc),
+ visit(node.arguments) || [],
+ token(node.rparen_loc)
+ )
+ end
+
+ private
+
+ # Initialize a new compiler with the given option overrides, used to
+ # visit a subtree with the given options.
+ def copy_compiler(forwarding: self.forwarding, in_destructure: self.in_destructure, in_pattern: self.in_pattern)
+ Compiler.new(parser, offset_cache, forwarding: forwarding, in_destructure: in_destructure, in_pattern: in_pattern)
+ end
+
+ # When *, **, &, or ... are used as an argument in a method call, we
+ # check if they were allowed by the current context. To determine that
+ # we build this lookup table.
+ def find_forwarding(node)
+ return [] if node.nil?
+
+ forwarding = []
+ forwarding << :* if node.rest.is_a?(RestParameterNode) && node.rest.name.nil?
+ forwarding << :** if node.keyword_rest.is_a?(KeywordRestParameterNode) && node.keyword_rest.name.nil?
+ forwarding << :& if !node.block.nil? && node.block.name.nil?
+ forwarding |= [:&, :"..."] if node.keyword_rest.is_a?(ForwardingParameterNode)
+
+ forwarding
+ end
+
+ # Returns the set of targets for a MultiTargetNode or a MultiWriteNode.
+ def multi_target_elements(node)
+ elements = [*node.lefts]
+ elements << node.rest if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
+ elements.concat(node.rights)
+ elements
+ end
+
+ # Blocks can have a special set of parameters that automatically expand
+ # when given arrays if they have a single required parameter and no
+ # other parameters.
+ def procarg0?(parameters)
+ parameters &&
+ parameters.requireds.length == 1 &&
+ parameters.optionals.empty? &&
+ parameters.rest.nil? &&
+ parameters.posts.empty? &&
+ parameters.keywords.empty? &&
+ parameters.keyword_rest.nil? &&
+ parameters.block.nil?
+ end
+
+ # Locations in the parser gem AST are generated using this class. We
+ # store a reference to its constant to make it slightly faster to look
+ # up.
+ Range = ::Parser::Source::Range
+
+ # Constructs a new source range from the given start and end offsets.
+ def srange(location)
+ Range.new(source_buffer, offset_cache[location.start_offset], offset_cache[location.end_offset]) if location
+ end
+
+ # Constructs a new source range from the given start and end offsets.
+ def srange_offsets(start_offset, end_offset)
+ Range.new(source_buffer, offset_cache[start_offset], offset_cache[end_offset])
+ end
+
+ # Constructs a new source range by finding a semicolon between the given
+ # start offset and end offset. If the semicolon is not found, it returns
+ # nil. Importantly it does not search past newlines or comments.
+ #
+ # Note that end_offset is allowed to be nil, in which case this will
+ # search until the end of the string.
+ def srange_semicolon(start_offset, end_offset)
+ if (match = source_buffer.source.byteslice(start_offset...end_offset)[/\A\s*;/])
+ final_offset = start_offset + match.bytesize
+ [";", Range.new(source_buffer, offset_cache[final_offset - 1], offset_cache[final_offset])]
+ end
+ end
+
+ # Transform a location into a token that the parser gem expects.
+ def token(location)
+ [location.slice, Range.new(source_buffer, offset_cache[location.start_offset], offset_cache[location.end_offset])] if location
+ end
+
+ # Visit a block node on a call.
+ def visit_block(call, block)
+ if block
+ parameters = block.parameters
+ implicit_parameters = parameters.is_a?(NumberedParametersNode) || parameters.is_a?(ItParametersNode)
+
+ builder.block(
+ call,
+ token(block.opening_loc),
+ if parameters.nil?
+ builder.args(nil, [], nil, false)
+ elsif implicit_parameters
+ visit(parameters)
+ else
+ builder.args(
+ token(parameters.opening_loc),
+ if procarg0?(parameters.parameters)
+ parameter = parameters.parameters.requireds.first
+ visited = parameter.is_a?(RequiredParameterNode) ? visit(parameter) : parameter.accept(copy_compiler(in_destructure: true))
+ [builder.procarg0(visited)].concat(visit_all(parameters.locals))
+ else
+ visit(parameters)
+ end,
+ token(parameters.closing_loc),
+ false
+ )
+ end,
+ visit(block.body),
+ token(block.closing_loc)
+ )
+ else
+ call
+ end
+ end
+
+ # Visit a heredoc that can be either a string or an xstring.
+ def visit_heredoc(node)
+ children = Array.new
+ indented = false
+
+ # If this is a dedenting heredoc, then we need to insert the opening
+ # content into the children as well.
+ if node.opening.start_with?("<<~") && node.parts.length > 0 && !node.parts.first.is_a?(StringNode)
+ location = node.parts.first.location
+ location = location.copy(start_offset: location.start_offset - location.start_line_slice.bytesize)
+ children << builder.string_internal(token(location))
+ indented = true
+ end
+
+ node.parts.each do |part|
+ pushing =
+ if part.is_a?(StringNode) && part.content.include?("\n")
+ string_nodes_from_line_continuations(part.unescaped, part.content, part.location.start_offset, node.opening)
+ else
+ [visit(part)]
+ end
+
+ pushing.each do |child|
+ if child.type == :str && child.children.last == ""
+ # nothing
+ elsif child.type == :str && children.last && children.last.type == :str && !children.last.children.first.end_with?("\n")
+ appendee = children[-1]
+
+ location = appendee.loc
+ location = location.with_expression(location.expression.join(child.loc.expression))
+
+ children[-1] = appendee.updated(:str, ["#{appendee.children.first}#{child.children.first}"], location: location)
+ else
+ children << child
+ end
+ end
+ end
+
+ closing = node.closing
+ closing_t = [closing.chomp, srange_offsets(node.closing_loc.start_offset, node.closing_loc.end_offset - (closing[/\s+$/]&.length || 0))]
+ composed = yield children, closing_t
+
+ composed = composed.updated(nil, children[1..-1]) if indented
+ composed
+ end
+
+ # Visit a numeric node and account for the optional sign.
+ def visit_numeric(node, value)
+ if (slice = node.slice).match?(/^[+-]/)
+ builder.unary_num(
+ [slice[0].to_sym, srange_offsets(node.location.start_offset, node.location.start_offset + 1)],
+ value
+ )
+ else
+ value
+ end
+ end
+
+ # Within the given block, track that we're within a pattern.
+ def within_pattern
+ begin
+ parser.pattern_variables.push
+ yield copy_compiler(in_pattern: true)
+ ensure
+ parser.pattern_variables.pop
+ end
+ end
+
+ # When the content of a string node is split across multiple lines, the
+ # parser gem creates individual string nodes for each line the content is part of.
+ def string_nodes_from_interpolation(node, opening)
+ node.parts.flat_map do |part|
+ if part.type == :string_node && part.content.include?("\n") && part.opening_loc.nil?
+ string_nodes_from_line_continuations(part.unescaped, part.content, part.content_loc.start_offset, opening)
+ else
+ visit(part)
+ end
+ end
+ end
+
+ # Create parser string nodes from a single prism node. The parser gem
+ # "glues" strings together when a line continuation is encountered.
+ def string_nodes_from_line_continuations(unescaped, escaped, start_offset, opening)
+ unescaped = unescaped.lines
+ escaped = escaped.lines
+ percent_array = opening&.start_with?("%w", "%W", "%i", "%I")
+ regex = opening == "/" || opening&.start_with?("%r")
+
+ # Non-interpolating strings
+ if opening&.end_with?("'") || opening&.start_with?("%q", "%s", "%w", "%i")
+ current_length = 0
+ current_line = +""
+
+ escaped.filter_map.with_index do |escaped_line, index|
+ unescaped_line = unescaped.fetch(index, "")
+ current_length += escaped_line.bytesize
+ current_line << unescaped_line
+
+ # Glue line continuations together. Only %w and %i arrays can contain these.
+ if percent_array && escaped_line[/(\\)*\n$/, 1]&.length&.odd?
+ next unless index == escaped.count - 1
+ end
+ s = builder.string_internal([current_line, srange_offsets(start_offset, start_offset + current_length)])
+ start_offset += escaped_line.bytesize
+ current_line = +""
+ current_length = 0
+ s
+ end
+ else
+ escaped_lengths = []
+ normalized_lengths = []
+ # Keeps track of where an unescaped line should start a new token. An unescaped
+ # \n would otherwise be indistinguishable from the actual newline at the end of
+ # of the line. The parser gem only emits a new string node at "real" newlines,
+ # line continuations don't start a new node as well.
+ do_next_tokens = []
+
+ escaped
+ .chunk_while { |before, after| before[/(\\*)\r?\n$/, 1]&.length&.odd? || false }
+ .each do |lines|
+ escaped_lengths << lines.sum(&:bytesize)
+
+ unescaped_lines_count =
+ if regex
+ 0 # Will always be preserved as is
+ else
+ lines.sum do |line|
+ count = line.scan(/(\\*)n/).count { |(backslashes)| backslashes&.length&.odd? }
+ count -= 1 if line.match?(/(?:\A|[^\\])(?:\\\\)*\\n\z/) && count > 0
+ count
+ end
+ end
+
+ extra = 1
+ extra = lines.count if percent_array # Account for line continuations in percent arrays
+
+ normalized_lengths.concat(Array.new(unescaped_lines_count + extra, 0))
+ normalized_lengths[-1] = lines.sum { |line| line.bytesize }
+ do_next_tokens.concat(Array.new(unescaped_lines_count + extra, false))
+ do_next_tokens[-1] = true
+ end
+
+ current_line = +""
+ current_normalized_length = 0
+
+ emitted_count = 0
+ unescaped.filter_map.with_index do |unescaped_line, index|
+ current_line << unescaped_line
+ current_normalized_length += normalized_lengths.fetch(index, 0)
+
+ if do_next_tokens[index]
+ inner_part = builder.string_internal([current_line, srange_offsets(start_offset, start_offset + current_normalized_length)])
+ start_offset += escaped_lengths.fetch(emitted_count, 0)
+ current_line = +""
+ current_normalized_length = 0
+ emitted_count += 1
+ inner_part
+ else
+ nil
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
new file mode 100644
index 0000000000..e82042867f
--- /dev/null
+++ b/lib/prism/translation/parser/lexer.rb
@@ -0,0 +1,819 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+require "strscan"
+require_relative "../../polyfill/append_as_bytes"
+require_relative "../../polyfill/scan_byte"
+
+module Prism
+ module Translation
+ class Parser
+ # Accepts a list of prism tokens and converts them into the expected
+ # format for the parser gem.
+ class Lexer # :nodoc:
+ # These tokens are always skipped
+ TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF])
+ private_constant :TYPES_ALWAYS_SKIP
+
+ # The direct translating of types between the two lexers.
+ TYPES = {
+ # These tokens should never appear in the output of the lexer.
+ EMBDOC_END: nil,
+ EMBDOC_LINE: nil,
+
+ # These tokens have more or less direct mappings.
+ AMPERSAND: :tAMPER2,
+ AMPERSAND_AMPERSAND: :tANDOP,
+ AMPERSAND_AMPERSAND_EQUAL: :tOP_ASGN,
+ AMPERSAND_DOT: :tANDDOT,
+ AMPERSAND_EQUAL: :tOP_ASGN,
+ BACK_REFERENCE: :tBACK_REF,
+ BACKTICK: :tXSTRING_BEG,
+ BANG: :tBANG,
+ BANG_EQUAL: :tNEQ,
+ BANG_TILDE: :tNMATCH,
+ BRACE_LEFT: :tLCURLY,
+ BRACE_RIGHT: :tRCURLY,
+ BRACKET_LEFT: :tLBRACK2,
+ BRACKET_LEFT_ARRAY: :tLBRACK,
+ BRACKET_LEFT_RIGHT: :tAREF,
+ BRACKET_LEFT_RIGHT_EQUAL: :tASET,
+ BRACKET_RIGHT: :tRBRACK,
+ CARET: :tCARET,
+ CARET_EQUAL: :tOP_ASGN,
+ CHARACTER_LITERAL: :tCHARACTER,
+ CLASS_VARIABLE: :tCVAR,
+ COLON: :tCOLON,
+ COLON_COLON: :tCOLON2,
+ COMMA: :tCOMMA,
+ COMMENT: :tCOMMENT,
+ CONSTANT: :tCONSTANT,
+ DOT: :tDOT,
+ DOT_DOT: :tDOT2,
+ DOT_DOT_DOT: :tDOT3,
+ EMBDOC_BEGIN: :tCOMMENT,
+ EMBEXPR_BEGIN: :tSTRING_DBEG,
+ EMBEXPR_END: :tSTRING_DEND,
+ EMBVAR: :tSTRING_DVAR,
+ EQUAL: :tEQL,
+ EQUAL_EQUAL: :tEQ,
+ EQUAL_EQUAL_EQUAL: :tEQQ,
+ EQUAL_GREATER: :tASSOC,
+ EQUAL_TILDE: :tMATCH,
+ FLOAT: :tFLOAT,
+ FLOAT_IMAGINARY: :tIMAGINARY,
+ FLOAT_RATIONAL: :tRATIONAL,
+ FLOAT_RATIONAL_IMAGINARY: :tIMAGINARY,
+ GLOBAL_VARIABLE: :tGVAR,
+ GREATER: :tGT,
+ GREATER_EQUAL: :tGEQ,
+ GREATER_GREATER: :tRSHFT,
+ GREATER_GREATER_EQUAL: :tOP_ASGN,
+ HEREDOC_START: :tSTRING_BEG,
+ HEREDOC_END: :tSTRING_END,
+ IDENTIFIER: :tIDENTIFIER,
+ INSTANCE_VARIABLE: :tIVAR,
+ INTEGER: :tINTEGER,
+ INTEGER_IMAGINARY: :tIMAGINARY,
+ INTEGER_RATIONAL: :tRATIONAL,
+ INTEGER_RATIONAL_IMAGINARY: :tIMAGINARY,
+ KEYWORD_ALIAS: :kALIAS,
+ KEYWORD_AND: :kAND,
+ KEYWORD_BEGIN: :kBEGIN,
+ KEYWORD_BEGIN_UPCASE: :klBEGIN,
+ KEYWORD_BREAK: :kBREAK,
+ KEYWORD_CASE: :kCASE,
+ KEYWORD_CLASS: :kCLASS,
+ KEYWORD_DEF: :kDEF,
+ KEYWORD_DEFINED: :kDEFINED,
+ KEYWORD_DO: :kDO,
+ KEYWORD_DO_BLOCK: :kDO_BLOCK,
+ KEYWORD_DO_LOOP: :kDO_COND,
+ KEYWORD_END: :kEND,
+ KEYWORD_END_UPCASE: :klEND,
+ KEYWORD_ENSURE: :kENSURE,
+ KEYWORD_ELSE: :kELSE,
+ KEYWORD_ELSIF: :kELSIF,
+ KEYWORD_FALSE: :kFALSE,
+ KEYWORD_FOR: :kFOR,
+ KEYWORD_IF: :kIF,
+ KEYWORD_IF_MODIFIER: :kIF_MOD,
+ KEYWORD_IN: :kIN,
+ KEYWORD_MODULE: :kMODULE,
+ KEYWORD_NEXT: :kNEXT,
+ KEYWORD_NIL: :kNIL,
+ KEYWORD_NOT: :kNOT,
+ KEYWORD_OR: :kOR,
+ KEYWORD_REDO: :kREDO,
+ KEYWORD_RESCUE: :kRESCUE,
+ KEYWORD_RESCUE_MODIFIER: :kRESCUE_MOD,
+ KEYWORD_RETRY: :kRETRY,
+ KEYWORD_RETURN: :kRETURN,
+ KEYWORD_SELF: :kSELF,
+ KEYWORD_SUPER: :kSUPER,
+ KEYWORD_THEN: :kTHEN,
+ KEYWORD_TRUE: :kTRUE,
+ KEYWORD_UNDEF: :kUNDEF,
+ KEYWORD_UNLESS: :kUNLESS,
+ KEYWORD_UNLESS_MODIFIER: :kUNLESS_MOD,
+ KEYWORD_UNTIL: :kUNTIL,
+ KEYWORD_UNTIL_MODIFIER: :kUNTIL_MOD,
+ KEYWORD_WHEN: :kWHEN,
+ KEYWORD_WHILE: :kWHILE,
+ KEYWORD_WHILE_MODIFIER: :kWHILE_MOD,
+ KEYWORD_YIELD: :kYIELD,
+ KEYWORD___ENCODING__: :k__ENCODING__,
+ KEYWORD___FILE__: :k__FILE__,
+ KEYWORD___LINE__: :k__LINE__,
+ LABEL: :tLABEL,
+ LABEL_END: :tLABEL_END,
+ LAMBDA_BEGIN: :tLAMBEG,
+ LESS: :tLT,
+ LESS_EQUAL: :tLEQ,
+ LESS_EQUAL_GREATER: :tCMP,
+ LESS_LESS: :tLSHFT,
+ LESS_LESS_EQUAL: :tOP_ASGN,
+ METHOD_NAME: :tFID,
+ MINUS: :tMINUS,
+ MINUS_EQUAL: :tOP_ASGN,
+ MINUS_GREATER: :tLAMBDA,
+ NEWLINE: :tNL,
+ NUMBERED_REFERENCE: :tNTH_REF,
+ PARENTHESIS_LEFT: :tLPAREN2,
+ PARENTHESIS_LEFT_PARENTHESES: :tLPAREN_ARG,
+ PARENTHESIS_RIGHT: :tRPAREN,
+ PERCENT: :tPERCENT,
+ PERCENT_EQUAL: :tOP_ASGN,
+ PERCENT_LOWER_I: :tQSYMBOLS_BEG,
+ PERCENT_LOWER_W: :tQWORDS_BEG,
+ PERCENT_UPPER_I: :tSYMBOLS_BEG,
+ PERCENT_UPPER_W: :tWORDS_BEG,
+ PERCENT_LOWER_X: :tXSTRING_BEG,
+ PLUS: :tPLUS,
+ PLUS_EQUAL: :tOP_ASGN,
+ PIPE_EQUAL: :tOP_ASGN,
+ PIPE: :tPIPE,
+ PIPE_PIPE: :tOROP,
+ PIPE_PIPE_EQUAL: :tOP_ASGN,
+ QUESTION_MARK: :tEH,
+ REGEXP_BEGIN: :tREGEXP_BEG,
+ REGEXP_END: :tSTRING_END,
+ SEMICOLON: :tSEMI,
+ SLASH: :tDIVIDE,
+ SLASH_EQUAL: :tOP_ASGN,
+ STAR: :tSTAR2,
+ STAR_EQUAL: :tOP_ASGN,
+ STAR_STAR: :tPOW,
+ STAR_STAR_EQUAL: :tOP_ASGN,
+ STRING_BEGIN: :tSTRING_BEG,
+ STRING_CONTENT: :tSTRING_CONTENT,
+ STRING_END: :tSTRING_END,
+ SYMBOL_BEGIN: :tSYMBEG,
+ TILDE: :tTILDE,
+ UAMPERSAND: :tAMPER,
+ UCOLON_COLON: :tCOLON3,
+ UDOT_DOT: :tBDOT2,
+ UDOT_DOT_DOT: :tBDOT3,
+ UMINUS: :tUMINUS,
+ UMINUS_NUM: :tUNARY_NUM,
+ UPLUS: :tUPLUS,
+ USTAR: :tSTAR,
+ USTAR_STAR: :tDSTAR,
+ WORDS_SEP: :tSPACE
+ }
+
+ # These constants represent flags in our lex state. We really, really
+ # don't want to be using them and we really, really don't want to be
+ # exposing them as part of our public API. Unfortunately, we don't have
+ # another way of matching the exact tokens that the parser gem expects
+ # without them. We should find another way to do this, but in the
+ # meantime we'll hide them from the documentation and mark them as
+ # private constants.
+ EXPR_BEG = 0x1
+ EXPR_LABEL = 0x400
+
+ # It is used to determine whether `do` is of the token type `kDO` or `kDO_LAMBDA`.
+ #
+ # NOTE: In edge cases like `-> (foo = -> (bar) {}) do end`, please note that `kDO` is still returned
+ # instead of `kDO_LAMBDA`, which is expected: https://github.com/ruby/prism/pull/3046
+ LAMBDA_TOKEN_TYPES = Set.new([:kDO_LAMBDA, :tLAMBDA, :tLAMBEG])
+
+ # The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem.
+ # The following token types are listed as those classified as `tLPAREN`.
+ LPAREN_CONVERSION_TOKEN_TYPES = Set.new([
+ :kBREAK, :tCARET, :kCASE, :tDIVIDE, :kFOR, :kIF, :kNEXT, :kRETURN, :kUNTIL, :kWHILE, :tAMPER, :tANDOP, :tBANG, :tCOMMA, :tDOT2, :tDOT3,
+ :tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS, :tLCURLY
+ ])
+
+ # Types of tokens that are allowed to continue a method call with comments in-between.
+ # For these, the parser gem doesn't emit a newline token after the last comment.
+ COMMENT_CONTINUATION_TYPES = Set.new([:COMMENT, :AMPERSAND_DOT, :DOT])
+ private_constant :COMMENT_CONTINUATION_TYPES
+
+ # Heredocs are complex and require us to keep track of a bit of info to refer to later
+ HeredocData = Struct.new(:identifier, :common_whitespace, keyword_init: true)
+
+ private_constant :TYPES, :EXPR_BEG, :EXPR_LABEL, :LAMBDA_TOKEN_TYPES, :LPAREN_CONVERSION_TOKEN_TYPES, :HeredocData
+
+ # The Parser::Source::Buffer that the tokens were lexed from.
+ attr_reader :source_buffer
+
+ # An array of tuples that contain prism tokens and their associated lex
+ # state when they were lexed.
+ attr_reader :lexed
+
+ # A hash that maps offsets in bytes to offsets in characters.
+ attr_reader :offset_cache
+
+ # Initialize the lexer with the given source buffer, prism tokens, and
+ # offset cache.
+ def initialize(source_buffer, lexed, offset_cache)
+ @source_buffer = source_buffer
+ @lexed = lexed
+ @offset_cache = offset_cache
+ end
+
+ Range = ::Parser::Source::Range
+ private_constant :Range
+
+ # Convert the prism tokens into the expected format for the parser gem.
+ def to_a
+ tokens = []
+
+ index = 0
+ length = lexed.length
+
+ heredoc_stack = []
+ quote_stack = []
+
+ # The parser gem emits the newline tokens for comments out of order. This saves
+ # that token location to emit at a later time to properly line everything up.
+ # https://github.com/whitequark/parser/issues/1025
+ comment_newline_location = nil
+
+ while index < length
+ token, state = lexed[index]
+ index += 1
+ next if TYPES_ALWAYS_SKIP.include?(token.type)
+
+ type = TYPES.fetch(token.type)
+ value = token.value
+ location = range(token.location.start_offset, token.location.end_offset)
+
+ case type
+ when :kDO
+ nearest_lambda_token = tokens.reverse_each.find do |token|
+ LAMBDA_TOKEN_TYPES.include?(token.first)
+ end
+
+ if nearest_lambda_token&.first == :tLAMBDA
+ type = :kDO_LAMBDA
+ end
+ when :tCHARACTER
+ value.delete_prefix!("?")
+ # Character literals behave similar to double-quoted strings. We can use the same escaping mechanism.
+ value = unescape_string(value, "?")
+ when :tCOMMENT
+ if token.type == :EMBDOC_BEGIN
+
+ while !((next_token = lexed[index]&.first) && next_token.type == :EMBDOC_END) && (index < length - 1)
+ value += next_token.value
+ index += 1
+ end
+
+ value += next_token.value
+ location = range(token.location.start_offset, next_token.location.end_offset)
+ index += 1
+ else
+ is_at_eol = value.chomp!.nil?
+ location = range(token.location.start_offset, token.location.end_offset + (is_at_eol ? 0 : -1))
+
+ prev_token, _ = lexed[index - 2] if index - 2 >= 0
+ next_token, _ = lexed[index]
+
+ is_inline_comment = prev_token&.location&.start_line == token.location.start_line
+ if is_inline_comment && !is_at_eol && !COMMENT_CONTINUATION_TYPES.include?(next_token&.type)
+ tokens << [:tCOMMENT, [value, location]]
+
+ nl_location = range(token.location.end_offset - 1, token.location.end_offset)
+ tokens << [:tNL, [nil, nl_location]]
+ next
+ elsif is_inline_comment && next_token&.type == :COMMENT
+ comment_newline_location = range(token.location.end_offset - 1, token.location.end_offset)
+ elsif comment_newline_location && !COMMENT_CONTINUATION_TYPES.include?(next_token&.type)
+ tokens << [:tCOMMENT, [value, location]]
+ tokens << [:tNL, [nil, comment_newline_location]]
+ comment_newline_location = nil
+ next
+ end
+ end
+ when :tNL
+ next_token, _ = lexed[index]
+ # Newlines after comments are emitted out of order.
+ if next_token&.type == :COMMENT
+ comment_newline_location = location
+ next
+ end
+
+ value = nil
+ when :tFLOAT
+ value = parse_float(value)
+ when :tIMAGINARY
+ value = parse_complex(value)
+ when :tINTEGER
+ if value.start_with?("+")
+ tokens << [:tUNARY_NUM, ["+", range(token.location.start_offset, token.location.start_offset + 1)]]
+ location = range(token.location.start_offset + 1, token.location.end_offset)
+ end
+
+ value = parse_integer(value)
+ when :tLABEL
+ value.chomp!(":")
+ when :tLABEL_END
+ value.chomp!(":")
+ when :tLCURLY
+ type = :tLBRACE if state == EXPR_BEG | EXPR_LABEL
+ when :tLPAREN2
+ type = :tLPAREN if tokens.empty? || LPAREN_CONVERSION_TOKEN_TYPES.include?(tokens.dig(-1, 0))
+ when :tNTH_REF
+ value = parse_integer(value.delete_prefix("$"))
+ when :tOP_ASGN
+ value.chomp!("=")
+ when :tRATIONAL
+ value = parse_rational(value)
+ when :tSPACE
+ location = range(token.location.start_offset, token.location.start_offset + percent_array_leading_whitespace(value))
+ value = nil
+ when :tSTRING_BEG
+ next_token, _ = lexed[index]
+ next_next_token, _ = lexed[index + 1]
+ basic_quotes = value == '"' || value == "'"
+
+ if basic_quotes && next_token&.type == :STRING_END
+ next_location = token.location.join(next_token.location)
+ type = :tSTRING
+ value = ""
+ location = range(next_location.start_offset, next_location.end_offset)
+ index += 1
+ elsif value.start_with?("'", '"', "%")
+ if next_token&.type == :STRING_CONTENT && next_next_token&.type == :STRING_END
+ string_value = next_token.value
+ if simplify_string?(string_value, value)
+ next_location = token.location.join(next_next_token.location)
+ if percent_array?(value)
+ value = percent_array_unescape(string_value)
+ else
+ value = unescape_string(string_value, value)
+ end
+ type = :tSTRING
+ location = range(next_location.start_offset, next_location.end_offset)
+ index += 2
+ tokens << [type, [value, location]]
+
+ next
+ end
+ end
+
+ quote_stack.push(value)
+ elsif token.type == :HEREDOC_START
+ quote = value[2] == "-" || value[2] == "~" ? value[3] : value[2]
+ heredoc_type = value[2] == "-" || value[2] == "~" ? value[2] : ""
+ heredoc = HeredocData.new(
+ identifier: value.match(/<<[-~]?["'`]?(?<heredoc_identifier>.*?)["'`]?\z/)[:heredoc_identifier],
+ common_whitespace: 0,
+ )
+
+ if quote == "`"
+ type = :tXSTRING_BEG
+ end
+
+ # The parser gem trims whitespace from squiggly heredocs. We must record
+ # the most common whitespace to later remove.
+ if heredoc_type == "~" || heredoc_type == "`"
+ heredoc.common_whitespace = calculate_heredoc_whitespace(index)
+ end
+
+ if quote == "'" || quote == '"' || quote == "`"
+ value = "<<#{quote}"
+ else
+ value = '<<"'
+ end
+
+ heredoc_stack.push(heredoc)
+ quote_stack.push(value)
+ end
+ when :tSTRING_CONTENT
+ is_percent_array = percent_array?(quote_stack.last)
+
+ if (lines = token.value.lines).one?
+ # Prism usually emits a single token for strings with line continuations.
+ # For squiggly heredocs they are not joined so we do that manually here.
+ current_string = +""
+ current_length = 0
+ start_offset = token.location.start_offset
+ while token.type == :STRING_CONTENT
+ current_length += token.value.bytesize
+ # Heredoc interpolation can have multiple STRING_CONTENT nodes on the same line.
+ prev_token, _ = lexed[index - 2] if index - 2 >= 0
+ is_first_token_on_line = prev_token && token.location.start_line != prev_token.location.start_line
+ # The parser gem only removes indentation when the heredoc is not nested
+ not_nested = heredoc_stack.size == 1
+ if is_percent_array
+ value = percent_array_unescape(token.value)
+ elsif is_first_token_on_line && not_nested && (current_heredoc = heredoc_stack.last).common_whitespace > 0
+ value = trim_heredoc_whitespace(token.value, current_heredoc)
+ end
+
+ current_string << unescape_string(value, quote_stack.last)
+ relevant_backslash_count = if quote_stack.last.start_with?("%W", "%I")
+ 0 # the last backslash escapes the newline
+ else
+ token.value[/(\\{1,})\n/, 1]&.length || 0
+ end
+ if relevant_backslash_count.even? || !interpolation?(quote_stack.last)
+ tokens << [:tSTRING_CONTENT, [current_string, range(start_offset, start_offset + current_length)]]
+ break
+ end
+ token, _ = lexed[index]
+ index += 1
+ end
+ else
+ # When the parser gem encounters a line continuation inside of a multiline string,
+ # it emits a single string node. The backslash (and remaining newline) is removed.
+ current_line = +""
+ adjustment = 0
+ start_offset = token.location.start_offset
+ emit = false
+
+ lines.each.with_index do |line, index|
+ chomped_line = line.chomp
+ backslash_count = chomped_line[/\\{1,}\z/]&.length || 0
+ is_interpolation = interpolation?(quote_stack.last)
+
+ if backslash_count.odd? && (is_interpolation || is_percent_array)
+ if is_percent_array
+ current_line << percent_array_unescape(line)
+ adjustment += 1
+ else
+ chomped_line.delete_suffix!("\\")
+ current_line << chomped_line
+ adjustment += 2
+ end
+ # If the string ends with a line continuation emit the remainder
+ emit = index == lines.count - 1
+ else
+ current_line << line
+ emit = true
+ end
+
+ if emit
+ end_offset = start_offset + current_line.bytesize + adjustment
+ tokens << [:tSTRING_CONTENT, [unescape_string(current_line, quote_stack.last), range(start_offset, end_offset)]]
+ start_offset = end_offset
+ current_line = +""
+ adjustment = 0
+ end
+ end
+ end
+ next
+ when :tSTRING_DVAR
+ value = nil
+ when :tSTRING_END
+ if token.type == :HEREDOC_END && value.end_with?("\n")
+ newline_length = value.end_with?("\r\n") ? 2 : 1
+ value = heredoc_stack.pop.identifier
+ location = range(token.location.start_offset, token.location.end_offset - newline_length)
+ elsif token.type == :REGEXP_END
+ value = value[0]
+ location = range(token.location.start_offset, token.location.start_offset + 1)
+ end
+
+ if percent_array?(quote_stack.pop)
+ prev_token, _ = lexed[index - 2] if index - 2 >= 0
+ empty = %i[PERCENT_LOWER_I PERCENT_LOWER_W PERCENT_UPPER_I PERCENT_UPPER_W].include?(prev_token&.type)
+ ends_with_whitespace = prev_token&.type == :WORDS_SEP
+ # parser always emits a space token after content in a percent array, even if no actual whitespace is present.
+ if !empty && !ends_with_whitespace
+ tokens << [:tSPACE, [nil, range(token.location.start_offset, token.location.start_offset)]]
+ end
+ end
+ when :tSYMBEG
+ if (next_token = lexed[index]&.first) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR && next_token.type != :STRING_END
+ next_location = token.location.join(next_token.location)
+ type = :tSYMBOL
+ value = next_token.value
+ value = { "~@" => "~", "!@" => "!" }.fetch(value, value)
+ location = range(next_location.start_offset, next_location.end_offset)
+ index += 1
+ else
+ quote_stack.push(value)
+ end
+ when :tFID
+ if !tokens.empty? && tokens.dig(-1, 0) == :kDEF
+ type = :tIDENTIFIER
+ end
+ when :tXSTRING_BEG
+ if (next_token = lexed[index]&.first) && !%i[STRING_CONTENT STRING_END EMBEXPR_BEGIN].include?(next_token.type)
+ # self.`()
+ type = :tBACK_REF2
+ end
+ quote_stack.push(value)
+ when :tSYMBOLS_BEG, :tQSYMBOLS_BEG, :tWORDS_BEG, :tQWORDS_BEG
+ if (next_token = lexed[index]&.first) && next_token.type == :WORDS_SEP
+ index += 1
+ end
+
+ quote_stack.push(value)
+ when :tREGEXP_BEG
+ quote_stack.push(value)
+ end
+
+ tokens << [type, [value, location]]
+
+ if token.type == :REGEXP_END
+ tokens << [:tREGEXP_OPT, [token.value[1..], range(token.location.start_offset + 1, token.location.end_offset)]]
+ end
+ end
+
+ tokens
+ end
+
+ private
+
+ # Creates a new parser range, taking prisms byte offsets into account
+ def range(start_offset, end_offset)
+ Range.new(source_buffer, offset_cache[start_offset], offset_cache[end_offset])
+ end
+
+ # Parse an integer from the string representation.
+ def parse_integer(value)
+ Integer(value)
+ rescue ArgumentError
+ 0
+ end
+
+ # Parse a float from the string representation.
+ def parse_float(value)
+ Float(value)
+ rescue ArgumentError
+ 0.0
+ end
+
+ # Parse a complex from the string representation.
+ def parse_complex(value)
+ value.chomp!("i")
+
+ if value.end_with?("r")
+ Complex(0, parse_rational(value))
+ elsif value.start_with?(/0[BbOoDdXx]/)
+ Complex(0, parse_integer(value))
+ else
+ Complex(0, value)
+ end
+ rescue ArgumentError
+ 0i
+ end
+
+ # Parse a rational from the string representation.
+ def parse_rational(value)
+ value.chomp!("r")
+
+ if value.start_with?(/0[BbOoDdXx]/)
+ Rational(parse_integer(value))
+ else
+ Rational(value)
+ end
+ rescue ArgumentError
+ 0r
+ end
+
+ # Wonky heredoc tab/spaces rules.
+ # https://github.com/ruby/prism/blob/v1.3.0/src/prism.c#L10548-L10558
+ def calculate_heredoc_whitespace(heredoc_token_index)
+ next_token_index = heredoc_token_index
+ nesting_level = 0
+ previous_line = -1
+ result = Float::MAX
+
+ while (next_token = lexed[next_token_index]&.first)
+ next_token_index += 1
+ next_next_token, _ = lexed[next_token_index]
+ first_token_on_line = next_token.location.start_column == 0
+
+ # String content inside nested heredocs and interpolation is ignored
+ if next_token.type == :HEREDOC_START || next_token.type == :EMBEXPR_BEGIN
+ # When interpolation is the first token of a line there is no string
+ # content to check against. There will be no common whitespace.
+ if nesting_level == 0 && first_token_on_line
+ result = 0
+ end
+ nesting_level += 1
+ elsif next_token.type == :HEREDOC_END || next_token.type == :EMBEXPR_END
+ nesting_level -= 1
+ # When we encountered the matching heredoc end, we can exit
+ break if nesting_level == -1
+ elsif next_token.type == :STRING_CONTENT && nesting_level == 0 && first_token_on_line
+ common_whitespace = 0
+ next_token.value[/^\s*/].each_char do |char|
+ if char == "\t"
+ common_whitespace = (common_whitespace / 8 + 1) * 8;
+ else
+ common_whitespace += 1
+ end
+ end
+
+ is_first_token_on_line = next_token.location.start_line != previous_line
+ # Whitespace is significant if followed by interpolation
+ whitespace_only = common_whitespace == next_token.value.length && next_next_token&.location&.start_line != next_token.location.start_line
+ if is_first_token_on_line && !whitespace_only && common_whitespace < result
+ result = common_whitespace
+ previous_line = next_token.location.start_line
+ end
+ end
+ end
+ result
+ end
+
+ # Wonky heredoc tab/spaces rules.
+ # https://github.com/ruby/prism/blob/v1.3.0/src/prism.c#L16528-L16545
+ def trim_heredoc_whitespace(string, heredoc)
+ trimmed_whitespace = 0
+ trimmed_characters = 0
+ while (string[trimmed_characters] == "\t" || string[trimmed_characters] == " ") && trimmed_whitespace < heredoc.common_whitespace
+ if string[trimmed_characters] == "\t"
+ trimmed_whitespace = (trimmed_whitespace / 8 + 1) * 8;
+ break if trimmed_whitespace > heredoc.common_whitespace
+ else
+ trimmed_whitespace += 1
+ end
+ trimmed_characters += 1
+ end
+
+ string[trimmed_characters..]
+ end
+
+ # Escape sequences that have special and should appear unescaped in the resulting string.
+ ESCAPES = {
+ "a" => "\a", "b" => "\b", "e" => "\e", "f" => "\f",
+ "n" => "\n", "r" => "\r", "s" => "\s", "t" => "\t",
+ "v" => "\v", "\\" => "\\"
+ }.freeze
+ private_constant :ESCAPES
+
+ # When one of these delimiters is encountered, then the other
+ # one is allowed to be escaped as well.
+ DELIMITER_SYMETRY = { "[" => "]", "(" => ")", "{" => "}", "<" => ">" }.freeze
+ private_constant :DELIMITER_SYMETRY
+
+
+ # https://github.com/whitequark/parser/blob/v3.3.6.0/lib/parser/lexer-strings.rl#L14
+ REGEXP_META_CHARACTERS = ["\\", "$", "(", ")", "*", "+", ".", "<", ">", "?", "[", "]", "^", "{", "|", "}"]
+ private_constant :REGEXP_META_CHARACTERS
+
+ # Apply Ruby string escaping rules
+ def unescape_string(string, quote)
+ # In single-quoted heredocs, everything is taken literally.
+ return string if quote == "<<'"
+
+ # OPTIMIZATION: Assume that few strings need escaping to speed up the common case.
+ return string unless string.include?("\\")
+
+ # Enclosing character for the string. `"` for `"foo"`, `{` for `%w{foo}`, etc.
+ delimiter = quote[-1]
+
+ if regexp?(quote)
+ # Should be escaped handled to single-quoted heredocs. The only character that is
+ # allowed to be escaped is the delimiter, except when that also has special meaning
+ # in the regexp. Since all the symetry delimiters have special meaning, they don't need
+ # to be considered separately.
+ if REGEXP_META_CHARACTERS.include?(delimiter)
+ string
+ else
+ # There can never be an even amount of backslashes. It would be a syntax error.
+ string.gsub(/\\(#{Regexp.escape(delimiter)})/, '\1')
+ end
+ elsif interpolation?(quote)
+ # Appending individual escape sequences may force the string out of its intended
+ # encoding. Start out with binary and force it back later.
+ result = "".b
+
+ scanner = StringScanner.new(string)
+ while (skipped = scanner.skip_until(/\\/))
+ # Append what was just skipped over, excluding the found backslash.
+ result.append_as_bytes(string.byteslice(scanner.pos - skipped, skipped - 1))
+ escape_read(result, scanner, false, false)
+ end
+
+ # Add remaining chars
+ result.append_as_bytes(string.byteslice(scanner.pos..))
+ result.force_encoding(source_buffer.source.encoding)
+ else
+ delimiters = Regexp.escape("#{delimiter}#{DELIMITER_SYMETRY[delimiter]}")
+ string.gsub(/\\([\\#{delimiters}])/, '\1')
+ end
+ end
+
+ # Certain strings are merged into a single string token.
+ def simplify_string?(value, quote)
+ case quote
+ when "'"
+ # Only simplify 'foo'
+ !value.include?("\n")
+ when '"'
+ # Simplify when every line ends with a line continuation, or it is the last line
+ value.lines.all? do |line|
+ !line.end_with?("\n") || line[/(\\*)$/, 1]&.length&.odd?
+ end
+ else
+ # %q and similar are never simplified
+ false
+ end
+ end
+
+ # Escape a byte value, given the control and meta flags.
+ def escape_build(value, control, meta)
+ value &= 0x9f if control
+ value |= 0x80 if meta
+ value
+ end
+
+ # Read an escape out of the string scanner, given the control and meta
+ # flags, and push the unescaped value into the result.
+ def escape_read(result, scanner, control, meta)
+ if scanner.skip("\n")
+ # Line continuation
+ elsif (value = ESCAPES[scanner.peek(1)])
+ # Simple single-character escape sequences like \n
+ result.append_as_bytes(value)
+ scanner.pos += 1
+ elsif (value = scanner.scan(/[0-7]{1,3}/))
+ # \nnn
+ result.append_as_bytes(escape_build(value.to_i(8), control, meta))
+ elsif (value = scanner.scan(/x[0-9a-fA-F]{1,2}/))
+ # \xnn
+ result.append_as_bytes(escape_build(value[1..].to_i(16), control, meta))
+ elsif (value = scanner.scan(/u[0-9a-fA-F]{4}/))
+ # \unnnn
+ result.append_as_bytes(value[1..].hex.chr(Encoding::UTF_8))
+ elsif scanner.skip("u{}")
+ # https://github.com/whitequark/parser/issues/856
+ elsif (value = scanner.scan(/u{.*?}/))
+ # \u{nnnn ...}
+ value[2..-2].split.each do |unicode|
+ result.append_as_bytes(unicode.hex.chr(Encoding::UTF_8))
+ end
+ elsif (value = scanner.scan(/c\\?(?=[[:print:]])|C-\\?(?=[[:print:]])/))
+ # \cx or \C-x where x is an ASCII printable character
+ escape_read(result, scanner, true, meta)
+ elsif (value = scanner.scan(/M-\\?(?=[[:print:]])/))
+ # \M-x where x is an ASCII printable character
+ escape_read(result, scanner, control, true)
+ elsif (byte = scanner.scan_byte)
+ # Something else after an escape.
+ if control && byte == 0x3f # ASCII '?'
+ result.append_as_bytes(escape_build(0x7f, false, meta))
+ else
+ result.append_as_bytes(escape_build(byte, control, meta))
+ end
+ end
+ end
+
+ # In a percent array, certain whitespace can be preceeded with a backslash,
+ # causing the following characters to be part of the previous element.
+ def percent_array_unescape(string)
+ string.gsub(/(\\)+[ \f\n\r\t\v]/) do |full_match|
+ full_match.delete_prefix!("\\") if Regexp.last_match[1].length.odd?
+ full_match
+ end
+ end
+
+ # For %-arrays whitespace, the parser gem only considers whitespace before the newline.
+ def percent_array_leading_whitespace(string)
+ return 1 if string.start_with?("\n")
+
+ leading_whitespace = 0
+ string.each_char do |c|
+ break if c == "\n"
+ leading_whitespace += 1
+ end
+ leading_whitespace
+ end
+
+ # Determine if characters preceeded by a backslash should be escaped or not
+ def interpolation?(quote)
+ !quote.end_with?("'") && !quote.start_with?("%q", "%w", "%i", "%s")
+ end
+
+ # Regexp allow interpolation but are handled differently during unescaping
+ def regexp?(quote)
+ quote == "/" || quote.start_with?("%r")
+ end
+
+ # Determine if the string is part of a %-style array.
+ def percent_array?(quote)
+ quote.start_with?("%w", "%W", "%i", "%I")
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/parser_current.rb b/lib/prism/translation/parser_current.rb
new file mode 100644
index 0000000000..f7c1070e30
--- /dev/null
+++ b/lib/prism/translation/parser_current.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+# :markup: markdown
+#--
+# typed: ignore
+
+module Prism
+ module Translation
+ case RUBY_VERSION
+ when /^3\.3\./
+ ParserCurrent = Parser33
+ when /^3\.4\./
+ ParserCurrent = Parser34
+ when /^3\.5\./, /^4\.0\./
+ ParserCurrent = Parser40
+ when /^4\.1\./
+ ParserCurrent = Parser41
+ else
+ # Keep this in sync with released Ruby.
+ parser = Parser40
+ major, minor, _patch = Gem::Version.new(RUBY_VERSION).segments
+ warn "warning: `Prism::Translation::Current` is loading #{parser.name}, " \
+ "but you are running #{major}.#{minor}."
+ ParserCurrent = parser
+ end
+ end
+end
diff --git a/lib/prism/translation/parser_versions.rb b/lib/prism/translation/parser_versions.rb
new file mode 100644
index 0000000000..720c7d548c
--- /dev/null
+++ b/lib/prism/translation/parser_versions.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+module Prism
+ module Translation
+ # This class is the entry-point for Ruby 3.3 of `Prism::Translation::Parser`.
+ class Parser33 < Parser
+ def version # :nodoc:
+ 33
+ end
+ end
+
+ # This class is the entry-point for Ruby 3.4 of `Prism::Translation::Parser`.
+ class Parser34 < Parser
+ def version # :nodoc:
+ 34
+ end
+ end
+
+ # This class is the entry-point for Ruby 4.0 of `Prism::Translation::Parser`.
+ class Parser40 < Parser
+ def version # :nodoc:
+ 40
+ end
+ end
+
+ Parser35 = Parser40 # :nodoc:
+
+ # This class is the entry-point for Ruby 4.1 of `Prism::Translation::Parser`.
+ class Parser41 < Parser
+ def version # :nodoc:
+ 41
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb
new file mode 100644
index 0000000000..f179a149a1
--- /dev/null
+++ b/lib/prism/translation/ripper.rb
@@ -0,0 +1,4266 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+module Prism
+ module Translation
+ # This class provides a compatibility layer between prism and Ripper. It
+ # functions by parsing the entire tree first and then walking it and
+ # executing each of the Ripper callbacks as it goes. To use this class, you
+ # treat `Prism::Translation::Ripper` effectively as you would treat the
+ # `Ripper` class.
+ #
+ # Note that this class will serve the most common use cases, but Ripper's
+ # API is extensive and undocumented. It relies on reporting the state of the
+ # parser at any given time. We do our best to replicate that here, but
+ # because it is a different architecture it is not possible to perfectly
+ # replicate the behavior of Ripper.
+ #
+ # The main known difference is that we may omit dispatching some events in
+ # some cases. This impacts the following events:
+ #
+ # - on_assign_error
+ # - on_comma
+ # - on_ignored_nl
+ # - on_ignored_sp
+ # - on_nl
+ # - on_operator_ambiguous
+ # - on_semicolon
+ # - on_sp
+ #
+ class Ripper < Compiler
+ # Parses the given Ruby program read from +src+.
+ # +src+ must be a String or an IO or a object with a #gets method.
+ def self.parse(src, filename = "(ripper)", lineno = 1)
+ new(src, filename, lineno).parse
+ end
+
+ # Tokenizes the Ruby program and returns an array of an array,
+ # which is formatted like
+ # <code>[[lineno, column], type, token, state]</code>.
+ # The +filename+ argument is mostly ignored.
+ # By default, this method does not handle syntax errors in +src+,
+ # use the +raise_errors+ keyword to raise a SyntaxError for an error in +src+.
+ #
+ # require "ripper"
+ # require "pp"
+ #
+ # pp Ripper.lex("def m(a) nil end")
+ # #=> [[[1, 0], :on_kw, "def", FNAME ],
+ # [[1, 3], :on_sp, " ", FNAME ],
+ # [[1, 4], :on_ident, "m", ENDFN ],
+ # [[1, 5], :on_lparen, "(", BEG|LABEL],
+ # [[1, 6], :on_ident, "a", ARG ],
+ # [[1, 7], :on_rparen, ")", ENDFN ],
+ # [[1, 8], :on_sp, " ", BEG ],
+ # [[1, 9], :on_kw, "nil", END ],
+ # [[1, 12], :on_sp, " ", END ],
+ # [[1, 13], :on_kw, "end", END ]]
+ #
+ def self.lex(src, filename = "-", lineno = 1, raise_errors: false)
+ coerced = coerce_source(src)
+ result = Prism.lex_compat(coerced, filepath: filename, line: lineno, version: "current", encoding: coerced.encoding)
+
+ if result.failure? && raise_errors
+ raise SyntaxError, result.errors.first.message
+ else
+ result.value
+ end
+ end
+
+ # Tokenizes the Ruby program and returns an array of strings.
+ # The +filename+ and +lineno+ arguments are mostly ignored, since the
+ # return value is just the tokenized input.
+ # By default, this method does not handle syntax errors in +src+,
+ # use the +raise_errors+ keyword to raise a SyntaxError for an error in +src+.
+ #
+ # p Ripper.tokenize("def m(a) nil end")
+ # # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
+ #
+ def self.tokenize(...)
+ lex(...).map { |token| token[2] }
+ end
+
+ # Mirros the various lex_types that ripper supports
+ def self.coerce_source(source) # :nodoc:
+ if source.is_a?(IO)
+ source.read
+ elsif source.respond_to?(:gets)
+ src = +""
+ while line = source.gets
+ src << line
+ end
+ src
+ else
+ source.to_str
+ end
+ end
+
+ # This contains a table of all of the parser events and their
+ # corresponding arity.
+ PARSER_EVENT_TABLE = {
+ BEGIN: 1,
+ END: 1,
+ alias: 2,
+ alias_error: 2,
+ aref: 2,
+ aref_field: 2,
+ arg_ambiguous: 1,
+ arg_paren: 1,
+ args_add: 2,
+ args_add_block: 2,
+ args_add_star: 2,
+ args_forward: 0,
+ args_new: 0,
+ array: 1,
+ aryptn: 4,
+ assign: 2,
+ assign_error: 2,
+ assoc_new: 2,
+ assoc_splat: 1,
+ assoclist_from_args: 1,
+ bare_assoc_hash: 1,
+ begin: 1,
+ binary: 3,
+ block_var: 2,
+ blockarg: 1,
+ bodystmt: 4,
+ brace_block: 2,
+ break: 1,
+ call: 3,
+ case: 2,
+ class: 3,
+ class_name_error: 2,
+ command: 2,
+ command_call: 4,
+ const_path_field: 2,
+ const_path_ref: 2,
+ const_ref: 1,
+ def: 3,
+ defined: 1,
+ defs: 5,
+ do_block: 2,
+ dot2: 2,
+ dot3: 2,
+ dyna_symbol: 1,
+ else: 1,
+ elsif: 3,
+ ensure: 1,
+ excessed_comma: 0,
+ fcall: 1,
+ field: 3,
+ fndptn: 4,
+ for: 3,
+ hash: 1,
+ heredoc_dedent: 2,
+ hshptn: 3,
+ if: 3,
+ if_mod: 2,
+ ifop: 3,
+ in: 3,
+ kwrest_param: 1,
+ lambda: 2,
+ magic_comment: 2,
+ massign: 2,
+ method_add_arg: 2,
+ method_add_block: 2,
+ mlhs_add: 2,
+ mlhs_add_post: 2,
+ mlhs_add_star: 2,
+ mlhs_new: 0,
+ mlhs_paren: 1,
+ module: 2,
+ mrhs_add: 2,
+ mrhs_add_star: 2,
+ mrhs_new: 0,
+ mrhs_new_from_args: 1,
+ next: 1,
+ nokw_param: 1,
+ opassign: 3,
+ operator_ambiguous: 2,
+ param_error: 2,
+ params: 7,
+ paren: 1,
+ parse_error: 1,
+ program: 1,
+ qsymbols_add: 2,
+ qsymbols_new: 0,
+ qwords_add: 2,
+ qwords_new: 0,
+ redo: 0,
+ regexp_add: 2,
+ regexp_literal: 2,
+ regexp_new: 0,
+ rescue: 4,
+ rescue_mod: 2,
+ rest_param: 1,
+ retry: 0,
+ return: 1,
+ return0: 0,
+ sclass: 2,
+ stmts_add: 2,
+ stmts_new: 0,
+ string_add: 2,
+ string_concat: 2,
+ string_content: 0,
+ string_dvar: 1,
+ string_embexpr: 1,
+ string_literal: 1,
+ super: 1,
+ symbol: 1,
+ symbol_literal: 1,
+ symbols_add: 2,
+ symbols_new: 0,
+ top_const_field: 1,
+ top_const_ref: 1,
+ unary: 2,
+ undef: 1,
+ unless: 3,
+ unless_mod: 2,
+ until: 2,
+ until_mod: 2,
+ var_alias: 2,
+ var_field: 1,
+ var_ref: 1,
+ vcall: 1,
+ void_stmt: 0,
+ when: 3,
+ while: 2,
+ while_mod: 2,
+ word_add: 2,
+ word_new: 0,
+ words_add: 2,
+ words_new: 0,
+ xstring_add: 2,
+ xstring_literal: 1,
+ xstring_new: 0,
+ yield: 1,
+ yield0: 0,
+ zsuper: 0
+ }
+
+ # This contains a table of all of the scanner events and their
+ # corresponding arity.
+ SCANNER_EVENT_TABLE = {
+ CHAR: 1,
+ __end__: 1,
+ backref: 1,
+ backtick: 1,
+ comma: 1,
+ comment: 1,
+ const: 1,
+ cvar: 1,
+ embdoc: 1,
+ embdoc_beg: 1,
+ embdoc_end: 1,
+ embexpr_beg: 1,
+ embexpr_end: 1,
+ embvar: 1,
+ float: 1,
+ gvar: 1,
+ heredoc_beg: 1,
+ heredoc_end: 1,
+ ident: 1,
+ ignored_nl: 1,
+ imaginary: 1,
+ int: 1,
+ ivar: 1,
+ kw: 1,
+ label: 1,
+ label_end: 1,
+ lbrace: 1,
+ lbracket: 1,
+ lparen: 1,
+ nl: 1,
+ op: 1,
+ period: 1,
+ qsymbols_beg: 1,
+ qwords_beg: 1,
+ rational: 1,
+ rbrace: 1,
+ rbracket: 1,
+ regexp_beg: 1,
+ regexp_end: 1,
+ rparen: 1,
+ semicolon: 1,
+ sp: 1,
+ symbeg: 1,
+ symbols_beg: 1,
+ tlambda: 1,
+ tlambeg: 1,
+ tstring_beg: 1,
+ tstring_content: 1,
+ tstring_end: 1,
+ words_beg: 1,
+ words_sep: 1,
+ ignored_sp: 1
+ }
+
+ # 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
+
+ # A list of all of the Ruby keywords.
+ KEYWORDS = [
+ "alias",
+ "and",
+ "begin",
+ "BEGIN",
+ "break",
+ "case",
+ "class",
+ "def",
+ "defined?",
+ "do",
+ "else",
+ "elsif",
+ "end",
+ "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",
+ "__ENCODING__",
+ "__FILE__",
+ "__LINE__"
+ ].to_set
+
+ # A list of all of the Ruby binary operators.
+ BINARY_OPERATORS = [
+ :!=,
+ :!~,
+ :=~,
+ :==,
+ :===,
+ :<=>,
+ :>,
+ :>=,
+ :<,
+ :<=,
+ :&,
+ :|,
+ :^,
+ :>>,
+ :<<,
+ :-,
+ :+,
+ :%,
+ :/,
+ :*,
+ :**
+ ].to_set
+
+ private_constant :KEYWORDS, :BINARY_OPERATORS
+
+ # Parses +src+ and create S-exp tree.
+ # Returns more readable tree rather than Ripper.sexp_raw.
+ # This method is mainly for developer use.
+ # The +filename+ argument is mostly ignored.
+ # By default, this method does not handle syntax errors in +src+,
+ # returning +nil+ in such cases. Use the +raise_errors+ keyword
+ # to raise a SyntaxError for an error in +src+.
+ #
+ # require "ripper"
+ # require "pp"
+ #
+ # pp Ripper.sexp("def m(a) nil end")
+ # #=> [:program,
+ # [[:def,
+ # [:@ident, "m", [1, 4]],
+ # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil, nil, nil]],
+ # [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
+ #
+ def self.sexp(src, filename = "-", lineno = 1, raise_errors: false)
+ builder = SexpBuilderPP.new(src, filename, lineno)
+ sexp = builder.parse
+ if builder.error?
+ if raise_errors
+ raise SyntaxError, builder.error
+ end
+ else
+ sexp
+ end
+ end
+
+ # Parses +src+ and create S-exp tree.
+ # This method is mainly for developer use.
+ # The +filename+ argument is mostly ignored.
+ # By default, this method does not handle syntax errors in +src+,
+ # returning +nil+ in such cases. Use the +raise_errors+ keyword
+ # to raise a SyntaxError for an error in +src+.
+ #
+ # require "ripper"
+ # require "pp"
+ #
+ # pp Ripper.sexp_raw("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 self.sexp_raw(src, filename = "-", lineno = 1, raise_errors: false)
+ builder = SexpBuilder.new(src, filename, lineno)
+ sexp = builder.parse
+ if builder.error?
+ if raise_errors
+ raise SyntaxError, builder.error
+ end
+ else
+ sexp
+ end
+ end
+
+ autoload :Filter, "prism/translation/ripper/filter"
+ autoload :Lexer, "prism/translation/ripper/lexer"
+ autoload :SexpBuilder, "prism/translation/ripper/sexp"
+ autoload :SexpBuilderPP, "prism/translation/ripper/sexp"
+
+ # Provides optimized access to line and column information.
+ # Ripper bounds are mostly accessed in a linear fashion, so
+ # we can try a linear scan first and fall back to binary search.
+ class LineAndColumnCache # :nodoc:
+ # How many should it look ahead/behind before falling back to binary searching.
+ WINDOW = 8
+ private_constant :WINDOW
+
+ #: (Source source) -> void
+ def initialize(source)
+ @source = source
+ @offsets = source.offsets
+ @hint = 0
+ end
+
+ #: (Integer byte_offset) -> [Integer, Integer]
+ def line_and_column(byte_offset)
+ @hint = new_hint(byte_offset) || @source.find_line(byte_offset)
+ return [@hint + @source.start_line, byte_offset - @offsets[@hint]]
+ end
+
+ private
+
+ def new_hint(byte_offset)
+ if @offsets[@hint] <= byte_offset
+ # Same line?
+ if (@hint + 1 >= @offsets.size || @offsets[@hint + 1] > byte_offset)
+ return @hint
+ end
+
+ # Scan forwards
+ limit = [@hint + WINDOW + 1, @offsets.size].min
+ idx = @hint + 1
+ while idx < limit
+ if @offsets[idx] > byte_offset
+ return idx - 1
+ end
+ if @offsets[idx] == byte_offset
+ return idx
+ end
+ idx += 1
+ end
+ else
+ # Scan backwards
+ limit = @hint > WINDOW ? @hint - WINDOW : 0
+ idx = @hint
+ while idx >= limit + 1
+ if @offsets[idx - 1] <= byte_offset
+ return idx - 1
+ end
+ idx -= 1
+ end
+ end
+
+ nil
+ end
+ end
+
+ # :stopdoc:
+ # This is not part of the public API but used by some gems.
+
+ # Ripper-internal bitflags.
+ LEX_STATE_NAMES = %i[
+ BEG END ENDARG ENDFN ARG CMDARG MID FNAME DOT CLASS LABEL LABELED FITEM
+ ].map.with_index.to_h { |name, i| [2 ** i, name] }.freeze
+ private_constant :LEX_STATE_NAMES
+
+ LEX_STATE_NAMES.each do |value, key|
+ const_set("EXPR_#{key}", value)
+ end
+ EXPR_NONE = 0
+ EXPR_VALUE = EXPR_BEG
+ EXPR_BEG_ANY = EXPR_BEG | EXPR_MID | EXPR_CLASS
+ EXPR_ARG_ANY = EXPR_ARG | EXPR_CMDARG
+ EXPR_END_ANY = EXPR_END | EXPR_ENDARG | EXPR_ENDFN
+
+ def self.lex_state_name(state)
+ LEX_STATE_NAMES.filter_map { |flag, name| name if state & flag != 0 }.join("|")
+ end
+
+ # :startdoc:
+
+ # The source that is being parsed.
+ attr_reader :source
+
+ # The filename of the source being parsed.
+ attr_reader :filename
+
+ # The current line number of the parser.
+ attr_reader :lineno
+
+ # The current column in bytes of the parser.
+ attr_reader :column
+
+ # Create a new Translation::Ripper object with the given source.
+ def initialize(source, filename = "(ripper)", lineno = 1)
+ @source = Ripper.coerce_source(source)
+ @filename = filename
+ @lineno = lineno
+ @column = 0
+ @result = nil
+ @line_and_column_cache = nil
+ end
+
+ ##########################################################################
+ # Public interface
+ ##########################################################################
+
+ # True if the parser encountered an error during parsing.
+ def error?
+ result.failure?
+ end
+
+ # Parse the source and return the result.
+ def parse
+ result.comments.each do |comment|
+ location = comment.location
+ bounds(location)
+
+ if comment.is_a?(InlineComment)
+ # Inline comments always contain a newline if the line itself contains it
+ if result.source.source.bytesize > comment.location.end_offset
+ on_comment("#{comment.slice}\n")
+ else
+ on_comment(comment.slice)
+ end
+ else
+ offset = location.start_offset
+ lines = comment.slice.lines
+
+ lines.each_with_index do |line, index|
+ bounds(location.copy(start_offset: offset))
+
+ if index == 0
+ on_embdoc_beg(line)
+ elsif index == lines.size - 1
+ on_embdoc_end(line)
+ else
+ on_embdoc(line)
+ end
+
+ offset += line.bytesize
+ end
+ end
+ end
+
+ result.magic_comments.each do |magic_comment|
+ on_magic_comment(magic_comment.key, magic_comment.value)
+ end
+
+ unless result.data_loc.nil?
+ on___end__(result.data_loc.slice.each_line.first)
+ end
+
+ result.warnings.each do |warning|
+ bounds(warning.location)
+
+ if warning.level == :default
+ warning(warning.message)
+ else
+ case warning.type
+ when :ambiguous_first_argument_plus
+ on_arg_ambiguous("+")
+ when :ambiguous_first_argument_minus
+ on_arg_ambiguous("-")
+ when :ambiguous_slash
+ on_arg_ambiguous("/")
+ else
+ warn(warning.message)
+ end
+ end
+ end
+
+ if error?
+ result.errors.each do |error|
+ location = error.location
+ bounds(location)
+
+ case error.type
+ when :alias_argument
+ on_alias_error("can't make alias for the number variables", location.slice)
+ when :argument_formal_class
+ on_param_error("formal argument cannot be a class variable", location.slice)
+ when :argument_format_constant
+ on_param_error("formal argument cannot be a constant", location.slice)
+ when :argument_formal_global
+ on_param_error("formal argument cannot be a global variable", location.slice)
+ when :argument_formal_ivar
+ on_param_error("formal argument cannot be an instance variable", location.slice)
+ when :class_name, :module_name
+ on_class_name_error("class/module name must be CONSTANT", location.slice)
+ else
+ on_parse_error(error.message)
+ end
+ end
+
+ nil
+ else
+ result.value.accept(self)
+ end
+ end
+
+ ##########################################################################
+ # Visitor methods
+ ##########################################################################
+
+ # :stopdoc:
+
+ # alias foo bar
+ # ^^^^^^^^^^^^^
+ def visit_alias_method_node(node)
+ bounds(node.keyword_loc)
+ on_kw("alias")
+
+ new_name = visit(node.new_name)
+ old_name = visit(node.old_name)
+
+ bounds(node.location)
+ on_alias(new_name, old_name)
+ end
+
+ # alias $foo $bar
+ # ^^^^^^^^^^^^^^^
+ def visit_alias_global_variable_node(node)
+ bounds(node.keyword_loc)
+ on_kw("alias")
+
+ new_name = visit_alias_global_variable_node_value(node.new_name)
+ old_name = visit_alias_global_variable_node_value(node.old_name)
+
+ bounds(node.location)
+ on_var_alias(new_name, old_name)
+ end
+
+ # Visit one side of an alias global variable node.
+ private def visit_alias_global_variable_node_value(node)
+ bounds(node.location)
+
+ case node
+ when BackReferenceReadNode
+ on_backref(node.slice)
+ when GlobalVariableReadNode
+ on_gvar(node.name.to_s)
+ else
+ raise
+ end
+ end
+
+ # foo => bar | baz
+ # ^^^^^^^^^
+ def visit_alternation_pattern_node(node)
+ left = visit_pattern_node(node.left)
+
+ bounds(node.operator_loc)
+ on_op("|")
+
+ right = visit_pattern_node(node.right)
+
+ bounds(node.location)
+ on_binary(left, :|, right)
+ end
+
+ # Visit a pattern within a pattern match. This is used to bypass the
+ # parenthesis node that can be used to wrap patterns.
+ private def visit_pattern_node(node)
+ if node.is_a?(ParenthesesNode)
+ bounds(node.opening_loc)
+ on_lparen("(")
+ result = visit(node.body)
+ bounds(node.closing_loc)
+ on_rparen(")")
+
+ result
+ else
+ visit(node)
+ end
+ end
+
+ # a and b
+ # ^^^^^^^
+ def visit_and_node(node)
+ left = visit(node.left)
+
+ bounds(node.operator_loc)
+ if node.operator == "and"
+ on_kw("and")
+ else
+ on_op("&&")
+ end
+
+ right = visit(node.right)
+
+ bounds(node.location)
+ on_binary(left, node.operator.to_sym, right)
+ end
+
+ # []
+ # ^^
+ def visit_array_node(node)
+ case (opening = node.opening)
+ when /^%w/
+ opening_loc = node.opening_loc
+ bounds(opening_loc)
+ on_qwords_beg(opening)
+
+ elements = on_qwords_new
+ previous = nil
+
+ node.elements.each do |element|
+ visit_words_sep(opening_loc, previous, element)
+
+ bounds(element.location)
+ elements = on_qwords_add(elements, on_tstring_content(element.content))
+
+ previous = element
+ end
+
+ visit_words_sep(opening_loc, node.elements.last, node.closing_loc)
+
+ bounds(node.closing_loc)
+ on_tstring_end(node.closing)
+ when /^%i/
+ opening_loc = node.opening_loc
+ bounds(opening_loc)
+ on_qsymbols_beg(opening)
+
+ elements = on_qsymbols_new
+ previous = nil
+
+ node.elements.each do |element|
+ visit_words_sep(opening_loc, previous, element)
+
+ bounds(element.location)
+ elements = on_qsymbols_add(elements, on_tstring_content(element.value))
+
+ previous = element
+ end
+
+ visit_words_sep(opening_loc, node.elements.last, node.closing_loc)
+
+ bounds(node.closing_loc)
+ on_tstring_end(node.closing)
+ when /^%W/
+ opening_loc = node.opening_loc
+ bounds(opening_loc)
+ on_words_beg(opening)
+
+ elements = on_words_new
+ previous = nil
+
+ node.elements.each do |element|
+ visit_words_sep(opening_loc, previous, element)
+
+ bounds(element.location)
+ elements =
+ on_words_add(
+ elements,
+ if element.is_a?(StringNode)
+ on_word_add(on_word_new, on_tstring_content(element.content))
+ else
+ element.parts.inject(on_word_new) do |word, part|
+ word_part =
+ if part.is_a?(StringNode)
+ bounds(part.location)
+ on_tstring_content(part.content)
+ else
+ visit(part)
+ end
+
+ on_word_add(word, word_part)
+ end
+ end
+ )
+
+ previous = element
+ end
+
+ visit_words_sep(opening_loc, node.elements.last, node.closing_loc)
+
+ bounds(node.closing_loc)
+ on_tstring_end(node.closing)
+ when /^%I/
+ opening_loc = node.opening_loc
+ bounds(opening_loc)
+ on_symbols_beg(opening)
+
+ elements = on_symbols_new
+ previous = nil
+
+ node.elements.each do |element|
+ visit_words_sep(opening_loc, previous, element)
+
+ bounds(element.location)
+ elements =
+ on_symbols_add(
+ elements,
+ if element.is_a?(SymbolNode)
+ on_word_add(on_word_new, on_tstring_content(element.value))
+ else
+ element.parts.inject(on_word_new) do |word, part|
+ word_part =
+ if part.is_a?(StringNode)
+ bounds(part.location)
+ on_tstring_content(part.content)
+ else
+ visit(part)
+ end
+
+ on_word_add(word, word_part)
+ end
+ end
+ )
+
+ previous = element
+ end
+
+ visit_words_sep(opening_loc, node.elements.last, node.closing_loc)
+
+ bounds(node.closing_loc)
+ on_tstring_end(node.closing)
+ else
+ bounds(node.opening_loc)
+ on_lbracket(opening)
+
+ elements = visit_arguments(node.elements) unless node.elements.empty?
+
+ bounds(node.closing_loc)
+ on_rbracket(node.closing)
+ end
+
+ bounds(node.location)
+ on_array(elements)
+ end
+
+ # Dispatch words_sep events that contains the whitespace between the elements
+ # of list literals.
+ private def visit_words_sep(opening_loc, previous, current)
+ start_offset = (previous.nil? ? opening_loc : previous.location).end_offset
+ end_offset = current.start_offset
+ length = end_offset - start_offset
+
+ if length > 0
+ whitespace = source.byteslice(start_offset, length)
+ current_offset = start_offset
+ whitespace.each_line do |part|
+ bounds(opening_loc.copy(start_offset: current_offset, length: part.bytesize))
+ on_words_sep(part)
+ current_offset += part.bytesize
+ end
+ end
+ end
+
+ # Visit a list of elements, like the elements of an array or arguments.
+ private def visit_arguments(elements)
+ bounds(elements.first.location)
+ elements.inject(on_args_new) do |args, element|
+ arg = visit(element)
+ bounds(element.location)
+
+ case element
+ when BlockArgumentNode
+ on_args_add_block(args, arg)
+ when SplatNode
+ on_args_add_star(args, arg)
+ else
+ on_args_add(args, arg)
+ end
+ end
+ end
+
+ # foo => [bar]
+ # ^^^^^
+ def visit_array_pattern_node(node)
+ constant = visit(node.constant)
+
+ if node.opening_loc
+ bounds(node.opening_loc)
+ node.opening == "[" ? on_lbracket("[") : on_lparen("(")
+ end
+
+ requireds = visit_all(node.requireds) if node.requireds.any?
+ rest =
+ if (rest_node = node.rest).is_a?(SplatNode)
+ bounds(rest_node.operator_loc)
+ on_op("*")
+
+ if rest_node.expression.nil?
+ bounds(rest_node.location)
+ on_var_field(nil)
+ else
+ visit(rest_node.expression)
+ end
+ end
+
+ posts = visit_all(node.posts) if node.posts.any?
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ node.closing == "]" ? on_rbracket("]") : on_rparen(")")
+ end
+ bounds(node.location)
+ on_aryptn(constant, requireds, rest, posts)
+ end
+
+ # foo(bar)
+ # ^^^
+ def visit_arguments_node(node)
+ arguments, _ = visit_call_node_arguments(node, nil, false)
+ arguments
+ end
+
+ # { a: 1 }
+ # ^^^^
+ def visit_assoc_node(node)
+ key = visit(node.key)
+
+ if node.operator_loc
+ bounds(node.operator_loc)
+ on_op("=>")
+ end
+
+ value = visit(node.value)
+
+ bounds(node.location)
+ on_assoc_new(key, value)
+ end
+
+ # def foo(**); bar(**); end
+ # ^^
+ #
+ # { **foo }
+ # ^^^^^
+ def visit_assoc_splat_node(node)
+ bounds(node.operator_loc)
+ on_op("**")
+
+ value = visit(node.value)
+
+ bounds(node.location)
+ on_assoc_splat(value)
+ end
+
+ # $+
+ # ^^
+ def visit_back_reference_read_node(node)
+ bounds(node.location)
+ on_backref(node.slice)
+ end
+
+ # begin end
+ # ^^^^^^^^^
+ def visit_begin_node(node)
+ if node.begin_keyword_loc
+ bounds(node.begin_keyword_loc)
+ on_kw("begin")
+ end
+
+ clauses = visit_begin_node_clauses(node.begin_keyword_loc, node, false)
+
+ if node.end_keyword_loc
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ on_begin(clauses)
+ end
+
+ # Visit the clauses of a begin node to form an on_bodystmt call.
+ private def visit_begin_node_clauses(location, node, allow_newline)
+ statements =
+ if node.statements.nil?
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ body = node.statements.body
+ body = [nil, *body] if void_stmt?(location, node.statements.body[0].location, allow_newline)
+
+ bounds(node.statements.location)
+ visit_statements_node_body(body)
+ end
+
+ rescue_clause = visit(node.rescue_clause)
+ else_clause =
+ unless (else_clause_node = node.else_clause).nil?
+ bounds(else_clause_node.else_keyword_loc)
+ on_kw("else")
+
+ else_statements =
+ if else_clause_node.statements.nil?
+ [nil]
+ else
+ body = else_clause_node.statements.body
+ body = [nil, *body] if void_stmt?(else_clause_node.else_keyword_loc, else_clause_node.statements.body[0].location, allow_newline)
+ body
+ end
+
+ bounds(else_clause_node.location)
+ visit_statements_node_body(else_statements)
+ end
+ ensure_clause = visit(node.ensure_clause)
+
+ bounds(node.location)
+ on_bodystmt(statements, rescue_clause, else_clause, ensure_clause)
+ end
+
+ # Visit the body of a structure that can have either a set of statements
+ # or statements wrapped in rescue/else/ensure.
+ private def visit_body_node(location, node, allow_newline = false)
+ case node
+ when nil
+ bounds(location)
+ on_bodystmt(visit_statements_node_body([nil]), nil, nil, nil)
+ when StatementsNode
+ body = [*node.body]
+ body = [nil, *body] if void_stmt?(location, body[0].location, allow_newline)
+ stmts = visit_statements_node_body(body)
+
+ bounds(node.body.first.location)
+ on_bodystmt(stmts, nil, nil, nil)
+ when BeginNode
+ visit_begin_node_clauses(location, node, allow_newline)
+ else
+ raise
+ end
+ end
+
+ # foo(&bar)
+ # ^^^^
+ def visit_block_argument_node(node)
+ bounds(node.operator_loc)
+ on_op("&")
+ visit(node.expression)
+ end
+
+ # foo { |; bar| }
+ # ^^^
+ def visit_block_local_variable_node(node)
+ bounds(node.location)
+ on_ident(node.name.to_s)
+ end
+
+ # Visit a BlockNode.
+ def visit_block_node(node)
+ braces = node.opening == "{"
+ bounds(node.opening_loc)
+ if braces
+ on_lbrace("{")
+ else
+ on_kw("do")
+ end
+
+ parameters = visit(node.parameters)
+
+ body =
+ case node.body
+ when nil
+ bounds(node.location)
+ stmts = on_stmts_add(on_stmts_new, on_void_stmt)
+
+ bounds(node.location)
+ braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
+ when StatementsNode
+ stmts = node.body.body
+ stmts = [nil, *stmts] if void_stmt?(node.parameters&.location || node.opening_loc, node.body.location, false)
+ stmts = visit_statements_node_body(stmts)
+
+ bounds(node.body.location)
+ braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
+ when BeginNode
+ visit_body_node(node.parameters&.location || node.opening_loc, node.body)
+ else
+ raise
+ end
+
+ if braces
+ bounds(node.closing_loc)
+ on_rbrace("}")
+ else
+ bounds(node.closing_loc)
+ on_kw("end")
+ end
+
+ if braces
+ bounds(node.location)
+ on_brace_block(parameters, body)
+ else
+ bounds(node.location)
+ on_do_block(parameters, body)
+ end
+ end
+
+ # def foo(&bar); end
+ # ^^^^
+ def visit_block_parameter_node(node)
+ bounds(node.operator_loc)
+ on_op("&")
+
+ if node.name_loc.nil?
+ bounds(node.location)
+ on_blockarg(nil)
+ else
+ bounds(node.name_loc)
+ name = on_ident(node.name.to_s)
+
+ bounds(node.location)
+ on_blockarg(name)
+ end
+ end
+
+ # A block's parameters.
+ def visit_block_parameters_node(node)
+ bounds(node.opening_loc)
+ on_op("|")
+
+ parameters =
+ if node.parameters.nil?
+ on_params(nil, nil, nil, nil, nil, nil, nil)
+ else
+ visit(node.parameters)
+ end
+
+ locals =
+ if node.locals.any?
+ visit_all(node.locals)
+ else
+ false
+ end
+
+ bounds(node.closing_loc)
+ on_op("|")
+
+ bounds(node.location)
+ on_block_var(parameters, locals)
+ end
+
+ # break
+ # ^^^^^
+ #
+ # break foo
+ # ^^^^^^^^^
+ def visit_break_node(node)
+ bounds(node.keyword_loc)
+ on_kw("break")
+
+ if node.arguments.nil?
+ bounds(node.location)
+ on_break(on_args_new)
+ else
+ arguments = visit(node.arguments)
+
+ bounds(node.location)
+ on_break(arguments)
+ end
+ end
+
+ # foo
+ # ^^^
+ #
+ # foo.bar
+ # ^^^^^^^
+ #
+ # foo.bar() {}
+ # ^^^^^^^^^^^^
+ def visit_call_node(node)
+ if node.call_operator_loc.nil?
+ case node.name
+ when :[]
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ arguments, block_node = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc))
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+
+ block = visit(block_node)
+
+ bounds(node.location)
+ call = on_aref(receiver, arguments)
+
+ if block_node
+ bounds(node.location)
+ on_method_add_block(call, block)
+ else
+ call
+ end
+ when :[]=
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ *arguments, last_argument = node.arguments.arguments
+ arguments << node.block if !node.block.nil?
+
+ arguments =
+ if arguments.any?
+ args = visit_arguments(arguments)
+
+ if !node.block.nil?
+ args
+ else
+ bounds(arguments.first.location)
+ on_args_add_block(args, false)
+ end
+ end
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+ bounds(node.equal_loc)
+ on_op("=")
+
+ bounds(node.location)
+ call = on_aref_field(receiver, arguments)
+ value = visit_write_value(last_argument)
+
+ bounds(last_argument.location)
+ on_assign(call, value)
+ when :-@, :+@, :~
+ bounds(node.message_loc)
+ on_op(node.message)
+
+ receiver = visit(node.receiver)
+ bounds(node.location)
+ on_unary(node.name, receiver)
+ when :!
+ bounds(node.message_loc)
+ if node.message == "not"
+ on_kw("not")
+
+ if node.opening_loc
+ bounds(node.opening_loc)
+ on_lparen("(")
+ end
+
+ receiver =
+ if node.receiver.is_a?(ParenthesesNode) && node.receiver.body.nil?
+ # The parens in `not()` just emit parens and nothing else.
+ bounds(node.receiver.opening_loc)
+ on_lparen("(")
+ bounds(node.receiver.closing_loc)
+ on_rparen(")")
+ nil
+ else
+ visit(node.receiver)
+ end
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ on_rparen(")")
+ end
+ bounds(node.location)
+ on_unary(:not, receiver)
+ else
+ on_op("!")
+
+ receiver = visit(node.receiver)
+
+ bounds(node.location)
+ on_unary(:!, receiver)
+ end
+ when BINARY_OPERATORS
+ receiver = visit(node.receiver)
+
+ bounds(node.message_loc)
+ on_op(node.message)
+
+ value = visit(node.arguments.arguments.first)
+
+ bounds(node.location)
+ on_binary(receiver, node.name, value)
+ else
+ bounds(node.message_loc)
+ message = visit_token(node.message, false)
+
+ if node.variable_call?
+ on_vcall(message)
+ else
+ if node.opening_loc
+ bounds(node.opening_loc)
+ on_lparen("(")
+ end
+
+ arguments, block_node = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc || node.location))
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ on_rparen(")")
+ end
+
+ block = visit(block_node)
+ call =
+ if node.opening_loc.nil? && get_arguments_and_block(node.arguments, node.block).first.any?
+ bounds(node.location)
+ on_command(message, arguments)
+ elsif !node.opening_loc.nil?
+ bounds(node.location)
+ on_method_add_arg(on_fcall(message), on_arg_paren(arguments))
+ else
+ bounds(node.location)
+ on_method_add_arg(on_fcall(message), on_args_new)
+ end
+
+ if block_node
+ bounds(node.block.location)
+ on_method_add_block(call, block)
+ else
+ call
+ end
+ end
+ end
+ else
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ call_operator = visit_call_operator(node.call_operator)
+
+ message =
+ if node.message_loc.nil?
+ :call
+ else
+ bounds(node.message_loc)
+ visit_token(node.message, false)
+ end
+
+ if node.equal_loc
+ bounds(node.equal_loc)
+ on_op("=")
+ end
+
+ if node.name.end_with?("=") && !node.message.end_with?("=") && !node.arguments.nil? && node.block.nil?
+ value = visit_write_value(node.arguments.arguments.first)
+
+ bounds(node.location)
+ on_assign(on_field(receiver, call_operator, message), value)
+ else
+ if node.opening_loc
+ bounds(node.opening_loc)
+ on_lparen("(")
+ end
+
+ arguments, block_node = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc || node.location))
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ on_rparen(")")
+ end
+
+ block = visit(block_node)
+ call =
+ if node.opening_loc.nil?
+ bounds(node.location)
+
+ if node.arguments.nil? && !node.block.is_a?(BlockArgumentNode)
+ on_call(receiver, call_operator, message)
+ else
+ on_command_call(receiver, call_operator, message, arguments)
+ end
+ else
+ bounds(node.opening_loc)
+ arguments = on_arg_paren(arguments)
+
+ bounds(node.location)
+ on_method_add_arg(on_call(receiver, call_operator, message), arguments)
+ end
+
+ if block_node
+ bounds(node.block.location)
+ on_method_add_block(call, block)
+ else
+ call
+ end
+ end
+ end
+ end
+
+ # Extract the arguments and block Ripper-style, which means if the block
+ # is like `&b` then it's moved to arguments.
+ private def get_arguments_and_block(arguments_node, block_node)
+ arguments = arguments_node&.arguments || []
+ block = block_node
+
+ if block.is_a?(BlockArgumentNode)
+ arguments += [block]
+ block = nil
+ end
+
+ [arguments, block]
+ end
+
+ # Visit the arguments and block of a call node and return the arguments
+ # and block as they should be used.
+ private def visit_call_node_arguments(arguments_node, block_node, trailing_comma)
+ arguments, block = get_arguments_and_block(arguments_node, block_node)
+
+ [
+ if arguments.length == 1 && arguments.first.is_a?(ForwardingArgumentsNode)
+ visit(arguments.first)
+ elsif arguments.any?
+ args = visit_arguments(arguments)
+
+ if block_node.is_a?(BlockArgumentNode) || arguments.last.is_a?(ForwardingArgumentsNode) || command?(arguments.last) || trailing_comma
+ args
+ else
+ bounds(arguments.first.location)
+ on_args_add_block(args, false)
+ end
+ end,
+ block,
+ ]
+ end
+
+ # Returns true if the given node is a command node.
+ private def command?(node)
+ node.is_a?(CallNode) &&
+ node.opening_loc.nil? &&
+ (!node.arguments.nil? || node.block.is_a?(BlockArgumentNode)) &&
+ !BINARY_OPERATORS.include?(node.name)
+ end
+
+ # foo.bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_operator_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ call_operator = visit_call_operator(node.call_operator)
+
+ bounds(node.message_loc)
+ message = visit_token(node.message)
+
+ bounds(node.location)
+ target = on_field(receiver, call_operator, message)
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo.bar &&= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_and_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ call_operator = visit_call_operator(node.call_operator)
+
+ bounds(node.message_loc)
+ message = visit_token(node.message)
+
+ bounds(node.location)
+ target = on_field(receiver, call_operator, message)
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo.bar ||= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_or_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ call_operator = visit_call_operator(node.call_operator)
+
+ bounds(node.message_loc)
+ message = visit_token(node.message)
+
+ bounds(node.location)
+ target = on_field(receiver, call_operator, message)
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo.bar, = 1
+ # ^^^^^^^
+ def visit_call_target_node(node)
+ if node.call_operator == "::"
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ on_op("::")
+
+ bounds(node.message_loc)
+ message = visit_token(node.message)
+
+ bounds(node.location)
+ on_const_path_field(receiver, message)
+ else
+ receiver = visit(node.receiver)
+
+ bounds(node.call_operator_loc)
+ call_operator = visit_call_operator(node.call_operator)
+
+ bounds(node.message_loc)
+ message = visit_token(node.message)
+
+ bounds(node.location)
+ on_field(receiver, call_operator, message)
+ end
+ end
+
+ # foo => bar => baz
+ # ^^^^^^^^^^
+ def visit_capture_pattern_node(node)
+ value = visit(node.value)
+
+ bounds(node.operator_loc)
+ on_op("=>")
+
+ target = visit(node.target)
+
+ bounds(node.location)
+ on_binary(value, :"=>", target)
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_node(node)
+ bounds(node.case_keyword_loc)
+ on_kw("case")
+
+ predicate = visit(node.predicate)
+ visited_conditions = node.conditions.map { |condition| visit(condition) }
+ visited_else_clause = visit(node.else_clause)
+
+ if !node.else_clause
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ clauses =
+ visited_conditions.reverse_each.inject(visited_else_clause) do |current, condition|
+ on_when(*condition, current)
+ end
+
+ bounds(node.location)
+ on_case(predicate, clauses)
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_match_node(node)
+ bounds(node.case_keyword_loc)
+ on_kw("case")
+
+ predicate = visit(node.predicate)
+ visited_conditions = node.conditions.map do | condition|
+ visit(condition)
+ end
+ visited_else_clause = visit(node.else_clause)
+
+ if !node.else_clause
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ clauses =
+ visited_conditions.reverse_each.inject(visited_else_clause) do |current, condition|
+ on_in(*condition, current)
+ end
+
+ bounds(node.location)
+ on_case(predicate, clauses)
+ end
+
+ # class Foo; end
+ # ^^^^^^^^^^^^^^
+ def visit_class_node(node)
+ bounds(node.class_keyword_loc)
+ on_kw("class")
+
+ constant_path =
+ if node.constant_path.is_a?(ConstantReadNode)
+ bounds(node.constant_path.location)
+ on_const_ref(on_const(node.constant_path.name.to_s))
+ else
+ visit(node.constant_path)
+ end
+
+ if node.inheritance_operator_loc
+ bounds(node.inheritance_operator_loc)
+ on_op("<")
+ end
+
+ superclass = visit(node.superclass)
+ bodystmt = visit_body_node(node.superclass&.location || node.constant_path.location, node.body, node.superclass.nil?)
+
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+
+ bounds(node.location)
+ on_class(constant_path, superclass, bodystmt)
+ end
+
+ # @@foo
+ # ^^^^^
+ def visit_class_variable_read_node(node)
+ bounds(node.location)
+ on_var_ref(on_cvar(node.slice))
+ end
+
+ # @@foo = 1
+ # ^^^^^^^^^
+ def visit_class_variable_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_cvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # @@foo += bar
+ # ^^^^^^^^^^^^
+ def visit_class_variable_operator_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_cvar(node.name.to_s))
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @@foo &&= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_and_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_cvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @@foo ||= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_or_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_cvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @@foo, = bar
+ # ^^^^^
+ def visit_class_variable_target_node(node)
+ bounds(node.location)
+ on_var_field(on_cvar(node.name.to_s))
+ end
+
+ # Foo
+ # ^^^
+ def visit_constant_read_node(node)
+ bounds(node.location)
+ on_var_ref(on_const(node.name.to_s))
+ end
+
+ # Foo = 1
+ # ^^^^^^^
+ def visit_constant_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_const(node.name.to_s))
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # Foo += bar
+ # ^^^^^^^^^^^
+ def visit_constant_operator_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_const(node.name.to_s))
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_and_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_const(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_or_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_const(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo, = bar
+ # ^^^
+ def visit_constant_target_node(node)
+ bounds(node.location)
+ on_var_field(on_const(node.name.to_s))
+ end
+
+ # Foo::Bar
+ # ^^^^^^^^
+ def visit_constant_path_node(node)
+ if node.parent.nil?
+ if node.delimiter_loc
+ bounds(node.delimiter_loc)
+ on_op("::")
+ end
+
+ bounds(node.name_loc)
+ child = on_const(node.name.to_s)
+
+ bounds(node.location)
+ on_top_const_ref(child)
+ else
+ parent = visit(node.parent)
+
+ bounds(node.delimiter_loc)
+ on_op("::")
+
+ bounds(node.name_loc)
+ child = on_const(node.name.to_s)
+
+ bounds(node.location)
+ on_const_path_ref(parent, child)
+ end
+ end
+
+ # Foo::Bar = 1
+ # ^^^^^^^^^^^^
+ def visit_constant_path_write_node(node)
+ target = visit_constant_path_write_node_target(node.target)
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # Visit a constant path that is part of a write node.
+ private def visit_constant_path_write_node_target(node)
+ if node.parent.nil?
+ if node.delimiter_loc
+ bounds(node.delimiter_loc)
+ on_op("::")
+ end
+
+ bounds(node.name_loc)
+ child = on_const(node.name.to_s)
+
+ bounds(node.location)
+ on_top_const_field(child)
+ else
+ parent = visit(node.parent)
+
+ bounds(node.delimiter_loc)
+ on_op("::")
+
+ bounds(node.name_loc)
+ child = on_const(node.name.to_s)
+
+ bounds(node.location)
+ on_const_path_field(parent, child)
+ end
+ end
+
+ # Foo::Bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_constant_path_operator_write_node(node)
+ target = visit_constant_path_write_node_target(node.target)
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo::Bar &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_and_write_node(node)
+ target = visit_constant_path_write_node_target(node.target)
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo::Bar ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_or_write_node(node)
+ target = visit_constant_path_write_node_target(node.target)
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # Foo::Bar, = baz
+ # ^^^^^^^^
+ def visit_constant_path_target_node(node)
+ visit_constant_path_write_node_target(node)
+ end
+
+ # def foo; end
+ # ^^^^^^^^^^^^
+ #
+ # def self.foo; end
+ # ^^^^^^^^^^^^^^^^^
+ def visit_def_node(node)
+ bounds(node.def_keyword_loc)
+ on_kw("def")
+
+ receiver = visit(node.receiver)
+ operator =
+ if !node.operator_loc.nil?
+ bounds(node.operator_loc)
+ node.operator == "." ? on_period(".") : on_op("::")
+ end
+
+ bounds(node.name_loc)
+ name = visit_token(node.name_loc.slice)
+
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ parameters =
+ if node.parameters.nil?
+ bounds(node.location)
+ on_params(nil, nil, nil, nil, nil, nil, nil)
+ else
+ visit(node.parameters)
+ end
+
+ if !node.lparen_loc.nil?
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ bounds(node.lparen_loc)
+ parameters = on_paren(parameters)
+ end
+
+ if node.equal_loc
+ bounds(node.equal_loc)
+ on_op("=")
+ end
+
+ bodystmt =
+ if node.equal_loc.nil?
+ visit_body_node(node.rparen_loc || node.end_keyword_loc, node.body)
+ else
+ body = visit(node.body.body.first)
+
+ bounds(node.body.location)
+ on_bodystmt(body, nil, nil, nil)
+ end
+
+ if node.end_keyword_loc
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ if receiver
+ on_defs(receiver, operator, name, parameters, bodystmt)
+ else
+ on_def(name, parameters, bodystmt)
+ end
+ end
+
+ # defined? a
+ # ^^^^^^^^^^
+ #
+ # defined?(a)
+ # ^^^^^^^^^^^
+ def visit_defined_node(node)
+ bounds(node.keyword_loc)
+ on_kw("defined?")
+
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ expression = visit(node.value)
+
+ if node.rparen_loc
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ end
+
+ # Very weird circumstances here where something like:
+ #
+ # defined?
+ # (1)
+ #
+ # gets parsed in Ruby as having only the `1` expression but in Ripper it
+ # gets parsed as having a parentheses node. In this case we need to
+ # synthesize that node to match Ripper's behavior.
+ if node.lparen_loc && node.keyword_loc.join(node.lparen_loc).slice.include?("\n")
+ bounds(node.lparen_loc.join(node.rparen_loc))
+ expression = on_paren(on_stmts_add(on_stmts_new, expression))
+ end
+
+ bounds(node.location)
+ on_defined(expression)
+ end
+
+ # if foo then bar else baz end
+ # ^^^^^^^^^^^^
+ def visit_else_node(node)
+ bounds(node.else_keyword_loc)
+ on_kw("else")
+
+ statements =
+ if node.statements.nil?
+ [nil]
+ else
+ body = node.statements.body
+ body = [nil, *body] if void_stmt?(node.else_keyword_loc, node.statements.body[0].location, false)
+ body
+ end
+
+ else_statements = visit_statements_node_body(statements)
+
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ bounds(node.location)
+ on_else(else_statements)
+ end
+
+ # "foo #{bar}"
+ # ^^^^^^
+ def visit_embedded_statements_node(node)
+ bounds(node.opening_loc)
+ on_embexpr_beg(node.opening)
+
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ bounds(node.closing_loc)
+ on_embexpr_end(node.closing)
+
+ bounds(node.location)
+ on_string_embexpr(statements)
+ end
+
+ # "foo #@bar"
+ # ^^^^^
+ def visit_embedded_variable_node(node)
+ bounds(node.operator_loc)
+ on_embvar(node.operator)
+
+ variable = visit(node.variable)
+
+ bounds(node.location)
+ on_string_dvar(variable)
+ end
+
+ # Visit an EnsureNode node.
+ def visit_ensure_node(node)
+ bounds(node.ensure_keyword_loc)
+ on_kw("ensure")
+
+ statements =
+ if node.statements.nil?
+ [nil]
+ else
+ body = node.statements.body
+ body = [nil, *body] if void_stmt?(node.ensure_keyword_loc, body[0].location, false)
+ body
+ end
+
+ statements = visit_statements_node_body(statements)
+
+ bounds(node.location)
+ on_ensure(statements)
+ end
+
+ # false
+ # ^^^^^
+ def visit_false_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("false"))
+ end
+
+ # foo => [*, bar, *]
+ # ^^^^^^^^^^^
+ def visit_find_pattern_node(node)
+ constant = visit(node.constant)
+
+ if node.opening_loc
+ bounds(node.opening_loc)
+ node.opening == "[" ? on_lbracket("[") : on_lparen("(")
+ end
+ bounds(node.left.operator_loc)
+ on_op("*")
+
+ left =
+ if node.left.expression.nil?
+ bounds(node.left.location)
+ on_var_field(nil)
+ else
+ visit(node.left.expression)
+ end
+
+ requireds = visit_all(node.requireds) if node.requireds.any?
+
+ bounds(node.right.operator_loc)
+ on_op("*")
+
+ right =
+ if node.right.expression.nil?
+ bounds(node.right.location)
+ on_var_field(nil)
+ else
+ visit(node.right.expression)
+ end
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ node.closing == "]" ? on_rbracket("]") : on_rparen(")")
+ end
+ bounds(node.location)
+ on_fndptn(constant, left, requireds, right)
+ end
+
+ # if foo .. bar; end
+ # ^^^^^^^^^^
+ def visit_flip_flop_node(node)
+ left = visit(node.left)
+
+ bounds(node.operator_loc)
+ on_op(node.operator)
+
+ right = visit(node.right)
+
+ bounds(node.location)
+ if node.exclude_end?
+ on_dot3(left, right)
+ else
+ on_dot2(left, right)
+ end
+ end
+
+ # 1.0
+ # ^^^
+ def visit_float_node(node)
+ visit_number_node(node) { |text| on_float(text) }
+ end
+
+ # for foo in bar do end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_for_node(node)
+ bounds(node.for_keyword_loc)
+ on_kw("for")
+
+ index = visit(node.index)
+ bounds(node.in_keyword_loc)
+ on_kw("in")
+
+ collection = visit(node.collection)
+ if node.do_keyword_loc
+ bounds(node.do_keyword_loc)
+ on_kw("do")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+
+ bounds(node.location)
+ on_for(index, collection, statements)
+ end
+
+ # def foo(...); bar(...); end
+ # ^^^
+ def visit_forwarding_arguments_node(node)
+ bounds(node.location)
+ on_op("...")
+ on_args_forward
+ end
+
+ # def foo(...); end
+ # ^^^
+ def visit_forwarding_parameter_node(node)
+ bounds(node.location)
+ on_op("...")
+ on_args_forward
+ end
+
+ # super
+ # ^^^^^
+ #
+ # super {}
+ # ^^^^^^^^
+ def visit_forwarding_super_node(node)
+ bounds(node.keyword_loc)
+ on_kw("super")
+
+ if node.block.nil?
+ bounds(node.location)
+ on_zsuper
+ else
+ block = visit(node.block)
+
+ bounds(node.location)
+ on_method_add_block(on_zsuper, block)
+ end
+ end
+
+ # $foo
+ # ^^^^
+ def visit_global_variable_read_node(node)
+ bounds(node.location)
+ on_var_ref(on_gvar(node.name.to_s))
+ end
+
+ # $foo = 1
+ # ^^^^^^^^
+ def visit_global_variable_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_gvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # $foo += bar
+ # ^^^^^^^^^^^
+ def visit_global_variable_operator_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_gvar(node.name.to_s))
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # $foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_and_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_gvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # $foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_or_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_gvar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # $foo, = bar
+ # ^^^^
+ def visit_global_variable_target_node(node)
+ bounds(node.location)
+ on_var_field(on_gvar(node.name.to_s))
+ end
+
+ # {}
+ # ^^
+ def visit_hash_node(node)
+ bounds(node.opening_loc)
+ on_lbrace("{")
+
+ elements =
+ if node.elements.any?
+ args = visit_all(node.elements)
+
+ bounds(node.elements.first.location)
+ on_assoclist_from_args(args)
+ end
+
+ bounds(node.closing_loc)
+ on_rbrace("}")
+ bounds(node.location)
+ on_hash(elements)
+ end
+
+ # foo => {}
+ # ^^
+ def visit_hash_pattern_node(node)
+ constant = visit(node.constant)
+
+ if node.constant
+ bounds(node.opening_loc)
+ node.opening == "[" ? on_lbracket("[") : on_lparen("(")
+ elsif node.opening_loc
+ bounds(node.opening_loc)
+ on_lbrace("{")
+ end
+
+ elements =
+ if node.elements.any? || !node.rest.nil?
+ node.elements.map do |element|
+ [
+ if (key = element.key).opening_loc.nil?
+ visit(key)
+ else
+ bounds(key.value_loc)
+ if (value = key.value).empty?
+ on_string_content
+ else
+ on_string_add(on_string_content, on_tstring_content(value))
+ end
+ end,
+ visit(element.value)
+ ]
+ end
+ end
+
+ rest =
+ case node.rest
+ when AssocSplatNode
+ bounds(node.rest.operator_loc)
+ on_op("**")
+ visit(node.rest.value)
+ when NoKeywordsParameterNode
+ bounds(node.rest.location)
+ on_var_field(visit(node.rest))
+ end
+
+ if node.constant
+ bounds(node.closing_loc)
+ node.closing == "]" ? on_rbracket("]") : on_rparen(")")
+ elsif node.closing_loc
+ bounds(node.closing_loc)
+ on_rbrace("}")
+ end
+ bounds(node.location)
+ on_hshptn(constant, elements, rest)
+ end
+
+ # if foo then bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar if foo
+ # ^^^^^^^^^^
+ #
+ # foo ? bar : baz
+ # ^^^^^^^^^^^^^^^
+ def visit_if_node(node)
+ if node.then_keyword == "?"
+ predicate = visit(node.predicate)
+
+ bounds(node.then_keyword_loc)
+ on_op("?")
+
+ truthy = visit(node.statements.body.first)
+
+ bounds(node.subsequent.else_keyword_loc)
+ on_op(":")
+
+ falsy = visit(node.subsequent.statements.body.first)
+
+ bounds(node.location)
+ on_ifop(predicate, truthy, falsy)
+ elsif node.statements.nil? || (node.predicate.location.start_offset < node.statements.location.start_offset)
+ bounds(node.if_keyword_loc)
+ on_kw(node.if_keyword)
+ predicate = visit(node.predicate)
+ if node.then_keyword_loc && node.then_keyword != "?"
+ bounds(node.then_keyword_loc)
+ on_kw("then")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+ subsequent = visit(node.subsequent)
+
+ if node.end_keyword_loc && !node.subsequent
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ if node.if_keyword == "if"
+ on_if(predicate, statements, subsequent)
+ else
+ on_elsif(predicate, statements, subsequent)
+ end
+ else
+ statements = visit(node.statements.body.first)
+ bounds(node.if_keyword_loc)
+ on_kw(node.if_keyword)
+ predicate = visit(node.predicate)
+
+ bounds(node.location)
+ on_if_mod(predicate, statements)
+ end
+ end
+
+ # 1i
+ # ^^
+ def visit_imaginary_node(node)
+ visit_number_node(node) { |text| on_imaginary(text) }
+ end
+
+ # { foo: }
+ # ^^^^
+ def visit_implicit_node(node)
+ end
+
+ # foo { |bar,| }
+ # ^
+ def visit_implicit_rest_node(node)
+ bounds(node.location)
+ on_excessed_comma
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_in_node(node)
+ # This is a special case where we're not going to call on_in directly
+ # because we don't have access to the subsequent. Instead, we'll return
+ # the component parts and let the parent node handle it.
+ bounds(node.in_loc)
+ on_kw("in")
+
+ pattern = visit_pattern_node(node.pattern)
+ if node.then_loc
+ bounds(node.then_loc)
+ on_kw("then")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ [pattern, statements]
+ end
+
+ # foo[bar] += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_index_operator_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ arguments, _ = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc))
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+
+ bounds(node.location)
+ target = on_aref_field(receiver, arguments)
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo[bar] &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_and_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ arguments, _ = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc))
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+
+ bounds(node.location)
+ target = on_aref_field(receiver, arguments)
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo[bar] ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_or_write_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ arguments, _ = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc))
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+
+ bounds(node.location)
+ target = on_aref_field(receiver, arguments)
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo[bar], = 1
+ # ^^^^^^^^
+ def visit_index_target_node(node)
+ receiver = visit(node.receiver)
+
+ bounds(node.opening_loc)
+ on_lbracket("[")
+
+ arguments, _ = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.closing_loc))
+
+ bounds(node.closing_loc)
+ on_rbracket("]")
+
+ bounds(node.location)
+ on_aref_field(receiver, arguments)
+ end
+
+ # @foo
+ # ^^^^
+ def visit_instance_variable_read_node(node)
+ bounds(node.location)
+ on_var_ref(on_ivar(node.name.to_s))
+ end
+
+ # @foo = 1
+ # ^^^^^^^^
+ def visit_instance_variable_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ivar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # @foo += bar
+ # ^^^^^^^^^^^
+ def visit_instance_variable_operator_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ivar(node.name.to_s))
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_and_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ivar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_or_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ivar(node.name.to_s))
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # @foo, = bar
+ # ^^^^
+ def visit_instance_variable_target_node(node)
+ bounds(node.location)
+ on_var_field(on_ivar(node.name.to_s))
+ end
+
+ # 1
+ # ^
+ def visit_integer_node(node)
+ visit_number_node(node) { |text| on_int(text) }
+ end
+
+ # if /foo #{bar}/ then end
+ # ^^^^^^^^^^^^
+ def visit_interpolated_match_last_line_node(node)
+ bounds(node.opening_loc)
+ on_regexp_beg(node.opening)
+
+ bounds(node.parts.first.location)
+ parts =
+ node.parts.inject(on_regexp_new) do |content, part|
+ on_regexp_add(content, visit_string_content(part))
+ end
+
+ bounds(node.closing_loc)
+ closing = on_regexp_end(node.closing)
+
+ bounds(node.location)
+ on_regexp_literal(parts, closing)
+ end
+
+ # /foo #{bar}/
+ # ^^^^^^^^^^^^
+ def visit_interpolated_regular_expression_node(node)
+ bounds(node.opening_loc)
+ on_regexp_beg(node.opening)
+
+ bounds(node.parts.first.location)
+ parts =
+ node.parts.inject(on_regexp_new) do |content, part|
+ on_regexp_add(content, visit_string_content(part))
+ end
+
+ bounds(node.closing_loc)
+ closing = on_regexp_end(node.closing)
+
+ bounds(node.location)
+ on_regexp_literal(parts, closing)
+ end
+
+ # "foo #{bar}"
+ # ^^^^^^^^^^^^
+ def visit_interpolated_string_node(node)
+ with_string_bounds(node) do
+ if node.opening&.start_with?("<<~")
+ heredoc = visit_heredoc_string_node(node)
+
+ bounds(node.location)
+ on_string_literal(heredoc)
+ elsif !node.heredoc? && node.parts.length > 1 && node.parts.any? { |part| (part.is_a?(StringNode) || part.is_a?(InterpolatedStringNode)) && !part.opening_loc.nil? }
+ first, *rest = node.parts
+ rest.inject(visit(first)) do |content, part|
+ concat = visit(part)
+
+ bounds(part.location)
+ on_string_concat(content, concat)
+ end
+ else
+ bounds(node.parts.first.location)
+ parts =
+ node.parts.inject(on_string_content) do |content, part|
+ on_string_add(content, visit_string_content(part))
+ end
+
+ bounds(node.location)
+ on_string_literal(parts)
+ end
+ end
+ end
+
+ # :"foo #{bar}"
+ # ^^^^^^^^^^^^^
+ def visit_interpolated_symbol_node(node)
+ with_string_bounds(node) do
+ bounds(node.parts.first.location)
+ parts =
+ node.parts.inject(on_string_content) do |content, part|
+ on_string_add(content, visit_string_content(part))
+ end
+
+ bounds(node.location)
+ on_dyna_symbol(parts)
+ end
+ end
+
+ # `foo #{bar}`
+ # ^^^^^^^^^^^^
+ def visit_interpolated_x_string_node(node)
+ with_string_bounds(node) do
+ if node.opening.start_with?("<<~")
+ heredoc = visit_heredoc_x_string_node(node)
+
+ bounds(node.location)
+ on_xstring_literal(heredoc)
+ else
+ bounds(node.parts.first.location)
+ parts =
+ node.parts.inject(on_xstring_new) do |content, part|
+ on_xstring_add(content, visit_string_content(part))
+ end
+
+ bounds(node.location)
+ on_xstring_literal(parts)
+ end
+ end
+ end
+
+ # Visit an individual part of a string-like node.
+ private def visit_string_content(part)
+ if part.is_a?(StringNode)
+ bounds(part.content_loc)
+ on_tstring_content(part.content)
+ else
+ visit(part)
+ end
+ end
+
+ # -> { it }
+ # ^^
+ def visit_it_local_variable_read_node(node)
+ bounds(node.location)
+ on_vcall(on_ident(node.slice))
+ end
+
+ # -> { it }
+ # ^^^^^^^^^
+ def visit_it_parameters_node(node)
+ end
+
+ # foo(bar: baz)
+ # ^^^^^^^^
+ def visit_keyword_hash_node(node)
+ elements = visit_all(node.elements)
+
+ bounds(node.location)
+ on_bare_assoc_hash(elements)
+ end
+
+ # def foo(**bar); end
+ # ^^^^^
+ #
+ # def foo(**); end
+ # ^^
+ def visit_keyword_rest_parameter_node(node)
+ bounds(node.operator_loc)
+ on_op("**")
+
+ if node.name_loc.nil?
+ bounds(node.location)
+ on_kwrest_param(nil)
+ else
+ bounds(node.name_loc)
+ name = on_ident(node.name.to_s)
+
+ bounds(node.location)
+ on_kwrest_param(name)
+ end
+ end
+
+ # -> {}
+ def visit_lambda_node(node)
+ bounds(node.operator_loc)
+ on_tlambda(node.operator)
+
+ parameters =
+ if node.parameters.is_a?(BlockParametersNode)
+ if node.parameters.opening_loc
+ bounds(node.parameters.opening_loc)
+ on_lparen("(")
+ end
+
+ # Ripper does not track block-locals within lambdas, so we skip
+ # directly to the parameters here.
+ params =
+ if node.parameters.parameters.nil?
+ bounds(node.location)
+ on_params(nil, nil, nil, nil, nil, nil, nil)
+ else
+ visit(node.parameters.parameters)
+ end
+
+ visit_all(node.parameters.locals)
+
+ if node.parameters.closing_loc
+ bounds(node.parameters.closing_loc)
+ on_rparen(")")
+ end
+
+ if node.parameters.opening_loc.nil?
+ params
+ else
+ bounds(node.parameters.opening_loc)
+ on_paren(params)
+ end
+ else
+ bounds(node.location)
+ on_params(nil, nil, nil, nil, nil, nil, nil)
+ end
+
+ braces = node.opening == "{"
+ bounds(node.opening_loc)
+ if braces
+ on_tlambeg(node.opening)
+ else
+ on_kw("do")
+ end
+
+ body =
+ case node.body
+ when nil
+ bounds(node.location)
+ stmts = on_stmts_add(on_stmts_new, on_void_stmt)
+
+ bounds(node.location)
+ braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
+ when StatementsNode
+ stmts = node.body.body
+ stmts = [nil, *stmts] if void_stmt?(node.parameters&.location || node.opening_loc, node.body.location, false)
+ stmts = visit_statements_node_body(stmts)
+
+ bounds(node.body.location)
+ braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
+ when BeginNode
+ visit_body_node(node.opening_loc, node.body)
+ else
+ raise
+ end
+
+ bounds(node.closing_loc)
+ if braces
+ on_rbrace("}")
+ else
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ on_lambda(parameters, body)
+ end
+
+ # foo
+ # ^^^
+ def visit_local_variable_read_node(node)
+ bounds(node.location)
+ on_var_ref(on_ident(node.slice))
+ end
+
+ # foo = 1
+ # ^^^^^^^
+ def visit_local_variable_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ident(node.name_loc.slice))
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_assign(target, value)
+ end
+
+ # foo += bar
+ # ^^^^^^^^^^
+ def visit_local_variable_operator_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ident(node.name_loc.slice))
+
+ bounds(node.binary_operator_loc)
+ operator = on_op("#{node.binary_operator}=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo &&= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_and_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ident(node.name_loc.slice))
+
+ bounds(node.operator_loc)
+ operator = on_op("&&=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo ||= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_or_write_node(node)
+ bounds(node.name_loc)
+ target = on_var_field(on_ident(node.name_loc.slice))
+
+ bounds(node.operator_loc)
+ operator = on_op("||=")
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_opassign(target, operator, value)
+ end
+
+ # foo, = bar
+ # ^^^
+ def visit_local_variable_target_node(node)
+ bounds(node.location)
+ on_var_field(on_ident(node.name.to_s))
+ end
+
+ # if /foo/ then end
+ # ^^^^^
+ def visit_match_last_line_node(node)
+ bounds(node.opening_loc)
+ on_regexp_beg(node.opening)
+
+ bounds(node.content_loc)
+ tstring_content = on_tstring_content(node.content)
+
+ bounds(node.closing_loc)
+ closing = on_regexp_end(node.closing)
+
+ on_regexp_literal(on_regexp_add(on_regexp_new, tstring_content), closing)
+ end
+
+ # foo in bar
+ # ^^^^^^^^^^
+ def visit_match_predicate_node(node)
+ value = visit(node.value)
+ bounds(node.operator_loc)
+ on_kw("in")
+ pattern = on_in(visit_pattern_node(node.pattern), nil, nil)
+
+ on_case(value, pattern)
+ end
+
+ # foo => bar
+ # ^^^^^^^^^^
+ def visit_match_required_node(node)
+ value = visit(node.value)
+
+ bounds(node.operator_loc)
+ on_op("=>")
+
+ pattern = on_in(visit_pattern_node(node.pattern), nil, nil)
+
+ on_case(value, pattern)
+ end
+
+ # /(?<foo>foo)/ =~ bar
+ # ^^^^^^^^^^^^^^^^^^^^
+ def visit_match_write_node(node)
+ visit(node.call)
+ end
+
+ # A node that is missing from the syntax tree. This is only used in the
+ # case of a syntax error.
+ def visit_error_recovery_node(node)
+ raise "Cannot visit error recovery nodes directly."
+ end
+
+ # module Foo; end
+ # ^^^^^^^^^^^^^^^
+ def visit_module_node(node)
+ bounds(node.module_keyword_loc)
+ on_kw("module")
+
+ constant_path =
+ if node.constant_path.is_a?(ConstantReadNode)
+ bounds(node.constant_path.location)
+ on_const_ref(on_const(node.constant_path.name.to_s))
+ else
+ visit(node.constant_path)
+ end
+
+ bodystmt = visit_body_node(node.constant_path.location, node.body, true)
+
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+
+ bounds(node.location)
+ on_module(constant_path, bodystmt)
+ end
+
+ # (foo, bar), bar = qux
+ # ^^^^^^^^^^
+ def visit_multi_target_node(node)
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ bounds(node.location)
+ targets = visit_multi_target_node_targets(node.lefts, node.rest, node.rights, true)
+
+ if node.rparen_loc
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ end
+
+ if node.lparen_loc.nil?
+ targets
+ else
+ bounds(node.lparen_loc)
+ on_mlhs_paren(targets)
+ end
+ end
+
+ # Visit the targets of a multi-target node.
+ private def visit_multi_target_node_targets(lefts, rest, rights, skippable)
+ if skippable && lefts.length == 1 && lefts.first.is_a?(MultiTargetNode) && rest.nil? && rights.empty?
+ return visit(lefts.first)
+ end
+
+ mlhs = on_mlhs_new
+
+ lefts.each do |left|
+ bounds(left.location)
+ mlhs = on_mlhs_add(mlhs, visit(left))
+ end
+
+ case rest
+ when nil
+ # do nothing
+ when ImplicitRestNode
+ # these do not get put into the generated tree
+ bounds(rest.location)
+ on_excessed_comma
+ else
+ bounds(rest.location)
+ mlhs = on_mlhs_add_star(mlhs, visit(rest))
+ end
+
+ if rights.any?
+ bounds(rights.first.location)
+ post = on_mlhs_new
+
+ rights.each do |right|
+ bounds(right.location)
+ post = on_mlhs_add(post, visit(right))
+ end
+
+ mlhs = on_mlhs_add_post(mlhs, post)
+ end
+
+ mlhs
+ end
+
+ # foo, bar = baz
+ # ^^^^^^^^^^^^^^
+ def visit_multi_write_node(node)
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ bounds(node.location)
+ targets = visit_multi_target_node_targets(node.lefts, node.rest, node.rights, true)
+
+ if node.rparen_loc
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ end
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ unless node.lparen_loc.nil?
+ bounds(node.lparen_loc)
+ targets = on_mlhs_paren(targets)
+ end
+
+ value = visit_write_value(node.value)
+
+ bounds(node.location)
+ on_massign(targets, value)
+ end
+
+ # next
+ # ^^^^
+ #
+ # next foo
+ # ^^^^^^^^
+ def visit_next_node(node)
+ bounds(node.keyword_loc)
+ on_kw("next")
+
+ if node.arguments.nil?
+ bounds(node.location)
+ on_next(on_args_new)
+ else
+ arguments = visit(node.arguments)
+
+ bounds(node.location)
+ on_next(arguments)
+ end
+ end
+
+ # nil
+ # ^^^
+ def visit_nil_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("nil"))
+ end
+
+ # def foo(&nil); end
+ # ^^^^
+ def visit_no_block_parameter_node(node)
+ bounds(node.operator_loc)
+ on_op("&")
+ bounds(node.keyword_loc)
+ on_kw("nil")
+ bounds(node.location)
+ on_blockarg(:nil)
+ end
+
+ # def foo(**nil); end
+ # ^^^^^
+ def visit_no_keywords_parameter_node(node)
+ bounds(node.operator_loc)
+ on_op("**")
+ bounds(node.keyword_loc)
+ on_kw("nil")
+ bounds(node.location)
+ on_nokw_param(nil)
+
+ :nil
+ end
+
+ # -> { _1 + _2 }
+ # ^^^^^^^^^^^^^^
+ def visit_numbered_parameters_node(node)
+ end
+
+ # $1
+ # ^^
+ def visit_numbered_reference_read_node(node)
+ bounds(node.location)
+ on_backref(node.slice)
+ end
+
+ # def foo(bar: baz); end
+ # ^^^^^^^^
+ def visit_optional_keyword_parameter_node(node)
+ bounds(node.name_loc)
+ name = on_label("#{node.name}:")
+ value = visit(node.value)
+
+ [name, value]
+ end
+
+ # def foo(bar = 1); end
+ # ^^^^^^^
+ def visit_optional_parameter_node(node)
+ bounds(node.name_loc)
+ name = on_ident(node.name.to_s)
+
+ bounds(node.operator_loc)
+ on_op("=")
+
+ value = visit(node.value)
+
+ [name, value]
+ end
+
+ # a or b
+ # ^^^^^^
+ def visit_or_node(node)
+ left = visit(node.left)
+
+ bounds(node.operator_loc)
+ if node.operator == "or"
+ on_kw("or")
+ else
+ on_op("||")
+ end
+
+ right = visit(node.right)
+
+ bounds(node.location)
+ on_binary(left, node.operator.to_sym, right)
+ end
+
+ # def foo(bar, *baz); end
+ # ^^^^^^^^^
+ def visit_parameters_node(node)
+ requireds = node.requireds.map { |required| required.is_a?(MultiTargetNode) ? visit_destructured_parameter_node(required) : visit(required) } if node.requireds.any?
+ optionals = visit_all(node.optionals) if node.optionals.any?
+ rest = visit(node.rest)
+ posts = node.posts.map { |post| post.is_a?(MultiTargetNode) ? visit_destructured_parameter_node(post) : visit(post) } if node.posts.any?
+ keywords = visit_all(node.keywords) if node.keywords.any?
+ keyword_rest = visit(node.keyword_rest)
+ block = visit(node.block)
+
+ bounds(node.location)
+ on_params(requireds, optionals, rest, posts, keywords, keyword_rest, block)
+ end
+
+ # Visit a destructured positional parameter node.
+ private def visit_destructured_parameter_node(node)
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ bounds(node.location)
+ targets = visit_multi_target_node_targets(node.lefts, node.rest, node.rights, false)
+
+ if node.rparen_loc
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ end
+
+ bounds(node.lparen_loc)
+ on_mlhs_paren(targets)
+ end
+
+ # ()
+ # ^^
+ #
+ # (1)
+ # ^^^
+ def visit_parentheses_node(node)
+ bounds(node.opening_loc)
+ on_lparen("(")
+
+ body =
+ if node.body.nil?
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.body)
+ end
+
+ bounds(node.closing_loc)
+ on_rparen(")")
+ bounds(node.location)
+ on_paren(body)
+ end
+
+ # foo => ^(bar)
+ # ^^^^^^
+ def visit_pinned_expression_node(node)
+ bounds(node.operator_loc)
+ on_op("^")
+ bounds(node.lparen_loc)
+ on_lparen("(")
+
+ expression = visit(node.expression)
+
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ bounds(node.location)
+ on_begin(expression)
+ end
+
+ # foo = 1 and bar => ^foo
+ # ^^^^
+ def visit_pinned_variable_node(node)
+ bounds(node.operator_loc)
+ on_op("^")
+
+ visit(node.variable)
+ end
+
+ # END {}
+ # ^^^^^^
+ def visit_post_execution_node(node)
+ bounds(node.keyword_loc)
+ on_kw("END")
+ bounds(node.opening_loc)
+ on_lbrace("{")
+
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ bounds(node.closing_loc)
+ on_rbrace("}")
+ bounds(node.location)
+ on_END(statements)
+ end
+
+ # BEGIN {}
+ # ^^^^^^^^
+ def visit_pre_execution_node(node)
+ bounds(node.keyword_loc)
+ on_kw("BEGIN")
+ bounds(node.opening_loc)
+ on_lbrace("{")
+
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ bounds(node.closing_loc)
+ on_rbrace("}")
+ bounds(node.location)
+ on_BEGIN(statements)
+ end
+
+ # The top-level program node.
+ def visit_program_node(node)
+ body = node.statements.body
+ body = [nil] if body.empty?
+ statements = visit_statements_node_body(body)
+
+ bounds(node.location)
+ on_program(statements)
+ end
+
+ # 0..5
+ # ^^^^
+ def visit_range_node(node)
+ left = visit(node.left)
+
+ bounds(node.operator_loc)
+ on_op(node.operator)
+
+ right = visit(node.right)
+
+ bounds(node.location)
+ if node.exclude_end?
+ on_dot3(left, right)
+ else
+ on_dot2(left, right)
+ end
+ end
+
+ # 1r
+ # ^^
+ def visit_rational_node(node)
+ visit_number_node(node) { |text| on_rational(text) }
+ end
+
+ # redo
+ # ^^^^
+ def visit_redo_node(node)
+ bounds(node.location)
+ on_kw("redo")
+ on_redo
+ end
+
+ # /foo/
+ # ^^^^^
+ def visit_regular_expression_node(node)
+ bounds(node.opening_loc)
+ on_regexp_beg(node.opening)
+
+ if node.content.empty?
+ bounds(node.closing_loc)
+ closing = on_regexp_end(node.closing)
+
+ on_regexp_literal(on_regexp_new, closing)
+ else
+ bounds(node.content_loc)
+ tstring_content = on_tstring_content(node.content)
+
+ bounds(node.closing_loc)
+ closing = on_regexp_end(node.closing)
+
+ on_regexp_literal(on_regexp_add(on_regexp_new, tstring_content), closing)
+ end
+ end
+
+ # def foo(bar:); end
+ # ^^^^
+ def visit_required_keyword_parameter_node(node)
+ bounds(node.name_loc)
+ [on_label("#{node.name}:"), false]
+ end
+
+ # def foo(bar); end
+ # ^^^
+ def visit_required_parameter_node(node)
+ bounds(node.location)
+ on_ident(node.name.to_s)
+ end
+
+ # foo rescue bar
+ # ^^^^^^^^^^^^^^
+ def visit_rescue_modifier_node(node)
+ bounds(node.keyword_loc)
+ on_kw("rescue")
+
+ expression = visit_write_value(node.expression)
+ rescue_expression = visit(node.rescue_expression)
+
+ bounds(node.location)
+ on_rescue_mod(expression, rescue_expression)
+ end
+
+ # begin; rescue; end
+ # ^^^^^^^
+ def visit_rescue_node(node)
+ bounds(node.keyword_loc)
+ on_kw("rescue")
+
+ exceptions =
+ case node.exceptions.length
+ when 0
+ nil
+ when 1
+ if (exception = node.exceptions.first).is_a?(SplatNode)
+ bounds(exception.location)
+ on_mrhs_add_star(on_mrhs_new, visit(exception))
+ else
+ [visit(node.exceptions.first)]
+ end
+ else
+ bounds(node.location)
+ length = node.exceptions.length
+
+ node.exceptions.each_with_index.inject(on_args_new) do |mrhs, (exception, index)|
+ arg = visit(exception)
+
+ bounds(exception.location)
+ mrhs = on_mrhs_new_from_args(mrhs) if index == length - 1
+
+ if exception.is_a?(SplatNode)
+ if index == length - 1
+ on_mrhs_add_star(mrhs, arg)
+ else
+ on_args_add_star(mrhs, arg)
+ end
+ else
+ if index == length - 1
+ on_mrhs_add(mrhs, arg)
+ else
+ on_args_add(mrhs, arg)
+ end
+ end
+ end
+ end
+
+ if node.operator_loc
+ bounds(node.operator_loc)
+ on_op("=>")
+ end
+
+ reference = visit(node.reference)
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ subsequent = visit(node.subsequent)
+
+ bounds(node.location)
+ on_rescue(exceptions, reference, statements, subsequent)
+ end
+
+ # def foo(*bar); end
+ # ^^^^
+ #
+ # def foo(*); end
+ # ^
+ def visit_rest_parameter_node(node)
+ bounds(node.operator_loc)
+ on_op("*")
+
+ if node.name_loc.nil?
+ bounds(node.location)
+ on_rest_param(nil)
+ else
+ bounds(node.name_loc)
+ on_rest_param(on_ident(node.name.to_s))
+ end
+ end
+
+ # retry
+ # ^^^^^
+ def visit_retry_node(node)
+ bounds(node.location)
+ on_kw("retry")
+ on_retry
+ end
+
+ # return
+ # ^^^^^^
+ #
+ # return 1
+ # ^^^^^^^^
+ def visit_return_node(node)
+ bounds(node.keyword_loc)
+ on_kw("return")
+
+ if node.arguments.nil?
+ bounds(node.location)
+ on_return0
+ else
+ arguments = visit(node.arguments)
+
+ bounds(node.location)
+ on_return(arguments)
+ end
+ end
+
+ # self
+ # ^^^^
+ def visit_self_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("self"))
+ end
+
+ # A shareable constant.
+ def visit_shareable_constant_node(node)
+ visit(node.write)
+ end
+
+ # class << self; end
+ # ^^^^^^^^^^^^^^^^^^
+ def visit_singleton_class_node(node)
+ bounds(node.class_keyword_loc)
+ on_kw("class")
+ bounds(node.operator_loc)
+ on_op("<<")
+
+ expression = visit(node.expression)
+ bodystmt = visit_body_node(node.body&.location || node.end_keyword_loc, node.body)
+
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+
+ bounds(node.location)
+ on_sclass(expression, bodystmt)
+ end
+
+ # __ENCODING__
+ # ^^^^^^^^^^^^
+ def visit_source_encoding_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("__ENCODING__"))
+ end
+
+ # __FILE__
+ # ^^^^^^^^
+ def visit_source_file_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("__FILE__"))
+ end
+
+ # __LINE__
+ # ^^^^^^^^
+ def visit_source_line_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("__LINE__"))
+ end
+
+ # foo(*bar)
+ # ^^^^
+ #
+ # def foo((bar, *baz)); end
+ # ^^^^
+ #
+ # def foo(*); bar(*); end
+ # ^
+ def visit_splat_node(node)
+ bounds(node.operator_loc)
+ on_op("*")
+ visit(node.expression)
+ end
+
+ # A list of statements.
+ def visit_statements_node(node)
+ bounds(node.location)
+ visit_statements_node_body(node.body)
+ end
+
+ # Visit the list of statements of a statements node. We support nil
+ # statements in the list. This would normally not be allowed by the
+ # structure of the prism parse tree, but we manually add them here so that
+ # we can mirror Ripper's void stmt.
+ private def visit_statements_node_body(body)
+ body.inject(on_stmts_new) do |stmts, stmt|
+ on_stmts_add(stmts, stmt.nil? ? on_void_stmt : visit(stmt))
+ end
+ end
+
+ # "foo"
+ # ^^^^^
+ def visit_string_node(node)
+ with_string_bounds(node) do
+ if (content = node.content).empty?
+ bounds(node.location)
+ on_string_literal(on_string_content)
+ elsif (opening = node.opening) == "?"
+ bounds(node.location)
+ on_CHAR("?#{node.content}")
+ elsif opening.start_with?("<<~")
+ heredoc = visit_heredoc_string_node(node.to_interpolated)
+
+ bounds(node.location)
+ on_string_literal(heredoc)
+ else
+ bounds(node.content_loc)
+ tstring_content = on_tstring_content(content)
+
+ bounds(node.location)
+ on_string_literal(on_string_add(on_string_content, tstring_content))
+ end
+ end
+ end
+
+ # Responsible for emitting the various string-like begin/end events
+ private def with_string_bounds(node)
+ # `foo "bar": baz` doesn't emit the closing location
+ assoc = !(opening = node.opening)&.include?(":") && node.closing&.end_with?(":")
+
+ is_heredoc = opening&.start_with?("<<")
+ if is_heredoc
+ bounds(node.opening_loc)
+ on_heredoc_beg(node.opening)
+ elsif opening&.start_with?(":", "%s")
+ bounds(node.opening_loc)
+ on_symbeg(node.opening)
+ elsif opening&.start_with?("`", "%x")
+ bounds(node.opening_loc)
+ on_backtick(node.opening)
+ elsif opening && !opening.start_with?("?")
+ bounds(node.opening_loc)
+ on_tstring_beg(opening)
+ end
+
+ result = yield
+ if assoc
+ if node.closing != ":"
+ bounds(node.closing_loc)
+ on_label_end(node.closing)
+ end
+ return result
+ end
+
+ if is_heredoc
+ bounds(node.closing_loc)
+ on_heredoc_end(node.closing)
+ elsif node.closing_loc
+ bounds(node.closing_loc)
+ on_tstring_end(node.closing)
+ end
+
+ result
+ end
+
+ # Ripper gives back the escaped string content but strips out the common
+ # leading whitespace. Prism gives back the unescaped string content and
+ # a location for the escaped string content. Unfortunately these don't
+ # work well together, so here we need to re-derive the common leading
+ # whitespace.
+ private def visit_heredoc_node_whitespace(parts)
+ common_whitespace = nil
+ dedent_next = true
+
+ parts.each do |part|
+ if part.is_a?(StringNode)
+ if dedent_next && !(content = part.content).chomp.empty?
+ common_whitespace = [
+ common_whitespace || Float::INFINITY,
+ content[/\A\s*/].each_char.inject(0) do |part_whitespace, char|
+ char == "\t" ? ((part_whitespace / 8 + 1) * 8) : (part_whitespace + 1)
+ end
+ ].min
+ end
+
+ dedent_next = true
+ else
+ dedent_next = false
+ end
+ end
+
+ common_whitespace || 0
+ end
+
+ # Visit a string that is expressed using a <<~ heredoc.
+ private def visit_heredoc_node(parts, base)
+ common_whitespace = visit_heredoc_node_whitespace(parts)
+
+ if common_whitespace == 0
+ bounds(parts.first.location)
+
+ string = []
+ result = base
+
+ parts.each do |part|
+ if part.is_a?(StringNode)
+ if string.empty?
+ string = [part]
+ else
+ string << part
+ end
+ else
+ unless string.empty?
+ bounds(string[0].location)
+ result = yield result, on_tstring_content(string.map(&:content).join)
+ string = []
+ end
+
+ result = yield result, visit(part)
+ end
+ end
+
+ unless string.empty?
+ bounds(string[0].location)
+ result = yield result, on_tstring_content(string.map(&:content).join)
+ end
+
+ result
+ else
+ bounds(parts.first.location)
+ result =
+ parts.inject(base) do |string_content, part|
+ yield string_content, visit_string_content(part)
+ end
+
+ bounds(parts.first.location)
+ on_heredoc_dedent(result, common_whitespace)
+ end
+ end
+
+ # Visit a heredoc node that is representing a string.
+ private def visit_heredoc_string_node(node)
+ bounds(node.location)
+ visit_heredoc_node(node.parts, on_string_content) do |parts, part|
+ on_string_add(parts, part)
+ end
+ end
+
+ # Visit a heredoc node that is representing an xstring.
+ private def visit_heredoc_x_string_node(node)
+ bounds(node.location)
+ visit_heredoc_node(node.parts, on_xstring_new) do |parts, part|
+ on_xstring_add(parts, part)
+ end
+ end
+
+ # super(foo)
+ # ^^^^^^^^^^
+ def visit_super_node(node)
+ bounds(node.keyword_loc)
+ on_kw("super")
+
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ arguments, block_node = visit_call_node_arguments(node.arguments, node.block, trailing_comma?(node.arguments&.location || node.location, node.rparen_loc || node.location))
+
+ if node.rparen_loc
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ end
+
+ block = visit(block_node)
+
+ if !node.lparen_loc.nil?
+ bounds(node.lparen_loc)
+ arguments = on_arg_paren(arguments)
+ end
+
+ bounds(node.location)
+ call = on_super(arguments)
+
+ if block_node
+ bounds(node.block.location)
+ on_method_add_block(call, block)
+ else
+ call
+ end
+ end
+
+ # :foo
+ # ^^^^
+ def visit_symbol_node(node)
+ with_string_bounds(node) do
+ if node.value_loc.nil?
+ bounds(node.location)
+ on_dyna_symbol(on_string_content)
+ elsif (opening = node.opening)&.match?(/^%s|['"]:?$/)
+ bounds(node.value_loc)
+ content = on_string_add(on_string_content, on_tstring_content(node.value))
+ bounds(node.location)
+ on_dyna_symbol(content)
+ elsif (closing = node.closing) == ":"
+ bounds(node.location)
+ on_label("#{node.value}:")
+ elsif opening.nil? && node.closing_loc.nil?
+ bounds(node.value_loc)
+ on_symbol_literal(visit_token(node.value))
+ else
+ bounds(node.value_loc)
+ on_symbol_literal(on_symbol(visit_token(node.value)))
+ end
+ end
+ end
+
+ # true
+ # ^^^^
+ def visit_true_node(node)
+ bounds(node.location)
+ on_var_ref(on_kw("true"))
+ end
+
+ # undef foo
+ # ^^^^^^^^^
+ def visit_undef_node(node)
+ bounds(node.keyword_loc)
+ on_kw("undef")
+
+ names = visit_all(node.names)
+
+ bounds(node.location)
+ on_undef(names)
+ end
+
+ # unless foo; bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar unless foo
+ # ^^^^^^^^^^^^^^
+ def visit_unless_node(node)
+ if node.statements.nil? || (node.predicate.location.start_offset < node.statements.location.start_offset)
+ bounds(node.keyword_loc)
+ on_kw("unless")
+ predicate = visit(node.predicate)
+ if node.then_keyword_loc
+ bounds(node.then_keyword_loc)
+ on_kw("then")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+ else_clause = visit(node.else_clause)
+
+ if node.end_keyword_loc && !node.else_clause
+ bounds(node.end_keyword_loc)
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ on_unless(predicate, statements, else_clause)
+ else
+ statements = visit(node.statements.body.first)
+ bounds(node.keyword_loc)
+ on_kw("unless")
+ predicate = visit(node.predicate)
+
+ bounds(node.location)
+ on_unless_mod(predicate, statements)
+ end
+ end
+
+ # until foo; bar end
+ # ^^^^^^^^^^^^^^^^^
+ #
+ # bar until foo
+ # ^^^^^^^^^^^^^
+ def visit_until_node(node)
+ bounds(node.keyword_loc)
+ on_kw("until")
+
+ if node.statements.nil? || (node.predicate.location.start_offset < node.statements.location.start_offset)
+ if node.do_keyword_loc
+ bounds(node.do_keyword_loc)
+ on_kw("do")
+ end
+ predicate = visit(node.predicate)
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ if node.closing_loc
+ bounds(node.closing_loc)
+ on_kw("end")
+ end
+
+ bounds(node.location)
+ on_until(predicate, statements)
+ else
+ statements = visit(node.statements.body.first)
+ predicate = visit(node.predicate)
+
+ bounds(node.location)
+ on_until_mod(predicate, statements)
+ end
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^
+ def visit_when_node(node)
+ # This is a special case where we're not going to call on_when directly
+ # because we don't have access to the subsequent. Instead, we'll return
+ # the component parts and let the parent node handle it.
+ bounds(node.keyword_loc)
+ on_kw("when")
+
+ conditions = visit_arguments(node.conditions)
+ if node.then_keyword_loc
+ bounds(node.then_keyword_loc)
+ on_kw("then")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ [conditions, statements]
+ end
+
+ # while foo; bar end
+ # ^^^^^^^^^^^^^^^^^^
+ #
+ # bar while foo
+ # ^^^^^^^^^^^^^
+ def visit_while_node(node)
+ if node.statements.nil? || (node.predicate.location.start_offset < node.statements.location.start_offset)
+ bounds(node.keyword_loc)
+ on_kw("while")
+ if node.do_keyword_loc
+ bounds(node.do_keyword_loc)
+ on_kw("do")
+ end
+ predicate = visit(node.predicate)
+ if node.closing_loc
+ bounds(node.closing_loc)
+ on_kw("end")
+ end
+ statements =
+ if node.statements.nil?
+ bounds(node.location)
+ on_stmts_add(on_stmts_new, on_void_stmt)
+ else
+ visit(node.statements)
+ end
+
+ bounds(node.location)
+ on_while(predicate, statements)
+ else
+ statements = visit(node.statements.body.first)
+ bounds(node.keyword_loc)
+ on_kw("while")
+ predicate = visit(node.predicate)
+
+ bounds(node.location)
+ on_while_mod(predicate, statements)
+ end
+ end
+
+ # `foo`
+ # ^^^^^
+ def visit_x_string_node(node)
+ with_string_bounds(node) do
+ if node.unescaped.empty?
+ bounds(node.location)
+ on_xstring_literal(on_xstring_new)
+ elsif node.opening.start_with?("<<~")
+ heredoc = visit_heredoc_x_string_node(node.to_interpolated)
+
+ bounds(node.location)
+ on_xstring_literal(heredoc)
+ else
+ bounds(node.content_loc)
+ content = on_tstring_content(node.content)
+
+ bounds(node.location)
+ on_xstring_literal(on_xstring_add(on_xstring_new, content))
+ end
+ end
+ end
+
+ # yield
+ # ^^^^^
+ #
+ # yield 1
+ # ^^^^^^^
+ def visit_yield_node(node)
+ bounds(node.keyword_loc)
+ on_kw("yield")
+
+ if node.arguments.nil? && node.lparen_loc.nil?
+ bounds(node.location)
+ on_yield0
+ else
+ if node.lparen_loc
+ bounds(node.lparen_loc)
+ on_lparen("(")
+ end
+
+ arguments =
+ if node.arguments.nil?
+ bounds(node.location)
+ on_args_new
+ else
+ visit(node.arguments)
+ end
+
+ unless node.lparen_loc.nil?
+ bounds(node.rparen_loc)
+ on_rparen(")")
+ bounds(node.lparen_loc)
+ arguments = on_paren(arguments)
+ end
+
+ bounds(node.location)
+ on_yield(arguments)
+ end
+ end
+
+ private
+
+ # Lazily initialize the parse result.
+ def result
+ @result ||= Prism.parse(source, partial_script: true, version: "current", freeze: true, encoding: source.encoding)
+ end
+
+ def line_and_column_cache
+ @line_and_column_cache ||= LineAndColumnCache.new(result.source)
+ end
+
+ ##########################################################################
+ # Helpers
+ ##########################################################################
+
+ # Returns true if there is a comma between the two locations.
+ def trailing_comma?(left, right)
+ source.byteslice(left.end_offset...right.start_offset).include?(",")
+ end
+
+ # Returns true if there is a semicolon between the two locations.
+ def void_stmt?(left, right, allow_newline)
+ pattern = allow_newline ? /[;\n]/ : /;/
+ source.byteslice(left.end_offset...right.start_offset).match?(pattern)
+ end
+
+ # Visit the string content of a particular node. This method is used to
+ # split into the various token types.
+ def visit_token(token, allow_keywords = true)
+ if token == "."
+ on_period(token)
+ elsif token == "`"
+ on_backtick(token)
+ elsif allow_keywords && KEYWORDS.include?(token)
+ on_kw(token)
+ elsif token.start_with?("_")
+ on_ident(token)
+ elsif token.match?(/^[[:upper:]]\w*$/)
+ on_const(token)
+ elsif token.start_with?("@@")
+ on_cvar(token)
+ elsif token.start_with?("@")
+ on_ivar(token)
+ elsif token.start_with?("$")
+ on_gvar(token)
+ elsif token.match?(/^[[:punct:]]/)
+ on_op(token)
+ else
+ on_ident(token)
+ end
+ end
+
+ # Visit either `.`, `&.`, or `::`.
+ def visit_call_operator(token)
+ token == "." ? on_period(token) : on_op(token)
+ end
+
+ # Visit a node that represents a number. We need to explicitly handle the
+ # unary - operator.
+ def visit_number_node(node)
+ slice = node.slice
+ location = node.location
+
+ if slice[0] == "-"
+ bounds(location.copy(length: 1))
+ on_op("-")
+
+ bounds(location.copy(start_offset: location.start_offset + 1))
+ value = yield slice[1..-1]
+
+ bounds(node.location)
+ on_unary(:-@, value)
+ else
+ bounds(location)
+ yield slice
+ end
+ end
+
+ # Visit a node that represents a write value. This is used to handle the
+ # special case of an implicit array that is generated without brackets.
+ def visit_write_value(node)
+ if node.is_a?(ArrayNode) && node.opening_loc.nil?
+ elements = node.elements
+ length = elements.length
+
+ bounds(elements.first.location)
+ elements.each_with_index.inject((elements.first.is_a?(SplatNode) && length == 1) ? on_mrhs_new : on_args_new) do |args, (element, index)|
+ arg = visit(element)
+ bounds(element.location)
+
+ if index == length - 1
+ if element.is_a?(SplatNode)
+ mrhs = index == 0 ? args : on_mrhs_new_from_args(args)
+ on_mrhs_add_star(mrhs, arg)
+ else
+ on_mrhs_add(on_mrhs_new_from_args(args), arg)
+ end
+ else
+ case element
+ when BlockArgumentNode
+ on_args_add_block(args, arg)
+ when SplatNode
+ on_args_add_star(args, arg)
+ else
+ on_args_add(args, arg)
+ end
+ end
+ end
+ else
+ visit(node)
+ end
+ end
+
+ # This method is responsible for updating lineno and column information
+ # to reflect the current node.
+ def bounds(location)
+ @lineno, @column = line_and_column_cache.line_and_column(location.start_offset)
+ end
+
+ # :startdoc:
+
+ ##########################################################################
+ # Ripper interface
+ ##########################################################################
+
+ # :stopdoc:
+ def _dispatch_0; end
+ def _dispatch_1(arg); arg end
+ def _dispatch_2(arg, _); arg end
+ def _dispatch_3(arg, _, _); arg end
+ def _dispatch_4(arg, _, _, _); arg end
+ def _dispatch_5(arg, _, _, _, _); arg end
+ def _dispatch_7(arg, _, _, _, _, _, _); arg end
+ # :startdoc:
+
+ #
+ # Parser Events
+ #
+
+ PARSER_EVENT_TABLE.each do |id, arity|
+ alias_method "on_#{id}", "_dispatch_#{arity}"
+ 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|
+ alias_method "on_#{id}", :_dispatch_1
+ end
+
+ # This method is provided by the Ripper C extension. It is called when a
+ # string needs to be dedented because of a tilde heredoc. It is expected
+ # that it will modify the string in place and return the number of bytes
+ # that were removed.
+ def dedent_string(string, width)
+ whitespace = 0
+ cursor = 0
+
+ while cursor < string.length && string[cursor].match?(/\s/) && whitespace < width
+ if string[cursor] == "\t"
+ whitespace = ((whitespace / 8 + 1) * 8)
+ break if whitespace > width
+ else
+ whitespace += 1
+ end
+
+ cursor += 1
+ end
+
+ string.replace(string[cursor..])
+ cursor
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/ripper/filter.rb b/lib/prism/translation/ripper/filter.rb
new file mode 100644
index 0000000000..19deef2d37
--- /dev/null
+++ b/lib/prism/translation/ripper/filter.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module Prism
+ module Translation
+ class Ripper
+ class Filter # :nodoc:
+ # :stopdoc:
+ def initialize(src, filename = '-', lineno = 1)
+ @__lexer = Lexer.new(src, filename, lineno)
+ @__line = nil
+ @__col = nil
+ @__state = nil
+ end
+
+ def filename
+ @__lexer.filename
+ end
+
+ def lineno
+ @__line
+ end
+
+ def column
+ @__col
+ end
+
+ def state
+ @__state
+ end
+
+ def parse(init = nil)
+ data = init
+ @__lexer.lex.each do |pos, event, tok, state|
+ @__line, @__col = *pos
+ @__state = state
+ data = if respond_to?(event, true)
+ then __send__(event, tok, data)
+ else on_default(event, tok, data)
+ end
+ end
+ data
+ end
+
+ private
+
+ def on_default(event, token, data)
+ data
+ end
+ # :startdoc:
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/ripper/lexer.rb b/lib/prism/translation/ripper/lexer.rb
new file mode 100644
index 0000000000..c6aeae4bd7
--- /dev/null
+++ b/lib/prism/translation/ripper/lexer.rb
@@ -0,0 +1,133 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+require_relative "../ripper"
+
+module Prism
+ module Translation
+ class Ripper
+ class Lexer < Ripper # :nodoc:
+ class State # :nodoc:
+ attr_reader :to_int, :to_s
+
+ def initialize(i)
+ @to_int = i
+ @to_s = Ripper.lex_state_name(i)
+ freeze
+ end
+
+ def [](index)
+ case index
+ when 0, :to_int
+ @to_int
+ when 1, :to_s
+ @to_s
+ else
+ nil
+ end
+ end
+
+ alias to_i to_int
+ alias inspect to_s
+ def pretty_print(q) q.text(to_s) end
+ def ==(i) super or to_int == i end
+ def &(i) self.class.new(to_int & i) end
+ def |(i) self.class.new(to_int | i) end
+ def allbits?(i) to_int.allbits?(i) end
+ def anybits?(i) to_int.anybits?(i) end
+ def nobits?(i) to_int.nobits?(i) end
+
+ # Instances are frozen and there are only a handful of them so we
+ # cache them here.
+ STATES = Hash.new { |hash, key| hash[key] = State.new(key) }
+ private_constant :STATES
+
+ def self.[](i)
+ STATES[i]
+ end
+ end
+
+ class Elem # :nodoc:
+ attr_accessor :pos, :event, :tok, :state, :message
+
+ def initialize(pos, event, tok, state, message = nil)
+ @pos = pos
+ @event = event
+ @tok = tok
+ @state = State[state]
+ @message = message
+ end
+
+ def [](index)
+ case index
+ when 0, :pos
+ @pos
+ when 1, :event
+ @event
+ when 2, :tok
+ @tok
+ when 3, :state
+ @state
+ when 4, :message
+ @message
+ else
+ nil
+ end
+ end
+
+ def inspect
+ "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
+ end
+
+ alias to_s inspect
+
+ def pretty_print(q)
+ q.group(2, "#<#{self.class}:", ">") {
+ q.breakable
+ q.text("#{event}@#{pos[0]}:#{pos[1]}")
+ q.breakable
+ state.pretty_print(q)
+ q.breakable
+ q.text("token: ")
+ tok.pretty_print(q)
+ if message
+ q.breakable
+ q.text("message: ")
+ q.text(message)
+ end
+ }
+ end
+
+ def to_a
+ if @message
+ [@pos, @event, @tok, @state, @message]
+ else
+ [@pos, @event, @tok, @state]
+ end
+ end
+ end
+
+ # Pretty much just the same as Prism.lex_compat.
+ def lex(raise_errors: false)
+ Ripper.lex(@source, filename, lineno, raise_errors: raise_errors)
+ end
+
+ # Returns the lex_compat result wrapped in `Elem`. Errors are omitted.
+ # Since ripper is a streaming parser, tokens are expected to be emitted in the order
+ # that the parser encounters them. This is not implemented.
+ def parse(...)
+ lex(...).map do |position, event, token, state|
+ Elem.new(position, event, token, state.to_int)
+ end
+ end
+
+ # Similar to parse but ripper sorts the elements by position in the source. Also
+ # includes errors. Since prism does error recovery, in cases of syntax errors
+ # the result may differ greatly compared to ripper.
+ def scan(...)
+ parse(...)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/ripper/sexp.rb b/lib/prism/translation/ripper/sexp.rb
new file mode 100644
index 0000000000..46c0333544
--- /dev/null
+++ b/lib/prism/translation/ripper/sexp.rb
@@ -0,0 +1,118 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+require_relative "../ripper"
+
+module Prism
+ module Translation
+ class Ripper
+ # This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that
+ # returns the arrays of [type, *children].
+ class SexpBuilder < Ripper # :nodoc:
+ attr_reader :error
+
+ private
+
+ def dedent_element(e, width)
+ if (n = dedent_string(e[1], width)) > 0
+ e[2][1] += n
+ end
+ e
+ end
+
+ def on_heredoc_dedent(val, width)
+ sub = proc do |cont|
+ cont.map! do |e|
+ if Array === e
+ case e[0]
+ when :@tstring_content
+ e = dedent_element(e, width)
+ when /_add\z/
+ e[1] = sub[e[1]]
+ end
+ elsif String === e
+ dedent_string(e, width)
+ end
+ e
+ end
+ end
+ sub[val]
+ val
+ end
+
+ events = private_instance_methods(false).grep(/\Aon_/) {$'.to_sym}
+ (PARSER_EVENTS - events).each do |event|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(*args)
+ args.unshift :#{event}
+ 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
+
+ def on_error(mesg)
+ @error = mesg
+ end
+ remove_method :on_parse_error
+ alias on_parse_error on_error
+ alias compile_error on_error
+ end
+
+ # This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that
+ # returns the same values as ::Ripper::SexpBuilder except with a couple of
+ # niceties that flatten linked lists into arrays.
+ class SexpBuilderPP < SexpBuilder # :nodoc:
+ private
+
+ def on_heredoc_dedent(val, width)
+ val.map! do |e|
+ next e if Symbol === e and /_content\z/ =~ e
+ if Array === e and e[0] == :@tstring_content
+ e = dedent_element(e, width)
+ elsif String === e
+ dedent_string(e, width)
+ end
+ e
+ end
+ val
+ end
+
+ def _dispatch_event_new
+ []
+ end
+
+ def _dispatch_event_push(list, item)
+ list.push item
+ list
+ end
+
+ def on_mlhs_paren(list)
+ [:mlhs, *list]
+ end
+
+ def on_mlhs_add_star(list, star)
+ list.push([:rest_param, star])
+ end
+
+ def on_mlhs_add_post(list, post)
+ list.concat(post)
+ end
+
+ PARSER_EVENT_TABLE.each do |event, arity|
+ if /_new\z/ =~ event and arity == 0
+ alias_method "on_#{event}", :_dispatch_event_new
+ elsif /_add\z/ =~ event
+ alias_method "on_#{event}", :_dispatch_event_push
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/prism/translation/ripper/shim.rb b/lib/prism/translation/ripper/shim.rb
new file mode 100644
index 0000000000..00ed625da3
--- /dev/null
+++ b/lib/prism/translation/ripper/shim.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+# This writes the prism ripper translation into the Ripper constant so that
+# users can transparently use Ripper without any changes.
+# :stopdoc:
+Ripper = Prism::Translation::Ripper
+# :startdoc:
diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb
new file mode 100644
index 0000000000..42bc5ee658
--- /dev/null
+++ b/lib/prism/translation/ruby_parser.rb
@@ -0,0 +1,1676 @@
+# frozen_string_literal: true
+# :markup: markdown
+
+begin
+ require "sexp"
+rescue LoadError
+ warn(%q{Error: Unable to load sexp. Add `gem "sexp_processor"` to your Gemfile.})
+ exit(1)
+end
+
+class RubyParser # :nodoc:
+ class SyntaxError < RuntimeError # :nodoc:
+ end
+end
+
+module Prism
+ module Translation
+ # This module is the entry-point for converting a prism syntax tree into the
+ # seattlerb/ruby_parser gem's syntax tree.
+ class RubyParser
+ # A prism visitor that builds Sexp objects.
+ class Compiler < ::Prism::Compiler # :nodoc:
+ # This is the name of the file that we are compiling. We set it on every
+ # Sexp object that is generated, and also use it to compile `__FILE__`
+ # nodes.
+ attr_reader :file
+
+ # Class variables will change their type based on if they are inside of
+ # a method definition or not, so we need to track that state.
+ attr_reader :in_def
+
+ # Some nodes will change their representation if they are inside of a
+ # pattern, so we need to track that state.
+ attr_reader :in_pattern
+
+ # Initialize a new compiler with the given file name.
+ def initialize(file, in_def: false, in_pattern: false)
+ @file = file
+ @in_def = in_def
+ @in_pattern = in_pattern
+ end
+
+ # alias foo bar
+ # ^^^^^^^^^^^^^
+ def visit_alias_method_node(node)
+ s(node, :alias, visit(node.new_name), visit(node.old_name))
+ end
+
+ # alias $foo $bar
+ # ^^^^^^^^^^^^^^^
+ def visit_alias_global_variable_node(node)
+ s(node, :valias, node.new_name.name, node.old_name.name)
+ end
+
+ # foo => bar | baz
+ # ^^^^^^^^^
+ def visit_alternation_pattern_node(node)
+ s(node, :or, visit(node.left), visit(node.right))
+ end
+
+ # a and b
+ # ^^^^^^^
+ def visit_and_node(node)
+ left = visit(node.left)
+
+ if left[0] == :and
+ # ruby_parser has the and keyword as right-associative as opposed to
+ # prism which has it as left-associative. We reverse that
+ # associativity here.
+ nest = left
+ nest = nest[2] while nest[2][0] == :and
+ nest[2] = s(node, :and, nest[2], visit(node.right))
+ left
+ else
+ s(node, :and, left, visit(node.right))
+ end
+ end
+
+ # []
+ # ^^
+ def visit_array_node(node)
+ if in_pattern
+ s(node, :array_pat, nil).concat(visit_all(node.elements))
+ else
+ s(node, :array).concat(visit_all(node.elements))
+ end
+ end
+
+ # foo => [bar]
+ # ^^^^^
+ def visit_array_pattern_node(node)
+ if node.constant.nil? && node.requireds.empty? && node.rest.nil? && node.posts.empty?
+ s(node, :array_pat)
+ else
+ result = s(node, :array_pat, visit_pattern_constant(node.constant)).concat(visit_all(node.requireds))
+
+ case node.rest
+ when SplatNode
+ result << :"*#{node.rest.expression&.name}"
+ when ImplicitRestNode
+ result << :*
+
+ # This doesn't make any sense at all, but since we're trying to
+ # replicate the behavior directly, we'll copy it.
+ result.line(666)
+ end
+
+ result.concat(visit_all(node.posts))
+ end
+ end
+
+ # foo(bar)
+ # ^^^
+ def visit_arguments_node(node)
+ raise "Cannot visit arguments directly"
+ end
+
+ # { a: 1 }
+ # ^^^^
+ def visit_assoc_node(node)
+ [visit(node.key), visit(node.value)]
+ end
+
+ # def foo(**); bar(**); end
+ # ^^
+ #
+ # { **foo }
+ # ^^^^^
+ def visit_assoc_splat_node(node)
+ if node.value.nil?
+ [s(node, :kwsplat)]
+ else
+ [s(node, :kwsplat, visit(node.value))]
+ end
+ end
+
+ # $+
+ # ^^
+ def visit_back_reference_read_node(node)
+ s(node, :back_ref, node.name.to_s.delete_prefix("$").to_sym)
+ end
+
+ # begin end
+ # ^^^^^^^^^
+ def visit_begin_node(node)
+ result = node.statements.nil? ? s(node, :nil) : visit(node.statements)
+
+ if !node.rescue_clause.nil?
+ if !node.statements.nil?
+ result = s(node.statements, :rescue, result, visit(node.rescue_clause))
+ else
+ result = s(node.rescue_clause, :rescue, visit(node.rescue_clause))
+ end
+
+ current = node.rescue_clause
+ until (current = current.subsequent).nil?
+ result << visit(current)
+ end
+ end
+
+ if !node.else_clause&.statements.nil?
+ result << visit(node.else_clause)
+ end
+
+ if !node.ensure_clause.nil?
+ if !node.statements.nil? || !node.rescue_clause.nil? || !node.else_clause.nil?
+ result = s(node.statements || node.rescue_clause || node.else_clause || node.ensure_clause, :ensure, result, visit(node.ensure_clause))
+ else
+ result = s(node.ensure_clause, :ensure, visit(node.ensure_clause))
+ end
+ end
+
+ result
+ end
+
+ # foo(&bar)
+ # ^^^^
+ def visit_block_argument_node(node)
+ s(node, :block_pass).tap do |result|
+ result << visit(node.expression) unless node.expression.nil?
+ end
+ end
+
+ # foo { |; bar| }
+ # ^^^
+ def visit_block_local_variable_node(node)
+ node.name
+ end
+
+ # A block on a keyword or method call.
+ def visit_block_node(node)
+ s(node, :block_pass, visit(node.expression))
+ end
+
+ # def foo(&bar); end
+ # ^^^^
+ def visit_block_parameter_node(node)
+ :"&#{node.name}"
+ end
+
+ # A block's parameters.
+ def visit_block_parameters_node(node)
+ # If this block parameters has no parameters and is using pipes, then
+ # it inherits its location from its shadow locals, even if they're not
+ # on the same lines as the pipes.
+ shadow_loc = true
+
+ result =
+ if node.parameters.nil?
+ s(node, :args)
+ else
+ shadow_loc = false
+ visit(node.parameters)
+ end
+
+ if node.opening == "("
+ result.line = node.opening_loc.start_line
+ result.line_max = node.closing_loc.end_line
+ shadow_loc = false
+ end
+
+ if node.locals.any?
+ shadow = s(node, :shadow).concat(visit_all(node.locals))
+ shadow.line = node.locals.first.location.start_line
+ shadow.line_max = node.locals.last.location.end_line
+ result << shadow
+
+ if shadow_loc
+ result.line = shadow.line
+ result.line_max = shadow.line_max
+ end
+ end
+
+ result
+ end
+
+ # break
+ # ^^^^^
+ #
+ # break foo
+ # ^^^^^^^^^
+ def visit_break_node(node)
+ if node.arguments.nil?
+ s(node, :break)
+ elsif node.arguments.arguments.length == 1
+ s(node, :break, visit(node.arguments.arguments.first))
+ else
+ s(node, :break, s(node.arguments, :array).concat(visit_all(node.arguments.arguments)))
+ end
+ end
+
+ # foo
+ # ^^^
+ #
+ # foo.bar
+ # ^^^^^^^
+ #
+ # foo.bar() {}
+ # ^^^^^^^^^^^^
+ def visit_call_node(node)
+ case node.name
+ when :!~
+ return s(node, :not, visit(node.copy(name: :"=~")))
+ when :=~
+ if node.arguments&.arguments&.length == 1 && node.block.nil?
+ case node.receiver
+ when StringNode
+ return s(node, :match3, visit(node.arguments.arguments.first), visit(node.receiver))
+ when RegularExpressionNode, InterpolatedRegularExpressionNode
+ return s(node, :match2, visit(node.receiver), visit(node.arguments.arguments.first))
+ end
+
+ case node.arguments.arguments.first
+ when RegularExpressionNode, InterpolatedRegularExpressionNode
+ return s(node, :match3, visit(node.arguments.arguments.first), visit(node.receiver))
+ end
+ end
+ end
+
+ type = node.attribute_write? ? :attrasgn : :call
+ type = :"safe_#{type}" if node.safe_navigation?
+
+ arguments = node.arguments&.arguments || []
+ write_value = arguments.pop if type == :attrasgn
+ block = node.block
+
+ if block.is_a?(BlockArgumentNode)
+ arguments << block
+ block = nil
+ end
+
+ result = s(node, type, visit(node.receiver), node.name).concat(visit_all(arguments))
+ result << visit_write_value(write_value) unless write_value.nil?
+
+ visit_block(node, result, block)
+ end
+
+ # foo.bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_operator_write_node(node)
+ if op_asgn?(node)
+ s(node, op_asgn_type(node, :op_asgn), visit(node.receiver), visit_write_value(node.value), node.read_name, node.binary_operator)
+ else
+ s(node, op_asgn_type(node, :op_asgn2), visit(node.receiver), node.write_name, node.binary_operator, visit_write_value(node.value))
+ end
+ end
+
+ # foo.bar &&= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_and_write_node(node)
+ if op_asgn?(node)
+ s(node, op_asgn_type(node, :op_asgn), visit(node.receiver), visit_write_value(node.value), node.read_name, :"&&")
+ else
+ s(node, op_asgn_type(node, :op_asgn2), visit(node.receiver), node.write_name, :"&&", visit_write_value(node.value))
+ end
+ end
+
+ # foo.bar ||= baz
+ # ^^^^^^^^^^^^^^^
+ def visit_call_or_write_node(node)
+ if op_asgn?(node)
+ s(node, op_asgn_type(node, :op_asgn), visit(node.receiver), visit_write_value(node.value), node.read_name, :"||")
+ else
+ s(node, op_asgn_type(node, :op_asgn2), visit(node.receiver), node.write_name, :"||", visit_write_value(node.value))
+ end
+ end
+
+ # Call nodes with operators following them will either be op_asgn or
+ # op_asgn2 nodes. That is determined by their call operator and their
+ # right-hand side.
+ private def op_asgn?(node)
+ node.call_operator == "::" || (node.value.is_a?(CallNode) && node.value.opening_loc.nil? && !node.value.arguments.nil?)
+ end
+
+ # Call nodes with operators following them can use &. as an operator,
+ # which changes their type by prefixing "safe_".
+ private def op_asgn_type(node, type)
+ node.safe_navigation? ? :"safe_#{type}" : type
+ end
+
+ # foo.bar, = 1
+ # ^^^^^^^
+ def visit_call_target_node(node)
+ s(node, :attrasgn, visit(node.receiver), node.name)
+ end
+
+ # foo => bar => baz
+ # ^^^^^^^^^^
+ def visit_capture_pattern_node(node)
+ visit(node.target) << visit(node.value)
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_node(node)
+ s(node, :case, visit(node.predicate)).concat(visit_all(node.conditions)) << visit(node.else_clause)
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_case_match_node(node)
+ s(node, :case, visit(node.predicate)).concat(visit_all(node.conditions)) << visit(node.else_clause)
+ end
+
+ # class Foo; end
+ # ^^^^^^^^^^^^^^
+ def visit_class_node(node)
+ name =
+ if node.constant_path.is_a?(ConstantReadNode)
+ node.name
+ else
+ visit(node.constant_path)
+ end
+
+ result =
+ if node.body.nil?
+ s(node, :class, name, visit(node.superclass))
+ elsif node.body.is_a?(StatementsNode)
+ compiler = copy_compiler(in_def: false)
+ s(node, :class, name, visit(node.superclass)).concat(node.body.body.map { |child| child.accept(compiler) })
+ else
+ s(node, :class, name, visit(node.superclass), node.body.accept(copy_compiler(in_def: false)))
+ end
+
+ attach_comments(result, node)
+ result
+ end
+
+ # @@foo
+ # ^^^^^
+ def visit_class_variable_read_node(node)
+ s(node, :cvar, node.name)
+ end
+
+ # @@foo = 1
+ # ^^^^^^^^^
+ def visit_class_variable_write_node(node)
+ s(node, class_variable_write_type, node.name, visit_write_value(node.value))
+ end
+
+ # @@foo += bar
+ # ^^^^^^^^^^^^
+ def visit_class_variable_operator_write_node(node)
+ s(node, class_variable_write_type, node.name, s(node, :call, s(node, :cvar, node.name), node.binary_operator, visit_write_value(node.value)))
+ end
+
+ # @@foo &&= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_and_write_node(node)
+ s(node, :op_asgn_and, s(node, :cvar, node.name), s(node, class_variable_write_type, node.name, visit_write_value(node.value)))
+ end
+
+ # @@foo ||= bar
+ # ^^^^^^^^^^^^^
+ def visit_class_variable_or_write_node(node)
+ s(node, :op_asgn_or, s(node, :cvar, node.name), s(node, class_variable_write_type, node.name, visit_write_value(node.value)))
+ end
+
+ # @@foo, = bar
+ # ^^^^^
+ def visit_class_variable_target_node(node)
+ s(node, class_variable_write_type, node.name)
+ end
+
+ # If a class variable is written within a method definition, it has a
+ # different type than everywhere else.
+ private def class_variable_write_type
+ in_def ? :cvasgn : :cvdecl
+ end
+
+ # Foo
+ # ^^^
+ def visit_constant_read_node(node)
+ s(node, :const, node.name)
+ end
+
+ # Foo = 1
+ # ^^^^^^^
+ #
+ # Foo, Bar = 1
+ # ^^^ ^^^
+ def visit_constant_write_node(node)
+ s(node, :cdecl, node.name, visit_write_value(node.value))
+ end
+
+ # Foo += bar
+ # ^^^^^^^^^^^
+ def visit_constant_operator_write_node(node)
+ s(node, :cdecl, node.name, s(node, :call, s(node, :const, node.name), node.binary_operator, visit_write_value(node.value)))
+ end
+
+ # Foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_and_write_node(node)
+ s(node, :op_asgn_and, s(node, :const, node.name), s(node, :cdecl, node.name, visit(node.value)))
+ end
+
+ # Foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_constant_or_write_node(node)
+ s(node, :op_asgn_or, s(node, :const, node.name), s(node, :cdecl, node.name, visit(node.value)))
+ end
+
+ # Foo, = bar
+ # ^^^
+ def visit_constant_target_node(node)
+ s(node, :cdecl, node.name)
+ end
+
+ # Foo::Bar
+ # ^^^^^^^^
+ def visit_constant_path_node(node)
+ if node.parent.nil?
+ s(node, :colon3, node.name)
+ else
+ s(node, :colon2, visit(node.parent), node.name)
+ end
+ end
+
+ # Foo::Bar = 1
+ # ^^^^^^^^^^^^
+ #
+ # Foo::Foo, Bar::Bar = 1
+ # ^^^^^^^^ ^^^^^^^^
+ def visit_constant_path_write_node(node)
+ s(node, :cdecl, visit(node.target), visit_write_value(node.value))
+ end
+
+ # Foo::Bar += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_constant_path_operator_write_node(node)
+ s(node, :op_asgn, visit(node.target), node.binary_operator, visit_write_value(node.value))
+ end
+
+ # Foo::Bar &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_and_write_node(node)
+ s(node, :op_asgn_and, visit(node.target), visit_write_value(node.value))
+ end
+
+ # Foo::Bar ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_constant_path_or_write_node(node)
+ s(node, :op_asgn_or, visit(node.target), visit_write_value(node.value))
+ end
+
+ # Foo::Bar, = baz
+ # ^^^^^^^^
+ def visit_constant_path_target_node(node)
+ inner =
+ if node.parent.nil?
+ s(node, :colon3, node.name)
+ else
+ s(node, :colon2, visit(node.parent), node.name)
+ end
+
+ s(node, :const, inner)
+ end
+
+ # def foo; end
+ # ^^^^^^^^^^^^
+ #
+ # def self.foo; end
+ # ^^^^^^^^^^^^^^^^^
+ def visit_def_node(node)
+ name = node.name_loc.slice.to_sym
+ result =
+ if node.receiver.nil?
+ s(node, :defn, name)
+ else
+ s(node, :defs, visit(node.receiver), name)
+ end
+
+ attach_comments(result, node)
+ result.line(node.name_loc.start_line)
+
+ if node.parameters.nil?
+ result << s(node, :args).line(node.name_loc.start_line)
+ else
+ result << visit(node.parameters)
+ end
+
+ if node.body.nil?
+ result << s(node, :nil)
+ elsif node.body.is_a?(StatementsNode)
+ compiler = copy_compiler(in_def: true)
+ result.concat(node.body.body.map { |child| child.accept(compiler) })
+ else
+ result << node.body.accept(copy_compiler(in_def: true))
+ end
+ end
+
+ # defined? a
+ # ^^^^^^^^^^
+ #
+ # defined?(a)
+ # ^^^^^^^^^^^
+ def visit_defined_node(node)
+ s(node, :defined, visit(node.value))
+ end
+
+ # if foo then bar else baz end
+ # ^^^^^^^^^^^^
+ def visit_else_node(node)
+ visit(node.statements)
+ end
+
+ # "foo #{bar}"
+ # ^^^^^^
+ def visit_embedded_statements_node(node)
+ result = s(node, :evstr)
+ result << visit(node.statements) unless node.statements.nil?
+ result
+ end
+
+ # "foo #@bar"
+ # ^^^^^
+ def visit_embedded_variable_node(node)
+ s(node, :evstr, visit(node.variable))
+ end
+
+ # begin; foo; ensure; bar; end
+ # ^^^^^^^^^^^^
+ def visit_ensure_node(node)
+ node.statements.nil? ? s(node, :nil) : visit(node.statements)
+ end
+
+ # false
+ # ^^^^^
+ def visit_false_node(node)
+ s(node, :false)
+ end
+
+ # foo => [*, bar, *]
+ # ^^^^^^^^^^^
+ def visit_find_pattern_node(node)
+ s(node, :find_pat, visit_pattern_constant(node.constant), :"*#{node.left.expression&.name}", *visit_all(node.requireds), :"*#{node.right.expression&.name}")
+ end
+
+ # if foo .. bar; end
+ # ^^^^^^^^^^
+ def visit_flip_flop_node(node)
+ if node.left.is_a?(IntegerNode) && node.right.is_a?(IntegerNode)
+ s(node, :lit, Range.new(node.left.value, node.right.value, node.exclude_end?))
+ else
+ s(node, node.exclude_end? ? :flip3 : :flip2, visit(node.left), visit(node.right))
+ end
+ end
+
+ # 1.0
+ # ^^^
+ def visit_float_node(node)
+ s(node, :lit, node.value)
+ end
+
+ # for foo in bar do end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_for_node(node)
+ s(node, :for, visit(node.collection), visit(node.index), visit(node.statements))
+ end
+
+ # def foo(...); bar(...); end
+ # ^^^
+ def visit_forwarding_arguments_node(node)
+ s(node, :forward_args)
+ end
+
+ # def foo(...); end
+ # ^^^
+ def visit_forwarding_parameter_node(node)
+ s(node, :forward_args)
+ end
+
+ # super
+ # ^^^^^
+ #
+ # super {}
+ # ^^^^^^^^
+ def visit_forwarding_super_node(node)
+ visit_block(node, s(node, :zsuper), node.block)
+ end
+
+ # $foo
+ # ^^^^
+ def visit_global_variable_read_node(node)
+ s(node, :gvar, node.name)
+ end
+
+ # $foo = 1
+ # ^^^^^^^^
+ def visit_global_variable_write_node(node)
+ s(node, :gasgn, node.name, visit_write_value(node.value))
+ end
+
+ # $foo += bar
+ # ^^^^^^^^^^^
+ def visit_global_variable_operator_write_node(node)
+ s(node, :gasgn, node.name, s(node, :call, s(node, :gvar, node.name), node.binary_operator, visit(node.value)))
+ end
+
+ # $foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_and_write_node(node)
+ s(node, :op_asgn_and, s(node, :gvar, node.name), s(node, :gasgn, node.name, visit_write_value(node.value)))
+ end
+
+ # $foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_global_variable_or_write_node(node)
+ s(node, :op_asgn_or, s(node, :gvar, node.name), s(node, :gasgn, node.name, visit_write_value(node.value)))
+ end
+
+ # $foo, = bar
+ # ^^^^
+ def visit_global_variable_target_node(node)
+ s(node, :gasgn, node.name)
+ end
+
+ # {}
+ # ^^
+ def visit_hash_node(node)
+ s(node, :hash).concat(node.elements.flat_map { |element| visit(element) })
+ end
+
+ # foo => {}
+ # ^^
+ def visit_hash_pattern_node(node)
+ result = s(node, :hash_pat, visit_pattern_constant(node.constant)).concat(node.elements.flat_map { |element| visit(element) })
+
+ case node.rest
+ when AssocSplatNode
+ result << s(node.rest, :kwrest, :"**#{node.rest.value&.name}")
+ when NoKeywordsParameterNode
+ result << visit(node.rest)
+ end
+
+ result
+ end
+
+ # if foo then bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar if foo
+ # ^^^^^^^^^^
+ #
+ # foo ? bar : baz
+ # ^^^^^^^^^^^^^^^
+ def visit_if_node(node)
+ s(node, :if, visit(node.predicate), visit(node.statements), visit(node.subsequent))
+ end
+
+ # 1i
+ def visit_imaginary_node(node)
+ s(node, :lit, node.value)
+ end
+
+ # { foo: }
+ # ^^^^
+ def visit_implicit_node(node)
+ end
+
+ # foo { |bar,| }
+ # ^
+ def visit_implicit_rest_node(node)
+ end
+
+ # case foo; in bar; end
+ # ^^^^^^^^^^^^^^^^^^^^^
+ def visit_in_node(node)
+ pattern =
+ if node.pattern.is_a?(ConstantPathNode)
+ s(node.pattern, :const, visit(node.pattern))
+ else
+ node.pattern.accept(copy_compiler(in_pattern: true))
+ end
+
+ s(node, :in, pattern).concat(node.statements.nil? ? [nil] : visit_all(node.statements.body))
+ end
+
+ # foo[bar] += baz
+ # ^^^^^^^^^^^^^^^
+ def visit_index_operator_write_node(node)
+ arglist = nil
+
+ if !node.arguments.nil? || !node.block.nil?
+ arglist = s(node, :arglist).concat(visit_all(node.arguments&.arguments || []))
+ arglist << visit(node.block) if !node.block.nil?
+ end
+
+ s(node, :op_asgn1, visit(node.receiver), arglist, node.binary_operator, visit_write_value(node.value))
+ end
+
+ # foo[bar] &&= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_and_write_node(node)
+ arglist = nil
+
+ if !node.arguments.nil? || !node.block.nil?
+ arglist = s(node, :arglist).concat(visit_all(node.arguments&.arguments || []))
+ arglist << visit(node.block) if !node.block.nil?
+ end
+
+ s(node, :op_asgn1, visit(node.receiver), arglist, :"&&", visit_write_value(node.value))
+ end
+
+ # foo[bar] ||= baz
+ # ^^^^^^^^^^^^^^^^
+ def visit_index_or_write_node(node)
+ arglist = nil
+
+ if !node.arguments.nil? || !node.block.nil?
+ arglist = s(node, :arglist).concat(visit_all(node.arguments&.arguments || []))
+ arglist << visit(node.block) if !node.block.nil?
+ end
+
+ s(node, :op_asgn1, visit(node.receiver), arglist, :"||", visit_write_value(node.value))
+ end
+
+ # foo[bar], = 1
+ # ^^^^^^^^
+ def visit_index_target_node(node)
+ arguments = visit_all(node.arguments&.arguments || [])
+ arguments << visit(node.block) unless node.block.nil?
+
+ s(node, :attrasgn, visit(node.receiver), :[]=).concat(arguments)
+ end
+
+ # @foo
+ # ^^^^
+ def visit_instance_variable_read_node(node)
+ s(node, :ivar, node.name)
+ end
+
+ # @foo = 1
+ # ^^^^^^^^
+ def visit_instance_variable_write_node(node)
+ s(node, :iasgn, node.name, visit_write_value(node.value))
+ end
+
+ # @foo += bar
+ # ^^^^^^^^^^^
+ def visit_instance_variable_operator_write_node(node)
+ s(node, :iasgn, node.name, s(node, :call, s(node, :ivar, node.name), node.binary_operator, visit_write_value(node.value)))
+ end
+
+ # @foo &&= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_and_write_node(node)
+ s(node, :op_asgn_and, s(node, :ivar, node.name), s(node, :iasgn, node.name, visit(node.value)))
+ end
+
+ # @foo ||= bar
+ # ^^^^^^^^^^^^
+ def visit_instance_variable_or_write_node(node)
+ s(node, :op_asgn_or, s(node, :ivar, node.name), s(node, :iasgn, node.name, visit(node.value)))
+ end
+
+ # @foo, = bar
+ # ^^^^
+ def visit_instance_variable_target_node(node)
+ s(node, :iasgn, node.name)
+ end
+
+ # 1
+ # ^
+ def visit_integer_node(node)
+ s(node, :lit, node.value)
+ end
+
+ # if /foo #{bar}/ then end
+ # ^^^^^^^^^^^^
+ def visit_interpolated_match_last_line_node(node)
+ parts = visit_interpolated_parts(node.parts)
+ regexp =
+ if parts.length == 1
+ s(node, :lit, Regexp.new(parts.first, node.options))
+ else
+ s(node, :dregx).concat(parts).tap do |result|
+ options = node.options
+ result << options if options != 0
+ end
+ end
+
+ s(node, :match, regexp)
+ end
+
+ # /foo #{bar}/
+ # ^^^^^^^^^^^^
+ def visit_interpolated_regular_expression_node(node)
+ parts = visit_interpolated_parts(node.parts)
+
+ if parts.length == 1
+ s(node, :lit, Regexp.new(parts.first, node.options))
+ else
+ s(node, :dregx).concat(parts).tap do |result|
+ options = node.options
+ result << options if options != 0
+ end
+ end
+ end
+
+ # "foo #{bar}"
+ # ^^^^^^^^^^^^
+ def visit_interpolated_string_node(node)
+ parts = visit_interpolated_parts(node.parts)
+ parts.length == 1 ? s(node, :str, parts.first) : s(node, :dstr).concat(parts)
+ end
+
+ # :"foo #{bar}"
+ # ^^^^^^^^^^^^^
+ def visit_interpolated_symbol_node(node)
+ parts = visit_interpolated_parts(node.parts)
+ parts.length == 1 ? s(node, :lit, parts.first.to_sym) : s(node, :dsym).concat(parts)
+ end
+
+ # `foo #{bar}`
+ # ^^^^^^^^^^^^
+ def visit_interpolated_x_string_node(node)
+ source = node.heredoc? ? node.parts.first : node
+ parts = visit_interpolated_parts(node.parts)
+ parts.length == 1 ? s(source, :xstr, parts.first) : s(source, :dxstr).concat(parts)
+ end
+
+ # Visit the interpolated content of the string-like node.
+ private def visit_interpolated_parts(parts)
+ visited = []
+
+ parts.each do |part|
+ result = visit(part)
+
+ if result[0] == :evstr && result[1]
+ if result[1][0] == :str
+ visited << result[1]
+ elsif result[1][0] == :dstr
+ visited.concat(result[1][1..-1])
+ else
+ visited << result
+ end
+ visited << :space
+ elsif result[0] == :dstr
+ if !visited.empty? && part.parts[0].is_a?(StringNode)
+ # If we are in the middle of an implicitly concatenated string,
+ # we should not have a bare string as the first part. In this
+ # case we need to visit just that first part and then we can
+ # push the rest of the parts onto the visited array.
+ result[1] = visit(part.parts[0])
+ end
+ visited.concat(result[1..-1])
+ else
+ visited << result
+ end
+ end
+
+ state = :beginning #: :beginning | :string_content | :interpolated_content
+ results = []
+
+ visited.each_with_index do |result, index|
+ case state
+ when :beginning
+ if result.is_a?(String)
+ results << result
+ state = :string_content
+ elsif result.is_a?(Array) && result[0] == :str
+ results << result[1]
+ state = :string_content
+ else
+ results << ""
+ results << result
+ state = :interpolated_content
+ end
+ when :string_content
+ if result == :space
+ # continue
+ elsif result.is_a?(String)
+ results[0] = "#{results[0]}#{result}"
+ elsif result.is_a?(Array) && result[0] == :str
+ results[0] = "#{results[0]}#{result[1]}"
+ else
+ results << result
+ state = :interpolated_content
+ end
+ when :interpolated_content
+ if result == :space
+ # continue
+ elsif visited[index - 1] != :space && result.is_a?(Array) && result[0] == :str && results[-1][0] == :str && (results[-1].line_max == result.line)
+ results[-1][1] = "#{results[-1][1]}#{result[1]}"
+ results[-1].line_max = result.line_max
+ else
+ results << result
+ end
+ end
+ end
+
+ results
+ end
+
+ # -> { it }
+ # ^^
+ def visit_it_local_variable_read_node(node)
+ s(node, :call, nil, :it)
+ end
+
+ # foo(bar: baz)
+ # ^^^^^^^^
+ def visit_keyword_hash_node(node)
+ s(node, :hash).concat(node.elements.flat_map { |element| visit(element) })
+ end
+
+ # def foo(**bar); end
+ # ^^^^^
+ #
+ # def foo(**); end
+ # ^^
+ def visit_keyword_rest_parameter_node(node)
+ :"**#{node.name}"
+ end
+
+ # -> {}
+ def visit_lambda_node(node)
+ parameters =
+ case node.parameters
+ when nil, ItParametersNode, NumberedParametersNode
+ 0
+ else
+ visit(node.parameters)
+ end
+
+ if node.body.nil?
+ s(node, :iter, s(node, :lambda), parameters)
+ else
+ s(node, :iter, s(node, :lambda), parameters, visit(node.body))
+ end
+ end
+
+ # foo
+ # ^^^
+ def visit_local_variable_read_node(node)
+ if node.name.match?(/^_\d$/)
+ s(node, :call, nil, node.name)
+ else
+ s(node, :lvar, node.name)
+ end
+ end
+
+ # foo = 1
+ # ^^^^^^^
+ def visit_local_variable_write_node(node)
+ s(node, :lasgn, node.name, visit_write_value(node.value))
+ end
+
+ # foo += bar
+ # ^^^^^^^^^^
+ def visit_local_variable_operator_write_node(node)
+ s(node, :lasgn, node.name, s(node, :call, s(node, :lvar, node.name), node.binary_operator, visit_write_value(node.value)))
+ end
+
+ # foo &&= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_and_write_node(node)
+ s(node, :op_asgn_and, s(node, :lvar, node.name), s(node, :lasgn, node.name, visit_write_value(node.value)))
+ end
+
+ # foo ||= bar
+ # ^^^^^^^^^^^
+ def visit_local_variable_or_write_node(node)
+ s(node, :op_asgn_or, s(node, :lvar, node.name), s(node, :lasgn, node.name, visit_write_value(node.value)))
+ end
+
+ # foo, = bar
+ # ^^^
+ def visit_local_variable_target_node(node)
+ s(node, :lasgn, node.name)
+ end
+
+ # if /foo/ then end
+ # ^^^^^
+ def visit_match_last_line_node(node)
+ s(node, :match, s(node, :lit, Regexp.new(node.unescaped, node.options)))
+ end
+
+ # foo in bar
+ # ^^^^^^^^^^
+ def visit_match_predicate_node(node)
+ s(node, :case, visit(node.value), s(node, :in, node.pattern.accept(copy_compiler(in_pattern: true)), nil), nil)
+ end
+
+ # foo => bar
+ # ^^^^^^^^^^
+ def visit_match_required_node(node)
+ s(node, :case, visit(node.value), s(node, :in, node.pattern.accept(copy_compiler(in_pattern: true)), nil), nil)
+ end
+
+ # /(?<foo>foo)/ =~ bar
+ # ^^^^^^^^^^^^^^^^^^^^
+ def visit_match_write_node(node)
+ s(node, :match2, visit(node.call.receiver), visit(node.call.arguments.arguments.first))
+ end
+
+ # A node that is missing from the syntax tree. This is only used in the
+ # case of a syntax error. The parser gem doesn't have such a concept, so
+ # we invent our own here.
+ def visit_error_recovery_node(node)
+ raise "Cannot visit error recovery node directly"
+ end
+
+ # module Foo; end
+ # ^^^^^^^^^^^^^^^
+ def visit_module_node(node)
+ name =
+ if node.constant_path.is_a?(ConstantReadNode)
+ node.name
+ else
+ visit(node.constant_path)
+ end
+
+ result =
+ if node.body.nil?
+ s(node, :module, name)
+ elsif node.body.is_a?(StatementsNode)
+ compiler = copy_compiler(in_def: false)
+ s(node, :module, name).concat(node.body.body.map { |child| child.accept(compiler) })
+ else
+ s(node, :module, name, node.body.accept(copy_compiler(in_def: false)))
+ end
+
+ attach_comments(result, node)
+ result
+ end
+
+ # foo, bar = baz
+ # ^^^^^^^^
+ def visit_multi_target_node(node)
+ targets = [*node.lefts]
+ targets << node.rest if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
+ targets.concat(node.rights)
+
+ s(node, :masgn, s(node, :array).concat(visit_all(targets)))
+ end
+
+ # foo, bar = baz
+ # ^^^^^^^^^^^^^^
+ def visit_multi_write_node(node)
+ targets = [*node.lefts]
+ targets << node.rest if !node.rest.nil? && !node.rest.is_a?(ImplicitRestNode)
+ targets.concat(node.rights)
+
+ value =
+ if node.value.is_a?(ArrayNode) && node.value.opening_loc.nil?
+ if node.value.elements.length == 1 && node.value.elements.first.is_a?(SplatNode)
+ visit(node.value.elements.first)
+ else
+ visit(node.value)
+ end
+ else
+ s(node.value, :to_ary, visit(node.value))
+ end
+
+ s(node, :masgn, s(node, :array).concat(visit_all(targets)), value)
+ end
+
+ # next
+ # ^^^^
+ #
+ # next foo
+ # ^^^^^^^^
+ def visit_next_node(node)
+ if node.arguments.nil?
+ s(node, :next)
+ elsif node.arguments.arguments.length == 1
+ argument = node.arguments.arguments.first
+ s(node, :next, argument.is_a?(SplatNode) ? s(node, :svalue, visit(argument)) : visit(argument))
+ else
+ s(node, :next, s(node, :array).concat(visit_all(node.arguments.arguments)))
+ end
+ end
+
+ # nil
+ # ^^^
+ def visit_nil_node(node)
+ s(node, :nil)
+ end
+
+ # def foo(&nil); end
+ # ^^^^
+ def visit_no_block_parameter_node(node)
+ :"&nil"
+ end
+
+ # def foo(**nil); end
+ # ^^^^^
+ def visit_no_keywords_parameter_node(node)
+ in_pattern ? s(node, :kwrest, :"**nil") : :"**nil"
+ end
+
+ # -> { _1 + _2 }
+ # ^^^^^^^^^^^^^^
+ def visit_numbered_parameters_node(node)
+ raise "Cannot visit numbered parameters directly"
+ end
+
+ # $1
+ # ^^
+ def visit_numbered_reference_read_node(node)
+ s(node, :nth_ref, node.number)
+ end
+
+ # def foo(bar: baz); end
+ # ^^^^^^^^
+ def visit_optional_keyword_parameter_node(node)
+ s(node, :kwarg, node.name, visit(node.value))
+ end
+
+ # def foo(bar = 1); end
+ # ^^^^^^^
+ def visit_optional_parameter_node(node)
+ s(node, :lasgn, node.name, visit(node.value))
+ end
+
+ # a or b
+ # ^^^^^^
+ def visit_or_node(node)
+ left = visit(node.left)
+
+ if left[0] == :or
+ # ruby_parser has the or keyword as right-associative as opposed to
+ # prism which has it as left-associative. We reverse that
+ # associativity here.
+ nest = left
+ nest = nest[2] while nest[2][0] == :or
+ nest[2] = s(node, :or, nest[2], visit(node.right))
+ left
+ else
+ s(node, :or, left, visit(node.right))
+ end
+ end
+
+ # def foo(bar, *baz); end
+ # ^^^^^^^^^
+ def visit_parameters_node(node)
+ children =
+ node.each_child_node.map do |element|
+ if element.is_a?(MultiTargetNode)
+ visit_destructured_parameter(element)
+ else
+ visit(element)
+ end
+ end
+
+ s(node, :args).concat(children)
+ end
+
+ # def foo((bar, baz)); end
+ # ^^^^^^^^^^
+ private def visit_destructured_parameter(node)
+ children =
+ [*node.lefts, *node.rest, *node.rights].map do |child|
+ case child
+ when RequiredParameterNode
+ visit(child)
+ when MultiTargetNode
+ visit_destructured_parameter(child)
+ when SplatNode
+ :"*#{child.expression&.name}"
+ else
+ raise
+ end
+ end
+
+ s(node, :masgn).concat(children)
+ end
+
+ # ()
+ # ^^
+ #
+ # (1)
+ # ^^^
+ def visit_parentheses_node(node)
+ if node.body.nil?
+ s(node, :nil)
+ else
+ visit(node.body)
+ end
+ end
+
+ # foo => ^(bar)
+ # ^^^^^^
+ def visit_pinned_expression_node(node)
+ node.expression.accept(copy_compiler(in_pattern: false))
+ end
+
+ # foo = 1 and bar => ^foo
+ # ^^^^
+ def visit_pinned_variable_node(node)
+ if node.variable.is_a?(LocalVariableReadNode) && node.variable.name.match?(/^_\d$/)
+ s(node, :lvar, node.variable.name)
+ else
+ visit(node.variable)
+ end
+ end
+
+ # END {}
+ def visit_post_execution_node(node)
+ s(node, :iter, s(node, :postexe), 0, visit(node.statements))
+ end
+
+ # BEGIN {}
+ def visit_pre_execution_node(node)
+ s(node, :iter, s(node, :preexe), 0, visit(node.statements))
+ end
+
+ # The top-level program node.
+ def visit_program_node(node)
+ visit(node.statements)
+ end
+
+ # 0..5
+ # ^^^^
+ def visit_range_node(node)
+ if !in_pattern && !node.left.nil? && !node.right.nil? && ([node.left.type, node.right.type] - %i[nil_node integer_node]).empty?
+ left = node.left.value if node.left.is_a?(IntegerNode)
+ right = node.right.value if node.right.is_a?(IntegerNode)
+ s(node, :lit, Range.new(left, right, node.exclude_end?))
+ else
+ s(node, node.exclude_end? ? :dot3 : :dot2, visit_range_bounds_node(node.left), visit_range_bounds_node(node.right))
+ end
+ end
+
+ # If the bounds of a range node are empty parentheses, then they do not
+ # get replaced by their usual s(:nil), but instead are s(:begin).
+ private def visit_range_bounds_node(node)
+ if node.is_a?(ParenthesesNode) && node.body.nil?
+ s(node, :begin)
+ else
+ visit(node)
+ end
+ end
+
+ # 1r
+ # ^^
+ def visit_rational_node(node)
+ s(node, :lit, node.value)
+ end
+
+ # redo
+ # ^^^^
+ def visit_redo_node(node)
+ s(node, :redo)
+ end
+
+ # /foo/
+ # ^^^^^
+ def visit_regular_expression_node(node)
+ s(node, :lit, Regexp.new(node.unescaped, node.options))
+ end
+
+ # def foo(bar:); end
+ # ^^^^
+ def visit_required_keyword_parameter_node(node)
+ s(node, :kwarg, node.name)
+ end
+
+ # def foo(bar); end
+ # ^^^
+ def visit_required_parameter_node(node)
+ node.name
+ end
+
+ # foo rescue bar
+ # ^^^^^^^^^^^^^^
+ def visit_rescue_modifier_node(node)
+ s(node, :rescue, visit(node.expression), s(node.rescue_expression, :resbody, s(node.rescue_expression, :array), visit(node.rescue_expression)))
+ end
+
+ # begin; rescue; end
+ # ^^^^^^^
+ def visit_rescue_node(node)
+ exceptions =
+ if node.exceptions.length == 1 && node.exceptions.first.is_a?(SplatNode)
+ visit(node.exceptions.first)
+ else
+ s(node, :array).concat(visit_all(node.exceptions))
+ end
+
+ if !node.reference.nil?
+ exceptions << (visit(node.reference) << s(node.reference, :gvar, :"$!"))
+ end
+
+ s(node, :resbody, exceptions).concat(node.statements.nil? ? [nil] : visit_all(node.statements.body))
+ end
+
+ # def foo(*bar); end
+ # ^^^^
+ #
+ # def foo(*); end
+ # ^
+ def visit_rest_parameter_node(node)
+ :"*#{node.name}"
+ end
+
+ # retry
+ # ^^^^^
+ def visit_retry_node(node)
+ s(node, :retry)
+ end
+
+ # return
+ # ^^^^^^
+ #
+ # return 1
+ # ^^^^^^^^
+ def visit_return_node(node)
+ if node.arguments.nil?
+ s(node, :return)
+ elsif node.arguments.arguments.length == 1
+ argument = node.arguments.arguments.first
+ s(node, :return, argument.is_a?(SplatNode) ? s(node, :svalue, visit(argument)) : visit(argument))
+ else
+ s(node, :return, s(node, :array).concat(visit_all(node.arguments.arguments)))
+ end
+ end
+
+ # self
+ # ^^^^
+ def visit_self_node(node)
+ s(node, :self)
+ end
+
+ # A shareable constant.
+ def visit_shareable_constant_node(node)
+ visit(node.write)
+ end
+
+ # class << self; end
+ # ^^^^^^^^^^^^^^^^^^
+ def visit_singleton_class_node(node)
+ s(node, :sclass, visit(node.expression)).tap do |sexp|
+ sexp << node.body.accept(copy_compiler(in_def: false)) unless node.body.nil?
+ end
+ end
+
+ # __ENCODING__
+ # ^^^^^^^^^^^^
+ def visit_source_encoding_node(node)
+ # TODO
+ s(node, :colon2, s(node, :const, :Encoding), :UTF_8)
+ end
+
+ # __FILE__
+ # ^^^^^^^^
+ def visit_source_file_node(node)
+ s(node, :str, node.filepath)
+ end
+
+ # __LINE__
+ # ^^^^^^^^
+ def visit_source_line_node(node)
+ s(node, :lit, node.location.start_line)
+ end
+
+ # foo(*bar)
+ # ^^^^
+ #
+ # def foo((bar, *baz)); end
+ # ^^^^
+ #
+ # def foo(*); bar(*); end
+ # ^
+ def visit_splat_node(node)
+ if node.expression.nil?
+ s(node, :splat)
+ else
+ s(node, :splat, visit(node.expression))
+ end
+ end
+
+ # A list of statements.
+ def visit_statements_node(node)
+ first, *rest = node.body
+
+ if rest.empty?
+ visit(first)
+ else
+ s(node, :block).concat(visit_all(node.body))
+ end
+ end
+
+ # "foo"
+ # ^^^^^
+ def visit_string_node(node)
+ unescaped = node.unescaped
+
+ if node.forced_binary_encoding?
+ unescaped = unescaped.dup
+ unescaped.force_encoding(Encoding::BINARY)
+ end
+
+ s(node, :str, unescaped)
+ end
+
+ # super(foo)
+ # ^^^^^^^^^^
+ def visit_super_node(node)
+ arguments = node.arguments&.arguments || []
+ block = node.block
+
+ if block.is_a?(BlockArgumentNode)
+ arguments << block
+ block = nil
+ end
+
+ visit_block(node, s(node, :super).concat(visit_all(arguments)), block)
+ end
+
+ # :foo
+ # ^^^^
+ def visit_symbol_node(node)
+ node.value == "!@" ? s(node, :lit, :"!@") : s(node, :lit, node.unescaped.to_sym)
+ end
+
+ # true
+ # ^^^^
+ def visit_true_node(node)
+ s(node, :true)
+ end
+
+ # undef foo
+ # ^^^^^^^^^
+ def visit_undef_node(node)
+ names = node.names.map { |name| s(node, :undef, visit(name)) }
+ names.length == 1 ? names.first : s(node, :block).concat(names)
+ end
+
+ # unless foo; bar end
+ # ^^^^^^^^^^^^^^^^^^^
+ #
+ # bar unless foo
+ # ^^^^^^^^^^^^^^
+ def visit_unless_node(node)
+ s(node, :if, visit(node.predicate), visit(node.else_clause), visit(node.statements))
+ end
+
+ # until foo; bar end
+ # ^^^^^^^^^^^^^^^^^
+ #
+ # bar until foo
+ # ^^^^^^^^^^^^^
+ def visit_until_node(node)
+ s(node, :until, visit(node.predicate), visit(node.statements), !node.begin_modifier?)
+ end
+
+ # case foo; when bar; end
+ # ^^^^^^^^^^^^^
+ def visit_when_node(node)
+ s(node, :when, s(node, :array).concat(visit_all(node.conditions))).concat(node.statements.nil? ? [nil] : visit_all(node.statements.body))
+ end
+
+ # while foo; bar end
+ # ^^^^^^^^^^^^^^^^^^
+ #
+ # bar while foo
+ # ^^^^^^^^^^^^^
+ def visit_while_node(node)
+ s(node, :while, visit(node.predicate), visit(node.statements), !node.begin_modifier?)
+ end
+
+ # `foo`
+ # ^^^^^
+ def visit_x_string_node(node)
+ result = s(node, :xstr, node.unescaped)
+
+ if node.heredoc?
+ result.line = node.content_loc.start_line
+ result.line_max = node.content_loc.end_line
+ end
+
+ result
+ end
+
+ # yield
+ # ^^^^^
+ #
+ # yield 1
+ # ^^^^^^^
+ def visit_yield_node(node)
+ s(node, :yield).concat(visit_all(node.arguments&.arguments || []))
+ end
+
+ private
+
+ # Attach prism comments to the given sexp.
+ def attach_comments(sexp, node)
+ return unless node.comments
+ return if node.comments.empty?
+
+ extra = node.location.start_line - node.comments.last.location.start_line
+ comments = node.comments.map(&:slice)
+ comments.concat([nil] * [0, extra].max)
+ sexp.comments = comments.join("\n")
+ end
+
+ # Create a new compiler with the given options.
+ def copy_compiler(in_def: self.in_def, in_pattern: self.in_pattern)
+ Compiler.new(file, in_def: in_def, in_pattern: in_pattern)
+ end
+
+ # Create a new Sexp object from the given prism node and arguments.
+ def s(node, *arguments)
+ result = Sexp.new(*arguments)
+ result.file = file
+ result.line = node.location.start_line
+ result.line_max = node.location.end_line
+ result
+ end
+
+ # Visit a block node, which will modify the AST by wrapping the given
+ # visited node in an iter node.
+ def visit_block(node, sexp, block)
+ if block.nil?
+ sexp
+ else
+ parameters =
+ case block.parameters
+ when nil, ItParametersNode, NumberedParametersNode
+ 0
+ else
+ visit(block.parameters)
+ end
+
+ if block.body.nil?
+ s(node, :iter, sexp, parameters)
+ else
+ s(node, :iter, sexp, parameters, visit(block.body))
+ end
+ end
+ end
+
+ # Pattern constants get wrapped in another layer of :const.
+ def visit_pattern_constant(node)
+ case node
+ when nil
+ # nothing
+ when ConstantReadNode
+ visit(node)
+ else
+ s(node, :const, visit(node))
+ end
+ end
+
+ # Visit the value of a write, which will be on the right-hand side of
+ # a write operator. Because implicit arrays can have splats, those could
+ # potentially be wrapped in an svalue node.
+ def visit_write_value(node)
+ if node.is_a?(ArrayNode) && node.opening_loc.nil?
+ if node.elements.length == 1 && node.elements.first.is_a?(SplatNode)
+ s(node, :svalue, visit(node.elements.first))
+ else
+ s(node, :svalue, visit(node))
+ end
+ else
+ visit(node)
+ end
+ end
+ end
+
+ private_constant :Compiler
+
+ # Parse the given source and translate it into the seattlerb/ruby_parser
+ # gem's Sexp format.
+ def parse(source, filepath = "(string)")
+ translate(Prism.parse(source, filepath: filepath, partial_script: true), filepath)
+ end
+
+ # Parse the given file and translate it into the seattlerb/ruby_parser
+ # gem's Sexp format.
+ def parse_file(filepath)
+ translate(Prism.parse_file(filepath, partial_script: true), filepath)
+ end
+
+ # Parse the give file and translate it into the
+ # seattlerb/ruby_parser gem's Sexp format. This method is
+ # provided for API compatibility to RubyParser and takes an
+ # optional +timeout+ argument.
+ def process(ruby, file = "(string)", timeout = nil)
+ Timeout.timeout(timeout) { parse(ruby, file) }
+ end
+
+ class << self
+ # Parse the given source and translate it into the seattlerb/ruby_parser
+ # gem's Sexp format.
+ def parse(source, filepath = "(string)")
+ new.parse(source, filepath)
+ end
+
+ # Parse the given file and translate it into the seattlerb/ruby_parser
+ # gem's Sexp format.
+ def parse_file(filepath)
+ new.parse_file(filepath)
+ end
+ end
+
+ private
+
+ # Translate the given parse result and filepath into the
+ # seattlerb/ruby_parser gem's Sexp format.
+ def translate(result, filepath)
+ if result.failure?
+ error = result.errors.first
+ raise ::RubyParser::SyntaxError, "#{filepath}:#{error.location.start_line} :: #{error.message}"
+ end
+
+ result.attach_comments!
+ result.value.accept(Compiler.new(filepath))
+ end
+ end
+ end
+end
diff --git a/lib/pstore.rb b/lib/pstore.rb
deleted file mode 100644
index 97df3c1509..0000000000
--- a/lib/pstore.rb
+++ /dev/null
@@ -1,731 +0,0 @@
-# frozen_string_literal: true
-# = PStore -- Transactional File Storage for Ruby Objects
-#
-# pstore.rb -
-# originally by matz
-# documentation by Kev Jackson and James Edward Gray II
-# improved by Hongli Lai
-#
-# See PStore for documentation.
-
-require "digest"
-
-# \PStore implements a file based persistence mechanism based on a Hash.
-# User code can store hierarchies of Ruby objects (values)
-# into the data store 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 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 marshalled,
-# for example.
-#
-# There are three important concepts here (details at the links):
-#
-# - {Store}[rdoc-ref:PStore@The+Store]: a store is an instance of \PStore.
-# - {Entries}[rdoc-ref:PStore@Entries]: the store is hash-like;
-# each entry is the key for a stored object.
-# - {Transactions}[rdoc-ref:PStore@Transactions]: each transaction is a collection
-# of prospective changes to the store;
-# a transaction is defined in the block given with a call
-# to PStore#transaction.
-#
-# == About the Examples
-#
-# Examples on this page need a store that has known properties.
-# They can get a new (and populated) store by calling thus:
-#
-# example_store do |store|
-# # Example code using store goes here.
-# end
-#
-# All we really need to know about +example_store+
-# is that it yields a fresh store with a known population of entries;
-# its implementation:
-#
-# require 'pstore'
-# require 'tempfile'
-# # Yield a pristine store for use in examples.
-# def example_store
-# # Create the store in a temporary file.
-# Tempfile.create do |file|
-# store = PStore.new(file)
-# # Populate the store.
-# store.transaction do
-# store[:foo] = 0
-# store[:bar] = 1
-# store[:baz] = 2
-# end
-# yield store
-# end
-# end
-#
-# == The Store
-#
-# The contents of the store are maintained in a file whose path is specified
-# when the store is created (see PStore.new).
-# The objects are stored and retrieved using
-# module Marshal, which means that certain objects cannot be added to the store;
-# see {Marshal::dump}[rdoc-ref:Marshal.dump].
-#
-# == Entries
-#
-# A store may have any number of entries.
-# Each entry has a key and a value, just as in a hash:
-#
-# - Key: as in a hash, the key can be (almost) any object;
-# see {Hash Keys}[rdoc-ref:Hash@Hash+Keys].
-# You may find it convenient to keep it simple by using only
-# symbols or strings as keys.
-# - Value: the value may be any object that can be marshalled by \Marshal
-# (see {Marshal::dump}[rdoc-ref:Marshal.dump])
-# and in fact may be a collection
-# (e.g., an array, a hash, a set, a range, etc).
-# That collection may in turn contain nested objects,
-# including collections, to any depth;
-# those objects must also be \Marshal-able.
-# See {Hierarchical Values}[rdoc-ref:PStore@Hierarchical+Values].
-#
-# == Transactions
-#
-# === The Transaction Block
-#
-# The block given with a call to method #transaction#
-# contains a _transaction_,
-# which consists of calls to \PStore methods that
-# read from or write to the store
-# (that is, all \PStore methods except #transaction itself,
-# #path, and Pstore.new):
-#
-# example_store do |store|
-# store.transaction do
-# store.keys # => [:foo, :bar, :baz]
-# store[:bat] = 3
-# store.keys # => [:foo, :bar, :baz, :bat]
-# end
-# end
-#
-# Execution of the transaction is deferred until the block exits,
-# and is executed _atomically_ (all-or-nothing):
-# either all transaction calls are executed, or none are.
-# This maintains the integrity of the store.
-#
-# Other code in the block (including even calls to #path and PStore.new)
-# is executed immediately, not deferred.
-#
-# The transaction block:
-#
-# - May not contain a nested call to #transaction.
-# - Is the only context where methods that read from or write to
-# the store are allowed.
-#
-# As seen above, changes in a transaction are made automatically
-# when the block exits.
-# The block may be exited early by calling method #commit or #abort.
-#
-# - Method #commit triggers the update to the store and exits the block:
-#
-# example_store do |store|
-# store.transaction do
-# store.keys # => [:foo, :bar, :baz]
-# store[:bat] = 3
-# store.commit
-# fail 'Cannot get here'
-# end
-# store.transaction do
-# # Update was completed.
-# store.keys # => [:foo, :bar, :baz, :bat]
-# end
-# end
-#
-# - Method #abort discards the update to the store and exits the block:
-#
-# example_store do |store|
-# store.transaction do
-# store.keys # => [:foo, :bar, :baz]
-# store[:bat] = 3
-# store.abort
-# fail 'Cannot get here'
-# end
-# store.transaction do
-# # Update was not completed.
-# store.keys # => [:foo, :bar, :baz]
-# end
-# end
-#
-# === Read-Only Transactions
-#
-# By default, a transaction allows both reading from and writing to
-# the store:
-#
-# store.transaction do
-# # Read-write transaction.
-# # Any code except a call to #transaction is allowed here.
-# end
-#
-# If argument +read_only+ is passed as +true+,
-# only reading is allowed:
-#
-# store.transaction(true) do
-# # Read-only transaction:
-# # Calls to #transaction, #[]=, and #delete are not allowed here.
-# end
-#
-# == Hierarchical Values
-#
-# The value for an entry may be a simple object (as seen above).
-# It may also be a hierarchy of objects nested to any depth:
-#
-# deep_store = PStore.new('deep.store')
-# deep_store.transaction do
-# array_of_hashes = [{}, {}, {}]
-# deep_store[:array_of_hashes] = array_of_hashes
-# deep_store[:array_of_hashes] # => [{}, {}, {}]
-# hash_of_arrays = {foo: [], bar: [], baz: []}
-# deep_store[:hash_of_arrays] = hash_of_arrays
-# deep_store[:hash_of_arrays] # => {:foo=>[], :bar=>[], :baz=>[]}
-# deep_store[:hash_of_arrays][:foo].push(:bat)
-# deep_store[:hash_of_arrays] # => {:foo=>[:bat], :bar=>[], :baz=>[]}
-# end
-#
-# And recall that you can use
-# {dig methods}[rdoc-ref:dig_methods.rdoc]
-# in a returned hierarchy of objects.
-#
-# == Working with the Store
-#
-# === Creating a Store
-#
-# Use method PStore.new to create a store.
-# The new store creates or opens its containing file:
-#
-# store = PStore.new('t.store')
-#
-# === Modifying the Store
-#
-# Use method #[]= to update or create an entry:
-#
-# example_store do |store|
-# store.transaction do
-# store[:foo] = 1 # Update.
-# store[:bam] = 1 # Create.
-# end
-# end
-#
-# Use method #delete to remove an entry:
-#
-# example_store do |store|
-# store.transaction do
-# store.delete(:foo)
-# store[:foo] # => nil
-# end
-# end
-#
-# === Retrieving Values
-#
-# Use method #fetch (allows default) or #[] (defaults to +nil+)
-# to retrieve an entry:
-#
-# example_store do |store|
-# store.transaction do
-# store[:foo] # => 0
-# store[:nope] # => nil
-# store.fetch(:baz) # => 2
-# store.fetch(:nope, nil) # => nil
-# store.fetch(:nope) # Raises exception.
-# end
-# end
-#
-# === Querying the Store
-#
-# Use method #key? to determine whether a given key exists:
-#
-# example_store do |store|
-# store.transaction do
-# store.key?(:foo) # => true
-# end
-# end
-#
-# Use method #keys to retrieve keys:
-#
-# example_store do |store|
-# store.transaction do
-# store.keys # => [:foo, :bar, :baz]
-# end
-# end
-#
-# Use method #path to retrieve the path to the store's underlying file;
-# this method may be called from outside a transaction block:
-#
-# store = PStore.new('t.store')
-# store.path # => "t.store"
-#
-# == Transaction Safety
-#
-# For transaction safety, see:
-#
-# - Optional argument +thread_safe+ at method PStore.new.
-# - Attribute #ultra_safe.
-#
-# Needless to say, if you're storing valuable data with \PStore, then you should
-# backup the \PStore file from time to time.
-#
-# == An Example Store
-#
-# require "pstore"
-#
-# # A mock wiki object.
-# class WikiPage
-#
-# attr_reader :page_name
-#
-# def initialize(page_name, author, contents)
-# @page_name = page_name
-# @revisions = Array.new
-# add_revision(author, contents)
-# end
-#
-# def add_revision(author, contents)
-# @revisions << {created: Time.now,
-# author: author,
-# contents: contents}
-# end
-#
-# def wiki_page_references
-# [@page_name] + @revisions.last[:contents].scan(/\b(?:[A-Z]+[a-z]+){2,}/)
-# end
-#
-# end
-#
-# # Create a new wiki page.
-# home_page = WikiPage.new("HomePage", "James Edward Gray II",
-# "A page about the JoysOfDocumentation..." )
-#
-# wiki = PStore.new("wiki_pages.pstore")
-# # Update page data and the index together, or not at all.
-# wiki.transaction do
-# # Store page.
-# wiki[home_page.page_name] = home_page
-# # Create page index.
-# wiki[:wiki_index] ||= Array.new
-# # Update wiki index.
-# wiki[:wiki_index].push(*home_page.wiki_page_references)
-# end
-#
-# # Read wiki data, setting argument read_only to true.
-# wiki.transaction(true) do
-# wiki.keys.each do |key|
-# puts key
-# puts wiki[key]
-# end
-# end
-#
-class PStore
- VERSION = "0.1.2"
-
- RDWR_ACCESS = {mode: IO::RDWR | IO::CREAT | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
- RD_ACCESS = {mode: IO::RDONLY | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
- WR_ACCESS = {mode: IO::WRONLY | IO::CREAT | IO::TRUNC | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
-
- # The error type thrown by all PStore methods.
- class Error < StandardError
- end
-
- # Whether \PStore should do its best to prevent file corruptions,
- # even when an unlikely error (such as memory-error or filesystem error) occurs:
- #
- # - +true+: changes are posted by creating a temporary file,
- # writing the updated data to it, then renaming the file to the given #path.
- # File integrity is maintained.
- # Note: has effect only if the filesystem has atomic file rename
- # (as do POSIX platforms Linux, MacOS, FreeBSD and others).
- #
- # - +false+ (the default): changes are posted by rewinding the open file
- # and writing the updated data.
- # File integrity is maintained if the filesystem raises
- # no unexpected I/O error;
- # if such an error occurs during a write to the store,
- # the file may become corrupted.
- #
- attr_accessor :ultra_safe
-
- # Returns a new \PStore object.
- #
- # Argument +file+ is the path to the file in which objects are to be stored;
- # if the file exists, it should be one that was written by \PStore.
- #
- # path = 't.store'
- # store = PStore.new(path)
- #
- # A \PStore object is
- # {reentrant}[https://en.wikipedia.org/wiki/Reentrancy_(computing)].
- # If argument +thread_safe+ is given as +true+,
- # the object is also thread-safe (at the cost of a small performance penalty):
- #
- # store = PStore.new(path, true)
- #
- def initialize(file, thread_safe = false)
- dir = File::dirname(file)
- unless File::directory? dir
- raise PStore::Error, format("directory %s does not exist", dir)
- end
- if File::exist? file and not File::readable? file
- raise PStore::Error, format("file %s not readable", file)
- end
- @filename = file
- @abort = false
- @ultra_safe = false
- @thread_safe = thread_safe
- @lock = Thread::Mutex.new
- end
-
- # Raises PStore::Error if the calling code is not in a PStore#transaction.
- def in_transaction
- raise PStore::Error, "not in transaction" unless @lock.locked?
- end
- #
- # Raises PStore::Error if the calling code is not in a PStore#transaction or
- # if the code is in a read-only PStore#transaction.
- #
- def in_transaction_wr
- in_transaction
- raise PStore::Error, "in read-only transaction" if @rdonly
- end
- private :in_transaction, :in_transaction_wr
-
- # Returns the value for the given +key+ if the key exists.
- # +nil+ otherwise;
- # if not +nil+, the returned value is an object or a hierarchy of objects:
- #
- # example_store do |store|
- # store.transaction do
- # store[:foo] # => 0
- # store[:nope] # => nil
- # end
- # end
- #
- # Returns +nil+ if there is no such key.
- #
- # See also {Hierarchical Values}[rdoc-ref:PStore@Hierarchical+Values].
- #
- # Raises an exception if called outside a transaction block.
- def [](key)
- in_transaction
- @table[key]
- end
-
- # Like #[], except that it accepts a default value for the store.
- # If the +key+ does not exist:
- #
- # - Raises an exception if +default+ is +PStore::Error+.
- # - Returns the value of +default+ otherwise:
- #
- # example_store do |store|
- # store.transaction do
- # store.fetch(:nope, nil) # => nil
- # store.fetch(:nope) # Raises an exception.
- # end
- # end
- #
- # Raises an exception if called outside a transaction block.
- def fetch(key, default=PStore::Error)
- in_transaction
- unless @table.key? key
- if default == PStore::Error
- raise PStore::Error, format("undefined key `%s'", key)
- else
- return default
- end
- end
- @table[key]
- end
-
- # Creates or replaces the value for the given +key+:
- #
- # example_store do |store|
- # temp.transaction do
- # temp[:bat] = 3
- # end
- # end
- #
- # See also {Hierarchical Values}[rdoc-ref:PStore@Hierarchical+Values].
- #
- # Raises an exception if called outside a transaction block.
- def []=(key, value)
- in_transaction_wr
- @table[key] = value
- end
-
- # Removes and returns the value at +key+ if it exists:
- #
- # example_store do |store|
- # store.transaction do
- # store[:bat] = 3
- # store.delete(:bat)
- # end
- # end
- #
- # Returns +nil+ if there is no such key.
- #
- # Raises an exception if called outside a transaction block.
- def delete(key)
- in_transaction_wr
- @table.delete key
- end
-
- # Returns an array of the existing keys:
- #
- # example_store do |store|
- # store.transaction do
- # store.keys # => [:foo, :bar, :baz]
- # end
- # end
- #
- # Raises an exception if called outside a transaction block.
- def keys
- in_transaction
- @table.keys
- end
- alias roots keys
-
- # Returns +true+ if +key+ exists, +false+ otherwise:
- #
- # example_store do |store|
- # store.transaction do
- # store.key?(:foo) # => true
- # end
- # end
- #
- # Raises an exception if called outside a transaction block.
- def key?(key)
- in_transaction
- @table.key? key
- end
- alias root? key?
-
- # Returns the string file path used to create the store:
- #
- # store.path # => "flat.store"
- #
- def path
- @filename
- end
-
- # Exits the current transaction block, committing any changes
- # specified in the transaction block.
- # See {Committing or Aborting}[rdoc-ref:PStore@Committing+or+Aborting].
- #
- # Raises an exception if called outside a transaction block.
- def commit
- in_transaction
- @abort = false
- throw :pstore_abort_transaction
- end
-
- # Exits the current transaction block, discarding any changes
- # specified in the transaction block.
- # See {Committing or Aborting}[rdoc-ref:PStore@Committing+or+Aborting].
- #
- # Raises an exception if called outside a transaction block.
- def abort
- in_transaction
- @abort = true
- throw :pstore_abort_transaction
- end
-
- # Opens a transaction block for the store.
- # See {Transactions}[rdoc-ref:PStore@Transactions].
- #
- # With argument +read_only+ as +false+, the block may both read from
- # and write to the store.
- #
- # With argument +read_only+ as +true+, the block may not include calls
- # to #transaction, #[]=, or #delete.
- #
- # Raises an exception if called within a transaction block.
- def transaction(read_only = false) # :yields: pstore
- value = nil
- if !@thread_safe
- raise PStore::Error, "nested transaction" unless @lock.try_lock
- else
- begin
- @lock.lock
- rescue ThreadError
- raise PStore::Error, "nested transaction"
- end
- end
- begin
- @rdonly = read_only
- @abort = false
- file = open_and_lock_file(@filename, read_only)
- if file
- begin
- @table, checksum, original_data_size = load_data(file, read_only)
-
- catch(:pstore_abort_transaction) do
- value = yield(self)
- end
-
- if !@abort && !read_only
- save_data(checksum, original_data_size, file)
- end
- ensure
- file.close
- end
- else
- # This can only occur if read_only == true.
- @table = {}
- catch(:pstore_abort_transaction) do
- value = yield(self)
- end
- end
- ensure
- @lock.unlock
- end
- value
- end
-
- private
- # Constant for relieving Ruby's garbage collector.
- CHECKSUM_ALGO = %w[SHA512 SHA384 SHA256 SHA1 RMD160 MD5].each do |algo|
- begin
- break Digest(algo)
- rescue LoadError
- end
- end
- EMPTY_STRING = ""
- EMPTY_MARSHAL_DATA = Marshal.dump({})
- EMPTY_MARSHAL_CHECKSUM = CHECKSUM_ALGO.digest(EMPTY_MARSHAL_DATA)
-
- #
- # Open the specified filename (either in read-only mode or in
- # read-write mode) and lock it for reading or writing.
- #
- # The opened File object will be returned. If _read_only_ is true,
- # and the file does not exist, then nil will be returned.
- #
- # All exceptions are propagated.
- #
- def open_and_lock_file(filename, read_only)
- if read_only
- begin
- file = File.new(filename, **RD_ACCESS)
- begin
- file.flock(File::LOCK_SH)
- return file
- rescue
- file.close
- raise
- end
- rescue Errno::ENOENT
- return nil
- end
- else
- file = File.new(filename, **RDWR_ACCESS)
- file.flock(File::LOCK_EX)
- return file
- end
- end
-
- # Load the given PStore file.
- # If +read_only+ is true, the unmarshalled Hash will be returned.
- # If +read_only+ is false, a 3-tuple will be returned: the unmarshalled
- # Hash, a checksum of the data, and the size of the data.
- def load_data(file, read_only)
- if read_only
- begin
- table = load(file)
- raise Error, "PStore file seems to be corrupted." unless table.is_a?(Hash)
- rescue EOFError
- # This seems to be a newly-created file.
- table = {}
- end
- table
- else
- data = file.read
- if data.empty?
- # This seems to be a newly-created file.
- table = {}
- checksum = empty_marshal_checksum
- size = empty_marshal_data.bytesize
- else
- table = load(data)
- checksum = CHECKSUM_ALGO.digest(data)
- size = data.bytesize
- raise Error, "PStore file seems to be corrupted." unless table.is_a?(Hash)
- end
- data.replace(EMPTY_STRING)
- [table, checksum, size]
- end
- end
-
- def on_windows?
- is_windows = RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince/
- self.class.__send__(:define_method, :on_windows?) do
- is_windows
- end
- is_windows
- end
-
- def save_data(original_checksum, original_file_size, file)
- new_data = dump(@table)
-
- if new_data.bytesize != original_file_size || CHECKSUM_ALGO.digest(new_data) != original_checksum
- if @ultra_safe && !on_windows?
- # Windows doesn't support atomic file renames.
- save_data_with_atomic_file_rename_strategy(new_data, file)
- else
- save_data_with_fast_strategy(new_data, file)
- end
- end
-
- new_data.replace(EMPTY_STRING)
- end
-
- def save_data_with_atomic_file_rename_strategy(data, file)
- temp_filename = "#{@filename}.tmp.#{Process.pid}.#{rand 1000000}"
- temp_file = File.new(temp_filename, **WR_ACCESS)
- begin
- temp_file.flock(File::LOCK_EX)
- temp_file.write(data)
- temp_file.flush
- File.rename(temp_filename, @filename)
- rescue
- File.unlink(temp_file) rescue nil
- raise
- ensure
- temp_file.close
- end
- end
-
- def save_data_with_fast_strategy(data, file)
- file.rewind
- file.write(data)
- file.truncate(data.bytesize)
- end
-
-
- # This method is just a wrapped around Marshal.dump
- # to allow subclass overriding used in YAML::Store.
- def dump(table) # :nodoc:
- Marshal::dump(table)
- end
-
- # This method is just a wrapped around Marshal.load.
- # to allow subclass overriding used in YAML::Store.
- def load(content) # :nodoc:
- Marshal::load(content)
- end
-
- def empty_marshal_data
- EMPTY_MARSHAL_DATA
- end
- def empty_marshal_checksum
- EMPTY_MARSHAL_CHECKSUM
- end
-end
diff --git a/lib/pstore/pstore.gemspec b/lib/pstore/pstore.gemspec
deleted file mode 100644
index 8425795afe..0000000000
--- a/lib/pstore/pstore.gemspec
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Transactional File Storage for Ruby Objects}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/pstore"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "https://github.com/ruby/pstore"
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/racc.rb b/lib/racc.rb
deleted file mode 100644
index f6e4ac03a8..0000000000
--- a/lib/racc.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'racc/compat'
-require 'racc/debugflags'
-require 'racc/grammar'
-require 'racc/state'
-require 'racc/exception'
-require 'racc/info'
diff --git a/lib/racc/compat.rb b/lib/racc/compat.rb
deleted file mode 100644
index 62f4f630be..0000000000
--- a/lib/racc/compat.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-unless Object.method_defined?(:__send)
- class Object
- alias __send __send__
- end
-end
-
-unless Object.method_defined?(:__send!)
- class Object
- alias __send! __send__
- end
-end
-
-unless Array.method_defined?(:map!)
- class Array
- if Array.method_defined?(:collect!)
- alias map! collect!
- else
- alias map! filter
- end
- end
-end
diff --git a/lib/racc/debugflags.rb b/lib/racc/debugflags.rb
deleted file mode 100644
index ee34cf2314..0000000000
--- a/lib/racc/debugflags.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
-
- class DebugFlags
- def DebugFlags.parse_option_string(s)
- parse = rule = token = state = la = prec = conf = false
- s.split(//).each do |ch|
- case ch
- when 'p' then parse = true
- when 'r' then rule = true
- when 't' then token = true
- when 's' then state = true
- when 'l' then la = true
- when 'c' then prec = true
- when 'o' then conf = true
- else
- raise "unknown debug flag char: #{ch.inspect}"
- end
- end
- new(parse, rule, token, state, la, prec, conf)
- end
-
- def initialize(parse = false, rule = false, token = false, state = false,
- la = false, prec = false, conf = false)
- @parse = parse
- @rule = rule
- @token = token
- @state = state
- @la = la
- @prec = prec
- @any = (parse || rule || token || state || la || prec)
- @status_logging = conf
- end
-
- attr_reader :parse
- attr_reader :rule
- attr_reader :token
- attr_reader :state
- attr_reader :la
- attr_reader :prec
-
- def any?
- @any
- end
-
- attr_reader :status_logging
- end
-
-end
diff --git a/lib/racc/exception.rb b/lib/racc/exception.rb
deleted file mode 100644
index c11dc2e43e..0000000000
--- a/lib/racc/exception.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
- class Error < StandardError; end
- class CompileError < Error; end
-end
diff --git a/lib/racc/grammar.rb b/lib/racc/grammar.rb
deleted file mode 100644
index 01c4c3df69..0000000000
--- a/lib/racc/grammar.rb
+++ /dev/null
@@ -1,1118 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc/compat'
-require 'racc/iset'
-require 'racc/sourcetext'
-require 'racc/logfilegenerator'
-require 'racc/exception'
-require 'forwardable'
-
-module Racc
-
- class Grammar
-
- def initialize(debug_flags = DebugFlags.new)
- @symboltable = SymbolTable.new
- @debug_symbol = debug_flags.token
- @rules = [] # :: [Rule]
- @start = nil
- @n_expected_srconflicts = nil
- @prec_table = []
- @prec_table_closed = false
- @closed = false
- @states = nil
- end
-
- attr_reader :start
- attr_reader :symboltable
- attr_accessor :n_expected_srconflicts
-
- def [](x)
- @rules[x]
- end
-
- def each_rule(&block)
- @rules.each(&block)
- end
-
- alias each each_rule
-
- def each_index(&block)
- @rules.each_index(&block)
- end
-
- def each_with_index(&block)
- @rules.each_with_index(&block)
- end
-
- def size
- @rules.size
- end
-
- def to_s
- "<Racc::Grammar>"
- end
-
- extend Forwardable
-
- def_delegator "@symboltable", :each, :each_symbol
- def_delegator "@symboltable", :each_terminal
- def_delegator "@symboltable", :each_nonterminal
-
- def intern(value, dummy = false)
- @symboltable.intern(value, dummy)
- end
-
- def symbols
- @symboltable.symbols
- end
-
- def nonterminal_base
- @symboltable.nt_base
- end
-
- def useless_nonterminal_exist?
- n_useless_nonterminals() != 0
- end
-
- def n_useless_nonterminals
- @n_useless_nonterminals ||= each_useless_nonterminal.count
- end
-
- def each_useless_nonterminal
- return to_enum __method__ unless block_given?
-
- @symboltable.each_nonterminal do |sym|
- yield sym if sym.useless?
- end
- end
-
- def useless_rule_exist?
- n_useless_rules() != 0
- end
-
- def n_useless_rules
- @n_useless_rules ||= each_useless_rule.count
- end
-
- def each_useless_rule
- return to_enum __method__ unless block_given?
-
- each do |r|
- yield r if r.useless?
- end
- end
-
- def nfa
- (@states ||= States.new(self)).nfa
- end
-
- def dfa
- (@states ||= States.new(self)).dfa
- end
-
- alias states dfa
-
- def state_transition_table
- states().state_transition_table
- end
-
- def parser_class
- states = states() # cache
- if $DEBUG
- srcfilename = caller(1).first.slice(/\A(.*?):/, 1)
- begin
- write_log srcfilename + ".output"
- rescue SystemCallError
- end
- report = lambda {|s| $stderr.puts "racc: #{srcfilename}: #{s}" }
- if states.should_report_srconflict?
- report["#{states.n_srconflicts} shift/reduce conflicts"]
- end
- if states.rrconflict_exist?
- report["#{states.n_rrconflicts} reduce/reduce conflicts"]
- end
- g = states.grammar
- if g.useless_nonterminal_exist?
- report["#{g.n_useless_nonterminals} useless nonterminals"]
- end
- if g.useless_rule_exist?
- report["#{g.n_useless_rules} useless rules"]
- end
- end
- states.state_transition_table.parser_class
- end
-
- def write_log(path)
- File.open(path, 'w') {|f|
- LogFileGenerator.new(states()).output f
- }
- end
-
- #
- # Grammar Definition Interface
- #
-
- def add(rule)
- raise ArgumentError, "rule added after the Grammar closed" if @closed
- @rules.push rule
- end
-
- def added?(sym)
- @rules.detect {|r| r.target == sym }
- end
-
- def start_symbol=(s)
- raise CompileError, "start symbol set twice'" if @start
- @start = s
- end
-
- def declare_precedence(assoc, syms)
- raise CompileError, "precedence table defined twice" if @prec_table_closed
- @prec_table.push [assoc, syms]
- end
-
- def end_precedence_declaration(reverse)
- @prec_table_closed = true
- return if @prec_table.empty?
- table = reverse ? @prec_table.reverse : @prec_table
- table.each_with_index do |(assoc, syms), idx|
- syms.each do |sym|
- sym.assoc = assoc
- sym.precedence = idx
- end
- end
- end
-
- #
- # Dynamic Generation Interface
- #
-
- def Grammar.define(&block)
- env = DefinitionEnv.new
- env.instance_eval(&block)
- env.grammar
- end
-
- class DefinitionEnv
- def initialize
- @grammar = Grammar.new
- @seqs = Hash.new(0)
- @delayed = []
- end
-
- def grammar
- flush_delayed
- @grammar.each do |rule|
- if rule.specified_prec
- rule.specified_prec = @grammar.intern(rule.specified_prec)
- end
- end
- @grammar.init
- @grammar
- end
-
- def precedence_table(&block)
- env = PrecedenceDefinitionEnv.new(@grammar)
- env.instance_eval(&block)
- @grammar.end_precedence_declaration env.reverse
- end
-
- def method_missing(mid, *args, &block)
- unless mid.to_s[-1,1] == '='
- super # raises NoMethodError
- end
- target = @grammar.intern(mid.to_s.chop.intern)
- unless args.size == 1
- raise ArgumentError, "too many arguments for #{mid} (#{args.size} for 1)"
- end
- _add target, args.first
- end
-
- def _add(target, x)
- case x
- when Sym
- @delayed.each do |rule|
- rule.replace x, target if rule.target == x
- end
- @grammar.symboltable.delete x
- else
- x.each_rule do |r|
- r.target = target
- @grammar.add r
- end
- end
- flush_delayed
- end
-
- def _delayed_add(rule)
- @delayed.push rule
- end
-
- def _added?(sym)
- @grammar.added?(sym) or @delayed.detect {|r| r.target == sym }
- end
-
- def flush_delayed
- return if @delayed.empty?
- @delayed.each do |rule|
- @grammar.add rule
- end
- @delayed.clear
- end
-
- def seq(*list, &block)
- Rule.new(nil, list.map {|x| _intern(x) }, UserAction.proc(block))
- end
-
- def null(&block)
- seq(&block)
- end
-
- def action(&block)
- id = "@#{@seqs["action"] += 1}".intern
- _delayed_add Rule.new(@grammar.intern(id), [], UserAction.proc(block))
- id
- end
-
- alias _ action
-
- def option(sym, default = nil, &block)
- _defmetasyntax("option", _intern(sym), block) {|target|
- seq() { default } | seq(sym)
- }
- end
-
- def many(sym, &block)
- _defmetasyntax("many", _intern(sym), block) {|target|
- seq() { [] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def many1(sym, &block)
- _defmetasyntax("many1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def separated_by(sep, sym, &block)
- option(separated_by1(sep, sym), [], &block)
- end
-
- def separated_by1(sep, sym, &block)
- _defmetasyntax("separated_by1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sep, sym) {|list, _, x| list.push x; list }
- }
- end
-
- def _intern(x)
- case x
- when Symbol, String
- @grammar.intern(x)
- when Racc::Sym
- x
- else
- raise TypeError, "wrong type #{x.class} (expected Symbol/String/Racc::Sym)"
- end
- end
-
- private
-
- def _defmetasyntax(type, id, action, &block)
- if action
- idbase = "#{type}@#{id}-#{@seqs[type] += 1}"
- target = _wrap(idbase, "#{idbase}-core", action)
- _register("#{idbase}-core", &block)
- else
- target = _register("#{type}@#{id}", &block)
- end
- @grammar.intern(target)
- end
-
- def _register(target_name)
- target = target_name.intern
- unless _added?(@grammar.intern(target))
- yield(target).each_rule do |rule|
- rule.target = @grammar.intern(target)
- _delayed_add rule
- end
- end
- target
- end
-
- def _wrap(target_name, sym, block)
- target = target_name.intern
- _delayed_add Rule.new(@grammar.intern(target),
- [@grammar.intern(sym.intern)],
- UserAction.proc(block))
- target
- end
- end
-
- class PrecedenceDefinitionEnv
- def initialize(g)
- @grammar = g
- @prechigh_seen = false
- @preclow_seen = false
- @reverse = false
- end
-
- attr_reader :reverse
-
- def higher
- if @prechigh_seen
- raise CompileError, "prechigh used twice"
- end
- @prechigh_seen = true
- end
-
- def lower
- if @preclow_seen
- raise CompileError, "preclow used twice"
- end
- if @prechigh_seen
- @reverse = true
- end
- @preclow_seen = true
- end
-
- def left(*syms)
- @grammar.declare_precedence :Left, syms.map {|s| @grammar.intern(s) }
- end
-
- def right(*syms)
- @grammar.declare_precedence :Right, syms.map {|s| @grammar.intern(s) }
- end
-
- def nonassoc(*syms)
- @grammar.declare_precedence :Nonassoc, syms.map {|s| @grammar.intern(s)}
- end
- end
-
- #
- # Computation
- #
-
- def init
- return if @closed
- @closed = true
- @start ||= @rules.map {|r| r.target }.detect {|sym| not sym.dummy? }
- raise CompileError, 'no rule in input' if @rules.empty?
- add_start_rule
- @rules.freeze
- fix_ident
- compute_hash
- compute_heads
- determine_terminals
- compute_nullable_0
- @symboltable.fix
- compute_locate
- @symboltable.each_nonterminal {|t| compute_expand t }
- compute_nullable
- compute_useless
- end
-
- private
-
- def add_start_rule
- r = Rule.new(@symboltable.dummy,
- [@start, @symboltable.anchor, @symboltable.anchor],
- UserAction.empty)
- r.ident = 0
- r.hash = 0
- r.precedence = nil
- @rules.unshift r
- end
-
- # Rule#ident
- # LocationPointer#ident
- def fix_ident
- @rules.each_with_index do |rule, idx|
- rule.ident = idx
- end
- end
-
- # Rule#hash
- def compute_hash
- hash = 4 # size of dummy rule
- @rules.each do |rule|
- rule.hash = hash
- hash += (rule.size + 1)
- end
- end
-
- # Sym#heads
- def compute_heads
- @rules.each do |rule|
- rule.target.heads.push rule.ptrs[0]
- end
- end
-
- # Sym#terminal?
- def determine_terminals
- @symboltable.each do |s|
- s.term = s.heads.empty?
- end
- end
-
- # Sym#self_null?
- def compute_nullable_0
- @symboltable.each do |s|
- if s.terminal?
- s.snull = false
- else
- s.snull = s.heads.any? {|loc| loc.reduce? }
- end
- end
- end
-
- # Sym#locate
- def compute_locate
- @rules.each do |rule|
- t = nil
- rule.ptrs.each do |ptr|
- unless ptr.reduce?
- tok = ptr.dereference
- tok.locate.push ptr
- t = tok if tok.terminal?
- end
- end
- rule.precedence = t
- end
- end
-
- # Sym#expand
- def compute_expand(t)
- puts "expand> #{t.to_s}" if @debug_symbol
- t.expand = _compute_expand(t, ISet.new, [])
- puts "expand< #{t.to_s}: #{t.expand.to_s}" if @debug_symbol
- end
-
- def _compute_expand(t, set, lock)
- if tmp = t.expand
- set.update tmp
- return set
- end
- tok = nil
- set.update_a t.heads
- t.heads.each do |ptr|
- tok = ptr.dereference
- if tok and tok.nonterminal?
- unless lock[tok.ident]
- lock[tok.ident] = true
- _compute_expand tok, set, lock
- end
- end
- end
- set
- end
-
- # Sym#nullable?, Rule#nullable?
- def compute_nullable
- @rules.each {|r| r.null = false }
- @symboltable.each {|t| t.null = false }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_nullable r
- check_symbols_nullable s
- end until rs == r.size and ss == s.size
- end
-
- def check_rules_nullable(rules)
- rules.delete_if do |rule|
- rule.null = true
- rule.symbols.each do |t|
- unless t.nullable?
- rule.null = false
- break
- end
- end
- rule.nullable?
- end
- end
-
- def check_symbols_nullable(symbols)
- symbols.delete_if do |sym|
- sym.heads.each do |ptr|
- if ptr.rule.nullable?
- sym.null = true
- break
- end
- end
- sym.nullable?
- end
- end
-
- # Sym#useless?, Rule#useless?
- # FIXME: what means "useless"?
- def compute_useless
- @symboltable.each_terminal {|sym| sym.useless = false }
- @symboltable.each_nonterminal {|sym| sym.useless = true }
- @rules.each {|rule| rule.useless = true }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_useless r
- check_symbols_useless s
- end until r.size == rs and s.size == ss
- end
-
- def check_rules_useless(rules)
- rules.delete_if do |rule|
- rule.useless = false
- rule.symbols.each do |sym|
- if sym.useless?
- rule.useless = true
- break
- end
- end
- not rule.useless?
- end
- end
-
- def check_symbols_useless(s)
- s.delete_if do |t|
- t.heads.each do |ptr|
- unless ptr.rule.useless?
- t.useless = false
- break
- end
- end
- not t.useless?
- end
- end
-
- end # class Grammar
-
-
- class Rule
-
- def initialize(target, syms, act)
- @target = target
- @symbols = syms
- @action = act
- @alternatives = []
-
- @ident = nil
- @hash = nil
- @ptrs = nil
- @precedence = nil
- @specified_prec = nil
- @null = nil
- @useless = nil
- end
-
- attr_accessor :target
- attr_reader :symbols
- attr_reader :action
-
- def |(x)
- @alternatives.push x.rule
- self
- end
-
- def rule
- self
- end
-
- def each_rule(&block)
- yield self
- @alternatives.each(&block)
- end
-
- attr_accessor :ident
-
- attr_reader :hash
- attr_reader :ptrs
-
- def hash=(n)
- @hash = n
- ptrs = []
- @symbols.each_with_index do |sym, idx|
- ptrs.push LocationPointer.new(self, idx, sym)
- end
- ptrs.push LocationPointer.new(self, @symbols.size, nil)
- @ptrs = ptrs
- end
-
- def precedence
- @specified_prec || @precedence
- end
-
- def precedence=(sym)
- @precedence ||= sym
- end
-
- def prec(sym, &block)
- @specified_prec = sym
- if block
- unless @action.empty?
- raise CompileError, 'both of rule action block and prec block given'
- end
- @action = UserAction.proc(block)
- end
- self
- end
-
- attr_accessor :specified_prec
-
- def nullable?() @null end
- def null=(n) @null = n end
-
- def useless?() @useless end
- def useless=(u) @useless = u end
-
- def inspect
- "#<Racc::Rule id=#{@ident} (#{@target})>"
- end
-
- def ==(other)
- other.kind_of?(Rule) and @ident == other.ident
- end
-
- def [](idx)
- @symbols[idx]
- end
-
- def size
- @symbols.size
- end
-
- def empty?
- @symbols.empty?
- end
-
- def to_s
- "#<rule#{@ident}>"
- end
-
- def accept?
- if tok = @symbols[-1]
- tok.anchor?
- else
- false
- end
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def replace(src, dest)
- @target = dest
- @symbols = @symbols.map {|s| s == src ? dest : s }
- end
-
- end # class Rule
-
-
- class UserAction
-
- def UserAction.source_text(src)
- new(src, nil)
- end
-
- def UserAction.proc(pr = nil, &block)
- if pr and block
- raise ArgumentError, "both of argument and block given"
- end
- new(nil, pr || block)
- end
-
- def UserAction.empty
- new(nil, nil)
- end
-
- private_class_method :new
-
- def initialize(src, proc)
- @source = src
- @proc = proc
- end
-
- attr_reader :source
- attr_reader :proc
-
- def source?
- not @proc
- end
-
- def proc?
- not @source
- end
-
- def empty?
- not @proc and not @source
- end
-
- def name
- "{action type=#{@source || @proc || 'nil'}}"
- end
-
- alias inspect name
-
- end
-
-
- class OrMark
- def initialize(lineno)
- @lineno = lineno
- end
-
- def name
- '|'
- end
-
- alias inspect name
-
- attr_reader :lineno
- end
-
-
- class Prec
- def initialize(symbol, lineno)
- @symbol = symbol
- @lineno = lineno
- end
-
- def name
- "=#{@symbol}"
- end
-
- alias inspect name
-
- attr_reader :symbol
- attr_reader :lineno
- end
-
-
- #
- # A set of rule and position in it's RHS.
- # Note that the number of pointers is more than rule's RHS array,
- # because pointer points right edge of the final symbol when reducing.
- #
- class LocationPointer
-
- def initialize(rule, i, sym)
- @rule = rule
- @index = i
- @symbol = sym
- @ident = @rule.hash + i
- @reduce = sym.nil?
- end
-
- attr_reader :rule
- attr_reader :index
- attr_reader :symbol
-
- alias dereference symbol
-
- attr_reader :ident
- alias hash ident
- attr_reader :reduce
- alias reduce? reduce
-
- def to_s
- sprintf('(%d,%d %s)',
- @rule.ident, @index, (reduce?() ? '#' : @symbol.to_s))
- end
-
- alias inspect to_s
-
- def eql?(ot)
- @hash == ot.hash
- end
-
- alias == eql?
-
- def head?
- @index == 0
- end
-
- def next
- @rule.ptrs[@index + 1] or ptr_bug!
- end
-
- alias increment next
-
- def before(len)
- @rule.ptrs[@index - len] or ptr_bug!
- end
-
- private
-
- def ptr_bug!
- raise "racc: fatal: pointer not exist: self: #{to_s}"
- end
-
- end # class LocationPointer
-
-
- class SymbolTable
-
- include Enumerable
-
- def initialize
- @symbols = [] # :: [Racc::Sym]
- @cache = {} # :: {(String|Symbol) => Racc::Sym}
- @dummy = intern(:$start, true)
- @anchor = intern(false, true) # Symbol ID = 0
- @error = intern(:error, false) # Symbol ID = 1
- end
-
- attr_reader :dummy
- attr_reader :anchor
- attr_reader :error
-
- def [](id)
- @symbols[id]
- end
-
- def intern(val, dummy = false)
- @cache[val] ||=
- begin
- sym = Sym.new(val, dummy)
- @symbols.push sym
- sym
- end
- end
-
- attr_reader :symbols
- alias to_a symbols
-
- def delete(sym)
- @symbols.delete sym
- @cache.delete sym.value
- end
-
- attr_reader :nt_base
-
- def nt_max
- @symbols.size
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def terminals(&block)
- @symbols[0, @nt_base]
- end
-
- def each_terminal(&block)
- @terms.each(&block)
- end
-
- def nonterminals
- @symbols[@nt_base, @symbols.size - @nt_base]
- end
-
- def each_nonterminal(&block)
- @nterms.each(&block)
- end
-
- def fix
- terms, nterms = @symbols.partition {|s| s.terminal? }
- @symbols = terms + nterms
- @terms = terms
- @nterms = nterms
- @nt_base = terms.size
- fix_ident
- check_terminals
- end
-
- private
-
- def fix_ident
- @symbols.each_with_index do |t, i|
- t.ident = i
- end
- end
-
- def check_terminals
- return unless @symbols.any? {|s| s.should_terminal? }
- @anchor.should_terminal
- @error.should_terminal
- each_terminal do |t|
- t.should_terminal if t.string_symbol?
- end
- each do |s|
- s.should_terminal if s.assoc
- end
- terminals().reject {|t| t.should_terminal? }.each do |t|
- raise CompileError, "terminal #{t} not declared as terminal"
- end
- nonterminals().select {|n| n.should_terminal? }.each do |n|
- raise CompileError, "symbol #{n} declared as terminal but is not terminal"
- end
- end
-
- end # class SymbolTable
-
-
- # Stands terminal and nonterminal symbols.
- class Sym
-
- def initialize(value, dummyp)
- @ident = nil
- @value = value
- @dummyp = dummyp
-
- @term = nil
- @nterm = nil
- @should_terminal = false
- @precedence = nil
- case value
- when Symbol
- @to_s = value.to_s
- @serialized = value.inspect
- @string = false
- when String
- @to_s = value.inspect
- @serialized = value.dump
- @string = true
- when false
- @to_s = '$end'
- @serialized = 'false'
- @string = false
- when ErrorSymbolValue
- @to_s = 'error'
- @serialized = 'Object.new'
- @string = false
- else
- raise ArgumentError, "unknown symbol value: #{value.class}"
- end
-
- @heads = []
- @locate = []
- @snull = nil
- @null = nil
- @expand = nil
- @useless = nil
- end
-
- class << self
- def once_writer(nm)
- nm = nm.id2name
- module_eval(<<-EOS)
- def #{nm}=(v)
- raise 'racc: fatal: @#{nm} != nil' unless @#{nm}.nil?
- @#{nm} = v
- end
- EOS
- end
- end
-
- once_writer :ident
- attr_reader :ident
-
- alias hash ident
-
- attr_reader :value
-
- def dummy?
- @dummyp
- end
-
- def terminal?
- @term
- end
-
- def nonterminal?
- @nterm
- end
-
- def term=(t)
- raise 'racc: fatal: term= called twice' unless @term.nil?
- @term = t
- @nterm = !t
- end
-
- def should_terminal
- @should_terminal = true
- end
-
- def should_terminal?
- @should_terminal
- end
-
- def string_symbol?
- @string
- end
-
- def serialize
- @serialized
- end
-
- attr_writer :serialized
-
- attr_accessor :precedence
- attr_accessor :assoc
-
- def to_s
- @to_s.dup
- end
-
- alias inspect to_s
-
- def |(x)
- rule() | x.rule
- end
-
- def rule
- Rule.new(nil, [self], UserAction.empty)
- end
-
- #
- # cache
- #
-
- attr_reader :heads
- attr_reader :locate
-
- def self_null?
- @snull
- end
-
- once_writer :snull
-
- def nullable?
- @null
- end
-
- def null=(n)
- @null = n
- end
-
- attr_reader :expand
- once_writer :expand
-
- def useless?
- @useless
- end
-
- def useless=(f)
- @useless = f
- end
-
- end # class Sym
-
-end # module Racc
diff --git a/lib/racc/grammarfileparser.rb b/lib/racc/grammarfileparser.rb
deleted file mode 100644
index c7d1207f0b..0000000000
--- a/lib/racc/grammarfileparser.rb
+++ /dev/null
@@ -1,561 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc'
-require 'racc/compat'
-require 'racc/grammar'
-require 'racc/parserfilegenerator'
-require 'racc/sourcetext'
-require 'stringio'
-
-module Racc
-
- grammar = Grammar.define {
- g = self
-
- g.class = seq(:CLASS, :cname, many(:param), :RULE, :rules, option(:END))
-
- g.cname = seq(:rubyconst) {|name|
- @result.params.classname = name
- }\
- | seq(:rubyconst, "<", :rubyconst) {|c, _, s|
- @result.params.classname = c
- @result.params.superclass = s
- }
-
- g.rubyconst = separated_by1(:colon2, :SYMBOL) {|syms|
- syms.map {|s| s.to_s }.join('::')
- }
-
- g.colon2 = seq(':', ':')
-
- g.param = seq(:CONV, many1(:convdef), :END) {|*|
- #@grammar.end_convert_block # FIXME
- }\
- | seq(:PRECHIGH, many1(:precdef), :PRECLOW) {|*|
- @grammar.end_precedence_declaration true
- }\
- | seq(:PRECLOW, many1(:precdef), :PRECHIGH) {|*|
- @grammar.end_precedence_declaration false
- }\
- | seq(:START, :symbol) {|_, sym|
- @grammar.start_symbol = sym
- }\
- | seq(:TOKEN, :symbols) {|_, syms|
- syms.each do |s|
- s.should_terminal
- end
- }\
- | seq(:OPTION, :options) {|_, syms|
- syms.each do |opt|
- case opt
- when 'result_var'
- @result.params.result_var = true
- when 'no_result_var'
- @result.params.result_var = false
- when 'omit_action_call'
- @result.params.omit_action_call = true
- when 'no_omit_action_call'
- @result.params.omit_action_call = false
- else
- raise CompileError, "unknown option: #{opt}"
- end
- end
- }\
- | seq(:EXPECT, :DIGIT) {|_, num|
- if @grammar.n_expected_srconflicts
- raise CompileError, "`expect' seen twice"
- end
- @grammar.n_expected_srconflicts = num
- }
-
- g.convdef = seq(:symbol, :STRING) {|sym, code|
- sym.serialized = code
- }
-
- g.precdef = seq(:LEFT, :symbols) {|_, syms|
- @grammar.declare_precedence :Left, syms
- }\
- | seq(:RIGHT, :symbols) {|_, syms|
- @grammar.declare_precedence :Right, syms
- }\
- | seq(:NONASSOC, :symbols) {|_, syms|
- @grammar.declare_precedence :Nonassoc, syms
- }
-
- g.symbols = seq(:symbol) {|sym|
- [sym]
- }\
- | seq(:symbols, :symbol) {|list, sym|
- list.push sym
- list
- }\
- | seq(:symbols, "|")
-
- g.symbol = seq(:SYMBOL) {|sym| @grammar.intern(sym) }\
- | seq(:STRING) {|str| @grammar.intern(str) }
-
- g.options = many(:SYMBOL) {|syms| syms.map {|s| s.to_s } }
-
- g.rules = option(:rules_core) {|list|
- add_rule_block list unless list.empty?
- nil
- }
-
- g.rules_core = seq(:symbol) {|sym|
- [sym]
- }\
- | seq(:rules_core, :rule_item) {|list, i|
- list.push i
- list
- }\
- | seq(:rules_core, ';') {|list, *|
- add_rule_block list unless list.empty?
- list.clear
- list
- }\
- | seq(:rules_core, ':') {|list, *|
- next_target = list.pop
- add_rule_block list unless list.empty?
- [next_target]
- }
-
- g.rule_item = seq(:symbol)\
- | seq("|") {|*|
- OrMark.new(@scanner.lineno)
- }\
- | seq("=", :symbol) {|_, sym|
- Prec.new(sym, @scanner.lineno)
- }\
- | seq(:ACTION) {|src|
- UserAction.source_text(src)
- }
- }
-
- GrammarFileParser = grammar.parser_class
-
- if grammar.states.srconflict_exist?
- raise 'Racc boot script fatal: S/R conflict in build'
- end
- if grammar.states.rrconflict_exist?
- raise 'Racc boot script fatal: R/R conflict in build'
- end
-
- class GrammarFileParser # reopen
-
- class Result
- def initialize(grammar)
- @grammar = grammar
- @params = ParserFileGenerator::Params.new
- end
-
- attr_reader :grammar
- attr_reader :params
- end
-
- def GrammarFileParser.parse_file(filename)
- parse(File.read(filename), filename, 1)
- end
-
- def GrammarFileParser.parse(src, filename = '-', lineno = 1)
- new().parse(src, filename, lineno)
- end
-
- def initialize(debug_flags = DebugFlags.new)
- @yydebug = debug_flags.parse
- end
-
- def parse(src, filename = '-', lineno = 1)
- @filename = filename
- @lineno = lineno
- @scanner = GrammarFileScanner.new(src, @filename)
- @scanner.debug = @yydebug
- @grammar = Grammar.new
- @result = Result.new(@grammar)
- @embedded_action_seq = 0
- yyparse @scanner, :yylex
- parse_user_code
- @result.grammar.init
- @result
- end
-
- private
-
- def next_token
- @scanner.scan
- end
-
- def on_error(tok, val, _values)
- if val.respond_to?(:id2name)
- v = val.id2name
- elsif val.kind_of?(String)
- v = val
- else
- v = val.inspect
- end
- raise CompileError, "#{location()}: unexpected token '#{v}'"
- end
-
- def location
- "#{@filename}:#{@lineno - 1 + @scanner.lineno}"
- end
-
- def add_rule_block(list)
- sprec = nil
- target = list.shift
- case target
- when OrMark, UserAction, Prec
- raise CompileError, "#{target.lineno}: unexpected symbol #{target.name}"
- end
- curr = []
- list.each do |i|
- case i
- when OrMark
- add_rule target, curr, sprec
- curr = []
- sprec = nil
- when Prec
- raise CompileError, "'=<prec>' used twice in one rule" if sprec
- sprec = i.symbol
- else
- curr.push i
- end
- end
- add_rule target, curr, sprec
- end
-
- def add_rule(target, list, sprec)
- if list.last.kind_of?(UserAction)
- act = list.pop
- else
- act = UserAction.empty
- end
- list.map! {|s| s.kind_of?(UserAction) ? embedded_action(s) : s }
- rule = Rule.new(target, list, act)
- rule.specified_prec = sprec
- @grammar.add rule
- end
-
- def embedded_action(act)
- sym = @grammar.intern("@#{@embedded_action_seq += 1}".intern, true)
- @grammar.add Rule.new(sym, [], act)
- sym
- end
-
- #
- # User Code Block
- #
-
- def parse_user_code
- line = @scanner.lineno
- _, *blocks = *@scanner.epilogue.split(/^----/)
- blocks.each do |block|
- header, *body = block.lines.to_a
- label0, paths = *header.sub(/\A-+/, '').split('=', 2)
- label = canonical_label(label0)
- (paths ? paths.strip.split(' ') : []).each do |path|
- add_user_code label, SourceText.new(File.read(path), path, 1)
- end
- add_user_code label, SourceText.new(body.join(''), @filename, line + 1)
- line += (1 + body.size)
- end
- end
-
- USER_CODE_LABELS = {
- 'header' => :header,
- 'prepare' => :header, # obsolete
- 'inner' => :inner,
- 'footer' => :footer,
- 'driver' => :footer # obsolete
- }
-
- def canonical_label(src)
- label = src.to_s.strip.downcase.slice(/\w+/)
- unless USER_CODE_LABELS.key?(label)
- raise CompileError, "unknown user code type: #{label.inspect}"
- end
- label
- end
-
- def add_user_code(label, src)
- @result.params.public_send(USER_CODE_LABELS[label]).push src
- end
-
- end
-
-
- class GrammarFileScanner
-
- def initialize(str, filename = '-')
- @lines = str.b.split(/\n|\r\n|\r/)
- @filename = filename
- @lineno = -1
- @line_head = true
- @in_rule_blk = false
- @in_conv_blk = false
- @in_block = nil
- @epilogue = ''
- @debug = false
- next_line
- end
-
- attr_reader :epilogue
-
- def lineno
- @lineno + 1
- end
-
- attr_accessor :debug
-
- def yylex(&block)
- unless @debug
- yylex0(&block)
- else
- yylex0 do |sym, tok|
- $stderr.printf "%7d %-10s %s\n", lineno(), sym.inspect, tok.inspect
- yield [sym, tok]
- end
- end
- end
-
- private
-
- def yylex0
- begin
- until @line.empty?
- @line.sub!(/\A\s+/, '')
- if /\A\#/ =~ @line
- break
- elsif /\A\/\*/ =~ @line
- skip_comment
- elsif s = reads(/\A[a-zA-Z_]\w*/)
- yield [atom_symbol(s), s.intern]
- elsif s = reads(/\A\d+/)
- yield [:DIGIT, s.to_i]
- elsif ch = reads(/\A./)
- case ch
- when '"', "'"
- yield [:STRING, eval(scan_quoted(ch))]
- when '{'
- lineno = lineno()
- yield [:ACTION, SourceText.new(scan_action(), @filename, lineno)]
- else
- if ch == '|'
- @line_head = false
- end
- yield [ch, ch]
- end
- else
- end
- end
- end while next_line()
- yield nil
- end
-
- def next_line
- @lineno += 1
- @line = @lines[@lineno]
- if not @line or /\A----/ =~ @line
- @epilogue = @lines.join("\n")
- @lines.clear
- @line = nil
- if @in_block
- @lineno -= 1
- scan_error! sprintf('unterminated %s', @in_block)
- end
- false
- else
- @line.sub!(/(?:\n|\r\n|\r)\z/, '')
- @line_head = true
- true
- end
- end
-
- ReservedWord = {
- 'right' => :RIGHT,
- 'left' => :LEFT,
- 'nonassoc' => :NONASSOC,
- 'preclow' => :PRECLOW,
- 'prechigh' => :PRECHIGH,
- 'token' => :TOKEN,
- 'convert' => :CONV,
- 'options' => :OPTION,
- 'start' => :START,
- 'expect' => :EXPECT,
- 'class' => :CLASS,
- 'rule' => :RULE,
- 'end' => :END
- }
-
- def atom_symbol(token)
- if token == 'end'
- symbol = :END
- @in_conv_blk = false
- @in_rule_blk = false
- else
- if @line_head and not @in_conv_blk and not @in_rule_blk
- symbol = ReservedWord[token] || :SYMBOL
- else
- symbol = :SYMBOL
- end
- case symbol
- when :RULE then @in_rule_blk = true
- when :CONV then @in_conv_blk = true
- end
- end
- @line_head = false
- symbol
- end
-
- def skip_comment
- @in_block = 'comment'
- until m = /\*\//.match(@line)
- next_line
- end
- @line = m.post_match
- @in_block = nil
- end
-
- $raccs_print_type = false
-
- def scan_action
- buf = String.new
- nest = 1
- pre = nil
- @in_block = 'action'
- begin
- pre = nil
- if s = reads(/\A\s+/)
- # does not set 'pre'
- buf << s
- end
- until @line.empty?
- if s = reads(/\A[^'"`{}%#\/\$]+/)
- buf << (pre = s)
- next
- end
- case ch = read(1)
- when '{'
- nest += 1
- buf << (pre = ch)
- when '}'
- nest -= 1
- if nest == 0
- @in_block = nil
- buf.sub!(/[ \t\f]+\z/, '')
- return buf
- end
- buf << (pre = ch)
- when '#' # comment
- buf << ch << @line
- break
- when "'", '"', '`'
- buf << (pre = scan_quoted(ch))
- when '%'
- if literal_head? pre, @line
- # % string, regexp, array
- buf << ch
- case ch = read(1)
- when /[qQx]/n
- buf << ch << (pre = scan_quoted(read(1), '%string'))
- when /wW/n
- buf << ch << (pre = scan_quoted(read(1), '%array'))
- when /s/n
- buf << ch << (pre = scan_quoted(read(1), '%symbol'))
- when /r/n
- buf << ch << (pre = scan_quoted(read(1), '%regexp'))
- when /[a-zA-Z0-9= ]/n # does not include "_"
- scan_error! "unknown type of % literal '%#{ch}'"
- else
- buf << (pre = scan_quoted(ch, '%string'))
- end
- else
- # operator
- buf << '||op->' if $raccs_print_type
- buf << (pre = ch)
- end
- when '/'
- if literal_head? pre, @line
- # regexp
- buf << (pre = scan_quoted(ch, 'regexp'))
- else
- # operator
- buf << '||op->' if $raccs_print_type
- buf << (pre = ch)
- end
- when '$' # gvar
- buf << ch << (pre = read(1))
- else
- raise 'racc: fatal: must not happen'
- end
- end
- buf << "\n"
- end while next_line()
- raise 'racc: fatal: scan finished before parser finished'
- end
-
- def literal_head?(pre, post)
- (!pre || /[a-zA-Z_0-9]/n !~ pre[-1,1]) &&
- !post.empty? && /\A[\s\=]/n !~ post
- end
-
- def read(len)
- s = @line[0, len]
- @line = @line[len .. -1]
- s
- end
-
- def reads(re)
- m = re.match(@line) or return nil
- @line = m.post_match
- m[0]
- end
-
- def scan_quoted(left, tag = 'string')
- buf = left.dup
- buf = "||#{tag}->" + buf if $raccs_print_type
- re = get_quoted_re(left)
- sv, @in_block = @in_block, tag
- begin
- if s = reads(re)
- buf << s
- break
- else
- buf << @line
- end
- end while next_line()
- @in_block = sv
- buf << "<-#{tag}||" if $raccs_print_type
- buf
- end
-
- LEFT_TO_RIGHT = {
- '(' => ')',
- '{' => '}',
- '[' => ']',
- '<' => '>'
- }
-
- CACHE = {}
-
- def get_quoted_re(left)
- term = Regexp.quote(LEFT_TO_RIGHT[left] || left)
- CACHE[left] ||= /\A[^#{term}\\]*(?:\\.[^\\#{term}]*)*#{term}/
- end
-
- def scan_error!(msg)
- raise CompileError, "#{lineno()}: #{msg}"
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/info.rb b/lib/racc/info.rb
deleted file mode 100644
index 37bff7edba..0000000000
--- a/lib/racc/info.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
- VERSION = '1.6.2'
- Version = VERSION
- Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
-end
diff --git a/lib/racc/iset.rb b/lib/racc/iset.rb
deleted file mode 100644
index 339221d21b..0000000000
--- a/lib/racc/iset.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
-
- # An "indexed" set. All items must respond to :ident.
- class ISet
-
- def initialize(a = [])
- @set = a
- end
-
- attr_reader :set
-
- def add(i)
- @set[i.ident] = i
- end
-
- def [](key)
- @set[key.ident]
- end
-
- def []=(key, val)
- @set[key.ident] = val
- end
-
- alias include? []
- alias key? []
-
- def update(other)
- s = @set
- o = other.set
- o.each_index do |idx|
- if t = o[idx]
- s[idx] = t
- end
- end
- end
-
- def update_a(a)
- s = @set
- a.each {|i| s[i.ident] = i }
- end
-
- def delete(key)
- i = @set[key.ident]
- @set[key.ident] = nil
- i
- end
-
- def each(&block)
- @set.compact.each(&block)
- end
-
- def to_a
- @set.compact
- end
-
- def to_s
- "[#{@set.compact.join(' ')}]"
- end
-
- alias inspect to_s
-
- def size
- @set.nitems
- end
-
- def empty?
- @set.nitems == 0
- end
-
- def clear
- @set.clear
- end
-
- def dup
- ISet.new(@set.dup)
- end
-
- end # class ISet
-
-end # module Racc
diff --git a/lib/racc/logfilegenerator.rb b/lib/racc/logfilegenerator.rb
deleted file mode 100644
index 2f5aa0c8b0..0000000000
--- a/lib/racc/logfilegenerator.rb
+++ /dev/null
@@ -1,212 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
-
- class LogFileGenerator
-
- def initialize(states, debug_flags = DebugFlags.new)
- @states = states
- @grammar = states.grammar
- @debug_flags = debug_flags
- end
-
- def output(out)
- output_conflict out; out.puts
- output_useless out; out.puts
- output_rule out; out.puts
- output_token out; out.puts
- output_state out
- end
-
- #
- # Warnings
- #
-
- def output_conflict(out)
- @states.each do |state|
- if state.srconf
- out.printf "state %d contains %d shift/reduce conflicts\n",
- state.stateid, state.srconf.size
- end
- if state.rrconf
- out.printf "state %d contains %d reduce/reduce conflicts\n",
- state.stateid, state.rrconf.size
- end
- end
- end
-
- def output_useless(out)
- @grammar.each do |rl|
- if rl.useless?
- out.printf "rule %d (%s) never reduced\n",
- rl.ident, rl.target.to_s
- end
- end
- @grammar.each_nonterminal do |t|
- if t.useless?
- out.printf "useless nonterminal %s\n", t.to_s
- end
- end
- end
-
- #
- # States
- #
-
- def output_state(out)
- out << "--------- State ---------\n"
-
- showall = @debug_flags.la || @debug_flags.state
- @states.each do |state|
- out << "\nstate #{state.ident}\n\n"
-
- (showall ? state.closure : state.core).each do |ptr|
- pointer_out(out, ptr) if ptr.rule.ident != 0 or showall
- end
- out << "\n"
-
- action_out out, state
- end
- end
-
- def pointer_out(out, ptr)
- buf = sprintf("%4d) %s :", ptr.rule.ident, ptr.rule.target.to_s)
- ptr.rule.symbols.each_with_index do |tok, idx|
- buf << ' _' if idx == ptr.index
- buf << ' ' << tok.to_s
- end
- buf << ' _' if ptr.reduce?
- out.puts buf
- end
-
- def action_out(f, state)
- sr = state.srconf && state.srconf.dup
- rr = state.rrconf && state.rrconf.dup
- acts = state.action
- keys = acts.keys
- keys.sort! {|a,b| a.ident <=> b.ident }
-
- [ Shift, Reduce, Error, Accept ].each do |klass|
- keys.delete_if do |tok|
- act = acts[tok]
- if act.kind_of?(klass)
- outact f, tok, act
- if sr and c = sr.delete(tok)
- outsrconf f, c
- end
- if rr and c = rr.delete(tok)
- outrrconf f, c
- end
-
- true
- else
- false
- end
- end
- end
- sr.each {|tok, c| outsrconf f, c } if sr
- rr.each {|tok, c| outrrconf f, c } if rr
-
- act = state.defact
- if not act.kind_of?(Error) or @debug_flags.any?
- outact f, '$default', act
- end
-
- f.puts
- state.goto_table.each do |t, st|
- if t.nonterminal?
- f.printf " %-12s go to state %d\n", t.to_s, st.ident
- end
- end
- end
-
- def outact(f, t, act)
- case act
- when Shift
- f.printf " %-12s shift, and go to state %d\n",
- t.to_s, act.goto_id
- when Reduce
- f.printf " %-12s reduce using rule %d (%s)\n",
- t.to_s, act.ruleid, act.rule.target.to_s
- when Accept
- f.printf " %-12s accept\n", t.to_s
- when Error
- f.printf " %-12s error\n", t.to_s
- else
- raise "racc: fatal: wrong act for outact: act=#{act}(#{act.class})"
- end
- end
-
- def outsrconf(f, confs)
- confs.each do |c|
- r = c.reduce
- f.printf " %-12s [reduce using rule %d (%s)]\n",
- c.shift.to_s, r.ident, r.target.to_s
- end
- end
-
- def outrrconf(f, confs)
- confs.each do |c|
- r = c.low_prec
- f.printf " %-12s [reduce using rule %d (%s)]\n",
- c.token.to_s, r.ident, r.target.to_s
- end
- end
-
- #
- # Rules
- #
-
- def output_rule(out)
- out.print "-------- Grammar --------\n\n"
- @grammar.each do |rl|
- if @debug_flags.any? or rl.ident != 0
- out.printf "rule %d %s: %s\n",
- rl.ident, rl.target.to_s, rl.symbols.join(' ')
- end
- end
- end
-
- #
- # Tokens
- #
-
- def output_token(out)
- out.print "------- Symbols -------\n\n"
-
- out.print "**Nonterminals, with rules where they appear\n\n"
- @grammar.each_nonterminal do |t|
- tmp = <<SRC
- %s (%d)
- on right: %s
- on left : %s
-SRC
- out.printf tmp, t.to_s, t.ident,
- symbol_locations(t.locate).join(' '),
- symbol_locations(t.heads).join(' ')
- end
-
- out.print "\n**Terminals, with rules where they appear\n\n"
- @grammar.each_terminal do |t|
- out.printf " %s (%d) %s\n",
- t.to_s, t.ident, symbol_locations(t.locate).join(' ')
- end
- end
-
- def symbol_locations(locs)
- locs.map {|loc| loc.rule.ident }.reject {|n| n == 0 }.uniq
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/parser-text.rb b/lib/racc/parser-text.rb
deleted file mode 100644
index 63ac2e368b..0000000000
--- a/lib/racc/parser-text.rb
+++ /dev/null
@@ -1,637 +0,0 @@
-module Racc
- PARSER_TEXT = <<'__end_of_file__'
-# frozen_string_literal: false
-#--
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# As a special exception, when this code is copied by Racc
-# into a Racc output file, you may use that output file
-# without restriction.
-#++
-
-require 'racc/info'
-
-unless defined?(NotImplementedError)
- NotImplementedError = NotImplementError # :nodoc:
-end
-
-module Racc
- class ParseError < StandardError; end
-end
-unless defined?(::ParseError)
- ParseError = Racc::ParseError # :nodoc:
-end
-
-# Racc is a LALR(1) parser generator.
-# It is written in Ruby itself, and generates Ruby programs.
-#
-# == Command-line Reference
-#
-# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
-# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
-# [-v] [--verbose]
-# [-O<var>filename</var>] [--log-file=<var>filename</var>]
-# [-g] [--debug]
-# [-E] [--embedded]
-# [-l] [--no-line-convert]
-# [-c] [--line-convert-all]
-# [-a] [--no-omit-actions]
-# [-C] [--check-only]
-# [-S] [--output-status]
-# [--version] [--copyright] [--help] <var>grammarfile</var>
-#
-# [+grammarfile+]
-# Racc grammar file. Any extension is permitted.
-# [-o+outfile+, --output-file=+outfile+]
-# A filename for output. default is <+filename+>.tab.rb
-# [-O+filename+, --log-file=+filename+]
-# Place logging output in file +filename+.
-# Default log file name is <+filename+>.output.
-# [-e+rubypath+, --executable=+rubypath+]
-# output executable file(mode 755). where +path+ is the Ruby interpreter.
-# [-v, --verbose]
-# verbose mode. create +filename+.output file, like yacc's y.output file.
-# [-g, --debug]
-# add debug code to parser class. To display debuggin information,
-# use this '-g' option and set @yydebug true in parser class.
-# [-E, --embedded]
-# Output parser which doesn't need runtime files (racc/parser.rb).
-# [-C, --check-only]
-# Check syntax of racc grammar file and quit.
-# [-S, --output-status]
-# Print messages time to time while compiling.
-# [-l, --no-line-convert]
-# turns off line number converting.
-# [-c, --line-convert-all]
-# Convert line number of actions, inner, header and footer.
-# [-a, --no-omit-actions]
-# Call all actions, even if an action is empty.
-# [--version]
-# print Racc version and quit.
-# [--copyright]
-# Print copyright and quit.
-# [--help]
-# Print usage and quit.
-#
-# == Generating Parser Using Racc
-#
-# To compile Racc grammar file, simply type:
-#
-# $ racc parse.y
-#
-# This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
-#
-# == Writing A Racc Grammar File
-#
-# If you want your own parser, you have to write a grammar file.
-# A grammar file contains the name of your parser class, grammar for the parser,
-# user code, and anything else.
-# When writing a grammar file, yacc's knowledge is helpful.
-# If you have not used yacc before, Racc is not too difficult.
-#
-# Here's an example Racc grammar file.
-#
-# class Calcparser
-# rule
-# target: exp { print val[0] }
-#
-# exp: exp '+' exp
-# | exp '*' exp
-# | '(' exp ')'
-# | NUMBER
-# end
-#
-# Racc grammar files resemble yacc files.
-# But (of course), this is Ruby code.
-# yacc's $$ is the 'result', $0, $1... is
-# an array called 'val', and $-1, $-2... is an array called '_values'.
-#
-# See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
-# more information on grammar files.
-#
-# == Parser
-#
-# Then you must prepare the parse entry method. There are two types of
-# parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
-#
-# Racc::Parser#do_parse is simple.
-#
-# It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
-# This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
-# EOF is [false, false].
-# (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
-# If you want to change this, see the grammar reference.
-#
-# Racc::Parser#yyparse is little complicated, but useful.
-# It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
-#
-# For example, <code>yyparse(obj, :scan)</code> causes
-# calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
-#
-# == Debugging
-#
-# When debugging, "-v" or/and the "-g" option is helpful.
-#
-# "-v" creates verbose log file (.output).
-# "-g" creates a "Verbose Parser".
-# Verbose Parser prints the internal status when parsing.
-# But it's _not_ automatic.
-# You must use -g option and set +@yydebug+ to +true+ in order to get output.
-# -g option only creates the verbose parser.
-#
-# === Racc reported syntax error.
-#
-# Isn't there too many "end"?
-# grammar of racc file is changed in v0.10.
-#
-# Racc does not use '%' mark, while yacc uses huge number of '%' marks..
-#
-# === Racc reported "XXXX conflicts".
-#
-# Try "racc -v xxxx.y".
-# It causes producing racc's internal log file, xxxx.output.
-#
-# === Generated parsers does not work correctly
-#
-# Try "racc -g xxxx.y".
-# This command let racc generate "debugging parser".
-# Then set @yydebug=true in your parser.
-# It produces a working log of your parser.
-#
-# == Re-distributing Racc runtime
-#
-# A parser, which is created by Racc, requires the Racc runtime module;
-# racc/parser.rb.
-#
-# Ruby 1.8.x comes with Racc runtime module,
-# you need NOT distribute Racc runtime files.
-#
-# If you want to include the Racc runtime module with your parser.
-# This can be done by using '-E' option:
-#
-# $ racc -E -omyparser.rb myparser.y
-#
-# This command creates myparser.rb which `includes' Racc runtime.
-# Only you must do is to distribute your parser file (myparser.rb).
-#
-# Note: parser.rb is ruby license, but your parser is not.
-# Your own parser is completely yours.
-module Racc
-
- unless defined?(Racc_No_Extensions)
- Racc_No_Extensions = false # :nodoc:
- end
-
- class Parser
-
- Racc_Runtime_Version = ::Racc::VERSION
- Racc_Runtime_Core_Version_R = ::Racc::VERSION
-
- begin
- if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
- require 'jruby'
- require 'racc/cparse-jruby.jar'
- com.headius.racc.Cparse.new.load(JRuby.runtime, false)
- else
- require 'racc/cparse'
- end
-
- unless new.respond_to?(:_racc_do_parse_c, true)
- raise LoadError, 'old cparse.so'
- end
- if Racc_No_Extensions
- raise LoadError, 'selecting ruby version of racc runtime core'
- end
-
- Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
- Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
- Racc_Runtime_Type = 'c' # :nodoc:
- rescue LoadError
- Racc_Main_Parsing_Routine = :_racc_do_parse_rb
- Racc_YY_Parse_Method = :_racc_yyparse_rb
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
- Racc_Runtime_Type = 'ruby'
- end
-
- def Parser.racc_runtime_type # :nodoc:
- Racc_Runtime_Type
- end
-
- def _racc_setup
- @yydebug = false unless self.class::Racc_debug_parser
- @yydebug = false unless defined?(@yydebug)
- if @yydebug
- @racc_debug_out = $stderr unless defined?(@racc_debug_out)
- @racc_debug_out ||= $stderr
- end
- arg = self.class::Racc_arg
- arg[13] = true if arg.size < 14
- arg
- end
-
- def _racc_init_sysvars
- @racc_state = [0]
- @racc_tstack = []
- @racc_vstack = []
-
- @racc_t = nil
- @racc_val = nil
-
- @racc_read_next = true
-
- @racc_user_yyerror = false
- @racc_error_status = 0
- end
-
- # The entry point of the parser. This method is used with #next_token.
- # If Racc wants to get token (and its value), calls next_token.
- #
- # Example:
- # def parse
- # @q = [[1,1],
- # [2,2],
- # [3,3],
- # [false, '$']]
- # do_parse
- # end
- #
- # def next_token
- # @q.shift
- # end
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
- def do_parse
- #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
- end
- RUBY
-
- # The method to fetch next token.
- # If you use #do_parse method, you must implement #next_token.
- #
- # The format of return value is [TOKEN_SYMBOL, VALUE].
- # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
- # for 'IDENT'. ";" (String) for ';'.
- #
- # The final symbol (End of file) must be false.
- def next_token
- raise NotImplementedError, "#{self.class}\#next_token is not defined"
- end
-
- def _racc_do_parse_rb(arg, in_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
- tok = act = i = nil
-
- catch(:racc_end_parse) {
- while true
- if i = action_pointer[@racc_state[-1]]
- if @racc_read_next
- if @racc_t != 0 # not EOF
- tok, @racc_val = next_token()
- unless tok # EOF
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- racc_read_token(@racc_t, tok, @racc_val) if @yydebug
- @racc_read_next = false
- end
- end
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- else
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- }
- end
-
- # Another entry point for the parser.
- # If you use this method, you must implement RECEIVER#METHOD_ID method.
- #
- # RECEIVER#METHOD_ID is a method to get next token.
- # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
- def yyparse(recv, mid)
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
- end
- RUBY
-
- def _racc_yyparse_rb(recv, mid, arg, c_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
-
- catch(:racc_end_parse) {
- until i = action_pointer[@racc_state[-1]]
- while act = _racc_evalact(action_default[@racc_state[-1]], arg)
- ;
- end
- end
- recv.__send__(mid) do |tok, val|
- unless tok
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- @racc_val = val
- @racc_read_next = false
-
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
-
- while !(i = action_pointer[@racc_state[-1]]) ||
- ! @racc_read_next ||
- @racc_t == 0 # $
- unless i and i += @racc_t and
- i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- end
- }
- end
-
- ###
- ### common
- ###
-
- def _racc_evalact(act, arg)
- action_table, action_check, _, action_pointer,
- _, _, _, _,
- _, _, _, shift_n,
- reduce_n, * = arg
- nerr = 0 # tmp
-
- if act > 0 and act < shift_n
- #
- # shift
- #
- if @racc_error_status > 0
- @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
- end
- @racc_vstack.push @racc_val
- @racc_state.push act
- @racc_read_next = true
- if @yydebug
- @racc_tstack.push @racc_t
- racc_shift @racc_t, @racc_tstack, @racc_vstack
- end
-
- elsif act < 0 and act > -reduce_n
- #
- # reduce
- #
- code = catch(:racc_jump) {
- @racc_state.push _racc_do_reduce(arg, act)
- false
- }
- if code
- case code
- when 1 # yyerror
- @racc_user_yyerror = true # user_yyerror
- return -reduce_n
- when 2 # yyaccept
- return shift_n
- else
- raise '[Racc Bug] unknown jump code'
- end
- end
-
- elsif act == shift_n
- #
- # accept
- #
- racc_accept if @yydebug
- throw :racc_end_parse, @racc_vstack[0]
-
- elsif act == -reduce_n
- #
- # error
- #
- case @racc_error_status
- when 0
- unless arg[21] # user_yyerror
- nerr += 1
- on_error @racc_t, @racc_val, @racc_vstack
- end
- when 3
- if @racc_t == 0 # is $
- # We're at EOF, and another error occurred immediately after
- # attempting auto-recovery
- throw :racc_end_parse, nil
- end
- @racc_read_next = true
- end
- @racc_user_yyerror = false
- @racc_error_status = 3
- while true
- if i = action_pointer[@racc_state[-1]]
- i += 1 # error token
- if i >= 0 and
- (act = action_table[i]) and
- action_check[i] == @racc_state[-1]
- break
- end
- end
- throw :racc_end_parse, nil if @racc_state.size <= 1
- @racc_state.pop
- @racc_vstack.pop
- if @yydebug
- @racc_tstack.pop
- racc_e_pop @racc_state, @racc_tstack, @racc_vstack
- end
- end
- return act
-
- else
- raise "[Racc Bug] unknown action #{act.inspect}"
- end
-
- racc_next_state(@racc_state[-1], @racc_state) if @yydebug
-
- nil
- end
-
- def _racc_do_reduce(arg, act)
- _, _, _, _,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, _, _,
- _, use_result, * = arg
-
- state = @racc_state
- vstack = @racc_vstack
- tstack = @racc_tstack
-
- i = act * -3
- len = reduce_table[i]
- reduce_to = reduce_table[i+1]
- method_id = reduce_table[i+2]
- void_array = []
-
- tmp_t = tstack[-len, len] if @yydebug
- tmp_v = vstack[-len, len]
- tstack[-len, len] = void_array if @yydebug
- vstack[-len, len] = void_array
- state[-len, len] = void_array
-
- # tstack must be updated AFTER method call
- if use_result
- vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
- else
- vstack.push __send__(method_id, tmp_v, vstack)
- end
- tstack.push reduce_to
-
- racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
- k1 = reduce_to - nt_base
- if i = goto_pointer[k1]
- i += state[-1]
- if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
- return curstate
- end
- end
- goto_default[k1]
- end
-
- # This method is called when a parse error is found.
- #
- # ERROR_TOKEN_ID is an internal ID of token which caused error.
- # You can get string representation of this ID by calling
- # #token_to_str.
- #
- # ERROR_VALUE is a value of error token.
- #
- # value_stack is a stack of symbol values.
- # DO NOT MODIFY this object.
- #
- # This method raises ParseError by default.
- #
- # If this method returns, parsers enter "error recovering mode".
- def on_error(t, val, vstack)
- raise ParseError, sprintf("\nparse error on value %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
-
- # Enter error recovering mode.
- # This method does not call #on_error.
- def yyerror
- throw :racc_jump, 1
- end
-
- # Exit parser.
- # Return value is +Symbol_Value_Stack[0]+.
- def yyaccept
- throw :racc_jump, 2
- end
-
- # Leave error recovering mode.
- def yyerrok
- @racc_error_status = 0
- end
-
- # For debugging output
- def racc_read_token(t, tok, val)
- @racc_debug_out.print 'read '
- @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
- @racc_debug_out.puts val.inspect
- @racc_debug_out.puts
- end
-
- def racc_shift(tok, tstack, vstack)
- @racc_debug_out.puts "shift #{racc_token2str tok}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_reduce(toks, sim, tstack, vstack)
- out = @racc_debug_out
- out.print 'reduce '
- if toks.empty?
- out.print ' <none>'
- else
- toks.each {|t| out.print ' ', racc_token2str(t) }
- end
- out.puts " --> #{racc_token2str(sim)}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_accept
- @racc_debug_out.puts 'accept'
- @racc_debug_out.puts
- end
-
- def racc_e_pop(state, tstack, vstack)
- @racc_debug_out.puts 'error recovering mode: pop token'
- racc_print_states state
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_next_state(curstate, state)
- @racc_debug_out.puts "goto #{curstate}"
- racc_print_states state
- @racc_debug_out.puts
- end
-
- def racc_print_stacks(t, v)
- out = @racc_debug_out
- out.print ' ['
- t.each_index do |i|
- out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
- end
- out.puts ' ]'
- end
-
- def racc_print_states(s)
- out = @racc_debug_out
- out.print ' ['
- s.each {|st| out.print ' ', st }
- out.puts ' ]'
- end
-
- def racc_token2str(tok)
- self.class::Racc_token_to_s_table[tok] or
- raise "[Racc Bug] can't convert token #{tok} to string"
- end
-
- # Convert internal ID of token symbol to the string.
- def token_to_str(t)
- self.class::Racc_token_to_s_table[t]
- end
-
- end
-
-end
-
-__end_of_file__
-end
diff --git a/lib/racc/parser.rb b/lib/racc/parser.rb
deleted file mode 100644
index f2cc050826..0000000000
--- a/lib/racc/parser.rb
+++ /dev/null
@@ -1,632 +0,0 @@
-# frozen_string_literal: false
-#--
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# As a special exception, when this code is copied by Racc
-# into a Racc output file, you may use that output file
-# without restriction.
-#++
-
-require 'racc/info'
-
-unless defined?(NotImplementedError)
- NotImplementedError = NotImplementError # :nodoc:
-end
-
-module Racc
- class ParseError < StandardError; end
-end
-unless defined?(::ParseError)
- ParseError = Racc::ParseError # :nodoc:
-end
-
-# Racc is a LALR(1) parser generator.
-# It is written in Ruby itself, and generates Ruby programs.
-#
-# == Command-line Reference
-#
-# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
-# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
-# [-v] [--verbose]
-# [-O<var>filename</var>] [--log-file=<var>filename</var>]
-# [-g] [--debug]
-# [-E] [--embedded]
-# [-l] [--no-line-convert]
-# [-c] [--line-convert-all]
-# [-a] [--no-omit-actions]
-# [-C] [--check-only]
-# [-S] [--output-status]
-# [--version] [--copyright] [--help] <var>grammarfile</var>
-#
-# [+grammarfile+]
-# Racc grammar file. Any extension is permitted.
-# [-o+outfile+, --output-file=+outfile+]
-# A filename for output. default is <+filename+>.tab.rb
-# [-O+filename+, --log-file=+filename+]
-# Place logging output in file +filename+.
-# Default log file name is <+filename+>.output.
-# [-e+rubypath+, --executable=+rubypath+]
-# output executable file(mode 755). where +path+ is the Ruby interpreter.
-# [-v, --verbose]
-# verbose mode. create +filename+.output file, like yacc's y.output file.
-# [-g, --debug]
-# add debug code to parser class. To display debuggin information,
-# use this '-g' option and set @yydebug true in parser class.
-# [-E, --embedded]
-# Output parser which doesn't need runtime files (racc/parser.rb).
-# [-C, --check-only]
-# Check syntax of racc grammar file and quit.
-# [-S, --output-status]
-# Print messages time to time while compiling.
-# [-l, --no-line-convert]
-# turns off line number converting.
-# [-c, --line-convert-all]
-# Convert line number of actions, inner, header and footer.
-# [-a, --no-omit-actions]
-# Call all actions, even if an action is empty.
-# [--version]
-# print Racc version and quit.
-# [--copyright]
-# Print copyright and quit.
-# [--help]
-# Print usage and quit.
-#
-# == Generating Parser Using Racc
-#
-# To compile Racc grammar file, simply type:
-#
-# $ racc parse.y
-#
-# This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
-#
-# == Writing A Racc Grammar File
-#
-# If you want your own parser, you have to write a grammar file.
-# A grammar file contains the name of your parser class, grammar for the parser,
-# user code, and anything else.
-# When writing a grammar file, yacc's knowledge is helpful.
-# If you have not used yacc before, Racc is not too difficult.
-#
-# Here's an example Racc grammar file.
-#
-# class Calcparser
-# rule
-# target: exp { print val[0] }
-#
-# exp: exp '+' exp
-# | exp '*' exp
-# | '(' exp ')'
-# | NUMBER
-# end
-#
-# Racc grammar files resemble yacc files.
-# But (of course), this is Ruby code.
-# yacc's $$ is the 'result', $0, $1... is
-# an array called 'val', and $-1, $-2... is an array called '_values'.
-#
-# See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
-# more information on grammar files.
-#
-# == Parser
-#
-# Then you must prepare the parse entry method. There are two types of
-# parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
-#
-# Racc::Parser#do_parse is simple.
-#
-# It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
-# This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
-# EOF is [false, false].
-# (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
-# If you want to change this, see the grammar reference.
-#
-# Racc::Parser#yyparse is little complicated, but useful.
-# It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
-#
-# For example, <code>yyparse(obj, :scan)</code> causes
-# calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
-#
-# == Debugging
-#
-# When debugging, "-v" or/and the "-g" option is helpful.
-#
-# "-v" creates verbose log file (.output).
-# "-g" creates a "Verbose Parser".
-# Verbose Parser prints the internal status when parsing.
-# But it's _not_ automatic.
-# You must use -g option and set +@yydebug+ to +true+ in order to get output.
-# -g option only creates the verbose parser.
-#
-# === Racc reported syntax error.
-#
-# Isn't there too many "end"?
-# grammar of racc file is changed in v0.10.
-#
-# Racc does not use '%' mark, while yacc uses huge number of '%' marks..
-#
-# === Racc reported "XXXX conflicts".
-#
-# Try "racc -v xxxx.y".
-# It causes producing racc's internal log file, xxxx.output.
-#
-# === Generated parsers does not work correctly
-#
-# Try "racc -g xxxx.y".
-# This command let racc generate "debugging parser".
-# Then set @yydebug=true in your parser.
-# It produces a working log of your parser.
-#
-# == Re-distributing Racc runtime
-#
-# A parser, which is created by Racc, requires the Racc runtime module;
-# racc/parser.rb.
-#
-# Ruby 1.8.x comes with Racc runtime module,
-# you need NOT distribute Racc runtime files.
-#
-# If you want to include the Racc runtime module with your parser.
-# This can be done by using '-E' option:
-#
-# $ racc -E -omyparser.rb myparser.y
-#
-# This command creates myparser.rb which `includes' Racc runtime.
-# Only you must do is to distribute your parser file (myparser.rb).
-#
-# Note: parser.rb is ruby license, but your parser is not.
-# Your own parser is completely yours.
-module Racc
-
- unless defined?(Racc_No_Extensions)
- Racc_No_Extensions = false # :nodoc:
- end
-
- class Parser
-
- Racc_Runtime_Version = ::Racc::VERSION
- Racc_Runtime_Core_Version_R = ::Racc::VERSION
-
- begin
- if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
- require 'jruby'
- require 'racc/cparse-jruby.jar'
- com.headius.racc.Cparse.new.load(JRuby.runtime, false)
- else
- require 'racc/cparse'
- end
-
- unless new.respond_to?(:_racc_do_parse_c, true)
- raise LoadError, 'old cparse.so'
- end
- if Racc_No_Extensions
- raise LoadError, 'selecting ruby version of racc runtime core'
- end
-
- Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
- Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
- Racc_Runtime_Type = 'c' # :nodoc:
- rescue LoadError
- Racc_Main_Parsing_Routine = :_racc_do_parse_rb
- Racc_YY_Parse_Method = :_racc_yyparse_rb
- Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
- Racc_Runtime_Type = 'ruby'
- end
-
- def Parser.racc_runtime_type # :nodoc:
- Racc_Runtime_Type
- end
-
- def _racc_setup
- @yydebug = false unless self.class::Racc_debug_parser
- @yydebug = false unless defined?(@yydebug)
- if @yydebug
- @racc_debug_out = $stderr unless defined?(@racc_debug_out)
- @racc_debug_out ||= $stderr
- end
- arg = self.class::Racc_arg
- arg[13] = true if arg.size < 14
- arg
- end
-
- def _racc_init_sysvars
- @racc_state = [0]
- @racc_tstack = []
- @racc_vstack = []
-
- @racc_t = nil
- @racc_val = nil
-
- @racc_read_next = true
-
- @racc_user_yyerror = false
- @racc_error_status = 0
- end
-
- # The entry point of the parser. This method is used with #next_token.
- # If Racc wants to get token (and its value), calls next_token.
- #
- # Example:
- # def parse
- # @q = [[1,1],
- # [2,2],
- # [3,3],
- # [false, '$']]
- # do_parse
- # end
- #
- # def next_token
- # @q.shift
- # end
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
- def do_parse
- #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
- end
- RUBY
-
- # The method to fetch next token.
- # If you use #do_parse method, you must implement #next_token.
- #
- # The format of return value is [TOKEN_SYMBOL, VALUE].
- # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
- # for 'IDENT'. ";" (String) for ';'.
- #
- # The final symbol (End of file) must be false.
- def next_token
- raise NotImplementedError, "#{self.class}\#next_token is not defined"
- end
-
- def _racc_do_parse_rb(arg, in_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
- tok = act = i = nil
-
- catch(:racc_end_parse) {
- while true
- if i = action_pointer[@racc_state[-1]]
- if @racc_read_next
- if @racc_t != 0 # not EOF
- tok, @racc_val = next_token()
- unless tok # EOF
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- racc_read_token(@racc_t, tok, @racc_val) if @yydebug
- @racc_read_next = false
- end
- end
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- else
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- }
- end
-
- # Another entry point for the parser.
- # If you use this method, you must implement RECEIVER#METHOD_ID method.
- #
- # RECEIVER#METHOD_ID is a method to get next token.
- # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
- def yyparse(recv, mid)
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
- end
- RUBY
-
- def _racc_yyparse_rb(recv, mid, arg, c_debug)
- action_table, action_check, action_default, action_pointer,
- _, _, _, _,
- _, _, token_table, * = arg
-
- _racc_init_sysvars
-
- catch(:racc_end_parse) {
- until i = action_pointer[@racc_state[-1]]
- while act = _racc_evalact(action_default[@racc_state[-1]], arg)
- ;
- end
- end
- recv.__send__(mid) do |tok, val|
- unless tok
- @racc_t = 0
- else
- @racc_t = (token_table[tok] or 1) # error token
- end
- @racc_val = val
- @racc_read_next = false
-
- i += @racc_t
- unless i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
-
- while !(i = action_pointer[@racc_state[-1]]) ||
- ! @racc_read_next ||
- @racc_t == 0 # $
- unless i and i += @racc_t and
- i >= 0 and
- act = action_table[i] and
- action_check[i] == @racc_state[-1]
- act = action_default[@racc_state[-1]]
- end
- while act = _racc_evalact(act, arg)
- ;
- end
- end
- end
- }
- end
-
- ###
- ### common
- ###
-
- def _racc_evalact(act, arg)
- action_table, action_check, _, action_pointer,
- _, _, _, _,
- _, _, _, shift_n,
- reduce_n, * = arg
- nerr = 0 # tmp
-
- if act > 0 and act < shift_n
- #
- # shift
- #
- if @racc_error_status > 0
- @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
- end
- @racc_vstack.push @racc_val
- @racc_state.push act
- @racc_read_next = true
- if @yydebug
- @racc_tstack.push @racc_t
- racc_shift @racc_t, @racc_tstack, @racc_vstack
- end
-
- elsif act < 0 and act > -reduce_n
- #
- # reduce
- #
- code = catch(:racc_jump) {
- @racc_state.push _racc_do_reduce(arg, act)
- false
- }
- if code
- case code
- when 1 # yyerror
- @racc_user_yyerror = true # user_yyerror
- return -reduce_n
- when 2 # yyaccept
- return shift_n
- else
- raise '[Racc Bug] unknown jump code'
- end
- end
-
- elsif act == shift_n
- #
- # accept
- #
- racc_accept if @yydebug
- throw :racc_end_parse, @racc_vstack[0]
-
- elsif act == -reduce_n
- #
- # error
- #
- case @racc_error_status
- when 0
- unless arg[21] # user_yyerror
- nerr += 1
- on_error @racc_t, @racc_val, @racc_vstack
- end
- when 3
- if @racc_t == 0 # is $
- # We're at EOF, and another error occurred immediately after
- # attempting auto-recovery
- throw :racc_end_parse, nil
- end
- @racc_read_next = true
- end
- @racc_user_yyerror = false
- @racc_error_status = 3
- while true
- if i = action_pointer[@racc_state[-1]]
- i += 1 # error token
- if i >= 0 and
- (act = action_table[i]) and
- action_check[i] == @racc_state[-1]
- break
- end
- end
- throw :racc_end_parse, nil if @racc_state.size <= 1
- @racc_state.pop
- @racc_vstack.pop
- if @yydebug
- @racc_tstack.pop
- racc_e_pop @racc_state, @racc_tstack, @racc_vstack
- end
- end
- return act
-
- else
- raise "[Racc Bug] unknown action #{act.inspect}"
- end
-
- racc_next_state(@racc_state[-1], @racc_state) if @yydebug
-
- nil
- end
-
- def _racc_do_reduce(arg, act)
- _, _, _, _,
- goto_table, goto_check, goto_default, goto_pointer,
- nt_base, reduce_table, _, _,
- _, use_result, * = arg
-
- state = @racc_state
- vstack = @racc_vstack
- tstack = @racc_tstack
-
- i = act * -3
- len = reduce_table[i]
- reduce_to = reduce_table[i+1]
- method_id = reduce_table[i+2]
- void_array = []
-
- tmp_t = tstack[-len, len] if @yydebug
- tmp_v = vstack[-len, len]
- tstack[-len, len] = void_array if @yydebug
- vstack[-len, len] = void_array
- state[-len, len] = void_array
-
- # tstack must be updated AFTER method call
- if use_result
- vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
- else
- vstack.push __send__(method_id, tmp_v, vstack)
- end
- tstack.push reduce_to
-
- racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
- k1 = reduce_to - nt_base
- if i = goto_pointer[k1]
- i += state[-1]
- if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
- return curstate
- end
- end
- goto_default[k1]
- end
-
- # This method is called when a parse error is found.
- #
- # ERROR_TOKEN_ID is an internal ID of token which caused error.
- # You can get string representation of this ID by calling
- # #token_to_str.
- #
- # ERROR_VALUE is a value of error token.
- #
- # value_stack is a stack of symbol values.
- # DO NOT MODIFY this object.
- #
- # This method raises ParseError by default.
- #
- # If this method returns, parsers enter "error recovering mode".
- def on_error(t, val, vstack)
- raise ParseError, sprintf("\nparse error on value %s (%s)",
- val.inspect, token_to_str(t) || '?')
- end
-
- # Enter error recovering mode.
- # This method does not call #on_error.
- def yyerror
- throw :racc_jump, 1
- end
-
- # Exit parser.
- # Return value is +Symbol_Value_Stack[0]+.
- def yyaccept
- throw :racc_jump, 2
- end
-
- # Leave error recovering mode.
- def yyerrok
- @racc_error_status = 0
- end
-
- # For debugging output
- def racc_read_token(t, tok, val)
- @racc_debug_out.print 'read '
- @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
- @racc_debug_out.puts val.inspect
- @racc_debug_out.puts
- end
-
- def racc_shift(tok, tstack, vstack)
- @racc_debug_out.puts "shift #{racc_token2str tok}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_reduce(toks, sim, tstack, vstack)
- out = @racc_debug_out
- out.print 'reduce '
- if toks.empty?
- out.print ' <none>'
- else
- toks.each {|t| out.print ' ', racc_token2str(t) }
- end
- out.puts " --> #{racc_token2str(sim)}"
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_accept
- @racc_debug_out.puts 'accept'
- @racc_debug_out.puts
- end
-
- def racc_e_pop(state, tstack, vstack)
- @racc_debug_out.puts 'error recovering mode: pop token'
- racc_print_states state
- racc_print_stacks tstack, vstack
- @racc_debug_out.puts
- end
-
- def racc_next_state(curstate, state)
- @racc_debug_out.puts "goto #{curstate}"
- racc_print_states state
- @racc_debug_out.puts
- end
-
- def racc_print_stacks(t, v)
- out = @racc_debug_out
- out.print ' ['
- t.each_index do |i|
- out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
- end
- out.puts ' ]'
- end
-
- def racc_print_states(s)
- out = @racc_debug_out
- out.print ' ['
- s.each {|st| out.print ' ', st }
- out.puts ' ]'
- end
-
- def racc_token2str(tok)
- self.class::Racc_token_to_s_table[tok] or
- raise "[Racc Bug] can't convert token #{tok} to string"
- end
-
- # Convert internal ID of token symbol to the string.
- def token_to_str(t)
- self.class::Racc_token_to_s_table[t]
- end
-
- end
-
-end
diff --git a/lib/racc/parserfilegenerator.rb b/lib/racc/parserfilegenerator.rb
deleted file mode 100644
index 7846b584fa..0000000000
--- a/lib/racc/parserfilegenerator.rb
+++ /dev/null
@@ -1,470 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc/compat'
-require 'racc/sourcetext'
-require 'racc/parser-text'
-require 'rbconfig'
-
-module Racc
-
- class ParserFileGenerator
-
- class Params
- def self.bool_attr(name)
- module_eval(<<-End)
- def #{name}?
- @#{name}
- end
-
- def #{name}=(b)
- @#{name} = b
- end
- End
- end
-
- attr_accessor :filename
- attr_accessor :classname
- attr_accessor :superclass
- bool_attr :omit_action_call
- bool_attr :result_var
- attr_accessor :header
- attr_accessor :inner
- attr_accessor :footer
-
- bool_attr :debug_parser
- bool_attr :convert_line
- bool_attr :convert_line_all
- bool_attr :embed_runtime
- bool_attr :make_executable
- attr_accessor :interpreter
-
- def initialize
- # Parameters derived from parser
- self.filename = nil
- self.classname = nil
- self.superclass = 'Racc::Parser'
- self.omit_action_call = true
- self.result_var = true
- self.header = []
- self.inner = []
- self.footer = []
-
- # Parameters derived from command line options
- self.debug_parser = false
- self.convert_line = true
- self.convert_line_all = false
- self.embed_runtime = false
- self.make_executable = false
- self.interpreter = nil
- end
- end
-
- def initialize(states, params)
- @states = states
- @grammar = states.grammar
- @params = params
- end
-
- def generate_parser
- string_io = StringIO.new
-
- init_line_conversion_system
- @f = string_io
- parser_file
-
- string_io.rewind
- string_io.read
- end
-
- def generate_parser_file(destpath)
- init_line_conversion_system
- File.open(destpath, 'w') {|f|
- @f = f
- parser_file
- }
- File.chmod 0755, destpath if @params.make_executable?
- end
-
- private
-
- def parser_file
- shebang @params.interpreter if @params.make_executable?
- notice
- line
- if @params.embed_runtime?
- embed_library runtime_source()
- else
- require 'racc/parser.rb'
- end
- header
- parser_class(@params.classname, @params.superclass) {
- inner
- state_transition_table
- }
- footer
- end
-
- c = ::RbConfig::CONFIG
- RUBY_PATH = "#{c['bindir']}/#{c['ruby_install_name']}#{c['EXEEXT']}"
-
- def shebang(path)
- line '#!' + (path == 'ruby' ? RUBY_PATH : path)
- end
-
- def notice
- line %q[#]
- line %q[# DO NOT MODIFY!!!!]
- line %Q[# This file is automatically generated by Racc #{Racc::Version}]
- line %Q[# from Racc grammar file "#{@params.filename}".]
- line %q[#]
- end
-
- def runtime_source
- SourceText.new(::Racc::PARSER_TEXT, 'racc/parser.rb', 1)
- end
-
- def embed_library(src)
- line %[###### #{src.filename} begin]
- line %[unless $".index '#{src.filename}']
- line %[$".push '#{src.filename}']
- put src, @params.convert_line?
- line %[end]
- line %[###### #{src.filename} end]
- end
-
- def require(feature)
- line "require '#{feature}'"
- end
-
- def parser_class(classname, superclass)
- mods = classname.split('::')
- classid = mods.pop
- mods.each do |mod|
- indent; line "module #{mod}"
- cref_push mod
- end
- indent; line "class #{classid} < #{superclass}"
- cref_push classid
- yield
- cref_pop
- indent; line "end \# class #{classid}"
- mods.reverse_each do |mod|
- cref_pop
- indent; line "end \# module #{mod}"
- end
- end
-
- def header
- @params.header.each do |src|
- line
- put src, @params.convert_line_all?
- end
- end
-
- def inner
- @params.inner.each do |src|
- line
- put src, @params.convert_line?
- end
- end
-
- def footer
- @params.footer.each do |src|
- line
- put src, @params.convert_line_all?
- end
- end
-
- # Low Level Routines
-
- def put(src, convert_line = false)
- if convert_line
- replace_location(src) {
- @f.puts src.text
- }
- else
- @f.puts src.text
- end
- end
-
- def line(str = '')
- @f.puts str
- end
-
- def init_line_conversion_system
- @cref = []
- @used_separator = {}
- end
-
- def cref_push(name)
- @cref.push name
- end
-
- def cref_pop
- @cref.pop
- end
-
- def indent
- @f.print ' ' * @cref.size
- end
-
- def toplevel?
- @cref.empty?
- end
-
- def replace_location(src)
- sep = make_separator(src)
- @f.print 'self.class.' if toplevel?
- @f.puts "module_eval(<<'#{sep}', '#{src.filename}', #{src.lineno})"
- yield
- @f.puts sep
- end
-
- def make_separator(src)
- sep = unique_separator(src.filename)
- sep *= 2 while src.text.index(sep)
- sep
- end
-
- def unique_separator(id)
- sep = String.new "...end #{id}/module_eval..."
- while @used_separator.key?(sep)
- sep.concat sprintf('%02x', rand(255))
- end
- @used_separator[sep] = true
- sep
- end
-
- #
- # State Transition Table Serialization
- #
-
- public
-
- def put_state_transition_table(f)
- @f = f
- state_transition_table
- end
-
- private
-
- def state_transition_table
- table = @states.state_transition_table
- table.use_result_var = @params.result_var?
- table.debug_parser = @params.debug_parser?
-
- line "##### State transition tables begin ###"
- line
- integer_list 'racc_action_table', table.action_table
- line
- integer_list 'racc_action_check', table.action_check
- line
- integer_list 'racc_action_pointer', table.action_pointer
- line
- integer_list 'racc_action_default', table.action_default
- line
- integer_list 'racc_goto_table', table.goto_table
- line
- integer_list 'racc_goto_check', table.goto_check
- line
- integer_list 'racc_goto_pointer', table.goto_pointer
- line
- integer_list 'racc_goto_default', table.goto_default
- line
- i_i_sym_list 'racc_reduce_table', table.reduce_table
- line
- line "racc_reduce_n = #{table.reduce_n}"
- line
- line "racc_shift_n = #{table.shift_n}"
- line
- sym_int_hash 'racc_token_table', table.token_table
- line
- line "racc_nt_base = #{table.nt_base}"
- line
- line "racc_use_result_var = #{table.use_result_var}"
- line
- @f.print(unindent_auto(<<-End))
- Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
- End
- line "Ractor.make_shareable(Racc_arg) if defined?(Ractor)"
- line
- string_list 'Racc_token_to_s_table', table.token_to_s_table
- line "Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)"
- line
- line "Racc_debug_parser = #{table.debug_parser}"
- line
- line '##### State transition tables end #####'
- actions
- end
-
- def integer_list(name, table)
- sep = ''
- line "#{name} = ["
- table.each_slice(10) do |ns|
- @f.print sep; sep = ",\n"
- @f.print ns.map {|n| sprintf('%6s', n ? n.to_s : 'nil') }.join(',')
- end
- line ' ]'
- end
-
- def i_i_sym_list(name, table)
- sep = ''
- line "#{name} = ["
- table.each_slice(3) do |len, target, mid|
- @f.print sep; sep = ",\n"
- @f.printf ' %d, %d, %s', len, target, mid.inspect
- end
- line " ]"
- end
-
- def sym_int_hash(name, h)
- sep = "\n"
- @f.print "#{name} = {"
- h.to_a.sort_by {|sym, i| i }.each do |sym, i|
- @f.print sep; sep = ",\n"
- @f.printf " %s => %d", sym.serialize, i
- end
- line " }"
- end
-
- def string_list(name, list)
- sep = " "
- line "#{name} = ["
- list.each do |s|
- @f.print sep; sep = ",\n "
- @f.print s.dump
- end
- line ' ]'
- end
-
- def actions
- @grammar.each do |rule|
- unless rule.action.source?
- raise "racc: fatal: cannot generate parser file when any action is a Proc"
- end
- end
-
- if @params.result_var?
- decl = ', result'
- retval = "\n result"
- default_body = ''
- else
- decl = ''
- retval = ''
- default_body = 'val[0]'
- end
- @grammar.each do |rule|
- line
- if rule.action.empty? and @params.omit_action_call?
- line "# reduce #{rule.ident} omitted"
- else
- src0 = rule.action.source || SourceText.new(default_body, __FILE__, 0)
- if @params.convert_line?
- src = remove_blank_lines(src0)
- delim = make_delimiter(src.text)
- @f.printf unindent_auto(<<-End),
- module_eval(<<'%s', '%s', %d)
- def _reduce_%d(val, _values%s)
- %s%s
- end
- %s
- End
- delim, src.filename, src.lineno - 1,
- rule.ident, decl,
- src.text, retval,
- delim
- else
- src = remove_blank_lines(src0)
- @f.printf unindent_auto(<<-End),
- def _reduce_%d(val, _values%s)
- %s%s
- end
- End
- rule.ident, decl,
- src.text, retval
- end
- end
- end
- line
- @f.printf unindent_auto(<<-'End'), decl
- def _reduce_none(val, _values%s)
- val[0]
- end
- End
- line
- end
-
- def remove_blank_lines(src)
- body = src.text.dup
- line = src.lineno
- while body.slice!(/\A[ \t\f]*(?:\n|\r\n|\r)/)
- line += 1
- end
- SourceText.new(body, src.filename, line)
- end
-
- def make_delimiter(body)
- delim = '.,.,'
- while body.index(delim)
- delim *= 2
- end
- delim
- end
-
- def unindent_auto(str)
- lines = str.lines.to_a
- n = minimum_indent(lines)
- lines.map {|line| detab(line).sub(indent_re(n), '').rstrip + "\n" }.join('')
- end
-
- def minimum_indent(lines)
- lines.map {|line| n_indent(line) }.min
- end
-
- def n_indent(line)
- line.slice(/\A\s+/).size
- end
-
- RE_CACHE = {}
-
- def indent_re(n)
- RE_CACHE[n] ||= /\A {#{n}}/
- end
-
- def detab(str, ts = 8)
- add = 0
- len = nil
- str.gsub(/\t/) {
- len = ts - ($`.size + add) % ts
- add += len - 1
- ' ' * len
- }
- end
-
- end
-
-end
diff --git a/lib/racc/racc.gemspec b/lib/racc/racc.gemspec
deleted file mode 100644
index 1095c8f47e..0000000000
--- a/lib/racc/racc.gemspec
+++ /dev/null
@@ -1,58 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-begin
- require_relative "lib/racc/info"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "info"
-end
-
-Gem::Specification.new do |s|
- s.name = "racc"
- s.version = Racc::VERSION
- s.summary = "Racc is a LALR(1) parser generator"
- s.description = <<DESC
-Racc is a LALR(1) parser generator.
- It is written in Ruby itself, and generates Ruby program.
-
- NOTE: Ruby 1.8.x comes with Racc runtime module. You
- can run your parsers generated by racc 1.4.x out of the
- box.
-DESC
- s.authors = ["Minero Aoki", "Aaron Patterson"]
- s.email = [nil, "aaron@tenderlovemaking.com"]
- s.homepage = "https://github.com/ruby/racc"
- s.licenses = ["Ruby", "BSD-2-Clause"]
- s.executables = ["racc"]
- s.files = [
- "COPYING", "ChangeLog", "TODO",
- "README.ja.rdoc", "README.rdoc", "bin/racc",
- "ext/racc/MANIFEST",
- "ext/racc/cparse/cparse.c",
- "ext/racc/cparse/extconf.rb",
- "lib/racc.rb", "lib/racc/compat.rb",
- "lib/racc/debugflags.rb", "lib/racc/exception.rb",
- "lib/racc/grammar.rb", "lib/racc/grammarfileparser.rb",
- "lib/racc/info.rb", "lib/racc/iset.rb",
- "lib/racc/logfilegenerator.rb", "lib/racc/parser-text.rb",
- "lib/racc/parser.rb", "lib/racc/parserfilegenerator.rb",
- "lib/racc/sourcetext.rb",
- "lib/racc/state.rb", "lib/racc/statetransitiontable.rb",
- "lib/racc/static.rb",
- "doc/en/NEWS.en.rdoc", "doc/en/grammar2.en.rdoc",
- "doc/en/grammar.en.rdoc", "doc/ja/NEWS.ja.rdoc",
- "doc/ja/command.ja.html", "doc/ja/debug.ja.rdoc",
- "doc/ja/grammar.ja.rdoc", "doc/ja/index.ja.html",
- "doc/ja/parser.ja.rdoc", "doc/ja/usage.ja.html",
- ]
- s.require_paths = ["lib"]
- s.required_ruby_version = ">= 2.5"
- s.rdoc_options = ["--main", "README.rdoc"]
- s.extra_rdoc_files = ["README.ja.rdoc", "README.rdoc"]
-
- if RUBY_PLATFORM =~ /java/
- s.files << 'lib/racc/cparse-jruby.jar'
- s.platform = 'java'
- else
- s.extensions = ["ext/racc/cparse/extconf.rb"]
- end
-end
diff --git a/lib/racc/sourcetext.rb b/lib/racc/sourcetext.rb
deleted file mode 100644
index de52dcae9b..0000000000
--- a/lib/racc/sourcetext.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
-
- class SourceText
- def initialize(text, filename, lineno)
- @text = text
- @filename = filename
- @lineno = lineno
- end
-
- attr_reader :text
- attr_reader :filename
- attr_reader :lineno
-
- def to_s
- "#<SourceText #{location()}>"
- end
-
- def location
- "#{@filename}:#{@lineno}"
- end
- end
-
-end
diff --git a/lib/racc/state.rb b/lib/racc/state.rb
deleted file mode 100644
index f85809fbeb..0000000000
--- a/lib/racc/state.rb
+++ /dev/null
@@ -1,972 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc/iset'
-require 'racc/statetransitiontable'
-require 'racc/exception'
-require 'forwardable'
-
-module Racc
-
- # A table of LALR states.
- class States
-
- include Enumerable
-
- def initialize(grammar, debug_flags = DebugFlags.new)
- @grammar = grammar
- @symboltable = grammar.symboltable
- @d_state = debug_flags.state
- @d_la = debug_flags.la
- @d_prec = debug_flags.prec
- @states = []
- @statecache = {}
- @actions = ActionTable.new(@grammar, self)
- @nfa_computed = false
- @dfa_computed = false
- end
-
- attr_reader :grammar
- attr_reader :actions
-
- def size
- @states.size
- end
-
- def inspect
- '#<state table>'
- end
-
- alias to_s inspect
-
- def [](i)
- @states[i]
- end
-
- def each_state(&block)
- @states.each(&block)
- end
-
- alias each each_state
-
- def each_index(&block)
- @states.each_index(&block)
- end
-
- extend Forwardable
-
- def_delegator "@actions", :shift_n
- def_delegator "@actions", :reduce_n
- def_delegator "@actions", :nt_base
-
- def should_report_srconflict?
- srconflict_exist? and
- (n_srconflicts() != @grammar.n_expected_srconflicts)
- end
-
- def srconflict_exist?
- n_srconflicts() != 0
- end
-
- def n_srconflicts
- @n_srconflicts ||= inject(0) {|sum, st| sum + st.n_srconflicts }
- end
-
- def rrconflict_exist?
- n_rrconflicts() != 0
- end
-
- def n_rrconflicts
- @n_rrconflicts ||= inject(0) {|sum, st| sum + st.n_rrconflicts }
- end
-
- def state_transition_table
- @state_transition_table ||= StateTransitionTable.generate(self.dfa)
- end
-
- #
- # NFA (Non-deterministic Finite Automaton) Computation
- #
-
- public
-
- def nfa
- return self if @nfa_computed
- compute_nfa
- @nfa_computed = true
- self
- end
-
- private
-
- def compute_nfa
- @grammar.init
- # add state 0
- core_to_state [ @grammar[0].ptrs[0] ]
- # generate LALR states
- cur = 0
- @gotos = []
- while cur < @states.size
- generate_states @states[cur] # state is added here
- cur += 1
- end
- @actions.init
- end
-
- def generate_states(state)
- puts "dstate: #{state}" if @d_state
-
- table = {}
- state.closure.each do |ptr|
- if sym = ptr.dereference
- addsym table, sym, ptr.next
- end
- end
- table.each do |sym, core|
- puts "dstate: sym=#{sym} ncore=#{core}" if @d_state
-
- dest = core_to_state(core.to_a)
- state.goto_table[sym] = dest
- id = sym.nonterminal?() ? @gotos.size : nil
- g = Goto.new(id, sym, state, dest)
- @gotos.push g if sym.nonterminal?
- state.gotos[sym] = g
- puts "dstate: #{state.ident} --#{sym}--> #{dest.ident}" if @d_state
-
- # check infinite recursion
- if state.ident == dest.ident and state.closure.size == 1
- raise CompileError,
- sprintf("Infinite recursion: state %d, with rule %d",
- state.ident, state.ptrs[0].rule.ident)
- end
- end
- end
-
- def addsym(table, sym, ptr)
- unless s = table[sym]
- table[sym] = s = ISet.new
- end
- s.add ptr
- end
-
- def core_to_state(core)
- #
- # convert CORE to a State object.
- # If matching state does not exist, create it and add to the table.
- #
-
- k = fingerprint(core)
- unless dest = @statecache[k]
- # not registered yet
- dest = State.new(@states.size, core)
- @states.push dest
-
- @statecache[k] = dest
-
- puts "core_to_state: create state ID #{dest.ident}" if @d_state
- else
- if @d_state
- puts "core_to_state: dest is cached ID #{dest.ident}"
- puts "core_to_state: dest core #{dest.core.join(' ')}"
- end
- end
-
- dest
- end
-
- def fingerprint(arr)
- arr.map {|i| i.ident }.pack('L*')
- end
-
- #
- # DFA (Deterministic Finite Automaton) Generation
- #
-
- public
-
- def dfa
- return self if @dfa_computed
- nfa
- compute_dfa
- @dfa_computed = true
- self
- end
-
- private
-
- def compute_dfa
- la = lookahead()
- @states.each do |state|
- state.la = la
- resolve state
- end
- set_accept
- @states.each do |state|
- pack state
- end
- check_useless
- end
-
- def lookahead
- #
- # lookahead algorithm ver.3 -- from bison 1.26
- #
-
- gotos = @gotos
- if @d_la
- puts "\n--- goto ---"
- gotos.each_with_index {|g, i| print i, ' '; p g }
- end
-
- ### initialize_LA()
- ### set_goto_map()
- la_rules = []
- @states.each do |state|
- state.check_la la_rules
- end
-
- ### initialize_F()
- f = create_tmap(gotos.size)
- reads = []
- edge = []
- gotos.each do |goto|
- goto.to_state.goto_table.each do |t, st|
- if t.terminal?
- f[goto.ident] |= (1 << t.ident)
- elsif t.nullable?
- edge.push goto.to_state.gotos[t].ident
- end
- end
- if edge.empty?
- reads.push nil
- else
- reads.push edge
- edge = []
- end
- end
- digraph f, reads
- if @d_la
- puts "\n--- F1 (reads) ---"
- print_tab gotos, reads, f
- end
-
- ### build_relations()
- ### compute_FOLLOWS
- path = nil
- edge = []
- lookback = Array.new(la_rules.size, nil)
- includes = []
- gotos.each do |goto|
- goto.symbol.heads.each do |ptr|
- path = record_path(goto.from_state, ptr.rule)
- lastgoto = path.last
- st = lastgoto ? lastgoto.to_state : goto.from_state
- if st.conflict?
- addrel lookback, st.rruleid(ptr.rule), goto
- end
- path.reverse_each do |g|
- break if g.symbol.terminal?
- edge.push g.ident
- break unless g.symbol.nullable?
- end
- end
- if edge.empty?
- includes.push nil
- else
- includes.push edge
- edge = []
- end
- end
- includes = transpose(includes)
- digraph f, includes
- if @d_la
- puts "\n--- F2 (includes) ---"
- print_tab gotos, includes, f
- end
-
- ### compute_lookaheads
- la = create_tmap(la_rules.size)
- lookback.each_with_index do |arr, i|
- if arr
- arr.each do |g|
- la[i] |= f[g.ident]
- end
- end
- end
- if @d_la
- puts "\n--- LA (lookback) ---"
- print_tab la_rules, lookback, la
- end
-
- la
- end
-
- def create_tmap(size)
- Array.new(size, 0) # use Integer as bitmap
- end
-
- def addrel(tbl, i, item)
- if a = tbl[i]
- a.push item
- else
- tbl[i] = [item]
- end
- end
-
- def record_path(begst, rule)
- st = begst
- path = []
- rule.symbols.each do |t|
- goto = st.gotos[t]
- path.push goto
- st = goto.to_state
- end
- path
- end
-
- def transpose(rel)
- new = Array.new(rel.size, nil)
- rel.each_with_index do |arr, idx|
- if arr
- arr.each do |i|
- addrel new, i, idx
- end
- end
- end
- new
- end
-
- def digraph(map, relation)
- n = relation.size
- index = Array.new(n, nil)
- vertices = []
- @infinity = n + 2
-
- index.each_index do |i|
- if not index[i] and relation[i]
- traverse i, index, vertices, map, relation
- end
- end
- end
-
- def traverse(i, index, vertices, map, relation)
- vertices.push i
- index[i] = height = vertices.size
-
- if rp = relation[i]
- rp.each do |proci|
- unless index[proci]
- traverse proci, index, vertices, map, relation
- end
- if index[i] > index[proci]
- # circulative recursion !!!
- index[i] = index[proci]
- end
- map[i] |= map[proci]
- end
- end
-
- if index[i] == height
- while true
- proci = vertices.pop
- index[proci] = @infinity
- break if i == proci
-
- map[proci] |= map[i]
- end
- end
- end
-
- # for debug
- def print_atab(idx, tab)
- tab.each_with_index do |i,ii|
- printf '%-20s', idx[ii].inspect
- p i
- end
- end
-
- def print_tab(idx, rel, tab)
- tab.each_with_index do |bin,i|
- print i, ' ', idx[i].inspect, ' << '; p rel[i]
- print ' '
- each_t(@symboltable, bin) {|t| print ' ', t }
- puts
- end
- end
-
- # for debug
- def print_tab_i(idx, rel, tab, i)
- bin = tab[i]
- print i, ' ', idx[i].inspect, ' << '; p rel[i]
- print ' '
- each_t(@symboltable, bin) {|t| print ' ', t }
- end
-
- # for debug
- def printb(i)
- each_t(@symboltable, i) do |t|
- print t, ' '
- end
- puts
- end
-
- def each_t(tbl, set)
- 0.upto( set.size ) do |i|
- (0..7).each do |ii|
- if set[idx = i * 8 + ii] == 1
- yield tbl[idx]
- end
- end
- end
- end
-
- #
- # resolve
- #
-
- def resolve(state)
- if state.conflict?
- resolve_rr state, state.ritems
- resolve_sr state, state.stokens
- else
- if state.rrules.empty?
- # shift
- state.stokens.each do |t|
- state.action[t] = @actions.shift(state.goto_table[t])
- end
- else
- # reduce
- state.defact = @actions.reduce(state.rrules[0])
- end
- end
- end
-
- def resolve_rr(state, r)
- r.each do |item|
- item.each_la(@symboltable) do |t|
- act = state.action[t]
- if act
- unless act.kind_of?(Reduce)
- raise "racc: fatal: #{act.class} in action table"
- end
- # Cannot resolve R/R conflict (on t).
- # Reduce with upper rule as default.
- state.rr_conflict act.rule, item.rule, t
- else
- # No conflict.
- state.action[t] = @actions.reduce(item.rule)
- end
- end
- end
- end
-
- def resolve_sr(state, s)
- s.each do |stok|
- goto = state.goto_table[stok]
- act = state.action[stok]
-
- unless act
- # no conflict
- state.action[stok] = @actions.shift(goto)
- else
- unless act.kind_of?(Reduce)
- puts 'DEBUG -------------------------------'
- p stok
- p act
- state.action.each do |k,v|
- print k.inspect, ' ', v.inspect, "\n"
- end
- raise "racc: fatal: #{act.class} in action table"
- end
-
- # conflict on stok
-
- rtok = act.rule.precedence
- case do_resolve_sr(stok, rtok)
- when :Reduce
- # action is already set
-
- when :Shift
- # overwrite
- act.decref
- state.action[stok] = @actions.shift(goto)
-
- when :Error
- act.decref
- state.action[stok] = @actions.error
-
- when :CantResolve
- # shift as default
- act.decref
- state.action[stok] = @actions.shift(goto)
- state.sr_conflict stok, act.rule
- end
- end
- end
- end
-
- ASSOC = {
- :Left => :Reduce,
- :Right => :Shift,
- :Nonassoc => :Error
- }
-
- def do_resolve_sr(stok, rtok)
- puts "resolve_sr: s/r conflict: rtok=#{rtok}, stok=#{stok}" if @d_prec
-
- unless rtok and rtok.precedence
- puts "resolve_sr: no prec for #{rtok}(R)" if @d_prec
- return :CantResolve
- end
- rprec = rtok.precedence
-
- unless stok and stok.precedence
- puts "resolve_sr: no prec for #{stok}(S)" if @d_prec
- return :CantResolve
- end
- sprec = stok.precedence
-
- ret = if rprec == sprec
- ASSOC[rtok.assoc] or
- raise "racc: fatal: #{rtok}.assoc is not Left/Right/Nonassoc"
- else
- (rprec > sprec) ? (:Reduce) : (:Shift)
- end
-
- puts "resolve_sr: resolved as #{ret.id2name}" if @d_prec
- ret
- end
-
- #
- # complete
- #
-
- def set_accept
- anch = @symboltable.anchor
- init_state = @states[0].goto_table[@grammar.start]
- targ_state = init_state.action[anch].goto_state
- acc_state = targ_state.action[anch].goto_state
-
- acc_state.action.clear
- acc_state.goto_table.clear
- acc_state.defact = @actions.accept
- end
-
- def pack(state)
- ### find most frequently used reduce rule
- act = state.action
- arr = Array.new(@grammar.size, 0)
- act.each do |t, a|
- arr[a.ruleid] += 1 if a.kind_of?(Reduce)
- end
- i = arr.max
- s = (i > 0) ? arr.index(i) : nil
-
- ### set & delete default action
- if s
- r = @actions.reduce(s)
- if not state.defact or state.defact == r
- act.delete_if {|t, a| a == r }
- state.defact = r
- end
- else
- state.defact ||= @actions.error
- end
- end
-
- def check_useless
- used = []
- @actions.each_reduce do |act|
- if not act or act.refn == 0
- act.rule.useless = true
- else
- t = act.rule.target
- used[t.ident] = t
- end
- end
- @symboltable.nt_base.upto(@symboltable.nt_max - 1) do |n|
- unless used[n]
- @symboltable[n].useless = true
- end
- end
- end
-
- end # class StateTable
-
-
- # A LALR state.
- class State
-
- def initialize(ident, core)
- @ident = ident
- @core = core
- @goto_table = {}
- @gotos = {}
- @stokens = nil
- @ritems = nil
- @action = {}
- @defact = nil
- @rrconf = nil
- @srconf = nil
-
- @closure = make_closure(@core)
- end
-
- attr_reader :ident
- alias stateid ident
- alias hash ident
-
- attr_reader :core
- attr_reader :closure
-
- attr_reader :goto_table
- attr_reader :gotos
-
- attr_reader :stokens
- attr_reader :ritems
- attr_reader :rrules
-
- attr_reader :action
- attr_accessor :defact # default action
-
- attr_reader :rrconf
- attr_reader :srconf
-
- def inspect
- "<state #{@ident}>"
- end
-
- alias to_s inspect
-
- def ==(oth)
- @ident == oth.ident
- end
-
- alias eql? ==
-
- def make_closure(core)
- set = ISet.new
- core.each do |ptr|
- set.add ptr
- if t = ptr.dereference and t.nonterminal?
- set.update_a t.expand
- end
- end
- set.to_a
- end
-
- def check_la(la_rules)
- @conflict = false
- s = []
- r = []
- @closure.each do |ptr|
- if t = ptr.dereference
- if t.terminal?
- s[t.ident] = t
- if t.ident == 1 # $error
- @conflict = true
- end
- end
- else
- r.push ptr.rule
- end
- end
- unless r.empty?
- if not s.empty? or r.size > 1
- @conflict = true
- end
- end
- s.compact!
- @stokens = s
- @rrules = r
-
- if @conflict
- @la_rules_i = la_rules.size
- @la_rules = r.map {|i| i.ident }
- la_rules.concat r
- else
- @la_rules_i = @la_rules = nil
- end
- end
-
- def conflict?
- @conflict
- end
-
- def rruleid(rule)
- if i = @la_rules.index(rule.ident)
- @la_rules_i + i
- else
- puts '/// rruleid'
- p self
- p rule
- p @rrules
- p @la_rules_i
- raise 'racc: fatal: cannot get reduce rule id'
- end
- end
-
- def la=(la)
- return unless @conflict
- i = @la_rules_i
- @ritems = r = []
- @rrules.each do |rule|
- r.push Item.new(rule, la[i])
- i += 1
- end
- end
-
- def rr_conflict(high, low, ctok)
- c = RRconflict.new(@ident, high, low, ctok)
-
- @rrconf ||= {}
- if a = @rrconf[ctok]
- a.push c
- else
- @rrconf[ctok] = [c]
- end
- end
-
- def sr_conflict(shift, reduce)
- c = SRconflict.new(@ident, shift, reduce)
-
- @srconf ||= {}
- if a = @srconf[shift]
- a.push c
- else
- @srconf[shift] = [c]
- end
- end
-
- def n_srconflicts
- @srconf ? @srconf.size : 0
- end
-
- def n_rrconflicts
- @rrconf ? @rrconf.size : 0
- end
-
- end # class State
-
-
- #
- # Represents a transition on the grammar.
- # "Real goto" means a transition by nonterminal,
- # but this class treats also terminal's.
- # If one is a terminal transition, .ident returns nil.
- #
- class Goto
- def initialize(ident, sym, from, to)
- @ident = ident
- @symbol = sym
- @from_state = from
- @to_state = to
- end
-
- attr_reader :ident
- attr_reader :symbol
- attr_reader :from_state
- attr_reader :to_state
-
- def inspect
- "(#{@from_state.ident}-#{@symbol}->#{@to_state.ident})"
- end
- end
-
-
- # LALR item. A set of rule and its lookahead tokens.
- class Item
- def initialize(rule, la)
- @rule = rule
- @la = la
- end
-
- attr_reader :rule
- attr_reader :la
-
- def each_la(tbl)
- la = @la
- 0.upto(la.size - 1) do |i|
- (0..7).each do |ii|
- if la[idx = i * 8 + ii] == 1
- yield tbl[idx]
- end
- end
- end
- end
- end
-
-
- # The table of LALR actions. Actions are either of
- # Shift, Reduce, Accept and Error.
- class ActionTable
-
- def initialize(rt, st)
- @grammar = rt
- @statetable = st
-
- @reduce = []
- @shift = []
- @accept = nil
- @error = nil
- end
-
- def init
- @grammar.each do |rule|
- @reduce.push Reduce.new(rule)
- end
- @statetable.each do |state|
- @shift.push Shift.new(state)
- end
- @accept = Accept.new
- @error = Error.new
- end
-
- def reduce_n
- @reduce.size
- end
-
- def reduce(i)
- case i
- when Rule then i = i.ident
- when Integer then ;
- else
- raise "racc: fatal: wrong class #{i.class} for reduce"
- end
-
- r = @reduce[i] or raise "racc: fatal: reduce action #{i.inspect} not exist"
- r.incref
- r
- end
-
- def each_reduce(&block)
- @reduce.each(&block)
- end
-
- def shift_n
- @shift.size
- end
-
- def shift(i)
- case i
- when State then i = i.ident
- when Integer then ;
- else
- raise "racc: fatal: wrong class #{i.class} for shift"
- end
-
- @shift[i] or raise "racc: fatal: shift action #{i} does not exist"
- end
-
- def each_shift(&block)
- @shift.each(&block)
- end
-
- attr_reader :accept
- attr_reader :error
-
- end
-
-
- class Shift
- def initialize(goto)
- @goto_state = goto
- end
-
- attr_reader :goto_state
-
- def goto_id
- @goto_state.ident
- end
-
- def inspect
- "<shift #{@goto_state.ident}>"
- end
- end
-
-
- class Reduce
- def initialize(rule)
- @rule = rule
- @refn = 0
- end
-
- attr_reader :rule
- attr_reader :refn
-
- def ruleid
- @rule.ident
- end
-
- def inspect
- "<reduce #{@rule.ident}>"
- end
-
- def incref
- @refn += 1
- end
-
- def decref
- @refn -= 1
- raise 'racc: fatal: act.refn < 0' if @refn < 0
- end
- end
-
- class Accept
- def inspect
- "<accept>"
- end
- end
-
- class Error
- def inspect
- "<error>"
- end
- end
-
- class SRconflict
- def initialize(sid, shift, reduce)
- @stateid = sid
- @shift = shift
- @reduce = reduce
- end
-
- attr_reader :stateid
- attr_reader :shift
- attr_reader :reduce
-
- def to_s
- sprintf('state %d: S/R conflict rule %d reduce and shift %s',
- @stateid, @reduce.ruleid, @shift.to_s)
- end
- end
-
- class RRconflict
- def initialize(sid, high, low, tok)
- @stateid = sid
- @high_prec = high
- @low_prec = low
- @token = tok
- end
-
- attr_reader :stateid
- attr_reader :high_prec
- attr_reader :low_prec
- attr_reader :token
-
- def to_s
- sprintf('state %d: R/R conflict with rule %d and %d on %s',
- @stateid, @high_prec.ident, @low_prec.ident, @token.to_s)
- end
- end
-
-end
diff --git a/lib/racc/statetransitiontable.rb b/lib/racc/statetransitiontable.rb
deleted file mode 100644
index d75fa1657a..0000000000
--- a/lib/racc/statetransitiontable.rb
+++ /dev/null
@@ -1,311 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc/parser'
-
-module Racc
-
- StateTransitionTable = Struct.new(:action_table,
- :action_check,
- :action_default,
- :action_pointer,
- :goto_table,
- :goto_check,
- :goto_default,
- :goto_pointer,
- :token_table,
- :reduce_table,
- :reduce_n,
- :shift_n,
- :nt_base,
- :token_to_s_table,
- :use_result_var,
- :debug_parser)
- class StateTransitionTable # reopen
- def StateTransitionTable.generate(states)
- StateTransitionTableGenerator.new(states).generate
- end
-
- def initialize(states)
- super()
- @states = states
- @grammar = states.grammar
- self.use_result_var = true
- self.debug_parser = true
- end
-
- attr_reader :states
- attr_reader :grammar
-
- def parser_class
- ParserClassGenerator.new(@states).generate
- end
-
- def token_value_table
- h = {}
- token_table().each do |sym, i|
- h[sym.value] = i
- end
- h
- end
- end
-
-
- class StateTransitionTableGenerator
-
- def initialize(states)
- @states = states
- @grammar = states.grammar
- end
-
- def generate
- t = StateTransitionTable.new(@states)
- gen_action_tables t, @states
- gen_goto_tables t, @grammar
- t.token_table = token_table(@grammar)
- t.reduce_table = reduce_table(@grammar)
- t.reduce_n = @states.reduce_n
- t.shift_n = @states.shift_n
- t.nt_base = @grammar.nonterminal_base
- t.token_to_s_table = @grammar.symbols.map {|sym| sym.to_s }
- t
- end
-
- def reduce_table(grammar)
- t = [0, 0, :racc_error]
- grammar.each_with_index do |rule, idx|
- next if idx == 0
- t.push rule.size
- t.push rule.target.ident
- t.push(if rule.action.empty? # and @params.omit_action_call?
- then :_reduce_none
- else "_reduce_#{idx}".intern
- end)
- end
- t
- end
-
- def token_table(grammar)
- h = {}
- grammar.symboltable.terminals.each do |t|
- h[t] = t.ident
- end
- h
- end
-
- def gen_action_tables(t, states)
- t.action_table = yytable = []
- t.action_check = yycheck = []
- t.action_default = yydefact = []
- t.action_pointer = yypact = []
- e1 = []
- e2 = []
- states.each do |state|
- yydefact.push act2actid(state.defact)
- if state.action.empty?
- yypact.push nil
- next
- end
- vector = []
- state.action.each do |tok, act|
- vector[tok.ident] = act2actid(act)
- end
- addent e1, vector, state.ident, yypact
- end
- set_table e1, e2, yytable, yycheck, yypact
- end
-
- def gen_goto_tables(t, grammar)
- t.goto_table = yytable2 = []
- t.goto_check = yycheck2 = []
- t.goto_pointer = yypgoto = []
- t.goto_default = yydefgoto = []
- e1 = []
- e2 = []
- grammar.each_nonterminal do |tok|
- tmp = []
-
- # decide default
- freq = Array.new(@states.size, 0)
- @states.each do |state|
- st = state.goto_table[tok]
- if st
- st = st.ident
- freq[st] += 1
- end
- tmp[state.ident] = st
- end
- max = freq.max
- if max > 1
- default = freq.index(max)
- tmp.map! {|i| default == i ? nil : i }
- else
- default = nil
- end
- yydefgoto.push default
-
- # delete default value
- tmp.pop until tmp.last or tmp.empty?
- if tmp.compact.empty?
- # only default
- yypgoto.push nil
- next
- end
-
- addent e1, tmp, (tok.ident - grammar.nonterminal_base), yypgoto
- end
- set_table e1, e2, yytable2, yycheck2, yypgoto
- end
-
- def addent(all, arr, chkval, ptr)
- max = arr.size
- min = nil
- arr.each_with_index do |item, idx|
- if item
- min ||= idx
- end
- end
- ptr.push(-7777) # mark
- arr = arr[min...max]
- all.push [arr, chkval, mkmapexp(arr), min, ptr.size - 1]
- end
-
- n = 2 ** 16
- begin
- Regexp.compile("a{#{n}}")
- RE_DUP_MAX = n
- rescue RegexpError
- n /= 2
- retry
- end
-
- def mkmapexp(arr)
- i = ii = 0
- as = arr.size
- map = String.new
- maxdup = RE_DUP_MAX
- curr = nil
- while i < as
- ii = i + 1
- if arr[i]
- ii += 1 while ii < as and arr[ii]
- curr = '-'
- else
- ii += 1 while ii < as and not arr[ii]
- curr = '.'
- end
-
- offset = ii - i
- if offset == 1
- map << curr
- else
- while offset > maxdup
- map << "#{curr}{#{maxdup}}"
- offset -= maxdup
- end
- map << "#{curr}{#{offset}}" if offset > 1
- end
- i = ii
- end
- Regexp.compile(map, Regexp::NOENCODING)
- end
-
- def set_table(entries, dummy, tbl, chk, ptr)
- upper = 0
- map = '-' * 10240
-
- # sort long to short
- entries.sort_by!.with_index {|a,i| [-a[0].size, i] }
-
- entries.each do |arr, chkval, expr, min, ptri|
- if upper + arr.size > map.size
- map << '-' * (arr.size + 1024)
- end
- idx = map.index(expr)
- ptr[ptri] = idx - min
- arr.each_with_index do |item, i|
- if item
- i += idx
- tbl[i] = item
- chk[i] = chkval
- map[i] = ?o
- end
- end
- upper = idx + arr.size
- end
- end
-
- def act2actid(act)
- case act
- when Shift then act.goto_id
- when Reduce then -act.ruleid
- when Accept then @states.shift_n
- when Error then @states.reduce_n * -1
- else
- raise "racc: fatal: wrong act type #{act.class} in action table"
- end
- end
-
- end
-
-
- class ParserClassGenerator
-
- def initialize(states)
- @states = states
- @grammar = states.grammar
- end
-
- def generate
- table = @states.state_transition_table
- c = Class.new(::Racc::Parser)
- c.const_set :Racc_arg, [table.action_table,
- table.action_check,
- table.action_default,
- table.action_pointer,
- table.goto_table,
- table.goto_check,
- table.goto_default,
- table.goto_pointer,
- table.nt_base,
- table.reduce_table,
- table.token_value_table,
- table.shift_n,
- table.reduce_n,
- false]
- c.const_set :Racc_token_to_s_table, table.token_to_s_table
- c.const_set :Racc_debug_parser, true
- define_actions c
- c
- end
-
- private
-
- def define_actions(c)
- c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
- @grammar.each do |rule|
- if rule.action.empty?
- c.alias_method("_reduce_#{rule.ident}", :_reduce_none)
- else
- c.define_method("_racc_action_#{rule.ident}", &rule.action.proc)
- c.module_eval(<<-End, __FILE__, __LINE__ + 1)
- def _reduce_#{rule.ident}(vals, vstack)
- _racc_action_#{rule.ident}(*vals)
- end
- End
- end
- end
- end
-
- end
-
-end # module Racc
diff --git a/lib/racc/static.rb b/lib/racc/static.rb
deleted file mode 100644
index bebbeb5aa6..0000000000
--- a/lib/racc/static.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'racc'
-require 'racc/parser'
-require 'racc/grammarfileparser'
-require 'racc/parserfilegenerator'
-require 'racc/logfilegenerator'
diff --git a/lib/random/formatter.rb b/lib/random/formatter.rb
index 4dea61c16c..4ecd6ad027 100644
--- a/lib/random/formatter.rb
+++ b/lib/random/formatter.rb
@@ -165,15 +165,133 @@ module Random::Formatter
#
# The result contains 122 random bits (15.25 random bytes).
#
- # See RFC4122[https://datatracker.ietf.org/doc/html/rfc4122] for details of UUID.
+ # See RFC9562[https://www.rfc-editor.org/rfc/rfc9562] for details of UUIDv4.
#
def uuid
- ary = random_bytes(16).unpack("NnnnnN")
- ary[2] = (ary[2] & 0x0fff) | 0x4000
- ary[3] = (ary[3] & 0x3fff) | 0x8000
- "%08x-%04x-%04x-%04x-%04x%08x" % ary
+ ary = random_bytes(16)
+ ary.setbyte(6, (ary.getbyte(6) & 0x0f) | 0x40)
+ ary.setbyte(8, (ary.getbyte(8) & 0x3f) | 0x80)
+ ary.unpack("H8H4H4H4H12").join(?-)
end
+ alias uuid_v4 uuid
+
+ # Generate a random v7 UUID (Universally Unique IDentifier).
+ #
+ # require 'random/formatter'
+ #
+ # Random.uuid_v7 # => "0188d4c3-1311-7f96-85c7-242a7aa58f1e"
+ # Random.uuid_v7 # => "0188d4c3-16fe-744f-86af-38fa04c62bb5"
+ # Random.uuid_v7 # => "0188d4c3-1af8-764f-b049-c204ce0afa23"
+ # Random.uuid_v7 # => "0188d4c3-1e74-7085-b14f-ef6415dc6f31"
+ # # |<--sorted-->| |<----- random ---->|
+ #
+ # # or
+ # prng = Random.new
+ # prng.uuid_v7 # => "0188ca51-5e72-7950-a11d-def7ff977c98"
+ #
+ # The version 7 UUID starts with the least significant 48 bits of a 64 bit
+ # Unix timestamp (milliseconds since the epoch) and fills the remaining bits
+ # with random data, excluding the version and variant bits.
+ #
+ # This allows version 7 UUIDs to be sorted by creation time. Time ordered
+ # UUIDs can be used for better database index locality of newly inserted
+ # records, which may have a significant performance benefit compared to random
+ # data inserts.
+ #
+ # The result contains 74 random bits (9.25 random bytes).
+ #
+ # Note that this method cannot be made reproducible because its output
+ # includes not only random bits but also timestamp.
+ #
+ # See RFC9562[https://www.rfc-editor.org/rfc/rfc9562] for details of UUIDv7.
+ #
+ # ==== Monotonicity
+ #
+ # UUIDv7 has millisecond precision by default, so multiple UUIDs created
+ # within the same millisecond are not issued in monotonically increasing
+ # order. To create UUIDs that are time-ordered with sub-millisecond
+ # precision, up to 12 bits of additional timestamp may added with
+ # +extra_timestamp_bits+. The extra timestamp precision comes at the expense
+ # of random bits. Setting <tt>extra_timestamp_bits: 12</tt> provides ~244ns
+ # of precision, but only 62 random bits (7.75 random bytes).
+ #
+ # prng = Random.new
+ # Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 12) }
+ # # =>
+ # ["0188d4c7-13da-74f9-8b53-22a786ffdd5a",
+ # "0188d4c7-13da-753b-83a5-7fb9b2afaeea",
+ # "0188d4c7-13da-754a-88ea-ac0baeedd8db",
+ # "0188d4c7-13da-7557-83e1-7cad9cda0d8d"]
+ # # |<--- sorted --->| |<-- random --->|
+ #
+ # Array.new(4) { prng.uuid_v7(extra_timestamp_bits: 8) }
+ # # =>
+ # ["0188d4c7-3333-7a95-850a-de6edb858f7e",
+ # "0188d4c7-3333-7ae8-842e-bc3a8b7d0cf9", # <- out of order
+ # "0188d4c7-3333-7ae2-995a-9f135dc44ead", # <- out of order
+ # "0188d4c7-3333-7af9-87c3-8f612edac82e"]
+ # # |<--- sorted -->||<---- random --->|
+ #
+ # Any rollbacks of the system clock will break monotonicity. UUIDv7 is based
+ # on UTC, which excludes leap seconds and can rollback the clock. To avoid
+ # this, the system clock can synchronize with an NTP server configured to use
+ # a "leap smear" approach. NTP or PTP will also be needed to synchronize
+ # across distributed nodes.
+ #
+ # Counters and other mechanisms for stronger guarantees of monotonicity are
+ # not implemented. Applications with stricter requirements should follow
+ # {Section 6.2}[https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counters]
+ # of the specification.
+ #
+ def uuid_v7(extra_timestamp_bits: 0)
+ case (extra_timestamp_bits = Integer(extra_timestamp_bits))
+ when 0 # min timestamp precision
+ ms = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
+ rand = random_bytes(10)
+ rand.setbyte(0, rand.getbyte(0) & 0x0f | 0x70) # version
+ rand.setbyte(2, rand.getbyte(2) & 0x3f | 0x80) # variant
+ "%08x-%04x-%s" % [
+ (ms & 0x0000_ffff_ffff_0000) >> 16,
+ (ms & 0x0000_0000_0000_ffff),
+ rand.unpack("H4H4H12").join("-")
+ ]
+
+ when 12 # max timestamp precision
+ ms, ns = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
+ .divmod(1_000_000)
+ extra_bits = ns * 4096 / 1_000_000
+ rand = random_bytes(8)
+ rand.setbyte(0, rand.getbyte(0) & 0x3f | 0x80) # variant
+ "%08x-%04x-7%03x-%s" % [
+ (ms & 0x0000_ffff_ffff_0000) >> 16,
+ (ms & 0x0000_0000_0000_ffff),
+ extra_bits,
+ rand.unpack("H4H12").join("-")
+ ]
+
+ when (0..12) # the generic version is slower than the special cases above
+ rand_a, rand_b1, rand_b2, rand_b3 = random_bytes(10).unpack("nnnN")
+ rand_mask_bits = 12 - extra_timestamp_bits
+ ms, ns = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
+ .divmod(1_000_000)
+ "%08x-%04x-%04x-%04x-%04x%08x" % [
+ (ms & 0x0000_ffff_ffff_0000) >> 16,
+ (ms & 0x0000_0000_0000_ffff),
+ 0x7000 |
+ ((ns * (1 << extra_timestamp_bits) / 1_000_000) << rand_mask_bits) |
+ rand_a & ((1 << rand_mask_bits) - 1),
+ 0x8000 | (rand_b1 & 0x3fff),
+ rand_b2,
+ rand_b3
+ ]
+
+ else
+ raise ArgumentError, "extra_timestamp_bits must be in 0..12"
+ end
+ end
+
+ # Internal interface to Random; Generate random data _n_ bytes.
private def gen_random(n)
self.bytes(n)
end
@@ -221,16 +339,20 @@ module Random::Formatter
result
end
- ALPHANUMERIC = [*'A'..'Z', *'a'..'z', *'0'..'9']
+ # The default character list for #alphanumeric.
+ ALPHANUMERIC = [*'A'..'Z', *'a'..'z', *'0'..'9'].map(&:freeze).freeze
+
# Generate a random alphanumeric string.
#
# The argument _n_ specifies the length, in characters, of the alphanumeric
# string to be generated.
+ # The argument _chars_ specifies the character list which the result is
+ # consist of.
#
# If _n_ is not specified or is nil, 16 is assumed.
# It may be larger in the future.
#
- # The result may contain A-Z, a-z and 0-9.
+ # The result may contain A-Z, a-z and 0-9, unless _chars_ is specified.
#
# require 'random/formatter'
#
@@ -238,8 +360,13 @@ module Random::Formatter
# # or
# prng = Random.new
# prng.alphanumeric(10) #=> "i6K93NdqiH"
- def alphanumeric(n=nil)
+ #
+ # Random.alphanumeric(4, chars: [*"0".."9"]) #=> "2952"
+ # # or
+ # prng = Random.new
+ # prng.alphanumeric(10, chars: [*"!".."/"]) #=> ",.,++%/''."
+ def alphanumeric(n = nil, chars: ALPHANUMERIC)
n = 16 if n.nil?
- choose(ALPHANUMERIC, n)
+ choose(chars, n)
end
end
diff --git a/lib/rdoc.rb b/lib/rdoc.rb
deleted file mode 100644
index b62c22576d..0000000000
--- a/lib/rdoc.rb
+++ /dev/null
@@ -1,201 +0,0 @@
-# frozen_string_literal: true
-$DEBUG_RDOC = nil
-
-# :main: README.rdoc
-
-##
-# RDoc produces documentation for Ruby source files by parsing the source and
-# extracting the definition for classes, modules, methods, includes and
-# requires. It associates these with optional documentation contained in an
-# immediately preceding comment block then renders the result using an output
-# formatter.
-#
-# For a simple introduction to writing or generating documentation using RDoc
-# see the README.
-#
-# == Roadmap
-#
-# If you think you found a bug in RDoc see CONTRIBUTING@Bugs
-#
-# If you want to use RDoc to create documentation for your Ruby source files,
-# see RDoc::Markup and refer to <tt>rdoc --help</tt> for command line usage.
-#
-# If you want to set the default markup format see
-# RDoc::Markup@Supported+Formats
-#
-# If you want to store rdoc configuration in your gem (such as the default
-# markup format) see RDoc::Options@Saved+Options
-#
-# If you want to write documentation for Ruby files see RDoc::Parser::Ruby
-#
-# If you want to write documentation for extensions written in C see
-# RDoc::Parser::C
-#
-# If you want to generate documentation using <tt>rake</tt> see RDoc::Task.
-#
-# If you want to drive RDoc programmatically, see RDoc::RDoc.
-#
-# If you want to use the library to format text blocks into HTML or other
-# formats, look at RDoc::Markup.
-#
-# If you want to make an RDoc plugin such as a generator or directive handler
-# see RDoc::RDoc.
-#
-# If you want to write your own output generator see RDoc::Generator.
-#
-# If you want an overview of how RDoc works see CONTRIBUTING
-#
-# == Credits
-#
-# RDoc is currently being maintained by Eric Hodel <drbrain@segment7.net>.
-#
-# Dave Thomas <dave@pragmaticprogrammer.com> is the original author of RDoc.
-#
-# * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding
-# work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby
-# parser for irb and the rtags package.
-
-module RDoc
-
- ##
- # Exception thrown by any rdoc error.
-
- class Error < RuntimeError; end
-
- require_relative 'rdoc/version'
-
- ##
- # Method visibilities
-
- VISIBILITIES = [:public, :protected, :private]
-
- ##
- # Name of the dotfile that contains the description of files to be processed
- # in the current directory
-
- DOT_DOC_FILENAME = ".document"
-
- ##
- # General RDoc modifiers
-
- GENERAL_MODIFIERS = %w[nodoc].freeze
-
- ##
- # RDoc modifiers for classes
-
- CLASS_MODIFIERS = GENERAL_MODIFIERS
-
- ##
- # RDoc modifiers for attributes
-
- ATTR_MODIFIERS = GENERAL_MODIFIERS
-
- ##
- # RDoc modifiers for constants
-
- CONSTANT_MODIFIERS = GENERAL_MODIFIERS
-
- ##
- # RDoc modifiers for methods
-
- METHOD_MODIFIERS = GENERAL_MODIFIERS +
- %w[arg args yield yields notnew not-new not_new doc]
-
- ##
- # Loads the best available YAML library.
-
- def self.load_yaml
- begin
- gem 'psych'
- rescue NameError => e # --disable-gems
- raise unless e.name == :gem
- rescue Gem::LoadError
- end
-
- begin
- require 'psych'
- rescue ::LoadError
- ensure
- require 'yaml'
- end
- end
-
- def self.home
- rdoc_dir = begin
- File.expand_path('~/.rdoc')
- rescue ArgumentError
- end
-
- if File.directory?(rdoc_dir)
- rdoc_dir
- else
- begin
- # XDG
- xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
- unless File.exist?(xdg_data_home)
- FileUtils.mkdir_p xdg_data_home
- end
- File.join xdg_data_home, "rdoc"
- rescue Errno::EACCES
- end
- end
- end
-
- autoload :RDoc, "#{__dir__}/rdoc/rdoc"
-
- autoload :CrossReference, "#{__dir__}/rdoc/cross_reference"
- autoload :ERBIO, "#{__dir__}/rdoc/erbio"
- autoload :ERBPartial, "#{__dir__}/rdoc/erb_partial"
- autoload :Encoding, "#{__dir__}/rdoc/encoding"
- autoload :Generator, "#{__dir__}/rdoc/generator"
- autoload :Options, "#{__dir__}/rdoc/options"
- autoload :Parser, "#{__dir__}/rdoc/parser"
- autoload :Servlet, "#{__dir__}/rdoc/servlet"
- autoload :RI, "#{__dir__}/rdoc/ri"
- autoload :Stats, "#{__dir__}/rdoc/stats"
- autoload :Store, "#{__dir__}/rdoc/store"
- autoload :Task, "#{__dir__}/rdoc/task"
- autoload :Text, "#{__dir__}/rdoc/text"
-
- autoload :Markdown, "#{__dir__}/rdoc/markdown"
- autoload :Markup, "#{__dir__}/rdoc/markup"
- autoload :RD, "#{__dir__}/rdoc/rd"
- autoload :TomDoc, "#{__dir__}/rdoc/tom_doc"
-
- autoload :KNOWN_CLASSES, "#{__dir__}/rdoc/known_classes"
-
- autoload :TokenStream, "#{__dir__}/rdoc/token_stream"
-
- autoload :Comment, "#{__dir__}/rdoc/comment"
-
- require_relative 'rdoc/i18n'
-
- # code objects
- #
- # We represent the various high-level code constructs that appear in Ruby
- # programs: classes, modules, methods, and so on.
- autoload :CodeObject, "#{__dir__}/rdoc/code_object"
-
- autoload :Context, "#{__dir__}/rdoc/context"
- autoload :TopLevel, "#{__dir__}/rdoc/top_level"
-
- autoload :AnonClass, "#{__dir__}/rdoc/anon_class"
- autoload :ClassModule, "#{__dir__}/rdoc/class_module"
- autoload :NormalClass, "#{__dir__}/rdoc/normal_class"
- autoload :NormalModule, "#{__dir__}/rdoc/normal_module"
- autoload :SingleClass, "#{__dir__}/rdoc/single_class"
-
- autoload :Alias, "#{__dir__}/rdoc/alias"
- autoload :AnyMethod, "#{__dir__}/rdoc/any_method"
- autoload :MethodAttr, "#{__dir__}/rdoc/method_attr"
- autoload :GhostMethod, "#{__dir__}/rdoc/ghost_method"
- autoload :MetaMethod, "#{__dir__}/rdoc/meta_method"
- autoload :Attr, "#{__dir__}/rdoc/attr"
-
- autoload :Constant, "#{__dir__}/rdoc/constant"
- autoload :Mixin, "#{__dir__}/rdoc/mixin"
- autoload :Include, "#{__dir__}/rdoc/include"
- autoload :Extend, "#{__dir__}/rdoc/extend"
- autoload :Require, "#{__dir__}/rdoc/require"
-
-end
diff --git a/lib/rdoc/.document b/lib/rdoc/.document
deleted file mode 100644
index 6b5e1b21a5..0000000000
--- a/lib/rdoc/.document
+++ /dev/null
@@ -1,2 +0,0 @@
-*.rb
-parser
diff --git a/lib/rdoc/alias.rb b/lib/rdoc/alias.rb
deleted file mode 100644
index 858e053049..0000000000
--- a/lib/rdoc/alias.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: true
-##
-# Represent an alias, which is an old_name/new_name pair associated with a
-# particular context
-#--
-# TODO implement Alias as a proxy to a method/attribute, inheriting from
-# MethodAttr
-
-class RDoc::Alias < RDoc::CodeObject
-
- ##
- # Aliased method's name
-
- attr_reader :new_name
-
- alias name new_name
-
- ##
- # Aliasee method's name
-
- attr_reader :old_name
-
- ##
- # Is this an alias declared in a singleton context?
-
- attr_accessor :singleton
-
- ##
- # Source file token stream
-
- attr_reader :text
-
- ##
- # Creates a new Alias with a token stream of +text+ that aliases +old_name+
- # to +new_name+, has +comment+ and is a +singleton+ context.
-
- def initialize(text, old_name, new_name, comment, singleton = false)
- super()
-
- @text = text
- @singleton = singleton
- @old_name = old_name
- @new_name = new_name
- self.comment = comment
- end
-
- ##
- # Order by #singleton then #new_name
-
- def <=>(other)
- [@singleton ? 0 : 1, new_name] <=> [other.singleton ? 0 : 1, other.new_name]
- end
-
- ##
- # HTML fragment reference for this alias
-
- def aref
- type = singleton ? 'c' : 'i'
- "#alias-#{type}-#{html_name}"
- end
-
- ##
- # Full old name including namespace
-
- def full_old_name
- @full_name || "#{parent.name}#{pretty_old_name}"
- end
-
- ##
- # HTML id-friendly version of +#new_name+.
-
- def html_name
- CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
- end
-
- def inspect # :nodoc:
- parent_name = parent ? parent.name : '(unknown)'
- "#<%s:0x%x %s.alias_method %s, %s>" % [
- self.class, object_id,
- parent_name, @old_name, @new_name,
- ]
- end
-
- ##
- # '::' for the alias of a singleton method/attribute, '#' for instance-level.
-
- def name_prefix
- singleton ? '::' : '#'
- end
-
- ##
- # Old name with prefix '::' or '#'.
-
- def pretty_old_name
- "#{singleton ? '::' : '#'}#{@old_name}"
- end
-
- ##
- # New name with prefix '::' or '#'.
-
- def pretty_new_name
- "#{singleton ? '::' : '#'}#{@new_name}"
- end
-
- alias pretty_name pretty_new_name
-
- def to_s # :nodoc:
- "alias: #{self.new_name} -> #{self.pretty_old_name} in: #{parent}"
- end
-
-end
-
diff --git a/lib/rdoc/anon_class.rb b/lib/rdoc/anon_class.rb
deleted file mode 100644
index d02a38c2cf..0000000000
--- a/lib/rdoc/anon_class.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-##
-# An anonymous class like:
-#
-# c = Class.new do end
-#
-# AnonClass is currently not used.
-
-class RDoc::AnonClass < RDoc::ClassModule
-end
-
diff --git a/lib/rdoc/any_method.rb b/lib/rdoc/any_method.rb
deleted file mode 100644
index 051f946a10..0000000000
--- a/lib/rdoc/any_method.rb
+++ /dev/null
@@ -1,364 +0,0 @@
-# frozen_string_literal: true
-##
-# AnyMethod is the base class for objects representing methods
-
-class RDoc::AnyMethod < RDoc::MethodAttr
-
- ##
- # 2::
- # RDoc 4
- # Added calls_super
- # Added parent name and class
- # Added section title
- # 3::
- # RDoc 4.1
- # Added is_alias_for
-
- MARSHAL_VERSION = 3 # :nodoc:
-
- ##
- # Don't rename \#initialize to \::new
-
- attr_accessor :dont_rename_initialize
-
- ##
- # The C function that implements this method (if it was defined in a C file)
-
- attr_accessor :c_function
-
- # The section title of the method (if defined in a C file via +:category:+)
- attr_accessor :section_title
-
- # Parameters for this method
-
- attr_accessor :params
-
- ##
- # If true this method uses +super+ to call a superclass version
-
- attr_accessor :calls_super
-
- include RDoc::TokenStream
-
- ##
- # Creates a new AnyMethod with a token stream +text+ and +name+
-
- def initialize text, name
- super
-
- @c_function = nil
- @dont_rename_initialize = false
- @token_stream = nil
- @calls_super = false
- @superclass_method = nil
- end
-
- ##
- # Adds +an_alias+ as an alias for this method in +context+.
-
- def add_alias an_alias, context = nil
- method = self.class.new an_alias.text, an_alias.new_name
-
- method.record_location an_alias.file
- method.singleton = self.singleton
- method.params = self.params
- method.visibility = self.visibility
- method.comment = an_alias.comment
- method.is_alias_for = self
- @aliases << method
- context.add_method method if context
- method
- end
-
- ##
- # Prefix for +aref+ is 'method'.
-
- def aref_prefix
- 'method'
- end
-
- ##
- # The call_seq or the param_seq with method name, if there is no call_seq.
- #
- # Use this for displaying a method's argument lists.
-
- def arglists
- if @call_seq then
- @call_seq
- elsif @params then
- "#{name}#{param_seq}"
- end
- end
-
- ##
- # Different ways to call this method
-
- def call_seq
- unless call_seq = _call_seq
- call_seq = is_alias_for._call_seq if is_alias_for
- end
-
- return unless call_seq
-
- deduplicate_call_seq(call_seq)
- end
-
- ##
- # Sets the different ways you can call this method. If an empty +call_seq+
- # is given nil is assumed.
- #
- # See also #param_seq
-
- def call_seq= call_seq
- return if call_seq.empty?
-
- @call_seq = call_seq
- end
-
- ##
- # Loads is_alias_for from the internal name. Returns nil if the alias
- # cannot be found.
-
- def is_alias_for # :nodoc:
- case @is_alias_for
- when RDoc::MethodAttr then
- @is_alias_for
- when Array then
- return nil unless @store
-
- klass_name, singleton, method_name = @is_alias_for
-
- return nil unless klass = @store.find_class_or_module(klass_name)
-
- @is_alias_for = klass.find_method method_name, singleton
- end
- end
-
- ##
- # Dumps this AnyMethod for use by ri. See also #marshal_load
-
- def marshal_dump
- aliases = @aliases.map do |a|
- [a.name, parse(a.comment)]
- end
-
- is_alias_for = [
- @is_alias_for.parent.full_name,
- @is_alias_for.singleton,
- @is_alias_for.name
- ] if @is_alias_for
-
- [ MARSHAL_VERSION,
- @name,
- full_name,
- @singleton,
- @visibility,
- parse(@comment),
- @call_seq,
- @block_params,
- aliases,
- @params,
- @file.relative_name,
- @calls_super,
- @parent.name,
- @parent.class,
- @section.title,
- is_alias_for,
- ]
- end
-
- ##
- # Loads this AnyMethod from +array+. For a loaded AnyMethod the following
- # methods will return cached values:
- #
- # * #full_name
- # * #parent_name
-
- def marshal_load array
- initialize_visibility
-
- @dont_rename_initialize = nil
- @token_stream = nil
- @aliases = []
- @parent = nil
- @parent_name = nil
- @parent_class = nil
- @section = nil
- @file = nil
-
- version = array[0]
- @name = array[1]
- @full_name = array[2]
- @singleton = array[3]
- @visibility = array[4]
- @comment = array[5]
- @call_seq = array[6]
- @block_params = array[7]
- # 8 handled below
- @params = array[9]
- # 10 handled below
- @calls_super = array[11]
- @parent_name = array[12]
- @parent_title = array[13]
- @section_title = array[14]
- @is_alias_for = array[15]
-
- array[8].each do |new_name, comment|
- add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)
- end
-
- @parent_name ||= if @full_name =~ /#/ then
- $`
- else
- name = @full_name.split('::')
- name.pop
- name.join '::'
- end
-
- @file = RDoc::TopLevel.new array[10] if version > 0
- end
-
- ##
- # Method name
- #
- # If the method has no assigned name, it extracts it from #call_seq.
-
- def name
- return @name if @name
-
- @name =
- @call_seq[/^.*?\.(\w+)/, 1] ||
- @call_seq[/^.*?(\w+)/, 1] ||
- @call_seq if @call_seq
- end
-
- ##
- # A list of this method's method and yield parameters. +call-seq+ params
- # are preferred over parsed method and block params.
-
- def param_list
- if @call_seq then
- params = @call_seq.split("\n").last
- params = params.sub(/.*?\((.*)\)/, '\1')
- params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
- elsif @params then
- params = @params.sub(/\((.*)\)/, '\1')
-
- params << ",#{@block_params}" if @block_params
- elsif @block_params then
- params = @block_params
- else
- return []
- end
-
- if @block_params then
- # If this method has explicit block parameters, remove any explicit
- # &block
- params = params.sub(/,?\s*&\w+/, '')
- else
- params = params.sub(/\&(\w+)/, '\1')
- end
-
- params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
-
- params.map { |param| param.sub(/=.*/, '') }
- end
-
- ##
- # Pretty parameter list for this method. If the method's parameters were
- # given by +call-seq+ it is preferred over the parsed values.
-
- def param_seq
- if @call_seq then
- params = @call_seq.split("\n").last
- params = params.sub(/[^( ]+/, '')
- params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
- elsif @params then
- params = @params.gsub(/\s*\#.*/, '')
- params = params.tr_s("\n ", " ")
- params = "(#{params})" unless params[0] == ?(
- else
- params = ''
- end
-
- if @block_params then
- # If this method has explicit block parameters, remove any explicit
- # &block
- params = params.sub(/,?\s*&\w+/, '')
-
- block = @block_params.tr_s("\n ", " ")
- if block[0] == ?(
- block = block.sub(/^\(/, '').sub(/\)/, '')
- end
- params << " { |#{block}| ... }"
- end
-
- params
- end
-
- ##
- # Sets the store for this method and its referenced code objects.
-
- def store= store
- super
-
- @file = @store.add_file @file.full_name if @file
- end
-
- ##
- # For methods that +super+, find the superclass method that would be called.
-
- def superclass_method
- return unless @calls_super
- return @superclass_method if @superclass_method
-
- parent.each_ancestor do |ancestor|
- if method = ancestor.method_list.find { |m| m.name == @name } then
- @superclass_method = method
- break
- end
- end
-
- @superclass_method
- end
-
- protected
-
- ##
- # call_seq without deduplication and alias lookup.
-
- def _call_seq
- @call_seq if defined?(@call_seq) && @call_seq
- end
-
- private
-
- ##
- # call_seq with alias examples information removed, if this
- # method is an alias method.
-
- def deduplicate_call_seq(call_seq)
- return call_seq unless is_alias_for || !aliases.empty?
-
- method_name = self.name
- method_name = method_name[0, 1] if method_name =~ /\A\[/
-
- entries = call_seq.split "\n"
-
- ignore = aliases.map(&:name)
- if is_alias_for
- ignore << is_alias_for.name
- ignore.concat is_alias_for.aliases.map(&:name)
- end
- ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
- ignore.delete(method_name)
- ignore = Regexp.union(ignore)
-
- matching = entries.reject do |entry|
- entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
- entry =~ /\s#{ignore}\s/
- end
-
- matching.empty? ? nil : matching.join("\n")
- end
-end
diff --git a/lib/rdoc/attr.rb b/lib/rdoc/attr.rb
deleted file mode 100644
index f780b3b976..0000000000
--- a/lib/rdoc/attr.rb
+++ /dev/null
@@ -1,176 +0,0 @@
-# frozen_string_literal: true
-##
-# An attribute created by \#attr, \#attr_reader, \#attr_writer or
-# \#attr_accessor
-
-class RDoc::Attr < RDoc::MethodAttr
-
- ##
- # 3::
- # RDoc 4
- # Added parent name and class
- # Added section title
-
- MARSHAL_VERSION = 3 # :nodoc:
-
- ##
- # Is the attribute readable ('R'), writable ('W') or both ('RW')?
-
- attr_accessor :rw
-
- ##
- # Creates a new Attr with body +text+, +name+, read/write status +rw+ and
- # +comment+. +singleton+ marks this as a class attribute.
-
- def initialize(text, name, rw, comment, singleton = false)
- super text, name
-
- @rw = rw
- @singleton = singleton
- self.comment = comment
- end
-
- ##
- # Attributes are equal when their names, singleton and rw are identical
-
- def == other
- self.class == other.class and
- self.name == other.name and
- self.rw == other.rw and
- self.singleton == other.singleton
- end
-
- ##
- # Add +an_alias+ as an attribute in +context+.
-
- def add_alias(an_alias, context)
- new_attr = self.class.new(self.text, an_alias.new_name, self.rw,
- self.comment, self.singleton)
-
- new_attr.record_location an_alias.file
- new_attr.visibility = self.visibility
- new_attr.is_alias_for = self
- @aliases << new_attr
- context.add_attribute new_attr
- new_attr
- end
-
- ##
- # The #aref prefix for attributes
-
- def aref_prefix
- 'attribute'
- end
-
- ##
- # Attributes never call super. See RDoc::AnyMethod#calls_super
- #
- # An RDoc::Attr can show up in the method list in some situations (see
- # Gem::ConfigFile)
-
- def calls_super # :nodoc:
- false
- end
-
- ##
- # Returns attr_reader, attr_writer or attr_accessor as appropriate.
-
- def definition
- case @rw
- when 'RW' then 'attr_accessor'
- when 'R' then 'attr_reader'
- when 'W' then 'attr_writer'
- end
- end
-
- def inspect # :nodoc:
- alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
- visibility = self.visibility
- visibility = "forced #{visibility}" if force_documentation
- "#<%s:0x%x %s %s (%s)%s>" % [
- self.class, object_id,
- full_name,
- rw,
- visibility,
- alias_for,
- ]
- end
-
- ##
- # Dumps this Attr for use by ri. See also #marshal_load
-
- def marshal_dump
- [ MARSHAL_VERSION,
- @name,
- full_name,
- @rw,
- @visibility,
- parse(@comment),
- singleton,
- @file.relative_name,
- @parent.full_name,
- @parent.class,
- @section.title
- ]
- end
-
- ##
- # Loads this Attr from +array+. For a loaded Attr the following
- # methods will return cached values:
- #
- # * #full_name
- # * #parent_name
-
- def marshal_load array
- initialize_visibility
-
- @aliases = []
- @parent = nil
- @parent_name = nil
- @parent_class = nil
- @section = nil
- @file = nil
-
- version = array[0]
- @name = array[1]
- @full_name = array[2]
- @rw = array[3]
- @visibility = array[4]
- @comment = array[5]
- @singleton = array[6] || false # MARSHAL_VERSION == 0
- # 7 handled below
- @parent_name = array[8]
- @parent_class = array[9]
- @section_title = array[10]
-
- @file = RDoc::TopLevel.new array[7] if version > 1
-
- @parent_name ||= @full_name.split('#', 2).first
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[#{self.class.name} #{full_name} #{rw} #{visibility}", "]" do
- unless comment.empty? then
- q.breakable
- q.text "comment:"
- q.breakable
- q.pp @comment
- end
- end
- end
-
- def to_s # :nodoc:
- "#{definition} #{name} in: #{parent}"
- end
-
- ##
- # Attributes do not have token streams.
- #
- # An RDoc::Attr can show up in the method list in some situations (see
- # Gem::ConfigFile)
-
- def token_stream # :nodoc:
- end
-
-end
-
diff --git a/lib/rdoc/class_module.rb b/lib/rdoc/class_module.rb
deleted file mode 100644
index 7609080fbf..0000000000
--- a/lib/rdoc/class_module.rb
+++ /dev/null
@@ -1,802 +0,0 @@
-# frozen_string_literal: true
-##
-# ClassModule is the base class for objects representing either a class or a
-# module.
-
-class RDoc::ClassModule < RDoc::Context
-
- ##
- # 1::
- # RDoc 3.7
- # * Added visibility, singleton and file to attributes
- # * Added file to constants
- # * Added file to includes
- # * Added file to methods
- # 2::
- # RDoc 3.13
- # * Added extends
- # 3::
- # RDoc 4.0
- # * Added sections
- # * Added in_files
- # * Added parent name
- # * Complete Constant dump
-
- MARSHAL_VERSION = 3 # :nodoc:
-
- ##
- # Constants that are aliases for this class or module
-
- attr_accessor :constant_aliases
-
- ##
- # Comment and the location it came from. Use #add_comment to add comments
-
- attr_accessor :comment_location
-
- attr_accessor :diagram # :nodoc:
-
- ##
- # Class or module this constant is an alias for
-
- attr_accessor :is_alias_for
-
- ##
- # Return a RDoc::ClassModule of class +class_type+ that is a copy
- # of module +module+. Used to promote modules to classes.
- #--
- # TODO move to RDoc::NormalClass (I think)
-
- def self.from_module class_type, mod
- klass = class_type.new mod.name
-
- mod.comment_location.each do |comment, location|
- klass.add_comment comment, location
- end
-
- klass.parent = mod.parent
- klass.section = mod.section
- klass.viewer = mod.viewer
-
- klass.attributes.concat mod.attributes
- klass.method_list.concat mod.method_list
- klass.aliases.concat mod.aliases
- klass.external_aliases.concat mod.external_aliases
- klass.constants.concat mod.constants
- klass.includes.concat mod.includes
- klass.extends.concat mod.extends
-
- klass.methods_hash.update mod.methods_hash
- klass.constants_hash.update mod.constants_hash
-
- klass.current_section = mod.current_section
- klass.in_files.concat mod.in_files
- klass.sections.concat mod.sections
- klass.unmatched_alias_lists = mod.unmatched_alias_lists
- klass.current_section = mod.current_section
- klass.visibility = mod.visibility
-
- klass.classes_hash.update mod.classes_hash
- klass.modules_hash.update mod.modules_hash
- klass.metadata.update mod.metadata
-
- klass.document_self = mod.received_nodoc ? nil : mod.document_self
- klass.document_children = mod.document_children
- klass.force_documentation = mod.force_documentation
- klass.done_documenting = mod.done_documenting
-
- # update the parent of all children
-
- (klass.attributes +
- klass.method_list +
- klass.aliases +
- klass.external_aliases +
- klass.constants +
- klass.includes +
- klass.extends +
- klass.classes +
- klass.modules).each do |obj|
- obj.parent = klass
- obj.full_name = nil
- end
-
- klass
- end
-
- ##
- # Creates a new ClassModule with +name+ with optional +superclass+
- #
- # This is a constructor for subclasses, and must never be called directly.
-
- def initialize(name, superclass = nil)
- @constant_aliases = []
- @diagram = nil
- @is_alias_for = nil
- @name = name
- @superclass = superclass
- @comment_location = [] # [[comment, location]]
-
- super()
- end
-
- ##
- # Adds +comment+ to this ClassModule's list of comments at +location+. This
- # method is preferred over #comment= since it allows ri data to be updated
- # across multiple runs.
-
- def add_comment comment, location
- return unless document_self
-
- original = comment
-
- comment = case comment
- when RDoc::Comment then
- comment.normalize
- else
- normalize_comment comment
- end
-
- if location.parser == RDoc::Parser::C
- @comment_location.delete_if { |(_, l)| l == location }
- end
-
- @comment_location << [comment, location]
-
- self.comment = original
- end
-
- def add_things my_things, other_things # :nodoc:
- other_things.each do |group, things|
- my_things[group].each { |thing| yield false, thing } if
- my_things.include? group
-
- things.each do |thing|
- yield true, thing
- end
- end
- end
-
- ##
- # Ancestors list for this ClassModule: the list of included modules
- # (classes will add their superclass if any).
- #
- # Returns the included classes or modules, not the includes
- # themselves. The returned values are either String or
- # RDoc::NormalModule instances (see RDoc::Include#module).
- #
- # The values are returned in reverse order of their inclusion,
- # which is the order suitable for searching methods/attributes
- # in the ancestors. The superclass, if any, comes last.
-
- def ancestors
- includes.map { |i| i.module }.reverse
- end
-
- def aref_prefix # :nodoc:
- raise NotImplementedError, "missing aref_prefix for #{self.class}"
- end
-
- ##
- # HTML fragment reference for this module or class. See
- # RDoc::NormalClass#aref and RDoc::NormalModule#aref
-
- def aref
- "#{aref_prefix}-#{full_name}"
- end
-
- ##
- # Ancestors of this class or module only
-
- alias direct_ancestors ancestors
-
- ##
- # Clears the comment. Used by the Ruby parser.
-
- def clear_comment
- @comment = ''
- end
-
- ##
- # This method is deprecated, use #add_comment instead.
- #
- # Appends +comment+ to the current comment, but separated by a rule. Works
- # more like <tt>+=</tt>.
-
- def comment= comment # :nodoc:
- comment = case comment
- when RDoc::Comment then
- comment.normalize
- else
- normalize_comment comment
- end
-
- comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
-
- super comment
- end
-
- ##
- # Prepares this ClassModule for use by a generator.
- #
- # See RDoc::Store#complete
-
- def complete min_visibility
- update_aliases
- remove_nodoc_children
- update_includes
- remove_invisible min_visibility
- end
-
- ##
- # Does this ClassModule or any of its methods have document_self set?
-
- def document_self_or_methods
- document_self || method_list.any?{ |m| m.document_self }
- end
-
- ##
- # Does this class or module have a comment with content or is
- # #received_nodoc true?
-
- def documented?
- return true if @received_nodoc
- return false if @comment_location.empty?
- @comment_location.any? { |comment, _| not comment.empty? }
- end
-
- ##
- # Iterates the ancestors of this class or module for which an
- # RDoc::ClassModule exists.
-
- def each_ancestor # :yields: module
- return enum_for __method__ unless block_given?
-
- ancestors.each do |mod|
- next if String === mod
- next if self == mod
- yield mod
- end
- end
-
- ##
- # Looks for a symbol in the #ancestors. See Context#find_local_symbol.
-
- def find_ancestor_local_symbol symbol
- each_ancestor do |m|
- res = m.find_local_symbol(symbol)
- return res if res
- end
-
- nil
- end
-
- ##
- # Finds a class or module with +name+ in this namespace or its descendants
-
- def find_class_named name
- return self if full_name == name
- return self if @name == name
-
- @classes.values.find do |klass|
- next if klass == self
- klass.find_class_named name
- end
- end
-
- ##
- # Return the fully qualified name of this class or module
-
- def full_name
- @full_name ||= if RDoc::ClassModule === parent then
- "#{parent.full_name}::#{@name}"
- else
- @name
- end
- end
-
- ##
- # TODO: filter included items by #display?
-
- def marshal_dump # :nodoc:
- attrs = attributes.sort.map do |attr|
- next unless attr.display?
- [ attr.name, attr.rw,
- attr.visibility, attr.singleton, attr.file_name,
- ]
- end.compact
-
- method_types = methods_by_type.map do |type, visibilities|
- visibilities = visibilities.map do |visibility, methods|
- method_names = methods.map do |method|
- next unless method.display?
- [method.name, method.file_name]
- end.compact
-
- [visibility, method_names.uniq]
- end
-
- [type, visibilities]
- end
-
- [ MARSHAL_VERSION,
- @name,
- full_name,
- @superclass,
- parse(@comment_location),
- attrs,
- constants.select { |constant| constant.display? },
- includes.map do |incl|
- next unless incl.display?
- [incl.name, parse(incl.comment), incl.file_name]
- end.compact,
- method_types,
- extends.map do |ext|
- next unless ext.display?
- [ext.name, parse(ext.comment), ext.file_name]
- end.compact,
- @sections.values,
- @in_files.map do |tl|
- tl.relative_name
- end,
- parent.full_name,
- parent.class,
- ]
- end
-
- def marshal_load array # :nodoc:
- initialize_visibility
- initialize_methods_etc
- @current_section = nil
- @document_self = true
- @done_documenting = false
- @parent = nil
- @temporary_section = nil
- @visibility = nil
- @classes = {}
- @modules = {}
-
- @name = array[1]
- @full_name = array[2]
- @superclass = array[3]
- @comment = array[4]
-
- @comment_location = if RDoc::Markup::Document === @comment.parts.first then
- @comment
- else
- RDoc::Markup::Document.new @comment
- end
-
- array[5].each do |name, rw, visibility, singleton, file|
- singleton ||= false
- visibility ||= :public
-
- attr = RDoc::Attr.new nil, name, rw, nil, singleton
-
- add_attribute attr
- attr.visibility = visibility
- attr.record_location RDoc::TopLevel.new file
- end
-
- array[6].each do |constant, comment, file|
- case constant
- when RDoc::Constant then
- add_constant constant
- else
- constant = add_constant RDoc::Constant.new(constant, nil, comment)
- constant.record_location RDoc::TopLevel.new file
- end
- end
-
- array[7].each do |name, comment, file|
- incl = add_include RDoc::Include.new(name, comment)
- incl.record_location RDoc::TopLevel.new file
- end
-
- array[8].each do |type, visibilities|
- visibilities.each do |visibility, methods|
- @visibility = visibility
-
- methods.each do |name, file|
- method = RDoc::AnyMethod.new nil, name
- method.singleton = true if type == 'class'
- method.record_location RDoc::TopLevel.new file
- add_method method
- end
- end
- end
-
- array[9].each do |name, comment, file|
- ext = add_extend RDoc::Extend.new(name, comment)
- ext.record_location RDoc::TopLevel.new file
- end if array[9] # Support Marshal version 1
-
- sections = (array[10] || []).map do |section|
- [section.title, section]
- end
-
- @sections = Hash[*sections.flatten]
- @current_section = add_section nil
-
- @in_files = []
-
- (array[11] || []).each do |filename|
- record_location RDoc::TopLevel.new filename
- end
-
- @parent_name = array[12]
- @parent_class = array[13]
- end
-
- ##
- # Merges +class_module+ into this ClassModule.
- #
- # The data in +class_module+ is preferred over the receiver.
-
- def merge class_module
- @parent = class_module.parent
- @parent_name = class_module.parent_name
-
- other_document = parse class_module.comment_location
-
- if other_document then
- document = parse @comment_location
-
- document = document.merge other_document
-
- @comment = @comment_location = document
- end
-
- cm = class_module
- other_files = cm.in_files
-
- merge_collections attributes, cm.attributes, other_files do |add, attr|
- if add then
- add_attribute attr
- else
- @attributes.delete attr
- @methods_hash.delete attr.pretty_name
- end
- end
-
- merge_collections constants, cm.constants, other_files do |add, const|
- if add then
- add_constant const
- else
- @constants.delete const
- @constants_hash.delete const.name
- end
- end
-
- merge_collections includes, cm.includes, other_files do |add, incl|
- if add then
- add_include incl
- else
- @includes.delete incl
- end
- end
-
- @includes.uniq! # clean up
-
- merge_collections extends, cm.extends, other_files do |add, ext|
- if add then
- add_extend ext
- else
- @extends.delete ext
- end
- end
-
- @extends.uniq! # clean up
-
- merge_collections method_list, cm.method_list, other_files do |add, meth|
- if add then
- add_method meth
- else
- @method_list.delete meth
- @methods_hash.delete meth.pretty_name
- end
- end
-
- merge_sections cm
-
- self
- end
-
- ##
- # Merges collection +mine+ with +other+ preferring other. +other_files+ is
- # used to help determine which items should be deleted.
- #
- # Yields whether the item should be added or removed (true or false) and the
- # item to be added or removed.
- #
- # merge_collections things, other.things, other.in_files do |add, thing|
- # if add then
- # # add the thing
- # else
- # # remove the thing
- # end
- # end
-
- def merge_collections mine, other, other_files, &block # :nodoc:
- my_things = mine. group_by { |thing| thing.file }
- other_things = other.group_by { |thing| thing.file }
-
- remove_things my_things, other_files, &block
- add_things my_things, other_things, &block
- end
-
- ##
- # Merges the comments in this ClassModule with the comments in the other
- # ClassModule +cm+.
-
- def merge_sections cm # :nodoc:
- my_sections = sections.group_by { |section| section.title }
- other_sections = cm.sections.group_by { |section| section.title }
-
- other_files = cm.in_files
-
- remove_things my_sections, other_files do |_, section|
- @sections.delete section.title
- end
-
- other_sections.each do |group, sections|
- if my_sections.include? group
- my_sections[group].each do |my_section|
- other_section = cm.sections_hash[group]
-
- my_comments = my_section.comments
- other_comments = other_section.comments
-
- other_files = other_section.in_files
-
- merge_collections my_comments, other_comments, other_files do |add, comment|
- if add then
- my_section.add_comment comment
- else
- my_section.remove_comment comment
- end
- end
- end
- else
- sections.each do |section|
- add_section group, section.comments
- end
- end
- end
- end
-
- ##
- # Does this object represent a module?
-
- def module?
- false
- end
-
- ##
- # Allows overriding the initial name.
- #
- # Used for modules and classes that are constant aliases.
-
- def name= new_name
- @name = new_name
- end
-
- ##
- # Parses +comment_location+ into an RDoc::Markup::Document composed of
- # multiple RDoc::Markup::Documents with their file set.
-
- def parse comment_location
- case comment_location
- when String then
- super
- when Array then
- docs = comment_location.map do |comment, location|
- doc = super comment
- doc.file = location
- doc
- end
-
- RDoc::Markup::Document.new(*docs)
- when RDoc::Comment then
- doc = super comment_location.text, comment_location.format
- doc.file = comment_location.location
- doc
- when RDoc::Markup::Document then
- return comment_location
- else
- raise ArgumentError, "unknown comment class #{comment_location.class}"
- end
- end
-
- ##
- # Path to this class or module for use with HTML generator output.
-
- def path
- http_url @store.rdoc.generator.class_dir
- end
-
- ##
- # Name to use to generate the url:
- # modules and classes that are aliases for another
- # module or class return the name of the latter.
-
- def name_for_path
- is_alias_for ? is_alias_for.full_name : full_name
- end
-
- ##
- # Returns the classes and modules that are not constants
- # aliasing another class or module. For use by formatters
- # only (caches its result).
-
- def non_aliases
- @non_aliases ||= classes_and_modules.reject { |cm| cm.is_alias_for }
- end
-
- ##
- # Updates the child modules or classes of class/module +parent+ by
- # deleting the ones that have been removed from the documentation.
- #
- # +parent_hash+ is either <tt>parent.modules_hash</tt> or
- # <tt>parent.classes_hash</tt> and +all_hash+ is ::all_modules_hash or
- # ::all_classes_hash.
-
- def remove_nodoc_children
- prefix = self.full_name + '::'
-
- modules_hash.each_key do |name|
- full_name = prefix + name
- modules_hash.delete name unless @store.modules_hash[full_name]
- end
-
- classes_hash.each_key do |name|
- full_name = prefix + name
- classes_hash.delete name unless @store.classes_hash[full_name]
- end
- end
-
- def remove_things my_things, other_files # :nodoc:
- my_things.delete_if do |file, things|
- next false unless other_files.include? file
-
- things.each do |thing|
- yield false, thing
- end
-
- true
- end
- end
-
- ##
- # Search record used by RDoc::Generator::JsonIndex
-
- def search_record
- [
- name,
- full_name,
- full_name,
- '',
- path,
- '',
- snippet(@comment_location),
- ]
- end
-
- ##
- # Sets the store for this class or module and its contained code objects.
-
- def store= store
- super
-
- @attributes .each do |attr| attr.store = store end
- @constants .each do |const| const.store = store end
- @includes .each do |incl| incl.store = store end
- @extends .each do |ext| ext.store = store end
- @method_list.each do |meth| meth.store = store end
- end
-
- ##
- # Get the superclass of this class. Attempts to retrieve the superclass
- # object, returns the name if it is not known.
-
- def superclass
- @store.find_class_named(@superclass) || @superclass
- end
-
- ##
- # Set the superclass of this class to +superclass+
-
- def superclass=(superclass)
- raise NoMethodError, "#{full_name} is a module" if module?
- @superclass = superclass
- end
-
- def to_s # :nodoc:
- if is_alias_for then
- "#{self.class.name} #{self.full_name} -> #{is_alias_for}"
- else
- super
- end
- end
-
- ##
- # 'module' or 'class'
-
- def type
- module? ? 'module' : 'class'
- end
-
- ##
- # Updates the child modules & classes by replacing the ones that are
- # aliases through a constant.
- #
- # The aliased module/class is replaced in the children and in
- # RDoc::Store#modules_hash or RDoc::Store#classes_hash
- # by a copy that has <tt>RDoc::ClassModule#is_alias_for</tt> set to
- # the aliased module/class, and this copy is added to <tt>#aliases</tt>
- # of the aliased module/class.
- #
- # Formatters can use the #non_aliases method to retrieve children that
- # are not aliases, for instance to list the namespace content, since
- # the aliased modules are included in the constants of the class/module,
- # that are listed separately.
-
- def update_aliases
- constants.each do |const|
- next unless cm = const.is_alias_for
- cm_alias = cm.dup
- cm_alias.name = const.name
-
- # Don't move top-level aliases under Object, they look ugly there
- unless RDoc::TopLevel === cm_alias.parent then
- cm_alias.parent = self
- cm_alias.full_name = nil # force update for new parent
- end
-
- cm_alias.aliases.clear
- cm_alias.is_alias_for = cm
-
- if cm.module? then
- @store.modules_hash[cm_alias.full_name] = cm_alias
- modules_hash[const.name] = cm_alias
- else
- @store.classes_hash[cm_alias.full_name] = cm_alias
- classes_hash[const.name] = cm_alias
- end
-
- cm.aliases << cm_alias
- end
- end
-
- ##
- # Deletes from #includes those whose module has been removed from the
- # documentation.
- #--
- # FIXME: includes are not reliably removed, see _possible_bug test case
-
- def update_includes
- includes.reject! do |include|
- mod = include.module
- !(String === mod) && @store.modules_hash[mod.full_name].nil?
- end
-
- includes.uniq!
- end
-
- ##
- # Deletes from #extends those whose module has been removed from the
- # documentation.
- #--
- # FIXME: like update_includes, extends are not reliably removed
-
- def update_extends
- extends.reject! do |ext|
- mod = ext.module
-
- !(String === mod) && @store.modules_hash[mod.full_name].nil?
- end
-
- extends.uniq!
- end
-
-end
-
diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb
deleted file mode 100644
index aeb4b4762e..0000000000
--- a/lib/rdoc/code_object.rb
+++ /dev/null
@@ -1,421 +0,0 @@
-# frozen_string_literal: true
-##
-# Base class for the RDoc code tree.
-#
-# We contain the common stuff for contexts (which are containers) and other
-# elements (methods, attributes and so on)
-#
-# Here's the tree of the CodeObject subclasses:
-#
-# * RDoc::Context
-# * RDoc::TopLevel
-# * RDoc::ClassModule
-# * RDoc::AnonClass (never used so far)
-# * RDoc::NormalClass
-# * RDoc::NormalModule
-# * RDoc::SingleClass
-# * RDoc::MethodAttr
-# * RDoc::Attr
-# * RDoc::AnyMethod
-# * RDoc::GhostMethod
-# * RDoc::MetaMethod
-# * RDoc::Alias
-# * RDoc::Constant
-# * RDoc::Mixin
-# * RDoc::Require
-# * RDoc::Include
-
-class RDoc::CodeObject
-
- include RDoc::Text
-
- ##
- # Our comment
-
- attr_reader :comment
-
- ##
- # Do we document our children?
-
- attr_reader :document_children
-
- ##
- # Do we document ourselves?
-
- attr_reader :document_self
-
- ##
- # Are we done documenting (ie, did we come across a :enddoc:)?
-
- attr_reader :done_documenting
-
- ##
- # Which file this code object was defined in
-
- attr_reader :file
-
- ##
- # Force documentation of this CodeObject
-
- attr_reader :force_documentation
-
- ##
- # Line in #file where this CodeObject was defined
-
- attr_accessor :line
-
- ##
- # Hash of arbitrary metadata for this CodeObject
-
- attr_reader :metadata
-
- ##
- # Sets the parent CodeObject
-
- attr_writer :parent
-
- ##
- # Did we ever receive a +:nodoc:+ directive?
-
- attr_reader :received_nodoc
-
- ##
- # Set the section this CodeObject is in
-
- attr_writer :section
-
- ##
- # The RDoc::Store for this object.
-
- attr_reader :store
-
- ##
- # We are the model of the code, but we know that at some point we will be
- # worked on by viewers. By implementing the Viewable protocol, viewers can
- # associated themselves with these objects.
-
- attr_accessor :viewer
-
- ##
- # Creates a new CodeObject that will document itself and its children
-
- def initialize
- @metadata = {}
- @comment = ''
- @parent = nil
- @parent_name = nil # for loading
- @parent_class = nil # for loading
- @section = nil
- @section_title = nil # for loading
- @file = nil
- @full_name = nil
- @store = nil
- @track_visibility = true
-
- initialize_visibility
- end
-
- ##
- # Initializes state for visibility of this CodeObject and its children.
-
- def initialize_visibility # :nodoc:
- @document_children = true
- @document_self = true
- @done_documenting = false
- @force_documentation = false
- @received_nodoc = false
- @ignored = false
- @suppressed = false
- @track_visibility = true
- end
-
- ##
- # Replaces our comment with +comment+, unless it is empty.
-
- def comment=(comment)
- @comment = case comment
- when NilClass then ''
- when RDoc::Markup::Document then comment
- when RDoc::Comment then comment.normalize
- else
- if comment and not comment.empty? then
- normalize_comment comment
- else
- # HACK correct fix is to have #initialize create @comment
- # with the correct encoding
- if String === @comment and @comment.empty? then
- @comment = RDoc::Encoding.change_encoding @comment, comment.encoding
- end
- @comment
- end
- end
- end
-
- ##
- # Should this CodeObject be displayed in output?
- #
- # A code object should be displayed if:
- #
- # * The item didn't have a nodoc or wasn't in a container that had nodoc
- # * The item wasn't ignored
- # * The item has documentation and was not suppressed
-
- def display?
- @document_self and not @ignored and
- (documented? or not @suppressed)
- end
-
- ##
- # Enables or disables documentation of this CodeObject's children unless it
- # has been turned off by :enddoc:
-
- def document_children=(document_children)
- return unless @track_visibility
-
- @document_children = document_children unless @done_documenting
- end
-
- ##
- # Enables or disables documentation of this CodeObject unless it has been
- # turned off by :enddoc:. If the argument is +nil+ it means the
- # documentation is turned off by +:nodoc:+.
-
- def document_self=(document_self)
- return unless @track_visibility
- return if @done_documenting
-
- @document_self = document_self
- @received_nodoc = true if document_self.nil?
- end
-
- ##
- # Does this object have a comment with content or is #received_nodoc true?
-
- def documented?
- @received_nodoc or !@comment.empty?
- end
-
- ##
- # Turns documentation on/off, and turns on/off #document_self
- # and #document_children.
- #
- # Once documentation has been turned off (by +:enddoc:+),
- # the object will refuse to turn #document_self or
- # #document_children on, so +:doc:+ and +:start_doc:+ directives
- # will have no effect in the current file.
-
- def done_documenting=(value)
- return unless @track_visibility
- @done_documenting = value
- @document_self = !value
- @document_children = @document_self
- end
-
- ##
- # Yields each parent of this CodeObject. See also
- # RDoc::ClassModule#each_ancestor
-
- def each_parent
- code_object = self
-
- while code_object = code_object.parent do
- yield code_object
- end
-
- self
- end
-
- ##
- # File name where this CodeObject was found.
- #
- # See also RDoc::Context#in_files
-
- def file_name
- return unless @file
-
- @file.absolute_name
- end
-
- ##
- # Force the documentation of this object unless documentation
- # has been turned off by :enddoc:
- #--
- # HACK untested, was assigning to an ivar
-
- def force_documentation=(value)
- @force_documentation = value unless @done_documenting
- end
-
- ##
- # Sets the full_name overriding any computed full name.
- #
- # Set to +nil+ to clear RDoc's cached value
-
- def full_name= full_name
- @full_name = full_name
- end
-
- ##
- # Use this to ignore a CodeObject and all its children until found again
- # (#record_location is called). An ignored item will not be displayed in
- # documentation.
- #
- # See github issue #55
- #
- # The ignored status is temporary in order to allow implementation details
- # to be hidden. At the end of processing a file RDoc allows all classes
- # and modules to add new documentation to previously created classes.
- #
- # If a class was ignored (via stopdoc) then reopened later with additional
- # documentation it should be displayed. If a class was ignored and never
- # reopened it should not be displayed. The ignore flag allows this to
- # occur.
-
- def ignore
- return unless @track_visibility
-
- @ignored = true
-
- stop_doc
- end
-
- ##
- # Has this class been ignored?
- #
- # See also #ignore
-
- def ignored?
- @ignored
- end
-
- ##
- # The options instance from the store this CodeObject is attached to, or a
- # default options instance if the CodeObject is not attached.
- #
- # This is used by Text#snippet
-
- def options
- if @store and @store.rdoc then
- @store.rdoc.options
- else
- RDoc::Options.new
- end
- end
-
- ##
- # Our parent CodeObject. The parent may be missing for classes loaded from
- # legacy RI data stores.
-
- def parent
- return @parent if @parent
- return nil unless @parent_name
-
- if @parent_class == RDoc::TopLevel then
- @parent = @store.add_file @parent_name
- else
- @parent = @store.find_class_or_module @parent_name
-
- return @parent if @parent
-
- begin
- @parent = @store.load_class @parent_name
- rescue RDoc::Store::MissingFileError
- nil
- end
- end
- end
-
- ##
- # File name of our parent
-
- def parent_file_name
- @parent ? @parent.base_name : '(unknown)'
- end
-
- ##
- # Name of our parent
-
- def parent_name
- @parent ? @parent.full_name : '(unknown)'
- end
-
- ##
- # Records the RDoc::TopLevel (file) where this code object was defined
-
- def record_location top_level
- @ignored = false
- @suppressed = false
- @file = top_level
- end
-
- ##
- # The section this CodeObject is in. Sections allow grouping of constants,
- # attributes and methods inside a class or module.
-
- def section
- return @section if @section
-
- @section = parent.add_section @section_title if parent
- end
-
- ##
- # Enable capture of documentation unless documentation has been
- # turned off by :enddoc:
-
- def start_doc
- return if @done_documenting
-
- @document_self = true
- @document_children = true
- @ignored = false
- @suppressed = false
- end
-
- ##
- # Disable capture of documentation
-
- def stop_doc
- return unless @track_visibility
-
- @document_self = false
- @document_children = false
- end
-
- ##
- # Sets the +store+ that contains this CodeObject
-
- def store= store
- @store = store
-
- return unless @track_visibility
-
- if :nodoc == options.visibility then
- initialize_visibility
- @track_visibility = false
- end
- end
-
- ##
- # Use this to suppress a CodeObject and all its children until the next file
- # it is seen in or documentation is discovered. A suppressed item with
- # documentation will be displayed while an ignored item with documentation
- # may not be displayed.
-
- def suppress
- return unless @track_visibility
-
- @suppressed = true
-
- stop_doc
- end
-
- ##
- # Has this class been suppressed?
- #
- # See also #suppress
-
- def suppressed?
- @suppressed
- end
-
-end
diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb
deleted file mode 100644
index d5f2f920ad..0000000000
--- a/lib/rdoc/code_objects.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-# This file was used to load all the RDoc::CodeObject subclasses at once. Now
-# autoload handles this.
-
-require_relative '../rdoc'
diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb
deleted file mode 100644
index 9e90999eac..0000000000
--- a/lib/rdoc/comment.rb
+++ /dev/null
@@ -1,250 +0,0 @@
-# frozen_string_literal: true
-##
-# A comment holds the text comment for a RDoc::CodeObject and provides a
-# unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
-#
-# Each comment may have a different markup format set by #format=. By default
-# 'rdoc' is used. The :markup: directive tells RDoc which format to use.
-#
-# See RDoc::Markup@Other+directives for instructions on adding an alternate
-# format.
-
-class RDoc::Comment
-
- include RDoc::Text
-
- ##
- # The format of this comment. Defaults to RDoc::Markup
-
- attr_reader :format
-
- ##
- # The RDoc::TopLevel this comment was found in
-
- attr_accessor :location
-
- ##
- # Line where this Comment was written
-
- attr_accessor :line
-
- ##
- # For duck-typing when merging classes at load time
-
- alias file location # :nodoc:
-
- ##
- # The text for this comment
-
- attr_reader :text
-
- ##
- # Alias for text
-
- alias to_s text
-
- ##
- # Overrides the content returned by #parse. Use when there is no #text
- # source for this comment
-
- attr_writer :document
-
- ##
- # Creates a new comment with +text+ that is found in the RDoc::TopLevel
- # +location+.
-
- def initialize text = nil, location = nil, language = nil
- @location = location
- @text = text.nil? ? nil : text.dup
- @language = language
-
- @document = nil
- @format = 'rdoc'
- @normalized = false
- end
-
- ##
- #--
- # TODO deep copy @document
-
- def initialize_copy copy # :nodoc:
- @text = copy.text.dup
- end
-
- def == other # :nodoc:
- self.class === other and
- other.text == @text and other.location == @location
- end
-
- ##
- # Look for a 'call-seq' in the comment to override the normal parameter
- # handling. The :call-seq: is indented from the baseline. All lines of the
- # same indentation level and prefix are consumed.
- #
- # For example, all of the following will be used as the :call-seq:
- #
- # # :call-seq:
- # # ARGF.readlines(sep=$/) -> array
- # # ARGF.readlines(limit) -> array
- # # ARGF.readlines(sep, limit) -> array
- # #
- # # ARGF.to_a(sep=$/) -> array
- # # ARGF.to_a(limit) -> array
- # # ARGF.to_a(sep, limit) -> array
-
- def extract_call_seq method
- # we must handle situations like the above followed by an unindented first
- # comment. The difficulty is to make sure not to match lines starting
- # with ARGF at the same indent, but that are after the first description
- # paragraph.
- if @text =~ /^\s*:?call-seq:(.*?(?:\S).*?)^\s*$/m then
- all_start, all_stop = $~.offset(0)
- seq_start, seq_stop = $~.offset(1)
-
- # we get the following lines that start with the leading word at the
- # same indent, even if they have blank lines before
- if $1 =~ /(^\s*\n)+^(\s*\w+)/m then
- leading = $2 # ' * ARGF' in the example above
- re = %r%
- \A(
- (^\s*\n)+
- (^#{Regexp.escape leading}.*?\n)+
- )+
- ^\s*$
- %xm
-
- if @text[seq_stop..-1] =~ re then
- all_stop = seq_stop + $~.offset(0).last
- seq_stop = seq_stop + $~.offset(1).last
- end
- end
-
- seq = @text[seq_start..seq_stop]
- seq.gsub!(/^\s*(\S|\n)/m, '\1')
- @text.slice! all_start...all_stop
-
- method.call_seq = seq.chomp
-
- else
- regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
- if regexp =~ @text then
- @text = @text.sub(regexp, '')
- seq = $1
- seq.gsub!(/^\s*/, '')
- method.call_seq = seq
- end
- end
-
- method
- end
-
- ##
- # A comment is empty if its text String is empty.
-
- def empty?
- @text.empty?
- end
-
- ##
- # HACK dubious
-
- def encode! encoding
- # TODO: Remove this condition after Ruby 2.2 EOL
- if RUBY_VERSION < '2.3.0'
- @text = @text.force_encoding encoding
- else
- @text = String.new @text, encoding: encoding
- end
- self
- end
-
- ##
- # Sets the format of this comment and resets any parsed document
-
- def format= format
- @format = format
- @document = nil
- end
-
- def inspect # :nodoc:
- location = @location ? @location.relative_name : '(unknown)'
-
- "#<%s:%x %s %p>" % [self.class, object_id, location, @text]
- end
-
- ##
- # Normalizes the text. See RDoc::Text#normalize_comment for details
-
- def normalize
- return self unless @text
- return self if @normalized # TODO eliminate duplicate normalization
-
- @text = normalize_comment @text
-
- @normalized = true
-
- self
- end
-
- ##
- # Was this text normalized?
-
- def normalized? # :nodoc:
- @normalized
- end
-
- ##
- # Parses the comment into an RDoc::Markup::Document. The parsed document is
- # cached until the text is changed.
-
- def parse
- return @document if @document
-
- @document = super @text, @format
- @document.file = @location
- @document
- end
-
- ##
- # Removes private sections from this comment. Private sections are flush to
- # the comment marker and start with <tt>--</tt> and end with <tt>++</tt>.
- # For C-style comments, a private marker may not start at the opening of the
- # comment.
- #
- # /*
- # *--
- # * private
- # *++
- # * public
- # */
-
- def remove_private
- # Workaround for gsub encoding for Ruby 1.9.2 and earlier
- empty = ''
- empty = RDoc::Encoding.change_encoding empty, @text.encoding
-
- @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
- @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
- end
-
- ##
- # Replaces this comment's text with +text+ and resets the parsed document.
- #
- # An error is raised if the comment contains a document but no text.
-
- def text= text
- raise RDoc::Error, 'replacing document-only comment is not allowed' if
- @text.nil? and @document
-
- @document = nil
- @text = text.nil? ? nil : text.dup
- end
-
- ##
- # Returns true if this comment is in TomDoc format.
-
- def tomdoc?
- @format == 'tomdoc'
- end
-
-end
diff --git a/lib/rdoc/constant.rb b/lib/rdoc/constant.rb
deleted file mode 100644
index 0c3d7505a1..0000000000
--- a/lib/rdoc/constant.rb
+++ /dev/null
@@ -1,187 +0,0 @@
-# frozen_string_literal: true
-##
-# A constant
-
-class RDoc::Constant < RDoc::CodeObject
-
- MARSHAL_VERSION = 0 # :nodoc:
-
- ##
- # Sets the module or class this is constant is an alias for.
-
- attr_writer :is_alias_for
-
- ##
- # The constant's name
-
- attr_accessor :name
-
- ##
- # The constant's value
-
- attr_accessor :value
-
- ##
- # The constant's visibility
-
- attr_accessor :visibility
-
- ##
- # Creates a new constant with +name+, +value+ and +comment+
-
- def initialize(name, value, comment)
- super()
-
- @name = name
- @value = value
-
- @is_alias_for = nil
- @visibility = :public
-
- self.comment = comment
- end
-
- ##
- # Constants are ordered by name
-
- def <=> other
- return unless self.class === other
-
- [parent_name, name] <=> [other.parent_name, other.name]
- end
-
- ##
- # Constants are equal when their #parent and #name is the same
-
- def == other
- self.class == other.class and
- @parent == other.parent and
- @name == other.name
- end
-
- ##
- # A constant is documented if it has a comment, or is an alias
- # for a documented class or module.
-
- def documented?
- return true if super
- return false unless @is_alias_for
- case @is_alias_for
- when String then
- found = @store.find_class_or_module @is_alias_for
- return false unless found
- @is_alias_for = found
- end
- @is_alias_for.documented?
- end
-
- ##
- # Full constant name including namespace
-
- def full_name
- @full_name ||= "#{parent_name}::#{@name}"
- end
-
- ##
- # The module or class this constant is an alias for
-
- def is_alias_for
- case @is_alias_for
- when String then
- found = @store.find_class_or_module @is_alias_for
- @is_alias_for = found if found
- @is_alias_for
- else
- @is_alias_for
- end
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %s::%s>" % [
- self.class, object_id,
- parent_name, @name,
- ]
- end
-
- ##
- # Dumps this Constant for use by ri. See also #marshal_load
-
- def marshal_dump
- alias_name = case found = is_alias_for
- when RDoc::CodeObject then found.full_name
- else found
- end
-
- [ MARSHAL_VERSION,
- @name,
- full_name,
- @visibility,
- alias_name,
- parse(@comment),
- @file.relative_name,
- parent.name,
- parent.class,
- section.title,
- ]
- end
-
- ##
- # Loads this Constant from +array+. For a loaded Constant the following
- # methods will return cached values:
- #
- # * #full_name
- # * #parent_name
-
- def marshal_load array
- initialize array[1], nil, array[5]
-
- @full_name = array[2]
- @visibility = array[3] || :public
- @is_alias_for = array[4]
- # 5 handled above
- # 6 handled below
- @parent_name = array[7]
- @parent_class = array[8]
- @section_title = array[9]
-
- @file = RDoc::TopLevel.new array[6]
- end
-
- ##
- # Path to this constant for use with HTML generator output.
-
- def path
- "#{@parent.path}##{@name}"
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[#{self.class.name} #{full_name}", "]" do
- unless comment.empty? then
- q.breakable
- q.text "comment:"
- q.breakable
- q.pp @comment
- end
- end
- end
-
- ##
- # Sets the store for this class or module and its contained code objects.
-
- def store= store
- super
-
- @file = @store.add_file @file.full_name if @file
- end
-
- def to_s # :nodoc:
- parent_name = parent ? parent.full_name : '(unknown)'
- if is_alias_for
- "constant #{parent_name}::#@name -> #{is_alias_for}"
- else
- "constant #{parent_name}::#@name"
- end
- end
-
-end
-
diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb
deleted file mode 100644
index c6edfb473c..0000000000
--- a/lib/rdoc/context.rb
+++ /dev/null
@@ -1,1264 +0,0 @@
-# frozen_string_literal: true
-##
-# A Context is something that can hold modules, classes, methods, attributes,
-# aliases, requires, and includes. Classes, modules, and files are all
-# Contexts.
-
-class RDoc::Context < RDoc::CodeObject
-
- include Comparable
-
- ##
- # Types of methods
-
- TYPES = %w[class instance]
-
- ##
- # If a context has these titles it will be sorted in this order.
-
- TOMDOC_TITLES = [nil, 'Public', 'Internal', 'Deprecated'] # :nodoc:
- TOMDOC_TITLES_SORT = TOMDOC_TITLES.sort_by { |title| title.to_s } # :nodoc:
-
- ##
- # Class/module aliases
-
- attr_reader :aliases
-
- ##
- # All attr* methods
-
- attr_reader :attributes
-
- ##
- # Block params to be used in the next MethodAttr parsed under this context
-
- attr_accessor :block_params
-
- ##
- # Constants defined
-
- attr_reader :constants
-
- ##
- # Sets the current documentation section of documentation
-
- attr_writer :current_section
-
- ##
- # Files this context is found in
-
- attr_reader :in_files
-
- ##
- # Modules this context includes
-
- attr_reader :includes
-
- ##
- # Modules this context is extended with
-
- attr_reader :extends
-
- ##
- # Methods defined in this context
-
- attr_reader :method_list
-
- ##
- # Name of this class excluding namespace. See also full_name
-
- attr_reader :name
-
- ##
- # Files this context requires
-
- attr_reader :requires
-
- ##
- # Use this section for the next method, attribute or constant added.
-
- attr_accessor :temporary_section
-
- ##
- # Hash <tt>old_name => [aliases]</tt>, for aliases
- # that haven't (yet) been resolved to a method/attribute.
- # (Not to be confused with the aliases of the context.)
-
- attr_accessor :unmatched_alias_lists
-
- ##
- # Aliases that could not be resolved.
-
- attr_reader :external_aliases
-
- ##
- # Current visibility of this context
-
- attr_accessor :visibility
-
- ##
- # Current visibility of this line
-
- attr_writer :current_line_visibility
-
- ##
- # Hash of registered methods. Attributes are also registered here,
- # twice if they are RW.
-
- attr_reader :methods_hash
-
- ##
- # Params to be used in the next MethodAttr parsed under this context
-
- attr_accessor :params
-
- ##
- # Hash of registered constants.
-
- attr_reader :constants_hash
-
- ##
- # Creates an unnamed empty context with public current visibility
-
- def initialize
- super
-
- @in_files = []
-
- @name ||= "unknown"
- @parent = nil
- @visibility = :public
-
- @current_section = Section.new self, nil, nil
- @sections = { nil => @current_section }
- @temporary_section = nil
-
- @classes = {}
- @modules = {}
-
- initialize_methods_etc
- end
-
- ##
- # Sets the defaults for methods and so-forth
-
- def initialize_methods_etc
- @method_list = []
- @attributes = []
- @aliases = []
- @requires = []
- @includes = []
- @extends = []
- @constants = []
- @external_aliases = []
- @current_line_visibility = nil
-
- # This Hash maps a method name to a list of unmatched aliases (aliases of
- # a method not yet encountered).
- @unmatched_alias_lists = {}
-
- @methods_hash = {}
- @constants_hash = {}
-
- @params = nil
-
- @store ||= nil
- end
-
- ##
- # Contexts are sorted by full_name
-
- def <=>(other)
- return nil unless RDoc::CodeObject === other
-
- full_name <=> other.full_name
- end
-
- ##
- # Adds an item of type +klass+ with the given +name+ and +comment+ to the
- # context.
- #
- # Currently only RDoc::Extend and RDoc::Include are supported.
-
- def add klass, name, comment
- if RDoc::Extend == klass then
- ext = RDoc::Extend.new name, comment
- add_extend ext
- elsif RDoc::Include == klass then
- incl = RDoc::Include.new name, comment
- add_include incl
- else
- raise NotImplementedError, "adding a #{klass} is not implemented"
- end
- end
-
- ##
- # Adds +an_alias+ that is automatically resolved
-
- def add_alias an_alias
- return an_alias unless @document_self
-
- method_attr = find_method(an_alias.old_name, an_alias.singleton) ||
- find_attribute(an_alias.old_name, an_alias.singleton)
-
- if method_attr then
- method_attr.add_alias an_alias, self
- else
- add_to @external_aliases, an_alias
- unmatched_alias_list =
- @unmatched_alias_lists[an_alias.pretty_old_name] ||= []
- unmatched_alias_list.push an_alias
- end
-
- an_alias
- end
-
- ##
- # Adds +attribute+ if not already there. If it is (as method(s) or attribute),
- # updates the comment if it was empty.
- #
- # The attribute is registered only if it defines a new method.
- # For instance, <tt>attr_reader :foo</tt> will not be registered
- # if method +foo+ exists, but <tt>attr_accessor :foo</tt> will be registered
- # if method +foo+ exists, but <tt>foo=</tt> does not.
-
- def add_attribute attribute
- return attribute unless @document_self
-
- # mainly to check for redefinition of an attribute as a method
- # TODO find a policy for 'attr_reader :foo' + 'def foo=()'
- register = false
-
- key = nil
-
- if attribute.rw.index 'R' then
- key = attribute.pretty_name
- known = @methods_hash[key]
-
- if known then
- known.comment = attribute.comment if known.comment.empty?
- elsif registered = @methods_hash[attribute.pretty_name + '='] and
- RDoc::Attr === registered then
- registered.rw = 'RW'
- else
- @methods_hash[key] = attribute
- register = true
- end
- end
-
- if attribute.rw.index 'W' then
- key = attribute.pretty_name + '='
- known = @methods_hash[key]
-
- if known then
- known.comment = attribute.comment if known.comment.empty?
- elsif registered = @methods_hash[attribute.pretty_name] and
- RDoc::Attr === registered then
- registered.rw = 'RW'
- else
- @methods_hash[key] = attribute
- register = true
- end
- end
-
- if register then
- attribute.visibility = @visibility
- add_to @attributes, attribute
- resolve_aliases attribute
- end
-
- attribute
- end
-
- ##
- # Adds a class named +given_name+ with +superclass+.
- #
- # Both +given_name+ and +superclass+ may contain '::', and are
- # interpreted relative to the +self+ context. This allows handling correctly
- # examples like these:
- # class RDoc::Gauntlet < Gauntlet
- # module Mod
- # class Object # implies < ::Object
- # class SubObject < Object # this is _not_ ::Object
- #
- # Given <tt>class Container::Item</tt> RDoc assumes +Container+ is a module
- # unless it later sees <tt>class Container</tt>. +add_class+ automatically
- # upgrades +given_name+ to a class in this case.
-
- def add_class class_type, given_name, superclass = '::Object'
- # superclass +nil+ is passed by the C parser in the following cases:
- # - registering Object in 1.8 (correct)
- # - registering BasicObject in 1.9 (correct)
- # - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c)
- #
- # If we later find a superclass for a registered class with a nil
- # superclass, we must honor it.
-
- # find the name & enclosing context
- if given_name =~ /^:+(\w+)$/ then
- full_name = $1
- enclosing = top_level
- name = full_name.split(/:+/).last
- else
- full_name = child_name given_name
-
- if full_name =~ /^(.+)::(\w+)$/ then
- name = $2
- ename = $1
- enclosing = @store.classes_hash[ename] || @store.modules_hash[ename]
- # HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming)
- unless enclosing then
- # try the given name at top level (will work for the above example)
- enclosing = @store.classes_hash[given_name] ||
- @store.modules_hash[given_name]
- return enclosing if enclosing
- # not found: create the parent(s)
- names = ename.split('::')
- enclosing = self
- names.each do |n|
- enclosing = enclosing.classes_hash[n] ||
- enclosing.modules_hash[n] ||
- enclosing.add_module(RDoc::NormalModule, n)
- end
- end
- else
- name = full_name
- enclosing = self
- end
- end
-
- # fix up superclass
- if full_name == 'BasicObject' then
- superclass = nil
- elsif full_name == 'Object' then
- superclass = '::BasicObject'
- end
-
- # find the superclass full name
- if superclass then
- if superclass =~ /^:+/ then
- superclass = $' #'
- else
- if superclass =~ /^(\w+):+(.+)$/ then
- suffix = $2
- mod = find_module_named($1)
- superclass = mod.full_name + '::' + suffix if mod
- else
- mod = find_module_named(superclass)
- superclass = mod.full_name if mod
- end
- end
-
- # did we believe it was a module?
- mod = @store.modules_hash.delete superclass
-
- upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod
-
- # e.g., Object < Object
- superclass = nil if superclass == full_name
- end
-
- klass = @store.classes_hash[full_name]
-
- if klass then
- # if TopLevel, it may not be registered in the classes:
- enclosing.classes_hash[name] = klass
-
- # update the superclass if needed
- if superclass then
- existing = klass.superclass
- existing = existing.full_name unless existing.is_a?(String) if existing
- if existing.nil? ||
- (existing == 'Object' && superclass != 'Object') then
- klass.superclass = superclass
- end
- end
- else
- # this is a new class
- mod = @store.modules_hash.delete full_name
-
- if mod then
- klass = upgrade_to_class mod, RDoc::NormalClass, enclosing
-
- klass.superclass = superclass unless superclass.nil?
- else
- klass = class_type.new name, superclass
-
- enclosing.add_class_or_module(klass, enclosing.classes_hash,
- @store.classes_hash)
- end
- end
-
- klass.parent = self
-
- klass
- end
-
- ##
- # Adds the class or module +mod+ to the modules or
- # classes Hash +self_hash+, and to +all_hash+ (either
- # <tt>TopLevel::modules_hash</tt> or <tt>TopLevel::classes_hash</tt>),
- # unless #done_documenting is +true+. Sets the #parent of +mod+
- # to +self+, and its #section to #current_section. Returns +mod+.
-
- def add_class_or_module mod, self_hash, all_hash
- mod.section = current_section # TODO declaring context? something is
- # wrong here...
- mod.parent = self
- mod.full_name = nil
- mod.store = @store
-
- unless @done_documenting then
- self_hash[mod.name] = mod
- # this must be done AFTER adding mod to its parent, so that the full
- # name is correct:
- all_hash[mod.full_name] = mod
- if @store.unmatched_constant_alias[mod.full_name] then
- to, file = @store.unmatched_constant_alias[mod.full_name]
- add_module_alias mod, mod.name, to, file
- end
- end
-
- mod
- end
-
- ##
- # Adds +constant+ if not already there. If it is, updates the comment,
- # value and/or is_alias_for of the known constant if they were empty/nil.
-
- def add_constant constant
- return constant unless @document_self
-
- # HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
- # (this is a #ifdef: should be handled by the C parser)
- known = @constants_hash[constant.name]
-
- if known then
- known.comment = constant.comment if known.comment.empty?
-
- known.value = constant.value if
- known.value.nil? or known.value.strip.empty?
-
- known.is_alias_for ||= constant.is_alias_for
- else
- @constants_hash[constant.name] = constant
- add_to @constants, constant
- end
-
- constant
- end
-
- ##
- # Adds included module +include+ which should be an RDoc::Include
-
- def add_include include
- add_to @includes, include
-
- include
- end
-
- ##
- # Adds extension module +ext+ which should be an RDoc::Extend
-
- def add_extend ext
- add_to @extends, ext
-
- ext
- end
-
- ##
- # Adds +method+ if not already there. If it is (as method or attribute),
- # updates the comment if it was empty.
-
- def add_method method
- return method unless @document_self
-
- # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)
- key = method.pretty_name
- known = @methods_hash[key]
-
- if known then
- if @store then # otherwise we are loading
- known.comment = method.comment if known.comment.empty?
- previously = ", previously in #{known.file}" unless
- method.file == known.file
- @store.rdoc.options.warn \
- "Duplicate method #{known.full_name} in #{method.file}#{previously}"
- end
- else
- @methods_hash[key] = method
- if @current_line_visibility
- method.visibility, @current_line_visibility = @current_line_visibility, nil
- else
- method.visibility = @visibility
- end
- add_to @method_list, method
- resolve_aliases method
- end
-
- method
- end
-
- ##
- # Adds a module named +name+. If RDoc already knows +name+ is a class then
- # that class is returned instead. See also #add_class.
-
- def add_module(class_type, name)
- mod = @classes[name] || @modules[name]
- return mod if mod
-
- full_name = child_name name
- mod = @store.modules_hash[full_name] || class_type.new(name)
-
- add_class_or_module mod, @modules, @store.modules_hash
- end
-
- ##
- # Adds a module by +RDoc::NormalModule+ instance. See also #add_module.
-
- def add_module_by_normal_module(mod)
- add_class_or_module mod, @modules, @store.modules_hash
- end
-
- ##
- # Adds an alias from +from+ (a class or module) to +name+ which was defined
- # in +file+.
-
- def add_module_alias from, from_name, to, file
- return from if @done_documenting
-
- to_full_name = child_name to.name
-
- # if we already know this name, don't register an alias:
- # see the metaprogramming in lib/active_support/basic_object.rb,
- # where we already know BasicObject is a class when we find
- # BasicObject = BlankSlate
- return from if @store.find_class_or_module to_full_name
-
- unless from
- @store.unmatched_constant_alias[child_name(from_name)] = [to, file]
- return to
- end
-
- new_to = from.dup
- new_to.name = to.name
- new_to.full_name = nil
-
- if new_to.module? then
- @store.modules_hash[to_full_name] = new_to
- @modules[to.name] = new_to
- else
- @store.classes_hash[to_full_name] = new_to
- @classes[to.name] = new_to
- end
-
- # Registers a constant for this alias. The constant value and comment
- # will be updated later, when the Ruby parser adds the constant
- const = RDoc::Constant.new to.name, nil, new_to.comment
- const.record_location file
- const.is_alias_for = from
- add_constant const
-
- new_to
- end
-
- ##
- # Adds +require+ to this context's top level
-
- def add_require(require)
- return require unless @document_self
-
- if RDoc::TopLevel === self then
- add_to @requires, require
- else
- parent.add_require require
- end
- end
-
- ##
- # Returns a section with +title+, creating it if it doesn't already exist.
- # +comment+ will be appended to the section's comment.
- #
- # A section with a +title+ of +nil+ will return the default section.
- #
- # See also RDoc::Context::Section
-
- def add_section title, comment = nil
- if section = @sections[title] then
- section.add_comment comment if comment
- else
- section = Section.new self, title, comment
- @sections[title] = section
- end
-
- section
- end
-
- ##
- # Adds +thing+ to the collection +array+
-
- def add_to array, thing
- array << thing if @document_self
-
- thing.parent = self
- thing.store = @store if @store
- thing.section = current_section
- end
-
- ##
- # Is there any content?
- #
- # This means any of: comment, aliases, methods, attributes, external
- # aliases, require, constant.
- #
- # Includes and extends are also checked unless <tt>includes == false</tt>.
-
- def any_content(includes = true)
- @any_content ||= !(
- @comment.empty? &&
- @method_list.empty? &&
- @attributes.empty? &&
- @aliases.empty? &&
- @external_aliases.empty? &&
- @requires.empty? &&
- @constants.empty?
- )
- @any_content || (includes && !(@includes + @extends).empty? )
- end
-
- ##
- # Creates the full name for a child with +name+
-
- def child_name name
- if name =~ /^:+/
- $' #'
- elsif RDoc::TopLevel === self then
- name
- else
- "#{self.full_name}::#{name}"
- end
- end
-
- ##
- # Class attributes
-
- def class_attributes
- @class_attributes ||= attributes.select { |a| a.singleton }
- end
-
- ##
- # Class methods
-
- def class_method_list
- @class_method_list ||= method_list.select { |a| a.singleton }
- end
-
- ##
- # Array of classes in this context
-
- def classes
- @classes.values
- end
-
- ##
- # All classes and modules in this namespace
-
- def classes_and_modules
- classes + modules
- end
-
- ##
- # Hash of classes keyed by class name
-
- def classes_hash
- @classes
- end
-
- ##
- # The current documentation section that new items will be added to. If
- # temporary_section is available it will be used.
-
- def current_section
- if section = @temporary_section then
- @temporary_section = nil
- else
- section = @current_section
- end
-
- section
- end
-
- ##
- # Is part of this thing was defined in +file+?
-
- def defined_in?(file)
- @in_files.include?(file)
- end
-
- def display(method_attr) # :nodoc:
- if method_attr.is_a? RDoc::Attr
- "#{method_attr.definition} #{method_attr.pretty_name}"
- else
- "method #{method_attr.pretty_name}"
- end
- end
-
- ##
- # Iterator for ancestors for duck-typing. Does nothing. See
- # RDoc::ClassModule#each_ancestor.
- #
- # This method exists to make it easy to work with Context subclasses that
- # aren't part of RDoc.
-
- def each_ancestor # :nodoc:
- end
-
- ##
- # Iterator for attributes
-
- def each_attribute # :yields: attribute
- @attributes.each { |a| yield a }
- end
-
- ##
- # Iterator for classes and modules
-
- def each_classmodule(&block) # :yields: module
- classes_and_modules.sort.each(&block)
- end
-
- ##
- # Iterator for constants
-
- def each_constant # :yields: constant
- @constants.each {|c| yield c}
- end
-
- ##
- # Iterator for included modules
-
- def each_include # :yields: include
- @includes.each do |i| yield i end
- end
-
- ##
- # Iterator for extension modules
-
- def each_extend # :yields: extend
- @extends.each do |e| yield e end
- end
-
- ##
- # Iterator for methods
-
- def each_method # :yields: method
- return enum_for __method__ unless block_given?
-
- @method_list.sort.each { |m| yield m }
- end
-
- ##
- # Iterator for each section's contents sorted by title. The +section+, the
- # section's +constants+ and the sections +attributes+ are yielded. The
- # +constants+ and +attributes+ collections are sorted.
- #
- # To retrieve methods in a section use #methods_by_type with the optional
- # +section+ parameter.
- #
- # NOTE: Do not edit collections yielded by this method
-
- def each_section # :yields: section, constants, attributes
- return enum_for __method__ unless block_given?
-
- constants = @constants.group_by do |constant| constant.section end
- attributes = @attributes.group_by do |attribute| attribute.section end
-
- constants.default = []
- attributes.default = []
-
- sort_sections.each do |section|
- yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort
- end
- end
-
- ##
- # Finds an attribute +name+ with singleton value +singleton+.
-
- def find_attribute(name, singleton)
- name = $1 if name =~ /^(.*)=$/
- @attributes.find { |a| a.name == name && a.singleton == singleton }
- end
-
- ##
- # Finds an attribute with +name+ in this context
-
- def find_attribute_named(name)
- case name
- when /\A#/ then
- find_attribute name[1..-1], false
- when /\A::/ then
- find_attribute name[2..-1], true
- else
- @attributes.find { |a| a.name == name }
- end
- end
-
- ##
- # Finds a class method with +name+ in this context
-
- def find_class_method_named(name)
- @method_list.find { |meth| meth.singleton && meth.name == name }
- end
-
- ##
- # Finds a constant with +name+ in this context
-
- def find_constant_named(name)
- @constants.find do |m|
- m.name == name || m.full_name == name
- end
- end
-
- ##
- # Find a module at a higher scope
-
- def find_enclosing_module_named(name)
- parent && parent.find_module_named(name)
- end
-
- ##
- # Finds an external alias +name+ with singleton value +singleton+.
-
- def find_external_alias(name, singleton)
- @external_aliases.find { |m| m.name == name && m.singleton == singleton }
- end
-
- ##
- # Finds an external alias with +name+ in this context
-
- def find_external_alias_named(name)
- case name
- when /\A#/ then
- find_external_alias name[1..-1], false
- when /\A::/ then
- find_external_alias name[2..-1], true
- else
- @external_aliases.find { |a| a.name == name }
- end
- end
-
- ##
- # Finds a file with +name+ in this context
-
- def find_file_named name
- @store.find_file_named name
- end
-
- ##
- # Finds an instance method with +name+ in this context
-
- def find_instance_method_named(name)
- @method_list.find { |meth| !meth.singleton && meth.name == name }
- end
-
- ##
- # Finds a method, constant, attribute, external alias, module or file
- # named +symbol+ in this context.
-
- def find_local_symbol(symbol)
- find_method_named(symbol) or
- find_constant_named(symbol) or
- find_attribute_named(symbol) or
- find_external_alias_named(symbol) or
- find_module_named(symbol) or
- find_file_named(symbol)
- end
-
- ##
- # Finds a method named +name+ with singleton value +singleton+.
-
- def find_method(name, singleton)
- @method_list.find { |m|
- if m.singleton
- m.name == name && m.singleton == singleton
- else
- m.name == name && !m.singleton && !singleton
- end
- }
- end
-
- ##
- # Finds a instance or module method with +name+ in this context
-
- def find_method_named(name)
- case name
- when /\A#/ then
- find_method name[1..-1], false
- when /\A::/ then
- find_method name[2..-1], true
- else
- @method_list.find { |meth| meth.name == name }
- end
- end
-
- ##
- # Find a module with +name+ using ruby's scoping rules
-
- def find_module_named(name)
- res = @modules[name] || @classes[name]
- return res if res
- return self if self.name == name
- find_enclosing_module_named name
- end
-
- ##
- # Look up +symbol+, first as a module, then as a local symbol.
-
- def find_symbol(symbol)
- find_symbol_module(symbol) || find_local_symbol(symbol)
- end
-
- ##
- # Look up a module named +symbol+.
-
- def find_symbol_module(symbol)
- result = nil
-
- # look for a class or module 'symbol'
- case symbol
- when /^::/ then
- result = @store.find_class_or_module symbol
- when /^(\w+):+(.+)$/
- suffix = $2
- top = $1
- searched = self
- while searched do
- mod = searched.find_module_named(top)
- break unless mod
- result = @store.find_class_or_module "#{mod.full_name}::#{suffix}"
- break if result || searched.is_a?(RDoc::TopLevel)
- searched = searched.parent
- end
- else
- searched = self
- while searched do
- result = searched.find_module_named(symbol)
- break if result || searched.is_a?(RDoc::TopLevel)
- searched = searched.parent
- end
- end
-
- result
- end
-
- ##
- # The full name for this context. This method is overridden by subclasses.
-
- def full_name
- '(unknown)'
- end
-
- ##
- # Does this context and its methods and constants all have documentation?
- #
- # (Yes, fully documented doesn't mean everything.)
-
- def fully_documented?
- documented? and
- attributes.all? { |a| a.documented? } and
- method_list.all? { |m| m.documented? } and
- constants.all? { |c| c.documented? }
- end
-
- ##
- # URL for this with a +prefix+
-
- def http_url(prefix)
- path = name_for_path
- path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<</
- path = [prefix] + path.split('::')
-
- File.join(*path.compact) + '.html'
- end
-
- ##
- # Instance attributes
-
- def instance_attributes
- @instance_attributes ||= attributes.reject { |a| a.singleton }
- end
-
- ##
- # Instance methods
-
- def instance_methods
- @instance_methods ||= method_list.reject { |a| a.singleton }
- end
-
- ##
- # Instance methods
- #--
- # TODO remove this later
-
- def instance_method_list
- warn '#instance_method_list is obsoleted, please use #instance_methods'
- @instance_methods ||= method_list.reject { |a| a.singleton }
- end
-
- ##
- # Breaks method_list into a nested hash by type (<tt>'class'</tt> or
- # <tt>'instance'</tt>) and visibility (+:public+, +:protected+, +:private+).
- #
- # If +section+ is provided only methods in that RDoc::Context::Section will
- # be returned.
-
- def methods_by_type section = nil
- methods = {}
-
- TYPES.each do |type|
- visibilities = {}
- RDoc::VISIBILITIES.each do |vis|
- visibilities[vis] = []
- end
-
- methods[type] = visibilities
- end
-
- each_method do |method|
- next if section and not method.section == section
- methods[method.type][method.visibility] << method
- end
-
- methods
- end
-
- ##
- # Yields AnyMethod and Attr entries matching the list of names in +methods+.
-
- def methods_matching(methods, singleton = false, &block)
- (@method_list + @attributes).each do |m|
- yield m if methods.include?(m.name) and m.singleton == singleton
- end
-
- each_ancestor do |parent|
- parent.methods_matching(methods, singleton, &block)
- end
- end
-
- ##
- # Array of modules in this context
-
- def modules
- @modules.values
- end
-
- ##
- # Hash of modules keyed by module name
-
- def modules_hash
- @modules
- end
-
- ##
- # Name to use to generate the url.
- # <tt>#full_name</tt> by default.
-
- def name_for_path
- full_name
- end
-
- ##
- # Changes the visibility for new methods to +visibility+
-
- def ongoing_visibility=(visibility)
- @visibility = visibility
- end
-
- ##
- # Record +top_level+ as a file +self+ is in.
-
- def record_location(top_level)
- @in_files << top_level unless @in_files.include?(top_level)
- end
-
- ##
- # Should we remove this context from the documentation?
- #
- # The answer is yes if:
- # * #received_nodoc is +true+
- # * #any_content is +false+ (not counting includes)
- # * All #includes are modules (not a string), and their module has
- # <tt>#remove_from_documentation? == true</tt>
- # * All classes and modules have <tt>#remove_from_documentation? == true</tt>
-
- def remove_from_documentation?
- @remove_from_documentation ||=
- @received_nodoc &&
- !any_content(false) &&
- @includes.all? { |i| !i.module.is_a?(String) && i.module.remove_from_documentation? } &&
- classes_and_modules.all? { |cm| cm.remove_from_documentation? }
- end
-
- ##
- # Removes methods and attributes with a visibility less than +min_visibility+.
- #--
- # TODO mark the visibility of attributes in the template (if not public?)
-
- def remove_invisible min_visibility
- return if [:private, :nodoc].include? min_visibility
- remove_invisible_in @method_list, min_visibility
- remove_invisible_in @attributes, min_visibility
- remove_invisible_in @constants, min_visibility
- end
-
- ##
- # Only called when min_visibility == :public or :private
-
- def remove_invisible_in array, min_visibility # :nodoc:
- if min_visibility == :public then
- array.reject! { |e|
- e.visibility != :public and not e.force_documentation
- }
- else
- array.reject! { |e|
- e.visibility == :private and not e.force_documentation
- }
- end
- end
-
- ##
- # Tries to resolve unmatched aliases when a method or attribute has just
- # been added.
-
- def resolve_aliases added
- # resolve any pending unmatched aliases
- key = added.pretty_name
- unmatched_alias_list = @unmatched_alias_lists[key]
- return unless unmatched_alias_list
- unmatched_alias_list.each do |unmatched_alias|
- added.add_alias unmatched_alias, self
- @external_aliases.delete unmatched_alias
- end
- @unmatched_alias_lists.delete key
- end
-
- ##
- # Returns RDoc::Context::Section objects referenced in this context for use
- # in a table of contents.
-
- def section_contents
- used_sections = {}
-
- each_method do |method|
- next unless method.display?
-
- used_sections[method.section] = true
- end
-
- # order found sections
- sections = sort_sections.select do |section|
- used_sections[section]
- end
-
- # only the default section is used
- return [] if
- sections.length == 1 and not sections.first.title
-
- sections
- end
-
- ##
- # Sections in this context
-
- def sections
- @sections.values
- end
-
- def sections_hash # :nodoc:
- @sections
- end
-
- ##
- # Sets the current section to a section with +title+. See also #add_section
-
- def set_current_section title, comment
- @current_section = add_section title, comment
- end
-
- ##
- # Given an array +methods+ of method names, set the visibility of each to
- # +visibility+
-
- def set_visibility_for(methods, visibility, singleton = false)
- methods_matching methods, singleton do |m|
- m.visibility = visibility
- end
- end
-
- ##
- # Given an array +names+ of constants, set the visibility of each constant to
- # +visibility+
-
- def set_constant_visibility_for(names, visibility)
- names.each do |name|
- constant = @constants_hash[name] or next
- constant.visibility = visibility
- end
- end
-
- ##
- # Sorts sections alphabetically (default) or in TomDoc fashion (none,
- # Public, Internal, Deprecated)
-
- def sort_sections
- titles = @sections.map { |title, _| title }
-
- if titles.length > 1 and
- TOMDOC_TITLES_SORT ==
- (titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then
- @sections.values_at(*TOMDOC_TITLES).compact
- else
- @sections.sort_by { |title, _|
- title.to_s
- }.map { |_, section|
- section
- }
- end
- end
-
- def to_s # :nodoc:
- "#{self.class.name} #{self.full_name}"
- end
-
- ##
- # Return the TopLevel that owns us
- #--
- # FIXME we can be 'owned' by several TopLevel (see #record_location &
- # #in_files)
-
- def top_level
- return @top_level if defined? @top_level
- @top_level = self
- @top_level = @top_level.parent until RDoc::TopLevel === @top_level
- @top_level
- end
-
- ##
- # Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+
-
- def upgrade_to_class mod, class_type, enclosing
- enclosing.modules_hash.delete mod.name
-
- klass = RDoc::ClassModule.from_module class_type, mod
- klass.store = @store
-
- # if it was there, then we keep it even if done_documenting
- @store.classes_hash[mod.full_name] = klass
- enclosing.classes_hash[mod.name] = klass
-
- klass
- end
-
- autoload :Section, "#{__dir__}/context/section"
-
-end
diff --git a/lib/rdoc/context/section.rb b/lib/rdoc/context/section.rb
deleted file mode 100644
index c316efe99f..0000000000
--- a/lib/rdoc/context/section.rb
+++ /dev/null
@@ -1,234 +0,0 @@
-# frozen_string_literal: true
-require 'cgi/util'
-
-##
-# A section of documentation like:
-#
-# # :section: The title
-# # The body
-#
-# Sections can be referenced multiple times and will be collapsed into a
-# single section.
-
-class RDoc::Context::Section
-
- include RDoc::Text
-
- MARSHAL_VERSION = 0 # :nodoc:
-
- ##
- # Section comment
-
- attr_reader :comment
-
- ##
- # Section comments
-
- attr_reader :comments
-
- ##
- # Context this Section lives in
-
- attr_reader :parent
-
- ##
- # Section title
-
- attr_reader :title
-
- ##
- # Creates a new section with +title+ and +comment+
-
- def initialize parent, title, comment
- @parent = parent
- @title = title ? title.strip : title
-
- @comments = []
-
- add_comment comment
- end
-
- ##
- # Sections are equal when they have the same #title
-
- def == other
- self.class === other and @title == other.title
- end
-
- alias eql? ==
-
- ##
- # Adds +comment+ to this section
-
- def add_comment comment
- comment = extract_comment comment
-
- return if comment.empty?
-
- case comment
- when RDoc::Comment then
- @comments << comment
- when RDoc::Markup::Document then
- @comments.concat comment.parts
- when Array then
- @comments.concat comment
- else
- raise TypeError, "unknown comment type: #{comment.inspect}"
- end
- end
-
- ##
- # Anchor reference for linking to this section
-
- def aref
- title = @title || '[untitled]'
-
- CGI.escape(title).gsub('%', '-').sub(/^-/, '')
- end
-
- ##
- # Extracts the comment for this section from the original comment block.
- # If the first line contains :section:, strip it and use the rest.
- # Otherwise remove lines up to the line containing :section:, and look
- # for those lines again at the end and remove them. This lets us write
- #
- # # :section: The title
- # # The body
-
- def extract_comment comment
- case comment
- when Array then
- comment.map do |c|
- extract_comment c
- end
- when nil
- RDoc::Comment.new ''
- when RDoc::Comment then
- if comment.text =~ /^#[ \t]*:section:.*\n/ then
- start = $`
- rest = $'
-
- comment.text = if start.empty? then
- rest
- else
- rest.sub(/#{start.chomp}\Z/, '')
- end
- end
-
- comment
- when RDoc::Markup::Document then
- comment
- else
- raise TypeError, "unknown comment #{comment.inspect}"
- end
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %p>" % [self.class, object_id, title]
- end
-
- def hash # :nodoc:
- @title.hash
- end
-
- ##
- # The files comments in this section come from
-
- def in_files
- return [] if @comments.empty?
-
- case @comments
- when Array then
- @comments.map do |comment|
- comment.file
- end
- when RDoc::Markup::Document then
- @comment.parts.map do |document|
- document.file
- end
- else
- raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
- end
- end
-
- ##
- # Serializes this Section. The title and parsed comment are saved, but not
- # the section parent which must be restored manually.
-
- def marshal_dump
- [
- MARSHAL_VERSION,
- @title,
- parse,
- ]
- end
-
- ##
- # De-serializes this Section. The section parent must be restored manually.
-
- def marshal_load array
- @parent = nil
-
- @title = array[1]
- @comments = array[2]
- end
-
- ##
- # Parses +comment_location+ into an RDoc::Markup::Document composed of
- # multiple RDoc::Markup::Documents with their file set.
-
- def parse
- case @comments
- when String then
- super
- when Array then
- docs = @comments.map do |comment, location|
- doc = super comment
- doc.file = location if location
- doc
- end
-
- RDoc::Markup::Document.new(*docs)
- when RDoc::Comment then
- doc = super @comments.text, comments.format
- doc.file = @comments.location
- doc
- when RDoc::Markup::Document then
- return @comments
- else
- raise ArgumentError, "unknown comment class #{comments.class}"
- end
- end
-
- ##
- # The section's title, or 'Top Section' if the title is nil.
- #
- # This is used by the table of contents template so the name is silly.
-
- def plain_html
- @title || 'Top Section'
- end
-
- ##
- # Removes a comment from this section if it is from the same file as
- # +comment+
-
- def remove_comment comment
- return if @comments.empty?
-
- case @comments
- when Array then
- @comments.delete_if do |my_comment|
- my_comment.file == comment.file
- end
- when RDoc::Markup::Document then
- @comments.parts.delete_if do |document|
- document.file == comment.file.name
- end
- else
- raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
- end
- end
-
-end
-
diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb
deleted file mode 100644
index 319bbc02ac..0000000000
--- a/lib/rdoc/cross_reference.rb
+++ /dev/null
@@ -1,226 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'markup/attribute_manager' # for PROTECT_ATTR
-
-##
-# RDoc::CrossReference is a reusable way to create cross references for names.
-
-class RDoc::CrossReference
-
- ##
- # Regular expression to match class references
- #
- # 1. There can be a '\\' in front of text to suppress the cross-reference
- # 2. There can be a '::' in front of class names to reference from the
- # top-level namespace.
- # 3. The method can be followed by parenthesis (not recommended)
-
- CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)'
-
- ##
- # Regular expression to match a single method argument.
-
- METHOD_ARG_REGEXP_STR = '[\w.+*/=<>-]+'
-
- ##
- # Regular expression to match method arguments.
-
- METHOD_ARGS_REGEXP_STR = /(?:\((?:#{METHOD_ARG_REGEXP_STR}(?:,\s*#{METHOD_ARG_REGEXP_STR})*)?\))?/.source
-
- ##
- # Regular expression to match method references.
- #
- # See CLASS_REGEXP_STR
-
- METHOD_REGEXP_STR = /(
- (?!\d)[\w#{RDoc::Markup::AttributeManager::PROTECT_ATTR}]+[!?=]?|
- %|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[\/%\`|&^~]
- )#{METHOD_ARGS_REGEXP_STR}/.source.delete("\n ").freeze
-
- ##
- # Regular expressions matching text that should potentially have
- # cross-reference links generated are passed to add_regexp_handling. Note
- # that these expressions are meant to pick up text for which cross-references
- # have been suppressed, since the suppression characters are removed by the
- # code that is triggered.
-
- CROSSREF_REGEXP = /(?:^|[\s()])
- (
- (?:
- # A::B::C.meth
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
-
- # A::B::C
- # The stuff after CLASS_REGEXP_STR is a
- # nasty hack. CLASS_REGEXP_STR unfortunately matches
- # words like dog and cat (these are legal "class"
- # names in Fortran 95). When a word is flagged as a
- # potential cross-reference, limitations in the markup
- # engine suppress other processing, such as typesetting.
- # This is particularly noticeable for contractions.
- # In order that words like "can't" not
- # be flagged as potential cross-references, only
- # flag potential class cross-references if the character
- # after the cross-reference is a space, sentence
- # punctuation, tag start character, or attribute
- # marker.
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
-
- # Stand-alone method (preceded by a #)
- | \\?\##{METHOD_REGEXP_STR}
-
- # Stand-alone method (preceded by ::)
- | ::#{METHOD_REGEXP_STR}
-
- # Things that look like filenames
- # The key thing is that there must be at least
- # one special character (period, slash, or
- # underscore).
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
-
- # Things that have markup suppressed
- # Don't process things like '\<' in \<tt>, though.
- # TODO: including < is a hack, not very satisfying.
- | \\[^\s<]
- )
-
- # labels for headings
- (?:@[\w+%-]+(?:\.[\w|%-]+)?)?
- )/x
-
- ##
- # Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
-
- ALL_CROSSREF_REGEXP = /
- (?:^|[\s()])
- (
- (?:
- # A::B::C.meth
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
-
- # A::B::C
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
-
- # Stand-alone method
- | \\?#{METHOD_REGEXP_STR}
-
- # Things that look like filenames
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
-
- # Things that have markup suppressed
- | \\[^\s<]
- )
-
- # labels for headings
- (?:@[\w+%-]+)?
- )/x
-
- ##
- # Hash of references that have been looked-up to their replacements
-
- attr_accessor :seen
-
- ##
- # Allows cross-references to be created based on the given +context+
- # (RDoc::Context).
-
- def initialize context
- @context = context
- @store = context.store
-
- @seen = {}
- end
-
- def resolve_method name
- ref = nil
-
- if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
- type = $2
- if '.' == type # will find either #method or ::method
- method = $3
- else
- method = "#{type}#{$3}"
- end
- container = @context.find_symbol_module($1)
- elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
- type = $1
- if '.' == type
- method = $2
- else
- method = "#{type}#{$2}"
- end
- container = @context
- else
- type = nil
- container = nil
- end
-
- if container then
- unless RDoc::TopLevel === container then
- if '.' == type then
- if 'new' == method then # AnyClassName.new will be class method
- ref = container.find_local_symbol method
- ref = container.find_ancestor_local_symbol method unless ref
- else
- ref = container.find_local_symbol "::#{method}"
- ref = container.find_ancestor_local_symbol "::#{method}" unless ref
- ref = container.find_local_symbol "##{method}" unless ref
- ref = container.find_ancestor_local_symbol "##{method}" unless ref
- end
- else
- ref = container.find_local_symbol method
- ref = container.find_ancestor_local_symbol method unless ref
- end
- end
- end
-
- ref
- end
-
- ##
- # Returns a reference to +name+.
- #
- # If the reference is found and +name+ is not documented +text+ will be
- # returned. If +name+ is escaped +name+ is returned. If +name+ is not
- # found +text+ is returned.
-
- def resolve name, text
- return @seen[name] if @seen.include? name
-
- ref = case name
- when /^\\(#{CLASS_REGEXP_STR})$/o then
- @context.find_symbol $1
- else
- @context.find_symbol name
- end
-
- ref = resolve_method name unless ref
-
- # Try a page name
- ref = @store.page name if not ref and name =~ /^[\w.]+$/
-
- ref = nil if RDoc::Alias === ref # external alias, can't link to it
-
- out = if name == '\\' then
- name
- elsif name =~ /^\\/ then
- # we remove the \ only in front of what we know:
- # other backslashes are treated later, only outside of <tt>
- ref ? $' : name
- elsif ref then
- if ref.display? then
- ref
- else
- text
- end
- else
- text
- end
-
- @seen[name] = out
-
- out
- end
-
-end
-
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb
deleted file mode 100644
index cf60badd24..0000000000
--- a/lib/rdoc/encoding.rb
+++ /dev/null
@@ -1,136 +0,0 @@
-# coding: US-ASCII
-# frozen_string_literal: true
-
-##
-# This class is a wrapper around File IO and Encoding that helps RDoc load
-# files and convert them to the correct encoding.
-
-module RDoc::Encoding
-
- HEADER_REGEXP = /^
- (?:
- \A\#!.*\n
- |
- ^\#\s+frozen[-_]string[-_]literal[=:].+\n
- |
- ^\#[^\n]+\b(?:en)?coding[=:]\s*(?<name>[^\s;]+).*\n
- |
- <\?xml[^?]*encoding=(?<quote>["'])(?<name>.*?)\k<quote>.*\n
- )+
- /xi # :nodoc:
-
- ##
- # Reads the contents of +filename+ and handles any encoding directives in
- # the file.
- #
- # The content will be converted to the +encoding+. If the file cannot be
- # converted a warning will be printed and nil will be returned.
- #
- # If +force_transcode+ is true the document will be transcoded and any
- # unknown character in the target encoding will be replaced with '?'
-
- def self.read_file filename, encoding, force_transcode = false
- content = File.open filename, "rb" do |f| f.read end
- content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
-
- utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
-
- enc = RDoc::Encoding.detect_encoding content
- content = RDoc::Encoding.change_encoding content, enc if enc
-
- begin
- encoding ||= Encoding.default_external
- orig_encoding = content.encoding
-
- if not orig_encoding.ascii_compatible? then
- content = content.encode encoding
- elsif utf8 then
- content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
- content = content.encode encoding
- else
- # assume the content is in our output encoding
- content = RDoc::Encoding.change_encoding content, encoding
- end
-
- unless content.valid_encoding? then
- # revert and try to transcode
- content = RDoc::Encoding.change_encoding content, orig_encoding
- content = content.encode encoding
- end
-
- unless content.valid_encoding? then
- warn "unable to convert #{filename} to #{encoding}, skipping"
- content = nil
- end
- rescue Encoding::InvalidByteSequenceError,
- Encoding::UndefinedConversionError => e
- if force_transcode then
- content = RDoc::Encoding.change_encoding content, orig_encoding
- content = content.encode(encoding,
- :invalid => :replace,
- :undef => :replace,
- :replace => '?')
- return content
- else
- warn "unable to convert #{e.message} for #{filename}, skipping"
- return nil
- end
- end
-
- content
- rescue ArgumentError => e
- raise unless e.message =~ /unknown encoding name - (.*)/
- warn "unknown encoding name \"#{$1}\" for #{filename}, skipping"
- nil
- rescue Errno::EISDIR, Errno::ENOENT
- nil
- end
-
- def self.remove_frozen_string_literal string
- string =~ /\A(?:#!.*\n)?(.*\n)/
- first_line = $1
-
- if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
- string = string.sub first_line, ''
- end
-
- string
- end
-
- ##
- # Detects the encoding of +string+ based on the magic comment
-
- def self.detect_encoding string
- result = HEADER_REGEXP.match string
- name = result && result[:name]
-
- name ? Encoding.find(name) : nil
- end
-
- ##
- # Removes magic comments and shebang
-
- def self.remove_magic_comment string
- string.sub HEADER_REGEXP do |s|
- s.gsub(/[^\n]/, '')
- end
- end
-
- ##
- # Changes encoding based on +encoding+ without converting and returns new
- # string
-
- def self.change_encoding text, encoding
- if text.kind_of? RDoc::Comment
- text.encode! encoding
- else
- # TODO: Remove this condition after Ruby 2.2 EOL
- if RUBY_VERSION < '2.3.0'
- text.force_encoding encoding
- else
- String.new text, encoding: encoding
- end
- end
- end
-
-end
diff --git a/lib/rdoc/erb_partial.rb b/lib/rdoc/erb_partial.rb
deleted file mode 100644
index d6e3f41b7e..0000000000
--- a/lib/rdoc/erb_partial.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-##
-# Allows an ERB template to be rendered in the context (binding) of an
-# existing ERB template evaluation.
-
-class RDoc::ERBPartial < ERB
-
- ##
- # Overrides +compiler+ startup to set the +eoutvar+ to an empty string only
- # if it isn't already set.
-
- def set_eoutvar compiler, eoutvar = '_erbout'
- super
-
- compiler.pre_cmd = ["#{eoutvar} ||= +''"]
- end
-
-end
-
diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb
deleted file mode 100644
index 0d5f96e133..0000000000
--- a/lib/rdoc/erbio.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-require 'erb'
-
-##
-# A subclass of ERB that writes directly to an IO. Credit to Aaron Patterson
-# and Masatoshi SEKI.
-#
-# To use:
-#
-# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil
-#
-# File.open 'hello.txt', 'w' do |io|
-# erbio.result binding
-# end
-#
-# Note that binding must enclose the io you wish to output on.
-
-class RDoc::ERBIO < ERB
-
- ##
- # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
-
- def initialize str, safe_level = nil, legacy_trim_mode = nil, legacy_eoutvar = 'io', trim_mode: nil, eoutvar: 'io'
- if RUBY_VERSION >= '2.6'
- super(str, trim_mode: trim_mode, eoutvar: eoutvar)
- else
- super(str, safe_level, legacy_trim_mode, legacy_eoutvar)
- end
- end
-
- ##
- # Instructs +compiler+ how to write to +io_variable+
-
- def set_eoutvar compiler, io_variable
- compiler.put_cmd = "#{io_variable}.write"
- compiler.insert_cmd = "#{io_variable}.write"
- compiler.pre_cmd = []
- compiler.post_cmd = []
- end
-
-end
-
diff --git a/lib/rdoc/extend.rb b/lib/rdoc/extend.rb
deleted file mode 100644
index e1b182902e..0000000000
--- a/lib/rdoc/extend.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-##
-# A Module extension to a class with \#extend
-#
-# RDoc::Extend.new 'Enumerable', 'comment ...'
-
-class RDoc::Extend < RDoc::Mixin
-
-end
-
diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb
deleted file mode 100644
index a769cf8ac0..0000000000
--- a/lib/rdoc/generator.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-##
-# RDoc uses generators to turn parsed source code in the form of an
-# RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
-# generator RDoc::Generator::Darkfish and an ri data generator
-# RDoc::Generator::RI.
-#
-# == Registering a Generator
-#
-# Generators are registered by calling RDoc::RDoc.add_generator with the class
-# of the generator:
-#
-# class My::Awesome::Generator
-# RDoc::RDoc.add_generator self
-# end
-#
-# == Adding Options to +rdoc+
-#
-# Before option processing in +rdoc+, RDoc::Options will call ::setup_options
-# on the generator class with an RDoc::Options instance. The generator can
-# use RDoc::Options#option_parser to add command-line options to the +rdoc+
-# tool. See RDoc::Options@Custom+Options for an example and see OptionParser
-# for details on how to add options.
-#
-# You can extend the RDoc::Options instance with additional accessors for your
-# generator.
-#
-# == Generator Instantiation
-#
-# After parsing, RDoc::RDoc will instantiate a generator by calling
-# #initialize with an RDoc::Store instance and an RDoc::Options instance.
-#
-# The RDoc::Store instance holds documentation for parsed source code. In
-# RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading
-# a generator from RDoc 3 and earlier you should only need to replace
-# RDoc::TopLevel with the store instance.
-#
-# RDoc will then call #generate on the generator instance. You can use the
-# various methods on RDoc::Store and in the RDoc::CodeObject tree to create
-# your desired output format.
-
-module RDoc::Generator
-
- autoload :Markup, "#{__dir__}/generator/markup"
-
- autoload :Darkfish, "#{__dir__}/generator/darkfish"
- autoload :JsonIndex, "#{__dir__}/generator/json_index"
- autoload :RI, "#{__dir__}/generator/ri"
- autoload :POT, "#{__dir__}/generator/pot"
-
-end
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb
deleted file mode 100644
index 60e0265e8c..0000000000
--- a/lib/rdoc/generator/darkfish.rb
+++ /dev/null
@@ -1,790 +0,0 @@
-# frozen_string_literal: true
-# -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
-
-require 'erb'
-require 'fileutils'
-require 'pathname'
-require_relative 'markup'
-
-##
-# Darkfish RDoc HTML Generator
-#
-# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $
-#
-# == Author/s
-# * Michael Granger (ged@FaerieMUD.org)
-#
-# == Contributors
-# * Mahlon E. Smith (mahlon@martini.nu)
-# * Eric Hodel (drbrain@segment7.net)
-#
-# == License
-#
-# Copyright (c) 2007, 2008, Michael Granger. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * 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.
-#
-# * Neither the name of the author/s, nor the names of the project's
-# contributors may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# == Attributions
-#
-# Darkfish uses the {Silk Icons}[http://www.famfamfam.com/lab/icons/silk/] set
-# by Mark James.
-
-class RDoc::Generator::Darkfish
-
- RDoc::RDoc.add_generator self
-
- include ERB::Util
-
- ##
- # Stylesheets, fonts, etc. that are included in RDoc.
-
- BUILTIN_STYLE_ITEMS = # :nodoc:
- %w[
- css/fonts.css
- fonts/Lato-Light.ttf
- fonts/Lato-LightItalic.ttf
- fonts/Lato-Regular.ttf
- fonts/Lato-RegularItalic.ttf
- fonts/SourceCodePro-Bold.ttf
- fonts/SourceCodePro-Regular.ttf
- css/rdoc.css
- ]
-
- ##
- # Path to this file's parent directory. Used to find templates and other
- # resources.
-
- GENERATOR_DIR = File.join 'rdoc', 'generator'
-
- ##
- # Release Version
-
- VERSION = '3'
-
- ##
- # Description of this generator
-
- DESCRIPTION = 'HTML generator, written by Michael Granger'
-
- ##
- # The relative path to style sheets and javascript. By default this is set
- # the same as the rel_prefix.
-
- attr_accessor :asset_rel_path
-
- ##
- # The path to generate files into, combined with <tt>--op</tt> from the
- # options for a full path.
-
- attr_reader :base_dir
-
- ##
- # Classes and modules to be used by this generator, not necessarily
- # displayed. See also #modsort
-
- attr_reader :classes
-
- ##
- # No files will be written when dry_run is true.
-
- attr_accessor :dry_run
-
- ##
- # When false the generate methods return a String instead of writing to a
- # file. The default is true.
-
- attr_accessor :file_output
-
- ##
- # Files to be displayed by this generator
-
- attr_reader :files
-
- ##
- # The JSON index generator for this Darkfish generator
-
- attr_reader :json_index
-
- ##
- # Methods to be displayed by this generator
-
- attr_reader :methods
-
- ##
- # Sorted list of classes and modules to be displayed by this generator
-
- attr_reader :modsort
-
- ##
- # The RDoc::Store that is the source of the generated content
-
- attr_reader :store
-
- ##
- # The directory where the template files live
-
- attr_reader :template_dir # :nodoc:
-
- ##
- # The output directory
-
- attr_reader :outputdir
-
- ##
- # Initialize a few instance variables before we start
-
- def initialize store, options
- @store = store
- @options = options
-
- @asset_rel_path = ''
- @base_dir = Pathname.pwd.expand_path
- @dry_run = @options.dry_run
- @file_output = true
- @template_dir = Pathname.new options.template_dir
- @template_cache = {}
-
- @classes = nil
- @context = nil
- @files = nil
- @methods = nil
- @modsort = nil
-
- @json_index = RDoc::Generator::JsonIndex.new self, options
- end
-
- ##
- # Output progress information if debugging is enabled
-
- def debug_msg *msg
- return unless $DEBUG_RDOC
- $stderr.puts(*msg)
- end
-
- ##
- # Directory where generated class HTML files live relative to the output
- # dir.
-
- def class_dir
- nil
- end
-
- ##
- # Directory where generated class HTML files live relative to the output
- # dir.
-
- def file_dir
- nil
- end
-
- ##
- # Create the directories the generated docs will live in if they don't
- # already exist.
-
- def gen_sub_directories
- @outputdir.mkpath
- end
-
- ##
- # Copy over the stylesheet into the appropriate place in the output
- # directory.
-
- def write_style_sheet
- debug_msg "Copying static files"
- options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
-
- BUILTIN_STYLE_ITEMS.each do |item|
- install_rdoc_static_file @template_dir + item, "./#{item}", options
- end
-
- unless @options.template_stylesheets.empty?
- FileUtils.cp @options.template_stylesheets, '.', **options
- end
-
- Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
- next if File.directory? path
- next if File.basename(path) =~ /^\./
-
- dst = Pathname.new(path).relative_path_from @template_dir
-
- install_rdoc_static_file @template_dir + path, dst, options
- end
- end
-
- ##
- # Build the initial indices and output objects based on an array of TopLevel
- # objects containing the extracted information.
-
- def generate
- setup
-
- write_style_sheet
- generate_index
- generate_class_files
- generate_file_files
- generate_table_of_contents
- @json_index.generate
- @json_index.generate_gzipped
-
- copy_static
-
- rescue => e
- debug_msg "%s: %s\n %s" % [
- e.class.name, e.message, e.backtrace.join("\n ")
- ]
-
- raise
- end
-
- ##
- # Copies static files from the static_path into the output directory
-
- def copy_static
- return if @options.static_path.empty?
-
- fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
-
- @options.static_path.each do |path|
- unless File.directory? path then
- FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
- next
- end
-
- Dir.chdir path do
- Dir[File.join('**', '*')].each do |entry|
- dest_file = @outputdir + entry
-
- if File.directory? entry then
- FileUtils.mkdir_p entry, **fu_options
- else
- FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
- end
- end
- end
- end
- end
-
- ##
- # Return a list of the documented modules sorted by salience first, then
- # by name.
-
- def get_sorted_module_list classes
- classes.select do |klass|
- klass.display?
- end.sort
- end
-
- ##
- # Generate an index page which lists all the classes which are documented.
-
- def generate_index
- setup
-
- template_file = @template_dir + 'index.rhtml'
- return unless template_file.exist?
-
- debug_msg "Rendering the index page..."
-
- out_file = @base_dir + @options.op_dir + 'index.html'
- rel_prefix = @outputdir.relative_path_from out_file.dirname
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- asset_rel_prefix = rel_prefix + @asset_rel_path
-
- @title = @options.title
-
- render_template template_file, out_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here
- end
- rescue => e
- error = RDoc::Error.new \
- "error generating index.html: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- ##
- # Generates a class file for +klass+
-
- def generate_class klass, template_file = nil
- setup
-
- current = klass
-
- template_file ||= @template_dir + 'class.rhtml'
-
- debug_msg " working on %s (%s)" % [klass.full_name, klass.path]
- out_file = @outputdir + klass.path
- rel_prefix = @outputdir.relative_path_from out_file.dirname
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- asset_rel_prefix = rel_prefix + @asset_rel_path
- svninfo = get_svninfo(current)
-
- @title = "#{klass.type} #{klass.full_name} - #{@options.title}"
-
- debug_msg " rendering #{out_file}"
- render_template template_file, out_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here.local_variable_set(:svninfo, svninfo)
- here
- end
- end
-
- ##
- # Generate a documentation file for each class and module
-
- def generate_class_files
- setup
-
- template_file = @template_dir + 'class.rhtml'
- template_file = @template_dir + 'classpage.rhtml' unless
- template_file.exist?
- return unless template_file.exist?
- debug_msg "Generating class documentation in #{@outputdir}"
-
- current = nil
-
- @classes.each do |klass|
- current = klass
-
- generate_class klass, template_file
- end
- rescue => e
- error = RDoc::Error.new \
- "error generating #{current.path}: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- ##
- # Generate a documentation file for each file
-
- def generate_file_files
- setup
-
- page_file = @template_dir + 'page.rhtml'
- fileinfo_file = @template_dir + 'fileinfo.rhtml'
-
- # for legacy templates
- filepage_file = @template_dir + 'filepage.rhtml' unless
- page_file.exist? or fileinfo_file.exist?
-
- return unless
- page_file.exist? or fileinfo_file.exist? or filepage_file.exist?
-
- debug_msg "Generating file documentation in #{@outputdir}"
-
- out_file = nil
- current = nil
-
- @files.each do |file|
- current = file
-
- if file.text? and page_file.exist? then
- generate_page file
- next
- end
-
- template_file = nil
- out_file = @outputdir + file.path
- debug_msg " working on %s (%s)" % [file.full_name, out_file]
- rel_prefix = @outputdir.relative_path_from out_file.dirname
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- asset_rel_prefix = rel_prefix + @asset_rel_path
-
- unless filepage_file then
- if file.text? then
- next unless page_file.exist?
- template_file = page_file
- @title = file.page_name
- else
- next unless fileinfo_file.exist?
- template_file = fileinfo_file
- @title = "File: #{file.base_name}"
- end
- end
-
- @title += " - #{@options.title}"
- template_file ||= filepage_file
-
- render_template template_file, out_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here.local_variable_set(:current, current)
- here
- end
- end
- rescue => e
- error =
- RDoc::Error.new "error generating #{out_file}: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- ##
- # Generate a page file for +file+
-
- def generate_page file
- setup
-
- template_file = @template_dir + 'page.rhtml'
-
- out_file = @outputdir + file.path
- debug_msg " working on %s (%s)" % [file.full_name, out_file]
- rel_prefix = @outputdir.relative_path_from out_file.dirname
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- current = file
- asset_rel_prefix = rel_prefix + @asset_rel_path
-
- @title = "#{file.page_name} - #{@options.title}"
-
- debug_msg " rendering #{out_file}"
- render_template template_file, out_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:current, current)
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here
- end
- end
-
- ##
- # Generates the 404 page for the RDoc servlet
-
- def generate_servlet_not_found message
- setup
-
- template_file = @template_dir + 'servlet_not_found.rhtml'
- return unless template_file.exist?
-
- debug_msg "Rendering the servlet 404 Not Found page..."
-
- rel_prefix = rel_prefix = ''
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- asset_rel_prefix = ''
-
- @title = 'Not Found'
-
- render_template template_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here
- end
- rescue => e
- error = RDoc::Error.new \
- "error generating servlet_not_found: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- ##
- # Generates the servlet root page for the RDoc servlet
-
- def generate_servlet_root installed
- setup
-
- template_file = @template_dir + 'servlet_root.rhtml'
- return unless template_file.exist?
-
- debug_msg 'Rendering the servlet root page...'
-
- rel_prefix = '.'
- asset_rel_prefix = rel_prefix
- search_index_rel_prefix = asset_rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- @title = 'Local RDoc Documentation'
-
- render_template template_file do |io| binding end
- rescue => e
- error = RDoc::Error.new \
- "error generating servlet_root: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- ##
- # Generate an index page which lists all the classes which are documented.
-
- def generate_table_of_contents
- setup
-
- template_file = @template_dir + 'table_of_contents.rhtml'
- return unless template_file.exist?
-
- debug_msg "Rendering the Table of Contents..."
-
- out_file = @outputdir + 'table_of_contents.html'
- rel_prefix = @outputdir.relative_path_from out_file.dirname
- search_index_rel_prefix = rel_prefix
- search_index_rel_prefix += @asset_rel_path if @file_output
-
- asset_rel_prefix = rel_prefix + @asset_rel_path
-
- @title = "Table of Contents - #{@options.title}"
-
- render_template template_file, out_file do |io|
- here = binding
- # suppress 1.9.3 warning
- here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
- here
- end
- rescue => e
- error = RDoc::Error.new \
- "error generating table_of_contents.html: #{e.message} (#{e.class})"
- error.set_backtrace e.backtrace
-
- raise error
- end
-
- def install_rdoc_static_file source, destination, options # :nodoc:
- return unless source.exist?
-
- begin
- FileUtils.mkdir_p File.dirname(destination), **options
-
- begin
- FileUtils.ln source, destination, **options
- rescue Errno::EEXIST
- FileUtils.rm destination
- retry
- end
- rescue
- FileUtils.cp source, destination, **options
- end
- end
-
- ##
- # Prepares for generation of output from the current directory
-
- def setup
- return if instance_variable_defined? :@outputdir
-
- @outputdir = Pathname.new(@options.op_dir).expand_path @base_dir
-
- return unless @store
-
- @classes = @store.all_classes_and_modules.sort
- @files = @store.all_files.sort
- @methods = @classes.map { |m| m.method_list }.flatten.sort
- @modsort = get_sorted_module_list @classes
- end
-
- ##
- # Return a string describing the amount of time in the given number of
- # seconds in terms a human can understand easily.
-
- def time_delta_string seconds
- return 'less than a minute' if seconds < 60
- return "#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}" if
- seconds < 3000 # 50 minutes
- return 'about one hour' if seconds < 5400 # 90 minutes
- return "#{seconds / 3600} hours" if seconds < 64800 # 18 hours
- return 'one day' if seconds < 86400 # 1 day
- return 'about one day' if seconds < 172800 # 2 days
- return "#{seconds / 86400} days" if seconds < 604800 # 1 week
- return 'about one week' if seconds < 1209600 # 2 week
- return "#{seconds / 604800} weeks" if seconds < 7257600 # 3 months
- return "#{seconds / 2419200} months" if seconds < 31536000 # 1 year
- return "#{seconds / 31536000} years"
- end
-
- # %q$Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $"
- SVNID_PATTERN = /
- \$Id:\s
- (\S+)\s # filename
- (\d+)\s # rev
- (\d{4}-\d{2}-\d{2})\s # Date (YYYY-MM-DD)
- (\d{2}:\d{2}:\d{2}Z)\s # Time (HH:MM:SSZ)
- (\w+)\s # committer
- \$$
- /x
-
- ##
- # Try to extract Subversion information out of the first constant whose
- # value looks like a subversion Id tag. If no matching constant is found,
- # and empty hash is returned.
-
- def get_svninfo klass
- constants = klass.constants or return {}
-
- constants.find { |c| c.value =~ SVNID_PATTERN } or return {}
-
- filename, rev, date, time, committer = $~.captures
- commitdate = Time.parse "#{date} #{time}"
-
- return {
- :filename => filename,
- :rev => Integer(rev),
- :commitdate => commitdate,
- :commitdelta => time_delta_string(Time.now - commitdate),
- :committer => committer,
- }
- end
-
- ##
- # Creates a template from its components and the +body_file+.
- #
- # For backwards compatibility, if +body_file+ contains "<html" the body is
- # used directly.
-
- def assemble_template body_file
- body = body_file.read
- return body if body =~ /<html/
-
- head_file = @template_dir + '_head.rhtml'
- footer_file = @template_dir + '_footer.rhtml'
-
- <<-TEMPLATE
-<!DOCTYPE html>
-
-<html>
-<head>
-#{head_file.read}
-
-#{body}
-
-#{footer_file.read}
- TEMPLATE
- end
-
- ##
- # Renders the ERb contained in +file_name+ relative to the template
- # directory and returns the result based on the current context.
-
- def render file_name
- template_file = @template_dir + file_name
-
- template = template_for template_file, false, RDoc::ERBPartial
-
- template.filename = template_file.to_s
-
- template.result @context
- end
-
- ##
- # Load and render the erb template in the given +template_file+ and write
- # it out to +out_file+.
- #
- # Both +template_file+ and +out_file+ should be Pathname-like objects.
- #
- # An io will be yielded which must be captured by binding in the caller.
-
- def render_template template_file, out_file = nil # :yield: io
- io_output = out_file && !@dry_run && @file_output
- erb_klass = io_output ? RDoc::ERBIO : ERB
-
- template = template_for template_file, true, erb_klass
-
- if io_output then
- debug_msg "Outputting to %s" % [out_file.expand_path]
-
- out_file.dirname.mkpath
- out_file.open 'w', 0644 do |io|
- io.set_encoding @options.encoding
-
- @context = yield io
-
- template_result template, @context, template_file
- end
- else
- @context = yield nil
-
- output = template_result template, @context, template_file
-
- debug_msg " would have written %d characters to %s" % [
- output.length, out_file.expand_path
- ] if @dry_run
-
- output
- end
- end
-
- ##
- # Creates the result for +template+ with +context+. If an error is raised a
- # Pathname +template_file+ will indicate the file where the error occurred.
-
- def template_result template, context, template_file
- template.filename = template_file.to_s
- template.result context
- rescue NoMethodError => e
- raise RDoc::Error, "Error while evaluating %s: %s" % [
- template_file.expand_path,
- e.message,
- ], e.backtrace
- end
-
- ##
- # Retrieves a cache template for +file+, if present, or fills the cache.
-
- def template_for file, page = true, klass = ERB
- template = @template_cache[file]
-
- return template if template
-
- if page then
- template = assemble_template file
- erbout = 'io'
- else
- template = file.read
- template = template.encode @options.encoding
-
- file_var = File.basename(file).sub(/\..*/, '')
-
- erbout = "_erbout_#{file_var}"
- end
-
- if RUBY_VERSION >= '2.6'
- template = klass.new template, trim_mode: '-', eoutvar: erbout
- else
- template = klass.new template, nil, '-', erbout
- end
- @template_cache[file] = template
- template
- end
-
-end
diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb
deleted file mode 100644
index 3a1000033d..0000000000
--- a/lib/rdoc/generator/json_index.rb
+++ /dev/null
@@ -1,300 +0,0 @@
-# frozen_string_literal: true
-require 'json'
-begin
- require 'zlib'
-rescue LoadError
-end
-
-##
-# The JsonIndex generator is designed to complement an HTML generator and
-# produces a JSON search index. This generator is derived from sdoc by
-# Vladimir Kolesnikov and contains verbatim code written by him.
-#
-# This generator is designed to be used with a regular HTML generator:
-#
-# class RDoc::Generator::Darkfish
-# def initialize options
-# # ...
-# @base_dir = Pathname.pwd.expand_path
-#
-# @json_index = RDoc::Generator::JsonIndex.new self, options
-# end
-#
-# def generate
-# # ...
-# @json_index.generate
-# end
-# end
-#
-# == Index Format
-#
-# The index is output as a JSON file assigned to the global variable
-# +search_data+. The structure is:
-#
-# var search_data = {
-# "index": {
-# "searchIndex":
-# ["a", "b", ...],
-# "longSearchIndex":
-# ["a", "a::b", ...],
-# "info": [
-# ["A", "A", "A.html", "", ""],
-# ["B", "A::B", "A::B.html", "", ""],
-# ...
-# ]
-# }
-# }
-#
-# The same item is described across the +searchIndex+, +longSearchIndex+ and
-# +info+ fields. The +searchIndex+ field contains the item's short name, the
-# +longSearchIndex+ field contains the full_name (when appropriate) and the
-# +info+ field contains the item's name, full_name, path, parameters and a
-# snippet of the item's comment.
-#
-# == LICENSE
-#
-# Copyright (c) 2009 Vladimir Kolesnikov
-#
-# 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.
-
-class RDoc::Generator::JsonIndex
-
- include RDoc::Text
-
- ##
- # Where the search index lives in the generated output
-
- SEARCH_INDEX_FILE = File.join 'js', 'search_index.js'
-
- attr_reader :index # :nodoc:
-
- ##
- # Creates a new generator. +parent_generator+ is used to determine the
- # class_dir and file_dir of links in the output index.
- #
- # +options+ are the same options passed to the parent generator.
-
- def initialize parent_generator, options
- @parent_generator = parent_generator
- @store = parent_generator.store
- @options = options
-
- @template_dir = File.expand_path '../template/json_index', __FILE__
- @base_dir = @parent_generator.base_dir
-
- @classes = nil
- @files = nil
- @index = nil
- end
-
- ##
- # Builds the JSON index as a Hash.
-
- def build_index
- reset @store.all_files.sort, @store.all_classes_and_modules.sort
-
- index_classes
- index_methods
- index_pages
-
- { :index => @index }
- end
-
- ##
- # Output progress information if debugging is enabled
-
- def debug_msg *msg
- return unless $DEBUG_RDOC
- $stderr.puts(*msg)
- end
-
- ##
- # Writes the JSON index to disk
-
- def generate
- debug_msg "Generating JSON index"
-
- debug_msg " writing search index to %s" % SEARCH_INDEX_FILE
- data = build_index
-
- return if @options.dry_run
-
- out_dir = @base_dir + @options.op_dir
- index_file = out_dir + SEARCH_INDEX_FILE
-
- FileUtils.mkdir_p index_file.dirname, :verbose => $DEBUG_RDOC
-
- index_file.open 'w', 0644 do |io|
- io.set_encoding Encoding::UTF_8
- io.write 'var search_data = '
-
- JSON.dump data, io, 0
- end
- unless ENV['SOURCE_DATE_EPOCH'].nil?
- index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
- end
-
- Dir.chdir @template_dir do
- Dir['**/*.js'].each do |source|
- dest = File.join out_dir, source
-
- FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
- end
- end
- end
-
- ##
- # Compress the search_index.js file using gzip
-
- def generate_gzipped
- return if @options.dry_run or not defined?(Zlib)
-
- debug_msg "Compressing generated JSON index"
- out_dir = @base_dir + @options.op_dir
-
- search_index_file = out_dir + SEARCH_INDEX_FILE
- outfile = out_dir + "#{search_index_file}.gz"
-
- debug_msg "Reading the JSON index file from %s" % search_index_file
- search_index = search_index_file.read(mode: 'r:utf-8')
-
- debug_msg "Writing gzipped search index to %s" % outfile
-
- Zlib::GzipWriter.open(outfile) do |gz|
- gz.mtime = File.mtime(search_index_file)
- gz.orig_name = search_index_file.basename.to_s
- gz.write search_index
- gz.close
- end
-
- # GZip the rest of the js files
- Dir.chdir @template_dir do
- Dir['**/*.js'].each do |source|
- dest = out_dir + source
- outfile = out_dir + "#{dest}.gz"
-
- debug_msg "Reading the original js file from %s" % dest
- data = dest.read
-
- debug_msg "Writing gzipped file to %s" % outfile
-
- Zlib::GzipWriter.open(outfile) do |gz|
- gz.mtime = File.mtime(dest)
- gz.orig_name = dest.basename.to_s
- gz.write data
- gz.close
- end
- end
- end
- end
-
- ##
- # Adds classes and modules to the index
-
- def index_classes
- debug_msg " generating class search index"
-
- documented = @classes.uniq.select do |klass|
- klass.document_self_or_methods
- end
-
- documented.each do |klass|
- debug_msg " #{klass.full_name}"
- record = klass.search_record
- @index[:searchIndex] << search_string(record.shift)
- @index[:longSearchIndex] << search_string(record.shift)
- @index[:info] << record
- end
- end
-
- ##
- # Adds methods to the index
-
- def index_methods
- debug_msg " generating method search index"
-
- list = @classes.uniq.map do |klass|
- klass.method_list
- end.flatten.sort_by do |method|
- [method.name, method.parent.full_name]
- end
-
- list.each do |method|
- debug_msg " #{method.full_name}"
- record = method.search_record
- @index[:searchIndex] << "#{search_string record.shift}()"
- @index[:longSearchIndex] << "#{search_string record.shift}()"
- @index[:info] << record
- end
- end
-
- ##
- # Adds pages to the index
-
- def index_pages
- debug_msg " generating pages search index"
-
- pages = @files.select do |file|
- file.text?
- end
-
- pages.each do |page|
- debug_msg " #{page.page_name}"
- record = page.search_record
- @index[:searchIndex] << search_string(record.shift)
- @index[:longSearchIndex] << ''
- record.shift
- @index[:info] << record
- end
- end
-
- ##
- # The directory classes are written to
-
- def class_dir
- @parent_generator.class_dir
- end
-
- ##
- # The directory files are written to
-
- def file_dir
- @parent_generator.file_dir
- end
-
- def reset files, classes # :nodoc:
- @files = files
- @classes = classes
-
- @index = {
- :searchIndex => [],
- :longSearchIndex => [],
- :info => []
- }
- end
-
- ##
- # Removes whitespace and downcases +string+
-
- def search_string string
- string.downcase.gsub(/\s/, '')
- end
-
-end
diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb
deleted file mode 100644
index b54265717c..0000000000
--- a/lib/rdoc/generator/markup.rb
+++ /dev/null
@@ -1,160 +0,0 @@
-# frozen_string_literal: true
-##
-# Handle common RDoc::Markup tasks for various CodeObjects
-#
-# This module is loaded by generators. It allows RDoc's CodeObject tree to
-# avoid loading generator code to improve startup time for +ri+.
-
-module RDoc::Generator::Markup
-
- ##
- # Generates a relative URL from this object's path to +target_path+
-
- def aref_to(target_path)
- RDoc::Markup::ToHtml.gen_relative_url path, target_path
- end
-
- ##
- # Generates a relative URL from +from_path+ to this object's path
-
- def as_href(from_path)
- RDoc::Markup::ToHtml.gen_relative_url from_path, path
- end
-
- ##
- # Handy wrapper for marking up this object's comment
-
- def description
- markup @comment
- end
-
- ##
- # Creates an RDoc::Markup::ToHtmlCrossref formatter
-
- def formatter
- return @formatter if defined? @formatter
-
- options = @store.rdoc.options
- this = RDoc::Context === self ? self : @parent
-
- @formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this
- @formatter.code_object = self
- @formatter
- end
-
- ##
- # Build a webcvs URL starting for the given +url+ with +full_path+ appended
- # as the destination path. If +url+ contains '%s' +full_path+ will be
- # will replace the %s using sprintf on the +url+.
-
- def cvs_url(url, full_path)
- if /%s/ =~ url then
- sprintf url, full_path
- else
- url + full_path
- end
- end
-
-end
-
-class RDoc::CodeObject
-
- include RDoc::Generator::Markup
-
-end
-
-class RDoc::MethodAttr
-
- ##
- # Prepend +src+ with line numbers. Relies on the first line of a source
- # code listing having:
- #
- # # File xxxxx, line dddd
- #
- # If it has this comment then line numbers are added to +src+ and the <tt>,
- # line dddd</tt> portion of the comment is removed.
-
- def add_line_numbers(src)
- return unless src.sub!(/\A(.*)(, line (\d+))/, '\1')
- first = $3.to_i - 1
- last = first + src.count("\n")
- size = last.to_s.length
-
- line = first
- src.gsub!(/^/) do
- res = if line == first then
- " " * (size + 1)
- else
- "<span class=\"line-num\">%2$*1$d</span> " % [size, line]
- end
-
- line += 1
- res
- end
- end
-
- ##
- # Turns the method's token stream into HTML.
- #
- # Prepends line numbers if +options.line_numbers+ is true.
-
- def markup_code
- return '' unless @token_stream
-
- src = RDoc::TokenStream.to_html @token_stream
-
- # dedent the source
- indent = src.length
- lines = src.lines.to_a
- lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment
- lines.each do |line|
- if line =~ /^ *(?=\S)/
- n = $~.end(0)
- indent = n if n < indent
- break if n == 0
- end
- end
- src.gsub!(/^#{' ' * indent}/, '') if indent > 0
-
- add_line_numbers(src) if options.line_numbers
-
- src
- end
-
-end
-
-class RDoc::ClassModule
-
- ##
- # Handy wrapper for marking up this class or module's comment
-
- def description
- markup @comment_location
- end
-
-end
-
-class RDoc::Context::Section
-
- include RDoc::Generator::Markup
-
-end
-
-class RDoc::TopLevel
-
- ##
- # Returns a URL for this source file on some web repository. Use the -W
- # command line option to set.
-
- def cvs_url
- url = @store.rdoc.options.webcvs
-
- if /%s/ =~ url then
- url % @relative_name
- else
- url + @relative_name
- end
- end
-
-end
-
diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb
deleted file mode 100644
index bee1133b07..0000000000
--- a/lib/rdoc/generator/pot.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-# frozen_string_literal: true
-##
-# Generates a POT file.
-#
-# Here is a translator work flow with the generator.
-#
-# == Create .pot
-#
-# You create .pot file by pot formatter:
-#
-# % rdoc --format pot
-#
-# It generates doc/rdoc.pot.
-#
-# == Create .po
-#
-# You create .po file from doc/rdoc.pot. This operation is needed only
-# the first time. This work flow assumes that you are a translator
-# for Japanese.
-#
-# You create locale/ja/rdoc.po from doc/rdoc.pot. You can use msginit
-# provided by GNU gettext or rmsginit provided by gettext gem. This
-# work flow uses gettext gem because it is more portable than GNU
-# gettext for Rubyists. Gettext gem is implemented by pure Ruby.
-#
-# % gem install gettext
-# % mkdir -p locale/ja
-# % rmsginit --input doc/rdoc.pot --output locale/ja/rdoc.po --locale ja
-#
-# Translate messages in .po
-#
-# You translate messages in .po by a PO file editor. po-mode.el exists
-# for Emacs users. There are some GUI tools such as GTranslator.
-# There are some Web services such as POEditor and Tansifex. You can
-# edit by your favorite text editor because .po is a text file.
-# Generate localized documentation
-#
-# You can generate localized documentation with locale/ja/rdoc.po:
-#
-# % rdoc --locale ja
-#
-# You can find documentation in Japanese in doc/. Yay!
-#
-# == Update translation
-#
-# You need to update translation when your application is added or
-# modified messages.
-#
-# You can update .po by the following command lines:
-#
-# % rdoc --format pot
-# % rmsgmerge --update locale/ja/rdoc.po doc/rdoc.pot
-#
-# You edit locale/ja/rdoc.po to translate new messages.
-
-class RDoc::Generator::POT
-
- RDoc::RDoc.add_generator self
-
- ##
- # Description of this generator
-
- DESCRIPTION = 'creates .pot file'
-
- ##
- # Set up a new .pot generator
-
- def initialize store, options #:not-new:
- @options = options
- @store = store
- end
-
- ##
- # Writes .pot to disk.
-
- def generate
- po = extract_messages
- pot_path = 'rdoc.pot'
- File.open(pot_path, "w") do |pot|
- pot.print(po.to_s)
- end
- end
-
- def class_dir
- nil
- end
-
- private
- def extract_messages
- extractor = MessageExtractor.new(@store)
- extractor.extract
- end
-
- require_relative 'pot/message_extractor'
- require_relative 'pot/po'
- require_relative 'pot/po_entry'
-
-end
diff --git a/lib/rdoc/generator/pot/message_extractor.rb b/lib/rdoc/generator/pot/message_extractor.rb
deleted file mode 100644
index 313dfd2dc7..0000000000
--- a/lib/rdoc/generator/pot/message_extractor.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# frozen_string_literal: true
-##
-# Extracts message from RDoc::Store
-
-class RDoc::Generator::POT::MessageExtractor
-
- ##
- # Creates a message extractor for +store+.
-
- def initialize store
- @store = store
- @po = RDoc::Generator::POT::PO.new
- end
-
- ##
- # Extracts messages from +store+, stores them into
- # RDoc::Generator::POT::PO and returns it.
-
- def extract
- @store.all_classes_and_modules.each do |klass|
- extract_from_klass(klass)
- end
- @po
- end
-
- private
-
- def extract_from_klass klass
- extract_text(klass.comment_location, klass.full_name)
-
- klass.each_section do |section, constants, attributes|
- extract_text(section.title ,"#{klass.full_name}: section title")
- section.comments.each do |comment|
- extract_text(comment, "#{klass.full_name}: #{section.title}")
- end
- end
-
- klass.each_constant do |constant|
- extract_text(constant.comment, constant.full_name)
- end
-
- klass.each_attribute do |attribute|
- extract_text(attribute.comment, attribute.full_name)
- end
-
- klass.each_method do |method|
- extract_text(method.comment, method.full_name)
- end
- end
-
- def extract_text text, comment, location = nil
- return if text.nil?
-
- options = {
- :extracted_comment => comment,
- :references => [location].compact,
- }
- i18n_text = RDoc::I18n::Text.new(text)
- i18n_text.extract_messages do |part|
- @po.add(entry(part[:paragraph], options))
- end
- end
-
- def entry msgid, options
- RDoc::Generator::POT::POEntry.new(msgid, options)
- end
-
-end
diff --git a/lib/rdoc/generator/pot/po.rb b/lib/rdoc/generator/pot/po.rb
deleted file mode 100644
index 37d45e5258..0000000000
--- a/lib/rdoc/generator/pot/po.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-##
-# Generates a PO format text
-
-class RDoc::Generator::POT::PO
-
- ##
- # Creates an object that represents PO format.
-
- def initialize
- @entries = {}
- add_header
- end
-
- ##
- # Adds a PO entry to the PO.
-
- def add entry
- existing_entry = @entries[entry.msgid]
- if existing_entry
- entry = existing_entry.merge(entry)
- end
- @entries[entry.msgid] = entry
- end
-
- ##
- # Returns PO format text for the PO.
-
- def to_s
- po = ''
- sort_entries.each do |entry|
- po += "\n" unless po.empty?
- po += entry.to_s
- end
- po
- end
-
- private
-
- def add_header
- add(header_entry)
- end
-
- def header_entry
- comment = <<-COMMENT
-SOME DESCRIPTIVE TITLE.
-Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-This file is distributed under the same license as the PACKAGE package.
-FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
- COMMENT
-
- content = <<-CONTENT
-Project-Id-Version: PACKAGE VERSEION
-Report-Msgid-Bugs-To:
-PO-Revision-Date: YEAR-MO_DA HO:MI+ZONE
-Last-Translator: FULL NAME <EMAIL@ADDRESS>
-Language-Team: LANGUAGE <LL@li.org>
-Language:
-MIME-Version: 1.0
-Content-Type: text/plain; charset=CHARSET
-Content-Transfer-Encoding: 8bit
-Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
- CONTENT
-
- options = {
- :msgstr => content,
- :translator_comment => comment,
- :flags => ['fuzzy'],
- }
- RDoc::Generator::POT::POEntry.new('', options)
- end
-
- def sort_entries
- headers, messages = @entries.values.partition do |entry|
- entry.msgid.empty?
- end
- # TODO: sort by location
- sorted_messages = messages.sort_by do |entry|
- entry.msgid
- end
- headers + sorted_messages
- end
-
-end
diff --git a/lib/rdoc/generator/pot/po_entry.rb b/lib/rdoc/generator/pot/po_entry.rb
deleted file mode 100644
index 3c278826f4..0000000000
--- a/lib/rdoc/generator/pot/po_entry.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-# frozen_string_literal: true
-##
-# A PO entry in PO
-
-class RDoc::Generator::POT::POEntry
-
- # The msgid content
- attr_reader :msgid
-
- # The msgstr content
- attr_reader :msgstr
-
- # The comment content created by translator (PO editor)
- attr_reader :translator_comment
-
- # The comment content extracted from source file
- attr_reader :extracted_comment
-
- # The locations where the PO entry is extracted
- attr_reader :references
-
- # The flags of the PO entry
- attr_reader :flags
-
- ##
- # Creates a PO entry for +msgid+. Other valus can be specified by
- # +options+.
-
- def initialize msgid, options = {}
- @msgid = msgid
- @msgstr = options[:msgstr] || ""
- @translator_comment = options[:translator_comment]
- @extracted_comment = options[:extracted_comment]
- @references = options[:references] || []
- @flags = options[:flags] || []
- end
-
- ##
- # Returns the PO entry in PO format.
-
- def to_s
- entry = ''
- entry += format_translator_comment
- entry += format_extracted_comment
- entry += format_references
- entry += format_flags
- entry += <<-ENTRY
-msgid #{format_message(@msgid)}
-msgstr #{format_message(@msgstr)}
- ENTRY
- end
-
- ##
- # Merges the PO entry with +other_entry+.
-
- def merge other_entry
- options = {
- :extracted_comment => merge_string(@extracted_comment,
- other_entry.extracted_comment),
- :translator_comment => merge_string(@translator_comment,
- other_entry.translator_comment),
- :references => merge_array(@references,
- other_entry.references),
- :flags => merge_array(@flags,
- other_entry.flags),
- }
- self.class.new(@msgid, options)
- end
-
- private
-
- def format_comment mark, comment
- return '' unless comment
- return '' if comment.empty?
-
- formatted_comment = ''
- comment.each_line do |line|
- formatted_comment += "#{mark} #{line}"
- end
- formatted_comment += "\n" unless formatted_comment.end_with?("\n")
- formatted_comment
- end
-
- def format_translator_comment
- format_comment('#', @translator_comment)
- end
-
- def format_extracted_comment
- format_comment('#.', @extracted_comment)
- end
-
- def format_references
- return '' if @references.empty?
-
- formatted_references = ''
- @references.sort.each do |file, line|
- formatted_references += "\#: #{file}:#{line}\n"
- end
- formatted_references
- end
-
- def format_flags
- return '' if @flags.empty?
-
- formatted_flags = flags.join(",")
- "\#, #{formatted_flags}\n"
- end
-
- def format_message message
- return "\"#{escape(message)}\"" unless message.include?("\n")
-
- formatted_message = '""'
- message.each_line do |line|
- formatted_message += "\n"
- formatted_message += "\"#{escape(line)}\""
- end
- formatted_message
- end
-
- def escape string
- string.gsub(/["\\\t\n]/) do |special_character|
- case special_character
- when "\t"
- "\\t"
- when "\n"
- "\\n"
- else
- "\\#{special_character}"
- end
- end
- end
-
- def merge_string string1, string2
- [string1, string2].compact.join("\n")
- end
-
- def merge_array array1, array2
- (array1 + array2).uniq
- end
-
-end
diff --git a/lib/rdoc/generator/ri.rb b/lib/rdoc/generator/ri.rb
deleted file mode 100644
index 0eef1d03f5..0000000000
--- a/lib/rdoc/generator/ri.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-##
-# Generates ri data files
-
-class RDoc::Generator::RI
-
- RDoc::RDoc.add_generator self
-
- ##
- # Description of this generator
-
- DESCRIPTION = 'creates ri data files'
-
- ##
- # Set up a new ri generator
-
- def initialize store, options #:not-new:
- @options = options
- @store = store
- @store.path = '.'
- end
-
- ##
- # Writes the parsed data store to disk for use by ri.
-
- def generate
- @store.save
- end
-
-end
-
diff --git a/lib/rdoc/generator/template/darkfish/_footer.rhtml b/lib/rdoc/generator/template/darkfish/_footer.rhtml
deleted file mode 100644
index 9791b42901..0000000000
--- a/lib/rdoc/generator/template/darkfish/_footer.rhtml
+++ /dev/null
@@ -1,5 +0,0 @@
-<footer id="validator-badges" role="contentinfo">
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> <%= RDoc::VERSION %>.
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
-</footer>
diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml
deleted file mode 100644
index d5aed3e9ef..0000000000
--- a/lib/rdoc/generator/template/darkfish/_head.rhtml
+++ /dev/null
@@ -1,20 +0,0 @@
-<meta charset="<%= @options.charset %>">
-
-<title><%= h @title %></title>
-
-<script type="text/javascript">
- var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
- var index_rel_prefix = "<%= h rel_prefix %>/";
-</script>
-
-<script src="<%= h asset_rel_prefix %>/js/navigation.js" defer></script>
-<script src="<%= h asset_rel_prefix %>/js/search.js" defer></script>
-<script src="<%= h asset_rel_prefix %>/js/search_index.js" defer></script>
-<script src="<%= h asset_rel_prefix %>/js/searcher.js" defer></script>
-<script src="<%= h asset_rel_prefix %>/js/darkfish.js" defer></script>
-
-<link href="<%= h asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
-<link href="<%= h asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
-<%- @options.template_stylesheets.each do |stylesheet| -%>
-<link href="<%= h asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml
deleted file mode 100644
index 22a12d9e95..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml
+++ /dev/null
@@ -1,19 +0,0 @@
-<%- if !svninfo.empty? then %>
-<div id="file-svninfo-section" class="nav-section">
- <h3>VCS Info</h3>
-
- <div class="section-body">
- <dl class="svninfo">
- <dt>Rev
- <dd><%= svninfo[:rev] %>
-
- <dt>Last Checked In
- <dd><%= svninfo[:commitdate].strftime('%Y-%m-%d %H:%M:%S') %>
- (<%= svninfo[:commitdelta] %> ago)
-
- <dt>Checked in by
- <dd><%= svninfo[:committer] %>
- </dl>
- </div>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml
deleted file mode 100644
index d3d8da4017..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml
+++ /dev/null
@@ -1,33 +0,0 @@
-<div id="classindex-section" class="nav-section">
- <h3>Class and Module Index</h3>
-
- <%-
- all_classes = @classes.group_by do |klass|
- klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
- end.delete_if do |_, klasses|
- !klasses.any?(&:display?)
- end
- link = proc do |index_klass, display = index_klass.display?|
- if display
- -%><code><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.name %></a></code><%-
- else
- -%><code><%= index_klass.name %></code><%-
- end
- end
- if top = all_classes[nil]
- solo = top.one? {|klass| klass.display?}
- traverse = proc do |klasses| -%>
- <ul class="link-list">
- <%- klasses.each do |index_klass| -%>
- <%- if children = all_classes[index_klass.full_name] -%>
- <li><details<% if solo; solo = false %> open<% end %>><summary><% link.call(index_klass) %></summary>
- <%- traverse.call(children) -%>
- </ul></details>
- <%- elsif index_klass.display? -%>
- <li><% link.call(index_klass, true) %>
- <%- end -%>
- <%- end -%>
- <%- end -%>
- <%- traverse.call(top) -%>
- <%- end -%>
-</div>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml
deleted file mode 100644
index 7602076c96..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml
+++ /dev/null
@@ -1,15 +0,0 @@
-<%- unless klass.extends.empty? then %>
-<div id="extends-section" class="nav-section">
- <h3>Extended With Modules</h3>
-
- <ul class="link-list">
- <%- klass.each_extend do |ext| -%>
- <%- unless String === ext.module then -%>
- <li><a class="extend" href="<%= klass.aref_to ext.module.path %>"><%= ext.module.full_name %></a>
- <%- else -%>
- <li><span class="extend"><%= ext.name %></span>
- <%- end -%>
- <%- end -%>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml
deleted file mode 100644
index 74869a4b51..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml
+++ /dev/null
@@ -1,9 +0,0 @@
-<div id="file-list-section" class="nav-section">
- <h3>Defined In</h3>
-
- <ul>
-<%- klass.in_files.each do |tl| -%>
- <li><%= h tl.relative_name %>
-<%- end -%>
- </ul>
-</div>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml
deleted file mode 100644
index 5b600e5975..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml
+++ /dev/null
@@ -1,15 +0,0 @@
-<%- unless klass.includes.empty? then %>
-<div id="includes-section" class="nav-section">
- <h3>Included Modules</h3>
-
- <ul class="link-list">
- <%- klass.each_include do |inc| -%>
- <%- unless String === inc.module then -%>
- <li><a class="include" href="<%= klass.aref_to inc.module.path %>"><%= inc.module.full_name %></a>
- <%- else -%>
- <li><span class="include"><%= inc.name %></span>
- <%- end -%>
- <%- end -%>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml
deleted file mode 100644
index faed7e0a94..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml
+++ /dev/null
@@ -1,15 +0,0 @@
-<div id="home-section" class="nav-section">
- <h3>Documentation</h3>
-
- <ul>
- <%- installed.each do |name, href, exists, type, _| -%>
- <%- next if type == :extra -%>
- <li class="folder">
- <%- if exists then -%>
- <a href="<%= href %>"><%= h name %></a>
- <%- else -%>
- <%= h name %>
- <%- end -%>
- <%- end -%>
- </ul>
-</div>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml
deleted file mode 100644
index 5b4c295bed..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml
+++ /dev/null
@@ -1,12 +0,0 @@
-<%- unless klass.method_list.empty? then %>
-<!-- Method Quickref -->
-<div id="method-list-section" class="nav-section">
- <h3>Methods</h3>
-
- <ul class="link-list" role="directory">
- <%- klass.each_method do |meth| -%>
- <li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= meth.singleton ? '::' : '#' %><%= h meth.name -%></a>
- <%- end -%>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml
deleted file mode 100644
index d7f330840a..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml
+++ /dev/null
@@ -1,11 +0,0 @@
-<div id="home-section" role="region" title="Quick navigation" class="nav-section">
- <h2>
- <a href="<%= rel_prefix %>/index.html" rel="home">Home</a>
- </h2>
-
- <div id="table-of-contents-navigation">
- <a href="<%= rel_prefix %>/table_of_contents.html#pages">Pages</a>
- <a href="<%= rel_prefix %>/table_of_contents.html#classes">Classes</a>
- <a href="<%= rel_prefix %>/table_of_contents.html#methods">Methods</a>
- </div>
-</div>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml
deleted file mode 100644
index 3f68f0c0dc..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml
+++ /dev/null
@@ -1,32 +0,0 @@
-<%- simple_files = @files.select { |f| f.text? } %>
-<%- if defined?(current) -%>
- <%- dir = current.full_name[%r{\A[^/]+(?=/)}] || current.page_name -%>
-<%- end -%>
-<%- unless simple_files.empty? then -%>
-<div id="fileindex-section" class="nav-section">
- <h3>Pages</h3>
-
- <ul class="link-list">
- <%- simple_files.group_by do |f| -%>
- <%- f.full_name[%r{\A[^/]+(?=/)}] || f.page_name -%>
- <%- end.each do |n, files| -%>
- <%- f = files.shift -%>
- <%- if files.empty? -%>
- <li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
- <%- next -%>
- <%- end -%>
- <li><details<% if dir == n %> open<% end %>><summary><%
- if n == f.page_name
- %><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h n %></a><%
- else
- %><%= h n %><% files.unshift(f)
- end %></summary>
- <ul class="link-list">
- <%- files.each do |f| -%>
- <li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
- <%- end -%>
- </ul></details>
- <%- end -%>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml
deleted file mode 100644
index 1420da3201..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml
+++ /dev/null
@@ -1,11 +0,0 @@
-<%- if klass.type == 'class' then %>
-<div id="parent-class-section" class="nav-section">
- <h3>Parent</h3>
-
- <%- if klass.superclass and not String === klass.superclass then -%>
- <p class="link"><a href="<%= klass.aref_to klass.superclass.path %>"><%= klass.superclass.full_name %></a>
- <%- else -%>
- <p class="link"><%= klass.superclass %>
- <%- end -%>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml
deleted file mode 100644
index 9c49b31376..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml
+++ /dev/null
@@ -1,14 +0,0 @@
-<div id="search-section" role="search" class="project-section initially-hidden">
- <form action="#" method="get" accept-charset="utf-8">
- <div id="search-field-wrapper">
- <input id="search-field" role="combobox" aria-label="Search"
- aria-autocomplete="list" aria-controls="search-results"
- type="text" name="search" placeholder="Search" spellcheck="false"
- title="Type to search, Up and Down to navigate, Enter to load">
- </div>
-
- <ul id="search-results" aria-label="Search Results"
- aria-busy="false" aria-expanded="false"
- aria-atomic="false" class="initially-hidden"></ul>
- </form>
-</div>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml
deleted file mode 100644
index 6dcd2ae81f..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml
+++ /dev/null
@@ -1,11 +0,0 @@
-<%- unless klass.sections.length == 1 then %>
-<div id="sections-section" class="nav-section">
- <h3>Sections</h3>
-
- <ul class="link-list" role="directory">
- <%- klass.sort_sections.each do |section| -%>
- <li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
- <%- end -%>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml
deleted file mode 100644
index b1e047b5f7..0000000000
--- a/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml
+++ /dev/null
@@ -1,39 +0,0 @@
-<%- comment = if current.respond_to? :comment_location then
- current.comment_location
- else
- current.comment
- end
- table = current.parse(comment).table_of_contents.dup
-
- if table.length > 1 then %>
-<div class="nav-section">
- <h3>Table of Contents</h3>
-
- <%- display_link = proc do |heading| -%>
- <a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
- <%- end -%>
-
- <%- list_siblings = proc do -%>
- <%- level = table.first&.level -%>
- <%- while table.first && table.first.level >= level -%>
- <%- heading = table.shift -%>
- <%- if table.first.nil? || table.first.level <= heading.level -%>
- <li><% display_link.call heading -%>
- <%- else -%>
- <li>
- <details open>
- <summary><%- display_link.call heading -%></summary>
- <ul class="link-list" role="directory">
- <% list_siblings.call %>
- </ul>
- </details>
- </li>
- <%- end -%>
- <%- end -%>
- <%- end -%>
-
- <ul class="link-list" role="directory">
- <% list_siblings.call %>
- </ul>
-</div>
-<%- end -%>
diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml
deleted file mode 100644
index 97d175dddc..0000000000
--- a/lib/rdoc/generator/template/darkfish/class.rhtml
+++ /dev/null
@@ -1,174 +0,0 @@
-<body id="top" role="document" class="<%= klass.type %>">
-<nav role="navigation">
- <div id="project-navigation">
- <%= render '_sidebar_navigation.rhtml' %>
- <%= render '_sidebar_search.rhtml' %>
- </div>
-
- <%= render '_sidebar_table_of_contents.rhtml' %>
-
- <div id="class-metadata">
- <%= render '_sidebar_sections.rhtml' %>
- <%= render '_sidebar_parent.rhtml' %>
- <%= render '_sidebar_includes.rhtml' %>
- <%= render '_sidebar_extends.rhtml' %>
- <%= render '_sidebar_methods.rhtml' %>
- </div>
-</nav>
-
-<main role="main" aria-labelledby="<%=h klass.aref %>">
- <h1 id="<%=h klass.aref %>" class="<%= klass.type %>">
- <%= klass.type %> <%= klass.full_name %>
- </h1>
-
- <section class="description">
- <%= klass.description %>
- </section>
-
- <%- klass.each_section do |section, constants, attributes| -%>
- <section id="<%= section.aref %>" class="documentation-section">
- <%- if section.title then -%>
- <header class="documentation-section-title">
- <h2>
- <%= section.title %>
- </h2>
- <span class="section-click-top">
- <a href="#top">&uarr; top</a>
- </span>
- </header>
- <%- end -%>
-
- <%- if section.comment then -%>
- <div>
- <%= section.description %>
- </div>
- <%- end -%>
-
- <%- unless constants.empty? then -%>
- <section class="constants-list">
- <header>
- <h3>Constants</h3>
- </header>
- <dl>
- <%- constants.each do |const| -%>
- <dt id="<%= const.name %>"><%= const.name %>
- <%- if const.comment then -%>
- <dd><%= const.description.strip %>
- <%- else -%>
- <dd class="missing-docs">(Not documented)
- <%- end -%>
- <%- end -%>
- </dl>
- </section>
- <%- end -%>
-
- <%- unless attributes.empty? then -%>
- <section class="attribute-method-details" class="method-section">
- <header>
- <h3>Attributes</h3>
- </header>
-
- <%- attributes.each do |attrib| -%>
- <div id="<%= attrib.aref %>" class="method-detail">
- <div class="method-heading attribute-method-heading">
- <span class="method-name"><%= h attrib.name %></span><span
- class="attribute-access-type">[<%= attrib.rw %>]</span>
- </div>
-
- <div class="method-description">
- <%- if attrib.comment then -%>
- <%= attrib.description.strip %>
- <%- else -%>
- <p class="missing-docs">(Not documented)
- <%- end -%>
- </div>
- </div>
- <%- end -%>
- </section>
- <%- end -%>
-
- <%- klass.methods_by_type(section).each do |type, visibilities|
- next if visibilities.empty?
- visibilities.each do |visibility, methods|
- next if methods.empty? %>
- <section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section">
- <header>
- <h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
- </header>
-
- <%- methods.each do |method| -%>
- <div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
- <div class="method-header">
- <%- if (call_seq = method.call_seq) then -%>
- <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
- <div class="method-heading">
- <span class="method-callseq">
- <%= h(call_seq.strip.
- gsub( /^\w+\./m, '')).
- gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
- </span>
- <%- if i == 0 and method.token_stream then -%>
- <span class="method-click-advice">click to toggle source</span>
- <%- end -%>
- </div>
- <%- end -%>
- <%- else -%>
- <div class="method-heading">
- <span class="method-name"><%= h method.name %></span><span
- class="method-args"><%= h method.param_seq %></span>
- <%- if method.token_stream then -%>
- <span class="method-click-advice">click to toggle source</span>
- <%- end -%>
- </div>
- <%- end -%>
- </div>
-
- <div class="method-description">
- <%- if method.comment then -%>
- <%= method.description.strip %>
- <%- else -%>
- <p class="missing-docs">(Not documented)
- <%- end -%>
- <%- if method.calls_super then -%>
- <div class="method-calls-super">
- Calls superclass method
- <%=
- method.superclass_method ?
- method.formatter.link(method.superclass_method.full_name, method.superclass_method.full_name) : nil
- %>
- </div>
- <%- end -%>
-
- <%- if method.token_stream then -%>
- <div class="method-source-code" id="<%= method.html_name %>-source">
- <pre><%= method.markup_code %></pre>
- </div>
- <%- end -%>
- </div>
-
- <%- unless method.aliases.empty? then -%>
- <div class="aliases">
- Also aliased as: <%= method.aliases.map do |aka|
- if aka.parent then # HACK lib/rexml/encodings
- %{<a href="#{klass.aref_to aka.path}">#{h aka.name}</a>}
- else
- h aka.name
- end
- end.join ", " %>
- </div>
- <%- end -%>
-
- <%- if method.is_alias_for then -%>
- <div class="aliases">
- Alias for: <a href="<%= klass.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
- </div>
- <%- end -%>
- </div>
-
- <%- end -%>
- </section>
- <%- end
- end %>
- </section>
-<%- end -%>
-</main>
diff --git a/lib/rdoc/generator/template/darkfish/css/fonts.css b/lib/rdoc/generator/template/darkfish/css/fonts.css
deleted file mode 100644
index 57302b5183..0000000000
--- a/lib/rdoc/generator/template/darkfish/css/fonts.css
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
- * with Reserved Font Name "Source". All Rights Reserved. Source is a
- * trademark of Adobe Systems Incorporated in the United States and/or other
- * countries.
- *
- * This Font Software is licensed under the SIL Open Font License, Version
- * 1.1.
- *
- * This license is copied below, and is also available with a FAQ at:
- * http://scripts.sil.org/OFL
- */
-
-@font-face {
- font-family: "Source Code Pro";
- font-style: normal;
- font-weight: 400;
- src: local("Source Code Pro"),
- local("SourceCodePro-Regular"),
- url("../fonts/SourceCodePro-Regular.ttf") format("truetype");
-}
-
-@font-face {
- font-family: "Source Code Pro";
- font-style: normal;
- font-weight: 700;
- src: local("Source Code Pro Bold"),
- local("SourceCodePro-Bold"),
- url("../fonts/SourceCodePro-Bold.ttf") format("truetype");
-}
-
-/*
- * Copyright (c) 2010, Åukasz Dziedzic (dziedzic@typoland.com),
- * with Reserved Font Name Lato.
- *
- * This Font Software is licensed under the SIL Open Font License, Version
- * 1.1.
- *
- * This license is copied below, and is also available with a FAQ at:
- * http://scripts.sil.org/OFL
- */
-
-@font-face {
- font-family: "Lato";
- font-style: normal;
- font-weight: 300;
- src: local("Lato Light"),
- local("Lato-Light"),
- url("../fonts/Lato-Light.ttf") format("truetype");
-}
-
-@font-face {
- font-family: "Lato";
- font-style: italic;
- font-weight: 300;
- src: local("Lato Light Italic"),
- local("Lato-LightItalic"),
- url("../fonts/Lato-LightItalic.ttf") format("truetype");
-}
-
-@font-face {
- font-family: "Lato";
- font-style: normal;
- font-weight: 700;
- src: local("Lato Regular"),
- local("Lato-Regular"),
- url("../fonts/Lato-Regular.ttf") format("truetype");
-}
-
-@font-face {
- font-family: "Lato";
- font-style: italic;
- font-weight: 700;
- src: local("Lato Italic"),
- local("Lato-Italic"),
- url("../fonts/Lato-RegularItalic.ttf") format("truetype");
-}
-
-/*
- * -----------------------------------------------------------
- * SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
- * -----------------------------------------------------------
- *
- * PREAMBLE
- * The goals of the Open Font License (OFL) are to stimulate worldwide
- * development of collaborative font projects, to support the font creation
- * efforts of academic and linguistic communities, and to provide a free and
- * open framework in which fonts may be shared and improved in partnership
- * with others.
- *
- * The OFL allows the licensed fonts to be used, studied, modified and
- * redistributed freely as long as they are not sold by themselves. The
- * fonts, including any derivative works, can be bundled, embedded,
- * redistributed and/or sold with any software provided that any reserved
- * names are not used by derivative works. The fonts and derivatives,
- * however, cannot be released under any other type of license. The
- * requirement for fonts to remain under this license does not apply
- * to any document created using the fonts or their derivatives.
- *
- * DEFINITIONS
- * "Font Software" refers to the set of files released by the Copyright
- * Holder(s) under this license and clearly marked as such. This may
- * include source files, build scripts and documentation.
- *
- * "Reserved Font Name" refers to any names specified as such after the
- * copyright statement(s).
- *
- * "Original Version" refers to the collection of Font Software components as
- * distributed by the Copyright Holder(s).
- *
- * "Modified Version" refers to any derivative made by adding to, deleting,
- * or substituting -- in part or in whole -- any of the components of the
- * Original Version, by changing formats or by porting the Font Software to a
- * new environment.
- *
- * "Author" refers to any designer, engineer, programmer, technical
- * writer or other person who contributed to the Font Software.
- *
- * PERMISSION & CONDITIONS
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of the Font Software, to use, study, copy, merge, embed, modify,
- * redistribute, and sell modified and unmodified copies of the Font
- * Software, subject to the following conditions:
- *
- * 1) Neither the Font Software nor any of its individual components,
- * in Original or Modified Versions, may be sold by itself.
- *
- * 2) Original or Modified Versions of the Font Software may be bundled,
- * redistributed and/or sold with any software, provided that each copy
- * contains the above copyright notice and this license. These can be
- * included either as stand-alone text files, human-readable headers or
- * in the appropriate machine-readable metadata fields within text or
- * binary files as long as those fields can be easily viewed by the user.
- *
- * 3) No Modified Version of the Font Software may use the Reserved Font
- * Name(s) unless explicit written permission is granted by the corresponding
- * Copyright Holder. This restriction only applies to the primary font name as
- * presented to the users.
- *
- * 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
- * Software shall not be used to promote, endorse or advertise any
- * Modified Version, except to acknowledge the contribution(s) of the
- * Copyright Holder(s) and the Author(s) or with their explicit written
- * permission.
- *
- * 5) The Font Software, modified or unmodified, in part or in whole,
- * must be distributed entirely under this license, and must not be
- * distributed under any other license. The requirement for fonts to
- * remain under this license does not apply to any document created
- * using the Font Software.
- *
- * TERMINATION
- * This license becomes null and void if any of the above conditions are
- * not met.
- *
- * DISCLAIMER
- * THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
- * OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
- * DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
- * OTHER DEALINGS IN THE FONT SOFTWARE.
- */
-
diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css
deleted file mode 100644
index 1be815f503..0000000000
--- a/lib/rdoc/generator/template/darkfish/css/rdoc.css
+++ /dev/null
@@ -1,662 +0,0 @@
-/*
- * "Darkfish" Rdoc CSS
- * $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $
- *
- * Author: Michael Granger <ged@FaerieMUD.org>
- *
- */
-
-/* vim: ft=css et sw=2 ts=2 sts=2 */
-/* Base Green is: #6C8C22 */
-
-.hide { display: none !important; }
-
-* { padding: 0; margin: 0; }
-
-body {
- background: #fafafa;
- font-family: Lato, sans-serif;
- font-weight: 300;
-}
-
-h1 span,
-h2 span,
-h3 span,
-h4 span,
-h5 span,
-h6 span {
- position: relative;
-
- display: none;
- padding-left: 1em;
- line-height: 0;
- vertical-align: baseline;
- font-size: 10px;
-}
-
-h1 span { top: -1.3em; }
-h2 span { top: -1.2em; }
-h3 span { top: -1.0em; }
-h4 span { top: -0.8em; }
-h5 span { top: -0.5em; }
-h6 span { top: -0.5em; }
-
-h1:hover span,
-h2:hover span,
-h3:hover span,
-h4:hover span,
-h5:hover span,
-h6:hover span {
- display: inline;
-}
-
-h1:target,
-h2:target,
-h3:target,
-h4:target,
-h5:target,
-h6:target {
- margin-left: -10px;
- border-left: 10px solid #f1edba;
-}
-
-:link,
-:visited {
- color: #6C8C22;
- text-decoration: none;
-}
-
-:link:hover,
-:visited:hover {
- border-bottom: 1px dotted #6C8C22;
-}
-
-code,
-pre {
- font-family: "Source Code Pro", Monaco, monospace;
- background-color: rgba(27,31,35,0.05);
- padding: 0em 0.2em;
- border-radius: 0.2em;
-}
-
-table {
- margin: 0;
- border-spacing: 0;
- border-collapse: collapse;
-}
-
-table tr th, table tr td {
- padding: 0.2em 0.4em;
- border: 1px solid #ccc;
-}
-
-table tr th {
- background-color: #eceaed;
-}
-
-table tr:nth-child(even) td {
- background-color: #f5f4f6;
-}
-
-/* @group Generic Classes */
-
-.initially-hidden {
- display: none;
-}
-
-#search-field {
- width: 98%;
- background: white;
- border: none;
- height: 1.5em;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
- text-align: left;
-}
-#search-field:focus {
- background: #f1edba;
-}
-#search-field:-moz-placeholder,
-#search-field::-webkit-input-placeholder {
- font-weight: bold;
- color: #666;
-}
-
-.missing-docs {
- font-size: 120%;
- background: white url(../images/wrench_orange.png) no-repeat 4px center;
- color: #ccc;
- line-height: 2em;
- border: 1px solid #d00;
- opacity: 1;
- padding-left: 20px;
- text-indent: 24px;
- letter-spacing: 3px;
- font-weight: bold;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
-}
-
-.target-section {
- border: 2px solid #dcce90;
- border-left-width: 8px;
- padding: 0 1em;
- background: #fff3c2;
-}
-
-/* @end */
-
-/* @group Index Page, Standalone file pages */
-.table-of-contents ul {
- margin: 1em;
- list-style: none;
-}
-
-.table-of-contents ul ul {
- margin-top: 0.25em;
-}
-
-.table-of-contents ul :link,
-.table-of-contents ul :visited {
- font-size: 16px;
-}
-
-.table-of-contents li {
- margin-bottom: 0.25em;
-}
-
-.table-of-contents li .toc-toggle {
- width: 16px;
- height: 16px;
- background: url(../images/add.png) no-repeat;
-}
-
-.table-of-contents li .toc-toggle.open {
- background: url(../images/delete.png) no-repeat;
-}
-
-/* @end */
-
-/* @group Top-Level Structure */
-
-nav {
- float: left;
- width: 260px;
- font-family: Helvetica, sans-serif;
- font-size: 14px;
- border-right: 1px solid #ccc;
- position: sticky;
- top: 0;
- overflow: auto;
- height: calc(100vh - 100px); /* reduce the footer height */
-}
-
-main {
- display: block;
- margin: 0 2em 5em 260px;
- padding-left: 20px;
- min-width: 340px;
- font-size: 16px;
-}
-
-main h1,
-main h2,
-main h3,
-main h4,
-main h5,
-main h6 {
- font-family: Helvetica, sans-serif;
-}
-
-.table-of-contents main {
- margin-left: 2em;
-}
-
-#validator-badges {
- clear: both;
- margin: 1em 1em 2em;
- font-size: smaller;
-}
-
-/* @end */
-
-/* @group navigation */
-nav {
- margin-bottom: 1em;
-}
-
-nav .nav-section {
- margin-top: 2em;
- border-top: 2px solid #aaa;
- font-size: 90%;
- overflow: hidden;
-}
-
-nav h2 {
- margin: 0;
- padding: 2px 8px 2px 8px;
- background-color: #e8e8e8;
- color: #555;
- font-size: 125%;
- text-align: center;
-}
-
-nav h3,
-#table-of-contents-navigation {
- margin: 0;
- padding: 2px 8px 2px 8px;
- text-align: right;
- background-color: #e8e8e8;
- color: #555;
-}
-
-nav ul,
-nav dl,
-nav p {
- padding: 4px 8px 0;
- list-style: none;
-}
-
-#project-navigation .nav-section {
- margin: 0;
- border-top: 0;
-}
-
-#home-section h2 {
- text-align: center;
-}
-
-#table-of-contents-navigation {
- font-size: 1.2em;
- font-weight: bold;
- text-align: center;
-}
-
-#search-section {
- margin-top: 0;
- border-top: 0;
-}
-
-#search-field-wrapper {
- border-top: 1px solid #aaa;
- border-bottom: 1px solid #aaa;
- padding: 3px 8px;
- background-color: #e8e8e8;
- color: #555;
-}
-
-ul.link-list li {
- white-space: nowrap;
- line-height: 1.4em;
-}
-
-ul.link-list .type {
- font-size: 8px;
- text-transform: uppercase;
- color: white;
- background: #969696;
- padding: 2px 4px;
- -webkit-border-radius: 5px;
-}
-
-dl.note-list dt {
- float: left;
- margin-right: 1em;
-}
-
-.calls-super {
- background: url(../images/arrow_up.png) no-repeat right center;
-}
-
-.nav-section details summary {
- display: block;
-}
-
-.nav-section details summary::-webkit-details-marker {
- display: none;
-}
-
-.nav-section details summary:before {
- content: "";
-}
-
-.nav-section details summary:after {
- content: " \25B6"; /* BLACK RIGHT-POINTING TRIANGLE */
-}
-.nav-section details[open] > summary:after {
- content: " \25BD"; /* WHITE DOWN-POINTING TRIANGLE */
-}
-
-/* @end */
-
-/* @group Documentation Section */
-main {
- color: #333;
-}
-
-main > h1:first-child,
-main > h2:first-child,
-main > h3:first-child,
-main > h4:first-child,
-main > h5:first-child,
-main > h6:first-child {
- margin-top: 0px;
-}
-
-main sup {
- vertical-align: super;
- font-size: 0.8em;
-}
-
-/* The heading with the class name */
-main h1[class] {
- margin-top: 0;
- margin-bottom: 1em;
- font-size: 2em;
- color: #6C8C22;
-}
-
-main h1 {
- margin: 2em 0 0.5em;
- font-size: 1.7em;
-}
-
-main h2 {
- margin: 2em 0 0.5em;
- font-size: 1.5em;
-}
-
-main h3 {
- margin: 2em 0 0.5em;
- font-size: 1.2em;
-}
-
-main h4 {
- margin: 2em 0 0.5em;
- font-size: 1.1em;
-}
-
-main h5 {
- margin: 2em 0 0.5em;
- font-size: 1em;
-}
-
-main h6 {
- margin: 2em 0 0.5em;
- font-size: 1em;
-}
-
-main p {
- margin: 0 0 0.5em;
- line-height: 1.4em;
-}
-
-main pre {
- margin: 1.2em 0.5em;
- padding: 1em;
- font-size: 0.8em;
-}
-
-main hr {
- margin: 1.5em 1em;
- border: 2px solid #ddd;
-}
-
-main blockquote {
- margin: 0 2em 1.2em 1.2em;
- padding-left: 0.5em;
- border-left: 2px solid #ddd;
-}
-
-main ol,
-main ul {
- margin: 1em 2em;
-}
-
-main li > p {
- margin-bottom: 0.5em;
-}
-
-main dl {
- margin: 1em 0.5em;
-}
-
-main dt {
- margin-bottom: 0.5em;
- font-weight: bold;
-}
-
-main dd {
- margin: 0 1em 1em 0.5em;
-}
-
-main header h2 {
- margin-top: 2em;
- border-width: 0;
- border-top: 4px solid #bbb;
- font-size: 130%;
-}
-
-main header h3 {
- margin: 2em 0 1.5em;
- border-width: 0;
- border-top: 3px solid #bbb;
- font-size: 120%;
-}
-
-.documentation-section-title {
- position: relative;
-}
-.documentation-section-title .section-click-top {
- position: absolute;
- top: 6px;
- left: 12px;
- font-size: 10px;
- color: #9b9877;
- visibility: hidden;
- padding-left: 0.5px;
-}
-
-.documentation-section-title:hover .section-click-top {
- visibility: visible;
-}
-
-.constants-list > dl {
- margin: 1em 0 2em;
- border: 0;
-}
-
-.constants-list > dl dt {
- margin-bottom: 0.75em;
- padding-left: 0;
- font-family: "Source Code Pro", Monaco, monospace;
- font-size: 110%;
-}
-
-.constants-list > dl dt a {
- color: inherit;
-}
-
-.constants-list > dl dd {
- margin: 0 0 2em 0;
- padding: 0;
- color: #666;
-}
-
-.documentation-section h2 {
- position: relative;
-}
-
-.documentation-section h2 a {
- position: absolute;
- top: 8px;
- right: 10px;
- font-size: 12px;
- color: #9b9877;
- visibility: hidden;
-}
-
-.documentation-section h2:hover a {
- visibility: visible;
-}
-
-/* @group Method Details */
-
-main .method-source-code {
- max-height: 0;
- overflow: auto;
- transition-duration: 200ms;
- transition-delay: 0ms;
- transition-property: all;
- transition-timing-function: ease-in-out;
-}
-
-main .method-source-code.active-menu {
- max-height: 100vh;
-}
-
-main .method-description .method-calls-super {
- color: #333;
- font-weight: bold;
-}
-
-main .method-detail {
- margin-bottom: 2.5em;
- cursor: pointer;
-}
-
-main .method-detail:target {
- margin-left: -10px;
- border-left: 10px solid #f1edba;
-}
-
-main .method-heading {
- position: relative;
- font-family: "Source Code Pro", Monaco, monospace;
- font-size: 110%;
- font-weight: bold;
- color: #333;
-}
-main .method-heading :link,
-main .method-heading :visited {
- color: inherit;
-}
-main .method-click-advice {
- position: absolute;
- top: 2px;
- right: 5px;
- font-size: 12px;
- color: #9b9877;
- visibility: hidden;
- padding-right: 20px;
- line-height: 20px;
- background: url(../images/zoom.png) no-repeat right top;
-}
-main .method-heading:hover .method-click-advice {
- visibility: visible;
-}
-
-main .method-alias .method-heading {
- color: #666;
-}
-
-main .method-description,
-main .aliases {
- margin-top: 0.75em;
- color: #333;
-}
-
-main .aliases {
- padding-top: 4px;
- font-style: italic;
- cursor: default;
-}
-main .method-description ul {
- margin-left: 1.5em;
-}
-
-main #attribute-method-details .method-detail:hover {
- background-color: transparent;
- cursor: default;
-}
-main .attribute-access-type {
- text-transform: uppercase;
- padding: 0 1em;
-}
-/* @end */
-
-/* @end */
-
-/* @group Source Code */
-
-pre {
- margin: 0.5em 0;
- border: 1px dashed #999;
- padding: 0.5em;
- background: #262626;
- color: white;
- overflow: auto;
-}
-
-.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: #dc0000; background: transparent; }
-.ruby-regexp { color: #ffa07a; background: transparent; }
-.ruby-value { color: #7fffd4; background: transparent; }
-
-/* @end */
-
-
-/* @group search results */
-#search-results {
- font-family: Lato, sans-serif;
- font-weight: 300;
-}
-
-#search-results .search-match {
- font-family: Helvetica, sans-serif;
- font-weight: normal;
-}
-
-#search-results .search-selected {
- background: #e8e8e8;
- border-bottom: 1px solid transparent;
-}
-
-#search-results li {
- list-style: none;
- border-bottom: 1px solid #aaa;
- margin-bottom: 0.5em;
-}
-
-#search-results li:last-child {
- border-bottom: none;
- margin-bottom: 0;
-}
-
-#search-results li p {
- padding: 0;
- margin: 0.5em;
-}
-
-#search-results .search-namespace {
- font-weight: bold;
-}
-
-#search-results li em {
- background: yellow;
- font-style: normal;
-}
-
-#search-results pre {
- margin: 0.5em;
- font-family: "Source Code Pro", Monaco, monospace;
-}
-
-/* @end */
-
diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf
deleted file mode 100644
index b49dd43729..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf
deleted file mode 100644
index 7959fef075..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf
deleted file mode 100644
index 839cd589dc..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf
deleted file mode 100644
index bababa09e3..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf b/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf
deleted file mode 100644
index dd00982d49..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf b/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf
deleted file mode 100644
index 1decfb95af..0000000000
--- a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/add.png b/lib/rdoc/generator/template/darkfish/images/add.png
deleted file mode 100644
index 6332fefea4..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/add.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/arrow_up.png b/lib/rdoc/generator/template/darkfish/images/arrow_up.png
deleted file mode 100644
index 1ebb193243..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/arrow_up.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/brick.png b/lib/rdoc/generator/template/darkfish/images/brick.png
deleted file mode 100644
index 7851cf34c9..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/brick.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/brick_link.png b/lib/rdoc/generator/template/darkfish/images/brick_link.png
deleted file mode 100644
index 9ebf013a23..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/brick_link.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/bug.png b/lib/rdoc/generator/template/darkfish/images/bug.png
deleted file mode 100644
index 2d5fb90ec6..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/bug.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_black.png b/lib/rdoc/generator/template/darkfish/images/bullet_black.png
deleted file mode 100644
index 57619706d1..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/bullet_black.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png b/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png
deleted file mode 100644
index b47ce55f68..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png b/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png
deleted file mode 100644
index 9ab4a89664..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/date.png b/lib/rdoc/generator/template/darkfish/images/date.png
deleted file mode 100644
index 783c83357f..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/date.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/delete.png b/lib/rdoc/generator/template/darkfish/images/delete.png
deleted file mode 100644
index 08f249365a..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/delete.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/find.png b/lib/rdoc/generator/template/darkfish/images/find.png
deleted file mode 100644
index 1547479646..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/find.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif b/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif
deleted file mode 100644
index 82290f4833..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png b/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png
deleted file mode 100644
index c6473b324e..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/package.png b/lib/rdoc/generator/template/darkfish/images/package.png
deleted file mode 100644
index da3c2a2d74..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/package.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/page_green.png b/lib/rdoc/generator/template/darkfish/images/page_green.png
deleted file mode 100644
index de8e003f9f..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/page_green.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/page_white_text.png b/lib/rdoc/generator/template/darkfish/images/page_white_text.png
deleted file mode 100644
index 813f712f72..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/page_white_text.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/page_white_width.png b/lib/rdoc/generator/template/darkfish/images/page_white_width.png
deleted file mode 100644
index 1eb880947d..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/page_white_width.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/plugin.png b/lib/rdoc/generator/template/darkfish/images/plugin.png
deleted file mode 100644
index 6187b15aec..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/plugin.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/ruby.png b/lib/rdoc/generator/template/darkfish/images/ruby.png
deleted file mode 100644
index f763a16880..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/ruby.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/tag_blue.png b/lib/rdoc/generator/template/darkfish/images/tag_blue.png
deleted file mode 100644
index 3f02b5f8f8..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/tag_blue.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/tag_green.png b/lib/rdoc/generator/template/darkfish/images/tag_green.png
deleted file mode 100644
index 83ec984bd7..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/tag_green.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/transparent.png b/lib/rdoc/generator/template/darkfish/images/transparent.png
deleted file mode 100644
index d665e179ef..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/transparent.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/wrench.png b/lib/rdoc/generator/template/darkfish/images/wrench.png
deleted file mode 100644
index 5c8213fef5..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/wrench.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/wrench_orange.png b/lib/rdoc/generator/template/darkfish/images/wrench_orange.png
deleted file mode 100644
index 565a9330e0..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/wrench_orange.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/images/zoom.png b/lib/rdoc/generator/template/darkfish/images/zoom.png
deleted file mode 100644
index 908612e394..0000000000
--- a/lib/rdoc/generator/template/darkfish/images/zoom.png
+++ /dev/null
Binary files differ
diff --git a/lib/rdoc/generator/template/darkfish/index.rhtml b/lib/rdoc/generator/template/darkfish/index.rhtml
deleted file mode 100644
index 423e225b68..0000000000
--- a/lib/rdoc/generator/template/darkfish/index.rhtml
+++ /dev/null
@@ -1,22 +0,0 @@
-<body id="top" role="document" class="file">
-<nav role="navigation">
- <div id="project-navigation">
- <%= render '_sidebar_navigation.rhtml' %>
-
- <%= render '_sidebar_search.rhtml' %>
- </div>
-
- <div id="project-metadata">
- <%= render '_sidebar_pages.rhtml' %>
- <%= render '_sidebar_classes.rhtml' %>
- </div>
-</nav>
-
-<main role="main">
-<%- if @options.main_page and
- main_page = @files.find { |f| f.full_name == @options.main_page } then %>
-<%= main_page.description %>
-<%- else -%>
-<p>This is the API documentation for <%= h @title %>.
-<%- end -%>
-</main>
diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js
deleted file mode 100644
index d0c9467751..0000000000
--- a/lib/rdoc/generator/template/darkfish/js/darkfish.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- *
- * Darkfish Page Functions
- * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
- *
- * Author: Michael Granger <mgranger@laika.com>
- *
- */
-
-/* Provide console simulation for firebug-less environments */
-/*
-if (!("console" in window) || !("firebug" in console)) {
- var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
- "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
-
- window.console = {};
- for (var i = 0; i < names.length; ++i)
- window.console[names[i]] = function() {};
-};
-*/
-
-
-function showSource( e ) {
- var target = e.target;
- while (!target.classList.contains('method-detail')) {
- target = target.parentNode;
- }
- if (typeof target !== "undefined" && target !== null) {
- target = target.querySelector('.method-source-code');
- }
- if (typeof target !== "undefined" && target !== null) {
- target.classList.toggle('active-menu')
- }
-};
-
-function hookSourceViews() {
- document.querySelectorAll('.method-heading').forEach(function (codeObject) {
- codeObject.addEventListener('click', showSource);
- });
-};
-
-function hookSearch() {
- var input = document.querySelector('#search-field');
- var result = document.querySelector('#search-results');
- result.classList.remove("initially-hidden");
-
- var search_section = document.querySelector('#search-section');
- search_section.classList.remove("initially-hidden");
-
- var search = new Search(search_data, input, result);
-
- search.renderItem = function(result) {
- var li = document.createElement('li');
- var html = '';
-
- // TODO add relative path to <script> per-page
- html += '<p class="search-match"><a href="' + index_rel_prefix + this.escapeHTML(result.path) + '">' + this.hlt(result.title);
- if (result.params)
- html += '<span class="params">' + result.params + '</span>';
- html += '</a>';
-
-
- if (result.namespace)
- html += '<p class="search-namespace">' + this.hlt(result.namespace);
-
- if (result.snippet)
- html += '<div class="search-snippet">' + result.snippet + '</div>';
-
- li.innerHTML = html;
-
- return li;
- }
-
- search.select = function(result) {
- window.location.href = result.firstChild.firstChild.href;
- }
-
- search.scrollIntoView = search.scrollInWindow;
-};
-
-document.addEventListener('DOMContentLoaded', function() {
- hookSourceViews();
- hookSearch();
-});
diff --git a/lib/rdoc/generator/template/darkfish/js/search.js b/lib/rdoc/generator/template/darkfish/js/search.js
deleted file mode 100644
index 58e52afecf..0000000000
--- a/lib/rdoc/generator/template/darkfish/js/search.js
+++ /dev/null
@@ -1,110 +0,0 @@
-Search = function(data, input, result) {
- this.data = data;
- this.input = input;
- this.result = result;
-
- this.current = null;
- this.view = this.result.parentNode;
- this.searcher = new Searcher(data.index);
- this.init();
-}
-
-Search.prototype = Object.assign({}, Navigation, new function() {
- var suid = 1;
-
- this.init = function() {
- var _this = this;
- var observer = function(e) {
- switch(e.keyCode) {
- case 38: // Event.KEY_UP
- case 40: // Event.KEY_DOWN
- return;
- }
- _this.search(_this.input.value);
- };
- this.input.addEventListener('keyup', observer);
- this.input.addEventListener('click', observer); // mac's clear field
-
- this.searcher.ready(function(results, isLast) {
- _this.addResults(results, isLast);
- })
-
- this.initNavigation();
- this.setNavigationActive(false);
- }
-
- this.search = function(value, selectFirstMatch) {
- value = value.trim().toLowerCase();
- if (value) {
- this.setNavigationActive(true);
- } else {
- this.setNavigationActive(false);
- }
-
- if (value == '') {
- this.lastQuery = value;
- this.result.innerHTML = '';
- this.result.setAttribute('aria-expanded', 'false');
- this.setNavigationActive(false);
- } else if (value != this.lastQuery) {
- this.lastQuery = value;
- this.result.setAttribute('aria-busy', 'true');
- this.result.setAttribute('aria-expanded', 'true');
- this.firstRun = true;
- this.searcher.find(value);
- }
- }
-
- this.addResults = function(results, isLast) {
- var target = this.result;
- if (this.firstRun && (results.length > 0 || isLast)) {
- this.current = null;
- this.result.innerHTML = '';
- }
-
- for (var i=0, l = results.length; i < l; i++) {
- var item = this.renderItem.call(this, results[i]);
- item.setAttribute('id', 'search-result-' + target.childElementCount);
- target.appendChild(item);
- };
-
- if (this.firstRun && results.length > 0) {
- this.firstRun = false;
- this.current = target.firstChild;
- this.current.classList.add('search-selected');
- }
- //TODO: ECMAScript
- //if (jQuery.browser.msie) this.$element[0].className += '';
-
- if (isLast) this.result.setAttribute('aria-busy', 'false');
- }
-
- this.move = function(isDown) {
- if (!this.current) return;
- var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
- if (next) {
- this.current.classList.remove('search-selected');
- next.classList.add('search-selected');
- this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
- this.scrollIntoView(next, this.view);
- this.current = next;
- this.input.value = next.firstChild.firstChild.text;
- this.input.select();
- }
- return true;
- }
-
- this.hlt = function(html) {
- return this.escapeHTML(html).
- replace(/\u0001/g, '<em>').
- replace(/\u0002/g, '</em>');
- }
-
- this.escapeHTML = function(html) {
- return html.replace(/[&<>"`']/g, function(c) {
- return '&#' + c.charCodeAt(0) + ';';
- });
- }
-
-});
-
diff --git a/lib/rdoc/generator/template/darkfish/page.rhtml b/lib/rdoc/generator/template/darkfish/page.rhtml
deleted file mode 100644
index 4a6b006bb3..0000000000
--- a/lib/rdoc/generator/template/darkfish/page.rhtml
+++ /dev/null
@@ -1,18 +0,0 @@
-<body id="top" role="document" class="file">
-<nav role="navigation">
- <div id="project-navigation">
- <%= render '_sidebar_navigation.rhtml' %>
- <%= render '_sidebar_search.rhtml' %>
- </div>
-
- <%= render '_sidebar_table_of_contents.rhtml' %>
-
- <div id="project-metadata">
- <%= render '_sidebar_pages.rhtml' %>
- </div>
-</nav>
-
-<main role="main" aria-label="Page <%=h file.full_name%>">
-<%= file.description %>
-</main>
-
diff --git a/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml b/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml
deleted file mode 100644
index f0841572c3..0000000000
--- a/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml
+++ /dev/null
@@ -1,18 +0,0 @@
-<body role="document">
-<nav role="navigation">
- <%= render '_sidebar_navigation.rhtml' %>
-
- <%= render '_sidebar_search.rhtml' %>
-
- <div id="project-metadata">
- <%= render '_sidebar_pages.rhtml' %>
- <%= render '_sidebar_classes.rhtml' %>
- </div>
-</nav>
-
-<main role="main">
- <h1>Not Found</h1>
-
- <p><%= message %>
-</main>
-
diff --git a/lib/rdoc/generator/template/darkfish/servlet_root.rhtml b/lib/rdoc/generator/template/darkfish/servlet_root.rhtml
deleted file mode 100644
index cab3092b17..0000000000
--- a/lib/rdoc/generator/template/darkfish/servlet_root.rhtml
+++ /dev/null
@@ -1,62 +0,0 @@
-<body role="document">
-<nav role="navigation">
- <div id="project-navigation">
- <div id="home-section" class="nav-section">
- <h2>
- <a href="<%= rel_prefix %>/" rel="home">Home</a>
- </h2>
- </div>
-
- <%= render '_sidebar_search.rhtml' %>
- </div>
-
-<%= render '_sidebar_installed.rhtml' %>
-</nav>
-
-<main role="main">
- <h1>Local RDoc Documentation</h1>
-
- <p>Here you can browse local documentation from the ruby standard library and
- your installed gems.
-
-<%- extra_dirs = installed.select { |_, _, _, type,| type == :extra } -%>
-<%- unless extra_dirs.empty? -%>
- <h2>Extra Documentation Directories</h2>
-
- <p>The following additional documentation directories are available:</p>
-
- <ol>
- <%- extra_dirs.each do |name, href, exists, _, path| -%>
- <li>
- <%- if exists -%>
- <a href="<%= href %>"><%= h name %></a> (<%= h path %>)
- <%- else -%>
- <%= h name %> (<%= h path %>; <i>not available</i>)
- <%- end -%>
- </li>
- <%- end -%>
- </ol>
-<%- end -%>
-
-<%- gems = installed.select { |_, _, _, type,| type == :gem } -%>
-<%- missing = gems.reject { |_, _, exists,| exists } -%>
-<%- unless missing.empty? then -%>
- <h2>Missing Gem Documentation</h2>
-
- <p>You are missing documentation for some of your installed gems.
- You can install missing documentation for gems by running
- <kbd>gem rdoc --all</kbd>. After installing the missing documentation you
- only need to reload this page. The newly created documentation will
- automatically appear.
-
- <p>You can also install documentation for a specific gem by running one of
- the following commands.
-
- <ul>
- <%- names = missing.map { |name,| name.sub(/-([^-]*)$/, '') }.uniq -%>
- <%- names.each do |name| -%>
- <li><kbd>gem rdoc <%=h name %></kbd>
- <%- end -%>
- </ul>
-<%- end -%>
-</main>
diff --git a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml b/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml
deleted file mode 100644
index 941ff9d630..0000000000
--- a/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml
+++ /dev/null
@@ -1,58 +0,0 @@
-<body id="top" class="table-of-contents">
-<main role="main">
-<h1 class="class"><%= h @title %></h1>
-
-<%- simple_files = @files.select { |f| f.text? } -%>
-<%- unless simple_files.empty? then -%>
-<h2 id="pages">Pages</h2>
-<ul>
-<%- simple_files.sort.each do |file| -%>
- <li class="file">
- <a href="<%= h file.path %>"><%= h file.page_name %></a>
-<%
- # HACK table_of_contents should not exist on Document
- table = file.parse(file.comment).table_of_contents
- unless table.empty? then %>
- <ul>
-<%- table.each do |heading| -%>
- <li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
-<%- end -%>
- </ul>
-<%- end -%>
- </li>
- <%- end -%>
-</ul>
-<%- end -%>
-
-<h2 id="classes">Classes and Modules</h2>
-<ul>
-<%- @modsort.each do |klass| -%>
- <li class="<%= klass.type %>">
- <a href="<%= klass.path %>"><%= klass.full_name %></a>
-<%- table = []
- table.concat klass.parse(klass.comment_location).table_of_contents
- table.concat klass.section_contents
-
- unless table.empty? then %>
- <ul>
-<%- table.each do |item| -%>
- <li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
-<%- end -%>
- </ul>
-<%- end -%>
- </li>
-<%- end -%>
-</ul>
-
-<h2 id="methods">Methods</h2>
-<ul>
-<%- @store.all_classes_and_modules.map do |mod|
- mod.method_list
- end.flatten.sort.each do |method| %>
- <li class="method">
- <a href="<%= method.path %>"><%= h method.pretty_name %></a>
- &mdash;
- <span class="container"><%= method.parent.full_name %></span>
-<%- end -%>
-</ul>
-</main>
diff --git a/lib/rdoc/generator/template/json_index/.document b/lib/rdoc/generator/template/json_index/.document
deleted file mode 100644
index 1713b67654..0000000000
--- a/lib/rdoc/generator/template/json_index/.document
+++ /dev/null
@@ -1 +0,0 @@
-# ignore all files in this directory
diff --git a/lib/rdoc/generator/template/json_index/js/navigation.js b/lib/rdoc/generator/template/json_index/js/navigation.js
deleted file mode 100644
index dfad74b1ae..0000000000
--- a/lib/rdoc/generator/template/json_index/js/navigation.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Navigation allows movement using the arrow keys through the search results.
- *
- * When using this library you will need to set scrollIntoView to the
- * appropriate function for your layout. Use scrollInWindow if the container
- * is not scrollable and scrollInElement if the container is a separate
- * scrolling region.
- */
-Navigation = new function() {
- this.initNavigation = function() {
- var _this = this;
-
- document.addEventListener('keydown', function(e) {
- _this.onkeydown(e);
- });
-
- this.navigationActive = true;
- }
-
- this.setNavigationActive = function(state) {
- this.navigationActive = state;
- }
-
- this.onkeydown = function(e) {
- if (!this.navigationActive) return;
- switch(e.keyCode) {
- case 37: //Event.KEY_LEFT:
- if (this.moveLeft()) e.preventDefault();
- break;
- case 38: //Event.KEY_UP:
- if (e.keyCode == 38 || e.ctrlKey) {
- if (this.moveUp()) e.preventDefault();
- }
- break;
- case 39: //Event.KEY_RIGHT:
- if (this.moveRight()) e.preventDefault();
- break;
- case 40: //Event.KEY_DOWN:
- if (e.keyCode == 40 || e.ctrlKey) {
- if (this.moveDown()) e.preventDefault();
- }
- break;
- case 13: //Event.KEY_RETURN:
- if (this.current) e.preventDefault();
- this.select(this.current);
- break;
- }
- if (e.ctrlKey && e.shiftKey) this.select(this.current);
- }
-
- this.moveRight = function() {
- }
-
- this.moveLeft = function() {
- }
-
- this.move = function(isDown) {
- }
-
- this.moveUp = function() {
- return this.move(false);
- }
-
- this.moveDown = function() {
- return this.move(true);
- }
-
- /*
- * Scrolls to the given element in the scrollable element view.
- */
- this.scrollInElement = function(element, view) {
- var offset, viewHeight, viewScroll, height;
- offset = element.offsetTop;
- height = element.offsetHeight;
- viewHeight = view.offsetHeight;
- viewScroll = view.scrollTop;
-
- if (offset - viewScroll + height > viewHeight) {
- view.scrollTop = offset - viewHeight + height;
- }
- if (offset < viewScroll) {
- view.scrollTop = offset;
- }
- }
-
- /*
- * Scrolls to the given element in the window. The second argument is
- * ignored
- */
- this.scrollInWindow = function(element, ignored) {
- var offset, viewHeight, viewScroll, height;
- offset = element.offsetTop;
- height = element.offsetHeight;
- viewHeight = window.innerHeight;
- viewScroll = window.scrollY;
-
- if (offset - viewScroll + height > viewHeight) {
- window.scrollTo(window.scrollX, offset - viewHeight + height);
- }
- if (offset < viewScroll) {
- window.scrollTo(window.scrollX, offset);
- }
- }
-}
-
diff --git a/lib/rdoc/generator/template/json_index/js/searcher.js b/lib/rdoc/generator/template/json_index/js/searcher.js
deleted file mode 100644
index e200a168b0..0000000000
--- a/lib/rdoc/generator/template/json_index/js/searcher.js
+++ /dev/null
@@ -1,229 +0,0 @@
-Searcher = function(data) {
- this.data = data;
- this.handlers = [];
-}
-
-Searcher.prototype = new function() {
- // search is performed in chunks of 1000 for non-blocking user input
- var CHUNK_SIZE = 1000;
- // do not try to find more than 100 results
- var MAX_RESULTS = 100;
- var huid = 1;
- var suid = 1;
- var runs = 0;
-
- this.find = function(query) {
- var queries = splitQuery(query);
- var regexps = buildRegexps(queries);
- var highlighters = buildHilighters(queries);
- var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
- var _this = this;
-
- this.currentSuid = state.n;
-
- if (!query) return;
-
- var run = function() {
- // stop current search thread if new search started
- if (state.n != _this.currentSuid) return;
-
- var results =
- performSearch(_this.data, regexps, queries, highlighters, state);
- var hasMore = (state.limit > 0 && state.pass < 4);
-
- triggerResults.call(_this, results, !hasMore);
- if (hasMore) {
- setTimeout(run, 2);
- }
- runs++;
- };
- runs = 0;
-
- // start search thread
- run();
- }
-
- /* ----- Events ------ */
- this.ready = function(fn) {
- fn.huid = huid;
- this.handlers.push(fn);
- }
-
- /* ----- Utilities ------ */
- function splitQuery(query) {
- return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
- return string.match(/\S/);
- });
- }
-
- function buildRegexps(queries) {
- return queries.map(function(query) {
- return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
- });
- }
-
- function buildHilighters(queries) {
- return queries.map(function(query) {
- return query.split('').map(function(l, i) {
- return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
- }).join('');
- });
- }
-
- // function longMatchRegexp(index, longIndex, regexps) {
- // for (var i = regexps.length - 1; i >= 0; i--){
- // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
- // };
- // return true;
- // }
-
-
- /* ----- Mathchers ------ */
-
- /*
- * This record matches if the index starts with queries[0] and the record
- * matches all of the regexps
- */
- function matchPassBeginning(index, longIndex, queries, regexps) {
- if (index.indexOf(queries[0]) != 0) return false;
- for (var i=1, l = regexps.length; i < l; i++) {
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
- return false;
- };
- return true;
- }
-
- /*
- * This record matches if the longIndex starts with queries[0] and the
- * longIndex matches all of the regexps
- */
- function matchPassLongIndex(index, longIndex, queries, regexps) {
- if (longIndex.indexOf(queries[0]) != 0) return false;
- for (var i=1, l = regexps.length; i < l; i++) {
- if (!longIndex.match(regexps[i]))
- return false;
- };
- return true;
- }
-
- /*
- * This record matches if the index contains queries[0] and the record
- * matches all of the regexps
- */
- function matchPassContains(index, longIndex, queries, regexps) {
- if (index.indexOf(queries[0]) == -1) return false;
- for (var i=1, l = regexps.length; i < l; i++) {
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
- return false;
- };
- return true;
- }
-
- /*
- * This record matches if regexps[0] matches the index and the record
- * matches all of the regexps
- */
- function matchPassRegexp(index, longIndex, queries, regexps) {
- if (!index.match(regexps[0])) return false;
- for (var i=1, l = regexps.length; i < l; i++) {
- if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
- return false;
- };
- return true;
- }
-
-
- /* ----- Highlighters ------ */
- function highlightRegexp(info, queries, regexps, highlighters) {
- var result = createResult(info);
- for (var i=0, l = regexps.length; i < l; i++) {
- result.title = result.title.replace(regexps[i], highlighters[i]);
- result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
- };
- return result;
- }
-
- function hltSubstring(string, pos, length) {
- return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
- }
-
- function highlightQuery(info, queries, regexps, highlighters) {
- var result = createResult(info);
- var pos = 0;
- var lcTitle = result.title.toLowerCase();
-
- pos = lcTitle.indexOf(queries[0]);
- if (pos != -1) {
- result.title = hltSubstring(result.title, pos, queries[0].length);
- }
-
- result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
- for (var i=1, l = regexps.length; i < l; i++) {
- result.title = result.title.replace(regexps[i], highlighters[i]);
- result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
- };
- return result;
- }
-
- function createResult(info) {
- var result = {};
- result.title = info[0];
- result.namespace = info[1];
- result.path = info[2];
- result.params = info[3];
- result.snippet = info[4];
- result.badge = info[6];
- return result;
- }
-
- /* ----- Searching ------ */
- function performSearch(data, regexps, queries, highlighters, state) {
- var searchIndex = data.searchIndex;
- var longSearchIndex = data.longSearchIndex;
- var info = data.info;
- var result = [];
- var i = state.from;
- var l = searchIndex.length;
- var togo = CHUNK_SIZE;
- var matchFunc, hltFunc;
-
- while (state.pass < 4 && state.limit > 0 && togo > 0) {
- if (state.pass == 0) {
- matchFunc = matchPassBeginning;
- hltFunc = highlightQuery;
- } else if (state.pass == 1) {
- matchFunc = matchPassLongIndex;
- hltFunc = highlightQuery;
- } else if (state.pass == 2) {
- matchFunc = matchPassContains;
- hltFunc = highlightQuery;
- } else if (state.pass == 3) {
- matchFunc = matchPassRegexp;
- hltFunc = highlightRegexp;
- }
-
- for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
- if (info[i].n == state.n) continue;
- if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
- info[i].n = state.n;
- result.push(hltFunc(info[i], queries, regexps, highlighters));
- state.limit--;
- }
- };
- if (searchIndex.length <= i) {
- state.pass++;
- i = state.from = 0;
- } else {
- state.from = i;
- }
- }
- return result;
- }
-
- function triggerResults(results, isLast) {
- this.handlers.forEach(function(fn) {
- fn.call(this, results, isLast)
- });
- }
-}
-
diff --git a/lib/rdoc/ghost_method.rb b/lib/rdoc/ghost_method.rb
deleted file mode 100644
index 2488feb9d7..0000000000
--- a/lib/rdoc/ghost_method.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-##
-# GhostMethod represents a method referenced only by a comment
-
-class RDoc::GhostMethod < RDoc::AnyMethod
-end
-
diff --git a/lib/rdoc/i18n.rb b/lib/rdoc/i18n.rb
deleted file mode 100644
index f209a9a6f6..0000000000
--- a/lib/rdoc/i18n.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-##
-# This module provides i18n related features.
-
-module RDoc::I18n
-
- autoload :Locale, "#{__dir__}/i18n/locale"
- require_relative 'i18n/text'
-
-end
diff --git a/lib/rdoc/i18n/locale.rb b/lib/rdoc/i18n/locale.rb
deleted file mode 100644
index 6a70d6c986..0000000000
--- a/lib/rdoc/i18n/locale.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# frozen_string_literal: true
-##
-# A message container for a locale.
-#
-# This object provides the following two features:
-#
-# * Loads translated messages from .po file.
-# * Translates a message into the locale.
-
-class RDoc::I18n::Locale
-
- @@locales = {} # :nodoc:
-
- class << self
-
- ##
- # Returns the locale object for +locale_name+.
-
- def [](locale_name)
- @@locales[locale_name] ||= new(locale_name)
- end
-
- ##
- # Sets the locale object for +locale_name+.
- #
- # Normally, this method is not used. This method is useful for
- # testing.
-
- def []=(locale_name, locale)
- @@locales[locale_name] = locale
- end
-
- end
-
- ##
- # The name of the locale. It uses IETF language tag format
- # +[language[_territory][.codeset][@modifier]]+.
- #
- # See also {BCP 47 - Tags for Identifying
- # Languages}[http://tools.ietf.org/rfc/bcp/bcp47.txt].
-
- attr_reader :name
-
- ##
- # Creates a new locale object for +name+ locale. +name+ must
- # follow IETF language tag format.
-
- def initialize(name)
- @name = name
- @messages = {}
- end
-
- ##
- # Loads translation messages from +locale_directory+/+@name+/rdoc.po
- # or +locale_directory+/+@name+.po. The former has high priority.
- #
- # This method requires gettext gem for parsing .po file. If you
- # don't have gettext gem, this method doesn't load .po file. This
- # method warns and returns +false+.
- #
- # Returns +true+ if succeeded, +false+ otherwise.
-
- def load(locale_directory)
- return false if @name.nil?
-
- po_file_candidates = [
- File.join(locale_directory, @name, 'rdoc.po'),
- File.join(locale_directory, "#{@name}.po"),
- ]
- po_file = po_file_candidates.find do |po_file_candidate|
- File.exist?(po_file_candidate)
- end
- return false unless po_file
-
- begin
- require 'gettext/po_parser'
- require 'gettext/mo'
- rescue LoadError
- warn('Need gettext gem for i18n feature:')
- warn(' gem install gettext')
- return false
- end
-
- po_parser = GetText::POParser.new
- messages = GetText::MO.new
- po_parser.report_warning = false
- po_parser.parse_file(po_file, messages)
-
- @messages.merge!(messages)
-
- true
- end
-
- ##
- # Translates the +message+ into locale. If there is no translation
- # messages for +message+ in locale, +message+ itself is returned.
-
- def translate(message)
- @messages[message] || message
- end
-
-end
diff --git a/lib/rdoc/i18n/text.rb b/lib/rdoc/i18n/text.rb
deleted file mode 100644
index 7ea6664442..0000000000
--- a/lib/rdoc/i18n/text.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-# frozen_string_literal: true
-##
-# An i18n supported text.
-#
-# This object provides the following two features:
-#
-# * Extracts translation messages from wrapped raw text.
-# * Translates wrapped raw text in specified locale.
-#
-# Wrapped raw text is one of String, RDoc::Comment or Array of them.
-
-class RDoc::I18n::Text
-
- ##
- # Creates a new i18n supported text for +raw+ text.
-
- def initialize(raw)
- @raw = raw
- end
-
- ##
- # Extracts translation target messages and yields each message.
- #
- # Each yielded message is a Hash. It consists of the followings:
- #
- # :type :: :paragraph
- # :paragraph :: String (The translation target message itself.)
- # :line_no :: Integer (The line number of the :paragraph is started.)
- #
- # The above content may be added in the future.
-
- def extract_messages
- parse do |part|
- case part[:type]
- when :empty_line
- # ignore
- when :paragraph
- yield(part)
- end
- end
- end
-
- # Translates raw text into +locale+.
- def translate(locale)
- translated_text = ''
- parse do |part|
- case part[:type]
- when :paragraph
- translated_text += locale.translate(part[:paragraph])
- when :empty_line
- translated_text += part[:line]
- else
- raise "should not reach here: unexpected type: #{type}"
- end
- end
- translated_text
- end
-
- private
- def parse(&block)
- paragraph = ''
- paragraph_start_line = 0
- line_no = 0
-
- each_line(@raw) do |line|
- line_no += 1
- case line
- when /\A\s*\z/
- if paragraph.empty?
- emit_empty_line_event(line, line_no, &block)
- else
- paragraph += line
- emit_paragraph_event(paragraph, paragraph_start_line, line_no,
- &block)
- paragraph = ''
- end
- else
- paragraph_start_line = line_no if paragraph.empty?
- paragraph += line
- end
- end
-
- unless paragraph.empty?
- emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
- end
- end
-
- def each_line(raw, &block)
- case raw
- when RDoc::Comment
- raw.text.each_line(&block)
- when Array
- raw.each do |comment, location|
- each_line(comment, &block)
- end
- else
- raw.each_line(&block)
- end
- end
-
- def emit_empty_line_event(line, line_no)
- part = {
- :type => :empty_line,
- :line => line,
- :line_no => line_no,
- }
- yield(part)
- end
-
- def emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
- paragraph_part = {
- :type => :paragraph,
- :line_no => paragraph_start_line,
- }
- match_data = /(\s*)\z/.match(paragraph)
- if match_data
- paragraph_part[:paragraph] = match_data.pre_match
- yield(paragraph_part)
- emit_empty_line_event(match_data[1], line_no, &block)
- else
- paragraph_part[:paragraph] = paragraph
- yield(paragraph_part)
- end
- end
-
-end
diff --git a/lib/rdoc/include.rb b/lib/rdoc/include.rb
deleted file mode 100644
index b3ad610649..0000000000
--- a/lib/rdoc/include.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-##
-# A Module included in a class with \#include
-#
-# RDoc::Include.new 'Enumerable', 'comment ...'
-
-class RDoc::Include < RDoc::Mixin
-
-end
-
diff --git a/lib/rdoc/known_classes.rb b/lib/rdoc/known_classes.rb
deleted file mode 100644
index 3e8752bbde..0000000000
--- a/lib/rdoc/known_classes.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# frozen_string_literal: true
-module RDoc
-
- ##
- # Ruby's built-in classes, modules and exceptions
-
- KNOWN_CLASSES = {
- "rb_cArray" => "Array",
- "rb_cBasicObject" => "BasicObject",
- "rb_cBignum" => "Bignum",
- "rb_cClass" => "Class",
- "rb_cData" => "Data",
- "rb_cDir" => "Dir",
- "rb_cEncoding" => "Encoding",
- "rb_cFalseClass" => "FalseClass",
- "rb_cFile" => "File",
- "rb_cFixnum" => "Fixnum",
- "rb_cFloat" => "Float",
- "rb_cHash" => "Hash",
- "rb_cIO" => "IO",
- "rb_cInteger" => "Integer",
- "rb_cModule" => "Module",
- "rb_cNilClass" => "NilClass",
- "rb_cNumeric" => "Numeric",
- "rb_cObject" => "Object",
- "rb_cProc" => "Proc",
- "rb_cRange" => "Range",
- "rb_cRefinement" => "Refinement",
- "rb_cRegexp" => "Regexp",
- "rb_cRubyVM" => "RubyVM",
- "rb_cSocket" => "Socket",
- "rb_cString" => "String",
- "rb_cStruct" => "Struct",
- "rb_cSymbol" => "Symbol",
- "rb_cThread" => "Thread",
- "rb_cTime" => "Time",
- "rb_cTrueClass" => "TrueClass",
-
- "rb_eArgError" => "ArgumentError",
- "rb_eEOFError" => "EOFError",
- "rb_eException" => "Exception",
- "rb_eFatal" => "fatal",
- "rb_eFloatDomainError" => "FloatDomainError",
- "rb_eIOError" => "IOError",
- "rb_eIndexError" => "IndexError",
- "rb_eInterrupt" => "Interrupt",
- "rb_eLoadError" => "LoadError",
- "rb_eNameError" => "NameError",
- "rb_eNoMemError" => "NoMemoryError",
- "rb_eNotImpError" => "NotImplementedError",
- "rb_eRangeError" => "RangeError",
- "rb_eRuntimeError" => "RuntimeError",
- "rb_eScriptError" => "ScriptError",
- "rb_eSecurityError" => "SecurityError",
- "rb_eSignal" => "SignalException",
- "rb_eStandardError" => "StandardError",
- "rb_eSyntaxError" => "SyntaxError",
- "rb_eSystemCallError" => "SystemCallError",
- "rb_eSystemExit" => "SystemExit",
- "rb_eTypeError" => "TypeError",
- "rb_eZeroDivError" => "ZeroDivisionError",
-
- "rb_mComparable" => "Comparable",
- "rb_mEnumerable" => "Enumerable",
- "rb_mErrno" => "Errno",
- "rb_mFConst" => "File::Constants",
- "rb_mFileTest" => "FileTest",
- "rb_mGC" => "GC",
- "rb_mKernel" => "Kernel",
- "rb_mMath" => "Math",
- "rb_mProcess" => "Process"
- }
-
-end
diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb
deleted file mode 100644
index a0709b6352..0000000000
--- a/lib/rdoc/markdown.rb
+++ /dev/null
@@ -1,16783 +0,0 @@
-# coding: UTF-8
-# frozen_string_literal: true
-# :markup: markdown
-
-##
-# RDoc::Markdown as described by the [markdown syntax][syntax].
-#
-# To choose Markdown as your only default format see
-# RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
-# file to store your project default.
-#
-# ## Usage
-#
-# Here is a brief example of using this parse to read a markdown file by hand.
-#
-# data = File.read("README.md")
-# formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
-# html = RDoc::Markdown.parse(data).accept(formatter)
-#
-# # do something with html
-#
-# ## Extensions
-#
-# The following markdown extensions are supported by the parser, but not all
-# are used in RDoc output by default.
-#
-# ### RDoc
-#
-# The RDoc Markdown parser has the following built-in behaviors that cannot be
-# disabled.
-#
-# Underscores embedded in words are never interpreted as emphasis. (While the
-# [markdown dingus][dingus] emphasizes in-word underscores, neither the
-# Markdown syntax nor MarkdownTest mention this behavior.)
-#
-# For HTML output, RDoc always auto-links bare URLs.
-#
-# ### Break on Newline
-#
-# The break_on_newline extension converts all newlines into hard line breaks
-# as in [Github Flavored Markdown][GFM]. This extension is disabled by
-# default.
-#
-# ### CSS
-#
-# The #css extension enables CSS blocks to be included in the output, but they
-# are not used for any built-in RDoc output format. This extension is disabled
-# by default.
-#
-# Example:
-#
-# <style type="text/css">
-# h1 { font-size: 3em }
-# </style>
-#
-# ### Definition Lists
-#
-# The definition_lists extension allows definition lists using the [PHP
-# Markdown Extra syntax][PHPE], but only one label and definition are supported
-# at this time. This extension is enabled by default.
-#
-# Example:
-#
-# ```
-# cat
-# : A small furry mammal
-# that seems to sleep a lot
-#
-# ant
-# : A little insect that is known
-# to enjoy picnics
-#
-# ```
-#
-# Produces:
-#
-# cat
-# : A small furry mammal
-# that seems to sleep a lot
-#
-# ant
-# : A little insect that is known
-# to enjoy picnics
-#
-# ### Strike
-#
-# Example:
-#
-# ```
-# This is ~~striked~~.
-# ```
-#
-# Produces:
-#
-# This is ~~striked~~.
-#
-# ### Github
-#
-# The #github extension enables a partial set of [Github Flavored Markdown]
-# [GFM]. This extension is enabled by default.
-#
-# Supported github extensions include:
-#
-# #### Fenced code blocks
-#
-# Use ` ``` ` around a block of code instead of indenting it four spaces.
-#
-# #### Syntax highlighting
-#
-# Use ` ``` ruby ` as the start of a code fence to add syntax highlighting.
-# (Currently only `ruby` syntax is supported).
-#
-# ### HTML
-#
-# Enables raw HTML to be included in the output. This extension is enabled by
-# default.
-#
-# Example:
-#
-# <table>
-# ...
-# </table>
-#
-# ### Notes
-#
-# The #notes extension enables footnote support. This extension is enabled by
-# default.
-#
-# Example:
-#
-# Here is some text[^1] including an inline footnote ^[for short footnotes]
-#
-# ...
-#
-# [^1]: With the footnote text down at the bottom
-#
-# Produces:
-#
-# Here is some text[^1] including an inline footnote ^[for short footnotes]
-#
-# [^1]: With the footnote text down at the bottom
-#
-# ## Limitations
-#
-# * Link titles are not used
-# * Footnotes are collapsed into a single paragraph
-#
-# ## Author
-#
-# This markdown parser is a port to kpeg from [peg-markdown][pegmarkdown] by
-# John MacFarlane.
-#
-# It is used under the MIT license:
-#
-# 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.
-#
-# The port to kpeg was performed by Eric Hodel and Evan Phoenix
-#
-# [dingus]: http://daringfireball.net/projects/markdown/dingus
-# [GFM]: https://github.github.com/gfm/
-# [pegmarkdown]: https://github.com/jgm/peg-markdown
-# [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
-# [syntax]: http://daringfireball.net/projects/markdown/syntax
-#--
-# Last updated to jgm/peg-markdown commit 8f8fc22ef0
-class RDoc::Markdown
- # :stopdoc:
-
- # This is distinct from setup_parser so that a standalone parser
- # can redefine #initialize and still have access to the proper
- # parser setup code.
- def initialize(str, debug=false)
- setup_parser(str, debug)
- end
-
-
-
- # Prepares for parsing +str+. If you define a custom initialize you must
- # call this method before #parse
- def setup_parser(str, debug=false)
- set_string str, 0
- @memoizations = Hash.new { |h,k| h[k] = {} }
- @result = nil
- @failed_rule = nil
- @failing_rule_offset = -1
- @line_offsets = nil
-
- setup_foreign_grammar
- end
-
- attr_reader :string
- attr_reader :failing_rule_offset
- attr_accessor :result, :pos
-
- def current_column(target=pos)
- if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
- return target - c
- elsif c = string.rindex("\n", target)
- return target - c
- end
-
- target + 1
- end
-
- def position_line_offsets
- unless @position_line_offsets
- @position_line_offsets = []
- total = 0
- string.each_line do |line|
- total += line.size
- @position_line_offsets << total
- end
- end
- @position_line_offsets
- end
-
- if [].respond_to? :bsearch_index
- def current_line(target=pos)
- if line = position_line_offsets.bsearch_index {|x| x > target }
- return line + 1
- end
- raise "Target position #{target} is outside of string"
- end
- else
- def current_line(target=pos)
- if line = position_line_offsets.index {|x| x > target }
- return line + 1
- end
-
- raise "Target position #{target} is outside of string"
- end
- end
-
- def current_character(target=pos)
- if target < 0 || target >= string.size
- raise "Target position #{target} is outside of string"
- end
- string[target, 1]
- end
-
- KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
-
- def current_pos_info(target=pos)
- l = current_line target
- c = current_column target
- ln = get_line(l-1)
- chr = string[target,1]
- KpegPosInfo.new(target, l, c, ln, chr)
- end
-
- def lines
- string.lines
- end
-
- def get_line(no)
- loff = position_line_offsets
- if no < 0
- raise "Line No is out of range: #{no} < 0"
- elsif no >= loff.size
- raise "Line No is out of range: #{no} >= #{loff.size}"
- end
- lend = loff[no]-1
- lstart = no > 0 ? loff[no-1] : 0
- string[lstart..lend]
- end
-
-
-
- def get_text(start)
- @string[start..@pos-1]
- end
-
- # Sets the string and current parsing position for the parser.
- def set_string string, pos
- @string = string
- @string_size = string ? string.size : 0
- @pos = pos
- @position_line_offsets = nil
- end
-
- def show_pos
- width = 10
- if @pos < width
- "#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
- else
- "#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
- end
- end
-
- def failure_info
- l = current_line @failing_rule_offset
- c = current_column @failing_rule_offset
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- "line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
- else
- "line #{l}, column #{c}: failed rule '#{@failed_rule}'"
- end
- end
-
- def failure_caret
- p = current_pos_info @failing_rule_offset
- "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
- end
-
- def failure_character
- current_character @failing_rule_offset
- end
-
- def failure_oneline
- p = current_pos_info @failing_rule_offset
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
- else
- "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
- end
- end
-
- class ParseError < RuntimeError
- end
-
- def raise_error
- raise ParseError, failure_oneline
- end
-
- def show_error(io=STDOUT)
- error_pos = @failing_rule_offset
- p = current_pos_info(error_pos)
-
- io.puts "On line #{p.lno}, column #{p.col}:"
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
- else
- io.puts "Failed to match rule '#{@failed_rule}'"
- end
-
- io.puts "Got: #{p.char.inspect}"
- io.puts "=> #{p.line}"
- io.print(" " * (p.col + 2))
- io.puts "^"
- end
-
- def set_failed_rule(name)
- if @pos > @failing_rule_offset
- @failed_rule = name
- @failing_rule_offset = @pos
- end
- end
-
- attr_reader :failed_rule
-
- def match_string(str)
- len = str.size
- if @string[pos,len] == str
- @pos += len
- return str
- end
-
- return nil
- end
-
- def scan(reg)
- if m = reg.match(@string, @pos)
- @pos = m.end(0)
- return true
- end
-
- return nil
- end
-
- if "".respond_to? :ord
- def get_byte
- if @pos >= @string_size
- return nil
- end
-
- s = @string[@pos].ord
- @pos += 1
- s
- end
- else
- def get_byte
- if @pos >= @string_size
- return nil
- end
-
- s = @string[@pos]
- @pos += 1
- s
- end
- end
-
- def parse(rule=nil)
- # We invoke the rules indirectly via apply
- # instead of by just calling them as methods because
- # if the rules use left recursion, apply needs to
- # manage that.
-
- if !rule
- apply(:_root)
- else
- method = rule.gsub("-","_hyphen_")
- apply :"_#{method}"
- end
- end
-
- class MemoEntry
- def initialize(ans, pos)
- @ans = ans
- @pos = pos
- @result = nil
- @set = false
- @left_rec = false
- end
-
- attr_reader :ans, :pos, :result, :set
- attr_accessor :left_rec
-
- def move!(ans, pos, result)
- @ans = ans
- @pos = pos
- @result = result
- @set = true
- @left_rec = false
- end
- end
-
- def external_invoke(other, rule, *args)
- old_pos = @pos
- old_string = @string
-
- set_string other.string, other.pos
-
- begin
- if val = __send__(rule, *args)
- other.pos = @pos
- other.result = @result
- else
- other.set_failed_rule "#{self.class}##{rule}"
- end
- val
- ensure
- set_string old_string, old_pos
- end
- end
-
- def apply_with_args(rule, *args)
- @result = nil
- memo_key = [rule, args]
- if m = @memoizations[memo_key][@pos]
- @pos = m.pos
- if !m.set
- m.left_rec = true
- return nil
- end
-
- @result = m.result
-
- return m.ans
- else
- m = MemoEntry.new(nil, @pos)
- @memoizations[memo_key][@pos] = m
- start_pos = @pos
-
- ans = __send__ rule, *args
-
- lr = m.left_rec
-
- m.move! ans, @pos, @result
-
- # Don't bother trying to grow the left recursion
- # if it's failing straight away (thus there is no seed)
- if ans and lr
- return grow_lr(rule, args, start_pos, m)
- else
- return ans
- end
- end
- end
-
- def apply(rule)
- @result = nil
- if m = @memoizations[rule][@pos]
- @pos = m.pos
- if !m.set
- m.left_rec = true
- return nil
- end
-
- @result = m.result
-
- return m.ans
- else
- m = MemoEntry.new(nil, @pos)
- @memoizations[rule][@pos] = m
- start_pos = @pos
-
- ans = __send__ rule
-
- lr = m.left_rec
-
- m.move! ans, @pos, @result
-
- # Don't bother trying to grow the left recursion
- # if it's failing straight away (thus there is no seed)
- if ans and lr
- return grow_lr(rule, nil, start_pos, m)
- else
- return ans
- end
- end
- end
-
- def grow_lr(rule, args, start_pos, m)
- while true
- @pos = start_pos
- @result = m.result
-
- if args
- ans = __send__ rule, *args
- else
- ans = __send__ rule
- end
- return nil unless ans
-
- break if @pos <= m.pos
-
- m.move! ans, @pos, @result
- end
-
- @result = m.result
- @pos = m.pos
- return m.ans
- end
-
- class RuleInfo
- def initialize(name, rendered)
- @name = name
- @rendered = rendered
- end
-
- attr_reader :name, :rendered
- end
-
- def self.rule_info(name, rendered)
- RuleInfo.new(name, rendered)
- end
-
-
- # :startdoc:
-
-
-
- require_relative '../rdoc'
- require_relative 'markup/to_joined_paragraph'
- require_relative 'markdown/entities'
-
- require_relative 'markdown/literals'
-
- ##
- # Supported extensions
-
- EXTENSIONS = []
-
- ##
- # Extensions enabled by default
-
- DEFAULT_EXTENSIONS = [
- :definition_lists,
- :github,
- :html,
- :notes,
- :strike,
- ]
-
- # :section: Extensions
-
- ##
- # Creates extension methods for the `name` extension to enable and disable
- # the extension and to query if they are active.
-
- def self.extension name
- EXTENSIONS << name
-
- define_method "#{name}?" do
- extension? name
- end
-
- define_method "#{name}=" do |enable|
- extension name, enable
- end
- end
-
- ##
- # Converts all newlines into hard breaks
-
- extension :break_on_newline
-
- ##
- # Allow style blocks
-
- extension :css
-
- ##
- # Allow PHP Markdown Extras style definition lists
-
- extension :definition_lists
-
- ##
- # Allow Github Flavored Markdown
-
- extension :github
-
- ##
- # Allow HTML
-
- extension :html
-
- ##
- # Enables the notes extension
-
- extension :notes
-
- ##
- # Enables the strike extension
-
- extension :strike
-
- # :section:
-
- ##
- # Parses the `markdown` document into an RDoc::Document using the default
- # extensions.
-
- def self.parse markdown
- parser = new
-
- parser.parse markdown
- end
-
- # TODO remove when kpeg 0.10 is released
- alias orig_initialize initialize # :nodoc:
-
- ##
- # Creates a new markdown parser that enables the given +extensions+.
-
- def initialize extensions = DEFAULT_EXTENSIONS, debug = false
- @debug = debug
- @formatter = RDoc::Markup::ToJoinedParagraph.new
- @extensions = extensions
-
- @references = nil
- @unlinked_references = nil
-
- @footnotes = nil
- @note_order = nil
- end
-
- ##
- # Wraps `text` in emphasis for rdoc inline formatting
-
- def emphasis text
- if text =~ /\A[a-z\d.\/]+\z/i then
- "_#{text}_"
- else
- "<em>#{text}</em>"
- end
- end
-
- ##
- # :category: Extensions
- #
- # Is the extension `name` enabled?
-
- def extension? name
- @extensions.include? name
- end
-
- ##
- # :category: Extensions
- #
- # Enables or disables the extension with `name`
-
- def extension name, enable
- if enable then
- @extensions |= [name]
- else
- @extensions -= [name]
- end
- end
-
- ##
- # Parses `text` in a clone of this parser. This is used for handling nested
- # lists the same way as markdown_parser.
-
- def inner_parse text # :nodoc:
- parser = clone
-
- parser.setup_parser text, @debug
-
- parser.peg_parse
-
- doc = parser.result
-
- doc.accept @formatter
-
- doc.parts
- end
-
- ##
- # Finds a link reference for `label` and creates a new link to it with
- # `content` as the link text. If `label` was not encountered in the
- # reference-gathering parser pass the label and content are reconstructed
- # with the linking `text` (usually whitespace).
-
- def link_to content, label = content, text = nil
- raise ParseError, 'enable notes extension' if
- content.start_with? '^' and label.equal? content
-
- if ref = @references[label] then
- "{#{content}}[#{ref}]"
- elsif label.equal? content then
- "[#{content}]#{text}"
- else
- "[#{content}]#{text}[#{label}]"
- end
- end
-
- ##
- # Creates an RDoc::Markup::ListItem by parsing the `unparsed` content from
- # the first parsing pass.
-
- def list_item_from unparsed
- parsed = inner_parse unparsed.join
- RDoc::Markup::ListItem.new nil, *parsed
- end
-
- ##
- # Stores `label` as a note and fills in previously unknown note references.
-
- def note label
- #foottext = "rdoc-label:foottext-#{label}:footmark-#{label}"
-
- #ref.replace foottext if ref = @unlinked_notes.delete(label)
-
- @notes[label] = foottext
-
- #"{^1}[rdoc-label:footmark-#{label}:foottext-#{label}] "
- end
-
- ##
- # Creates a new link for the footnote `reference` and adds the reference to
- # the note order list for proper display at the end of the document.
-
- def note_for ref
- @note_order << ref
-
- label = @note_order.length
-
- "{*#{label}}[rdoc-label:foottext-#{label}:footmark-#{label}]"
- end
-
- ##
- # The internal kpeg parse method
-
- alias peg_parse parse # :nodoc:
-
- ##
- # Creates an RDoc::Markup::Paragraph from `parts` and including
- # extension-specific behavior
-
- def paragraph parts
- parts = parts.map do |part|
- if "\n" == part then
- RDoc::Markup::HardBreak.new
- else
- part
- end
- end if break_on_newline?
-
- RDoc::Markup::Paragraph.new(*parts)
- end
-
- ##
- # Parses `markdown` into an RDoc::Document
-
- def parse markdown
- @references = {}
- @unlinked_references = {}
-
- markdown += "\n\n"
-
- setup_parser markdown, @debug
- peg_parse 'References'
-
- if notes? then
- @footnotes = {}
-
- setup_parser markdown, @debug
- peg_parse 'Notes'
-
- # using note_order on the first pass would be a bug
- @note_order = []
- end
-
- setup_parser markdown, @debug
- peg_parse
-
- doc = result
-
- if notes? and not @footnotes.empty? then
- doc << RDoc::Markup::Rule.new(1)
-
- @note_order.each_with_index do |ref, index|
- label = index + 1
- note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
-
- link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
- note.parts.unshift link
-
- doc << note
- end
- end
-
- doc.accept @formatter
-
- doc
- end
-
- ##
- # Stores `label` as a reference to `link` and fills in previously unknown
- # link references.
-
- def reference label, link
- if ref = @unlinked_references.delete(label) then
- ref.replace link
- end
-
- @references[label] = link
- end
-
- ##
- # Wraps `text` in strong markup for rdoc inline formatting
-
- def strong text
- if text =~ /\A[a-z\d.\/-]+\z/i then
- "*#{text}*"
- else
- "<b>#{text}</b>"
- end
- end
-
- ##
- # Wraps `text` in strike markup for rdoc inline formatting
-
- def strike text
- if text =~ /\A[a-z\d.\/-]+\z/i then
- "~#{text}~"
- else
- "<s>#{text}</s>"
- end
- end
-
-
- # :stopdoc:
- def setup_foreign_grammar
- @_grammar_literals = RDoc::Markdown::Literals.new(nil)
- end
-
- # root = Doc
- def _root
- _tmp = apply(:_Doc)
- set_failed_rule :_root unless _tmp
- return _tmp
- end
-
- # Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }
- def _Doc
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = apply(:_BOM)
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _ary = []
- while true
- _tmp = apply(:_Block)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Document.new(*a.compact) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Doc unless _tmp
- return _tmp
- end
-
- # Block = @BlankLine* (BlockQuote | Verbatim | CodeFence | Table | Note | Reference | HorizontalRule | Heading | OrderedList | BulletList | DefinitionList | HtmlBlock | StyleBlock | Para | Plain)
- def _Block
-
- _save = self.pos
- while true # sequence
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_BlockQuote)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Verbatim)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_CodeFence)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Table)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Note)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Reference)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_HorizontalRule)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Heading)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_OrderedList)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_BulletList)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_DefinitionList)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_HtmlBlock)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_StyleBlock)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Para)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_Plain)
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Block unless _tmp
- return _tmp
- end
-
- # Para = @NonindentSpace Inlines:a @BlankLine+ { paragraph a }
- def _Para
-
- _save = self.pos
- while true # sequence
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Inlines)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; paragraph a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Para unless _tmp
- return _tmp
- end
-
- # Plain = Inlines:a { paragraph a }
- def _Plain
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Inlines)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; paragraph a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Plain unless _tmp
- return _tmp
- end
-
- # AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline
- def _AtxInline
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = scan(/\G(?-mix:#*)/)
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save2
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Inline)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_AtxInline unless _tmp
- return _tmp
- end
-
- # AtxStart = < /\#{1,6}/ > { text.length }
- def _AtxStart
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:\#{1,6})/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text.length ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_AtxStart unless _tmp
- return _tmp
- end
-
- # AtxHeading = AtxStart:s @Sp AtxInline+:a (@Sp /#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }
- def _AtxHeading
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_AtxStart)
- s = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _ary = []
- _tmp = apply(:_AtxInline)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_AtxInline)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = scan(/\G(?-mix:#*)/)
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- unless _tmp
- _tmp = true
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Heading.new(s, a.join) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_AtxHeading unless _tmp
- return _tmp
- end
-
- # SetextHeading = (SetextHeading1 | SetextHeading2)
- def _SetextHeading
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_SetextHeading1)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_SetextHeading2)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_SetextHeading unless _tmp
- return _tmp
- end
-
- # SetextBottom1 = /={1,}/ @Newline
- def _SetextBottom1
-
- _save = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:={1,})/)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_SetextBottom1 unless _tmp
- return _tmp
- end
-
- # SetextBottom2 = /-{1,}/ @Newline
- def _SetextBottom2
-
- _save = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:-{1,})/)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_SetextBottom2 unless _tmp
- return _tmp
- end
-
- # SetextHeading1 = &(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) }
- def _SetextHeading1
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = _RawLine()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = apply(:_SetextBottom1)
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save6 = self.pos
- while true # sequence
- _save7 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save6
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save3
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_SetextBottom1)
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Heading.new(1, a.join) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_SetextHeading1 unless _tmp
- return _tmp
- end
-
- # SetextHeading2 = &(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) }
- def _SetextHeading2
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = _RawLine()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = apply(:_SetextBottom2)
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save6 = self.pos
- while true # sequence
- _save7 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save6
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save3
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_SetextBottom2)
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Heading.new(2, a.join) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_SetextHeading2 unless _tmp
- return _tmp
- end
-
- # Heading = (SetextHeading | AtxHeading)
- def _Heading
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_SetextHeading)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_AtxHeading)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Heading unless _tmp
- return _tmp
- end
-
- # BlockQuote = BlockQuoteRaw:a { RDoc::Markup::BlockQuote.new(*a) }
- def _BlockQuote
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_BlockQuoteRaw)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::BlockQuote.new(*a) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_BlockQuote unless _tmp
- return _tmp
- end
-
- # BlockQuoteRaw = @StartList:a (">" " "? Line:l { a << l } (!">" !@BlankLine Line:c { a << c })* (@BlankLine:n { a << n })*)+ { inner_parse a.join }
- def _BlockQuoteRaw
-
- _save = self.pos
- while true # sequence
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save2
- break
- end
- _save3 = self.pos
- _tmp = match_string(" ")
- unless _tmp
- _tmp = true
- self.pos = _save3
- end
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = apply(:_Line)
- l = @result
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- break
- end
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _save7 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_Line)
- c = @result
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; a << c ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save2
- break
- end
- while true
-
- _save9 = self.pos
- while true # sequence
- _tmp = _BlankLine()
- n = @result
- unless _tmp
- self.pos = _save9
- break
- end
- @result = begin; a << n ; end
- _tmp = true
- unless _tmp
- self.pos = _save9
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save10 = self.pos
- while true # sequence
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save10
- break
- end
- _save11 = self.pos
- _tmp = match_string(" ")
- unless _tmp
- _tmp = true
- self.pos = _save11
- end
- unless _tmp
- self.pos = _save10
- break
- end
- _tmp = apply(:_Line)
- l = @result
- unless _tmp
- self.pos = _save10
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save10
- break
- end
- while true
-
- _save13 = self.pos
- while true # sequence
- _save14 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save14
- unless _tmp
- self.pos = _save13
- break
- end
- _save15 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save15
- unless _tmp
- self.pos = _save13
- break
- end
- _tmp = apply(:_Line)
- c = @result
- unless _tmp
- self.pos = _save13
- break
- end
- @result = begin; a << c ; end
- _tmp = true
- unless _tmp
- self.pos = _save13
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save10
- break
- end
- while true
-
- _save17 = self.pos
- while true # sequence
- _tmp = _BlankLine()
- n = @result
- unless _tmp
- self.pos = _save17
- break
- end
- @result = begin; a << n ; end
- _tmp = true
- unless _tmp
- self.pos = _save17
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; inner_parse a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_BlockQuoteRaw unless _tmp
- return _tmp
- end
-
- # NonblankIndentedLine = !@BlankLine IndentedLine
- def _NonblankIndentedLine
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_IndentedLine)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_NonblankIndentedLine unless _tmp
- return _tmp
- end
-
- # VerbatimChunk = @BlankLine*:a NonblankIndentedLine+:b { a.concat b }
- def _VerbatimChunk
-
- _save = self.pos
- while true # sequence
- _ary = []
- while true
- _tmp = _BlankLine()
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _ary = []
- _tmp = apply(:_NonblankIndentedLine)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_NonblankIndentedLine)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save2
- end
- b = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a.concat b ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_VerbatimChunk unless _tmp
- return _tmp
- end
-
- # Verbatim = VerbatimChunk+:a { RDoc::Markup::Verbatim.new(*a.flatten) }
- def _Verbatim
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _ary = []
- _tmp = apply(:_VerbatimChunk)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_VerbatimChunk)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Verbatim.new(*a.flatten) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Verbatim unless _tmp
- return _tmp
- end
-
- # HorizontalRule = @NonindentSpace ("*" @Sp "*" @Sp "*" (@Sp "*")* | "-" @Sp "-" @Sp "-" (@Sp "-")* | "_" @Sp "_" @Sp "_" (@Sp "_")*) @Sp @Newline @BlankLine+ { RDoc::Markup::Rule.new 1 }
- def _HorizontalRule
-
- _save = self.pos
- while true # sequence
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save2
- break
- end
- while true
-
- _save4 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string("-")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = match_string("-")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = match_string("-")
- unless _tmp
- self.pos = _save5
- break
- end
- while true
-
- _save7 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = match_string("-")
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save8 = self.pos
- while true # sequence
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save8
- break
- end
- while true
-
- _save10 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save10
- break
- end
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- _save11 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save11
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::Rule.new 1 ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HorizontalRule unless _tmp
- return _tmp
- end
-
- # Bullet = !HorizontalRule @NonindentSpace /[+*-]/ @Spacechar+
- def _Bullet
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = apply(:_HorizontalRule)
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = scan(/\G(?-mix:[+*-])/)
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = _Spacechar()
- if _tmp
- while true
- _tmp = _Spacechar()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Bullet unless _tmp
- return _tmp
- end
-
- # BulletList = &Bullet (ListTight | ListLoose):a { RDoc::Markup::List.new(:BULLET, *a) }
- def _BulletList
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = apply(:_Bullet)
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_ListTight)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_ListLoose)
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::List.new(:BULLET, *a) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_BulletList unless _tmp
- return _tmp
- end
-
- # ListTight = ListItemTight+:a @BlankLine* !(Bullet | Enumerator) { a }
- def _ListTight
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _ary = []
- _tmp = apply(:_ListItemTight)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_ListItemTight)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _save3 = self.pos
-
- _save4 = self.pos
- while true # choice
- _tmp = apply(:_Bullet)
- break if _tmp
- self.pos = _save4
- _tmp = apply(:_Enumerator)
- break if _tmp
- self.pos = _save4
- break
- end # end choice
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListTight unless _tmp
- return _tmp
- end
-
- # ListLoose = @StartList:a (ListItem:b @BlankLine* { a << b })+ { a }
- def _ListLoose
-
- _save = self.pos
- while true # sequence
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = apply(:_ListItem)
- b = @result
- unless _tmp
- self.pos = _save2
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save4 = self.pos
- while true # sequence
- _tmp = apply(:_ListItem)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListLoose unless _tmp
- return _tmp
- end
-
- # ListItem = (Bullet | Enumerator) @StartList:a ListBlock:b { a << b } (ListContinuationBlock:c { a.push(*c) })* { list_item_from a }
- def _ListItem
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_Bullet)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_Enumerator)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_ListBlock)
- b = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save3 = self.pos
- while true # sequence
- _tmp = apply(:_ListContinuationBlock)
- c = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a.push(*c) ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; list_item_from a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListItem unless _tmp
- return _tmp
- end
-
- # ListItemTight = (Bullet | Enumerator) ListBlock:a (!@BlankLine ListContinuationBlock:b { a.push(*b) })* !ListContinuationBlock { list_item_from a }
- def _ListItemTight
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_Bullet)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_Enumerator)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_ListBlock)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_ListContinuationBlock)
- b = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a.push(*b) ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _save5 = self.pos
- _tmp = apply(:_ListContinuationBlock)
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; list_item_from a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListItemTight unless _tmp
- return _tmp
- end
-
- # ListBlock = !@BlankLine Line:a ListBlockLine*:c { [a, *c] }
- def _ListBlock
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Line)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _ary = []
- while true
- _tmp = apply(:_ListBlockLine)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- c = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; [a, *c] ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListBlock unless _tmp
- return _tmp
- end
-
- # ListContinuationBlock = @StartList:a @BlankLine* { a << "\n" } (Indent ListBlock:b { a.concat b })+ { a }
- def _ListContinuationBlock
-
- _save = self.pos
- while true # sequence
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a << "\n" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = apply(:_Indent)
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_ListBlock)
- b = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a.concat b ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save4 = self.pos
- while true # sequence
- _tmp = apply(:_Indent)
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_ListBlock)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a.concat b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListContinuationBlock unless _tmp
- return _tmp
- end
-
- # Enumerator = @NonindentSpace [0-9]+ "." @Spacechar+
- def _Enumerator
-
- _save = self.pos
- while true # sequence
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _save2 = self.pos
- _tmp = get_byte
- if _tmp
- unless _tmp >= 48 and _tmp <= 57
- self.pos = _save2
- _tmp = nil
- end
- end
- if _tmp
- while true
- _save3 = self.pos
- _tmp = get_byte
- if _tmp
- unless _tmp >= 48 and _tmp <= 57
- self.pos = _save3
- _tmp = nil
- end
- end
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(".")
- unless _tmp
- self.pos = _save
- break
- end
- _save4 = self.pos
- _tmp = _Spacechar()
- if _tmp
- while true
- _tmp = _Spacechar()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save4
- end
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Enumerator unless _tmp
- return _tmp
- end
-
- # OrderedList = &Enumerator (ListTight | ListLoose):a { RDoc::Markup::List.new(:NUMBER, *a) }
- def _OrderedList
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = apply(:_Enumerator)
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_ListTight)
- break if _tmp
- self.pos = _save2
- _tmp = apply(:_ListLoose)
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::List.new(:NUMBER, *a) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_OrderedList unless _tmp
- return _tmp
- end
-
- # ListBlockLine = !@BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule OptionallyIndentedLine
- def _ListBlockLine
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_Indent)
- unless _tmp
- _tmp = true
- self.pos = _save4
- end
- unless _tmp
- self.pos = _save3
- break
- end
-
- _save5 = self.pos
- while true # choice
- _tmp = apply(:_Bullet)
- break if _tmp
- self.pos = _save5
- _tmp = apply(:_Enumerator)
- break if _tmp
- self.pos = _save5
- break
- end # end choice
-
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save2
- unless _tmp
- self.pos = _save
- break
- end
- _save6 = self.pos
- _tmp = apply(:_HorizontalRule)
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_OptionallyIndentedLine)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ListBlockLine unless _tmp
- return _tmp
- end
-
- # HtmlOpenAnchor = "<" Spnl ("a" | "A") Spnl HtmlAttribute* ">"
- def _HtmlOpenAnchor
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("a")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("A")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlOpenAnchor unless _tmp
- return _tmp
- end
-
- # HtmlCloseAnchor = "<" Spnl "/" ("a" | "A") Spnl ">"
- def _HtmlCloseAnchor
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("a")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("A")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlCloseAnchor unless _tmp
- return _tmp
- end
-
- # HtmlAnchor = HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor
- def _HtmlAnchor
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlOpenAnchor)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlAnchor)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlCloseAnchor)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlCloseAnchor)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlAnchor unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenAddress = "<" Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenAddress
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("address")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("ADDRESS")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenAddress unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseAddress = "<" Spnl "/" ("address" | "ADDRESS") Spnl ">"
- def _HtmlBlockCloseAddress
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("address")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("ADDRESS")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseAddress unless _tmp
- return _tmp
- end
-
- # HtmlBlockAddress = HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress
- def _HtmlBlockAddress
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenAddress)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockAddress)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseAddress)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseAddress)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockAddress unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenBlockquote = "<" Spnl ("blockquote" | "BLOCKQUOTE") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenBlockquote
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("blockquote")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("BLOCKQUOTE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenBlockquote unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseBlockquote = "<" Spnl "/" ("blockquote" | "BLOCKQUOTE") Spnl ">"
- def _HtmlBlockCloseBlockquote
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("blockquote")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("BLOCKQUOTE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseBlockquote unless _tmp
- return _tmp
- end
-
- # HtmlBlockBlockquote = HtmlBlockOpenBlockquote (HtmlBlockBlockquote | !HtmlBlockCloseBlockquote .)* HtmlBlockCloseBlockquote
- def _HtmlBlockBlockquote
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenBlockquote)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockBlockquote)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseBlockquote)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseBlockquote)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockBlockquote unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenCenter = "<" Spnl ("center" | "CENTER") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenCenter
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("center")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("CENTER")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenCenter unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseCenter = "<" Spnl "/" ("center" | "CENTER") Spnl ">"
- def _HtmlBlockCloseCenter
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("center")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("CENTER")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseCenter unless _tmp
- return _tmp
- end
-
- # HtmlBlockCenter = HtmlBlockOpenCenter (HtmlBlockCenter | !HtmlBlockCloseCenter .)* HtmlBlockCloseCenter
- def _HtmlBlockCenter
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenCenter)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockCenter)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseCenter)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseCenter)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCenter unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenDir = "<" Spnl ("dir" | "DIR") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenDir
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dir")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DIR")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenDir unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseDir = "<" Spnl "/" ("dir" | "DIR") Spnl ">"
- def _HtmlBlockCloseDir
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dir")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DIR")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseDir unless _tmp
- return _tmp
- end
-
- # HtmlBlockDir = HtmlBlockOpenDir (HtmlBlockDir | !HtmlBlockCloseDir .)* HtmlBlockCloseDir
- def _HtmlBlockDir
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenDir)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockDir)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseDir)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseDir)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockDir unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenDiv = "<" Spnl ("div" | "DIV") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenDiv
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("div")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DIV")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenDiv unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseDiv = "<" Spnl "/" ("div" | "DIV") Spnl ">"
- def _HtmlBlockCloseDiv
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("div")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DIV")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseDiv unless _tmp
- return _tmp
- end
-
- # HtmlBlockDiv = HtmlBlockOpenDiv (HtmlBlockDiv | !HtmlBlockCloseDiv .)* HtmlBlockCloseDiv
- def _HtmlBlockDiv
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenDiv)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockDiv)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseDiv)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseDiv)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockDiv unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenDl = "<" Spnl ("dl" | "DL") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenDl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dl")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenDl unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseDl = "<" Spnl "/" ("dl" | "DL") Spnl ">"
- def _HtmlBlockCloseDl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dl")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseDl unless _tmp
- return _tmp
- end
-
- # HtmlBlockDl = HtmlBlockOpenDl (HtmlBlockDl | !HtmlBlockCloseDl .)* HtmlBlockCloseDl
- def _HtmlBlockDl
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenDl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockDl)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseDl)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseDl)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockDl unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenFieldset = "<" Spnl ("fieldset" | "FIELDSET") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenFieldset
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("fieldset")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FIELDSET")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenFieldset unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseFieldset = "<" Spnl "/" ("fieldset" | "FIELDSET") Spnl ">"
- def _HtmlBlockCloseFieldset
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("fieldset")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FIELDSET")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseFieldset unless _tmp
- return _tmp
- end
-
- # HtmlBlockFieldset = HtmlBlockOpenFieldset (HtmlBlockFieldset | !HtmlBlockCloseFieldset .)* HtmlBlockCloseFieldset
- def _HtmlBlockFieldset
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenFieldset)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockFieldset)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseFieldset)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseFieldset)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockFieldset unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenForm = "<" Spnl ("form" | "FORM") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenForm
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("form")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FORM")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenForm unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseForm = "<" Spnl "/" ("form" | "FORM") Spnl ">"
- def _HtmlBlockCloseForm
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("form")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FORM")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseForm unless _tmp
- return _tmp
- end
-
- # HtmlBlockForm = HtmlBlockOpenForm (HtmlBlockForm | !HtmlBlockCloseForm .)* HtmlBlockCloseForm
- def _HtmlBlockForm
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenForm)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockForm)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseForm)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseForm)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockForm unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH1 = "<" Spnl ("h1" | "H1") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH1
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h1")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H1")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH1 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH1 = "<" Spnl "/" ("h1" | "H1") Spnl ">"
- def _HtmlBlockCloseH1
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h1")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H1")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH1 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH1 = HtmlBlockOpenH1 (HtmlBlockH1 | !HtmlBlockCloseH1 .)* HtmlBlockCloseH1
- def _HtmlBlockH1
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH1)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH1)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH1)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH1)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH1 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH2 = "<" Spnl ("h2" | "H2") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH2
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h2")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H2")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH2 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH2 = "<" Spnl "/" ("h2" | "H2") Spnl ">"
- def _HtmlBlockCloseH2
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h2")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H2")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH2 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH2 = HtmlBlockOpenH2 (HtmlBlockH2 | !HtmlBlockCloseH2 .)* HtmlBlockCloseH2
- def _HtmlBlockH2
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH2)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH2)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH2)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH2)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH2 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH3 = "<" Spnl ("h3" | "H3") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH3
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h3")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H3")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH3 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH3 = "<" Spnl "/" ("h3" | "H3") Spnl ">"
- def _HtmlBlockCloseH3
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h3")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H3")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH3 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH3 = HtmlBlockOpenH3 (HtmlBlockH3 | !HtmlBlockCloseH3 .)* HtmlBlockCloseH3
- def _HtmlBlockH3
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH3)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH3)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH3)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH3)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH3 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH4 = "<" Spnl ("h4" | "H4") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH4
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h4")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H4")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH4 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH4 = "<" Spnl "/" ("h4" | "H4") Spnl ">"
- def _HtmlBlockCloseH4
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h4")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H4")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH4 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH4 = HtmlBlockOpenH4 (HtmlBlockH4 | !HtmlBlockCloseH4 .)* HtmlBlockCloseH4
- def _HtmlBlockH4
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH4)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH4)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH4)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH4)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH4 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH5 = "<" Spnl ("h5" | "H5") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH5
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h5")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H5")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH5 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH5 = "<" Spnl "/" ("h5" | "H5") Spnl ">"
- def _HtmlBlockCloseH5
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h5")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H5")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH5 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH5 = HtmlBlockOpenH5 (HtmlBlockH5 | !HtmlBlockCloseH5 .)* HtmlBlockCloseH5
- def _HtmlBlockH5
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH5)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH5)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH5)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH5)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH5 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenH6 = "<" Spnl ("h6" | "H6") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenH6
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h6")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H6")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenH6 unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseH6 = "<" Spnl "/" ("h6" | "H6") Spnl ">"
- def _HtmlBlockCloseH6
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("h6")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("H6")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseH6 unless _tmp
- return _tmp
- end
-
- # HtmlBlockH6 = HtmlBlockOpenH6 (HtmlBlockH6 | !HtmlBlockCloseH6 .)* HtmlBlockCloseH6
- def _HtmlBlockH6
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenH6)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockH6)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseH6)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseH6)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockH6 unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenMenu = "<" Spnl ("menu" | "MENU") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenMenu
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("menu")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("MENU")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenMenu unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseMenu = "<" Spnl "/" ("menu" | "MENU") Spnl ">"
- def _HtmlBlockCloseMenu
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("menu")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("MENU")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseMenu unless _tmp
- return _tmp
- end
-
- # HtmlBlockMenu = HtmlBlockOpenMenu (HtmlBlockMenu | !HtmlBlockCloseMenu .)* HtmlBlockCloseMenu
- def _HtmlBlockMenu
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenMenu)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockMenu)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseMenu)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseMenu)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockMenu unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenNoframes = "<" Spnl ("noframes" | "NOFRAMES") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenNoframes
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("noframes")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("NOFRAMES")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenNoframes unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseNoframes = "<" Spnl "/" ("noframes" | "NOFRAMES") Spnl ">"
- def _HtmlBlockCloseNoframes
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("noframes")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("NOFRAMES")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseNoframes unless _tmp
- return _tmp
- end
-
- # HtmlBlockNoframes = HtmlBlockOpenNoframes (HtmlBlockNoframes | !HtmlBlockCloseNoframes .)* HtmlBlockCloseNoframes
- def _HtmlBlockNoframes
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenNoframes)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockNoframes)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseNoframes)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseNoframes)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockNoframes unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenNoscript = "<" Spnl ("noscript" | "NOSCRIPT") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenNoscript
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("noscript")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("NOSCRIPT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenNoscript unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseNoscript = "<" Spnl "/" ("noscript" | "NOSCRIPT") Spnl ">"
- def _HtmlBlockCloseNoscript
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("noscript")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("NOSCRIPT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseNoscript unless _tmp
- return _tmp
- end
-
- # HtmlBlockNoscript = HtmlBlockOpenNoscript (HtmlBlockNoscript | !HtmlBlockCloseNoscript .)* HtmlBlockCloseNoscript
- def _HtmlBlockNoscript
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenNoscript)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockNoscript)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseNoscript)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseNoscript)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockNoscript unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenOl = "<" Spnl ("ol" | "OL") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenOl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("ol")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("OL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenOl unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseOl = "<" Spnl "/" ("ol" | "OL") Spnl ">"
- def _HtmlBlockCloseOl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("ol")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("OL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseOl unless _tmp
- return _tmp
- end
-
- # HtmlBlockOl = HtmlBlockOpenOl (HtmlBlockOl | !HtmlBlockCloseOl .)* HtmlBlockCloseOl
- def _HtmlBlockOl
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenOl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockOl)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseOl)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseOl)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOl unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenP = "<" Spnl ("p" | "P") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenP
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("p")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("P")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenP unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseP = "<" Spnl "/" ("p" | "P") Spnl ">"
- def _HtmlBlockCloseP
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("p")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("P")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseP unless _tmp
- return _tmp
- end
-
- # HtmlBlockP = HtmlBlockOpenP (HtmlBlockP | !HtmlBlockCloseP .)* HtmlBlockCloseP
- def _HtmlBlockP
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenP)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockP)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseP)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseP)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockP unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenPre = "<" Spnl ("pre" | "PRE") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenPre
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("pre")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("PRE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenPre unless _tmp
- return _tmp
- end
-
- # HtmlBlockClosePre = "<" Spnl "/" ("pre" | "PRE") Spnl ">"
- def _HtmlBlockClosePre
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("pre")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("PRE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockClosePre unless _tmp
- return _tmp
- end
-
- # HtmlBlockPre = HtmlBlockOpenPre (HtmlBlockPre | !HtmlBlockClosePre .)* HtmlBlockClosePre
- def _HtmlBlockPre
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenPre)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockPre)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockClosePre)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockClosePre)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockPre unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTable = "<" Spnl ("table" | "TABLE") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTable
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("table")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TABLE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTable unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTable = "<" Spnl "/" ("table" | "TABLE") Spnl ">"
- def _HtmlBlockCloseTable
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("table")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TABLE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTable unless _tmp
- return _tmp
- end
-
- # HtmlBlockTable = HtmlBlockOpenTable (HtmlBlockTable | !HtmlBlockCloseTable .)* HtmlBlockCloseTable
- def _HtmlBlockTable
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTable)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTable)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTable)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTable)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTable unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenUl = "<" Spnl ("ul" | "UL") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenUl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("ul")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("UL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenUl unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseUl = "<" Spnl "/" ("ul" | "UL") Spnl ">"
- def _HtmlBlockCloseUl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("ul")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("UL")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseUl unless _tmp
- return _tmp
- end
-
- # HtmlBlockUl = HtmlBlockOpenUl (HtmlBlockUl | !HtmlBlockCloseUl .)* HtmlBlockCloseUl
- def _HtmlBlockUl
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenUl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockUl)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseUl)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseUl)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockUl unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenDd = "<" Spnl ("dd" | "DD") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenDd
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dd")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenDd unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseDd = "<" Spnl "/" ("dd" | "DD") Spnl ">"
- def _HtmlBlockCloseDd
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dd")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseDd unless _tmp
- return _tmp
- end
-
- # HtmlBlockDd = HtmlBlockOpenDd (HtmlBlockDd | !HtmlBlockCloseDd .)* HtmlBlockCloseDd
- def _HtmlBlockDd
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenDd)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockDd)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseDd)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseDd)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockDd unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenDt = "<" Spnl ("dt" | "DT") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenDt
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dt")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenDt unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseDt = "<" Spnl "/" ("dt" | "DT") Spnl ">"
- def _HtmlBlockCloseDt
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("dt")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("DT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseDt unless _tmp
- return _tmp
- end
-
- # HtmlBlockDt = HtmlBlockOpenDt (HtmlBlockDt | !HtmlBlockCloseDt .)* HtmlBlockCloseDt
- def _HtmlBlockDt
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenDt)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockDt)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseDt)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseDt)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockDt unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenFrameset = "<" Spnl ("frameset" | "FRAMESET") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenFrameset
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("frameset")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FRAMESET")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenFrameset unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseFrameset = "<" Spnl "/" ("frameset" | "FRAMESET") Spnl ">"
- def _HtmlBlockCloseFrameset
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("frameset")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("FRAMESET")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseFrameset unless _tmp
- return _tmp
- end
-
- # HtmlBlockFrameset = HtmlBlockOpenFrameset (HtmlBlockFrameset | !HtmlBlockCloseFrameset .)* HtmlBlockCloseFrameset
- def _HtmlBlockFrameset
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenFrameset)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockFrameset)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseFrameset)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseFrameset)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockFrameset unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenLi = "<" Spnl ("li" | "LI") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenLi
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("li")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("LI")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenLi unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseLi = "<" Spnl "/" ("li" | "LI") Spnl ">"
- def _HtmlBlockCloseLi
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("li")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("LI")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseLi unless _tmp
- return _tmp
- end
-
- # HtmlBlockLi = HtmlBlockOpenLi (HtmlBlockLi | !HtmlBlockCloseLi .)* HtmlBlockCloseLi
- def _HtmlBlockLi
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenLi)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockLi)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseLi)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseLi)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockLi unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTbody = "<" Spnl ("tbody" | "TBODY") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTbody
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tbody")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TBODY")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTbody unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTbody = "<" Spnl "/" ("tbody" | "TBODY") Spnl ">"
- def _HtmlBlockCloseTbody
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tbody")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TBODY")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTbody unless _tmp
- return _tmp
- end
-
- # HtmlBlockTbody = HtmlBlockOpenTbody (HtmlBlockTbody | !HtmlBlockCloseTbody .)* HtmlBlockCloseTbody
- def _HtmlBlockTbody
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTbody)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTbody)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTbody)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTbody)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTbody unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTd = "<" Spnl ("td" | "TD") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTd
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("td")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTd unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTd = "<" Spnl "/" ("td" | "TD") Spnl ">"
- def _HtmlBlockCloseTd
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("td")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTd unless _tmp
- return _tmp
- end
-
- # HtmlBlockTd = HtmlBlockOpenTd (HtmlBlockTd | !HtmlBlockCloseTd .)* HtmlBlockCloseTd
- def _HtmlBlockTd
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTd)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTd)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTd)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTd)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTd unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTfoot = "<" Spnl ("tfoot" | "TFOOT") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTfoot
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tfoot")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TFOOT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTfoot unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTfoot = "<" Spnl "/" ("tfoot" | "TFOOT") Spnl ">"
- def _HtmlBlockCloseTfoot
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tfoot")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TFOOT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTfoot unless _tmp
- return _tmp
- end
-
- # HtmlBlockTfoot = HtmlBlockOpenTfoot (HtmlBlockTfoot | !HtmlBlockCloseTfoot .)* HtmlBlockCloseTfoot
- def _HtmlBlockTfoot
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTfoot)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTfoot)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTfoot)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTfoot)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTfoot unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTh = "<" Spnl ("th" | "TH") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTh
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("th")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TH")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTh unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTh = "<" Spnl "/" ("th" | "TH") Spnl ">"
- def _HtmlBlockCloseTh
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("th")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TH")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTh unless _tmp
- return _tmp
- end
-
- # HtmlBlockTh = HtmlBlockOpenTh (HtmlBlockTh | !HtmlBlockCloseTh .)* HtmlBlockCloseTh
- def _HtmlBlockTh
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTh)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTh)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTh)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTh)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTh unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenThead = "<" Spnl ("thead" | "THEAD") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenThead
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("thead")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("THEAD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenThead unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseThead = "<" Spnl "/" ("thead" | "THEAD") Spnl ">"
- def _HtmlBlockCloseThead
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("thead")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("THEAD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseThead unless _tmp
- return _tmp
- end
-
- # HtmlBlockThead = HtmlBlockOpenThead (HtmlBlockThead | !HtmlBlockCloseThead .)* HtmlBlockCloseThead
- def _HtmlBlockThead
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenThead)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockThead)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseThead)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseThead)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockThead unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenTr = "<" Spnl ("tr" | "TR") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenTr
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tr")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TR")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenTr unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseTr = "<" Spnl "/" ("tr" | "TR") Spnl ">"
- def _HtmlBlockCloseTr
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("tr")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("TR")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseTr unless _tmp
- return _tmp
- end
-
- # HtmlBlockTr = HtmlBlockOpenTr (HtmlBlockTr | !HtmlBlockCloseTr .)* HtmlBlockCloseTr
- def _HtmlBlockTr
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenTr)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockTr)
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_HtmlBlockCloseTr)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseTr)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockTr unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenScript = "<" Spnl ("script" | "SCRIPT") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenScript
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("script")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("SCRIPT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenScript unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseScript = "<" Spnl "/" ("script" | "SCRIPT") Spnl ">"
- def _HtmlBlockCloseScript
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("script")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("SCRIPT")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseScript unless _tmp
- return _tmp
- end
-
- # HtmlBlockScript = HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript
- def _HtmlBlockScript
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenScript)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = apply(:_HtmlBlockCloseScript)
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseScript)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockScript unless _tmp
- return _tmp
- end
-
- # HtmlBlockOpenHead = "<" Spnl ("head" | "HEAD") Spnl HtmlAttribute* ">"
- def _HtmlBlockOpenHead
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("head")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("HEAD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockOpenHead unless _tmp
- return _tmp
- end
-
- # HtmlBlockCloseHead = "<" Spnl "/" ("head" | "HEAD") Spnl ">"
- def _HtmlBlockCloseHead
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("head")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("HEAD")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockCloseHead unless _tmp
- return _tmp
- end
-
- # HtmlBlockHead = HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead
- def _HtmlBlockHead
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_HtmlBlockOpenHead)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = apply(:_HtmlBlockCloseHead)
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockCloseHead)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockHead unless _tmp
- return _tmp
- end
-
- # HtmlBlockInTags = (HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript | HtmlBlockHead)
- def _HtmlBlockInTags
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_HtmlAnchor)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockAddress)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockBlockquote)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockCenter)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockDir)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockDiv)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockDl)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockFieldset)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockForm)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH1)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH2)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH3)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH4)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH5)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockH6)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockMenu)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockNoframes)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockNoscript)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockOl)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockP)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockPre)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTable)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockUl)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockDd)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockDt)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockFrameset)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockLi)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTbody)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTd)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTfoot)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTh)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockThead)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockTr)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockScript)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_HtmlBlockHead)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_HtmlBlockInTags unless _tmp
- return _tmp
- end
-
- # HtmlBlock = < (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) > @BlankLine+ { if html? then RDoc::Markup::Raw.new text end }
- def _HtmlBlock
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlockInTags)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_HtmlComment)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_HtmlBlockSelfClosing)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_HtmlUnclosed)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; if html? then
- RDoc::Markup::Raw.new text
- end ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlock unless _tmp
- return _tmp
- end
-
- # HtmlUnclosed = "<" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl ">"
- def _HtmlUnclosed
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlUnclosedType)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlUnclosed unless _tmp
- return _tmp
- end
-
- # HtmlUnclosedType = ("HR" | "hr")
- def _HtmlUnclosedType
-
- _save = self.pos
- while true # choice
- _tmp = match_string("HR")
- break if _tmp
- self.pos = _save
- _tmp = match_string("hr")
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_HtmlUnclosedType unless _tmp
- return _tmp
- end
-
- # HtmlBlockSelfClosing = "<" Spnl HtmlBlockType Spnl HtmlAttribute* "/" Spnl ">"
- def _HtmlBlockSelfClosing
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_HtmlBlockType)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlBlockSelfClosing unless _tmp
- return _tmp
- end
-
- # HtmlBlockType = ("ADDRESS" | "BLOCKQUOTE" | "CENTER" | "DD" | "DIR" | "DIV" | "DL" | "DT" | "FIELDSET" | "FORM" | "FRAMESET" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "HR" | "ISINDEX" | "LI" | "MENU" | "NOFRAMES" | "NOSCRIPT" | "OL" | "P" | "PRE" | "SCRIPT" | "TABLE" | "TBODY" | "TD" | "TFOOT" | "TH" | "THEAD" | "TR" | "UL" | "address" | "blockquote" | "center" | "dd" | "dir" | "div" | "dl" | "dt" | "fieldset" | "form" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "hr" | "isindex" | "li" | "menu" | "noframes" | "noscript" | "ol" | "p" | "pre" | "script" | "table" | "tbody" | "td" | "tfoot" | "th" | "thead" | "tr" | "ul")
- def _HtmlBlockType
-
- _save = self.pos
- while true # choice
- _tmp = match_string("ADDRESS")
- break if _tmp
- self.pos = _save
- _tmp = match_string("BLOCKQUOTE")
- break if _tmp
- self.pos = _save
- _tmp = match_string("CENTER")
- break if _tmp
- self.pos = _save
- _tmp = match_string("DD")
- break if _tmp
- self.pos = _save
- _tmp = match_string("DIR")
- break if _tmp
- self.pos = _save
- _tmp = match_string("DIV")
- break if _tmp
- self.pos = _save
- _tmp = match_string("DL")
- break if _tmp
- self.pos = _save
- _tmp = match_string("DT")
- break if _tmp
- self.pos = _save
- _tmp = match_string("FIELDSET")
- break if _tmp
- self.pos = _save
- _tmp = match_string("FORM")
- break if _tmp
- self.pos = _save
- _tmp = match_string("FRAMESET")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H1")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H2")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H3")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H4")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H5")
- break if _tmp
- self.pos = _save
- _tmp = match_string("H6")
- break if _tmp
- self.pos = _save
- _tmp = match_string("HR")
- break if _tmp
- self.pos = _save
- _tmp = match_string("ISINDEX")
- break if _tmp
- self.pos = _save
- _tmp = match_string("LI")
- break if _tmp
- self.pos = _save
- _tmp = match_string("MENU")
- break if _tmp
- self.pos = _save
- _tmp = match_string("NOFRAMES")
- break if _tmp
- self.pos = _save
- _tmp = match_string("NOSCRIPT")
- break if _tmp
- self.pos = _save
- _tmp = match_string("OL")
- break if _tmp
- self.pos = _save
- _tmp = match_string("P")
- break if _tmp
- self.pos = _save
- _tmp = match_string("PRE")
- break if _tmp
- self.pos = _save
- _tmp = match_string("SCRIPT")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TABLE")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TBODY")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TD")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TFOOT")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TH")
- break if _tmp
- self.pos = _save
- _tmp = match_string("THEAD")
- break if _tmp
- self.pos = _save
- _tmp = match_string("TR")
- break if _tmp
- self.pos = _save
- _tmp = match_string("UL")
- break if _tmp
- self.pos = _save
- _tmp = match_string("address")
- break if _tmp
- self.pos = _save
- _tmp = match_string("blockquote")
- break if _tmp
- self.pos = _save
- _tmp = match_string("center")
- break if _tmp
- self.pos = _save
- _tmp = match_string("dd")
- break if _tmp
- self.pos = _save
- _tmp = match_string("dir")
- break if _tmp
- self.pos = _save
- _tmp = match_string("div")
- break if _tmp
- self.pos = _save
- _tmp = match_string("dl")
- break if _tmp
- self.pos = _save
- _tmp = match_string("dt")
- break if _tmp
- self.pos = _save
- _tmp = match_string("fieldset")
- break if _tmp
- self.pos = _save
- _tmp = match_string("form")
- break if _tmp
- self.pos = _save
- _tmp = match_string("frameset")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h1")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h2")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h3")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h4")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h5")
- break if _tmp
- self.pos = _save
- _tmp = match_string("h6")
- break if _tmp
- self.pos = _save
- _tmp = match_string("hr")
- break if _tmp
- self.pos = _save
- _tmp = match_string("isindex")
- break if _tmp
- self.pos = _save
- _tmp = match_string("li")
- break if _tmp
- self.pos = _save
- _tmp = match_string("menu")
- break if _tmp
- self.pos = _save
- _tmp = match_string("noframes")
- break if _tmp
- self.pos = _save
- _tmp = match_string("noscript")
- break if _tmp
- self.pos = _save
- _tmp = match_string("ol")
- break if _tmp
- self.pos = _save
- _tmp = match_string("p")
- break if _tmp
- self.pos = _save
- _tmp = match_string("pre")
- break if _tmp
- self.pos = _save
- _tmp = match_string("script")
- break if _tmp
- self.pos = _save
- _tmp = match_string("table")
- break if _tmp
- self.pos = _save
- _tmp = match_string("tbody")
- break if _tmp
- self.pos = _save
- _tmp = match_string("td")
- break if _tmp
- self.pos = _save
- _tmp = match_string("tfoot")
- break if _tmp
- self.pos = _save
- _tmp = match_string("th")
- break if _tmp
- self.pos = _save
- _tmp = match_string("thead")
- break if _tmp
- self.pos = _save
- _tmp = match_string("tr")
- break if _tmp
- self.pos = _save
- _tmp = match_string("ul")
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_HtmlBlockType unless _tmp
- return _tmp
- end
-
- # StyleOpen = "<" Spnl ("style" | "STYLE") Spnl HtmlAttribute* ">"
- def _StyleOpen
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("style")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("STYLE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StyleOpen unless _tmp
- return _tmp
- end
-
- # StyleClose = "<" Spnl "/" ("style" | "STYLE") Spnl ">"
- def _StyleClose
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("/")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = match_string("style")
- break if _tmp
- self.pos = _save1
- _tmp = match_string("STYLE")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StyleClose unless _tmp
- return _tmp
- end
-
- # InStyleTags = StyleOpen (!StyleClose .)* StyleClose
- def _InStyleTags
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_StyleOpen)
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = apply(:_StyleClose)
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_StyleClose)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_InStyleTags unless _tmp
- return _tmp
- end
-
- # StyleBlock = < InStyleTags > @BlankLine* { if css? then RDoc::Markup::Raw.new text end }
- def _StyleBlock
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = apply(:_InStyleTags)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; if css? then
- RDoc::Markup::Raw.new text
- end ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StyleBlock unless _tmp
- return _tmp
- end
-
- # Inlines = (!@Endline Inline:i { i } | @Endline:c !(&{ github? } Ticks3 /[^`\n]*$/) &Inline { c })+:chunks @Endline? { chunks }
- def _Inlines
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _ary = []
-
- _save2 = self.pos
- while true # choice
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_Inline)
- i = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; i ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
-
- _save5 = self.pos
- while true # sequence
- _tmp = _Endline()
- c = @result
- unless _tmp
- self.pos = _save5
- break
- end
- _save6 = self.pos
-
- _save7 = self.pos
- while true # sequence
- _save8 = self.pos
- _tmp = begin; github? ; end
- self.pos = _save8
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = scan(/\G(?-mix:[^`\n]*$)/)
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _save9 = self.pos
- _tmp = apply(:_Inline)
- self.pos = _save9
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; c ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- if _tmp
- _ary << @result
- while true
-
- _save10 = self.pos
- while true # choice
-
- _save11 = self.pos
- while true # sequence
- _save12 = self.pos
- _tmp = _Endline()
- _tmp = _tmp ? nil : true
- self.pos = _save12
- unless _tmp
- self.pos = _save11
- break
- end
- _tmp = apply(:_Inline)
- i = @result
- unless _tmp
- self.pos = _save11
- break
- end
- @result = begin; i ; end
- _tmp = true
- unless _tmp
- self.pos = _save11
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save10
-
- _save13 = self.pos
- while true # sequence
- _tmp = _Endline()
- c = @result
- unless _tmp
- self.pos = _save13
- break
- end
- _save14 = self.pos
-
- _save15 = self.pos
- while true # sequence
- _save16 = self.pos
- _tmp = begin; github? ; end
- self.pos = _save16
- unless _tmp
- self.pos = _save15
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save15
- break
- end
- _tmp = scan(/\G(?-mix:[^`\n]*$)/)
- unless _tmp
- self.pos = _save15
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save14
- unless _tmp
- self.pos = _save13
- break
- end
- _save17 = self.pos
- _tmp = apply(:_Inline)
- self.pos = _save17
- unless _tmp
- self.pos = _save13
- break
- end
- @result = begin; c ; end
- _tmp = true
- unless _tmp
- self.pos = _save13
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save10
- break
- end # end choice
-
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- chunks = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save18 = self.pos
- _tmp = _Endline()
- unless _tmp
- _tmp = true
- self.pos = _save18
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; chunks ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Inlines unless _tmp
- return _tmp
- end
-
- # Inline = (Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol)
- def _Inline
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_Str)
- break if _tmp
- self.pos = _save
- _tmp = _Endline()
- break if _tmp
- self.pos = _save
- _tmp = apply(:_UlOrStarLine)
- break if _tmp
- self.pos = _save
- _tmp = _Space()
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Strong)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Emph)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Strike)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Image)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Link)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_NoteReference)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_InlineNote)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Code)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_RawHtml)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Entity)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_EscapedChar)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_Symbol)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Inline unless _tmp
- return _tmp
- end
-
- # Space = @Spacechar+ { " " }
- def _Space
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _Spacechar()
- if _tmp
- while true
- _tmp = _Spacechar()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; " " ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Space unless _tmp
- return _tmp
- end
-
- # Str = @StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a }
- def _Str
-
- _save = self.pos
- while true # sequence
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _save1 = self.pos
- _tmp = _NormalChar()
- if _tmp
- while true
- _tmp = _NormalChar()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a = text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save3 = self.pos
- while true # sequence
- _tmp = apply(:_StrChunk)
- c = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a << c ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Str unless _tmp
- return _tmp
- end
-
- # StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text }
- def _StrChunk
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _save1 = self.pos
-
- _save2 = self.pos
- while true # choice
- _tmp = _NormalChar()
- break if _tmp
- self.pos = _save2
-
- _save3 = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:_+)/)
- unless _tmp
- self.pos = _save3
- break
- end
- _save4 = self.pos
- _tmp = apply(:_Alphanumeric)
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # choice
- _tmp = _NormalChar()
- break if _tmp
- self.pos = _save5
-
- _save6 = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:_+)/)
- unless _tmp
- self.pos = _save6
- break
- end
- _save7 = self.pos
- _tmp = apply(:_Alphanumeric)
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save5
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StrChunk unless _tmp
- return _tmp
- end
-
- # EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
- def _EscapedChar
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("\\")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:[:\\`|*_{}\[\]()#+.!><-])/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_EscapedChar unless _tmp
- return _tmp
- end
-
- # Entity = (HexEntity | DecEntity | CharEntity):a { a }
- def _Entity
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_HexEntity)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_DecEntity)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_CharEntity)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Entity unless _tmp
- return _tmp
- end
-
- # Endline = (@LineBreak | @TerminalEndline | @NormalEndline)
- def _Endline
-
- _save = self.pos
- while true # choice
- _tmp = _LineBreak()
- break if _tmp
- self.pos = _save
- _tmp = _TerminalEndline()
- break if _tmp
- self.pos = _save
- _tmp = _NormalEndline()
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Endline unless _tmp
- return _tmp
- end
-
- # NormalEndline = @Sp @Newline !@BlankLine !">" !AtxStart !(Line /={1,}|-{1,}/ @Newline) { "\n" }
- def _NormalEndline
-
- _save = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save2
- unless _tmp
- self.pos = _save
- break
- end
- _save3 = self.pos
- _tmp = apply(:_AtxStart)
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save
- break
- end
- _save4 = self.pos
-
- _save5 = self.pos
- while true # sequence
- _tmp = apply(:_Line)
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = scan(/\G(?-mix:={1,}|-{1,})/)
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "\n" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_NormalEndline unless _tmp
- return _tmp
- end
-
- # TerminalEndline = @Sp @Newline @Eof
- def _TerminalEndline
-
- _save = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Eof()
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TerminalEndline unless _tmp
- return _tmp
- end
-
- # LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new }
- def _LineBreak
-
- _save = self.pos
- while true # sequence
- _tmp = match_string(" ")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _NormalEndline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::HardBreak.new ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_LineBreak unless _tmp
- return _tmp
- end
-
- # Symbol = < @SpecialChar > { text }
- def _Symbol
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = _SpecialChar()
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Symbol unless _tmp
- return _tmp
- end
-
- # UlOrStarLine = (UlLine | StarLine):a { a }
- def _UlOrStarLine
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_UlLine)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_StarLine)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_UlOrStarLine unless _tmp
- return _tmp
- end
-
- # StarLine = (< /\*{4,}/ > { text } | < @Spacechar /\*+/ &@Spacechar > { text })
- def _StarLine
-
- _save = self.pos
- while true # choice
-
- _save1 = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:\*{4,})/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save1
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save1
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
-
- _save2 = self.pos
- while true # sequence
- _text_start = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = _Spacechar()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = scan(/\G(?-mix:\*+)/)
- unless _tmp
- self.pos = _save3
- break
- end
- _save4 = self.pos
- _tmp = _Spacechar()
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_StarLine unless _tmp
- return _tmp
- end
-
- # UlLine = (< /_{4,}/ > { text } | < @Spacechar /_+/ &@Spacechar > { text })
- def _UlLine
-
- _save = self.pos
- while true # choice
-
- _save1 = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:_{4,})/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save1
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save1
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
-
- _save2 = self.pos
- while true # sequence
- _text_start = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = _Spacechar()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = scan(/\G(?-mix:_+)/)
- unless _tmp
- self.pos = _save3
- break
- end
- _save4 = self.pos
- _tmp = _Spacechar()
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_UlLine unless _tmp
- return _tmp
- end
-
- # Emph = (EmphStar | EmphUl)
- def _Emph
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_EmphStar)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_EmphUl)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Emph unless _tmp
- return _tmp
- end
-
- # Whitespace = (@Spacechar | @Newline)
- def _Whitespace
-
- _save = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save
- _tmp = _Newline()
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Whitespace unless _tmp
- return _tmp
- end
-
- # EmphStar = "*" !@Whitespace @StartList:a (!"*" Inline:b { a << b } | StrongStar:b { a << b })+ "*" { emphasis a.join }
- def _EmphStar
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _Whitespace()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # choice
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = match_string("*")
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save3
-
- _save6 = self.pos
- while true # sequence
- _tmp = apply(:_StrongStar)
- b = @result
- unless _tmp
- self.pos = _save6
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save3
- break
- end # end choice
-
- if _tmp
- while true
-
- _save7 = self.pos
- while true # choice
-
- _save8 = self.pos
- while true # sequence
- _save9 = self.pos
- _tmp = match_string("*")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save8
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save7
-
- _save10 = self.pos
- while true # sequence
- _tmp = apply(:_StrongStar)
- b = @result
- unless _tmp
- self.pos = _save10
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save7
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("*")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; emphasis a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_EmphStar unless _tmp
- return _tmp
- end
-
- # EmphUl = "_" !@Whitespace @StartList:a (!"_" Inline:b { a << b } | StrongUl:b { a << b })+ "_" { emphasis a.join }
- def _EmphUl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _Whitespace()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # choice
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = match_string("_")
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save3
-
- _save6 = self.pos
- while true # sequence
- _tmp = apply(:_StrongUl)
- b = @result
- unless _tmp
- self.pos = _save6
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save3
- break
- end # end choice
-
- if _tmp
- while true
-
- _save7 = self.pos
- while true # choice
-
- _save8 = self.pos
- while true # sequence
- _save9 = self.pos
- _tmp = match_string("_")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save8
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save7
-
- _save10 = self.pos
- while true # sequence
- _tmp = apply(:_StrongUl)
- b = @result
- unless _tmp
- self.pos = _save10
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save7
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("_")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; emphasis a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_EmphUl unless _tmp
- return _tmp
- end
-
- # Strong = (StrongStar | StrongUl)
- def _Strong
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_StrongStar)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_StrongUl)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Strong unless _tmp
- return _tmp
- end
-
- # StrongStar = "**" !@Whitespace @StartList:a (!"**" Inline:b { a << b })+ "**" { strong a.join }
- def _StrongStar
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("**")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _Whitespace()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("**")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = match_string("**")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("**")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; strong a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StrongStar unless _tmp
- return _tmp
- end
-
- # StrongUl = "__" !@Whitespace @StartList:a (!"__" Inline:b { a << b })+ "__" { strong a.join }
- def _StrongUl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("__")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _Whitespace()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("__")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = match_string("__")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("__")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; strong a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StrongUl unless _tmp
- return _tmp
- end
-
- # Strike = &{ strike? } "~~" !@Whitespace @StartList:a (!"~~" Inline:b { a << b })+ "~~" { strike a.join }
- def _Strike
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; strike? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("~~")
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = _Whitespace()
- _tmp = _tmp ? nil : true
- self.pos = _save2
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = match_string("~~")
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save4
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save6 = self.pos
- while true # sequence
- _save7 = self.pos
- _tmp = match_string("~~")
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- break
- end
- _tmp = apply(:_Inline)
- b = @result
- unless _tmp
- self.pos = _save6
- break
- end
- @result = begin; a << b ; end
- _tmp = true
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save3
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("~~")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; strike a.join ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Strike unless _tmp
- return _tmp
- end
-
- # Image = "!" (ExplicitLink | ReferenceLink):a { "rdoc-image:#{a[/\[(.*)\]/, 1]}" }
- def _Image
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("!")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_ExplicitLink)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_ReferenceLink)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "rdoc-image:#{a[/\[(.*)\]/, 1]}" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Image unless _tmp
- return _tmp
- end
-
- # Link = (ExplicitLink | ReferenceLink | AutoLink)
- def _Link
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_ExplicitLink)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_ReferenceLink)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_AutoLink)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Link unless _tmp
- return _tmp
- end
-
- # ReferenceLink = (ReferenceLinkDouble | ReferenceLinkSingle)
- def _ReferenceLink
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_ReferenceLinkDouble)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_ReferenceLinkSingle)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_ReferenceLink unless _tmp
- return _tmp
- end
-
- # ReferenceLinkDouble = Label:content < Spnl > !"[]" Label:label { link_to content, label, text }
- def _ReferenceLinkDouble
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Label)
- content = @result
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _tmp = apply(:_Spnl)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("[]")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Label)
- label = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; link_to content, label, text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ReferenceLinkDouble unless _tmp
- return _tmp
- end
-
- # ReferenceLinkSingle = Label:content < (Spnl "[]")? > { link_to content, content, text }
- def _ReferenceLinkSingle
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Label)
- content = @result
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = match_string("[]")
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; link_to content, content, text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ReferenceLinkSingle unless _tmp
- return _tmp
- end
-
- # ExplicitLink = Label:l "(" @Sp Source:s Spnl Title @Sp ")" { "{#{l}}[#{s}]" }
- def _ExplicitLink
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Label)
- l = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("(")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Source)
- s = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Title)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(")")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "{#{l}}[#{s}]" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ExplicitLink unless _tmp
- return _tmp
- end
-
- # Source = ("<" < SourceContents > ">" | < SourceContents >) { text }
- def _Source
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save2
- break
- end
- _text_start = self.pos
- _tmp = apply(:_SourceContents)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- _text_start = self.pos
- _tmp = apply(:_SourceContents)
- if _tmp
- text = get_text(_text_start)
- end
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Source unless _tmp
- return _tmp
- end
-
- # SourceContents = ((!"(" !")" !">" Nonspacechar)+ | "(" SourceContents ")")*
- def _SourceContents
- while true
-
- _save1 = self.pos
- while true # choice
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("(")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _save5 = self.pos
- _tmp = match_string(")")
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save3
- break
- end
- _save6 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save7 = self.pos
- while true # sequence
- _save8 = self.pos
- _tmp = match_string("(")
- _tmp = _tmp ? nil : true
- self.pos = _save8
- unless _tmp
- self.pos = _save7
- break
- end
- _save9 = self.pos
- _tmp = match_string(")")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save7
- break
- end
- _save10 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save10
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- break if _tmp
- self.pos = _save1
-
- _save11 = self.pos
- while true # sequence
- _tmp = match_string("(")
- unless _tmp
- self.pos = _save11
- break
- end
- _tmp = apply(:_SourceContents)
- unless _tmp
- self.pos = _save11
- break
- end
- _tmp = match_string(")")
- unless _tmp
- self.pos = _save11
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- set_failed_rule :_SourceContents unless _tmp
- return _tmp
- end
-
- # Title = (TitleSingle | TitleDouble | ""):a { a }
- def _Title
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_TitleSingle)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_TitleDouble)
- break if _tmp
- self.pos = _save1
- _tmp = match_string("")
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Title unless _tmp
- return _tmp
- end
-
- # TitleSingle = "'" (!("'" @Sp (")" | @Newline)) .)* "'"
- def _TitleSingle
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save4
- break
- end
-
- _save5 = self.pos
- while true # choice
- _tmp = match_string(")")
- break if _tmp
- self.pos = _save5
- _tmp = _Newline()
- break if _tmp
- self.pos = _save5
- break
- end # end choice
-
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TitleSingle unless _tmp
- return _tmp
- end
-
- # TitleDouble = "\"" (!("\"" @Sp (")" | @Newline)) .)* "\""
- def _TitleDouble
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save4
- break
- end
-
- _save5 = self.pos
- while true # choice
- _tmp = match_string(")")
- break if _tmp
- self.pos = _save5
- _tmp = _Newline()
- break if _tmp
- self.pos = _save5
- break
- end # end choice
-
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TitleDouble unless _tmp
- return _tmp
- end
-
- # AutoLink = (AutoLinkUrl | AutoLinkEmail)
- def _AutoLink
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_AutoLinkUrl)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_AutoLinkEmail)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_AutoLink unless _tmp
- return _tmp
- end
-
- # AutoLinkUrl = "<" < /[A-Za-z]+/ "://" (!@Newline !">" .)+ > ">" { text }
- def _AutoLinkUrl
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
-
- _save1 = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:[A-Za-z]+)/)
- unless _tmp
- self.pos = _save1
- break
- end
- _tmp = match_string("://")
- unless _tmp
- self.pos = _save1
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _save5 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save6 = self.pos
- while true # sequence
- _save7 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- break
- end
- _save8 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save8
- unless _tmp
- self.pos = _save6
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save1
- end
- break
- end # end sequence
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_AutoLinkUrl unless _tmp
- return _tmp
- end
-
- # AutoLinkEmail = "<" "mailto:"? < /[\w+.\/!%~$-]+/i "@" (!@Newline !">" .)+ > ">" { "mailto:#{text}" }
- def _AutoLinkEmail
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("mailto:")
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = scan(/\G(?i-mx:[\w+.\/!%~$-]+)/)
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = match_string("@")
- unless _tmp
- self.pos = _save2
- break
- end
- _save3 = self.pos
-
- _save4 = self.pos
- while true # sequence
- _save5 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save4
- break
- end
- _save6 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save4
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save4
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save7 = self.pos
- while true # sequence
- _save8 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save8
- unless _tmp
- self.pos = _save7
- break
- end
- _save9 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save3
- end
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "mailto:#{text}" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_AutoLinkEmail unless _tmp
- return _tmp
- end
-
- # Reference = @NonindentSpace !"[]" Label:label ":" Spnl RefSrc:link RefTitle @BlankLine+ { # TODO use title reference label, link nil }
- def _Reference
-
- _save = self.pos
- while true # sequence
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("[]")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Label)
- label = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(":")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_RefSrc)
- link = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_RefTitle)
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; # TODO use title
- reference label, link
- nil
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Reference unless _tmp
- return _tmp
- end
-
- # Label = "[" (!"^" &{ notes? } | &. &{ !notes? }) @StartList:a (!"]" Inline:l { a << l })* "]" { a.join.gsub(/\s+/, ' ') }
- def _Label
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("[")
- unless _tmp
- self.pos = _save
- break
- end
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = match_string("^")
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _save4 = self.pos
- _tmp = begin; notes? ; end
- self.pos = _save4
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = get_byte
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _save7 = self.pos
- _tmp = begin; !notes? ; end
- self.pos = _save7
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save9 = self.pos
- while true # sequence
- _save10 = self.pos
- _tmp = match_string("]")
- _tmp = _tmp ? nil : true
- self.pos = _save10
- unless _tmp
- self.pos = _save9
- break
- end
- _tmp = apply(:_Inline)
- l = @result
- unless _tmp
- self.pos = _save9
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save9
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("]")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a.join.gsub(/\s+/, ' ') ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Label unless _tmp
- return _tmp
- end
-
- # RefSrc = < Nonspacechar+ > { text }
- def _RefSrc
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _save1 = self.pos
- _tmp = apply(:_Nonspacechar)
- if _tmp
- while true
- _tmp = apply(:_Nonspacechar)
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RefSrc unless _tmp
- return _tmp
- end
-
- # RefTitle = (RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle)
- def _RefTitle
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_RefTitleSingle)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_RefTitleDouble)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_RefTitleParens)
- break if _tmp
- self.pos = _save
- _tmp = apply(:_EmptyTitle)
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_RefTitle unless _tmp
- return _tmp
- end
-
- # EmptyTitle = ""
- def _EmptyTitle
- _tmp = match_string("")
- set_failed_rule :_EmptyTitle unless _tmp
- return _tmp
- end
-
- # RefTitleSingle = Spnl "'" < (!("'" @Sp @Newline | @Newline) .)* > "'" { text }
- def _RefTitleSingle
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
-
- _save4 = self.pos
- while true # choice
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save4
- _tmp = _Newline()
- break if _tmp
- self.pos = _save4
- break
- end # end choice
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RefTitleSingle unless _tmp
- return _tmp
- end
-
- # RefTitleDouble = Spnl "\"" < (!("\"" @Sp @Newline | @Newline) .)* > "\"" { text }
- def _RefTitleDouble
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
-
- _save4 = self.pos
- while true # choice
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save4
- _tmp = _Newline()
- break if _tmp
- self.pos = _save4
- break
- end # end choice
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RefTitleDouble unless _tmp
- return _tmp
- end
-
- # RefTitleParens = Spnl "(" < (!(")" @Sp @Newline | @Newline) .)* > ")" { text }
- def _RefTitleParens
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("(")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
-
- _save4 = self.pos
- while true # choice
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string(")")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save4
- _tmp = _Newline()
- break if _tmp
- self.pos = _save4
- break
- end # end choice
-
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(")")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RefTitleParens unless _tmp
- return _tmp
- end
-
- # References = (Reference | SkipBlock)*
- def _References
- while true
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_Reference)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_SkipBlock)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- set_failed_rule :_References unless _tmp
- return _tmp
- end
-
- # Ticks1 = "`" !"`"
- def _Ticks1
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("`")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Ticks1 unless _tmp
- return _tmp
- end
-
- # Ticks2 = "``" !"`"
- def _Ticks2
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("``")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Ticks2 unless _tmp
- return _tmp
- end
-
- # Ticks3 = "```" !"`"
- def _Ticks3
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("```")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Ticks3 unless _tmp
- return _tmp
- end
-
- # Ticks4 = "````" !"`"
- def _Ticks4
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("````")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Ticks4 unless _tmp
- return _tmp
- end
-
- # Ticks5 = "`````" !"`"
- def _Ticks5
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("`````")
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Ticks5 unless _tmp
- return _tmp
- end
-
- # Code = (Ticks1 @Sp < ((!"`" Nonspacechar)+ | !Ticks1 /`+/ | !(@Sp Ticks1) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks1 | Ticks2 @Sp < ((!"`" Nonspacechar)+ | !Ticks2 /`+/ | !(@Sp Ticks2) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks2 | Ticks3 @Sp < ((!"`" Nonspacechar)+ | !Ticks3 /`+/ | !(@Sp Ticks3) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks3 | Ticks4 @Sp < ((!"`" Nonspacechar)+ | !Ticks4 /`+/ | !(@Sp Ticks4) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks4 | Ticks5 @Sp < ((!"`" Nonspacechar)+ | !Ticks5 /`+/ | !(@Sp Ticks5) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks5) { "<code>#{text}</code>" }
- def _Code
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _tmp = apply(:_Ticks1)
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save2
- break
- end
- _text_start = self.pos
- _save3 = self.pos
-
- _save4 = self.pos
- while true # choice
- _save5 = self.pos
-
- _save6 = self.pos
- while true # sequence
- _save7 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save6
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save6
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save8 = self.pos
- while true # sequence
- _save9 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save5
- end
- break if _tmp
- self.pos = _save4
-
- _save10 = self.pos
- while true # sequence
- _save11 = self.pos
- _tmp = apply(:_Ticks1)
- _tmp = _tmp ? nil : true
- self.pos = _save11
- unless _tmp
- self.pos = _save10
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save4
-
- _save12 = self.pos
- while true # sequence
- _save13 = self.pos
-
- _save14 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save14
- break
- end
- _tmp = apply(:_Ticks1)
- unless _tmp
- self.pos = _save14
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save13
- unless _tmp
- self.pos = _save12
- break
- end
-
- _save15 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save15
-
- _save16 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save16
- break
- end
- _save17 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save17
- unless _tmp
- self.pos = _save16
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save15
- break
- end # end choice
-
- unless _tmp
- self.pos = _save12
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save4
- break
- end # end choice
-
- if _tmp
- while true
-
- _save18 = self.pos
- while true # choice
- _save19 = self.pos
-
- _save20 = self.pos
- while true # sequence
- _save21 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save21
- unless _tmp
- self.pos = _save20
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save20
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save22 = self.pos
- while true # sequence
- _save23 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save23
- unless _tmp
- self.pos = _save22
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save22
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save19
- end
- break if _tmp
- self.pos = _save18
-
- _save24 = self.pos
- while true # sequence
- _save25 = self.pos
- _tmp = apply(:_Ticks1)
- _tmp = _tmp ? nil : true
- self.pos = _save25
- unless _tmp
- self.pos = _save24
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save24
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save18
-
- _save26 = self.pos
- while true # sequence
- _save27 = self.pos
-
- _save28 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save28
- break
- end
- _tmp = apply(:_Ticks1)
- unless _tmp
- self.pos = _save28
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save27
- unless _tmp
- self.pos = _save26
- break
- end
-
- _save29 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save29
-
- _save30 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save30
- break
- end
- _save31 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save31
- unless _tmp
- self.pos = _save30
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save29
- break
- end # end choice
-
- unless _tmp
- self.pos = _save26
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save18
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save3
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = apply(:_Ticks1)
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save32 = self.pos
- while true # sequence
- _tmp = apply(:_Ticks2)
- unless _tmp
- self.pos = _save32
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save32
- break
- end
- _text_start = self.pos
- _save33 = self.pos
-
- _save34 = self.pos
- while true # choice
- _save35 = self.pos
-
- _save36 = self.pos
- while true # sequence
- _save37 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save37
- unless _tmp
- self.pos = _save36
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save36
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save38 = self.pos
- while true # sequence
- _save39 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save39
- unless _tmp
- self.pos = _save38
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save38
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save35
- end
- break if _tmp
- self.pos = _save34
-
- _save40 = self.pos
- while true # sequence
- _save41 = self.pos
- _tmp = apply(:_Ticks2)
- _tmp = _tmp ? nil : true
- self.pos = _save41
- unless _tmp
- self.pos = _save40
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save40
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save34
-
- _save42 = self.pos
- while true # sequence
- _save43 = self.pos
-
- _save44 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save44
- break
- end
- _tmp = apply(:_Ticks2)
- unless _tmp
- self.pos = _save44
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save43
- unless _tmp
- self.pos = _save42
- break
- end
-
- _save45 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save45
-
- _save46 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save46
- break
- end
- _save47 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save47
- unless _tmp
- self.pos = _save46
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save45
- break
- end # end choice
-
- unless _tmp
- self.pos = _save42
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save34
- break
- end # end choice
-
- if _tmp
- while true
-
- _save48 = self.pos
- while true # choice
- _save49 = self.pos
-
- _save50 = self.pos
- while true # sequence
- _save51 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save51
- unless _tmp
- self.pos = _save50
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save50
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save52 = self.pos
- while true # sequence
- _save53 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save53
- unless _tmp
- self.pos = _save52
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save52
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save49
- end
- break if _tmp
- self.pos = _save48
-
- _save54 = self.pos
- while true # sequence
- _save55 = self.pos
- _tmp = apply(:_Ticks2)
- _tmp = _tmp ? nil : true
- self.pos = _save55
- unless _tmp
- self.pos = _save54
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save54
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save48
-
- _save56 = self.pos
- while true # sequence
- _save57 = self.pos
-
- _save58 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save58
- break
- end
- _tmp = apply(:_Ticks2)
- unless _tmp
- self.pos = _save58
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save57
- unless _tmp
- self.pos = _save56
- break
- end
-
- _save59 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save59
-
- _save60 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save60
- break
- end
- _save61 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save61
- unless _tmp
- self.pos = _save60
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save59
- break
- end # end choice
-
- unless _tmp
- self.pos = _save56
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save48
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save33
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save32
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save32
- break
- end
- _tmp = apply(:_Ticks2)
- unless _tmp
- self.pos = _save32
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save62 = self.pos
- while true # sequence
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save62
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save62
- break
- end
- _text_start = self.pos
- _save63 = self.pos
-
- _save64 = self.pos
- while true # choice
- _save65 = self.pos
-
- _save66 = self.pos
- while true # sequence
- _save67 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save67
- unless _tmp
- self.pos = _save66
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save66
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save68 = self.pos
- while true # sequence
- _save69 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save69
- unless _tmp
- self.pos = _save68
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save68
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save65
- end
- break if _tmp
- self.pos = _save64
-
- _save70 = self.pos
- while true # sequence
- _save71 = self.pos
- _tmp = apply(:_Ticks3)
- _tmp = _tmp ? nil : true
- self.pos = _save71
- unless _tmp
- self.pos = _save70
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save70
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save64
-
- _save72 = self.pos
- while true # sequence
- _save73 = self.pos
-
- _save74 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save74
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save74
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save73
- unless _tmp
- self.pos = _save72
- break
- end
-
- _save75 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save75
-
- _save76 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save76
- break
- end
- _save77 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save77
- unless _tmp
- self.pos = _save76
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save75
- break
- end # end choice
-
- unless _tmp
- self.pos = _save72
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save64
- break
- end # end choice
-
- if _tmp
- while true
-
- _save78 = self.pos
- while true # choice
- _save79 = self.pos
-
- _save80 = self.pos
- while true # sequence
- _save81 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save81
- unless _tmp
- self.pos = _save80
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save80
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save82 = self.pos
- while true # sequence
- _save83 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save83
- unless _tmp
- self.pos = _save82
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save82
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save79
- end
- break if _tmp
- self.pos = _save78
-
- _save84 = self.pos
- while true # sequence
- _save85 = self.pos
- _tmp = apply(:_Ticks3)
- _tmp = _tmp ? nil : true
- self.pos = _save85
- unless _tmp
- self.pos = _save84
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save84
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save78
-
- _save86 = self.pos
- while true # sequence
- _save87 = self.pos
-
- _save88 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save88
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save88
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save87
- unless _tmp
- self.pos = _save86
- break
- end
-
- _save89 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save89
-
- _save90 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save90
- break
- end
- _save91 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save91
- unless _tmp
- self.pos = _save90
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save89
- break
- end # end choice
-
- unless _tmp
- self.pos = _save86
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save78
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save63
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save62
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save62
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save62
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save92 = self.pos
- while true # sequence
- _tmp = apply(:_Ticks4)
- unless _tmp
- self.pos = _save92
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save92
- break
- end
- _text_start = self.pos
- _save93 = self.pos
-
- _save94 = self.pos
- while true # choice
- _save95 = self.pos
-
- _save96 = self.pos
- while true # sequence
- _save97 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save97
- unless _tmp
- self.pos = _save96
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save96
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save98 = self.pos
- while true # sequence
- _save99 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save99
- unless _tmp
- self.pos = _save98
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save98
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save95
- end
- break if _tmp
- self.pos = _save94
-
- _save100 = self.pos
- while true # sequence
- _save101 = self.pos
- _tmp = apply(:_Ticks4)
- _tmp = _tmp ? nil : true
- self.pos = _save101
- unless _tmp
- self.pos = _save100
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save100
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save94
-
- _save102 = self.pos
- while true # sequence
- _save103 = self.pos
-
- _save104 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save104
- break
- end
- _tmp = apply(:_Ticks4)
- unless _tmp
- self.pos = _save104
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save103
- unless _tmp
- self.pos = _save102
- break
- end
-
- _save105 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save105
-
- _save106 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save106
- break
- end
- _save107 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save107
- unless _tmp
- self.pos = _save106
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save105
- break
- end # end choice
-
- unless _tmp
- self.pos = _save102
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save94
- break
- end # end choice
-
- if _tmp
- while true
-
- _save108 = self.pos
- while true # choice
- _save109 = self.pos
-
- _save110 = self.pos
- while true # sequence
- _save111 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save111
- unless _tmp
- self.pos = _save110
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save110
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save112 = self.pos
- while true # sequence
- _save113 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save113
- unless _tmp
- self.pos = _save112
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save112
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save109
- end
- break if _tmp
- self.pos = _save108
-
- _save114 = self.pos
- while true # sequence
- _save115 = self.pos
- _tmp = apply(:_Ticks4)
- _tmp = _tmp ? nil : true
- self.pos = _save115
- unless _tmp
- self.pos = _save114
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save114
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save108
-
- _save116 = self.pos
- while true # sequence
- _save117 = self.pos
-
- _save118 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save118
- break
- end
- _tmp = apply(:_Ticks4)
- unless _tmp
- self.pos = _save118
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save117
- unless _tmp
- self.pos = _save116
- break
- end
-
- _save119 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save119
-
- _save120 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save120
- break
- end
- _save121 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save121
- unless _tmp
- self.pos = _save120
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save119
- break
- end # end choice
-
- unless _tmp
- self.pos = _save116
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save108
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save93
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save92
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save92
- break
- end
- _tmp = apply(:_Ticks4)
- unless _tmp
- self.pos = _save92
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
-
- _save122 = self.pos
- while true # sequence
- _tmp = apply(:_Ticks5)
- unless _tmp
- self.pos = _save122
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save122
- break
- end
- _text_start = self.pos
- _save123 = self.pos
-
- _save124 = self.pos
- while true # choice
- _save125 = self.pos
-
- _save126 = self.pos
- while true # sequence
- _save127 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save127
- unless _tmp
- self.pos = _save126
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save126
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save128 = self.pos
- while true # sequence
- _save129 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save129
- unless _tmp
- self.pos = _save128
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save128
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save125
- end
- break if _tmp
- self.pos = _save124
-
- _save130 = self.pos
- while true # sequence
- _save131 = self.pos
- _tmp = apply(:_Ticks5)
- _tmp = _tmp ? nil : true
- self.pos = _save131
- unless _tmp
- self.pos = _save130
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save130
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save124
-
- _save132 = self.pos
- while true # sequence
- _save133 = self.pos
-
- _save134 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save134
- break
- end
- _tmp = apply(:_Ticks5)
- unless _tmp
- self.pos = _save134
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save133
- unless _tmp
- self.pos = _save132
- break
- end
-
- _save135 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save135
-
- _save136 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save136
- break
- end
- _save137 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save137
- unless _tmp
- self.pos = _save136
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save135
- break
- end # end choice
-
- unless _tmp
- self.pos = _save132
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save124
- break
- end # end choice
-
- if _tmp
- while true
-
- _save138 = self.pos
- while true # choice
- _save139 = self.pos
-
- _save140 = self.pos
- while true # sequence
- _save141 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save141
- unless _tmp
- self.pos = _save140
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save140
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save142 = self.pos
- while true # sequence
- _save143 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save143
- unless _tmp
- self.pos = _save142
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save142
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save139
- end
- break if _tmp
- self.pos = _save138
-
- _save144 = self.pos
- while true # sequence
- _save145 = self.pos
- _tmp = apply(:_Ticks5)
- _tmp = _tmp ? nil : true
- self.pos = _save145
- unless _tmp
- self.pos = _save144
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save144
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save138
-
- _save146 = self.pos
- while true # sequence
- _save147 = self.pos
-
- _save148 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save148
- break
- end
- _tmp = apply(:_Ticks5)
- unless _tmp
- self.pos = _save148
- end
- break
- end # end sequence
-
- _tmp = _tmp ? nil : true
- self.pos = _save147
- unless _tmp
- self.pos = _save146
- break
- end
-
- _save149 = self.pos
- while true # choice
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save149
-
- _save150 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save150
- break
- end
- _save151 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save151
- unless _tmp
- self.pos = _save150
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save149
- break
- end # end choice
-
- unless _tmp
- self.pos = _save146
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save138
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save123
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save122
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save122
- break
- end
- _tmp = apply(:_Ticks5)
- unless _tmp
- self.pos = _save122
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "<code>#{text}</code>" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Code unless _tmp
- return _tmp
- end
-
- # RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) > { if html? then text else '' end }
- def _RawHtml
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_HtmlComment)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_HtmlBlockScript)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_HtmlTag)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; if html? then text else '' end ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RawHtml unless _tmp
- return _tmp
- end
-
- # BlankLine = @Sp @Newline { "\n" }
- def _BlankLine
-
- _save = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; "\n" ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_BlankLine unless _tmp
- return _tmp
- end
-
- # Quoted = ("\"" (!"\"" .)* "\"" | "'" (!"'" .)* "'")
- def _Quoted
-
- _save = self.pos
- while true # choice
-
- _save1 = self.pos
- while true # sequence
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save1
- break
- end
- while true
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("\"")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save1
- break
- end
- _tmp = match_string("\"")
- unless _tmp
- self.pos = _save1
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save5
- break
- end
- while true
-
- _save7 = self.pos
- while true # sequence
- _save8 = self.pos
- _tmp = match_string("'")
- _tmp = _tmp ? nil : true
- self.pos = _save8
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = match_string("'")
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_Quoted unless _tmp
- return _tmp
- end
-
- # HtmlAttribute = (AlphanumericAscii | "-")+ Spnl ("=" Spnl (Quoted | (!">" Nonspacechar)+))? Spnl
- def _HtmlAttribute
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
-
- _save2 = self.pos
- while true # choice
- _tmp = apply(:_AlphanumericAscii)
- break if _tmp
- self.pos = _save2
- _tmp = match_string("-")
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- if _tmp
- while true
-
- _save3 = self.pos
- while true # choice
- _tmp = apply(:_AlphanumericAscii)
- break if _tmp
- self.pos = _save3
- _tmp = match_string("-")
- break if _tmp
- self.pos = _save3
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _save4 = self.pos
-
- _save5 = self.pos
- while true # sequence
- _tmp = match_string("=")
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save5
- break
- end
-
- _save6 = self.pos
- while true # choice
- _tmp = apply(:_Quoted)
- break if _tmp
- self.pos = _save6
- _save7 = self.pos
-
- _save8 = self.pos
- while true # sequence
- _save9 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save10 = self.pos
- while true # sequence
- _save11 = self.pos
- _tmp = match_string(">")
- _tmp = _tmp ? nil : true
- self.pos = _save11
- unless _tmp
- self.pos = _save10
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save10
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save7
- end
- break if _tmp
- self.pos = _save6
- break
- end # end choice
-
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- unless _tmp
- _tmp = true
- self.pos = _save4
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlAttribute unless _tmp
- return _tmp
- end
-
- # HtmlComment = "<!--" (!"-->" .)* "-->"
- def _HtmlComment
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<!--")
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = match_string("-->")
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("-->")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlComment unless _tmp
- return _tmp
- end
-
- # HtmlTag = "<" Spnl "/"? AlphanumericAscii+ Spnl HtmlAttribute* "/"? Spnl ">"
- def _HtmlTag
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("<")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = match_string("/")
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = apply(:_AlphanumericAscii)
- if _tmp
- while true
- _tmp = apply(:_AlphanumericAscii)
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = apply(:_HtmlAttribute)
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- _save4 = self.pos
- _tmp = match_string("/")
- unless _tmp
- _tmp = true
- self.pos = _save4
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(">")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HtmlTag unless _tmp
- return _tmp
- end
-
- # Eof = !.
- def _Eof
- _save = self.pos
- _tmp = get_byte
- _tmp = _tmp ? nil : true
- self.pos = _save
- set_failed_rule :_Eof unless _tmp
- return _tmp
- end
-
- # Nonspacechar = !@Spacechar !@Newline .
- def _Nonspacechar
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = _Spacechar()
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save2
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Nonspacechar unless _tmp
- return _tmp
- end
-
- # Sp = @Spacechar*
- def _Sp
- while true
- _tmp = _Spacechar()
- break unless _tmp
- end
- _tmp = true
- set_failed_rule :_Sp unless _tmp
- return _tmp
- end
-
- # Spnl = @Sp (@Newline @Sp)?
- def _Spnl
-
- _save = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = _Newline()
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Spnl unless _tmp
- return _tmp
- end
-
- # SpecialChar = (/[~*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar)
- def _SpecialChar
-
- _save = self.pos
- while true # choice
- _tmp = scan(/\G(?-mix:[~*_`&\[\]()<!#\\'"])/)
- break if _tmp
- self.pos = _save
- _tmp = _ExtendedSpecialChar()
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_SpecialChar unless _tmp
- return _tmp
- end
-
- # NormalChar = !(@SpecialChar | @Spacechar | @Newline) .
- def _NormalChar
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
-
- _save2 = self.pos
- while true # choice
- _tmp = _SpecialChar()
- break if _tmp
- self.pos = _save2
- _tmp = _Spacechar()
- break if _tmp
- self.pos = _save2
- _tmp = _Newline()
- break if _tmp
- self.pos = _save2
- break
- end # end choice
-
- _tmp = _tmp ? nil : true
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_NormalChar unless _tmp
- return _tmp
- end
-
- # Digit = [0-9]
- def _Digit
- _save = self.pos
- _tmp = get_byte
- if _tmp
- unless _tmp >= 48 and _tmp <= 57
- self.pos = _save
- _tmp = nil
- end
- end
- set_failed_rule :_Digit unless _tmp
- return _tmp
- end
-
- # Alphanumeric = %literals.Alphanumeric
- def _Alphanumeric
- _tmp = @_grammar_literals.external_invoke(self, :_Alphanumeric)
- set_failed_rule :_Alphanumeric unless _tmp
- return _tmp
- end
-
- # AlphanumericAscii = %literals.AlphanumericAscii
- def _AlphanumericAscii
- _tmp = @_grammar_literals.external_invoke(self, :_AlphanumericAscii)
- set_failed_rule :_AlphanumericAscii unless _tmp
- return _tmp
- end
-
- # BOM = %literals.BOM
- def _BOM
- _tmp = @_grammar_literals.external_invoke(self, :_BOM)
- set_failed_rule :_BOM unless _tmp
- return _tmp
- end
-
- # Newline = %literals.Newline
- def _Newline
- _tmp = @_grammar_literals.external_invoke(self, :_Newline)
- set_failed_rule :_Newline unless _tmp
- return _tmp
- end
-
- # Spacechar = %literals.Spacechar
- def _Spacechar
- _tmp = @_grammar_literals.external_invoke(self, :_Spacechar)
- set_failed_rule :_Spacechar unless _tmp
- return _tmp
- end
-
- # HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";" { [text.to_i(16)].pack 'U' }
- def _HexEntity
-
- _save = self.pos
- while true # sequence
- _tmp = scan(/\G(?i-mx:&#x)/)
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:[0-9a-fA-F]+)/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(";")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; [text.to_i(16)].pack 'U' ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_HexEntity unless _tmp
- return _tmp
- end
-
- # DecEntity = "&#" < /[0-9]+/ > ";" { [text.to_i].pack 'U' }
- def _DecEntity
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("&#")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:[0-9]+)/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(";")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; [text.to_i].pack 'U' ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_DecEntity unless _tmp
- return _tmp
- end
-
- # CharEntity = "&" < /[A-Za-z0-9]+/ > ";" { if entity = HTML_ENTITIES[text] then entity.pack 'U*' else "&#{text};" end }
- def _CharEntity
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("&")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:[A-Za-z0-9]+)/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(";")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; if entity = HTML_ENTITIES[text] then
- entity.pack 'U*'
- else
- "&#{text};"
- end
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_CharEntity unless _tmp
- return _tmp
- end
-
- # NonindentSpace = / {0,3}/
- def _NonindentSpace
- _tmp = scan(/\G(?-mix: {0,3})/)
- set_failed_rule :_NonindentSpace unless _tmp
- return _tmp
- end
-
- # Indent = /\t| /
- def _Indent
- _tmp = scan(/\G(?-mix:\t| )/)
- set_failed_rule :_Indent unless _tmp
- return _tmp
- end
-
- # IndentedLine = Indent Line
- def _IndentedLine
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_Indent)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Line)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_IndentedLine unless _tmp
- return _tmp
- end
-
- # OptionallyIndentedLine = Indent? Line
- def _OptionallyIndentedLine
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = apply(:_Indent)
- unless _tmp
- _tmp = true
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Line)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_OptionallyIndentedLine unless _tmp
- return _tmp
- end
-
- # StartList = &. { [] }
- def _StartList
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = get_byte
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; [] ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_StartList unless _tmp
- return _tmp
- end
-
- # Line = @RawLine:a { a }
- def _Line
-
- _save = self.pos
- while true # sequence
- _tmp = _RawLine()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Line unless _tmp
- return _tmp
- end
-
- # RawLine = (< /[^\r\n]*/ @Newline > | < .+ > @Eof) { text }
- def _RawLine
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
- _text_start = self.pos
-
- _save2 = self.pos
- while true # sequence
- _tmp = scan(/\G(?-mix:[^\r\n]*)/)
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- text = get_text(_text_start)
- end
- break if _tmp
- self.pos = _save1
-
- _save3 = self.pos
- while true # sequence
- _text_start = self.pos
- _save4 = self.pos
- _tmp = get_byte
- if _tmp
- while true
- _tmp = get_byte
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save4
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = _Eof()
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RawLine unless _tmp
- return _tmp
- end
-
- # SkipBlock = (HtmlBlock | (!"#" !SetextBottom1 !SetextBottom2 !@BlankLine @RawLine)+ @BlankLine* | @BlankLine+ | @RawLine)
- def _SkipBlock
-
- _save = self.pos
- while true # choice
- _tmp = apply(:_HtmlBlock)
- break if _tmp
- self.pos = _save
-
- _save1 = self.pos
- while true # sequence
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("#")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _save5 = self.pos
- _tmp = apply(:_SetextBottom1)
- _tmp = _tmp ? nil : true
- self.pos = _save5
- unless _tmp
- self.pos = _save3
- break
- end
- _save6 = self.pos
- _tmp = apply(:_SetextBottom2)
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save3
- break
- end
- _save7 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = _RawLine()
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save8 = self.pos
- while true # sequence
- _save9 = self.pos
- _tmp = match_string("#")
- _tmp = _tmp ? nil : true
- self.pos = _save9
- unless _tmp
- self.pos = _save8
- break
- end
- _save10 = self.pos
- _tmp = apply(:_SetextBottom1)
- _tmp = _tmp ? nil : true
- self.pos = _save10
- unless _tmp
- self.pos = _save8
- break
- end
- _save11 = self.pos
- _tmp = apply(:_SetextBottom2)
- _tmp = _tmp ? nil : true
- self.pos = _save11
- unless _tmp
- self.pos = _save8
- break
- end
- _save12 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save12
- unless _tmp
- self.pos = _save8
- break
- end
- _tmp = _RawLine()
- unless _tmp
- self.pos = _save8
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save1
- break
- end
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save1
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save
- _save14 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save14
- end
- break if _tmp
- self.pos = _save
- _tmp = _RawLine()
- break if _tmp
- self.pos = _save
- break
- end # end choice
-
- set_failed_rule :_SkipBlock unless _tmp
- return _tmp
- end
-
- # ExtendedSpecialChar = &{ notes? } "^"
- def _ExtendedSpecialChar
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; notes? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("^")
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_ExtendedSpecialChar unless _tmp
- return _tmp
- end
-
- # NoteReference = &{ notes? } RawNoteReference:ref { note_for ref }
- def _NoteReference
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; notes? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_RawNoteReference)
- ref = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; note_for ref ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_NoteReference unless _tmp
- return _tmp
- end
-
- # RawNoteReference = "[^" < (!@Newline !"]" .)+ > "]" { text }
- def _RawNoteReference
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("[^")
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _save4 = self.pos
- _tmp = match_string("]")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = _Newline()
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _save7 = self.pos
- _tmp = match_string("]")
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = get_byte
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("]")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RawNoteReference unless _tmp
- return _tmp
- end
-
- # Note = &{ notes? } @NonindentSpace RawNoteReference:ref ":" @Sp @StartList:a RawNoteBlock:i { a.concat i } (&Indent RawNoteBlock:i { a.concat i })* { @footnotes[ref] = paragraph a nil }
- def _Note
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; notes? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_RawNoteReference)
- ref = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(":")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_RawNoteBlock)
- i = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a.concat i ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- while true
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = apply(:_Indent)
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_RawNoteBlock)
- i = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a.concat i ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; @footnotes[ref] = paragraph a
-
- nil
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Note unless _tmp
- return _tmp
- end
-
- # InlineNote = &{ notes? } "^[" @StartList:a (!"]" Inline:l { a << l })+ "]" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }
- def _InlineNote
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; notes? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("^[")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _save4 = self.pos
- _tmp = match_string("]")
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_Inline)
- l = @result
- unless _tmp
- self.pos = _save3
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = match_string("]")
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_Inline)
- l = @result
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string("]")
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; ref = [:inline, @note_order.length]
- @footnotes[ref] = paragraph a
-
- note_for ref
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_InlineNote unless _tmp
- return _tmp
- end
-
- # Notes = (Note | SkipBlock)*
- def _Notes
- while true
-
- _save1 = self.pos
- while true # choice
- _tmp = apply(:_Note)
- break if _tmp
- self.pos = _save1
- _tmp = apply(:_SkipBlock)
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- set_failed_rule :_Notes unless _tmp
- return _tmp
- end
-
- # RawNoteBlock = @StartList:a (!@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }
- def _RawNoteBlock
-
- _save = self.pos
- while true # sequence
- _tmp = _StartList()
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
-
- _save2 = self.pos
- while true # sequence
- _save3 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save3
- unless _tmp
- self.pos = _save2
- break
- end
- _save4 = self.pos
- _tmp = apply(:_RawNoteReference)
- _tmp = _tmp ? nil : true
- self.pos = _save4
- unless _tmp
- self.pos = _save2
- break
- end
- _tmp = apply(:_OptionallyIndentedLine)
- l = @result
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save5 = self.pos
- while true # sequence
- _save6 = self.pos
- _tmp = _BlankLine()
- _tmp = _tmp ? nil : true
- self.pos = _save6
- unless _tmp
- self.pos = _save5
- break
- end
- _save7 = self.pos
- _tmp = apply(:_RawNoteReference)
- _tmp = _tmp ? nil : true
- self.pos = _save7
- unless _tmp
- self.pos = _save5
- break
- end
- _tmp = apply(:_OptionallyIndentedLine)
- l = @result
- unless _tmp
- self.pos = _save5
- break
- end
- @result = begin; a << l ; end
- _tmp = true
- unless _tmp
- self.pos = _save5
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a << text ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_RawNoteBlock unless _tmp
- return _tmp
- end
-
- # CodeFence = &{ github? } Ticks3 (@Sp StrChunk:format)? Spnl < ((!"`" Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* { verbatim = RDoc::Markup::Verbatim.new text verbatim.format = format.intern if format.instance_of?(String) verbatim }
- def _CodeFence
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; github? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
-
- _save3 = self.pos
- while true # sequence
- _tmp = _Sp()
- unless _tmp
- self.pos = _save3
- break
- end
- _tmp = apply(:_StrChunk)
- format = @result
- unless _tmp
- self.pos = _save3
- end
- break
- end # end sequence
-
- unless _tmp
- _tmp = true
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Spnl)
- unless _tmp
- self.pos = _save
- break
- end
- _text_start = self.pos
- _save4 = self.pos
-
- _save5 = self.pos
- while true # choice
- _save6 = self.pos
-
- _save7 = self.pos
- while true # sequence
- _save8 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save8
- unless _tmp
- self.pos = _save7
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save7
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save9 = self.pos
- while true # sequence
- _save10 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save10
- unless _tmp
- self.pos = _save9
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save9
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save6
- end
- break if _tmp
- self.pos = _save5
-
- _save11 = self.pos
- while true # sequence
- _save12 = self.pos
- _tmp = apply(:_Ticks3)
- _tmp = _tmp ? nil : true
- self.pos = _save12
- unless _tmp
- self.pos = _save11
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save11
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save5
- _tmp = apply(:_Spacechar)
- break if _tmp
- self.pos = _save5
- _tmp = _Newline()
- break if _tmp
- self.pos = _save5
- break
- end # end choice
-
- if _tmp
- while true
-
- _save13 = self.pos
- while true # choice
- _save14 = self.pos
-
- _save15 = self.pos
- while true # sequence
- _save16 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save16
- unless _tmp
- self.pos = _save15
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save15
- end
- break
- end # end sequence
-
- if _tmp
- while true
-
- _save17 = self.pos
- while true # sequence
- _save18 = self.pos
- _tmp = match_string("`")
- _tmp = _tmp ? nil : true
- self.pos = _save18
- unless _tmp
- self.pos = _save17
- break
- end
- _tmp = apply(:_Nonspacechar)
- unless _tmp
- self.pos = _save17
- end
- break
- end # end sequence
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save14
- end
- break if _tmp
- self.pos = _save13
-
- _save19 = self.pos
- while true # sequence
- _save20 = self.pos
- _tmp = apply(:_Ticks3)
- _tmp = _tmp ? nil : true
- self.pos = _save20
- unless _tmp
- self.pos = _save19
- break
- end
- _tmp = scan(/\G(?-mix:`+)/)
- unless _tmp
- self.pos = _save19
- end
- break
- end # end sequence
-
- break if _tmp
- self.pos = _save13
- _tmp = apply(:_Spacechar)
- break if _tmp
- self.pos = _save13
- _tmp = _Newline()
- break if _tmp
- self.pos = _save13
- break
- end # end choice
-
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save4
- end
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Ticks3)
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- while true
- _tmp = _Newline()
- break unless _tmp
- end
- _tmp = true
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; verbatim = RDoc::Markup::Verbatim.new text
- verbatim.format = format.intern if format.instance_of?(String)
- verbatim
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_CodeFence unless _tmp
- return _tmp
- end
-
- # Table = &{ github? } TableHead:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }
- def _Table
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; github? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_TableHead)
- header = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_TableLine)
- line = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _ary = []
- _tmp = apply(:_TableRow)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_TableRow)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save2
- end
- body = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; table = RDoc::Markup::Table.new(header, line, body) ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_Table unless _tmp
- return _tmp
- end
-
- # TableHead = TableItem2+:items "|"? @Newline { items }
- def _TableHead
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _ary = []
- _tmp = apply(:_TableItem2)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_TableItem2)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- items = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _tmp = match_string("|")
- unless _tmp
- _tmp = true
- self.pos = _save2
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; items ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableHead unless _tmp
- return _tmp
- end
-
- # TableRow = ((TableItem:item1 TableItem2*:items { [item1, *items] }):row | TableItem2+:row) "|"? @Newline { row }
- def _TableRow
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _tmp = apply(:_TableItem)
- item1 = @result
- unless _tmp
- self.pos = _save2
- break
- end
- _ary = []
- while true
- _tmp = apply(:_TableItem2)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- items = @result
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; [item1, *items] ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- row = @result
- break if _tmp
- self.pos = _save1
- _save4 = self.pos
- _ary = []
- _tmp = apply(:_TableItem2)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_TableItem2)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save4
- end
- row = @result
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _save5 = self.pos
- _tmp = match_string("|")
- unless _tmp
- _tmp = true
- self.pos = _save5
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; row ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableRow unless _tmp
- return _tmp
- end
-
- # TableItem2 = "|" TableItem
- def _TableItem2
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("|")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_TableItem)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableItem2 unless _tmp
- return _tmp
- end
-
- # TableItem = < /(?:\\.|[^|\n])+/ > { text.strip.gsub(/\\(.)/, '\1') }
- def _TableItem
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = scan(/\G(?-mix:(?:\\.|[^|\n])+)/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; text.strip.gsub(/\\(.)/, '\1') ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableItem unless _tmp
- return _tmp
- end
-
- # TableLine = ((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line | TableAlign2+:line) "|"? @Newline { line }
- def _TableLine
-
- _save = self.pos
- while true # sequence
-
- _save1 = self.pos
- while true # choice
-
- _save2 = self.pos
- while true # sequence
- _tmp = apply(:_TableAlign)
- align1 = @result
- unless _tmp
- self.pos = _save2
- break
- end
- _ary = []
- while true
- _tmp = apply(:_TableAlign2)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- aligns = @result
- unless _tmp
- self.pos = _save2
- break
- end
- @result = begin; [align1, *aligns] ; end
- _tmp = true
- unless _tmp
- self.pos = _save2
- end
- break
- end # end sequence
-
- line = @result
- break if _tmp
- self.pos = _save1
- _save4 = self.pos
- _ary = []
- _tmp = apply(:_TableAlign2)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_TableAlign2)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save4
- end
- line = @result
- break if _tmp
- self.pos = _save1
- break
- end # end choice
-
- unless _tmp
- self.pos = _save
- break
- end
- _save5 = self.pos
- _tmp = match_string("|")
- unless _tmp
- _tmp = true
- self.pos = _save5
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; line ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableLine unless _tmp
- return _tmp
- end
-
- # TableAlign2 = "|" @Sp TableAlign
- def _TableAlign2
-
- _save = self.pos
- while true # sequence
- _tmp = match_string("|")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_TableAlign)
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableAlign2 unless _tmp
- return _tmp
- end
-
- # TableAlign = < /:?-+:?/ > @Sp { text.start_with?(":") ? (text.end_with?(":") ? :center : :left) : (text.end_with?(":") ? :right : nil) }
- def _TableAlign
-
- _save = self.pos
- while true # sequence
- _text_start = self.pos
- _tmp = scan(/\G(?-mix::?-+:?)/)
- if _tmp
- text = get_text(_text_start)
- end
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin;
- text.start_with?(":") ?
- (text.end_with?(":") ? :center : :left) :
- (text.end_with?(":") ? :right : nil)
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_TableAlign unless _tmp
- return _tmp
- end
-
- # DefinitionList = &{ definition_lists? } DefinitionListItem+:list { RDoc::Markup::List.new :NOTE, *list.flatten }
- def _DefinitionList
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _tmp = begin; definition_lists? ; end
- self.pos = _save1
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _ary = []
- _tmp = apply(:_DefinitionListItem)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_DefinitionListItem)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save2
- end
- list = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; RDoc::Markup::List.new :NOTE, *list.flatten ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_DefinitionList unless _tmp
- return _tmp
- end
-
- # DefinitionListItem = DefinitionListLabel+:label DefinitionListDefinition+:defns { list_items = [] list_items << RDoc::Markup::ListItem.new(label, defns.shift) list_items.concat defns.map { |defn| RDoc::Markup::ListItem.new nil, defn } unless list_items.empty? list_items }
- def _DefinitionListItem
-
- _save = self.pos
- while true # sequence
- _save1 = self.pos
- _ary = []
- _tmp = apply(:_DefinitionListLabel)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_DefinitionListLabel)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save1
- end
- label = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save2 = self.pos
- _ary = []
- _tmp = apply(:_DefinitionListDefinition)
- if _tmp
- _ary << @result
- while true
- _tmp = apply(:_DefinitionListDefinition)
- _ary << @result if _tmp
- break unless _tmp
- end
- _tmp = true
- @result = _ary
- else
- self.pos = _save2
- end
- defns = @result
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; list_items = []
- list_items <<
- RDoc::Markup::ListItem.new(label, defns.shift)
-
- list_items.concat defns.map { |defn|
- RDoc::Markup::ListItem.new nil, defn
- } unless list_items.empty?
-
- list_items
- ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_DefinitionListItem unless _tmp
- return _tmp
- end
-
- # DefinitionListLabel = StrChunk:label @Sp @Newline { label }
- def _DefinitionListLabel
-
- _save = self.pos
- while true # sequence
- _tmp = apply(:_StrChunk)
- label = @result
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Sp()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Newline()
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; label ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_DefinitionListLabel unless _tmp
- return _tmp
- end
-
- # DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+ { paragraph a }
- def _DefinitionListDefinition
-
- _save = self.pos
- while true # sequence
- _tmp = _NonindentSpace()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = match_string(":")
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = _Space()
- unless _tmp
- self.pos = _save
- break
- end
- _tmp = apply(:_Inlines)
- a = @result
- unless _tmp
- self.pos = _save
- break
- end
- _save1 = self.pos
- _tmp = _BlankLine()
- if _tmp
- while true
- _tmp = _BlankLine()
- break unless _tmp
- end
- _tmp = true
- else
- self.pos = _save1
- end
- unless _tmp
- self.pos = _save
- break
- end
- @result = begin; paragraph a ; end
- _tmp = true
- unless _tmp
- self.pos = _save
- end
- break
- end # end sequence
-
- set_failed_rule :_DefinitionListDefinition unless _tmp
- return _tmp
- end
-
- Rules = {}
- Rules[:_root] = rule_info("root", "Doc")
- Rules[:_Doc] = rule_info("Doc", "BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }")
- Rules[:_Block] = rule_info("Block", "@BlankLine* (BlockQuote | Verbatim | CodeFence | Table | Note | Reference | HorizontalRule | Heading | OrderedList | BulletList | DefinitionList | HtmlBlock | StyleBlock | Para | Plain)")
- Rules[:_Para] = rule_info("Para", "@NonindentSpace Inlines:a @BlankLine+ { paragraph a }")
- Rules[:_Plain] = rule_info("Plain", "Inlines:a { paragraph a }")
- Rules[:_AtxInline] = rule_info("AtxInline", "!@Newline !(@Sp /\#*/ @Sp @Newline) Inline")
- Rules[:_AtxStart] = rule_info("AtxStart", "< /\\\#{1,6}/ > { text.length }")
- Rules[:_AtxHeading] = rule_info("AtxHeading", "AtxStart:s @Sp AtxInline+:a (@Sp /\#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }")
- Rules[:_SetextHeading] = rule_info("SetextHeading", "(SetextHeading1 | SetextHeading2)")
- Rules[:_SetextBottom1] = rule_info("SetextBottom1", "/={1,}/ @Newline")
- Rules[:_SetextBottom2] = rule_info("SetextBottom2", "/-{1,}/ @Newline")
- Rules[:_SetextHeading1] = rule_info("SetextHeading1", "&(@RawLine SetextBottom1) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) }")
- Rules[:_SetextHeading2] = rule_info("SetextHeading2", "&(@RawLine SetextBottom2) @StartList:a (!@Endline Inline:b { a << b })+ @Sp @Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) }")
- Rules[:_Heading] = rule_info("Heading", "(SetextHeading | AtxHeading)")
- Rules[:_BlockQuote] = rule_info("BlockQuote", "BlockQuoteRaw:a { RDoc::Markup::BlockQuote.new(*a) }")
- Rules[:_BlockQuoteRaw] = rule_info("BlockQuoteRaw", "@StartList:a (\">\" \" \"? Line:l { a << l } (!\">\" !@BlankLine Line:c { a << c })* (@BlankLine:n { a << n })*)+ { inner_parse a.join }")
- Rules[:_NonblankIndentedLine] = rule_info("NonblankIndentedLine", "!@BlankLine IndentedLine")
- Rules[:_VerbatimChunk] = rule_info("VerbatimChunk", "@BlankLine*:a NonblankIndentedLine+:b { a.concat b }")
- Rules[:_Verbatim] = rule_info("Verbatim", "VerbatimChunk+:a { RDoc::Markup::Verbatim.new(*a.flatten) }")
- Rules[:_HorizontalRule] = rule_info("HorizontalRule", "@NonindentSpace (\"*\" @Sp \"*\" @Sp \"*\" (@Sp \"*\")* | \"-\" @Sp \"-\" @Sp \"-\" (@Sp \"-\")* | \"_\" @Sp \"_\" @Sp \"_\" (@Sp \"_\")*) @Sp @Newline @BlankLine+ { RDoc::Markup::Rule.new 1 }")
- Rules[:_Bullet] = rule_info("Bullet", "!HorizontalRule @NonindentSpace /[+*-]/ @Spacechar+")
- Rules[:_BulletList] = rule_info("BulletList", "&Bullet (ListTight | ListLoose):a { RDoc::Markup::List.new(:BULLET, *a) }")
- Rules[:_ListTight] = rule_info("ListTight", "ListItemTight+:a @BlankLine* !(Bullet | Enumerator) { a }")
- Rules[:_ListLoose] = rule_info("ListLoose", "@StartList:a (ListItem:b @BlankLine* { a << b })+ { a }")
- Rules[:_ListItem] = rule_info("ListItem", "(Bullet | Enumerator) @StartList:a ListBlock:b { a << b } (ListContinuationBlock:c { a.push(*c) })* { list_item_from a }")
- Rules[:_ListItemTight] = rule_info("ListItemTight", "(Bullet | Enumerator) ListBlock:a (!@BlankLine ListContinuationBlock:b { a.push(*b) })* !ListContinuationBlock { list_item_from a }")
- Rules[:_ListBlock] = rule_info("ListBlock", "!@BlankLine Line:a ListBlockLine*:c { [a, *c] }")
- Rules[:_ListContinuationBlock] = rule_info("ListContinuationBlock", "@StartList:a @BlankLine* { a << \"\\n\" } (Indent ListBlock:b { a.concat b })+ { a }")
- Rules[:_Enumerator] = rule_info("Enumerator", "@NonindentSpace [0-9]+ \".\" @Spacechar+")
- Rules[:_OrderedList] = rule_info("OrderedList", "&Enumerator (ListTight | ListLoose):a { RDoc::Markup::List.new(:NUMBER, *a) }")
- Rules[:_ListBlockLine] = rule_info("ListBlockLine", "!@BlankLine !(Indent? (Bullet | Enumerator)) !HorizontalRule OptionallyIndentedLine")
- Rules[:_HtmlOpenAnchor] = rule_info("HtmlOpenAnchor", "\"<\" Spnl (\"a\" | \"A\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlCloseAnchor] = rule_info("HtmlCloseAnchor", "\"<\" Spnl \"/\" (\"a\" | \"A\") Spnl \">\"")
- Rules[:_HtmlAnchor] = rule_info("HtmlAnchor", "HtmlOpenAnchor (HtmlAnchor | !HtmlCloseAnchor .)* HtmlCloseAnchor")
- Rules[:_HtmlBlockOpenAddress] = rule_info("HtmlBlockOpenAddress", "\"<\" Spnl (\"address\" | \"ADDRESS\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseAddress] = rule_info("HtmlBlockCloseAddress", "\"<\" Spnl \"/\" (\"address\" | \"ADDRESS\") Spnl \">\"")
- Rules[:_HtmlBlockAddress] = rule_info("HtmlBlockAddress", "HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress")
- Rules[:_HtmlBlockOpenBlockquote] = rule_info("HtmlBlockOpenBlockquote", "\"<\" Spnl (\"blockquote\" | \"BLOCKQUOTE\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseBlockquote] = rule_info("HtmlBlockCloseBlockquote", "\"<\" Spnl \"/\" (\"blockquote\" | \"BLOCKQUOTE\") Spnl \">\"")
- Rules[:_HtmlBlockBlockquote] = rule_info("HtmlBlockBlockquote", "HtmlBlockOpenBlockquote (HtmlBlockBlockquote | !HtmlBlockCloseBlockquote .)* HtmlBlockCloseBlockquote")
- Rules[:_HtmlBlockOpenCenter] = rule_info("HtmlBlockOpenCenter", "\"<\" Spnl (\"center\" | \"CENTER\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseCenter] = rule_info("HtmlBlockCloseCenter", "\"<\" Spnl \"/\" (\"center\" | \"CENTER\") Spnl \">\"")
- Rules[:_HtmlBlockCenter] = rule_info("HtmlBlockCenter", "HtmlBlockOpenCenter (HtmlBlockCenter | !HtmlBlockCloseCenter .)* HtmlBlockCloseCenter")
- Rules[:_HtmlBlockOpenDir] = rule_info("HtmlBlockOpenDir", "\"<\" Spnl (\"dir\" | \"DIR\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseDir] = rule_info("HtmlBlockCloseDir", "\"<\" Spnl \"/\" (\"dir\" | \"DIR\") Spnl \">\"")
- Rules[:_HtmlBlockDir] = rule_info("HtmlBlockDir", "HtmlBlockOpenDir (HtmlBlockDir | !HtmlBlockCloseDir .)* HtmlBlockCloseDir")
- Rules[:_HtmlBlockOpenDiv] = rule_info("HtmlBlockOpenDiv", "\"<\" Spnl (\"div\" | \"DIV\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseDiv] = rule_info("HtmlBlockCloseDiv", "\"<\" Spnl \"/\" (\"div\" | \"DIV\") Spnl \">\"")
- Rules[:_HtmlBlockDiv] = rule_info("HtmlBlockDiv", "HtmlBlockOpenDiv (HtmlBlockDiv | !HtmlBlockCloseDiv .)* HtmlBlockCloseDiv")
- Rules[:_HtmlBlockOpenDl] = rule_info("HtmlBlockOpenDl", "\"<\" Spnl (\"dl\" | \"DL\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseDl] = rule_info("HtmlBlockCloseDl", "\"<\" Spnl \"/\" (\"dl\" | \"DL\") Spnl \">\"")
- Rules[:_HtmlBlockDl] = rule_info("HtmlBlockDl", "HtmlBlockOpenDl (HtmlBlockDl | !HtmlBlockCloseDl .)* HtmlBlockCloseDl")
- Rules[:_HtmlBlockOpenFieldset] = rule_info("HtmlBlockOpenFieldset", "\"<\" Spnl (\"fieldset\" | \"FIELDSET\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseFieldset] = rule_info("HtmlBlockCloseFieldset", "\"<\" Spnl \"/\" (\"fieldset\" | \"FIELDSET\") Spnl \">\"")
- Rules[:_HtmlBlockFieldset] = rule_info("HtmlBlockFieldset", "HtmlBlockOpenFieldset (HtmlBlockFieldset | !HtmlBlockCloseFieldset .)* HtmlBlockCloseFieldset")
- Rules[:_HtmlBlockOpenForm] = rule_info("HtmlBlockOpenForm", "\"<\" Spnl (\"form\" | \"FORM\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseForm] = rule_info("HtmlBlockCloseForm", "\"<\" Spnl \"/\" (\"form\" | \"FORM\") Spnl \">\"")
- Rules[:_HtmlBlockForm] = rule_info("HtmlBlockForm", "HtmlBlockOpenForm (HtmlBlockForm | !HtmlBlockCloseForm .)* HtmlBlockCloseForm")
- Rules[:_HtmlBlockOpenH1] = rule_info("HtmlBlockOpenH1", "\"<\" Spnl (\"h1\" | \"H1\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH1] = rule_info("HtmlBlockCloseH1", "\"<\" Spnl \"/\" (\"h1\" | \"H1\") Spnl \">\"")
- Rules[:_HtmlBlockH1] = rule_info("HtmlBlockH1", "HtmlBlockOpenH1 (HtmlBlockH1 | !HtmlBlockCloseH1 .)* HtmlBlockCloseH1")
- Rules[:_HtmlBlockOpenH2] = rule_info("HtmlBlockOpenH2", "\"<\" Spnl (\"h2\" | \"H2\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH2] = rule_info("HtmlBlockCloseH2", "\"<\" Spnl \"/\" (\"h2\" | \"H2\") Spnl \">\"")
- Rules[:_HtmlBlockH2] = rule_info("HtmlBlockH2", "HtmlBlockOpenH2 (HtmlBlockH2 | !HtmlBlockCloseH2 .)* HtmlBlockCloseH2")
- Rules[:_HtmlBlockOpenH3] = rule_info("HtmlBlockOpenH3", "\"<\" Spnl (\"h3\" | \"H3\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH3] = rule_info("HtmlBlockCloseH3", "\"<\" Spnl \"/\" (\"h3\" | \"H3\") Spnl \">\"")
- Rules[:_HtmlBlockH3] = rule_info("HtmlBlockH3", "HtmlBlockOpenH3 (HtmlBlockH3 | !HtmlBlockCloseH3 .)* HtmlBlockCloseH3")
- Rules[:_HtmlBlockOpenH4] = rule_info("HtmlBlockOpenH4", "\"<\" Spnl (\"h4\" | \"H4\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH4] = rule_info("HtmlBlockCloseH4", "\"<\" Spnl \"/\" (\"h4\" | \"H4\") Spnl \">\"")
- Rules[:_HtmlBlockH4] = rule_info("HtmlBlockH4", "HtmlBlockOpenH4 (HtmlBlockH4 | !HtmlBlockCloseH4 .)* HtmlBlockCloseH4")
- Rules[:_HtmlBlockOpenH5] = rule_info("HtmlBlockOpenH5", "\"<\" Spnl (\"h5\" | \"H5\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH5] = rule_info("HtmlBlockCloseH5", "\"<\" Spnl \"/\" (\"h5\" | \"H5\") Spnl \">\"")
- Rules[:_HtmlBlockH5] = rule_info("HtmlBlockH5", "HtmlBlockOpenH5 (HtmlBlockH5 | !HtmlBlockCloseH5 .)* HtmlBlockCloseH5")
- Rules[:_HtmlBlockOpenH6] = rule_info("HtmlBlockOpenH6", "\"<\" Spnl (\"h6\" | \"H6\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseH6] = rule_info("HtmlBlockCloseH6", "\"<\" Spnl \"/\" (\"h6\" | \"H6\") Spnl \">\"")
- Rules[:_HtmlBlockH6] = rule_info("HtmlBlockH6", "HtmlBlockOpenH6 (HtmlBlockH6 | !HtmlBlockCloseH6 .)* HtmlBlockCloseH6")
- Rules[:_HtmlBlockOpenMenu] = rule_info("HtmlBlockOpenMenu", "\"<\" Spnl (\"menu\" | \"MENU\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseMenu] = rule_info("HtmlBlockCloseMenu", "\"<\" Spnl \"/\" (\"menu\" | \"MENU\") Spnl \">\"")
- Rules[:_HtmlBlockMenu] = rule_info("HtmlBlockMenu", "HtmlBlockOpenMenu (HtmlBlockMenu | !HtmlBlockCloseMenu .)* HtmlBlockCloseMenu")
- Rules[:_HtmlBlockOpenNoframes] = rule_info("HtmlBlockOpenNoframes", "\"<\" Spnl (\"noframes\" | \"NOFRAMES\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseNoframes] = rule_info("HtmlBlockCloseNoframes", "\"<\" Spnl \"/\" (\"noframes\" | \"NOFRAMES\") Spnl \">\"")
- Rules[:_HtmlBlockNoframes] = rule_info("HtmlBlockNoframes", "HtmlBlockOpenNoframes (HtmlBlockNoframes | !HtmlBlockCloseNoframes .)* HtmlBlockCloseNoframes")
- Rules[:_HtmlBlockOpenNoscript] = rule_info("HtmlBlockOpenNoscript", "\"<\" Spnl (\"noscript\" | \"NOSCRIPT\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseNoscript] = rule_info("HtmlBlockCloseNoscript", "\"<\" Spnl \"/\" (\"noscript\" | \"NOSCRIPT\") Spnl \">\"")
- Rules[:_HtmlBlockNoscript] = rule_info("HtmlBlockNoscript", "HtmlBlockOpenNoscript (HtmlBlockNoscript | !HtmlBlockCloseNoscript .)* HtmlBlockCloseNoscript")
- Rules[:_HtmlBlockOpenOl] = rule_info("HtmlBlockOpenOl", "\"<\" Spnl (\"ol\" | \"OL\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseOl] = rule_info("HtmlBlockCloseOl", "\"<\" Spnl \"/\" (\"ol\" | \"OL\") Spnl \">\"")
- Rules[:_HtmlBlockOl] = rule_info("HtmlBlockOl", "HtmlBlockOpenOl (HtmlBlockOl | !HtmlBlockCloseOl .)* HtmlBlockCloseOl")
- Rules[:_HtmlBlockOpenP] = rule_info("HtmlBlockOpenP", "\"<\" Spnl (\"p\" | \"P\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseP] = rule_info("HtmlBlockCloseP", "\"<\" Spnl \"/\" (\"p\" | \"P\") Spnl \">\"")
- Rules[:_HtmlBlockP] = rule_info("HtmlBlockP", "HtmlBlockOpenP (HtmlBlockP | !HtmlBlockCloseP .)* HtmlBlockCloseP")
- Rules[:_HtmlBlockOpenPre] = rule_info("HtmlBlockOpenPre", "\"<\" Spnl (\"pre\" | \"PRE\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockClosePre] = rule_info("HtmlBlockClosePre", "\"<\" Spnl \"/\" (\"pre\" | \"PRE\") Spnl \">\"")
- Rules[:_HtmlBlockPre] = rule_info("HtmlBlockPre", "HtmlBlockOpenPre (HtmlBlockPre | !HtmlBlockClosePre .)* HtmlBlockClosePre")
- Rules[:_HtmlBlockOpenTable] = rule_info("HtmlBlockOpenTable", "\"<\" Spnl (\"table\" | \"TABLE\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTable] = rule_info("HtmlBlockCloseTable", "\"<\" Spnl \"/\" (\"table\" | \"TABLE\") Spnl \">\"")
- Rules[:_HtmlBlockTable] = rule_info("HtmlBlockTable", "HtmlBlockOpenTable (HtmlBlockTable | !HtmlBlockCloseTable .)* HtmlBlockCloseTable")
- Rules[:_HtmlBlockOpenUl] = rule_info("HtmlBlockOpenUl", "\"<\" Spnl (\"ul\" | \"UL\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseUl] = rule_info("HtmlBlockCloseUl", "\"<\" Spnl \"/\" (\"ul\" | \"UL\") Spnl \">\"")
- Rules[:_HtmlBlockUl] = rule_info("HtmlBlockUl", "HtmlBlockOpenUl (HtmlBlockUl | !HtmlBlockCloseUl .)* HtmlBlockCloseUl")
- Rules[:_HtmlBlockOpenDd] = rule_info("HtmlBlockOpenDd", "\"<\" Spnl (\"dd\" | \"DD\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseDd] = rule_info("HtmlBlockCloseDd", "\"<\" Spnl \"/\" (\"dd\" | \"DD\") Spnl \">\"")
- Rules[:_HtmlBlockDd] = rule_info("HtmlBlockDd", "HtmlBlockOpenDd (HtmlBlockDd | !HtmlBlockCloseDd .)* HtmlBlockCloseDd")
- Rules[:_HtmlBlockOpenDt] = rule_info("HtmlBlockOpenDt", "\"<\" Spnl (\"dt\" | \"DT\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseDt] = rule_info("HtmlBlockCloseDt", "\"<\" Spnl \"/\" (\"dt\" | \"DT\") Spnl \">\"")
- Rules[:_HtmlBlockDt] = rule_info("HtmlBlockDt", "HtmlBlockOpenDt (HtmlBlockDt | !HtmlBlockCloseDt .)* HtmlBlockCloseDt")
- Rules[:_HtmlBlockOpenFrameset] = rule_info("HtmlBlockOpenFrameset", "\"<\" Spnl (\"frameset\" | \"FRAMESET\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseFrameset] = rule_info("HtmlBlockCloseFrameset", "\"<\" Spnl \"/\" (\"frameset\" | \"FRAMESET\") Spnl \">\"")
- Rules[:_HtmlBlockFrameset] = rule_info("HtmlBlockFrameset", "HtmlBlockOpenFrameset (HtmlBlockFrameset | !HtmlBlockCloseFrameset .)* HtmlBlockCloseFrameset")
- Rules[:_HtmlBlockOpenLi] = rule_info("HtmlBlockOpenLi", "\"<\" Spnl (\"li\" | \"LI\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseLi] = rule_info("HtmlBlockCloseLi", "\"<\" Spnl \"/\" (\"li\" | \"LI\") Spnl \">\"")
- Rules[:_HtmlBlockLi] = rule_info("HtmlBlockLi", "HtmlBlockOpenLi (HtmlBlockLi | !HtmlBlockCloseLi .)* HtmlBlockCloseLi")
- Rules[:_HtmlBlockOpenTbody] = rule_info("HtmlBlockOpenTbody", "\"<\" Spnl (\"tbody\" | \"TBODY\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTbody] = rule_info("HtmlBlockCloseTbody", "\"<\" Spnl \"/\" (\"tbody\" | \"TBODY\") Spnl \">\"")
- Rules[:_HtmlBlockTbody] = rule_info("HtmlBlockTbody", "HtmlBlockOpenTbody (HtmlBlockTbody | !HtmlBlockCloseTbody .)* HtmlBlockCloseTbody")
- Rules[:_HtmlBlockOpenTd] = rule_info("HtmlBlockOpenTd", "\"<\" Spnl (\"td\" | \"TD\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTd] = rule_info("HtmlBlockCloseTd", "\"<\" Spnl \"/\" (\"td\" | \"TD\") Spnl \">\"")
- Rules[:_HtmlBlockTd] = rule_info("HtmlBlockTd", "HtmlBlockOpenTd (HtmlBlockTd | !HtmlBlockCloseTd .)* HtmlBlockCloseTd")
- Rules[:_HtmlBlockOpenTfoot] = rule_info("HtmlBlockOpenTfoot", "\"<\" Spnl (\"tfoot\" | \"TFOOT\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTfoot] = rule_info("HtmlBlockCloseTfoot", "\"<\" Spnl \"/\" (\"tfoot\" | \"TFOOT\") Spnl \">\"")
- Rules[:_HtmlBlockTfoot] = rule_info("HtmlBlockTfoot", "HtmlBlockOpenTfoot (HtmlBlockTfoot | !HtmlBlockCloseTfoot .)* HtmlBlockCloseTfoot")
- Rules[:_HtmlBlockOpenTh] = rule_info("HtmlBlockOpenTh", "\"<\" Spnl (\"th\" | \"TH\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTh] = rule_info("HtmlBlockCloseTh", "\"<\" Spnl \"/\" (\"th\" | \"TH\") Spnl \">\"")
- Rules[:_HtmlBlockTh] = rule_info("HtmlBlockTh", "HtmlBlockOpenTh (HtmlBlockTh | !HtmlBlockCloseTh .)* HtmlBlockCloseTh")
- Rules[:_HtmlBlockOpenThead] = rule_info("HtmlBlockOpenThead", "\"<\" Spnl (\"thead\" | \"THEAD\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseThead] = rule_info("HtmlBlockCloseThead", "\"<\" Spnl \"/\" (\"thead\" | \"THEAD\") Spnl \">\"")
- Rules[:_HtmlBlockThead] = rule_info("HtmlBlockThead", "HtmlBlockOpenThead (HtmlBlockThead | !HtmlBlockCloseThead .)* HtmlBlockCloseThead")
- Rules[:_HtmlBlockOpenTr] = rule_info("HtmlBlockOpenTr", "\"<\" Spnl (\"tr\" | \"TR\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseTr] = rule_info("HtmlBlockCloseTr", "\"<\" Spnl \"/\" (\"tr\" | \"TR\") Spnl \">\"")
- Rules[:_HtmlBlockTr] = rule_info("HtmlBlockTr", "HtmlBlockOpenTr (HtmlBlockTr | !HtmlBlockCloseTr .)* HtmlBlockCloseTr")
- Rules[:_HtmlBlockOpenScript] = rule_info("HtmlBlockOpenScript", "\"<\" Spnl (\"script\" | \"SCRIPT\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseScript] = rule_info("HtmlBlockCloseScript", "\"<\" Spnl \"/\" (\"script\" | \"SCRIPT\") Spnl \">\"")
- Rules[:_HtmlBlockScript] = rule_info("HtmlBlockScript", "HtmlBlockOpenScript (!HtmlBlockCloseScript .)* HtmlBlockCloseScript")
- Rules[:_HtmlBlockOpenHead] = rule_info("HtmlBlockOpenHead", "\"<\" Spnl (\"head\" | \"HEAD\") Spnl HtmlAttribute* \">\"")
- Rules[:_HtmlBlockCloseHead] = rule_info("HtmlBlockCloseHead", "\"<\" Spnl \"/\" (\"head\" | \"HEAD\") Spnl \">\"")
- Rules[:_HtmlBlockHead] = rule_info("HtmlBlockHead", "HtmlBlockOpenHead (!HtmlBlockCloseHead .)* HtmlBlockCloseHead")
- Rules[:_HtmlBlockInTags] = rule_info("HtmlBlockInTags", "(HtmlAnchor | HtmlBlockAddress | HtmlBlockBlockquote | HtmlBlockCenter | HtmlBlockDir | HtmlBlockDiv | HtmlBlockDl | HtmlBlockFieldset | HtmlBlockForm | HtmlBlockH1 | HtmlBlockH2 | HtmlBlockH3 | HtmlBlockH4 | HtmlBlockH5 | HtmlBlockH6 | HtmlBlockMenu | HtmlBlockNoframes | HtmlBlockNoscript | HtmlBlockOl | HtmlBlockP | HtmlBlockPre | HtmlBlockTable | HtmlBlockUl | HtmlBlockDd | HtmlBlockDt | HtmlBlockFrameset | HtmlBlockLi | HtmlBlockTbody | HtmlBlockTd | HtmlBlockTfoot | HtmlBlockTh | HtmlBlockThead | HtmlBlockTr | HtmlBlockScript | HtmlBlockHead)")
- Rules[:_HtmlBlock] = rule_info("HtmlBlock", "< (HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) > @BlankLine+ { if html? then RDoc::Markup::Raw.new text end }")
- Rules[:_HtmlUnclosed] = rule_info("HtmlUnclosed", "\"<\" Spnl HtmlUnclosedType Spnl HtmlAttribute* Spnl \">\"")
- Rules[:_HtmlUnclosedType] = rule_info("HtmlUnclosedType", "(\"HR\" | \"hr\")")
- Rules[:_HtmlBlockSelfClosing] = rule_info("HtmlBlockSelfClosing", "\"<\" Spnl HtmlBlockType Spnl HtmlAttribute* \"/\" Spnl \">\"")
- Rules[:_HtmlBlockType] = rule_info("HtmlBlockType", "(\"ADDRESS\" | \"BLOCKQUOTE\" | \"CENTER\" | \"DD\" | \"DIR\" | \"DIV\" | \"DL\" | \"DT\" | \"FIELDSET\" | \"FORM\" | \"FRAMESET\" | \"H1\" | \"H2\" | \"H3\" | \"H4\" | \"H5\" | \"H6\" | \"HR\" | \"ISINDEX\" | \"LI\" | \"MENU\" | \"NOFRAMES\" | \"NOSCRIPT\" | \"OL\" | \"P\" | \"PRE\" | \"SCRIPT\" | \"TABLE\" | \"TBODY\" | \"TD\" | \"TFOOT\" | \"TH\" | \"THEAD\" | \"TR\" | \"UL\" | \"address\" | \"blockquote\" | \"center\" | \"dd\" | \"dir\" | \"div\" | \"dl\" | \"dt\" | \"fieldset\" | \"form\" | \"frameset\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"hr\" | \"isindex\" | \"li\" | \"menu\" | \"noframes\" | \"noscript\" | \"ol\" | \"p\" | \"pre\" | \"script\" | \"table\" | \"tbody\" | \"td\" | \"tfoot\" | \"th\" | \"thead\" | \"tr\" | \"ul\")")
- Rules[:_StyleOpen] = rule_info("StyleOpen", "\"<\" Spnl (\"style\" | \"STYLE\") Spnl HtmlAttribute* \">\"")
- Rules[:_StyleClose] = rule_info("StyleClose", "\"<\" Spnl \"/\" (\"style\" | \"STYLE\") Spnl \">\"")
- Rules[:_InStyleTags] = rule_info("InStyleTags", "StyleOpen (!StyleClose .)* StyleClose")
- Rules[:_StyleBlock] = rule_info("StyleBlock", "< InStyleTags > @BlankLine* { if css? then RDoc::Markup::Raw.new text end }")
- Rules[:_Inlines] = rule_info("Inlines", "(!@Endline Inline:i { i } | @Endline:c !(&{ github? } Ticks3 /[^`\\n]*$/) &Inline { c })+:chunks @Endline? { chunks }")
- Rules[:_Inline] = rule_info("Inline", "(Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol)")
- Rules[:_Space] = rule_info("Space", "@Spacechar+ { \" \" }")
- Rules[:_Str] = rule_info("Str", "@StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a }")
- Rules[:_StrChunk] = rule_info("StrChunk", "< (@NormalChar | /_+/ &Alphanumeric)+ > { text }")
- Rules[:_EscapedChar] = rule_info("EscapedChar", "\"\\\\\" !@Newline < /[:\\\\`|*_{}\\[\\]()\#+.!><-]/ > { text }")
- Rules[:_Entity] = rule_info("Entity", "(HexEntity | DecEntity | CharEntity):a { a }")
- Rules[:_Endline] = rule_info("Endline", "(@LineBreak | @TerminalEndline | @NormalEndline)")
- Rules[:_NormalEndline] = rule_info("NormalEndline", "@Sp @Newline !@BlankLine !\">\" !AtxStart !(Line /={1,}|-{1,}/ @Newline) { \"\\n\" }")
- Rules[:_TerminalEndline] = rule_info("TerminalEndline", "@Sp @Newline @Eof")
- Rules[:_LineBreak] = rule_info("LineBreak", "\" \" @NormalEndline { RDoc::Markup::HardBreak.new }")
- Rules[:_Symbol] = rule_info("Symbol", "< @SpecialChar > { text }")
- Rules[:_UlOrStarLine] = rule_info("UlOrStarLine", "(UlLine | StarLine):a { a }")
- Rules[:_StarLine] = rule_info("StarLine", "(< /\\*{4,}/ > { text } | < @Spacechar /\\*+/ &@Spacechar > { text })")
- Rules[:_UlLine] = rule_info("UlLine", "(< /_{4,}/ > { text } | < @Spacechar /_+/ &@Spacechar > { text })")
- Rules[:_Emph] = rule_info("Emph", "(EmphStar | EmphUl)")
- Rules[:_Whitespace] = rule_info("Whitespace", "(@Spacechar | @Newline)")
- Rules[:_EmphStar] = rule_info("EmphStar", "\"*\" !@Whitespace @StartList:a (!\"*\" Inline:b { a << b } | StrongStar:b { a << b })+ \"*\" { emphasis a.join }")
- Rules[:_EmphUl] = rule_info("EmphUl", "\"_\" !@Whitespace @StartList:a (!\"_\" Inline:b { a << b } | StrongUl:b { a << b })+ \"_\" { emphasis a.join }")
- Rules[:_Strong] = rule_info("Strong", "(StrongStar | StrongUl)")
- Rules[:_StrongStar] = rule_info("StrongStar", "\"**\" !@Whitespace @StartList:a (!\"**\" Inline:b { a << b })+ \"**\" { strong a.join }")
- Rules[:_StrongUl] = rule_info("StrongUl", "\"__\" !@Whitespace @StartList:a (!\"__\" Inline:b { a << b })+ \"__\" { strong a.join }")
- Rules[:_Strike] = rule_info("Strike", "&{ strike? } \"~~\" !@Whitespace @StartList:a (!\"~~\" Inline:b { a << b })+ \"~~\" { strike a.join }")
- Rules[:_Image] = rule_info("Image", "\"!\" (ExplicitLink | ReferenceLink):a { \"rdoc-image:\#{a[/\\[(.*)\\]/, 1]}\" }")
- Rules[:_Link] = rule_info("Link", "(ExplicitLink | ReferenceLink | AutoLink)")
- Rules[:_ReferenceLink] = rule_info("ReferenceLink", "(ReferenceLinkDouble | ReferenceLinkSingle)")
- Rules[:_ReferenceLinkDouble] = rule_info("ReferenceLinkDouble", "Label:content < Spnl > !\"[]\" Label:label { link_to content, label, text }")
- Rules[:_ReferenceLinkSingle] = rule_info("ReferenceLinkSingle", "Label:content < (Spnl \"[]\")? > { link_to content, content, text }")
- Rules[:_ExplicitLink] = rule_info("ExplicitLink", "Label:l \"(\" @Sp Source:s Spnl Title @Sp \")\" { \"{\#{l}}[\#{s}]\" }")
- Rules[:_Source] = rule_info("Source", "(\"<\" < SourceContents > \">\" | < SourceContents >) { text }")
- Rules[:_SourceContents] = rule_info("SourceContents", "((!\"(\" !\")\" !\">\" Nonspacechar)+ | \"(\" SourceContents \")\")*")
- Rules[:_Title] = rule_info("Title", "(TitleSingle | TitleDouble | \"\"):a { a }")
- Rules[:_TitleSingle] = rule_info("TitleSingle", "\"'\" (!(\"'\" @Sp (\")\" | @Newline)) .)* \"'\"")
- Rules[:_TitleDouble] = rule_info("TitleDouble", "\"\\\"\" (!(\"\\\"\" @Sp (\")\" | @Newline)) .)* \"\\\"\"")
- Rules[:_AutoLink] = rule_info("AutoLink", "(AutoLinkUrl | AutoLinkEmail)")
- Rules[:_AutoLinkUrl] = rule_info("AutoLinkUrl", "\"<\" < /[A-Za-z]+/ \"://\" (!@Newline !\">\" .)+ > \">\" { text }")
- Rules[:_AutoLinkEmail] = rule_info("AutoLinkEmail", "\"<\" \"mailto:\"? < /[\\w+.\\/!%~$-]+/i \"@\" (!@Newline !\">\" .)+ > \">\" { \"mailto:\#{text}\" }")
- Rules[:_Reference] = rule_info("Reference", "@NonindentSpace !\"[]\" Label:label \":\" Spnl RefSrc:link RefTitle @BlankLine+ { \# TODO use title reference label, link nil }")
- Rules[:_Label] = rule_info("Label", "\"[\" (!\"^\" &{ notes? } | &. &{ !notes? }) @StartList:a (!\"]\" Inline:l { a << l })* \"]\" { a.join.gsub(/\\s+/, ' ') }")
- Rules[:_RefSrc] = rule_info("RefSrc", "< Nonspacechar+ > { text }")
- Rules[:_RefTitle] = rule_info("RefTitle", "(RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle)")
- Rules[:_EmptyTitle] = rule_info("EmptyTitle", "\"\"")
- Rules[:_RefTitleSingle] = rule_info("RefTitleSingle", "Spnl \"'\" < (!(\"'\" @Sp @Newline | @Newline) .)* > \"'\" { text }")
- Rules[:_RefTitleDouble] = rule_info("RefTitleDouble", "Spnl \"\\\"\" < (!(\"\\\"\" @Sp @Newline | @Newline) .)* > \"\\\"\" { text }")
- Rules[:_RefTitleParens] = rule_info("RefTitleParens", "Spnl \"(\" < (!(\")\" @Sp @Newline | @Newline) .)* > \")\" { text }")
- Rules[:_References] = rule_info("References", "(Reference | SkipBlock)*")
- Rules[:_Ticks1] = rule_info("Ticks1", "\"`\" !\"`\"")
- Rules[:_Ticks2] = rule_info("Ticks2", "\"``\" !\"`\"")
- Rules[:_Ticks3] = rule_info("Ticks3", "\"```\" !\"`\"")
- Rules[:_Ticks4] = rule_info("Ticks4", "\"````\" !\"`\"")
- Rules[:_Ticks5] = rule_info("Ticks5", "\"`````\" !\"`\"")
- Rules[:_Code] = rule_info("Code", "(Ticks1 @Sp < ((!\"`\" Nonspacechar)+ | !Ticks1 /`+/ | !(@Sp Ticks1) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks1 | Ticks2 @Sp < ((!\"`\" Nonspacechar)+ | !Ticks2 /`+/ | !(@Sp Ticks2) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks2 | Ticks3 @Sp < ((!\"`\" Nonspacechar)+ | !Ticks3 /`+/ | !(@Sp Ticks3) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks3 | Ticks4 @Sp < ((!\"`\" Nonspacechar)+ | !Ticks4 /`+/ | !(@Sp Ticks4) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks4 | Ticks5 @Sp < ((!\"`\" Nonspacechar)+ | !Ticks5 /`+/ | !(@Sp Ticks5) (@Spacechar | @Newline !@BlankLine))+ > @Sp Ticks5) { \"<code>\#{text}</code>\" }")
- Rules[:_RawHtml] = rule_info("RawHtml", "< (HtmlComment | HtmlBlockScript | HtmlTag) > { if html? then text else '' end }")
- Rules[:_BlankLine] = rule_info("BlankLine", "@Sp @Newline { \"\\n\" }")
- Rules[:_Quoted] = rule_info("Quoted", "(\"\\\"\" (!\"\\\"\" .)* \"\\\"\" | \"'\" (!\"'\" .)* \"'\")")
- Rules[:_HtmlAttribute] = rule_info("HtmlAttribute", "(AlphanumericAscii | \"-\")+ Spnl (\"=\" Spnl (Quoted | (!\">\" Nonspacechar)+))? Spnl")
- Rules[:_HtmlComment] = rule_info("HtmlComment", "\"<!--\" (!\"-->\" .)* \"-->\"")
- Rules[:_HtmlTag] = rule_info("HtmlTag", "\"<\" Spnl \"/\"? AlphanumericAscii+ Spnl HtmlAttribute* \"/\"? Spnl \">\"")
- Rules[:_Eof] = rule_info("Eof", "!.")
- Rules[:_Nonspacechar] = rule_info("Nonspacechar", "!@Spacechar !@Newline .")
- Rules[:_Sp] = rule_info("Sp", "@Spacechar*")
- Rules[:_Spnl] = rule_info("Spnl", "@Sp (@Newline @Sp)?")
- Rules[:_SpecialChar] = rule_info("SpecialChar", "(/[~*_`&\\[\\]()<!\#\\\\'\"]/ | @ExtendedSpecialChar)")
- Rules[:_NormalChar] = rule_info("NormalChar", "!(@SpecialChar | @Spacechar | @Newline) .")
- Rules[:_Digit] = rule_info("Digit", "[0-9]")
- Rules[:_Alphanumeric] = rule_info("Alphanumeric", "%literals.Alphanumeric")
- Rules[:_AlphanumericAscii] = rule_info("AlphanumericAscii", "%literals.AlphanumericAscii")
- Rules[:_BOM] = rule_info("BOM", "%literals.BOM")
- Rules[:_Newline] = rule_info("Newline", "%literals.Newline")
- Rules[:_Spacechar] = rule_info("Spacechar", "%literals.Spacechar")
- Rules[:_HexEntity] = rule_info("HexEntity", "/&\#x/i < /[0-9a-fA-F]+/ > \";\" { [text.to_i(16)].pack 'U' }")
- Rules[:_DecEntity] = rule_info("DecEntity", "\"&\#\" < /[0-9]+/ > \";\" { [text.to_i].pack 'U' }")
- Rules[:_CharEntity] = rule_info("CharEntity", "\"&\" < /[A-Za-z0-9]+/ > \";\" { if entity = HTML_ENTITIES[text] then entity.pack 'U*' else \"&\#{text};\" end }")
- Rules[:_NonindentSpace] = rule_info("NonindentSpace", "/ {0,3}/")
- Rules[:_Indent] = rule_info("Indent", "/\\t| /")
- Rules[:_IndentedLine] = rule_info("IndentedLine", "Indent Line")
- Rules[:_OptionallyIndentedLine] = rule_info("OptionallyIndentedLine", "Indent? Line")
- Rules[:_StartList] = rule_info("StartList", "&. { [] }")
- Rules[:_Line] = rule_info("Line", "@RawLine:a { a }")
- Rules[:_RawLine] = rule_info("RawLine", "(< /[^\\r\\n]*/ @Newline > | < .+ > @Eof) { text }")
- Rules[:_SkipBlock] = rule_info("SkipBlock", "(HtmlBlock | (!\"\#\" !SetextBottom1 !SetextBottom2 !@BlankLine @RawLine)+ @BlankLine* | @BlankLine+ | @RawLine)")
- Rules[:_ExtendedSpecialChar] = rule_info("ExtendedSpecialChar", "&{ notes? } \"^\"")
- Rules[:_NoteReference] = rule_info("NoteReference", "&{ notes? } RawNoteReference:ref { note_for ref }")
- Rules[:_RawNoteReference] = rule_info("RawNoteReference", "\"[^\" < (!@Newline !\"]\" .)+ > \"]\" { text }")
- Rules[:_Note] = rule_info("Note", "&{ notes? } @NonindentSpace RawNoteReference:ref \":\" @Sp @StartList:a RawNoteBlock:i { a.concat i } (&Indent RawNoteBlock:i { a.concat i })* { @footnotes[ref] = paragraph a nil }")
- Rules[:_InlineNote] = rule_info("InlineNote", "&{ notes? } \"^[\" @StartList:a (!\"]\" Inline:l { a << l })+ \"]\" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }")
- Rules[:_Notes] = rule_info("Notes", "(Note | SkipBlock)*")
- Rules[:_RawNoteBlock] = rule_info("RawNoteBlock", "@StartList:a (!@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }")
- Rules[:_CodeFence] = rule_info("CodeFence", "&{ github? } Ticks3 (@Sp StrChunk:format)? Spnl < ((!\"`\" Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* { verbatim = RDoc::Markup::Verbatim.new text verbatim.format = format.intern if format.instance_of?(String) verbatim }")
- Rules[:_Table] = rule_info("Table", "&{ github? } TableHead:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }")
- Rules[:_TableHead] = rule_info("TableHead", "TableItem2+:items \"|\"? @Newline { items }")
- Rules[:_TableRow] = rule_info("TableRow", "((TableItem:item1 TableItem2*:items { [item1, *items] }):row | TableItem2+:row) \"|\"? @Newline { row }")
- Rules[:_TableItem2] = rule_info("TableItem2", "\"|\" TableItem")
- Rules[:_TableItem] = rule_info("TableItem", "< /(?:\\\\.|[^|\\n])+/ > { text.strip.gsub(/\\\\(.)/, '\\1') }")
- Rules[:_TableLine] = rule_info("TableLine", "((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line | TableAlign2+:line) \"|\"? @Newline { line }")
- Rules[:_TableAlign2] = rule_info("TableAlign2", "\"|\" @Sp TableAlign")
- Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > @Sp { text.start_with?(\":\") ? (text.end_with?(\":\") ? :center : :left) : (text.end_with?(\":\") ? :right : nil) }")
- Rules[:_DefinitionList] = rule_info("DefinitionList", "&{ definition_lists? } DefinitionListItem+:list { RDoc::Markup::List.new :NOTE, *list.flatten }")
- Rules[:_DefinitionListItem] = rule_info("DefinitionListItem", "DefinitionListLabel+:label DefinitionListDefinition+:defns { list_items = [] list_items << RDoc::Markup::ListItem.new(label, defns.shift) list_items.concat defns.map { |defn| RDoc::Markup::ListItem.new nil, defn } unless list_items.empty? list_items }")
- Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "StrChunk:label @Sp @Newline { label }")
- Rules[:_DefinitionListDefinition] = rule_info("DefinitionListDefinition", "@NonindentSpace \":\" @Space Inlines:a @BlankLine+ { paragraph a }")
- # :startdoc:
-end
diff --git a/lib/rdoc/markdown/entities.rb b/lib/rdoc/markdown/entities.rb
deleted file mode 100644
index d2cf610293..0000000000
--- a/lib/rdoc/markdown/entities.rb
+++ /dev/null
@@ -1,2132 +0,0 @@
-# frozen_string_literal: true
-##
-# HTML entity name map for RDoc::Markdown
-
-RDoc::Markdown::HTML_ENTITIES = {
- "AElig" => [0x000C6],
- "AMP" => [0x00026],
- "Aacute" => [0x000C1],
- "Abreve" => [0x00102],
- "Acirc" => [0x000C2],
- "Acy" => [0x00410],
- "Afr" => [0x1D504],
- "Agrave" => [0x000C0],
- "Alpha" => [0x00391],
- "Amacr" => [0x00100],
- "And" => [0x02A53],
- "Aogon" => [0x00104],
- "Aopf" => [0x1D538],
- "ApplyFunction" => [0x02061],
- "Aring" => [0x000C5],
- "Ascr" => [0x1D49C],
- "Assign" => [0x02254],
- "Atilde" => [0x000C3],
- "Auml" => [0x000C4],
- "Backslash" => [0x02216],
- "Barv" => [0x02AE7],
- "Barwed" => [0x02306],
- "Bcy" => [0x00411],
- "Because" => [0x02235],
- "Bernoullis" => [0x0212C],
- "Beta" => [0x00392],
- "Bfr" => [0x1D505],
- "Bopf" => [0x1D539],
- "Breve" => [0x002D8],
- "Bscr" => [0x0212C],
- "Bumpeq" => [0x0224E],
- "CHcy" => [0x00427],
- "COPY" => [0x000A9],
- "Cacute" => [0x00106],
- "Cap" => [0x022D2],
- "CapitalDifferentialD" => [0x02145],
- "Cayleys" => [0x0212D],
- "Ccaron" => [0x0010C],
- "Ccedil" => [0x000C7],
- "Ccirc" => [0x00108],
- "Cconint" => [0x02230],
- "Cdot" => [0x0010A],
- "Cedilla" => [0x000B8],
- "CenterDot" => [0x000B7],
- "Cfr" => [0x0212D],
- "Chi" => [0x003A7],
- "CircleDot" => [0x02299],
- "CircleMinus" => [0x02296],
- "CirclePlus" => [0x02295],
- "CircleTimes" => [0x02297],
- "ClockwiseContourIntegral" => [0x02232],
- "CloseCurlyDoubleQuote" => [0x0201D],
- "CloseCurlyQuote" => [0x02019],
- "Colon" => [0x02237],
- "Colone" => [0x02A74],
- "Congruent" => [0x02261],
- "Conint" => [0x0222F],
- "ContourIntegral" => [0x0222E],
- "Copf" => [0x02102],
- "Coproduct" => [0x02210],
- "CounterClockwiseContourIntegral" => [0x02233],
- "Cross" => [0x02A2F],
- "Cscr" => [0x1D49E],
- "Cup" => [0x022D3],
- "CupCap" => [0x0224D],
- "DD" => [0x02145],
- "DDotrahd" => [0x02911],
- "DJcy" => [0x00402],
- "DScy" => [0x00405],
- "DZcy" => [0x0040F],
- "Dagger" => [0x02021],
- "Darr" => [0x021A1],
- "Dashv" => [0x02AE4],
- "Dcaron" => [0x0010E],
- "Dcy" => [0x00414],
- "Del" => [0x02207],
- "Delta" => [0x00394],
- "Dfr" => [0x1D507],
- "DiacriticalAcute" => [0x000B4],
- "DiacriticalDot" => [0x002D9],
- "DiacriticalDoubleAcute" => [0x002DD],
- "DiacriticalGrave" => [0x00060],
- "DiacriticalTilde" => [0x002DC],
- "Diamond" => [0x022C4],
- "DifferentialD" => [0x02146],
- "Dopf" => [0x1D53B],
- "Dot" => [0x000A8],
- "DotDot" => [0x020DC],
- "DotEqual" => [0x02250],
- "DoubleContourIntegral" => [0x0222F],
- "DoubleDot" => [0x000A8],
- "DoubleDownArrow" => [0x021D3],
- "DoubleLeftArrow" => [0x021D0],
- "DoubleLeftRightArrow" => [0x021D4],
- "DoubleLeftTee" => [0x02AE4],
- "DoubleLongLeftArrow" => [0x027F8],
- "DoubleLongLeftRightArrow" => [0x027FA],
- "DoubleLongRightArrow" => [0x027F9],
- "DoubleRightArrow" => [0x021D2],
- "DoubleRightTee" => [0x022A8],
- "DoubleUpArrow" => [0x021D1],
- "DoubleUpDownArrow" => [0x021D5],
- "DoubleVerticalBar" => [0x02225],
- "DownArrow" => [0x02193],
- "DownArrowBar" => [0x02913],
- "DownArrowUpArrow" => [0x021F5],
- "DownBreve" => [0x00311],
- "DownLeftRightVector" => [0x02950],
- "DownLeftTeeVector" => [0x0295E],
- "DownLeftVector" => [0x021BD],
- "DownLeftVectorBar" => [0x02956],
- "DownRightTeeVector" => [0x0295F],
- "DownRightVector" => [0x021C1],
- "DownRightVectorBar" => [0x02957],
- "DownTee" => [0x022A4],
- "DownTeeArrow" => [0x021A7],
- "Downarrow" => [0x021D3],
- "Dscr" => [0x1D49F],
- "Dstrok" => [0x00110],
- "ENG" => [0x0014A],
- "ETH" => [0x000D0],
- "Eacute" => [0x000C9],
- "Ecaron" => [0x0011A],
- "Ecirc" => [0x000CA],
- "Ecy" => [0x0042D],
- "Edot" => [0x00116],
- "Efr" => [0x1D508],
- "Egrave" => [0x000C8],
- "Element" => [0x02208],
- "Emacr" => [0x00112],
- "EmptySmallSquare" => [0x025FB],
- "EmptyVerySmallSquare" => [0x025AB],
- "Eogon" => [0x00118],
- "Eopf" => [0x1D53C],
- "Epsilon" => [0x00395],
- "Equal" => [0x02A75],
- "EqualTilde" => [0x02242],
- "Equilibrium" => [0x021CC],
- "Escr" => [0x02130],
- "Esim" => [0x02A73],
- "Eta" => [0x00397],
- "Euml" => [0x000CB],
- "Exists" => [0x02203],
- "ExponentialE" => [0x02147],
- "Fcy" => [0x00424],
- "Ffr" => [0x1D509],
- "FilledSmallSquare" => [0x025FC],
- "FilledVerySmallSquare" => [0x025AA],
- "Fopf" => [0x1D53D],
- "ForAll" => [0x02200],
- "Fouriertrf" => [0x02131],
- "Fscr" => [0x02131],
- "GJcy" => [0x00403],
- "GT" => [0x0003E],
- "Gamma" => [0x00393],
- "Gammad" => [0x003DC],
- "Gbreve" => [0x0011E],
- "Gcedil" => [0x00122],
- "Gcirc" => [0x0011C],
- "Gcy" => [0x00413],
- "Gdot" => [0x00120],
- "Gfr" => [0x1D50A],
- "Gg" => [0x022D9],
- "Gopf" => [0x1D53E],
- "GreaterEqual" => [0x02265],
- "GreaterEqualLess" => [0x022DB],
- "GreaterFullEqual" => [0x02267],
- "GreaterGreater" => [0x02AA2],
- "GreaterLess" => [0x02277],
- "GreaterSlantEqual" => [0x02A7E],
- "GreaterTilde" => [0x02273],
- "Gscr" => [0x1D4A2],
- "Gt" => [0x0226B],
- "HARDcy" => [0x0042A],
- "Hacek" => [0x002C7],
- "Hat" => [0x0005E],
- "Hcirc" => [0x00124],
- "Hfr" => [0x0210C],
- "HilbertSpace" => [0x0210B],
- "Hopf" => [0x0210D],
- "HorizontalLine" => [0x02500],
- "Hscr" => [0x0210B],
- "Hstrok" => [0x00126],
- "HumpDownHump" => [0x0224E],
- "HumpEqual" => [0x0224F],
- "IEcy" => [0x00415],
- "IJlig" => [0x00132],
- "IOcy" => [0x00401],
- "Iacute" => [0x000CD],
- "Icirc" => [0x000CE],
- "Icy" => [0x00418],
- "Idot" => [0x00130],
- "Ifr" => [0x02111],
- "Igrave" => [0x000CC],
- "Im" => [0x02111],
- "Imacr" => [0x0012A],
- "ImaginaryI" => [0x02148],
- "Implies" => [0x021D2],
- "Int" => [0x0222C],
- "Integral" => [0x0222B],
- "Intersection" => [0x022C2],
- "InvisibleComma" => [0x02063],
- "InvisibleTimes" => [0x02062],
- "Iogon" => [0x0012E],
- "Iopf" => [0x1D540],
- "Iota" => [0x00399],
- "Iscr" => [0x02110],
- "Itilde" => [0x00128],
- "Iukcy" => [0x00406],
- "Iuml" => [0x000CF],
- "Jcirc" => [0x00134],
- "Jcy" => [0x00419],
- "Jfr" => [0x1D50D],
- "Jopf" => [0x1D541],
- "Jscr" => [0x1D4A5],
- "Jsercy" => [0x00408],
- "Jukcy" => [0x00404],
- "KHcy" => [0x00425],
- "KJcy" => [0x0040C],
- "Kappa" => [0x0039A],
- "Kcedil" => [0x00136],
- "Kcy" => [0x0041A],
- "Kfr" => [0x1D50E],
- "Kopf" => [0x1D542],
- "Kscr" => [0x1D4A6],
- "LJcy" => [0x00409],
- "LT" => [0x0003C],
- "Lacute" => [0x00139],
- "Lambda" => [0x0039B],
- "Lang" => [0x027EA],
- "Laplacetrf" => [0x02112],
- "Larr" => [0x0219E],
- "Lcaron" => [0x0013D],
- "Lcedil" => [0x0013B],
- "Lcy" => [0x0041B],
- "LeftAngleBracket" => [0x027E8],
- "LeftArrow" => [0x02190],
- "LeftArrowBar" => [0x021E4],
- "LeftArrowRightArrow" => [0x021C6],
- "LeftCeiling" => [0x02308],
- "LeftDoubleBracket" => [0x027E6],
- "LeftDownTeeVector" => [0x02961],
- "LeftDownVector" => [0x021C3],
- "LeftDownVectorBar" => [0x02959],
- "LeftFloor" => [0x0230A],
- "LeftRightArrow" => [0x02194],
- "LeftRightVector" => [0x0294E],
- "LeftTee" => [0x022A3],
- "LeftTeeArrow" => [0x021A4],
- "LeftTeeVector" => [0x0295A],
- "LeftTriangle" => [0x022B2],
- "LeftTriangleBar" => [0x029CF],
- "LeftTriangleEqual" => [0x022B4],
- "LeftUpDownVector" => [0x02951],
- "LeftUpTeeVector" => [0x02960],
- "LeftUpVector" => [0x021BF],
- "LeftUpVectorBar" => [0x02958],
- "LeftVector" => [0x021BC],
- "LeftVectorBar" => [0x02952],
- "Leftarrow" => [0x021D0],
- "Leftrightarrow" => [0x021D4],
- "LessEqualGreater" => [0x022DA],
- "LessFullEqual" => [0x02266],
- "LessGreater" => [0x02276],
- "LessLess" => [0x02AA1],
- "LessSlantEqual" => [0x02A7D],
- "LessTilde" => [0x02272],
- "Lfr" => [0x1D50F],
- "Ll" => [0x022D8],
- "Lleftarrow" => [0x021DA],
- "Lmidot" => [0x0013F],
- "LongLeftArrow" => [0x027F5],
- "LongLeftRightArrow" => [0x027F7],
- "LongRightArrow" => [0x027F6],
- "Longleftarrow" => [0x027F8],
- "Longleftrightarrow" => [0x027FA],
- "Longrightarrow" => [0x027F9],
- "Lopf" => [0x1D543],
- "LowerLeftArrow" => [0x02199],
- "LowerRightArrow" => [0x02198],
- "Lscr" => [0x02112],
- "Lsh" => [0x021B0],
- "Lstrok" => [0x00141],
- "Lt" => [0x0226A],
- "Map" => [0x02905],
- "Mcy" => [0x0041C],
- "MediumSpace" => [0x0205F],
- "Mellintrf" => [0x02133],
- "Mfr" => [0x1D510],
- "MinusPlus" => [0x02213],
- "Mopf" => [0x1D544],
- "Mscr" => [0x02133],
- "Mu" => [0x0039C],
- "NJcy" => [0x0040A],
- "Nacute" => [0x00143],
- "Ncaron" => [0x00147],
- "Ncedil" => [0x00145],
- "Ncy" => [0x0041D],
- "NegativeMediumSpace" => [0x0200B],
- "NegativeThickSpace" => [0x0200B],
- "NegativeThinSpace" => [0x0200B],
- "NegativeVeryThinSpace" => [0x0200B],
- "NestedGreaterGreater" => [0x0226B],
- "NestedLessLess" => [0x0226A],
- "NewLine" => [0x0000A],
- "Nfr" => [0x1D511],
- "NoBreak" => [0x02060],
- "NonBreakingSpace" => [0x000A0],
- "Nopf" => [0x02115],
- "Not" => [0x02AEC],
- "NotCongruent" => [0x02262],
- "NotCupCap" => [0x0226D],
- "NotDoubleVerticalBar" => [0x02226],
- "NotElement" => [0x02209],
- "NotEqual" => [0x02260],
- "NotEqualTilde" => [0x02242, 0x00338],
- "NotExists" => [0x02204],
- "NotGreater" => [0x0226F],
- "NotGreaterEqual" => [0x02271],
- "NotGreaterFullEqual" => [0x02267, 0x00338],
- "NotGreaterGreater" => [0x0226B, 0x00338],
- "NotGreaterLess" => [0x02279],
- "NotGreaterSlantEqual" => [0x02A7E, 0x00338],
- "NotGreaterTilde" => [0x02275],
- "NotHumpDownHump" => [0x0224E, 0x00338],
- "NotHumpEqual" => [0x0224F, 0x00338],
- "NotLeftTriangle" => [0x022EA],
- "NotLeftTriangleBar" => [0x029CF, 0x00338],
- "NotLeftTriangleEqual" => [0x022EC],
- "NotLess" => [0x0226E],
- "NotLessEqual" => [0x02270],
- "NotLessGreater" => [0x02278],
- "NotLessLess" => [0x0226A, 0x00338],
- "NotLessSlantEqual" => [0x02A7D, 0x00338],
- "NotLessTilde" => [0x02274],
- "NotNestedGreaterGreater" => [0x02AA2, 0x00338],
- "NotNestedLessLess" => [0x02AA1, 0x00338],
- "NotPrecedes" => [0x02280],
- "NotPrecedesEqual" => [0x02AAF, 0x00338],
- "NotPrecedesSlantEqual" => [0x022E0],
- "NotReverseElement" => [0x0220C],
- "NotRightTriangle" => [0x022EB],
- "NotRightTriangleBar" => [0x029D0, 0x00338],
- "NotRightTriangleEqual" => [0x022ED],
- "NotSquareSubset" => [0x0228F, 0x00338],
- "NotSquareSubsetEqual" => [0x022E2],
- "NotSquareSuperset" => [0x02290, 0x00338],
- "NotSquareSupersetEqual" => [0x022E3],
- "NotSubset" => [0x02282, 0x020D2],
- "NotSubsetEqual" => [0x02288],
- "NotSucceeds" => [0x02281],
- "NotSucceedsEqual" => [0x02AB0, 0x00338],
- "NotSucceedsSlantEqual" => [0x022E1],
- "NotSucceedsTilde" => [0x0227F, 0x00338],
- "NotSuperset" => [0x02283, 0x020D2],
- "NotSupersetEqual" => [0x02289],
- "NotTilde" => [0x02241],
- "NotTildeEqual" => [0x02244],
- "NotTildeFullEqual" => [0x02247],
- "NotTildeTilde" => [0x02249],
- "NotVerticalBar" => [0x02224],
- "Nscr" => [0x1D4A9],
- "Ntilde" => [0x000D1],
- "Nu" => [0x0039D],
- "OElig" => [0x00152],
- "Oacute" => [0x000D3],
- "Ocirc" => [0x000D4],
- "Ocy" => [0x0041E],
- "Odblac" => [0x00150],
- "Ofr" => [0x1D512],
- "Ograve" => [0x000D2],
- "Omacr" => [0x0014C],
- "Omega" => [0x003A9],
- "Omicron" => [0x0039F],
- "Oopf" => [0x1D546],
- "OpenCurlyDoubleQuote" => [0x0201C],
- "OpenCurlyQuote" => [0x02018],
- "Or" => [0x02A54],
- "Oscr" => [0x1D4AA],
- "Oslash" => [0x000D8],
- "Otilde" => [0x000D5],
- "Otimes" => [0x02A37],
- "Ouml" => [0x000D6],
- "OverBar" => [0x0203E],
- "OverBrace" => [0x023DE],
- "OverBracket" => [0x023B4],
- "OverParenthesis" => [0x023DC],
- "PartialD" => [0x02202],
- "Pcy" => [0x0041F],
- "Pfr" => [0x1D513],
- "Phi" => [0x003A6],
- "Pi" => [0x003A0],
- "PlusMinus" => [0x000B1],
- "Poincareplane" => [0x0210C],
- "Popf" => [0x02119],
- "Pr" => [0x02ABB],
- "Precedes" => [0x0227A],
- "PrecedesEqual" => [0x02AAF],
- "PrecedesSlantEqual" => [0x0227C],
- "PrecedesTilde" => [0x0227E],
- "Prime" => [0x02033],
- "Product" => [0x0220F],
- "Proportion" => [0x02237],
- "Proportional" => [0x0221D],
- "Pscr" => [0x1D4AB],
- "Psi" => [0x003A8],
- "QUOT" => [0x00022],
- "Qfr" => [0x1D514],
- "Qopf" => [0x0211A],
- "Qscr" => [0x1D4AC],
- "RBarr" => [0x02910],
- "REG" => [0x000AE],
- "Racute" => [0x00154],
- "Rang" => [0x027EB],
- "Rarr" => [0x021A0],
- "Rarrtl" => [0x02916],
- "Rcaron" => [0x00158],
- "Rcedil" => [0x00156],
- "Rcy" => [0x00420],
- "Re" => [0x0211C],
- "ReverseElement" => [0x0220B],
- "ReverseEquilibrium" => [0x021CB],
- "ReverseUpEquilibrium" => [0x0296F],
- "Rfr" => [0x0211C],
- "Rho" => [0x003A1],
- "RightAngleBracket" => [0x027E9],
- "RightArrow" => [0x02192],
- "RightArrowBar" => [0x021E5],
- "RightArrowLeftArrow" => [0x021C4],
- "RightCeiling" => [0x02309],
- "RightDoubleBracket" => [0x027E7],
- "RightDownTeeVector" => [0x0295D],
- "RightDownVector" => [0x021C2],
- "RightDownVectorBar" => [0x02955],
- "RightFloor" => [0x0230B],
- "RightTee" => [0x022A2],
- "RightTeeArrow" => [0x021A6],
- "RightTeeVector" => [0x0295B],
- "RightTriangle" => [0x022B3],
- "RightTriangleBar" => [0x029D0],
- "RightTriangleEqual" => [0x022B5],
- "RightUpDownVector" => [0x0294F],
- "RightUpTeeVector" => [0x0295C],
- "RightUpVector" => [0x021BE],
- "RightUpVectorBar" => [0x02954],
- "RightVector" => [0x021C0],
- "RightVectorBar" => [0x02953],
- "Rightarrow" => [0x021D2],
- "Ropf" => [0x0211D],
- "RoundImplies" => [0x02970],
- "Rrightarrow" => [0x021DB],
- "Rscr" => [0x0211B],
- "Rsh" => [0x021B1],
- "RuleDelayed" => [0x029F4],
- "SHCHcy" => [0x00429],
- "SHcy" => [0x00428],
- "SOFTcy" => [0x0042C],
- "Sacute" => [0x0015A],
- "Sc" => [0x02ABC],
- "Scaron" => [0x00160],
- "Scedil" => [0x0015E],
- "Scirc" => [0x0015C],
- "Scy" => [0x00421],
- "Sfr" => [0x1D516],
- "ShortDownArrow" => [0x02193],
- "ShortLeftArrow" => [0x02190],
- "ShortRightArrow" => [0x02192],
- "ShortUpArrow" => [0x02191],
- "Sigma" => [0x003A3],
- "SmallCircle" => [0x02218],
- "Sopf" => [0x1D54A],
- "Sqrt" => [0x0221A],
- "Square" => [0x025A1],
- "SquareIntersection" => [0x02293],
- "SquareSubset" => [0x0228F],
- "SquareSubsetEqual" => [0x02291],
- "SquareSuperset" => [0x02290],
- "SquareSupersetEqual" => [0x02292],
- "SquareUnion" => [0x02294],
- "Sscr" => [0x1D4AE],
- "Star" => [0x022C6],
- "Sub" => [0x022D0],
- "Subset" => [0x022D0],
- "SubsetEqual" => [0x02286],
- "Succeeds" => [0x0227B],
- "SucceedsEqual" => [0x02AB0],
- "SucceedsSlantEqual" => [0x0227D],
- "SucceedsTilde" => [0x0227F],
- "SuchThat" => [0x0220B],
- "Sum" => [0x02211],
- "Sup" => [0x022D1],
- "Superset" => [0x02283],
- "SupersetEqual" => [0x02287],
- "Supset" => [0x022D1],
- "THORN" => [0x000DE],
- "TRADE" => [0x02122],
- "TSHcy" => [0x0040B],
- "TScy" => [0x00426],
- "Tab" => [0x00009],
- "Tau" => [0x003A4],
- "Tcaron" => [0x00164],
- "Tcedil" => [0x00162],
- "Tcy" => [0x00422],
- "Tfr" => [0x1D517],
- "Therefore" => [0x02234],
- "Theta" => [0x00398],
- "ThickSpace" => [0x0205F, 0x0200A],
- "ThinSpace" => [0x02009],
- "Tilde" => [0x0223C],
- "TildeEqual" => [0x02243],
- "TildeFullEqual" => [0x02245],
- "TildeTilde" => [0x02248],
- "Topf" => [0x1D54B],
- "TripleDot" => [0x020DB],
- "Tscr" => [0x1D4AF],
- "Tstrok" => [0x00166],
- "Uacute" => [0x000DA],
- "Uarr" => [0x0219F],
- "Uarrocir" => [0x02949],
- "Ubrcy" => [0x0040E],
- "Ubreve" => [0x0016C],
- "Ucirc" => [0x000DB],
- "Ucy" => [0x00423],
- "Udblac" => [0x00170],
- "Ufr" => [0x1D518],
- "Ugrave" => [0x000D9],
- "Umacr" => [0x0016A],
- "UnderBar" => [0x0005F],
- "UnderBrace" => [0x023DF],
- "UnderBracket" => [0x023B5],
- "UnderParenthesis" => [0x023DD],
- "Union" => [0x022C3],
- "UnionPlus" => [0x0228E],
- "Uogon" => [0x00172],
- "Uopf" => [0x1D54C],
- "UpArrow" => [0x02191],
- "UpArrowBar" => [0x02912],
- "UpArrowDownArrow" => [0x021C5],
- "UpDownArrow" => [0x02195],
- "UpEquilibrium" => [0x0296E],
- "UpTee" => [0x022A5],
- "UpTeeArrow" => [0x021A5],
- "Uparrow" => [0x021D1],
- "Updownarrow" => [0x021D5],
- "UpperLeftArrow" => [0x02196],
- "UpperRightArrow" => [0x02197],
- "Upsi" => [0x003D2],
- "Upsilon" => [0x003A5],
- "Uring" => [0x0016E],
- "Uscr" => [0x1D4B0],
- "Utilde" => [0x00168],
- "Uuml" => [0x000DC],
- "VDash" => [0x022AB],
- "Vbar" => [0x02AEB],
- "Vcy" => [0x00412],
- "Vdash" => [0x022A9],
- "Vdashl" => [0x02AE6],
- "Vee" => [0x022C1],
- "Verbar" => [0x02016],
- "Vert" => [0x02016],
- "VerticalBar" => [0x02223],
- "VerticalLine" => [0x0007C],
- "VerticalSeparator" => [0x02758],
- "VerticalTilde" => [0x02240],
- "VeryThinSpace" => [0x0200A],
- "Vfr" => [0x1D519],
- "Vopf" => [0x1D54D],
- "Vscr" => [0x1D4B1],
- "Vvdash" => [0x022AA],
- "Wcirc" => [0x00174],
- "Wedge" => [0x022C0],
- "Wfr" => [0x1D51A],
- "Wopf" => [0x1D54E],
- "Wscr" => [0x1D4B2],
- "Xfr" => [0x1D51B],
- "Xi" => [0x0039E],
- "Xopf" => [0x1D54F],
- "Xscr" => [0x1D4B3],
- "YAcy" => [0x0042F],
- "YIcy" => [0x00407],
- "YUcy" => [0x0042E],
- "Yacute" => [0x000DD],
- "Ycirc" => [0x00176],
- "Ycy" => [0x0042B],
- "Yfr" => [0x1D51C],
- "Yopf" => [0x1D550],
- "Yscr" => [0x1D4B4],
- "Yuml" => [0x00178],
- "ZHcy" => [0x00416],
- "Zacute" => [0x00179],
- "Zcaron" => [0x0017D],
- "Zcy" => [0x00417],
- "Zdot" => [0x0017B],
- "ZeroWidthSpace" => [0x0200B],
- "Zeta" => [0x00396],
- "Zfr" => [0x02128],
- "Zopf" => [0x02124],
- "Zscr" => [0x1D4B5],
- "aacute" => [0x000E1],
- "abreve" => [0x00103],
- "ac" => [0x0223E],
- "acE" => [0x0223E, 0x00333],
- "acd" => [0x0223F],
- "acirc" => [0x000E2],
- "acute" => [0x000B4],
- "acy" => [0x00430],
- "aelig" => [0x000E6],
- "af" => [0x02061],
- "afr" => [0x1D51E],
- "agrave" => [0x000E0],
- "alefsym" => [0x02135],
- "aleph" => [0x02135],
- "alpha" => [0x003B1],
- "amacr" => [0x00101],
- "amalg" => [0x02A3F],
- "amp" => [0x00026],
- "and" => [0x02227],
- "andand" => [0x02A55],
- "andd" => [0x02A5C],
- "andslope" => [0x02A58],
- "andv" => [0x02A5A],
- "ang" => [0x02220],
- "ange" => [0x029A4],
- "angle" => [0x02220],
- "angmsd" => [0x02221],
- "angmsdaa" => [0x029A8],
- "angmsdab" => [0x029A9],
- "angmsdac" => [0x029AA],
- "angmsdad" => [0x029AB],
- "angmsdae" => [0x029AC],
- "angmsdaf" => [0x029AD],
- "angmsdag" => [0x029AE],
- "angmsdah" => [0x029AF],
- "angrt" => [0x0221F],
- "angrtvb" => [0x022BE],
- "angrtvbd" => [0x0299D],
- "angsph" => [0x02222],
- "angst" => [0x000C5],
- "angzarr" => [0x0237C],
- "aogon" => [0x00105],
- "aopf" => [0x1D552],
- "ap" => [0x02248],
- "apE" => [0x02A70],
- "apacir" => [0x02A6F],
- "ape" => [0x0224A],
- "apid" => [0x0224B],
- "apos" => [0x00027],
- "approx" => [0x02248],
- "approxeq" => [0x0224A],
- "aring" => [0x000E5],
- "ascr" => [0x1D4B6],
- "ast" => [0x0002A],
- "asymp" => [0x02248],
- "asympeq" => [0x0224D],
- "atilde" => [0x000E3],
- "auml" => [0x000E4],
- "awconint" => [0x02233],
- "awint" => [0x02A11],
- "bNot" => [0x02AED],
- "backcong" => [0x0224C],
- "backepsilon" => [0x003F6],
- "backprime" => [0x02035],
- "backsim" => [0x0223D],
- "backsimeq" => [0x022CD],
- "barvee" => [0x022BD],
- "barwed" => [0x02305],
- "barwedge" => [0x02305],
- "bbrk" => [0x023B5],
- "bbrktbrk" => [0x023B6],
- "bcong" => [0x0224C],
- "bcy" => [0x00431],
- "bdquo" => [0x0201E],
- "becaus" => [0x02235],
- "because" => [0x02235],
- "bemptyv" => [0x029B0],
- "bepsi" => [0x003F6],
- "bernou" => [0x0212C],
- "beta" => [0x003B2],
- "beth" => [0x02136],
- "between" => [0x0226C],
- "bfr" => [0x1D51F],
- "bigcap" => [0x022C2],
- "bigcirc" => [0x025EF],
- "bigcup" => [0x022C3],
- "bigodot" => [0x02A00],
- "bigoplus" => [0x02A01],
- "bigotimes" => [0x02A02],
- "bigsqcup" => [0x02A06],
- "bigstar" => [0x02605],
- "bigtriangledown" => [0x025BD],
- "bigtriangleup" => [0x025B3],
- "biguplus" => [0x02A04],
- "bigvee" => [0x022C1],
- "bigwedge" => [0x022C0],
- "bkarow" => [0x0290D],
- "blacklozenge" => [0x029EB],
- "blacksquare" => [0x025AA],
- "blacktriangle" => [0x025B4],
- "blacktriangledown" => [0x025BE],
- "blacktriangleleft" => [0x025C2],
- "blacktriangleright" => [0x025B8],
- "blank" => [0x02423],
- "blk12" => [0x02592],
- "blk14" => [0x02591],
- "blk34" => [0x02593],
- "block" => [0x02588],
- "bne" => [0x0003D, 0x020E5],
- "bnequiv" => [0x02261, 0x020E5],
- "bnot" => [0x02310],
- "bopf" => [0x1D553],
- "bot" => [0x022A5],
- "bottom" => [0x022A5],
- "bowtie" => [0x022C8],
- "boxDL" => [0x02557],
- "boxDR" => [0x02554],
- "boxDl" => [0x02556],
- "boxDr" => [0x02553],
- "boxH" => [0x02550],
- "boxHD" => [0x02566],
- "boxHU" => [0x02569],
- "boxHd" => [0x02564],
- "boxHu" => [0x02567],
- "boxUL" => [0x0255D],
- "boxUR" => [0x0255A],
- "boxUl" => [0x0255C],
- "boxUr" => [0x02559],
- "boxV" => [0x02551],
- "boxVH" => [0x0256C],
- "boxVL" => [0x02563],
- "boxVR" => [0x02560],
- "boxVh" => [0x0256B],
- "boxVl" => [0x02562],
- "boxVr" => [0x0255F],
- "boxbox" => [0x029C9],
- "boxdL" => [0x02555],
- "boxdR" => [0x02552],
- "boxdl" => [0x02510],
- "boxdr" => [0x0250C],
- "boxh" => [0x02500],
- "boxhD" => [0x02565],
- "boxhU" => [0x02568],
- "boxhd" => [0x0252C],
- "boxhu" => [0x02534],
- "boxminus" => [0x0229F],
- "boxplus" => [0x0229E],
- "boxtimes" => [0x022A0],
- "boxuL" => [0x0255B],
- "boxuR" => [0x02558],
- "boxul" => [0x02518],
- "boxur" => [0x02514],
- "boxv" => [0x02502],
- "boxvH" => [0x0256A],
- "boxvL" => [0x02561],
- "boxvR" => [0x0255E],
- "boxvh" => [0x0253C],
- "boxvl" => [0x02524],
- "boxvr" => [0x0251C],
- "bprime" => [0x02035],
- "breve" => [0x002D8],
- "brvbar" => [0x000A6],
- "bscr" => [0x1D4B7],
- "bsemi" => [0x0204F],
- "bsim" => [0x0223D],
- "bsime" => [0x022CD],
- "bsol" => [0x0005C],
- "bsolb" => [0x029C5],
- "bsolhsub" => [0x027C8],
- "bull" => [0x02022],
- "bullet" => [0x02022],
- "bump" => [0x0224E],
- "bumpE" => [0x02AAE],
- "bumpe" => [0x0224F],
- "bumpeq" => [0x0224F],
- "cacute" => [0x00107],
- "cap" => [0x02229],
- "capand" => [0x02A44],
- "capbrcup" => [0x02A49],
- "capcap" => [0x02A4B],
- "capcup" => [0x02A47],
- "capdot" => [0x02A40],
- "caps" => [0x02229, 0x0FE00],
- "caret" => [0x02041],
- "caron" => [0x002C7],
- "ccaps" => [0x02A4D],
- "ccaron" => [0x0010D],
- "ccedil" => [0x000E7],
- "ccirc" => [0x00109],
- "ccups" => [0x02A4C],
- "ccupssm" => [0x02A50],
- "cdot" => [0x0010B],
- "cedil" => [0x000B8],
- "cemptyv" => [0x029B2],
- "cent" => [0x000A2],
- "centerdot" => [0x000B7],
- "cfr" => [0x1D520],
- "chcy" => [0x00447],
- "check" => [0x02713],
- "checkmark" => [0x02713],
- "chi" => [0x003C7],
- "cir" => [0x025CB],
- "cirE" => [0x029C3],
- "circ" => [0x002C6],
- "circeq" => [0x02257],
- "circlearrowleft" => [0x021BA],
- "circlearrowright" => [0x021BB],
- "circledR" => [0x000AE],
- "circledS" => [0x024C8],
- "circledast" => [0x0229B],
- "circledcirc" => [0x0229A],
- "circleddash" => [0x0229D],
- "cire" => [0x02257],
- "cirfnint" => [0x02A10],
- "cirmid" => [0x02AEF],
- "cirscir" => [0x029C2],
- "clubs" => [0x02663],
- "clubsuit" => [0x02663],
- "colon" => [0x0003A],
- "colone" => [0x02254],
- "coloneq" => [0x02254],
- "comma" => [0x0002C],
- "commat" => [0x00040],
- "comp" => [0x02201],
- "compfn" => [0x02218],
- "complement" => [0x02201],
- "complexes" => [0x02102],
- "cong" => [0x02245],
- "congdot" => [0x02A6D],
- "conint" => [0x0222E],
- "copf" => [0x1D554],
- "coprod" => [0x02210],
- "copy" => [0x000A9],
- "copysr" => [0x02117],
- "crarr" => [0x021B5],
- "cross" => [0x02717],
- "cscr" => [0x1D4B8],
- "csub" => [0x02ACF],
- "csube" => [0x02AD1],
- "csup" => [0x02AD0],
- "csupe" => [0x02AD2],
- "ctdot" => [0x022EF],
- "cudarrl" => [0x02938],
- "cudarrr" => [0x02935],
- "cuepr" => [0x022DE],
- "cuesc" => [0x022DF],
- "cularr" => [0x021B6],
- "cularrp" => [0x0293D],
- "cup" => [0x0222A],
- "cupbrcap" => [0x02A48],
- "cupcap" => [0x02A46],
- "cupcup" => [0x02A4A],
- "cupdot" => [0x0228D],
- "cupor" => [0x02A45],
- "cups" => [0x0222A, 0x0FE00],
- "curarr" => [0x021B7],
- "curarrm" => [0x0293C],
- "curlyeqprec" => [0x022DE],
- "curlyeqsucc" => [0x022DF],
- "curlyvee" => [0x022CE],
- "curlywedge" => [0x022CF],
- "curren" => [0x000A4],
- "curvearrowleft" => [0x021B6],
- "curvearrowright" => [0x021B7],
- "cuvee" => [0x022CE],
- "cuwed" => [0x022CF],
- "cwconint" => [0x02232],
- "cwint" => [0x02231],
- "cylcty" => [0x0232D],
- "dArr" => [0x021D3],
- "dHar" => [0x02965],
- "dagger" => [0x02020],
- "daleth" => [0x02138],
- "darr" => [0x02193],
- "dash" => [0x02010],
- "dashv" => [0x022A3],
- "dbkarow" => [0x0290F],
- "dblac" => [0x002DD],
- "dcaron" => [0x0010F],
- "dcy" => [0x00434],
- "dd" => [0x02146],
- "ddagger" => [0x02021],
- "ddarr" => [0x021CA],
- "ddotseq" => [0x02A77],
- "deg" => [0x000B0],
- "delta" => [0x003B4],
- "demptyv" => [0x029B1],
- "dfisht" => [0x0297F],
- "dfr" => [0x1D521],
- "dharl" => [0x021C3],
- "dharr" => [0x021C2],
- "diam" => [0x022C4],
- "diamond" => [0x022C4],
- "diamondsuit" => [0x02666],
- "diams" => [0x02666],
- "die" => [0x000A8],
- "digamma" => [0x003DD],
- "disin" => [0x022F2],
- "div" => [0x000F7],
- "divide" => [0x000F7],
- "divideontimes" => [0x022C7],
- "divonx" => [0x022C7],
- "djcy" => [0x00452],
- "dlcorn" => [0x0231E],
- "dlcrop" => [0x0230D],
- "dollar" => [0x00024],
- "dopf" => [0x1D555],
- "dot" => [0x002D9],
- "doteq" => [0x02250],
- "doteqdot" => [0x02251],
- "dotminus" => [0x02238],
- "dotplus" => [0x02214],
- "dotsquare" => [0x022A1],
- "doublebarwedge" => [0x02306],
- "downarrow" => [0x02193],
- "downdownarrows" => [0x021CA],
- "downharpoonleft" => [0x021C3],
- "downharpoonright" => [0x021C2],
- "drbkarow" => [0x02910],
- "drcorn" => [0x0231F],
- "drcrop" => [0x0230C],
- "dscr" => [0x1D4B9],
- "dscy" => [0x00455],
- "dsol" => [0x029F6],
- "dstrok" => [0x00111],
- "dtdot" => [0x022F1],
- "dtri" => [0x025BF],
- "dtrif" => [0x025BE],
- "duarr" => [0x021F5],
- "duhar" => [0x0296F],
- "dwangle" => [0x029A6],
- "dzcy" => [0x0045F],
- "dzigrarr" => [0x027FF],
- "eDDot" => [0x02A77],
- "eDot" => [0x02251],
- "eacute" => [0x000E9],
- "easter" => [0x02A6E],
- "ecaron" => [0x0011B],
- "ecir" => [0x02256],
- "ecirc" => [0x000EA],
- "ecolon" => [0x02255],
- "ecy" => [0x0044D],
- "edot" => [0x00117],
- "ee" => [0x02147],
- "efDot" => [0x02252],
- "efr" => [0x1D522],
- "eg" => [0x02A9A],
- "egrave" => [0x000E8],
- "egs" => [0x02A96],
- "egsdot" => [0x02A98],
- "el" => [0x02A99],
- "elinters" => [0x023E7],
- "ell" => [0x02113],
- "els" => [0x02A95],
- "elsdot" => [0x02A97],
- "emacr" => [0x00113],
- "empty" => [0x02205],
- "emptyset" => [0x02205],
- "emptyv" => [0x02205],
- "emsp" => [0x02003],
- "emsp13" => [0x02004],
- "emsp14" => [0x02005],
- "eng" => [0x0014B],
- "ensp" => [0x02002],
- "eogon" => [0x00119],
- "eopf" => [0x1D556],
- "epar" => [0x022D5],
- "eparsl" => [0x029E3],
- "eplus" => [0x02A71],
- "epsi" => [0x003B5],
- "epsilon" => [0x003B5],
- "epsiv" => [0x003F5],
- "eqcirc" => [0x02256],
- "eqcolon" => [0x02255],
- "eqsim" => [0x02242],
- "eqslantgtr" => [0x02A96],
- "eqslantless" => [0x02A95],
- "equals" => [0x0003D],
- "equest" => [0x0225F],
- "equiv" => [0x02261],
- "equivDD" => [0x02A78],
- "eqvparsl" => [0x029E5],
- "erDot" => [0x02253],
- "erarr" => [0x02971],
- "escr" => [0x0212F],
- "esdot" => [0x02250],
- "esim" => [0x02242],
- "eta" => [0x003B7],
- "eth" => [0x000F0],
- "euml" => [0x000EB],
- "euro" => [0x020AC],
- "excl" => [0x00021],
- "exist" => [0x02203],
- "expectation" => [0x02130],
- "exponentiale" => [0x02147],
- "fallingdotseq" => [0x02252],
- "fcy" => [0x00444],
- "female" => [0x02640],
- "ffilig" => [0x0FB03],
- "fflig" => [0x0FB00],
- "ffllig" => [0x0FB04],
- "ffr" => [0x1D523],
- "filig" => [0x0FB01],
- "fjlig" => [0x00066, 0x0006A],
- "flat" => [0x0266D],
- "fllig" => [0x0FB02],
- "fltns" => [0x025B1],
- "fnof" => [0x00192],
- "fopf" => [0x1D557],
- "forall" => [0x02200],
- "fork" => [0x022D4],
- "forkv" => [0x02AD9],
- "fpartint" => [0x02A0D],
- "frac12" => [0x000BD],
- "frac13" => [0x02153],
- "frac14" => [0x000BC],
- "frac15" => [0x02155],
- "frac16" => [0x02159],
- "frac18" => [0x0215B],
- "frac23" => [0x02154],
- "frac25" => [0x02156],
- "frac34" => [0x000BE],
- "frac35" => [0x02157],
- "frac38" => [0x0215C],
- "frac45" => [0x02158],
- "frac56" => [0x0215A],
- "frac58" => [0x0215D],
- "frac78" => [0x0215E],
- "frasl" => [0x02044],
- "frown" => [0x02322],
- "fscr" => [0x1D4BB],
- "gE" => [0x02267],
- "gEl" => [0x02A8C],
- "gacute" => [0x001F5],
- "gamma" => [0x003B3],
- "gammad" => [0x003DD],
- "gap" => [0x02A86],
- "gbreve" => [0x0011F],
- "gcirc" => [0x0011D],
- "gcy" => [0x00433],
- "gdot" => [0x00121],
- "ge" => [0x02265],
- "gel" => [0x022DB],
- "geq" => [0x02265],
- "geqq" => [0x02267],
- "geqslant" => [0x02A7E],
- "ges" => [0x02A7E],
- "gescc" => [0x02AA9],
- "gesdot" => [0x02A80],
- "gesdoto" => [0x02A82],
- "gesdotol" => [0x02A84],
- "gesl" => [0x022DB, 0x0FE00],
- "gesles" => [0x02A94],
- "gfr" => [0x1D524],
- "gg" => [0x0226B],
- "ggg" => [0x022D9],
- "gimel" => [0x02137],
- "gjcy" => [0x00453],
- "gl" => [0x02277],
- "glE" => [0x02A92],
- "gla" => [0x02AA5],
- "glj" => [0x02AA4],
- "gnE" => [0x02269],
- "gnap" => [0x02A8A],
- "gnapprox" => [0x02A8A],
- "gne" => [0x02A88],
- "gneq" => [0x02A88],
- "gneqq" => [0x02269],
- "gnsim" => [0x022E7],
- "gopf" => [0x1D558],
- "grave" => [0x00060],
- "gscr" => [0x0210A],
- "gsim" => [0x02273],
- "gsime" => [0x02A8E],
- "gsiml" => [0x02A90],
- "gt" => [0x0003E],
- "gtcc" => [0x02AA7],
- "gtcir" => [0x02A7A],
- "gtdot" => [0x022D7],
- "gtlPar" => [0x02995],
- "gtquest" => [0x02A7C],
- "gtrapprox" => [0x02A86],
- "gtrarr" => [0x02978],
- "gtrdot" => [0x022D7],
- "gtreqless" => [0x022DB],
- "gtreqqless" => [0x02A8C],
- "gtrless" => [0x02277],
- "gtrsim" => [0x02273],
- "gvertneqq" => [0x02269, 0x0FE00],
- "gvnE" => [0x02269, 0x0FE00],
- "hArr" => [0x021D4],
- "hairsp" => [0x0200A],
- "half" => [0x000BD],
- "hamilt" => [0x0210B],
- "hardcy" => [0x0044A],
- "harr" => [0x02194],
- "harrcir" => [0x02948],
- "harrw" => [0x021AD],
- "hbar" => [0x0210F],
- "hcirc" => [0x00125],
- "hearts" => [0x02665],
- "heartsuit" => [0x02665],
- "hellip" => [0x02026],
- "hercon" => [0x022B9],
- "hfr" => [0x1D525],
- "hksearow" => [0x02925],
- "hkswarow" => [0x02926],
- "hoarr" => [0x021FF],
- "homtht" => [0x0223B],
- "hookleftarrow" => [0x021A9],
- "hookrightarrow" => [0x021AA],
- "hopf" => [0x1D559],
- "horbar" => [0x02015],
- "hscr" => [0x1D4BD],
- "hslash" => [0x0210F],
- "hstrok" => [0x00127],
- "hybull" => [0x02043],
- "hyphen" => [0x02010],
- "iacute" => [0x000ED],
- "ic" => [0x02063],
- "icirc" => [0x000EE],
- "icy" => [0x00438],
- "iecy" => [0x00435],
- "iexcl" => [0x000A1],
- "iff" => [0x021D4],
- "ifr" => [0x1D526],
- "igrave" => [0x000EC],
- "ii" => [0x02148],
- "iiiint" => [0x02A0C],
- "iiint" => [0x0222D],
- "iinfin" => [0x029DC],
- "iiota" => [0x02129],
- "ijlig" => [0x00133],
- "imacr" => [0x0012B],
- "image" => [0x02111],
- "imagline" => [0x02110],
- "imagpart" => [0x02111],
- "imath" => [0x00131],
- "imof" => [0x022B7],
- "imped" => [0x001B5],
- "in" => [0x02208],
- "incare" => [0x02105],
- "infin" => [0x0221E],
- "infintie" => [0x029DD],
- "inodot" => [0x00131],
- "int" => [0x0222B],
- "intcal" => [0x022BA],
- "integers" => [0x02124],
- "intercal" => [0x022BA],
- "intlarhk" => [0x02A17],
- "intprod" => [0x02A3C],
- "iocy" => [0x00451],
- "iogon" => [0x0012F],
- "iopf" => [0x1D55A],
- "iota" => [0x003B9],
- "iprod" => [0x02A3C],
- "iquest" => [0x000BF],
- "iscr" => [0x1D4BE],
- "isin" => [0x02208],
- "isinE" => [0x022F9],
- "isindot" => [0x022F5],
- "isins" => [0x022F4],
- "isinsv" => [0x022F3],
- "isinv" => [0x02208],
- "it" => [0x02062],
- "itilde" => [0x00129],
- "iukcy" => [0x00456],
- "iuml" => [0x000EF],
- "jcirc" => [0x00135],
- "jcy" => [0x00439],
- "jfr" => [0x1D527],
- "jmath" => [0x00237],
- "jopf" => [0x1D55B],
- "jscr" => [0x1D4BF],
- "jsercy" => [0x00458],
- "jukcy" => [0x00454],
- "kappa" => [0x003BA],
- "kappav" => [0x003F0],
- "kcedil" => [0x00137],
- "kcy" => [0x0043A],
- "kfr" => [0x1D528],
- "kgreen" => [0x00138],
- "khcy" => [0x00445],
- "kjcy" => [0x0045C],
- "kopf" => [0x1D55C],
- "kscr" => [0x1D4C0],
- "lAarr" => [0x021DA],
- "lArr" => [0x021D0],
- "lAtail" => [0x0291B],
- "lBarr" => [0x0290E],
- "lE" => [0x02266],
- "lEg" => [0x02A8B],
- "lHar" => [0x02962],
- "lacute" => [0x0013A],
- "laemptyv" => [0x029B4],
- "lagran" => [0x02112],
- "lambda" => [0x003BB],
- "lang" => [0x027E8],
- "langd" => [0x02991],
- "langle" => [0x027E8],
- "lap" => [0x02A85],
- "laquo" => [0x000AB],
- "larr" => [0x02190],
- "larrb" => [0x021E4],
- "larrbfs" => [0x0291F],
- "larrfs" => [0x0291D],
- "larrhk" => [0x021A9],
- "larrlp" => [0x021AB],
- "larrpl" => [0x02939],
- "larrsim" => [0x02973],
- "larrtl" => [0x021A2],
- "lat" => [0x02AAB],
- "latail" => [0x02919],
- "late" => [0x02AAD],
- "lates" => [0x02AAD, 0x0FE00],
- "lbarr" => [0x0290C],
- "lbbrk" => [0x02772],
- "lbrace" => [0x0007B],
- "lbrack" => [0x0005B],
- "lbrke" => [0x0298B],
- "lbrksld" => [0x0298F],
- "lbrkslu" => [0x0298D],
- "lcaron" => [0x0013E],
- "lcedil" => [0x0013C],
- "lceil" => [0x02308],
- "lcub" => [0x0007B],
- "lcy" => [0x0043B],
- "ldca" => [0x02936],
- "ldquo" => [0x0201C],
- "ldquor" => [0x0201E],
- "ldrdhar" => [0x02967],
- "ldrushar" => [0x0294B],
- "ldsh" => [0x021B2],
- "le" => [0x02264],
- "leftarrow" => [0x02190],
- "leftarrowtail" => [0x021A2],
- "leftharpoondown" => [0x021BD],
- "leftharpoonup" => [0x021BC],
- "leftleftarrows" => [0x021C7],
- "leftrightarrow" => [0x02194],
- "leftrightarrows" => [0x021C6],
- "leftrightharpoons" => [0x021CB],
- "leftrightsquigarrow" => [0x021AD],
- "leftthreetimes" => [0x022CB],
- "leg" => [0x022DA],
- "leq" => [0x02264],
- "leqq" => [0x02266],
- "leqslant" => [0x02A7D],
- "les" => [0x02A7D],
- "lescc" => [0x02AA8],
- "lesdot" => [0x02A7F],
- "lesdoto" => [0x02A81],
- "lesdotor" => [0x02A83],
- "lesg" => [0x022DA, 0x0FE00],
- "lesges" => [0x02A93],
- "lessapprox" => [0x02A85],
- "lessdot" => [0x022D6],
- "lesseqgtr" => [0x022DA],
- "lesseqqgtr" => [0x02A8B],
- "lessgtr" => [0x02276],
- "lesssim" => [0x02272],
- "lfisht" => [0x0297C],
- "lfloor" => [0x0230A],
- "lfr" => [0x1D529],
- "lg" => [0x02276],
- "lgE" => [0x02A91],
- "lhard" => [0x021BD],
- "lharu" => [0x021BC],
- "lharul" => [0x0296A],
- "lhblk" => [0x02584],
- "ljcy" => [0x00459],
- "ll" => [0x0226A],
- "llarr" => [0x021C7],
- "llcorner" => [0x0231E],
- "llhard" => [0x0296B],
- "lltri" => [0x025FA],
- "lmidot" => [0x00140],
- "lmoust" => [0x023B0],
- "lmoustache" => [0x023B0],
- "lnE" => [0x02268],
- "lnap" => [0x02A89],
- "lnapprox" => [0x02A89],
- "lne" => [0x02A87],
- "lneq" => [0x02A87],
- "lneqq" => [0x02268],
- "lnsim" => [0x022E6],
- "loang" => [0x027EC],
- "loarr" => [0x021FD],
- "lobrk" => [0x027E6],
- "longleftarrow" => [0x027F5],
- "longleftrightarrow" => [0x027F7],
- "longmapsto" => [0x027FC],
- "longrightarrow" => [0x027F6],
- "looparrowleft" => [0x021AB],
- "looparrowright" => [0x021AC],
- "lopar" => [0x02985],
- "lopf" => [0x1D55D],
- "loplus" => [0x02A2D],
- "lotimes" => [0x02A34],
- "lowast" => [0x02217],
- "lowbar" => [0x0005F],
- "loz" => [0x025CA],
- "lozenge" => [0x025CA],
- "lozf" => [0x029EB],
- "lpar" => [0x00028],
- "lparlt" => [0x02993],
- "lrarr" => [0x021C6],
- "lrcorner" => [0x0231F],
- "lrhar" => [0x021CB],
- "lrhard" => [0x0296D],
- "lrm" => [0x0200E],
- "lrtri" => [0x022BF],
- "lsaquo" => [0x02039],
- "lscr" => [0x1D4C1],
- "lsh" => [0x021B0],
- "lsim" => [0x02272],
- "lsime" => [0x02A8D],
- "lsimg" => [0x02A8F],
- "lsqb" => [0x0005B],
- "lsquo" => [0x02018],
- "lsquor" => [0x0201A],
- "lstrok" => [0x00142],
- "lt" => [0x0003C],
- "ltcc" => [0x02AA6],
- "ltcir" => [0x02A79],
- "ltdot" => [0x022D6],
- "lthree" => [0x022CB],
- "ltimes" => [0x022C9],
- "ltlarr" => [0x02976],
- "ltquest" => [0x02A7B],
- "ltrPar" => [0x02996],
- "ltri" => [0x025C3],
- "ltrie" => [0x022B4],
- "ltrif" => [0x025C2],
- "lurdshar" => [0x0294A],
- "luruhar" => [0x02966],
- "lvertneqq" => [0x02268, 0x0FE00],
- "lvnE" => [0x02268, 0x0FE00],
- "mDDot" => [0x0223A],
- "macr" => [0x000AF],
- "male" => [0x02642],
- "malt" => [0x02720],
- "maltese" => [0x02720],
- "map" => [0x021A6],
- "mapsto" => [0x021A6],
- "mapstodown" => [0x021A7],
- "mapstoleft" => [0x021A4],
- "mapstoup" => [0x021A5],
- "marker" => [0x025AE],
- "mcomma" => [0x02A29],
- "mcy" => [0x0043C],
- "mdash" => [0x02014],
- "measuredangle" => [0x02221],
- "mfr" => [0x1D52A],
- "mho" => [0x02127],
- "micro" => [0x000B5],
- "mid" => [0x02223],
- "midast" => [0x0002A],
- "midcir" => [0x02AF0],
- "middot" => [0x000B7],
- "minus" => [0x02212],
- "minusb" => [0x0229F],
- "minusd" => [0x02238],
- "minusdu" => [0x02A2A],
- "mlcp" => [0x02ADB],
- "mldr" => [0x02026],
- "mnplus" => [0x02213],
- "models" => [0x022A7],
- "mopf" => [0x1D55E],
- "mp" => [0x02213],
- "mscr" => [0x1D4C2],
- "mstpos" => [0x0223E],
- "mu" => [0x003BC],
- "multimap" => [0x022B8],
- "mumap" => [0x022B8],
- "nGg" => [0x022D9, 0x00338],
- "nGt" => [0x0226B, 0x020D2],
- "nGtv" => [0x0226B, 0x00338],
- "nLeftarrow" => [0x021CD],
- "nLeftrightarrow" => [0x021CE],
- "nLl" => [0x022D8, 0x00338],
- "nLt" => [0x0226A, 0x020D2],
- "nLtv" => [0x0226A, 0x00338],
- "nRightarrow" => [0x021CF],
- "nVDash" => [0x022AF],
- "nVdash" => [0x022AE],
- "nabla" => [0x02207],
- "nacute" => [0x00144],
- "nang" => [0x02220, 0x020D2],
- "nap" => [0x02249],
- "napE" => [0x02A70, 0x00338],
- "napid" => [0x0224B, 0x00338],
- "napos" => [0x00149],
- "napprox" => [0x02249],
- "natur" => [0x0266E],
- "natural" => [0x0266E],
- "naturals" => [0x02115],
- "nbsp" => [0x000A0],
- "nbump" => [0x0224E, 0x00338],
- "nbumpe" => [0x0224F, 0x00338],
- "ncap" => [0x02A43],
- "ncaron" => [0x00148],
- "ncedil" => [0x00146],
- "ncong" => [0x02247],
- "ncongdot" => [0x02A6D, 0x00338],
- "ncup" => [0x02A42],
- "ncy" => [0x0043D],
- "ndash" => [0x02013],
- "ne" => [0x02260],
- "neArr" => [0x021D7],
- "nearhk" => [0x02924],
- "nearr" => [0x02197],
- "nearrow" => [0x02197],
- "nedot" => [0x02250, 0x00338],
- "nequiv" => [0x02262],
- "nesear" => [0x02928],
- "nesim" => [0x02242, 0x00338],
- "nexist" => [0x02204],
- "nexists" => [0x02204],
- "nfr" => [0x1D52B],
- "ngE" => [0x02267, 0x00338],
- "nge" => [0x02271],
- "ngeq" => [0x02271],
- "ngeqq" => [0x02267, 0x00338],
- "ngeqslant" => [0x02A7E, 0x00338],
- "nges" => [0x02A7E, 0x00338],
- "ngsim" => [0x02275],
- "ngt" => [0x0226F],
- "ngtr" => [0x0226F],
- "nhArr" => [0x021CE],
- "nharr" => [0x021AE],
- "nhpar" => [0x02AF2],
- "ni" => [0x0220B],
- "nis" => [0x022FC],
- "nisd" => [0x022FA],
- "niv" => [0x0220B],
- "njcy" => [0x0045A],
- "nlArr" => [0x021CD],
- "nlE" => [0x02266, 0x00338],
- "nlarr" => [0x0219A],
- "nldr" => [0x02025],
- "nle" => [0x02270],
- "nleftarrow" => [0x0219A],
- "nleftrightarrow" => [0x021AE],
- "nleq" => [0x02270],
- "nleqq" => [0x02266, 0x00338],
- "nleqslant" => [0x02A7D, 0x00338],
- "nles" => [0x02A7D, 0x00338],
- "nless" => [0x0226E],
- "nlsim" => [0x02274],
- "nlt" => [0x0226E],
- "nltri" => [0x022EA],
- "nltrie" => [0x022EC],
- "nmid" => [0x02224],
- "nopf" => [0x1D55F],
- "not" => [0x000AC],
- "notin" => [0x02209],
- "notinE" => [0x022F9, 0x00338],
- "notindot" => [0x022F5, 0x00338],
- "notinva" => [0x02209],
- "notinvb" => [0x022F7],
- "notinvc" => [0x022F6],
- "notni" => [0x0220C],
- "notniva" => [0x0220C],
- "notnivb" => [0x022FE],
- "notnivc" => [0x022FD],
- "npar" => [0x02226],
- "nparallel" => [0x02226],
- "nparsl" => [0x02AFD, 0x020E5],
- "npart" => [0x02202, 0x00338],
- "npolint" => [0x02A14],
- "npr" => [0x02280],
- "nprcue" => [0x022E0],
- "npre" => [0x02AAF, 0x00338],
- "nprec" => [0x02280],
- "npreceq" => [0x02AAF, 0x00338],
- "nrArr" => [0x021CF],
- "nrarr" => [0x0219B],
- "nrarrc" => [0x02933, 0x00338],
- "nrarrw" => [0x0219D, 0x00338],
- "nrightarrow" => [0x0219B],
- "nrtri" => [0x022EB],
- "nrtrie" => [0x022ED],
- "nsc" => [0x02281],
- "nsccue" => [0x022E1],
- "nsce" => [0x02AB0, 0x00338],
- "nscr" => [0x1D4C3],
- "nshortmid" => [0x02224],
- "nshortparallel" => [0x02226],
- "nsim" => [0x02241],
- "nsime" => [0x02244],
- "nsimeq" => [0x02244],
- "nsmid" => [0x02224],
- "nspar" => [0x02226],
- "nsqsube" => [0x022E2],
- "nsqsupe" => [0x022E3],
- "nsub" => [0x02284],
- "nsubE" => [0x02AC5, 0x00338],
- "nsube" => [0x02288],
- "nsubset" => [0x02282, 0x020D2],
- "nsubseteq" => [0x02288],
- "nsubseteqq" => [0x02AC5, 0x00338],
- "nsucc" => [0x02281],
- "nsucceq" => [0x02AB0, 0x00338],
- "nsup" => [0x02285],
- "nsupE" => [0x02AC6, 0x00338],
- "nsupe" => [0x02289],
- "nsupset" => [0x02283, 0x020D2],
- "nsupseteq" => [0x02289],
- "nsupseteqq" => [0x02AC6, 0x00338],
- "ntgl" => [0x02279],
- "ntilde" => [0x000F1],
- "ntlg" => [0x02278],
- "ntriangleleft" => [0x022EA],
- "ntrianglelefteq" => [0x022EC],
- "ntriangleright" => [0x022EB],
- "ntrianglerighteq" => [0x022ED],
- "nu" => [0x003BD],
- "num" => [0x00023],
- "numero" => [0x02116],
- "numsp" => [0x02007],
- "nvDash" => [0x022AD],
- "nvHarr" => [0x02904],
- "nvap" => [0x0224D, 0x020D2],
- "nvdash" => [0x022AC],
- "nvge" => [0x02265, 0x020D2],
- "nvgt" => [0x0003E, 0x020D2],
- "nvinfin" => [0x029DE],
- "nvlArr" => [0x02902],
- "nvle" => [0x02264, 0x020D2],
- "nvlt" => [0x0003C, 0x020D2],
- "nvltrie" => [0x022B4, 0x020D2],
- "nvrArr" => [0x02903],
- "nvrtrie" => [0x022B5, 0x020D2],
- "nvsim" => [0x0223C, 0x020D2],
- "nwArr" => [0x021D6],
- "nwarhk" => [0x02923],
- "nwarr" => [0x02196],
- "nwarrow" => [0x02196],
- "nwnear" => [0x02927],
- "oS" => [0x024C8],
- "oacute" => [0x000F3],
- "oast" => [0x0229B],
- "ocir" => [0x0229A],
- "ocirc" => [0x000F4],
- "ocy" => [0x0043E],
- "odash" => [0x0229D],
- "odblac" => [0x00151],
- "odiv" => [0x02A38],
- "odot" => [0x02299],
- "odsold" => [0x029BC],
- "oelig" => [0x00153],
- "ofcir" => [0x029BF],
- "ofr" => [0x1D52C],
- "ogon" => [0x002DB],
- "ograve" => [0x000F2],
- "ogt" => [0x029C1],
- "ohbar" => [0x029B5],
- "ohm" => [0x003A9],
- "oint" => [0x0222E],
- "olarr" => [0x021BA],
- "olcir" => [0x029BE],
- "olcross" => [0x029BB],
- "oline" => [0x0203E],
- "olt" => [0x029C0],
- "omacr" => [0x0014D],
- "omega" => [0x003C9],
- "omicron" => [0x003BF],
- "omid" => [0x029B6],
- "ominus" => [0x02296],
- "oopf" => [0x1D560],
- "opar" => [0x029B7],
- "operp" => [0x029B9],
- "oplus" => [0x02295],
- "or" => [0x02228],
- "orarr" => [0x021BB],
- "ord" => [0x02A5D],
- "order" => [0x02134],
- "orderof" => [0x02134],
- "ordf" => [0x000AA],
- "ordm" => [0x000BA],
- "origof" => [0x022B6],
- "oror" => [0x02A56],
- "orslope" => [0x02A57],
- "orv" => [0x02A5B],
- "oscr" => [0x02134],
- "oslash" => [0x000F8],
- "osol" => [0x02298],
- "otilde" => [0x000F5],
- "otimes" => [0x02297],
- "otimesas" => [0x02A36],
- "ouml" => [0x000F6],
- "ovbar" => [0x0233D],
- "par" => [0x02225],
- "para" => [0x000B6],
- "parallel" => [0x02225],
- "parsim" => [0x02AF3],
- "parsl" => [0x02AFD],
- "part" => [0x02202],
- "pcy" => [0x0043F],
- "percnt" => [0x00025],
- "period" => [0x0002E],
- "permil" => [0x02030],
- "perp" => [0x022A5],
- "pertenk" => [0x02031],
- "pfr" => [0x1D52D],
- "phi" => [0x003C6],
- "phiv" => [0x003D5],
- "phmmat" => [0x02133],
- "phone" => [0x0260E],
- "pi" => [0x003C0],
- "pitchfork" => [0x022D4],
- "piv" => [0x003D6],
- "planck" => [0x0210F],
- "planckh" => [0x0210E],
- "plankv" => [0x0210F],
- "plus" => [0x0002B],
- "plusacir" => [0x02A23],
- "plusb" => [0x0229E],
- "pluscir" => [0x02A22],
- "plusdo" => [0x02214],
- "plusdu" => [0x02A25],
- "pluse" => [0x02A72],
- "plusmn" => [0x000B1],
- "plussim" => [0x02A26],
- "plustwo" => [0x02A27],
- "pm" => [0x000B1],
- "pointint" => [0x02A15],
- "popf" => [0x1D561],
- "pound" => [0x000A3],
- "pr" => [0x0227A],
- "prE" => [0x02AB3],
- "prap" => [0x02AB7],
- "prcue" => [0x0227C],
- "pre" => [0x02AAF],
- "prec" => [0x0227A],
- "precapprox" => [0x02AB7],
- "preccurlyeq" => [0x0227C],
- "preceq" => [0x02AAF],
- "precnapprox" => [0x02AB9],
- "precneqq" => [0x02AB5],
- "precnsim" => [0x022E8],
- "precsim" => [0x0227E],
- "prime" => [0x02032],
- "primes" => [0x02119],
- "prnE" => [0x02AB5],
- "prnap" => [0x02AB9],
- "prnsim" => [0x022E8],
- "prod" => [0x0220F],
- "profalar" => [0x0232E],
- "profline" => [0x02312],
- "profsurf" => [0x02313],
- "prop" => [0x0221D],
- "propto" => [0x0221D],
- "prsim" => [0x0227E],
- "prurel" => [0x022B0],
- "pscr" => [0x1D4C5],
- "psi" => [0x003C8],
- "puncsp" => [0x02008],
- "qfr" => [0x1D52E],
- "qint" => [0x02A0C],
- "qopf" => [0x1D562],
- "qprime" => [0x02057],
- "qscr" => [0x1D4C6],
- "quaternions" => [0x0210D],
- "quatint" => [0x02A16],
- "quest" => [0x0003F],
- "questeq" => [0x0225F],
- "quot" => [0x00022],
- "rAarr" => [0x021DB],
- "rArr" => [0x021D2],
- "rAtail" => [0x0291C],
- "rBarr" => [0x0290F],
- "rHar" => [0x02964],
- "race" => [0x0223D, 0x00331],
- "racute" => [0x00155],
- "radic" => [0x0221A],
- "raemptyv" => [0x029B3],
- "rang" => [0x027E9],
- "rangd" => [0x02992],
- "range" => [0x029A5],
- "rangle" => [0x027E9],
- "raquo" => [0x000BB],
- "rarr" => [0x02192],
- "rarrap" => [0x02975],
- "rarrb" => [0x021E5],
- "rarrbfs" => [0x02920],
- "rarrc" => [0x02933],
- "rarrfs" => [0x0291E],
- "rarrhk" => [0x021AA],
- "rarrlp" => [0x021AC],
- "rarrpl" => [0x02945],
- "rarrsim" => [0x02974],
- "rarrtl" => [0x021A3],
- "rarrw" => [0x0219D],
- "ratail" => [0x0291A],
- "ratio" => [0x02236],
- "rationals" => [0x0211A],
- "rbarr" => [0x0290D],
- "rbbrk" => [0x02773],
- "rbrace" => [0x0007D],
- "rbrack" => [0x0005D],
- "rbrke" => [0x0298C],
- "rbrksld" => [0x0298E],
- "rbrkslu" => [0x02990],
- "rcaron" => [0x00159],
- "rcedil" => [0x00157],
- "rceil" => [0x02309],
- "rcub" => [0x0007D],
- "rcy" => [0x00440],
- "rdca" => [0x02937],
- "rdldhar" => [0x02969],
- "rdquo" => [0x0201D],
- "rdquor" => [0x0201D],
- "rdsh" => [0x021B3],
- "real" => [0x0211C],
- "realine" => [0x0211B],
- "realpart" => [0x0211C],
- "reals" => [0x0211D],
- "rect" => [0x025AD],
- "reg" => [0x000AE],
- "rfisht" => [0x0297D],
- "rfloor" => [0x0230B],
- "rfr" => [0x1D52F],
- "rhard" => [0x021C1],
- "rharu" => [0x021C0],
- "rharul" => [0x0296C],
- "rho" => [0x003C1],
- "rhov" => [0x003F1],
- "rightarrow" => [0x02192],
- "rightarrowtail" => [0x021A3],
- "rightharpoondown" => [0x021C1],
- "rightharpoonup" => [0x021C0],
- "rightleftarrows" => [0x021C4],
- "rightleftharpoons" => [0x021CC],
- "rightrightarrows" => [0x021C9],
- "rightsquigarrow" => [0x0219D],
- "rightthreetimes" => [0x022CC],
- "ring" => [0x002DA],
- "risingdotseq" => [0x02253],
- "rlarr" => [0x021C4],
- "rlhar" => [0x021CC],
- "rlm" => [0x0200F],
- "rmoust" => [0x023B1],
- "rmoustache" => [0x023B1],
- "rnmid" => [0x02AEE],
- "roang" => [0x027ED],
- "roarr" => [0x021FE],
- "robrk" => [0x027E7],
- "ropar" => [0x02986],
- "ropf" => [0x1D563],
- "roplus" => [0x02A2E],
- "rotimes" => [0x02A35],
- "rpar" => [0x00029],
- "rpargt" => [0x02994],
- "rppolint" => [0x02A12],
- "rrarr" => [0x021C9],
- "rsaquo" => [0x0203A],
- "rscr" => [0x1D4C7],
- "rsh" => [0x021B1],
- "rsqb" => [0x0005D],
- "rsquo" => [0x02019],
- "rsquor" => [0x02019],
- "rthree" => [0x022CC],
- "rtimes" => [0x022CA],
- "rtri" => [0x025B9],
- "rtrie" => [0x022B5],
- "rtrif" => [0x025B8],
- "rtriltri" => [0x029CE],
- "ruluhar" => [0x02968],
- "rx" => [0x0211E],
- "sacute" => [0x0015B],
- "sbquo" => [0x0201A],
- "sc" => [0x0227B],
- "scE" => [0x02AB4],
- "scap" => [0x02AB8],
- "scaron" => [0x00161],
- "sccue" => [0x0227D],
- "sce" => [0x02AB0],
- "scedil" => [0x0015F],
- "scirc" => [0x0015D],
- "scnE" => [0x02AB6],
- "scnap" => [0x02ABA],
- "scnsim" => [0x022E9],
- "scpolint" => [0x02A13],
- "scsim" => [0x0227F],
- "scy" => [0x00441],
- "sdot" => [0x022C5],
- "sdotb" => [0x022A1],
- "sdote" => [0x02A66],
- "seArr" => [0x021D8],
- "searhk" => [0x02925],
- "searr" => [0x02198],
- "searrow" => [0x02198],
- "sect" => [0x000A7],
- "semi" => [0x0003B],
- "seswar" => [0x02929],
- "setminus" => [0x02216],
- "setmn" => [0x02216],
- "sext" => [0x02736],
- "sfr" => [0x1D530],
- "sfrown" => [0x02322],
- "sharp" => [0x0266F],
- "shchcy" => [0x00449],
- "shcy" => [0x00448],
- "shortmid" => [0x02223],
- "shortparallel" => [0x02225],
- "shy" => [0x000AD],
- "sigma" => [0x003C3],
- "sigmaf" => [0x003C2],
- "sigmav" => [0x003C2],
- "sim" => [0x0223C],
- "simdot" => [0x02A6A],
- "sime" => [0x02243],
- "simeq" => [0x02243],
- "simg" => [0x02A9E],
- "simgE" => [0x02AA0],
- "siml" => [0x02A9D],
- "simlE" => [0x02A9F],
- "simne" => [0x02246],
- "simplus" => [0x02A24],
- "simrarr" => [0x02972],
- "slarr" => [0x02190],
- "smallsetminus" => [0x02216],
- "smashp" => [0x02A33],
- "smeparsl" => [0x029E4],
- "smid" => [0x02223],
- "smile" => [0x02323],
- "smt" => [0x02AAA],
- "smte" => [0x02AAC],
- "smtes" => [0x02AAC, 0x0FE00],
- "softcy" => [0x0044C],
- "sol" => [0x0002F],
- "solb" => [0x029C4],
- "solbar" => [0x0233F],
- "sopf" => [0x1D564],
- "spades" => [0x02660],
- "spadesuit" => [0x02660],
- "spar" => [0x02225],
- "sqcap" => [0x02293],
- "sqcaps" => [0x02293, 0x0FE00],
- "sqcup" => [0x02294],
- "sqcups" => [0x02294, 0x0FE00],
- "sqsub" => [0x0228F],
- "sqsube" => [0x02291],
- "sqsubset" => [0x0228F],
- "sqsubseteq" => [0x02291],
- "sqsup" => [0x02290],
- "sqsupe" => [0x02292],
- "sqsupset" => [0x02290],
- "sqsupseteq" => [0x02292],
- "squ" => [0x025A1],
- "square" => [0x025A1],
- "squarf" => [0x025AA],
- "squf" => [0x025AA],
- "srarr" => [0x02192],
- "sscr" => [0x1D4C8],
- "ssetmn" => [0x02216],
- "ssmile" => [0x02323],
- "sstarf" => [0x022C6],
- "star" => [0x02606],
- "starf" => [0x02605],
- "straightepsilon" => [0x003F5],
- "straightphi" => [0x003D5],
- "strns" => [0x000AF],
- "sub" => [0x02282],
- "subE" => [0x02AC5],
- "subdot" => [0x02ABD],
- "sube" => [0x02286],
- "subedot" => [0x02AC3],
- "submult" => [0x02AC1],
- "subnE" => [0x02ACB],
- "subne" => [0x0228A],
- "subplus" => [0x02ABF],
- "subrarr" => [0x02979],
- "subset" => [0x02282],
- "subseteq" => [0x02286],
- "subseteqq" => [0x02AC5],
- "subsetneq" => [0x0228A],
- "subsetneqq" => [0x02ACB],
- "subsim" => [0x02AC7],
- "subsub" => [0x02AD5],
- "subsup" => [0x02AD3],
- "succ" => [0x0227B],
- "succapprox" => [0x02AB8],
- "succcurlyeq" => [0x0227D],
- "succeq" => [0x02AB0],
- "succnapprox" => [0x02ABA],
- "succneqq" => [0x02AB6],
- "succnsim" => [0x022E9],
- "succsim" => [0x0227F],
- "sum" => [0x02211],
- "sung" => [0x0266A],
- "sup" => [0x02283],
- "sup1" => [0x000B9],
- "sup2" => [0x000B2],
- "sup3" => [0x000B3],
- "supE" => [0x02AC6],
- "supdot" => [0x02ABE],
- "supdsub" => [0x02AD8],
- "supe" => [0x02287],
- "supedot" => [0x02AC4],
- "suphsol" => [0x027C9],
- "suphsub" => [0x02AD7],
- "suplarr" => [0x0297B],
- "supmult" => [0x02AC2],
- "supnE" => [0x02ACC],
- "supne" => [0x0228B],
- "supplus" => [0x02AC0],
- "supset" => [0x02283],
- "supseteq" => [0x02287],
- "supseteqq" => [0x02AC6],
- "supsetneq" => [0x0228B],
- "supsetneqq" => [0x02ACC],
- "supsim" => [0x02AC8],
- "supsub" => [0x02AD4],
- "supsup" => [0x02AD6],
- "swArr" => [0x021D9],
- "swarhk" => [0x02926],
- "swarr" => [0x02199],
- "swarrow" => [0x02199],
- "swnwar" => [0x0292A],
- "szlig" => [0x000DF],
- "target" => [0x02316],
- "tau" => [0x003C4],
- "tbrk" => [0x023B4],
- "tcaron" => [0x00165],
- "tcedil" => [0x00163],
- "tcy" => [0x00442],
- "tdot" => [0x020DB],
- "telrec" => [0x02315],
- "tfr" => [0x1D531],
- "there4" => [0x02234],
- "therefore" => [0x02234],
- "theta" => [0x003B8],
- "thetasym" => [0x003D1],
- "thetav" => [0x003D1],
- "thickapprox" => [0x02248],
- "thicksim" => [0x0223C],
- "thinsp" => [0x02009],
- "thkap" => [0x02248],
- "thksim" => [0x0223C],
- "thorn" => [0x000FE],
- "tilde" => [0x002DC],
- "times" => [0x000D7],
- "timesb" => [0x022A0],
- "timesbar" => [0x02A31],
- "timesd" => [0x02A30],
- "tint" => [0x0222D],
- "toea" => [0x02928],
- "top" => [0x022A4],
- "topbot" => [0x02336],
- "topcir" => [0x02AF1],
- "topf" => [0x1D565],
- "topfork" => [0x02ADA],
- "tosa" => [0x02929],
- "tprime" => [0x02034],
- "trade" => [0x02122],
- "triangle" => [0x025B5],
- "triangledown" => [0x025BF],
- "triangleleft" => [0x025C3],
- "trianglelefteq" => [0x022B4],
- "triangleq" => [0x0225C],
- "triangleright" => [0x025B9],
- "trianglerighteq" => [0x022B5],
- "tridot" => [0x025EC],
- "trie" => [0x0225C],
- "triminus" => [0x02A3A],
- "triplus" => [0x02A39],
- "trisb" => [0x029CD],
- "tritime" => [0x02A3B],
- "trpezium" => [0x023E2],
- "tscr" => [0x1D4C9],
- "tscy" => [0x00446],
- "tshcy" => [0x0045B],
- "tstrok" => [0x00167],
- "twixt" => [0x0226C],
- "twoheadleftarrow" => [0x0219E],
- "twoheadrightarrow" => [0x021A0],
- "uArr" => [0x021D1],
- "uHar" => [0x02963],
- "uacute" => [0x000FA],
- "uarr" => [0x02191],
- "ubrcy" => [0x0045E],
- "ubreve" => [0x0016D],
- "ucirc" => [0x000FB],
- "ucy" => [0x00443],
- "udarr" => [0x021C5],
- "udblac" => [0x00171],
- "udhar" => [0x0296E],
- "ufisht" => [0x0297E],
- "ufr" => [0x1D532],
- "ugrave" => [0x000F9],
- "uharl" => [0x021BF],
- "uharr" => [0x021BE],
- "uhblk" => [0x02580],
- "ulcorn" => [0x0231C],
- "ulcorner" => [0x0231C],
- "ulcrop" => [0x0230F],
- "ultri" => [0x025F8],
- "umacr" => [0x0016B],
- "uml" => [0x000A8],
- "uogon" => [0x00173],
- "uopf" => [0x1D566],
- "uparrow" => [0x02191],
- "updownarrow" => [0x02195],
- "upharpoonleft" => [0x021BF],
- "upharpoonright" => [0x021BE],
- "uplus" => [0x0228E],
- "upsi" => [0x003C5],
- "upsih" => [0x003D2],
- "upsilon" => [0x003C5],
- "upuparrows" => [0x021C8],
- "urcorn" => [0x0231D],
- "urcorner" => [0x0231D],
- "urcrop" => [0x0230E],
- "uring" => [0x0016F],
- "urtri" => [0x025F9],
- "uscr" => [0x1D4CA],
- "utdot" => [0x022F0],
- "utilde" => [0x00169],
- "utri" => [0x025B5],
- "utrif" => [0x025B4],
- "uuarr" => [0x021C8],
- "uuml" => [0x000FC],
- "uwangle" => [0x029A7],
- "vArr" => [0x021D5],
- "vBar" => [0x02AE8],
- "vBarv" => [0x02AE9],
- "vDash" => [0x022A8],
- "vangrt" => [0x0299C],
- "varepsilon" => [0x003F5],
- "varkappa" => [0x003F0],
- "varnothing" => [0x02205],
- "varphi" => [0x003D5],
- "varpi" => [0x003D6],
- "varpropto" => [0x0221D],
- "varr" => [0x02195],
- "varrho" => [0x003F1],
- "varsigma" => [0x003C2],
- "varsubsetneq" => [0x0228A, 0x0FE00],
- "varsubsetneqq" => [0x02ACB, 0x0FE00],
- "varsupsetneq" => [0x0228B, 0x0FE00],
- "varsupsetneqq" => [0x02ACC, 0x0FE00],
- "vartheta" => [0x003D1],
- "vartriangleleft" => [0x022B2],
- "vartriangleright" => [0x022B3],
- "vcy" => [0x00432],
- "vdash" => [0x022A2],
- "vee" => [0x02228],
- "veebar" => [0x022BB],
- "veeeq" => [0x0225A],
- "vellip" => [0x022EE],
- "verbar" => [0x0007C],
- "vert" => [0x0007C],
- "vfr" => [0x1D533],
- "vltri" => [0x022B2],
- "vnsub" => [0x02282, 0x020D2],
- "vnsup" => [0x02283, 0x020D2],
- "vopf" => [0x1D567],
- "vprop" => [0x0221D],
- "vrtri" => [0x022B3],
- "vscr" => [0x1D4CB],
- "vsubnE" => [0x02ACB, 0x0FE00],
- "vsubne" => [0x0228A, 0x0FE00],
- "vsupnE" => [0x02ACC, 0x0FE00],
- "vsupne" => [0x0228B, 0x0FE00],
- "vzigzag" => [0x0299A],
- "wcirc" => [0x00175],
- "wedbar" => [0x02A5F],
- "wedge" => [0x02227],
- "wedgeq" => [0x02259],
- "weierp" => [0x02118],
- "wfr" => [0x1D534],
- "wopf" => [0x1D568],
- "wp" => [0x02118],
- "wr" => [0x02240],
- "wreath" => [0x02240],
- "wscr" => [0x1D4CC],
- "xcap" => [0x022C2],
- "xcirc" => [0x025EF],
- "xcup" => [0x022C3],
- "xdtri" => [0x025BD],
- "xfr" => [0x1D535],
- "xhArr" => [0x027FA],
- "xharr" => [0x027F7],
- "xi" => [0x003BE],
- "xlArr" => [0x027F8],
- "xlarr" => [0x027F5],
- "xmap" => [0x027FC],
- "xnis" => [0x022FB],
- "xodot" => [0x02A00],
- "xopf" => [0x1D569],
- "xoplus" => [0x02A01],
- "xotime" => [0x02A02],
- "xrArr" => [0x027F9],
- "xrarr" => [0x027F6],
- "xscr" => [0x1D4CD],
- "xsqcup" => [0x02A06],
- "xuplus" => [0x02A04],
- "xutri" => [0x025B3],
- "xvee" => [0x022C1],
- "xwedge" => [0x022C0],
- "yacute" => [0x000FD],
- "yacy" => [0x0044F],
- "ycirc" => [0x00177],
- "ycy" => [0x0044B],
- "yen" => [0x000A5],
- "yfr" => [0x1D536],
- "yicy" => [0x00457],
- "yopf" => [0x1D56A],
- "yscr" => [0x1D4CE],
- "yucy" => [0x0044E],
- "yuml" => [0x000FF],
- "zacute" => [0x0017A],
- "zcaron" => [0x0017E],
- "zcy" => [0x00437],
- "zdot" => [0x0017C],
- "zeetrf" => [0x02128],
- "zeta" => [0x003B6],
- "zfr" => [0x1D537],
- "zhcy" => [0x00436],
- "zigrarr" => [0x021DD],
- "zopf" => [0x1D56B],
- "zscr" => [0x1D4CF],
- "zwj" => [0x0200D],
- "zwnj" => [0x0200C],
-}
-
diff --git a/lib/rdoc/markdown/literals.rb b/lib/rdoc/markdown/literals.rb
deleted file mode 100644
index 37659b7ae0..0000000000
--- a/lib/rdoc/markdown/literals.rb
+++ /dev/null
@@ -1,455 +0,0 @@
-# coding: UTF-8
-# frozen_string_literal: true
-# :markup: markdown
-
-##
-#--
-# This set of literals is for Ruby 1.9 regular expressions and gives full
-# unicode support.
-#
-# Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
-# characters, newlines and spaces.
-class RDoc::Markdown::Literals
- # :stopdoc:
-
- # This is distinct from setup_parser so that a standalone parser
- # can redefine #initialize and still have access to the proper
- # parser setup code.
- def initialize(str, debug=false)
- setup_parser(str, debug)
- end
-
-
-
- # Prepares for parsing +str+. If you define a custom initialize you must
- # call this method before #parse
- def setup_parser(str, debug=false)
- set_string str, 0
- @memoizations = Hash.new { |h,k| h[k] = {} }
- @result = nil
- @failed_rule = nil
- @failing_rule_offset = -1
- @line_offsets = nil
-
- setup_foreign_grammar
- end
-
- attr_reader :string
- attr_reader :failing_rule_offset
- attr_accessor :result, :pos
-
- def current_column(target=pos)
- if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
- return target - c
- elsif c = string.rindex("\n", target)
- return target - c
- end
-
- target + 1
- end
-
- def position_line_offsets
- unless @position_line_offsets
- @position_line_offsets = []
- total = 0
- string.each_line do |line|
- total += line.size
- @position_line_offsets << total
- end
- end
- @position_line_offsets
- end
-
- if [].respond_to? :bsearch_index
- def current_line(target=pos)
- if line = position_line_offsets.bsearch_index {|x| x > target }
- return line + 1
- end
- raise "Target position #{target} is outside of string"
- end
- else
- def current_line(target=pos)
- if line = position_line_offsets.index {|x| x > target }
- return line + 1
- end
-
- raise "Target position #{target} is outside of string"
- end
- end
-
- def current_character(target=pos)
- if target < 0 || target >= string.size
- raise "Target position #{target} is outside of string"
- end
- string[target, 1]
- end
-
- KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
-
- def current_pos_info(target=pos)
- l = current_line target
- c = current_column target
- ln = get_line(l-1)
- chr = string[target,1]
- KpegPosInfo.new(target, l, c, ln, chr)
- end
-
- def lines
- string.lines
- end
-
- def get_line(no)
- loff = position_line_offsets
- if no < 0
- raise "Line No is out of range: #{no} < 0"
- elsif no >= loff.size
- raise "Line No is out of range: #{no} >= #{loff.size}"
- end
- lend = loff[no]-1
- lstart = no > 0 ? loff[no-1] : 0
- string[lstart..lend]
- end
-
-
-
- def get_text(start)
- @string[start..@pos-1]
- end
-
- # Sets the string and current parsing position for the parser.
- def set_string string, pos
- @string = string
- @string_size = string ? string.size : 0
- @pos = pos
- @position_line_offsets = nil
- end
-
- def show_pos
- width = 10
- if @pos < width
- "#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
- else
- "#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
- end
- end
-
- def failure_info
- l = current_line @failing_rule_offset
- c = current_column @failing_rule_offset
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- "line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
- else
- "line #{l}, column #{c}: failed rule '#{@failed_rule}'"
- end
- end
-
- def failure_caret
- p = current_pos_info @failing_rule_offset
- "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
- end
-
- def failure_character
- current_character @failing_rule_offset
- end
-
- def failure_oneline
- p = current_pos_info @failing_rule_offset
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
- else
- "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
- end
- end
-
- class ParseError < RuntimeError
- end
-
- def raise_error
- raise ParseError, failure_oneline
- end
-
- def show_error(io=STDOUT)
- error_pos = @failing_rule_offset
- p = current_pos_info(error_pos)
-
- io.puts "On line #{p.lno}, column #{p.col}:"
-
- if @failed_rule.kind_of? Symbol
- info = self.class::Rules[@failed_rule]
- io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
- else
- io.puts "Failed to match rule '#{@failed_rule}'"
- end
-
- io.puts "Got: #{p.char.inspect}"
- io.puts "=> #{p.line}"
- io.print(" " * (p.col + 2))
- io.puts "^"
- end
-
- def set_failed_rule(name)
- if @pos > @failing_rule_offset
- @failed_rule = name
- @failing_rule_offset = @pos
- end
- end
-
- attr_reader :failed_rule
-
- def match_string(str)
- len = str.size
- if @string[pos,len] == str
- @pos += len
- return str
- end
-
- return nil
- end
-
- def scan(reg)
- if m = reg.match(@string, @pos)
- @pos = m.end(0)
- return true
- end
-
- return nil
- end
-
- if "".respond_to? :ord
- def get_byte
- if @pos >= @string_size
- return nil
- end
-
- s = @string[@pos].ord
- @pos += 1
- s
- end
- else
- def get_byte
- if @pos >= @string_size
- return nil
- end
-
- s = @string[@pos]
- @pos += 1
- s
- end
- end
-
- def parse(rule=nil)
- # We invoke the rules indirectly via apply
- # instead of by just calling them as methods because
- # if the rules use left recursion, apply needs to
- # manage that.
-
- if !rule
- apply(:_root)
- else
- method = rule.gsub("-","_hyphen_")
- apply :"_#{method}"
- end
- end
-
- class MemoEntry
- def initialize(ans, pos)
- @ans = ans
- @pos = pos
- @result = nil
- @set = false
- @left_rec = false
- end
-
- attr_reader :ans, :pos, :result, :set
- attr_accessor :left_rec
-
- def move!(ans, pos, result)
- @ans = ans
- @pos = pos
- @result = result
- @set = true
- @left_rec = false
- end
- end
-
- def external_invoke(other, rule, *args)
- old_pos = @pos
- old_string = @string
-
- set_string other.string, other.pos
-
- begin
- if val = __send__(rule, *args)
- other.pos = @pos
- other.result = @result
- else
- other.set_failed_rule "#{self.class}##{rule}"
- end
- val
- ensure
- set_string old_string, old_pos
- end
- end
-
- def apply_with_args(rule, *args)
- @result = nil
- memo_key = [rule, args]
- if m = @memoizations[memo_key][@pos]
- @pos = m.pos
- if !m.set
- m.left_rec = true
- return nil
- end
-
- @result = m.result
-
- return m.ans
- else
- m = MemoEntry.new(nil, @pos)
- @memoizations[memo_key][@pos] = m
- start_pos = @pos
-
- ans = __send__ rule, *args
-
- lr = m.left_rec
-
- m.move! ans, @pos, @result
-
- # Don't bother trying to grow the left recursion
- # if it's failing straight away (thus there is no seed)
- if ans and lr
- return grow_lr(rule, args, start_pos, m)
- else
- return ans
- end
- end
- end
-
- def apply(rule)
- @result = nil
- if m = @memoizations[rule][@pos]
- @pos = m.pos
- if !m.set
- m.left_rec = true
- return nil
- end
-
- @result = m.result
-
- return m.ans
- else
- m = MemoEntry.new(nil, @pos)
- @memoizations[rule][@pos] = m
- start_pos = @pos
-
- ans = __send__ rule
-
- lr = m.left_rec
-
- m.move! ans, @pos, @result
-
- # Don't bother trying to grow the left recursion
- # if it's failing straight away (thus there is no seed)
- if ans and lr
- return grow_lr(rule, nil, start_pos, m)
- else
- return ans
- end
- end
- end
-
- def grow_lr(rule, args, start_pos, m)
- while true
- @pos = start_pos
- @result = m.result
-
- if args
- ans = __send__ rule, *args
- else
- ans = __send__ rule
- end
- return nil unless ans
-
- break if @pos <= m.pos
-
- m.move! ans, @pos, @result
- end
-
- @result = m.result
- @pos = m.pos
- return m.ans
- end
-
- class RuleInfo
- def initialize(name, rendered)
- @name = name
- @rendered = rendered
- end
-
- attr_reader :name, :rendered
- end
-
- def self.rule_info(name, rendered)
- RuleInfo.new(name, rendered)
- end
-
-
- # :startdoc:
- # :stopdoc:
- def setup_foreign_grammar; end
-
- # Alphanumeric = /\p{Word}/
- def _Alphanumeric
- _tmp = scan(/\G(?-mix:\p{Word})/)
- set_failed_rule :_Alphanumeric unless _tmp
- return _tmp
- end
-
- # AlphanumericAscii = /[A-Za-z0-9]/
- def _AlphanumericAscii
- _tmp = scan(/\G(?-mix:[A-Za-z0-9])/)
- set_failed_rule :_AlphanumericAscii unless _tmp
- return _tmp
- end
-
- # BOM = "uFEFF"
- def _BOM
- _tmp = match_string("uFEFF")
- set_failed_rule :_BOM unless _tmp
- return _tmp
- end
-
- # Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
- def _Newline
- _tmp = scan(/\G(?-mix:\n|\r\n?|\p{Zl}|\p{Zp})/)
- set_failed_rule :_Newline unless _tmp
- return _tmp
- end
-
- # NonAlphanumeric = /\p{^Word}/
- def _NonAlphanumeric
- _tmp = scan(/\G(?-mix:\p{^Word})/)
- set_failed_rule :_NonAlphanumeric unless _tmp
- return _tmp
- end
-
- # Spacechar = /\t|\p{Zs}/
- def _Spacechar
- _tmp = scan(/\G(?-mix:\t|\p{Zs})/)
- set_failed_rule :_Spacechar unless _tmp
- return _tmp
- end
-
- Rules = {}
- Rules[:_Alphanumeric] = rule_info("Alphanumeric", "/\\p{Word}/")
- Rules[:_AlphanumericAscii] = rule_info("AlphanumericAscii", "/[A-Za-z0-9]/")
- Rules[:_BOM] = rule_info("BOM", "\"uFEFF\"")
- Rules[:_Newline] = rule_info("Newline", "/\\n|\\r\\n?|\\p{Zl}|\\p{Zp}/")
- Rules[:_NonAlphanumeric] = rule_info("NonAlphanumeric", "/\\p{^Word}/")
- Rules[:_Spacechar] = rule_info("Spacechar", "/\\t|\\p{Zs}/")
- # :startdoc:
-end
diff --git a/lib/rdoc/markup.rb b/lib/rdoc/markup.rb
deleted file mode 100644
index 6e93030965..0000000000
--- a/lib/rdoc/markup.rb
+++ /dev/null
@@ -1,235 +0,0 @@
-# frozen_string_literal: true
-##
-# RDoc::Markup parses plain text documents and attempts to decompose them into
-# their constituent parts. Some of these parts are high-level: paragraphs,
-# chunks of verbatim text, list entries and the like. Other parts happen at
-# the character level: a piece of bold text, a word in code font. This markup
-# is similar in spirit to that used on WikiWiki webs, where folks create web
-# pages using a simple set of formatting rules.
-#
-# RDoc::Markup and other markup formats do no output formatting, this is
-# handled by the RDoc::Markup::Formatter subclasses.
-#
-# = Supported Formats
-#
-# Besides the RDoc::Markup format, the following formats are built in to RDoc:
-#
-# markdown::
-# The markdown format as described by
-# http://daringfireball.net/projects/markdown/. See RDoc::Markdown for
-# details on the parser and supported extensions.
-# rd::
-# The rdtool format. See RDoc::RD for details on the parser and format.
-# tomdoc::
-# The TomDoc format as described by http://tomdoc.org/. See RDoc::TomDoc
-# for details on the parser and supported extensions.
-#
-# You can choose a markup format using the following methods:
-#
-# per project::
-# If you build your documentation with rake use RDoc::Task#markup.
-#
-# If you build your documentation by hand run:
-#
-# rdoc --markup your_favorite_format --write-options
-#
-# and commit <tt>.rdoc_options</tt> and ship it with your packaged gem.
-# per file::
-# At the top of the file use the <tt>:markup:</tt> directive to set the
-# default format for the rest of the file.
-# per comment::
-# Use the <tt>:markup:</tt> directive at the top of a comment you want
-# to write in a different format.
-#
-# = RDoc::Markup
-#
-# RDoc::Markup is extensible at runtime: you can add \new markup elements to
-# be recognized in the documents that RDoc::Markup parses.
-#
-# RDoc::Markup is intended to be the basis for a family of tools which share
-# the common requirement that simple, plain-text should be rendered in a
-# variety of different output formats and media. It is envisaged that
-# RDoc::Markup could be the basis for formatting RDoc style comment blocks,
-# Wiki entries, and online FAQs.
-#
-# == Synopsis
-#
-# This code converts +input_string+ to HTML. The conversion takes place in
-# the +convert+ method, so you can use the same RDoc::Markup converter to
-# convert multiple input strings.
-#
-# require 'rdoc'
-#
-# h = RDoc::Markup::ToHtml.new(RDoc::Options.new)
-#
-# puts h.convert(input_string)
-#
-# You can extend the RDoc::Markup parser to recognize new markup
-# sequences, and to add regexp handling. Here we make WikiWords significant to
-# the parser, and also make the sequences {word} and \<no>text...</no> signify
-# strike-through text. We then subclass the HTML output class to deal
-# with these:
-#
-# require 'rdoc'
-#
-# class WikiHtml < RDoc::Markup::ToHtml
-# def handle_regexp_WIKIWORD(target)
-# "<font color=red>" + target.text + "</font>"
-# end
-# end
-#
-# markup = RDoc::Markup.new
-# markup.add_word_pair("{", "}", :STRIKE)
-# markup.add_html("no", :STRIKE)
-#
-# markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
-#
-# wh = WikiHtml.new RDoc::Options.new, markup
-# wh.add_tag(:STRIKE, "<strike>", "</strike>")
-#
-# puts "<body>#{wh.convert ARGF.read}</body>"
-#
-# == Encoding
-#
-# Where Encoding support is available, RDoc will automatically convert all
-# documents to the same output encoding. The output encoding can be set via
-# RDoc::Options#encoding and defaults to Encoding.default_external.
-#
-# = \RDoc Markup Reference
-#
-# See RDoc::MarkupReference.
-#
-#--
-# Original Author:: Dave Thomas, dave@pragmaticprogrammer.com
-# License:: Ruby license
-
-class RDoc::Markup
-
- ##
- # An AttributeManager which handles inline markup.
-
- attr_reader :attribute_manager
-
- ##
- # Parses +str+ into an RDoc::Markup::Document.
-
- def self.parse str
- RDoc::Markup::Parser.parse str
- rescue RDoc::Markup::Parser::Error => e
- $stderr.puts <<-EOF
-While parsing markup, RDoc encountered a #{e.class}:
-
-#{e}
-\tfrom #{e.backtrace.join "\n\tfrom "}
-
----8<---
-#{text}
----8<---
-
-RDoc #{RDoc::VERSION}
-
-Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE}
-
-Please file a bug report with the above information at:
-
-https://github.com/ruby/rdoc/issues
-
- EOF
- raise
- end
-
- ##
- # Take a block of text and use various heuristics to determine its
- # structure (paragraphs, lists, and so on). Invoke an event handler as we
- # identify significant chunks.
-
- def initialize attribute_manager = nil
- @attribute_manager = attribute_manager || RDoc::Markup::AttributeManager.new
- @output = nil
- end
-
- ##
- # Add to the sequences used to add formatting to an individual word (such
- # as *bold*). Matching entries will generate attributes that the output
- # formatters can recognize by their +name+.
-
- def add_word_pair(start, stop, name)
- @attribute_manager.add_word_pair(start, stop, name)
- end
-
- ##
- # Add to the sequences recognized as general markup.
-
- def add_html(tag, name)
- @attribute_manager.add_html(tag, name)
- end
-
- ##
- # Add to other inline sequences. For example, we could add WikiWords using
- # something like:
- #
- # parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
- #
- # Each wiki word will be presented to the output formatter.
-
- def add_regexp_handling(pattern, name)
- @attribute_manager.add_regexp_handling(pattern, name)
- end
-
- ##
- # We take +input+, parse it if necessary, then invoke the output +formatter+
- # using a Visitor to render the result.
-
- def convert input, formatter
- document = case input
- when RDoc::Markup::Document then
- input
- else
- RDoc::Markup::Parser.parse input
- end
-
- document.accept formatter
- end
-
- autoload :Parser, "#{__dir__}/markup/parser"
- autoload :PreProcess, "#{__dir__}/markup/pre_process"
-
- # Inline markup classes
- autoload :AttrChanger, "#{__dir__}/markup/attr_changer"
- autoload :AttrSpan, "#{__dir__}/markup/attr_span"
- autoload :Attributes, "#{__dir__}/markup/attributes"
- autoload :AttributeManager, "#{__dir__}/markup/attribute_manager"
- autoload :RegexpHandling, "#{__dir__}/markup/regexp_handling"
-
- # RDoc::Markup AST
- autoload :BlankLine, "#{__dir__}/markup/blank_line"
- autoload :BlockQuote, "#{__dir__}/markup/block_quote"
- autoload :Document, "#{__dir__}/markup/document"
- autoload :HardBreak, "#{__dir__}/markup/hard_break"
- autoload :Heading, "#{__dir__}/markup/heading"
- autoload :Include, "#{__dir__}/markup/include"
- autoload :IndentedParagraph, "#{__dir__}/markup/indented_paragraph"
- autoload :List, "#{__dir__}/markup/list"
- autoload :ListItem, "#{__dir__}/markup/list_item"
- autoload :Paragraph, "#{__dir__}/markup/paragraph"
- autoload :Table, "#{__dir__}/markup/table"
- autoload :Raw, "#{__dir__}/markup/raw"
- autoload :Rule, "#{__dir__}/markup/rule"
- autoload :Verbatim, "#{__dir__}/markup/verbatim"
-
- # Formatters
- autoload :Formatter, "#{__dir__}/markup/formatter"
-
- autoload :ToAnsi, "#{__dir__}/markup/to_ansi"
- autoload :ToBs, "#{__dir__}/markup/to_bs"
- autoload :ToHtml, "#{__dir__}/markup/to_html"
- autoload :ToHtmlCrossref, "#{__dir__}/markup/to_html_crossref"
- autoload :ToHtmlSnippet, "#{__dir__}/markup/to_html_snippet"
- autoload :ToLabel, "#{__dir__}/markup/to_label"
- autoload :ToMarkdown, "#{__dir__}/markup/to_markdown"
- autoload :ToRdoc, "#{__dir__}/markup/to_rdoc"
- autoload :ToTableOfContents, "#{__dir__}/markup/to_table_of_contents"
- autoload :ToTest, "#{__dir__}/markup/to_test"
- autoload :ToTtOnly, "#{__dir__}/markup/to_tt_only"
-
-end
diff --git a/lib/rdoc/markup/attr_changer.rb b/lib/rdoc/markup/attr_changer.rb
deleted file mode 100644
index 4c4bc6479e..0000000000
--- a/lib/rdoc/markup/attr_changer.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-class RDoc::Markup
-
- AttrChanger = Struct.new :turn_on, :turn_off # :nodoc:
-
-end
-
-##
-# An AttrChanger records a change in attributes. It contains a bitmap of the
-# attributes to turn on, and a bitmap of those to turn off.
-
-class RDoc::Markup::AttrChanger
-
- def to_s # :nodoc:
- "Attr: +#{turn_on}/-#{turn_off}"
- end
-
- def inspect # :nodoc:
- '+%d/-%d' % [turn_on, turn_off]
- end
-
-end
-
diff --git a/lib/rdoc/markup/attr_span.rb b/lib/rdoc/markup/attr_span.rb
deleted file mode 100644
index 20ef11cd6d..0000000000
--- a/lib/rdoc/markup/attr_span.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-##
-# An array of attributes which parallels the characters in a string.
-
-class RDoc::Markup::AttrSpan
-
- ##
- # Creates a new AttrSpan for +length+ characters
-
- def initialize(length, exclusive)
- @attrs = Array.new(length, 0)
- @exclusive = exclusive
- end
-
- ##
- # Toggles +bits+ from +start+ to +length+
- def set_attrs(start, length, bits)
- updated = false
- for i in start ... (start+length)
- if (@exclusive & @attrs[i]) == 0 || (@exclusive & bits) != 0
- @attrs[i] |= bits
- updated = true
- end
- end
- updated
- end
-
- ##
- # Accesses flags for character +n+
-
- def [](n)
- @attrs[n]
- end
-
-end
-
diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb
deleted file mode 100644
index 601e6bc189..0000000000
--- a/lib/rdoc/markup/attribute_manager.rb
+++ /dev/null
@@ -1,403 +0,0 @@
-# frozen_string_literal: true
-##
-# Manages changes of attributes in a block of text
-
-unless MatchData.method_defined?(:match_length)
- using Module.new {
- refine(MatchData) {
- def match_length(nth)
- b, e = offset(nth)
- e - b if b
- end
- }
- }
-end
-
-class RDoc::Markup::AttributeManager
-
- ##
- # The NUL character
-
- NULL = "\000".freeze
-
- #--
- # We work by substituting non-printing characters in to the text. For now
- # I'm assuming that I can substitute a character in the range 0..8 for a 7
- # bit character without damaging the encoded string, but this might be
- # optimistic
- #++
-
- A_PROTECT = 004 # :nodoc:
-
- ##
- # Special mask character to prevent inline markup handling
-
- PROTECT_ATTR = A_PROTECT.chr # :nodoc:
-
- ##
- # The attributes enabled for this markup object.
-
- attr_reader :attributes
-
- ##
- # This maps delimiters that occur around words (such as *bold* or +tt+)
- # where the start and end delimiters and the same. This lets us optimize
- # the regexp
-
- attr_reader :matching_word_pairs
-
- ##
- # And this is used when the delimiters aren't the same. In this case the
- # hash maps a pattern to the attribute character
-
- attr_reader :word_pair_map
-
- ##
- # This maps HTML tags to the corresponding attribute char
-
- attr_reader :html_tags
-
- ##
- # A \ in front of a character that would normally be processed turns off
- # processing. We do this by turning \< into <#{PROTECT}
-
- attr_reader :protectable
-
- ##
- # And this maps _regexp handling_ sequences to a name. A regexp handling
- # sequence is something like a WikiWord
-
- attr_reader :regexp_handlings
-
- ##
- # A bits of exclusive maps
- attr_reader :exclusive_bitmap
-
- ##
- # Creates a new attribute manager that understands bold, emphasized and
- # teletype text.
-
- def initialize
- @html_tags = {}
- @matching_word_pairs = {}
- @protectable = %w[<]
- @regexp_handlings = []
- @word_pair_map = {}
- @exclusive_bitmap = 0
- @attributes = RDoc::Markup::Attributes.new
-
- add_word_pair "*", "*", :BOLD, true
- add_word_pair "_", "_", :EM, true
- add_word_pair "+", "+", :TT, true
-
- add_html "em", :EM, true
- add_html "i", :EM, true
- add_html "b", :BOLD, true
- add_html "tt", :TT, true
- add_html "code", :TT, true
- end
-
- ##
- # Return an attribute object with the given turn_on and turn_off bits set
-
- def attribute(turn_on, turn_off)
- RDoc::Markup::AttrChanger.new turn_on, turn_off
- end
-
- ##
- # Changes the current attribute from +current+ to +new+
-
- def change_attribute current, new
- diff = current ^ new
- attribute(new & diff, current & diff)
- end
-
- ##
- # Used by the tests to change attributes by name from +current_set+ to
- # +new_set+
-
- def changed_attribute_by_name current_set, new_set
- current = new = 0
- current_set.each do |name|
- current |= @attributes.bitmap_for(name)
- end
-
- new_set.each do |name|
- new |= @attributes.bitmap_for(name)
- end
-
- change_attribute(current, new)
- end
-
- ##
- # Copies +start_pos+ to +end_pos+ from the current string
-
- def copy_string(start_pos, end_pos)
- res = @str[start_pos...end_pos]
- res.gsub!(/\000/, '')
- res
- end
-
- def exclusive?(attr)
- (attr & @exclusive_bitmap) != 0
- end
-
- NON_PRINTING_START = "\1" # :nodoc:
- NON_PRINTING_END = "\2" # :nodoc:
-
- ##
- # Map attributes like <b>text</b>to the sequence
- # \001\002<char>\001\003<char>, where <char> is a per-attribute specific
- # character
-
- def convert_attrs(str, attrs, exclusive = false)
- convert_attrs_matching_word_pairs(str, attrs, exclusive)
- convert_attrs_word_pair_map(str, attrs, exclusive)
- end
-
- def convert_attrs_matching_word_pairs(str, attrs, exclusive)
- # first do matching ones
- tags = @matching_word_pairs.select { |start, bitmap|
- exclusive == exclusive?(bitmap)
- }.keys
- return if tags.empty?
- tags = "[#{tags.join("")}](?!#{PROTECT_ATTR})"
- all_tags = "[#{@matching_word_pairs.keys.join("")}](?!#{PROTECT_ATTR})"
-
- re = /(?:^|\W|#{all_tags})\K(#{tags})(\1*[#\\]?[\w:#{PROTECT_ATTR}.\/\[\]-]+?\S?)\1(?!\1)(?=#{all_tags}|\W|$)/
-
- 1 while str.gsub!(re) { |orig|
- a, w = (m = $~).values_at(1, 2)
- attr = @matching_word_pairs[a]
- if attrs.set_attrs(m.begin(2), w.length, attr)
- a = NULL * a.length
- else
- a = NON_PRINTING_START + a + NON_PRINTING_END
- end
- a + w + a
- }
- str.delete!(NON_PRINTING_START + NON_PRINTING_END)
- end
-
- def convert_attrs_word_pair_map(str, attrs, exclusive)
- # then non-matching
- unless @word_pair_map.empty? then
- @word_pair_map.each do |regexp, attr|
- next unless exclusive == exclusive?(attr)
- 1 while str.gsub!(regexp) { |orig|
- w = (m = ($~))[2]
- updated = attrs.set_attrs(m.begin(2), w.length, attr)
- if updated
- NULL * m.match_length(1) + w + NULL * m.match_length(3)
- else
- orig
- end
- }
- end
- end
- end
-
- ##
- # Converts HTML tags to RDoc attributes
-
- def convert_html(str, attrs, exclusive = false)
- tags = @html_tags.select { |start, bitmap|
- exclusive == exclusive?(bitmap)
- }.keys.join '|'
-
- 1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
- attr = @html_tags[$1.downcase]
- html_length = $~.match_length(1) + 2 # "<>".length
- seq = NULL * html_length
- attrs.set_attrs($~.begin(2), $~.match_length(2), attr)
- seq + $2 + seq + NULL
- }
- end
-
- ##
- # Converts regexp handling sequences to RDoc attributes
-
- def convert_regexp_handlings str, attrs, exclusive = false
- @regexp_handlings.each do |regexp, attribute|
- next unless exclusive == exclusive?(attribute)
- str.scan(regexp) do
- capture = $~.size == 1 ? 0 : 1
-
- s, e = $~.offset capture
-
- attrs.set_attrs s, e - s, attribute | @attributes.regexp_handling
- end
- end
- end
-
- ##
- # Escapes regexp handling sequences of text to prevent conversion to RDoc
-
- def mask_protected_sequences
- # protect __send__, __FILE__, etc.
- @str.gsub!(/__([a-z]+)__/i,
- "_#{PROTECT_ATTR}_#{PROTECT_ATTR}\\1_#{PROTECT_ATTR}_#{PROTECT_ATTR}")
- @str.gsub!(/(\A|[^\\])\\([#{Regexp.escape @protectable.join}])/m,
- "\\1\\2#{PROTECT_ATTR}")
- @str.gsub!(/\\(\\[#{Regexp.escape @protectable.join}])/m, "\\1")
- end
-
- ##
- # Unescapes regexp handling sequences of text
-
- def unmask_protected_sequences
- @str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
- end
-
- ##
- # Adds a markup class with +name+ for words wrapped in the +start+ and
- # +stop+ character. To make words wrapped with "*" bold:
- #
- # am.add_word_pair '*', '*', :BOLD
-
- def add_word_pair(start, stop, name, exclusive = false)
- raise ArgumentError, "Word flags may not start with '<'" if
- start[0,1] == '<'
-
- bitmap = @attributes.bitmap_for name
-
- if start == stop then
- @matching_word_pairs[start] = bitmap
- else
- pattern = /(#{Regexp.escape start})(\S+)(#{Regexp.escape stop})/
- @word_pair_map[pattern] = bitmap
- end
-
- @protectable << start[0,1]
- @protectable.uniq!
-
- @exclusive_bitmap |= bitmap if exclusive
- end
-
- ##
- # Adds a markup class with +name+ for words surrounded by HTML tag +tag+.
- # To process emphasis tags:
- #
- # am.add_html 'em', :EM
-
- def add_html(tag, name, exclusive = false)
- bitmap = @attributes.bitmap_for name
- @html_tags[tag.downcase] = bitmap
- @exclusive_bitmap |= bitmap if exclusive
- end
-
- ##
- # Adds a regexp handling for +pattern+ with +name+. A simple URL handler
- # would be:
- #
- # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
-
- def add_regexp_handling pattern, name, exclusive = false
- bitmap = @attributes.bitmap_for(name)
- @regexp_handlings << [pattern, bitmap]
- @exclusive_bitmap |= bitmap if exclusive
- end
-
- ##
- # Processes +str+ converting attributes, HTML and regexp handlings
-
- def flow str
- @str = str.dup
-
- mask_protected_sequences
-
- @attrs = RDoc::Markup::AttrSpan.new @str.length, @exclusive_bitmap
-
- convert_attrs @str, @attrs, true
- convert_html @str, @attrs, true
- convert_regexp_handlings @str, @attrs, true
- convert_attrs @str, @attrs
- convert_html @str, @attrs
- convert_regexp_handlings @str, @attrs
-
- unmask_protected_sequences
-
- split_into_flow
- end
-
- ##
- # Debug method that prints a string along with its attributes
-
- def display_attributes
- puts
- puts @str.tr(NULL, "!")
- bit = 1
- 16.times do |bno|
- line = ""
- @str.length.times do |i|
- if (@attrs[i] & bit) == 0
- line << " "
- else
- if bno.zero?
- line << "S"
- else
- line << ("%d" % (bno+1))
- end
- end
- end
- puts(line) unless line =~ /^ *$/
- bit <<= 1
- end
- end
-
- ##
- # Splits the string into chunks by attribute change
-
- def split_into_flow
- res = []
- current_attr = 0
-
- str_len = @str.length
-
- # skip leading invisible text
- i = 0
- i += 1 while i < str_len and @str[i].chr == "\0"
- start_pos = i
-
- # then scan the string, chunking it on attribute changes
- while i < str_len
- new_attr = @attrs[i]
- if new_attr != current_attr
- if i > start_pos
- res << copy_string(start_pos, i)
- start_pos = i
- end
-
- res << change_attribute(current_attr, new_attr)
- current_attr = new_attr
-
- if (current_attr & @attributes.regexp_handling) != 0 then
- i += 1 while
- i < str_len and (@attrs[i] & @attributes.regexp_handling) != 0
-
- res << RDoc::Markup::RegexpHandling.new(current_attr,
- copy_string(start_pos, i))
- start_pos = i
- next
- end
- end
-
- # move on, skipping any invisible characters
- begin
- i += 1
- end while i < str_len and @str[i].chr == "\0"
- end
-
- # tidy up trailing text
- if start_pos < str_len
- res << copy_string(start_pos, str_len)
- end
-
- # and reset to all attributes off
- res << change_attribute(current_attr, 0) if current_attr != 0
-
- res
- end
-
-end
-
diff --git a/lib/rdoc/markup/attributes.rb b/lib/rdoc/markup/attributes.rb
deleted file mode 100644
index ce014ce928..0000000000
--- a/lib/rdoc/markup/attributes.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: true
-##
-# We manage a set of attributes. Each attribute has a symbol name and a bit
-# value.
-
-class RDoc::Markup::Attributes
-
- ##
- # The regexp handling attribute type. See RDoc::Markup#add_regexp_handling
-
- attr_reader :regexp_handling
-
- ##
- # Creates a new attributes set.
-
- def initialize
- @regexp_handling = 1
-
- @name_to_bitmap = [
- [:_REGEXP_HANDLING_, @regexp_handling],
- ]
-
- @next_bitmap = @regexp_handling << 1
- end
-
- ##
- # Returns a unique bit for +name+
-
- def bitmap_for name
- bitmap = @name_to_bitmap.assoc name
-
- unless bitmap then
- bitmap = @next_bitmap
- @next_bitmap <<= 1
- @name_to_bitmap << [name, bitmap]
- else
- bitmap = bitmap.last
- end
-
- bitmap
- end
-
- ##
- # Returns a string representation of +bitmap+
-
- def as_string bitmap
- return 'none' if bitmap.zero?
- res = []
-
- @name_to_bitmap.each do |name, bit|
- res << name if (bitmap & bit) != 0
- end
-
- res.join ','
- end
-
- ##
- # yields each attribute name in +bitmap+
-
- def each_name_of bitmap
- return enum_for __method__, bitmap unless block_given?
-
- @name_to_bitmap.each do |name, bit|
- next if bit == @regexp_handling
-
- yield name.to_s if (bitmap & bit) != 0
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/blank_line.rb b/lib/rdoc/markup/blank_line.rb
deleted file mode 100644
index 3129ab5e7f..0000000000
--- a/lib/rdoc/markup/blank_line.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-##
-# An empty line. This class is a singleton.
-
-class RDoc::Markup::BlankLine
-
- @instance = new
-
- ##
- # RDoc::Markup::BlankLine is a singleton
-
- def self.new
- @instance
- end
-
- ##
- # Calls #accept_blank_line on +visitor+
-
- def accept visitor
- visitor.accept_blank_line self
- end
-
- def pretty_print q # :nodoc:
- q.text 'blankline'
- end
-
-end
-
diff --git a/lib/rdoc/markup/block_quote.rb b/lib/rdoc/markup/block_quote.rb
deleted file mode 100644
index 7a4b3e36b0..0000000000
--- a/lib/rdoc/markup/block_quote.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-##
-# A quoted section which contains markup items.
-
-class RDoc::Markup::BlockQuote < RDoc::Markup::Raw
-
- ##
- # Calls #accept_block_quote on +visitor+
-
- def accept visitor
- visitor.accept_block_quote self
- end
-
-end
-
diff --git a/lib/rdoc/markup/document.rb b/lib/rdoc/markup/document.rb
deleted file mode 100644
index f3a5de1fc3..0000000000
--- a/lib/rdoc/markup/document.rb
+++ /dev/null
@@ -1,165 +0,0 @@
-# frozen_string_literal: true
-##
-# A Document containing lists, headings, paragraphs, etc.
-
-class RDoc::Markup::Document
-
- include Enumerable
-
- ##
- # The file this document was created from. See also
- # RDoc::ClassModule#add_comment
-
- attr_reader :file
-
- ##
- # If a heading is below the given level it will be omitted from the
- # table_of_contents
-
- attr_accessor :omit_headings_below
-
- ##
- # The parts of the Document
-
- attr_reader :parts
-
- ##
- # Creates a new Document with +parts+
-
- def initialize *parts
- @parts = []
- @parts.concat parts
-
- @file = nil
- @omit_headings_from_table_of_contents_below = nil
- end
-
- ##
- # Appends +part+ to the document
-
- def << part
- case part
- when RDoc::Markup::Document then
- unless part.empty? then
- parts.concat part.parts
- parts << RDoc::Markup::BlankLine.new
- end
- when String then
- raise ArgumentError,
- "expected RDoc::Markup::Document and friends, got String" unless
- part.empty?
- else
- parts << part
- end
- end
-
- def == other # :nodoc:
- self.class == other.class and
- @file == other.file and
- @parts == other.parts
- end
-
- ##
- # Runs this document and all its #items through +visitor+
-
- def accept visitor
- visitor.start_accepting
-
- visitor.accept_document self
-
- visitor.end_accepting
- end
-
- ##
- # Concatenates the given +parts+ onto the document
-
- def concat parts
- self.parts.concat parts
- end
-
- ##
- # Enumerator for the parts of this document
-
- def each &block
- @parts.each(&block)
- end
-
- ##
- # Does this document have no parts?
-
- def empty?
- @parts.empty? or (@parts.length == 1 and merged? and @parts.first.empty?)
- end
-
- ##
- # The file this Document was created from.
-
- def file= location
- @file = case location
- when RDoc::TopLevel then
- location.relative_name
- else
- location
- end
- end
-
- ##
- # When this is a collection of documents (#file is not set and this document
- # contains only other documents as its direct children) #merge replaces
- # documents in this class with documents from +other+ when the file matches
- # and adds documents from +other+ when the files do not.
- #
- # The information in +other+ is preferred over the receiver
-
- def merge other
- if empty? then
- @parts = other.parts
- return self
- end
-
- other.parts.each do |other_part|
- self.parts.delete_if do |self_part|
- self_part.file and self_part.file == other_part.file
- end
-
- self.parts << other_part
- end
-
- self
- end
-
- ##
- # Does this Document contain other Documents?
-
- def merged?
- RDoc::Markup::Document === @parts.first
- end
-
- def pretty_print q # :nodoc:
- start = @file ? "[doc (#{@file}): " : '[doc: '
-
- q.group 2, start, ']' do
- q.seplist @parts do |part|
- q.pp part
- end
- end
- end
-
- ##
- # Appends +parts+ to the document
-
- def push *parts
- self.parts.concat parts
- end
-
- ##
- # Returns an Array of headings in the document.
- #
- # Require 'rdoc/markup/formatter' before calling this method.
-
- def table_of_contents
- accept RDoc::Markup::ToTableOfContents.to_toc
- end
-
-end
-
diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb
deleted file mode 100644
index 2bac76e838..0000000000
--- a/lib/rdoc/markup/formatter.rb
+++ /dev/null
@@ -1,266 +0,0 @@
-# frozen_string_literal: true
-##
-# Base class for RDoc markup formatters
-#
-# Formatters are a visitor that converts an RDoc::Markup tree (from a comment)
-# into some kind of output. RDoc ships with formatters for converting back to
-# rdoc, ANSI text, HTML, a Table of Contents and other formats.
-#
-# If you'd like to write your own Formatter use
-# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
-# use RDoc::Markup::TextFormatterTestCase which provides extra test cases.
-
-class RDoc::Markup::Formatter
-
- ##
- # Tag for inline markup containing a +bit+ for the bitmask and the +on+ and
- # +off+ triggers.
-
- InlineTag = Struct.new(:bit, :on, :off)
-
- ##
- # Converts a target url to one that is relative to a given path
-
- def self.gen_relative_url path, target
- from = File.dirname path
- to, to_file = File.split target
-
- from = from.split "/"
- to = to.split "/"
-
- from.delete '.'
- to.delete '.'
-
- while from.size > 0 and to.size > 0 and from[0] == to[0] do
- from.shift
- to.shift
- end
-
- from.fill ".."
- from.concat to
- from << to_file
- File.join(*from)
- end
-
- ##
- # Creates a new Formatter
-
- def initialize options, markup = nil
- @options = options
-
- @markup = markup || RDoc::Markup.new
- @am = @markup.attribute_manager
- @am.add_regexp_handling(/<br>/, :HARD_BREAK)
-
- @attributes = @am.attributes
-
- @attr_tags = []
-
- @in_tt = 0
- @tt_bit = @attributes.bitmap_for :TT
-
- @hard_break = ''
- @from_path = '.'
- end
-
- ##
- # Adds +document+ to the output
-
- def accept_document document
- document.parts.each do |item|
- case item
- when RDoc::Markup::Document then # HACK
- accept_document item
- else
- item.accept self
- end
- end
- end
-
- ##
- # Adds a regexp handling for links of the form rdoc-...:
-
- def add_regexp_handling_RDOCLINK
- @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
- end
-
- ##
- # Adds a regexp handling for links of the form {<text>}[<url>] and
- # <word>[<url>]
-
- def add_regexp_handling_TIDYLINK
- @markup.add_regexp_handling(/(?:
- \{.*?\} | # multi-word label
- \b[^\s{}]+? # single-word label
- )
-
- \[\S+?\] # link target
- /x, :TIDYLINK)
- end
-
- ##
- # Add a new set of tags for an attribute. We allow separate start and end
- # tags for flexibility
-
- def add_tag(name, start, stop)
- attr = @attributes.bitmap_for name
- @attr_tags << InlineTag.new(attr, start, stop)
- end
-
- ##
- # Allows +tag+ to be decorated with additional information.
-
- def annotate(tag)
- tag
- end
-
- ##
- # Marks up +content+
-
- def convert content
- @markup.convert content, self
- end
-
- ##
- # Converts flow items +flow+
-
- def convert_flow(flow)
- res = []
-
- flow.each do |item|
- case item
- when String then
- res << convert_string(item)
- when RDoc::Markup::AttrChanger then
- off_tags res, item
- on_tags res, item
- when RDoc::Markup::RegexpHandling then
- res << convert_regexp_handling(item)
- else
- raise "Unknown flow element: #{item.inspect}"
- end
- end
-
- res.join
- end
-
- ##
- # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
-
- def convert_regexp_handling target
- return target.text if in_tt?
-
- handled = false
-
- @attributes.each_name_of target.type do |name|
- method_name = "handle_regexp_#{name}"
-
- if respond_to? method_name then
- target.text = public_send method_name, target
- handled = true
- end
- end
-
- unless handled then
- target_name = @attributes.as_string target.type
-
- raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
- end
-
- target.text
- end
-
- ##
- # Converts a string to be fancier if desired
-
- def convert_string string
- string
- end
-
- ##
- # Use ignore in your subclass to ignore the content of a node.
- #
- # ##
- # # We don't support raw nodes in ToNoRaw
- #
- # alias accept_raw ignore
-
- def ignore *node
- end
-
- ##
- # Are we currently inside tt tags?
-
- def in_tt?
- @in_tt > 0
- end
-
- ##
- # Turns on tags for +item+ on +res+
-
- def on_tags res, item
- attr_mask = item.turn_on
- return if attr_mask.zero?
-
- @attr_tags.each do |tag|
- if attr_mask & tag.bit != 0 then
- res << annotate(tag.on)
- @in_tt += 1 if tt? tag
- end
- end
- end
-
- ##
- # Turns off tags for +item+ on +res+
-
- def off_tags res, item
- attr_mask = item.turn_off
- return if attr_mask.zero?
-
- @attr_tags.reverse_each do |tag|
- if attr_mask & tag.bit != 0 then
- @in_tt -= 1 if tt? tag
- res << annotate(tag.off)
- end
- end
- end
-
- ##
- # Extracts and a scheme, url and an anchor id from +url+ and returns them.
-
- def parse_url url
- case url
- when /^rdoc-label:([^:]*)(?::(.*))?/ then
- scheme = 'link'
- path = "##{$1}"
- id = " id=\"#{$2}\"" if $2
- when /([A-Za-z]+):(.*)/ then
- scheme = $1.downcase
- path = $2
- when /^#/ then
- else
- scheme = 'http'
- path = url
- url = url
- end
-
- if scheme == 'link' then
- url = if path[0, 1] == '#' then # is this meaningful?
- path
- else
- self.class.gen_relative_url @from_path, path
- end
- end
-
- [scheme, url, id]
- end
-
- ##
- # Is +tag+ a tt tag?
-
- def tt? tag
- tag.bit == @tt_bit
- end
-
-end
-
diff --git a/lib/rdoc/markup/hard_break.rb b/lib/rdoc/markup/hard_break.rb
deleted file mode 100644
index 046068d5c2..0000000000
--- a/lib/rdoc/markup/hard_break.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-##
-# A hard-break in the middle of a paragraph.
-
-class RDoc::Markup::HardBreak
-
- @instance = new
-
- ##
- # RDoc::Markup::HardBreak is a singleton
-
- def self.new
- @instance
- end
-
- ##
- # Calls #accept_hard_break on +visitor+
-
- def accept visitor
- visitor.accept_hard_break self
- end
-
- def == other # :nodoc:
- self.class === other
- end
-
- def pretty_print q # :nodoc:
- q.text "[break]"
- end
-
-end
-
diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb
deleted file mode 100644
index 93a3a52000..0000000000
--- a/lib/rdoc/markup/heading.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-# frozen_string_literal: true
-##
-# A heading with a level (1-6) and text
-
-RDoc::Markup::Heading =
- Struct.new :level, :text do
-
- @to_html = nil
- @to_label = nil
-
- ##
- # A singleton RDoc::Markup::ToLabel formatter for headings.
-
- def self.to_label
- @to_label ||= RDoc::Markup::ToLabel.new
- end
-
- ##
- # A singleton plain HTML formatter for headings. Used for creating labels
- # for the Table of Contents
-
- def self.to_html
- return @to_html if @to_html
-
- markup = RDoc::Markup.new
- markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
-
- @to_html = RDoc::Markup::ToHtml.new nil
-
- def @to_html.handle_regexp_CROSSREF target
- target.text.sub(/^\\/, '')
- end
-
- @to_html
- end
-
- ##
- # Calls #accept_heading on +visitor+
-
- def accept visitor
- visitor.accept_heading self
- end
-
- ##
- # An HTML-safe anchor reference for this header.
-
- def aref
- "label-#{self.class.to_label.convert text.dup}"
- end
-
- ##
- # Creates a fully-qualified label which will include the label from
- # +context+. This helps keep ids unique in HTML.
-
- def label context = nil
- label = aref
-
- label = [context.aref, label].compact.join '-' if
- context and context.respond_to? :aref
-
- label
- end
-
- ##
- # HTML markup of the text of this label without the surrounding header
- # element.
-
- def plain_html
- self.class.to_html.to_html(text.dup)
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[head: #{level} ", ']' do
- q.pp text
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/include.rb b/lib/rdoc/markup/include.rb
deleted file mode 100644
index ad7c4a9640..0000000000
--- a/lib/rdoc/markup/include.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-##
-# A file included at generation time. Objects of this class are created by
-# RDoc::RD for an extension-less include.
-#
-# This implementation in incomplete.
-
-class RDoc::Markup::Include
-
- ##
- # The filename to be included, without extension
-
- attr_reader :file
-
- ##
- # Directories to search for #file
-
- attr_reader :include_path
-
- ##
- # Creates a new include that will import +file+ from +include_path+
-
- def initialize file, include_path
- @file = file
- @include_path = include_path
- end
-
- def == other # :nodoc:
- self.class === other and
- @file == other.file and @include_path == other.include_path
- end
-
- def pretty_print q # :nodoc:
- q.group 2, '[incl ', ']' do
- q.text file
- q.breakable
- q.text 'from '
- q.pp include_path
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/indented_paragraph.rb b/lib/rdoc/markup/indented_paragraph.rb
deleted file mode 100644
index d42b2e52b8..0000000000
--- a/lib/rdoc/markup/indented_paragraph.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-##
-# An Indented Paragraph of text
-
-class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
-
- ##
- # The indent in number of spaces
-
- attr_reader :indent
-
- ##
- # Creates a new IndentedParagraph containing +parts+ indented with +indent+
- # spaces
-
- def initialize indent, *parts
- @indent = indent
-
- super(*parts)
- end
-
- def == other # :nodoc:
- super and indent == other.indent
- end
-
- ##
- # Calls #accept_indented_paragraph on +visitor+
-
- def accept visitor
- visitor.accept_indented_paragraph self
- end
-
- ##
- # Joins the raw paragraph text and converts inline HardBreaks to the
- # +hard_break+ text followed by the indent.
-
- def text hard_break = nil
- @parts.map do |part|
- if RDoc::Markup::HardBreak === part then
- '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
- else
- part
- end
- end.join
- end
-
-end
-
diff --git a/lib/rdoc/markup/list.rb b/lib/rdoc/markup/list.rb
deleted file mode 100644
index 05c3609202..0000000000
--- a/lib/rdoc/markup/list.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# frozen_string_literal: true
-##
-# A List is a homogeneous set of ListItems.
-#
-# The supported list types include:
-#
-# :BULLET::
-# An unordered list
-# :LABEL::
-# An unordered definition list, but using an alternate RDoc::Markup syntax
-# :LALPHA::
-# An ordered list using increasing lowercase English letters
-# :NOTE::
-# An unordered definition list
-# :NUMBER::
-# An ordered list using increasing Arabic numerals
-# :UALPHA::
-# An ordered list using increasing uppercase English letters
-#
-# Definition lists behave like HTML definition lists. Each list item can
-# describe multiple terms. See RDoc::Markup::ListItem for how labels and
-# definition are stored as list items.
-
-class RDoc::Markup::List
-
- ##
- # The list's type
-
- attr_accessor :type
-
- ##
- # Items in the list
-
- attr_reader :items
-
- ##
- # Creates a new list of +type+ with +items+. Valid list types are:
- # +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+
-
- def initialize type = nil, *items
- @type = type
- @items = []
- @items.concat items
- end
-
- ##
- # Appends +item+ to the list
-
- def << item
- @items << item
- end
-
- def == other # :nodoc:
- self.class == other.class and
- @type == other.type and
- @items == other.items
- end
-
- ##
- # Runs this list and all its #items through +visitor+
-
- def accept visitor
- visitor.accept_list_start self
-
- @items.each do |item|
- item.accept visitor
- end
-
- visitor.accept_list_end self
- end
-
- ##
- # Is the list empty?
-
- def empty?
- @items.empty?
- end
-
- ##
- # Returns the last item in the list
-
- def last
- @items.last
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[list: #{@type} ", ']' do
- q.seplist @items do |item|
- q.pp item
- end
- end
- end
-
- ##
- # Appends +items+ to the list
-
- def push *items
- @items.concat items
- end
-
-end
-
diff --git a/lib/rdoc/markup/list_item.rb b/lib/rdoc/markup/list_item.rb
deleted file mode 100644
index d22554ee73..0000000000
--- a/lib/rdoc/markup/list_item.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# frozen_string_literal: true
-##
-# An item within a List that contains paragraphs, headings, etc.
-#
-# For BULLET, NUMBER, LALPHA and UALPHA lists, the label will always be nil.
-# For NOTE and LABEL lists, the list label may contain:
-#
-# * a single String for a single label
-# * an Array of Strings for a list item with multiple terms
-# * nil for an extra description attached to a previously labeled list item
-
-class RDoc::Markup::ListItem
-
- ##
- # The label for the ListItem
-
- attr_accessor :label
-
- ##
- # Parts of the ListItem
-
- attr_reader :parts
-
- ##
- # Creates a new ListItem with an optional +label+ containing +parts+
-
- def initialize label = nil, *parts
- @label = label
- @parts = []
- @parts.concat parts
- end
-
- ##
- # Appends +part+ to the ListItem
-
- def << part
- @parts << part
- end
-
- def == other # :nodoc:
- self.class == other.class and
- @label == other.label and
- @parts == other.parts
- end
-
- ##
- # Runs this list item and all its #parts through +visitor+
-
- def accept visitor
- visitor.accept_list_item_start self
-
- @parts.each do |part|
- part.accept visitor
- end
-
- visitor.accept_list_item_end self
- end
-
- ##
- # Is the ListItem empty?
-
- def empty?
- @parts.empty?
- end
-
- ##
- # Length of parts in the ListItem
-
- def length
- @parts.length
- end
-
- def pretty_print q # :nodoc:
- q.group 2, '[item: ', ']' do
- case @label
- when Array then
- q.pp @label
- q.text ';'
- q.breakable
- when String then
- q.pp @label
- q.text ';'
- q.breakable
- end
-
- q.seplist @parts do |part|
- q.pp part
- end
- end
- end
-
- ##
- # Adds +parts+ to the ListItem
-
- def push *parts
- @parts.concat parts
- end
-
-end
-
diff --git a/lib/rdoc/markup/paragraph.rb b/lib/rdoc/markup/paragraph.rb
deleted file mode 100644
index a2e45ef009..0000000000
--- a/lib/rdoc/markup/paragraph.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-##
-# A Paragraph of text
-
-class RDoc::Markup::Paragraph < RDoc::Markup::Raw
-
- ##
- # Calls #accept_paragraph on +visitor+
-
- def accept visitor
- visitor.accept_paragraph self
- end
-
- ##
- # Joins the raw paragraph text and converts inline HardBreaks to the
- # +hard_break+ text.
-
- def text hard_break = ''
- @parts.map do |part|
- if RDoc::Markup::HardBreak === part then
- hard_break
- else
- part
- end
- end.join
- end
-
-end
-
diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb
deleted file mode 100644
index 0029df7e65..0000000000
--- a/lib/rdoc/markup/parser.rb
+++ /dev/null
@@ -1,581 +0,0 @@
-# frozen_string_literal: true
-require 'strscan'
-
-##
-# A recursive-descent parser for RDoc markup.
-#
-# The parser tokenizes an input string then parses the tokens into a Document.
-# Documents can be converted into output formats by writing a visitor like
-# RDoc::Markup::ToHTML.
-#
-# The parser only handles the block-level constructs Paragraph, List,
-# ListItem, Heading, Verbatim, BlankLine, Rule and BlockQuote.
-# Inline markup such as <tt>\+blah\+</tt> is handled separately by
-# RDoc::Markup::AttributeManager.
-#
-# To see what markup the Parser implements read RDoc. To see how to use
-# RDoc markup to format text in your program read RDoc::Markup.
-
-class RDoc::Markup::Parser
-
- include RDoc::Text
-
- ##
- # List token types
-
- LIST_TOKENS = [
- :BULLET,
- :LABEL,
- :LALPHA,
- :NOTE,
- :NUMBER,
- :UALPHA,
- ]
-
- ##
- # Parser error subclass
-
- class Error < RuntimeError; end
-
- ##
- # Raised when the parser is unable to handle the given markup
-
- class ParseError < Error; end
-
- ##
- # Enables display of debugging information
-
- attr_accessor :debug
-
- ##
- # Token accessor
-
- attr_reader :tokens
-
- ##
- # Parses +str+ into a Document.
- #
- # Use RDoc::Markup#parse instead of this method.
-
- def self.parse str
- parser = new
- parser.tokenize str
- doc = RDoc::Markup::Document.new
- parser.parse doc
- end
-
- ##
- # Returns a token stream for +str+, for testing
-
- def self.tokenize str
- parser = new
- parser.tokenize str
- parser.tokens
- end
-
- ##
- # Creates a new Parser. See also ::parse
-
- def initialize
- @binary_input = nil
- @current_token = nil
- @debug = false
- @s = nil
- @tokens = []
- end
-
- ##
- # Builds a Heading of +level+
-
- def build_heading level
- type, text, = get
-
- text = case type
- when :TEXT then
- skip :NEWLINE
- text
- else
- unget
- ''
- end
-
- RDoc::Markup::Heading.new level, text
- end
-
- ##
- # Builds a List flush to +margin+
-
- def build_list margin
- p :list_start => margin if @debug
-
- list = RDoc::Markup::List.new
- label = nil
-
- until @tokens.empty? do
- type, data, column, = get
-
- case type
- when *LIST_TOKENS then
- if column < margin || (list.type && list.type != type) then
- unget
- break
- end
-
- list.type = type
- peek_type, _, column, = peek_token
-
- case type
- when :NOTE, :LABEL then
- label = [] unless label
-
- if peek_type == :NEWLINE then
- # description not on the same line as LABEL/NOTE
- # skip the trailing newline & any blank lines below
- while peek_type == :NEWLINE
- get
- peek_type, _, column, = peek_token
- end
-
- # we may be:
- # - at end of stream
- # - at a column < margin:
- # [text]
- # blah blah blah
- # - at the same column, but with a different type of list item
- # [text]
- # * blah blah
- # - at the same column, with the same type of list item
- # [one]
- # [two]
- # In all cases, we have an empty description.
- # In the last case only, we continue.
- if peek_type.nil? || column < margin then
- empty = true
- elsif column == margin then
- case peek_type
- when type
- empty = :continue
- when *LIST_TOKENS
- empty = true
- else
- empty = false
- end
- else
- empty = false
- end
-
- if empty then
- label << data
- next if empty == :continue
- break
- end
- end
- else
- data = nil
- end
-
- if label then
- data = label << data
- label = nil
- end
-
- list_item = RDoc::Markup::ListItem.new data
- parse list_item, column
- list << list_item
-
- else
- unget
- break
- end
- end
-
- p :list_end => margin if @debug
-
- if list.empty? then
- return nil unless label
- return nil unless [:LABEL, :NOTE].include? list.type
-
- list_item = RDoc::Markup::ListItem.new label, RDoc::Markup::BlankLine.new
- list << list_item
- end
-
- list
- end
-
- ##
- # Builds a Paragraph that is flush to +margin+
-
- def build_paragraph margin
- p :paragraph_start => margin if @debug
-
- paragraph = RDoc::Markup::Paragraph.new
-
- until @tokens.empty? do
- type, data, column, = get
-
- if type == :TEXT and column == margin then
- paragraph << data
-
- break if peek_token.first == :BREAK
-
- data << ' ' if skip :NEWLINE
- else
- unget
- break
- end
- end
-
- paragraph.parts.last.sub!(/ \z/, '') # cleanup
-
- p :paragraph_end => margin if @debug
-
- paragraph
- end
-
- ##
- # Builds a Verbatim that is indented from +margin+.
- #
- # The verbatim block is shifted left (the least indented lines start in
- # column 0). Each part of the verbatim is one line of text, always
- # terminated by a newline. Blank lines always consist of a single newline
- # character, and there is never a single newline at the end of the verbatim.
-
- def build_verbatim margin
- p :verbatim_begin => margin if @debug
- verbatim = RDoc::Markup::Verbatim.new
-
- min_indent = nil
- generate_leading_spaces = true
- line = ''.dup
-
- until @tokens.empty? do
- type, data, column, = get
-
- if type == :NEWLINE then
- line << data
- verbatim << line
- line = ''.dup
- generate_leading_spaces = true
- next
- end
-
- if column <= margin
- unget
- break
- end
-
- if generate_leading_spaces then
- indent = column - margin
- line << ' ' * indent
- min_indent = indent if min_indent.nil? || indent < min_indent
- generate_leading_spaces = false
- end
-
- case type
- when :HEADER then
- line << '=' * data
- _, _, peek_column, = peek_token
- peek_column ||= column + data
- indent = peek_column - column - data
- line << ' ' * indent
- when :RULE then
- width = 2 + data
- line << '-' * width
- _, _, peek_column, = peek_token
- peek_column ||= column + width
- indent = peek_column - column - width
- line << ' ' * indent
- when :BREAK, :TEXT then
- line << data
- when :BLOCKQUOTE then
- line << '>>>'
- peek_type, _, peek_column = peek_token
- if peek_type != :NEWLINE and peek_column
- line << ' ' * (peek_column - column - 3)
- end
- else # *LIST_TOKENS
- list_marker = case type
- when :BULLET then data
- when :LABEL then "[#{data}]"
- when :NOTE then "#{data}::"
- else # :LALPHA, :NUMBER, :UALPHA
- "#{data}."
- end
- line << list_marker
- peek_type, _, peek_column = peek_token
- unless peek_type == :NEWLINE then
- peek_column ||= column + list_marker.length
- indent = peek_column - column - list_marker.length
- line << ' ' * indent
- end
- end
-
- end
-
- verbatim << line << "\n" unless line.empty?
- verbatim.parts.each { |p| p.slice!(0, min_indent) unless p == "\n" } if min_indent > 0
- verbatim.normalize
-
- p :verbatim_end => margin if @debug
-
- verbatim
- end
-
- ##
- # Pulls the next token from the stream.
-
- def get
- @current_token = @tokens.shift
- p :get => @current_token if @debug
- @current_token
- end
-
- ##
- # Parses the tokens into an array of RDoc::Markup::XXX objects,
- # and appends them to the passed +parent+ RDoc::Markup::YYY object.
- #
- # Exits at the end of the token stream, or when it encounters a token
- # in a column less than +indent+ (unless it is a NEWLINE).
- #
- # Returns +parent+.
-
- def parse parent, indent = 0
- p :parse_start => indent if @debug
-
- until @tokens.empty? do
- type, data, column, = get
-
- case type
- when :BREAK then
- parent << RDoc::Markup::BlankLine.new
- skip :NEWLINE, false
- next
- when :NEWLINE then
- # trailing newlines are skipped below, so this is a blank line
- parent << RDoc::Markup::BlankLine.new
- skip :NEWLINE, false
- next
- end
-
- # indentation change: break or verbatim
- if column < indent then
- unget
- break
- elsif column > indent then
- unget
- parent << build_verbatim(indent)
- next
- end
-
- # indentation is the same
- case type
- when :HEADER then
- parent << build_heading(data)
- when :RULE then
- parent << RDoc::Markup::Rule.new(data)
- skip :NEWLINE
- when :TEXT then
- unget
- parse_text parent, indent
- when :BLOCKQUOTE then
- nil while (type, = get; type) and type != :NEWLINE
- _, _, column, = peek_token
- bq = RDoc::Markup::BlockQuote.new
- p :blockquote_start => [data, column] if @debug
- parse bq, column
- p :blockquote_end => indent if @debug
- parent << bq
- when *LIST_TOKENS then
- unget
- parent << build_list(indent)
- else
- type, data, column, line = @current_token
- raise ParseError, "Unhandled token #{type} (#{data.inspect}) at #{line}:#{column}"
- end
- end
-
- p :parse_end => indent if @debug
-
- parent
-
- end
-
- ##
- # Small hook that is overridden by RDoc::TomDoc
-
- def parse_text parent, indent # :nodoc:
- parent << build_paragraph(indent)
- end
-
- ##
- # Returns the next token on the stream without modifying the stream
-
- def peek_token
- token = @tokens.first || []
- p :peek => token if @debug
- token
- end
-
- ##
- # A simple wrapper of StringScanner that is aware of the current column and lineno
-
- class MyStringScanner
- def initialize(input)
- @line = @column = 0
- @s = StringScanner.new input
- end
-
- def scan(re)
- ret = @s.scan(re)
- @column += ret.length if ret
- ret
- end
-
- def unscan(s)
- @s.pos -= s.bytesize
- @column -= s.length
- end
-
- def pos
- [@column, @line]
- end
-
- def newline!
- @column = 0
- @line += 1
- end
-
- def eos?
- @s.eos?
- end
-
- def matched
- @s.matched
- end
-
- def [](i)
- @s[i]
- end
- end
-
- ##
- # Creates the StringScanner
-
- def setup_scanner input
- @s = MyStringScanner.new input
- end
-
- ##
- # Skips the next token if its type is +token_type+.
- #
- # Optionally raises an error if the next token is not of the expected type.
-
- def skip token_type, error = true
- type, = get
- return unless type # end of stream
- return @current_token if token_type == type
- unget
- raise ParseError, "expected #{token_type} got #{@current_token.inspect}" if error
- end
-
- ##
- # Turns text +input+ into a stream of tokens
-
- def tokenize input
- setup_scanner input
-
- until @s.eos? do
- pos = @s.pos
-
- # leading spaces will be reflected by the column of the next token
- # the only thing we loose are trailing spaces at the end of the file
- next if @s.scan(/ +/)
-
- # note: after BULLET, LABEL, etc.,
- # indent will be the column of the next non-newline token
-
- @tokens << case
- # [CR]LF => :NEWLINE
- when @s.scan(/\r?\n/) then
- token = [:NEWLINE, @s.matched, *pos]
- @s.newline!
- token
- # === text => :HEADER then :TEXT
- when @s.scan(/(=+)(\s*)/) then
- level = @s[1].length
- header = [:HEADER, level, *pos]
-
- if @s[2] =~ /^\r?\n/ then
- @s.unscan(@s[2])
- header
- else
- pos = @s.pos
- @s.scan(/.*/)
- @tokens << header
- [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
- end
- # --- (at least 3) and nothing else on the line => :RULE
- when @s.scan(/(-{3,}) *\r?$/) then
- [:RULE, @s[1].length - 2, *pos]
- # * or - followed by white space and text => :BULLET
- when @s.scan(/([*-]) +(\S)/) then
- @s.unscan(@s[2])
- [:BULLET, @s[1], *pos]
- # A. text, a. text, 12. text => :UALPHA, :LALPHA, :NUMBER
- when @s.scan(/([a-z]|\d+)\. +(\S)/i) then
- # FIXME if tab(s), the column will be wrong
- # either support tabs everywhere by first expanding them to
- # spaces, or assume that they will have been replaced
- # before (and provide a check for that at least in debug
- # mode)
- list_label = @s[1]
- @s.unscan(@s[2])
- list_type =
- case list_label
- when /[a-z]/ then :LALPHA
- when /[A-Z]/ then :UALPHA
- when /\d/ then :NUMBER
- else
- raise ParseError, "BUG token #{list_label}"
- end
- [list_type, list_label, *pos]
- # [text] followed by spaces or end of line => :LABEL
- when @s.scan(/\[(.*?)\]( +|\r?$)/) then
- [:LABEL, @s[1], *pos]
- # text:: followed by spaces or end of line => :NOTE
- when @s.scan(/(.*?)::( +|\r?$)/) then
- [:NOTE, @s[1], *pos]
- # >>> followed by end of line => :BLOCKQUOTE
- when @s.scan(/>>> *(\w+)?$/) then
- if word = @s[1]
- @s.unscan(word)
- end
- [:BLOCKQUOTE, word, *pos]
- # anything else: :TEXT
- else
- @s.scan(/(.*?)( )?\r?$/)
- token = [:TEXT, @s[1], *pos]
-
- if @s[2] then
- @tokens << token
- [:BREAK, @s[2], pos[0] + @s[1].length, pos[1]]
- else
- token
- end
- end
- end
-
- self
- end
-
- ##
- # Returns the current token to the token stream
-
- def unget
- token = @current_token
- p :unget => token if @debug
- raise Error, 'too many #ungets' if token == @tokens.first
- @tokens.unshift token if token
- end
-
-end
diff --git a/lib/rdoc/markup/pre_process.rb b/lib/rdoc/markup/pre_process.rb
deleted file mode 100644
index 88078c9cef..0000000000
--- a/lib/rdoc/markup/pre_process.rb
+++ /dev/null
@@ -1,298 +0,0 @@
-# frozen_string_literal: true
-##
-# Handle common directives that can occur in a block of text:
-#
-# \:include: filename
-#
-# Directives can be escaped by preceding them with a backslash.
-#
-# RDoc plugin authors can register additional directives to be handled by
-# using RDoc::Markup::PreProcess::register.
-#
-# Any directive that is not built-in to RDoc (including those registered via
-# plugins) will be stored in the metadata hash on the CodeObject the comment
-# is attached to. See RDoc::Markup@Directives for the list of built-in
-# directives.
-
-class RDoc::Markup::PreProcess
-
- ##
- # An RDoc::Options instance that will be filled in with overrides from
- # directives
-
- attr_accessor :options
-
- ##
- # Adds a post-process handler for directives. The handler will be called
- # with the result RDoc::Comment (or text String) and the code object for the
- # comment (if any).
-
- def self.post_process &block
- @post_processors << block
- end
-
- ##
- # Registered post-processors
-
- def self.post_processors
- @post_processors
- end
-
- ##
- # Registers +directive+ as one handled by RDoc. If a block is given the
- # directive will be replaced by the result of the block, otherwise the
- # directive will be removed from the processed text.
- #
- # The block will be called with the directive name and the directive
- # parameter:
- #
- # RDoc::Markup::PreProcess.register 'my-directive' do |directive, param|
- # # replace text, etc.
- # end
-
- def self.register directive, &block
- @registered[directive] = block
- end
-
- ##
- # Registered directives
-
- def self.registered
- @registered
- end
-
- ##
- # Clears all registered directives and post-processors
-
- def self.reset
- @post_processors = []
- @registered = {}
- end
-
- reset
-
- ##
- # Creates a new pre-processor for +input_file_name+ that will look for
- # included files in +include_path+
-
- def initialize(input_file_name, include_path)
- @input_file_name = input_file_name
- @include_path = include_path
- @options = nil
- end
-
- ##
- # Look for directives in the given +text+.
- #
- # Options that we don't handle are yielded. If the block returns false the
- # directive is restored to the text. If the block returns nil or no block
- # was given the directive is handled according to the registered directives.
- # If a String was returned the directive is replaced with the string.
- #
- # If no matching directive was registered the directive is restored to the
- # text.
- #
- # If +code_object+ is given and the directive is unknown then the
- # directive's parameter is set as metadata on the +code_object+. See
- # RDoc::CodeObject#metadata for details.
-
- def handle text, code_object = nil, &block
- if RDoc::Comment === text then
- comment = text
- text = text.text
- end
-
- # regexp helper (square brackets for optional)
- # $1 $2 $3 $4 $5
- # [prefix][\]:directive:[spaces][param]newline
- text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
- # skip something like ':toto::'
- next $& if $4.empty? and $5 and $5[0, 1] == ':'
-
- # skip if escaped
- next "#$1:#$3:#$4#$5\n" unless $2.empty?
-
- # This is not in handle_directive because I didn't want to pass another
- # argument into it
- if comment and $3 == 'markup' then
- next "#{$1.strip}\n" unless $5
- comment.format = $5.downcase
- next "#{$1.strip}\n"
- end
-
- handle_directive $1, $3, $5, code_object, text.encoding, &block
- end
-
- if comment then
- comment.text = text
- else
- comment = text
- end
-
- self.class.post_processors.each do |handler|
- handler.call comment, code_object
- end
-
- text
- end
-
- ##
- # Performs the actions described by +directive+ and its parameter +param+.
- #
- # +code_object+ is used for directives that operate on a class or module.
- # +prefix+ is used to ensure the replacement for handled directives is
- # correct. +encoding+ is used for the <tt>include</tt> directive.
- #
- # For a list of directives in RDoc see RDoc::Markup.
- #--
- # When 1.8.7 support is ditched prefix can be defaulted to ''
-
- def handle_directive prefix, directive, param, code_object = nil,
- encoding = nil
- blankline = "#{prefix.strip}\n"
- directive = directive.downcase
-
- case directive
- when 'arg', 'args' then
- return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod)
-
- code_object.params = param
-
- blankline
- when 'category' then
- if RDoc::Context === code_object then
- section = code_object.add_section param
- code_object.temporary_section = section
- elsif RDoc::AnyMethod === code_object then
- code_object.section_title = param
- end
-
- blankline # ignore category if we're not on an RDoc::Context
- when 'doc' then
- return blankline unless code_object
- code_object.document_self = true
- code_object.force_documentation = true
-
- blankline
- when 'enddoc' then
- return blankline unless code_object
- code_object.done_documenting = true
-
- blankline
- when 'include' then
- filename = param.split(' ', 2).first
- include_file filename, prefix, encoding
- when 'main' then
- @options.main_page = param if @options.respond_to? :main_page
-
- blankline
- when 'nodoc' then
- return blankline unless code_object
- code_object.document_self = nil # notify nodoc
- code_object.document_children = param !~ /all/i
-
- blankline
- when 'notnew', 'not_new', 'not-new' then
- return blankline unless RDoc::AnyMethod === code_object
-
- code_object.dont_rename_initialize = true
-
- blankline
- when 'startdoc' then
- return blankline unless code_object
-
- code_object.start_doc
- code_object.force_documentation = true
-
- blankline
- when 'stopdoc' then
- return blankline unless code_object
-
- code_object.stop_doc
-
- blankline
- when 'title' then
- @options.default_title = param if @options.respond_to? :default_title=
-
- blankline
- when 'yield', 'yields' then
- return blankline unless code_object
- # remove parameter &block
- code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
-
- code_object.block_params = param
-
- blankline
- else
- result = yield directive, param if block_given?
-
- case result
- when nil then
- code_object.metadata[directive] = param if code_object
-
- if RDoc::Markup::PreProcess.registered.include? directive then
- handler = RDoc::Markup::PreProcess.registered[directive]
- result = handler.call directive, param if handler
- else
- result = "#{prefix}:#{directive}: #{param}\n"
- end
- when false then
- result = "#{prefix}:#{directive}: #{param}\n"
- end
-
- result
- end
- end
-
- ##
- # Handles the <tt>:include: _filename_</tt> directive.
- #
- # If the first line of the included file starts with '#', and contains
- # an encoding information in the form 'coding:' or 'coding=', it is
- # removed.
- #
- # If all lines in the included file start with a '#', this leading '#'
- # is removed before inclusion. The included content is indented like
- # the <tt>:include:</tt> directive.
- #--
- # so all content will be verbatim because of the likely space after '#'?
- # TODO shift left the whole file content in that case
- # TODO comment stop/start #-- and #++ in included file must be processed here
-
- def include_file name, indent, encoding
- full_name = find_include_file name
-
- unless full_name then
- warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
- return ''
- end
-
- content = RDoc::Encoding.read_file full_name, encoding, true
- content = RDoc::Encoding.remove_magic_comment content
-
- # strip magic comment
- content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
-
- # strip leading '#'s, but only if all lines start with them
- if content =~ /^[^#]/ then
- content.gsub(/^/, indent)
- else
- content.gsub(/^#?/, indent)
- end
- end
-
- ##
- # Look for the given file in the directory containing the current file,
- # and then in each of the directories specified in the RDOC_INCLUDE path
-
- def find_include_file(name)
- to_search = [File.dirname(@input_file_name)].concat @include_path
- to_search.each do |dir|
- full_name = File.join(dir, name)
- stat = File.stat(full_name) rescue next
- return full_name if stat.readable?
- end
- nil
- end
-
-end
diff --git a/lib/rdoc/markup/raw.rb b/lib/rdoc/markup/raw.rb
deleted file mode 100644
index 85e2c8b825..0000000000
--- a/lib/rdoc/markup/raw.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# frozen_string_literal: true
-##
-# A section of text that is added to the output document as-is
-
-class RDoc::Markup::Raw
-
- ##
- # The component parts of the list
-
- attr_reader :parts
-
- ##
- # Creates a new Raw containing +parts+
-
- def initialize *parts
- @parts = []
- @parts.concat parts
- end
-
- ##
- # Appends +text+
-
- def << text
- @parts << text
- end
-
- def == other # :nodoc:
- self.class == other.class and @parts == other.parts
- end
-
- ##
- # Calls #accept_raw+ on +visitor+
-
- def accept visitor
- visitor.accept_raw self
- end
-
- ##
- # Appends +other+'s parts
-
- def merge other
- @parts.concat other.parts
- end
-
- def pretty_print q # :nodoc:
- self.class.name =~ /.*::(\w{1,4})/i
-
- q.group 2, "[#{$1.downcase}: ", ']' do
- q.seplist @parts do |part|
- q.pp part
- end
- end
- end
-
- ##
- # Appends +texts+ onto this Paragraph
-
- def push *texts
- self.parts.concat texts
- end
-
- ##
- # The raw text
-
- def text
- @parts.join ' '
- end
-
-end
-
diff --git a/lib/rdoc/markup/regexp_handling.rb b/lib/rdoc/markup/regexp_handling.rb
deleted file mode 100644
index 6ed868c2c1..0000000000
--- a/lib/rdoc/markup/regexp_handling.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-##
-# Hold details of a regexp handling sequence
-
-class RDoc::Markup::RegexpHandling
-
- ##
- # Regexp handling type
-
- attr_reader :type
-
- ##
- # Regexp handling text
-
- attr_accessor :text
-
- ##
- # Creates a new regexp handling sequence of +type+ with +text+
-
- def initialize(type, text)
- @type, @text = type, text
- end
-
- ##
- # Regexp handlings are equal when the have the same text and type
-
- def ==(o)
- self.text == o.text && self.type == o.type
- end
-
- def inspect # :nodoc:
- "#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
- object_id, @type, text.dump]
- end
-
- def to_s # :nodoc:
- "RegexpHandling: type=#{type} text=#{text.dump}"
- end
-
-end
-
diff --git a/lib/rdoc/markup/rule.rb b/lib/rdoc/markup/rule.rb
deleted file mode 100644
index 38c1dc7f56..0000000000
--- a/lib/rdoc/markup/rule.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-##
-# A horizontal rule with a weight
-
-class RDoc::Markup::Rule < Struct.new :weight
-
- ##
- # Calls #accept_rule on +visitor+
-
- def accept visitor
- visitor.accept_rule self
- end
-
- def pretty_print q # :nodoc:
- q.group 2, '[rule:', ']' do
- q.pp weight
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/table.rb b/lib/rdoc/markup/table.rb
deleted file mode 100644
index 7bcb10aff3..0000000000
--- a/lib/rdoc/markup/table.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-##
-# A section of table
-
-class RDoc::Markup::Table
- attr_accessor :header, :align, :body
-
- def initialize header, align, body
- @header, @align, @body = header, align, body
- end
-
- def == other
- self.class == other.class and
- @header == other.header and
- @align == other.align and
- @body == other.body
- end
-
- def accept visitor
- visitor.accept_table @header, @body, @align
- end
-
- def pretty_print q # :nodoc:
- q.group 2, '[Table: ', ']' do
- q.group 2, '[Head: ', ']' do
- q.seplist @header.zip(@align) do |text, align|
- q.pp text
- if align
- q.text ":"
- q.breakable
- q.text align.to_s
- end
- end
- end
- q.breakable
- q.group 2, '[Body: ', ']' do
- q.seplist @body do |body|
- q.group 2, '[', ']' do
- q.seplist body do |text|
- q.pp text
- end
- end
- end
- end
- end
- end
-end
diff --git a/lib/rdoc/markup/to_ansi.rb b/lib/rdoc/markup/to_ansi.rb
deleted file mode 100644
index 6cc3b70e93..0000000000
--- a/lib/rdoc/markup/to_ansi.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-# frozen_string_literal: true
-##
-# Outputs RDoc markup with vibrant ANSI color!
-
-class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
-
- ##
- # Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
-
- def initialize markup = nil
- super
-
- @headings.clear
- @headings[1] = ["\e[1;32m", "\e[m"] # bold
- @headings[2] = ["\e[4;32m", "\e[m"] # underline
- @headings[3] = ["\e[32m", "\e[m"] # just green
- end
-
- ##
- # Maps attributes to ANSI sequences
-
- def init_tags
- add_tag :BOLD, "\e[1m", "\e[m"
- add_tag :TT, "\e[7m", "\e[m"
- add_tag :EM, "\e[4m", "\e[m"
- end
-
- ##
- # Overrides indent width to ensure output lines up correctly.
-
- def accept_list_item_end list_item
- width = case @list_type.last
- when :BULLET then
- 2
- when :NOTE, :LABEL then
- if @prefix then
- @res << @prefix.strip
- @prefix = nil
- end
-
- @res << "\n" unless res.length == 1
- 2
- else
- bullet = @list_index.last.to_s
- @list_index[-1] = @list_index.last.succ
- bullet.length + 2
- end
-
- @indent -= width
- end
-
- ##
- # Adds coloring to note and label list items
-
- def accept_list_item_start list_item
- bullet = case @list_type.last
- when :BULLET then
- '*'
- when :NOTE, :LABEL then
- labels = Array(list_item.label).map do |label|
- attributes(label).strip
- end.join "\n"
-
- labels << ":\n" unless labels.empty?
-
- labels
- else
- @list_index.last.to_s + '.'
- end
-
- case @list_type.last
- when :NOTE, :LABEL then
- @indent += 2
- @prefix = bullet + (' ' * @indent)
- else
- @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
-
- width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
-
- @indent += width
- end
- end
-
- ##
- # Starts accepting with a reset screen
-
- def start_accepting
- super
-
- @res = ["\e[0m"]
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_bs.rb b/lib/rdoc/markup/to_bs.rb
deleted file mode 100644
index f9b86487db..0000000000
--- a/lib/rdoc/markup/to_bs.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-# frozen_string_literal: true
-##
-# Outputs RDoc markup with hot backspace action! You will probably need a
-# pager to use this output format.
-#
-# This formatter won't work on 1.8.6 because it lacks String#chars.
-
-class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
-
- ##
- # Returns a new ToBs that is ready for hot backspace action!
-
- def initialize markup = nil
- super
-
- @in_b = false
- @in_em = false
- end
-
- ##
- # Sets a flag that is picked up by #annotate to do the right thing in
- # #convert_string
-
- def init_tags
- add_tag :BOLD, '+b', '-b'
- add_tag :EM, '+_', '-_'
- add_tag :TT, '' , '' # we need in_tt information maintained
- end
-
- ##
- # Makes heading text bold.
-
- def accept_heading heading
- use_prefix or @res << ' ' * @indent
- @res << @headings[heading.level][0]
- @in_b = true
- @res << attributes(heading.text)
- @in_b = false
- @res << @headings[heading.level][1]
- @res << "\n"
- end
-
- ##
- # Turns on or off regexp handling for +convert_string+
-
- def annotate tag
- case tag
- when '+b' then @in_b = true
- when '-b' then @in_b = false
- when '+_' then @in_em = true
- when '-_' then @in_em = false
- end
- ''
- end
-
- ##
- # Calls convert_string on the result of convert_regexp_handling
-
- def convert_regexp_handling target
- convert_string super
- end
-
- ##
- # Adds bold or underline mixed with backspaces
-
- def convert_string string
- return string unless @in_b or @in_em
- chars = if @in_b then
- string.chars.map do |char| "#{char}\b#{char}" end
- elsif @in_em then
- string.chars.map do |char| "_\b#{char}" end
- end
-
- chars.join
- end
-
-end
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
deleted file mode 100644
index bf323074de..0000000000
--- a/lib/rdoc/markup/to_html.rb
+++ /dev/null
@@ -1,448 +0,0 @@
-# frozen_string_literal: true
-require 'cgi/util'
-
-##
-# Outputs RDoc markup as HTML.
-
-class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
-
- include RDoc::Text
-
- # :section: Utilities
-
- ##
- # Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags
-
- LIST_TYPE_TO_HTML = {
- :BULLET => ['<ul>', '</ul>'],
- :LABEL => ['<dl class="rdoc-list label-list">', '</dl>'],
- :LALPHA => ['<ol style="list-style-type: lower-alpha">', '</ol>'],
- :NOTE => ['<dl class="rdoc-list note-list">', '</dl>'],
- :NUMBER => ['<ol>', '</ol>'],
- :UALPHA => ['<ol style="list-style-type: upper-alpha">', '</ol>'],
- }
-
- attr_reader :res # :nodoc:
- attr_reader :in_list_entry # :nodoc:
- attr_reader :list # :nodoc:
-
- ##
- # The RDoc::CodeObject HTML is being generated for. This is used to
- # generate namespaced URI fragments
-
- attr_accessor :code_object
-
- ##
- # Path to this document for relative links
-
- attr_accessor :from_path
-
- # :section:
-
- ##
- # Creates a new formatter that will output HTML
-
- def initialize options, markup = nil
- super
-
- @code_object = nil
- @from_path = ''
- @in_list_entry = nil
- @list = nil
- @th = nil
- @hard_break = "<br>\n"
-
- init_regexp_handlings
-
- init_tags
- end
-
- # :section: Regexp Handling
- #
- # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
-
- URL_CHARACTERS_REGEXP_STR = /[A-Za-z0-9\-._~:\/\?#\[\]@!$&'\(\)*+,;%=]/.source
-
- ##
- # Adds regexp handlings.
-
- def init_regexp_handlings
- # external links
- @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)#{URL_CHARACTERS_REGEXP_STR}+\w/,
- :HYPERLINK)
- init_link_notation_regexp_handlings
- end
-
- ##
- # Adds regexp handlings about link notations.
-
- def init_link_notation_regexp_handlings
- add_regexp_handling_RDOCLINK
- add_regexp_handling_TIDYLINK
- end
-
- def handle_RDOCLINK url # :nodoc:
- case url
- when /^rdoc-ref:/
- CGI.escapeHTML($')
- when /^rdoc-label:/
- text = $'
-
- text = case text
- when /\Alabel-/ then $'
- when /\Afootmark-/ then $'
- when /\Afoottext-/ then $'
- else text
- end
-
- gen_url CGI.escapeHTML(url), CGI.escapeHTML(text)
- when /^rdoc-image:/
- %[<img src=\"#{CGI.escapeHTML($')}\">]
- when /\Ardoc-[a-z]+:/
- CGI.escapeHTML($')
- end
- end
-
- ##
- # +target+ is a <code><br></code>
-
- def handle_regexp_HARD_BREAK target
- '<br>'
- end
-
- ##
- # +target+ is a potential link. The following schemes are handled:
- #
- # <tt>mailto:</tt>::
- # Inserted as-is.
- # <tt>http:</tt>::
- # Links are checked to see if they reference an image. If so, that image
- # gets inserted using an <tt><img></tt> tag. Otherwise a conventional
- # <tt><a href></tt> is used.
- # <tt>link:</tt>::
- # Reference to a local file relative to the output directory.
-
- def handle_regexp_HYPERLINK(target)
- url = CGI.escapeHTML(target.text)
-
- gen_url url, url
- end
-
- ##
- # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
- #
- # For the +rdoc-ref+ scheme the named reference will be returned without
- # creating a link.
- #
- # For the +rdoc-label+ scheme the footnote and label prefixes are stripped
- # when creating a link. All other contents will be linked verbatim.
-
- def handle_regexp_RDOCLINK target
- handle_RDOCLINK target.text
- end
-
- ##
- # This +target+ is a link where the label is different from the URL
- # <tt>label[url]</tt> or <tt>{long label}[url]</tt>
-
- def handle_regexp_TIDYLINK(target)
- text = target.text
-
- return text unless
- text =~ /^\{(.*)\}\[(.*?)\]$/ or text =~ /^(\S+)\[(.*?)\]$/
-
- label = $1
- url = CGI.escapeHTML($2)
-
- if /^rdoc-image:/ =~ label
- label = handle_RDOCLINK(label)
- else
- label = CGI.escapeHTML(label)
- end
-
- gen_url url, label
- end
-
- # :section: Visitor
- #
- # These methods implement the HTML visitor.
-
- ##
- # Prepares the visitor for HTML generation
-
- def start_accepting
- @res = []
- @in_list_entry = []
- @list = []
- end
-
- ##
- # Returns the generated output
-
- def end_accepting
- @res.join
- end
-
- ##
- # Adds +block_quote+ to the output
-
- def accept_block_quote block_quote
- @res << "\n<blockquote>"
-
- block_quote.parts.each do |part|
- part.accept self
- end
-
- @res << "</blockquote>\n"
- end
-
- ##
- # Adds +paragraph+ to the output
-
- def accept_paragraph paragraph
- @res << "\n<p>"
- text = paragraph.text @hard_break
- text = text.gsub(/\r?\n/, ' ')
- @res << to_html(text)
- @res << "</p>\n"
- end
-
- ##
- # Adds +verbatim+ to the output
-
- def accept_verbatim verbatim
- text = verbatim.text.rstrip
-
- klass = nil
-
- content = if verbatim.ruby? or parseable? text then
- begin
- tokens = RDoc::Parser::RipperStateLex.parse text
- klass = ' class="ruby"'
-
- result = RDoc::TokenStream.to_html tokens
- result = result + "\n" unless "\n" == result[-1]
- result
- rescue
- CGI.escapeHTML text
- end
- else
- CGI.escapeHTML text
- end
-
- if @options.pipe then
- @res << "\n<pre><code>#{CGI.escapeHTML text}\n</code></pre>\n"
- else
- @res << "\n<pre#{klass}>#{content}</pre>\n"
- end
- end
-
- ##
- # Adds +rule+ to the output
-
- def accept_rule rule
- @res << "<hr>\n"
- end
-
- ##
- # Prepares the visitor for consuming +list+
-
- def accept_list_start(list)
- @list << list.type
- @res << html_list_name(list.type, true)
- @in_list_entry.push false
- end
-
- ##
- # Finishes consumption of +list+
-
- def accept_list_end(list)
- @list.pop
- if tag = @in_list_entry.pop
- @res << tag
- end
- @res << html_list_name(list.type, false) << "\n"
- end
-
- ##
- # Prepares the visitor for consuming +list_item+
-
- def accept_list_item_start(list_item)
- if tag = @in_list_entry.last
- @res << tag
- end
-
- @res << list_item_start(list_item, @list.last)
- end
-
- ##
- # Finishes consumption of +list_item+
-
- def accept_list_item_end(list_item)
- @in_list_entry[-1] = list_end_for(@list.last)
- end
-
- ##
- # Adds +blank_line+ to the output
-
- def accept_blank_line(blank_line)
- # @res << annotate("<p />") << "\n"
- end
-
- ##
- # Adds +heading+ to the output. The headings greater than 6 are trimmed to
- # level 6.
-
- def accept_heading heading
- level = [6, heading.level].min
-
- label = heading.label @code_object
-
- @res << if @options.output_decoration
- "\n<h#{level} id=\"#{label}\">"
- else
- "\n<h#{level}>"
- end
- @res << to_html(heading.text)
- unless @options.pipe then
- @res << "<span><a href=\"##{label}\">&para;</a>"
- @res << " <a href=\"#top\">&uarr;</a></span>"
- end
- @res << "</h#{level}>\n"
- end
-
- ##
- # Adds +raw+ to the output
-
- def accept_raw raw
- @res << raw.parts.join("\n")
- end
-
- ##
- # Adds +table+ to the output
-
- def accept_table header, body, aligns
- @res << "\n<table role=\"table\">\n<thead>\n<tr>\n"
- header.zip(aligns) do |text, align|
- @res << '<th'
- @res << ' align="' << align << '"' if align
- @res << '>' << to_html(text) << "</th>\n"
- end
- @res << "</tr>\n</thead>\n<tbody>\n"
- body.each do |row|
- @res << "<tr>\n"
- row.zip(aligns) do |text, align|
- @res << '<td'
- @res << ' align="' << align << '"' if align
- @res << '>' << to_html(text) << "</td>\n"
- end
- @res << "</tr>\n"
- end
- @res << "</tbody>\n</table>\n"
- end
-
- # :section: Utilities
-
- ##
- # CGI-escapes +text+
-
- def convert_string(text)
- CGI.escapeHTML text
- end
-
- ##
- # Generate a link to +url+ with content +text+. Handles the special cases
- # for img: and link: described under handle_regexp_HYPERLINK
-
- def gen_url url, text
- scheme, url, id = parse_url url
-
- if %w[http https link].include?(scheme) and
- url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
- "<img src=\"#{url}\" />"
- else
- if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
- url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
- end
-
- text = text.sub %r%^#{scheme}:/*%i, ''
- text = text.sub %r%^[*\^](\d+)$%, '\1'
-
- link = "<a#{id} href=\"#{url}\">#{text}</a>"
-
- link = "<sup>#{link}</sup>" if /"foot/ =~ id
-
- link
- end
- end
-
- ##
- # Determines the HTML list element for +list_type+ and +open_tag+
-
- def html_list_name(list_type, open_tag)
- tags = LIST_TYPE_TO_HTML[list_type]
- raise RDoc::Error, "Invalid list type: #{list_type.inspect}" unless tags
- tags[open_tag ? 0 : 1]
- end
-
- ##
- # Maps attributes to HTML tags
-
- def init_tags
- add_tag :BOLD, "<strong>", "</strong>"
- add_tag :TT, "<code>", "</code>"
- add_tag :EM, "<em>", "</em>"
- end
-
- ##
- # Returns the HTML tag for +list_type+, possible using a label from
- # +list_item+
-
- def list_item_start(list_item, list_type)
- case list_type
- when :BULLET, :LALPHA, :NUMBER, :UALPHA then
- "<li>"
- when :LABEL, :NOTE then
- Array(list_item.label).map do |label|
- "<dt>#{to_html label}\n"
- end.join << "<dd>"
- else
- raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
- end
- end
-
- ##
- # Returns the HTML end-tag for +list_type+
-
- def list_end_for(list_type)
- case list_type
- when :BULLET, :LALPHA, :NUMBER, :UALPHA then
- "</li>"
- when :LABEL, :NOTE then
- "</dd>"
- else
- raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
- end
- end
-
- ##
- # Returns true if text is valid ruby syntax
-
- def parseable? text
- verbose, $VERBOSE = $VERBOSE, nil
- eval("BEGIN {return true}\n#{text}")
- rescue SyntaxError
- false
- ensure
- $VERBOSE = verbose
- end
-
- ##
- # Converts +item+ to HTML using RDoc::Text#to_html
-
- def to_html item
- super convert_flow @am.flow item
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
deleted file mode 100644
index a9fd09df41..0000000000
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ /dev/null
@@ -1,176 +0,0 @@
-# frozen_string_literal: true
-##
-# Subclass of the RDoc::Markup::ToHtml class that supports looking up method
-# names, classes, etc to create links. RDoc::CrossReference is used to
-# generate those links based on the current context.
-
-class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
-
- # :stopdoc:
- ALL_CROSSREF_REGEXP = RDoc::CrossReference::ALL_CROSSREF_REGEXP
- CLASS_REGEXP_STR = RDoc::CrossReference::CLASS_REGEXP_STR
- CROSSREF_REGEXP = RDoc::CrossReference::CROSSREF_REGEXP
- METHOD_REGEXP_STR = RDoc::CrossReference::METHOD_REGEXP_STR
- # :startdoc:
-
- ##
- # RDoc::CodeObject for generating references
-
- attr_accessor :context
-
- ##
- # Should we show '#' characters on method references?
-
- attr_accessor :show_hash
-
- ##
- # Creates a new crossref resolver that generates links relative to +context+
- # which lives at +from_path+ in the generated files. '#' characters on
- # references are removed unless +show_hash+ is true. Only method names
- # preceded by '#' or '::' are linked, unless +hyperlink_all+ is true.
-
- def initialize(options, from_path, context, markup = nil)
- raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
-
- super options, markup
-
- @context = context
- @from_path = from_path
- @hyperlink_all = @options.hyperlink_all
- @show_hash = @options.show_hash
-
- @cross_reference = RDoc::CrossReference.new @context
- end
-
- def init_link_notation_regexp_handlings
- add_regexp_handling_RDOCLINK
-
- # The crossref must be linked before tidylink because Klass.method[:sym]
- # will be processed as a tidylink first and will be broken.
- crossref_re = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
- @markup.add_regexp_handling crossref_re, :CROSSREF
-
- add_regexp_handling_TIDYLINK
- end
-
- ##
- # Creates a link to the reference +name+ if the name exists. If +text+ is
- # given it is used as the link text, otherwise +name+ is used.
-
- def cross_reference name, text = nil, code = true
- lookup = name
-
- name = name[1..-1] unless @show_hash if name[0, 1] == '#'
-
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
- text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
- code = false
- else
- text ||= name
- end
-
- link lookup, text, code
- end
-
- ##
- # We're invoked when any text matches the CROSSREF pattern. If we find the
- # corresponding reference, generate a link. If the name we're looking for
- # contains no punctuation, we look for it up the module/class chain. For
- # example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
- # because we look for it in module Markup first.
-
- def handle_regexp_CROSSREF(target)
- name = target.text
-
- return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
-
- unless @hyperlink_all then
- # This ensures that words entirely consisting of lowercase letters will
- # not have cross-references generated (to suppress lots of erroneous
- # cross-references to "new" in text, for instance)
- return name if name =~ /\A[a-z]*\z/
- end
-
- cross_reference name
- end
-
- ##
- # Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
- # handle other schemes.
-
- def handle_regexp_HYPERLINK target
- return cross_reference $' if target.text =~ /\Ardoc-ref:/
-
- super
- end
-
- ##
- # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
- # For the rdoc-ref scheme the cross-reference will be looked up and the
- # given name will be used.
- #
- # All other contents are handled by
- # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
-
- def handle_regexp_RDOCLINK target
- url = target.text
-
- case url
- when /\Ardoc-ref:/ then
- cross_reference $'
- else
- super
- end
- end
-
- ##
- # Generates links for <tt>rdoc-ref:</tt> scheme URLs and allows
- # RDoc::Markup::ToHtml to handle other schemes.
-
- def gen_url url, text
- return super unless url =~ /\Ardoc-ref:/
-
- name = $'
- cross_reference name, text, name == text
- end
-
- ##
- # Creates an HTML link to +name+ with the given +text+.
-
- def link name, text, code = true
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
- name = $1
- label = $'
- end
-
- ref = @cross_reference.resolve name, text
-
- case ref
- when String then
- ref
- else
- path = ref.as_href @from_path
-
- if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
- text = "<code>#{CGI.escapeHTML text}</code>"
- end
-
- if path =~ /#/ then
- path << "-label-#{label}"
- elsif ref.sections and
- ref.sections.any? { |section| label == section.title } then
- path << "##{label}"
- else
- if ref.respond_to?(:aref)
- path << "##{ref.aref}-label-#{label}"
- else
- path << "#label-#{label}"
- end
- end if label
-
- "<a href=\"#{path}\">#{text}</a>"
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb
deleted file mode 100644
index 4eb36592b7..0000000000
--- a/lib/rdoc/markup/to_html_snippet.rb
+++ /dev/null
@@ -1,285 +0,0 @@
-# frozen_string_literal: true
-##
-# Outputs RDoc markup as paragraphs with inline markup only.
-
-class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
-
- ##
- # After this many characters the input will be cut off.
-
- attr_reader :character_limit
-
- ##
- # The number of characters seen so far.
-
- attr_reader :characters # :nodoc:
-
- ##
- # The attribute bitmask
-
- attr_reader :mask
-
- ##
- # After this many paragraphs the input will be cut off.
-
- attr_reader :paragraph_limit
-
- ##
- # Count of paragraphs found
-
- attr_reader :paragraphs
-
- ##
- # Creates a new ToHtmlSnippet formatter that will cut off the input on the
- # next word boundary after the given number of +characters+ or +paragraphs+
- # of text have been encountered.
-
- def initialize options, characters = 100, paragraphs = 3, markup = nil
- super options, markup
-
- @character_limit = characters
- @paragraph_limit = paragraphs
-
- @characters = 0
- @mask = 0
- @paragraphs = 0
-
- @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
- end
-
- ##
- # Adds +heading+ to the output as a paragraph
-
- def accept_heading heading
- @res << "<p>#{to_html heading.text}\n"
-
- add_paragraph
- end
-
- ##
- # Raw sections are untrusted and ignored
-
- alias accept_raw ignore
-
- ##
- # Rules are ignored
-
- alias accept_rule ignore
-
- def accept_paragraph paragraph
- para = @in_list_entry.last || "<p>"
-
- text = paragraph.text @hard_break
-
- @res << "#{para}#{to_html text}\n"
-
- add_paragraph
- end
-
- ##
- # Finishes consumption of +list_item+
-
- def accept_list_item_end list_item
- end
-
- ##
- # Prepares the visitor for consuming +list_item+
-
- def accept_list_item_start list_item
- @res << list_item_start(list_item, @list.last)
- end
-
- ##
- # Prepares the visitor for consuming +list+
-
- def accept_list_start list
- @list << list.type
- @res << html_list_name(list.type, true)
- @in_list_entry.push ''
- end
-
- ##
- # Adds +verbatim+ to the output
-
- def accept_verbatim verbatim
- throw :done if @characters >= @character_limit
- input = verbatim.text.rstrip
-
- text = truncate input
- text << ' ...' unless text == input
-
- super RDoc::Markup::Verbatim.new text
-
- add_paragraph
- end
-
- ##
- # Prepares the visitor for HTML snippet generation
-
- def start_accepting
- super
-
- @characters = 0
- end
-
- ##
- # Removes escaping from the cross-references in +target+
-
- def handle_regexp_CROSSREF target
- target.text.sub(/\A\\/, '')
- end
-
- ##
- # +target+ is a <code><br></code>
-
- def handle_regexp_HARD_BREAK target
- @characters -= 4
- '<br>'
- end
-
- ##
- # Lists are paragraphs, but notes and labels have a separator
-
- def list_item_start list_item, list_type
- throw :done if @characters >= @character_limit
-
- case list_type
- when :BULLET, :LALPHA, :NUMBER, :UALPHA then
- "<p>"
- when :LABEL, :NOTE then
- labels = Array(list_item.label).map do |label|
- to_html label
- end.join ', '
-
- labels << " &mdash; " unless labels.empty?
-
- start = "<p>#{labels}"
- @characters += 1 # try to include the label
- start
- else
- raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
- end
- end
-
- ##
- # Returns just the text of +link+, +url+ is only used to determine the link
- # type.
-
- def gen_url url, text
- if url =~ /^rdoc-label:([^:]*)(?::(.*))?/ then
- type = "link"
- elsif url =~ /([A-Za-z]+):(.*)/ then
- type = $1
- else
- type = "http"
- end
-
- if (type == "http" or type == "https" or type == "link") and
- url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
- ''
- else
- text.sub(%r%^#{type}:/*%, '')
- end
- end
-
- ##
- # In snippets, there are no lists
-
- def html_list_name list_type, open_tag
- ''
- end
-
- ##
- # Throws +:done+ when paragraph_limit paragraphs have been encountered
-
- def add_paragraph
- @paragraphs += 1
-
- throw :done if @paragraphs >= @paragraph_limit
- end
-
- ##
- # Marks up +content+
-
- def convert content
- catch :done do
- return super
- end
-
- end_accepting
- end
-
- ##
- # Converts flow items +flow+
-
- def convert_flow flow
- throw :done if @characters >= @character_limit
-
- res = []
- @mask = 0
-
- flow.each do |item|
- case item
- when RDoc::Markup::AttrChanger then
- off_tags res, item
- on_tags res, item
- when String then
- text = convert_string item
- res << truncate(text)
- when RDoc::Markup::RegexpHandling then
- text = convert_regexp_handling item
- res << truncate(text)
- else
- raise "Unknown flow element: #{item.inspect}"
- end
-
- if @characters >= @character_limit then
- off_tags res, RDoc::Markup::AttrChanger.new(0, @mask)
- break
- end
- end
-
- res << ' ...' if @characters >= @character_limit
-
- res.join
- end
-
- ##
- # Maintains a bitmask to allow HTML elements to be closed properly. See
- # RDoc::Markup::Formatter.
-
- def on_tags res, item
- @mask ^= item.turn_on
-
- super
- end
-
- ##
- # Maintains a bitmask to allow HTML elements to be closed properly. See
- # RDoc::Markup::Formatter.
-
- def off_tags res, item
- @mask ^= item.turn_off
-
- super
- end
-
- ##
- # Truncates +text+ at the end of the first word after the character_limit.
-
- def truncate text
- length = text.length
- characters = @characters
- @characters += length
-
- return text if @characters < @character_limit
-
- remaining = @character_limit - characters
-
- text =~ /\A(.{#{remaining},}?)(\s|$)/m # TODO word-break instead of \s?
-
- $1
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_joined_paragraph.rb b/lib/rdoc/markup/to_joined_paragraph.rb
deleted file mode 100644
index 46e07c94ad..0000000000
--- a/lib/rdoc/markup/to_joined_paragraph.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-##
-# Joins the parts of an RDoc::Markup::Paragraph into a single String.
-#
-# This allows for easier maintenance and testing of Markdown support.
-#
-# This formatter only works on Paragraph instances. Attempting to process
-# other markup syntax items will not work.
-
-class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
-
- def initialize # :nodoc:
- super nil
- end
-
- def start_accepting # :nodoc:
- end
-
- def end_accepting # :nodoc:
- end
-
- ##
- # Converts the parts of +paragraph+ to a single entry.
-
- def accept_paragraph paragraph
- parts = paragraph.parts.chunk do |part|
- String === part
- end.map do |string, chunk|
- string ? chunk.join.rstrip : chunk
- end.flatten
-
- paragraph.parts.replace parts
- end
-
- alias accept_block_quote ignore
- alias accept_heading ignore
- alias accept_list_end ignore
- alias accept_list_item_end ignore
- alias accept_list_item_start ignore
- alias accept_list_start ignore
- alias accept_raw ignore
- alias accept_rule ignore
- alias accept_verbatim ignore
- alias accept_table ignore
-
-end
-
diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb
deleted file mode 100644
index aa1dbcf2a1..0000000000
--- a/lib/rdoc/markup/to_label.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# frozen_string_literal: true
-require 'cgi/util'
-
-##
-# Creates HTML-safe labels suitable for use in id attributes. Tidylinks are
-# converted to their link part and cross-reference links have the suppression
-# marks removed (\\SomeClass is converted to SomeClass).
-
-class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
-
- attr_reader :res # :nodoc:
-
- ##
- # Creates a new formatter that will output HTML-safe labels
-
- def initialize markup = nil
- super nil, markup
-
- @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
- @markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
-
- add_tag :BOLD, '', ''
- add_tag :TT, '', ''
- add_tag :EM, '', ''
-
- @res = []
- end
-
- ##
- # Converts +text+ to an HTML-safe label
-
- def convert text
- label = convert_flow @am.flow text
-
- CGI.escape(label).gsub('%', '-').sub(/^-/, '')
- end
-
- ##
- # Converts the CROSSREF +target+ to plain text, removing the suppression
- # marker, if any
-
- def handle_regexp_CROSSREF target
- text = target.text
-
- text.sub(/^\\/, '')
- end
-
- ##
- # Converts the TIDYLINK +target+ to just the text part
-
- def handle_regexp_TIDYLINK target
- text = target.text
-
- return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
-
- $1
- end
-
- alias accept_blank_line ignore
- alias accept_block_quote ignore
- alias accept_heading ignore
- alias accept_list_end ignore
- alias accept_list_item_end ignore
- alias accept_list_item_start ignore
- alias accept_list_start ignore
- alias accept_paragraph ignore
- alias accept_raw ignore
- alias accept_rule ignore
- alias accept_verbatim ignore
- alias end_accepting ignore
- alias handle_regexp_HARD_BREAK ignore
- alias start_accepting ignore
-
-end
-
diff --git a/lib/rdoc/markup/to_markdown.rb b/lib/rdoc/markup/to_markdown.rb
deleted file mode 100644
index 3ee48becb0..0000000000
--- a/lib/rdoc/markup/to_markdown.rb
+++ /dev/null
@@ -1,192 +0,0 @@
-# frozen_string_literal: true
-# :markup: markdown
-
-##
-# Outputs parsed markup as Markdown
-
-class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
-
- ##
- # Creates a new formatter that will output Markdown format text
-
- def initialize markup = nil
- super
-
- @headings[1] = ['# ', '']
- @headings[2] = ['## ', '']
- @headings[3] = ['### ', '']
- @headings[4] = ['#### ', '']
- @headings[5] = ['##### ', '']
- @headings[6] = ['###### ', '']
-
- add_regexp_handling_RDOCLINK
- add_regexp_handling_TIDYLINK
-
- @hard_break = " \n"
- end
-
- ##
- # Maps attributes to HTML sequences
-
- def init_tags
- add_tag :BOLD, '**', '**'
- add_tag :EM, '*', '*'
- add_tag :TT, '`', '`'
- end
-
- ##
- # Adds a newline to the output
-
- def handle_regexp_HARD_BREAK target
- " \n"
- end
-
- ##
- # Finishes consumption of `list`
-
- def accept_list_end list
- @res << "\n"
-
- super
- end
-
- ##
- # Finishes consumption of `list_item`
-
- def accept_list_item_end list_item
- width = case @list_type.last
- when :BULLET then
- 4
- when :NOTE, :LABEL then
- use_prefix
-
- 4
- else
- @list_index[-1] = @list_index.last.succ
- 4
- end
-
- @indent -= width
- end
-
- ##
- # Prepares the visitor for consuming `list_item`
-
- def accept_list_item_start list_item
- type = @list_type.last
-
- case type
- when :NOTE, :LABEL then
- bullets = Array(list_item.label).map do |label|
- attributes(label).strip
- end.join "\n"
-
- bullets << "\n:"
-
- @prefix = ' ' * @indent
- @indent += 4
- @prefix << bullets + (' ' * (@indent - 1))
- else
- bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
- @prefix = (' ' * @indent) + bullet.ljust(4)
-
- @indent += 4
- end
- end
-
- ##
- # Prepares the visitor for consuming `list`
-
- def accept_list_start list
- case list.type
- when :BULLET, :LABEL, :NOTE then
- @list_index << nil
- when :LALPHA, :NUMBER, :UALPHA then
- @list_index << 1
- else
- raise RDoc::Error, "invalid list type #{list.type}"
- end
-
- @list_width << 4
- @list_type << list.type
- end
-
- ##
- # Adds `rule` to the output
-
- def accept_rule rule
- use_prefix or @res << ' ' * @indent
- @res << '-' * 3
- @res << "\n"
- end
-
- ##
- # Outputs `verbatim` indented 4 columns
-
- def accept_verbatim verbatim
- indent = ' ' * (@indent + 4)
-
- verbatim.parts.each do |part|
- @res << indent unless part == "\n"
- @res << part
- end
-
- @res << "\n"
- end
-
- ##
- # Creates a Markdown-style URL from +url+ with +text+.
-
- def gen_url url, text
- scheme, url, = parse_url url
-
- "[#{text.sub(%r{^#{scheme}:/*}i, '')}](#{url})"
- end
-
- ##
- # Handles <tt>rdoc-</tt> type links for footnotes.
-
- def handle_rdoc_link url
- case url
- when /^rdoc-ref:/ then
- $'
- when /^rdoc-label:footmark-(\d+)/ then
- "[^#{$1}]:"
- when /^rdoc-label:foottext-(\d+)/ then
- "[^#{$1}]"
- when /^rdoc-label:label-/ then
- gen_url url, $'
- when /^rdoc-image:/ then
- "![](#{$'})"
- when /^rdoc-[a-z]+:/ then
- $'
- end
- end
-
- ##
- # Converts the RDoc markup tidylink into a Markdown.style link.
-
- def handle_regexp_TIDYLINK target
- text = target.text
-
- return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
-
- label = $1
- url = $2
-
- if url =~ /^rdoc-label:foot/ then
- handle_rdoc_link url
- else
- gen_url url, label
- end
- end
-
- ##
- # Converts the rdoc-...: links into a Markdown.style links.
-
- def handle_regexp_RDOCLINK target
- handle_rdoc_link target.text
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb
deleted file mode 100644
index 2a9b05625c..0000000000
--- a/lib/rdoc/markup/to_rdoc.rb
+++ /dev/null
@@ -1,345 +0,0 @@
-# frozen_string_literal: true
-##
-# Outputs RDoc markup as RDoc markup! (mostly)
-
-class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
-
- ##
- # Current indent amount for output in characters
-
- attr_accessor :indent
-
- ##
- # Output width in characters
-
- attr_accessor :width
-
- ##
- # Stack of current list indexes for alphabetic and numeric lists
-
- attr_reader :list_index
-
- ##
- # Stack of list types
-
- attr_reader :list_type
-
- ##
- # Stack of list widths for indentation
-
- attr_reader :list_width
-
- ##
- # Prefix for the next list item. See #use_prefix
-
- attr_reader :prefix
-
- ##
- # Output accumulator
-
- attr_reader :res
-
- ##
- # Creates a new formatter that will output (mostly) \RDoc markup
-
- def initialize markup = nil
- super nil, markup
-
- @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
- @width = 78
- init_tags
-
- @headings = {}
- @headings.default = []
-
- @headings[1] = ['= ', '']
- @headings[2] = ['== ', '']
- @headings[3] = ['=== ', '']
- @headings[4] = ['==== ', '']
- @headings[5] = ['===== ', '']
- @headings[6] = ['====== ', '']
-
- @hard_break = "\n"
- end
-
- ##
- # Maps attributes to HTML sequences
-
- def init_tags
- add_tag :BOLD, "<b>", "</b>"
- add_tag :TT, "<tt>", "</tt>"
- add_tag :EM, "<em>", "</em>"
- end
-
- ##
- # Adds +blank_line+ to the output
-
- def accept_blank_line blank_line
- @res << "\n"
- end
-
- ##
- # Adds +paragraph+ to the output
-
- def accept_block_quote block_quote
- @indent += 2
-
- block_quote.parts.each do |part|
- @prefix = '> '
-
- part.accept self
- end
-
- @indent -= 2
- end
-
- ##
- # Adds +heading+ to the output
-
- def accept_heading heading
- use_prefix or @res << ' ' * @indent
- @res << @headings[heading.level][0]
- @res << attributes(heading.text)
- @res << @headings[heading.level][1]
- @res << "\n"
- end
-
- ##
- # Finishes consumption of +list+
-
- def accept_list_end list
- @list_index.pop
- @list_type.pop
- @list_width.pop
- end
-
- ##
- # Finishes consumption of +list_item+
-
- def accept_list_item_end list_item
- width = case @list_type.last
- when :BULLET then
- 2
- when :NOTE, :LABEL then
- if @prefix then
- @res << @prefix.strip
- @prefix = nil
- end
-
- @res << "\n"
- 2
- else
- bullet = @list_index.last.to_s
- @list_index[-1] = @list_index.last.succ
- bullet.length + 2
- end
-
- @indent -= width
- end
-
- ##
- # Prepares the visitor for consuming +list_item+
-
- def accept_list_item_start list_item
- type = @list_type.last
-
- case type
- when :NOTE, :LABEL then
- bullets = Array(list_item.label).map do |label|
- attributes(label).strip
- end.join "\n"
-
- bullets << ":\n" unless bullets.empty?
-
- @prefix = ' ' * @indent
- @indent += 2
- @prefix << bullets + (' ' * @indent)
- else
- bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
- @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
- width = bullet.length + 1
- @indent += width
- end
- end
-
- ##
- # Prepares the visitor for consuming +list+
-
- def accept_list_start list
- case list.type
- when :BULLET then
- @list_index << nil
- @list_width << 1
- when :LABEL, :NOTE then
- @list_index << nil
- @list_width << 2
- when :LALPHA then
- @list_index << 'a'
- @list_width << list.items.length.to_s.length
- when :NUMBER then
- @list_index << 1
- @list_width << list.items.length.to_s.length
- when :UALPHA then
- @list_index << 'A'
- @list_width << list.items.length.to_s.length
- else
- raise RDoc::Error, "invalid list type #{list.type}"
- end
-
- @list_type << list.type
- end
-
- ##
- # Adds +paragraph+ to the output
-
- def accept_paragraph paragraph
- text = paragraph.text @hard_break
- wrap attributes text
- end
-
- ##
- # Adds +paragraph+ to the output
-
- def accept_indented_paragraph paragraph
- @indent += paragraph.indent
- text = paragraph.text @hard_break
- wrap attributes text
- @indent -= paragraph.indent
- end
-
- ##
- # Adds +raw+ to the output
-
- def accept_raw raw
- @res << raw.parts.join("\n")
- end
-
- ##
- # Adds +rule+ to the output
-
- def accept_rule rule
- use_prefix or @res << ' ' * @indent
- @res << '-' * (@width - @indent)
- @res << "\n"
- end
-
- ##
- # Outputs +verbatim+ indented 2 columns
-
- def accept_verbatim verbatim
- indent = ' ' * (@indent + 2)
-
- verbatim.parts.each do |part|
- @res << indent unless part == "\n"
- @res << part
- end
-
- @res << "\n"
- end
-
- ##
- # Adds +table+ to the output
-
- def accept_table header, body, aligns
- widths = header.zip(body) do |h, b|
- [h.size, b.size].max
- end
- aligns = aligns.map do |a|
- case a
- when nil
- :center
- when :left
- :ljust
- when :right
- :rjust
- end
- end
- @res << header.zip(widths, aligns) do |h, w, a|
- h.__send__(a, w)
- end.join("|").rstrip << "\n"
- @res << widths.map {|w| "-" * w }.join("|") << "\n"
- body.each do |row|
- @res << row.zip(widths, aligns) do |t, w, a|
- t.__send__(a, w)
- end.join("|").rstrip << "\n"
- end
- end
-
- ##
- # Applies attribute-specific markup to +text+ using RDoc::AttributeManager
-
- def attributes text
- flow = @am.flow text.dup
- convert_flow flow
- end
-
- ##
- # Returns the generated output
-
- def end_accepting
- @res.join
- end
-
- ##
- # Removes preceding \\ from the suppressed crossref +target+
-
- def handle_regexp_SUPPRESSED_CROSSREF target
- text = target.text
- text = text.sub('\\', '') unless in_tt?
- text
- end
-
- ##
- # Adds a newline to the output
-
- def handle_regexp_HARD_BREAK target
- "\n"
- end
-
- ##
- # Prepares the visitor for text generation
-
- def start_accepting
- @res = [""]
- @indent = 0
- @prefix = nil
-
- @list_index = []
- @list_type = []
- @list_width = []
- end
-
- ##
- # Adds the stored #prefix to the output and clears it. Lists generate a
- # prefix for later consumption.
-
- def use_prefix
- prefix, @prefix = @prefix, nil
- @res << prefix if prefix
-
- prefix
- end
-
- ##
- # Wraps +text+ to #width
-
- def wrap text
- return unless text && !text.empty?
-
- text_len = @width - @indent
-
- text_len = 20 if text_len < 20
-
- next_prefix = ' ' * @indent
-
- prefix = @prefix || next_prefix
- @prefix = nil
-
- text.scan(/\G(?:([^ \n]{#{text_len}})(?=[^ \n])|(.{1,#{text_len}})(?:[ \n]|\z))/) do
- @res << prefix << ($1 || $2) << "\n"
- prefix = next_prefix
- end
- end
-
-end
-
diff --git a/lib/rdoc/markup/to_table_of_contents.rb b/lib/rdoc/markup/to_table_of_contents.rb
deleted file mode 100644
index eb8e8faa16..0000000000
--- a/lib/rdoc/markup/to_table_of_contents.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# frozen_string_literal: true
-##
-# Extracts just the RDoc::Markup::Heading elements from a
-# RDoc::Markup::Document to help build a table of contents
-
-class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
-
- @to_toc = nil
-
- ##
- # Singleton for table-of-contents generation
-
- def self.to_toc
- @to_toc ||= new
- end
-
- ##
- # Output accumulator
-
- attr_reader :res
-
- ##
- # Omits headings with a level less than the given level.
-
- attr_accessor :omit_headings_below
-
- def initialize # :nodoc:
- super nil
-
- @omit_headings_below = nil
- end
-
- ##
- # Adds +document+ to the output, using its heading cutoff if present
-
- def accept_document document
- @omit_headings_below = document.omit_headings_below
-
- super
- end
-
- ##
- # Adds +heading+ to the table of contents
-
- def accept_heading heading
- @res << heading unless suppressed? heading
- end
-
- ##
- # Returns the table of contents
-
- def end_accepting
- @res
- end
-
- ##
- # Prepares the visitor for text generation
-
- def start_accepting
- @omit_headings_below = nil
- @res = []
- end
-
- ##
- # Returns true if +heading+ is below the display threshold
-
- def suppressed? heading
- return false unless @omit_headings_below
-
- heading.level > @omit_headings_below
- end
-
- # :stopdoc:
- alias accept_block_quote ignore
- alias accept_raw ignore
- alias accept_rule ignore
- alias accept_blank_line ignore
- alias accept_paragraph ignore
- alias accept_verbatim ignore
- alias accept_list_end ignore
- alias accept_list_item_start ignore
- alias accept_list_item_end ignore
- alias accept_list_end_bullet ignore
- alias accept_list_start ignore
- alias accept_table ignore
- # :startdoc:
-
-end
-
diff --git a/lib/rdoc/markup/to_test.rb b/lib/rdoc/markup/to_test.rb
deleted file mode 100644
index 61d3cffaf0..0000000000
--- a/lib/rdoc/markup/to_test.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# frozen_string_literal: true
-##
-# This Markup outputter is used for testing purposes.
-
-class RDoc::Markup::ToTest < RDoc::Markup::Formatter
-
- # :stopdoc:
-
- ##
- # :section: Visitor
-
- def start_accepting
- @res = []
- @list = []
- end
-
- def end_accepting
- @res
- end
-
- def accept_paragraph(paragraph)
- @res << convert_flow(@am.flow(paragraph.text))
- end
-
- def accept_raw raw
- @res << raw.parts.join
- end
-
- def accept_verbatim(verbatim)
- @res << verbatim.text.gsub(/^(\S)/, ' \1')
- end
-
- def accept_list_start(list)
- @list << case list.type
- when :BULLET then
- '*'
- when :NUMBER then
- '1'
- else
- list.type
- end
- end
-
- def accept_list_end(list)
- @list.pop
- end
-
- def accept_list_item_start(list_item)
- @res << "#{' ' * (@list.size - 1)}#{@list.last}: "
- end
-
- def accept_list_item_end(list_item)
- end
-
- def accept_blank_line(blank_line)
- @res << "\n"
- end
-
- def accept_heading(heading)
- @res << "#{'=' * heading.level} #{heading.text}"
- end
-
- def accept_rule(rule)
- @res << '-' * rule.weight
- end
-
- # :startdoc:
-
-end
-
diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb
deleted file mode 100644
index 9235d33f04..0000000000
--- a/lib/rdoc/markup/to_tt_only.rb
+++ /dev/null
@@ -1,121 +0,0 @@
-# frozen_string_literal: true
-##
-# Extracts sections of text enclosed in plus, tt or code. Used to discover
-# undocumented parameters.
-
-class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
-
- ##
- # Stack of list types
-
- attr_reader :list_type
-
- ##
- # Output accumulator
-
- attr_reader :res
-
- ##
- # Creates a new tt-only formatter.
-
- def initialize markup = nil
- super nil, markup
-
- add_tag :TT, nil, nil
- end
-
- ##
- # Adds tts from +block_quote+ to the output
-
- def accept_block_quote block_quote
- tt_sections block_quote.text
- end
-
- ##
- # Pops the list type for +list+ from #list_type
-
- def accept_list_end list
- @list_type.pop
- end
-
- ##
- # Pushes the list type for +list+ onto #list_type
-
- def accept_list_start list
- @list_type << list.type
- end
-
- ##
- # Prepares the visitor for consuming +list_item+
-
- def accept_list_item_start list_item
- case @list_type.last
- when :NOTE, :LABEL then
- Array(list_item.label).map do |label|
- tt_sections label
- end.flatten
- end
- end
-
- ##
- # Adds +paragraph+ to the output
-
- def accept_paragraph paragraph
- tt_sections(paragraph.text)
- end
-
- ##
- # Does nothing to +markup_item+ because it doesn't have any user-built
- # content
-
- def do_nothing markup_item
- end
-
- alias accept_blank_line do_nothing # :nodoc:
- alias accept_heading do_nothing # :nodoc:
- alias accept_list_item_end do_nothing # :nodoc:
- alias accept_raw do_nothing # :nodoc:
- alias accept_rule do_nothing # :nodoc:
- alias accept_verbatim do_nothing # :nodoc:
-
- ##
- # Extracts tt sections from +text+
-
- def tt_sections text
- flow = @am.flow text.dup
-
- flow.each do |item|
- case item
- when String then
- @res << item if in_tt?
- when RDoc::Markup::AttrChanger then
- off_tags res, item
- on_tags res, item
- when RDoc::Markup::RegexpHandling then
- @res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
- else
- raise "Unknown flow element: #{item.inspect}"
- end
- end
-
- res
- end
-
- ##
- # Returns an Array of items that were wrapped in plus, tt or code.
-
- def end_accepting
- @res.compact
- end
-
- ##
- # Prepares the visitor for gathering tt sections
-
- def start_accepting
- @res = []
-
- @list_type = []
- end
-
-end
-
diff --git a/lib/rdoc/markup/verbatim.rb b/lib/rdoc/markup/verbatim.rb
deleted file mode 100644
index 7f1bc29a09..0000000000
--- a/lib/rdoc/markup/verbatim.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-##
-# A section of verbatim text
-
-class RDoc::Markup::Verbatim < RDoc::Markup::Raw
-
- ##
- # Format of this verbatim section
-
- attr_accessor :format
-
- def initialize *parts # :nodoc:
- super
-
- @format = nil
- end
-
- def == other # :nodoc:
- super and @format == other.format
- end
-
- ##
- # Calls #accept_verbatim on +visitor+
-
- def accept visitor
- visitor.accept_verbatim self
- end
-
- ##
- # Collapses 3+ newlines into two newlines
-
- def normalize
- parts = []
-
- newlines = 0
-
- @parts.each do |part|
- case part
- when /^\s*\n/ then
- newlines += 1
- parts << part if newlines == 1
- else
- newlines = 0
- parts << part
- end
- end
-
- parts.pop if parts.last =~ /\A\r?\n\z/
-
- @parts = parts
- end
-
- def pretty_print q # :nodoc:
- self.class.name =~ /.*::(\w{1,4})/i
-
- q.group 2, "[#{$1.downcase}: ", ']' do
- if @format then
- q.text "format: #{@format}"
- q.breakable
- end
-
- q.seplist @parts do |part|
- q.pp part
- end
- end
- end
-
- ##
- # Is this verbatim section Ruby code?
-
- def ruby?
- @format ||= nil # TODO for older ri data, switch the tree to marshal_dump
- @format == :ruby
- end
-
- ##
- # The text of the section
-
- def text
- @parts.join
- end
-
-end
-
diff --git a/lib/rdoc/meta_method.rb b/lib/rdoc/meta_method.rb
deleted file mode 100644
index 7927a9ce9c..0000000000
--- a/lib/rdoc/meta_method.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-##
-# MetaMethod represents a meta-programmed method
-
-class RDoc::MetaMethod < RDoc::AnyMethod
-end
-
diff --git a/lib/rdoc/method_attr.rb b/lib/rdoc/method_attr.rb
deleted file mode 100644
index aae3c47e85..0000000000
--- a/lib/rdoc/method_attr.rb
+++ /dev/null
@@ -1,419 +0,0 @@
-# frozen_string_literal: true
-##
-# Abstract class representing either a method or an attribute.
-
-class RDoc::MethodAttr < RDoc::CodeObject
-
- include Comparable
-
- ##
- # Name of this method/attribute.
-
- attr_accessor :name
-
- ##
- # public, protected, private
-
- attr_accessor :visibility
-
- ##
- # Is this a singleton method/attribute?
-
- attr_accessor :singleton
-
- ##
- # Source file token stream
-
- attr_reader :text
-
- ##
- # Array of other names for this method/attribute
-
- attr_reader :aliases
-
- ##
- # The method/attribute we're aliasing
-
- attr_accessor :is_alias_for
-
- #--
- # The attributes below are for AnyMethod only.
- # They are left here for the time being to
- # allow ri to operate.
- # TODO modify ri to avoid calling these on attributes.
- #++
-
- ##
- # Parameters yielded by the called block
-
- attr_reader :block_params
-
- ##
- # Parameters for this method
-
- attr_accessor :params
-
- ##
- # Different ways to call this method
-
- attr_accessor :call_seq
-
- ##
- # The call_seq or the param_seq with method name, if there is no call_seq.
-
- attr_reader :arglists
-
- ##
- # Pretty parameter list for this method
-
- attr_reader :param_seq
-
-
- ##
- # Creates a new MethodAttr from token stream +text+ and method or attribute
- # name +name+.
- #
- # Usually this is called by super from a subclass.
-
- def initialize text, name
- super()
-
- @text = text
- @name = name
-
- @aliases = []
- @is_alias_for = nil
- @parent_name = nil
- @singleton = nil
- @visibility = :public
- @see = false
-
- @arglists = nil
- @block_params = nil
- @call_seq = nil
- @param_seq = nil
- @params = nil
- end
-
- ##
- # Resets cached data for the object so it can be rebuilt by accessor methods
-
- def initialize_copy other # :nodoc:
- @full_name = nil
- end
-
- def initialize_visibility # :nodoc:
- super
- @see = nil
- end
-
- ##
- # Order by #singleton then #name
-
- def <=>(other)
- return unless other.respond_to?(:singleton) &&
- other.respond_to?(:name)
-
- [ @singleton ? 0 : 1, name] <=>
- [other.singleton ? 0 : 1, other.name]
- end
-
- def == other # :nodoc:
- equal?(other) or self.class == other.class and full_name == other.full_name
- end
-
- ##
- # A method/attribute is documented if any of the following is true:
- # - it was marked with :nodoc:;
- # - it has a comment;
- # - it is an alias for a documented method;
- # - it has a +#see+ method that is documented.
-
- def documented?
- super or
- (is_alias_for and is_alias_for.documented?) or
- (see and see.documented?)
- end
-
- ##
- # A method/attribute to look at,
- # in particular if this method/attribute has no documentation.
- #
- # It can be a method/attribute of the superclass or of an included module,
- # including the Kernel module, which is always appended to the included
- # modules.
- #
- # Returns +nil+ if there is no such method/attribute.
- # The +#is_alias_for+ method/attribute, if any, is not included.
- #
- # Templates may generate a "see also ..." if this method/attribute
- # has documentation, and "see ..." if it does not.
-
- def see
- @see = find_see if @see == false
- @see
- end
-
- ##
- # Sets the store for this class or module and its contained code objects.
-
- def store= store
- super
-
- @file = @store.add_file @file.full_name if @file
- end
-
- def find_see # :nodoc:
- return nil if singleton || is_alias_for
-
- # look for the method
- other = find_method_or_attribute name
- return other if other
-
- # if it is a setter, look for a getter
- return nil unless name =~ /[a-z_]=$/i # avoid == or ===
- return find_method_or_attribute name[0..-2]
- end
-
- def find_method_or_attribute name # :nodoc:
- return nil unless parent.respond_to? :ancestors
-
- searched = parent.ancestors
- kernel = @store.modules_hash['Kernel']
-
- searched << kernel if kernel &&
- parent != kernel && !searched.include?(kernel)
-
- searched.each do |ancestor|
- next if String === ancestor
- next if parent == ancestor
-
- other = ancestor.find_method_named('#' + name) ||
- ancestor.find_attribute_named(name)
-
- return other if other
- end
-
- nil
- end
-
- ##
- # Abstract method. Contexts in their building phase call this
- # to register a new alias for this known method/attribute.
- #
- # - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>;
- # - adds +self+ as an alias for the new method or attribute
- # - adds the method or attribute to #aliases
- # - adds the method or attribute to +context+.
-
- def add_alias(an_alias, context)
- raise NotImplementedError
- end
-
- ##
- # HTML fragment reference for this method
-
- def aref
- type = singleton ? 'c' : 'i'
- # % characters are not allowed in html names => dash instead
- "#{aref_prefix}-#{type}-#{html_name}"
- end
-
- ##
- # Prefix for +aref+, defined by subclasses.
-
- def aref_prefix
- raise NotImplementedError
- end
-
- ##
- # Attempts to sanitize the content passed by the Ruby parser:
- # remove outer parentheses, etc.
-
- def block_params=(value)
- # 'yield.to_s' or 'assert yield, msg'
- return @block_params = '' if value =~ /^[\.,]/
-
- # remove trailing 'if/unless ...'
- return @block_params = '' if value =~ /^(if|unless)\s/
-
- value = $1.strip if value =~ /^(.+)\s(if|unless)\s/
-
- # outer parentheses
- value = $1 if value =~ /^\s*\((.*)\)\s*$/
- value = value.strip
-
- # proc/lambda
- return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/
-
- # surrounding +...+ or [...]
- value = $1.strip if value =~ /^\+(.*)\+$/
- value = $1.strip if value =~ /^\[(.*)\]$/
-
- return @block_params = '' if value.empty?
-
- # global variable
- return @block_params = 'str' if value =~ /^\$[&0-9]$/
-
- # wipe out array/hash indices
- value.gsub!(/(\w)\[[^\[]+\]/, '\1')
-
- # remove @ from class/instance variables
- value.gsub!(/@@?([a-z0-9_]+)/, '\1')
-
- # method calls => method name
- value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do
- case $2
- when 'to_s' then $1
- when 'const_get' then 'const'
- when 'new' then
- $1.split('::').last. # ClassName => class_name
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
- downcase
- else
- $2
- end
- end
-
- # class prefixes
- value.gsub!(/[A-Za-z0-9_:]+::/, '')
-
- # simple expressions
- value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/
-
- @block_params = value.strip
- end
-
- ##
- # HTML id-friendly method/attribute name
-
- def html_name
- require 'cgi/util'
-
- CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
- end
-
- ##
- # Full method/attribute name including namespace
-
- def full_name
- @full_name ||= "#{parent_name}#{pretty_name}"
- end
-
- def inspect # :nodoc:
- alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
- visibility = self.visibility
- visibility = "forced #{visibility}" if force_documentation
- "#<%s:0x%x %s (%s)%s>" % [
- self.class, object_id,
- full_name,
- visibility,
- alias_for,
- ]
- end
-
- ##
- # '::' for a class method/attribute, '#' for an instance method.
-
- def name_prefix
- @singleton ? '::' : '#'
- end
-
- ##
- # Name for output to HTML. For class methods the full name with a "." is
- # used like +SomeClass.method_name+. For instance methods the class name is
- # used if +context+ does not match the parent.
- #
- # This is to help prevent people from using :: to call class methods.
-
- def output_name context
- return "#{name_prefix}#{@name}" if context == parent
-
- "#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
- end
-
- ##
- # Method/attribute name with class/instance indicator
-
- def pretty_name
- "#{name_prefix}#{@name}"
- end
-
- ##
- # Type of method/attribute (class or instance)
-
- def type
- singleton ? 'class' : 'instance'
- end
-
- ##
- # Path to this method for use with HTML generator output.
-
- def path
- "#{@parent.path}##{aref}"
- end
-
- ##
- # Name of our parent with special handling for un-marshaled methods
-
- def parent_name
- @parent_name || super
- end
-
- def pretty_print q # :nodoc:
- alias_for =
- if @is_alias_for.respond_to? :name then
- "alias for #{@is_alias_for.name}"
- elsif Array === @is_alias_for then
- "alias for #{@is_alias_for.last}"
- end
-
- q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
- if alias_for then
- q.breakable
- q.text alias_for
- end
-
- if text then
- q.breakable
- q.text "text:"
- q.breakable
- q.pp @text
- end
-
- unless comment.empty? then
- q.breakable
- q.text "comment:"
- q.breakable
- q.pp @comment
- end
- end
- end
-
- ##
- # Used by RDoc::Generator::JsonIndex to create a record for the search
- # engine.
-
- def search_record
- [
- @name,
- full_name,
- @name,
- @parent.full_name,
- path,
- params,
- snippet(@comment),
- ]
- end
-
- def to_s # :nodoc:
- if @is_alias_for
- "#{self.class.name}: #{full_name} -> #{is_alias_for}"
- else
- "#{self.class.name}: #{full_name}"
- end
- end
-
-end
-
diff --git a/lib/rdoc/mixin.rb b/lib/rdoc/mixin.rb
deleted file mode 100644
index 379d7cc526..0000000000
--- a/lib/rdoc/mixin.rb
+++ /dev/null
@@ -1,121 +0,0 @@
-# frozen_string_literal: true
-##
-# A Mixin adds features from a module into another context. RDoc::Include and
-# RDoc::Extend are both mixins.
-
-class RDoc::Mixin < RDoc::CodeObject
-
- ##
- # Name of included module
-
- attr_accessor :name
-
- ##
- # Creates a new Mixin for +name+ with +comment+
-
- def initialize(name, comment)
- super()
- @name = name
- self.comment = comment
- @module = nil # cache for module if found
- end
-
- ##
- # Mixins are sorted by name
-
- def <=> other
- return unless self.class === other
-
- name <=> other.name
- end
-
- def == other # :nodoc:
- self.class === other and @name == other.name
- end
-
- alias eql? == # :nodoc:
-
- ##
- # Full name based on #module
-
- def full_name
- m = self.module
- RDoc::ClassModule === m ? m.full_name : @name
- end
-
- def hash # :nodoc:
- [@name, self.module].hash
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %s.%s %s>" % [
- self.class,
- object_id,
- parent_name, self.class.name.downcase, @name,
- ]
- end
-
- ##
- # Attempts to locate the included module object. Returns the name if not
- # known.
- #
- # The scoping rules of Ruby to resolve the name of an included module are:
- # - first look into the children of the current context;
- # - if not found, look into the children of included modules,
- # in reverse inclusion order;
- # - if still not found, go up the hierarchy of names.
- #
- # This method has <code>O(n!)</code> behavior when the module calling
- # include is referencing nonexistent modules. Avoid calling #module until
- # after all the files are parsed. This behavior is due to ruby's constant
- # lookup behavior.
- #
- # As of the beginning of October, 2011, no gem includes nonexistent modules.
-
- def module
- return @module if @module
-
- # search the current context
- return @name unless parent
- full_name = parent.child_name(@name)
- @module = @store.modules_hash[full_name]
- return @module if @module
- return @name if @name =~ /^::/
-
- # search the includes before this one, in reverse order
- searched = parent.includes.take_while { |i| i != self }.reverse
- searched.each do |i|
- inc = i.module
- next if String === inc
- full_name = inc.child_name(@name)
- @module = @store.modules_hash[full_name]
- return @module if @module
- end
-
- # go up the hierarchy of names
- up = parent.parent
- while up
- full_name = up.child_name(@name)
- @module = @store.modules_hash[full_name]
- return @module if @module
- up = up.parent
- end
-
- @name
- end
-
- ##
- # Sets the store for this class or module and its contained code objects.
-
- def store= store
- super
-
- @file = @store.add_file @file.full_name if @file
- end
-
- def to_s # :nodoc:
- "#{self.class.name.downcase} #@name in: #{parent}"
- end
-
-end
-
diff --git a/lib/rdoc/normal_class.rb b/lib/rdoc/normal_class.rb
deleted file mode 100644
index 68dfa7d4a3..0000000000
--- a/lib/rdoc/normal_class.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# frozen_string_literal: true
-##
-# A normal class, neither singleton nor anonymous
-
-class RDoc::NormalClass < RDoc::ClassModule
-
- ##
- # The ancestors of this class including modules. Unlike Module#ancestors,
- # this class is not included in the result. The result will contain both
- # RDoc::ClassModules and Strings.
-
- def ancestors
- if String === superclass then
- super << superclass
- elsif superclass then
- ancestors = super
- ancestors << superclass
- ancestors.concat superclass.ancestors
- else
- super
- end
- end
-
- def aref_prefix # :nodoc:
- 'class'
- end
-
- ##
- # The definition of this class, <tt>class MyClassName</tt>
-
- def definition
- "class #{full_name}"
- end
-
- def direct_ancestors
- superclass ? super + [superclass] : super
- end
-
- def inspect # :nodoc:
- superclass = @superclass ? " < #{@superclass}" : nil
- "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
- self.class, object_id,
- full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases
- ]
- end
-
- def to_s # :nodoc:
- display = "#{self.class.name} #{self.full_name}"
- if superclass
- display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
- end
- display += ' -> ' + is_alias_for.to_s if is_alias_for
- display
- end
-
- def pretty_print q # :nodoc:
- superclass = @superclass ? " < #{@superclass}" : nil
-
- q.group 2, "[class #{full_name}#{superclass}", "]" do
- q.breakable
- q.text "includes:"
- q.breakable
- q.seplist @includes do |inc| q.pp inc end
-
- q.breakable
- q.text "constants:"
- q.breakable
- q.seplist @constants do |const| q.pp const end
-
- q.breakable
- q.text "attributes:"
- q.breakable
- q.seplist @attributes do |attr| q.pp attr end
-
- q.breakable
- q.text "methods:"
- q.breakable
- q.seplist @method_list do |meth| q.pp meth end
-
- q.breakable
- q.text "aliases:"
- q.breakable
- q.seplist @aliases do |aliaz| q.pp aliaz end
-
- q.breakable
- q.text "comment:"
- q.breakable
- q.pp comment
- end
- end
-
-end
-
diff --git a/lib/rdoc/normal_module.rb b/lib/rdoc/normal_module.rb
deleted file mode 100644
index edf29f8f1c..0000000000
--- a/lib/rdoc/normal_module.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# frozen_string_literal: true
-##
-# A normal module, like NormalClass
-
-class RDoc::NormalModule < RDoc::ClassModule
-
- def aref_prefix # :nodoc:
- 'module'
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
- self.class, object_id,
- full_name, @includes, @extends, @attributes, @method_list, @aliases
- ]
- end
-
- ##
- # The definition of this module, <tt>module MyModuleName</tt>
-
- def definition
- "module #{full_name}"
- end
-
- ##
- # This is a module, returns true
-
- def module?
- true
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[module #{full_name}:", "]" do
- q.breakable
- q.text "includes:"
- q.breakable
- q.seplist @includes do |inc| q.pp inc end
- q.breakable
-
- q.breakable
- q.text "constants:"
- q.breakable
- q.seplist @constants do |const| q.pp const end
-
- q.text "attributes:"
- q.breakable
- q.seplist @attributes do |attr| q.pp attr end
- q.breakable
-
- q.text "methods:"
- q.breakable
- q.seplist @method_list do |meth| q.pp meth end
- q.breakable
-
- q.text "aliases:"
- q.breakable
- q.seplist @aliases do |aliaz| q.pp aliaz end
- q.breakable
-
- q.text "comment:"
- q.breakable
- q.pp comment
- end
- end
-
- ##
- # Modules don't have one, raises NoMethodError
-
- def superclass
- raise NoMethodError, "#{full_name} is a module"
- end
-
-end
-
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
deleted file mode 100644
index eed0f6b39b..0000000000
--- a/lib/rdoc/options.rb
+++ /dev/null
@@ -1,1329 +0,0 @@
-# frozen_string_literal: true
-require 'optparse'
-require 'pathname'
-
-##
-# RDoc::Options handles the parsing and storage of options
-#
-# == Saved Options
-#
-# You can save some options like the markup format in the
-# <tt>.rdoc_options</tt> file in your gem. The easiest way to do this is:
-#
-# rdoc --markup tomdoc --write-options
-#
-# Which will automatically create the file and fill it with the options you
-# specified.
-#
-# The following options will not be saved since they interfere with the user's
-# preferences or with the normal operation of RDoc:
-#
-# * +--coverage-report+
-# * +--dry-run+
-# * +--encoding+
-# * +--force-update+
-# * +--format+
-# * +--pipe+
-# * +--quiet+
-# * +--template+
-# * +--verbose+
-#
-# == Custom Options
-#
-# Generators can hook into RDoc::Options to add generator-specific command
-# line options.
-#
-# When <tt>--format</tt> is encountered in ARGV, RDoc calls ::setup_options on
-# the generator class to add extra options to the option parser. Options for
-# custom generators must occur after <tt>--format</tt>. <tt>rdoc --help</tt>
-# will list options for all installed generators.
-#
-# Example:
-#
-# class RDoc::Generator::Spellcheck
-# RDoc::RDoc.add_generator self
-#
-# def self.setup_options rdoc_options
-# op = rdoc_options.option_parser
-#
-# op.on('--spell-dictionary DICTIONARY',
-# RDoc::Options::Path) do |dictionary|
-# rdoc_options.spell_dictionary = dictionary
-# end
-# end
-# end
-#
-# Of course, RDoc::Options does not respond to +spell_dictionary+ by default
-# so you will need to add it:
-#
-# class RDoc::Options
-#
-# ##
-# # The spell dictionary used by the spell-checking plugin.
-#
-# attr_accessor :spell_dictionary
-#
-# end
-#
-# == Option Validators
-#
-# OptionParser validators will validate and cast user input values. In
-# addition to the validators that ship with OptionParser (String, Integer,
-# Float, TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.),
-# RDoc::Options adds Path, PathArray and Template.
-
-class RDoc::Options
-
- ##
- # The deprecated options.
-
- DEPRECATED = {
- '--accessor' => 'support discontinued',
- '--diagram' => 'support discontinued',
- '--help-output' => 'support discontinued',
- '--image-format' => 'was an option for --diagram',
- '--inline-source' => 'source code is now always inlined',
- '--merge' => 'ri now always merges class information',
- '--one-file' => 'support discontinued',
- '--op-name' => 'support discontinued',
- '--opname' => 'support discontinued',
- '--promiscuous' => 'files always only document their content',
- '--ri-system' => 'Ruby installers use other techniques',
- }
-
- ##
- # RDoc options ignored (or handled specially) by --write-options
-
- SPECIAL = %w[
- coverage_report
- dry_run
- encoding
- files
- force_output
- force_update
- generator
- generator_name
- generator_options
- generators
- op_dir
- page_dir
- option_parser
- pipe
- rdoc_include
- root
- static_path
- stylesheet_url
- template
- template_dir
- update_output_dir
- verbosity
- write_options
- ]
-
- ##
- # Option validator for OptionParser that matches a directory that exists on
- # the filesystem.
-
- Directory = Object.new
-
- ##
- # Option validator for OptionParser that matches a file or directory that
- # exists on the filesystem.
-
- Path = Object.new
-
- ##
- # Option validator for OptionParser that matches a comma-separated list of
- # files or directories that exist on the filesystem.
-
- PathArray = Object.new
-
- ##
- # Option validator for OptionParser that matches a template directory for an
- # installed generator that lives in
- # <tt>"rdoc/generator/template/#{template_name}"</tt>
-
- Template = Object.new
-
- ##
- # Character-set for HTML output. #encoding is preferred over #charset
-
- attr_accessor :charset
-
- ##
- # If true, RDoc will not write any files.
-
- attr_accessor :dry_run
-
- ##
- # The output encoding. All input files will be transcoded to this encoding.
- #
- # The default encoding is UTF-8. This is set via --encoding.
-
- attr_accessor :encoding
-
- ##
- # Files matching this pattern will be excluded
-
- attr_writer :exclude
-
- ##
- # The list of files to be processed
-
- attr_accessor :files
-
- ##
- # Create the output even if the output directory does not look
- # like an rdoc output directory
-
- attr_accessor :force_output
-
- ##
- # Scan newer sources than the flag file if true.
-
- attr_accessor :force_update
-
- ##
- # Formatter to mark up text with
-
- attr_accessor :formatter
-
- ##
- # Description of the output generator (set with the <tt>--format</tt> option)
-
- attr_accessor :generator
-
- ##
- # For #==
-
- attr_reader :generator_name # :nodoc:
-
- ##
- # Loaded generator options. Used to prevent --help from loading the same
- # options multiple times.
-
- attr_accessor :generator_options
-
- ##
- # Old rdoc behavior: hyperlink all words that match a method name,
- # even if not preceded by '#' or '::'
-
- attr_accessor :hyperlink_all
-
- ##
- # Include line numbers in the source code
-
- attr_accessor :line_numbers
-
- ##
- # The output locale.
-
- attr_accessor :locale
-
- ##
- # The directory where locale data live.
-
- attr_accessor :locale_dir
-
- ##
- # Name of the file, class or module to display in the initial index page (if
- # not specified the first file we encounter is used)
-
- attr_accessor :main_page
-
- ##
- # The default markup format. The default is 'rdoc'. 'markdown', 'tomdoc'
- # and 'rd' are also built-in.
-
- attr_accessor :markup
-
- ##
- # If true, only report on undocumented files
-
- attr_accessor :coverage_report
-
- ##
- # The name of the output directory
-
- attr_accessor :op_dir
-
- ##
- # The OptionParser for this instance
-
- attr_accessor :option_parser
-
- ##
- # Output heading decorations?
- attr_accessor :output_decoration
-
- ##
- # Directory where guides, FAQ, and other pages not associated with a class
- # live. You may leave this unset if these are at the root of your project.
-
- attr_accessor :page_dir
-
- ##
- # Is RDoc in pipe mode?
-
- attr_accessor :pipe
-
- ##
- # Array of directories to search for files to satisfy an :include:
-
- attr_accessor :rdoc_include
-
- ##
- # Root of the source documentation will be generated for. Set this when
- # building documentation outside the source directory. Defaults to the
- # current directory.
-
- attr_accessor :root
-
- ##
- # Include the '#' at the front of hyperlinked instance method names
-
- attr_accessor :show_hash
-
- ##
- # Directory to copy static files from
-
- attr_accessor :static_path
-
- ##
- # The number of columns in a tab
-
- attr_accessor :tab_width
-
- ##
- # Template to be used when generating output
-
- attr_accessor :template
-
- ##
- # Directory the template lives in
-
- attr_accessor :template_dir
-
- ##
- # Additional template stylesheets
-
- attr_accessor :template_stylesheets
-
- ##
- # Documentation title
-
- attr_accessor :title
-
- ##
- # Should RDoc update the timestamps in the output dir?
-
- attr_accessor :update_output_dir
-
- ##
- # Verbosity, zero means quiet
-
- attr_accessor :verbosity
-
- ##
- # URL of web cvs frontend
-
- attr_accessor :webcvs
-
- ##
- # Minimum visibility of a documented method. One of +:public+, +:protected+,
- # +:private+ or +:nodoc+.
- #
- # The +:nodoc+ visibility ignores all directives related to visibility. The
- # other visibilities may be overridden on a per-method basis with the :doc:
- # directive.
-
- attr_reader :visibility
-
- ##
- # Indicates if files of test suites should be skipped
- attr_accessor :skip_tests
-
- def initialize loaded_options = nil # :nodoc:
- init_ivars
- override loaded_options if loaded_options
- end
-
- def init_ivars # :nodoc:
- @dry_run = false
- @exclude = %w[
- ~\z \.orig\z \.rej\z \.bak\z
- \.gemspec\z
- ]
- @files = nil
- @force_output = false
- @force_update = true
- @generator = nil
- @generator_name = nil
- @generator_options = []
- @generators = RDoc::RDoc::GENERATORS
- @hyperlink_all = false
- @line_numbers = false
- @locale = nil
- @locale_name = nil
- @locale_dir = 'locale'
- @main_page = nil
- @markup = 'rdoc'
- @coverage_report = false
- @op_dir = nil
- @page_dir = nil
- @pipe = false
- @output_decoration = true
- @rdoc_include = []
- @root = Pathname(Dir.pwd)
- @show_hash = false
- @static_path = []
- @stylesheet_url = nil # TODO remove in RDoc 4
- @tab_width = 8
- @template = nil
- @template_dir = nil
- @template_stylesheets = []
- @title = nil
- @update_output_dir = true
- @verbosity = 1
- @visibility = :protected
- @webcvs = nil
- @write_options = false
- @encoding = Encoding::UTF_8
- @charset = @encoding.name
- @skip_tests = true
- end
-
- def init_with map # :nodoc:
- init_ivars
-
- encoding = map['encoding']
- @encoding = encoding ? Encoding.find(encoding) : encoding
-
- @charset = map['charset']
- @exclude = map['exclude']
- @generator_name = map['generator_name']
- @hyperlink_all = map['hyperlink_all']
- @line_numbers = map['line_numbers']
- @locale_name = map['locale_name']
- @locale_dir = map['locale_dir']
- @main_page = map['main_page']
- @markup = map['markup']
- @op_dir = map['op_dir']
- @show_hash = map['show_hash']
- @tab_width = map['tab_width']
- @template_dir = map['template_dir']
- @title = map['title']
- @visibility = map['visibility']
- @webcvs = map['webcvs']
-
- @rdoc_include = sanitize_path map['rdoc_include']
- @static_path = sanitize_path map['static_path']
- end
-
- def yaml_initialize tag, map # :nodoc:
- init_with map
- end
-
- def override map # :nodoc:
- if map.has_key?('encoding')
- encoding = map['encoding']
- @encoding = encoding ? Encoding.find(encoding) : encoding
- end
-
- @charset = map['charset'] if map.has_key?('charset')
- @exclude = map['exclude'] if map.has_key?('exclude')
- @generator_name = map['generator_name'] if map.has_key?('generator_name')
- @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
- @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
- @locale_name = map['locale_name'] if map.has_key?('locale_name')
- @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
- @main_page = map['main_page'] if map.has_key?('main_page')
- @markup = map['markup'] if map.has_key?('markup')
- @op_dir = map['op_dir'] if map.has_key?('op_dir')
- @page_dir = map['page_dir'] if map.has_key?('page_dir')
- @show_hash = map['show_hash'] if map.has_key?('show_hash')
- @tab_width = map['tab_width'] if map.has_key?('tab_width')
- @template_dir = map['template_dir'] if map.has_key?('template_dir')
- @title = map['title'] if map.has_key?('title')
- @visibility = map['visibility'] if map.has_key?('visibility')
- @webcvs = map['webcvs'] if map.has_key?('webcvs')
-
- if map.has_key?('rdoc_include')
- @rdoc_include = sanitize_path map['rdoc_include']
- end
- if map.has_key?('static_path')
- @static_path = sanitize_path map['static_path']
- end
- end
-
- def == other # :nodoc:
- self.class === other and
- @encoding == other.encoding and
- @generator_name == other.generator_name and
- @hyperlink_all == other.hyperlink_all and
- @line_numbers == other.line_numbers and
- @locale == other.locale and
- @locale_dir == other.locale_dir and
- @main_page == other.main_page and
- @markup == other.markup and
- @op_dir == other.op_dir and
- @rdoc_include == other.rdoc_include and
- @show_hash == other.show_hash and
- @static_path == other.static_path and
- @tab_width == other.tab_width and
- @template == other.template and
- @title == other.title and
- @visibility == other.visibility and
- @webcvs == other.webcvs
- end
-
- ##
- # Check that the files on the command line exist
-
- def check_files
- @files.delete_if do |file|
- if File.exist? file then
- if File.readable? file then
- false
- else
- warn "file '#{file}' not readable"
-
- true
- end
- else
- warn "file '#{file}' not found"
-
- true
- end
- end
- end
-
- ##
- # Ensure only one generator is loaded
-
- def check_generator
- if @generator then
- raise OptionParser::InvalidOption,
- "generator already set to #{@generator_name}"
- end
- end
-
- ##
- # Set the title, but only if not already set. Used to set the title
- # from a source file, so that a title set from the command line
- # will have the priority.
-
- def default_title=(string)
- @title ||= string
- end
-
- ##
- # For dumping YAML
-
- def to_yaml(*options) # :nodoc:
- encoding = @encoding ? @encoding.name : nil
-
- yaml = {}
- yaml['encoding'] = encoding
- yaml['static_path'] = sanitize_path(@static_path)
- yaml['rdoc_include'] = sanitize_path(@rdoc_include)
- yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
-
- ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
- ivars -= SPECIAL
-
- ivars.sort.each do |ivar|
- yaml[ivar] = instance_variable_get("@#{ivar}")
- end
- yaml.to_yaml
- end
-
- ##
- # Create a regexp for #exclude
-
- def exclude
- if @exclude.nil? or Regexp === @exclude then
- # done, #finish is being re-run
- @exclude
- elsif @exclude.empty? then
- nil
- else
- Regexp.new(@exclude.join("|"))
- end
- end
-
- ##
- # Completes any unfinished option setup business such as filtering for
- # existent files, creating a regexp for #exclude and setting a default
- # #template.
-
- def finish
- if @write_options then
- write_options
- exit
- end
-
- @op_dir ||= 'doc'
-
- @rdoc_include << "." if @rdoc_include.empty?
- root = @root.to_s
- @rdoc_include << root unless @rdoc_include.include?(root)
-
- @exclude = self.exclude
-
- finish_page_dir
-
- check_files
-
- # If no template was specified, use the default template for the output
- # formatter
-
- unless @template then
- @template = @generator_name
- @template_dir = template_dir_for @template
- end
-
- if @locale_name
- @locale = RDoc::I18n::Locale[@locale_name]
- @locale.load(@locale_dir)
- else
- @locale = nil
- end
-
- self
- end
-
- ##
- # Fixes the page_dir to be relative to the root_dir and adds the page_dir to
- # the files list.
-
- def finish_page_dir
- return unless @page_dir
-
- @files << @page_dir
-
- page_dir = Pathname(@page_dir)
- begin
- page_dir = page_dir.expand_path.relative_path_from @root
- rescue ArgumentError
- # On Windows, sometimes crosses different drive letters.
- page_dir = page_dir.expand_path
- end
-
- @page_dir = page_dir
- end
-
- ##
- # Returns a properly-space list of generators and their descriptions.
-
- def generator_descriptions
- lengths = []
-
- generators = RDoc::RDoc::GENERATORS.map do |name, generator|
- lengths << name.length
-
- description = generator::DESCRIPTION if
- generator.const_defined? :DESCRIPTION
-
- [name, description]
- end
-
- longest = lengths.max
-
- generators.sort.map do |name, description|
- if description then
- " %-*s - %s" % [longest, name, description]
- else
- " #{name}"
- end
- end.join "\n"
- end
-
- ##
- # Parses command line options.
-
- def parse argv
- ignore_invalid = true
-
- argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
-
- opts = OptionParser.new do |opt|
- @option_parser = opt
- opt.program_name = File.basename $0
- opt.version = RDoc::VERSION
- opt.release = nil
- opt.summary_indent = ' ' * 4
- opt.banner = <<-EOF
-Usage: #{opt.program_name} [options] [names...]
-
- Files are parsed, and the information they contain collected, before any
- output is produced. This allows cross references between all files to be
- resolved. If a name is a directory, it is traversed. If no names are
- specified, all Ruby files in the current directory (and subdirectories) are
- processed.
-
- How RDoc generates output depends on the output formatter being used, and on
- the options you give.
-
- Options can be specified via the RDOCOPT environment variable, which
- functions similar to the RUBYOPT environment variable for ruby.
-
- $ export RDOCOPT="--show-hash"
-
- will make rdoc show hashes in method links by default. Command-line options
- always will override those in RDOCOPT.
-
- Available formatters:
-
-#{generator_descriptions}
-
- RDoc understands the following file formats:
-
- EOF
-
- parsers = Hash.new { |h,parser| h[parser] = [] }
-
- RDoc::Parser.parsers.each do |regexp, parser|
- parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
- end
-
- parsers.sort.each do |parser, regexp|
- opt.banner += " - #{parser}: #{regexp.join ', '}\n"
- end
- opt.banner += " - TomDoc: Only in ruby files\n"
-
- opt.banner += "\n The following options are deprecated:\n\n"
-
- name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
-
- DEPRECATED.sort_by { |k,| k }.each do |name, reason|
- opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason]
- end
-
- opt.accept Template do |template|
- template_dir = template_dir_for template
-
- unless template_dir then
- $stderr.puts "could not find template #{template}"
- nil
- else
- [template, template_dir]
- end
- end
-
- opt.accept Directory do |directory|
- directory = File.expand_path directory
-
- raise OptionParser::InvalidArgument unless File.directory? directory
-
- directory
- end
-
- opt.accept Path do |path|
- path = File.expand_path path
-
- raise OptionParser::InvalidArgument unless File.exist? path
-
- path
- end
-
- opt.accept PathArray do |paths,|
- paths = if paths then
- paths.split(',').map { |d| d unless d.empty? }
- end
-
- paths.map do |path|
- path = File.expand_path path
-
- raise OptionParser::InvalidArgument unless File.exist? path
-
- path
- end
- end
-
- opt.separator nil
- opt.separator "Parsing options:"
- opt.separator nil
-
- opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
- "Specifies the output encoding. All files",
- "read will be converted to this encoding.",
- "The default encoding is UTF-8.",
- "--encoding is preferred over --charset") do |value|
- @encoding = Encoding.find value
- @charset = @encoding.name # may not be valid value
- end
-
- opt.separator nil
-
- opt.on("--locale=NAME",
- "Specifies the output locale.") do |value|
- @locale_name = value
- end
-
- opt.on("--locale-data-dir=DIR",
- "Specifies the directory where locale data live.") do |value|
- @locale_dir = value
- end
-
- opt.separator nil
-
- opt.on("--all", "-a",
- "Synonym for --visibility=private.") do |value|
- @visibility = :private
- end
-
- opt.separator nil
-
- opt.on("--exclude=PATTERN", "-x", Regexp,
- "Do not process files or directories",
- "matching PATTERN.") do |value|
- @exclude << value
- end
-
- opt.separator nil
-
- opt.on("--no-skipping-tests", nil,
- "Don't skip generating documentation for test and spec files") do |value|
- @skip_tests = false
- end
-
- opt.separator nil
-
- opt.on("--extension=NEW=OLD", "-E",
- "Treat files ending with .new as if they",
- "ended with .old. Using '-E cgi=rb' will",
- "cause xxx.cgi to be parsed as a Ruby file.") do |value|
- new, old = value.split(/=/, 2)
-
- unless new and old then
- raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
- end
-
- unless RDoc::Parser.alias_extension old, new then
- raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
- end
- end
-
- opt.separator nil
-
- opt.on("--[no-]force-update", "-U",
- "Forces rdoc to scan all sources even if",
- "no files are newer than the flag file.") do |value|
- @force_update = value
- end
-
- opt.separator nil
-
- opt.on("--pipe", "-p",
- "Convert RDoc on stdin to HTML") do
- @pipe = true
- end
-
- opt.separator nil
-
- opt.on("--tab-width=WIDTH", "-w", Integer,
- "Set the width of tab characters.") do |value|
- raise OptionParser::InvalidArgument,
- "#{value} is an invalid tab width" if value <= 0
- @tab_width = value
- end
-
- opt.separator nil
-
- opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES + [:nodoc],
- "Minimum visibility to document a method.",
- "One of 'public', 'protected' (the default),",
- "'private' or 'nodoc' (show everything)") do |value|
- @visibility = value
- end
-
- opt.separator nil
-
- markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
-
- opt.on("--markup=MARKUP", markup_formats,
- "The markup format for the named files.",
- "The default is rdoc. Valid values are:",
- markup_formats.join(', ')) do |value|
- @markup = value
- end
-
- opt.separator nil
-
- opt.on("--root=ROOT", Directory,
- "Root of the source tree documentation",
- "will be generated for. Set this when",
- "building documentation outside the",
- "source directory. Default is the",
- "current directory.") do |root|
- @root = Pathname(root)
- end
-
- opt.separator nil
-
- opt.on("--page-dir=DIR", Directory,
- "Directory where guides, your FAQ or",
- "other pages not associated with a class",
- "live. Set this when you don't store",
- "such files at your project root.",
- "NOTE: Do not use the same file name in",
- "the page dir and the root of your project") do |page_dir|
- @page_dir = page_dir
- end
-
- opt.separator nil
- opt.separator "Common generator options:"
- opt.separator nil
-
- opt.on("--force-output", "-O",
- "Forces rdoc to write the output files,",
- "even if the output directory exists",
- "and does not seem to have been created",
- "by rdoc.") do |value|
- @force_output = value
- end
-
- opt.separator nil
-
- generator_text = @generators.keys.map { |name| " #{name}" }.sort
-
- opt.on("-f", "--fmt=FORMAT", "--format=FORMAT", @generators.keys,
- "Set the output formatter. One of:", *generator_text) do |value|
- check_generator
-
- @generator_name = value.downcase
- setup_generator
- end
-
- opt.separator nil
-
- opt.on("--include=DIRECTORIES", "-i", PathArray,
- "Set (or add to) the list of directories to",
- "be searched when satisfying :include:",
- "requests. Can be used more than once.") do |value|
- @rdoc_include.concat value.map { |dir| dir.strip }
- end
-
- opt.separator nil
-
- opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
- "Prints a report on undocumented items.",
- "Does not generate files.") do |value|
- value = 0 if value.nil? # Integer converts -C to nil
-
- @coverage_report = value
- @force_update = true if value
- end
-
- opt.separator nil
-
- opt.on("--output=DIR", "--op", "-o",
- "Set the output directory.") do |value|
- @op_dir = value
- end
-
- opt.separator nil
-
- opt.on("-d",
- "Deprecated --diagram option.",
- "Prevents firing debug mode",
- "with legacy invocation.") do |value|
- end
-
- opt.separator nil
- opt.separator 'HTML generator options:'
- opt.separator nil
-
- opt.on("--charset=CHARSET", "-c",
- "Specifies the output HTML character-set.",
- "Use --encoding instead of --charset if",
- "available.") do |value|
- @charset = value
- end
-
- opt.separator nil
-
- opt.on("--hyperlink-all", "-A",
- "Generate hyperlinks for all words that",
- "correspond to known methods, even if they",
- "do not start with '#' or '::' (legacy",
- "behavior).") do |value|
- @hyperlink_all = value
- end
-
- opt.separator nil
-
- opt.on("--main=NAME", "-m",
- "NAME will be the initial page displayed.") do |value|
- @main_page = value
- end
-
- opt.separator nil
-
- opt.on("--[no-]line-numbers", "-N",
- "Include line numbers in the source code.",
- "By default, only the number of the first",
- "line is displayed, in a leading comment.") do |value|
- @line_numbers = value
- end
-
- opt.separator nil
-
- opt.on("--show-hash", "-H",
- "A name of the form #name in a comment is a",
- "possible hyperlink to an instance method",
- "name. When displayed, the '#' is removed",
- "unless this option is specified.") do |value|
- @show_hash = value
- end
-
- opt.separator nil
-
- opt.on("--template=NAME", "-T", Template,
- "Set the template used when generating",
- "output. The default depends on the",
- "formatter used.") do |(template, template_dir)|
- @template = template
- @template_dir = template_dir
- end
-
- opt.separator nil
-
- opt.on("--template-stylesheets=FILES", PathArray,
- "Set (or add to) the list of files to",
- "include with the html template.") do |value|
- @template_stylesheets.concat value
- end
-
- opt.separator nil
-
- opt.on("--title=TITLE", "-t",
- "Set TITLE as the title for HTML output.") do |value|
- @title = value
- end
-
- opt.separator nil
-
- opt.on("--copy-files=PATH", Path,
- "Specify a file or directory to copy static",
- "files from.",
- "If a file is given it will be copied into",
- "the output dir. If a directory is given the",
- "entire directory will be copied.",
- "You can use this multiple times") do |value|
- @static_path << value
- end
-
- opt.separator nil
-
- opt.on("--webcvs=URL", "-W",
- "Specify a URL for linking to a web frontend",
- "to CVS. If the URL contains a '\%s', the",
- "name of the current file will be",
- "substituted; if the URL doesn't contain a",
- "'\%s', the filename will be appended to it.") do |value|
- @webcvs = value
- end
-
- opt.separator nil
- opt.separator "ri generator options:"
- opt.separator nil
-
- opt.on("--ri", "-r",
- "Generate output for use by `ri`. The files",
- "are stored in the '.rdoc' directory under",
- "your home directory unless overridden by a",
- "subsequent --op parameter, so no special",
- "privileges are needed.") do |value|
- check_generator
-
- @generator_name = "ri"
- @op_dir ||= RDoc::RI::Paths::HOMEDIR
- setup_generator
- end
-
- opt.separator nil
-
- opt.on("--ri-site", "-R",
- "Generate output for use by `ri`. The files",
- "are stored in a site-wide directory,",
- "making them accessible to others, so",
- "special privileges are needed.") do |value|
- check_generator
-
- @generator_name = "ri"
- @op_dir = RDoc::RI::Paths.site_dir
- setup_generator
- end
-
- opt.separator nil
- opt.separator "Generic options:"
- opt.separator nil
-
- opt.on("--write-options",
- "Write .rdoc_options to the current",
- "directory with the given options. Not all",
- "options will be used. See RDoc::Options",
- "for details.") do |value|
- @write_options = true
- end
-
- opt.separator nil
-
- opt.on("--[no-]dry-run",
- "Don't write any files") do |value|
- @dry_run = value
- end
-
- opt.separator nil
-
- opt.on("-D", "--[no-]debug",
- "Displays lots on internal stuff.") do |value|
- $DEBUG_RDOC = value
- end
-
- opt.separator nil
-
- opt.on("--[no-]ignore-invalid",
- "Ignore invalid options and continue",
- "(default true).") do |value|
- ignore_invalid = value
- end
-
- opt.separator nil
-
- opt.on("--quiet", "-q",
- "Don't show progress as we parse.") do |value|
- @verbosity = 0
- end
-
- opt.separator nil
-
- opt.on("--verbose", "-V",
- "Display extra progress as RDoc parses") do |value|
- @verbosity = 2
- end
-
- opt.separator nil
-
- opt.on("--version", "-v", "print the version") do
- puts opt.version
- exit
- end
-
- opt.separator nil
-
- opt.on("--help", "-h", "Display this help") do
- RDoc::RDoc::GENERATORS.each_key do |generator|
- setup_generator generator
- end
-
- puts opt.help
- exit
- end
-
- opt.separator nil
- end
-
- setup_generator 'darkfish' if
- argv.grep(/\A(-f|--fmt|--format|-r|-R|--ri|--ri-site)\b/).empty?
-
- deprecated = []
- invalid = []
-
- begin
- opts.parse! argv
- rescue OptionParser::ParseError => e
- if DEPRECATED[e.args.first] then
- deprecated << e.args.first
- elsif %w[--format --ri -r --ri-site -R].include? e.args.first then
- raise
- else
- invalid << e.args.join(' ')
- end
-
- retry
- end
-
- unless @generator then
- @generator = RDoc::Generator::Darkfish
- @generator_name = 'darkfish'
- end
-
- if @pipe and not argv.empty? then
- @pipe = false
- invalid << '-p (with files)'
- end
-
- unless quiet then
- deprecated.each do |opt|
- $stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
- end
- end
-
- unless invalid.empty? then
- invalid = "invalid options: #{invalid.join ', '}"
-
- if ignore_invalid then
- unless quiet then
- $stderr.puts invalid
- $stderr.puts '(invalid options are ignored)'
- end
- else
- unless quiet then
- $stderr.puts opts
- end
- $stderr.puts invalid
- exit 1
- end
- end
-
- @files = argv.dup
-
- self
- end
-
- ##
- # Don't display progress as we process the files
-
- def quiet
- @verbosity.zero?
- end
-
- ##
- # Set quietness to +bool+
-
- def quiet= bool
- @verbosity = bool ? 0 : 1
- end
-
- ##
- # Removes directories from +path+ that are outside the current directory
-
- def sanitize_path path
- require 'pathname'
- dot = Pathname.new('.').expand_path
-
- path.reject do |item|
- path = Pathname.new(item).expand_path
- is_reject = nil
- relative = nil
- begin
- relative = path.relative_path_from(dot).to_s
- rescue ArgumentError
- # On Windows, sometimes crosses different drive letters.
- is_reject = true
- else
- is_reject = relative.start_with? '..'
- end
- is_reject
- end
- end
-
- ##
- # Set up an output generator for the named +generator_name+.
- #
- # If the found generator responds to :setup_options it will be called with
- # the options instance. This allows generators to add custom options or set
- # default options.
-
- def setup_generator generator_name = @generator_name
- @generator = @generators[generator_name]
-
- unless @generator then
- raise OptionParser::InvalidArgument,
- "Invalid output formatter #{generator_name}"
- end
-
- return if @generator_options.include? @generator
-
- @generator_name = generator_name
- @generator_options << @generator
-
- if @generator.respond_to? :setup_options then
- @option_parser ||= OptionParser.new
- @generator.setup_options self
- end
- end
-
- ##
- # Finds the template dir for +template+
-
- def template_dir_for template
- template_path = File.join 'rdoc', 'generator', 'template', template
-
- $LOAD_PATH.map do |path|
- File.join File.expand_path(path), template_path
- end.find do |dir|
- File.directory? dir
- end
- end
-
- # Sets the minimum visibility of a documented method.
- #
- # Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
- #
- # When +:all+ is passed, visibility is set to +:private+, similarly to
- # RDOCOPT="--all", see #visibility for more information.
-
- def visibility= visibility
- case visibility
- when :all
- @visibility = :private
- else
- @visibility = visibility
- end
- end
-
- ##
- # Displays a warning using Kernel#warn if we're being verbose
-
- def warn message
- super message if @verbosity > 1
- end
-
- ##
- # Writes the YAML file .rdoc_options to the current directory containing the
- # parsed options.
-
- def write_options
- RDoc.load_yaml
-
- File.open '.rdoc_options', 'w' do |io|
- io.set_encoding Encoding::UTF_8
-
- io.print to_yaml
- end
- end
-
- ##
- # Loads options from .rdoc_options if the file exists, otherwise creates a
- # new RDoc::Options instance.
-
- def self.load_options
- options_file = File.expand_path '.rdoc_options'
- return RDoc::Options.new unless File.exist? options_file
-
- RDoc.load_yaml
-
- begin
- options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
- rescue Psych::SyntaxError
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
- end
-
- return RDoc::Options.new unless options # Allow empty file.
-
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
- RDoc::Options === options or Hash === options
-
- if Hash === options
- # Override the default values with the contents of YAML file.
- options = RDoc::Options.new options
- end
-
- options
- end
-
-end
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb
deleted file mode 100644
index 3bb6f5d1f2..0000000000
--- a/lib/rdoc/parser.rb
+++ /dev/null
@@ -1,294 +0,0 @@
-# -*- coding: us-ascii -*-
-# frozen_string_literal: true
-
-##
-# A parser is simple a class that subclasses RDoc::Parser and implements #scan
-# to fill in an RDoc::TopLevel with parsed data.
-#
-# The initialize method takes an RDoc::TopLevel to fill with parsed content,
-# the name of the file to be parsed, the content of the file, an RDoc::Options
-# object and an RDoc::Stats object to inform the user of parsed items. The
-# scan method is then called to parse the file and must return the
-# RDoc::TopLevel object. By calling super these items will be set for you.
-#
-# In order to be used by RDoc the parser needs to register the file extensions
-# it can parse. Use ::parse_files_matching to register extensions.
-#
-# require 'rdoc'
-#
-# class RDoc::Parser::Xyz < RDoc::Parser
-# parse_files_matching /\.xyz$/
-#
-# def initialize top_level, file_name, content, options, stats
-# super
-#
-# # extra initialization if needed
-# end
-#
-# def scan
-# # parse file and fill in @top_level
-# end
-# end
-
-class RDoc::Parser
-
- @parsers = []
-
- class << self
-
- ##
- # An Array of arrays that maps file extension (or name) regular
- # expressions to parser classes that will parse matching filenames.
- #
- # Use parse_files_matching to register a parser's file extensions.
-
- attr_reader :parsers
-
- end
-
- ##
- # The name of the file being parsed
-
- attr_reader :file_name
-
- ##
- # Alias an extension to another extension. After this call, files ending
- # "new_ext" will be parsed using the same parser as "old_ext"
-
- def self.alias_extension(old_ext, new_ext)
- old_ext = old_ext.sub(/^\.(.*)/, '\1')
- new_ext = new_ext.sub(/^\.(.*)/, '\1')
-
- parser = can_parse_by_name "xxx.#{old_ext}"
- return false unless parser
-
- RDoc::Parser.parsers.unshift [/\.#{new_ext}$/, parser]
-
- true
- end
-
- ##
- # Determines if the file is a "binary" file which basically means it has
- # content that an RDoc parser shouldn't try to consume.
-
- def self.binary?(file)
- return false if file =~ /\.(rdoc|txt)$/
-
- s = File.read(file, 1024) or return false
-
- return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")
-
- mode = 'r:utf-8' # default source encoding has been changed to utf-8
- s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
- encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
- mode = "rb:#{encoding}" if encoding
- s = File.open(file, mode) {|f| f.gets(nil, 1024)}
-
- not s.valid_encoding?
- end
-
- ##
- # Checks if +file+ is a zip file in disguise. Signatures from
- # http://www.garykessler.net/library/file_sigs.html
-
- def self.zip? file
- zip_signature = File.read file, 4
-
- zip_signature == "PK\x03\x04" or
- zip_signature == "PK\x05\x06" or
- zip_signature == "PK\x07\x08"
- rescue
- false
- end
-
- ##
- # Return a parser that can handle a particular extension
-
- def self.can_parse file_name
- parser = can_parse_by_name file_name
-
- # HACK Selenium hides a jar file using a .txt extension
- return if parser == RDoc::Parser::Simple and zip? file_name
-
- parser
- end
-
- ##
- # Returns a parser that can handle the extension for +file_name+. This does
- # not depend upon the file being readable.
-
- def self.can_parse_by_name file_name
- _, parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }
-
- # The default parser must not parse binary files
- ext_name = File.extname file_name
- return parser if ext_name.empty?
-
- if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then
- case check_modeline file_name
- when nil, 'rdoc' then # continue
- else return nil
- end
- end
-
- parser
- rescue Errno::EACCES
- end
-
- ##
- # Returns the file type from the modeline in +file_name+
-
- def self.check_modeline file_name
- line = File.open file_name do |io|
- io.gets
- end
-
- /-\*-\s*(.*?\S)\s*-\*-/ =~ line
-
- return nil unless type = $1
-
- if /;/ =~ type then
- return nil unless /(?:\s|\A)mode:\s*([^\s;]+)/i =~ type
- type = $1
- end
-
- return nil if /coding:/i =~ type
-
- type.downcase
- rescue ArgumentError
- rescue Encoding::InvalidByteSequenceError # invalid byte sequence
-
- end
-
- ##
- # Finds and instantiates the correct parser for the given +file_name+ and
- # +content+.
-
- def self.for top_level, file_name, content, options, stats
- return if binary? file_name
-
- parser = use_markup content
-
- unless parser then
- parse_name = file_name
-
- # If no extension, look for shebang
- if file_name !~ /\.\w+$/ && content =~ %r{\A#!(.+)} then
- shebang = $1
- case shebang
- when %r{env\s+ruby}, %r{/ruby}
- parse_name = 'dummy.rb'
- end
- end
-
- parser = can_parse parse_name
- end
-
- return unless parser
-
- content = remove_modeline content
-
- parser.new top_level, file_name, content, options, stats
- rescue SystemCallError
- nil
- end
-
- ##
- # Record which file types this parser can understand.
- #
- # It is ok to call this multiple times.
-
- def self.parse_files_matching(regexp)
- RDoc::Parser.parsers.unshift [regexp, self]
- end
-
- ##
- # Removes an emacs-style modeline from the first line of the document
-
- def self.remove_modeline content
- content.sub(/\A.*-\*-\s*(.*?\S)\s*-\*-.*\r?\n/, '')
- end
-
- ##
- # If there is a <tt>markup: parser_name</tt> comment at the front of the
- # file, use it to determine the parser. For example:
- #
- # # markup: rdoc
- # # Class comment can go here
- #
- # class C
- # end
- #
- # The comment should appear as the first line of the +content+.
- #
- # If the content contains a shebang or editor modeline the comment may
- # appear on the second or third line.
- #
- # Any comment style may be used to hide the markup comment.
-
- def self.use_markup content
- markup = content.lines.first(3).grep(/markup:\s+(\w+)/) { $1 }.first
-
- return unless markup
-
- # TODO Ruby should be returned only when the filename is correct
- return RDoc::Parser::Ruby if %w[tomdoc markdown].include? markup
-
- markup = Regexp.escape markup
-
- _, selected = RDoc::Parser.parsers.find do |_, parser|
- /^#{markup}$/i =~ parser.name.sub(/.*:/, '')
- end
-
- selected
- end
-
- ##
- # Creates a new Parser storing +top_level+, +file_name+, +content+,
- # +options+ and +stats+ in instance variables. In +@preprocess+ an
- # RDoc::Markup::PreProcess object is created which allows processing of
- # directives.
-
- def initialize top_level, file_name, content, options, stats
- @top_level = top_level
- @top_level.parser = self.class
- @store = @top_level.store
-
- @file_name = file_name
- @content = content
- @options = options
- @stats = stats
-
- @preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
- @preprocess.options = @options
- end
-
- autoload :RubyTools, "#{__dir__}/parser/ruby_tools"
- autoload :Text, "#{__dir__}/parser/text"
-
- ##
- # Normalizes tabs in +body+
-
- def handle_tab_width(body)
- if /\t/ =~ body
- tab_width = @options.tab_width
- body.split(/\n/).map do |line|
- 1 while line.gsub!(/\t+/) do
- b, e = $~.offset(0)
- ' ' * (tab_width * (e-b) - b % tab_width)
- end
- line
- end.join "\n"
- else
- body
- end
- end
-end
-
-# simple must come first in order to show up last in the parsers list
-require_relative 'parser/simple'
-require_relative 'parser/c'
-require_relative 'parser/changelog'
-require_relative 'parser/markdown'
-require_relative 'parser/rd'
-require_relative 'parser/ruby'
diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
deleted file mode 100644
index 5695bf1acb..0000000000
--- a/lib/rdoc/parser/c.rb
+++ /dev/null
@@ -1,1225 +0,0 @@
-# frozen_string_literal: true
-require 'tsort'
-
-##
-# RDoc::Parser::C attempts to parse C extension files. It looks for
-# the standard patterns that you find in extensions: +rb_define_class+,
-# +rb_define_method+ and so on. It tries to find the corresponding
-# C source for the methods and extract comments, but if we fail
-# we don't worry too much.
-#
-# The comments associated with a Ruby method are extracted from the C
-# comment block associated with the routine that _implements_ that
-# method, that is to say the method whose name is given in the
-# +rb_define_method+ call. For example, you might write:
-#
-# /*
-# * Returns a new array that is a one-dimensional flattening of this
-# * array (recursively). That is, for every element that is an array,
-# * extract its elements into the new array.
-# *
-# * s = [ 1, 2, 3 ] #=> [1, 2, 3]
-# * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
-# * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
-# * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-# */
-# static VALUE
-# rb_ary_flatten(VALUE ary)
-# {
-# ary = rb_obj_dup(ary);
-# rb_ary_flatten_bang(ary);
-# return ary;
-# }
-#
-# ...
-#
-# void
-# Init_Array(void)
-# {
-# ...
-# rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
-#
-# Here RDoc will determine from the +rb_define_method+ line that there's a
-# method called "flatten" in class Array, and will look for the implementation
-# in the method +rb_ary_flatten+. It will then use the comment from that
-# method in the HTML output. This method must be in the same source file
-# as the +rb_define_method+.
-#
-# The comment blocks may include special directives:
-#
-# [Document-class: +name+]
-# Documentation for the named class.
-#
-# [Document-module: +name+]
-# Documentation for the named module.
-#
-# [Document-const: +name+]
-# Documentation for the named +rb_define_const+.
-#
-# Constant values can be supplied on the first line of the comment like so:
-#
-# /* 300: The highest possible score in bowling */
-# rb_define_const(cFoo, "PERFECT", INT2FIX(300));
-#
-# The value can contain internal colons so long as they are escaped with a \
-#
-# [Document-global: +name+]
-# Documentation for the named +rb_define_global_const+
-#
-# [Document-variable: +name+]
-# Documentation for the named +rb_define_variable+
-#
-# [Document-method\: +method_name+]
-# Documentation for the named method. Use this when the method name is
-# unambiguous.
-#
-# [Document-method\: <tt>ClassName::method_name</tt>]
-# Documentation for a singleton method in the given class. Use this when
-# the method name alone is ambiguous.
-#
-# [Document-method\: <tt>ClassName#method_name</tt>]
-# Documentation for a instance method in the given class. Use this when the
-# method name alone is ambiguous.
-#
-# [Document-attr: +name+]
-# Documentation for the named attribute.
-#
-# [call-seq: <i>text up to an empty line</i>]
-# Because C source doesn't give descriptive names to Ruby-level parameters,
-# you need to document the calling sequence explicitly
-#
-# 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:
-#
-# rb_define_method(....); // in filename
-#
-# As an example, we might have an extension that defines multiple classes
-# in its Init_xxx method. We could document them using
-#
-# /*
-# * Document-class: MyClass
-# *
-# * Encapsulate the writing and reading of the configuration
-# * file. ...
-# */
-#
-# /*
-# * Document-method: read_value
-# *
-# * call-seq:
-# * cfg.read_value(key) -> value
-# * cfg.read_value(key} { |key| } -> value
-# *
-# * Return the value corresponding to +key+ from the configuration.
-# * In the second form, if the key isn't found, invoke the
-# * block and return its value.
-# */
-
-class RDoc::Parser::C < RDoc::Parser
-
- parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
-
- include RDoc::Text
-
- # :stopdoc:
- BOOL_ARG_PATTERN = /\s*+\b([01]|Q?(?:true|false)|TRUE|FALSE)\b\s*/
- TRUE_VALUES = ['1', 'TRUE', 'true', 'Qtrue'].freeze
- # :startdoc:
-
- ##
- # Maps C variable names to names of Ruby classes or modules
-
- attr_reader :classes
-
- ##
- # C file the parser is parsing
-
- attr_accessor :content
-
- ##
- # Dependencies from a missing enclosing class to the classes in
- # missing_dependencies that depend upon it.
-
- attr_reader :enclosure_dependencies
-
- ##
- # Maps C variable names to names of Ruby classes (and singleton classes)
-
- attr_reader :known_classes
-
- ##
- # Classes found while parsing the C file that were not yet registered due to
- # a missing enclosing class. These are processed by do_missing
-
- attr_reader :missing_dependencies
-
- ##
- # Maps C variable names to names of Ruby singleton classes
-
- attr_reader :singleton_classes
-
- ##
- # The TopLevel items in the parsed file belong to
-
- attr_reader :top_level
-
- ##
- # Prepares for parsing a C file. See RDoc::Parser#initialize for details on
- # the arguments.
-
- def initialize top_level, file_name, content, options, stats
- super
-
- @known_classes = RDoc::KNOWN_CLASSES.dup
- @content = handle_tab_width handle_ifdefs_in @content
- @file_dir = File.dirname @file_name
-
- @classes = load_variable_map :c_class_variables
- @singleton_classes = load_variable_map :c_singleton_class_variables
-
- @markup = @options.markup
-
- # class_variable => { function => [method, ...] }
- @methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }
-
- # missing variable => [handle_class_module arguments]
- @missing_dependencies = {}
-
- # missing enclosure variable => [dependent handle_class_module arguments]
- @enclosure_dependencies = Hash.new { |h, k| h[k] = [] }
- @enclosure_dependencies.instance_variable_set :@missing_dependencies,
- @missing_dependencies
-
- @enclosure_dependencies.extend TSort
-
- def @enclosure_dependencies.tsort_each_node &block
- each_key(&block)
- rescue TSort::Cyclic => e
- cycle_vars = e.message.scan(/"(.*?)"/).flatten
-
- cycle = cycle_vars.sort.map do |var_name|
- delete var_name
-
- var_name, type, mod_name, = @missing_dependencies[var_name]
-
- "#{type} #{mod_name} (#{var_name})"
- end.join ', '
-
- warn "Unable to create #{cycle} due to a cyclic class or module creation"
-
- retry
- end
-
- def @enclosure_dependencies.tsort_each_child node, &block
- fetch(node, []).each(&block)
- end
- end
-
- ##
- # Scans #content for rb_define_alias
-
- def do_aliases
- @content.scan(/rb_define_alias\s*\(
- \s*(\w+),
- \s*"(.+?)",
- \s*"(.+?)"
- \s*\)/xm) do |var_name, new_name, old_name|
- class_name = @known_classes[var_name]
-
- unless class_name then
- @options.warn "Enclosing class or module %p for alias %s %s is not known" % [
- var_name, new_name, old_name]
- next
- end
-
- class_obj = find_class var_name, class_name
- comment = find_alias_comment var_name, new_name, old_name
- comment.normalize
- if comment.to_s.empty? and existing_method = class_obj.method_list.find { |m| m.name == old_name}
- comment = existing_method.comment
- end
- add_alias(var_name, class_obj, old_name, new_name, comment)
- end
- end
-
- ##
- # Add alias, either from a direct alias definition, or from two
- # method that reference the same function.
-
- def add_alias(var_name, class_obj, old_name, new_name, comment)
- al = RDoc::Alias.new '', old_name, new_name, ''
- al.singleton = @singleton_classes.key? var_name
- al.comment = comment
- al.record_location @top_level
- class_obj.add_alias al
- @stats.add_alias al
- al
- end
-
- ##
- # Scans #content for rb_attr and rb_define_attr
-
- def do_attrs
- @content.scan(/rb_attr\s*\(
- \s*(\w+),
- \s*([\w"()]+),
- #{BOOL_ARG_PATTERN},
- #{BOOL_ARG_PATTERN},
- \s*\w+\);/xmo) do |var_name, attr_name, read, write|
- handle_attr var_name, attr_name, read, write
- end
-
- @content.scan(%r%rb_define_attr\(
- \s*([\w\.]+),
- \s*"([^"]+)",
- #{BOOL_ARG_PATTERN},
- #{BOOL_ARG_PATTERN}\);
- %xmo) do |var_name, attr_name, read, write|
- handle_attr var_name, attr_name, read, write
- end
- end
-
- ##
- # Scans #content for boot_defclass
-
- def do_boot_defclass
- @content.scan(/(\w+)\s*=\s*boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\s*\)/) do
- |var_name, class_name, parent|
- parent = nil if parent == "0"
- handle_class_module(var_name, :class, class_name, parent, nil)
- end
- end
-
- ##
- # Scans #content for rb_define_class, boot_defclass, rb_define_class_under
- # and rb_singleton_class
-
- def do_classes_and_modules
- do_boot_defclass if @file_name == "class.c"
-
- @content.scan(
- %r(
- (?<open>\s*\(\s*) {0}
- (?<close>\s*\)\s*) {0}
- (?<name>\s*"(?<class_name>\w+)") {0}
- (?<parent>\s*(?:
- (?<parent_name>[\w\*\s\(\)\.\->]+) |
- rb_path2class\s*\(\s*"(?<path>[\w:]+)"\s*\)
- )) {0}
- (?<under>\w+) {0}
-
- (?<var_name>[\w\.]+)\s* =
- \s*rb_(?:
- define_(?:
- class(?: # rb_define_class(name, parent_name)
- \(\s*
- \g<name>,
- \g<parent>
- \s*\)
- |
- _under\g<open> # rb_define_class_under(under, name, parent_name...)
- \g<under>,
- \g<name>,
- \g<parent>
- \g<close>
- )
- |
- (?<module>)
- module(?: # rb_define_module(name)
- \g<open>
- \g<name>
- \g<close>
- |
- _under\g<open> # rb_define_module_under(under, name)
- \g<under>,
- \g<name>
- \g<close>
- )
- )
- |
- (?<attributes>(?:\s*"\w+",)*\s*NULL\s*) {0}
- struct_define(?:
- \g<open> # rb_struct_define(name, ...)
- \g<name>,
- |
- _under\g<open> # rb_struct_define_under(under, name, ...)
- \g<under>,
- \g<name>,
- |
- _without_accessor(?:
- \g<open> # rb_struct_define_without_accessor(name, parent_name, ...)
- |
- _under\g<open> # rb_struct_define_without_accessor_under(under, name, parent_name, ...)
- \g<under>,
- )
- \g<name>,
- \g<parent>,
- \s*\w+, # Allocation function
- )
- \g<attributes>
- \g<close>
- |
- singleton_class\g<open> # rb_singleton_class(target_class_name)
- (?<target_class_name>\w+)
- \g<close>
- )
- )mx
- ) do
- if target_class_name = $~[:target_class_name]
- # rb_singleton_class(target_class_name)
- handle_singleton $~[:var_name], target_class_name
- next
- end
-
- var_name = $~[:var_name]
- type = $~[:module] ? :module : :class
- class_name = $~[:class_name]
- parent_name = $~[:parent_name] || $~[:path]
- under = $~[:under]
- attributes = $~[:attributes]
-
- handle_class_module(var_name, type, class_name, parent_name, under)
- if attributes and !parent_name # rb_struct_define *not* without_accessor
- true_flag = 'Qtrue'
- attributes.scan(/"\K\w+(?=")/) do |attr_name|
- handle_attr var_name, attr_name, true_flag, true_flag
- end
- end
- end
- end
-
- ##
- # Scans #content for rb_define_variable, rb_define_readonly_variable,
- # rb_define_const and rb_define_global_const
-
- def do_constants
- @content.scan(%r%\Wrb_define_
- ( variable |
- readonly_variable |
- const |
- global_const )
- \s*\(
- (?:\s*(\w+),)?
- \s*"(\w+)",
- \s*(.*?)\s*\)\s*;
- %xm) do |type, var_name, const_name, definition|
- var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
- handle_constants type, var_name, const_name, definition
- end
-
- @content.scan(%r%
- \Wrb_curses_define_const
- \s*\(
- \s*
- (\w+)
- \s*
- \)
- \s*;%xm) do |consts|
- const = consts.first
-
- handle_constants 'const', 'mCurses', const, "UINT2NUM(#{const})"
- end
-
- @content.scan(%r%
- \Wrb_file_const
- \s*\(
- \s*
- "([^"]+)",
- \s*
- (.*?)
- \s*
- \)
- \s*;%xm) do |name, value|
- handle_constants 'const', 'rb_mFConst', name, value
- end
- end
-
-
- ##
- # Scans #content for rb_include_module
-
- def do_includes
- @content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
- next unless cls = @classes[c]
- m = @known_classes[m] || m
-
- comment = new_comment '', @top_level, :c
- incl = cls.add_include RDoc::Include.new(m, comment)
- incl.record_location @top_level
- end
- end
-
- ##
- # Scans #content for rb_define_method, rb_define_singleton_method,
- # rb_define_module_function, rb_define_private_method,
- # rb_define_global_function and define_filetest_function
-
- def do_methods
- @content.scan(%r%rb_define_
- (
- singleton_method |
- method |
- module_function |
- private_method
- )
- \s*\(\s*([\w\.]+),
- \s*"([^"]+)",
- \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\(|\(METHOD\))?(\w+)\)?,
- \s*(-?\w+)\s*\)
- (?:;\s*/[*/]\s+in\s+(\w+?\.(?:cpp|c|y)))?
- %xm) do |type, var_name, meth_name, function, param_count, source_file|
-
- # Ignore top-object and weird struct.c dynamic stuff
- next if var_name == "ruby_top_self"
- next if var_name == "nstr"
-
- var_name = "rb_cObject" if var_name == "rb_mKernel"
- handle_method(type, var_name, meth_name, function, param_count,
- source_file)
- end
-
- @content.scan(%r%rb_define_global_function\s*\(
- \s*"([^"]+)",
- \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
- \s*(-?\w+)\s*\)
- (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
- %xm) do |meth_name, function, param_count, source_file|
- handle_method("method", "rb_mKernel", meth_name, function, param_count,
- source_file)
- end
-
- @content.scan(/define_filetest_function\s*\(
- \s*"([^"]+)",
- \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
- \s*(-?\w+)\s*\)/xm) do |meth_name, function, param_count|
-
- handle_method("method", "rb_mFileTest", meth_name, function, param_count)
- handle_method("singleton_method", "rb_cFile", meth_name, function,
- param_count)
- end
- end
-
- ##
- # Creates classes and module that were missing were defined due to the file
- # order being different than the declaration order.
-
- def do_missing
- return if @missing_dependencies.empty?
-
- @enclosure_dependencies.tsort.each do |in_module|
- arguments = @missing_dependencies.delete in_module
-
- next unless arguments # dependency on existing class
-
- handle_class_module(*arguments)
- end
- end
-
- ##
- # Finds the comment for an alias on +class_name+ from +new_name+ to
- # +old_name+
-
- def find_alias_comment class_name, new_name, old_name
- content =~ %r%((?>/\*.*?\*/\s+))
- rb_define_alias\(\s*#{Regexp.escape class_name}\s*,
- \s*"#{Regexp.escape new_name}"\s*,
- \s*"#{Regexp.escape old_name}"\s*\);%xm
-
- new_comment($1 || '', @top_level, :c)
- end
-
- ##
- # Finds a comment for rb_define_attr, rb_attr or Document-attr.
- #
- # +var_name+ is the C class variable the attribute is defined on.
- # +attr_name+ is the attribute's name.
- #
- # +read+ and +write+ are the read/write flags ('1' or '0'). Either both or
- # neither must be provided.
-
- def find_attr_comment var_name, attr_name, read = nil, write = nil
- attr_name = Regexp.escape attr_name
-
- rw = if read and write then
- /\s*#{read}\s*,\s*#{write}\s*/xm
- else
- /.*?/m
- end
-
- comment = if @content =~ %r%((?>/\*.*?\*/\s+))
- rb_define_attr\((?:\s*#{var_name},)?\s*
- "#{attr_name}"\s*,
- #{rw}\)\s*;%xm then
- $1
- elsif @content =~ %r%((?>/\*.*?\*/\s+))
- rb_attr\(\s*#{var_name}\s*,
- \s*#{attr_name}\s*,
- #{rw},.*?\)\s*;%xm then
- $1
- elsif @content =~ %r%(/\*.*?(?:\s*\*\s*)?)
- Document-attr:\s#{attr_name}\s*?\n
- ((?>(.|\n)*?\*/))%x then
- "#{$1}\n#{$2}"
- else
- ''
- end
-
- new_comment comment, @top_level, :c
- end
-
- ##
- # Generate a Ruby-method table
-
- def gen_body_table file_content
- table = {}
- file_content.scan(%r{
- ((?>/\*.*?\*/\s*)?)
- ((?:(?:\w+)\s+)?
- (?:intern\s+)?VALUE\s+(\w+)
- \s*(?:\([^)]*\))(?:[^\);]|$))
- | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
- | ^\s*\#\s*define\s+(\w+)\s+(\w+)
- }xm) do
- case
- when $1
- table[$3] = [:func_def, $1, $2, $~.offset(2)] if !table[$3] || table[$3][0] != :func_def
- when $4
- table[$6] = [:macro_def, $4, $5, $~.offset(5), $7] if !table[$6] || table[$6][0] == :macro_alias
- when $8
- table[$8] ||= [:macro_alias, $9]
- end
- end
- table
- end
-
- ##
- # Find the C code corresponding to a Ruby method
-
- def find_body class_name, meth_name, meth_obj, file_content, quiet = false
- if file_content
- @body_table ||= {}
- @body_table[file_content] ||= gen_body_table file_content
- type, *args = @body_table[file_content][meth_name]
- end
-
- case type
- when :func_def
- comment = new_comment args[0], @top_level, :c
- body = args[1]
- offset, = args[2]
-
- comment.remove_private if comment
-
- # try to find the whole body
- body = $& if /#{Regexp.escape body}[^(]*?\{.*?^\}/m =~ file_content
-
- # The comment block may have been overridden with a 'Document-method'
- # block. This happens in the interpreter when multiple methods are
- # vectored through to the same C method but those methods are logically
- # distinct (for example Kernel.hash and Kernel.object_id share the same
- # implementation
-
- override_comment = find_override_comment class_name, meth_obj
- comment = override_comment if override_comment
-
- comment.normalize
- find_modifiers comment, meth_obj if comment
-
- #meth_obj.params = params
- meth_obj.start_collecting_tokens
- tk = { :line_no => 1, :char_no => 1, :text => body }
- meth_obj.add_token tk
- meth_obj.comment = comment
- meth_obj.line = file_content[0, offset].count("\n") + 1
-
- body
- when :macro_def
- comment = new_comment args[0], @top_level, :c
- body = args[1]
- offset, = args[2]
-
- find_body class_name, args[3], meth_obj, file_content, true
-
- comment.normalize
- find_modifiers comment, meth_obj
-
- meth_obj.start_collecting_tokens
- tk = { :line_no => 1, :char_no => 1, :text => body }
- meth_obj.add_token tk
- meth_obj.comment = comment
- meth_obj.line = file_content[0, offset].count("\n") + 1
-
- body
- when :macro_alias
- # with no comment we hope the aliased definition has it and use it's
- # definition
-
- body = find_body(class_name, args[0], meth_obj, file_content, true)
-
- return body if body
-
- @options.warn "No definition for #{meth_name}"
- false
- else # No body, but might still have an override comment
- comment = find_override_comment class_name, meth_obj
-
- if comment then
- comment.normalize
- find_modifiers comment, meth_obj
- meth_obj.comment = comment
-
- ''
- else
- @options.warn "No definition for #{meth_name}"
- false
- end
- end
- end
-
- ##
- # Finds a RDoc::NormalClass or RDoc::NormalModule for +raw_name+
-
- def find_class(raw_name, name, base_name = nil)
- unless @classes[raw_name]
- if raw_name =~ /^rb_m/
- container = @top_level.add_module RDoc::NormalModule, name
- else
- container = @top_level.add_class RDoc::NormalClass, name
- end
- container.name = base_name if base_name
-
- container.record_location @top_level
- @classes[raw_name] = container
- end
- @classes[raw_name]
- end
-
- ##
- # Look for class or module documentation above Init_+class_name+(void),
- # in a Document-class +class_name+ (or module) comment or above an
- # rb_define_class (or module). If a comment is supplied above a matching
- # Init_ and a rb_define_class the Init_ comment is used.
- #
- # /*
- # * This is a comment for Foo
- # */
- # Init_Foo(void) {
- # VALUE cFoo = rb_define_class("Foo", rb_cObject);
- # }
- #
- # /*
- # * Document-class: Foo
- # * This is a comment for Foo
- # */
- # Init_foo(void) {
- # VALUE cFoo = rb_define_class("Foo", rb_cObject);
- # }
- #
- # /*
- # * This is a comment for Foo
- # */
- # VALUE cFoo = rb_define_class("Foo", rb_cObject);
-
- def find_class_comment class_name, class_mod
- comment = nil
-
- if @content =~ %r%
- ((?>/\*.*?\*/\s+))
- (static\s+)?
- void\s+
- Init(?:VM)?_(?i:#{class_name})\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xm then
- comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '')
- elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
- (?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
- comment = "/*\n#{$1}"
- elsif @content =~ %r%((?>/\*.*?\*/\s+))
- ([\w\.\s]+\s* = \s+)?rb_define_(class|module)[\t (]*?"(#{class_name})"%xm then
- comment = $1
- elsif @content =~ %r%((?>/\*.*?\*/\s+))
- ([\w\. \t]+ = \s+)?rb_define_(class|module)_under[\t\w, (]*?"(#{class_name.split('::').last})"%xm then
- comment = $1
- else
- comment = ''
- end
-
- comment = new_comment comment, @top_level, :c
- comment.normalize
-
- look_for_directives_in class_mod, comment
-
- class_mod.add_comment comment, @top_level
- end
-
- ##
- # Generate a const table
-
- def gen_const_table file_content
- table = {}
- @content.scan(%r{
- ((?>^\s*/\*.*?\*/\s+))
- rb_define_(\w+)\((?:\s*(?:\w+),)?\s*
- "(\w+)"\s*,
- .*?\)\s*;
- | Document-(?:const|global|variable):\s
- ((?:\w+::)*\w+)
- \s*?\n((?>.*?\*/))
- }mxi) do
- case
- when $1 then table[[$2, $3]] = $1
- when $4 then table[$4] = "/*\n" + $5
- end
- end
- table
- end
-
- ##
- # Finds a comment matching +type+ and +const_name+ either above the
- # comment or in the matching Document- section.
-
- def find_const_comment(type, const_name, class_name = nil)
- @const_table ||= {}
- @const_table[@content] ||= gen_const_table @content
- table = @const_table[@content]
-
- comment =
- table[[type, const_name]] ||
- (class_name && table[class_name + "::" + const_name]) ||
- table[const_name] ||
- ''
-
- new_comment comment, @top_level, :c
- end
-
- ##
- # Handles modifiers in +comment+ and updates +meth_obj+ as appropriate.
-
- def find_modifiers comment, meth_obj
- comment.normalize
- comment.extract_call_seq meth_obj
-
- look_for_directives_in meth_obj, comment
- end
-
- ##
- # Finds a <tt>Document-method</tt> override for +meth_obj+ on +class_name+
-
- def find_override_comment class_name, meth_obj
- name = Regexp.escape meth_obj.name
- prefix = Regexp.escape meth_obj.name_prefix
-
- comment = if @content =~ %r%Document-method:
- \s+#{class_name}#{prefix}#{name}
- \s*?\n((?>.*?\*/))%xm then
- "/*#{$1}"
- elsif @content =~ %r%Document-method:
- \s#{name}\s*?\n((?>.*?\*/))%xm then
- "/*#{$1}"
- end
-
- return unless comment
-
- new_comment comment, @top_level, :c
- end
-
- ##
- # Creates a new RDoc::Attr +attr_name+ on class +var_name+ that is either
- # +read+, +write+ or both
-
- def handle_attr(var_name, attr_name, read, write)
- rw = ''
- rw += 'R' if TRUE_VALUES.include?(read)
- rw += 'W' if TRUE_VALUES.include?(write)
-
- class_name = @known_classes[var_name]
-
- return unless class_name
-
- class_obj = find_class var_name, class_name
-
- return unless class_obj
-
- comment = find_attr_comment var_name, attr_name
- comment.normalize
-
- name = attr_name.gsub(/rb_intern(?:_const)?\("([^"]+)"\)/, '\1')
-
- attr = RDoc::Attr.new '', name, rw, comment
-
- attr.record_location @top_level
- class_obj.add_attribute attr
- @stats.add_attribute attr
- end
-
- ##
- # Creates a new RDoc::NormalClass or RDoc::NormalModule based on +type+
- # named +class_name+ in +parent+ which was assigned to the C +var_name+.
-
- def handle_class_module(var_name, type, class_name, parent, in_module)
- parent_name = @known_classes[parent] || parent
-
- if in_module then
- enclosure = @classes[in_module] || @store.find_c_enclosure(in_module)
-
- if enclosure.nil? and enclosure = @known_classes[in_module] then
- enc_type = /^rb_m/ =~ in_module ? :module : :class
- handle_class_module in_module, enc_type, enclosure, nil, nil
- enclosure = @classes[in_module]
- end
-
- unless enclosure then
- @enclosure_dependencies[in_module] << var_name
- @missing_dependencies[var_name] =
- [var_name, type, class_name, parent, in_module]
-
- return
- end
- else
- enclosure = @top_level
- end
-
- if type == :class then
- full_name = if RDoc::ClassModule === enclosure then
- enclosure.full_name + "::#{class_name}"
- else
- class_name
- end
-
- if @content =~ %r%Document-class:\s+#{full_name}\s*<\s+([:,\w]+)% then
- parent_name = $1
- end
-
- cm = enclosure.add_class RDoc::NormalClass, class_name, parent_name
- else
- cm = enclosure.add_module RDoc::NormalModule, class_name
- end
-
- cm.record_location enclosure.top_level
-
- find_class_comment cm.full_name, cm
-
- case cm
- when RDoc::NormalClass
- @stats.add_class cm
- when RDoc::NormalModule
- @stats.add_module cm
- end
-
- @classes[var_name] = cm
- @known_classes[var_name] = cm.full_name
- @store.add_c_enclosure var_name, cm
- end
-
- ##
- # Adds constants. By providing some_value: at the start of the comment you
- # can override the C value of the comment to give a friendly definition.
- #
- # /* 300: The perfect score in bowling */
- # rb_define_const(cFoo, "PERFECT", INT2FIX(300));
- #
- # Will override <tt>INT2FIX(300)</tt> with the value +300+ in the output
- # RDoc. Values may include quotes and escaped colons (\:).
-
- def handle_constants(type, var_name, const_name, definition)
- class_name = @known_classes[var_name]
-
- return unless class_name
-
- class_obj = find_class var_name, class_name, class_name[/::\K[^:]+\z/]
-
- unless class_obj then
- @options.warn 'Enclosing class or module %p is not known' % [const_name]
- return
- end
-
- comment = find_const_comment type, const_name, class_name
- comment.normalize
-
- # In the case of rb_define_const, the definition and comment are in
- # "/* definition: comment */" form. The literal ':' and '\' characters
- # can be escaped with a backslash.
- if type.downcase == 'const' then
- no_match, new_definition, new_comment = comment.text.split(/(\A.*):/)
-
- if no_match and no_match.empty? then
- if new_definition.empty? then # Default to literal C definition
- new_definition = definition
- else
- new_definition = new_definition.gsub("\:", ":")
- new_definition = new_definition.gsub("\\", '\\')
- end
-
- new_definition.sub!(/\A(\s+)/, '')
-
- new_comment = "#{$1}#{new_comment.lstrip}"
-
- new_comment = self.new_comment(new_comment, @top_level, :c)
-
- con = RDoc::Constant.new const_name, new_definition, new_comment
- else
- con = RDoc::Constant.new const_name, definition, comment
- end
- else
- con = RDoc::Constant.new const_name, definition, comment
- end
-
- con.record_location @top_level
- @stats.add_constant con
- class_obj.add_constant con
- end
-
- ##
- # Removes #ifdefs that would otherwise confuse us
-
- def handle_ifdefs_in(body)
- body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m, '\1')
- end
-
- ##
- # Adds an RDoc::AnyMethod +meth_name+ defined on a class or module assigned
- # to +var_name+. +type+ is the type of method definition function used.
- # +singleton_method+ and +module_function+ create a singleton method.
-
- def handle_method(type, var_name, meth_name, function, param_count,
- source_file = nil)
- class_name = @known_classes[var_name]
- singleton = @singleton_classes.key? var_name
-
- @methods[var_name][function] << meth_name
-
- return unless class_name
-
- class_obj = find_class var_name, class_name
-
- if existing_method = class_obj.method_list.find { |m| m.c_function == function }
- add_alias(var_name, class_obj, existing_method.name, meth_name, existing_method.comment)
- end
-
- if class_obj then
- if meth_name == 'initialize' then
- meth_name = 'new'
- singleton = true
- type = 'method' # force public
- end
-
- meth_obj = RDoc::AnyMethod.new '', meth_name
- meth_obj.c_function = function
- meth_obj.singleton =
- singleton || %w[singleton_method module_function].include?(type)
-
- p_count = Integer(param_count) rescue -1
-
- if source_file then
- file_name = File.join @file_dir, source_file
-
- if File.exist? file_name then
- file_content = File.read file_name
- else
- @options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
- end
- else
- file_content = @content
- end
-
- body = find_body class_name, function, meth_obj, file_content
-
- if body and meth_obj.document_self then
- meth_obj.params = if p_count < -1 then # -2 is Array
- '(*args)'
- elsif p_count == -1 then # argc, argv
- rb_scan_args body
- else
- args = (1..p_count).map { |i| "p#{i}" }
- "(#{args.join ', '})"
- end
-
-
- meth_obj.record_location @top_level
-
- if meth_obj.section_title
- class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
- end
- class_obj.add_method meth_obj
-
- @stats.add_method meth_obj
- meth_obj.visibility = :private if 'private_method' == type
- end
- end
- end
-
- ##
- # Registers a singleton class +sclass_var+ as a singleton of +class_var+
-
- def handle_singleton sclass_var, class_var
- class_name = @known_classes[class_var]
-
- @known_classes[sclass_var] = class_name
- @singleton_classes[sclass_var] = class_name
- end
-
- ##
- # Loads the variable map with the given +name+ from the RDoc::Store, if
- # present.
-
- def load_variable_map map_name
- return {} unless files = @store.cache[map_name]
- return {} unless name_map = files[@file_name]
-
- class_map = {}
-
- name_map.each do |variable, name|
- next unless mod = @store.find_class_or_module(name)
-
- class_map[variable] = if map_name == :c_class_variables then
- mod
- else
- name
- end
- @known_classes[variable] = name
- end
-
- class_map
- end
-
- ##
- # Look for directives in a normal comment block:
- #
- # /*
- # * :title: My Awesome Project
- # */
- #
- # This method modifies the +comment+
-
- def look_for_directives_in context, comment
- @preprocess.handle comment, context do |directive, param|
- case directive
- when 'main' then
- @options.main_page = param
- ''
- when 'title' then
- @options.default_title = param if @options.respond_to? :default_title=
- ''
- end
- end
-
- comment
- end
-
- ##
- # Extracts parameters from the +method_body+ and returns a method
- # parameter string. Follows 1.9.3dev's scan-arg-spec, see README.EXT
-
- def rb_scan_args method_body
- method_body =~ /rb_scan_args\((.*?)\)/m
- return '(*args)' unless $1
-
- $1.split(/,/)[2] =~ /"(.*?)"/ # format argument
- format = $1.split(//)
-
- lead = opt = trail = 0
-
- if format.first =~ /\d/ then
- lead = $&.to_i
- format.shift
- if format.first =~ /\d/ then
- opt = $&.to_i
- format.shift
- if format.first =~ /\d/ then
- trail = $&.to_i
- format.shift
- block_arg = true
- end
- end
- end
-
- if format.first == '*' and not block_arg then
- var = true
- format.shift
- if format.first =~ /\d/ then
- trail = $&.to_i
- format.shift
- end
- end
-
- if format.first == ':' then
- hash = true
- format.shift
- end
-
- if format.first == '&' then
- block = true
- format.shift
- end
-
- # if the format string is not empty there's a bug in the C code, ignore it
-
- args = []
- position = 1
-
- (1...(position + lead)).each do |index|
- args << "p#{index}"
- end
-
- position += lead
-
- (position...(position + opt)).each do |index|
- args << "p#{index} = v#{index}"
- end
-
- position += opt
-
- if var then
- args << '*args'
- position += 1
- end
-
- (position...(position + trail)).each do |index|
- args << "p#{index}"
- end
-
- position += trail
-
- if hash then
- args << "p#{position} = {}"
- end
-
- args << '&block' if block
-
- "(#{args.join ', '})"
- end
-
- ##
- # Removes lines that are commented out that might otherwise get picked up
- # when scanning for classes and methods
-
- def remove_commented_out_lines
- @content = @content.gsub(%r%//.*rb_define_%, '//')
- end
-
- ##
- # Extracts the classes, modules, methods, attributes, constants and aliases
- # from a C file and returns an RDoc::TopLevel for this file
-
- def scan
- remove_commented_out_lines
-
- do_classes_and_modules
- do_missing
-
- do_constants
- do_methods
- do_includes
- do_aliases
- do_attrs
-
- @store.add_c_variables self
-
- @top_level
- end
-
- def new_comment text = nil, location = nil, language = nil
- RDoc::Comment.new(text, location, language).tap do |comment|
- comment.format = @markup
- end
- end
-end
diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb
deleted file mode 100644
index 9245d49376..0000000000
--- a/lib/rdoc/parser/changelog.rb
+++ /dev/null
@@ -1,335 +0,0 @@
-# frozen_string_literal: true
-
-##
-# A ChangeLog file parser.
-#
-# This parser converts a ChangeLog into an RDoc::Markup::Document. When
-# viewed as HTML a ChangeLog page will have an entry for each day's entries in
-# the sidebar table of contents.
-#
-# This parser is meant to parse the MRI ChangeLog, but can be used to parse any
-# {GNU style Change
-# Log}[http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html].
-
-class RDoc::Parser::ChangeLog < RDoc::Parser
-
- include RDoc::Parser::Text
-
- parse_files_matching(/(\/|\\|\A)ChangeLog[^\/\\]*\z/)
-
- ##
- # Attaches the +continuation+ of the previous line to the +entry_body+.
- #
- # Continued function listings are joined together as a single entry.
- # Continued descriptions are joined to make a single paragraph.
-
- def continue_entry_body entry_body, continuation
- return unless last = entry_body.last
-
- if last =~ /\)\s*\z/ and continuation =~ /\A\(/ then
- last.sub!(/\)\s*\z/, ',')
- continuation = continuation.sub(/\A\(/, '')
- end
-
- if last =~ /\s\z/ then
- last << continuation
- else
- last << ' ' + continuation
- end
- end
-
- ##
- # Creates an RDoc::Markup::Document given the +groups+ of ChangeLog entries.
-
- def create_document groups
- doc = RDoc::Markup::Document.new
- doc.omit_headings_below = 2
- doc.file = @top_level
-
- doc << RDoc::Markup::Heading.new(1, File.basename(@file_name))
- doc << RDoc::Markup::BlankLine.new
-
- groups.sort_by do |day,| day end.reverse_each do |day, entries|
- doc << RDoc::Markup::Heading.new(2, day.dup)
- doc << RDoc::Markup::BlankLine.new
-
- doc.concat create_entries entries
- end
-
- doc
- end
-
- ##
- # Returns a list of ChangeLog entries an RDoc::Markup nodes for the given
- # +entries+.
-
- def create_entries entries
- out = []
-
- entries.each do |entry, items|
- out << RDoc::Markup::Heading.new(3, entry)
- out << RDoc::Markup::BlankLine.new
-
- out << create_items(items)
- end
-
- out
- end
-
- ##
- # Returns an RDoc::Markup::List containing the given +items+ in the
- # ChangeLog
-
- def create_items items
- list = RDoc::Markup::List.new :NOTE
-
- items.each do |item|
- item =~ /\A(.*?(?:\([^)]+\))?):\s*/
-
- title = $1
- body = $'
-
- paragraph = RDoc::Markup::Paragraph.new body
- list_item = RDoc::Markup::ListItem.new title, paragraph
- list << list_item
- end
-
- list
- end
-
- ##
- # Groups +entries+ by date.
-
- def group_entries entries
- @time_cache ||= {}
- entries.group_by do |title, _|
- begin
- time = @time_cache[title]
- (time || parse_date(title)).strftime '%Y-%m-%d'
- rescue NoMethodError, ArgumentError
- time, = title.split ' ', 2
- parse_date(time).strftime '%Y-%m-%d'
- end
- end
- end
-
- ##
- # Parse date in ISO-8601, RFC-2822, or default of Git
-
- def parse_date(date)
- case date
- when /\A\s*(\d+)-(\d+)-(\d+)(?:[ T](\d+):(\d+):(\d+) *([-+]\d\d):?(\d\d))?\b/
- Time.new($1, $2, $3, $4, $5, $6, ("#{$7}:#{$8}" if $7))
- when /\A\s*\w{3}, +(\d+) (\w{3}) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
- Time.new($3, $2, $1, $4, $5, $6, ("#{$7}:#{$8}" if $7))
- when /\A\s*\w{3} (\w{3}) +(\d+) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
- Time.new($3, $1, $2, $4, $5, $6, ("#{$7}:#{$8}" if $7))
- when /\A\s*\w{3} (\w{3}) +(\d+) (\d+):(\d+):(\d+) (\d+)\b/
- Time.new($6, $1, $2, $3, $4, $5)
- else
- raise ArgumentError, "bad date: #{date}"
- end
- end
-
- ##
- # Parses the entries in the ChangeLog.
- #
- # Returns an Array of each ChangeLog entry in order of parsing.
- #
- # A ChangeLog entry is an Array containing the ChangeLog title (date and
- # committer) and an Array of ChangeLog items (file and function changed with
- # description).
- #
- # An example result would be:
- #
- # [ 'Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
- # [ 'README.EXT: Converted to RDoc format',
- # 'README.EXT.ja: ditto']]
-
- def parse_entries
- @time_cache ||= {}
-
- if /\A((?:.*\n){,3})commit\s/ =~ @content
- class << self; prepend Git; end
- parse_info($1)
- return parse_entries
- end
-
- entries = []
- entry_name = nil
- entry_body = []
-
- @content.each_line do |line|
- case line
- when /^\s*$/ then
- next
- when /^\w.*/ then
- entries << [entry_name, entry_body] if entry_name
-
- entry_name = $&
-
- begin
- time = parse_date entry_name
- @time_cache[entry_name] = time
- rescue ArgumentError
- entry_name = nil
- end
-
- entry_body = []
- when /^(\t| {8})?\*\s*(.*)/ then # "\t* file.c (func): ..."
- entry_body << $2.dup
- when /^(\t| {8})?\s*(\(.*)/ then # "\t(func): ..."
- entry = $2
-
- if entry_body.last =~ /:/ then
- entry_body << entry.dup
- else
- continue_entry_body entry_body, entry
- end
- when /^(\t| {8})?\s*(.*)/ then
- continue_entry_body entry_body, $2
- end
- end
-
- entries << [entry_name, entry_body] if entry_name
-
- entries.reject! do |(entry,_)|
- entry == nil
- end
-
- entries
- end
-
- ##
- # Converts the ChangeLog into an RDoc::Markup::Document
-
- def scan
- @time_cache = {}
-
- entries = parse_entries
- grouped_entries = group_entries entries
-
- doc = create_document grouped_entries
-
- @top_level.comment = doc
-
- @top_level
- end
-
- module Git
- def parse_info(info)
- /^\s*base-url\s*=\s*(.*\S)/ =~ info
- @base_url = $1
- end
-
- def parse_entries
- entries = []
-
- @content.scan(/^commit\s+(\h{20})\h*\n((?:.+\n)*)\n((?: {4}.*\n+)*)/) do
- entry_name, header, entry_body = $1, $2, $3.gsub(/^ {4}/, '')
- # header = header.scan(/^ *(\S+?): +(.*)/).to_h
- # date = header["CommitDate"] || header["Date"]
- date = header[/^ *(?:Author)?Date: +(.*)/, 1]
- author = header[/^ *Author: +(.*)/, 1]
- begin
- time = parse_date(header[/^ *CommitDate: +(.*)/, 1] || date)
- @time_cache[entry_name] = time
- author.sub!(/\s*<(.*)>/, '')
- email = $1
- entries << [entry_name, [author, email, date, entry_body]]
- rescue ArgumentError
- end
- end
-
- entries
- end
-
- def create_entries entries
- # git log entries have no strictly itemized style like the old
- # style, just assume Markdown.
- entries.map do |commit, entry|
- LogEntry.new(@base_url, commit, *entry)
- end
- end
-
- LogEntry = Struct.new(:base, :commit, :author, :email, :date, :contents) do
- HEADING_LEVEL = 3
-
- def initialize(base, commit, author, email, date, contents)
- case contents
- when String
- contents = RDoc::Markdown.parse(contents).parts.each do |body|
- case body
- when RDoc::Markup::Heading
- body.level += HEADING_LEVEL + 1
- end
- end
- case first = contents[0]
- when RDoc::Markup::Paragraph
- contents[0] = RDoc::Markup::Heading.new(HEADING_LEVEL + 1, first.text)
- end
- end
- super
- end
-
- def level
- HEADING_LEVEL
- end
-
- def aref
- "label-#{commit}"
- end
-
- def label context = nil
- aref
- end
-
- def text
- case base
- when nil
- "#{date}"
- when /%s/
- "{#{date}}[#{base % commit}]"
- else
- "{#{date}}[#{base}#{commit}]"
- end + " {#{author}}[mailto:#{email}]"
- end
-
- def accept visitor
- visitor.accept_heading self
- begin
- if visitor.respond_to?(:code_object=)
- code_object = visitor.code_object
- visitor.code_object = self
- end
- contents.each do |body|
- body.accept visitor
- end
- ensure
- if visitor.respond_to?(:code_object)
- visitor.code_object = code_object
- end
- end
- end
-
- def pretty_print q # :nodoc:
- q.group(2, '[log_entry: ', ']') do
- q.text commit
- q.text ','
- q.breakable
- q.group(2, '[date: ', ']') { q.text date }
- q.text ','
- q.breakable
- q.group(2, '[author: ', ']') { q.text author }
- q.text ','
- q.breakable
- q.group(2, '[email: ', ']') { q.text email }
- q.text ','
- q.breakable
- q.pp contents
- end
- end
- end
- end
-end
-
diff --git a/lib/rdoc/parser/markdown.rb b/lib/rdoc/parser/markdown.rb
deleted file mode 100644
index 9ff478f872..0000000000
--- a/lib/rdoc/parser/markdown.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-##
-# Parse a Markdown format file. The parsed RDoc::Markup::Document is attached
-# as a file comment.
-
-class RDoc::Parser::Markdown < RDoc::Parser
-
- include RDoc::Parser::Text
-
- parse_files_matching(/\.(md|markdown)(?:\.[^.]+)?$/)
-
- ##
- # Creates an Markdown-format TopLevel for the given file.
-
- def scan
- comment = RDoc::Comment.new @content, @top_level
- comment.format = 'markdown'
-
- @top_level.comment = comment
- end
-
-end
-
-
diff --git a/lib/rdoc/parser/rd.rb b/lib/rdoc/parser/rd.rb
deleted file mode 100644
index 25f5711731..0000000000
--- a/lib/rdoc/parser/rd.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-##
-# Parse a RD format file. The parsed RDoc::Markup::Document is attached as a
-# file comment.
-
-class RDoc::Parser::RD < RDoc::Parser
-
- include RDoc::Parser::Text
-
- parse_files_matching(/\.rd(?:\.[^.]+)?$/)
-
- ##
- # Creates an rd-format TopLevel for the given file.
-
- def scan
- comment = RDoc::Comment.new @content, @top_level
- comment.format = 'rd'
-
- @top_level.comment = comment
- end
-
-end
-
diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb
deleted file mode 100644
index 5492f08726..0000000000
--- a/lib/rdoc/parser/ripper_state_lex.rb
+++ /dev/null
@@ -1,590 +0,0 @@
-# frozen_string_literal: true
-require 'ripper'
-
-class RDoc::Parser::RipperStateLex
- # TODO: Remove this constants after Ruby 2.4 EOL
- RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
-
- Token = Struct.new(:line_no, :char_no, :kind, :text, :state)
-
- EXPR_NONE = 0
- EXPR_BEG = 1
- EXPR_END = 2
- EXPR_ENDARG = 4
- EXPR_ENDFN = 8
- EXPR_ARG = 16
- EXPR_CMDARG = 32
- EXPR_MID = 64
- EXPR_FNAME = 128
- EXPR_DOT = 256
- EXPR_CLASS = 512
- EXPR_LABEL = 1024
- EXPR_LABELED = 2048
- EXPR_FITEM = 4096
- EXPR_VALUE = EXPR_BEG
- EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS)
- EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG)
- EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN)
-
- class InnerStateLex < Ripper::Filter
- attr_accessor :lex_state
-
- def initialize(code)
- @lex_state = EXPR_BEG
- @in_fname = false
- @continue = false
- reset
- super(code)
- end
-
- def reset
- @command_start = false
- @cmd_state = @command_start
- end
-
- def on_nl(tok, data)
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @continue = true
- else
- @continue = false
- @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_ignored_nl(tok, data)
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @continue = true
- else
- @continue = false
- @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_op(tok, data)
- case tok
- when '&', '|', '!', '!=', '!~'
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- when '<<'
- # TODO next token?
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- when '?'
- @lex_state = EXPR_BEG
- when '&&', '||', '+=', '-=', '*=', '**=',
- '&=', '|=', '^=', '<<=', '>>=', '||=', '&&='
- @lex_state = EXPR_BEG
- when '::'
- case @lex_state
- when EXPR_ARG, EXPR_CMDARG
- @lex_state = EXPR_DOT
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- else
- case @lex_state
- when EXPR_FNAME, EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_BEG
- end
- end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_kw(tok, data)
- case tok
- when 'class'
- @lex_state = EXPR_CLASS
- @in_fname = true
- when 'def'
- @lex_state = EXPR_FNAME
- @continue = true
- @in_fname = true
- when 'if', 'unless', 'while', 'until'
- if ((EXPR_MID | EXPR_END | EXPR_ENDARG | EXPR_ENDFN | EXPR_ARG | EXPR_CMDARG) & @lex_state) != 0 # postfix if
- @lex_state = EXPR_BEG | EXPR_LABEL
- else
- @lex_state = EXPR_BEG
- end
- when 'begin', 'case', 'when'
- @lex_state = EXPR_BEG
- when 'return', 'break'
- @lex_state = EXPR_MID
- else
- if @lex_state == EXPR_FNAME
- @lex_state = EXPR_END
- else
- @lex_state = EXPR_END
- end
- end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_tstring_beg(tok, data)
- @lex_state = EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_tstring_end(tok, data)
- @lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_CHAR(tok, data)
- @lex_state = EXPR_END
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_period(tok, data)
- @lex_state = EXPR_DOT
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_int(tok, data)
- @lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_float(tok, data)
- @lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_rational(tok, data)
- @lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_imaginary(tok, data)
- @lex_state = EXPR_END | EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_symbeg(tok, data)
- @lex_state = EXPR_FNAME
- @continue = true
- @in_fname = true
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- private def on_variables(event, tok, data)
- if @in_fname
- @lex_state = EXPR_ENDFN
- @in_fname = false
- @continue = false
- elsif @continue
- case @lex_state
- when EXPR_DOT
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_ENDFN
- @continue = false
- end
- else
- @lex_state = EXPR_CMDARG
- end
- data << Token.new(lineno, column, event, tok, @lex_state)
- end
-
- def on_ident(tok, data)
- on_variables(__method__, tok, data)
- end
-
- def on_ivar(tok, data)
- @lex_state = EXPR_END
- on_variables(__method__, tok, data)
- end
-
- def on_cvar(tok, data)
- @lex_state = EXPR_END
- on_variables(__method__, tok, data)
- end
-
- def on_gvar(tok, data)
- @lex_state = EXPR_END
- on_variables(__method__, tok, data)
- end
-
- def on_backref(tok, data)
- @lex_state = EXPR_END
- on_variables(__method__, tok, data)
- end
-
- def on_lparen(tok, data)
- @lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_rparen(tok, data)
- @lex_state = EXPR_ENDFN
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_lbrace(tok, data)
- @lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_rbrace(tok, data)
- @lex_state = EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_lbracket(tok, data)
- @lex_state = EXPR_LABEL | EXPR_BEG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_rbracket(tok, data)
- @lex_state = EXPR_ENDARG
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_const(tok, data)
- case @lex_state
- when EXPR_FNAME
- @lex_state = EXPR_ENDFN
- when EXPR_CLASS, EXPR_CMDARG, EXPR_MID
- @lex_state = EXPR_ARG
- else
- @lex_state = EXPR_CMDARG
- end
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_sp(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_comma(tok, data)
- @lex_state = EXPR_BEG | EXPR_LABEL if (EXPR_ARG_ANY & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_comment(tok, data)
- @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_ignored_sp(tok, data)
- @lex_state = EXPR_BEG unless (EXPR_LABEL & @lex_state) != 0
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- end
-
- def on_heredoc_beg(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- @lex_state = EXPR_END
- data
- end
-
- def on_heredoc_end(tok, data)
- data << Token.new(lineno, column, __method__, tok, @lex_state)
- @lex_state = EXPR_BEG
- data
- end
-
- def on_default(event, tok, data)
- reset
- data << Token.new(lineno, column, event, tok, @lex_state)
- end
- end unless RIPPER_HAS_LEX_STATE
-
- class InnerStateLex < Ripper::Filter
- def initialize(code)
- super(code)
- end
-
- def on_default(event, tok, data)
- data << Token.new(lineno, column, event, tok, state)
- end
- end if RIPPER_HAS_LEX_STATE
-
- def get_squashed_tk
- if @buf.empty?
- tk = @tokens.shift
- else
- tk = @buf.shift
- end
- return nil if tk.nil?
- case tk[:kind]
- when :on_symbeg then
- tk = get_symbol_tk(tk)
- when :on_tstring_beg then
- tk = get_string_tk(tk)
- when :on_backtick then
- if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0
- @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
- tk[:kind] = :on_ident
- tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
- else
- tk = get_string_tk(tk)
- end
- when :on_regexp_beg then
- tk = get_regexp_tk(tk)
- when :on_embdoc_beg then
- tk = get_embdoc_tk(tk)
- when :on_heredoc_beg then
- @heredoc_queue << retrieve_heredoc_info(tk)
- @inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE
- when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
- if !@heredoc_queue.empty?
- get_heredoc_tk(*@heredoc_queue.shift)
- elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil
- tk[:text] = ''
- end
- when :on_words_beg then
- tk = get_words_tk(tk)
- when :on_qwords_beg then
- tk = get_words_tk(tk)
- when :on_symbols_beg then
- tk = get_words_tk(tk)
- when :on_qsymbols_beg then
- tk = get_words_tk(tk)
- when :on_op then
- if '&.' == tk[:text]
- tk[:kind] = :on_period
- else
- tk = get_op_tk(tk)
- end
- end
- tk
- end
-
- private def get_symbol_tk(tk)
- is_symbol = true
- symbol_tk = Token.new(tk.line_no, tk.char_no, :on_symbol)
- if ":'" == tk[:text] or ':"' == tk[:text]
- tk1 = get_string_tk(tk)
- symbol_tk[:text] = tk1[:text]
- symbol_tk[:state] = tk1[:state]
- else
- case (tk1 = get_squashed_tk)[:kind]
- when :on_ident
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_tstring_content
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = get_squashed_tk[:state] # skip :on_tstring_end
- when :on_tstring_end
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_op
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_ivar
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_cvar
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_gvar
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_const
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- when :on_kw
- symbol_tk[:text] = ":#{tk1[:text]}"
- symbol_tk[:state] = tk1[:state]
- else
- is_symbol = false
- tk = tk1
- end
- end
- if is_symbol
- tk = symbol_tk
- end
- tk
- end
-
- private def get_string_tk(tk)
- string = tk[:text]
- state = nil
- kind = :on_tstring
- loop do
- inner_str_tk = get_squashed_tk
- if inner_str_tk.nil?
- break
- elsif :on_tstring_end == inner_str_tk[:kind]
- string = string + inner_str_tk[:text]
- state = inner_str_tk[:state]
- break
- elsif :on_label_end == inner_str_tk[:kind]
- string = string + inner_str_tk[:text]
- state = inner_str_tk[:state]
- kind = :on_symbol
- break
- else
- string = string + inner_str_tk[:text]
- if :on_embexpr_beg == inner_str_tk[:kind] then
- kind = :on_dstring if :on_tstring == kind
- end
- end
- end
- Token.new(tk.line_no, tk.char_no, kind, string, state)
- end
-
- private def get_regexp_tk(tk)
- string = tk[:text]
- state = nil
- loop do
- inner_str_tk = get_squashed_tk
- if inner_str_tk.nil?
- break
- elsif :on_regexp_end == inner_str_tk[:kind]
- string = string + inner_str_tk[:text]
- state = inner_str_tk[:state]
- break
- else
- string = string + inner_str_tk[:text]
- end
- end
- Token.new(tk.line_no, tk.char_no, :on_regexp, string, state)
- end
-
- private def get_embdoc_tk(tk)
- string = tk[:text]
- until :on_embdoc_end == (embdoc_tk = get_squashed_tk)[:kind] do
- string = string + embdoc_tk[:text]
- end
- string = string + embdoc_tk[:text]
- Token.new(tk.line_no, tk.char_no, :on_embdoc, string, embdoc_tk.state)
- end
-
- private def get_heredoc_tk(heredoc_name, indent)
- string = ''
- start_tk = nil
- prev_tk = nil
- until heredoc_end?(heredoc_name, indent, tk = @tokens.shift) do
- start_tk = tk unless start_tk
- if (prev_tk.nil? or "\n" == prev_tk[:text][-1]) and 0 != tk[:char_no]
- string = string + (' ' * tk[:char_no])
- end
- string = string + tk[:text]
- prev_tk = tk
- end
- start_tk = tk unless start_tk
- prev_tk = tk unless prev_tk
- @buf.unshift tk # closing heredoc
- heredoc_tk = Token.new(start_tk.line_no, start_tk.char_no, :on_heredoc, string, prev_tk.state)
- @buf.unshift heredoc_tk
- end
-
- private def retrieve_heredoc_info(tk)
- name = tk[:text].gsub(/\A<<[-~]?(['"`]?)(.+)\1\z/, '\2')
- indent = tk[:text] =~ /\A<<[-~]/
- [name, indent]
- end
-
- private def heredoc_end?(name, indent, tk)
- result = false
- if :on_heredoc_end == tk[:kind] then
- tk_name = tk[:text].chomp
- tk_name.lstrip! if indent
- if name == tk_name
- result = true
- end
- end
- result
- end
-
- private def get_words_tk(tk)
- string = ''
- start_token = tk[:text]
- start_quote = tk[:text].rstrip[-1]
- line_no = tk[:line_no]
- char_no = tk[:char_no]
- state = tk[:state]
- end_quote =
- case start_quote
- when ?( then ?)
- when ?[ then ?]
- when ?{ then ?}
- when ?< then ?>
- else start_quote
- end
- end_token = nil
- loop do
- tk = get_squashed_tk
- if tk.nil?
- end_token = end_quote
- break
- elsif :on_tstring_content == tk[:kind] then
- string += tk[:text]
- elsif :on_words_sep == tk[:kind] or :on_tstring_end == tk[:kind] then
- if end_quote == tk[:text].strip then
- end_token = tk[:text]
- break
- else
- string += tk[:text]
- end
- else
- string += tk[:text]
- end
- end
- text = "#{start_token}#{string}#{end_token}"
- Token.new(line_no, char_no, :on_dstring, text, state)
- end
-
- private def get_op_tk(tk)
- redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~]
- if redefinable_operators.include?(tk[:text]) and tk[:state] == EXPR_ARG then
- @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
- tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
- tk[:kind] = :on_ident
- elsif tk[:text] =~ /^[-+]$/ then
- tk_ahead = get_squashed_tk
- case tk_ahead[:kind]
- when :on_int, :on_float, :on_rational, :on_imaginary then
- tk[:text] += tk_ahead[:text]
- tk[:kind] = tk_ahead[:kind]
- tk[:state] = tk_ahead[:state]
- when :on_heredoc_beg, :on_tstring, :on_dstring # frozen/non-frozen string literal
- tk[:text] += tk_ahead[:text]
- tk[:kind] = tk_ahead[:kind]
- tk[:state] = tk_ahead[:state]
- else
- @buf.unshift tk_ahead
- end
- end
- tk
- end
-
- def initialize(code)
- @buf = []
- @heredoc_queue = []
- @inner_lex = InnerStateLex.new(code)
- @tokens = @inner_lex.parse([])
- end
-
- def self.parse(code)
- lex = self.new(code)
- tokens = []
- begin
- while tk = lex.get_squashed_tk
- tokens.push tk
- end
- rescue StopIteration
- end
- tokens
- end
-
- def self.end?(token)
- (token[:state] & EXPR_END)
- end
-end
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
deleted file mode 100644
index 0323e4de41..0000000000
--- a/lib/rdoc/parser/ruby.rb
+++ /dev/null
@@ -1,2360 +0,0 @@
-# frozen_string_literal: true
-##
-# This file contains stuff stolen outright from:
-#
-# rtags.rb -
-# ruby-lex.rb - ruby lexcal analyzer
-# ruby-token.rb - ruby tokens
-# by Keiju ISHITSUKA (Nippon Rational Inc.)
-#
-
-require 'ripper'
-require_relative 'ripper_state_lex'
-
-##
-# Extracts code elements from a source file returning a TopLevel object
-# containing the constituent file elements.
-#
-# This file is based on rtags
-#
-# RubyParser understands how to document:
-# * classes
-# * modules
-# * methods
-# * constants
-# * aliases
-# * private, public, protected
-# * private_class_function, public_class_function
-# * private_constant, public_constant
-# * module_function
-# * attr, attr_reader, attr_writer, attr_accessor
-# * extra accessors given on the command line
-# * metaprogrammed methods
-# * require
-# * include
-#
-# == Method Arguments
-#
-#--
-# NOTE: I don't think this works, needs tests, remove the paragraph following
-# this block when known to work
-#
-# The parser extracts the arguments from the method definition. You can
-# override this with a custom argument definition using the :args: directive:
-#
-# ##
-# # This method tries over and over until it is tired
-#
-# def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try
-# puts thing_to_try
-# go_go_go thing_to_try, tries - 1
-# end
-#
-# If you have a more-complex set of overrides you can use the :call-seq:
-# directive:
-#++
-#
-# The parser extracts the arguments from the method definition. You can
-# override this with a custom argument definition using the :call-seq:
-# directive:
-#
-# ##
-# # This method can be called with a range or an offset and length
-# #
-# # :call-seq:
-# # my_method(Range)
-# # my_method(offset, length)
-#
-# def my_method(*args)
-# end
-#
-# The parser extracts +yield+ expressions from method bodies to gather the
-# yielded argument names. If your method manually calls a block instead of
-# yielding or you want to override the discovered argument names use
-# the :yields: directive:
-#
-# ##
-# # My method is awesome
-#
-# def my_method(&block) # :yields: happy, times
-# block.call 1, 2
-# end
-#
-# == Metaprogrammed Methods
-#
-# To pick up a metaprogrammed method, the parser looks for a comment starting
-# with '##' before an identifier:
-#
-# ##
-# # This is a meta-programmed method!
-#
-# add_my_method :meta_method, :arg1, :arg2
-#
-# The parser looks at the token after the identifier to determine the name, in
-# this example, :meta_method. If a name cannot be found, a warning is printed
-# and 'unknown is used.
-#
-# You can force the name of a method using the :method: directive:
-#
-# ##
-# # :method: some_method!
-#
-# By default, meta-methods are instance methods. To indicate that a method is
-# a singleton method instead use the :singleton-method: directive:
-#
-# ##
-# # :singleton-method:
-#
-# You can also use the :singleton-method: directive with a name:
-#
-# ##
-# # :singleton-method: some_method!
-#
-# You can define arguments for metaprogrammed methods via either the
-# :call-seq:, :arg: or :args: directives.
-#
-# Additionally you can mark a method as an attribute by
-# using :attr:, :attr_reader:, :attr_writer: or :attr_accessor:. Just like
-# for :method:, the name is optional.
-#
-# ##
-# # :attr_reader: my_attr_name
-#
-# == Hidden methods and attributes
-#
-# You can provide documentation for methods that don't appear using
-# the :method:, :singleton-method: and :attr: directives:
-#
-# ##
-# # :attr_writer: ghost_writer
-# # There is an attribute here, but you can't see it!
-#
-# ##
-# # :method: ghost_method
-# # There is a method here, but you can't see it!
-#
-# ##
-# # this is a comment for a regular method
-#
-# def regular_method() end
-#
-# Note that by default, the :method: directive will be ignored if there is a
-# standard rdocable item following it.
-
-class RDoc::Parser::Ruby < RDoc::Parser
-
- parse_files_matching(/\.rbw?$/)
-
- include RDoc::TokenStream
- include RDoc::Parser::RubyTools
-
- ##
- # RDoc::NormalClass type
-
- NORMAL = "::"
-
- ##
- # RDoc::SingleClass type
-
- SINGLE = "<<"
-
- ##
- # Creates a new Ruby parser.
-
- def initialize(top_level, file_name, content, options, stats)
- super
-
- content = handle_tab_width(content)
-
- @size = 0
- @token_listeners = nil
- content = RDoc::Encoding.remove_magic_comment content
- @scanner = RDoc::Parser::RipperStateLex.parse(content)
- @content = content
- @scanner_point = 0
- @prev_seek = nil
- @markup = @options.markup
- @track_visibility = :nodoc != @options.visibility
- @encoding = @options.encoding
-
- reset
- end
-
- def tk_nl?(tk)
- :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]
- end
-
- ##
- # Retrieves the read token stream and replaces +pattern+ with +replacement+
- # using gsub. If the result is only a ";" returns an empty string.
-
- def get_tkread_clean pattern, replacement # :nodoc:
- read = get_tkread.gsub(pattern, replacement).strip
- return '' if read == ';'
- read
- end
-
- ##
- # Extracts the visibility information for the visibility token +tk+
- # and +single+ class type identifier.
- #
- # Returns the visibility type (a string), the visibility (a symbol) and
- # +singleton+ if the methods following should be converted to singleton
- # methods.
-
- def get_visibility_information tk, single # :nodoc:
- vis_type = tk[:text]
- singleton = single == SINGLE
-
- vis =
- case vis_type
- when 'private' then :private
- when 'protected' then :protected
- when 'public' then :public
- when 'private_class_method' then
- singleton = true
- :private
- when 'public_class_method' then
- singleton = true
- :public
- when 'module_function' then
- singleton = true
- :public
- else
- raise RDoc::Error, "Invalid visibility: #{tk.name}"
- end
-
- return vis_type, vis, singleton
- end
-
- ##
- # Look for the first comment in a file that isn't a shebang line.
-
- def collect_first_comment
- skip_tkspace
- comment = ''.dup
- comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
- first_line = true
- first_comment_tk_kind = nil
- line_no = nil
-
- tk = get_tk
-
- while tk && (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])
- comment_body = retrieve_comment_body(tk)
- if first_line and comment_body =~ /\A#!/ then
- skip_tkspace
- tk = get_tk
- elsif first_line and comment_body =~ /\A#\s*-\*-/ then
- first_line = false
- skip_tkspace
- tk = get_tk
- else
- break if first_comment_tk_kind and not first_comment_tk_kind === tk[:kind]
- first_comment_tk_kind = tk[:kind]
-
- line_no = tk[:line_no] if first_line
- first_line = false
- comment << comment_body
- tk = get_tk
-
- if :on_nl === tk then
- skip_tkspace_without_nl
- tk = get_tk
- end
- end
- end
-
- unget_tk tk
-
- new_comment comment, line_no
- end
-
- ##
- # Consumes trailing whitespace from the token stream
-
- def consume_trailing_spaces # :nodoc:
- skip_tkspace_without_nl
- end
-
- ##
- # Creates a new attribute in +container+ with +name+.
-
- def create_attr container, single, name, rw, comment # :nodoc:
- att = RDoc::Attr.new get_tkread, name, rw, comment, single == SINGLE
- record_location att
-
- container.add_attribute att
- @stats.add_attribute att
-
- att
- end
-
- ##
- # Creates a module alias in +container+ at +rhs_name+ (or at the top-level
- # for "::") with the name from +constant+.
-
- def create_module_alias container, constant, rhs_name # :nodoc:
- mod = if rhs_name =~ /^::/ then
- @store.find_class_or_module rhs_name
- else
- container.find_module_named rhs_name
- end
-
- container.add_module_alias mod, rhs_name, constant, @top_level
- end
-
- ##
- # Aborts with +msg+
-
- def error(msg)
- msg = make_message msg
-
- abort msg
- end
-
- ##
- # Looks for a true or false token.
-
- def get_bool
- skip_tkspace
- tk = get_tk
- if :on_kw == tk[:kind] && 'true' == tk[:text]
- true
- elsif :on_kw == tk[:kind] && ('false' == tk[:text] || 'nil' == tk[:text])
- false
- else
- unget_tk tk
- true
- end
- end
-
- ##
- # Look for the name of a class of module (optionally with a leading :: or
- # with :: separated named) and return the ultimate name, the associated
- # container, and the given name (with the ::).
-
- def get_class_or_module container, ignore_constants = false
- skip_tkspace
- name_t = get_tk
- given_name = ''.dup
-
- # class ::A -> A is in the top level
- if :on_op == name_t[:kind] and '::' == name_t[:text] then # bug
- name_t = get_tk
- container = @top_level
- given_name << '::'
- end
-
- skip_tkspace_without_nl
- given_name << name_t[:text]
-
- is_self = name_t[:kind] == :on_op && name_t[:text] == '<<'
- new_modules = []
- while !is_self && (tk = peek_tk) and :on_op == tk[:kind] and '::' == tk[:text] do
- prev_container = container
- container = container.find_module_named name_t[:text]
- container ||=
- if ignore_constants then
- c = RDoc::NormalModule.new name_t[:text]
- c.store = @store
- new_modules << [prev_container, c]
- c
- else
- c = prev_container.add_module RDoc::NormalModule, name_t[:text]
- c.ignore unless prev_container.document_children
- @top_level.add_to_classes_or_modules c
- c
- end
-
- record_location container
-
- get_tk
- skip_tkspace
- if :on_lparen == peek_tk[:kind] # ProcObjectInConstant::()
- parse_method_or_yield_parameters
- break
- end
- name_t = get_tk
- unless :on_const == name_t[:kind] || :on_ident == name_t[:kind]
- raise RDoc::Error, "Invalid class or module definition: #{given_name}"
- end
- if prev_container == container and !ignore_constants
- given_name = name_t[:text]
- else
- given_name << '::' + name_t[:text]
- end
- end
-
- skip_tkspace_without_nl
-
- return [container, name_t, given_name, new_modules]
- end
-
- ##
- # Skip opening parentheses and yield the block.
- # Skip closing parentheses too when exists.
-
- def skip_parentheses(&block)
- left_tk = peek_tk
-
- if :on_lparen == left_tk[:kind]
- get_tk
-
- ret = skip_parentheses(&block)
-
- right_tk = peek_tk
- if :on_rparen == right_tk[:kind]
- get_tk
- end
-
- ret
- else
- yield
- end
- end
-
- ##
- # Return a superclass, which can be either a constant of an expression
-
- def get_class_specification
- tk = peek_tk
- if tk.nil?
- return ''
- elsif :on_kw == tk[:kind] && 'self' == tk[:text]
- return 'self'
- elsif :on_gvar == tk[:kind]
- return ''
- end
-
- res = get_constant
-
- skip_tkspace_without_nl
-
- get_tkread # empty out read buffer
-
- tk = get_tk
- return res unless tk
-
- case tk[:kind]
- when :on_nl, :on_comment, :on_embdoc, :on_semicolon then
- unget_tk(tk)
- return res
- end
-
- res += parse_call_parameters(tk)
- res
- end
-
- ##
- # Parse a constant, which might be qualified by one or more class or module
- # names
-
- def get_constant
- res = ""
- skip_tkspace_without_nl
- tk = get_tk
-
- while tk && ((:on_op == tk[:kind] && '::' == tk[:text]) || :on_const == tk[:kind]) do
- res += tk[:text]
- tk = get_tk
- end
-
- unget_tk(tk)
- res
- end
-
- ##
- # Get an included module that may be surrounded by parens
-
- def get_included_module_with_optional_parens
- skip_tkspace_without_nl
- get_tkread
- tk = get_tk
- end_token = get_end_token tk
- return '' unless end_token
-
- nest = 0
- continue = false
- only_constant = true
-
- while tk != nil do
- is_element_of_constant = false
- case tk[:kind]
- when :on_semicolon then
- break if nest == 0
- when :on_lbracket then
- nest += 1
- when :on_rbracket then
- nest -= 1
- when :on_lbrace then
- nest += 1
- when :on_rbrace then
- nest -= 1
- if nest <= 0
- # we might have a.each { |i| yield i }
- unget_tk(tk) if nest < 0
- break
- end
- when :on_lparen then
- nest += 1
- when end_token[:kind] then
- if end_token[:kind] == :on_rparen
- nest -= 1
- break if nest <= 0
- else
- break if nest <= 0
- end
- when :on_rparen then
- nest -= 1
- when :on_comment, :on_embdoc then
- @read.pop
- if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
- (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
- break if !continue and nest <= 0
- end
- when :on_comma then
- continue = true
- when :on_ident then
- continue = false if continue
- when :on_kw then
- case tk[:text]
- when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
- nest += 1
- when 'if', 'unless', 'while', 'until', 'rescue'
- # postfix if/unless/while/until/rescue must be EXPR_LABEL
- nest += 1 unless (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0
- when 'end'
- nest -= 1
- break if nest == 0
- end
- when :on_const then
- is_element_of_constant = true
- when :on_op then
- is_element_of_constant = true if '::' == tk[:text]
- end
- only_constant = false unless is_element_of_constant
- tk = get_tk
- end
-
- if only_constant
- get_tkread_clean(/\s+/, ' ')
- else
- ''
- end
- end
-
- ##
- # Little hack going on here. In the statement:
- #
- # f = 2*(1+yield)
- #
- # We see the RPAREN as the next token, so we need to exit early. This still
- # won't catch all cases (such as "a = yield + 1"
-
- def get_end_token tk # :nodoc:
- case tk[:kind]
- when :on_lparen
- token = RDoc::Parser::RipperStateLex::Token.new
- token[:kind] = :on_rparen
- token[:text] = ')'
- token
- when :on_rparen
- nil
- else
- token = RDoc::Parser::RipperStateLex::Token.new
- token[:kind] = :on_nl
- token[:text] = "\n"
- token
- end
- end
-
- ##
- # Retrieves the method container for a singleton method.
-
- def get_method_container container, name_t # :nodoc:
- prev_container = container
- container = container.find_module_named(name_t[:text])
-
- unless container then
- constant = prev_container.constants.find do |const|
- const.name == name_t[:text]
- end
-
- if constant then
- parse_method_dummy prev_container
- return
- end
- end
-
- unless container then
- # TODO seems broken, should starting at Object in @store
- obj = name_t[:text].split("::").inject(Object) do |state, item|
- state.const_get(item)
- end rescue nil
-
- type = obj.class == Class ? RDoc::NormalClass : RDoc::NormalModule
-
- unless [Class, Module].include?(obj.class) then
- warn("Couldn't find #{name_t[:text]}. Assuming it's a module")
- end
-
- if type == RDoc::NormalClass then
- sclass = obj.superclass ? obj.superclass.name : nil
- container = prev_container.add_class type, name_t[:text], sclass
- else
- container = prev_container.add_module type, name_t[:text]
- end
-
- record_location container
- end
-
- container
- end
-
- ##
- # Extracts a name or symbol from the token stream.
-
- def get_symbol_or_name
- tk = get_tk
- case tk[:kind]
- when :on_symbol then
- text = tk[:text].sub(/^:/, '')
-
- next_tk = peek_tk
- if next_tk && :on_op == next_tk[:kind] && '=' == next_tk[:text] then
- get_tk
- text << '='
- end
-
- text
- when :on_ident, :on_const, :on_gvar, :on_cvar, :on_ivar, :on_op, :on_kw then
- tk[:text]
- when :on_tstring, :on_dstring then
- tk[:text][1..-2]
- else
- raise RDoc::Error, "Name or symbol expected (got #{tk})"
- end
- end
-
- ##
- # Marks containers between +container+ and +ancestor+ as ignored
-
- def suppress_parents container, ancestor # :nodoc:
- while container and container != ancestor do
- container.suppress unless container.documented?
- container = container.parent
- end
- end
-
- ##
- # Look for directives in a normal comment block:
- #
- # # :stopdoc:
- # # Don't display comment from this point forward
- #
- # This routine modifies its +comment+ parameter.
-
- def look_for_directives_in container, comment
- @preprocess.handle comment, container do |directive, param|
- case directive
- when 'method', 'singleton-method',
- 'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then
- false # handled elsewhere
- when 'section' then
- break unless container.kind_of?(RDoc::Context)
- container.set_current_section param, comment.dup
- comment.text = ''
- break
- end
- end
-
- comment.remove_private
- end
-
- ##
- # Adds useful info about the parser to +message+
-
- def make_message message
- prefix = "#{@file_name}:".dup
-
- tk = peek_tk
- prefix << "#{tk[:line_no]}:#{tk[:char_no]}:" if tk
-
- "#{prefix} #{message}"
- end
-
- ##
- # Creates a comment with the correct format
-
- def new_comment comment, line_no = nil
- c = RDoc::Comment.new comment, @top_level, :ruby
- c.line = line_no
- c.format = @markup
- c
- end
-
- ##
- # Creates an RDoc::Attr for the name following +tk+, setting the comment to
- # +comment+.
-
- def parse_attr(context, single, tk, comment)
- line_no = tk[:line_no]
-
- args = parse_symbol_arg 1
- if args.size > 0 then
- name = args[0]
- rw = "R"
- skip_tkspace_without_nl
- tk = get_tk
-
- if :on_comma == tk[:kind] then
- rw = "RW" if get_bool
- else
- unget_tk tk
- end
-
- att = create_attr context, single, name, rw, comment
- att.line = line_no
-
- read_documentation_modifiers att, RDoc::ATTR_MODIFIERS
- else
- warn "'attr' ignored - looks like a variable"
- end
- end
-
- ##
- # Creates an RDoc::Attr for each attribute listed after +tk+, setting the
- # comment for each to +comment+.
-
- def parse_attr_accessor(context, single, tk, comment)
- line_no = tk[:line_no]
-
- args = parse_symbol_arg
- rw = "?"
-
- tmp = RDoc::CodeObject.new
- read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
- # TODO In most other places we let the context keep track of document_self
- # and add found items appropriately but here we do not. I'm not sure why.
- return if @track_visibility and not tmp.document_self
-
- case tk[:text]
- when "attr_reader" then rw = "R"
- when "attr_writer" then rw = "W"
- when "attr_accessor" then rw = "RW"
- else
- rw = '?'
- end
-
- for name in args
- att = create_attr context, single, name, rw, comment
- att.line = line_no
- end
- end
-
- ##
- # Parses an +alias+ in +context+ with +comment+
-
- def parse_alias(context, single, tk, comment)
- line_no = tk[:line_no]
-
- skip_tkspace
-
- if :on_lparen === peek_tk[:kind] then
- get_tk
- skip_tkspace
- end
-
- new_name = get_symbol_or_name
-
- skip_tkspace
- if :on_comma === peek_tk[:kind] then
- get_tk
- skip_tkspace
- end
-
- begin
- old_name = get_symbol_or_name
- rescue RDoc::Error
- return
- end
-
- al = RDoc::Alias.new(get_tkread, old_name, new_name, comment,
- single == SINGLE)
- record_location al
- al.line = line_no
-
- read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
- context.add_alias al
- @stats.add_alias al
-
- al
- end
-
- ##
- # Extracts call parameters from the token stream.
-
- def parse_call_parameters(tk)
- end_token = case tk[:kind]
- when :on_lparen
- :on_rparen
- when :on_rparen
- return ""
- else
- :on_nl
- end
- nest = 0
-
- loop do
- break if tk.nil?
- case tk[:kind]
- when :on_semicolon
- break
- when :on_lparen
- nest += 1
- when end_token
- if end_token == :on_rparen
- nest -= 1
- break if RDoc::Parser::RipperStateLex.end?(tk) and nest <= 0
- else
- break if RDoc::Parser::RipperStateLex.end?(tk)
- end
- when :on_comment, :on_embdoc
- unget_tk(tk)
- break
- when :on_op
- if tk[:text] =~ /^(.{1,2})?=$/
- unget_tk(tk)
- break
- end
- end
- tk = get_tk
- end
-
- get_tkread_clean "\n", " "
- end
-
- ##
- # Parses a class in +context+ with +comment+
-
- def parse_class container, single, tk, comment
- line_no = tk[:line_no]
-
- declaration_context = container
- container, name_t, given_name, = get_class_or_module container
-
- if name_t[:kind] == :on_const
- cls = parse_class_regular container, declaration_context, single,
- name_t, given_name, comment
- elsif name_t[:kind] == :on_op && name_t[:text] == '<<'
- case name = skip_parentheses { get_class_specification }
- when 'self', container.name
- read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
- parse_statements container, SINGLE
- return # don't update line
- else
- cls = parse_class_singleton container, name, comment
- end
- else
- warn "Expected class name or '<<'. Got #{name_t[:kind]}: #{name_t[:text].inspect}"
- return
- end
-
- cls.line = line_no
-
- # after end modifiers
- read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
-
- cls
- end
-
- ##
- # Parses and creates a regular class
-
- def parse_class_regular container, declaration_context, single, # :nodoc:
- name_t, given_name, comment
- superclass = '::Object'
-
- if given_name =~ /^::/ then
- declaration_context = @top_level
- given_name = $'
- end
-
- tk = peek_tk
- if tk[:kind] == :on_op && tk[:text] == '<' then
- get_tk
- skip_tkspace
- superclass = get_class_specification
- superclass = '(unknown)' if superclass.empty?
- end
-
- cls_type = single == SINGLE ? RDoc::SingleClass : RDoc::NormalClass
- cls = declaration_context.add_class cls_type, given_name, superclass
- cls.ignore unless container.document_children
-
- read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
- record_location cls
-
- cls.add_comment comment, @top_level
-
- @top_level.add_to_classes_or_modules cls
- @stats.add_class cls
-
- suppress_parents container, declaration_context unless cls.document_self
-
- parse_statements cls
-
- cls
- end
-
- ##
- # Parses a singleton class in +container+ with the given +name+ and
- # +comment+.
-
- def parse_class_singleton container, name, comment # :nodoc:
- other = @store.find_class_named name
-
- unless other then
- if name =~ /^::/ then
- name = $'
- container = @top_level
- end
-
- other = container.add_module RDoc::NormalModule, name
- record_location other
-
- # class << $gvar
- other.ignore if name.empty?
-
- other.add_comment comment, @top_level
- end
-
- # notify :nodoc: all if not a constant-named class/module
- # (and remove any comment)
- unless name =~ /\A(::)?[A-Z]/ then
- other.document_self = nil
- other.document_children = false
- other.clear_comment
- end
-
- @top_level.add_to_classes_or_modules other
- @stats.add_class other
-
- read_documentation_modifiers other, RDoc::CLASS_MODIFIERS
- parse_statements(other, SINGLE)
-
- other
- end
-
- ##
- # Parses a constant in +context+ with +comment+. If +ignore_constants+ is
- # true, no found constants will be added to RDoc.
-
- def parse_constant container, tk, comment, ignore_constants = false
- line_no = tk[:line_no]
-
- name = tk[:text]
- skip_tkspace_without_nl
-
- return unless name =~ /^\w+$/
-
- new_modules = []
- if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then
- unget_tk tk
-
- container, name_t, _, new_modules = get_class_or_module container, true
-
- name = name_t[:text]
- end
-
- is_array_or_hash = false
- if peek_tk && :on_lbracket == peek_tk[:kind]
- get_tk
- nest = 1
- while bracket_tk = get_tk
- case bracket_tk[:kind]
- when :on_lbracket
- nest += 1
- when :on_rbracket
- nest -= 1
- break if nest == 0
- end
- end
- skip_tkspace_without_nl
- is_array_or_hash = true
- end
-
- unless peek_tk && :on_op == peek_tk[:kind] && '=' == peek_tk[:text] then
- return false
- end
- get_tk
-
- unless ignore_constants
- new_modules.each do |prev_c, new_module|
- prev_c.add_module_by_normal_module new_module
- new_module.ignore unless prev_c.document_children
- @top_level.add_to_classes_or_modules new_module
- end
- end
-
- value = ''
- con = RDoc::Constant.new name, value, comment
-
- body = parse_constant_body container, con, is_array_or_hash
-
- return unless body
-
- con.value = body
- record_location con
- con.line = line_no
- read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
-
- return if is_array_or_hash
-
- @stats.add_constant con
- container.add_constant con
-
- true
- end
-
- def parse_constant_body container, constant, is_array_or_hash # :nodoc:
- nest = 0
- rhs_name = ''.dup
-
- get_tkread
-
- tk = get_tk
-
- body = nil
- loop do
- break if tk.nil?
- if :on_semicolon == tk[:kind] then
- break if nest <= 0
- elsif [:on_tlambeg, :on_lparen, :on_lbrace, :on_lbracket].include?(tk[:kind]) then
- nest += 1
- elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
- nest += 1
- elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
- nest += 1
- end
- elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
- (:on_kw == tk[:kind] && 'end' == tk[:text]) then
- nest -= 1
- elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
- unget_tk tk
- if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
- body = get_tkread_clean(/^[ \t]+/, '')
- read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
- break
- else
- read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
- end
- elsif :on_const == tk[:kind] then
- rhs_name << tk[:text]
-
- next_tk = peek_tk
- if nest <= 0 and (next_tk.nil? || :on_nl == next_tk[:kind]) then
- create_module_alias container, constant, rhs_name unless is_array_or_hash
- break
- end
- elsif :on_nl == tk[:kind] then
- if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
- unget_tk tk
- break
- end
- elsif :on_op == tk[:kind] && '::' == tk[:text]
- rhs_name << '::'
- end
- tk = get_tk
- end
-
- body ? body : get_tkread_clean(/^[ \t]+/, '')
- end
-
- ##
- # Generates an RDoc::Method or RDoc::Attr from +comment+ by looking for
- # :method: or :attr: directives in +comment+.
-
- def parse_comment container, tk, comment
- return parse_comment_tomdoc container, tk, comment if @markup == 'tomdoc'
- column = tk[:char_no]
- line_no = comment.line.nil? ? tk[:line_no] : comment.line
-
- comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
- singleton = !!$~
-
- co =
- if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then
- line_no += $`.count("\n")
- parse_comment_ghost container, comment.text, $1, column, line_no, comment
- elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then
- parse_comment_attr container, $1, $3, comment
- end
-
- if co then
- co.singleton = singleton
- co.line = line_no
- end
-
- true
- end
-
- ##
- # Parse a comment that is describing an attribute in +container+ with the
- # given +name+ and +comment+.
-
- def parse_comment_attr container, type, name, comment # :nodoc:
- return if name.empty?
-
- rw = case type
- when 'attr_reader' then 'R'
- when 'attr_writer' then 'W'
- else 'RW'
- end
-
- create_attr container, NORMAL, name, rw, comment
- end
-
- def parse_comment_ghost container, text, name, column, line_no, # :nodoc:
- comment
- name = nil if name.empty?
-
- meth = RDoc::GhostMethod.new get_tkread, name
- record_location meth
-
- meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
- meth.add_tokens [position_comment, newline, indent]
-
- meth.params =
- if text.sub!(/^#\s+:?args?:\s*(.*?)\s*$/i, '') then
- $1
- else
- ''
- end
-
- comment.normalize
- comment.extract_call_seq meth
-
- return unless meth.name
-
- container.add_method meth
-
- meth.comment = comment
-
- @stats.add_method meth
-
- meth
- end
-
- ##
- # Creates an RDoc::Method on +container+ from +comment+ if there is a
- # Signature section in the comment
-
- def parse_comment_tomdoc container, tk, comment
- return unless signature = RDoc::TomDoc.signature(comment)
- column = tk[:char_no]
- line_no = tk[:line_no]
-
- name, = signature.split %r%[ \(]%, 2
-
- meth = RDoc::GhostMethod.new get_tkread, name
- record_location meth
- meth.line = line_no
-
- meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
- meth.add_tokens [position_comment, newline, indent]
-
- meth.call_seq = signature
-
- comment.normalize
-
- return unless meth.name
-
- container.add_method meth
-
- meth.comment = comment
-
- @stats.add_method meth
- end
-
- ##
- # Parses an +include+ or +extend+, indicated by the +klass+ and adds it to
- # +container+ # with +comment+
-
- def parse_extend_or_include klass, container, comment # :nodoc:
- loop do
- skip_tkspace_comment
-
- name = get_included_module_with_optional_parens
-
- unless name.empty? then
- obj = container.add klass, name, comment
- record_location obj
- end
-
- return if peek_tk.nil? || :on_comma != peek_tk[:kind]
-
- get_tk
- end
- end
-
- ##
- # Parses an +included+ with a block feature of ActiveSupport::Concern.
-
- def parse_included_with_activesupport_concern container, comment # :nodoc:
- skip_tkspace_without_nl
- tk = get_tk
- unless tk[:kind] == :on_lbracket || (tk[:kind] == :on_kw && tk[:text] == 'do')
- unget_tk tk
- return nil # should be a block
- end
-
- parse_statements container
-
- container
- end
-
- ##
- # Parses identifiers that can create new methods or change visibility.
- #
- # Returns true if the comment was not consumed.
-
- def parse_identifier container, single, tk, comment # :nodoc:
- case tk[:text]
- when 'private', 'protected', 'public', 'private_class_method',
- 'public_class_method', 'module_function' then
- parse_visibility container, single, tk
- return true
- when 'private_constant', 'public_constant'
- parse_constant_visibility container, single, tk
- return true
- when 'attr' then
- parse_attr container, single, tk, comment
- when /^attr_(reader|writer|accessor)$/ then
- parse_attr_accessor container, single, tk, comment
- when 'alias_method' then
- parse_alias container, single, tk, comment
- when 'require', 'include' then
- # ignore
- else
- if comment.text =~ /\A#\#$/ then
- case comment.text
- when /^# +:?attr(_reader|_writer|_accessor)?:/ then
- parse_meta_attr container, single, tk, comment
- else
- method = parse_meta_method container, single, tk, comment
- method.params = container.params if
- container.params
- method.block_params = container.block_params if
- container.block_params
- end
- end
- end
-
- false
- end
-
- ##
- # Parses a meta-programmed attribute and creates an RDoc::Attr.
- #
- # To create foo and bar attributes on class C with comment "My attributes":
- #
- # class C
- #
- # ##
- # # :attr:
- # #
- # # My attributes
- #
- # my_attr :foo, :bar
- #
- # end
- #
- # To create a foo attribute on class C with comment "My attribute":
- #
- # class C
- #
- # ##
- # # :attr: foo
- # #
- # # My attribute
- #
- # my_attr :foo, :bar
- #
- # end
-
- def parse_meta_attr(context, single, tk, comment)
- args = parse_symbol_arg
- rw = "?"
-
- # If nodoc is given, don't document any of them
-
- tmp = RDoc::CodeObject.new
- read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS
-
- regexp = /^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i
- if regexp =~ comment.text then
- comment.text = comment.text.sub(regexp, '')
- rw = case $1
- when 'attr_reader' then 'R'
- when 'attr_writer' then 'W'
- else 'RW'
- end
- name = $3 unless $3.empty?
- end
-
- if name then
- att = create_attr context, single, name, rw, comment
- else
- args.each do |attr_name|
- att = create_attr context, single, attr_name, rw, comment
- end
- end
-
- att
- end
-
- ##
- # Parses a meta-programmed method
-
- def parse_meta_method(container, single, tk, comment)
- column = tk[:char_no]
- line_no = tk[:line_no]
-
- start_collecting_tokens
- add_token tk
- add_token_listener self
-
- skip_tkspace_without_nl
-
- comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
- singleton = !!$~
-
- name = parse_meta_method_name comment, tk
-
- return unless name
-
- meth = RDoc::MetaMethod.new get_tkread, name
- record_location meth
- meth.line = line_no
- meth.singleton = singleton
-
- remove_token_listener self
-
- meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- position_comment = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- position_comment[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
- meth.add_tokens [position_comment, newline, indent]
- meth.add_tokens @token_stream
-
- parse_meta_method_params container, single, meth, tk, comment
-
- meth.comment = comment
-
- @stats.add_method meth
-
- meth
- end
-
- ##
- # Parses the name of a metaprogrammed method. +comment+ is used to
- # determine the name while +tk+ is used in an error message if the name
- # cannot be determined.
-
- def parse_meta_method_name comment, tk # :nodoc:
- if comment.text.sub!(/^# +:?method: *(\S*).*?\n/i, '') then
- return $1 unless $1.empty?
- end
-
- name_t = get_tk
-
- if :on_symbol == name_t[:kind] then
- name_t[:text][1..-1]
- elsif :on_tstring == name_t[:kind] then
- name_t[:text][1..-2]
- elsif :on_op == name_t[:kind] && '=' == name_t[:text] then # ignore
- remove_token_listener self
-
- nil
- else
- warn "unknown name token #{name_t.inspect} for meta-method '#{tk[:text]}'"
- 'unknown'
- end
- end
-
- ##
- # Parses the parameters and block for a meta-programmed method.
-
- def parse_meta_method_params container, single, meth, tk, comment # :nodoc:
- token_listener meth do
- meth.params = ''
-
- look_for_directives_in meth, comment
- comment.normalize
- comment.extract_call_seq meth
-
- container.add_method meth
-
- last_tk = tk
-
- while tk = get_tk do
- if :on_semicolon == tk[:kind] then
- break
- elsif :on_nl == tk[:kind] then
- break unless last_tk and :on_comma == last_tk[:kind]
- elsif :on_sp == tk[:kind] then
- # expression continues
- elsif :on_kw == tk[:kind] && 'do' == tk[:text] then
- parse_statements container, single, meth
- break
- else
- last_tk = tk
- end
- end
- end
- end
-
- ##
- # Parses a normal method defined by +def+
-
- def parse_method(container, single, tk, comment)
- singleton = nil
- added_container = false
- name = nil
- column = tk[:char_no]
- line_no = tk[:line_no]
-
- start_collecting_tokens
- add_token tk
-
- token_listener self do
- prev_container = container
- name, container, singleton = parse_method_name container
- added_container = container != prev_container
- end
-
- return unless name
-
- meth = RDoc::AnyMethod.new get_tkread, name
- look_for_directives_in meth, comment
- meth.singleton = single == SINGLE ? true : singleton
-
- record_location meth
- meth.line = line_no
-
- meth.start_collecting_tokens
- indent = RDoc::Parser::RipperStateLex::Token.new(1, 1, :on_sp, ' ' * column)
- token = RDoc::Parser::RipperStateLex::Token.new(line_no, 1, :on_comment)
- token[:text] = "# File #{@top_level.relative_name}, line #{line_no}"
- newline = RDoc::Parser::RipperStateLex::Token.new(0, 0, :on_nl, "\n")
- meth.add_tokens [token, newline, indent]
- meth.add_tokens @token_stream
-
- parse_method_params_and_body container, single, meth, added_container
-
- comment.normalize
- comment.extract_call_seq meth
-
- meth.comment = comment
-
- # after end modifiers
- read_documentation_modifiers meth, RDoc::METHOD_MODIFIERS
-
- @stats.add_method meth
- end
-
- ##
- # Parses the parameters and body of +meth+
-
- def parse_method_params_and_body container, single, meth, added_container
- token_listener meth do
- parse_method_parameters meth
-
- if meth.document_self or not @track_visibility then
- container.add_method meth
- elsif added_container then
- container.document_self = false
- end
-
- # Having now read the method parameters and documentation modifiers, we
- # now know whether we have to rename #initialize to ::new
-
- if meth.name == "initialize" && !meth.singleton then
- if meth.dont_rename_initialize then
- meth.visibility = :protected
- else
- meth.singleton = true
- meth.name = "new"
- meth.visibility = :public
- end
- end
-
- parse_statements container, single, meth
- end
- end
-
- ##
- # Parses a method that needs to be ignored.
-
- def parse_method_dummy container
- dummy = RDoc::Context.new
- dummy.parent = container
- dummy.store = container.store
- skip_method dummy
- end
-
- ##
- # Parses the name of a method in +container+.
- #
- # Returns the method name, the container it is in (for def Foo.name) and if
- # it is a singleton or regular method.
-
- def parse_method_name container # :nodoc:
- skip_tkspace
- name_t = get_tk
- back_tk = skip_tkspace_without_nl
- singleton = false
-
- dot = get_tk
- if dot[:kind] == :on_period || (dot[:kind] == :on_op && dot[:text] == '::') then
- singleton = true
-
- name, container = parse_method_name_singleton container, name_t
- else
- unget_tk dot
- back_tk.reverse_each do |token|
- unget_tk token
- end
-
- name = parse_method_name_regular container, name_t
- end
-
- return name, container, singleton
- end
-
- ##
- # For the given +container+ and initial name token +name_t+ the method name
- # is parsed from the token stream for a regular method.
-
- def parse_method_name_regular container, name_t # :nodoc:
- if :on_op == name_t[:kind] && (%w{* & [] []= <<}.include?(name_t[:text])) then
- name_t[:text]
- else
- unless [:on_kw, :on_const, :on_ident].include?(name_t[:kind]) then
- warn "expected method name token, . or ::, got #{name_t.inspect}"
- skip_method container
- return
- end
- name_t[:text]
- end
- end
-
- ##
- # For the given +container+ and initial name token +name_t+ the method name
- # and the new +container+ (if necessary) are parsed from the token stream
- # for a singleton method.
-
- def parse_method_name_singleton container, name_t # :nodoc:
- skip_tkspace
- name_t2 = get_tk
-
- if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then
- # NOTE: work around '[' being consumed early
- if :on_lbracket == name_t2[:kind]
- get_tk
- name = '[]'
- else
- name = name_t2[:text]
- end
- elsif :on_const == name_t[:kind] then
- name = name_t2[:text]
-
- container = get_method_container container, name_t
-
- return unless container
-
- name
- elsif :on_ident == name_t[:kind] || :on_ivar == name_t[:kind] || :on_gvar == name_t[:kind] then
- parse_method_dummy container
-
- name = nil
- elsif (:on_kw == name_t[:kind]) && ('true' == name_t[:text] || 'false' == name_t[:text] || 'nil' == name_t[:text]) then
- klass_name = "#{name_t[:text].capitalize}Class"
- container = @store.find_class_named klass_name
- container ||= @top_level.add_class RDoc::NormalClass, klass_name
-
- name = name_t2[:text]
- else
- warn "unexpected method name token #{name_t.inspect}"
- # break
- skip_method container
-
- name = nil
- end
-
- return name, container
- end
-
- ##
- # Extracts +yield+ parameters from +method+
-
- def parse_method_or_yield_parameters(method = nil,
- modifiers = RDoc::METHOD_MODIFIERS)
- skip_tkspace_without_nl
- tk = get_tk
- end_token = get_end_token tk
- return '' unless end_token
-
- nest = 0
- continue = false
-
- while tk != nil do
- case tk[:kind]
- when :on_semicolon then
- break if nest == 0
- when :on_lbracket then
- nest += 1
- when :on_rbracket then
- nest -= 1
- when :on_lbrace then
- nest += 1
- when :on_rbrace then
- nest -= 1
- if nest <= 0
- # we might have a.each { |i| yield i }
- unget_tk(tk) if nest < 0
- break
- end
- when :on_lparen then
- nest += 1
- when end_token[:kind] then
- if end_token[:kind] == :on_rparen
- nest -= 1
- break if nest <= 0
- else
- break
- end
- when :on_rparen then
- nest -= 1
- when :on_comment, :on_embdoc then
- @read.pop
- if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
- (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
- if method && method.block_params.nil? then
- unget_tk tk
- read_documentation_modifiers method, modifiers
- end
- break if !continue and nest <= 0
- end
- when :on_comma then
- continue = true
- when :on_ident then
- continue = false if continue
- end
- tk = get_tk
- end
-
- get_tkread_clean(/\s+/, ' ')
- end
-
- ##
- # Capture the method's parameters. Along the way, look for a comment
- # containing:
- #
- # # yields: ....
- #
- # and add this as the block_params for the method
-
- def parse_method_parameters method
- res = parse_method_or_yield_parameters method
-
- res = "(#{res})" unless res =~ /\A\(/
- method.params = res unless method.params
-
- return if method.block_params
-
- skip_tkspace_without_nl
- read_documentation_modifiers method, RDoc::METHOD_MODIFIERS
- end
-
- ##
- # Parses an RDoc::NormalModule in +container+ with +comment+
-
- def parse_module container, single, tk, comment
- container, name_t, = get_class_or_module container
-
- name = name_t[:text]
-
- mod = container.add_module RDoc::NormalModule, name
- mod.ignore unless container.document_children
- record_location mod
-
- read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
- mod.add_comment comment, @top_level
- parse_statements mod
-
- # after end modifiers
- read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
-
- @stats.add_module mod
- end
-
- ##
- # Parses an RDoc::Require in +context+ containing +comment+
-
- def parse_require(context, comment)
- skip_tkspace_comment
- tk = get_tk
-
- if :on_lparen == tk[:kind] then
- skip_tkspace_comment
- tk = get_tk
- end
-
- name = tk[:text][1..-2] if :on_tstring == tk[:kind]
-
- if name then
- @top_level.add_require RDoc::Require.new(name, comment)
- else
- unget_tk tk
- end
- end
-
- ##
- # Parses a rescue
-
- def parse_rescue
- skip_tkspace_without_nl
-
- while tk = get_tk
- case tk[:kind]
- when :on_nl, :on_semicolon, :on_comment then
- break
- when :on_comma then
- skip_tkspace_without_nl
-
- get_tk if :on_nl == peek_tk[:kind]
- end
-
- skip_tkspace_without_nl
- end
- end
-
- ##
- # Retrieve comment body without =begin/=end
-
- def retrieve_comment_body(tk)
- if :on_embdoc == tk[:kind]
- tk[:text].gsub(/\A=begin.*\n/, '').gsub(/=end\n?\z/, '')
- else
- tk[:text]
- end
- end
-
- ##
- # The core of the Ruby parser.
-
- def parse_statements(container, single = NORMAL, current_method = nil,
- comment = new_comment(''))
- raise 'no' unless RDoc::Comment === comment
- comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
-
- nest = 1
- save_visibility = container.visibility
-
- non_comment_seen = true
-
- while tk = get_tk do
- keep_comment = false
- try_parse_comment = false
-
- non_comment_seen = true unless (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])
-
- case tk[:kind]
- when :on_nl, :on_ignored_nl, :on_comment, :on_embdoc then
- if :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]
- skip_tkspace
- tk = get_tk
- else
- past_tokens = @read.size > 1 ? @read[0..-2] : []
- nl_position = 0
- past_tokens.reverse.each_with_index do |read_tk, i|
- if read_tk =~ /^\n$/ then
- nl_position = (past_tokens.size - 1) - i
- break
- elsif read_tk =~ /^#.*\n$/ then
- nl_position = ((past_tokens.size - 1) - i) + 1
- break
- end
- end
- comment_only_line = past_tokens[nl_position..-1].all?{ |c| c =~ /^\s+$/ }
- unless comment_only_line then
- tk = get_tk
- end
- end
-
- if tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
- if non_comment_seen then
- # Look for RDoc in a comment about to be thrown away
- non_comment_seen = parse_comment container, tk, comment unless
- comment.empty?
-
- comment = ''
- comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
- end
-
- line_no = nil
- while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
- comment_body = retrieve_comment_body(tk)
- line_no = tk[:line_no] if comment.empty?
- comment += comment_body
- comment << "\n" unless comment_body =~ /\n\z/
-
- if comment_body.size > 1 && comment_body =~ /\n\z/ then
- skip_tkspace_without_nl # leading spaces
- end
- tk = get_tk
- end
-
- comment = new_comment comment, line_no
-
- unless comment.empty? then
- look_for_directives_in container, comment
-
- if container.done_documenting then
- throw :eof if RDoc::TopLevel === container
- container.ongoing_visibility = save_visibility
- end
- end
-
- keep_comment = true
- else
- non_comment_seen = true
- end
-
- unget_tk tk
- keep_comment = true
- container.current_line_visibility = nil
-
- when :on_kw then
- case tk[:text]
- when 'class' then
- parse_class container, single, tk, comment
-
- when 'module' then
- parse_module container, single, tk, comment
-
- when 'def' then
- parse_method container, single, tk, comment
-
- when 'alias' then
- parse_alias container, single, tk, comment unless current_method
-
- when 'yield' then
- if current_method.nil? then
- warn "Warning: yield outside of method" if container.document_self
- else
- parse_yield container, single, tk, current_method
- end
-
- when 'until', 'while' then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
- nest += 1
- skip_optional_do_after_expression
- end
-
- # Until and While can have a 'do', which shouldn't increase the nesting.
- # We can't solve the general case, but we can handle most occurrences by
- # ignoring a do at the end of a line.
-
- # 'for' is trickier
- when 'for' then
- nest += 1
- skip_for_variable
- skip_optional_do_after_expression
-
- when 'case', 'do', 'if', 'unless', 'begin' then
- if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
- nest += 1
- end
-
- when 'super' then
- current_method.calls_super = true if current_method
-
- when 'rescue' then
- parse_rescue
-
- when 'end' then
- nest -= 1
- if nest == 0 then
- container.ongoing_visibility = save_visibility
-
- parse_comment container, tk, comment unless comment.empty?
-
- return
- end
- end
-
- when :on_const then
- unless parse_constant container, tk, comment, current_method then
- try_parse_comment = true
- end
-
- when :on_ident then
- if nest == 1 and current_method.nil? then
- keep_comment = parse_identifier container, single, tk, comment
- end
-
- case tk[:text]
- when "require" then
- parse_require container, comment
- when "include" then
- parse_extend_or_include RDoc::Include, container, comment
- when "extend" then
- parse_extend_or_include RDoc::Extend, container, comment
- when "included" then
- parse_included_with_activesupport_concern container, comment
- end
-
- else
- try_parse_comment = nest == 1
- end
-
- if try_parse_comment then
- non_comment_seen = parse_comment container, tk, comment unless
- comment.empty?
-
- keep_comment = false
- end
-
- unless keep_comment then
- comment = new_comment ''
- comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
- container.params = nil
- container.block_params = nil
- end
-
- consume_trailing_spaces
- end
-
- container.params = nil
- container.block_params = nil
- end
-
- ##
- # Parse up to +no+ symbol arguments
-
- def parse_symbol_arg(no = nil)
- skip_tkspace_comment
-
- tk = get_tk
- if tk[:kind] == :on_lparen
- parse_symbol_arg_paren no
- else
- parse_symbol_arg_space no, tk
- end
- end
-
- ##
- # Parses up to +no+ symbol arguments surrounded by () and places them in
- # +args+.
-
- def parse_symbol_arg_paren no # :nodoc:
- args = []
-
- loop do
- skip_tkspace_comment
- if tk1 = parse_symbol_in_arg
- args.push tk1
- break if no and args.size >= no
- end
-
- skip_tkspace_comment
- case (tk2 = get_tk)[:kind]
- when :on_rparen
- break
- when :on_comma
- else
- warn("unexpected token: '#{tk2.inspect}'") if $DEBUG_RDOC
- break
- end
- end
-
- args
- end
-
- ##
- # Parses up to +no+ symbol arguments separated by spaces and places them in
- # +args+.
-
- def parse_symbol_arg_space no, tk # :nodoc:
- args = []
-
- unget_tk tk
- if tk = parse_symbol_in_arg
- args.push tk
- return args if no and args.size >= no
- end
-
- loop do
- skip_tkspace_without_nl
-
- tk1 = get_tk
- if tk1.nil? || :on_comma != tk1[:kind] then
- unget_tk tk1
- break
- end
-
- skip_tkspace_comment
- if tk = parse_symbol_in_arg
- args.push tk
- break if no and args.size >= no
- end
- end
-
- args
- end
-
- ##
- # Returns symbol text from the next token
-
- def parse_symbol_in_arg
- tk = get_tk
- if :on_symbol == tk[:kind] then
- tk[:text].sub(/^:/, '')
- elsif :on_tstring == tk[:kind] then
- tk[:text][1..-2]
- elsif :on_dstring == tk[:kind] or :on_ident == tk[:kind] then
- nil # ignore
- else
- warn("Expected symbol or string, got #{tk.inspect}") if $DEBUG_RDOC
- nil
- end
- end
-
- ##
- # Parses statements in the top-level +container+
-
- def parse_top_level_statements container
- comment = collect_first_comment
-
- look_for_directives_in container, comment
-
- throw :eof if container.done_documenting
-
- @markup = comment.format
-
- # HACK move if to RDoc::Context#comment=
- container.comment = comment if container.document_self unless comment.empty?
-
- parse_statements container, NORMAL, nil, comment
- end
-
- ##
- # Determines the visibility in +container+ from +tk+
-
- def parse_visibility(container, single, tk)
- vis_type, vis, singleton = get_visibility_information tk, single
-
- skip_tkspace_comment false
-
- ptk = peek_tk
- # Ryan Davis suggested the extension to ignore modifiers, because he
- # often writes
- #
- # protected unless $TESTING
- #
- if [:on_nl, :on_semicolon].include?(ptk[:kind]) || (:on_kw == ptk[:kind] && (['if', 'unless'].include?(ptk[:text]))) then
- container.ongoing_visibility = vis
- elsif :on_kw == ptk[:kind] && 'def' == ptk[:text]
- container.current_line_visibility = vis
- else
- update_visibility container, vis_type, vis, singleton
- end
- end
-
- ##
- # Parses a Module#private_constant or Module#public_constant call from +tk+.
-
- def parse_constant_visibility(container, single, tk)
- args = parse_symbol_arg
- case tk[:text]
- when 'private_constant'
- vis = :private
- when 'public_constant'
- vis = :public
- else
- raise RDoc::Error, 'Unreachable'
- end
- container.set_constant_visibility_for args, vis
- end
-
- ##
- # Determines the block parameter for +context+
-
- def parse_yield(context, single, tk, method)
- return if method.block_params
-
- get_tkread
- method.block_params = parse_method_or_yield_parameters
- end
-
- ##
- # Directives are modifier comments that can appear after class, module, or
- # method names. For example:
- #
- # def fred # :yields: a, b
- #
- # or:
- #
- # class MyClass # :nodoc:
- #
- # We return the directive name and any parameters as a two element array if
- # the name is in +allowed+. A directive can be found anywhere up to the end
- # of the current line.
-
- def read_directive allowed
- tokens = []
-
- while tk = get_tk do
- tokens << tk
-
- if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
- return
- elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then
- return unless tk[:text] =~ /\s*:?([\w-]+):\s*(.*)/
-
- directive = $1.downcase
-
- return [directive, $2] if allowed.include? directive
-
- return
- end
- end
- ensure
- unless tokens.length == 1 and (:on_comment == tokens.first[:kind] or :on_embdoc == tokens.first[:kind]) then
- tokens.reverse_each do |token|
- unget_tk token
- end
- end
- end
-
- ##
- # Handles directives following the definition for +context+ (any
- # RDoc::CodeObject) if the directives are +allowed+ at this point.
- #
- # See also RDoc::Markup::PreProcess#handle_directive
-
- def read_documentation_modifiers context, allowed
- skip_tkspace_without_nl
- directive, value = read_directive allowed
-
- return unless directive
-
- @preprocess.handle_directive '', directive, value, context do |dir, param|
- if %w[notnew not_new not-new].include? dir then
- context.dont_rename_initialize = true
-
- true
- end
- end
- end
-
- ##
- # Records the location of this +container+ in the file for this parser and
- # adds it to the list of classes and modules in the file.
-
- def record_location container # :nodoc:
- case container
- when RDoc::ClassModule then
- @top_level.add_to_classes_or_modules container
- end
-
- container.record_location @top_level
- end
-
- ##
- # Scans this Ruby file for Ruby constructs
-
- def scan
- reset
-
- catch :eof do
- begin
- parse_top_level_statements @top_level
-
- rescue StandardError => e
- if @content.include?('<%') and @content.include?('%>') then
- # Maybe, this is ERB.
- $stderr.puts "\033[2KRDoc detects ERB file. Skips it for compatibility:"
- $stderr.puts @file_name
- return
- end
-
- if @scanner_point >= @scanner.size
- now_line_no = @scanner[@scanner.size - 1][:line_no]
- else
- now_line_no = peek_tk[:line_no]
- end
- first_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no }
- last_tk_index = @scanner.find_index { |tk| tk[:line_no] == now_line_no + 1 }
- last_tk_index = last_tk_index ? last_tk_index - 1 : @scanner.size - 1
- code = @scanner[first_tk_index..last_tk_index].map{ |t| t[:text] }.join
-
- $stderr.puts <<-EOF
-
-#{self.class} failure around line #{now_line_no} of
-#{@file_name}
-
- EOF
-
- unless code.empty? then
- $stderr.puts code
- $stderr.puts
- end
-
- raise e
- end
- end
-
- @top_level
- end
-
- ##
- # while, until, and for have an optional do
-
- def skip_optional_do_after_expression
- skip_tkspace_without_nl
- tk = get_tk
-
- b_nest = 0
- nest = 0
-
- loop do
- break unless tk
- case tk[:kind]
- when :on_semicolon, :on_nl, :on_ignored_nl then
- break if b_nest.zero?
- when :on_lparen then
- nest += 1
- when :on_rparen then
- nest -= 1
- when :on_kw then
- case tk[:text]
- when 'begin'
- b_nest += 1
- when 'end'
- b_nest -= 1
- when 'do'
- break if nest.zero?
- end
- when :on_comment, :on_embdoc then
- if b_nest.zero? and "\n" == tk[:text][-1] then
- break
- end
- end
- tk = get_tk
- end
-
- skip_tkspace_without_nl
-
- get_tk if peek_tk && :on_kw == peek_tk[:kind] && 'do' == peek_tk[:text]
- end
-
- ##
- # skip the var [in] part of a 'for' statement
-
- def skip_for_variable
- skip_tkspace_without_nl
- get_tk
- skip_tkspace_without_nl
- tk = get_tk
- unget_tk(tk) unless :on_kw == tk[:kind] and 'in' == tk[:text]
- end
-
- ##
- # Skips the next method in +container+
-
- def skip_method container
- meth = RDoc::AnyMethod.new "", "anon"
- parse_method_parameters meth
- parse_statements container, false, meth
- end
-
- ##
- # Skip spaces until a comment is found
-
- def skip_tkspace_comment(skip_nl = true)
- loop do
- skip_nl ? skip_tkspace : skip_tkspace_without_nl
- next_tk = peek_tk
- return if next_tk.nil? || (:on_comment != next_tk[:kind] and :on_embdoc != next_tk[:kind])
- get_tk
- end
- end
-
- ##
- # Updates visibility in +container+ from +vis_type+ and +vis+.
-
- def update_visibility container, vis_type, vis, singleton # :nodoc:
- new_methods = []
-
- case vis_type
- when 'module_function' then
- args = parse_symbol_arg
- container.set_visibility_for args, :private, false
-
- container.methods_matching args do |m|
- s_m = m.dup
- record_location s_m
- s_m.singleton = true
- new_methods << s_m
- end
- when 'public_class_method', 'private_class_method' then
- args = parse_symbol_arg
-
- container.methods_matching args, true do |m|
- if m.parent != container then
- m = m.dup
- record_location m
- new_methods << m
- end
-
- m.visibility = vis
- end
- else
- args = parse_symbol_arg
- container.set_visibility_for args, vis, singleton
- end
-
- new_methods.each do |method|
- case method
- when RDoc::AnyMethod then
- container.add_method method
- when RDoc::Attr then
- container.add_attribute method
- end
- method.visibility = vis
- end
- end
-
- ##
- # Prints +message+ to +$stderr+ unless we're being quiet
-
- def warn message
- @options.warn make_message message
- end
-
-end
diff --git a/lib/rdoc/parser/ruby_tools.rb b/lib/rdoc/parser/ruby_tools.rb
deleted file mode 100644
index 681d7166ce..0000000000
--- a/lib/rdoc/parser/ruby_tools.rb
+++ /dev/null
@@ -1,167 +0,0 @@
-# frozen_string_literal: true
-##
-# Collection of methods for writing parsers
-
-module RDoc::Parser::RubyTools
-
- ##
- # Adds a token listener +obj+, but you should probably use token_listener
-
- def add_token_listener(obj)
- @token_listeners ||= []
- @token_listeners << obj
- end
-
- ##
- # Fetches the next token from the scanner
-
- def get_tk
- tk = nil
-
- if @tokens.empty? then
- if @scanner_point >= @scanner.size
- return nil
- else
- tk = @scanner[@scanner_point]
- @scanner_point += 1
- @read.push tk[:text]
- end
- else
- @read.push @unget_read.shift
- tk = @tokens.shift
- end
-
- if tk == nil || :on___end__ == tk[:kind]
- tk = nil
- end
-
- return nil unless tk
-
- # inform any listeners of our shiny new token
- @token_listeners.each do |obj|
- obj.add_token(tk)
- end if @token_listeners
-
- tk
- end
-
- ##
- # Reads and returns all tokens up to one of +tokens+. Leaves the matched
- # token in the token list.
-
- def get_tk_until(*tokens)
- read = []
-
- loop do
- tk = get_tk
-
- case tk
- when *tokens then
- unget_tk tk
- break
- end
-
- read << tk
- end
-
- read
- end
-
- ##
- # Retrieves a String representation of the read tokens
-
- def get_tkread
- read = @read.join("")
- @read = []
- read
- end
-
- ##
- # Peek equivalent for get_tkread
-
- def peek_read
- @read.join('')
- end
-
- ##
- # Peek at the next token, but don't remove it from the stream
-
- def peek_tk
- unget_tk(tk = get_tk)
- tk
- end
-
- ##
- # Removes the token listener +obj+
-
- def remove_token_listener(obj)
- @token_listeners.delete(obj)
- end
-
- ##
- # Resets the tools
-
- def reset
- @read = []
- @tokens = []
- @unget_read = []
- @nest = 0
- @scanner_point = 0
- end
-
- ##
- # Skips whitespace tokens including newlines
-
- def skip_tkspace
- tokens = []
-
- while (tk = get_tk) and (:on_sp == tk[:kind] or :on_nl == tk[:kind] or :on_ignored_nl == tk[:kind]) do
- tokens.push(tk)
- end
-
- unget_tk(tk)
- tokens
- end
-
- ##
- # Skips whitespace tokens excluding newlines
-
- def skip_tkspace_without_nl
- tokens = []
-
- while (tk = get_tk) and :on_sp == tk[:kind] do
- tokens.push(tk)
- end
-
- unget_tk(tk)
- tokens
- end
-
- ##
- # Has +obj+ listen to tokens
-
- def token_listener(obj)
- add_token_listener obj
- yield
- ensure
- remove_token_listener obj
- end
-
- ##
- # Returns +tk+ to the scanner
-
- def unget_tk(tk)
- @tokens.unshift tk
- @unget_read.unshift @read.pop
-
- # Remove this token from any listeners
- @token_listeners.each do |obj|
- obj.pop_token
- end if @token_listeners
-
- nil
- end
-
-end
-
-
diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb
deleted file mode 100644
index b1dabad0f8..0000000000
--- a/lib/rdoc/parser/simple.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-##
-# Parse a non-source file. We basically take the whole thing as one big
-# comment.
-
-class RDoc::Parser::Simple < RDoc::Parser
-
- include RDoc::Parser::Text
-
- parse_files_matching(//)
-
- attr_reader :content # :nodoc:
-
- ##
- # Prepare to parse a plain file
-
- def initialize(top_level, file_name, content, options, stats)
- super
-
- preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
-
- @content = preprocess.handle @content, @top_level
- end
-
- ##
- # Extract the file contents and attach them to the TopLevel as a comment
-
- def scan
- comment = remove_coding_comment @content
- comment = remove_private_comment comment
-
- comment = RDoc::Comment.new comment, @top_level
-
- @top_level.comment = comment
- @top_level
- end
-
- ##
- # Removes the encoding magic comment from +text+
-
- def remove_coding_comment text
- text.sub(/\A# .*coding[=:].*$/, '')
- end
-
- ##
- # Removes private comments.
- #
- # Unlike RDoc::Comment#remove_private this implementation only looks for two
- # dashes at the beginning of the line. Three or more dashes are considered
- # to be a rule and ignored.
-
- def remove_private_comment comment
- # Workaround for gsub encoding for Ruby 1.9.2 and earlier
- empty = ''
- empty = RDoc::Encoding.change_encoding empty, comment.encoding
-
- comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty)
- comment.sub(%r%^--\n.*%m, empty)
- end
-
-end
diff --git a/lib/rdoc/parser/text.rb b/lib/rdoc/parser/text.rb
deleted file mode 100644
index 01de0cc595..0000000000
--- a/lib/rdoc/parser/text.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-##
-# Indicates this parser is text and doesn't contain code constructs.
-#
-# Include this module in a RDoc::Parser subclass to make it show up as a file,
-# not as part of a class or module.
-#--
-# This is not named File to avoid overriding ::File
-
-module RDoc::Parser::Text
-end
-
diff --git a/lib/rdoc/rd.rb b/lib/rdoc/rd.rb
deleted file mode 100644
index 8c2366a3ca..0000000000
--- a/lib/rdoc/rd.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-# frozen_string_literal: true
-##
-# RDoc::RD implements the RD format from the rdtool gem.
-#
-# To choose RD as your only default format see
-# RDoc::Options@Saved+Options for instructions on setting up a
-# <code>.doc_options</code> file to store your project default.
-#
-# == LICENSE
-#
-# The grammar that produces RDoc::RD::BlockParser and RDoc::RD::InlineParser
-# is included in RDoc under the Ruby License.
-#
-# You can find the original source for rdtool at
-# https://github.com/uwabami/rdtool/
-#
-# You can use, re-distribute or change these files under Ruby's License or GPL.
-#
-# 1. You may make and give away verbatim copies of the source form of the
-# software without restriction, provided that you duplicate all of the
-# original copyright notices and associated disclaimers.
-#
-# 2. You may modify your copy of the software in any way, provided that
-# you do at least ONE of the following:
-#
-# a. place your modifications in the Public Domain or otherwise
-# make them Freely Available, such as by posting said
-# modifications to Usenet or an equivalent medium, or by allowing
-# the author to include your modifications in the software.
-#
-# b. use the modified software only within your corporation or
-# organization.
-#
-# c. give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d. make other distribution arrangements with the author.
-#
-# 3. You may distribute the software in object code or binary form,
-# provided that you do at least ONE of the following:
-#
-# a. distribute the binaries and library files of the software,
-# together with instructions (in the manual page or equivalent)
-# on where to get the original distribution.
-#
-# b. accompany the distribution with the machine-readable source of
-# the software.
-#
-# c. give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d. make other distribution arrangements with the author.
-#
-# 4. You may modify and include the part of the software into any other
-# software (possibly commercial). But some files in the distribution
-# are not written by the author, so that they are not under these terms.
-#
-# For the list of those files and their copying conditions, see the
-# file LEGAL.
-#
-# 5. The scripts and library files supplied as input to or produced as
-# output from the software do not automatically fall under the
-# copyright of the software, but belong to whomever generated them,
-# and may be sold commercially, and may be aggregated with this
-# software.
-#
-# 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE.
-
-class RDoc::RD
-
- ##
- # Parses +rd+ source and returns an RDoc::Markup::Document. If the
- # <tt>=begin</tt> or <tt>=end</tt> lines are missing they will be added.
-
- def self.parse rd
- rd = rd.lines.to_a
-
- if rd.find { |i| /\S/ === i } and !rd.find{|i| /^=begin\b/ === i } then
- rd.unshift("=begin\n").push("=end\n")
- end
-
- parser = RDoc::RD::BlockParser.new
- document = parser.parse rd
-
- # isn't this always true?
- document.parts.shift if RDoc::Markup::BlankLine === document.parts.first
- document.parts.pop if RDoc::Markup::BlankLine === document.parts.last
-
- document
- end
-
- autoload :BlockParser, "#{__dir__}/rd/block_parser"
- autoload :InlineParser, "#{__dir__}/rd/inline_parser"
- autoload :Inline, "#{__dir__}/rd/inline"
-
-end
diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb
deleted file mode 100644
index 52ea1467d8..0000000000
--- a/lib/rdoc/rd/block_parser.rb
+++ /dev/null
@@ -1,1062 +0,0 @@
-# frozen_string_literal: true
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.6.2
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-class RDoc::RD
-
-##
-# RD format parser for headings, paragraphs, lists, verbatim sections that
-# exist as blocks.
-
-class BlockParser < Racc::Parser
-
-
-# :stopdoc:
-
-MARK_TO_LEVEL = {
- '=' => 1,
- '==' => 2,
- '===' => 3,
- '====' => 4,
- '+' => 5,
- '++' => 6,
-}
-
-# :startdoc:
-
-##
-# Footnotes for this document
-
-attr_reader :footnotes
-
-##
-# Labels for items in this document
-
-attr_reader :labels
-
-##
-# Path to find included files in
-
-attr_accessor :include_path
-
-##
-# Creates a new RDoc::RD::BlockParser. Use #parse to parse an rd-format
-# document.
-
-def initialize
- @inline_parser = RDoc::RD::InlineParser.new self
- @include_path = []
-
- # for testing
- @footnotes = []
- @labels = {}
-end
-
-##
-# Parses +src+ and returns an RDoc::Markup::Document.
-
-def parse src
- @src = src
- @src.push false
-
- @footnotes = []
- @labels = {}
-
- # @i: index(line no.) of src
- @i = 0
-
- # stack for current indentation
- @indent_stack = []
-
- # how indented.
- @current_indent = @indent_stack.join("")
-
- # RDoc::RD::BlockParser for tmp src
- @subparser = nil
-
- # which part is in now
- @in_part = nil
- @part_content = []
-
- @in_verbatim = false
-
- @yydebug = true
-
- document = do_parse
-
- unless @footnotes.empty? then
- blankline = document.parts.pop
-
- document.parts << RDoc::Markup::Rule.new(1)
- document.parts.concat @footnotes
-
- document.parts.push blankline
- end
-
- document
-end
-
-##
-# Returns the next token from the document
-
-def next_token # :nodoc:
- # preprocessing
- # if it is not in RD part
- # => method
- while @in_part != "rd"
- line = @src[@i]
- @i += 1 # next line
-
- case line
- # src end
- when false
- return [false, false]
- # RD part begin
- when /^=begin\s*(?:\bRD\b.*)?\s*$/
- if @in_part # if in non-RD part
- @part_content.push(line)
- else
- @in_part = "rd"
- return [:WHITELINE, "=begin\n"] # <= for textblockand
- end
- # non-RD part begin
- when /^=begin\s+(\w+)/
- part = $1
-=begin # not imported to RDoc
- if @in_part # if in non-RD part
- @part_content.push(line)
- else
- @in_part = part if @tree.filter[part] # if filter exists
-# p "BEGIN_PART: #{@in_part}" # DEBUG
- end
-=end
- @in_part = part
- # non-RD part end
- when /^=end(?:$|[\s\0\C-d\C-z])/
- if @in_part # if in non-RD part
-=begin # not imported to RDoc
-# p "END_PART: #{@in_part}" # DEBUG
- # make Part-in object
- part = RDoc::RD::Part.new(@part_content.join(""), @tree, "r")
- @part_content.clear
- # call filter, part_out is output(Part object)
- part_out = @tree.filter[@in_part].call(part)
-
- if @tree.filter[@in_part].mode == :rd # if output is RD formatted
- subtree = parse_subtree(part_out.to_a)
- else # if output is target formatted
- basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
- tmpfile.print(part_out)
- File.basename(tmpfile.path)
- end
- subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
- end
- @in_part = nil
- return [:SUBTREE, subtree]
-=end
- end
- else
-=begin # not imported to RDoc
- if @in_part # if in non-RD part
- @part_content.push(line)
- end
-=end
- end
- end
-
- @current_indent = @indent_stack.join("")
- line = @src[@i]
- case line
- when false
- if_current_indent_equal("") do
- [false, false]
- end
- when /^=end/
- if_current_indent_equal("") do
- @in_part = nil
- [:WHITELINE, "=end"] # MUST CHANGE??
- end
- when /^\s*$/
- @i += 1 # next line
- return [:WHITELINE, ':WHITELINE']
- when /^\#/ # comment line
- @i += 1 # next line
- self.next_token()
- when /^(={1,4})(?!=)\s*(?=\S)/, /^(\+{1,2})(?!\+)\s*(?=\S)/
- rest = $' # '
- rest.strip!
- mark = $1
- if_current_indent_equal("") do
- return [:HEADLINE, [MARK_TO_LEVEL[mark], rest]]
- end
- when /^<<<\s*(\S+)/
- file = $1
- if_current_indent_equal("") do
- suffix = file[-3 .. -1]
- if suffix == ".rd" or suffix == ".rb"
- subtree = parse_subtree(get_included(file))
- [:SUBTREE, subtree]
- else
- [:INCLUDE, file]
- end
- end
- when /^(\s*)\*(\s*)/
- rest = $' # '
- newIndent = $2
- if_current_indent_equal($1) do
- if @in_verbatim
- [:STRINGLINE, line]
- else
- @indent_stack.push("\s" + newIndent)
- [:ITEMLISTLINE, rest]
- end
- end
- when /^(\s*)(\(\d+\))(\s*)/
- rest = $' # '
- mark = $2
- newIndent = $3
- if_current_indent_equal($1) do
- if @in_verbatim
- [:STRINGLINE, line]
- else
- @indent_stack.push("\s" * mark.size + newIndent)
- [:ENUMLISTLINE, rest]
- end
- end
- when /^(\s*):(\s*)/
- rest = $' # '
- newIndent = $2
- if_current_indent_equal($1) do
- if @in_verbatim
- [:STRINGLINE, line]
- else
- @indent_stack.push("\s#{$2}")
- [:DESCLISTLINE, rest]
- end
- end
- when /^(\s*)---(?!-|\s*$)/
- indent = $1
- rest = $'
- /\s*/ === rest
- term = $'
- new_indent = $&
- if_current_indent_equal(indent) do
- if @in_verbatim
- [:STRINGLINE, line]
- else
- @indent_stack.push("\s\s\s" + new_indent)
- [:METHODLISTLINE, term]
- end
- end
- when /^(\s*)/
- if_current_indent_equal($1) do
- [:STRINGLINE, line]
- end
- else
- raise "[BUG] parsing error may occurred."
- end
-end
-
-##
-# Yields to the given block if +indent+ matches the current indent, otherwise
-# an indentation token is processed.
-
-def if_current_indent_equal(indent)
- indent = indent.sub(/\t/, "\s" * 8)
- if @current_indent == indent
- @i += 1 # next line
- yield
- elsif indent.index(@current_indent) == 0
- @indent_stack.push(indent[@current_indent.size .. -1])
- [:INDENT, ":INDENT"]
- else
- @indent_stack.pop
- [:DEDENT, ":DEDENT"]
- end
-end
-private :if_current_indent_equal
-
-##
-# Cuts off excess whitespace in +src+
-
-def cut_off(src)
- ret = []
- whiteline_buf = []
-
- line = src.shift
- /^\s*/ =~ line
-
- indent = Regexp.quote($&)
- ret.push($')
-
- while line = src.shift
- if /^(\s*)$/ =~ line
- whiteline_buf.push(line)
- elsif /^#{indent}/ =~ line
- unless whiteline_buf.empty?
- ret.concat(whiteline_buf)
- whiteline_buf.clear
- end
- ret.push($')
- else
- raise "[BUG]: probably Parser Error while cutting off.\n"
- end
- end
- ret
-end
-private :cut_off
-
-def set_term_to_element(parent, term)
-# parent.set_term_under_document_struct(term, @tree.document_struct)
- parent.set_term_without_document_struct(term)
-end
-private :set_term_to_element
-
-##
-# Raises a ParseError when invalid formatting is found
-
-def on_error(et, ev, _values)
- prv, cur, nxt = format_line_num(@i, @i+1, @i+2)
-
- raise ParseError, <<Msg
-
-RD syntax error: line #{@i+1}:
- #{prv} |#{@src[@i-1].chomp}
- #{cur}=>|#{@src[@i].chomp}
- #{nxt} |#{@src[@i+1].chomp}
-
-Msg
-end
-
-##
-# Current line number
-
-def line_index
- @i
-end
-
-##
-# Parses subtree +src+
-
-def parse_subtree src
- @subparser ||= RDoc::RD::BlockParser.new
-
- @subparser.parse src
-end
-private :parse_subtree
-
-##
-# Retrieves the content for +file+ from the include_path
-
-def get_included(file)
- included = []
-
- @include_path.each do |dir|
- file_name = File.join dir, file
-
- if File.exist? file_name then
- included = File.readlines file_name
- break
- end
- end
-
- included
-end
-private :get_included
-
-##
-# Formats line numbers +line_numbers+ prettily
-
-def format_line_num(*line_numbers)
- width = line_numbers.collect{|i| i.to_s.length }.max
- line_numbers.collect{|i| sprintf("%#{width}d", i) }
-end
-private :format_line_num
-
-##
-# Retrieves the content of +values+ as a single String
-
-def content values
- values.map { |value| value.content }.join
-end
-
-##
-# Creates a paragraph for +value+
-
-def paragraph value
- content = cut_off(value).join(' ').rstrip
- contents = @inline_parser.parse content
-
- RDoc::Markup::Paragraph.new(*contents)
-end
-
-##
-# Adds footnote +content+ to the document
-
-def add_footnote content
- index = @footnotes.length / 2 + 1
-
- footmark_link = "{^#{index}}[rdoc-label:footmark-#{index}:foottext-#{index}]"
-
- @footnotes << RDoc::Markup::Paragraph.new(footmark_link, ' ', *content)
- @footnotes << RDoc::Markup::BlankLine.new
-
- index
-end
-
-##
-# Adds label +label+ to the document
-
-def add_label label
- @labels[label] = true
-
- label
-end
-
-# :stopdoc:
-
-##### State transition tables begin ###
-
-racc_action_table = [
- 34, 35, 30, 33, 40, 34, 35, 30, 33, 40,
- 65, 34, 35, 30, 33, 14, 73, 36, 38, 34,
- 15, 88, 34, 35, 30, 33, 14, 9, 10, 11,
- 12, 15, 34, 35, 30, 33, 14, 9, 10, 11,
- 12, 15, 34, 35, 30, 33, 35, 47, 30, 54,
- 33, 15, 34, 35, 30, 33, 54, 47, 14, 14,
- 59, 15, 34, 35, 30, 33, 14, 73, 67, 76,
- 77, 15, 34, 35, 30, 33, 14, 73, 54, 81,
- 38, 15, 34, 35, 30, 33, 14, 73, 38, 40,
- 83, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, nil, nil,
- nil, 15, 34, 35, 30, 33, 14, 73, 61, 63,
- nil, 15, 14, 62, 60, 61, 63, 79, 61, 63,
- 62, 87, nil, 62, 34, 35, 30, 33 ]
-
-racc_action_check = [
- 41, 41, 41, 41, 41, 15, 15, 15, 15, 15,
- 41, 86, 86, 86, 86, 86, 86, 1, 13, 22,
- 86, 86, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 24, 24, 24, 24, 25, 24, 28, 30,
- 31, 24, 27, 27, 27, 27, 33, 27, 34, 35,
- 36, 27, 45, 45, 45, 45, 45, 45, 44, 49,
- 51, 45, 46, 46, 46, 46, 46, 46, 54, 56,
- 57, 46, 47, 47, 47, 47, 47, 47, 58, 62,
- 66, 47, 68, 68, 68, 68, 68, 68, nil, nil,
- nil, 68, 74, 74, 74, 74, 74, 74, nil, nil,
- nil, 74, 75, 75, 75, 75, 75, 75, nil, nil,
- nil, 75, 78, 78, 78, 78, 78, 78, nil, nil,
- nil, 78, 79, 79, 79, 79, 79, 79, nil, nil,
- nil, 79, 85, 85, 85, 85, 85, 85, 39, 39,
- nil, 85, 52, 39, 39, 82, 82, 52, 64, 64,
- 82, 82, nil, 64, 20, 20, 20, 20 ]
-
-racc_action_pointer = [
- 19, 17, 29, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 11, nil, 2, nil, nil, nil, nil,
- 161, nil, 16, nil, 39, 42, nil, 49, 43, nil,
- 41, 44, nil, 48, 51, 52, 60, nil, nil, 141,
- nil, -3, nil, nil, 55, 59, 69, 79, nil, 56,
- nil, 57, 145, nil, 70, nil, 66, 73, 81, nil,
- nil, nil, 82, nil, 151, nil, 77, nil, 89, nil,
- nil, nil, nil, nil, 99, 109, nil, nil, 119, 129,
- nil, nil, 148, nil, nil, 139, 8, nil, nil ]
-
-racc_action_default = [
- -2, -73, -1, -4, -5, -6, -7, -8, -9, -10,
- -11, -12, -13, -14, -16, -73, -23, -24, -25, -26,
- -27, -31, -32, -34, -72, -36, -38, -72, -40, -42,
- -59, -44, -46, -59, -63, -65, -73, -3, -15, -73,
- -22, -73, -30, -33, -73, -69, -70, -71, -37, -73,
- -41, -73, -51, -58, -61, -45, -73, -62, -64, 89,
- -17, -19, -73, -21, -18, -28, -73, -35, -66, -53,
- -54, -55, -56, -57, -67, -68, -39, -43, -49, -73,
- -60, -47, -73, -29, -52, -48, -73, -20, -50 ]
-
-racc_goto_table = [
- 4, 39, 4, 68, 74, 75, 5, 6, 5, 6,
- 44, 42, 51, 49, 3, 56, 37, 57, 58, 1,
- 2, 66, 84, 41, 43, 48, 50, 64, 84, 84,
- 45, 46, 42, 45, 46, 55, 85, 86, 80, 84,
- 84, nil, nil, nil, nil, nil, nil, nil, 82, nil,
- nil, nil, 78 ]
-
-racc_goto_check = [
- 4, 10, 4, 31, 31, 31, 5, 6, 5, 6,
- 21, 12, 27, 21, 3, 27, 3, 9, 9, 1,
- 2, 11, 32, 17, 19, 23, 26, 10, 32, 32,
- 5, 6, 12, 5, 6, 29, 31, 31, 33, 32,
- 32, nil, nil, nil, nil, nil, nil, nil, 10, nil,
- nil, nil, 4 ]
-
-racc_goto_pointer = [
- nil, 19, 20, 14, 0, 6, 7, nil, nil, -17,
- -14, -20, -9, nil, nil, nil, nil, 8, nil, 2,
- nil, -14, nil, 0, nil, nil, -2, -18, nil, 4,
- nil, -42, -46, -16 ]
-
-racc_goto_default = [
- nil, nil, nil, nil, 70, 71, 72, 7, 8, 13,
- nil, nil, 21, 16, 17, 18, 19, 20, 22, 23,
- 24, nil, 25, 26, 27, 28, 29, nil, 31, 32,
- 52, nil, 69, 53 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 15, :_reduce_1,
- 0, 15, :_reduce_2,
- 2, 16, :_reduce_3,
- 1, 16, :_reduce_4,
- 1, 17, :_reduce_5,
- 1, 17, :_reduce_6,
- 1, 17, :_reduce_none,
- 1, 17, :_reduce_8,
- 1, 17, :_reduce_9,
- 1, 17, :_reduce_10,
- 1, 17, :_reduce_11,
- 1, 21, :_reduce_12,
- 1, 22, :_reduce_13,
- 1, 18, :_reduce_14,
- 2, 23, :_reduce_15,
- 1, 23, :_reduce_16,
- 3, 19, :_reduce_17,
- 1, 25, :_reduce_18,
- 2, 24, :_reduce_19,
- 4, 24, :_reduce_20,
- 2, 24, :_reduce_21,
- 1, 24, :_reduce_22,
- 1, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 1, 26, :_reduce_none,
- 1, 20, :_reduce_27,
- 3, 20, :_reduce_28,
- 4, 20, :_reduce_29,
- 2, 31, :_reduce_30,
- 1, 31, :_reduce_31,
- 1, 27, :_reduce_32,
- 2, 32, :_reduce_33,
- 1, 32, :_reduce_34,
- 3, 33, :_reduce_35,
- 1, 28, :_reduce_36,
- 2, 36, :_reduce_37,
- 1, 36, :_reduce_38,
- 3, 37, :_reduce_39,
- 1, 29, :_reduce_40,
- 2, 39, :_reduce_41,
- 1, 39, :_reduce_42,
- 3, 40, :_reduce_43,
- 1, 30, :_reduce_44,
- 2, 42, :_reduce_45,
- 1, 42, :_reduce_46,
- 3, 43, :_reduce_47,
- 3, 41, :_reduce_48,
- 2, 41, :_reduce_49,
- 4, 41, :_reduce_50,
- 1, 41, :_reduce_51,
- 2, 45, :_reduce_52,
- 1, 45, :_reduce_none,
- 1, 46, :_reduce_54,
- 1, 46, :_reduce_55,
- 1, 46, :_reduce_none,
- 1, 46, :_reduce_57,
- 1, 44, :_reduce_none,
- 0, 44, :_reduce_none,
- 2, 47, :_reduce_none,
- 1, 47, :_reduce_none,
- 2, 34, :_reduce_62,
- 1, 34, :_reduce_63,
- 2, 38, :_reduce_64,
- 1, 38, :_reduce_65,
- 2, 35, :_reduce_66,
- 2, 35, :_reduce_67,
- 2, 35, :_reduce_68,
- 1, 35, :_reduce_69,
- 1, 35, :_reduce_none,
- 1, 35, :_reduce_71,
- 0, 35, :_reduce_72 ]
-
-racc_reduce_n = 73
-
-racc_shift_n = 89
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :DUMMY => 2,
- :ITEMLISTLINE => 3,
- :ENUMLISTLINE => 4,
- :DESCLISTLINE => 5,
- :METHODLISTLINE => 6,
- :STRINGLINE => 7,
- :WHITELINE => 8,
- :SUBTREE => 9,
- :HEADLINE => 10,
- :INCLUDE => 11,
- :INDENT => 12,
- :DEDENT => 13 }
-
-racc_nt_base = 14
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-Ractor.make_shareable(Racc_arg) if defined?(Ractor)
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "DUMMY",
- "ITEMLISTLINE",
- "ENUMLISTLINE",
- "DESCLISTLINE",
- "METHODLISTLINE",
- "STRINGLINE",
- "WHITELINE",
- "SUBTREE",
- "HEADLINE",
- "INCLUDE",
- "INDENT",
- "DEDENT",
- "$start",
- "document",
- "blocks",
- "block",
- "textblock",
- "verbatim",
- "lists",
- "headline",
- "include",
- "textblockcontent",
- "verbatimcontent",
- "verbatim_after_lists",
- "list",
- "itemlist",
- "enumlist",
- "desclist",
- "methodlist",
- "lists2",
- "itemlistitems",
- "itemlistitem",
- "first_textblock_in_itemlist",
- "other_blocks_in_list",
- "enumlistitems",
- "enumlistitem",
- "first_textblock_in_enumlist",
- "desclistitems",
- "desclistitem",
- "description_part",
- "methodlistitems",
- "methodlistitem",
- "whitelines",
- "blocks_in_list",
- "block_in_list",
- "whitelines2" ]
-Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-def _reduce_1(val, _values, result)
- result = RDoc::Markup::Document.new(*val[0])
- result
-end
-
-def _reduce_2(val, _values, result)
- raise ParseError, "file empty"
- result
-end
-
-def _reduce_3(val, _values, result)
- result = val[0].concat val[1]
- result
-end
-
-def _reduce_4(val, _values, result)
- result = val[0]
- result
-end
-
-def _reduce_5(val, _values, result)
- result = val
- result
-end
-
-def _reduce_6(val, _values, result)
- result = val
- result
-end
-
-# reduce 7 omitted
-
-def _reduce_8(val, _values, result)
- result = val
- result
-end
-
-def _reduce_9(val, _values, result)
- result = val
- result
-end
-
-def _reduce_10(val, _values, result)
- result = [RDoc::Markup::BlankLine.new]
- result
-end
-
-def _reduce_11(val, _values, result)
- result = val[0].parts
- result
-end
-
-def _reduce_12(val, _values, result)
- # val[0] is like [level, title]
- title = @inline_parser.parse(val[0][1])
- result = RDoc::Markup::Heading.new(val[0][0], title)
-
- result
-end
-
-def _reduce_13(val, _values, result)
- result = RDoc::Markup::Include.new val[0], @include_path
-
- result
-end
-
-def _reduce_14(val, _values, result)
- # val[0] is Array of String
- result = paragraph val[0]
-
- result
-end
-
-def _reduce_15(val, _values, result)
- result << val[1].rstrip
- result
-end
-
-def _reduce_16(val, _values, result)
- result = [val[0].rstrip]
- result
-end
-
-def _reduce_17(val, _values, result)
- # val[1] is Array of String
- content = cut_off val[1]
- result = RDoc::Markup::Verbatim.new(*content)
-
- # imform to lexer.
- @in_verbatim = false
-
- result
-end
-
-def _reduce_18(val, _values, result)
- # val[0] is Array of String
- content = cut_off val[0]
- result = RDoc::Markup::Verbatim.new(*content)
-
- # imform to lexer.
- @in_verbatim = false
-
- result
-end
-
-def _reduce_19(val, _values, result)
- result << val[1]
-
- result
-end
-
-def _reduce_20(val, _values, result)
- result.concat val[2]
-
- result
-end
-
-def _reduce_21(val, _values, result)
- result << "\n"
-
- result
-end
-
-def _reduce_22(val, _values, result)
- result = val
- # inform to lexer.
- @in_verbatim = true
-
- result
-end
-
-# reduce 23 omitted
-
-# reduce 24 omitted
-
-# reduce 25 omitted
-
-# reduce 26 omitted
-
-def _reduce_27(val, _values, result)
- result = val[0]
-
- result
-end
-
-def _reduce_28(val, _values, result)
- result = val[1]
-
- result
-end
-
-def _reduce_29(val, _values, result)
- result = val[1].push(val[2])
-
- result
-end
-
-def _reduce_30(val, _values, result)
- result = val[0] << val[1]
- result
-end
-
-def _reduce_31(val, _values, result)
- result = [val[0]]
- result
-end
-
-def _reduce_32(val, _values, result)
- result = RDoc::Markup::List.new :BULLET, *val[0]
-
- result
-end
-
-def _reduce_33(val, _values, result)
- result.push(val[1])
- result
-end
-
-def _reduce_34(val, _values, result)
- result = val
- result
-end
-
-def _reduce_35(val, _values, result)
- result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
-
- result
-end
-
-def _reduce_36(val, _values, result)
- result = RDoc::Markup::List.new :NUMBER, *val[0]
-
- result
-end
-
-def _reduce_37(val, _values, result)
- result.push(val[1])
- result
-end
-
-def _reduce_38(val, _values, result)
- result = val
- result
-end
-
-def _reduce_39(val, _values, result)
- result = RDoc::Markup::ListItem.new nil, val[0], *val[1]
-
- result
-end
-
-def _reduce_40(val, _values, result)
- result = RDoc::Markup::List.new :NOTE, *val[0]
-
- result
-end
-
-def _reduce_41(val, _values, result)
- result.push(val[1])
- result
-end
-
-def _reduce_42(val, _values, result)
- result = val
- result
-end
-
-def _reduce_43(val, _values, result)
- term = @inline_parser.parse val[0].strip
-
- result = RDoc::Markup::ListItem.new term, *val[1]
-
- result
-end
-
-def _reduce_44(val, _values, result)
- result = RDoc::Markup::List.new :LABEL, *val[0]
-
- result
-end
-
-def _reduce_45(val, _values, result)
- result.push(val[1])
- result
-end
-
-def _reduce_46(val, _values, result)
- result = val
- result
-end
-
-def _reduce_47(val, _values, result)
- result = RDoc::Markup::ListItem.new "<tt>#{val[0].strip}</tt>", *val[1]
-
- result
-end
-
-def _reduce_48(val, _values, result)
- result = [val[1]].concat(val[2])
-
- result
-end
-
-def _reduce_49(val, _values, result)
- result = [val[1]]
-
- result
-end
-
-def _reduce_50(val, _values, result)
- result = val[2]
-
- result
-end
-
-def _reduce_51(val, _values, result)
- result = []
-
- result
-end
-
-def _reduce_52(val, _values, result)
- result.concat val[1]
- result
-end
-
-# reduce 53 omitted
-
-def _reduce_54(val, _values, result)
- result = val
- result
-end
-
-def _reduce_55(val, _values, result)
- result = val
- result
-end
-
-# reduce 56 omitted
-
-def _reduce_57(val, _values, result)
- result = []
- result
-end
-
-# reduce 58 omitted
-
-# reduce 59 omitted
-
-# reduce 60 omitted
-
-# reduce 61 omitted
-
-def _reduce_62(val, _values, result)
- result = paragraph [val[0]].concat(val[1])
-
- result
-end
-
-def _reduce_63(val, _values, result)
- result = paragraph [val[0]]
-
- result
-end
-
-def _reduce_64(val, _values, result)
- result = paragraph [val[0]].concat(val[1])
-
- result
-end
-
-def _reduce_65(val, _values, result)
- result = paragraph [val[0]]
-
- result
-end
-
-def _reduce_66(val, _values, result)
- result = [val[0]].concat(val[1])
-
- result
-end
-
-def _reduce_67(val, _values, result)
- result.concat val[1]
- result
-end
-
-def _reduce_68(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_69(val, _values, result)
- result = val
- result
-end
-
-# reduce 70 omitted
-
-def _reduce_71(val, _values, result)
- result = []
- result
-end
-
-def _reduce_72(val, _values, result)
- result = []
- result
-end
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
-end # class BlockParser
-
-end
diff --git a/lib/rdoc/rd/inline.rb b/lib/rdoc/rd/inline.rb
deleted file mode 100644
index e5cb545728..0000000000
--- a/lib/rdoc/rd/inline.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# frozen_string_literal: true
-##
-# Inline keeps track of markup and labels to create proper links.
-
-class RDoc::RD::Inline
-
- ##
- # The text of the reference
-
- attr_reader :reference
-
- ##
- # The markup of this reference in RDoc format
-
- attr_reader :rdoc
-
- ##
- # Creates a new Inline for +rdoc+ and +reference+.
- #
- # +rdoc+ may be another Inline or a String. If +reference+ is not given it
- # will use the text from +rdoc+.
-
- def self.new rdoc, reference = rdoc
- if self === rdoc and reference.equal? rdoc then
- rdoc
- else
- super
- end
- end
-
- ##
- # Initializes the Inline with +rdoc+ and +inline+
-
- def initialize rdoc, reference # :not-new:
- @reference = reference.equal?(rdoc) ? reference.dup : reference
-
- # unpack
- @reference = @reference.reference if self.class === @reference
- @rdoc = rdoc
- end
-
- def == other # :nodoc:
- self.class === other and
- @reference == other.reference and @rdoc == other.rdoc
- end
-
- ##
- # Appends +more+ to this inline. +more+ may be a String or another Inline.
-
- def append more
- case more
- when String then
- @reference += more
- @rdoc += more
- when RDoc::RD::Inline then
- @reference += more.reference
- @rdoc += more.rdoc
- else
- raise "unknown thingy #{more}"
- end
-
- self
- end
-
- def inspect # :nodoc:
- "(inline: #{self})"
- end
-
- alias to_s rdoc # :nodoc:
-
-end
-
diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb
deleted file mode 100644
index 0f0becefef..0000000000
--- a/lib/rdoc/rd/inline_parser.rb
+++ /dev/null
@@ -1,1210 +0,0 @@
-# frozen_string_literal: true
-#
-# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.6.2
-# from Racc grammar file "".
-#
-
-require 'racc/parser.rb'
-
-require 'strscan'
-
-class RDoc::RD
-
-##
-# RD format parser for inline markup such as emphasis, links, footnotes, etc.
-
-class InlineParser < Racc::Parser
-
-
-# :stopdoc:
-
-EM_OPEN = '((*'
-EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
-EM_CLOSE = '*))'
-EM_CLOSE_RE = /\A#{Regexp.quote(EM_CLOSE)}/
-CODE_OPEN = '(({'
-CODE_OPEN_RE = /\A#{Regexp.quote(CODE_OPEN)}/
-CODE_CLOSE = '}))'
-CODE_CLOSE_RE = /\A#{Regexp.quote(CODE_CLOSE)}/
-VAR_OPEN = '((|'
-VAR_OPEN_RE = /\A#{Regexp.quote(VAR_OPEN)}/
-VAR_CLOSE = '|))'
-VAR_CLOSE_RE = /\A#{Regexp.quote(VAR_CLOSE)}/
-KBD_OPEN = '((%'
-KBD_OPEN_RE = /\A#{Regexp.quote(KBD_OPEN)}/
-KBD_CLOSE = '%))'
-KBD_CLOSE_RE = /\A#{Regexp.quote(KBD_CLOSE)}/
-INDEX_OPEN = '((:'
-INDEX_OPEN_RE = /\A#{Regexp.quote(INDEX_OPEN)}/
-INDEX_CLOSE = ':))'
-INDEX_CLOSE_RE = /\A#{Regexp.quote(INDEX_CLOSE)}/
-REF_OPEN = '((<'
-REF_OPEN_RE = /\A#{Regexp.quote(REF_OPEN)}/
-REF_CLOSE = '>))'
-REF_CLOSE_RE = /\A#{Regexp.quote(REF_CLOSE)}/
-FOOTNOTE_OPEN = '((-'
-FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
-FOOTNOTE_CLOSE = '-))'
-FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
-VERB_OPEN = "(('"
-VERB_OPEN_RE = /\A#{Regexp.quote(VERB_OPEN)}/
-VERB_CLOSE = "'))"
-VERB_CLOSE_RE = /\A#{Regexp.quote(VERB_CLOSE)}/
-
-BAR = "|"
-BAR_RE = /\A#{Regexp.quote(BAR)}/
-QUOTE = '"'
-QUOTE_RE = /\A#{Regexp.quote(QUOTE)}/
-SLASH = "/"
-SLASH_RE = /\A#{Regexp.quote(SLASH)}/
-BACK_SLASH = "\\"
-BACK_SLASH_RE = /\A#{Regexp.quote(BACK_SLASH)}/
-URL = "URL:"
-URL_RE = /\A#{Regexp.quote(URL)}/
-
-other_re_mode = Regexp::EXTENDED
-other_re_mode |= Regexp::MULTILINE
-
-OTHER_RE = Regexp.new(
- "\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|
- #{Regexp.quote(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|
- #{Regexp.quote(VAR_OPEN)}|#{Regexp.quote(VAR_CLOSE)}|
- #{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|
- #{Regexp.quote(INDEX_OPEN)}|#{Regexp.quote(INDEX_CLOSE)}|
- #{Regexp.quote(REF_OPEN)}|#{Regexp.quote(REF_CLOSE)}|
- #{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|
- #{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}|
- #{Regexp.quote(BAR)}|
- #{Regexp.quote(QUOTE)}|
- #{Regexp.quote(SLASH)}|
- #{Regexp.quote(BACK_SLASH)}|
- #{Regexp.quote(URL)})", other_re_mode)
-
-# :startdoc:
-
-##
-# Creates a new parser for inline markup in the rd format. The +block_parser+
-# is used to for footnotes and labels in the inline text.
-
-def initialize block_parser
- @block_parser = block_parser
-end
-
-##
-# Parses the +inline+ text from RD format into RDoc format.
-
-def parse inline
- @inline = inline
- @src = StringScanner.new inline
- @pre = "".dup
- @yydebug = true
- do_parse.to_s
-end
-
-##
-# Returns the next token from the inline text
-
-def next_token
- return [false, false] if @src.eos?
-# p @src.rest if @yydebug
- if ret = @src.scan(EM_OPEN_RE)
- @pre << ret
- [:EM_OPEN, ret]
- elsif ret = @src.scan(EM_CLOSE_RE)
- @pre << ret
- [:EM_CLOSE, ret]
- elsif ret = @src.scan(CODE_OPEN_RE)
- @pre << ret
- [:CODE_OPEN, ret]
- elsif ret = @src.scan(CODE_CLOSE_RE)
- @pre << ret
- [:CODE_CLOSE, ret]
- elsif ret = @src.scan(VAR_OPEN_RE)
- @pre << ret
- [:VAR_OPEN, ret]
- elsif ret = @src.scan(VAR_CLOSE_RE)
- @pre << ret
- [:VAR_CLOSE, ret]
- elsif ret = @src.scan(KBD_OPEN_RE)
- @pre << ret
- [:KBD_OPEN, ret]
- elsif ret = @src.scan(KBD_CLOSE_RE)
- @pre << ret
- [:KBD_CLOSE, ret]
- elsif ret = @src.scan(INDEX_OPEN_RE)
- @pre << ret
- [:INDEX_OPEN, ret]
- elsif ret = @src.scan(INDEX_CLOSE_RE)
- @pre << ret
- [:INDEX_CLOSE, ret]
- elsif ret = @src.scan(REF_OPEN_RE)
- @pre << ret
- [:REF_OPEN, ret]
- elsif ret = @src.scan(REF_CLOSE_RE)
- @pre << ret
- [:REF_CLOSE, ret]
- elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
- @pre << ret
- [:FOOTNOTE_OPEN, ret]
- elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
- @pre << ret
- [:FOOTNOTE_CLOSE, ret]
- elsif ret = @src.scan(VERB_OPEN_RE)
- @pre << ret
- [:VERB_OPEN, ret]
- elsif ret = @src.scan(VERB_CLOSE_RE)
- @pre << ret
- [:VERB_CLOSE, ret]
- elsif ret = @src.scan(BAR_RE)
- @pre << ret
- [:BAR, ret]
- elsif ret = @src.scan(QUOTE_RE)
- @pre << ret
- [:QUOTE, ret]
- elsif ret = @src.scan(SLASH_RE)
- @pre << ret
- [:SLASH, ret]
- elsif ret = @src.scan(BACK_SLASH_RE)
- @pre << ret
- [:BACK_SLASH, ret]
- elsif ret = @src.scan(URL_RE)
- @pre << ret
- [:URL, ret]
- elsif ret = @src.scan(OTHER_RE)
- @pre << ret
- [:OTHER, ret]
- else
- ret = @src.rest
- @pre << ret
- @src.terminate
- [:OTHER, ret]
- end
-end
-
-##
-# Raises a ParseError when invalid formatting is found
-
-def on_error(et, ev, values)
- lines_of_rest = @src.rest.lines.to_a.length
- prev_words = prev_words_on_error(ev)
- at = 4 + prev_words.length
-
- message = <<-MSG
-RD syntax error: line #{@block_parser.line_index - lines_of_rest}:
-...#{prev_words} #{(ev||'')} #{next_words_on_error()} ...
- MSG
-
- message << " " * at + "^" * (ev ? ev.length : 0) + "\n"
- raise ParseError, message
-end
-
-##
-# Returns words before the error
-
-def prev_words_on_error(ev)
- pre = @pre
- if ev and /#{Regexp.quote(ev)}$/ =~ pre
- pre = $`
- end
- last_line(pre)
-end
-
-##
-# Returns the last line of +src+
-
-def last_line(src)
- if n = src.rindex("\n")
- src[(n+1) .. -1]
- else
- src
- end
-end
-private :last_line
-
-##
-# Returns words following an error
-
-def next_words_on_error
- if n = @src.rest.index("\n")
- @src.rest[0 .. (n-1)]
- else
- @src.rest
- end
-end
-
-##
-# Creates a new RDoc::RD::Inline for the +rdoc+ markup and the raw +reference+
-
-def inline rdoc, reference = rdoc
- RDoc::RD::Inline.new rdoc, reference
-end
-
-# :stopdoc:
-##### State transition tables begin ###
-
-racc_action_table = [
- 104, 103, 102, 100, 101, 99, 115, 116, 117, 29,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 84, 118, 119, 63, 64, 65, 61, 81, 62, 76,
- 78, 79, 85, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 77, 80, 149, 63, 64, 65, 153,
- 81, 62, 76, 78, 79, 86, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 77, 80, 152, 104,
- 103, 102, 100, 101, 99, 115, 116, 117, 87, 105,
- 106, 107, 108, 109, 110, 111, 112, 113, 114, 88,
- 118, 119, 104, 103, 102, 100, 101, 99, 115, 116,
- 117, 89, 105, 106, 107, 108, 109, 110, 111, 112,
- 113, 114, 96, 118, 119, 104, 103, 102, 100, 101,
- 99, 115, 116, 117, 124, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 137, 118, 119, 22, 23,
- 24, 25, 26, 21, 18, 19, 176, 177, 13, 148,
- 14, 154, 15, 137, 16, 161, 17, 164, 173, 20,
- 22, 23, 24, 25, 26, 21, 18, 19, 175, 177,
- 13, nil, 14, nil, 15, nil, 16, nil, 17, nil,
- nil, 20, 22, 23, 24, 25, 26, 21, 18, 19,
- nil, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, nil, nil, 20, 22, 23, 24, 25, 26, 21,
- 18, 19, nil, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, nil, nil, 20, 22, 23, 24, 25,
- 26, 21, 18, 19, nil, nil, 13, nil, 14, nil,
- 15, nil, 16, nil, 17, nil, nil, 20, 22, 23,
- 24, 25, 26, 21, 18, 19, nil, nil, 13, nil,
- 14, nil, 15, nil, 16, nil, 17, nil, nil, 20,
- 22, 23, 24, 25, 26, 21, 18, 19, nil, nil,
- 13, nil, 14, nil, 15, nil, 16, nil, 17, 42,
- nil, 20, 54, 38, 53, 55, 56, 57, nil, 13,
- nil, 14, nil, 15, nil, 16, nil, 17, nil, nil,
- 20, 22, 23, 24, 25, 26, 21, 18, 19, nil,
- nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
- nil, nil, 20, 63, 64, 65, 61, 81, 62, 76,
- 78, 79, nil, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 77, 80, 122, nil, nil, 54, nil,
- 53, 55, 56, 57, nil, 13, nil, 14, nil, 15,
- nil, 16, nil, 17, 145, nil, 20, 54, 133, 53,
- 55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, 145, nil, 20, 54, 133, 53, 55,
- 56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
- nil, 17, 145, nil, 20, 54, 133, 53, 55, 56,
- 57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, 145, nil, 20, 54, 133, 53, 55, 56, 57,
- nil, 13, nil, 14, nil, 15, nil, 16, nil, 17,
- nil, nil, 20, 135, 136, 54, 133, 53, 55, 56,
- 57, nil, 13, nil, 14, nil, 15, nil, 16, nil,
- 17, nil, nil, 20, 135, 136, 54, 133, 53, 55,
- 56, 57, nil, 13, nil, 14, nil, 15, nil, 16,
- nil, 17, nil, nil, 20, 135, 136, 54, 133, 53,
- 55, 56, 57, nil, 13, nil, 14, nil, 15, nil,
- 16, nil, 17, 95, nil, 20, 54, 91, 53, 55,
- 56, 57, 145, nil, nil, 54, 133, 53, 55, 56,
- 57, 158, nil, nil, 54, nil, 53, 55, 56, 57,
- 165, 135, 136, 54, 133, 53, 55, 56, 57, 145,
- nil, nil, 54, 133, 53, 55, 56, 57, 172, 135,
- 136, 54, 133, 53, 55, 56, 57, 174, 135, 136,
- 54, 133, 53, 55, 56, 57, 178, 135, 136, 54,
- 133, 53, 55, 56, 57, 135, 136, 54, 133, 53,
- 55, 56, 57, 135, 136, 54, 133, 53, 55, 56,
- 57, 135, 136, 54, 133, 53, 55, 56, 57, 22,
- 23, 24, 25, 26, 21 ]
-
-racc_action_check = [
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 1,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 29, 38, 38, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 31, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 32, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 33, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 34,
- 91, 91, 97, 97, 97, 97, 97, 97, 97, 97,
- 97, 35, 97, 97, 97, 97, 97, 97, 97, 97,
- 97, 97, 37, 97, 97, 155, 155, 155, 155, 155,
- 155, 155, 155, 155, 41, 155, 155, 155, 155, 155,
- 155, 155, 155, 155, 155, 43, 155, 155, 0, 0,
- 0, 0, 0, 0, 0, 0, 165, 165, 0, 58,
- 0, 90, 0, 94, 0, 100, 0, 125, 162, 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 164, 172,
- 2, nil, 2, nil, 2, nil, 2, nil, 2, nil,
- nil, 2, 13, 13, 13, 13, 13, 13, 13, 13,
- nil, nil, 13, nil, 13, nil, 13, nil, 13, nil,
- 13, nil, nil, 13, 14, 14, 14, 14, 14, 14,
- 14, 14, nil, nil, 14, nil, 14, nil, 14, nil,
- 14, nil, 14, nil, nil, 14, 15, 15, 15, 15,
- 15, 15, 15, 15, nil, nil, 15, nil, 15, nil,
- 15, nil, 15, nil, 15, nil, nil, 15, 16, 16,
- 16, 16, 16, 16, 16, 16, nil, nil, 16, nil,
- 16, nil, 16, nil, 16, nil, 16, nil, nil, 16,
- 17, 17, 17, 17, 17, 17, 17, 17, nil, nil,
- 17, nil, 17, nil, 17, nil, 17, nil, 17, 18,
- nil, 17, 18, 18, 18, 18, 18, 18, nil, 18,
- nil, 18, nil, 18, nil, 18, nil, 18, nil, nil,
- 18, 19, 19, 19, 19, 19, 19, 19, 19, nil,
- nil, 19, nil, 19, nil, 19, nil, 19, nil, 19,
- nil, nil, 19, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, nil, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 39, nil, nil, 39, nil,
- 39, 39, 39, 39, nil, 39, nil, 39, nil, 39,
- nil, 39, nil, 39, 44, nil, 39, 44, 44, 44,
- 44, 44, 44, nil, 44, nil, 44, nil, 44, nil,
- 44, nil, 44, 45, nil, 44, 45, 45, 45, 45,
- 45, 45, nil, 45, nil, 45, nil, 45, nil, 45,
- nil, 45, 138, nil, 45, 138, 138, 138, 138, 138,
- 138, nil, 138, nil, 138, nil, 138, nil, 138, nil,
- 138, 146, nil, 138, 146, 146, 146, 146, 146, 146,
- nil, 146, nil, 146, nil, 146, nil, 146, nil, 146,
- nil, nil, 146, 42, 42, 42, 42, 42, 42, 42,
- 42, nil, 42, nil, 42, nil, 42, nil, 42, nil,
- 42, nil, nil, 42, 122, 122, 122, 122, 122, 122,
- 122, 122, nil, 122, nil, 122, nil, 122, nil, 122,
- nil, 122, nil, nil, 122, 127, 127, 127, 127, 127,
- 127, 127, 127, nil, 127, nil, 127, nil, 127, nil,
- 127, nil, 127, 36, nil, 127, 36, 36, 36, 36,
- 36, 36, 52, nil, nil, 52, 52, 52, 52, 52,
- 52, 92, nil, nil, 92, nil, 92, 92, 92, 92,
- 126, 126, 126, 126, 126, 126, 126, 126, 126, 142,
- nil, nil, 142, 142, 142, 142, 142, 142, 159, 159,
- 159, 159, 159, 159, 159, 159, 159, 163, 163, 163,
- 163, 163, 163, 163, 163, 163, 171, 171, 171, 171,
- 171, 171, 171, 171, 171, 95, 95, 95, 95, 95,
- 95, 95, 95, 158, 158, 158, 158, 158, 158, 158,
- 158, 168, 168, 168, 168, 168, 168, 168, 168, 27,
- 27, 27, 27, 27, 27 ]
-
-racc_action_pointer = [
- 135, 9, 157, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 179, 201, 223, 245, 267, 286, 308,
- 330, nil, nil, nil, nil, nil, nil, 606, nil, 20,
- nil, 18, 39, 60, 69, 79, 510, 89, -3, 352,
- nil, 120, 449, 130, 371, 390, nil, nil, nil, nil,
- nil, nil, 519, nil, nil, nil, nil, nil, 138, 20,
- nil, 43, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- 128, 66, 528, nil, 148, 581, nil, 89, nil, nil,
- 149, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, 470, nil, nil, 154, 537, 491, nil, nil,
- nil, nil, nil, nil, nil, nil, nil, nil, 409, nil,
- nil, nil, 546, nil, nil, nil, 428, nil, nil, nil,
- nil, nil, nil, nil, nil, 112, nil, nil, 589, 555,
- nil, nil, 155, 564, 164, 142, nil, nil, 597, nil,
- nil, 573, 164, nil, nil, nil, nil, nil, nil ]
-
-racc_action_default = [
- -138, -138, -1, -3, -4, -5, -6, -7, -8, -9,
- -10, -11, -12, -138, -138, -138, -138, -138, -138, -138,
- -138, -103, -104, -105, -106, -107, -108, -111, -110, -138,
- -2, -138, -138, -138, -138, -138, -138, -138, -138, -27,
- -26, -35, -138, -58, -41, -40, -47, -48, -49, -50,
- -51, -52, -63, -66, -67, -68, -69, -70, -138, -138,
- -112, -138, -116, -117, -118, -119, -120, -121, -122, -123,
- -124, -125, -126, -127, -128, -129, -130, -131, -132, -133,
- -134, -135, -137, -109, 179, -13, -14, -15, -16, -17,
- -138, -138, -23, -22, -33, -138, -19, -24, -79, -80,
- -138, -82, -83, -84, -85, -86, -87, -88, -89, -90,
- -91, -92, -93, -94, -95, -96, -97, -98, -99, -100,
- -25, -35, -138, -58, -28, -138, -59, -42, -46, -55,
- -56, -65, -71, -72, -75, -76, -77, -31, -38, -44,
- -53, -54, -57, -61, -73, -74, -39, -62, -101, -102,
- -136, -113, -114, -115, -18, -20, -21, -33, -138, -138,
- -78, -81, -138, -59, -36, -37, -64, -45, -59, -43,
- -60, -138, -34, -36, -37, -29, -30, -32, -34 ]
-
-racc_goto_table = [
- 126, 44, 125, 43, 144, 144, 160, 93, 97, 52,
- 166, 82, 144, 40, 41, 39, 138, 146, 169, 30,
- 36, 94, 44, 1, 123, 129, 169, 52, 90, 37,
- 52, 167, 147, 92, 120, 121, 31, 32, 33, 34,
- 35, 170, 58, 166, 59, 83, 170, 166, 151, nil,
- 150, nil, 166, 159, 4, 166, 4, nil, nil, nil,
- nil, 155, nil, 156, 160, nil, nil, 4, 4, 4,
- 4, 4, nil, 4, 5, nil, 5, 157, nil, nil,
- 163, nil, 162, 52, nil, 168, nil, 5, 5, 5,
- 5, 5, nil, 5, nil, nil, nil, nil, 144, nil,
- nil, nil, 144, nil, nil, 129, 144, 144, nil, 6,
- 129, 6, nil, nil, nil, nil, 171, 7, nil, 7,
- nil, nil, 6, 6, 6, 6, 6, 8, 6, 8,
- 7, 7, 7, 7, 7, 11, 7, 11, nil, nil,
- 8, 8, 8, 8, 8, nil, 8, nil, 11, 11,
- 11, 11, 11, nil, 11 ]
-
-racc_goto_check = [
- 22, 24, 21, 23, 36, 36, 37, 18, 16, 34,
- 35, 41, 36, 19, 20, 17, 25, 25, 28, 3,
- 13, 23, 24, 1, 23, 24, 28, 34, 14, 15,
- 34, 29, 32, 17, 19, 20, 1, 1, 1, 1,
- 1, 33, 1, 35, 38, 39, 33, 35, 42, nil,
- 41, nil, 35, 22, 4, 35, 4, nil, nil, nil,
- nil, 16, nil, 18, 37, nil, nil, 4, 4, 4,
- 4, 4, nil, 4, 5, nil, 5, 23, nil, nil,
- 22, nil, 21, 34, nil, 22, nil, 5, 5, 5,
- 5, 5, nil, 5, nil, nil, nil, nil, 36, nil,
- nil, nil, 36, nil, nil, 24, 36, 36, nil, 6,
- 24, 6, nil, nil, nil, nil, 22, 7, nil, 7,
- nil, nil, 6, 6, 6, 6, 6, 8, 6, 8,
- 7, 7, 7, 7, 7, 11, 7, 11, nil, nil,
- 8, 8, 8, 8, 8, nil, 8, nil, 11, 11,
- 11, 11, 11, nil, 11 ]
-
-racc_goto_pointer = [
- nil, 23, nil, 17, 54, 74, 109, 117, 127, nil,
- nil, 135, nil, 2, -8, 11, -30, -3, -29, -5,
- -4, -40, -42, -15, -17, -28, nil, nil, -120, -96,
- nil, nil, -20, -101, -9, -116, -40, -91, 24, 18,
- nil, -9, -13 ]
-
-racc_goto_default = [
- nil, nil, 2, 3, 46, 47, 48, 49, 50, 9,
- 10, 51, 12, nil, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, 140, nil, 45, 127, 139, 128,
- 141, 130, 142, 143, 132, 131, 134, 98, nil, 28,
- 27, nil, 60 ]
-
-racc_reduce_table = [
- 0, 0, :racc_error,
- 1, 27, :_reduce_none,
- 2, 28, :_reduce_2,
- 1, 28, :_reduce_3,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 1, 29, :_reduce_none,
- 3, 30, :_reduce_13,
- 3, 31, :_reduce_14,
- 3, 32, :_reduce_15,
- 3, 33, :_reduce_16,
- 3, 34, :_reduce_17,
- 4, 35, :_reduce_18,
- 3, 35, :_reduce_19,
- 2, 40, :_reduce_20,
- 2, 40, :_reduce_21,
- 1, 40, :_reduce_22,
- 1, 40, :_reduce_23,
- 2, 41, :_reduce_24,
- 2, 41, :_reduce_25,
- 1, 41, :_reduce_26,
- 1, 41, :_reduce_27,
- 2, 39, :_reduce_none,
- 4, 39, :_reduce_29,
- 4, 39, :_reduce_30,
- 2, 43, :_reduce_31,
- 4, 43, :_reduce_32,
- 1, 44, :_reduce_33,
- 3, 44, :_reduce_34,
- 1, 45, :_reduce_none,
- 3, 45, :_reduce_36,
- 3, 45, :_reduce_37,
- 2, 46, :_reduce_38,
- 2, 46, :_reduce_39,
- 1, 46, :_reduce_40,
- 1, 46, :_reduce_41,
- 1, 47, :_reduce_none,
- 2, 51, :_reduce_43,
- 1, 51, :_reduce_44,
- 2, 53, :_reduce_45,
- 1, 53, :_reduce_46,
- 1, 50, :_reduce_none,
- 1, 50, :_reduce_none,
- 1, 50, :_reduce_none,
- 1, 50, :_reduce_none,
- 1, 50, :_reduce_none,
- 1, 50, :_reduce_none,
- 1, 54, :_reduce_none,
- 1, 54, :_reduce_none,
- 1, 55, :_reduce_none,
- 1, 55, :_reduce_none,
- 1, 56, :_reduce_57,
- 1, 52, :_reduce_58,
- 1, 57, :_reduce_59,
- 2, 58, :_reduce_60,
- 1, 58, :_reduce_none,
- 2, 49, :_reduce_62,
- 1, 49, :_reduce_none,
- 2, 48, :_reduce_64,
- 1, 48, :_reduce_none,
- 1, 60, :_reduce_none,
- 1, 60, :_reduce_none,
- 1, 60, :_reduce_none,
- 1, 60, :_reduce_none,
- 1, 60, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 62, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 59, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 1, 61, :_reduce_none,
- 2, 42, :_reduce_78,
- 1, 42, :_reduce_none,
- 1, 63, :_reduce_none,
- 2, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 1, 63, :_reduce_none,
- 3, 36, :_reduce_101,
- 3, 37, :_reduce_102,
- 1, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 1, 65, :_reduce_none,
- 2, 66, :_reduce_109,
- 1, 66, :_reduce_none,
- 1, 38, :_reduce_111,
- 1, 67, :_reduce_none,
- 2, 67, :_reduce_113,
- 2, 67, :_reduce_114,
- 2, 67, :_reduce_115,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 1, 68, :_reduce_none,
- 2, 64, :_reduce_136,
- 1, 64, :_reduce_none ]
-
-racc_reduce_n = 138
-
-racc_shift_n = 179
-
-racc_token_table = {
- false => 0,
- :error => 1,
- :EX_LOW => 2,
- :QUOTE => 3,
- :BAR => 4,
- :SLASH => 5,
- :BACK_SLASH => 6,
- :URL => 7,
- :OTHER => 8,
- :REF_OPEN => 9,
- :FOOTNOTE_OPEN => 10,
- :FOOTNOTE_CLOSE => 11,
- :EX_HIGH => 12,
- :EM_OPEN => 13,
- :EM_CLOSE => 14,
- :CODE_OPEN => 15,
- :CODE_CLOSE => 16,
- :VAR_OPEN => 17,
- :VAR_CLOSE => 18,
- :KBD_OPEN => 19,
- :KBD_CLOSE => 20,
- :INDEX_OPEN => 21,
- :INDEX_CLOSE => 22,
- :REF_CLOSE => 23,
- :VERB_OPEN => 24,
- :VERB_CLOSE => 25 }
-
-racc_nt_base = 26
-
-racc_use_result_var = true
-
-Racc_arg = [
- racc_action_table,
- racc_action_check,
- racc_action_default,
- racc_action_pointer,
- racc_goto_table,
- racc_goto_check,
- racc_goto_default,
- racc_goto_pointer,
- racc_nt_base,
- racc_reduce_table,
- racc_token_table,
- racc_shift_n,
- racc_reduce_n,
- racc_use_result_var ]
-Ractor.make_shareable(Racc_arg) if defined?(Ractor)
-
-Racc_token_to_s_table = [
- "$end",
- "error",
- "EX_LOW",
- "QUOTE",
- "BAR",
- "SLASH",
- "BACK_SLASH",
- "URL",
- "OTHER",
- "REF_OPEN",
- "FOOTNOTE_OPEN",
- "FOOTNOTE_CLOSE",
- "EX_HIGH",
- "EM_OPEN",
- "EM_CLOSE",
- "CODE_OPEN",
- "CODE_CLOSE",
- "VAR_OPEN",
- "VAR_CLOSE",
- "KBD_OPEN",
- "KBD_CLOSE",
- "INDEX_OPEN",
- "INDEX_CLOSE",
- "REF_CLOSE",
- "VERB_OPEN",
- "VERB_CLOSE",
- "$start",
- "content",
- "elements",
- "element",
- "emphasis",
- "code",
- "var",
- "keyboard",
- "index",
- "reference",
- "footnote",
- "verb",
- "normal_str_ele",
- "substitute",
- "ref_label",
- "ref_label2",
- "ref_url_strings",
- "filename",
- "element_label",
- "element_label2",
- "ref_subst_content",
- "ref_subst_content_q",
- "ref_subst_strings_q",
- "ref_subst_strings_first",
- "ref_subst_ele2",
- "ref_subst_eles",
- "ref_subst_str_ele_first",
- "ref_subst_eles_q",
- "ref_subst_ele",
- "ref_subst_ele_q",
- "ref_subst_str_ele",
- "ref_subst_str_ele_q",
- "ref_subst_strings",
- "ref_subst_string3",
- "ref_subst_string",
- "ref_subst_string_q",
- "ref_subst_string2",
- "ref_url_string",
- "verb_strings",
- "normal_string",
- "normal_strings",
- "verb_string",
- "verb_normal_string" ]
-Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
-
-Racc_debug_parser = false
-
-##### State transition tables end #####
-
-# reduce 0 omitted
-
-# reduce 1 omitted
-
-def _reduce_2(val, _values, result)
- result.append val[1]
- result
-end
-
-def _reduce_3(val, _values, result)
- result = val[0]
- result
-end
-
-# reduce 4 omitted
-
-# reduce 5 omitted
-
-# reduce 6 omitted
-
-# reduce 7 omitted
-
-# reduce 8 omitted
-
-# reduce 9 omitted
-
-# reduce 10 omitted
-
-# reduce 11 omitted
-
-# reduce 12 omitted
-
-def _reduce_13(val, _values, result)
- content = val[1]
- result = inline "<em>#{content}</em>", content
-
- result
-end
-
-def _reduce_14(val, _values, result)
- content = val[1]
- result = inline "<code>#{content}</code>", content
-
- result
-end
-
-def _reduce_15(val, _values, result)
- content = val[1]
- result = inline "+#{content}+", content
-
- result
-end
-
-def _reduce_16(val, _values, result)
- content = val[1]
- result = inline "<tt>#{content}</tt>", content
-
- result
-end
-
-def _reduce_17(val, _values, result)
- label = val[1]
- @block_parser.add_label label.reference
- result = "<span id=\"label-#{label}\">#{label}</span>"
-
- result
-end
-
-def _reduce_18(val, _values, result)
- result = "{#{val[1]}}[#{val[2].join}]"
-
- result
-end
-
-def _reduce_19(val, _values, result)
- scheme, inline = val[1]
-
- result = "{#{inline}}[#{scheme}#{inline.reference}]"
-
- result
-end
-
-def _reduce_20(val, _values, result)
- result = [nil, inline(val[1])]
-
- result
-end
-
-def _reduce_21(val, _values, result)
- result = [
- 'rdoc-label:',
- inline("#{val[0].reference}/#{val[1].reference}")
- ]
-
- result
-end
-
-def _reduce_22(val, _values, result)
- result = ['rdoc-label:', val[0].reference]
-
- result
-end
-
-def _reduce_23(val, _values, result)
- result = ['rdoc-label:', "#{val[0].reference}/"]
-
- result
-end
-
-def _reduce_24(val, _values, result)
- result = [nil, inline(val[1])]
-
- result
-end
-
-def _reduce_25(val, _values, result)
- result = [
- 'rdoc-label:',
- inline("#{val[0].reference}/#{val[1].reference}")
- ]
-
- result
-end
-
-def _reduce_26(val, _values, result)
- result = ['rdoc-label:', val[0]]
-
- result
-end
-
-def _reduce_27(val, _values, result)
- ref = val[0].reference
- result = ['rdoc-label:', inline(ref, "#{ref}/")]
-
- result
-end
-
-# reduce 28 omitted
-
-def _reduce_29(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_30(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_31(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-def _reduce_32(val, _values, result)
- result = inline "\"#{val[1]}\""
-
- result
-end
-
-def _reduce_33(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-def _reduce_34(val, _values, result)
- result = inline "\"#{val[1]}\""
-
- result
-end
-
-# reduce 35 omitted
-
-def _reduce_36(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_37(val, _values, result)
- result = inline val[1]
- result
-end
-
-def _reduce_38(val, _values, result)
- result = val[0].append val[1]
-
- result
-end
-
-def _reduce_39(val, _values, result)
- result = val[0].append val[1]
-
- result
-end
-
-def _reduce_40(val, _values, result)
- result = val[0]
-
- result
-end
-
-def _reduce_41(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-# reduce 42 omitted
-
-def _reduce_43(val, _values, result)
- result = val[0].append val[1]
-
- result
-end
-
-def _reduce_44(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-def _reduce_45(val, _values, result)
- result = val[0].append val[1]
-
- result
-end
-
-def _reduce_46(val, _values, result)
- result = val[0]
-
- result
-end
-
-# reduce 47 omitted
-
-# reduce 48 omitted
-
-# reduce 49 omitted
-
-# reduce 50 omitted
-
-# reduce 51 omitted
-
-# reduce 52 omitted
-
-# reduce 53 omitted
-
-# reduce 54 omitted
-
-# reduce 55 omitted
-
-# reduce 56 omitted
-
-def _reduce_57(val, _values, result)
- result = val[0]
-
- result
-end
-
-def _reduce_58(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-def _reduce_59(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-def _reduce_60(val, _values, result)
- result << val[1]
- result
-end
-
-# reduce 61 omitted
-
-def _reduce_62(val, _values, result)
- result << val[1]
-
- result
-end
-
-# reduce 63 omitted
-
-def _reduce_64(val, _values, result)
- result << val[1]
-
- result
-end
-
-# reduce 65 omitted
-
-# reduce 66 omitted
-
-# reduce 67 omitted
-
-# reduce 68 omitted
-
-# reduce 69 omitted
-
-# reduce 70 omitted
-
-# reduce 71 omitted
-
-# reduce 72 omitted
-
-# reduce 73 omitted
-
-# reduce 74 omitted
-
-# reduce 75 omitted
-
-# reduce 76 omitted
-
-# reduce 77 omitted
-
-def _reduce_78(val, _values, result)
- result << val[1]
- result
-end
-
-# reduce 79 omitted
-
-# reduce 80 omitted
-
-# reduce 81 omitted
-
-# reduce 82 omitted
-
-# reduce 83 omitted
-
-# reduce 84 omitted
-
-# reduce 85 omitted
-
-# reduce 86 omitted
-
-# reduce 87 omitted
-
-# reduce 88 omitted
-
-# reduce 89 omitted
-
-# reduce 90 omitted
-
-# reduce 91 omitted
-
-# reduce 92 omitted
-
-# reduce 93 omitted
-
-# reduce 94 omitted
-
-# reduce 95 omitted
-
-# reduce 96 omitted
-
-# reduce 97 omitted
-
-# reduce 98 omitted
-
-# reduce 99 omitted
-
-# reduce 100 omitted
-
-def _reduce_101(val, _values, result)
- index = @block_parser.add_footnote val[1].rdoc
- result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]"
-
- result
-end
-
-def _reduce_102(val, _values, result)
- result = inline "<tt>#{val[1]}</tt>", val[1]
-
- result
-end
-
-# reduce 103 omitted
-
-# reduce 104 omitted
-
-# reduce 105 omitted
-
-# reduce 106 omitted
-
-# reduce 107 omitted
-
-# reduce 108 omitted
-
-def _reduce_109(val, _values, result)
- result << val[1]
- result
-end
-
-# reduce 110 omitted
-
-def _reduce_111(val, _values, result)
- result = inline val[0]
-
- result
-end
-
-# reduce 112 omitted
-
-def _reduce_113(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_114(val, _values, result)
- result = val[1]
- result
-end
-
-def _reduce_115(val, _values, result)
- result = val[1]
- result
-end
-
-# reduce 116 omitted
-
-# reduce 117 omitted
-
-# reduce 118 omitted
-
-# reduce 119 omitted
-
-# reduce 120 omitted
-
-# reduce 121 omitted
-
-# reduce 122 omitted
-
-# reduce 123 omitted
-
-# reduce 124 omitted
-
-# reduce 125 omitted
-
-# reduce 126 omitted
-
-# reduce 127 omitted
-
-# reduce 128 omitted
-
-# reduce 129 omitted
-
-# reduce 130 omitted
-
-# reduce 131 omitted
-
-# reduce 132 omitted
-
-# reduce 133 omitted
-
-# reduce 134 omitted
-
-# reduce 135 omitted
-
-def _reduce_136(val, _values, result)
- result << val[1]
- result
-end
-
-# reduce 137 omitted
-
-def _reduce_none(val, _values, result)
- val[0]
-end
-
-end # class InlineParser
-
-end
diff --git a/lib/rdoc/rdoc.gemspec b/lib/rdoc/rdoc.gemspec
deleted file mode 100644
index 3c96f7deb1..0000000000
--- a/lib/rdoc/rdoc.gemspec
+++ /dev/null
@@ -1,233 +0,0 @@
-begin
- require_relative "lib/rdoc/version"
-rescue LoadError
- # for Ruby repository
- require_relative "version"
-end
-
-Gem::Specification.new do |s|
- s.name = "rdoc"
- s.version = RDoc::VERSION
-
- s.authors = [
- "Eric Hodel",
- "Dave Thomas",
- "Phil Hagelberg",
- "Tony Strauss",
- "Zachary Scott",
- "Hiroshi SHIBATA",
- "ITOYANAGI Sakura"
- ]
- s.email = ["drbrain@segment7.net", "", "", "", "mail@zzak.io", "hsbt@ruby-lang.org", "aycabta@gmail.com"]
-
- s.summary = "RDoc produces HTML and command-line documentation for Ruby projects"
- s.description = <<-DESCRIPTION
-RDoc produces HTML and command-line documentation for Ruby projects.
-RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentation from the command-line.
- DESCRIPTION
- s.homepage = "https://ruby.github.io/rdoc"
- s.licenses = ["Ruby"]
-
- s.bindir = "exe"
- s.executables = ["rdoc", "ri"]
- s.require_paths = ["lib"]
- # for ruby core repository. It was generated by
- # `git ls-files -z`.split("\x0").each {|f| puts " #{f.dump}," unless f.start_with?(*%W[test/ spec/ features/ .]) }
- s.files = [
- "CONTRIBUTING.rdoc",
- "CVE-2013-0256.rdoc",
- "ExampleMarkdown.md",
- "ExampleRDoc.rdoc",
- "History.rdoc",
- "LEGAL.rdoc",
- "LICENSE.rdoc",
- "README.rdoc",
- "RI.rdoc",
- "TODO.rdoc",
- "exe/rdoc",
- "exe/ri",
- "lib/rdoc.rb",
- "lib/rdoc/alias.rb",
- "lib/rdoc/anon_class.rb",
- "lib/rdoc/any_method.rb",
- "lib/rdoc/attr.rb",
- "lib/rdoc/class_module.rb",
- "lib/rdoc/code_object.rb",
- "lib/rdoc/code_objects.rb",
- "lib/rdoc/comment.rb",
- "lib/rdoc/constant.rb",
- "lib/rdoc/context.rb",
- "lib/rdoc/context/section.rb",
- "lib/rdoc/cross_reference.rb",
- "lib/rdoc/encoding.rb",
- "lib/rdoc/erb_partial.rb",
- "lib/rdoc/erbio.rb",
- "lib/rdoc/extend.rb",
- "lib/rdoc/generator.rb",
- "lib/rdoc/generator/darkfish.rb",
- "lib/rdoc/generator/json_index.rb",
- "lib/rdoc/generator/markup.rb",
- "lib/rdoc/generator/pot.rb",
- "lib/rdoc/generator/pot/message_extractor.rb",
- "lib/rdoc/generator/pot/po.rb",
- "lib/rdoc/generator/pot/po_entry.rb",
- "lib/rdoc/generator/ri.rb",
- "lib/rdoc/generator/template/darkfish/.document",
- "lib/rdoc/generator/template/darkfish/_footer.rhtml",
- "lib/rdoc/generator/template/darkfish/_head.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml",
- "lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml",
- "lib/rdoc/generator/template/darkfish/class.rhtml",
- "lib/rdoc/generator/template/darkfish/css/fonts.css",
- "lib/rdoc/generator/template/darkfish/css/rdoc.css",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf",
- "lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf",
- "lib/rdoc/generator/template/darkfish/images/add.png",
- "lib/rdoc/generator/template/darkfish/images/arrow_up.png",
- "lib/rdoc/generator/template/darkfish/images/brick.png",
- "lib/rdoc/generator/template/darkfish/images/brick_link.png",
- "lib/rdoc/generator/template/darkfish/images/bug.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_black.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png",
- "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png",
- "lib/rdoc/generator/template/darkfish/images/date.png",
- "lib/rdoc/generator/template/darkfish/images/delete.png",
- "lib/rdoc/generator/template/darkfish/images/find.png",
- "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif",
- "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png",
- "lib/rdoc/generator/template/darkfish/images/package.png",
- "lib/rdoc/generator/template/darkfish/images/page_green.png",
- "lib/rdoc/generator/template/darkfish/images/page_white_text.png",
- "lib/rdoc/generator/template/darkfish/images/page_white_width.png",
- "lib/rdoc/generator/template/darkfish/images/plugin.png",
- "lib/rdoc/generator/template/darkfish/images/ruby.png",
- "lib/rdoc/generator/template/darkfish/images/tag_blue.png",
- "lib/rdoc/generator/template/darkfish/images/tag_green.png",
- "lib/rdoc/generator/template/darkfish/images/transparent.png",
- "lib/rdoc/generator/template/darkfish/images/wrench.png",
- "lib/rdoc/generator/template/darkfish/images/wrench_orange.png",
- "lib/rdoc/generator/template/darkfish/images/zoom.png",
- "lib/rdoc/generator/template/darkfish/index.rhtml",
- "lib/rdoc/generator/template/darkfish/js/darkfish.js",
- "lib/rdoc/generator/template/darkfish/js/search.js",
- "lib/rdoc/generator/template/darkfish/page.rhtml",
- "lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml",
- "lib/rdoc/generator/template/darkfish/servlet_root.rhtml",
- "lib/rdoc/generator/template/darkfish/table_of_contents.rhtml",
- "lib/rdoc/generator/template/json_index/.document",
- "lib/rdoc/generator/template/json_index/js/navigation.js",
- "lib/rdoc/generator/template/json_index/js/searcher.js",
- "lib/rdoc/ghost_method.rb",
- "lib/rdoc/i18n.rb",
- "lib/rdoc/i18n/locale.rb",
- "lib/rdoc/i18n/text.rb",
- "lib/rdoc/include.rb",
- "lib/rdoc/known_classes.rb",
- "lib/rdoc/markdown.kpeg",
- "lib/rdoc/markdown/entities.rb",
- "lib/rdoc/markdown/literals.kpeg",
- "lib/rdoc/markup.rb",
- "lib/rdoc/markup/attr_changer.rb",
- "lib/rdoc/markup/attr_span.rb",
- "lib/rdoc/markup/attribute_manager.rb",
- "lib/rdoc/markup/attributes.rb",
- "lib/rdoc/markup/blank_line.rb",
- "lib/rdoc/markup/block_quote.rb",
- "lib/rdoc/markup/document.rb",
- "lib/rdoc/markup/formatter.rb",
- "lib/rdoc/markup/hard_break.rb",
- "lib/rdoc/markup/heading.rb",
- "lib/rdoc/markup/include.rb",
- "lib/rdoc/markup/indented_paragraph.rb",
- "lib/rdoc/markup/list.rb",
- "lib/rdoc/markup/list_item.rb",
- "lib/rdoc/markup/paragraph.rb",
- "lib/rdoc/markup/parser.rb",
- "lib/rdoc/markup/pre_process.rb",
- "lib/rdoc/markup/raw.rb",
- "lib/rdoc/markup/regexp_handling.rb",
- "lib/rdoc/markup/rule.rb",
- "lib/rdoc/markup/table.rb",
- "lib/rdoc/markup/to_ansi.rb",
- "lib/rdoc/markup/to_bs.rb",
- "lib/rdoc/markup/to_html.rb",
- "lib/rdoc/markup/to_html_crossref.rb",
- "lib/rdoc/markup/to_html_snippet.rb",
- "lib/rdoc/markup/to_joined_paragraph.rb",
- "lib/rdoc/markup/to_label.rb",
- "lib/rdoc/markup/to_markdown.rb",
- "lib/rdoc/markup/to_rdoc.rb",
- "lib/rdoc/markup/to_table_of_contents.rb",
- "lib/rdoc/markup/to_test.rb",
- "lib/rdoc/markup/to_tt_only.rb",
- "lib/rdoc/markup/verbatim.rb",
- "lib/rdoc/meta_method.rb",
- "lib/rdoc/method_attr.rb",
- "lib/rdoc/mixin.rb",
- "lib/rdoc/normal_class.rb",
- "lib/rdoc/normal_module.rb",
- "lib/rdoc/options.rb",
- "lib/rdoc/parser.rb",
- "lib/rdoc/parser/c.rb",
- "lib/rdoc/parser/changelog.rb",
- "lib/rdoc/parser/markdown.rb",
- "lib/rdoc/parser/rd.rb",
- "lib/rdoc/parser/ripper_state_lex.rb",
- "lib/rdoc/parser/ruby.rb",
- "lib/rdoc/parser/ruby_tools.rb",
- "lib/rdoc/parser/simple.rb",
- "lib/rdoc/parser/text.rb",
- "lib/rdoc/rd.rb",
- "lib/rdoc/rd/block_parser.ry",
- "lib/rdoc/rd/inline.rb",
- "lib/rdoc/rd/inline_parser.ry",
- "lib/rdoc/rdoc.rb",
- "lib/rdoc/require.rb",
- "lib/rdoc/ri.rb",
- "lib/rdoc/ri/driver.rb",
- "lib/rdoc/ri/formatter.rb",
- "lib/rdoc/ri/paths.rb",
- "lib/rdoc/ri/store.rb",
- "lib/rdoc/ri/task.rb",
- "lib/rdoc/rubygems_hook.rb",
- "lib/rdoc/servlet.rb",
- "lib/rdoc/single_class.rb",
- "lib/rdoc/stats.rb",
- "lib/rdoc/stats/normal.rb",
- "lib/rdoc/stats/quiet.rb",
- "lib/rdoc/stats/verbose.rb",
- "lib/rdoc/store.rb",
- "lib/rdoc/task.rb",
- "lib/rdoc/text.rb",
- "lib/rdoc/token_stream.rb",
- "lib/rdoc/tom_doc.rb",
- "lib/rdoc/top_level.rb",
- "lib/rdoc/version.rb",
- "man/ri.1",
- ]
- # files from .gitignore
- s.files << "lib/rdoc/rd/block_parser.rb" << "lib/rdoc/rd/inline_parser.rb" << "lib/rdoc/markdown.rb" << "lib/rdoc/markdown/literals.rb"
-
- s.rdoc_options = ["--main", "README.rdoc"]
- s.extra_rdoc_files += s.files.grep(%r[\A[^\/]+\.(?:rdoc|md)\z])
-
- s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
- s.required_rubygems_version = Gem::Requirement.new(">= 2.2")
-
- s.add_dependency 'psych', '>= 4.0.0'
-end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
deleted file mode 100644
index 2d8a9dea8c..0000000000
--- a/lib/rdoc/rdoc.rb
+++ /dev/null
@@ -1,565 +0,0 @@
-# frozen_string_literal: true
-require_relative '../rdoc'
-
-require 'find'
-require 'fileutils'
-require 'pathname'
-require 'time'
-
-##
-# This is the driver for generating RDoc output. It handles file parsing and
-# generation of output.
-#
-# To use this class to generate RDoc output via the API, the recommended way
-# is:
-#
-# rdoc = RDoc::RDoc.new
-# options = RDoc::Options.load_options # returns an RDoc::Options instance
-# # set extra options
-# rdoc.document options
-#
-# You can also generate output like the +rdoc+ executable:
-#
-# rdoc = RDoc::RDoc.new
-# rdoc.document argv
-#
-# Where +argv+ is an array of strings, each corresponding to an argument you'd
-# give rdoc on the command line. See <tt>rdoc --help</tt> for details.
-
-class RDoc::RDoc
-
- @current = nil
-
- ##
- # This is the list of supported output generators
-
- GENERATORS = {}
-
- ##
- # List of directory names always skipped
-
- UNCONDITIONALLY_SKIPPED_DIRECTORIES = %w[CVS .svn .git].freeze
-
- ##
- # List of directory names skipped if test suites should be skipped
-
- TEST_SUITE_DIRECTORY_NAMES = %w[spec test].freeze
-
-
- ##
- # Generator instance used for creating output
-
- attr_accessor :generator
-
- ##
- # Hash of files and their last modified times.
-
- attr_reader :last_modified
-
- ##
- # RDoc options
-
- attr_accessor :options
-
- ##
- # Accessor for statistics. Available after each call to parse_files
-
- attr_reader :stats
-
- ##
- # The current documentation store
-
- attr_reader :store
-
- ##
- # Add +klass+ that can generate output after parsing
-
- def self.add_generator(klass)
- name = klass.name.sub(/^RDoc::Generator::/, '').downcase
- GENERATORS[name] = klass
- end
-
- ##
- # Active RDoc::RDoc instance
-
- def self.current
- @current
- end
-
- ##
- # Sets the active RDoc::RDoc instance
-
- def self.current= rdoc
- @current = rdoc
- end
-
- ##
- # Creates a new RDoc::RDoc instance. Call #document to parse files and
- # generate documentation.
-
- def initialize
- @current = nil
- @generator = nil
- @last_modified = {}
- @old_siginfo = nil
- @options = nil
- @stats = nil
- @store = nil
- end
-
- ##
- # Report an error message and exit
-
- def error(msg)
- raise RDoc::Error, msg
- end
-
- ##
- # Gathers a set of parseable files from the files and directories listed in
- # +files+.
-
- def gather_files files
- files = ["."] if files.empty?
-
- file_list = normalized_file_list files, true, @options.exclude
-
- file_list = remove_unparseable(file_list)
-
- if file_list.count {|name, mtime|
- file_list[name] = @last_modified[name] unless mtime
- mtime
- } > 0
- @last_modified.replace file_list
- file_list.keys.sort
- else
- []
- end
- end
-
- ##
- # Turns RDoc from stdin into HTML
-
- def handle_pipe
- @html = RDoc::Markup::ToHtml.new @options
-
- parser = RDoc::Text::MARKUP_FORMAT[@options.markup]
-
- document = parser.parse $stdin.read
-
- out = @html.convert document
-
- $stdout.write out
- end
-
- ##
- # Installs a siginfo handler that prints the current filename.
-
- def install_siginfo_handler
- return unless Signal.list.include? 'INFO'
-
- @old_siginfo = trap 'INFO' do
- puts @current if @current
- end
- end
-
- ##
- # Create an output dir if it doesn't exist. If it does exist, but doesn't
- # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
- # we may clobber some manually generated documentation
-
- def setup_output_dir(dir, force)
- flag_file = output_flag_file dir
-
- last = {}
-
- if @options.dry_run then
- # do nothing
- elsif File.exist? dir then
- error "#{dir} exists and is not a directory" unless File.directory? dir
-
- begin
- File.open flag_file do |io|
- unless force then
- Time.parse io.gets
-
- io.each do |line|
- file, time = line.split "\t", 2
- time = Time.parse(time) rescue next
- last[file] = time
- end
- end
- end
- rescue SystemCallError, TypeError
- error <<-ERROR
-
-Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
-
-Because RDoc doesn't want to risk destroying any of your existing files,
-you'll need to specify a different output directory name (using the --op <dir>
-option)
-
- ERROR
- end unless @options.force_output
- else
- FileUtils.mkdir_p dir
- FileUtils.touch flag_file
- end
-
- last
- end
-
- ##
- # Sets the current documentation tree to +store+ and sets the store's rdoc
- # driver to this instance.
-
- def store= store
- @store = store
- @store.rdoc = self
- end
-
- ##
- # Update the flag file in an output directory.
-
- def update_output_dir(op_dir, time, last = {})
- return if @options.dry_run or not @options.update_output_dir
- unless ENV['SOURCE_DATE_EPOCH'].nil?
- time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
- end
-
- File.open output_flag_file(op_dir), "w" do |f|
- f.puts time.rfc2822
- last.each do |n, t|
- f.puts "#{n}\t#{t.rfc2822}"
- end
- end
- end
-
- ##
- # Return the path name of the flag file in an output directory.
-
- def output_flag_file(op_dir)
- File.join op_dir, "created.rid"
- end
-
- ##
- # The .document file contains a list of file and directory name patterns,
- # representing candidates for documentation. It may also contain comments
- # (starting with '#')
-
- def parse_dot_doc_file in_dir, filename
- # read and strip comments
- patterns = File.read(filename).gsub(/#.*/, '')
-
- result = {}
-
- patterns.split(' ').each do |patt|
- candidates = Dir.glob(File.join(in_dir, patt))
- result.update normalized_file_list(candidates, false, @options.exclude)
- end
-
- result
- end
-
- ##
- # Given a list of files and directories, create a list of all the Ruby
- # files they contain.
- #
- # If +force_doc+ is true we always add the given files, if false, only
- # add files that we guarantee we can parse. It is true when looking at
- # files given on the command line, false when recursing through
- # subdirectories.
- #
- # The effect of this is that if you want a file with a non-standard
- # extension parsed, you must name it explicitly.
-
- def normalized_file_list(relative_files, force_doc = false,
- exclude_pattern = nil)
- file_list = {}
-
- relative_files.each do |rel_file_name|
- rel_file_name = rel_file_name.sub(/^\.\//, '')
- next if rel_file_name.end_with? 'created.rid'
- next if exclude_pattern && exclude_pattern =~ rel_file_name
- stat = File.stat rel_file_name rescue next
-
- case type = stat.ftype
- when "file" then
- mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
- stat.mtime.to_i <= last_modified.to_i))
-
- if force_doc or RDoc::Parser.can_parse(rel_file_name) then
- file_list[rel_file_name] = mtime
- end
- when "directory" then
- next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
-
- basename = File.basename(rel_file_name)
- next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
-
- created_rid = File.join rel_file_name, "created.rid"
- next if File.file? created_rid
-
- dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
-
- if File.file? dot_doc then
- file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
- else
- file_list.update(list_files_in_directory(rel_file_name))
- end
- else
- warn "rdoc can't parse the #{type} #{rel_file_name}"
- end
- end
-
- file_list
- end
-
- ##
- # Return a list of the files to be processed in a directory. We know that
- # this directory doesn't have a .document file, so we're looking for real
- # files. However we may well contain subdirectories which must be tested
- # for .document files.
-
- def list_files_in_directory dir
- files = Dir.glob File.join(dir, "*")
-
- normalized_file_list files, false, @options.exclude
- end
-
- ##
- # Parses +filename+ and returns an RDoc::TopLevel
-
- def parse_file filename
- encoding = @options.encoding
- filename = filename.encode encoding
-
- @stats.add_file filename
-
- return if RDoc::Parser.binary? filename
-
- content = RDoc::Encoding.read_file filename, encoding
-
- return unless content
-
- filename_path = Pathname(filename).expand_path
- begin
- relative_path = filename_path.relative_path_from @options.root
- rescue ArgumentError
- relative_path = filename_path
- end
-
- if @options.page_dir and
- relative_path.to_s.start_with? @options.page_dir.to_s then
- relative_path =
- relative_path.relative_path_from @options.page_dir
- end
-
- top_level = @store.add_file filename, relative_name: relative_path.to_s
-
- parser = RDoc::Parser.for top_level, filename, content, @options, @stats
-
- return unless parser
-
- parser.scan
-
- # restart documentation for the classes & modules found
- top_level.classes_or_modules.each do |cm|
- cm.done_documenting = false
- end
-
- top_level
-
- rescue Errno::EACCES => e
- $stderr.puts <<-EOF
-Unable to read #{filename}, #{e.message}
-
-Please check the permissions for this file. Perhaps you do not have access to
-it or perhaps the original author's permissions are to restrictive. If the
-this is not your library please report a bug to the author.
- EOF
- rescue => e
- $stderr.puts <<-EOF
-Before reporting this, could you check that the file you're documenting
-has proper syntax:
-
- #{Gem.ruby} -c #{filename}
-
-RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.
-
-The internal error was:
-
-\t(#{e.class}) #{e.message}
-
- EOF
-
- $stderr.puts e.backtrace.join("\n\t") if $DEBUG_RDOC
-
- raise e
- nil
- end
-
- ##
- # Parse each file on the command line, recursively entering directories.
-
- def parse_files files
- file_list = gather_files files
- @stats = RDoc::Stats.new @store, file_list.length, @options.verbosity
-
- return [] if file_list.empty?
-
- original_options = @options.dup
- @stats.begin_adding
-
- file_info = file_list.map do |filename|
- @current = filename
- parse_file filename
- end.compact
-
- @stats.done_adding
- @options = original_options
-
- file_info
- end
-
- ##
- # Removes file extensions known to be unparseable from +files+ and TAGS
- # files for emacs and vim.
-
- def remove_unparseable files
- files.reject do |file, *|
- file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
- (file =~ /tags$/i and
- File.open(file, 'rb') { |io|
- io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
- })
- end
- end
-
- ##
- # Generates documentation or a coverage report depending upon the settings
- # in +options+.
- #
- # +options+ can be either an RDoc::Options instance or an array of strings
- # equivalent to the strings that would be passed on the command line like
- # <tt>%w[-q -o doc -t My\ Doc\ Title]</tt>. #document will automatically
- # call RDoc::Options#finish if an options instance was given.
- #
- # For a list of options, see either RDoc::Options or <tt>rdoc --help</tt>.
- #
- # By default, output will be stored in a directory called "doc" below the
- # current directory, so make sure you're somewhere writable before invoking.
-
- def document options
- self.store = RDoc::Store.new
-
- if RDoc::Options === options then
- @options = options
- else
- @options = RDoc::Options.load_options
- @options.parse options
- end
- @options.finish
-
- if @options.pipe then
- handle_pipe
- exit
- end
-
- unless @options.coverage_report then
- @last_modified = setup_output_dir @options.op_dir, @options.force_update
- end
-
- @store.encoding = @options.encoding
- @store.dry_run = @options.dry_run
- @store.main = @options.main_page
- @store.title = @options.title
- @store.path = @options.op_dir
-
- @start_time = Time.now
-
- @store.load_cache
-
- file_info = parse_files @options.files
-
- @options.default_title = "RDoc Documentation"
-
- @store.complete @options.visibility
-
- @stats.coverage_level = @options.coverage_report
-
- if @options.coverage_report then
- puts
-
- puts @stats.report.accept RDoc::Markup::ToRdoc.new
- elsif file_info.empty? then
- $stderr.puts "\nNo newer files." unless @options.quiet
- else
- gen_klass = @options.generator
-
- @generator = gen_klass.new @store, @options
-
- generate
- end
-
- if @stats and (@options.coverage_report or not @options.quiet) then
- puts
- puts @stats.summary.accept RDoc::Markup::ToRdoc.new
- end
-
- exit @stats.fully_documented? if @options.coverage_report
- end
-
- ##
- # Generates documentation for +file_info+ (from #parse_files) into the
- # output dir using the generator selected
- # by the RDoc options
-
- def generate
- if @options.dry_run then
- # do nothing
- @generator.generate
- else
- Dir.chdir @options.op_dir do
- unless @options.quiet then
- $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
- end
-
- @generator.generate
- update_output_dir '.', @start_time, @last_modified
- end
- end
- end
-
- ##
- # Removes a siginfo handler and replaces the previous
-
- def remove_siginfo_handler
- return unless Signal.list.key? 'INFO'
-
- handler = @old_siginfo || 'DEFAULT'
-
- trap 'INFO', handler
- end
-
-end
-
-begin
- require 'rubygems'
-
- rdoc_extensions = Gem.find_files 'rdoc/discover'
-
- rdoc_extensions.each do |extension|
- begin
- load extension
- rescue => e
- warn "error loading #{extension.inspect}: #{e.message} (#{e.class})"
- warn "\t#{e.backtrace.join "\n\t"}" if $DEBUG
- end
- end
-rescue LoadError
-end
-
-# require built-in generators after discovery in case they've been replaced
-require_relative 'generator/darkfish'
-require_relative 'generator/ri'
-require_relative 'generator/pot'
diff --git a/lib/rdoc/require.rb b/lib/rdoc/require.rb
deleted file mode 100644
index 91f9c24e5d..0000000000
--- a/lib/rdoc/require.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-##
-# A file loaded by \#require
-
-class RDoc::Require < RDoc::CodeObject
-
- ##
- # Name of the required file
-
- attr_accessor :name
-
- ##
- # Creates a new Require that loads +name+ with +comment+
-
- def initialize(name, comment)
- super()
- @name = name.gsub(/'|"/, "") #'
- @top_level = nil
- self.comment = comment
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x require '%s' in %s>" % [
- self.class,
- object_id,
- @name,
- parent_file_name,
- ]
- end
-
- def to_s # :nodoc:
- "require #{name} in: #{parent}"
- end
-
- ##
- # The RDoc::TopLevel corresponding to this require, or +nil+ if not found.
-
- def top_level
- @top_level ||= begin
- tl = RDoc::TopLevel.all_files_hash[name + '.rb']
-
- if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then
- # second chance
- tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb']
- end
-
- tl
- end
- end
-
-end
-
diff --git a/lib/rdoc/ri.rb b/lib/rdoc/ri.rb
deleted file mode 100644
index 0af05f729f..0000000000
--- a/lib/rdoc/ri.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-require_relative '../rdoc'
-
-##
-# Namespace for the ri command line tool's implementation.
-#
-# See <tt>ri --help</tt> for details.
-
-module RDoc::RI
-
- ##
- # Base RI error class
-
- class Error < RDoc::Error; end
-
- autoload :Driver, "#{__dir__}/ri/driver"
- autoload :Paths, "#{__dir__}/ri/paths"
- autoload :Store, "#{__dir__}/ri/store"
-
-end
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
deleted file mode 100644
index 819cff8aa3..0000000000
--- a/lib/rdoc/ri/driver.rb
+++ /dev/null
@@ -1,1512 +0,0 @@
-# frozen_string_literal: true
-require 'optparse'
-
-require_relative '../../rdoc'
-
-require_relative 'formatter' # For RubyGems backwards compatibility
-# TODO: Fix weird documentation with `require_relative`
-
-##
-# The RI driver implements the command-line ri tool.
-#
-# The driver supports:
-# * loading RI data from:
-# * Ruby's standard library
-# * RubyGems
-# * ~/.rdoc
-# * A user-supplied directory
-# * Paging output (uses RI_PAGER environment variable, PAGER environment
-# variable or the less, more and pager programs)
-# * Interactive mode with tab-completion
-# * Abbreviated names (ri Zl shows Zlib documentation)
-# * Colorized output
-# * Merging output from multiple RI data sources
-
-class RDoc::RI::Driver
-
- ##
- # Base Driver error class
-
- class Error < RDoc::RI::Error; end
-
- ##
- # Raised when a name isn't found in the ri data stores
-
- class NotFoundError < Error
-
- def initialize(klass, suggestions = nil) # :nodoc:
- @klass = klass
- @suggestions = suggestions
- end
-
- ##
- # Name that wasn't found
-
- def name
- @klass
- end
-
- def message # :nodoc:
- str = "Nothing known about #{@klass}"
- if @suggestions and !@suggestions.empty?
- str += "\nDid you mean? #{@suggestions.join("\n ")}"
- end
- str
- end
- end
-
- ##
- # Show all method documentation following a class or module
-
- attr_accessor :show_all
-
- ##
- # An RDoc::RI::Store for each entry in the RI path
-
- attr_accessor :stores
-
- ##
- # Controls the user of the pager vs $stdout
-
- attr_accessor :use_stdout
-
- ##
- # Default options for ri
-
- def self.default_options
- options = {}
- options[:interactive] = false
- options[:profile] = false
- options[:show_all] = false
- options[:use_stdout] = !$stdout.tty?
- options[:width] = 72
-
- # By default all standard paths are used.
- options[:use_system] = true
- options[:use_site] = true
- options[:use_home] = true
- options[:use_gems] = true
- options[:extra_doc_dirs] = []
-
- return options
- end
-
- ##
- # Dump +data_path+ using pp
-
- def self.dump data_path
- require 'pp'
-
- File.open data_path, 'rb' do |io|
- pp Marshal.load(io.read)
- end
- end
-
- ##
- # Parses +argv+ and returns a Hash of options
-
- def self.process_args argv
- options = default_options
-
- opts = OptionParser.new do |opt|
- opt.accept File do |file,|
- File.readable?(file) and not File.directory?(file) and file
- end
-
- opt.program_name = File.basename $0
- opt.version = RDoc::VERSION
- opt.release = nil
- opt.summary_indent = ' ' * 4
-
- opt.banner = <<-EOT
-Usage: #{opt.program_name} [options] [name ...]
-
-Where name can be:
-
- Class | Module | Module::Class
-
- Class::method | Class#method | Class.method | method
-
- gem_name: | gem_name:README | gem_name:History
-
- ruby: | ruby:NEWS | ruby:globals
-
-All class names may be abbreviated to their minimum unambiguous form.
-If a name is ambiguous, all valid options will be listed.
-
-A '.' matches either class or instance methods, while #method
-matches only instance and ::method matches only class methods.
-
-README and other files may be displayed by prefixing them with the gem name
-they're contained in. If the gem name is followed by a ':' all files in the
-gem will be shown. The file name extension may be omitted where it is
-unambiguous.
-
-'ruby' can be used as a pseudo gem name to display files from the Ruby
-core documentation. Use 'ruby:' by itself to get a list of all available
-core documentation files.
-
-For example:
-
- #{opt.program_name} Fil
- #{opt.program_name} File
- #{opt.program_name} File.new
- #{opt.program_name} zip
- #{opt.program_name} rdoc:README
- #{opt.program_name} ruby:comments
-
-Note that shell quoting or escaping may be required for method names
-containing punctuation:
-
- #{opt.program_name} 'Array.[]'
- #{opt.program_name} compact\\!
-
-To see the default directories #{opt.program_name} will search, run:
-
- #{opt.program_name} --list-doc-dirs
-
-Specifying the --system, --site, --home, --gems, or --doc-dir options
-will limit ri to searching only the specified directories.
-
-ri options may be set in the RI environment variable.
-
-The ri pager can be set with the RI_PAGER environment variable
-or the PAGER environment variable.
- EOT
-
- opt.separator nil
- opt.separator "Options:"
-
- opt.separator nil
-
- opt.on("--[no-]interactive", "-i",
- "In interactive mode you can repeatedly",
- "look up methods with autocomplete.") do |interactive|
- options[:interactive] = interactive
- end
-
- opt.separator nil
-
- opt.on("--[no-]all", "-a",
- "Show all documentation for a class or",
- "module.") do |show_all|
- options[:show_all] = show_all
- end
-
- opt.separator nil
-
- opt.on("--[no-]list", "-l",
- "List classes ri knows about.") do |list|
- options[:list] = list
- end
-
- opt.separator nil
-
- opt.on("--[no-]pager",
- "Send output to a pager,",
- "rather than directly to stdout.") do |use_pager|
- options[:use_stdout] = !use_pager
- end
-
- opt.separator nil
-
- opt.on("-T",
- "Synonym for --no-pager.") do
- options[:use_stdout] = true
- end
-
- opt.separator nil
-
- opt.on("--width=WIDTH", "-w", OptionParser::DecimalInteger,
- "Set the width of the output.") do |width|
- options[:width] = width
- end
-
- opt.separator nil
-
- opt.on("--server[=PORT]", Integer,
- "Run RDoc server on the given port.",
- "The default port is 8214.") do |port|
- options[:server] = port || 8214
- end
-
- opt.separator nil
-
- formatters = RDoc::Markup.constants.grep(/^To[A-Z][a-z]+$/).sort
- formatters = formatters.sort.map do |formatter|
- formatter.to_s.sub('To', '').downcase
- end
- formatters -= %w[html label test] # remove useless output formats
-
- opt.on("--format=NAME", "-f",
- "Use the selected formatter. The default",
- "formatter is bs for paged output and ansi",
- "otherwise. Valid formatters are:",
- "#{formatters.join(', ')}.", formatters) do |value|
- options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
- end
-
- opt.separator nil
-
- opt.on("--help", "-h",
- "Show help and exit.") do
- puts opts
- exit
- end
-
- opt.separator nil
-
- opt.on("--version", "-v",
- "Output version information and exit.") do
- puts "#{opts.program_name} #{opts.version}"
- exit
- end
-
- opt.separator nil
- opt.separator "Data source options:"
- opt.separator nil
-
- opt.on("--[no-]list-doc-dirs",
- "List the directories from which ri will",
- "source documentation on stdout and exit.") do |list_doc_dirs|
- options[:list_doc_dirs] = list_doc_dirs
- end
-
- opt.separator nil
-
- opt.on("--doc-dir=DIRNAME", "-d", Array,
- "List of directories from which to source",
- "documentation in addition to the standard",
- "directories. May be repeated.") do |value|
- value.each do |dir|
- unless File.directory? dir then
- raise OptionParser::InvalidArgument, "#{dir} is not a directory"
- end
-
- options[:extra_doc_dirs] << File.expand_path(dir)
- end
- end
-
- opt.separator nil
-
- opt.on("--no-standard-docs",
- "Do not include documentation from",
- "the Ruby standard library, site_lib,",
- "installed gems, or ~/.rdoc.",
- "Use with --doc-dir.") do
- options[:use_system] = false
- options[:use_site] = false
- options[:use_gems] = false
- options[:use_home] = false
- end
-
- opt.separator nil
-
- opt.on("--[no-]system",
- "Include documentation from Ruby's",
- "standard library. Defaults to true.") do |value|
- options[:use_system] = value
- end
-
- opt.separator nil
-
- opt.on("--[no-]site",
- "Include documentation from libraries",
- "installed in site_lib.",
- "Defaults to true.") do |value|
- options[:use_site] = value
- end
-
- opt.separator nil
-
- opt.on("--[no-]gems",
- "Include documentation from RubyGems.",
- "Defaults to true.") do |value|
- options[:use_gems] = value
- end
-
- opt.separator nil
-
- opt.on("--[no-]home",
- "Include documentation stored in ~/.rdoc.",
- "Defaults to true.") do |value|
- options[:use_home] = value
- end
-
- opt.separator nil
- opt.separator "Debug options:"
- opt.separator nil
-
- opt.on("--[no-]profile",
- "Run with the ruby profiler.") do |value|
- options[:profile] = value
- end
-
- opt.separator nil
-
- opt.on("--dump=CACHE", File,
- "Dump data from an ri cache or data file.") do |value|
- options[:dump_path] = value
- end
- end
-
- argv = ENV['RI'].to_s.split(' ').concat argv
-
- opts.parse! argv
-
- options[:names] = argv
-
- options[:use_stdout] ||= !$stdout.tty?
- options[:use_stdout] ||= options[:interactive]
- options[:width] ||= 72
-
- options
-
- rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
- puts opts
- puts
- puts e
- exit 1
- end
-
- ##
- # Runs the ri command line executable using +argv+
-
- def self.run argv = ARGV
- options = process_args argv
-
- if options[:dump_path] then
- dump options[:dump_path]
- return
- end
-
- ri = new options
- ri.run
- end
-
- ##
- # Creates a new driver using +initial_options+ from ::process_args
-
- def initialize initial_options = {}
- @paging = false
- @classes = nil
-
- options = self.class.default_options.update(initial_options)
-
- @formatter_klass = options[:formatter]
-
- require 'profile' if options[:profile]
-
- @names = options[:names]
- @list = options[:list]
-
- @doc_dirs = []
- @stores = []
-
- RDoc::RI::Paths.each(options[:use_system], options[:use_site],
- options[:use_home], options[:use_gems],
- *options[:extra_doc_dirs]) do |path, type|
- @doc_dirs << path
-
- store = RDoc::RI::Store.new path, type
- store.load_cache
- @stores << store
- end
-
- @list_doc_dirs = options[:list_doc_dirs]
-
- @interactive = options[:interactive]
- @server = options[:server]
- @use_stdout = options[:use_stdout]
- @show_all = options[:show_all]
- @width = options[:width]
- end
-
- ##
- # Adds paths for undocumented classes +also_in+ to +out+
-
- def add_also_in out, also_in
- return if also_in.empty?
-
- out << RDoc::Markup::Rule.new(1)
- out << RDoc::Markup::Paragraph.new("Also found in:")
-
- paths = RDoc::Markup::Verbatim.new
- also_in.each do |store|
- paths.parts.push store.friendly_path, "\n"
- end
- out << paths
- end
-
- ##
- # Adds a class header to +out+ for class +name+ which is described in
- # +classes+.
-
- def add_class out, name, classes
- heading = if classes.all? { |klass| klass.module? } then
- name
- else
- superclass = classes.map do |klass|
- klass.superclass unless klass.module?
- end.compact.shift || 'Object'
-
- superclass = superclass.full_name unless String === superclass
-
- "#{name} < #{superclass}"
- end
-
- out << RDoc::Markup::Heading.new(1, heading)
- out << RDoc::Markup::BlankLine.new
- end
-
- ##
- # Adds "(from ...)" to +out+ for +store+
-
- def add_from out, store
- out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
- end
-
- ##
- # Adds +extends+ to +out+
-
- def add_extends out, extends
- add_extension_modules out, 'Extended by', extends
- end
-
- ##
- # Adds a list of +extensions+ to this module of the given +type+ to +out+.
- # add_includes and add_extends call this, so you should use those directly.
-
- def add_extension_modules out, type, extensions
- return if extensions.empty?
-
- out << RDoc::Markup::Rule.new(1)
- out << RDoc::Markup::Heading.new(1, "#{type}:")
-
- extensions.each do |modules, store|
- if modules.length == 1 then
- add_extension_modules_single out, store, modules.first
- else
- add_extension_modules_multiple out, store, modules
- end
- end
- end
-
- ##
- # Renders multiple included +modules+ from +store+ to +out+.
-
- def add_extension_modules_multiple out, store, modules # :nodoc:
- out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
-
- wout, with = modules.partition { |incl| incl.comment.empty? }
-
- out << RDoc::Markup::BlankLine.new unless with.empty?
-
- with.each do |incl|
- out << RDoc::Markup::Paragraph.new(incl.name)
- out << RDoc::Markup::BlankLine.new
- out << incl.comment
- end
-
- unless wout.empty? then
- verb = RDoc::Markup::Verbatim.new
-
- wout.each do |incl|
- verb.push incl.name, "\n"
- end
-
- out << verb
- end
- end
-
- ##
- # Adds a single extension module +include+ from +store+ to +out+
-
- def add_extension_modules_single out, store, include # :nodoc:
- name = include.name
- path = store.friendly_path
- out << RDoc::Markup::Paragraph.new("#{name} (from #{path})")
-
- if include.comment then
- out << RDoc::Markup::BlankLine.new
- out << include.comment
- end
- end
-
- ##
- # Adds +includes+ to +out+
-
- def add_includes out, includes
- add_extension_modules out, 'Includes', includes
- end
-
- ##
- # Looks up the method +name+ and adds it to +out+
-
- def add_method out, name
- filtered = lookup_method name
-
- method_out = method_document name, filtered
-
- out.concat method_out.parts
- end
-
- ##
- # Adds documentation for all methods in +klass+ to +out+
-
- def add_method_documentation out, klass
- klass.method_list.each do |method|
- begin
- add_method out, method.full_name
- rescue NotFoundError
- next
- end
- end
- end
-
- ##
- # Adds a list of +methods+ to +out+ with a heading of +name+
-
- def add_method_list out, methods, name
- return if methods.empty?
-
- out << RDoc::Markup::Heading.new(1, "#{name}:")
- out << RDoc::Markup::BlankLine.new
-
- if @use_stdout and !@interactive then
- out.concat methods.map { |method|
- RDoc::Markup::Verbatim.new method
- }
- else
- out << RDoc::Markup::IndentedParagraph.new(2, methods.join(', '))
- end
-
- out << RDoc::Markup::BlankLine.new
- end
-
- ##
- # Returns ancestor classes of +klass+
-
- def ancestors_of klass
- ancestors = []
-
- unexamined = [klass]
- seen = []
-
- loop do
- break if unexamined.empty?
- current = unexamined.shift
- seen << current
-
- stores = classes[current]
-
- next unless stores and not stores.empty?
-
- klasses = stores.flat_map do |store|
- store.ancestors[current] || []
- end.uniq
-
- klasses = klasses - seen
-
- ancestors.concat klasses
- unexamined.concat klasses
- end
-
- ancestors.reverse
- end
-
- ##
- # For RubyGems backwards compatibility
-
- def class_cache # :nodoc:
- end
-
- ##
- # Builds a RDoc::Markup::Document from +found+, +klasess+ and +includes+
-
- def class_document name, found, klasses, includes, extends
- also_in = []
-
- out = RDoc::Markup::Document.new
-
- add_class out, name, klasses
-
- add_includes out, includes
- add_extends out, extends
-
- found.each do |store, klass|
- render_class out, store, klass, also_in
- end
-
- add_also_in out, also_in
-
- out
- end
-
- ##
- # Adds the class +comment+ to +out+.
-
- def class_document_comment out, comment # :nodoc:
- unless comment.empty? then
- out << RDoc::Markup::Rule.new(1)
-
- if comment.merged? then
- parts = comment.parts
- parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
- parts.flatten!
- parts.pop
-
- out.concat parts
- else
- out << comment
- end
- end
- end
-
- ##
- # Adds the constants from +klass+ to the Document +out+.
-
- def class_document_constants out, klass # :nodoc:
- return if klass.constants.empty?
-
- out << RDoc::Markup::Heading.new(1, "Constants:")
- out << RDoc::Markup::BlankLine.new
- list = RDoc::Markup::List.new :NOTE
-
- constants = klass.constants.sort_by { |constant| constant.name }
-
- list.items.concat constants.map { |constant|
- parts = constant.comment.parts if constant.comment
- parts << RDoc::Markup::Paragraph.new('[not documented]') if
- parts.empty?
-
- RDoc::Markup::ListItem.new(constant.name, *parts)
- }
-
- out << list
- out << RDoc::Markup::BlankLine.new
- end
-
- ##
- # Hash mapping a known class or module to the stores it can be loaded from
-
- def classes
- return @classes if @classes
-
- @classes = {}
-
- @stores.each do |store|
- store.cache[:modules].each do |mod|
- # using default block causes searched-for modules to be added
- @classes[mod] ||= []
- @classes[mod] << store
- end
- end
-
- @classes
- end
-
- ##
- # Returns the stores wherein +name+ is found along with the classes,
- # extends and includes that match it
-
- def classes_and_includes_and_extends_for name
- klasses = []
- extends = []
- includes = []
-
- found = @stores.map do |store|
- begin
- klass = store.load_class name
- klasses << klass
- extends << [klass.extends, store] if klass.extends
- includes << [klass.includes, store] if klass.includes
- [store, klass]
- rescue RDoc::Store::MissingFileError
- end
- end.compact
-
- extends.reject! do |modules,| modules.empty? end
- includes.reject! do |modules,| modules.empty? end
-
- [found, klasses, includes, extends]
- end
-
- ##
- # Completes +name+ based on the caches. For Readline
-
- def complete name
- completions = []
-
- klass, selector, method = parse_name name
-
- complete_klass name, klass, selector, method, completions
- complete_method name, klass, selector, completions
-
- completions.sort.uniq
- end
-
- def complete_klass name, klass, selector, method, completions # :nodoc:
- klasses = classes.keys
-
- # may need to include Foo when given Foo::
- klass_name = method ? name : klass
-
- if name !~ /#|\./ then
- completions.replace klasses.grep(/^#{Regexp.escape klass_name}[^:]*$/)
- completions.concat klasses.grep(/^#{Regexp.escape name}[^:]*$/) if
- name =~ /::$/
-
- completions << klass if classes.key? klass # to complete a method name
- elsif selector then
- completions << klass if classes.key? klass
- elsif classes.key? klass_name then
- completions << klass_name
- end
- end
-
- def complete_method name, klass, selector, completions # :nodoc:
- if completions.include? klass and name =~ /#|\.|::/ then
- methods = list_methods_matching name
-
- if not methods.empty? then
- # remove Foo if given Foo:: and a method was found
- completions.delete klass
- elsif selector then
- # replace Foo with Foo:: as given
- completions.delete klass
- completions << "#{klass}#{selector}"
- end
-
- completions.concat methods
- end
- end
-
- ##
- # Converts +document+ to text and writes it to the pager
-
- def display document
- page do |io|
- f = formatter(io)
- f.width = @width if @width and f.respond_to?(:width)
- text = document.accept f
-
- io.write text
- end
- end
-
- ##
- # Outputs formatted RI data for class +name+. Groups undocumented classes
-
- def display_class name
- return if name =~ /#|\./
-
- found, klasses, includes, extends =
- classes_and_includes_and_extends_for name
-
- return if found.empty?
-
- out = class_document name, found, klasses, includes, extends
-
- display out
- end
-
- ##
- # Outputs formatted RI data for method +name+
-
- def display_method name
- out = RDoc::Markup::Document.new
-
- add_method out, name
-
- display out
- end
-
- ##
- # Outputs formatted RI data for the class or method +name+.
- #
- # Returns true if +name+ was found, false if it was not an alternative could
- # be guessed, raises an error if +name+ couldn't be guessed.
-
- def display_name name
- if name =~ /\w:(\w|$)/ then
- display_page name
- return true
- end
-
- return true if display_class name
-
- display_method name if name =~ /::|#|\./
-
- true
- rescue NotFoundError
- matches = list_methods_matching name if name =~ /::|#|\./
- matches = classes.keys.grep(/^#{Regexp.escape name}/) if matches.empty?
-
- raise if matches.empty?
-
- page do |io|
- io.puts "#{name} not found, maybe you meant:"
- io.puts
- io.puts matches.sort.join("\n")
- end
-
- false
- end
-
- ##
- # Displays each name in +name+
-
- def display_names names
- names.each do |name|
- name = expand_name name
-
- display_name name
- end
- end
-
- ##
- # Outputs formatted RI data for page +name+.
-
- def display_page name
- store_name, page_name = name.split ':', 2
-
- store = @stores.find { |s| s.source == store_name }
-
- return display_page_list store if page_name.empty?
-
- pages = store.cache[:pages]
-
- unless pages.include? page_name then
- found_names = pages.select do |n|
- n =~ /#{Regexp.escape page_name}\.[^.]+$/
- end
-
- if found_names.length.zero? then
- return display_page_list store, pages
- elsif found_names.length > 1 then
- return display_page_list store, found_names, page_name
- end
-
- page_name = found_names.first
- end
-
- page = store.load_page page_name
-
- display page.comment
- end
-
- ##
- # Outputs a formatted RI page list for the pages in +store+.
-
- def display_page_list store, pages = store.cache[:pages], search = nil
- out = RDoc::Markup::Document.new
-
- title = if search then
- "#{search} pages"
- else
- 'Pages'
- end
-
- out << RDoc::Markup::Heading.new(1, "#{title} in #{store.friendly_path}")
- out << RDoc::Markup::BlankLine.new
-
- list = RDoc::Markup::List.new(:BULLET)
-
- pages.each do |page|
- list << RDoc::Markup::Paragraph.new(page)
- end
-
- out << list
-
- display out
- end
-
- def check_did_you_mean # :nodoc:
- if defined? DidYouMean::SpellChecker
- true
- else
- begin
- require 'did_you_mean'
- if defined? DidYouMean::SpellChecker
- true
- else
- false
- end
- rescue LoadError
- false
- end
- end
- end
-
- ##
- # Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
- # will be expanded to Zlib::DataError.
-
- def expand_class klass
- class_names = classes.keys
- ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
- if ary.length != 1 && ary.first != klass
- if check_did_you_mean
- suggestions = DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass)
- raise NotFoundError.new(klass, suggestions)
- else
- raise NotFoundError, klass
- end
- end
- ary.first
- end
-
- ##
- # Expands the class portion of +name+ into a fully-qualified class. See
- # #expand_class.
-
- def expand_name name
- klass, selector, method = parse_name name
-
- return [selector, method].join if klass.empty?
-
- case selector
- when ':' then
- [find_store(klass), selector, method]
- else
- [expand_class(klass), selector, method]
- end.join
- end
-
- ##
- # Filters the methods in +found+ trying to find a match for +name+.
-
- def filter_methods found, name
- regexp = name_regexp name
-
- filtered = found.find_all do |store, methods|
- methods.any? { |method| method.full_name =~ regexp }
- end
-
- return filtered unless filtered.empty?
-
- found
- end
-
- ##
- # Yields items matching +name+ including the store they were found in, the
- # class being searched for, the class they were found in (an ancestor) the
- # types of methods to look up (from #method_type), and the method name being
- # searched for
-
- def find_methods name
- klass, selector, method = parse_name name
-
- types = method_type selector
-
- klasses = nil
- ambiguous = klass.empty?
-
- if ambiguous then
- klasses = classes.keys
- else
- klasses = ancestors_of klass
- klasses.unshift klass
- end
-
- methods = []
-
- klasses.each do |ancestor|
- ancestors = classes[ancestor]
-
- next unless ancestors
-
- klass = ancestor if ambiguous
-
- ancestors.each do |store|
- methods << [store, klass, ancestor, types, method]
- end
- end
-
- methods = methods.sort_by do |_, k, a, _, m|
- [k, a, m].compact
- end
-
- methods.each do |item|
- yield(*item) # :yields: store, klass, ancestor, types, method
- end
-
- self
- end
-
- ##
- # Finds a store that matches +name+ which can be the name of a gem, "ruby",
- # "home" or "site".
- #
- # See also RDoc::Store#source
-
- def find_store name
- @stores.each do |store|
- source = store.source
-
- return source if source == name
-
- return source if
- store.type == :gem and source =~ /^#{Regexp.escape name}-\d/
- end
-
- raise RDoc::RI::Driver::NotFoundError, name
- end
-
- ##
- # Creates a new RDoc::Markup::Formatter. If a formatter is given with -f,
- # use it. If we're outputting to a pager, use bs, otherwise ansi.
-
- def formatter(io)
- if @formatter_klass then
- @formatter_klass.new
- elsif paging? or !io.tty? then
- RDoc::Markup::ToBs.new
- else
- RDoc::Markup::ToAnsi.new
- end
- end
-
- ##
- # Runs ri interactively using Readline if it is available.
-
- def interactive
- puts "\nEnter the method name you want to look up."
-
- begin
- require 'readline'
- rescue LoadError
- end
- if defined? Readline then
- Readline.completion_proc = method :complete
- puts "You can use tab to autocomplete."
- end
-
- puts "Enter a blank line to exit.\n\n"
-
- loop do
- name = if defined? Readline then
- Readline.readline ">> "
- else
- print ">> "
- $stdin.gets
- end
-
- return if name.nil? or name.empty?
-
- begin
- display_name expand_name(name.strip)
- rescue NotFoundError => e
- puts e.message
- end
- end
-
- rescue Interrupt
- exit
- end
-
- ##
- # Lists classes known to ri starting with +names+. If +names+ is empty all
- # known classes are shown.
-
- def list_known_classes names = []
- classes = []
-
- stores.each do |store|
- classes << store.module_names
- end
-
- classes = classes.flatten.uniq.sort
-
- unless names.empty? then
- filter = Regexp.union names.map { |name| /^#{name}/ }
-
- classes = classes.grep filter
- end
-
- page do |io|
- if paging? or io.tty? then
- if names.empty? then
- io.puts "Classes and Modules known to ri:"
- else
- io.puts "Classes and Modules starting with #{names.join ', '}:"
- end
- io.puts
- end
-
- io.puts classes.join("\n")
- end
- end
-
- ##
- # Returns an Array of methods matching +name+
-
- def list_methods_matching name
- found = []
-
- find_methods name do |store, klass, ancestor, types, method|
- if types == :instance or types == :both then
- methods = store.instance_methods[ancestor]
-
- if methods then
- matches = methods.grep(/^#{Regexp.escape method.to_s}/)
-
- matches = matches.map do |match|
- "#{klass}##{match}"
- end
-
- found.concat matches
- end
- end
-
- if types == :class or types == :both then
- methods = store.class_methods[ancestor]
-
- next unless methods
- matches = methods.grep(/^#{Regexp.escape method.to_s}/)
-
- matches = matches.map do |match|
- "#{klass}::#{match}"
- end
-
- found.concat matches
- end
- end
-
- found.uniq
- end
-
- ##
- # Loads RI data for method +name+ on +klass+ from +store+. +type+ and
- # +cache+ indicate if it is a class or instance method.
-
- def load_method store, cache, klass, type, name
- methods = store.public_send(cache)[klass]
-
- return unless methods
-
- method = methods.find do |method_name|
- method_name == name
- end
-
- return unless method
-
- store.load_method klass, "#{type}#{method}"
- rescue RDoc::Store::MissingFileError => e
- comment = RDoc::Comment.new("missing documentation at #{e.file}").parse
-
- method = RDoc::AnyMethod.new nil, name
- method.comment = comment
- method
- end
-
- ##
- # Returns an Array of RI data for methods matching +name+
-
- def load_methods_matching name
- found = []
-
- find_methods name do |store, klass, ancestor, types, method|
- methods = []
-
- methods << load_method(store, :class_methods, ancestor, '::', method) if
- [:class, :both].include? types
-
- methods << load_method(store, :instance_methods, ancestor, '#', method) if
- [:instance, :both].include? types
-
- found << [store, methods.compact]
- end
-
- found.reject do |path, methods| methods.empty? end
- end
-
- ##
- # Returns a filtered list of methods matching +name+
-
- def lookup_method name
- found = load_methods_matching name
-
- if found.empty?
- if check_did_you_mean
- methods = []
- _, _, method_name = parse_name name
- find_methods name do |store, klass, ancestor, types, method|
- methods.push(*store.class_methods[klass]) if [:class, :both].include? types
- methods.push(*store.instance_methods[klass]) if [:instance, :both].include? types
- end
- methods = methods.uniq
- suggestions = DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name)
- raise NotFoundError.new(name, suggestions)
- else
- raise NotFoundError, name
- end
- end
-
- filter_methods found, name
- end
-
- ##
- # Builds a RDoc::Markup::Document from +found+, +klasses+ and +includes+
-
- def method_document name, filtered
- out = RDoc::Markup::Document.new
-
- out << RDoc::Markup::Heading.new(1, name)
- out << RDoc::Markup::BlankLine.new
-
- filtered.each do |store, methods|
- methods.each do |method|
- render_method out, store, method, name
- end
- end
-
- out
- end
-
- ##
- # Returns the type of method (:both, :instance, :class) for +selector+
-
- def method_type selector
- case selector
- when '.', nil then :both
- when '#' then :instance
- else :class
- end
- end
-
- ##
- # Returns a regular expression for +name+ that will match an
- # RDoc::AnyMethod's name.
-
- def name_regexp name
- klass, type, name = parse_name name
-
- case type
- when '#', '::' then
- /^#{klass}#{type}#{Regexp.escape name}$/
- else
- /^#{klass}(#|::)#{Regexp.escape name}$/
- end
- end
-
- ##
- # Paginates output through a pager program.
-
- def page
- if pager = setup_pager then
- begin
- yield pager
- ensure
- pager.close
- end
- else
- yield $stdout
- end
- rescue Errno::EPIPE
- ensure
- @paging = false
- end
-
- ##
- # Are we using a pager?
-
- def paging?
- @paging
- end
-
- ##
- # Extracts the class, selector and method name parts from +name+ like
- # Foo::Bar#baz.
- #
- # NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
- # method
-
- def parse_name name
- parts = name.split(/(::?|#|\.)/)
-
- if parts.length == 1 then
- if parts.first =~ /^[a-z]|^([%&*+\/<>^`|~-]|\+@|-@|<<|<=>?|===?|=>|=~|>>|\[\]=?|~@)$/ then
- type = '.'
- meth = parts.pop
- else
- type = nil
- meth = nil
- end
- elsif parts.length == 2 or parts.last =~ /::|#|\./ then
- type = parts.pop
- meth = nil
- elsif parts[1] == ':' then
- klass = parts.shift
- type = parts.shift
- meth = parts.join
- elsif parts[-2] != '::' or parts.last !~ /^[A-Z]/ then
- meth = parts.pop
- type = parts.pop
- end
-
- klass ||= parts.join
-
- [klass, type, meth]
- end
-
- ##
- # Renders the +klass+ from +store+ to +out+. If the klass has no
- # documentable items the class is added to +also_in+ instead.
-
- def render_class out, store, klass, also_in # :nodoc:
- comment = klass.comment
- # TODO the store's cache should always return an empty Array
- class_methods = store.class_methods[klass.full_name] || []
- instance_methods = store.instance_methods[klass.full_name] || []
- attributes = store.attributes[klass.full_name] || []
-
- if comment.empty? and
- instance_methods.empty? and class_methods.empty? then
- also_in << store
- return
- end
-
- add_from out, store
-
- class_document_comment out, comment
-
- if class_methods or instance_methods or not klass.constants.empty? then
- out << RDoc::Markup::Rule.new(1)
- end
-
- class_document_constants out, klass
-
- add_method_list out, class_methods, 'Class methods'
- add_method_list out, instance_methods, 'Instance methods'
- add_method_list out, attributes, 'Attributes'
-
- add_method_documentation out, klass if @show_all
- end
-
- def render_method out, store, method, name # :nodoc:
- out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
-
- unless name =~ /^#{Regexp.escape method.parent_name}/ then
- out << RDoc::Markup::Heading.new(3, "Implementation from #{method.parent_name}")
- end
-
- out << RDoc::Markup::Rule.new(1)
-
- render_method_arguments out, method.arglists
- render_method_superclass out, method
- if method.is_alias_for
- al = method.is_alias_for
- alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}"
- render_method_comment out, method, alias_for
- else
- render_method_comment out, method
- end
- end
-
- def render_method_arguments out, arglists # :nodoc:
- return unless arglists
-
- arglists = arglists.chomp.split "\n"
- arglists = arglists.map { |line| line + "\n" }
- out << RDoc::Markup::Verbatim.new(*arglists)
- out << RDoc::Markup::Rule.new(1)
- end
-
- def render_method_comment out, method, alias_for = nil# :nodoc:
- if alias_for
- unless method.comment.nil? or method.comment.empty?
- out << RDoc::Markup::BlankLine.new
- out << method.comment
- end
- out << RDoc::Markup::BlankLine.new
- out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
- out << RDoc::Markup::BlankLine.new
- out << alias_for.comment
- out << RDoc::Markup::BlankLine.new
- else
- out << RDoc::Markup::BlankLine.new
- out << method.comment
- out << RDoc::Markup::BlankLine.new
- end
- end
-
- def render_method_superclass out, method # :nodoc:
- return unless
- method.respond_to?(:superclass_method) and method.superclass_method
-
- out << RDoc::Markup::BlankLine.new
- out << RDoc::Markup::Heading.new(4, "(Uses superclass method #{method.superclass_method})")
- out << RDoc::Markup::Rule.new(1)
- end
-
- ##
- # Looks up and displays ri data according to the options given.
-
- def run
- if @list_doc_dirs then
- puts @doc_dirs
- elsif @list then
- list_known_classes @names
- elsif @server then
- start_server
- elsif @interactive or @names.empty? then
- interactive
- else
- display_names @names
- end
- rescue NotFoundError => e
- abort e.message
- end
-
- ##
- # Sets up a pager program to pass output through. Tries the RI_PAGER and
- # PAGER environment variables followed by pager, less then more.
-
- def setup_pager
- return if @use_stdout
-
- pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
-
- require 'shellwords'
- pagers.compact.uniq.each do |pager|
- pager = Shellwords.split(pager)
- next if pager.empty?
-
- io = IO.popen(pager, 'w') rescue next
- next if $? and $?.pid == io.pid and $?.exited? # pager didn't work
-
- @paging = true
-
- return io
- end
-
- @use_stdout = true
-
- nil
- end
-
- ##
- # Starts a WEBrick server for ri.
-
- def start_server
- begin
- require 'webrick'
- rescue LoadError
- abort "webrick is not found. You may need to `gem install webrick` to install webrick."
- end
-
- server = WEBrick::HTTPServer.new :Port => @server
-
- extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact
-
- server.mount '/', RDoc::Servlet, nil, extra_doc_dirs
-
- trap 'INT' do server.shutdown end
- trap 'TERM' do server.shutdown end
-
- server.start
- end
-
-end
diff --git a/lib/rdoc/ri/formatter.rb b/lib/rdoc/ri/formatter.rb
deleted file mode 100644
index 832a101e6c..0000000000
--- a/lib/rdoc/ri/formatter.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-##
-# For RubyGems backwards compatibility
-
-module RDoc::RI::Formatter # :nodoc:
-end
diff --git a/lib/rdoc/ri/paths.rb b/lib/rdoc/ri/paths.rb
deleted file mode 100644
index 8e89b04e54..0000000000
--- a/lib/rdoc/ri/paths.rb
+++ /dev/null
@@ -1,171 +0,0 @@
-# frozen_string_literal: true
-require_relative '../rdoc'
-
-##
-# The directories where ri data lives. Paths can be enumerated via ::each, or
-# queried individually via ::system_dir, ::site_dir, ::home_dir and ::gem_dir.
-
-module RDoc::RI::Paths
-
- #:stopdoc:
- require 'rbconfig'
-
- version = RbConfig::CONFIG['ruby_version']
-
- BASE = File.join RbConfig::CONFIG['ridir'], version
-
- HOMEDIR = RDoc.home
- #:startdoc:
-
- ##
- # Iterates over each selected path yielding the directory and type.
- #
- # Yielded types:
- # :system:: Where Ruby's ri data is stored. Yielded when +system+ is
- # true
- # :site:: Where ri for installed libraries are stored. Yielded when
- # +site+ is true. Normally no ri data is stored here.
- # :home:: ~/.rdoc. Yielded when +home+ is true.
- # :gem:: ri data for an installed gem. Yielded when +gems+ is true.
- # :extra:: ri data directory from the command line. Yielded for each
- # entry in +extra_dirs+
-
- def self.each system = true, site = true, home = true, gems = :latest, *extra_dirs # :yields: directory, type
- return enum_for __method__, system, site, home, gems, *extra_dirs unless
- block_given?
-
- extra_dirs.each do |dir|
- yield dir, :extra
- end
-
- yield system_dir, :system if system
- yield site_dir, :site if site
- yield home_dir, :home if home and HOMEDIR
-
- gemdirs(gems).each do |dir|
- yield dir, :gem
- end if gems
-
- nil
- end
-
- ##
- # The ri directory for the gem with +gem_name+.
-
- def self.gem_dir name, version
- req = Gem::Requirement.new "= #{version}"
-
- spec = Gem::Specification.find_by_name name, req
-
- File.join spec.doc_dir, 'ri'
- end
-
- ##
- # The latest installed gems' ri directories. +filter+ can be :all or
- # :latest.
- #
- # A +filter+ :all includes all versions of gems and includes gems without
- # ri documentation.
-
- def self.gemdirs filter = :latest
- ri_paths = {}
-
- all = Gem::Specification.map do |spec|
- [File.join(spec.doc_dir, 'ri'), spec.name, spec.version]
- end
-
- if filter == :all then
- gemdirs = []
-
- all.group_by do |_, name, _|
- name
- end.sort_by do |group, _|
- group
- end.map do |group, items|
- items.sort_by do |_, _, version|
- version
- end.reverse_each do |dir,|
- gemdirs << dir
- end
- end
-
- return gemdirs
- end
-
- all.each do |dir, name, ver|
- next unless File.exist? dir
-
- if ri_paths[name].nil? or ver > ri_paths[name].first then
- ri_paths[name] = [ver, name, dir]
- end
- end
-
- ri_paths.sort_by { |_, (_, name, _)| name }.map { |k, v| v.last }
- rescue LoadError
- []
- end
-
- ##
- # The location of the rdoc data in the user's home directory.
- #
- # Like ::system, ri data in the user's home directory is rare and predates
- # libraries distributed via RubyGems. ri data is rarely generated into this
- # directory.
-
- def self.home_dir
- HOMEDIR
- end
-
- ##
- # Returns existing directories from the selected documentation directories
- # as an Array.
- #
- # See also ::each
-
- def self.path(system = true, site = true, home = true, gems = :latest, *extra_dirs)
- path = raw_path system, site, home, gems, *extra_dirs
-
- path.select { |directory| File.directory? directory }
- end
-
- ##
- # Returns selected documentation directories including nonexistent
- # directories.
- #
- # See also ::each
-
- def self.raw_path(system, site, home, gems, *extra_dirs)
- path = []
-
- each(system, site, home, gems, *extra_dirs) do |dir, type|
- path << dir
- end
-
- path.compact
- end
-
- ##
- # The location of ri data installed into the site dir.
- #
- # Historically this was available for documentation installed by Ruby
- # libraries predating RubyGems. It is unlikely to contain any content for
- # modern Ruby installations.
-
- def self.site_dir
- File.join BASE, 'site'
- end
-
- ##
- # The location of the built-in ri data.
- #
- # This data is built automatically when `make` is run when Ruby is
- # installed. If you did not install Ruby by hand you may need to install
- # the documentation yourself. Please consult the documentation for your
- # package manager or Ruby installer for details. You can also use the
- # rdoc-data gem to install system ri data for common versions of Ruby.
-
- def self.system_dir
- File.join BASE, 'system'
- end
-
-end
diff --git a/lib/rdoc/ri/store.rb b/lib/rdoc/ri/store.rb
deleted file mode 100644
index 9f4b03734a..0000000000
--- a/lib/rdoc/ri/store.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-module RDoc::RI
-
- Store = RDoc::Store # :nodoc:
-
-end
-
diff --git a/lib/rdoc/ri/task.rb b/lib/rdoc/ri/task.rb
deleted file mode 100644
index 1122ea3775..0000000000
--- a/lib/rdoc/ri/task.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: true
-begin
- gem 'rdoc'
-rescue Gem::LoadError
-end unless defined?(RDoc)
-
-require_relative '../task'
-
-##
-# RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
-#
-# It contains the following tasks:
-#
-# [ri]
-# Build ri data
-#
-# [clobber_ri]
-# Delete ri data files. This target is automatically added to the main
-# clobber target.
-#
-# [reri]
-# Rebuild the ri data from scratch even if they are not out of date.
-#
-# Simple example:
-#
-# require 'rdoc/ri/task'
-#
-# RDoc::RI::Task.new do |ri|
-# ri.main = 'README.rdoc'
-# ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
-# end
-#
-# For further configuration details see RDoc::Task.
-
-class RDoc::RI::Task < RDoc::Task
-
- DEFAULT_NAMES = { # :nodoc:
- :clobber_rdoc => :clobber_ri,
- :rdoc => :ri,
- :rerdoc => :reri,
- }
-
- ##
- # Create an ri task with the given name. See RDoc::Task for documentation on
- # setting names.
-
- def initialize name = DEFAULT_NAMES # :yield: self
- super
- end
-
- def clobber_task_description # :nodoc:
- "Remove RI data files"
- end
-
- ##
- # Sets default task values
-
- def defaults
- super
-
- @rdoc_dir = '.rdoc'
- end
-
- def rdoc_task_description # :nodoc:
- 'Build RI data files'
- end
-
- def rerdoc_task_description # :nodoc:
- 'Rebuild RI data files'
- end
-end
diff --git a/lib/rdoc/rubygems_hook.rb b/lib/rdoc/rubygems_hook.rb
deleted file mode 100644
index 3160072e53..0000000000
--- a/lib/rdoc/rubygems_hook.rb
+++ /dev/null
@@ -1,248 +0,0 @@
-# frozen_string_literal: true
-require 'rubygems/user_interaction'
-require 'fileutils'
-require_relative '../rdoc'
-
-##
-# Gem::RDoc provides methods to generate RDoc and ri data for installed gems
-# upon gem installation.
-#
-# This file is automatically required by RubyGems 1.9 and newer.
-
-class RDoc::RubygemsHook
-
- include Gem::UserInteraction
- extend Gem::UserInteraction
-
- @rdoc_version = nil
- @specs = []
-
- ##
- # Force installation of documentation?
-
- attr_accessor :force
-
- ##
- # Generate rdoc?
-
- attr_accessor :generate_rdoc
-
- ##
- # Generate ri data?
-
- attr_accessor :generate_ri
-
- class << self
-
- ##
- # Loaded version of RDoc. Set by ::load_rdoc
-
- attr_reader :rdoc_version
-
- end
-
- ##
- # Post installs hook that generates documentation for each specification in
- # +specs+
-
- def self.generation_hook installer, specs
- start = Time.now
- types = installer.document
-
- generate_rdoc = types.include? 'rdoc'
- generate_ri = types.include? 'ri'
-
- specs.each do |spec|
- new(spec, generate_rdoc, generate_ri).generate
- end
-
- return unless generate_rdoc or generate_ri
-
- duration = (Time.now - start).to_i
- names = specs.map(&:name).join ', '
-
- say "Done installing documentation for #{names} after #{duration} seconds"
- end
-
- ##
- # Loads the RDoc generator
-
- def self.load_rdoc
- return if @rdoc_version
-
- require_relative 'rdoc'
-
- @rdoc_version = Gem::Version.new ::RDoc::VERSION
- end
-
- ##
- # Creates a new documentation generator for +spec+. RDoc and ri data
- # generation can be enabled or disabled through +generate_rdoc+ and
- # +generate_ri+ respectively.
- #
- # Only +generate_ri+ is enabled by default.
-
- def initialize spec, generate_rdoc = false, generate_ri = true
- @doc_dir = spec.doc_dir
- @force = false
- @rdoc = nil
- @spec = spec
-
- @generate_rdoc = generate_rdoc
- @generate_ri = generate_ri
-
- @rdoc_dir = spec.doc_dir 'rdoc'
- @ri_dir = spec.doc_dir 'ri'
- end
-
- ##
- # Removes legacy rdoc arguments from +args+
- #--
- # TODO move to RDoc::Options
-
- def delete_legacy_args args
- args.delete '--inline-source'
- args.delete '--promiscuous'
- args.delete '-p'
- args.delete '--one-file'
- end
-
- ##
- # Generates documentation using the named +generator+ ("darkfish" or "ri")
- # and following the given +options+.
- #
- # Documentation will be generated into +destination+
-
- def document generator, options, destination
- generator_name = generator
-
- options = options.dup
- options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
- options.setup_generator generator
- options.op_dir = destination
- Dir.chdir @spec.full_gem_path do
- options.finish
- end
-
- generator = options.generator.new @rdoc.store, options
-
- @rdoc.options = options
- @rdoc.generator = generator
-
- say "Installing #{generator_name} documentation for #{@spec.full_name}"
-
- FileUtils.mkdir_p options.op_dir
-
- Dir.chdir options.op_dir do
- begin
- @rdoc.class.current = @rdoc
- @rdoc.generator.generate
- ensure
- @rdoc.class.current = nil
- end
- end
- end
-
- ##
- # Generates RDoc and ri data
-
- def generate
- return if @spec.default_gem?
- return unless @generate_ri or @generate_rdoc
-
- setup
-
- options = nil
-
- args = @spec.rdoc_options
- args.concat @spec.source_paths
- args.concat @spec.extra_rdoc_files
-
- case config_args = Gem.configuration[:rdoc]
- when String then
- args = args.concat config_args.split(' ')
- when Array then
- args = args.concat config_args
- end
-
- delete_legacy_args args
-
- Dir.chdir @spec.full_gem_path do
- options = ::RDoc::Options.new
- options.default_title = "#{@spec.full_name} Documentation"
- options.parse args
- end
-
- options.quiet = !Gem.configuration.really_verbose
-
- @rdoc = new_rdoc
- @rdoc.options = options
-
- store = RDoc::Store.new
- store.encoding = options.encoding
- store.dry_run = options.dry_run
- store.main = options.main_page
- store.title = options.title
-
- @rdoc.store = store
-
- say "Parsing documentation for #{@spec.full_name}"
-
- Dir.chdir @spec.full_gem_path do
- @rdoc.parse_files options.files
- end
-
- document 'ri', options, @ri_dir if
- @generate_ri and (@force or not File.exist? @ri_dir)
-
- document 'darkfish', options, @rdoc_dir if
- @generate_rdoc and (@force or not File.exist? @rdoc_dir)
- end
-
- ##
- # #new_rdoc creates a new RDoc instance. This method is provided only to
- # make testing easier.
-
- def new_rdoc # :nodoc:
- ::RDoc::RDoc.new
- end
-
- ##
- # Is rdoc documentation installed?
-
- def rdoc_installed?
- File.exist? @rdoc_dir
- end
-
- ##
- # Removes generated RDoc and ri data
-
- def remove
- base_dir = @spec.base_dir
-
- raise Gem::FilePermissionError, base_dir unless File.writable? base_dir
-
- FileUtils.rm_rf @rdoc_dir
- FileUtils.rm_rf @ri_dir
- end
-
- ##
- # Is ri data installed?
-
- def ri_installed?
- File.exist? @ri_dir
- end
-
- ##
- # Prepares the spec for documentation generation
-
- def setup
- self.class.load_rdoc
-
- raise Gem::FilePermissionError, @doc_dir if
- File.exist?(@doc_dir) and not File.writable?(@doc_dir)
-
- FileUtils.mkdir_p @doc_dir unless File.exist? @doc_dir
- end
-
-end
diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb
deleted file mode 100644
index d05368766a..0000000000
--- a/lib/rdoc/servlet.rb
+++ /dev/null
@@ -1,451 +0,0 @@
-# frozen_string_literal: true
-require_relative '../rdoc'
-require 'erb'
-require 'time'
-require 'json'
-
-begin
- require 'webrick'
-rescue LoadError
- abort "webrick is not found. You may need to `gem install webrick` to install webrick."
-end
-
-##
-# This is a WEBrick servlet that allows you to browse ri documentation.
-#
-# You can show documentation through either `ri --server` or, with RubyGems
-# 2.0 or newer, `gem server`. For ri, the server runs on port 8214 by
-# default. For RubyGems the server runs on port 8808 by default.
-#
-# You can use this servlet in your own project by mounting it on a WEBrick
-# server:
-#
-# require 'webrick'
-#
-# server = WEBrick::HTTPServer.new Port: 8000
-#
-# server.mount '/', RDoc::Servlet
-#
-# If you want to mount the servlet some other place than the root, provide the
-# base path when mounting:
-#
-# server.mount '/rdoc', RDoc::Servlet, '/rdoc'
-
-class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
-
- @server_stores = Hash.new { |hash, server| hash[server] = {} }
- @cache = Hash.new { |hash, store| hash[store] = {} }
-
- ##
- # Maps an asset type to its path on the filesystem
-
- attr_reader :asset_dirs
-
- ##
- # An RDoc::Options instance used for rendering options
-
- attr_reader :options
-
- ##
- # Creates an instance of this servlet that shares cached data between
- # requests.
-
- def self.get_instance server, *options # :nodoc:
- stores = @server_stores[server]
-
- new server, stores, @cache, *options
- end
-
- ##
- # Creates a new WEBrick servlet.
- #
- # Use +mount_path+ when mounting the servlet somewhere other than /.
- #
- # Use +extra_doc_dirs+ for additional documentation directories.
- #
- # +server+ is provided automatically by WEBrick when mounting. +stores+ and
- # +cache+ are provided automatically by the servlet.
-
- def initialize server, stores, cache, mount_path = nil, extra_doc_dirs = []
- super server
-
- @cache = cache
- @mount_path = mount_path
- @extra_doc_dirs = extra_doc_dirs
- @stores = stores
-
- @options = RDoc::Options.new
- @options.op_dir = '.'
-
- darkfish_dir = nil
-
- # HACK dup
- $LOAD_PATH.each do |path|
- darkfish_dir = File.join path, 'rdoc/generator/template/darkfish/'
- next unless File.directory? darkfish_dir
- @options.template_dir = darkfish_dir
- break
- end
-
- @asset_dirs = {
- :darkfish => darkfish_dir,
- :json_index =>
- File.expand_path('../generator/template/json_index/', __FILE__),
- }
- end
-
- ##
- # Serves the asset at the path in +req+ for +generator_name+ via +res+.
-
- def asset generator_name, req, res
- asset_dir = @asset_dirs[generator_name]
-
- asset_path = File.join asset_dir, req.path
-
- if_modified_since req, res, asset_path
-
- res.body = File.read asset_path
-
- res.content_type = case req.path
- when /\.css\z/ then 'text/css'
- when /\.js\z/ then 'application/javascript'
- else 'application/octet-stream'
- end
- end
-
- ##
- # GET request entry point. Fills in +res+ for the path, etc. in +req+.
-
- def do_GET req, res
- req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
-
- case req.path
- when '/' then
- root req, res
- when '/js/darkfish.js', '/js/jquery.js', '/js/search.js',
- %r%^/css/%, %r%^/images/%, %r%^/fonts/% then
- asset :darkfish, req, res
- when '/js/navigation.js', '/js/searcher.js' then
- asset :json_index, req, res
- when '/js/search_index.js' then
- root_search req, res
- else
- show_documentation req, res
- end
- rescue WEBrick::HTTPStatus::NotFound => e
- generator = generator_for RDoc::Store.new
-
- not_found generator, req, res, e.message
- rescue WEBrick::HTTPStatus::Status
- raise
- rescue => e
- error e, req, res
- end
-
- ##
- # Fills in +res+ with the class, module or page for +req+ from +store+.
- #
- # +path+ is relative to the mount_path and is used to determine the class,
- # module or page name (/RDoc/Servlet.html becomes RDoc::Servlet).
- # +generator+ is used to create the page.
-
- def documentation_page store, generator, path, req, res
- text_name = path.chomp '.html'
- name = text_name.gsub '/', '::'
-
- if klass = store.find_class_or_module(name) then
- res.body = generator.generate_class klass
- elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then
- res.body = generator.generate_page page
- elsif page = store.find_text_page(text_name.sub(/_([^_]*)\z/, '.\1')) then
- res.body = generator.generate_page page
- else
- not_found generator, req, res
- end
- end
-
- ##
- # Creates the JSON search index on +res+ for the given +store+. +generator+
- # must respond to \#json_index to build. +req+ is ignored.
-
- def documentation_search store, generator, req, res
- json_index = @cache[store].fetch :json_index do
- @cache[store][:json_index] =
- JSON.dump generator.json_index.build_index
- end
-
- res.content_type = 'application/javascript'
- res.body = "var search_data = #{json_index}"
- end
-
- ##
- # Returns the RDoc::Store and path relative to +mount_path+ for
- # documentation at +path+.
-
- def documentation_source path
- _, source_name, path = path.split '/', 3
-
- store = @stores[source_name]
- return store, path if store
-
- store = store_for source_name
-
- store.load_all
-
- @stores[source_name] = store
-
- return store, path
- end
-
- ##
- # Generates an error page for the +exception+ while handling +req+ on +res+.
-
- def error exception, req, res
- backtrace = exception.backtrace.join "\n"
-
- res.content_type = 'text/html'
- res.status = 500
- res.body = <<-BODY
-<!DOCTYPE html>
-<html>
-<head>
-<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
-
-<title>Error - #{ERB::Util.html_escape exception.class}</title>
-
-<link type="text/css" media="screen" href="#{@mount_path}/css/rdoc.css" rel="stylesheet">
-</head>
-<body>
-<h1>Error</h1>
-
-<p>While processing <code>#{ERB::Util.html_escape req.request_uri}</code> the
-RDoc (#{ERB::Util.html_escape RDoc::VERSION}) server has encountered a
-<code>#{ERB::Util.html_escape exception.class}</code>
-exception:
-
-<pre>#{ERB::Util.html_escape exception.message}</pre>
-
-<p>Please report this to the
-<a href="https://github.com/ruby/rdoc/issues">RDoc issues tracker</a>. Please
-include the RDoc version, the URI above and exception class, message and
-backtrace. If you're viewing a gem's documentation, include the gem name and
-version. If you're viewing Ruby's documentation, include the version of ruby.
-
-<p>Backtrace:
-
-<pre>#{ERB::Util.html_escape backtrace}</pre>
-
-</body>
-</html>
- BODY
- end
-
- ##
- # Instantiates a Darkfish generator for +store+
-
- def generator_for store
- generator = RDoc::Generator::Darkfish.new store, @options
- generator.file_output = false
- generator.asset_rel_path = '..'
-
- rdoc = RDoc::RDoc.new
- rdoc.store = store
- rdoc.generator = generator
- rdoc.options = @options
-
- @options.main_page = store.main
- @options.title = store.title
-
- generator
- end
-
- ##
- # Handles the If-Modified-Since HTTP header on +req+ for +path+. If the
- # file has not been modified a Not Modified response is returned. If the
- # file has been modified a Last-Modified header is added to +res+.
-
- def if_modified_since req, res, path = nil
- last_modified = File.stat(path).mtime if path
-
- res['last-modified'] = last_modified.httpdate
-
- return unless ims = req['if-modified-since']
-
- ims = Time.parse ims
-
- unless ims < last_modified then
- res.body = ''
- raise WEBrick::HTTPStatus::NotModified
- end
- end
-
- ##
- # Returns an Array of installed documentation.
- #
- # Each entry contains the documentation name (gem name, 'Ruby
- # Documentation', etc.), the path relative to the mount point, whether the
- # documentation exists, the type of documentation (See RDoc::RI::Paths#each)
- # and the filesystem to the RDoc::Store for the documentation.
-
- def installed_docs
- extra_counter = 0
- ri_paths.map do |path, type|
- store = RDoc::Store.new path, type
- exists = File.exist? store.cache_path
-
- case type
- when :gem then
- gem_path = path[%r%/([^/]*)/ri$%, 1]
- [gem_path, "#{gem_path}/", exists, type, path]
- when :system then
- ['Ruby Documentation', 'ruby/', exists, type, path]
- when :site then
- ['Site Documentation', 'site/', exists, type, path]
- when :home then
- ['Home Documentation', 'home/', exists, type, path]
- when :extra then
- extra_counter += 1
- store.load_cache if exists
- title = store.title || "Extra Documentation"
- [title, "extra-#{extra_counter}/", exists, type, path]
- end
- end
- end
-
- ##
- # Returns a 404 page built by +generator+ for +req+ on +res+.
-
- def not_found generator, req, res, message = nil
- message ||= "The page <kbd>#{ERB::Util.h req.path}</kbd> was not found"
- res.body = generator.generate_servlet_not_found message
- res.status = 404
- end
-
- ##
- # Enumerates the ri paths. See RDoc::RI::Paths#each
-
- def ri_paths &block
- RDoc::RI::Paths.each true, true, true, :all, *@extra_doc_dirs, &block #TODO: pass extra_dirs
- end
-
- ##
- # Generates the root page on +res+. +req+ is ignored.
-
- def root req, res
- generator = RDoc::Generator::Darkfish.new nil, @options
-
- res.body = generator.generate_servlet_root installed_docs
-
- res.content_type = 'text/html'
- end
-
- ##
- # Generates a search index for the root page on +res+. +req+ is ignored.
-
- def root_search req, res
- search_index = []
- info = []
-
- installed_docs.map do |name, href, exists, type, path|
- next unless exists
-
- search_index << name
-
- case type
- when :gem
- gemspec = path.gsub(%r%/doc/([^/]*?)/ri$%,
- '/specifications/\1.gemspec')
-
- spec = Gem::Specification.load gemspec
-
- path = spec.full_name
- comment = spec.summary
- when :system then
- path = 'ruby'
- comment = 'Documentation for the Ruby standard library'
- when :site then
- path = 'site'
- comment = 'Documentation for non-gem libraries'
- when :home then
- path = 'home'
- comment = 'Documentation from your home directory'
- when :extra
- comment = name
- end
-
- info << [name, '', path, '', comment]
- end
-
- index = {
- :index => {
- :searchIndex => search_index,
- :longSearchIndex => search_index,
- :info => info,
- }
- }
-
- res.body = "var search_data = #{JSON.dump index};"
- res.content_type = 'application/javascript'
- end
-
- ##
- # Displays documentation for +req+ on +res+, whether that be HTML or some
- # asset.
-
- def show_documentation req, res
- store, path = documentation_source req.path
-
- if_modified_since req, res, store.cache_path
-
- generator = generator_for store
-
- case path
- when nil, '', 'index.html' then
- res.body = generator.generate_index
- when 'table_of_contents.html' then
- res.body = generator.generate_table_of_contents
- when 'js/search_index.js' then
- documentation_search store, generator, req, res
- else
- documentation_page store, generator, path, req, res
- end
- ensure
- res.content_type ||= 'text/html'
- end
-
- ##
- # Returns an RDoc::Store for the given +source_name+ ('ruby' or a gem name).
-
- def store_for source_name
- case source_name
- when 'home' then
- RDoc::Store.new RDoc::RI::Paths.home_dir, :home
- when 'ruby' then
- RDoc::Store.new RDoc::RI::Paths.system_dir, :system
- when 'site' then
- RDoc::Store.new RDoc::RI::Paths.site_dir, :site
- when /\Aextra-(\d+)\z/ then
- index = $1.to_i - 1
- ri_dir = installed_docs[index][4]
- RDoc::Store.new ri_dir, :extra
- else
- ri_dir, type = ri_paths.find do |dir, dir_type|
- next unless dir_type == :gem
-
- source_name == dir[%r%/([^/]*)/ri$%, 1]
- end
-
- raise WEBrick::HTTPStatus::NotFound,
- "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
-
- store = RDoc::Store.new ri_dir, type
-
- return store if File.exist? store.cache_path
-
- raise WEBrick::HTTPStatus::NotFound,
- "Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
-
- end
- end
-
-end
diff --git a/lib/rdoc/single_class.rb b/lib/rdoc/single_class.rb
deleted file mode 100644
index 860f06a6e5..0000000000
--- a/lib/rdoc/single_class.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-##
-# A singleton class
-
-class RDoc::SingleClass < RDoc::ClassModule
-
- ##
- # Adds the superclass to the included modules.
-
- def ancestors
- superclass ? super + [superclass] : super
- end
-
- def aref_prefix # :nodoc:
- 'sclass'
- end
-
- ##
- # The definition of this singleton class, <tt>class << MyClassName</tt>
-
- def definition
- "class << #{full_name}"
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[class << #{full_name}", "]" do
- next
- end
- end
-end
-
diff --git a/lib/rdoc/stats.rb b/lib/rdoc/stats.rb
deleted file mode 100644
index 4817c9c729..0000000000
--- a/lib/rdoc/stats.rb
+++ /dev/null
@@ -1,461 +0,0 @@
-# frozen_string_literal: true
-##
-# RDoc statistics collector which prints a summary and report of a project's
-# documentation totals.
-
-class RDoc::Stats
-
- include RDoc::Text
-
- ##
- # Output level for the coverage report
-
- attr_reader :coverage_level
-
- ##
- # Count of files parsed during parsing
-
- attr_reader :files_so_far
-
- ##
- # Total number of files found
-
- attr_reader :num_files
-
- ##
- # Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1
- # which will create an RDoc::Stats::Normal outputter.
-
- def initialize store, num_files, verbosity = 1
- @num_files = num_files
- @store = store
-
- @coverage_level = 0
- @doc_items = nil
- @files_so_far = 0
- @fully_documented = false
- @num_params = 0
- @percent_doc = nil
- @start = Time.now
- @undoc_params = 0
-
- @display = case verbosity
- when 0 then Quiet.new num_files
- when 1 then Normal.new num_files
- else Verbose.new num_files
- end
- end
-
- ##
- # Records the parsing of an alias +as+.
-
- def add_alias as
- @display.print_alias as
- end
-
- ##
- # Records the parsing of an attribute +attribute+
-
- def add_attribute attribute
- @display.print_attribute attribute
- end
-
- ##
- # Records the parsing of a class +klass+
-
- def add_class klass
- @display.print_class klass
- end
-
- ##
- # Records the parsing of +constant+
-
- def add_constant constant
- @display.print_constant constant
- end
-
- ##
- # Records the parsing of +file+
-
- def add_file(file)
- @files_so_far += 1
- @display.print_file @files_so_far, file
- end
-
- ##
- # Records the parsing of +method+
-
- def add_method(method)
- @display.print_method method
- end
-
- ##
- # Records the parsing of a module +mod+
-
- def add_module(mod)
- @display.print_module mod
- end
-
- ##
- # Call this to mark the beginning of parsing for display purposes
-
- def begin_adding
- @display.begin_adding
- end
-
- ##
- # Calculates documentation totals and percentages for classes, modules,
- # constants, attributes and methods.
-
- def calculate
- return if @doc_items
-
- ucm = @store.unique_classes_and_modules
-
- classes = @store.unique_classes.reject { |cm| cm.full_name == 'Object' }
-
- constants = []
- ucm.each { |cm| constants.concat cm.constants }
-
- methods = []
- ucm.each { |cm| methods.concat cm.method_list }
-
- attributes = []
- ucm.each { |cm| attributes.concat cm.attributes }
-
- @num_attributes, @undoc_attributes = doc_stats attributes
- @num_classes, @undoc_classes = doc_stats classes
- @num_constants, @undoc_constants = doc_stats constants
- @num_methods, @undoc_methods = doc_stats methods
- @num_modules, @undoc_modules = doc_stats @store.unique_modules
-
- @num_items =
- @num_attributes +
- @num_classes +
- @num_constants +
- @num_methods +
- @num_modules +
- @num_params
-
- @undoc_items =
- @undoc_attributes +
- @undoc_classes +
- @undoc_constants +
- @undoc_methods +
- @undoc_modules +
- @undoc_params
-
- @doc_items = @num_items - @undoc_items
- end
-
- ##
- # Sets coverage report level. Accepted values are:
- #
- # false or nil:: No report
- # 0:: Classes, modules, constants, attributes, methods
- # 1:: Level 0 + method parameters
-
- def coverage_level= level
- level = -1 unless level
-
- @coverage_level = level
- end
-
- ##
- # Returns the length and number of undocumented items in +collection+.
-
- def doc_stats collection
- visible = collection.select { |item| item.display? }
- [visible.length, visible.count { |item| not item.documented? }]
- end
-
- ##
- # Call this to mark the end of parsing for display purposes
-
- def done_adding
- @display.done_adding
- end
-
- ##
- # The documentation status of this project. +true+ when 100%, +false+ when
- # less than 100% and +nil+ when unknown.
- #
- # Set by calling #calculate
-
- def fully_documented?
- @fully_documented
- end
-
- ##
- # A report that says you did a great job!
-
- def great_job
- report = RDoc::Markup::Document.new
-
- report << RDoc::Markup::Paragraph.new('100% documentation!')
- report << RDoc::Markup::Paragraph.new('Great Job!')
-
- report
- end
-
- ##
- # Calculates the percentage of items documented.
-
- def percent_doc
- return @percent_doc if @percent_doc
-
- @fully_documented = (@num_items - @doc_items) == 0
-
- @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
- @percent_doc ||= 0
-
- @percent_doc
- end
-
- ##
- # Returns a report on which items are not documented
-
- def report
- if @coverage_level > 0 then
- extend RDoc::Text
- end
-
- if @coverage_level.zero? then
- calculate
-
- return great_job if @num_items == @doc_items
- end
-
- ucm = @store.unique_classes_and_modules
-
- report = RDoc::Markup::Document.new
- report << RDoc::Markup::Paragraph.new('The following items are not documented:')
- report << RDoc::Markup::BlankLine.new
-
- ucm.sort.each do |cm|
- body = report_class_module(cm) {
- [
- report_constants(cm),
- report_attributes(cm),
- report_methods(cm),
- ].compact
- }
-
- report << body if body
- end
-
- if @coverage_level > 0 then
- calculate
-
- return great_job if @num_items == @doc_items
- end
-
- report
- end
-
- ##
- # Returns a report on undocumented attributes in ClassModule +cm+
-
- def report_attributes cm
- return if cm.attributes.empty?
-
- report = []
-
- cm.each_attribute do |attr|
- next if attr.documented?
- line = attr.line ? ":#{attr.line}" : nil
- report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n"
- report << "\n"
- end
-
- report
- end
-
- ##
- # Returns a report on undocumented items in ClassModule +cm+
-
- def report_class_module cm
- return if cm.fully_documented? and @coverage_level.zero?
- return unless cm.display?
-
- report = RDoc::Markup::Document.new
-
- if cm.in_files.empty? then
- report << RDoc::Markup::Paragraph.new("#{cm.definition} is referenced but empty.")
- report << RDoc::Markup::Paragraph.new("It probably came from another project. I'm sorry I'm holding it against you.")
-
- return report
- elsif cm.documented? then
- documented = true
- klass = RDoc::Markup::Verbatim.new("#{cm.definition} # is documented\n")
- else
- report << RDoc::Markup::Paragraph.new('In files:')
-
- list = RDoc::Markup::List.new :BULLET
-
- cm.in_files.each do |file|
- para = RDoc::Markup::Paragraph.new file.full_name
- list << RDoc::Markup::ListItem.new(nil, para)
- end
-
- report << list
- report << RDoc::Markup::BlankLine.new
-
- klass = RDoc::Markup::Verbatim.new("#{cm.definition}\n")
- end
-
- klass << "\n"
-
- body = yield.flatten # HACK remove #flatten
-
- if body.empty? then
- return if documented
-
- klass.parts.pop
- else
- klass.parts.concat body
- end
-
- klass << "end\n"
-
- report << klass
-
- report
- end
-
- ##
- # Returns a report on undocumented constants in ClassModule +cm+
-
- def report_constants cm
- return if cm.constants.empty?
-
- report = []
-
- cm.each_constant do |constant|
- # TODO constant aliases are listed in the summary but not reported
- # figure out what to do here
- next if constant.documented? || constant.is_alias_for
-
- line = constant.line ? ":#{constant.line}" : line
- report << " # in file #{constant.file.full_name}#{line}\n"
- report << " #{constant.name} = nil\n"
- report << "\n"
- end
-
- report
- end
-
- ##
- # Returns a report on undocumented methods in ClassModule +cm+
-
- def report_methods cm
- return if cm.method_list.empty?
-
- report = []
-
- cm.each_method do |method|
- next if method.documented? and @coverage_level.zero?
-
- if @coverage_level > 0 then
- params, undoc = undoc_params method
-
- @num_params += params
-
- unless undoc.empty? then
- @undoc_params += undoc.length
-
- undoc = undoc.map do |param| "+#{param}+" end
- param_report = " # #{undoc.join ', '} is not documented\n"
- end
- end
-
- next if method.documented? and not param_report
-
- line = method.line ? ":#{method.line}" : nil
- scope = method.singleton ? 'self.' : nil
-
- report << " # in file #{method.file.full_name}#{line}\n"
- report << param_report if param_report
- report << " def #{scope}#{method.name}#{method.params}; end\n"
- report << "\n"
- end
-
- report
- end
-
- ##
- # Returns a summary of the collected statistics.
-
- def summary
- calculate
-
- num_width = [@num_files, @num_items].max.to_s.length
- undoc_width = [
- @undoc_attributes,
- @undoc_classes,
- @undoc_constants,
- @undoc_items,
- @undoc_methods,
- @undoc_modules,
- @undoc_params,
- ].max.to_s.length
-
- report = RDoc::Markup::Verbatim.new
-
- report << "Files: %*d\n" % [num_width, @num_files]
-
- report << "\n"
-
- report << "Classes: %*d (%*d undocumented)\n" % [
- num_width, @num_classes, undoc_width, @undoc_classes]
- report << "Modules: %*d (%*d undocumented)\n" % [
- num_width, @num_modules, undoc_width, @undoc_modules]
- report << "Constants: %*d (%*d undocumented)\n" % [
- num_width, @num_constants, undoc_width, @undoc_constants]
- report << "Attributes: %*d (%*d undocumented)\n" % [
- num_width, @num_attributes, undoc_width, @undoc_attributes]
- report << "Methods: %*d (%*d undocumented)\n" % [
- num_width, @num_methods, undoc_width, @undoc_methods]
- report << "Parameters: %*d (%*d undocumented)\n" % [
- num_width, @num_params, undoc_width, @undoc_params] if
- @coverage_level > 0
-
- report << "\n"
-
- report << "Total: %*d (%*d undocumented)\n" % [
- num_width, @num_items, undoc_width, @undoc_items]
-
- report << "%6.2f%% documented\n" % percent_doc
- report << "\n"
- report << "Elapsed: %0.1fs\n" % (Time.now - @start)
-
- RDoc::Markup::Document.new report
- end
-
- ##
- # Determines which parameters in +method+ were not documented. Returns a
- # total parameter count and an Array of undocumented methods.
-
- def undoc_params method
- @formatter ||= RDoc::Markup::ToTtOnly.new
-
- params = method.param_list
-
- params = params.map { |param| param.gsub(/^\*\*?/, '') }
-
- return 0, [] if params.empty?
-
- document = parse method.comment
-
- tts = document.accept @formatter
-
- undoc = params - tts
-
- [params.length, undoc]
- end
-
- autoload :Quiet, "#{__dir__}/stats/quiet"
- autoload :Normal, "#{__dir__}/stats/normal"
- autoload :Verbose, "#{__dir__}/stats/verbose"
-
-end
diff --git a/lib/rdoc/stats/normal.rb b/lib/rdoc/stats/normal.rb
deleted file mode 100644
index 0a22f0582b..0000000000
--- a/lib/rdoc/stats/normal.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-begin
- require 'io/console/size'
-rescue LoadError
- # for JRuby
- require 'io/console'
-end
-
-##
-# Stats printer that prints just the files being documented with a progress
-# bar
-
-class RDoc::Stats::Normal < RDoc::Stats::Quiet
-
- def begin_adding # :nodoc:
- puts "Parsing sources..."
- @last_width = 0
- end
-
- ##
- # Prints a file with a progress bar
-
- def print_file files_so_far, filename
- progress_bar = sprintf("%3d%% [%2d/%2d] ",
- 100 * files_so_far / @num_files,
- files_so_far,
- @num_files)
-
- if $stdout.tty?
- # Print a progress bar, but make sure it fits on a single line. Filename
- # will be truncated if necessary.
- size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
- terminal_width = size[1].to_i.nonzero? || 80
- max_filename_size = (terminal_width - progress_bar.size) - 1
-
- if filename.size > max_filename_size then
- # Turn "some_long_filename.rb" to "...ong_filename.rb"
- filename = filename[(filename.size - max_filename_size) .. -1]
- filename[0..2] = "..."
- end
-
- # Clean the line with whitespaces so that leftover output from the
- # previous line doesn't show up.
- $stdout.print("\r\e[K") if @last_width && @last_width > 0
- @last_width = progress_bar.size + filename.size
- term = "\r"
- else
- term = "\n"
- end
- $stdout.print(progress_bar, filename, term)
- $stdout.flush
- end
-
- def done_adding # :nodoc:
- puts
- end
-
-end
diff --git a/lib/rdoc/stats/quiet.rb b/lib/rdoc/stats/quiet.rb
deleted file mode 100644
index bc4161b2d4..0000000000
--- a/lib/rdoc/stats/quiet.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-##
-# Stats printer that prints nothing
-
-class RDoc::Stats::Quiet
-
- ##
- # Creates a new Quiet that will print nothing
-
- def initialize num_files
- @num_files = num_files
- end
-
- ##
- # Prints a message at the beginning of parsing
-
- def begin_adding(*) end
-
- ##
- # Prints when an alias is added
-
- def print_alias(*) end
-
- ##
- # Prints when an attribute is added
-
- def print_attribute(*) end
-
- ##
- # Prints when a class is added
-
- def print_class(*) end
-
- ##
- # Prints when a constant is added
-
- def print_constant(*) end
-
- ##
- # Prints when a file is added
-
- def print_file(*) end
-
- ##
- # Prints when a method is added
-
- def print_method(*) end
-
- ##
- # Prints when a module is added
-
- def print_module(*) end
-
- ##
- # Prints when RDoc is done
-
- def done_adding(*) end
-
-end
-
diff --git a/lib/rdoc/stats/verbose.rb b/lib/rdoc/stats/verbose.rb
deleted file mode 100644
index 6ace8937a2..0000000000
--- a/lib/rdoc/stats/verbose.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-##
-# Stats printer that prints everything documented, including the documented
-# status
-
-class RDoc::Stats::Verbose < RDoc::Stats::Normal
-
- ##
- # Returns a marker for RDoc::CodeObject +co+ being undocumented
-
- def nodoc co
- " (undocumented)" unless co.documented?
- end
-
- def print_alias as # :nodoc:
- puts " alias #{as.new_name} #{as.old_name}#{nodoc as}"
- end
-
- def print_attribute attribute # :nodoc:
- puts " #{attribute.definition} #{attribute.name}#{nodoc attribute}"
- end
-
- def print_class(klass) # :nodoc:
- puts " class #{klass.full_name}#{nodoc klass}"
- end
-
- def print_constant(constant) # :nodoc:
- puts " #{constant.name}#{nodoc constant}"
- end
-
- def print_file(files_so_far, file) # :nodoc:
- super
- puts
- end
-
- def print_method(method) # :nodoc:
- puts " #{method.singleton ? '::' : '#'}#{method.name}#{nodoc method}"
- end
-
- def print_module(mod) # :nodoc:
- puts " module #{mod.full_name}#{nodoc mod}"
- end
-
-end
-
-
diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb
deleted file mode 100644
index 9fc540d317..0000000000
--- a/lib/rdoc/store.rb
+++ /dev/null
@@ -1,979 +0,0 @@
-# frozen_string_literal: true
-require 'fileutils'
-
-##
-# A set of rdoc data for a single project (gem, path, etc.).
-#
-# The store manages reading and writing ri data for a project and maintains a
-# cache of methods, classes and ancestors in the store.
-#
-# The store maintains a #cache of its contents for faster lookup. After
-# adding items to the store it must be flushed using #save_cache. The cache
-# contains the following structures:
-#
-# @cache = {
-# :ancestors => {}, # class name => ancestor names
-# :attributes => {}, # class name => attributes
-# :class_methods => {}, # class name => class methods
-# :instance_methods => {}, # class name => instance methods
-# :modules => [], # classes and modules in this store
-# :pages => [], # page names
-# }
-#--
-# TODO need to prune classes
-
-class RDoc::Store
-
- ##
- # Errors raised from loading or saving the store
-
- class Error < RDoc::Error
- end
-
- ##
- # Raised when a stored file for a class, module, page or method is missing.
-
- class MissingFileError < Error
-
- ##
- # The store the file should exist in
-
- attr_reader :store
-
- ##
- # The file the #name should be saved as
-
- attr_reader :file
-
- ##
- # The name of the object the #file would be loaded from
-
- attr_reader :name
-
- ##
- # Creates a new MissingFileError for the missing +file+ for the given
- # +name+ that should have been in the +store+.
-
- def initialize store, file, name
- @store = store
- @file = file
- @name = name
- end
-
- def message # :nodoc:
- "store at #{@store.path} missing file #{@file} for #{@name}"
- end
-
- end
-
- ##
- # Stores the name of the C variable a class belongs to. This helps wire up
- # classes defined from C across files.
-
- attr_reader :c_enclosure_classes # :nodoc:
-
- attr_reader :c_enclosure_names # :nodoc:
-
- ##
- # Maps C variables to class or module names for each parsed C file.
-
- attr_reader :c_class_variables
-
- ##
- # Maps C variables to singleton class names for each parsed C file.
-
- attr_reader :c_singleton_class_variables
-
- ##
- # If true this Store will not write any files
-
- attr_accessor :dry_run
-
- ##
- # Path this store reads or writes
-
- attr_accessor :path
-
- ##
- # The RDoc::RDoc driver for this parse tree. This allows classes consulting
- # the documentation tree to access user-set options, for example.
-
- attr_accessor :rdoc
-
- ##
- # Type of ri datastore this was loaded from. See RDoc::RI::Driver,
- # RDoc::RI::Paths.
-
- attr_accessor :type
-
- ##
- # The contents of the Store
-
- attr_reader :cache
-
- ##
- # The encoding of the contents in the Store
-
- attr_accessor :encoding
-
- ##
- # The lazy constants alias will be discovered in passing
-
- attr_reader :unmatched_constant_alias
-
- ##
- # Creates a new Store of +type+ that will load or save to +path+
-
- def initialize path = nil, type = nil
- @dry_run = false
- @encoding = nil
- @path = path
- @rdoc = nil
- @type = type
-
- @cache = {
- :ancestors => {},
- :attributes => {},
- :class_methods => {},
- :c_class_variables => {},
- :c_singleton_class_variables => {},
- :encoding => @encoding,
- :instance_methods => {},
- :main => nil,
- :modules => [],
- :pages => [],
- :title => nil,
- }
-
- @classes_hash = {}
- @modules_hash = {}
- @files_hash = {}
- @text_files_hash = {}
-
- @c_enclosure_classes = {}
- @c_enclosure_names = {}
-
- @c_class_variables = {}
- @c_singleton_class_variables = {}
-
- @unique_classes = nil
- @unique_modules = nil
-
- @unmatched_constant_alias = {}
- end
-
- ##
- # Adds +module+ as an enclosure (namespace) for the given +variable+ for C
- # files.
-
- def add_c_enclosure variable, namespace
- @c_enclosure_classes[variable] = namespace
- end
-
- ##
- # Adds C variables from an RDoc::Parser::C
-
- def add_c_variables c_parser
- filename = c_parser.top_level.relative_name
-
- @c_class_variables[filename] = make_variable_map c_parser.classes
-
- @c_singleton_class_variables[filename] = c_parser.singleton_classes
- end
-
- ##
- # Adds the file with +name+ as an RDoc::TopLevel to the store. Returns the
- # created RDoc::TopLevel.
-
- def add_file absolute_name, relative_name: absolute_name, parser: nil
- unless top_level = @files_hash[relative_name] then
- top_level = RDoc::TopLevel.new absolute_name, relative_name
- top_level.parser = parser if parser
- top_level.store = self
- @files_hash[relative_name] = top_level
- @text_files_hash[relative_name] = top_level if top_level.text?
- end
-
- top_level
- end
-
- def update_parser_of_file(absolute_name, parser)
- if top_level = @files_hash[absolute_name] then
- @text_files_hash[absolute_name] = top_level if top_level.text?
- end
- end
-
- ##
- # Returns all classes discovered by RDoc
-
- def all_classes
- @classes_hash.values
- end
-
- ##
- # Returns all classes and modules discovered by RDoc
-
- def all_classes_and_modules
- @classes_hash.values + @modules_hash.values
- end
-
- ##
- # All TopLevels known to RDoc
-
- def all_files
- @files_hash.values
- end
-
- ##
- # Returns all modules discovered by RDoc
-
- def all_modules
- modules_hash.values
- end
-
- ##
- # Ancestors cache accessor. Maps a klass name to an Array of its ancestors
- # in this store. If Foo in this store inherits from Object, Kernel won't be
- # listed (it will be included from ruby's ri store).
-
- def ancestors
- @cache[:ancestors]
- end
-
- ##
- # Attributes cache accessor. Maps a class to an Array of its attributes.
-
- def attributes
- @cache[:attributes]
- end
-
- ##
- # Path to the cache file
-
- def cache_path
- File.join @path, 'cache.ri'
- end
-
- ##
- # Path to the ri data for +klass_name+
-
- def class_file klass_name
- name = klass_name.split('::').last
- File.join class_path(klass_name), "cdesc-#{name}.ri"
- end
-
- ##
- # Class methods cache accessor. Maps a class to an Array of its class
- # methods (not full name).
-
- def class_methods
- @cache[:class_methods]
- end
-
- ##
- # Path where data for +klass_name+ will be stored (methods or class data)
-
- def class_path klass_name
- File.join @path, *klass_name.split('::')
- end
-
- ##
- # Hash of all classes known to RDoc
-
- def classes_hash
- @classes_hash
- end
-
- ##
- # Removes empty items and ensures item in each collection are unique and
- # sorted
-
- def clean_cache_collection collection # :nodoc:
- collection.each do |name, item|
- if item.empty? then
- collection.delete name
- else
- # HACK mongrel-1.1.5 documents its files twice
- item.uniq!
- item.sort!
- end
- end
- end
-
- ##
- # Prepares the RDoc code object tree for use by a generator.
- #
- # It finds unique classes/modules defined, and replaces classes/modules that
- # are aliases for another one by a copy with RDoc::ClassModule#is_alias_for
- # set.
- #
- # It updates the RDoc::ClassModule#constant_aliases attribute of "real"
- # classes or modules.
- #
- # It also completely removes the classes and modules that should be removed
- # from the documentation and the methods that have a visibility below
- # +min_visibility+, which is the <tt>--visibility</tt> option.
- #
- # See also RDoc::Context#remove_from_documentation?
-
- def complete min_visibility
- fix_basic_object_inheritance
-
- # cache included modules before they are removed from the documentation
- all_classes_and_modules.each { |cm| cm.ancestors }
-
- unless min_visibility == :nodoc then
- remove_nodoc @classes_hash
- remove_nodoc @modules_hash
- end
-
- @unique_classes = find_unique @classes_hash
- @unique_modules = find_unique @modules_hash
-
- unique_classes_and_modules.each do |cm|
- cm.complete min_visibility
- end
-
- @files_hash.each_key do |file_name|
- tl = @files_hash[file_name]
-
- unless tl.text? then
- tl.modules_hash.clear
- tl.classes_hash.clear
-
- tl.classes_or_modules.each do |cm|
- name = cm.full_name
- if cm.type == 'class' then
- tl.classes_hash[name] = cm if @classes_hash[name]
- else
- tl.modules_hash[name] = cm if @modules_hash[name]
- end
- end
- end
- end
- end
-
- ##
- # Hash of all files known to RDoc
-
- def files_hash
- @files_hash
- end
-
- ##
- # Finds the enclosure (namespace) for the given C +variable+.
-
- def find_c_enclosure variable
- @c_enclosure_classes.fetch variable do
- break unless name = @c_enclosure_names[variable]
-
- mod = find_class_or_module name
-
- unless mod then
- loaded_mod = load_class_data name
-
- file = loaded_mod.in_files.first
-
- return unless file # legacy data source
-
- file.store = self
-
- mod = file.add_module RDoc::NormalModule, name
- end
-
- @c_enclosure_classes[variable] = mod
- end
- end
-
- ##
- # Finds the class with +name+ in all discovered classes
-
- def find_class_named name
- @classes_hash[name]
- end
-
- ##
- # Finds the class with +name+ starting in namespace +from+
-
- def find_class_named_from name, from
- from = find_class_named from unless RDoc::Context === from
-
- until RDoc::TopLevel === from do
- return nil unless from
-
- klass = from.find_class_named name
- return klass if klass
-
- from = from.parent
- end
-
- find_class_named name
- end
-
- ##
- # Finds the class or module with +name+
-
- def find_class_or_module name
- name = $' if name =~ /^::/
- @classes_hash[name] || @modules_hash[name]
- end
-
- ##
- # Finds the file with +name+ in all discovered files
-
- def find_file_named name
- @files_hash[name]
- end
-
- ##
- # Finds the module with +name+ in all discovered modules
-
- def find_module_named name
- @modules_hash[name]
- end
-
- ##
- # Returns the RDoc::TopLevel that is a text file and has the given
- # +file_name+
-
- def find_text_page file_name
- @text_files_hash.each_value.find do |file|
- file.full_name == file_name
- end
- end
-
- ##
- # Finds unique classes/modules defined in +all_hash+,
- # and returns them as an array. Performs the alias
- # updates in +all_hash+: see ::complete.
- #--
- # TODO aliases should be registered by Context#add_module_alias
-
- def find_unique all_hash
- unique = []
-
- all_hash.each_pair do |full_name, cm|
- unique << cm if full_name == cm.full_name
- end
-
- unique
- end
-
- ##
- # Fixes the erroneous <tt>BasicObject < Object</tt> in 1.9.
- #
- # Because we assumed all classes without a stated superclass
- # inherit from Object, we have the above wrong inheritance.
- #
- # We fix BasicObject right away if we are running in a Ruby
- # version >= 1.9.
-
- def fix_basic_object_inheritance
- basic = classes_hash['BasicObject']
- return unless basic
- basic.superclass = nil
- end
-
- ##
- # Friendly rendition of #path
-
- def friendly_path
- case type
- when :gem then
- parent = File.expand_path '..', @path
- "gem #{File.basename parent}"
- when :home then RDoc.home
- when :site then 'ruby site'
- when :system then 'ruby core'
- else @path
- end
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %s %p>" % [self.class, object_id, @path, module_names.sort]
- end
-
- ##
- # Instance methods cache accessor. Maps a class to an Array of its
- # instance methods (not full name).
-
- def instance_methods
- @cache[:instance_methods]
- end
-
- ##
- # Loads all items from this store into memory. This recreates a
- # documentation tree for use by a generator
-
- def load_all
- load_cache
-
- module_names.each do |module_name|
- mod = find_class_or_module(module_name) || load_class(module_name)
-
- # load method documentation since the loaded class/module does not have
- # it
- loaded_methods = mod.method_list.map do |method|
- load_method module_name, method.full_name
- end
-
- mod.method_list.replace loaded_methods
-
- loaded_attributes = mod.attributes.map do |attribute|
- load_method module_name, attribute.full_name
- end
-
- mod.attributes.replace loaded_attributes
- end
-
- all_classes_and_modules.each do |mod|
- descendent_re = /^#{mod.full_name}::[^:]+$/
-
- module_names.each do |name|
- next unless name =~ descendent_re
-
- descendent = find_class_or_module name
-
- case descendent
- when RDoc::NormalClass then
- mod.classes_hash[name] = descendent
- when RDoc::NormalModule then
- mod.modules_hash[name] = descendent
- end
- end
- end
-
- @cache[:pages].each do |page_name|
- page = load_page page_name
- @files_hash[page_name] = page
- @text_files_hash[page_name] = page if page.text?
- end
- end
-
- ##
- # Loads cache file for this store
-
- def load_cache
- #orig_enc = @encoding
-
- File.open cache_path, 'rb' do |io|
- @cache = Marshal.load io
- end
-
- load_enc = @cache[:encoding]
-
- # TODO this feature will be time-consuming to add:
- # a) Encodings may be incompatible but transcodeable
- # b) Need to warn in the appropriate spots, wherever they may be
- # c) Need to handle cross-cache differences in encodings
- # d) Need to warn when generating into a cache with different encodings
- #
- #if orig_enc and load_enc != orig_enc then
- # warn "Cached encoding #{load_enc} is incompatible with #{orig_enc}\n" \
- # "from #{path}/cache.ri" unless
- # Encoding.compatible? orig_enc, load_enc
- #end
-
- @encoding = load_enc unless @encoding
-
- @cache[:pages] ||= []
- @cache[:main] ||= nil
- @cache[:c_class_variables] ||= {}
- @cache[:c_singleton_class_variables] ||= {}
-
- @cache[:c_class_variables].each do |_, map|
- map.each do |variable, name|
- @c_enclosure_names[variable] = name
- end
- end
-
- @cache
- rescue Errno::ENOENT
- end
-
- ##
- # Loads ri data for +klass_name+ and hooks it up to this store.
-
- def load_class klass_name
- obj = load_class_data klass_name
-
- obj.store = self
-
- case obj
- when RDoc::NormalClass then
- @classes_hash[klass_name] = obj
- when RDoc::SingleClass then
- @classes_hash[klass_name] = obj
- when RDoc::NormalModule then
- @modules_hash[klass_name] = obj
- end
- end
-
- ##
- # Loads ri data for +klass_name+
-
- def load_class_data klass_name
- file = class_file klass_name
-
- File.open file, 'rb' do |io|
- Marshal.load io
- end
- rescue Errno::ENOENT => e
- error = MissingFileError.new(self, file, klass_name)
- error.set_backtrace e.backtrace
- raise error
- end
-
- ##
- # Loads ri data for +method_name+ in +klass_name+
-
- def load_method klass_name, method_name
- file = method_file klass_name, method_name
-
- File.open file, 'rb' do |io|
- obj = Marshal.load io
- obj.store = self
- obj.parent =
- find_class_or_module(klass_name) || load_class(klass_name) unless
- obj.parent
- obj
- end
- rescue Errno::ENOENT => e
- error = MissingFileError.new(self, file, klass_name + method_name)
- error.set_backtrace e.backtrace
- raise error
- end
-
- ##
- # Loads ri data for +page_name+
-
- def load_page page_name
- file = page_file page_name
-
- File.open file, 'rb' do |io|
- obj = Marshal.load io
- obj.store = self
- obj
- end
- rescue Errno::ENOENT => e
- error = MissingFileError.new(self, file, page_name)
- error.set_backtrace e.backtrace
- raise error
- end
-
- ##
- # Gets the main page for this RDoc store. This page is used as the root of
- # the RDoc server.
-
- def main
- @cache[:main]
- end
-
- ##
- # Sets the main page for this RDoc store.
-
- def main= page
- @cache[:main] = page
- end
-
- ##
- # Converts the variable => ClassModule map +variables+ from a C parser into
- # a variable => class name map.
-
- def make_variable_map variables
- map = {}
-
- variables.each { |variable, class_module|
- map[variable] = class_module.full_name
- }
-
- map
- end
-
- ##
- # Path to the ri data for +method_name+ in +klass_name+
-
- def method_file klass_name, method_name
- method_name = method_name.split('::').last
- method_name =~ /#(.*)/
- method_type = $1 ? 'i' : 'c'
- method_name = $1 if $1
- method_name = method_name.gsub(/\W/) { "%%%02x" % $&[0].ord }
-
- File.join class_path(klass_name), "#{method_name}-#{method_type}.ri"
- end
-
- ##
- # Modules cache accessor. An Array of all the module (and class) names in
- # the store.
-
- def module_names
- @cache[:modules]
- end
-
- ##
- # Hash of all modules known to RDoc
-
- def modules_hash
- @modules_hash
- end
-
- ##
- # Returns the RDoc::TopLevel that is a text file and has the given +name+
-
- def page name
- @text_files_hash.each_value.find do |file|
- file.page_name == name or file.base_name == name
- end
- end
-
- ##
- # Path to the ri data for +page_name+
-
- def page_file page_name
- file_name = File.basename(page_name).gsub('.', '_')
-
- File.join @path, File.dirname(page_name), "page-#{file_name}.ri"
- end
-
- ##
- # Removes from +all_hash+ the contexts that are nodoc or have no content.
- #
- # See RDoc::Context#remove_from_documentation?
-
- def remove_nodoc all_hash
- all_hash.keys.each do |name|
- context = all_hash[name]
- all_hash.delete(name) if context.remove_from_documentation?
- end
- end
-
- ##
- # Saves all entries in the store
-
- def save
- load_cache
-
- all_classes_and_modules.each do |klass|
- save_class klass
-
- klass.each_method do |method|
- save_method klass, method
- end
-
- klass.each_attribute do |attribute|
- save_method klass, attribute
- end
- end
-
- all_files.each do |file|
- save_page file
- end
-
- save_cache
- end
-
- ##
- # Writes the cache file for this store
-
- def save_cache
- clean_cache_collection @cache[:ancestors]
- clean_cache_collection @cache[:attributes]
- clean_cache_collection @cache[:class_methods]
- clean_cache_collection @cache[:instance_methods]
-
- @cache[:modules].uniq!
- @cache[:modules].sort!
-
- @cache[:pages].uniq!
- @cache[:pages].sort!
-
- @cache[:encoding] = @encoding # this gets set twice due to assert_cache
-
- @cache[:c_class_variables].merge! @c_class_variables
- @cache[:c_singleton_class_variables].merge! @c_singleton_class_variables
-
- return if @dry_run
-
- File.open cache_path, 'wb' do |io|
- Marshal.dump @cache, io
- end
- end
-
- ##
- # Writes the ri data for +klass+ (or module)
-
- def save_class klass
- full_name = klass.full_name
-
- FileUtils.mkdir_p class_path(full_name) unless @dry_run
-
- @cache[:modules] << full_name
-
- path = class_file full_name
-
- begin
- disk_klass = load_class full_name
-
- klass = disk_klass.merge klass
- rescue MissingFileError
- end
-
- # BasicObject has no ancestors
- ancestors = klass.direct_ancestors.compact.map do |ancestor|
- # HACK for classes we don't know about (class X < RuntimeError)
- String === ancestor ? ancestor : ancestor.full_name
- end
-
- @cache[:ancestors][full_name] ||= []
- @cache[:ancestors][full_name].concat ancestors
-
- attribute_definitions = klass.attributes.map do |attribute|
- "#{attribute.definition} #{attribute.name}"
- end
-
- unless attribute_definitions.empty? then
- @cache[:attributes][full_name] ||= []
- @cache[:attributes][full_name].concat attribute_definitions
- end
-
- to_delete = []
-
- unless klass.method_list.empty? then
- @cache[:class_methods][full_name] ||= []
- @cache[:instance_methods][full_name] ||= []
-
- class_methods, instance_methods =
- klass.method_list.partition { |meth| meth.singleton }
-
- class_methods = class_methods. map { |method| method.name }
- instance_methods = instance_methods.map { |method| method.name }
- attribute_names = klass.attributes.map { |attr| attr.name }
-
- old = @cache[:class_methods][full_name] - class_methods
- to_delete.concat old.map { |method|
- method_file full_name, "#{full_name}::#{method}"
- }
-
- old = @cache[:instance_methods][full_name] -
- instance_methods - attribute_names
- to_delete.concat old.map { |method|
- method_file full_name, "#{full_name}##{method}"
- }
-
- @cache[:class_methods][full_name] = class_methods
- @cache[:instance_methods][full_name] = instance_methods
- end
-
- return if @dry_run
-
- FileUtils.rm_f to_delete
-
- File.open path, 'wb' do |io|
- Marshal.dump klass, io
- end
- end
-
- ##
- # Writes the ri data for +method+ on +klass+
-
- def save_method klass, method
- full_name = klass.full_name
-
- FileUtils.mkdir_p class_path(full_name) unless @dry_run
-
- cache = if method.singleton then
- @cache[:class_methods]
- else
- @cache[:instance_methods]
- end
- cache[full_name] ||= []
- cache[full_name] << method.name
-
- return if @dry_run
-
- File.open method_file(full_name, method.full_name), 'wb' do |io|
- Marshal.dump method, io
- end
- end
-
- ##
- # Writes the ri data for +page+
-
- def save_page page
- return unless page.text?
-
- path = page_file page.full_name
-
- FileUtils.mkdir_p File.dirname(path) unless @dry_run
-
- cache[:pages] ||= []
- cache[:pages] << page.full_name
-
- return if @dry_run
-
- File.open path, 'wb' do |io|
- Marshal.dump page, io
- end
- end
-
- ##
- # Source of the contents of this store.
- #
- # For a store from a gem the source is the gem name. For a store from the
- # home directory the source is "home". For system ri store (the standard
- # library documentation) the source is"ruby". For a store from the site
- # ri directory the store is "site". For other stores the source is the
- # #path.
-
- def source
- case type
- when :gem then File.basename File.expand_path '..', @path
- when :home then 'home'
- when :site then 'site'
- when :system then 'ruby'
- else @path
- end
- end
-
- ##
- # Gets the title for this RDoc store. This is used as the title in each
- # page on the RDoc server
-
- def title
- @cache[:title]
- end
-
- ##
- # Sets the title page for this RDoc store.
-
- def title= title
- @cache[:title] = title
- end
-
- ##
- # Returns the unique classes discovered by RDoc.
- #
- # ::complete must have been called prior to using this method.
-
- def unique_classes
- @unique_classes
- end
-
- ##
- # Returns the unique classes and modules discovered by RDoc.
- # ::complete must have been called prior to using this method.
-
- def unique_classes_and_modules
- @unique_classes + @unique_modules
- end
-
- ##
- # Returns the unique modules discovered by RDoc.
- # ::complete must have been called prior to using this method.
-
- def unique_modules
- @unique_modules
- end
-
-end
diff --git a/lib/rdoc/task.rb b/lib/rdoc/task.rb
deleted file mode 100644
index eb584c9d2a..0000000000
--- a/lib/rdoc/task.rb
+++ /dev/null
@@ -1,355 +0,0 @@
-# frozen_string_literal: true
-#--
-# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
-#
-# 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
- gem 'rdoc'
-rescue Gem::LoadError
-end unless defined?(RDoc)
-
-begin
- gem 'rake'
-rescue Gem::LoadError
-end unless defined?(Rake)
-
-require_relative '../rdoc'
-require 'rake'
-require 'rake/tasklib'
-
-##
-# RDoc::Task creates the following rake tasks to generate and clean up RDoc
-# output:
-#
-# [rdoc]
-# Main task for this RDoc task.
-#
-# [clobber_rdoc]
-# Delete all the rdoc files. This target is automatically added to the main
-# clobber target.
-#
-# [rerdoc]
-# Rebuild the rdoc files from scratch, even if they are not out of date.
-#
-# [rdoc:coverage]
-# Print RDoc coverage report for all rdoc files.
-#
-# Simple Example:
-#
-# require 'rdoc/task'
-#
-# RDoc::Task.new do |rdoc|
-# rdoc.main = "README.rdoc"
-# rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
-# end
-#
-# The +rdoc+ object passed to the block is an RDoc::Task object. See the
-# attributes list for the RDoc::Task class for available customization options.
-#
-# == Specifying different task names
-#
-# 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:
-#
-# require 'rdoc/task'
-#
-# RDoc::Task.new :rdoc_dev do |rdoc|
-# rdoc.main = "README.rdoc"
-# rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
-# rdoc.options << "--all"
-# end
-#
-# The tasks would then be named :<em>rdoc_dev</em>,
-# :clobber_<em>rdoc_dev</em>, and :re<em>rdoc_dev</em>.
-#
-# If you wish to have completely different task names, then pass a Hash as
-# first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
-# <tt>:rerdoc</tt> options, you can customize the task names to your liking.
-#
-# For example:
-#
-# require 'rdoc/task'
-#
-# RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean",
-# :rerdoc => "rdoc:force")
-#
-# This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc:clean</tt>,
-# <tt>:rdoc:force</tt>, and <tt>:rdoc:coverage</tt>.
-
-class RDoc::Task < Rake::TaskLib
-
- ##
- # Name of the main, top level task. (default is :rdoc)
-
- attr_accessor :name
-
- ##
- # Comment markup format. rdoc, rd and tomdoc are supported. (default is
- # 'rdoc')
-
- attr_accessor :markup
-
- ##
- # Name of directory to receive the html output files. (default is "html")
-
- attr_accessor :rdoc_dir
-
- ##
- # Title of RDoc documentation. (defaults to rdoc's default)
-
- 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. (defaults to rdoc's default)
-
- attr_accessor :template
-
- ##
- # Name of format generator (<tt>--format</tt>) used by rdoc. (defaults to
- # rdoc's default)
-
- attr_accessor :generator
-
- ##
- # List of files to be included in the rdoc generation. (default is [])
-
- attr_accessor :rdoc_files
-
- ##
- # Additional list of options to be passed rdoc. (default is [])
-
- attr_accessor :options
-
- ##
- # Whether to run the rdoc process as an external shell (default is false)
-
- attr_accessor :external
-
- ##
- # Create an RDoc task with the given name. See the RDoc::Task class overview
- # for documentation.
-
- def initialize name = :rdoc # :yield: self
- defaults
-
- check_names name
-
- @name = name
-
- yield self if block_given?
-
- define
- end
-
- ##
- # Ensures that +names+ only includes names for the :rdoc, :clobber_rdoc and
- # :rerdoc. If other names are given an ArgumentError is raised.
-
- def check_names names
- return unless Hash === names
-
- invalid_options =
- names.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
-
- unless invalid_options.empty? then
- raise ArgumentError, "invalid options: #{invalid_options.join ', '}"
- end
- end
-
- ##
- # Task description for the clobber rdoc task or its renamed equivalent
-
- def clobber_task_description
- "Remove RDoc HTML files"
- end
-
- ##
- # Sets default task values
-
- def defaults
- @name = :rdoc
- @rdoc_files = Rake::FileList.new
- @rdoc_dir = 'html'
- @main = nil
- @title = nil
- @template = nil
- @generator = nil
- @options = []
- end
-
- ##
- # All source is inline now. This method is deprecated
-
- def inline_source # :nodoc:
- warn "RDoc::Task#inline_source is deprecated"
- true
- end
-
- ##
- # All source is inline now. This method is deprecated
-
- def inline_source=(value) # :nodoc:
- warn "RDoc::Task#inline_source is deprecated"
- end
-
- ##
- # Create the tasks defined by this task lib.
-
- def define
- desc rdoc_task_description
- task rdoc_task_name
-
- desc rerdoc_task_description
- task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
-
- desc clobber_task_description
- task clobber_task_name do
- rm_r @rdoc_dir rescue nil
- end
-
- task :clobber => [clobber_task_name]
-
- directory @rdoc_dir
-
- rdoc_target_deps = [
- @rdoc_files,
- Rake.application.rakefile
- ].flatten.compact
-
- task rdoc_task_name => [rdoc_target]
- file rdoc_target => rdoc_target_deps do
- @before_running_rdoc.call if @before_running_rdoc
- args = option_list + @rdoc_files
-
- $stderr.puts "rdoc #{args.join ' '}" if Rake.application.options.trace
- RDoc::RDoc.new.document args
- end
-
- namespace rdoc_task_name do
- desc coverage_task_description
- task coverage_task_name do
- @before_running_rdoc.call if @before_running_rdoc
- opts = option_list << "-C"
- args = opts + @rdoc_files
-
- $stderr.puts "rdoc #{args.join ' '}" if Rake.application.options.trace
- RDoc::RDoc.new.document args
- end
- end
-
- self
- end
-
- ##
- # List of options that will be supplied to RDoc
-
- def option_list
- result = @options.dup
- result << "-o" << @rdoc_dir
- result << "--main" << main if main
- result << "--markup" << markup if markup
- result << "--title" << title if title
- result << "-T" << template if template
- result << '-f' << generator if generator
- result
- end
-
- ##
- # The block passed to this method will be called just before running the
- # RDoc generator. It is allowed to modify RDoc::Task attributes inside the
- # block.
-
- def before_running_rdoc(&block)
- @before_running_rdoc = block
- end
-
- ##
- # Task description for the rdoc task or its renamed equivalent
-
- def rdoc_task_description
- 'Build RDoc HTML files'
- end
-
- ##
- # Task description for the rerdoc task or its renamed description
-
- def rerdoc_task_description
- "Rebuild RDoc HTML files"
- end
-
- ##
- # Task description for the coverage task or its renamed description
-
- def coverage_task_description
- "Print RDoc coverage report"
- end
-
- private
-
- def rdoc_target
- "#{rdoc_dir}/created.rid"
- end
-
- def rdoc_task_name
- case name
- when Hash then (name[:rdoc] || "rdoc").to_s
- else name.to_s
- end
- end
-
- def clobber_task_name
- case name
- when Hash then (name[:clobber_rdoc] || "clobber_rdoc").to_s
- else "clobber_#{name}"
- end
- end
-
- def rerdoc_task_name
- case name
- when Hash then (name[:rerdoc] || "rerdoc").to_s
- else "re#{name}"
- end
- end
-
- def coverage_task_name
- "coverage"
- end
-
-end
-
-# :stopdoc:
-module Rake
-
- ##
- # For backwards compatibility
-
- RDocTask = RDoc::Task # :nodoc:
-
-end
-# :startdoc:
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb
deleted file mode 100644
index 0bc4aba428..0000000000
--- a/lib/rdoc/text.rb
+++ /dev/null
@@ -1,312 +0,0 @@
-# frozen_string_literal: true
-
-##
-# For RDoc::Text#to_html
-
-require 'strscan'
-
-##
-# Methods for manipulating comment text
-
-module RDoc::Text
-
- attr_accessor :language
-
- ##
- # Maps markup formats to classes that can parse them. If the format is
- # unknown, "rdoc" format is used.
-
- MARKUP_FORMAT = {
- 'markdown' => RDoc::Markdown,
- 'rdoc' => RDoc::Markup,
- 'rd' => RDoc::RD,
- 'tomdoc' => RDoc::TomDoc,
- }
-
- MARKUP_FORMAT.default = RDoc::Markup
-
- ##
- # Maps an encoding to a Hash of characters properly transcoded for that
- # encoding.
- #
- # See also encode_fallback.
-
- TO_HTML_CHARACTERS = Hash.new do |h, encoding|
- h[encoding] = {
- :close_dquote => encode_fallback('â€', encoding, '"'),
- :close_squote => encode_fallback('’', encoding, '\''),
- :copyright => encode_fallback('©', encoding, '(c)'),
- :ellipsis => encode_fallback('…', encoding, '...'),
- :em_dash => encode_fallback('—', encoding, '---'),
- :en_dash => encode_fallback('–', encoding, '--'),
- :open_dquote => encode_fallback('“', encoding, '"'),
- :open_squote => encode_fallback('‘', encoding, '\''),
- :trademark => encode_fallback('®', encoding, '(r)'),
- }
- end
-
- ##
- # Transcodes +character+ to +encoding+ with a +fallback+ character.
-
- def self.encode_fallback character, encoding, fallback
- character.encode(encoding, :fallback => { character => fallback },
- :undef => :replace, :replace => fallback)
- end
-
- ##
- # Expands tab characters in +text+ to eight spaces
-
- def expand_tabs text
- expanded = []
-
- text.each_line do |line|
- nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
- r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
- r = RDoc::Encoding.change_encoding r, text.encoding
- r
- end
-
- expanded << line
- end
-
- expanded.join
- end
-
- ##
- # Flush +text+ left based on the shortest line
-
- def flush_left text
- indent = 9999
-
- text.each_line do |line|
- line_indent = line =~ /\S/ || 9999
- indent = line_indent if indent > line_indent
- end
-
- empty = ''
- empty = RDoc::Encoding.change_encoding empty, text.encoding
-
- text.gsub(/^ {0,#{indent}}/, empty)
- end
-
- ##
- # Convert a string in markup format into HTML.
- #
- # Requires the including class to implement #formatter
-
- def markup text
- if @store.rdoc.options
- locale = @store.rdoc.options.locale
- else
- locale = nil
- end
- if locale
- i18n_text = RDoc::I18n::Text.new(text)
- text = i18n_text.translate(locale)
- end
- parse(text).accept formatter
- end
-
- ##
- # Strips hashes, expands tabs then flushes +text+ to the left
-
- def normalize_comment text
- return text if text.empty?
-
- case language
- when :ruby
- text = strip_hashes text
- when :c
- text = strip_stars text
- end
- text = expand_tabs text
- text = flush_left text
- text = strip_newlines text
- text
- end
-
- ##
- # Normalizes +text+ then builds a RDoc::Markup::Document from it
-
- def parse text, format = 'rdoc'
- return text if RDoc::Markup::Document === text
- return text.parse if RDoc::Comment === text
-
- text = normalize_comment text # TODO remove, should not be necessary
-
- return RDoc::Markup::Document.new if text =~ /\A\n*\z/
-
- MARKUP_FORMAT[format].parse text
- end
-
- ##
- # The first +limit+ characters of +text+ as HTML
-
- def snippet text, limit = 100
- document = parse text
-
- RDoc::Markup::ToHtmlSnippet.new(options, limit).convert document
- end
-
- ##
- # Strips leading # characters from +text+
-
- def strip_hashes text
- return text if text =~ /^(?>\s*)[^\#]/
-
- empty = ''
- empty = RDoc::Encoding.change_encoding empty, text.encoding
-
- text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
- end
-
- ##
- # Strips leading and trailing \n characters from +text+
-
- def strip_newlines text
- text.gsub(/\A\n*(.*?)\n*\z/m) do $1 end # block preserves String encoding
- end
-
- ##
- # Strips /* */ style comments
-
- def strip_stars text
- return text unless text =~ %r%/\*.*\*/%m
-
- encoding = text.encoding
-
- text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+\-/*\%@`\[\]]+%, ''
-
- space = ' '
- space = RDoc::Encoding.change_encoding space, encoding if encoding
-
- text.sub! %r%/\*+% do space * $&.length end
- text.sub! %r%\*+/% do space * $&.length end
- text.gsub! %r%^[ \t]*\*%m do space * $&.length end
-
- empty = ''
- empty = RDoc::Encoding.change_encoding empty, encoding if encoding
- text.gsub(/^\s+$/, empty)
- end
-
- ##
- # Converts ampersand, dashes, ellipsis, quotes, copyright and registered
- # trademark symbols in +text+ to properly encoded characters.
-
- def to_html text
- html = (''.encode text.encoding).dup
-
- encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
-
- s = StringScanner.new text
- insquotes = false
- indquotes = false
- after_word = nil
-
- until s.eos? do
- case
- when s.scan(/<(tt|code)>.*?<\/\1>/) then # skip contents of tt
- html << s.matched.gsub('\\\\', '\\')
- when s.scan(/<(tt|code)>.*?/) then
- warn "mismatched <#{s[1]}> tag" # TODO signal file/line
- html << s.matched
- when s.scan(/<[^>]+\/?s*>/) then # skip HTML tags
- html << s.matched
- when s.scan(/\\(\S)/) then # unhandled suppressed crossref
- html << s[1]
- after_word = nil
- when s.scan(/\.\.\.(\.?)/) then
- html << s[1] << encoded[:ellipsis]
- after_word = nil
- when s.scan(/\(c\)/i) then
- html << encoded[:copyright]
- after_word = nil
- when s.scan(/\(r\)/i) then
- html << encoded[:trademark]
- after_word = nil
- when s.scan(/---/) then
- html << encoded[:em_dash]
- after_word = nil
- when s.scan(/--/) then
- html << encoded[:en_dash]
- after_word = nil
- when s.scan(/&quot;|"/) then
- html << encoded[indquotes ? :close_dquote : :open_dquote]
- indquotes = !indquotes
- after_word = nil
- when s.scan(/``/) then # backtick double quote
- html << encoded[:open_dquote]
- after_word = nil
- when s.scan(/(?:&#39;|'){2}/) then # tick double quote
- html << encoded[:close_dquote]
- after_word = nil
- when s.scan(/`/) then # backtick
- if insquotes or after_word
- html << '`'
- after_word = false
- else
- html << encoded[:open_squote]
- insquotes = true
- end
- when s.scan(/&#39;|'/) then # single quote
- if insquotes
- html << encoded[:close_squote]
- insquotes = false
- elsif after_word
- # Mary's dog, my parents' house: do not start paired quotes
- html << encoded[:close_squote]
- else
- html << encoded[:open_squote]
- insquotes = true
- end
-
- after_word = nil
- else # advance to the next potentially significant character
- match = s.scan(/.+?(?=[<\\.("'`&-])/) #"
-
- if match then
- html << match
- after_word = match =~ /\w$/
- else
- html << s.rest
- break
- end
- end
- end
-
- html
- end
-
- ##
- # Wraps +txt+ to +line_len+
-
- def wrap(txt, line_len = 76)
- res = []
- sp = 0
- ep = txt.length
-
- while sp < ep
- # scan back for a space
- p = sp + line_len - 1
- if p >= ep
- p = ep
- else
- while p > sp and txt[p] != ?\s
- p -= 1
- end
- if p <= sp
- p = sp + line_len
- while p < ep and txt[p] != ?\s
- p += 1
- end
- end
- end
- res << txt[sp...p] << "\n"
- sp = p
- sp += 1 while sp < ep and txt[sp] == ?\s
- end
-
- res.join.strip
- end
-
-end
diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb
deleted file mode 100644
index f428e2400c..0000000000
--- a/lib/rdoc/token_stream.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-# frozen_string_literal: true
-##
-# A TokenStream is a list of tokens, gathered during the parse of some entity
-# (say a method). Entities populate these streams by being registered with the
-# lexer. Any class can collect tokens by including TokenStream. From the
-# outside, you use such an object by calling the start_collecting_tokens
-# method, followed by calls to add_token and pop_token.
-
-module RDoc::TokenStream
-
- ##
- # Converts +token_stream+ to HTML wrapping various tokens with
- # <tt><span></tt> elements. Some tokens types are wrapped in spans
- # with the given class names. Other token types are not wrapped in spans.
-
- def self.to_html token_stream
- starting_title = false
-
- token_stream.map do |t|
- next unless t
-
- style = case t[:kind]
- when :on_const then 'ruby-constant'
- when :on_kw then 'ruby-keyword'
- when :on_ivar then 'ruby-ivar'
- when :on_cvar then 'ruby-identifier'
- when :on_gvar then 'ruby-identifier'
- when '=' != t[:text] && :on_op
- then 'ruby-operator'
- when :on_tlambda then 'ruby-operator'
- when :on_ident then 'ruby-identifier'
- when :on_label then 'ruby-value'
- when :on_backref, :on_dstring
- then 'ruby-node'
- when :on_comment then 'ruby-comment'
- when :on_embdoc then 'ruby-comment'
- when :on_regexp then 'ruby-regexp'
- when :on_tstring then 'ruby-string'
- when :on_int, :on_float,
- :on_rational, :on_imaginary,
- :on_heredoc,
- :on_symbol, :on_CHAR then 'ruby-value'
- when :on_heredoc_beg, :on_heredoc_end
- then 'ruby-identifier'
- end
-
- comment_with_nl = false
- if :on_comment == t[:kind] or :on_embdoc == t[:kind] or :on_heredoc_end == t[:kind]
- comment_with_nl = true if "\n" == t[:text][-1]
- text = t[:text].rstrip
- else
- text = t[:text]
- end
-
- if :on_ident == t[:kind] && starting_title
- starting_title = false
- style = 'ruby-identifier ruby-title'
- end
-
- if :on_kw == t[:kind] and 'def' == t[:text]
- starting_title = true
- end
-
- text = CGI.escapeHTML text
-
- if style then
- "<span class=\"#{style}\">#{text}</span>#{"\n" if comment_with_nl}"
- else
- text
- end
- end.join
- end
-
- ##
- # Adds +tokens+ to the collected tokens
-
- def add_tokens(tokens)
- @token_stream.concat(tokens)
- end
-
- ##
- # Adds one +token+ to the collected tokens
-
- def add_token(token)
- @token_stream.push(token)
- end
-
- ##
- # Starts collecting tokens
-
- def collect_tokens
- @token_stream = []
- end
-
- alias start_collecting_tokens collect_tokens
-
- ##
- # Remove the last token from the collected tokens
-
- def pop_token
- @token_stream.pop
- end
-
- ##
- # Current token stream
-
- def token_stream
- @token_stream
- end
-
- ##
- # Returns a string representation of the token stream
-
- def tokens_to_s
- token_stream.compact.map { |token| token[:text] }.join ''
- end
-
-end
-
diff --git a/lib/rdoc/tom_doc.rb b/lib/rdoc/tom_doc.rb
deleted file mode 100644
index e161fcf42f..0000000000
--- a/lib/rdoc/tom_doc.rb
+++ /dev/null
@@ -1,263 +0,0 @@
-# frozen_string_literal: true
-# :markup: tomdoc
-
-# A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a)
-#
-# The TomDoc specification can be found at:
-#
-# http://tomdoc.org
-#
-# The latest version of the TomDoc specification can be found at:
-#
-# https://github.com/mojombo/tomdoc/blob/master/tomdoc.md
-#
-# To choose TomDoc as your only default format see RDoc::Options@Saved+Options
-# for instructions on setting up a <code>.rdoc_options</code> file to store
-# your project default.
-#
-# There are a few differences between this parser and the specification. A
-# best-effort was made to follow the specification as closely as possible but
-# some choices to deviate were made.
-#
-# A future version of RDoc will warn when a MUST or MUST NOT is violated and
-# may warn when a SHOULD or SHOULD NOT is violated. RDoc will always try
-# to emit documentation even if given invalid TomDoc.
-#
-# Here are some implementation choices this parser currently makes:
-#
-# This parser allows rdoc-style inline markup but you should not depended on
-# it.
-#
-# This parser allows a space between the comment and the method body.
-#
-# This parser does not require the default value to be described for an
-# optional argument.
-#
-# This parser does not examine the order of sections. An Examples section may
-# precede the Arguments section.
-#
-# This class is documented in TomDoc format. Since this is a subclass of the
-# RDoc markup parser there isn't much to see here, unfortunately.
-
-class RDoc::TomDoc < RDoc::Markup::Parser
-
- # Internal: Token accessor
-
- attr_reader :tokens
-
- # Internal: Adds a post-processor which sets the RDoc section based on the
- # comment's status.
- #
- # Returns nothing.
-
- def self.add_post_processor # :nodoc:
- RDoc::Markup::PreProcess.post_process do |comment, code_object|
- next unless code_object and
- RDoc::Comment === comment and comment.format == 'tomdoc'
-
- comment.text.gsub!(/(\A\s*# )(Public|Internal|Deprecated):\s+/) do
- section = code_object.add_section $2
- code_object.temporary_section = section
-
- $1
- end
- end
- end
-
- add_post_processor
-
- # Public: Parses TomDoc from text
- #
- # text - A String containing TomDoc-format text.
- #
- # Examples
- #
- # RDoc::TomDoc.parse <<-TOMDOC
- # This method does some things
- #
- # Returns nothing.
- # TOMDOC
- # # => #<RDoc::Markup::Document:0xXXX @parts=[...], @file=nil>
- #
- # Returns an RDoc::Markup::Document representing the TomDoc format.
-
- def self.parse text
- parser = new
-
- parser.tokenize text
- doc = RDoc::Markup::Document.new
- parser.parse doc
- doc
- end
-
- # Internal: Extracts the Signature section's method signature
- #
- # comment - An RDoc::Comment that will be parsed and have the signature
- # extracted
- #
- # Returns a String containing the signature and nil if not
-
- def self.signature comment
- return unless comment.tomdoc?
-
- document = comment.parse
-
- signature = nil
- found_heading = false
- found_signature = false
-
- document.parts.delete_if do |part|
- next false if found_signature
-
- found_heading ||=
- RDoc::Markup::Heading === part && part.text == 'Signature'
-
- next false unless found_heading
-
- next true if RDoc::Markup::BlankLine === part
-
- if RDoc::Markup::Verbatim === part then
- signature = part
- found_signature = true
- end
- end
-
- signature and signature.text
- end
-
- # Public: Creates a new TomDoc parser. See also RDoc::Markup::parse
-
- def initialize
- super
-
- @section = nil
- @seen_returns = false
- end
-
- # Internal: Builds a heading from the token stream
- #
- # level - The level of heading to create
- #
- # Returns an RDoc::Markup::Heading
-
- def build_heading level
- heading = super
-
- @section = heading.text
-
- heading
- end
-
- # Internal: Builds a verbatim from the token stream. A verbatim in the
- # Examples section will be marked as in Ruby format.
- #
- # margin - The indentation from the margin for lines that belong to this
- # verbatim section.
- #
- # Returns an RDoc::Markup::Verbatim
-
- def build_verbatim margin
- verbatim = super
-
- verbatim.format = :ruby if @section == 'Examples'
-
- verbatim
- end
-
- # Internal: Builds a paragraph from the token stream
- #
- # margin - Unused
- #
- # Returns an RDoc::Markup::Paragraph.
-
- def build_paragraph margin
- p :paragraph_start => margin if @debug
-
- paragraph = RDoc::Markup::Paragraph.new
-
- until @tokens.empty? do
- type, data, = get
-
- case type
- when :TEXT then
- @section = 'Returns' if data =~ /\A(Returns|Raises)/
-
- paragraph << data
- when :NEWLINE then
- if :TEXT == peek_token[0] then
- # Lines beginning with 'Raises' in the Returns section should not be
- # treated as multiline text
- if 'Returns' == @section and
- peek_token[1].start_with?('Raises') then
- break
- else
- paragraph << ' '
- end
- else
- break
- end
- else
- unget
- break
- end
- end
-
- p :paragraph_end => margin if @debug
-
- paragraph
- end
-
- ##
- # Detects a section change to "Returns" and adds a heading
-
- def parse_text parent, indent # :nodoc:
- paragraph = build_paragraph indent
-
- if false == @seen_returns and 'Returns' == @section then
- @seen_returns = true
- parent << RDoc::Markup::Heading.new(3, 'Returns')
- parent << RDoc::Markup::BlankLine.new
- end
-
- parent << paragraph
- end
-
- # Internal: Turns text into an Array of tokens
- #
- # text - A String containing TomDoc-format text.
- #
- # Returns self.
-
- def tokenize text
- text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '')
-
- setup_scanner text
-
- until @s.eos? do
- pos = @s.pos
-
- # leading spaces will be reflected by the column of the next token
- # the only thing we loose are trailing spaces at the end of the file
- next if @s.scan(/ +/)
-
- @tokens << case
- when @s.scan(/\r?\n/) then
- token = [:NEWLINE, @s.matched, *pos]
- @s.newline!
- token
- when @s.scan(/(Examples|Signature)$/) then
- @tokens << [:HEADER, 3, *pos]
-
- [:TEXT, @s[1], *pos]
- when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
- [:NOTE, @s[1], *pos]
- else
- @s.scan(/.*/)
- [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
- end
- end
-
- self
- end
-
-end
diff --git a/lib/rdoc/top_level.rb b/lib/rdoc/top_level.rb
deleted file mode 100644
index b8b6110bb2..0000000000
--- a/lib/rdoc/top_level.rb
+++ /dev/null
@@ -1,289 +0,0 @@
-# frozen_string_literal: true
-##
-# A TopLevel context is a representation of the contents of a single file
-
-class RDoc::TopLevel < RDoc::Context
-
- MARSHAL_VERSION = 0 # :nodoc:
-
- ##
- # This TopLevel's File::Stat struct
-
- attr_accessor :file_stat
-
- ##
- # Relative name of this file
-
- attr_accessor :relative_name
-
- ##
- # Absolute name of this file
-
- attr_accessor :absolute_name
-
- ##
- # All the classes or modules that were declared in
- # this file. These are assigned to either +#classes_hash+
- # or +#modules_hash+ once we know what they really are.
-
- attr_reader :classes_or_modules
-
- attr_accessor :diagram # :nodoc:
-
- ##
- # The parser class that processed this file
-
- attr_reader :parser
-
- ##
- # Creates a new TopLevel for the file at +absolute_name+. If documentation
- # is being generated outside the source dir +relative_name+ is relative to
- # the source directory.
-
- def initialize absolute_name, relative_name = absolute_name
- super()
- @name = nil
- @absolute_name = absolute_name
- @relative_name = relative_name
- @file_stat = File.stat(absolute_name) rescue nil # HACK for testing
- @diagram = nil
- @parser = nil
-
- @classes_or_modules = []
- end
-
- def parser=(val)
- @parser = val
- @store.update_parser_of_file(absolute_name, val) if @store
- @parser
- end
-
- ##
- # An RDoc::TopLevel is equal to another with the same relative_name
-
- def == other
- self.class === other and @relative_name == other.relative_name
- end
-
- alias eql? ==
-
- ##
- # Adds +an_alias+ to +Object+ instead of +self+.
-
- def add_alias(an_alias)
- object_class.record_location self
- return an_alias unless @document_self
- object_class.add_alias an_alias
- end
-
- ##
- # Adds +constant+ to +Object+ instead of +self+.
-
- def add_constant constant
- object_class.record_location self
- return constant unless @document_self
- object_class.add_constant constant
- end
-
- ##
- # Adds +include+ to +Object+ instead of +self+.
-
- def add_include(include)
- object_class.record_location self
- return include unless @document_self
- object_class.add_include include
- end
-
- ##
- # Adds +method+ to +Object+ instead of +self+.
-
- def add_method(method)
- object_class.record_location self
- return method unless @document_self
- object_class.add_method method
- end
-
- ##
- # Adds class or module +mod+. Used in the building phase
- # by the Ruby parser.
-
- def add_to_classes_or_modules mod
- @classes_or_modules << mod
- end
-
- ##
- # Base name of this file
-
- def base_name
- File.basename @relative_name
- end
-
- alias name base_name
-
- ##
- # Only a TopLevel that contains text file) will be displayed. See also
- # RDoc::CodeObject#display?
-
- def display?
- text? and super
- end
-
- ##
- # See RDoc::TopLevel::find_class_or_module
- #--
- # TODO Why do we search through all classes/modules found, not just the
- # ones of this instance?
-
- def find_class_or_module name
- @store.find_class_or_module name
- end
-
- ##
- # Finds a class or module named +symbol+
-
- def find_local_symbol(symbol)
- find_class_or_module(symbol) || super
- end
-
- ##
- # Finds a module or class with +name+
-
- def find_module_named(name)
- find_class_or_module(name)
- end
-
- ##
- # Returns the relative name of this file
-
- def full_name
- @relative_name
- end
-
- ##
- # An RDoc::TopLevel has the same hash as another with the same
- # relative_name
-
- def hash
- @relative_name.hash
- end
-
- ##
- # URL for this with a +prefix+
-
- def http_url(prefix)
- path = [prefix, @relative_name.tr('.', '_')]
-
- File.join(*path.compact) + '.html'
- end
-
- def inspect # :nodoc:
- "#<%s:0x%x %p modules: %p classes: %p>" % [
- self.class, object_id,
- base_name,
- @modules.map { |n,m| m },
- @classes.map { |n,c| c }
- ]
- end
-
- ##
- # Time this file was last modified, if known
-
- def last_modified
- @file_stat ? file_stat.mtime : nil
- end
-
- ##
- # Dumps this TopLevel for use by ri. See also #marshal_load
-
- def marshal_dump
- [
- MARSHAL_VERSION,
- @relative_name,
- @parser,
- parse(@comment),
- ]
- end
-
- ##
- # Loads this TopLevel from +array+.
-
- def marshal_load array # :nodoc:
- initialize array[1]
-
- @parser = array[2]
- @comment = array[3]
-
- @file_stat = nil
- end
-
- ##
- # Returns the NormalClass "Object", creating it if not found.
- #
- # Records +self+ as a location in "Object".
-
- def object_class
- @object_class ||= begin
- oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
- oc.record_location self
- oc
- end
- end
-
- ##
- # Base name of this file without the extension
-
- def page_name
- basename = File.basename @relative_name
- basename =~ /\.(rb|rdoc|txt|md)$/i
-
- $` || basename
- end
-
- ##
- # Path to this file for use with HTML generator output.
-
- def path
- http_url @store.rdoc.generator.file_dir
- end
-
- def pretty_print q # :nodoc:
- q.group 2, "[#{self.class}: ", "]" do
- q.text "base name: #{base_name.inspect}"
- q.breakable
-
- items = @modules.map { |n,m| m }
- items.concat @modules.map { |n,c| c }
- q.seplist items do |mod| q.pp mod end
- end
- end
-
- ##
- # Search record used by RDoc::Generator::JsonIndex
-
- def search_record
- return unless @parser < RDoc::Parser::Text
-
- [
- page_name,
- '',
- page_name,
- '',
- path,
- '',
- snippet(@comment),
- ]
- end
-
- ##
- # Is this TopLevel from a text file instead of a source code file?
-
- def text?
- @parser and @parser.include? RDoc::Parser::Text
- end
-
- def to_s # :nodoc:
- "file #{full_name}"
- end
-
-end
-
diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb
deleted file mode 100644
index 04322a1970..0000000000
--- a/lib/rdoc/version.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-module RDoc
-
- ##
- # RDoc version you are using
-
- VERSION = '6.5.0'
-
-end
diff --git a/lib/readline.gemspec b/lib/readline.gemspec
deleted file mode 100644
index 3a18f9edb6..0000000000
--- a/lib/readline.gemspec
+++ /dev/null
@@ -1,33 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = 'readline'
- spec.version = '0.0.3'
- spec.authors = ['aycabta']
- spec.email = ['aycabta@gmail.com']
-
- spec.summary = %q{Loader for "readline".}
- spec.description = <<~EOD
- This is just a loader for "readline". If Ruby has the "readline-ext" gem
- that is a native extension, this gem will load it. If Ruby does not have
- the "readline-ext" gem this gem will load "reline", a library that is
- compatible with the "readline-ext" gem and implemented in pure Ruby.
- EOD
- spec.homepage = 'https://github.com/ruby/readline'
- spec.license = 'Ruby'
-
- spec.files = Dir['BSDL', 'COPYING', 'README.md', 'lib/readline.rb']
- spec.require_paths = ['lib']
-
- spec.post_install_message = <<~EOM
- +---------------------------------------------------------------------------+
- | This is just a loader for "readline". If Ruby has the "readline-ext" gem |
- | that is a native extension, this gem will load it. If Ruby does not have |
- | the "readline-ext" gem this gem will load "reline", a library that is |
- | compatible with the "readline-ext" gem and implemented in pure Ruby. |
- | |
- | If you intend to use GNU Readline by `require 'readline'`, please install |
- | the "readline-ext" gem. |
- +---------------------------------------------------------------------------+
- EOM
-
- spec.add_runtime_dependency 'reline'
-end
diff --git a/lib/readline.rb b/lib/readline.rb
deleted file mode 100644
index 29cdf3a14f..0000000000
--- a/lib/readline.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-begin
- require 'readline.so'
-rescue LoadError
- require 'reline' unless defined? Reline
- Object.send(:remove_const, :Readline) if Object.const_defined?(:Readline)
- Readline = Reline
-end
diff --git a/lib/reline.rb b/lib/reline.rb
deleted file mode 100644
index 210f33478f..0000000000
--- a/lib/reline.rb
+++ /dev/null
@@ -1,603 +0,0 @@
-require 'io/console'
-require 'timeout'
-require 'forwardable'
-require 'reline/version'
-require 'reline/config'
-require 'reline/key_actor'
-require 'reline/key_stroke'
-require 'reline/line_editor'
-require 'reline/history'
-require 'reline/terminfo'
-require 'rbconfig'
-
-module Reline
- # NOTE: For making compatible with the rb-readline gem
- FILENAME_COMPLETION_PROC = nil
- USERNAME_COMPLETION_PROC = nil
-
- class ConfigEncodingConversionError < StandardError; end
-
- Key = Struct.new('Key', :char, :combined_char, :with_meta) do
- def match?(other)
- case other
- when Reline::Key
- (other.char.nil? or char.nil? or char == other.char) and
- (other.combined_char.nil? or combined_char.nil? or combined_char == other.combined_char) and
- (other.with_meta.nil? or with_meta.nil? or with_meta == other.with_meta)
- when Integer, Symbol
- (combined_char and combined_char == other) or
- (combined_char.nil? and char and char == other)
- else
- false
- end
- end
- alias_method :==, :match?
- end
- CursorPos = Struct.new(:x, :y)
- DialogRenderInfo = Struct.new(
- :pos,
- :contents,
- :bg_color,
- :pointer_bg_color,
- :fg_color,
- :pointer_fg_color,
- :width,
- :height,
- :scrollbar,
- keyword_init: true
- )
-
- class Core
- ATTR_READER_NAMES = %i(
- completion_append_character
- basic_word_break_characters
- completer_word_break_characters
- basic_quote_characters
- completer_quote_characters
- filename_quote_characters
- special_prefixes
- completion_proc
- output_modifier_proc
- prompt_proc
- auto_indent_proc
- pre_input_hook
- dig_perfect_match_proc
- ).each(&method(:attr_reader))
-
- attr_accessor :config
- attr_accessor :key_stroke
- attr_accessor :line_editor
- attr_accessor :last_incremental_search
- attr_reader :output
-
- extend Forwardable
- def_delegators :config,
- :autocompletion,
- :autocompletion=
-
- def initialize
- self.output = STDOUT
- @dialog_proc_list = {}
- yield self
- @completion_quote_character = nil
- @bracketed_paste_finished = false
- end
-
- def encoding
- Reline::IOGate.encoding
- end
-
- def completion_append_character=(val)
- if val.nil?
- @completion_append_character = nil
- elsif val.size == 1
- @completion_append_character = val.encode(Reline::IOGate.encoding)
- elsif val.size > 1
- @completion_append_character = val[0].encode(Reline::IOGate.encoding)
- else
- @completion_append_character = nil
- end
- end
-
- def basic_word_break_characters=(v)
- @basic_word_break_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def completer_word_break_characters=(v)
- @completer_word_break_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def basic_quote_characters=(v)
- @basic_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def completer_quote_characters=(v)
- @completer_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def filename_quote_characters=(v)
- @filename_quote_characters = v.encode(Reline::IOGate.encoding)
- end
-
- def special_prefixes=(v)
- @special_prefixes = v.encode(Reline::IOGate.encoding)
- end
-
- def completion_case_fold=(v)
- @config.completion_ignore_case = v
- end
-
- def completion_case_fold
- @config.completion_ignore_case
- end
-
- def completion_quote_character
- @completion_quote_character
- end
-
- def completion_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @completion_proc = p
- end
-
- def output_modifier_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @output_modifier_proc = p
- end
-
- def prompt_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @prompt_proc = p
- end
-
- def auto_indent_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @auto_indent_proc = p
- end
-
- def pre_input_hook=(p)
- @pre_input_hook = p
- end
-
- def dig_perfect_match_proc=(p)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- @dig_perfect_match_proc = p
- end
-
- DialogProc = Struct.new(:dialog_proc, :context)
- def add_dialog_proc(name_sym, p, context = nil)
- raise ArgumentError unless p.respond_to?(:call) or p.nil?
- raise ArgumentError unless name_sym.instance_of?(Symbol)
- @dialog_proc_list[name_sym] = DialogProc.new(p, context)
- end
-
- def dialog_proc(name_sym)
- @dialog_proc_list[name_sym]
- end
-
- def input=(val)
- raise TypeError unless val.respond_to?(:getc) or val.nil?
- if val.respond_to?(:getc)
- if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
- Reline::ANSI.input = val
- elsif Reline::IOGate == Reline::GeneralIO
- Reline::GeneralIO.input = val
- end
- end
- end
-
- def output=(val)
- raise TypeError unless val.respond_to?(:write) or val.nil?
- @output = val
- if defined?(Reline::ANSI) and Reline::IOGate == Reline::ANSI
- Reline::ANSI.output = val
- end
- end
-
- def vi_editing_mode
- config.editing_mode = :vi_insert
- nil
- end
-
- def emacs_editing_mode
- config.editing_mode = :emacs
- nil
- end
-
- def vi_editing_mode?
- config.editing_mode_is?(:vi_insert, :vi_command)
- end
-
- def emacs_editing_mode?
- config.editing_mode_is?(:emacs)
- end
-
- def get_screen_size
- Reline::IOGate.get_screen_size
- end
-
- Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() {
- # autocomplete
- return nil unless config.autocompletion
- if just_cursor_moving and completion_journey_data.nil?
- # Auto complete starts only when edited
- return nil
- end
- pre, target, post = retrieve_completion_block(true)
- if target.nil? or target.empty? or (completion_journey_data&.pointer == -1 and target.size <= 3)
- return nil
- end
- if completion_journey_data and completion_journey_data.list
- result = completion_journey_data.list.dup
- result.shift
- pointer = completion_journey_data.pointer - 1
- else
- result = call_completion_proc_with_checking_args(pre, target, post)
- pointer = nil
- end
- if result and result.size == 1 and result[0] == target and pointer != 0
- result = nil
- end
- target_width = Reline::Unicode.calculate_width(target)
- x = cursor_pos.x - target_width
- if x < 0
- x = screen_width + x
- y = -1
- else
- y = 0
- end
- cursor_pos_to_render = Reline::CursorPos.new(x, y)
- if context and context.is_a?(Array)
- context.clear
- context.push(cursor_pos_to_render, result, pointer, dialog)
- end
- dialog.pointer = pointer
- DialogRenderInfo.new(
- pos: cursor_pos_to_render,
- contents: result,
- scrollbar: true,
- height: 15,
- bg_color: 46,
- pointer_bg_color: 45,
- fg_color: 37,
- pointer_fg_color: 37
- )
- }
- Reline::DEFAULT_DIALOG_CONTEXT = Array.new
-
- def readmultiline(prompt = '', add_hist = false, &confirm_multiline_termination)
- Reline::IOGate.with_raw_input do
- unless confirm_multiline_termination
- raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
- end
- inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
-
- whole_buffer = line_editor.whole_buffer.dup
- whole_buffer.taint if RUBY_VERSION < '2.7'
- if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
- Reline::HISTORY << whole_buffer
- end
-
- line_editor.reset_line if line_editor.whole_buffer.nil?
- whole_buffer
- end
- end
-
- def readline(prompt = '', add_hist = false)
- inner_readline(prompt, add_hist, false)
-
- line = line_editor.line.dup
- line.taint if RUBY_VERSION < '2.7'
- if add_hist and line and line.chomp("\n").size > 0
- Reline::HISTORY << line.chomp("\n")
- end
-
- line_editor.reset_line if line_editor.line.nil?
- line
- end
-
- private def inner_readline(prompt, add_hist, multiline, &confirm_multiline_termination)
- if ENV['RELINE_STDERR_TTY']
- if Reline::IOGate.win?
- $stderr = File.open(ENV['RELINE_STDERR_TTY'], 'a')
- else
- $stderr.reopen(ENV['RELINE_STDERR_TTY'], 'w')
- end
- $stderr.sync = true
- $stderr.puts "Reline is used by #{Process.pid}"
- end
- otio = Reline::IOGate.prep
-
- may_req_ambiguous_char_width
- line_editor.reset(prompt, encoding: Reline::IOGate.encoding)
- if multiline
- line_editor.multiline_on
- if block_given?
- line_editor.confirm_multiline_termination_proc = confirm_multiline_termination
- end
- else
- line_editor.multiline_off
- end
- line_editor.output = output
- line_editor.completion_proc = completion_proc
- line_editor.completion_append_character = completion_append_character
- line_editor.output_modifier_proc = output_modifier_proc
- line_editor.prompt_proc = prompt_proc
- line_editor.auto_indent_proc = auto_indent_proc
- line_editor.dig_perfect_match_proc = dig_perfect_match_proc
- line_editor.pre_input_hook = pre_input_hook
- @dialog_proc_list.each_pair do |name_sym, d|
- line_editor.add_dialog_proc(name_sym, d.dialog_proc, d.context)
- end
-
- unless config.test_mode
- config.read
- config.reset_default_key_bindings
- Reline::IOGate.set_default_key_bindings(config)
- end
-
- line_editor.rerender
-
- begin
- line_editor.set_signal_handlers
- prev_pasting_state = false
- loop do
- prev_pasting_state = Reline::IOGate.in_pasting?
- read_io(config.keyseq_timeout) { |inputs|
- line_editor.set_pasting_state(Reline::IOGate.in_pasting?)
- inputs.each { |c|
- line_editor.input_key(c)
- line_editor.rerender
- }
- if @bracketed_paste_finished
- line_editor.rerender_all
- @bracketed_paste_finished = false
- end
- }
- if prev_pasting_state == true and not Reline::IOGate.in_pasting? and not line_editor.finished?
- line_editor.set_pasting_state(false)
- prev_pasting_state = false
- line_editor.rerender_all
- end
- break if line_editor.finished?
- end
- Reline::IOGate.move_cursor_column(0)
- rescue Errno::EIO
- # Maybe the I/O has been closed.
- rescue StandardError => e
- line_editor.finalize
- Reline::IOGate.deprep(otio)
- raise e
- rescue Exception
- # Including Interrupt
- line_editor.finalize
- Reline::IOGate.deprep(otio)
- raise
- end
-
- line_editor.finalize
- Reline::IOGate.deprep(otio)
- end
-
- # GNU Readline waits for "keyseq-timeout" milliseconds to see if the ESC
- # is followed by a character, and times out and treats it as a standalone
- # ESC if the second character does not arrive. If the second character
- # comes before timed out, it is treated as a modifier key with the
- # meta-property of meta-key, so that it can be distinguished from
- # multibyte characters with the 8th bit turned on.
- #
- # GNU Readline will wait for the 2nd character with "keyseq-timeout"
- # milli-seconds but wait forever after 3rd characters.
- private def read_io(keyseq_timeout, &block)
- buffer = []
- loop do
- c = Reline::IOGate.getc
- if c == -1
- result = :unmatched
- @bracketed_paste_finished = true
- else
- buffer << c
- result = key_stroke.match_status(buffer)
- end
- case result
- when :matched
- expanded = key_stroke.expand(buffer).map{ |expanded_c|
- Reline::Key.new(expanded_c, expanded_c, false)
- }
- block.(expanded)
- break
- when :matching
- if buffer.size == 1
- case read_2nd_character_of_key_sequence(keyseq_timeout, buffer, c, block)
- when :break then break
- when :next then next
- end
- end
- when :unmatched
- if buffer.size == 1 and c == "\e".ord
- read_escaped_key(keyseq_timeout, c, block)
- else
- expanded = buffer.map{ |expanded_c|
- Reline::Key.new(expanded_c, expanded_c, false)
- }
- block.(expanded)
- end
- break
- end
- end
- end
-
- private def read_2nd_character_of_key_sequence(keyseq_timeout, buffer, c, block)
- begin
- succ_c = nil
- Timeout.timeout(keyseq_timeout / 1000.0) {
- succ_c = Reline::IOGate.getc
- }
- rescue Timeout::Error # cancel matching only when first byte
- block.([Reline::Key.new(c, c, false)])
- return :break
- else
- case key_stroke.match_status(buffer.dup.push(succ_c))
- when :unmatched
- if c == "\e".ord
- block.([Reline::Key.new(succ_c, succ_c | 0b10000000, true)])
- else
- block.([Reline::Key.new(c, c, false), Reline::Key.new(succ_c, succ_c, false)])
- end
- return :break
- when :matching
- Reline::IOGate.ungetc(succ_c)
- return :next
- when :matched
- buffer << succ_c
- expanded = key_stroke.expand(buffer).map{ |expanded_c|
- Reline::Key.new(expanded_c, expanded_c, false)
- }
- block.(expanded)
- return :break
- end
- end
- end
-
- private def read_escaped_key(keyseq_timeout, c, block)
- begin
- escaped_c = nil
- Timeout.timeout(keyseq_timeout / 1000.0) {
- escaped_c = Reline::IOGate.getc
- }
- rescue Timeout::Error # independent ESC
- block.([Reline::Key.new(c, c, false)])
- else
- if escaped_c.nil?
- block.([Reline::Key.new(c, c, false)])
- elsif escaped_c >= 128 # maybe, first byte of multi byte
- block.([Reline::Key.new(c, c, false), Reline::Key.new(escaped_c, escaped_c, false)])
- elsif escaped_c == "\e".ord # escape twice
- block.([Reline::Key.new(c, c, false), Reline::Key.new(c, c, false)])
- else
- block.([Reline::Key.new(escaped_c, escaped_c | 0b10000000, true)])
- end
- end
- end
-
- def ambiguous_width
- may_req_ambiguous_char_width unless defined? @ambiguous_width
- @ambiguous_width
- end
-
- private def may_req_ambiguous_char_width
- @ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or !STDOUT.tty?
- return if defined? @ambiguous_width
- Reline::IOGate.move_cursor_column(0)
- begin
- output.write "\u{25bd}"
- rescue Encoding::UndefinedConversionError
- # LANG=C
- @ambiguous_width = 1
- else
- @ambiguous_width = Reline::IOGate.cursor_pos.x
- end
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- end
- end
-
- extend Forwardable
- extend SingleForwardable
-
- #--------------------------------------------------------
- # Documented API
- #--------------------------------------------------------
-
- (Core::ATTR_READER_NAMES).each { |name|
- def_single_delegators :core, :"#{name}", :"#{name}="
- }
- def_single_delegators :core, :input=, :output=
- def_single_delegators :core, :vi_editing_mode, :emacs_editing_mode
- def_single_delegators :core, :readline
- def_single_delegators :core, :completion_case_fold, :completion_case_fold=
- def_single_delegators :core, :completion_quote_character
- def_instance_delegators self, :readline
- private :readline
-
-
- #--------------------------------------------------------
- # Undocumented API
- #--------------------------------------------------------
-
- # Testable in original
- def_single_delegators :core, :get_screen_size
- def_single_delegators :line_editor, :eof?
- def_instance_delegators self, :eof?
- def_single_delegators :line_editor, :delete_text
- def_single_delegator :line_editor, :line, :line_buffer
- def_single_delegator :line_editor, :byte_pointer, :point
- def_single_delegator :line_editor, :byte_pointer=, :point=
-
- def self.insert_text(*args, &block)
- line_editor.insert_text(*args, &block)
- self
- end
-
- # Untestable in original
- def_single_delegator :line_editor, :rerender, :redisplay
- def_single_delegators :core, :vi_editing_mode?, :emacs_editing_mode?
- def_single_delegators :core, :ambiguous_width
- def_single_delegators :core, :last_incremental_search
- def_single_delegators :core, :last_incremental_search=
- def_single_delegators :core, :add_dialog_proc
- def_single_delegators :core, :dialog_proc
- def_single_delegators :core, :autocompletion, :autocompletion=
-
- def_single_delegators :core, :readmultiline
- def_instance_delegators self, :readmultiline
- private :readmultiline
-
- def self.encoding_system_needs
- self.core.encoding
- end
-
- def self.core
- @core ||= Core.new { |core|
- core.config = Reline::Config.new
- core.key_stroke = Reline::KeyStroke.new(core.config)
- core.line_editor = Reline::LineEditor.new(core.config, Reline::IOGate.encoding)
-
- core.basic_word_break_characters = " \t\n`><=;|&{("
- core.completer_word_break_characters = " \t\n`><=;|&{("
- core.basic_quote_characters = '"\''
- core.completer_quote_characters = '"\''
- core.filename_quote_characters = ""
- core.special_prefixes = ""
- core.add_dialog_proc(:autocomplete, Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE, Reline::DEFAULT_DIALOG_CONTEXT)
- }
- end
-
- def self.ungetc(c)
- Reline::IOGate.ungetc(c)
- end
-
- def self.line_editor
- core.line_editor
- end
-end
-
-require 'reline/general_io'
-io = Reline::GeneralIO
-unless ENV['TERM'] == 'dumb'
- case RbConfig::CONFIG['host_os']
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
- require 'reline/windows'
- tty = (io = Reline::Windows).msys_tty?
- else
- tty = $stdout.tty?
- end
-end
-Reline::IOGate = if tty
- require 'reline/ansi'
- Reline::ANSI
-else
- io
-end
-
-Reline::HISTORY = Reline::History.new(Reline.core.config)
diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
deleted file mode 100644
index 42a3913387..0000000000
--- a/lib/reline/ansi.rb
+++ /dev/null
@@ -1,355 +0,0 @@
-require 'io/console'
-require 'io/wait'
-require 'timeout'
-require_relative 'terminfo'
-
-class Reline::ANSI
- CAPNAME_KEY_BINDINGS = {
- 'khome' => :ed_move_to_beg,
- 'kend' => :ed_move_to_end,
- 'kdch1' => :key_delete,
- 'kcuu1' => :ed_prev_history,
- 'kcud1' => :ed_next_history,
- 'kcuf1' => :ed_next_char,
- 'kcub1' => :ed_prev_char,
- 'cuu' => :ed_prev_history,
- 'cud' => :ed_next_history,
- 'cuf' => :ed_next_char,
- 'cub' => :ed_prev_char,
- }
-
- if Reline::Terminfo.enabled?
- Reline::Terminfo.setupterm(0, 2)
- end
-
- def self.encoding
- Encoding.default_external
- end
-
- def self.win?
- false
- end
-
- def self.set_default_key_bindings(config, allow_terminfo: true)
- if allow_terminfo && Reline::Terminfo.enabled?
- set_default_key_bindings_terminfo(config)
- else
- set_default_key_bindings_comprehensive_list(config)
- end
- {
- # extended entries of terminfo
- [27, 91, 49, 59, 53, 67] => :em_next_word, # Ctrl+→, extended entry
- [27, 91, 49, 59, 53, 68] => :ed_prev_word, # Ctrl+â†, extended entry
- [27, 91, 49, 59, 51, 67] => :em_next_word, # Meta+→, extended entry
- [27, 91, 49, 59, 51, 68] => :ed_prev_word, # Meta+â†, extended entry
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- config.add_default_key_binding_by_keymap(:vi_command, key, func)
- end
- {
- [27, 91, 90] => :completion_journey_up, # S-Tab
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- end
- {
- # default bindings
- [27, 32] => :em_set_mark, # M-<space>
- [24, 24] => :em_exchange_mark, # C-x C-x
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- end
- end
-
- def self.set_default_key_bindings_terminfo(config)
- key_bindings = CAPNAME_KEY_BINDINGS.map do |capname, key_binding|
- begin
- key_code = Reline::Terminfo.tigetstr(capname)
- case capname
- # Escape sequences that omit the move distance and are set to defaults
- # value 1 may be sometimes sent by pressing the arrow-key.
- when 'cuu', 'cud', 'cuf', 'cub'
- [ key_code.sub(/%p1%d/, '').bytes, key_binding ]
- else
- [ key_code.bytes, key_binding ]
- end
- rescue Reline::Terminfo::TerminfoError
- # capname is undefined
- end
- end.compact.to_h
-
- key_bindings.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- config.add_default_key_binding_by_keymap(:vi_command, key, func)
- end
- end
-
- def self.set_default_key_bindings_comprehensive_list(config)
- {
- # Console (80x25)
- [27, 91, 49, 126] => :ed_move_to_beg, # Home
- [27, 91, 52, 126] => :ed_move_to_end, # End
- [27, 91, 51, 126] => :key_delete, # Del
- [27, 91, 65] => :ed_prev_history, # ↑
- [27, 91, 66] => :ed_next_history, # ↓
- [27, 91, 67] => :ed_next_char, # →
- [27, 91, 68] => :ed_prev_char, # â†
-
- # KDE
- [27, 91, 72] => :ed_move_to_beg, # Home
- [27, 91, 70] => :ed_move_to_end, # End
- # Del is 0x08
- [27, 71, 65] => :ed_prev_history, # ↑
- [27, 71, 66] => :ed_next_history, # ↓
- [27, 71, 67] => :ed_next_char, # →
- [27, 71, 68] => :ed_prev_char, # â†
-
- # urxvt / exoterm
- [27, 91, 55, 126] => :ed_move_to_beg, # Home
- [27, 91, 56, 126] => :ed_move_to_end, # End
-
- # GNOME
- [27, 79, 72] => :ed_move_to_beg, # Home
- [27, 79, 70] => :ed_move_to_end, # End
- # Del is 0x08
- # Arrow keys are the same of KDE
-
- # iTerm2
- [27, 27, 91, 67] => :em_next_word, # Option+→, extended entry
- [27, 27, 91, 68] => :ed_prev_word, # Option+â†, extended entry
- [195, 166] => :em_next_word, # Option+f
- [195, 162] => :ed_prev_word, # Option+b
-
- [27, 79, 65] => :ed_prev_history, # ↑
- [27, 79, 66] => :ed_next_history, # ↓
- [27, 79, 67] => :ed_next_char, # →
- [27, 79, 68] => :ed_prev_char, # â†
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- config.add_default_key_binding_by_keymap(:vi_command, key, func)
- end
- end
-
- @@input = STDIN
- def self.input=(val)
- @@input = val
- end
-
- @@output = STDOUT
- def self.output=(val)
- @@output = val
- end
-
- def self.with_raw_input
- @@input.raw { yield }
- end
-
- @@buf = []
- def self.inner_getc
- unless @@buf.empty?
- return @@buf.shift
- end
- until c = @@input.raw(intr: true) { @@input.wait_readable(0.1) && @@input.getbyte }
- Reline.core.line_editor.resize
- end
- (c == 0x16 && @@input.raw(min: 0, time: 0, &:getbyte)) || c
- rescue Errno::EIO
- # Maybe the I/O has been closed.
- nil
- rescue Errno::ENOTTY
- nil
- end
-
- @@in_bracketed_paste_mode = false
- START_BRACKETED_PASTE = String.new("\e[200~,", encoding: Encoding::ASCII_8BIT)
- END_BRACKETED_PASTE = String.new("\e[200~.", encoding: Encoding::ASCII_8BIT)
- def self.getc_with_bracketed_paste
- buffer = String.new(encoding: Encoding::ASCII_8BIT)
- buffer << inner_getc
- while START_BRACKETED_PASTE.start_with?(buffer) or END_BRACKETED_PASTE.start_with?(buffer) do
- if START_BRACKETED_PASTE == buffer
- @@in_bracketed_paste_mode = true
- return inner_getc
- elsif END_BRACKETED_PASTE == buffer
- @@in_bracketed_paste_mode = false
- ungetc(-1)
- return inner_getc
- end
- begin
- succ_c = nil
- Timeout.timeout(Reline.core.config.keyseq_timeout * 100) {
- succ_c = inner_getc
- }
- rescue Timeout::Error
- break
- else
- buffer << succ_c
- end
- end
- buffer.bytes.reverse_each do |ch|
- ungetc ch
- end
- inner_getc
- end
-
- def self.getc
- if Reline.core.config.enable_bracketed_paste
- getc_with_bracketed_paste
- else
- inner_getc
- end
- end
-
- def self.in_pasting?
- @@in_bracketed_paste_mode or (not Reline::IOGate.empty_buffer?)
- end
-
- def self.empty_buffer?
- unless @@buf.empty?
- return false
- end
- !@@input.wait_readable(0)
- end
-
- def self.ungetc(c)
- @@buf.unshift(c)
- end
-
- def self.retrieve_keybuffer
- begin
- return unless @@input.wait_readable(0.001)
- str = @@input.read_nonblock(1024)
- str.bytes.each do |c|
- @@buf.push(c)
- end
- rescue EOFError
- end
- end
-
- def self.get_screen_size
- s = @@input.winsize
- return s if s[0] > 0 && s[1] > 0
- s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]
- return s if s[0] > 0 && s[1] > 0
- [24, 80]
- rescue Errno::ENOTTY
- [24, 80]
- end
-
- def self.set_screen_size(rows, columns)
- @@input.winsize = [rows, columns]
- self
- rescue Errno::ENOTTY
- self
- end
-
- def self.cursor_pos
- begin
- res = +''
- m = nil
- @@input.raw do |stdin|
- @@output << "\e[6n"
- @@output.flush
- loop do
- c = stdin.getc
- next if c.nil?
- res << c
- m = res.match(/\e\[(?<row>\d+);(?<column>\d+)R/)
- break if m
- end
- (m.pre_match + m.post_match).chars.reverse_each do |ch|
- stdin.ungetc ch
- end
- end
- column = m[:column].to_i - 1
- row = m[:row].to_i - 1
- rescue Errno::ENOTTY
- begin
- buf = @@output.pread(@@output.pos, 0)
- row = buf.count("\n")
- column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
- rescue Errno::ESPIPE
- # Just returns column 1 for ambiguous width because this I/O is not
- # tty and can't seek.
- row = 0
- column = 1
- end
- end
- Reline::CursorPos.new(column, row)
- end
-
- def self.move_cursor_column(x)
- @@output.write "\e[#{x + 1}G"
- end
-
- def self.move_cursor_up(x)
- if x > 0
- @@output.write "\e[#{x}A"
- elsif x < 0
- move_cursor_down(-x)
- end
- end
-
- def self.move_cursor_down(x)
- if x > 0
- @@output.write "\e[#{x}B"
- elsif x < 0
- move_cursor_up(-x)
- end
- end
-
- def self.hide_cursor
- if Reline::Terminfo.enabled?
- begin
- @@output.write Reline::Terminfo.tigetstr('civis')
- rescue Reline::Terminfo::TerminfoError
- # civis is undefined
- end
- else
- # ignored
- end
- end
-
- def self.show_cursor
- if Reline::Terminfo.enabled?
- begin
- @@output.write Reline::Terminfo.tigetstr('cnorm')
- rescue Reline::Terminfo::TerminfoError
- # cnorm is undefined
- end
- else
- # ignored
- end
- end
-
- def self.erase_after_cursor
- @@output.write "\e[K"
- end
-
- def self.scroll_down(x)
- return if x.zero?
- @@output.write "\e[#{x}S"
- end
-
- def self.clear_screen
- @@output.write "\e[2J"
- @@output.write "\e[1;1H"
- end
-
- @@old_winch_handler = nil
- def self.set_winch_handler(&handler)
- @@old_winch_handler = Signal.trap('WINCH', &handler)
- end
-
- def self.prep
- retrieve_keybuffer
- nil
- end
-
- def self.deprep(otio)
- Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
- end
-end
diff --git a/lib/reline/config.rb b/lib/reline/config.rb
deleted file mode 100644
index 87726393a6..0000000000
--- a/lib/reline/config.rb
+++ /dev/null
@@ -1,401 +0,0 @@
-class Reline::Config
- attr_reader :test_mode
-
- KEYSEQ_PATTERN = /\\(?:C|Control)-[A-Za-z_]|\\(?:M|Meta)-[0-9A-Za-z_]|\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]|\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]|\\e|\\[\\\"\'abdfnrtv]|\\\d{1,3}|\\x\h{1,2}|./
-
- class InvalidInputrc < RuntimeError
- attr_accessor :file, :lineno
- end
-
- VARIABLE_NAMES = %w{
- bind-tty-special-chars
- blink-matching-paren
- byte-oriented
- completion-ignore-case
- convert-meta
- disable-completion
- enable-keypad
- expand-tilde
- history-preserve-point
- history-size
- horizontal-scroll-mode
- input-meta
- keyseq-timeout
- mark-directories
- mark-modified-lines
- mark-symlinked-directories
- match-hidden-files
- meta-flag
- output-meta
- page-completions
- prefer-visible-bell
- print-completions-horizontally
- show-all-if-ambiguous
- show-all-if-unmodified
- visible-stats
- show-mode-in-prompt
- vi-cmd-mode-string
- vi-ins-mode-string
- emacs-mode-string
- enable-bracketed-paste
- isearch-terminators
- }
- VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES.map { |v| :"#{v.tr(?-, ?_)}" }
- VARIABLE_NAME_SYMBOLS.each do |v|
- attr_accessor v
- end
-
- attr_accessor :autocompletion
-
- def initialize
- @additional_key_bindings = {} # from inputrc
- @additional_key_bindings[:emacs] = {}
- @additional_key_bindings[:vi_insert] = {}
- @additional_key_bindings[:vi_command] = {}
- @oneshot_key_bindings = {}
- @skip_section = nil
- @if_stack = nil
- @editing_mode_label = :emacs
- @keymap_label = :emacs
- @keymap_prefix = []
- @key_actors = {}
- @key_actors[:emacs] = Reline::KeyActor::Emacs.new
- @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new
- @key_actors[:vi_command] = Reline::KeyActor::ViCommand.new
- @vi_cmd_mode_string = '(cmd)'
- @vi_ins_mode_string = '(ins)'
- @emacs_mode_string = '@'
- # https://tiswww.case.edu/php/chet/readline/readline.html#IDX25
- @history_size = -1 # unlimited
- @keyseq_timeout = 500
- @test_mode = false
- @autocompletion = false
- @convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
- end
-
- def reset
- if editing_mode_is?(:vi_command)
- @editing_mode_label = :vi_insert
- end
- @additional_key_bindings.keys.each do |key|
- @additional_key_bindings[key].clear
- end
- @oneshot_key_bindings.clear
- reset_default_key_bindings
- end
-
- def editing_mode
- @key_actors[@editing_mode_label]
- end
-
- def editing_mode=(val)
- @editing_mode_label = val
- end
-
- def editing_mode_is?(*val)
- val.any?(@editing_mode_label)
- end
-
- def keymap
- @key_actors[@keymap_label]
- end
-
- def inputrc_path
- case ENV['INPUTRC']
- when nil, ''
- else
- return File.expand_path(ENV['INPUTRC'])
- end
-
- # In the XDG Specification, if ~/.config/readline/inputrc exists, then
- # ~/.inputrc should not be read, but for compatibility with GNU Readline,
- # if ~/.inputrc exists, then it is given priority.
- home_rc_path = File.expand_path('~/.inputrc')
- return home_rc_path if File.exist?(home_rc_path)
-
- case path = ENV['XDG_CONFIG_HOME']
- when nil, ''
- else
- path = File.join(path, 'readline/inputrc')
- return path if File.exist?(path) and path == File.expand_path(path)
- end
-
- path = File.expand_path('~/.config/readline/inputrc')
- return path if File.exist?(path)
-
- return home_rc_path
- end
-
- private def default_inputrc_path
- @default_inputrc_path ||= inputrc_path
- end
-
- def read(file = nil)
- file ||= default_inputrc_path
- begin
- if file.respond_to?(:readlines)
- lines = file.readlines
- else
- lines = File.readlines(file)
- end
- rescue Errno::ENOENT
- return nil
- end
-
- read_lines(lines, file)
- self
- rescue InvalidInputrc => e
- warn e.message
- nil
- end
-
- def key_bindings
- # The key bindings for each editing mode will be overwritten by the user-defined ones.
- kb = @key_actors[@editing_mode_label].default_key_bindings.dup
- kb.merge!(@additional_key_bindings[@editing_mode_label])
- kb.merge!(@oneshot_key_bindings)
- kb
- end
-
- def add_oneshot_key_binding(keystroke, target)
- @oneshot_key_bindings[keystroke] = target
- end
-
- def reset_oneshot_key_bindings
- @oneshot_key_bindings.clear
- end
-
- def add_default_key_binding_by_keymap(keymap, keystroke, target)
- @key_actors[keymap].default_key_bindings[keystroke] = target
- end
-
- def add_default_key_binding(keystroke, target)
- @key_actors[@keymap_label].default_key_bindings[keystroke] = target
- end
-
- def reset_default_key_bindings
- @key_actors.values.each do |ka|
- ka.reset_default_key_bindings
- end
- end
-
- def read_lines(lines, file = nil)
- if not lines.empty? and lines.first.encoding != Reline.encoding_system_needs
- begin
- lines = lines.map do |l|
- l.encode(Reline.encoding_system_needs)
- rescue Encoding::UndefinedConversionError
- mes = "The inputrc encoded in #{lines.first.encoding.name} can't be converted to the locale #{Reline.encoding_system_needs.name}."
- raise Reline::ConfigEncodingConversionError.new(mes)
- end
- end
- end
- conditions = [@skip_section, @if_stack]
- @skip_section = nil
- @if_stack = []
-
- lines.each_with_index do |line, no|
- next if line.match(/\A\s*#/)
-
- no += 1
-
- line = line.chomp.lstrip
- if line.start_with?('$')
- handle_directive(line[1..-1], file, no)
- next
- end
-
- next if @skip_section
-
- case line
- when /^set +([^ ]+) +([^ ]+)/i
- var, value = $1.downcase, $2
- bind_variable(var, value)
- next
- when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
- key, func_name = $1, $2
- keystroke, func = bind_key(key, func_name)
- next unless keystroke
- @additional_key_bindings[@keymap_label][@keymap_prefix + keystroke] = func
- end
- end
- unless @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{@if_stack.last[1]}: unclosed if"
- end
- ensure
- @skip_section, @if_stack = conditions
- end
-
- def handle_directive(directive, file, no)
- directive, args = directive.split(' ')
- case directive
- when 'if'
- condition = false
- case args
- when 'mode'
- when 'term'
- when 'version'
- else # application name
- condition = true if args == 'Ruby'
- condition = true if args == 'Reline'
- end
- @if_stack << [file, no, @skip_section]
- @skip_section = !condition
- when 'else'
- if @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{no}: unmatched else"
- end
- @skip_section = !@skip_section
- when 'endif'
- if @if_stack.empty?
- raise InvalidInputrc, "#{file}:#{no}: unmatched endif"
- end
- @skip_section = @if_stack.pop
- when 'include'
- read(args)
- end
- end
-
- def bind_variable(name, value)
- case name
- when 'history-size'
- begin
- @history_size = Integer(value)
- rescue ArgumentError
- @history_size = 500
- end
- when 'bell-style'
- @bell_style =
- case value
- when 'none', 'off'
- :none
- when 'audible', 'on'
- :audible
- when 'visible'
- :visible
- else
- :audible
- end
- when 'comment-begin'
- @comment_begin = value.dup
- when 'completion-query-items'
- @completion_query_items = value.to_i
- when 'isearch-terminators'
- @isearch_terminators = retrieve_string(value)
- when 'editing-mode'
- case value
- when 'emacs'
- @editing_mode_label = :emacs
- @keymap_label = :emacs
- @keymap_prefix = []
- when 'vi'
- @editing_mode_label = :vi_insert
- @keymap_label = :vi_insert
- @keymap_prefix = []
- end
- when 'keymap'
- case value
- when 'emacs', 'emacs-standard'
- @keymap_label = :emacs
- @keymap_prefix = []
- when 'emacs-ctlx'
- @keymap_label = :emacs
- @keymap_prefix = [?\C-x.ord]
- when 'emacs-meta'
- @keymap_label = :emacs
- @keymap_prefix = [?\e.ord]
- when 'vi', 'vi-move', 'vi-command'
- @keymap_label = :vi_command
- @keymap_prefix = []
- when 'vi-insert'
- @keymap_label = :vi_insert
- @keymap_prefix = []
- end
- when 'keyseq-timeout'
- @keyseq_timeout = value.to_i
- when 'show-mode-in-prompt'
- case value
- when 'off'
- @show_mode_in_prompt = false
- when 'on'
- @show_mode_in_prompt = true
- else
- @show_mode_in_prompt = false
- end
- when 'vi-cmd-mode-string'
- @vi_cmd_mode_string = retrieve_string(value)
- when 'vi-ins-mode-string'
- @vi_ins_mode_string = retrieve_string(value)
- when 'emacs-mode-string'
- @emacs_mode_string = retrieve_string(value)
- when *VARIABLE_NAMES then
- variable_name = :"@#{name.tr(?-, ?_)}"
- instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on')
- end
- end
-
- def retrieve_string(str)
- str = $1 if str =~ /\A"(.*)"\z/
- parse_keyseq(str).map { |c| c.chr(Reline.encoding_system_needs) }.join
- end
-
- def bind_key(key, func_name)
- if key =~ /\A"(.*)"\z/
- keyseq = parse_keyseq($1)
- else
- keyseq = nil
- end
- if func_name =~ /"(.*)"/
- func = parse_keyseq($1)
- else
- func = func_name.tr(?-, ?_).to_sym # It must be macro.
- end
- [keyseq, func]
- end
-
- def key_notation_to_code(notation)
- case notation
- when /\\(?:C|Control)-([A-Za-z_])/
- (1 + $1.downcase.ord - ?a.ord)
- when /\\(?:M|Meta)-([0-9A-Za-z_])/
- modified_key = $1
- case $1
- when /[0-9]/
- ?\M-0.bytes.first + (modified_key.ord - ?0.ord)
- when /[A-Z]/
- ?\M-A.bytes.first + (modified_key.ord - ?A.ord)
- when /[a-z]/
- ?\M-a.bytes.first + (modified_key.ord - ?a.ord)
- end
- when /\\(?:C|Control)-(?:M|Meta)-[A-Za-z_]/, /\\(?:M|Meta)-(?:C|Control)-[A-Za-z_]/
- # 129 M-^A
- when /\\(\d{1,3})/ then $1.to_i(8) # octal
- when /\\x(\h{1,2})/ then $1.to_i(16) # hexadecimal
- when "\\e" then ?\e.ord
- when "\\\\" then ?\\.ord
- when "\\\"" then ?".ord
- when "\\'" then ?'.ord
- when "\\a" then ?\a.ord
- when "\\b" then ?\b.ord
- when "\\d" then ?\d.ord
- when "\\f" then ?\f.ord
- when "\\n" then ?\n.ord
- when "\\r" then ?\r.ord
- when "\\t" then ?\t.ord
- when "\\v" then ?\v.ord
- else notation.ord
- end
- end
-
- def parse_keyseq(str)
- ret = []
- str.scan(KEYSEQ_PATTERN) do
- ret << key_notation_to_code($&)
- end
- ret
- end
-
- private def seven_bit_encoding?(encoding)
- encoding == Encoding::US_ASCII
- end
-end
diff --git a/lib/reline/general_io.rb b/lib/reline/general_io.rb
deleted file mode 100644
index 9929846568..0000000000
--- a/lib/reline/general_io.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-require 'timeout'
-require 'io/wait'
-
-class Reline::GeneralIO
- def self.reset(encoding: nil)
- @@pasting = false
- @@encoding = encoding
- end
-
- def self.encoding
- if defined?(@@encoding)
- @@encoding
- elsif RUBY_PLATFORM =~ /mswin|mingw/
- Encoding::UTF_8
- else
- Encoding::default_external
- end
- end
-
- def self.win?
- false
- end
-
- def self.set_default_key_bindings(_)
- end
-
- @@buf = []
- @@input = STDIN
-
- def self.input=(val)
- @@input = val
- end
-
- def self.with_raw_input
- yield
- end
-
- def self.getc
- unless @@buf.empty?
- return @@buf.shift
- end
- c = nil
- loop do
- result = @@input.wait_readable(0.1)
- next if result.nil?
- c = @@input.read(1)
- break
- end
- c&.ord
- end
-
- def self.ungetc(c)
- @@buf.unshift(c)
- end
-
- def self.get_screen_size
- [1, 1]
- end
-
- def self.cursor_pos
- Reline::CursorPos.new(1, 1)
- end
-
- def self.hide_cursor
- end
-
- def self.show_cursor
- end
-
- def self.move_cursor_column(val)
- end
-
- def self.move_cursor_up(val)
- end
-
- def self.move_cursor_down(val)
- end
-
- def self.erase_after_cursor
- end
-
- def self.scroll_down(val)
- end
-
- def self.clear_screen
- end
-
- def self.set_screen_size(rows, columns)
- end
-
- def self.set_winch_handler(&handler)
- end
-
- @@pasting = false
-
- def self.in_pasting?
- @@pasting
- end
-
- def self.start_pasting
- @@pasting = true
- end
-
- def self.finish_pasting
- @@pasting = false
- end
-
- def self.prep
- end
-
- def self.deprep(otio)
- end
-end
diff --git a/lib/reline/history.rb b/lib/reline/history.rb
deleted file mode 100644
index 7a1ed6b90b..0000000000
--- a/lib/reline/history.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-class Reline::History < Array
- def initialize(config)
- @config = config
- end
-
- def to_s
- 'HISTORY'
- end
-
- def delete_at(index)
- index = check_index(index)
- super(index)
- end
-
- def [](index)
- index = check_index(index) unless index.is_a?(Range)
- super(index)
- end
-
- def []=(index, val)
- index = check_index(index)
- super(index, String.new(val, encoding: Reline.encoding_system_needs))
- end
-
- def concat(*val)
- val.each do |v|
- push(*v)
- end
- end
-
- def push(*val)
- # If history_size is zero, all histories are dropped.
- return self if @config.history_size.zero?
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- diff = size + val.size - @config.history_size
- if diff > 0
- if diff <= size
- shift(diff)
- else
- diff -= size
- clear
- val.shift(diff)
- end
- end
- end
- super(*(val.map{ |v|
- String.new(v, encoding: Reline.encoding_system_needs)
- }))
- end
-
- def <<(val)
- # If history_size is zero, all histories are dropped.
- return self if @config.history_size.zero?
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- shift if size + 1 > @config.history_size
- end
- super(String.new(val, encoding: Reline.encoding_system_needs))
- end
-
- private def check_index(index)
- index += size if index < 0
- if index < -2147483648 or 2147483647 < index
- raise RangeError.new("integer #{index} too big to convert to `int'")
- end
- # If history_size is negative, history size is unlimited.
- if @config.history_size.positive?
- if index < -@config.history_size or @config.history_size < index
- raise RangeError.new("index=<#{index}>")
- end
- end
- raise IndexError.new("index=<#{index}>") if index < 0 or size <= index
- index
- end
-end
diff --git a/lib/reline/key_actor.rb b/lib/reline/key_actor.rb
deleted file mode 100644
index ebe09d2009..0000000000
--- a/lib/reline/key_actor.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Reline::KeyActor
-end
-
-require 'reline/key_actor/base'
-require 'reline/key_actor/emacs'
-require 'reline/key_actor/vi_command'
-require 'reline/key_actor/vi_insert'
diff --git a/lib/reline/key_actor/base.rb b/lib/reline/key_actor/base.rb
deleted file mode 100644
index a1cd7fb2a1..0000000000
--- a/lib/reline/key_actor/base.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class Reline::KeyActor::Base
- MAPPING = Array.new(256)
-
- def get_method(key)
- self.class::MAPPING[key]
- end
-
- def initialize
- @default_key_bindings = {}
- end
-
- def default_key_bindings
- @default_key_bindings
- end
-
- def reset_default_key_bindings
- @default_key_bindings.clear
- end
-end
diff --git a/lib/reline/key_actor/emacs.rb b/lib/reline/key_actor/emacs.rb
deleted file mode 100644
index a561feee57..0000000000
--- a/lib/reline/key_actor/emacs.rb
+++ /dev/null
@@ -1,517 +0,0 @@
-class Reline::KeyActor::Emacs < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :em_set_mark,
- # 1 ^A
- :ed_move_to_beg,
- # 2 ^B
- :ed_prev_char,
- # 3 ^C
- :ed_ignore,
- # 4 ^D
- :em_delete,
- # 5 ^E
- :ed_move_to_end,
- # 6 ^F
- :ed_next_char,
- # 7 ^G
- :ed_unassigned,
- # 8 ^H
- :em_delete_prev_char,
- # 9 ^I
- :ed_unassigned,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_kill_line,
- # 12 ^L
- :ed_clear_screen,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_next_history,
- # 15 ^O
- :ed_ignore,
- # 16 ^P
- :ed_prev_history,
- # 17 ^Q
- :ed_quoted_insert,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :vi_search_next,
- # 20 ^T
- :ed_transpose_chars,
- # 21 ^U
- :unix_line_discard,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :em_kill_region,
- # 24 ^X
- :ed_sequence_lead_in,
- # 25 ^Y
- :em_yank,
- # 26 ^Z
- :ed_ignore,
- # 27 ^[
- :em_meta_next,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_ignore,
- # 30 ^^
- :ed_unassigned,
- # 31 ^_
- :ed_unassigned,
- # 32 SPACE
- :ed_insert,
- # 33 !
- :ed_insert,
- # 34 "
- :ed_insert,
- # 35 #
- :ed_insert,
- # 36 $
- :ed_insert,
- # 37 %
- :ed_insert,
- # 38 &
- :ed_insert,
- # 39 '
- :ed_insert,
- # 40 (
- :ed_insert,
- # 41 )
- :ed_insert,
- # 42 *
- :ed_insert,
- # 43 +
- :ed_insert,
- # 44 ,
- :ed_insert,
- # 45 -
- :ed_insert,
- # 46 .
- :ed_insert,
- # 47 /
- :ed_insert,
- # 48 0
- :ed_digit,
- # 49 1
- :ed_digit,
- # 50 2
- :ed_digit,
- # 51 3
- :ed_digit,
- # 52 4
- :ed_digit,
- # 53 5
- :ed_digit,
- # 54 6
- :ed_digit,
- # 55 7
- :ed_digit,
- # 56 8
- :ed_digit,
- # 57 9
- :ed_digit,
- # 58 :
- :ed_insert,
- # 59 ;
- :ed_insert,
- # 60 <
- :ed_insert,
- # 61 =
- :ed_insert,
- # 62 >
- :ed_insert,
- # 63 ?
- :ed_insert,
- # 64 @
- :ed_insert,
- # 65 A
- :ed_insert,
- # 66 B
- :ed_insert,
- # 67 C
- :ed_insert,
- # 68 D
- :ed_insert,
- # 69 E
- :ed_insert,
- # 70 F
- :ed_insert,
- # 71 G
- :ed_insert,
- # 72 H
- :ed_insert,
- # 73 I
- :ed_insert,
- # 74 J
- :ed_insert,
- # 75 K
- :ed_insert,
- # 76 L
- :ed_insert,
- # 77 M
- :ed_insert,
- # 78 N
- :ed_insert,
- # 79 O
- :ed_insert,
- # 80 P
- :ed_insert,
- # 81 Q
- :ed_insert,
- # 82 R
- :ed_insert,
- # 83 S
- :ed_insert,
- # 84 T
- :ed_insert,
- # 85 U
- :ed_insert,
- # 86 V
- :ed_insert,
- # 87 W
- :ed_insert,
- # 88 X
- :ed_insert,
- # 89 Y
- :ed_insert,
- # 90 Z
- :ed_insert,
- # 91 [
- :ed_insert,
- # 92 \
- :ed_insert,
- # 93 ]
- :ed_insert,
- # 94 ^
- :ed_insert,
- # 95 _
- :ed_insert,
- # 96 `
- :ed_insert,
- # 97 a
- :ed_insert,
- # 98 b
- :ed_insert,
- # 99 c
- :ed_insert,
- # 100 d
- :ed_insert,
- # 101 e
- :ed_insert,
- # 102 f
- :ed_insert,
- # 103 g
- :ed_insert,
- # 104 h
- :ed_insert,
- # 105 i
- :ed_insert,
- # 106 j
- :ed_insert,
- # 107 k
- :ed_insert,
- # 108 l
- :ed_insert,
- # 109 m
- :ed_insert,
- # 110 n
- :ed_insert,
- # 111 o
- :ed_insert,
- # 112 p
- :ed_insert,
- # 113 q
- :ed_insert,
- # 114 r
- :ed_insert,
- # 115 s
- :ed_insert,
- # 116 t
- :ed_insert,
- # 117 u
- :ed_insert,
- # 118 v
- :ed_insert,
- # 119 w
- :ed_insert,
- # 120 x
- :ed_insert,
- # 121 y
- :ed_insert,
- # 122 z
- :ed_insert,
- # 123 {
- :ed_insert,
- # 124 |
- :ed_insert,
- # 125 }
- :ed_insert,
- # 126 ~
- :ed_insert,
- # 127 ^?
- :em_delete_prev_char,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_delete_prev_word,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :key_newline,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_clear_screen,
- # 141 M-^M
- :key_newline,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :em_yank_pop,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :em_copy_prev_word,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_argument_digit,
- # 177 M-1
- :ed_argument_digit,
- # 178 M-2
- :ed_argument_digit,
- # 179 M-3
- :ed_argument_digit,
- # 180 M-4
- :ed_argument_digit,
- # 181 M-5
- :ed_argument_digit,
- # 182 M-6
- :ed_argument_digit,
- # 183 M-7
- :ed_argument_digit,
- # 184 M-8
- :ed_argument_digit,
- # 185 M-9
- :ed_argument_digit,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_prev_word,
- # 195 M-C
- :em_capitol_case,
- # 196 M-D
- :em_delete_next_word,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :em_next_word,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :em_lower_case,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :vi_search_next,
- # 207 M-O
- :ed_sequence_lead_in,
- # 208 M-P
- :vi_search_prev,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :em_upper_case,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :em_copy_region,
- # 216 M-X
- :ed_command,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_sequence_lead_in,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_prev_word,
- # 227 M-c
- :em_capitol_case,
- # 228 M-d
- :em_delete_next_word,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :em_next_word,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :em_lower_case,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :vi_search_next,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :vi_search_prev,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_transpose_words,
- # 245 M-u
- :em_upper_case,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :em_copy_region,
- # 248 M-x
- :ed_command,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_delete_prev_word
- # EOF
- ]
-end
diff --git a/lib/reline/key_actor/vi_command.rb b/lib/reline/key_actor/vi_command.rb
deleted file mode 100644
index 98146d2f77..0000000000
--- a/lib/reline/key_actor/vi_command.rb
+++ /dev/null
@@ -1,518 +0,0 @@
-class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :ed_unassigned,
- # 1 ^A
- :ed_move_to_beg,
- # 2 ^B
- :ed_unassigned,
- # 3 ^C
- :ed_ignore,
- # 4 ^D
- :vi_end_of_transmission,
- # 5 ^E
- :ed_move_to_end,
- # 6 ^F
- :ed_unassigned,
- # 7 ^G
- :ed_unassigned,
- # 8 ^H
- :ed_unassigned,
- # 9 ^I
- :ed_unassigned,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_kill_line,
- # 12 ^L
- :ed_clear_screen,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_next_history,
- # 15 ^O
- :ed_ignore,
- # 16 ^P
- :ed_prev_history,
- # 17 ^Q
- :ed_ignore,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :ed_ignore,
- # 20 ^T
- :ed_unassigned,
- # 21 ^U
- :vi_kill_line_prev,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :ed_delete_prev_word,
- # 24 ^X
- :ed_unassigned,
- # 25 ^Y
- :ed_unassigned,
- # 26 ^Z
- :ed_unassigned,
- # 27 ^[
- :ed_unassigned,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_unassigned,
- # 30 ^^
- :ed_unassigned,
- # 31 ^_
- :ed_unassigned,
- # 32 SPACE
- :ed_next_char,
- # 33 !
- :ed_unassigned,
- # 34 "
- :ed_unassigned,
- # 35 #
- :vi_comment_out,
- # 36 $
- :ed_move_to_end,
- # 37 %
- :vi_match,
- # 38 &
- :ed_unassigned,
- # 39 '
- :ed_unassigned,
- # 40 (
- :ed_unassigned,
- # 41 )
- :ed_unassigned,
- # 42 *
- :ed_unassigned,
- # 43 +
- :ed_next_history,
- # 44 ,
- :vi_repeat_prev_char,
- # 45 -
- :ed_prev_history,
- # 46 .
- :vi_redo,
- # 47 /
- :vi_search_prev,
- # 48 0
- :vi_zero,
- # 49 1
- :ed_argument_digit,
- # 50 2
- :ed_argument_digit,
- # 51 3
- :ed_argument_digit,
- # 52 4
- :ed_argument_digit,
- # 53 5
- :ed_argument_digit,
- # 54 6
- :ed_argument_digit,
- # 55 7
- :ed_argument_digit,
- # 56 8
- :ed_argument_digit,
- # 57 9
- :ed_argument_digit,
- # 58 :
- :ed_command,
- # 59 ;
- :vi_repeat_next_char,
- # 60 <
- :ed_unassigned,
- # 61 =
- :ed_unassigned,
- # 62 >
- :ed_unassigned,
- # 63 ?
- :vi_search_next,
- # 64 @
- :vi_alias,
- # 65 A
- :vi_add_at_eol,
- # 66 B
- :vi_prev_big_word,
- # 67 C
- :vi_change_to_eol,
- # 68 D
- :ed_kill_line,
- # 69 E
- :vi_end_big_word,
- # 70 F
- :vi_prev_char,
- # 71 G
- :vi_to_history_line,
- # 72 H
- :ed_unassigned,
- # 73 I
- :vi_insert_at_bol,
- # 74 J
- :vi_join_lines,
- # 75 K
- :vi_search_prev,
- # 76 L
- :ed_unassigned,
- # 77 M
- :ed_unassigned,
- # 78 N
- :vi_repeat_search_prev,
- # 79 O
- :ed_sequence_lead_in,
- # 80 P
- :vi_paste_prev,
- # 81 Q
- :ed_unassigned,
- # 82 R
- :vi_replace_mode,
- # 83 S
- :vi_substitute_line,
- # 84 T
- :vi_to_prev_char,
- # 85 U
- :vi_undo_line,
- # 86 V
- :ed_unassigned,
- # 87 W
- :vi_next_big_word,
- # 88 X
- :ed_delete_prev_char,
- # 89 Y
- :vi_yank_end,
- # 90 Z
- :ed_unassigned,
- # 91 [
- :ed_sequence_lead_in,
- # 92 \
- :ed_unassigned,
- # 93 ]
- :ed_unassigned,
- # 94 ^
- :vi_first_print,
- # 95 _
- :vi_history_word,
- # 96 `
- :ed_unassigned,
- # 97 a
- :vi_add,
- # 98 b
- :vi_prev_word,
- # 99 c
- :vi_change_meta,
- # 100 d
- :vi_delete_meta,
- # 101 e
- :vi_end_word,
- # 102 f
- :vi_next_char,
- # 103 g
- :ed_unassigned,
- # 104 h
- :ed_prev_char,
- # 105 i
- :vi_insert,
- # 106 j
- :ed_next_history,
- # 107 k
- :ed_prev_history,
- # 108 l
- :ed_next_char,
- # 109 m
- :ed_unassigned,
- # 110 n
- :vi_repeat_search_next,
- # 111 o
- :ed_unassigned,
- # 112 p
- :vi_paste_next,
- # 113 q
- :ed_unassigned,
- # 114 r
- :vi_replace_char,
- # 115 s
- :vi_substitute_char,
- # 116 t
- :vi_to_next_char,
- # 117 u
- :vi_undo,
- # 118 v
- :vi_histedit,
- # 119 w
- :vi_next_word,
- # 120 x
- :ed_delete_next_char,
- # 121 y
- :vi_yank,
- # 122 z
- :ed_unassigned,
- # 123 {
- :ed_unassigned,
- # 124 |
- :vi_to_column,
- # 125 }
- :ed_unassigned,
- # 126 ~
- :vi_change_case,
- # 127 ^?
- :ed_unassigned,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_unassigned,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :ed_unassigned,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_unassigned,
- # 141 M-^M
- :ed_unassigned,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :ed_unassigned,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :ed_unassigned,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_unassigned,
- # 177 M-1
- :ed_unassigned,
- # 178 M-2
- :ed_unassigned,
- # 179 M-3
- :ed_unassigned,
- # 180 M-4
- :ed_unassigned,
- # 181 M-5
- :ed_unassigned,
- # 182 M-6
- :ed_unassigned,
- # 183 M-7
- :ed_unassigned,
- # 184 M-8
- :ed_unassigned,
- # 185 M-9
- :ed_unassigned,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_unassigned,
- # 195 M-C
- :ed_unassigned,
- # 196 M-D
- :ed_unassigned,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :ed_unassigned,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :ed_unassigned,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :ed_unassigned,
- # 207 M-O
- :ed_sequence_lead_in,
- # 208 M-P
- :ed_unassigned,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :ed_unassigned,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :ed_unassigned,
- # 216 M-X
- :ed_unassigned,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_sequence_lead_in,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_unassigned,
- # 227 M-c
- :ed_unassigned,
- # 228 M-d
- :ed_unassigned,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :ed_unassigned,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :ed_unassigned,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :ed_unassigned,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :ed_unassigned,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_unassigned,
- # 245 M-u
- :ed_unassigned,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :ed_unassigned,
- # 248 M-x
- :ed_unassigned,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_unassigned
- # EOF
- ]
-end
-
diff --git a/lib/reline/key_actor/vi_insert.rb b/lib/reline/key_actor/vi_insert.rb
deleted file mode 100644
index b8e89f81d8..0000000000
--- a/lib/reline/key_actor/vi_insert.rb
+++ /dev/null
@@ -1,517 +0,0 @@
-class Reline::KeyActor::ViInsert < Reline::KeyActor::Base
- MAPPING = [
- # 0 ^@
- :ed_unassigned,
- # 1 ^A
- :ed_insert,
- # 2 ^B
- :ed_insert,
- # 3 ^C
- :ed_insert,
- # 4 ^D
- :vi_list_or_eof,
- # 5 ^E
- :ed_insert,
- # 6 ^F
- :ed_insert,
- # 7 ^G
- :ed_insert,
- # 8 ^H
- :vi_delete_prev_char,
- # 9 ^I
- :ed_insert,
- # 10 ^J
- :ed_newline,
- # 11 ^K
- :ed_insert,
- # 12 ^L
- :ed_insert,
- # 13 ^M
- :ed_newline,
- # 14 ^N
- :ed_insert,
- # 15 ^O
- :ed_insert,
- # 16 ^P
- :ed_insert,
- # 17 ^Q
- :ed_ignore,
- # 18 ^R
- :vi_search_prev,
- # 19 ^S
- :vi_search_next,
- # 20 ^T
- :ed_insert,
- # 21 ^U
- :vi_kill_line_prev,
- # 22 ^V
- :ed_quoted_insert,
- # 23 ^W
- :ed_delete_prev_word,
- # 24 ^X
- :ed_insert,
- # 25 ^Y
- :ed_insert,
- # 26 ^Z
- :ed_insert,
- # 27 ^[
- :vi_command_mode,
- # 28 ^\
- :ed_ignore,
- # 29 ^]
- :ed_insert,
- # 30 ^^
- :ed_insert,
- # 31 ^_
- :ed_insert,
- # 32 SPACE
- :ed_insert,
- # 33 !
- :ed_insert,
- # 34 "
- :ed_insert,
- # 35 #
- :ed_insert,
- # 36 $
- :ed_insert,
- # 37 %
- :ed_insert,
- # 38 &
- :ed_insert,
- # 39 '
- :ed_insert,
- # 40 (
- :ed_insert,
- # 41 )
- :ed_insert,
- # 42 *
- :ed_insert,
- # 43 +
- :ed_insert,
- # 44 ,
- :ed_insert,
- # 45 -
- :ed_insert,
- # 46 .
- :ed_insert,
- # 47 /
- :ed_insert,
- # 48 0
- :ed_insert,
- # 49 1
- :ed_insert,
- # 50 2
- :ed_insert,
- # 51 3
- :ed_insert,
- # 52 4
- :ed_insert,
- # 53 5
- :ed_insert,
- # 54 6
- :ed_insert,
- # 55 7
- :ed_insert,
- # 56 8
- :ed_insert,
- # 57 9
- :ed_insert,
- # 58 :
- :ed_insert,
- # 59 ;
- :ed_insert,
- # 60 <
- :ed_insert,
- # 61 =
- :ed_insert,
- # 62 >
- :ed_insert,
- # 63 ?
- :ed_insert,
- # 64 @
- :ed_insert,
- # 65 A
- :ed_insert,
- # 66 B
- :ed_insert,
- # 67 C
- :ed_insert,
- # 68 D
- :ed_insert,
- # 69 E
- :ed_insert,
- # 70 F
- :ed_insert,
- # 71 G
- :ed_insert,
- # 72 H
- :ed_insert,
- # 73 I
- :ed_insert,
- # 74 J
- :ed_insert,
- # 75 K
- :ed_insert,
- # 76 L
- :ed_insert,
- # 77 M
- :ed_insert,
- # 78 N
- :ed_insert,
- # 79 O
- :ed_insert,
- # 80 P
- :ed_insert,
- # 81 Q
- :ed_insert,
- # 82 R
- :ed_insert,
- # 83 S
- :ed_insert,
- # 84 T
- :ed_insert,
- # 85 U
- :ed_insert,
- # 86 V
- :ed_insert,
- # 87 W
- :ed_insert,
- # 88 X
- :ed_insert,
- # 89 Y
- :ed_insert,
- # 90 Z
- :ed_insert,
- # 91 [
- :ed_insert,
- # 92 \
- :ed_insert,
- # 93 ]
- :ed_insert,
- # 94 ^
- :ed_insert,
- # 95 _
- :ed_insert,
- # 96 `
- :ed_insert,
- # 97 a
- :ed_insert,
- # 98 b
- :ed_insert,
- # 99 c
- :ed_insert,
- # 100 d
- :ed_insert,
- # 101 e
- :ed_insert,
- # 102 f
- :ed_insert,
- # 103 g
- :ed_insert,
- # 104 h
- :ed_insert,
- # 105 i
- :ed_insert,
- # 106 j
- :ed_insert,
- # 107 k
- :ed_insert,
- # 108 l
- :ed_insert,
- # 109 m
- :ed_insert,
- # 110 n
- :ed_insert,
- # 111 o
- :ed_insert,
- # 112 p
- :ed_insert,
- # 113 q
- :ed_insert,
- # 114 r
- :ed_insert,
- # 115 s
- :ed_insert,
- # 116 t
- :ed_insert,
- # 117 u
- :ed_insert,
- # 118 v
- :ed_insert,
- # 119 w
- :ed_insert,
- # 120 x
- :ed_insert,
- # 121 y
- :ed_insert,
- # 122 z
- :ed_insert,
- # 123 {
- :ed_insert,
- # 124 |
- :ed_insert,
- # 125 }
- :ed_insert,
- # 126 ~
- :ed_insert,
- # 127 ^?
- :vi_delete_prev_char,
- # 128 M-^@
- :ed_unassigned,
- # 129 M-^A
- :ed_unassigned,
- # 130 M-^B
- :ed_unassigned,
- # 131 M-^C
- :ed_unassigned,
- # 132 M-^D
- :ed_unassigned,
- # 133 M-^E
- :ed_unassigned,
- # 134 M-^F
- :ed_unassigned,
- # 135 M-^G
- :ed_unassigned,
- # 136 M-^H
- :ed_unassigned,
- # 137 M-^I
- :ed_unassigned,
- # 138 M-^J
- :key_newline,
- # 139 M-^K
- :ed_unassigned,
- # 140 M-^L
- :ed_unassigned,
- # 141 M-^M
- :key_newline,
- # 142 M-^N
- :ed_unassigned,
- # 143 M-^O
- :ed_unassigned,
- # 144 M-^P
- :ed_unassigned,
- # 145 M-^Q
- :ed_unassigned,
- # 146 M-^R
- :ed_unassigned,
- # 147 M-^S
- :ed_unassigned,
- # 148 M-^T
- :ed_unassigned,
- # 149 M-^U
- :ed_unassigned,
- # 150 M-^V
- :ed_unassigned,
- # 151 M-^W
- :ed_unassigned,
- # 152 M-^X
- :ed_unassigned,
- # 153 M-^Y
- :ed_unassigned,
- # 154 M-^Z
- :ed_unassigned,
- # 155 M-^[
- :ed_unassigned,
- # 156 M-^\
- :ed_unassigned,
- # 157 M-^]
- :ed_unassigned,
- # 158 M-^^
- :ed_unassigned,
- # 159 M-^_
- :ed_unassigned,
- # 160 M-SPACE
- :ed_unassigned,
- # 161 M-!
- :ed_unassigned,
- # 162 M-"
- :ed_unassigned,
- # 163 M-#
- :ed_unassigned,
- # 164 M-$
- :ed_unassigned,
- # 165 M-%
- :ed_unassigned,
- # 166 M-&
- :ed_unassigned,
- # 167 M-'
- :ed_unassigned,
- # 168 M-(
- :ed_unassigned,
- # 169 M-)
- :ed_unassigned,
- # 170 M-*
- :ed_unassigned,
- # 171 M-+
- :ed_unassigned,
- # 172 M-,
- :ed_unassigned,
- # 173 M--
- :ed_unassigned,
- # 174 M-.
- :ed_unassigned,
- # 175 M-/
- :ed_unassigned,
- # 176 M-0
- :ed_unassigned,
- # 177 M-1
- :ed_unassigned,
- # 178 M-2
- :ed_unassigned,
- # 179 M-3
- :ed_unassigned,
- # 180 M-4
- :ed_unassigned,
- # 181 M-5
- :ed_unassigned,
- # 182 M-6
- :ed_unassigned,
- # 183 M-7
- :ed_unassigned,
- # 184 M-8
- :ed_unassigned,
- # 185 M-9
- :ed_unassigned,
- # 186 M-:
- :ed_unassigned,
- # 187 M-;
- :ed_unassigned,
- # 188 M-<
- :ed_unassigned,
- # 189 M-=
- :ed_unassigned,
- # 190 M->
- :ed_unassigned,
- # 191 M-?
- :ed_unassigned,
- # 192 M-@
- :ed_unassigned,
- # 193 M-A
- :ed_unassigned,
- # 194 M-B
- :ed_unassigned,
- # 195 M-C
- :ed_unassigned,
- # 196 M-D
- :ed_unassigned,
- # 197 M-E
- :ed_unassigned,
- # 198 M-F
- :ed_unassigned,
- # 199 M-G
- :ed_unassigned,
- # 200 M-H
- :ed_unassigned,
- # 201 M-I
- :ed_unassigned,
- # 202 M-J
- :ed_unassigned,
- # 203 M-K
- :ed_unassigned,
- # 204 M-L
- :ed_unassigned,
- # 205 M-M
- :ed_unassigned,
- # 206 M-N
- :ed_unassigned,
- # 207 M-O
- :ed_unassigned,
- # 208 M-P
- :ed_unassigned,
- # 209 M-Q
- :ed_unassigned,
- # 210 M-R
- :ed_unassigned,
- # 211 M-S
- :ed_unassigned,
- # 212 M-T
- :ed_unassigned,
- # 213 M-U
- :ed_unassigned,
- # 214 M-V
- :ed_unassigned,
- # 215 M-W
- :ed_unassigned,
- # 216 M-X
- :ed_unassigned,
- # 217 M-Y
- :ed_unassigned,
- # 218 M-Z
- :ed_unassigned,
- # 219 M-[
- :ed_unassigned,
- # 220 M-\
- :ed_unassigned,
- # 221 M-]
- :ed_unassigned,
- # 222 M-^
- :ed_unassigned,
- # 223 M-_
- :ed_unassigned,
- # 224 M-`
- :ed_unassigned,
- # 225 M-a
- :ed_unassigned,
- # 226 M-b
- :ed_unassigned,
- # 227 M-c
- :ed_unassigned,
- # 228 M-d
- :ed_unassigned,
- # 229 M-e
- :ed_unassigned,
- # 230 M-f
- :ed_unassigned,
- # 231 M-g
- :ed_unassigned,
- # 232 M-h
- :ed_unassigned,
- # 233 M-i
- :ed_unassigned,
- # 234 M-j
- :ed_unassigned,
- # 235 M-k
- :ed_unassigned,
- # 236 M-l
- :ed_unassigned,
- # 237 M-m
- :ed_unassigned,
- # 238 M-n
- :ed_unassigned,
- # 239 M-o
- :ed_unassigned,
- # 240 M-p
- :ed_unassigned,
- # 241 M-q
- :ed_unassigned,
- # 242 M-r
- :ed_unassigned,
- # 243 M-s
- :ed_unassigned,
- # 244 M-t
- :ed_unassigned,
- # 245 M-u
- :ed_unassigned,
- # 246 M-v
- :ed_unassigned,
- # 247 M-w
- :ed_unassigned,
- # 248 M-x
- :ed_unassigned,
- # 249 M-y
- :ed_unassigned,
- # 250 M-z
- :ed_unassigned,
- # 251 M-{
- :ed_unassigned,
- # 252 M-|
- :ed_unassigned,
- # 253 M-}
- :ed_unassigned,
- # 254 M-~
- :ed_unassigned,
- # 255 M-^?
- :ed_unassigned
- # EOF
- ]
-end
diff --git a/lib/reline/key_stroke.rb b/lib/reline/key_stroke.rb
deleted file mode 100644
index c1c61513a9..0000000000
--- a/lib/reline/key_stroke.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-class Reline::KeyStroke
- def initialize(config)
- @config = config
- end
-
- def compress_meta_key(ary)
- return ary unless @config.convert_meta
- ary.inject([]) { |result, key|
- if result.size > 0 and result.last == "\e".ord
- result[result.size - 1] = Reline::Key.new(key, key | 0b10000000, true)
- else
- result << key
- end
- result
- }
- end
-
- def start_with?(me, other)
- compressed_me = compress_meta_key(me)
- compressed_other = compress_meta_key(other)
- i = 0
- loop do
- my_c = compressed_me[i]
- other_c = compressed_other[i]
- other_is_last = (i + 1) == compressed_other.size
- me_is_last = (i + 1) == compressed_me.size
- if my_c != other_c
- if other_c == "\e".ord and other_is_last and my_c.is_a?(Reline::Key) and my_c.with_meta
- return true
- else
- return false
- end
- elsif other_is_last
- return true
- elsif me_is_last
- return false
- end
- i += 1
- end
- end
-
- def equal?(me, other)
- case me
- when Array
- compressed_me = compress_meta_key(me)
- compressed_other = compress_meta_key(other)
- compressed_me.size == compressed_other.size and [compressed_me, compressed_other].transpose.all?{ |i| equal?(i[0], i[1]) }
- when Integer
- if other.is_a?(Reline::Key)
- if other.combined_char == "\e".ord
- false
- else
- other.combined_char == me
- end
- else
- me == other
- end
- when Reline::Key
- if other.is_a?(Integer)
- me.combined_char == other
- else
- me == other
- end
- end
- end
-
- def match_status(input)
- key_mapping.keys.select { |lhs|
- start_with?(lhs, input)
- }.tap { |it|
- return :matched if it.size == 1 && equal?(it[0], input)
- return :matching if it.size == 1 && !equal?(it[0], input)
- return :matched if it.max_by(&:size)&.size&.< input.size
- return :matching if it.size > 1
- }
- key_mapping.keys.select { |lhs|
- start_with?(input, lhs)
- }.tap { |it|
- return it.size > 0 ? :matched : :unmatched
- }
- end
-
- def expand(input)
- input = compress_meta_key(input)
- lhs = key_mapping.keys.select { |item| start_with?(input, item) }.sort_by(&:size).last
- return input unless lhs
- rhs = key_mapping[lhs]
-
- case rhs
- when String
- rhs_bytes = rhs.bytes
- expand(expand(rhs_bytes) + expand(input.drop(lhs.size)))
- when Symbol
- [rhs] + expand(input.drop(lhs.size))
- when Array
- rhs
- end
- end
-
- private
-
- def key_mapping
- @config.key_bindings
- end
-end
diff --git a/lib/reline/kill_ring.rb b/lib/reline/kill_ring.rb
deleted file mode 100644
index bb3684b42b..0000000000
--- a/lib/reline/kill_ring.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-class Reline::KillRing
- include Enumerable
-
- module State
- FRESH = :fresh
- CONTINUED = :continued
- PROCESSED = :processed
- YANK = :yank
- end
-
- RingPoint = Struct.new(:backward, :forward, :str) do
- def initialize(str)
- super(nil, nil, str)
- end
-
- def ==(other)
- object_id == other.object_id
- end
- end
-
- class RingBuffer
- attr_reader :size
- attr_reader :head
-
- def initialize(max = 1024)
- @max = max
- @size = 0
- @head = nil # reading head of ring-shaped tape
- end
-
- def <<(point)
- if @size.zero?
- @head = point
- @head.backward = @head
- @head.forward = @head
- @size = 1
- elsif @size >= @max
- tail = @head.forward
- new_tail = tail.forward
- @head.forward = point
- point.backward = @head
- new_tail.backward = point
- point.forward = new_tail
- @head = point
- else
- tail = @head.forward
- @head.forward = point
- point.backward = @head
- tail.backward = point
- point.forward = tail
- @head = point
- @size += 1
- end
- end
-
- def empty?
- @size.zero?
- end
- end
-
- def initialize(max = 1024)
- @ring = RingBuffer.new(max)
- @ring_pointer = nil
- @buffer = nil
- @state = State::FRESH
- end
-
- def append(string, before_p = false)
- case @state
- when State::FRESH, State::YANK
- @ring << RingPoint.new(string)
- @state = State::CONTINUED
- when State::CONTINUED, State::PROCESSED
- if before_p
- @ring.head.str.prepend(string)
- else
- @ring.head.str.concat(string)
- end
- @state = State::CONTINUED
- end
- end
-
- def process
- case @state
- when State::FRESH
- # nothing to do
- when State::CONTINUED
- @state = State::PROCESSED
- when State::PROCESSED
- @state = State::FRESH
- when State::YANK
- # nothing to do
- end
- end
-
- def yank
- unless @ring.empty?
- @state = State::YANK
- @ring_pointer = @ring.head
- @ring_pointer.str
- else
- nil
- end
- end
-
- def yank_pop
- if @state == State::YANK
- prev_yank = @ring_pointer.str
- @ring_pointer = @ring_pointer.backward
- [@ring_pointer.str, prev_yank]
- else
- nil
- end
- end
-
- def each
- start = head = @ring.head
- loop do
- break if head.nil?
- yield head.str
- head = head.backward
- break if head == start
- end
- end
-end
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
deleted file mode 100644
index 87ce7fba5d..0000000000
--- a/lib/reline/line_editor.rb
+++ /dev/null
@@ -1,3347 +0,0 @@
-require 'reline/kill_ring'
-require 'reline/unicode'
-
-require 'tempfile'
-
-class Reline::LineEditor
- # TODO: undo
- # TODO: Use "private alias_method" idiom after drop Ruby 2.5.
- attr_reader :line
- attr_reader :byte_pointer
- attr_accessor :confirm_multiline_termination_proc
- attr_accessor :completion_proc
- attr_accessor :completion_append_character
- attr_accessor :output_modifier_proc
- attr_accessor :prompt_proc
- attr_accessor :auto_indent_proc
- attr_accessor :pre_input_hook
- attr_accessor :dig_perfect_match_proc
- attr_writer :output
-
- VI_MOTIONS = %i{
- ed_prev_char
- ed_next_char
- vi_zero
- ed_move_to_beg
- ed_move_to_end
- vi_to_column
- vi_next_char
- vi_prev_char
- vi_next_word
- vi_prev_word
- vi_to_next_char
- vi_to_prev_char
- vi_end_word
- vi_next_big_word
- vi_prev_big_word
- vi_end_big_word
- vi_repeat_next_char
- vi_repeat_prev_char
- }
-
- module CompletionState
- NORMAL = :normal
- COMPLETION = :completion
- MENU = :menu
- JOURNEY = :journey
- MENU_WITH_PERFECT_MATCH = :menu_with_perfect_match
- PERFECT_MATCH = :perfect_match
- end
-
- CompletionJourneyData = Struct.new('CompletionJourneyData', :preposing, :postposing, :list, :pointer)
- MenuInfo = Struct.new('MenuInfo', :target, :list)
-
- PROMPT_LIST_CACHE_TIMEOUT = 0.5
- MINIMUM_SCROLLBAR_HEIGHT = 1
-
- def initialize(config, encoding)
- @config = config
- @completion_append_character = ''
- reset_variables(encoding: encoding)
- end
-
- def set_pasting_state(in_pasting)
- @in_pasting = in_pasting
- end
-
- def simplified_rendering?
- if finished?
- false
- elsif @just_cursor_moving and not @rerender_all
- true
- else
- not @rerender_all and not finished? and @in_pasting
- end
- end
-
- private def check_mode_string
- mode_string = nil
- if @config.show_mode_in_prompt
- if @config.editing_mode_is?(:vi_command)
- mode_string = @config.vi_cmd_mode_string
- elsif @config.editing_mode_is?(:vi_insert)
- mode_string = @config.vi_ins_mode_string
- elsif @config.editing_mode_is?(:emacs)
- mode_string = @config.emacs_mode_string
- else
- mode_string = '?'
- end
- end
- if mode_string != @prev_mode_string
- @rerender_all = true
- end
- @prev_mode_string = mode_string
- mode_string
- end
-
- private def check_multiline_prompt(buffer)
- if @vi_arg
- prompt = "(arg: #{@vi_arg}) "
- @rerender_all = true
- elsif @searching_prompt
- prompt = @searching_prompt
- @rerender_all = true
- else
- prompt = @prompt
- end
- if simplified_rendering?
- mode_string = check_mode_string
- prompt = mode_string + prompt if mode_string
- return [prompt, calculate_width(prompt, true), [prompt] * buffer.size]
- end
- if @prompt_proc
- use_cached_prompt_list = false
- if @cached_prompt_list
- if @just_cursor_moving
- use_cached_prompt_list = true
- elsif Time.now.to_f < (@prompt_cache_time + PROMPT_LIST_CACHE_TIMEOUT) and buffer.size == @cached_prompt_list.size
- use_cached_prompt_list = true
- end
- end
- use_cached_prompt_list = false if @rerender_all
- if use_cached_prompt_list
- prompt_list = @cached_prompt_list
- else
- prompt_list = @cached_prompt_list = @prompt_proc.(buffer).map { |pr| pr.gsub("\n", "\\n") }
- @prompt_cache_time = Time.now.to_f
- end
- prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
- prompt_list = [prompt] if prompt_list.empty?
- mode_string = check_mode_string
- prompt_list = prompt_list.map{ |pr| mode_string + pr } if mode_string
- prompt = prompt_list[@line_index]
- prompt = prompt_list[0] if prompt.nil?
- prompt = prompt_list.last if prompt.nil?
- if buffer.size > prompt_list.size
- (buffer.size - prompt_list.size).times do
- prompt_list << prompt_list.last
- end
- end
- prompt_width = calculate_width(prompt, true)
- [prompt, prompt_width, prompt_list]
- else
- mode_string = check_mode_string
- prompt = mode_string + prompt if mode_string
- prompt_width = calculate_width(prompt, true)
- [prompt, prompt_width, nil]
- end
- end
-
- def reset(prompt = '', encoding:)
- @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
- @screen_size = Reline::IOGate.get_screen_size
- @screen_height = @screen_size.first
- reset_variables(prompt, encoding: encoding)
- Reline::IOGate.set_winch_handler do
- @resized = true
- end
- if ENV.key?('RELINE_ALT_SCROLLBAR')
- @full_block = '::'
- @upper_half_block = "''"
- @lower_half_block = '..'
- @block_elem_width = 2
- elsif Reline::IOGate.win?
- @full_block = 'â–ˆ'
- @upper_half_block = 'â–€'
- @lower_half_block = 'â–„'
- @block_elem_width = 1
- elsif @encoding == Encoding::UTF_8
- @full_block = 'â–ˆ'
- @upper_half_block = 'â–€'
- @lower_half_block = 'â–„'
- @block_elem_width = Reline::Unicode.calculate_width('â–ˆ')
- else
- @full_block = '::'
- @upper_half_block = "''"
- @lower_half_block = '..'
- @block_elem_width = 2
- end
- end
-
- def resize
- return unless @resized
- @resized = false
- @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
- old_screen_size = @screen_size
- @screen_size = Reline::IOGate.get_screen_size
- @screen_height = @screen_size.first
- if old_screen_size.last < @screen_size.last # columns increase
- @rerender_all = true
- rerender
- else
- back = 0
- new_buffer = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_buffer)
- new_buffer.each_with_index do |line, index|
- prompt_width = calculate_width(prompt_list[index], true) if @prompt_proc
- width = prompt_width + calculate_width(line)
- height = calculate_height_by_width(width)
- back += height
- end
- @highest_in_all = back
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
- end
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- calculate_nearest_cursor
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @rerender_all = true
- end
- end
-
- def set_signal_handlers
- @old_trap = Signal.trap('INT') {
- clear_dialog
- if @scroll_partial_screen
- move_cursor_down(@screen_height - (@line_index - @scroll_partial_screen) - 1)
- else
- move_cursor_down(@highest_in_all - @line_index - 1)
- end
- Reline::IOGate.move_cursor_column(0)
- scroll_down(1)
- case @old_trap
- when 'DEFAULT', 'SYSTEM_DEFAULT'
- raise Interrupt
- when 'IGNORE'
- # Do nothing
- when 'EXIT'
- exit
- else
- @old_trap.call if @old_trap.respond_to?(:call)
- end
- }
- begin
- @old_tstp_trap = Signal.trap('TSTP') {
- Reline::IOGate.ungetc("\C-z".ord)
- @old_tstp_trap.call if @old_tstp_trap.respond_to?(:call)
- }
- rescue ArgumentError
- end
- end
-
- def finalize
- Signal.trap('INT', @old_trap)
- begin
- Signal.trap('TSTP', @old_tstp_trap)
- rescue ArgumentError
- end
- end
-
- def eof?
- @eof
- end
-
- def reset_variables(prompt = '', encoding:)
- @prompt = prompt.gsub("\n", "\\n")
- @mark_pointer = nil
- @encoding = encoding
- @is_multiline = false
- @finished = false
- @cleared = false
- @rerender_all = false
- @history_pointer = nil
- @kill_ring ||= Reline::KillRing.new
- @vi_clipboard = ''
- @vi_arg = nil
- @waiting_proc = nil
- @waiting_operator_proc = nil
- @waiting_operator_vi_arg = nil
- @completion_journey_data = nil
- @completion_state = CompletionState::NORMAL
- @perfect_matched = nil
- @menu_info = nil
- @first_prompt = true
- @searching_prompt = nil
- @first_char = true
- @add_newline_to_end_of_buffer = false
- @just_cursor_moving = nil
- @cached_prompt_list = nil
- @prompt_cache_time = nil
- @eof = false
- @continuous_insertion_buffer = String.new(encoding: @encoding)
- @scroll_partial_screen = nil
- @prev_mode_string = nil
- @drop_terminate_spaces = false
- @in_pasting = false
- @auto_indent_proc = nil
- @dialogs = []
- @last_key = nil
- @resized = false
- reset_line
- end
-
- def reset_line
- @cursor = 0
- @cursor_max = 0
- @byte_pointer = 0
- @buffer_of_lines = [String.new(encoding: @encoding)]
- @line_index = 0
- @previous_line_index = nil
- @line = @buffer_of_lines[0]
- @first_line_started_from = 0
- @move_up = 0
- @started_from = 0
- @highest_in_this = 1
- @highest_in_all = 1
- @line_backup_in_history = nil
- @multibyte_buffer = String.new(encoding: 'ASCII-8BIT')
- @check_new_auto_indent = false
- end
-
- def multiline_on
- @is_multiline = true
- end
-
- def multiline_off
- @is_multiline = false
- end
-
- private def calculate_height_by_lines(lines, prompt)
- result = 0
- prompt_list = prompt.is_a?(Array) ? prompt : nil
- lines.each_with_index { |line, i|
- prompt = prompt_list[i] if prompt_list and prompt_list[i]
- result += calculate_height_by_width(calculate_width(prompt, true) + calculate_width(line))
- }
- result
- end
-
- private def insert_new_line(cursor_line, next_line)
- @line = cursor_line
- @buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding))
- @previous_line_index = @line_index
- @line_index += 1
- @just_cursor_moving = false
- end
-
- private def calculate_height_by_width(width)
- width.div(@screen_size.last) + 1
- end
-
- private def split_by_width(str, max_width)
- Reline::Unicode.split_by_width(str, max_width, @encoding)
- end
-
- private def scroll_down(val)
- if val <= @rest_height
- Reline::IOGate.move_cursor_down(val)
- @rest_height -= val
- else
- Reline::IOGate.move_cursor_down(@rest_height)
- Reline::IOGate.scroll_down(val - @rest_height)
- @rest_height = 0
- end
- end
-
- private def move_cursor_up(val)
- if val > 0
- Reline::IOGate.move_cursor_up(val)
- @rest_height += val
- elsif val < 0
- move_cursor_down(-val)
- end
- end
-
- private def move_cursor_down(val)
- if val > 0
- Reline::IOGate.move_cursor_down(val)
- @rest_height -= val
- @rest_height = 0 if @rest_height < 0
- elsif val < 0
- move_cursor_up(-val)
- end
- end
-
- private def calculate_nearest_cursor(line_to_calc = @line, cursor = @cursor, started_from = @started_from, byte_pointer = @byte_pointer, update = true)
- new_cursor_max = calculate_width(line_to_calc)
- new_cursor = 0
- new_byte_pointer = 0
- height = 1
- max_width = @screen_size.last
- if @config.editing_mode_is?(:vi_command)
- last_byte_size = Reline::Unicode.get_prev_mbchar_size(line_to_calc, line_to_calc.bytesize)
- if last_byte_size > 0
- last_mbchar = line_to_calc.byteslice(line_to_calc.bytesize - last_byte_size, last_byte_size)
- last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
- end_of_line_cursor = new_cursor_max - last_width
- else
- end_of_line_cursor = new_cursor_max
- end
- else
- end_of_line_cursor = new_cursor_max
- end
- line_to_calc.grapheme_clusters.each do |gc|
- mbchar = gc.encode(Encoding::UTF_8)
- mbchar_width = Reline::Unicode.get_mbchar_width(mbchar)
- now = new_cursor + mbchar_width
- if now > end_of_line_cursor or now > cursor
- break
- end
- new_cursor += mbchar_width
- if new_cursor > max_width * height
- height += 1
- end
- new_byte_pointer += gc.bytesize
- end
- new_started_from = height - 1
- if update
- @cursor = new_cursor
- @cursor_max = new_cursor_max
- @started_from = new_started_from
- @byte_pointer = new_byte_pointer
- else
- [new_cursor, new_cursor_max, new_started_from, new_byte_pointer]
- end
- end
-
- def rerender_all
- @rerender_all = true
- process_insert(force: true)
- rerender
- end
-
- def rerender
- return if @line.nil?
- if @menu_info
- scroll_down(@highest_in_all - @first_line_started_from)
- @rerender_all = true
- end
- if @menu_info
- show_menu
- @menu_info = nil
- end
- prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines)
- if @cleared
- clear_screen_buffer(prompt, prompt_list, prompt_width)
- @cleared = false
- return
- end
- if @is_multiline and finished? and @scroll_partial_screen
- # Re-output all code higher than the screen when finished.
- Reline::IOGate.move_cursor_up(@first_line_started_from + @started_from - @scroll_partial_screen)
- Reline::IOGate.move_cursor_column(0)
- @scroll_partial_screen = nil
- new_lines = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
- modify_lines(new_lines).each_with_index do |line, index|
- @output.write "#{prompt_list ? prompt_list[index] : prompt}#{line}\r\n"
- Reline::IOGate.erase_after_cursor
- end
- @output.flush
- clear_dialog
- return
- end
- new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line))
- rendered = false
- if @add_newline_to_end_of_buffer
- clear_dialog_with_content
- rerender_added_newline(prompt, prompt_width, prompt_list)
- @add_newline_to_end_of_buffer = false
- else
- if @just_cursor_moving and not @rerender_all
- clear_dialog_with_content
- rendered = just_move_cursor
- @just_cursor_moving = false
- return
- elsif @previous_line_index or new_highest_in_this != @highest_in_this
- clear_dialog_with_content
- rerender_changed_current_line
- @previous_line_index = nil
- rendered = true
- elsif @rerender_all
- rerender_all_lines
- @rerender_all = false
- rendered = true
- else
- end
- end
- if @is_multiline
- if finished?
- # Always rerender on finish because output_modifier_proc may return a different output.
- new_lines = whole_lines
- line = modify_lines(new_lines)[@line_index]
- clear_dialog
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
- render_partial(prompt, prompt_width, line, @first_line_started_from)
- move_cursor_down(@highest_in_all - (@first_line_started_from + @highest_in_this - 1) - 1)
- scroll_down(1)
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- else
- if not rendered and not @in_pasting
- line = modify_lines(whole_lines)[@line_index]
- prompt, prompt_width, prompt_list = check_multiline_prompt(whole_lines)
- render_partial(prompt, prompt_width, line, @first_line_started_from)
- end
- render_dialog((prompt_width + @cursor) % @screen_size.last)
- end
- @buffer_of_lines[@line_index] = @line
- @rest_height = 0 if @scroll_partial_screen
- else
- line = modify_lines(whole_lines)[@line_index]
- render_partial(prompt, prompt_width, line, 0)
- if finished?
- scroll_down(1)
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- end
- end
- end
-
- class DialogProcScope
- def initialize(line_editor, config, proc_to_exec, context)
- @line_editor = line_editor
- @config = config
- @proc_to_exec = proc_to_exec
- @context = context
- @cursor_pos = Reline::CursorPos.new
- end
-
- def context
- @context
- end
-
- def retrieve_completion_block(set_completion_quote_character = false)
- @line_editor.retrieve_completion_block(set_completion_quote_character)
- end
-
- def call_completion_proc_with_checking_args(pre, target, post)
- @line_editor.call_completion_proc_with_checking_args(pre, target, post)
- end
-
- def set_dialog(dialog)
- @dialog = dialog
- end
-
- def dialog
- @dialog
- end
-
- def set_cursor_pos(col, row)
- @cursor_pos.x = col
- @cursor_pos.y = row
- end
-
- def set_key(key)
- @key = key
- end
-
- def key
- @key
- end
-
- def cursor_pos
- @cursor_pos
- end
-
- def just_cursor_moving
- @line_editor.instance_variable_get(:@just_cursor_moving)
- end
-
- def screen_width
- @line_editor.instance_variable_get(:@screen_size).last
- end
-
- def completion_journey_data
- @line_editor.instance_variable_get(:@completion_journey_data)
- end
-
- def config
- @config
- end
-
- def call
- instance_exec(&@proc_to_exec)
- end
- end
-
- class Dialog
- attr_reader :name, :contents, :width
- attr_accessor :scroll_top, :scrollbar_pos, :pointer, :column, :vertical_offset, :lines_backup, :trap_key
-
- def initialize(name, config, proc_scope)
- @name = name
- @config = config
- @proc_scope = proc_scope
- @width = nil
- @scroll_top = 0
- @trap_key = nil
- end
-
- def set_cursor_pos(col, row)
- @proc_scope.set_cursor_pos(col, row)
- end
-
- def width=(v)
- @width = v
- end
-
- def contents=(contents)
- @contents = contents
- if contents and @width.nil?
- @width = contents.map{ |line| Reline::Unicode.calculate_width(line, true) }.max
- end
- end
-
- def call(key)
- @proc_scope.set_dialog(self)
- @proc_scope.set_key(key)
- dialog_render_info = @proc_scope.call
- if @trap_key
- if @trap_key.any?{ |i| i.is_a?(Array) } # multiple trap
- @trap_key.each do |t|
- @config.add_oneshot_key_binding(t, @name)
- end
- elsif @trap_key.is_a?(Array)
- @config.add_oneshot_key_binding(@trap_key, @name)
- elsif @trap_key.is_a?(Integer) or @trap_key.is_a?(Reline::Key)
- @config.add_oneshot_key_binding([@trap_key], @name)
- end
- end
- dialog_render_info
- end
- end
-
- def add_dialog_proc(name, p, context = nil)
- dialog = Dialog.new(name, @config, DialogProcScope.new(self, @config, p, context))
- if index = @dialogs.find_index { |d| d.name == name }
- @dialogs[index] = dialog
- else
- @dialogs << dialog
- end
- end
-
- DIALOG_DEFAULT_HEIGHT = 20
- private def render_dialog(cursor_column)
- @dialogs.each do |dialog|
- render_each_dialog(dialog, cursor_column)
- end
- end
-
- private def padding_space_with_escape_sequences(str, width)
- padding_width = width - calculate_width(str, true)
- # padding_width should be only positive value. But macOS and Alacritty returns negative value.
- padding_width = 0 if padding_width < 0
- str + (' ' * padding_width)
- end
-
- private def render_each_dialog(dialog, cursor_column)
- if @in_pasting
- clear_each_dialog(dialog)
- dialog.contents = nil
- dialog.trap_key = nil
- return
- end
- dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
- dialog_render_info = dialog.call(@last_key)
- if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
- lines = whole_lines
- dialog.lines_backup = {
- unmodified_lines: lines,
- lines: modify_lines(lines),
- line_index: @line_index,
- first_line_started_from: @first_line_started_from,
- started_from: @started_from,
- byte_pointer: @byte_pointer
- }
- clear_each_dialog(dialog)
- dialog.contents = nil
- dialog.trap_key = nil
- return
- end
- old_dialog = dialog.clone
- dialog.contents = dialog_render_info.contents
- pointer = dialog.pointer
- if dialog_render_info.width
- dialog.width = dialog_render_info.width
- else
- dialog.width = dialog.contents.map { |l| calculate_width(l, true) }.max
- end
- height = dialog_render_info.height || DIALOG_DEFAULT_HEIGHT
- height = dialog.contents.size if dialog.contents.size < height
- if dialog.contents.size > height
- if dialog.pointer
- if dialog.pointer < 0
- dialog.scroll_top = 0
- elsif (dialog.pointer - dialog.scroll_top) >= (height - 1)
- dialog.scroll_top = dialog.pointer - (height - 1)
- elsif (dialog.pointer - dialog.scroll_top) < 0
- dialog.scroll_top = dialog.pointer
- end
- pointer = dialog.pointer - dialog.scroll_top
- else
- dialog.scroll_top = 0
- end
- dialog.contents = dialog.contents[dialog.scroll_top, height]
- end
- if dialog_render_info.scrollbar and dialog_render_info.contents.size > height
- bar_max_height = height * 2
- moving_distance = (dialog_render_info.contents.size - height) * 2
- position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
- bar_height = (bar_max_height * ((dialog.contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
- bar_height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT
- dialog.scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
- else
- dialog.scrollbar_pos = nil
- end
- upper_space = @first_line_started_from - @started_from
- dialog.column = dialog_render_info.pos.x
- dialog.width += @block_elem_width if dialog.scrollbar_pos
- diff = (dialog.column + dialog.width) - (@screen_size.last)
- if diff > 0
- dialog.column -= diff
- end
- if (@rest_height - dialog_render_info.pos.y) >= height
- dialog.vertical_offset = dialog_render_info.pos.y + 1
- elsif upper_space >= height
- dialog.vertical_offset = dialog_render_info.pos.y - height
- else
- if (@rest_height - dialog_render_info.pos.y) < height
- scroll_down(height + dialog_render_info.pos.y)
- move_cursor_up(height + dialog_render_info.pos.y)
- end
- dialog.vertical_offset = dialog_render_info.pos.y + 1
- end
- Reline::IOGate.hide_cursor
- if dialog.column < 0
- dialog.column = 0
- dialog.width = @screen_size.last
- end
- reset_dialog(dialog, old_dialog)
- move_cursor_down(dialog.vertical_offset)
- Reline::IOGate.move_cursor_column(dialog.column)
- dialog.contents.each_with_index do |item, i|
- if i == pointer
- fg_color = dialog_render_info.pointer_fg_color
- bg_color = dialog_render_info.pointer_bg_color
- else
- fg_color = dialog_render_info.fg_color
- bg_color = dialog_render_info.bg_color
- end
- str_width = dialog.width - (dialog.scrollbar_pos.nil? ? 0 : @block_elem_width)
- str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, str_width), str_width)
- @output.write "\e[#{bg_color}m\e[#{fg_color}m#{str}"
- if dialog.scrollbar_pos
- @output.write "\e[37m"
- if dialog.scrollbar_pos <= (i * 2) and (i * 2 + 1) < (dialog.scrollbar_pos + bar_height)
- @output.write @full_block
- elsif dialog.scrollbar_pos <= (i * 2) and (i * 2) < (dialog.scrollbar_pos + bar_height)
- @output.write @upper_half_block
- elsif dialog.scrollbar_pos <= (i * 2 + 1) and (i * 2) < (dialog.scrollbar_pos + bar_height)
- @output.write @lower_half_block
- else
- @output.write ' ' * @block_elem_width
- end
- end
- @output.write "\e[0m"
- Reline::IOGate.move_cursor_column(dialog.column)
- move_cursor_down(1) if i < (dialog.contents.size - 1)
- end
- Reline::IOGate.move_cursor_column(cursor_column)
- move_cursor_up(dialog.vertical_offset + dialog.contents.size - 1)
- Reline::IOGate.show_cursor
- lines = whole_lines
- dialog.lines_backup = {
- unmodified_lines: lines,
- lines: modify_lines(lines),
- line_index: @line_index,
- first_line_started_from: @first_line_started_from,
- started_from: @started_from,
- byte_pointer: @byte_pointer
- }
- end
-
- private def reset_dialog(dialog, old_dialog)
- return if dialog.lines_backup.nil? or old_dialog.contents.nil?
- prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
- visual_lines = []
- visual_start = nil
- dialog.lines_backup[:lines].each_with_index { |l, i|
- pr = prompt_list ? prompt_list[i] : prompt
- vl, _ = split_by_width(pr + l, @screen_size.last)
- vl.compact!
- if i == dialog.lines_backup[:line_index]
- visual_start = visual_lines.size + dialog.lines_backup[:started_from]
- end
- visual_lines.concat(vl)
- }
- old_y = dialog.lines_backup[:first_line_started_from] + dialog.lines_backup[:started_from]
- y = @first_line_started_from + @started_from
- y_diff = y - old_y
- if (old_y + old_dialog.vertical_offset) < (y + dialog.vertical_offset)
- # rerender top
- move_cursor_down(old_dialog.vertical_offset - y_diff)
- start = visual_start + old_dialog.vertical_offset
- line_num = dialog.vertical_offset - old_dialog.vertical_offset
- line_num.times do |i|
- Reline::IOGate.move_cursor_column(old_dialog.column)
- if visual_lines[start + i].nil?
- s = ' ' * old_dialog.width
- else
- s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, old_dialog.width)
- s = padding_space_with_escape_sequences(s, old_dialog.width)
- end
- @output.write "\e[0m#{s}\e[0m"
- move_cursor_down(1) if i < (line_num - 1)
- end
- move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
- end
- if (old_y + old_dialog.vertical_offset + old_dialog.contents.size) > (y + dialog.vertical_offset + dialog.contents.size)
- # rerender bottom
- move_cursor_down(dialog.vertical_offset + dialog.contents.size - y_diff)
- start = visual_start + dialog.vertical_offset + dialog.contents.size
- line_num = (old_dialog.vertical_offset + old_dialog.contents.size) - (dialog.vertical_offset + dialog.contents.size)
- line_num.times do |i|
- Reline::IOGate.move_cursor_column(old_dialog.column)
- if visual_lines[start + i].nil?
- s = ' ' * old_dialog.width
- else
- s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, old_dialog.width)
- s = padding_space_with_escape_sequences(s, old_dialog.width)
- end
- @output.write "\e[0m#{s}\e[0m"
- move_cursor_down(1) if i < (line_num - 1)
- end
- move_cursor_up(dialog.vertical_offset + dialog.contents.size + line_num - 1 - y_diff)
- end
- if old_dialog.column < dialog.column
- # rerender left
- move_cursor_down(old_dialog.vertical_offset - y_diff)
- width = dialog.column - old_dialog.column
- start = visual_start + old_dialog.vertical_offset
- line_num = old_dialog.contents.size
- line_num.times do |i|
- Reline::IOGate.move_cursor_column(old_dialog.column)
- if visual_lines[start + i].nil?
- s = ' ' * width
- else
- s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column, width)
- s = padding_space_with_escape_sequences(s, dialog.width)
- end
- @output.write "\e[0m#{s}\e[0m"
- move_cursor_down(1) if i < (line_num - 1)
- end
- move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
- end
- if (old_dialog.column + old_dialog.width) > (dialog.column + dialog.width)
- # rerender right
- move_cursor_down(old_dialog.vertical_offset + y_diff)
- width = (old_dialog.column + old_dialog.width) - (dialog.column + dialog.width)
- start = visual_start + old_dialog.vertical_offset
- line_num = old_dialog.contents.size
- line_num.times do |i|
- Reline::IOGate.move_cursor_column(old_dialog.column + dialog.width)
- if visual_lines[start + i].nil?
- s = ' ' * width
- else
- s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column + dialog.width, width)
- rerender_width = old_dialog.width - dialog.width
- s = padding_space_with_escape_sequences(s, rerender_width)
- end
- Reline::IOGate.move_cursor_column(dialog.column + dialog.width)
- @output.write "\e[0m#{s}\e[0m"
- move_cursor_down(1) if i < (line_num - 1)
- end
- move_cursor_up(old_dialog.vertical_offset + line_num - 1 + y_diff)
- end
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- end
-
- private def clear_dialog
- @dialogs.each do |dialog|
- clear_each_dialog(dialog)
- end
- end
-
- private def clear_dialog_with_content
- @dialogs.each do |dialog|
- clear_each_dialog(dialog)
- dialog.contents = nil
- dialog.trap_key = nil
- end
- end
-
- private def clear_each_dialog(dialog)
- dialog.trap_key = nil
- return unless dialog.contents
- prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
- visual_lines = []
- visual_lines_under_dialog = []
- visual_start = nil
- dialog.lines_backup[:lines].each_with_index { |l, i|
- pr = prompt_list ? prompt_list[i] : prompt
- vl, _ = split_by_width(pr + l, @screen_size.last)
- vl.compact!
- if i == dialog.lines_backup[:line_index]
- visual_start = visual_lines.size + dialog.lines_backup[:started_from] + dialog.vertical_offset
- end
- visual_lines.concat(vl)
- }
- visual_lines_under_dialog = visual_lines[visual_start, dialog.contents.size]
- visual_lines_under_dialog = [] if visual_lines_under_dialog.nil?
- Reline::IOGate.hide_cursor
- move_cursor_down(dialog.vertical_offset)
- dialog_vertical_size = dialog.contents.size
- dialog_vertical_size.times do |i|
- if i < visual_lines_under_dialog.size
- Reline::IOGate.move_cursor_column(dialog.column)
- str = Reline::Unicode.take_range(visual_lines_under_dialog[i], dialog.column, dialog.width)
- str = padding_space_with_escape_sequences(str, dialog.width)
- @output.write "\e[0m#{str}\e[0m"
- else
- Reline::IOGate.move_cursor_column(dialog.column)
- @output.write "\e[0m#{' ' * dialog.width}\e[0m"
- end
- move_cursor_down(1) if i < (dialog_vertical_size - 1)
- end
- move_cursor_up(dialog_vertical_size - 1 + dialog.vertical_offset)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- Reline::IOGate.show_cursor
- end
-
- private def calculate_scroll_partial_screen(highest_in_all, cursor_y)
- if @screen_height < highest_in_all
- old_scroll_partial_screen = @scroll_partial_screen
- if cursor_y == 0
- @scroll_partial_screen = 0
- elsif cursor_y == (highest_in_all - 1)
- @scroll_partial_screen = highest_in_all - @screen_height
- else
- if @scroll_partial_screen
- if cursor_y <= @scroll_partial_screen
- @scroll_partial_screen = cursor_y
- elsif (@scroll_partial_screen + @screen_height - 1) < cursor_y
- @scroll_partial_screen = cursor_y - (@screen_height - 1)
- end
- else
- if cursor_y > (@screen_height - 1)
- @scroll_partial_screen = cursor_y - (@screen_height - 1)
- else
- @scroll_partial_screen = 0
- end
- end
- end
- if @scroll_partial_screen != old_scroll_partial_screen
- @rerender_all = true
- end
- else
- if @scroll_partial_screen
- @rerender_all = true
- end
- @scroll_partial_screen = nil
- end
- end
-
- private def rerender_added_newline(prompt, prompt_width, prompt_list)
- @buffer_of_lines[@previous_line_index] = @line
- @line = @buffer_of_lines[@line_index]
- @previous_line_index = nil
- if @in_pasting
- scroll_down(1)
- else
- lines = whole_lines
- prev_line_prompt = @prompt_proc ? prompt_list[@line_index - 1] : prompt
- prev_line_prompt_width = @prompt_proc ? calculate_width(prev_line_prompt, true) : prompt_width
- prev_line = modify_lines(lines)[@line_index - 1]
- render_partial(prev_line_prompt, prev_line_prompt_width, prev_line, @first_line_started_from + @started_from, with_control: false)
- scroll_down(1)
- render_partial(prompt, prompt_width, @line, @first_line_started_from + @started_from + 1, with_control: false)
- end
- @cursor = @cursor_max = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @highest_in_all += @highest_in_this
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @first_line_started_from += @started_from + 1
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- end
-
- def just_move_cursor
- prompt, prompt_width, prompt_list = check_multiline_prompt(@buffer_of_lines)
- move_cursor_up(@started_from)
- new_first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
- end
- first_line_diff = new_first_line_started_from - @first_line_started_from
- new_cursor, new_cursor_max, new_started_from, new_byte_pointer = calculate_nearest_cursor(@buffer_of_lines[@line_index], @cursor, @started_from, @byte_pointer, false)
- new_started_from = calculate_height_by_width(prompt_width + new_cursor) - 1
- calculate_scroll_partial_screen(@highest_in_all, new_first_line_started_from + new_started_from)
- @previous_line_index = nil
- if @rerender_all
- @line = @buffer_of_lines[@line_index]
- rerender_all_lines
- @rerender_all = false
- true
- else
- @line = @buffer_of_lines[@line_index]
- @first_line_started_from = new_first_line_started_from
- @started_from = new_started_from
- @cursor = new_cursor
- @cursor_max = new_cursor_max
- @byte_pointer = new_byte_pointer
- move_cursor_down(first_line_diff + @started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- false
- end
- end
-
- private def rerender_changed_current_line
- new_lines = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_lines)
- all_height = calculate_height_by_lines(new_lines, prompt_list || prompt)
- diff = all_height - @highest_in_all
- move_cursor_down(@highest_in_all - @first_line_started_from - @started_from - 1)
- if diff > 0
- scroll_down(diff)
- move_cursor_up(all_height - 1)
- elsif diff < 0
- (-diff).times do
- Reline::IOGate.move_cursor_column(0)
- Reline::IOGate.erase_after_cursor
- move_cursor_up(1)
- end
- move_cursor_up(all_height - 1)
- else
- move_cursor_up(all_height - 1)
- end
- @highest_in_all = all_height
- back = render_whole_lines(new_lines, prompt_list || prompt, prompt_width)
- move_cursor_up(back)
- if @previous_line_index
- @buffer_of_lines[@previous_line_index] = @line
- @line = @buffer_of_lines[@line_index]
- end
- @first_line_started_from =
- if @line_index.zero?
- 0
- else
- calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt)
- end
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- move_cursor_down(@first_line_started_from)
- calculate_nearest_cursor
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- move_cursor_down(@started_from)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- end
-
- private def rerender_all_lines
- move_cursor_up(@first_line_started_from + @started_from)
- Reline::IOGate.move_cursor_column(0)
- back = 0
- new_buffer = whole_lines
- prompt, prompt_width, prompt_list = check_multiline_prompt(new_buffer)
- new_buffer.each_with_index do |line, index|
- prompt_width = calculate_width(prompt_list[index], true) if @prompt_proc
- width = prompt_width + calculate_width(line)
- height = calculate_height_by_width(width)
- back += height
- end
- old_highest_in_all = @highest_in_all
- if @line_index.zero?
- new_first_line_started_from = 0
- else
- new_first_line_started_from = calculate_height_by_lines(new_buffer[0..(@line_index - 1)], prompt_list || prompt)
- end
- new_started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- calculate_scroll_partial_screen(back, new_first_line_started_from + new_started_from)
- if @scroll_partial_screen
- move_cursor_up(@first_line_started_from + @started_from)
- scroll_down(@screen_height - 1)
- move_cursor_up(@screen_height)
- Reline::IOGate.move_cursor_column(0)
- elsif back > old_highest_in_all
- scroll_down(back - 1)
- move_cursor_up(back - 1)
- elsif back < old_highest_in_all
- scroll_down(back)
- Reline::IOGate.erase_after_cursor
- (old_highest_in_all - back - 1).times do
- scroll_down(1)
- Reline::IOGate.erase_after_cursor
- end
- move_cursor_up(old_highest_in_all - 1)
- end
- render_whole_lines(new_buffer, prompt_list || prompt, prompt_width)
- if @prompt_proc
- prompt = prompt_list[@line_index]
- prompt_width = calculate_width(prompt, true)
- end
- @highest_in_this = calculate_height_by_width(prompt_width + @cursor_max)
- @highest_in_all = back
- @first_line_started_from = new_first_line_started_from
- @started_from = new_started_from
- if @scroll_partial_screen
- Reline::IOGate.move_cursor_up(@screen_height - (@first_line_started_from + @started_from - @scroll_partial_screen) - 1)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- else
- move_cursor_down(@first_line_started_from + @started_from - back + 1)
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- end
- end
-
- private def render_whole_lines(lines, prompt, prompt_width)
- rendered_height = 0
- modify_lines(lines).each_with_index do |line, index|
- if prompt.is_a?(Array)
- line_prompt = prompt[index]
- prompt_width = calculate_width(line_prompt, true)
- else
- line_prompt = prompt
- end
- height = render_partial(line_prompt, prompt_width, line, rendered_height, with_control: false)
- if index < (lines.size - 1)
- if @scroll_partial_screen
- if (@scroll_partial_screen - height) < rendered_height and (@scroll_partial_screen + @screen_height - 1) >= (rendered_height + height)
- move_cursor_down(1)
- end
- else
- scroll_down(1)
- end
- rendered_height += height
- else
- rendered_height += height - 1
- end
- end
- rendered_height
- end
-
- private def render_partial(prompt, prompt_width, line_to_render, this_started_from, with_control: true)
- visual_lines, height = split_by_width(line_to_render.nil? ? prompt : prompt + line_to_render, @screen_size.last)
- cursor_up_from_last_line = 0
- if @scroll_partial_screen
- last_visual_line = this_started_from + (height - 1)
- last_screen_line = @scroll_partial_screen + (@screen_height - 1)
- if (@scroll_partial_screen - this_started_from) >= height
- # Render nothing because this line is before the screen.
- visual_lines = []
- elsif this_started_from > last_screen_line
- # Render nothing because this line is after the screen.
- visual_lines = []
- else
- deleted_lines_before_screen = []
- if @scroll_partial_screen > this_started_from and last_visual_line >= @scroll_partial_screen
- # A part of visual lines are before the screen.
- deleted_lines_before_screen = visual_lines.shift((@scroll_partial_screen - this_started_from) * 2)
- deleted_lines_before_screen.compact!
- end
- if this_started_from <= last_screen_line and last_screen_line < last_visual_line
- # A part of visual lines are after the screen.
- visual_lines.pop((last_visual_line - last_screen_line) * 2)
- end
- move_cursor_up(deleted_lines_before_screen.size - @started_from)
- cursor_up_from_last_line = @started_from - deleted_lines_before_screen.size
- end
- end
- if with_control
- if height > @highest_in_this
- diff = height - @highest_in_this
- scroll_down(diff)
- @highest_in_all += diff
- @highest_in_this = height
- move_cursor_up(diff)
- elsif height < @highest_in_this
- diff = @highest_in_this - height
- @highest_in_all -= diff
- @highest_in_this = height
- end
- move_cursor_up(@started_from)
- @started_from = calculate_height_by_width(prompt_width + @cursor) - 1
- cursor_up_from_last_line = height - 1 - @started_from
- end
- if Reline::Unicode::CSI_REGEXP.match?(prompt + line_to_render)
- @output.write "\e[0m" # clear character decorations
- end
- visual_lines.each_with_index do |line, index|
- Reline::IOGate.move_cursor_column(0)
- if line.nil?
- if calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last
- # reaches the end of line
- if Reline::IOGate.win? and Reline::IOGate.win_legacy_console?
- # A newline is automatically inserted if a character is rendered at
- # eol on command prompt.
- else
- # When the cursor is at the end of the line and erases characters
- # after the cursor, some terminals delete the character at the
- # cursor position.
- move_cursor_down(1)
- Reline::IOGate.move_cursor_column(0)
- end
- else
- Reline::IOGate.erase_after_cursor
- move_cursor_down(1)
- Reline::IOGate.move_cursor_column(0)
- end
- next
- end
- @output.write line
- if Reline::IOGate.win? and Reline::IOGate.win_legacy_console? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last
- # A newline is automatically inserted if a character is rendered at eol on command prompt.
- @rest_height -= 1 if @rest_height > 0
- end
- @output.flush
- if @first_prompt
- @first_prompt = false
- @pre_input_hook&.call
- end
- end
- unless visual_lines.empty?
- Reline::IOGate.erase_after_cursor
- Reline::IOGate.move_cursor_column(0)
- end
- if with_control
- # Just after rendring, so the cursor is on the last line.
- if finished?
- Reline::IOGate.move_cursor_column(0)
- else
- # Moves up from bottom of lines to the cursor position.
- move_cursor_up(cursor_up_from_last_line)
- # This logic is buggy if a fullwidth char is wrapped because there is only one halfwidth at end of a line.
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- end
- end
- height
- end
-
- private def modify_lines(before)
- return before if before.nil? || before.empty? || simplified_rendering?
-
- if after = @output_modifier_proc&.call("#{before.join("\n")}\n", complete: finished?)
- after.lines("\n").map { |l| l.chomp('') }
- else
- before
- end
- end
-
- private def show_menu
- scroll_down(@highest_in_all - @first_line_started_from)
- @rerender_all = true
- @menu_info.list.sort!.each do |item|
- Reline::IOGate.move_cursor_column(0)
- @output.write item
- @output.flush
- scroll_down(1)
- end
- scroll_down(@highest_in_all - 1)
- move_cursor_up(@highest_in_all - 1 - @first_line_started_from)
- end
-
- private def clear_screen_buffer(prompt, prompt_list, prompt_width)
- Reline::IOGate.clear_screen
- back = 0
- modify_lines(whole_lines).each_with_index do |line, index|
- if @prompt_proc
- pr = prompt_list[index]
- height = render_partial(pr, calculate_width(pr), line, back, with_control: false)
- else
- height = render_partial(prompt, prompt_width, line, back, with_control: false)
- end
- if index < (@buffer_of_lines.size - 1)
- move_cursor_down(1)
- back += height
- end
- end
- move_cursor_up(back)
- move_cursor_down(@first_line_started_from + @started_from)
- @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y
- Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last)
- end
-
- def editing_mode
- @config.editing_mode
- end
-
- private def menu(target, list)
- @menu_info = MenuInfo.new(target, list)
- end
-
- private def complete_internal_proc(list, is_menu)
- preposing, target, postposing = retrieve_completion_block
- list = list.select { |i|
- if i and not Encoding.compatible?(target.encoding, i.encoding)
- raise Encoding::CompatibilityError, "#{target.encoding.name} is not compatible with #{i.encoding.name}"
- end
- if @config.completion_ignore_case
- i&.downcase&.start_with?(target.downcase)
- else
- i&.start_with?(target)
- end
- }.uniq
- if is_menu
- menu(target, list)
- return nil
- end
- completed = list.inject { |memo, item|
- begin
- memo_mbchars = memo.unicode_normalize.grapheme_clusters
- item_mbchars = item.unicode_normalize.grapheme_clusters
- rescue Encoding::CompatibilityError
- memo_mbchars = memo.grapheme_clusters
- item_mbchars = item.grapheme_clusters
- end
- size = [memo_mbchars.size, item_mbchars.size].min
- result = ''
- size.times do |i|
- if @config.completion_ignore_case
- if memo_mbchars[i].casecmp?(item_mbchars[i])
- result << memo_mbchars[i]
- else
- break
- end
- else
- if memo_mbchars[i] == item_mbchars[i]
- result << memo_mbchars[i]
- else
- break
- end
- end
- end
- result
- }
- [target, preposing, completed, postposing]
- end
-
- private def complete(list, just_show_list = false)
- case @completion_state
- when CompletionState::NORMAL, CompletionState::JOURNEY
- @completion_state = CompletionState::COMPLETION
- when CompletionState::PERFECT_MATCH
- @dig_perfect_match_proc&.(@perfect_matched)
- end
- if just_show_list
- is_menu = true
- elsif @completion_state == CompletionState::MENU
- is_menu = true
- elsif @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
- is_menu = true
- else
- is_menu = false
- end
- result = complete_internal_proc(list, is_menu)
- if @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
- @completion_state = CompletionState::PERFECT_MATCH
- end
- return if result.nil?
- target, preposing, completed, postposing = result
- return if completed.nil?
- if target <= completed and (@completion_state == CompletionState::COMPLETION)
- if list.include?(completed)
- if list.one?
- @completion_state = CompletionState::PERFECT_MATCH
- else
- @completion_state = CompletionState::MENU_WITH_PERFECT_MATCH
- end
- @perfect_matched = completed
- else
- @completion_state = CompletionState::MENU
- end
- if not just_show_list and target < completed
- @line = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding)
- line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n").last || String.new(encoding: @encoding)
- @cursor_max = calculate_width(@line)
- @cursor = calculate_width(line_to_pointer)
- @byte_pointer = line_to_pointer.bytesize
- end
- end
- end
-
- private def move_completed_list(list, direction)
- case @completion_state
- when CompletionState::NORMAL, CompletionState::COMPLETION,
- CompletionState::MENU, CompletionState::MENU_WITH_PERFECT_MATCH
- @completion_state = CompletionState::JOURNEY
- result = retrieve_completion_block
- return if result.nil?
- preposing, target, postposing = result
- @completion_journey_data = CompletionJourneyData.new(
- preposing, postposing,
- [target] + list.select{ |item| item.start_with?(target) }, 0)
- if @completion_journey_data.list.size == 1
- @completion_journey_data.pointer = 0
- else
- case direction
- when :up
- @completion_journey_data.pointer = @completion_journey_data.list.size - 1
- when :down
- @completion_journey_data.pointer = 1
- end
- end
- @completion_state = CompletionState::JOURNEY
- else
- case direction
- when :up
- @completion_journey_data.pointer -= 1
- if @completion_journey_data.pointer < 0
- @completion_journey_data.pointer = @completion_journey_data.list.size - 1
- end
- when :down
- @completion_journey_data.pointer += 1
- if @completion_journey_data.pointer >= @completion_journey_data.list.size
- @completion_journey_data.pointer = 0
- end
- end
- end
- completed = @completion_journey_data.list[@completion_journey_data.pointer]
- new_line = (@completion_journey_data.preposing + completed + @completion_journey_data.postposing).split("\n")[@line_index]
- @line = new_line.nil? ? String.new(encoding: @encoding) : new_line
- line_to_pointer = (@completion_journey_data.preposing + completed).split("\n").last
- line_to_pointer = String.new(encoding: @encoding) if line_to_pointer.nil?
- @cursor_max = calculate_width(@line)
- @cursor = calculate_width(line_to_pointer)
- @byte_pointer = line_to_pointer.bytesize
- end
-
- private def run_for_operators(key, method_symbol, &block)
- if @waiting_operator_proc
- if VI_MOTIONS.include?(method_symbol)
- old_cursor, old_byte_pointer = @cursor, @byte_pointer
- @vi_arg = @waiting_operator_vi_arg if @waiting_operator_vi_arg&.> 1
- block.(true)
- unless @waiting_proc
- cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
- @cursor, @byte_pointer = old_cursor, old_byte_pointer
- @waiting_operator_proc.(cursor_diff, byte_pointer_diff)
- else
- old_waiting_proc = @waiting_proc
- old_waiting_operator_proc = @waiting_operator_proc
- current_waiting_operator_proc = @waiting_operator_proc
- @waiting_proc = proc { |k|
- old_cursor, old_byte_pointer = @cursor, @byte_pointer
- old_waiting_proc.(k)
- cursor_diff, byte_pointer_diff = @cursor - old_cursor, @byte_pointer - old_byte_pointer
- @cursor, @byte_pointer = old_cursor, old_byte_pointer
- current_waiting_operator_proc.(cursor_diff, byte_pointer_diff)
- @waiting_operator_proc = old_waiting_operator_proc
- }
- end
- else
- # Ignores operator when not motion is given.
- block.(false)
- end
- @waiting_operator_proc = nil
- @waiting_operator_vi_arg = nil
- if @vi_arg
- @rerender_all = true
- @vi_arg = nil
- end
- else
- block.(false)
- end
- end
-
- private def argumentable?(method_obj)
- method_obj and method_obj.parameters.any? { |param| param[0] == :key and param[1] == :arg }
- end
-
- private def inclusive?(method_obj)
- # If a motion method with the keyword argument "inclusive" follows the
- # operator, it must contain the character at the cursor position.
- method_obj and method_obj.parameters.any? { |param| param[0] == :key and param[1] == :inclusive }
- end
-
- def wrap_method_call(method_symbol, method_obj, key, with_operator = false)
- if @config.editing_mode_is?(:emacs, :vi_insert) and @waiting_proc.nil? and @waiting_operator_proc.nil?
- not_insertion = method_symbol != :ed_insert
- process_insert(force: not_insertion)
- end
- if @vi_arg and argumentable?(method_obj)
- if with_operator and inclusive?(method_obj)
- method_obj.(key, arg: @vi_arg, inclusive: true)
- else
- method_obj.(key, arg: @vi_arg)
- end
- else
- if with_operator and inclusive?(method_obj)
- method_obj.(key, inclusive: true)
- else
- method_obj.(key)
- end
- end
- end
-
- private def process_key(key, method_symbol)
- if method_symbol and respond_to?(method_symbol, true)
- method_obj = method(method_symbol)
- else
- method_obj = nil
- end
- if method_symbol and key.is_a?(Symbol)
- if @vi_arg and argumentable?(method_obj)
- run_for_operators(key, method_symbol) do |with_operator|
- wrap_method_call(method_symbol, method_obj, key, with_operator)
- end
- else
- wrap_method_call(method_symbol, method_obj, key) if method_obj
- end
- @kill_ring.process
- if @vi_arg
- @rerender_al = true
- @vi_arg = nil
- end
- elsif @vi_arg
- if key.chr =~ /[0-9]/
- ed_argument_digit(key)
- else
- if argumentable?(method_obj)
- run_for_operators(key, method_symbol) do |with_operator|
- wrap_method_call(method_symbol, method_obj, key, with_operator)
- end
- elsif @waiting_proc
- @waiting_proc.(key)
- elsif method_obj
- wrap_method_call(method_symbol, method_obj, key)
- else
- ed_insert(key) unless @config.editing_mode_is?(:vi_command)
- end
- @kill_ring.process
- if @vi_arg
- @rerender_all = true
- @vi_arg = nil
- end
- end
- elsif @waiting_proc
- @waiting_proc.(key)
- @kill_ring.process
- elsif method_obj
- if method_symbol == :ed_argument_digit
- wrap_method_call(method_symbol, method_obj, key)
- else
- run_for_operators(key, method_symbol) do |with_operator|
- wrap_method_call(method_symbol, method_obj, key, with_operator)
- end
- end
- @kill_ring.process
- else
- ed_insert(key) unless @config.editing_mode_is?(:vi_command)
- end
- end
-
- private def normal_char(key)
- method_symbol = method_obj = nil
- if key.combined_char.is_a?(Symbol)
- process_key(key.combined_char, key.combined_char)
- return
- end
- @multibyte_buffer << key.combined_char
- if @multibyte_buffer.size > 1
- if @multibyte_buffer.dup.force_encoding(@encoding).valid_encoding?
- process_key(@multibyte_buffer.dup.force_encoding(@encoding), nil)
- @multibyte_buffer.clear
- else
- # invalid
- return
- end
- else # single byte
- return if key.char >= 128 # maybe, first byte of multi byte
- method_symbol = @config.editing_mode.get_method(key.combined_char)
- if key.with_meta and method_symbol == :ed_unassigned
- # split ESC + key
- method_symbol = @config.editing_mode.get_method("\e".ord)
- process_key("\e".ord, method_symbol)
- method_symbol = @config.editing_mode.get_method(key.char)
- process_key(key.char, method_symbol)
- else
- process_key(key.combined_char, method_symbol)
- end
- @multibyte_buffer.clear
- end
- if @config.editing_mode_is?(:vi_command) and @cursor > 0 and @cursor == @cursor_max
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- end
- end
-
- def input_key(key)
- @last_key = key
- @config.reset_oneshot_key_bindings
- @dialogs.each do |dialog|
- if key.char.instance_of?(Symbol) and key.char == dialog.name
- return
- end
- end
- @just_cursor_moving = nil
- if key.char.nil?
- if @first_char
- @line = nil
- end
- finish
- return
- end
- old_line = @line.dup
- @first_char = false
- completion_occurs = false
- if @config.editing_mode_is?(:emacs, :vi_insert) and key.char == "\C-i".ord
- unless @config.disable_completion
- result = call_completion_proc
- if result.is_a?(Array)
- completion_occurs = true
- process_insert
- if @config.autocompletion
- move_completed_list(result, :down)
- else
- complete(result)
- end
- end
- end
- elsif @config.editing_mode_is?(:emacs, :vi_insert) and key.char == :completion_journey_up
- if not @config.disable_completion and @config.autocompletion
- result = call_completion_proc
- if result.is_a?(Array)
- completion_occurs = true
- process_insert
- move_completed_list(result, :up)
- end
- end
- elsif not @config.disable_completion and @config.editing_mode_is?(:vi_insert) and ["\C-p".ord, "\C-n".ord].include?(key.char)
- unless @config.disable_completion
- result = call_completion_proc
- if result.is_a?(Array)
- completion_occurs = true
- process_insert
- move_completed_list(result, "\C-p".ord == key.char ? :up : :down)
- end
- end
- elsif Symbol === key.char and respond_to?(key.char, true)
- process_key(key.char, key.char)
- else
- normal_char(key)
- end
- unless completion_occurs
- @completion_state = CompletionState::NORMAL
- @completion_journey_data = nil
- end
- if not @in_pasting and @just_cursor_moving.nil?
- if @previous_line_index and @buffer_of_lines[@previous_line_index] == @line
- @just_cursor_moving = true
- elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line and old_line == @line
- @just_cursor_moving = true
- else
- @just_cursor_moving = false
- end
- else
- @just_cursor_moving = false
- end
- if @is_multiline and @auto_indent_proc and not simplified_rendering?
- process_auto_indent
- end
- end
-
- def call_completion_proc
- result = retrieve_completion_block(true)
- pre, target, post = result
- result = call_completion_proc_with_checking_args(pre, target, post)
- Reline.core.instance_variable_set(:@completion_quote_character, nil)
- result
- end
-
- def call_completion_proc_with_checking_args(pre, target, post)
- if @completion_proc and target
- argnum = @completion_proc.parameters.inject(0) { |result, item|
- case item.first
- when :req, :opt
- result + 1
- when :rest
- break 3
- end
- }
- case argnum
- when 1
- result = @completion_proc.(target)
- when 2
- result = @completion_proc.(target, pre)
- when 3..Float::INFINITY
- result = @completion_proc.(target, pre, post)
- end
- end
- result
- end
-
- private def process_auto_indent
- return if not @check_new_auto_indent and @previous_line_index # move cursor up or down
- if @check_new_auto_indent and @previous_line_index and @previous_line_index > 0 and @line_index > @previous_line_index
- # Fix indent of a line when a newline is inserted to the next
- new_lines = whole_lines
- new_indent = @auto_indent_proc.(new_lines[0..-3].push(''), @line_index - 1, 0, true)
- md = @line.match(/\A */)
- prev_indent = md[0].count(' ')
- @line = ' ' * new_indent + @line.lstrip
-
- new_indent = nil
- result = @auto_indent_proc.(new_lines[0..-2], @line_index - 1, (new_lines[-2].size + 1), false)
- if result
- new_indent = result
- end
- if new_indent&.>= 0
- @line = ' ' * new_indent + @line.lstrip
- end
- end
- new_lines = whole_lines
- new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
- if new_indent&.>= 0
- md = new_lines[@line_index].match(/\A */)
- prev_indent = md[0].count(' ')
- if @check_new_auto_indent
- line = @buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
- @cursor = new_indent
- @cursor_max = calculate_width(line)
- @byte_pointer = new_indent
- else
- @line = ' ' * new_indent + @line.lstrip
- @cursor += new_indent - prev_indent
- @cursor_max = calculate_width(@line)
- @byte_pointer += new_indent - prev_indent
- end
- end
- @check_new_auto_indent = false
- end
-
- def retrieve_completion_block(set_completion_quote_character = false)
- if Reline.completer_word_break_characters.empty?
- word_break_regexp = nil
- else
- word_break_regexp = /\A[#{Regexp.escape(Reline.completer_word_break_characters)}]/
- end
- if Reline.completer_quote_characters.empty?
- quote_characters_regexp = nil
- else
- quote_characters_regexp = /\A[#{Regexp.escape(Reline.completer_quote_characters)}]/
- end
- before = @line.byteslice(0, @byte_pointer)
- rest = nil
- break_pointer = nil
- quote = nil
- closing_quote = nil
- escaped_quote = nil
- i = 0
- while i < @byte_pointer do
- slice = @line.byteslice(i, @byte_pointer - i)
- unless slice.valid_encoding?
- i += 1
- next
- end
- if quote and slice.start_with?(closing_quote)
- quote = nil
- i += 1
- rest = nil
- elsif quote and slice.start_with?(escaped_quote)
- # skip
- i += 2
- elsif quote_characters_regexp and slice =~ quote_characters_regexp # find new "
- rest = $'
- quote = $&
- closing_quote = /(?!\\)#{Regexp.escape(quote)}/
- escaped_quote = /\\#{Regexp.escape(quote)}/
- i += 1
- break_pointer = i - 1
- elsif word_break_regexp and not quote and slice =~ word_break_regexp
- rest = $'
- i += 1
- before = @line.byteslice(i, @byte_pointer - i)
- break_pointer = i
- else
- i += 1
- end
- end
- postposing = @line.byteslice(@byte_pointer, @line.bytesize - @byte_pointer)
- if rest
- preposing = @line.byteslice(0, break_pointer)
- target = rest
- if set_completion_quote_character and quote
- Reline.core.instance_variable_set(:@completion_quote_character, quote)
- if postposing !~ /(?!\\)#{Regexp.escape(quote)}/ # closing quote
- insert_text(quote)
- end
- end
- else
- preposing = ''
- if break_pointer
- preposing = @line.byteslice(0, break_pointer)
- else
- preposing = ''
- end
- target = before
- end
- if @is_multiline
- lines = whole_lines
- if @line_index > 0
- preposing = lines[0..(@line_index - 1)].join("\n") + "\n" + preposing
- end
- if (lines.size - 1) > @line_index
- postposing = postposing + "\n" + lines[(@line_index + 1)..-1].join("\n")
- end
- end
- [preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)]
- end
-
- def confirm_multiline_termination
- temp_buffer = @buffer_of_lines.dup
- if @previous_line_index and @line_index == (@buffer_of_lines.size - 1)
- temp_buffer[@previous_line_index] = @line
- else
- temp_buffer[@line_index] = @line
- end
- @confirm_multiline_termination_proc.(temp_buffer.join("\n") + "\n")
- end
-
- def insert_text(text)
- width = calculate_width(text)
- if @cursor == @cursor_max
- @line += text
- else
- @line = byteinsert(@line, @byte_pointer, text)
- end
- @byte_pointer += text.bytesize
- @cursor += width
- @cursor_max += width
- end
-
- def delete_text(start = nil, length = nil)
- if start.nil? and length.nil?
- if @is_multiline
- if @buffer_of_lines.size == 1
- @line&.clear
- @byte_pointer = 0
- @cursor = 0
- @cursor_max = 0
- elsif @line_index == (@buffer_of_lines.size - 1) and @line_index > 0
- @buffer_of_lines.pop
- @line_index -= 1
- @line = @buffer_of_lines[@line_index]
- @byte_pointer = 0
- @cursor = 0
- @cursor_max = calculate_width(@line)
- elsif @line_index < (@buffer_of_lines.size - 1)
- @buffer_of_lines.delete_at(@line_index)
- @line = @buffer_of_lines[@line_index]
- @byte_pointer = 0
- @cursor = 0
- @cursor_max = calculate_width(@line)
- end
- else
- @line&.clear
- @byte_pointer = 0
- @cursor = 0
- @cursor_max = 0
- end
- elsif not start.nil? and not length.nil?
- if @line
- before = @line.byteslice(0, start)
- after = @line.byteslice(start + length, @line.bytesize)
- @line = before + after
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
- elsif start.is_a?(Range)
- range = start
- first = range.first
- last = range.last
- last = @line.bytesize - 1 if last > @line.bytesize
- last += @line.bytesize if last < 0
- first += @line.bytesize if first < 0
- range = range.exclude_end? ? first...last : first..last
- @line = @line.bytes.reject.with_index{ |c, i| range.include?(i) }.map{ |c| c.chr(Encoding::ASCII_8BIT) }.join.force_encoding(@encoding)
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- else
- @line = @line.byteslice(0, start)
- @byte_pointer = @line.bytesize if @byte_pointer > @line.bytesize
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
- end
-
- def byte_pointer=(val)
- @byte_pointer = val
- str = @line.byteslice(0, @byte_pointer)
- @cursor = calculate_width(str)
- @cursor_max = calculate_width(@line)
- end
-
- def whole_lines
- index = @previous_line_index || @line_index
- temp_lines = @buffer_of_lines.dup
- temp_lines[index] = @line
- temp_lines
- end
-
- def whole_buffer
- if @buffer_of_lines.size == 1 and @line.nil?
- nil
- else
- whole_lines.join("\n")
- end
- end
-
- def finished?
- @finished
- end
-
- def finish
- @finished = true
- @rerender_all = true
- @config.reset
- end
-
- private def byteslice!(str, byte_pointer, size)
- new_str = str.byteslice(0, byte_pointer)
- new_str << str.byteslice(byte_pointer + size, str.bytesize)
- [new_str, str.byteslice(byte_pointer, size)]
- end
-
- private def byteinsert(str, byte_pointer, other)
- new_str = str.byteslice(0, byte_pointer)
- new_str << other
- new_str << str.byteslice(byte_pointer, str.bytesize)
- new_str
- end
-
- private def calculate_width(str, allow_escape_code = false)
- Reline::Unicode.calculate_width(str, allow_escape_code)
- end
-
- private def key_delete(key)
- if @config.editing_mode_is?(:vi_insert, :emacs)
- ed_delete_next_char(key)
- end
- end
-
- private def key_newline(key)
- if @is_multiline
- if (@buffer_of_lines.size - 1) == @line_index and @line.bytesize == @byte_pointer
- @add_newline_to_end_of_buffer = true
- end
- next_line = @line.byteslice(@byte_pointer, @line.bytesize - @byte_pointer)
- cursor_line = @line.byteslice(0, @byte_pointer)
- insert_new_line(cursor_line, next_line)
- @cursor = 0
- @check_new_auto_indent = true unless @in_pasting
- end
- end
-
- # Editline:: +ed-unassigned+ This editor command always results in an error.
- # GNU Readline:: There is no corresponding macro.
- private def ed_unassigned(key) end # do nothing
-
- private def process_insert(force: false)
- return if @continuous_insertion_buffer.empty? or (@in_pasting and not force)
- width = Reline::Unicode.calculate_width(@continuous_insertion_buffer)
- bytesize = @continuous_insertion_buffer.bytesize
- if @cursor == @cursor_max
- @line += @continuous_insertion_buffer
- else
- @line = byteinsert(@line, @byte_pointer, @continuous_insertion_buffer)
- end
- @byte_pointer += bytesize
- @cursor += width
- @cursor_max += width
- @continuous_insertion_buffer.clear
- end
-
- # Editline:: +ed-insert+ (vi input: almost all; emacs: printable characters)
- # In insert mode, insert the input character left of the cursor
- # position. In replace mode, overwrite the character at the
- # cursor and move the cursor to the right by one character
- # position. Accept an argument to do this repeatedly. It is an
- # error if the input character is the NUL character (+Ctrl-@+).
- # Failure to enlarge the edit buffer also results in an error.
- # Editline:: +ed-digit+ (emacs: 0 to 9) If in argument input mode, append
- # the input digit to the argument being read. Otherwise, call
- # +ed-insert+. It is an error if the input character is not a
- # digit or if the existing argument is already greater than a
- # million.
- # GNU Readline:: +self-insert+ (a, b, A, 1, !, …) Insert yourself.
- private def ed_insert(key)
- str = nil
- width = nil
- bytesize = nil
- if key.instance_of?(String)
- begin
- key.encode(Encoding::UTF_8)
- rescue Encoding::UndefinedConversionError
- return
- end
- str = key
- bytesize = key.bytesize
- else
- begin
- key.chr.encode(Encoding::UTF_8)
- rescue Encoding::UndefinedConversionError
- return
- end
- str = key.chr
- bytesize = 1
- end
- if @in_pasting
- @continuous_insertion_buffer << str
- return
- elsif not @continuous_insertion_buffer.empty?
- process_insert
- end
- width = Reline::Unicode.get_mbchar_width(str)
- if @cursor == @cursor_max
- @line += str
- else
- @line = byteinsert(@line, @byte_pointer, str)
- end
- last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer += bytesize
- last_mbchar = @line.byteslice((@byte_pointer - bytesize - last_byte_size), last_byte_size)
- combined_char = last_mbchar + str
- if last_byte_size != 0 and combined_char.grapheme_clusters.size == 1
- # combined char
- last_mbchar_width = Reline::Unicode.get_mbchar_width(last_mbchar)
- combined_char_width = Reline::Unicode.get_mbchar_width(combined_char)
- if combined_char_width > last_mbchar_width
- width = combined_char_width - last_mbchar_width
- else
- width = 0
- end
- end
- @cursor += width
- @cursor_max += width
- end
- alias_method :ed_digit, :ed_insert
- alias_method :self_insert, :ed_insert
-
- private def ed_quoted_insert(str, arg: 1)
- @waiting_proc = proc { |key|
- arg.times do
- if key == "\C-j".ord or key == "\C-m".ord
- key_newline(key)
- elsif key == 0
- # Ignore NUL.
- else
- ed_insert(key)
- end
- end
- @waiting_proc = nil
- }
- end
- alias_method :quoted_insert, :ed_quoted_insert
-
- private def ed_next_char(key, arg: 1)
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if (@byte_pointer < @line.bytesize)
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor += width if width
- @byte_pointer += byte_size
- elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == @line.bytesize and @line_index < @buffer_of_lines.size - 1
- next_line = @buffer_of_lines[@line_index + 1]
- @cursor = 0
- @byte_pointer = 0
- @cursor_max = calculate_width(next_line)
- @previous_line_index = @line_index
- @line_index += 1
- end
- arg -= 1
- ed_next_char(key, arg: arg) if arg > 0
- end
- alias_method :forward_char, :ed_next_char
-
- private def ed_prev_char(key, arg: 1)
- if @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- elsif @is_multiline and @config.editing_mode_is?(:emacs) and @byte_pointer == 0 and @line_index > 0
- prev_line = @buffer_of_lines[@line_index - 1]
- @cursor = calculate_width(prev_line)
- @byte_pointer = prev_line.bytesize
- @cursor_max = calculate_width(prev_line)
- @previous_line_index = @line_index
- @line_index -= 1
- end
- arg -= 1
- ed_prev_char(key, arg: arg) if arg > 0
- end
- alias_method :backward_char, :ed_prev_char
-
- private def vi_first_print(key)
- @byte_pointer, @cursor = Reline::Unicode.vi_first_print(@line)
- end
-
- private def ed_move_to_beg(key)
- @byte_pointer = @cursor = 0
- end
- alias_method :beginning_of_line, :ed_move_to_beg
-
- private def ed_move_to_end(key)
- @byte_pointer = 0
- @cursor = 0
- byte_size = 0
- while @byte_pointer < @line.bytesize
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if byte_size > 0
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- @cursor += Reline::Unicode.get_mbchar_width(mbchar)
- end
- @byte_pointer += byte_size
- end
- end
- alias_method :end_of_line, :ed_move_to_end
-
- private def generate_searcher
- Fiber.new do |first_key|
- prev_search_key = first_key
- search_word = String.new(encoding: @encoding)
- multibyte_buf = String.new(encoding: 'ASCII-8BIT')
- last_hit = nil
- case first_key
- when "\C-r".ord
- prompt_name = 'reverse-i-search'
- when "\C-s".ord
- prompt_name = 'i-search'
- end
- loop do
- key = Fiber.yield(search_word)
- search_again = false
- case key
- when -1 # determined
- Reline.last_incremental_search = search_word
- break
- when "\C-h".ord, "\C-?".ord
- grapheme_clusters = search_word.grapheme_clusters
- if grapheme_clusters.size > 0
- grapheme_clusters.pop
- search_word = grapheme_clusters.join
- end
- when "\C-r".ord, "\C-s".ord
- search_again = true if prev_search_key == key
- prev_search_key = key
- else
- multibyte_buf << key
- if multibyte_buf.dup.force_encoding(@encoding).valid_encoding?
- search_word << multibyte_buf.dup.force_encoding(@encoding)
- multibyte_buf.clear
- end
- end
- hit = nil
- if not search_word.empty? and @line_backup_in_history&.include?(search_word)
- @history_pointer = nil
- hit = @line_backup_in_history
- else
- if search_again
- if search_word.empty? and Reline.last_incremental_search
- search_word = Reline.last_incremental_search
- end
- if @history_pointer
- case prev_search_key
- when "\C-r".ord
- history_pointer_base = 0
- history = Reline::HISTORY[0..(@history_pointer - 1)]
- when "\C-s".ord
- history_pointer_base = @history_pointer + 1
- history = Reline::HISTORY[(@history_pointer + 1)..-1]
- end
- else
- history_pointer_base = 0
- history = Reline::HISTORY
- end
- elsif @history_pointer
- case prev_search_key
- when "\C-r".ord
- history_pointer_base = 0
- history = Reline::HISTORY[0..@history_pointer]
- when "\C-s".ord
- history_pointer_base = @history_pointer
- history = Reline::HISTORY[@history_pointer..-1]
- end
- else
- history_pointer_base = 0
- history = Reline::HISTORY
- end
- case prev_search_key
- when "\C-r".ord
- hit_index = history.rindex { |item|
- item.include?(search_word)
- }
- when "\C-s".ord
- hit_index = history.index { |item|
- item.include?(search_word)
- }
- end
- if hit_index
- @history_pointer = history_pointer_base + hit_index
- hit = Reline::HISTORY[@history_pointer]
- end
- end
- case prev_search_key
- when "\C-r".ord
- prompt_name = 'reverse-i-search'
- when "\C-s".ord
- prompt_name = 'i-search'
- end
- if hit
- if @is_multiline
- @buffer_of_lines = hit.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @byte_pointer = @line.bytesize
- @cursor = @cursor_max = calculate_width(@line)
- @rerender_all = true
- @searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
- else
- @line = hit
- @searching_prompt = "(%s)`%s': %s" % [prompt_name, search_word, hit]
- end
- last_hit = hit
- else
- if @is_multiline
- @rerender_all = true
- @searching_prompt = "(failed %s)`%s'" % [prompt_name, search_word]
- else
- @searching_prompt = "(failed %s)`%s': %s" % [prompt_name, search_word, last_hit]
- end
- end
- end
- end
- end
-
- private def incremental_search_history(key)
- unless @history_pointer
- if @is_multiline
- @line_backup_in_history = whole_buffer
- else
- @line_backup_in_history = @line
- end
- end
- searcher = generate_searcher
- searcher.resume(key)
- @searching_prompt = "(reverse-i-search)`': "
- termination_keys = ["\C-j".ord]
- termination_keys.concat(@config.isearch_terminators&.chars&.map(&:ord)) if @config.isearch_terminators
- @waiting_proc = ->(k) {
- case k
- when *termination_keys
- if @history_pointer
- buffer = Reline::HISTORY[@history_pointer]
- else
- buffer = @line_backup_in_history
- end
- if @is_multiline
- @buffer_of_lines = buffer.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line = buffer
- end
- @searching_prompt = nil
- @waiting_proc = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- @rerender_all = true
- @cached_prompt_list = nil
- searcher.resume(-1)
- when "\C-g".ord
- if @is_multiline
- @buffer_of_lines = @line_backup_in_history.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line = @line_backup_in_history
- end
- @history_pointer = nil
- @searching_prompt = nil
- @waiting_proc = nil
- @line_backup_in_history = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- @rerender_all = true
- else
- chr = k.is_a?(String) ? k : k.chr(Encoding::ASCII_8BIT)
- if chr.match?(/[[:print:]]/) or k == "\C-h".ord or k == "\C-?".ord or k == "\C-r".ord or k == "\C-s".ord
- searcher.resume(k)
- else
- if @history_pointer
- line = Reline::HISTORY[@history_pointer]
- else
- line = @line_backup_in_history
- end
- if @is_multiline
- @line_backup_in_history = whole_buffer
- @buffer_of_lines = line.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line_backup_in_history = @line
- @line = line
- end
- @searching_prompt = nil
- @waiting_proc = nil
- @cursor_max = calculate_width(@line)
- @cursor = @byte_pointer = 0
- @rerender_all = true
- @cached_prompt_list = nil
- searcher.resume(-1)
- end
- end
- }
- end
-
- private def vi_search_prev(key)
- incremental_search_history(key)
- end
- alias_method :reverse_search_history, :vi_search_prev
-
- private def vi_search_next(key)
- incremental_search_history(key)
- end
- alias_method :forward_search_history, :vi_search_next
-
- private def ed_search_prev_history(key, arg: 1)
- history = nil
- h_pointer = nil
- line_no = nil
- substr = @line.slice(0, @byte_pointer)
- if @history_pointer.nil?
- return if not @line.empty? and substr.empty?
- history = Reline::HISTORY
- elsif @history_pointer.zero?
- history = nil
- h_pointer = nil
- else
- history = Reline::HISTORY.slice(0, @history_pointer)
- end
- return if history.nil?
- if @is_multiline
- h_pointer = history.rindex { |h|
- h.split("\n").each_with_index { |l, i|
- if l.start_with?(substr)
- line_no = i
- break
- end
- }
- not line_no.nil?
- }
- else
- h_pointer = history.rindex { |l|
- l.start_with?(substr)
- }
- end
- return if h_pointer.nil?
- @history_pointer = h_pointer
- if @is_multiline
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = line_no
- @line = @buffer_of_lines[@line_index]
- @rerender_all = true
- else
- @line = Reline::HISTORY[@history_pointer]
- end
- @cursor_max = calculate_width(@line)
- arg -= 1
- ed_search_prev_history(key, arg: arg) if arg > 0
- end
- alias_method :history_search_backward, :ed_search_prev_history
-
- private def ed_search_next_history(key, arg: 1)
- substr = @line.slice(0, @byte_pointer)
- if @history_pointer.nil?
- return
- elsif @history_pointer == (Reline::HISTORY.size - 1) and not substr.empty?
- return
- end
- history = Reline::HISTORY.slice((@history_pointer + 1)..-1)
- h_pointer = nil
- line_no = nil
- if @is_multiline
- h_pointer = history.index { |h|
- h.split("\n").each_with_index { |l, i|
- if l.start_with?(substr)
- line_no = i
- break
- end
- }
- not line_no.nil?
- }
- else
- h_pointer = history.index { |l|
- l.start_with?(substr)
- }
- end
- h_pointer += @history_pointer + 1 if h_pointer and @history_pointer
- return if h_pointer.nil? and not substr.empty?
- @history_pointer = h_pointer
- if @is_multiline
- if @history_pointer.nil? and substr.empty?
- @buffer_of_lines = []
- @line_index = 0
- else
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @line_index = line_no
- end
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line = @buffer_of_lines[@line_index]
- @rerender_all = true
- else
- if @history_pointer.nil? and substr.empty?
- @line = ''
- else
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- @cursor_max = calculate_width(@line)
- arg -= 1
- ed_search_next_history(key, arg: arg) if arg > 0
- end
- alias_method :history_search_forward, :ed_search_next_history
-
- private def ed_prev_history(key, arg: 1)
- if @is_multiline and @line_index > 0
- @previous_line_index = @line_index
- @line_index -= 1
- return
- end
- if Reline::HISTORY.empty?
- return
- end
- if @history_pointer.nil?
- @history_pointer = Reline::HISTORY.size - 1
- if @is_multiline
- @line_backup_in_history = whole_buffer
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- @line_backup_in_history = @line
- @line = Reline::HISTORY[@history_pointer]
- end
- elsif @history_pointer.zero?
- return
- else
- if @is_multiline
- Reline::HISTORY[@history_pointer] = whole_buffer
- @history_pointer -= 1
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = @buffer_of_lines.size - 1
- @line = @buffer_of_lines.last
- @rerender_all = true
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer -= 1
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- if @config.editing_mode_is?(:emacs, :vi_insert)
- @cursor_max = @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- elsif @config.editing_mode_is?(:vi_command)
- @byte_pointer = @cursor = 0
- @cursor_max = calculate_width(@line)
- end
- arg -= 1
- ed_prev_history(key, arg: arg) if arg > 0
- end
- alias_method :previous_history, :ed_prev_history
-
- private def ed_next_history(key, arg: 1)
- if @is_multiline and @line_index < (@buffer_of_lines.size - 1)
- @previous_line_index = @line_index
- @line_index += 1
- return
- end
- if @history_pointer.nil?
- return
- elsif @history_pointer == (Reline::HISTORY.size - 1)
- if @is_multiline
- @history_pointer = nil
- @buffer_of_lines = @line_backup_in_history.split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = 0
- @line = @buffer_of_lines.first
- @rerender_all = true
- else
- @history_pointer = nil
- @line = @line_backup_in_history
- end
- else
- if @is_multiline
- Reline::HISTORY[@history_pointer] = whole_buffer
- @history_pointer += 1
- @buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = 0
- @line = @buffer_of_lines.first
- @rerender_all = true
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer += 1
- @line = Reline::HISTORY[@history_pointer]
- end
- end
- @line = '' unless @line
- if @config.editing_mode_is?(:emacs, :vi_insert)
- @cursor_max = @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- elsif @config.editing_mode_is?(:vi_command)
- @byte_pointer = @cursor = 0
- @cursor_max = calculate_width(@line)
- end
- arg -= 1
- ed_next_history(key, arg: arg) if arg > 0
- end
- alias_method :next_history, :ed_next_history
-
- private def ed_newline(key)
- process_insert(force: true)
- if @is_multiline
- if @config.editing_mode_is?(:vi_command)
- if @line_index < (@buffer_of_lines.size - 1)
- ed_next_history(key) # means cursor down
- else
- # should check confirm_multiline_termination to finish?
- finish
- end
- else
- if @line_index == (@buffer_of_lines.size - 1)
- if confirm_multiline_termination
- finish
- else
- key_newline(key)
- end
- else
- # should check confirm_multiline_termination to finish?
- @previous_line_index = @line_index
- @line_index = @buffer_of_lines.size - 1
- finish
- end
- end
- else
- if @history_pointer
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer = nil
- end
- finish
- end
- end
-
- private def em_delete_prev_char(key, arg: 1)
- if @is_multiline and @cursor == 0 and @line_index > 0
- @buffer_of_lines[@line_index] = @line
- @cursor = calculate_width(@buffer_of_lines[@line_index - 1])
- @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
- @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
- @line_index -= 1
- @line = @buffer_of_lines[@line_index]
- @cursor_max = calculate_width(@line)
- @rerender_all = true
- elsif @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- arg -= 1
- em_delete_prev_char(key, arg: arg) if arg > 0
- end
- alias_method :backward_delete_char, :em_delete_prev_char
-
- # Editline:: +ed-kill-line+ (vi command: +D+, +Ctrl-K+; emacs: +Ctrl-K+,
- # +Ctrl-U+) + Kill from the cursor to the end of the line.
- # GNU Readline:: +kill-line+ (+C-k+) Kill the text from point to the end of
- # the line. With a negative numeric argument, kill backward
- # from the cursor to the beginning of the current line.
- private def ed_kill_line(key)
- if @line.bytesize > @byte_pointer
- @line, deleted = byteslice!(@line, @byte_pointer, @line.bytesize - @byte_pointer)
- @byte_pointer = @line.bytesize
- @cursor = @cursor_max = calculate_width(@line)
- @kill_ring.append(deleted)
- elsif @is_multiline and @byte_pointer == @line.bytesize and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += @buffer_of_lines.delete_at(@line_index + 1)
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- end
- alias_method :kill_line, :ed_kill_line
-
- # Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
- # beginning of the edit buffer to the cursor and save it to the
- # cut buffer.
- # GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor
- # to the beginning of the current line.
- private def vi_kill_line_prev(key)
- if @byte_pointer > 0
- @line, deleted = byteslice!(@line, 0, @byte_pointer)
- @byte_pointer = 0
- @kill_ring.append(deleted, true)
- @cursor_max = calculate_width(@line)
- @cursor = 0
- end
- end
- alias_method :unix_line_discard, :vi_kill_line_prev
-
- # Editline:: +em-kill-line+ (not bound) Delete the entire contents of the
- # edit buffer and save it to the cut buffer. +vi-kill-line-prev+
- # GNU Readline:: +kill-whole-line+ (not bound) Kill all characters on the
- # current line, no matter where point is.
- private def em_kill_line(key)
- if @line.size > 0
- @kill_ring.append(@line.dup, true)
- @line.clear
- @byte_pointer = 0
- @cursor_max = 0
- @cursor = 0
- end
- end
- alias_method :kill_whole_line, :em_kill_line
-
- private def em_delete(key)
- if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
- @line = nil
- if @buffer_of_lines.size > 1
- scroll_down(@highest_in_all - @first_line_started_from)
- end
- Reline::IOGate.move_cursor_column(0)
- @eof = true
- finish
- elsif @byte_pointer < @line.bytesize
- splitted_last = @line.byteslice(@byte_pointer, @line.bytesize)
- mbchar = splitted_last.grapheme_clusters.first
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor_max -= width
- @line, = byteslice!(@line, @byte_pointer, mbchar.bytesize)
- elsif @is_multiline and @byte_pointer == @line.bytesize and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += @buffer_of_lines.delete_at(@line_index + 1)
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- end
- alias_method :delete_char, :em_delete
-
- private def em_delete_or_list(key)
- if @line.empty? or @byte_pointer < @line.bytesize
- em_delete(key)
- else # show completed list
- result = call_completion_proc
- if result.is_a?(Array)
- complete(result, true)
- end
- end
- end
- alias_method :delete_char_or_list, :em_delete_or_list
-
- private def em_yank(key)
- yanked = @kill_ring.yank
- if yanked
- @line = byteinsert(@line, @byte_pointer, yanked)
- yanked_width = calculate_width(yanked)
- @cursor += yanked_width
- @cursor_max += yanked_width
- @byte_pointer += yanked.bytesize
- end
- end
- alias_method :yank, :em_yank
-
- private def em_yank_pop(key)
- yanked, prev_yank = @kill_ring.yank_pop
- if yanked
- prev_yank_width = calculate_width(prev_yank)
- @cursor -= prev_yank_width
- @cursor_max -= prev_yank_width
- @byte_pointer -= prev_yank.bytesize
- @line, = byteslice!(@line, @byte_pointer, prev_yank.bytesize)
- @line = byteinsert(@line, @byte_pointer, yanked)
- yanked_width = calculate_width(yanked)
- @cursor += yanked_width
- @cursor_max += yanked_width
- @byte_pointer += yanked.bytesize
- end
- end
- alias_method :yank_pop, :em_yank_pop
-
- private def ed_clear_screen(key)
- @cleared = true
- end
- alias_method :clear_screen, :ed_clear_screen
-
- private def em_next_word(key)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- end
- alias_method :forward_word, :em_next_word
-
- private def ed_prev_word(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- end
- alias_method :backward_word, :ed_prev_word
-
- private def em_delete_next_word(key)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- @line, word = byteslice!(@line, @byte_pointer, byte_size)
- @kill_ring.append(word)
- @cursor_max -= width
- end
- end
-
- private def ed_delete_prev_word(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_backward_word(@line, @byte_pointer)
- @line, word = byteslice!(@line, @byte_pointer - byte_size, byte_size)
- @kill_ring.append(word, true)
- @byte_pointer -= byte_size
- @cursor -= width
- @cursor_max -= width
- end
- end
-
- private def ed_transpose_chars(key)
- if @byte_pointer > 0
- if @cursor_max > @cursor
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- mbchar = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor += width
- @byte_pointer += byte_size
- end
- back1_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- if (@byte_pointer - back1_byte_size) > 0
- back2_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer - back1_byte_size)
- back2_pointer = @byte_pointer - back1_byte_size - back2_byte_size
- @line, back2_mbchar = byteslice!(@line, back2_pointer, back2_byte_size)
- @line = byteinsert(@line, @byte_pointer - back2_byte_size, back2_mbchar)
- end
- end
- end
- alias_method :transpose_chars, :ed_transpose_chars
-
- private def ed_transpose_words(key)
- left_word_start, middle_start, right_word_start, after_start = Reline::Unicode.ed_transpose_words(@line, @byte_pointer)
- before = @line.byteslice(0, left_word_start)
- left_word = @line.byteslice(left_word_start, middle_start - left_word_start)
- middle = @line.byteslice(middle_start, right_word_start - middle_start)
- right_word = @line.byteslice(right_word_start, after_start - right_word_start)
- after = @line.byteslice(after_start, @line.bytesize - after_start)
- return if left_word.empty? or right_word.empty?
- @line = before + right_word + middle + left_word + after
- from_head_to_left_word = before + right_word + middle + left_word
- @byte_pointer = from_head_to_left_word.bytesize
- @cursor = calculate_width(from_head_to_left_word)
- end
- alias_method :transpose_words, :ed_transpose_words
-
- private def em_capitol_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, _, new_str = Reline::Unicode.em_forward_word_with_capitalization(@line, @byte_pointer)
- before = @line.byteslice(0, @byte_pointer)
- after = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = before + new_str + after
- @byte_pointer += new_str.bytesize
- @cursor += calculate_width(new_str)
- end
- end
- alias_method :capitalize_word, :em_capitol_case
-
- private def em_lower_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- part = @line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
- mbchar =~ /[A-Z]/ ? mbchar.downcase : mbchar
- }.join
- rest = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = @line.byteslice(0, @byte_pointer) + part
- @byte_pointer = @line.bytesize
- @cursor = calculate_width(@line)
- @cursor_max = @cursor + calculate_width(rest)
- @line += rest
- end
- end
- alias_method :downcase_word, :em_lower_case
-
- private def em_upper_case(key)
- if @line.bytesize > @byte_pointer
- byte_size, = Reline::Unicode.em_forward_word(@line, @byte_pointer)
- part = @line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
- mbchar =~ /[a-z]/ ? mbchar.upcase : mbchar
- }.join
- rest = @line.byteslice((@byte_pointer + byte_size)..-1)
- @line = @line.byteslice(0, @byte_pointer) + part
- @byte_pointer = @line.bytesize
- @cursor = calculate_width(@line)
- @cursor_max = @cursor + calculate_width(rest)
- @line += rest
- end
- end
- alias_method :upcase_word, :em_upper_case
-
- private def em_kill_region(key)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.em_big_backward_word(@line, @byte_pointer)
- @line, deleted = byteslice!(@line, @byte_pointer - byte_size, byte_size)
- @byte_pointer -= byte_size
- @cursor -= width
- @cursor_max -= width
- @kill_ring.append(deleted, true)
- end
- end
- alias_method :unix_word_rubout, :em_kill_region
-
- private def copy_for_vi(text)
- if @config.editing_mode_is?(:vi_insert) or @config.editing_mode_is?(:vi_command)
- @vi_clipboard = text
- end
- end
-
- private def vi_insert(key)
- @config.editing_mode = :vi_insert
- end
-
- private def vi_add(key)
- @config.editing_mode = :vi_insert
- ed_next_char(key)
- end
-
- private def vi_command_mode(key)
- ed_prev_char(key)
- @config.editing_mode = :vi_command
- end
- alias_method :vi_movement_mode, :vi_command_mode
-
- private def vi_next_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_forward_word(@line, @byte_pointer, @drop_terminate_spaces)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_next_word(key, arg: arg) if arg > 0
- end
-
- private def vi_prev_word(key, arg: 1)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.vi_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- arg -= 1
- vi_prev_word(key, arg: arg) if arg > 0
- end
-
- private def vi_end_word(key, arg: 1, inclusive: false)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_forward_end_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- if inclusive and arg.zero?
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if byte_size > 0
- c = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(c)
- @byte_pointer += byte_size
- @cursor += width
- end
- end
- vi_end_word(key, arg: arg) if arg > 0
- end
-
- private def vi_next_big_word(key, arg: 1)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_big_forward_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- vi_next_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_prev_big_word(key, arg: 1)
- if @byte_pointer > 0
- byte_size, width = Reline::Unicode.vi_big_backward_word(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- arg -= 1
- vi_prev_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_end_big_word(key, arg: 1, inclusive: false)
- if @line.bytesize > @byte_pointer
- byte_size, width = Reline::Unicode.vi_big_forward_end_word(@line, @byte_pointer)
- @byte_pointer += byte_size
- @cursor += width
- end
- arg -= 1
- if inclusive and arg.zero?
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if byte_size > 0
- c = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(c)
- @byte_pointer += byte_size
- @cursor += width
- end
- end
- vi_end_big_word(key, arg: arg) if arg > 0
- end
-
- private def vi_delete_prev_char(key)
- if @is_multiline and @cursor == 0 and @line_index > 0
- @buffer_of_lines[@line_index] = @line
- @cursor = calculate_width(@buffer_of_lines[@line_index - 1])
- @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
- @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
- @line_index -= 1
- @line = @buffer_of_lines[@line_index]
- @cursor_max = calculate_width(@line)
- @rerender_all = true
- elsif @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- end
-
- private def vi_insert_at_bol(key)
- ed_move_to_beg(key)
- @config.editing_mode = :vi_insert
- end
-
- private def vi_add_at_eol(key)
- ed_move_to_end(key)
- @config.editing_mode = :vi_insert
- end
-
- private def ed_delete_prev_char(key, arg: 1)
- deleted = ''
- arg.times do
- if @cursor > 0
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- @byte_pointer -= byte_size
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- deleted.prepend(mbchar)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor -= width
- @cursor_max -= width
- end
- end
- copy_for_vi(deleted)
- end
-
- private def vi_zero(key)
- @byte_pointer = 0
- @cursor = 0
- end
-
- private def vi_change_meta(key, arg: 1)
- @drop_terminate_spaces = true
- @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
- if byte_pointer_diff > 0
- @line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
- elsif byte_pointer_diff < 0
- @line, cut = byteslice!(@line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
- end
- copy_for_vi(cut)
- @cursor += cursor_diff if cursor_diff < 0
- @cursor_max -= cursor_diff.abs
- @byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
- @config.editing_mode = :vi_insert
- @drop_terminate_spaces = false
- }
- @waiting_operator_vi_arg = arg
- end
-
- private def vi_delete_meta(key, arg: 1)
- @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
- if byte_pointer_diff > 0
- @line, cut = byteslice!(@line, @byte_pointer, byte_pointer_diff)
- elsif byte_pointer_diff < 0
- @line, cut = byteslice!(@line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
- end
- copy_for_vi(cut)
- @cursor += cursor_diff if cursor_diff < 0
- @cursor_max -= cursor_diff.abs
- @byte_pointer += byte_pointer_diff if byte_pointer_diff < 0
- }
- @waiting_operator_vi_arg = arg
- end
-
- private def vi_yank(key, arg: 1)
- @waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
- if byte_pointer_diff > 0
- cut = @line.byteslice(@byte_pointer, byte_pointer_diff)
- elsif byte_pointer_diff < 0
- cut = @line.byteslice(@byte_pointer + byte_pointer_diff, -byte_pointer_diff)
- end
- copy_for_vi(cut)
- }
- @waiting_operator_vi_arg = arg
- end
-
- private def vi_list_or_eof(key)
- if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
- @line = nil
- if @buffer_of_lines.size > 1
- scroll_down(@highest_in_all - @first_line_started_from)
- end
- Reline::IOGate.move_cursor_column(0)
- @eof = true
- finish
- else
- ed_newline(key)
- end
- end
- alias_method :vi_end_of_transmission, :vi_list_or_eof
- alias_method :vi_eof_maybe, :vi_list_or_eof
-
- private def ed_delete_next_char(key, arg: 1)
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- unless @line.empty? || byte_size == 0
- @line, mbchar = byteslice!(@line, @byte_pointer, byte_size)
- copy_for_vi(mbchar)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @cursor_max -= width
- if @cursor > 0 and @cursor >= @cursor_max
- byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
- mbchar = @line.byteslice(@byte_pointer - byte_size, byte_size)
- width = Reline::Unicode.get_mbchar_width(mbchar)
- @byte_pointer -= byte_size
- @cursor -= width
- end
- end
- arg -= 1
- ed_delete_next_char(key, arg: arg) if arg > 0
- end
-
- private def vi_to_history_line(key)
- if Reline::HISTORY.empty?
- return
- end
- if @history_pointer.nil?
- @history_pointer = 0
- @line_backup_in_history = @line
- @line = Reline::HISTORY[@history_pointer]
- @cursor_max = calculate_width(@line)
- @cursor = 0
- @byte_pointer = 0
- elsif @history_pointer.zero?
- return
- else
- Reline::HISTORY[@history_pointer] = @line
- @history_pointer = 0
- @line = Reline::HISTORY[@history_pointer]
- @cursor_max = calculate_width(@line)
- @cursor = 0
- @byte_pointer = 0
- end
- end
-
- private def vi_histedit(key)
- path = Tempfile.open { |fp|
- if @is_multiline
- fp.write whole_lines.join("\n")
- else
- fp.write @line
- end
- fp.path
- }
- system("#{ENV['EDITOR']} #{path}")
- if @is_multiline
- @buffer_of_lines = File.read(path).split("\n")
- @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
- @line_index = 0
- @line = @buffer_of_lines[@line_index]
- @rerender_all = true
- else
- @line = File.read(path)
- end
- finish
- end
-
- private def vi_paste_prev(key, arg: 1)
- if @vi_clipboard.size > 0
- @line = byteinsert(@line, @byte_pointer, @vi_clipboard)
- @cursor_max += calculate_width(@vi_clipboard)
- cursor_point = @vi_clipboard.grapheme_clusters[0..-2].join
- @cursor += calculate_width(cursor_point)
- @byte_pointer += cursor_point.bytesize
- end
- arg -= 1
- vi_paste_prev(key, arg: arg) if arg > 0
- end
-
- private def vi_paste_next(key, arg: 1)
- if @vi_clipboard.size > 0
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- @line = byteinsert(@line, @byte_pointer + byte_size, @vi_clipboard)
- @cursor_max += calculate_width(@vi_clipboard)
- @cursor += calculate_width(@vi_clipboard)
- @byte_pointer += @vi_clipboard.bytesize
- end
- arg -= 1
- vi_paste_next(key, arg: arg) if arg > 0
- end
-
- private def ed_argument_digit(key)
- if @vi_arg.nil?
- if key.chr.to_i.zero?
- if key.anybits?(0b10000000)
- unescaped_key = key ^ 0b10000000
- unless unescaped_key.chr.to_i.zero?
- @vi_arg = unescaped_key.chr.to_i
- end
- end
- else
- @vi_arg = key.chr.to_i
- end
- else
- @vi_arg = @vi_arg * 10 + key.chr.to_i
- end
- end
-
- private def vi_to_column(key, arg: 0)
- @byte_pointer, @cursor = @line.grapheme_clusters.inject([0, 0]) { |total, gc|
- # total has [byte_size, cursor]
- mbchar_width = Reline::Unicode.get_mbchar_width(gc)
- if (total.last + mbchar_width) >= arg
- break total
- elsif (total.last + mbchar_width) >= @cursor_max
- break total
- else
- total = [total.first + gc.bytesize, total.last + mbchar_width]
- total
- end
- }
- end
-
- private def vi_replace_char(key, arg: 1)
- @waiting_proc = ->(k) {
- if arg == 1
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- before = @line.byteslice(0, @byte_pointer)
- remaining_point = @byte_pointer + byte_size
- after = @line.byteslice(remaining_point, @line.bytesize - remaining_point)
- @line = before + k.chr + after
- @cursor_max = calculate_width(@line)
- @waiting_proc = nil
- elsif arg > 1
- byte_size = 0
- arg.times do
- byte_size += Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer + byte_size)
- end
- before = @line.byteslice(0, @byte_pointer)
- remaining_point = @byte_pointer + byte_size
- after = @line.byteslice(remaining_point, @line.bytesize - remaining_point)
- replaced = k.chr * arg
- @line = before + replaced + after
- @byte_pointer += replaced.bytesize
- @cursor += calculate_width(replaced)
- @cursor_max = calculate_width(@line)
- @waiting_proc = nil
- end
- }
- end
-
- private def vi_next_char(key, arg: 1, inclusive: false)
- @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, inclusive: inclusive) }
- end
-
- private def vi_to_next_char(key, arg: 1, inclusive: false)
- @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, need_prev_char: true, inclusive: inclusive) }
- end
-
- private def search_next_char(key, arg, need_prev_char: false, inclusive: false)
- if key.instance_of?(String)
- inputed_char = key
- else
- inputed_char = key.chr
- end
- prev_total = nil
- total = nil
- found = false
- @line.byteslice(@byte_pointer..-1).grapheme_clusters.each do |mbchar|
- # total has [byte_size, cursor]
- unless total
- # skip cursor point
- width = Reline::Unicode.get_mbchar_width(mbchar)
- total = [mbchar.bytesize, width]
- else
- if inputed_char == mbchar
- arg -= 1
- if arg.zero?
- found = true
- break
- end
- end
- width = Reline::Unicode.get_mbchar_width(mbchar)
- prev_total = total
- total = [total.first + mbchar.bytesize, total.last + width]
- end
- end
- if not need_prev_char and found and total
- byte_size, width = total
- @byte_pointer += byte_size
- @cursor += width
- elsif need_prev_char and found and prev_total
- byte_size, width = prev_total
- @byte_pointer += byte_size
- @cursor += width
- end
- if inclusive
- byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
- if byte_size > 0
- c = @line.byteslice(@byte_pointer, byte_size)
- width = Reline::Unicode.get_mbchar_width(c)
- @byte_pointer += byte_size
- @cursor += width
- end
- end
- @waiting_proc = nil
- end
-
- private def vi_prev_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg) }
- end
-
- private def vi_to_prev_char(key, arg: 1)
- @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg, true) }
- end
-
- private def search_prev_char(key, arg, need_next_char = false)
- if key.instance_of?(String)
- inputed_char = key
- else
- inputed_char = key.chr
- end
- prev_total = nil
- total = nil
- found = false
- @line.byteslice(0..@byte_pointer).grapheme_clusters.reverse_each do |mbchar|
- # total has [byte_size, cursor]
- unless total
- # skip cursor point
- width = Reline::Unicode.get_mbchar_width(mbchar)
- total = [mbchar.bytesize, width]
- else
- if inputed_char == mbchar
- arg -= 1
- if arg.zero?
- found = true
- break
- end
- end
- width = Reline::Unicode.get_mbchar_width(mbchar)
- prev_total = total
- total = [total.first + mbchar.bytesize, total.last + width]
- end
- end
- if not need_next_char and found and total
- byte_size, width = total
- @byte_pointer -= byte_size
- @cursor -= width
- elsif need_next_char and found and prev_total
- byte_size, width = prev_total
- @byte_pointer -= byte_size
- @cursor -= width
- end
- @waiting_proc = nil
- end
-
- private def vi_join_lines(key, arg: 1)
- if @is_multiline and @buffer_of_lines.size > @line_index + 1
- @cursor = calculate_width(@line)
- @byte_pointer = @line.bytesize
- @line += ' ' + @buffer_of_lines.delete_at(@line_index + 1).lstrip
- @cursor_max = calculate_width(@line)
- @buffer_of_lines[@line_index] = @line
- @rerender_all = true
- @rest_height += 1
- end
- arg -= 1
- vi_join_lines(key, arg: arg) if arg > 0
- end
-
- private def em_set_mark(key)
- @mark_pointer = [@byte_pointer, @line_index]
- end
- alias_method :set_mark, :em_set_mark
-
- private def em_exchange_mark(key)
- return unless @mark_pointer
- new_pointer = [@byte_pointer, @line_index]
- @previous_line_index = @line_index
- @byte_pointer, @line_index = @mark_pointer
- @cursor = calculate_width(@line.byteslice(0, @byte_pointer))
- @cursor_max = calculate_width(@line)
- @mark_pointer = new_pointer
- end
- alias_method :exchange_point_and_mark, :em_exchange_mark
-end
diff --git a/lib/reline/reline.gemspec b/lib/reline/reline.gemspec
deleted file mode 100644
index 7bf1f8758b..0000000000
--- a/lib/reline/reline.gemspec
+++ /dev/null
@@ -1,25 +0,0 @@
-
-begin
- require_relative 'lib/reline/version'
-rescue LoadError
- require_relative 'version'
-end
-
-Gem::Specification.new do |spec|
- spec.name = 'reline'
- spec.version = Reline::VERSION
- spec.authors = ['aycabta']
- spec.email = ['aycabta@gmail.com']
-
- spec.summary = %q{Alternative GNU Readline or Editline implementation by pure Ruby.}
- spec.description = %q{Alternative GNU Readline or Editline implementation by pure Ruby.}
- spec.homepage = 'https://github.com/ruby/reline'
- spec.license = 'Ruby'
-
- spec.files = Dir['BSDL', 'COPYING', 'README.md', 'license_of_rb-readline', 'lib/**/*']
- spec.require_paths = ['lib']
-
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6')
-
- spec.add_dependency 'io-console', '~> 0.5'
-end
diff --git a/lib/reline/terminfo.rb b/lib/reline/terminfo.rb
deleted file mode 100644
index f53642b919..0000000000
--- a/lib/reline/terminfo.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-begin
- require 'fiddle'
- require 'fiddle/import'
-rescue LoadError
- module Reline::Terminfo
- def self.curses_dl
- false
- end
- end
-end
-
-module Reline::Terminfo
- extend Fiddle::Importer
-
- class TerminfoError < StandardError; end
-
- def self.curses_dl_files
- case RUBY_PLATFORM
- when /mingw/, /mswin/
- # aren't supported
- []
- when /cygwin/
- %w[cygncursesw-10.dll cygncurses-10.dll]
- when /darwin/
- %w[libncursesw.dylib libcursesw.dylib libncurses.dylib libcurses.dylib]
- else
- %w[libncursesw.so libcursesw.so libncurses.so libcurses.so]
- end
- end
-
- @curses_dl = false
- def self.curses_dl
- return @curses_dl unless @curses_dl == false
- if RUBY_VERSION >= '3.0.0'
- # Gem module isn't defined in test-all of the Ruby repository, and
- # Fiddle in Ruby 3.0.0 or later supports Fiddle::TYPE_VARIADIC.
- fiddle_supports_variadic = true
- elsif Fiddle.const_defined?(:VERSION,false) and Gem::Version.create(Fiddle::VERSION) >= Gem::Version.create('1.0.1')
- # Fiddle::TYPE_VARIADIC is supported from Fiddle 1.0.1.
- fiddle_supports_variadic = true
- else
- fiddle_supports_variadic = false
- end
- if fiddle_supports_variadic and not Fiddle.const_defined?(:TYPE_VARIADIC)
- # If the libffi version is not 3.0.5 or higher, there isn't TYPE_VARIADIC.
- fiddle_supports_variadic = false
- end
- if fiddle_supports_variadic
- curses_dl_files.each do |curses_name|
- result = Fiddle::Handle.new(curses_name)
- rescue Fiddle::DLError
- next
- else
- @curses_dl = result
- break
- end
- end
- @curses_dl = nil if @curses_dl == false
- @curses_dl
- end
-end if not Reline.const_defined?(:Terminfo) or not Reline::Terminfo.respond_to?(:curses_dl)
-
-module Reline::Terminfo
- dlload curses_dl
- #extern 'int setupterm(char *term, int fildes, int *errret)'
- @setupterm = Fiddle::Function.new(curses_dl['setupterm'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
- #extern 'char *tigetstr(char *capname)'
- @tigetstr = Fiddle::Function.new(curses_dl['tigetstr'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP)
- begin
- #extern 'char *tiparm(const char *str, ...)'
- @tiparm = Fiddle::Function.new(curses_dl['tiparm'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VARIADIC], Fiddle::TYPE_VOIDP)
- rescue Fiddle::DLError
- # OpenBSD lacks tiparm
- #extern 'char *tparm(const char *str, ...)'
- @tiparm = Fiddle::Function.new(curses_dl['tparm'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VARIADIC], Fiddle::TYPE_VOIDP)
- end
- begin
- #extern 'int tigetflag(char *str)'
- @tigetflag = Fiddle::Function.new(curses_dl['tigetflag'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
- rescue Fiddle::DLError
- # OpenBSD lacks tigetflag
- #extern 'int tgetflag(char *str)'
- @tigetflag = Fiddle::Function.new(curses_dl['tgetflag'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
- end
- begin
- #extern 'int tigetnum(char *str)'
- @tigetnum = Fiddle::Function.new(curses_dl['tigetnum'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
- rescue Fiddle::DLError
- # OpenBSD lacks tigetnum
- #extern 'int tgetnum(char *str)'
- @tigetnum = Fiddle::Function.new(curses_dl['tgetnum'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
- end
-
- def self.setupterm(term, fildes)
- errret_int = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
- ret = @setupterm.(term, fildes, errret_int)
- errret = errret_int[0, Fiddle::SIZEOF_INT].unpack1('i')
- case ret
- when 0 # OK
- 0
- when -1 # ERR
- case errret
- when 1
- raise TerminfoError.new('The terminal is hardcopy, cannot be used for curses applications.')
- when 0
- raise TerminfoError.new('The terminal could not be found, or that it is a generic type, having too little information for curses applications to run.')
- when -1
- raise TerminfoError.new('The terminfo database could not be found.')
- else # unknown
- -1
- end
- else # unknown
- -2
- end
- end
-
- class StringWithTiparm < String
- def tiparm(*args) # for method chain
- Reline::Terminfo.tiparm(self, *args)
- end
- end
-
- def self.tigetstr(capname)
- raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
- capability = @tigetstr.(capname)
- case capability.to_i
- when 0, -1
- raise TerminfoError, "can't find capability: #{capname}"
- end
- StringWithTiparm.new(capability.to_s)
- end
-
- def self.tiparm(str, *args)
- new_args = []
- args.each do |a|
- new_args << Fiddle::TYPE_INT << a
- end
- @tiparm.(str, *new_args).to_s
- end
-
- def self.tigetflag(capname)
- raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
- flag = @tigetflag.(capname).to_i
- case flag
- when -1
- raise TerminfoError, "not boolean capability: #{capname}"
- when 0
- raise TerminfoError, "can't find capability: #{capname}"
- end
- flag
- end
-
- def self.tigetnum(capname)
- raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String)
- num = @tigetnum.(capname).to_i
- case num
- when -2
- raise TerminfoError, "not numeric capability: #{capname}"
- when -1
- raise TerminfoError, "can't find capability: #{capname}"
- end
- num
- end
-
- def self.enabled?
- true
- end
-end if Reline::Terminfo.curses_dl
-
-module Reline::Terminfo
- def self.enabled?
- false
- end
-end unless Reline::Terminfo.curses_dl
diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb
deleted file mode 100644
index 6000c9f82a..0000000000
--- a/lib/reline/unicode.rb
+++ /dev/null
@@ -1,665 +0,0 @@
-class Reline::Unicode
- EscapedPairs = {
- 0x00 => '^@',
- 0x01 => '^A', # C-a
- 0x02 => '^B',
- 0x03 => '^C',
- 0x04 => '^D',
- 0x05 => '^E',
- 0x06 => '^F',
- 0x07 => '^G',
- 0x08 => '^H', # Backspace
- 0x09 => '^I',
- 0x0A => '^J',
- 0x0B => '^K',
- 0x0C => '^L',
- 0x0D => '^M', # Enter
- 0x0E => '^N',
- 0x0F => '^O',
- 0x10 => '^P',
- 0x11 => '^Q',
- 0x12 => '^R',
- 0x13 => '^S',
- 0x14 => '^T',
- 0x15 => '^U',
- 0x16 => '^V',
- 0x17 => '^W',
- 0x18 => '^X',
- 0x19 => '^Y',
- 0x1A => '^Z', # C-z
- 0x1B => '^[', # C-[ C-3
- 0x1D => '^]', # C-]
- 0x1E => '^^', # C-~ C-6
- 0x1F => '^_', # C-_ C-7
- 0x7F => '^?', # C-? C-8
- }
- EscapedChars = EscapedPairs.keys.map(&:chr)
-
- NON_PRINTING_START = "\1"
- NON_PRINTING_END = "\2"
- CSI_REGEXP = /\e\[[\d;]*[ABCDEFGHJKSTfminsuhl]/
- OSC_REGEXP = /\e\]\d+(?:;[^;]+)*\a/
- WIDTH_SCANNER = /\G(?:(#{NON_PRINTING_START})|(#{NON_PRINTING_END})|(#{CSI_REGEXP})|(#{OSC_REGEXP})|(\X))/o
- NON_PRINTING_START_INDEX = 0
- NON_PRINTING_END_INDEX = 1
- CSI_REGEXP_INDEX = 2
- OSC_REGEXP_INDEX = 3
- GRAPHEME_CLUSTER_INDEX = 4
-
- def self.get_mbchar_byte_size_by_first_char(c)
- # Checks UTF-8 character byte size
- case c.ord
- # 0b0xxxxxxx
- when ->(code) { (code ^ 0b10000000).allbits?(0b10000000) } then 1
- # 0b110xxxxx
- when ->(code) { (code ^ 0b00100000).allbits?(0b11100000) } then 2
- # 0b1110xxxx
- when ->(code) { (code ^ 0b00010000).allbits?(0b11110000) } then 3
- # 0b11110xxx
- when ->(code) { (code ^ 0b00001000).allbits?(0b11111000) } then 4
- # 0b111110xx
- when ->(code) { (code ^ 0b00000100).allbits?(0b11111100) } then 5
- # 0b1111110x
- when ->(code) { (code ^ 0b00000010).allbits?(0b11111110) } then 6
- # successor of mbchar
- else 0
- end
- end
-
- def self.escape_for_print(str)
- str.chars.map! { |gr|
- escaped = EscapedPairs[gr.ord]
- if escaped && gr != -"\n" && gr != -"\t"
- escaped
- else
- gr
- end
- }.join
- end
-
- require 'reline/unicode/east_asian_width'
-
- HalfwidthDakutenHandakuten = /[\u{FF9E}\u{FF9F}]/
-
- MBCharWidthRE = /
- (?<width_2_1>
- [#{ EscapedChars.map {|c| "\\x%02x" % c.ord }.join }] (?# ^ + char, such as ^M, ^H, ^[, ...)
- )
- | (?<width_3>^\u{2E3B}) (?# THREE-EM DASH)
- | (?<width_0>^\p{M})
- | (?<width_2_2>
- #{ EastAsianWidth::TYPE_F }
- | #{ EastAsianWidth::TYPE_W }
- )
- | (?<width_1>
- #{ EastAsianWidth::TYPE_H }
- | #{ EastAsianWidth::TYPE_NA }
- | #{ EastAsianWidth::TYPE_N }
- )(?!#{ HalfwidthDakutenHandakuten })
- | (?<width_2_3>
- (?: #{ EastAsianWidth::TYPE_H }
- | #{ EastAsianWidth::TYPE_NA }
- | #{ EastAsianWidth::TYPE_N })
- #{ HalfwidthDakutenHandakuten }
- )
- | (?<ambiguous_width>
- #{EastAsianWidth::TYPE_A}
- )
- /x
-
- def self.get_mbchar_width(mbchar)
- ord = mbchar.ord
- if (0x00 <= ord and ord <= 0x1F) # in EscapedPairs
- return 2
- elsif (0x20 <= ord and ord <= 0x7E) # printable ASCII chars
- return 1
- end
- m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE)
- case
- when m.nil? then 1 # TODO should be U+FFFD � REPLACEMENT CHARACTER
- when m[:width_2_1], m[:width_2_2], m[:width_2_3] then 2
- when m[:width_3] then 3
- when m[:width_0] then 0
- when m[:width_1] then 1
- when m[:ambiguous_width] then Reline.ambiguous_width
- else
- nil
- end
- end
-
- def self.calculate_width(str, allow_escape_code = false)
- if allow_escape_code
- width = 0
- rest = str.encode(Encoding::UTF_8)
- in_zero_width = false
- rest.scan(WIDTH_SCANNER) do |gc|
- case
- when gc[NON_PRINTING_START_INDEX]
- in_zero_width = true
- when gc[NON_PRINTING_END_INDEX]
- in_zero_width = false
- when gc[CSI_REGEXP_INDEX], gc[OSC_REGEXP_INDEX]
- when gc[GRAPHEME_CLUSTER_INDEX]
- gc = gc[GRAPHEME_CLUSTER_INDEX]
- unless in_zero_width
- width += get_mbchar_width(gc)
- end
- end
- end
- width
- else
- str.encode(Encoding::UTF_8).grapheme_clusters.inject(0) { |w, gc|
- w + get_mbchar_width(gc)
- }
- end
- end
-
- def self.split_by_width(str, max_width, encoding = str.encoding)
- lines = [String.new(encoding: encoding)]
- height = 1
- width = 0
- rest = str.encode(Encoding::UTF_8)
- in_zero_width = false
- rest.scan(WIDTH_SCANNER) do |gc|
- case
- when gc[NON_PRINTING_START_INDEX]
- in_zero_width = true
- when gc[NON_PRINTING_END_INDEX]
- in_zero_width = false
- when gc[CSI_REGEXP_INDEX]
- lines.last << gc[CSI_REGEXP_INDEX]
- when gc[OSC_REGEXP_INDEX]
- lines.last << gc[OSC_REGEXP_INDEX]
- when gc[GRAPHEME_CLUSTER_INDEX]
- gc = gc[GRAPHEME_CLUSTER_INDEX]
- unless in_zero_width
- mbchar_width = get_mbchar_width(gc)
- if (width += mbchar_width) > max_width
- width = mbchar_width
- lines << nil
- lines << String.new(encoding: encoding)
- height += 1
- end
- end
- lines.last << gc
- end
- end
- # The cursor moves to next line in first
- if width == max_width
- lines << nil
- lines << String.new(encoding: encoding)
- height += 1
- end
- [lines, height]
- end
-
- # Take a chunk of a String cut by width with escape sequences.
- def self.take_range(str, start_col, max_width, encoding = str.encoding)
- chunk = String.new(encoding: encoding)
- total_width = 0
- rest = str.encode(Encoding::UTF_8)
- in_zero_width = false
- rest.scan(WIDTH_SCANNER) do |gc|
- case
- when gc[NON_PRINTING_START_INDEX]
- in_zero_width = true
- when gc[NON_PRINTING_END_INDEX]
- in_zero_width = false
- when gc[CSI_REGEXP_INDEX]
- chunk << gc[CSI_REGEXP_INDEX]
- when gc[OSC_REGEXP_INDEX]
- chunk << gc[OSC_REGEXP_INDEX]
- when gc[GRAPHEME_CLUSTER_INDEX]
- gc = gc[GRAPHEME_CLUSTER_INDEX]
- if in_zero_width
- chunk << gc
- else
- mbchar_width = get_mbchar_width(gc)
- total_width += mbchar_width
- break if (start_col + max_width) < total_width
- chunk << gc if start_col < total_width
- end
- end
- end
- chunk
- end
-
- def self.get_next_mbchar_size(line, byte_pointer)
- grapheme = line.byteslice(byte_pointer..-1).grapheme_clusters.first
- grapheme ? grapheme.bytesize : 0
- end
-
- def self.get_prev_mbchar_size(line, byte_pointer)
- if byte_pointer.zero?
- 0
- else
- grapheme = line.byteslice(0..(byte_pointer - 1)).grapheme_clusters.last
- grapheme ? grapheme.bytesize : 0
- end
- end
-
- def self.em_forward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.em_forward_word_with_capitalization(line, byte_pointer)
- width = 0
- byte_size = 0
- new_str = String.new
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- new_str += mbchar
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- first = true
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- if first
- new_str += mbchar.upcase
- first = false
- else
- new_str += mbchar.downcase
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width, new_str]
- end
-
- def self.em_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.em_big_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.ed_transpose_words(line, byte_pointer)
- right_word_start = nil
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if size.zero?
- # ' aaa bbb [cursor]'
- byte_size = 0
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- elsif mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- # ' aaa bb[cursor]b'
- byte_size = 0
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- byte_size = 0
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- else
- byte_size = 0
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size += size
- end
- if (byte_pointer + byte_size) == (line.bytesize - 1)
- # ' aaa bbb [cursor] '
- after_start = line.bytesize
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- right_word_start = byte_pointer + byte_size
- else
- # ' aaa [cursor] bbb '
- right_word_start = byte_pointer + byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size += size
- end
- after_start = byte_pointer + byte_size
- end
- end
- byte_size = right_word_start - byte_pointer
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\p{Word}/
- byte_size -= size
- end
- middle_start = byte_pointer + byte_size
- byte_size = middle_start - byte_pointer
- while 0 < (byte_pointer + byte_size)
- size = get_prev_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size - size, size)
- break if mbchar.encode(Encoding::UTF_8) =~ /\P{Word}/
- byte_size -= size
- end
- left_word_start = byte_pointer + byte_size
- [left_word_start, middle_start, right_word_start, after_start]
- end
-
- def self.vi_big_forward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_big_forward_end_word(line, byte_pointer)
- if (line.bytesize - 1) > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- prev_width = width
- prev_byte_size = byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\s/
- prev_width = width
- prev_byte_size = byte_size
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [prev_byte_size, prev_width]
- end
-
- def self.vi_big_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- break if mbchar =~ /\s/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_forward_word(line, byte_pointer, drop_terminate_spaces = false)
- if line.bytesize > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if mbchar =~ /\w/
- started_by = :word
- elsif mbchar =~ /\s/
- started_by = :space
- else
- started_by = :non_word_printable
- end
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :space
- break if mbchar =~ /\S/
- when :non_word_printable
- break if mbchar =~ /\w|\s/
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- return [byte_size, width] if drop_terminate_spaces
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- break if mbchar =~ /\S/
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_forward_end_word(line, byte_pointer)
- if (line.bytesize - 1) > byte_pointer
- size = get_next_mbchar_size(line, byte_pointer)
- mbchar = line.byteslice(byte_pointer, size)
- if mbchar =~ /\w/
- started_by = :word
- elsif mbchar =~ /\s/
- started_by = :space
- else
- started_by = :non_word_printable
- end
- width = get_mbchar_width(mbchar)
- byte_size = size
- else
- return [0, 0]
- end
- if (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- if mbchar =~ /\w/
- second = :word
- elsif mbchar =~ /\s/
- second = :space
- else
- second = :non_word_printable
- end
- second_width = get_mbchar_width(mbchar)
- second_byte_size = size
- else
- return [byte_size, width]
- end
- if second == :space
- width += second_width
- byte_size += second_byte_size
- while (line.bytesize - 1) > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- if mbchar =~ /\S/
- if mbchar =~ /\w/
- started_by = :word
- else
- started_by = :non_word_printable
- end
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- else
- case [started_by, second]
- when [:word, :non_word_printable], [:non_word_printable, :word]
- started_by = second
- else
- width += second_width
- byte_size += second_byte_size
- started_by = second
- end
- end
- prev_width = width
- prev_byte_size = byte_size
- while line.bytesize > (byte_pointer + byte_size)
- size = get_next_mbchar_size(line, byte_pointer + byte_size)
- mbchar = line.byteslice(byte_pointer + byte_size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :non_word_printable
- break if mbchar =~ /[\w\s]/
- end
- prev_width = width
- prev_byte_size = byte_size
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [prev_byte_size, prev_width]
- end
-
- def self.vi_backward_word(line, byte_pointer)
- width = 0
- byte_size = 0
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- if mbchar =~ /\S/
- if mbchar =~ /\w/
- started_by = :word
- else
- started_by = :non_word_printable
- end
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- while 0 < (byte_pointer - byte_size)
- size = get_prev_mbchar_size(line, byte_pointer - byte_size)
- mbchar = line.byteslice(byte_pointer - byte_size - size, size)
- case started_by
- when :word
- break if mbchar =~ /\W/
- when :non_word_printable
- break if mbchar =~ /[\w\s]/
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-
- def self.vi_first_print(line)
- width = 0
- byte_size = 0
- while (line.bytesize - 1) > byte_size
- size = get_next_mbchar_size(line, byte_size)
- mbchar = line.byteslice(byte_size, size)
- if mbchar =~ /\S/
- break
- end
- width += get_mbchar_width(mbchar)
- byte_size += size
- end
- [byte_size, width]
- end
-end
diff --git a/lib/reline/unicode/east_asian_width.rb b/lib/reline/unicode/east_asian_width.rb
deleted file mode 100644
index 97dfec4c52..0000000000
--- a/lib/reline/unicode/east_asian_width.rb
+++ /dev/null
@@ -1,1196 +0,0 @@
-class Reline::Unicode::EastAsianWidth
- # This is based on EastAsianWidth.txt
- # EastAsianWidth.txt
-
- # Fullwidth
- TYPE_F = /^[#{ %W(
- \u{3000}
- \u{FF01}-\u{FF60}
- \u{FFE0}-\u{FFE6}
- ).join }]/
-
- # Halfwidth
- TYPE_H = /^[#{ %W(
- \u{20A9}
- \u{FF61}-\u{FFBE}
- \u{FFC2}-\u{FFC7}
- \u{FFCA}-\u{FFCF}
- \u{FFD2}-\u{FFD7}
- \u{FFDA}-\u{FFDC}
- \u{FFE8}-\u{FFEE}
- ).join }]/
-
- # Wide
- TYPE_W = /^[#{ %W(
- \u{1100}-\u{115F}
- \u{231A}-\u{231B}
- \u{2329}-\u{232A}
- \u{23E9}-\u{23EC}
- \u{23F0}
- \u{23F3}
- \u{25FD}-\u{25FE}
- \u{2614}-\u{2615}
- \u{2648}-\u{2653}
- \u{267F}
- \u{2693}
- \u{26A1}
- \u{26AA}-\u{26AB}
- \u{26BD}-\u{26BE}
- \u{26C4}-\u{26C5}
- \u{26CE}
- \u{26D4}
- \u{26EA}
- \u{26F2}-\u{26F3}
- \u{26F5}
- \u{26FA}
- \u{26FD}
- \u{2705}
- \u{270A}-\u{270B}
- \u{2728}
- \u{274C}
- \u{274E}
- \u{2753}-\u{2755}
- \u{2757}
- \u{2795}-\u{2797}
- \u{27B0}
- \u{27BF}
- \u{2B1B}-\u{2B1C}
- \u{2B50}
- \u{2B55}
- \u{2E80}-\u{2E99}
- \u{2E9B}-\u{2EF3}
- \u{2F00}-\u{2FD5}
- \u{2FF0}-\u{2FFB}
- \u{3001}-\u{303E}
- \u{3041}-\u{3096}
- \u{3099}-\u{30FF}
- \u{3105}-\u{312F}
- \u{3131}-\u{318E}
- \u{3190}-\u{31E3}
- \u{31F0}-\u{321E}
- \u{3220}-\u{3247}
- \u{3250}-\u{4DBF}
- \u{4E00}-\u{A48C}
- \u{A490}-\u{A4C6}
- \u{A960}-\u{A97C}
- \u{AC00}-\u{D7A3}
- \u{F900}-\u{FAFF}
- \u{FE10}-\u{FE19}
- \u{FE30}-\u{FE52}
- \u{FE54}-\u{FE66}
- \u{FE68}-\u{FE6B}
- \u{16FE0}-\u{16FE4}
- \u{16FF0}-\u{16FF1}
- \u{17000}-\u{187F7}
- \u{18800}-\u{18CD5}
- \u{18D00}-\u{18D08}
- \u{1AFF0}-\u{1AFF3}
- \u{1AFF5}-\u{1AFFB}
- \u{1AFFD}-\u{1AFFE}
- \u{1B000}-\u{1B122}
- \u{1B132}
- \u{1B150}-\u{1B152}
- \u{1B155}
- \u{1B164}-\u{1B167}
- \u{1B170}-\u{1B2FB}
- \u{1F004}
- \u{1F0CF}
- \u{1F18E}
- \u{1F191}-\u{1F19A}
- \u{1F200}-\u{1F202}
- \u{1F210}-\u{1F23B}
- \u{1F240}-\u{1F248}
- \u{1F250}-\u{1F251}
- \u{1F260}-\u{1F265}
- \u{1F300}-\u{1F320}
- \u{1F32D}-\u{1F335}
- \u{1F337}-\u{1F37C}
- \u{1F37E}-\u{1F393}
- \u{1F3A0}-\u{1F3CA}
- \u{1F3CF}-\u{1F3D3}
- \u{1F3E0}-\u{1F3F0}
- \u{1F3F4}
- \u{1F3F8}-\u{1F43E}
- \u{1F440}
- \u{1F442}-\u{1F4FC}
- \u{1F4FF}-\u{1F53D}
- \u{1F54B}-\u{1F54E}
- \u{1F550}-\u{1F567}
- \u{1F57A}
- \u{1F595}-\u{1F596}
- \u{1F5A4}
- \u{1F5FB}-\u{1F64F}
- \u{1F680}-\u{1F6C5}
- \u{1F6CC}
- \u{1F6D0}-\u{1F6D2}
- \u{1F6D5}-\u{1F6D7}
- \u{1F6DC}-\u{1F6DF}
- \u{1F6EB}-\u{1F6EC}
- \u{1F6F4}-\u{1F6FC}
- \u{1F7E0}-\u{1F7EB}
- \u{1F7F0}
- \u{1F90C}-\u{1F93A}
- \u{1F93C}-\u{1F945}
- \u{1F947}-\u{1F9FF}
- \u{1FA70}-\u{1FA7C}
- \u{1FA80}-\u{1FA88}
- \u{1FA90}-\u{1FABD}
- \u{1FABF}-\u{1FAC5}
- \u{1FACE}-\u{1FADB}
- \u{1FAE0}-\u{1FAE8}
- \u{1FAF0}-\u{1FAF8}
- \u{20000}-\u{2FFFD}
- \u{30000}-\u{3FFFD}
- ).join }]/
-
- # Narrow
- TYPE_NA = /^[#{ %W(
- \u{0020}-\u{007E}
- \u{00A2}-\u{00A3}
- \u{00A5}-\u{00A6}
- \u{00AC}
- \u{00AF}
- \u{27E6}-\u{27ED}
- \u{2985}-\u{2986}
- ).join }]/
-
- # Ambiguous
- TYPE_A = /^[#{ %W(
- \u{00A1}
- \u{00A4}
- \u{00A7}-\u{00A8}
- \u{00AA}
- \u{00AD}-\u{00AE}
- \u{00B0}-\u{00B4}
- \u{00B6}-\u{00BA}
- \u{00BC}-\u{00BF}
- \u{00C6}
- \u{00D0}
- \u{00D7}-\u{00D8}
- \u{00DE}-\u{00E1}
- \u{00E6}
- \u{00E8}-\u{00EA}
- \u{00EC}-\u{00ED}
- \u{00F0}
- \u{00F2}-\u{00F3}
- \u{00F7}-\u{00FA}
- \u{00FC}
- \u{00FE}
- \u{0101}
- \u{0111}
- \u{0113}
- \u{011B}
- \u{0126}-\u{0127}
- \u{012B}
- \u{0131}-\u{0133}
- \u{0138}
- \u{013F}-\u{0142}
- \u{0144}
- \u{0148}-\u{014B}
- \u{014D}
- \u{0152}-\u{0153}
- \u{0166}-\u{0167}
- \u{016B}
- \u{01CE}
- \u{01D0}
- \u{01D2}
- \u{01D4}
- \u{01D6}
- \u{01D8}
- \u{01DA}
- \u{01DC}
- \u{0251}
- \u{0261}
- \u{02C4}
- \u{02C7}
- \u{02C9}-\u{02CB}
- \u{02CD}
- \u{02D0}
- \u{02D8}-\u{02DB}
- \u{02DD}
- \u{02DF}
- \u{0300}-\u{036F}
- \u{0391}-\u{03A1}
- \u{03A3}-\u{03A9}
- \u{03B1}-\u{03C1}
- \u{03C3}-\u{03C9}
- \u{0401}
- \u{0410}-\u{044F}
- \u{0451}
- \u{2010}
- \u{2013}-\u{2016}
- \u{2018}-\u{2019}
- \u{201C}-\u{201D}
- \u{2020}-\u{2022}
- \u{2024}-\u{2027}
- \u{2030}
- \u{2032}-\u{2033}
- \u{2035}
- \u{203B}
- \u{203E}
- \u{2074}
- \u{207F}
- \u{2081}-\u{2084}
- \u{20AC}
- \u{2103}
- \u{2105}
- \u{2109}
- \u{2113}
- \u{2116}
- \u{2121}-\u{2122}
- \u{2126}
- \u{212B}
- \u{2153}-\u{2154}
- \u{215B}-\u{215E}
- \u{2160}-\u{216B}
- \u{2170}-\u{2179}
- \u{2189}
- \u{2190}-\u{2199}
- \u{21B8}-\u{21B9}
- \u{21D2}
- \u{21D4}
- \u{21E7}
- \u{2200}
- \u{2202}-\u{2203}
- \u{2207}-\u{2208}
- \u{220B}
- \u{220F}
- \u{2211}
- \u{2215}
- \u{221A}
- \u{221D}-\u{2220}
- \u{2223}
- \u{2225}
- \u{2227}-\u{222C}
- \u{222E}
- \u{2234}-\u{2237}
- \u{223C}-\u{223D}
- \u{2248}
- \u{224C}
- \u{2252}
- \u{2260}-\u{2261}
- \u{2264}-\u{2267}
- \u{226A}-\u{226B}
- \u{226E}-\u{226F}
- \u{2282}-\u{2283}
- \u{2286}-\u{2287}
- \u{2295}
- \u{2299}
- \u{22A5}
- \u{22BF}
- \u{2312}
- \u{2460}-\u{24E9}
- \u{24EB}-\u{254B}
- \u{2550}-\u{2573}
- \u{2580}-\u{258F}
- \u{2592}-\u{2595}
- \u{25A0}-\u{25A1}
- \u{25A3}-\u{25A9}
- \u{25B2}-\u{25B3}
- \u{25B6}-\u{25B7}
- \u{25BC}-\u{25BD}
- \u{25C0}-\u{25C1}
- \u{25C6}-\u{25C8}
- \u{25CB}
- \u{25CE}-\u{25D1}
- \u{25E2}-\u{25E5}
- \u{25EF}
- \u{2605}-\u{2606}
- \u{2609}
- \u{260E}-\u{260F}
- \u{261C}
- \u{261E}
- \u{2640}
- \u{2642}
- \u{2660}-\u{2661}
- \u{2663}-\u{2665}
- \u{2667}-\u{266A}
- \u{266C}-\u{266D}
- \u{266F}
- \u{269E}-\u{269F}
- \u{26BF}
- \u{26C6}-\u{26CD}
- \u{26CF}-\u{26D3}
- \u{26D5}-\u{26E1}
- \u{26E3}
- \u{26E8}-\u{26E9}
- \u{26EB}-\u{26F1}
- \u{26F4}
- \u{26F6}-\u{26F9}
- \u{26FB}-\u{26FC}
- \u{26FE}-\u{26FF}
- \u{273D}
- \u{2776}-\u{277F}
- \u{2B56}-\u{2B59}
- \u{3248}-\u{324F}
- \u{E000}-\u{F8FF}
- \u{FE00}-\u{FE0F}
- \u{FFFD}
- \u{1F100}-\u{1F10A}
- \u{1F110}-\u{1F12D}
- \u{1F130}-\u{1F169}
- \u{1F170}-\u{1F18D}
- \u{1F18F}-\u{1F190}
- \u{1F19B}-\u{1F1AC}
- \u{E0100}-\u{E01EF}
- \u{F0000}-\u{FFFFD}
- \u{100000}-\u{10FFFD}
- ).join }]/
-
- # Neutral
- TYPE_N = /^[#{ %W(
- \u{0000}-\u{001F}
- \u{007F}-\u{00A0}
- \u{00A9}
- \u{00AB}
- \u{00B5}
- \u{00BB}
- \u{00C0}-\u{00C5}
- \u{00C7}-\u{00CF}
- \u{00D1}-\u{00D6}
- \u{00D9}-\u{00DD}
- \u{00E2}-\u{00E5}
- \u{00E7}
- \u{00EB}
- \u{00EE}-\u{00EF}
- \u{00F1}
- \u{00F4}-\u{00F6}
- \u{00FB}
- \u{00FD}
- \u{00FF}-\u{0100}
- \u{0102}-\u{0110}
- \u{0112}
- \u{0114}-\u{011A}
- \u{011C}-\u{0125}
- \u{0128}-\u{012A}
- \u{012C}-\u{0130}
- \u{0134}-\u{0137}
- \u{0139}-\u{013E}
- \u{0143}
- \u{0145}-\u{0147}
- \u{014C}
- \u{014E}-\u{0151}
- \u{0154}-\u{0165}
- \u{0168}-\u{016A}
- \u{016C}-\u{01CD}
- \u{01CF}
- \u{01D1}
- \u{01D3}
- \u{01D5}
- \u{01D7}
- \u{01D9}
- \u{01DB}
- \u{01DD}-\u{0250}
- \u{0252}-\u{0260}
- \u{0262}-\u{02C3}
- \u{02C5}-\u{02C6}
- \u{02C8}
- \u{02CC}
- \u{02CE}-\u{02CF}
- \u{02D1}-\u{02D7}
- \u{02DC}
- \u{02DE}
- \u{02E0}-\u{02FF}
- \u{0370}-\u{0377}
- \u{037A}-\u{037F}
- \u{0384}-\u{038A}
- \u{038C}
- \u{038E}-\u{0390}
- \u{03AA}-\u{03B0}
- \u{03C2}
- \u{03CA}-\u{0400}
- \u{0402}-\u{040F}
- \u{0450}
- \u{0452}-\u{052F}
- \u{0531}-\u{0556}
- \u{0559}-\u{058A}
- \u{058D}-\u{058F}
- \u{0591}-\u{05C7}
- \u{05D0}-\u{05EA}
- \u{05EF}-\u{05F4}
- \u{0600}-\u{070D}
- \u{070F}-\u{074A}
- \u{074D}-\u{07B1}
- \u{07C0}-\u{07FA}
- \u{07FD}-\u{082D}
- \u{0830}-\u{083E}
- \u{0840}-\u{085B}
- \u{085E}
- \u{0860}-\u{086A}
- \u{0870}-\u{088E}
- \u{0890}-\u{0891}
- \u{0898}-\u{0983}
- \u{0985}-\u{098C}
- \u{098F}-\u{0990}
- \u{0993}-\u{09A8}
- \u{09AA}-\u{09B0}
- \u{09B2}
- \u{09B6}-\u{09B9}
- \u{09BC}-\u{09C4}
- \u{09C7}-\u{09C8}
- \u{09CB}-\u{09CE}
- \u{09D7}
- \u{09DC}-\u{09DD}
- \u{09DF}-\u{09E3}
- \u{09E6}-\u{09FE}
- \u{0A01}-\u{0A03}
- \u{0A05}-\u{0A0A}
- \u{0A0F}-\u{0A10}
- \u{0A13}-\u{0A28}
- \u{0A2A}-\u{0A30}
- \u{0A32}-\u{0A33}
- \u{0A35}-\u{0A36}
- \u{0A38}-\u{0A39}
- \u{0A3C}
- \u{0A3E}-\u{0A42}
- \u{0A47}-\u{0A48}
- \u{0A4B}-\u{0A4D}
- \u{0A51}
- \u{0A59}-\u{0A5C}
- \u{0A5E}
- \u{0A66}-\u{0A76}
- \u{0A81}-\u{0A83}
- \u{0A85}-\u{0A8D}
- \u{0A8F}-\u{0A91}
- \u{0A93}-\u{0AA8}
- \u{0AAA}-\u{0AB0}
- \u{0AB2}-\u{0AB3}
- \u{0AB5}-\u{0AB9}
- \u{0ABC}-\u{0AC5}
- \u{0AC7}-\u{0AC9}
- \u{0ACB}-\u{0ACD}
- \u{0AD0}
- \u{0AE0}-\u{0AE3}
- \u{0AE6}-\u{0AF1}
- \u{0AF9}-\u{0AFF}
- \u{0B01}-\u{0B03}
- \u{0B05}-\u{0B0C}
- \u{0B0F}-\u{0B10}
- \u{0B13}-\u{0B28}
- \u{0B2A}-\u{0B30}
- \u{0B32}-\u{0B33}
- \u{0B35}-\u{0B39}
- \u{0B3C}-\u{0B44}
- \u{0B47}-\u{0B48}
- \u{0B4B}-\u{0B4D}
- \u{0B55}-\u{0B57}
- \u{0B5C}-\u{0B5D}
- \u{0B5F}-\u{0B63}
- \u{0B66}-\u{0B77}
- \u{0B82}-\u{0B83}
- \u{0B85}-\u{0B8A}
- \u{0B8E}-\u{0B90}
- \u{0B92}-\u{0B95}
- \u{0B99}-\u{0B9A}
- \u{0B9C}
- \u{0B9E}-\u{0B9F}
- \u{0BA3}-\u{0BA4}
- \u{0BA8}-\u{0BAA}
- \u{0BAE}-\u{0BB9}
- \u{0BBE}-\u{0BC2}
- \u{0BC6}-\u{0BC8}
- \u{0BCA}-\u{0BCD}
- \u{0BD0}
- \u{0BD7}
- \u{0BE6}-\u{0BFA}
- \u{0C00}-\u{0C0C}
- \u{0C0E}-\u{0C10}
- \u{0C12}-\u{0C28}
- \u{0C2A}-\u{0C39}
- \u{0C3C}-\u{0C44}
- \u{0C46}-\u{0C48}
- \u{0C4A}-\u{0C4D}
- \u{0C55}-\u{0C56}
- \u{0C58}-\u{0C5A}
- \u{0C5D}
- \u{0C60}-\u{0C63}
- \u{0C66}-\u{0C6F}
- \u{0C77}-\u{0C8C}
- \u{0C8E}-\u{0C90}
- \u{0C92}-\u{0CA8}
- \u{0CAA}-\u{0CB3}
- \u{0CB5}-\u{0CB9}
- \u{0CBC}-\u{0CC4}
- \u{0CC6}-\u{0CC8}
- \u{0CCA}-\u{0CCD}
- \u{0CD5}-\u{0CD6}
- \u{0CDD}-\u{0CDE}
- \u{0CE0}-\u{0CE3}
- \u{0CE6}-\u{0CEF}
- \u{0CF1}-\u{0CF3}
- \u{0D00}-\u{0D0C}
- \u{0D0E}-\u{0D10}
- \u{0D12}-\u{0D44}
- \u{0D46}-\u{0D48}
- \u{0D4A}-\u{0D4F}
- \u{0D54}-\u{0D63}
- \u{0D66}-\u{0D7F}
- \u{0D81}-\u{0D83}
- \u{0D85}-\u{0D96}
- \u{0D9A}-\u{0DB1}
- \u{0DB3}-\u{0DBB}
- \u{0DBD}
- \u{0DC0}-\u{0DC6}
- \u{0DCA}
- \u{0DCF}-\u{0DD4}
- \u{0DD6}
- \u{0DD8}-\u{0DDF}
- \u{0DE6}-\u{0DEF}
- \u{0DF2}-\u{0DF4}
- \u{0E01}-\u{0E3A}
- \u{0E3F}-\u{0E5B}
- \u{0E81}-\u{0E82}
- \u{0E84}
- \u{0E86}-\u{0E8A}
- \u{0E8C}-\u{0EA3}
- \u{0EA5}
- \u{0EA7}-\u{0EBD}
- \u{0EC0}-\u{0EC4}
- \u{0EC6}
- \u{0EC8}-\u{0ECE}
- \u{0ED0}-\u{0ED9}
- \u{0EDC}-\u{0EDF}
- \u{0F00}-\u{0F47}
- \u{0F49}-\u{0F6C}
- \u{0F71}-\u{0F97}
- \u{0F99}-\u{0FBC}
- \u{0FBE}-\u{0FCC}
- \u{0FCE}-\u{0FDA}
- \u{1000}-\u{10C5}
- \u{10C7}
- \u{10CD}
- \u{10D0}-\u{10FF}
- \u{1160}-\u{1248}
- \u{124A}-\u{124D}
- \u{1250}-\u{1256}
- \u{1258}
- \u{125A}-\u{125D}
- \u{1260}-\u{1288}
- \u{128A}-\u{128D}
- \u{1290}-\u{12B0}
- \u{12B2}-\u{12B5}
- \u{12B8}-\u{12BE}
- \u{12C0}
- \u{12C2}-\u{12C5}
- \u{12C8}-\u{12D6}
- \u{12D8}-\u{1310}
- \u{1312}-\u{1315}
- \u{1318}-\u{135A}
- \u{135D}-\u{137C}
- \u{1380}-\u{1399}
- \u{13A0}-\u{13F5}
- \u{13F8}-\u{13FD}
- \u{1400}-\u{169C}
- \u{16A0}-\u{16F8}
- \u{1700}-\u{1715}
- \u{171F}-\u{1736}
- \u{1740}-\u{1753}
- \u{1760}-\u{176C}
- \u{176E}-\u{1770}
- \u{1772}-\u{1773}
- \u{1780}-\u{17DD}
- \u{17E0}-\u{17E9}
- \u{17F0}-\u{17F9}
- \u{1800}-\u{1819}
- \u{1820}-\u{1878}
- \u{1880}-\u{18AA}
- \u{18B0}-\u{18F5}
- \u{1900}-\u{191E}
- \u{1920}-\u{192B}
- \u{1930}-\u{193B}
- \u{1940}
- \u{1944}-\u{196D}
- \u{1970}-\u{1974}
- \u{1980}-\u{19AB}
- \u{19B0}-\u{19C9}
- \u{19D0}-\u{19DA}
- \u{19DE}-\u{1A1B}
- \u{1A1E}-\u{1A5E}
- \u{1A60}-\u{1A7C}
- \u{1A7F}-\u{1A89}
- \u{1A90}-\u{1A99}
- \u{1AA0}-\u{1AAD}
- \u{1AB0}-\u{1ACE}
- \u{1B00}-\u{1B4C}
- \u{1B50}-\u{1B7E}
- \u{1B80}-\u{1BF3}
- \u{1BFC}-\u{1C37}
- \u{1C3B}-\u{1C49}
- \u{1C4D}-\u{1C88}
- \u{1C90}-\u{1CBA}
- \u{1CBD}-\u{1CC7}
- \u{1CD0}-\u{1CFA}
- \u{1D00}-\u{1F15}
- \u{1F18}-\u{1F1D}
- \u{1F20}-\u{1F45}
- \u{1F48}-\u{1F4D}
- \u{1F50}-\u{1F57}
- \u{1F59}
- \u{1F5B}
- \u{1F5D}
- \u{1F5F}-\u{1F7D}
- \u{1F80}-\u{1FB4}
- \u{1FB6}-\u{1FC4}
- \u{1FC6}-\u{1FD3}
- \u{1FD6}-\u{1FDB}
- \u{1FDD}-\u{1FEF}
- \u{1FF2}-\u{1FF4}
- \u{1FF6}-\u{1FFE}
- \u{2000}-\u{200F}
- \u{2011}-\u{2012}
- \u{2017}
- \u{201A}-\u{201B}
- \u{201E}-\u{201F}
- \u{2023}
- \u{2028}-\u{202F}
- \u{2031}
- \u{2034}
- \u{2036}-\u{203A}
- \u{203C}-\u{203D}
- \u{203F}-\u{2064}
- \u{2066}-\u{2071}
- \u{2075}-\u{207E}
- \u{2080}
- \u{2085}-\u{208E}
- \u{2090}-\u{209C}
- \u{20A0}-\u{20A8}
- \u{20AA}-\u{20AB}
- \u{20AD}-\u{20C0}
- \u{20D0}-\u{20F0}
- \u{2100}-\u{2102}
- \u{2104}
- \u{2106}-\u{2108}
- \u{210A}-\u{2112}
- \u{2114}-\u{2115}
- \u{2117}-\u{2120}
- \u{2123}-\u{2125}
- \u{2127}-\u{212A}
- \u{212C}-\u{2152}
- \u{2155}-\u{215A}
- \u{215F}
- \u{216C}-\u{216F}
- \u{217A}-\u{2188}
- \u{218A}-\u{218B}
- \u{219A}-\u{21B7}
- \u{21BA}-\u{21D1}
- \u{21D3}
- \u{21D5}-\u{21E6}
- \u{21E8}-\u{21FF}
- \u{2201}
- \u{2204}-\u{2206}
- \u{2209}-\u{220A}
- \u{220C}-\u{220E}
- \u{2210}
- \u{2212}-\u{2214}
- \u{2216}-\u{2219}
- \u{221B}-\u{221C}
- \u{2221}-\u{2222}
- \u{2224}
- \u{2226}
- \u{222D}
- \u{222F}-\u{2233}
- \u{2238}-\u{223B}
- \u{223E}-\u{2247}
- \u{2249}-\u{224B}
- \u{224D}-\u{2251}
- \u{2253}-\u{225F}
- \u{2262}-\u{2263}
- \u{2268}-\u{2269}
- \u{226C}-\u{226D}
- \u{2270}-\u{2281}
- \u{2284}-\u{2285}
- \u{2288}-\u{2294}
- \u{2296}-\u{2298}
- \u{229A}-\u{22A4}
- \u{22A6}-\u{22BE}
- \u{22C0}-\u{2311}
- \u{2313}-\u{2319}
- \u{231C}-\u{2328}
- \u{232B}-\u{23E8}
- \u{23ED}-\u{23EF}
- \u{23F1}-\u{23F2}
- \u{23F4}-\u{2426}
- \u{2440}-\u{244A}
- \u{24EA}
- \u{254C}-\u{254F}
- \u{2574}-\u{257F}
- \u{2590}-\u{2591}
- \u{2596}-\u{259F}
- \u{25A2}
- \u{25AA}-\u{25B1}
- \u{25B4}-\u{25B5}
- \u{25B8}-\u{25BB}
- \u{25BE}-\u{25BF}
- \u{25C2}-\u{25C5}
- \u{25C9}-\u{25CA}
- \u{25CC}-\u{25CD}
- \u{25D2}-\u{25E1}
- \u{25E6}-\u{25EE}
- \u{25F0}-\u{25FC}
- \u{25FF}-\u{2604}
- \u{2607}-\u{2608}
- \u{260A}-\u{260D}
- \u{2610}-\u{2613}
- \u{2616}-\u{261B}
- \u{261D}
- \u{261F}-\u{263F}
- \u{2641}
- \u{2643}-\u{2647}
- \u{2654}-\u{265F}
- \u{2662}
- \u{2666}
- \u{266B}
- \u{266E}
- \u{2670}-\u{267E}
- \u{2680}-\u{2692}
- \u{2694}-\u{269D}
- \u{26A0}
- \u{26A2}-\u{26A9}
- \u{26AC}-\u{26BC}
- \u{26C0}-\u{26C3}
- \u{26E2}
- \u{26E4}-\u{26E7}
- \u{2700}-\u{2704}
- \u{2706}-\u{2709}
- \u{270C}-\u{2727}
- \u{2729}-\u{273C}
- \u{273E}-\u{274B}
- \u{274D}
- \u{274F}-\u{2752}
- \u{2756}
- \u{2758}-\u{2775}
- \u{2780}-\u{2794}
- \u{2798}-\u{27AF}
- \u{27B1}-\u{27BE}
- \u{27C0}-\u{27E5}
- \u{27EE}-\u{2984}
- \u{2987}-\u{2B1A}
- \u{2B1D}-\u{2B4F}
- \u{2B51}-\u{2B54}
- \u{2B5A}-\u{2B73}
- \u{2B76}-\u{2B95}
- \u{2B97}-\u{2CF3}
- \u{2CF9}-\u{2D25}
- \u{2D27}
- \u{2D2D}
- \u{2D30}-\u{2D67}
- \u{2D6F}-\u{2D70}
- \u{2D7F}-\u{2D96}
- \u{2DA0}-\u{2DA6}
- \u{2DA8}-\u{2DAE}
- \u{2DB0}-\u{2DB6}
- \u{2DB8}-\u{2DBE}
- \u{2DC0}-\u{2DC6}
- \u{2DC8}-\u{2DCE}
- \u{2DD0}-\u{2DD6}
- \u{2DD8}-\u{2DDE}
- \u{2DE0}-\u{2E5D}
- \u{303F}
- \u{4DC0}-\u{4DFF}
- \u{A4D0}-\u{A62B}
- \u{A640}-\u{A6F7}
- \u{A700}-\u{A7CA}
- \u{A7D0}-\u{A7D1}
- \u{A7D3}
- \u{A7D5}-\u{A7D9}
- \u{A7F2}-\u{A82C}
- \u{A830}-\u{A839}
- \u{A840}-\u{A877}
- \u{A880}-\u{A8C5}
- \u{A8CE}-\u{A8D9}
- \u{A8E0}-\u{A953}
- \u{A95F}
- \u{A980}-\u{A9CD}
- \u{A9CF}-\u{A9D9}
- \u{A9DE}-\u{A9FE}
- \u{AA00}-\u{AA36}
- \u{AA40}-\u{AA4D}
- \u{AA50}-\u{AA59}
- \u{AA5C}-\u{AAC2}
- \u{AADB}-\u{AAF6}
- \u{AB01}-\u{AB06}
- \u{AB09}-\u{AB0E}
- \u{AB11}-\u{AB16}
- \u{AB20}-\u{AB26}
- \u{AB28}-\u{AB2E}
- \u{AB30}-\u{AB6B}
- \u{AB70}-\u{ABED}
- \u{ABF0}-\u{ABF9}
- \u{D7B0}-\u{D7C6}
- \u{D7CB}-\u{D7FB}
- \u{FB00}-\u{FB06}
- \u{FB13}-\u{FB17}
- \u{FB1D}-\u{FB36}
- \u{FB38}-\u{FB3C}
- \u{FB3E}
- \u{FB40}-\u{FB41}
- \u{FB43}-\u{FB44}
- \u{FB46}-\u{FBC2}
- \u{FBD3}-\u{FD8F}
- \u{FD92}-\u{FDC7}
- \u{FDCF}
- \u{FDF0}-\u{FDFF}
- \u{FE20}-\u{FE2F}
- \u{FE70}-\u{FE74}
- \u{FE76}-\u{FEFC}
- \u{FEFF}
- \u{FFF9}-\u{FFFC}
- \u{10000}-\u{1000B}
- \u{1000D}-\u{10026}
- \u{10028}-\u{1003A}
- \u{1003C}-\u{1003D}
- \u{1003F}-\u{1004D}
- \u{10050}-\u{1005D}
- \u{10080}-\u{100FA}
- \u{10100}-\u{10102}
- \u{10107}-\u{10133}
- \u{10137}-\u{1018E}
- \u{10190}-\u{1019C}
- \u{101A0}
- \u{101D0}-\u{101FD}
- \u{10280}-\u{1029C}
- \u{102A0}-\u{102D0}
- \u{102E0}-\u{102FB}
- \u{10300}-\u{10323}
- \u{1032D}-\u{1034A}
- \u{10350}-\u{1037A}
- \u{10380}-\u{1039D}
- \u{1039F}-\u{103C3}
- \u{103C8}-\u{103D5}
- \u{10400}-\u{1049D}
- \u{104A0}-\u{104A9}
- \u{104B0}-\u{104D3}
- \u{104D8}-\u{104FB}
- \u{10500}-\u{10527}
- \u{10530}-\u{10563}
- \u{1056F}-\u{1057A}
- \u{1057C}-\u{1058A}
- \u{1058C}-\u{10592}
- \u{10594}-\u{10595}
- \u{10597}-\u{105A1}
- \u{105A3}-\u{105B1}
- \u{105B3}-\u{105B9}
- \u{105BB}-\u{105BC}
- \u{10600}-\u{10736}
- \u{10740}-\u{10755}
- \u{10760}-\u{10767}
- \u{10780}-\u{10785}
- \u{10787}-\u{107B0}
- \u{107B2}-\u{107BA}
- \u{10800}-\u{10805}
- \u{10808}
- \u{1080A}-\u{10835}
- \u{10837}-\u{10838}
- \u{1083C}
- \u{1083F}-\u{10855}
- \u{10857}-\u{1089E}
- \u{108A7}-\u{108AF}
- \u{108E0}-\u{108F2}
- \u{108F4}-\u{108F5}
- \u{108FB}-\u{1091B}
- \u{1091F}-\u{10939}
- \u{1093F}
- \u{10980}-\u{109B7}
- \u{109BC}-\u{109CF}
- \u{109D2}-\u{10A03}
- \u{10A05}-\u{10A06}
- \u{10A0C}-\u{10A13}
- \u{10A15}-\u{10A17}
- \u{10A19}-\u{10A35}
- \u{10A38}-\u{10A3A}
- \u{10A3F}-\u{10A48}
- \u{10A50}-\u{10A58}
- \u{10A60}-\u{10A9F}
- \u{10AC0}-\u{10AE6}
- \u{10AEB}-\u{10AF6}
- \u{10B00}-\u{10B35}
- \u{10B39}-\u{10B55}
- \u{10B58}-\u{10B72}
- \u{10B78}-\u{10B91}
- \u{10B99}-\u{10B9C}
- \u{10BA9}-\u{10BAF}
- \u{10C00}-\u{10C48}
- \u{10C80}-\u{10CB2}
- \u{10CC0}-\u{10CF2}
- \u{10CFA}-\u{10D27}
- \u{10D30}-\u{10D39}
- \u{10E60}-\u{10E7E}
- \u{10E80}-\u{10EA9}
- \u{10EAB}-\u{10EAD}
- \u{10EB0}-\u{10EB1}
- \u{10EFD}-\u{10F27}
- \u{10F30}-\u{10F59}
- \u{10F70}-\u{10F89}
- \u{10FB0}-\u{10FCB}
- \u{10FE0}-\u{10FF6}
- \u{11000}-\u{1104D}
- \u{11052}-\u{11075}
- \u{1107F}-\u{110C2}
- \u{110CD}
- \u{110D0}-\u{110E8}
- \u{110F0}-\u{110F9}
- \u{11100}-\u{11134}
- \u{11136}-\u{11147}
- \u{11150}-\u{11176}
- \u{11180}-\u{111DF}
- \u{111E1}-\u{111F4}
- \u{11200}-\u{11211}
- \u{11213}-\u{11241}
- \u{11280}-\u{11286}
- \u{11288}
- \u{1128A}-\u{1128D}
- \u{1128F}-\u{1129D}
- \u{1129F}-\u{112A9}
- \u{112B0}-\u{112EA}
- \u{112F0}-\u{112F9}
- \u{11300}-\u{11303}
- \u{11305}-\u{1130C}
- \u{1130F}-\u{11310}
- \u{11313}-\u{11328}
- \u{1132A}-\u{11330}
- \u{11332}-\u{11333}
- \u{11335}-\u{11339}
- \u{1133B}-\u{11344}
- \u{11347}-\u{11348}
- \u{1134B}-\u{1134D}
- \u{11350}
- \u{11357}
- \u{1135D}-\u{11363}
- \u{11366}-\u{1136C}
- \u{11370}-\u{11374}
- \u{11400}-\u{1145B}
- \u{1145D}-\u{11461}
- \u{11480}-\u{114C7}
- \u{114D0}-\u{114D9}
- \u{11580}-\u{115B5}
- \u{115B8}-\u{115DD}
- \u{11600}-\u{11644}
- \u{11650}-\u{11659}
- \u{11660}-\u{1166C}
- \u{11680}-\u{116B9}
- \u{116C0}-\u{116C9}
- \u{11700}-\u{1171A}
- \u{1171D}-\u{1172B}
- \u{11730}-\u{11746}
- \u{11800}-\u{1183B}
- \u{118A0}-\u{118F2}
- \u{118FF}-\u{11906}
- \u{11909}
- \u{1190C}-\u{11913}
- \u{11915}-\u{11916}
- \u{11918}-\u{11935}
- \u{11937}-\u{11938}
- \u{1193B}-\u{11946}
- \u{11950}-\u{11959}
- \u{119A0}-\u{119A7}
- \u{119AA}-\u{119D7}
- \u{119DA}-\u{119E4}
- \u{11A00}-\u{11A47}
- \u{11A50}-\u{11AA2}
- \u{11AB0}-\u{11AF8}
- \u{11B00}-\u{11B09}
- \u{11C00}-\u{11C08}
- \u{11C0A}-\u{11C36}
- \u{11C38}-\u{11C45}
- \u{11C50}-\u{11C6C}
- \u{11C70}-\u{11C8F}
- \u{11C92}-\u{11CA7}
- \u{11CA9}-\u{11CB6}
- \u{11D00}-\u{11D06}
- \u{11D08}-\u{11D09}
- \u{11D0B}-\u{11D36}
- \u{11D3A}
- \u{11D3C}-\u{11D3D}
- \u{11D3F}-\u{11D47}
- \u{11D50}-\u{11D59}
- \u{11D60}-\u{11D65}
- \u{11D67}-\u{11D68}
- \u{11D6A}-\u{11D8E}
- \u{11D90}-\u{11D91}
- \u{11D93}-\u{11D98}
- \u{11DA0}-\u{11DA9}
- \u{11EE0}-\u{11EF8}
- \u{11F00}-\u{11F10}
- \u{11F12}-\u{11F3A}
- \u{11F3E}-\u{11F59}
- \u{11FB0}
- \u{11FC0}-\u{11FF1}
- \u{11FFF}-\u{12399}
- \u{12400}-\u{1246E}
- \u{12470}-\u{12474}
- \u{12480}-\u{12543}
- \u{12F90}-\u{12FF2}
- \u{13000}-\u{13455}
- \u{14400}-\u{14646}
- \u{16800}-\u{16A38}
- \u{16A40}-\u{16A5E}
- \u{16A60}-\u{16A69}
- \u{16A6E}-\u{16ABE}
- \u{16AC0}-\u{16AC9}
- \u{16AD0}-\u{16AED}
- \u{16AF0}-\u{16AF5}
- \u{16B00}-\u{16B45}
- \u{16B50}-\u{16B59}
- \u{16B5B}-\u{16B61}
- \u{16B63}-\u{16B77}
- \u{16B7D}-\u{16B8F}
- \u{16E40}-\u{16E9A}
- \u{16F00}-\u{16F4A}
- \u{16F4F}-\u{16F87}
- \u{16F8F}-\u{16F9F}
- \u{1BC00}-\u{1BC6A}
- \u{1BC70}-\u{1BC7C}
- \u{1BC80}-\u{1BC88}
- \u{1BC90}-\u{1BC99}
- \u{1BC9C}-\u{1BCA3}
- \u{1CF00}-\u{1CF2D}
- \u{1CF30}-\u{1CF46}
- \u{1CF50}-\u{1CFC3}
- \u{1D000}-\u{1D0F5}
- \u{1D100}-\u{1D126}
- \u{1D129}-\u{1D1EA}
- \u{1D200}-\u{1D245}
- \u{1D2C0}-\u{1D2D3}
- \u{1D2E0}-\u{1D2F3}
- \u{1D300}-\u{1D356}
- \u{1D360}-\u{1D378}
- \u{1D400}-\u{1D454}
- \u{1D456}-\u{1D49C}
- \u{1D49E}-\u{1D49F}
- \u{1D4A2}
- \u{1D4A5}-\u{1D4A6}
- \u{1D4A9}-\u{1D4AC}
- \u{1D4AE}-\u{1D4B9}
- \u{1D4BB}
- \u{1D4BD}-\u{1D4C3}
- \u{1D4C5}-\u{1D505}
- \u{1D507}-\u{1D50A}
- \u{1D50D}-\u{1D514}
- \u{1D516}-\u{1D51C}
- \u{1D51E}-\u{1D539}
- \u{1D53B}-\u{1D53E}
- \u{1D540}-\u{1D544}
- \u{1D546}
- \u{1D54A}-\u{1D550}
- \u{1D552}-\u{1D6A5}
- \u{1D6A8}-\u{1D7CB}
- \u{1D7CE}-\u{1DA8B}
- \u{1DA9B}-\u{1DA9F}
- \u{1DAA1}-\u{1DAAF}
- \u{1DF00}-\u{1DF1E}
- \u{1DF25}-\u{1DF2A}
- \u{1E000}-\u{1E006}
- \u{1E008}-\u{1E018}
- \u{1E01B}-\u{1E021}
- \u{1E023}-\u{1E024}
- \u{1E026}-\u{1E02A}
- \u{1E030}-\u{1E06D}
- \u{1E08F}
- \u{1E100}-\u{1E12C}
- \u{1E130}-\u{1E13D}
- \u{1E140}-\u{1E149}
- \u{1E14E}-\u{1E14F}
- \u{1E290}-\u{1E2AE}
- \u{1E2C0}-\u{1E2F9}
- \u{1E2FF}
- \u{1E4D0}-\u{1E4F9}
- \u{1E7E0}-\u{1E7E6}
- \u{1E7E8}-\u{1E7EB}
- \u{1E7ED}-\u{1E7EE}
- \u{1E7F0}-\u{1E7FE}
- \u{1E800}-\u{1E8C4}
- \u{1E8C7}-\u{1E8D6}
- \u{1E900}-\u{1E94B}
- \u{1E950}-\u{1E959}
- \u{1E95E}-\u{1E95F}
- \u{1EC71}-\u{1ECB4}
- \u{1ED01}-\u{1ED3D}
- \u{1EE00}-\u{1EE03}
- \u{1EE05}-\u{1EE1F}
- \u{1EE21}-\u{1EE22}
- \u{1EE24}
- \u{1EE27}
- \u{1EE29}-\u{1EE32}
- \u{1EE34}-\u{1EE37}
- \u{1EE39}
- \u{1EE3B}
- \u{1EE42}
- \u{1EE47}
- \u{1EE49}
- \u{1EE4B}
- \u{1EE4D}-\u{1EE4F}
- \u{1EE51}-\u{1EE52}
- \u{1EE54}
- \u{1EE57}
- \u{1EE59}
- \u{1EE5B}
- \u{1EE5D}
- \u{1EE5F}
- \u{1EE61}-\u{1EE62}
- \u{1EE64}
- \u{1EE67}-\u{1EE6A}
- \u{1EE6C}-\u{1EE72}
- \u{1EE74}-\u{1EE77}
- \u{1EE79}-\u{1EE7C}
- \u{1EE7E}
- \u{1EE80}-\u{1EE89}
- \u{1EE8B}-\u{1EE9B}
- \u{1EEA1}-\u{1EEA3}
- \u{1EEA5}-\u{1EEA9}
- \u{1EEAB}-\u{1EEBB}
- \u{1EEF0}-\u{1EEF1}
- \u{1F000}-\u{1F003}
- \u{1F005}-\u{1F02B}
- \u{1F030}-\u{1F093}
- \u{1F0A0}-\u{1F0AE}
- \u{1F0B1}-\u{1F0BF}
- \u{1F0C1}-\u{1F0CE}
- \u{1F0D1}-\u{1F0F5}
- \u{1F10B}-\u{1F10F}
- \u{1F12E}-\u{1F12F}
- \u{1F16A}-\u{1F16F}
- \u{1F1AD}
- \u{1F1E6}-\u{1F1FF}
- \u{1F321}-\u{1F32C}
- \u{1F336}
- \u{1F37D}
- \u{1F394}-\u{1F39F}
- \u{1F3CB}-\u{1F3CE}
- \u{1F3D4}-\u{1F3DF}
- \u{1F3F1}-\u{1F3F3}
- \u{1F3F5}-\u{1F3F7}
- \u{1F43F}
- \u{1F441}
- \u{1F4FD}-\u{1F4FE}
- \u{1F53E}-\u{1F54A}
- \u{1F54F}
- \u{1F568}-\u{1F579}
- \u{1F57B}-\u{1F594}
- \u{1F597}-\u{1F5A3}
- \u{1F5A5}-\u{1F5FA}
- \u{1F650}-\u{1F67F}
- \u{1F6C6}-\u{1F6CB}
- \u{1F6CD}-\u{1F6CF}
- \u{1F6D3}-\u{1F6D4}
- \u{1F6E0}-\u{1F6EA}
- \u{1F6F0}-\u{1F6F3}
- \u{1F700}-\u{1F776}
- \u{1F77B}-\u{1F7D9}
- \u{1F800}-\u{1F80B}
- \u{1F810}-\u{1F847}
- \u{1F850}-\u{1F859}
- \u{1F860}-\u{1F887}
- \u{1F890}-\u{1F8AD}
- \u{1F8B0}-\u{1F8B1}
- \u{1F900}-\u{1F90B}
- \u{1F93B}
- \u{1F946}
- \u{1FA00}-\u{1FA53}
- \u{1FA60}-\u{1FA6D}
- \u{1FB00}-\u{1FB92}
- \u{1FB94}-\u{1FBCA}
- \u{1FBF0}-\u{1FBF9}
- \u{E0001}
- \u{E0020}-\u{E007F}
- ).join }]/
-end
diff --git a/lib/reline/version.rb b/lib/reline/version.rb
deleted file mode 100644
index 67a3d694bd..0000000000
--- a/lib/reline/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Reline
- VERSION = '0.3.2'
-end
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
deleted file mode 100644
index 7ea2a00f63..0000000000
--- a/lib/reline/windows.rb
+++ /dev/null
@@ -1,501 +0,0 @@
-require 'fiddle/import'
-
-class Reline::Windows
- def self.encoding
- Encoding::UTF_8
- end
-
- def self.win?
- true
- end
-
- def self.win_legacy_console?
- @@legacy_console
- end
-
- def self.set_default_key_bindings(config)
- {
- [224, 72] => :ed_prev_history, # ↑
- [224, 80] => :ed_next_history, # ↓
- [224, 77] => :ed_next_char, # →
- [224, 75] => :ed_prev_char, # â†
- [224, 83] => :key_delete, # Del
- [224, 71] => :ed_move_to_beg, # Home
- [224, 79] => :ed_move_to_end, # End
- [ 0, 41] => :ed_unassigned, # input method on/off
- [ 0, 72] => :ed_prev_history, # ↑
- [ 0, 80] => :ed_next_history, # ↓
- [ 0, 77] => :ed_next_char, # →
- [ 0, 75] => :ed_prev_char, # â†
- [ 0, 83] => :key_delete, # Del
- [ 0, 71] => :ed_move_to_beg, # Home
- [ 0, 79] => :ed_move_to_end # End
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- config.add_default_key_binding_by_keymap(:vi_command, key, func)
- end
-
- {
- [27, 32] => :em_set_mark, # M-<space>
- [24, 24] => :em_exchange_mark, # C-x C-x
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- end
-
- # Emulate ANSI key sequence.
- {
- [27, 91, 90] => :completion_journey_up, # S-Tab
- }.each_pair do |key, func|
- config.add_default_key_binding_by_keymap(:emacs, key, func)
- config.add_default_key_binding_by_keymap(:vi_insert, key, func)
- end
- end
-
- if defined? JRUBY_VERSION
- require 'win32api'
- else
- class Win32API
- DLL = {}
- TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
- POINTER_TYPE = Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*'
-
- WIN32_TYPES = "VPpNnLlIi"
- DL_TYPES = "0SSI"
-
- def initialize(dllname, func, import, export = "0", calltype = :stdcall)
- @proto = [import].join.tr(WIN32_TYPES, DL_TYPES).sub(/^(.)0*$/, '\1')
- import = @proto.chars.map {|win_type| TYPEMAP[win_type.tr(WIN32_TYPES, DL_TYPES)]}
- export = TYPEMAP[export.tr(WIN32_TYPES, DL_TYPES)]
- calltype = Fiddle::Importer.const_get(:CALL_TYPE_TO_ABI)[calltype]
-
- handle = DLL[dllname] ||=
- begin
- Fiddle.dlopen(dllname)
- rescue Fiddle::DLError
- raise unless File.extname(dllname).empty?
- Fiddle.dlopen(dllname + ".dll")
- end
-
- @func = Fiddle::Function.new(handle[func], import, export, calltype)
- rescue Fiddle::DLError => e
- raise LoadError, e.message, e.backtrace
- end
-
- def call(*args)
- import = @proto.split("")
- args.each_with_index do |x, i|
- args[i], = [x == 0 ? nil : x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
- args[i], = [x].pack("I").unpack("i") if import[i] == "I"
- end
- ret, = @func.call(*args)
- return ret || 0
- end
- end
- end
-
- VK_RETURN = 0x0D
- VK_MENU = 0x12 # ALT key
- VK_LMENU = 0xA4
- VK_CONTROL = 0x11
- VK_SHIFT = 0x10
- VK_DIVIDE = 0x6F
-
- KEY_EVENT = 0x01
- WINDOW_BUFFER_SIZE_EVENT = 0x04
-
- CAPSLOCK_ON = 0x0080
- ENHANCED_KEY = 0x0100
- LEFT_ALT_PRESSED = 0x0002
- LEFT_CTRL_PRESSED = 0x0008
- NUMLOCK_ON = 0x0020
- RIGHT_ALT_PRESSED = 0x0001
- RIGHT_CTRL_PRESSED = 0x0004
- SCROLLLOCK_ON = 0x0040
- SHIFT_PRESSED = 0x0010
-
- VK_TAB = 0x09
- VK_END = 0x23
- VK_HOME = 0x24
- VK_LEFT = 0x25
- VK_UP = 0x26
- VK_RIGHT = 0x27
- VK_DOWN = 0x28
- VK_DELETE = 0x2E
-
- STD_INPUT_HANDLE = -10
- STD_OUTPUT_HANDLE = -11
- FILE_TYPE_PIPE = 0x0003
- FILE_NAME_INFO = 2
- @@getwch = Win32API.new('msvcrt', '_getwch', [], 'I')
- @@kbhit = Win32API.new('msvcrt', '_kbhit', [], 'I')
- @@GetKeyState = Win32API.new('user32', 'GetKeyState', ['L'], 'L')
- @@GetConsoleScreenBufferInfo = Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L')
- @@SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', ['L', 'L'], 'L')
- @@GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
- @@FillConsoleOutputCharacter = Win32API.new('kernel32', 'FillConsoleOutputCharacter', ['L', 'L', 'L', 'L', 'P'], 'L')
- @@ScrollConsoleScreenBuffer = Win32API.new('kernel32', 'ScrollConsoleScreenBuffer', ['L', 'P', 'P', 'L', 'P'], 'L')
- @@hConsoleHandle = @@GetStdHandle.call(STD_OUTPUT_HANDLE)
- @@hConsoleInputHandle = @@GetStdHandle.call(STD_INPUT_HANDLE)
- @@GetNumberOfConsoleInputEvents = Win32API.new('kernel32', 'GetNumberOfConsoleInputEvents', ['L', 'P'], 'L')
- @@ReadConsoleInputW = Win32API.new('kernel32', 'ReadConsoleInputW', ['L', 'P', 'L', 'P'], 'L')
- @@GetFileType = Win32API.new('kernel32', 'GetFileType', ['L'], 'L')
- @@GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I')
- @@FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L')
- @@SetConsoleCursorInfo = Win32API.new('kernel32', 'SetConsoleCursorInfo', ['L', 'P'], 'L')
-
- @@GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L')
- @@SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L')
- @@WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', ['L', 'L'], 'L')
- ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
-
- private_class_method def self.getconsolemode
- mode = "\000\000\000\000"
- @@GetConsoleMode.call(@@hConsoleHandle, mode)
- mode.unpack1('L')
- end
-
- private_class_method def self.setconsolemode(mode)
- @@SetConsoleMode.call(@@hConsoleHandle, mode)
- end
-
- @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0)
- #if @@legacy_console
- # setconsolemode(getconsolemode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
- # @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0)
- #end
-
- @@input_buf = []
- @@output_buf = []
-
- @@output = STDOUT
-
- def self.msys_tty?(io = @@hConsoleInputHandle)
- # check if fd is a pipe
- if @@GetFileType.call(io) != FILE_TYPE_PIPE
- return false
- end
-
- bufsize = 1024
- p_buffer = "\0" * bufsize
- res = @@GetFileInformationByHandleEx.call(io, FILE_NAME_INFO, p_buffer, bufsize - 2)
- return false if res == 0
-
- # get pipe name: p_buffer layout is:
- # struct _FILE_NAME_INFO {
- # DWORD FileNameLength;
- # WCHAR FileName[1];
- # } FILE_NAME_INFO
- len = p_buffer[0, 4].unpack1("L")
- name = p_buffer[4, len].encode(Encoding::UTF_8, Encoding::UTF_16LE, invalid: :replace)
-
- # Check if this could be a MSYS2 pty pipe ('\msys-XXXX-ptyN-XX')
- # or a cygwin pty pipe ('\cygwin-XXXX-ptyN-XX')
- name =~ /(msys-|cygwin-).*-pty/ ? true : false
- end
-
- KEY_MAP = [
- # It's treated as Meta+Enter on Windows.
- [ { control_keys: :CTRL, virtual_key_code: 0x0D }, "\e\r".bytes ],
- [ { control_keys: :SHIFT, virtual_key_code: 0x0D }, "\e\r".bytes ],
-
- # It's treated as Meta+Space on Windows.
- [ { control_keys: :CTRL, char_code: 0x20 }, "\e ".bytes ],
-
- # Emulate getwch() key sequences.
- [ { control_keys: [], virtual_key_code: VK_UP }, [0, 72] ],
- [ { control_keys: [], virtual_key_code: VK_DOWN }, [0, 80] ],
- [ { control_keys: [], virtual_key_code: VK_RIGHT }, [0, 77] ],
- [ { control_keys: [], virtual_key_code: VK_LEFT }, [0, 75] ],
- [ { control_keys: [], virtual_key_code: VK_DELETE }, [0, 83] ],
- [ { control_keys: [], virtual_key_code: VK_HOME }, [0, 71] ],
- [ { control_keys: [], virtual_key_code: VK_END }, [0, 79] ],
-
- # Emulate ANSI key sequence.
- [ { control_keys: :SHIFT, virtual_key_code: VK_TAB }, [27, 91, 90] ],
- ]
-
- @@hsg = nil
-
- def self.process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
-
- # high-surrogate
- if 0xD800 <= char_code and char_code <= 0xDBFF
- @@hsg = char_code
- return
- end
- # low-surrogate
- if 0xDC00 <= char_code and char_code <= 0xDFFF
- if @@hsg
- char_code = 0x10000 + (@@hsg - 0xD800) * 0x400 + char_code - 0xDC00
- @@hsg = nil
- else
- # no high-surrogate. ignored.
- return
- end
- else
- # ignore high-surrogate without low-surrogate if there
- @@hsg = nil
- end
-
- key = KeyEventRecord.new(virtual_key_code, char_code, control_key_state)
-
- match = KEY_MAP.find { |args,| key.matches?(**args) }
- unless match.nil?
- @@output_buf.concat(match.last)
- return
- end
-
- # no char, only control keys
- return if key.char_code == 0 and key.control_keys.any?
-
- @@output_buf.push("\e".ord) if key.control_keys.include?(:ALT) and !key.control_keys.include?(:CTRL)
-
- @@output_buf.concat(key.char.bytes)
- end
-
- def self.check_input_event
- num_of_events = 0.chr * 8
- while @@output_buf.empty?
- Reline.core.line_editor.resize
- if @@WaitForSingleObject.(@@hConsoleInputHandle, 100) != 0 # max 0.1 sec
- # prevent for background consolemode change
- @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0)
- next
- end
- next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack1('L') == 0
- input_records = 0.chr * 20 * 80
- read_event = 0.chr * 4
- if @@ReadConsoleInputW.(@@hConsoleInputHandle, input_records, 80, read_event) != 0
- read_events = read_event.unpack1('L')
- 0.upto(read_events) do |idx|
- input_record = input_records[idx * 20, 20]
- event = input_record[0, 2].unpack1('s*')
- case event
- when WINDOW_BUFFER_SIZE_EVENT
- @@winch_handler.()
- when KEY_EVENT
- key_down = input_record[4, 4].unpack1('l*')
- repeat_count = input_record[8, 2].unpack1('s*')
- virtual_key_code = input_record[10, 2].unpack1('s*')
- virtual_scan_code = input_record[12, 2].unpack1('s*')
- char_code = input_record[14, 2].unpack1('S*')
- control_key_state = input_record[16, 2].unpack1('S*')
- is_key_down = key_down.zero? ? false : true
- if is_key_down
- process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
- end
- end
- end
- end
- end
- end
-
- def self.with_raw_input
- yield
- end
-
- def self.getc
- check_input_event
- @@output_buf.shift
- end
-
- def self.ungetc(c)
- @@output_buf.unshift(c)
- end
-
- def self.in_pasting?
- not self.empty_buffer?
- end
-
- def self.empty_buffer?
- if not @@output_buf.empty?
- false
- elsif @@kbhit.call == 0
- true
- else
- false
- end
- end
-
- def self.get_console_screen_buffer_info
- # CONSOLE_SCREEN_BUFFER_INFO
- # [ 0,2] dwSize.X
- # [ 2,2] dwSize.Y
- # [ 4,2] dwCursorPositions.X
- # [ 6,2] dwCursorPositions.Y
- # [ 8,2] wAttributes
- # [10,2] srWindow.Left
- # [12,2] srWindow.Top
- # [14,2] srWindow.Right
- # [16,2] srWindow.Bottom
- # [18,2] dwMaximumWindowSize.X
- # [20,2] dwMaximumWindowSize.Y
- csbi = 0.chr * 22
- return if @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi) == 0
- csbi
- end
-
- def self.get_screen_size
- unless csbi = get_console_screen_buffer_info
- return [1, 1]
- end
- csbi[0, 4].unpack('SS').reverse
- end
-
- def self.cursor_pos
- unless csbi = get_console_screen_buffer_info
- return Reline::CursorPos.new(0, 0)
- end
- x = csbi[4, 2].unpack1('s')
- y = csbi[6, 2].unpack1('s')
- Reline::CursorPos.new(x, y)
- end
-
- def self.move_cursor_column(val)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, cursor_pos.y * 65536 + val)
- end
-
- def self.move_cursor_up(val)
- if val > 0
- y = cursor_pos.y - val
- y = 0 if y < 0
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, y * 65536 + cursor_pos.x)
- elsif val < 0
- move_cursor_down(-val)
- end
- end
-
- def self.move_cursor_down(val)
- if val > 0
- return unless csbi = get_console_screen_buffer_info
- screen_height = get_screen_size.first
- y = cursor_pos.y + val
- y = screen_height - 1 if y > (screen_height - 1)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, (cursor_pos.y + val) * 65536 + cursor_pos.x)
- elsif val < 0
- move_cursor_up(-val)
- end
- end
-
- def self.erase_after_cursor
- return unless csbi = get_console_screen_buffer_info
- attributes = csbi[8, 2].unpack1('S')
- cursor = csbi[4, 4].unpack1('L')
- written = 0.chr * 4
- @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, get_screen_size.last - cursor_pos.x, cursor, written)
- @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, get_screen_size.last - cursor_pos.x, cursor, written)
- end
-
- def self.scroll_down(val)
- return if val < 0
- return unless csbi = get_console_screen_buffer_info
- buffer_width, buffer_lines, x, y, attributes, window_left, window_top, window_bottom = csbi.unpack('ssssSssx2s')
- screen_height = window_bottom - window_top + 1
- val = screen_height if val > screen_height
-
- if @@legacy_console || window_left != 0
- # unless ENABLE_VIRTUAL_TERMINAL,
- # if srWindow.Left != 0 then it's conhost.exe hosted console
- # and puts "\n" causes horizontal scroll. its glitch.
- # FYI irb write from culumn 1, so this gives no gain.
- scroll_rectangle = [0, val, buffer_width, buffer_lines - val].pack('s4')
- destination_origin = 0 # y * 65536 + x
- fill = [' '.ord, attributes].pack('SS')
- @@ScrollConsoleScreenBuffer.call(@@hConsoleHandle, scroll_rectangle, nil, destination_origin, fill)
- else
- origin_x = x + 1
- origin_y = y - window_top + 1
- @@output.write [
- (origin_y != screen_height) ? "\e[#{screen_height};H" : nil,
- "\n" * val,
- (origin_y != screen_height or !x.zero?) ? "\e[#{origin_y};#{origin_x}H" : nil
- ].join
- end
- end
-
- def self.clear_screen
- if @@legacy_console
- return unless csbi = get_console_screen_buffer_info
- buffer_width, _buffer_lines, attributes, window_top, window_bottom = csbi.unpack('ss@8S@12sx2s')
- fill_length = buffer_width * (window_bottom - window_top + 1)
- screen_topleft = window_top * 65536
- written = 0.chr * 4
- @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, fill_length, screen_topleft, written)
- @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, fill_length, screen_topleft, written)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, screen_topleft)
- else
- @@output.write "\e[2J" "\e[H"
- end
- end
-
- def self.set_screen_size(rows, columns)
- raise NotImplementedError
- end
-
- def self.hide_cursor
- size = 100
- visible = 0 # 0 means false
- cursor_info = [size, visible].pack('Li')
- @@SetConsoleCursorInfo.call(@@hConsoleHandle, cursor_info)
- end
-
- def self.show_cursor
- size = 100
- visible = 1 # 1 means true
- cursor_info = [size, visible].pack('Li')
- @@SetConsoleCursorInfo.call(@@hConsoleHandle, cursor_info)
- end
-
- def self.set_winch_handler(&handler)
- @@winch_handler = handler
- end
-
- def self.prep
- # do nothing
- nil
- end
-
- def self.deprep(otio)
- # do nothing
- end
-
- class KeyEventRecord
-
- attr_reader :virtual_key_code, :char_code, :control_key_state, :control_keys
-
- def initialize(virtual_key_code, char_code, control_key_state)
- @virtual_key_code = virtual_key_code
- @char_code = char_code
- @control_key_state = control_key_state
- @enhanced = control_key_state & ENHANCED_KEY != 0
-
- (@control_keys = []).tap do |control_keys|
- # symbols must be sorted to make comparison is easier later on
- control_keys << :ALT if control_key_state & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED) != 0
- control_keys << :CTRL if control_key_state & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) != 0
- control_keys << :SHIFT if control_key_state & SHIFT_PRESSED != 0
- end.freeze
- end
-
- def char
- @char_code.chr(Encoding::UTF_8)
- end
-
- def enhanced?
- @enhanced
- end
-
- # Verifies if the arguments match with this key event.
- # Nil arguments are ignored, but at least one must be passed as non-nil.
- # To verify that no control keys were pressed, pass an empty array: `control_keys: []`.
- def matches?(control_keys: nil, virtual_key_code: nil, char_code: nil)
- raise ArgumentError, 'No argument was passed to match key event' if control_keys.nil? && virtual_key_code.nil? && char_code.nil?
-
- (control_keys.nil? || [*control_keys].sort == @control_keys) &&
- (virtual_key_code.nil? || @virtual_key_code == virtual_key_code) &&
- (char_code.nil? || char_code == @char_code)
- end
-
- end
-end
diff --git a/lib/resolv-replace.gemspec b/lib/resolv-replace.gemspec
deleted file mode 100644
index 48f7108a8e..0000000000
--- a/lib/resolv-replace.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "resolv-replace"
- spec.version = "0.1.1"
- spec.authors = ["Tanaka Akira"]
- spec.email = ["akr@fsij.org"]
-
- spec.summary = %q{Replace Socket DNS with Resolv.}
- spec.description = %q{Replace Socket DNS with Resolv.}
- spec.homepage = "https://github.com/ruby/resolv-replace"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
-
- spec.add_dependency "resolv"
-end
diff --git a/lib/resolv-replace.rb b/lib/resolv-replace.rb
deleted file mode 100644
index a83e79d996..0000000000
--- a/lib/resolv-replace.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-require 'socket'
-require 'resolv'
-
-class << IPSocket
- # :stopdoc:
- alias original_resolv_getaddress getaddress
- # :startdoc:
- def getaddress(host)
- begin
- return Resolv.getaddress(host).to_s
- rescue Resolv::ResolvError
- raise SocketError, "Hostname not known: #{host}"
- end
- end
-end
-
-class TCPSocket < IPSocket
- # :stopdoc:
- alias original_resolv_initialize initialize
- # :startdoc:
- def initialize(host, serv, *rest)
- rest[0] = IPSocket.getaddress(rest[0]) if rest[0]
- original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
- end
-end
-
-class UDPSocket < IPSocket
- # :stopdoc:
- alias original_resolv_bind bind
- # :startdoc:
- def bind(host, port)
- host = IPSocket.getaddress(host) if host != ""
- original_resolv_bind(host, port)
- end
-
- # :stopdoc:
- alias original_resolv_connect connect
- # :startdoc:
- def connect(host, port)
- original_resolv_connect(IPSocket.getaddress(host), port)
- end
-
- # :stopdoc:
- alias original_resolv_send send
- # :startdoc:
- def send(mesg, flags, *rest)
- if rest.length == 2
- host, port = rest
- begin
- addrs = Resolv.getaddresses(host)
- rescue Resolv::ResolvError
- raise SocketError, "Hostname not known: #{host}"
- end
- addrs[0...-1].each {|addr|
- begin
- return original_resolv_send(mesg, flags, addr, port)
- rescue SystemCallError
- end
- }
- original_resolv_send(mesg, flags, addrs[-1], port)
- else
- original_resolv_send(mesg, flags, *rest)
- end
- end
-end
-
-class SOCKSSocket < TCPSocket
- # :stopdoc:
- alias original_resolv_initialize initialize
- # :startdoc:
- def initialize(host, serv)
- original_resolv_initialize(IPSocket.getaddress(host), port)
- end
-end if defined? SOCKSSocket
diff --git a/lib/resolv.gemspec b/lib/resolv.gemspec
index db256dc1b0..66aed34e01 100644
--- a/lib/resolv.gemspec
+++ b/lib/resolv.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "resolv"
- spec.version = "0.2.2"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
@@ -9,13 +16,13 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/resolv"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.extensions << "ext/win32/resolv/extconf.rb"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
+ excludes = %W[/.git* /bin /test /*file /#{File.basename(__FILE__)}]
+ spec.files = IO.popen(%W[git -C #{__dir__} ls-files -z --] + excludes.map {|e| ":^#{e}"}, &:read).split("\x0")
spec.bindir = "exe"
spec.executables = []
spec.require_paths = ["lib"]
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 61c9c7d5cf..6b58f92813 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -3,11 +3,8 @@
require 'socket'
require 'timeout'
require 'io/wait'
-
-begin
- require 'securerandom'
-rescue LoadError
-end
+require 'securerandom'
+require 'rbconfig'
# Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can
# handle multiple DNS requests concurrently without blocking the entire Ruby
@@ -37,6 +34,9 @@ end
class Resolv
+ # The version string
+ VERSION = "0.7.1"
+
##
# Looks up the first IP address for +name+.
@@ -81,9 +81,22 @@ class Resolv
##
# Creates a new Resolv using +resolvers+.
+ #
+ # If +resolvers+ is not given, a hash, or +nil+, uses a Hosts resolver and
+ # and a DNS resolver. If +resolvers+ is a hash, uses the hash as
+ # configuration for the DNS resolver.
+
+ def initialize(resolvers=(arg_not_set = true; nil), use_ipv6: (keyword_not_set = true; nil))
+ if !keyword_not_set && !arg_not_set
+ warn "Support for separate use_ipv6 keyword is deprecated, as it is ignored if an argument is provided. Do not provide a positional argument if using the use_ipv6 keyword argument.", uplevel: 1
+ end
- def initialize(resolvers=[Hosts.new, DNS.new])
- @resolvers = resolvers
+ @resolvers = case resolvers
+ when Hash, nil
+ [Hosts.new, DNS.new(DNS::Config.default_config_hash.merge(resolvers || {}))]
+ else
+ resolvers
+ end
end
##
@@ -166,14 +179,15 @@ class Resolv
# Resolv::Hosts is a hostname resolver that uses the system hosts file.
class Hosts
- if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and
+ if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/
begin
- require 'win32/resolv'
- DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
+ require 'win32/resolv' unless defined?(Win32::Resolv)
+ hosts = Win32::Resolv.get_hosts_path || IO::NULL
rescue LoadError
end
end
- DefaultFileName ||= '/etc/hosts'
+ # The default file name for host names
+ DefaultFileName = hosts || '/etc/hosts'
##
# Creates a new Resolv::Hosts, using +filename+ for its data source.
@@ -192,17 +206,10 @@ class Resolv
File.open(@filename, 'rb') {|f|
f.each {|line|
line.sub!(/#.*/, '')
- addr, hostname, *aliases = line.split(/\s+/)
+ addr, *hostnames = line.split(/\s+/)
next unless addr
- @addr2name[addr] = [] unless @addr2name.include? addr
- @addr2name[addr] << hostname
- @addr2name[addr] += aliases
- @name2addr[hostname] = [] unless @name2addr.include? hostname
- @name2addr[hostname] << addr
- aliases.each {|n|
- @name2addr[n] = [] unless @name2addr.include? n
- @name2addr[n] << addr
- }
+ (@addr2name[addr] ||= []).concat(hostnames)
+ hostnames.each {|hostname| (@name2addr[hostname] ||= []) << addr}
}
}
@name2addr.each {|name, arr| arr.reverse!}
@@ -310,6 +317,8 @@ class Resolv
# String:: Path to a file using /etc/resolv.conf's format.
# Hash:: Must contain :nameserver, :search and :ndots keys.
# :nameserver_port can be used to specify port number of nameserver address.
+ # :raise_timeout_errors can be used to raise timeout errors
+ # as exceptions instead of treating the same as an NXDOMAIN response.
#
# The value of :nameserver should be an address string or
# an array of address strings.
@@ -399,13 +408,20 @@ class Resolv
# be a Resolv::IPv4 or Resolv::IPv6
def each_address(name)
- each_resource(name, Resource::IN::A) {|resource| yield resource.address}
if use_ipv6?
each_resource(name, Resource::IN::AAAA) {|resource| yield resource.address}
end
+ each_resource(name, Resource::IN::A) {|resource| yield resource.address}
end
def use_ipv6? # :nodoc:
+ @config.lazy_initialize unless @config.instance_variable_get(:@initialized)
+
+ use_ipv6 = @config.use_ipv6?
+ unless use_ipv6.nil?
+ return use_ipv6
+ end
+
begin
list = Socket.ip_address_list
rescue NotImplementedError
@@ -471,13 +487,18 @@ class Resolv
# * Resolv::DNS::Resource::IN::A
# * Resolv::DNS::Resource::IN::AAAA
# * Resolv::DNS::Resource::IN::ANY
+ # * Resolv::DNS::Resource::IN::CAA
# * Resolv::DNS::Resource::IN::CNAME
# * Resolv::DNS::Resource::IN::HINFO
+ # * Resolv::DNS::Resource::IN::HTTPS
+ # * Resolv::DNS::Resource::IN::LOC
# * Resolv::DNS::Resource::IN::MINFO
# * Resolv::DNS::Resource::IN::MX
# * Resolv::DNS::Resource::IN::NS
# * Resolv::DNS::Resource::IN::PTR
# * Resolv::DNS::Resource::IN::SOA
+ # * Resolv::DNS::Resource::IN::SRV
+ # * Resolv::DNS::Resource::IN::SVCB
# * Resolv::DNS::Resource::IN::TXT
# * Resolv::DNS::Resource::IN::WKS
#
@@ -509,37 +530,44 @@ class Resolv
}
end
+ # :stopdoc:
+
def fetch_resource(name, typeclass)
lazy_initialize
- begin
- requester = make_udp_requester
+ truncated = {}
+ requesters = {}
+ udp_requester = begin
+ make_udp_requester
rescue Errno::EACCES
# fall back to TCP
end
senders = {}
+
begin
- @config.resolv(name) {|candidate, tout, nameserver, port|
- requester ||= make_tcp_requester(nameserver, port)
+ @config.resolv(name) do |candidate, tout, nameserver, port|
msg = Message.new
msg.rd = 1
msg.add_question(candidate, typeclass)
- unless sender = senders[[candidate, nameserver, port]]
+
+ requester = requesters.fetch([nameserver, port]) do
+ if !truncated[candidate] && udp_requester
+ udp_requester
+ else
+ requesters[[nameserver, port]] = make_tcp_requester(nameserver, port)
+ end
+ end
+
+ unless sender = senders[[candidate, requester, nameserver, port]]
sender = requester.sender(msg, candidate, nameserver, port)
next if !sender
- senders[[candidate, nameserver, port]] = sender
+ senders[[candidate, requester, nameserver, port]] = sender
end
reply, reply_name = requester.request(sender, tout)
case reply.rcode
when RCode::NoError
if reply.tc == 1 and not Requester::TCP === requester
- requester.close
# Retry via TCP:
- requester = make_tcp_requester(nameserver, port)
- senders = {}
- # This will use TCP for all remaining candidates (assuming the
- # current candidate does not already respond successfully via
- # TCP). This makes sense because we already know the full
- # response will not fit in an untruncated UDP packet.
+ truncated[candidate] = true
redo
else
yield(reply, reply_name)
@@ -550,9 +578,10 @@ class Resolv
else
raise Config::OtherResolvError.new(reply_name.to_s)
end
- }
+ end
ensure
- requester&.close
+ udp_requester&.close
+ requesters.each_value { |requester| requester&.close }
end
end
@@ -567,6 +596,11 @@ class Resolv
def make_tcp_requester(host, port) # :nodoc:
return Requester::TCP.new(host, port)
+ rescue Errno::ECONNREFUSED
+ # Treat a refused TCP connection attempt to a nameserver like a timeout,
+ # as Resolv::DNS::Config#resolv considers ResolvTimeout exceptions as a
+ # hint to try the next nameserver:
+ raise ResolvTimeout
end
def extract_resources(msg, name, typeclass) # :nodoc:
@@ -600,16 +634,10 @@ 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:
+ def self.random(arg) # :nodoc:
+ begin
+ SecureRandom.random_number(arg)
+ rescue NotImplementedError
rand(arg)
end
end
@@ -641,8 +669,20 @@ class Resolv
}
end
- def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
- begin
+ case RUBY_PLATFORM
+ when *[
+ # https://www.rfc-editor.org/rfc/rfc6056.txt
+ # Appendix A. Survey of the Algorithms in Use by Some Popular Implementations
+ /freebsd/, /linux/, /netbsd/, /openbsd/, /solaris/,
+ /darwin/, # the same as FreeBSD
+ ] then
+ def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
+ udpsock.bind(bind_host, 0)
+ end
+ else
+ # Sequential port assignment
+ def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
+ # Ephemeral port number range recommended by RFC 6056
port = random(1024..65535)
udpsock.bind(bind_host, port)
rescue Errno::EADDRINUSE, # POSIX
@@ -686,7 +726,8 @@ class Resolv
begin
reply, from = recv_reply(select_result[0])
rescue Errno::ECONNREFUSED, # GNU/Linux, FreeBSD
- Errno::ECONNRESET # Windows
+ Errno::ECONNRESET, # Windows
+ EOFError
# No name server running on the server?
# Don't wait anymore.
raise ResolvTimeout
@@ -748,7 +789,7 @@ class Resolv
next if @socks_hash[bind_host]
begin
sock = UDPSocket.new(af)
- rescue Errno::EAFNOSUPPORT
+ rescue Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT
next # The kernel doesn't support the address family.
end
@socks << sock
@@ -895,8 +936,11 @@ class Resolv
end
def recv_reply(readable_socks)
- len = readable_socks[0].read(2).unpack('n')[0]
+ len_data = readable_socks[0].read(2)
+ raise EOFError if len_data.nil? || len_data.bytesize != 2
+ len = len_data.unpack('n')[0]
reply = @socks[0].read(len)
+ raise EOFError if reply.nil? || reply.bytesize != len
return reply, nil
end
@@ -965,13 +1009,13 @@ class Resolv
next unless keyword
case keyword
when 'nameserver'
- nameserver += args
+ nameserver.concat(args.each(&:freeze))
when 'domain'
next if args.empty?
- search = [args[0]]
+ search = [args[0].freeze]
when 'search'
next if args.empty?
- search = args
+ search = args.each(&:freeze)
when 'options'
args.each {|arg|
case arg
@@ -982,28 +1026,28 @@ class Resolv
end
}
}
- return { :nameserver => nameserver, :search => search, :ndots => ndots }
+ return { :nameserver => nameserver.freeze, :search => search.freeze, :ndots => ndots.freeze }.freeze
end
def Config.default_config_hash(filename="/etc/resolv.conf")
if File.exist? filename
- config_hash = Config.parse_resolv_conf(filename)
+ Config.parse_resolv_conf(filename)
+ elsif defined?(Win32::Resolv)
+ search, nameserver = Win32::Resolv.get_resolv_info
+ config_hash = {}
+ config_hash[:nameserver] = nameserver if nameserver
+ config_hash[:search] = [search].flatten if search
+ config_hash
else
- if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
- require 'win32/resolv'
- search, nameserver = Win32::Resolv.get_resolv_info
- config_hash = {}
- config_hash[:nameserver] = nameserver if nameserver
- config_hash[:search] = [search].flatten if search
- end
+ {}
end
- config_hash || {}
end
def lazy_initialize
@mutex.synchronize {
unless @initialized
@nameserver_port = []
+ @use_ipv6 = nil
@search = nil
@ndots = 1
case @config_info
@@ -1028,8 +1072,12 @@ class Resolv
if config_hash.include? :nameserver_port
@nameserver_port = config_hash[:nameserver_port].map {|ns, port| [ns, (port || Port)] }
end
+ if config_hash.include? :use_ipv6
+ @use_ipv6 = config_hash[:use_ipv6]
+ end
@search = config_hash[:search] if config_hash.include? :search
@ndots = config_hash[:ndots] if config_hash.include? :ndots
+ @raise_timeout_errors = config_hash[:raise_timeout_errors]
if @nameserver_port.empty?
@nameserver_port << ['0.0.0.0', Port]
@@ -1083,6 +1131,10 @@ class Resolv
@nameserver_port
end
+ def use_ipv6?
+ @use_ipv6
+ end
+
def generate_candidates(name)
candidates = nil
name = Name.create(name)
@@ -1116,6 +1168,7 @@ class Resolv
def resolv(name)
candidates = generate_candidates(name)
timeouts = @timeouts || generate_timeouts
+ timeout_error = false
begin
candidates.each {|candidate|
begin
@@ -1127,11 +1180,13 @@ class Resolv
end
}
}
+ timeout_error = true
raise ResolvError.new("DNS resolv timeout: #{name}")
rescue NXDomain
end
}
rescue ResolvError
+ raise if @raise_timeout_errors && timeout_error
end
end
@@ -1487,14 +1542,14 @@ class Resolv
}
end
- def put_name(d)
- put_labels(d.to_a)
+ def put_name(d, compress: true)
+ put_labels(d.to_a, compress: compress)
end
- def put_labels(d)
+ def put_labels(d, compress: true)
d.each_index {|i|
domain = d[i..-1]
- if idx = @names[domain]
+ if compress && idx = @names[domain]
self.put_pack("n", 0xc000 | idx)
return
else
@@ -1518,13 +1573,15 @@ class Resolv
id, flag, qdcount, ancount, nscount, arcount =
msg.get_unpack('nnnnnn')
o.id = id
+ o.tc = (flag >> 9) & 1
+ o.rcode = flag & 15
+ return o unless o.tc.zero?
+
o.qr = (flag >> 15) & 1
o.opcode = (flag >> 11) & 15
o.aa = (flag >> 10) & 1
- o.tc = (flag >> 9) & 1
o.rd = (flag >> 8) & 1
o.ra = (flag >> 7) & 1
- o.rcode = flag & 15
(1..qdcount).each {
name, typeclass = msg.get_question
o.add_question(name, typeclass)
@@ -1616,6 +1673,14 @@ class Resolv
strings
end
+ def get_list
+ [].tap do |values|
+ while @index < @limit
+ values << yield
+ end
+ end
+ end
+
def get_name
return Name.new(self.get_labels)
end
@@ -1624,6 +1689,7 @@ class Resolv
prev_index = @index
save_index = nil
d = []
+ size = -1
while true
raise DecodeError.new("limit exceeded") if @limit <= @index
case @data.getbyte(@index)
@@ -1644,7 +1710,10 @@ class Resolv
end
@index = idx
else
- d << self.get_label
+ l = self.get_label
+ d << l
+ size += 1 + l.string.bytesize
+ raise DecodeError.new("name label data exceed 255 octets") if size > 255
end
end
end
@@ -1677,6 +1746,377 @@ class Resolv
end
##
+ # SvcParams for service binding RRs. [RFC9460]
+
+ class SvcParams
+ include Enumerable
+
+ ##
+ # Create a list of SvcParams with the given initial content.
+ #
+ # +params+ has to be an enumerable of +SvcParam+s.
+ # If its content has +SvcParam+s with the duplicate key,
+ # the one appears last takes precedence.
+
+ def initialize(params = [])
+ @params = {}
+
+ params.each do |param|
+ add param
+ end
+ end
+
+ ##
+ # Get SvcParam for the given +key+ in this list.
+
+ def [](key)
+ @params[canonical_key(key)]
+ end
+
+ ##
+ # Get the number of SvcParams in this list.
+
+ def count
+ @params.count
+ end
+
+ ##
+ # Get whether this list is empty.
+
+ def empty?
+ @params.empty?
+ end
+
+ ##
+ # Add the SvcParam +param+ to this list, overwriting the existing one with the same key.
+
+ def add(param)
+ @params[param.class.key_number] = param
+ end
+
+ ##
+ # Remove the +SvcParam+ with the given +key+ and return it.
+
+ def delete(key)
+ @params.delete(canonical_key(key))
+ end
+
+ ##
+ # Enumerate the +SvcParam+s in this list.
+
+ def each(&block)
+ return enum_for(:each) unless block
+ @params.each_value(&block)
+ end
+
+ def encode(msg) # :nodoc:
+ @params.keys.sort.each do |key|
+ msg.put_pack('n', key)
+ msg.put_length16 do
+ @params.fetch(key).encode(msg)
+ end
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ params = msg.get_list do
+ key, = msg.get_unpack('n')
+ msg.get_length16 do
+ SvcParam::ClassHash[key].decode(msg)
+ end
+ end
+
+ return self.new(params)
+ end
+
+ private
+
+ def canonical_key(key) # :nodoc:
+ case key
+ when Integer
+ key
+ when /\Akey(\d+)\z/
+ Integer($1)
+ when Symbol
+ SvcParam::ClassHash[key].key_number
+ else
+ raise TypeError, 'key must be either String or Symbol'
+ end
+ end
+ end
+
+ ##
+ # Base class for SvcParam. [RFC9460]
+
+ class SvcParam
+
+ ##
+ # Get the presentation name of the SvcParamKey.
+
+ def self.key_name
+ const_get(:KeyName)
+ end
+
+ ##
+ # Get the registered number of the SvcParamKey.
+
+ def self.key_number
+ const_get(:KeyNumber)
+ end
+
+ ClassHash = Hash.new do |h, key| # :nodoc:
+ case key
+ when Integer
+ Generic.create(key)
+ when /\Akey(?<key>\d+)\z/
+ Generic.create(key.to_int)
+ when Symbol
+ raise KeyError, "unknown key #{key}"
+ else
+ raise TypeError, 'key must be either String or Symbol'
+ end
+ end
+
+ ##
+ # Generic SvcParam abstract class.
+
+ class Generic < SvcParam
+
+ ##
+ # SvcParamValue in wire-format byte string.
+
+ attr_reader :value
+
+ ##
+ # Create generic SvcParam
+
+ def initialize(value)
+ @value = value
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_bytes(@value)
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new(msg.get_bytes)
+ end
+
+ def self.create(key_number)
+ c = Class.new(Generic)
+ key_name = :"key#{key_number}"
+ c.const_set(:KeyName, key_name)
+ c.const_set(:KeyNumber, key_number)
+ self.const_set(:"Key#{key_number}", c)
+ ClassHash[key_name] = ClassHash[key_number] = c
+ return c
+ end
+ end
+
+ ##
+ # "mandatory" SvcParam -- Mandatory keys in service binding RR
+
+ class Mandatory < SvcParam
+ KeyName = :mandatory
+ KeyNumber = 0
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Mandatory keys.
+
+ attr_reader :keys
+
+ ##
+ # Initialize "mandatory" ScvParam.
+
+ def initialize(keys)
+ @keys = keys.map(&:to_int)
+ end
+
+ def encode(msg) # :nodoc:
+ @keys.sort.each do |key|
+ msg.put_pack('n', key)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ keys = msg.get_list { msg.get_unpack('n')[0] }
+ return self.new(keys)
+ end
+ end
+
+ ##
+ # "alpn" SvcParam -- Additional supported protocols
+
+ class ALPN < SvcParam
+ KeyName = :alpn
+ KeyNumber = 1
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Supported protocol IDs.
+
+ attr_reader :protocol_ids
+
+ ##
+ # Initialize "alpn" ScvParam.
+
+ def initialize(protocol_ids)
+ @protocol_ids = protocol_ids.map(&:to_str)
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_string_list(@protocol_ids)
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new(msg.get_string_list)
+ end
+ end
+
+ ##
+ # "no-default-alpn" SvcParam -- No support for default protocol
+
+ class NoDefaultALPN < SvcParam
+ KeyName = :'no-default-alpn'
+ KeyNumber = 2
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ def encode(msg) # :nodoc:
+ # no payload
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new
+ end
+ end
+
+ ##
+ # "port" SvcParam -- Port for alternative endpoint
+
+ class Port < SvcParam
+ KeyName = :port
+ KeyNumber = 3
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Port number.
+
+ attr_reader :port
+
+ ##
+ # Initialize "port" ScvParam.
+
+ def initialize(port)
+ @port = port.to_int
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_pack('n', @port)
+ end
+
+ def self.decode(msg) # :nodoc:
+ port, = msg.get_unpack('n')
+ return self.new(port)
+ end
+ end
+
+ ##
+ # "ipv4hint" SvcParam -- IPv4 address hints
+
+ class IPv4Hint < SvcParam
+ KeyName = :ipv4hint
+ KeyNumber = 4
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Set of IPv4 addresses.
+
+ attr_reader :addresses
+
+ ##
+ # Initialize "ipv4hint" ScvParam.
+
+ def initialize(addresses)
+ @addresses = addresses.map {|address| IPv4.create(address) }
+ end
+
+ def encode(msg) # :nodoc:
+ @addresses.each do |address|
+ msg.put_bytes(address.address)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ addresses = msg.get_list { IPv4.new(msg.get_bytes(4)) }
+ return self.new(addresses)
+ end
+ end
+
+ ##
+ # "ipv6hint" SvcParam -- IPv6 address hints
+
+ class IPv6Hint < SvcParam
+ KeyName = :ipv6hint
+ KeyNumber = 6
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Set of IPv6 addresses.
+
+ attr_reader :addresses
+
+ ##
+ # Initialize "ipv6hint" ScvParam.
+
+ def initialize(addresses)
+ @addresses = addresses.map {|address| IPv6.create(address) }
+ end
+
+ def encode(msg) # :nodoc:
+ @addresses.each do |address|
+ msg.put_bytes(address.address)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ addresses = msg.get_list { IPv6.new(msg.get_bytes(16)) }
+ return self.new(addresses)
+ end
+ end
+
+ ##
+ # "dohpath" SvcParam -- DNS over HTTPS path template [RFC9461]
+
+ class DoHPath < SvcParam
+ KeyName = :dohpath
+ KeyNumber = 7
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # URI template for DoH queries.
+
+ attr_reader :template
+
+ ##
+ # Initialize "dohpath" ScvParam.
+
+ def initialize(template)
+ @template = template.encode('utf-8')
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_bytes(@template)
+ end
+
+ def self.decode(msg) # :nodoc:
+ template = msg.get_bytes.force_encoding('utf-8')
+ return self.new(template)
+ end
+ end
+ end
+
+ ##
# A DNS query abstract class.
class Query
@@ -1699,7 +2139,14 @@ class Resolv
attr_reader :ttl
- ClassHash = {} # :nodoc:
+ ClassHash = Module.new do
+ module_function
+
+ def []=(type_class_value, klass)
+ type_value, class_value = type_class_value
+ Resource.const_set(:"Type#{type_value}_Class#{class_value}", klass)
+ end
+ end
def encode_rdata(msg) # :nodoc:
raise NotImplementedError.new
@@ -1737,7 +2184,9 @@ class Resolv
end
def self.get_class(type_value, class_value) # :nodoc:
- return ClassHash[[type_value, class_value]] ||
+ cache = :"Type#{type_value}_Class#{class_value}"
+
+ return (const_defined?(cache) && const_get(cache)) ||
Generic.create(type_value, class_value)
end
@@ -2103,7 +2552,6 @@ class Resolv
attr_reader :altitude
-
def encode_rdata(msg) # :nodoc:
msg.put_bytes(@version)
msg.put_bytes(@ssize.scalar)
@@ -2141,8 +2589,70 @@ class Resolv
TypeValue = 255 # :nodoc:
end
+ ##
+ # CAA resource record defined in RFC 8659
+ #
+ # These records identify certificate authority allowed to issue
+ # certificates for the given domain.
+
+ class CAA < Resource
+ TypeValue = 257
+
+ ##
+ # Creates a new CAA for +flags+, +tag+ and +value+.
+
+ def initialize(flags, tag, value)
+ unless (0..255) === flags
+ raise ArgumentError.new('flags must be an Integer between 0 and 255')
+ end
+ unless (1..15) === tag.bytesize
+ raise ArgumentError.new('length of tag must be between 1 and 15')
+ end
+
+ @flags = flags
+ @tag = tag
+ @value = value
+ end
+
+ ##
+ # Flags for this property:
+ # - Bit 0 : 0 = not critical, 1 = critical
+
+ attr_reader :flags
+
+ ##
+ # Property tag ("issue", "issuewild", "iodef"...).
+
+ attr_reader :tag
+
+ ##
+ # Property value.
+
+ attr_reader :value
+
+ ##
+ # Whether the critical flag is set on this property.
+
+ def critical?
+ flags & 0x80 != 0
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack('C', @flags)
+ msg.put_string(@tag)
+ msg.put_bytes(@value)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ flags, = msg.get_unpack('C')
+ tag = msg.get_string
+ value = msg.get_bytes
+ self.new flags, tag, value
+ end
+ end
+
ClassInsensitiveTypes = [ # :nodoc:
- NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, LOC, ANY
+ NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, LOC, ANY, CAA
]
##
@@ -2328,7 +2838,7 @@ class Resolv
msg.put_pack("n", @priority)
msg.put_pack("n", @weight)
msg.put_pack("n", @port)
- msg.put_name(@target)
+ msg.put_name(@target, compress: false)
end
def self.decode_rdata(msg) # :nodoc:
@@ -2339,6 +2849,84 @@ class Resolv
return self.new(priority, weight, port, target)
end
end
+
+ ##
+ # Common implementation for SVCB-compatible resource records.
+
+ class ServiceBinding
+
+ ##
+ # Create a service binding resource record.
+
+ def initialize(priority, target, params = [])
+ @priority = priority.to_int
+ @target = Name.create(target)
+ @params = SvcParams.new(params)
+ end
+
+ ##
+ # The priority of this target host.
+ #
+ # The range is 0-65535.
+ # If set to 0, this RR is in AliasMode. Otherwise, it is in ServiceMode.
+
+ attr_reader :priority
+
+ ##
+ # The domain name of the target host.
+
+ attr_reader :target
+
+ ##
+ # The service parameters for the target host.
+
+ attr_reader :params
+
+ ##
+ # Whether this RR is in AliasMode.
+
+ def alias_mode?
+ self.priority == 0
+ end
+
+ ##
+ # Whether this RR is in ServiceMode.
+
+ def service_mode?
+ !alias_mode?
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack("n", @priority)
+ msg.put_name(@target, compress: false)
+ @params.encode(msg)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ priority, = msg.get_unpack("n")
+ target = msg.get_name
+ params = SvcParams.decode(msg)
+ return self.new(priority, target, params)
+ end
+ end
+
+ ##
+ # SVCB resource record [RFC9460]
+
+ class SVCB < ServiceBinding
+ TypeValue = 64
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+ end
+
+ ##
+ # HTTPS resource record [RFC9460]
+
+ class HTTPS < ServiceBinding
+ TypeValue = 65
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+ end
end
end
end
@@ -2348,15 +2936,21 @@ class Resolv
class IPv4
- ##
- # Regular expression IPv4 addresses must match.
-
Regex256 = /0
|1(?:[0-9][0-9]?)?
|2(?:[0-4][0-9]?|5[0-5]?|[6-9])?
- |[3-9][0-9]?/x
+ |[3-9][0-9]?/x # :nodoc:
+
+ ##
+ # Regular expression IPv4 addresses must match.
Regex = /\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/
+ ##
+ # Creates a new IPv4 address from +arg+ which may be:
+ #
+ # IPv4:: returns +arg+.
+ # String:: +arg+ must match the IPv4::Regex constant
+
def self.create(arg)
case arg
when IPv4
@@ -2558,11 +3152,7 @@ class Resolv
attr_reader :address
def to_s # :nodoc:
- address = sprintf("%x:%x:%x:%x:%x:%x:%x:%x", *@address.unpack("nnnnnnnn"))
- unless address.sub!(/(^|:)0(:0)+(:|$)/, '::')
- address.sub!(/(^|:)0(:|$)/, '::')
- end
- return address
+ sprintf("%x:%x:%x:%x:%x:%x:%x:%x", *@address.unpack("nnnnnnnn")).sub(/(^|:)0(:0)+(:|$)/, '::')
end
def inspect # :nodoc:
@@ -2669,14 +3259,16 @@ class Resolv
end
- module LOC
+ module LOC # :nodoc:
##
# A Resolv::LOC::Size
class Size
- Regex = /^(\d+\.*\d*)[m]$/
+ # Regular expression LOC size must match.
+
+ Regex = /\A0*(\d{1,8}(?:\.\d+)?)m\z/
##
# Creates a new LOC::Size from +arg+ which may be:
@@ -2689,18 +3281,20 @@ class Resolv
when Size
return arg
when String
- scalar = ''
- if Regex =~ arg
- scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C")
- else
+ unless Regex =~ arg
raise ArgumentError.new("not a properly formed Size string: " + arg)
end
- return Size.new(scalar)
+ unless (0.0...1e8) === (scalar = $1.to_f)
+ raise ArgumentError.new("out of range as Size: #{arg}")
+ end
+ str = (scalar * 100).to_i.to_s
+ return new([(str[0].to_i << 4) + (str.bytesize-1)].pack("C"))
else
raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}")
end
end
+ # Internal use; use self.create.
def initialize(scalar)
@scalar = scalar
end
@@ -2711,8 +3305,8 @@ class Resolv
attr_reader :scalar
def to_s # :nodoc:
- s = @scalar.unpack("H2").join.to_s
- return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m"
+ s, = @scalar.unpack("C")
+ return "#{(s >> 4) * (10.0 ** ((s & 0xf) - 2))}m"
end
def inspect # :nodoc:
@@ -2738,7 +3332,12 @@ class Resolv
class Coord
- Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/
+ # Regular expression LOC Coord must match.
+
+ Regex = /\A0*(\d{1,3})\s([0-5]?\d)\s([0-5]?\d(?:\.\d+)?)\s([NESW])\z/
+
+ # Bias for the equator/prime meridian, in thousandths of a second of arc.
+ Bias = 1 << 31
##
# Creates a new LOC::Coord from +arg+ which may be:
@@ -2751,27 +3350,30 @@ class Resolv
when Coord
return arg
when String
- coordinates = ''
- if Regex =~ arg && $1.to_f < 180
- m = $~
- hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
- coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
- (m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")
- orientation = m[4][/[NS]/] ? 'lat' : 'lon'
- else
+ unless m = Regex.match(arg)
raise ArgumentError.new("not a properly formed Coord string: " + arg)
end
- return Coord.new(coordinates,orientation)
+
+ arc = (m[1].to_i * 3_600_000) + (m[2].to_i * 60_000) + (m[3].to_f * 1_000).to_i
+ dir = m[4]
+ lat = dir[/[NS]/]
+ unless arc <= (lat ? 324_000_000 : 648_000_000) # (lat ? 90 : 180) * 3_600_000
+ raise ArgumentError.new("out of range as Coord: #{arg}")
+ end
+
+ hemi = dir[/[NE]/] ? 1 : -1
+ return new([arc * hemi + Bias].pack("N"), lat ? "lat" : "lon")
else
raise ArgumentError.new("cannot interpret as Coord: #{arg.inspect}")
end
end
+ # Internal use; use self.create.
def initialize(coordinates,orientation)
- unless coordinates.kind_of?(String)
+ unless coordinates.kind_of?(String) and coordinates.bytesize == 4
raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
end
- unless orientation.kind_of?(String) && orientation[/^lon$|^lat$/]
+ unless orientation == "lon" || orientation == "lat"
raise ArgumentError.new('Coord expects orientation to be a String argument of "lat" or "lon"')
end
@coordinates = coordinates
@@ -2788,22 +3390,17 @@ class Resolv
attr_reader :orientation
def to_s # :nodoc:
- c = @coordinates.unpack("N").join.to_i
- val = (c - (2**31)).abs
- fracsecs = (val % 1e3).to_i.to_s
- val = val / 1e3
- secs = (val % 60).to_i.to_s
- val = val / 60
- mins = (val % 60).to_i.to_s
- degs = (val / 60).to_i.to_s
- posi = (c >= 2**31)
- case posi
- when true
- hemi = @orientation[/^lat$/] ? "N" : "E"
+ c, = @coordinates.unpack("N")
+ val = (c -= Bias).abs
+ val, fracsecs = val.divmod(1000)
+ val, secs = val.divmod(60)
+ degs, mins = val.divmod(60)
+ hemi = if c.negative?
+ @orientation == "lon" ? "W" : "S"
else
- hemi = @orientation[/^lon$/] ? "W" : "S"
+ @orientation == "lat" ? "N" : "E"
end
- return degs << " " << mins << " " << secs << "." << fracsecs << " " << hemi
+ format("%d %02d %02d.%03d %s", degs, mins, secs, fracsecs, hemi)
end
def inspect # :nodoc:
@@ -2829,7 +3426,12 @@ class Resolv
class Alt
- Regex = /^([+-]*\d+\.*\d*)[m]$/
+ # Regular expression LOC Alt must match.
+
+ Regex = /\A([+-]?0*\d{1,8}(?:\.\d+)?)m\z/
+
+ # Bias to a base of 100,000m below the WGS 84 reference spheroid.
+ Bias = 100_000_00
##
# Creates a new LOC::Alt from +arg+ which may be:
@@ -2842,18 +3444,20 @@ class Resolv
when Alt
return arg
when String
- altitude = ''
- if Regex =~ arg
- altitude = [($1.to_f*(1e2))+(1e7)].pack("N")
- else
+ unless Regex =~ arg
raise ArgumentError.new("not a properly formed Alt string: " + arg)
end
- return Alt.new(altitude)
+ altitude = ($1.to_f * 100).to_i + Bias
+ unless (0...0x1_0000_0000) === altitude
+ raise ArgumentError.new("out of raise as Alt: #{arg}")
+ end
+ return new([altitude].pack("N"))
else
raise ArgumentError.new("cannot interpret as Alt: #{arg.inspect}")
end
end
+ # Internal use; use self.create.
def initialize(altitude)
@altitude = altitude
end
@@ -2864,8 +3468,8 @@ class Resolv
attr_reader :altitude
def to_s # :nodoc:
- a = @altitude.unpack("N").join.to_i
- return ((a.to_f/1e2)-1e5).to_s + "m"
+ a, = @altitude.unpack("N")
+ return "#{(a - Bias).fdiv(100)}m"
end
def inspect # :nodoc:
@@ -2907,4 +3511,3 @@ class Resolv
AddressRegex = /(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/
end
-
diff --git a/lib/rinda/rinda.gemspec b/lib/rinda/rinda.gemspec
deleted file mode 100644
index 0c13e3c2df..0000000000
--- a/lib/rinda/rinda.gemspec
+++ /dev/null
@@ -1,28 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "rinda"
- spec.version = "0.1.1"
- spec.authors = ["Masatoshi SEKI"]
- spec.email = ["seki@ruby-lang.org"]
-
- spec.summary = %q{The Linda distributed computing paradigm in Ruby.}
- spec.description = %q{The Linda distributed computing paradigm in Ruby.}
- spec.homepage = "https://github.com/ruby/rinda"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_dependency "drb"
- spec.add_dependency "ipaddr"
- spec.add_dependency "forwardable"
-end
diff --git a/lib/rinda/rinda.rb b/lib/rinda/rinda.rb
deleted file mode 100644
index e762286d3b..0000000000
--- a/lib/rinda/rinda.rb
+++ /dev/null
@@ -1,327 +0,0 @@
-# frozen_string_literal: false
-require 'drb/drb'
-
-##
-# A module to implement the Linda distributed computing paradigm in Ruby.
-#
-# Rinda is part of DRb (dRuby).
-#
-# == Example(s)
-#
-# See the sample/drb/ directory in the Ruby distribution, from 1.8.2 onwards.
-#
-#--
-# TODO
-# == Introduction to Linda/rinda?
-#
-# == Why is this library separate from DRb?
-
-module Rinda
-
- ##
- # Rinda error base class
-
- class RindaError < RuntimeError; end
-
- ##
- # Raised when a hash-based tuple has an invalid key.
-
- class InvalidHashTupleKey < RindaError; end
-
- ##
- # Raised when trying to use a canceled tuple.
-
- class RequestCanceledError < ThreadError; end
-
- ##
- # Raised when trying to use an expired tuple.
-
- class RequestExpiredError < ThreadError; end
-
- ##
- # A tuple is the elementary object in Rinda programming.
- # Tuples may be matched against templates if the tuple and
- # the template are the same size.
-
- class Tuple
-
- ##
- # Creates a new Tuple from +ary_or_hash+ which must be an Array or Hash.
-
- def initialize(ary_or_hash)
- if hash?(ary_or_hash)
- init_with_hash(ary_or_hash)
- else
- init_with_ary(ary_or_hash)
- end
- end
-
- ##
- # The number of elements in the tuple.
-
- def size
- @tuple.size
- end
-
- ##
- # Accessor method for elements of the tuple.
-
- def [](k)
- @tuple[k]
- end
-
- ##
- # Fetches item +k+ from the tuple.
-
- def fetch(k)
- @tuple.fetch(k)
- end
-
- ##
- # Iterate through the tuple, yielding the index or key, and the
- # value, thus ensuring arrays are iterated similarly to hashes.
-
- def each # FIXME
- if Hash === @tuple
- @tuple.each { |k, v| yield(k, v) }
- else
- @tuple.each_with_index { |v, k| yield(k, v) }
- end
- end
-
- ##
- # Return the tuple itself
- def value
- @tuple
- end
-
- private
-
- def hash?(ary_or_hash)
- ary_or_hash.respond_to?(:keys)
- end
-
- ##
- # Munges +ary+ into a valid Tuple.
-
- def init_with_ary(ary)
- @tuple = Array.new(ary.size)
- @tuple.size.times do |i|
- @tuple[i] = ary[i]
- end
- end
-
- ##
- # Ensures +hash+ is a valid Tuple.
-
- def init_with_hash(hash)
- @tuple = Hash.new
- hash.each do |k, v|
- raise InvalidHashTupleKey unless String === k
- @tuple[k] = v
- end
- end
-
- end
-
- ##
- # Templates are used to match tuples in Rinda.
-
- class Template < Tuple
-
- ##
- # Matches this template against +tuple+. The +tuple+ must be the same
- # size as the template. An element with a +nil+ value in a template acts
- # as a wildcard, matching any value in the corresponding position in the
- # tuple. Elements of the template match the +tuple+ if the are #== or
- # #===.
- #
- # Template.new([:foo, 5]).match Tuple.new([:foo, 5]) # => true
- # Template.new([:foo, nil]).match Tuple.new([:foo, 5]) # => true
- # Template.new([String]).match Tuple.new(['hello']) # => true
- #
- # Template.new([:foo]).match Tuple.new([:foo, 5]) # => false
- # Template.new([:foo, 6]).match Tuple.new([:foo, 5]) # => false
- # Template.new([:foo, nil]).match Tuple.new([:foo]) # => false
- # Template.new([:foo, 6]).match Tuple.new([:foo]) # => false
-
- def match(tuple)
- return false unless tuple.respond_to?(:size)
- return false unless tuple.respond_to?(:fetch)
- return false unless self.size == tuple.size
- each do |k, v|
- begin
- it = tuple.fetch(k)
- rescue
- return false
- end
- next if v.nil?
- next if v == it
- next if v === it
- return false
- end
- return true
- end
-
- ##
- # Alias for #match.
-
- def ===(tuple)
- match(tuple)
- end
-
- end
-
- ##
- # <i>Documentation?</i>
-
- class DRbObjectTemplate
-
- ##
- # Creates a new DRbObjectTemplate that will match against +uri+ and +ref+.
-
- def initialize(uri=nil, ref=nil)
- @drb_uri = uri
- @drb_ref = ref
- end
-
- ##
- # This DRbObjectTemplate matches +ro+ if the remote object's drburi and
- # drbref are the same. +nil+ is used as a wildcard.
-
- def ===(ro)
- return true if super(ro)
- unless @drb_uri.nil?
- return false unless (@drb_uri === ro.__drburi rescue false)
- end
- unless @drb_ref.nil?
- return false unless (@drb_ref === ro.__drbref rescue false)
- end
- true
- end
-
- end
-
- ##
- # TupleSpaceProxy allows a remote Tuplespace to appear as local.
-
- class TupleSpaceProxy
- ##
- # A Port ensures that a moved tuple arrives properly at its destination
- # and does not get lost.
- #
- # See https://bugs.ruby-lang.org/issues/8125
-
- class Port # :nodoc:
- attr_reader :value
-
- def self.deliver
- port = new
-
- begin
- yield(port)
- ensure
- port.close
- end
-
- port.value
- end
-
- def initialize
- @open = true
- @value = nil
- end
-
- ##
- # Don't let the DRb thread push to it when remote sends tuple
-
- def close
- @open = false
- end
-
- ##
- # Stores +value+ and ensure it does not get marshaled multiple times.
-
- def push value
- raise 'port closed' unless @open
-
- @value = value
-
- nil # avoid Marshal
- end
- end
-
- ##
- # Creates a new TupleSpaceProxy to wrap +ts+.
-
- def initialize(ts)
- @ts = ts
- end
-
- ##
- # Adds +tuple+ to the proxied TupleSpace. See TupleSpace#write.
-
- def write(tuple, sec=nil)
- @ts.write(tuple, sec)
- end
-
- ##
- # Takes +tuple+ from the proxied TupleSpace. See TupleSpace#take.
-
- def take(tuple, sec=nil, &block)
- Port.deliver do |port|
- @ts.move(DRbObject.new(port), tuple, sec, &block)
- end
- end
-
- ##
- # Reads +tuple+ from the proxied TupleSpace. See TupleSpace#read.
-
- def read(tuple, sec=nil, &block)
- @ts.read(tuple, sec, &block)
- end
-
- ##
- # Reads all tuples matching +tuple+ from the proxied TupleSpace. See
- # TupleSpace#read_all.
-
- def read_all(tuple)
- @ts.read_all(tuple)
- end
-
- ##
- # Registers for notifications of event +ev+ on the proxied TupleSpace.
- # See TupleSpace#notify
-
- def notify(ev, tuple, sec=nil)
- @ts.notify(ev, tuple, sec)
- end
-
- end
-
- ##
- # An SimpleRenewer allows a TupleSpace to check if a TupleEntry is still
- # alive.
-
- class SimpleRenewer
-
- include DRbUndumped
-
- ##
- # Creates a new SimpleRenewer that keeps an object alive for another +sec+
- # seconds.
-
- def initialize(sec=180)
- @sec = sec
- end
-
- ##
- # Called by the TupleSpace to check if the object is still alive.
-
- def renew
- @sec
- end
- end
-
-end
-
diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb
deleted file mode 100644
index 948cfaf208..0000000000
--- a/lib/rinda/ring.rb
+++ /dev/null
@@ -1,484 +0,0 @@
-# frozen_string_literal: false
-#
-# Note: Rinda::Ring API is unstable.
-#
-require 'drb/drb'
-require_relative 'rinda'
-require 'ipaddr'
-
-module Rinda
-
- ##
- # The default port Ring discovery will use.
-
- Ring_PORT = 7647
-
- ##
- # A RingServer allows a Rinda::TupleSpace to be located via UDP broadcasts.
- # Default service location uses the following steps:
- #
- # 1. A RingServer begins listening on the network broadcast UDP address.
- # 2. A RingFinger sends a UDP packet containing the DRb URI where it will
- # listen for a reply.
- # 3. The RingServer receives the UDP packet and connects back to the
- # provided DRb URI with the DRb service.
- #
- # A RingServer requires a TupleSpace:
- #
- # ts = Rinda::TupleSpace.new
- # rs = Rinda::RingServer.new
- #
- # RingServer can also listen on multicast addresses for announcements. This
- # allows multiple RingServers to run on the same host. To use network
- # broadcast and multicast:
- #
- # ts = Rinda::TupleSpace.new
- # rs = Rinda::RingServer.new ts, %w[Socket::INADDR_ANY, 239.0.0.1 ff02::1]
-
- class RingServer
-
- include DRbUndumped
-
- ##
- # Special renewer for the RingServer to allow shutdown
-
- class Renewer # :nodoc:
- include DRbUndumped
-
- ##
- # Set to false to shutdown future requests using this Renewer
-
- attr_writer :renew
-
- def initialize # :nodoc:
- @renew = true
- end
-
- def renew # :nodoc:
- @renew ? 1 : true
- end
- end
-
- ##
- # Advertises +ts+ on the given +addresses+ at +port+.
- #
- # If +addresses+ is omitted only the UDP broadcast address is used.
- #
- # +addresses+ can contain multiple addresses. If a multicast address is
- # given in +addresses+ then the RingServer will listen for multicast
- # queries.
- #
- # If you use IPv4 multicast you may need to set an address of the inbound
- # interface which joins a multicast group.
- #
- # ts = Rinda::TupleSpace.new
- # rs = Rinda::RingServer.new(ts, [['239.0.0.1', '9.5.1.1']])
- #
- # You can set addresses as an Array Object. The first element of the
- # Array is a multicast address and the second is an inbound interface
- # address. If the second is omitted then '0.0.0.0' is used.
- #
- # If you use IPv6 multicast you may need to set both the local interface
- # address and the inbound interface index:
- #
- # rs = Rinda::RingServer.new(ts, [['ff02::1', '::1', 1]])
- #
- # The first element is a multicast address and the second is an inbound
- # interface address. The third is an inbound interface index.
- #
- # At this time there is no easy way to get an interface index by name.
- #
- # If the second is omitted then '::1' is used.
- # If the third is omitted then 0 (default interface) is used.
-
- def initialize(ts, addresses=[Socket::INADDR_ANY], port=Ring_PORT)
- @port = port
-
- if Integer === addresses then
- addresses, @port = [Socket::INADDR_ANY], addresses
- end
-
- @renewer = Renewer.new
-
- @ts = ts
- @sockets = []
- addresses.each do |address|
- if Array === address
- make_socket(*address)
- else
- make_socket(address)
- end
- end
-
- @w_services = write_services
- @r_service = reply_service
- end
-
- ##
- # Creates a socket at +address+
- #
- # If +address+ is multicast address then +interface_address+ and
- # +multicast_interface+ can be set as optional.
- #
- # A created socket is bound to +interface_address+. If you use IPv4
- # multicast then the interface of +interface_address+ is used as the
- # inbound interface. If +interface_address+ is omitted or nil then
- # '0.0.0.0' or '::1' is used.
- #
- # If you use IPv6 multicast then +multicast_interface+ is used as the
- # inbound interface. +multicast_interface+ is a network interface index.
- # If +multicast_interface+ is omitted then 0 (default interface) is used.
-
- def make_socket(address, interface_address=nil, multicast_interface=0)
- addrinfo = Addrinfo.udp(address, @port)
-
- socket = Socket.new(addrinfo.pfamily, addrinfo.socktype,
- addrinfo.protocol)
-
- if addrinfo.ipv4_multicast? or addrinfo.ipv6_multicast? then
- if Socket.const_defined?(:SO_REUSEPORT) then
- socket.setsockopt(:SOCKET, :SO_REUSEPORT, true)
- else
- socket.setsockopt(:SOCKET, :SO_REUSEADDR, true)
- end
-
- if addrinfo.ipv4_multicast? then
- interface_address = '0.0.0.0' if interface_address.nil?
- socket.bind(Addrinfo.udp(interface_address, @port))
-
- mreq = IPAddr.new(addrinfo.ip_address).hton +
- IPAddr.new(interface_address).hton
-
- socket.setsockopt(:IPPROTO_IP, :IP_ADD_MEMBERSHIP, mreq)
- else
- interface_address = '::1' if interface_address.nil?
- socket.bind(Addrinfo.udp(interface_address, @port))
-
- mreq = IPAddr.new(addrinfo.ip_address).hton +
- [multicast_interface].pack('I')
-
- socket.setsockopt(:IPPROTO_IPV6, :IPV6_JOIN_GROUP, mreq)
- end
- else
- socket.bind(addrinfo)
- end
-
- socket
- rescue
- socket = socket.close if socket
- raise
- ensure
- @sockets << socket if socket
- end
-
- ##
- # Creates threads that pick up UDP packets and passes them to do_write for
- # decoding.
-
- def write_services
- @sockets.map do |s|
- Thread.new(s) do |socket|
- loop do
- msg = socket.recv(1024)
- do_write(msg)
- end
- end
- end
- end
-
- ##
- # Extracts the response URI from +msg+ and adds it to TupleSpace where it
- # will be picked up by +reply_service+ for notification.
-
- def do_write(msg)
- Thread.new do
- begin
- tuple, sec = Marshal.load(msg)
- @ts.write(tuple, sec)
- rescue
- end
- end
- end
-
- ##
- # Creates a thread that notifies waiting clients from the TupleSpace.
-
- def reply_service
- Thread.new do
- loop do
- do_reply
- end
- end
- end
-
- ##
- # Pulls lookup tuples out of the TupleSpace and sends their DRb object the
- # address of the local TupleSpace.
-
- def do_reply
- tuple = @ts.take([:lookup_ring, nil], @renewer)
- Thread.new { tuple[1].call(@ts) rescue nil}
- rescue
- end
-
- ##
- # Shuts down the RingServer
-
- def shutdown
- @renewer.renew = false
-
- @w_services.each do |thread|
- thread.kill
- thread.join
- end
-
- @sockets.each do |socket|
- socket.close
- end
-
- @r_service.kill
- @r_service.join
- end
-
- end
-
- ##
- # RingFinger is used by RingServer clients to discover the RingServer's
- # TupleSpace. Typically, all a client needs to do is call
- # RingFinger.primary to retrieve the remote TupleSpace, which it can then
- # begin using.
- #
- # To find the first available remote TupleSpace:
- #
- # Rinda::RingFinger.primary
- #
- # To create a RingFinger that broadcasts to a custom list:
- #
- # rf = Rinda::RingFinger.new ['localhost', '192.0.2.1']
- # rf.primary
- #
- # Rinda::RingFinger also understands multicast addresses and sets them up
- # properly. This allows you to run multiple RingServers on the same host:
- #
- # rf = Rinda::RingFinger.new ['239.0.0.1']
- # rf.primary
- #
- # You can set the hop count (or TTL) for multicast searches using
- # #multicast_hops.
- #
- # If you use IPv6 multicast you may need to set both an address and the
- # outbound interface index:
- #
- # rf = Rinda::RingFinger.new ['ff02::1']
- # rf.multicast_interface = 1
- # rf.primary
- #
- # At this time there is no easy way to get an interface index by name.
-
- class RingFinger
-
- @@broadcast_list = ['<broadcast>', 'localhost']
-
- @@finger = nil
-
- ##
- # Creates a singleton RingFinger and looks for a RingServer. Returns the
- # created RingFinger.
-
- def self.finger
- unless @@finger
- @@finger = self.new
- @@finger.lookup_ring_any
- end
- @@finger
- end
-
- ##
- # Returns the first advertised TupleSpace.
-
- def self.primary
- finger.primary
- end
-
- ##
- # Contains all discovered TupleSpaces except for the primary.
-
- def self.to_a
- finger.to_a
- end
-
- ##
- # The list of addresses where RingFinger will send query packets.
-
- attr_accessor :broadcast_list
-
- ##
- # Maximum number of hops for sent multicast packets (if using a multicast
- # address in the broadcast list). The default is 1 (same as UDP
- # broadcast).
-
- attr_accessor :multicast_hops
-
- ##
- # The interface index to send IPv6 multicast packets from.
-
- attr_accessor :multicast_interface
-
- ##
- # The port that RingFinger will send query packets to.
-
- attr_accessor :port
-
- ##
- # Contain the first advertised TupleSpace after lookup_ring_any is called.
-
- attr_accessor :primary
-
- ##
- # Creates a new RingFinger that will look for RingServers at +port+ on
- # the addresses in +broadcast_list+.
- #
- # If +broadcast_list+ contains a multicast address then multicast queries
- # will be made using the given multicast_hops and multicast_interface.
-
- def initialize(broadcast_list=@@broadcast_list, port=Ring_PORT)
- @broadcast_list = broadcast_list || ['localhost']
- @port = port
- @primary = nil
- @rings = []
-
- @multicast_hops = 1
- @multicast_interface = 0
- end
-
- ##
- # Contains all discovered TupleSpaces except for the primary.
-
- def to_a
- @rings
- end
-
- ##
- # Iterates over all discovered TupleSpaces starting with the primary.
-
- def each
- lookup_ring_any unless @primary
- return unless @primary
- yield(@primary)
- @rings.each { |x| yield(x) }
- end
-
- ##
- # Looks up RingServers waiting +timeout+ seconds. RingServers will be
- # given +block+ as a callback, which will be called with the remote
- # TupleSpace.
-
- def lookup_ring(timeout=5, &block)
- return lookup_ring_any(timeout) unless block_given?
-
- msg = Marshal.dump([[:lookup_ring, DRbObject.new(block)], timeout])
- @broadcast_list.each do |it|
- send_message(it, msg)
- end
- sleep(timeout)
- end
-
- ##
- # Returns the first found remote TupleSpace. Any further recovered
- # TupleSpaces can be found by calling +to_a+.
-
- def lookup_ring_any(timeout=5)
- queue = Thread::Queue.new
-
- Thread.new do
- self.lookup_ring(timeout) do |ts|
- queue.push(ts)
- end
- queue.push(nil)
- end
-
- @primary = queue.pop
- raise('RingNotFound') if @primary.nil?
-
- Thread.new do
- while it = queue.pop
- @rings.push(it)
- end
- end
-
- @primary
- end
-
- ##
- # Creates a socket for +address+ with the appropriate multicast options
- # for multicast addresses.
-
- def make_socket(address) # :nodoc:
- addrinfo = Addrinfo.udp(address, @port)
-
- soc = Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol)
- begin
- if addrinfo.ipv4_multicast? then
- soc.setsockopt(Socket::Option.ipv4_multicast_loop(1))
- soc.setsockopt(Socket::Option.ipv4_multicast_ttl(@multicast_hops))
- elsif addrinfo.ipv6_multicast? then
- soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_LOOP, true)
- soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS,
- [@multicast_hops].pack('I'))
- soc.setsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_IF,
- [@multicast_interface].pack('I'))
- else
- soc.setsockopt(:SOL_SOCKET, :SO_BROADCAST, true)
- end
-
- soc.connect(addrinfo)
- rescue Exception
- soc.close
- raise
- end
-
- soc
- end
-
- def send_message(address, message) # :nodoc:
- soc = make_socket(address)
-
- soc.send(message, 0)
- rescue
- nil
- ensure
- soc.close if soc
- end
-
- end
-
- ##
- # RingProvider uses a RingServer advertised TupleSpace as a name service.
- # TupleSpace clients can register themselves with the remote TupleSpace and
- # look up other provided services via the remote TupleSpace.
- #
- # Services are registered with a tuple of the format [:name, klass,
- # DRbObject, description].
-
- class RingProvider
-
- ##
- # Creates a RingProvider that will provide a +klass+ service running on
- # +front+, with a +description+. +renewer+ is optional.
-
- def initialize(klass, front, desc, renewer = nil)
- @tuple = [:name, klass, front, desc]
- @renewer = renewer || Rinda::SimpleRenewer.new
- end
-
- ##
- # Advertises this service on the primary remote TupleSpace.
-
- def provide
- ts = Rinda::RingFinger.primary
- ts.write(@tuple, @renewer)
- end
-
- end
-
-end
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
deleted file mode 100644
index 6a41a7ba75..0000000000
--- a/lib/rinda/tuplespace.rb
+++ /dev/null
@@ -1,641 +0,0 @@
-# frozen_string_literal: false
-require 'monitor'
-require 'drb/drb'
-require_relative 'rinda'
-require 'forwardable'
-
-module Rinda
-
- ##
- # A TupleEntry is a Tuple (i.e. a possible entry in some Tuplespace)
- # together with expiry and cancellation data.
-
- class TupleEntry
-
- include DRbUndumped
-
- attr_accessor :expires
-
- ##
- # Creates a TupleEntry based on +ary+ with an optional renewer or expiry
- # time +sec+.
- #
- # A renewer must implement the +renew+ method which returns a Numeric,
- # nil, or true to indicate when the tuple has expired.
-
- def initialize(ary, sec=nil)
- @cancel = false
- @expires = nil
- @tuple = make_tuple(ary)
- @renewer = nil
- renew(sec)
- end
-
- ##
- # Marks this TupleEntry as canceled.
-
- def cancel
- @cancel = true
- end
-
- ##
- # A TupleEntry is dead when it is canceled or expired.
-
- def alive?
- !canceled? && !expired?
- end
-
- ##
- # Return the object which makes up the tuple itself: the Array
- # or Hash.
-
- def value; @tuple.value; end
-
- ##
- # Returns the canceled status.
-
- def canceled?; @cancel; end
-
- ##
- # Has this tuple expired? (true/false).
- #
- # A tuple has expired when its expiry timer based on the +sec+ argument to
- # #initialize runs out.
-
- def expired?
- return true unless @expires
- return false if @expires > Time.now
- return true if @renewer.nil?
- renew(@renewer)
- return true unless @expires
- return @expires < Time.now
- end
-
- ##
- # Reset the expiry time according to +sec_or_renewer+.
- #
- # +nil+:: it is set to expire in the far future.
- # +true+:: it has expired.
- # Numeric:: it will expire in that many seconds.
- #
- # Otherwise the argument refers to some kind of renewer object
- # which will reset its expiry time.
-
- def renew(sec_or_renewer)
- sec, @renewer = get_renewer(sec_or_renewer)
- @expires = make_expires(sec)
- end
-
- ##
- # Returns an expiry Time based on +sec+ which can be one of:
- # Numeric:: +sec+ seconds into the future
- # +true+:: the expiry time is the start of 1970 (i.e. expired)
- # +nil+:: it is Tue Jan 19 03:14:07 GMT Standard Time 2038 (i.e. when
- # UNIX clocks will die)
-
- def make_expires(sec=nil)
- case sec
- when Numeric
- Time.now + sec
- when true
- Time.at(1)
- when nil
- Time.at(2**31-1)
- end
- end
-
- ##
- # Retrieves +key+ from the tuple.
-
- def [](key)
- @tuple[key]
- end
-
- ##
- # Fetches +key+ from the tuple.
-
- def fetch(key)
- @tuple.fetch(key)
- end
-
- ##
- # The size of the tuple.
-
- def size
- @tuple.size
- end
-
- ##
- # Creates a Rinda::Tuple for +ary+.
-
- def make_tuple(ary)
- Rinda::Tuple.new(ary)
- end
-
- private
-
- ##
- # Returns a valid argument to make_expires and the renewer or nil.
- #
- # Given +true+, +nil+, or Numeric, returns that value and +nil+ (no actual
- # renewer). Otherwise it returns an expiry value from calling +it.renew+
- # and the renewer.
-
- def get_renewer(it)
- case it
- when Numeric, true, nil
- return it, nil
- else
- begin
- return it.renew, it
- rescue Exception
- return it, nil
- end
- end
- end
-
- end
-
- ##
- # A TemplateEntry is a Template together with expiry and cancellation data.
-
- class TemplateEntry < TupleEntry
- ##
- # Matches this TemplateEntry against +tuple+. See Template#match for
- # details on how a Template matches a Tuple.
-
- def match(tuple)
- @tuple.match(tuple)
- end
-
- alias === match
-
- def make_tuple(ary) # :nodoc:
- Rinda::Template.new(ary)
- end
-
- end
-
- ##
- # <i>Documentation?</i>
-
- class WaitTemplateEntry < TemplateEntry
-
- attr_reader :found
-
- def initialize(place, ary, expires=nil)
- super(ary, expires)
- @place = place
- @cond = place.new_cond
- @found = nil
- end
-
- def cancel
- super
- signal
- end
-
- def wait
- @cond.wait
- end
-
- def read(tuple)
- @found = tuple
- signal
- end
-
- def signal
- @place.synchronize do
- @cond.signal
- end
- end
-
- end
-
- ##
- # A NotifyTemplateEntry is returned by TupleSpace#notify and is notified of
- # TupleSpace changes. You may receive either your subscribed event or the
- # 'close' event when iterating over notifications.
- #
- # See TupleSpace#notify_event for valid notification types.
- #
- # == Example
- #
- # ts = Rinda::TupleSpace.new
- # observer = ts.notify 'write', [nil]
- #
- # Thread.start do
- # observer.each { |t| p t }
- # end
- #
- # 3.times { |i| ts.write [i] }
- #
- # Outputs:
- #
- # ['write', [0]]
- # ['write', [1]]
- # ['write', [2]]
-
- class NotifyTemplateEntry < TemplateEntry
-
- ##
- # Creates a new NotifyTemplateEntry that watches +place+ for +event+s that
- # match +tuple+.
-
- def initialize(place, event, tuple, expires=nil)
- ary = [event, Rinda::Template.new(tuple)]
- super(ary, expires)
- @queue = Thread::Queue.new
- @done = false
- end
-
- ##
- # Called by TupleSpace to notify this NotifyTemplateEntry of a new event.
-
- def notify(ev)
- @queue.push(ev)
- end
-
- ##
- # Retrieves a notification. Raises RequestExpiredError when this
- # NotifyTemplateEntry expires.
-
- def pop
- raise RequestExpiredError if @done
- it = @queue.pop
- @done = true if it[0] == 'close'
- return it
- end
-
- ##
- # Yields event/tuple pairs until this NotifyTemplateEntry expires.
-
- def each # :yields: event, tuple
- while !@done
- it = pop
- yield(it)
- end
- rescue
- ensure
- cancel
- end
-
- end
-
- ##
- # TupleBag is an unordered collection of tuples. It is the basis
- # 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
- @bin.reverse_each do |x|
- return x if yield(x)
- end
- nil
- end
- end
-
- def initialize # :nodoc:
- @hash = {}
- @enum = enum_for(:each_entry)
- end
-
- ##
- # +true+ if the TupleBag to see if it has any expired entries.
-
- def has_expires?
- @enum.find do |tuple|
- tuple.expires
- end
- end
-
- ##
- # Add +tuple+ to the TupleBag.
-
- def push(tuple)
- key = bin_key(tuple)
- @hash[key] ||= TupleBin.new
- @hash[key].add(tuple)
- end
-
- ##
- # Removes +tuple+ from the TupleBag.
-
- 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)
- bin_for_find(template).find_all do |tuple|
- tuple.alive? && template.match(tuple)
- end
- end
-
- ##
- # Finds a live tuple that matches +template+.
-
- def find(template)
- bin_for_find(template).find do |tuple|
- tuple.alive? && template.match(tuple)
- end
- end
-
- ##
- # Finds all tuples in the TupleBag which when treated as templates, match
- # +tuple+ and are alive.
-
- def find_all_template(tuple)
- @enum.find_all do |template|
- template.alive? && template.match(tuple)
- end
- end
-
- ##
- # Delete tuples which dead tuples from the TupleBag, returning the deleted
- # tuples.
-
- def delete_unless_alive
- deleted = []
- @hash.each do |key, bin|
- bin.delete_if do |tuple|
- if tuple.alive?
- false
- else
- deleted.push(tuple)
- true
- end
- end
- 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
-
- ##
- # The Tuplespace manages access to the tuples it contains,
- # ensuring mutual exclusion requirements are met.
- #
- # The +sec+ option for the write, take, move, read and notify methods may
- # either be a number of seconds or a Renewer object.
-
- class TupleSpace
-
- include DRbUndumped
- include MonitorMixin
-
- ##
- # Creates a new TupleSpace. +period+ is used to control how often to look
- # for dead tuples after modifications to the TupleSpace.
- #
- # If no dead tuples are found +period+ seconds after the last
- # modification, the TupleSpace will stop looking for dead tuples.
-
- def initialize(period=60)
- super()
- @bag = TupleBag.new
- @read_waiter = TupleBag.new
- @take_waiter = TupleBag.new
- @notify_waiter = TupleBag.new
- @period = period
- @keeper = nil
- end
-
- ##
- # Adds +tuple+
-
- def write(tuple, sec=nil)
- entry = create_entry(tuple, sec)
- synchronize do
- if entry.expired?
- @read_waiter.find_all_template(entry).each do |template|
- template.read(tuple)
- end
- notify_event('write', entry.value)
- 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
- @take_waiter.find_all_template(entry).each do |template|
- template.signal
- end
- notify_event('write', entry.value)
- end
- end
- entry
- end
-
- ##
- # Removes +tuple+
-
- def take(tuple, sec=nil, &block)
- move(nil, tuple, sec, &block)
- end
-
- ##
- # Moves +tuple+ to +port+.
-
- def move(port, tuple, sec=nil)
- template = WaitTemplateEntry.new(self, tuple, sec)
- yield(template) if block_given?
- synchronize do
- entry = @bag.find(template)
- if entry
- port.push(entry.value) if port
- @bag.delete(entry)
- notify_event('take', entry.value)
- return port ? nil : entry.value
- end
- raise RequestExpiredError if template.expired?
-
- begin
- @take_waiter.push(template)
- start_keeper if template.expires
- while true
- raise RequestCanceledError if template.canceled?
- raise RequestExpiredError if template.expired?
- entry = @bag.find(template)
- if entry
- port.push(entry.value) if port
- @bag.delete(entry)
- notify_event('take', entry.value)
- return port ? nil : entry.value
- end
- template.wait
- end
- ensure
- @take_waiter.delete(template)
- end
- end
- end
-
- ##
- # Reads +tuple+, but does not remove it.
-
- def read(tuple, sec=nil)
- template = WaitTemplateEntry.new(self, tuple, sec)
- yield(template) if block_given?
- synchronize do
- entry = @bag.find(template)
- return entry.value if entry
- raise RequestExpiredError if template.expired?
-
- begin
- @read_waiter.push(template)
- start_keeper if template.expires
- template.wait
- raise RequestCanceledError if template.canceled?
- raise RequestExpiredError if template.expired?
- return template.found
- ensure
- @read_waiter.delete(template)
- end
- end
- end
-
- ##
- # Returns all tuples matching +tuple+. Does not remove the found tuples.
-
- def read_all(tuple)
- template = WaitTemplateEntry.new(self, tuple, nil)
- synchronize do
- entry = @bag.find_all(template)
- entry.collect do |e|
- e.value
- end
- end
- end
-
- ##
- # Registers for notifications of +event+. Returns a NotifyTemplateEntry.
- # See NotifyTemplateEntry for examples of how to listen for notifications.
- #
- # +event+ can be:
- # 'write':: A tuple was added
- # 'take':: A tuple was taken or moved
- # 'delete':: A tuple was lost after being overwritten or expiring
- #
- # The TupleSpace will also notify you of the 'close' event when the
- # NotifyTemplateEntry has expired.
-
- def notify(event, tuple, sec=nil)
- template = NotifyTemplateEntry.new(self, event, tuple, sec)
- synchronize do
- @notify_waiter.push(template)
- end
- template
- end
-
- private
-
- def create_entry(tuple, sec)
- TupleEntry.new(tuple, sec)
- end
-
- ##
- # Removes dead tuples.
-
- def keep_clean
- synchronize do
- @read_waiter.delete_unless_alive.each do |e|
- e.signal
- end
- @take_waiter.delete_unless_alive.each do |e|
- e.signal
- end
- @notify_waiter.delete_unless_alive.each do |e|
- e.notify(['close'])
- end
- @bag.delete_unless_alive.each do |e|
- notify_event('delete', e.value)
- end
- end
- end
-
- ##
- # Notifies all registered listeners for +event+ of a status change of
- # +tuple+.
-
- def notify_event(event, tuple)
- ev = [event, tuple]
- @notify_waiter.find_all_template(ev).each do |template|
- template.notify(ev)
- end
- end
-
- ##
- # Creates a thread that scans the tuplespace for expired tuples.
-
- def start_keeper
- return if @keeper && @keeper.alive?
- @keeper = Thread.new do
- while true
- sleep(@period)
- synchronize do
- break unless need_keeper?
- keep_clean
- end
- end
- end
- end
-
- ##
- # Checks the tuplespace to see if it needs cleaning.
-
- def need_keeper?
- return true if @bag.has_expires?
- return true if @read_waiter.has_expires?
- return true if @take_waiter.has_expires?
- return true if @notify_waiter.has_expires?
- end
-
- end
-
-end
-
diff --git a/lib/ruby_vm/rjit/assembler.rb b/lib/ruby_vm/rjit/assembler.rb
deleted file mode 100644
index 6bd654fd3e..0000000000
--- a/lib/ruby_vm/rjit/assembler.rb
+++ /dev/null
@@ -1,1097 +0,0 @@
-# frozen_string_literal: true
-module RubyVM::RJIT
- # 8-bit memory access
- class BytePtr < Data.define(:reg, :disp); end
-
- # 32-bit memory access
- class DwordPtr < Data.define(:reg, :disp); end
-
- # 64-bit memory access
- QwordPtr = Array
-
- # SystemV x64 calling convention
- C_ARGS = [:rdi, :rsi, :rdx, :rcx, :r8, :r9]
- C_RET = :rax
-
- # https://www.intel.com/content/dam/develop/public/us/en/documents/325383-sdm-vol-2abcd.pdf
- # Mostly an x86_64 assembler, but this also has some stuff that is useful for any architecture.
- class Assembler
- # rel8 jumps are made with labels
- class Label < Data.define(:id, :name); end
-
- # rel32 is inserted as [Rel32, Rel32Pad..] and converted on #resolve_rel32
- class Rel32 < Data.define(:addr); end
- Rel32Pad = Object.new
-
- # A set of ModR/M values encoded on #insn
- class ModRM < Data.define(:mod, :reg, :rm); end
- Mod00 = 0b00 # Mod 00: [reg]
- Mod01 = 0b01 # Mod 01: [reg]+disp8
- Mod10 = 0b10 # Mod 10: [reg]+disp32
- Mod11 = 0b11 # Mod 11: reg
-
- # REX = 0100WR0B
- REX_B = 0b01000001
- REX_R = 0b01000100
- REX_W = 0b01001000
-
- # Operand matchers
- R32 = -> (op) { op.is_a?(Symbol) && r32?(op) }
- R64 = -> (op) { op.is_a?(Symbol) && r64?(op) }
- IMM8 = -> (op) { op.is_a?(Integer) && imm8?(op) }
- IMM32 = -> (op) { op.is_a?(Integer) && imm32?(op) }
- IMM64 = -> (op) { op.is_a?(Integer) && imm64?(op) }
-
- def initialize
- @bytes = []
- @labels = {}
- @label_id = 0
- @comments = Hash.new { |h, k| h[k] = [] }
- @blocks = Hash.new { |h, k| h[k] = [] }
- @stub_starts = Hash.new { |h, k| h[k] = [] }
- @stub_ends = Hash.new { |h, k| h[k] = [] }
- @pos_markers = Hash.new { |h, k| h[k] = [] }
- end
-
- def assemble(addr)
- set_code_addrs(addr)
- resolve_rel32(addr)
- resolve_labels
-
- write_bytes(addr)
-
- @pos_markers.each do |write_pos, markers|
- markers.each { |marker| marker.call(addr + write_pos) }
- end
- @bytes.size
- ensure
- @bytes.clear
- end
-
- def size
- @bytes.size
- end
-
- #
- # Instructions
- #
-
- def add(dst, src)
- case [dst, src]
- # ADD r/m64, imm8 (Mod 00: [reg])
- in [QwordPtr[R64 => dst_reg], IMM8 => src_imm]
- # REX.W + 83 /0 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod00, reg: 0, rm: dst_reg],
- imm: imm8(src_imm),
- )
- # ADD r/m64, imm8 (Mod 11: reg)
- in [R64 => dst_reg, IMM8 => src_imm]
- # REX.W + 83 /0 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod11, reg: 0, rm: dst_reg],
- imm: imm8(src_imm),
- )
- # ADD r/m64 imm32 (Mod 11: reg)
- in [R64 => dst_reg, IMM32 => src_imm]
- # REX.W + 81 /0 id
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x81,
- mod_rm: ModRM[mod: Mod11, reg: 0, rm: dst_reg],
- imm: imm32(src_imm),
- )
- # ADD r/m64, r64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 01 /r
- # MR: Operand 1: ModRM:r/m (r, w), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x01,
- mod_rm: ModRM[mod: Mod11, reg: src_reg, rm: dst_reg],
- )
- end
- end
-
- def and(dst, src)
- case [dst, src]
- # AND r/m64, imm8 (Mod 11: reg)
- in [R64 => dst_reg, IMM8 => src_imm]
- # REX.W + 83 /4 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod11, reg: 4, rm: dst_reg],
- imm: imm8(src_imm),
- )
- # AND r/m64, imm32 (Mod 11: reg)
- in [R64 => dst_reg, IMM32 => src_imm]
- # REX.W + 81 /4 id
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x81,
- mod_rm: ModRM[mod: Mod11, reg: 4, rm: dst_reg],
- imm: imm32(src_imm),
- )
- # AND r64, r/m64 (Mod 01: [reg]+disp8)
- in [R64 => dst_reg, QwordPtr[R64 => src_reg, IMM8 => src_disp]]
- # REX.W + 23 /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x23,
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: imm8(src_disp),
- )
- end
- end
-
- def call(dst)
- case dst
- # CALL rel32
- in Integer => dst_addr
- # E8 cd
- # D: Operand 1: Offset
- insn(opcode: 0xe8, imm: rel32(dst_addr))
- # CALL r/m64 (Mod 11: reg)
- in R64 => dst_reg
- # FF /2
- # M: Operand 1: ModRM:r/m (r)
- insn(
- opcode: 0xff,
- mod_rm: ModRM[mod: Mod11, reg: 2, rm: dst_reg],
- )
- end
- end
-
- def cmove(dst, src)
- case [dst, src]
- # CMOVE r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 44 /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x44],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovg(dst, src)
- case [dst, src]
- # CMOVG r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 4F /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x4f],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovge(dst, src)
- case [dst, src]
- # CMOVGE r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 4D /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x4d],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovl(dst, src)
- case [dst, src]
- # CMOVL r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 4C /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x4c],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovle(dst, src)
- case [dst, src]
- # CMOVLE r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 4E /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x4e],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovnz(dst, src)
- case [dst, src]
- # CMOVNZ r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 45 /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x45],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- end
- end
-
- def cmovz(dst, src)
- case [dst, src]
- # CMOVZ r64, r/m64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 0F 44 /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x44],
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- # CMOVZ r64, r/m64 (Mod 01: [reg]+disp8)
- in [R64 => dst_reg, QwordPtr[R64 => src_reg, IMM8 => src_disp]]
- # REX.W + 0F 44 /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: [0x0f, 0x44],
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: imm8(src_disp),
- )
- end
- end
-
- def cmp(left, right)
- case [left, right]
- # CMP r/m8, imm8 (Mod 01: [reg]+disp8)
- in [BytePtr[R64 => left_reg, IMM8 => left_disp], IMM8 => right_imm]
- # 80 /7 ib
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- opcode: 0x80,
- mod_rm: ModRM[mod: Mod01, reg: 7, rm: left_reg],
- disp: left_disp,
- imm: imm8(right_imm),
- )
- # CMP r/m32, imm32 (Mod 01: [reg]+disp8)
- in [DwordPtr[R64 => left_reg, IMM8 => left_disp], IMM32 => right_imm]
- # 81 /7 id
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- opcode: 0x81,
- mod_rm: ModRM[mod: Mod01, reg: 7, rm: left_reg],
- disp: left_disp,
- imm: imm32(right_imm),
- )
- # CMP r/m64, imm8 (Mod 01: [reg]+disp8)
- in [QwordPtr[R64 => left_reg, IMM8 => left_disp], IMM8 => right_imm]
- # REX.W + 83 /7 ib
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod01, reg: 7, rm: left_reg],
- disp: left_disp,
- imm: imm8(right_imm),
- )
- # CMP r/m64, imm8 (Mod 10: [reg]+disp32)
- in [QwordPtr[R64 => left_reg, IMM32 => left_disp], IMM8 => right_imm]
- # REX.W + 83 /7 ib
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod10, reg: 7, rm: left_reg],
- disp: imm32(left_disp),
- imm: imm8(right_imm),
- )
- # CMP r/m64, imm8 (Mod 11: reg)
- in [R64 => left_reg, IMM8 => right_imm]
- # REX.W + 83 /7 ib
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod11, reg: 7, rm: left_reg],
- imm: imm8(right_imm),
- )
- # CMP r/m64, imm32 (Mod 11: reg)
- in [R64 => left_reg, IMM32 => right_imm]
- # REX.W + 81 /7 id
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x81,
- mod_rm: ModRM[mod: Mod11, reg: 7, rm: left_reg],
- imm: imm32(right_imm),
- )
- # CMP r/m64, r64 (Mod 01: [reg]+disp8)
- in [QwordPtr[R64 => left_reg, IMM8 => left_disp], R64 => right_reg]
- # REX.W + 39 /r
- # MR: Operand 1: ModRM:r/m (r), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x39,
- mod_rm: ModRM[mod: Mod01, reg: right_reg, rm: left_reg],
- disp: left_disp,
- )
- # CMP r/m64, r64 (Mod 10: [reg]+disp32)
- in [QwordPtr[R64 => left_reg, IMM32 => left_disp], R64 => right_reg]
- # REX.W + 39 /r
- # MR: Operand 1: ModRM:r/m (r), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x39,
- mod_rm: ModRM[mod: Mod10, reg: right_reg, rm: left_reg],
- disp: imm32(left_disp),
- )
- # CMP r/m64, r64 (Mod 11: reg)
- in [R64 => left_reg, R64 => right_reg]
- # REX.W + 39 /r
- # MR: Operand 1: ModRM:r/m (r), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x39,
- mod_rm: ModRM[mod: Mod11, reg: right_reg, rm: left_reg],
- )
- end
- end
-
- def jbe(dst)
- case dst
- # JBE rel8
- in Label => dst_label
- # 76 cb
- insn(opcode: 0x76, imm: dst_label)
- # JBE rel32
- in Integer => dst_addr
- # 0F 86 cd
- insn(opcode: [0x0f, 0x86], imm: rel32(dst_addr))
- end
- end
-
- def je(dst)
- case dst
- # JE rel8
- in Label => dst_label
- # 74 cb
- insn(opcode: 0x74, imm: dst_label)
- # JE rel32
- in Integer => dst_addr
- # 0F 84 cd
- insn(opcode: [0x0f, 0x84], imm: rel32(dst_addr))
- end
- end
-
- def jl(dst)
- case dst
- # JL rel32
- in Integer => dst_addr
- # 0F 8C cd
- insn(opcode: [0x0f, 0x8c], imm: rel32(dst_addr))
- end
- end
-
- def jmp(dst)
- case dst
- # JZ rel8
- in Label => dst_label
- # EB cb
- insn(opcode: 0xeb, imm: dst_label)
- # JMP rel32
- in Integer => dst_addr
- # E9 cd
- insn(opcode: 0xe9, imm: rel32(dst_addr))
- # JMP r/m64 (Mod 01: [reg]+disp8)
- in QwordPtr[R64 => dst_reg, IMM8 => dst_disp]
- # FF /4
- insn(opcode: 0xff, mod_rm: ModRM[mod: Mod01, reg: 4, rm: dst_reg], disp: dst_disp)
- # JMP r/m64 (Mod 11: reg)
- in R64 => dst_reg
- # FF /4
- insn(opcode: 0xff, mod_rm: ModRM[mod: Mod11, reg: 4, rm: dst_reg])
- end
- end
-
- def jne(dst)
- case dst
- # JNE rel32
- in Integer => dst_addr
- # 0F 85 cd
- insn(opcode: [0x0f, 0x85], imm: rel32(dst_addr))
- end
- end
-
- def jnz(dst)
- case dst
- # JE rel8
- in Label => dst_label
- # 75 cb
- insn(opcode: 0x75, imm: dst_label)
- # JNZ rel32
- in Integer => dst_addr
- # 0F 85 cd
- insn(opcode: [0x0f, 0x85], imm: rel32(dst_addr))
- end
- end
-
- def jo(dst)
- case dst
- # JO rel32
- in Integer => dst_addr
- # 0F 80 cd
- insn(opcode: [0x0f, 0x80], imm: rel32(dst_addr))
- end
- end
-
- def jz(dst)
- case dst
- # JZ rel8
- in Label => dst_label
- # 74 cb
- insn(opcode: 0x74, imm: dst_label)
- # JZ rel32
- in Integer => dst_addr
- # 0F 84 cd
- insn(opcode: [0x0f, 0x84], imm: rel32(dst_addr))
- end
- end
-
- def lea(dst, src)
- case [dst, src]
- # LEA r64,m (Mod 01: [reg]+disp8)
- in [R64 => dst_reg, QwordPtr[R64 => src_reg, IMM8 => src_disp]]
- # REX.W + 8D /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8d,
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: imm8(src_disp),
- )
- # LEA r64,m (Mod 10: [reg]+disp32)
- in [R64 => dst_reg, QwordPtr[R64 => src_reg, IMM32 => src_disp]]
- # REX.W + 8D /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8d,
- mod_rm: ModRM[mod: Mod10, reg: dst_reg, rm: src_reg],
- disp: imm32(src_disp),
- )
- end
- end
-
- def mov(dst, src)
- case dst
- in R32 => dst_reg
- case src
- # MOV r32 r/m32 (Mod 01: [reg]+disp8)
- in DwordPtr[R64 => src_reg, IMM8 => src_disp]
- # 8B /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- opcode: 0x8b,
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: src_disp,
- )
- # MOV r32, imm32 (Mod 11: reg)
- in IMM32 => src_imm
- # B8+ rd id
- # OI: Operand 1: opcode + rd (w), Operand 2: imm8/16/32/64
- insn(
- opcode: 0xb8,
- rd: dst_reg,
- imm: imm32(src_imm),
- )
- end
- in R64 => dst_reg
- case src
- # MOV r64, r/m64 (Mod 00: [reg])
- in QwordPtr[R64 => src_reg]
- # REX.W + 8B /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8b,
- mod_rm: ModRM[mod: Mod00, reg: dst_reg, rm: src_reg],
- )
- # MOV r64, r/m64 (Mod 01: [reg]+disp8)
- in QwordPtr[R64 => src_reg, IMM8 => src_disp]
- # REX.W + 8B /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8b,
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: src_disp,
- )
- # MOV r64, r/m64 (Mod 10: [reg]+disp32)
- in QwordPtr[R64 => src_reg, IMM32 => src_disp]
- # REX.W + 8B /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8b,
- mod_rm: ModRM[mod: Mod10, reg: dst_reg, rm: src_reg],
- disp: imm32(src_disp),
- )
- # MOV r64, r/m64 (Mod 11: reg)
- in R64 => src_reg
- # REX.W + 8B /r
- # RM: Operand 1: ModRM:reg (w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x8b,
- mod_rm: ModRM[mod: Mod11, reg: dst_reg, rm: src_reg],
- )
- # MOV r/m64, imm32 (Mod 11: reg)
- in IMM32 => src_imm
- # REX.W + C7 /0 id
- # MI: Operand 1: ModRM:r/m (w), Operand 2: imm8/16/32/64
- insn(
- prefix: REX_W,
- opcode: 0xc7,
- mod_rm: ModRM[mod: Mod11, reg: 0, rm: dst_reg],
- imm: imm32(src_imm),
- )
- # MOV r64, imm64
- in IMM64 => src_imm
- # REX.W + B8+ rd io
- # OI: Operand 1: opcode + rd (w), Operand 2: imm8/16/32/64
- insn(
- prefix: REX_W,
- opcode: 0xb8,
- rd: dst_reg,
- imm: imm64(src_imm),
- )
- end
- in DwordPtr[R64 => dst_reg, IMM8 => dst_disp]
- case src
- # MOV r/m32, imm32 (Mod 01: [reg]+disp8)
- in IMM32 => src_imm
- # C7 /0 id
- # MI: Operand 1: ModRM:r/m (w), Operand 2: imm8/16/32/64
- insn(
- opcode: 0xc7,
- mod_rm: ModRM[mod: Mod01, reg: 0, rm: dst_reg],
- disp: dst_disp,
- imm: imm32(src_imm),
- )
- end
- in QwordPtr[R64 => dst_reg]
- case src
- # MOV r/m64, imm32 (Mod 00: [reg])
- in IMM32 => src_imm
- # REX.W + C7 /0 id
- # MI: Operand 1: ModRM:r/m (w), Operand 2: imm8/16/32/64
- insn(
- prefix: REX_W,
- opcode: 0xc7,
- mod_rm: ModRM[mod: Mod00, reg: 0, rm: dst_reg],
- imm: imm32(src_imm),
- )
- # MOV r/m64, r64 (Mod 00: [reg])
- in R64 => src_reg
- # REX.W + 89 /r
- # MR: Operand 1: ModRM:r/m (w), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x89,
- mod_rm: ModRM[mod: Mod00, reg: src_reg, rm: dst_reg],
- )
- end
- in QwordPtr[R64 => dst_reg, IMM8 => dst_disp]
- # Optimize encoding when disp is 0
- return mov([dst_reg], src) if dst_disp == 0
-
- case src
- # MOV r/m64, imm32 (Mod 01: [reg]+disp8)
- in IMM32 => src_imm
- # REX.W + C7 /0 id
- # MI: Operand 1: ModRM:r/m (w), Operand 2: imm8/16/32/64
- insn(
- prefix: REX_W,
- opcode: 0xc7,
- mod_rm: ModRM[mod: Mod01, reg: 0, rm: dst_reg],
- disp: dst_disp,
- imm: imm32(src_imm),
- )
- # MOV r/m64, r64 (Mod 01: [reg]+disp8)
- in R64 => src_reg
- # REX.W + 89 /r
- # MR: Operand 1: ModRM:r/m (w), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x89,
- mod_rm: ModRM[mod: Mod01, reg: src_reg, rm: dst_reg],
- disp: dst_disp,
- )
- end
- in QwordPtr[R64 => dst_reg, IMM32 => dst_disp]
- case src
- # MOV r/m64, imm32 (Mod 10: [reg]+disp32)
- in IMM32 => src_imm
- # REX.W + C7 /0 id
- # MI: Operand 1: ModRM:r/m (w), Operand 2: imm8/16/32/64
- insn(
- prefix: REX_W,
- opcode: 0xc7,
- mod_rm: ModRM[mod: Mod10, reg: 0, rm: dst_reg],
- disp: imm32(dst_disp),
- imm: imm32(src_imm),
- )
- # MOV r/m64, r64 (Mod 10: [reg]+disp32)
- in R64 => src_reg
- # REX.W + 89 /r
- # MR: Operand 1: ModRM:r/m (w), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x89,
- mod_rm: ModRM[mod: Mod10, reg: src_reg, rm: dst_reg],
- disp: imm32(dst_disp),
- )
- end
- end
- end
-
- def or(dst, src)
- case [dst, src]
- # OR r/m64, imm8 (Mod 11: reg)
- in [R64 => dst_reg, IMM8 => src_imm]
- # REX.W + 83 /1 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod11, reg: 1, rm: dst_reg],
- imm: imm8(src_imm),
- )
- # OR r/m64, imm32 (Mod 11: reg)
- in [R64 => dst_reg, IMM32 => src_imm]
- # REX.W + 81 /1 id
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x81,
- mod_rm: ModRM[mod: Mod11, reg: 1, rm: dst_reg],
- imm: imm32(src_imm),
- )
- # OR r64, r/m64 (Mod 01: [reg]+disp8)
- in [R64 => dst_reg, QwordPtr[R64 => src_reg, IMM8 => src_disp]]
- # REX.W + 0B /r
- # RM: Operand 1: ModRM:reg (r, w), Operand 2: ModRM:r/m (r)
- insn(
- prefix: REX_W,
- opcode: 0x0b,
- mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
- disp: imm8(src_disp),
- )
- end
- end
-
- def push(src)
- case src
- # PUSH r64
- in R64 => src_reg
- # 50+rd
- # O: Operand 1: opcode + rd (r)
- insn(opcode: 0x50, rd: src_reg)
- end
- end
-
- def pop(dst)
- case dst
- # POP r64
- in R64 => dst_reg
- # 58+ rd
- # O: Operand 1: opcode + rd (r)
- insn(opcode: 0x58, rd: dst_reg)
- end
- end
-
- def ret
- # RET
- # Near return: A return to a procedure within the current code segment
- insn(opcode: 0xc3)
- end
-
- def sar(dst, src)
- case [dst, src]
- in [R64 => dst_reg, IMM8 => src_imm]
- # REX.W + C1 /7 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8
- insn(
- prefix: REX_W,
- opcode: 0xc1,
- mod_rm: ModRM[mod: Mod11, reg: 7, rm: dst_reg],
- imm: imm8(src_imm),
- )
- end
- end
-
- def sub(dst, src)
- case [dst, src]
- # SUB r/m64, imm8 (Mod 11: reg)
- in [R64 => dst_reg, IMM8 => src_imm]
- # REX.W + 83 /5 ib
- # MI: Operand 1: ModRM:r/m (r, w), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0x83,
- mod_rm: ModRM[mod: Mod11, reg: 5, rm: dst_reg],
- imm: imm8(src_imm),
- )
- # SUB r/m64, r64 (Mod 11: reg)
- in [R64 => dst_reg, R64 => src_reg]
- # REX.W + 29 /r
- # MR: Operand 1: ModRM:r/m (r, w), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x29,
- mod_rm: ModRM[mod: Mod11, reg: src_reg, rm: dst_reg],
- )
- end
- end
-
- def test(left, right)
- case [left, right]
- # TEST r/m8*, imm8 (Mod 01: [reg]+disp8)
- in [BytePtr[R64 => left_reg, IMM8 => left_disp], IMM8 => right_imm]
- # REX + F6 /0 ib
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- opcode: 0xf6,
- mod_rm: ModRM[mod: Mod01, reg: 0, rm: left_reg],
- disp: left_disp,
- imm: imm8(right_imm),
- )
- # TEST r/m64, imm32 (Mod 01: [reg]+disp8)
- in [QwordPtr[R64 => left_reg, IMM8 => left_disp], IMM32 => right_imm]
- # REX.W + F7 /0 id
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0xf7,
- mod_rm: ModRM[mod: Mod01, reg: 0, rm: left_reg],
- disp: left_disp,
- imm: imm32(right_imm),
- )
- # TEST r/m64, imm32 (Mod 10: [reg]+disp32)
- in [QwordPtr[R64 => left_reg, IMM32 => left_disp], IMM32 => right_imm]
- # REX.W + F7 /0 id
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0xf7,
- mod_rm: ModRM[mod: Mod10, reg: 0, rm: left_reg],
- disp: imm32(left_disp),
- imm: imm32(right_imm),
- )
- # TEST r/m64, imm32 (Mod 11: reg)
- in [R64 => left_reg, IMM32 => right_imm]
- # REX.W + F7 /0 id
- # MI: Operand 1: ModRM:r/m (r), Operand 2: imm8/16/32
- insn(
- prefix: REX_W,
- opcode: 0xf7,
- mod_rm: ModRM[mod: Mod11, reg: 0, rm: left_reg],
- imm: imm32(right_imm),
- )
- # TEST r/m32, r32 (Mod 11: reg)
- in [R32 => left_reg, R32 => right_reg]
- # 85 /r
- # MR: Operand 1: ModRM:r/m (r), Operand 2: ModRM:reg (r)
- insn(
- opcode: 0x85,
- mod_rm: ModRM[mod: Mod11, reg: right_reg, rm: left_reg],
- )
- # TEST r/m64, r64 (Mod 11: reg)
- in [R64 => left_reg, R64 => right_reg]
- # REX.W + 85 /r
- # MR: Operand 1: ModRM:r/m (r), Operand 2: ModRM:reg (r)
- insn(
- prefix: REX_W,
- opcode: 0x85,
- mod_rm: ModRM[mod: Mod11, reg: right_reg, rm: left_reg],
- )
- end
- end
-
- #
- # Utilities
- #
-
- attr_reader :comments
-
- def comment(message)
- @comments[@bytes.size] << message
- end
-
- # Mark the starting address of a block
- def block(block)
- @blocks[@bytes.size] << block
- end
-
- # Mark the starting/ending addresses of a stub
- def stub(stub)
- @stub_starts[@bytes.size] << stub
- yield
- ensure
- @stub_ends[@bytes.size] << stub
- end
-
- def pos_marker(&block)
- @pos_markers[@bytes.size] << block
- end
-
- def new_label(name)
- Label.new(id: @label_id += 1, name:)
- end
-
- # @param [RubyVM::RJIT::Assembler::Label] label
- def write_label(label)
- @labels[label] = @bytes.size
- end
-
- def incr_counter(name)
- if C.rjit_opts.stats
- comment("increment counter #{name}")
- mov(:rax, C.rb_rjit_counters[name].to_i)
- add([:rax], 1) # TODO: lock
- end
- end
-
- private
-
- def insn(prefix: 0, opcode:, rd: nil, mod_rm: nil, disp: nil, imm: nil)
- # Determine prefix
- if rd
- prefix |= REX_B if extended_reg?(rd)
- opcode += reg_code(rd)
- end
- if mod_rm
- prefix |= REX_R if mod_rm.reg.is_a?(Symbol) && extended_reg?(mod_rm.reg)
- prefix |= REX_B if mod_rm.rm.is_a?(Symbol) && extended_reg?(mod_rm.rm)
- end
-
- # Encode insn
- if prefix > 0
- @bytes.push(prefix)
- end
- @bytes.push(*Array(opcode))
- if mod_rm
- mod_rm_byte = encode_mod_rm(
- mod: mod_rm.mod,
- reg: mod_rm.reg.is_a?(Symbol) ? reg_code(mod_rm.reg) : mod_rm.reg,
- rm: mod_rm.rm.is_a?(Symbol) ? reg_code(mod_rm.rm) : mod_rm.rm,
- )
- @bytes.push(mod_rm_byte)
- end
- if disp
- @bytes.push(*Array(disp))
- end
- if imm
- @bytes.push(*imm)
- end
- end
-
- def reg_code(reg)
- reg_code_extended(reg).first
- end
-
- # Table 2-2. 32-Bit Addressing Forms with the ModR/M Byte
- #
- # 7 6 5 4 3 2 1 0
- # +--+--+--+--+--+--+--+--+
- # | Mod | Reg/ | R/M |
- # | | Opcode | |
- # +--+--+--+--+--+--+--+--+
- #
- # The r/m field can specify a register as an operand or it can be combined
- # with the mod field to encode an addressing mode.
- #
- # /0: R/M is 0 (not used)
- # /r: R/M is a register
- def encode_mod_rm(mod:, reg: 0, rm: 0)
- if mod > 0b11
- raise ArgumentError, "too large Mod: #{mod}"
- end
- if reg > 0b111
- raise ArgumentError, "too large Reg/Opcode: #{reg}"
- end
- if rm > 0b111
- raise ArgumentError, "too large R/M: #{rm}"
- end
- (mod << 6) + (reg << 3) + rm
- end
-
- # ib: 1 byte
- def imm8(imm)
- unless imm8?(imm)
- raise ArgumentError, "unexpected imm8: #{imm}"
- end
- [imm].pack('c').unpack('c*') # TODO: consider uimm
- end
-
- # id: 4 bytes
- def imm32(imm)
- unless imm32?(imm)
- raise ArgumentError, "unexpected imm32: #{imm}"
- end
- [imm].pack('l').unpack('c*') # TODO: consider uimm
- end
-
- # io: 8 bytes
- def imm64(imm)
- unless imm64?(imm)
- raise ArgumentError, "unexpected imm64: #{imm}"
- end
- imm_bytes(imm, 8)
- end
-
- def imm_bytes(imm, num_bytes)
- bytes = []
- bits = imm
- num_bytes.times do
- bytes << (bits & 0xff)
- bits >>= 8
- end
- if bits != 0
- raise ArgumentError, "unexpected imm with #{num_bytes} bytes: #{imm}"
- end
- bytes
- end
-
- def rel32(addr)
- [Rel32.new(addr), Rel32Pad, Rel32Pad, Rel32Pad]
- end
-
- def set_code_addrs(write_addr)
- (@bytes.size + 1).times do |index|
- @blocks.fetch(index, []).each do |block|
- block.start_addr = write_addr + index
- end
- @stub_starts.fetch(index, []).each do |stub|
- stub.start_addr = write_addr + index
- end
- @stub_ends.fetch(index, []).each do |stub|
- stub.end_addr = write_addr + index
- end
- end
- end
-
- def resolve_rel32(write_addr)
- @bytes.each_with_index do |byte, index|
- if byte.is_a?(Rel32)
- src_addr = write_addr + index + 4 # offset 4 bytes for rel32 itself
- dst_addr = byte.addr
- rel32 = dst_addr - src_addr
- raise "unexpected offset: #{rel32}" unless imm32?(rel32)
- imm32(rel32).each_with_index do |rel_byte, rel_index|
- @bytes[index + rel_index] = rel_byte
- end
- end
- end
- end
-
- def resolve_labels
- @bytes.each_with_index do |byte, index|
- if byte.is_a?(Label)
- src_index = index + 1 # offset 1 byte for rel8 itself
- dst_index = @labels.fetch(byte)
- rel8 = dst_index - src_index
- raise "unexpected offset: #{rel8}" unless imm8?(rel8)
- @bytes[index] = rel8
- end
- end
- end
-
- def write_bytes(addr)
- Fiddle::Pointer.new(addr)[0, @bytes.size] = @bytes.pack('c*')
- end
- end
-
- module OperandMatcher
- def imm8?(imm)
- (-0x80..0x7f).include?(imm)
- end
-
- def imm32?(imm)
- (-0x8000_0000..0x7fff_ffff).include?(imm) # TODO: consider uimm
- end
-
- def imm64?(imm)
- (-0x8000_0000_0000_0000..0xffff_ffff_ffff_ffff).include?(imm)
- end
-
- def r32?(reg)
- if extended_reg?(reg)
- reg.end_with?('d')
- else
- reg.start_with?('e')
- end
- end
-
- def r64?(reg)
- if extended_reg?(reg)
- reg.match?(/\Ar\d+\z/)
- else
- reg.start_with?('r')
- end
- end
-
- def extended_reg?(reg)
- reg_code_extended(reg).last
- end
-
- def reg_code_extended(reg)
- case reg
- # Not extended
- when :al, :ax, :eax, :rax then [0, false]
- when :cl, :cx, :ecx, :rcx then [1, false]
- when :dl, :dx, :edx, :rdx then [2, false]
- when :bl, :bx, :ebx, :rbx then [3, false]
- when :ah, :sp, :esp, :rsp then [4, false]
- when :ch, :bp, :ebp, :rbp then [5, false]
- when :dh, :si, :esi, :rsi then [6, false]
- when :bh, :di, :edi, :rdi then [7, false]
- # Extended
- when :r8b, :r8w, :r8d, :r8 then [0, true]
- when :r9b, :r9w, :r9d, :r9 then [1, true]
- when :r10b, :r10w, :r10d, :r10 then [2, true]
- when :r11b, :r11w, :r11d, :r11 then [3, true]
- when :r12b, :r12w, :r12d, :r12 then [4, true]
- when :r13b, :r13w, :r13d, :r13 then [5, true]
- when :r14b, :r14w, :r14d, :r14 then [6, true]
- when :r15b, :r15w, :r15d, :r15 then [7, true]
- else raise ArgumentError, "unexpected reg: #{reg.inspect}"
- end
- end
- end
-
- class Assembler
- include OperandMatcher
- extend OperandMatcher
- end
-end
diff --git a/lib/ruby_vm/rjit/block.rb b/lib/ruby_vm/rjit/block.rb
deleted file mode 100644
index cfdaade8b1..0000000000
--- a/lib/ruby_vm/rjit/block.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class RubyVM::RJIT::Block < Struct.new(
- :iseq, # @param ``
- :pc, # @param [Integer] Starting PC
- :ctx, # @param [RubyVM::RJIT::Context] **Starting** Context (TODO: freeze?)
- :start_addr, # @param [Integer] Starting address of this block's JIT code
- :entry_exit, # @param [Integer] Address of entry exit (optional)
- :incoming, # @param [Array<RubyVM::RJIT::BranchStub>] Incoming branches
- :invalidated, # @param [TrueClass,FalseClass] true if already invalidated
-)
- def initialize(incoming: [], invalidated: false, **) = super
-end
diff --git a/lib/ruby_vm/rjit/branch_stub.rb b/lib/ruby_vm/rjit/branch_stub.rb
deleted file mode 100644
index b9fe78b744..0000000000
--- a/lib/ruby_vm/rjit/branch_stub.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module RubyVM::RJIT
- # Branch shapes
- Next0 = :Next0 # target0 is a fallthrough
- Next1 = :Next1 # target1 is a fallthrough
- Default = :Default # neither targets is a fallthrough
-
- class BranchStub < Struct.new(
- :iseq, # @param [RubyVM::RJIT::CPointer::Struct_rb_iseq_struct] Branch target ISEQ
- :shape, # @param [Symbol] Next0, Next1, or Default
- :target0, # @param [RubyVM::RJIT::BranchTarget] First branch target
- :target1, # @param [RubyVM::RJIT::BranchTarget,NilClass] Second branch target (optional)
- :compile, # @param [Proc] A callback to (re-)generate this branch stub
- :start_addr, # @param [Integer] Stub source start address to be re-generated
- :end_addr, # @param [Integer] Stub source end address to be re-generated
- )
- end
-
- class BranchTarget < Struct.new(
- :pc,
- :ctx,
- :address,
- )
- end
-end
diff --git a/lib/ruby_vm/rjit/c_pointer.rb b/lib/ruby_vm/rjit/c_pointer.rb
deleted file mode 100644
index d65d5a93a5..0000000000
--- a/lib/ruby_vm/rjit/c_pointer.rb
+++ /dev/null
@@ -1,360 +0,0 @@
-module RubyVM::RJIT
- # Every class under this namespace is a pointer. Even if the type is
- # immediate, it shouldn't be dereferenced until `*` is called.
- module CPointer
- # Note: We'd like to avoid alphabetic method names to avoid a conflict
- # with member methods. to_i and to_s are considered an exception.
- class Struct
- # @param name [String]
- # @param sizeof [Integer]
- # @param members [Hash{ Symbol => [RubyVM::RJIT::CType::*, Integer, TrueClass] }]
- def initialize(addr, sizeof, members)
- @addr = addr
- @sizeof = sizeof
- @members = members
- end
-
- # Get a raw address
- def to_i
- @addr
- end
-
- # Serialized address for generated code
- def to_s
- "0x#{@addr.to_s(16)}"
- end
-
- # Pointer diff
- def -(struct)
- raise ArgumentError if self.class != struct.class
- (@addr - struct.to_i) / @sizeof
- end
-
- # Primitive API that does no automatic dereference
- # TODO: remove this?
- # @param member [Symbol]
- def [](member)
- type, offset = @members.fetch(member)
- type.new(@addr + offset / 8)
- end
-
- private
-
- # @param member [Symbol]
- # @param value [Object]
- def []=(member, value)
- type, offset = @members.fetch(member)
- type[@addr + offset / 8] = value
- end
-
- # @param size [Integer]
- # @param members [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }]
- def self.define(size, members)
- Class.new(self) do
- # Return the size of this type
- define_singleton_method(:size) { size }
-
- # Return the offset to a field
- define_singleton_method(:offsetof) do |field, *fields|
- member, offset = members.fetch(field)
- offset /= 8
- unless fields.empty?
- offset += member.offsetof(*fields)
- end
- offset
- end
-
- # Return member names
- define_singleton_method(:members) { members.keys }
-
- define_method(:initialize) do |addr = nil|
- if addr.nil? # TODO: get rid of this feature later
- addr = Fiddle.malloc(size)
- end
- super(addr, size, members)
- end
-
- members.each do |member, (type, offset, to_ruby)|
- # Intelligent API that does automatic dereference
- define_method(member) do
- value = self[member]
- if value.respond_to?(:*)
- value = value.*
- end
- if to_ruby
- value = C.to_ruby(value)
- end
- value
- end
-
- define_method("#{member}=") do |value|
- if to_ruby
- value = C.to_value(value)
- end
- self[member] = value
- end
- end
- end
- end
- end
-
- # Note: We'd like to avoid alphabetic method names to avoid a conflict
- # with member methods. to_i is considered an exception.
- class Union
- # @param _name [String] To be used when it starts defining a union pointer class
- # @param sizeof [Integer]
- # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
- def initialize(addr, sizeof, members)
- @addr = addr
- @sizeof = sizeof
- @members = members
- end
-
- # Get a raw address
- def to_i
- @addr
- end
-
- # Move addr to access this pointer like an array
- def +(index)
- raise ArgumentError unless index.is_a?(Integer)
- self.class.new(@addr + index * @sizeof)
- end
-
- # Pointer diff
- def -(union)
- raise ArgumentError if self.class != union.class
- (@addr - union.instance_variable_get(:@addr)) / @sizeof
- end
-
- # @param sizeof [Integer]
- # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
- def self.define(sizeof, members)
- Class.new(self) do
- # Return the size of this type
- define_singleton_method(:sizeof) { sizeof }
-
- # Part of Struct's offsetof implementation
- define_singleton_method(:offsetof) do |field, *fields|
- member = members.fetch(field)
- offset = 0
- unless fields.empty?
- offset += member.offsetof(*fields)
- end
- offset
- end
-
- define_method(:initialize) do |addr|
- super(addr, sizeof, members)
- end
-
- members.each do |member, type|
- # Intelligent API that does automatic dereference
- define_method(member) do
- value = type.new(@addr)
- if value.respond_to?(:*)
- value = value.*
- end
- value
- end
- end
- end
- end
- end
-
- class Immediate
- # @param addr [Integer]
- # @param size [Integer]
- # @param pack [String]
- def initialize(addr, size, pack)
- @addr = addr
- @size = size
- @pack = pack
- end
-
- # Get a raw address
- def to_i
- @addr
- end
-
- # Move addr to addess this pointer like an array
- def +(index)
- Immediate.new(@addr + index * @size, @size, @pack)
- end
-
- # Dereference
- def *
- self[0]
- end
-
- # Array access
- def [](index)
- return nil if @addr == 0
- Fiddle::Pointer.new(@addr + index * @size)[0, @size].unpack1(@pack)
- end
-
- # Array set
- def []=(index, value)
- Fiddle::Pointer.new(@addr + index * @size)[0, @size] = [value].pack(@pack)
- end
-
- # Serialized address for generated code. Used for embedding things like body->iseq_encoded.
- def to_s
- "0x#{Integer(@addr).to_s(16)}"
- end
-
- # @param fiddle_type [Integer] Fiddle::TYPE_*
- def self.define(fiddle_type)
- size = Fiddle::PackInfo::SIZE_MAP.fetch(fiddle_type)
- pack = Fiddle::PackInfo::PACK_MAP.fetch(fiddle_type)
-
- Class.new(self) do
- define_method(:initialize) do |addr|
- super(addr, size, pack)
- end
-
- define_singleton_method(:size) do
- size
- end
-
- # Type-level []=: Used by struct fields
- define_singleton_method(:[]=) do |addr, value|
- Fiddle::Pointer.new(addr)[0, size] = [value].pack(pack)
- end
- end
- end
- end
-
- # -Fiddle::TYPE_CHAR Immediate with special handling of true/false
- class Bool < Immediate.define(-Fiddle::TYPE_CHAR)
- # Dereference
- def *
- return nil if @addr == 0
- super != 0
- end
-
- def self.[]=(addr, value)
- super(addr, value ? 1 : 0)
- end
- end
-
- class Pointer
- attr_reader :type
-
- # @param addr [Integer]
- # @param type [Class] RubyVM::RJIT::CType::*
- def initialize(addr, type)
- @addr = addr
- @type = type
- end
-
- # Move addr to addess this pointer like an array
- def +(index)
- raise ArgumentError unless index.is_a?(Integer)
- Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP, @type)
- end
-
- # Dereference
- def *
- return nil if dest_addr == 0
- @type.new(dest_addr)
- end
-
- # Array access
- def [](index)
- (self + index).*
- end
-
- # Array set
- # @param index [Integer]
- # @param value [Integer, RubyVM::RJIT::CPointer::Struct] an address itself or an object that return an address with to_i
- def []=(index, value)
- Fiddle::Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP)[0, Fiddle::SIZEOF_VOIDP] =
- [value.to_i].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])
- end
-
- # Get a raw address
- def to_i
- @addr
- end
-
- private
-
- def dest_addr
- Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_VOIDP].unpack1(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])
- end
-
- def self.define(block)
- Class.new(self) do
- define_method(:initialize) do |addr|
- super(addr, block.call)
- end
-
- # Type-level []=: Used by struct fields
- # @param addr [Integer]
- # @param value [Integer, RubyVM::RJIT::CPointer::Struct] an address itself, or an object that return an address with to_i
- define_singleton_method(:[]=) do |addr, value|
- value = value.to_i
- Fiddle::Pointer.new(addr)[0, Fiddle::SIZEOF_VOIDP] = [value].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])
- end
- end
- end
- end
-
- class BitField
- # @param addr [Integer]
- # @param width [Integer]
- # @param offset [Integer]
- def initialize(addr, width, offset)
- @addr = addr
- @width = width
- @offset = offset
- end
-
- # Dereference
- def *
- byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first
- if @width == 1
- bit = (1 & (byte >> @offset))
- bit == 1
- elsif @width <= 8 && @offset == 0
- bitmask = @width.times.map { |i| 1 << i }.sum
- byte & bitmask
- else
- raise NotImplementedError.new("not-implemented bit field access: width=#{@width} offset=#{@offset}")
- end
- end
-
- # @param width [Integer]
- # @param offset [Integer]
- def self.define(width, offset)
- Class.new(self) do
- define_method(:initialize) do |addr|
- super(addr, width, offset)
- end
- end
- end
- end
-
- # Give a name to a dynamic CPointer class to see it on inspect
- def self.with_class_name(prefix, name, cache: false, &block)
- return block.call if name.empty?
-
- # Use a cached result only if cache: true
- class_name = "#{prefix}_#{name}"
- klass =
- if cache && self.const_defined?(class_name)
- self.const_get(class_name)
- else
- block.call
- end
-
- # Give it a name unless it's already defined
- unless self.const_defined?(class_name)
- self.const_set(class_name, klass)
- end
-
- klass
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/c_type.rb b/lib/ruby_vm/rjit/c_type.rb
deleted file mode 100644
index bec7e21c38..0000000000
--- a/lib/ruby_vm/rjit/c_type.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'fiddle'
-require 'fiddle/pack'
-require_relative 'c_pointer'
-
-module RubyVM::RJIT
- module CType
- module Struct
- # @param name [String]
- # @param members [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }]
- def self.new(name, sizeof, **members)
- name = members.keys.join('_') if name.empty?
- CPointer.with_class_name('Struct', name) do
- CPointer::Struct.define(sizeof, members)
- end
- end
- end
-
- module Union
- # @param name [String]
- # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
- def self.new(name, sizeof, **members)
- name = members.keys.join('_') if name.empty?
- CPointer.with_class_name('Union', name) do
- CPointer::Union.define(sizeof, members)
- end
- end
- end
-
- module Immediate
- # @param fiddle_type [Integer]
- def self.new(fiddle_type)
- name = Fiddle.constants.find do |const|
- const.start_with?('TYPE_') && Fiddle.const_get(const) == fiddle_type.abs
- end&.to_s
- name.delete_prefix!('TYPE_')
- if fiddle_type.negative?
- name.prepend('U')
- end
- CPointer.with_class_name('Immediate', name, cache: true) do
- CPointer::Immediate.define(fiddle_type)
- end
- end
-
- # @param type [String]
- def self.parse(ctype)
- new(Fiddle::Importer.parse_ctype(ctype))
- end
-
- def self.find(size, signed)
- fiddle_type = TYPE_MAP.fetch(size)
- fiddle_type = -fiddle_type unless signed
- new(fiddle_type)
- end
-
- TYPE_MAP = Fiddle::PackInfo::SIZE_MAP.map { |type, size| [size, type.abs] }.to_h
- private_constant :TYPE_MAP
- end
-
- module Bool
- def self.new
- CPointer::Bool
- end
- end
-
- class Pointer
- # This takes a block to avoid "stack level too deep" on a cyclic reference
- # @param block [Proc]
- def self.new(&block)
- CPointer.with_class_name('Pointer', block.object_id.to_s) do
- CPointer::Pointer.define(block)
- end
- end
- end
-
- module BitField
- # @param width [Integer]
- # @param offset [Integer]
- def self.new(width, offset)
- CPointer.with_class_name('BitField', "#{offset}_#{width}") do
- CPointer::BitField.define(width, offset)
- end
- end
- end
-
- # Types that are referenced but not part of code generation targets
- Stub = ::Struct.new(:name)
-
- # Types that it failed to figure out from the header
- Unknown = Module.new
- end
-end
diff --git a/lib/ruby_vm/rjit/code_block.rb b/lib/ruby_vm/rjit/code_block.rb
deleted file mode 100644
index 6260ec8b4b..0000000000
--- a/lib/ruby_vm/rjit/code_block.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-module RubyVM::RJIT
- class CodeBlock
- # @param mem_block [Integer] JIT buffer address
- # @param mem_size [Integer] JIT buffer size
- # @param outliend [TrueClass,FalseClass] true for outlined CodeBlock
- def initialize(mem_block:, mem_size:, outlined: false)
- @comments = Hash.new { |h, k| h[k] = [] }
- @mem_block = mem_block
- @mem_size = mem_size
- @write_pos = 0
- @outlined = outlined
- end
-
- # @param asm [RubyVM::RJIT::Assembler]
- def write(asm)
- return 0 if @write_pos + asm.size >= @mem_size
-
- start_addr = write_addr
-
- # Write machine code
- C.mprotect_write(@mem_block, @mem_size)
- @write_pos += asm.assemble(start_addr)
- C.mprotect_exec(@mem_block, @mem_size)
-
- end_addr = write_addr
-
- # Convert comment indexes to addresses
- asm.comments.each do |index, comments|
- @comments[start_addr + index] += comments
- end
- asm.comments.clear
-
- # Dump disasm if --rjit-dump-disasm
- if C.rjit_opts.dump_disasm && start_addr < end_addr
- dump_disasm(start_addr, end_addr)
- end
- start_addr
- end
-
- def set_write_addr(addr)
- @write_pos = addr - @mem_block
- @comments.delete(addr) # TODO: clean up old comments for all the overwritten range?
- end
-
- def with_write_addr(addr)
- old_write_pos = @write_pos
- set_write_addr(addr)
- yield
- ensure
- @write_pos = old_write_pos
- end
-
- def write_addr
- @mem_block + @write_pos
- end
-
- def include?(addr)
- (@mem_block...(@mem_block + @mem_size)).include?(addr)
- end
-
- def dump_disasm(from, to, io: STDOUT, color: true, test: false)
- C.dump_disasm(from, to, test:).each do |address, mnemonic, op_str|
- @comments.fetch(address, []).each do |comment|
- io.puts colorize(" # #{comment}", bold: true, color:)
- end
- io.puts colorize(" 0x#{format("%x", address)}: #{mnemonic} #{op_str}", color:)
- end
- io.puts
- end
-
- private
-
- def colorize(text, bold: false, color:)
- return text unless color
- buf = +''
- buf << "\e[1m" if bold
- buf << "\e[34m" if @outlined
- buf << text
- buf << "\e[0m"
- buf
- end
-
- def bold(text)
- "\e[1m#{text}\e[0m"
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/compiler.rb b/lib/ruby_vm/rjit/compiler.rb
deleted file mode 100644
index 357fe7d734..0000000000
--- a/lib/ruby_vm/rjit/compiler.rb
+++ /dev/null
@@ -1,330 +0,0 @@
-require 'ruby_vm/rjit/assembler'
-require 'ruby_vm/rjit/block'
-require 'ruby_vm/rjit/branch_stub'
-require 'ruby_vm/rjit/code_block'
-require 'ruby_vm/rjit/context'
-require 'ruby_vm/rjit/exit_compiler'
-require 'ruby_vm/rjit/insn_compiler'
-require 'ruby_vm/rjit/instruction'
-require 'ruby_vm/rjit/invariants'
-require 'ruby_vm/rjit/jit_state'
-
-module RubyVM::RJIT
- # Compilation status
- KeepCompiling = :KeepCompiling
- CantCompile = :CantCompile
- EndBlock = :EndBlock
-
- # Ruby constants
- Qtrue = Fiddle::Qtrue
- Qfalse = Fiddle::Qfalse
- Qnil = Fiddle::Qnil
- Qundef = Fiddle::Qundef
-
- # Callee-saved registers
- # TODO: support using r12/r13 here
- EC = :r14
- CFP = :r15
- SP = :rbx
-
- # Scratch registers: rax, rcx
-
- # Mark objects in this Array during GC
- GC_REFS = []
-
- class Compiler
- attr_accessor :write_pos
-
- def self.decode_insn(encoded)
- INSNS.fetch(C.rb_vm_insn_decode(encoded))
- end
-
- def initialize
- mem_size = C.rjit_opts.exec_mem_size * 1024 * 1024
- mem_block = C.mmap(mem_size)
- @cb = CodeBlock.new(mem_block: mem_block, mem_size: mem_size / 2)
- @ocb = CodeBlock.new(mem_block: mem_block + mem_size / 2, mem_size: mem_size / 2, outlined: true)
- @exit_compiler = ExitCompiler.new
- @insn_compiler = InsnCompiler.new(@cb, @ocb, @exit_compiler)
- Invariants.initialize(@cb, @ocb, self, @exit_compiler)
- end
-
- # Compile an ISEQ from its entry point.
- # @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
- # @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
- def compile(iseq, cfp)
- # TODO: Support has_opt
- return if iseq.body.param.flags.has_opt
-
- jit = JITState.new(iseq:, cfp:)
- asm = Assembler.new
- asm.comment("Block: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq.body.location.first_lineno}")
- compile_prologue(asm)
- compile_block(asm, jit:)
- iseq.body.jit_func = @cb.write(asm)
- rescue Exception => e
- $stderr.puts e.full_message
- exit 1
- end
-
- # Compile a branch stub.
- # @param branch_stub [RubyVM::RJIT::BranchStub]
- # @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
- # @param target0_p [TrueClass,FalseClass]
- # @return [Integer] The starting address of the compiled branch stub
- def branch_stub_hit(branch_stub, cfp, target0_p)
- # Update cfp->pc for `jit.at_current_insn?`
- target = target0_p ? branch_stub.target0 : branch_stub.target1
- cfp.pc = target.pc
-
- # Reuse an existing block if it already exists
- block = find_block(branch_stub.iseq, target.pc, target.ctx)
-
- # If the branch stub's jump is the last code, allow overwriting part of
- # the old branch code with the new block code.
- fallthrough = block.nil? && @cb.write_addr == branch_stub.end_addr
- if fallthrough
- # If the branch stub's jump is the last code, allow overwriting part of
- # the old branch code with the new block code.
- @cb.set_write_addr(branch_stub.start_addr)
- branch_stub.shape = target0_p ? Next0 : Next1
- Assembler.new.tap do |branch_asm|
- branch_stub.compile.call(branch_asm)
- @cb.write(branch_asm)
- end
- end
-
- # Reuse or generate a block
- if block
- target.address = block.start_addr
- else
- jit = JITState.new(iseq: branch_stub.iseq, cfp:)
- target.address = Assembler.new.then do |asm|
- compile_block(asm, jit:, pc: target.pc, ctx: target.ctx.dup)
- @cb.write(asm)
- end
- block = jit.block
- end
- block.incoming << branch_stub # prepare for invalidate_block
-
- # Re-generate the branch code for non-fallthrough cases
- unless fallthrough
- @cb.with_write_addr(branch_stub.start_addr) do
- branch_asm = Assembler.new
- branch_stub.compile.call(branch_asm)
- @cb.write(branch_asm)
- end
- end
-
- return target.address
- rescue Exception => e
- $stderr.puts e.full_message
- exit 1
- end
-
- # @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
- # @param pc [Integer]
- def invalidate_blocks(iseq, pc)
- list_blocks(iseq, pc).each do |block|
- invalidate_block(block)
- end
-
- # If they were the ISEQ's first blocks, re-compile RJIT entry as well
- if iseq.body.iseq_encoded.to_i == pc
- iseq.body.jit_func = 0
- iseq.body.total_calls = 0
- end
- end
-
- def invalidate_block(block)
- iseq = block.iseq
- # Avoid touching GCed ISEQs. We assume it won't be re-entered.
- return unless C.imemo_type_p(iseq, C.imemo_iseq)
-
- # Remove this block from the version array
- remove_block(iseq, block)
-
- # Invalidate the block with entry exit
- unless block.invalidated
- @cb.with_write_addr(block.start_addr) do
- asm = Assembler.new
- asm.comment('invalidate_block')
- asm.jmp(block.entry_exit)
- @cb.write(asm)
- end
- block.invalidated = true
- end
-
- # Re-stub incoming branches
- block.incoming.each do |branch_stub|
- target = [branch_stub.target0, branch_stub.target1].compact.find do |target|
- target.pc == block.pc && target.ctx == block.ctx
- end
- next if target.nil?
- # TODO: Could target.address be a stub address? Is invalidation not needed in that case?
-
- # If the target being re-generated is currently a fallthrough block,
- # the fallthrough code must be rewritten with a jump to the stub.
- if target.address == branch_stub.end_addr
- branch_stub.shape = Default
- end
-
- target.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(block.ctx, ocb_asm, branch_stub, target == branch_stub.target0)
- @ocb.write(ocb_asm)
- end
- @cb.with_write_addr(branch_stub.start_addr) do
- branch_asm = Assembler.new
- branch_stub.compile.call(branch_asm)
- @cb.write(branch_asm)
- end
- end
- end
-
- private
-
- # Callee-saved: rbx, rsp, rbp, r12, r13, r14, r15
- # Caller-saved: rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11
- #
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_prologue(asm)
- asm.comment('RJIT entry point')
-
- # Save callee-saved registers used by JITed code
- asm.push(CFP)
- asm.push(EC)
- asm.push(SP)
-
- # Move arguments EC and CFP to dedicated registers
- asm.mov(EC, :rdi)
- asm.mov(CFP, :rsi)
-
- # Load sp to a dedicated register
- asm.mov(SP, [CFP, C.rb_control_frame_t.offsetof(:sp)]) # rbx = cfp->sp
-
- # Setup cfp->jit_return
- asm.mov(:rax, leave_exit)
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:jit_return)], :rax)
- end
-
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_block(asm, jit:, pc: jit.iseq.body.iseq_encoded.to_i, ctx: Context.new)
- # Mark the block start address and prepare an exit code storage
- block = Block.new(iseq: jit.iseq, pc:, ctx: ctx.dup)
- jit.block = block
- asm.block(block)
-
- # Compile each insn
- iseq = jit.iseq
- index = (pc - iseq.body.iseq_encoded.to_i) / C.VALUE.size
- while index < iseq.body.iseq_size
- insn = self.class.decode_insn(iseq.body.iseq_encoded[index])
- jit.pc = (iseq.body.iseq_encoded + index).to_i
-
- # If previous instruction requested to record the boundary
- if jit.record_boundary_patch_point
- # Generate an exit to this instruction and record it
- exit_pos = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_side_exit(jit.pc, ctx, ocb_asm)
- @ocb.write(ocb_asm)
- end
- Invariants.record_global_inval_patch(asm, exit_pos)
- jit.record_boundary_patch_point = false
- end
-
- case status = @insn_compiler.compile(jit, ctx, asm, insn)
- when KeepCompiling
- # For now, reset the chain depth after each instruction as only the
- # first instruction in the block can concern itself with the depth.
- ctx.chain_depth = 0
-
- index += insn.len
- when EndBlock
- # TODO: pad nops if entry exit exists (not needed for x86_64?)
- break
- when CantCompile
- @exit_compiler.compile_side_exit(jit.pc, ctx, asm)
-
- # If this is the first instruction, this block never needs to be invalidated.
- if block.pc == iseq.body.iseq_encoded.to_i + index * C.VALUE.size
- block.invalidated = true
- end
-
- break
- else
- raise "compiling #{insn.name} returned unexpected status: #{status.inspect}"
- end
- end
-
- incr_counter(:compiled_block_count)
- add_block(iseq, block)
- end
-
- def leave_exit
- @leave_exit ||= Assembler.new.then do |asm|
- @exit_compiler.compile_leave_exit(asm)
- @ocb.write(asm)
- end
- end
-
- def incr_counter(name)
- if C.rjit_opts.stats
- C.rb_rjit_counters[name][0] += 1
- end
- end
-
- def list_blocks(iseq, pc)
- rjit_blocks(iseq)[pc]
- end
-
- # @param [Integer] pc
- # @param [RubyVM::RJIT::Context] ctx
- # @return [RubyVM::RJIT::Block,NilClass]
- def find_block(iseq, pc, ctx)
- src = ctx
- rjit_blocks(iseq)[pc].find do |block|
- dst = block.ctx
-
- # Can only lookup the first version in the chain
- if dst.chain_depth != 0
- next false
- end
-
- # Blocks with depth > 0 always produce new versions
- # Sidechains cannot overlap
- if src.chain_depth != 0
- next false
- end
-
- src.stack_size == dst.stack_size &&
- src.sp_offset == dst.sp_offset
- end
- end
-
- # @param [RubyVM::RJIT::Block] block
- def add_block(iseq, block)
- rjit_blocks(iseq)[block.pc] << block
- end
-
- # @param [RubyVM::RJIT::Block] block
- def remove_block(iseq, block)
- rjit_blocks(iseq)[block.pc].delete(block)
- end
-
- def rjit_blocks(iseq)
- # Guard against ISEQ GC at random moments
-
- unless C.imemo_type_p(iseq, C.imemo_iseq)
- return Hash.new { |h, k| h[k] = [] }
- end
-
- unless iseq.body.rjit_blocks
- iseq.body.rjit_blocks = Hash.new { |blocks, pc| blocks[pc] = [] }
- # For some reason, rb_rjit_iseq_mark didn't protect this Hash
- # from being freed. So we rely on GC_REFS to keep the Hash.
- GC_REFS << iseq.body.rjit_blocks
- end
- iseq.body.rjit_blocks
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/context.rb b/lib/ruby_vm/rjit/context.rb
deleted file mode 100644
index 746f29b8fb..0000000000
--- a/lib/ruby_vm/rjit/context.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module RubyVM::RJIT
- class Context < Struct.new(
- :stack_size, # @param [Integer] The number of values on the stack
- :sp_offset, # @param [Integer] JIT sp offset relative to the interpreter's sp
- :chain_depth, # @param [Integer] jit_chain_guard depth
- )
- def initialize(stack_size: 0, sp_offset: 0, chain_depth: 0) = super
-
- def stack_push(size = 1)
- self.stack_size += size
- self.sp_offset += size
- stack_opnd(0)
- end
-
- def stack_pop(size = 1)
- opnd = stack_opnd(0)
- self.stack_size -= size
- self.sp_offset -= size
- opnd
- end
-
- def stack_opnd(depth_from_top)
- [SP, C.VALUE.size * (self.sp_offset - 1 - depth_from_top)]
- end
-
- def sp_opnd(offset_bytes = 0)
- [SP, (C.VALUE.size * self.sp_offset) + offset_bytes]
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/exit_compiler.rb b/lib/ruby_vm/rjit/exit_compiler.rb
deleted file mode 100644
index b7beb22177..0000000000
--- a/lib/ruby_vm/rjit/exit_compiler.rb
+++ /dev/null
@@ -1,152 +0,0 @@
-module RubyVM::RJIT
- class ExitCompiler
- def initialize = freeze
-
- # Used for invalidating a block on entry.
- # @param pc [Integer]
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_entry_exit(pc, ctx, asm, cause:)
- # Fix pc/sp offsets for the interpreter
- save_pc_and_sp(pc, ctx, asm, reset_sp_offset: false)
-
- # Increment per-insn exit counter
- count_insn_exit(pc, asm)
-
- # Restore callee-saved registers
- asm.comment("#{cause}: entry exit")
- asm.pop(SP)
- asm.pop(EC)
- asm.pop(CFP)
-
- asm.mov(C_RET, Qundef)
- asm.ret
- end
-
- # Set to cfp->jit_return by default for leave insn
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_leave_exit(asm)
- asm.comment('default cfp->jit_return')
-
- # Restore callee-saved registers
- asm.pop(SP)
- asm.pop(EC)
- asm.pop(CFP)
-
- # :rax is written by #leave
- asm.ret
- end
-
- # Fire cfunc events on invalidation by TracePoint
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_full_cfunc_return(asm)
- # This chunk of code expects REG_EC to be filled properly and
- # RAX to contain the return value of the C method.
-
- asm.comment('full cfunc return')
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], :rax)
- asm.call(C.rjit_full_cfunc_return)
-
- # TODO: count the exit
-
- # Restore callee-saved registers
- asm.pop(SP)
- asm.pop(EC)
- asm.pop(CFP)
-
- asm.mov(C_RET, Qundef)
- asm.ret
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def compile_side_exit(pc, ctx, asm)
- # Fix pc/sp offsets for the interpreter
- save_pc_and_sp(pc, ctx.dup, asm) # dup to avoid sp_offset update
-
- # Increment per-insn exit counter
- count_insn_exit(pc, asm)
-
- # Restore callee-saved registers
- asm.comment("exit to interpreter on #{pc_to_insn(pc).name}")
- asm.pop(SP)
- asm.pop(EC)
- asm.pop(CFP)
-
- asm.mov(C_RET, Qundef)
- asm.ret
- end
-
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- # @param branch_stub [RubyVM::RJIT::BranchStub]
- # @param target0_p [TrueClass,FalseClass]
- def compile_branch_stub(ctx, asm, branch_stub, target0_p)
- # Call rb_rjit_branch_stub_hit
- iseq = branch_stub.iseq
- if C.rjit_opts.dump_disasm && C.imemo_type_p(iseq, C.imemo_iseq) # Guard against ISEQ GC at random moments
- asm.comment("branch stub hit: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq_lineno(iseq, target0_p ? branch_stub.target0.pc : branch_stub.target1.pc)}")
- end
- asm.mov(:rdi, to_value(branch_stub))
- asm.mov(:esi, ctx.sp_offset)
- asm.mov(:edx, target0_p ? 1 : 0)
- asm.call(C.rb_rjit_branch_stub_hit)
-
- # Jump to the address returned by rb_rjit_stub_hit
- asm.jmp(:rax)
- end
-
- private
-
- def pc_to_insn(pc)
- Compiler.decode_insn(C.VALUE.new(pc).*)
- end
-
- # @param pc [Integer]
- # @param asm [RubyVM::RJIT::Assembler]
- def count_insn_exit(pc, asm)
- if C.rjit_opts.stats
- insn = Compiler.decode_insn(C.VALUE.new(pc).*)
- asm.comment("increment insn exit: #{insn.name}")
- asm.mov(:rax, (C.rjit_insn_exits + insn.bin).to_i)
- asm.add([:rax], 1) # TODO: lock
- end
- if C.rjit_opts.trace_exits
- asm.comment('rjit_record_exit_stack')
- asm.mov(C_ARGS[0], pc)
- asm.call(C.rjit_record_exit_stack)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def save_pc_and_sp(pc, ctx, asm, reset_sp_offset: true)
- # Update pc (TODO: manage PC offset?)
- asm.comment("save PC#{' and SP' if ctx.sp_offset != 0} to CFP")
- asm.mov(:rax, pc) # rax = jit.pc
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:pc)], :rax) # cfp->pc = rax
-
- # Update sp
- if ctx.sp_offset != 0
- asm.add(SP, C.VALUE.size * ctx.sp_offset) # sp += stack_size
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:sp)], SP) # cfp->sp = sp
- if reset_sp_offset
- ctx.sp_offset = 0
- end
- end
- end
-
- def to_value(obj)
- GC_REFS << obj
- C.to_value(obj)
- end
-
- def iseq_lineno(iseq, pc)
- C.rb_iseq_line_no(iseq, (pc - iseq.body.iseq_encoded.to_i) / C.VALUE.size)
- rescue RangeError # bignum too big to convert into `unsigned long long' (RangeError)
- -1
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/hooks.rb b/lib/ruby_vm/rjit/hooks.rb
deleted file mode 100644
index ea9d7bf5a8..0000000000
--- a/lib/ruby_vm/rjit/hooks.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-module RubyVM::RJIT
- module Hooks # :nodoc: all
- def self.on_bop_redefined(_redefined_flag, _bop)
- # C.rjit_cancel_all("BOP is redefined")
- end
-
- def self.on_cme_invalidate(cme)
- cme = C.rb_callable_method_entry_struct.new(cme)
- Invariants.on_cme_invalidate(cme)
- end
-
- def self.on_ractor_spawn
- # C.rjit_cancel_all("Ractor is spawned")
- end
-
- # Global constant changes like const_set
- def self.on_constant_state_changed(id)
- Invariants.on_constant_state_changed(id)
- end
-
- # ISEQ-specific constant invalidation
- def self.on_constant_ic_update(iseq, ic, insn_idx)
- iseq = C.rb_iseq_t.new(iseq)
- ic = C.IC.new(ic)
- Invariants.on_constant_ic_update(iseq, ic, insn_idx)
- end
-
- def self.on_tracing_invalidate_all(_new_iseq_events)
- Invariants.on_tracing_invalidate_all
- end
-
- def self.on_update_references
- Invariants.on_update_references
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb
deleted file mode 100644
index bcff9e4525..0000000000
--- a/lib/ruby_vm/rjit/insn_compiler.rb
+++ /dev/null
@@ -1,4051 +0,0 @@
-module RubyVM::RJIT
- class InsnCompiler
- # @param ocb [CodeBlock]
- # @param exit_compiler [RubyVM::RJIT::ExitCompiler]
- def initialize(cb, ocb, exit_compiler)
- @ocb = ocb
- @exit_compiler = exit_compiler
-
- @cfunc_codegen_table = {}
- register_cfunc_codegen_funcs
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- # @param insn `RubyVM::RJIT::Instruction`
- def compile(jit, ctx, asm, insn)
- asm.incr_counter(:rjit_insns_count)
- asm.comment("Insn: #{insn.name}")
-
- # 74/102
- case insn.name
- when :nop then nop(jit, ctx, asm)
- when :getlocal then getlocal(jit, ctx, asm)
- when :setlocal then setlocal(jit, ctx, asm)
- when :getblockparam then getblockparam(jit, ctx, asm)
- # setblockparam
- when :getblockparamproxy then getblockparamproxy(jit, ctx, asm)
- # getspecial
- # setspecial
- when :getinstancevariable then getinstancevariable(jit, ctx, asm)
- when :setinstancevariable then setinstancevariable(jit, ctx, asm)
- when :getclassvariable then getclassvariable(jit, ctx, asm)
- # setclassvariable
- when :opt_getconstant_path then opt_getconstant_path(jit, ctx, asm)
- when :getconstant then getconstant(jit, ctx, asm)
- # setconstant
- # getglobal
- # setglobal
- when :putnil then putnil(jit, ctx, asm)
- when :putself then putself(jit, ctx, asm)
- when :putobject then putobject(jit, ctx, asm)
- # putspecialobject
- when :putstring then putstring(jit, ctx, asm)
- when :concatstrings then concatstrings(jit, ctx, asm)
- when :anytostring then anytostring(jit, ctx, asm)
- # toregexp
- # intern
- when :newarray then newarray(jit, ctx, asm)
- # newarraykwsplat
- when :duparray then duparray(jit, ctx, asm)
- # duphash
- when :expandarray then expandarray(jit, ctx, asm)
- when :concatarray then concatarray(jit, ctx, asm)
- when :splatarray then splatarray(jit, ctx, asm)
- when :newhash then newhash(jit, ctx, asm)
- # newrange
- when :pop then pop(jit, ctx, asm)
- when :dup then dup(jit, ctx, asm)
- when :dupn then dupn(jit, ctx, asm)
- when :swap then swap(jit, ctx, asm)
- # opt_reverse
- when :topn then topn(jit, ctx, asm)
- when :setn then setn(jit, ctx, asm)
- when :adjuststack then adjuststack(jit, ctx, asm)
- when :defined then defined(jit, ctx, asm)
- when :definedivar then definedivar(jit, ctx, asm)
- # checkmatch
- # checkkeyword
- # checktype
- # defineclass
- # definemethod
- # definesmethod
- when :send then send(jit, ctx, asm)
- when :opt_send_without_block then opt_send_without_block(jit, ctx, asm)
- when :objtostring then objtostring(jit, ctx, asm)
- when :opt_str_freeze then opt_str_freeze(jit, ctx, asm)
- when :opt_nil_p then opt_nil_p(jit, ctx, asm)
- # opt_str_uminus
- # opt_newarray_max
- when :opt_newarray_min then opt_newarray_min(jit, ctx, asm)
- when :invokesuper then invokesuper(jit, ctx, asm)
- when :invokeblock then invokeblock(jit, ctx, asm)
- when :leave then leave(jit, ctx, asm)
- # throw
- when :jump then jump(jit, ctx, asm)
- when :branchif then branchif(jit, ctx, asm)
- when :branchunless then branchunless(jit, ctx, asm)
- when :branchnil then branchnil(jit, ctx, asm)
- # once
- when :opt_case_dispatch then opt_case_dispatch(jit, ctx, asm)
- when :opt_plus then opt_plus(jit, ctx, asm)
- when :opt_minus then opt_minus(jit, ctx, asm)
- when :opt_mult then opt_mult(jit, ctx, asm)
- when :opt_div then opt_div(jit, ctx, asm)
- when :opt_mod then opt_mod(jit, ctx, asm)
- when :opt_eq then opt_eq(jit, ctx, asm)
- when :opt_neq then opt_neq(jit, ctx, asm)
- when :opt_lt then opt_lt(jit, ctx, asm)
- when :opt_le then opt_le(jit, ctx, asm)
- when :opt_gt then opt_gt(jit, ctx, asm)
- when :opt_ge then opt_ge(jit, ctx, asm)
- when :opt_ltlt then opt_ltlt(jit, ctx, asm)
- when :opt_and then opt_and(jit, ctx, asm)
- when :opt_or then opt_or(jit, ctx, asm)
- when :opt_aref then opt_aref(jit, ctx, asm)
- when :opt_aset then opt_aset(jit, ctx, asm)
- # opt_aset_with
- # opt_aref_with
- when :opt_length then opt_length(jit, ctx, asm)
- when :opt_size then opt_size(jit, ctx, asm)
- when :opt_empty_p then opt_empty_p(jit, ctx, asm)
- when :opt_succ then opt_succ(jit, ctx, asm)
- when :opt_not then opt_not(jit, ctx, asm)
- when :opt_regexpmatch2 then opt_regexpmatch2(jit, ctx, asm)
- # invokebuiltin
- when :opt_invokebuiltin_delegate then opt_invokebuiltin_delegate(jit, ctx, asm)
- when :opt_invokebuiltin_delegate_leave then opt_invokebuiltin_delegate_leave(jit, ctx, asm)
- when :getlocal_WC_0 then getlocal_WC_0(jit, ctx, asm)
- when :getlocal_WC_1 then getlocal_WC_1(jit, ctx, asm)
- when :setlocal_WC_0 then setlocal_WC_0(jit, ctx, asm)
- when :setlocal_WC_1 then setlocal_WC_1(jit, ctx, asm)
- when :putobject_INT2FIX_0_ then putobject_INT2FIX_0_(jit, ctx, asm)
- when :putobject_INT2FIX_1_ then putobject_INT2FIX_1_(jit, ctx, asm)
- else CantCompile
- end
- end
-
- private
-
- #
- # Insns
- #
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def nop(jit, ctx, asm)
- # Do nothing
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getlocal(jit, ctx, asm)
- idx = jit.operand(0)
- level = jit.operand(1)
- jit_getlocal_generic(jit, ctx, asm, idx:, level:)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def setlocal(jit, ctx, asm)
- idx = jit.operand(0)
- level = jit.operand(1)
- jit_setlocal_generic(jit, ctx, asm, idx:, level:)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getblockparam(jit, ctx, asm)
- # EP level
- level = jit.operand(1)
-
- # Save the PC and SP because we might allocate
- jit_prepare_routine_call(jit, ctx, asm)
-
- # A mirror of the interpreter code. Checking for the case
- # where it's pushing rb_block_param_proxy.
- side_exit = side_exit(jit, ctx)
-
- # Load environment pointer EP from CFP
- ep_reg = :rax
- jit_get_ep(asm, level, reg: ep_reg)
-
- # Bail when VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM) is non zero
- # FIXME: This is testing bits in the same place that the WB check is testing.
- # We should combine these at some point
- asm.test([ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS], C::VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)
-
- # If the frame flag has been modified, then the actual proc value is
- # already in the EP and we should just use the value.
- frame_flag_modified = asm.new_label('frame_flag_modified')
- asm.jnz(frame_flag_modified)
-
- # This instruction writes the block handler to the EP. If we need to
- # fire a write barrier for the write, then exit (we'll let the
- # interpreter handle it so it can fire the write barrier).
- # flags & VM_ENV_FLAG_WB_REQUIRED
- asm.test([ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS], C::VM_ENV_FLAG_WB_REQUIRED)
-
- # if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
- asm.jnz(side_exit)
-
- # Convert the block handler in to a proc
- # call rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler)
- asm.mov(C_ARGS[0], EC)
- # The block handler for the current frame
- # note, VM_ASSERT(VM_ENV_LOCAL_P(ep))
- asm.mov(C_ARGS[1], [ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_SPECVAL])
- asm.call(C.rb_vm_bh_to_procval)
-
- # Load environment pointer EP from CFP (again)
- ep_reg = :rcx
- jit_get_ep(asm, level, reg: ep_reg)
-
- # Write the value at the environment pointer
- idx = jit.operand(0)
- offs = -(C.VALUE.size * idx)
- asm.mov([ep_reg, offs], C_RET);
-
- # Set the frame modified flag
- asm.mov(:rax, [ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS]) # flag_check
- asm.or(:rax, C::VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM) # modified_flag
- asm.mov([ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS], :rax)
-
- asm.write_label(frame_flag_modified)
-
- # Push the proc on the stack
- stack_ret = ctx.stack_push
- ep_reg = :rax
- jit_get_ep(asm, level, reg: ep_reg)
- asm.mov(:rax, [ep_reg, offs])
- asm.mov(stack_ret, :rax)
-
- KeepCompiling
- end
-
- # setblockparam
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getblockparamproxy(jit, ctx, asm)
- # To get block_handler
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- starting_context = ctx.dup # make a copy for use with jit_chain_guard
-
- # A mirror of the interpreter code. Checking for the case
- # where it's pushing rb_block_param_proxy.
- side_exit = side_exit(jit, ctx)
-
- # EP level
- level = jit.operand(1)
-
- # Peek at the block handler so we can check whether it's nil
- comptime_handler = jit.peek_at_block_handler(level)
-
- # When a block handler is present, it should always be a GC-guarded
- # pointer (VM_BH_ISEQ_BLOCK_P)
- if comptime_handler != 0 && comptime_handler & 0x3 != 0x1
- asm.incr_counter(:getblockpp_not_gc_guarded)
- return CantCompile
- end
-
- # Load environment pointer EP from CFP
- ep_reg = :rax
- jit_get_ep(asm, level, reg: ep_reg)
-
- # Bail when VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM) is non zero
- asm.test([ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS], C::VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)
- asm.jnz(counted_exit(side_exit, :getblockpp_block_param_modified))
-
- # Load the block handler for the current frame
- # note, VM_ASSERT(VM_ENV_LOCAL_P(ep))
- block_handler = :rax
- asm.mov(block_handler, [ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_SPECVAL])
-
- # Specialize compilation for the case where no block handler is present
- if comptime_handler == 0
- # Bail if there is a block handler
- asm.cmp(block_handler, 0)
-
- jit_chain_guard(:jnz, jit, starting_context, asm, counted_exit(side_exit, :getblockpp_block_handler_none))
-
- putobject(jit, ctx, asm, val: Qnil)
- else
- # Block handler is a tagged pointer. Look at the tag. 0x03 is from VM_BH_ISEQ_BLOCK_P().
- asm.and(block_handler, 0x3)
-
- # Bail unless VM_BH_ISEQ_BLOCK_P(bh). This also checks for null.
- asm.cmp(block_handler, 0x1)
-
- jit_chain_guard(:jnz, jit, starting_context, asm, counted_exit(side_exit, :getblockpp_not_iseq_block))
-
- # Push rb_block_param_proxy. It's a root, so no need to use jit_mov_gc_ptr.
- top = ctx.stack_push
- asm.mov(:rax, C.rb_block_param_proxy)
- asm.mov(top, :rax)
- end
-
- jump_to_next_insn(jit, ctx, asm)
-
- EndBlock
- end
-
- # getspecial
- # setspecial
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getinstancevariable(jit, ctx, asm)
- # Specialize on a compile-time receiver, and split a block for chain guards
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- id = jit.operand(0)
- comptime_obj = jit.peek_at_self
-
- jit_getivar(jit, ctx, asm, comptime_obj, id)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def setinstancevariable(jit, ctx, asm)
- starting_context = ctx.dup # make a copy for use with jit_chain_guard
-
- # Defer compilation so we can specialize on a runtime `self`
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- ivar_name = jit.operand(0)
- comptime_receiver = jit.peek_at_self
-
- # If the comptime receiver is frozen, writing an IV will raise an exception
- # and we don't want to JIT code to deal with that situation.
- if C.rb_obj_frozen_p(comptime_receiver)
- asm.incr_counter(:setivar_frozen)
- return CantCompile
- end
-
- # Check if the comptime receiver is a T_OBJECT
- receiver_t_object = C::BUILTIN_TYPE(comptime_receiver) == C::T_OBJECT
-
- # If the receiver isn't a T_OBJECT, or uses a custom allocator,
- # then just write out the IV write as a function call.
- # too-complex shapes can't use index access, so we use rb_ivar_get for them too.
- if !receiver_t_object || shape_too_complex?(comptime_receiver) || ctx.chain_depth >= 10
- asm.comment('call rb_vm_setinstancevariable')
-
- ic = jit.operand(1)
-
- # The function could raise exceptions.
- # Note that this modifies REG_SP, which is why we do it first
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Get the operands from the stack
- val_opnd = ctx.stack_pop(1)
-
- # Call rb_vm_setinstancevariable(iseq, obj, id, val, ic);
- asm.mov(:rdi, jit.iseq.to_i)
- asm.mov(:rsi, [CFP, C.rb_control_frame_t.offsetof(:self)])
- asm.mov(:rdx, ivar_name)
- asm.mov(:rcx, val_opnd)
- asm.mov(:r8, ic)
- asm.call(C.rb_vm_setinstancevariable)
- else
- # Get the iv index
- shape_id = C.rb_shape_get_shape_id(comptime_receiver)
- ivar_index = C.rb_shape_get_iv_index(shape_id, ivar_name)
-
- # Get the receiver
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)])
-
- # Generate a side exit
- side_exit = side_exit(jit, ctx)
-
- # Upgrade type
- guard_object_is_heap(asm, :rax, counted_exit(side_exit, :setivar_not_heap))
-
- asm.comment('guard shape')
- asm.cmp(DwordPtr[:rax, C.rb_shape_id_offset], shape_id)
- megamorphic_side_exit = counted_exit(side_exit, :setivar_megamorphic)
- jit_chain_guard(:jne, jit, starting_context, asm, megamorphic_side_exit)
-
- # If we don't have an instance variable index, then we need to
- # transition out of the current shape.
- if ivar_index.nil?
- shape = C.rb_shape_get_shape_by_id(shape_id)
-
- current_capacity = shape.capacity
- new_capacity = current_capacity * 2
-
- # If the object doesn't have the capacity to store the IV,
- # then we'll need to allocate it.
- needs_extension = shape.next_iv_index >= current_capacity
-
- # We can write to the object, but we need to transition the shape
- ivar_index = shape.next_iv_index
-
- capa_shape =
- if needs_extension
- # We need to add an extended table to the object
- # First, create an outgoing transition that increases the capacity
- C.rb_shape_transition_shape_capa(shape, new_capacity)
- else
- nil
- end
-
- dest_shape =
- if capa_shape
- C.rb_shape_get_next(capa_shape, comptime_receiver, ivar_name)
- else
- C.rb_shape_get_next(shape, comptime_receiver, ivar_name)
- end
- new_shape_id = C.rb_shape_id(dest_shape)
-
- if new_shape_id == C::OBJ_TOO_COMPLEX_SHAPE_ID
- asm.incr_counter(:setivar_too_complex)
- return CantCompile
- end
-
- if needs_extension
- # Generate the C call so that runtime code will increase
- # the capacity and set the buffer.
- asm.mov(C_ARGS[0], :rax)
- asm.mov(C_ARGS[1], current_capacity)
- asm.mov(C_ARGS[2], new_capacity)
- asm.call(C.rb_ensure_iv_list_size)
-
- # Load the receiver again after the function call
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)])
- end
-
- write_val = ctx.stack_pop(1)
- jit_write_iv(asm, comptime_receiver, :rax, :rcx, ivar_index, write_val, needs_extension)
-
- # Store the new shape
- asm.comment('write shape')
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)]) # reload after jit_write_iv
- asm.mov(DwordPtr[:rax, C.rb_shape_id_offset], new_shape_id)
- else
- # If the iv index already exists, then we don't need to
- # transition to a new shape. The reason is because we find
- # the iv index by searching up the shape tree. If we've
- # made the transition already, then there's no reason to
- # update the shape on the object. Just set the IV.
- write_val = ctx.stack_pop(1)
- jit_write_iv(asm, comptime_receiver, :rax, :rcx, ivar_index, write_val, false)
- end
-
- skip_wb = asm.new_label('skip_wb')
- # If the value we're writing is an immediate, we don't need to WB
- asm.test(write_val, C::RUBY_IMMEDIATE_MASK)
- asm.jnz(skip_wb)
-
- # If the value we're writing is nil or false, we don't need to WB
- asm.cmp(write_val, Qnil)
- asm.jbe(skip_wb)
-
- asm.comment('write barrier')
- asm.mov(C_ARGS[0], [CFP, C.rb_control_frame_t.offsetof(:self)]) # reload after jit_write_iv
- asm.mov(C_ARGS[1], write_val)
- asm.call(C.rb_gc_writebarrier)
-
- asm.write_label(skip_wb)
- end
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getclassvariable(jit, ctx, asm)
- # rb_vm_getclassvariable can raise exceptions.
- jit_prepare_routine_call(jit, ctx, asm)
-
- asm.mov(C_ARGS[0], [CFP, C.rb_control_frame_t.offsetof(:iseq)])
- asm.mov(C_ARGS[1], CFP)
- asm.mov(C_ARGS[2], jit.operand(0))
- asm.mov(C_ARGS[3], jit.operand(1))
- asm.call(C.rb_vm_getclassvariable)
-
- top = ctx.stack_push
- asm.mov(top, C_RET)
-
- KeepCompiling
- end
-
- # setclassvariable
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_getconstant_path(jit, ctx, asm)
- # Cut the block for invalidation
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- ic = C.iseq_inline_constant_cache.new(jit.operand(0))
- idlist = ic.segments
-
- # Make sure there is an exit for this block as the interpreter might want
- # to invalidate this block from rb_rjit_constant_ic_update().
- # For now, we always take an entry exit even if it was a side exit.
- Invariants.ensure_block_entry_exit(jit, cause: 'opt_getconstant_path')
-
- # See vm_ic_hit_p(). The same conditions are checked in yjit_constant_ic_update().
- ice = ic.entry
- if ice.nil?
- # In this case, leave a block that unconditionally side exits
- # for the interpreter to invalidate.
- asm.incr_counter(:optgetconst_not_cached)
- return CantCompile
- end
-
- if ice.ic_cref # with cref
- # Cache is keyed on a certain lexical scope. Use the interpreter's cache.
- side_exit = side_exit(jit, ctx)
-
- # Call function to verify the cache. It doesn't allocate or call methods.
- asm.mov(C_ARGS[0], ic.to_i)
- asm.mov(C_ARGS[1], [CFP, C.rb_control_frame_t.offsetof(:ep)])
- asm.call(C.rb_vm_ic_hit_p)
-
- # Check the result. SysV only specifies one byte for _Bool return values,
- # so it's important we only check one bit to ignore the higher bits in the register.
- asm.test(C_RET, 1)
- asm.jz(counted_exit(side_exit, :optgetconst_cache_miss))
-
- asm.mov(:rax, ic.to_i) # inline_cache
- asm.mov(:rax, [:rax, C.iseq_inline_constant_cache.offsetof(:entry)]) # ic_entry
- asm.mov(:rax, [:rax, C.iseq_inline_constant_cache_entry.offsetof(:value)]) # ic_entry_val
-
- # Push ic->entry->value
- stack_top = ctx.stack_push
- asm.mov(stack_top, :rax)
- else # without cref
- # TODO: implement this
- # Optimize for single ractor mode.
- # if !assume_single_ractor_mode(jit, ocb)
- # return CantCompile
- # end
-
- # Invalidate output code on any constant writes associated with
- # constants referenced within the current block.
- Invariants.assume_stable_constant_names(jit, idlist)
-
- putobject(jit, ctx, asm, val: ice.value)
- end
-
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getconstant(jit, ctx, asm)
- id = jit.operand(0)
-
- # vm_get_ev_const can raise exceptions.
- jit_prepare_routine_call(jit, ctx, asm)
-
- allow_nil_opnd = ctx.stack_pop(1)
- klass_opnd = ctx.stack_pop(1)
-
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], klass_opnd)
- asm.mov(C_ARGS[2], id)
- asm.mov(C_ARGS[3], allow_nil_opnd)
- asm.call(C.rb_vm_get_ev_const)
-
- top = ctx.stack_push
- asm.mov(top, C_RET)
-
- KeepCompiling
- end
-
- # setconstant
- # getglobal
- # setglobal
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putnil(jit, ctx, asm)
- putobject(jit, ctx, asm, val: Qnil)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putself(jit, ctx, asm)
- stack_top = ctx.stack_push
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)])
- asm.mov(stack_top, :rax)
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putobject(jit, ctx, asm, val: jit.operand(0))
- # Push it to the stack
- stack_top = ctx.stack_push
- if asm.imm32?(val)
- asm.mov(stack_top, val)
- else # 64-bit immediates can't be directly written to memory
- asm.mov(:rax, val)
- asm.mov(stack_top, :rax)
- end
- # TODO: GC offsets?
-
- KeepCompiling
- end
-
- # putspecialobject
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putstring(jit, ctx, asm)
- put_val = jit.operand(0, ruby: true)
-
- # Save the PC and SP because the callee will allocate
- jit_prepare_routine_call(jit, ctx, asm)
-
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], to_value(put_val))
- asm.call(C.rb_ec_str_resurrect)
-
- stack_top = ctx.stack_push
- asm.mov(stack_top, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def concatstrings(jit, ctx, asm)
- n = jit.operand(0)
-
- # Save the PC and SP because we are allocating
- jit_prepare_routine_call(jit, ctx, asm)
-
- asm.lea(:rax, ctx.sp_opnd(-C.VALUE.size * n))
-
- # call rb_str_concat_literals(size_t n, const VALUE *strings);
- asm.mov(C_ARGS[0], n)
- asm.mov(C_ARGS[1], :rax)
- asm.call(C.rb_str_concat_literals)
-
- ctx.stack_pop(n)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def anytostring(jit, ctx, asm)
- # Save the PC and SP since we might call #to_s
- jit_prepare_routine_call(jit, ctx, asm)
-
- str = ctx.stack_pop(1)
- val = ctx.stack_pop(1)
-
- asm.mov(C_ARGS[0], str)
- asm.mov(C_ARGS[1], val)
- asm.call(C.rb_obj_as_string_result)
-
- # Push the return value
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # toregexp
- # intern
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def newarray(jit, ctx, asm)
- n = jit.operand(0)
-
- # Save the PC and SP because we are allocating
- jit_prepare_routine_call(jit, ctx, asm)
-
- # If n is 0, then elts is never going to be read, so we can just pass null
- if n == 0
- values_ptr = 0
- else
- asm.comment('load pointer to array elts')
- offset_magnitude = C.VALUE.size * n
- values_opnd = ctx.sp_opnd(-(offset_magnitude))
- asm.lea(:rax, values_opnd)
- values_ptr = :rax
- end
-
- # call rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], n)
- asm.mov(C_ARGS[2], values_ptr)
- asm.call(C.rb_ec_ary_new_from_values)
-
- ctx.stack_pop(n)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # newarraykwsplat
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def duparray(jit, ctx, asm)
- ary = jit.operand(0)
-
- # Save the PC and SP because we are allocating
- jit_prepare_routine_call(jit, ctx, asm)
-
- # call rb_ary_resurrect(VALUE ary);
- asm.comment('call rb_ary_resurrect')
- asm.mov(C_ARGS[0], ary)
- asm.call(C.rb_ary_resurrect)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # duphash
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def expandarray(jit, ctx, asm)
- # Both arguments are rb_num_t which is unsigned
- num = jit.operand(0)
- flag = jit.operand(1)
-
- # If this instruction has the splat flag, then bail out.
- if flag & 0x01 != 0
- asm.incr_counter(:expandarray_splat)
- return CantCompile
- end
-
- # If this instruction has the postarg flag, then bail out.
- if flag & 0x02 != 0
- asm.incr_counter(:expandarray_postarg)
- return CantCompile
- end
-
- side_exit = side_exit(jit, ctx)
-
- array_opnd = ctx.stack_pop(1)
-
- # num is the number of requested values. If there aren't enough in the
- # array then we're going to push on nils.
- # TODO: implement this
-
- # Move the array from the stack and check that it's an array.
- asm.mov(:rax, array_opnd)
- guard_object_is_heap(asm, :rax, counted_exit(side_exit, :expandarray_not_array))
- guard_object_is_array(asm, :rax, :rcx, counted_exit(side_exit, :expandarray_not_array))
-
- # If we don't actually want any values, then just return.
- if num == 0
- return KeepCompiling
- end
-
- jit_array_len(asm, :rax, :rcx)
-
- # Only handle the case where the number of values in the array is greater
- # than or equal to the number of values requested.
- asm.cmp(:rcx, num)
- asm.jl(counted_exit(side_exit, :expandarray_rhs_too_small))
-
- # Conditionally load the address of the heap array into REG1.
- # (struct RArray *)(obj)->as.heap.ptr
- #asm.mov(:rax, array_opnd)
- asm.mov(:rcx, [:rax, C.RBasic.offsetof(:flags)])
- asm.test(:rcx, C::RARRAY_EMBED_FLAG);
- asm.mov(:rcx, [:rax, C.RArray.offsetof(:as, :heap, :ptr)])
-
- # Load the address of the embedded array into REG1.
- # (struct RArray *)(obj)->as.ary
- asm.lea(:rax, [:rax, C.RArray.offsetof(:as, :ary)])
-
- asm.cmovnz(:rcx, :rax)
-
- # Loop backward through the array and push each element onto the stack.
- (num - 1).downto(0).each do |i|
- top = ctx.stack_push
- asm.mov(:rax, [:rcx, i * C.VALUE.size])
- asm.mov(top, :rax)
- end
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def concatarray(jit, ctx, asm)
- # Save the PC and SP because the callee may allocate
- # Note that this modifies REG_SP, which is why we do it first
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Get the operands from the stack
- ary2st_opnd = ctx.stack_pop(1)
- ary1_opnd = ctx.stack_pop(1)
-
- # Call rb_vm_concat_array(ary1, ary2st)
- asm.mov(C_ARGS[0], ary1_opnd)
- asm.mov(C_ARGS[1], ary2st_opnd)
- asm.call(C.rb_vm_concat_array)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def splatarray(jit, ctx, asm)
- flag = jit.operand(0)
-
- # Save the PC and SP because the callee may allocate
- # Note that this modifies REG_SP, which is why we do it first
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Get the operands from the stack
- ary_opnd = ctx.stack_pop(1)
-
- # Call rb_vm_splat_array(flag, ary)
- asm.mov(C_ARGS[0], flag)
- asm.mov(C_ARGS[1], ary_opnd)
- asm.call(C.rb_vm_splat_array)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def newhash(jit, ctx, asm)
- num = jit.operand(0)
-
- # Save the PC and SP because we are allocating
- jit_prepare_routine_call(jit, ctx, asm)
-
- if num != 0
- # val = rb_hash_new_with_size(num / 2);
- asm.mov(C_ARGS[0], num / 2)
- asm.call(C.rb_hash_new_with_size)
-
- # Save the allocated hash as we want to push it after insertion
- asm.push(C_RET)
- asm.push(C_RET) # x86 alignment
-
- # Get a pointer to the values to insert into the hash
- asm.lea(:rcx, ctx.stack_opnd(num - 1))
-
- # rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
- asm.mov(C_ARGS[0], num)
- asm.mov(C_ARGS[1], :rcx)
- asm.mov(C_ARGS[2], C_RET)
- asm.call(C.rb_hash_bulk_insert)
-
- asm.pop(:rax)
- asm.pop(:rax)
-
- ctx.stack_pop(num)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
- else
- # val = rb_hash_new();
- asm.call(C.rb_hash_new)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
- end
-
- KeepCompiling
- end
-
- # newrange
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def pop(jit, ctx, asm)
- ctx.stack_pop
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def dup(jit, ctx, asm)
- val1 = ctx.stack_opnd(0)
- val2 = ctx.stack_push
- asm.mov(:rax, val1)
- asm.mov(val2, :rax)
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def dupn(jit, ctx, asm)
- n = jit.operand(0)
-
- # In practice, seems to be only used for n==2
- if n != 2
- return CantCompile
- end
-
- opnd1 = ctx.stack_opnd(1)
- opnd0 = ctx.stack_opnd(0)
-
- dst1 = ctx.stack_push
- asm.mov(:rax, opnd1)
- asm.mov(dst1, :rax)
-
- dst0 = ctx.stack_push
- asm.mov(:rax, opnd0)
- asm.mov(dst0, :rax)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def swap(jit, ctx, asm)
- stack0_mem = ctx.stack_opnd(0)
- stack1_mem = ctx.stack_opnd(1)
-
- asm.mov(:rax, stack0_mem)
- asm.mov(:rcx, stack1_mem)
- asm.mov(stack0_mem, :rcx)
- asm.mov(stack1_mem, :rax)
-
- KeepCompiling
- end
-
- # opt_reverse
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def topn(jit, ctx, asm)
- n = jit.operand(0)
-
- top_n_val = ctx.stack_opnd(n)
- loc0 = ctx.stack_push
- asm.mov(:rax, top_n_val)
- asm.mov(loc0, :rax)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def setn(jit, ctx, asm)
- n = jit.operand(0)
-
- top_val = ctx.stack_pop(0)
- dst_opnd = ctx.stack_opnd(n)
- asm.mov(:rax, top_val)
- asm.mov(dst_opnd, :rax)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def adjuststack(jit, ctx, asm)
- n = jit.operand(0)
- ctx.stack_pop(n)
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def defined(jit, ctx, asm)
- op_type = jit.operand(0)
- obj = jit.operand(1, ruby: true)
- pushval = jit.operand(2, ruby: true)
-
- # Save the PC and SP because the callee may allocate
- # Note that this modifies REG_SP, which is why we do it first
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Get the operands from the stack
- v_opnd = ctx.stack_pop(1)
-
- # Call vm_defined(ec, reg_cfp, op_type, obj, v)
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], CFP)
- asm.mov(C_ARGS[2], op_type)
- asm.mov(C_ARGS[3], to_value(obj))
- asm.mov(C_ARGS[4], v_opnd)
- asm.call(C.rb_vm_defined)
-
- asm.test(C_RET, 255)
- asm.mov(:rax, Qnil)
- asm.mov(:rcx, to_value(pushval))
- asm.cmovnz(:rax, :rcx)
-
- # Push the return value onto the stack
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def definedivar(jit, ctx, asm)
- ivar_name = jit.operand(0)
- pushval = jit.operand(2)
-
- # Get the receiver
- asm.mov(:rcx, [CFP, C.rb_control_frame_t.offsetof(:self)])
-
- # Save the PC and SP because the callee may allocate
- # Note that this modifies REG_SP, which is why we do it first
- jit_prepare_routine_call(jit, ctx, asm) # clobbers :rax
-
- # Call rb_ivar_defined(recv, ivar_name)
- asm.mov(C_ARGS[0], :rcx)
- asm.mov(C_ARGS[1], ivar_name)
- asm.call(C.rb_ivar_defined)
-
- # if (rb_ivar_defined(recv, ivar_name)) {
- # val = pushval;
- # }
- asm.test(C_RET, 255)
- asm.mov(:rax, Qnil)
- asm.mov(:rcx, pushval)
- asm.cmovnz(:rax, :rcx)
-
- # Push the return value onto the stack
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
-
- KeepCompiling
- end
-
- # checkmatch
- # checkkeyword
- # checktype
- # defineclass
- # definemethod
- # definesmethod
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def send(jit, ctx, asm)
- # Specialize on a compile-time receiver, and split a block for chain guards
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- cd = C.rb_call_data.new(jit.operand(0))
- blockiseq = jit.operand(1)
-
- block_handler = jit_caller_setup_arg_block(jit, ctx, asm, cd.ci, blockiseq, false)
- if block_handler == CantCompile
- return CantCompile
- end
-
- # calling->ci
- mid = C.vm_ci_mid(cd.ci)
- argc = C.vm_ci_argc(cd.ci)
- flags = C.vm_ci_flag(cd.ci)
-
- # vm_sendish
- cme, comptime_recv_klass = jit_search_method(jit, ctx, asm, mid, argc, flags)
- if cme == CantCompile
- return CantCompile
- end
- jit_call_general(jit, ctx, asm, mid, argc, flags, cme, block_handler, comptime_recv_klass)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_send_without_block(jit, ctx, asm, cd: C.rb_call_data.new(jit.operand(0)))
- # Specialize on a compile-time receiver, and split a block for chain guards
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- # calling->ci
- mid = C.vm_ci_mid(cd.ci)
- argc = C.vm_ci_argc(cd.ci)
- flags = C.vm_ci_flag(cd.ci)
-
- # vm_sendish
- cme, comptime_recv_klass = jit_search_method(jit, ctx, asm, mid, argc, flags)
- if cme == CantCompile
- return CantCompile
- end
- jit_call_general(jit, ctx, asm, mid, argc, flags, cme, C::VM_BLOCK_HANDLER_NONE, comptime_recv_klass)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def objtostring(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- recv = ctx.stack_opnd(0)
- comptime_recv = jit.peek_at_stack(0)
-
- if C::RB_TYPE_P(comptime_recv, C::RUBY_T_STRING)
- side_exit = side_exit(jit, ctx)
-
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_recv), recv, comptime_recv, side_exit)
- # No work needed. The string value is already on the top of the stack.
- KeepCompiling
- else
- cd = C.rb_call_data.new(jit.operand(0))
- opt_send_without_block(jit, ctx, asm, cd:)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_str_freeze(jit, ctx, asm)
- unless Invariants.assume_bop_not_redefined(jit, C::STRING_REDEFINED_OP_FLAG, C::BOP_FREEZE)
- return CantCompile;
- end
-
- str = jit.operand(0, ruby: true)
-
- # Push the return value onto the stack
- stack_ret = ctx.stack_push
- asm.mov(:rax, to_value(str))
- asm.mov(stack_ret, :rax)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_nil_p(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # opt_str_uminus
- # opt_newarray_max
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_newarray_min(jit, ctx, asm)
- num = jit.operand(0)
-
- # Save the PC and SP because we may allocate
- jit_prepare_routine_call(jit, ctx, asm)
-
- offset_magnitude = C.VALUE.size * num
- values_opnd = ctx.sp_opnd(-offset_magnitude)
- asm.lea(:rax, values_opnd)
-
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], num)
- asm.mov(C_ARGS[2], :rax)
- asm.call(C.rb_vm_opt_newarray_min)
-
- ctx.stack_pop(num)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def invokesuper(jit, ctx, asm)
- # Specialize on a compile-time receiver, and split a block for chain guards
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- cd = C.rb_call_data.new(jit.operand(0))
- blockiseq = jit.operand(1)
-
- block_handler = jit_caller_setup_arg_block(jit, ctx, asm, cd.ci, blockiseq, true)
- if block_handler == CantCompile
- return CantCompile
- end
-
- # calling->ci
- mid = C.vm_ci_mid(cd.ci)
- argc = C.vm_ci_argc(cd.ci)
- flags = C.vm_ci_flag(cd.ci)
-
- # vm_sendish
- cme = jit_search_super_method(jit, ctx, asm, mid, argc, flags)
- if cme == CantCompile
- return CantCompile
- end
- jit_call_general(jit, ctx, asm, mid, argc, flags, cme, block_handler, nil)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def invokeblock(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- # Get call info
- cd = C.rb_call_data.new(jit.operand(0))
- ci = cd.ci
- _argc = C.vm_ci_argc(ci)
- _flags = C.vm_ci_flag(ci)
-
- # Get block_handler
- cfp = jit.cfp
- lep = C.rb_vm_ep_local_ep(cfp.ep)
- comptime_handler = lep[C::VM_ENV_DATA_INDEX_SPECVAL]
-
- # Handle each block_handler type
- if comptime_handler == C::VM_BLOCK_HANDLER_NONE # no block given
- asm.incr_counter(:invokeblock_none)
- CantCompile
- elsif comptime_handler & 0x3 == 0x1 # VM_BH_ISEQ_BLOCK_P
- asm.incr_counter(:invokeblock_iseq)
- CantCompile
- elsif comptime_handler & 0x3 == 0x3 # VM_BH_IFUNC_P
- asm.incr_counter(:invokeblock_ifunc)
- CantCompile
- elsif symbol?(comptime_handler)
- asm.incr_counter(:invokeblock_symbol)
- CantCompile
- else # Proc
- asm.incr_counter(:invokeblock_proc)
- CantCompile
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def leave(jit, ctx, asm)
- assert_equal(ctx.stack_size, 1)
-
- jit_check_ints(jit, ctx, asm)
-
- asm.comment('pop stack frame')
- asm.lea(:rax, [CFP, C.rb_control_frame_t.size])
- asm.mov(CFP, :rax)
- asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], :rax)
-
- # Return a value (for compile_leave_exit)
- ret_opnd = ctx.stack_pop
- asm.mov(:rax, ret_opnd)
-
- # Set caller's SP and push a value to its stack (for JIT)
- asm.mov(SP, [CFP, C.rb_control_frame_t.offsetof(:sp)]) # Note: SP is in the position after popping a receiver and arguments
- asm.mov([SP], :rax)
-
- # Jump to cfp->jit_return
- asm.jmp([CFP, -C.rb_control_frame_t.size + C.rb_control_frame_t.offsetof(:jit_return)])
-
- EndBlock
- end
-
- # throw
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jump(jit, ctx, asm)
- # Check for interrupts, but only on backward branches that may create loops
- jump_offset = jit.operand(0, signed: true)
- if jump_offset < 0
- jit_check_ints(jit, ctx, asm)
- end
-
- pc = jit.pc + C.VALUE.size * (jit.insn.len + jump_offset)
- jit_direct_jump(jit.iseq, pc, ctx, asm)
- EndBlock
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def branchif(jit, ctx, asm)
- # Check for interrupts, but only on backward branches that may create loops
- jump_offset = jit.operand(0, signed: true)
- if jump_offset < 0
- jit_check_ints(jit, ctx, asm)
- end
-
- # TODO: skip check for known truthy
-
- # This `test` sets ZF only for Qnil and Qfalse, which let jz jump.
- val = ctx.stack_pop
- asm.test(val, ~Qnil)
-
- # Set stubs
- branch_stub = BranchStub.new(
- iseq: jit.iseq,
- shape: Default,
- target0: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * (jit.insn.len + jump_offset)), # branch target
- target1: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * jit.insn.len), # fallthrough
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.target1.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, false)
- @ocb.write(ocb_asm)
- end
-
- # Jump to target0 on jnz
- branch_stub.compile = proc do |branch_asm|
- branch_asm.comment("branchif #{branch_stub.shape}")
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.jnz(branch_stub.target0.address)
- branch_asm.jmp(branch_stub.target1.address)
- in Next0
- branch_asm.jz(branch_stub.target1.address)
- in Next1
- branch_asm.jnz(branch_stub.target0.address)
- end
- end
- end
- branch_stub.compile.call(asm)
-
- EndBlock
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def branchunless(jit, ctx, asm)
- # Check for interrupts, but only on backward branches that may create loops
- jump_offset = jit.operand(0, signed: true)
- if jump_offset < 0
- jit_check_ints(jit, ctx, asm)
- end
-
- # TODO: skip check for known truthy
-
- # This `test` sets ZF only for Qnil and Qfalse, which let jz jump.
- val = ctx.stack_pop
- asm.test(val, ~Qnil)
-
- # Set stubs
- branch_stub = BranchStub.new(
- iseq: jit.iseq,
- shape: Default,
- target0: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * (jit.insn.len + jump_offset)), # branch target
- target1: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * jit.insn.len), # fallthrough
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.target1.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, false)
- @ocb.write(ocb_asm)
- end
-
- # Jump to target0 on jz
- branch_stub.compile = proc do |branch_asm|
- branch_asm.comment("branchunless #{branch_stub.shape}")
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.jz(branch_stub.target0.address)
- branch_asm.jmp(branch_stub.target1.address)
- in Next0
- branch_asm.jnz(branch_stub.target1.address)
- in Next1
- branch_asm.jz(branch_stub.target0.address)
- end
- end
- end
- branch_stub.compile.call(asm)
-
- EndBlock
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def branchnil(jit, ctx, asm)
- # Check for interrupts, but only on backward branches that may create loops
- jump_offset = jit.operand(0, signed: true)
- if jump_offset < 0
- jit_check_ints(jit, ctx, asm)
- end
-
- # TODO: skip check for known truthy
-
- val = ctx.stack_pop
- asm.cmp(val, Qnil)
-
- # Set stubs
- branch_stub = BranchStub.new(
- iseq: jit.iseq,
- shape: Default,
- target0: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * (jit.insn.len + jump_offset)), # branch target
- target1: BranchTarget.new(ctx:, pc: jit.pc + C.VALUE.size * jit.insn.len), # fallthrough
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.target1.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, false)
- @ocb.write(ocb_asm)
- end
-
- # Jump to target0 on je
- branch_stub.compile = proc do |branch_asm|
- branch_asm.comment("branchnil #{branch_stub.shape}")
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.je(branch_stub.target0.address)
- branch_asm.jmp(branch_stub.target1.address)
- in Next0
- branch_asm.jne(branch_stub.target1.address)
- in Next1
- branch_asm.je(branch_stub.target0.address)
- end
- end
- end
- branch_stub.compile.call(asm)
-
- EndBlock
- end
-
- # once
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_case_dispatch(jit, ctx, asm)
- # Just go to === branches for now
- ctx.stack_pop
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_plus(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- comptime_recv = jit.peek_at_stack(1)
- comptime_obj = jit.peek_at_stack(0)
-
- if fixnum?(comptime_recv) && fixnum?(comptime_obj)
- # Generate a side exit before popping operands
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_PLUS)
- return CantCompile
- end
-
- obj_opnd = ctx.stack_pop
- recv_opnd = ctx.stack_pop
-
- asm.comment('guard recv is fixnum') # TODO: skip this with type information
- asm.test(recv_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.comment('guard obj is fixnum') # TODO: skip this with type information
- asm.test(obj_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.mov(:rax, recv_opnd)
- asm.sub(:rax, 1) # untag
- asm.mov(:rcx, obj_opnd)
- asm.add(:rax, :rcx)
- asm.jo(side_exit)
-
- dst_opnd = ctx.stack_push
- asm.mov(dst_opnd, :rax)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_minus(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- comptime_recv = jit.peek_at_stack(1)
- comptime_obj = jit.peek_at_stack(0)
-
- if fixnum?(comptime_recv) && fixnum?(comptime_obj)
- # Generate a side exit before popping operands
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_MINUS)
- return CantCompile
- end
-
- obj_opnd = ctx.stack_pop
- recv_opnd = ctx.stack_pop
-
- asm.comment('guard recv is fixnum') # TODO: skip this with type information
- asm.test(recv_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.comment('guard obj is fixnum') # TODO: skip this with type information
- asm.test(obj_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.mov(:rax, recv_opnd)
- asm.mov(:rcx, obj_opnd)
- asm.sub(:rax, :rcx)
- asm.jo(side_exit)
- asm.add(:rax, 1) # re-tag
-
- dst_opnd = ctx.stack_push
- asm.mov(dst_opnd, :rax)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_mult(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_div(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_mod(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- if two_fixnums_on_stack?(jit)
- # Create a side-exit to fall back to the interpreter
- # Note: we generate the side-exit before popping operands from the stack
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_MOD)
- return CantCompile
- end
-
- # Check that both operands are fixnums
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- # Get the operands and destination from the stack
- arg1 = ctx.stack_pop(1)
- arg0 = ctx.stack_pop(1)
-
- # Check for arg0 % 0
- asm.cmp(arg1, 0)
- asm.je(side_exit)
-
- # Call rb_fix_mod_fix(VALUE recv, VALUE obj)
- asm.mov(C_ARGS[0], arg0)
- asm.mov(C_ARGS[1], arg1)
- asm.call(C.rb_fix_mod_fix)
-
- # Push the return value onto the stack
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_eq(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- if jit_equality_specialized(jit, ctx, asm, true)
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_neq(jit, ctx, asm)
- # opt_neq is passed two rb_call_data as arguments:
- # first for ==, second for !=
- neq_cd = C.rb_call_data.new(jit.operand(1))
- opt_send_without_block(jit, ctx, asm, cd: neq_cd)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_lt(jit, ctx, asm)
- jit_fixnum_cmp(jit, ctx, asm, opcode: :cmovl, bop: C::BOP_LT)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_le(jit, ctx, asm)
- jit_fixnum_cmp(jit, ctx, asm, opcode: :cmovle, bop: C::BOP_LE)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_gt(jit, ctx, asm)
- jit_fixnum_cmp(jit, ctx, asm, opcode: :cmovg, bop: C::BOP_GT)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_ge(jit, ctx, asm)
- jit_fixnum_cmp(jit, ctx, asm, opcode: :cmovge, bop: C::BOP_GE)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_ltlt(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_and(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- if two_fixnums_on_stack?(jit)
- # Create a side-exit to fall back to the interpreter
- # Note: we generate the side-exit before popping operands from the stack
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_AND)
- return CantCompile
- end
-
- # Check that both operands are fixnums
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- # Get the operands and destination from the stack
- arg1 = ctx.stack_pop(1)
- arg0 = ctx.stack_pop(1)
-
- asm.comment('bitwise and')
- asm.mov(:rax, arg0)
- asm.and(:rax, arg1)
-
- # Push the return value onto the stack
- dst = ctx.stack_push
- asm.mov(dst, :rax)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_or(jit, ctx, asm)
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- if two_fixnums_on_stack?(jit)
- # Create a side-exit to fall back to the interpreter
- # Note: we generate the side-exit before popping operands from the stack
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_OR)
- return CantCompile
- end
-
- # Check that both operands are fixnums
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- # Get the operands and destination from the stack
- asm.comment('bitwise or')
- arg1 = ctx.stack_pop(1)
- arg0 = ctx.stack_pop(1)
-
- # Do the bitwise or arg0 | arg1
- asm.mov(:rax, arg0)
- asm.or(:rax, arg1)
-
- # Push the return value onto the stack
- dst = ctx.stack_push
- asm.mov(dst, :rax)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_aref(jit, ctx, asm)
- cd = C.rb_call_data.new(jit.operand(0))
- argc = C.vm_ci_argc(cd.ci)
-
- if argc != 1
- asm.incr_counter(:optaref_argc_not_one)
- return CantCompile
- end
-
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- comptime_recv = jit.peek_at_stack(1)
- comptime_obj = jit.peek_at_stack(0)
-
- side_exit = side_exit(jit, ctx)
-
- if C.rb_class_of(comptime_recv) == Array && fixnum?(comptime_obj)
- unless Invariants.assume_bop_not_redefined(jit, C::ARRAY_REDEFINED_OP_FLAG, C::BOP_AREF)
- return CantCompile
- end
-
- idx_opnd = ctx.stack_opnd(0)
- recv_opnd = ctx.stack_opnd(1)
-
- not_array_exit = counted_exit(side_exit, :optaref_recv_not_array)
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_recv), recv_opnd, comptime_recv, not_array_exit)
-
- # Bail if idx is not a FIXNUM
- asm.mov(:rax, idx_opnd)
- asm.test(:rax, C::RUBY_FIXNUM_FLAG)
- asm.jz(counted_exit(side_exit, :optaref_arg_not_fixnum))
-
- # Call VALUE rb_ary_entry_internal(VALUE ary, long offset).
- # It never raises or allocates, so we don't need to write to cfp->pc.
- asm.sar(:rax, 1) # Convert fixnum to int
- asm.mov(C_ARGS[0], recv_opnd)
- asm.mov(C_ARGS[1], :rax)
- asm.call(C.rb_ary_entry_internal)
-
- # Pop the argument and the receiver
- ctx.stack_pop(2)
-
- # Push the return value onto the stack
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- # Let guard chains share the same successor
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- elsif C.rb_class_of(comptime_recv) == Hash
- unless Invariants.assume_bop_not_redefined(jit, C::HASH_REDEFINED_OP_FLAG, C::BOP_AREF)
- return CantCompile
- end
-
- recv_opnd = ctx.stack_opnd(1)
-
- # Guard that the receiver is a Hash
- not_hash_exit = counted_exit(side_exit, :optaref_recv_not_hash)
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_recv), recv_opnd, comptime_recv, not_hash_exit)
-
- # Prepare to call rb_hash_aref(). It might call #hash on the key.
- jit_prepare_routine_call(jit, ctx, asm)
-
- asm.comment('call rb_hash_aref')
- key_opnd = ctx.stack_opnd(0)
- recv_opnd = ctx.stack_opnd(1)
- asm.mov(:rdi, recv_opnd)
- asm.mov(:rsi, key_opnd)
- asm.call(C.rb_hash_aref)
-
- # Pop the key and the receiver
- ctx.stack_pop(2)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- # Let guard chains share the same successor
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_aset(jit, ctx, asm)
- # Defer compilation so we can specialize on a runtime `self`
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- comptime_recv = jit.peek_at_stack(2)
- comptime_key = jit.peek_at_stack(1)
-
- # Get the operands from the stack
- recv = ctx.stack_opnd(2)
- key = ctx.stack_opnd(1)
- _val = ctx.stack_opnd(0)
-
- if C.rb_class_of(comptime_recv) == Array && fixnum?(comptime_key)
- side_exit = side_exit(jit, ctx)
-
- # Guard receiver is an Array
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_recv), recv, comptime_recv, side_exit)
-
- # Guard key is a fixnum
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_key), key, comptime_key, side_exit)
-
- # We might allocate or raise
- jit_prepare_routine_call(jit, ctx, asm)
-
- asm.comment('call rb_ary_store')
- recv = ctx.stack_opnd(2)
- key = ctx.stack_opnd(1)
- val = ctx.stack_opnd(0)
- asm.mov(:rax, key)
- asm.sar(:rax, 1) # FIX2LONG(key)
- asm.mov(C_ARGS[0], recv)
- asm.mov(C_ARGS[1], :rax)
- asm.mov(C_ARGS[2], val)
- asm.call(C.rb_ary_store)
-
- # rb_ary_store returns void
- # stored value should still be on stack
- val = ctx.stack_opnd(0)
-
- # Push the return value onto the stack
- ctx.stack_pop(3)
- stack_ret = ctx.stack_push
- asm.mov(:rax, val)
- asm.mov(stack_ret, :rax)
-
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- elsif C.rb_class_of(comptime_recv) == Hash
- side_exit = side_exit(jit, ctx)
-
- # Guard receiver is a Hash
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_recv), recv, comptime_recv, side_exit)
-
- # We might allocate or raise
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Call rb_hash_aset
- recv = ctx.stack_opnd(2)
- key = ctx.stack_opnd(1)
- val = ctx.stack_opnd(0)
- asm.mov(C_ARGS[0], recv)
- asm.mov(C_ARGS[1], key)
- asm.mov(C_ARGS[2], val)
- asm.call(C.rb_hash_aset)
-
- # Push the return value onto the stack
- ctx.stack_pop(3)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # opt_aset_with
- # opt_aref_with
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_length(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_size(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_empty_p(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_succ(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_not(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_regexpmatch2(jit, ctx, asm)
- opt_send_without_block(jit, ctx, asm)
- end
-
- # invokebuiltin
-
- def opt_invokebuiltin_delegate(jit, ctx, asm)
- bf = C.rb_builtin_function.new(jit.operand(0))
- bf_argc = bf.argc
- start_index = jit.operand(1)
-
- # ec, self, and arguments
- if bf_argc + 2 > C_ARGS.size
- return CantCompile
- end
-
- # If the calls don't allocate, do they need up to date PC, SP?
- jit_prepare_routine_call(jit, ctx, asm)
-
- # Call the builtin func (ec, recv, arg1, arg2, ...)
- asm.comment('call builtin func')
- asm.mov(C_ARGS[0], EC)
- asm.mov(C_ARGS[1], [CFP, C.rb_control_frame_t.offsetof(:self)])
-
- # Copy arguments from locals
- if bf_argc > 0
- # Load environment pointer EP from CFP
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:ep)])
-
- bf_argc.times do |i|
- table_size = jit.iseq.body.local_table_size
- offs = -table_size - C::VM_ENV_DATA_SIZE + 1 + start_index + i
- asm.mov(C_ARGS[2 + i], [:rax, offs * C.VALUE.size])
- end
- end
- asm.call(bf.func_ptr)
-
- # Push the return value
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def opt_invokebuiltin_delegate_leave(jit, ctx, asm)
- opt_invokebuiltin_delegate(jit, ctx, asm)
- # opt_invokebuiltin_delegate is always followed by leave insn
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getlocal_WC_0(jit, ctx, asm)
- # Get operands
- idx = jit.operand(0)
-
- # Get EP
- asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:ep)])
-
- # Get a local variable
- asm.mov(:rax, [:rax, -idx * C.VALUE.size])
-
- # Push it to the stack
- stack_top = ctx.stack_push
- asm.mov(stack_top, :rax)
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def getlocal_WC_1(jit, ctx, asm)
- idx = jit.operand(0)
- jit_getlocal_generic(jit, ctx, asm, idx:, level: 1)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def setlocal_WC_0(jit, ctx, asm)
- slot_idx = jit.operand(0)
-
- # Load environment pointer EP (level 0) from CFP
- ep_reg = :rax
- jit_get_ep(asm, 0, reg: ep_reg)
-
- # Write barriers may be required when VM_ENV_FLAG_WB_REQUIRED is set, however write barriers
- # only affect heap objects being written. If we know an immediate value is being written we
- # can skip this check.
-
- # flags & VM_ENV_FLAG_WB_REQUIRED
- flags_opnd = [ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS]
- asm.test(flags_opnd, C::VM_ENV_FLAG_WB_REQUIRED)
-
- # Create a side-exit to fall back to the interpreter
- side_exit = side_exit(jit, ctx)
-
- # if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
- asm.jnz(side_exit)
-
- # Pop the value to write from the stack
- stack_top = ctx.stack_pop(1)
-
- # Write the value at the environment pointer
- asm.mov(:rcx, stack_top)
- asm.mov([ep_reg, -8 * slot_idx], :rcx)
-
- KeepCompiling
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def setlocal_WC_1(jit, ctx, asm)
- idx = jit.operand(0)
- jit_setlocal_generic(jit, ctx, asm, idx:, level: 1)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putobject_INT2FIX_0_(jit, ctx, asm)
- putobject(jit, ctx, asm, val: C.to_value(0))
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def putobject_INT2FIX_1_(jit, ctx, asm)
- putobject(jit, ctx, asm, val: C.to_value(1))
- end
-
- #
- # C func
- #
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_true(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 0
- asm.comment('nil? == true');
- ctx.stack_pop(1)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, Qtrue)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_false(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 0
- asm.comment('nil? == false');
- ctx.stack_pop(1)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, Qfalse)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_obj_not(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 0
- asm.comment('rb_obj_not')
-
- recv = ctx.stack_pop
- # This `test` sets ZF only for Qnil and Qfalse, which let cmovz set.
- asm.test(recv, ~Qnil)
- asm.mov(:rax, Qfalse)
- asm.mov(:rcx, Qtrue)
- asm.cmovz(:rax, :rcx)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_obj_equal(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- asm.comment('equal?')
- obj1 = ctx.stack_pop(1)
- obj2 = ctx.stack_pop(1)
-
- asm.mov(:rax, obj1)
- asm.mov(:rcx, obj2)
- asm.cmp(:rax, :rcx)
- asm.mov(:rax, Qfalse)
- asm.mov(:rcx, Qtrue)
- asm.cmove(:rax, :rcx)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_obj_not_equal(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- jit_equality_specialized(jit, ctx, asm, false)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_mod_eqq(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
-
- asm.comment('Module#===')
- # By being here, we know that the receiver is a T_MODULE or a T_CLASS, because Module#=== can
- # only live on these objects. With that, we can call rb_obj_is_kind_of() without
- # jit_prepare_routine_call() or a control frame push because it can't raise, allocate, or call
- # Ruby methods with these inputs.
- # Note the difference in approach from Kernel#is_a? because we don't get a free guard for the
- # right hand side.
- lhs = ctx.stack_opnd(1) # the module
- rhs = ctx.stack_opnd(0)
- asm.mov(C_ARGS[0], rhs);
- asm.mov(C_ARGS[1], lhs);
- asm.call(C.rb_obj_is_kind_of)
-
- # Return the result
- ctx.stack_pop(2)
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- return true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_int_equal(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- return false unless two_fixnums_on_stack?(jit)
-
- side_exit = side_exit(jit, ctx)
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- # Compare the arguments
- asm.comment('rb_int_equal')
- arg1 = ctx.stack_pop(1)
- arg0 = ctx.stack_pop(1)
- asm.mov(:rax, arg1)
- asm.cmp(arg0, :rax)
- asm.mov(:rax, Qfalse)
- asm.mov(:rcx, Qtrue)
- asm.cmove(:rax, :rcx)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_int_mul(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- return false unless two_fixnums_on_stack?(jit)
-
- side_exit = side_exit(jit, ctx)
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- asm.comment('rb_int_mul')
- y_opnd = ctx.stack_pop
- x_opnd = ctx.stack_pop
- asm.mov(C_ARGS[0], x_opnd)
- asm.mov(C_ARGS[1], y_opnd)
- asm.call(C.rb_fix_mul_fix)
-
- ret_opnd = ctx.stack_push
- asm.mov(ret_opnd, C_RET)
- true
- end
-
- def jit_rb_int_div(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- return false unless two_fixnums_on_stack?(jit)
-
- side_exit = side_exit(jit, ctx)
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- asm.comment('rb_int_div')
- y_opnd = ctx.stack_pop
- x_opnd = ctx.stack_pop
- asm.mov(:rax, y_opnd)
- asm.cmp(:rax, C.to_value(0))
- asm.je(side_exit)
-
- asm.mov(C_ARGS[0], x_opnd)
- asm.mov(C_ARGS[1], :rax)
- asm.call(C.rb_fix_div_fix)
-
- ret_opnd = ctx.stack_push
- asm.mov(ret_opnd, C_RET)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_int_aref(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- return false unless two_fixnums_on_stack?(jit)
-
- side_exit = side_exit(jit, ctx)
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- asm.comment('rb_int_aref')
- y_opnd = ctx.stack_pop
- x_opnd = ctx.stack_pop
-
- asm.mov(C_ARGS[0], x_opnd)
- asm.mov(C_ARGS[1], y_opnd)
- asm.call(C.rb_fix_aref)
-
- ret_opnd = ctx.stack_push
- asm.mov(ret_opnd, C_RET)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_str_to_s(jit, ctx, asm, argc, known_recv_class)
- return false if argc != 0
- if known_recv_class == String
- asm.comment('to_s on plain string')
- # The method returns the receiver, which is already on the stack.
- # No stack movement.
- return true
- end
- false
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_str_getbyte(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- asm.comment('rb_str_getbyte')
-
- index_opnd = ctx.stack_pop
- str_opnd = ctx.stack_pop
- asm.mov(C_ARGS[0], str_opnd)
- asm.mov(C_ARGS[1], index_opnd)
- asm.call(C.rb_str_getbyte)
-
- ret_opnd = ctx.stack_push
- asm.mov(ret_opnd, C_RET)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_rb_ary_push(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 1
- asm.comment('rb_ary_push')
-
- jit_prepare_routine_call(jit, ctx, asm)
-
- item_opnd = ctx.stack_pop
- ary_opnd = ctx.stack_pop
- asm.mov(C_ARGS[0], ary_opnd)
- asm.mov(C_ARGS[1], item_opnd)
- asm.call(C.rb_ary_push)
-
- ret_opnd = ctx.stack_push
- asm.mov(ret_opnd, C_RET)
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_thread_s_current(jit, ctx, asm, argc, _known_recv_class)
- return false if argc != 0
- asm.comment('Thread.current')
- ctx.stack_pop(1)
-
- # ec->thread_ptr
- asm.mov(:rax, [EC, C.rb_execution_context_t.offsetof(:thread_ptr)])
-
- # thread->self
- asm.mov(:rax, [:rax, C.rb_thread_struct.offsetof(:self)])
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, :rax)
- true
- end
-
- #
- # Helpers
- #
-
- def register_cfunc_codegen_funcs
- # Specialization for C methods. See register_cfunc_method for details.
- register_cfunc_method(BasicObject, :!, :jit_rb_obj_not)
-
- register_cfunc_method(NilClass, :nil?, :jit_rb_true)
- register_cfunc_method(Kernel, :nil?, :jit_rb_false)
- #register_cfunc_method(Kernel, :is_a?, :jit_rb_kernel_is_a)
- #register_cfunc_method(Kernel, :kind_of?, :jit_rb_kernel_is_a)
- #register_cfunc_method(Kernel, :instance_of?, :jit_rb_kernel_instance_of)
-
- register_cfunc_method(BasicObject, :==, :jit_rb_obj_equal)
- register_cfunc_method(BasicObject, :equal?, :jit_rb_obj_equal)
- register_cfunc_method(BasicObject, :!=, :jit_rb_obj_not_equal)
- register_cfunc_method(Kernel, :eql?, :jit_rb_obj_equal)
- register_cfunc_method(Module, :==, :jit_rb_obj_equal)
- register_cfunc_method(Module, :===, :jit_rb_mod_eqq)
- register_cfunc_method(Symbol, :==, :jit_rb_obj_equal)
- register_cfunc_method(Symbol, :===, :jit_rb_obj_equal)
- register_cfunc_method(Integer, :==, :jit_rb_int_equal)
- register_cfunc_method(Integer, :===, :jit_rb_int_equal)
-
- # rb_str_to_s() methods in string.c
- #register_cfunc_method(String, :empty?, :jit_rb_str_empty_p)
- register_cfunc_method(String, :to_s, :jit_rb_str_to_s)
- register_cfunc_method(String, :to_str, :jit_rb_str_to_s)
- #register_cfunc_method(String, :bytesize, :jit_rb_str_bytesize)
- #register_cfunc_method(String, :<<, :jit_rb_str_concat)
- #register_cfunc_method(String, :+@, :jit_rb_str_uplus)
-
- # rb_ary_empty_p() method in array.c
- #register_cfunc_method(Array, :empty?, :jit_rb_ary_empty_p)
-
- #register_cfunc_method(Kernel, :respond_to?, :jit_obj_respond_to)
- #register_cfunc_method(Kernel, :block_given?, :jit_rb_f_block_given_p)
-
- # Thread.current
- register_cfunc_method(C.rb_singleton_class(Thread), :current, :jit_thread_s_current)
-
- #---
- register_cfunc_method(Array, :<<, :jit_rb_ary_push)
- register_cfunc_method(Integer, :*, :jit_rb_int_mul)
- register_cfunc_method(Integer, :/, :jit_rb_int_div)
- register_cfunc_method(Integer, :[], :jit_rb_int_aref)
- register_cfunc_method(String, :getbyte, :jit_rb_str_getbyte)
- end
-
- def register_cfunc_method(klass, mid_sym, func)
- mid = C.rb_intern(mid_sym.to_s)
- me = C.rb_method_entry_at(klass, mid)
-
- assert_equal(false, me.nil?)
-
- # Only cfuncs are supported
- method_serial = me.def.method_serial
-
- @cfunc_codegen_table[method_serial] = method(func)
- end
-
- def lookup_cfunc_codegen(cme_def)
- @cfunc_codegen_table[cme_def.method_serial]
- end
-
- def jit_getlocal_generic(jit, ctx, asm, idx:, level:)
- # Load environment pointer EP at level
- ep_reg = :rax
- jit_get_ep(asm, level, reg: ep_reg)
-
- # Get a local variable
- asm.mov(:rax, [ep_reg, -idx * C.VALUE.size])
-
- # Push it to the stack
- stack_top = ctx.stack_push
- asm.mov(stack_top, :rax)
- KeepCompiling
- end
-
- def jit_setlocal_generic(jit, ctx, asm, idx:, level:)
- # Load environment pointer EP at level
- ep_reg = :rax
- jit_get_ep(asm, level, reg: ep_reg)
-
- # Write barriers may be required when VM_ENV_FLAG_WB_REQUIRED is set, however write barriers
- # only affect heap objects being written. If we know an immediate value is being written we
- # can skip this check.
-
- # flags & VM_ENV_FLAG_WB_REQUIRED
- flags_opnd = [ep_reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_FLAGS]
- asm.test(flags_opnd, C::VM_ENV_FLAG_WB_REQUIRED)
-
- # Create a side-exit to fall back to the interpreter
- side_exit = side_exit(jit, ctx)
-
- # if (flags & VM_ENV_FLAG_WB_REQUIRED) != 0
- asm.jnz(side_exit)
-
- # Pop the value to write from the stack
- stack_top = ctx.stack_pop(1)
-
- # Write the value at the environment pointer
- asm.mov(:rcx, stack_top)
- asm.mov([ep_reg, -(C.VALUE.size * idx)], :rcx)
-
- KeepCompiling
- end
-
- # Compute the index of a local variable from its slot index
- def slot_to_local_idx(iseq, slot_idx)
- # Layout illustration
- # This is an array of VALUE
- # | VM_ENV_DATA_SIZE |
- # v v
- # low addr <+-------+-------+-------+-------+------------------+
- # |local 0|local 1| ... |local n| .... |
- # +-------+-------+-------+-------+------------------+
- # ^ ^ ^ ^
- # +-------+---local_table_size----+ cfp->ep--+
- # | |
- # +------------------slot_idx----------------+
- #
- # See usages of local_var_name() from iseq.c for similar calculation.
-
- local_table_size = iseq.body.local_table_size
- op = slot_idx - C::VM_ENV_DATA_SIZE
- local_table_size - op - 1
- end
-
- # @param asm [RubyVM::RJIT::Assembler]
- def guard_object_is_heap(asm, object_opnd, side_exit)
- asm.comment('guard object is heap')
- # Test that the object is not an immediate
- asm.test(object_opnd, C::RUBY_IMMEDIATE_MASK)
- asm.jnz(side_exit)
-
- # Test that the object is not false
- asm.cmp(object_opnd, Qfalse)
- asm.je(side_exit)
- end
-
- # @param asm [RubyVM::RJIT::Assembler]
- def guard_object_is_array(asm, object_reg, flags_reg, side_exit)
- asm.comment('guard object is array')
- # Pull out the type mask
- asm.mov(flags_reg, [object_reg, C.RBasic.offsetof(:flags)])
- asm.and(flags_reg, C::RUBY_T_MASK)
-
- # Compare the result with T_ARRAY
- asm.cmp(flags_reg, C::RUBY_T_ARRAY)
- asm.jne(side_exit)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_chain_guard(opcode, jit, ctx, asm, side_exit, limit: 20)
- opcode => :je | :jne | :jnz | :jz
-
- if ctx.chain_depth < limit
- deeper = ctx.dup
- deeper.chain_depth += 1
-
- branch_stub = BranchStub.new(
- iseq: jit.iseq,
- shape: Default,
- target0: BranchTarget.new(ctx: deeper, pc: jit.pc),
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(deeper, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.compile = proc do |branch_asm|
- # Not using `asm.comment` here since it's usually put before cmp/test before this.
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.public_send(opcode, branch_stub.target0.address)
- end
- end
- end
- branch_stub.compile.call(asm)
- else
- asm.public_send(opcode, side_exit)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_guard_known_klass(jit, ctx, asm, known_klass, obj_opnd, comptime_obj, side_exit, limit: 10)
- # Only memory operand is supported for now
- assert_equal(true, obj_opnd.is_a?(Array))
-
- if known_klass == NilClass
- asm.comment('guard object is nil')
- asm.cmp(obj_opnd, Qnil)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- elsif known_klass == TrueClass
- asm.comment('guard object is true')
- asm.cmp(obj_opnd, Qtrue)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- elsif known_klass == FalseClass
- asm.comment('guard object is false')
- asm.cmp(obj_opnd, Qfalse)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- elsif known_klass == Integer && fixnum?(comptime_obj)
- asm.comment('guard object is fixnum')
- asm.test(obj_opnd, C::RUBY_FIXNUM_FLAG)
- jit_chain_guard(:jz, jit, ctx, asm, side_exit, limit:)
- elsif known_klass == Symbol && static_symbol?(comptime_obj)
- # We will guard STATIC vs DYNAMIC as though they were separate classes
- # DYNAMIC symbols can be handled by the general else case below
- asm.comment('guard object is static symbol')
- assert_equal(8, C::RUBY_SPECIAL_SHIFT)
- asm.cmp(BytePtr[*obj_opnd], C::RUBY_SYMBOL_FLAG)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- elsif known_klass == Float && flonum?(comptime_obj)
- # We will guard flonum vs heap float as though they were separate classes
- asm.comment('guard object is flonum')
- asm.mov(:rax, obj_opnd)
- asm.and(:rax, C::RUBY_FLONUM_MASK)
- asm.cmp(:rax, C::RUBY_FLONUM_FLAG)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- elsif C::FL_TEST(known_klass, C::RUBY_FL_SINGLETON) && comptime_obj == C.rb_class_attached_object(known_klass)
- asm.comment('guard known object with singleton class')
- asm.mov(:rax, C.to_value(comptime_obj))
- asm.cmp(obj_opnd, :rax)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- else
- # Load memory to a register
- asm.mov(:rax, obj_opnd)
- obj_opnd = :rax
-
- # Check that the receiver is a heap object
- # Note: if we get here, the class doesn't have immediate instances.
- asm.comment('guard not immediate')
- asm.test(obj_opnd, C::RUBY_IMMEDIATE_MASK)
- jit_chain_guard(:jnz, jit, ctx, asm, side_exit, limit:)
- asm.cmp(obj_opnd, Qfalse)
- jit_chain_guard(:je, jit, ctx, asm, side_exit, limit:)
-
- # Bail if receiver class is different from known_klass
- klass_opnd = [obj_opnd, C.RBasic.offsetof(:klass)]
- asm.comment("guard known class #{known_klass}")
- asm.mov(:rcx, to_value(known_klass))
- asm.cmp(klass_opnd, :rcx)
- jit_chain_guard(:jne, jit, ctx, asm, side_exit, limit:)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- def two_fixnums_on_stack?(jit)
- comptime_recv = jit.peek_at_stack(1)
- comptime_arg = jit.peek_at_stack(0)
- return fixnum?(comptime_recv) && fixnum?(comptime_arg)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def guard_two_fixnums(jit, ctx, asm, side_exit)
- # Get stack operands without popping them
- arg1 = ctx.stack_opnd(0)
- arg0 = ctx.stack_opnd(1)
-
- asm.comment('guard arg0 fixnum')
- asm.test(arg0, C::RUBY_FIXNUM_FLAG)
- jit_chain_guard(:jz, jit, ctx, asm, side_exit)
- # TODO: upgrade type, and skip the check when possible
-
- asm.comment('guard arg1 fixnum')
- asm.test(arg1, C::RUBY_FIXNUM_FLAG)
- jit_chain_guard(:jz, jit, ctx, asm, side_exit)
- # TODO: upgrade type, and skip the check when possible
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_fixnum_cmp(jit, ctx, asm, opcode:, bop:)
- opcode => :cmovl | :cmovle | :cmovg | :cmovge
-
- unless jit.at_current_insn?
- defer_compilation(jit, ctx, asm)
- return EndBlock
- end
-
- comptime_recv = jit.peek_at_stack(1)
- comptime_obj = jit.peek_at_stack(0)
-
- if fixnum?(comptime_recv) && fixnum?(comptime_obj)
- # Generate a side exit before popping operands
- side_exit = side_exit(jit, ctx)
-
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, bop)
- return CantCompile
- end
-
- obj_opnd = ctx.stack_pop
- recv_opnd = ctx.stack_pop
-
- asm.comment('guard recv is fixnum') # TODO: skip this with type information
- asm.test(recv_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.comment('guard obj is fixnum') # TODO: skip this with type information
- asm.test(obj_opnd, C::RUBY_FIXNUM_FLAG)
- asm.jz(side_exit)
-
- asm.mov(:rax, obj_opnd)
- asm.cmp(recv_opnd, :rax)
- asm.mov(:rax, Qfalse)
- asm.mov(:rcx, Qtrue)
- asm.public_send(opcode, :rax, :rcx)
-
- dst_opnd = ctx.stack_push
- asm.mov(dst_opnd, :rax)
-
- KeepCompiling
- else
- opt_send_without_block(jit, ctx, asm)
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_equality_specialized(jit, ctx, asm, gen_eq)
- # Create a side-exit to fall back to the interpreter
- side_exit = side_exit(jit, ctx)
-
- a_opnd = ctx.stack_opnd(1)
- b_opnd = ctx.stack_opnd(0)
-
- comptime_a = jit.peek_at_stack(1)
- comptime_b = jit.peek_at_stack(0)
-
- if two_fixnums_on_stack?(jit)
- unless Invariants.assume_bop_not_redefined(jit, C::INTEGER_REDEFINED_OP_FLAG, C::BOP_EQ)
- return false
- end
-
- guard_two_fixnums(jit, ctx, asm, side_exit)
-
- asm.comment('check fixnum equality')
- asm.mov(:rax, a_opnd)
- asm.mov(:rcx, b_opnd)
- asm.cmp(:rax, :rcx)
- asm.mov(:rax, gen_eq ? Qfalse : Qtrue)
- asm.mov(:rcx, gen_eq ? Qtrue : Qfalse)
- asm.cmove(:rax, :rcx)
-
- # Push the output on the stack
- ctx.stack_pop(2)
- dst = ctx.stack_push
- asm.mov(dst, :rax)
-
- true
- elsif C.rb_class_of(comptime_a) == String && C.rb_class_of(comptime_b) == String
- unless Invariants.assume_bop_not_redefined(jit, C::STRING_REDEFINED_OP_FLAG, C::BOP_EQ)
- # if overridden, emit the generic version
- return false
- end
-
- # Guard that a is a String
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_a), a_opnd, comptime_a, side_exit)
-
- equal_label = asm.new_label(:equal)
- ret_label = asm.new_label(:ret)
-
- # If they are equal by identity, return true
- asm.mov(:rax, a_opnd)
- asm.mov(:rcx, b_opnd)
- asm.cmp(:rax, :rcx)
- asm.je(equal_label)
-
- # Otherwise guard that b is a T_STRING (from type info) or String (from runtime guard)
- # Note: any T_STRING is valid here, but we check for a ::String for simplicity
- # To pass a mutable static variable (rb_cString) requires an unsafe block
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_b), b_opnd, comptime_b, side_exit)
-
- asm.comment('call rb_str_eql_internal')
- asm.mov(C_ARGS[0], a_opnd)
- asm.mov(C_ARGS[1], b_opnd)
- asm.call(gen_eq ? C.rb_str_eql_internal : C.rjit_str_neq_internal)
-
- # Push the output on the stack
- ctx.stack_pop(2)
- dst = ctx.stack_push
- asm.mov(dst, C_RET)
- asm.jmp(ret_label)
-
- asm.write_label(equal_label)
- asm.mov(dst, gen_eq ? Qtrue : Qfalse)
-
- asm.write_label(ret_label)
-
- true
- else
- false
- end
- end
-
- # NOTE: This clobbers :rax
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_prepare_routine_call(jit, ctx, asm)
- jit.record_boundary_patch_point = true
- jit_save_pc(jit, asm)
- jit_save_sp(jit, ctx, asm)
- end
-
- # Note: This clobbers :rax
- # @param jit [RubyVM::RJIT::JITState]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_save_pc(jit, asm, comment: 'save PC to CFP')
- next_pc = jit.pc + jit.insn.len * C.VALUE.size # Use the next one for backtrace and side exits
- asm.comment(comment)
- asm.mov(:rax, next_pc)
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:pc)], :rax)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_save_sp(jit, ctx, asm)
- if ctx.sp_offset != 0
- asm.comment('save SP to CFP')
- asm.lea(SP, ctx.sp_opnd)
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:sp)], SP)
- ctx.sp_offset = 0
- end
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jump_to_next_insn(jit, ctx, asm)
- reset_depth = ctx.dup
- reset_depth.chain_depth = 0
-
- next_pc = jit.pc + jit.insn.len * C.VALUE.size
-
- # We are at the end of the current instruction. Record the boundary.
- if jit.record_boundary_patch_point
- exit_pos = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_side_exit(next_pc, ctx, ocb_asm)
- @ocb.write(ocb_asm)
- end
- Invariants.record_global_inval_patch(asm, exit_pos)
- jit.record_boundary_patch_point = false
- end
-
- jit_direct_jump(jit.iseq, next_pc, reset_depth, asm, comment: 'jump_to_next_insn')
- end
-
- # rb_vm_check_ints
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_check_ints(jit, ctx, asm)
- asm.comment('RUBY_VM_CHECK_INTS(ec)')
- asm.mov(:eax, DwordPtr[EC, C.rb_execution_context_t.offsetof(:interrupt_flag)])
- asm.test(:eax, :eax)
- asm.jnz(side_exit(jit, ctx))
- end
-
- # See get_lvar_level in compile.c
- def get_lvar_level(iseq)
- level = 0
- while iseq.to_i != iseq.body.local_iseq.to_i
- level += 1
- iseq = iseq.body.parent_iseq
- end
- return level
- end
-
- # GET_LEP
- # @param jit [RubyVM::RJIT::JITState]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_get_lep(jit, asm, reg:)
- level = get_lvar_level(jit.iseq)
- jit_get_ep(asm, level, reg:)
- end
-
- # vm_get_ep
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_get_ep(asm, level, reg:)
- asm.mov(reg, [CFP, C.rb_control_frame_t.offsetof(:ep)])
- level.times do
- # GET_PREV_EP: ep[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03
- asm.mov(reg, [reg, C.VALUE.size * C::VM_ENV_DATA_INDEX_SPECVAL])
- asm.and(reg, ~0x03)
- end
- end
-
- # vm_getivar
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_getivar(jit, ctx, asm, comptime_obj, ivar_id, obj_opnd = nil)
- side_exit = side_exit(jit, ctx)
- starting_ctx = ctx.dup # copy for jit_chain_guard
-
- # Guard not special const
- if C::SPECIAL_CONST_P(comptime_obj)
- asm.incr_counter(:getivar_special_const)
- return CantCompile
- end
-
- case C::BUILTIN_TYPE(comptime_obj)
- when C::T_OBJECT
- # This is the only supported case for now (ROBJECT_IVPTR)
- else
- # General case. Call rb_ivar_get().
- # VALUE rb_ivar_get(VALUE obj, ID id)
- asm.comment('call rb_ivar_get()')
- asm.mov(C_ARGS[0], obj_opnd ? obj_opnd : [CFP, C.rb_control_frame_t.offsetof(:self)])
- asm.mov(C_ARGS[1], ivar_id)
-
- # The function could raise exceptions.
- jit_prepare_routine_call(jit, ctx, asm) # clobbers obj_opnd and :rax
-
- asm.call(C.rb_ivar_get)
-
- if obj_opnd # attr_reader
- ctx.stack_pop
- end
-
- # Push the ivar on the stack
- out_opnd = ctx.stack_push
- asm.mov(out_opnd, C_RET)
-
- # Jump to next instruction. This allows guard chains to share the same successor.
- jump_to_next_insn(jit, ctx, asm)
- return EndBlock
- end
-
- asm.mov(:rax, obj_opnd ? obj_opnd : [CFP, C.rb_control_frame_t.offsetof(:self)])
- guard_object_is_heap(asm, :rax, counted_exit(side_exit, :getivar_not_heap))
-
- shape_id = C.rb_shape_get_shape_id(comptime_obj)
- if shape_id == C::OBJ_TOO_COMPLEX_SHAPE_ID
- asm.incr_counter(:getivar_too_complex)
- return CantCompile
- end
-
- asm.comment('guard shape')
- asm.cmp(DwordPtr[:rax, C.rb_shape_id_offset], shape_id)
- jit_chain_guard(:jne, jit, starting_ctx, asm, counted_exit(side_exit, :getivar_megamorphic))
-
- index = C.rb_shape_get_iv_index(shape_id, ivar_id)
- if index
- asm.comment('ROBJECT_IVPTR')
- if C::FL_TEST_RAW(comptime_obj, C::ROBJECT_EMBED)
- # Access embedded array
- asm.mov(:rax, [:rax, C.RObject.offsetof(:as, :ary) + (index * C.VALUE.size)])
- else
- # Pull out an ivar table on heap
- asm.mov(:rax, [:rax, C.RObject.offsetof(:as, :heap, :ivptr)])
- # Read the table
- asm.mov(:rax, [:rax, index * C.VALUE.size])
- end
- val_opnd = :rax
- else
- val_opnd = Qnil
- end
-
- if obj_opnd
- ctx.stack_pop # pop receiver for attr_reader
- end
- stack_opnd = ctx.stack_push
- asm.mov(stack_opnd, val_opnd)
-
- # Let guard chains share the same successor
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- end
-
- def jit_write_iv(asm, comptime_receiver, recv_reg, temp_reg, ivar_index, set_value, needs_extension)
- # Compile time self is embedded and the ivar index lands within the object
- embed_test_result = C::FL_TEST_RAW(comptime_receiver, C::ROBJECT_EMBED) && !needs_extension
-
- if embed_test_result
- # Find the IV offset
- offs = C.RObject.offsetof(:as, :ary) + ivar_index * C.VALUE.size
-
- # Write the IV
- asm.comment('write IV')
- asm.mov(temp_reg, set_value)
- asm.mov([recv_reg, offs], temp_reg)
- else
- # Compile time value is *not* embedded.
-
- # Get a pointer to the extended table
- asm.mov(recv_reg, [recv_reg, C.RObject.offsetof(:as, :heap, :ivptr)])
-
- # Write the ivar in to the extended table
- asm.comment("write IV");
- asm.mov(temp_reg, set_value)
- asm.mov([recv_reg, C.VALUE.size * ivar_index], temp_reg)
- end
- end
-
- # vm_caller_setup_arg_block
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_caller_setup_arg_block(jit, ctx, asm, ci, blockiseq, is_super)
- side_exit = side_exit(jit, ctx)
- if C.vm_ci_flag(ci) & C::VM_CALL_ARGS_BLOCKARG != 0
- # TODO: Skip cmp + jne using Context?
- block_code = jit.peek_at_stack(0)
- block_opnd = ctx.stack_opnd(0) # to be popped after eliminating side exit possibility
- if block_code.nil?
- asm.cmp(block_opnd, Qnil)
- jit_chain_guard(:jne, jit, ctx, asm, counted_exit(side_exit, :send_block_not_nil))
- return C::VM_BLOCK_HANDLER_NONE
- elsif C.to_value(block_code) == C.rb_block_param_proxy
- asm.mov(:rax, C.rb_block_param_proxy)
- asm.cmp(block_opnd, :rax)
- jit_chain_guard(:jne, jit, ctx, asm, counted_exit(side_exit, :send_block_not_proxy))
- return C.rb_block_param_proxy
- else
- asm.incr_counter(:send_blockarg_not_nil_or_proxy)
- return CantCompile
- end
- elsif blockiseq != 0
- return blockiseq
- else
- if is_super
- # GET_BLOCK_HANDLER();
- # Guard no block passed. Only handle that case for now.
- asm.comment('guard no block given')
- jit_get_lep(jit, asm, reg: :rax)
- asm.cmp([:rax, C.VALUE.size * C::VM_ENV_DATA_INDEX_SPECVAL], C::VM_BLOCK_HANDLER_NONE)
- asm.jne(counted_exit(side_exit, :send_block_handler))
- return C::VM_BLOCK_HANDLER_NONE
- else
- # Not implemented yet. Is this even necessary?
- asm.incr_counter(:send_block_setup)
- return CantCompile
- end
- end
- end
-
- # vm_search_method
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_search_method(jit, ctx, asm, mid, argc, flags, send_shift: 0)
- assert_equal(true, jit.at_current_insn?)
-
- # Generate a side exit
- side_exit = side_exit(jit, ctx)
-
- # kw_splat is not supported yet
- if flags & C::VM_CALL_KW_SPLAT != 0
- asm.incr_counter(:send_kw_splat)
- return CantCompile
- end
-
- # Get a compile-time receiver and its class
- recv_idx = argc + (flags & C::VM_CALL_ARGS_BLOCKARG != 0 ? 1 : 0) # blockarg is not popped yet
- recv_idx += send_shift
- comptime_recv = jit.peek_at_stack(recv_idx)
- comptime_recv_klass = C.rb_class_of(comptime_recv)
-
- # Guard the receiver class (part of vm_search_method_fastpath)
- recv_opnd = ctx.stack_opnd(recv_idx)
- megamorphic_exit = counted_exit(side_exit, :send_klass_megamorphic)
- jit_guard_known_klass(jit, ctx, asm, comptime_recv_klass, recv_opnd, comptime_recv, megamorphic_exit)
-
- # Do method lookup (vm_cc_cme(cc) != NULL)
- cme = C.rb_callable_method_entry(comptime_recv_klass, mid)
- if cme.nil?
- asm.incr_counter(:send_missing_cme)
- return CantCompile # We don't support vm_call_method_name
- end
-
- # Invalidate on redefinition (part of vm_search_method_fastpath)
- Invariants.assume_method_lookup_stable(jit, cme)
-
- return cme, comptime_recv_klass
- end
-
- def jit_search_super_method(jit, ctx, asm, mid, argc, flags)
- assert_equal(true, jit.at_current_insn?)
-
- me = C.rb_vm_frame_method_entry(jit.cfp)
- if me.nil?
- return CantCompile
- end
-
- # FIXME: We should track and invalidate this block when this cme is invalidated
- current_defined_class = me.defined_class
- mid = me.def.original_id
-
- if me.to_i != C.rb_callable_method_entry(current_defined_class, me.called_id).to_i
- # Though we likely could generate this call, as we are only concerned
- # with the method entry remaining valid, assume_method_lookup_stable
- # below requires that the method lookup matches as well
- return CantCompile
- end
-
- # vm_search_normal_superclass
- rbasic_klass = C.to_ruby(C.RBasic.new(C.to_value(current_defined_class)).klass)
- if C::BUILTIN_TYPE(current_defined_class) == C::RUBY_T_ICLASS && C::BUILTIN_TYPE(rbasic_klass) == C::RUBY_T_MODULE && \
- C::FL_TEST_RAW(rbasic_klass, C::RMODULE_IS_REFINEMENT) != 0
- return CantCompile
- end
- comptime_superclass = C.rb_class_get_superclass(current_defined_class)
-
- # Don't JIT calls that aren't simple
- # Note, not using VM_CALL_ARGS_SIMPLE because sometimes we pass a block.
-
- if flags & C::VM_CALL_KWARG != 0
- asm.incr_counter(:send_kwarg)
- return CantCompile
- end
- if flags & C::VM_CALL_KW_SPLAT != 0
- asm.incr_counter(:send_kw_splat)
- return CantCompile
- end
-
- # Ensure we haven't rebound this method onto an incompatible class.
- # In the interpreter we try to avoid making this check by performing some
- # cheaper calculations first, but since we specialize on the method entry
- # and so only have to do this once at compile time this is fine to always
- # check and side exit.
- comptime_recv = jit.peek_at_stack(argc)
- unless C.obj_is_kind_of(comptime_recv, current_defined_class)
- return CantCompile
- end
-
- # Do method lookup
- cme = C.rb_callable_method_entry(comptime_superclass, mid)
-
- if cme.nil?
- return CantCompile
- end
-
- # workaround -- TODO: Why does this happen?
- if me.to_i == cme.to_i
- asm.incr_counter(:invokesuper_same_me)
- return CantCompile
- end
-
- # Check that we'll be able to write this method dispatch before generating checks
- cme_def_type = cme.def.type
- if cme_def_type != C::VM_METHOD_TYPE_ISEQ && cme_def_type != C::VM_METHOD_TYPE_CFUNC
- # others unimplemented
- return CantCompile
- end
-
- # Guard that the receiver has the same class as the one from compile time
- side_exit = side_exit(jit, ctx)
-
- asm.comment('guard known me')
- jit_get_lep(jit, asm, reg: :rax)
-
- asm.mov(:rcx, me.to_i)
- asm.cmp([:rax, C.VALUE.size * C::VM_ENV_DATA_INDEX_ME_CREF], :rcx)
- asm.jne(counted_exit(side_exit, :invokesuper_me_changed))
-
- # We need to assume that both our current method entry and the super
- # method entry we invoke remain stable
- Invariants.assume_method_lookup_stable(jit, me)
- Invariants.assume_method_lookup_stable(jit, cme)
-
- return cme
- end
-
- # vm_call_general
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_general(jit, ctx, asm, mid, argc, flags, cme, block_handler, known_recv_class)
- jit_call_method(jit, ctx, asm, mid, argc, flags, cme, block_handler, known_recv_class)
- end
-
- # vm_call_method
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- # @param send_shift [Integer] The number of shifts needed for VM_CALL_OPT_SEND
- def jit_call_method(jit, ctx, asm, mid, argc, flags, cme, block_handler, known_recv_class, send_shift: 0)
- # The main check of vm_call_method before vm_call_method_each_type
- case C::METHOD_ENTRY_VISI(cme)
- in C::METHOD_VISI_PUBLIC
- # You can always call public methods
- in C::METHOD_VISI_PRIVATE
- # Allow only callsites without a receiver
- if flags & C::VM_CALL_FCALL == 0
- asm.incr_counter(:send_private)
- return CantCompile
- end
- in C::METHOD_VISI_PROTECTED
- # If the method call is an FCALL, it is always valid
- if flags & C::VM_CALL_FCALL == 0
- # otherwise we need an ancestry check to ensure the receiver is valid to be called as protected
- jit_protected_callee_ancestry_guard(asm, cme, side_exit(jit, ctx))
- end
- end
-
- # Get a compile-time receiver
- recv_idx = argc + (flags & C::VM_CALL_ARGS_BLOCKARG != 0 ? 1 : 0) # blockarg is not popped yet
- recv_idx += send_shift
- comptime_recv = jit.peek_at_stack(recv_idx)
- recv_opnd = ctx.stack_opnd(recv_idx)
-
- jit_call_method_each_type(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- end
-
- # Generate ancestry guard for protected callee.
- # Calls to protected callees only go through when self.is_a?(klass_that_defines_the_callee).
- def jit_protected_callee_ancestry_guard(asm, cme, side_exit)
- # See vm_call_method().
- def_class = cme.defined_class
- # Note: PC isn't written to current control frame as rb_is_kind_of() shouldn't raise.
- # VALUE rb_obj_is_kind_of(VALUE obj, VALUE klass);
-
- asm.mov(C_ARGS[0], [CFP, C.rb_control_frame_t.offsetof(:self)])
- asm.mov(C_ARGS[1], to_value(def_class))
- asm.call(C.rb_obj_is_kind_of)
- asm.test(C_RET, C_RET)
- asm.jz(counted_exit(side_exit, :send_protected_check_failed))
- end
-
- # vm_call_method_each_type
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_method_each_type(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- case cme.def.type
- in C::VM_METHOD_TYPE_ISEQ
- iseq = def_iseq_ptr(cme.def)
- jit_call_iseq_setup(jit, ctx, asm, cme, flags, argc, iseq, block_handler, send_shift:)
- in C::VM_METHOD_TYPE_NOTIMPLEMENTED
- asm.incr_counter(:send_notimplemented)
- return CantCompile
- in C::VM_METHOD_TYPE_CFUNC
- jit_call_cfunc(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- in C::VM_METHOD_TYPE_ATTRSET
- asm.incr_counter(:send_attrset)
- return CantCompile
- in C::VM_METHOD_TYPE_IVAR
- jit_call_ivar(jit, ctx, asm, cme, flags, argc, comptime_recv, recv_opnd, send_shift:)
- in C::VM_METHOD_TYPE_MISSING
- asm.incr_counter(:send_missing)
- return CantCompile
- in C::VM_METHOD_TYPE_BMETHOD
- jit_call_bmethod(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- in C::VM_METHOD_TYPE_ALIAS
- jit_call_alias(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- in C::VM_METHOD_TYPE_OPTIMIZED
- jit_call_optimized(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- in C::VM_METHOD_TYPE_UNDEF
- asm.incr_counter(:send_undef)
- return CantCompile
- in C::VM_METHOD_TYPE_ZSUPER
- asm.incr_counter(:send_zsuper)
- return CantCompile
- in C::VM_METHOD_TYPE_REFINED
- asm.incr_counter(:send_refined)
- return CantCompile
- end
- end
-
- # vm_call_iseq_setup
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_iseq_setup(jit, ctx, asm, cme, flags, argc, iseq, block_handler, send_shift:, frame_type: nil, prev_ep: nil)
- opt_pc = jit_callee_setup_arg(jit, ctx, asm, flags, argc, iseq)
- if opt_pc == CantCompile
- return CantCompile
- end
-
- if flags & C::VM_CALL_TAILCALL != 0
- # We don't support vm_call_iseq_setup_tailcall
- asm.incr_counter(:send_tailcall)
- return CantCompile
- end
- jit_call_iseq_setup_normal(jit, ctx, asm, cme, flags, argc, iseq, block_handler, opt_pc, send_shift:, frame_type:, prev_ep:)
- end
-
- # vm_call_iseq_setup_normal (vm_call_iseq_setup_2 -> vm_call_iseq_setup_normal)
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_iseq_setup_normal(jit, ctx, asm, cme, flags, argc, iseq, block_handler, opt_pc, send_shift:, frame_type:, prev_ep:)
- # We will not have side exits from here. Adjust the stack.
- if flags & C::VM_CALL_OPT_SEND != 0
- jit_call_opt_send_shift_stack(ctx, asm, argc, send_shift:)
- end
-
- # Save caller SP and PC before pushing a callee frame for backtrace and side exits
- asm.comment('save SP to caller CFP')
- recv_idx = argc + (flags & C::VM_CALL_ARGS_BLOCKARG != 0 ? 1 : 0) # blockarg is not popped yet
- # Skip setting this to SP register. This cfp->sp will be copied to SP on leave insn.
- asm.lea(:rax, ctx.sp_opnd(C.VALUE.size * -(1 + recv_idx))) # Pop receiver and arguments to prepare for side exits
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:sp)], :rax)
- jit_save_pc(jit, asm, comment: 'save PC to caller CFP')
-
- frame_type ||= C::VM_FRAME_MAGIC_METHOD | C::VM_ENV_FLAG_LOCAL
- jit_push_frame(
- jit, ctx, asm, cme, flags, argc, frame_type, block_handler,
- iseq: iseq,
- local_size: iseq.body.local_table_size - iseq.body.param.size,
- stack_max: iseq.body.stack_max,
- prev_ep:,
- )
-
- # Jump to a stub for the callee ISEQ
- callee_ctx = Context.new
- pc = (iseq.body.iseq_encoded + opt_pc).to_i
- jit_direct_jump(iseq, pc, callee_ctx, asm)
-
- EndBlock
- end
-
- # vm_call_cfunc
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_cfunc(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- if jit_caller_setup_arg(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
- if jit_caller_remove_empty_kw_splat(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
-
- jit_call_cfunc_with_frame(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- end
-
- # jit_call_cfunc_with_frame
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_cfunc_with_frame(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- cfunc = cme.def.body.cfunc
-
- if argc + 1 > 6
- asm.incr_counter(:send_cfunc_too_many_args)
- return CantCompile
- end
-
- frame_type = C::VM_FRAME_MAGIC_CFUNC | C::VM_FRAME_FLAG_CFRAME | C::VM_ENV_FLAG_LOCAL
- if flags & C::VM_CALL_KW_SPLAT != 0
- frame_type |= C::VM_FRAME_FLAG_CFRAME_KW
- end
-
- # EXEC_EVENT_HOOK: RUBY_EVENT_C_CALL and RUBY_EVENT_C_RETURN
- if C.rb_rjit_global_events & (C::RUBY_EVENT_C_CALL | C::RUBY_EVENT_C_RETURN) != 0
- asm.incr_counter(:send_c_tracing)
- return CantCompile
- end
-
- # rb_check_arity
- if cfunc.argc >= 0 && argc != cfunc.argc
- asm.incr_counter(:send_arity)
- return CantCompile
- end
- if cfunc.argc == -2
- asm.incr_counter(:send_cfunc_ruby_array_varg)
- return CantCompile
- end
-
- # Delegate to codegen for C methods if we have it.
- if flags & C::VM_CALL_KWARG == 0 && flags & C::VM_CALL_OPT_SEND == 0
- known_cfunc_codegen = lookup_cfunc_codegen(cme.def)
- if known_cfunc_codegen&.call(jit, ctx, asm, argc, known_recv_class)
- # cfunc codegen generated code. Terminate the block so
- # there isn't multiple calls in the same block.
- jump_to_next_insn(jit, ctx, asm)
- return EndBlock
- end
- end
-
- # We will not have side exits from here. Adjust the stack.
- if flags & C::VM_CALL_OPT_SEND != 0
- jit_call_opt_send_shift_stack(ctx, asm, argc, send_shift:)
- end
-
- # Check interrupts before SP motion to safely side-exit with the original SP.
- jit_check_ints(jit, ctx, asm)
-
- # Save caller SP and PC before pushing a callee frame for backtrace and side exits
- asm.comment('save SP to caller CFP')
- sp_index = -(1 + argc + (flags & C::VM_CALL_ARGS_BLOCKARG != 0 ? 1 : 0)) # Pop receiver and arguments for side exits. blockarg is not popped yet
- asm.lea(SP, ctx.sp_opnd(C.VALUE.size * sp_index))
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:sp)], SP)
- ctx.sp_offset = -sp_index
- jit_save_pc(jit, asm, comment: 'save PC to caller CFP')
-
- # Push a callee frame. SP register and ctx are not modified inside this.
- jit_push_frame(jit, ctx, asm, cme, flags, argc, frame_type, block_handler)
-
- asm.comment('call C function')
- case cfunc.argc
- in (0..) # Non-variadic method
- # Push receiver and args
- (1 + argc).times do |i|
- asm.mov(C_ARGS[i], ctx.stack_opnd(argc - i)) # TODO: +1 for VM_CALL_ARGS_BLOCKARG
- end
- in -1 # Variadic method: rb_f_puts(int argc, VALUE *argv, VALUE recv)
- asm.mov(C_ARGS[0], argc)
- asm.lea(C_ARGS[1], ctx.stack_opnd(argc - 1)) # argv
- asm.mov(C_ARGS[2], ctx.stack_opnd(argc)) # recv
- end
- asm.mov(:rax, cfunc.func)
- asm.call(:rax) # TODO: use rel32 if close enough
- ctx.stack_pop(1 + argc)
-
- Invariants.record_global_inval_patch(asm, full_cfunc_return)
-
- asm.comment('push the return value')
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
-
- asm.comment('pop the stack frame')
- asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], CFP)
-
- # Let guard chains share the same successor (ctx.sp_offset == 1)
- assert_equal(1, ctx.sp_offset)
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- end
-
- # vm_call_ivar (+ part of vm_call_method_each_type)
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_ivar(jit, ctx, asm, cme, flags, argc, comptime_recv, recv_opnd, send_shift:)
- if flags & C::VM_CALL_ARGS_SPLAT != 0
- asm.incr_counter(:send_ivar_splat)
- return CantCompile
- end
-
- if argc != 0
- asm.incr_counter(:send_arity)
- return CantCompile
- end
-
- # We don't support jit_call_opt_send_shift_stack for this yet.
- if flags & C::VM_CALL_OPT_SEND != 0
- asm.incr_counter(:send_ivar_opt_send)
- return CantCompile
- end
-
- ivar_id = cme.def.body.attr.id
-
- # Not handling block_handler
- if flags & C::VM_CALL_ARGS_BLOCKARG != 0
- asm.incr_counter(:send_ivar_blockarg)
- return CantCompile
- end
-
- jit_getivar(jit, ctx, asm, comptime_recv, ivar_id, recv_opnd)
- end
-
- # vm_call_bmethod
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_bmethod(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- proc_addr = cme.def.body.bmethod.proc
-
- proc_t = C.rb_yjit_get_proc_ptr(proc_addr)
- proc_block = proc_t.block
-
- if proc_block.type != C.block_type_iseq
- asm.incr_counter(:send_bmethod_not_iseq)
- return CantCompile
- end
-
- capture = proc_block.as.captured
- iseq = capture.code.iseq
-
- # TODO: implement this
- # Optimize for single ractor mode and avoid runtime check for
- # "defined with an un-shareable Proc in a different Ractor"
- # if !assume_single_ractor_mode(jit, ocb)
- # return CantCompile;
- # end
-
- # Passing a block to a block needs logic different from passing
- # a block to a method and sometimes requires allocation. Bail for now.
- if block_handler != C::VM_BLOCK_HANDLER_NONE
- asm.incr_counter(:send_bmethod_blockarg)
- return CantCompile
- end
-
- frame_type = C::VM_FRAME_MAGIC_BLOCK | C::VM_FRAME_FLAG_BMETHOD | C::VM_FRAME_FLAG_LAMBDA
- prev_ep = capture.ep
- jit_call_iseq_setup(jit, ctx, asm, cme, flags, argc, iseq, block_handler, send_shift:, frame_type:, prev_ep:)
- end
-
- # vm_call_alias
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_alias(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- cme = C.rb_aliased_callable_method_entry(cme)
- jit_call_method_each_type(jit, ctx, asm, argc, flags, cme, comptime_recv, recv_opnd, block_handler, known_recv_class, send_shift:)
- end
-
- # vm_call_optimized
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_optimized(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- if flags & C::VM_CALL_ARGS_BLOCKARG != 0
- # Not working yet
- asm.incr_counter(:send_optimized_blockarg)
- return CantCompile
- end
-
- case cme.def.body.optimized.type
- in C::OPTIMIZED_METHOD_TYPE_SEND
- jit_call_opt_send(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- in C::OPTIMIZED_METHOD_TYPE_CALL
- jit_call_opt_call(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- in C::OPTIMIZED_METHOD_TYPE_BLOCK_CALL
- asm.incr_counter(:send_optimized_block_call)
- return CantCompile
- in C::OPTIMIZED_METHOD_TYPE_STRUCT_AREF
- jit_call_opt_struct_aref(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- in C::OPTIMIZED_METHOD_TYPE_STRUCT_ASET
- asm.incr_counter(:send_optimized_struct_aset)
- return CantCompile
- end
- end
-
- # vm_call_opt_send
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_opt_send(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- if jit_caller_setup_arg(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
-
- if argc == 0
- asm.incr_counter(:send_optimized_send_no_args)
- return CantCompile
- end
-
- argc -= 1
- # We aren't handling `send(:send, ...)` yet. This might work, but not tested yet.
- if send_shift > 0
- asm.incr_counter(:send_optimized_send_send)
- return CantCompile
- end
- # Ideally, we want to shift the stack here, but it's not safe until you reach the point
- # where you never exit. `send_shift` signals to lazily shift the stack by this amount.
- send_shift += 1
-
- kw_splat = flags & C::VM_CALL_KW_SPLAT != 0
- jit_call_symbol(jit, ctx, asm, cme, C::VM_CALL_FCALL, argc, kw_splat, block_handler, known_recv_class, send_shift:)
- end
-
- # vm_call_opt_call
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_opt_call(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- if block_handler != C::VM_BLOCK_HANDLER_NONE
- asm.incr_counter(:send_optimized_call_block)
- return CantCompile
- end
-
- if flags & C::VM_CALL_KWARG != 0
- asm.incr_counter(:send_optimized_call_kwarg)
- return CantCompile
- end
-
- if flags & C::VM_CALL_ARGS_SPLAT != 0
- asm.incr_counter(:send_optimized_call_splat)
- return CantCompile
- end
-
- # TODO: implement this
- # Optimize for single ractor mode and avoid runtime check for
- # "defined with an un-shareable Proc in a different Ractor"
- # if !assume_single_ractor_mode(jit, ocb)
- # return CantCompile
- # end
-
- # If this is a .send call we need to adjust the stack
- if flags & C::VM_CALL_OPT_SEND != 0
- jit_call_opt_send_shift_stack(ctx, asm, argc, send_shift:)
- end
-
- # About to reset the SP, need to load this here
- recv_idx = argc # blockarg is not supported. send_shift is already handled.
- asm.mov(:rcx, ctx.stack_opnd(recv_idx)) # recv
-
- # Save the PC and SP because the callee can make Ruby calls
- jit_prepare_routine_call(jit, ctx, asm) # NOTE: clobbers rax
-
- asm.lea(:rax, ctx.sp_opnd(0)) # sp
-
- kw_splat = flags & C::VM_CALL_KW_SPLAT
-
- asm.mov(C_ARGS[0], :rcx)
- asm.mov(C_ARGS[1], EC)
- asm.mov(C_ARGS[2], argc)
- asm.lea(C_ARGS[3], [:rax, -argc * C.VALUE.size]) # stack_argument_pointer. NOTE: C_ARGS[3] is rcx
- asm.mov(C_ARGS[4], kw_splat)
- asm.mov(C_ARGS[5], C::VM_BLOCK_HANDLER_NONE)
- asm.call(C.rjit_optimized_call)
-
- ctx.stack_pop(argc + 1)
-
- stack_ret = ctx.stack_push
- asm.mov(stack_ret, C_RET)
- return KeepCompiling
- end
-
- # vm_call_opt_struct_aref
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_opt_struct_aref(jit, ctx, asm, cme, flags, argc, block_handler, known_recv_class, send_shift:)
- if argc != 0
- asm.incr_counter(:send_optimized_struct_aref_error)
- return CantCompile
- end
-
- off = cme.def.body.optimized.index
-
- recv_idx = argc # blockarg is not supported
- recv_idx += send_shift
- comptime_recv = jit.peek_at_stack(recv_idx)
-
- # This is a .send call and we need to adjust the stack
- if flags & C::VM_CALL_OPT_SEND != 0
- jit_call_opt_send_shift_stack(ctx, asm, argc, send_shift:)
- end
-
- # All structs from the same Struct class should have the same
- # length. So if our comptime_recv is embedded all runtime
- # structs of the same class should be as well, and the same is
- # true of the converse.
- embedded = C::FL_TEST_RAW(comptime_recv, C::RSTRUCT_EMBED_LEN_MASK)
-
- asm.comment('struct aref')
- asm.mov(:rax, ctx.stack_pop(1)) # recv
-
- if embedded
- asm.mov(:rax, [:rax, C.RStruct.offsetof(:as, :ary) + (C.VALUE.size * off)])
- else
- asm.mov(:rax, [:rax, C.RStruct.offsetof(:as, :heap, :ptr)])
- asm.mov(:rax, [:rax, C.VALUE.size * off])
- end
-
- ret = ctx.stack_push
- asm.mov(ret, :rax)
-
- jump_to_next_insn(jit, ctx, asm)
- EndBlock
- end
-
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_opt_send_shift_stack(ctx, asm, argc, send_shift:)
- # We don't support `send(:send, ...)` for now.
- assert_equal(1, send_shift)
-
- asm.comment('shift stack')
- (0...argc).reverse_each do |i|
- opnd = ctx.stack_opnd(i)
- opnd2 = ctx.stack_opnd(i + 1)
- asm.mov(:rax, opnd)
- asm.mov(opnd2, :rax)
- end
-
- ctx.stack_pop(1)
- end
-
- # vm_call_symbol
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_call_symbol(jit, ctx, asm, cme, flags, argc, kw_splat, block_handler, known_recv_class, send_shift:)
- flags |= C::VM_CALL_OPT_SEND | (kw_splat ? C::VM_CALL_KW_SPLAT : 0)
-
- comptime_symbol = jit.peek_at_stack(argc)
- if comptime_symbol.class != String && !static_symbol?(comptime_symbol)
- asm.incr_counter(:send_optimized_send_not_sym_or_str)
- return CantCompile
- end
-
- mid = C.get_symbol_id(comptime_symbol)
- if mid == 0
- asm.incr_counter(:send_optimized_send_null_mid)
- return CantCompile
- end
-
- asm.comment("Guard #{comptime_symbol.inspect} is on stack")
- class_changed_exit = counted_exit(side_exit(jit, ctx), :send_optimized_send_mid_class_changed)
- jit_guard_known_klass(jit, ctx, asm, C.rb_class_of(comptime_symbol), ctx.stack_opnd(argc), comptime_symbol, class_changed_exit)
- asm.mov(C_ARGS[0], ctx.stack_opnd(argc))
- asm.call(C.rb_get_symbol_id)
- asm.cmp(C_RET, mid)
- id_changed_exit = counted_exit(side_exit(jit, ctx), :send_optimized_send_mid_id_changed)
- jit_chain_guard(:jne, jit, ctx, asm, id_changed_exit)
-
- # rb_callable_method_entry_with_refinements
- cme, _ = jit_search_method(jit, ctx, asm, mid, argc, flags, send_shift:)
- if cme == CantCompile
- return CantCompile
- end
-
- if flags & C::VM_CALL_FCALL != 0
- return jit_call_method(jit, ctx, asm, mid, argc, flags, cme, block_handler, known_recv_class, send_shift:)
- end
-
- raise NotImplementedError # unreachable for now
- end
-
- # vm_push_frame
- #
- # Frame structure:
- # | args | locals | cme/cref | block_handler/prev EP | frame type (EP here) | stack bottom (SP here)
- #
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_push_frame(jit, ctx, asm, cme, flags, argc, frame_type, block_handler, iseq: nil, local_size: 0, stack_max: 0, prev_ep: nil)
- # CHECK_VM_STACK_OVERFLOW0: next_cfp <= sp + (local_size + stack_max)
- asm.comment('stack overflow check')
- asm.lea(:rax, ctx.sp_opnd(C.rb_control_frame_t.size + C.VALUE.size * (local_size + stack_max)))
- asm.cmp(CFP, :rax)
- asm.jbe(counted_exit(side_exit(jit, ctx), :send_stackoverflow))
-
- # Pop blockarg after all side exits
- if flags & C::VM_CALL_ARGS_BLOCKARG != 0
- ctx.stack_pop(1)
- end
-
- if iseq
- # This was not handled in jit_callee_setup_arg
- opts_filled = argc - iseq.body.param.lead_num # TODO: kwarg
- opts_missing = iseq.body.param.opt_num - opts_filled
- local_size += opts_missing
- end
- local_size.times do |i|
- asm.comment('set local variables') if i == 0
- local_index = ctx.sp_offset + i
- asm.mov([SP, C.VALUE.size * local_index], Qnil)
- end
-
- asm.comment('set up EP with managing data')
- ep_offset = ctx.sp_offset + local_size + 2
- # ep[-2]: cref_or_me
- asm.mov(:rax, cme.to_i)
- asm.mov([SP, C.VALUE.size * (ep_offset - 2)], :rax)
- # ep[-1]: block handler or prev env ptr (specval)
- if prev_ep
- asm.mov(:rax, prev_ep.to_i | 1) # tagged prev ep
- asm.mov([SP, C.VALUE.size * (ep_offset - 1)], :rax)
- elsif block_handler == C::VM_BLOCK_HANDLER_NONE
- asm.mov([SP, C.VALUE.size * (ep_offset - 1)], C::VM_BLOCK_HANDLER_NONE)
- elsif block_handler == C.rb_block_param_proxy
- # vm_caller_setup_arg_block: block_code == rb_block_param_proxy
- jit_get_lep(jit, asm, reg: :rax) # VM_CF_BLOCK_HANDLER: VM_CF_LEP
- asm.mov(:rax, [:rax, C.VALUE.size * C::VM_ENV_DATA_INDEX_SPECVAL]) # VM_CF_BLOCK_HANDLER: VM_ENV_BLOCK_HANDLER
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:block_code)], :rax) # reg_cfp->block_code = handler
- asm.mov([SP, C.VALUE.size * (ep_offset - 1)], :rax) # return handler;
- else # assume blockiseq
- asm.mov(:rax, block_handler)
- asm.mov([CFP, C.rb_control_frame_t.offsetof(:block_code)], :rax)
- asm.lea(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)]) # VM_CFP_TO_CAPTURED_BLOCK
- asm.or(:rax, 1) # VM_BH_FROM_ISEQ_BLOCK
- asm.mov([SP, C.VALUE.size * (ep_offset - 1)], :rax)
- end
- # ep[-0]: ENV_FLAGS
- asm.mov([SP, C.VALUE.size * (ep_offset - 0)], frame_type)
-
- asm.comment('set up new frame')
- cfp_offset = -C.rb_control_frame_t.size # callee CFP
- # For ISEQ, JIT code will set it as needed. However, C func needs 0 there for svar frame detection.
- if iseq.nil?
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:pc)], 0)
- end
- asm.mov(:rax, iseq.to_i)
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:iseq)], :rax)
- self_index = ctx.sp_offset - (1 + argc) # blockarg has been popped
- asm.mov(:rax, [SP, C.VALUE.size * self_index])
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:self)], :rax)
- asm.lea(:rax, [SP, C.VALUE.size * ep_offset])
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:ep)], :rax)
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:block_code)], 0)
- # Update SP register only for ISEQ calls. SP-relative operations should be done above this.
- sp_reg = iseq ? SP : :rax
- asm.lea(sp_reg, [SP, C.VALUE.size * (ctx.sp_offset + local_size + 3)])
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:sp)], sp_reg)
- asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:__bp__)], sp_reg) # TODO: get rid of this!!
-
- # cfp->jit_return is used only for ISEQs
- if iseq
- # Stub cfp->jit_return
- return_ctx = ctx.dup
- return_ctx.stack_size -= argc # Pop args. blockarg has been popped
- return_ctx.sp_offset = 1 # SP is in the position after popping a receiver and arguments
- return_ctx.chain_depth = 0
- branch_stub = BranchStub.new(
- iseq: jit.iseq,
- shape: Default,
- target0: BranchTarget.new(ctx: return_ctx, pc: jit.pc + jit.insn.len * C.VALUE.size),
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(return_ctx, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.compile = proc do |branch_asm|
- branch_asm.comment('set jit_return to callee CFP')
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.mov(:rax, branch_stub.target0.address)
- branch_asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:jit_return)], :rax)
- end
- end
- end
- branch_stub.compile.call(asm)
- end
-
- asm.comment('switch to callee CFP')
- # Update CFP register only for ISEQ calls
- cfp_reg = iseq ? CFP : :rax
- asm.lea(cfp_reg, [CFP, cfp_offset])
- asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], cfp_reg)
- end
-
- # vm_callee_setup_arg: Set up args and return opt_pc (or CantCompile)
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_callee_setup_arg(jit, ctx, asm, flags, argc, iseq)
- if flags & C::VM_CALL_KW_SPLAT == 0
- if C.rb_simple_iseq_p(iseq)
- if jit_caller_setup_arg(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
- if jit_caller_remove_empty_kw_splat(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
-
- if argc != iseq.body.param.lead_num
- # argument_arity_error
- return CantCompile
- end
-
- return 0
- elsif C.rb_iseq_only_optparam_p(iseq)
- if jit_caller_setup_arg(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
- if jit_caller_remove_empty_kw_splat(jit, ctx, asm, flags) == CantCompile
- return CantCompile
- end
-
- lead_num = iseq.body.param.lead_num
- opt_num = iseq.body.param.opt_num
- opt = argc - lead_num
-
- if opt < 0 || opt > opt_num
- asm.incr_counter(:send_arity)
- return CantCompile
- end
-
- # Qnil push is handled in jit_push_frame
-
- return iseq.body.param.opt_table[opt]
- elsif C.rb_iseq_only_kwparam_p(iseq) && (flags & C::VM_CALL_ARGS_SPLAT) == 0
- asm.incr_counter(:send_iseq_kwparam)
- return CantCompile
- end
- end
-
- return jit_setup_parameters_complex(jit, ctx, asm, flags, argc, iseq)
- end
-
- # setup_parameters_complex
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_setup_parameters_complex(jit, ctx, asm, flags, argc, iseq)
- # We don't support setup_parameters_complex
- asm.incr_counter(:send_iseq_complex)
- return CantCompile
- end
-
- # CALLER_SETUP_ARG: Return CantCompile if not supported
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_caller_setup_arg(jit, ctx, asm, flags)
- if flags & C::VM_CALL_ARGS_SPLAT != 0
- # We don't support vm_caller_setup_arg_splat
- asm.incr_counter(:send_args_splat)
- return CantCompile
- end
- if flags & (C::VM_CALL_KWARG | C::VM_CALL_KW_SPLAT) != 0
- # We don't support keyword args either
- asm.incr_counter(:send_kwarg)
- return CantCompile
- end
- end
-
- # CALLER_REMOVE_EMPTY_KW_SPLAT: Return CantCompile if not supported
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def jit_caller_remove_empty_kw_splat(jit, ctx, asm, flags)
- if (flags & C::VM_CALL_KW_SPLAT) > 0
- # We don't support removing the last Hash argument
- asm.incr_counter(:send_kw_splat)
- return CantCompile
- end
- end
-
- # Generate RARRAY_LEN. For array_opnd, use Opnd::Reg to reduce memory access,
- # and use Opnd::Mem to save registers.
- def jit_array_len(asm, array_reg, len_reg)
- asm.comment('get array length for embedded or heap')
-
- # Pull out the embed flag to check if it's an embedded array.
- asm.mov(len_reg, [array_reg, C.RBasic.offsetof(:flags)])
-
- # Get the length of the array
- asm.and(len_reg, C::RARRAY_EMBED_LEN_MASK)
- asm.sar(len_reg, C::RARRAY_EMBED_LEN_SHIFT)
-
- # Conditionally move the length of the heap array
- asm.test([array_reg, C.RBasic.offsetof(:flags)], C::RARRAY_EMBED_FLAG)
-
- # Select the array length value
- asm.cmovz(len_reg, [array_reg, C.RArray.offsetof(:as, :heap, :len)])
- end
-
- def assert_equal(left, right)
- if left != right
- raise "'#{left.inspect}' was not '#{right.inspect}'"
- end
- end
-
- def fixnum?(obj)
- (C.to_value(obj) & C::RUBY_FIXNUM_FLAG) == C::RUBY_FIXNUM_FLAG
- end
-
- def flonum?(obj)
- (C.to_value(obj) & C::RUBY_FLONUM_MASK) == C::RUBY_FLONUM_FLAG
- end
-
- def symbol?(obj)
- static_symbol?(obj) || dynamic_symbol?(obj)
- end
-
- def static_symbol?(obj)
- (C.to_value(obj) & 0xff) == C::RUBY_SYMBOL_FLAG
- end
-
- def dynamic_symbol?(obj)
- return false if C::SPECIAL_CONST_P(obj)
- C::RB_TYPE_P(obj, C::RUBY_T_SYMBOL)
- end
-
- def shape_too_complex?(obj)
- C.rb_shape_get_shape_id(obj) == C::OBJ_TOO_COMPLEX_SHAPE_ID
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- # @param asm [RubyVM::RJIT::Assembler]
- def defer_compilation(jit, ctx, asm)
- # Make a stub to compile the current insn
- if ctx.chain_depth != 0
- raise "double defer!"
- end
- ctx.chain_depth += 1
- jit_direct_jump(jit.iseq, jit.pc, ctx, asm, comment: 'defer_compilation')
- end
-
- def jit_direct_jump(iseq, pc, ctx, asm, comment: 'jit_direct_jump')
- branch_stub = BranchStub.new(
- iseq:,
- shape: Default,
- target0: BranchTarget.new(ctx:, pc:),
- )
- branch_stub.target0.address = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
- @ocb.write(ocb_asm)
- end
- branch_stub.compile = proc do |branch_asm|
- branch_asm.comment(comment)
- branch_asm.stub(branch_stub) do
- case branch_stub.shape
- in Default
- branch_asm.jmp(branch_stub.target0.address)
- in Next0
- # Just write the block without a jump
- end
- end
- end
- branch_stub.compile.call(asm)
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param ctx [RubyVM::RJIT::Context]
- def side_exit(jit, ctx)
- if side_exit = jit.side_exits[jit.pc]
- return side_exit
- end
- asm = Assembler.new
- @exit_compiler.compile_side_exit(jit.pc, ctx, asm)
- jit.side_exits[jit.pc] = @ocb.write(asm)
- end
-
- def counted_exit(side_exit, name)
- asm = Assembler.new
- asm.incr_counter(name)
- asm.jmp(side_exit)
- @ocb.write(asm)
- end
-
- def def_iseq_ptr(cme_def)
- C.rb_iseq_check(cme_def.body.iseq.iseqptr)
- end
-
- def to_value(obj)
- GC_REFS << obj
- C.to_value(obj)
- end
-
- def full_cfunc_return
- @full_cfunc_return ||= Assembler.new.then do |asm|
- @exit_compiler.compile_full_cfunc_return(asm)
- @ocb.write(asm)
- end
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/invariants.rb b/lib/ruby_vm/rjit/invariants.rb
deleted file mode 100644
index 8a3fcb4874..0000000000
--- a/lib/ruby_vm/rjit/invariants.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-require 'set'
-
-module RubyVM::RJIT
- class Invariants
- class << self
- # Called by RubyVM::RJIT::Compiler to lazily initialize this
- # @param cb [CodeBlock]
- # @param ocb [CodeBlock]
- # @param compiler [RubyVM::RJIT::Compiler]
- # @param exit_compiler [RubyVM::RJIT::ExitCompiler]
- def initialize(cb, ocb, compiler, exit_compiler)
- @cb = cb
- @ocb = ocb
- @compiler = compiler
- @exit_compiler = exit_compiler
- @bop_blocks = Set.new # TODO: actually invalidate this
- @cme_blocks = Hash.new { |h, k| h[k] = Set.new }
- @const_blocks = Hash.new { |h, k| h[k] = Set.new }
- @patches = {}
-
- # freeze # workaround a binding.irb issue. TODO: resurrect this
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param klass [Integer]
- # @param op [Integer]
- def assume_bop_not_redefined(jit, klass, op)
- return false unless C.BASIC_OP_UNREDEFINED_P(klass, op)
-
- ensure_block_entry_exit(jit, cause: 'assume_bop_not_redefined')
- @bop_blocks << jit.block
- true
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- def assume_method_lookup_stable(jit, cme)
- ensure_block_entry_exit(jit, cause: 'assume_method_lookup_stable')
- @cme_blocks[cme.to_i] << jit.block
- end
-
- def assume_stable_constant_names(jit, idlist)
- (0..).each do |i|
- break if (id = idlist[i]) == 0
- @const_blocks[id] << jit.block
- end
- end
-
- # @param asm [RubyVM::RJIT::Assembler]
- def record_global_inval_patch(asm, target)
- asm.pos_marker do |address|
- if @patches.key?(address)
- raise 'multiple patches in the same address'
- end
- @patches[address] = target
- end
- end
-
- def on_cme_invalidate(cme)
- @cme_blocks.fetch(cme.to_i, []).each do |block|
- @cb.with_write_addr(block.start_addr) do
- asm = Assembler.new
- asm.comment('on_cme_invalidate')
- asm.jmp(block.entry_exit)
- @cb.write(asm)
- end
- # TODO: re-generate branches that refer to this block
- end
- @cme_blocks.delete(cme.to_i)
- end
-
- def on_constant_ic_update(iseq, ic, insn_idx)
- # TODO: check multi ractor as well
- if ic.entry.ic_cref
- # No need to recompile the slowpath
- return
- end
-
- pc = iseq.body.iseq_encoded + insn_idx
- insn_name = Compiler.decode_insn(pc.*).name
- if insn_name != :opt_getconstant_path && insn_name != :trace_opt_getconstant_path
- raise 'insn_idx was not at opt_getconstant_path'
- end
- if ic.to_i != pc[1]
- raise 'insn_idx + 1 was not at the updated IC'
- end
- @compiler.invalidate_blocks(iseq, pc.to_i)
- end
-
- def on_constant_state_changed(id)
- @const_blocks.fetch(id, []).each do |block|
- @compiler.invalidate_block(block)
- end
- end
-
- def on_tracing_invalidate_all
- invalidate_all
- end
-
- def on_update_references
- # Give up. In order to support GC.compact, you'd have to update ISEQ
- # addresses in BranchStub, etc. Ideally, we'd need to update moved
- # pointers in JITed code here, but we just invalidate all for now.
- invalidate_all
- end
-
- # @param jit [RubyVM::RJIT::JITState]
- # @param block [RubyVM::RJIT::Block]
- def ensure_block_entry_exit(jit, cause:)
- block = jit.block
- if block.entry_exit.nil?
- block.entry_exit = Assembler.new.then do |asm|
- @exit_compiler.compile_entry_exit(block.pc, block.ctx, asm, cause:)
- @ocb.write(asm)
- end
- end
- end
-
- private
-
- def invalidate_all
- # On-Stack Replacement
- @patches.each do |address, target|
- # TODO: assert patches don't overlap each other
- @cb.with_write_addr(address) do
- asm = Assembler.new
- asm.comment('on_tracing_invalidate_all')
- asm.jmp(target)
- @cb.write(asm)
- end
- end
- @patches.clear
-
- C.rjit_for_each_iseq do |iseq|
- # Avoid entering past code
- iseq.body.jit_func = 0
- # Avoid reusing past code
- iseq.body.rjit_blocks.clear if iseq.body.rjit_blocks
- # Compile this again if not converted to trace_* insns
- iseq.body.total_calls = 0
- end
- end
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/jit_state.rb b/lib/ruby_vm/rjit/jit_state.rb
deleted file mode 100644
index a365559d17..0000000000
--- a/lib/ruby_vm/rjit/jit_state.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module RubyVM::RJIT
- class JITState < Struct.new(
- :iseq, # @param `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
- :pc, # @param [Integer] The JIT target PC
- :cfp, # @param `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before RJIT is called)
- :block, # @param [RubyVM::RJIT::Block]
- :side_exits, # @param [Hash{ Integer => Integer }] { PC => address }
- :record_boundary_patch_point, # @param [TrueClass,FalseClass]
- )
- def initialize(side_exits: {}, record_boundary_patch_point: false, **) = super
-
- def insn
- Compiler.decode_insn(C.VALUE.new(pc).*)
- end
-
- def operand(index, signed: false, ruby: false)
- addr = pc + (index + 1) * Fiddle::SIZEOF_VOIDP
- value = Fiddle::Pointer.new(addr)[0, Fiddle::SIZEOF_VOIDP].unpack(signed ? 'q' : 'Q')[0]
- if ruby
- value = C.to_ruby(value)
- end
- value
- end
-
- def at_current_insn?
- pc == cfp.pc.to_i
- end
-
- def peek_at_stack(depth_from_top)
- raise 'not at current insn' unless at_current_insn?
- offset = -(1 + depth_from_top)
- # rb_rjit_branch_stub_hit updates SP, so you don't need to worry about sp_offset
- value = (cfp.sp + offset).*
- C.to_ruby(value)
- end
-
- def peek_at_self
- C.to_ruby(cfp.self)
- end
-
- def peek_at_block_handler(level)
- ep = ep_at_level(cfp, level:)
- ep[C::VM_ENV_DATA_INDEX_SPECVAL]
- end
-
- private
-
- def ep_at_level(cfp, level:)
- ep = cfp.ep
- level.times do
- # VM_ENV_PREV_EP
- ep = C.VALUE.new(ep[C::VM_ENV_DATA_INDEX_SPECVAL] & ~0x03)
- end
- ep
- end
- end
-end
diff --git a/lib/ruby_vm/rjit/stats.rb b/lib/ruby_vm/rjit/stats.rb
deleted file mode 100644
index 65bb962aac..0000000000
--- a/lib/ruby_vm/rjit/stats.rb
+++ /dev/null
@@ -1,186 +0,0 @@
-# frozen_string_literal: true
-module RubyVM::RJIT
- def self.runtime_stats
- stats = {}
-
- # Insn exits
- INSNS.each_value do |insn|
- exits = C.rjit_insn_exits[insn.bin]
- if exits > 0
- stats[:"exit_#{insn.name}"] = exits
- end
- end
-
- # Runtime stats
- C.rb_rjit_runtime_counters.members.each do |member|
- stats[member] = C.rb_rjit_counters.public_send(member)
- end
-
- # Other stats are calculated here
- stats[:side_exit_count] = stats.select { |name, _count| name.start_with?('exit_') }.sum(&:last)
- if stats[:vm_insns_count] > 0
- retired_in_rjit = stats[:rjit_insns_count] - stats[:side_exit_count]
- stats[:total_insns_count] = retired_in_rjit + stats[:vm_insns_count]
- stats[:ratio_in_rjit] = 100.0 * retired_in_rjit / stats[:total_insns_count]
- end
-
- stats
- end
-
- class << self
- private
-
- # --yjit-stats at_exit
- def print_stats
- stats = runtime_stats
- $stderr.puts("***RJIT: Printing RJIT statistics on exit***")
-
- print_counters(stats, prefix: 'send_', prompt: 'method call exit reasons')
- print_counters(stats, prefix: 'invokeblock_', prompt: 'invokeblock exit reasons')
- print_counters(stats, prefix: 'invokesuper_', prompt: 'invokesuper exit reasons')
- print_counters(stats, prefix: 'getblockpp_', prompt: 'getblockparamproxy exit reasons')
- print_counters(stats, prefix: 'getivar_', prompt: 'getinstancevariable exit reasons')
- print_counters(stats, prefix: 'setivar_', prompt: 'setinstancevariable exit reasons')
- print_counters(stats, prefix: 'optaref_', prompt: 'opt_aref exit reasons')
- print_counters(stats, prefix: 'optgetconst_', prompt: 'opt_getconstant_path exit reasons')
- print_counters(stats, prefix: 'expandarray_', prompt: 'expandarray exit reasons')
-
- $stderr.puts "compiled_block_count: #{format_number(13, stats[:compiled_block_count])}"
- $stderr.puts "side_exit_count: #{format_number(13, stats[:side_exit_count])}"
- $stderr.puts "total_insns_count: #{format_number(13, stats[:total_insns_count])}" if stats.key?(:total_insns_count)
- $stderr.puts "vm_insns_count: #{format_number(13, stats[:vm_insns_count])}" if stats.key?(:vm_insns_count)
- $stderr.puts "rjit_insns_count: #{format_number(13, stats[:rjit_insns_count])}"
- $stderr.puts "ratio_in_rjit: #{format('%12.1f', stats[:ratio_in_rjit])}%" if stats.key?(:ratio_in_rjit)
-
- print_exit_counts(stats)
- end
-
- def print_counters(stats, prefix:, prompt:)
- $stderr.puts("#{prompt}: ")
- counters = stats.filter { |key, _| key.start_with?(prefix) }
- counters.filter! { |_, value| value != 0 }
- counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) }
-
- if counters.empty?
- $stderr.puts(" (all relevant counters are zero)")
- return
- end
-
- counters = counters.to_a
- counters.sort_by! { |(_, counter_value)| counter_value }
- longest_name_length = counters.max_by { |(name, _)| name.length }.first.length
- total = counters.sum { |(_, counter_value)| counter_value }
-
- counters.reverse_each do |(name, value)|
- percentage = value.fdiv(total) * 100
- $stderr.printf(" %*s %s (%4.1f%%)\n", longest_name_length, name, format_number(10, value), percentage)
- end
- end
-
- def print_exit_counts(stats, how_many: 20, padding: 2)
- exits = stats.filter_map { |name, count| [name.to_s.delete_prefix('exit_'), count] if name.start_with?('exit_') }.to_h
- return if exits.empty?
-
- top_exits = exits.sort_by { |_name, count| -count }.first(how_many).to_h
- total_exits = exits.values.sum
- $stderr.puts "Top-#{top_exits.size} most frequent exit ops (#{format("%.1f", 100.0 * top_exits.values.sum / total_exits)}% of exits):"
-
- name_width = top_exits.map { |name, _count| name.length }.max + padding
- count_width = top_exits.map { |_name, count| format_number(10, count).length }.max + padding
- top_exits.each do |name, count|
- ratio = 100.0 * count / total_exits
- $stderr.puts "#{format("%#{name_width}s", name)}: #{format_number(count_width, count)} (#{format('%4.1f', ratio)}%)"
- end
- end
-
- # Format large numbers with comma separators for readability
- def format_number(pad, number)
- integer, decimal = number.to_s.split('.')
- d_groups = integer.chars.reverse.each_slice(3)
- with_commas = d_groups.map(&:join).join(',').reverse
- [with_commas, decimal].compact.join('.').rjust(pad, ' ')
- end
-
- # --yjit-trace-exits at_exit
- def dump_trace_exits
- filename = "#{Dir.pwd}/rjit_exit_locations.dump"
- File.binwrite(filename, Marshal.dump(exit_traces))
- $stderr.puts("RJIT exit locations dumped to:\n#{filename}")
- end
-
- # Convert rb_rjit_raw_samples and rb_rjit_line_samples into a StackProf format.
- def exit_traces
- results = C.rjit_exit_traces
- raw_samples = results[:raw].dup
- line_samples = results[:lines].dup
- frames = results[:frames].dup
- samples_count = 0
-
- # Loop through the instructions and set the frame hash with the data.
- # We use nonexistent.def for the file name, otherwise insns.def will be displayed
- # and that information isn't useful in this context.
- RubyVM::INSTRUCTION_NAMES.each_with_index do |name, frame_id|
- frame_hash = { samples: 0, total_samples: 0, edges: {}, name: name, file: "nonexistent.def", line: nil, lines: {} }
- results[:frames][frame_id] = frame_hash
- frames[frame_id] = frame_hash
- end
-
- # Loop through the raw_samples and build the hashes for StackProf.
- # The loop is based off an example in the StackProf documentation and therefore
- # this functionality can only work with that library.
- #
- # Raw Samples:
- # [ length, frame1, frame2, frameN, ..., instruction, count
- #
- # Line Samples
- # [ length, line_1, line_2, line_n, ..., dummy value, count
- i = 0
- while i < raw_samples.length
- stack_length = raw_samples[i] + 1
- i += 1 # consume the stack length
-
- prev_frame_id = nil
- stack_length.times do |idx|
- idx += i
- frame_id = raw_samples[idx]
-
- if prev_frame_id
- prev_frame = frames[prev_frame_id]
- prev_frame[:edges][frame_id] ||= 0
- prev_frame[:edges][frame_id] += 1
- end
-
- frame_info = frames[frame_id]
- frame_info[:total_samples] += 1
-
- frame_info[:lines][line_samples[idx]] ||= [0, 0]
- frame_info[:lines][line_samples[idx]][0] += 1
-
- prev_frame_id = frame_id
- end
-
- i += stack_length # consume the stack
-
- top_frame_id = prev_frame_id
- top_frame_line = 1
-
- sample_count = raw_samples[i]
-
- frames[top_frame_id][:samples] += sample_count
- frames[top_frame_id][:lines] ||= {}
- frames[top_frame_id][:lines][top_frame_line] ||= [0, 0]
- frames[top_frame_id][:lines][top_frame_line][1] += sample_count
-
- samples_count += sample_count
- i += 1
- end
-
- results[:samples] = samples_count
- # Set missed_samples and gc_samples to 0 as their values
- # don't matter to us in this context.
- results[:missed_samples] = 0
- results[:gc_samples] = 0
- results
- end
- end
-end
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 756e7ed008..d289cab0fd 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -8,15 +9,15 @@
require "rbconfig"
module Gem
- VERSION = "3.5.0.dev"
+ VERSION = "4.1.0.dev"
end
-# Must be first since it unloads the prelude from 1.9.2
-require_relative "rubygems/compatibility"
-
require_relative "rubygems/defaults"
require_relative "rubygems/deprecate"
require_relative "rubygems/errors"
+require_relative "rubygems/target_rbconfig"
+require_relative "rubygems/win_platform"
+require_relative "rubygems/util/atomic_file_writer"
##
# RubyGems is the Ruby standard for publishing and managing third party
@@ -37,7 +38,7 @@ require_relative "rubygems/errors"
# Further RubyGems documentation can be found at:
#
# * {RubyGems Guides}[https://guides.rubygems.org]
-# * {RubyGems API}[https://www.rubydoc.info/github/rubygems/rubygems] (also available from
+# * {RubyGems API}[https://guides.rubygems.org/rubygems-org-api/] (also available from
# <tt>gem server</tt>)
#
# == RubyGems Plugins
@@ -69,7 +70,7 @@ require_relative "rubygems/errors"
# == Bugs
#
# You can submit bugs to the
-# {RubyGems bug tracker}[https://github.com/rubygems/rubygems/issues]
+# {RubyGems bug tracker}[https://github.com/ruby/rubygems/issues]
# on GitHub
#
# == Credits
@@ -105,7 +106,7 @@ require_relative "rubygems/errors"
#
# == License
#
-# See {LICENSE.txt}[rdoc-ref:lib/rubygems/LICENSE.txt] for permissions.
+# See {LICENSE.txt}[https://github.com/ruby/rubygems/blob/master/LICENSE.txt] for permissions.
#
# Thanks!
#
@@ -114,23 +115,6 @@ require_relative "rubygems/errors"
module Gem
RUBYGEMS_DIR = __dir__
- # Taint support is deprecated in Ruby 2.7.
- # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
- # to avoid deprecation warnings in Ruby 2.7.
- UNTAINT = RUBY_VERSION < "2.7" ? :untaint.to_sym : proc {}
-
- ##
- # An Array of Regexps that match windows Ruby platforms.
-
- WIN_PATTERNS = [
- /bccwin/i,
- /cygwin/i,
- /djgpp/i,
- /mingw/i,
- /mswin/i,
- /wince/i,
- ].freeze
-
GEM_DEP_FILES = %w[
gem.deps.rb
gems.rb
@@ -159,7 +143,12 @@ module Gem
specifications/default
].freeze
- @@win_platform = nil
+ ##
+ # The default value for SOURCE_DATE_EPOCH if not specified.
+ # We want a date after 1980-01-01, to prevent issues with Zip files.
+ # This particular timestamp is for 1980-01-02 00:00:00 GMT.
+
+ DEFAULT_SOURCE_DATE_EPOCH = 315_619_200
@configuration = nil
@gemdeps = nil
@@ -183,6 +172,8 @@ module Gem
@discover_gems_on_require = true
+ @target_rbconfig = nil
+
##
# Try to activate a gem containing +path+. Returns true if
# activation succeeded or wasn't needed because it was already
@@ -202,15 +193,17 @@ module Gem
begin
spec.activate
rescue Gem::LoadError => e # this could fail due to gem dep collisions, go lax
- spec_by_name = Gem::Specification.find_by_name(spec.name)
- if spec_by_name.nil?
+ name = spec.name
+ spec = Gem::Specification.find_unloaded_by_path(path)
+ spec ||= Gem::Specification.find_by_name(name)
+ if spec.nil?
raise e
else
- spec_by_name.activate
+ spec.activate
end
end
- return true
+ true
end
def self.needs
@@ -221,7 +214,7 @@ module Gem
finish_resolve rs
end
- def self.finish_resolve(request_set=Gem::RequestSet.new)
+ def self.finish_resolve(request_set = Gem::RequestSet.new)
request_set.import Gem::Specification.unresolved_deps.values
request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
@@ -243,6 +236,16 @@ module Gem
find_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end
+ def self.find_and_activate_spec_for_exe(name, exec_name, requirements)
+ spec = find_spec_for_exe name, exec_name, requirements
+ Gem::LOADED_SPECS_MUTEX.synchronize do
+ spec.activate
+ finish_resolve
+ end
+ spec
+ end
+ private_class_method :find_and_activate_spec_for_exe
+
def self.find_spec_for_exe(name, exec_name, requirements)
raise ArgumentError, "you must supply exec_name" unless exec_name
@@ -268,6 +271,42 @@ module Gem
private_class_method :find_spec_for_exe
##
+ # Find and load the full path to the executable for gem +name+. If the
+ # +exec_name+ is not given, an exception will be raised, otherwise the
+ # specified executable's path is returned. +requirements+ allows
+ # you to specify specific gem versions.
+ #
+ # A side effect of this method is that it will activate the gem that
+ # contains the executable.
+ #
+ # This method should *only* be used in bin stub files.
+
+ def self.activate_and_load_bin_path(name, exec_name = nil, *requirements)
+ spec = find_and_activate_spec_for_exe name, exec_name, requirements
+
+ if spec.name == "bundler"
+ # Old versions of Bundler need a workaround to support nested `bundle
+ # exec` invocations by overriding `Gem.activate_bin_path`. However,
+ # RubyGems now uses this new `Gem.activate_and_load_bin_path` helper in
+ # binstubs, which is of course not overridden in Bundler since it didn't
+ # exist at the time. So, include the override here to workaround that.
+ load ENV["BUNDLE_BIN_PATH"] if ENV["BUNDLE_BIN_PATH"] && spec.version <= Gem::Version.create("2.5.22")
+
+ # Make sure there's no version of Bundler in `$LOAD_PATH` that's different
+ # from the version we just activated. If that was the case (it happens
+ # when testing Bundler from ruby/ruby), we would load Bundler extensions
+ # to RubyGems from the copy in `$LOAD_PATH` but then load the binstub from
+ # an installed copy, causing those copies to be mixed and yet more
+ # redefinition warnings.
+ #
+ require_path = $LOAD_PATH.resolve_feature_path("bundler").last.delete_suffix("/bundler.rb")
+ Gem.load_bundler_extensions(spec.version) if spec.full_require_paths.include?(require_path)
+ end
+
+ load spec.bin_file(exec_name)
+ end
+
+ ##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, an exception will be raised, otherwise the
# specified executable's path is returned. +requirements+ allows
@@ -279,12 +318,7 @@ module Gem
# This method should *only* be used in bin stub files.
def self.activate_bin_path(name, exec_name = nil, *requirements) # :nodoc:
- spec = find_spec_for_exe name, exec_name, requirements
- Gem::LOADED_SPECS_MUTEX.synchronize do
- spec.activate
- finish_resolve
- end
- spec.bin_file exec_name
+ find_and_activate_spec_for_exe(name, exec_name, requirements).bin_file exec_name
end
##
@@ -297,7 +331,7 @@ module Gem
##
# The path where gem executables are to be installed.
- def self.bindir(install_dir=Gem.dir)
+ def self.bindir(install_dir = Gem.dir)
return File.join install_dir, "bin" unless
install_dir.to_s == Gem.default_dir.to_s
Gem.default_bindir
@@ -306,7 +340,7 @@ module Gem
##
# The path were rubygems plugins are to be installed.
- def self.plugindir(install_dir=Gem.dir)
+ def self.plugindir(install_dir = Gem.dir)
File.join install_dir, "plugins"
end
@@ -318,6 +352,8 @@ module Gem
def self.clear_paths
@paths = nil
@user_home = nil
+ @cache_home = nil
+ @data_home = nil
Gem::Specification.reset
Gem::Security.reset if defined?(Gem::Security)
end
@@ -401,6 +437,23 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
+ # The RbConfig object for the deployment target platform.
+ #
+ # This is usually the same as the running platform, but may be
+ # different if you are cross-compiling.
+
+ def self.target_rbconfig
+ @target_rbconfig || Gem::TargetRbConfig.for_running_ruby
+ end
+
+ def self.set_target_rbconfig(rbconfig_path)
+ @target_rbconfig = Gem::TargetRbConfig.from_path(rbconfig_path)
+ Gem::Platform.local(refresh: true)
+ Gem.platforms << Gem::Platform.local unless Gem.platforms.include? Gem::Platform.local
+ @target_rbconfig
+ end
+
+ ##
# Quietly ensure the Gem directory +dir+ contains all the proper
# subdirectories. If we can't create a directory due to a permission
# problem, then we will silently continue.
@@ -428,7 +481,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
old_umask = File.umask
- File.umask old_umask | 002
+ File.umask old_umask | 0o002
options = {}
@@ -454,7 +507,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# distinction as extensions cannot be shared between the two.
def self.extension_api_version # :nodoc:
- if "no" == RbConfig::CONFIG["ENABLE_SHARED"]
+ if target_rbconfig["ENABLE_SHARED"] == "no"
"#{ruby_api_version}-static"
else
ruby_api_version
@@ -473,29 +526,29 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Note that find_files will return all files even if they are from different
# versions of the same gem. See also find_latest_files
- def self.find_files(glob, check_load_path=true)
+ def self.find_files(glob, check_load_path = true)
files = []
files = find_files_from_load_path glob if check_load_path
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
- files.concat gem_specifications.map {|spec|
+ files.concat gem_specifications.flat_map {|spec|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
- }.flatten
+ }
# $LOAD_PATH might contain duplicate entries or reference
# the spec dirs directly, so we prune.
files.uniq! if check_load_path
- return files
+ files
end
def self.find_files_from_load_path(glob) # :nodoc:
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
- $LOAD_PATH.map do |load_path|
+ $LOAD_PATH.flat_map do |load_path|
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
- end.flatten.select {|file| File.file? file.tap(&Gem::UNTAINT) }
+ end.select {|file| File.file? file }
end
##
@@ -510,20 +563,20 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Unlike find_files, find_latest_files will return only files from the
# latest version of a gem.
- def self.find_latest_files(glob, check_load_path=true)
+ def self.find_latest_files(glob, check_load_path = true)
files = []
files = find_files_from_load_path glob if check_load_path
- files.concat Gem::Specification.latest_specs(true).map {|spec|
+ files.concat Gem::Specification.latest_specs(true).flat_map {|spec|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
- }.flatten
+ }
# $LOAD_PATH might contain duplicate entries or reference
# the spec dirs directly, so we prune.
files.uniq! if check_load_path
- return files
+ files
end
##
@@ -571,7 +624,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# The number of paths in the +$LOAD_PATH+ from activated gems. Used to
- # prioritize +-I+ and +ENV['RUBYLIB']+ entries during +require+.
+ # prioritize +-I+ and <code>ENV['RUBYLIB']</code> entries during +require+.
def self.activated_gem_paths
@activated_gem_paths ||= 0
@@ -588,6 +641,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
@yaml_loaded = false
+ @use_psych = nil
+
+ ##
+ # Returns true if the Psych YAML parser is enabled via configuration.
+
+ def self.use_psych?
+ @use_psych || false
+ end
##
# Loads YAML, preferring Psych
@@ -595,14 +656,54 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.load_yaml
return if @yaml_loaded
- require "psych"
- require_relative "rubygems/psych_tree"
+ @use_psych = ENV["RUBYGEMS_USE_PSYCH"] == "true" ||
+ (defined?(@configuration) && @configuration && !@configuration[:use_psych].nil?)
+
+ if @use_psych
+ require "psych"
+ require_relative "rubygems/psych_tree"
+ end
+ require_relative "rubygems/yaml_serializer"
require_relative "rubygems/safe_yaml"
@yaml_loaded = true
end
+ @safe_marshal_loaded = false
+
+ def self.load_safe_marshal
+ return if @safe_marshal_loaded
+
+ require_relative "rubygems/safe_marshal"
+
+ @safe_marshal_loaded = true
+ end
+
+ ##
+ # Load Bundler extensions to RubyGems, making sure to avoid redefinition
+ # warnings in platform constants
+
+ def self.load_bundler_extensions(version)
+ return unless version <= Gem::Version.create("2.6.9")
+
+ previous_platforms = {}
+
+ platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"]
+
+ platform_const_list.each do |platform|
+ previous_platforms[platform] = Gem::Platform.const_get(platform)
+ Gem::Platform.send(:remove_const, platform)
+ end
+
+ require "bundler/rubygems_ext"
+
+ platform_const_list.each do |platform|
+ Gem::Platform.send(:remove_const, platform) if Gem::Platform.const_defined?(platform)
+ Gem::Platform.const_set(platform, previous_platforms[platform])
+ end
+ end
+
##
# The file name and line number of the caller of the caller of this method.
#
@@ -731,7 +832,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
if prefix != File.expand_path(RbConfig::CONFIG["sitelibdir"]) &&
prefix != File.expand_path(RbConfig::CONFIG["libdir"]) &&
- "lib" == File.basename(RUBYGEMS_DIR)
+ File.basename(RUBYGEMS_DIR) == "lib"
prefix
end
end
@@ -747,48 +848,58 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Safely read a file in binary mode on all platforms.
def self.read_binary(path)
- open_file(path, "rb+") do |io|
- io.read
- end
- rescue Errno::EACCES, Errno::EROFS
- open_file(path, "rb") do |io|
- io.read
- end
+ File.binread(path)
end
##
- # Safely write a file in binary mode on all platforms.
+ # Atomically write a file in binary mode on all platforms.
+
def self.write_binary(path, data)
- open_file(path, "wb") do |io|
- io.write data
+ Gem::AtomicFileWriter.open(path) do |file|
+ file.write(data)
end
- rescue Errno::ENOSPC
- # If we ran out of space but the file exists, it's *guaranteed* to be corrupted.
- File.delete(path) if File.exist?(path)
- raise
end
##
- # Open a file with given flags, and on Windows protect access with flock
+ # Open a file with given flags
def self.open_file(path, flags, &block)
- File.open(path, flags) do |io|
- if !java_platform? && win_platform?
- begin
+ File.open(path, flags, &block)
+ end
+
+ ##
+ # Open a file with given flags, and protect access with a file lock
+
+ def self.open_file_with_lock(path, &block)
+ file_lock = "#{path}.lock"
+ open_file_with_flock(file_lock, &block)
+ ensure
+ require "fileutils"
+ FileUtils.rm_f file_lock
+ end
+
+ ##
+ # Open a file with given flags, and protect access with flock
+
+ def self.open_file_with_flock(path, &block)
+ # read-write mode is used rather than read-only in order to support NFS
+ mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
+ mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
+
+ File.open(path, mode) do |io|
+ begin
+ # Try to get a lock without blocking.
+ # If we do, the file is locked.
+ # Otherwise, explain why we're waiting and get a lock, but block this time.
+ if io.flock(File::LOCK_EX | File::LOCK_NB) != 0
+ warn "Waiting for another process to let go of lock: #{path}"
io.flock(File::LOCK_EX)
- rescue Errno::ENOSYS, Errno::ENOTSUP
end
+ io.puts(Process.pid)
+ rescue Errno::ENOSYS, Errno::ENOTSUP
end
yield io
end
- rescue Errno::ENOLCK # NFS
- if Thread.main != Thread.current
- raise
- else
- File.open(path, flags) do |io|
- yield io
- end
- end
end
##
@@ -798,7 +909,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
if @ruby.nil?
@ruby = RbConfig.ruby
- @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/
+ @ruby = "\"#{@ruby}\"" if /\s/.match?(@ruby)
end
@ruby
@@ -808,7 +919,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Returns a String containing the API compatibility version of Ruby
def self.ruby_api_version
- @ruby_api_version ||= RbConfig::CONFIG["ruby_version"].dup
+ @ruby_api_version ||= target_rbconfig["ruby_version"].dup
end
def self.env_requirement(gem_name)
@@ -941,6 +1052,13 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
+ # Suffixes for dynamic library require-able paths.
+
+ def self.dynamic_library_suffixes
+ @dynamic_library_suffixes ||= suffixes - [".rb"]
+ end
+
+ ##
# Prints the amount of time the supplied block takes to run using the debug
# UI output.
@@ -951,7 +1069,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
elapsed = Time.now - now
- ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
+ ui.say format("%2$*1$s: %3$3.3fs", -width, msg, elapsed) if display
value
end
@@ -978,18 +1096,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
- # Is this a windows platform?
-
- def self.win_platform?
- if @@win_platform.nil?
- ruby_platform = RbConfig::CONFIG["host_os"]
- @@win_platform = !!WIN_PATTERNS.find {|r| ruby_platform =~ r }
- end
-
- @@win_platform
- end
-
- ##
# Is this a java platform?
def self.java_platform?
@@ -1004,6 +1110,13 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
##
+ # Is this platform FreeBSD
+
+ def self.freebsd_platform?
+ RbConfig::CONFIG["host_os"].to_s.include?("bsd")
+ end
+
+ ##
# Load +plugins+ as Ruby files
def self.load_plugin_files(plugins) # :nodoc:
@@ -1011,11 +1124,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Skip older versions of the GemCutter plugin: Its commands are in
# RubyGems proper now.
- next if plugin =~ /gemcutter-0\.[0-3]/
+ next if /gemcutter-0\.[0-3]/.match?(plugin)
begin
load plugin
- rescue ::Exception => e
+ rescue ScriptError, StandardError => e
details = "#{plugin.inspect}: #{e.message} (#{e.class})"
warn "Error loading RubyGems plugin #{details}"
end
@@ -1077,8 +1190,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
end
end
- path.tap(&Gem::UNTAINT)
-
unless File.file? path
return unless raise_exception
@@ -1090,13 +1201,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
require "bundler"
begin
Gem::DefaultUserInteraction.use_ui(ui) do
- begin
- Bundler.ui.silence do
- @gemdeps = Bundler.setup
- end
- ensure
- Gem::DefaultUserInteraction.ui.close
+ Bundler.ui.silence do
+ @gemdeps = Bundler.setup
end
+ ensure
+ Gem::DefaultUserInteraction.ui.close
end
rescue Bundler::BundlerError => e
warn e.message
@@ -1107,8 +1216,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# If the SOURCE_DATE_EPOCH environment variable is set, returns it's value.
- # Otherwise, returns the time that +Gem.source_date_epoch_string+ was
- # first called in the same format as SOURCE_DATE_EPOCH.
+ # Otherwise, returns DEFAULT_SOURCE_DATE_EPOCH as a string.
#
# NOTE(@duckinator): The implementation is a tad weird because we want to:
# 1. Make builds reproducible by default, by having this function always
@@ -1123,15 +1231,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# https://reproducible-builds.org/specs/source-date-epoch/
def self.source_date_epoch_string
- # The value used if $SOURCE_DATE_EPOCH is not set.
- @default_source_date_epoch ||= Time.now.to_i.to_s
-
specified_epoch = ENV["SOURCE_DATE_EPOCH"]
# If it's empty or just whitespace, treat it like it wasn't set at all.
specified_epoch = nil if !specified_epoch.nil? && specified_epoch.strip.empty?
- epoch = specified_epoch || @default_source_date_epoch
+ epoch = specified_epoch || DEFAULT_SOURCE_DATE_EPOCH.to_s
epoch.strip
end
@@ -1142,7 +1247,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# This is used throughout RubyGems for enabling reproducible builds.
def self.source_date_epoch
- Time.at(self.source_date_epoch_string.to_i).utc.freeze
+ Time.at(source_date_epoch_string.to_i).utc.freeze
end
# FIX: Almost everywhere else we use the `def self.` way of defining class
@@ -1195,10 +1300,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
prefix_pattern = /^(#{prefix_group})/
end
+ native_extension_suffixes = Gem.dynamic_library_suffixes.reject(&:empty?)
+
spec.files.each do |file|
if new_format
file = file.sub(prefix_pattern, "")
- next unless $~
+ unless $~
+ # Also register native extension files (e.g. date_core.bundle)
+ # that are listed without require path prefix in the gemspec
+ next if file.include?("/")
+ next unless file.end_with?(*native_extension_suffixes)
+ end
end
spec.activate if already_loaded?(file)
@@ -1211,9 +1323,16 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# Find a Gem::Specification of default gem from +path+
+ def find_default_spec(path)
+ @path_to_default_spec_map[path]
+ end
+
+ ##
+ # Find an unresolved Gem::Specification of default gem from +path+
+
def find_unresolved_default_spec(path)
default_spec = @path_to_default_spec_map[path]
- return default_spec if default_spec && loaded_specs[default_spec.name] != default_spec
+ default_spec if default_spec && loaded_specs[default_spec.name] != default_spec
end
##
@@ -1289,9 +1408,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
##
# Location of Marshal quick gemspecs on remote repositories
- MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
+ MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/".freeze
autoload :ConfigFile, File.expand_path("rubygems/config_file", __dir__)
+ autoload :CIDetector, File.expand_path("rubygems/ci_detector", __dir__)
autoload :Dependency, File.expand_path("rubygems/dependency", __dir__)
autoload :DependencyList, File.expand_path("rubygems/dependency_list", __dir__)
autoload :Installer, File.expand_path("rubygems/installer", __dir__)
@@ -1314,9 +1434,7 @@ require_relative "rubygems/specification"
# REFACTOR: This should be pulled out into some kind of hacks file.
begin
- ##
# Defaults the operating system (or packager) wants to provide for RubyGems.
-
require "rubygems/defaults/operating_system"
rescue LoadError
# Ignored
@@ -1331,9 +1449,7 @@ rescue StandardError => e
end
begin
- ##
# Defaults the Ruby implementation wants to provide for RubyGems
-
require "rubygems/defaults/#{RUBY_ENGINE}"
rescue LoadError
end
@@ -1347,7 +1463,7 @@ require_relative "rubygems/core_ext/kernel_gem"
path = File.join(__dir__, "rubygems/core_ext/kernel_require.rb")
# When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
if RUBY_ENGINE == "truffleruby" ||
- (RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.0")
+ RUBY_ENGINE == "ruby"
file = "<internal:#{path}>"
else
require_relative "rubygems/core_ext/kernel_warn"
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index a06e506737..0af80cc3db 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class Gem::AvailableSet
include Enumerable
@@ -69,7 +70,7 @@ class Gem::AvailableSet
end
def all_specs
- @set.map {|t| t.spec }
+ @set.map(&:spec)
end
def match_platform!
@@ -104,14 +105,14 @@ class Gem::AvailableSet
def to_request_set(development = :none)
request_set = Gem::RequestSet.new
- request_set.development = :all == development
+ request_set.development = development == :all
each_spec do |spec|
request_set.always_install << spec
request_set.gem spec.name, spec.version
request_set.import spec.development_dependencies if
- :shallow == development
+ development == :shallow
end
request_set
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index e33c2bc915..0ed7fc60bb 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# BasicSpecification is an abstract class which implements some common code
# used by both Specification and StubSpecification.
@@ -33,15 +34,6 @@ class Gem::BasicSpecification
internal_init
end
- def self.default_specifications_dir
- Gem.default_specifications_dir
- end
-
- class << self
- extend Gem::Deprecate
- rubygems_deprecate :default_specifications_dir, "Gem.default_specifications_dir"
- end
-
##
# The path to the gem.build_complete file within the extension install
# directory.
@@ -70,32 +62,57 @@ class Gem::BasicSpecification
# Return true if this spec can require +file+.
def contains_requirable_file?(file)
- if @ignored
- return false
- elsif missing_extensions?
- @ignored = true
-
- if Gem::Platform::RUBY == platform || Gem::Platform.local === platform
- warn "Ignoring #{full_name} because its extensions are not built. " +
+ if ignored?
+ if platform == Gem::Platform::RUBY || Gem::Platform.local === platform
+ warn "Ignoring #{full_name} because its extensions are not built. " \
"Try: gem pristine #{name} --version #{version}"
end
return false
end
- have_file? file, Gem.suffixes
+ is_soext = file.end_with?(".so", ".o")
+
+ if is_soext
+ have_file? file.delete_suffix(File.extname(file)), Gem.dynamic_library_suffixes
+ else
+ have_file? file, Gem.suffixes
+ end
+ end
+
+ ##
+ # Return true if this spec should be ignored because it's missing extensions.
+
+ def ignored?
+ return @ignored unless @ignored.nil?
+
+ @ignored = missing_extensions?
end
def default_gem?
- loaded_from &&
+ !loaded_from.nil? &&
File.dirname(loaded_from) == Gem.default_specifications_dir
end
##
+ # Regular gems take precedence over default gems
+
+ def default_gem_priority
+ default_gem? ? 1 : -1
+ end
+
+ ##
+ # Gems higher up in +gem_path+ take precedence
+
+ def base_dir_priority(gem_path)
+ gem_path.index(base_dir) || gem_path.size
+ end
+
+ ##
# Returns full path to the directory where gem's extensions are installed.
def extension_dir
- @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).tap(&Gem::UNTAINT)
+ @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name))
end
##
@@ -108,20 +125,17 @@ class Gem::BasicSpecification
end
def find_full_gem_path # :nodoc:
- # TODO: also, shouldn't it default to full_name if it hasn't been written?
- path = File.expand_path File.join(gems_dir, full_name)
- path.tap(&Gem::UNTAINT)
- path
+ File.expand_path File.join(gems_dir, full_name)
end
private :find_full_gem_path
##
# The full path to the gem (install path + full name).
+ #
+ # TODO: This is duplicated with #gem_dir. Eventually either of them should be deprecated.
def full_gem_path
- # TODO: This is a heavily used method by gems, so we'll need
- # to aleast just alias it to #gem_dir rather than remove it.
@full_gem_path ||= find_full_gem_path
end
@@ -132,9 +146,22 @@ class Gem::BasicSpecification
def full_name
if platform == Gem::Platform::RUBY || platform.nil?
- "#{name}-#{version}".dup.tap(&Gem::UNTAINT)
+ "#{name}-#{version}"
+ else
+ "#{name}-#{version}-#{platform}"
+ end
+ end
+
+ ##
+ # Returns the full name of this Gem (see `Gem::BasicSpecification#full_name`).
+ # Information about where the gem is installed is also included if not
+ # installed in the default GEM_HOME.
+
+ def full_name_with_location
+ if base_dir != Gem.dir
+ "#{full_name} in #{base_dir}"
else
- "#{name}-#{version}-#{platform}".dup.tap(&Gem::UNTAINT)
+ full_name
end
end
@@ -146,7 +173,7 @@ class Gem::BasicSpecification
@full_require_paths ||=
begin
full_paths = raw_require_paths.map do |path|
- File.join full_gem_path, path.tap(&Gem::UNTAINT)
+ File.join full_gem_path, path
end
full_paths << extension_dir if have_extensions?
@@ -160,9 +187,12 @@ class Gem::BasicSpecification
def datadir
# TODO: drop the extra ", gem_name" which is uselessly redundant
- File.expand_path(File.join(gems_dir, full_name, "data", name)).tap(&Gem::UNTAINT)
+ File.expand_path(File.join(gems_dir, full_name, "data", name))
end
+ extend Gem::Deprecate
+ rubygems_deprecate :datadir, :none, "4.1"
+
##
# Full path of the target library file.
# If the file is not in this gem, return nil.
@@ -170,27 +200,25 @@ class Gem::BasicSpecification
def to_fullpath(path)
if activated?
@paths_map ||= {}
- @paths_map[path] ||=
- begin
- fullpath = nil
- suffixes = Gem.suffixes
- suffixes.find do |suf|
- full_require_paths.find do |dir|
- File.file?(fullpath = "#{dir}/#{path}#{suf}")
- end
- end ? fullpath : nil
+ Gem.suffixes.each do |suf|
+ full_require_paths.each do |dir|
+ fullpath = "#{dir}/#{path}#{suf}"
+ next unless File.file?(fullpath)
+ @paths_map[path] ||= fullpath
end
- else
- nil
+ end
+ @paths_map[path]
end
end
##
# Returns the full path to this spec's gem directory.
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
+ #
+ # TODO: This is duplicated with #full_gem_path. Eventually either of them should be deprecated.
def gem_dir
- @gem_dir ||= File.expand_path File.join(gems_dir, full_name)
+ @gem_dir ||= find_full_gem_path
end
##
@@ -222,6 +250,13 @@ class Gem::BasicSpecification
raise NotImplementedError
end
+ def installable_on_platform?(target_platform) # :nodoc:
+ return true if [Gem::Platform::RUBY, nil, target_platform].include?(platform)
+ return true if Gem::Platform.new(platform) === target_platform
+
+ false
+ end
+
def raw_require_paths # :nodoc:
raise NotImplementedError
end
@@ -271,9 +306,9 @@ class Gem::BasicSpecification
# Return all files in this gem that match for +glob+.
def matches_for_glob(glob) # TODO: rename?
- glob = File.join(self.lib_dirs_glob, glob)
+ glob = File.join(lib_dirs_glob, glob)
- Dir[glob].map {|f| f.tap(&Gem::UNTAINT) } # FIX our tests are broken, run w/ SAFE=1
+ Dir[glob]
end
##
@@ -288,17 +323,17 @@ class Gem::BasicSpecification
# for this spec.
def lib_dirs_glob
- dirs = if self.raw_require_paths
- if self.raw_require_paths.size > 1
- "{#{self.raw_require_paths.join(",")}}"
+ dirs = if raw_require_paths
+ if raw_require_paths.size > 1
+ "{#{raw_require_paths.join(",")}}"
else
- self.raw_require_paths.first
+ raw_require_paths.first
end
else
"lib" # default value for require_paths for bundler/inline
end
- "#{self.full_gem_path}/#{dirs}".dup.tap(&Gem::UNTAINT)
+ "#{full_gem_path}/#{dirs}"
end
##
@@ -335,7 +370,7 @@ class Gem::BasicSpecification
def have_file?(file, suffixes)
return true if raw_require_paths.any? do |path|
- base = File.join(gems_dir, full_name, path.tap(&Gem::UNTAINT), file).tap(&Gem::UNTAINT)
+ base = File.join(gems_dir, full_name, path, file)
suffixes.any? {|suf| File.file? base + suf }
end
diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb
index cd51c37c59..bbe7bf0ab5 100644
--- a/lib/rubygems/bundler_version_finder.rb
+++ b/lib/rubygems/bundler_version_finder.rb
@@ -2,11 +2,17 @@
module Gem::BundlerVersionFinder
def self.bundler_version
+ bcv = bundle_config_version
+ return if bcv == "system"
+
v = ENV["BUNDLER_VERSION"]
+ v = nil if v&.empty?
v ||= bundle_update_bundler_version
return if v == true
+ v ||= bcv unless bcv == "lockfile"
+
v ||= lockfile_version
return unless v
@@ -21,7 +27,7 @@ module Gem::BundlerVersionFinder
end
def self.bundle_update_bundler_version
- return unless File.basename($0) == "bundle"
+ return unless ["bundle", "bundler"].include? File.basename($0)
return unless "update".start_with?(ARGV.first || " ")
bundler_version = nil
update_index = nil
@@ -46,13 +52,74 @@ module Gem::BundlerVersionFinder
private_class_method :lockfile_version
def self.lockfile_contents
+ gemfile = gemfile_path
+
+ return unless gemfile
+
+ lockfile = ENV["BUNDLE_LOCKFILE"]
+ lockfile = nil if lockfile&.empty?
+
+ lockfile ||= case gemfile
+ when "gems.rb" then "gems.locked"
+ else "#{gemfile}.lock"
+ end
+
+ return unless File.file?(lockfile)
+
+ File.read(lockfile)
+ end
+ private_class_method :lockfile_contents
+
+ def self.bundle_config_version
+ env_version = ENV["BUNDLE_VERSION"]
+ return env_version if env_version && !env_version.empty?
+
+ version = nil
+
+ [bundler_local_config_file, bundler_global_config_file].each do |config_file|
+ next unless config_file && File.file?(config_file)
+
+ contents = File.read(config_file)
+ contents =~ /^BUNDLE_VERSION:\s*["']?([^"'\s]+)["']?\s*$/
+
+ version = $1
+ break if version
+ end
+
+ version
+ end
+ private_class_method :bundle_config_version
+
+ def self.bundler_global_config_file
+ # see Bundler::Settings#global_config_file
+ if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
+ ENV["BUNDLE_CONFIG"]
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
+ ENV["BUNDLE_USER_CONFIG"]
+ elsif ENV["BUNDLE_USER_HOME"] && !ENV["BUNDLE_USER_HOME"].empty?
+ ENV["BUNDLE_USER_HOME"] + "config"
+ elsif Gem.user_home && !Gem.user_home.empty?
+ Gem.user_home + ".bundle/config"
+ end
+ end
+ private_class_method :bundler_global_config_file
+
+ def self.bundler_local_config_file
+ gemfile = gemfile_path
+ return unless gemfile
+
+ File.join(File.dirname(gemfile), ".bundle", "config")
+ end
+ private_class_method :bundler_local_config_file
+
+ def self.gemfile_path
gemfile = ENV["BUNDLE_GEMFILE"]
gemfile = nil if gemfile&.empty?
unless gemfile
begin
Gem::Util.traverse_parents(Dir.pwd) do |directory|
- next unless gemfile = Gem::GEM_DEP_FILES.find {|f| File.file?(f.tap(&Gem::UNTAINT)) }
+ next unless gemfile = Gem::GEM_DEP_FILES.find {|f| File.file?(f) }
gemfile = File.join directory, gemfile
break
@@ -62,16 +129,7 @@ module Gem::BundlerVersionFinder
end
end
- return unless gemfile
-
- lockfile = case gemfile
- when "gems.rb" then "gems.locked"
- else "#{gemfile}.lock"
- end.dup.tap(&Gem::UNTAINT)
-
- return unless File.file?(lockfile)
-
- File.read(lockfile)
+ gemfile
end
- private_class_method :lockfile_contents
+ private_class_method :gemfile_path
end
diff --git a/lib/rubygems/ci_detector.rb b/lib/rubygems/ci_detector.rb
new file mode 100644
index 0000000000..7a2d4ee29a
--- /dev/null
+++ b/lib/rubygems/ci_detector.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module Gem
+ module CIDetector
+ # NOTE: Any changes made here will need to be made to both lib/rubygems/ci_detector.rb and
+ # bundler/lib/bundler/ci_detector.rb (which are enforced duplicates).
+ # TODO: Drop that duplication once bundler drops support for RubyGems 3.4
+ #
+ # ## Recognized CI providers, their signifiers, and the relevant docs ##
+ #
+ # Travis CI - CI, TRAVIS https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
+ # Cirrus CI - CI, CIRRUS_CI https://cirrus-ci.org/guide/writing-tasks/#environment-variables
+ # Circle CI - CI, CIRCLECI https://circleci.com/docs/variables/#built-in-environment-variables
+ # Gitlab CI - CI, GITLAB_CI https://docs.gitlab.com/ee/ci/variables/
+ # AppVeyor - CI, APPVEYOR https://www.appveyor.com/docs/environment-variables/
+ # CodeShip - CI_NAME https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables#_default_environment_variables
+ # dsari - CI, DSARI https://github.com/rfinnie/dsari#running
+ # Jenkins - BUILD_NUMBER https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
+ # TeamCity - TEAMCITY_VERSION https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
+ # Appflow - CI_BUILD_ID https://ionic.io/docs/appflow/automation/environments#predefined-environments
+ # TaskCluster - TASKCLUSTER_ROOT_URL https://docs.taskcluster.net/docs/manual/design/env-vars
+ # Semaphore - CI, SEMAPHORE https://docs.semaphoreci.com/ci-cd-environment/environment-variables/
+ # BuildKite - CI, BUILDKITE https://buildkite.com/docs/pipelines/environment-variables
+ # GoCD - GO_SERVER_URL https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html
+ # GH Actions - CI, GITHUB_ACTIONS https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
+ #
+ # ### Some "standard" ENVs that multiple providers may set ###
+ #
+ # * CI - this is set by _most_ (but not all) CI providers now; it's approaching a standard.
+ # * CI_NAME - Not as frequently used, but some providers set this to specify their own name
+
+ # Any of these being set is a reasonably reliable indicator that we are
+ # executing in a CI environment.
+ ENV_INDICATORS = [
+ "CI",
+ "CI_NAME",
+ "CONTINUOUS_INTEGRATION",
+ "BUILD_NUMBER",
+ "CI_APP_ID",
+ "CI_BUILD_ID",
+ "CI_BUILD_NUMBER",
+ "RUN_ID",
+ "TASKCLUSTER_ROOT_URL",
+ ].freeze
+
+ # For each CI, this env suffices to indicate that we're on _that_ CI's
+ # containers. (A few of them only supply a CI_NAME variable, which is also
+ # nice). And if they set "CI" but we can't tell which one they are, we also
+ # want to know that - a bare "ci" without another token tells us as much.
+ ENV_DESCRIPTORS = {
+ "TRAVIS" => "travis",
+ "CIRCLECI" => "circle",
+ "CIRRUS_CI" => "cirrus",
+ "DSARI" => "dsari",
+ "SEMAPHORE" => "semaphore",
+ "JENKINS_URL" => "jenkins",
+ "BUILDKITE" => "buildkite",
+ "GO_SERVER_URL" => "go",
+ "GITLAB_CI" => "gitlab",
+ "GITHUB_ACTIONS" => "github",
+ "TASKCLUSTER_ROOT_URL" => "taskcluster",
+ "CI" => "ci",
+ }.freeze
+
+ def self.ci?
+ ENV_INDICATORS.any? {|var| ENV.include?(var) }
+ end
+
+ def self.ci_strings
+ matching_names = ENV_DESCRIPTORS.select {|env, _| ENV[env] }.values
+ matching_names << ENV["CI_NAME"].downcase if ENV["CI_NAME"]
+ matching_names.reject(&:empty?).sort.uniq
+ end
+ end
+end
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index f459dbf868..d38363f293 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require_relative "optparse"
+require_relative "vendored_optparse"
require_relative "requirement"
require_relative "user_interaction"
@@ -19,9 +20,7 @@ require_relative "user_interaction"
class Gem::Command
include Gem::UserInteraction
- Gem::OptionParser.accept Symbol do |value|
- value.to_sym
- end
+ Gem::OptionParser.accept Symbol, &:to_sym
##
# The name of the command.
@@ -118,7 +117,7 @@ class Gem::Command
# Unhandled arguments (gem names, files, etc.) are left in
# <tt>options[:args]</tt>.
- def initialize(command, summary=nil, defaults={})
+ def initialize(command, summary = nil, defaults = {})
@command = command
@summary = summary
@program_name = "gem #{command}"
@@ -191,7 +190,7 @@ class Gem::Command
"Please specify at least one gem name (e.g. gem build GEMNAME)"
end
- args.select {|arg| arg !~ /^-/ }
+ args.reject {|arg| arg.start_with?("-") }
end
##
@@ -315,7 +314,7 @@ class Gem::Command
options[:build_args] = build_args
if options[:silent]
- old_ui = self.ui
+ old_ui = ui
self.ui = ui = Gem::SilentUI.new
end
@@ -397,22 +396,21 @@ class Gem::Command
def check_deprecated_options(options)
options.each do |option|
- if option_is_deprecated?(option)
- deprecation = @deprecated_options[command][option]
- version_to_expire = deprecation["rg_version_to_expire"]
+ next unless option_is_deprecated?(option)
+ deprecation = @deprecated_options[command][option]
+ version_to_expire = deprecation["rg_version_to_expire"]
- deprecate_option_msg = if version_to_expire
- "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
- else
- "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
- end
+ deprecate_option_msg = if version_to_expire
+ "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}."
+ else
+ "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems."
+ end
- extra_msg = deprecation["extra_msg"]
+ extra_msg = deprecation["extra_msg"]
- deprecate_option_msg += " #{extra_msg}" if extra_msg
+ deprecate_option_msg += " #{extra_msg}" if extra_msg
- alert_warning(deprecate_option_msg)
- end
+ alert_warning(deprecate_option_msg)
end
end
@@ -429,12 +427,10 @@ class Gem::Command
# True if the command handles the given argument list.
def handles?(args)
- begin
- parser.parse!(args.dup)
- return true
- rescue
- return false
- end
+ parser.parse!(args.dup)
+ true
+ rescue StandardError
+ false
end
##
@@ -461,7 +457,7 @@ class Gem::Command
until extra.empty? do
ex = []
ex << extra.shift
- ex << extra.shift if extra.first.to_s =~ /^[^-]/
+ ex << extra.shift if /^[^-]/.match?(extra.first.to_s)
result << ex if handles?(ex)
end
@@ -477,7 +473,7 @@ class Gem::Command
private
def option_is_deprecated?(option)
- @deprecated_options[command].has_key?(option)
+ @deprecated_options[command].key?(option)
end
def add_parser_description # :nodoc:
@@ -489,7 +485,7 @@ class Gem::Command
@parser.separator nil
@parser.separator " Description:"
- formatted.split("\n").each do |line|
+ formatted.each_line do |line|
@parser.separator " #{line.rstrip}"
end
end
@@ -516,8 +512,8 @@ class Gem::Command
@parser.separator nil
@parser.separator " #{title}:"
- content.split(/\n/).each do |line|
- @parser.separator " #{line}"
+ content.each_line do |line|
+ @parser.separator " #{line.rstrip}"
end
end
@@ -526,7 +522,7 @@ class Gem::Command
@parser.separator nil
@parser.separator " Summary:"
- wrap(@summary, 80 - 4).split("\n").each do |line|
+ wrap(@summary, 80 - 4).each_line do |line|
@parser.separator " #{line.strip}"
end
end
@@ -654,9 +650,6 @@ RubyGems is a package manager for Ruby.
gem help platforms gem platforms guide
gem help <COMMAND> show help on COMMAND
(e.g. 'gem help install')
- gem server present a web page at
- http://localhost:8808/
- with info about installed gems
Further information:
https://guides.rubygems.org
HELP
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index f8b9796b37..76b2fba835 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -57,8 +58,8 @@ class Gem::CommandManager
:owner,
:pristine,
:push,
- :query,
:rdoc,
+ :rebuild,
:search,
:server,
:signin,
@@ -83,7 +84,7 @@ class Gem::CommandManager
# Return the authoritative instance of the command manager.
def self.instance
- @command_manager ||= new
+ @instance ||= new
end
##
@@ -98,14 +99,14 @@ class Gem::CommandManager
# Reset the authoritative instance of the command manager.
def self.reset
- @command_manager = nil
+ @instance = nil
end
##
# Register all the subcommands supported by the gem command.
def initialize
- require "timeout"
+ require_relative "vendored_timeout"
@commands = {}
BUILTIN_COMMANDS.each do |name|
@@ -116,7 +117,7 @@ class Gem::CommandManager
##
# Register the Symbol +command+ as a gem command.
- def register_command(command, obj=false)
+ def register_command(command, obj = false)
@commands[command] = obj
end
@@ -140,15 +141,15 @@ class Gem::CommandManager
# Return a sorted list of all command names as strings.
def command_names
- @commands.keys.collect {|key| key.to_s }.sort
+ @commands.keys.collect(&:to_s).sort
end
##
# Run the command specified by +args+.
- def run(args, build_args=nil)
+ def run(args, build_args = nil)
process_args(args, build_args)
- rescue StandardError, Timeout::Error => ex
+ rescue StandardError, Gem::Timeout::Error => ex
if ex.respond_to?(:detailed_message)
msg = ex.detailed_message(highlight: false).sub(/\A(.*?)(?: \(.+?\))/) { $1 }
else
@@ -163,7 +164,7 @@ class Gem::CommandManager
terminate_interaction(1)
end
- def process_args(args, build_args=nil)
+ def process_args(args, build_args = nil)
if args.empty?
say Gem::Command::HELP
terminate_interaction 1
@@ -228,18 +229,16 @@ class Gem::CommandManager
def load_and_instantiate(command_name)
command_name = command_name.to_s
const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command"
- load_error = nil
begin
begin
require "rubygems/commands/#{command_name}_command"
- rescue LoadError => e
- load_error = e
+ rescue LoadError
+ # it may have been defined from a rubygems_plugin.rb file
end
- Gem::Commands.const_get(const_name).new
- rescue Exception => e
- e = load_error if load_error
+ Gem::Commands.const_get(const_name).new
+ rescue StandardError => e
alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}")
ui.backtrace e
end
@@ -248,6 +247,7 @@ class Gem::CommandManager
def invoke_command(args, build_args)
cmd_name = args.shift.downcase
cmd = find_command cmd_name
+ terminate_interaction 1 unless cmd
cmd.deprecation_warning if cmd.deprecated?
cmd.invoke_with_build_args args, build_args
end
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index 1dd4de8c48..cfe1f8ec3c 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -1,10 +1,13 @@
# frozen_string_literal: true
+
require_relative "../command"
+require_relative "../gemspec_helpers"
require_relative "../package"
require_relative "../version_option"
class Gem::Commands::BuildCommand < Gem::Command
include Gem::VersionOption
+ include Gem::GemspecHelpers
def initialize
super "build", "Build a gem from a gemspec"
@@ -22,13 +25,6 @@ class Gem::Commands::BuildCommand < Gem::Command
add_option "-o", "--output FILE", "output gem with the given filename" do |value, options|
options[:output] = value
end
-
- add_option "-C PATH", "Run as if gem build was started in <PATH> instead of the current working directory." do |value, options|
- options[:build_path] = value
- end
- deprecate_option "-C",
- version: "4.0",
- extra_msg: "-C is a global flag now. Use `gem -C PATH build GEMSPEC_FILE [options]` instead"
end
def arguments # :nodoc:
@@ -74,17 +70,6 @@ Gems can be saved to a specified filename with the output option:
private
- def find_gemspec(glob = "*.gemspec")
- gemspecs = Dir.glob(glob).sort
-
- if gemspecs.size > 1
- alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
- terminate_interaction(1)
- end
-
- gemspecs.first
- end
-
def build_gem
gemspec = resolve_gem_name
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index e7fcfdca4e..fe03841ddb 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../security"
class Gem::Commands::CertCommand < Gem::Command
def initialize
super "cert", "Manage RubyGems certificates and signing settings",
- :add => [], :remove => [], :list => [], :build => [], :sign => []
+ add: [], remove: [], list: [], build: [], sign: []
add_option("-a", "--add CERT",
"Add a trusted certificate.") do |cert_file, options|
@@ -157,7 +158,7 @@ class Gem::Commands::CertCommand < Gem::Command
cert = Gem::Security.create_cert_email(
email,
key,
- (Gem::Security::ONE_DAY * expiration_length_days)
+ Gem::Security::ONE_DAY * expiration_length_days
)
Gem::Security.write cert, "gem-public_cert.pem"
@@ -177,9 +178,9 @@ class Gem::Commands::CertCommand < Gem::Command
algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
key = Gem::Security.create_key(algorithm)
- key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
+ key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase
- return key, key_path
+ [key, key_path]
end
def certificates_matching(filter)
@@ -290,7 +291,7 @@ For further reading on signing gems see `ri Gem::Security`.
cert = File.read cert_file
cert = OpenSSL::X509::Certificate.new cert
- permissions = File.stat(cert_file).mode & 0777
+ permissions = File.stat(cert_file).mode & 0o777
issuer_cert = options[:issuer_cert]
issuer_key = options[:key]
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 4d1f8782b1..fb23dd9cb4 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
require_relative "../validator"
@@ -9,7 +10,7 @@ class Gem::Commands::CheckCommand < Gem::Command
def initialize
super "check", "Check a gem repository for added or missing files",
- :alien => true, :doctor => false, :dry_run => false, :gems => true
+ alien: true, doctor: false, dry_run: false, gems: true
add_option("-a", "--[no-]alien",
'Report "unmanaged" or rogue files in the',
@@ -40,17 +41,21 @@ class Gem::Commands::CheckCommand < Gem::Command
def check_gems
say "Checking gems..."
say
- gems = get_all_gem_names rescue []
+ gems = begin
+ get_all_gem_names
+ rescue StandardError
+ []
+ end
Gem::Validator.new.alien(gems).sort.each do |key, val|
- unless val.empty?
+ if val.empty?
+ say "#{key} is error-free" if Gem.configuration.verbose
+ else
say "#{key} has #{val.size} problems"
val.each do |error_entry|
say " #{error_entry.path}:"
say " #{error_entry.problem}"
end
- else
- say "#{key} is error-free" if Gem.configuration.verbose
end
say
end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 86c61bc336..c89a24eee9 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../dependency_list"
require_relative "../uninstaller"
@@ -7,8 +8,8 @@ class Gem::Commands::CleanupCommand < Gem::Command
def initialize
super "cleanup",
"Clean up old versions of installed gems",
- :force => false, :install_dir => Gem.dir,
- :check_dev => true
+ force: false, install_dir: Gem.dir,
+ check_dev: true
add_option("-n", "-d", "--dry-run",
"Do not uninstall gems") do |_value, options|
@@ -37,8 +38,6 @@ class Gem::Commands::CleanupCommand < Gem::Command
@default_gems = []
@full = nil
@gems_to_cleanup = nil
- @original_home = nil
- @original_path = nil
@primary_gems = nil
end
@@ -74,7 +73,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
until done do
clean_gems
- this_set = @gems_to_cleanup.map {|spec| spec.full_name }.sort
+ this_set = @gems_to_cleanup.map(&:full_name).sort
done = this_set.empty? || last_set == this_set
@@ -87,16 +86,13 @@ If no gems are named all gems in GEM_HOME are cleaned.
say "Clean up complete"
verbose do
- skipped = @default_gems.map {|spec| spec.full_name }
+ skipped = @default_gems.map(&:full_name)
"Skipped default gems: #{skipped.join ", "}"
end
end
def clean_gems
- @original_home = Gem.dir
- @original_path = Gem.path
-
get_primary_gems
get_candidate_gems
get_gems_to_cleanup
@@ -111,17 +107,15 @@ If no gems are named all gems in GEM_HOME are cleaned.
deps.reverse_each do |spec|
uninstall_dep spec
end
-
- Gem::Specification.reset
end
def get_candidate_gems
- @candidate_gems = unless options[:args].empty?
- options[:args].map do |gem_name|
- Gem::Specification.find_all_by_name gem_name
- end.flatten
- else
+ @candidate_gems = if options[:args].empty?
Gem::Specification.to_a
+ else
+ options[:args].flat_map do |gem_name|
+ Gem::Specification.find_all_by_name gem_name
+ end
end
end
@@ -130,11 +124,9 @@ If no gems are named all gems in GEM_HOME are cleaned.
@primary_gems[spec.name].version != spec.version
end
- default_gems, gems_to_cleanup = gems_to_cleanup.partition do |spec|
- spec.default_gem?
- end
+ default_gems, gems_to_cleanup = gems_to_cleanup.partition(&:default_gem?)
- uninstall_from = options[:user_install] ? Gem.user_dir : @original_home
+ uninstall_from = options[:user_install] ? Gem.user_dir : Gem.dir
gems_to_cleanup = gems_to_cleanup.select do |spec|
spec.base_dir == uninstall_from
@@ -167,8 +159,8 @@ If no gems are named all gems in GEM_HOME are cleaned.
say "Attempting to uninstall #{spec.full_name}"
uninstall_options = {
- :executables => false,
- :version => "= #{spec.version}",
+ executables: false,
+ version: "= #{spec.version}",
}
uninstall_options[:user_install] = Gem.user_dir == spec.base_dir
@@ -182,8 +174,5 @@ If no gems are named all gems in GEM_HOME are cleaned.
say "Unable to uninstall #{spec.full_name}:"
say "\t#{e.class}: #{e.message}"
end
- ensure
- # Restore path Gem::Uninstaller may have changed
- Gem.use_paths @original_home, *@original_path
end
end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 314b50e93e..d4f9871868 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
@@ -7,8 +8,8 @@ class Gem::Commands::ContentsCommand < Gem::Command
def initialize
super "contents", "Display the contents of the installed gems",
- :specdirs => [], :lib_only => false, :prefix => true,
- :show_install_dir => false
+ specdirs: [], lib_only: false, prefix: true,
+ show_install_dir: false
add_version_option
@@ -93,7 +94,7 @@ prefix or only the files that are requireable.
gem_path = spec.full_gem_path
extra = "/{#{spec.require_paths.join ","}}" if options[:lib_only]
glob = "#{gem_path}#{extra}/**/*"
- prefix_re = /#{Regexp.escape(gem_path)}\//
+ prefix_re = %r{#{Regexp.escape(gem_path)}/}
Dir[glob].map do |file|
[gem_path, file.sub(prefix_re, "")]
@@ -101,15 +102,22 @@ prefix or only the files that are requireable.
end
def files_in_default_gem(spec)
- spec.files.map do |file|
- case file
- when /\A#{spec.bindir}\//
- # $' is POSTMATCH
- [RbConfig::CONFIG["bindir"], $']
- when /\.so\z/
- [RbConfig::CONFIG["archdir"], file]
+ spec.files.filter_map do |file|
+ if file.start_with?("#{spec.bindir}/")
+ [RbConfig::CONFIG["bindir"], file.delete_prefix("#{spec.bindir}/")]
else
- [RbConfig::CONFIG["rubylibdir"], file]
+ gem spec.name, spec.version
+
+ require_path = spec.require_paths.find do |path|
+ file.start_with?("#{path}/")
+ end
+
+ requirable_part = file.delete_prefix("#{require_path}/")
+
+ resolve = $LOAD_PATH.resolve_feature_path(requirable_part)&.last
+ next unless resolve
+
+ [resolve.delete_suffix(requirable_part), requirable_part]
end
end
end
@@ -177,12 +185,12 @@ prefix or only the files that are requireable.
@spec_dirs.sort.each {|dir| say dir }
end
- return nil
+ nil
end
def specification_directories # :nodoc:
- options[:specdirs].map do |i|
+ options[:specdirs].flat_map do |i|
[i, File.join(i, "specifications")]
- end.flatten
+ end
end
end
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index a5870e9106..9aaefae999 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
@@ -10,7 +11,7 @@ class Gem::Commands::DependencyCommand < Gem::Command
def initialize
super "dependency",
"Show the dependencies of an installed gem",
- :version => Gem::Requirement.default, :domain => :local
+ version: Gem::Requirement.default, domain: :local
add_version_option
add_platform_option
@@ -89,10 +90,9 @@ use with other commands.
def display_pipe(specs) # :nodoc:
specs.each do |spec|
- unless spec.dependencies.empty?
- spec.dependencies.sort_by {|dep| dep.name }.each do |dep|
- say "#{dep.name} --version '#{dep.requirement}'"
- end
+ next if spec.dependencies.empty?
+ spec.dependencies.sort_by(&:name).each do |dep|
+ say "#{dep.name} --version '#{dep.requirement}'"
end
end
end
@@ -152,7 +152,7 @@ use with other commands.
response = String.new
response << " " * level + "Gem #{spec.full_name}\n"
unless spec.dependencies.empty?
- spec.dependencies.sort_by {|dep| dep.name }.each do |dep|
+ spec.dependencies.sort_by(&:name).each do |dep|
response << " " * level + " #{dep}\n"
end
end
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index d1b7d07a1d..a5eb521a53 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::EnvironmentCommand < Gem::Command
@@ -14,9 +15,10 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
version display the gem format version
remotesources display the remote gem servers
platform display the supported gem platforms
+ credentials display the path where credentials are stored
<omitted> display everything
EOF
- return args.gsub(/^\s+/, "")
+ args.gsub(/^\s+/, "")
end
def description # :nodoc:
@@ -36,6 +38,7 @@ keys:
:verbose: Verbosity of the gem command. false, true, and :really are the
levels
:update_sources: Enable/disable automatic updating of repository metadata
+ :concurrent_downloads: The number of gem downloads to perform concurrently
:backtrace: Print backtrace when RubyGems encounters an error
:gempath: The paths in which to look for gems
:disable_default_gem_server: Force specification of gem server host on push
@@ -87,6 +90,8 @@ lib/rubygems/defaults/operating_system.rb
Gem.sources.to_a.join("\n")
when /^platform/ then
Gem.platforms.join(File::PATH_SEPARATOR)
+ when /^credentials/, /^creds/ then
+ Gem.configuration.credentials_path
when nil then
show_environment
else
@@ -113,6 +118,8 @@ lib/rubygems/defaults/operating_system.rb
out << " - USER INSTALLATION DIRECTORY: #{Gem.user_dir}\n"
+ out << " - CREDENTIALS FILE: #{Gem.configuration.credentials_path}\n"
+
out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
@@ -170,6 +177,6 @@ lib/rubygems/defaults/operating_system.rb
end
end
- return nil
+ nil
end
end
diff --git a/lib/rubygems/commands/exec_command.rb b/lib/rubygems/commands/exec_command.rb
index 3855dc47bb..1feafbdd35 100644
--- a/lib/rubygems/commands/exec_command.rb
+++ b/lib/rubygems/commands/exec_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../dependency_installer"
require_relative "../gem_runner"
@@ -56,8 +57,6 @@ to the same gem path as user-installed gems.
end
def execute
- gem_paths = { "GEM_HOME" => Gem.paths.home, "GEM_PATH" => Gem.paths.path.join(File::PATH_SEPARATOR), "GEM_SPEC_CACHE" => Gem.paths.spec_cache_dir }.compact
-
check_executable
print_command
@@ -73,9 +72,6 @@ to the same gem path as user-installed gems.
end
load!
- ensure
- ENV.update(gem_paths) if gem_paths
- Gem.clear_paths
end
private
@@ -142,7 +138,7 @@ to the same gem path as user-installed gems.
end
def set_gem_exec_install_paths
- home = File.join(Gem.dir, "gem_exec")
+ home = Gem.dir
ENV["GEM_PATH"] = ([home] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = home
@@ -177,6 +173,9 @@ to the same gem path as user-installed gems.
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
terminate_interaction 1
+ rescue Gem::DependencyResolutionError => e
+ alert_error "Error installing #{gem_name}:\n\t#{e.message}"
+ terminate_interaction 2
rescue Gem::GemNotFoundException => e
show_lookup_failure e.name, e.version, e.errors, false
@@ -199,7 +198,7 @@ to the same gem path as user-installed gems.
argv = ARGV.clone
ARGV.replace options[:args]
- exe = executable = options[:executable]
+ executable = options[:executable]
contains_executable = Gem.loaded_specs.values.select do |spec|
spec.executables.include?(executable)
@@ -210,13 +209,22 @@ to the same gem path as user-installed gems.
end
if contains_executable.empty?
- if (spec = Gem.loaded_specs[executable]) && (exe = spec.executable)
- contains_executable << spec
- else
+ spec = Gem.loaded_specs[executable]
+
+ if spec.nil? || spec.executables.empty?
alert_error "Failed to load executable `#{executable}`," \
" are you sure the gem `#{options[:gem_name]}` contains it?"
terminate_interaction 1
end
+
+ if spec.executables.size > 1
+ alert_error "Ambiguous which executable from gem `#{executable}` should be run: " \
+ "the options are #{spec.executables.sort}, specify one via COMMAND, and use `-g` and `-v` to specify gem and version"
+ terminate_interaction 1
+ end
+
+ contains_executable << spec
+ executable = spec.executable
end
if contains_executable.size > 1
@@ -226,8 +234,11 @@ to the same gem path as user-installed gems.
terminate_interaction 1
end
- load Gem.activate_bin_path(contains_executable.first.name, exe, ">= 0.a")
+ old_exe = $0
+ $0 = executable
+ load Gem.activate_bin_path(contains_executable.first.name, executable, ">= 0.a")
ensure
+ $0 = old_exe if old_exe
ARGV.replace argv
end
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 5eb45d259c..8e64a18cee 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
@@ -9,8 +10,8 @@ class Gem::Commands::FetchCommand < Gem::Command
def initialize
defaults = {
- :suggest_alternate => true,
- :version => Gem::Requirement.default,
+ suggest_alternate: true,
+ version: Gem::Requirement.default,
}
super "fetch", "Download a gem and place it in the current directory", defaults
@@ -55,13 +56,24 @@ then repackaging it.
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ " version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:>=2'`"
terminate_interaction 1
end
end
def execute
check_version
+
+ exit_code = fetch_gems
+
+ terminate_interaction exit_code
+ end
+
+ private
+
+ def fetch_gems
+ exit_code = 0
+
version = options[:version]
platform = Gem.platforms.last
@@ -85,10 +97,13 @@ then repackaging it.
if spec.nil?
show_lookup_failure gem_name, gem_version, errors, suppress_suggestions, options[:domain]
+ exit_code |= 2
next
end
source.download spec
say "Downloaded #{spec.full_name}"
end
+
+ exit_code
end
end
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index bc71e60ff0..13be92593b 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -1,85 +1,51 @@
# frozen_string_literal: true
+
require_relative "../command"
-require_relative "../indexer"
-##
-# Generates a index files for use as a gem server.
-#
-# See `gem help generate_index`
+unless defined? Gem::Commands::GenerateIndexCommand
+ class Gem::Commands::GenerateIndexCommand < Gem::Command
+ module RubygemsTrampoline
+ def description # :nodoc:
+ <<~EOF
+ The generate_index command has been moved to the rubygems-generate_index gem.
+ EOF
+ end
-class Gem::Commands::GenerateIndexCommand < Gem::Command
- def initialize
- super "generate_index",
- "Generates the index files for a gem server directory",
- :directory => ".", :build_modern => true
+ def execute
+ alert_error "Install the rubygems-generate_index gem for the generate_index command"
+ end
- add_option "-d", "--directory=DIRNAME",
- "repository base dir containing gems subdir" do |dir, options|
- options[:directory] = File.expand_path dir
+ def invoke_with_build_args(args, build_args)
+ name = "rubygems-generate_index"
+ spec = begin
+ Gem::Specification.find_by_name(name)
+ rescue Gem::LoadError
+ require "rubygems/dependency_installer"
+ Gem.install(name, Gem::Requirement.default, Gem::DependencyInstaller::DEFAULT_OPTIONS).find {|s| s.name == name }
+ end
+
+ # remove the methods defined in this file so that the methods defined in the gem are used instead,
+ # and without a method redefinition warning
+ %w[description execute invoke_with_build_args].each do |method|
+ RubygemsTrampoline.remove_method(method)
+ end
+ self.class.singleton_class.remove_method(:new)
+
+ spec.activate
+ Gem.load_plugin_files spec.matches_for_glob("rubygems_plugin#{Gem.suffix_pattern}")
+
+ self.class.new.invoke_with_build_args(args, build_args)
+ end
end
+ private_constant :RubygemsTrampoline
- add_option "--[no-]modern",
- "Generate indexes for RubyGems",
- "(always true)" do |value, options|
- options[:build_modern] = value
+ # remove_method(:initialize) warns, but removing new does not warn
+ def self.new
+ command = allocate
+ command.send(:initialize, "generate_index", "Generates the index files for a gem server directory (requires rubygems-generate_index)")
+ command
end
- deprecate_option("--modern", version: "4.0", extra_msg: "Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.")
- deprecate_option("--no-modern", version: "4.0", extra_msg: "The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.")
-
- add_option "--update",
- "Update modern indexes with gems added",
- "since the last update" do |value, options|
- options[:update] = value
- end
- end
-
- def defaults_str # :nodoc:
- "--directory . --modern"
- 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. The given directory will be the directory you serve
-as the gem repository.
-
-For `gem generate_index --directory /path/to/repo`, expose /path/to/repo via
-your HTTP server configuration (not /path/to/repo/gems).
-
-When done, it will generate a set of files like this:
-
- gems/*.gem # .gem files you want to
- # index
-
- specs.<version>.gz # specs index
- latest_specs.<version>.gz # latest specs index
- prerelease_specs.<version>.gz # prerelease specs index
- quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
-
-The .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.
- EOF
- end
-
- def execute
- # This is always true because it's the only way now.
- options[:build_modern] = true
-
- if !File.exist?(options[:directory]) ||
- !File.directory?(options[:directory])
- alert_error "unknown directory name #{options[:directory]}."
- terminate_interaction 1
- else
- indexer = Gem::Indexer.new options.delete(:directory), options
-
- if options[:update]
- indexer.update_index
- else
- indexer.generate_index
- end
- end
+ prepend(RubygemsTrampoline)
end
end
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index a4d9f39d9a..664f400561 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::HelpCommand < Gem::Command
@@ -58,7 +59,7 @@ multiple environments. The RubyGems implementation is designed to be
compatible with Bundler's Gemfile format. You can see additional
documentation on the format at:
- http://bundler.io
+ https://bundler.io
RubyGems automatically looks for these gem dependencies files:
@@ -89,7 +90,9 @@ Use #gem to declare which gems you directly depend upon:
To depend on a specific set of versions:
- gem 'rake', '~> 10.3', '>= 10.3.2'
+ gem 'rake', '>= 10.3.2'
+ # or for multiple version restrictions
+ gem 'rake', '>= 10.3.2', "< 13"
RubyGems will require the gem name when activating the gem using
the RUBYGEMS_GEMDEPS environment variable or Gem::use_gemdeps. Use the
@@ -171,7 +174,7 @@ and #platforms methods:
See the bundler Gemfile manual page for a list of platforms supported in a gem
dependencies file.:
- http://bundler.io/v1.6/man/gemfile.5.html
+ https://bundler.io/v2.5/man/gemfile.5.html
Ruby Version and Engine Dependency
==================================
@@ -268,7 +271,7 @@ Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
platform.
EOF
- # NOTE when updating also update Gem::Command::HELP
+ # NOTE: when updating also update Gem::Command::HELP
SUBCOMMANDS = [
["commands", :show_commands],
@@ -323,7 +326,7 @@ platform.
margin_width = 4
- desc_width = @command_manager.command_names.map {|n| n.size }.max + 4
+ desc_width = @command_manager.command_names.map(&:size).max + 4
summary_width = 80 - margin_width - desc_width
wrap_indent = " " * (margin_width + desc_width)
@@ -332,7 +335,7 @@ platform.
@command_manager.command_names.each do |cmd_name|
command = @command_manager[cmd_name]
- next if command.deprecated?
+ next if command&.deprecated?
summary =
if command
@@ -342,7 +345,7 @@ platform.
end
summary = wrap(summary, summary_width).split "\n"
- out << sprintf(format, cmd_name, summary.shift)
+ out << format(format, cmd_name, summary.shift)
until summary.empty? do
out << "#{wrap_indent}#{summary.shift}"
end
diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb
index ced7751ff5..f65c639662 100644
--- a/lib/rubygems/commands/info_command.rb
+++ b/lib/rubygems/commands/info_command.rb
@@ -8,8 +8,8 @@ class Gem::Commands::InfoCommand < Gem::Command
def initialize
super "info", "Show information for the given gem",
- :name => //, :domain => :local, :details => false, :versions => true,
- :installed => nil, :version => Gem::Requirement.default
+ name: //, domain: :local, details: false, versions: true,
+ installed: nil, version: Gem::Requirement.default
add_query_options
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index c04c01f258..6d3beec0b4 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../install_update_options"
require_relative "../dependency_installer"
@@ -22,11 +23,11 @@ class Gem::Commands::InstallCommand < Gem::Command
def initialize
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
- :format_executable => false,
- :lock => true,
- :suggest_alternate => true,
- :version => Gem::Requirement.default,
- :without_groups => [],
+ format_executable: false,
+ lock: true,
+ suggest_alternate: true,
+ version: Gem::Requirement.default,
+ without_groups: [],
})
defaults.merge!(install_update_options)
@@ -47,7 +48,7 @@ class Gem::Commands::InstallCommand < Gem::Command
end
def defaults_str # :nodoc:
- "--both --version '#{Gem::Requirement.default}' --no-force\n" +
+ "--both --version '#{Gem::Requirement.default}' --no-force\n" \
"--install-dir #{Gem.dir} --lock\n" +
install_update_defaults_str
end
@@ -135,18 +136,11 @@ You can use `i` command instead of `install`.
"#{program_name} [options] GEMNAME [GEMNAME ...] -- --build-flags"
end
- def check_install_dir # :nodoc:
- if options[:install_dir] && options[:user_install]
- alert_error "Use --install-dir or --user-install but not both"
- terminate_interaction 1
- end
- end
-
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:>=2'`"
terminate_interaction 1
end
end
@@ -161,7 +155,6 @@ You can use `i` command instead of `install`.
ENV.delete "GEM_PATH" if options[:install_dir].nil?
- check_install_dir
check_version
load_hooks
@@ -170,7 +163,7 @@ You can use `i` command instead of `install`.
show_installed
- say update_suggestion if eglible_for_update?
+ say update_suggestion if eligible_for_update?
terminate_interaction exit_code
end
@@ -231,9 +224,8 @@ You can use `i` command instead of `install`.
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
- rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors, suppress_suggestions
-
+ rescue Gem::DependencyResolutionError => e
+ alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 2
rescue Gem::UnsatisfiableDependencyError => e
show_lookup_failure e.name, e.version, e.errors, suppress_suggestions,
@@ -250,11 +242,7 @@ You can use `i` command instead of `install`.
# Loads post-install hooks
def load_hooks # :nodoc:
- if options[:install_as_default]
- require_relative "../install_default_message"
- else
- require_relative "../install_message"
- end
+ require_relative "../install_message"
require_relative "../rdoc"
end
@@ -262,7 +250,7 @@ You can use `i` command instead of `install`.
return unless errors
errors.each do |x|
- return unless Gem::SourceFetchProblem === x
+ next unless Gem::SourceFetchProblem === x
require_relative "../uri"
msg = "Unable to pull data from '#{Gem::Uri.redact(x.source.uri)}': #{x.error.message}"
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index 011873b99c..fab4b73814 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../query_utils"
@@ -10,8 +11,8 @@ class Gem::Commands::ListCommand < Gem::Command
def initialize
super "list", "Display local gems whose name matches REGEXP",
- :domain => :local, :details => false, :versions => true,
- :installed => nil, :version => Gem::Requirement.default
+ domain: :local, details: false, versions: true,
+ installed: nil, version: Gem::Requirement.default
add_query_options
end
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index da636492c9..f7fd5ada16 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::LockCommand < Gem::Command
def initialize
super "lock", "Generate a lockdown list of gems",
- :strict => false
+ strict: false
add_option "-s", "--[no-]strict",
"fail if unable to satisfy a dependency" do |strict, options|
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
index b633cd3d81..b91a8db12d 100644
--- a/lib/rubygems/commands/mirror_command.rb
+++ b/lib/rubygems/commands/mirror_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
unless defined? Gem::Commands::MirrorCommand
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index d5283f72dd..0fe90dc8b8 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
@@ -69,9 +70,7 @@ class Gem::Commands::OpenCommand < Gem::Command
end
def open_editor(path)
- Dir.chdir(path) do
- system(*@editor.split(/\s+/) + [path])
- end
+ system(*@editor.split(/\s+/) + [path], { chdir: path })
end
def spec_for(name)
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index 1785194389..08a9221a26 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../spec_fetcher"
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 0ef8c45e97..675e866734 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../gemcutter_utilities"
@@ -38,7 +39,7 @@ permission to.
add_proxy_option
add_key_option
add_otp_option
- defaults.merge! :add => [], :remove => []
+ defaults.merge! add: [], remove: []
add_option "-a", "--add NEW_OWNER", "Add an owner by user identifier" do |value, options|
options[:add] << value
@@ -74,11 +75,12 @@ permission to.
end
with_response response do |resp|
- owners = Gem::SafeYAML.load clean_text(resp.body)
+ owners = Gem::SafeYAML.safe_load clean_text(resp.body)
say "Owners for gem: #{name}"
owners.each do |owner|
- say "- #{owner["email"] || owner["handle"] || owner["id"]}"
+ identifier = owner["email"] || owner["handle"] || owner["id"]
+ say "- #{identifier} (#{owner["role"]})"
end
end
end
@@ -93,14 +95,14 @@ permission to.
def manage_owners(method, name, owners)
owners.each do |owner|
- begin
- response = send_owner_request(method, name, owner)
- action = method == :delete ? "Removing" : "Adding"
-
- with_response response, "#{action} #{owner}"
- rescue
- # ignore
- end
+ response = send_owner_request(method, name, owner)
+ action = method == :delete ? "Removing" : "Adding"
+
+ with_response response, "#{action} #{owner}"
+ rescue Gem::WebauthnVerificationError => e
+ raise e
+ rescue StandardError
+ # ignore early exits to allow for completing the iteration of all owners
end
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index d7c78ba13d..10978c2af7 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../package"
require_relative "../installer"
@@ -10,10 +11,10 @@ class Gem::Commands::PristineCommand < Gem::Command
def initialize
super "pristine",
"Restores installed gems to pristine condition from files located in the gem cache",
- :version => Gem::Requirement.default,
- :extensions => true,
- :extensions_set => false,
- :all => false
+ version: Gem::Requirement.default,
+ extensions: true,
+ extensions_set: false,
+ all: false
add_option("--all",
"Restore all installed gems to pristine",
@@ -56,7 +57,7 @@ class Gem::Commands::PristineCommand < Gem::Command
end
add_option("-i", "--install-dir DIR",
- "Gem repository to get binstubs and plugins installed") do |value, options|
+ "Gem repository to get gems restored") do |value, options|
options[:install_dir] = File.expand_path(value)
end
@@ -87,6 +88,10 @@ If you have made modifications to an installed gem, the pristine command
will revert them. All extensions are rebuilt and all bin stubs for the gem
are regenerated after checking for modifications.
+Rebuilding extensions also refreshes C-extension gems against updated system
+libraries (for example after OS or package upgrades) to avoid mismatches like
+outdated library version warnings.
+
If the cached gem cannot be found it will be downloaded.
If --no-extensions is provided pristine will not attempt to restore a gem
@@ -102,59 +107,73 @@ extensions will be restored.
end
def execute
+ install_dir = options[:install_dir]
+
+ specification_record = install_dir ? Gem::SpecificationRecord.from_path(install_dir) : Gem::Specification.specification_record
+
specs = if options[:all]
- Gem::Specification.map
+ specification_record.map
# `--extensions` must be explicitly given to pristine only gems
# with extensions.
elsif options[:extensions_set] &&
options[:extensions] && options[:args].empty?
- Gem::Specification.select do |spec|
+ specification_record.select do |spec|
spec.extensions && !spec.extensions.empty?
end
elsif options[:only_missing_extensions]
- Gem::Specification.select do |spec|
- spec.missing_extensions?
- end
+ specification_record.select(&:missing_extensions?)
else
- get_all_gem_names.sort.map do |gem_name|
- Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
- end.flatten
+ get_all_gem_names.sort.flat_map do |gem_name|
+ specification_record.find_all_by_name(gem_name, options[:version]).reverse
+ end
end
- specs = specs.select {|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
+ specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
if specs.to_a.empty?
+ if options[:only_missing_extensions]
+ say "No gems with missing extensions to restore"
+ return
+ end
+
raise Gem::Exception,
"Failed to find gems #{options[:args]} #{options[:version]}"
end
say "Restoring gems to pristine condition..."
- specs.each do |spec|
- if spec.default_gem?
- say "Skipped #{spec.full_name}, it is a default gem"
- next
+ specs.group_by(&:full_name_with_location).values.each do |grouped_specs|
+ spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first
+
+ only_executables = options[:only_executables]
+ only_plugins = options[:only_plugins]
+
+ unless only_executables || only_plugins
+ # Default gemspecs include changes provided by ruby-core installer that
+ # can't currently be pristined (inclusion of compiled extension targets in
+ # the file list). So stick to resetting executables if it's a default gem.
+ only_executables = true if spec.default_gem?
end
- if options.has_key? :skip
+ if options.key? :skip
if options[:skip].include? spec.name
say "Skipped #{spec.full_name}, it was given through options"
next
end
end
- unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
- say "Skipped #{spec.full_name}, it needs to compile an extension"
+ unless spec.extensions.empty? || options[:extensions] || only_executables || only_plugins
+ say "Skipped #{spec.full_name_with_location}, it needs to compile an extension"
next
end
gem = spec.cache_file
- unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
+ unless File.exist?(gem) || only_executables || only_plugins
require_relative "../remote_fetcher"
- say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
+ say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..."
dep = Gem::Dependency.new spec.name, spec.version
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
@@ -177,21 +196,20 @@ extensions will be restored.
end
bin_dir = options[:bin_dir] if options[:bin_dir]
- install_dir = options[:install_dir] if options[:install_dir]
installer_options = {
- :wrappers => true,
- :force => true,
- :install_dir => install_dir || spec.base_dir,
- :env_shebang => env_shebang,
- :build_args => spec.build_args,
- :bin_dir => bin_dir,
+ wrappers: true,
+ force: true,
+ install_dir: install_dir || spec.base_dir,
+ env_shebang: env_shebang,
+ build_args: spec.build_args,
+ bin_dir: bin_dir,
}
- if options[:only_executables]
+ if only_executables
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
- elsif options[:only_plugins]
+ elsif only_plugins
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_plugins
else
@@ -199,7 +217,7 @@ extensions will be restored.
installer.install
end
- say "Restored #{spec.full_name}"
+ say "Restored #{spec.full_name_with_location}"
end
end
end
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 46b65f4e15..02931b3025 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../gemcutter_utilities"
@@ -29,7 +30,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
end
def initialize
- super "push", "Push a gem up to the gem server", :host => self.host
+ super "push", "Push a gem up to the gem server", host: host, attestations: []
@user_defined_host = false
@@ -44,6 +45,11 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
@user_defined_host = true
end
+ add_option("--attestation FILE",
+ "Push with sigstore attestations") do |value, options|
+ options[:attestations] << value
+ end
+
@host = nil
end
@@ -74,7 +80,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
@host ||= push_host
# Always include @host, even if it's nil
- args += [ @host, push_host ]
+ args += [@host, push_host]
say "Pushing gem to #{@host || Gem.host}..."
@@ -86,12 +92,77 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
private
def send_push_request(name, args)
- rubygems_api_request(*args, scope: get_push_scope) do |request|
- request.body = Gem.read_binary name
- request.add_field "Content-Length", request.body.size
+ # Always honor explicit --attestation option
+ # Auto-attestation is only supported on rubygems.org with GitHub Actions (not JRuby)
+ if options[:attestations].any? || (RUBY_ENGINE != "jruby" && attestation_supported_host? && ENV["GITHUB_ACTIONS"])
+ send_push_request_with_attestation(name, args)
+ else
+ send_push_request_without_attestation(name, args)
+ end
+ end
+
+ def send_push_request_without_attestation(name, args)
+ scope = get_push_scope
+ rubygems_api_request(*args, scope: scope) do |request|
+ body = Gem.read_binary name
+ request.body = body
request.add_field "Content-Type", "application/octet-stream"
- request.add_field "Authorization", api_key
+ request.add_field "Content-Length", request.body.size
+ request.add_field "Authorization", api_key
+ end
+ end
+
+ def send_push_request_with_attestation(name, args)
+ attestations = if options[:attestations].any?
+ options[:attestations].map do |attestation|
+ Gem.read_binary(attestation)
+ end
+ else
+ bundle_path = attest!(name)
+ begin
+ [Gem.read_binary(bundle_path)]
+ ensure
+ File.unlink(bundle_path) if bundle_path && File.exist?(bundle_path)
+ end
+ end
+ bundles = "[" + attestations.join(",") + "]"
+
+ rubygems_api_request(*args, scope: get_push_scope) do |request|
+ request.set_form([
+ ["gem", Gem.read_binary(name), { filename: name, content_type: "application/octet-stream" }],
+ ["attestations", bundles, { content_type: "application/json" }],
+ ], "multipart/form-data")
+ request.add_field "Authorization", api_key
end
+ rescue StandardError => e
+ message = "Failed to push with attestation, retrying without attestation.\n"
+ message += if Gem.configuration.really_verbose
+ e.full_message
+ else
+ e.message
+ end
+ alert_warning message
+ send_push_request_without_attestation(name, args)
+ end
+
+ def attest!(name)
+ require "open3"
+ require "tempfile"
+
+ tempfile = Tempfile.new([File.basename(name, ".*"), ".sigstore.json"])
+ bundle = tempfile.path
+ tempfile.close(false)
+
+ env = defined?(Bundler.unbundled_env) ? Bundler.unbundled_env : ENV.to_h
+ out, st = Open3.capture2e(
+ env,
+ Gem.ruby, "-S", "gem", "exec", "--conservative",
+ "sigstore-cli", "sign", name, "--bundle", bundle,
+ unsetenv_others: true
+ )
+ raise Gem::Exception, "Failed to sign gem:\n\n#{out}" unless st.success?
+
+ bundle
end
def get_hosts_for(name)
@@ -106,4 +177,9 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
def get_push_scope
:push_rubygem
end
+
+ def attestation_supported_host?
+ host = (@host || Gem.host).to_s.chomp("/")
+ host == Gem::DEFAULT_HOST
+ end
end
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
deleted file mode 100644
index 9d57d0c87e..0000000000
--- a/lib/rubygems/commands/query_command.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-require_relative "../command"
-require_relative "../query_utils"
-require_relative "../deprecate"
-
-class Gem::Commands::QueryCommand < Gem::Command
- extend Gem::Deprecate
- rubygems_deprecate_command
-
- include Gem::QueryUtils
-
- alias_method :warning_without_suggested_alternatives, :deprecation_warning
- def deprecation_warning
- warning_without_suggested_alternatives
-
- message = "It is recommended that you use `gem search` or `gem list` instead.\n"
- alert_warning message unless Gem::Deprecate.skip
- end
-
- def initialize(name = "query",
- summary = "Query gem information in local or remote repositories")
- super name, summary,
- :domain => :local, :details => false, :versions => true,
- :installed => nil, :version => Gem::Requirement.default
-
- 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_query_options
- end
-
- def description # :nodoc:
- <<-EOF
-The query command is the basis for the list and search commands.
-
-You should really use the list and search commands instead. This command
-is too hard to use.
- EOF
- end
-end
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index a998a9704c..62c4bf8ce9 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
require_relative "../rdoc"
@@ -9,8 +10,8 @@ class Gem::Commands::RdocCommand < Gem::Command
def initialize
super "rdoc", "Generates RDoc for pre-installed gems",
- :version => Gem::Requirement.default,
- :include_rdoc => false, :include_ri => true, :overwrite => false
+ version: Gem::Requirement.default,
+ include_rdoc: false, include_ri: true, overwrite: false
add_option("--all",
"Generate RDoc/RI documentation for all",
@@ -63,9 +64,9 @@ Use --overwrite to force rebuilding of documentation.
specs = if options[:all]
Gem::Specification.to_a
else
- get_all_gem_names.map do |name|
+ get_all_gem_names.flat_map do |name|
Gem::Specification.find_by_name name, options[:version]
- end.flatten.uniq
+ end.uniq
end
if specs.empty?
@@ -83,14 +84,7 @@ Use --overwrite to force rebuilding of documentation.
FileUtils.rm_rf File.join(spec.doc_dir, "rdoc")
end
- begin
- doc.generate
- rescue Errno::ENOENT => e
- match = / - /.match(e.message)
- alert_error "Unable to document #{spec.full_name}, " \
- " #{match.post_match} is missing, skipping"
- terminate_interaction 1 if specs.length == 1
- end
+ doc.generate
end
end
end
diff --git a/lib/rubygems/commands/rebuild_command.rb b/lib/rubygems/commands/rebuild_command.rb
new file mode 100644
index 0000000000..23b9d7b3ba
--- /dev/null
+++ b/lib/rubygems/commands/rebuild_command.rb
@@ -0,0 +1,261 @@
+# frozen_string_literal: true
+
+require "digest"
+require "fileutils"
+require "tmpdir"
+require_relative "../gemspec_helpers"
+require_relative "../package"
+
+class Gem::Commands::RebuildCommand < Gem::Command
+ include Gem::GemspecHelpers
+
+ def initialize
+ super "rebuild", "Attempt to reproduce a build of a gem."
+
+ add_option "--diff", "If the files don't match, compare them using diffoscope." do |_value, options|
+ options[:diff] = true
+ end
+
+ add_option "--force", "Skip validation of the spec." do |_value, options|
+ options[:force] = true
+ end
+
+ add_option "--strict", "Consider warnings as errors when validating the spec." do |_value, options|
+ options[:strict] = true
+ end
+
+ add_option "--source GEM_SOURCE", "Specify the source to download the gem from." do |value, options|
+ options[:source] = value
+ end
+
+ add_option "--original GEM_FILE", "Specify a local file to compare against (instead of downloading it)." do |value, options|
+ options[:original_gem_file] = value
+ end
+
+ add_option "--gemspec GEMSPEC_FILE", "Specify the name of the gemspec file." do |value, options|
+ options[:gemspec_file] = value
+ end
+
+ add_option "-C PATH", "Run as if gem build was started in <PATH> instead of the current working directory." do |value, options|
+ options[:build_path] = value
+ end
+ end
+
+ def arguments # :nodoc:
+ "GEM_NAME gem name on gem server\n" \
+ "GEM_VERSION gem version you are attempting to rebuild"
+ end
+
+ def description # :nodoc:
+ <<-EOF
+The rebuild command allows you to (attempt to) reproduce a build of a gem
+from a ruby gemspec.
+
+This command assumes the gemspec can be built with the `gem build` command.
+If you use any of `gem build`, `rake build`, or`rake release` in the
+build/release process for a gem, it is a potential candidate.
+
+You will need to match the RubyGems version used, since this is included in
+the Gem metadata.
+
+If the gem includes lockfiles (e.g. Gemfile.lock) and similar, it will
+require more effort to reproduce a build. For example, it might require
+more precisely matched versions of Ruby and/or Bundler to be used.
+ EOF
+ end
+
+ def usage # :nodoc:
+ "#{program_name} GEM_NAME GEM_VERSION"
+ end
+
+ def execute
+ gem_name, gem_version = get_gem_name_and_version
+
+ old_dir, new_dir = prep_dirs
+
+ gem_filename = "#{gem_name}-#{gem_version}.gem"
+ old_file = File.join(old_dir, gem_filename)
+ new_file = File.join(new_dir, gem_filename)
+
+ if options[:original_gem_file]
+ FileUtils.copy_file(options[:original_gem_file], old_file)
+ else
+ download_gem(gem_name, gem_version, old_file)
+ end
+
+ rg_version = rubygems_version(old_file)
+ unless rg_version == Gem::VERSION
+ alert_error <<-EOF
+You need to use the same RubyGems version #{gem_name} v#{gem_version} was built with.
+
+#{gem_name} v#{gem_version} was built using RubyGems v#{rg_version}.
+Gem files include the version of RubyGems used to build them.
+This means in order to reproduce #{gem_filename}, you must also use RubyGems v#{rg_version}.
+
+You're using RubyGems v#{Gem::VERSION}.
+
+Please install RubyGems v#{rg_version} and try again.
+ EOF
+ terminate_interaction 1
+ end
+
+ source_date_epoch = get_timestamp(old_file).to_s
+
+ if build_path = options[:build_path]
+ Dir.chdir(build_path) { build_gem(gem_name, source_date_epoch, new_file) }
+ else
+ build_gem(gem_name, source_date_epoch, new_file)
+ end
+
+ compare(source_date_epoch, old_file, new_file)
+ end
+
+ private
+
+ def sha256(file)
+ Digest::SHA256.hexdigest(Gem.read_binary(file))
+ end
+
+ def get_timestamp(file)
+ mtime = nil
+ File.open(file, Gem.binary_mode) do |f|
+ Gem::Package::TarReader.new(f) do |tar|
+ mtime = tar.seek("metadata.gz") {|tf| tf.header.mtime }
+ end
+ end
+
+ mtime
+ end
+
+ def compare(source_date_epoch, old_file, new_file)
+ date = Time.at(source_date_epoch.to_i).strftime("%F %T %Z")
+
+ old_hash = sha256(old_file)
+ new_hash = sha256(new_file)
+
+ say
+ say "Built at: #{date} (#{source_date_epoch})"
+ say "Original build saved to: #{old_file}"
+ say "Reproduced build saved to: #{new_file}"
+ say "Working directory: #{options[:build_path] || Dir.pwd}"
+ say
+ say "Hash comparison:"
+ say " #{old_hash}\t#{old_file}"
+ say " #{new_hash}\t#{new_file}"
+ say
+
+ if old_hash == new_hash
+ say "SUCCESS - original and rebuild hashes matched"
+ else
+ say "FAILURE - original and rebuild hashes did not match"
+ say
+
+ if options[:diff]
+ if system("diffoscope", old_file, new_file).nil?
+ alert_error "error: could not find `diffoscope` executable"
+ end
+ else
+ say "Pass --diff for more details (requires diffoscope to be installed)."
+ end
+
+ terminate_interaction 1
+ end
+ end
+
+ def prep_dirs
+ rebuild_dir = Dir.mktmpdir("gem_rebuild")
+ old_dir = File.join(rebuild_dir, "old")
+ new_dir = File.join(rebuild_dir, "new")
+
+ FileUtils.mkdir_p(old_dir)
+ FileUtils.mkdir_p(new_dir)
+
+ [old_dir, new_dir]
+ end
+
+ def get_gem_name_and_version
+ args = options[:args] || []
+ if args.length == 2
+ gem_name, gem_version = args
+ elsif args.length > 2
+ raise Gem::CommandLineError, "Too many arguments"
+ else
+ raise Gem::CommandLineError, "Expected GEM_NAME and GEM_VERSION arguments (gem rebuild GEM_NAME GEM_VERSION)"
+ end
+
+ [gem_name, gem_version]
+ end
+
+ def build_gem(gem_name, source_date_epoch, output_file)
+ gemspec = options[:gemspec_file] || find_gemspec("#{gem_name}.gemspec")
+
+ if gemspec
+ build_package(gemspec, source_date_epoch, output_file)
+ else
+ alert_error error_message(gem_name)
+ terminate_interaction(1)
+ end
+ end
+
+ def build_package(gemspec, source_date_epoch, output_file)
+ with_source_date_epoch(source_date_epoch) do
+ spec = Gem::Specification.load(gemspec)
+ if spec
+ Gem::Package.build(
+ spec,
+ options[:force],
+ options[:strict],
+ output_file
+ )
+ else
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
+ end
+ end
+ end
+
+ def with_source_date_epoch(source_date_epoch)
+ old_sde = ENV["SOURCE_DATE_EPOCH"]
+ ENV["SOURCE_DATE_EPOCH"] = source_date_epoch.to_s
+
+ yield
+ ensure
+ ENV["SOURCE_DATE_EPOCH"] = old_sde
+ end
+
+ def error_message(gem_name)
+ if gem_name
+ "Couldn't find a gemspec file matching '#{gem_name}' in #{Dir.pwd}"
+ else
+ "Couldn't find a gemspec file in #{Dir.pwd}"
+ end
+ end
+
+ def download_gem(gem_name, gem_version, old_file)
+ # This code was based loosely off the `gem fetch` command.
+ version = "= #{gem_version}"
+ dep = Gem::Dependency.new gem_name, version
+
+ specs_and_sources, errors =
+ Gem::SpecFetcher.fetcher.spec_for_dependency dep
+
+ # There should never be more than one item in specs_and_sources,
+ # since we search for an exact version.
+ spec, source = specs_and_sources[0]
+
+ if spec.nil?
+ show_lookup_failure gem_name, version, errors, options[:domain]
+ terminate_interaction 1
+ end
+
+ download_path = source.download spec
+
+ FileUtils.move(download_path, old_file)
+
+ say "Downloaded #{gem_name} version #{gem_version} as #{old_file}."
+ end
+
+ def rubygems_version(gem_file)
+ Gem::Package.new(gem_file).spec.rubygems_version
+ end
+end
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 3f8f7e13f2..50e161ac9b 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../query_utils"
@@ -7,8 +8,8 @@ class Gem::Commands::SearchCommand < Gem::Command
def initialize
super "search", "Display remote gems whose name matches REGEXP",
- :domain => :remote, :details => false, :versions => true,
- :installed => nil, :version => Gem::Requirement.default
+ domain: :remote, details: false, versions: true,
+ installed: nil, version: Gem::Requirement.default
add_query_options
end
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
index 56be07c79d..f1dde4aa02 100644
--- a/lib/rubygems/commands/server_command.rb
+++ b/lib/rubygems/commands/server_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
unless defined? Gem::Commands::ServerCommand
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index efc387a69f..175599967c 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
##
@@ -6,19 +7,19 @@ require_relative "../command"
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
- HISTORY_HEADER = /^#\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
- VERSION_MATCHER = /^#\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
+ HISTORY_HEADER = %r{^##\s*[\d.a-zA-Z]+\s*/\s*\d{4}-\d{2}-\d{2}\s*$}
+ VERSION_MATCHER = %r{^##\s*([\d.a-zA-Z]+)\s*/\s*\d{4}-\d{2}-\d{2}\s*$}
ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
def initialize
super "setup", "Install RubyGems",
- :format_executable => false, :document => %w[ri],
- :force => true,
- :site_or_vendor => "sitelibdir",
- :destdir => "", :prefix => "", :previous_version => "",
- :regenerate_binstubs => true,
- :regenerate_plugins => true
+ format_executable: false, document: %w[ri],
+ force: true,
+ site_or_vendor: "sitelibdir",
+ destdir: "", prefix: "", previous_version: "",
+ regenerate_binstubs: true,
+ regenerate_plugins: true
add_option "--previous-version=VERSION",
"Previous version of RubyGems",
@@ -106,15 +107,6 @@ class Gem::Commands::SetupCommand < Gem::Command
@verbose = nil
end
- def check_ruby_version
- required_version = Gem::Requirement.new ">= 2.6.0"
-
- unless required_version.satisfied_by? Gem.ruby_version
- alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
- terminate_interaction 1
- end
- end
-
def defaults_str # :nodoc:
"--format-executable --document ri --regenerate-binstubs"
end
@@ -147,8 +139,6 @@ By default, this RubyGems will install gem as:
def execute
@verbose = Gem.configuration.really_verbose
- check_ruby_version
-
require "fileutils"
if Gem.configuration.really_verbose
extend FileUtils::Verbose
@@ -242,9 +232,9 @@ By default, this RubyGems will install gem as:
end
def install_executables(bin_dir)
- prog_mode = options[:prog_mode] || 0755
+ prog_mode = options[:prog_mode] || 0o755
- executables = { "gem" => "bin" }
+ executables = { "gem" => "exe" }
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
@@ -264,7 +254,7 @@ By default, this RubyGems will install gem as:
fp.puts bin.join
end
- install bin_tmp_file, dest_file, :mode => prog_mode
+ install bin_tmp_file, dest_file, mode: prog_mode
bin_file_names << dest_file
ensure
rm bin_tmp_file
@@ -278,15 +268,11 @@ By default, this RubyGems will install gem as:
File.open bin_cmd_file, "w" do |file|
file.puts <<-TEXT
@ECHO OFF
- IF NOT "%~f0" == "~f0" GOTO :WinNT
- @"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
- GOTO :EOF
- :WinNT
- @"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
+ @"%~dp0#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
TEXT
end
- install bin_cmd_file, "#{dest_file}.bat", :mode => prog_mode
+ install bin_cmd_file, "#{dest_file}.bat", mode: prog_mode
ensure
rm bin_cmd_file
end
@@ -339,6 +325,8 @@ By default, this RubyGems will install gem as:
require_relative "../rdoc"
+ return false unless defined?(Gem::RDoc)
+
fake_spec = Gem::Specification.new "rubygems", Gem::VERSION
def fake_spec.full_gem_path
File.expand_path "../../..", __dir__
@@ -356,30 +344,39 @@ By default, this RubyGems will install gem as:
say "Set the GEM_HOME environment variable if you want RDoc generated"
end
- return false
+ false
end
def install_default_bundler_gem(bin_dir)
current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
specs_dir = if current_default_spec && default_dir == Gem.default_dir
+ all_specs_current_version = Gem::Specification.stubs.select {|s| s.full_name == current_default_spec.full_name }
+
Gem::Specification.remove_spec current_default_spec
loaded_from = current_default_spec.loaded_from
File.delete(loaded_from)
+
+ # Remove previous default gem executables if they were not shadowed by a regular gem
+ FileUtils.rm_rf current_default_spec.full_gem_path if all_specs_current_version.size == 1
+
File.dirname(loaded_from)
else
target_specs_dir = File.join(default_dir, "specifications", "default")
- mkdir_p target_specs_dir, :mode => 0755
+ mkdir_p target_specs_dir, mode: 0o755
target_specs_dir
end
- bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
- default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec")
- Gem.write_binary(default_spec_path, bundler_spec.to_ruby)
+ new_bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
+ full_name = new_bundler_spec.full_name
+ gemspec_path = "#{full_name}.gemspec"
+
+ default_spec_path = File.join(specs_dir, gemspec_path)
+ Gem.write_binary(default_spec_path, new_bundler_spec.to_ruby)
bundler_spec = Gem::Specification.load(default_spec_path)
# Remove gemspec that was same version of vendored bundler.
- normal_gemspec = File.join(default_dir, "specifications", "bundler-#{bundler_spec.version}.gemspec")
+ normal_gemspec = File.join(default_dir, "specifications", gemspec_path)
if File.file? normal_gemspec
File.delete normal_gemspec
end
@@ -387,39 +384,37 @@ By default, this RubyGems will install gem as:
# Remove gem files that were same version of vendored bundler.
if File.directory? bundler_spec.gems_dir
Dir.entries(bundler_spec.gems_dir).
- select {|default_gem| File.basename(default_gem) == "bundler-#{bundler_spec.version}" }.
+ select {|default_gem| File.basename(default_gem) == full_name }.
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end
- bundler_bin_dir = bundler_spec.bin_dir
- mkdir_p bundler_bin_dir, :mode => 0755
- bundler_spec.executables.each do |e|
- cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
- end
-
require_relative "../installer"
Dir.chdir("bundler") do
- built_gem = Gem::Package.build(bundler_spec)
+ built_gem = Gem::Package.build(new_bundler_spec)
begin
- Gem::Installer.at(
+ installer = Gem::Installer.at(
built_gem,
env_shebang: options[:env_shebang],
format_executable: options[:format_executable],
force: options[:force],
- install_as_default: true,
bin_dir: bin_dir,
install_dir: default_dir,
wrappers: true
- ).install
+ )
+ # We need to install only executable and default spec files.
+ # lib/bundler.rb and lib/bundler/* are available under the site_ruby directory.
+ installer.extract_bin
+ installer.generate_bin
+ installer.write_default_spec
ensure
FileUtils.rm_f built_gem
end
end
- bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
+ new_bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
- say "Bundler #{bundler_spec.version} installed"
+ say "Bundler #{new_bundler_spec.version} installed"
end
def make_destination_dirs
@@ -429,10 +424,10 @@ By default, this RubyGems will install gem as:
lib_dir, bin_dir = generate_default_dirs
end
- mkdir_p lib_dir, :mode => 0755
- mkdir_p bin_dir, :mode => 0755
+ mkdir_p lib_dir, mode: 0o755
+ mkdir_p bin_dir, mode: 0o755
- return lib_dir, bin_dir
+ [lib_dir, bin_dir]
end
def generate_default_man_dir
@@ -575,8 +570,8 @@ abort "#{deprecation_message}"
def uninstall_old_gemcutter
require_relative "../uninstaller"
- ui = Gem::Uninstaller.new("gemcutter", :all => true, :ignore => true,
- :version => "< 0.4")
+ ui = Gem::Uninstaller.new("gemcutter", all: true, ignore: true,
+ version: "< 0.4")
ui.uninstall
rescue Gem::InstallError
end
@@ -587,6 +582,8 @@ abort "#{deprecation_message}"
args = %w[--all --only-executables --silent]
args << "--bindir=#{bindir}"
+ args << "--install-dir=#{default_dir}"
+
if options[:env_shebang]
args << "--env-shebang"
end
@@ -638,10 +635,10 @@ abort "#{deprecation_message}"
dest_file = File.join dest_dir, file
dest_dir = File.dirname dest_file
unless File.directory? dest_dir
- mkdir_p dest_dir, :mode => 0755
+ mkdir_p dest_dir, mode: 0o755
end
- install file, dest_file, :mode => options[:data_mode] || 0644
+ install file, dest_file, mode: options[:data_mode] || 0o644
end
def remove_file_list(files, dir)
diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb
index 2660eee4f3..0f77908c5b 100644
--- a/lib/rubygems/commands/signin_command.rb
+++ b/lib/rubygems/commands/signin_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../gemcutter_utilities"
diff --git a/lib/rubygems/commands/signout_command.rb b/lib/rubygems/commands/signout_command.rb
index fa688ea3f8..bdd01e4393 100644
--- a/lib/rubygems/commands/signout_command.rb
+++ b/lib/rubygems/commands/signout_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::SignoutCommand < Gem::Command
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 0ed5b4a8f8..b399af2bd3 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../remote_fetcher"
require_relative "../spec_fetcher"
@@ -17,6 +18,14 @@ class Gem::Commands::SourcesCommand < Gem::Command
options[:add] = value
end
+ add_option "--append SOURCE_URI", "Append source (can be used multiple times)" do |value, options|
+ options[:append] = value
+ end
+
+ add_option "-p", "--prepend SOURCE_URI", "Prepend source (can be used multiple times)" do |value, options|
+ options[:prepend] = value
+ end
+
add_option "-l", "--list", "List sources" do |value, options|
options[:list] = value
end
@@ -25,8 +34,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
options[:remove] = value
end
- add_option "-c", "--clear-all",
- "Remove all sources (clear the cache)" do |value, options|
+ add_option "-c", "--clear-all", "Remove all sources (clear the cache)" do |value, options|
options[:clear_all] = value
end
@@ -42,11 +50,8 @@ class Gem::Commands::SourcesCommand < Gem::Command
end
def add_source(source_uri) # :nodoc:
- check_rubygems_https source_uri
-
- source = Gem::Source.new source_uri
-
- check_typo_squatting(source)
+ source = build_new_source(source_uri)
+ source_uri = source.uri.to_s
begin
if Gem.sources.include? source
@@ -58,7 +63,55 @@ class Gem::Commands::SourcesCommand < Gem::Command
say "#{source_uri} added to sources"
end
- rescue URI::Error, ArgumentError
+ rescue Gem::URI::Error, ArgumentError
+ say "#{source_uri} is not a URI"
+ terminate_interaction 1
+ rescue Gem::RemoteFetcher::FetchError => e
+ say "Error fetching #{Gem::Uri.redact(source.uri)}:\n\t#{e.message}"
+ terminate_interaction 1
+ end
+ end
+
+ def append_source(source_uri) # :nodoc:
+ source = build_new_source(source_uri)
+ source_uri = source.uri.to_s
+
+ begin
+ source.load_specs :released
+ was_present = Gem.sources.include?(source)
+ Gem.sources.append source
+ Gem.configuration.write
+
+ if was_present
+ say "#{source_uri} moved to end of sources"
+ else
+ say "#{source_uri} added to sources"
+ end
+ rescue Gem::URI::Error, ArgumentError
+ say "#{source_uri} is not a URI"
+ terminate_interaction 1
+ rescue Gem::RemoteFetcher::FetchError => e
+ say "Error fetching #{Gem::Uri.redact(source.uri)}:\n\t#{e.message}"
+ terminate_interaction 1
+ end
+ end
+
+ def prepend_source(source_uri) # :nodoc:
+ source = build_new_source(source_uri)
+ source_uri = source.uri.to_s
+
+ begin
+ source.load_specs :released
+ was_present = Gem.sources.include?(source)
+ Gem.sources.prepend source
+ Gem.configuration.write
+
+ if was_present
+ say "#{source_uri} moved to top of sources"
+ else
+ say "#{source_uri} added to sources"
+ end
+ rescue Gem::URI::Error, ArgumentError
say "#{source_uri} is not a URI"
terminate_interaction 1
rescue Gem::RemoteFetcher::FetchError => e
@@ -79,11 +132,24 @@ Do you want to add this source?
end
end
+ def normalize_source_uri(source_uri) # :nodoc:
+ # Ensure the source URI has a trailing slash for proper RFC 2396 path merging
+ # Without a trailing slash, the last path segment is treated as a file and removed
+ # during relative path resolution (e.g., "/blish" + "gems/foo.gem" = "/gems/foo.gem")
+ # With a trailing slash, it's treated as a directory (e.g., "/blish/" + "gems/foo.gem" = "/blish/gems/foo.gem")
+ uri = Gem::URI.parse(source_uri)
+ uri.path = uri.path.gsub(%r{/+\z}, "") + "/" if uri.path && !uri.path.empty?
+ uri.to_s
+ rescue Gem::URI::Error
+ # If parsing fails, return the original URI and let later validation handle it
+ source_uri
+ end
+
def check_rubygems_https(source_uri) # :nodoc:
- uri = URI source_uri
+ uri = Gem::URI source_uri
- if uri.scheme && uri.scheme.downcase == "http" &&
- uri.host.downcase == "rubygems.org"
+ if uri.scheme && uri.scheme.casecmp("http").zero? &&
+ uri.host.casecmp("rubygems.org").zero?
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@@ -98,16 +164,16 @@ Do you want to add this insecure source?
path = Gem.spec_cache_dir
FileUtils.rm_rf path
- unless File.exist? path
- say "*** Removed specs cache ***"
- else
- unless File.writable? path
- say "*** Unable to remove source cache (write protected) ***"
- else
+ if File.exist? path
+ if File.writable? path
say "*** Unable to remove source cache ***"
+ else
+ say "*** Unable to remove source cache (write protected) ***"
end
terminate_interaction 1
+ else
+ say "*** Removed specs cache ***"
end
end
@@ -127,7 +193,7 @@ yourself to use your own gem server.
Without any arguments the sources lists your currently configured sources:
$ gem sources
- *** CURRENT SOURCES ***
+ *** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
https://rubygems.org
@@ -146,33 +212,49 @@ Since all of these sources point to the same set of gems you only need one
of them in your list. https://rubygems.org is recommended as it brings the
protections of an SSL connection to gem downloads.
-To add a source use the --add argument:
+To add a private gem source use the --prepend argument to insert it before
+the default source. This is usually the best place for private gem sources:
- $ gem sources --add https://rubygems.org
- https://rubygems.org added to sources
+ $ gem sources --prepend https://my.private.source
+ https://my.private.source added to sources
RubyGems will check to see if gems can be installed from the source given
before it is added.
+To add or move a source after all other sources, use --append:
+
+ $ gem sources --append https://rubygems.org
+ https://rubygems.org moved to end of sources
+
To remove a source use the --remove argument:
- $ gem sources --remove https://rubygems.org/
- https://rubygems.org/ removed from sources
+ $ gem sources --remove https://my.private.source/
+ https://my.private.source/ removed from sources
EOF
end
def list # :nodoc:
- say "*** CURRENT SOURCES ***"
+ if configured_sources
+ header = "*** CURRENT SOURCES ***"
+ list = configured_sources
+ else
+ header = "*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***"
+ list = Gem.sources
+ end
+
+ say header
say
- Gem.sources.each do |src|
+ list.each do |src|
say src
end
end
def list? # :nodoc:
!(options[:add] ||
+ options[:prepend] ||
+ options[:append] ||
options[:clear_all] ||
options[:remove] ||
options[:update])
@@ -181,11 +263,13 @@ To remove a source use the --remove argument:
def execute
clear_all if options[:clear_all]
- source_uri = options[:add]
- add_source source_uri if source_uri
+ add_source options[:add] if options[:add]
+
+ prepend_source options[:prepend] if options[:prepend]
+
+ append_source options[:append] if options[:append]
- source_uri = options[:remove]
- remove_source source_uri if source_uri
+ remove_source options[:remove] if options[:remove]
update if options[:update]
@@ -193,13 +277,22 @@ To remove a source use the --remove argument:
end
def remove_source(source_uri) # :nodoc:
- unless Gem.sources.include? source_uri
- say "source #{source_uri} not present in cache"
- else
- Gem.sources.delete source_uri
+ source = build_source(source_uri)
+ source_uri = source.uri.to_s
+
+ if configured_sources&.include? source
+ Gem.sources.delete source
Gem.configuration.write
- say "#{source_uri} removed from sources"
+ if default_sources.include?(source) && configured_sources.one?
+ alert_warning "Removing a default source when it is the only source has no effect. Add a different source to #{config_file_name} if you want to stop using it as a source."
+ else
+ say "#{source_uri} removed from sources"
+ end
+ elsif configured_sources
+ say "source #{source_uri} cannot be removed because it's not present in #{config_file_name}"
+ else
+ say "source #{source_uri} cannot be removed because there are no configured sources in #{config_file_name}"
end
end
@@ -223,4 +316,33 @@ To remove a source use the --remove argument:
say "*** Unable to remove #{desc} source cache ***"
end
end
+
+ private
+
+ def default_sources
+ Gem::SourceList.from(Gem.default_sources)
+ end
+
+ def configured_sources
+ return @configured_sources if defined?(@configured_sources)
+
+ configuration_sources = Gem.configuration.sources
+ @configured_sources = Gem::SourceList.from(configuration_sources) if configuration_sources
+ end
+
+ def config_file_name
+ Gem.configuration.config_file_name
+ end
+
+ def build_source(source_uri)
+ source_uri = normalize_source_uri(source_uri)
+ Gem::Source.new(source_uri)
+ end
+
+ def build_new_source(source_uri)
+ source = build_source(source_uri)
+ check_rubygems_https(source.uri.to_s)
+ check_typo_squatting(source)
+ source
+ end
end
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 5cdf5966d2..15e543f1a6 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
@@ -12,8 +13,8 @@ class Gem::Commands::SpecificationCommand < Gem::Command
Gem.load_yaml
super "specification", "Display gem specification (in yaml)",
- :domain => :local, :version => Gem::Requirement.default,
- :format => :yaml
+ domain: :local, version: Gem::Requirement.default,
+ format: :yaml
add_version_option("examine")
add_platform_option
@@ -41,7 +42,7 @@ class Gem::Commands::SpecificationCommand < Gem::Command
def arguments # :nodoc:
<<-ARGS
-GEMFILE name of gem to show the gemspec for
+GEM_OR_FILE gem name or a .gem file to show the gemspec for
FIELD name of gemspec field to show
ARGS
end
@@ -67,7 +68,7 @@ Specific fields in the specification can be extracted in YAML format:
end
def usage # :nodoc:
- "#{program_name} [GEMFILE] [FIELD]"
+ "#{program_name} [GEM_OR_FILE] [FIELD]"
end
def execute
@@ -76,7 +77,7 @@ Specific fields in the specification can be extracted in YAML format:
unless gem
raise Gem::CommandLineError,
- "Please specify a gem name or file on the command line"
+ "Please specify a gem name or a .gem file on the command line"
end
case v = options[:version]
@@ -106,7 +107,11 @@ Specific fields in the specification can be extracted in YAML format:
if local?
if File.exist? gem
- specs << Gem::Package.new(gem).spec rescue nil
+ begin
+ specs << Gem::Package.new(gem).spec
+ rescue StandardError
+ nil
+ end
end
if specs.empty?
@@ -133,7 +138,7 @@ Specific fields in the specification can be extracted in YAML format:
end
unless options[:all]
- specs = [specs.max_by {|s| s.version }]
+ specs = [specs.max_by(&:version)]
end
specs.each do |s|
@@ -142,7 +147,7 @@ Specific fields in the specification can be extracted in YAML format:
say case options[:format]
when :ruby then s.to_ruby
when :marshal then Marshal.dump s
- else s.to_yaml
+ else Gem.use_psych? ? s.to_yaml : Gem::YAMLSerializer.dump(s)
end
say "\n"
diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb
index 2812179d92..0be2b85159 100644
--- a/lib/rubygems/commands/stale_command.rb
+++ b/lib/rubygems/commands/stale_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::StaleCommand < Gem::Command
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index aa05cda2c8..3c26074f93 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
require_relative "../uninstaller"
@@ -14,8 +15,8 @@ class Gem::Commands::UninstallCommand < Gem::Command
def initialize
super "uninstall", "Uninstall gems from the local repository",
- :version => Gem::Requirement.default, :user_install => true,
- :check_dev => false, :vendor => false
+ version: Gem::Requirement.default, user_install: true,
+ check_dev: false, vendor: false
add_option("-a", "--[no-]all",
"Uninstall all matching versions") do |value, options|
@@ -94,7 +95,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
end
def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}' --no-force " +
+ "--version '#{Gem::Requirement.default}' --no-force " \
"--user-install"
end
@@ -116,7 +117,7 @@ that is a dependency of an existing gem. You can use the
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:>=2'`"
terminate_interaction 1
end
end
@@ -137,7 +138,7 @@ that is a dependency of an existing gem. You can use the
end
def uninstall_all
- specs = Gem::Specification.reject {|spec| spec.default_gem? }
+ specs = Gem::Specification.reject(&:default_gem?)
specs.each do |spec|
options[:version] = spec.version
@@ -156,9 +157,14 @@ that is a dependency of an existing gem. You can use the
gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
- say("Gem '#{name}' is not installed") if gem_specs.empty?
- gem_specs.each do |spec|
- deplist.add spec
+ if gem_specs.empty?
+ say("Gem '#{name}' is not installed")
+ else
+ gem_specs.reject!(&:default_gem?) if gem_specs.size > 1
+
+ gem_specs.each do |spec|
+ deplist.add spec
+ end
end
end
@@ -167,15 +173,14 @@ that is a dependency of an existing gem. You can use the
gems_to_uninstall = {}
deps.each do |dep|
- unless gems_to_uninstall[dep.name]
+ if original_gem_version[dep.name] == Gem::Requirement.default
+ next if gems_to_uninstall[dep.name]
gems_to_uninstall[dep.name] = true
-
- unless original_gem_version[dep.name] == Gem::Requirement.default
- options[:version] = dep.version
- end
-
- uninstall_gem(dep.name)
+ else
+ options[:version] = dep.version
end
+
+ uninstall_gem(dep.name)
end
end
@@ -183,12 +188,12 @@ that is a dependency of an existing gem. You can use the
uninstall(gem_name)
rescue Gem::GemNotInHomeException => e
spec = e.spec
- alert("In order to remove #{spec.name}, please execute:\n" +
- "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
+ alert("In order to remove #{spec.name}, please execute:\n" \
+ "\tgem uninstall #{spec.name} --install-dir=#{spec.base_dir}")
rescue Gem::UninstallError => e
spec = e.spec
- alert_error("Error: unable to successfully uninstall '#{spec.name}' which is " +
- "located at '#{spec.full_gem_path}'. This is most likely because" +
+ alert_error("Error: unable to successfully uninstall '#{spec.name}' which is " \
+ "located at '#{spec.full_gem_path}'. This is most likely because" \
"the current user does not have the appropriate permissions")
terminate_interaction 1
end
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index e48e36823c..c2fc720297 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../version_option"
require_relative "../security_option"
@@ -20,8 +21,8 @@ class Gem::Commands::UnpackCommand < Gem::Command
require "fileutils"
super "unpack", "Unpack an installed gem to the current directory",
- :version => Gem::Requirement.default,
- :target => Dir.pwd
+ version: Gem::Requirement.default,
+ target: Dir.pwd
add_option("--target=DIR",
"target directory for unpacking") do |value, options|
@@ -95,12 +96,10 @@ command help for an example.
FileUtils.mkdir_p @options[:target] if @options[:target]
- destination = begin
- if @options[:target]
- File.join @options[:target], spec_file
- else
- spec_file
- end
+ destination = if @options[:target]
+ File.join @options[:target], spec_file
+ else
+ spec_file
end
File.open destination, "w" do |io|
@@ -131,7 +130,7 @@ command help for an example.
return this_path if File.exist? this_path
end
- return nil
+ nil
end
##
@@ -144,24 +143,18 @@ command help for an example.
# 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(dependency)
- return dependency.name if dependency.name =~ /\.gem$/i
+ return dependency.name if /\.gem$/i.match?(dependency.name)
specs = dependency.matching_specs
- selected = specs.max_by {|s| s.version }
+ selected = specs.max_by(&:version)
return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
selected
- return unless dependency.name =~ /^#{selected.name}$/i
+ return unless /^#{selected.name}$/i.match?(dependency.name)
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
# the name match must be exact (ignoring case).
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 1801d8be28..d9740d814a 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../command_manager"
require_relative "../dependency_installer"
@@ -20,7 +21,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
def initialize
options = {
- :force => false,
+ force: false,
}
options.merge!(install_update_options)
@@ -36,10 +37,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
add_option("--system [VERSION]", Gem::Version,
- "Update the RubyGems system software") do |value, options|
- value = true unless value
+ "Update the RubyGems system software") do |value, opts|
+ value ||= true
- options[:system] = value
+ opts[:system] = value
end
add_local_remote_options
@@ -119,7 +120,7 @@ command to remove old versions.
updated = update_gems gems_to_update
installed_names = highest_installed_gems.keys
- updated_names = updated.map {|spec| spec.name }
+ updated_names = updated.map(&:name)
not_updated_names = options[:args].uniq - updated_names
not_installed_names = not_updated_names - installed_names
up_to_date_names = not_updated_names - not_installed_names
@@ -185,7 +186,9 @@ command to remove old versions.
system Gem.ruby, "--disable-gems", "setup.rb", *args
end
- say "RubyGems system software updated" if installed unless options[:silent]
+ unless options[:silent]
+ say "RubyGems system software updated" if installed
+ end
end
end
@@ -194,18 +197,17 @@ command to remove old versions.
yield
else
require "tmpdir"
- tmpdir = Dir.mktmpdir
- FileUtils.mv Gem.plugindir, tmpdir
+ Dir.mktmpdir("gem_update") do |tmpdir|
+ FileUtils.mv Gem.plugindir, tmpdir
- status = yield
+ status = yield
- if status
- FileUtils.rm_rf tmpdir
- else
- FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugindir
- end
+ unless status
+ FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugindir
+ end
- status
+ status
+ end
end
end
@@ -230,7 +232,7 @@ command to remove old versions.
highest_remote_tup = highest_remote_name_tuple(rubygems_update)
target = highest_remote_tup ? highest_remote_tup.version : version
- return target, requirement
+ [target, requirement]
end
def update_gem(name, version = Gem::Requirement.default)
@@ -241,7 +243,7 @@ command to remove old versions.
@installer = Gem::DependencyInstaller.new update_options
- say "Updating #{name}" unless options[:system] && options[:silent]
+ say "Updating #{name}" unless options[:system]
begin
@installer.install name, Gem::Requirement.new(version)
rescue Gem::InstallError, Gem::DependencyError => e
@@ -279,7 +281,7 @@ command to remove old versions.
check_oldest_rubygems version
installed_gems = Gem::Specification.find_all_by_name "rubygems-update", requirement
- installed_gems = update_gem("rubygems-update", version) if installed_gems.empty? || installed_gems.first.version != version
+ installed_gems = update_gem("rubygems-update", requirement) if installed_gems.empty? || installed_gems.first.version != version
return if installed_gems.empty?
install_rubygems installed_gems.first
@@ -291,9 +293,7 @@ command to remove old versions.
args << "--prefix" << Gem.prefix if Gem.prefix
args << "--no-document" unless options[:document].include?("rdoc") || options[:document].include?("ri")
args << "--no-format-executable" if options[:no_format_executable]
- args << "--previous-version" << Gem::VERSION if
- options[:system] == true ||
- Gem::Version.new(options[:system]) >= Gem::Version.new(2)
+ args << "--previous-version" << Gem::VERSION
args
end
@@ -317,20 +317,10 @@ command to remove old versions.
#
# Oldest version we support downgrading to. This is the version that
- # originally ships with the first patch version of each ruby, because we never
- # test each ruby against older rubygems, so we can't really guarantee it
- # works. Version list can be checked here: https://stdgems.org/rubygems
+ # originally ships with the oldest supported patch version of ruby.
#
def oldest_supported_version
@oldest_supported_version ||=
- if Gem.ruby_version > Gem::Version.new("3.1.a")
- Gem::Version.new("3.3.3")
- elsif Gem.ruby_version > Gem::Version.new("3.0.a")
- Gem::Version.new("3.2.3")
- elsif Gem.ruby_version > Gem::Version.new("2.7.a")
- Gem::Version.new("3.1.2")
- else
- Gem::Version.new("3.0.1")
- end
+ Gem::Version.new("3.3.3")
end
end
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index 5b9a79b734..5ed4d9d142 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true
+
require_relative "../command"
class Gem::Commands::WhichCommand < Gem::Command
def initialize
super "which", "Find the location of a library file you can require",
- :search_gems_first => false, :show_all => false
+ 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
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index 1499f72f5d..fbdc262549 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../command"
require_relative "../local_remote_options"
require_relative "../version_option"
@@ -61,7 +62,7 @@ data you will need to change them immediately and yank your gem.
end
def yank_gem(version, platform)
- say "Yanking gem from #{self.host}..."
+ say "Yanking gem from #{host}..."
args = [:delete, version, platform, "api/v1/gems/yank"]
response = yank_api_request(*args)
@@ -88,7 +89,7 @@ data you will need to change them immediately and yank your gem.
def get_version_from_requirements(requirements)
requirements.requirements.first[1].version
- rescue
+ rescue StandardError
nil
end
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
deleted file mode 100644
index d04ab6483d..0000000000
--- a/lib/rubygems/compatibility.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-#--
-# This file contains all sorts of little compatibility hacks that we've
-# had to introduce over the years. Quarantining them into one file helps
-# us know when we can get rid of them.
-#
-# Ruby 1.9.x has introduced some things that are awkward, and we need to
-# support them, so we define some constants to use later.
-#
-# TODO remove at RubyGems 4
-#++
-
-module Gem
- # :stopdoc:
-
- RubyGemsVersion = VERSION
- deprecate_constant(:RubyGemsVersion)
-
- RbConfigPriorities = %w[
- MAJOR
- MINOR
- TEENY
- EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
- ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
- rubylibdir
- ].freeze
-
- unless defined?(ConfigMap)
- ##
- # Configuration settings from ::RbConfig
- ConfigMap = Hash.new do |cm, key|
- cm[key] = RbConfig::CONFIG[key.to_s]
- end
- deprecate_constant(:ConfigMap)
- else
- RbConfigPriorities.each do |key|
- ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
- end
- end
-end
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index c1dda3404d..d5e9eb4e33 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -25,9 +26,22 @@ require "rbconfig"
# RubyGems options use symbol keys. Valid options are:
#
# +:backtrace+:: See #backtrace
-# +:sources+:: Sets Gem::sources
+# +:bulk_threshold+:: See #bulk_threshold
# +:verbose+:: See #verbose
+# +:update_sources+:: See #update_sources
# +:concurrent_downloads+:: See #concurrent_downloads
+# +:cert_expiration_length_days+:: See #cert_expiration_length_days
+# +:install_extension_in_lib+:: See #install_extension_in_lib
+# +:ipv4_fallback_enabled+:: See #ipv4_fallback_enabled
+# +:global_gem_cache+:: See #global_gem_cache
+# +:use_psych+:: See #use_psych
+# +:gemhome+:: See #home
+# +:gempath+:: See #path
+# +:sources+:: Sets Gem::sources
+# +:disable_default_gem_server+:: See #disable_default_gem_server
+# +:ssl_verify_mode+:: See #ssl_verify_mode
+# +:ssl_ca_cert+:: See #ssl_ca_cert
+# +:ssl_client_cert+:: See #ssl_client_cert
#
# gemrc files may exist in various locations and are read and merged in
# the following order:
@@ -46,6 +60,9 @@ class Gem::ConfigFile
DEFAULT_CONCURRENT_DOWNLOADS = 8
DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
DEFAULT_IPV4_FALLBACK_ENABLED = false
+ DEFAULT_INSTALL_EXTENSION_IN_LIB = true
+ DEFAULT_GLOBAL_GEM_CACHE = false
+ DEFAULT_USE_PSYCH = false
##
# For Ruby packagers to set configuration defaults. Set in
@@ -142,12 +159,28 @@ class Gem::ConfigFile
attr_accessor :cert_expiration_length_days
##
+ # Install extensions into lib as well as into the extension directory.
+
+ attr_accessor :install_extension_in_lib
+
+ ##
# == Experimental ==
# Fallback to IPv4 when IPv6 is not reachable or slow (default: false)
attr_accessor :ipv4_fallback_enabled
##
+ # Use a global cache for .gem files shared across all Ruby installations.
+ # When enabled, gems are cached to ~/.cache/gem/gems (or XDG_CACHE_HOME/gem/gems).
+
+ attr_accessor :global_gem_cache
+
+ ##
+ # Use Psych (C extension YAML parser) instead of the pure Ruby YAMLSerializer.
+
+ attr_accessor :use_psych
+
+ ##
# Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
attr_reader :ssl_client_cert
@@ -182,15 +215,18 @@ class Gem::ConfigFile
@update_sources = DEFAULT_UPDATE_SOURCES
@concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
@cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS
+ @install_extension_in_lib = DEFAULT_INSTALL_EXTENSION_IN_LIB
@ipv4_fallback_enabled = ENV["IPV4_FALLBACK_ENABLED"] == "true" || DEFAULT_IPV4_FALLBACK_ENABLED
+ @global_gem_cache = ENV["RUBYGEMS_GLOBAL_GEM_CACHE"] == "true" || DEFAULT_GLOBAL_GEM_CACHE
+ @use_psych = ENV["RUBYGEMS_USE_PSYCH"] == "true" || DEFAULT_USE_PSYCH
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
- user_config = load_file config_file_name.dup.tap(&Gem::UNTAINT)
+ user_config = load_file config_file_name
- environment_config = (ENV["GEMRC"] || "")
- .split(File::PATH_SEPARATOR).inject({}) do |result, file|
+ environment_config = (ENV["GEMRC"] || "").
+ split(File::PATH_SEPARATOR).inject({}) do |result, file|
result.merge load_file file
end
@@ -201,21 +237,37 @@ class Gem::ConfigFile
@hash = @hash.merge environment_config
end
- # HACK these override command-line args, which is bad
+ @hash.transform_keys! do |k|
+ # gemhome and gempath are not working with symbol keys
+ if %w[backtrace bulk_threshold verbose update_sources cert_expiration_length_days
+ concurrent_downloads install_extension_in_lib ipv4_fallback_enabled
+ global_gem_cache use_psych sources
+ disable_default_gem_server ssl_verify_mode ssl_ca_cert ssl_client_cert].include?(k)
+ k.to_sym
+ else
+ k
+ end
+ end
+
+ # HACK: these override command-line args, which is bad
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
@bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- @home = @hash[:gemhome] if @hash.key? :gemhome
- @path = @hash[:gempath] if @hash.key? :gempath
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
@verbose = @hash[:verbose] if @hash.key? :verbose
- @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
- @sources = @hash[:sources] if @hash.key? :sources
+ @update_sources = @hash[:update_sources] if @hash.key? :update_sources
+ @concurrent_downloads = @hash[:concurrent_downloads] if @hash.key? :concurrent_downloads
@cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
+ @install_extension_in_lib = @hash[:install_extension_in_lib] if @hash.key? :install_extension_in_lib
@ipv4_fallback_enabled = @hash[:ipv4_fallback_enabled] if @hash.key? :ipv4_fallback_enabled
+ @global_gem_cache = @hash[:global_gem_cache] if @hash.key? :global_gem_cache
+ @use_psych = @hash[:use_psych] if @hash.key? :use_psych
- @ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
- @ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
- @ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
+ @home = @hash[:gemhome] if @hash.key? :gemhome
+ @path = @hash[:gempath] if @hash.key? :gempath
+ @sources = @hash[:sources] if @hash.key? :sources
+ @disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
+ @ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
+ @ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
+ @ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
@api_keys = nil
@rubygems_api_key = nil
@@ -240,9 +292,9 @@ class Gem::ConfigFile
return if Gem.win_platform? # windows doesn't write 0600 as 0600
return unless File.exist? credentials_path
- existing_permissions = File.stat(credentials_path).mode & 0777
+ existing_permissions = File.stat(credentials_path).mode & 0o777
- return if existing_permissions == 0600
+ return if existing_permissions == 0o600
alert_error <<-ERROR
Your gem push credentials file located at:
@@ -323,11 +375,9 @@ if you believe they were disclosed to a third party.
require "fileutils"
FileUtils.mkdir_p(dirname)
- Gem.load_yaml
-
- permissions = 0600 & (~File.umask)
+ permissions = 0o600 & ~File.umask
File.open(credentials_path, "w", permissions) do |f|
- f.write config.to_yaml
+ f.write self.class.dump_with_rubygems_yaml(config)
end
load_api_keys # reload
@@ -343,20 +393,20 @@ if you believe they were disclosed to a third party.
end
def load_file(filename)
- Gem.load_yaml
-
yaml_errors = [ArgumentError]
- yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)
return {} unless filename && !filename.empty? && File.exist?(filename)
begin
- content = Gem::SafeYAML.load(File.read(filename))
- unless content.is_a? Hash
+ config = self.class.load_with_rubygems_config_hash(File.read(filename))
+ has_invalid_keys = config.keys.any? {|k| k.to_s.gsub(%r{https?:\/\/}, "").include?(": ") }
+ has_invalid_values = config.values.any? {|v| v.is_a?(String) && v.gsub(%r{https?:\/\/}, "").match?(/\A\S+: /) }
+ if has_invalid_keys || has_invalid_values
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
return {}
+ else
+ return config
end
- return content
rescue *yaml_errors => e
warn "Failed to load #{filename}, #{e}"
rescue Errno::EACCES
@@ -467,6 +517,9 @@ if you believe they were disclosed to a third party.
yaml_hash[:concurrent_downloads] =
@hash.fetch(:concurrent_downloads, DEFAULT_CONCURRENT_DOWNLOADS)
+ yaml_hash[:install_extension_in_lib] =
+ @hash.fetch(:install_extension_in_lib, DEFAULT_INSTALL_EXTENSION_IN_LIB)
+
yaml_hash[:ssl_verify_mode] =
@hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@@ -476,17 +529,17 @@ if you believe they were disclosed to a third party.
yaml_hash[:ssl_client_cert] =
@hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
- keys = yaml_hash.keys.map {|key| key.to_s }
+ keys = yaml_hash.keys.map(&:to_s)
keys << "debug"
re = Regexp.union(*keys)
@hash.each do |key, value|
key = key.to_s
- next if key =~ re
+ next if key&.match?(re)
yaml_hash[key.to_s] = value
end
- yaml_hash.to_yaml
+ self.class.dump_with_rubygems_yaml(yaml_hash)
end
# Writes out this config file, replacing its source.
@@ -501,12 +554,12 @@ if you believe they were disclosed to a third party.
# Return the configuration information for +key+.
def [](key)
- @hash[key.to_s]
+ @hash[key] || @hash[key.to_s]
end
# Set configuration option +key+ to +value+.
def []=(key, value)
- @hash[key.to_s] = value
+ @hash[key] = value
end
def ==(other) # :nodoc:
@@ -521,8 +574,66 @@ if you believe they were disclosed to a third party.
attr_reader :hash
protected :hash
+ def self.dump_with_rubygems_yaml(content)
+ content.transform_keys! do |k|
+ k.is_a?(Symbol) ? ":#{k}" : k
+ end
+
+ require_relative "yaml_serializer"
+ Gem::YAMLSerializer.dump(content)
+ end
+
+ def self.load_with_rubygems_config_hash(yaml)
+ require_relative "yaml_serializer"
+
+ content = Gem::YAMLSerializer.load(yaml, permitted_classes: [])
+ return {} unless content.is_a?(Hash)
+
+ deep_transform_config_keys!(content)
+ end
+
private
+ def self.deep_transform_config_keys!(config)
+ config.transform_keys! do |k|
+ if k.match?(/\A:(.*)\Z/)
+ k[1..-1].to_sym
+ elsif k.include?("__") || k.match?(%r{/\Z})
+ if k.is_a?(Symbol)
+ k.to_s.gsub(/__/,".").gsub(%r{/\Z}, "").to_sym
+ else
+ k.dup.gsub(/__/,".").gsub(%r{/\Z}, "")
+ end
+ else
+ k
+ end
+ end
+
+ config.transform_values! do |v|
+ if v.is_a?(String)
+ if v.match?(/\A:(.*)\Z/)
+ v[1..-1].to_sym
+ elsif v.match?(/\A[+-]?\d+\Z/)
+ v.to_i
+ elsif v.match?(/\Atrue|false\Z/)
+ v == "true"
+ elsif v.empty?
+ nil
+ else
+ v
+ end
+ elsif v.respond_to?(:empty?) && v.empty?
+ nil
+ elsif v.is_a?(Hash)
+ deep_transform_config_keys!(v)
+ else
+ v
+ end
+ end
+
+ config
+ end
+
def set_config_file_name(args)
@config_file_name = ENV["GEMRC"]
need_config_file_name = false
@@ -533,7 +644,7 @@ if you believe they were disclosed to a third party.
need_config_file_name = false
elsif arg =~ /^--config-file=(.*)/
@config_file_name = $1
- elsif arg =~ /^--config-file$/
+ elsif /^--config-file$/.match?(arg)
need_config_file_name = true
end
end
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index d92b3429e4..3a9bdbdc9d 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -35,53 +36,48 @@ module Kernel
def require(path) # :doc:
return gem_original_require(path) unless Gem.discover_gems_on_require
- begin
- RUBYGEMS_ACTIVATION_MONITOR.enter
+ RUBYGEMS_ACTIVATION_MONITOR.synchronize do
+ path = File.path(path)
+
+ # If +path+ belongs to a default gem, we activate it and then go straight
+ # to normal require
+
+ if spec = Gem.find_default_spec(path)
+ name = spec.name
- path = path.to_path if path.respond_to? :to_path
+ next if Gem.loaded_specs[name]
- if spec = Gem.find_unresolved_default_spec(path)
# Ensure -I beats a default gem
resolved_path = begin
rp = nil
load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
- Gem.suffixes.each do |s|
- $LOAD_PATH[0...load_path_check_index].each do |lp|
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
- begin
- if File.symlink? safe_lp # for backward compatibility
- next
- end
- rescue SecurityError
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
+ Gem.suffixes.find do |s|
+ $LOAD_PATH[0...load_path_check_index].find do |lp|
+ if File.symlink? lp # for backward compatibility
+ next
end
- full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
- if File.file?(full_path)
- rp = full_path
- break
- end
+ full_path = File.expand_path(File.join(lp, "#{path}#{s}"))
+ rp = full_path if File.file?(full_path)
end
- break if rp
end
rp
end
- begin
- Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease)
- rescue Exception
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
- end unless resolved_path
+ next if resolved_path
+
+ Kernel.send(:gem, name, Gem::Requirement.default_prerelease)
+
+ Gem.load_bundler_extensions(Gem.loaded_specs[name].version) if name == "bundler"
+
+ next
end
# If there are no unresolved deps, then we can use just try
# normal require handle loading a gem from the rescue below.
if Gem::Specification.unresolved_deps.empty?
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(path)
+ next
end
# If +path+ is for a gem that has already been loaded, don't
@@ -91,8 +87,7 @@ module Kernel
# TODO request access to the C implementation of this to speed up RubyGems
if Gem::Specification.find_active_stub_by_path(path)
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(path)
+ next
end
# Attempt to find +path+ in any unresolved gems...
@@ -112,9 +107,7 @@ module Kernel
if found_specs.empty?
found_specs = Gem::Specification.find_in_unresolved_tree path
- found_specs.each do |found_spec|
- found_spec.activate
- end
+ found_specs.each(&:activate)
# We found +path+ directly in an unresolved gem. Now we figure out, of
# the possible found specs, which one we should activate.
@@ -125,7 +118,6 @@ module Kernel
names = found_specs.map(&:name).uniq
if names.size > 1
- RUBYGEMS_ACTIVATION_MONITOR.exit
raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ", "}"
end
@@ -136,26 +128,20 @@ module Kernel
unless valid
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
le.name = names.first
- RUBYGEMS_ACTIVATION_MONITOR.exit
raise le
end
valid.activate
end
+ end
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(path)
+ begin
+ gem_original_require(path)
rescue LoadError => load_error
- if load_error.path == path
- RUBYGEMS_ACTIVATION_MONITOR.enter
-
- begin
- require_again = Gem.try_activate(path)
- ensure
- RUBYGEMS_ACTIVATION_MONITOR.exit
- end
+ if load_error.path == path &&
+ RUBYGEMS_ACTIVATION_MONITOR.synchronize { Gem.try_activate(path) }
- return gem_original_require(path) if require_again
+ return gem_original_require(path)
end
raise load_error
diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb
index 2dadf1fcd8..f806b77fab 100644
--- a/lib/rubygems/core_ext/kernel_warn.rb
+++ b/lib/rubygems/core_ext/kernel_warn.rb
@@ -13,11 +13,7 @@ module Kernel
module_function define_method(:warn) {|*messages, **kw|
unless uplevel = kw[:uplevel]
- if Gem.java_platform? && RUBY_VERSION < "3.1"
- return original_warn.bind(self).call(*messages)
- else
- return original_warn.bind(self).call(*messages, **kw)
- end
+ return original_warn.bind_call(self, *messages, **kw)
end
# Ensure `uplevel` fits a `long`
@@ -35,16 +31,15 @@ module Kernel
start += 1
- if path = loc.path
- unless path.start_with?(rubygems_path, "<internal:")
- # Non-rubygems frames
- uplevel -= 1
- end
+ next unless path = loc.path
+ unless path.start_with?(rubygems_path, "<internal:")
+ # Non-rubygems frames
+ uplevel -= 1
end
end
kw[:uplevel] = start
end
- original_warn.bind(self).call(*messages, **kw)
+ original_warn.bind_call(self, *messages, **kw)
}
end
diff --git a/lib/rubygems/core_ext/tcpsocket_init.rb b/lib/rubygems/core_ext/tcpsocket_init.rb
index c9e0a92953..018c49dbeb 100644
--- a/lib/rubygems/core_ext/tcpsocket_init.rb
+++ b/lib/rubygems/core_ext/tcpsocket_init.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "socket"
module CoreExtensions
@@ -17,7 +19,7 @@ module CoreExtensions
cond_var = Thread::ConditionVariable.new
Addrinfo.foreach(host, serv, nil, :STREAM) do |addr|
- Thread.report_on_exception = false if defined? Thread.report_on_exception = ()
+ Thread.report_on_exception = false
threads << Thread.new(addr) do
# give head start to ipv6 addresses
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index b186375f69..2247c49c81 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Gem
DEFAULT_HOST = "https://rubygems.org"
@@ -12,7 +13,7 @@ module Gem
# An Array of the default sources that come with RubyGems
def self.default_sources
- %w[https://rubygems.org/]
+ @default_sources ||= %w[https://rubygems.org/]
end
##
@@ -23,7 +24,7 @@ module Gem
default_spec_cache_dir = File.join Gem.user_home, ".gem", "specs"
unless File.exist?(default_spec_cache_dir)
- default_spec_cache_dir = File.join Gem.data_home, "gem", "specs"
+ default_spec_cache_dir = File.join Gem.cache_home, "gem", "specs"
end
default_spec_cache_dir
@@ -79,7 +80,7 @@ module Gem
def self.find_home
Dir.home.dup
- rescue
+ rescue StandardError
if Gem.win_platform?
File.expand_path File.join(ENV["HOMEDRIVE"] || ENV["SystemDrive"], "/")
else
@@ -93,7 +94,7 @@ module Gem
# The home directory for the user.
def self.user_home
- @user_home ||= find_home.tap(&Gem::UNTAINT)
+ @user_home ||= find_home
end
##
@@ -111,7 +112,7 @@ module Gem
# The path to standard location of the user's configuration directory.
def self.config_home
- @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, ".config"))
+ @config_home ||= ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, ".config")
end
##
@@ -130,35 +131,44 @@ module Gem
# The path to standard location of the user's .gemrc file.
def self.config_file
- @config_file ||= find_config_file.tap(&Gem::UNTAINT)
+ @config_file ||= find_config_file
end
##
# The path to standard location of the user's state file.
def self.state_file
- @state_file ||= File.join(Gem.state_home, "gem", "last_update_check").tap(&Gem::UNTAINT)
+ @state_file ||= File.join(Gem.state_home, "gem", "last_update_check")
end
##
# The path to standard location of the user's cache directory.
def self.cache_home
- @cache_home ||= (ENV["XDG_CACHE_HOME"] || File.join(Gem.user_home, ".cache"))
+ @cache_home ||= ENV["XDG_CACHE_HOME"] || File.join(Gem.user_home, ".cache")
+ end
+
+ ##
+ # The path to the global gem cache directory.
+ # This is used when global_gem_cache is enabled to share .gem files
+ # across all Ruby installations.
+
+ def self.global_gem_cache_path
+ File.join(cache_home, "gem", "gems")
end
##
# The path to standard location of the user's data directory.
def self.data_home
- @data_home ||= (ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, ".local", "share"))
+ @data_home ||= ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, ".local", "share")
end
##
# The path to standard location of the user's state directory.
def self.state_home
- @state_home ||= (ENV["XDG_STATE_HOME"] || File.join(Gem.user_home, ".local", "state"))
+ @state_home ||= ENV["XDG_STATE_HOME"] || File.join(Gem.user_home, ".local", "state")
end
##
@@ -183,7 +193,11 @@ module Gem
# Deduce Ruby's --program-prefix and --program-suffix from its install name
def self.default_exec_format
- exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s"
+ exec_format = begin
+ RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s")
+ rescue StandardError
+ "%s"
+ end
unless exec_format.include?("%s")
raise Gem::Exception,
@@ -231,10 +245,22 @@ module Gem
end
##
+ # Enables automatic installation into user directory
+
+ def self.default_user_install # :nodoc:
+ if !ENV.key?("GEM_HOME") && File.exist?(Gem.dir) && !File.writable?(Gem.dir)
+ Gem.ui.say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
+ return true
+ end
+
+ false
+ end
+
+ ##
# Install extensions into lib as well as into the extension directory.
def self.install_extension_in_lib # :nodoc:
- true
+ Gem.configuration.install_extension_in_lib
end
##
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index fde05e9332..1e91f493a6 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The Dependency class holds a Gem name and a Gem::Requirement.
@@ -45,10 +46,10 @@ class Gem::Dependency
end
type = Symbol === requirements.last ? requirements.pop : :runtime
- requirements = requirements.first if 1 == requirements.length # unpack
+ requirements = requirements.first if requirements.length == 1 # unpack
unless TYPES.include? type
- raise ArgumentError, "Valid types are #{TYPES.inspect}, " +
+ raise ArgumentError, "Valid types are #{TYPES.inspect}, " \
"not #{type.inspect}"
end
@@ -73,11 +74,9 @@ class Gem::Dependency
def inspect # :nodoc:
if prerelease?
- "<%s type=%p name=%p requirements=%p prerelease=ok>" %
- [self.class, self.type, self.name, requirement.to_s]
+ format("<%s type=%p name=%p requirements=%p prerelease=ok>", self.class, type, name, requirement.to_s)
else
- "<%s type=%p name=%p requirements=%p>" %
- [self.class, self.type, self.name, requirement.to_s]
+ format("<%s type=%p name=%p requirements=%p>", self.class, type, name, requirement.to_s)
end
end
@@ -168,16 +167,16 @@ class Gem::Dependency
def ==(other) # :nodoc:
Gem::Dependency === other &&
- self.name == other.name &&
- self.type == other.type &&
- self.requirement == other.requirement
+ name == other.name &&
+ type == other.type &&
+ requirement == other.requirement
end
##
# Dependencies are ordered by name.
def <=>(other)
- self.name <=> other.name
+ name <=> other.name
end
##
@@ -218,7 +217,7 @@ class Gem::Dependency
# NOTE: Unlike #matches_spec? this method does not return true when the
# version is a prerelease version unless this is a prerelease dependency.
- def match?(obj, version=nil, allow_prerelease=false)
+ def match?(obj, version = nil, allow_prerelease = false)
if !version
name = obj.name
version = obj.version
@@ -262,7 +261,7 @@ class Gem::Dependency
end
default = Gem::Requirement.default
- self_req = self.requirement
+ self_req = requirement
other_req = other.requirement
return self.class.new name, self_req if other_req == default
@@ -272,15 +271,7 @@ class Gem::Dependency
end
def matching_specs(platform_only = false)
- env_req = Gem.env_requirement(name)
- matches = Gem::Specification.stubs_for(name).find_all do |spec|
- requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
- end.map(&:to_spec)
-
- if prioritizes_bundler?
- require_relative "bundler_version_finder"
- Gem::BundlerVersionFinder.prioritize!(matches)
- end
+ matches = Gem::Specification.find_all_by_name(name, requirement)
if platform_only
matches.reject! do |spec|
@@ -288,7 +279,7 @@ class Gem::Dependency
end
end
- matches
+ matches.reject(&:ignored?)
end
##
@@ -298,10 +289,6 @@ class Gem::Dependency
@requirement.specific?
end
- def prioritizes_bundler?
- name == "bundler" && !specific?
- end
-
def to_specs
matches = matching_specs true
@@ -323,15 +310,15 @@ class Gem::Dependency
end
def to_spec
- matches = self.to_specs.compact
+ matches = to_specs.compact
- active = matches.find {|spec| spec.activated? }
+ active = matches.find(&:activated?)
return active if active
unless prerelease?
- # Move prereleases to the end of the list for >= 0 requirements
+ # Consider prereleases only as a fallback
pre, matches = matches.partition {|spec| spec.version.prerelease? }
- matches += pre if requirement == Gem::Requirement.default
+ matches = pre if matches.empty?
end
matches.first
@@ -350,4 +337,12 @@ class Gem::Dependency
:released
end
end
+
+ def encode_with(coder) # :nodoc:
+ coder.add "name", @name
+ coder.add "requirement", @requirement
+ coder.add "type", @type
+ coder.add "prerelease", @prerelease
+ coder.add "version_requirements", @version_requirements
+ end
end
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 941a5bda4c..c842714d95 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../rubygems"
require_relative "dependency_list"
require_relative "package"
@@ -6,28 +7,25 @@ require_relative "installer"
require_relative "spec_fetcher"
require_relative "user_interaction"
require_relative "available_set"
-require_relative "deprecate"
##
# Installs a gem along with all its dependencies from local and remote gems.
class Gem::DependencyInstaller
include Gem::UserInteraction
- extend Gem::Deprecate
DEFAULT_OPTIONS = { # :nodoc:
- :env_shebang => false,
- :document => %w[ri],
- :domain => :both, # HACK dup
- :force => false,
- :format_executable => false, # HACK dup
- :ignore_dependencies => false,
- :prerelease => false,
- :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
- :wrappers => true,
- :build_args => nil,
- :build_docs_in_background => false,
- :install_as_default => false,
+ env_shebang: false,
+ document: %w[ri],
+ domain: :both, # HACK: dup
+ force: false,
+ format_executable: false, # HACK: dup
+ ignore_dependencies: false,
+ prerelease: false,
+ security_policy: nil, # HACK: NoSecurity requires OpenSSL. AlmostNo? Low?
+ wrappers: true,
+ build_args: nil,
+ build_docs_in_background: false,
}.freeze
##
@@ -65,7 +63,7 @@ class Gem::DependencyInstaller
# :build_args:: See Gem::Installer::new
def initialize(options = {})
- @only_install_dir = !!options[:install_dir]
+ @only_install_dir = !options[:install_dir].nil?
@install_dir = options[:install_dir] || Gem.dir
@build_root = options[:build_root]
@@ -85,11 +83,13 @@ class Gem::DependencyInstaller
@user_install = options[:user_install]
@wrappers = options[:wrappers]
@build_args = options[:build_args]
+ @build_jobs = options[:build_jobs]
@build_docs_in_background = options[:build_docs_in_background]
- @install_as_default = options[:install_as_default]
@dir_mode = options[:dir_mode]
@data_mode = options[:data_mode]
@prog_mode = options[:prog_mode]
+ @build_extension = options[:build_extension]
+ @install_plugin = options[:install_plugin]
# Indicates that we should not try to update any deps unless
# we absolutely must.
@@ -120,80 +120,6 @@ class Gem::DependencyInstaller
@domain == :both || @domain == :remote
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 preferred over older gems, and
- # local gems preferred over remote gems.
-
- def find_gems_with_sources(dep, best_only=false) # :nodoc:
- set = Gem::AvailableSet.new
-
- if consider_local?
- sl = Gem::Source::Local.new
-
- if spec = sl.find_gem(dep.name)
- if dep.matches_spec? spec
- set.add spec, sl
- end
- end
- end
-
- if consider_remote?
- begin
- # This is pulled from #spec_for_dependency to allow
- # us to filter tuples before fetching specs.
- tuples, errors = Gem::SpecFetcher.fetcher.search_for_dependency dep
-
- if best_only && !tuples.empty?
- tuples.sort! do |a,b|
- if b[0].version == a[0].version
- if b[0].platform != Gem::Platform::RUBY
- 1
- else
- -1
- end
- else
- b[0].version <=> a[0].version
- end
- end
- tuples = [tuples.first]
- end
-
- specs = []
- tuples.each do |tup, source|
- begin
- spec = source.fetch_spec(tup)
- rescue Gem::RemoteFetcher::FetchError => e
- errors << Gem::SourceFetchProblem.new(source, e)
- else
- specs << [spec, source]
- end
- end
-
- if @errors
- @errors += errors
- else
- @errors = errors
- end
-
- set << specs
- rescue Gem::RemoteFetcher::FetchError => e
- # FIX if there is a problem talking to the network, we either need to always tell
- # the user (no really_verbose) or fail hard, not silently tell them that we just
- # couldn't find their requested gem.
- verbose do
- "Error fetching remote data:\t\t#{e.message}\n" \
- "Falling back to local-only install"
- end
- @domain = :local
- end
- end
-
- set
- end
- rubygems_deprecate :find_gems_with_sources
-
def in_background(what) # :nodoc:
fork_happened = false
if @build_docs_in_background && Process.respond_to?(:fork)
@@ -229,22 +155,24 @@ class Gem::DependencyInstaller
@installed_gems = []
options = {
- :bin_dir => @bin_dir,
- :build_args => @build_args,
- :document => @document,
- :env_shebang => @env_shebang,
- :force => @force,
- :format_executable => @format_executable,
- :ignore_dependencies => @ignore_dependencies,
- :prerelease => @prerelease,
- :security_policy => @security_policy,
- :user_install => @user_install,
- :wrappers => @wrappers,
- :build_root => @build_root,
- :install_as_default => @install_as_default,
- :dir_mode => @dir_mode,
- :data_mode => @data_mode,
- :prog_mode => @prog_mode,
+ bin_dir: @bin_dir,
+ build_args: @build_args,
+ build_jobs: @build_jobs,
+ document: @document,
+ env_shebang: @env_shebang,
+ force: @force,
+ format_executable: @format_executable,
+ ignore_dependencies: @ignore_dependencies,
+ prerelease: @prerelease,
+ security_policy: @security_policy,
+ user_install: @user_install,
+ wrappers: @wrappers,
+ build_root: @build_root,
+ dir_mode: @dir_mode,
+ data_mode: @data_mode,
+ prog_mode: @prog_mode,
+ build_extension: @build_extension,
+ install_plugin: @install_plugin,
}
options[:install_dir] = @install_dir if @only_install_dir
@@ -292,13 +220,11 @@ class Gem::DependencyInstaller
src = Gem::Source::SpecificFile.new dep_or_name
installer_set.add_local dep_or_name, src.spec, src
version = src.spec.version if version == Gem::Requirement.default
- elsif dep_or_name =~ /\.gem$/
+ elsif dep_or_name =~ /\.gem$/ # rubocop:disable Performance/RegexpMatch
Dir[dep_or_name].each do |name|
- begin
- src = Gem::Source::SpecificFile.new name
- installer_set.add_local dep_or_name, src.spec, src
- rescue Gem::Package::FormatError
- end
+ src = Gem::Source::SpecificFile.new name
+ installer_set.add_local dep_or_name, src.spec, src
+ rescue Gem::Package::FormatError
end
# else This is a dependency. InstallerSet handles this case
end
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index eaf6702177..d50cfe2d54 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require_relative "tsort"
-require_relative "deprecate"
+require_relative "vendored_tsort"
##
# Gem::DependencyList is used for installing and uninstalling gems in the
@@ -104,7 +104,7 @@ class Gem::DependencyList
end
def inspect # :nodoc:
- "%s %p>" % [super[0..-2], map {|s| s.full_name }]
+ format("%s %p>", super[0..-2], map(&:full_name))
end
##
@@ -139,7 +139,7 @@ class Gem::DependencyList
# If removing the gemspec creates breaks a currently ok dependency, then it
# is NOT ok to remove the gemspec.
- def ok_to_remove?(full_name, check_dev=true)
+ def ok_to_remove?(full_name, check_dev = true)
gem_to_remove = find_name full_name
# If the state is inconsistent, at least don't crash
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index c0554aa763..eb503bb269 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -1,163 +1,171 @@
# frozen_string_literal: true
-##
-# Provides 3 methods for declaring when something is going away.
-#
-# +deprecate(name, repl, year, month)+:
-# Indicate something may be removed on/after a certain date.
-#
-# +rubygems_deprecate(name, replacement=:none)+:
-# Indicate something will be removed in the next major RubyGems version,
-# and (optionally) a replacement for it.
-#
-# +rubygems_deprecate_command+:
-# Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
-# removed in the next RubyGems version.
-#
-# Also provides +skip_during+ for temporarily turning off deprecation warnings.
-# This is intended to be used in the test suite, so deprecation warnings
-# don't cause test failures if you need to make sure stderr is otherwise empty.
-#
-#
-# Example usage of +deprecate+ and +rubygems_deprecate+:
-#
-# class Legacy
-# def self.some_class_method
-# # ...
-# end
-#
-# def some_instance_method
-# # ...
-# end
-#
-# def some_old_method
-# # ...
-# end
-#
-# extend Gem::Deprecate
-# deprecate :some_instance_method, "X.z", 2011, 4
-# rubygems_deprecate :some_old_method, "Modern#some_new_method"
-#
-# class << self
-# extend Gem::Deprecate
-# deprecate :some_class_method, :none, 2011, 4
-# end
-# end
-#
-#
-# Example usage of +rubygems_deprecate_command+:
-#
-# class Gem::Commands::QueryCommand < Gem::Command
-# extend Gem::Deprecate
-# rubygems_deprecate_command
-#
-# # ...
-# end
-#
-#
-# Example usage of +skip_during+:
-#
-# class TestSomething < Gem::Testcase
-# def test_some_thing_with_deprecations
-# Gem::Deprecate.skip_during do
-# actual_stdout, actual_stderr = capture_output do
-# Gem.something_deprecated
-# end
-# assert_empty actual_stdout
-# assert_equal(expected, actual_stderr)
-# end
-# end
-# end
-module Gem::Deprecate
- def self.skip # :nodoc:
- @skip ||= false
- end
+module Gem
+ ##
+ # Provides 3 methods for declaring when something is going away.
+ #
+ # <tt>deprecate(name, repl, year, month)</tt>:
+ # Indicate something may be removed on/after a certain date.
+ #
+ # <tt>rubygems_deprecate(name, replacement=:none)</tt>:
+ # Indicate something will be removed in the next major RubyGems version,
+ # and (optionally) a replacement for it.
+ #
+ # +rubygems_deprecate_command+:
+ # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
+ # removed in the next RubyGems version.
+ #
+ # Also provides +skip_during+ for temporarily turning off deprecation warnings.
+ # This is intended to be used in the test suite, so deprecation warnings
+ # don't cause test failures if you need to make sure stderr is otherwise empty.
+ #
+ #
+ # Example usage of +deprecate+ and +rubygems_deprecate+:
+ #
+ # class Legacy
+ # def self.some_class_method
+ # # ...
+ # end
+ #
+ # def some_instance_method
+ # # ...
+ # end
+ #
+ # def some_old_method
+ # # ...
+ # end
+ #
+ # extend Gem::Deprecate
+ # deprecate :some_instance_method, "X.z", 2011, 4
+ # rubygems_deprecate :some_old_method, "Modern#some_new_method"
+ #
+ # class << self
+ # extend Gem::Deprecate
+ # deprecate :some_class_method, :none, 2011, 4
+ # end
+ # end
+ #
+ #
+ # Example usage of +rubygems_deprecate_command+:
+ #
+ # class Gem::Commands::QueryCommand < Gem::Command
+ # extend Gem::Deprecate
+ # rubygems_deprecate_command
+ #
+ # # ...
+ # end
+ #
+ #
+ # Example usage of +skip_during+:
+ #
+ # class TestSomething < Gem::Testcase
+ # def test_some_thing_with_deprecations
+ # Gem::Deprecate.skip_during do
+ # actual_stdout, actual_stderr = capture_output do
+ # Gem.something_deprecated
+ # end
+ # assert_empty actual_stdout
+ # assert_equal(expected, actual_stderr)
+ # end
+ # end
+ # end
- def self.skip=(v) # :nodoc:
- @skip = v
- end
+ module Deprecate
+ def self.skip # :nodoc:
+ @skip ||= false
+ end
- ##
- # Temporarily turn off warnings. Intended for tests only.
+ def self.skip=(v) # :nodoc:
+ @skip = v
+ end
- def skip_during
- original = Gem::Deprecate.skip
- Gem::Deprecate.skip = true
- yield
- ensure
- Gem::Deprecate.skip = original
- end
+ ##
+ # Temporarily turn off warnings. Intended for tests only.
- def self.next_rubygems_major_version # :nodoc:
- Gem::Version.new(Gem.rubygems_version.segments.first).bump
- end
+ def skip_during
+ original = Gem::Deprecate.skip
+ Gem::Deprecate.skip = true
+ yield
+ ensure
+ Gem::Deprecate.skip = original
+ end
- ##
- # Simple deprecation method that deprecates +name+ by wrapping it up
- # in a dummy method. It warns on each call to the dummy method
- # telling the user of +repl+ (unless +repl+ is :none) and the
- # year/month that it is planned to go away.
+ def self.next_rubygems_major_version # :nodoc:
+ Gem::Version.new(Gem.rubygems_version.segments.first).bump
+ end
+
+ ##
+ # Simple deprecation method that deprecates +name+ by wrapping it up
+ # in a dummy method. It warns on each call to the dummy method
+ # telling the user of +repl+ (unless +repl+ is :none) and the
+ # year/month that it is planned to go away.
- def deprecate(name, repl, year, month)
- class_eval do
- old = "_deprecated_#{name}"
- alias_method old, name
- define_method name do |*args, &block|
- klass = self.is_a? Module
- target = klass ? "#{self}." : "#{self.class}#"
- msg = [ "NOTE: #{target}#{name} is deprecated",
- repl == :none ? " with no replacement" : "; use #{repl} instead",
- ". It will be removed on or after %4d-%02d." % [year, month],
- "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
- ]
- warn "#{msg.join}." unless Gem::Deprecate.skip
- send old, *args, &block
+ def deprecate(name, repl, year, month)
+ class_eval do
+ old = "_deprecated_#{name}"
+ alias_method old, name
+ define_method name do |*args, &block|
+ klass = is_a? Module
+ target = klass ? "#{self}." : "#{self.class}#"
+ msg = [
+ "NOTE: #{target}#{name} is deprecated",
+ repl == :none ? " with no replacement" : "; use #{repl} instead",
+ format(". It will be removed on or after %4d-%02d.", year, month),
+ "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
+ ]
+ warn "#{msg.join}." unless Gem::Deprecate.skip
+ send old, *args, &block
+ end
+ ruby2_keywords name if respond_to?(:ruby2_keywords, true)
end
- ruby2_keywords name if respond_to?(:ruby2_keywords, true)
end
- end
- ##
- # Simple deprecation method that deprecates +name+ by wrapping it up
- # in a dummy method. It warns on each call to the dummy method
- # telling the user of +repl+ (unless +repl+ is :none) and the
- # Rubygems version that it is planned to go away.
+ ##
+ # Simple deprecation method that deprecates +name+ by wrapping it up
+ # in a dummy method. It warns on each call to the dummy method
+ # telling the user of +repl+ (unless +repl+ is :none) and the
+ # Rubygems version that it is planned to go away.
- def rubygems_deprecate(name, replacement=:none)
- class_eval do
- old = "_deprecated_#{name}"
- alias_method old, name
- define_method name do |*args, &block|
- klass = self.is_a? Module
- target = klass ? "#{self}." : "#{self.class}#"
- msg = [ "NOTE: #{target}#{name} is deprecated",
- replacement == :none ? " with no replacement" : "; use #{replacement} instead",
- ". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}",
- "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
- ]
- warn "#{msg.join}." unless Gem::Deprecate.skip
- send old, *args, &block
+ def rubygems_deprecate(name, replacement = :none, version = nil)
+ class_eval do
+ old = "_deprecated_#{name}"
+ alias_method old, name
+ define_method name do |*args, &block|
+ klass = is_a? Module
+ target = klass ? "#{self}." : "#{self.class}#"
+ version ||= Gem::Deprecate.next_rubygems_major_version
+ msg = [
+ "NOTE: #{target}#{name} is deprecated",
+ replacement == :none ? " with no replacement" : "; use #{replacement} instead",
+ ". It will be removed in Rubygems #{version}",
+ "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
+ ]
+ warn "#{msg.join}." unless Gem::Deprecate.skip
+ send old, *args, &block
+ end
+ ruby2_keywords name if respond_to?(:ruby2_keywords, true)
end
- ruby2_keywords name if respond_to?(:ruby2_keywords, true)
end
- end
- # Deprecation method to deprecate Rubygems commands
- def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
- class_eval do
- define_method "deprecated?" do
- true
- end
+ # Deprecation method to deprecate Rubygems commands
+ def rubygems_deprecate_command(version = nil)
+ class_eval do
+ define_method "deprecated?" do
+ true
+ end
- define_method "deprecation_warning" do
- msg = [ "#{self.command} command is deprecated",
- ". It will be removed in Rubygems #{version}.\n",
- ]
+ define_method "deprecation_warning" do
+ version ||= Gem::Deprecate.next_rubygems_major_version
+ msg = [
+ "#{command} command is deprecated",
+ ". It will be removed in Rubygems #{version}.\n",
+ ]
- alert_warning msg.join.to_s unless Gem::Deprecate.skip
+ alert_warning msg.join.to_s unless Gem::Deprecate.skip
+ end
end
end
- end
- module_function :rubygems_deprecate, :rubygems_deprecate_command, :skip_during
+ module_function :rubygems_deprecate, :rubygems_deprecate_command, :skip_during
+ end
end
diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb
index d21e06b92b..4f26260d83 100644
--- a/lib/rubygems/doctor.rb
+++ b/lib/rubygems/doctor.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../rubygems"
require_relative "user_interaction"
@@ -52,7 +53,7 @@ class Gem::Doctor
# Specs installed in this gem repository
def installed_specs # :nodoc:
- @installed_specs ||= Gem::Specification.map {|s| s.full_name }
+ @installed_specs ||= Gem::Specification.map(&:full_name)
end
##
@@ -74,7 +75,7 @@ class Gem::Doctor
Gem.use_paths @gem_repository.to_s
unless gem_repository?
- say "This directory does not appear to be a RubyGems repository, " +
+ say "This directory does not appear to be a RubyGems repository, " \
"skipping"
say
return
@@ -103,16 +104,16 @@ class Gem::Doctor
directory = File.join(@gem_repository, sub_directory)
Dir.entries(directory).sort.each do |ent|
- next if ent == "." || ent == ".."
+ next if [".", ".."].include?(ent)
child = File.join(directory, ent)
next unless File.exist?(child)
basename = File.basename(child, extension)
next if installed_specs.include? basename
- next if /^rubygems-\d/ =~ basename
- next if "specifications" == sub_directory && "default" == basename
- next if "plugins" == sub_directory && Gem.plugin_suffix_regexp =~ (basename)
+ next if /^rubygems-\d/.match?(basename)
+ next if sub_directory == "specifications" && basename == "default"
+ next if sub_directory == "plugins" && Gem.plugin_suffix_regexp =~ basename
type = File.directory?(child) ? "directory" : "file"
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index 19313d9ce4..4bbc5217e0 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# This file contains all the various exceptions and other errors that are used
# inside of RubyGems.
@@ -25,10 +26,11 @@ module Gem
# system. Instead of rescuing from this class, make sure to rescue from the
# superclass Gem::LoadError to catch all types of load errors.
class MissingSpecError < Gem::LoadError
- def initialize(name, requirement, extra_message=nil)
+ def initialize(name, requirement, extra_message = nil)
@name = name
@requirement = requirement
@extra_message = extra_message
+ super(message)
end
def message # :nodoc:
@@ -52,8 +54,8 @@ module Gem
attr_reader :specs
def initialize(name, requirement, specs)
- super(name, requirement)
@specs = specs
+ super(name, requirement)
end
private
@@ -133,11 +135,7 @@ module Gem
##
# A wordy description of the error.
def wordy
- "Found %s (%s), but was for platform%s %s" %
- [@name,
- @version,
- @platforms.size == 1 ? "" : "s",
- @platforms.join(" ,")]
+ format("Found %s (%s), but was for platform%s %s", @name, @version, @platforms.size == 1 ? "" : "s", @platforms.join(" ,"))
end
end
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 9525b84f17..e00a70c662 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require_relative "deprecate"
require_relative "unknown_command_spell_checker"
##
@@ -21,20 +20,11 @@ class Gem::UnknownCommandError < Gem::Exception
end
def self.attach_correctable
- return if defined?(@attached)
+ return if method_defined?(:corrections)
- if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
- if DidYouMean.respond_to?(:correct_error)
- DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
- else
- DidYouMean::SPELL_CHECKERS["Gem::UnknownCommandError"] =
- Gem::UnknownCommandSpellChecker
-
- prepend DidYouMean::Correctable
- end
+ if defined?(DidYouMean) && DidYouMean.respond_to?(:correct_error)
+ DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
end
-
- @attached = true
end
end
@@ -43,22 +33,24 @@ class Gem::DependencyError < Gem::Exception; end
class Gem::DependencyRemovalException < Gem::Exception; end
##
-# Raised by Gem::Resolver when a Gem::Dependency::Conflict reaches the
-# toplevel. Indicates which dependencies were incompatible through #conflict
-# and #conflicting_dependencies
+# Raised by Gem::Resolver when dependency resolution fails.
class Gem::DependencyResolutionError < Gem::DependencyError
- attr_reader :conflict
-
def initialize(conflict)
- @conflict = conflict
- a, b = conflicting_dependencies
+ @explanation = conflict.explanation
+ super @explanation
+ end
+
+ def explanation
+ @explanation
+ end
- super "conflicting dependencies #{a} and #{b}\n#{@conflict.explanation}"
+ def conflict
+ nil
end
def conflicting_dependencies
- @conflict.conflicting_dependencies
+ []
end
end
@@ -104,16 +96,13 @@ end
class Gem::GemNotFoundException < Gem::Exception; end
-##
-# Raised by the DependencyInstaller when a specific gem cannot be found
-
class Gem::SpecificGemNotFoundException < Gem::GemNotFoundException
##
# Creates a new SpecificGemNotFoundException for a gem with the given +name+
# and +version+. Any +errors+ encountered when attempting to find the gem
# are also stored.
- def initialize(name, version, errors=nil)
+ def initialize(name, version, errors = nil)
super "Could not find a valid gem '#{name}' (#{version}) locally or in a repository"
@name = name
@@ -137,39 +126,7 @@ class Gem::SpecificGemNotFoundException < Gem::GemNotFoundException
attr_reader :errors
end
-##
-# Raised by Gem::Resolver when dependencies conflict and create the
-# inability to find a valid possible spec for a request.
-
-class Gem::ImpossibleDependenciesError < Gem::Exception
- attr_reader :conflicts
- attr_reader :request
-
- def initialize(request, conflicts)
- @request = request
- @conflicts = conflicts
-
- super build_message
- end
-
- def build_message # :nodoc:
- requester = @request.requester
- requester = requester ? requester.spec.full_name : "The user"
- dependency = @request.dependency
-
- message = "#{requester} requires #{dependency} but it conflicted:\n".dup
-
- @conflicts.each do |_, conflict|
- message << conflict.explanation
- end
-
- message
- end
-
- def dependency
- @request.dependency
- end
-end
+Gem.deprecate_constant :SpecificGemNotFoundException
class Gem::InstallError < Gem::Exception; end
@@ -215,6 +172,16 @@ class Gem::RubyVersionMismatch < Gem::Exception; end
class Gem::VerificationError < Gem::Exception; end
##
+# Raised by Gem::WebauthnListener when an error occurs during security
+# device verification.
+
+class Gem::WebauthnVerificationError < Gem::Exception
+ def initialize(message)
+ super "Security device verification failed: #{message}"
+ end
+end
+
+##
# Raised to indicate that a system exit should occur with the specified
# exit_code
@@ -252,7 +219,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
# Creates a new UnsatisfiableDependencyError for the unsatisfiable
# Gem::Resolver::DependencyRequest +dep+
- def initialize(dep, platform_mismatch=nil)
+ def initialize(dep, platform_mismatch = nil)
if platform_mismatch && !platform_mismatch.empty?
plats = platform_mismatch.map {|x| x.platform.to_s }.sort.uniq
super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(", ")}"
@@ -282,9 +249,3 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
@dependency.requirement
end
end
-
-##
-# Backwards compatible typo'd exception class for early RubyGems 2.0.x
-
-Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
-Gem.deprecate_constant :UnsatisfiableDepedencyError
diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb
index d714985c21..b5ca126a08 100644
--- a/lib/rubygems/ext.rb
+++ b/lib/rubygems/ext.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/build_error.rb b/lib/rubygems/ext/build_error.rb
index 727bc065c2..0329c1eec3 100644
--- a/lib/rubygems/ext/build_error.rb
+++ b/lib/rubygems/ext/build_error.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Raised when there is an error while building extensions.
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index 9ddcf988e5..e00cf159da 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -10,6 +11,9 @@ require_relative "../user_interaction"
class Gem::Ext::Builder
include Gem::UserInteraction
+ class NoMakefileError < Gem::InstallError
+ end
+
attr_accessor :build_args # :nodoc:
def self.class_name
@@ -17,27 +21,37 @@ class Gem::Ext::Builder
$1.downcase
end
- def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"])
+ def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"],
+ target_rbconfig: Gem.target_rbconfig, n_jobs: nil)
unless File.exist? File.join(make_dir, "Makefile")
- raise Gem::InstallError, "Makefile not found"
+ # No makefile exists, nothing to do.
+ raise NoMakefileError, "No Makefile found in #{make_dir}"
end
# try to find make program from Ruby configure arguments first
- RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/
+ target_rbconfig["configure_args"] =~ /with-make-prog\=(\w+)/
make_program_name = ENV["MAKE"] || ENV["make"] || $1
- unless make_program_name
- make_program_name = (RUBY_PLATFORM.include?("mswin")) ? "nmake" : "make"
- end
- make_program = Shellwords.split(make_program_name)
+ make_program_name ||= RUBY_PLATFORM.include?("mswin") ? "nmake" : "make"
+ make_program = shellsplit(make_program_name)
+ is_nmake = /\bnmake/i.match?(make_program_name)
# The installation of the bundled gems is failed when DESTDIR is empty in mswin platform.
- destdir = (/\bnmake/i !~ make_program_name || ENV["DESTDIR"] && ENV["DESTDIR"] != "") ? "DESTDIR=%s" % ENV["DESTDIR"] : ""
+ destdir = !is_nmake || ENV["DESTDIR"] && ENV["DESTDIR"] != "" ? format("DESTDIR=%s", ENV["DESTDIR"]) : ""
+
+ # nmake doesn't support parallel build
+ unless is_nmake
+ have_make_arguments = make_program.size > 1
+
+ if !have_make_arguments && !ENV["MAKEFLAGS"] && n_jobs
+ make_program << "-j#{n_jobs}"
+ end
+ end
env = [destdir]
if sitedir
- env << "sitearchdir=%s" % sitedir
- env << "sitelibdir=%s" % sitedir
+ env << format("sitearchdir=%s", sitedir)
+ env << format("sitelibdir=%s", sitedir)
end
targets.each do |target|
@@ -55,6 +69,22 @@ class Gem::Ext::Builder
end
end
+ def self.ruby
+ # Gem.ruby is quoted if it contains whitespace
+ cmd = shellsplit(Gem.ruby)
+
+ # This load_path is only needed when running rubygems test without a proper installation.
+ # Prepending it in a normal installation will cause problem with order of $LOAD_PATH.
+ # Therefore only add load_path if it is not present in the default $LOAD_PATH.
+ load_path = File.expand_path("../..", __dir__)
+ case load_path
+ when RbConfig::CONFIG["sitelibdir"], RbConfig::CONFIG["vendorlibdir"], RbConfig::CONFIG["rubylibdir"]
+ cmd
+ else
+ cmd << "-I#{load_path}"
+ end
+ end
+
def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
verbose = Gem.configuration.really_verbose
@@ -66,20 +96,27 @@ class Gem::Ext::Builder
p(command)
end
results << "current directory: #{dir}"
- require "shellwords"
- results << command.shelljoin
+ results << shelljoin(command)
require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env)
output, status = begin
- Open3.capture2e(build_env, *command, :chdir => dir)
- rescue => error
+ Open3.popen2e(build_env, *command, chdir: dir) do |stdin, stdouterr, wait_thread|
+ stdin.close
+ output = String.new
+ while line = stdouterr.gets
+ output << line
+ if verbose
+ print line
+ end
+ end
+ [output, wait_thread.value]
+ end
+ rescue StandardError => error
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
end
- if verbose
- puts output
- else
+ unless verbose
results << output
end
ensure
@@ -104,17 +141,29 @@ class Gem::Ext::Builder
end
end
+ def self.shellsplit(command)
+ require "shellwords"
+
+ Shellwords.split(command)
+ end
+
+ def self.shelljoin(command)
+ require "shellwords"
+
+ Shellwords.join(command)
+ end
+
##
# Creates a new extension builder for +spec+. If the +spec+ does not yet
# have build arguments, saved, set +build_args+ which is an ARGV-style
# array.
- def initialize(spec, build_args = spec.build_args)
+ def initialize(spec, build_args = spec.build_args, target_rbconfig = Gem.target_rbconfig, build_jobs = nil)
@spec = spec
@build_args = build_args
@gem_dir = spec.full_gem_path
-
- @ran_rake = false
+ @target_rbconfig = target_rbconfig
+ @build_jobs = build_jobs
end
##
@@ -127,10 +176,9 @@ class Gem::Ext::Builder
when /configure/ then
Gem::Ext::ConfigureBuilder
when /rakefile/i, /mkrf_conf/i then
- @ran_rake = true
Gem::Ext::RakeBuilder
when /CMakeLists.txt/ then
- Gem::Ext::CmakeBuilder
+ Gem::Ext::CmakeBuilder.new
when /Cargo.toml/ then
Gem::Ext::CargoBuilder.new
else
@@ -169,12 +217,12 @@ EOF
FileUtils.mkdir_p dest_path
results = builder.build(extension, dest_path,
- results, @build_args, lib_dir, extension_dir)
+ results, @build_args, lib_dir, extension_dir, @target_rbconfig, n_jobs: @build_jobs)
verbose { results.join("\n") }
write_gem_make_out results.join "\n"
- rescue => e
+ rescue StandardError => e
results << e.message
build_error(results.join("\n"), $@)
end
@@ -200,8 +248,6 @@ EOF
FileUtils.rm_f @spec.gem_build_complete_path
@spec.extensions.each do |extension|
- break if @ran_rake
-
build_extension extension, dest_path
end
diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb
index 022aabf481..516459dd60 100644
--- a/lib/rubygems/ext/cargo_builder.rb
+++ b/lib/rubygems/ext/cargo_builder.rb
@@ -14,10 +14,15 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
@profile = :release
end
- def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
+ def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd,
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
require "tempfile"
require "fileutils"
+ if target_rbconfig.path
+ warn "--target-rbconfig is not yet supported for Rust extensions. Ignoring"
+ end
+
# Where's the Cargo.toml of the crate we're building
cargo_toml = File.join(cargo_dir, "Cargo.toml")
# What's the crate's name
@@ -45,7 +50,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
nesting = extension_nesting(extension)
- # TODO: remove in RubyGems 4
if Gem.install_extension_in_lib && lib_dir
nested_lib_dir = File.join(lib_dir, nesting)
FileUtils.mkdir_p nested_lib_dir
@@ -73,8 +77,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
end
def cargo_command(cargo_toml, dest_path, args = [], crate_name = nil)
- require "shellwords"
-
cmd = []
cmd += [cargo, "rustc"]
cmd += ["--crate-type", "cdylib"]
@@ -155,7 +157,11 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
# We want to use the same linker that Ruby uses, so that the linker flags from
# mkmf work properly.
def linker_args
- cc_flag = Shellwords.split(makefile_config("CC"))
+ cc_flag = self.class.shellsplit(makefile_config("CC"))
+ # Avoid to ccache like tool from Rust build
+ # see https://github.com/ruby/rubygems/pull/8521#issuecomment-2689854359
+ # ex. CC="ccache gcc" or CC="sccache clang --any --args"
+ cc_flag.shift if cc_flag.size >= 2 && !cc_flag[1].start_with?("-")
linker = cc_flag.shift
link_args = cc_flag.flat_map {|a| ["-C", "link-arg=#{a}"] }
@@ -174,7 +180,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
def libruby_args(dest_dir)
libs = makefile_config(ruby_static? ? "LIBRUBYARG_STATIC" : "LIBRUBYARG_SHARED")
- raw_libs = Shellwords.split(libs)
+ raw_libs = self.class.shellsplit(libs)
raw_libs.flat_map {|l| ldflag_to_link_modifier(l) }
end
@@ -185,6 +191,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
end
def cargo_dylib_path(dest_path, crate_name)
+ so_ext = RbConfig::CONFIG["SOEXT"]
prefix = so_ext == "dll" ? "" : "lib"
path_parts = [dest_path]
path_parts << ENV["CARGO_BUILD_TARGET"] if ENV["CARGO_BUILD_TARGET"]
@@ -198,8 +205,8 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
output, status =
begin
- Open3.capture2e(cargo, "metadata", "--no-deps", "--format-version", "1", :chdir => cargo_dir)
- rescue => error
+ Open3.capture2e(cargo, "metadata", "--no-deps", "--format-version", "1", chdir: cargo_dir)
+ rescue StandardError => error
raise Gem::InstallError, "cargo metadata failed #{error.message}"
end
@@ -220,10 +227,9 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
raise Gem::InstallError, "cargo metadata failed#{exit_reason}"
end
- # cargo metadata output is specified as json, but with the
- # --format-version 1 option the output is compatible with YAML, so we can
- # avoid the json dependency
- metadata = Gem::SafeYAML.safe_load(output)
+ # cargo metadata output is specified as json
+ require "json"
+ metadata = JSON.parse(output)
package = metadata["packages"].find {|pkg| normalize_path(pkg["manifest_path"]) == manifest_path }
unless package
found = metadata["packages"].map {|md| "#{md["name"]} at #{md["manifest_path"]}" }
@@ -246,10 +252,9 @@ EOF
end
def rustc_dynamic_linker_flags(dest_dir, crate_name)
- split_flags("DLDFLAGS")
- .map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }
- .compact
- .flat_map {|arg| ldflag_to_link_modifier(arg) }
+ split_flags("DLDFLAGS").
+ filter_map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }.
+ flat_map {|arg| ldflag_to_link_modifier(arg) }
end
def rustc_lib_flags(dest_dir)
@@ -257,7 +262,7 @@ EOF
end
def split_flags(var)
- Shellwords.split(RbConfig::CONFIG.fetch(var, ""))
+ self.class.shellsplit(RbConfig::CONFIG.fetch(var, ""))
end
def ldflag_to_link_modifier(arg)
@@ -293,7 +298,7 @@ EOF
case var_name
# On windows, it is assumed that mkmf has setup an exports file for the
- # extension, so we have to to create one ourselves.
+ # extension, so we have to create one ourselves.
when "DEFFILE"
write_deffile(dest_dir, crate_name)
else
@@ -313,22 +318,6 @@ EOF
deffile_path
end
- # We have to basically reimplement RbConfig::CONFIG['SOEXT'] here to support
- # Ruby < 2.5
- #
- # @see https://github.com/ruby/ruby/blob/c87c027f18c005460746a74c07cd80ee355b16e4/configure.ac#L3185
- def so_ext
- return RbConfig::CONFIG["SOEXT"] if RbConfig::CONFIG.key?("SOEXT")
-
- if win_target?
- "dll"
- elsif darwin_target?
- "dylib"
- else
- "so"
- end
- end
-
# Corresponds to $(LIBPATH) in mkmf
def mkmf_libpath
["-L", "native=#{makefile_config("libdir")}"]
diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb
index b162664784..e660ed558b 100644
--- a/lib/rubygems/ext/cmake_builder.rb
+++ b/lib/rubygems/ext/cmake_builder.rb
@@ -1,16 +1,110 @@
# frozen_string_literal: true
+# This builder creates extensions defined using CMake. Its is invoked if a Gem's spec file
+# sets the `extension` property to a string that contains `CMakeLists.txt`.
+#
+# In general, CMake projects are built in two steps:
+#
+# * configure
+# * build
+#
+# The builder follow this convention. First it runs a configuration step and then it runs a build step.
+#
+# CMake projects can be quite configurable - it is likely you will want to specify options when
+# installing a gem. To pass options to CMake specify them after `--` in the gem install command. For example:
+#
+# gem install <gem_name> -- --preset <preset_name>
+#
+# Note that options are ONLY sent to the configure step - it is not currently possible to specify
+# options for the build step. If this becomes and issue then the CMake builder can be updated to
+# support build options.
+#
+# Useful options to know are:
+#
+# -G to specify a generator (-G Ninja is recommended)
+# -D<CMAKE_VARIABLE> to set a CMake variable (for example -DCMAKE_BUILD_TYPE=Release)
+# --preset <preset_name> to use a preset
+#
+# If the Gem author provides presets, via CMakePresets.json file, you will likely want to use one of them.
+# If not, you may wish to specify a generator. Ninja is recommended because it can build projects in parallel
+# and thus much faster than building them serially like Make does.
+
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd)
- unless File.exist?(File.join(cmake_dir, "Makefile"))
- require_relative "../command"
- cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}", *Gem::Command.build_args]
+ attr_accessor :runner, :profile
+ def initialize
+ @runner = self.class.method(:run)
+ @profile = :release
+ end
- run cmd, results, class_name, cmake_dir
+ def build(extension, dest_path, results, args = [], lib_dir = nil, cmake_dir = Dir.pwd,
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
+ if target_rbconfig.path
+ warn "--target-rbconfig is not yet supported for CMake extensions. Ignoring"
end
- make dest_path, results, cmake_dir
+ # Figure the build dir
+ build_dir = File.join(cmake_dir, "build")
+
+ # Check if the gem defined presets
+ check_presets(cmake_dir, args, results)
+
+ # Configure
+ configure(cmake_dir, build_dir, dest_path, args, results)
+
+ # Compile
+ compile(cmake_dir, build_dir, args, results)
results
end
+
+ def configure(cmake_dir, build_dir, install_dir, args, results)
+ cmd = ["cmake",
+ cmake_dir,
+ "-B",
+ build_dir,
+ "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=#{install_dir}", # Windows
+ "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=#{install_dir}", # Not Windows
+ *Gem::Command.build_args,
+ *args]
+
+ runner.call(cmd, results, "cmake_configure", cmake_dir)
+ end
+
+ def compile(cmake_dir, build_dir, args, results)
+ cmd = ["cmake",
+ "--build",
+ build_dir.to_s,
+ "--config",
+ @profile.to_s]
+
+ runner.call(cmd, results, "cmake_compile", cmake_dir)
+ end
+
+ private
+
+ def check_presets(cmake_dir, args, results)
+ # Return if the user specified a preset
+ return unless args.grep(/--preset/i).empty?
+
+ cmd = ["cmake",
+ "--list-presets"]
+
+ presets = Array.new
+ begin
+ runner.call(cmd, presets, "cmake_presets", cmake_dir)
+
+ # Remove the first two lines of the array which is the current_directory and the command
+ # that was run
+ presets = presets[2..].join
+ results << <<~EOS
+ The gem author provided a list of presets that can be used to build the gem. To use a preset specify it on the command line:
+
+ gem install <gem_name> -- --preset <preset_name>
+
+ #{presets}
+ EOS
+ rescue Gem::InstallError
+ # Do nothing, CMakePresets.json was not included in the Gem
+ end
+ end
end
diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb
index 51106c6370..230b214b3c 100644
--- a/lib/rubygems/ext/configure_builder.rb
+++ b/lib/rubygems/ext/configure_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -6,14 +7,19 @@
#++
class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, configure_dir=Dir.pwd)
+ def self.build(extension, dest_path, results, args = [], lib_dir = nil, configure_dir = Dir.pwd,
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
+ if target_rbconfig.path
+ warn "--target-rbconfig is not yet supported for configure-based extensions. Ignoring"
+ end
+
unless File.exist?(File.join(configure_dir, "Makefile"))
cmd = ["sh", "./configure", "--prefix=#{dest_path}", *args]
run cmd, results, class_name, configure_dir
end
- make dest_path, results, configure_dir
+ make dest_path, results, configure_dir, target_rbconfig: target_rbconfig, n_jobs: n_jobs
results
end
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index 9254197009..822454355d 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -6,7 +7,8 @@
#++
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd)
+ def self.build(extension, dest_path, results, args = [], lib_dir = nil, extension_dir = Dir.pwd,
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
require "fileutils"
require "tempfile"
@@ -21,8 +23,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destdir = ENV["DESTDIR"]
begin
- require "shellwords"
- cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../..", __dir__) << File.basename(extension)
+ cmd = ruby << File.basename(extension)
+ cmd << "--target-rbconfig=#{target_rbconfig.path}" if target_rbconfig.path
cmd.push(*args)
run(cmd, results, class_name, extension_dir) do |s, r|
@@ -39,16 +41,18 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
ENV["DESTDIR"] = nil
- make dest_path, results, extension_dir, tmp_dest_relative
+ make dest_path, results, extension_dir, tmp_dest_relative, target_rbconfig: target_rbconfig, n_jobs: n_jobs
full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
- # TODO remove in RubyGems 4
- if Gem.install_extension_in_lib && lib_dir
+ is_cross_compiling = target_rbconfig["platform"] != RbConfig::CONFIG["platform"]
+ # Do not copy extension libraries by default when cross-compiling
+ # not to conflict with the one already built for the host platform.
+ if Gem.install_extension_in_lib && lib_dir && !is_cross_compiling
FileUtils.mkdir_p lib_dir
entries = Dir.entries(full_tmp_dest) - %w[. ..]
entries = entries.map {|entry| File.join full_tmp_dest, entry }
- FileUtils.cp_r entries, lib_dir, :remove_destination => true
+ FileUtils.cp_r entries, lib_dir, remove_destination: true
end
FileUtils::Entry_.new(full_tmp_dest).traverse do |ent|
@@ -56,12 +60,16 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destent.exist? || FileUtils.mv(ent.path, destent.path)
end
- make dest_path, results, extension_dir, tmp_dest_relative, ["clean"]
+ make dest_path, results, extension_dir, tmp_dest_relative, ["clean"], target_rbconfig: target_rbconfig
ensure
ENV["DESTDIR"] = destdir
end
results
+ rescue Gem::Ext::Builder::NoMakefileError => error
+ results << error.message
+ results << "Skipping make for #{extension} as no Makefile was found."
+ # We are good, do not re-raise the error.
ensure
FileUtils.rm_rf tmp_dest if tmp_dest
end
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 9f2e099d40..d702d7f339 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -6,19 +7,23 @@
#++
class Gem::Ext::RakeBuilder < Gem::Ext::Builder
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd)
- if File.basename(extension) =~ /mkrf_conf/i
+ def self.build(extension, dest_path, results, args = [], lib_dir = nil, extension_dir = Dir.pwd,
+ target_rbconfig = Gem.target_rbconfig, n_jobs: nil)
+ if target_rbconfig.path
+ warn "--target-rbconfig is not yet supported for Rake extensions. Ignoring"
+ end
+
+ if /mkrf_conf/i.match?(File.basename(extension))
run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir)
end
rake = ENV["rake"]
if rake
- require "shellwords"
- rake = rake.shellsplit
+ rake = shellsplit(rake)
else
begin
- rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path("rake", "rake")]
+ rake = ruby << "-rrubygems" << Gem.bin_path("rake", "rake")
rescue Gem::Exception
rake = [Gem.default_exec_format % "rake"]
end
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index c63c177ed2..e60cebd0cb 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -7,7 +8,6 @@
require_relative "../rubygems"
require_relative "command_manager"
-require_relative "deprecate"
##
# Run an instance of the gem program.
@@ -28,11 +28,16 @@ class Gem::GemRunner
# Run the gem command with the following arguments.
def run(args)
+ validate_encoding args
build_args = extract_build_args args
do_configuration args
- Gem.load_env_plugins rescue nil
+ begin
+ Gem.load_env_plugins
+ rescue StandardError
+ nil
+ end
Gem.load_plugins
cmd = @command_manager_class.instance
@@ -67,6 +72,14 @@ class Gem::GemRunner
private
+ def validate_encoding(args)
+ invalid_arg = args.find {|arg| !arg.valid_encoding? }
+
+ if invalid_arg
+ raise Gem::OptionParser::InvalidArgument.new("'#{invalid_arg.scrub}' has invalid encoding")
+ end
+ end
+
def do_configuration(args)
Gem.configuration = @config_file_class.new(args)
Gem.use_paths Gem.configuration[:gemhome], Gem.configuration[:gempath]
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 3d72e28dbe..9c22c14fad 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -1,13 +1,17 @@
# frozen_string_literal: true
+
require_relative "remote_fetcher"
require_relative "text"
+require_relative "gemcutter_utilities/webauthn_listener"
+require_relative "gemcutter_utilities/webauthn_poller"
##
# Utility methods for using the RubyGems API.
module Gem::GemcutterUtilities
ERROR_CODE = 1
- API_SCOPES = %i[index_rubygems push_rubygem yank_rubygem add_owner remove_owner access_webhooks show_dashboard].freeze
+ API_SCOPES = [:index_rubygems, :push_rubygem, :yank_rubygem, :add_owner, :remove_owner, :access_webhooks].freeze
+ EXCLUSIVELY_API_SCOPES = [:show_dashboard].freeze
include Gem::Text
@@ -58,6 +62,10 @@ module Gem::GemcutterUtilities
options[:otp] || ENV["GEM_HOST_OTP_CODE"]
end
+ def webauthn_enabled?
+ options[:webauthn]
+ end
+
##
# The host to connect to either from the RUBYGEMS_HOST environment variable
# or from the user's configuration
@@ -80,8 +88,8 @@ module Gem::GemcutterUtilities
#
# If +allowed_push_host+ metadata is present, then it will only allow that host.
- def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scope: nil, &block)
- require "net/http"
+ def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scope: nil, credentials: {}, &block)
+ require_relative "vendored_net_http"
self.host = host if host
unless self.host
@@ -90,8 +98,8 @@ module Gem::GemcutterUtilities
end
if allowed_push_host
- allowed_host_uri = URI.parse(allowed_push_host)
- host_uri = URI.parse(self.host)
+ allowed_host_uri = Gem::URI.parse(allowed_push_host)
+ host_uri = Gem::URI.parse(self.host)
unless (host_uri.scheme == allowed_host_uri.scheme) && (host_uri.host == allowed_host_uri.host)
alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
@@ -99,11 +107,11 @@ module Gem::GemcutterUtilities
end
end
- uri = URI.parse "#{self.host}/#{path}"
+ uri = Gem::URI.parse "#{self.host}/#{path}"
response = request_with_otp(method, uri, &block)
if mfa_unauthorized?(response)
- ask_otp
+ fetch_otp(credentials)
response = request_with_otp(method, uri, &block)
end
@@ -116,24 +124,23 @@ module Gem::GemcutterUtilities
end
def mfa_unauthorized?(response)
- response.is_a?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication")
+ response.is_a?(Gem::Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication")
end
def update_scope(scope)
- sign_in_host = self.host
+ sign_in_host = host
pretty_host = pretty_host(sign_in_host)
update_scope_params = { scope => true }
say "The existing key doesn't have access of #{scope} on #{pretty_host}. Please sign in to update access."
- email = ask " Email: "
- password = ask_for_password "Password: "
+ identifier = ask "Username/email: "
+ password = ask_for_password " Password: "
response = rubygems_api_request(:put, "api/v1/api_key",
sign_in_host, scope: scope) do |request|
- request.basic_auth email, password
- request["OTP"] = otp if otp
- request.body = URI.encode_www_form({ :api_key => api_key }.merge(update_scope_params))
+ request.basic_auth identifier, password
+ request.body = Gem::URI.encode_www_form({ api_key: api_key }.merge(update_scope_params))
end
with_response response do |_resp|
@@ -146,33 +153,34 @@ module Gem::GemcutterUtilities
# key.
def sign_in(sign_in_host = nil, scope: nil)
- sign_in_host ||= self.host
- return if api_key
-
+ sign_in_host ||= host
pretty_host = pretty_host(sign_in_host)
-
+ if api_key
+ say "You are already signed in on #{pretty_host}."
+ return
+ end
say "Enter your #{pretty_host} credentials."
- say "Don't have an account yet? " +
+ say "Don't have an account yet? " \
"Create one at #{sign_in_host}/sign_up"
- email = ask " Email: "
- password = ask_for_password "Password: "
+ identifier = ask "Username/email: "
+ password = ask_for_password " Password: "
say "\n"
key_name = get_key_name(scope)
scope_params = get_scope_params(scope)
- profile = get_user_profile(email, password)
+ profile = get_user_profile(identifier, password)
mfa_params = get_mfa_params(profile)
all_params = scope_params.merge(mfa_params)
warning = profile["warning"]
+ credentials = { identifier: identifier, password: password }
say "#{warning}\n" if warning
response = rubygems_api_request(:post, "api/v1/api_key",
- sign_in_host, scope: scope) do |request|
- request.basic_auth email, password
- request["OTP"] = otp if otp
- request.body = URI.encode_www_form({ name: key_name }.merge(all_params))
+ sign_in_host, credentials: credentials, scope: scope) do |request|
+ request.basic_auth identifier, password
+ request.body = Gem::URI.encode_www_form({ name: key_name }.merge(all_params))
end
with_response response do |resp|
@@ -204,13 +212,13 @@ module Gem::GemcutterUtilities
def with_response(response, error_prefix = nil)
case response
- when Net::HTTPSuccess then
+ when Gem::Net::HTTPSuccess then
if block_given?
yield response
else
say clean_text(response.body)
end
- when Net::HTTPPermanentRedirect, Net::HTTPRedirection then
+ when Gem::Net::HTTPPermanentRedirect, Gem::Net::HTTPRedirection then
message = "The request has redirected permanently to #{response["location"]}. Please check your defined push host URL."
message = "#{error_prefix}: #{message}" if error_prefix
@@ -240,17 +248,67 @@ module Gem::GemcutterUtilities
private
def request_with_otp(method, uri, &block)
- request_method = Net::HTTP.const_get method.to_s.capitalize
+ request_method = Gem::Net::HTTP.const_get method.to_s.capitalize
Gem::RemoteFetcher.fetcher.request(uri, request_method) do |req|
req["OTP"] = otp if otp
block.call(req)
end
+ ensure
+ options[:otp] = nil if webauthn_enabled?
+ end
+
+ def fetch_otp(credentials)
+ options[:otp] = if webauthn_url = webauthn_verification_url(credentials)
+ server = TCPServer.new 0
+ port = server.addr[1].to_s
+
+ url_with_port = "#{webauthn_url}?port=#{port}"
+ say "You have enabled multi-factor authentication. Please visit the following URL to authenticate via security device. If you can't verify using WebAuthn but have OTP enabled, you can re-run the gem signin command with the `--otp [your_code]` option."
+ say ""
+ say url_with_port
+ say ""
+
+ threads = [WebauthnListener.listener_thread(host, server), WebauthnPoller.poll_thread(options, host, webauthn_url, credentials)]
+ otp_thread = wait_for_otp_thread(*threads)
+
+ threads.each(&:join)
+
+ if error = otp_thread[:error]
+ alert_error error.message
+ terminate_interaction(1)
+ end
+
+ options[:webauthn] = true
+
+ say "You are verified with a security device. You may close the browser window."
+ otp_thread[:otp]
+ else
+ say "You have enabled multi-factor authentication. Please enter OTP code."
+ ask "Code: "
+ end
end
- def ask_otp
- say "You have enabled multi-factor authentication. Please enter OTP code."
- options[:otp] = ask "Code: "
+ def wait_for_otp_thread(*threads)
+ loop do
+ threads.each do |otp_thread|
+ return otp_thread unless otp_thread.alive?
+ end
+ sleep 0.1
+ end
+ ensure
+ threads.each(&:exit)
+ end
+
+ def webauthn_verification_url(credentials)
+ response = rubygems_api_request(:post, "api/v1/webauthn_verification") do |request|
+ if credentials.empty?
+ request.add_field "Authorization", api_key
+ else
+ request.basic_auth credentials[:identifier], credentials[:password]
+ end
+ end
+ response.is_a?(Gem::Net::HTTPSuccess) ? response.body : nil
end
def pretty_host(host)
@@ -262,15 +320,31 @@ module Gem::GemcutterUtilities
end
def get_scope_params(scope)
- scope_params = {}
+ scope_params = { index_rubygems: true, push_rubygem: true }
if scope
scope_params = { scope => true }
else
- say "Please select scopes you want to enable for the API key (y/n)"
- API_SCOPES.each do |scope|
- selected = ask_yes_no(scope.to_s, false)
- scope_params[scope] = true if selected
+ say "The default access scope is:"
+ scope_params.each do |k, _v|
+ say " #{k}: y"
+ end
+ say "\n"
+ customise = ask_yes_no("Do you want to customise scopes?", false)
+ if customise
+ EXCLUSIVELY_API_SCOPES.each do |excl_scope|
+ selected = ask_yes_no("#{excl_scope} (exclusive scope, answering yes will not prompt for other scopes)", false)
+ next unless selected
+
+ return { excl_scope => true }
+ end
+
+ scope_params = {}
+
+ API_SCOPES.each do |s|
+ selected = ask_yes_no(s.to_s, false)
+ scope_params[s] = true if selected
+ end
end
say "\n"
end
@@ -279,25 +353,25 @@ module Gem::GemcutterUtilities
end
def default_host?
- self.host == Gem::DEFAULT_HOST
+ host == Gem::DEFAULT_HOST
end
- def get_user_profile(email, password)
+ def get_user_profile(identifier, password)
return {} unless default_host?
response = rubygems_api_request(:get, "api/v1/profile/me.yaml") do |request|
- request.basic_auth email, password
+ request.basic_auth identifier, password
end
with_response response do |resp|
- Gem::SafeYAML.load clean_text(resp.body)
+ Gem::ConfigFile.load_with_rubygems_config_hash(clean_text(resp.body))
end
end
def get_mfa_params(profile)
mfa_level = profile["mfa"]
params = {}
- if mfa_level == "ui_only" || mfa_level == "ui_and_gem_signin"
+ if ["ui_only", "ui_and_gem_signin"].include?(mfa_level)
selected = ask_yes_no("Would you like to enable MFA for this key? (strongly recommended)")
params["mfa"] = true if selected
end
@@ -319,6 +393,6 @@ module Gem::GemcutterUtilities
end
def api_key_forbidden?(response)
- response.is_a?(Net::HTTPForbidden) && response.body.start_with?("The API key doesn't have access")
+ response.is_a?(Gem::Net::HTTPForbidden) && response.body.start_with?("The API key doesn't have access")
end
end
diff --git a/lib/rubygems/gemcutter_utilities/webauthn_listener.rb b/lib/rubygems/gemcutter_utilities/webauthn_listener.rb
new file mode 100644
index 0000000000..3f56a077c9
--- /dev/null
+++ b/lib/rubygems/gemcutter_utilities/webauthn_listener.rb
@@ -0,0 +1,112 @@
+# frozen_string_literal: true
+
+require_relative "webauthn_listener/response"
+
+##
+# The WebauthnListener class retrieves an OTP after a user successfully WebAuthns with the Gem host.
+# An instance opens a socket using the TCPServer instance given and listens for a request from the Gem host.
+# The request should be a GET request to the root path and contains the OTP code in the form
+# of a query parameter `code`. The listener will return the code which will be used as the OTP for
+# API requests.
+#
+# Types of responses sent by the listener after receiving a request:
+# - 200 OK: OTP code was successfully retrieved
+# - 204 No Content: If the request was an OPTIONS request
+# - 400 Bad Request: If the request did not contain a query parameter `code`
+# - 404 Not Found: The request was not to the root path
+# - 405 Method Not Allowed: OTP code was not retrieved because the request was not a GET/OPTIONS request
+#
+# Example usage:
+#
+# thread = Gem::WebauthnListener.listener_thread("https://rubygems.example", server)
+# thread.join
+# otp = thread[:otp]
+# error = thread[:error]
+#
+
+module Gem::GemcutterUtilities
+ class WebauthnListener
+ attr_reader :host
+
+ def initialize(host)
+ @host = host
+ end
+
+ def self.listener_thread(host, server)
+ Thread.new do
+ thread = Thread.current
+ thread.abort_on_exception = true
+ thread.report_on_exception = false
+ thread[:otp] = new(host).wait_for_otp_code(server)
+ rescue Gem::WebauthnVerificationError => e
+ thread[:error] = e
+ ensure
+ server.close
+ end
+ end
+
+ def wait_for_otp_code(server)
+ loop do
+ socket = server.accept
+ request_line = socket.gets
+
+ method, req_uri, _protocol = request_line.split(" ")
+ req_uri = Gem::URI.parse(req_uri)
+
+ responder = SocketResponder.new(socket)
+
+ unless root_path?(req_uri)
+ responder.send(NotFoundResponse.for(host))
+ raise Gem::WebauthnVerificationError, "Page at #{req_uri.path} not found."
+ end
+
+ case method.upcase
+ when "OPTIONS"
+ responder.send(NoContentResponse.for(host))
+ next # will be GET
+ when "GET"
+ if otp = parse_otp_from_uri(req_uri)
+ responder.send(OkResponse.for(host))
+ return otp
+ end
+ responder.send(BadRequestResponse.for(host))
+ raise Gem::WebauthnVerificationError, "Did not receive OTP from #{host}."
+ else
+ responder.send(MethodNotAllowedResponse.for(host))
+ raise Gem::WebauthnVerificationError, "Invalid HTTP method #{method.upcase} received."
+ end
+ end
+ end
+
+ private
+
+ def root_path?(uri)
+ uri.path == "/"
+ end
+
+ def parse_otp_from_uri(uri)
+ query = uri.query
+ return unless query && !query.empty?
+
+ query.split("&") do |param|
+ key, value = param.split("=", 2)
+ if value && Gem::URI.decode_www_form_component(key) == "code"
+ return Gem::URI.decode_www_form_component(value)
+ end
+ end
+
+ nil
+ end
+
+ class SocketResponder
+ def initialize(socket)
+ @socket = socket
+ end
+
+ def send(response)
+ @socket.print response.to_s
+ @socket.close
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb b/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb
new file mode 100644
index 0000000000..17baa64fff
--- /dev/null
+++ b/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb
@@ -0,0 +1,163 @@
+# frozen_string_literal: true
+
+##
+# The WebauthnListener Response class is used by the WebauthnListener to create
+# responses to be sent to the Gem host. It creates a Gem::Net::HTTPResponse instance
+# when initialized and can be converted to the appropriate format to be sent by a socket using `to_s`.
+# Gem::Net::HTTPResponse instances cannot be directly sent over a socket.
+#
+# Types of response classes:
+# - OkResponse
+# - NoContentResponse
+# - BadRequestResponse
+# - NotFoundResponse
+# - MethodNotAllowedResponse
+#
+# Example usage:
+#
+# server = TCPServer.new(0)
+# socket = server.accept
+#
+# response = OkResponse.for("https://rubygems.example")
+# socket.print response.to_s
+# socket.close
+#
+
+module Gem::GemcutterUtilities
+ class WebauthnListener
+ class Response
+ attr_reader :http_response
+
+ def self.for(host)
+ new(host)
+ end
+
+ def initialize(host)
+ @host = host
+
+ build_http_response
+ end
+
+ def to_s
+ status_line = "HTTP/#{@http_response.http_version} #{@http_response.code} #{@http_response.message}\r\n"
+ headers = @http_response.to_hash.map {|header, value| "#{header}: #{value.join(", ")}\r\n" }.join + "\r\n"
+ body = @http_response.body ? "#{@http_response.body}\n" : ""
+
+ status_line + headers + body
+ end
+
+ private
+
+ # Must be implemented in subclasses
+ def code
+ raise NotImplementedError
+ end
+
+ def reason_phrase
+ raise NotImplementedError
+ end
+
+ def body; end
+
+ def build_http_response
+ response_class = Gem::Net::HTTPResponse::CODE_TO_OBJ[code.to_s]
+ @http_response = response_class.new("1.1", code, reason_phrase)
+ @http_response.instance_variable_set(:@read, true)
+
+ add_connection_header
+ add_access_control_headers
+ add_body
+ end
+
+ def add_connection_header
+ @http_response["connection"] = "close"
+ end
+
+ def add_access_control_headers
+ @http_response["access-control-allow-origin"] = @host
+ @http_response["access-control-allow-methods"] = "POST"
+ @http_response["access-control-allow-headers"] = %w[Content-Type Authorization x-csrf-token]
+ end
+
+ def add_body
+ return unless body
+ @http_response["content-type"] = "text/plain; charset=utf-8"
+ @http_response["content-length"] = body.bytesize
+ @http_response.instance_variable_set(:@body, body)
+ end
+ end
+
+ class OkResponse < Response
+ private
+
+ def code
+ 200
+ end
+
+ def reason_phrase
+ "OK"
+ end
+
+ def body
+ "success"
+ end
+ end
+
+ class NoContentResponse < Response
+ private
+
+ def code
+ 204
+ end
+
+ def reason_phrase
+ "No Content"
+ end
+ end
+
+ class BadRequestResponse < Response
+ private
+
+ def code
+ 400
+ end
+
+ def reason_phrase
+ "Bad Request"
+ end
+
+ def body
+ "missing code parameter"
+ end
+ end
+
+ class NotFoundResponse < Response
+ private
+
+ def code
+ 404
+ end
+
+ def reason_phrase
+ "Not Found"
+ end
+ end
+
+ class MethodNotAllowedResponse < Response
+ private
+
+ def code
+ 405
+ end
+
+ def reason_phrase
+ "Method Not Allowed"
+ end
+
+ def add_access_control_headers
+ super
+ @http_response["allow"] = %w[GET OPTIONS]
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/gemcutter_utilities/webauthn_poller.rb b/lib/rubygems/gemcutter_utilities/webauthn_poller.rb
new file mode 100644
index 0000000000..fe3f163a88
--- /dev/null
+++ b/lib/rubygems/gemcutter_utilities/webauthn_poller.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+##
+# The WebauthnPoller class retrieves an OTP after a user successfully WebAuthns. An instance
+# polls the Gem host for the OTP code. The polling request (api/v1/webauthn_verification/<webauthn_token>/status.json)
+# is sent to the Gem host every 5 seconds and will timeout after 5 minutes. If the status field in the json response
+# is "success", the code field will contain the OTP code.
+#
+# Example usage:
+#
+# thread = Gem::WebauthnPoller.poll_thread(
+# {},
+# "RubyGems.org",
+# "https://rubygems.org/api/v1/webauthn_verification/odow34b93t6aPCdY",
+# { email: "email@example.com", password: "password" }
+# )
+# thread.join
+# otp = thread[:otp]
+# error = thread[:error]
+#
+
+module Gem::GemcutterUtilities
+ class WebauthnPoller
+ include Gem::GemcutterUtilities
+ TIMEOUT_IN_SECONDS = 300
+
+ attr_reader :options, :host
+
+ def initialize(options, host)
+ @options = options
+ @host = host
+ end
+
+ def self.poll_thread(options, host, webauthn_url, credentials)
+ Thread.new do
+ thread = Thread.current
+ thread.abort_on_exception = true
+ thread.report_on_exception = false
+ thread[:otp] = new(options, host).poll_for_otp(webauthn_url, credentials)
+ rescue Gem::WebauthnVerificationError, Gem::Timeout::Error => e
+ thread[:error] = e
+ end
+ end
+
+ def poll_for_otp(webauthn_url, credentials)
+ Gem::Timeout.timeout(TIMEOUT_IN_SECONDS) do
+ loop do
+ response = webauthn_verification_poll_response(webauthn_url, credentials)
+ raise Gem::WebauthnVerificationError, response.message unless response.is_a?(Gem::Net::HTTPSuccess)
+
+ require "json"
+ parsed_response = JSON.parse(response.body)
+ case parsed_response["status"]
+ when "pending"
+ sleep 5
+ when "success"
+ return parsed_response["code"]
+ else
+ raise Gem::WebauthnVerificationError, parsed_response.fetch("message", "Invalid response from server")
+ end
+ end
+ end
+ end
+
+ private
+
+ def webauthn_verification_poll_response(webauthn_url, credentials)
+ webauthn_token = %r{(?<=\/)[^\/]+(?=$)}.match(webauthn_url)[0]
+ rubygems_api_request(:get, "api/v1/webauthn_verification/#{webauthn_token}/status.json") do |request|
+ if credentials.empty?
+ request.add_field "Authorization", api_key
+ elsif credentials[:identifier] && credentials[:password]
+ request.basic_auth credentials[:identifier], credentials[:password]
+ else
+ raise Gem::WebauthnVerificationError, "Provided missing credentials"
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/gemspec_helpers.rb b/lib/rubygems/gemspec_helpers.rb
new file mode 100644
index 0000000000..2b20fcafa1
--- /dev/null
+++ b/lib/rubygems/gemspec_helpers.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require_relative "../rubygems"
+
+##
+# Mixin methods for commands that work with gemspecs.
+
+module Gem::GemspecHelpers
+ def find_gemspec(glob = "*.gemspec")
+ gemspecs = Dir.glob(glob).sort
+
+ if gemspecs.size > 1
+ alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
+ terminate_interaction(1)
+ end
+
+ gemspecs.first
+ end
+end
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
deleted file mode 100644
index d0061ff82e..0000000000
--- a/lib/rubygems/indexer.rb
+++ /dev/null
@@ -1,427 +0,0 @@
-# frozen_string_literal: true
-require_relative "../rubygems"
-require_relative "package"
-require "tmpdir"
-
-##
-# Top level class for building the gem repository index.
-
-class Gem::Indexer
- include Gem::UserInteraction
-
- ##
- # Build indexes for RubyGems 1.2.0 and newer when true
-
- attr_accessor :build_modern
-
- ##
- # Index install location
-
- attr_reader :dest_directory
-
- ##
- # Specs index install location
-
- attr_reader :dest_specs_index
-
- ##
- # Latest specs index install location
-
- attr_reader :dest_latest_specs_index
-
- ##
- # Prerelease specs index install location
-
- attr_reader :dest_prerelease_specs_index
-
- ##
- # Index build directory
-
- attr_reader :directory
-
- ##
- # Create an indexer that will index the gems in +directory+.
-
- def initialize(directory, options = {})
- require "fileutils"
- require "tmpdir"
- require "zlib"
-
- options = { :build_modern => true }.merge options
-
- @build_modern = options[:build_modern]
-
- @dest_directory = directory
- @directory = Dir.mktmpdir "gem_generate_index"
-
- marshal_name = "Marshal.#{Gem.marshal_version}"
-
- @master_index = File.join @directory, "yaml"
- @marshal_index = File.join @directory, marshal_name
-
- @quick_dir = File.join @directory, "quick"
- @quick_marshal_dir = File.join @quick_dir, marshal_name
- @quick_marshal_dir_base = File.join "quick", marshal_name # FIX: UGH
-
- @quick_index = File.join @quick_dir, "index"
- @latest_index = File.join @quick_dir, "latest_index"
-
- @specs_index = File.join @directory, "specs.#{Gem.marshal_version}"
- @latest_specs_index =
- File.join(@directory, "latest_specs.#{Gem.marshal_version}")
- @prerelease_specs_index =
- File.join(@directory, "prerelease_specs.#{Gem.marshal_version}")
- @dest_specs_index =
- File.join(@dest_directory, "specs.#{Gem.marshal_version}")
- @dest_latest_specs_index =
- File.join(@dest_directory, "latest_specs.#{Gem.marshal_version}")
- @dest_prerelease_specs_index =
- File.join(@dest_directory, "prerelease_specs.#{Gem.marshal_version}")
-
- @files = []
- end
-
- ##
- # Build various indices
-
- def build_indices
- specs = map_gems_to_specs gem_file_list
- Gem::Specification._resort! specs
- build_marshal_gemspecs specs
- build_modern_indices specs if @build_modern
-
- compress_indices
- end
-
- ##
- # Builds Marshal quick index gemspecs.
-
- def build_marshal_gemspecs(specs)
- count = specs.count
- progress = ui.progress_reporter count,
- "Generating Marshal quick index gemspecs for #{count} gems",
- "Complete"
-
- files = []
-
- Gem.time "Generated Marshal quick index gemspecs" do
- specs.each do |spec|
- next if spec.default_gem?
- spec_file_name = "#{spec.original_name}.gemspec.rz"
- marshal_name = File.join @quick_marshal_dir, spec_file_name
-
- marshal_zipped = Gem.deflate Marshal.dump(spec)
-
- File.open marshal_name, "wb" do |io|
- io.write marshal_zipped
- end
-
- files << marshal_name
-
- progress.updated spec.original_name
- end
-
- progress.done
- end
-
- @files << @quick_marshal_dir
-
- files
- end
-
- ##
- # Build a single index for RubyGems 1.2 and newer
-
- def build_modern_index(index, file, name)
- say "Generating #{name} index"
-
- Gem.time "Generated #{name} index" do
- File.open(file, "wb") do |io|
- specs = index.map do |*spec|
- # We have to splat here because latest_specs is an array, while the
- # others are hashes.
- spec = spec.flatten.last
- platform = spec.original_platform
-
- # win32-api-1.0.4-x86-mswin32-60
- unless String === platform
- alert_warning "Skipping invalid platform in gem: #{spec.full_name}"
- next
- end
-
- platform = Gem::Platform::RUBY if platform.nil? || platform.empty?
- [spec.name, spec.version, platform]
- end
-
- specs = compact_specs(specs)
- Marshal.dump(specs, io)
- end
- end
- end
-
- ##
- # Builds indices for RubyGems 1.2 and newer. Handles full, latest, prerelease
-
- def build_modern_indices(specs)
- prerelease, released = specs.partition do |s|
- s.version.prerelease?
- end
- latest_specs =
- Gem::Specification._latest_specs specs
-
- build_modern_index(released.sort, @specs_index, "specs")
- build_modern_index(latest_specs.sort, @latest_specs_index, "latest specs")
- build_modern_index(prerelease.sort, @prerelease_specs_index,
- "prerelease specs")
-
- @files += [@specs_index,
- "#{@specs_index}.gz",
- @latest_specs_index,
- "#{@latest_specs_index}.gz",
- @prerelease_specs_index,
- "#{@prerelease_specs_index}.gz"]
- end
-
- def map_gems_to_specs(gems)
- gems.map do |gemfile|
- if File.size(gemfile) == 0
- alert_warning "Skipping zero-length gem: #{gemfile}"
- next
- end
-
- begin
- spec = Gem::Package.new(gemfile).spec
- spec.loaded_from = gemfile
-
- spec.abbreviate
- spec.sanitize
-
- spec
- rescue SignalException
- alert_error "Received signal, exiting"
- raise
- rescue Exception => e
- msg = ["Unable to process #{gemfile}",
- "#{e.message} (#{e.class})",
- "\t#{e.backtrace.join "\n\t"}"].join("\n")
- alert_error msg
- end
- end.compact
- end
-
- ##
- # Compresses indices on disk
- #--
- # All future files should be compressed using gzip, not deflate
-
- def compress_indices
- say "Compressing indices"
-
- Gem.time "Compressed indices" do
- if @build_modern
- gzip @specs_index
- gzip @latest_specs_index
- gzip @prerelease_specs_index
- end
- end
- end
-
- ##
- # Compacts Marshal output for the specs index data source by using identical
- # objects as much as possible.
-
- def compact_specs(specs)
- names = {}
- versions = {}
- platforms = {}
-
- specs.map do |(name, version, platform)|
- names[name] = name unless names.include? name
- versions[version] = version unless versions.include? version
- platforms[platform] = platform unless platforms.include? platform
-
- [names[name], versions[version], platforms[platform]]
- end
- end
-
- ##
- # Compress +filename+ with +extension+.
-
- def compress(filename, extension)
- data = Gem.read_binary filename
-
- zipped = Gem.deflate data
-
- File.open "#{filename}.#{extension}", "wb" do |io|
- io.write zipped
- end
- end
-
- ##
- # List of gem file names to index.
-
- def gem_file_list
- Gem::Util.glob_files_in_dir("*.gem", File.join(@dest_directory, "gems"))
- end
-
- ##
- # Builds and installs indices.
-
- def generate_index
- make_temp_directories
- build_indices
- install_indices
- rescue SignalException
- ensure
- FileUtils.rm_rf @directory
- end
-
- ##
- # Zlib::GzipWriter wrapper that gzips +filename+ on disk.
-
- def gzip(filename)
- Zlib::GzipWriter.open "#{filename}.gz" do |io|
- io.write Gem.read_binary(filename)
- end
- end
-
- ##
- # Install generated indices into the destination directory.
-
- def install_indices
- verbose = Gem.configuration.really_verbose
-
- say "Moving index into production dir #{@dest_directory}" if verbose
-
- files = @files
- files.delete @quick_marshal_dir if files.include? @quick_dir
-
- if files.include?(@quick_marshal_dir) && !files.include?(@quick_dir)
- files.delete @quick_marshal_dir
-
- dst_name = File.join(@dest_directory, @quick_marshal_dir_base)
-
- FileUtils.mkdir_p File.dirname(dst_name), :verbose => verbose
- FileUtils.rm_rf dst_name, :verbose => verbose
- FileUtils.mv(@quick_marshal_dir, dst_name,
- :verbose => verbose, :force => true)
- end
-
- files = files.map do |path|
- path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK?
- end
-
- files.each do |file|
- src_name = File.join @directory, file
- dst_name = File.join @dest_directory, file
-
- FileUtils.rm_rf dst_name, :verbose => verbose
- FileUtils.mv(src_name, @dest_directory,
- :verbose => verbose, :force => true)
- end
- end
-
- ##
- # Make directories for index generation
-
- def make_temp_directories
- FileUtils.rm_rf @directory
- FileUtils.mkdir_p @directory, :mode => 0700
- FileUtils.mkdir_p @quick_marshal_dir
- end
-
- ##
- # Ensure +path+ and path with +extension+ are identical.
-
- def paranoid(path, extension)
- data = Gem.read_binary path
- compressed_data = Gem.read_binary "#{path}.#{extension}"
-
- unless data == Gem::Util.inflate(compressed_data)
- raise "Compressed file #{compressed_path} does not match uncompressed file #{path}"
- end
- end
-
- ##
- # Perform an in-place update of the repository from newly added gems.
-
- def update_index
- make_temp_directories
-
- specs_mtime = File.stat(@dest_specs_index).mtime
- newest_mtime = Time.at 0
-
- updated_gems = gem_file_list.select do |gem|
- gem_mtime = File.stat(gem).mtime
- newest_mtime = gem_mtime if gem_mtime > newest_mtime
- gem_mtime >= specs_mtime
- end
-
- if updated_gems.empty?
- say "No new gems"
- terminate_interaction 0
- end
-
- specs = map_gems_to_specs updated_gems
- prerelease, released = specs.partition {|s| s.version.prerelease? }
-
- files = build_marshal_gemspecs specs
-
- Gem.time "Updated indexes" do
- update_specs_index released, @dest_specs_index, @specs_index
- update_specs_index released, @dest_latest_specs_index, @latest_specs_index
- update_specs_index(prerelease,
- @dest_prerelease_specs_index,
- @prerelease_specs_index)
- end
-
- compress_indices
-
- verbose = Gem.configuration.really_verbose
-
- say "Updating production dir #{@dest_directory}" if verbose
-
- files << @specs_index
- files << "#{@specs_index}.gz"
- files << @latest_specs_index
- files << "#{@latest_specs_index}.gz"
- files << @prerelease_specs_index
- files << "#{@prerelease_specs_index}.gz"
-
- files = files.map do |path|
- path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK?
- end
-
- files.each do |file|
- src_name = File.join @directory, file
- dst_name = File.join @dest_directory, file # REFACTOR: duped above
-
- FileUtils.mv src_name, dst_name, :verbose => verbose,
- :force => true
-
- File.utime newest_mtime, newest_mtime, dst_name
- end
- ensure
- FileUtils.rm_rf @directory
- end
-
- ##
- # Combines specs in +index+ and +source+ then writes out a new copy to
- # +dest+. For a latest index, does not ensure the new file is minimal.
-
- def update_specs_index(index, source, dest)
- specs_index = Marshal.load Gem.read_binary(source)
-
- index.each do |spec|
- platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil? || platform.empty?
- specs_index << [spec.name, spec.version, platform]
- end
-
- specs_index = compact_specs specs_index.uniq.sort
-
- File.open dest, "wb" do |io|
- Marshal.dump specs_index, io
- end
- end
-end
diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb
deleted file mode 100644
index 0d112a15df..0000000000
--- a/lib/rubygems/install_default_message.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-require_relative "../rubygems"
-require_relative "user_interaction"
-
-##
-# A post-install hook that displays "Successfully installed
-# some_gem-1.0 as a default gem"
-
-Gem.post_install do |installer|
- ui = Gem::DefaultUserInteraction.ui
- ui.say "Successfully installed #{installer.spec.full_name} as a default gem"
-end
diff --git a/lib/rubygems/install_message.rb b/lib/rubygems/install_message.rb
index 2565f36261..a24e26b918 100644
--- a/lib/rubygems/install_message.rb
+++ b/lib/rubygems/install_message.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../rubygems"
require_relative "user_interaction"
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index ffb7d1b233..e8859cadaf 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -30,6 +31,15 @@ module Gem::InstallUpdateOptions
options[:bin_dir] = File.expand_path(value)
end
+ add_option(:"Install/Update", "-j", "--build-jobs VALUE", Integer,
+ "Specify the number of jobs to pass to `make` when installing",
+ "gems with native extensions.",
+ "Defaults to the number of processors.",
+ "This option is ignored on the mswin platform or",
+ "if the MAKEFLAGS environment variable is set.") do |value, options|
+ options[:build_jobs] = value
+ end
+
add_option(:"Install/Update", "--document [TYPES]", Array,
"Generate documentation for installed gems",
"List the documentation types you wish to",
@@ -136,9 +146,9 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", "-g", "--file [FILE]",
"Read from a gem dependencies API file and",
"install the listed gems") do |v,_o|
- v = Gem::GEM_DEP_FILES.find do |file|
+ v ||= Gem::GEM_DEP_FILES.find do |file|
File.exist? file
- end unless v
+ end
unless v
message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ", "})"
@@ -154,13 +164,12 @@ module Gem::InstallUpdateOptions
"Omit the named groups (comma separated)",
"when installing from a gem dependencies",
"file") do |v,_o|
- options[:without_groups].concat v.map {|without| without.intern }
+ options[:without_groups].concat v.map(&:intern)
end
- add_option(:"Install/Update", "--default",
+ add_option(:Deprecated, "--default",
"Add the gem's full specification to",
"specifications/default and extract only its bin") do |v,_o|
- options[:install_as_default] = v
end
add_option(:"Install/Update", "--explain",
@@ -178,6 +187,23 @@ module Gem::InstallUpdateOptions
"Suggest alternates when gems are not found") do |v,_o|
options[:suggest_alternate] = v
end
+
+ add_option(:"Install/Update", "--target-rbconfig [FILE]",
+ "rbconfig.rb for the deployment target platform") do |v, _o|
+ Gem.set_target_rbconfig(v)
+ end
+
+ add_option(:"Install/Update", "--[no-]build-extension",
+ "Build native extensions during installation.",
+ "Defaults to true") do |v, _o|
+ options[:build_extension] = v
+ end
+
+ add_option(:"Install/Update", "--[no-]install-plugin",
+ "Install plugins during installation.",
+ "Defaults to true") do |v, _o|
+ options[:install_plugin] = v
+ end
end
##
@@ -185,7 +211,7 @@ module Gem::InstallUpdateOptions
def install_update_options
{
- :document => %w[ri],
+ document: %w[ri],
}
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 96e777aaee..15d6aac0fd 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -7,7 +8,6 @@
require_relative "installer_uninstaller_utils"
require_relative "exceptions"
-require_relative "deprecate"
require_relative "package"
require_relative "ext"
require_relative "user_interaction"
@@ -26,8 +26,6 @@ require_relative "user_interaction"
# file. See Gem.pre_install and Gem.post_install for details.
class Gem::Installer
- extend Gem::Deprecate
-
##
# Paths where env(1) might live. Some systems are broken and have it in
# /bin
@@ -65,31 +63,7 @@ class Gem::Installer
attr_reader :package
- @path_warning = false
-
class << self
- #
- # Changes in rubygems to lazily loading `rubygems/command` (in order to
- # lazily load `optparse` as a side effect) affect bundler's custom installer
- # which uses `Gem::Command` without requiring it (up until bundler 2.2.29).
- # This hook is to compensate for that missing require.
- #
- # TODO: Remove when rubygems no longer supports running on bundler older
- # than 2.2.29.
-
- def inherited(klass)
- if klass.name == "Bundler::RubyGemsGemInstaller"
- require "rubygems/command"
- end
-
- super(klass)
- end
-
- ##
- # True if we've warned about PATH not including Gem.bindir
-
- attr_accessor :path_warning
-
##
# Overrides the executable format.
#
@@ -176,7 +150,7 @@ class Gem::Installer
# process. If not set, then Gem::Command.build_args is used
# :post_install_message:: Print gem post install message if true
- def initialize(package, options={})
+ def initialize(package, options = {})
require "fileutils"
@options = options
@@ -187,13 +161,6 @@ class Gem::Installer
@package.dir_mode = options[:dir_mode]
@package.prog_mode = options[:prog_mode]
@package.data_mode = options[:data_mode]
-
- if options[:user_install]
- @gem_home = Gem.user_dir
- @bin_dir = Gem.bindir gem_home unless options[:bin_dir]
- @plugins_dir = Gem.plugindir(gem_home)
- check_that_user_bin_dir_is_in_path
- end
end
##
@@ -221,31 +188,31 @@ class Gem::Installer
File.open generated_bin, "rb" do |io|
line = io.gets
- shebang = /^#!.*ruby/
+ shebang = /^#!.*ruby/o
- if load_relative_enabled?
- until line.nil? || line =~ shebang do
+ # TruffleRuby uses a bash prelude in default launchers
+ if load_relative_enabled? || RUBY_ENGINE == "truffleruby"
+ until line.nil? || shebang.match?(line) do
line = io.gets
end
end
- next unless line =~ shebang
+ next unless line&.match?(shebang)
io.gets # blankline
- # TODO detect a specially formatted comment instead of trying
+ # TODO: detect a specially formatted comment instead of trying
# to find a string inside Ruby code.
- next unless io.gets.to_s.include?("This file was generated by RubyGems")
+ next unless io.gets&.include?("This file was generated by RubyGems")
ruby_executable = true
- existing = io.read.slice(%r{
+ existing = io.read.slice(/
^\s*(
- gem \s |
- load \s Gem\.bin_path\( |
+ Gem\.activate_and_load_bin_path\( |
load \s Gem\.activate_bin_path\(
)
(['"])(.*?)(\2),
- }x, 3)
+ /x, 3)
end
return if spec.name == existing
@@ -304,75 +271,67 @@ class Gem::Installer
run_pre_install_hooks
# Set loaded_from to ensure extension_dir is correct
- if @options[:install_as_default]
- spec.loaded_from = default_spec_file
- else
- spec.loaded_from = spec_file
- end
+ spec.loaded_from = spec_file
# Completely remove any previous gem files
FileUtils.rm_rf gem_dir
FileUtils.rm_rf spec.extension_dir
dir_mode = options[:dir_mode]
- FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p gem_dir, mode: dir_mode && 0o755
- if @options[:install_as_default]
- extract_bin
- write_default_spec
- else
- extract_files
+ extract_files
- build_extensions
- write_build_info_file
- run_post_build_hooks
- end
+ build_extensions
+ write_build_info_file
+ run_post_build_hooks
generate_bin
- generate_plugins
-
- unless @options[:install_as_default]
- write_spec
- write_cache_file
+ if options[:install_plugin] == false
+ remove_stale_plugins
+ warn_skipped_plugins
+ else
+ generate_plugins
end
+ write_spec
+ write_cache_file
+
File.chmod(dir_mode, gem_dir) if dir_mode
say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil?
- Gem::Specification.add_spec(spec)
+ Gem::Specification.add_spec(spec) unless @install_dir
+
+ load_plugin unless options[:install_plugin] == false
run_post_install_hooks
spec
-
- # TODO This rescue is in the wrong place. What is raising this exception?
- # move this rescue to around the code that actually might raise it.
- rescue Zlib::GzipFile::Error
- raise Gem::InstallError, "gzip error installing #{gem}"
+ rescue Errno::EACCES => e
+ # Permission denied - /path/to/foo
+ raise Gem::FilePermissionError, e.message.split(" - ").last
end
def run_pre_install_hooks # :nodoc:
Gem.pre_install_hooks.each do |hook|
- if hook.call(self) == false
- location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
+ next unless hook.call(self) == false
+ location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
- message = "pre-install hook#{location} failed for #{spec.full_name}"
- raise Gem::InstallError, message
- end
+ message = "pre-install hook#{location} failed for #{spec.full_name}"
+ raise Gem::InstallError, message
end
end
def run_post_build_hooks # :nodoc:
Gem.post_build_hooks.each do |hook|
- if hook.call(self) == false
- FileUtils.rm_rf gem_dir
+ next unless hook.call(self) == false
+ FileUtils.rm_rf gem_dir
- location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
+ location = " at #{$1}" if hook.inspect =~ /[ @](.*:\d+)/
- message = "post-build hook#{location} failed for #{spec.full_name}"
- raise Gem::InstallError, message
- end
+ message = "post-build hook#{location} failed for #{spec.full_name}"
+ raise Gem::InstallError, message
end
end
@@ -388,11 +347,11 @@ class Gem::Installer
# we'll be installing into.
def installed_specs
- @specs ||= begin
+ @installed_specs ||= begin
specs = []
Gem::Util.glob_files_in_dir("*.gemspec", File.join(gem_home, "specifications")).each do |path|
- spec = Gem::Specification.load path.tap(&Gem::UNTAINT)
+ spec = Gem::Specification.load path
specs << spec if spec
end
@@ -425,15 +384,6 @@ class Gem::Installer
end
##
- # Unpacks the gem into the given directory.
-
- def unpack(directory)
- @gem_dir = directory
- extract_files
- end
- rubygems_deprecate :unpack
-
- ##
# The location of the spec file that is installed.
#
@@ -441,12 +391,18 @@ class Gem::Installer
File.join gem_home, "specifications", "#{spec.full_name}.gemspec"
end
+ def default_spec_dir
+ dir = File.join(gem_home, "specifications", "default")
+ FileUtils.mkdir_p dir
+ dir
+ end
+
##
# The location of the default spec file for default gems.
#
def default_spec_file
- File.join gem_home, "specifications", "default", "#{spec.full_name}.gemspec"
+ File.join default_spec_dir, "#{spec.full_name}.gemspec"
end
##
@@ -462,6 +418,9 @@ class Gem::Installer
##
# Writes the full .gemspec specification (in Ruby) to the gem home's
# specifications/default directory.
+ #
+ # In contrast to #write_spec, this keeps file lists, so the `gem contents`
+ # command works.
def write_default_spec
Gem.write_binary(default_spec_file, spec.to_ruby)
@@ -483,21 +442,29 @@ class Gem::Installer
end
def generate_bin # :nodoc:
- return if spec.executables.nil? || spec.executables.empty?
+ executables = spec.executables
+ return if executables.nil? || executables.empty?
+
+ if @gem_home == Gem.user_dir
+ # If we get here, then one of the following likely happened:
+ # - `--user-install` was specified
+ # - `Gem::PathSupport#home` fell back to `Gem.user_dir`
+ # - GEM_HOME was manually set to `Gem.user_dir`
+
+ check_that_user_bin_dir_is_in_path(executables)
+ end
ensure_writable_dir @bin_dir
- spec.executables.each do |filename|
- filename.tap(&Gem::UNTAINT)
+ executables.each do |filename|
bin_path = File.join gem_dir, spec.bindir, filename
next unless File.exist? bin_path
mode = File.stat(bin_path).mode
- dir_mode = options[:prog_mode] || (mode | 0111)
+ dir_mode = options[:prog_mode] || (mode | 0o111)
unless dir_mode == mode
- require "fileutils"
- FileUtils.chmod dir_mode, bin_path
+ File.chmod dir_mode, bin_path
end
check_executable_overwrite filename
@@ -535,12 +502,14 @@ class Gem::Installer
def generate_bin_script(filename, bindir)
bin_script_path = File.join bindir, formatted_program_filename(filename)
- require "fileutils"
- FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
+ Gem.open_file_with_lock(bin_script_path) do
+ require "fileutils"
+ FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
- File.open bin_script_path, "wb", 0755 do |file|
- file.print app_script_text(filename)
- file.chmod(options[:prog_mode] || 0755)
+ File.open(bin_script_path, "wb", 0o755) do |file|
+ file.write app_script_text(filename)
+ file.chmod(options[:prog_mode] || 0o755)
+ end
end
verbose bin_script_path
@@ -565,7 +534,7 @@ class Gem::Installer
File.unlink dst
end
- FileUtils.symlink src, dst, :verbose => Gem.configuration.really_verbose
+ FileUtils.symlink src, dst, verbose: Gem.configuration.really_verbose
rescue NotImplementedError, SystemCallError
alert_warning "Unable to use symlinks, installing wrapper"
generate_bin_script filename, bindir
@@ -588,7 +557,7 @@ class Gem::Installer
def shebang(bin_file_name)
path = File.join gem_dir, spec.bindir, bin_file_name
- first_line = File.open(path, "rb") {|file| file.gets } || ""
+ first_line = File.open(path, "rb", &:gets) || ""
if first_line.start_with?("#!")
# Preserve extra words on shebang line, like "-w". Thanks RPA.
@@ -630,7 +599,6 @@ class Gem::Installer
def ensure_loadable_spec
ruby = spec.to_ruby_for_cache
- ruby.tap(&Gem::UNTAINT)
begin
eval ruby
@@ -651,31 +619,37 @@ class Gem::Installer
def process_options # :nodoc:
@options = {
- :bin_dir => nil,
- :env_shebang => false,
- :force => false,
- :only_install_dir => false,
- :post_install_message => true,
+ bin_dir: nil,
+ env_shebang: false,
+ force: false,
+ only_install_dir: false,
+ post_install_message: true,
}.merge options
@env_shebang = options[:env_shebang]
@force = options[:force]
@install_dir = options[:install_dir]
- @gem_home = options[:install_dir] || Gem.dir
- @plugins_dir = Gem.plugindir(@gem_home)
+ @user_install = options[:user_install]
@ignore_dependencies = options[:ignore_dependencies]
@format_executable = options[:format_executable]
@wrappers = options[:wrappers]
@only_install_dir = options[:only_install_dir]
- # 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.
- @bin_dir = options[:bin_dir] || Gem.bindir(gem_home)
+ @bin_dir = options[:bin_dir]
@development = options[:development]
@build_root = options[:build_root]
@build_args = options[:build_args]
+ @build_jobs = options[:build_jobs]
+
+ @gem_home = @install_dir || user_install_dir || Gem.dir
+
+ # 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.
+ @bin_dir ||= Gem.bindir(@gem_home)
+
+ @plugins_dir = Gem.plugindir(@gem_home)
unless @build_root.nil?
@bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, ""))
@@ -685,9 +659,7 @@ class Gem::Installer
end
end
- def check_that_user_bin_dir_is_in_path # :nodoc:
- return if self.class.path_warning
-
+ def check_that_user_bin_dir_is_in_path(executables) # :nodoc:
user_bin_dir = @bin_dir || Gem.bindir(gem_home)
user_bin_dir = user_bin_dir.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
@@ -703,19 +675,17 @@ class Gem::Installer
unless path.include? user_bin_dir
unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV["HOME"], "~"))
- alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
- self.class.path_warning = true
+ alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables (#{executables.join(", ")}) will not run."
end
end
end
def verify_gem_home # :nodoc:
- FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
- raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
+ FileUtils.mkdir_p gem_home, mode: options[:dir_mode] && 0o755
end
def verify_spec
- unless spec.name =~ Gem::Specification::VALID_NAME_PATTERN
+ unless Gem::Specification::VALID_NAME_PATTERN.match?(spec.name)
raise Gem::InstallError, "#{spec} has an invalid name"
end
@@ -727,11 +697,11 @@ class Gem::Installer
raise Gem::InstallError, "#{spec} has an invalid extensions"
end
- if spec.platform.to_s =~ /\R/
+ if /\R/.match?(spec.platform.to_s)
raise Gem::InstallError, "#{spec.platform} is an invalid platform"
end
- unless spec.specification_version.to_s =~ /\A\d+\z/
+ unless /\A\d+\z/.match?(spec.specification_version.to_s)
raise Gem::InstallError, "#{spec} has an invalid specification_version"
end
@@ -748,56 +718,55 @@ class Gem::Installer
# Return the text for an application file.
def app_script_text(bin_file_name)
- # note that the `load` lines cannot be indented, as old RG versions match
+ # NOTE: that the `load` lines cannot be indented, as old RG versions match
# against the beginning of the line
- return <<-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'
-#{gemdeps_load(spec.name)}
-version = "#{Gem::Requirement.default_prerelease}"
-
-str = ARGV.first
-if str
- str = str.b[/\\A_(.*)_\\z/, 1]
- if str and Gem::Version.correct?(str)
- #{explicit_version_requirement(spec.name)}
- ARGV.shift
- end
-end
+ <<~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'
+ #{gemdeps_load(spec.name)}
+ version = "#{Gem::Requirement.default_prerelease}"
+
+ str = ARGV.first
+ if str
+ str = str.b[/\\A_(.*)_\\z/, 1]
+ if str and Gem::Version.correct?(str)
+ #{explicit_version_requirement(spec.name)}
+ ARGV.shift
+ end
+ end
-if Gem.respond_to?(:activate_bin_path)
-load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
-else
-gem #{spec.name.dump}, version
-load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
-end
-TEXT
+ if Gem.respond_to?(:activate_and_load_bin_path)
+ Gem.activate_and_load_bin_path('#{spec.name}', '#{bin_file_name}', version)
+ else
+ load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
+ end
+ TEXT
end
def gemdeps_load(name)
return "" if name == "bundler"
- <<-TEXT
+ <<~TEXT
-Gem.use_gemdeps
-TEXT
+ Gem.use_gemdeps
+ TEXT
end
def explicit_version_requirement(name)
code = "version = str"
return code unless name == "bundler"
- code += <<-TEXT
+ code += <<~TEXT
- ENV['BUNDLER_VERSION'] = str
-TEXT
+ ENV['BUNDLER_VERSION'] = str
+ TEXT
end
##
@@ -812,9 +781,9 @@ TEXT
if File.exist?(File.join(bindir, ruby_exe))
# stub & ruby.exe within same folder. Portable
- <<-TEXT
-@ECHO OFF
-@"%~dp0#{ruby_exe}" "%~dpn0" %*
+ <<~TEXT
+ @ECHO OFF
+ @"%~dp0#{ruby_exe}" "%~dpn0" %*
TEXT
elsif bindir.downcase.start_with? rb_topdir.downcase
# stub within ruby folder, but not standard bin. Portable
@@ -822,16 +791,16 @@ TEXT
from = Pathname.new bindir
to = Pathname.new "#{rb_topdir}/bin"
rel = to.relative_path_from from
- <<-TEXT
-@ECHO OFF
-@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
+ <<~TEXT
+ @ECHO OFF
+ @"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
TEXT
else
# outside ruby folder, maybe -user-install or bundler. Portable, but ruby
# is dependent on PATH
- <<-TEXT
-@ECHO OFF
-@#{ruby_exe} "%~dpn0" %*
+ <<~TEXT
+ @ECHO OFF
+ @#{ruby_exe} "%~dpn0" %*
TEXT
end
end
@@ -840,11 +809,37 @@ TEXT
# configure scripts and rakefiles or mkrf_conf files.
def build_extensions
- builder = Gem::Ext::Builder.new spec, build_args
+ if options[:build_extension] == false
+ warn_skipped_extensions
+ return
+ end
+
+ builder = Gem::Ext::Builder.new spec, build_args, Gem.target_rbconfig, build_jobs
builder.build_extensions
end
+ def warn_skipped_extensions # :nodoc:
+ return if spec.extensions.empty?
+
+ alert_warning "#{spec.full_name} contains native extensions that were not built.\n" \
+ "To build extensions, run: gem pristine #{spec.name} --extensions"
+ end
+
+ def warn_skipped_plugins # :nodoc:
+ return if spec.plugins.empty?
+
+ alert_warning "#{spec.full_name} contains plugins that were not installed.\n" \
+ "To install plugins, run: gem pristine #{spec.name} --only-plugins"
+ end
+
+ def remove_stale_plugins # :nodoc:
+ return unless spec.plugins.empty?
+
+ ensure_writable_dir @plugins_dir
+ remove_plugins_for(spec, @plugins_dir)
+ end
+
##
# Reads the file index and extracts each file into the gem directory.
#
@@ -909,11 +904,7 @@ TEXT
ensure_loadable_spec
- if options[:install_as_default]
- Gem.ensure_default_gem_subdirectories gem_home
- else
- Gem.ensure_gem_subdirectories gem_home
- end
+ Gem.ensure_gem_subdirectories gem_home
return true if @force
@@ -932,7 +923,7 @@ TEXT
build_info_dir = File.join gem_home, "build_info"
dir_mode = options[:dir_mode]
- FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p build_info_dir, mode: dir_mode && 0o755
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
@@ -954,17 +945,27 @@ TEXT
end
def ensure_writable_dir(dir) # :nodoc:
- begin
- Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
- rescue SystemCallError
- raise unless File.directory? dir
- end
+ require "fileutils"
+ FileUtils.mkdir_p dir, mode: options[:dir_mode] && 0o755
raise Gem::FilePermissionError.new(dir) unless File.writable? dir
end
private
+ def user_install_dir
+ # never install to user home in --build-root mode
+ return unless @build_root.nil?
+
+ # Please note that @user_install might have three states:
+ # * `true`: `--user-install`
+ # * `false`: `--no-user-install` and
+ # * `nil`: option was not specified
+ if @user_install || (@user_install.nil? && Gem.default_user_install)
+ Gem.user_dir
+ end
+ end
+
def build_args
@build_args ||= begin
require_relative "command"
@@ -972,8 +973,17 @@ TEXT
end
end
+ def build_jobs
+ @build_jobs ||= begin
+ require "etc"
+ Etc.nprocessors + 1
+ rescue LoadError
+ 1
+ end
+ end
+
def rb_config
- RbConfig::CONFIG
+ Gem.target_rbconfig
end
def ruby_install_name
@@ -986,22 +996,35 @@ TEXT
def bash_prolog_script
if load_relative_enabled?
- script = +<<~EOS
- bindir="${0%/*}"
- EOS
-
- script << %Q(exec "$bindir/#{ruby_install_name}" "-x" "$0" "$@"\n)
-
<<~EOS
#!/bin/sh
# -*- ruby -*-
_=_\\
=begin
- #{script.chomp}
+ bindir="${0%/*}"
+ ruby="$bindir/#{ruby_install_name}"
+ if [ ! -f "$ruby" ]; then
+ ruby="#{ruby_install_name}"
+ fi
+ exec "$ruby" "-x" "$0" "$@"
=end
EOS
else
""
end
end
+
+ def load_plugin
+ specs = Gem::Specification.find_all_by_name(spec.name)
+ # If old version already exists, this plugin isn't loaded
+ # immediately. It's for avoiding a case that multiple versions
+ # are loaded at the same time.
+ return unless specs.size == 1
+
+ plugin_files = spec.plugins.filter_map do |plugin|
+ path = File.join(@plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}")
+ path if File.exist?(path)
+ end
+ Gem.load_plugin_files(plugin_files) unless plugin_files.empty?
+ end
end
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
index 9751d9cd4c..3b88c43149 100644
--- a/lib/rubygems/local_remote_options.rb
+++ b/lib/rubygems/local_remote_options.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require "uri"
+require_relative "vendor/uri/lib/uri"
require_relative "../rubygems"
##
@@ -16,10 +17,10 @@ module Gem::LocalRemoteOptions
# Allows Gem::OptionParser to handle HTTP URIs.
def accept_uri_http
- Gem::OptionParser.accept URI::HTTP do |value|
+ Gem::OptionParser.accept Gem::URI::HTTP do |value|
begin
- uri = URI.parse value
- rescue URI::InvalidURIError
+ uri = Gem::URI.parse value
+ rescue Gem::URI::InvalidURIError
raise Gem::OptionParser::InvalidArgument, value
end
@@ -87,9 +88,9 @@ module Gem::LocalRemoteOptions
def add_proxy_option
accept_uri_http
- add_option(:"Local/Remote", "-p", "--[no-]http-proxy [URL]", URI::HTTP,
+ add_option(:"Local/Remote", "-p", "--[no-]http-proxy [URL]", Gem::URI::HTTP,
"Use HTTP proxy for remote operations") do |value, options|
- options[:http_proxy] = (value == false) ? :no_proxy : value
+ options[:http_proxy] = value == false ? :no_proxy : value
Gem.configuration[:http_proxy] = options[:http_proxy]
end
end
@@ -100,9 +101,9 @@ module Gem::LocalRemoteOptions
def add_source_option
accept_uri_http
- add_option(:"Local/Remote", "-s", "--source URL", URI::HTTP,
+ add_option(:"Local/Remote", "-s", "--source URL", Gem::URI::HTTP,
"Append URL to list of remote gem sources") do |source, options|
- source << "/" if source !~ /\/\z/
+ source << "/" unless source.end_with?("/")
if options.delete :sources_cleared
Gem.sources = [source]
@@ -133,13 +134,13 @@ module Gem::LocalRemoteOptions
# Is local fetching enabled?
def local?
- options[:domain] == :local || options[:domain] == :both
+ [:local, :both].include?(options[:domain])
end
##
# Is remote fetching enabled?
def remote?
- options[:domain] == :remote || options[:domain] == :both
+ [:remote, :both].include?(options[:domain])
end
end
diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb
deleted file mode 100644
index fab292d42a..0000000000
--- a/lib/rubygems/mock_gem_ui.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# frozen_string_literal: true
-require_relative "user_interaction"
-
-##
-# This Gem::StreamUI subclass records input and output to StringIO for
-# retrieval during tests.
-
-class Gem::MockGemUi < Gem::StreamUI
- ##
- # Raised when you haven't provided enough input to your MockGemUi
-
- class InputEOFError < RuntimeError
- def initialize(question)
- super "Out of input for MockGemUi on #{question.inspect}"
- end
- end
-
- class TermError < RuntimeError
- attr_reader :exit_code
-
- def initialize(exit_code)
- super
- @exit_code = exit_code
- end
- end
-
- class SystemExitException < RuntimeError; end
-
- module TTY
- attr_accessor :tty
-
- def tty?
- @tty = true unless defined?(@tty)
- @tty
- end
-
- def noecho
- yield self
- end
- end
-
- def initialize(input = "")
- require "stringio"
- ins = StringIO.new input
- outs = StringIO.new
- errs = StringIO.new
-
- ins.extend TTY
- outs.extend TTY
- errs.extend TTY
-
- super ins, outs, errs, true
-
- @terminated = false
- end
-
- def ask(question)
- raise InputEOFError, question if @ins.eof?
-
- super
- end
-
- def input
- @ins.string
- end
-
- def output
- @outs.string
- end
-
- def error
- @errs.string
- end
-
- def terminated?
- @terminated
- end
-
- def terminate_interaction(status=0)
- @terminated = true
-
- raise TermError, status if status != 0
- raise SystemExitException
- end
-end
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb
index 8e39fc3a4f..cbdf4d7ac5 100644
--- a/lib/rubygems/name_tuple.rb
+++ b/lib/rubygems/name_tuple.rb
@@ -1,18 +1,17 @@
# frozen_string_literal: true
+
##
#
# Represents a gem of name +name+ at +version+ of +platform+. These
# wrap the data returned from the indexes.
class Gem::NameTuple
- def initialize(name, version, platform="ruby")
+ def initialize(name, version, platform = Gem::Platform::RUBY)
@name = name
@version = version
- unless platform.is_a? Gem::Platform
- platform = "ruby" if !platform || platform.empty?
- end
-
+ platform &&= platform.to_s
+ platform = Gem::Platform::RUBY if !platform || platform.empty?
@platform = platform
end
@@ -31,7 +30,7 @@ class Gem::NameTuple
# [name, version, platform] tuples.
def self.to_basic(list)
- list.map {|t| t.to_a }
+ list.map(&:to_a)
end
##
@@ -48,11 +47,11 @@ class Gem::NameTuple
def full_name
case @platform
- when nil, "ruby", ""
+ when nil, "", Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@platform}"
- end.dup.tap(&Gem::UNTAINT)
+ end
end
##
@@ -82,6 +81,12 @@ class Gem::NameTuple
[@name, @version, @platform]
end
+ alias_method :deconstruct, :to_a
+
+ def deconstruct_keys(keys)
+ { name: @name, version: @version, platform: @platform }
+ end
+
def inspect # :nodoc:
"#<Gem::NameTuple #{@name}, #{@version}, #{@platform}>"
end
diff --git a/lib/rubygems/optparse.rb b/lib/rubygems/optparse.rb
deleted file mode 100644
index 6ed718423c..0000000000
--- a/lib/rubygems/optparse.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "optparse/lib/optparse"
diff --git a/lib/rubygems/optparse/lib/optparse.rb b/lib/rubygems/optparse/lib/optparse.rb
deleted file mode 100644
index 1e50bda769..0000000000
--- a/lib/rubygems/optparse/lib/optparse.rb
+++ /dev/null
@@ -1,2308 +0,0 @@
-# frozen_string_literal: true
-#
-# optparse.rb - command-line option analysis with the Gem::OptionParser class.
-#
-# Author:: Nobu Nakada
-# Documentation:: Nobu Nakada and Gavin Sinclair.
-#
-# See Gem::OptionParser for documentation.
-#
-
-
-#--
-# == Developer Documentation (not for RDoc output)
-#
-# === Class tree
-#
-# - Gem::OptionParser:: front end
-# - Gem::OptionParser::Switch:: each switches
-# - Gem::OptionParser::List:: options list
-# - Gem::OptionParser::ParseError:: errors on parsing
-# - Gem::OptionParser::AmbiguousOption
-# - Gem::OptionParser::NeedlessArgument
-# - Gem::OptionParser::MissingArgument
-# - Gem::OptionParser::InvalidOption
-# - Gem::OptionParser::InvalidArgument
-# - Gem::OptionParser::AmbiguousArgument
-#
-# === Object relationship diagram
-#
-# +--------------+
-# | Gem::OptionParser |<>-----+
-# +--------------+ | +--------+
-# | ,-| Switch |
-# on_head -------->+---------------+ / +--------+
-# accept/reject -->| List |<|>-
-# | |<|>- +----------+
-# on ------------->+---------------+ `-| argument |
-# : : | class |
-# +---------------+ |==========|
-# on_tail -------->| | |pattern |
-# +---------------+ |----------|
-# Gem::OptionParser.accept ->| DefaultList | |converter |
-# reject |(shared between| +----------+
-# | all instances)|
-# +---------------+
-#
-#++
-#
-# == Gem::OptionParser
-#
-# === New to \Gem::OptionParser?
-#
-# See the {Tutorial}[optparse/tutorial.rdoc].
-#
-# === Introduction
-#
-# Gem::OptionParser is a class for command-line option analysis. It is much more
-# advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented
-# solution.
-#
-# === Features
-#
-# 1. The argument specification and the code to handle it are written in the
-# same place.
-# 2. It can output an option summary; you don't need to maintain this string
-# separately.
-# 3. Optional and mandatory arguments are specified very gracefully.
-# 4. Arguments can be automatically converted to a specified class.
-# 5. Arguments can be restricted to a certain set.
-#
-# All of these features are demonstrated in the examples below. See
-# #make_switch for full documentation.
-#
-# === Minimal example
-#
-# require 'rubygems/optparse/lib/optparse'
-#
-# options = {}
-# Gem::OptionParser.new do |parser|
-# parser.banner = "Usage: example.rb [options]"
-#
-# parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
-# options[:verbose] = v
-# end
-# end.parse!
-#
-# p options
-# p ARGV
-#
-# === Generating Help
-#
-# Gem::OptionParser can be used to automatically generate help for the commands you
-# write:
-#
-# require 'rubygems/optparse/lib/optparse'
-#
-# Options = Struct.new(:name)
-#
-# class Parser
-# def self.parse(options)
-# args = Options.new("world")
-#
-# opt_parser = Gem::OptionParser.new do |parser|
-# parser.banner = "Usage: example.rb [options]"
-#
-# parser.on("-nNAME", "--name=NAME", "Name to say hello to") do |n|
-# args.name = n
-# end
-#
-# parser.on("-h", "--help", "Prints this help") do
-# puts parser
-# exit
-# end
-# end
-#
-# opt_parser.parse!(options)
-# return args
-# end
-# end
-# options = Parser.parse %w[--help]
-#
-# #=>
-# # Usage: example.rb [options]
-# # -n, --name=NAME Name to say hello to
-# # -h, --help Prints this help
-#
-# === Required Arguments
-#
-# For options that require an argument, option specification strings may include an
-# option name in all caps. If an option is used without the required argument,
-# an exception will be raised.
-#
-# require 'rubygems/optparse/lib/optparse'
-#
-# options = {}
-# Gem::OptionParser.new do |parser|
-# parser.on("-r", "--require LIBRARY",
-# "Require the LIBRARY before executing your script") do |lib|
-# puts "You required #{lib}!"
-# end
-# end.parse!
-#
-# Used:
-#
-# $ ruby optparse-test.rb -r
-# optparse-test.rb:9:in `<main>': missing argument: -r (Gem::OptionParser::MissingArgument)
-# $ ruby optparse-test.rb -r my-library
-# You required my-library!
-#
-# === Type Coercion
-#
-# Gem::OptionParser supports the ability to coerce command line arguments
-# into objects for us.
-#
-# Gem::OptionParser comes with a few ready-to-use kinds of type
-# coercion. They are:
-#
-# - Date -- Anything accepted by +Date.parse+
-# - DateTime -- Anything accepted by +DateTime.parse+
-# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+
-# - URI -- Anything accepted by +URI.parse+
-# - Shellwords -- Anything accepted by +Shellwords.shellwords+
-# - String -- Any non-empty string
-# - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
-# - Float -- Any float. (e.g. 10, 3.14, -100E+13)
-# - Numeric -- Any integer, float, or rational (1, 3.4, 1/3)
-# - DecimalInteger -- Like +Integer+, but no octal format.
-# - OctalInteger -- Like +Integer+, but no decimal format.
-# - DecimalNumeric -- Decimal integer or float.
-# - TrueClass -- Accepts '+, yes, true, -, no, false' and
-# defaults as +true+
-# - FalseClass -- Same as +TrueClass+, but defaults to +false+
-# - Array -- Strings separated by ',' (e.g. 1,2,3)
-# - Regexp -- Regular expressions. Also includes options.
-#
-# We can also add our own coercions, which we will cover below.
-#
-# ==== Using Built-in Conversions
-#
-# As an example, the built-in +Time+ conversion is used. The other built-in
-# conversions behave in the same way.
-# Gem::OptionParser will attempt to parse the argument
-# as a +Time+. If it succeeds, that time will be passed to the
-# handler block. Otherwise, an exception will be raised.
-#
-# require 'rubygems/optparse/lib/optparse'
-# require 'rubygems/optparse/lib/optparse/time'
-# Gem::OptionParser.new do |parser|
-# parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
-# p time
-# end
-# end.parse!
-#
-# Used:
-#
-# $ ruby optparse-test.rb -t nonsense
-# ... invalid argument: -t nonsense (Gem::OptionParser::InvalidArgument)
-# $ ruby optparse-test.rb -t 10-11-12
-# 2010-11-12 00:00:00 -0500
-# $ ruby optparse-test.rb -t 9:30
-# 2014-08-13 09:30:00 -0400
-#
-# ==== Creating Custom Conversions
-#
-# The +accept+ method on Gem::OptionParser may be used to create converters.
-# It specifies which conversion block to call whenever a class is specified.
-# The example below uses it to fetch a +User+ object before the +on+ handler receives it.
-#
-# require 'rubygems/optparse/lib/optparse'
-#
-# User = Struct.new(:id, :name)
-#
-# def find_user id
-# not_found = ->{ raise "No User Found for id #{id}" }
-# [ User.new(1, "Sam"),
-# User.new(2, "Gandalf") ].find(not_found) do |u|
-# u.id == id
-# end
-# end
-#
-# op = Gem::OptionParser.new
-# op.accept(User) do |user_id|
-# find_user user_id.to_i
-# end
-#
-# op.on("--user ID", User) do |user|
-# puts user
-# end
-#
-# op.parse!
-#
-# Used:
-#
-# $ ruby optparse-test.rb --user 1
-# #<struct User id=1, name="Sam">
-# $ ruby optparse-test.rb --user 2
-# #<struct User id=2, name="Gandalf">
-# $ ruby optparse-test.rb --user 3
-# optparse-test.rb:15:in `block in find_user': No User Found for id 3 (RuntimeError)
-#
-# === Store options to a Hash
-#
-# The +into+ option of +order+, +parse+ and so on methods stores command line options into a Hash.
-#
-# require 'rubygems/optparse/lib/optparse'
-#
-# options = {}
-# Gem::OptionParser.new do |parser|
-# parser.on('-a')
-# parser.on('-b NUM', Integer)
-# parser.on('-v', '--verbose')
-# end.parse!(into: options)
-#
-# p options
-#
-# Used:
-#
-# $ ruby optparse-test.rb -a
-# {:a=>true}
-# $ ruby optparse-test.rb -a -v
-# {:a=>true, :verbose=>true}
-# $ ruby optparse-test.rb -a -b 100
-# {:a=>true, :b=>100}
-#
-# === Complete example
-#
-# The following example is a complete Ruby program. You can run it and see the
-# effect of specifying various options. This is probably the best way to learn
-# the features of +optparse+.
-#
-# require 'rubygems/optparse/lib/optparse'
-# require 'rubygems/optparse/lib/optparse/time'
-# require 'ostruct'
-# require 'pp'
-#
-# class OptparseExample
-# Version = '1.0.0'
-#
-# CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
-# CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
-#
-# class ScriptOptions
-# attr_accessor :library, :inplace, :encoding, :transfer_type,
-# :verbose, :extension, :delay, :time, :record_separator,
-# :list
-#
-# def initialize
-# self.library = []
-# self.inplace = false
-# self.encoding = "utf8"
-# self.transfer_type = :auto
-# self.verbose = false
-# end
-#
-# def define_options(parser)
-# parser.banner = "Usage: example.rb [options]"
-# parser.separator ""
-# parser.separator "Specific options:"
-#
-# # add additional options
-# perform_inplace_option(parser)
-# delay_execution_option(parser)
-# execute_at_time_option(parser)
-# specify_record_separator_option(parser)
-# list_example_option(parser)
-# specify_encoding_option(parser)
-# optional_option_argument_with_keyword_completion_option(parser)
-# boolean_verbose_option(parser)
-#
-# parser.separator ""
-# parser.separator "Common options:"
-# # No argument, shows at tail. This will print an options summary.
-# # Try it and see!
-# parser.on_tail("-h", "--help", "Show this message") do
-# puts parser
-# exit
-# end
-# # Another typical switch to print the version.
-# parser.on_tail("--version", "Show version") do
-# puts Version
-# exit
-# end
-# end
-#
-# def perform_inplace_option(parser)
-# # Specifies an optional option argument
-# parser.on("-i", "--inplace [EXTENSION]",
-# "Edit ARGV files in place",
-# "(make backup if EXTENSION supplied)") do |ext|
-# self.inplace = true
-# self.extension = ext || ''
-# self.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
-# end
-# end
-#
-# def delay_execution_option(parser)
-# # Cast 'delay' argument to a Float.
-# parser.on("--delay N", Float, "Delay N seconds before executing") do |n|
-# self.delay = n
-# end
-# end
-#
-# def execute_at_time_option(parser)
-# # Cast 'time' argument to a Time object.
-# parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
-# self.time = time
-# end
-# end
-#
-# def specify_record_separator_option(parser)
-# # Cast to octal integer.
-# parser.on("-F", "--irs [OCTAL]", Gem::OptionParser::OctalInteger,
-# "Specify record separator (default \\0)") do |rs|
-# self.record_separator = rs
-# end
-# end
-#
-# def list_example_option(parser)
-# # List of arguments.
-# parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
-# self.list = list
-# end
-# end
-#
-# def specify_encoding_option(parser)
-# # Keyword completion. We are specifying a specific set of arguments (CODES
-# # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
-# # the shortest unambiguous text.
-# code_list = (CODE_ALIASES.keys + CODES).join(', ')
-# parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
-# "(#{code_list})") do |encoding|
-# self.encoding = encoding
-# end
-# end
-#
-# def optional_option_argument_with_keyword_completion_option(parser)
-# # Optional '--type' option argument with keyword completion.
-# parser.on("--type [TYPE]", [:text, :binary, :auto],
-# "Select transfer type (text, binary, auto)") do |t|
-# self.transfer_type = t
-# end
-# end
-#
-# def boolean_verbose_option(parser)
-# # Boolean switch.
-# parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
-# self.verbose = v
-# end
-# end
-# end
-#
-# #
-# # Return a structure describing the options.
-# #
-# def parse(args)
-# # The options specified on the command line will be collected in
-# # *options*.
-#
-# @options = ScriptOptions.new
-# @args = Gem::OptionParser.new do |parser|
-# @options.define_options(parser)
-# parser.parse!(args)
-# end
-# @options
-# end
-#
-# attr_reader :parser, :options
-# end # class OptparseExample
-#
-# example = OptparseExample.new
-# options = example.parse(ARGV)
-# pp options # example.options
-# pp ARGV
-#
-# === Shell Completion
-#
-# For modern shells (e.g. bash, zsh, etc.), you can use shell
-# completion for command line options.
-#
-# === Further documentation
-#
-# The above examples, along with the accompanying
-# {Tutorial}[optparse/tutorial.rdoc],
-# should be enough to learn how to use this class.
-# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
-#
-class Gem::OptionParser
- Gem::OptionParser::Version = "0.3.0"
-
- # :stopdoc:
- NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
- RequiredArgument = [REQUIRED_ARGUMENT = :REQUIRED, true].freeze
- OptionalArgument = [OPTIONAL_ARGUMENT = :OPTIONAL, false].freeze
- # :startdoc:
-
- #
- # Keyword completion module. This allows partial arguments to be specified
- # and resolved against a list of acceptable values.
- #
- module Completion
- def self.regexp(key, icase)
- Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
- end
-
- def self.candidate(key, icase = false, pat = nil, &block)
- pat ||= Completion.regexp(key, icase)
- candidates = []
- block.call do |k, *v|
- (if Regexp === k
- kn = ""
- k === key
- else
- kn = defined?(k.id2name) ? k.id2name : k
- pat === kn
- end) or next
- v << k if v.empty?
- candidates << [k, v, kn]
- end
- candidates
- end
-
- def candidate(key, icase = false, pat = nil)
- Completion.candidate(key, icase, pat, &method(:each))
- end
-
- public
- def complete(key, icase = false, pat = nil)
- candidates = candidate(key, icase, pat, &method(:each)).sort_by {|k, v, kn| kn.size}
- if candidates.size == 1
- canon, sw, * = candidates[0]
- elsif candidates.size > 1
- canon, sw, cn = candidates.shift
- candidates.each do |k, v, kn|
- next if sw == v
- if String === cn and String === kn
- if cn.rindex(kn, 0)
- canon, sw, cn = k, v, kn
- next
- elsif kn.rindex(cn, 0)
- next
- end
- end
- throw :ambiguous, key
- end
- end
- if canon
- block_given? or return key, *sw
- yield(key, *sw)
- end
- end
-
- def convert(opt = nil, val = nil, *)
- val
- end
- end
-
-
- #
- # Map from option/keyword string to object with completion.
- #
- class OptionMap < Hash
- include Completion
- end
-
-
- #
- # Individual switch class. Not important to the user.
- #
- # Defined within Switch are several Switch-derived classes: NoArgument,
- # RequiredArgument, etc.
- #
- class Switch
- attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
-
- #
- # Guesses argument style from +arg+. Returns corresponding
- # Gem::OptionParser::Switch class (OptionalArgument, etc.).
- #
- def self.guess(arg)
- case arg
- when ""
- t = self
- when /\A=?\[/
- t = Switch::OptionalArgument
- when /\A\s+\[/
- t = Switch::PlacedArgument
- else
- t = Switch::RequiredArgument
- end
- self >= t or incompatible_argument_styles(arg, t)
- t
- end
-
- def self.incompatible_argument_styles(arg, t)
- raise(ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}",
- ParseError.filter_backtrace(caller(2)))
- end
-
- def self.pattern
- NilClass
- end
-
- def initialize(pattern = nil, conv = nil,
- short = nil, long = nil, arg = nil,
- desc = ([] if short or long), block = nil, &_block)
- raise if Array === pattern
- block ||= _block
- @pattern, @conv, @short, @long, @arg, @desc, @block =
- pattern, conv, short, long, arg, desc, block
- end
-
- #
- # Parses +arg+ and returns rest of +arg+ and matched portion to the
- # argument pattern. Yields when the pattern doesn't match substring.
- #
- def parse_arg(arg) # :nodoc:
- pattern or return nil, [arg]
- unless m = pattern.match(arg)
- yield(InvalidArgument, arg)
- return arg, []
- end
- if String === m
- m = [s = m]
- else
- m = m.to_a
- s = m[0]
- return nil, m unless String === s
- end
- raise InvalidArgument, arg unless arg.rindex(s, 0)
- return nil, m if s.length == arg.length
- yield(InvalidArgument, arg) # didn't match whole arg
- return arg[s.length..-1], m
- end
- private :parse_arg
-
- #
- # Parses argument, converts and returns +arg+, +block+ and result of
- # conversion. Yields at semi-error condition instead of raising an
- # exception.
- #
- def conv_arg(arg, val = []) # :nodoc:
- if conv
- val = conv.call(*val)
- else
- val = proc {|v| v}.call(*val)
- end
- return arg, block, val
- end
- private :conv_arg
-
- #
- # Produces the summary text. Each line of the summary is yielded to the
- # block (without newline).
- #
- # +sdone+:: Already summarized short style options keyed hash.
- # +ldone+:: Already summarized long style options keyed hash.
- # +width+:: Width of left side (option part). In other words, the right
- # side (description part) starts after +width+ columns.
- # +max+:: Maximum width of left side -> the options are filled within
- # +max+ columns.
- # +indent+:: Prefix string indents all summarized lines.
- #
- def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "")
- sopts, lopts = [], [], nil
- @short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
- @long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
- return if sopts.empty? and lopts.empty? # completely hidden
-
- left = [sopts.join(', ')]
- right = desc.dup
-
- while s = lopts.shift
- l = left[-1].length + s.length
- l += arg.length if left.size == 1 && arg
- l < max or sopts.empty? or left << +''
- left[-1] << (left[-1].empty? ? ' ' * 4 : ', ') << s
- end
-
- if arg
- left[0] << (left[1] ? arg.sub(/\A(\[?)=/, '\1') + ',' : arg)
- end
- mlen = left.collect {|ss| ss.length}.max.to_i
- while mlen > width and l = left.shift
- mlen = left.collect {|ss| ss.length}.max.to_i if l.length == mlen
- if l.length < width and (r = right[0]) and !r.empty?
- l = l.to_s.ljust(width) + ' ' + r
- right.shift
- end
- yield(indent + l)
- end
-
- while begin l = left.shift; r = right.shift; l or r end
- l = l.to_s.ljust(width) + ' ' + r if r and !r.empty?
- yield(indent + l)
- end
-
- self
- end
-
- def add_banner(to) # :nodoc:
- unless @short or @long
- s = desc.join
- to << " [" + s + "]..." unless s.empty?
- end
- to
- end
-
- def match_nonswitch?(str) # :nodoc:
- @pattern =~ str unless @short or @long
- end
-
- #
- # Main name of the switch.
- #
- def switch_name
- (long.first || short.first).sub(/\A-+(?:\[no-\])?/, '')
- end
-
- def compsys(sdone, ldone) # :nodoc:
- sopts, lopts = [], []
- @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
-
- (sopts+lopts).each do |opt|
- # "(-x -c -r)-l[left justify]"
- if /^--\[no-\](.+)$/ =~ opt
- o = $1
- yield("--#{o}", desc.join(""))
- yield("--no-#{o}", desc.join(""))
- else
- yield("#{opt}", desc.join(""))
- end
- end
- end
-
- def pretty_print_contents(q) # :nodoc:
- if @block
- q.text ":" + @block.source_location.join(":") + ":"
- first = false
- else
- first = true
- end
- [@short, @long].each do |list|
- list.each do |opt|
- if first
- q.text ":"
- first = false
- end
- q.breakable
- q.text opt
- end
- end
- end
-
- def pretty_print(q) # :nodoc:
- q.object_group(self) {pretty_print_contents(q)}
- end
-
- #
- # Switch that takes no arguments.
- #
- class NoArgument < self
-
- #
- # Raises an exception if any arguments given.
- #
- def parse(arg, argv)
- yield(NeedlessArgument, arg) if arg
- conv_arg(arg)
- end
-
- def self.incompatible_argument_styles(*)
- end
-
- def self.pattern
- Object
- end
-
- def pretty_head # :nodoc:
- "NoArgument"
- end
- end
-
- #
- # Switch that takes an argument.
- #
- class RequiredArgument < self
-
- #
- # Raises an exception if argument is not present.
- #
- def parse(arg, argv)
- unless arg
- raise MissingArgument if argv.empty?
- arg = argv.shift
- end
- conv_arg(*parse_arg(arg, &method(:raise)))
- end
-
- def pretty_head # :nodoc:
- "Required"
- end
- end
-
- #
- # Switch that can omit argument.
- #
- class OptionalArgument < self
-
- #
- # Parses argument if given, or uses default value.
- #
- def parse(arg, argv, &error)
- if arg
- conv_arg(*parse_arg(arg, &error))
- else
- conv_arg(arg)
- end
- end
-
- def pretty_head # :nodoc:
- "Optional"
- end
- end
-
- #
- # Switch that takes an argument, which does not begin with '-' or is '-'.
- #
- class PlacedArgument < self
-
- #
- # Returns nil if argument is not present or begins with '-' and is not '-'.
- #
- def parse(arg, argv, &error)
- if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
- return nil, block, nil
- end
- opt = (val = parse_arg(val, &error))[1]
- val = conv_arg(*val)
- if opt and !arg
- argv.shift
- else
- val[0] = nil
- end
- val
- end
-
- def pretty_head # :nodoc:
- "Placed"
- end
- end
- end
-
- #
- # Simple option list providing mapping from short and/or long option
- # string to Gem::OptionParser::Switch and mapping from acceptable argument to
- # matching pattern and converter pair. Also provides summary feature.
- #
- class List
- # Map from acceptable argument types to pattern and converter pairs.
- attr_reader :atype
-
- # Map from short style option switches to actual switch objects.
- attr_reader :short
-
- # Map from long style option switches to actual switch objects.
- attr_reader :long
-
- # List of all switches and summary string.
- attr_reader :list
-
- #
- # Just initializes all instance variables.
- #
- def initialize
- @atype = {}
- @short = OptionMap.new
- @long = OptionMap.new
- @list = []
- end
-
- def pretty_print(q) # :nodoc:
- q.group(1, "(", ")") do
- @list.each do |sw|
- next unless Switch === sw
- q.group(1, "(" + sw.pretty_head, ")") do
- sw.pretty_print_contents(q)
- end
- end
- end
- end
-
- #
- # See Gem::OptionParser.accept.
- #
- def accept(t, pat = /.*/m, &block)
- if pat
- pat.respond_to?(:match) or
- raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
- else
- pat = t if t.respond_to?(:match)
- end
- unless block
- block = pat.method(:convert).to_proc if pat.respond_to?(:convert)
- end
- @atype[t] = [pat, block]
- end
-
- #
- # See Gem::OptionParser.reject.
- #
- def reject(t)
- @atype.delete(t)
- end
-
- #
- # Adds +sw+ according to +sopts+, +lopts+ and +nlopts+.
- #
- # +sw+:: Gem::OptionParser::Switch instance to be added.
- # +sopts+:: Short style option list.
- # +lopts+:: Long style option list.
- # +nlopts+:: Negated long style options list.
- #
- def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
- sopts.each {|o| @short[o] = sw} if sopts
- lopts.each {|o| @long[o] = sw} if lopts
- nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
- used = @short.invert.update(@long.invert)
- @list.delete_if {|o| Switch === o and !used[o]}
- end
- private :update
-
- #
- # Inserts +switch+ at the head of the list, and associates short, long
- # and negated long options. Arguments are:
- #
- # +switch+:: Gem::OptionParser::Switch instance to be inserted.
- # +short_opts+:: List of short style options.
- # +long_opts+:: List of long style options.
- # +nolong_opts+:: List of long style options with "no-" prefix.
- #
- # prepend(switch, short_opts, long_opts, nolong_opts)
- #
- def prepend(*args)
- update(*args)
- @list.unshift(args[0])
- end
-
- #
- # Appends +switch+ at the tail of the list, and associates short, long
- # and negated long options. Arguments are:
- #
- # +switch+:: Gem::OptionParser::Switch instance to be inserted.
- # +short_opts+:: List of short style options.
- # +long_opts+:: List of long style options.
- # +nolong_opts+:: List of long style options with "no-" prefix.
- #
- # append(switch, short_opts, long_opts, nolong_opts)
- #
- def append(*args)
- update(*args)
- @list.push(args[0])
- end
-
- #
- # Searches +key+ in +id+ list. The result is returned or yielded if a
- # block is given. If it isn't found, nil is returned.
- #
- def search(id, key)
- if list = __send__(id)
- val = list.fetch(key) {return nil}
- block_given? ? yield(val) : val
- end
- end
-
- #
- # Searches list +id+ for +opt+ and the optional patterns for completion
- # +pat+. If +icase+ is true, the search is case insensitive. The result
- # is returned or yielded if a block is given. If it isn't found, nil is
- # returned.
- #
- def complete(id, opt, icase = false, *pat, &block)
- __send__(id).complete(opt, icase, *pat, &block)
- end
-
- def get_candidates(id)
- yield __send__(id).keys
- end
-
- #
- # Iterates over each option, passing the option to the +block+.
- #
- def each_option(&block)
- list.each(&block)
- end
-
- #
- # Creates the summary table, passing each line to the +block+ (without
- # newline). The arguments +args+ are passed along to the summarize
- # method which is called on every option.
- #
- def summarize(*args, &block)
- sum = []
- list.reverse_each do |opt|
- if opt.respond_to?(:summarize) # perhaps Gem::OptionParser::Switch
- s = []
- opt.summarize(*args) {|l| s << l}
- sum.concat(s.reverse)
- elsif !opt or opt.empty?
- sum << ""
- elsif opt.respond_to?(:each_line)
- sum.concat([*opt.each_line].reverse)
- else
- sum.concat([*opt.each].reverse)
- end
- end
- sum.reverse_each(&block)
- end
-
- def add_banner(to) # :nodoc:
- list.each do |opt|
- if opt.respond_to?(:add_banner)
- opt.add_banner(to)
- end
- end
- to
- end
-
- def compsys(*args, &block) # :nodoc:
- list.each do |opt|
- if opt.respond_to?(:compsys)
- opt.compsys(*args, &block)
- end
- end
- end
- end
-
- #
- # Hash with completion search feature. See Gem::OptionParser::Completion.
- #
- class CompletingHash < Hash
- include Completion
-
- #
- # Completion for hash key.
- #
- def match(key)
- *values = fetch(key) {
- raise AmbiguousArgument, catch(:ambiguous) {return complete(key)}
- }
- return key, *values
- end
- end
-
- # :stopdoc:
-
- #
- # Enumeration of acceptable argument styles. Possible values are:
- #
- # NO_ARGUMENT:: The switch takes no arguments. (:NONE)
- # REQUIRED_ARGUMENT:: The switch requires an argument. (:REQUIRED)
- # OPTIONAL_ARGUMENT:: The switch requires an optional argument. (:OPTIONAL)
- #
- # Use like --switch=argument (long style) or -Xargument (short style). For
- # short style, only portion matched to argument pattern is treated as
- # argument.
- #
- ArgumentStyle = {}
- NoArgument.each {|el| ArgumentStyle[el] = Switch::NoArgument}
- RequiredArgument.each {|el| ArgumentStyle[el] = Switch::RequiredArgument}
- OptionalArgument.each {|el| ArgumentStyle[el] = Switch::OptionalArgument}
- ArgumentStyle.freeze
-
- #
- # Switches common used such as '--', and also provides default
- # argument classes
- #
- DefaultList = List.new
- DefaultList.short['-'] = Switch::NoArgument.new {}
- DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
-
-
- COMPSYS_HEADER = <<'XXX' # :nodoc:
-
-typeset -A opt_args
-local context state line
-
-_arguments -s -S \
-XXX
-
- def compsys(to, name = File.basename($0)) # :nodoc:
- to << "#compdef #{name}\n"
- to << COMPSYS_HEADER
- visit(:compsys, {}, {}) {|o, d|
- to << %Q[ "#{o}[#{d.gsub(/[\"\[\]]/, '\\\\\&')}]" \\\n]
- }
- to << " '*:file:_files' && return 0\n"
- end
-
- #
- # Default options for ARGV, which never appear in option summary.
- #
- Officious = {}
-
- #
- # --help
- # Shows option summary.
- #
- Officious['help'] = proc do |parser|
- Switch::NoArgument.new do |arg|
- puts parser.help
- exit
- end
- end
-
- #
- # --*-completion-bash=WORD
- # Shows candidates for command line completion.
- #
- Officious['*-completion-bash'] = proc do |parser|
- Switch::RequiredArgument.new do |arg|
- puts parser.candidate(arg)
- exit
- end
- end
-
- #
- # --*-completion-zsh[=NAME:FILE]
- # Creates zsh completion file.
- #
- Officious['*-completion-zsh'] = proc do |parser|
- Switch::OptionalArgument.new do |arg|
- parser.compsys(STDOUT, arg)
- exit
- end
- end
-
- #
- # --version
- # Shows version string if Version is defined.
- #
- Officious['version'] = proc do |parser|
- Switch::OptionalArgument.new do |pkg|
- if pkg
- begin
- require 'rubygems/optparse/lib/optparse/version'
- rescue LoadError
- else
- show_version(*pkg.split(/,/)) or
- abort("#{parser.program_name}: no version found in package #{pkg}")
- exit
- end
- end
- v = parser.ver or abort("#{parser.program_name}: version unknown")
- puts v
- exit
- end
- end
-
- # :startdoc:
-
- #
- # Class methods
- #
-
- #
- # Initializes a new instance and evaluates the optional block in context
- # of the instance. Arguments +args+ are passed to #new, see there for
- # description of parameters.
- #
- # This method is *deprecated*, its behavior corresponds to the older #new
- # method.
- #
- def self.with(*args, &block)
- opts = new(*args)
- opts.instance_eval(&block)
- opts
- end
-
- #
- # Returns an incremented value of +default+ according to +arg+.
- #
- def self.inc(arg, default = nil)
- case arg
- when Integer
- arg.nonzero?
- when nil
- default.to_i + 1
- end
- end
- def inc(*args)
- self.class.inc(*args)
- end
-
- #
- # Initializes the instance and yields itself if called with a block.
- #
- # +banner+:: Banner message.
- # +width+:: Summary width.
- # +indent+:: Summary indent.
- #
- def initialize(banner = nil, width = 32, indent = ' ' * 4)
- @stack = [DefaultList, List.new, List.new]
- @program_name = nil
- @banner = banner
- @summary_width = width
- @summary_indent = indent
- @default_argv = ARGV
- @require_exact = false
- @raise_unknown = true
- add_officious
- yield self if block_given?
- end
-
- def add_officious # :nodoc:
- list = base()
- Officious.each do |opt, block|
- list.long[opt] ||= block.call(self)
- end
- end
-
- #
- # Terminates option parsing. Optional parameter +arg+ is a string pushed
- # back to be the first non-option argument.
- #
- def terminate(arg = nil)
- self.class.terminate(arg)
- end
- def self.terminate(arg = nil)
- throw :terminate, arg
- end
-
- @stack = [DefaultList]
- def self.top() DefaultList end
-
- #
- # Directs to accept specified class +t+. The argument string is passed to
- # the block in which it should be converted to the desired class.
- #
- # +t+:: Argument class specifier, any object including Class.
- # +pat+:: Pattern for argument, defaults to +t+ if it responds to match.
- #
- # accept(t, pat, &block)
- #
- def accept(*args, &blk) top.accept(*args, &blk) end
- #
- # See #accept.
- #
- def self.accept(*args, &blk) top.accept(*args, &blk) end
-
- #
- # Directs to reject specified class argument.
- #
- # +t+:: Argument class specifier, any object including Class.
- #
- # reject(t)
- #
- def reject(*args, &blk) top.reject(*args, &blk) end
- #
- # See #reject.
- #
- def self.reject(*args, &blk) top.reject(*args, &blk) end
-
- #
- # Instance methods
- #
-
- # Heading banner preceding summary.
- attr_writer :banner
-
- # Program name to be emitted in error message and default banner,
- # defaults to $0.
- attr_writer :program_name
-
- # Width for option list portion of summary. Must be Numeric.
- attr_accessor :summary_width
-
- # Indentation for summary. Must be String (or have + String method).
- attr_accessor :summary_indent
-
- # Strings to be parsed in default.
- attr_accessor :default_argv
-
- # Whether to require that options match exactly (disallows providing
- # abbreviated long option as short option).
- attr_accessor :require_exact
-
- # Whether to raise at unknown option.
- attr_accessor :raise_unknown
-
- #
- # Heading banner preceding summary.
- #
- def banner
- unless @banner
- @banner = +"Usage: #{program_name} [options]"
- visit(:add_banner, @banner)
- end
- @banner
- end
-
- #
- # Program name to be emitted in error message and default banner, defaults
- # to $0.
- #
- def program_name
- @program_name || File.basename($0, '.*')
- end
-
- # for experimental cascading :-)
- alias set_banner banner=
- alias set_program_name program_name=
- alias set_summary_width summary_width=
- alias set_summary_indent summary_indent=
-
- # Version
- attr_writer :version
- # Release code
- attr_writer :release
-
- #
- # Version
- #
- def version
- (defined?(@version) && @version) || (defined?(::Version) && ::Version)
- end
-
- #
- # Release code
- #
- def release
- (defined?(@release) && @release) || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
- end
-
- #
- # Returns version string from program_name, version and release.
- #
- def ver
- if v = version
- str = +"#{program_name} #{[v].join('.')}"
- str << " (#{v})" if v = release
- str
- end
- end
-
- def warn(mesg = $!)
- super("#{program_name}: #{mesg}")
- end
-
- def abort(mesg = $!)
- super("#{program_name}: #{mesg}")
- end
-
- #
- # Subject of #on / #on_head, #accept / #reject
- #
- def top
- @stack[-1]
- end
-
- #
- # Subject of #on_tail.
- #
- def base
- @stack[1]
- end
-
- #
- # Pushes a new List.
- #
- def new
- @stack.push(List.new)
- if block_given?
- yield self
- else
- self
- end
- end
-
- #
- # Removes the last List.
- #
- def remove
- @stack.pop
- end
-
- #
- # Puts option summary into +to+ and returns +to+. Yields each line if
- # a block is given.
- #
- # +to+:: Output destination, which must have method <<. Defaults to [].
- # +width+:: Width of left side, defaults to @summary_width.
- # +max+:: Maximum length allowed for left side, defaults to +width+ - 1.
- # +indent+:: Indentation, defaults to @summary_indent.
- #
- def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
- nl = "\n"
- blk ||= proc {|l| to << (l.index(nl, -1) ? l : l + nl)}
- visit(:summarize, {}, {}, width, max, indent, &blk)
- to
- end
-
- #
- # Returns option summary string.
- #
- def help; summarize("#{banner}".sub(/\n?\z/, "\n")) end
- alias to_s help
-
- def pretty_print(q) # :nodoc:
- q.object_group(self) do
- first = true
- if @stack.size > 2
- @stack.each_with_index do |s, i|
- next if i < 2
- next if s.list.empty?
- if first
- first = false
- q.text ":"
- end
- q.breakable
- s.pretty_print(q)
- end
- end
- end
- end
-
- def inspect # :nodoc:
- require 'pp'
- pretty_print_inspect
- end
-
- #
- # Returns option summary list.
- #
- def to_a; summarize("#{banner}".split(/^/)) end
-
- #
- # Checks if an argument is given twice, in which case an ArgumentError is
- # raised. Called from Gem::OptionParser#switch only.
- #
- # +obj+:: New argument.
- # +prv+:: Previously specified argument.
- # +msg+:: Exception message.
- #
- def notwice(obj, prv, msg) # :nodoc:
- unless !prv or prv == obj
- raise(ArgumentError, "argument #{msg} given twice: #{obj}",
- ParseError.filter_backtrace(caller(2)))
- end
- obj
- end
- private :notwice
-
- SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a} # :nodoc:
-
- # :call-seq:
- # make_switch(params, block = nil)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- def make_switch(opts, block = nil)
- short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
- ldesc, sdesc, desc, arg = [], [], []
- default_style = Switch::NoArgument
- default_pattern = nil
- klass = nil
- q, a = nil
- has_arg = false
-
- opts.each do |o|
- # argument class
- next if search(:atype, o) do |pat, c|
- klass = notwice(o, klass, 'type')
- if not_style and not_style != Switch::NoArgument
- not_pattern, not_conv = pat, c
- else
- default_pattern, conv = pat, c
- end
- end
-
- # directly specified pattern(any object possible to match)
- if (!(String === o || Symbol === o)) and o.respond_to?(:match)
- pattern = notwice(o, pattern, 'pattern')
- if pattern.respond_to?(:convert)
- conv = pattern.method(:convert).to_proc
- else
- conv = SPLAT_PROC
- end
- next
- end
-
- # anything others
- case o
- when Proc, Method
- block = notwice(o, block, 'block')
- when Array, Hash
- case pattern
- when CompletingHash
- when nil
- pattern = CompletingHash.new
- conv = pattern.method(:convert).to_proc if pattern.respond_to?(:convert)
- else
- raise ArgumentError, "argument pattern given twice"
- end
- o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
- when Module
- raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4))
- when *ArgumentStyle.keys
- style = notwice(ArgumentStyle[o], style, 'style')
- when /^--no-([^\[\]=\s]*)(.+)?/
- q, a = $1, $2
- o = notwice(a ? Object : TrueClass, klass, 'type')
- not_pattern, not_conv = search(:atype, o) unless not_style
- not_style = (not_style || default_style).guess(arg = a) if a
- default_style = Switch::NoArgument
- default_pattern, conv = search(:atype, FalseClass) unless default_pattern
- ldesc << "--no-#{q}"
- (q = q.downcase).tr!('_', '-')
- long << "no-#{q}"
- nolong << q
- when /^--\[no-\]([^\[\]=\s]*)(.+)?/
- q, a = $1, $2
- o = notwice(a ? Object : TrueClass, klass, 'type')
- if a
- default_style = default_style.guess(arg = a)
- default_pattern, conv = search(:atype, o) unless default_pattern
- end
- ldesc << "--[no-]#{q}"
- (o = q.downcase).tr!('_', '-')
- long << o
- not_pattern, not_conv = search(:atype, FalseClass) unless not_style
- not_style = Switch::NoArgument
- nolong << "no-#{o}"
- when /^--([^\[\]=\s]*)(.+)?/
- q, a = $1, $2
- if a
- o = notwice(NilClass, klass, 'type')
- default_style = default_style.guess(arg = a)
- default_pattern, conv = search(:atype, o) unless default_pattern
- end
- ldesc << "--#{q}"
- (o = q.downcase).tr!('_', '-')
- long << o
- when /^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
- q, a = $1, $2
- o = notwice(Object, klass, 'type')
- if a
- default_style = default_style.guess(arg = a)
- default_pattern, conv = search(:atype, o) unless default_pattern
- else
- has_arg = true
- end
- sdesc << "-#{q}"
- short << Regexp.new(q)
- when /^-(.)(.+)?/
- q, a = $1, $2
- if a
- o = notwice(NilClass, klass, 'type')
- default_style = default_style.guess(arg = a)
- default_pattern, conv = search(:atype, o) unless default_pattern
- end
- sdesc << "-#{q}"
- short << q
- when /^=/
- style = notwice(default_style.guess(arg = o), style, 'style')
- default_pattern, conv = search(:atype, Object) unless default_pattern
- else
- desc.push(o) if o && !o.empty?
- end
- end
-
- default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
- if !(short.empty? and long.empty?)
- if has_arg and default_style == Switch::NoArgument
- default_style = Switch::RequiredArgument
- end
- s = (style || default_style).new(pattern || default_pattern,
- conv, sdesc, ldesc, arg, desc, block)
- elsif !block
- if style or pattern
- raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller)
- end
- s = desc
- else
- short << pattern
- s = (style || default_style).new(pattern,
- conv, nil, nil, arg, desc, block)
- end
- return s, short, long,
- (not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
- nolong
- end
-
- # :call-seq:
- # define(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- def define(*opts, &block)
- top.append(*(sw = make_switch(opts, block)))
- sw[0]
- end
-
- # :call-seq:
- # on(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- def on(*opts, &block)
- define(*opts, &block)
- self
- end
- alias def_option define
-
- # :call-seq:
- # define_head(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- def define_head(*opts, &block)
- top.prepend(*(sw = make_switch(opts, block)))
- sw[0]
- end
-
- # :call-seq:
- # on_head(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- # The new option is added at the head of the summary.
- #
- def on_head(*opts, &block)
- define_head(*opts, &block)
- self
- end
- alias def_head_option define_head
-
- # :call-seq:
- # define_tail(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- def define_tail(*opts, &block)
- base.append(*(sw = make_switch(opts, block)))
- sw[0]
- end
-
- #
- # :call-seq:
- # on_tail(*params, &block)
- #
- # :include: ../doc/optparse/creates_option.rdoc
- #
- # The new option is added at the tail of the summary.
- #
- def on_tail(*opts, &block)
- define_tail(*opts, &block)
- self
- end
- alias def_tail_option define_tail
-
- #
- # Add separator in summary.
- #
- def separator(string)
- top.append(string, nil, nil)
- end
-
- #
- # Parses command line arguments +argv+ in order. When a block is given,
- # each non-option argument is yielded. When optional +into+ keyword
- # argument is provided, the parsed option values are stored there via
- # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
- # similar object).
- #
- # Returns the rest of +argv+ left unparsed.
- #
- def order(*argv, into: nil, &nonopt)
- argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- order!(argv, into: into, &nonopt)
- end
-
- #
- # Same as #order, but removes switches destructively.
- # Non-option arguments remain in +argv+.
- #
- def order!(argv = default_argv, into: nil, &nonopt)
- setter = ->(name, val) {into[name.to_sym] = val} if into
- parse_in_order(argv, setter, &nonopt)
- end
-
- def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
- opt, arg, val, rest = nil
- nonopt ||= proc {|a| throw :terminate, a}
- argv.unshift(arg) if arg = catch(:terminate) {
- while arg = argv.shift
- case arg
- # long option
- when /\A--([^=]*)(?:=(.*))?/m
- opt, rest = $1, $2
- opt.tr!('_', '-')
- begin
- sw, = complete(:long, opt, true)
- if require_exact && !sw.long.include?(arg)
- throw :terminate, arg unless raise_unknown
- raise InvalidOption, arg
- end
- rescue ParseError
- throw :terminate, arg unless raise_unknown
- raise $!.set_option(arg, true)
- end
- begin
- opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
- val = cb.call(val) if cb
- setter.call(sw.switch_name, val) if setter
- rescue ParseError
- raise $!.set_option(arg, rest)
- end
-
- # short option
- when /\A-(.)((=).*|.+)?/m
- eq, rest, opt = $3, $2, $1
- has_arg, val = eq, rest
- begin
- sw, = search(:short, opt)
- unless sw
- begin
- sw, = complete(:short, opt)
- # short option matched.
- val = arg.delete_prefix('-')
- has_arg = true
- rescue InvalidOption
- raise if require_exact
- # if no short options match, try completion with long
- # options.
- sw, = complete(:long, opt)
- eq ||= !rest
- end
- end
- rescue ParseError
- throw :terminate, arg unless raise_unknown
- raise $!.set_option(arg, true)
- end
- begin
- opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
- rescue ParseError
- raise $!.set_option(arg, arg.length > 2)
- else
- raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
- end
- begin
- argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-')
- val = cb.call(val) if cb
- setter.call(sw.switch_name, val) if setter
- rescue ParseError
- raise $!.set_option(arg, arg.length > 2)
- end
-
- # non-option argument
- else
- catch(:prune) do
- visit(:each_option) do |sw0|
- sw = sw0
- sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg)
- end
- nonopt.call(arg)
- end
- end
- end
-
- nil
- }
-
- visit(:search, :short, nil) {|sw| sw.block.call(*argv) if !sw.pattern}
-
- argv
- end
- private :parse_in_order
-
- #
- # Parses command line arguments +argv+ in permutation mode and returns
- # list of non-option arguments. When optional +into+ keyword
- # argument is provided, the parsed option values are stored there via
- # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
- # similar object).
- #
- def permute(*argv, into: nil)
- argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- permute!(argv, into: into)
- end
-
- #
- # Same as #permute, but removes switches destructively.
- # Non-option arguments remain in +argv+.
- #
- def permute!(argv = default_argv, into: nil)
- nonopts = []
- order!(argv, into: into, &nonopts.method(:<<))
- argv[0, 0] = nonopts
- argv
- end
-
- #
- # Parses command line arguments +argv+ in order when environment variable
- # POSIXLY_CORRECT is set, and in permutation mode otherwise.
- # When optional +into+ keyword argument is provided, the parsed option
- # values are stored there via <code>[]=</code> method (so it can be Hash,
- # or OpenStruct, or other similar object).
- #
- def parse(*argv, into: nil)
- argv = argv[0].dup if argv.size == 1 and Array === argv[0]
- parse!(argv, into: into)
- end
-
- #
- # Same as #parse, but removes switches destructively.
- # Non-option arguments remain in +argv+.
- #
- def parse!(argv = default_argv, into: nil)
- if ENV.include?('POSIXLY_CORRECT')
- order!(argv, into: into)
- else
- permute!(argv, into: into)
- end
- end
-
- #
- # Wrapper method for getopts.rb.
- #
- # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
- # # params["a"] = true # -a
- # # params["b"] = "1" # -b1
- # # params["foo"] = "1" # --foo
- # # params["bar"] = "x" # --bar x
- # # params["zot"] = "z" # --zot Z
- #
- def getopts(*args)
- argv = Array === args.first ? args.shift : default_argv
- single_options, *long_options = *args
-
- result = {}
-
- single_options.scan(/(.)(:)?/) do |opt, val|
- if val
- result[opt] = nil
- define("-#{opt} VAL")
- else
- result[opt] = false
- define("-#{opt}")
- end
- end if single_options
-
- long_options.each do |arg|
- arg, desc = arg.split(';', 2)
- opt, val = arg.split(':', 2)
- if val
- result[opt] = val.empty? ? nil : val
- define("--#{opt}=#{result[opt] || "VAL"}", *[desc].compact)
- else
- result[opt] = false
- define("--#{opt}", *[desc].compact)
- end
- end
-
- parse_in_order(argv, result.method(:[]=))
- result
- end
-
- #
- # See #getopts.
- #
- def self.getopts(*args)
- new.getopts(*args)
- end
-
- #
- # Traverses @stack, sending each element method +id+ with +args+ and
- # +block+.
- #
- def visit(id, *args, &block) # :nodoc:
- @stack.reverse_each do |el|
- el.__send__(id, *args, &block)
- end
- nil
- end
- private :visit
-
- #
- # Searches +key+ in @stack for +id+ hash and returns or yields the result.
- #
- def search(id, key) # :nodoc:
- block_given = block_given?
- visit(:search, id, key) do |k|
- return block_given ? yield(k) : k
- end
- end
- private :search
-
- #
- # Completes shortened long style option switch and returns pair of
- # canonical switch and switch descriptor Gem::OptionParser::Switch.
- #
- # +typ+:: Searching table.
- # +opt+:: Searching key.
- # +icase+:: Search case insensitive if true.
- # +pat+:: Optional pattern for completion.
- #
- def complete(typ, opt, icase = false, *pat) # :nodoc:
- if pat.empty?
- search(typ, opt) {|sw| return [sw, opt]} # exact match or...
- end
- ambiguous = catch(:ambiguous) {
- visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
- }
- exc = ambiguous ? AmbiguousOption : InvalidOption
- raise exc.new(opt, additional: self.method(:additional_message).curry[typ])
- end
- private :complete
-
- #
- # Returns additional info.
- #
- def additional_message(typ, opt)
- return unless typ and opt and defined?(DidYouMean::SpellChecker)
- all_candidates = []
- visit(:get_candidates, typ) do |candidates|
- all_candidates.concat(candidates)
- end
- all_candidates.select! {|cand| cand.is_a?(String) }
- checker = DidYouMean::SpellChecker.new(dictionary: all_candidates)
- DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
- end
-
- def candidate(word)
- list = []
- case word
- when '-'
- long = short = true
- when /\A--/
- word, arg = word.split(/=/, 2)
- argpat = Completion.regexp(arg, false) if arg and !arg.empty?
- long = true
- when /\A-/
- short = true
- end
- pat = Completion.regexp(word, long)
- visit(:each_option) do |opt|
- next unless Switch === opt
- opts = (long ? opt.long : []) + (short ? opt.short : [])
- opts = Completion.candidate(word, true, pat, &opts.method(:each)).map(&:first) if pat
- if /\A=/ =~ opt.arg
- opts.map! {|sw| sw + "="}
- if arg and CompletingHash === opt.pattern
- if opts = opt.pattern.candidate(arg, false, argpat)
- opts.map!(&:last)
- end
- end
- end
- list.concat(opts)
- end
- list
- end
-
- #
- # Loads options from file names as +filename+. Does nothing when the file
- # is not present. Returns whether successfully loaded.
- #
- # +filename+ defaults to basename of the program without suffix in a
- # directory ~/.options, then the basename with '.options' suffix
- # under XDG and Haiku standard places.
- #
- # The optional +into+ keyword argument works exactly like that accepted in
- # method #parse.
- #
- def load(filename = nil, into: nil)
- unless filename
- basename = File.basename($0, '.*')
- return true if load(File.expand_path(basename, '~/.options'), into: into) rescue nil
- basename << ".options"
- return [
- # XDG
- ENV['XDG_CONFIG_HOME'],
- '~/.config',
- *ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR),
-
- # Haiku
- '~/config/settings',
- ].any? {|dir|
- next if !dir or dir.empty?
- load(File.expand_path(basename, dir), into: into) rescue nil
- }
- end
- begin
- parse(*File.readlines(filename, chomp: true), into: into)
- true
- rescue Errno::ENOENT, Errno::ENOTDIR
- false
- end
- end
-
- #
- # Parses environment variable +env+ or its uppercase with splitting like a
- # shell.
- #
- # +env+ defaults to the basename of the program.
- #
- def environment(env = File.basename($0, '.*'))
- env = ENV[env] || ENV[env.upcase] or return
- require 'shellwords'
- parse(*Shellwords.shellwords(env))
- end
-
- #
- # Acceptable argument classes
- #
-
- #
- # Any string and no conversion. This is fall-back.
- #
- accept(Object) {|s,|s or s.nil?}
-
- accept(NilClass) {|s,|s}
-
- #
- # Any non-empty string, and no conversion.
- #
- accept(String, /.+/m) {|s,*|s}
-
- #
- # Ruby/C-like integer, octal for 0-7 sequence, binary for 0b, hexadecimal
- # for 0x, and decimal for others; with optional sign prefix. Converts to
- # Integer.
- #
- decimal = '\d+(?:_\d+)*'
- binary = 'b[01]+(?:_[01]+)*'
- hex = 'x[\da-f]+(?:_[\da-f]+)*'
- octal = "0(?:[0-7]+(?:_[0-7]+)*|#{binary}|#{hex})?"
- integer = "#{octal}|#{decimal}"
-
- accept(Integer, %r"\A[-+]?(?:#{integer})\z"io) {|s,|
- begin
- Integer(s)
- rescue ArgumentError
- raise Gem::OptionParser::InvalidArgument, s
- end if s
- }
-
- #
- # Float number format, and converts to Float.
- #
- float = "(?:#{decimal}(?=(.)?)(?:\\.(?:#{decimal})?)?|\\.#{decimal})(?:E[-+]?#{decimal})?"
- floatpat = %r"\A[-+]?#{float}\z"io
- accept(Float, floatpat) {|s,| s.to_f if s}
-
- #
- # Generic numeric format, converts to Integer for integer format, Float
- # for float format, and Rational for rational format.
- #
- real = "[-+]?(?:#{octal}|#{float})"
- accept(Numeric, /\A(#{real})(?:\/(#{real}))?\z/io) {|s, d, f, n,|
- if n
- Rational(d, n)
- elsif f
- Float(s)
- else
- Integer(s)
- end
- }
-
- #
- # Decimal integer format, to be converted to Integer.
- #
- DecimalInteger = /\A[-+]?#{decimal}\z/io
- accept(DecimalInteger, DecimalInteger) {|s,|
- begin
- Integer(s, 10)
- rescue ArgumentError
- raise Gem::OptionParser::InvalidArgument, s
- end if s
- }
-
- #
- # Ruby/C like octal/hexadecimal/binary integer format, to be converted to
- # Integer.
- #
- OctalInteger = /\A[-+]?(?:[0-7]+(?:_[0-7]+)*|0(?:#{binary}|#{hex}))\z/io
- accept(OctalInteger, OctalInteger) {|s,|
- begin
- Integer(s, 8)
- rescue ArgumentError
- raise Gem::OptionParser::InvalidArgument, s
- end if s
- }
-
- #
- # Decimal integer/float number format, to be converted to Integer for
- # integer format, Float for float format.
- #
- DecimalNumeric = floatpat # decimal integer is allowed as float also.
- accept(DecimalNumeric, floatpat) {|s, f|
- begin
- if f
- Float(s)
- else
- Integer(s)
- end
- rescue ArgumentError
- raise Gem::OptionParser::InvalidArgument, s
- end if s
- }
-
- #
- # Boolean switch, which means whether it is present or not, whether it is
- # absent or not with prefix no-, or it takes an argument
- # yes/no/true/false/+/-.
- #
- yesno = CompletingHash.new
- %w[- no false].each {|el| yesno[el] = false}
- %w[+ yes true].each {|el| yesno[el] = true}
- yesno['nil'] = false # should be nil?
- accept(TrueClass, yesno) {|arg, val| val == nil or val}
- #
- # Similar to TrueClass, but defaults to false.
- #
- accept(FalseClass, yesno) {|arg, val| val != nil and val}
-
- #
- # List of strings separated by ",".
- #
- accept(Array) do |s, |
- if s
- s = s.split(',').collect {|ss| ss unless ss.empty?}
- end
- s
- end
-
- #
- # Regular expression with options.
- #
- accept(Regexp, %r"\A/((?:\\.|[^\\])*)/([[:alpha:]]+)?\z|.*") do |all, s, o|
- f = 0
- if o
- f |= Regexp::IGNORECASE if /i/ =~ o
- f |= Regexp::MULTILINE if /m/ =~ o
- f |= Regexp::EXTENDED if /x/ =~ o
- k = o.delete("imx")
- k = nil if k.empty?
- end
- Regexp.new(s || all, f, k)
- end
-
- #
- # Exceptions
- #
-
- #
- # Base class of exceptions from Gem::OptionParser.
- #
- class ParseError < RuntimeError
- # Reason which caused the error.
- Reason = 'parse error'
-
- def initialize(*args, additional: nil)
- @additional = additional
- @arg0, = args
- @args = args
- @reason = nil
- end
-
- attr_reader :args
- attr_writer :reason
- attr_accessor :additional
-
- #
- # Pushes back erred argument(s) to +argv+.
- #
- def recover(argv)
- argv[0, 0] = @args
- argv
- end
-
- def self.filter_backtrace(array)
- unless $DEBUG
- array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
- end
- array
- end
-
- def set_backtrace(array)
- super(self.class.filter_backtrace(array))
- end
-
- def set_option(opt, eq)
- if eq
- @args[0] = opt
- else
- @args.unshift(opt)
- end
- self
- end
-
- #
- # Returns error reason. Override this for I18N.
- #
- def reason
- @reason || self.class::Reason
- end
-
- def inspect
- "#<#{self.class}: #{args.join(' ')}>"
- end
-
- #
- # Default stringizing method to emit standard error message.
- #
- def message
- "#{reason}: #{args.join(' ')}#{additional[@arg0] if additional}"
- end
-
- alias to_s message
- end
-
- #
- # Raises when ambiguously completable string is encountered.
- #
- class AmbiguousOption < ParseError
- const_set(:Reason, 'ambiguous option')
- end
-
- #
- # Raises when there is an argument for a switch which takes no argument.
- #
- class NeedlessArgument < ParseError
- const_set(:Reason, 'needless argument')
- end
-
- #
- # Raises when a switch with mandatory argument has no argument.
- #
- class MissingArgument < ParseError
- const_set(:Reason, 'missing argument')
- end
-
- #
- # Raises when switch is undefined.
- #
- class InvalidOption < ParseError
- const_set(:Reason, 'invalid option')
- end
-
- #
- # Raises when the given argument does not match required format.
- #
- class InvalidArgument < ParseError
- const_set(:Reason, 'invalid argument')
- end
-
- #
- # Raises when the given argument word can't be completed uniquely.
- #
- class AmbiguousArgument < InvalidArgument
- const_set(:Reason, 'ambiguous argument')
- end
-
- #
- # Miscellaneous
- #
-
- #
- # Extends command line arguments array (ARGV) to parse itself.
- #
- module Arguable
-
- #
- # Sets Gem::OptionParser object, when +opt+ is +false+ or +nil+, methods
- # Gem::OptionParser::Arguable#options and Gem::OptionParser::Arguable#options= are
- # undefined. Thus, there is no ways to access the Gem::OptionParser object
- # via the receiver object.
- #
- def options=(opt)
- unless @optparse = opt
- class << self
- undef_method(:options)
- undef_method(:options=)
- end
- end
- end
-
- #
- # Actual Gem::OptionParser object, automatically created if nonexistent.
- #
- # If called with a block, yields the Gem::OptionParser object and returns the
- # result of the block. If an Gem::OptionParser::ParseError exception occurs
- # in the block, it is rescued, a error message printed to STDERR and
- # +nil+ returned.
- #
- def options
- @optparse ||= Gem::OptionParser.new
- @optparse.default_argv = self
- block_given? or return @optparse
- begin
- yield @optparse
- rescue ParseError
- @optparse.warn $!
- nil
- end
- end
-
- #
- # Parses +self+ destructively in order and returns +self+ containing the
- # rest arguments left unparsed.
- #
- def order!(&blk) options.order!(self, &blk) end
-
- #
- # Parses +self+ destructively in permutation mode and returns +self+
- # containing the rest arguments left unparsed.
- #
- def permute!() options.permute!(self) end
-
- #
- # Parses +self+ destructively and returns +self+ containing the
- # rest arguments left unparsed.
- #
- def parse!() options.parse!(self) end
-
- #
- # Substitution of getopts is possible as follows. Also see
- # Gem::OptionParser#getopts.
- #
- # def getopts(*args)
- # ($OPT = ARGV.getopts(*args)).each do |opt, val|
- # eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val"
- # end
- # rescue Gem::OptionParser::ParseError
- # end
- #
- def getopts(*args)
- options.getopts(self, *args)
- end
-
- #
- # Initializes instance variable.
- #
- def self.extend_object(obj)
- super
- obj.instance_eval {@optparse = nil}
- end
- def initialize(*args)
- super
- @optparse = nil
- end
- end
-
- #
- # Acceptable argument classes. Now contains DecimalInteger, OctalInteger
- # and DecimalNumeric. See Acceptable argument classes (in source code).
- #
- module Acceptables
- const_set(:DecimalInteger, Gem::OptionParser::DecimalInteger)
- const_set(:OctalInteger, Gem::OptionParser::OctalInteger)
- const_set(:DecimalNumeric, Gem::OptionParser::DecimalNumeric)
- end
-end
-
-# ARGV is arguable by Gem::OptionParser
-ARGV.extend(Gem::OptionParser::Arguable)
diff --git a/lib/rubygems/optparse/lib/optparse/ac.rb b/lib/rubygems/optparse/lib/optparse/ac.rb
deleted file mode 100644
index e84d01bf91..0000000000
--- a/lib/rubygems/optparse/lib/optparse/ac.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# frozen_string_literal: false
-require_relative '../optparse'
-
-class Gem::OptionParser::AC < Gem::OptionParser
- private
-
- def _check_ac_args(name, block)
- unless /\A\w[-\w]*\z/ =~ name
- raise ArgumentError, name
- end
- unless block
- raise ArgumentError, "no block given", ParseError.filter_backtrace(caller)
- end
- end
-
- ARG_CONV = proc {|val| val.nil? ? true : val}
-
- def _ac_arg_enable(prefix, name, help_string, block)
- _check_ac_args(name, block)
-
- sdesc = []
- ldesc = ["--#{prefix}-#{name}"]
- desc = [help_string]
- q = name.downcase
- ac_block = proc {|val| block.call(ARG_CONV.call(val))}
- enable = Switch::PlacedArgument.new(nil, ARG_CONV, sdesc, ldesc, nil, desc, ac_block)
- disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, ac_block)
- top.append(enable, [], ["enable-" + q], disable, ['disable-' + q])
- enable
- end
-
- public
-
- def ac_arg_enable(name, help_string, &block)
- _ac_arg_enable("enable", name, help_string, block)
- end
-
- def ac_arg_disable(name, help_string, &block)
- _ac_arg_enable("disable", name, help_string, block)
- end
-
- def ac_arg_with(name, help_string, &block)
- _check_ac_args(name, block)
-
- sdesc = []
- ldesc = ["--with-#{name}"]
- desc = [help_string]
- q = name.downcase
- with = Switch::PlacedArgument.new(*search(:atype, String), sdesc, ldesc, nil, desc, block)
- without = Switch::NoArgument.new(nil, proc {}, sdesc, ldesc, nil, desc, block)
- top.append(with, [], ["with-" + q], without, ['without-' + q])
- with
- end
-end
diff --git a/lib/rubygems/optparse/lib/optparse/kwargs.rb b/lib/rubygems/optparse/lib/optparse/kwargs.rb
deleted file mode 100644
index 6987a5ed62..0000000000
--- a/lib/rubygems/optparse/lib/optparse/kwargs.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-require_relative '../optparse'
-
-class Gem::OptionParser
- # :call-seq:
- # define_by_keywords(options, method, **params)
- #
- # :include: ../../doc/optparse/creates_option.rdoc
- #
- def define_by_keywords(options, meth, **opts)
- meth.parameters.each do |type, name|
- case type
- when :key, :keyreq
- op, cl = *(type == :key ? %w"[ ]" : ["", ""])
- define("--#{name}=#{op}#{name.upcase}#{cl}", *opts[name]) do |o|
- options[name] = o
- end
- end
- end
- options
- end
-end
diff --git a/lib/rubygems/optparse/lib/optparse/uri.rb b/lib/rubygems/optparse/lib/optparse/uri.rb
deleted file mode 100644
index 664d7f2af4..0000000000
--- a/lib/rubygems/optparse/lib/optparse/uri.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: false
-# -*- ruby -*-
-
-require_relative '../optparse'
-require 'uri'
-
-Gem::OptionParser.accept(URI) {|s,| URI.parse(s) if s}
diff --git a/lib/rubygems/optparse/lib/optparse/version.rb b/lib/rubygems/optparse/lib/optparse/version.rb
deleted file mode 100644
index 5d79e9db44..0000000000
--- a/lib/rubygems/optparse/lib/optparse/version.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-# frozen_string_literal: false
-# Gem::OptionParser internal utility
-
-class << Gem::OptionParser
- def show_version(*pkgs)
- progname = ARGV.options.program_name
- result = false
- show = proc do |klass, cname, version|
- str = "#{progname}"
- unless klass == ::Object and cname == :VERSION
- version = version.join(".") if Array === version
- str << ": #{klass}" unless klass == Object
- str << " version #{version}"
- end
- [:Release, :RELEASE].find do |rel|
- if klass.const_defined?(rel)
- str << " (#{klass.const_get(rel)})"
- end
- end
- puts str
- result = true
- end
- if pkgs.size == 1 and pkgs[0] == "all"
- self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
- unless cname[1] == ?e and klass.const_defined?(:Version)
- show.call(klass, cname.intern, version)
- end
- end
- else
- pkgs.each do |pkg|
- begin
- pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
- v = case
- when pkg.const_defined?(:Version)
- pkg.const_get(n = :Version)
- when pkg.const_defined?(:VERSION)
- pkg.const_get(n = :VERSION)
- else
- n = nil
- "unknown"
- end
- show.call(pkg, n, v)
- rescue NameError
- end
- end
- end
- result
- end
-
- def each_const(path, base = ::Object)
- path.split(/::|\//).inject(base) do |klass, name|
- raise NameError, path unless Module === klass
- klass.constants.grep(/#{name}/i) do |c|
- klass.const_defined?(c) or next
- klass.const_get(c)
- end
- end
- end
-
- def search_const(klass, name)
- klasses = [klass]
- while klass = klasses.shift
- klass.constants.each do |cname|
- klass.const_defined?(cname) or next
- const = klass.const_get(cname)
- yield klass, cname, const if name === cname
- klasses << const if Module === const and const != ::Object
- end
- end
- end
-end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 67b6d386ef..7e41b18f66 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -1,10 +1,13 @@
# frozen_string_literal: true
-#--
+
+# rubocop:disable Style/AsciiComments
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
-#++
-require_relative "../rubygems"
+# rubocop:enable Style/AsciiComments
+
+require_relative "win_platform"
require_relative "security"
require_relative "user_interaction"
@@ -56,9 +59,9 @@ class Gem::Package
def initialize(message, source = nil)
if source
- @path = source.path
+ @path = source.is_a?(String) ? source : source.path
- message = message + " in #{path}" if path
+ message += " in #{path}" if path
end
super message
@@ -67,15 +70,13 @@ class Gem::Package
class PathError < Error
def initialize(destination, destination_dir)
- super "installing into parent path %s of %s is not allowed" %
- [destination, destination_dir]
+ super format("installing into parent path %s of %s is not allowed", destination, destination_dir)
end
end
class SymlinkError < Error
def initialize(name, destination, destination_dir)
- super "installing symlink '%s' pointing to parent path %s of %s is not allowed" %
- [name, destination, destination_dir]
+ super format("installing symlink '%s' pointing to parent path %s of %s is not allowed", name, destination, destination_dir)
end
end
@@ -154,7 +155,7 @@ class Gem::Package
Gem::Package::FileSource.new gem
end
- return super unless Gem::Package == self
+ return super unless self == Gem::Package
return super unless gem.present?
return super unless gem.start
@@ -186,7 +187,7 @@ class Gem::Package
end
end
- return spec, metadata
+ [spec, metadata]
end
##
@@ -229,9 +230,13 @@ class Gem::Package
end
end
- tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io|
+ tar.add_file_signed "checksums.yaml.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
- Psych.dump checksums_by_algorithm, gz_io
+ if Gem.use_psych?
+ Psych.dump checksums_by_algorithm, gz_io
+ else
+ gz_io.write Gem::YAMLSerializer.dump(checksums_by_algorithm)
+ end
end
end
end
@@ -241,7 +246,7 @@ class Gem::Package
# and adds this file to the +tar+.
def add_contents(tar) # :nodoc:
- digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io|
+ digests = tar.add_file_signed "data.tar.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
Gem::Package::TarWriter.new gz_io do |data_tar|
add_files data_tar
@@ -267,7 +272,7 @@ class Gem::Package
tar.add_file_simple file, stat.mode, stat.size do |dst_io|
File.open file, "rb" do |src_io|
- dst_io.write src_io.read 16_384 until src_io.eof?
+ copy_stream(src_io, dst_io, stat.size)
end
end
end
@@ -277,7 +282,7 @@ class Gem::Package
# Adds the package's Gem::Specification to the +tar+ file
def add_metadata(tar) # :nodoc:
- digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io|
+ digests = tar.add_file_signed "metadata.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
gz_io.write @spec.to_yaml
end
@@ -294,7 +299,6 @@ class Gem::Package
Gem.load_yaml
- @spec.mark_version
@spec.validate true, strict_validation unless skip_validation
setup_signer(
@@ -346,6 +350,8 @@ EOM
return @contents
end
end
+ rescue Zlib::GzipFile::Error, EOFError, Gem::Package::TarInvalidError => e
+ raise Gem::Package::FormatError.new e.message, @gem
end
##
@@ -354,18 +360,21 @@ EOM
def digest(entry) # :nodoc:
algorithms = if @checksums
- @checksums.keys
- else
- [Gem::Security::DIGEST_NAME].compact
+ @checksums.to_h {|algorithm, _| [algorithm, Gem::Security.create_digest(algorithm)] }
+ elsif Gem::Security::DIGEST_NAME
+ { Gem::Security::DIGEST_NAME => Gem::Security.create_digest(Gem::Security::DIGEST_NAME) }
end
- algorithms.each do |algorithm|
- digester = Gem::Security.create_digest(algorithm)
-
- digester << entry.read(16_384) until entry.eof?
+ return @digests if algorithms.nil? || algorithms.empty?
- entry.rewind
+ buf = String.new(capacity: 16_384, encoding: Encoding::BINARY)
+ until entry.eof?
+ entry.readpartial(16_384, buf)
+ algorithms.each_value {|digester| digester << buf }
+ end
+ entry.rewind
+ algorithms.each do |algorithm, digester|
@digests[algorithm][entry.full_name] = digester
end
@@ -381,7 +390,7 @@ EOM
def extract_files(destination_dir, pattern = "*")
verify unless @spec
- FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p destination_dir, mode: dir_mode && 0o755
@gem.with_read_io do |io|
reader = Gem::Package::TarReader.new io
@@ -391,9 +400,11 @@ EOM
extract_tar_gz entry, destination_dir, pattern
- return # ignore further entries
+ break # ignore further entries
end
end
+ rescue Zlib::GzipFile::Error, EOFError, Gem::Package::TarInvalidError => e
+ raise Gem::Package::FormatError.new e.message, @gem
end
##
@@ -408,6 +419,8 @@ EOM
# extracted.
def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
+ destination_dir = File.realpath(destination_dir)
+
directories = []
symlinks = []
@@ -428,10 +441,6 @@ EOM
symlinks << [full_name, link_target, destination, real_destination]
end
- FileUtils.rm_rf destination
-
- mkdir_options = {}
- mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
mkdir =
if entry.directory?
destination
@@ -440,13 +449,24 @@ EOM
end
unless directories.include?(mkdir)
- FileUtils.mkdir_p mkdir, **mkdir_options
+ FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
directories << mkdir
end
+ real_mkdir = File.realpath(mkdir)
+ unless real_mkdir == destination_dir || normalize_path(real_mkdir).start_with?(normalize_path(destination_dir + "/"))
+ raise Gem::Package::PathError.new(real_mkdir, destination_dir)
+ end
+
if entry.file?
- File.open(destination, "wb") {|out| out.write entry.read }
- FileUtils.chmod file_mode(entry.header.mode), destination
+ File.open(destination, "wb") do |out|
+ copy_stream(tar.io, out, entry.size)
+ # Flush needs to happen before chmod because there could be data
+ # in the IO buffer that needs to be written, and that could be
+ # written after the chmod (on close) which would mess up the perms
+ out.flush
+ out.chmod file_mode(entry.header.mode) & ~File.umask
+ end
end
verbose destination
@@ -455,7 +475,7 @@ EOM
symlinks.each do |name, target, destination, real_destination|
if File.exist?(real_destination)
- File.symlink(target, destination)
+ create_symlink(target, destination)
else
alert_warning "#{@spec.full_name} ships with a dangling symlink named #{name} pointing to missing #{target} file. Ignoring"
end
@@ -467,7 +487,7 @@ EOM
end
def file_mode(mode) # :nodoc:
- ((mode & 0111).zero? ? data_mode : prog_mode) ||
+ ((mode & 0o111).zero? ? data_mode : prog_mode) ||
# If we're not using one of the default modes, then we're going to fall
# back to the mode from the tarball. In this case we need to mask it down
# to fit into 2^16 bits (the maximum value for a mode in CRuby since it
@@ -505,14 +525,15 @@ EOM
raise Gem::Package::PathError.new(destination, destination_dir) unless
normalize_path(destination).start_with? normalize_path(destination_dir + "/")
- destination.tap(&Gem::UNTAINT)
destination
end
- def normalize_path(pathname)
- if Gem.win_platform?
+ if Gem.win_platform?
+ def normalize_path(pathname) # :nodoc:
pathname.downcase
- else
+ end
+ else
+ def normalize_path(pathname) # :nodoc:
pathname
end
end
@@ -520,13 +541,14 @@ EOM
##
# Loads a Gem::Specification from the TarEntry +entry+
- def load_spec(entry) # :nodoc:
+ def load_spec_from_metadata(entry) # :nodoc:
+ limit = 10 * 1024 * 1024
case entry.full_name
when "metadata" then
- @spec = Gem::Specification.from_yaml entry.read
+ @spec = Gem::Specification.from_yaml limit_read(entry, "metadata", limit)
when "metadata.gz" then
Zlib::GzipReader.wrap(entry, external_encoding: Encoding::UTF_8) do |gzio|
- @spec = Gem::Specification.from_yaml gzio.read
+ @spec = Gem::Specification.from_yaml limit_read(gzio, "metadata.gz", limit)
end
end
end
@@ -539,6 +561,15 @@ EOM
tar = Gem::Package::TarReader.new gzio
yield tar
+ ensure
+ # Consume remaining gzip data to prevent the
+ # "attempt to close unfinished zstream; reset forced" warning
+ # when the GzipReader is closed with unconsumed compressed data.
+ begin
+ IO.copy_stream(gzio, IO::NULL)
+ rescue Zlib::GzipFile::Error, IOError
+ nil
+ end
end
end
@@ -550,7 +581,7 @@ EOM
@checksums = gem.seek "checksums.yaml.gz" do |entry|
Zlib::GzipReader.wrap entry do |gz_io|
- Gem::SafeYAML.safe_load gz_io.read
+ Gem::SafeYAML.safe_load limit_read(gz_io, "checksums.yaml.gz", 10 * 1024 * 1024)
end
end
end
@@ -571,10 +602,10 @@ EOM
)
@spec.signing_key = nil
- @spec.cert_chain = @signer.cert_chain.map {|cert| cert.to_s }
+ @spec.cert_chain = @signer.cert_chain.map(&:to_s)
else
@signer = Gem::Security::Signer.new nil, nil, passphrase
- @spec.cert_chain = @signer.cert_chain.map {|cert| cert.to_pem } if
+ @spec.cert_chain = @signer.cert_chain.map(&:to_pem) if
@signer.cert_chain
end
end
@@ -625,10 +656,12 @@ EOM
raise
rescue Errno::ENOENT => e
raise Gem::Package::FormatError.new e.message
- rescue Gem::Package::TarInvalidError => e
+ rescue Zlib::GzipFile::Error, EOFError, Gem::Package::TarInvalidError => e
raise Gem::Package::FormatError.new e.message, @gem
end
+ private
+
##
# Verifies the +checksums+ against the +digests+. This check is not
# cryptographically secure. Missing checksums are ignored.
@@ -657,19 +690,14 @@ EOM
case file_name
when /\.sig$/ then
- @signatures[$`] = entry.read if @security_policy
+ @signatures[$`] = limit_read(entry, file_name, 1024 * 1024) if @security_policy
return
else
digest entry
end
- case file_name
- when "metadata", "metadata.gz" then
- load_spec entry
- when "data.tar.gz" then
- verify_gz entry
- end
- rescue
+ load_spec_from_metadata entry
+ rescue StandardError
warn "Exception while verifying #{@gem.path}"
raise
end
@@ -696,15 +724,37 @@ EOM
end
end
- ##
- # Verifies that +entry+ is a valid gzipped file.
+ if RUBY_ENGINE == "truffleruby"
+ def copy_stream(src, dst, size) # :nodoc:
+ dst.write src.read(size)
+ end
+ else
+ def copy_stream(src, dst, size) # :nodoc:
+ IO.copy_stream(src, dst, size)
+ end
+ end
+
+ def limit_read(io, name, limit)
+ bytes = io.read(limit + 1)
+ raise Gem::Package::FormatError, "#{name} is too big (over #{limit} bytes)" if bytes.size > limit
+ bytes
+ end
- def verify_gz(entry) # :nodoc:
- Zlib::GzipReader.wrap entry do |gzio|
- gzio.read 16_384 until gzio.eof? # gzip checksum verification
+ if Gem.win_platform?
+ # Create a symlink and fallback to copy the file or directory on Windows,
+ # where symlink creation needs special privileges in form of the Developer Mode.
+ # JRuby on Windows raises TypeError from the wincode path-conversion helper
+ # when it cannot create the symlink, so fall back to copy in that case too.
+ def create_symlink(old_name, new_name)
+ File.symlink(old_name, new_name)
+ rescue Errno::EACCES, TypeError
+ from = File.expand_path(old_name, File.dirname(new_name))
+ FileUtils.cp_r(from, new_name)
+ end
+ else
+ def create_symlink(old_name, new_name)
+ File.symlink(old_name, new_name)
end
- rescue Zlib::GzipFile::Error => e
- raise Gem::Package::FormatError.new(e.message, entry.full_name)
end
end
diff --git a/lib/rubygems/package/digest_io.rb b/lib/rubygems/package/digest_io.rb
index 4736f76d93..f04ab97462 100644
--- a/lib/rubygems/package/digest_io.rb
+++ b/lib/rubygems/package/digest_io.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# IO wrapper that creates digests of contents written to the IO it wraps.
@@ -35,7 +36,7 @@ class Gem::Package::DigestIO
yield digest_io
- return digests
+ digests
end
##
diff --git a/lib/rubygems/package/file_source.rb b/lib/rubygems/package/file_source.rb
index 14c7a9f6d2..d9717e0f2a 100644
--- a/lib/rubygems/package/file_source.rb
+++ b/lib/rubygems/package/file_source.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The primary source of gems is a file on disk, including all usages
# internal to rubygems.
diff --git a/lib/rubygems/package/io_source.rb b/lib/rubygems/package/io_source.rb
index 03d7714524..227835dfce 100644
--- a/lib/rubygems/package/io_source.rb
+++ b/lib/rubygems/package/io_source.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Supports reading and writing gems from/to a generic IO object. This is
# useful for other applications built on top of rubygems, such as
diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb
index 09a02d3ecd..1a13ac3e29 100644
--- a/lib/rubygems/package/old.rb
+++ b/lib/rubygems/package/old.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -69,7 +70,7 @@ class Gem::Package::Old < Gem::Package
file_data << line
end
- file_data = file_data.strip.unpack("m")[0]
+ file_data = file_data.strip.unpack1("m")
file_data = Zlib::Inflate.inflate file_data
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if
@@ -77,7 +78,7 @@ class Gem::Package::Old < Gem::Package
FileUtils.rm_rf destination
- FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
+ FileUtils.mkdir_p File.dirname(destination), mode: dir_mode && 0o755
File.open destination, "wb", file_mode(entry["mode"]) do |out|
out.write file_data
diff --git a/lib/rubygems/package/source.rb b/lib/rubygems/package/source.rb
index 69701e55e9..8c44f8c305 100644
--- a/lib/rubygems/package/source.rb
+++ b/lib/rubygems/package/source.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
+
class Gem::Package::Source # :nodoc:
end
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index a66ce8a68e..dd20d65080 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
-#--
+
+# rubocop:disable Style/AsciiComments
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
-#++
+
+# rubocop:enable Style/AsciiComments
##
#--
@@ -53,7 +56,7 @@ class Gem::Package::TarHeader
##
# Pack format for a tar header
- PACK_FORMAT = "a100" + # name
+ PACK_FORMAT = ("a100" + # name
"a8" + # mode
"a8" + # uid
"a8" + # gid
@@ -68,12 +71,12 @@ class Gem::Package::TarHeader
"a32" + # gname
"a8" + # devmajor
"a8" + # devminor
- "a155" # prefix
+ "a155").freeze # prefix
##
# Unpack format for a tar header
- UNPACK_FORMAT = "A100" + # name
+ UNPACK_FORMAT = ("A100" + # name
"A8" + # mode
"A8" + # uid
"A8" + # gid
@@ -88,43 +91,44 @@ class Gem::Package::TarHeader
"A32" + # gname
"A8" + # devmajor
"A8" + # devminor
- "A155" # prefix
+ "A155").freeze # prefix
attr_reader(*FIELDS)
- EMPTY_HEADER = ("\0" * 512).freeze # :nodoc:
+ EMPTY_HEADER = ("\0" * 512).b.freeze # :nodoc:
##
# Creates a tar header from IO +stream+
def self.from(stream)
header = stream.read 512
- empty = (EMPTY_HEADER == header)
+ return EMPTY if header == EMPTY_HEADER
fields = header.unpack UNPACK_FORMAT
- new :name => fields.shift,
- :mode => strict_oct(fields.shift),
- :uid => oct_or_256based(fields.shift),
- :gid => oct_or_256based(fields.shift),
- :size => strict_oct(fields.shift),
- :mtime => strict_oct(fields.shift),
- :checksum => strict_oct(fields.shift),
- :typeflag => fields.shift,
- :linkname => fields.shift,
- :magic => fields.shift,
- :version => strict_oct(fields.shift),
- :uname => fields.shift,
- :gname => fields.shift,
- :devmajor => strict_oct(fields.shift),
- :devminor => strict_oct(fields.shift),
- :prefix => fields.shift,
-
- :empty => empty
+ new name: fields.shift,
+ mode: strict_oct(fields.shift),
+ uid: oct_or_256based(fields.shift),
+ gid: oct_or_256based(fields.shift),
+ size: strict_oct(fields.shift),
+ mtime: strict_oct(fields.shift),
+ checksum: strict_oct(fields.shift),
+ typeflag: fields.shift,
+ linkname: fields.shift,
+ magic: fields.shift,
+ version: strict_oct(fields.shift),
+ uname: fields.shift,
+ gname: fields.shift,
+ devmajor: strict_oct(fields.shift),
+ devminor: strict_oct(fields.shift),
+ prefix: fields.shift,
+
+ empty: false
end
def self.strict_oct(str)
- return str.strip.oct if str.strip =~ /\A[0-7]*\z/
+ str.strip!
+ return str.oct if /\A[0-7]*\z/.match?(str)
raise ArgumentError, "#{str.inspect} is not an octal string"
end
@@ -134,7 +138,8 @@ class Gem::Package::TarHeader
# \ff flags a negative 256-based number
# In case we have a match, parse it as a signed binary value
# in big-endian order, except that the high-order bit is ignored.
- return str.unpack("N2").last if str =~ /\A[\x80\xff]/n
+
+ return str.unpack1("@4N") if /\A[\x80\xff]/n.match?(str)
strict_oct(str)
end
@@ -146,25 +151,43 @@ class Gem::Package::TarHeader
raise ArgumentError, ":name, :size, :prefix and :mode required"
end
- vals[:uid] ||= 0
- vals[:gid] ||= 0
- vals[:mtime] ||= 0
- vals[:checksum] ||= ""
- vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty?
- vals[:magic] ||= "ustar"
- vals[:version] ||= "00"
- vals[:uname] ||= "wheel"
- vals[:gname] ||= "wheel"
- vals[:devmajor] ||= 0
- vals[:devminor] ||= 0
-
- FIELDS.each do |name|
- instance_variable_set "@#{name}", vals[name]
- end
+ @checksum = vals[:checksum] || ""
+ @devmajor = vals[:devmajor] || 0
+ @devminor = vals[:devminor] || 0
+ @gid = vals[:gid] || 0
+ @gname = vals[:gname] || "wheel"
+ @linkname = vals[:linkname]
+ @magic = vals[:magic] || "ustar"
+ @mode = vals[:mode]
+ @mtime = vals[:mtime] || 0
+ @name = vals[:name]
+ @prefix = vals[:prefix]
+ @size = vals[:size]
+ @typeflag = vals[:typeflag]
+ @typeflag = "0" if @typeflag.nil? || @typeflag.empty?
+ @uid = vals[:uid] || 0
+ @uname = vals[:uname] || "wheel"
+ @version = vals[:version] || "00"
@empty = vals[:empty]
end
+ EMPTY = new({ # :nodoc:
+ checksum: 0,
+ gname: "",
+ linkname: "",
+ magic: "",
+ mode: 0,
+ name: "",
+ prefix: "",
+ size: 0,
+ uname: "",
+ version: 0,
+
+ empty: true,
+ }).freeze
+ private_constant :EMPTY
+
##
# Is the tar entry empty?
@@ -205,10 +228,21 @@ class Gem::Package::TarHeader
@checksum = oct calculate_checksum(header), 6
end
+ ##
+ # Header's full name, including prefix
+
+ def full_name
+ if prefix != ""
+ File.join prefix, name
+ else
+ name
+ end
+ end
+
private
def calculate_checksum(header)
- header.bytes.sum
+ header.sum(0)
end
def header(checksum = @checksum)
@@ -234,10 +268,10 @@ class Gem::Package::TarHeader
header = header.pack PACK_FORMAT
- header << ("\0" * ((512 - header.size) % 512))
+ header.ljust 512, "\0"
end
def oct(num, len)
- "%0#{len}o" % num
+ format("%0#{len}o", num)
end
end
diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb
index 98c6fe7c00..b66a8a62bc 100644
--- a/lib/rubygems/package/tar_reader.rb
+++ b/lib/rubygems/package/tar_reader.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
-#--
+
+# rubocop:disable Style/AsciiComments
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
-#++
+
+# rubocop:enable Style/AsciiComments
##
# TarReader reads tar files and allows iteration over their items
@@ -11,11 +14,6 @@ class Gem::Package::TarReader
include Enumerable
##
- # Raised if the tar IO is not seekable
-
- class UnexpectedEOF < StandardError; end
-
- ##
# Creates a new TarReader on +io+ and yields it to the block, if given.
def self.new(io)
@@ -32,6 +30,8 @@ class Gem::Package::TarReader
nil
end
+ attr_reader :io # :nodoc:
+
##
# Creates a new tar file reader on +io+ which needs to respond to #pos,
# #eof?, #read, #getc and #pos=
@@ -54,7 +54,14 @@ class Gem::Package::TarReader
return enum_for __method__ unless block_given?
until @io.eof? do
- header = Gem::Package::TarHeader.from @io
+ begin
+ header = Gem::Package::TarHeader.from @io
+ rescue ArgumentError => e
+ # Specialize only exceptions from Gem::Package::TarHeader.strict_oct
+ raise e unless e.message.match?(/ is not an octal string$/)
+ raise Gem::Package::TarInvalidError, e.message
+ end
+
return if header.empty?
entry = Gem::Package::TarReader::Entry.new header, @io
yield entry
@@ -87,7 +94,7 @@ class Gem::Package::TarReader
return unless found
- return yield found
+ yield found
ensure
rewind
end
diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb
index 9cd43b9664..f837e86fd6 100644
--- a/lib/rubygems/package/tar_reader/entry.rb
+++ b/lib/rubygems/package/tar_reader/entry.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
-#++
+
+# rubocop:disable Style/AsciiComments
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
-#--
+
+# rubocop:enable Style/AsciiComments
##
# Class for reading entries out of a tar file
@@ -84,11 +87,7 @@ class Gem::Package::TarReader::Entry
# Full name of the tar entry
def full_name
- if @header.prefix != ""
- File.join @header.prefix, @header.name
- else
- @header.name
- end
+ @header.full_name.force_encoding(Encoding::UTF_8)
rescue ArgumentError => e
raise unless e.message == "string contains null byte"
raise Gem::Package::TarInvalidError,
@@ -99,9 +98,7 @@ class Gem::Package::TarReader::Entry
# Read one byte from the tar entry
def getc
- check_closed
-
- return nil if @read >= @header.size
+ return nil if eof?
ret = @io.getc
@read += 1 if ret
@@ -144,7 +141,6 @@ class Gem::Package::TarReader::Entry
def pos=(new_pos)
seek(new_pos, IO::SEEK_SET)
- new_pos
end
def size
@@ -154,30 +150,28 @@ class Gem::Package::TarReader::Entry
alias_method :length, :size
##
- # Reads +len+ bytes from the tar file entry, or the rest of the entry if
- # nil
-
- def read(len = nil)
- check_closed
+ # Reads +maxlen+ bytes from the tar file entry, or the rest of the entry if nil
- len ||= @header.size - @read
-
- return nil if len > 0 && @read >= @header.size
+ def read(maxlen = nil)
+ if eof?
+ return maxlen.to_i.zero? ? "" : nil
+ end
- max_read = [len, @header.size - @read].min
+ max_read = [maxlen, @header.size - @read].compact.min
ret = @io.read max_read
+ if ret.nil?
+ return maxlen ? nil : "" # IO.read returns nil on EOF with len argument
+ end
@read += ret.size
ret
end
- def readpartial(maxlen = nil, outbuf = "".b)
- check_closed
-
- maxlen ||= @header.size - @read
-
- raise EOFError if maxlen > 0 && @read >= @header.size
+ def readpartial(maxlen, outbuf = "".b)
+ if eof? && maxlen > 0
+ raise EOFError, "end of file reached"
+ end
max_read = [maxlen, @header.size - @read].min
@@ -211,6 +205,8 @@ class Gem::Package::TarReader::Entry
pending = new_pos - @io.pos
+ return 0 if pending == 0
+
if @io.respond_to?(:seek)
begin
# avoid reading if the @io supports seeking
@@ -228,8 +224,8 @@ class Gem::Package::TarReader::Entry
end
while pending > 0 do
- size_read = @io.read([pending, 4096].min).size
- raise UnexpectedEOF if @io.eof?
+ size_read = @io.read([pending, 4096].min)&.size
+ raise(EOFError, "end of file reached") if size_read.nil?
pending -= size_read
end
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index db5242c5e4..39fed9e2af 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
-#--
+
+# rubocop:disable Style/AsciiComments
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
-#++
+
+# rubocop:enable Style/AsciiComments
##
# Allows writing of tar files
@@ -92,10 +95,11 @@ class Gem::Package::TarWriter
end
##
- # Adds file +name+ with permissions +mode+, and yields an IO for writing the
- # file to
+ # Adds file +name+ with permissions +mode+ and mtime +mtime+ (sets
+ # Gem.source_date_epoch if not specified), and yields an IO for
+ # writing the file to
- def add_file(name, mode) # :yields: io
+ def add_file(name, mode, mtime = nil) # :yields: io
check_closed
name, prefix = split_name name
@@ -113,9 +117,9 @@ class Gem::Package::TarWriter
final_pos = @io.pos
@io.pos = init_pos
- header = Gem::Package::TarHeader.new :name => name, :mode => mode,
- :size => size, :prefix => prefix,
- :mtime => Gem.source_date_epoch
+ header = Gem::Package::TarHeader.new name: name, mode: mode,
+ size: size, prefix: prefix,
+ mtime: mtime || Gem.source_date_epoch
@io.write header
@io.pos = final_pos
@@ -189,7 +193,7 @@ class Gem::Package::TarWriter
if signer.key
signature = signer.sign signature_digest.digest
- add_file_simple "#{name}.sig", 0444, signature.length do |io|
+ add_file_simple "#{name}.sig", 0o444, signature.length do |io|
io.write signature
end
end
@@ -206,9 +210,9 @@ class Gem::Package::TarWriter
name, prefix = split_name name
- header = Gem::Package::TarHeader.new(:name => name, :mode => mode,
- :size => size, :prefix => prefix,
- :mtime => Gem.source_date_epoch).to_s
+ header = Gem::Package::TarHeader.new(name: name, mode: mode,
+ size: size, prefix: prefix,
+ mtime: Gem.source_date_epoch).to_s
@io.write header
os = BoundedStream.new @io, size
@@ -232,11 +236,11 @@ class Gem::Package::TarWriter
name, prefix = split_name name
- header = Gem::Package::TarHeader.new(:name => name, :mode => mode,
- :size => 0, :typeflag => "2",
- :linkname => target,
- :prefix => prefix,
- :mtime => Gem.source_date_epoch).to_s
+ header = Gem::Package::TarHeader.new(name: name, mode: mode,
+ size: 0, typeflag: "2",
+ linkname: target,
+ prefix: prefix,
+ mtime: Gem.source_date_epoch).to_s
@io.write header
@@ -286,10 +290,10 @@ class Gem::Package::TarWriter
name, prefix = split_name(name)
- header = Gem::Package::TarHeader.new :name => name, :mode => mode,
- :typeflag => "5", :size => 0,
- :prefix => prefix,
- :mtime => Gem.source_date_epoch
+ header = Gem::Package::TarHeader.new name: name, mode: mode,
+ typeflag: "5", size: 0,
+ prefix: prefix,
+ mtime: Gem.source_date_epoch
@io.write header
@@ -323,6 +327,6 @@ class Gem::Package::TarWriter
end
end
- return name, prefix
+ [name, prefix]
end
end
diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb
index 8432bc5806..d26411684d 100644
--- a/lib/rubygems/package_task.rb
+++ b/lib/rubygems/package_task.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -96,13 +97,13 @@ class Gem::PackageTask < Rake::PackageTask
gem_path = File.join package_dir, gem_file
gem_dir = File.join package_dir, gem_spec.full_name
- task :package => [:gem]
+ task package: [:gem]
directory package_dir
directory gem_dir
desc "Build the gem file #{gem_file}"
- task :gem => [gem_path]
+ task gem: [gem_path]
trace = Rake.application.options.trace
Gem.configuration.verbose = trace
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index d601e653c9..13091e29ba 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
#
# Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings
@@ -23,23 +24,22 @@ class Gem::PathSupport
# hashtable, or defaults to ENV, the system environment.
#
def initialize(env)
- @home = env["GEM_HOME"] || Gem.default_dir
-
- if File::ALT_SEPARATOR
- @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
- end
-
- @home = expand(@home)
-
+ @home = normalize_home_dir(env["GEM_HOME"] || Gem.default_dir)
@path = split_gem_path env["GEM_PATH"], @home
@spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir
-
- @spec_cache_dir = @spec_cache_dir.dup.tap(&Gem::UNTAINT)
end
private
+ def normalize_home_dir(home)
+ if File::ALT_SEPARATOR
+ home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
+ end
+
+ expand(home)
+ end
+
##
# Split the Gem search path (as reported by Gem.path).
@@ -52,7 +52,7 @@ class Gem::PathSupport
gem_path = gpaths.split(Gem.path_separator)
# Handle the path_separator being set to a regexp, which will cause
# end_with? to error
- if gpaths =~ /#{Gem.path_separator}\z/
+ if /#{Gem.path_separator}\z/.match?(gpaths)
gem_path += default_path
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 3cfe5aa0a0..367b00e7e1 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require_relative "deprecate"
##
# Available list of platforms for targeting Gem installations.
@@ -11,14 +10,13 @@ class Gem::Platform
attr_accessor :cpu, :os, :version
- def self.local
- arch = RbConfig::CONFIG["arch"]
- arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/
- @local ||= new(arch)
- end
-
- def self.match(platform)
- match_platforms?(platform, Gem.platforms)
+ def self.local(refresh: false)
+ return @local if @local && !refresh
+ @local = begin
+ arch = Gem.target_rbconfig["arch"]
+ arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
+ new(arch)
+ end
end
def self.match_platforms?(platform, platforms)
@@ -35,10 +33,20 @@ class Gem::Platform
match_gem?(spec.platform, spec.name)
end
- def self.match_gem?(platform, gem_name)
- # Note: this method might be redefined by Ruby implementations to
- # customize behavior per RUBY_ENGINE, gem_name or other criteria.
- match_platforms?(platform, Gem.platforms)
+ if RUBY_ENGINE == "truffleruby"
+ def self.match_gem?(platform, gem_name)
+ raise "Not a string: #{gem_name.inspect}" unless String === gem_name
+
+ if REUSE_AS_BINARY_ON_TRUFFLERUBY.include?(gem_name)
+ match_platforms?(platform, [Gem::Platform::RUBY, Gem::Platform.local])
+ else
+ match_platforms?(platform, Gem.platforms)
+ end
+ end
+ else
+ def self.match_gem?(platform, gem_name)
+ match_platforms?(platform, Gem.platforms)
+ end
end
def self.sort_priority(platform)
@@ -69,56 +77,46 @@ class Gem::Platform
when Array then
@cpu, @os, @version = arch
when String then
- arch = arch.split "-"
+ cpu, os = arch.sub(/-+$/, "").split("-", 2)
- if arch.length > 2 && arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc}
- extra = arch.pop
- arch.last << "-#{extra}"
+ @cpu = if cpu&.match?(/i\d86/)
+ "x86"
+ else
+ cpu
end
- cpu = arch.shift
-
- @cpu = case cpu
- when /i\d86/ then "x86"
- else cpu
- end
-
- if arch.length == 2 && arch.last =~ /^\d+(\.\d+)?$/ # for command-line
- @os, @version = arch
- return
- end
-
- os, = arch
if os.nil?
@cpu = nil
os = cpu
end # legacy jruby
@os, @version = case os
- when /aix(\d+)?/ then [ "aix", $1 ]
- when /cygwin/ then [ "cygwin", nil ]
- when /darwin(\d+)?/ then [ "darwin", $1 ]
- when /^macruby$/ then [ "macruby", nil ]
- when /freebsd(\d+)?/ then [ "freebsd", $1 ]
- when /^java$/, /^jruby$/ then [ "java", nil ]
- when /^java([\d.]*)/ then [ "java", $1 ]
- when /^dalvik(\d+)?$/ then [ "dalvik", $1 ]
- when /^dotnet$/ then [ "dotnet", nil ]
- when /^dotnet([\d.]*)/ then [ "dotnet", $1 ]
- when /linux-?(\w+)?/ then [ "linux", $1 ]
- when /mingw32/ then [ "mingw32", nil ]
- when /mingw-?(\w+)?/ then [ "mingw", $1 ]
- when /(mswin\d+)(\_(\d+))?/ then
+ when /aix-?(\d+)?/ then ["aix", $1]
+ when /cygwin/ then ["cygwin", nil]
+ when /darwin-?(\d+)?/ then ["darwin", $1]
+ when "macruby" then ["macruby", nil]
+ when /^macruby-?(\d+(?:\.\d+)*)?/ then ["macruby", $1]
+ when /freebsd-?(\d+)?/ then ["freebsd", $1]
+ when "java", "jruby" then ["java", nil]
+ when /^java-?(\d+(?:\.\d+)*)?/ then ["java", $1]
+ when /^dalvik-?(\d+)?$/ then ["dalvik", $1]
+ when /^dotnet$/ then ["dotnet", nil]
+ when /^dotnet-?(\d+(?:\.\d+)*)?/ then ["dotnet", $1]
+ when /linux-?(\w+)?/ then ["linux", $1]
+ when /mingw32/ then ["mingw32", nil]
+ when /mingw-?(\w+)?/ then ["mingw", $1]
+ when /(mswin\d+)(?:[_-](\d+))?/ then
os = $1
- version = $3
- @cpu = "x86" if @cpu.nil? && os =~ /32$/
+ version = $2
+ @cpu = "x86" if @cpu.nil? && os.end_with?("32")
[os, version]
- when /netbsdelf/ then [ "netbsdelf", nil ]
- when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ]
- when /solaris(\d+\.\d+)?/ then [ "solaris", $1 ]
+ when /netbsdelf/ then ["netbsdelf", nil]
+ when /openbsd-?(\d+\.\d+)?/ then ["openbsd", $1]
+ when /solaris-?(\d+\.\d+)?/ then ["solaris", $1]
+ when /wasi/ then ["wasi", nil]
# test
- when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]
- else [ "unknown", nil ]
+ when /^(\w+_platform)-?(\d+)?/ then [$1, $2]
+ else ["unknown", nil]
end
when Gem::Platform then
@cpu = arch.cpu
@@ -134,7 +132,38 @@ class Gem::Platform
end
def to_s
- to_a.compact.join "-"
+ to_a.compact.join(@cpu.nil? ? "" : "-")
+ end
+
+ ##
+ # Deconstructs the platform into an array for pattern matching.
+ # Returns [cpu, os, version].
+ #
+ # Gem::Platform.new("x86_64-linux").deconstruct #=> ["x86_64", "linux", nil]
+ #
+ # This enables array pattern matching:
+ #
+ # case Gem::Platform.new("arm64-darwin-21")
+ # in ["arm64", "darwin", version]
+ # # version => "21"
+ # end
+ alias_method :deconstruct, :to_a
+
+ ##
+ # Deconstructs the platform into a hash for pattern matching.
+ # Returns a hash with keys +:cpu+, +:os+, and +:version+.
+ #
+ # Gem::Platform.new("x86_64-darwin-20").deconstruct_keys(nil)
+ # #=> { cpu: "x86_64", os: "darwin", version: "20" }
+ #
+ # This enables hash pattern matching:
+ #
+ # case Gem::Platform.new("x86_64-linux")
+ # in cpu: "x86_64", os: "linux"
+ # # Matches Linux on x86_64
+ # end
+ def deconstruct_keys(keys)
+ { cpu: @cpu, os: @os, version: @version }
end
##
@@ -157,7 +186,7 @@ class Gem::Platform
# they have the same version, or either one has no version
#
# Additionally, the platform will match if the local CPU is 'arm' and the
- # other CPU starts with "arm" (for generic ARM family support).
+ # other CPU starts with "armv" (for generic 32-bit ARM family support).
#
# Of note, this method is not commutative. Indeed the OS 'linux' has a
# special case: the version is the libc name, yet while "no version" stands
@@ -178,7 +207,7 @@ class Gem::Platform
# cpu
([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
- (@cpu == "arm" && other.cpu.start_with?("arm"))) &&
+ (@cpu == "arm" && other.cpu.start_with?("armv"))) &&
# os
@os == other.os &&
@@ -213,17 +242,17 @@ class Gem::Platform
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 /^dalvik(\d+)?$/ then [nil, "dalvik", $1 ]
- when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2 ]
- when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2 ]
- when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $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 ]
+ when /^i686-darwin(\d)/ then ["x86", "darwin", $1]
+ when /^i\d86-linux/ then ["x86", "linux", nil]
+ when "java", "jruby" then [nil, "java", nil]
+ when /^dalvik(\d+)?$/ then [nil, "dalvik", $1]
+ when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2]
+ when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2]
+ when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $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
@@ -246,4 +275,118 @@ class Gem::Platform
# This will be replaced with Gem::Platform::local.
CURRENT = "current"
+
+ JAVA = Gem::Platform.new("java") # :nodoc:
+ MSWIN = Gem::Platform.new("mswin32") # :nodoc:
+ MSWIN64 = Gem::Platform.new("mswin64") # :nodoc:
+ MINGW = Gem::Platform.new("x86-mingw32") # :nodoc:
+ X64_MINGW_LEGACY = Gem::Platform.new("x64-mingw32") # :nodoc:
+ X64_MINGW = Gem::Platform.new("x64-mingw-ucrt") # :nodoc:
+ UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw") # :nodoc:
+ WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].freeze # :nodoc:
+ X64_LINUX = Gem::Platform.new("x86_64-linux") # :nodoc:
+ X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") # :nodoc:
+
+ GENERICS = [JAVA, *WINDOWS].freeze # :nodoc:
+ private_constant :GENERICS
+
+ GENERIC_CACHE = GENERICS.each_with_object({}) {|g, h| h[g] = g } # :nodoc:
+ private_constant :GENERIC_CACHE
+
+ class << self
+ ##
+ # Returns the generic platform for the given platform.
+
+ def generic(platform)
+ return Gem::Platform::RUBY if platform.nil? || platform == Gem::Platform::RUBY
+
+ GENERIC_CACHE[platform] ||= begin
+ found = GENERICS.find do |match|
+ platform === match
+ end
+ found || Gem::Platform::RUBY
+ end
+ end
+
+ ##
+ # Returns the platform specificity match for the given spec platform and user platform.
+
+ def platform_specificity_match(spec_platform, user_platform)
+ return -1 if spec_platform == user_platform
+ return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
+
+ os_match(spec_platform, user_platform) +
+ cpu_match(spec_platform, user_platform) * 10 +
+ version_match(spec_platform, user_platform) * 100
+ end
+
+ ##
+ # Sorts and filters the best platform match for the given matching specs and platform.
+
+ def sort_and_filter_best_platform_match(matching, platform)
+ return matching if matching.one?
+
+ exact = matching.select {|spec| spec.platform == platform }
+ return exact if exact.any?
+
+ sorted_matching = sort_best_platform_match(matching, platform)
+ exemplary_spec = sorted_matching.first
+
+ sorted_matching.take_while {|spec| same_specificity?(platform, spec, exemplary_spec) && same_deps?(spec, exemplary_spec) }
+ end
+
+ ##
+ # Sorts the best platform match for the given matching specs and platform.
+
+ def sort_best_platform_match(matching, platform)
+ matching.sort_by.with_index do |spec, i|
+ [
+ platform_specificity_match(spec.platform, platform),
+ i, # for stable sort
+ ]
+ end
+ end
+
+ private
+
+ def same_specificity?(platform, spec, exemplary_spec)
+ platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
+ end
+
+ def same_deps?(spec, exemplary_spec)
+ spec.required_ruby_version == exemplary_spec.required_ruby_version &&
+ spec.required_rubygems_version == exemplary_spec.required_rubygems_version &&
+ spec.dependencies.sort == exemplary_spec.dependencies.sort
+ end
+
+ def os_match(spec_platform, user_platform)
+ if spec_platform.os == user_platform.os
+ 0
+ else
+ 1
+ end
+ end
+
+ def cpu_match(spec_platform, user_platform)
+ if spec_platform.cpu == user_platform.cpu
+ 0
+ elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
+ 0
+ elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
+ 1
+ else
+ 2
+ end
+ end
+
+ def version_match(spec_platform, user_platform)
+ if spec_platform.version == user_platform.version
+ 0
+ elsif spec_platform.version.nil?
+ 1
+ else
+ 2
+ end
+ end
+ end
end
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb
index b90f9f7d1d..8b4c425a33 100644
--- a/lib/rubygems/psych_tree.rb
+++ b/lib/rubygems/psych_tree.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Gem
if defined? ::Psych::Visitors
class NoAliasYAMLTree < Psych::Visitors::YAMLTree
@@ -13,11 +14,15 @@ module Gem
@emitter.scalar str, nil, nil, false, true, quote
end
+ def visit_Hash(o)
+ super(o.compact)
+ end
+
# Noop this out so there are no anchors
def register(target, obj)
end
- # This is ported over from the yaml_tree in 1.9.3
+ # This is ported over from the YAMLTree implementation in Ruby 1.9.3
def format_time(time)
if time.utc?
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb
index 2c09ef4e1a..9849370b1a 100644
--- a/lib/rubygems/query_utils.rb
+++ b/lib/rubygems/query_utils.rb
@@ -132,7 +132,7 @@ module Gem::QueryUtils
version_matches = show_prereleases? || !s.version.prerelease?
name_matches && version_matches
- end
+ end.uniq(&:full_name)
spec_tuples = specs.map do |spec|
[spec.name_tuple, spec]
@@ -242,7 +242,7 @@ module Gem::QueryUtils
list =
if platforms.empty? || options[:details]
- name_tuples.map {|n| n.version }.uniq
+ name_tuples.map(&:version).uniq
else
platforms.sort.reverse.map do |version, pls|
out = version.to_s
@@ -311,8 +311,8 @@ module Gem::QueryUtils
label = "Installed at"
specs.each do |s|
version = s.version.to_s
- version << ", default" if s.default_gem?
- entry << "\n" << " #{label} (#{version}): #{s.base_dir}"
+ default = s.default_gem? ? ", default" : ""
+ entry << "\n" << " #{label} (#{version}#{default}): #{s.base_dir}"
label = " " * label.length
end
end
@@ -331,7 +331,7 @@ module Gem::QueryUtils
else
entry << " Platforms:\n"
- sorted_platforms = platforms.sort_by {|version,| version }
+ sorted_platforms = platforms.sort
sorted_platforms.each do |version, pls|
label = " #{version}: "
diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb
index 769ec61d1e..3524b161b2 100644
--- a/lib/rubygems/rdoc.rb
+++ b/lib/rubygems/rdoc.rb
@@ -1,12 +1,26 @@
# frozen_string_literal: true
+
require_relative "../rubygems"
begin
require "rdoc/rubygems_hook"
module Gem
- RDoc = ::RDoc::RubygemsHook
- end
+ ##
+ # Returns whether RDoc defines its own install hooks through a RubyGems
+ # plugin. This and whatever is guarded by it can be removed once no
+ # supported Ruby ships with RDoc older than 6.9.0.
+
+ def self.rdoc_hooks_defined_via_plugin?
+ Gem::Version.new(::RDoc::VERSION) >= Gem::Version.new("6.9.0")
+ end
- Gem.done_installing(&Gem::RDoc.method(:generation_hook))
+ if rdoc_hooks_defined_via_plugin?
+ RDoc = ::RDoc::RubyGemsHook
+ else
+ RDoc = ::RDoc::RubygemsHook
+
+ Gem.done_installing(&Gem::RDoc.method(:generation_hook))
+ end
+ end
rescue LoadError
end
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 658752798e..5b83dc6f6f 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../rubygems"
require_relative "request"
require_relative "request/connection_pools"
@@ -52,7 +53,7 @@ class Gem::RemoteFetcher
# Cached RemoteFetcher instance.
def self.fetcher
- @fetcher ||= self.new Gem.configuration[:http_proxy]
+ @fetcher ||= new Gem.configuration[:http_proxy]
end
attr_accessor :headers
@@ -71,17 +72,17 @@ class Gem::RemoteFetcher
# +headers+: A set of additional HTTP headers to be sent to the server when
# fetching the gem.
- def initialize(proxy=nil, dns=nil, headers={})
+ def initialize(proxy = nil, dns = nil, headers = {})
require_relative "core_ext/tcpsocket_init" if Gem.configuration.ipv4_fallback_enabled
- require "net/http"
- require "stringio"
- require "uri"
+ require_relative "vendored_net_http"
+ require_relative "vendor/uri/lib/uri"
Socket.do_not_reverse_lookup = true
@proxy = proxy
@pools = {}
@pool_lock = Thread::Mutex.new
+ @pool_size = 1
@cert_files = Gem::Request.get_cert_files
@headers = headers
@@ -110,28 +111,35 @@ class Gem::RemoteFetcher
# always replaced.
def download(spec, source_uri, install_dir = Gem.dir)
+ gem_file_name = File.basename spec.cache_file
+
install_cache_dir = File.join install_dir, "cache"
cache_dir =
- if Dir.pwd == install_dir # see fetch_command
+ if Gem.configuration.global_gem_cache
+ Gem.global_gem_cache_path
+ elsif Dir.pwd == install_dir # see fetch_command
install_dir
- elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && (!File.exist?(install_cache_dir)))
+ elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && !File.exist?(install_cache_dir))
install_cache_dir
else
File.join Gem.user_dir, "cache"
end
- gem_file_name = File.basename spec.cache_file
local_gem_path = File.join cache_dir, gem_file_name
require "fileutils"
- FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
+ begin
+ FileUtils.mkdir_p cache_dir
+ rescue StandardError
+ nil
+ end unless File.exist? cache_dir
source_uri = Gem::Uri.new(source_uri)
scheme = source_uri.scheme
- # URI.parse gets confused by MS Windows paths with forward slashes.
- scheme = nil if scheme =~ /^[a-z]$/i
+ # Gem::URI.parse gets confused by MS Windows paths with forward slashes.
+ scheme = nil if /^[a-z]$/i.match?(scheme)
# REFACTOR: split this up and dispatch on scheme (eg download_http)
# REFACTOR: be sure to clean up fake fetcher when you do this... cleaner
@@ -143,7 +151,7 @@ class Gem::RemoteFetcher
remote_gem_path = source_uri + "gems/#{gem_file_name}"
- self.cache_update_path remote_gem_path, local_gem_path
+ cache_update_path remote_gem_path, local_gem_path
rescue FetchError
raise if spec.original_platform == spec.platform
@@ -153,7 +161,7 @@ class Gem::RemoteFetcher
remote_gem_path = source_uri + "gems/#{alternate_name}"
- self.cache_update_path remote_gem_path, local_gem_path
+ cache_update_path remote_gem_path, local_gem_path
end
end
when "file" then
@@ -169,7 +177,7 @@ class Gem::RemoteFetcher
end
verbose "Using local gem #{local_gem_path}"
- when nil then # TODO test for local overriding cache
+ when nil then
source_path = if Gem.win_platform? && source_uri.scheme &&
!source_uri.path.include?(":")
"#{source_uri.scheme}:#{source_uri.path}"
@@ -205,17 +213,17 @@ class Gem::RemoteFetcher
# HTTP Fetcher. Dispatched by +fetch_path+. Use it instead.
def fetch_http(uri, last_modified = nil, head = false, depth = 0)
- fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
+ fetch_type = head ? Gem::Net::HTTP::Head : Gem::Net::HTTP::Get
response = request uri, fetch_type, last_modified do |req|
headers.each {|k,v| req.add_field(k,v) }
end
case response
- when Net::HTTPOK, Net::HTTPNotModified then
+ when Gem::Net::HTTPOK, Gem::Net::HTTPNotModified then
response.uri = uri
head ? response : response.body
- when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
- Net::HTTPTemporaryRedirect then
+ when Gem::Net::HTTPMovedPermanently, Gem::Net::HTTPFound, Gem::Net::HTTPSeeOther,
+ Gem::Net::HTTPTemporaryRedirect then
raise FetchError.new("too many redirects", uri) if depth > 10
unless location = response["Location"]
@@ -229,7 +237,9 @@ class Gem::RemoteFetcher
fetch_http(location, last_modified, head, depth + 1)
else
- raise FetchError.new("bad response #{response.message} #{response.code}", uri)
+ custom_error = response["X-Error-Message"]
+ error_detail = custom_error || response.message
+ raise FetchError.new("Bad response #{error_detail} #{response.code}", uri)
end
end
@@ -241,11 +251,14 @@ class Gem::RemoteFetcher
def fetch_path(uri, mtime = nil, head = false)
uri = Gem::Uri.new uri
- unless uri.scheme
- raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}"
- end
+ method = {
+ "http" => "fetch_http",
+ "https" => "fetch_http",
+ "s3" => "fetch_s3",
+ "file" => "fetch_file",
+ }.fetch(uri.scheme) { raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}" }
- data = send "fetch_#{uri.scheme}", uri, mtime, head
+ data = send method, uri, mtime, head
if data && !head && uri.to_s.end_with?(".gz")
begin
@@ -256,14 +269,14 @@ class Gem::RemoteFetcher
end
data
- rescue Timeout::Error, IOError, SocketError, SystemCallError,
+ rescue Gem::Timeout::Error, IOError, SocketError, SystemCallError,
*(OpenSSL::SSL::SSLError if Gem::HAVE_OPENSSL) => e
raise FetchError.new("#{e.class}: #{e}", uri)
end
def fetch_s3(uri, mtime = nil, head = false)
begin
- public_uri = s3_uri_signer(uri).sign
+ public_uri = s3_uri_signer(uri, head ? "HEAD" : "GET").sign
rescue Gem::S3URISigner::ConfigurationError, Gem::S3URISigner::InstanceProfileError => e
raise FetchError.new(e.message, "s3://#{uri.host}")
end
@@ -271,8 +284,8 @@ class Gem::RemoteFetcher
end
# we have our own signing code here to avoid a dependency on the aws-sdk gem
- def s3_uri_signer(uri)
- Gem::S3URISigner.new(uri)
+ def s3_uri_signer(uri, method)
+ Gem::S3URISigner.new(uri, method)
end
##
@@ -280,7 +293,11 @@ class Gem::RemoteFetcher
# passes the data.
def cache_update_path(uri, path = nil, update = true)
- mtime = path && File.stat(path).mtime rescue nil
+ mtime = begin
+ path && File.stat(path).mtime
+ rescue StandardError
+ nil
+ end
data = fetch_path(uri, mtime)
@@ -296,8 +313,8 @@ class Gem::RemoteFetcher
end
##
- # Performs a Net::HTTP request of type +request_class+ on +uri+ returning
- # a Net::HTTP response object. request maintains a table of persistent
+ # Performs a Gem::Net::HTTP request of type +request_class+ on +uri+ returning
+ # a Gem::Net::HTTP response object. request maintains a table of persistent
# connections to reduce connect overhead.
def request(uri, request_class, last_modified = nil)
@@ -312,11 +329,11 @@ class Gem::RemoteFetcher
end
def https?(uri)
- uri.scheme.downcase == "https"
+ uri.scheme.casecmp("https").zero?
end
def close_all
- @pools.each_value {|pool| pool.close_all }
+ @pools.each_value(&:close_all)
end
private
@@ -327,7 +344,7 @@ class Gem::RemoteFetcher
def pools_for(proxy)
@pool_lock.synchronize do
- @pools[proxy] ||= Gem::Request::ConnectionPools.new proxy, @cert_files
+ @pools[proxy] ||= Gem::Request::ConnectionPools.new proxy, @cert_files, @pool_size
end
end
end
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index 1eeaa416fc..e817ee5704 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
-require "net/http"
+
+require_relative "vendored_net_http"
require_relative "user_interaction"
+require_relative "uri_formatter"
class Gem::Request
extend Gem::UserInteraction
@@ -17,11 +19,11 @@ class Gem::Request
end
def self.proxy_uri(proxy) # :nodoc:
- require "uri"
+ require_relative "vendor/uri/lib/uri"
case proxy
when :no_proxy then nil
- when URI::HTTP then proxy
- else URI.parse(proxy)
+ when Gem::URI::HTTP then proxy
+ else Gem::URI.parse(proxy)
end
end
@@ -29,7 +31,7 @@ class Gem::Request
@uri = uri
@request_class = request_class
@last_modified = last_modified
- @requests = Hash.new 0
+ @requests = Hash.new(0).compare_by_identity
@user_agent = user_agent
@connection_pool = pool
@@ -164,23 +166,22 @@ class Gem::Request
# environment variables.
def self.get_proxy_from_env(scheme = "http")
- _scheme = scheme.downcase
- _SCHEME = scheme.upcase
- env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"]
+ downcase_scheme = scheme.downcase
+ upcase_scheme = scheme.upcase
+ env_proxy = ENV["#{downcase_scheme}_proxy"] || ENV["#{upcase_scheme}_PROXY"]
no_env_proxy = env_proxy.nil? || env_proxy.empty?
if no_env_proxy
- return (_scheme == "https" || _scheme == "http") ?
- :no_proxy : get_proxy_from_env("http")
+ return ["https", "http"].include?(downcase_scheme) ? :no_proxy : get_proxy_from_env("http")
end
require "uri"
- uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
+ uri = Gem::URI(Gem::UriFormatter.new(env_proxy).normalize)
if uri && uri.user.nil? && uri.password.nil?
- user = ENV["#{_scheme}_proxy_user"] || ENV["#{_SCHEME}_PROXY_USER"]
- password = ENV["#{_scheme}_proxy_pass"] || ENV["#{_SCHEME}_PROXY_PASS"]
+ user = ENV["#{downcase_scheme}_proxy_user"] || ENV["#{upcase_scheme}_PROXY_USER"]
+ password = ENV["#{downcase_scheme}_proxy_pass"] || ENV["#{upcase_scheme}_PROXY_PASS"]
uri.user = Gem::UriFormatter.new(user).escape
uri.password = Gem::UriFormatter.new(password).escape
@@ -196,7 +197,7 @@ class Gem::Request
bad_response = false
begin
- @requests[connection.object_id] += 1
+ @requests[connection] += 1
verbose "#{request.method} #{Gem::Uri.redact(@uri)}"
@@ -205,7 +206,7 @@ class Gem::Request
if request.response_body_permitted? && file_name =~ /\.gem$/
reporter = ui.download_reporter
response = connection.request(request) do |incomplete_response|
- if Net::HTTPOK === incomplete_response
+ if Gem::Net::HTTPOK === incomplete_response
reporter.fetch(file_name, incomplete_response.content_length)
downloaded = 0
data = String.new
@@ -228,7 +229,7 @@ class Gem::Request
end
verbose "#{response.code} #{response.message}"
- rescue Net::HTTPBadResponse
+ rescue Gem::Net::HTTPBadResponse
verbose "bad response"
reset connection
@@ -237,17 +238,17 @@ class Gem::Request
bad_response = true
retry
- rescue Net::HTTPFatalError
+ rescue Gem::Net::HTTPFatalError
verbose "fatal error"
raise Gem::RemoteFetcher::FetchError.new("fatal error", @uri)
- # HACK work around EOFError bug in Net::HTTP
+ # HACK: work around EOFError bug in Gem::Net::HTTP
# NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
# to install gems.
- rescue EOFError, Timeout::Error,
+ rescue EOFError, Gem::Timeout::Error,
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
- requests = @requests[connection.object_id]
+ requests = @requests[connection]
verbose "connection reset after #{requests} requests, retrying"
raise Gem::RemoteFetcher::FetchError.new("too many connection resets", @uri) if retried
@@ -267,7 +268,7 @@ class Gem::Request
# Resets HTTP connection +connection+.
def reset(connection)
- @requests.delete connection.object_id
+ @requests.delete connection
connection.finish
connection.start
@@ -282,7 +283,7 @@ class Gem::Request
ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}"
if RUBY_PATCHLEVEL >= 0
ua << " patchlevel #{RUBY_PATCHLEVEL}"
- elsif defined?(RUBY_REVISION)
+ else
ua << " revision #{RUBY_REVISION}"
end
ua << ")"
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index 44280489fb..01e7e0629a 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -1,17 +1,18 @@
# frozen_string_literal: true
class Gem::Request::ConnectionPools # :nodoc:
- @client = Net::HTTP
+ @client = Gem::Net::HTTP
class << self
attr_accessor :client
end
- def initialize(proxy_uri, cert_files)
+ def initialize(proxy_uri, cert_files, pool_size = 1)
@proxy_uri = proxy_uri
@cert_files = cert_files
@pools = {}
@pool_mutex = Thread::Mutex.new
+ @pool_size = pool_size
end
def pool_for(uri)
@@ -20,15 +21,15 @@ class Gem::Request::ConnectionPools # :nodoc:
@pool_mutex.synchronize do
@pools[key] ||=
if https? uri
- Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri)
+ Gem::Request::HTTPSPool.new(http_args, @cert_files, @proxy_uri, @pool_size)
else
- Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri)
+ Gem::Request::HTTPPool.new(http_args, @cert_files, @proxy_uri, @pool_size)
end
end
end
def close_all
- @pools.each_value {|pool| pool.close_all }
+ @pools.each_value(&:close_all)
end
private
@@ -45,7 +46,7 @@ class Gem::Request::ConnectionPools # :nodoc:
end
def https?(uri)
- uri.scheme.downcase == "https"
+ uri.scheme.casecmp("https").zero?
end
def no_proxy?(host, env_no_proxy)
diff --git a/lib/rubygems/request/http_pool.rb b/lib/rubygems/request/http_pool.rb
index 7b309eedd3..468502ca6b 100644
--- a/lib/rubygems/request/http_pool.rb
+++ b/lib/rubygems/request/http_pool.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A connection "pool" that only manages one connection for now. Provides
# thread safe `checkout` and `checkin` methods. The pool consists of one
@@ -8,12 +9,14 @@
class Gem::Request::HTTPPool # :nodoc:
attr_reader :cert_files, :proxy_uri
- def initialize(http_args, cert_files, proxy_uri)
+ def initialize(http_args, cert_files, proxy_uri, pool_size)
@http_args = http_args
@cert_files = cert_files
@proxy_uri = proxy_uri
- @queue = Thread::SizedQueue.new 1
- @queue << nil
+ @pool_size = pool_size
+
+ @queue = Thread::SizedQueue.new @pool_size
+ setup_queue
end
def checkout
@@ -30,7 +33,8 @@ class Gem::Request::HTTPPool # :nodoc:
connection.finish
end
end
- @queue.push(nil)
+
+ setup_queue
end
private
@@ -43,4 +47,8 @@ class Gem::Request::HTTPPool # :nodoc:
connection.start
connection
end
+
+ def setup_queue
+ @pool_size.times { @queue.push(nil) }
+ end
end
diff --git a/lib/rubygems/request/https_pool.rb b/lib/rubygems/request/https_pool.rb
index 50f42d9e0d..cb1d4b59b6 100644
--- a/lib/rubygems/request/https_pool.rb
+++ b/lib/rubygems/request/https_pool.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc:
private
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index f1af47618b..eb8b4658f3 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require_relative "tsort"
+
+require_relative "vendored_tsort"
##
# A RequestSet groups a request to activate a set of dependencies.
@@ -107,7 +108,7 @@ class Gem::RequestSet
@requests = []
@sets = []
@soft_missing = false
- @sorted = nil
+ @sorted_requests = nil
@specs = nil
@vendor_set = nil
@source_set = nil
@@ -180,13 +181,10 @@ class Gem::RequestSet
# Install requested gems after they have been downloaded
sorted_requests.each do |req|
- if req.installed?
- req.spec.spec.build_extensions
-
- if @always_install.none? {|spec| spec == req.spec.spec }
- yield req, nil if block_given?
- next
- end
+ if req.installed? && @always_install.none? {|spec| spec == req.spec.spec }
+ req.spec.spec.build_extensions unless options[:build_extension] == false
+ yield req, nil if block_given?
+ next
end
spec =
@@ -236,10 +234,6 @@ class Gem::RequestSet
sorted_requests.each do |spec|
puts " #{spec.full_name}"
end
-
- if Gem.configuration.really_verbose
- @resolver.stats.display
- end
else
installed = install options, &block
@@ -323,12 +317,9 @@ class Gem::RequestSet
@git_set.root_dir = @install_dir
- lock_file = "#{File.expand_path(path)}.lock".dup.tap(&Gem::UNTAINT)
- begin
- tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
- parser = tokenizer.make_parser self, []
- parser.parse
- rescue Errno::ENOENT
+ lock_file = "#{File.expand_path(path)}.lock"
+ if File.exist?(lock_file)
+ load_lockfile lock_file
end
gf = Gem::RequestSet::GemDependencyAPI.new self, path
@@ -337,6 +328,63 @@ class Gem::RequestSet
gf.load
end
+ def load_lockfile(lock_file) # :nodoc:
+ require "bundler"
+ require "bundler/lockfile_parser"
+
+ # Bundler::Source::Path resolves relative `remote:` paths against
+ # Bundler.root, which raises when there is no Gemfile in the working
+ # directory. Anchor it to the lockfile's directory so PATH sections in a
+ # `gem install -g` lockfile can be parsed without a Bundler environment.
+ previous_root = Bundler.instance_variable_get(:@root)
+ Bundler.instance_variable_set(:@root, Pathname.new(File.expand_path(File.dirname(lock_file))))
+
+ parser = Bundler::LockfileParser.new(File.read(lock_file), lockfile_path: lock_file)
+
+ parser.specs.group_by(&:source).each do |source, specs|
+ case source
+ when Bundler::Source::Rubygems
+ remotes = source.remotes.map {|remote| Gem::Source.new(remote.to_s) }
+ remotes << Gem::Source.new(Gem::DEFAULT_HOST) if remotes.empty?
+ lock_set = Gem::Resolver::LockSet.new(remotes)
+ specs.each do |spec|
+ added = lock_set.add(spec.name, spec.version.to_s, spec.platform)
+ spec.dependencies.each do |dep|
+ added.each {|s| s.add_dependency dep }
+ end
+ end
+ @sets << lock_set
+ when Bundler::Source::Git
+ git_set = Gem::Resolver::GitSet.new
+ git_set.root_dir = @install_dir
+ specs.each do |spec|
+ git_spec = git_set.add_git_spec(
+ spec.name,
+ spec.version.to_s,
+ source.uri.to_s,
+ source.revision,
+ source.submodules || false
+ )
+ spec.dependencies.each {|dep| git_spec.add_dependency dep }
+ end
+ @sets << git_set
+ when Bundler::Source::Path
+ vendor_set = Gem::Resolver::VendorSet.new
+ specs.each do |spec|
+ loaded = vendor_set.add_vendor_gem(spec.name, source.path.to_s)
+ spec.dependencies.each {|dep| loaded.dependencies << dep }
+ end
+ @sets << vendor_set
+ end
+ end
+
+ parser.dependencies.each_value do |dep|
+ gem dep.name, *dep.requirement.as_list
+ end
+ ensure
+ Bundler.instance_variable_set(:@root, previous_root) if defined?(previous_root)
+ end
+
def pretty_print(q) # :nodoc:
q.group 2, "[RequestSet:", "]" do
q.breakable
@@ -375,7 +423,7 @@ class Gem::RequestSet
q.text "sets:"
q.breakable
- q.pp @sets.map {|set| set.class }
+ q.pp @sets.map(&:class)
end
end
@@ -425,11 +473,11 @@ class Gem::RequestSet
end
def sorted_requests
- @sorted ||= strongly_connected_components.flatten
+ @sorted_requests ||= strongly_connected_components.flatten
end
def specs
- @specs ||= @requests.map {|r| r.full_spec }
+ @specs ||= @requests.map(&:full_spec)
end
def specs_in(dir)
@@ -447,7 +495,7 @@ class Gem::RequestSet
next if dep.type == :development && !@development
match = @requests.find do |r|
- dep.match? r.spec.name, r.spec.version, r.spec.is_a?(Gem::Resolver::InstalledSpecification) || @prerelease
+ dep.match?(r.spec.name, r.spec.version, r.spec.is_a?(Gem::Resolver::InstalledSpecification) || @prerelease)
end
unless match
@@ -464,4 +512,3 @@ end
require_relative "request_set/gem_dependency_api"
require_relative "request_set/lockfile"
-require_relative "request_set/lockfile/tokenizer"
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index a71522aa4d..99d96f928b 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A semi-compatible DSL for the Bundler Gemfile and Isolate gem dependencies
# files.
@@ -32,22 +33,22 @@
class Gem::RequestSet::GemDependencyAPI
ENGINE_MAP = { # :nodoc:
- :jruby => %w[jruby],
- :jruby_18 => %w[jruby],
- :jruby_19 => %w[jruby],
- :maglev => %w[maglev],
- :mri => %w[ruby],
- :mri_18 => %w[ruby],
- :mri_19 => %w[ruby],
- :mri_20 => %w[ruby],
- :mri_21 => %w[ruby],
- :rbx => %w[rbx],
- :truffleruby => %w[truffleruby],
- :ruby => %w[ruby rbx maglev truffleruby],
- :ruby_18 => %w[ruby rbx maglev truffleruby],
- :ruby_19 => %w[ruby rbx maglev truffleruby],
- :ruby_20 => %w[ruby rbx maglev truffleruby],
- :ruby_21 => %w[ruby rbx maglev truffleruby],
+ jruby: %w[jruby],
+ jruby_18: %w[jruby],
+ jruby_19: %w[jruby],
+ maglev: %w[maglev],
+ mri: %w[ruby],
+ mri_18: %w[ruby],
+ mri_19: %w[ruby],
+ mri_20: %w[ruby],
+ mri_21: %w[ruby],
+ rbx: %w[rbx],
+ truffleruby: %w[truffleruby],
+ ruby: %w[ruby rbx maglev truffleruby],
+ ruby_18: %w[ruby rbx maglev truffleruby],
+ ruby_19: %w[ruby rbx maglev truffleruby],
+ ruby_20: %w[ruby rbx maglev truffleruby],
+ ruby_21: %w[ruby rbx maglev truffleruby],
}.freeze
mswin = Gem::Platform.new "x86-mswin32"
@@ -56,39 +57,39 @@ class Gem::RequestSet::GemDependencyAPI
x64_mingw = Gem::Platform.new "x64-mingw32"
PLATFORM_MAP = { # :nodoc:
- :jruby => Gem::Platform::RUBY,
- :jruby_18 => Gem::Platform::RUBY,
- :jruby_19 => Gem::Platform::RUBY,
- :maglev => Gem::Platform::RUBY,
- :mingw => x86_mingw,
- :mingw_18 => x86_mingw,
- :mingw_19 => x86_mingw,
- :mingw_20 => x86_mingw,
- :mingw_21 => x86_mingw,
- :mri => Gem::Platform::RUBY,
- :mri_18 => Gem::Platform::RUBY,
- :mri_19 => Gem::Platform::RUBY,
- :mri_20 => Gem::Platform::RUBY,
- :mri_21 => Gem::Platform::RUBY,
- :mswin => mswin,
- :mswin_18 => mswin,
- :mswin_19 => mswin,
- :mswin_20 => mswin,
- :mswin_21 => mswin,
- :mswin64 => mswin64,
- :mswin64_19 => mswin64,
- :mswin64_20 => mswin64,
- :mswin64_21 => mswin64,
- :rbx => Gem::Platform::RUBY,
- :ruby => Gem::Platform::RUBY,
- :ruby_18 => Gem::Platform::RUBY,
- :ruby_19 => Gem::Platform::RUBY,
- :ruby_20 => Gem::Platform::RUBY,
- :ruby_21 => Gem::Platform::RUBY,
- :truffleruby => Gem::Platform::RUBY,
- :x64_mingw => x64_mingw,
- :x64_mingw_20 => x64_mingw,
- :x64_mingw_21 => x64_mingw,
+ jruby: Gem::Platform::RUBY,
+ jruby_18: Gem::Platform::RUBY,
+ jruby_19: Gem::Platform::RUBY,
+ maglev: Gem::Platform::RUBY,
+ mingw: x86_mingw,
+ mingw_18: x86_mingw,
+ mingw_19: x86_mingw,
+ mingw_20: x86_mingw,
+ mingw_21: x86_mingw,
+ mri: Gem::Platform::RUBY,
+ mri_18: Gem::Platform::RUBY,
+ mri_19: Gem::Platform::RUBY,
+ mri_20: Gem::Platform::RUBY,
+ mri_21: Gem::Platform::RUBY,
+ mswin: mswin,
+ mswin_18: mswin,
+ mswin_19: mswin,
+ mswin_20: mswin,
+ mswin_21: mswin,
+ mswin64: mswin64,
+ mswin64_19: mswin64,
+ mswin64_20: mswin64,
+ mswin64_21: mswin64,
+ rbx: Gem::Platform::RUBY,
+ ruby: Gem::Platform::RUBY,
+ ruby_18: Gem::Platform::RUBY,
+ ruby_19: Gem::Platform::RUBY,
+ ruby_20: Gem::Platform::RUBY,
+ ruby_21: Gem::Platform::RUBY,
+ truffleruby: Gem::Platform::RUBY,
+ x64_mingw: x64_mingw,
+ x64_mingw_20: x64_mingw,
+ x64_mingw_21: x64_mingw,
}.freeze
gt_eq_0 = Gem::Requirement.new ">= 0"
@@ -98,70 +99,70 @@ class Gem::RequestSet::GemDependencyAPI
tilde_gt_2_1_0 = Gem::Requirement.new "~> 2.1.0"
VERSION_MAP = { # :nodoc:
- :jruby => gt_eq_0,
- :jruby_18 => tilde_gt_1_8_0,
- :jruby_19 => tilde_gt_1_9_0,
- :maglev => gt_eq_0,
- :mingw => gt_eq_0,
- :mingw_18 => tilde_gt_1_8_0,
- :mingw_19 => tilde_gt_1_9_0,
- :mingw_20 => tilde_gt_2_0_0,
- :mingw_21 => tilde_gt_2_1_0,
- :mri => gt_eq_0,
- :mri_18 => tilde_gt_1_8_0,
- :mri_19 => tilde_gt_1_9_0,
- :mri_20 => tilde_gt_2_0_0,
- :mri_21 => tilde_gt_2_1_0,
- :mswin => gt_eq_0,
- :mswin_18 => tilde_gt_1_8_0,
- :mswin_19 => tilde_gt_1_9_0,
- :mswin_20 => tilde_gt_2_0_0,
- :mswin_21 => tilde_gt_2_1_0,
- :mswin64 => gt_eq_0,
- :mswin64_19 => tilde_gt_1_9_0,
- :mswin64_20 => tilde_gt_2_0_0,
- :mswin64_21 => tilde_gt_2_1_0,
- :rbx => gt_eq_0,
- :ruby => gt_eq_0,
- :ruby_18 => tilde_gt_1_8_0,
- :ruby_19 => tilde_gt_1_9_0,
- :ruby_20 => tilde_gt_2_0_0,
- :ruby_21 => tilde_gt_2_1_0,
- :truffleruby => gt_eq_0,
- :x64_mingw => gt_eq_0,
- :x64_mingw_20 => tilde_gt_2_0_0,
- :x64_mingw_21 => tilde_gt_2_1_0,
+ jruby: gt_eq_0,
+ jruby_18: tilde_gt_1_8_0,
+ jruby_19: tilde_gt_1_9_0,
+ maglev: gt_eq_0,
+ mingw: gt_eq_0,
+ mingw_18: tilde_gt_1_8_0,
+ mingw_19: tilde_gt_1_9_0,
+ mingw_20: tilde_gt_2_0_0,
+ mingw_21: tilde_gt_2_1_0,
+ mri: gt_eq_0,
+ mri_18: tilde_gt_1_8_0,
+ mri_19: tilde_gt_1_9_0,
+ mri_20: tilde_gt_2_0_0,
+ mri_21: tilde_gt_2_1_0,
+ mswin: gt_eq_0,
+ mswin_18: tilde_gt_1_8_0,
+ mswin_19: tilde_gt_1_9_0,
+ mswin_20: tilde_gt_2_0_0,
+ mswin_21: tilde_gt_2_1_0,
+ mswin64: gt_eq_0,
+ mswin64_19: tilde_gt_1_9_0,
+ mswin64_20: tilde_gt_2_0_0,
+ mswin64_21: tilde_gt_2_1_0,
+ rbx: gt_eq_0,
+ ruby: gt_eq_0,
+ ruby_18: tilde_gt_1_8_0,
+ ruby_19: tilde_gt_1_9_0,
+ ruby_20: tilde_gt_2_0_0,
+ ruby_21: tilde_gt_2_1_0,
+ truffleruby: gt_eq_0,
+ x64_mingw: gt_eq_0,
+ x64_mingw_20: tilde_gt_2_0_0,
+ x64_mingw_21: tilde_gt_2_1_0,
}.freeze
WINDOWS = { # :nodoc:
- :mingw => :only,
- :mingw_18 => :only,
- :mingw_19 => :only,
- :mingw_20 => :only,
- :mingw_21 => :only,
- :mri => :never,
- :mri_18 => :never,
- :mri_19 => :never,
- :mri_20 => :never,
- :mri_21 => :never,
- :mswin => :only,
- :mswin_18 => :only,
- :mswin_19 => :only,
- :mswin_20 => :only,
- :mswin_21 => :only,
- :mswin64 => :only,
- :mswin64_19 => :only,
- :mswin64_20 => :only,
- :mswin64_21 => :only,
- :rbx => :never,
- :ruby => :never,
- :ruby_18 => :never,
- :ruby_19 => :never,
- :ruby_20 => :never,
- :ruby_21 => :never,
- :x64_mingw => :only,
- :x64_mingw_20 => :only,
- :x64_mingw_21 => :only,
+ mingw: :only,
+ mingw_18: :only,
+ mingw_19: :only,
+ mingw_20: :only,
+ mingw_21: :only,
+ mri: :never,
+ mri_18: :never,
+ mri_19: :never,
+ mri_20: :never,
+ mri_21: :never,
+ mswin: :only,
+ mswin_18: :only,
+ mswin_19: :only,
+ mswin_20: :only,
+ mswin_21: :only,
+ mswin64: :only,
+ mswin64_19: :only,
+ mswin64_20: :only,
+ mswin64_21: :only,
+ rbx: :never,
+ ruby: :never,
+ ruby_18: :never,
+ ruby_19: :never,
+ ruby_20: :never,
+ ruby_21: :never,
+ x64_mingw: :only,
+ x64_mingw_20: :only,
+ x64_mingw_21: :only,
}.freeze
##
@@ -261,7 +262,7 @@ class Gem::RequestSet::GemDependencyAPI
raise ArgumentError, "no gemspecs found at #{Dir.pwd}"
else
raise ArgumentError,
- "found multiple gemspecs at #{Dir.pwd}, " +
+ "found multiple gemspecs at #{Dir.pwd}, " \
"use the name: option to specify the one you want"
end
end
@@ -279,7 +280,7 @@ class Gem::RequestSet::GemDependencyAPI
# Loads the gem dependency file and returns self.
def load
- instance_eval File.read(@path).tap(&Gem::UNTAINT), @path, 1
+ instance_eval File.read(@path), @path, 1
self
end
@@ -329,7 +330,7 @@ class Gem::RequestSet::GemDependencyAPI
# git: ::
# Install this dependency from a git repository:
#
- # gem 'private_gem', git: git@my.company.example:private_gem.git'
+ # gem 'private_gem', git: 'git@my.company.example:private_gem.git'
#
# gist: ::
# Install this dependency from the gist ID:
@@ -789,15 +790,15 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
return true if @installing
- unless RUBY_VERSION == version
- message = "Your Ruby version is #{RUBY_VERSION}, " +
+ unless version == RUBY_VERSION
+ message = "Your Ruby version is #{RUBY_VERSION}, " \
"but your #{gem_deps_file} requires #{version}"
raise Gem::RubyVersionMismatch, message
end
if engine && engine != Gem.ruby_engine
- message = "Your Ruby engine is #{Gem.ruby_engine}, " +
+ message = "Your Ruby engine is #{Gem.ruby_engine}, " \
"but your #{gem_deps_file} requires #{engine}"
raise Gem::RubyVersionMismatch, message
@@ -806,14 +807,14 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
if engine_version
if engine_version != RUBY_ENGINE_VERSION
message =
- "Your Ruby engine version is #{Gem.ruby_engine} #{RUBY_ENGINE_VERSION}, " +
+ "Your Ruby engine version is #{Gem.ruby_engine} #{RUBY_ENGINE_VERSION}, " \
"but your #{gem_deps_file} requires #{engine} #{engine_version}"
raise Gem::RubyVersionMismatch, message
end
end
- return true
+ true
end
##
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index 3ba202f661..8b9c9690d6 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Parses a gem.deps.rb.lock file and constructs a LockSet containing the
# dependencies found inside. If the lock file is missing no LockSet is
@@ -37,7 +38,7 @@ class Gem::RequestSet::Lockfile
end
##
- # Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
+ # Creates a new Lockfile for the given Gem::RequestSet and +gem_deps_file+
# location.
def self.build(request_set, gem_deps_file, dependencies = nil)
@@ -75,18 +76,13 @@ class Gem::RequestSet::Lockfile
@dependencies = dependencies
@gem_deps_file = File.expand_path(gem_deps_file)
@gem_deps_dir = File.dirname(@gem_deps_file)
-
- if RUBY_VERSION < "2.7"
- @gem_deps_file.untaint unless gem_deps_file.tainted?
- end
-
@platforms = []
end
def add_DEPENDENCIES(out) # :nodoc:
out << "DEPENDENCIES"
- out.concat @dependencies.sort_by {|name,| name }.map {|name, requirement|
+ out.concat @dependencies.sort.map {|name, requirement|
" #{name}#{requirement.for_lockfile}"
}
@@ -105,10 +101,10 @@ class Gem::RequestSet::Lockfile
out << " remote: #{group}"
out << " specs:"
- requests.sort_by {|request| request.name }.each do |request|
+ requests.sort_by(&:name).each do |request|
next if request.spec.name == "bundler"
platform = "-#{request.spec.platform}" unless
- Gem::Platform::RUBY == request.spec.platform
+ request.spec.platform == Gem::Platform::RUBY
out << " #{request.name} (#{request.version}#{platform})"
@@ -137,10 +133,10 @@ class Gem::RequestSet::Lockfile
out << " revision: #{revision}"
out << " specs:"
- requests.sort_by {|request| request.name }.each do |request|
+ requests.sort_by(&:name).each do |request|
out << " #{request.name} (#{request.version})"
- dependencies = request.spec.dependencies.sort_by {|dep| dep.name }
+ dependencies = request.spec.dependencies.sort_by(&:name)
dependencies.each do |dep|
out << " #{dep.name}#{dep.requirement.for_lockfile}"
end
@@ -184,7 +180,7 @@ class Gem::RequestSet::Lockfile
platforms = requests.map {|request| request.spec.platform }.uniq
- platforms = platforms.sort_by {|platform| platform.to_s }
+ platforms = platforms.sort_by(&:to_s)
platforms.each do |platform|
out << " #{platform}"
@@ -235,5 +231,3 @@ class Gem::RequestSet::Lockfile
@set.sorted_requests
end
end
-
-require_relative "lockfile/tokenizer"
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
deleted file mode 100644
index 2d98c9520b..0000000000
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ /dev/null
@@ -1,343 +0,0 @@
-# frozen_string_literal: true
-class Gem::RequestSet::Lockfile::Parser
- ###
- # Parses lockfiles
-
- def initialize(tokenizer, set, platforms, filename = nil)
- @tokens = tokenizer
- @filename = filename
- @set = set
- @platforms = platforms
- end
-
- def parse
- until @tokens.empty? do
- token = get
-
- case token.type
- when :section then
- @tokens.skip :newline
-
- case token.value
- when "DEPENDENCIES" then
- parse_DEPENDENCIES
- when "GIT" then
- parse_GIT
- when "GEM" then
- parse_GEM
- when "PATH" then
- parse_PATH
- when "PLATFORMS" then
- parse_PLATFORMS
- else
- token = get until @tokens.empty? || peek.first == :section
- end
- else
- raise "BUG: unhandled token #{token.type} (#{token.value.inspect}) at line #{token.line} column #{token.column}"
- end
- end
- end
-
- ##
- # Gets the next token for a Lockfile
-
- def get(expected_types = nil, expected_value = nil) # :nodoc:
- token = @tokens.shift
-
- if expected_types && !Array(expected_types).include?(token.type)
- unget token
-
- message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
- "expected #{expected_types.inspect}"
-
- raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
- end
-
- if expected_value && expected_value != token.value
- unget token
-
- message = "unexpected token [#{token.type.inspect}, #{token.value.inspect}], " +
- "expected [#{expected_types.inspect}, " +
- "#{expected_value.inspect}]"
-
- raise Gem::RequestSet::Lockfile::ParseError.new message, token.column, token.line, @filename
- end
-
- token
- end
-
- def parse_DEPENDENCIES # :nodoc:
- while !@tokens.empty? && :text == peek.type do
- token = get :text
-
- requirements = []
-
- case peek[0]
- when :bang then
- get :bang
-
- requirements << pinned_requirement(token.value)
- when :l_paren then
- get :l_paren
-
- loop do
- op = get(:requirement).value
- version = get(:text).value
-
- requirements << "#{op} #{version}"
-
- break unless peek.type == :comma
-
- get :comma
- end
-
- get :r_paren
-
- if peek[0] == :bang
- requirements.clear
- requirements << pinned_requirement(token.value)
-
- get :bang
- end
- end
-
- @set.gem token.value, *requirements
-
- skip :newline
- end
- end
-
- def parse_GEM # :nodoc:
- sources = []
-
- while [:entry, "remote"] == peek.first(2) do
- get :entry, "remote"
- data = get(:text).value
- skip :newline
-
- sources << Gem::Source.new(data)
- end
-
- sources << Gem::Source.new(Gem::DEFAULT_HOST) if sources.empty?
-
- get :entry, "specs"
-
- skip :newline
-
- set = Gem::Resolver::LockSet.new sources
- last_specs = nil
-
- while !@tokens.empty? && :text == peek.type do
- token = get :text
- name = token.value
- column = token.column
-
- case peek[0]
- when :newline then
- last_specs.each do |spec|
- spec.add_dependency Gem::Dependency.new name if column == 6
- end
- when :l_paren then
- get :l_paren
-
- token = get [:text, :requirement]
- type = token.type
- data = token.value
-
- if type == :text && column == 4
- version, platform = data.split "-", 2
-
- platform =
- platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
-
- last_specs = set.add name, version, platform
- else
- dependency = parse_dependency name, data
-
- last_specs.each do |spec|
- spec.add_dependency dependency
- end
- end
-
- get :r_paren
- else
- raise "BUG: unknown token #{peek}"
- end
-
- skip :newline
- end
-
- @set.sets << set
- end
-
- def parse_GIT # :nodoc:
- get :entry, "remote"
- repository = get(:text).value
-
- skip :newline
-
- get :entry, "revision"
- revision = get(:text).value
-
- skip :newline
-
- type = peek.type
- value = peek.value
- if type == :entry && %w[branch ref tag].include?(value)
- get
- get :text
-
- skip :newline
- end
-
- get :entry, "specs"
-
- skip :newline
-
- set = Gem::Resolver::GitSet.new
- set.root_dir = @set.install_dir
-
- last_spec = nil
-
- while !@tokens.empty? && :text == peek.type do
- token = get :text
- name = token.value
- column = token.column
-
- case peek[0]
- when :newline then
- last_spec.add_dependency Gem::Dependency.new name if column == 6
- when :l_paren then
- get :l_paren
-
- token = get [:text, :requirement]
- type = token.type
- data = token.value
-
- if type == :text && column == 4
- last_spec = set.add_git_spec name, data, repository, revision, true
- else
- dependency = parse_dependency name, data
-
- last_spec.add_dependency dependency
- end
-
- get :r_paren
- else
- raise "BUG: unknown token #{peek}"
- end
-
- skip :newline
- end
-
- @set.sets << set
- end
-
- def parse_PATH # :nodoc:
- get :entry, "remote"
- directory = get(:text).value
-
- skip :newline
-
- get :entry, "specs"
-
- skip :newline
-
- set = Gem::Resolver::VendorSet.new
- last_spec = nil
-
- while !@tokens.empty? && :text == peek.first do
- token = get :text
- name = token.value
- column = token.column
-
- case peek[0]
- when :newline then
- last_spec.add_dependency Gem::Dependency.new name if column == 6
- when :l_paren then
- get :l_paren
-
- token = get [:text, :requirement]
- type = token.type
- data = token.value
-
- if type == :text && column == 4
- last_spec = set.add_vendor_gem name, directory
- else
- dependency = parse_dependency name, data
-
- last_spec.dependencies << dependency
- end
-
- get :r_paren
- else
- raise "BUG: unknown token #{peek}"
- end
-
- skip :newline
- end
-
- @set.sets << set
- end
-
- def parse_PLATFORMS # :nodoc:
- while !@tokens.empty? && :text == peek.first do
- name = get(:text).value
-
- @platforms << name
-
- skip :newline
- end
- end
-
- ##
- # Parses the requirements following the dependency +name+ and the +op+ for
- # the first token of the requirements and returns a Gem::Dependency object.
-
- def parse_dependency(name, op) # :nodoc:
- return Gem::Dependency.new name, op unless peek[0] == :text
-
- version = get(:text).value
-
- requirements = ["#{op} #{version}"]
-
- while peek.type == :comma do
- get :comma
- op = get(:requirement).value
- version = get(:text).value
-
- requirements << "#{op} #{version}"
- end
-
- Gem::Dependency.new name, requirements
- end
-
- private
-
- def skip(type) # :nodoc:
- @tokens.skip type
- end
-
- ##
- # Peeks at the next token for Lockfile
-
- def peek # :nodoc:
- @tokens.peek
- end
-
- def pinned_requirement(name) # :nodoc:
- requirement = Gem::Dependency.new name
- specification = @set.sets.flat_map do |set|
- set.find_all(requirement)
- end.compact.first
-
- specification&.version
- end
-
- ##
- # Ungets the last token retrieved by #get
-
- def unget(token) # :nodoc:
- @tokens.unshift token
- end
-end
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
deleted file mode 100644
index 59163e8cfb..0000000000
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# ) frozen_string_literal: true
-require_relative "parser"
-
-class Gem::RequestSet::Lockfile::Tokenizer
- Token = Struct.new :type, :value, :column, :line
- EOF = Token.new :EOF
-
- def self.from_file(file)
- new File.read(file), file
- end
-
- def initialize(input, filename = nil, line = 0, pos = 0)
- @line = line
- @line_pos = pos
- @tokens = []
- @filename = filename
- tokenize input
- end
-
- def make_parser(set, platforms)
- Gem::RequestSet::Lockfile::Parser.new self, set, platforms, @filename
- end
-
- def to_a
- @tokens.map {|token| [token.type, token.value, token.column, token.line] }
- end
-
- def skip(type)
- @tokens.shift while !@tokens.empty? && peek.type == type
- end
-
- ##
- # Calculates the column (by byte) and the line of the current token based on
- # +byte_offset+.
-
- def token_pos(byte_offset) # :nodoc:
- [byte_offset - @line_pos, @line]
- end
-
- def empty?
- @tokens.empty?
- end
-
- def unshift(token)
- @tokens.unshift token
- end
-
- def next_token
- @tokens.shift
- end
- alias_method :shift, :next_token
-
- def peek
- @tokens.first || EOF
- end
-
- private
-
- def tokenize(input)
- require "strscan"
- s = StringScanner.new input
-
- until s.eos? do
- pos = s.pos
-
- pos = s.pos if leading_whitespace = s.scan(/ +/)
-
- if s.scan(/[<|=>]{7}/)
- message = "your #{@filename} contains merge conflict markers"
- column, line = token_pos pos
-
- raise Gem::RequestSet::Lockfile::ParseError.new message, column, line, @filename
- end
-
- @tokens <<
- case
- when s.scan(/\r?\n/) then
- token = Token.new(:newline, nil, *token_pos(pos))
- @line_pos = s.pos
- @line += 1
- token
- when s.scan(/[A-Z]+/) then
- if leading_whitespace
- text = s.matched
- text += s.scan(/[^\s)]*/).to_s # in case of no match
- Token.new(:text, text, *token_pos(pos))
- else
- Token.new(:section, s.matched, *token_pos(pos))
- end
- when s.scan(/([a-z]+):\s/) then
- s.pos -= 1 # rewind for possible newline
- Token.new(:entry, s[1], *token_pos(pos))
- when s.scan(/\(/) then
- Token.new(:l_paren, nil, *token_pos(pos))
- when s.scan(/\)/) then
- Token.new(:r_paren, nil, *token_pos(pos))
- when s.scan(/<=|>=|=|~>|<|>|!=/) then
- Token.new(:requirement, s.matched, *token_pos(pos))
- when s.scan(/,/) then
- Token.new(:comma, nil, *token_pos(pos))
- when s.scan(/!/) then
- Token.new(:bang, nil, *token_pos(pos))
- when s.scan(/[^\s),!]*/) then
- Token.new(:text, s.matched, *token_pos(pos))
- else
- raise "BUG: can't create token for: #{s.string[s.pos..-1].inspect}"
- end
- end
-
- @tokens
- end
-end
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index ccdf2e50fe..0d3f98eb0f 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "version"
##
@@ -12,8 +13,8 @@ class Gem::Requirement
OPS = { # :nodoc:
"=" => 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 },
"<=" => lambda {|v, r| v <= r },
"~>" => lambda {|v, r| v >= r && v.release < r.bump },
@@ -21,13 +22,13 @@ class Gem::Requirement
SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
- quoted = OPS.keys.map {|k| Regexp.quote k }.join "|"
- PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
+ quoted = Regexp.union(OPS.keys)
+ PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*".freeze # :nodoc:
##
# A regular expression that matches a requirement
- PATTERN = /\A#{PATTERN_RAW}\z/.freeze
+ PATTERN = /\A#{PATTERN_RAW}\z/
##
# The default requirement matches any non-prerelease version
@@ -105,13 +106,15 @@ class Gem::Requirement
unless PATTERN =~ obj.to_s
raise BadRequirementError, "Illformed requirement [#{obj.inspect}]"
end
+ op = -($1 || "=")
+ version = -$2
- if $1 == ">=" && $2 == "0"
+ if op == ">=" && version == "0"
DefaultRequirement
- elsif $1 == ">=" && $2 == "0.a"
+ elsif op == ">=" && version == "0.a"
DefaultPrereleaseRequirement
else
- [-($1 || "="), Gem::Version.new($2)]
+ [op, Gem::Version.new(version)]
end
end
@@ -155,7 +158,7 @@ class Gem::Requirement
# Formats this requirement for use in a Gem::RequestSet::Lockfile.
def for_lockfile # :nodoc:
- return if [DefaultRequirement] == @requirements
+ return if @requirements == [DefaultRequirement]
list = requirements.sort_by do |_, version|
version
@@ -200,7 +203,8 @@ class Gem::Requirement
def marshal_load(array) # :nodoc:
@requirements = array[0]
- raise TypeError, "wrong @requirements" unless Array === @requirements
+ raise TypeError, "wrong @requirements" unless Array === @requirements &&
+ @requirements.all? {|r| r.size == 2 && (r.first.is_a?(String) || r[0] = "=") && r.last.is_a?(Gem::Version) }
end
def yaml_initialize(tag, vals) # :nodoc:
@@ -213,10 +217,6 @@ class Gem::Requirement
yaml_initialize coder.tag, coder.map
end
- def to_yaml_properties # :nodoc:
- ["@requirements"]
- end
-
def encode_with(coder) # :nodoc:
coder.add "requirements", @requirements
end
@@ -241,7 +241,7 @@ class Gem::Requirement
def satisfied_by?(version)
raise ArgumentError, "Need a Gem::Version: #{version.inspect}" unless
Gem::Version === version
- requirements.all? {|op, rv| OPS[op].call version, rv }
+ requirements.all? {|op, rv| OPS.fetch(op).call version, rv }
end
alias_method :===, :satisfied_by?
@@ -283,6 +283,11 @@ class Gem::Requirement
def _tilde_requirements
@_tilde_requirements ||= _sorted_requirements.select {|r| r.first == "~>" }
end
+
+ def initialize_copy(other) # :nodoc:
+ @requirements = other.requirements.dup
+ super
+ end
end
class Gem::Version
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 76d1e9d0cc..788206c056 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
+
require_relative "dependency"
require_relative "exceptions"
-require_relative "util/list"
##
# Given a set of Gem::Dependency objects as +needed+ and a way to query the
@@ -10,7 +10,7 @@ require_relative "util/list"
# all the requirements.
class Gem::Resolver
- require_relative "resolver/molinillo"
+ require_relative "vendored_pub_grub"
##
# If the DEBUG_RESOLVER environment variable is set then debugging mode is
@@ -35,21 +35,13 @@ class Gem::Resolver
attr_accessor :ignore_dependencies
##
- # List of dependencies that could not be found in the configured sources.
-
- attr_reader :missing
-
- attr_reader :stats
-
- ##
# Hash of gems to skip resolution. Keyed by gem name, with arrays of
# gem specifications as values.
attr_accessor :skip_gems
##
- # When a missing dependency, don't stop. Just go on and record what was
- # missing.
+ #
attr_accessor :soft_missing
@@ -61,7 +53,7 @@ class Gem::Resolver
def self.compose_sets(*sets)
sets.compact!
- sets = sets.map do |set|
+ sets = sets.flat_map do |set|
case set
when Gem::Resolver::BestSet then
set
@@ -70,7 +62,7 @@ class Gem::Resolver
else
set
end
- end.flatten
+ end
case sets.length
when 0 then
@@ -105,225 +97,451 @@ class Gem::Resolver
@development = false
@development_shallow = false
@ignore_dependencies = false
- @missing = []
@skip_gems = {}
@soft_missing = false
- @stats = Gem::Resolver::Stats.new
- end
- def explain(stage, *data) # :nodoc:
- return unless DEBUG_RESOLVER
+ @root_package = RootPackage.new
+ @root_version = Gem::PubGrub::Package.root_version
+
+ @packages = {}
- d = data.map {|x| x.pretty_inspect }.join(", ")
- $stderr.printf "%10s %s\n", stage.to_s.upcase, d
+ @unfiltered_specs = Hash.new {|h, name| h[name] = find_unfiltered_specs_for(name) }
+ @all_specs = Hash.new {|h, name| h[name] = filter_specs(@unfiltered_specs[name]) }
+ @all_versions = Hash.new {|h, pkg| h[pkg] = @all_specs[pkg.to_s].map(&:version).uniq.sort }
+ @sorted_versions = Hash.new do |h, pkg|
+ h[pkg] = Gem::PubGrub::Package.root?(pkg) ? [@root_version] : @all_versions[pkg]
+ end
+ @cached_dependencies = Hash.new do |h, pkg|
+ h[pkg] = if Gem::PubGrub::Package.root?(pkg)
+ { @root_version => root_dependencies }
+ else
+ Hash.new {|v, ver| v[ver] = compute_dependencies(pkg, ver) }
+ end
+ end
+ @version_to_index = Hash.new {|h, pkg| h[pkg] = @sorted_versions[pkg].each_with_index.to_h }
+ @versions_for_cache = Hash.new {|h, pkg| h[pkg] = {} }
+ @spec_for_cache = Hash.new {|h, name| h[name] = build_spec_for_cache(name) }
end
- def explain_list(stage) # :nodoc:
- return unless DEBUG_RESOLVER
+ ##
+ # Proceed with resolution! Returns an array of ActivationRequest objects.
+
+ def resolve
+ # Pre-check: raise UnsatisfiableDependencyError for root deps with no
+ # platform match. We filter by platform ONLY here (not required_ruby_version
+ # / required_rubygems_version): a foreign-platform gem is genuinely "not
+ # found", but a gem that exists yet is incompatible with the running Ruby
+ # should flow through the solver to a DependencyResolutionError that names
+ # the Ruby requirement. That matches Bundler (which models Ruby as a
+ # synthetic dependency, so this surfaces as a solve failure) and gives a
+ # clearer message than the platform-oriented UnsatisfiableDependencyError.
+ @needed.each do |dep|
+ next if @soft_missing
+ dep_request = DependencyRequest.new(dep, nil)
+ all = @set.find_all(dep_request)
+ matching = select_local_platforms(all)
+
+ next unless matching.empty?
+
+ exc = Gem::UnsatisfiableDependencyError.new(dep_request, all)
+ exc.errors = @set.errors
+ raise exc
+ end
- data = yield
- $stderr.printf "%10s (%d entries)\n", stage.to_s.upcase, data.size
- unless data.empty?
- require "pp"
- PP.pp data, $stderr
+ solver = Gem::PubGrub::VersionSolver.new(
+ source: self,
+ root: @root_package,
+ strategy: Gem::Resolver::Strategy.new(self),
+ logger: make_logger
+ )
+ result = solver.solve
+
+ # Convert to Array<ActivationRequest>
+ needed_by_name = @needed.group_by(&:name)
+ result.filter_map do |package, version|
+ next if Gem::PubGrub::Package.root?(package)
+ spec = spec_for(package.to_s, version)
+ dep = needed_by_name[package.to_s]&.first || Gem::Dependency.new(package.to_s)
+ dep_request = DependencyRequest.new(dep, nil)
+ ActivationRequest.new(spec, dep_request)
+ end
+ rescue Gem::PubGrub::SolveFailure => e
+ extended = extract_extended_explanation(e.incompatibility)
+ if extended
+ message = "#{e.explanation}\n\n#{extended}"
+ raise Gem::DependencyResolutionError, Struct.new(:explanation).new(message)
+ else
+ raise Gem::DependencyResolutionError, e
end
end
- ##
- # Creates an ActivationRequest for the given +dep+ and the last +possible+
- # specification.
- #
- # Returns the Specification and the ActivationRequest
+ # PubGrub source interface methods
+
+ def all_versions_for(package)
+ versions = @sorted_versions[package].reverse # highest first
+ name = package.to_s
+
+ if (skip_dep_gems = skip_gems[name]) && !skip_dep_gems.empty?
+ # Conservative mode: float the already-installed (skip) versions to the
+ # front so the solver prefers them. This sets *preference* only (it feeds
+ # the strategy's version-index map); it does not restrict availability, so
+ # every version stays selectable via versions_for. When an installed
+ # version is made impossible by a downstream conflict, the solver
+ # backtracks to a newer version instead of failing. Molinillo instead
+ # hard-restricted the candidate set to skip versions and raised.
+ #
+ # This reaches the same outcome as Bundler (upgrade-over-raise) for the
+ # common single-blocked-gem case, though the mechanism differs: Bundler
+ # hard-pins locked gems and selectively unlocks + re-solves on conflict,
+ # whereas we float as a preference and let PubGrub backtrack in one solve.
+ # The float can therefore over-upgrade when several installed gems are
+ # jointly involved in a conflict; that outcome-level divergence is
+ # accepted (see test_conservative_upgrades_when_installed_blocked).
+ skip_versions = skip_dep_gems.map(&:version)
+ preferred, rest = versions.partition {|v| skip_versions.include?(v) }
+ preferred + rest
+ else
+ # Prefer already-installed versions to avoid unnecessary upgrades
+ installed_versions = @all_specs[name].
+ select {|s| s.is_a?(Gem::Resolver::InstalledSpecification) }.
+ map(&:version)
+ if installed_versions.any?
+ preferred, rest = versions.partition {|v| installed_versions.include?(v) }
+ preferred + rest
+ else
+ versions
+ end
+ end
+ end
- def activation_request(dep, possible) # :nodoc:
- spec = possible.pop
+ def versions_for(package, range = Gem::PubGrub::VersionRange.any)
+ @versions_for_cache[package][range] ||= begin
+ candidates = range.select_versions(@sorted_versions[package])
- explain :activate, [spec.full_name, possible.size]
- explain :possible, possible
+ if Gem::PubGrub::Package.root?(package) ||
+ (@set.respond_to?(:prerelease) && @set.prerelease) ||
+ range_admits_prerelease?(range)
+ candidates
+ elsif @all_versions[package].any? {|v| !v.prerelease? }
+ candidates.reject(&:prerelease?)
+ else
+ # Only prereleases exist for this gem; fall back to them so
+ # dependencies like `>= 1.0` can still be satisfied.
+ candidates
+ end
+ end
+ end
+
+ def no_versions_incompatibility_for(_package, unsatisfied_term)
+ cause = Gem::PubGrub::Incompatibility::NoVersions.new(unsatisfied_term)
+
+ name = unsatisfied_term.package.to_s
+ constraint = unsatisfied_term.constraint
+ extended_explanation = build_extended_explanation(name, constraint)
- activation_request =
- Gem::Resolver::ActivationRequest.new spec, dep, possible
+ custom_explanation = if extended_explanation
+ "#{constraint} could not be found in any repository"
+ end
- return spec, activation_request
+ Gem::Resolver::Incompatibility.new(
+ [unsatisfied_term],
+ cause: cause,
+ custom_explanation: custom_explanation,
+ extended_explanation: extended_explanation
+ )
end
- def requests(s, act, reqs=[]) # :nodoc:
- return reqs if @ignore_dependencies
+ def incompatibilities_for(package, version)
+ package_deps = @cached_dependencies[package]
+ sorted_versions = @sorted_versions[package]
+ package_deps[version].filter_map do |dep_package_name, dep_constraint|
+ dep_package = dep_constraint.package
- s.fetch_development_dependencies if @development
+ low = high = @version_to_index[package][version]
- s.dependencies.reverse_each do |d|
- next if d.type == :development && !@development
- next if d.type == :development && @development_shallow &&
- act.development?
- next if d.type == :development && @development_shallow &&
- act.parent
+ # find version low such that all >= low share the same dep
+ while low > 0 &&
+ package_deps[sorted_versions[low - 1]][dep_package_name] == dep_constraint
+ low -= 1
+ end
+ low =
+ if low == 0
+ nil
+ else
+ sorted_versions[low]
+ end
+
+ # find version high such that all < high share the same dep
+ while high < sorted_versions.length &&
+ package_deps[sorted_versions[high]][dep_package_name] == dep_constraint
+ high += 1
+ end
+ high =
+ if high == sorted_versions.length
+ nil
+ else
+ sorted_versions[high]
+ end
+
+ range = Gem::PubGrub::VersionRange.new(min: low, max: high, include_min: !low.nil?)
+ self_constraint = Gem::PubGrub::VersionConstraint.new(package, range: range)
+
+ # No specs anywhere means an unknown package. Check @unfiltered_specs, not
+ # the filtered set, so a dep filtered out by platform/Ruby/prerelease falls
+ # through to NoVersions for proper hints instead. The band-scoped
+ # self_constraint lets clean sibling versions still resolve via backtracking.
+ if @unfiltered_specs[dep_package_name].empty?
+ cause = Gem::PubGrub::Incompatibility::InvalidDependency.new(dep_package, dep_constraint)
+ self_term = Gem::PubGrub::Term.new(self_constraint, true)
+ # PubGrub's default InvalidDependency rendering drops the version
+ # requirement ("depends on unknown package bar"). Supply a custom
+ # explanation so the missing dependency's constraint is preserved
+ # ("depends on bar = 0.5 which could not be found in any repository"),
+ # matching Molinillo's diagnostics.
+ return [Gem::PubGrub::Incompatibility.new(
+ [self_term],
+ cause: cause,
+ custom_explanation: "#{self_term.to_s(allow_every: true)} depends on #{dep_constraint} which could not be found in any repository"
+ )]
+ end
+
+ # An empty range means the requirement is self-contradictory (e.g. `> 2, < 1`).
+ if dep_constraint.range.empty?
+ return [Gem::Resolver::Incompatibility.new(
+ [Gem::PubGrub::Term.new(self_constraint, true)],
+ cause: Gem::PubGrub::Incompatibility::NoVersions.new(dep_constraint),
+ custom_explanation: "#{dep_package_name} cannot satisfy contradictory requirements #{dep_constraint.constraint_string}"
+ )]
+ end
- reqs << Gem::Resolver::DependencyRequest.new(d, act)
- @stats.requirement!
+ Gem::PubGrub::Incompatibility.new(
+ [Gem::PubGrub::Term.new(self_constraint, true), Gem::PubGrub::Term.new(dep_constraint, false)],
+ cause: :dependency
+ )
end
+ end
+
+ ##
+ # Returns the gems in +specs+ that match the local platform.
- @set.prefetch reqs
+ def select_local_platforms(specs) # :nodoc:
+ specs.select do |spec|
+ Gem::Platform.installable? spec
+ end
+ end
- @stats.record_requirements reqs
+ private
- reqs
+ def package_for(name)
+ @packages[name] ||= Gem::PubGrub::Package.new(name)
end
- include Molinillo::UI
+ def root_dependencies
+ deps = {}
+ @needed.each do |dep|
+ constraint = Gem::PubGrub::RubyGems.requirement_to_constraint(package_for(dep.name), dep.requirement)
+ deps[dep.name] = deps.key?(dep.name) ? deps[dep.name].intersect(constraint) : constraint
+ end
+ deps
+ end
- def output
- @output ||= debug? ? $stdout : File.open(IO::NULL, "w")
+ # Only the min bound is inspected: `~>` synthesises a max like `X.A`
+ # whose suffix looks prerelease to Gem::Version but is not the user's
+ # intent, so checking max would mis-admit prereleases for every `~>`.
+ def range_admits_prerelease?(range)
+ range.ranges.any? do |r|
+ next false if r.empty?
+ r.min&.prerelease?
+ end
end
- def debug?
- DEBUG_RESOLVER
+ def find_unfiltered_specs_for(name)
+ dep = Gem::Dependency.new(name, ">= 0.a")
+ dep_request = DependencyRequest.new(dep, nil)
+ @set.find_all(dep_request)
end
- include Molinillo::SpecificationProvider
+ def filter_specs(specs)
+ filtered = select_local_platforms(specs)
- ##
- # Proceed with resolution! Returns an array of ActivationRequest objects.
+ unless @soft_missing
+ filtered = filtered.select do |s|
+ s.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
+ s.required_rubygems_version.satisfied_by?(Gem.rubygems_version)
+ rescue StandardError
+ true
+ end
+ end
- def resolve
- locking_dg = Molinillo::DependencyGraph.new
- Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }, locking_dg).tsort.map(&:payload).compact
- rescue Molinillo::VersionConflict => e
- conflict = e.conflicts.values.first
- raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)
- ensure
- @output.close if defined?(@output) && !debug?
+ filtered
end
- ##
- # Extracts the specifications that may be able to fulfill +dependency+ and
- # returns those that match the local platform and all those that match.
+ def spec_for(name, version)
+ @spec_for_cache[name][version]
+ end
- def find_possible(dependency) # :nodoc:
- all = @set.find_all dependency
+ def build_spec_for_cache(name)
+ # Rank sources by the order they were first supplied so that, when multiple
+ # sources offer the same version and platform, the earlier source wins.
+ source_rank = {}
+ @all_specs[name].each do |s|
+ source_rank[s.source] ||= source_rank.size
+ end
- if (skip_dep_gems = skip_gems[dependency.name]) && !skip_dep_gems.empty?
- matching = all.select do |api_spec|
- skip_dep_gems.any? {|s| api_spec.version == s.version }
- end
+ @all_specs[name].group_by(&:version).transform_values do |candidates|
+ next candidates.first if candidates.length == 1
- all = matching unless matching.empty?
+ # Prefer already-installed specs to avoid unnecessary downloads
+ installed = candidates.select {|s| s.is_a?(Gem::Resolver::InstalledSpecification) }
+ next installed.first if installed.length == 1
+ candidates = installed if installed.any?
+
+ # Among remaining candidates, prefer the most specific platform, then the
+ # earlier-supplied source.
+ candidates.min_by do |s|
+ [Gem::Platform.platform_specificity_match(s.platform, Gem::Platform.local),
+ source_rank[s.source]]
+ end
end
+ end
- matching_platform = select_local_platforms all
+ def compute_dependencies(package, version)
+ spec = spec_for(package.to_s, version)
+ return {} unless spec
+ return {} if @ignore_dependencies
- return matching_platform, all
- end
+ spec.fetch_development_dependencies if @development && spec.respond_to?(:fetch_development_dependencies)
- ##
- # Returns the gems in +specs+ that match the local platform.
+ deps = {}
+ root_names = @needed.map(&:name)
- def select_local_platforms(specs) # :nodoc:
- specs.select do |spec|
- Gem::Platform.installable? spec
+ spec.dependencies.each do |d|
+ next if d.name == package.to_s
+ next if d.type == :development && !@development
+ next if d.type == :development && @development_shallow && !root_names.include?(package.to_s)
+
+ dep_package = package_for(d.name)
+
+ # In force mode, skip deps that can't be satisfied - either no
+ # specs at all, or no specs matching the version requirement.
+ if @soft_missing
+ dep_specs = @all_specs[d.name]
+ matching = dep_specs.select {|s| d.requirement.satisfied_by?(s.version) }
+ next if matching.empty?
+ end
+
+ deps[d.name] = Gem::PubGrub::RubyGems.requirement_to_constraint(dep_package, d.requirement)
end
+
+ deps
end
- def search_for(dependency)
- possibles, all = find_possible(dependency)
- if !@soft_missing && possibles.empty?
- @missing << dependency
- exc = Gem::UnsatisfiableDependencyError.new dependency, all
- exc.errors = @set.errors
- raise exc
- end
+ def build_extended_explanation(name, constraint)
+ unfiltered = @unfiltered_specs[name]
+ return if unfiltered.empty?
+
+ filtered = @all_specs[name]
+ pkg = package_for(name)
- groups = Hash.new {|hash, key| hash[key] = [] }
+ # A prerelease hint applies when the source would strip prereleases for
+ # this constraint (global prerelease flag off and the constraint's range
+ # doesn't itself reach into prerelease territory) AND a prerelease of
+ # the gem exists somewhere.
+ prerelease_gated = !(@set.respond_to?(:prerelease) && @set.prerelease) &&
+ !range_admits_prerelease?(constraint.range)
+ has_prerelease_candidate = prerelease_gated &&
+ @all_versions[pkg].any?(&:prerelease?)
- # create groups & sources in the same loop
- sources = possibles.map do |spec|
- source = spec.source
- groups[source] << spec
- source
- end.uniq.reverse
+ return if filtered.length == unfiltered.length && !has_prerelease_candidate
- activation_requests = []
+ hints = []
- sources.each do |source|
- groups[source].
- sort_by {|spec| [spec.version, spec.platform =~ Gem::Platform.local ? 1 : 0] }.
- map {|spec| ActivationRequest.new spec, dependency }.
- each {|activation_request| activation_requests << activation_request }
+ # Check for specs that exist for other platforms
+ platform_specs = unfiltered.select do |s|
+ !Gem::Platform.installable?(s) && constraint.range.include?(s.version)
+ end
+ if platform_specs.any?
+ label = "#{name} (#{constraint.constraint_string})"
+ hints << "The source contains the following gems matching '#{label}':"
+ platform_specs.each do |s|
+ actual = s.respond_to?(:spec) ? s.spec : s
+ hints << " * #{actual.full_name}"
+ end
end
- activation_requests
- end
+ # Check for specs filtered by Ruby version
+ installable = select_local_platforms(unfiltered)
+ ruby_specs = installable.select do |s|
+ actual = s.respond_to?(:spec) ? s.spec : s
+ constraint.range.include?(s.version) &&
+ !actual.required_ruby_version.satisfied_by?(Gem.ruby_version)
+ rescue StandardError
+ false
+ end
+ if ruby_specs.any?
+ versions = ruby_specs.map(&:version).uniq.sort.reverse.first(3)
+ sample = ruby_specs.find {|s| s.version == versions.first }
+ actual = sample.respond_to?(:spec) ? sample.spec : sample
+ ruby_req = actual.required_ruby_version
+ hints << "#{name} #{versions.join(", ")} requires Ruby #{ruby_req} (you have #{Gem.ruby_version})"
+ end
- def dependencies_for(specification)
- return [] if @ignore_dependencies
- spec = specification.spec
- requests(spec, specification)
+ # Check for specs filtered by prerelease status
+ if prerelease_gated
+ prerelease_versions = @all_versions[pkg].select(&:prerelease?)
+ if prerelease_versions.any?
+ versions = prerelease_versions.sort.reverse.first(3) # limit to avoid cluttering error output
+ hints << "#{name} #{versions.join(", ")} are pre-release versions. Use --prerelease to allow pre-release gems."
+ end
+ end
+
+ hints.empty? ? nil : hints.join("\n")
end
- def requirement_satisfied_by?(requirement, activated, spec)
- matches_spec = requirement.matches_spec? spec
- return matches_spec if @soft_missing
+ def extract_extended_explanation(incompatibility)
+ while incompatibility.cause.is_a?(Gem::PubGrub::Incompatibility::ConflictCause)
+ cause = incompatibility.cause
- matches_spec &&
- spec.spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
- spec.spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version)
- end
+ [cause.conflict, cause.other].each do |incompat|
+ if incompat.cause.is_a?(Gem::PubGrub::Incompatibility::NoVersions) &&
+ incompat.respond_to?(:extended_explanation) &&
+ incompat.extended_explanation
+ return incompat.extended_explanation
+ end
+ end
+
+ incompatibility = cause.conflict
+ end
- def name_for(dependency)
- dependency.name
+ nil
end
- def allow_missing?(dependency)
- @missing << dependency
- @soft_missing
+ def make_logger
+ DEBUG_RESOLVER ? Gem::PubGrub::StderrLogger.new : Gem::PubGrub::NullLogger.new
end
- def sort_dependencies(dependencies, activated, conflicts)
- dependencies.sort_by.with_index do |dependency, i|
- name = name_for(dependency)
- [
- activated.vertex_named(name).payload ? 0 : 1,
- amount_constrained(dependency),
- conflicts[name] ? 0 : 1,
- activated.vertex_named(name).payload ? 0 : search_for(dependency).count,
- i, # for stable sort
- ]
+ # Custom root package so error messages say "your request depends on..."
+ # instead of PubGrub's default "root depends on...".
+ class RootPackage < Gem::PubGrub::Package
+ def initialize
+ super(:root)
end
- end
- SINGLE_POSSIBILITY_CONSTRAINT_PENALTY = 1_000_000
- private_constant :SINGLE_POSSIBILITY_CONSTRAINT_PENALTY if defined?(private_constant)
+ def root?
+ true
+ end
- # returns an integer \in (-\infty, 0]
- # a number closer to 0 means the dependency is less constraining
- #
- # dependencies w/ 0 or 1 possibilities (ignoring version requirements)
- # are given very negative values, so they _always_ sort first,
- # before dependencies that are unconstrained
- def amount_constrained(dependency)
- @amount_constrained ||= {}
- @amount_constrained[dependency.name] ||= begin
- name_dependency = Gem::Dependency.new(dependency.name)
- dependency_request_for_name = Gem::Resolver::DependencyRequest.new(name_dependency, dependency.requester)
- all = @set.find_all(dependency_request_for_name).size
-
- if all <= 1
- all - SINGLE_POSSIBILITY_CONSTRAINT_PENALTY
- else
- search = search_for(dependency).size
- search - all
- end
+ def to_s
+ "your request"
end
end
- private :amount_constrained
end
require_relative "resolver/activation_request"
-require_relative "resolver/conflict"
require_relative "resolver/dependency_request"
+require_relative "resolver/incompatibility"
+require_relative "resolver/strategy"
require_relative "resolver/requirement_list"
-require_relative "resolver/stats"
-
require_relative "resolver/set"
require_relative "resolver/api_set"
require_relative "resolver/composed_set"
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index 27877e0f4b..5c722001b1 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Specifies a Specification object that should be activated. Also contains a
# dependency that was used to introduce this activation.
@@ -58,10 +59,8 @@ class Gem::Resolver::ActivationRequest
if @spec.respond_to? :sources
exception = nil
path = @spec.sources.find do |source|
- begin
- source.download full_spec, path
- rescue exception
- end
+ source.download full_spec, path
+ rescue exception
end
return path if path
raise exception if exception
@@ -93,9 +92,7 @@ class Gem::Resolver::ActivationRequest
end
def inspect # :nodoc:
- "#<%s for %p from %s>" % [
- self.class, @spec, @request
- ]
+ format("#<%s for %p from %s>", self.class, @spec, @request)
end
##
@@ -109,7 +106,7 @@ class Gem::Resolver::ActivationRequest
this_spec = full_spec
Gem::Specification.any? do |s|
- s == this_spec
+ s == this_spec && s.base_dir == this_spec.base_dir
end
end
end
diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb
index f8f14ff9fa..3f443519d8 100644
--- a/lib/rubygems/resolver/api_set.rb
+++ b/lib/rubygems/resolver/api_set.rb
@@ -1,13 +1,14 @@
# frozen_string_literal: true
+
##
-# The global rubygems pool, available via the rubygems.org API.
+# The global rubygems pool, available via the Compact Index API.
# Returns instances of APISpecification.
class Gem::Resolver::APISet < Gem::Resolver::Set
autoload :GemParser, File.expand_path("api_set/gem_parser", __dir__)
##
- # The URI for the dependency API this APISet uses.
+ # The URI for the Compact Index API this APISet uses.
attr_reader :dep_uri # :nodoc:
@@ -22,14 +23,14 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
attr_reader :uri
##
- # Creates a new APISet that will retrieve gems from +uri+ using the RubyGems
- # API URL +dep_uri+ which is described at
- # https://guides.rubygems.org/rubygems-org-api
+ # Creates a new APISet that will retrieve gems from +uri+ using the Compact
+ # Index API URL +dep_uri+ which is described at
+ # https://guides.rubygems.org/rubygems-org-compact-index-api
def initialize(dep_uri = "https://index.rubygems.org/info/")
super()
- dep_uri = URI dep_uri unless URI === dep_uri
+ dep_uri = Gem::URI dep_uri unless Gem::URI === dep_uri
@dep_uri = dep_uri
@uri = dep_uri + ".."
@@ -103,16 +104,21 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
end
uri = @dep_uri + name
- str = Gem::RemoteFetcher.fetcher.fetch_path uri
- lines(str).each do |ver|
- number, platform, dependencies, requirements = parse_gem(ver)
+ begin
+ str = Gem::RemoteFetcher.fetcher.fetch_path uri
+ rescue Gem::RemoteFetcher::FetchError
+ @data[name] = []
+ else
+ lines(str).each do |ver|
+ number, platform, dependencies, requirements = parse_gem(ver)
- platform ||= "ruby"
- dependencies = dependencies.map {|dep_name, reqs| [dep_name, reqs.join(", ")] }
- requirements = requirements.map {|req_name, reqs| [req_name.to_sym, reqs] }.to_h
+ platform ||= "ruby"
+ dependencies = dependencies.map {|dep_name, reqs| [dep_name, reqs.join(", ")] }
+ requirements = requirements.map {|req_name, reqs| [req_name.to_sym, reqs] }.to_h
- @data[name] << { name: name, number: number, platform: platform, dependencies: dependencies, requirements: requirements }
+ @data[name] << { name: name, number: number, platform: platform, dependencies: dependencies, requirements: requirements }
+ end
end
@data[name]
diff --git a/lib/rubygems/resolver/api_set/gem_parser.rb b/lib/rubygems/resolver/api_set/gem_parser.rb
index 685c39558d..4d827f4980 100644
--- a/lib/rubygems/resolver/api_set/gem_parser.rb
+++ b/lib/rubygems/resolver/api_set/gem_parser.rb
@@ -4,17 +4,18 @@ class Gem::Resolver::APISet::GemParser
def parse(line)
version_and_platform, rest = line.split(" ", 2)
version, platform = version_and_platform.split("-", 2)
- dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest
- dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : []
- requirements = requirements ? requirements.map {|d| parse_dependency(d) } : []
+ dependencies, requirements = rest.split("|", 2).map! {|s| s.split(",") } if rest
+ dependencies = dependencies ? dependencies.map! {|d| parse_dependency(d) } : []
+ requirements = requirements ? requirements.map! {|d| parse_dependency(d) } : []
[version, platform, dependencies, requirements]
end
private
def parse_dependency(string)
- dependency = string.split(":")
+ dependency = string.split(":", 2)
dependency[-1] = dependency[-1].split("&") if dependency.size > 1
+ dependency[0] = -dependency[0]
dependency
end
end
diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb
index 1e65d5e5a9..ccfd6fe084 100644
--- a/lib/rubygems/resolver/api_specification.rb
+++ b/lib/rubygems/resolver/api_specification.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
##
-# Represents a specification retrieved via the rubygems.org API.
+# Represents a specification retrieved via the Compact Index API.
#
# This is used to avoid loading the full Specification object when all we need
# is the name, version, and dependencies.
@@ -18,10 +19,10 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
end
##
- # Creates an APISpecification for the given +set+ from the rubygems.org
+ # Creates an APISpecification for the given +set+ from the Compact Index API
# +api_data+.
#
- # See https://guides.rubygems.org/rubygems-org-api/#misc_methods for the
+ # See https://guides.rubygems.org/rubygems-org-compact-index-api for the
# format of the +api_data+.
def initialize(set, api_data)
diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
index 075ee1ef5c..e647a2c11b 100644
--- a/lib/rubygems/resolver/best_set.rb
+++ b/lib/rubygems/resolver/best_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The BestSet chooses the best available method to query a remote index.
#
@@ -20,7 +21,7 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
def pick_sets # :nodoc:
@sources.each_source do |source|
- @sets << source.dependency_resolver_set
+ @sets << source.dependency_resolver_set(@prerelease)
end
end
@@ -28,10 +29,6 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
pick_sets if @remote && @sets.empty?
super
- rescue Gem::RemoteFetcher::FetchError => e
- replace_failed_api_set e
-
- retry
end
def prefetch(reqs) # :nodoc:
@@ -49,28 +46,4 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
q.pp @sets
end
end
-
- ##
- # Replaces a failed APISet for the URI in +error+ with an IndexSet.
- #
- # If no matching APISet can be found the original +error+ is raised.
- #
- # The calling method must retry the exception to repeat the lookup.
-
- def replace_failed_api_set(error) # :nodoc:
- uri = error.original_uri
- uri = URI uri unless URI === uri
- uri = uri + "."
-
- raise error unless api_set = @sets.find do |set|
- Gem::Resolver::APISet === set && set.dep_uri == uri
- end
-
- index_set = Gem::Resolver::IndexSet.new api_set.source
-
- @sets.map! do |set|
- next set unless set == api_set
- index_set
- end
- end
end
diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb
index 226da1e1e0..e67dd41754 100644
--- a/lib/rubygems/resolver/composed_set.rb
+++ b/lib/rubygems/resolver/composed_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A ComposedSet allows multiple sets to be queried like a single set.
#
@@ -43,16 +44,16 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
end
def errors
- @errors + @sets.map {|set| set.errors }.flatten
+ @errors + @sets.flat_map(&:errors)
end
##
# Finds all specs matching +req+ in all sets.
def find_all(req)
- @sets.map do |s|
+ @sets.flat_map do |s|
s.find_all req
- end.flatten
+ end
end
##
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
deleted file mode 100644
index fa0d3f089e..0000000000
--- a/lib/rubygems/resolver/conflict.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-# frozen_string_literal: true
-##
-# Used internally to indicate that a dependency conflicted
-# with a spec that would be activated.
-
-class Gem::Resolver::Conflict
- ##
- # The specification that was activated prior to the conflict
-
- attr_reader :activated
-
- ##
- # The dependency that is in conflict with the activated gem.
-
- attr_reader :dependency
-
- attr_reader :failed_dep # :nodoc:
-
- ##
- # Creates a new resolver conflict when +dependency+ is in conflict with an
- # already +activated+ specification.
-
- def initialize(dependency, activated, failed_dep=dependency)
- @dependency = dependency
- @activated = activated
- @failed_dep = failed_dep
- end
-
- def ==(other) # :nodoc:
- self.class === other &&
- @dependency == other.dependency &&
- @activated == other.activated &&
- @failed_dep == other.failed_dep
- end
-
- ##
- # A string explanation of the conflict.
-
- def explain
- "<Conflict wanted: #{@failed_dep}, had: #{activated.spec.full_name}>"
- end
-
- ##
- # Return the 2 dependency objects that conflicted
-
- def conflicting_dependencies
- [@failed_dep.dependency, @activated.request.dependency]
- end
-
- ##
- # Explanation of the conflict used by exceptions to print useful messages
-
- def explanation
- activated = @activated.spec.full_name
- dependency = @failed_dep.dependency
- requirement = dependency.requirement
- alternates = dependency.matching_specs.map {|spec| spec.full_name }
-
- unless alternates.empty?
- matching = <<-MATCHING.chomp
-
- Gems matching %s:
- %s
- MATCHING
-
- matching = matching % [
- dependency,
- alternates.join(", "),
- ]
- end
-
- explanation = <<-EXPLANATION
- Activated %s
- which does not match conflicting dependency (%s)
-
- Conflicting dependency chains:
- %s
-
- versus:
- %s
-%s
- EXPLANATION
-
- explanation % [
- activated, requirement,
- request_path(@activated).reverse.join(", depends on\n "),
- request_path(@failed_dep).reverse.join(", depends on\n "),
- matching
- ]
- end
-
- ##
- # Returns true if the conflicting dependency's name matches +spec+.
-
- def for_spec?(spec)
- @dependency.name == spec.name
- end
-
- def pretty_print(q) # :nodoc:
- q.group 2, "[Dependency conflict: ", "]" do
- q.breakable
-
- q.text "activated "
- q.pp @activated
-
- q.breakable
- q.text " dependency "
- q.pp @dependency
-
- q.breakable
- if @dependency == @failed_dep
- q.text " failed"
- else
- q.text " failed dependency "
- q.pp @failed_dep
- end
- end
- end
-
- ##
- # Path of activations from the +current+ list.
-
- def request_path(current)
- path = []
-
- while current do
- case current
- when Gem::Resolver::ActivationRequest then
- path <<
- "#{current.request.dependency}, #{current.spec.version} activated"
-
- current = current.parent
- when Gem::Resolver::DependencyRequest then
- path << current.dependency.to_s
-
- current = current.requester
- else
- raise Gem::Exception, "[BUG] unknown request class #{current.class}"
- end
- end
-
- path = ["user request (gem command or Gemfile)"] if path.empty?
-
- path
- end
-
- ##
- # Return the Specification that listed the dependency
-
- def requester
- @failed_dep.requester
- end
-end
diff --git a/lib/rubygems/resolver/current_set.rb b/lib/rubygems/resolver/current_set.rb
index c3aa3a2c37..370e445089 100644
--- a/lib/rubygems/resolver/current_set.rb
+++ b/lib/rubygems/resolver/current_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A set which represents the installed gems. Respects
# all the normal settings that control where to look
diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb
index 70a61cbc25..60b338277f 100644
--- a/lib/rubygems/resolver/dependency_request.rb
+++ b/lib/rubygems/resolver/dependency_request.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Used Internally. Wraps a Dependency object to also track which spec
# contained the Dependency.
diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb
index f010273a8f..2912378fe7 100644
--- a/lib/rubygems/resolver/git_set.rb
+++ b/lib/rubygems/resolver/git_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A GitSet represents gems that are sourced from git repositories.
#
@@ -35,7 +36,6 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
def initialize # :nodoc:
super()
- @git = ENV["git"] || "git"
@need_submodules = {}
@repositories = {}
@root_dir = Gem.dir
diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb
index 6a178ea82e..e587c17d2a 100644
--- a/lib/rubygems/resolver/git_specification.rb
+++ b/lib/rubygems/resolver/git_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A GitSpecification represents a gem that is sourced from a git repository
# and is being loaded through a gem dependencies file through the +git:+
diff --git a/lib/rubygems/resolver/incompatibility.rb b/lib/rubygems/resolver/incompatibility.rb
new file mode 100644
index 0000000000..57a60affb4
--- /dev/null
+++ b/lib/rubygems/resolver/incompatibility.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class Gem::Resolver::Incompatibility < Gem::PubGrub::Incompatibility
+ attr_reader :extended_explanation
+
+ def initialize(terms, cause:, custom_explanation: nil, extended_explanation: nil)
+ @extended_explanation = extended_explanation
+ super(terms, cause: cause, custom_explanation: custom_explanation)
+ end
+end
diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb
index 61f3c14e4f..cddaf8773f 100644
--- a/lib/rubygems/resolver/index_set.rb
+++ b/lib/rubygems/resolver/index_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The global rubygems pool represented via the traditional
# source index.
@@ -43,11 +44,10 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
name = req.dependency.name
@all[name].each do |uri, n|
- if req.match? n, @prerelease
- res << Gem::Resolver::IndexSpecification.new(
- self, n.name, n.version, uri, n.platform
- )
- end
+ next unless req.match? n, @prerelease
+ res << Gem::Resolver::IndexSpecification.new(
+ self, n.name, n.version, uri, n.platform
+ )
end
res
@@ -65,11 +65,11 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
q.breakable
- names = @all.values.map do |tuples|
+ names = @all.values.flat_map do |tuples|
tuples.map do |_, tuple|
tuple.full_name
end
- end.flatten
+ end
q.seplist names do |name|
q.text name
diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index 0fc758dfd3..7b95608071 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Represents a possible Specification object returned from IndexSet. Used to
# delay needed to download full Specification objects when only the +name+
@@ -67,7 +68,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
end
def inspect # :nodoc:
- "#<%s %s source %s>" % [self.class, full_name, @source]
+ format("#<%s %s source %s>", self.class, full_name, @source)
end
def pretty_print(q) # :nodoc:
@@ -75,7 +76,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
q.breakable
q.text full_name
- unless Gem::Platform::RUBY == @platform
+ unless @platform == Gem::Platform::RUBY
q.breakable
q.text @platform.to_s
end
diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb
index 7088be390f..8280ae4672 100644
--- a/lib/rubygems/resolver/installed_specification.rb
+++ b/lib/rubygems/resolver/installed_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# An InstalledSpecification represents a gem that is already installed
# locally.
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index 4e794c2ea5..42ce0890e2 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A set of gems for installation sourced from remote sources and local .gem
# files
@@ -147,6 +148,8 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
res << Gem::Resolver::InstalledSpecification.new(self, gemspec)
end unless @ignore_installed
+ matching_local = []
+
if consider_local?
matching_local = @local.values.select do |spec, _|
req.match? spec
@@ -157,7 +160,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
res.concat matching_local
begin
- if local_spec = @local_source.find_gem(name, dep.requirement)
+ @local_source.find_all_gems(name, dep.requirement).each do |local_spec|
res << Gem::Resolver::IndexSpecification.new(
self, local_spec.name, local_spec.version,
@local_source, local_spec.platform
@@ -168,7 +171,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
end
- res.concat @remote_set.find_all req if consider_remote?
+ res.concat @remote_set.find_all req if consider_remote? && matching_local.empty?
res
end
@@ -184,11 +187,9 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
def inspect # :nodoc:
- always_install = @always_install.map {|s| s.full_name }
+ always_install = @always_install.map(&:full_name)
- "#<%s domain: %s specs: %p always install: %p>" % [
- self.class, @domain, @specs.keys, always_install
- ]
+ format("#<%s domain: %s specs: %p always install: %p>", self.class, @domain, @specs.keys, always_install)
end
##
@@ -262,7 +263,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
unless rrgv.satisfied_by? Gem.rubygems_version
rg_version = Gem::VERSION
raise Gem::RuntimeRequirementNotMetError,
- "#{spec.full_name} requires RubyGems version #{rrgv}. The current RubyGems version is #{rg_version}. " +
+ "#{spec.full_name} requires RubyGems version #{rrgv}. The current RubyGems version is #{rg_version}. " \
"Try 'gem update --system' to update RubyGems itself."
end
end
diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb
index 1d17c70529..b57d40e795 100644
--- a/lib/rubygems/resolver/local_specification.rb
+++ b/lib/rubygems/resolver/local_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A LocalSpecification comes from a .gem file on the local filesystem.
diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
index b1a5433cb5..e5ee32a9a6 100644
--- a/lib/rubygems/resolver/lock_set.rb
+++ b/lib/rubygems/resolver/lock_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A set of gems from a gem dependencies lockfile.
@@ -74,7 +75,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
q.text "specs:"
q.breakable
- q.pp @specs.map {|spec| spec.full_name }
+ q.pp @specs.map(&:full_name)
end
end
end
diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb
index 7de2a14658..06f912dd85 100644
--- a/lib/rubygems/resolver/lock_specification.rb
+++ b/lib/rubygems/resolver/lock_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile).
#
diff --git a/lib/rubygems/resolver/molinillo.rb b/lib/rubygems/resolver/molinillo.rb
deleted file mode 100644
index e154342571..0000000000
--- a/lib/rubygems/resolver/molinillo.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# frozen_string_literal: true
-require_relative "molinillo/lib/molinillo"
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo.rb b/lib/rubygems/resolver/molinillo/lib/molinillo.rb
deleted file mode 100644
index f67badbde7..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'molinillo/gem_metadata'
-require_relative 'molinillo/errors'
-require_relative 'molinillo/resolver'
-require_relative 'molinillo/modules/ui'
-require_relative 'molinillo/modules/specification_provider'
-
-# Gem::Resolver::Molinillo is a generic dependency resolution algorithm.
-module Gem::Resolver::Molinillo
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb
deleted file mode 100644
index d540d3baff..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # @!visibility private
- module Delegates
- # Delegates all {Gem::Resolver::Molinillo::ResolutionState} methods to a `#state` property.
- module ResolutionState
- # (see Gem::Resolver::Molinillo::ResolutionState#name)
- def name
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.name
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#requirements)
- def requirements
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.requirements
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#activated)
- def activated
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.activated
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#requirement)
- def requirement
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.requirement
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#possibilities)
- def possibilities
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.possibilities
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#depth)
- def depth
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.depth
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#conflicts)
- def conflicts
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.conflicts
- end
-
- # (see Gem::Resolver::Molinillo::ResolutionState#unused_unwind_options)
- def unused_unwind_options
- current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty
- current_state.unused_unwind_options
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb
deleted file mode 100644
index b765226fb0..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- module Delegates
- # Delegates all {Gem::Resolver::Molinillo::SpecificationProvider} methods to a
- # `#specification_provider` property.
- module SpecificationProvider
- # (see Gem::Resolver::Molinillo::SpecificationProvider#search_for)
- def search_for(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.search_for(dependency)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#dependencies_for)
- def dependencies_for(specification)
- with_no_such_dependency_error_handling do
- specification_provider.dependencies_for(specification)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#requirement_satisfied_by?)
- def requirement_satisfied_by?(requirement, activated, spec)
- with_no_such_dependency_error_handling do
- specification_provider.requirement_satisfied_by?(requirement, activated, spec)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#dependencies_equal?)
- def dependencies_equal?(dependencies, other_dependencies)
- with_no_such_dependency_error_handling do
- specification_provider.dependencies_equal?(dependencies, other_dependencies)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#name_for)
- def name_for(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.name_for(dependency)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#name_for_explicit_dependency_source)
- def name_for_explicit_dependency_source
- with_no_such_dependency_error_handling do
- specification_provider.name_for_explicit_dependency_source
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#name_for_locking_dependency_source)
- def name_for_locking_dependency_source
- with_no_such_dependency_error_handling do
- specification_provider.name_for_locking_dependency_source
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#sort_dependencies)
- def sort_dependencies(dependencies, activated, conflicts)
- with_no_such_dependency_error_handling do
- specification_provider.sort_dependencies(dependencies, activated, conflicts)
- end
- end
-
- # (see Gem::Resolver::Molinillo::SpecificationProvider#allow_missing?)
- def allow_missing?(dependency)
- with_no_such_dependency_error_handling do
- specification_provider.allow_missing?(dependency)
- end
- end
-
- private
-
- # Ensures any raised {NoSuchDependencyError} has its
- # {NoSuchDependencyError#required_by} set.
- # @yield
- def with_no_such_dependency_error_handling
- yield
- rescue NoSuchDependencyError => error
- if state
- vertex = activated.vertex_named(name_for(error.dependency))
- error.required_by += vertex.incoming_edges.map { |e| e.origin.name }
- error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty?
- end
- raise
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
deleted file mode 100644
index 731a9e3e90..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-# frozen_string_literal: true
-
-require_relative '../../../../tsort'
-
-require_relative 'dependency_graph/log'
-require_relative 'dependency_graph/vertex'
-
-module Gem::Resolver::Molinillo
- # A directed acyclic graph that is tuned to hold named dependencies
- class DependencyGraph
- include Enumerable
-
- # Enumerates through the vertices of the graph.
- # @return [Array<Vertex>] The graph's vertices.
- def each
- return vertices.values.each unless block_given?
- vertices.values.each { |v| yield v }
- end
-
- include Gem::TSort
-
- # @!visibility private
- alias tsort_each_node each
-
- # @!visibility private
- def tsort_each_child(vertex, &block)
- vertex.successors.each(&block)
- end
-
- # Topologically sorts the given vertices.
- # @param [Enumerable<Vertex>] vertices the vertices to be sorted, which must
- # all belong to the same graph.
- # @return [Array<Vertex>] The sorted vertices.
- def self.tsort(vertices)
- Gem::TSort.tsort(
- lambda { |b| vertices.each(&b) },
- lambda { |v, &b| (v.successors & vertices).each(&b) }
- )
- end
-
- # A directed edge of a {DependencyGraph}
- # @attr [Vertex] origin The origin of the directed edge
- # @attr [Vertex] destination The destination of the directed edge
- # @attr [Object] requirement The requirement the directed edge represents
- Edge = Struct.new(:origin, :destination, :requirement)
-
- # @return [{String => Vertex}] the vertices of the dependency graph, keyed
- # by {Vertex#name}
- attr_reader :vertices
-
- # @return [Log] the op log for this graph
- attr_reader :log
-
- # Initializes an empty dependency graph
- def initialize
- @vertices = {}
- @log = Log.new
- end
-
- # Tags the current state of the dependency as the given tag
- # @param [Object] tag an opaque tag for the current state of the graph
- # @return [Void]
- def tag(tag)
- log.tag(self, tag)
- end
-
- # Rewinds the graph to the state tagged as `tag`
- # @param [Object] tag the tag to rewind to
- # @return [Void]
- def rewind_to(tag)
- log.rewind_to(self, tag)
- end
-
- # Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices}
- # are properly copied.
- # @param [DependencyGraph] other the graph to copy.
- def initialize_copy(other)
- super
- @vertices = {}
- @log = other.log.dup
- traverse = lambda do |new_v, old_v|
- return if new_v.outgoing_edges.size == old_v.outgoing_edges.size
- old_v.outgoing_edges.each do |edge|
- destination = add_vertex(edge.destination.name, edge.destination.payload)
- add_edge_no_circular(new_v, destination, edge.requirement)
- traverse.call(destination, edge.destination)
- end
- end
- other.vertices.each do |name, vertex|
- new_vertex = add_vertex(name, vertex.payload, vertex.root?)
- new_vertex.explicit_requirements.replace(vertex.explicit_requirements)
- traverse.call(new_vertex, vertex)
- end
- end
-
- # @return [String] a string suitable for debugging
- def inspect
- "#{self.class}:#{vertices.values.inspect}"
- end
-
- # @param [Hash] options options for dot output.
- # @return [String] Returns a dot format representation of the graph
- def to_dot(options = {})
- edge_label = options.delete(:edge_label)
- raise ArgumentError, "Unknown options: #{options.keys}" unless options.empty?
-
- dot_vertices = []
- dot_edges = []
- vertices.each do |n, v|
- dot_vertices << " #{n} [label=\"{#{n}|#{v.payload}}\"]"
- v.outgoing_edges.each do |e|
- label = edge_label ? edge_label.call(e) : e.requirement
- dot_edges << " #{e.origin.name} -> #{e.destination.name} [label=#{label.to_s.dump}]"
- end
- end
-
- dot_vertices.uniq!
- dot_vertices.sort!
- dot_edges.uniq!
- dot_edges.sort!
-
- dot = dot_vertices.unshift('digraph G {').push('') + dot_edges.push('}')
- dot.join("\n")
- end
-
- # @param [DependencyGraph] other
- # @return [Boolean] whether the two dependency graphs are equal, determined
- # by a recursive traversal of each {#root_vertices} and its
- # {Vertex#successors}
- def ==(other)
- return false unless other
- return true if equal?(other)
- vertices.each do |name, vertex|
- other_vertex = other.vertex_named(name)
- return false unless other_vertex
- return false unless vertex.payload == other_vertex.payload
- return false unless other_vertex.successors.to_set == vertex.successors.to_set
- end
- end
-
- # @param [String] name
- # @param [Object] payload
- # @param [Array<String>] parent_names
- # @param [Object] requirement the requirement that is requiring the child
- # @return [void]
- def add_child_vertex(name, payload, parent_names, requirement)
- root = !parent_names.delete(nil) { true }
- vertex = add_vertex(name, payload, root)
- vertex.explicit_requirements << requirement if root
- parent_names.each do |parent_name|
- parent_vertex = vertex_named(parent_name)
- add_edge(parent_vertex, vertex, requirement)
- end
- vertex
- end
-
- # Adds a vertex with the given name, or updates the existing one.
- # @param [String] name
- # @param [Object] payload
- # @return [Vertex] the vertex that was added to `self`
- def add_vertex(name, payload, root = false)
- log.add_vertex(self, name, payload, root)
- end
-
- # Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
- # removing any non-root vertices that were orphaned in the process
- # @param [String] name
- # @return [Array<Vertex>] the vertices which have been detached
- def detach_vertex_named(name)
- log.detach_vertex_named(self, name)
- end
-
- # @param [String] name
- # @return [Vertex,nil] the vertex with the given name
- def vertex_named(name)
- vertices[name]
- end
-
- # @param [String] name
- # @return [Vertex,nil] the root vertex with the given name
- def root_vertex_named(name)
- vertex = vertex_named(name)
- vertex if vertex && vertex.root?
- end
-
- # Adds a new {Edge} to the dependency graph
- # @param [Vertex] origin
- # @param [Vertex] destination
- # @param [Object] requirement the requirement that this edge represents
- # @return [Edge] the added edge
- def add_edge(origin, destination, requirement)
- if destination.path_to?(origin)
- raise CircularDependencyError.new(path(destination, origin))
- end
- add_edge_no_circular(origin, destination, requirement)
- end
-
- # Deletes an {Edge} from the dependency graph
- # @param [Edge] edge
- # @return [Void]
- def delete_edge(edge)
- log.delete_edge(self, edge.origin.name, edge.destination.name, edge.requirement)
- end
-
- # Sets the payload of the vertex with the given name
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload
- # @return [Void]
- def set_payload(name, payload)
- log.set_payload(self, name, payload)
- end
-
- private
-
- # Adds a new {Edge} to the dependency graph without checking for
- # circularity.
- # @param (see #add_edge)
- # @return (see #add_edge)
- def add_edge_no_circular(origin, destination, requirement)
- log.add_edge_no_circular(self, origin.name, destination.name, requirement)
- end
-
- # Returns the path between two vertices
- # @raise [ArgumentError] if there is no path between the vertices
- # @param [Vertex] from
- # @param [Vertex] to
- # @return [Array<Vertex>] the shortest path from `from` to `to`
- def path(from, to)
- distances = Hash.new(vertices.size + 1)
- distances[from.name] = 0
- predecessors = {}
- each do |vertex|
- vertex.successors.each do |successor|
- if distances[successor.name] > distances[vertex.name] + 1
- distances[successor.name] = distances[vertex.name] + 1
- predecessors[successor] = vertex
- end
- end
- end
-
- path = [to]
- while before = predecessors[to]
- path << before
- to = before
- break if to == from
- end
-
- unless path.last.equal?(from)
- raise ArgumentError, "There is no path from #{from.name} to #{to.name}"
- end
-
- path.reverse
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
deleted file mode 100644
index cc140031b3..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # An action that modifies a {DependencyGraph} that is reversible.
- # @abstract
- class Action
- # rubocop:disable Lint/UnusedMethodArgument
-
- # @return [Symbol] The name of the action.
- def self.action_name
- raise 'Abstract'
- end
-
- # Performs the action on the given graph.
- # @param [DependencyGraph] graph the graph to perform the action on.
- # @return [Void]
- def up(graph)
- raise 'Abstract'
- end
-
- # Reverses the action on the given graph.
- # @param [DependencyGraph] graph the graph to reverse the action on.
- # @return [Void]
- def down(graph)
- raise 'Abstract'
- end
-
- # @return [Action,Nil] The previous action
- attr_accessor :previous
-
- # @return [Action,Nil] The next action
- attr_accessor :next
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
deleted file mode 100644
index 5570483253..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#add_edge_no_circular)
- class AddEdgeNoCircular < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges << edge
- edge.destination.incoming_edges << edge
- edge
- end
-
- # (see Action#down)
- def down(graph)
- edge = make_edge(graph)
- delete_first(edge.origin.outgoing_edges, edge)
- delete_first(edge.destination.incoming_edges, edge)
- end
-
- # @!group AddEdgeNoCircular
-
- # @return [String] the name of the origin of the edge
- attr_reader :origin
-
- # @return [String] the name of the destination of the edge
- attr_reader :destination
-
- # @return [Object] the requirement that the edge represents
- attr_reader :requirement
-
- # @param [DependencyGraph] graph the graph to find vertices from
- # @return [Edge] The edge this action adds
- def make_edge(graph)
- Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
- end
-
- # Initialize an action to add an edge to a dependency graph
- # @param [String] origin the name of the origin of the edge
- # @param [String] destination the name of the destination of the edge
- # @param [Object] requirement the requirement that the edge represents
- def initialize(origin, destination, requirement)
- @origin = origin
- @destination = destination
- @requirement = requirement
- end
-
- private
-
- def delete_first(array, item)
- return unless index = array.index(item)
- array.delete_at(index)
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
deleted file mode 100644
index f1411d5efa..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#add_vertex)
- class AddVertex < Action # :nodoc:
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- if existing = graph.vertices[name]
- @existing_payload = existing.payload
- @existing_root = existing.root
- end
- vertex = existing || Vertex.new(name, payload)
- graph.vertices[vertex.name] = vertex
- vertex.payload ||= payload
- vertex.root ||= root
- vertex
- end
-
- # (see Action#down)
- def down(graph)
- if defined?(@existing_payload)
- vertex = graph.vertices[name]
- vertex.payload = @existing_payload
- vertex.root = @existing_root
- else
- graph.vertices.delete(name)
- end
- end
-
- # @!group AddVertex
-
- # @return [String] the name of the vertex
- attr_reader :name
-
- # @return [Object] the payload for the vertex
- attr_reader :payload
-
- # @return [Boolean] whether the vertex is root or not
- attr_reader :root
-
- # Initialize an action to add a vertex to a dependency graph
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload for the vertex
- # @param [Boolean] root whether the vertex is root or not
- def initialize(name, payload, root)
- @name = name
- @payload = payload
- @root = root
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
deleted file mode 100644
index 3b48d77a50..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # (see DependencyGraph#delete_edge)
- class DeleteEdge < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :delete_edge
- end
-
- # (see Action#up)
- def up(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges.delete(edge)
- edge.destination.incoming_edges.delete(edge)
- end
-
- # (see Action#down)
- def down(graph)
- edge = make_edge(graph)
- edge.origin.outgoing_edges << edge
- edge.destination.incoming_edges << edge
- edge
- end
-
- # @!group DeleteEdge
-
- # @return [String] the name of the origin of the edge
- attr_reader :origin_name
-
- # @return [String] the name of the destination of the edge
- attr_reader :destination_name
-
- # @return [Object] the requirement that the edge represents
- attr_reader :requirement
-
- # @param [DependencyGraph] graph the graph to find vertices from
- # @return [Edge] The edge this action adds
- def make_edge(graph)
- Edge.new(
- graph.vertex_named(origin_name),
- graph.vertex_named(destination_name),
- requirement
- )
- end
-
- # Initialize an action to add an edge to a dependency graph
- # @param [String] origin_name the name of the origin of the edge
- # @param [String] destination_name the name of the destination of the edge
- # @param [Object] requirement the requirement that the edge represents
- def initialize(origin_name, destination_name, requirement)
- @origin_name = origin_name
- @destination_name = destination_name
- @requirement = requirement
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
deleted file mode 100644
index 92f60d5be8..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#detach_vertex_named
- class DetachVertexNamed < Action
- # @!group Action
-
- # (see Action#name)
- def self.action_name
- :add_vertex
- end
-
- # (see Action#up)
- def up(graph)
- return [] unless @vertex = graph.vertices.delete(name)
-
- removed_vertices = [@vertex]
- @vertex.outgoing_edges.each do |e|
- v = e.destination
- v.incoming_edges.delete(e)
- if !v.root? && v.incoming_edges.empty?
- removed_vertices.concat graph.detach_vertex_named(v.name)
- end
- end
-
- @vertex.incoming_edges.each do |e|
- v = e.origin
- v.outgoing_edges.delete(e)
- end
-
- removed_vertices
- end
-
- # (see Action#down)
- def down(graph)
- return unless @vertex
- graph.vertices[@vertex.name] = @vertex
- @vertex.outgoing_edges.each do |e|
- e.destination.incoming_edges << e
- end
- @vertex.incoming_edges.each do |e|
- e.origin.outgoing_edges << e
- end
- end
-
- # @!group DetachVertexNamed
-
- # @return [String] the name of the vertex to detach
- attr_reader :name
-
- # Initialize an action to detach a vertex from a dependency graph
- # @param [String] name the name of the vertex to detach
- def initialize(name)
- @name = name
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
deleted file mode 100644
index 7aeb8847ec..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'add_edge_no_circular'
-require_relative 'add_vertex'
-require_relative 'delete_edge'
-require_relative 'detach_vertex_named'
-require_relative 'set_payload'
-require_relative 'tag'
-
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # A log for dependency graph actions
- class Log
- # Initializes an empty log
- def initialize
- @current_action = @first_action = nil
- end
-
- # @!macro [new] action
- # {include:DependencyGraph#$0}
- # @param [Graph] graph the graph to perform the action on
- # @param (see DependencyGraph#$0)
- # @return (see DependencyGraph#$0)
-
- # @macro action
- def tag(graph, tag)
- push_action(graph, Tag.new(tag))
- end
-
- # @macro action
- def add_vertex(graph, name, payload, root)
- push_action(graph, AddVertex.new(name, payload, root))
- end
-
- # @macro action
- def detach_vertex_named(graph, name)
- push_action(graph, DetachVertexNamed.new(name))
- end
-
- # @macro action
- def add_edge_no_circular(graph, origin, destination, requirement)
- push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement))
- end
-
- # {include:DependencyGraph#delete_edge}
- # @param [Graph] graph the graph to perform the action on
- # @param [String] origin_name
- # @param [String] destination_name
- # @param [Object] requirement
- # @return (see DependencyGraph#delete_edge)
- def delete_edge(graph, origin_name, destination_name, requirement)
- push_action(graph, DeleteEdge.new(origin_name, destination_name, requirement))
- end
-
- # @macro action
- def set_payload(graph, name, payload)
- push_action(graph, SetPayload.new(name, payload))
- end
-
- # Pops the most recent action from the log and undoes the action
- # @param [DependencyGraph] graph
- # @return [Action] the action that was popped off the log
- def pop!(graph)
- return unless action = @current_action
- unless @current_action = action.previous
- @first_action = nil
- end
- action.down(graph)
- action
- end
-
- extend Enumerable
-
- # @!visibility private
- # Enumerates each action in the log
- # @yield [Action]
- def each
- return enum_for unless block_given?
- action = @first_action
- loop do
- break unless action
- yield action
- action = action.next
- end
- self
- end
-
- # @!visibility private
- # Enumerates each action in the log in reverse order
- # @yield [Action]
- def reverse_each
- return enum_for(:reverse_each) unless block_given?
- action = @current_action
- loop do
- break unless action
- yield action
- action = action.previous
- end
- self
- end
-
- # @macro action
- def rewind_to(graph, tag)
- loop do
- action = pop!(graph)
- raise "No tag #{tag.inspect} found" unless action
- break if action.class.action_name == :tag && action.tag == tag
- end
- end
-
- private
-
- # Adds the given action to the log, running the action
- # @param [DependencyGraph] graph
- # @param [Action] action
- # @return The value returned by `action.up`
- def push_action(graph, action)
- action.previous = @current_action
- @current_action.next = action if @current_action
- @current_action = action
- @first_action ||= action
- action.up(graph)
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
deleted file mode 100644
index 726292a2c3..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#set_payload
- class SetPayload < Action # :nodoc:
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :set_payload
- end
-
- # (see Action#up)
- def up(graph)
- vertex = graph.vertex_named(name)
- @old_payload = vertex.payload
- vertex.payload = payload
- end
-
- # (see Action#down)
- def down(graph)
- graph.vertex_named(name).payload = @old_payload
- end
-
- # @!group SetPayload
-
- # @return [String] the name of the vertex
- attr_reader :name
-
- # @return [Object] the payload for the vertex
- attr_reader :payload
-
- # Initialize an action to add set the payload for a vertex in a dependency
- # graph
- # @param [String] name the name of the vertex
- # @param [Object] payload the payload for the vertex
- def initialize(name, payload)
- @name = name
- @payload = payload
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
deleted file mode 100644
index bfe6fd31f8..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'action'
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # @!visibility private
- # @see DependencyGraph#tag
- class Tag < Action
- # @!group Action
-
- # (see Action.action_name)
- def self.action_name
- :tag
- end
-
- # (see Action#up)
- def up(graph)
- end
-
- # (see Action#down)
- def down(graph)
- end
-
- # @!group Tag
-
- # @return [Object] An opaque tag
- attr_reader :tag
-
- # Initialize an action to tag a state of a dependency graph
- # @param [Object] tag an opaque tag
- def initialize(tag)
- @tag = tag
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb
deleted file mode 100644
index 77114951b2..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- class DependencyGraph
- # A vertex in a {DependencyGraph} that encapsulates a {#name} and a
- # {#payload}
- class Vertex
- # @return [String] the name of the vertex
- attr_accessor :name
-
- # @return [Object] the payload the vertex holds
- attr_accessor :payload
-
- # @return [Array<Object>] the explicit requirements that required
- # this vertex
- attr_reader :explicit_requirements
-
- # @return [Boolean] whether the vertex is considered a root vertex
- attr_accessor :root
- alias root? root
-
- # Initializes a vertex with the given name and payload.
- # @param [String] name see {#name}
- # @param [Object] payload see {#payload}
- def initialize(name, payload)
- @name = name.frozen? ? name : name.dup.freeze
- @payload = payload
- @explicit_requirements = []
- @outgoing_edges = []
- @incoming_edges = []
- end
-
- # @return [Array<Object>] all of the requirements that required
- # this vertex
- def requirements
- (incoming_edges.map(&:requirement) + explicit_requirements).uniq
- end
-
- # @return [Array<Edge>] the edges of {#graph} that have `self` as their
- # {Edge#origin}
- attr_accessor :outgoing_edges
-
- # @return [Array<Edge>] the edges of {#graph} that have `self` as their
- # {Edge#destination}
- attr_accessor :incoming_edges
-
- # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
- # `self` as their {Edge#destination}
- def predecessors
- incoming_edges.map(&:origin)
- end
-
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is a
- # {#descendent?}
- def recursive_predecessors
- _recursive_predecessors
- end
-
- # @param [Set<Vertex>] vertices the set to add the predecessors to
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is a
- # {#descendent?}
- def _recursive_predecessors(vertices = new_vertex_set)
- incoming_edges.each do |edge|
- vertex = edge.origin
- next unless vertices.add?(vertex)
- vertex._recursive_predecessors(vertices)
- end
-
- vertices
- end
- protected :_recursive_predecessors
-
- # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
- # `self` as their {Edge#origin}
- def successors
- outgoing_edges.map(&:destination)
- end
-
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
- # {#ancestor?}
- def recursive_successors
- _recursive_successors
- end
-
- # @param [Set<Vertex>] vertices the set to add the successors to
- # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
- # {#ancestor?}
- def _recursive_successors(vertices = new_vertex_set)
- outgoing_edges.each do |edge|
- vertex = edge.destination
- next unless vertices.add?(vertex)
- vertex._recursive_successors(vertices)
- end
-
- vertices
- end
- protected :_recursive_successors
-
- # @return [String] a string suitable for debugging
- def inspect
- "#{self.class}:#{name}(#{payload.inspect})"
- end
-
- # @return [Boolean] whether the two vertices are equal, determined
- # by a recursive traversal of each {Vertex#successors}
- def ==(other)
- return true if equal?(other)
- shallow_eql?(other) &&
- successors.to_set == other.successors.to_set
- end
-
- # @param [Vertex] other the other vertex to compare to
- # @return [Boolean] whether the two vertices are equal, determined
- # solely by {#name} and {#payload} equality
- def shallow_eql?(other)
- return true if equal?(other)
- other &&
- name == other.name &&
- payload == other.payload
- end
-
- alias eql? ==
-
- # @return [Fixnum] a hash for the vertex based upon its {#name}
- def hash
- name.hash
- end
-
- # Is there a path from `self` to `other` following edges in the
- # dependency graph?
- # @return whether there is a path following edges within this {#graph}
- def path_to?(other)
- _path_to?(other)
- end
-
- alias descendent? path_to?
-
- # @param [Vertex] other the vertex to check if there's a path to
- # @param [Set<Vertex>] visited the vertices of {#graph} that have been visited
- # @return [Boolean] whether there is a path to `other` from `self`
- def _path_to?(other, visited = new_vertex_set)
- return false unless visited.add?(self)
- return true if equal?(other)
- successors.any? { |v| v._path_to?(other, visited) }
- end
- protected :_path_to?
-
- # Is there a path from `other` to `self` following edges in the
- # dependency graph?
- # @return whether there is a path following edges within this {#graph}
- def ancestor?(other)
- other.path_to?(self)
- end
-
- alias is_reachable_from? ancestor?
-
- def new_vertex_set
- require 'set'
- Set.new
- end
- private :new_vertex_set
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
deleted file mode 100644
index 4289902828..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # An error that occurred during the resolution process
- class ResolverError < StandardError; end
-
- # An error caused by searching for a dependency that is completely unknown,
- # i.e. has no versions available whatsoever.
- class NoSuchDependencyError < ResolverError
- # @return [Object] the dependency that could not be found
- attr_accessor :dependency
-
- # @return [Array<Object>] the specifications that depended upon {#dependency}
- attr_accessor :required_by
-
- # Initializes a new error with the given missing dependency.
- # @param [Object] dependency @see {#dependency}
- # @param [Array<Object>] required_by @see {#required_by}
- def initialize(dependency, required_by = [])
- @dependency = dependency
- @required_by = required_by.uniq
- super()
- end
-
- # The error message for the missing dependency, including the specifications
- # that had this dependency.
- def message
- sources = required_by.map { |r| "`#{r}`" }.join(' and ')
- message = "Unable to find a specification for `#{dependency}`"
- message += " depended upon by #{sources}" unless sources.empty?
- message
- end
- end
-
- # An error caused by attempting to fulfil a dependency that was circular
- #
- # @note This exception will be thrown if and only if a {Vertex} is added to a
- # {DependencyGraph} that has a {DependencyGraph::Vertex#path_to?} an
- # existing {DependencyGraph::Vertex}
- class CircularDependencyError < ResolverError
- # [Set<Object>] the dependencies responsible for causing the error
- attr_reader :dependencies
-
- # Initializes a new error with the given circular vertices.
- # @param [Array<DependencyGraph::Vertex>] vertices the vertices in the dependency
- # that caused the error
- def initialize(vertices)
- super "There is a circular dependency between #{vertices.map(&:name).join(' and ')}"
- @dependencies = vertices.map { |vertex| vertex.payload.possibilities.last }.to_set
- end
- end
-
- # An error caused by conflicts in version
- class VersionConflict < ResolverError
- # @return [{String => Resolution::Conflict}] the conflicts that caused
- # resolution to fail
- attr_reader :conflicts
-
- # @return [SpecificationProvider] the specification provider used during
- # resolution
- attr_reader :specification_provider
-
- # Initializes a new error with the given version conflicts.
- # @param [{String => Resolution::Conflict}] conflicts see {#conflicts}
- # @param [SpecificationProvider] specification_provider see {#specification_provider}
- def initialize(conflicts, specification_provider)
- pairs = []
- conflicts.values.flat_map(&:requirements).each do |conflicting|
- conflicting.each do |source, conflict_requirements|
- conflict_requirements.each do |c|
- pairs << [c, source]
- end
- end
- end
-
- super "Unable to satisfy the following requirements:\n\n" \
- "#{pairs.map { |r, d| "- `#{r}` required by `#{d}`" }.join("\n")}"
-
- @conflicts = conflicts
- @specification_provider = specification_provider
- end
-
- require_relative 'delegates/specification_provider'
- include Delegates::SpecificationProvider
-
- # @return [String] An error message that includes requirement trees,
- # which is much more detailed & customizable than the default message
- # @param [Hash] opts the options to create a message with.
- # @option opts [String] :solver_name The user-facing name of the solver
- # @option opts [String] :possibility_type The generic name of a possibility
- # @option opts [Proc] :reduce_trees A proc that reduced the list of requirement trees
- # @option opts [Proc] :printable_requirement A proc that pretty-prints requirements
- # @option opts [Proc] :additional_message_for_conflict A proc that appends additional
- # messages for each conflict
- # @option opts [Proc] :version_for_spec A proc that returns the version number for a
- # possibility
- def message_with_trees(opts = {})
- solver_name = opts.delete(:solver_name) { self.class.name.split('::').first }
- possibility_type = opts.delete(:possibility_type) { 'possibility named' }
- reduce_trees = opts.delete(:reduce_trees) { proc { |trees| trees.uniq.sort_by(&:to_s) } }
- printable_requirement = opts.delete(:printable_requirement) { proc { |req| req.to_s } }
- additional_message_for_conflict = opts.delete(:additional_message_for_conflict) { proc {} }
- version_for_spec = opts.delete(:version_for_spec) { proc(&:to_s) }
- incompatible_version_message_for_conflict = opts.delete(:incompatible_version_message_for_conflict) do
- proc do |name, _conflict|
- %(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
- end
- end
-
- full_message_for_conflict = opts.delete(:full_message_for_conflict) do
- proc do |name, conflict|
- o = "\n".dup << incompatible_version_message_for_conflict.call(name, conflict) << "\n"
- if conflict.locked_requirement
- o << %( In snapshot (#{name_for_locking_dependency_source}):\n)
- o << %( #{printable_requirement.call(conflict.locked_requirement)}\n)
- o << %(\n)
- end
- o << %( In #{name_for_explicit_dependency_source}:\n)
- trees = reduce_trees.call(conflict.requirement_trees)
-
- o << trees.map do |tree|
- t = ''.dup
- depth = 2
- tree.each do |req|
- t << ' ' * depth << printable_requirement.call(req)
- unless tree.last == req
- if spec = conflict.activated_by_name[name_for(req)]
- t << %( was resolved to #{version_for_spec.call(spec)}, which)
- end
- t << %( depends on)
- end
- t << %(\n)
- depth += 1
- end
- t
- end.join("\n")
-
- additional_message_for_conflict.call(o, name, conflict)
-
- o
- end
- end
-
- conflicts.sort.reduce(''.dup) do |o, (name, conflict)|
- o << full_message_for_conflict.call(name, conflict)
- end.strip
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
deleted file mode 100644
index 86c249c404..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # The version of Gem::Resolver::Molinillo.
- VERSION = '0.8.0'.freeze
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
deleted file mode 100644
index 1067bf7439..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # Provides information about specifications and dependencies to the resolver,
- # allowing the {Resolver} class to remain generic while still providing power
- # and flexibility.
- #
- # This module contains the methods that users of Gem::Resolver::Molinillo must to implement,
- # using knowledge of their own model classes.
- module SpecificationProvider
- # Search for the specifications that match the given dependency.
- # The specifications in the returned array will be considered in reverse
- # order, so the latest version ought to be last.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `dependency` parameter.
- #
- # @param [Object] dependency
- # @return [Array<Object>] the specifications that satisfy the given
- # `dependency`.
- def search_for(dependency)
- []
- end
-
- # Returns the dependencies of `specification`.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `specification` parameter.
- #
- # @param [Object] specification
- # @return [Array<Object>] the dependencies that are required by the given
- # `specification`.
- def dependencies_for(specification)
- []
- end
-
- # Determines whether the given `requirement` is satisfied by the given
- # `spec`, in the context of the current `activated` dependency graph.
- #
- # @param [Object] requirement
- # @param [DependencyGraph] activated the current dependency graph in the
- # resolution process.
- # @param [Object] spec
- # @return [Boolean] whether `requirement` is satisfied by `spec` in the
- # context of the current `activated` dependency graph.
- def requirement_satisfied_by?(requirement, activated, spec)
- true
- end
-
- # Determines whether two arrays of dependencies are equal, and thus can be
- # grouped.
- #
- # @param [Array<Object>] dependencies
- # @param [Array<Object>] other_dependencies
- # @return [Boolean] whether `dependencies` and `other_dependencies` should
- # be considered equal.
- def dependencies_equal?(dependencies, other_dependencies)
- dependencies == other_dependencies
- end
-
- # Returns the name for the given `dependency`.
- # @note This method should be 'pure', i.e. the return value should depend
- # only on the `dependency` parameter.
- #
- # @param [Object] dependency
- # @return [String] the name for the given `dependency`.
- def name_for(dependency)
- dependency.to_s
- end
-
- # @return [String] the name of the source of explicit dependencies, i.e.
- # those passed to {Resolver#resolve} directly.
- def name_for_explicit_dependency_source
- 'user-specified dependency'
- end
-
- # @return [String] the name of the source of 'locked' dependencies, i.e.
- # those passed to {Resolver#resolve} directly as the `base`
- def name_for_locking_dependency_source
- 'Lockfile'
- end
-
- # Sort dependencies so that the ones that are easiest to resolve are first.
- # Easiest to resolve is (usually) defined by:
- # 1) Is this dependency already activated?
- # 2) How relaxed are the requirements?
- # 3) Are there any conflicts for this dependency?
- # 4) How many possibilities are there to satisfy this dependency?
- #
- # @param [Array<Object>] dependencies
- # @param [DependencyGraph] activated the current dependency graph in the
- # resolution process.
- # @param [{String => Array<Conflict>}] conflicts
- # @return [Array<Object>] a sorted copy of `dependencies`.
- def sort_dependencies(dependencies, activated, conflicts)
- dependencies.sort_by do |dependency|
- name = name_for(dependency)
- [
- activated.vertex_named(name).payload ? 0 : 1,
- conflicts[name] ? 0 : 1,
- ]
- end
- end
-
- # Returns whether this dependency, which has no possible matching
- # specifications, can safely be ignored.
- #
- # @param [Object] dependency
- # @return [Boolean] whether this dependency can safely be skipped.
- def allow_missing?(dependency)
- false
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
deleted file mode 100644
index a810fd519c..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # Conveys information about the resolution process to a user.
- module UI
- # The {IO} object that should be used to print output. `STDOUT`, by default.
- #
- # @return [IO]
- def output
- STDOUT
- end
-
- # Called roughly every {#progress_rate}, this method should convey progress
- # to the user.
- #
- # @return [void]
- def indicate_progress
- output.print '.' unless debug?
- end
-
- # How often progress should be conveyed to the user via
- # {#indicate_progress}, in seconds. A third of a second, by default.
- #
- # @return [Float]
- def progress_rate
- 0.33
- end
-
- # Called before resolution begins.
- #
- # @return [void]
- def before_resolution
- output.print 'Resolving dependencies...'
- end
-
- # Called after resolution ends (either successfully or with an error).
- # By default, prints a newline.
- #
- # @return [void]
- def after_resolution
- output.puts
- end
-
- # Conveys debug information to the user.
- #
- # @param [Integer] depth the current depth of the resolution process.
- # @return [void]
- def debug(depth = 0)
- if debug?
- debug_info = yield
- debug_info = debug_info.inspect unless debug_info.is_a?(String)
- debug_info = debug_info.split("\n").map { |s| ":#{depth.to_s.rjust 4}: #{s}" }
- output.puts debug_info
- end
- end
-
- # Whether or not debug messages should be printed.
- # By default, whether or not the `MOLINILLO_DEBUG` environment variable is
- # set.
- #
- # @return [Boolean]
- def debug?
- return @debug_mode if defined?(@debug_mode)
- @debug_mode = ENV['MOLINILLO_DEBUG']
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
deleted file mode 100644
index 8b40e59e42..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
+++ /dev/null
@@ -1,839 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- class Resolver
- # A specific resolution from a given {Resolver}
- class Resolution
- # A conflict that the resolution process encountered
- # @attr [Object] requirement the requirement that immediately led to the conflict
- # @attr [{String,Nil=>[Object]}] requirements the requirements that caused the conflict
- # @attr [Object, nil] existing the existing spec that was in conflict with
- # the {#possibility}
- # @attr [Object] possibility_set the set of specs that was unable to be
- # activated due to a conflict.
- # @attr [Object] locked_requirement the relevant locking requirement.
- # @attr [Array<Array<Object>>] requirement_trees the different requirement
- # trees that led to every requirement for the conflicting name.
- # @attr [{String=>Object}] activated_by_name the already-activated specs.
- # @attr [Object] underlying_error an error that has occurred during resolution, and
- # will be raised at the end of it if no resolution is found.
- Conflict = Struct.new(
- :requirement,
- :requirements,
- :existing,
- :possibility_set,
- :locked_requirement,
- :requirement_trees,
- :activated_by_name,
- :underlying_error
- )
-
- class Conflict
- # @return [Object] a spec that was unable to be activated due to a conflict
- def possibility
- possibility_set && possibility_set.latest_version
- end
- end
-
- # A collection of possibility states that share the same dependencies
- # @attr [Array] dependencies the dependencies for this set of possibilities
- # @attr [Array] possibilities the possibilities
- PossibilitySet = Struct.new(:dependencies, :possibilities)
-
- class PossibilitySet
- # String representation of the possibility set, for debugging
- def to_s
- "[#{possibilities.join(', ')}]"
- end
-
- # @return [Object] most up-to-date dependency in the possibility set
- def latest_version
- possibilities.last
- end
- end
-
- # Details of the state to unwind to when a conflict occurs, and the cause of the unwind
- # @attr [Integer] state_index the index of the state to unwind to
- # @attr [Object] state_requirement the requirement of the state we're unwinding to
- # @attr [Array] requirement_tree for the requirement we're relaxing
- # @attr [Array] conflicting_requirements the requirements that combined to cause the conflict
- # @attr [Array] requirement_trees for the conflict
- # @attr [Array] requirements_unwound_to_instead array of unwind requirements that were chosen over this unwind
- UnwindDetails = Struct.new(
- :state_index,
- :state_requirement,
- :requirement_tree,
- :conflicting_requirements,
- :requirement_trees,
- :requirements_unwound_to_instead
- )
-
- class UnwindDetails
- include Comparable
-
- # We compare UnwindDetails when choosing which state to unwind to. If
- # two options have the same state_index we prefer the one most
- # removed from a requirement that caused the conflict. Both options
- # would unwind to the same state, but a `grandparent` option will
- # filter out fewer of its possibilities after doing so - where a state
- # is both a `parent` and a `grandparent` to requirements that have
- # caused a conflict this is the correct behaviour.
- # @param [UnwindDetail] other UnwindDetail to be compared
- # @return [Integer] integer specifying ordering
- def <=>(other)
- if state_index > other.state_index
- 1
- elsif state_index == other.state_index
- reversed_requirement_tree_index <=> other.reversed_requirement_tree_index
- else
- -1
- end
- end
-
- # @return [Integer] index of state requirement in reversed requirement tree
- # (the conflicting requirement itself will be at position 0)
- def reversed_requirement_tree_index
- @reversed_requirement_tree_index ||=
- if state_requirement
- requirement_tree.reverse.index(state_requirement)
- else
- 999_999
- end
- end
-
- # @return [Boolean] where the requirement of the state we're unwinding
- # to directly caused the conflict. Note: in this case, it is
- # impossible for the state we're unwinding to to be a parent of
- # any of the other conflicting requirements (or we would have
- # circularity)
- def unwinding_to_primary_requirement?
- requirement_tree.last == state_requirement
- end
-
- # @return [Array] array of sub-dependencies to avoid when choosing a
- # new possibility for the state we've unwound to. Only relevant for
- # non-primary unwinds
- def sub_dependencies_to_avoid
- @requirements_to_avoid ||=
- requirement_trees.map do |tree|
- index = tree.index(state_requirement)
- tree[index + 1] if index
- end.compact
- end
-
- # @return [Array] array of all the requirements that led to the need for
- # this unwind
- def all_requirements
- @all_requirements ||= requirement_trees.flatten(1)
- end
- end
-
- # @return [SpecificationProvider] the provider that knows about
- # dependencies, requirements, specifications, versions, etc.
- attr_reader :specification_provider
-
- # @return [UI] the UI that knows how to communicate feedback about the
- # resolution process back to the user
- attr_reader :resolver_ui
-
- # @return [DependencyGraph] the base dependency graph to which
- # dependencies should be 'locked'
- attr_reader :base
-
- # @return [Array] the dependencies that were explicitly required
- attr_reader :original_requested
-
- # Initializes a new resolution.
- # @param [SpecificationProvider] specification_provider
- # see {#specification_provider}
- # @param [UI] resolver_ui see {#resolver_ui}
- # @param [Array] requested see {#original_requested}
- # @param [DependencyGraph] base see {#base}
- def initialize(specification_provider, resolver_ui, requested, base)
- @specification_provider = specification_provider
- @resolver_ui = resolver_ui
- @original_requested = requested
- @base = base
- @states = []
- @iteration_counter = 0
- @parents_of = Hash.new { |h, k| h[k] = [] }
- end
-
- # Resolves the {#original_requested} dependencies into a full dependency
- # graph
- # @raise [ResolverError] if successful resolution is impossible
- # @return [DependencyGraph] the dependency graph of successfully resolved
- # dependencies
- def resolve
- start_resolution
-
- while state
- break if !state.requirement && state.requirements.empty?
- indicate_progress
- if state.respond_to?(:pop_possibility_state) # DependencyState
- debug(depth) { "Creating possibility state for #{requirement} (#{possibilities.count} remaining)" }
- state.pop_possibility_state.tap do |s|
- if s
- states.push(s)
- activated.tag(s)
- end
- end
- end
- process_topmost_state
- end
-
- resolve_activated_specs
- ensure
- end_resolution
- end
-
- # @return [Integer] the number of resolver iterations in between calls to
- # {#resolver_ui}'s {UI#indicate_progress} method
- attr_accessor :iteration_rate
- private :iteration_rate
-
- # @return [Time] the time at which resolution began
- attr_accessor :started_at
- private :started_at
-
- # @return [Array<ResolutionState>] the stack of states for the resolution
- attr_accessor :states
- private :states
-
- private
-
- # Sets up the resolution process
- # @return [void]
- def start_resolution
- @started_at = Time.now
-
- push_initial_state
-
- debug { "Starting resolution (#{@started_at})\nUser-requested dependencies: #{original_requested}" }
- resolver_ui.before_resolution
- end
-
- def resolve_activated_specs
- activated.vertices.each do |_, vertex|
- next unless vertex.payload
-
- latest_version = vertex.payload.possibilities.reverse_each.find do |possibility|
- vertex.requirements.all? { |req| requirement_satisfied_by?(req, activated, possibility) }
- end
-
- activated.set_payload(vertex.name, latest_version)
- end
- activated.freeze
- end
-
- # Ends the resolution process
- # @return [void]
- def end_resolution
- resolver_ui.after_resolution
- debug do
- "Finished resolution (#{@iteration_counter} steps) " \
- "(Took #{(ended_at = Time.now) - @started_at} seconds) (#{ended_at})"
- end
- debug { 'Unactivated: ' + Hash[activated.vertices.reject { |_n, v| v.payload }].keys.join(', ') } if state
- debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state
- end
-
- require_relative 'state'
- require_relative 'modules/specification_provider'
-
- require_relative 'delegates/resolution_state'
- require_relative 'delegates/specification_provider'
-
- include Gem::Resolver::Molinillo::Delegates::ResolutionState
- include Gem::Resolver::Molinillo::Delegates::SpecificationProvider
-
- # Processes the topmost available {RequirementState} on the stack
- # @return [void]
- def process_topmost_state
- if possibility
- attempt_to_activate
- else
- create_conflict
- unwind_for_conflict
- end
- rescue CircularDependencyError => underlying_error
- create_conflict(underlying_error)
- unwind_for_conflict
- end
-
- # @return [Object] the current possibility that the resolution is trying
- # to activate
- def possibility
- possibilities.last
- end
-
- # @return [RequirementState] the current state the resolution is
- # operating upon
- def state
- states.last
- end
-
- # Creates and pushes the initial state for the resolution, based upon the
- # {#requested} dependencies
- # @return [void]
- def push_initial_state
- graph = DependencyGraph.new.tap do |dg|
- original_requested.each do |requested|
- vertex = dg.add_vertex(name_for(requested), nil, true)
- vertex.explicit_requirements << requested
- end
- dg.tag(:initial_state)
- end
-
- push_state_for_requirements(original_requested, true, graph)
- end
-
- # Unwinds the states stack because a conflict has been encountered
- # @return [void]
- def unwind_for_conflict
- details_for_unwind = build_details_for_unwind
- unwind_options = unused_unwind_options
- debug(depth) { "Unwinding for conflict: #{requirement} to #{details_for_unwind.state_index / 2}" }
- conflicts.tap do |c|
- sliced_states = states.slice!((details_for_unwind.state_index + 1)..-1)
- raise_error_unless_state(c)
- activated.rewind_to(sliced_states.first || :initial_state) if sliced_states
- state.conflicts = c
- state.unused_unwind_options = unwind_options
- filter_possibilities_after_unwind(details_for_unwind)
- index = states.size - 1
- @parents_of.each { |_, a| a.reject! { |i| i >= index } }
- state.unused_unwind_options.reject! { |uw| uw.state_index >= index }
- end
- end
-
- # Raises a VersionConflict error, or any underlying error, if there is no
- # current state
- # @return [void]
- def raise_error_unless_state(conflicts)
- return if state
-
- error = conflicts.values.map(&:underlying_error).compact.first
- raise error || VersionConflict.new(conflicts, specification_provider)
- end
-
- # @return [UnwindDetails] Details of the nearest index to which we could unwind
- def build_details_for_unwind
- # Get the possible unwinds for the current conflict
- current_conflict = conflicts[name]
- binding_requirements = binding_requirements_for_conflict(current_conflict)
- unwind_details = unwind_options_for_requirements(binding_requirements)
-
- last_detail_for_current_unwind = unwind_details.sort.last
- current_detail = last_detail_for_current_unwind
-
- # Look for past conflicts that could be unwound to affect the
- # requirement tree for the current conflict
- all_reqs = last_detail_for_current_unwind.all_requirements
- all_reqs_size = all_reqs.size
- relevant_unused_unwinds = unused_unwind_options.select do |alternative|
- diff_reqs = all_reqs - alternative.requirements_unwound_to_instead
- next if diff_reqs.size == all_reqs_size
- # Find the highest index unwind whilst looping through
- current_detail = alternative if alternative > current_detail
- alternative
- end
-
- # Add the current unwind options to the `unused_unwind_options` array.
- # The "used" option will be filtered out during `unwind_for_conflict`.
- state.unused_unwind_options += unwind_details.reject { |detail| detail.state_index == -1 }
-
- # Update the requirements_unwound_to_instead on any relevant unused unwinds
- relevant_unused_unwinds.each do |d|
- (d.requirements_unwound_to_instead << current_detail.state_requirement).uniq!
- end
- unwind_details.each do |d|
- (d.requirements_unwound_to_instead << current_detail.state_requirement).uniq!
- end
-
- current_detail
- end
-
- # @param [Array<Object>] binding_requirements array of requirements that combine to create a conflict
- # @return [Array<UnwindDetails>] array of UnwindDetails that have a chance
- # of resolving the passed requirements
- def unwind_options_for_requirements(binding_requirements)
- unwind_details = []
-
- trees = []
- binding_requirements.reverse_each do |r|
- partial_tree = [r]
- trees << partial_tree
- unwind_details << UnwindDetails.new(-1, nil, partial_tree, binding_requirements, trees, [])
-
- # If this requirement has alternative possibilities, check if any would
- # satisfy the other requirements that created this conflict
- requirement_state = find_state_for(r)
- if conflict_fixing_possibilities?(requirement_state, binding_requirements)
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
-
- # Next, look at the parent of this requirement, and check if the requirement
- # could have been avoided if an alternative PossibilitySet had been chosen
- parent_r = parent_of(r)
- next if parent_r.nil?
- partial_tree.unshift(parent_r)
- requirement_state = find_state_for(parent_r)
- if requirement_state.possibilities.any? { |set| !set.dependencies.include?(r) }
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- parent_r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
-
- # Finally, look at the grandparent and up of this requirement, looking
- # for any possibilities that wouldn't create their parent requirement
- grandparent_r = parent_of(parent_r)
- until grandparent_r.nil?
- partial_tree.unshift(grandparent_r)
- requirement_state = find_state_for(grandparent_r)
- if requirement_state.possibilities.any? { |set| !set.dependencies.include?(parent_r) }
- unwind_details << UnwindDetails.new(
- states.index(requirement_state),
- grandparent_r,
- partial_tree,
- binding_requirements,
- trees,
- []
- )
- end
- parent_r = grandparent_r
- grandparent_r = parent_of(parent_r)
- end
- end
-
- unwind_details
- end
-
- # @param [DependencyState] state
- # @param [Array] binding_requirements array of requirements
- # @return [Boolean] whether or not the given state has any possibilities
- # that could satisfy the given requirements
- def conflict_fixing_possibilities?(state, binding_requirements)
- return false unless state
-
- state.possibilities.any? do |possibility_set|
- possibility_set.possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, binding_requirements)
- end
- end
- end
-
- # Filter's a state's possibilities to remove any that would not fix the
- # conflict we've just rewound from
- # @param [UnwindDetails] unwind_details details of the conflict just
- # unwound from
- # @return [void]
- def filter_possibilities_after_unwind(unwind_details)
- return unless state && !state.possibilities.empty?
-
- if unwind_details.unwinding_to_primary_requirement?
- filter_possibilities_for_primary_unwind(unwind_details)
- else
- filter_possibilities_for_parent_unwind(unwind_details)
- end
- end
-
- # Filter's a state's possibilities to remove any that would not satisfy
- # the requirements in the conflict we've just rewound from
- # @param [UnwindDetails] unwind_details details of the conflict just unwound from
- # @return [void]
- def filter_possibilities_for_primary_unwind(unwind_details)
- unwinds_to_state = unused_unwind_options.select { |uw| uw.state_index == unwind_details.state_index }
- unwinds_to_state << unwind_details
- unwind_requirement_sets = unwinds_to_state.map(&:conflicting_requirements)
-
- state.possibilities.reject! do |possibility_set|
- possibility_set.possibilities.none? do |poss|
- unwind_requirement_sets.any? do |requirements|
- possibility_satisfies_requirements?(poss, requirements)
- end
- end
- end
- end
-
- # @param [Object] possibility a single possibility
- # @param [Array] requirements an array of requirements
- # @return [Boolean] whether the possibility satisfies all of the
- # given requirements
- def possibility_satisfies_requirements?(possibility, requirements)
- name = name_for(possibility)
-
- activated.tag(:swap)
- activated.set_payload(name, possibility) if activated.vertex_named(name)
- satisfied = requirements.all? { |r| requirement_satisfied_by?(r, activated, possibility) }
- activated.rewind_to(:swap)
-
- satisfied
- end
-
- # Filter's a state's possibilities to remove any that would (eventually)
- # create a requirement in the conflict we've just rewound from
- # @param [UnwindDetails] unwind_details details of the conflict just unwound from
- # @return [void]
- def filter_possibilities_for_parent_unwind(unwind_details)
- unwinds_to_state = unused_unwind_options.select { |uw| uw.state_index == unwind_details.state_index }
- unwinds_to_state << unwind_details
-
- primary_unwinds = unwinds_to_state.select(&:unwinding_to_primary_requirement?).uniq
- parent_unwinds = unwinds_to_state.uniq - primary_unwinds
-
- allowed_possibility_sets = primary_unwinds.flat_map do |unwind|
- states[unwind.state_index].possibilities.select do |possibility_set|
- possibility_set.possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, unwind.conflicting_requirements)
- end
- end
- end
-
- requirements_to_avoid = parent_unwinds.flat_map(&:sub_dependencies_to_avoid)
-
- state.possibilities.reject! do |possibility_set|
- !allowed_possibility_sets.include?(possibility_set) &&
- (requirements_to_avoid - possibility_set.dependencies).empty?
- end
- end
-
- # @param [Conflict] conflict
- # @return [Array] minimal array of requirements that would cause the passed
- # conflict to occur.
- def binding_requirements_for_conflict(conflict)
- return [conflict.requirement] if conflict.possibility.nil?
-
- possible_binding_requirements = conflict.requirements.values.flatten(1).uniq
-
- # When there's a `CircularDependency` error the conflicting requirement
- # (the one causing the circular) won't be `conflict.requirement`
- # (which won't be for the right state, because we won't have created it,
- # because it's circular).
- # We need to make sure we have that requirement in the conflict's list,
- # otherwise we won't be able to unwind properly, so we just return all
- # the requirements for the conflict.
- return possible_binding_requirements if conflict.underlying_error
-
- possibilities = search_for(conflict.requirement)
-
- # If all the requirements together don't filter out all possibilities,
- # then the only two requirements we need to consider are the initial one
- # (where the dependency's version was first chosen) and the last
- if binding_requirement_in_set?(nil, possible_binding_requirements, possibilities)
- return [conflict.requirement, requirement_for_existing_name(name_for(conflict.requirement))].compact
- end
-
- # Loop through the possible binding requirements, removing each one
- # that doesn't bind. Use a `reverse_each` as we want the earliest set of
- # binding requirements, and don't use `reject!` as we wish to refine the
- # array *on each iteration*.
- binding_requirements = possible_binding_requirements.dup
- possible_binding_requirements.reverse_each do |req|
- next if req == conflict.requirement
- unless binding_requirement_in_set?(req, binding_requirements, possibilities)
- binding_requirements -= [req]
- end
- end
-
- binding_requirements
- end
-
- # @param [Object] requirement we wish to check
- # @param [Array] possible_binding_requirements array of requirements
- # @param [Array] possibilities array of possibilities the requirements will be used to filter
- # @return [Boolean] whether or not the given requirement is required to filter
- # out all elements of the array of possibilities.
- def binding_requirement_in_set?(requirement, possible_binding_requirements, possibilities)
- possibilities.any? do |poss|
- possibility_satisfies_requirements?(poss, possible_binding_requirements - [requirement])
- end
- end
-
- # @param [Object] requirement
- # @return [Object] the requirement that led to `requirement` being added
- # to the list of requirements.
- def parent_of(requirement)
- return unless requirement
- return unless index = @parents_of[requirement].last
- return unless parent_state = @states[index]
- parent_state.requirement
- end
-
- # @param [String] name
- # @return [Object] the requirement that led to a version of a possibility
- # with the given name being activated.
- def requirement_for_existing_name(name)
- return nil unless vertex = activated.vertex_named(name)
- return nil unless vertex.payload
- states.find { |s| s.name == name }.requirement
- end
-
- # @param [Object] requirement
- # @return [ResolutionState] the state whose `requirement` is the given
- # `requirement`.
- def find_state_for(requirement)
- return nil unless requirement
- states.find { |i| requirement == i.requirement }
- end
-
- # @param [Object] underlying_error
- # @return [Conflict] a {Conflict} that reflects the failure to activate
- # the {#possibility} in conjunction with the current {#state}
- def create_conflict(underlying_error = nil)
- vertex = activated.vertex_named(name)
- locked_requirement = locked_requirement_named(name)
-
- requirements = {}
- unless vertex.explicit_requirements.empty?
- requirements[name_for_explicit_dependency_source] = vertex.explicit_requirements
- end
- requirements[name_for_locking_dependency_source] = [locked_requirement] if locked_requirement
- vertex.incoming_edges.each do |edge|
- (requirements[edge.origin.payload.latest_version] ||= []).unshift(edge.requirement)
- end
-
- activated_by_name = {}
- activated.each { |v| activated_by_name[v.name] = v.payload.latest_version if v.payload }
- conflicts[name] = Conflict.new(
- requirement,
- requirements,
- vertex.payload && vertex.payload.latest_version,
- possibility,
- locked_requirement,
- requirement_trees,
- activated_by_name,
- underlying_error
- )
- end
-
- # @return [Array<Array<Object>>] The different requirement
- # trees that led to every requirement for the current spec.
- def requirement_trees
- vertex = activated.vertex_named(name)
- vertex.requirements.map { |r| requirement_tree_for(r) }
- end
-
- # @param [Object] requirement
- # @return [Array<Object>] the list of requirements that led to
- # `requirement` being required.
- def requirement_tree_for(requirement)
- tree = []
- while requirement
- tree.unshift(requirement)
- requirement = parent_of(requirement)
- end
- tree
- end
-
- # Indicates progress roughly once every second
- # @return [void]
- def indicate_progress
- @iteration_counter += 1
- @progress_rate ||= resolver_ui.progress_rate
- if iteration_rate.nil?
- if Time.now - started_at >= @progress_rate
- self.iteration_rate = @iteration_counter
- end
- end
-
- if iteration_rate && (@iteration_counter % iteration_rate) == 0
- resolver_ui.indicate_progress
- end
- end
-
- # Calls the {#resolver_ui}'s {UI#debug} method
- # @param [Integer] depth the depth of the {#states} stack
- # @param [Proc] block a block that yields a {#to_s}
- # @return [void]
- def debug(depth = 0, &block)
- resolver_ui.debug(depth, &block)
- end
-
- # Attempts to activate the current {#possibility}
- # @return [void]
- def attempt_to_activate
- debug(depth) { 'Attempting to activate ' + possibility.to_s }
- existing_vertex = activated.vertex_named(name)
- if existing_vertex.payload
- debug(depth) { "Found existing spec (#{existing_vertex.payload})" }
- attempt_to_filter_existing_spec(existing_vertex)
- else
- latest = possibility.latest_version
- possibility.possibilities.select! do |possibility|
- requirement_satisfied_by?(requirement, activated, possibility)
- end
- if possibility.latest_version.nil?
- # ensure there's a possibility for better error messages
- possibility.possibilities << latest if latest
- create_conflict
- unwind_for_conflict
- else
- activate_new_spec
- end
- end
- end
-
- # Attempts to update the existing vertex's `PossibilitySet` with a filtered version
- # @return [void]
- def attempt_to_filter_existing_spec(vertex)
- filtered_set = filtered_possibility_set(vertex)
- if !filtered_set.possibilities.empty?
- activated.set_payload(name, filtered_set)
- new_requirements = requirements.dup
- push_state_for_requirements(new_requirements, false)
- else
- create_conflict
- debug(depth) { "Unsatisfied by existing spec (#{vertex.payload})" }
- unwind_for_conflict
- end
- end
-
- # Generates a filtered version of the existing vertex's `PossibilitySet` using the
- # current state's `requirement`
- # @param [Object] vertex existing vertex
- # @return [PossibilitySet] filtered possibility set
- def filtered_possibility_set(vertex)
- PossibilitySet.new(vertex.payload.dependencies, vertex.payload.possibilities & possibility.possibilities)
- end
-
- # @param [String] requirement_name the spec name to search for
- # @return [Object] the locked spec named `requirement_name`, if one
- # is found on {#base}
- def locked_requirement_named(requirement_name)
- vertex = base.vertex_named(requirement_name)
- vertex && vertex.payload
- end
-
- # Add the current {#possibility} to the dependency graph of the current
- # {#state}
- # @return [void]
- def activate_new_spec
- conflicts.delete(name)
- debug(depth) { "Activated #{name} at #{possibility}" }
- activated.set_payload(name, possibility)
- require_nested_dependencies_for(possibility)
- end
-
- # Requires the dependencies that the recently activated spec has
- # @param [Object] possibility_set the PossibilitySet that has just been
- # activated
- # @return [void]
- def require_nested_dependencies_for(possibility_set)
- nested_dependencies = dependencies_for(possibility_set.latest_version)
- debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" }
- nested_dependencies.each do |d|
- activated.add_child_vertex(name_for(d), nil, [name_for(possibility_set.latest_version)], d)
- parent_index = states.size - 1
- parents = @parents_of[d]
- parents << parent_index if parents.empty?
- end
-
- push_state_for_requirements(requirements + nested_dependencies, !nested_dependencies.empty?)
- end
-
- # Pushes a new {DependencyState} that encapsulates both existing and new
- # requirements
- # @param [Array] new_requirements
- # @param [Boolean] requires_sort
- # @param [Object] new_activated
- # @return [void]
- def push_state_for_requirements(new_requirements, requires_sort = true, new_activated = activated)
- new_requirements = sort_dependencies(new_requirements.uniq, new_activated, conflicts) if requires_sort
- new_requirement = nil
- loop do
- new_requirement = new_requirements.shift
- break if new_requirement.nil? || states.none? { |s| s.requirement == new_requirement }
- end
- new_name = new_requirement ? name_for(new_requirement) : ''.freeze
- possibilities = possibilities_for_requirement(new_requirement)
- handle_missing_or_push_dependency_state DependencyState.new(
- new_name, new_requirements, new_activated,
- new_requirement, possibilities, depth, conflicts.dup, unused_unwind_options.dup
- )
- end
-
- # Checks a proposed requirement with any existing locked requirement
- # before generating an array of possibilities for it.
- # @param [Object] requirement the proposed requirement
- # @param [Object] activated
- # @return [Array] possibilities
- def possibilities_for_requirement(requirement, activated = self.activated)
- return [] unless requirement
- if locked_requirement_named(name_for(requirement))
- return locked_requirement_possibility_set(requirement, activated)
- end
-
- group_possibilities(search_for(requirement))
- end
-
- # @param [Object] requirement the proposed requirement
- # @param [Object] activated
- # @return [Array] possibility set containing only the locked requirement, if any
- def locked_requirement_possibility_set(requirement, activated = self.activated)
- all_possibilities = search_for(requirement)
- locked_requirement = locked_requirement_named(name_for(requirement))
-
- # Longwinded way to build a possibilities array with either the locked
- # requirement or nothing in it. Required, since the API for
- # locked_requirement isn't guaranteed.
- locked_possibilities = all_possibilities.select do |possibility|
- requirement_satisfied_by?(locked_requirement, activated, possibility)
- end
-
- group_possibilities(locked_possibilities)
- end
-
- # Build an array of PossibilitySets, with each element representing a group of
- # dependency versions that all have the same sub-dependency version constraints
- # and are contiguous.
- # @param [Array] possibilities an array of possibilities
- # @return [Array<PossibilitySet>] an array of possibility sets
- def group_possibilities(possibilities)
- possibility_sets = []
- current_possibility_set = nil
-
- possibilities.reverse_each do |possibility|
- dependencies = dependencies_for(possibility)
- if current_possibility_set && dependencies_equal?(current_possibility_set.dependencies, dependencies)
- current_possibility_set.possibilities.unshift(possibility)
- else
- possibility_sets.unshift(PossibilitySet.new(dependencies, [possibility]))
- current_possibility_set = possibility_sets.first
- end
- end
-
- possibility_sets
- end
-
- # Pushes a new {DependencyState}.
- # If the {#specification_provider} says to
- # {SpecificationProvider#allow_missing?} that particular requirement, and
- # there are no possibilities for that requirement, then `state` is not
- # pushed, and the vertex in {#activated} is removed, and we continue
- # resolving the remaining requirements.
- # @param [DependencyState] state
- # @return [void]
- def handle_missing_or_push_dependency_state(state)
- if state.requirement && state.possibilities.empty? && allow_missing?(state.requirement)
- state.activated.detach_vertex_named(state.name)
- push_state_for_requirements(state.requirements.dup, false, state.activated)
- else
- states.push(state).tap { activated.tag(state) }
- end
- end
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
deleted file mode 100644
index d43121f8ca..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require_relative 'dependency_graph'
-
-module Gem::Resolver::Molinillo
- # This class encapsulates a dependency resolver.
- # The resolver is responsible for determining which set of dependencies to
- # activate, with feedback from the {#specification_provider}
- #
- #
- class Resolver
- require_relative 'resolution'
-
- # @return [SpecificationProvider] the specification provider used
- # in the resolution process
- attr_reader :specification_provider
-
- # @return [UI] the UI module used to communicate back to the user
- # during the resolution process
- attr_reader :resolver_ui
-
- # Initializes a new resolver.
- # @param [SpecificationProvider] specification_provider
- # see {#specification_provider}
- # @param [UI] resolver_ui
- # see {#resolver_ui}
- def initialize(specification_provider, resolver_ui)
- @specification_provider = specification_provider
- @resolver_ui = resolver_ui
- end
-
- # Resolves the requested dependencies into a {DependencyGraph},
- # locking to the base dependency graph (if specified)
- # @param [Array] requested an array of 'requested' dependencies that the
- # {#specification_provider} can understand
- # @param [DependencyGraph,nil] base the base dependency graph to which
- # dependencies should be 'locked'
- def resolve(requested, base = DependencyGraph.new)
- Resolution.new(specification_provider,
- resolver_ui,
- requested,
- base).
- resolve
- end
- end
-end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
deleted file mode 100644
index 6e7c715fce..0000000000
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-
-module Gem::Resolver::Molinillo
- # A state that a {Resolution} can be in
- # @attr [String] name the name of the current requirement
- # @attr [Array<Object>] requirements currently unsatisfied requirements
- # @attr [DependencyGraph] activated the graph of activated dependencies
- # @attr [Object] requirement the current requirement
- # @attr [Object] possibilities the possibilities to satisfy the current requirement
- # @attr [Integer] depth the depth of the resolution
- # @attr [Hash] conflicts unresolved conflicts, indexed by dependency name
- # @attr [Array<UnwindDetails>] unused_unwind_options unwinds for previous conflicts that weren't explored
- ResolutionState = Struct.new(
- :name,
- :requirements,
- :activated,
- :requirement,
- :possibilities,
- :depth,
- :conflicts,
- :unused_unwind_options
- )
-
- class ResolutionState
- # Returns an empty resolution state
- # @return [ResolutionState] an empty state
- def self.empty
- new(nil, [], DependencyGraph.new, nil, nil, 0, {}, [])
- end
- end
-
- # A state that encapsulates a set of {#requirements} with an {Array} of
- # possibilities
- class DependencyState < ResolutionState
- # Removes a possibility from `self`
- # @return [PossibilityState] a state with a single possibility,
- # the possibility that was removed from `self`
- def pop_possibility_state
- PossibilityState.new(
- name,
- requirements.dup,
- activated,
- requirement,
- [possibilities.pop],
- depth + 1,
- conflicts.dup,
- unused_unwind_options.dup
- ).tap do |state|
- state.activated.tag(state)
- end
- end
- end
-
- # A state that encapsulates a single possibility to fulfill the given
- # {#requirement}
- class PossibilityState < ResolutionState
- end
-end
diff --git a/lib/rubygems/resolver/requirement_list.rb b/lib/rubygems/resolver/requirement_list.rb
index 5b51493c9a..6f86f0f412 100644
--- a/lib/rubygems/resolver/requirement_list.rb
+++ b/lib/rubygems/resolver/requirement_list.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The RequirementList is used to hold the requirements being considered
# while resolving a set of gems.
diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb
index 5d8dd51eaa..243fee5fd5 100644
--- a/lib/rubygems/resolver/set.rb
+++ b/lib/rubygems/resolver/set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Resolver sets are used to look up specifications (and their
# dependencies) used in resolution. This set is abstract.
diff --git a/lib/rubygems/resolver/source_set.rb b/lib/rubygems/resolver/source_set.rb
index bf8c23184e..074b473edc 100644
--- a/lib/rubygems/resolver/source_set.rb
+++ b/lib/rubygems/resolver/source_set.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
##
# The SourceSet chooses the best available method to query a remote index.
#
@@ -40,6 +42,6 @@ class Gem::Resolver::SourceSet < Gem::Resolver::Set
def get_set(name)
link = @links[name]
- @sets[link] ||= Gem::Source.new(link).dependency_resolver_set if link
+ @sets[link] ||= Gem::Source.new(link).dependency_resolver_set(@prerelease) if link
end
end
diff --git a/lib/rubygems/resolver/spec_specification.rb b/lib/rubygems/resolver/spec_specification.rb
index 7b665fe876..00ef9fdba0 100644
--- a/lib/rubygems/resolver/spec_specification.rb
+++ b/lib/rubygems/resolver/spec_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The Resolver::SpecSpecification contains common functionality for
# Resolver specifications that are backed by a Gem::Specification.
@@ -65,4 +66,11 @@ class Gem::Resolver::SpecSpecification < Gem::Resolver::Specification
def version
spec.version
end
+
+ ##
+ # The hash value for this specification.
+
+ def hash
+ spec.hash
+ end
end
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb
index 3da803cab5..d2098ef0e2 100644
--- a/lib/rubygems/resolver/specification.rb
+++ b/lib/rubygems/resolver/specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A Resolver::Specification contains a subset of the information
# contained in a Gem::Specification. Only the information necessary for
diff --git a/lib/rubygems/resolver/stats.rb b/lib/rubygems/resolver/stats.rb
deleted file mode 100644
index 3b95efebf7..0000000000
--- a/lib/rubygems/resolver/stats.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-class Gem::Resolver::Stats
- def initialize
- @max_depth = 0
- @max_requirements = 0
- @requirements = 0
- @backtracking = 0
- @iterations = 0
- end
-
- def record_depth(stack)
- if stack.size > @max_depth
- @max_depth = stack.size
- end
- end
-
- def record_requirements(reqs)
- if reqs.size > @max_requirements
- @max_requirements = reqs.size
- end
- end
-
- def requirement!
- @requirements += 1
- end
-
- def backtracking!
- @backtracking += 1
- end
-
- def iteration!
- @iterations += 1
- end
-
- PATTERN = "%20s: %d\n"
-
- def display
- $stdout.puts "=== Resolver Statistics ==="
- $stdout.printf PATTERN, "Max Depth", @max_depth
- $stdout.printf PATTERN, "Total Requirements", @requirements
- $stdout.printf PATTERN, "Max Requirements", @max_requirements
- $stdout.printf PATTERN, "Backtracking #", @backtracking
- $stdout.printf PATTERN, "Iteration #", @iterations
- end
-end
diff --git a/lib/rubygems/resolver/strategy.rb b/lib/rubygems/resolver/strategy.rb
new file mode 100644
index 0000000000..bf0dbb6adc
--- /dev/null
+++ b/lib/rubygems/resolver/strategy.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+# Custom PubGrub strategy with caching for version selection.
+# Modeled after Bundler's strategy to avoid redundant versions_for
+# calls during the solver's package selection loop.
+
+class Gem::Resolver::Strategy
+ def initialize(source)
+ @source = source
+ @package_priority_cache = Hash.new {|h, pkg| h[pkg] = {} }
+
+ @version_indexes = Hash.new do |h, k|
+ if Gem::PubGrub::Package.root?(k)
+ h[k] = { Gem::PubGrub::Package.root_version => 0 }
+ else
+ h[k] = @source.all_versions_for(k).each.with_index.to_h
+ end
+ end
+ end
+
+ def next_package_and_version(unsatisfied)
+ package, range = next_term_to_try_from(unsatisfied)
+ [package, most_preferred_version_of(package, range)]
+ end
+
+ private
+
+ def most_preferred_version_of(package, range)
+ versions = @source.versions_for(package, range)
+ indexes = @version_indexes[package]
+ versions.min_by {|version| indexes[version] || Float::INFINITY }
+ end
+
+ def next_term_to_try_from(unsatisfied)
+ unsatisfied.min_by do |package, range|
+ @package_priority_cache[package][range] ||= begin
+ matching_versions = @source.versions_for(package, range)
+ higher_versions = @source.versions_for(package, range.upper_invert)
+
+ [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb
index 6c0ef2a1a1..293a1e3331 100644
--- a/lib/rubygems/resolver/vendor_set.rb
+++ b/lib/rubygems/resolver/vendor_set.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A VendorSet represents gems that have been unpacked into a specific
# directory that contains a gemspec.
diff --git a/lib/rubygems/resolver/vendor_specification.rb b/lib/rubygems/resolver/vendor_specification.rb
index 600a98a2bf..ac78f54558 100644
--- a/lib/rubygems/resolver/vendor_specification.rb
+++ b/lib/rubygems/resolver/vendor_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A VendorSpecification represents a gem that has been unpacked into a project
# and is being loaded through a gem dependencies file through the +path:+
diff --git a/lib/rubygems/s3_uri_signer.rb b/lib/rubygems/s3_uri_signer.rb
index c13852337b..148cba38c4 100644
--- a/lib/rubygems/s3_uri_signer.rb
+++ b/lib/rubygems/s3_uri_signer.rb
@@ -1,16 +1,21 @@
+# frozen_string_literal: true
+
require_relative "openssl"
+require_relative "user_interaction"
##
# S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems
# More on AWS SigV4: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
class Gem::S3URISigner
+ include Gem::UserInteraction
+
class ConfigurationError < Gem::Exception
def initialize(message)
super message
end
def to_s # :nodoc:
- (super).to_s
+ super.to_s
end
end
@@ -20,14 +25,16 @@ class Gem::S3URISigner
end
def to_s # :nodoc:
- (super).to_s
+ super.to_s
end
end
attr_accessor :uri
+ attr_accessor :method
- def initialize(uri)
+ def initialize(uri, method)
@uri = uri
+ @method = method
end
##
@@ -36,7 +43,7 @@ class Gem::S3URISigner
s3_config = fetch_s3_config
current_time = Time.now.utc
- date_time = current_time.strftime("%Y%m%dT%H%m%SZ")
+ date_time = current_time.strftime("%Y%m%dT%H%M%SZ")
date = date_time[0,8]
credential_info = "#{date}/#{s3_config.region}/s3/aws4_request"
@@ -47,7 +54,7 @@ class Gem::S3URISigner
string_to_sign = generate_string_to_sign(date_time, credential_info, canonical_request)
signature = generate_signature(s3_config, date, string_to_sign)
- URI.parse("https://#{canonical_host}#{uri.path}?#{query_params}&X-Amz-Signature=#{signature}")
+ Gem::URI.parse("https://#{canonical_host}#{uri.path}?#{query_params}&X-Amz-Signature=#{signature}")
end
private
@@ -71,7 +78,7 @@ class Gem::S3URISigner
def generate_canonical_request(canonical_host, query_params)
[
- "GET",
+ method.upcase,
uri.path,
query_params,
"host:#{canonical_host}",
@@ -134,35 +141,78 @@ class Gem::S3URISigner
end
def base64_uri_escape(str)
- str.gsub(/[\+\/=\n]/, BASE64_URI_TRANSLATE)
+ str.gsub(%r{[\+/=\n]}, BASE64_URI_TRANSLATE)
end
def ec2_metadata_credentials_json
- require "net/http"
+ require_relative "vendored_net_http"
require_relative "request"
require_relative "request/connection_pools"
require "json"
- iam_info = ec2_metadata_request(EC2_IAM_INFO)
+ # First try V2 fallback to V1
+ res = nil
+ begin
+ res = ec2_metadata_credentials_imds_v2
+ rescue InstanceProfileError
+ alert_warning "Unable to access ec2 credentials via IMDSv2, falling back to IMDSv1"
+ res = ec2_metadata_credentials_imds_v1
+ end
+ res
+ end
+
+ def ec2_metadata_credentials_imds_v2
+ token = ec2_metadata_token
+ iam_info = ec2_metadata_request(EC2_IAM_INFO, token:)
# Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
role_name = iam_info["InstanceProfileArn"].split("/").last
- ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name)
+ ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name, token:)
end
- def ec2_metadata_request(url)
- uri = URI(url)
- @request_pool ||= create_request_pool(uri)
- request = Gem::Request.new(uri, Net::HTTP::Get, nil, @request_pool)
- response = request.fetch
+ def ec2_metadata_credentials_imds_v1
+ iam_info = ec2_metadata_request(EC2_IAM_INFO, token: nil)
+ # Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
+ role_name = iam_info["InstanceProfileArn"].split("/").last
+ ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name, token: nil)
+ end
+
+ def ec2_metadata_request(url, token:)
+ request = ec2_iam_request(Gem::URI(url), Gem::Net::HTTP::Get)
+
+ response = request.fetch do |req|
+ if token
+ req.add_field "X-aws-ec2-metadata-token", token
+ end
+ end
case response
- when Net::HTTPOK then
+ when Gem::Net::HTTPOK then
JSON.parse(response.body)
else
raise InstanceProfileError.new("Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}")
end
end
+ def ec2_metadata_token
+ request = ec2_iam_request(Gem::URI(EC2_IAM_TOKEN), Gem::Net::HTTP::Put)
+
+ response = request.fetch do |req|
+ req.add_field "X-aws-ec2-metadata-token-ttl-seconds", 60
+ end
+
+ case response
+ when Gem::Net::HTTPOK then
+ response.body
+ else
+ raise InstanceProfileError.new("Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}")
+ end
+ end
+
+ def ec2_iam_request(uri, verb)
+ @request_pool ||= create_request_pool(uri)
+ Gem::Request.new(uri, verb, nil, @request_pool)
+ end
+
def create_request_pool(uri)
proxy_uri = Gem::Request.proxy_uri(Gem::Request.get_proxy_from_env(uri.scheme))
certs = Gem::Request.get_cert_files
@@ -170,6 +220,7 @@ class Gem::S3URISigner
end
BASE64_URI_TRANSLATE = { "+" => "%2B", "/" => "%2F", "=" => "%3D", "\n" => "" }.freeze
- EC2_IAM_INFO = "http://169.254.169.254/latest/meta-data/iam/info".freeze
- EC2_IAM_SECURITY_CREDENTIALS = "http://169.254.169.254/latest/meta-data/iam/security-credentials/".freeze
+ EC2_IAM_TOKEN = "http://169.254.169.254/latest/api/token"
+ EC2_IAM_INFO = "http://169.254.169.254/latest/meta-data/iam/info"
+ EC2_IAM_SECURITY_CREDENTIALS = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
end
diff --git a/lib/rubygems/safe_marshal.rb b/lib/rubygems/safe_marshal.rb
new file mode 100644
index 0000000000..871f24727d
--- /dev/null
+++ b/lib/rubygems/safe_marshal.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+require "stringio"
+
+require_relative "safe_marshal/reader"
+require_relative "safe_marshal/visitors/to_ruby"
+
+module Gem
+ ###
+ # This module is used for safely loading Marshal specs from a gem. The
+ # `safe_load` method defined on this module is specifically designed for
+ # loading Gem specifications.
+
+ module SafeMarshal
+ PERMITTED_CLASSES = %w[
+ Date
+ Time
+ Rational
+
+ Gem::Dependency
+ Gem::NameTuple
+ Gem::Platform
+ Gem::Requirement
+ Gem::Specification
+ Gem::Version
+ Gem::Version::Requirement
+
+ YAML::Syck::DefaultKey
+ YAML::PrivateType
+ ].freeze
+ private_constant :PERMITTED_CLASSES
+
+ PERMITTED_SYMBOLS = %w[
+ development
+ runtime
+
+ name
+ number
+ platform
+ dependencies
+ ].freeze
+ private_constant :PERMITTED_SYMBOLS
+
+ PERMITTED_IVARS = {
+ "String" => %w[E encoding @taguri @debug_created_info],
+ "Time" => %w[
+ offset zone nano_num nano_den submicro
+ @_zone @marshal_with_utc_coercion
+ ],
+ "Gem::Dependency" => %w[
+ @name @requirement @prerelease @version_requirement @version_requirements @type
+ @force_ruby_platform
+ ],
+ "Gem::NameTuple" => %w[@name @version @platform],
+ "Gem::Platform" => %w[@os @cpu @version],
+ "Psych::PrivateType" => %w[@value @type_id],
+ "YAML::PrivateType" => %w[@value @type_id],
+ }.freeze
+ private_constant :PERMITTED_IVARS
+
+ def self.safe_load(input)
+ load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, permitted_ivars: PERMITTED_IVARS)
+ end
+
+ def self.load(input, permitted_classes: [::Symbol], permitted_symbols: [], permitted_ivars: {})
+ root = Reader.new(StringIO.new(input, "r").binmode).read!
+
+ Visitors::ToRuby.new(
+ permitted_classes: permitted_classes,
+ permitted_symbols: permitted_symbols,
+ permitted_ivars: permitted_ivars,
+ ).visit(root)
+ end
+ end
+end
diff --git a/lib/rubygems/safe_marshal/elements.rb b/lib/rubygems/safe_marshal/elements.rb
new file mode 100644
index 0000000000..f8874b1b2f
--- /dev/null
+++ b/lib/rubygems/safe_marshal/elements.rb
@@ -0,0 +1,146 @@
+# frozen_string_literal: true
+
+module Gem
+ module SafeMarshal
+ module Elements
+ class Element
+ end
+
+ class Symbol < Element
+ def initialize(name)
+ @name = name
+ end
+ attr_reader :name
+ end
+
+ class UserDefined < Element
+ def initialize(name, binary_string)
+ @name = name
+ @binary_string = binary_string
+ end
+
+ attr_reader :name, :binary_string
+ end
+
+ class UserMarshal < Element
+ def initialize(name, data)
+ @name = name
+ @data = data
+ end
+
+ attr_reader :name, :data
+ end
+
+ class String < Element
+ def initialize(str)
+ @str = str
+ end
+
+ attr_reader :str
+ end
+
+ class Hash < Element
+ def initialize(pairs)
+ @pairs = pairs
+ end
+
+ attr_reader :pairs
+ end
+
+ class HashWithDefaultValue < Hash
+ def initialize(pairs, default)
+ super(pairs)
+ @default = default
+ end
+
+ attr_reader :default
+ end
+
+ class Array < Element
+ def initialize(elements)
+ @elements = elements
+ end
+
+ attr_reader :elements
+ end
+
+ class Integer < Element
+ def initialize(int)
+ @int = int
+ end
+
+ attr_reader :int
+ end
+
+ class True < Element
+ def initialize
+ end
+ TRUE = new.freeze
+ end
+
+ class False < Element
+ def initialize
+ end
+
+ FALSE = new.freeze
+ end
+
+ class WithIvars < Element
+ def initialize(object, ivars)
+ @object = object
+ @ivars = ivars
+ end
+
+ attr_reader :object, :ivars
+ end
+
+ class Object < Element
+ def initialize(name)
+ @name = name
+ end
+ attr_reader :name
+ end
+
+ class Nil < Element
+ NIL = new.freeze
+ end
+
+ class ObjectLink < Element
+ def initialize(offset)
+ @offset = offset
+ end
+ attr_reader :offset
+ end
+
+ class SymbolLink < Element
+ def initialize(offset)
+ @offset = offset
+ end
+ attr_reader :offset
+ end
+
+ class Float < Element
+ def initialize(string)
+ @string = string
+ end
+ attr_reader :string
+ end
+
+ class Bignum < Element # rubocop:disable Lint/UnifiedInteger
+ def initialize(sign, data)
+ @sign = sign
+ @data = data
+ end
+ attr_reader :sign, :data
+ end
+
+ class UserClass < Element
+ def initialize(name, wrapped_object)
+ @name = name
+ @wrapped_object = wrapped_object
+ end
+ attr_reader :name, :wrapped_object
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/safe_marshal/reader.rb b/lib/rubygems/safe_marshal/reader.rb
new file mode 100644
index 0000000000..4362d65fd6
--- /dev/null
+++ b/lib/rubygems/safe_marshal/reader.rb
@@ -0,0 +1,325 @@
+# frozen_string_literal: true
+
+require_relative "elements"
+
+module Gem
+ module SafeMarshal
+ class Reader
+ class Error < StandardError
+ end
+
+ class UnsupportedVersionError < Error
+ end
+
+ class UnconsumedBytesError < Error
+ end
+
+ class NotImplementedError < Error
+ end
+
+ class EOFError < Error
+ end
+
+ class DataTooShortError < Error
+ end
+
+ class NegativeLengthError < Error
+ end
+
+ def initialize(io)
+ @io = io
+ end
+
+ def read!
+ read_header
+ root = read_element
+ raise UnconsumedBytesError, "expected EOF, got #{@io.read(10).inspect}... after top-level element #{root.class}" unless @io.eof?
+ root
+ end
+
+ private
+
+ MARSHAL_VERSION = [Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION].map(&:chr).join.freeze
+ private_constant :MARSHAL_VERSION
+
+ def read_header
+ v = @io.read(2)
+ raise UnsupportedVersionError, "Unsupported marshal version #{v.bytes.map(&:ord).join(".")}, expected #{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" unless v == MARSHAL_VERSION
+ end
+
+ def read_bytes(n)
+ raise NegativeLengthError if n < 0
+ str = @io.read(n)
+ raise EOFError, "expected #{n} bytes, got EOF" if str.nil?
+ raise DataTooShortError, "expected #{n} bytes, got #{str.inspect}" unless str.bytesize == n
+ str
+ end
+
+ def read_byte
+ @io.getbyte || raise(EOFError, "Unexpected EOF")
+ end
+
+ def read_integer
+ b = read_byte
+
+ case b
+ when 0x00
+ 0
+ when 0x01
+ read_byte
+ when 0x02
+ read_byte | (read_byte << 8)
+ when 0x03
+ read_byte | (read_byte << 8) | (read_byte << 16)
+ when 0x04
+ read_byte | (read_byte << 8) | (read_byte << 16) | (read_byte << 24)
+ when 0xFC
+ read_byte | (read_byte << 8) | (read_byte << 16) | (read_byte << 24) | -0x100000000
+ when 0xFD
+ read_byte | (read_byte << 8) | (read_byte << 16) | -0x1000000
+ when 0xFE
+ read_byte | (read_byte << 8) | -0x10000
+ when 0xFF
+ read_byte | -0x100
+ else
+ signed = (b ^ 128) - 128
+ if b >= 128
+ signed + 5
+ else
+ signed - 5
+ end
+ end
+ end
+
+ def read_element
+ type = read_byte
+ case type
+ when 34 then read_string # ?"
+ when 48 then read_nil # ?0
+ when 58 then read_symbol # ?:
+ when 59 then read_symbol_link # ?;
+ when 64 then read_object_link # ?@
+ when 70 then read_false # ?F
+ when 73 then read_object_with_ivars # ?I
+ when 84 then read_true # ?T
+ when 85 then read_user_marshal # ?U
+ when 91 then read_array # ?[
+ when 102 then read_float # ?f
+ when 105 then Elements::Integer.new(read_integer) # ?i
+ when 108 then read_bignum # ?l
+ when 111 then read_object # ?o
+ when 117 then read_user_defined # ?u
+ when 123 then read_hash # ?{
+ when 125 then read_hash_with_default_value # ?}
+ when 101 then read_extended_object # ?e
+ when 99 then read_class # ?c
+ when 109 then read_module # ?m
+ when 77 then read_class_or_module # ?M
+ when 100 then read_data # ?d
+ when 47 then read_regexp # ?/
+ when 83 then read_struct # ?S
+ when 67 then read_user_class # ?C
+ else
+ raise Error, "Unknown marshal type discriminator #{type.chr.inspect} (#{type})"
+ end
+ end
+
+ STRING_E_SYMBOL = Elements::Symbol.new("E").freeze
+ private_constant :STRING_E_SYMBOL
+
+ def read_symbol
+ len = read_integer
+ if len == 1
+ byte = read_byte
+ if byte == 69 # ?E
+ STRING_E_SYMBOL
+ else
+ Elements::Symbol.new(byte.chr)
+ end
+ else
+ name = read_bytes(len)
+ Elements::Symbol.new(name)
+ end
+ end
+
+ EMPTY_STRING = Elements::String.new("".b.freeze).freeze
+ private_constant :EMPTY_STRING
+
+ def read_string
+ length = read_integer
+ return EMPTY_STRING if length == 0
+ str = read_bytes(length)
+ Elements::String.new(str)
+ end
+
+ def read_true
+ Elements::True::TRUE
+ end
+
+ def read_false
+ Elements::False::FALSE
+ end
+
+ def read_user_defined
+ name = read_element
+ binary_string = read_bytes(read_integer)
+ Elements::UserDefined.new(name, binary_string)
+ end
+
+ EMPTY_ARRAY = Elements::Array.new([].freeze).freeze
+ private_constant :EMPTY_ARRAY
+
+ def read_array
+ length = read_integer
+ return EMPTY_ARRAY if length == 0
+ raise NegativeLengthError if length < 0
+ elements = Array.new(length) do
+ read_element
+ end
+ Elements::Array.new(elements)
+ end
+
+ def read_object_with_ivars
+ object = read_element
+ length = read_integer
+ raise NegativeLengthError if length < 0
+ ivars = Array.new(length) do
+ [read_element, read_element]
+ end
+ Elements::WithIvars.new(object, ivars)
+ end
+
+ def read_symbol_link
+ offset = read_integer
+ Elements::SymbolLink.new(offset)
+ end
+
+ def read_user_marshal
+ name = read_element
+ data = read_element
+ Elements::UserMarshal.new(name, data)
+ end
+
+ # profiling bundle install --full-index shows that
+ # offset 6 is by far the most common object link,
+ # so we special case it to avoid allocating a new
+ # object a third of the time.
+ # the following are all the object links that
+ # appear more than 10000 times in my profiling
+
+ OBJECT_LINKS = {
+ 6 => Elements::ObjectLink.new(6).freeze,
+ 30 => Elements::ObjectLink.new(30).freeze,
+ 81 => Elements::ObjectLink.new(81).freeze,
+ 34 => Elements::ObjectLink.new(34).freeze,
+ 38 => Elements::ObjectLink.new(38).freeze,
+ 50 => Elements::ObjectLink.new(50).freeze,
+ 91 => Elements::ObjectLink.new(91).freeze,
+ 42 => Elements::ObjectLink.new(42).freeze,
+ 46 => Elements::ObjectLink.new(46).freeze,
+ 150 => Elements::ObjectLink.new(150).freeze,
+ 100 => Elements::ObjectLink.new(100).freeze,
+ 104 => Elements::ObjectLink.new(104).freeze,
+ 108 => Elements::ObjectLink.new(108).freeze,
+ 242 => Elements::ObjectLink.new(242).freeze,
+ 246 => Elements::ObjectLink.new(246).freeze,
+ 139 => Elements::ObjectLink.new(139).freeze,
+ 143 => Elements::ObjectLink.new(143).freeze,
+ 114 => Elements::ObjectLink.new(114).freeze,
+ 308 => Elements::ObjectLink.new(308).freeze,
+ 200 => Elements::ObjectLink.new(200).freeze,
+ 54 => Elements::ObjectLink.new(54).freeze,
+ 62 => Elements::ObjectLink.new(62).freeze,
+ 1_286_245 => Elements::ObjectLink.new(1_286_245).freeze,
+ }.freeze
+ private_constant :OBJECT_LINKS
+
+ def read_object_link
+ offset = read_integer
+ OBJECT_LINKS[offset] || Elements::ObjectLink.new(offset)
+ end
+
+ EMPTY_HASH = Elements::Hash.new([].freeze).freeze
+ private_constant :EMPTY_HASH
+
+ def read_hash
+ length = read_integer
+ return EMPTY_HASH if length == 0
+ pairs = Array.new(length) do
+ [read_element, read_element]
+ end
+ Elements::Hash.new(pairs)
+ end
+
+ def read_hash_with_default_value
+ length = read_integer
+ raise NegativeLengthError if length < 0
+ pairs = Array.new(length) do
+ [read_element, read_element]
+ end
+ default = read_element
+ Elements::HashWithDefaultValue.new(pairs, default)
+ end
+
+ def read_object
+ name = read_element
+ object = Elements::Object.new(name)
+ length = read_integer
+ raise NegativeLengthError if length < 0
+ ivars = Array.new(length) do
+ [read_element, read_element]
+ end
+ Elements::WithIvars.new(object, ivars)
+ end
+
+ def read_nil
+ Elements::Nil::NIL
+ end
+
+ def read_float
+ string = read_bytes(read_integer)
+ Elements::Float.new(string)
+ end
+
+ def read_bignum
+ sign = read_byte
+ data = read_bytes(read_integer * 2)
+ Elements::Bignum.new(sign, data)
+ end
+
+ def read_extended_object
+ raise NotImplementedError, "Reading Marshal objects of type extended_object is not implemented"
+ end
+
+ def read_class
+ raise NotImplementedError, "Reading Marshal objects of type class is not implemented"
+ end
+
+ def read_module
+ raise NotImplementedError, "Reading Marshal objects of type module is not implemented"
+ end
+
+ def read_class_or_module
+ raise NotImplementedError, "Reading Marshal objects of type class_or_module is not implemented"
+ end
+
+ def read_data
+ raise NotImplementedError, "Reading Marshal objects of type data is not implemented"
+ end
+
+ def read_regexp
+ raise NotImplementedError, "Reading Marshal objects of type regexp is not implemented"
+ end
+
+ def read_struct
+ raise NotImplementedError, "Reading Marshal objects of type struct is not implemented"
+ end
+
+ def read_user_class
+ name = read_element
+ wrapped_object = read_element
+ Elements::UserClass.new(name, wrapped_object)
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/safe_marshal/visitors/stream_printer.rb b/lib/rubygems/safe_marshal/visitors/stream_printer.rb
new file mode 100644
index 0000000000..162b36ad05
--- /dev/null
+++ b/lib/rubygems/safe_marshal/visitors/stream_printer.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require_relative "visitor"
+
+module Gem::SafeMarshal
+ module Visitors
+ class StreamPrinter < Visitor
+ def initialize(io, indent: "")
+ @io = io
+ @indent = indent
+ @level = 0
+ end
+
+ def visit(target)
+ @io.write("#{@indent * @level}#{target.class}")
+ target.instance_variables.each do |ivar|
+ value = target.instance_variable_get(ivar)
+ next if Elements::Element === value || Array === value
+ @io.write(" #{ivar}=#{value.inspect}")
+ end
+ @io.write("\n")
+ begin
+ @level += 1
+ super
+ ensure
+ @level -= 1
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/safe_marshal/visitors/to_ruby.rb b/lib/rubygems/safe_marshal/visitors/to_ruby.rb
new file mode 100644
index 0000000000..a1f9481776
--- /dev/null
+++ b/lib/rubygems/safe_marshal/visitors/to_ruby.rb
@@ -0,0 +1,428 @@
+# frozen_string_literal: true
+
+require_relative "visitor"
+
+module Gem::SafeMarshal
+ module Visitors
+ class ToRuby < Visitor
+ def initialize(permitted_classes:, permitted_symbols:, permitted_ivars:)
+ @permitted_classes = permitted_classes
+ @permitted_symbols = ["E"].concat(permitted_symbols).concat(permitted_classes)
+ @permitted_ivars = permitted_ivars
+
+ @objects = []
+ @symbols = []
+ @class_cache = {}
+
+ @stack = ["root"]
+ @stack_idx = 1
+ end
+
+ def inspect # :nodoc:
+ format("#<%s permitted_classes: %p permitted_symbols: %p permitted_ivars: %p>",
+ self.class, @permitted_classes, @permitted_symbols, @permitted_ivars)
+ end
+
+ def visit(target)
+ stack_idx = @stack_idx
+ super
+ ensure
+ @stack_idx = stack_idx - 1
+ end
+
+ private
+
+ def push_stack(element)
+ @stack[@stack_idx] = element
+ @stack_idx += 1
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Array(a)
+ array = register_object([])
+
+ elements = a.elements
+ size = elements.size
+ idx = 0
+ # not idiomatic, but there's a huge number of IMEMOs allocated here, so we avoid the block
+ # because this is such a hot path when doing a bundle install with the full index
+ while idx < size
+ push_stack idx
+ array << visit(elements[idx])
+ idx += 1
+ end
+
+ array
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Symbol(s)
+ name = s.name
+ raise UnpermittedSymbolError.new(symbol: name, stack: formatted_stack) unless @permitted_symbols.include?(name)
+ visit_symbol_type(s)
+ end
+
+ def map_ivars(klass, ivars)
+ stack_idx = @stack_idx
+ ivars.map.with_index do |(k, v), i|
+ @stack_idx = stack_idx
+
+ push_stack "ivar_"
+ push_stack i
+ k = resolve_ivar(klass, k)
+
+ @stack_idx = stack_idx
+ push_stack k
+
+ next k, visit(v)
+ end
+ end
+
+ def visit_Gem_SafeMarshal_Elements_WithIvars(e)
+ object_offset = @objects.size
+ push_stack "object"
+ object = visit(e.object)
+ ivars = map_ivars(object.class, e.ivars)
+
+ case e.object
+ when Elements::UserDefined
+ if object.class == ::Time
+ internal = []
+
+ ivars.reject! do |k, v|
+ case k
+ when :offset, :zone, :nano_num, :nano_den, :submicro
+ internal << [k, v]
+ true
+ else
+ false
+ end
+ end
+
+ s = e.object.binary_string
+ # 122 is the largest integer that can be represented in marshal in a single byte
+ raise TimeTooLargeError.new("binary string too large", stack: formatted_stack) if s.bytesize > 122
+
+ marshal_string = "\x04\bIu:\tTime".b
+ marshal_string.concat(s.bytesize + 5)
+ marshal_string << s
+ # internal is limited to 5, so no overflow is possible
+ marshal_string.concat(internal.size + 5)
+
+ internal.each do |k, v|
+ k = k.name
+ # ivar name can't be too large because only known ivars are in the internal ivars list
+ marshal_string.concat(":")
+ marshal_string.concat(k.bytesize + 5)
+ marshal_string.concat(k)
+ dumped = Marshal.dump(v)
+ dumped[0, 2] = ""
+ marshal_string.concat(dumped)
+ end
+
+ object = @objects[object_offset] = Marshal.load(marshal_string)
+ end
+ when Elements::String
+ enc = nil
+
+ ivars.reject! do |k, v|
+ case k
+ when :E
+ case v
+ when TrueClass
+ enc = "UTF-8"
+ when FalseClass
+ enc = "US-ASCII"
+ else
+ raise FormatError, "Unexpected value for String :E #{v.inspect}"
+ end
+ when :encoding
+ enc = v
+ else
+ next false
+ end
+ true
+ end
+
+ object.force_encoding(enc) if enc
+ end
+
+ ivars.each do |k, v|
+ object.instance_variable_set k, v
+ end
+ object
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Hash(o)
+ hash = register_object({})
+
+ o.pairs.each_with_index do |(k, v), i|
+ push_stack i
+ k = visit(k)
+ push_stack k
+ hash[k] = visit(v)
+ end
+
+ hash
+ end
+
+ def visit_Gem_SafeMarshal_Elements_HashWithDefaultValue(o)
+ hash = visit_Gem_SafeMarshal_Elements_Hash(o)
+ push_stack :default
+ hash.default = visit(o.default)
+ hash
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Object(o)
+ register_object(resolve_class(o.name).allocate)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_ObjectLink(o)
+ @objects.fetch(o.offset)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_SymbolLink(o)
+ @symbols.fetch(o.offset)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_UserDefined(o)
+ register_object(call_method(resolve_class(o.name), :_load, o.binary_string))
+ end
+
+ def visit_Gem_SafeMarshal_Elements_UserMarshal(o)
+ klass = resolve_class(o.name)
+ compat = COMPAT_CLASSES.fetch(klass, nil)
+ idx = @objects.size
+ object = register_object(call_method(compat || klass, :allocate))
+
+ push_stack :data
+ ret = call_method(object, :marshal_load, visit(o.data))
+
+ if compat
+ object = @objects[idx] = ret
+ end
+
+ object
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Integer(i)
+ i.int
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Nil(_)
+ nil
+ end
+
+ def visit_Gem_SafeMarshal_Elements_True(_)
+ true
+ end
+
+ def visit_Gem_SafeMarshal_Elements_False(_)
+ false
+ end
+
+ def visit_Gem_SafeMarshal_Elements_String(s)
+ register_object(+s.str)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Float(f)
+ register_object(
+ case f.string
+ when "inf"
+ ::Float::INFINITY
+ when "-inf"
+ -::Float::INFINITY
+ when "nan"
+ ::Float::NAN
+ else
+ f.string.to_f
+ end
+ )
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Bignum(b)
+ result = 0
+ b.data.each_byte.with_index do |byte, exp|
+ result += (byte * 2**(exp * 8))
+ end
+
+ case b.sign
+ when 43 # ?+
+ result
+ when 45 # ?-
+ -result
+ else
+ raise FormatError, "Unexpected sign for Bignum #{b.sign.chr.inspect} (#{b.sign})"
+ end
+ end
+
+ def visit_Gem_SafeMarshal_Elements_UserClass(r)
+ if resolve_class(r.name) == ::Hash && r.wrapped_object.is_a?(Elements::Hash)
+
+ hash = register_object({}.compare_by_identity)
+
+ o = r.wrapped_object
+ o.pairs.each_with_index do |(k, v), i|
+ push_stack i
+ k = visit(k)
+ push_stack k
+ hash[k] = visit(v)
+ end
+
+ if o.is_a?(Elements::HashWithDefaultValue)
+ push_stack :default
+ hash.default = visit(o.default)
+ end
+
+ hash
+ else
+ raise UnsupportedError.new("Unsupported user class #{resolve_class(r.name)} in marshal stream", stack: formatted_stack)
+ end
+ end
+
+ def resolve_class(n)
+ @class_cache[n] ||= begin
+ to_s = resolve_symbol_name(n)
+ raise UnpermittedClassError.new(name: to_s, stack: formatted_stack) unless @permitted_classes.include?(to_s)
+ visit_symbol_type(n)
+ begin
+ ::Object.const_get(to_s)
+ rescue NameError
+ raise ArgumentError, "Undefined class #{to_s.inspect}"
+ end
+ end
+ end
+
+ class RationalCompat
+ def marshal_load(s)
+ num, den = s
+ raise ArgumentError, "Expected 2 ints" unless s.size == 2 && num.is_a?(Integer) && den.is_a?(Integer)
+ Rational(num, den)
+ end
+ end
+ private_constant :RationalCompat
+
+ COMPAT_CLASSES = {}.tap do |h|
+ h[Rational] = RationalCompat
+ end.compare_by_identity.freeze
+ private_constant :COMPAT_CLASSES
+
+ def resolve_ivar(klass, name)
+ to_s = resolve_symbol_name(name)
+
+ raise UnpermittedIvarError.new(symbol: to_s, klass: klass, stack: formatted_stack) unless @permitted_ivars.fetch(klass.name, [].freeze).include?(to_s)
+
+ visit_symbol_type(name)
+ end
+
+ def visit_symbol_type(element)
+ case element
+ when Elements::Symbol
+ sym = element.name.to_sym
+ @symbols << sym
+ sym
+ when Elements::SymbolLink
+ visit_Gem_SafeMarshal_Elements_SymbolLink(element)
+ end
+ end
+
+ # This is a hot method, so avoid respond_to? checks on every invocation
+ if :read.respond_to?(:name)
+ def resolve_symbol_name(element)
+ case element
+ when Elements::Symbol
+ element.name
+ when Elements::SymbolLink
+ visit_Gem_SafeMarshal_Elements_SymbolLink(element).name
+ else
+ raise FormatError, "Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}"
+ end
+ end
+ else
+ def resolve_symbol_name(element)
+ case element
+ when Elements::Symbol
+ element.name
+ when Elements::SymbolLink
+ visit_Gem_SafeMarshal_Elements_SymbolLink(element).to_s
+ else
+ raise FormatError, "Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}"
+ end
+ end
+ end
+
+ def register_object(o)
+ @objects << o
+ o
+ end
+
+ def call_method(receiver, method, *args)
+ receiver.__send__(method, *args)
+ rescue NoMethodError => e
+ raise unless e.receiver == receiver
+
+ raise MethodCallError, "Unable to call #{method.inspect} on #{receiver.inspect}, perhaps it is a class using marshal compat, which is not visible in ruby? #{e}"
+ end
+
+ def formatted_stack
+ formatted = []
+ @stack[0, @stack_idx].each do |e|
+ if e.is_a?(Integer)
+ if formatted.last == "ivar_"
+ formatted[-1] = "ivar_#{e}"
+ else
+ formatted << "[#{e}]"
+ end
+ else
+ formatted << e
+ end
+ end
+ formatted
+ end
+
+ class Error < StandardError
+ end
+
+ class TimeTooLargeError < Error
+ def initialize(message, stack:)
+ super "#{message} @ #{stack.join "."}"
+ end
+ end
+
+ class UnpermittedSymbolError < Error
+ def initialize(symbol:, stack:)
+ @symbol = symbol
+ @stack = stack
+ super "Attempting to load unpermitted symbol #{symbol.inspect} @ #{stack.join "."}"
+ end
+ end
+
+ class UnpermittedIvarError < Error
+ def initialize(symbol:, klass:, stack:)
+ @symbol = symbol
+ @klass = klass
+ @stack = stack
+ super "Attempting to set unpermitted ivar #{symbol.inspect} on object of class #{klass} @ #{stack.join "."}"
+ end
+ end
+
+ class UnpermittedClassError < Error
+ def initialize(name:, stack:)
+ @name = name
+ @stack = stack
+ super "Attempting to load unpermitted class #{name.inspect} @ #{stack.join "."}"
+ end
+ end
+
+ class UnsupportedError < Error
+ def initialize(message, stack:)
+ super "#{message} @ #{stack.join "."}"
+ end
+ end
+
+ class FormatError < Error
+ end
+
+ class MethodCallError < Error
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/safe_marshal/visitors/visitor.rb b/lib/rubygems/safe_marshal/visitors/visitor.rb
new file mode 100644
index 0000000000..c9a079dc0e
--- /dev/null
+++ b/lib/rubygems/safe_marshal/visitors/visitor.rb
@@ -0,0 +1,74 @@
+# frozen_string_literal: true
+
+module Gem::SafeMarshal::Visitors
+ class Visitor
+ def visit(target)
+ send DISPATCH.fetch(target.class), target
+ end
+
+ private
+
+ DISPATCH = Gem::SafeMarshal::Elements.constants.each_with_object({}) do |c, h|
+ next if c == :Element
+
+ klass = Gem::SafeMarshal::Elements.const_get(c)
+ h[klass] = :"visit_#{klass.name.gsub("::", "_")}"
+ h.default = :visit_unknown_element
+ end.compare_by_identity.freeze
+ private_constant :DISPATCH
+
+ def visit_unknown_element(e)
+ raise ArgumentError, "Attempting to visit unknown element #{e.inspect}"
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Array(target)
+ target.elements.each {|e| visit(e) }
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Bignum(target); end
+ def visit_Gem_SafeMarshal_Elements_False(target); end
+ def visit_Gem_SafeMarshal_Elements_Float(target); end
+
+ def visit_Gem_SafeMarshal_Elements_Hash(target)
+ target.pairs.each do |k, v|
+ visit(k)
+ visit(v)
+ end
+ end
+
+ def visit_Gem_SafeMarshal_Elements_HashWithDefaultValue(target)
+ visit_Gem_SafeMarshal_Elements_Hash(target)
+ visit(target.default)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_Integer(target); end
+ def visit_Gem_SafeMarshal_Elements_Nil(target); end
+
+ def visit_Gem_SafeMarshal_Elements_Object(target)
+ visit(target.name)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_ObjectLink(target); end
+ def visit_Gem_SafeMarshal_Elements_String(target); end
+ def visit_Gem_SafeMarshal_Elements_Symbol(target); end
+ def visit_Gem_SafeMarshal_Elements_SymbolLink(target); end
+ def visit_Gem_SafeMarshal_Elements_True(target); end
+
+ def visit_Gem_SafeMarshal_Elements_UserDefined(target)
+ visit(target.name)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_UserMarshal(target)
+ visit(target.name)
+ visit(target.data)
+ end
+
+ def visit_Gem_SafeMarshal_Elements_WithIvars(target)
+ visit(target.object)
+ target.ivars.each do |k, v|
+ visit(k)
+ visit(v)
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb
index c6135e9eb2..f4bba00136 100644
--- a/lib/rubygems/safe_yaml.rb
+++ b/lib/rubygems/safe_yaml.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module Gem
###
# This module is used for safely loading YAML specs from a gem. The
@@ -23,12 +25,31 @@ module Gem
runtime
].freeze
+ @aliases_enabled = true
+ def self.aliases_enabled=(value) # :nodoc:
+ @aliases_enabled = !!value
+ end
+
+ def self.aliases_enabled? # :nodoc:
+ @aliases_enabled
+ end
+
def self.safe_load(input)
- ::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
+ if Gem.use_psych?
+ ::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES,
+ permitted_symbols: PERMITTED_SYMBOLS, aliases: @aliases_enabled)
+ else
+ Gem::YAMLSerializer.load(
+ input,
+ permitted_classes: PERMITTED_CLASSES,
+ permitted_symbols: PERMITTED_SYMBOLS,
+ aliases: aliases_enabled?
+ )
+ end
end
- def self.load(input)
- ::Psych.safe_load(input, permitted_classes: [::Symbol])
+ class << self
+ alias_method :load, :safe_load
end
end
end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index ab28106056..69ba87b07f 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -322,7 +323,7 @@ require_relative "openssl"
# == Original author
#
# Paul Duncan <pabs@pablotron.org>
-# http://pablotron.org/
+# https://pablotron.org/
module Gem::Security
##
@@ -397,8 +398,7 @@ module Gem::Security
#
# The +extensions+ restrict the key to the indicated uses.
- def self.create_cert(subject, key, age = ONE_YEAR, extensions = EXTENSIONS,
- serial = 1)
+ def self.create_cert(subject, key, age = ONE_YEAR, extensions = EXTENSIONS, serial = 1)
cert = OpenSSL::X509::Certificate.new
cert.public_key = get_public_key(key)
@@ -449,8 +449,7 @@ module Gem::Security
# Creates a self-signed certificate with an issuer and subject of +subject+
# and the given +extensions+ for the +key+.
- def self.create_cert_self_signed(subject, key, age = ONE_YEAR,
- extensions = EXTENSIONS, serial = 1)
+ def self.create_cert_self_signed(subject, key, age = ONE_YEAR, extensions = EXTENSIONS, serial = 1)
certificate = create_cert subject, key, age, extensions
sign certificate, key, certificate, age, extensions, serial
@@ -506,8 +505,7 @@ module Gem::Security
#--
# TODO increment serial
- def self.re_sign(expired_certificate, private_key, age = ONE_YEAR,
- extensions = EXTENSIONS)
+ def self.re_sign(expired_certificate, private_key, age = ONE_YEAR, extensions = EXTENSIONS)
raise Gem::Security::Exception,
"incorrect signing key for re-signing " +
expired_certificate.subject.to_s unless
@@ -519,7 +517,7 @@ module Gem::Security
issuer = alt_name_or_x509_entry expired_certificate, :issuer
raise Gem::Security::Exception,
- "#{subject} is not self-signed, contact #{issuer} " +
+ "#{subject} is not self-signed, contact #{issuer} " \
"to obtain a valid certificate"
end
@@ -543,8 +541,7 @@ module Gem::Security
#
# Returns the newly signed certificate.
- def self.sign(certificate, signing_key, signing_cert,
- age = ONE_YEAR, extensions = EXTENSIONS, serial = 1)
+ def self.sign(certificate, signing_key, signing_cert, age = ONE_YEAR, extensions = EXTENSIONS, serial = 1)
signee_subject = certificate.subject
signee_key = certificate.public_key
@@ -592,7 +589,7 @@ module Gem::Security
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
# passed to +to_pem+.
- def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
+ def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
path = File.expand_path path
File.open path, "wb", permissions do |io|
diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb
index 368a24e95d..41f66043ad 100644
--- a/lib/rubygems/security/policies.rb
+++ b/lib/rubygems/security/policies.rb
@@ -1,16 +1,17 @@
# frozen_string_literal: true
+
module Gem::Security
##
# No security policy: all package signature checks are disabled.
NoSecurity = Policy.new(
"No Security",
- :verify_data => false,
- :verify_signer => false,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
+ verify_data: false,
+ verify_signer: false,
+ verify_chain: false,
+ verify_root: false,
+ only_trusted: false,
+ only_signed: false
)
##
@@ -23,12 +24,12 @@ module Gem::Security
AlmostNoSecurity = Policy.new(
"Almost No Security",
- :verify_data => true,
- :verify_signer => false,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
+ verify_data: true,
+ verify_signer: false,
+ verify_chain: false,
+ verify_root: false,
+ only_trusted: false,
+ only_signed: false
)
##
@@ -40,12 +41,12 @@ module Gem::Security
LowSecurity = Policy.new(
"Low Security",
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
+ verify_data: true,
+ verify_signer: true,
+ verify_chain: false,
+ verify_root: false,
+ only_trusted: false,
+ only_signed: false
)
##
@@ -59,12 +60,12 @@ module Gem::Security
MediumSecurity = Policy.new(
"Medium Security",
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => true,
- :verify_root => true,
- :only_trusted => true,
- :only_signed => false
+ verify_data: true,
+ verify_signer: true,
+ verify_chain: true,
+ verify_root: true,
+ only_trusted: true,
+ only_signed: false
)
##
@@ -78,12 +79,12 @@ module Gem::Security
HighSecurity = Policy.new(
"High Security",
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => true,
- :verify_root => true,
- :only_trusted => true,
- :only_signed => true
+ verify_data: true,
+ verify_signer: true,
+ verify_chain: true,
+ verify_root: true,
+ only_trusted: true,
+ only_signed: true
)
##
@@ -91,12 +92,12 @@ module Gem::Security
SigningPolicy = Policy.new(
"Signing Policy",
- :verify_data => false,
- :verify_signer => true,
- :verify_chain => true,
- :verify_root => true,
- :only_trusted => false,
- :only_signed => false
+ verify_data: false,
+ verify_signer: true,
+ verify_chain: true,
+ verify_root: true,
+ only_trusted: false,
+ only_signed: false
)
##
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index d4449d670d..128958ab80 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "../user_interaction"
##
@@ -134,7 +135,7 @@ class Gem::Security::Policy
raise Gem::Security::Exception, "missing root certificate" unless root
raise Gem::Security::Exception,
- "root certificate #{root.subject} is not self-signed " +
+ "root certificate #{root.subject} is not self-signed " \
"(issuer #{root.issuer})" if
root.issuer != root.subject
@@ -142,7 +143,7 @@ class Gem::Security::Policy
end
##
- # Ensures the root of +chain+ has a trusted certificate in +trust_dir+ and
+ # Ensures the root of +chain+ has a trusted certificate in Gem::Security.trust_dir and
# the digests of the two certificates match according to +digester+
def check_trust(chain, digester, trust_dir)
@@ -170,7 +171,7 @@ class Gem::Security::Policy
cert_dgst = digester.digest pkey_str
raise Gem::Security::Exception,
- "trusted root certificate #{root.subject} checksum " +
+ "trusted root certificate #{root.subject} checksum " \
"does not match signing root certificate checksum" unless
save_dgst == cert_dgst
@@ -191,11 +192,8 @@ class Gem::Security::Policy
end
def inspect # :nodoc:
- ("[Policy: %s - data: %p signer: %p chain: %p root: %p " +
- "signed-only: %p trusted-only: %p]") % [
- @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
- @only_signed, @only_trusted
- ]
+ format("[Policy: %s - data: %p signer: %p chain: %p root: %p " \
+ "signed-only: %p trusted-only: %p]", @name, @verify_chain, @verify_data, @verify_root, @verify_signer, @only_signed, @only_trusted)
end
##
@@ -205,8 +203,7 @@ class Gem::Security::Policy
#
# If +key+ is given it is used to validate the signing certificate.
- def verify(chain, key = nil, digests = {}, signatures = {},
- full_name = "(unknown)")
+ def verify(chain, key = nil, digests = {}, signatures = {}, full_name = "(unknown)")
if signatures.empty?
if @only_signed
raise Gem::Security::Exception,
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index cca82f1cf8..eeeeb52906 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Basic OpenSSL-based package signing class.
@@ -51,7 +52,7 @@ class Gem::Security::Signer
re_signed_cert = Gem::Security.re_sign(
expired_cert,
private_key,
- (Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days)
+ Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days
)
Gem::Security.write(re_signed_cert, expired_cert_path)
@@ -105,7 +106,7 @@ class Gem::Security::Signer
# this value is preferred, otherwise the subject is used.
def extract_name(cert) # :nodoc:
- subject_alt_name = cert.extensions.find {|e| "subjectAltName" == e.oid }
+ subject_alt_name = cert.extensions.find {|e| e.oid == "subjectAltName" }
if subject_alt_name
/\Aemail:/ =~ subject_alt_name.value # rubocop:disable Performance/StartWith
@@ -174,10 +175,18 @@ class Gem::Security::Signer
old_cert = @cert_chain.last
disk_cert_path = File.join(Gem.default_cert_path)
- disk_cert = File.read(disk_cert_path) rescue nil
+ disk_cert = begin
+ File.read(disk_cert_path)
+ rescue StandardError
+ nil
+ end
disk_key_path = File.join(Gem.default_key_path)
- disk_key = OpenSSL::PKey.read(File.read(disk_key_path), @passphrase) rescue nil
+ disk_key = begin
+ OpenSSL::PKey.read(File.read(disk_key_path), @passphrase)
+ rescue StandardError
+ nil
+ end
return unless disk_key
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index df59680d84..d23d161cfe 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The TrustDir manages the trusted certificates for gem signature
# verification.
@@ -8,8 +9,8 @@ class Gem::Security::TrustDir
# Default permissions for the trust directory and its contents
DEFAULT_PERMISSIONS = {
- :trust_dir => 0700,
- :trusted_cert => 0600,
+ trust_dir: 0o700,
+ trusted_cert: 0o600,
}.freeze
##
@@ -44,13 +45,11 @@ class Gem::Security::TrustDir
glob = File.join @dir, "*.pem"
Dir[glob].each do |certificate_file|
- begin
- certificate = load_certificate certificate_file
+ certificate = load_certificate certificate_file
- yield certificate, certificate_file
- rescue OpenSSL::X509::CertificateError
- next # HACK warn
- end
+ yield certificate, certificate_file
+ rescue OpenSSL::X509::CertificateError
+ next # HACK: warn
end
end
@@ -92,7 +91,7 @@ class Gem::Security::TrustDir
destination = cert_path certificate
- File.open destination, "wb", 0600 do |io|
+ File.open destination, "wb", 0o600 do |io|
io.write certificate.to_pem
io.chmod(@permissions[:trusted_cert])
end
@@ -110,9 +109,9 @@ class Gem::Security::TrustDir
"trust directory #{@dir} is not a directory" unless
File.directory? @dir
- FileUtils.chmod 0700, @dir
+ FileUtils.chmod 0o700, @dir
else
- FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir]
+ FileUtils.mkdir_p @dir, mode: @permissions[:trust_dir]
end
end
end
diff --git a/lib/rubygems/security_option.rb b/lib/rubygems/security_option.rb
index c9d72f4a89..3a101fe9db 100644
--- a/lib/rubygems/security_option.rb
+++ b/lib/rubygems/security_option.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 7c3a7534a8..86717e3e71 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -5,16 +5,16 @@ require_relative "text"
# A Source knows how to list and fetch gems from a RubyGems marshal index.
#
# There are other Source subclasses for installed gems, local gems, the
-# bundler dependency API and so-forth.
+# Compact Index API and so-forth.
class Gem::Source
include Comparable
include Gem::Text
FILES = { # :nodoc:
- :released => "specs",
- :latest => "latest_specs",
- :prerelease => "prerelease_specs",
+ released: "specs",
+ latest: "latest_specs",
+ prerelease: "prerelease_specs",
}.freeze
##
@@ -56,8 +56,6 @@ class Gem::Source
return 1 unless @uri.to_s == other.uri.to_s
0
- else
- nil
end
end
@@ -69,28 +67,11 @@ class Gem::Source
##
# Returns a Set that can fetch specifications from this source.
-
- def dependency_resolver_set # :nodoc:
- return Gem::Resolver::IndexSet.new self if "file" == uri.scheme
-
- fetch_uri = if uri.host == "rubygems.org"
- index_uri = uri.dup
- index_uri.host = "index.rubygems.org"
- index_uri
- else
- uri
- end
-
- bundler_api_uri = enforce_trailing_slash(fetch_uri)
-
- begin
- fetcher = Gem::RemoteFetcher.fetcher
- response = fetcher.fetch_path bundler_api_uri, nil, true
- rescue Gem::RemoteFetcher::FetchError
- Gem::Resolver::IndexSet.new self
- else
- Gem::Resolver::APISet.new response.uri + "./info/"
- end
+ #
+ # The set will optionally fetch prereleases if requested.
+ #
+ def dependency_resolver_set(prerelease = false)
+ new_dependency_resolver_set.tap {|set| set.prerelease = prerelease }
end
def hash # :nodoc:
@@ -102,8 +83,7 @@ class Gem::Source
def cache_dir(uri)
# Correct for windows paths
- escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/')
- escaped_path.tap(&Gem::UNTAINT)
+ escaped_path = uri.path.sub(%r{^/([a-z]):/}i, '/\\1-/')
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
end
@@ -122,7 +102,7 @@ class Gem::Source
end
##
- # Fetches a specification for the given +name_tuple+.
+ # Fetches a specification for the given Gem::NameTuple.
def fetch_spec(name_tuple)
fetcher = Gem::RemoteFetcher.fetcher
@@ -137,7 +117,12 @@ class Gem::Source
if File.exist? local_spec
spec = Gem.read_binary local_spec
- spec = Marshal.load(spec) rescue nil
+ Gem.load_safe_marshal
+ spec = begin
+ Gem::SafeMarshal.safe_load(spec)
+ rescue StandardError
+ nil
+ end
return spec if spec
end
@@ -155,8 +140,9 @@ class Gem::Source
end
end
+ Gem.load_safe_marshal
# TODO: Investigate setting Gem::Specification#loaded_from to a URI
- Marshal.load spec
+ Gem::SafeMarshal.safe_load spec
end
##
@@ -186,8 +172,9 @@ class Gem::Source
spec_dump = fetcher.cache_update_path spec_path, local_file, update_cache?
+ Gem.load_safe_marshal
begin
- Gem::NameTuple.from_list Marshal.load(spec_dump)
+ Gem::NameTuple.from_list Gem::SafeMarshal.safe_load(spec_dump)
rescue ArgumentError
if update_cache? && !retried
FileUtils.rm local_file
@@ -203,33 +190,58 @@ class Gem::Source
# Downloads +spec+ and writes it to +dir+. See also
# Gem::RemoteFetcher#download.
- def download(spec, dir=Dir.pwd)
+ def download(spec, dir = Dir.pwd)
fetcher = Gem::RemoteFetcher.fetcher
fetcher.download spec, uri.to_s, dir
end
def pretty_print(q) # :nodoc:
- q.group 2, "[Remote:", "]" do
- q.breakable
- q.text @uri.to_s
-
- if api = uri
+ q.object_group(self) do
+ q.group 2, "[Remote:", "]" do
q.breakable
- q.text "API URI: "
- q.text api.to_s
+ q.text @uri.to_s
+
+ if api = uri
+ q.breakable
+ q.text "API URI: "
+ q.text api.to_s
+ end
end
end
end
- def typo_squatting?(host, distance_threshold=4)
+ def typo_squatting?(host, distance_threshold = 4)
return if @uri.host.nil?
levenshtein_distance(@uri.host, host).between? 1, distance_threshold
end
private
+ def new_dependency_resolver_set
+ return Gem::Resolver::IndexSet.new self if uri.scheme == "file"
+
+ fetch_uri = if uri.host == "rubygems.org"
+ index_uri = uri.dup
+ index_uri.host = "index.rubygems.org"
+ index_uri
+ else
+ uri
+ end
+
+ bundler_api_uri = enforce_trailing_slash(fetch_uri) + "versions"
+
+ begin
+ fetcher = Gem::RemoteFetcher.fetcher
+ response = fetcher.fetch_path bundler_api_uri, nil, true
+ rescue Gem::RemoteFetcher::FetchError
+ Gem::Resolver::IndexSet.new self
+ else
+ Gem::Resolver::APISet.new response.uri + "./info/"
+ end
+ end
+
def enforce_trailing_slash(uri)
- uri.merge(uri.path.gsub(/\/+$/, "") + "/")
+ uri.merge(uri.path.gsub(%r{/+$}, "") + "/")
end
end
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index 7ac685f978..baf2f9dd4c 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -58,7 +58,6 @@ class Gem::Source::Git < Gem::Source
@remote = true
@root_dir = Gem.dir
- @git = ENV["git"] || "git"
end
def <=>(other)
@@ -70,8 +69,6 @@ class Gem::Source::Git < Gem::Source
-1
when Gem::Source then
1
- else
- nil
end
end
@@ -83,6 +80,10 @@ class Gem::Source::Git < Gem::Source
@need_submodules == other.need_submodules
end
+ def git_command
+ ENV.fetch("git", "git")
+ end
+
##
# Checks out the files for the repository into the install_dir.
@@ -92,18 +93,18 @@ class Gem::Source::Git < Gem::Source
return false unless File.exist? repo_cache_dir
unless File.exist? install_dir
- system @git, "clone", "--quiet", "--no-checkout",
+ system git_command, "clone", "--quiet", "--no-checkout",
repo_cache_dir, install_dir
end
Dir.chdir install_dir do
- system @git, "fetch", "--quiet", "--force", "--tags", install_dir
+ system git_command, "fetch", "--quiet", "--force", "--tags", install_dir
- success = system @git, "reset", "--quiet", "--hard", rev_parse
+ success = system git_command, "reset", "--quiet", "--hard", rev_parse
if @need_submodules
require "open3"
- _, status = Open3.capture2e(@git, "submodule", "update", "--quiet", "--init", "--recursive")
+ _, status = Open3.capture2e(git_command, "submodule", "update", "--quiet", "--init", "--recursive")
success &&= status.success?
end
@@ -120,11 +121,11 @@ class Gem::Source::Git < Gem::Source
if File.exist? repo_cache_dir
Dir.chdir repo_cache_dir do
- system @git, "fetch", "--quiet", "--force", "--tags",
+ system git_command, "fetch", "--quiet", "--force", "--tags",
@repository, "refs/heads/*:refs/heads/*"
end
else
- system @git, "clone", "--quiet", "--bare", "--no-hardlinks",
+ system git_command, "clone", "--quiet", "--bare", "--no-hardlinks",
@repository, repo_cache_dir
end
end
@@ -159,12 +160,14 @@ class Gem::Source::Git < Gem::Source
end
def pretty_print(q) # :nodoc:
- q.group 2, "[Git: ", "]" do
- q.breakable
- q.text @repository
+ q.object_group(self) do
+ q.group 2, "[Git: ", "]" do
+ q.breakable
+ q.text @repository
- q.breakable
- q.text @reference
+ q.breakable
+ q.text @reference
+ end
end
end
@@ -182,7 +185,7 @@ class Gem::Source::Git < Gem::Source
hash = nil
Dir.chdir repo_cache_dir do
- hash = Gem::Util.popen(@git, "rev-parse", @reference).strip
+ hash = Gem::Util.popen(git_command, "rev-parse", @reference).strip
end
raise Gem::Exception,
@@ -201,7 +204,7 @@ class Gem::Source::Git < Gem::Source
return [] unless install_dir
Dir.chdir install_dir do
- Dir["{,*,*/*}.gemspec"].map do |spec_file|
+ Dir["{,*,*/*}.gemspec"].filter_map do |spec_file|
directory = File.dirname spec_file
file = File.basename spec_file
@@ -218,19 +221,19 @@ class Gem::Source::Git < Gem::Source
end
spec
end
- end.compact
+ end
end
end
##
- # A hash for the git gem based on the git repository URI.
+ # A hash for the git gem based on the git repository Gem::URI.
def uri_hash # :nodoc:
require_relative "../openssl"
normalized =
- if @repository =~ %r{^\w+://(\w+@)?}
- uri = URI(@repository).normalize.to_s.sub %r{/$},""
+ if @repository.match?(%r{^\w+://(\w+@)?})
+ uri = Gem::URI(@repository).normalize.to_s.sub %r{/$},""
uri.sub(/\A(\w+)/) { $1.downcase }
else
@repository
diff --git a/lib/rubygems/source/installed.rb b/lib/rubygems/source/installed.rb
index 786faab3e3..f5c96fee51 100644
--- a/lib/rubygems/source/installed.rb
+++ b/lib/rubygems/source/installed.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Represents an installed gem. This is used for dependency resolution.
@@ -20,8 +21,6 @@ class Gem::Source::Installed < Gem::Source
0
when Gem::Source then
1
- else
- nil
end
end
@@ -33,6 +32,8 @@ class Gem::Source::Installed < Gem::Source
end
def pretty_print(q) # :nodoc:
- q.text "[Installed]"
+ q.object_group(self) do
+ q.text "[Installed]"
+ end
end
end
diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb
index 51d6d243a8..4bef31a265 100644
--- a/lib/rubygems/source/local.rb
+++ b/lib/rubygems/source/local.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# The local source finds gems in the current directory for fulfilling
# dependencies.
@@ -23,14 +24,12 @@ class Gem::Source::Local < Gem::Source
0
when Gem::Source then
1
- else
- nil
end
end
def inspect # :nodoc:
keys = @specs ? @specs.keys.sort : "NOT LOADED"
- "#<%s specs: %p>" % [self.class, keys]
+ format("#<%s specs: %p>", self.class, keys)
end
def load_specs(type) # :nodoc:
@@ -40,36 +39,35 @@ class Gem::Source::Local < Gem::Source
@specs = {}
Dir["*.gem"].each do |file|
- begin
- pkg = Gem::Package.new(file)
- rescue SystemCallError, Gem::Package::FormatError
- # ignore
- else
- tup = pkg.spec.name_tuple
- @specs[tup] = [File.expand_path(file), pkg]
-
- case type
- when :released
- unless pkg.spec.version.prerelease?
- names << pkg.spec.name_tuple
- end
- when :prerelease
- if pkg.spec.version.prerelease?
- names << pkg.spec.name_tuple
- end
- when :latest
- tup = pkg.spec.name_tuple
-
- cur = names.find {|x| x.name == tup.name }
- if !cur
- names << tup
- elsif cur.version < tup.version
- names.delete cur
- names << tup
- end
- else
+ pkg = Gem::Package.new(file)
+ spec = pkg.spec
+ rescue SystemCallError, Gem::Package::FormatError
+ # ignore
+ else
+ tup = spec.name_tuple
+ @specs[tup] = [File.expand_path(file), pkg]
+
+ case type
+ when :released
+ unless pkg.spec.version.prerelease?
names << pkg.spec.name_tuple
end
+ when :prerelease
+ if pkg.spec.version.prerelease?
+ names << pkg.spec.name_tuple
+ end
+ when :latest
+ tup = pkg.spec.name_tuple
+
+ cur = names.find {|x| x.name == tup.name }
+ if !cur
+ names << tup
+ elsif cur.version < tup.version
+ names.delete cur
+ names << tup
+ end
+ else
+ names << pkg.spec.name_tuple
end
end
@@ -77,27 +75,29 @@ class Gem::Source::Local < Gem::Source
end
end
- def find_gem(gem_name, version = Gem::Requirement.default, # :nodoc:
- prerelease = false)
+ def find_gem(gem_name, version = Gem::Requirement.default, prerelease = false) # :nodoc:
+ find_all_gems(gem_name, version, prerelease).max_by(&:version)
+ end
+
+ def find_all_gems(gem_name, version = Gem::Requirement.default, prerelease = false) # :nodoc:
load_specs :complete
found = []
@specs.each do |n, data|
- if n.name == gem_name
- s = data[1].spec
-
- if version.satisfied_by?(s.version)
- if prerelease
- found << s
- elsif !s.version.prerelease? || version.prerelease?
- found << s
- end
+ next unless n.name == gem_name
+ s = data[1].spec
+
+ if version.satisfied_by?(s.version)
+ if prerelease
+ found << s
+ elsif !s.version.prerelease? || version.prerelease?
+ found << s
end
end
end
- found.max_by {|s| s.version }
+ found
end
def fetch_spec(name) # :nodoc:
@@ -121,10 +121,14 @@ class Gem::Source::Local < Gem::Source
end
def pretty_print(q) # :nodoc:
- q.group 2, "[Local gems:", "]" do
- q.breakable
- q.seplist @specs.keys do |v|
- q.text v.full_name
+ q.object_group(self) do
+ q.group 2, "[Local gems:", "]" do
+ q.breakable
+ if @specs
+ q.seplist @specs.keys do |v|
+ q.text v.full_name
+ end
+ end
end
end
end
diff --git a/lib/rubygems/source/lock.rb b/lib/rubygems/source/lock.rb
index 49f097467b..70849210bd 100644
--- a/lib/rubygems/source/lock.rb
+++ b/lib/rubygems/source/lock.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A Lock source wraps an installed gem's source and sorts before other sources
# during dependency resolution. This allows RubyGems to prefer gems from
@@ -24,13 +25,11 @@ class Gem::Source::Lock < Gem::Source
@wrapped <=> other.wrapped
when Gem::Source then
1
- else
- nil
end
end
def ==(other) # :nodoc:
- 0 == (self <=> other)
+ (self <=> other) == 0
end
def hash # :nodoc:
diff --git a/lib/rubygems/source/specific_file.rb b/lib/rubygems/source/specific_file.rb
index 552aeba50f..dde1d48a21 100644
--- a/lib/rubygems/source/specific_file.rb
+++ b/lib/rubygems/source/specific_file.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# A source representing a single .gem file. This is used for installation of
# local gems.
@@ -33,7 +34,6 @@ class Gem::Source::SpecificFile < Gem::Source
def fetch_spec(name) # :nodoc:
return @spec if name == @name
raise Gem::Exception, "Unable to find '#{name}'"
- @spec
end
def download(spec, dir = nil) # :nodoc:
@@ -42,9 +42,11 @@ class Gem::Source::SpecificFile < Gem::Source
end
def pretty_print(q) # :nodoc:
- q.group 2, "[SpecificFile:", "]" do
- q.breakable
- q.text @path
+ q.object_group(self) do
+ q.group 2, "[SpecificFile:", "]" do
+ q.breakable
+ q.text @path
+ end
end
end
diff --git a/lib/rubygems/source/vendor.rb b/lib/rubygems/source/vendor.rb
index 543acf1388..44ef614441 100644
--- a/lib/rubygems/source/vendor.rb
+++ b/lib/rubygems/source/vendor.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# This represents a vendored source that is similar to an installed gem.
@@ -18,8 +19,6 @@ class Gem::Source::Vendor < Gem::Source::Installed
0
when Gem::Source then
1
- else
- nil
end
end
end
diff --git a/lib/rubygems/source_list.rb b/lib/rubygems/source_list.rb
index 3c1397d834..19bf4595c4 100644
--- a/lib/rubygems/source_list.rb
+++ b/lib/rubygems/source_list.rb
@@ -36,7 +36,7 @@ class Gem::SourceList
list.replace ary
- return list
+ list
end
def initialize_copy(other) # :nodoc:
@@ -44,7 +44,7 @@ class Gem::SourceList
end
##
- # Appends +obj+ to the source list which may be a Gem::Source, URI or URI
+ # Appends +obj+ to the source list which may be a Gem::Source, Gem::URI or URI
# String.
def <<(obj)
@@ -60,6 +60,42 @@ class Gem::SourceList
end
##
+ # Prepends +obj+ to the beginning of the source list which may be a Gem::Source, Gem::URI or URI
+ # Moves +obj+ to the beginning of the list if already present.
+ # String.
+
+ def prepend(obj)
+ src = case obj
+ when Gem::Source
+ obj
+ else
+ Gem::Source.new(obj)
+ end
+
+ @sources.delete(src) if @sources.include?(src)
+ @sources.unshift(src)
+ src
+ end
+
+ ##
+ # Appends +obj+ to the end of the source list, moving it if already present.
+ # +obj+ may be a Gem::Source, Gem::URI or URI String.
+ # Moves +obj+ to the end of the list if already present.
+
+ def append(obj)
+ src = case obj
+ when Gem::Source
+ obj
+ else
+ Gem::Source.new(obj)
+ end
+
+ @sources.delete(src) if @sources.include?(src)
+ @sources << src
+ src
+ end
+
+ ##
# Replaces this SourceList with the sources in +other+ See #<< for
# acceptable items in +other+.
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index 23f2d982d6..835dedf948 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative "remote_fetcher"
require_relative "user_interaction"
require_relative "errors"
@@ -68,9 +69,9 @@ class Gem::SpecFetcher
@prerelease_specs = {}
@caches = {
- :latest => @latest_specs,
- :prerelease => @prerelease_specs,
- :released => @specs,
+ latest: @latest_specs,
+ prerelease: @prerelease_specs,
+ released: @specs,
}
@fetcher = Gem::RemoteFetcher.fetcher
@@ -82,7 +83,7 @@ class Gem::SpecFetcher
#
# If +matching_platform+ is false, gems for all platforms are returned.
- def search_for_dependency(dependency, matching_platform=true)
+ def search_for_dependency(dependency, matching_platform = true)
found = {}
rejected_specs = {}
@@ -123,13 +124,13 @@ class Gem::SpecFetcher
tuples = tuples.sort_by {|x| x[0].version }
- return [tuples, errors]
+ [tuples, errors]
end
##
# Return all gem name tuples who's names match +obj+
- def detect(type=:complete)
+ def detect(type = :complete)
tuples = []
list, _ = available_specs(type)
@@ -149,21 +150,19 @@ class Gem::SpecFetcher
#
# If +matching_platform+ is false, gems for all platforms are returned.
- def spec_for_dependency(dependency, matching_platform=true)
+ def spec_for_dependency(dependency, matching_platform = true)
tuples, errors = search_for_dependency(dependency, matching_platform)
specs = []
tuples.each do |tup, source|
- begin
- spec = source.fetch_spec(tup)
- rescue Gem::RemoteFetcher::FetchError => e
- errors << Gem::SourceFetchProblem.new(source, e)
- else
- specs << [spec, source]
- end
+ spec = source.fetch_spec(tup)
+ rescue Gem::RemoteFetcher::FetchError => e
+ errors << Gem::SourceFetchProblem.new(source, e)
+ else
+ specs << [spec, source]
end
- return [specs, errors]
+ [specs, errors]
end
##
@@ -171,23 +170,55 @@ class Gem::SpecFetcher
# alternative gem names.
def suggest_gems_from_name(gem_name, type = :latest, num_results = 5)
- gem_name = gem_name.downcase.tr("_-", "")
- max = gem_name.size / 2
- names = available_specs(type).first.values.flatten(1)
+ gem_name = gem_name.downcase.tr("_-", "")
+
+ # All results for 3-character-or-shorter (minus hyphens/underscores) gem
+ # names get rejected, so we just return an empty array immediately instead.
+ return [] if gem_name.length <= 3
- matches = names.map do |n|
+ max = gem_name.size / 2
+ names = available_specs(type).first.values.flatten(1)
+
+ min_length = gem_name.length - max
+ max_length = gem_name.length + max
+
+ gem_name_with_postfix = "#{gem_name}ruby"
+ gem_name_with_prefix = "ruby#{gem_name}"
+
+ matches = names.filter_map do |n|
+ len = n.name.length
+ # If the gem doesn't support the current platform, bail early.
next unless n.match_platform?
- [n.name, 0] if n.name.downcase.tr("_-", "").include?(gem_name)
- end.compact
-
- if matches.length < num_results
- matches += names.map do |n|
- next unless n.match_platform?
- distance = levenshtein_distance gem_name, n.name.downcase.tr("_-", "")
- next if distance >= max
- return [n.name] if distance == 0
- [n.name, distance]
- end.compact
+
+ # If the length is min_length or shorter, we've done `max` deletions.
+ # This would be rejected later, so we skip it for performance.
+ next if len <= min_length
+
+ # The candidate name, normalized the same as gem_name.
+ normalized_name = n.name.downcase
+ normalized_name.tr!("_-", "")
+
+ # If the gem is "{NAME}-ruby" and "ruby-{NAME}", we want to return it.
+ # But we already removed hyphens, so we check "{NAME}ruby" and "ruby{NAME}".
+ next [n.name, 0] if normalized_name == gem_name_with_postfix
+ next [n.name, 0] if normalized_name == gem_name_with_prefix
+
+ # If the length is max_length or longer, we've done `max` insertions.
+ # This would be rejected later, so we skip it for performance.
+ next if len >= max_length
+
+ # If we found an exact match (after stripping underscores and hyphens),
+ # that's our most likely candidate.
+ # Return it immediately, and skip the rest of the loop.
+ return [n.name] if normalized_name == gem_name
+
+ distance = levenshtein_distance gem_name, normalized_name
+
+ # Skip current candidate, if the edit distance is greater than allowed.
+ next if distance >= max
+
+ # If all else fails, return the name and the calculated distance.
+ [n.name, distance]
end
matches = if matches.empty? && type != :prerelease
@@ -214,34 +245,32 @@ class Gem::SpecFetcher
list = {}
@sources.each_source do |source|
- begin
- names = case type
- when :latest
- tuples_for source, :latest
- when :released
- tuples_for source, :released
- when :complete
- names =
- tuples_for(source, :prerelease, true) +
- tuples_for(source, :released)
-
- names.sort
- when :abs_latest
- names =
- tuples_for(source, :prerelease, true) +
- tuples_for(source, :latest)
-
- names.sort
- when :prerelease
- tuples_for(source, :prerelease)
- else
- raise Gem::Exception, "Unknown type - :#{type}"
- end
- rescue Gem::RemoteFetcher::FetchError => e
- errors << Gem::SourceFetchProblem.new(source, e)
- else
- list[source] = names
+ names = case type
+ when :latest
+ tuples_for source, :latest
+ when :released
+ tuples_for source, :released
+ when :complete
+ names =
+ tuples_for(source, :prerelease, true) +
+ tuples_for(source, :released)
+
+ names.sort
+ when :abs_latest
+ names =
+ tuples_for(source, :prerelease, true) +
+ tuples_for(source, :latest)
+
+ names.sort
+ when :prerelease
+ tuples_for(source, :prerelease)
+ else
+ raise Gem::Exception, "Unknown type - :#{type}"
end
+ rescue Gem::RemoteFetcher::FetchError => e
+ errors << Gem::SourceFetchProblem.new(source, e)
+ else
+ list[source] = names
end
[list, errors]
@@ -251,9 +280,9 @@ class Gem::SpecFetcher
# Retrieves NameTuples from +source+ of the given +type+ (:prerelease,
# etc.). If +gracefully_ignore+ is true, errors are ignored.
- def tuples_for(source, type, gracefully_ignore=false) # :nodoc:
+ def tuples_for(source, type, gracefully_ignore = false) # :nodoc:
@caches[type][source.uri] ||=
- source.load_specs(type).sort_by {|tup| tup.name }
+ source.load_specs(type).sort_by(&:name)
rescue Gem::RemoteFetcher::FetchError
raise unless gracefully_ignore
[]
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 7acdb5c52a..51729d755b 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
@@ -6,11 +7,10 @@
# See LICENSE.txt for permissions.
#++
-require_relative "deprecate"
require_relative "basic_specification"
require_relative "stub_specification"
require_relative "platform"
-require_relative "util/list"
+require_relative "specification_record"
require "rbconfig"
@@ -34,10 +34,17 @@ require "rbconfig"
# Starting in RubyGems 2.0, a Specification can hold arbitrary
# metadata. See #metadata for restrictions on the format and size of metadata
# items you may add to a specification.
+#
+# Specifications must be deterministic, as in the example above. For instance,
+# you cannot define attributes conditionally:
+#
+# # INVALID: do not do this.
+# unless RUBY_ENGINE == "jruby"
+# s.extensions << "ext/example/extconf.rb"
+# end
+#
class Gem::Specification < Gem::BasicSpecification
- extend Gem::Deprecate
-
# REFACTOR: Consider breaking out this version stuff into a separate
# module. There's enough special stuff around it that it may justify
# a separate class.
@@ -107,7 +114,7 @@ class Gem::Specification < Gem::BasicSpecification
@load_cache = {} # :nodoc:
@load_cache_mutex = Thread::Mutex.new
- VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
# :startdoc:
@@ -126,35 +133,35 @@ class Gem::Specification < Gem::BasicSpecification
# Map of attribute names to default values.
@@default_value = {
- :authors => [],
- :autorequire => nil,
- :bindir => "bin",
- :cert_chain => [],
- :date => nil,
- :dependencies => [],
- :description => nil,
- :email => nil,
- :executables => [],
- :extensions => [],
- :extra_rdoc_files => [],
- :files => [],
- :homepage => nil,
- :licenses => [],
- :metadata => {},
- :name => nil,
- :platform => Gem::Platform::RUBY,
- :post_install_message => nil,
- :rdoc_options => [],
- :require_paths => ["lib"],
- :required_ruby_version => Gem::Requirement.default,
- :required_rubygems_version => Gem::Requirement.default,
- :requirements => [],
- :rubygems_version => Gem::VERSION,
- :signing_key => nil,
- :specification_version => CURRENT_SPECIFICATION_VERSION,
- :summary => nil,
- :test_files => [],
- :version => nil,
+ authors: [],
+ autorequire: nil,
+ bindir: "bin",
+ cert_chain: [],
+ date: nil,
+ dependencies: [],
+ description: nil,
+ email: nil,
+ executables: [],
+ extensions: [],
+ extra_rdoc_files: [],
+ files: [],
+ homepage: nil,
+ licenses: [],
+ metadata: {},
+ name: nil,
+ platform: Gem::Platform::RUBY,
+ post_install_message: nil,
+ rdoc_options: [],
+ require_paths: ["lib"],
+ required_ruby_version: Gem::Requirement.default,
+ required_rubygems_version: Gem::Requirement.default,
+ requirements: [],
+ rubygems_version: Gem::VERSION,
+ signing_key: nil,
+ specification_version: CURRENT_SPECIFICATION_VERSION,
+ summary: nil,
+ test_files: [],
+ version: nil,
}.freeze
# rubocop:disable Style/MutableConstant
@@ -167,35 +174,23 @@ class Gem::Specification < Gem::BasicSpecification
v.inspect
when String
v.dump
- when Numeric
- "default_value(:#{k})"
else
"default_value(:#{k}).dup"
end
end
- @@attributes = @@default_value.keys.sort_by {|s| s.to_s }
- @@array_attributes = @@default_value.reject {|_k,v| v != [] }.keys
+ @@attributes = @@default_value.keys.sort_by(&:to_s)
+ @@array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
@@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
@@default_value[k].nil?
end
- def self.clear_specs # :nodoc:
- @@all = nil
- @@stubs = nil
- @@stubs_by_name = {}
- @@spec_with_requirable_file = {}
- @@active_stub_with_requirable_file = {}
- end
- private_class_method :clear_specs
-
- clear_specs
-
# Sentinel object to represent "not found" stubs
NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
+ deprecate_constant :NOT_FOUND
# Tracking removed method calls to warn users during build time.
- REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
+ REMOVED_METHODS = [:rubyforge_project=, :mark_version].freeze # :nodoc:
def removed_method_calls
@removed_method_calls ||= []
end
@@ -302,7 +297,7 @@ class Gem::Specification < Gem::BasicSpecification
#
# Usage:
#
- # spec.description = <<-EOF
+ # spec.description = <<~EOF
# Rake is a Make-like program implemented in Ruby. Tasks and
# dependencies are specified in standard Ruby syntax.
# EOF
@@ -342,7 +337,7 @@ class Gem::Specification < Gem::BasicSpecification
# https://opensource.org/licenses/ approved.
#
# The most commonly used OSI-approved licenses are MIT and Apache-2.0.
- # GitHub also provides a license picker at http://choosealicense.com/.
+ # GitHub also provides a license picker at https://choosealicense.com/.
#
# You can also use a custom license file along with your gemspec and specify
# a LicenseRef-<idstring>, where idstring is the name of the file containing
@@ -401,7 +396,7 @@ class Gem::Specification < Gem::BasicSpecification
# "homepage_uri" => "https://bestgemever.example.io",
# "mailing_list_uri" => "https://groups.example.com/bestgemever",
# "source_code_uri" => "https://example.com/user/bestgemever",
- # "wiki_uri" => "https://example.com/user/bestgemever/wiki"
+ # "wiki_uri" => "https://example.com/user/bestgemever/wiki",
# "funding_uri" => "https://example.com/donate"
# }
#
@@ -427,11 +422,11 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # The path in the gem for executable scripts. Usually 'bin'
+ # The path in the gem for executable scripts. Usually 'exe'
#
# Usage:
#
- # spec.bindir = 'bin'
+ # spec.bindir = 'exe'
attr_accessor :bindir
@@ -474,10 +469,7 @@ class Gem::Specification < Gem::BasicSpecification
# spec.platform = Gem::Platform.local
def platform=(platform)
- if @original_platform.nil? ||
- @original_platform == Gem::Platform::RUBY
- @original_platform = platform
- end
+ @original_platform = platform
case platform
when Gem::Platform::CURRENT then
@@ -501,10 +493,6 @@ class Gem::Specification < Gem::BasicSpecification
end
@platform = @new_platform.to_s
-
- invalidate_memoized_attributes
-
- @new_platform
end
##
@@ -534,13 +522,6 @@ class Gem::Specification < Gem::BasicSpecification
attr_reader :required_rubygems_version
##
- # The version of RubyGems used to create this gem.
- #
- # Do not set this, it is set automatically when the gem is packaged.
-
- attr_accessor :rubygems_version
-
- ##
# The key used to sign this gem. See Gem::Security for details.
attr_accessor :signing_key
@@ -565,9 +546,9 @@ class Gem::Specification < Gem::BasicSpecification
#
# Usage:
#
- # spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'
+ # spec.add_dependency 'example', '~> 1.1', '>= 1.1.4'
- def add_runtime_dependency(gem, *requirements)
+ def add_dependency(gem, *requirements)
if requirements.uniq.size != requirements.size
warn "WARNING: duplicated #{gem} dependency #{requirements}"
end
@@ -578,7 +559,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# Executables included in the gem.
#
- # For example, the rake gem has rake as an executable. You don’t specify the
+ # For example, the rake gem has rake as an executable. You don't specify the
# full path (as in bin/rake); all application-style files are expected to be
# found in bindir. These files must be executable Ruby files. Files that
# use bash or other interpreters will not work.
@@ -599,7 +580,7 @@ class Gem::Specification < Gem::BasicSpecification
# extconf.rb-style files used to compile extensions.
#
# These files will be run when the gem is installed, causing the C (or
- # whatever) code to be compiled on the user’s machine.
+ # whatever) code to be compiled on the user's machine.
#
# Usage:
#
@@ -728,6 +709,21 @@ class Gem::Specification < Gem::BasicSpecification
end
######################################################################
+ # :section: Read-only attributes
+
+ ##
+ # The version of RubyGems used to create this gem.
+
+ attr_accessor :rubygems_version
+
+ ##
+ # The path where this gem installs its extensions.
+
+ def extensions_dir
+ @extensions_dir ||= super
+ end
+
+ ######################################################################
# :section: Specification internals
##
@@ -745,14 +741,6 @@ class Gem::Specification < Gem::BasicSpecification
attr_accessor :autorequire # :nodoc:
##
- # Sets the default executable for this gem.
- #
- # Deprecated: You must now specify the executable name to Gem.bin_path.
-
- attr_writer :default_executable
- rubygems_deprecate :default_executable=
-
- ##
# Allows deinstallation of gems with legacy platforms.
attr_writer :original_platform # :nodoc:
@@ -765,7 +753,7 @@ class Gem::Specification < Gem::BasicSpecification
attr_accessor :specification_version
def self._all # :nodoc:
- @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
+ specification_record.all
end
def self.clear_load_cache # :nodoc:
@@ -775,34 +763,22 @@ class Gem::Specification < Gem::BasicSpecification
end
private_class_method :clear_load_cache
+ def self.gem_path # :nodoc:
+ Gem.path
+ end
+ private_class_method :gem_path
+
def self.each_gemspec(dirs) # :nodoc:
dirs.each do |dir|
Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
- yield path.tap(&Gem::UNTAINT)
+ yield path
end
end
end
- def self.gemspec_stubs_in(dir, pattern)
+ def self.gemspec_stubs_in(dir, pattern) # :nodoc:
Gem::Util.glob_files_in_dir(pattern, dir).map {|path| yield path }.select(&:valid?)
end
- private_class_method :gemspec_stubs_in
-
- def self.installed_stubs(dirs, pattern)
- map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
- Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
- end
- end
- private_class_method :installed_stubs
-
- def self.map_stubs(dirs, pattern) # :nodoc:
- dirs.flat_map do |dir|
- base_dir = File.dirname dir
- gems_dir = File.join base_dir, "gems"
- gemspec_stubs_in(dir, pattern) {|path| yield path, base_dir, gems_dir }
- end
- end
- private_class_method :map_stubs
def self.each_spec(dirs) # :nodoc:
each_gemspec(dirs) do |path|
@@ -815,13 +791,7 @@ class Gem::Specification < Gem::BasicSpecification
# Returns a Gem::StubSpecification for every installed gem
def self.stubs
- @@stubs ||= begin
- pattern = "*.gemspec"
- stubs = stubs_for_pattern(pattern, false)
-
- @@stubs_by_name = stubs.select {|s| Gem::Platform.match_spec? s }.group_by(&:name)
- stubs
- end
+ specification_record.stubs
end
##
@@ -840,13 +810,7 @@ class Gem::Specification < Gem::BasicSpecification
# only returns stubs that match Gem.platforms
def self.stubs_for(name)
- if @@stubs
- @@stubs_by_name[name] || []
- else
- @@stubs_by_name[name] ||= stubs_for_pattern("#{name}-*.gemspec").select do |s|
- s.name == name
- end
- end
+ specification_record.stubs_for(name)
end
##
@@ -854,12 +818,7 @@ class Gem::Specification < Gem::BasicSpecification
# optionally filtering out specs not matching the current platform
#
def self.stubs_for_pattern(pattern, match_platform = true) # :nodoc:
- installed_stubs = installed_stubs(Gem::Specification.dirs, pattern)
- installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
- stubs = installed_stubs + default_stubs(pattern)
- stubs = stubs.uniq {|stub| stub.full_name }
- _resort!(stubs)
- stubs
+ specification_record.stubs_for_pattern(pattern, match_platform)
end
def self._resort!(specs) # :nodoc:
@@ -868,7 +827,11 @@ class Gem::Specification < Gem::BasicSpecification
next names if names.nonzero?
versions = b.version <=> a.version
next versions if versions.nonzero?
- Gem::Platform.sort_priority(b.platform)
+ platforms = Gem::Platform.sort_priority(b.platform) <=> Gem::Platform.sort_priority(a.platform)
+ next platforms if platforms.nonzero?
+ default_gem = a.default_gem_priority <=> b.default_gem_priority
+ next default_gem if default_gem.nonzero?
+ a.base_dir_priority(gem_path) <=> b.base_dir_priority(gem_path)
end
end
@@ -888,23 +851,14 @@ class Gem::Specification < Gem::BasicSpecification
# properly sorted.
def self.add_spec(spec)
- return if _all.include? spec
-
- _all << spec
- stubs << spec
- (@@stubs_by_name[spec.name] ||= []) << spec
-
- _resort!(@@stubs_by_name[spec.name])
- _resort!(stubs)
+ specification_record.add_spec(spec)
end
##
# Removes +spec+ from the known specs.
def self.remove_spec(spec)
- _all.delete spec.to_spec
- stubs.delete spec
- (@@stubs_by_name[spec.name] || []).delete spec
+ specification_record.remove_spec(spec)
end
##
@@ -912,33 +866,23 @@ class Gem::Specification < Gem::BasicSpecification
# You probably want to use one of the Enumerable methods instead.
def self.all
- warn "NOTE: Specification.all called from #{caller.first}" unless
+ warn "NOTE: Specification.all called from #{caller(1, 1).first}" unless
Gem::Deprecate.skip
_all
end
##
- # Sets the known specs to +specs+. Not guaranteed to work for you in
- # the future. Use at your own risk. Caveat emptor. Doomy doom doom.
- # Etc etc.
- #
- #--
- # Makes +specs+ the known specs
- # Listen, time is a river
- # Winter comes, code breaks
- #
- # -- wilsonb
+ # Sets the known specs to +specs+.
def self.all=(specs)
- @@stubs_by_name = specs.group_by(&:name)
- @@all = @@stubs = specs
+ specification_record.all = specs
end
##
# Return full names of all specs in sorted order.
def self.all_names
- self._all.map(&:full_name)
+ specification_record.all_names
end
##
@@ -963,9 +907,7 @@ class Gem::Specification < Gem::BasicSpecification
# Return the directories that Specification uses to find specs.
def self.dirs
- @@dirs ||= Gem.path.collect do |dir|
- File.join dir.dup.tap(&Gem::UNTAINT), "specifications"
- end
+ @@dirs ||= Gem::SpecificationRecord.dirs_from(gem_path)
end
##
@@ -973,9 +915,9 @@ class Gem::Specification < Gem::BasicSpecification
# this resets the list of known specs.
def self.dirs=(dirs)
- self.reset
+ reset
- @@dirs = Array(dirs).map {|dir| File.join dir, "specifications" }
+ @@dirs = Gem::SpecificationRecord.dirs_from(Array(dirs))
end
extend Enumerable
@@ -984,23 +926,15 @@ class Gem::Specification < Gem::BasicSpecification
# Enumerate every known spec. See ::dirs= and ::add_spec to set the list of
# specs.
- def self.each
- return enum_for(:each) unless block_given?
-
- self._all.each do |x|
- yield x
- end
+ def self.each(&block)
+ specification_record.each(&block)
end
##
# Returns every spec that matches +name+ and optional +requirements+.
def self.find_all_by_name(name, *requirements)
- requirements = Gem::Requirement.default if requirements.empty?
-
- # TODO: maybe try: find_all { |s| spec === dep }
-
- Gem::Dependency.new(name, *requirements).matching_specs
+ specification_record.find_all_by_name(name, *requirements)
end
##
@@ -1017,8 +951,6 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_name(name, *requirements)
requirements = Gem::Requirement.default if requirements.empty?
- # TODO: maybe try: find { |s| spec === dep }
-
Gem::Dependency.new(name, *requirements).to_spec
end
@@ -1032,11 +964,16 @@ class Gem::Specification < Gem::BasicSpecification
# Return the best specification that contains the file matching +path+.
def self.find_by_path(path)
- path = path.dup.freeze
- spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
- s.contains_requirable_file? path
- end || NOT_FOUND)
- spec.to_spec
+ specification_record.find_by_path(path)
+ end
+
+ ##
+ # Return the best specification that contains the file matching +path+
+ # amongst the specs that are not loaded. This method is different than
+ # +find_inactive_by_path+ as it will filter out loaded specs by their name.
+
+ def self.find_unloaded_by_path(path)
+ specification_record.find_unloaded_by_path(path)
end
##
@@ -1044,18 +981,15 @@ class Gem::Specification < Gem::BasicSpecification
# amongst the specs that are not activated.
def self.find_inactive_by_path(path)
- stub = stubs.find do |s|
- next if s.activated?
- s.contains_requirable_file? path
- end
- stub&.to_spec
+ specification_record.find_inactive_by_path(path)
end
+ ##
+ # Return the best specification that contains the file matching +path+, among
+ # those already activated.
+
def self.find_active_stub_by_path(path)
- stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
- s.activated? && s.contains_requirable_file?(path)
- end || NOT_FOUND)
- stub.this
+ specification_record.find_active_stub_by_path(path)
end
##
@@ -1072,7 +1006,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_in_unresolved_tree(path)
unresolved_specs.each do |spec|
spec.traverse do |_from_spec, _dep, to_spec, trail|
- if to_spec.has_conflicts? || to_spec.conficts_when_loaded_with?(trail)
+ if to_spec.has_conflicts? || to_spec.conflicts_when_loaded_with?(trail)
:next
else
return trail.reverse if to_spec.contains_requirable_file? path
@@ -1084,7 +1018,7 @@ class Gem::Specification < Gem::BasicSpecification
end
def self.unresolved_specs
- unresolved_deps.values.map {|dep| dep.to_specs }.flatten
+ unresolved_deps.values.flat_map(&:to_specs)
end
private_class_method :unresolved_specs
@@ -1122,26 +1056,28 @@ class Gem::Specification < Gem::BasicSpecification
# +prerelease+ is true.
def self.latest_specs(prerelease = false)
- _latest_specs Gem::Specification.stubs, prerelease
+ specification_record.latest_specs(prerelease)
end
##
# Return the latest installed spec for gem +name+.
def self.latest_spec_for(name)
- latest_specs(true).find {|installed_spec| installed_spec.name == name }
+ specification_record.latest_spec_for(name)
end
def self._latest_specs(specs, prerelease = false) # :nodoc:
result = {}
specs.reverse_each do |spec|
- next if spec.version.prerelease? unless prerelease
+ unless prerelease
+ next if spec.version.prerelease?
+ end
result[spec.name] = spec
end
- result.map(&:last).flatten.sort_by {|tup| tup.name }
+ result.flat_map(&:last).sort_by(&:name)
end
##
@@ -1150,36 +1086,33 @@ class Gem::Specification < Gem::BasicSpecification
def self.load(file)
return unless file
- _spec = @load_cache_mutex.synchronize { @load_cache[file] }
- return _spec if _spec
+ spec = @load_cache_mutex.synchronize { @load_cache[file] }
+ return spec if spec
- file = file.dup.tap(&Gem::UNTAINT)
return unless File.file?(file)
code = Gem.open_file(file, "r:UTF-8:-", &:read)
- code.tap(&Gem::UNTAINT)
-
begin
- _spec = eval code, binding, file
+ spec = eval code, binding, file
- if Gem::Specification === _spec
- _spec.loaded_from = File.expand_path file.to_s
+ if Gem::Specification === spec
+ spec.loaded_from = File.expand_path file.to_s
@load_cache_mutex.synchronize do
prev = @load_cache[file]
if prev
- _spec = prev
+ spec = prev
else
- @load_cache[file] = _spec
+ @load_cache[file] = spec
end
end
- return _spec
+ return spec
end
- warn "[#{file}] isn't a Gem::Specification (#{_spec.class} instead)."
+ warn "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
rescue SignalException, SystemExit
raise
- rescue SyntaxError, Exception => e
+ rescue SyntaxError, StandardError => e
warn "Invalid gemspec in [#{file}]: #{e}"
end
@@ -1267,26 +1200,42 @@ class Gem::Specification < Gem::BasicSpecification
def self.reset
@@dirs = nil
- Gem.pre_reset_hooks.each {|hook| hook.call }
- clear_specs
+ Gem.pre_reset_hooks.each(&:call)
+ @specification_record = nil
clear_load_cache
- unresolved = unresolved_deps
- unless unresolved.empty?
- warn "WARN: Unresolved or ambiguous specs during Gem::Specification.reset:"
- unresolved.values.each do |dep|
- warn " #{dep}"
-
- versions = find_all_by_name(dep.name)
- unless versions.empty?
- warn " Available/installed versions of this gem:"
- versions.each {|s| warn " - #{s.version}" }
+
+ unless unresolved_deps.empty?
+ unresolved = unresolved_deps.filter_map do |name, dep|
+ matching_versions = find_all_by_name(name)
+ next if dep.latest_version? && matching_versions.any?(&:default_gem?)
+
+ [dep, matching_versions.uniq(&:full_name)]
+ end.to_h
+
+ unless unresolved.empty?
+ warn "WARN: Unresolved or ambiguous specs during Gem::Specification.reset:"
+ unresolved.each do |dep, versions|
+ warn " #{dep}"
+
+ unless versions.empty?
+ warn " Available/installed versions of this gem:"
+ versions.each {|s| warn " - #{s.version}" }
+ end
end
+ warn "WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
+ warn "Please report a bug if this causes problems."
end
- warn "WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
- warn "Please report a bug if this causes problems."
- unresolved.clear
+
+ unresolved_deps.clear
end
- Gem.post_reset_hooks.each {|hook| hook.call }
+ Gem.post_reset_hooks.each(&:call)
+ end
+
+ ##
+ # Keeps track of all currently known specifications
+
+ def self.specification_record
+ @specification_record ||= Gem::SpecificationRecord.new(dirs)
end
# DOC: This method needs documented or nodoc'd
@@ -1299,10 +1248,23 @@ class Gem::Specification < Gem::BasicSpecification
def self._load(str)
Gem.load_yaml
+ Gem.load_safe_marshal
+
+ yaml_set = false
+ retry_count = 0
array = begin
- Marshal.load str
+ Gem::SafeMarshal.safe_load str
rescue ArgumentError => e
+ # Avoid an infinite retry loop when the argument error has nothing to do
+ # with the classes not being defined.
+ # 1 retry each allowed in case all 3 of
+ # - YAML
+ # - YAML::Syck::DefaultKey
+ # - YAML::PrivateType
+ # need to be defined
+ raise if retry_count >= 3
+
#
# Some very old marshaled specs included references to `YAML::PrivateType`
# and `YAML::Syck::DefaultKey` constants due to bugs in the old emitter
@@ -1312,17 +1274,23 @@ class Gem::Specification < Gem::BasicSpecification
message = e.message
raise unless message.include?("YAML::")
- Object.const_set "YAML", Psych unless Object.const_defined?(:YAML)
+ unless Object.const_defined?(:YAML)
+ Object.const_set "YAML", Module.new
+ yaml_set = true
+ end
if message.include?("YAML::Syck::")
YAML.const_set "Syck", YAML unless YAML.const_defined?(:Syck)
- YAML::Syck.const_set "DefaultKey", Class.new if message.include?("YAML::Syck::DefaultKey")
- elsif message.include?("YAML::PrivateType")
- YAML.const_set "PrivateType", Class.new
+ YAML::Syck.const_set "DefaultKey", Class.new if message.include?("YAML::Syck::DefaultKey") && !YAML::Syck.const_defined?(:DefaultKey)
+ elsif message.include?("YAML::PrivateType") && !YAML.const_defined?(:PrivateType)
+ YAML.const_set "PrivateType", Class.new { attr_accessor :type_id, :value }
end
+ retry_count += 1
retry
+ ensure
+ Object.__send__(:remove_const, "YAML") if yaml_set
end
spec = Gem::Specification.new
@@ -1350,17 +1318,15 @@ class Gem::Specification < Gem::BasicSpecification
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.platform = array[8]
spec.instance_variable_set :@dependencies, array[9]
# offset due to rubyforge_project removal
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 :@license, array[17]
+ # offset due to has_rdoc removal
+ spec.instance_variable_set :@licenses, array[17]
spec.instance_variable_set :@metadata, array[18]
spec.instance_variable_set :@loaded, false
spec.instance_variable_set :@activated, false
@@ -1416,7 +1382,7 @@ class Gem::Specification < Gem::BasicSpecification
# there are conflicts upon activation.
def activate
- other = Gem.loaded_specs[self.name]
+ other = Gem.loaded_specs[name]
if other
check_version_conflict other
return false
@@ -1427,11 +1393,11 @@ class Gem::Specification < Gem::BasicSpecification
activate_dependencies
add_self_to_load_path
- Gem.loaded_specs[self.name] = self
+ Gem.loaded_specs[name] = self
@activated = true
@loaded = true
- return true
+ true
end
##
@@ -1442,7 +1408,7 @@ class Gem::Specification < Gem::BasicSpecification
def activate_dependencies
unresolved = Gem::Specification.unresolved_deps
- self.runtime_dependencies.each do |spec_dep|
+ runtime_dependencies.each do |spec_dep|
if loaded = Gem.loaded_specs[spec_dep.name]
next if spec_dep.matches_spec? loaded
@@ -1453,13 +1419,11 @@ class Gem::Specification < Gem::BasicSpecification
raise e
end
- begin
- specs = spec_dep.to_specs
- rescue Gem::MissingSpecError => e
- raise Gem::MissingSpecError.new(e.name, e.requirement, "at: #{self.spec_file}")
- end
+ specs = spec_dep.matching_specs(true).uniq(&:full_name)
- if specs.size == 1
+ if specs.size == 0
+ raise Gem::MissingSpecError.new(spec_dep.name, spec_dep.requirement, "at: #{spec_file}")
+ elsif specs.size == 1
specs.first.activate
else
name = spec_dep.name
@@ -1502,7 +1466,7 @@ class Gem::Specification < Gem::BasicSpecification
def sanitize_string(string)
return string unless string
- # HACK the #to_s is in here because RSpec has an Array of Arrays of
+ # 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 gemspec
# generation. (Probably won't happen.)
string.to_s
@@ -1520,8 +1484,8 @@ class Gem::Specification < Gem::BasicSpecification
else
executables
end
- rescue
- return nil
+ rescue StandardError
+ nil
end
##
@@ -1546,7 +1510,7 @@ class Gem::Specification < Gem::BasicSpecification
private :add_dependency_with_type
- alias_method :add_dependency, :add_runtime_dependency
+ alias_method :add_runtime_dependency, :add_dependency
##
# Adds this spec's require paths to LOAD_PATH, in the proper location.
@@ -1598,7 +1562,7 @@ class Gem::Specification < Gem::BasicSpecification
def build_args
if File.exist? build_info_file
build_info = File.readlines build_info_file
- build_info = build_info.map {|x| x.strip }
+ build_info = build_info.map(&:strip)
build_info.delete ""
build_info
else
@@ -1660,14 +1624,14 @@ class Gem::Specification < Gem::BasicSpecification
# spec's cached gem.
def cache_dir
- @cache_dir ||= File.join base_dir, "cache"
+ File.join base_dir, "cache"
end
##
# Returns the full path to the cached gem for this spec.
def cache_file
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
+ File.join cache_dir, "#{full_name}.gem"
end
##
@@ -1675,7 +1639,7 @@ class Gem::Specification < Gem::BasicSpecification
def conflicts
conflicts = {}
- self.runtime_dependencies.each do |dep|
+ runtime_dependencies.each do |dep|
spec = Gem.loaded_specs[dep.name]
if spec && !spec.satisfies_requirement?(dep)
(conflicts[spec] ||= []) << dep
@@ -1689,9 +1653,9 @@ class Gem::Specification < Gem::BasicSpecification
##
# return true if there will be conflict when spec if loaded together with the list of specs.
- def conficts_when_loaded_with?(list_of_specs) # :nodoc:
+ def conflicts_when_loaded_with?(list_of_specs) # :nodoc:
result = list_of_specs.any? do |spec|
- spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
+ spec.runtime_dependencies.any? {|dep| (dep.name == name) && !satisfies_requirement?(dep) }
end
result
end
@@ -1701,13 +1665,9 @@ class Gem::Specification < Gem::BasicSpecification
def has_conflicts?
return true unless Gem.env_requirement(name).satisfied_by?(version)
- self.dependencies.any? do |dep|
- if dep.runtime?
- spec = Gem.loaded_specs[dep.name]
- spec && !spec.satisfies_requirement?(dep)
- else
- false
- end
+ runtime_dependencies.any? do |dep|
+ spec = Gem.loaded_specs[dep.name]
+ spec && !spec.satisfies_requirement?(dep)
end
rescue ArgumentError => e
raise e, "#{name} #{version}: #{e.message}"
@@ -1734,7 +1694,7 @@ class Gem::Specification < Gem::BasicSpecification
/\A
(\d{4})-(\d{2})-(\d{2})
(\s+ \d{2}:\d{2}:\d{2}\.\d+ \s* (Z | [-+]\d\d:\d\d) )?
- \Z/x.freeze
+ \Z/x
##
# The date this gem was created
@@ -1761,24 +1721,6 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # The default executable for this gem.
- #
- # Deprecated: The name of the gem is assumed to be the name of the
- # executable now. See Gem.bin_path.
-
- def default_executable # :nodoc:
- if defined?(@default_executable) && @default_executable
- result = @default_executable
- elsif @executables && @executables.size == 1
- result = Array(@executables).first
- else
- result = nil
- end
- result
- end
- rubygems_deprecate :default_executable
-
- ##
# The default value for specification attribute +name+
def default_value(name)
@@ -1801,18 +1743,17 @@ class Gem::Specification < Gem::BasicSpecification
#
# [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
- def dependent_gems(check_dev=true)
+ def dependent_gems(check_dev = true)
out = []
Gem::Specification.each do |spec|
deps = check_dev ? spec.dependencies : spec.runtime_dependencies
deps.each do |dep|
- if self.satisfies_requirement?(dep)
- sats = []
- find_all_satisfiers(dep) do |sat|
- sats << sat
- end
- out << [spec, dep, sats]
+ next unless satisfies_requirement?(dep)
+ sats = []
+ find_all_satisfiers(dep) do |sat|
+ sats << sat
end
+ out << [spec, dep, sats]
end
end
out
@@ -1822,7 +1763,7 @@ class Gem::Specification < Gem::BasicSpecification
# Returns all specs that matches this spec's runtime dependencies.
def dependent_specs
- runtime_dependencies.map {|dep| dep.to_specs }.flatten
+ runtime_dependencies.flat_map(&:to_specs)
end
##
@@ -1858,23 +1799,15 @@ class Gem::Specification < Gem::BasicSpecification
end
def encode_with(coder) # :nodoc:
- mark_version
-
coder.add "name", @name
coder.add "version", @version
- platform = case @original_platform
- when nil, "" then
- "ruby"
- when String then
- @original_platform
- else
- @original_platform.to_s
- end
- coder.add "platform", platform
+ coder.add "platform", platform.to_s
+ coder.add "original_platform", original_platform.to_s if platform.to_s != original_platform.to_s
attributes = @@attributes.map(&:to_s) - %w[name version platform]
attributes.each do |name|
- coder.add name, instance_variable_get("@#{name}")
+ value = instance_variable_get("@#{name}")
+ coder.add name, value unless value.nil?
end
end
@@ -1956,12 +1889,9 @@ class Gem::Specification < Gem::BasicSpecification
spec
end
- def full_name
- @full_name ||= super
- end
-
##
- # Work around bundler removing my methods
+ # Work around old bundler versions removing my methods
+ # Can be removed once RubyGems can no longer install Bundler 2.5
def gem_dir # :nodoc:
super
@@ -1972,29 +1902,6 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Deprecated and ignored, defaults to true.
- #
- # Formerly used to indicate this gem was RDoc-capable.
-
- def has_rdoc # :nodoc:
- true
- end
- rubygems_deprecate :has_rdoc
-
- ##
- # Deprecated and ignored.
- #
- # Formerly used to indicate this gem was RDoc-capable.
-
- def has_rdoc=(ignored) # :nodoc:
- @has_rdoc = true
- end
- rubygems_deprecate :has_rdoc=
-
- alias_method :has_rdoc?, :has_rdoc # :nodoc:
- rubygems_deprecate :has_rdoc?
-
- ##
# True if this gem has files in test_files
def has_unit_tests? # :nodoc:
@@ -2059,7 +1966,8 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Duplicates array_attributes from +other_spec+ so state isn't shared.
+ # Duplicates Array and Gem::Requirement attributes from +other_spec+ so state isn't shared.
+ #
def initialize_copy(other_spec)
self.class.array_attributes.each do |name|
@@ -2081,6 +1989,9 @@ class Gem::Specification < Gem::BasicSpecification
raise e
end
end
+
+ @required_ruby_version = other_spec.required_ruby_version.dup
+ @required_rubygems_version = other_spec.required_rubygems_version.dup
end
def base_dir
@@ -2092,17 +2003,6 @@ class Gem::Specification < Gem::BasicSpecification
end
end
- ##
- # Expire memoized instance variables that can incorrectly generate, replace
- # or miss files due changes in certain attributes used to compute them.
-
- def invalidate_memoized_attributes
- @full_name = nil
- @cache_file = nil
- end
-
- private :invalidate_memoized_attributes
-
def inspect # :nodoc:
if $DEBUG
super
@@ -2141,8 +2041,6 @@ class Gem::Specification < Gem::BasicSpecification
def internal_init # :nodoc:
super
@bin_dir = nil
- @cache_dir = nil
- @cache_file = nil
@doc_dir = nil
@ri_dir = nil
@spec_dir = nil
@@ -2150,13 +2048,6 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Sets the rubygems_version to the current RubyGems version.
-
- def mark_version
- @rubygems_version = Gem::VERSION
- end
-
- ##
# Track removed method calls to warn about during build time.
# Warn about unknown attributes while loading a spec.
@@ -2179,6 +2070,7 @@ class Gem::Specification < Gem::BasicSpecification
# probably want to build_extensions
def missing_extensions?
+ return false if RUBY_ENGINE == "jruby"
return false if extensions.empty?
return false if default_gem?
return false if File.exist? gem_build_complete_path
@@ -2199,11 +2091,11 @@ class Gem::Specification < Gem::BasicSpecification
@files.concat(@extra_rdoc_files)
end
- @files = @files.uniq if @files
- @extensions = @extensions.uniq if @extensions
- @test_files = @test_files.uniq if @test_files
- @executables = @executables.uniq if @executables
- @extra_rdoc_files = @extra_rdoc_files.uniq if @extra_rdoc_files
+ @files = @files.uniq.sort if @files
+ @extensions = @extensions.uniq.sort if @extensions
+ @test_files = @test_files.uniq.sort if @test_files
+ @executables = @executables.uniq.sort if @executables
+ @extra_rdoc_files = @extra_rdoc_files.uniq.sort if @extra_rdoc_files
end
##
@@ -2236,7 +2128,7 @@ class Gem::Specification < Gem::BasicSpecification
# The platform this gem runs on. See Gem::Platform for details.
def platform
- @new_platform ||= Gem::Platform::RUBY
+ @new_platform ||= Gem::Platform::RUBY # rubocop:disable Naming/MemoizedInstanceVariableName
end
def pretty_print(q) # :nodoc:
@@ -2249,23 +2141,22 @@ class Gem::Specification < Gem::BasicSpecification
attributes.unshift :name
attributes.each do |attr_name|
- current_value = self.send attr_name
- current_value = current_value.sort if %i[files test_files].include? attr_name
- if current_value != default_value(attr_name) ||
- self.class.required_attribute?(attr_name)
+ current_value = send attr_name
+ current_value = current_value.sort if [:files, :test_files].include? attr_name
+ next unless current_value != default_value(attr_name) ||
+ self.class.required_attribute?(attr_name)
- q.text "s.#{attr_name} = "
+ q.text "s.#{attr_name} = "
- if attr_name == :date
- current_value = current_value.utc
+ if attr_name == :date
+ current_value = current_value.utc
- q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
- else
- q.pp current_value
- end
-
- q.breakable
+ q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
+ else
+ q.pp current_value
end
+
+ q.breakable
end
end
end
@@ -2275,7 +2166,7 @@ class Gem::Specification < Gem::BasicSpecification
# that is already loaded (+other+)
def check_version_conflict(other) # :nodoc:
- return if self.version == other.version
+ return if version == other.version
# This gem is already loaded. If the currently loaded gem is not in the
# list of candidate gems, then we have a version conflict.
@@ -2283,7 +2174,7 @@ class Gem::Specification < Gem::BasicSpecification
msg = "can't activate #{full_name}, already activated #{other.full_name}"
e = Gem::LoadError.new msg
- e.name = self.name
+ e.name = name
raise e
end
@@ -2300,10 +2191,13 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Sets rdoc_options to +value+, ensuring it is an array.
+ # Sets rdoc_options to +value+, ensuring it is a flat array of strings.
+ # Handles malformed gemspecs where rdoc_options may be a Hash or contain Hashes.
def rdoc_options=(options)
- @rdoc_options = Array options
+ @rdoc_options = Array(options).flat_map do |opt|
+ opt.is_a?(Hash) ? opt.to_a.flatten.map(&:to_s) : opt
+ end
end
##
@@ -2349,12 +2243,12 @@ class Gem::Specification < Gem::BasicSpecification
when Hash then
seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
"{ #{seg.join(", ")} }"
- when Gem::Version then obj.to_s.dump
+ when Gem::Version then ruby_code(obj.to_s)
when DateLike then obj.strftime("%Y-%m-%d").dump
when Time then obj.strftime("%Y-%m-%d").dump
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::Platform then "Gem::Platform.new(#{ruby_code obj.to_a})"
when Gem::Requirement then
list = obj.as_list
"Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
@@ -2375,7 +2269,7 @@ class Gem::Specification < Gem::BasicSpecification
# True if this gem has the same attributes as +other+.
def same_attributes?(spec)
- @@attributes.all? {|name, _default| self.send(name) == spec.send(name) }
+ @@attributes.all? {|name, _default| send(name) == spec.send(name) }
end
private :same_attributes?
@@ -2384,8 +2278,8 @@ class Gem::Specification < Gem::BasicSpecification
# Checks if this specification meets the requirement of +dependency+.
def satisfies_requirement?(dependency)
- return @name == dependency.name &&
- dependency.requirement.satisfied_by?(@version)
+ @name == dependency.name &&
+ dependency.requirement.satisfied_by?(@version)
end
##
@@ -2474,7 +2368,6 @@ class Gem::Specification < Gem::BasicSpecification
# still have their default values are omitted.
def to_ruby
- mark_version
result = []
result << "# -*- encoding: utf-8 -*-"
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{raw_require_paths.join("\0")}"
@@ -2504,27 +2397,25 @@ class Gem::Specification < Gem::BasicSpecification
:required_rubygems_version,
:specification_version,
:version,
- :has_rdoc,
- :default_executable,
:metadata,
:signing_key,
]
@@attributes.each do |attr_name|
next if handled.include? attr_name
- current_value = self.send(attr_name)
+ current_value = send(attr_name)
if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
result << " s.#{attr_name} = #{ruby_code current_value}"
end
end
if String === signing_key
- result << " s.signing_key = #{signing_key.dump}.freeze"
+ result << " s.signing_key = #{ruby_code signing_key}"
end
if @installed_by_version
result << nil
- result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
+ result << " s.installed_by_version = #{ruby_code Gem::VERSION}"
end
unless dependencies.empty?
@@ -2533,9 +2424,8 @@ class Gem::Specification < Gem::BasicSpecification
result << nil
dependencies.each do |dep|
- req = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{ruby_code dep.requirements_list})"
end
end
@@ -2569,24 +2459,28 @@ class Gem::Specification < Gem::BasicSpecification
def to_yaml(opts = {}) # :nodoc:
Gem.load_yaml
- # Because the user can switch the YAML engine behind our
- # back, we have to check again here to make sure that our
- # psych code was properly loaded, and load it if not.
- unless Gem.const_defined?(:NoAliasYAMLTree)
- require_relative "psych_tree"
- end
+ if Gem.use_psych?
+ # Because the user can switch the YAML engine behind our
+ # back, we have to check again here to make sure that our
+ # psych code was properly loaded, and load it if not.
+ unless Gem.const_defined?(:NoAliasYAMLTree)
+ require_relative "psych_tree"
+ end
- builder = Gem::NoAliasYAMLTree.create
- builder << self
- ast = builder.tree
+ builder = Gem::NoAliasYAMLTree.create
+ builder << self
+ ast = builder.tree
- require "stringio"
- io = StringIO.new
- io.set_encoding Encoding::UTF_8
+ require "stringio"
+ io = StringIO.new
+ io.set_encoding Encoding::UTF_8
- Psych::Visitors::Emitter.new(io).accept(ast)
+ Psych::Visitors::Emitter.new(io).accept(ast)
- io.string.gsub(/ !!null \n/, " \n")
+ io.string.gsub(/ !!null \n/, " \n")
+ else
+ Gem::YAMLSerializer.dump(self)
+ end
end
##
@@ -2596,10 +2490,9 @@ class Gem::Specification < Gem::BasicSpecification
def traverse(trail = [], visited = {}, &block)
trail.push(self)
begin
- dependencies.each do |dep|
- next unless dep.runtime?
+ runtime_dependencies.each do |dep|
dep.matching_specs(true).each do |dep_spec|
- next if visited.has_key?(dep_spec)
+ next if visited.key?(dep_spec)
visited[dep_spec] = true
trail.push(dep_spec)
begin
@@ -2607,11 +2500,10 @@ class Gem::Specification < Gem::BasicSpecification
ensure
trail.pop
end
- unless result == :next
- spec_name = dep_spec.name
- dep_spec.traverse(trail, visited, &block) unless
- trail.any? {|s| s.name == spec_name }
- end
+ next if result == :next
+ spec_name = dep_spec.name
+ dep_spec.traverse(trail, visited, &block) unless
+ trail.any? {|s| s.name == spec_name }
end
end
ensure
@@ -2642,38 +2534,15 @@ class Gem::Specification < Gem::BasicSpecification
@test_files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
end
- def validate_metadata
- Gem::SpecificationPolicy.new(self).validate_metadata
- end
- rubygems_deprecate :validate_metadata
-
- def validate_dependencies
- Gem::SpecificationPolicy.new(self).validate_dependencies
- end
- rubygems_deprecate :validate_dependencies
-
- def validate_permissions
- Gem::SpecificationPolicy.new(self).validate_permissions
+ def validate_for_resolution
+ Gem::SpecificationPolicy.new(self).validate_for_resolution
end
- rubygems_deprecate :validate_permissions
##
- # Set the version to +version+, potentially also setting
- # required_rubygems_version if +version+ indicates it is a
- # prerelease.
+ # Set the version to +version+.
def version=(version)
- @version = Gem::Version.create(version)
- return if @version.nil?
-
- # skip to set required_ruby_version when pre-released rubygems.
- # It caused to raise CircularDependencyError
- if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
- self.required_rubygems_version = "> 1.3.1"
- end
- invalidate_memoized_attributes
-
- return @version
+ @version = version.nil? ? version : Gem::Version.create(version)
end
def stubbed?
@@ -2685,14 +2554,17 @@ class Gem::Specification < Gem::BasicSpecification
case ivar
when "date"
# Force Date to go through the extra coerce logic in date=
- self.date = val.tap(&Gem::UNTAINT)
+ self.date = val
+ when "platform"
+ self.platform = val
+ when "rdoc_options"
+ self.rdoc_options = val
+ when "requirements"
+ self.requirements = val
else
- instance_variable_set "@#{ivar}", val.tap(&Gem::UNTAINT)
+ instance_variable_set "@#{ivar}", val
end
end
-
- @original_platform = @platform # for backwards compatibility
- self.platform = Gem::Platform.new @platform
end
##
@@ -2704,7 +2576,7 @@ class Gem::Specification < Gem::BasicSpecification
end
nil_attributes.each do |attribute|
- default = self.default_value attribute
+ default = default_value attribute
value = case default
when Time, Numeric, Symbol, true, false, nil then default
@@ -2715,6 +2587,8 @@ class Gem::Specification < Gem::BasicSpecification
end
@installed_by_version ||= nil
+
+ nil
end
def flatten_require_paths # :nodoc:
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index 765f57bfca..478e294e09 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -1,22 +1,25 @@
+# frozen_string_literal: true
+
require_relative "user_interaction"
class Gem::SpecificationPolicy
include Gem::UserInteraction
- VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
- SPECIAL_CHARACTERS = /\A[#{Regexp.escape('.-_')}]+/.freeze # :nodoc:
+ SPECIAL_CHARACTERS = /\A[#{Regexp.escape(".-_")}]+/ # :nodoc:
- VALID_URI_PATTERN = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z}.freeze # :nodoc:
+ VALID_URI_PATTERN = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z} # :nodoc:
METADATA_LINK_KEYS = %w[
- bug_tracker_uri
- changelog_uri
- documentation_uri
homepage_uri
- mailing_list_uri
+ changelog_uri
source_code_uri
+ documentation_uri
wiki_uri
+ mailing_list_uri
+ bug_tracker_uri
+ download_uri
funding_uri
].freeze # :nodoc:
@@ -42,6 +45,7 @@ class Gem::SpecificationPolicy
def validate(strict = false)
validate_required!
+ validate_required_metadata!
validate_optional(strict) if packaging || strict
@@ -82,15 +86,17 @@ class Gem::SpecificationPolicy
validate_authors_field
- validate_metadata
-
validate_licenses_length
- validate_lazy_metadata
-
validate_duplicate_dependencies
end
+ def validate_required_metadata!
+ validate_metadata
+
+ validate_lazy_metadata
+ end
+
def validate_optional(strict)
validate_licenses
@@ -100,10 +106,14 @@ class Gem::SpecificationPolicy
validate_dependencies
+ validate_required_ruby_version
+
validate_extensions
validate_removed_attributes
+ validate_unique_links
+
if @warnings > 0
if strict
error "specification has warnings"
@@ -114,6 +124,13 @@ class Gem::SpecificationPolicy
end
##
+ # Implementation for Specification#validate_for_resolution
+
+ def validate_for_resolution
+ validate_required!
+ end
+
+ ##
# Implementation for Specification#validate_metadata
def validate_metadata
@@ -141,10 +158,9 @@ class Gem::SpecificationPolicy
error "#{entry} value is too large (#{value.size} > 1024)"
end
- if METADATA_LINK_KEYS.include? key
- if value !~ VALID_URI_PATTERN
- error "#{entry} has invalid link: #{value.inspect}"
- end
+ next unless METADATA_LINK_KEYS.include? key
+ unless VALID_URI_PATTERN.match?(value)
+ error "#{entry} has invalid link: #{value.inspect}"
end
end
end
@@ -161,7 +177,7 @@ class Gem::SpecificationPolicy
if prev = seen[dep.type][dep.name]
error_messages << <<-MESSAGE
duplicate dependency on #{dep}, (#{prev.requirement}) use:
- add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
+ add_#{dep.type}_dependency \"#{dep.name}\", \"#{dep.requirement}\", \"#{prev.requirement}\"
MESSAGE
end
@@ -174,53 +190,21 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
##
# Checks that the gem does not depend on itself.
- # Checks that dependencies use requirements as we recommend. Warnings are
- # issued when dependencies are open-ended or overly strict for semantic
- # versioning.
def validate_dependencies # :nodoc:
- warning_messages = []
+ error_messages = []
@specification.dependencies.each do |dep|
- if dep.name == @specification.name # warn on self reference
- warning_messages << "Self referencing dependency is unnecessary and strongly discouraged."
- end
-
- prerelease_dep = dep.requirements_list.any? do |req|
- Gem::Requirement.new(req).prerelease?
- end
-
- warning_messages << "prerelease dependency on #{dep} is not recommended" if
- prerelease_dep && !@specification.version.prerelease?
-
- open_ended = dep.requirement.requirements.all? do |op, version|
- !version.prerelease? && (op == ">" || op == ">=")
+ if dep.name == @specification.name # error on self reference
+ error_messages << "Dependencies of this gem include a self-reference."
end
+ end
- if open_ended
- op, dep_version = dep.requirement.requirements.first
-
- segments = dep_version.segments
-
- base = segments.first 2
-
- recommendation = if (op == ">" || op == ">=") && segments == [0]
- " use a bounded requirement, such as '~> x.y'"
- else
- bugfix = if op == ">"
- ", '> #{dep_version}'"
- elsif op == ">=" && base != segments
- ", '>= #{dep_version}'"
- end
-
- " if #{dep.name} is semantically versioned, use:\n" \
- " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join "."}'#{bugfix}"
- end
+ error error_messages.join if error_messages.any?
+ end
- warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
- end
- end
- if warning_messages.any?
- warning_messages.each {|warning_message| warning warning_message }
+ def validate_required_ruby_version
+ if @specification.required_ruby_version.requirements == [Gem::Requirement::DefaultRequirement]
+ warning "make sure you specify the oldest ruby version constraint (like \">= 3.0\") that you want your gem to support by setting the `required_ruby_version` gemspec attribute"
end
end
@@ -234,7 +218,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
@specification.files.each do |file|
next unless File.file?(file)
- next if File.stat(file).mode & 0444 == 0444
+ next if File.stat(file).mode & 0o444 == 0o444
warning "#{file} is not world-readable"
end
@@ -263,7 +247,9 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
return if rubygems_version == Gem::VERSION
- error "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
+ warning "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
+
+ @specification.rubygems_version = Gem::VERSION
end
def validate_required_attributes
@@ -279,12 +265,12 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
if !name.is_a?(String)
error "invalid value for attribute name: \"#{name.inspect}\" must be a string"
- elsif name !~ /[a-zA-Z]/
+ elsif !/[a-zA-Z]/.match?(name)
error "invalid value for attribute name: #{name.dump} must include at least one letter"
- elsif name !~ VALID_NAME_PATTERN
+ elsif !VALID_NAME_PATTERN.match?(name)
error "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
- elsif name =~ SPECIAL_CHARACTERS
- error "invalid value for attribute name: #{name.dump} can not begin with a period, dash, or underscore"
+ elsif SPECIAL_CHARACTERS.match?(name)
+ error "invalid value for attribute name: #{name.dump} cannot begin with a period, dash, or underscore"
end
end
@@ -343,7 +329,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
String
end
- unless Array === val && val.all? {|x| x.is_a?(klass) }
+ unless Array === val && val.all? {|x| x.is_a?(klass) || (field == :licenses && x.nil?) }
error "#{field} must be an Array of #{klass}"
end
end
@@ -358,6 +344,8 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
licenses = @specification.licenses
licenses.each do |license|
+ next if license.nil?
+
if license.length > 64
error "each license must be 64 characters or less"
end
@@ -368,26 +356,38 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
licenses = @specification.licenses
licenses.each do |license|
- unless Gem::Licenses.match?(license)
- suggestions = Gem::Licenses.suggestions(license)
- message = <<-WARNING
-license value '#{license}' is invalid. Use a license identifier from
-http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
- WARNING
- message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
- warning(message)
+ next if Gem::Licenses.match?(license) || license.nil?
+ license_id_deprecated = Gem::Licenses.deprecated_license_id?(license)
+ exception_id_deprecated = Gem::Licenses.deprecated_exception_id?(license)
+ suggestions = Gem::Licenses.suggestions(license)
+
+ if license_id_deprecated
+ main_message = "License identifier '#{license}' is deprecated"
+ elsif exception_id_deprecated
+ main_message = "Exception identifier at '#{license}' is deprecated"
+ else
+ main_message = "License identifier '#{license}' is invalid"
end
+
+ message = <<-WARNING
+#{main_message}. Use an identifier from
+https://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license,
+or set it to nil if you don't want to specify a license.
+ WARNING
+ message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
+ warning(message)
end
warning <<-WARNING if licenses.empty?
-licenses is empty, but is recommended. Use a license identifier from
-http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
+licenses is empty, but is recommended. Use an license identifier from
+https://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license,
+or set it to nil if you don't want to specify a license.
WARNING
end
LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, "")
- LAZY_PATTERN = /\AFI XME|\ATO DO/x.freeze
- HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i.freeze
+ LAZY_PATTERN = /\AFI XME|\ATO DO/x
+ HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i
def validate_lazy_metadata
unless @specification.authors.grep(LAZY_PATTERN).empty?
@@ -398,11 +398,11 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
error "#{LAZY} is not an email"
end
- if @specification.description =~ LAZY_PATTERN
+ if LAZY_PATTERN.match?(@specification.description)
error "#{LAZY} is not a description"
end
- if @specification.summary =~ LAZY_PATTERN
+ if LAZY_PATTERN.match?(@specification.summary)
error "#{LAZY} is not a summary"
end
@@ -410,13 +410,13 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
# Make sure a homepage is valid HTTP/HTTPS URI
if homepage && !homepage.empty?
- require "uri"
+ require_relative "vendor/uri/lib/uri"
begin
- homepage_uri = URI.parse(homepage)
- unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class
+ homepage_uri = Gem::URI.parse(homepage)
+ unless [Gem::URI::HTTP, Gem::URI::HTTPS].member? homepage_uri.class
error "\"#{homepage}\" is not a valid HTTP URI"
end
- rescue URI::InvalidURIError
+ rescue Gem::URI::InvalidURIError
error "\"#{homepage}\" is not a valid HTTP URI"
end
end
@@ -435,6 +435,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
warning "deprecated autorequire specified" if @specification.autorequire
@specification.executables.each do |executable|
+ validate_executable(executable)
validate_shebang_line_in(executable)
end
@@ -448,6 +449,13 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
warning("no #{attribute} specified") if value.nil? || value.empty?
end
+ def validate_executable(executable)
+ separators = [File::SEPARATOR, File::ALT_SEPARATOR, File::PATH_SEPARATOR].compact.map {|sep| Regexp.escape(sep) }.join
+ return unless executable.match?(/[\s#{separators}]/)
+
+ error "executable \"#{executable}\" contains invalid characters"
+ end
+
def validate_shebang_line_in(executable)
executable_path = File.join(@specification.bindir, executable)
return if File.read(executable_path, 2) == "#!"
@@ -467,6 +475,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
validate_rake_extensions(builder)
validate_rust_extensions(builder)
+ validate_extension_require_relative
end
def validate_rust_extensions(builder) # :nodoc:
@@ -480,13 +489,56 @@ You have specified rust based extension, but Cargo.lock is not part of the gem f
def validate_rake_extensions(builder) # :nodoc:
rake_extension = @specification.extensions.any? {|s| builder.builder_for(s) == Gem::Ext::RakeBuilder }
- rake_dependency = @specification.dependencies.any? {|d| d.name == "rake" }
+ rake_dependency = @specification.dependencies.any? {|d| d.name == "rake" && d.type == :runtime }
warning <<-WARNING if rake_extension && !rake_dependency
-You have specified rake based extension, but rake is not added as dependency. It is recommended to add rake as a dependency in gemspec since there's no guarantee rake will be already installed.
+You have specified rake based extension, but rake is not added as runtime dependency. It is recommended to add rake as a runtime dependency in gemspec since there's no guarantee rake will be already installed.
WARNING
end
+ def validate_extension_require_relative # :nodoc:
+ return unless @specification.extensions.any?
+
+ require_paths = @specification.require_paths
+
+ @specification.files.each do |rb_file|
+ next unless rb_file.end_with?(".rb")
+ next unless require_paths.any? {|rp| rb_file.start_with?("#{rp}/") }
+ next unless File.file?(rb_file)
+
+ File.foreach(rb_file).with_index(1) do |line, lineno|
+ next unless line =~ /^\s*require_relative\s+["']([^"']+)["']/
+
+ required_path = Regexp.last_match(1)
+ resolved = File.join(File.dirname(rb_file), required_path)
+
+ next if @specification.files.any? {|f| f == "#{resolved}.rb" || f == resolved }
+
+ warning <<~WARNING
+ #{rb_file}:#{lineno} uses `require_relative "#{required_path}"` to load a compiled extension.
+ This will break in RubyGems 4.2, which will stop copying compiled extensions into the gem's lib directory.
+ Use `require` instead of `require_relative` to load compiled extensions.
+ WARNING
+ end
+ end
+ end
+
+ def validate_unique_links
+ links = @specification.metadata.slice(*METADATA_LINK_KEYS)
+ grouped = links.group_by {|_key, uri| uri }
+ grouped.each do |uri, copies|
+ next unless copies.length > 1
+ keys = copies.map(&:first).join("\n ")
+ warning <<~WARNING
+ You have specified the uri:
+ #{uri}
+ for all of the following keys:
+ #{keys}
+ Only the first one will be shown on rubygems.org
+ WARNING
+ end
+ end
+
def warning(statement) # :nodoc:
@warnings += 1
diff --git a/lib/rubygems/specification_record.rb b/lib/rubygems/specification_record.rb
new file mode 100644
index 0000000000..c7e5cbedb5
--- /dev/null
+++ b/lib/rubygems/specification_record.rb
@@ -0,0 +1,225 @@
+# frozen_string_literal: true
+
+module Gem
+ class SpecificationRecord
+ def self.dirs_from(paths)
+ paths.map do |path|
+ File.join(path, "specifications")
+ end
+ end
+
+ def self.from_path(path)
+ new(dirs_from([path]))
+ end
+
+ def initialize(dirs)
+ @all = nil
+ @stubs = nil
+ @stubs_by_name = {}
+ @spec_with_requirable_file = {}
+ @active_stub_with_requirable_file = {}
+
+ @dirs = dirs
+ end
+
+ # Sentinel object to represent "not found" stubs
+ NOT_FOUND = Struct.new(:to_spec, :this).new
+ private_constant :NOT_FOUND
+
+ ##
+ # Returns the list of all specifications in the record
+
+ def all
+ @all ||= stubs.map(&:to_spec)
+ end
+
+ ##
+ # Returns a Gem::StubSpecification for every specification in the record
+
+ def stubs
+ @stubs ||= begin
+ pattern = "*.gemspec"
+ stubs = stubs_for_pattern(pattern, false)
+
+ @stubs_by_name = stubs.select {|s| Gem::Platform.match_spec? s }.group_by(&:name)
+ stubs
+ end
+ end
+
+ ##
+ # Returns a Gem::StubSpecification for every specification in the record
+ # named +name+ only returns stubs that match Gem.platforms
+
+ def stubs_for(name)
+ if @stubs
+ @stubs_by_name[name] || []
+ else
+ @stubs_by_name[name] ||= stubs_for_pattern("#{name}-*.gemspec").select do |s|
+ s.name == name
+ end
+ end
+ end
+
+ ##
+ # Finds stub specifications matching a pattern in the record, optionally
+ # filtering out specs not matching the current platform
+
+ def stubs_for_pattern(pattern, match_platform = true)
+ installed_stubs = installed_stubs(pattern)
+ installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
+ stubs = installed_stubs + Gem::Specification.default_stubs(pattern)
+ Gem::Specification._resort!(stubs)
+ stubs
+ end
+
+ ##
+ # Adds +spec+ to the record, keeping the collection properly sorted.
+
+ def add_spec(spec)
+ return if all.include? spec
+
+ all << spec
+ stubs << spec
+ (@stubs_by_name[spec.name] ||= []) << spec
+
+ Gem::Specification._resort!(@stubs_by_name[spec.name])
+ Gem::Specification._resort!(stubs)
+ end
+
+ ##
+ # Removes +spec+ from the record.
+
+ def remove_spec(spec)
+ all.delete spec.to_spec
+ stubs.delete spec
+ (@stubs_by_name[spec.name] || []).delete spec
+ end
+
+ ##
+ # Sets the specs known by the record to +specs+.
+
+ def all=(specs)
+ @stubs_by_name = specs.group_by(&:name)
+ @all = @stubs = specs
+ end
+
+ ##
+ # Return full names of all specs in the record in sorted order.
+
+ def all_names
+ all.map(&:full_name)
+ end
+
+ include Enumerable
+
+ ##
+ # Enumerate every known spec.
+
+ def each
+ return enum_for(:each) unless block_given?
+
+ all.each do |x|
+ yield x
+ end
+ end
+
+ ##
+ # Returns every spec in the record that matches +name+ and optional +requirements+.
+
+ def find_all_by_name(name, *requirements)
+ req = Gem::Requirement.create(*requirements)
+ env_req = Gem.env_requirement(name)
+
+ matches = stubs_for(name).find_all do |spec|
+ req.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
+ end.map(&:to_spec)
+
+ if name == "bundler" && !req.specific?
+ require_relative "bundler_version_finder"
+ Gem::BundlerVersionFinder.prioritize!(matches)
+ end
+
+ matches
+ end
+
+ ##
+ # Return the best specification in the record that contains the file matching +path+.
+
+ def find_by_path(path)
+ path = path.dup.freeze
+ spec = @spec_with_requirable_file[path] ||= stubs.find do |s|
+ s.contains_requirable_file? path
+ end || NOT_FOUND
+
+ spec.to_spec
+ end
+
+ ##
+ # Return the best specification that contains the file matching +path+
+ # amongst the specs that are not loaded. This method is different than
+ # +find_inactive_by_path+ as it will filter out loaded specs by their name.
+
+ def find_unloaded_by_path(path)
+ stub = stubs.find do |s|
+ next if Gem.loaded_specs[s.name]
+ s.contains_requirable_file? path
+ end
+ stub&.to_spec
+ end
+
+ ##
+ # Return the best specification in the record that contains the file
+ # matching +path+ amongst the specs that are not activated.
+
+ def find_inactive_by_path(path)
+ stub = stubs.find do |s|
+ next if s.activated?
+ s.contains_requirable_file? path
+ end
+ stub&.to_spec
+ end
+
+ ##
+ # Return the best specification in the record that contains the file
+ # matching +path+, among those already activated.
+
+ def find_active_stub_by_path(path)
+ stub = @active_stub_with_requirable_file[path] ||= stubs.find do |s|
+ s.activated? && s.contains_requirable_file?(path)
+ end || NOT_FOUND
+
+ stub.this
+ end
+
+ ##
+ # Return the latest specs in the record, optionally including prerelease
+ # specs if +prerelease+ is true.
+
+ def latest_specs(prerelease)
+ Gem::Specification._latest_specs stubs, prerelease
+ end
+
+ ##
+ # Return the latest installed spec in the record for gem +name+.
+
+ def latest_spec_for(name)
+ latest_specs(true).find {|installed_spec| installed_spec.name == name }
+ end
+
+ private
+
+ def installed_stubs(pattern)
+ map_stubs(pattern) do |path, base_dir, gems_dir|
+ Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
+ end
+ end
+
+ def map_stubs(pattern)
+ @dirs.flat_map do |dir|
+ base_dir = File.dirname dir
+ gems_dir = File.join base_dir, "gems"
+ Gem::Specification.gemspec_stubs_in(dir, pattern) {|path| yield path, base_dir, gems_dir }
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem b/lib/rubygems/ssl_certs/rubygems.org/GlobalSign.pem
index 8afb219058..8afb219058 100644
--- a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem
+++ b/lib/rubygems/ssl_certs/rubygems.org/GlobalSign.pem
diff --git a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem b/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem
deleted file mode 100644
index f4ce4ca43d..0000000000
--- a/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
-A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
-b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
-MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
-YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
-aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
-jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
-xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
-1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
-snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
-U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
-9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
-BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
-AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
-yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
-38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
-AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
-DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
-HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
------END CERTIFICATE-----
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 4682cc94fd..53b337ed85 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
##
# Gem::StubSpecification reads the stub: line from the gemspec. This prevents
# us having to eval the entire gemspec in order to find out certain
@@ -34,7 +35,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
def initialize(data, extensions)
parts = data[PREFIX.length..-1].split(" ", 4)
- @name = parts[0].freeze
+ @name = -parts[0]
@version = if Gem::Version.correct?(parts[1])
Gem::Version.new(parts[1])
else
@@ -68,7 +69,6 @@ class Gem::StubSpecification < Gem::BasicSpecification
def initialize(filename, base_dir, gems_dir, default_gem)
super()
- filename.tap(&Gem::UNTAINT)
self.loaded_from = filename
@data = nil
@@ -83,11 +83,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
# True when this gem has been activated
def activated?
- @activated ||=
- begin
- loaded = Gem.loaded_specs[name]
- loaded && loaded.version == version
- end
+ @activated ||= !loaded_spec.nil?
end
def default_gem?
@@ -111,20 +107,23 @@ class Gem::StubSpecification < Gem::BasicSpecification
saved_lineno = $.
Gem.open_file loaded_from, OPEN_MODE do |file|
- begin
- file.readline # discard encoding line
- stubline = file.readline.chomp
- if stubline.start_with?(PREFIX)
- extensions = if /\A#{PREFIX}/ =~ file.readline.chomp
- $'.split "\0"
+ file.readline # discard encoding line
+ stubline = file.readline
+ if stubline.start_with?(PREFIX)
+ extline = file.readline
+
+ extensions =
+ if extline.delete_prefix!(PREFIX)
+ extline.chomp!
+ extline.split "\0"
else
StubLine::NO_EXTENSIONS
end
- @data = StubLine.new stubline, extensions
- end
- rescue EOFError
+ stubline.chomp! # readline(chomp: true) allocates 3x as much as .readline.chomp!
+ @data = StubLine.new stubline, extensions
end
+ rescue EOFError
end
ensure
$. = saved_lineno
@@ -141,6 +140,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
end
def missing_extensions?
+ return false if RUBY_ENGINE == "jruby"
return false if default_gem?
return false if extensions.empty?
return false if File.exist? gem_build_complete_path
@@ -183,14 +183,11 @@ class Gem::StubSpecification < Gem::BasicSpecification
##
# The full Gem::Specification for this gem, loaded from evalling its gemspec
- def to_spec
- @spec ||= if @data
- loaded = Gem.loaded_specs[name]
- loaded if loaded && loaded.version == version
- end
-
+ def spec
+ @spec ||= loaded_spec if @data
@spec ||= Gem::Specification.load(loaded_from)
end
+ alias_method :to_spec, :spec
##
# Is this StubSpecification valid? i.e. have we found a stub line, OR does
@@ -206,4 +203,34 @@ class Gem::StubSpecification < Gem::BasicSpecification
def stubbed?
data.is_a? StubLine
end
+
+ def ==(other) # :nodoc:
+ self.class === other &&
+ name == other.name &&
+ version == other.version &&
+ platform == other.platform
+ end
+
+ alias_method :eql?, :== # :nodoc:
+
+ def hash # :nodoc:
+ name.hash ^ version.hash ^ platform.hash
+ end
+
+ def <=>(other) # :nodoc:
+ sort_obj <=> other.sort_obj
+ end
+
+ def sort_obj # :nodoc:
+ [name, version, Gem::Platform.sort_priority(platform)]
+ end
+
+ private
+
+ def loaded_spec
+ spec = Gem.loaded_specs[name]
+ return unless spec && spec.version == version && spec.default_gem? == default_gem?
+
+ spec
+ end
end
diff --git a/lib/rubygems/target_rbconfig.rb b/lib/rubygems/target_rbconfig.rb
new file mode 100644
index 0000000000..21d90ee9db
--- /dev/null
+++ b/lib/rubygems/target_rbconfig.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require "rbconfig"
+
+##
+# A TargetConfig is a wrapper around an RbConfig object that provides a
+# consistent interface for querying configuration for *deployment target
+# platform*, where the gem being installed is intended to run on.
+#
+# The TargetConfig is typically created from the RbConfig of the running Ruby
+# process, but can also be created from an RbConfig file on disk for cross-
+# compiling gems.
+
+class Gem::TargetRbConfig
+ attr_reader :path
+
+ def initialize(rbconfig, path)
+ @rbconfig = rbconfig
+ @path = path
+ end
+
+ ##
+ # Creates a TargetRbConfig for the platform that RubyGems is running on.
+
+ def self.for_running_ruby
+ new(::RbConfig, nil)
+ end
+
+ ##
+ # Creates a TargetRbConfig from the RbConfig file at the given path.
+ # Typically used for cross-compiling gems.
+
+ def self.from_path(rbconfig_path)
+ namespace = Module.new do |m|
+ # Load the rbconfig.rb file within a new anonymous module to avoid
+ # conflicts with the rbconfig for the running platform.
+ Kernel.load rbconfig_path, m
+ end
+ rbconfig = namespace.const_get(:RbConfig)
+
+ new(rbconfig, rbconfig_path)
+ end
+
+ ##
+ # Queries the configuration for the given key.
+
+ def [](key)
+ @rbconfig::CONFIG[key]
+ end
+end
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index 1cd466f997..88d4ce59b4 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -21,7 +21,7 @@ module Gem::Text
# Wraps +text+ to +wrap+ characters and optionally indents by +indent+
# characters
- def format_text(text, wrap, indent=0)
+ def format_text(text, wrap, indent = 0)
result = []
work = clean_text(text)
@@ -66,7 +66,7 @@ module Gem::Text
str1.each_codepoint.with_index(1) do |char1, i|
j = 0
while j < m
- cost = (char1 == str2_codepoints[j]) ? 0 : 1
+ cost = char1 == str2_codepoints[j] ? 0 : 1
x = min3(
d[j + 1] + 1, # insertion
i + 1, # deletion
diff --git a/lib/rubygems/tsort.rb b/lib/rubygems/tsort.rb
deleted file mode 100644
index 60ebe22e81..0000000000
--- a/lib/rubygems/tsort.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "tsort/lib/tsort"
diff --git a/lib/rubygems/tsort/.document b/lib/rubygems/tsort/.document
deleted file mode 100644
index 0c43bbd6b3..0000000000
--- a/lib/rubygems/tsort/.document
+++ /dev/null
@@ -1 +0,0 @@
-# Vendored files do not need to be documented
diff --git a/lib/rubygems/tsort/lib/tsort.rb b/lib/rubygems/tsort/lib/tsort.rb
deleted file mode 100644
index f825f14257..0000000000
--- a/lib/rubygems/tsort/lib/tsort.rb
+++ /dev/null
@@ -1,452 +0,0 @@
-# frozen_string_literal: true
-
-#--
-# tsort.rb - provides a module for topological sorting and strongly connected components.
-#++
-#
-
-#
-# Gem::TSort implements topological sorting using Tarjan's algorithm for
-# strongly connected components.
-#
-# Gem::TSort is designed to be able to be used with any object which can be
-# interpreted as a directed graph.
-#
-# Gem::TSort requires two methods to interpret an object as a graph,
-# tsort_each_node and tsort_each_child.
-#
-# * tsort_each_node is used to iterate for all nodes over a graph.
-# * tsort_each_child is used to iterate for child nodes of a given node.
-#
-# The equality of nodes are defined by eql? and hash since
-# Gem::TSort uses Hash internally.
-#
-# == A Simple Example
-#
-# The following example demonstrates how to mix the Gem::TSort module into an
-# existing class (in this case, Hash). Here, we're treating each key in
-# the hash as a node in the graph, and so we simply alias the required
-# #tsort_each_node method to Hash's #each_key method. For each key in the
-# hash, the associated value is an array of the node's child nodes. This
-# choice in turn leads to our implementation of the required #tsort_each_child
-# method, which fetches the array of child nodes and then iterates over that
-# array using the user-supplied block.
-#
-# require 'rubygems/tsort/lib/tsort'
-#
-# class Hash
-# include Gem::TSort
-# alias tsort_each_node each_key
-# def tsort_each_child(node, &block)
-# fetch(node).each(&block)
-# end
-# end
-#
-# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
-# #=> [3, 2, 1, 4]
-#
-# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
-# #=> [[4], [2, 3], [1]]
-#
-# == A More Realistic Example
-#
-# A very simple `make' like tool can be implemented as follows:
-#
-# require 'rubygems/tsort/lib/tsort'
-#
-# class Make
-# def initialize
-# @dep = {}
-# @dep.default = []
-# end
-#
-# def rule(outputs, inputs=[], &block)
-# triple = [outputs, inputs, block]
-# outputs.each {|f| @dep[f] = [triple]}
-# @dep[triple] = inputs
-# end
-#
-# def build(target)
-# each_strongly_connected_component_from(target) {|ns|
-# if ns.length != 1
-# fs = ns.delete_if {|n| Array === n}
-# raise Gem::TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
-# end
-# n = ns.first
-# if Array === n
-# outputs, inputs, block = n
-# inputs_time = inputs.map {|f| File.mtime f}.max
-# begin
-# outputs_time = outputs.map {|f| File.mtime f}.min
-# rescue Errno::ENOENT
-# outputs_time = nil
-# end
-# if outputs_time == nil ||
-# inputs_time != nil && outputs_time <= inputs_time
-# sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
-# block.call
-# end
-# end
-# }
-# end
-#
-# def tsort_each_child(node, &block)
-# @dep[node].each(&block)
-# end
-# include Gem::TSort
-# end
-#
-# def command(arg)
-# print arg, "\n"
-# system arg
-# end
-#
-# m = Make.new
-# m.rule(%w[t1]) { command 'date > t1' }
-# m.rule(%w[t2]) { command 'date > t2' }
-# m.rule(%w[t3]) { command 'date > t3' }
-# m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
-# m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' }
-# m.build('t5')
-#
-# == Bugs
-#
-# * 'tsort.rb' is wrong name because this library uses
-# Tarjan's algorithm for strongly connected components.
-# Although 'strongly_connected_components.rb' is correct but too long.
-#
-# == References
-#
-# R. E. Tarjan, "Depth First Search and Linear Graph Algorithms",
-# <em>SIAM Journal on Computing</em>, Vol. 1, No. 2, pp. 146-160, June 1972.
-#
-
-module Gem::TSort
- class Cyclic < StandardError
- end
-
- # Returns a topologically sorted array of nodes.
- # The array is sorted from children to parents, i.e.
- # the first element has no child and the last node has no parent.
- #
- # If there is a cycle, Gem::TSort::Cyclic is raised.
- #
- # class G
- # include Gem::TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # p graph.tsort #=> [4, 2, 3, 1]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # p graph.tsort # raises Gem::TSort::Cyclic
- #
- def tsort
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- Gem::TSort.tsort(each_node, each_child)
- end
-
- # Returns a topologically sorted array of nodes.
- # The array is sorted from children to parents, i.e.
- # the first element has no child and the last node has no parent.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # If there is a cycle, Gem::TSort::Cyclic is raised.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p Gem::TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p Gem::TSort.tsort(each_node, each_child) # raises Gem::TSort::Cyclic
- #
- def self.tsort(each_node, each_child)
- tsort_each(each_node, each_child).to_a
- end
-
- # The iterator version of the #tsort method.
- # <tt><em>obj</em>.tsort_each</tt> is similar to <tt><em>obj</em>.tsort.each</tt>, but
- # modification of _obj_ during the iteration may lead to unexpected results.
- #
- # #tsort_each returns +nil+.
- # If there is a cycle, Gem::TSort::Cyclic is raised.
- #
- # class G
- # include Gem::TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.tsort_each {|n| p n }
- # #=> 4
- # # 2
- # # 3
- # # 1
- #
- def tsort_each(&block) # :yields: node
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- Gem::TSort.tsort_each(each_node, each_child, &block)
- end
-
- # The iterator version of the Gem::TSort.tsort method.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # Gem::TSort.tsort_each(each_node, each_child) {|n| p n }
- # #=> 4
- # # 2
- # # 3
- # # 1
- #
- def self.tsort_each(each_node, each_child) # :yields: node
- return to_enum(__method__, each_node, each_child) unless block_given?
-
- each_strongly_connected_component(each_node, each_child) {|component|
- if component.size == 1
- yield component.first
- else
- raise Cyclic.new("topological sort failed: #{component.inspect}")
- end
- }
- end
-
- # Returns strongly connected components as an array of arrays of nodes.
- # The array is sorted from children to parents.
- # Each elements of the array represents a strongly connected component.
- #
- # class G
- # include Gem::TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # p graph.strongly_connected_components #=> [[4], [2], [3], [1]]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # p graph.strongly_connected_components #=> [[4], [2, 3], [1]]
- #
- def strongly_connected_components
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- Gem::TSort.strongly_connected_components(each_node, each_child)
- end
-
- # Returns strongly connected components as an array of arrays of nodes.
- # The array is sorted from children to parents.
- # Each elements of the array represents a strongly connected component.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p Gem::TSort.strongly_connected_components(each_node, each_child)
- # #=> [[4], [2], [3], [1]]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p Gem::TSort.strongly_connected_components(each_node, each_child)
- # #=> [[4], [2, 3], [1]]
- #
- def self.strongly_connected_components(each_node, each_child)
- each_strongly_connected_component(each_node, each_child).to_a
- end
-
- # The iterator version of the #strongly_connected_components method.
- # <tt><em>obj</em>.each_strongly_connected_component</tt> is similar to
- # <tt><em>obj</em>.strongly_connected_components.each</tt>, but
- # modification of _obj_ during the iteration may lead to unexpected results.
- #
- # #each_strongly_connected_component returns +nil+.
- #
- # class G
- # include Gem::TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.each_strongly_connected_component {|scc| p scc }
- # #=> [4]
- # # [2]
- # # [3]
- # # [1]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # graph.each_strongly_connected_component {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def each_strongly_connected_component(&block) # :yields: nodes
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- Gem::TSort.each_strongly_connected_component(each_node, each_child, &block)
- end
-
- # The iterator version of the Gem::TSort.strongly_connected_components method.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
- # #=> [4]
- # # [2]
- # # [3]
- # # [1]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def self.each_strongly_connected_component(each_node, each_child) # :yields: nodes
- return to_enum(__method__, each_node, each_child) unless block_given?
-
- id_map = {}
- stack = []
- each_node.call {|node|
- unless id_map.include? node
- each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
- yield c
- }
- end
- }
- nil
- end
-
- # Iterates over strongly connected component in the subgraph reachable from
- # _node_.
- #
- # Return value is unspecified.
- #
- # #each_strongly_connected_component_from doesn't call #tsort_each_node.
- #
- # class G
- # include Gem::TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.each_strongly_connected_component_from(2) {|scc| p scc }
- # #=> [4]
- # # [2]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # graph.each_strongly_connected_component_from(2) {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- #
- def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) # :yields: nodes
- Gem::TSort.each_strongly_connected_component_from(node, method(:tsort_each_child), id_map, stack, &block)
- end
-
- # Iterates over strongly connected components in a graph.
- # The graph is represented by _node_ and _each_child_.
- #
- # _node_ is the first node.
- # _each_child_ should have +call+ method which takes a node argument
- # and yields for each child node.
- #
- # Return value is unspecified.
- #
- # #Gem::TSort.each_strongly_connected_component_from is a class method and
- # it doesn't need a class to represent a graph which includes Gem::TSort.
- #
- # graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_child = lambda {|n, &b| graph[n].each(&b) }
- # Gem::TSort.each_strongly_connected_component_from(1, each_child) {|scc|
- # p scc
- # }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def self.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
- return to_enum(__method__, node, each_child, id_map, stack) unless block_given?
-
- minimum_id = node_id = id_map[node] = id_map.size
- stack_length = stack.length
- stack << node
-
- each_child.call(node) {|child|
- if id_map.include? child
- child_id = id_map[child]
- minimum_id = child_id if child_id && child_id < minimum_id
- else
- sub_minimum_id =
- each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
- yield c
- }
- minimum_id = sub_minimum_id if sub_minimum_id < minimum_id
- end
- }
-
- if node_id == minimum_id
- component = stack.slice!(stack_length .. -1)
- component.each {|n| id_map[n] = nil}
- yield component
- end
-
- minimum_id
- end
-
- # Should be implemented by a extended class.
- #
- # #tsort_each_node is used to iterate for all nodes over a graph.
- #
- def tsort_each_node # :yields: node
- raise NotImplementedError.new
- end
-
- # Should be implemented by a extended class.
- #
- # #tsort_each_child is used to iterate for child nodes of _node_.
- #
- def tsort_each_child(node) # :yields: child
- raise NotImplementedError.new
- end
-end
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 79334d2d64..fe4c3a80cf 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -9,7 +10,6 @@ require "fileutils"
require_relative "../rubygems"
require_relative "installer_uninstaller_utils"
require_relative "dependency_list"
-require_relative "rdoc"
require_relative "user_interaction"
##
@@ -31,7 +31,7 @@ class Gem::Uninstaller
attr_reader :bin_dir
##
- # The gem repository the gem will be installed into
+ # The gem repository the gem will be uninstalled from
attr_reader :gem_home
@@ -42,24 +42,36 @@ class Gem::Uninstaller
attr_reader :spec
##
- # Constructs an uninstaller that will uninstall +gem+
+ # Constructs an uninstaller that will uninstall gem named +gem+.
+ # +options+ is a Hash with the following keys:
+ #
+ # :version:: Version requirement for the gem to uninstall. If not specified,
+ # uses Gem::Requirement.default.
+ # :install_dir:: The directory where the gem is installed. If not specified,
+ # uses Gem.dir.
+ # :executables:: Whether executables should be removed without confirmation or not. If nil, asks the user explicitly.
+ # :all:: If more than one version matches the requirement, whether to forcefully remove all matching versions or ask the user to select specific matching versions that should be removed.
+ # :ignore:: Ignore broken dependency checks when uninstalling.
+ # :bin_dir:: Directory containing executables to remove. If not specified,
+ # uses Gem.bindir.
+ # :format_executable:: In order to find executables to be removed, format executable names using Gem::Installer.exec_format.
+ # :abort_on_dependent:: Directly abort uninstallation if dependencies would be broken, rather than asking the user for confirmation.
+ # :check_dev:: When checking if uninstalling gem would leave broken dependencies around, also consider development dependencies.
+ # :force:: Set both :all and :ignore to true for forced uninstallation.
+ # :user_install:: Uninstall from user gem directory instead of system directory.
def initialize(gem, options = {})
- # TODO document the valid options
@gem = gem
@version = options[:version] || Gem::Requirement.default
- @gem_home = File.realpath(options[:install_dir] || Gem.dir)
- @plugins_dir = Gem.plugindir(@gem_home)
+ @install_dir = options[:install_dir]
+ @gem_home = File.realpath(@install_dir || Gem.dir)
+ @user_dir = File.exist?(Gem.user_dir) ? File.realpath(Gem.user_dir) : Gem.user_dir
@force_executables = options[:executables]
@force_all = options[:all]
@force_ignore = options[:ignore]
@bin_dir = options[:bin_dir]
@format_executable = options[:format_executable]
@abort_on_dependent = options[:abort_on_dependent]
-
- # Indicate if development dependencies should be checked when
- # uninstalling. (default: false)
- #
@check_dev = options[:check_dev]
if options[:force]
@@ -69,7 +81,7 @@ class Gem::Uninstaller
# only add user directory if install_dir is not set
@user_install = false
- @user_install = options[:user_install] unless options[:install_dir]
+ @user_install = options[:user_install] unless @install_dir
# Optimization: populated during #uninstall
@default_specs_matching_uninstall_params = []
@@ -84,11 +96,7 @@ class Gem::Uninstaller
list = []
- dirs =
- Gem::Specification.dirs +
- [Gem.default_specifications_dir]
-
- Gem::Specification.each_spec dirs do |spec|
+ specification_record.stubs.each do |spec|
next unless dependency.matches_spec? spec
list << spec
@@ -98,15 +106,13 @@ class Gem::Uninstaller
raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
end
- default_specs, list = list.partition do |spec|
- spec.default_gem?
- end
+ default_specs, list = list.partition(&:default_gem?)
warn_cannot_uninstall_default_gems(default_specs - list)
- @default_specs_matching_uninstall_params = default_specs
+ @default_specs_matching_uninstall_params = default_specs.map(&:to_spec)
list, other_repo_specs = list.partition do |spec|
@gem_home == spec.base_dir ||
- (@user_install && spec.base_dir == Gem.user_dir)
+ (@user_install && spec.base_dir == @user_dir)
end
list.sort!
@@ -114,7 +120,7 @@ class Gem::Uninstaller
if list.empty?
return unless other_repo_specs.any?
- other_repos = other_repo_specs.map {|spec| spec.base_dir }.uniq
+ other_repos = other_repo_specs.map(&:base_dir).uniq
message = ["#{@gem} is not installed in GEM_HOME, try:"]
message.concat other_repos.map {|repo|
@@ -126,7 +132,7 @@ class Gem::Uninstaller
remove_all list
elsif list.size > 1
- gem_names = list.map {|gem| gem.full_name }
+ gem_names = list.map(&:full_name_with_location)
gem_names << "All versions"
say
@@ -134,7 +140,7 @@ class Gem::Uninstaller
if index == list.size
remove_all list
- elsif index >= 0 && index < list.size
+ elsif index && index >= 0 && index < list.size
uninstall_gem list[index]
else
say "Error: must enter a number [1-#{list.size + 1}]"
@@ -147,7 +153,9 @@ class Gem::Uninstaller
##
# Uninstalls gem +spec+
- def uninstall_gem(spec)
+ def uninstall_gem(stub)
+ spec = stub.to_spec
+
@spec = spec
unless dependencies_ok? spec
@@ -165,6 +173,8 @@ class Gem::Uninstaller
remove_plugins @spec
remove @spec
+ specification_record.remove_spec(stub)
+
regenerate_plugins
Gem.post_uninstall_hooks.each do |hook|
@@ -178,7 +188,7 @@ class Gem::Uninstaller
# Removes installed executables and batch files (windows only) for +spec+.
def remove_executables(spec)
- return if spec.executables.empty?
+ return if spec.executables.empty? || default_spec_matches?(spec)
executables = spec.executables.clone
@@ -200,8 +210,8 @@ class Gem::Uninstaller
executables = executables.map {|exec| formatted_program_filename exec }
remove = if @force_executables.nil?
- ask_yes_no("Remove executables:\n" +
- "\t#{executables.join ", "}\n\n" +
+ ask_yes_no("Remove executables:\n" \
+ "\t#{executables.join ", "}\n\n" \
"in addition to the gem?",
true)
else
@@ -240,7 +250,7 @@ class Gem::Uninstaller
def remove(spec)
unless path_ok?(@gem_home, spec) ||
- (@user_install && path_ok?(Gem.user_dir, spec))
+ (@user_install && path_ok?(@user_dir, spec))
e = Gem::GemNotInHomeException.new \
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
e.spec = spec
@@ -251,7 +261,15 @@ class Gem::Uninstaller
raise Gem::FilePermissionError, spec.base_dir unless
File.writable?(spec.base_dir)
- safe_delete { FileUtils.rm_r spec.full_gem_path }
+ full_gem_path = spec.full_gem_path
+ exclusions = []
+
+ if default_spec_matches?(spec) && spec.executables.any?
+ exclusions = spec.executables.map {|exe| File.join(spec.bin_dir, exe) }
+ exclusions << File.dirname(exclusions.last) until exclusions.last == full_gem_path
+ end
+
+ safe_delete { rm_r full_gem_path, exclusions: exclusions }
safe_delete { FileUtils.rm_r spec.extension_dir }
old_platform_name = spec.original_name
@@ -275,8 +293,6 @@ class Gem::Uninstaller
safe_delete { FileUtils.rm_r gemspec }
announce_deletion_of(spec)
-
- Gem::Specification.reset
end
##
@@ -285,17 +301,17 @@ class Gem::Uninstaller
def remove_plugins(spec) # :nodoc:
return if spec.plugins.empty?
- remove_plugins_for(spec, @plugins_dir)
+ remove_plugins_for(spec, plugin_dir_for(spec))
end
##
# Regenerates plugin wrappers after removal.
def regenerate_plugins
- latest = Gem::Specification.latest_spec_for(@spec.name)
+ latest = specification_record.latest_spec_for(@spec.name)
return if latest.nil?
- regenerate_plugins_for(latest, @plugins_dir)
+ regenerate_plugins_for(latest, plugin_dir_for(@spec))
end
##
@@ -349,7 +365,7 @@ class Gem::Uninstaller
msg << "If you remove this gem, these dependencies will not be met."
msg << "Continue with Uninstall?"
- return ask_yes_no(msg.join("\n"), false)
+ ask_yes_no(msg.join("\n"), false)
end
##
@@ -380,6 +396,16 @@ class Gem::Uninstaller
private
+ def rm_r(path, exclusions:)
+ FileUtils::Entry_.new(path).postorder_traverse do |ent|
+ ent.remove unless exclusions.include?(ent.path)
+ end
+ end
+
+ def specification_record
+ @specification_record ||= @install_dir ? Gem::SpecificationRecord.from_path(@install_dir) : Gem::Specification.specification_record
+ end
+
def announce_deletion_of(spec)
name = spec.full_name
say "Successfully uninstalled #{name}"
@@ -407,4 +433,8 @@ class Gem::Uninstaller
say "Gem #{spec.full_name} cannot be uninstalled because it is a default gem"
end
end
+
+ def plugin_dir_for(spec)
+ Gem.plugindir(spec.base_dir)
+ end
end
diff --git a/lib/rubygems/update_suggestion.rb b/lib/rubygems/update_suggestion.rb
index c2e81b2374..6f3ec5f493 100644
--- a/lib/rubygems/update_suggestion.rb
+++ b/lib/rubygems/update_suggestion.rb
@@ -4,15 +4,6 @@
# Mixin methods for Gem::Command to promote available RubyGems update
module Gem::UpdateSuggestion
- # list taken from https://github.com/watson/ci-info/blob/7a3c30d/index.js#L56-L66
- CI_ENV_VARS = [
- "CI", # Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
- "CONTINUOUS_INTEGRATION", # Travis CI, Cirrus CI
- "BUILD_NUMBER", # Jenkins, TeamCity
- "CI_APP_ID", "CI_BUILD_ID", "CI_BUILD_NUMBER", # Applfow
- "RUN_ID" # TaskCluster, dsari
- ].freeze
-
ONE_WEEK = 7 * 24 * 60 * 60
##
@@ -28,9 +19,9 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
end
##
- # Determines if current environment is eglible for update suggestion.
+ # Determines if current environment is eligible for update suggestion.
- def eglible_for_update?
+ def eligible_for_update?
# explicit opt-out
return false if Gem.configuration[:prevent_update_suggestion]
return false if ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
@@ -39,7 +30,7 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
return false unless Gem.ui.tty?
return false if Gem.rubygems_version.prerelease?
return false if Gem.disable_system_update_message
- return false if ci?
+ return false if Gem::CIDetector.ci?
# check makes sense only when we can store timestamp of last try
# otherwise we will not be able to prevent "annoying" update message
@@ -53,17 +44,13 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
# compare current and latest version, this is the part where
# latest rubygems spec is fetched from remote
- (Gem.rubygems_version < Gem.latest_rubygems_version).tap do |eglible|
+ (Gem.rubygems_version < Gem.latest_rubygems_version).tap do |eligible|
# store the time of last successful check into state file
Gem.configuration.last_update_check = check_time
- return eglible
+ return eligible
end
- rescue # don't block install command on any problem
+ rescue StandardError # don't block install command on any problem
false
end
-
- def ci?
- CI_ENV_VARS.any? {|var| ENV.include?(var) }
- end
end
diff --git a/lib/rubygems/uri.rb b/lib/rubygems/uri.rb
index 4b5d035aa0..d729c67d26 100644
--- a/lib/rubygems/uri.rb
+++ b/lib/rubygems/uri.rb
@@ -16,9 +16,9 @@ class Gem::Uri
# Parses uri, raising if it's invalid
def self.parse!(uri)
- require "uri"
+ require_relative "vendor/uri/lib/uri"
- raise URI::InvalidURIError unless uri
+ raise Gem::URI::InvalidURIError unless uri
return uri unless uri.is_a?(String)
@@ -28,9 +28,9 @@ class Gem::Uri
# as "%7BDESede%7D". If this is escaped again the percentage
# symbols will be escaped.
begin
- URI.parse(uri)
- rescue URI::InvalidURIError
- URI.parse(URI::DEFAULT_PARSER.escape(uri))
+ Gem::URI.parse(uri)
+ rescue Gem::URI::InvalidURIError
+ Gem::URI.parse(Gem::URI::RFC2396_PARSER.escape(uri))
end
end
@@ -39,7 +39,7 @@ class Gem::Uri
def self.parse(uri)
parse!(uri)
- rescue URI::InvalidURIError
+ rescue Gem::URI::InvalidURIError
uri
end
diff --git a/lib/rubygems/uri_formatter.rb b/lib/rubygems/uri_formatter.rb
index 3f1d02d774..8856fdadd2 100644
--- a/lib/rubygems/uri_formatter.rb
+++ b/lib/rubygems/uri_formatter.rb
@@ -17,7 +17,8 @@ class Gem::UriFormatter
# Creates a new URI formatter for +uri+.
def initialize(uri)
- require "cgi"
+ require "cgi/escape"
+ require "cgi/util" unless defined?(CGI::EscapeExt)
@uri = uri
end
@@ -34,7 +35,7 @@ class Gem::UriFormatter
# Normalize the URI by adding "http://" if it is missing.
def normalize
- (@uri =~ /^(https?|ftp|file):/i) ? @uri : "http://#{@uri}"
+ /^(https?|ftp|file):/i.match?(@uri) ? @uri : "http://#{@uri}"
end
##
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 502ccc4357..9fe3e755c4 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require_relative "deprecate"
require_relative "text"
##
@@ -169,8 +169,6 @@ end
# Gem::StreamUI implements a simple stream based user interface.
class Gem::StreamUI
- extend Gem::Deprecate
-
##
# The input stream
@@ -192,7 +190,7 @@ class Gem::StreamUI
# then special operations (like asking for passwords) will use the TTY
# commands to disable character echo.
- def initialize(in_stream, out_stream, err_stream=STDERR, usetty=true)
+ def initialize(in_stream, out_stream, err_stream = $stderr, usetty = true)
@ins = in_stream
@outs = out_stream
@errs = err_stream
@@ -236,7 +234,8 @@ class Gem::StreamUI
return nil, nil unless result
result = result.strip.to_i - 1
- return list[result], result
+ return nil, nil unless (0...list.size) === result
+ [list[result], result]
end
##
@@ -244,7 +243,7 @@ class Gem::StreamUI
# to a tty, raises an exception if default is nil, otherwise returns
# default.
- def ask_yes_no(question, default=nil)
+ def ask_yes_no(question, default = nil)
unless tty?
if default.nil?
raise Gem::OperationNotSupportedError,
@@ -270,11 +269,10 @@ class Gem::StreamUI
when /^y/i then true
when /^n/i then false
when /^$/ then default
- else nil
end
end
- return result
+ result
end
##
@@ -324,14 +322,14 @@ class Gem::StreamUI
##
# Display a statement.
- def say(statement="")
+ def say(statement = "")
@outs.puts statement
end
##
# Display an informational alert. Will ask +question+ if it is not nil.
- def alert(statement, question=nil)
+ def alert(statement, question = nil)
@outs.puts "INFO: #{statement}"
ask(question) if question
end
@@ -339,7 +337,7 @@ class Gem::StreamUI
##
# Display a warning on stderr. Will ask +question+ if it is not nil.
- def alert_warning(statement, question=nil)
+ def alert_warning(statement, question = nil)
@errs.puts "WARNING: #{statement}"
ask(question) if question
end
@@ -348,7 +346,7 @@ class Gem::StreamUI
# Display an error message in a location expected to get error messages.
# Will ask +question+ if it is not nil.
- def alert_error(statement, question=nil)
+ def alert_error(statement, question = nil)
@errs.puts "ERROR: #{statement}"
ask(question) if question
end
@@ -425,8 +423,7 @@ class Gem::StreamUI
# +size+ items. Shows the given +initial_message+ when progress starts
# and the +terminal_message+ when it is complete.
- def initialize(out_stream, size, initial_message,
- terminal_message = "complete")
+ def initialize(out_stream, size, initial_message, terminal_message = "complete")
@out = out_stream
@total = size
@count = 0
@@ -468,8 +465,7 @@ class Gem::StreamUI
# +size+ items. Shows the given +initial_message+ when progress starts
# and the +terminal_message+ when it is complete.
- def initialize(out_stream, size, initial_message,
- terminal_message = "complete")
+ def initialize(out_stream, size, initial_message, terminal_message = "complete")
@out = out_stream
@total = size
@count = 0
@@ -592,8 +588,8 @@ class Gem::StreamUI
end
##
-# Subclass of StreamUI that instantiates the user interaction using STDIN,
-# STDOUT, and STDERR.
+# Subclass of StreamUI that instantiates the user interaction using $stdin,
+# $stdout, and $stderr.
class Gem::ConsoleUI < Gem::StreamUI
##
@@ -601,7 +597,7 @@ class Gem::ConsoleUI < Gem::StreamUI
# stdin, output to stdout and warnings or errors to stderr.
def initialize
- super STDIN, STDOUT, STDERR, true
+ super $stdin, $stdout, $stderr, true
end
end
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index b19e22aef9..ee4106c6ce 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require_relative "deprecate"
##
# This module contains various utility methods as module methods.
@@ -56,26 +55,6 @@ module Gem::Util
end
##
- # Invokes system, but silences all output.
-
- def self.silent_system(*command)
- opt = { :out => IO::NULL, :err => [:child, :out] }
- if Hash === command.last
- opt.update(command.last)
- cmds = command[0...-1]
- else
- cmds = command.dup
- end
- system(*(cmds << opt))
- end
-
- class << self
- extend Gem::Deprecate
-
- rubygems_deprecate :silent_system
- end
-
- ##
# Enumerates the parents of +directory+.
def self.traverse_parents(directory, &block)
@@ -83,7 +62,11 @@ module Gem::Util
here = File.expand_path directory
loop do
- Dir.chdir here, &block rescue Errno::EACCES
+ begin
+ Dir.chdir here, &block
+ rescue StandardError
+ Errno::EACCES
+ end
new_here = File.expand_path("..", here)
return if new_here == here # toplevel
@@ -100,11 +83,11 @@ module Gem::Util
end
##
- # Corrects +path+ (usually returned by `URI.parse().path` on Windows), that
+ # Corrects +path+ (usually returned by `Gem::URI.parse().path` on Windows), that
# comes with a leading slash.
def self.correct_for_windows_path(path)
- if path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
+ if path[0].chr == "/" && path[1].chr.match?(/[a-z]/i) && path[2].chr == ":"
path[1..-1]
else
path
diff --git a/lib/rubygems/util/atomic_file_writer.rb b/lib/rubygems/util/atomic_file_writer.rb
new file mode 100644
index 0000000000..32767c6a79
--- /dev/null
+++ b/lib/rubygems/util/atomic_file_writer.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+# Based on ActiveSupport's AtomicFile implementation
+# Copyright (c) David Heinemeier Hansson
+# https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/file/atomic.rb
+# Licensed under the MIT License
+
+module Gem
+ class AtomicFileWriter
+ ##
+ # Write to a file atomically. Useful for situations where you don't
+ # want other processes or threads to see half-written files.
+
+ def self.open(file_name)
+ require "securerandom" unless defined?(SecureRandom)
+
+ old_stat = begin
+ File.stat(file_name)
+ rescue SystemCallError
+ nil
+ end
+
+ # Names can't be longer than 255B
+ tmp_suffix = ".tmp.#{SecureRandom.hex}"
+ dirname = File.dirname(file_name)
+ basename = File.basename(file_name)
+ tmp_path = File.join(dirname, ".#{basename.byteslice(0, 254 - tmp_suffix.bytesize)}#{tmp_suffix}")
+
+ flags = File::RDWR | File::CREAT | File::EXCL | File::BINARY
+ flags |= File::SHARE_DELETE if defined?(File::SHARE_DELETE)
+
+ File.open(tmp_path, flags) do |temp_file|
+ temp_file.binmode
+ if old_stat
+ # Set correct permissions on new file
+ begin
+ File.chown(old_stat.uid, old_stat.gid, temp_file.path)
+ # This operation will affect filesystem ACL's
+ File.chmod(old_stat.mode, temp_file.path)
+ rescue Errno::EPERM, Errno::EACCES
+ # Changing file ownership failed, moving on.
+ end
+ end
+
+ return_val = yield temp_file
+ rescue StandardError => error
+ begin
+ temp_file.close
+ rescue StandardError
+ nil
+ end
+
+ begin
+ File.unlink(temp_file.path)
+ rescue StandardError
+ nil
+ end
+
+ raise error
+ else
+ begin
+ File.rename(temp_file.path, file_name)
+ rescue StandardError
+ begin
+ File.unlink(temp_file.path)
+ rescue StandardError
+ end
+
+ raise
+ end
+
+ return_val
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb
index a26e964728..caf53d0b7e 100644
--- a/lib/rubygems/util/licenses.rb
+++ b/lib/rubygems/util/licenses.rb
@@ -15,6 +15,7 @@ class Gem::Licenses
# license identifiers
LICENSE_IDENTIFIERS = %w[
0BSD
+ 3D-Slicer-1.0
AAL
ADSL
AFL-1.1
@@ -22,14 +23,15 @@ class Gem::Licenses
AFL-2.0
AFL-2.1
AFL-3.0
- AGPL-1.0
AGPL-1.0-only
AGPL-1.0-or-later
- AGPL-3.0
AGPL-3.0-only
AGPL-3.0-or-later
+ ALGLIB-Documentation
+ AMD-newlib
AMDPLPA
AML
+ AML-glslang
AMPAS
ANTLR-PD
ANTLR-PD-fallback
@@ -39,9 +41,15 @@ class Gem::Licenses
APSL-1.1
APSL-1.2
APSL-2.0
+ ASWF-Digital-Assets-1.0
+ ASWF-Digital-Assets-1.1
Abstyles
+ AdaCore-doc
Adobe-2006
+ Adobe-Display-PostScript
Adobe-Glyph
+ Adobe-Utopia
+ Advanced-Cryptics-Dictionary
Afmparse
Aladdin
Apache-1.0
@@ -53,15 +61,20 @@ class Gem::Licenses
Artistic-1.0-Perl
Artistic-1.0-cl8
Artistic-2.0
+ Artistic-dist
+ Aspell-RU
+ BOLA-1.1
BSD-1-Clause
BSD-2-Clause
- BSD-2-Clause-FreeBSD
- BSD-2-Clause-NetBSD
+ BSD-2-Clause-Darwin
BSD-2-Clause-Patent
BSD-2-Clause-Views
+ BSD-2-Clause-first-lines
+ BSD-2-Clause-pkgconf-disclaimer
BSD-3-Clause
BSD-3-Clause-Attribution
BSD-3-Clause-Clear
+ BSD-3-Clause-HP
BSD-3-Clause-LBNL
BSD-3-Clause-Modification
BSD-3-Clause-No-Military-License
@@ -69,11 +82,24 @@ class Gem::Licenses
BSD-3-Clause-No-Nuclear-License-2014
BSD-3-Clause-No-Nuclear-Warranty
BSD-3-Clause-Open-MPI
+ BSD-3-Clause-Sun
+ BSD-3-Clause-Tso
+ BSD-3-Clause-acpica
+ BSD-3-Clause-flex
BSD-4-Clause
BSD-4-Clause-Shortened
BSD-4-Clause-UC
+ BSD-4.3RENO
+ BSD-4.3TAHOE
+ BSD-Advertising-Acknowledgement
+ BSD-Attribution-HPND-disclaimer
+ BSD-Inferno-Nettverk
+ BSD-Mark-Modifications
BSD-Protection
BSD-Source-Code
+ BSD-Source-beginning-file
+ BSD-Systemics
+ BSD-Systemics-W3Works
BSL-1.0
BUSL-1.1
Baekmuk
@@ -82,12 +108,19 @@ class Gem::Licenses
Beerware
BitTorrent-1.0
BitTorrent-1.1
+ Bitstream-Charter
Bitstream-Vera
BlueOak-1.0.0
+ Boehm-GC
+ Boehm-GC-without-fee
Borceux
+ Brian-Gladman-2-Clause
+ Brian-Gladman-3-Clause
+ Buddy
C-UDA-1.0
CAL-1.0
CAL-1.0-Combined-Work-Exception
+ CAPEC-tou
CATOSL-1.1
CC-BY-1.0
CC-BY-2.0
@@ -95,6 +128,7 @@ class Gem::Licenses
CC-BY-2.5-AU
CC-BY-3.0
CC-BY-3.0-AT
+ CC-BY-3.0-AU
CC-BY-3.0-DE
CC-BY-3.0-IGO
CC-BY-3.0-NL
@@ -115,6 +149,7 @@ class Gem::Licenses
CC-BY-NC-ND-4.0
CC-BY-NC-SA-1.0
CC-BY-NC-SA-2.0
+ CC-BY-NC-SA-2.0-DE
CC-BY-NC-SA-2.0-FR
CC-BY-NC-SA-2.0-UK
CC-BY-NC-SA-2.5
@@ -136,8 +171,11 @@ class Gem::Licenses
CC-BY-SA-3.0
CC-BY-SA-3.0-AT
CC-BY-SA-3.0-DE
+ CC-BY-SA-3.0-IGO
CC-BY-SA-4.0
CC-PDDC
+ CC-PDM-1.0
+ CC-SA-1.0
CC0-1.0
CDDL-1.0
CDDL-1.1
@@ -156,6 +194,9 @@ class Gem::Licenses
CERN-OHL-P-2.0
CERN-OHL-S-2.0
CERN-OHL-W-2.0
+ CFITSIO
+ CMU-Mach
+ CMU-Mach-nodoc
CNRI-Jython
CNRI-Python
CNRI-Python-GPL-Compatible
@@ -165,17 +206,30 @@ class Gem::Licenses
CPOL-1.02
CUA-OPL-1.0
Caldera
+ Caldera-no-preamble
+ Catharon
ClArtistic
+ Clips
Community-Spec-1.0
Condor-1.1
+ Cornell-Lossless-JPEG
+ Cronyx
Crossword
+ CryptoSwift
CrystalStacker
Cube
D-FSL-1.0
+ DEC-3-Clause
DL-DE-BY-2.0
+ DL-DE-ZERO-2.0
DOC
DRL-1.0
+ DRL-1.1
DSDP
+ DocBook-DTD
+ DocBook-Schema
+ DocBook-Stylesheet
+ DocBook-XML
Dotseqn
ECL-1.0
ECL-2.0
@@ -184,6 +238,9 @@ class Gem::Licenses
EPICS
EPL-1.0
EPL-2.0
+ ESA-PL-permissive-2.4
+ ESA-PL-strong-copyleft-2.4
+ ESA-PL-weak-copyleft-2.4
EUDatagrid
EUPL-1.0
EUPL-1.1
@@ -192,32 +249,37 @@ class Gem::Licenses
Entessa
ErlPL-1.1
Eurosym
+ FBM
FDK-AAC
FSFAP
+ FSFAP-no-warranty-disclaimer
FSFUL
FSFULLR
+ FSFULLRSD
FSFULLRWD
+ FSL-1.1-ALv2
+ FSL-1.1-MIT
FTL
Fair
+ Ferguson-Twofish
Frameworx-1.0
FreeBSD-DOC
FreeImage
+ Furuseth
+ GCR-docs
GD
- GFDL-1.1
GFDL-1.1-invariants-only
GFDL-1.1-invariants-or-later
GFDL-1.1-no-invariants-only
GFDL-1.1-no-invariants-or-later
GFDL-1.1-only
GFDL-1.1-or-later
- GFDL-1.2
GFDL-1.2-invariants-only
GFDL-1.2-invariants-or-later
GFDL-1.2-no-invariants-only
GFDL-1.2-no-invariants-or-later
GFDL-1.2-only
GFDL-1.2-or-later
- GFDL-1.3
GFDL-1.3-invariants-only
GFDL-1.3-invariants-or-later
GFDL-1.3-no-invariants-only
@@ -226,65 +288,88 @@ class Gem::Licenses
GFDL-1.3-or-later
GL2PS
GLWTPL
- GPL-1.0
- GPL-1.0+
GPL-1.0-only
GPL-1.0-or-later
- GPL-2.0
- GPL-2.0+
GPL-2.0-only
GPL-2.0-or-later
- GPL-2.0-with-GCC-exception
- GPL-2.0-with-autoconf-exception
- GPL-2.0-with-bison-exception
- GPL-2.0-with-classpath-exception
- GPL-2.0-with-font-exception
- GPL-3.0
- GPL-3.0+
GPL-3.0-only
GPL-3.0-or-later
- GPL-3.0-with-GCC-exception
- GPL-3.0-with-autoconf-exception
+ Game-Programming-Gems
Giftware
Glide
Glulxe
+ Graphics-Gems
+ Gutmann
+ HDF5
+ HIDAPI
+ HP-1986
+ HP-1989
HPND
+ HPND-DEC
+ HPND-Fenneberg-Livingston
+ HPND-INRIA-IMAG
+ HPND-Intel
+ HPND-Kevlin-Henney
+ HPND-MIT-disclaimer
+ HPND-Markus-Kuhn
+ HPND-Netrek
+ HPND-Pbmplus
+ HPND-SMC
+ HPND-UC
+ HPND-UC-export-US
+ HPND-doc
+ HPND-doc-sell
+ HPND-export-US
+ HPND-export-US-acknowledgement
+ HPND-export-US-modify
+ HPND-export2-US
+ HPND-merchantability-variant
+ HPND-sell-MIT-disclaimer-xserver
+ HPND-sell-regexpr
HPND-sell-variant
+ HPND-sell-variant-MIT-disclaimer
+ HPND-sell-variant-MIT-disclaimer-rev
+ HPND-sell-variant-critical-systems
HTMLTIDY
HaskellReport
Hippocratic-2.1
IBM-pibs
ICU
+ IEC-Code-Components-EULA
IJG
+ IJG-short
IPA
IPL-1.0
ISC
+ ISC-Veillard
+ ISO-permission
ImageMagick
Imlib2
Info-ZIP
+ Inner-Net-2.0
+ InnoSetup
Intel
Intel-ACPI
Interbase-1.0
+ JPL-image
JPNIC
JSON
Jam
JasPer-2.0
+ Kastrup
+ Kazlib
Knuth-CTAN
LAL-1.2
LAL-1.3
- LGPL-2.0
- LGPL-2.0+
LGPL-2.0-only
LGPL-2.0-or-later
- LGPL-2.1
- LGPL-2.1+
LGPL-2.1-only
LGPL-2.1-or-later
- LGPL-3.0
- LGPL-3.0+
LGPL-3.0-only
LGPL-3.0-or-later
LGPLLR
+ LOOP
+ LPD-document
LPL-1.0
LPL-1.02
LPPL-1.0
@@ -295,22 +380,37 @@ class Gem::Licenses
LZMA-SDK-9.11-to-9.20
LZMA-SDK-9.22
Latex2e
+ Latex2e-translated-notice
Leptonica
LiLiQ-P-1.1
LiLiQ-R-1.1
LiLiQ-Rplus-1.1
Libpng
Linux-OpenIB
+ Linux-man-pages-1-para
Linux-man-pages-copyleft
+ Linux-man-pages-copyleft-2-para
+ Linux-man-pages-copyleft-var
+ Lucida-Bitmap-Fonts
+ MIPS
MIT
MIT-0
MIT-CMU
+ MIT-Click
+ MIT-Festival
+ MIT-Khronos-old
MIT-Modern-Variant
+ MIT-STK
+ MIT-Wu
MIT-advertising
MIT-enna
MIT-feh
MIT-open-group
+ MIT-testregex
MITNFA
+ MMIXware
+ MMPL-1.0.1
+ MPEG-SSG
MPL-1.0
MPL-1.1
MPL-2.0
@@ -319,7 +419,11 @@ class Gem::Licenses
MS-PL
MS-RL
MTLL
+ Mackerras-3-Clause
+ Mackerras-3-Clause-acknowledgment
MakeIndex
+ Martin-Birgmeier
+ McPhee-slideshow
Minpack
MirOS
Motosoto
@@ -330,12 +434,16 @@ class Gem::Licenses
NAIST-2003
NASA-1.3
NBPL-1.0
+ NCBI-PD
NCGL-UK-2.0
+ NCL
NCSA
NGPL
NICTA-1.0
NIST-PD
+ NIST-PD-TNT
NIST-PD-fallback
+ NIST-Software
NLOD-1.0
NLOD-2.0
NLPL
@@ -344,20 +452,21 @@ class Gem::Licenses
NPL-1.1
NPOSL-3.0
NRL
+ NTIA-PD
NTP
NTP-0
Naumen
- Net-SNMP
NetCDF
Newsletr
Nokia
Noweb
- Nunit
O-UDA-1.0
+ OAR
OCCT-PL
OCLC-2.0
ODC-By-1.0
ODbL-1.0
+ OFFIS
OFL-1.0
OFL-1.0-RFN
OFL-1.0-no-RFN
@@ -387,22 +496,34 @@ class Gem::Licenses
OLDAP-2.6
OLDAP-2.7
OLDAP-2.8
+ OLFL-1.3
OML
OPL-1.0
+ OPL-UK-3.0
OPUBL-1.0
+ OSC-1.0
OSET-PL-2.1
OSL-1.0
OSL-1.1
OSL-2.0
OSL-2.1
OSL-3.0
+ OSSP
+ OpenMDW-1.0
+ OpenPBS-2.3
OpenSSL
+ OpenSSL-standalone
+ OpenVision
+ PADL
PDDL-1.0
PHP-3.0
PHP-3.01
+ PPL
PSF-2.0
+ ParaType-Free-Font-1.3
Parity-6.0.0
Parity-7.0.0
+ Pixar
Plexus
PolyForm-Noncommercial-1.0.0
PolyForm-Small-Business-1.0.0
@@ -410,6 +531,7 @@ class Gem::Licenses
Python-2.0
Python-2.0.1
QPL-1.0
+ QPL-1.0-INRIA-2004
Qhull
RHeCos-1.1
RPL-1.1
@@ -419,62 +541,103 @@ class Gem::Licenses
RSCPL
Rdisc
Ruby
+ Ruby-pty
SAX-PD
+ SAX-PD-2.0
SCEA
SGI-B-1.0
SGI-B-1.1
SGI-B-2.0
+ SGI-OpenGL
+ SGMLUG-PM
+ SGP4
SHL-0.5
SHL-0.51
SISSL
SISSL-1.2
+ SL
+ SMAIL-GPL
SMLNJ
SMPPL
SNIA
+ SOFA
SPL-1.0
SSH-OpenSSH
SSH-short
+ SSLeay-standalone
SSPL-1.0
+ SUL-1.0
SWL
Saxpath
SchemeReport
Sendmail
Sendmail-8.23
+ Sendmail-Open-Source-1.1
SimPL-2.0
Sleepycat
+ Soundex
Spencer-86
Spencer-94
Spencer-99
- StandardML-NJ
SugarCRM-1.1.3
+ Sun-PPP
+ Sun-PPP-2000
+ SunPro
+ Symlinks
TAPR-OHL-1.0
TCL
TCP-wrappers
+ TGPPL-1.0
TMate
TORQUE-1.1
TOSL
+ TPDL
+ TPL-1.0
+ TTWL
+ TTYP0
TU-Berlin-1.0
TU-Berlin-2.0
+ TekHVC
+ TermReadKey
+ ThirdEye
+ TrustedQSL
+ UCAR
UCL-1.0
+ UMich-Merit
UPL-1.0
+ URT-RLE
+ Ubuntu-font-1.0
+ UnRAR
+ Unicode-3.0
Unicode-DFS-2015
Unicode-DFS-2016
Unicode-TOU
+ UnixCrypt
Unlicense
+ Unlicense-libtelnet
+ Unlicense-libwhirlpool
VOSTROM
VSL-1.0
Vim
+ Vixie-Cron
W3C
W3C-19980720
W3C-20150513
+ WTFNMFPL
WTFPL
Watcom-1.0
+ Widget-Workshop
+ WordNet
Wsuipa
X11
X11-distribute-modifications-variant
+ X11-no-permit-persons
+ X11-swapped
XFree86-1.1
XSkat
+ Xdebug-1.03
Xerox
+ Xfig
Xnet
YPL-1.0
YPL-1.1
@@ -482,90 +645,199 @@ class Gem::Licenses
ZPL-2.0
ZPL-2.1
Zed
+ Zeeff
Zend-2.0
Zimbra-1.3
Zimbra-1.4
Zlib
+ any-OSI
+ any-OSI-perl-modules
+ bcrypt-Solar-Designer
blessing
- bzip2-1.0.5
bzip2-1.0.6
+ check-cvs
checkmk
copyleft-next-0.3.0
copyleft-next-0.3.1
curl
+ cve-tou
diffmark
+ dtoa
dvipdfm
- eCos-2.0
eGenix
etalab-2.0
+ fwlw
gSOAP-1.3b
+ generic-xts
gnuplot
+ gtkbook
+ hdparm
+ hyphen-bulgarian
iMatix
+ jove
+ libpng-1.6.35
libpng-2.0
libselinux-1.0
libtiff
libutil-David-Nugent
+ lsof
+ magaz
+ mailprio
+ man2html
+ metamail
mpi-permissive
mpich2
mplus
+ ngrep
+ pkgconf
+ pnmstitch
psfrag
psutils
- wxWindows
+ python-ldap
+ radvd
+ snprintf
+ softSurfer
+ ssh-keyscan
+ swrule
+ threeparttable
+ ulem
+ w3m
+ wwl
xinetd
+ xkeyboard-config-Zinoviev
+ xlock
xpp
+ xzoom
zlib-acknowledgement
].freeze
+ DEPRECATED_LICENSE_IDENTIFIERS = %w[
+ AGPL-1.0
+ AGPL-3.0
+ BSD-2-Clause-FreeBSD
+ BSD-2-Clause-NetBSD
+ GFDL-1.1
+ GFDL-1.2
+ GFDL-1.3
+ GPL-1.0
+ GPL-1.0+
+ GPL-2.0
+ GPL-2.0+
+ GPL-2.0-with-GCC-exception
+ GPL-2.0-with-autoconf-exception
+ GPL-2.0-with-bison-exception
+ GPL-2.0-with-classpath-exception
+ GPL-2.0-with-font-exception
+ GPL-3.0
+ GPL-3.0+
+ GPL-3.0-with-GCC-exception
+ GPL-3.0-with-autoconf-exception
+ LGPL-2.0
+ LGPL-2.0+
+ LGPL-2.1
+ LGPL-2.1+
+ LGPL-3.0
+ LGPL-3.0+
+ Net-SNMP
+ Nunit
+ StandardML-NJ
+ bzip2-1.0.5
+ eCos-2.0
+ wxWindows
+ ].freeze
+
# exception identifiers
EXCEPTION_IDENTIFIERS = %w[
389-exception
+ Asterisk-exception
+ Asterisk-linking-protocols-exception
Autoconf-exception-2.0
Autoconf-exception-3.0
+ Autoconf-exception-generic
+ Autoconf-exception-generic-3.0
+ Autoconf-exception-macro
+ Bison-exception-1.24
Bison-exception-2.2
Bootloader-exception
+ CGAL-linking-exception
CLISP-exception-2.0
Classpath-exception-2.0
+ Classpath-exception-2.0-short
DigiRule-FOSS-exception
+ Digia-Qt-LGPL-exception-1.1
FLTK-exception
Fawkes-Runtime-exception
Font-exception-2.0
GCC-exception-2.0
+ GCC-exception-2.0-note
GCC-exception-3.1
+ GNAT-exception
+ GNOME-examples-exception
+ GNU-compiler-exception
+ GPL-3.0-389-ds-base-exception
+ GPL-3.0-interface-exception
GPL-3.0-linking-exception
GPL-3.0-linking-source-exception
GPL-CC-1.0
GStreamer-exception-2005
GStreamer-exception-2008
+ Gmsh-exception
+ Independent-modules-exception
KiCad-libraries-exception
LGPL-3.0-linking-exception
+ LLGPL
LLVM-exception
LZMA-exception
Libtool-exception
Linux-syscall-note
- Nokia-Qt-exception-1.1
OCCT-exception-1.0
OCaml-LGPL-linking-exception
OpenJDK-assembly-exception-1.0
+ PCRE2-exception
PS-or-PDF-font-exception-20170817
+ QPL-1.0-INRIA-2004-exception
Qt-GPL-exception-1.0
Qt-LGPL-exception-1.1
Qwt-exception-1.0
+ RRDtool-FLOSS-exception-2.0
+ SANE-exception
SHL-2.0
SHL-2.1
+ SWI-exception
+ Simple-Library-Usage-exception
Swift-exception
+ Texinfo-exception
+ UBDL-exception
Universal-FOSS-exception-1.0
WxWindows-exception-3.1
+ cryptsetup-OpenSSL-exception
eCos-exception-2.0
+ erlang-otp-linking-exception
+ fmt-exception
freertos-exception-2.0
gnu-javamail-exception
+ harbour-exception
i2p-gpl-java-exception
+ kvirc-openssl-exception
+ libpri-OpenH323-exception
mif-exception
+ mxml-exception
openvpn-openssl-exception
+ polyparse-exception
+ romic-exception
+ rsync-linking-exception
+ sqlitestudio-OpenSSL-exception
+ stunnel-exception
u-boot-exception-2.0
+ vsftpd-openssl-exception
x11vnc-openssl-exception
].freeze
- REGEXP = %r{
+ DEPRECATED_EXCEPTION_IDENTIFIERS = %w[
+ Nokia-Qt-exception-1.1
+ ].freeze
+
+ VALID_REGEXP = /
\A
(?:
#{Regexp.union(LICENSE_IDENTIFIERS)}
@@ -575,10 +847,34 @@ class Gem::Licenses
| #{LICENSE_REF}
)
\Z
- }ox.freeze
+ /ox
+
+ DEPRECATED_LICENSE_REGEXP = /
+ \A
+ #{Regexp.union(DEPRECATED_LICENSE_IDENTIFIERS)}
+ \+?
+ (?:\s WITH \s .+?)?
+ \Z
+ /ox
+
+ DEPRECATED_EXCEPTION_REGEXP = /
+ \A
+ .+?
+ \+?
+ (?:\s WITH \s #{Regexp.union(DEPRECATED_EXCEPTION_IDENTIFIERS)})
+ \Z
+ /ox
def self.match?(license)
- !REGEXP.match(license).nil?
+ VALID_REGEXP.match?(license)
+ end
+
+ def self.deprecated_license_id?(license)
+ DEPRECATED_LICENSE_REGEXP.match?(license)
+ end
+
+ def self.deprecated_exception_id?(license)
+ DEPRECATED_EXCEPTION_REGEXP.match?(license)
end
def self.suggestions(license)
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb
deleted file mode 100644
index fc2ab38c45..0000000000
--- a/lib/rubygems/util/list.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-module Gem
- # The Gem::List class is currently unused and will be removed in the next major rubygems version
- class List # :nodoc:
- include Enumerable
- attr_accessor :value, :tail
-
- def initialize(value = nil, tail = nil)
- @value = value
- @tail = tail
- end
-
- def each
- n = self
- while n
- yield n.value
- n = n.tail
- end
- end
-
- def to_a
- super.reverse
- end
-
- def prepend(value)
- List.new value, self
- end
-
- def pretty_print(q) # :nodoc:
- q.pp to_a
- end
-
- def self.prepend(list, value)
- return List.new(value) unless list
- List.new value, list
- end
- end
- deprecate_constant :List
-end
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index b42a176ae3..eb5b513570 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -24,7 +25,7 @@ class Gem::Validator
installed_files = []
Find.find gem_directory do |file_name|
- fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "")
+ fn = file_name[gem_directory.size..file_name.size - 1].sub(%r{^/}, "")
installed_files << fn unless
fn.empty? || fn.include?("CVS") || File.directory?(file_name)
end
@@ -58,11 +59,13 @@ class Gem::Validator
#--
# TODO needs further cleanup
- def alien(gems=[])
+ def alien(gems = [])
errors = Hash.new {|h,k| h[k] = {} }
Gem::Specification.each do |spec|
- next unless gems.include? spec.name unless gems.empty?
+ unless gems.empty?
+ next unless gems.include? spec.name
+ end
next if spec.default_gem?
gem_name = spec.file_name
@@ -107,15 +110,13 @@ class Gem::Validator
end
good.each do |entry, data|
- begin
- next unless data # HACK `gem check -a mkrf`
+ next unless data # HACK: `gem check -a mkrf`
- source = File.join gem_directory, entry["path"]
+ source = File.join gem_directory, entry["path"]
- File.open source, Gem.binary_mode do |f|
- unless f.read == data
- errors[gem_name][entry["path"]] = "Modified from original"
- end
+ File.open source, Gem.binary_mode do |f|
+ unless f.read == data
+ errors[gem_name][entry["path"]] = "Modified from original"
end
end
end
diff --git a/lib/rubygems/optparse/.document b/lib/rubygems/vendor/.document
index 0c43bbd6b3..0c43bbd6b3 100644
--- a/lib/rubygems/optparse/.document
+++ b/lib/rubygems/vendor/.document
diff --git a/lib/rubygems/vendor/net-http/lib/net/http.rb b/lib/rubygems/vendor/net-http/lib/net/http.rb
new file mode 100644
index 0000000000..4800cd25f1
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http.rb
@@ -0,0 +1,2608 @@
+# frozen_string_literal: true
+#
+# = net/http.rb
+#
+# Copyright (c) 1999-2007 Yukihiro Matsumoto
+# Copyright (c) 1999-2007 Minero Aoki
+# Copyright (c) 2001 GOTOU Yuuzou
+#
+# Written and maintained by Minero Aoki <aamine@loveruby.net>.
+# HTTPS support added by GOTOU Yuuzou <gotoyuzo@notwork.org>.
+#
+# This file is derived from "http-access.rb".
+#
+# Documented by Minero Aoki; converted to RDoc by William Webber.
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms of ruby itself ---
+# Ruby Distribution License or GNU General Public License.
+#
+# See Gem::Net::HTTP for an overview and examples.
+#
+
+require_relative '../../../net-protocol/lib/net/protocol'
+require_relative '../../../uri/lib/uri'
+require_relative '../../../resolv/lib/resolv'
+autoload :OpenSSL, 'openssl'
+
+module Gem::Net #:nodoc:
+
+ # :stopdoc:
+ class HTTPBadResponse < StandardError; end
+ class HTTPHeaderSyntaxError < StandardError; end
+ # :startdoc:
+
+ # \Class \Gem::Net::HTTP provides a rich library that implements the client
+ # in a client-server model that uses the \HTTP request-response protocol.
+ # For information about \HTTP, see:
+ #
+ # - {Hypertext Transfer Protocol}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol].
+ # - {Technical overview}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Technical_overview].
+ #
+ # == About the Examples
+ #
+ # :include: doc/net-http/examples.rdoc
+ #
+ # == Strategies
+ #
+ # - If you will make only a few GET requests,
+ # consider using {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html].
+ # - If you will make only a few requests of all kinds,
+ # consider using the various singleton convenience methods in this class.
+ # Each of the following methods automatically starts and finishes
+ # a {session}[rdoc-ref:Gem::Net::HTTP@Sessions] that sends a single request:
+ #
+ # # Return string response body.
+ # Gem::Net::HTTP.get(hostname, path)
+ # Gem::Net::HTTP.get(uri)
+ #
+ # # Write string response body to $stdout.
+ # Gem::Net::HTTP.get_print(hostname, path)
+ # Gem::Net::HTTP.get_print(uri)
+ #
+ # # Return response as Gem::Net::HTTPResponse object.
+ # Gem::Net::HTTP.get_response(hostname, path)
+ # Gem::Net::HTTP.get_response(uri)
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # Gem::Net::HTTP.post(uri, data)
+ # params = {title: 'foo', body: 'bar', userId: 1}
+ # Gem::Net::HTTP.post_form(uri, params)
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # Gem::Net::HTTP.put(uri, data)
+ #
+ # - If performance is important, consider using sessions, which lower request overhead.
+ # This {session}[rdoc-ref:Gem::Net::HTTP@Sessions] has multiple requests for
+ # {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]
+ # and {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]:
+ #
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # # Session started automatically before block execution.
+ # http.get(path)
+ # http.head(path)
+ # body = 'Some text'
+ # http.post(path, body) # Can also have a block.
+ # http.put(path, body)
+ # http.delete(path)
+ # http.options(path)
+ # http.trace(path)
+ # http.patch(path, body) # Can also have a block.
+ # http.copy(path)
+ # http.lock(path, body)
+ # http.mkcol(path, body)
+ # http.move(path)
+ # http.propfind(path, body)
+ # http.proppatch(path, body)
+ # http.unlock(path, body)
+ # # Session finished automatically at block exit.
+ # end
+ #
+ # The methods cited above are convenience methods that, via their few arguments,
+ # allow minimal control over the requests.
+ # For greater control, consider using {request objects}[rdoc-ref:Gem::Net::HTTPRequest].
+ #
+ # == URIs
+ #
+ # On the internet, a Gem::URI
+ # ({Universal Resource Identifier}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier])
+ # is a string that identifies a particular resource.
+ # It consists of some or all of: scheme, hostname, path, query, and fragment;
+ # see {Gem::URI syntax}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax].
+ #
+ # A Ruby {Gem::URI::Generic}[https://docs.ruby-lang.org/en/master/Gem::URI/Generic.html] object
+ # represents an internet Gem::URI.
+ # It provides, among others, methods
+ # +scheme+, +hostname+, +path+, +query+, and +fragment+.
+ #
+ # === Schemes
+ #
+ # An internet \Gem::URI has
+ # a {scheme}[https://en.wikipedia.org/wiki/List_of_URI_schemes].
+ #
+ # The two schemes supported in \Gem::Net::HTTP are <tt>'https'</tt> and <tt>'http'</tt>:
+ #
+ # uri.scheme # => "https"
+ # Gem::URI('http://example.com').scheme # => "http"
+ #
+ # === Hostnames
+ #
+ # A hostname identifies a server (host) to which requests may be sent:
+ #
+ # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # # Some HTTP stuff.
+ # end
+ #
+ # === Paths
+ #
+ # A host-specific path identifies a resource on the host:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/todos/1'
+ # hostname = _uri.hostname
+ # path = _uri.path
+ # Gem::Net::HTTP.get(hostname, path)
+ #
+ # === Queries
+ #
+ # A host-specific query adds name/value pairs to the Gem::URI:
+ #
+ # _uri = uri.dup
+ # params = {userId: 1, completed: false}
+ # _uri.query = Gem::URI.encode_www_form(params)
+ # _uri # => #<Gem::URI::HTTPS https://jsonplaceholder.typicode.com?userId=1&completed=false>
+ # Gem::Net::HTTP.get(_uri)
+ #
+ # === Fragments
+ #
+ # A {Gem::URI fragment}[https://en.wikipedia.org/wiki/URI_fragment] has no effect
+ # in \Gem::Net::HTTP;
+ # the same data is returned, regardless of whether a fragment is included.
+ #
+ # == Request Headers
+ #
+ # Request headers may be used to pass additional information to the host,
+ # similar to arguments passed in a method call;
+ # each header is a name/value pair.
+ #
+ # Each of the \Gem::Net::HTTP methods that sends a request to the host
+ # has optional argument +headers+,
+ # where the headers are expressed as a hash of field-name/value pairs:
+ #
+ # headers = {Accept: 'application/json', Connection: 'Keep-Alive'}
+ # Gem::Net::HTTP.get(uri, headers)
+ #
+ # See lists of both standard request fields and common request fields at
+ # {Request Fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
+ # A host may also accept other custom fields.
+ #
+ # == \HTTP Sessions
+ #
+ # A _session_ is a connection between a server (host) and a client that:
+ #
+ # - Is begun by instance method Gem::Net::HTTP#start.
+ # - May contain any number of requests.
+ # - Is ended by instance method Gem::Net::HTTP#finish.
+ #
+ # See example sessions at {Strategies}[rdoc-ref:Gem::Net::HTTP@Strategies].
+ #
+ # === Session Using \Gem::Net::HTTP.start
+ #
+ # If you have many requests to make to a single host (and port),
+ # consider using singleton method Gem::Net::HTTP.start with a block;
+ # the method handles the session automatically by:
+ #
+ # - Calling #start before block execution.
+ # - Executing the block.
+ # - Calling #finish after block execution.
+ #
+ # In the block, you can use these instance methods,
+ # each of which that sends a single request:
+ #
+ # - {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]:
+ #
+ # - #get, #request_get: GET.
+ # - #head, #request_head: HEAD.
+ # - #post, #request_post: POST.
+ # - #delete: DELETE.
+ # - #options: OPTIONS.
+ # - #trace: TRACE.
+ # - #patch: PATCH.
+ #
+ # - {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]:
+ #
+ # - #copy: COPY.
+ # - #lock: LOCK.
+ # - #mkcol: MKCOL.
+ # - #move: MOVE.
+ # - #propfind: PROPFIND.
+ # - #proppatch: PROPPATCH.
+ # - #unlock: UNLOCK.
+ #
+ # === Session Using \Gem::Net::HTTP.start and \Gem::Net::HTTP.finish
+ #
+ # You can manage a session manually using methods #start and #finish:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.start
+ # http.get('/todos/1')
+ # http.get('/todos/2')
+ # http.delete('/posts/1')
+ # http.finish # Needed to free resources.
+ #
+ # === Single-Request Session
+ #
+ # Certain convenience methods automatically handle a session by:
+ #
+ # - Creating an \HTTP object
+ # - Starting a session.
+ # - Sending a single request.
+ # - Finishing the session.
+ # - Destroying the object.
+ #
+ # Such methods that send GET requests:
+ #
+ # - ::get: Returns the string response body.
+ # - ::get_print: Writes the string response body to $stdout.
+ # - ::get_response: Returns a Gem::Net::HTTPResponse object.
+ #
+ # Such methods that send POST requests:
+ #
+ # - ::post: Posts data to the host.
+ # - ::post_form: Posts form data to the host.
+ #
+ # == \HTTP Requests and Responses
+ #
+ # Many of the methods above are convenience methods,
+ # each of which sends a request and returns a string
+ # without directly using \Gem::Net::HTTPRequest and \Gem::Net::HTTPResponse objects.
+ #
+ # You can, however, directly create a request object, send the request,
+ # and retrieve the response object; see:
+ #
+ # - Gem::Net::HTTPRequest.
+ # - Gem::Net::HTTPResponse.
+ #
+ # == Following Redirection
+ #
+ # Each returned response is an instance of a subclass of Gem::Net::HTTPResponse.
+ # See the {response class hierarchy}[rdoc-ref:Gem::Net::HTTPResponse@Response+Subclasses].
+ #
+ # In particular, class Gem::Net::HTTPRedirection is the parent
+ # of all redirection classes.
+ # This allows you to craft a case statement to handle redirections properly:
+ #
+ # def fetch(uri, limit = 10)
+ # # You should choose a better exception.
+ # raise ArgumentError, 'Too many HTTP redirects' if limit == 0
+ #
+ # res = Gem::Net::HTTP.get_response(Gem::URI(uri))
+ # case res
+ # when Gem::Net::HTTPSuccess # Any success class.
+ # res
+ # when Gem::Net::HTTPRedirection # Any redirection class.
+ # location = res['Location']
+ # warn "Redirected to #{location}"
+ # fetch(location, limit - 1)
+ # else # Any other class.
+ # res.value
+ # end
+ # end
+ #
+ # fetch(uri)
+ #
+ # == Basic Authentication
+ #
+ # Basic authentication is performed according to
+ # {RFC2617}[http://www.ietf.org/rfc/rfc2617.txt]:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.basic_auth('user', 'pass')
+ # res = Gem::Net::HTTP.start(hostname) do |http|
+ # http.request(req)
+ # end
+ #
+ # == Streaming Response Bodies
+ #
+ # By default \Gem::Net::HTTP reads an entire response into memory. If you are
+ # handling large files or wish to implement a progress bar you can instead
+ # stream the body directly to an IO.
+ #
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # http.request(req) do |res|
+ # open('t.tmp', 'w') do |f|
+ # res.read_body do |chunk|
+ # f.write chunk
+ # end
+ # end
+ # end
+ # end
+ #
+ # == HTTPS
+ #
+ # HTTPS is enabled for an \HTTP connection by Gem::Net::HTTP#use_ssl=:
+ #
+ # Gem::Net::HTTP.start(hostname, :use_ssl => true) do |http|
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # res = http.request(req)
+ # end
+ #
+ # Or if you simply want to make a GET request, you may pass in a Gem::URI
+ # object that has an \HTTPS URL. \Gem::Net::HTTP automatically turns on TLS
+ # verification if the Gem::URI object has a 'https' Gem::URI scheme:
+ #
+ # uri # => #<Gem::URI::HTTPS https://jsonplaceholder.typicode.com/>
+ # Gem::Net::HTTP.get(uri)
+ #
+ # == Proxy Server
+ #
+ # An \HTTP object can have
+ # a {proxy server}[https://en.wikipedia.org/wiki/Proxy_server].
+ #
+ # You can create an \HTTP object with a proxy server
+ # using method Gem::Net::HTTP.new or method Gem::Net::HTTP.start.
+ #
+ # The proxy may be defined either by argument +p_addr+
+ # or by environment variable <tt>'http_proxy'</tt>.
+ #
+ # === Proxy Using Argument +p_addr+ as a \String
+ #
+ # When argument +p_addr+ is a string hostname,
+ # the returned +http+ has the given host as its proxy:
+ #
+ # http = Gem::Net::HTTP.new(hostname, nil, 'proxy.example')
+ # http.proxy? # => true
+ # http.proxy_from_env? # => false
+ # http.proxy_address # => "proxy.example"
+ # # These use default values.
+ # http.proxy_port # => 80
+ # http.proxy_user # => nil
+ # http.proxy_pass # => nil
+ #
+ # The port, username, and password for the proxy may also be given:
+ #
+ # http = Gem::Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass')
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.proxy? # => true
+ # http.proxy_from_env? # => false
+ # http.proxy_address # => "proxy.example"
+ # http.proxy_port # => 8000
+ # http.proxy_user # => "pname"
+ # http.proxy_pass # => "ppass"
+ #
+ # === Proxy Using '<tt>ENV['http_proxy']</tt>'
+ #
+ # When environment variable <tt>'http_proxy'</tt>
+ # is set to a \Gem::URI string,
+ # the returned +http+ will have the server at that Gem::URI as its proxy;
+ # note that the \Gem::URI string must have a protocol
+ # such as <tt>'http'</tt> or <tt>'https'</tt>:
+ #
+ # ENV['http_proxy'] = 'http://example.com'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.proxy? # => true
+ # http.proxy_from_env? # => true
+ # http.proxy_address # => "example.com"
+ # # These use default values.
+ # http.proxy_port # => 80
+ # http.proxy_user # => nil
+ # http.proxy_pass # => nil
+ #
+ # The \Gem::URI string may include proxy username, password, and port number:
+ #
+ # ENV['http_proxy'] = 'http://pname:ppass@example.com:8000'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.proxy? # => true
+ # http.proxy_from_env? # => true
+ # http.proxy_address # => "example.com"
+ # http.proxy_port # => 8000
+ # http.proxy_user # => "pname"
+ # http.proxy_pass # => "ppass"
+ #
+ # === Filtering Proxies
+ #
+ # With method Gem::Net::HTTP.new (but not Gem::Net::HTTP.start),
+ # you can use argument +p_no_proxy+ to filter proxies:
+ #
+ # - Reject a certain address:
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
+ # http.proxy_address # => nil
+ #
+ # - Reject certain domains or subdomains:
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
+ # http.proxy_address # => nil
+ #
+ # - Reject certain addresses and port combinations:
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234')
+ # http.proxy_address # => "proxy.example"
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # - Reject a list of the types above delimited using a comma:
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # http = Gem::Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # == Compression and Decompression
+ #
+ # \Gem::Net::HTTP does not compress the body of a request before sending.
+ #
+ # By default, \Gem::Net::HTTP adds header <tt>'Accept-Encoding'</tt>
+ # to a new {request object}[rdoc-ref:Gem::Net::HTTPRequest]:
+ #
+ # Gem::Net::HTTP::Get.new(uri)['Accept-Encoding']
+ # # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
+ #
+ # This requests the server to zip-encode the response body if there is one;
+ # the server is not required to do so.
+ #
+ # \Gem::Net::HTTP does not automatically decompress a response body
+ # if the response has header <tt>'Content-Range'</tt>.
+ #
+ # Otherwise decompression (or not) depends on the value of header
+ # {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]:
+ #
+ # - <tt>'deflate'</tt>, <tt>'gzip'</tt>, or <tt>'x-gzip'</tt>:
+ # decompresses the body and deletes the header.
+ # - <tt>'none'</tt> or <tt>'identity'</tt>:
+ # does not decompress the body, but deletes the header.
+ # - Any other value:
+ # leaves the body and header unchanged.
+ #
+ # == What's Here
+ #
+ # First, what's elsewhere. Class Gem::Net::HTTP:
+ #
+ # - Inherits from {class Object}[https://docs.ruby-lang.org/en/master/Object.html#class-Object-label-What-27s+Here].
+ #
+ # This is a categorized summary of methods and attributes.
+ #
+ # === \Gem::Net::HTTP Objects
+ #
+ # - {::new}[rdoc-ref:Gem::Net::HTTP.new]:
+ # Creates a new instance.
+ # - {#inspect}[rdoc-ref:Gem::Net::HTTP#inspect]:
+ # Returns a string representation of +self+.
+ #
+ # === Sessions
+ #
+ # - {::start}[rdoc-ref:Gem::Net::HTTP.start]:
+ # Begins a new session in a new \Gem::Net::HTTP object.
+ # - {#started?}[rdoc-ref:Gem::Net::HTTP#started?]:
+ # Returns whether in a session.
+ # - {#finish}[rdoc-ref:Gem::Net::HTTP#finish]:
+ # Ends an active session.
+ # - {#start}[rdoc-ref:Gem::Net::HTTP#start]:
+ # Begins a new session in an existing \Gem::Net::HTTP object (+self+).
+ #
+ # === Connections
+ #
+ # - {:continue_timeout}[rdoc-ref:Gem::Net::HTTP#continue_timeout]:
+ # Returns the continue timeout.
+ # - {#continue_timeout=}[rdoc-ref:Gem::Net::HTTP#continue_timeout=]:
+ # Sets the continue timeout seconds.
+ # - {:keep_alive_timeout}[rdoc-ref:Gem::Net::HTTP#keep_alive_timeout]:
+ # Returns the keep-alive timeout.
+ # - {:keep_alive_timeout=}[rdoc-ref:Gem::Net::HTTP#keep_alive_timeout=]:
+ # Sets the keep-alive timeout.
+ # - {:max_retries}[rdoc-ref:Gem::Net::HTTP#max_retries]:
+ # Returns the maximum retries.
+ # - {#max_retries=}[rdoc-ref:Gem::Net::HTTP#max_retries=]:
+ # Sets the maximum retries.
+ # - {:open_timeout}[rdoc-ref:Gem::Net::HTTP#open_timeout]:
+ # Returns the open timeout.
+ # - {:open_timeout=}[rdoc-ref:Gem::Net::HTTP#open_timeout=]:
+ # Sets the open timeout.
+ # - {:read_timeout}[rdoc-ref:Gem::Net::HTTP#read_timeout]:
+ # Returns the open timeout.
+ # - {:read_timeout=}[rdoc-ref:Gem::Net::HTTP#read_timeout=]:
+ # Sets the read timeout.
+ # - {:ssl_timeout}[rdoc-ref:Gem::Net::HTTP#ssl_timeout]:
+ # Returns the ssl timeout.
+ # - {:ssl_timeout=}[rdoc-ref:Gem::Net::HTTP#ssl_timeout=]:
+ # Sets the ssl timeout.
+ # - {:write_timeout}[rdoc-ref:Gem::Net::HTTP#write_timeout]:
+ # Returns the write timeout.
+ # - {write_timeout=}[rdoc-ref:Gem::Net::HTTP#write_timeout=]:
+ # Sets the write timeout.
+ #
+ # === Requests
+ #
+ # - {::get}[rdoc-ref:Gem::Net::HTTP.get]:
+ # Sends a GET request and returns the string response body.
+ # - {::get_print}[rdoc-ref:Gem::Net::HTTP.get_print]:
+ # Sends a GET request and write the string response body to $stdout.
+ # - {::get_response}[rdoc-ref:Gem::Net::HTTP.get_response]:
+ # Sends a GET request and returns a response object.
+ # - {::post_form}[rdoc-ref:Gem::Net::HTTP.post_form]:
+ # Sends a POST request with form data and returns a response object.
+ # - {::post}[rdoc-ref:Gem::Net::HTTP.post]:
+ # Sends a POST request with data and returns a response object.
+ # - {::put}[rdoc-ref:Gem::Net::HTTP.put]:
+ # Sends a PUT request with data and returns a response object.
+ # - {#copy}[rdoc-ref:Gem::Net::HTTP#copy]:
+ # Sends a COPY request and returns a response object.
+ # - {#delete}[rdoc-ref:Gem::Net::HTTP#delete]:
+ # Sends a DELETE request and returns a response object.
+ # - {#get}[rdoc-ref:Gem::Net::HTTP#get]:
+ # Sends a GET request and returns a response object.
+ # - {#head}[rdoc-ref:Gem::Net::HTTP#head]:
+ # Sends a HEAD request and returns a response object.
+ # - {#lock}[rdoc-ref:Gem::Net::HTTP#lock]:
+ # Sends a LOCK request and returns a response object.
+ # - {#mkcol}[rdoc-ref:Gem::Net::HTTP#mkcol]:
+ # Sends a MKCOL request and returns a response object.
+ # - {#move}[rdoc-ref:Gem::Net::HTTP#move]:
+ # Sends a MOVE request and returns a response object.
+ # - {#options}[rdoc-ref:Gem::Net::HTTP#options]:
+ # Sends a OPTIONS request and returns a response object.
+ # - {#patch}[rdoc-ref:Gem::Net::HTTP#patch]:
+ # Sends a PATCH request and returns a response object.
+ # - {#post}[rdoc-ref:Gem::Net::HTTP#post]:
+ # Sends a POST request and returns a response object.
+ # - {#propfind}[rdoc-ref:Gem::Net::HTTP#propfind]:
+ # Sends a PROPFIND request and returns a response object.
+ # - {#proppatch}[rdoc-ref:Gem::Net::HTTP#proppatch]:
+ # Sends a PROPPATCH request and returns a response object.
+ # - {#put}[rdoc-ref:Gem::Net::HTTP#put]:
+ # Sends a PUT request and returns a response object.
+ # - {#request}[rdoc-ref:Gem::Net::HTTP#request]:
+ # Sends a request and returns a response object.
+ # - {#request_get}[rdoc-ref:Gem::Net::HTTP#request_get]:
+ # Sends a GET request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#request_head}[rdoc-ref:Gem::Net::HTTP#request_head]:
+ # Sends a HEAD request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#request_post}[rdoc-ref:Gem::Net::HTTP#request_post]:
+ # Sends a POST request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#send_request}[rdoc-ref:Gem::Net::HTTP#send_request]:
+ # Sends a request and returns a response object.
+ # - {#trace}[rdoc-ref:Gem::Net::HTTP#trace]:
+ # Sends a TRACE request and returns a response object.
+ # - {#unlock}[rdoc-ref:Gem::Net::HTTP#unlock]:
+ # Sends an UNLOCK request and returns a response object.
+ #
+ # === Responses
+ #
+ # - {:close_on_empty_response}[rdoc-ref:Gem::Net::HTTP#close_on_empty_response]:
+ # Returns whether to close connection on empty response.
+ # - {:close_on_empty_response=}[rdoc-ref:Gem::Net::HTTP#close_on_empty_response=]:
+ # Sets whether to close connection on empty response.
+ # - {:ignore_eof}[rdoc-ref:Gem::Net::HTTP#ignore_eof]:
+ # Returns whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers.
+ # - {:ignore_eof=}[rdoc-ref:Gem::Net::HTTP#ignore_eof=]:
+ # Sets whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers.
+ # - {:response_body_encoding}[rdoc-ref:Gem::Net::HTTP#response_body_encoding]:
+ # Returns the encoding to use for the response body.
+ # - {#response_body_encoding=}[rdoc-ref:Gem::Net::HTTP#response_body_encoding=]:
+ # Sets the response body encoding.
+ #
+ # === Proxies
+ #
+ # - {:proxy_address}[rdoc-ref:Gem::Net::HTTP#proxy_address]:
+ # Returns the proxy address.
+ # - {:proxy_address=}[rdoc-ref:Gem::Net::HTTP#proxy_address=]:
+ # Sets the proxy address.
+ # - {::proxy_class?}[rdoc-ref:Gem::Net::HTTP.proxy_class?]:
+ # Returns whether +self+ is a proxy class.
+ # - {#proxy?}[rdoc-ref:Gem::Net::HTTP#proxy?]:
+ # Returns whether +self+ has a proxy.
+ # - {#proxy_address}[rdoc-ref:Gem::Net::HTTP#proxy_address]:
+ # Returns the proxy address.
+ # - {#proxy_from_env?}[rdoc-ref:Gem::Net::HTTP#proxy_from_env?]:
+ # Returns whether the proxy is taken from an environment variable.
+ # - {:proxy_from_env=}[rdoc-ref:Gem::Net::HTTP#proxy_from_env=]:
+ # Sets whether the proxy is to be taken from an environment variable.
+ # - {:proxy_pass}[rdoc-ref:Gem::Net::HTTP#proxy_pass]:
+ # Returns the proxy password.
+ # - {:proxy_pass=}[rdoc-ref:Gem::Net::HTTP#proxy_pass=]:
+ # Sets the proxy password.
+ # - {:proxy_port}[rdoc-ref:Gem::Net::HTTP#proxy_port]:
+ # Returns the proxy port.
+ # - {:proxy_port=}[rdoc-ref:Gem::Net::HTTP#proxy_port=]:
+ # Sets the proxy port.
+ # - {#proxy_user}[rdoc-ref:Gem::Net::HTTP#proxy_user]:
+ # Returns the proxy user name.
+ # - {:proxy_user=}[rdoc-ref:Gem::Net::HTTP#proxy_user=]:
+ # Sets the proxy user.
+ #
+ # === Security
+ #
+ # - {:ca_file}[rdoc-ref:Gem::Net::HTTP#ca_file]:
+ # Returns the path to a CA certification file.
+ # - {:ca_file=}[rdoc-ref:Gem::Net::HTTP#ca_file=]:
+ # Sets the path to a CA certification file.
+ # - {:ca_path}[rdoc-ref:Gem::Net::HTTP#ca_path]:
+ # Returns the path of to CA directory containing certification files.
+ # - {:ca_path=}[rdoc-ref:Gem::Net::HTTP#ca_path=]:
+ # Sets the path of to CA directory containing certification files.
+ # - {:cert}[rdoc-ref:Gem::Net::HTTP#cert]:
+ # Returns the OpenSSL::X509::Certificate object to be used for client certification.
+ # - {:cert=}[rdoc-ref:Gem::Net::HTTP#cert=]:
+ # Sets the OpenSSL::X509::Certificate object to be used for client certification.
+ # - {:cert_store}[rdoc-ref:Gem::Net::HTTP#cert_store]:
+ # Returns the X509::Store to be used for verifying peer certificate.
+ # - {:cert_store=}[rdoc-ref:Gem::Net::HTTP#cert_store=]:
+ # Sets the X509::Store to be used for verifying peer certificate.
+ # - {:ciphers}[rdoc-ref:Gem::Net::HTTP#ciphers]:
+ # Returns the available SSL ciphers.
+ # - {:ciphers=}[rdoc-ref:Gem::Net::HTTP#ciphers=]:
+ # Sets the available SSL ciphers.
+ # - {:extra_chain_cert}[rdoc-ref:Gem::Net::HTTP#extra_chain_cert]:
+ # Returns the extra X509 certificates to be added to the certificate chain.
+ # - {:extra_chain_cert=}[rdoc-ref:Gem::Net::HTTP#extra_chain_cert=]:
+ # Sets the extra X509 certificates to be added to the certificate chain.
+ # - {:key}[rdoc-ref:Gem::Net::HTTP#key]:
+ # Returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ # - {:key=}[rdoc-ref:Gem::Net::HTTP#key=]:
+ # Sets the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ # - {:max_version}[rdoc-ref:Gem::Net::HTTP#max_version]:
+ # Returns the maximum SSL version.
+ # - {:max_version=}[rdoc-ref:Gem::Net::HTTP#max_version=]:
+ # Sets the maximum SSL version.
+ # - {:min_version}[rdoc-ref:Gem::Net::HTTP#min_version]:
+ # Returns the minimum SSL version.
+ # - {:min_version=}[rdoc-ref:Gem::Net::HTTP#min_version=]:
+ # Sets the minimum SSL version.
+ # - {#peer_cert}[rdoc-ref:Gem::Net::HTTP#peer_cert]:
+ # Returns the X509 certificate chain for the session's socket peer.
+ # - {:ssl_version}[rdoc-ref:Gem::Net::HTTP#ssl_version]:
+ # Returns the SSL version.
+ # - {:ssl_version=}[rdoc-ref:Gem::Net::HTTP#ssl_version=]:
+ # Sets the SSL version.
+ # - {#use_ssl=}[rdoc-ref:Gem::Net::HTTP#use_ssl=]:
+ # Sets whether a new session is to use Transport Layer Security.
+ # - {#use_ssl?}[rdoc-ref:Gem::Net::HTTP#use_ssl?]:
+ # Returns whether +self+ uses SSL.
+ # - {:verify_callback}[rdoc-ref:Gem::Net::HTTP#verify_callback]:
+ # Returns the callback for the server certification verification.
+ # - {:verify_callback=}[rdoc-ref:Gem::Net::HTTP#verify_callback=]:
+ # Sets the callback for the server certification verification.
+ # - {:verify_depth}[rdoc-ref:Gem::Net::HTTP#verify_depth]:
+ # Returns the maximum depth for the certificate chain verification.
+ # - {:verify_depth=}[rdoc-ref:Gem::Net::HTTP#verify_depth=]:
+ # Sets the maximum depth for the certificate chain verification.
+ # - {:verify_hostname}[rdoc-ref:Gem::Net::HTTP#verify_hostname]:
+ # Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_hostname=}[rdoc-ref:Gem::Net::HTTP#verify_hostname=]:
+ # Sets he flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_mode}[rdoc-ref:Gem::Net::HTTP#verify_mode]:
+ # Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_mode=}[rdoc-ref:Gem::Net::HTTP#verify_mode=]:
+ # Sets the flags for server the certification verification at the beginning of the SSL/TLS session.
+ #
+ # === Addresses and Ports
+ #
+ # - {:address}[rdoc-ref:Gem::Net::HTTP#address]:
+ # Returns the string host name or host IP.
+ # - {::default_port}[rdoc-ref:Gem::Net::HTTP.default_port]:
+ # Returns integer 80, the default port to use for HTTP requests.
+ # - {::http_default_port}[rdoc-ref:Gem::Net::HTTP.http_default_port]:
+ # Returns integer 80, the default port to use for HTTP requests.
+ # - {::https_default_port}[rdoc-ref:Gem::Net::HTTP.https_default_port]:
+ # Returns integer 443, the default port to use for HTTPS requests.
+ # - {#ipaddr}[rdoc-ref:Gem::Net::HTTP#ipaddr]:
+ # Returns the IP address for the connection.
+ # - {#ipaddr=}[rdoc-ref:Gem::Net::HTTP#ipaddr=]:
+ # Sets the IP address for the connection.
+ # - {:local_host}[rdoc-ref:Gem::Net::HTTP#local_host]:
+ # Returns the string local host used to establish the connection.
+ # - {:local_host=}[rdoc-ref:Gem::Net::HTTP#local_host=]:
+ # Sets the string local host used to establish the connection.
+ # - {:local_port}[rdoc-ref:Gem::Net::HTTP#local_port]:
+ # Returns the integer local port used to establish the connection.
+ # - {:local_port=}[rdoc-ref:Gem::Net::HTTP#local_port=]:
+ # Sets the integer local port used to establish the connection.
+ # - {:port}[rdoc-ref:Gem::Net::HTTP#port]:
+ # Returns the integer port number.
+ #
+ # === \HTTP Version
+ #
+ # - {::version_1_2?}[rdoc-ref:Gem::Net::HTTP.version_1_2?]
+ # (aliased as {::version_1_2}[rdoc-ref:Gem::Net::HTTP.version_1_2]):
+ # Returns true; retained for compatibility.
+ #
+ # === Debugging
+ #
+ # - {#set_debug_output}[rdoc-ref:Gem::Net::HTTP#set_debug_output]:
+ # Sets the output stream for debugging.
+ #
+ class HTTP < Protocol
+
+ # :stopdoc:
+ VERSION = "0.9.1"
+ HTTPVersion = '1.1'
+ begin
+ require 'zlib'
+ HAVE_ZLIB=true
+ rescue LoadError
+ HAVE_ZLIB=false
+ end
+ # :startdoc:
+
+ # Returns +true+; retained for compatibility.
+ def HTTP.version_1_2
+ true
+ end
+
+ # Returns +true+; retained for compatibility.
+ def HTTP.version_1_2?
+ true
+ end
+
+ # Returns +false+; retained for compatibility.
+ def HTTP.version_1_1? #:nodoc:
+ false
+ end
+
+ class << HTTP
+ alias is_version_1_1? version_1_1? #:nodoc:
+ alias is_version_1_2? version_1_2? #:nodoc:
+ end
+
+ # :call-seq:
+ # Gem::Net::HTTP.get_print(hostname, path, port = 80) -> nil
+ # Gem::Net::HTTP:get_print(uri, headers = {}, port = uri.port) -> nil
+ #
+ # Like Gem::Net::HTTP.get, but writes the returned body to $stdout;
+ # returns +nil+.
+ def HTTP.get_print(uri_or_host, path_or_headers = nil, port = nil)
+ get_response(uri_or_host, path_or_headers, port) {|res|
+ res.read_body do |chunk|
+ $stdout.print chunk
+ end
+ }
+ nil
+ end
+
+ # :call-seq:
+ # Gem::Net::HTTP.get(hostname, path, port = 80) -> body
+ # Gem::Net::HTTP:get(uri, headers = {}, port = uri.port) -> body
+ #
+ # Sends a GET request and returns the \HTTP response body as a string.
+ #
+ # With string arguments +hostname+ and +path+:
+ #
+ # hostname = 'jsonplaceholder.typicode.com'
+ # path = '/todos/1'
+ # puts Gem::Net::HTTP.get(hostname, path)
+ #
+ # Output:
+ #
+ # {
+ # "userId": 1,
+ # "id": 1,
+ # "title": "delectus aut autem",
+ # "completed": false
+ # }
+ #
+ # With Gem::URI object +uri+ and optional hash argument +headers+:
+ #
+ # uri = Gem::URI('https://jsonplaceholder.typicode.com/todos/1')
+ # headers = {'Content-type' => 'application/json; charset=UTF-8'}
+ # Gem::Net::HTTP.get(uri, headers)
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Get: request class for \HTTP method +GET+.
+ # - Gem::Net::HTTP#get: convenience method for \HTTP method +GET+.
+ #
+ def HTTP.get(uri_or_host, path_or_headers = nil, port = nil)
+ get_response(uri_or_host, path_or_headers, port).body
+ end
+
+ # :call-seq:
+ # Gem::Net::HTTP.get_response(hostname, path, port = 80) -> http_response
+ # Gem::Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response
+ #
+ # Like Gem::Net::HTTP.get, but returns a Gem::Net::HTTPResponse object
+ # instead of the body string.
+ def HTTP.get_response(uri_or_host, path_or_headers = nil, port = nil, &block)
+ if path_or_headers && !path_or_headers.is_a?(Hash)
+ host = uri_or_host
+ path = path_or_headers
+ new(host, port || HTTP.default_port).start {|http|
+ return http.request_get(path, &block)
+ }
+ else
+ uri = uri_or_host
+ headers = path_or_headers
+ start(uri.hostname, uri.port,
+ :use_ssl => uri.scheme == 'https') {|http|
+ return http.request_get(uri, headers, &block)
+ }
+ end
+ end
+
+ # Posts data to a host; returns a Gem::Net::HTTPResponse object.
+ #
+ # Argument +url+ must be a URL;
+ # argument +data+ must be a string:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # headers = {'content-type': 'application/json'}
+ # res = Gem::Net::HTTP.post(_uri, data, headers) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ # puts res.body
+ #
+ # Output:
+ #
+ # {
+ # "title": "foo",
+ # "body": "bar",
+ # "userId": 1,
+ # "id": 101
+ # }
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Post: request class for \HTTP method +POST+.
+ # - Gem::Net::HTTP#post: convenience method for \HTTP method +POST+.
+ #
+ def HTTP.post(url, data, header = nil)
+ start(url.hostname, url.port,
+ :use_ssl => url.scheme == 'https' ) {|http|
+ http.post(url, data, header)
+ }
+ end
+
+ # Posts data to a host; returns a Gem::Net::HTTPResponse object.
+ #
+ # Argument +url+ must be a Gem::URI;
+ # argument +data+ must be a hash:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # data = {title: 'foo', body: 'bar', userId: 1}
+ # res = Gem::Net::HTTP.post_form(_uri, data) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ # puts res.body
+ #
+ # Output:
+ #
+ # {
+ # "title": "foo",
+ # "body": "bar",
+ # "userId": "1",
+ # "id": 101
+ # }
+ #
+ def HTTP.post_form(url, params)
+ req = Post.new(url)
+ req.form_data = params
+ req.basic_auth url.user, url.password if url.user
+ start(url.hostname, url.port,
+ :use_ssl => url.scheme == 'https' ) {|http|
+ http.request(req)
+ }
+ end
+
+ # Sends a PUT request to the server; returns a Gem::Net::HTTPResponse object.
+ #
+ # Argument +url+ must be a URL;
+ # argument +data+ must be a string:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
+ # headers = {'content-type': 'application/json'}
+ # res = Gem::Net::HTTP.put(_uri, data, headers) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ # puts res.body
+ #
+ # Output:
+ #
+ # {
+ # "title": "foo",
+ # "body": "bar",
+ # "userId": 1,
+ # "id": 101
+ # }
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Put: request class for \HTTP method +PUT+.
+ # - Gem::Net::HTTP#put: convenience method for \HTTP method +PUT+.
+ #
+ def HTTP.put(url, data, header = nil)
+ start(url.hostname, url.port,
+ :use_ssl => url.scheme == 'https' ) {|http|
+ http.put(url, data, header)
+ }
+ end
+
+ #
+ # \HTTP session management
+ #
+
+ # Returns integer +80+, the default port to use for \HTTP requests:
+ #
+ # Gem::Net::HTTP.default_port # => 80
+ #
+ def HTTP.default_port
+ http_default_port()
+ end
+
+ # Returns integer +80+, the default port to use for \HTTP requests:
+ #
+ # Gem::Net::HTTP.http_default_port # => 80
+ #
+ def HTTP.http_default_port
+ 80
+ end
+
+ # Returns integer +443+, the default port to use for HTTPS requests:
+ #
+ # Gem::Net::HTTP.https_default_port # => 443
+ #
+ def HTTP.https_default_port
+ 443
+ end
+
+ def HTTP.socket_type #:nodoc: obsolete
+ BufferedIO
+ end
+
+ # :call-seq:
+ # HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http
+ # HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object
+ #
+ # Creates a new \Gem::Net::HTTP object, +http+, via \Gem::Net::HTTP.new:
+ #
+ # - For arguments +address+ and +port+, see Gem::Net::HTTP.new.
+ # - For proxy-defining arguments +p_addr+ through +p_pass+,
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ # - For argument +opts+, see below.
+ #
+ # With no block given:
+ #
+ # - Calls <tt>http.start</tt> with no block (see #start),
+ # which opens a TCP connection and \HTTP session.
+ # - Returns +http+.
+ # - The caller should call #finish to close the session:
+ #
+ # http = Gem::Net::HTTP.start(hostname)
+ # http.started? # => true
+ # http.finish
+ # http.started? # => false
+ #
+ # With a block given:
+ #
+ # - Calls <tt>http.start</tt> with the block (see #start), which:
+ #
+ # - Opens a TCP connection and \HTTP session.
+ # - Calls the block,
+ # which may make any number of requests to the host.
+ # - Closes the \HTTP session and TCP connection on block exit.
+ # - Returns the block's value +object+.
+ #
+ # - Returns +object+.
+ #
+ # Example:
+ #
+ # hostname = 'jsonplaceholder.typicode.com'
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # puts http.get('/todos/1').body
+ # puts http.get('/todos/2').body
+ # end
+ #
+ # Output:
+ #
+ # {
+ # "userId": 1,
+ # "id": 1,
+ # "title": "delectus aut autem",
+ # "completed": false
+ # }
+ # {
+ # "userId": 1,
+ # "id": 2,
+ # "title": "quis ut nam facilis et officia qui",
+ # "completed": false
+ # }
+ #
+ # If the last argument given is a hash, it is the +opts+ hash,
+ # where each key is a method or accessor to be called,
+ # and its value is the value to be set.
+ #
+ # The keys may include:
+ #
+ # - #ca_file
+ # - #ca_path
+ # - #cert
+ # - #cert_store
+ # - #ciphers
+ # - #close_on_empty_response
+ # - +ipaddr+ (calls #ipaddr=)
+ # - #keep_alive_timeout
+ # - #key
+ # - #open_timeout
+ # - #read_timeout
+ # - #ssl_timeout
+ # - #ssl_version
+ # - +use_ssl+ (calls #use_ssl=)
+ # - #verify_callback
+ # - #verify_depth
+ # - #verify_mode
+ # - #write_timeout
+ #
+ # Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value,
+ # the value passed to +new+ is Gem::Net::HTTP.https_default_port, not +port+.
+ #
+ def HTTP.start(address, *arg, &block) # :yield: +http+
+ arg.pop if opt = Hash.try_convert(arg[-1])
+ port, p_addr, p_port, p_user, p_pass = *arg
+ p_addr = :ENV if arg.size < 2
+ port = https_default_port if !port && opt && opt[:use_ssl]
+ http = new(address, port, p_addr, p_port, p_user, p_pass)
+ http.ipaddr = opt[:ipaddr] if opt && opt[:ipaddr]
+
+ if opt
+ if opt[:use_ssl]
+ opt = {verify_mode: OpenSSL::SSL::VERIFY_PEER}.update(opt)
+ end
+ http.methods.grep(/\A(\w+)=\z/) do |meth|
+ key = $1.to_sym
+ opt.key?(key) or next
+ http.__send__(meth, opt[key])
+ end
+ end
+
+ http.start(&block)
+ end
+
+ class << HTTP
+ alias newobj new # :nodoc:
+ end
+
+ # Returns a new \Gem::Net::HTTP object +http+
+ # (but does not open a TCP connection or \HTTP session).
+ #
+ # With only string argument +address+ given
+ # (and <tt>ENV['http_proxy']</tt> undefined or +nil+),
+ # the returned +http+:
+ #
+ # - Has the given address.
+ # - Has the default port number, Gem::Net::HTTP.default_port (80).
+ # - Has no proxy.
+ #
+ # Example:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.address # => "jsonplaceholder.typicode.com"
+ # http.port # => 80
+ # http.proxy? # => false
+ #
+ # With integer argument +port+ also given,
+ # the returned +http+ has the given port:
+ #
+ # http = Gem::Net::HTTP.new(hostname, 8000)
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:8000 open=false>
+ # http.port # => 8000
+ #
+ # For proxy-defining arguments +p_addr+ through +p_no_proxy+,
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ #
+ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil, p_use_ssl = nil)
+ http = super address, port
+
+ if proxy_class? then # from Gem::Net::HTTP::Proxy()
+ http.proxy_from_env = @proxy_from_env
+ http.proxy_address = @proxy_address
+ http.proxy_port = @proxy_port
+ http.proxy_user = @proxy_user
+ http.proxy_pass = @proxy_pass
+ http.proxy_use_ssl = @proxy_use_ssl
+ elsif p_addr == :ENV then
+ http.proxy_from_env = true
+ else
+ if p_addr && p_no_proxy && !Gem::URI::Generic.use_proxy?(address, address, port, p_no_proxy)
+ p_addr = nil
+ p_port = nil
+ end
+ http.proxy_address = p_addr
+ http.proxy_port = p_port || default_port
+ http.proxy_user = p_user
+ http.proxy_pass = p_pass
+ http.proxy_use_ssl = p_use_ssl
+ end
+
+ http
+ end
+
+ class << HTTP
+ # Allows to set the default configuration that will be used
+ # when creating a new connection.
+ #
+ # Example:
+ #
+ # Gem::Net::HTTP.default_configuration = {
+ # read_timeout: 1,
+ # write_timeout: 1
+ # }
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.open_timeout # => 60
+ # http.read_timeout # => 1
+ # http.write_timeout # => 1
+ #
+ attr_accessor :default_configuration
+ end
+
+ # Creates a new \Gem::Net::HTTP object for the specified server address,
+ # without opening the TCP connection or initializing the \HTTP session.
+ # The +address+ should be a DNS hostname or IP address.
+ def initialize(address, port = nil) # :nodoc:
+ defaults = {
+ keep_alive_timeout: 2,
+ close_on_empty_response: false,
+ open_timeout: 60,
+ read_timeout: 60,
+ write_timeout: 60,
+ continue_timeout: nil,
+ max_retries: 1,
+ debug_output: nil,
+ response_body_encoding: false,
+ ignore_eof: true
+ }
+ options = defaults.merge(self.class.default_configuration || {})
+
+ @address = address
+ @port = (port || HTTP.default_port)
+ @ipaddr = nil
+ @local_host = nil
+ @local_port = nil
+ @curr_http_version = HTTPVersion
+ @keep_alive_timeout = options[:keep_alive_timeout]
+ @last_communicated = nil
+ @close_on_empty_response = options[:close_on_empty_response]
+ @socket = nil
+ @started = false
+ @open_timeout = options[:open_timeout]
+ @read_timeout = options[:read_timeout]
+ @write_timeout = options[:write_timeout]
+ @continue_timeout = options[:continue_timeout]
+ @max_retries = options[:max_retries]
+ @debug_output = options[:debug_output]
+ @response_body_encoding = options[:response_body_encoding]
+ @ignore_eof = options[:ignore_eof]
+ @tcpsocket_supports_open_timeout = nil
+
+ @proxy_from_env = false
+ @proxy_uri = nil
+ @proxy_address = nil
+ @proxy_port = nil
+ @proxy_user = nil
+ @proxy_pass = nil
+ @proxy_use_ssl = nil
+
+ @use_ssl = false
+ @ssl_context = nil
+ @ssl_session = nil
+ @sspi_enabled = false
+ SSL_IVNAMES.each do |ivname|
+ instance_variable_set ivname, nil
+ end
+ end
+
+ # Returns a string representation of +self+:
+ #
+ # Gem::Net::HTTP.new(hostname).inspect
+ # # => "#<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=false>"
+ #
+ def inspect
+ "#<#{self.class} #{@address}:#{@port} open=#{started?}>"
+ end
+
+ # *WARNING* This method opens a serious security hole.
+ # Never use this method in production code.
+ #
+ # Sets the output stream for debugging:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # File.open('t.tmp', 'w') do |file|
+ # http.set_debug_output(file)
+ # http.start
+ # http.get('/nosuch/1')
+ # http.finish
+ # end
+ # puts File.read('t.tmp')
+ #
+ # Output:
+ #
+ # opening connection to jsonplaceholder.typicode.com:80...
+ # opened
+ # <- "GET /nosuch/1 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: jsonplaceholder.typicode.com\r\n\r\n"
+ # -> "HTTP/1.1 404 Not Found\r\n"
+ # -> "Date: Mon, 12 Dec 2022 21:14:11 GMT\r\n"
+ # -> "Content-Type: application/json; charset=utf-8\r\n"
+ # -> "Content-Length: 2\r\n"
+ # -> "Connection: keep-alive\r\n"
+ # -> "X-Powered-By: Express\r\n"
+ # -> "X-Ratelimit-Limit: 1000\r\n"
+ # -> "X-Ratelimit-Remaining: 999\r\n"
+ # -> "X-Ratelimit-Reset: 1670879660\r\n"
+ # -> "Vary: Origin, Accept-Encoding\r\n"
+ # -> "Access-Control-Allow-Credentials: true\r\n"
+ # -> "Cache-Control: max-age=43200\r\n"
+ # -> "Pragma: no-cache\r\n"
+ # -> "Expires: -1\r\n"
+ # -> "X-Content-Type-Options: nosniff\r\n"
+ # -> "Etag: W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\"\r\n"
+ # -> "Via: 1.1 vegur\r\n"
+ # -> "CF-Cache-Status: MISS\r\n"
+ # -> "Server-Timing: cf-q-config;dur=1.3000000762986e-05\r\n"
+ # -> "Report-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=yOr40jo%2BwS1KHzhTlVpl54beJ5Wx2FcG4gGV0XVrh3X9OlR5q4drUn2dkt5DGO4GDcE%2BVXT7CNgJvGs%2BZleIyMu8CLieFiDIvOviOY3EhHg94m0ZNZgrEdpKD0S85S507l1vsEwEHkoTm%2Ff19SiO\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\n"
+ # -> "NEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\n"
+ # -> "Server: cloudflare\r\n"
+ # -> "CF-RAY: 778977dc484ce591-DFW\r\n"
+ # -> "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n"
+ # -> "\r\n"
+ # reading 2 bytes...
+ # -> "{}"
+ # read 2 bytes
+ # Conn keep-alive
+ #
+ def set_debug_output(output)
+ warn 'Gem::Net::HTTP#set_debug_output called after HTTP started', uplevel: 1 if started?
+ @debug_output = output
+ end
+
+ # Returns the string host name or host IP given as argument +address+ in ::new.
+ attr_reader :address
+
+ # Returns the integer port number given as argument +port+ in ::new.
+ attr_reader :port
+
+ # Sets or returns the string local host used to establish the connection;
+ # initially +nil+.
+ attr_accessor :local_host
+
+ # Sets or returns the integer local port used to establish the connection;
+ # initially +nil+.
+ attr_accessor :local_port
+
+ # Returns the encoding to use for the response body;
+ # see #response_body_encoding=.
+ attr_reader :response_body_encoding
+
+ # Sets the encoding to be used for the response body;
+ # returns the encoding.
+ #
+ # The given +value+ may be:
+ #
+ # - An Encoding object.
+ # - The name of an encoding.
+ # - An alias for an encoding name.
+ #
+ # See {Encoding}[https://docs.ruby-lang.org/en/master/Encoding.html].
+ #
+ # Examples:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.response_body_encoding = Encoding::US_ASCII # => #<Encoding:US-ASCII>
+ # http.response_body_encoding = 'US-ASCII' # => "US-ASCII"
+ # http.response_body_encoding = 'ASCII' # => "ASCII"
+ #
+ def response_body_encoding=(value)
+ value = Encoding.find(value) if value.is_a?(String)
+ @response_body_encoding = value
+ end
+
+ # Sets whether to determine the proxy from environment variable
+ # '<tt>ENV['http_proxy']</tt>';
+ # see {Proxy Using ENV['http_proxy']}[rdoc-ref:Gem::Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D-27].
+ attr_writer :proxy_from_env
+
+ # Sets the proxy address;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ attr_writer :proxy_address
+
+ # Sets the proxy port;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ attr_writer :proxy_port
+
+ # Sets the proxy user;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ attr_writer :proxy_user
+
+ # Sets the proxy password;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ attr_writer :proxy_pass
+
+ # Sets whether the proxy uses SSL;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ attr_writer :proxy_use_ssl
+
+ # Returns the IP address for the connection.
+ #
+ # If the session has not been started,
+ # returns the value set by #ipaddr=,
+ # or +nil+ if it has not been set:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.ipaddr # => nil
+ # http.ipaddr = '172.67.155.76'
+ # http.ipaddr # => "172.67.155.76"
+ #
+ # If the session has been started,
+ # returns the IP address from the socket:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.start
+ # http.ipaddr # => "172.67.155.76"
+ # http.finish
+ #
+ def ipaddr
+ started? ? @socket.io.peeraddr[3] : @ipaddr
+ end
+
+ # Sets the IP address for the connection:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.ipaddr # => nil
+ # http.ipaddr = '172.67.155.76'
+ # http.ipaddr # => "172.67.155.76"
+ #
+ # The IP address may not be set if the session has been started.
+ def ipaddr=(addr)
+ raise IOError, "ipaddr value changed, but session already started" if started?
+ @ipaddr = addr
+ end
+
+ # Sets or returns the numeric (\Integer or \Float) number of seconds
+ # to wait for a connection to open;
+ # initially 60.
+ # If the connection is not made in the given interval,
+ # an exception is raised.
+ attr_accessor :open_timeout
+
+ # Returns the numeric (\Integer or \Float) number of seconds
+ # to wait for one block to be read (via one read(2) call);
+ # see #read_timeout=.
+ attr_reader :read_timeout
+
+ # Returns the numeric (\Integer or \Float) number of seconds
+ # to wait for one block to be written (via one write(2) call);
+ # see #write_timeout=.
+ attr_reader :write_timeout
+
+ # Sets the maximum number of times to retry an idempotent request in case of
+ # \Gem::Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET,
+ # Errno::ECONNABORTED, Errno::EPIPE, OpenSSL::SSL::SSLError,
+ # Gem::Timeout::Error.
+ # The initial value is 1.
+ #
+ # Argument +retries+ must be a non-negative numeric value:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.max_retries = 2 # => 2
+ # http.max_retries # => 2
+ #
+ def max_retries=(retries)
+ retries = retries.to_int
+ if retries < 0
+ raise ArgumentError, 'max_retries should be non-negative integer number'
+ end
+ @max_retries = retries
+ end
+
+ # Returns the maximum number of times to retry an idempotent request;
+ # see #max_retries=.
+ attr_reader :max_retries
+
+ # Sets the read timeout, in seconds, for +self+ to integer +sec+;
+ # the initial value is 60.
+ #
+ # Argument +sec+ must be a non-negative numeric value:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.read_timeout # => 60
+ # http.get('/todos/1') # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ # http.read_timeout = 0
+ # http.get('/todos/1') # Raises Gem::Net::ReadTimeout.
+ #
+ def read_timeout=(sec)
+ @socket.read_timeout = sec if @socket
+ @read_timeout = sec
+ end
+
+ # Sets the write timeout, in seconds, for +self+ to integer +sec+;
+ # the initial value is 60.
+ #
+ # Argument +sec+ must be a non-negative numeric value:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # body = 'bar' * 200000
+ # data = <<EOF
+ # {"title": "foo", "body": "#{body}", "userId": "1"}
+ # EOF
+ # headers = {'content-type': 'application/json'}
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.write_timeout # => 60
+ # http.post(_uri.path, data, headers)
+ # # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ # http.write_timeout = 0
+ # http.post(_uri.path, data, headers) # Raises Gem::Net::WriteTimeout.
+ #
+ def write_timeout=(sec)
+ @socket.write_timeout = sec if @socket
+ @write_timeout = sec
+ end
+
+ # Returns the continue timeout value;
+ # see continue_timeout=.
+ attr_reader :continue_timeout
+
+ # Sets the continue timeout value,
+ # which is the number of seconds to wait for an expected 100 Continue response.
+ # If the \HTTP object does not receive a response in this many seconds
+ # it sends the request body.
+ def continue_timeout=(sec)
+ @socket.continue_timeout = sec if @socket
+ @continue_timeout = sec
+ end
+
+ # Sets or returns the numeric (\Integer or \Float) number of seconds
+ # to keep the connection open after a request is sent;
+ # initially 2.
+ # If a new request is made during the given interval,
+ # the still-open connection is used;
+ # otherwise the connection will have been closed
+ # and a new connection is opened.
+ attr_accessor :keep_alive_timeout
+
+ # Sets or returns whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers;
+ # initially +true+.
+ attr_accessor :ignore_eof
+
+ # Returns +true+ if the \HTTP session has been started:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.started? # => false
+ # http.start
+ # http.started? # => true
+ # http.finish # => nil
+ # http.started? # => false
+ #
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # http.started?
+ # end # => true
+ # http.started? # => false
+ #
+ def started?
+ @started
+ end
+
+ alias active? started? #:nodoc: obsolete
+
+ # Sets or returns whether to close the connection when the response is empty;
+ # initially +false+.
+ attr_accessor :close_on_empty_response
+
+ # Returns +true+ if +self+ uses SSL, +false+ otherwise.
+ # See Gem::Net::HTTP#use_ssl=.
+ def use_ssl?
+ @use_ssl
+ end
+
+ # Sets whether a new session is to use
+ # {Transport Layer Security}[https://en.wikipedia.org/wiki/Transport_Layer_Security]:
+ #
+ # Raises IOError if attempting to change during a session.
+ #
+ # Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port.
+ def use_ssl=(flag)
+ flag = flag ? true : false
+ if started? and @use_ssl != flag
+ raise IOError, "use_ssl value changed, but session already started"
+ end
+ @use_ssl = flag
+ end
+
+ SSL_ATTRIBUTES = [
+ :ca_file,
+ :ca_path,
+ :cert,
+ :cert_store,
+ :ciphers,
+ :extra_chain_cert,
+ :key,
+ :ssl_timeout,
+ :ssl_version,
+ :min_version,
+ :max_version,
+ :verify_callback,
+ :verify_depth,
+ :verify_mode,
+ :verify_hostname,
+ ].freeze # :nodoc:
+
+ SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:
+
+ # Sets or returns the path to a CA certification file in PEM format.
+ attr_accessor :ca_file
+
+ # Sets or returns the path of to CA directory
+ # containing certification files in PEM format.
+ attr_accessor :ca_path
+
+ # Sets or returns the OpenSSL::X509::Certificate object
+ # to be used for client certification.
+ attr_accessor :cert
+
+ # Sets or returns the X509::Store to be used for verifying peer certificate.
+ attr_accessor :cert_store
+
+ # Sets or returns the available SSL ciphers.
+ # See {OpenSSL::SSL::SSLContext#ciphers=}[OpenSSL::SSL::SSL::Context#ciphers=].
+ attr_accessor :ciphers
+
+ # Sets or returns the extra X509 certificates to be added to the certificate chain.
+ # See {OpenSSL::SSL::SSLContext#add_certificate}[OpenSSL::SSL::SSL::Context#add_certificate].
+ attr_accessor :extra_chain_cert
+
+ # Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ attr_accessor :key
+
+ # Sets or returns the SSL timeout seconds.
+ attr_accessor :ssl_timeout
+
+ # Sets or returns the SSL version.
+ # See {OpenSSL::SSL::SSLContext#ssl_version=}[OpenSSL::SSL::SSL::Context#ssl_version=].
+ attr_accessor :ssl_version
+
+ # Sets or returns the minimum SSL version.
+ # See {OpenSSL::SSL::SSLContext#min_version=}[OpenSSL::SSL::SSL::Context#min_version=].
+ attr_accessor :min_version
+
+ # Sets or returns the maximum SSL version.
+ # See {OpenSSL::SSL::SSLContext#max_version=}[OpenSSL::SSL::SSL::Context#max_version=].
+ attr_accessor :max_version
+
+ # Sets or returns the callback for the server certification verification.
+ attr_accessor :verify_callback
+
+ # Sets or returns the maximum depth for the certificate chain verification.
+ attr_accessor :verify_depth
+
+ # Sets or returns the flags for server the certification verification
+ # at the beginning of the SSL/TLS session.
+ # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
+ attr_accessor :verify_mode
+
+ # Sets or returns whether to verify that the server certificate is valid
+ # for the hostname.
+ # See {OpenSSL::SSL::SSLContext#verify_hostname=}[OpenSSL::SSL::SSL::Context#verify_hostname=].
+ attr_accessor :verify_hostname
+
+ # Returns the X509 certificate chain (an array of strings)
+ # for the session's socket peer,
+ # or +nil+ if none.
+ def peer_cert
+ if not use_ssl? or not @socket
+ return nil
+ end
+ @socket.io.peer_cert
+ end
+
+ # Starts an \HTTP session.
+ #
+ # Without a block, returns +self+:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.start
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=true>
+ # http.started? # => true
+ # http.finish
+ #
+ # With a block, calls the block with +self+,
+ # finishes the session when the block exits,
+ # and returns the block's value:
+ #
+ # http.start do |http|
+ # http
+ # end
+ # # => #<Gem::Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.started? # => false
+ #
+ def start # :yield: http
+ raise IOError, 'HTTP session already opened' if @started
+ if block_given?
+ begin
+ do_start
+ return yield(self)
+ ensure
+ do_finish
+ end
+ end
+ do_start
+ self
+ end
+
+ # Finishes the \HTTP session:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.start
+ # http.started? # => true
+ # http.finish # => nil
+ # http.started? # => false
+ #
+ # Raises IOError if not in a session.
+ def finish
+ raise IOError, 'HTTP session not yet started' unless started?
+ do_finish
+ end
+
+ # :stopdoc:
+ def do_start
+ connect
+ @started = true
+ end
+ private :do_start
+
+ def connect
+ if use_ssl?
+ # reference early to load OpenSSL before connecting,
+ # as OpenSSL may take time to load.
+ @ssl_context = OpenSSL::SSL::SSLContext.new
+ end
+
+ if proxy? then
+ conn_addr = proxy_address
+ conn_port = proxy_port
+ else
+ conn_addr = conn_address
+ conn_port = port
+ end
+
+ debug "opening connection to #{conn_addr}:#{conn_port}..."
+ begin
+ s = timeouted_connect(conn_addr, conn_port)
+ rescue => e
+ if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
+ e = Gem::Net::OpenTimeout.new(e)
+ end
+ raise e, "Failed to open TCP connection to " +
+ "#{conn_addr}:#{conn_port} (#{e.message})"
+ end
+ s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
+ debug "opened"
+ if use_ssl?
+ if proxy?
+ if @proxy_use_ssl
+ proxy_sock = OpenSSL::SSL::SSLSocket.new(s)
+ ssl_socket_connect(proxy_sock, @open_timeout)
+ else
+ proxy_sock = s
+ end
+ proxy_sock = BufferedIO.new(proxy_sock, read_timeout: @read_timeout,
+ write_timeout: @write_timeout,
+ continue_timeout: @continue_timeout,
+ debug_output: @debug_output)
+ buf = +"CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n" \
+ "Host: #{@address}:#{@port}\r\n"
+ if proxy_user
+ credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
+ buf << "Proxy-Authorization: Basic #{credential}\r\n"
+ end
+ buf << "\r\n"
+ proxy_sock.write(buf)
+ HTTPResponse.read_new(proxy_sock).value
+ # assuming nothing left in buffers after successful CONNECT response
+ end
+
+ ssl_parameters = Hash.new
+ iv_list = instance_variables
+ SSL_IVNAMES.each_with_index do |ivname, i|
+ if iv_list.include?(ivname)
+ value = instance_variable_get(ivname)
+ unless value.nil?
+ ssl_parameters[SSL_ATTRIBUTES[i]] = value
+ end
+ end
+ end
+ @ssl_context.set_params(ssl_parameters)
+ unless @ssl_context.session_cache_mode.nil? # a dummy method on JRuby
+ @ssl_context.session_cache_mode =
+ OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
+ OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
+ end
+ if @ssl_context.respond_to?(:session_new_cb) # not implemented under JRuby
+ @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
+ end
+
+ # Still do the post_connection_check below even if connecting
+ # to IP address
+ verify_hostname = @ssl_context.verify_hostname
+
+ # Server Name Indication (SNI) RFC 3546/6066
+ case @address
+ when Gem::Resolv::IPv4::Regex, Gem::Resolv::IPv6::Regex
+ # don't set SNI, as IP addresses in SNI is not valid
+ # per RFC 6066, section 3.
+
+ # Avoid openssl warning
+ @ssl_context.verify_hostname = false
+ else
+ ssl_host_address = @address
+ end
+
+ debug "starting SSL for #{conn_addr}:#{conn_port}..."
+ s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
+ s.sync_close = true
+ s.hostname = ssl_host_address if s.respond_to?(:hostname=) && ssl_host_address
+
+ if @ssl_session and
+ Process.clock_gettime(Process::CLOCK_REALTIME) < @ssl_session.time.to_f + @ssl_session.timeout
+ s.session = @ssl_session
+ end
+ ssl_socket_connect(s, @open_timeout)
+ if (@ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && verify_hostname
+ s.post_connection_check(@address)
+ end
+ debug "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}"
+ end
+ @socket = BufferedIO.new(s, read_timeout: @read_timeout,
+ write_timeout: @write_timeout,
+ continue_timeout: @continue_timeout,
+ debug_output: @debug_output)
+ @last_communicated = nil
+ on_connect
+ rescue => exception
+ if s
+ debug "Conn close because of connect error #{exception}"
+ s.close
+ end
+ raise
+ end
+ private :connect
+
+ tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
+ TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
+ tcp_socket_parameters.include?([:key, :open_timeout])
+ else
+ # Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
+ # See discussion in https://github.com/ruby/net-http/pull/224
+ Socket.method(:tcp).parameters.include?([:key, :open_timeout])
+ end
+ private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
+
+ def timeouted_connect(conn_addr, conn_port)
+ if TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
+ TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
+ else
+ Gem::Timeout.timeout(@open_timeout, Gem::Net::OpenTimeout) {
+ TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
+ }
+ end
+ end
+ private :timeouted_connect
+
+ def on_connect
+ end
+ private :on_connect
+
+ def do_finish
+ @started = false
+ @socket.close if @socket
+ @socket = nil
+ end
+ private :do_finish
+
+ #
+ # proxy
+ #
+
+ public
+
+ # no proxy
+ @is_proxy_class = false
+ @proxy_from_env = false
+ @proxy_addr = nil
+ @proxy_port = nil
+ @proxy_user = nil
+ @proxy_pass = nil
+ @proxy_use_ssl = nil
+
+ # Creates an \HTTP proxy class which behaves like \Gem::Net::HTTP, but
+ # performs all access via the specified proxy.
+ #
+ # This class is obsolete. You may pass these same parameters directly to
+ # \Gem::Net::HTTP.new. See Gem::Net::HTTP.new for details of the arguments.
+ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ssl = nil) #:nodoc:
+ return self unless p_addr
+
+ Class.new(self) {
+ @is_proxy_class = true
+
+ if p_addr == :ENV then
+ @proxy_from_env = true
+ @proxy_address = nil
+ @proxy_port = nil
+ else
+ @proxy_from_env = false
+ @proxy_address = p_addr
+ @proxy_port = p_port || default_port
+ end
+
+ @proxy_user = p_user
+ @proxy_pass = p_pass
+ @proxy_use_ssl = p_use_ssl
+ }
+ end
+
+ # :startdoc:
+
+ class << HTTP
+ # Returns true if self is a class which was created by HTTP::Proxy.
+ def proxy_class?
+ defined?(@is_proxy_class) ? @is_proxy_class : false
+ end
+
+ # Returns the address of the proxy host, or +nil+ if none;
+ # see Gem::Net::HTTP@Proxy+Server.
+ attr_reader :proxy_address
+
+ # Returns the port number of the proxy host, or +nil+ if none;
+ # see Gem::Net::HTTP@Proxy+Server.
+ attr_reader :proxy_port
+
+ # Returns the user name for accessing the proxy, or +nil+ if none;
+ # see Gem::Net::HTTP@Proxy+Server.
+ attr_reader :proxy_user
+
+ # Returns the password for accessing the proxy, or +nil+ if none;
+ # see Gem::Net::HTTP@Proxy+Server.
+ attr_reader :proxy_pass
+
+ # Use SSL when talking to the proxy. If Gem::Net::HTTP does not use a proxy, nil.
+ attr_reader :proxy_use_ssl
+ end
+
+ # Returns +true+ if a proxy server is defined, +false+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy?
+ !!(@proxy_from_env ? proxy_uri : @proxy_address)
+ end
+
+ # Returns +true+ if the proxy server is defined in the environment,
+ # +false+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy_from_env?
+ @proxy_from_env
+ end
+
+ # The proxy Gem::URI determined from the environment for this connection.
+ def proxy_uri # :nodoc:
+ return if @proxy_uri == false
+ @proxy_uri ||= Gem::URI::HTTP.new(
+ "http", nil, address, port, nil, nil, nil, nil, nil
+ ).find_proxy || false
+ @proxy_uri || nil
+ end
+
+ # Returns the address of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy_address
+ if @proxy_from_env then
+ proxy_uri&.hostname
+ else
+ @proxy_address
+ end
+ end
+
+ # Returns the port number of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy_port
+ if @proxy_from_env then
+ proxy_uri&.port
+ else
+ @proxy_port
+ end
+ end
+
+ # Returns the user name of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy_user
+ if @proxy_from_env
+ user = proxy_uri&.user
+ unescape(user) if user
+ else
+ @proxy_user
+ end
+ end
+
+ # Returns the password of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
+ def proxy_pass
+ if @proxy_from_env
+ pass = proxy_uri&.password
+ unescape(pass) if pass
+ else
+ @proxy_pass
+ end
+ end
+
+ alias proxyaddr proxy_address #:nodoc: obsolete
+ alias proxyport proxy_port #:nodoc: obsolete
+
+ private
+ # :stopdoc:
+
+ def unescape(value)
+ require 'cgi/escape'
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
+ CGI.unescape(value)
+ end
+
+ # without proxy, obsolete
+
+ def conn_address # :nodoc:
+ @ipaddr || address()
+ end
+
+ def conn_port # :nodoc:
+ port()
+ end
+
+ def edit_path(path)
+ if proxy?
+ if path.start_with?("ftp://") || use_ssl?
+ path
+ else
+ "http://#{addr_port}#{path}"
+ end
+ else
+ path
+ end
+ end
+ # :startdoc:
+
+ #
+ # HTTP operations
+ #
+
+ public
+
+ # :call-seq:
+ # get(path, initheader = nil) {|res| ... }
+ #
+ # Sends a GET request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Get object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # With a block given, calls the block with the response body:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.get('/todos/1') do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
+ #
+ # With no block given, simply returns the response object:
+ #
+ # http.get('/') # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Get: request class for \HTTP method GET.
+ # - Gem::Net::HTTP.get: sends GET request, returns response body.
+ #
+ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
+ res = nil
+
+ request(Get.new(path, initheader)) {|r|
+ r.read_body dest, &block
+ res = r
+ }
+ res
+ end
+
+ # Sends a HEAD request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Head object
+ # created from string +path+ and initial headers hash +initheader+:
+ #
+ # res = http.head('/todos/1') # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ # res.body # => nil
+ # res.to_hash.take(3)
+ # # =>
+ # [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]],
+ # ["content-type", ["application/json; charset=utf-8"]],
+ # ["connection", ["close"]]]
+ #
+ def head(path, initheader = nil)
+ request(Head.new(path, initheader))
+ end
+
+ # :call-seq:
+ # post(path, data, initheader = nil) {|res| ... }
+ #
+ # Sends a POST request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Post object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # With a block given, calls the block with the response body:
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.post('/todos', data) do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ # Output:
+ #
+ # "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}"
+ #
+ # With no block given, simply returns the response object:
+ #
+ # http.post('/todos', data) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Post: request class for \HTTP method POST.
+ # - Gem::Net::HTTP.post: sends POST request, returns response body.
+ #
+ def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
+ send_entity(path, data, initheader, dest, Post, &block)
+ end
+
+ # :call-seq:
+ # patch(path, data, initheader = nil) {|res| ... }
+ #
+ # Sends a PATCH request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Patch object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # With a block given, calls the block with the response body:
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.patch('/todos/1', data) do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}"
+ #
+ # With no block given, simply returns the response object:
+ #
+ # http.patch('/todos/1', data) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
+ send_entity(path, data, initheader, dest, Patch, &block)
+ end
+
+ # Sends a PUT request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Put object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.put('/todos/1', data) # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Related:
+ #
+ # - Gem::Net::HTTP::Put: request class for \HTTP method PUT.
+ # - Gem::Net::HTTP.put: sends PUT request, returns response body.
+ #
+ def put(path, data, initheader = nil)
+ request(Put.new(path, initheader), data)
+ end
+
+ # Sends a PROPPATCH request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Proppatch object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.proppatch('/todos/1', data)
+ #
+ def proppatch(path, body, initheader = nil)
+ request(Proppatch.new(path, initheader), body)
+ end
+
+ # Sends a LOCK request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Lock object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.lock('/todos/1', data)
+ #
+ def lock(path, body, initheader = nil)
+ request(Lock.new(path, initheader), body)
+ end
+
+ # Sends an UNLOCK request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Unlock object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.unlock('/todos/1', data)
+ #
+ def unlock(path, body, initheader = nil)
+ request(Unlock.new(path, initheader), body)
+ end
+
+ # Sends an Options request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Options object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.options('/')
+ #
+ def options(path, initheader = nil)
+ request(Options.new(path, initheader))
+ end
+
+ # Sends a PROPFIND request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Propfind object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.propfind('/todos/1', data)
+ #
+ def propfind(path, body = nil, initheader = {'Depth' => '0'})
+ request(Propfind.new(path, initheader), body)
+ end
+
+ # Sends a DELETE request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Delete object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.delete('/todos/1')
+ #
+ def delete(path, initheader = {'Depth' => 'Infinity'})
+ request(Delete.new(path, initheader))
+ end
+
+ # Sends a MOVE request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Move object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.move('/todos/1')
+ #
+ def move(path, initheader = nil)
+ request(Move.new(path, initheader))
+ end
+
+ # Sends a COPY request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Copy object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.copy('/todos/1')
+ #
+ def copy(path, initheader = nil)
+ request(Copy.new(path, initheader))
+ end
+
+ # Sends a MKCOL request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Mkcol object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http.mkcol('/todos/1', data)
+ # http = Gem::Net::HTTP.new(hostname)
+ #
+ def mkcol(path, body = nil, initheader = nil)
+ request(Mkcol.new(path, initheader), body)
+ end
+
+ # Sends a TRACE request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Trace object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.trace('/todos/1')
+ #
+ def trace(path, initheader = nil)
+ request(Trace.new(path, initheader))
+ end
+
+ # Sends a GET request to the server;
+ # forms the response into a Gem::Net::HTTPResponse object.
+ #
+ # The request is based on the Gem::Net::HTTP::Get object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # With no block given, returns the response object:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.request_get('/todos') # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # With a block given, calls the block with the response object
+ # and returns the response object:
+ #
+ # http.request_get('/todos') do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # #<Gem::Net::HTTPOK 200 OK readbody=false>
+ #
+ def request_get(path, initheader = nil, &block) # :yield: +response+
+ request(Get.new(path, initheader), &block)
+ end
+
+ # Sends a HEAD request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Head object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.head('/todos/1') # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ def request_head(path, initheader = nil, &block)
+ request(Head.new(path, initheader), &block)
+ end
+
+ # Sends a POST request to the server;
+ # forms the response into a Gem::Net::HTTPResponse object.
+ #
+ # The request is based on the Gem::Net::HTTP::Post object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # With no block given, returns the response object:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.post('/todos', 'xyzzy')
+ # # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ # With a block given, calls the block with the response body
+ # and returns the response object:
+ #
+ # http.post('/todos', 'xyzzy') do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ # Output:
+ #
+ # "{\n \"xyzzy\": \"\",\n \"id\": 201\n}"
+ #
+ def request_post(path, data, initheader = nil, &block) # :yield: +response+
+ request Post.new(path, initheader), data, &block
+ end
+
+ # Sends a PUT request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTP::Put object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.put('/todos/1', 'xyzzy')
+ # # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ def request_put(path, data, initheader = nil, &block) #:nodoc:
+ request Put.new(path, initheader), data, &block
+ end
+
+ alias get2 request_get #:nodoc: obsolete
+ alias head2 request_head #:nodoc: obsolete
+ alias post2 request_post #:nodoc: obsolete
+ alias put2 request_put #:nodoc: obsolete
+
+ # Sends an \HTTP request to the server;
+ # returns an instance of a subclass of Gem::Net::HTTPResponse.
+ #
+ # The request is based on the Gem::Net::HTTPRequest object
+ # created from string +path+, string +data+, and initial headers hash +header+.
+ # That object is an instance of the
+ # {subclass of Gem::Net::HTTPRequest}[rdoc-ref:Gem::Net::HTTPRequest@Request+Subclasses],
+ # that corresponds to the given uppercase string +name+,
+ # which must be
+ # an {HTTP request method}[https://en.wikipedia.org/wiki/HTTP#Request_methods]
+ # or a {WebDAV request method}[https://en.wikipedia.org/wiki/WebDAV#Implementation].
+ #
+ # Examples:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # http.send_request('GET', '/todos/1')
+ # # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ # http.send_request('POST', '/todos', 'xyzzy')
+ # # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ def send_request(name, path, data = nil, header = nil)
+ has_response_body = name != 'HEAD'
+ r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header)
+ request r, data
+ end
+
+ # Sends the given request +req+ to the server;
+ # forms the response into a Gem::Net::HTTPResponse object.
+ #
+ # The given +req+ must be an instance of a
+ # {subclass of Gem::Net::HTTPRequest}[rdoc-ref:Gem::Net::HTTPRequest@Request+Subclasses].
+ # Argument +body+ should be given only if needed for the request.
+ #
+ # With no block given, returns the response object:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ #
+ # req = Gem::Net::HTTP::Get.new('/todos/1')
+ # http.request(req)
+ # # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # req = Gem::Net::HTTP::Post.new('/todos')
+ # http.request(req, 'xyzzy')
+ # # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ # With a block given, calls the block with the response and returns the response:
+ #
+ # req = Gem::Net::HTTP::Get.new('/todos/1')
+ # http.request(req) do |res|
+ # p res
+ # end # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # #<Gem::Net::HTTPOK 200 OK readbody=false>
+ #
+ def request(req, body = nil, &block) # :yield: +response+
+ unless started?
+ start {
+ req['connection'] ||= 'close'
+ return request(req, body, &block)
+ }
+ end
+ if proxy_user()
+ req.proxy_basic_auth proxy_user(), proxy_pass() 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)
+ end
+ res
+ end
+
+ private
+
+ # Executes a request which uses a representation
+ # and returns its body.
+ def send_entity(path, data, initheader, dest, type, &block)
+ res = nil
+ request(type.new(path, initheader), data) {|r|
+ r.read_body dest, &block
+ res = r
+ }
+ res
+ end
+
+ # :stopdoc:
+
+ IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/.freeze # :nodoc:
+
+ def transport_request(req)
+ count = 0
+ begin
+ begin_transport req
+ res = catch(:response) {
+ begin
+ req.exec @socket, @curr_http_version, edit_path(req.path)
+ rescue Errno::EPIPE
+ # Failure when writing full request, but we can probably
+ # still read the received response.
+ end
+
+ begin
+ res = HTTPResponse.read_new(@socket)
+ res.decode_content = req.decode_content
+ res.body_encoding = @response_body_encoding
+ res.ignore_eof = @ignore_eof
+ end while res.kind_of?(HTTPInformation)
+
+ res.uri = req.uri
+
+ res
+ }
+ res.reading_body(@socket, req.response_body_permitted?) {
+ if block_given?
+ count = max_retries # Don't restart in the middle of a download
+ yield res
+ end
+ }
+ rescue Gem::Net::OpenTimeout
+ raise
+ rescue Gem::Net::ReadTimeout, IOError, EOFError,
+ Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, Errno::ETIMEDOUT,
+ # avoid a dependency on OpenSSL
+ defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
+ Gem::Timeout::Error => exception
+ if count < max_retries && IDEMPOTENT_METHODS_.include?(req.method)
+ count += 1
+ @socket.close if @socket
+ debug "Conn close because of error #{exception}, and retry"
+ retry
+ end
+ debug "Conn close because of error #{exception}"
+ @socket.close if @socket
+ raise
+ end
+
+ end_transport req, res
+ res
+ rescue => exception
+ debug "Conn close because of error #{exception}"
+ @socket.close if @socket
+ raise exception
+ end
+
+ def begin_transport(req)
+ if @socket.closed?
+ connect
+ elsif @last_communicated
+ if @last_communicated + @keep_alive_timeout < Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ debug 'Conn close because of keep_alive_timeout'
+ @socket.close
+ connect
+ elsif @socket.io.to_io.wait_readable(0) && @socket.eof?
+ debug "Conn close because of EOF"
+ @socket.close
+ connect
+ end
+ end
+
+ if not req.response_body_permitted? and @close_on_empty_response
+ req['connection'] ||= 'close'
+ end
+
+ req.update_uri address, port, use_ssl?
+ req['host'] ||= addr_port()
+ end
+
+ def end_transport(req, res)
+ @curr_http_version = res.http_version
+ @last_communicated = nil
+ if @socket.closed?
+ debug 'Conn socket closed'
+ elsif not res.body and @close_on_empty_response
+ debug 'Conn close'
+ @socket.close
+ elsif keep_alive?(req, res)
+ debug 'Conn keep-alive'
+ @last_communicated = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ else
+ debug 'Conn close'
+ @socket.close
+ end
+ 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)
+ end
+
+ #
+ # utils
+ #
+
+ private
+
+ def addr_port
+ addr = address
+ addr = "[#{addr}]" if addr.include?(":")
+ default_port = use_ssl? ? HTTP.https_default_port : HTTP.http_default_port
+ default_port == port ? addr : "#{addr}:#{port}"
+ end
+
+ # Adds a message to debugging output
+ def debug(msg)
+ return unless @debug_output
+ @debug_output << msg
+ @debug_output << "\n"
+ end
+
+ alias_method :D, :debug
+ end
+
+ # for backward compatibility until Ruby 4.0
+ # https://bugs.ruby-lang.org/issues/20900
+ # https://github.com/bblimke/webmock/pull/1081
+ HTTPSession = HTTP
+ deprecate_constant :HTTPSession
+end
+
+require_relative 'http/exceptions'
+
+require_relative 'http/header'
+
+require_relative 'http/generic_request'
+require_relative 'http/request'
+require_relative 'http/requests'
+
+require_relative 'http/response'
+require_relative 'http/responses'
+
+require_relative 'http/proxy_delta'
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb b/lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb
new file mode 100644
index 0000000000..218df9a8bd
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+module Gem::Net
+ # Gem::Net::HTTP exception class.
+ # You cannot use Gem::Net::HTTPExceptions directly; instead, you must use
+ # its subclasses.
+ module HTTPExceptions # :nodoc:
+ def initialize(msg, res) #:nodoc:
+ super msg
+ @response = res
+ end
+ attr_reader :response
+ alias data response #:nodoc: obsolete
+ end
+
+ # :stopdoc:
+ class HTTPError < ProtocolError
+ include HTTPExceptions
+ end
+
+ class HTTPRetriableError < ProtoRetriableError
+ include HTTPExceptions
+ end
+
+ class HTTPClientException < ProtoServerError
+ include HTTPExceptions
+ end
+
+ class HTTPFatalError < ProtoFatalError
+ include HTTPExceptions
+ end
+
+ # We cannot use the name "HTTPServerError", it is the name of the response.
+ HTTPServerException = HTTPClientException # :nodoc:
+ deprecate_constant(:HTTPServerException)
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb b/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb
new file mode 100644
index 0000000000..d6496d4ac1
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb
@@ -0,0 +1,429 @@
+# frozen_string_literal: true
+#
+# \HTTPGenericRequest is the parent of the Gem::Net::HTTPRequest class.
+#
+# Do not use this directly; instead, use a subclass of Gem::Net::HTTPRequest.
+#
+# == About the Examples
+#
+# :include: doc/net-http/examples.rdoc
+#
+class Gem::Net::HTTPGenericRequest
+
+ include Gem::Net::HTTPHeader
+
+ def initialize(m, reqbody, resbody, uri_or_path, initheader = nil) # :nodoc:
+ @method = m
+ @request_has_body = reqbody
+ @response_has_body = resbody
+
+ if Gem::URI === uri_or_path then
+ raise ArgumentError, "not an HTTP Gem::URI" unless Gem::URI::HTTP === uri_or_path
+ hostname = uri_or_path.host
+ raise ArgumentError, "no host component for Gem::URI" unless (hostname && hostname.length > 0)
+ @uri = uri_or_path.dup
+ @path = uri_or_path.request_uri
+ raise ArgumentError, "no HTTP request path given" unless @path
+ else
+ @uri = nil
+ raise ArgumentError, "no HTTP request path given" unless uri_or_path
+ raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
+ @path = uri_or_path.dup
+ end
+
+ @decode_content = false
+
+ if Gem::Net::HTTP::HAVE_ZLIB then
+ if !initheader ||
+ !initheader.keys.any? { |k|
+ %w[accept-encoding range].include? k.downcase
+ } then
+ @decode_content = true if @response_has_body
+ initheader = initheader ? initheader.dup : {}
+ initheader["accept-encoding"] =
+ "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
+ end
+ end
+
+ initialize_http_header initheader
+ self['Accept'] ||= '*/*'
+ self['User-Agent'] ||= 'Ruby'
+ self['Host'] ||= @uri.authority if @uri
+ @body = nil
+ @body_stream = nil
+ @body_data = nil
+ end
+
+ # Returns the string method name for the request:
+ #
+ # Gem::Net::HTTP::Get.new(uri).method # => "GET"
+ # Gem::Net::HTTP::Post.new(uri).method # => "POST"
+ #
+ attr_reader :method
+
+ # Returns the string path for the request:
+ #
+ # Gem::Net::HTTP::Get.new(uri).path # => "/"
+ # Gem::Net::HTTP::Post.new('example.com').path # => "example.com"
+ #
+ attr_reader :path
+
+ # Returns the Gem::URI object for the request, or +nil+ if none:
+ #
+ # Gem::Net::HTTP::Get.new(uri).uri
+ # # => #<Gem::URI::HTTPS https://jsonplaceholder.typicode.com/>
+ # Gem::Net::HTTP::Get.new('example.com').uri # => nil
+ #
+ attr_reader :uri
+
+ # Returns +false+ if the request's header <tt>'Accept-Encoding'</tt>
+ # has been set manually or deleted
+ # (indicating that the user intends to handle encoding in the response),
+ # +true+ otherwise:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri) # => #<Gem::Net::HTTP::Get GET>
+ # req['Accept-Encoding'] # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
+ # req.decode_content # => true
+ # req['Accept-Encoding'] = 'foo'
+ # req.decode_content # => false
+ # req.delete('Accept-Encoding')
+ # req.decode_content # => false
+ #
+ attr_reader :decode_content
+
+ # Returns a string representation of the request:
+ #
+ # Gem::Net::HTTP::Post.new(uri).inspect # => "#<Gem::Net::HTTP::Post POST>"
+ #
+ def inspect
+ "\#<#{self.class} #{@method}>"
+ end
+
+ # Returns a string representation of the request with the details for pp:
+ #
+ # require 'pp'
+ # post = Gem::Net::HTTP::Post.new(uri)
+ # post.inspect # => "#<Gem::Net::HTTP::Post POST>"
+ # post.pretty_inspect
+ # # => #<Gem::Net::HTTP::Post
+ # POST
+ # path="/"
+ # headers={"accept-encoding" => ["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
+ # "accept" => ["*/*"],
+ # "user-agent" => ["Ruby"],
+ # "host" => ["www.ruby-lang.org"]}>
+ #
+ def pretty_print(q)
+ q.object_group(self) {
+ q.breakable
+ q.text @method
+ q.breakable
+ q.text "path="; q.pp @path
+ q.breakable
+ q.text "headers="; q.pp to_hash
+ }
+ end
+
+ ##
+ # Don't automatically decode response content-encoding if the user indicates
+ # they want to handle it.
+
+ def []=(key, val) # :nodoc:
+ @decode_content = false if key.downcase == 'accept-encoding'
+
+ super key, val
+ end
+
+ # Returns whether the request may have a body:
+ #
+ # Gem::Net::HTTP::Post.new(uri).request_body_permitted? # => true
+ # Gem::Net::HTTP::Get.new(uri).request_body_permitted? # => false
+ #
+ def request_body_permitted?
+ @request_has_body
+ end
+
+ # Returns whether the response may have a body:
+ #
+ # Gem::Net::HTTP::Post.new(uri).response_body_permitted? # => true
+ # Gem::Net::HTTP::Head.new(uri).response_body_permitted? # => false
+ #
+ def response_body_permitted?
+ @response_has_body
+ end
+
+ def body_exist? # :nodoc:
+ warn "Gem::Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?", uplevel: 1 if $VERBOSE
+ response_body_permitted?
+ end
+
+ # Returns the string body for the request, or +nil+ if there is none:
+ #
+ # req = Gem::Net::HTTP::Post.new(uri)
+ # req.body # => nil
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
+ # req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
+ #
+ attr_reader :body
+
+ # Sets the body for the request:
+ #
+ # req = Gem::Net::HTTP::Post.new(uri)
+ # req.body # => nil
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
+ # req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
+ #
+ def body=(str)
+ @body = str
+ @body_stream = nil
+ @body_data = nil
+ str
+ end
+
+ # Returns the body stream object for the request, or +nil+ if there is none:
+ #
+ # req = Gem::Net::HTTP::Post.new(uri) # => #<Gem::Net::HTTP::Post POST>
+ # req.body_stream # => nil
+ # require 'stringio'
+ # req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
+ # req.body_stream # => #<StringIO:0x0000027d1e5affa8>
+ #
+ attr_reader :body_stream
+
+ # Sets the body stream for the request:
+ #
+ # req = Gem::Net::HTTP::Post.new(uri) # => #<Gem::Net::HTTP::Post POST>
+ # req.body_stream # => nil
+ # require 'stringio'
+ # req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
+ # req.body_stream # => #<StringIO:0x0000027d1e5affa8>
+ #
+ def body_stream=(input)
+ @body = nil
+ @body_stream = input
+ @body_data = nil
+ input
+ end
+
+ def set_body_internal(str) #:nodoc: internal use only
+ raise ArgumentError, "both of body argument and HTTPRequest#body set" if str and (@body or @body_stream)
+ self.body = str if str
+ if @body.nil? && @body_stream.nil? && @body_data.nil? && request_body_permitted?
+ self.body = ''
+ end
+ end
+
+ #
+ # write
+ #
+
+ def exec(sock, ver, path) #:nodoc: internal use only
+ if @body
+ send_request_with_body sock, ver, path, @body
+ elsif @body_stream
+ send_request_with_body_stream sock, ver, path, @body_stream
+ elsif @body_data
+ send_request_with_body_data sock, ver, path, @body_data
+ else
+ write_header sock, ver, path
+ end
+ end
+
+ def update_uri(addr, port, ssl) # :nodoc: internal use only
+ # reflect the connection and @path to @uri
+ return unless @uri
+
+ if ssl
+ scheme = 'https'
+ klass = Gem::URI::HTTPS
+ else
+ scheme = 'http'
+ klass = Gem::URI::HTTP
+ end
+
+ if host = self['host']
+ host = Gem::URI.parse("//#{host}").host # Remove a port component from the existing Host header
+ elsif host = @uri.host
+ else
+ host = addr
+ end
+ # convert the class of the Gem::URI
+ if @uri.is_a?(klass)
+ @uri.host = host
+ @uri.port = port
+ else
+ @uri = klass.new(
+ scheme, @uri.userinfo,
+ host, port, nil,
+ @uri.path, nil, @uri.query, nil)
+ end
+ end
+
+ private
+
+ # :stopdoc:
+
+ class Chunker #:nodoc:
+ def initialize(sock)
+ @sock = sock
+ @prev = nil
+ end
+
+ def write(buf)
+ # avoid memcpy() of buf, buf can huge and eat memory bandwidth
+ rv = buf.bytesize
+ @sock.write("#{rv.to_s(16)}\r\n", buf, "\r\n")
+ rv
+ end
+
+ def finish
+ @sock.write("0\r\n\r\n")
+ end
+ end
+
+ def send_request_with_body(sock, ver, path, body)
+ self.content_length = body.bytesize
+ delete 'Transfer-Encoding'
+ write_header sock, ver, path
+ wait_for_continue sock, ver if sock.continue_timeout
+ sock.write body
+ end
+
+ def send_request_with_body_stream(sock, ver, path, f)
+ unless content_length() or chunked?
+ raise ArgumentError,
+ "Content-Length not given and Transfer-Encoding is not `chunked'"
+ end
+ write_header sock, ver, path
+ wait_for_continue sock, ver if sock.continue_timeout
+ if chunked?
+ chunker = Chunker.new(sock)
+ IO.copy_stream(f, chunker)
+ chunker.finish
+ else
+ IO.copy_stream(f, sock)
+ end
+ end
+
+ def send_request_with_body_data(sock, ver, path, params)
+ if /\Amultipart\/form-data\z/i !~ self.content_type
+ self.content_type = 'application/x-www-form-urlencoded'
+ return send_request_with_body(sock, ver, path, Gem::URI.encode_www_form(params))
+ end
+
+ opt = @form_option.dup
+ require 'securerandom' unless defined?(SecureRandom)
+ opt[:boundary] ||= SecureRandom.urlsafe_base64(40)
+ self.set_content_type(self.content_type, boundary: opt[:boundary])
+ if chunked?
+ write_header sock, ver, path
+ encode_multipart_form_data(sock, params, opt)
+ else
+ require 'tempfile'
+ file = Tempfile.new('multipart')
+ file.binmode
+ encode_multipart_form_data(file, params, opt)
+ file.rewind
+ self.content_length = file.size
+ write_header sock, ver, path
+ IO.copy_stream(file, sock)
+ file.close(true)
+ end
+ end
+
+ def encode_multipart_form_data(out, params, opt)
+ charset = opt[:charset]
+ boundary = opt[:boundary]
+ require 'securerandom' unless defined?(SecureRandom)
+ boundary ||= SecureRandom.urlsafe_base64(40)
+ chunked_p = chunked?
+
+ buf = +''
+ params.each do |key, value, h={}|
+ key = quote_string(key, charset)
+ filename =
+ h.key?(:filename) ? h[:filename] :
+ value.respond_to?(:to_path) ? File.basename(value.to_path) :
+ nil
+
+ buf << "--#{boundary}\r\n"
+ if filename
+ filename = quote_string(filename, charset)
+ type = h[:content_type] || 'application/octet-stream'
+ buf << "Content-Disposition: form-data; " \
+ "name=\"#{key}\"; filename=\"#{filename}\"\r\n" \
+ "Content-Type: #{type}\r\n\r\n"
+ if !out.respond_to?(:write) || !value.respond_to?(:read)
+ # if +out+ is not an IO or +value+ is not an IO
+ buf << (value.respond_to?(:read) ? value.read : value)
+ elsif value.respond_to?(:size) && chunked_p
+ # if +out+ is an IO and +value+ is a File, use IO.copy_stream
+ flush_buffer(out, buf, chunked_p)
+ out << "%x\r\n" % value.size if chunked_p
+ IO.copy_stream(value, out)
+ out << "\r\n" if chunked_p
+ else
+ # +out+ is an IO, and +value+ is not a File but an IO
+ flush_buffer(out, buf, chunked_p)
+ 1 while flush_buffer(out, value.read(4096), chunked_p)
+ end
+ else
+ # non-file field:
+ # HTML5 says, "The parts of the generated multipart/form-data
+ # resource that correspond to non-file fields must not have a
+ # Content-Type header specified."
+ buf << "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
+ buf << (value.respond_to?(:read) ? value.read : value)
+ end
+ buf << "\r\n"
+ end
+ buf << "--#{boundary}--\r\n"
+ flush_buffer(out, buf, chunked_p)
+ out << "0\r\n\r\n" if chunked_p
+ end
+
+ def quote_string(str, charset)
+ str = str.encode(charset, fallback:->(c){'&#%d;'%c.encode("UTF-8").ord}) if charset
+ str.gsub(/[\\"]/, '\\\\\&')
+ end
+
+ def flush_buffer(out, buf, chunked_p)
+ return unless buf
+ out << "%x\r\n"%buf.bytesize if chunked_p
+ out << buf
+ out << "\r\n" if chunked_p
+ buf.clear
+ end
+
+ ##
+ # Waits up to the continue timeout for a response from the server provided
+ # we're speaking HTTP 1.1 and are expecting a 100-continue response.
+
+ def wait_for_continue(sock, ver)
+ if ver >= '1.1' and @header['expect'] and
+ @header['expect'].include?('100-continue')
+ if sock.io.to_io.wait_readable(sock.continue_timeout)
+ res = Gem::Net::HTTPResponse.read_new(sock)
+ unless res.kind_of?(Gem::Net::HTTPContinue)
+ res.decode_content = @decode_content
+ throw :response, res
+ end
+ end
+ end
+ end
+
+ def write_header(sock, ver, path)
+ reqline = "#{@method} #{path} HTTP/#{ver}"
+ if /[\r\n]/ =~ reqline
+ raise ArgumentError, "A Request-Line must not contain CR or LF"
+ end
+ buf = +''
+ buf << reqline << "\r\n"
+ each_capitalized do |k,v|
+ buf << "#{k}: #{v}\r\n"
+ end
+ buf << "\r\n"
+ sock.write buf
+ end
+
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/header.rb b/lib/rubygems/vendor/net-http/lib/net/http/header.rb
new file mode 100644
index 0000000000..bc68cd2eef
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/header.rb
@@ -0,0 +1,985 @@
+# frozen_string_literal: true
+#
+# The \HTTPHeader module provides access to \HTTP headers.
+#
+# The module is included in:
+#
+# - Gem::Net::HTTPGenericRequest (and therefore Gem::Net::HTTPRequest).
+# - Gem::Net::HTTPResponse.
+#
+# The headers are a hash-like collection of key/value pairs called _fields_.
+#
+# == Request and Response Fields
+#
+# Headers may be included in:
+#
+# - A Gem::Net::HTTPRequest object:
+# the object's headers will be sent with the request.
+# Any fields may be defined in the request;
+# see {Setters}[rdoc-ref:Gem::Net::HTTPHeader@Setters].
+# - A Gem::Net::HTTPResponse object:
+# the objects headers are usually those returned from the host.
+# Fields may be retrieved from the object;
+# see {Getters}[rdoc-ref:Gem::Net::HTTPHeader@Getters]
+# and {Iterators}[rdoc-ref:Gem::Net::HTTPHeader@Iterators].
+#
+# Exactly which fields should be sent or expected depends on the host;
+# see:
+#
+# - {Request fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
+# - {Response fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields].
+#
+# == About the Examples
+#
+# :include: doc/net-http/examples.rdoc
+#
+# == Fields
+#
+# A header field is a key/value pair.
+#
+# === Field Keys
+#
+# A field key may be:
+#
+# - A string: Key <tt>'Accept'</tt> is treated as if it were
+# <tt>'Accept'.downcase</tt>; i.e., <tt>'accept'</tt>.
+# - A symbol: Key <tt>:Accept</tt> is treated as if it were
+# <tt>:Accept.to_s.downcase</tt>; i.e., <tt>'accept'</tt>.
+#
+# Examples:
+#
+# req = Gem::Net::HTTP::Get.new(uri)
+# req[:accept] # => "*/*"
+# req['Accept'] # => "*/*"
+# req['ACCEPT'] # => "*/*"
+#
+# req['accept'] = 'text/html'
+# req[:accept] = 'text/html'
+# req['ACCEPT'] = 'text/html'
+#
+# === Field Values
+#
+# A field value may be returned as an array of strings or as a string:
+#
+# - These methods return field values as arrays:
+#
+# - #get_fields: Returns the array value for the given key,
+# or +nil+ if it does not exist.
+# - #to_hash: Returns a hash of all header fields:
+# each key is a field name; its value is the array value for the field.
+#
+# - These methods return field values as string;
+# the string value for a field is equivalent to
+# <tt>self[key.downcase.to_s].join(', '))</tt>:
+#
+# - #[]: Returns the string value for the given key,
+# or +nil+ if it does not exist.
+# - #fetch: Like #[], but accepts a default value
+# to be returned if the key does not exist.
+#
+# The field value may be set:
+#
+# - #[]=: Sets the value for the given key;
+# the given value may be a string, a symbol, an array, or a hash.
+# - #add_field: Adds a given value to a value for the given key
+# (not overwriting the existing value).
+# - #delete: Deletes the field for the given key.
+#
+# Example field values:
+#
+# - \String:
+#
+# req['Accept'] = 'text/html' # => "text/html"
+# req['Accept'] # => "text/html"
+# req.get_fields('Accept') # => ["text/html"]
+#
+# - \Symbol:
+#
+# req['Accept'] = :text # => :text
+# req['Accept'] # => "text"
+# req.get_fields('Accept') # => ["text"]
+#
+# - Simple array:
+#
+# req[:foo] = %w[bar baz bat]
+# req[:foo] # => "bar, baz, bat"
+# req.get_fields(:foo) # => ["bar", "baz", "bat"]
+#
+# - Simple hash:
+#
+# req[:foo] = {bar: 0, baz: 1, bat: 2}
+# req[:foo] # => "bar, 0, baz, 1, bat, 2"
+# req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"]
+#
+# - Nested:
+#
+# req[:foo] = [%w[bar baz], {bat: 0, bam: 1}]
+# req[:foo] # => "bar, baz, bat, 0, bam, 1"
+# req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"]
+#
+# req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}}
+# req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1"
+# req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"]
+#
+# == Convenience Methods
+#
+# Various convenience methods retrieve values, set values, query values,
+# set form values, or iterate over fields.
+#
+# === Setters
+#
+# \Method #[]= can set any field, but does little to validate the new value;
+# some of the other setter methods provide some validation:
+#
+# - #[]=: Sets the string or array value for the given key.
+# - #add_field: Creates or adds to the array value for the given key.
+# - #basic_auth: Sets the string authorization header for <tt>'Authorization'</tt>.
+# - #content_length=: Sets the integer length for field <tt>'Content-Length</tt>.
+# - #content_type=: Sets the string value for field <tt>'Content-Type'</tt>.
+# - #proxy_basic_auth: Sets the string authorization header for <tt>'Proxy-Authorization'</tt>.
+# - #set_range: Sets the value for field <tt>'Range'</tt>.
+#
+# === Form Setters
+#
+# - #set_form: Sets an HTML form data set.
+# - #set_form_data: Sets header fields and a body from HTML form data.
+#
+# === Getters
+#
+# \Method #[] can retrieve the value of any field that exists,
+# but always as a string;
+# some of the other getter methods return something different
+# from the simple string value:
+#
+# - #[]: Returns the string field value for the given key.
+# - #content_length: Returns the integer value of field <tt>'Content-Length'</tt>.
+# - #content_range: Returns the Range value of field <tt>'Content-Range'</tt>.
+# - #content_type: Returns the string value of field <tt>'Content-Type'</tt>.
+# - #fetch: Returns the string field value for the given key.
+# - #get_fields: Returns the array field value for the given +key+.
+# - #main_type: Returns first part of the string value of field <tt>'Content-Type'</tt>.
+# - #sub_type: Returns second part of the string value of field <tt>'Content-Type'</tt>.
+# - #range: Returns an array of Range objects of field <tt>'Range'</tt>, or +nil+.
+# - #range_length: Returns the integer length of the range given in field <tt>'Content-Range'</tt>.
+# - #type_params: Returns the string parameters for <tt>'Content-Type'</tt>.
+#
+# === Queries
+#
+# - #chunked?: Returns whether field <tt>'Transfer-Encoding'</tt> is set to <tt>'chunked'</tt>.
+# - #connection_close?: Returns whether field <tt>'Connection'</tt> is set to <tt>'close'</tt>.
+# - #connection_keep_alive?: Returns whether field <tt>'Connection'</tt> is set to <tt>'keep-alive'</tt>.
+# - #key?: Returns whether a given key exists.
+#
+# === Iterators
+#
+# - #each_capitalized: Passes each field capitalized-name/value pair to the block.
+# - #each_capitalized_name: Passes each capitalized field name to the block.
+# - #each_header: Passes each field name/value pair to the block.
+# - #each_name: Passes each field name to the block.
+# - #each_value: Passes each string field value to the block.
+#
+module Gem::Net::HTTPHeader
+ # The maximum length of HTTP header keys.
+ MAX_KEY_LENGTH = 1024
+ # The maximum length of HTTP header values.
+ MAX_FIELD_LENGTH = 65536
+
+ def initialize_http_header(initheader) #:nodoc:
+ @header = {}
+ return unless initheader
+ initheader.each do |key, value|
+ warn "net/http: duplicated HTTP header: #{key}", uplevel: 3 if key?(key) and $VERBOSE
+ if value.nil?
+ warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
+ else
+ value = value.strip # raise error for invalid byte sequences
+ if key.to_s.bytesize > MAX_KEY_LENGTH
+ raise ArgumentError, "too long (#{key.bytesize} bytes) header: #{key[0, 30].inspect}..."
+ end
+ if value.to_s.bytesize > MAX_FIELD_LENGTH
+ raise ArgumentError, "header #{key} has too long field value: #{value.bytesize}"
+ end
+ if value.count("\r\n") > 0
+ raise ArgumentError, "header #{key} has field value #{value.inspect}, this cannot include CR/LF"
+ end
+ @header[key.downcase.to_s] = [value]
+ end
+ end
+ end
+
+ def size #:nodoc: obsolete
+ @header.size
+ end
+
+ alias length size #:nodoc: obsolete
+
+ # Returns the string field value for the case-insensitive field +key+,
+ # or +nil+ if there is no such key;
+ # see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['Connection'] # => "keep-alive"
+ # res['Nosuch'] # => nil
+ #
+ # Note that some field values may be retrieved via convenience methods;
+ # see {Getters}[rdoc-ref:Gem::Net::HTTPHeader@Getters].
+ def [](key)
+ a = @header[key.downcase.to_s] or return nil
+ a.join(', ')
+ end
+
+ # Sets the value for the case-insensitive +key+ to +val+,
+ # overwriting the previous value if the field exists;
+ # see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req['Accept'] # => "*/*"
+ # req['Accept'] = 'text/html'
+ # req['Accept'] # => "text/html"
+ #
+ # Note that some field values may be set via convenience methods;
+ # see {Setters}[rdoc-ref:Gem::Net::HTTPHeader@Setters].
+ def []=(key, val)
+ unless val
+ @header.delete key.downcase.to_s
+ return val
+ end
+ set_field(key, val)
+ end
+
+ # Adds value +val+ to the value array for field +key+ if the field exists;
+ # creates the field with the given +key+ and +val+ if it does not exist.
+ # see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.add_field('Foo', 'bar')
+ # req['Foo'] # => "bar"
+ # req.add_field('Foo', 'baz')
+ # req['Foo'] # => "bar, baz"
+ # req.add_field('Foo', %w[baz bam])
+ # req['Foo'] # => "bar, baz, baz, bam"
+ # req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"]
+ #
+ def add_field(key, val)
+ stringified_downcased_key = key.downcase.to_s
+ if @header.key?(stringified_downcased_key)
+ append_field_value(@header[stringified_downcased_key], val)
+ else
+ set_field(key, val)
+ end
+ end
+
+ # :stopdoc:
+ private def set_field(key, val)
+ case val
+ when Enumerable
+ ary = []
+ append_field_value(ary, val)
+ @header[key.downcase.to_s] = ary
+ else
+ val = val.to_s # for compatibility use to_s instead of to_str
+ if val.b.count("\r\n") > 0
+ raise ArgumentError, 'header field value cannot include CR/LF'
+ end
+ @header[key.downcase.to_s] = [val]
+ end
+ end
+
+ private def append_field_value(ary, val)
+ case val
+ when Enumerable
+ val.each{|x| append_field_value(ary, x)}
+ else
+ val = val.to_s
+ if /[\r\n]/n.match?(val.b)
+ raise ArgumentError, 'header field value cannot include CR/LF'
+ end
+ ary.push val
+ end
+ end
+ # :startdoc:
+
+ # Returns the array field value for the given +key+,
+ # or +nil+ if there is no such field;
+ # see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.get_fields('Connection') # => ["keep-alive"]
+ # res.get_fields('Nosuch') # => nil
+ #
+ def get_fields(key)
+ stringified_downcased_key = key.downcase.to_s
+ return nil unless @header[stringified_downcased_key]
+ @header[stringified_downcased_key].dup
+ end
+
+ # call-seq:
+ # fetch(key, default_val = nil) {|key| ... } -> object
+ # fetch(key, default_val = nil) -> value or default_val
+ #
+ # With a block, returns the string value for +key+ if it exists;
+ # otherwise returns the value of the block;
+ # ignores the +default_val+;
+ # see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ #
+ # # Field exists; block not called.
+ # res.fetch('Connection') do |value|
+ # fail 'Cannot happen'
+ # end # => "keep-alive"
+ #
+ # # Field does not exist; block called.
+ # res.fetch('Nosuch') do |value|
+ # value.downcase
+ # end # => "nosuch"
+ #
+ # With no block, returns the string value for +key+ if it exists;
+ # otherwise, returns +default_val+ if it was given;
+ # otherwise raises an exception:
+ #
+ # res.fetch('Connection', 'Foo') # => "keep-alive"
+ # res.fetch('Nosuch', 'Foo') # => "Foo"
+ # res.fetch('Nosuch') # Raises KeyError.
+ #
+ def fetch(key, *args, &block) #:yield: +key+
+ a = @header.fetch(key.downcase.to_s, *args, &block)
+ a.kind_of?(Array) ? a.join(', ') : a
+ end
+
+ # Calls the block with each key/value pair:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.each_header do |key, value|
+ # p [key, value] if key.start_with?('c')
+ # end
+ #
+ # Output:
+ #
+ # ["content-type", "application/json; charset=utf-8"]
+ # ["connection", "keep-alive"]
+ # ["cache-control", "max-age=43200"]
+ # ["cf-cache-status", "HIT"]
+ # ["cf-ray", "771d17e9bc542cf5-ORD"]
+ #
+ # Returns an enumerator if no block is given.
+ #
+ # Gem::Net::HTTPHeader#each is an alias for Gem::Net::HTTPHeader#each_header.
+ def each_header #:yield: +key+, +value+
+ block_given? or return enum_for(__method__) { @header.size }
+ @header.each do |k,va|
+ yield k, va.join(', ')
+ end
+ end
+
+ alias each each_header
+
+ # Calls the block with each field key:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.each_key do |key|
+ # p key if key.start_with?('c')
+ # end
+ #
+ # Output:
+ #
+ # "content-type"
+ # "connection"
+ # "cache-control"
+ # "cf-cache-status"
+ # "cf-ray"
+ #
+ # Returns an enumerator if no block is given.
+ #
+ # Gem::Net::HTTPHeader#each_name is an alias for Gem::Net::HTTPHeader#each_key.
+ def each_name(&block) #:yield: +key+
+ block_given? or return enum_for(__method__) { @header.size }
+ @header.each_key(&block)
+ end
+
+ alias each_key each_name
+
+ # Calls the block with each capitalized field name:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.each_capitalized_name do |key|
+ # p key if key.start_with?('C')
+ # end
+ #
+ # Output:
+ #
+ # "Content-Type"
+ # "Connection"
+ # "Cache-Control"
+ # "Cf-Cache-Status"
+ # "Cf-Ray"
+ #
+ # The capitalization is system-dependent;
+ # see {Case Mapping}[https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html].
+ #
+ # Returns an enumerator if no block is given.
+ def each_capitalized_name #:yield: +key+
+ block_given? or return enum_for(__method__) { @header.size }
+ @header.each_key do |k|
+ yield capitalize(k)
+ end
+ end
+
+ # Calls the block with each string field value:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.each_value do |value|
+ # p value if value.start_with?('c')
+ # end
+ #
+ # Output:
+ #
+ # "chunked"
+ # "cf-q-config;dur=6.0000002122251e-06"
+ # "cloudflare"
+ #
+ # Returns an enumerator if no block is given.
+ def each_value #:yield: +value+
+ block_given? or return enum_for(__method__) { @header.size }
+ @header.each_value do |va|
+ yield va.join(', ')
+ end
+ end
+
+ # Removes the header for the given case-insensitive +key+
+ # (see {Fields}[rdoc-ref:Gem::Net::HTTPHeader@Fields]);
+ # returns the deleted value, or +nil+ if no such field exists:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.delete('Accept') # => ["*/*"]
+ # req.delete('Nosuch') # => nil
+ #
+ def delete(key)
+ @header.delete(key.downcase.to_s)
+ end
+
+ # Returns +true+ if the field for the case-insensitive +key+ exists, +false+ otherwise:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.key?('Accept') # => true
+ # req.key?('Nosuch') # => false
+ #
+ def key?(key)
+ @header.key?(key.downcase.to_s)
+ end
+
+ # Returns a hash of the key/value pairs:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.to_hash
+ # # =>
+ # {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
+ # "accept"=>["*/*"],
+ # "user-agent"=>["Ruby"],
+ # "host"=>["jsonplaceholder.typicode.com"]}
+ #
+ def to_hash
+ @header.dup
+ end
+
+ # Like #each_header, but the keys are returned in capitalized form.
+ #
+ # Gem::Net::HTTPHeader#canonical_each is an alias for Gem::Net::HTTPHeader#each_capitalized.
+ def each_capitalized
+ block_given? or return enum_for(__method__) { @header.size }
+ @header.each do |k,v|
+ yield capitalize(k), v.join(', ')
+ end
+ end
+
+ alias canonical_each each_capitalized
+
+ def capitalize(name) # :nodoc:
+ name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze)
+ end
+ private :capitalize
+
+ # Returns an array of Range objects that represent
+ # the value of field <tt>'Range'</tt>,
+ # or +nil+ if there is no such field;
+ # see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req['Range'] = 'bytes=0-99,200-299,400-499'
+ # req.range # => [0..99, 200..299, 400..499]
+ # req.delete('Range')
+ # req.range # # => nil
+ #
+ def range
+ return nil unless @header['range']
+
+ value = self['Range']
+ # byte-range-set = *( "," OWS ) ( byte-range-spec / suffix-byte-range-spec )
+ # *( OWS "," [ OWS ( byte-range-spec / suffix-byte-range-spec ) ] )
+ # corrected collected ABNF
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#section-5.4.1
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#appendix-C
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-19#section-3.2.5
+ unless /\Abytes=((?:,[ \t]*)*(?:\d+-\d*|-\d+)(?:[ \t]*,(?:[ \t]*\d+-\d*|-\d+)?)*)\z/ =~ value
+ raise Gem::Net::HTTPHeaderSyntaxError, "invalid syntax for byte-ranges-specifier: '#{value}'"
+ end
+
+ byte_range_set = $1
+ result = byte_range_set.split(/,/).map {|spec|
+ m = /(\d+)?\s*-\s*(\d+)?/i.match(spec) or
+ raise Gem::Net::HTTPHeaderSyntaxError, "invalid byte-range-spec: '#{spec}'"
+ d1 = m[1].to_i
+ d2 = m[2].to_i
+ if m[1] and m[2]
+ if d1 > d2
+ raise Gem::Net::HTTPHeaderSyntaxError, "last-byte-pos MUST greater than or equal to first-byte-pos but '#{spec}'"
+ end
+ d1..d2
+ elsif m[1]
+ d1..-1
+ elsif m[2]
+ -d2..-1
+ else
+ raise Gem::Net::HTTPHeaderSyntaxError, 'range is not specified'
+ end
+ }
+ # if result.empty?
+ # byte-range-set must include at least one byte-range-spec or suffix-byte-range-spec
+ # but above regexp already denies it.
+ if result.size == 1 && result[0].begin == 0 && result[0].end == -1
+ raise Gem::Net::HTTPHeaderSyntaxError, 'only one suffix-byte-range-spec with zero suffix-length'
+ end
+ result
+ end
+
+ # call-seq:
+ # set_range(length) -> length
+ # set_range(offset, length) -> range
+ # set_range(begin..length) -> range
+ #
+ # Sets the value for field <tt>'Range'</tt>;
+ # see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
+ #
+ # With argument +length+:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.set_range(100) # => 100
+ # req['Range'] # => "bytes=0-99"
+ #
+ # With arguments +offset+ and +length+:
+ #
+ # req.set_range(100, 100) # => 100...200
+ # req['Range'] # => "bytes=100-199"
+ #
+ # With argument +range+:
+ #
+ # req.set_range(100..199) # => 100..199
+ # req['Range'] # => "bytes=100-199"
+ #
+ # Gem::Net::HTTPHeader#range= is an alias for Gem::Net::HTTPHeader#set_range.
+ def set_range(r, e = nil)
+ unless r
+ @header.delete 'range'
+ return r
+ end
+ r = (r...r+e) if e
+ case r
+ when Numeric
+ n = r.to_i
+ rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}")
+ when Range
+ first = r.first
+ last = r.end
+ last -= 1 if r.exclude_end?
+ if last == -1
+ rangestr = (first > 0 ? "#{first}-" : "-#{-first}")
+ else
+ raise Gem::Net::HTTPHeaderSyntaxError, 'range.first is negative' if first < 0
+ raise Gem::Net::HTTPHeaderSyntaxError, 'range.last is negative' if last < 0
+ raise Gem::Net::HTTPHeaderSyntaxError, 'must be .first < .last' if first > last
+ rangestr = "#{first}-#{last}"
+ end
+ else
+ raise TypeError, 'Range/Integer is required'
+ end
+ @header['range'] = ["bytes=#{rangestr}"]
+ r
+ end
+
+ alias range= set_range
+
+ # Returns the value of field <tt>'Content-Length'</tt> as an integer,
+ # or +nil+ if there is no such field;
+ # see {Content-Length request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-request-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/nosuch/1')
+ # res.content_length # => 2
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res.content_length # => nil
+ #
+ def content_length
+ return nil unless key?('Content-Length')
+ len = self['Content-Length'].slice(/\d+/) or
+ raise Gem::Net::HTTPHeaderSyntaxError, 'wrong Content-Length format'
+ len.to_i
+ end
+
+ # Sets the value of field <tt>'Content-Length'</tt> to the given numeric;
+ # see {Content-Length response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-response-header]:
+ #
+ # _uri = uri.dup
+ # hostname = _uri.hostname # => "jsonplaceholder.typicode.com"
+ # _uri.path = '/posts' # => "/posts"
+ # req = Gem::Net::HTTP::Post.new(_uri) # => #<Gem::Net::HTTP::Post POST>
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
+ # req.content_length = req.body.size # => 42
+ # req.content_type = 'application/json'
+ # res = Gem::Net::HTTP.start(hostname) do |http|
+ # http.request(req)
+ # end # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
+ #
+ def content_length=(len)
+ unless len
+ @header.delete 'content-length'
+ return nil
+ end
+ @header['content-length'] = [len.to_i.to_s]
+ end
+
+ # Returns +true+ if field <tt>'Transfer-Encoding'</tt>
+ # exists and has value <tt>'chunked'</tt>,
+ # +false+ otherwise;
+ # see {Transfer-Encoding response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-encoding-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['Transfer-Encoding'] # => "chunked"
+ # res.chunked? # => true
+ #
+ def chunked?
+ return false unless @header['transfer-encoding']
+ field = self['Transfer-Encoding']
+ (/(?:\A|[^\-\w])chunked(?![\-\w])/i =~ field) ? true : false
+ end
+
+ # Returns a Range object representing the value of field
+ # <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
+ # see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['Content-Range'] # => nil
+ # res['Content-Range'] = 'bytes 0-499/1000'
+ # res['Content-Range'] # => "bytes 0-499/1000"
+ # res.content_range # => 0..499
+ #
+ def content_range
+ return nil unless @header['content-range']
+ m = %r<\A\s*(\w+)\s+(\d+)-(\d+)/(\d+|\*)>.match(self['Content-Range']) or
+ raise Gem::Net::HTTPHeaderSyntaxError, 'wrong Content-Range format'
+ return unless m[1] == 'bytes'
+ m[2].to_i .. m[3].to_i
+ end
+
+ # Returns the integer representing length of the value of field
+ # <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
+ # see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['Content-Range'] # => nil
+ # res['Content-Range'] = 'bytes 0-499/1000'
+ # res.range_length # => 500
+ #
+ def range_length
+ r = content_range() or return nil
+ r.end - r.begin + 1
+ end
+
+ # Returns the {media type}[https://en.wikipedia.org/wiki/Media_type]
+ # from the value of field <tt>'Content-Type'</tt>,
+ # or +nil+ if no such field exists;
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['content-type'] # => "application/json; charset=utf-8"
+ # res.content_type # => "application/json"
+ #
+ def content_type
+ main = main_type()
+ return nil unless main
+
+ sub = sub_type()
+ if sub
+ "#{main}/#{sub}"
+ else
+ main
+ end
+ end
+
+ # Returns the leading ('type') part of the
+ # {media type}[https://en.wikipedia.org/wiki/Media_type]
+ # from the value of field <tt>'Content-Type'</tt>,
+ # or +nil+ if no such field exists;
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['content-type'] # => "application/json; charset=utf-8"
+ # res.main_type # => "application"
+ #
+ def main_type
+ return nil unless @header['content-type']
+ self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip
+ end
+
+ # Returns the trailing ('subtype') part of the
+ # {media type}[https://en.wikipedia.org/wiki/Media_type]
+ # from the value of field <tt>'Content-Type'</tt>,
+ # or +nil+ if no such field exists;
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['content-type'] # => "application/json; charset=utf-8"
+ # res.sub_type # => "json"
+ #
+ def sub_type
+ return nil unless @header['content-type']
+ _, sub = *self['Content-Type'].split(';').first.to_s.split('/')
+ return nil unless sub
+ sub.strip
+ end
+
+ # Returns the trailing ('parameters') part of the value of field <tt>'Content-Type'</tt>,
+ # or +nil+ if no such field exists;
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
+ #
+ # res = Gem::Net::HTTP.get_response(hostname, '/todos/1')
+ # res['content-type'] # => "application/json; charset=utf-8"
+ # res.type_params # => {"charset"=>"utf-8"}
+ #
+ def type_params
+ result = {}
+ list = self['Content-Type'].to_s.split(';')
+ list.shift
+ list.each do |param|
+ k, v = *param.split('=', 2)
+ result[k.strip] = v.strip
+ end
+ result
+ end
+
+ # Sets the value of field <tt>'Content-Type'</tt>;
+ # returns the new value;
+ # see {Content-Type request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-request-header]:
+ #
+ # req = Gem::Net::HTTP::Get.new(uri)
+ # req.set_content_type('application/json') # => ["application/json"]
+ #
+ # Gem::Net::HTTPHeader#content_type= is an alias for Gem::Net::HTTPHeader#set_content_type.
+ def set_content_type(type, params = {})
+ @header['content-type'] = [type + params.map{|k,v|"; #{k}=#{v}"}.join('')]
+ end
+
+ alias content_type= set_content_type
+
+ # Sets the request body to a URL-encoded string derived from argument +params+,
+ # and sets request header field <tt>'Content-Type'</tt>
+ # to <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The resulting request is suitable for HTTP request +POST+ or +PUT+.
+ #
+ # Argument +params+ must be suitable for use as argument +enum+ to
+ # {Gem::URI.encode_www_form}[https://docs.ruby-lang.org/en/master/Gem::URI.html#method-c-encode_www_form].
+ #
+ # With only argument +params+ given,
+ # sets the body to a URL-encoded string with the default separator <tt>'&'</tt>:
+ #
+ # req = Gem::Net::HTTP::Post.new('example.com')
+ #
+ # req.set_form_data(q: 'ruby', lang: 'en')
+ # req.body # => "q=ruby&lang=en"
+ # req['Content-Type'] # => "application/x-www-form-urlencoded"
+ #
+ # req.set_form_data([['q', 'ruby'], ['lang', 'en']])
+ # req.body # => "q=ruby&lang=en"
+ #
+ # req.set_form_data(q: ['ruby', 'perl'], lang: 'en')
+ # req.body # => "q=ruby&q=perl&lang=en"
+ #
+ # req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']])
+ # req.body # => "q=ruby&q=perl&lang=en"
+ #
+ # With string argument +sep+ also given,
+ # uses that string as the separator:
+ #
+ # req.set_form_data({q: 'ruby', lang: 'en'}, '|')
+ # req.body # => "q=ruby|lang=en"
+ #
+ # Gem::Net::HTTPHeader#form_data= is an alias for Gem::Net::HTTPHeader#set_form_data.
+ def set_form_data(params, sep = '&')
+ query = Gem::URI.encode_www_form(params)
+ query.gsub!(/&/, sep) if sep != '&'
+ self.body = query
+ self.content_type = 'application/x-www-form-urlencoded'
+ end
+
+ alias form_data= set_form_data
+
+ # Stores form data to be used in a +POST+ or +PUT+ request.
+ #
+ # The form data given in +params+ consists of zero or more fields;
+ # each field is:
+ #
+ # - A scalar value.
+ # - A name/value pair.
+ # - An IO stream opened for reading.
+ #
+ # Argument +params+ should be an
+ # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
+ # (method <tt>params.map</tt> will be called),
+ # and is often an array or hash.
+ #
+ # First, we set up a request:
+ #
+ # _uri = uri.dup
+ # _uri.path ='/posts'
+ # req = Gem::Net::HTTP::Post.new(_uri)
+ #
+ # <b>Argument +params+ As an Array</b>
+ #
+ # When +params+ is an array,
+ # each of its elements is a subarray that defines a field;
+ # the subarray may contain:
+ #
+ # - One string:
+ #
+ # req.set_form([['foo'], ['bar'], ['baz']])
+ #
+ # - Two strings:
+ #
+ # req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]])
+ #
+ # - When argument +enctype+ (see below) is given as
+ # <tt>'multipart/form-data'</tt>:
+ #
+ # - A string name and an IO stream opened for reading:
+ #
+ # require 'stringio'
+ # req.set_form([['file', StringIO.new('Ruby is cool.')]])
+ #
+ # - A string name, an IO stream opened for reading,
+ # and an options hash, which may contain these entries:
+ #
+ # - +:filename+: The name of the file to use.
+ # - +:content_type+: The content type of the uploaded file.
+ #
+ # Example:
+ #
+ # req.set_form([['file', file, {filename: "other-filename.foo"}]]
+ #
+ # The various forms may be mixed:
+ #
+ # req.set_form(['foo', %w[bar 1], ['file', file]])
+ #
+ # <b>Argument +params+ As a Hash</b>
+ #
+ # When +params+ is a hash,
+ # each of its entries is a name/value pair that defines a field:
+ #
+ # - The name is a string.
+ # - The value may be:
+ #
+ # - +nil+.
+ # - Another string.
+ # - An IO stream opened for reading
+ # (only when argument +enctype+ -- see below -- is given as
+ # <tt>'multipart/form-data'</tt>).
+ #
+ # Examples:
+ #
+ # # Nil-valued fields.
+ # req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil})
+ #
+ # # String-valued fields.
+ # req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2})
+ #
+ # # IO-valued field.
+ # require 'stringio'
+ # req.set_form({'file' => StringIO.new('Ruby is cool.')})
+ #
+ # # Mixture of fields.
+ # req.set_form({'foo' => nil, 'bar' => 1, 'file' => file})
+ #
+ # Optional argument +enctype+ specifies the value to be given
+ # to field <tt>'Content-Type'</tt>, and must be one of:
+ #
+ # - <tt>'application/x-www-form-urlencoded'</tt> (the default).
+ # - <tt>'multipart/form-data'</tt>;
+ # see {RFC 7578}[https://www.rfc-editor.org/rfc/rfc7578].
+ #
+ # Optional argument +formopt+ is a hash of options
+ # (applicable only when argument +enctype+
+ # is <tt>'multipart/form-data'</tt>)
+ # that may include the following entries:
+ #
+ # - +:boundary+: The value is the boundary string for the multipart message.
+ # If not given, the boundary is a random string.
+ # See {Boundary}[https://www.rfc-editor.org/rfc/rfc7578#section-4.1].
+ # - +:charset+: Value is the character set for the form submission.
+ # Field names and values of non-file fields should be encoded with this charset.
+ #
+ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
+ @body_data = params
+ @body = nil
+ @body_stream = nil
+ @form_option = formopt
+ case enctype
+ when /\Aapplication\/x-www-form-urlencoded\z/i,
+ /\Amultipart\/form-data\z/i
+ self.content_type = enctype
+ else
+ raise ArgumentError, "invalid enctype: #{enctype}"
+ end
+ end
+
+ # Sets header <tt>'Authorization'</tt> using the given
+ # +account+ and +password+ strings:
+ #
+ # req.basic_auth('my_account', 'my_password')
+ # req['Authorization']
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
+ #
+ def basic_auth(account, password)
+ @header['authorization'] = [basic_encode(account, password)]
+ end
+
+ # Sets header <tt>'Proxy-Authorization'</tt> using the given
+ # +account+ and +password+ strings:
+ #
+ # req.proxy_basic_auth('my_account', 'my_password')
+ # req['Proxy-Authorization']
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
+ #
+ def proxy_basic_auth(account, password)
+ @header['proxy-authorization'] = [basic_encode(account, password)]
+ end
+
+ def basic_encode(account, password) # :nodoc:
+ 'Basic ' + ["#{account}:#{password}"].pack('m0')
+ end
+ private :basic_encode
+
+ # Returns whether the HTTP session is to be closed.
+ def connection_close?
+ token = /(?:\A|,)\s*close\s*(?:\z|,)/i
+ @header['connection']&.grep(token) {return true}
+ @header['proxy-connection']&.grep(token) {return true}
+ false
+ end
+
+ # Returns whether the HTTP session is to be kept alive.
+ def connection_keep_alive?
+ token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
+ @header['connection']&.grep(token) {return true}
+ @header['proxy-connection']&.grep(token) {return true}
+ false
+ end
+
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb b/lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb
new file mode 100644
index 0000000000..137295a883
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+module Gem::Net::HTTP::ProxyDelta #:nodoc: internal use only
+ private
+
+ def conn_address
+ proxy_address()
+ end
+
+ def conn_port
+ proxy_port()
+ end
+
+ def edit_path(path)
+ use_ssl? ? path : "http://#{addr_port()}#{path}"
+ end
+end
+
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/request.rb b/lib/rubygems/vendor/net-http/lib/net/http/request.rb
new file mode 100644
index 0000000000..495ec9be54
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/request.rb
@@ -0,0 +1,88 @@
+# frozen_string_literal: true
+
+# This class is the base class for \Gem::Net::HTTP request classes.
+# The class should not be used directly;
+# instead you should use its subclasses, listed below.
+#
+# == Creating a Request
+#
+# An request object may be created with either a Gem::URI or a string hostname:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('https://jsonplaceholder.typicode.com/')
+# req = Gem::Net::HTTP::Get.new(uri) # => #<Gem::Net::HTTP::Get GET>
+# req = Gem::Net::HTTP::Get.new(uri.hostname) # => #<Gem::Net::HTTP::Get GET>
+#
+# And with any of the subclasses:
+#
+# req = Gem::Net::HTTP::Head.new(uri) # => #<Gem::Net::HTTP::Head HEAD>
+# req = Gem::Net::HTTP::Post.new(uri) # => #<Gem::Net::HTTP::Post POST>
+# req = Gem::Net::HTTP::Put.new(uri) # => #<Gem::Net::HTTP::Put PUT>
+# # ...
+#
+# The new instance is suitable for use as the argument to Gem::Net::HTTP#request.
+#
+# == Request Headers
+#
+# A new request object has these header fields by default:
+#
+# req.to_hash
+# # =>
+# {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
+# "accept"=>["*/*"],
+# "user-agent"=>["Ruby"],
+# "host"=>["jsonplaceholder.typicode.com"]}
+#
+# See:
+#
+# - {Request header Accept-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Accept-Encoding]
+# and {Compression and Decompression}[rdoc-ref:Gem::Net::HTTP@Compression+and+Decompression].
+# - {Request header Accept}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-request-header].
+# - {Request header User-Agent}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user-agent-request-header].
+# - {Request header Host}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-request-header].
+#
+# You can add headers or override default headers:
+#
+# # res = Gem::Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'})
+#
+# This class (and therefore its subclasses) also includes (indirectly)
+# module Gem::Net::HTTPHeader, which gives access to its
+# {methods for setting headers}[rdoc-ref:Gem::Net::HTTPHeader@Setters].
+#
+# == Request Subclasses
+#
+# Subclasses for HTTP requests:
+#
+# - Gem::Net::HTTP::Get
+# - Gem::Net::HTTP::Head
+# - Gem::Net::HTTP::Post
+# - Gem::Net::HTTP::Put
+# - Gem::Net::HTTP::Delete
+# - Gem::Net::HTTP::Options
+# - Gem::Net::HTTP::Trace
+# - Gem::Net::HTTP::Patch
+#
+# Subclasses for WebDAV requests:
+#
+# - Gem::Net::HTTP::Propfind
+# - Gem::Net::HTTP::Proppatch
+# - Gem::Net::HTTP::Mkcol
+# - Gem::Net::HTTP::Copy
+# - Gem::Net::HTTP::Move
+# - Gem::Net::HTTP::Lock
+# - Gem::Net::HTTP::Unlock
+#
+class Gem::Net::HTTPRequest < Gem::Net::HTTPGenericRequest
+ # Creates an HTTP request object for +path+.
+ #
+ # +initheader+ are the default headers to use. Gem::Net::HTTP adds
+ # Accept-Encoding to enable compression of the response body unless
+ # Accept-Encoding or Range are supplied in +initheader+.
+
+ def initialize(path, initheader = nil)
+ super self.class::METHOD,
+ self.class::REQUEST_HAS_BODY,
+ self.class::RESPONSE_HAS_BODY,
+ path, initheader
+ end
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/requests.rb b/lib/rubygems/vendor/net-http/lib/net/http/requests.rb
new file mode 100644
index 0000000000..f990761042
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/requests.rb
@@ -0,0 +1,444 @@
+# frozen_string_literal: true
+
+# HTTP/1.1 methods --- RFC2616
+
+# \Class for representing
+# {HTTP method GET}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#GET_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Get.new(uri) # => #<Gem::Net::HTTP::Get GET>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: optional.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+#
+# Related:
+#
+# - Gem::Net::HTTP.get: sends +GET+ request, returns response body.
+# - Gem::Net::HTTP#get: sends +GET+ request, returns response object.
+#
+class Gem::Net::HTTP::Get < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'GET'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method HEAD}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#HEAD_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Head.new(uri) # => #<Gem::Net::HTTP::Head HEAD>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: optional.
+# - Response body: no.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+#
+# Related:
+#
+# - Gem::Net::HTTP#head: sends +HEAD+ request, returns response object.
+#
+class Gem::Net::HTTP::Head < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'HEAD'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = false
+end
+
+# \Class for representing
+# {HTTP method POST}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#POST_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# uri.path = '/posts'
+# req = Gem::Net::HTTP::Post.new(uri) # => #<Gem::Net::HTTP::Post POST>
+# req.body = '{"title": "foo","body": "bar","userId": 1}'
+# req.content_type = 'application/json'
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: yes.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
+#
+# Related:
+#
+# - Gem::Net::HTTP.post: sends +POST+ request, returns response object.
+# - Gem::Net::HTTP#post: sends +POST+ request, returns response object.
+#
+class Gem::Net::HTTP::Post < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'POST'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method PUT}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#PUT_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# uri.path = '/posts'
+# req = Gem::Net::HTTP::Put.new(uri) # => #<Gem::Net::HTTP::Put PUT>
+# req.body = '{"title": "foo","body": "bar","userId": 1}'
+# req.content_type = 'application/json'
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: yes.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+#
+# Related:
+#
+# - Gem::Net::HTTP.put: sends +PUT+ request, returns response object.
+# - Gem::Net::HTTP#put: sends +PUT+ request, returns response object.
+#
+class Gem::Net::HTTP::Put < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'PUT'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method DELETE}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#DELETE_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# uri.path = '/posts/1'
+# req = Gem::Net::HTTP::Delete.new(uri) # => #<Gem::Net::HTTP::Delete DELETE>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: optional.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+#
+# Related:
+#
+# - Gem::Net::HTTP#delete: sends +DELETE+ request, returns response object.
+#
+class Gem::Net::HTTP::Delete < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'DELETE'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method OPTIONS}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#OPTIONS_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Options.new(uri) # => #<Gem::Net::HTTP::Options OPTIONS>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: optional.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+#
+# Related:
+#
+# - Gem::Net::HTTP#options: sends +OPTIONS+ request, returns response object.
+#
+class Gem::Net::HTTP::Options < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'OPTIONS'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method TRACE}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#TRACE_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Trace.new(uri) # => #<Gem::Net::HTTP::Trace TRACE>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: no.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+#
+# Related:
+#
+# - Gem::Net::HTTP#trace: sends +TRACE+ request, returns response object.
+#
+class Gem::Net::HTTP::Trace < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'TRACE'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {HTTP method PATCH}[https://en.wikipedia.org/w/index.php?title=Hypertext_Transfer_Protocol#PATCH_method]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# uri.path = '/posts'
+# req = Gem::Net::HTTP::Patch.new(uri) # => #<Gem::Net::HTTP::Patch PATCH>
+# req.body = '{"title": "foo","body": "bar","userId": 1}'
+# req.content_type = 'application/json'
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Properties:
+#
+# - Request body: yes.
+# - Response body: yes.
+# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
+# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
+# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
+#
+# Related:
+#
+# - Gem::Net::HTTP#patch: sends +PATCH+ request, returns response object.
+#
+class Gem::Net::HTTP::Patch < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'PATCH'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+#
+# WebDAV methods --- RFC2518
+#
+
+# \Class for representing
+# {WebDAV method PROPFIND}[http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Propfind.new(uri) # => #<Gem::Net::HTTP::Propfind PROPFIND>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#propfind: sends +PROPFIND+ request, returns response object.
+#
+class Gem::Net::HTTP::Propfind < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'PROPFIND'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method PROPPATCH}[http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Proppatch.new(uri) # => #<Gem::Net::HTTP::Proppatch PROPPATCH>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object.
+#
+class Gem::Net::HTTP::Proppatch < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'PROPPATCH'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method MKCOL}[http://www.webdav.org/specs/rfc4918.html#METHOD_MKCOL]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Mkcol.new(uri) # => #<Gem::Net::HTTP::Mkcol MKCOL>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#mkcol: sends +MKCOL+ request, returns response object.
+#
+class Gem::Net::HTTP::Mkcol < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'MKCOL'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method COPY}[http://www.webdav.org/specs/rfc4918.html#METHOD_COPY]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Copy.new(uri) # => #<Gem::Net::HTTP::Copy COPY>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#copy: sends +COPY+ request, returns response object.
+#
+class Gem::Net::HTTP::Copy < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'COPY'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method MOVE}[http://www.webdav.org/specs/rfc4918.html#METHOD_MOVE]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Move.new(uri) # => #<Gem::Net::HTTP::Move MOVE>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#move: sends +MOVE+ request, returns response object.
+#
+class Gem::Net::HTTP::Move < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'MOVE'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method LOCK}[http://www.webdav.org/specs/rfc4918.html#METHOD_LOCK]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Lock.new(uri) # => #<Gem::Net::HTTP::Lock LOCK>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#lock: sends +LOCK+ request, returns response object.
+#
+class Gem::Net::HTTP::Lock < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'LOCK'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
+
+# \Class for representing
+# {WebDAV method UNLOCK}[http://www.webdav.org/specs/rfc4918.html#METHOD_UNLOCK]:
+#
+# require 'rubygems/vendor/net-http/lib/net/http'
+# uri = Gem::URI('http://example.com')
+# hostname = uri.hostname # => "example.com"
+# req = Gem::Net::HTTP::Unlock.new(uri) # => #<Gem::Net::HTTP::Unlock UNLOCK>
+# res = Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end
+#
+# See {Request Headers}[rdoc-ref:Gem::Net::HTTPRequest@Request+Headers].
+#
+# Related:
+#
+# - Gem::Net::HTTP#unlock: sends +UNLOCK+ request, returns response object.
+#
+class Gem::Net::HTTP::Unlock < Gem::Net::HTTPRequest
+ # :stopdoc:
+ METHOD = 'UNLOCK'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/response.rb b/lib/rubygems/vendor/net-http/lib/net/http/response.rb
new file mode 100644
index 0000000000..dc164f1504
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/response.rb
@@ -0,0 +1,739 @@
+# frozen_string_literal: true
+
+# This class is the base class for \Gem::Net::HTTP response classes.
+#
+# == About the Examples
+#
+# :include: doc/net-http/examples.rdoc
+#
+# == Returned Responses
+#
+# \Method Gem::Net::HTTP.get_response returns
+# an instance of one of the subclasses of \Gem::Net::HTTPResponse:
+#
+# Gem::Net::HTTP.get_response(uri)
+# # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+# Gem::Net::HTTP.get_response(hostname, '/nosuch')
+# # => #<Gem::Net::HTTPNotFound 404 Not Found readbody=true>
+#
+# As does method Gem::Net::HTTP#request:
+#
+# req = Gem::Net::HTTP::Get.new(uri)
+# Gem::Net::HTTP.start(hostname) do |http|
+# http.request(req)
+# end # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+#
+# \Class \Gem::Net::HTTPResponse includes module Gem::Net::HTTPHeader,
+# which provides access to response header values via (among others):
+#
+# - \Hash-like method <tt>[]</tt>.
+# - Specific reader methods, such as +content_type+.
+#
+# Examples:
+#
+# res = Gem::Net::HTTP.get_response(uri) # => #<Gem::Net::HTTPOK 200 OK readbody=true>
+# res['Content-Type'] # => "text/html; charset=UTF-8"
+# res.content_type # => "text/html"
+#
+# == Response Subclasses
+#
+# \Class \Gem::Net::HTTPResponse has a subclass for each
+# {HTTP status code}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes].
+# You can look up the response class for a given code:
+#
+# Gem::Net::HTTPResponse::CODE_TO_OBJ['200'] # => Gem::Net::HTTPOK
+# Gem::Net::HTTPResponse::CODE_TO_OBJ['400'] # => Gem::Net::HTTPBadRequest
+# Gem::Net::HTTPResponse::CODE_TO_OBJ['404'] # => Gem::Net::HTTPNotFound
+#
+# And you can retrieve the status code for a response object:
+#
+# Gem::Net::HTTP.get_response(uri).code # => "200"
+# Gem::Net::HTTP.get_response(hostname, '/nosuch').code # => "404"
+#
+# The response subclasses (indentation shows class hierarchy):
+#
+# - Gem::Net::HTTPUnknownResponse (for unhandled \HTTP extensions).
+#
+# - Gem::Net::HTTPInformation:
+#
+# - Gem::Net::HTTPContinue (100)
+# - Gem::Net::HTTPSwitchProtocol (101)
+# - Gem::Net::HTTPProcessing (102)
+# - Gem::Net::HTTPEarlyHints (103)
+#
+# - Gem::Net::HTTPSuccess:
+#
+# - Gem::Net::HTTPOK (200)
+# - Gem::Net::HTTPCreated (201)
+# - Gem::Net::HTTPAccepted (202)
+# - Gem::Net::HTTPNonAuthoritativeInformation (203)
+# - Gem::Net::HTTPNoContent (204)
+# - Gem::Net::HTTPResetContent (205)
+# - Gem::Net::HTTPPartialContent (206)
+# - Gem::Net::HTTPMultiStatus (207)
+# - Gem::Net::HTTPAlreadyReported (208)
+# - Gem::Net::HTTPIMUsed (226)
+#
+# - Gem::Net::HTTPRedirection:
+#
+# - Gem::Net::HTTPMultipleChoices (300)
+# - Gem::Net::HTTPMovedPermanently (301)
+# - Gem::Net::HTTPFound (302)
+# - Gem::Net::HTTPSeeOther (303)
+# - Gem::Net::HTTPNotModified (304)
+# - Gem::Net::HTTPUseProxy (305)
+# - Gem::Net::HTTPTemporaryRedirect (307)
+# - Gem::Net::HTTPPermanentRedirect (308)
+#
+# - Gem::Net::HTTPClientError:
+#
+# - Gem::Net::HTTPBadRequest (400)
+# - Gem::Net::HTTPUnauthorized (401)
+# - Gem::Net::HTTPPaymentRequired (402)
+# - Gem::Net::HTTPForbidden (403)
+# - Gem::Net::HTTPNotFound (404)
+# - Gem::Net::HTTPMethodNotAllowed (405)
+# - Gem::Net::HTTPNotAcceptable (406)
+# - Gem::Net::HTTPProxyAuthenticationRequired (407)
+# - Gem::Net::HTTPRequestTimeOut (408)
+# - Gem::Net::HTTPConflict (409)
+# - Gem::Net::HTTPGone (410)
+# - Gem::Net::HTTPLengthRequired (411)
+# - Gem::Net::HTTPPreconditionFailed (412)
+# - Gem::Net::HTTPRequestEntityTooLarge (413)
+# - Gem::Net::HTTPRequestURITooLong (414)
+# - Gem::Net::HTTPUnsupportedMediaType (415)
+# - Gem::Net::HTTPRequestedRangeNotSatisfiable (416)
+# - Gem::Net::HTTPExpectationFailed (417)
+# - Gem::Net::HTTPMisdirectedRequest (421)
+# - Gem::Net::HTTPUnprocessableEntity (422)
+# - Gem::Net::HTTPLocked (423)
+# - Gem::Net::HTTPFailedDependency (424)
+# - Gem::Net::HTTPUpgradeRequired (426)
+# - Gem::Net::HTTPPreconditionRequired (428)
+# - Gem::Net::HTTPTooManyRequests (429)
+# - Gem::Net::HTTPRequestHeaderFieldsTooLarge (431)
+# - Gem::Net::HTTPUnavailableForLegalReasons (451)
+#
+# - Gem::Net::HTTPServerError:
+#
+# - Gem::Net::HTTPInternalServerError (500)
+# - Gem::Net::HTTPNotImplemented (501)
+# - Gem::Net::HTTPBadGateway (502)
+# - Gem::Net::HTTPServiceUnavailable (503)
+# - Gem::Net::HTTPGatewayTimeOut (504)
+# - Gem::Net::HTTPVersionNotSupported (505)
+# - Gem::Net::HTTPVariantAlsoNegotiates (506)
+# - Gem::Net::HTTPInsufficientStorage (507)
+# - Gem::Net::HTTPLoopDetected (508)
+# - Gem::Net::HTTPNotExtended (510)
+# - Gem::Net::HTTPNetworkAuthenticationRequired (511)
+#
+# There is also the Gem::Net::HTTPBadResponse exception which is raised when
+# there is a protocol error.
+#
+class Gem::Net::HTTPResponse
+ class << self
+ # true if the response has a body.
+ def body_permitted?
+ self::HAS_BODY
+ end
+
+ def exception_type # :nodoc: internal use only
+ self::EXCEPTION_TYPE
+ end
+
+ def read_new(sock) #:nodoc: internal use only
+ httpv, code, msg = read_status_line(sock)
+ res = response_class(code).new(httpv, code, msg)
+ each_response_header(sock) do |k,v|
+ res.add_field k, v
+ end
+ res
+ end
+
+ private
+ # :stopdoc:
+
+ def read_status_line(sock)
+ str = sock.readline
+ m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or
+ raise Gem::Net::HTTPBadResponse, "wrong status line: #{str.dump}"
+ m.captures
+ end
+
+ def response_class(code)
+ CODE_TO_OBJ[code] or
+ CODE_CLASS_TO_OBJ[code[0,1]] or
+ Gem::Net::HTTPUnknownResponse
+ end
+
+ def each_response_header(sock)
+ key = value = nil
+ while true
+ line = sock.readuntil("\n", true).sub(/\s+\z/, '')
+ break if line.empty?
+ if line[0] == ?\s or line[0] == ?\t and value
+ value << ' ' unless value.empty?
+ value << line.strip
+ else
+ yield key, value if key
+ key, value = line.strip.split(/\s*:\s*/, 2)
+ raise Gem::Net::HTTPBadResponse, 'wrong header line format' if value.nil?
+ end
+ end
+ yield key, value if key
+ end
+ end
+
+ # next is to fix bug in RDoc, where the private inside class << self
+ # spills out.
+ public
+
+ include Gem::Net::HTTPHeader
+
+ def initialize(httpv, code, msg) #:nodoc: internal use only
+ @http_version = httpv
+ @code = code
+ @message = msg
+ initialize_http_header nil
+ @body = nil
+ @read = false
+ @uri = nil
+ @decode_content = false
+ @body_encoding = false
+ @ignore_eof = true
+ end
+
+ # The HTTP version supported by the server.
+ attr_reader :http_version
+
+ # The HTTP result code string. For example, '302'. You can also
+ # determine the response type by examining which response subclass
+ # the response object is an instance of.
+ attr_reader :code
+
+ # The HTTP result message sent by the server. For example, 'Not Found'.
+ attr_reader :message
+ alias msg message # :nodoc: obsolete
+
+ # The Gem::URI used to fetch this response. The response Gem::URI is only available
+ # if a Gem::URI was used to create the request.
+ attr_reader :uri
+
+ # Set to true automatically when the request did not contain an
+ # Accept-Encoding header from the user.
+ attr_accessor :decode_content
+
+ # Returns the value set by body_encoding=, or +false+ if none;
+ # see #body_encoding=.
+ attr_reader :body_encoding
+
+ # Sets the encoding that should be used when reading the body:
+ #
+ # - If the given value is an Encoding object, that encoding will be used.
+ # - Otherwise if the value is a string, the value of
+ # {Encoding#find(value)}[https://docs.ruby-lang.org/en/master/Encoding.html#method-c-find]
+ # will be used.
+ # - Otherwise an encoding will be deduced from the body itself.
+ #
+ # Examples:
+ #
+ # http = Gem::Net::HTTP.new(hostname)
+ # req = Gem::Net::HTTP::Get.new('/')
+ #
+ # http.request(req) do |res|
+ # p res.body.encoding # => #<Encoding:ASCII-8BIT>
+ # end
+ #
+ # http.request(req) do |res|
+ # res.body_encoding = "UTF-8"
+ # p res.body.encoding # => #<Encoding:UTF-8>
+ # end
+ #
+ def body_encoding=(value)
+ value = Encoding.find(value) if value.is_a?(String)
+ @body_encoding = value
+ end
+
+ # Whether to ignore EOF when reading bodies with a specified Content-Length
+ # header.
+ attr_accessor :ignore_eof
+
+ def inspect # :nodoc:
+ "#<#{self.class} #{@code} #{@message} readbody=#{@read}>"
+ end
+
+ #
+ # response <-> exception relationship
+ #
+
+ def code_type #:nodoc:
+ self.class
+ end
+
+ def error! #:nodoc:
+ message = @code
+ message = "#{message} #{@message.dump}" if @message
+ raise error_type().new(message, self)
+ end
+
+ def error_type #:nodoc:
+ self.class::EXCEPTION_TYPE
+ end
+
+ # Raises an HTTP error if the response is not 2xx (success).
+ def value
+ error! unless self.kind_of?(Gem::Net::HTTPSuccess)
+ end
+
+ def uri= uri # :nodoc:
+ @uri = uri.dup if uri
+ end
+
+ #
+ # header (for backward compatibility only; DO NOT USE)
+ #
+
+ def response #:nodoc:
+ warn "Gem::Net::HTTPResponse#response is obsolete", uplevel: 1 if $VERBOSE
+ self
+ end
+
+ def header #:nodoc:
+ warn "Gem::Net::HTTPResponse#header is obsolete", uplevel: 1 if $VERBOSE
+ self
+ end
+
+ def read_header #:nodoc:
+ warn "Gem::Net::HTTPResponse#read_header is obsolete", uplevel: 1 if $VERBOSE
+ self
+ end
+
+ #
+ # body
+ #
+
+ def reading_body(sock, reqmethodallowbody) #:nodoc: internal use only
+ @socket = sock
+ @body_exist = reqmethodallowbody && self.class.body_permitted?
+ begin
+ yield
+ self.body # ensure to read body
+ ensure
+ @socket = nil
+ end
+ end
+
+ # Gets the entity body returned by the remote HTTP server.
+ #
+ # If a block is given, the body is passed to the block, and
+ # the body is provided in fragments, as it is read in from the socket.
+ #
+ # If +dest+ argument is given, response is read into that variable,
+ # with <code>dest#<<</code> method (it could be String or IO, or any
+ # other object responding to <code><<</code>).
+ #
+ # Calling this method a second or subsequent time for the same
+ # HTTPResponse object will return the value already read.
+ #
+ # http.request_get('/index.html') {|res|
+ # puts res.read_body
+ # }
+ #
+ # http.request_get('/index.html') {|res|
+ # p res.read_body.object_id # 538149362
+ # p res.read_body.object_id # 538149362
+ # }
+ #
+ # # using iterator
+ # http.request_get('/index.html') {|res|
+ # res.read_body do |segment|
+ # print segment
+ # end
+ # }
+ #
+ def read_body(dest = nil, &block)
+ if @read
+ raise IOError, "#{self.class}\#read_body called twice" if dest or block
+ return @body
+ end
+ to = procdest(dest, block)
+ stream_check
+ if @body_exist
+ read_body_0 to
+ @body = to
+ else
+ @body = nil
+ end
+ @read = true
+ return if @body.nil?
+
+ case enc = @body_encoding
+ when Encoding, false, nil
+ # Encoding: force given encoding
+ # false/nil: do not force encoding
+ else
+ # other value: detect encoding from body
+ enc = detect_encoding(@body)
+ end
+
+ @body.force_encoding(enc) if enc
+
+ @body
+ end
+
+ # Returns the string response body;
+ # note that repeated calls for the unmodified body return a cached string:
+ #
+ # path = '/todos/1'
+ # Gem::Net::HTTP.start(hostname) do |http|
+ # res = http.get(path)
+ # p res.body
+ # p http.head(path).body # No body.
+ # end
+ #
+ # Output:
+ #
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
+ # nil
+ #
+ def body
+ read_body()
+ end
+
+ # Sets the body of the response to the given value.
+ def body=(value)
+ @body = value
+ end
+
+ alias entity body #:nodoc: obsolete
+
+ private
+
+ # :nodoc:
+ def detect_encoding(str, encoding=nil)
+ if encoding
+ elsif encoding = type_params['charset']
+ elsif encoding = check_bom(str)
+ else
+ encoding = case content_type&.downcase
+ when %r{text/x(?:ht)?ml|application/(?:[^+]+\+)?xml}
+ /\A<xml[ \t\r\n]+
+ version[ \t\r\n]*=[ \t\r\n]*(?:"[0-9.]+"|'[0-9.]*')[ \t\r\n]+
+ encoding[ \t\r\n]*=[ \t\r\n]*
+ (?:"([A-Za-z][\-A-Za-z0-9._]*)"|'([A-Za-z][\-A-Za-z0-9._]*)')/x =~ str
+ encoding = $1 || $2 || Encoding::UTF_8
+ when %r{text/html.*}
+ sniff_encoding(str)
+ end
+ end
+ return encoding
+ end
+
+ # :nodoc:
+ def sniff_encoding(str, encoding=nil)
+ # the encoding sniffing algorithm
+ # http://www.w3.org/TR/html5/parsing.html#determining-the-character-encoding
+ if enc = scanning_meta(str)
+ enc
+ # 6. last visited page or something
+ # 7. frequency
+ elsif str.ascii_only?
+ Encoding::US_ASCII
+ elsif str.dup.force_encoding(Encoding::UTF_8).valid_encoding?
+ Encoding::UTF_8
+ end
+ # 8. implementation-defined or user-specified
+ end
+
+ # :nodoc:
+ def check_bom(str)
+ case str.byteslice(0, 2)
+ when "\xFE\xFF"
+ return Encoding::UTF_16BE
+ when "\xFF\xFE"
+ return Encoding::UTF_16LE
+ end
+ if "\xEF\xBB\xBF" == str.byteslice(0, 3)
+ return Encoding::UTF_8
+ end
+ nil
+ end
+
+ # :nodoc:
+ def scanning_meta(str)
+ require 'strscan'
+ ss = StringScanner.new(str)
+ if ss.scan_until(/<meta[\t\n\f\r ]*/)
+ attrs = {} # attribute_list
+ got_pragma = false
+ need_pragma = nil
+ charset = nil
+
+ # step: Attributes
+ while attr = get_attribute(ss)
+ name, value = *attr
+ next if attrs[name]
+ attrs[name] = true
+ case name
+ when 'http-equiv'
+ got_pragma = true if value == 'content-type'
+ when 'content'
+ encoding = extracting_encodings_from_meta_elements(value)
+ unless charset
+ charset = encoding
+ end
+ need_pragma = true
+ when 'charset'
+ need_pragma = false
+ charset = value
+ end
+ end
+
+ # step: Processing
+ return if need_pragma.nil?
+ return if need_pragma && !got_pragma
+
+ charset = Encoding.find(charset) rescue nil
+ return unless charset
+ charset = Encoding::UTF_8 if charset == Encoding::UTF_16
+ return charset # tentative
+ end
+ nil
+ end
+
+ def get_attribute(ss)
+ ss.scan(/[\t\n\f\r \/]*/)
+ if ss.peek(1) == '>'
+ ss.getch
+ return nil
+ end
+ name = ss.scan(/[^=\t\n\f\r \/>]*/)
+ name.downcase!
+ raise if name.empty?
+ ss.skip(/[\t\n\f\r ]*/)
+ if ss.getch != '='
+ value = ''
+ return [name, value]
+ end
+ ss.skip(/[\t\n\f\r ]*/)
+ case ss.peek(1)
+ when '"'
+ ss.getch
+ value = ss.scan(/[^"]+/)
+ value.downcase!
+ ss.getch
+ when "'"
+ ss.getch
+ value = ss.scan(/[^']+/)
+ value.downcase!
+ ss.getch
+ when '>'
+ value = ''
+ else
+ value = ss.scan(/[^\t\n\f\r >]+/)
+ value.downcase!
+ end
+ [name, value]
+ end
+
+ def extracting_encodings_from_meta_elements(value)
+ # http://dev.w3.org/html5/spec/fetching-resources.html#algorithm-for-extracting-an-encoding-from-a-meta-element
+ if /charset[\t\n\f\r ]*=(?:"([^"]*)"|'([^']*)'|["']|\z|([^\t\n\f\r ;]+))/i =~ value
+ return $1 || $2 || $3
+ end
+ return nil
+ end
+
+ ##
+ # Checks for a supported Content-Encoding header and yields an Inflate
+ # wrapper for this response's socket when zlib is present. If the
+ # Content-Encoding is not supported or zlib is missing, the plain socket is
+ # yielded.
+ #
+ # If a Content-Range header is present, a plain socket is yielded as the
+ # bytes in the range may not be a complete deflate block.
+
+ def inflater # :nodoc:
+ return yield @socket unless Gem::Net::HTTP::HAVE_ZLIB
+ return yield @socket unless @decode_content
+ return yield @socket if self['content-range']
+
+ v = self['content-encoding']
+ case v&.downcase
+ when 'deflate', 'gzip', 'x-gzip' then
+ self.delete 'content-encoding'
+
+ inflate_body_io = Inflater.new(@socket)
+
+ begin
+ yield inflate_body_io
+ success = true
+ ensure
+ begin
+ inflate_body_io.finish
+ if self['content-length']
+ self['content-length'] = inflate_body_io.bytes_inflated.to_s
+ end
+ rescue => err
+ # Ignore #finish's error if there is an exception from yield
+ raise err if success
+ end
+ end
+ when 'none', 'identity' then
+ self.delete 'content-encoding'
+
+ yield @socket
+ else
+ yield @socket
+ end
+ end
+
+ def read_body_0(dest)
+ inflater do |inflate_body_io|
+ if chunked?
+ read_chunked dest, inflate_body_io
+ return
+ end
+
+ @socket = inflate_body_io
+
+ clen = content_length()
+ if clen
+ @socket.read clen, dest, @ignore_eof
+ return
+ end
+ clen = range_length()
+ if clen
+ @socket.read clen, dest
+ return
+ end
+ @socket.read_all dest
+ end
+ end
+
+ ##
+ # read_chunked reads from +@socket+ for chunk-size, chunk-extension, CRLF,
+ # etc. and +chunk_data_io+ for chunk-data which may be deflate or gzip
+ # encoded.
+ #
+ # See RFC 2616 section 3.6.1 for definitions
+
+ def read_chunked(dest, chunk_data_io) # :nodoc:
+ total = 0
+ while true
+ line = @socket.readline
+ hexlen = line.slice(/[0-9a-fA-F]+/) or
+ raise Gem::Net::HTTPBadResponse, "wrong chunk size line: #{line}"
+ len = hexlen.hex
+ break if len == 0
+ begin
+ chunk_data_io.read len, dest
+ ensure
+ total += len
+ @socket.read 2 # \r\n
+ end
+ end
+ until @socket.readline.empty?
+ # none
+ end
+ end
+
+ def stream_check
+ raise IOError, 'attempt to read body out of block' if @socket.nil? || @socket.closed?
+ end
+
+ def procdest(dest, block)
+ raise ArgumentError, 'both arg and block given for HTTP method' if
+ dest and block
+ if block
+ Gem::Net::ReadAdapter.new(block)
+ else
+ dest || +''
+ end
+ end
+
+ ##
+ # Inflater is a wrapper around Gem::Net::BufferedIO that transparently inflates
+ # zlib and gzip streams.
+
+ class Inflater # :nodoc:
+
+ ##
+ # Creates a new Inflater wrapping +socket+
+
+ def initialize socket
+ @socket = socket
+ # zlib with automatic gzip detection
+ @inflate = Zlib::Inflate.new(32 + Zlib::MAX_WBITS)
+ end
+
+ ##
+ # Finishes the inflate stream.
+
+ def finish
+ return if @inflate.total_in == 0
+ @inflate.finish
+ end
+
+ ##
+ # The number of bytes inflated, used to update the Content-Length of
+ # the response.
+
+ def bytes_inflated
+ @inflate.total_out
+ end
+
+ ##
+ # Returns a Gem::Net::ReadAdapter that inflates each read chunk into +dest+.
+ #
+ # This allows a large response body to be inflated without storing the
+ # entire body in memory.
+
+ def inflate_adapter(dest)
+ if dest.respond_to?(:set_encoding)
+ dest.set_encoding(Encoding::ASCII_8BIT)
+ elsif dest.respond_to?(:force_encoding)
+ dest.force_encoding(Encoding::ASCII_8BIT)
+ end
+ block = proc do |compressed_chunk|
+ @inflate.inflate(compressed_chunk) do |chunk|
+ compressed_chunk.clear
+ dest << chunk
+ end
+ end
+
+ Gem::Net::ReadAdapter.new(block)
+ end
+
+ ##
+ # Reads +clen+ bytes from the socket, inflates them, then writes them to
+ # +dest+. +ignore_eof+ is passed down to Gem::Net::BufferedIO#read
+ #
+ # Unlike Gem::Net::BufferedIO#read, this method returns more than +clen+ bytes.
+ # At this time there is no way for a user of Gem::Net::HTTPResponse to read a
+ # specific number of bytes from the HTTP response body, so this internal
+ # API does not return the same number of bytes as were requested.
+ #
+ # See https://bugs.ruby-lang.org/issues/6492 for further discussion.
+
+ def read clen, dest, ignore_eof = false
+ temp_dest = inflate_adapter(dest)
+
+ @socket.read clen, temp_dest, ignore_eof
+ end
+
+ ##
+ # Reads the rest of the socket, inflates it, then writes it to +dest+.
+
+ def read_all dest
+ temp_dest = inflate_adapter(dest)
+
+ @socket.read_all temp_dest
+ end
+
+ end
+
+end
+
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/responses.rb b/lib/rubygems/vendor/net-http/lib/net/http/responses.rb
new file mode 100644
index 0000000000..62ce1cba1b
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/responses.rb
@@ -0,0 +1,1242 @@
+# frozen_string_literal: true
+#--
+# https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
+
+module Gem::Net
+
+ # Unknown HTTP response
+ class HTTPUnknownResponse < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPError #
+ end
+
+ # Parent class for informational (1xx) HTTP response classes.
+ #
+ # An informational response indicates that the request was received and understood.
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#status.1xx].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response].
+ #
+ class HTTPInformation < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = false
+ EXCEPTION_TYPE = HTTPError #
+ end
+
+ # Parent class for success (2xx) HTTP response classes.
+ #
+ # A success response indicates the action requested by the client
+ # was received, understood, and accepted.
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#status.2xx].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success].
+ #
+ class HTTPSuccess < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPError #
+ end
+
+ # Parent class for redirection (3xx) HTTP response classes.
+ #
+ # A redirection response indicates the client must take additional action
+ # to complete the request.
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#status.3xx].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection].
+ #
+ class HTTPRedirection < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPRetriableError #
+ end
+
+ # Parent class for client error (4xx) HTTP response classes.
+ #
+ # A client error response indicates that the client may have caused an error.
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#status.4xx].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors].
+ #
+ class HTTPClientError < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPClientException #
+ end
+
+ # Parent class for server error (5xx) HTTP response classes.
+ #
+ # A server error response indicates that the server failed to fulfill a request.
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#status.5xx].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors].
+ #
+ class HTTPServerError < HTTPResponse
+ # :stopdoc:
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPFatalError #
+ end
+
+ # Response class for +Continue+ responses (status code 100).
+ #
+ # A +Continue+ response indicates that the server has received the request headers.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-100-continue].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100].
+ #
+ class HTTPContinue < HTTPInformation
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Switching Protocol</tt> responses (status code 101).
+ #
+ # The <tt>Switching Protocol<tt> response indicates that the server has received
+ # a request to switch protocols, and has agreed to do so.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-101-switching-protocols].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101].
+ #
+ class HTTPSwitchProtocol < HTTPInformation
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for +Processing+ responses (status code 102).
+ #
+ # The +Processing+ response indicates that the server has received
+ # and is processing the request, but no response is available yet.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 2518}[https://www.rfc-editor.org/rfc/rfc2518#section-10.1].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102].
+ #
+ class HTTPProcessing < HTTPInformation
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Early Hints</tt> responses (status code 103).
+ #
+ # The <tt>Early Hints</tt> indicates that the server has received
+ # and is processing the request, and contains certain headers;
+ # the final response is not available yet.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103].
+ # - {RFC 8297}[https://www.rfc-editor.org/rfc/rfc8297.html#section-2].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103].
+ #
+ class HTTPEarlyHints < HTTPInformation
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for +OK+ responses (status code 200).
+ #
+ # The +OK+ response indicates that the server has received
+ # a request and has responded successfully.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200].
+ #
+ class HTTPOK < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for +Created+ responses (status code 201).
+ #
+ # The +Created+ response indicates that the server has received
+ # and has fulfilled a request to create a new resource.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-201-created].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201].
+ #
+ class HTTPCreated < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for +Accepted+ responses (status code 202).
+ #
+ # The +Accepted+ response indicates that the server has received
+ # and is processing a request, but the processing has not yet been completed.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-202-accepted].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202].
+ #
+ class HTTPAccepted < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Non-Authoritative Information</tt> responses (status code 203).
+ #
+ # The <tt>Non-Authoritative Information</tt> response indicates that the server
+ # is a transforming proxy (such as a Web accelerator)
+ # that received a 200 OK response from its origin,
+ # and is returning a modified version of the origin's response.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/203].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-203-non-authoritative-infor].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203].
+ #
+ class HTTPNonAuthoritativeInformation < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>No Content</tt> responses (status code 204).
+ #
+ # The <tt>No Content</tt> response indicates that the server
+ # successfully processed the request, and is not returning any content.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-204-no-content].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204].
+ #
+ class HTTPNoContent < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Reset Content</tt> responses (status code 205).
+ #
+ # The <tt>Reset Content</tt> response indicates that the server
+ # successfully processed the request,
+ # asks that the client reset its document view, and is not returning any content.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/205].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-205-reset-content].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205].
+ #
+ class HTTPResetContent < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Partial Content</tt> responses (status code 206).
+ #
+ # The <tt>Partial Content</tt> response indicates that the server is delivering
+ # only part of the resource (byte serving)
+ # due to a Range header in the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-206-partial-content].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206].
+ #
+ class HTTPPartialContent < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Multi-Status (WebDAV)</tt> responses (status code 207).
+ #
+ # The <tt>Multi-Status (WebDAV)</tt> response indicates that the server
+ # has received the request,
+ # and that the message body can contain a number of separate response codes.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 4818}[https://www.rfc-editor.org/rfc/rfc4918#section-11.1].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207].
+ #
+ class HTTPMultiStatus < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Already Reported (WebDAV)</tt> responses (status code 208).
+ #
+ # The <tt>Already Reported (WebDAV)</tt> response indicates that the server
+ # has received the request,
+ # and that the members of a DAV binding have already been enumerated
+ # in a preceding part of the (multi-status) response,
+ # and are not being included again.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 5842}[https://www.rfc-editor.org/rfc/rfc5842.html#section-7.1].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208].
+ #
+ class HTTPAlreadyReported < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>IM Used</tt> responses (status code 226).
+ #
+ # The <tt>IM Used</tt> response indicates that the server has fulfilled a request
+ # for the resource, and the response is a representation of the result
+ # of one or more instance-manipulations applied to the current instance.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 3229}[https://www.rfc-editor.org/rfc/rfc3229.html#section-10.4.1].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226].
+ #
+ class HTTPIMUsed < HTTPSuccess
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Multiple Choices</tt> responses (status code 300).
+ #
+ # The <tt>Multiple Choices</tt> response indicates that the server
+ # offers multiple options for the resource from which the client may choose.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-300-multiple-choices].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300].
+ #
+ class HTTPMultipleChoices < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPMultipleChoice = HTTPMultipleChoices
+
+ # Response class for <tt>Moved Permanently</tt> responses (status code 301).
+ #
+ # The <tt>Moved Permanently</tt> response indicates that links or records
+ # returning this response should be updated to use the given URL.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-301-moved-permanently].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301].
+ #
+ class HTTPMovedPermanently < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Found</tt> responses (status code 302).
+ #
+ # The <tt>Found</tt> response indicates that the client
+ # should look at (browse to) another URL.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-302-found].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302].
+ #
+ class HTTPFound < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPMovedTemporarily = HTTPFound
+
+ # Response class for <tt>See Other</tt> responses (status code 303).
+ #
+ # The response to the request can be found under another Gem::URI using the GET method.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-303-see-other].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303].
+ #
+ class HTTPSeeOther < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Not Modified</tt> responses (status code 304).
+ #
+ # Indicates that the resource has not been modified since the version
+ # specified by the request headers.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-304-not-modified].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304].
+ #
+ class HTTPNotModified < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Use Proxy</tt> responses (status code 305).
+ #
+ # The requested resource is available only through a proxy,
+ # whose address is provided in the response.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-305-use-proxy].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305].
+ #
+ class HTTPUseProxy < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = false
+ end
+
+ # Response class for <tt>Temporary Redirect</tt> responses (status code 307).
+ #
+ # The request should be repeated with another Gem::URI;
+ # however, future requests should still use the original Gem::URI.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-307-temporary-redirect].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307].
+ #
+ class HTTPTemporaryRedirect < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Permanent Redirect</tt> responses (status code 308).
+ #
+ # This and all future requests should be directed to the given Gem::URI.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-308-permanent-redirect].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308].
+ #
+ class HTTPPermanentRedirect < HTTPRedirection
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Bad Request</tt> responses (status code 400).
+ #
+ # The server cannot or will not process the request due to an apparent client error.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400].
+ #
+ class HTTPBadRequest < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Unauthorized</tt> responses (status code 401).
+ #
+ # Authentication is required, but either was not provided or failed.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401].
+ #
+ class HTTPUnauthorized < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Payment Required</tt> responses (status code 402).
+ #
+ # Reserved for future use.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-402-payment-required].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402].
+ #
+ class HTTPPaymentRequired < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Forbidden</tt> responses (status code 403).
+ #
+ # The request contained valid data and was understood by the server,
+ # but the server is refusing action.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403].
+ #
+ class HTTPForbidden < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Not Found</tt> responses (status code 404).
+ #
+ # The requested resource could not be found but may be available in the future.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404].
+ #
+ class HTTPNotFound < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Method Not Allowed</tt> responses (status code 405).
+ #
+ # The request method is not supported for the requested resource.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-405-method-not-allowed].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405].
+ #
+ class HTTPMethodNotAllowed < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Not Acceptable</tt> responses (status code 406).
+ #
+ # The requested resource is capable of generating only content
+ # that not acceptable according to the Accept headers sent in the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-406-not-acceptable].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406].
+ #
+ class HTTPNotAcceptable < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Proxy Authentication Required</tt> responses (status code 407).
+ #
+ # The client must first authenticate itself with the proxy.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-407-proxy-authentication-re].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407].
+ #
+ class HTTPProxyAuthenticationRequired < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Request Gem::Timeout</tt> responses (status code 408).
+ #
+ # The server timed out waiting for the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-408-request-timeout].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408].
+ #
+ class HTTPRequestTimeout < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPRequestTimeOut = HTTPRequestTimeout
+
+ # Response class for <tt>Conflict</tt> responses (status code 409).
+ #
+ # The request could not be processed because of conflict in the current state of the resource.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409].
+ #
+ class HTTPConflict < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Gone</tt> responses (status code 410).
+ #
+ # The resource requested was previously in use but is no longer available
+ # and will not be available again.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-410-gone].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410].
+ #
+ class HTTPGone < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Length Required</tt> responses (status code 411).
+ #
+ # The request did not specify the length of its content,
+ # which is required by the requested resource.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-411-length-required].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411].
+ #
+ class HTTPLengthRequired < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Precondition Failed</tt> responses (status code 412).
+ #
+ # The server does not meet one of the preconditions
+ # specified in the request headers.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-412-precondition-failed].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412].
+ #
+ class HTTPPreconditionFailed < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Payload Too Large</tt> responses (status code 413).
+ #
+ # The request is larger than the server is willing or able to process.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-large].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413].
+ #
+ class HTTPPayloadTooLarge < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPRequestEntityTooLarge = HTTPPayloadTooLarge
+
+ # Response class for <tt>Gem::URI Too Long</tt> responses (status code 414).
+ #
+ # The Gem::URI provided was too long for the server to process.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-414-uri-too-long].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414].
+ #
+ class HTTPURITooLong < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPRequestURITooLong = HTTPURITooLong
+ HTTPRequestURITooLarge = HTTPRequestURITooLong
+
+ # Response class for <tt>Unsupported Media Type</tt> responses (status code 415).
+ #
+ # The request entity has a media type which the server or resource does not support.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-415-unsupported-media-type].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415].
+ #
+ class HTTPUnsupportedMediaType < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Range Not Satisfiable</tt> responses (status code 416).
+ #
+ # The request entity has a media type which the server or resource does not support.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-416-range-not-satisfiable].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416].
+ #
+ class HTTPRangeNotSatisfiable < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable
+
+ # Response class for <tt>Expectation Failed</tt> responses (status code 417).
+ #
+ # The server cannot meet the requirements of the Expect request-header field.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/417].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-417-expectation-failed].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417].
+ #
+ class HTTPExpectationFailed < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # 418 I'm a teapot - RFC 2324; a joke RFC
+ # See https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#418.
+
+ # 420 Enhance Your Calm - Twitter
+
+ # Response class for <tt>Misdirected Request</tt> responses (status code 421).
+ #
+ # The request was directed at a server that is not able to produce a response.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-421-misdirected-request].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421].
+ #
+ class HTTPMisdirectedRequest < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Unprocessable Entity</tt> responses (status code 422).
+ #
+ # The request was well-formed but had semantic errors.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-content].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422].
+ #
+ class HTTPUnprocessableEntity < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Locked (WebDAV)</tt> responses (status code 423).
+ #
+ # The requested resource is locked.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 4918}[https://www.rfc-editor.org/rfc/rfc4918#section-11.3].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423].
+ #
+ class HTTPLocked < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Failed Dependency (WebDAV)</tt> responses (status code 424).
+ #
+ # The request failed because it depended on another request and that request failed.
+ # See {424 Failed Dependency (WebDAV)}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424].
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {RFC 4918}[https://www.rfc-editor.org/rfc/rfc4918#section-11.4].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424].
+ #
+ class HTTPFailedDependency < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # 425 Too Early
+ # https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#425.
+
+ # Response class for <tt>Upgrade Required</tt> responses (status code 426).
+ #
+ # The client should switch to the protocol given in the Upgrade header field.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/426].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-426-upgrade-required].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426].
+ #
+ class HTTPUpgradeRequired < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Precondition Required</tt> responses (status code 428).
+ #
+ # The origin server requires the request to be conditional.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428].
+ # - {RFC 6585}[https://www.rfc-editor.org/rfc/rfc6585#section-3].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428].
+ #
+ class HTTPPreconditionRequired < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Too Many Requests</tt> responses (status code 429).
+ #
+ # The user has sent too many requests in a given amount of time.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429].
+ # - {RFC 6585}[https://www.rfc-editor.org/rfc/rfc6585#section-4].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429].
+ #
+ class HTTPTooManyRequests < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Request Header Fields Too Large</tt> responses (status code 431).
+ #
+ # An individual header field is too large,
+ # or all the header fields collectively, are too large.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/431].
+ # - {RFC 6585}[https://www.rfc-editor.org/rfc/rfc6585#section-5].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431].
+ #
+ class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Unavailable For Legal Reasons</tt> responses (status code 451).
+ #
+ # A server operator has received a legal demand to deny access to a resource or to a set of resources
+ # that includes the requested resource.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451].
+ # - {RFC 7725}[https://www.rfc-editor.org/rfc/rfc7725.html#section-3].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451].
+ #
+ class HTTPUnavailableForLegalReasons < HTTPClientError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ # 444 No Response - Nginx
+ # 449 Retry With - Microsoft
+ # 450 Blocked by Windows Parental Controls - Microsoft
+ # 499 Client Closed Request - Nginx
+
+ # Response class for <tt>Internal Server Error</tt> responses (status code 500).
+ #
+ # An unexpected condition was encountered and no more specific message is suitable.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-500-internal-server-error].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500].
+ #
+ class HTTPInternalServerError < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Not Implemented</tt> responses (status code 501).
+ #
+ # The server either does not recognize the request method,
+ # or it lacks the ability to fulfil the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501].
+ #
+ class HTTPNotImplemented < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Bad Gateway</tt> responses (status code 502).
+ #
+ # The server was acting as a gateway or proxy
+ # and received an invalid response from the upstream server.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-502-bad-gateway].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502].
+ #
+ class HTTPBadGateway < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Service Unavailable</tt> responses (status code 503).
+ #
+ # The server cannot handle the request
+ # (because it is overloaded or down for maintenance).
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-503-service-unavailable].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503].
+ #
+ class HTTPServiceUnavailable < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Gateway Gem::Timeout</tt> responses (status code 504).
+ #
+ # The server was acting as a gateway or proxy
+ # and did not receive a timely response from the upstream server.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-504-gateway-timeout].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504].
+ #
+ class HTTPGatewayTimeout < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ HTTPGatewayTimeOut = HTTPGatewayTimeout
+
+ # Response class for <tt>HTTP Version Not Supported</tt> responses (status code 505).
+ #
+ # The server does not support the HTTP version used in the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/505].
+ # - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-505-http-version-not-suppor].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505].
+ #
+ class HTTPVersionNotSupported < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Variant Also Negotiates</tt> responses (status code 506).
+ #
+ # Transparent content negotiation for the request results in a circular reference.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506].
+ # - {RFC 2295}[https://www.rfc-editor.org/rfc/rfc2295#section-8.1].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506].
+ #
+ class HTTPVariantAlsoNegotiates < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Insufficient Storage (WebDAV)</tt> responses (status code 507).
+ #
+ # The server is unable to store the representation needed to complete the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507].
+ # - {RFC 4918}[https://www.rfc-editor.org/rfc/rfc4918#section-11.5].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507].
+ #
+ class HTTPInsufficientStorage < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Loop Detected (WebDAV)</tt> responses (status code 508).
+ #
+ # The server detected an infinite loop while processing the request.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508].
+ # - {RFC 5942}[https://www.rfc-editor.org/rfc/rfc5842.html#section-7.2].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508].
+ #
+ class HTTPLoopDetected < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+ # 509 Bandwidth Limit Exceeded - Apache bw/limited extension
+
+ # Response class for <tt>Not Extended</tt> responses (status code 510).
+ #
+ # Further extensions to the request are required for the server to fulfill it.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510].
+ # - {RFC 2774}[https://www.rfc-editor.org/rfc/rfc2774.html#section-7].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510].
+ #
+ class HTTPNotExtended < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+ # Response class for <tt>Network Authentication Required</tt> responses (status code 511).
+ #
+ # The client needs to authenticate to gain network access.
+ #
+ # :include: doc/net-http/included_getters.rdoc
+ #
+ # References:
+ #
+ # - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511].
+ # - {RFC 6585}[https://www.rfc-editor.org/rfc/rfc6585#section-6].
+ # - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511].
+ #
+ class HTTPNetworkAuthenticationRequired < HTTPServerError
+ # :stopdoc:
+ HAS_BODY = true
+ end
+
+end
+
+class Gem::Net::HTTPResponse
+ # :stopdoc:
+ CODE_CLASS_TO_OBJ = {
+ '1' => Gem::Net::HTTPInformation,
+ '2' => Gem::Net::HTTPSuccess,
+ '3' => Gem::Net::HTTPRedirection,
+ '4' => Gem::Net::HTTPClientError,
+ '5' => Gem::Net::HTTPServerError
+ }.freeze
+ CODE_TO_OBJ = {
+ '100' => Gem::Net::HTTPContinue,
+ '101' => Gem::Net::HTTPSwitchProtocol,
+ '102' => Gem::Net::HTTPProcessing,
+ '103' => Gem::Net::HTTPEarlyHints,
+
+ '200' => Gem::Net::HTTPOK,
+ '201' => Gem::Net::HTTPCreated,
+ '202' => Gem::Net::HTTPAccepted,
+ '203' => Gem::Net::HTTPNonAuthoritativeInformation,
+ '204' => Gem::Net::HTTPNoContent,
+ '205' => Gem::Net::HTTPResetContent,
+ '206' => Gem::Net::HTTPPartialContent,
+ '207' => Gem::Net::HTTPMultiStatus,
+ '208' => Gem::Net::HTTPAlreadyReported,
+ '226' => Gem::Net::HTTPIMUsed,
+
+ '300' => Gem::Net::HTTPMultipleChoices,
+ '301' => Gem::Net::HTTPMovedPermanently,
+ '302' => Gem::Net::HTTPFound,
+ '303' => Gem::Net::HTTPSeeOther,
+ '304' => Gem::Net::HTTPNotModified,
+ '305' => Gem::Net::HTTPUseProxy,
+ '307' => Gem::Net::HTTPTemporaryRedirect,
+ '308' => Gem::Net::HTTPPermanentRedirect,
+
+ '400' => Gem::Net::HTTPBadRequest,
+ '401' => Gem::Net::HTTPUnauthorized,
+ '402' => Gem::Net::HTTPPaymentRequired,
+ '403' => Gem::Net::HTTPForbidden,
+ '404' => Gem::Net::HTTPNotFound,
+ '405' => Gem::Net::HTTPMethodNotAllowed,
+ '406' => Gem::Net::HTTPNotAcceptable,
+ '407' => Gem::Net::HTTPProxyAuthenticationRequired,
+ '408' => Gem::Net::HTTPRequestTimeout,
+ '409' => Gem::Net::HTTPConflict,
+ '410' => Gem::Net::HTTPGone,
+ '411' => Gem::Net::HTTPLengthRequired,
+ '412' => Gem::Net::HTTPPreconditionFailed,
+ '413' => Gem::Net::HTTPPayloadTooLarge,
+ '414' => Gem::Net::HTTPURITooLong,
+ '415' => Gem::Net::HTTPUnsupportedMediaType,
+ '416' => Gem::Net::HTTPRangeNotSatisfiable,
+ '417' => Gem::Net::HTTPExpectationFailed,
+ '421' => Gem::Net::HTTPMisdirectedRequest,
+ '422' => Gem::Net::HTTPUnprocessableEntity,
+ '423' => Gem::Net::HTTPLocked,
+ '424' => Gem::Net::HTTPFailedDependency,
+ '426' => Gem::Net::HTTPUpgradeRequired,
+ '428' => Gem::Net::HTTPPreconditionRequired,
+ '429' => Gem::Net::HTTPTooManyRequests,
+ '431' => Gem::Net::HTTPRequestHeaderFieldsTooLarge,
+ '451' => Gem::Net::HTTPUnavailableForLegalReasons,
+
+ '500' => Gem::Net::HTTPInternalServerError,
+ '501' => Gem::Net::HTTPNotImplemented,
+ '502' => Gem::Net::HTTPBadGateway,
+ '503' => Gem::Net::HTTPServiceUnavailable,
+ '504' => Gem::Net::HTTPGatewayTimeout,
+ '505' => Gem::Net::HTTPVersionNotSupported,
+ '506' => Gem::Net::HTTPVariantAlsoNegotiates,
+ '507' => Gem::Net::HTTPInsufficientStorage,
+ '508' => Gem::Net::HTTPLoopDetected,
+ '510' => Gem::Net::HTTPNotExtended,
+ '511' => Gem::Net::HTTPNetworkAuthenticationRequired,
+ }.freeze
+end
diff --git a/lib/rubygems/vendor/net-http/lib/net/http/status.rb b/lib/rubygems/vendor/net-http/lib/net/http/status.rb
new file mode 100644
index 0000000000..9110b108b8
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/http/status.rb
@@ -0,0 +1,84 @@
+# frozen_string_literal: true
+
+require_relative '../http'
+
+if $0 == __FILE__
+ require 'open-uri'
+ File.foreach(__FILE__) do |line|
+ puts line
+ break if line.start_with?('end')
+ end
+ puts
+ puts "Gem::Net::HTTP::STATUS_CODES = {"
+ url = "https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv"
+ Gem::URI(url).read.each_line do |line|
+ code, mes, = line.split(',')
+ next if ['(Unused)', 'Unassigned', 'Description'].include?(mes)
+ puts " #{code} => '#{mes}',"
+ end
+ puts "} # :nodoc:"
+end
+
+Gem::Net::HTTP::STATUS_CODES = {
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+ 102 => 'Processing',
+ 103 => 'Early Hints',
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+ 207 => 'Multi-Status',
+ 208 => 'Already Reported',
+ 226 => 'IM Used',
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 307 => 'Temporary Redirect',
+ 308 => 'Permanent 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 => 'Content Too Large',
+ 414 => 'URI Too Long',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Range Not Satisfiable',
+ 417 => 'Expectation Failed',
+ 421 => 'Misdirected Request',
+ 422 => 'Unprocessable Content',
+ 423 => 'Locked',
+ 424 => 'Failed Dependency',
+ 425 => 'Too Early',
+ 426 => 'Upgrade Required',
+ 428 => 'Precondition Required',
+ 429 => 'Too Many Requests',
+ 431 => 'Request Header Fields Too Large',
+ 451 => 'Unavailable For Legal Reasons',
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Timeout',
+ 505 => 'HTTP Version Not Supported',
+ 506 => 'Variant Also Negotiates',
+ 507 => 'Insufficient Storage',
+ 508 => 'Loop Detected',
+ 510 => 'Not Extended (OBSOLETED)',
+ 511 => 'Network Authentication Required',
+} # :nodoc:
diff --git a/lib/rubygems/vendor/net-http/lib/net/https.rb b/lib/rubygems/vendor/net-http/lib/net/https.rb
new file mode 100644
index 0000000000..f104c85c81
--- /dev/null
+++ b/lib/rubygems/vendor/net-http/lib/net/https.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+=begin
+
+= net/https -- SSL/TLS enhancement for Gem::Net::HTTP.
+
+ This file has been merged with net/http. There is no longer any need to
+ require_relative 'https' to use HTTPS.
+
+ See Gem::Net::HTTP for details on how to make HTTPS connections.
+
+== Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ All rights reserved.
+
+== Licence
+ This program is licensed under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+=end
+
+require_relative 'http'
+require 'openssl'
diff --git a/lib/rubygems/vendor/net-protocol/lib/net/protocol.rb b/lib/rubygems/vendor/net-protocol/lib/net/protocol.rb
new file mode 100644
index 0000000000..53d34d8d98
--- /dev/null
+++ b/lib/rubygems/vendor/net-protocol/lib/net/protocol.rb
@@ -0,0 +1,544 @@
+# frozen_string_literal: true
+#
+# = net/protocol.rb
+#
+#--
+# Copyright (c) 1999-2004 Yukihiro Matsumoto
+# Copyright (c) 1999-2004 Minero Aoki
+#
+# written and maintained by Minero Aoki <aamine@loveruby.net>
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms as Ruby itself,
+# Ruby Distribute License or GNU General Public License.
+#
+# $Id$
+#++
+#
+# WARNING: This file is going to remove.
+# Do not rely on the implementation written in this file.
+#
+
+require 'socket'
+require_relative '../../../timeout/lib/timeout'
+require 'io/wait'
+
+module Gem::Net # :nodoc:
+
+ class Protocol #:nodoc: internal use only
+ VERSION = "0.2.2"
+
+ private
+ def Protocol.protocol_param(name, val)
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def #{name}
+ #{val}
+ end
+ End
+ end
+
+ def ssl_socket_connect(s, timeout)
+ if timeout
+ while true
+ raise Gem::Net::OpenTimeout if timeout <= 0
+ start = Process.clock_gettime Process::CLOCK_MONOTONIC
+ # to_io is required because SSLSocket doesn't have wait_readable yet
+ case s.connect_nonblock(exception: false)
+ when :wait_readable; s.to_io.wait_readable(timeout)
+ when :wait_writable; s.to_io.wait_writable(timeout)
+ else; break
+ end
+ timeout -= Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
+ end
+ else
+ s.connect
+ end
+ end
+ end
+
+
+ class ProtocolError < StandardError; end
+ class ProtoSyntaxError < ProtocolError; end
+ class ProtoFatalError < ProtocolError; end
+ class ProtoUnknownError < ProtocolError; end
+ class ProtoServerError < ProtocolError; end
+ class ProtoAuthError < ProtocolError; end
+ class ProtoCommandError < ProtocolError; end
+ class ProtoRetriableError < ProtocolError; end
+ ProtocRetryError = ProtoRetriableError
+
+ ##
+ # OpenTimeout, a subclass of Gem::Timeout::Error, is raised if a connection cannot
+ # be created within the open_timeout.
+
+ class OpenTimeout < Gem::Timeout::Error; end
+
+ ##
+ # ReadTimeout, a subclass of Gem::Timeout::Error, is raised if a chunk of the
+ # response cannot be read within the read_timeout.
+
+ class ReadTimeout < Gem::Timeout::Error
+ def initialize(io = nil)
+ @io = io
+ end
+ attr_reader :io
+
+ def message
+ msg = super
+ if @io
+ msg = "#{msg} with #{@io.inspect}"
+ end
+ msg
+ end
+ end
+
+ ##
+ # WriteTimeout, a subclass of Gem::Timeout::Error, is raised if a chunk of the
+ # response cannot be written within the write_timeout. Not raised on Windows.
+
+ class WriteTimeout < Gem::Timeout::Error
+ def initialize(io = nil)
+ @io = io
+ end
+ attr_reader :io
+
+ def message
+ msg = super
+ if @io
+ msg = "#{msg} with #{@io.inspect}"
+ end
+ msg
+ end
+ end
+
+
+ class BufferedIO #:nodoc: internal use only
+ def initialize(io, read_timeout: 60, write_timeout: 60, continue_timeout: nil, debug_output: nil)
+ @io = io
+ @read_timeout = read_timeout
+ @write_timeout = write_timeout
+ @continue_timeout = continue_timeout
+ @debug_output = debug_output
+ @rbuf = ''.b
+ @rbuf_empty = true
+ @rbuf_offset = 0
+ end
+
+ attr_reader :io
+ attr_accessor :read_timeout
+ attr_accessor :write_timeout
+ attr_accessor :continue_timeout
+ attr_accessor :debug_output
+
+ def inspect
+ "#<#{self.class} io=#{@io}>"
+ end
+
+ def eof?
+ @io.eof?
+ end
+
+ def closed?
+ @io.closed?
+ end
+
+ def close
+ @io.close
+ end
+
+ #
+ # Read
+ #
+
+ public
+
+ def read(len, dest = ''.b, ignore_eof = false)
+ LOG "reading #{len} bytes..."
+ read_bytes = 0
+ begin
+ while read_bytes + rbuf_size < len
+ if s = rbuf_consume_all
+ read_bytes += s.bytesize
+ dest << s
+ end
+ rbuf_fill
+ end
+ s = rbuf_consume(len - read_bytes)
+ read_bytes += s.bytesize
+ dest << s
+ rescue EOFError
+ raise unless ignore_eof
+ end
+ LOG "read #{read_bytes} bytes"
+ dest
+ end
+
+ def read_all(dest = ''.b)
+ LOG 'reading all...'
+ read_bytes = 0
+ begin
+ while true
+ if s = rbuf_consume_all
+ read_bytes += s.bytesize
+ dest << s
+ end
+ rbuf_fill
+ end
+ rescue EOFError
+ ;
+ end
+ LOG "read #{read_bytes} bytes"
+ dest
+ end
+
+ def readuntil(terminator, ignore_eof = false)
+ offset = @rbuf_offset
+ begin
+ until idx = @rbuf.index(terminator, offset)
+ offset = @rbuf.bytesize
+ rbuf_fill
+ end
+ return rbuf_consume(idx + terminator.bytesize - @rbuf_offset)
+ rescue EOFError
+ raise unless ignore_eof
+ return rbuf_consume
+ end
+ end
+
+ def readline
+ readuntil("\n").chop
+ end
+
+ private
+
+ BUFSIZE = 1024 * 16
+
+ def rbuf_fill
+ tmp = @rbuf_empty ? @rbuf : nil
+ case rv = @io.read_nonblock(BUFSIZE, tmp, exception: false)
+ when String
+ @rbuf_empty = false
+ if rv.equal?(tmp)
+ @rbuf_offset = 0
+ else
+ @rbuf << rv
+ rv.clear
+ end
+ return
+ when :wait_readable
+ (io = @io.to_io).wait_readable(@read_timeout) or raise Gem::Net::ReadTimeout.new(io)
+ # continue looping
+ when :wait_writable
+ # OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable.
+ # http://www.openssl.org/support/faq.html#PROG10
+ (io = @io.to_io).wait_writable(@read_timeout) or raise Gem::Net::ReadTimeout.new(io)
+ # continue looping
+ when nil
+ raise EOFError, 'end of file reached'
+ end while true
+ end
+
+ def rbuf_flush
+ if @rbuf_empty
+ @rbuf.clear
+ @rbuf_offset = 0
+ end
+ nil
+ end
+
+ def rbuf_size
+ @rbuf.bytesize - @rbuf_offset
+ end
+
+ def rbuf_consume_all
+ rbuf_consume if rbuf_size > 0
+ end
+
+ def rbuf_consume(len = nil)
+ if @rbuf_offset == 0 && (len.nil? || len == @rbuf.bytesize)
+ s = @rbuf
+ @rbuf = ''.b
+ @rbuf_offset = 0
+ @rbuf_empty = true
+ elsif len.nil?
+ s = @rbuf.byteslice(@rbuf_offset..-1)
+ @rbuf = ''.b
+ @rbuf_offset = 0
+ @rbuf_empty = true
+ else
+ s = @rbuf.byteslice(@rbuf_offset, len)
+ @rbuf_offset += len
+ @rbuf_empty = @rbuf_offset == @rbuf.bytesize
+ rbuf_flush
+ end
+
+ @debug_output << %Q[-> #{s.dump}\n] if @debug_output
+ s
+ end
+
+ #
+ # Write
+ #
+
+ public
+
+ def write(*strs)
+ writing {
+ write0(*strs)
+ }
+ end
+
+ alias << write
+
+ def writeline(str)
+ writing {
+ write0 str + "\r\n"
+ }
+ end
+
+ private
+
+ def writing
+ @written_bytes = 0
+ @debug_output << '<- ' if @debug_output
+ yield
+ @debug_output << "\n" if @debug_output
+ bytes = @written_bytes
+ @written_bytes = nil
+ bytes
+ end
+
+ def write0(*strs)
+ @debug_output << strs.map(&:dump).join if @debug_output
+ orig_written_bytes = @written_bytes
+ strs.each_with_index do |str, i|
+ need_retry = true
+ case len = @io.write_nonblock(str, exception: false)
+ when Integer
+ @written_bytes += len
+ len -= str.bytesize
+ if len == 0
+ if strs.size == i+1
+ return @written_bytes - orig_written_bytes
+ else
+ need_retry = false
+ # next string
+ end
+ elsif len < 0
+ str = str.byteslice(len, -len)
+ else # len > 0
+ need_retry = false
+ # next string
+ end
+ # continue looping
+ when :wait_writable
+ (io = @io.to_io).wait_writable(@write_timeout) or raise Gem::Net::WriteTimeout.new(io)
+ # continue looping
+ end while need_retry
+ end
+ end
+
+ #
+ # Logging
+ #
+
+ private
+
+ def LOG_off
+ @save_debug_out = @debug_output
+ @debug_output = nil
+ end
+
+ def LOG_on
+ @debug_output = @save_debug_out
+ end
+
+ def LOG(msg)
+ return unless @debug_output
+ @debug_output << msg + "\n"
+ end
+ end
+
+
+ class InternetMessageIO < BufferedIO #:nodoc: internal use only
+ def initialize(*, **)
+ super
+ @wbuf = nil
+ end
+
+ #
+ # Read
+ #
+
+ def each_message_chunk
+ LOG 'reading message...'
+ LOG_off()
+ read_bytes = 0
+ while (line = readuntil("\r\n")) != ".\r\n"
+ read_bytes += line.size
+ yield line.delete_prefix('.')
+ end
+ LOG_on()
+ LOG "read message (#{read_bytes} bytes)"
+ end
+
+ # *library private* (cannot handle 'break')
+ def each_list_item
+ while (str = readuntil("\r\n")) != ".\r\n"
+ yield str.chop
+ end
+ end
+
+ def write_message_0(src)
+ prev = @written_bytes
+ each_crlf_line(src) do |line|
+ write0 dot_stuff(line)
+ end
+ @written_bytes - prev
+ end
+
+ #
+ # Write
+ #
+
+ def write_message(src)
+ LOG "writing message from #{src.class}"
+ LOG_off()
+ len = writing {
+ using_each_crlf_line {
+ write_message_0 src
+ }
+ }
+ LOG_on()
+ LOG "wrote #{len} bytes"
+ len
+ end
+
+ def write_message_by_block(&block)
+ LOG 'writing message from block'
+ LOG_off()
+ len = writing {
+ using_each_crlf_line {
+ begin
+ block.call(WriteAdapter.new(self.method(:write_message_0)))
+ rescue LocalJumpError
+ # allow `break' from writer block
+ end
+ }
+ }
+ LOG_on()
+ LOG "wrote #{len} bytes"
+ len
+ end
+
+ private
+
+ def dot_stuff(s)
+ s.sub(/\A\./, '..')
+ end
+
+ def using_each_crlf_line
+ @wbuf = ''.b
+ yield
+ if not @wbuf.empty? # unterminated last line
+ write0 dot_stuff(@wbuf.chomp) + "\r\n"
+ elsif @written_bytes == 0 # empty src
+ write0 "\r\n"
+ end
+ write0 ".\r\n"
+ @wbuf = nil
+ end
+
+ def each_crlf_line(src)
+ buffer_filling(@wbuf, src) do
+ while line = @wbuf.slice!(/\A[^\r\n]*(?:\n|\r(?:\n|(?!\z)))/)
+ yield line.chomp("\n") + "\r\n"
+ end
+ end
+ end
+
+ def buffer_filling(buf, src)
+ case src
+ when String # for speeding up.
+ 0.step(src.size - 1, 1024) do |i|
+ buf << src[i, 1024]
+ yield
+ end
+ when File # for speeding up.
+ while s = src.read(1024)
+ buf << s
+ yield
+ end
+ else # generic reader
+ src.each do |str|
+ buf << str
+ yield if buf.size > 1024
+ end
+ yield unless buf.empty?
+ end
+ end
+ end
+
+
+ #
+ # The writer adapter class
+ #
+ class WriteAdapter
+ def initialize(writer)
+ @writer = writer
+ end
+
+ def inspect
+ "#<#{self.class} writer=#{@writer.inspect}>"
+ end
+
+ def write(str)
+ @writer.call(str)
+ end
+
+ alias print write
+
+ def <<(str)
+ write str
+ self
+ end
+
+ def puts(str = '')
+ write str.chomp("\n") + "\n"
+ end
+
+ def printf(*args)
+ write sprintf(*args)
+ end
+ end
+
+
+ class ReadAdapter #:nodoc: internal use only
+ def initialize(block)
+ @block = block
+ end
+
+ def inspect
+ "#<#{self.class}>"
+ end
+
+ def <<(str)
+ call_block(str, &@block) if @block
+ end
+
+ private
+
+ # This method is needed because @block must be called by yield,
+ # not Proc#call. You can see difference when using `break' in
+ # the block.
+ def call_block(str)
+ yield str
+ end
+ end
+
+
+ module NetPrivate #:nodoc: obsolete
+ Socket = ::Gem::Net::InternetMessageIO
+ end
+
+end # module Gem::Net
diff --git a/lib/rubygems/optparse/lib/optionparser.rb b/lib/rubygems/vendor/optparse/lib/optionparser.rb
index 4b9b40d82a..4b9b40d82a 100644
--- a/lib/rubygems/optparse/lib/optionparser.rb
+++ b/lib/rubygems/vendor/optparse/lib/optionparser.rb
diff --git a/lib/rubygems/vendor/optparse/lib/optparse.rb b/lib/rubygems/vendor/optparse/lib/optparse.rb
new file mode 100644
index 0000000000..d39d9dd4e0
--- /dev/null
+++ b/lib/rubygems/vendor/optparse/lib/optparse.rb
@@ -0,0 +1,2467 @@
+# frozen_string_literal: true
+#
+# optparse.rb - command-line option analysis with the Gem::OptionParser class.
+#
+# Author:: Nobu Nakada
+# Documentation:: Nobu Nakada and Gavin Sinclair.
+#
+# See Gem::OptionParser for documentation.
+#
+require 'set' unless defined?(Set)
+
+#--
+# == Developer Documentation (not for RDoc output)
+#
+# === Class tree
+#
+# - Gem::OptionParser:: front end
+# - Gem::OptionParser::Switch:: each switches
+# - Gem::OptionParser::List:: options list
+# - Gem::OptionParser::ParseError:: errors on parsing
+# - Gem::OptionParser::AmbiguousOption
+# - Gem::OptionParser::NeedlessArgument
+# - Gem::OptionParser::MissingArgument
+# - Gem::OptionParser::InvalidOption
+# - Gem::OptionParser::InvalidArgument
+# - Gem::OptionParser::AmbiguousArgument
+#
+# === Object relationship diagram
+#
+# +--------------+
+# | Gem::OptionParser |<>-----+
+# +--------------+ | +--------+
+# | ,-| Switch |
+# on_head -------->+---------------+ / +--------+
+# accept/reject -->| List |<|>-
+# | |<|>- +----------+
+# on ------------->+---------------+ `-| argument |
+# : : | class |
+# +---------------+ |==========|
+# on_tail -------->| | |pattern |
+# +---------------+ |----------|
+# Gem::OptionParser.accept ->| DefaultList | |converter |
+# reject |(shared between| +----------+
+# | all instances)|
+# +---------------+
+#
+#++
+#
+# == Gem::OptionParser
+#
+# === New to +Gem::OptionParser+?
+#
+# See the {Tutorial}[optparse/tutorial.rdoc].
+#
+# === Introduction
+#
+# Gem::OptionParser is a class for command-line option analysis. It is much more
+# advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented
+# solution.
+#
+# === Features
+#
+# 1. The argument specification and the code to handle it are written in the
+# same place.
+# 2. It can output an option summary; you don't need to maintain this string
+# separately.
+# 3. Optional and mandatory arguments are specified very gracefully.
+# 4. Arguments can be automatically converted to a specified class.
+# 5. Arguments can be restricted to a certain set.
+#
+# All of these features are demonstrated in the examples below. See
+# #make_switch for full documentation.
+#
+# === Minimal example
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+#
+# options = {}
+# Gem::OptionParser.new do |parser|
+# parser.banner = "Usage: example.rb [options]"
+#
+# parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
+# options[:verbose] = v
+# end
+# end.parse!
+#
+# p options
+# p ARGV
+#
+# === Generating Help
+#
+# Gem::OptionParser can be used to automatically generate help for the commands you
+# write:
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+#
+# Options = Struct.new(:name)
+#
+# class Parser
+# def self.parse(options)
+# args = Options.new("world")
+#
+# opt_parser = Gem::OptionParser.new do |parser|
+# parser.banner = "Usage: example.rb [options]"
+#
+# parser.on("-nNAME", "--name=NAME", "Name to say hello to") do |n|
+# args.name = n
+# end
+#
+# parser.on("-h", "--help", "Prints this help") do
+# puts parser
+# exit
+# end
+# end
+#
+# opt_parser.parse!(options)
+# return args
+# end
+# end
+# options = Parser.parse %w[--help]
+#
+# #=>
+# # Usage: example.rb [options]
+# # -n, --name=NAME Name to say hello to
+# # -h, --help Prints this help
+#
+# === Required Arguments
+#
+# For options that require an argument, option specification strings may include an
+# option name in all caps. If an option is used without the required argument,
+# an exception will be raised.
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+#
+# options = {}
+# Gem::OptionParser.new do |parser|
+# parser.on("-r", "--require LIBRARY",
+# "Require the LIBRARY before executing your script") do |lib|
+# puts "You required #{lib}!"
+# end
+# end.parse!
+#
+# Used:
+#
+# $ ruby optparse-test.rb -r
+# optparse-test.rb:9:in '<main>': missing argument: -r (Gem::OptionParser::MissingArgument)
+# $ ruby optparse-test.rb -r my-library
+# You required my-library!
+#
+# === Type Coercion
+#
+# Gem::OptionParser supports the ability to coerce command line arguments
+# into objects for us.
+#
+# Gem::OptionParser comes with a few ready-to-use kinds of type
+# coercion. They are:
+#
+# - Date -- Anything accepted by +Date.parse+ (need to require +optparse/date+)
+# - DateTime -- Anything accepted by +DateTime.parse+ (need to require +optparse/date+)
+# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+ (need to require +optparse/time+)
+# - URI -- Anything accepted by +Gem::URI.parse+ (need to require +optparse/uri+)
+# - Shellwords -- Anything accepted by +Shellwords.shellwords+ (need to require +optparse/shellwords+)
+# - String -- Any non-empty string
+# - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
+# - Float -- Any float. (e.g. 10, 3.14, -100E+13)
+# - Numeric -- Any integer, float, or rational (1, 3.4, 1/3)
+# - DecimalInteger -- Like +Integer+, but no octal format.
+# - OctalInteger -- Like +Integer+, but no decimal format.
+# - DecimalNumeric -- Decimal integer or float.
+# - TrueClass -- Accepts '+, yes, true, -, no, false' and
+# defaults as +true+
+# - FalseClass -- Same as +TrueClass+, but defaults to +false+
+# - Array -- Strings separated by ',' (e.g. 1,2,3)
+# - Regexp -- Regular expressions. Also includes options.
+#
+# We can also add our own coercions, which we will cover below.
+#
+# ==== Using Built-in Conversions
+#
+# As an example, the built-in +Time+ conversion is used. The other built-in
+# conversions behave in the same way.
+# Gem::OptionParser will attempt to parse the argument
+# as a +Time+. If it succeeds, that time will be passed to the
+# handler block. Otherwise, an exception will be raised.
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+# require 'rubygems/vendor/optparse/lib/optparse/time'
+# Gem::OptionParser.new do |parser|
+# parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
+# p time
+# end
+# end.parse!
+#
+# Used:
+#
+# $ ruby optparse-test.rb -t nonsense
+# ... invalid argument: -t nonsense (Gem::OptionParser::InvalidArgument)
+# $ ruby optparse-test.rb -t 10-11-12
+# 2010-11-12 00:00:00 -0500
+# $ ruby optparse-test.rb -t 9:30
+# 2014-08-13 09:30:00 -0400
+#
+# ==== Creating Custom Conversions
+#
+# The +accept+ method on Gem::OptionParser may be used to create converters.
+# It specifies which conversion block to call whenever a class is specified.
+# The example below uses it to fetch a +User+ object before the +on+ handler receives it.
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+#
+# User = Struct.new(:id, :name)
+#
+# def find_user id
+# not_found = ->{ raise "No User Found for id #{id}" }
+# [ User.new(1, "Sam"),
+# User.new(2, "Gandalf") ].find(not_found) do |u|
+# u.id == id
+# end
+# end
+#
+# op = Gem::OptionParser.new
+# op.accept(User) do |user_id|
+# find_user user_id.to_i
+# end
+#
+# op.on("--user ID", User) do |user|
+# puts user
+# end
+#
+# op.parse!
+#
+# Used:
+#
+# $ ruby optparse-test.rb --user 1
+# #<struct User id=1, name="Sam">
+# $ ruby optparse-test.rb --user 2
+# #<struct User id=2, name="Gandalf">
+# $ ruby optparse-test.rb --user 3
+# optparse-test.rb:15:in 'block in find_user': No User Found for id 3 (RuntimeError)
+#
+# === Store options to a Hash
+#
+# The +into+ option of +order+, +parse+ and so on methods stores command line options into a Hash.
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+#
+# options = {}
+# Gem::OptionParser.new do |parser|
+# parser.on('-a')
+# parser.on('-b NUM', Integer)
+# parser.on('-v', '--verbose')
+# end.parse!(into: options)
+#
+# p options
+#
+# Used:
+#
+# $ ruby optparse-test.rb -a
+# {:a=>true}
+# $ ruby optparse-test.rb -a -v
+# {:a=>true, :verbose=>true}
+# $ ruby optparse-test.rb -a -b 100
+# {:a=>true, :b=>100}
+#
+# === Complete example
+#
+# The following example is a complete Ruby program. You can run it and see the
+# effect of specifying various options. This is probably the best way to learn
+# the features of +optparse+.
+#
+# require 'rubygems/vendor/optparse/lib/optparse'
+# require 'rubygems/vendor/optparse/lib/optparse/time'
+# require 'ostruct'
+# require 'pp'
+#
+# class OptparseExample
+# Version = '1.0.0'
+#
+# CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
+# CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
+#
+# class ScriptOptions
+# attr_accessor :library, :inplace, :encoding, :transfer_type,
+# :verbose, :extension, :delay, :time, :record_separator,
+# :list
+#
+# def initialize
+# self.library = []
+# self.inplace = false
+# self.encoding = "utf8"
+# self.transfer_type = :auto
+# self.verbose = false
+# end
+#
+# def define_options(parser)
+# parser.banner = "Usage: example.rb [options]"
+# parser.separator ""
+# parser.separator "Specific options:"
+#
+# # add additional options
+# perform_inplace_option(parser)
+# delay_execution_option(parser)
+# execute_at_time_option(parser)
+# specify_record_separator_option(parser)
+# list_example_option(parser)
+# specify_encoding_option(parser)
+# optional_option_argument_with_keyword_completion_option(parser)
+# boolean_verbose_option(parser)
+#
+# parser.separator ""
+# parser.separator "Common options:"
+# # No argument, shows at tail. This will print an options summary.
+# # Try it and see!
+# parser.on_tail("-h", "--help", "Show this message") do
+# puts parser
+# exit
+# end
+# # Another typical switch to print the version.
+# parser.on_tail("--version", "Show version") do
+# puts Version
+# exit
+# end
+# end
+#
+# def perform_inplace_option(parser)
+# # Specifies an optional option argument
+# parser.on("-i", "--inplace [EXTENSION]",
+# "Edit ARGV files in place",
+# "(make backup if EXTENSION supplied)") do |ext|
+# self.inplace = true
+# self.extension = ext || ''
+# self.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
+# end
+# end
+#
+# def delay_execution_option(parser)
+# # Cast 'delay' argument to a Float.
+# parser.on("--delay N", Float, "Delay N seconds before executing") do |n|
+# self.delay = n
+# end
+# end
+#
+# def execute_at_time_option(parser)
+# # Cast 'time' argument to a Time object.
+# parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
+# self.time = time
+# end
+# end
+#
+# def specify_record_separator_option(parser)
+# # Cast to octal integer.
+# parser.on("-F", "--irs [OCTAL]", Gem::OptionParser::OctalInteger,
+# "Specify record separator (default \\0)") do |rs|
+# self.record_separator = rs
+# end
+# end
+#
+# def list_example_option(parser)
+# # List of arguments.
+# parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
+# self.list = list
+# end
+# end
+#
+# def specify_encoding_option(parser)
+# # Keyword completion. We are specifying a specific set of arguments (CODES
+# # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
+# # the shortest unambiguous text.
+# code_list = (CODE_ALIASES.keys + CODES).join(', ')
+# parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
+# "(#{code_list})") do |encoding|
+# self.encoding = encoding
+# end
+# end
+#
+# def optional_option_argument_with_keyword_completion_option(parser)
+# # Optional '--type' option argument with keyword completion.
+# parser.on("--type [TYPE]", [:text, :binary, :auto],
+# "Select transfer type (text, binary, auto)") do |t|
+# self.transfer_type = t
+# end
+# end
+#
+# def boolean_verbose_option(parser)
+# # Boolean switch.
+# parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
+# self.verbose = v
+# end
+# end
+# end
+#
+# #
+# # Return a structure describing the options.
+# #
+# def parse(args)
+# # The options specified on the command line will be collected in
+# # *options*.
+#
+# @options = ScriptOptions.new
+# @args = Gem::OptionParser.new do |parser|
+# @options.define_options(parser)
+# parser.parse!(args)
+# end
+# @options
+# end
+#
+# attr_reader :parser, :options
+# end # class OptparseExample
+#
+# example = OptparseExample.new
+# options = example.parse(ARGV)
+# pp options # example.options
+# pp ARGV
+#
+# === Shell Completion
+#
+# For modern shells (e.g. bash, zsh, etc.), you can use shell
+# completion for command line options.
+#
+# === Further documentation
+#
+# The above examples, along with the accompanying
+# {Tutorial}[optparse/tutorial.rdoc],
+# should be enough to learn how to use this class.
+# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
+#
+class Gem::OptionParser
+ # The version string
+ VERSION = "0.8.0"
+ Version = VERSION # for compatibility
+
+ # :stopdoc:
+ NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
+ RequiredArgument = [REQUIRED_ARGUMENT = :REQUIRED, true].freeze
+ OptionalArgument = [OPTIONAL_ARGUMENT = :OPTIONAL, false].freeze
+ # :startdoc:
+
+ #
+ # Keyword completion module. This allows partial arguments to be specified
+ # and resolved against a list of acceptable values.
+ #
+ module Completion
+ # :nodoc:
+
+ def self.regexp(key, icase)
+ Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
+ end
+
+ def self.candidate(key, icase = false, pat = nil, &block)
+ pat ||= Completion.regexp(key, icase)
+ candidates = []
+ block.call do |k, *v|
+ (if Regexp === k
+ kn = ""
+ k === key
+ else
+ kn = defined?(k.id2name) ? k.id2name : k
+ pat === kn
+ end) or next
+ v << k if v.empty?
+ candidates << [k, v, kn]
+ end
+ candidates
+ end
+
+ def self.completable?(key)
+ String.try_convert(key) or defined?(key.id2name)
+ end
+
+ def candidate(key, icase = false, pat = nil, &_)
+ Completion.candidate(key, icase, pat, &method(:each))
+ end
+
+ public
+ def complete(key, icase = false, pat = nil)
+ candidates = candidate(key, icase, pat, &method(:each)).sort_by {|k, v, kn| kn.size}
+ if candidates.size == 1
+ canon, sw, * = candidates[0]
+ elsif candidates.size > 1
+ canon, sw, cn = candidates.shift
+ candidates.each do |k, v, kn|
+ next if sw == v
+ if String === cn and String === kn
+ if cn.rindex(kn, 0)
+ canon, sw, cn = k, v, kn
+ next
+ elsif kn.rindex(cn, 0)
+ next
+ end
+ end
+ throw :ambiguous, key
+ end
+ end
+ if canon
+ block_given? or return key, *sw
+ yield(key, *sw)
+ end
+ end
+
+ def convert(opt = nil, val = nil, *)
+ val
+ end
+ end
+
+ #
+ # Map from option/keyword string to object with completion.
+ #
+ class OptionMap < Hash
+ include Completion
+ end
+
+ #
+ # Individual switch class. Not important to the user.
+ #
+ # Defined within Switch are several Switch-derived classes: NoArgument,
+ # RequiredArgument, etc.
+ #
+ class Switch
+ # :nodoc:
+
+ attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
+
+ #
+ # Guesses argument style from +arg+. Returns corresponding
+ # Gem::OptionParser::Switch class (OptionalArgument, etc.).
+ #
+ def self.guess(arg)
+ case arg
+ when ""
+ t = self
+ when /\A=?\[/
+ t = Switch::OptionalArgument
+ when /\A\s+\[/
+ t = Switch::PlacedArgument
+ else
+ t = Switch::RequiredArgument
+ end
+ self >= t or incompatible_argument_styles(arg, t)
+ t
+ end
+
+ def self.incompatible_argument_styles(arg, t)
+ raise(ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}",
+ ParseError.filter_backtrace(caller(2)))
+ end
+
+ def self.pattern
+ NilClass
+ end
+
+ def initialize(pattern = nil, conv = nil,
+ short = nil, long = nil, arg = nil,
+ desc = ([] if short or long), block = nil, values = nil, &_block)
+ raise if Array === pattern
+ block ||= _block
+ @pattern, @conv, @short, @long, @arg, @desc, @block, @values =
+ pattern, conv, short, long, arg, desc, block, values
+ end
+
+ #
+ # Parses +arg+ and returns rest of +arg+ and matched portion to the
+ # argument pattern. Yields when the pattern doesn't match substring.
+ #
+ def parse_arg(arg) # :nodoc:
+ pattern or return nil, [arg]
+ unless m = pattern.match(arg)
+ yield(InvalidArgument, arg)
+ return arg, []
+ end
+ if String === m
+ m = [s = m]
+ else
+ m = m.to_a
+ s = m[0]
+ return nil, m unless String === s
+ end
+ raise InvalidArgument, arg unless arg.rindex(s, 0)
+ return nil, m if s.length == arg.length
+ yield(InvalidArgument, arg) # didn't match whole arg
+ return arg[s.length..-1], m
+ end
+ private :parse_arg
+
+ #
+ # Parses argument, converts and returns +arg+, +block+ and result of
+ # conversion. Yields at semi-error condition instead of raising an
+ # exception.
+ #
+ def conv_arg(arg, val = []) # :nodoc:
+ v, = *val
+ if conv
+ val = conv.call(*val)
+ else
+ val = proc {|v| v}.call(*val)
+ end
+ if @values
+ @values.include?(val) or raise InvalidArgument, v
+ end
+ return arg, block, val
+ end
+ private :conv_arg
+
+ #
+ # Produces the summary text. Each line of the summary is yielded to the
+ # block (without newline).
+ #
+ # +sdone+:: Already summarized short style options keyed hash.
+ # +ldone+:: Already summarized long style options keyed hash.
+ # +width+:: Width of left side (option part). In other words, the right
+ # side (description part) starts after +width+ columns.
+ # +max+:: Maximum width of left side -> the options are filled within
+ # +max+ columns.
+ # +indent+:: Prefix string indents all summarized lines.
+ #
+ def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "")
+ sopts, lopts = [], [], nil
+ @short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
+ @long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
+ return if sopts.empty? and lopts.empty? # completely hidden
+
+ left = [sopts.join(', ')]
+ right = desc.dup
+
+ while s = lopts.shift
+ l = left[-1].length + s.length
+ l += arg.length if left.size == 1 && arg
+ l < max or sopts.empty? or left << +''
+ left[-1] << (left[-1].empty? ? ' ' * 4 : ', ') << s
+ end
+
+ if arg
+ left[0] << (left[1] ? arg.sub(/\A(\[?)=/, '\1') + ',' : arg)
+ end
+ mlen = left.collect {|ss| ss.length}.max.to_i
+ while mlen > width and l = left.shift
+ mlen = left.collect {|ss| ss.length}.max.to_i if l.length == mlen
+ if l.length < width and (r = right[0]) and !r.empty?
+ l = l.to_s.ljust(width) + ' ' + r
+ right.shift
+ end
+ yield(indent + l)
+ end
+
+ while begin l = left.shift; r = right.shift; l or r end
+ l = l.to_s.ljust(width) + ' ' + r if r and !r.empty?
+ yield(indent + l)
+ end
+
+ self
+ end
+
+ def add_banner(to) # :nodoc:
+ unless @short or @long
+ s = desc.join
+ to << " [" + s + "]..." unless s.empty?
+ end
+ to
+ end
+
+ def match_nonswitch?(str) # :nodoc:
+ @pattern =~ str unless @short or @long
+ end
+
+ #
+ # Main name of the switch.
+ #
+ def switch_name
+ (long.first || short.first).sub(/\A-+(?:\[no-\])?/, '')
+ end
+
+ def compsys(sdone, ldone) # :nodoc:
+ sopts, lopts = [], []
+ @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
+
+ (sopts+lopts).each do |opt|
+ # "(-x -c -r)-l[left justify]"
+ if /\A--\[no-\](.+)$/ =~ opt
+ o = $1
+ yield("--#{o}", desc.join(""))
+ yield("--no-#{o}", desc.join(""))
+ else
+ yield("#{opt}", desc.join(""))
+ end
+ end
+ end
+
+ def pretty_print_contents(q) # :nodoc:
+ if @block
+ q.text ":" + @block.source_location.join(":") + ":"
+ first = false
+ else
+ first = true
+ end
+ [@short, @long].each do |list|
+ list.each do |opt|
+ if first
+ q.text ":"
+ first = false
+ end
+ q.breakable
+ q.text opt
+ end
+ end
+ end
+
+ def pretty_print(q) # :nodoc:
+ q.object_group(self) {pretty_print_contents(q)}
+ end
+
+ def omitted_argument(val) # :nodoc:
+ val.pop if val.size == 3 and val.last.nil?
+ val
+ end
+
+ #
+ # Switch that takes no arguments.
+ #
+ class NoArgument < self
+
+ #
+ # Raises an exception if any arguments given.
+ #
+ def parse(arg, argv)
+ yield(NeedlessArgument, arg) if arg
+ conv_arg(arg)
+ end
+
+ def self.incompatible_argument_styles(*) # :nodoc:
+ end
+
+ def self.pattern # :nodoc:
+ Object
+ end
+
+ def pretty_head # :nodoc:
+ "NoArgument"
+ end
+ end
+
+ #
+ # Switch that takes an argument.
+ #
+ class RequiredArgument < self
+
+ #
+ # Raises an exception if argument is not present.
+ #
+ def parse(arg, argv, &_)
+ unless arg
+ raise MissingArgument if argv.empty?
+ arg = argv.shift
+ end
+ conv_arg(*parse_arg(arg, &method(:raise)))
+ end
+
+ def pretty_head # :nodoc:
+ "Required"
+ end
+ end
+
+ #
+ # Switch that can omit argument.
+ #
+ class OptionalArgument < self
+
+ #
+ # Parses argument if given, or uses default value.
+ #
+ def parse(arg, argv, &error)
+ if arg
+ conv_arg(*parse_arg(arg, &error))
+ else
+ omitted_argument conv_arg(arg)
+ end
+ end
+
+ def pretty_head # :nodoc:
+ "Optional"
+ end
+ end
+
+ #
+ # Switch that takes an argument, which does not begin with '-' or is '-'.
+ #
+ class PlacedArgument < self
+
+ #
+ # Returns nil if argument is not present or begins with '-' and is not '-'.
+ #
+ def parse(arg, argv, &error)
+ if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
+ return nil, block
+ end
+ opt = (val = parse_arg(val, &error))[1]
+ val = conv_arg(*val)
+ if opt and !arg
+ argv.shift
+ else
+ omitted_argument val
+ val[0] = nil
+ end
+ val
+ end
+
+ def pretty_head # :nodoc:
+ "Placed"
+ end
+ end
+ end
+
+ #
+ # Simple option list providing mapping from short and/or long option
+ # string to Gem::OptionParser::Switch and mapping from acceptable argument to
+ # matching pattern and converter pair. Also provides summary feature.
+ #
+ class List
+ # :nodoc:
+
+ # Map from acceptable argument types to pattern and converter pairs.
+ attr_reader :atype
+
+ # Map from short style option switches to actual switch objects.
+ attr_reader :short
+
+ # Map from long style option switches to actual switch objects.
+ attr_reader :long
+
+ # List of all switches and summary string.
+ attr_reader :list
+
+ #
+ # Just initializes all instance variables.
+ #
+ def initialize
+ @atype = {}
+ @short = OptionMap.new
+ @long = OptionMap.new
+ @list = []
+ end
+
+ def pretty_print(q) # :nodoc:
+ q.group(1, "(", ")") do
+ @list.each do |sw|
+ next unless Switch === sw
+ q.group(1, "(" + sw.pretty_head, ")") do
+ sw.pretty_print_contents(q)
+ end
+ end
+ end
+ end
+
+ #
+ # See Gem::OptionParser.accept.
+ #
+ def accept(t, pat = /.*/m, &block)
+ if pat
+ pat.respond_to?(:match) or
+ raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
+ else
+ pat = t if t.respond_to?(:match)
+ end
+ unless block
+ block = pat.method(:convert).to_proc if pat.respond_to?(:convert)
+ end
+ @atype[t] = [pat, block]
+ end
+
+ #
+ # See Gem::OptionParser.reject.
+ #
+ def reject(t)
+ @atype.delete(t)
+ end
+
+ #
+ # Adds +sw+ according to +sopts+, +lopts+ and +nlopts+.
+ #
+ # +sw+:: Gem::OptionParser::Switch instance to be added.
+ # +sopts+:: Short style option list.
+ # +lopts+:: Long style option list.
+ # +nlopts+:: Negated long style options list.
+ #
+ def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
+ sopts.each {|o| @short[o] = sw} if sopts
+ lopts.each {|o| @long[o] = sw} if lopts
+ nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
+ used = @short.invert.update(@long.invert)
+ @list.delete_if {|o| Switch === o and !used[o]}
+ end
+ private :update
+
+ #
+ # Inserts +switch+ at the head of the list, and associates short, long
+ # and negated long options. Arguments are:
+ #
+ # +switch+:: Gem::OptionParser::Switch instance to be inserted.
+ # +short_opts+:: List of short style options.
+ # +long_opts+:: List of long style options.
+ # +nolong_opts+:: List of long style options with "no-" prefix.
+ #
+ # prepend(switch, short_opts, long_opts, nolong_opts)
+ #
+ def prepend(*args)
+ update(*args)
+ @list.unshift(args[0])
+ end
+
+ #
+ # Appends +switch+ at the tail of the list, and associates short, long
+ # and negated long options. Arguments are:
+ #
+ # +switch+:: Gem::OptionParser::Switch instance to be inserted.
+ # +short_opts+:: List of short style options.
+ # +long_opts+:: List of long style options.
+ # +nolong_opts+:: List of long style options with "no-" prefix.
+ #
+ # append(switch, short_opts, long_opts, nolong_opts)
+ #
+ def append(*args)
+ update(*args)
+ @list.push(args[0])
+ end
+
+ #
+ # Searches +key+ in +id+ list. The result is returned or yielded if a
+ # block is given. If it isn't found, nil is returned.
+ #
+ def search(id, key)
+ if list = __send__(id)
+ val = list.fetch(key) {return nil}
+ block_given? ? yield(val) : val
+ end
+ end
+
+ #
+ # Searches list +id+ for +opt+ and the optional patterns for completion
+ # +pat+. If +icase+ is true, the search is case insensitive. The result
+ # is returned or yielded if a block is given. If it isn't found, nil is
+ # returned.
+ #
+ def complete(id, opt, icase = false, *pat, &block)
+ __send__(id).complete(opt, icase, *pat, &block)
+ end
+
+ def get_candidates(id)
+ yield __send__(id).keys
+ end
+
+ #
+ # Iterates over each option, passing the option to the +block+.
+ #
+ def each_option(&block)
+ list.each(&block)
+ end
+
+ #
+ # Creates the summary table, passing each line to the +block+ (without
+ # newline). The arguments +args+ are passed along to the summarize
+ # method which is called on every option.
+ #
+ def summarize(*args, &block)
+ sum = []
+ list.reverse_each do |opt|
+ if opt.respond_to?(:summarize) # perhaps Gem::OptionParser::Switch
+ s = []
+ opt.summarize(*args) {|l| s << l}
+ sum.concat(s.reverse)
+ elsif !opt or opt.empty?
+ sum << ""
+ elsif opt.respond_to?(:each_line)
+ sum.concat([*opt.each_line].reverse)
+ else
+ sum.concat([*opt.each].reverse)
+ end
+ end
+ sum.reverse_each(&block)
+ end
+
+ def add_banner(to) # :nodoc:
+ list.each do |opt|
+ if opt.respond_to?(:add_banner)
+ opt.add_banner(to)
+ end
+ end
+ to
+ end
+
+ def compsys(*args, &block) # :nodoc:
+ list.each do |opt|
+ if opt.respond_to?(:compsys)
+ opt.compsys(*args, &block)
+ end
+ end
+ end
+ end
+
+ #
+ # Hash with completion search feature. See Gem::OptionParser::Completion.
+ #
+ class CompletingHash < Hash
+ include Completion
+
+ #
+ # Completion for hash key.
+ #
+ def match(key)
+ *values = fetch(key) {
+ raise AmbiguousArgument, catch(:ambiguous) {return complete(key)}
+ }
+ return key, *values
+ end
+ end
+
+ # :stopdoc:
+
+ #
+ # Enumeration of acceptable argument styles. Possible values are:
+ #
+ # NO_ARGUMENT:: The switch takes no arguments. (:NONE)
+ # REQUIRED_ARGUMENT:: The switch requires an argument. (:REQUIRED)
+ # OPTIONAL_ARGUMENT:: The switch requires an optional argument. (:OPTIONAL)
+ #
+ # Use like --switch=argument (long style) or -Xargument (short style). For
+ # short style, only portion matched to argument pattern is treated as
+ # argument.
+ #
+ ArgumentStyle = {}
+ NoArgument.each {|el| ArgumentStyle[el] = Switch::NoArgument}
+ RequiredArgument.each {|el| ArgumentStyle[el] = Switch::RequiredArgument}
+ OptionalArgument.each {|el| ArgumentStyle[el] = Switch::OptionalArgument}
+ ArgumentStyle.freeze
+
+ #
+ # Switches common used such as '--', and also provides default
+ # argument classes
+ #
+ DefaultList = List.new
+ DefaultList.short['-'] = Switch::NoArgument.new {}
+ DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
+
+ COMPSYS_HEADER = <<'XXX' # :nodoc:
+
+typeset -A opt_args
+local context state line
+
+_arguments -s -S \
+XXX
+
+ def compsys(to, name = File.basename($0)) # :nodoc:
+ to << "#compdef #{name}\n"
+ to << COMPSYS_HEADER
+ visit(:compsys, {}, {}) {|o, d|
+ to << %Q[ "#{o}[#{d.gsub(/[\\\"\[\]]/, '\\\\\&')}]" \\\n]
+ }
+ to << " '*:file:_files' && return 0\n"
+ end
+
+ def help_exit
+ if $stdout.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?})
+ less = ENV["LESS"]
+ args = [{"LESS" => "#{less} -Fe"}, pager, "w"]
+ print = proc do |f|
+ f.puts help
+ rescue Errno::EPIPE
+ # pager terminated
+ end
+ if Process.respond_to?(:fork) and false
+ IO.popen("-") {|f| f ? Process.exec(*args, in: f) : print.call($stdout)}
+ # unreachable
+ end
+ IO.popen(*args, &print)
+ else
+ puts help
+ end
+ exit
+ end
+
+ #
+ # Default options for ARGV, which never appear in option summary.
+ #
+ Officious = {}
+
+ #
+ # --help
+ # Shows option summary.
+ #
+ Officious['help'] = proc do |parser|
+ Switch::NoArgument.new do |arg|
+ parser.help_exit
+ end
+ end
+
+ #
+ # --*-completion-bash=WORD
+ # Shows candidates for command line completion.
+ #
+ Officious['*-completion-bash'] = proc do |parser|
+ Switch::RequiredArgument.new do |arg|
+ puts parser.candidate(arg)
+ exit
+ end
+ end
+
+ #
+ # --*-completion-zsh[=NAME:FILE]
+ # Creates zsh completion file.
+ #
+ Officious['*-completion-zsh'] = proc do |parser|
+ Switch::OptionalArgument.new do |arg|
+ parser.compsys($stdout, arg)
+ exit
+ end
+ end
+
+ #
+ # --version
+ # Shows version string if Version is defined.
+ #
+ Officious['version'] = proc do |parser|
+ Switch::OptionalArgument.new do |pkg|
+ if pkg
+ begin
+ require_relative 'optparse/version'
+ rescue LoadError
+ else
+ show_version(*pkg.split(/,/)) or
+ abort("#{parser.program_name}: no version found in package #{pkg}")
+ exit
+ end
+ end
+ v = parser.ver or abort("#{parser.program_name}: version unknown")
+ puts v
+ exit
+ end
+ end
+
+ # :startdoc:
+
+ #
+ # Class methods
+ #
+
+ #
+ # Initializes a new instance and evaluates the optional block in context
+ # of the instance. Arguments +args+ are passed to #new, see there for
+ # description of parameters.
+ #
+ # This method is *deprecated*, its behavior corresponds to the older #new
+ # method.
+ #
+ def self.with(*args, &block)
+ opts = new(*args)
+ opts.instance_eval(&block)
+ opts
+ end
+
+ #
+ # Returns an incremented value of +default+ according to +arg+.
+ #
+ def self.inc(arg, default = nil)
+ case arg
+ when Integer
+ arg.nonzero?
+ when nil
+ default.to_i + 1
+ end
+ end
+
+ #
+ # See self.inc
+ #
+ def inc(*args)
+ self.class.inc(*args)
+ end
+
+ #
+ # Initializes the instance and yields itself if called with a block.
+ #
+ # +banner+:: Banner message.
+ # +width+:: Summary width.
+ # +indent+:: Summary indent.
+ #
+ def initialize(banner = nil, width = 32, indent = ' ' * 4)
+ @stack = [DefaultList, List.new, List.new]
+ @program_name = nil
+ @banner = banner
+ @summary_width = width
+ @summary_indent = indent
+ @default_argv = ARGV
+ @require_exact = false
+ @raise_unknown = true
+ add_officious
+ yield self if block_given?
+ end
+
+ def add_officious # :nodoc:
+ list = base()
+ Officious.each do |opt, block|
+ list.long[opt] ||= block.call(self)
+ end
+ end
+
+ #
+ # Terminates option parsing. Optional parameter +arg+ is a string pushed
+ # back to be the first non-option argument.
+ #
+ def terminate(arg = nil)
+ self.class.terminate(arg)
+ end
+ #
+ # See #terminate.
+ #
+ def self.terminate(arg = nil)
+ throw :terminate, arg
+ end
+
+ @stack = [DefaultList]
+ #
+ # Returns the global top option list.
+ #
+ # Do not use directly.
+ #
+ def self.top() DefaultList end
+
+ #
+ # Directs to accept specified class +t+. The argument string is passed to
+ # the block in which it should be converted to the desired class.
+ #
+ # +t+:: Argument class specifier, any object including Class.
+ # +pat+:: Pattern for argument, defaults to +t+ if it responds to match.
+ #
+ # accept(t, pat, &block)
+ #
+ def accept(*args, &blk) top.accept(*args, &blk) end
+ #
+ # See #accept.
+ #
+ def self.accept(*args, &blk) top.accept(*args, &blk) end
+
+ #
+ # Directs to reject specified class argument.
+ #
+ # +type+:: Argument class specifier, any object including Class.
+ #
+ # reject(type)
+ #
+ def reject(*args, &blk) top.reject(*args, &blk) end
+ #
+ # See #reject.
+ #
+ def self.reject(*args, &blk) top.reject(*args, &blk) end
+
+ #
+ # Instance methods
+ #
+
+ # Heading banner preceding summary.
+ attr_writer :banner
+
+ # Program name to be emitted in error message and default banner,
+ # defaults to $0.
+ attr_writer :program_name
+
+ # Width for option list portion of summary. Must be Numeric.
+ attr_accessor :summary_width
+
+ # Indentation for summary. Must be String (or have + String method).
+ attr_accessor :summary_indent
+
+ # Strings to be parsed in default.
+ attr_accessor :default_argv
+
+ # Whether to require that options match exactly (disallows providing
+ # abbreviated long option as short option).
+ attr_accessor :require_exact
+
+ # Whether to raise at unknown option.
+ attr_accessor :raise_unknown
+
+ #
+ # Heading banner preceding summary.
+ #
+ def banner
+ unless @banner
+ @banner = +"Usage: #{program_name} [options]"
+ visit(:add_banner, @banner)
+ end
+ @banner
+ end
+
+ #
+ # Program name to be emitted in error message and default banner, defaults
+ # to $0.
+ #
+ def program_name
+ @program_name || strip_ext(File.basename($0))
+ end
+
+ private def strip_ext(name) # :nodoc:
+ exts = /#{
+ require "rbconfig"
+ Regexp.union(*RbConfig::CONFIG["EXECUTABLE_EXTS"]&.split(" "))
+ }\z/o
+ name.sub(exts, "")
+ end
+
+ # for experimental cascading :-)
+ alias set_banner banner=
+ alias set_program_name program_name=
+ alias set_summary_width summary_width=
+ alias set_summary_indent summary_indent=
+
+ # Version
+ attr_writer :version
+ # Release code
+ attr_writer :release
+
+ #
+ # Version
+ #
+ def version
+ (defined?(@version) && @version) || (defined?(::Version) && ::Version)
+ end
+
+ #
+ # Release code
+ #
+ def release
+ (defined?(@release) && @release) || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
+ end
+
+ #
+ # Returns version string from program_name, version and release.
+ #
+ def ver
+ if v = version
+ str = +"#{program_name} #{[v].join('.')}"
+ str << " (#{v})" if v = release
+ str
+ end
+ end
+
+ #
+ # Shows warning message with the program name
+ #
+ # +mesg+:: Message, defaulted to +$!+.
+ #
+ # See Kernel#warn.
+ #
+ def warn(mesg = $!)
+ super("#{program_name}: #{mesg}")
+ end
+
+ #
+ # Shows message with the program name then aborts.
+ #
+ # +mesg+:: Message, defaulted to +$!+.
+ #
+ # See Kernel#abort.
+ #
+ def abort(mesg = $!)
+ super("#{program_name}: #{mesg}")
+ end
+
+ #
+ # Subject of #on / #on_head, #accept / #reject
+ #
+ def top
+ @stack[-1]
+ end
+
+ #
+ # Subject of #on_tail.
+ #
+ def base
+ @stack[1]
+ end
+
+ #
+ # Pushes a new List.
+ #
+ # If a block is given, yields +self+ and returns the result of the
+ # block, otherwise returns +self+.
+ #
+ def new
+ @stack.push(List.new)
+ if block_given?
+ yield self
+ else
+ self
+ end
+ end
+
+ #
+ # Removes the last List.
+ #
+ def remove
+ @stack.pop
+ end
+
+ #
+ # Puts option summary into +to+ and returns +to+. Yields each line if
+ # a block is given.
+ #
+ # +to+:: Output destination, which must have method <<. Defaults to [].
+ # +width+:: Width of left side, defaults to @summary_width.
+ # +max+:: Maximum length allowed for left side, defaults to +width+ - 1.
+ # +indent+:: Indentation, defaults to @summary_indent.
+ #
+ def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
+ nl = "\n"
+ blk ||= proc {|l| to << (l.index(nl, -1) ? l : l + nl)}
+ visit(:summarize, {}, {}, width, max, indent, &blk)
+ to
+ end
+
+ #
+ # Returns option summary string.
+ #
+ def help; summarize("#{banner}".sub(/\n?\z/, "\n")) end
+ alias to_s help
+
+ def pretty_print(q) # :nodoc:
+ q.object_group(self) do
+ first = true
+ if @stack.size > 2
+ @stack.each_with_index do |s, i|
+ next if i < 2
+ next if s.list.empty?
+ if first
+ first = false
+ q.text ":"
+ end
+ q.breakable
+ s.pretty_print(q)
+ end
+ end
+ end
+ end
+
+ def inspect # :nodoc:
+ require 'pp'
+ pretty_print_inspect
+ end
+
+ #
+ # Returns option summary list.
+ #
+ def to_a; summarize("#{banner}".split(/^/)) end
+
+ #
+ # Checks if an argument is given twice, in which case an ArgumentError is
+ # raised. Called from Gem::OptionParser#switch only.
+ #
+ # +obj+:: New argument.
+ # +prv+:: Previously specified argument.
+ # +msg+:: Exception message.
+ #
+ def notwice(obj, prv, msg) # :nodoc:
+ unless !prv or prv == obj
+ raise(ArgumentError, "argument #{msg} given twice: #{obj}",
+ ParseError.filter_backtrace(caller(2)))
+ end
+ obj
+ end
+ private :notwice
+
+ SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a} # :nodoc:
+
+ # :call-seq:
+ # make_switch(params, block = nil)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ def make_switch(opts, block = nil)
+ short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
+ ldesc, sdesc, desc, arg = [], [], []
+ default_style = Switch::NoArgument
+ default_pattern = nil
+ klass = nil
+ q, a = nil
+ has_arg = false
+ values = nil
+
+ opts.each do |o|
+ # argument class
+ next if search(:atype, o) do |pat, c|
+ klass = notwice(o, klass, 'type')
+ if not_style and not_style != Switch::NoArgument
+ not_pattern, not_conv = pat, c
+ else
+ default_pattern, conv = pat, c
+ end
+ end
+
+ # directly specified pattern(any object possible to match)
+ if !Completion.completable?(o) and o.respond_to?(:match)
+ pattern = notwice(o, pattern, 'pattern')
+ if pattern.respond_to?(:convert)
+ conv = pattern.method(:convert).to_proc
+ else
+ conv = SPLAT_PROC
+ end
+ next
+ end
+
+ # anything others
+ case o
+ when Proc, Method
+ block = notwice(o, block, 'block')
+ when Array, Hash, Set
+ if Array === o
+ o, v = o.partition {|v,| Completion.completable?(v)}
+ values = notwice(v, values, 'values') unless v.empty?
+ next if o.empty?
+ end
+ case pattern
+ when CompletingHash
+ when nil
+ pattern = CompletingHash.new
+ conv = pattern.method(:convert).to_proc if pattern.respond_to?(:convert)
+ else
+ raise ArgumentError, "argument pattern given twice"
+ end
+ o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
+ when Range
+ values = notwice(o, values, 'values')
+ when Module
+ raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4))
+ when *ArgumentStyle.keys
+ style = notwice(ArgumentStyle[o], style, 'style')
+ when /\A--no-([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ o = notwice(a ? Object : TrueClass, klass, 'type')
+ not_pattern, not_conv = search(:atype, o) unless not_style
+ not_style = (not_style || default_style).guess(arg = a) if a
+ default_style = Switch::NoArgument
+ default_pattern, conv = search(:atype, FalseClass) unless default_pattern
+ ldesc << "--no-#{q}"
+ (q = q.downcase).tr!('_', '-')
+ long << "no-#{q}"
+ nolong << q
+ when /\A--\[no-\]([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ o = notwice(a ? Object : TrueClass, klass, 'type')
+ if a
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ ldesc << "--[no-]#{q}"
+ (o = q.downcase).tr!('_', '-')
+ long << o
+ not_pattern, not_conv = search(:atype, FalseClass) unless not_style
+ not_style = Switch::NoArgument
+ nolong << "no-#{o}"
+ when /\A--([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ if a
+ o = notwice(NilClass, klass, 'type')
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ ldesc << "--#{q}"
+ (o = q.downcase).tr!('_', '-')
+ long << o
+ when /\A-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
+ q, a = $1, $2
+ o = notwice(Object, klass, 'type')
+ if a
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ else
+ has_arg = true
+ end
+ sdesc << "-#{q}"
+ short << Regexp.new(q)
+ when /\A-(.)(.+)?/
+ q, a = $1, $2
+ if a
+ o = notwice(NilClass, klass, 'type')
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ sdesc << "-#{q}"
+ short << q
+ when /\A=/
+ style = notwice(default_style.guess(arg = o), style, 'style')
+ default_pattern, conv = search(:atype, Object) unless default_pattern
+ else
+ desc.push(o) if o && !o.empty?
+ end
+ end
+
+ default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
+ if Range === values and klass
+ unless (!values.begin or klass === values.begin) and
+ (!values.end or klass === values.end)
+ raise ArgumentError, "range does not match class"
+ end
+ end
+ if !(short.empty? and long.empty?)
+ if has_arg and default_style == Switch::NoArgument
+ default_style = Switch::RequiredArgument
+ end
+ s = (style || default_style).new(pattern || default_pattern,
+ conv, sdesc, ldesc, arg, desc, block, values)
+ elsif !block
+ if style or pattern
+ raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller)
+ end
+ s = desc
+ else
+ short << pattern
+ s = (style || default_style).new(pattern,
+ conv, nil, nil, arg, desc, block, values)
+ end
+ return s, short, long,
+ (not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
+ nolong
+ end
+
+ # ----
+ # Option definition phase methods
+ #
+ # These methods are used to define options, or to construct an
+ # Gem::OptionParser instance in other words.
+
+ # :call-seq:
+ # define(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ def define(*opts, &block)
+ top.append(*(sw = make_switch(opts, block)))
+ sw[0]
+ end
+
+ # :call-seq:
+ # on(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ def on(*opts, &block)
+ define(*opts, &block)
+ self
+ end
+ alias def_option define
+
+ # :call-seq:
+ # define_head(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ def define_head(*opts, &block)
+ top.prepend(*(sw = make_switch(opts, block)))
+ sw[0]
+ end
+
+ # :call-seq:
+ # on_head(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ # The new option is added at the head of the summary.
+ #
+ def on_head(*opts, &block)
+ define_head(*opts, &block)
+ self
+ end
+ alias def_head_option define_head
+
+ # :call-seq:
+ # define_tail(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ def define_tail(*opts, &block)
+ base.append(*(sw = make_switch(opts, block)))
+ sw[0]
+ end
+
+ #
+ # :call-seq:
+ # on_tail(*params, &block)
+ #
+ # :include: ../doc/optparse/creates_option.rdoc
+ #
+ # The new option is added at the tail of the summary.
+ #
+ def on_tail(*opts, &block)
+ define_tail(*opts, &block)
+ self
+ end
+ alias def_tail_option define_tail
+
+ #
+ # Add separator in summary.
+ #
+ def separator(string)
+ top.append(string, nil, nil)
+ end
+
+ # ----
+ # Arguments parse phase methods
+ #
+ # These methods parse +argv+, convert, and store the results by
+ # calling handlers. As these methods do not modify +self+, +self+
+ # can be frozen.
+
+ #
+ # Parses command line arguments +argv+ in order. When a block is given,
+ # each non-option argument is yielded. When optional +into+ keyword
+ # argument is provided, the parsed option values are stored there via
+ # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
+ # similar object).
+ #
+ # Returns the rest of +argv+ left unparsed.
+ #
+ def order(*argv, **keywords, &nonopt)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ order!(argv, **keywords, &nonopt)
+ end
+
+ #
+ # Same as #order, but removes switches destructively.
+ # Non-option arguments remain in +argv+.
+ #
+ def order!(argv = default_argv, into: nil, **keywords, &nonopt)
+ setter = ->(name, val) {into[name.to_sym] = val} if into
+ parse_in_order(argv, setter, **keywords, &nonopt)
+ end
+
+ def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
+ opt, arg, val, rest = nil
+ nonopt ||= proc {|a| throw :terminate, a}
+ argv.unshift(arg) if arg = catch(:terminate) {
+ while arg = argv.shift
+ case arg
+ # long option
+ when /\A--([^=]*)(?:=(.*))?/m
+ opt, rest = $1, $2
+ opt.tr!('_', '-')
+ begin
+ if exact
+ sw, = search(:long, opt)
+ else
+ sw, = complete(:long, opt, true)
+ end
+ rescue ParseError
+ throw :terminate, arg unless raise_unknown
+ raise $!.set_option(arg, true)
+ else
+ unless sw
+ throw :terminate, arg unless raise_unknown
+ raise InvalidOption, arg
+ end
+ end
+ begin
+ opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
+ val = callback!(cb, 1, val) if cb
+ callback!(setter, 2, sw.switch_name, val) if setter
+ rescue ParseError
+ raise $!.set_option(arg, rest)
+ end
+
+ # short option
+ when /\A-(.)((=).*|.+)?/m
+ eq, rest, opt = $3, $2, $1
+ has_arg, val = eq, rest
+ begin
+ sw, = search(:short, opt)
+ unless sw
+ begin
+ sw, = complete(:short, opt)
+ # short option matched.
+ val = arg.delete_prefix('-')
+ has_arg = true
+ rescue InvalidOption
+ raise if exact
+ # if no short options match, try completion with long
+ # options.
+ sw, = complete(:long, opt)
+ eq ||= !rest
+ end
+ end
+ rescue ParseError
+ throw :terminate, arg unless raise_unknown
+ raise $!.set_option(arg, true)
+ end
+ begin
+ opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
+ rescue ParseError
+ raise $!.set_option(arg, arg.length > 2)
+ else
+ raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
+ end
+ begin
+ argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-')
+ val = callback!(cb, 1, val) if cb
+ callback!(setter, 2, sw.switch_name, val) if setter
+ rescue ParseError
+ raise $!.set_option(arg, arg.length > 2)
+ end
+
+ # non-option argument
+ else
+ catch(:prune) do
+ visit(:each_option) do |sw0|
+ sw = sw0
+ sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg)
+ end
+ nonopt.call(arg)
+ end
+ end
+ end
+
+ nil
+ }
+
+ visit(:search, :short, nil) {|sw| sw.block.call(*argv) if !sw.pattern}
+
+ argv
+ end
+ private :parse_in_order
+
+ # Calls callback with _val_.
+ def callback!(cb, max_arity, *args) # :nodoc:
+ args.compact!
+
+ if (size = args.size) < max_arity and cb.to_proc.lambda?
+ (arity = cb.arity) < 0 and arity = (1-arity)
+ arity = max_arity if arity > max_arity
+ args[arity - 1] = nil if arity > size
+ end
+ cb.call(*args)
+ end
+ private :callback!
+
+ #
+ # Parses command line arguments +argv+ in permutation mode and returns
+ # list of non-option arguments. When optional +into+ keyword
+ # argument is provided, the parsed option values are stored there via
+ # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
+ # similar object).
+ #
+ def permute(*argv, **keywords)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ permute!(argv, **keywords)
+ end
+
+ #
+ # Same as #permute, but removes switches destructively.
+ # Non-option arguments remain in +argv+.
+ #
+ def permute!(argv = default_argv, **keywords)
+ nonopts = []
+ order!(argv, **keywords) {|nonopt| nonopts << nonopt}
+ argv[0, 0] = nonopts
+ argv
+ end
+
+ #
+ # Parses command line arguments +argv+ in order when environment variable
+ # POSIXLY_CORRECT is set, and in permutation mode otherwise.
+ # When optional +into+ keyword argument is provided, the parsed option
+ # values are stored there via <code>[]=</code> method (so it can be Hash,
+ # or OpenStruct, or other similar object).
+ #
+ def parse(*argv, **keywords)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ parse!(argv, **keywords)
+ end
+
+ #
+ # Same as #parse, but removes switches destructively.
+ # Non-option arguments remain in +argv+.
+ #
+ def parse!(argv = default_argv, **keywords)
+ if ENV.include?('POSIXLY_CORRECT')
+ order!(argv, **keywords)
+ else
+ permute!(argv, **keywords)
+ end
+ end
+
+ #
+ # Wrapper method for getopts.rb.
+ #
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
+ # # params["a"] = true # -a
+ # # params["b"] = "1" # -b1
+ # # params["foo"] = "1" # --foo
+ # # params["bar"] = "x" # --bar x
+ # # params["zot"] = "z" # --zot Z
+ #
+ # Option +symbolize_names+ (boolean) specifies whether returned Hash keys should be Symbols; defaults to +false+ (use Strings).
+ #
+ # params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option", symbolize_names: true)
+ # # params[:a] = true # -a
+ # # params[:b] = "1" # -b1
+ # # params[:foo] = "1" # --foo
+ # # params[:bar] = "x" # --bar x
+ # # params[:zot] = "z" # --zot Z
+ #
+ def getopts(*args, symbolize_names: false, **keywords)
+ argv = Array === args.first ? args.shift : default_argv
+ single_options, *long_options = *args
+
+ result = {}
+ setter = (symbolize_names ?
+ ->(name, val) {result[name.to_sym] = val}
+ : ->(name, val) {result[name] = val})
+
+ single_options.scan(/(.)(:)?/) do |opt, val|
+ if val
+ setter[opt, nil]
+ define("-#{opt} VAL")
+ else
+ setter[opt, false]
+ define("-#{opt}")
+ end
+ end if single_options
+
+ long_options.each do |arg|
+ arg, desc = arg.split(';', 2)
+ opt, val = arg.split(':', 2)
+ if val
+ setter[opt, (val unless val.empty?)]
+ define("--#{opt}=#{result[opt] || "VAL"}", *[desc].compact)
+ else
+ setter[opt, false]
+ define("--#{opt}", *[desc].compact)
+ end
+ end
+
+ parse_in_order(argv, setter, **keywords)
+ result
+ end
+
+ #
+ # See #getopts.
+ #
+ def self.getopts(*args, symbolize_names: false)
+ new.getopts(*args, symbolize_names: symbolize_names)
+ end
+
+ #
+ # Traverses @stack, sending each element method +id+ with +args+ and
+ # +block+.
+ #
+ def visit(id, *args, &block) # :nodoc:
+ @stack.reverse_each do |el|
+ el.__send__(id, *args, &block)
+ end
+ nil
+ end
+ private :visit
+
+ #
+ # Searches +key+ in @stack for +id+ hash and returns or yields the result.
+ #
+ def search(id, key) # :nodoc:
+ block_given = block_given?
+ visit(:search, id, key) do |k|
+ return block_given ? yield(k) : k
+ end
+ end
+ private :search
+
+ #
+ # Completes shortened long style option switch and returns pair of
+ # canonical switch and switch descriptor Gem::OptionParser::Switch.
+ #
+ # +typ+:: Searching table.
+ # +opt+:: Searching key.
+ # +icase+:: Search case insensitive if true.
+ # +pat+:: Optional pattern for completion.
+ #
+ def complete(typ, opt, icase = false, *pat) # :nodoc:
+ if pat.empty?
+ search(typ, opt) {|sw| return [sw, opt]} # exact match or...
+ end
+ ambiguous = catch(:ambiguous) {
+ visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
+ }
+ exc = ambiguous ? AmbiguousOption : InvalidOption
+ raise exc.new(opt, additional: proc {|o| additional_message(typ, o)})
+ end
+ private :complete
+
+ #
+ # Returns additional info.
+ #
+ def additional_message(typ, opt)
+ return unless typ and opt and defined?(DidYouMean::SpellChecker)
+ all_candidates = []
+ visit(:get_candidates, typ) do |candidates|
+ all_candidates.concat(candidates)
+ end
+ all_candidates.select! {|cand| cand.is_a?(String) }
+ checker = DidYouMean::SpellChecker.new(dictionary: all_candidates)
+ DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
+ end
+
+ #
+ # Return candidates for +word+.
+ #
+ def candidate(word)
+ list = []
+ case word
+ when '-'
+ long = short = true
+ when /\A--/
+ word, arg = word.split(/=/, 2)
+ argpat = Completion.regexp(arg, false) if arg and !arg.empty?
+ long = true
+ when /\A-/
+ short = true
+ end
+ pat = Completion.regexp(word, long)
+ visit(:each_option) do |opt|
+ next unless Switch === opt
+ opts = (long ? opt.long : []) + (short ? opt.short : [])
+ opts = Completion.candidate(word, true, pat, &opts.method(:each)).map(&:first) if pat
+ if /\A=/ =~ opt.arg
+ opts.map! {|sw| sw + "="}
+ if arg and CompletingHash === opt.pattern
+ if opts = opt.pattern.candidate(arg, false, argpat)
+ opts.map!(&:last)
+ end
+ end
+ end
+ list.concat(opts)
+ end
+ list
+ end
+
+ #
+ # Loads options from file names as +filename+. Does nothing when the file
+ # is not present. Returns whether successfully loaded.
+ #
+ # +filename+ defaults to basename of the program without suffix in a
+ # directory ~/.options, then the basename with '.options' suffix
+ # under XDG and Haiku standard places.
+ #
+ # The optional +into+ keyword argument works exactly like that accepted in
+ # method #parse.
+ #
+ def load(filename = nil, **keywords)
+ unless filename
+ basename = File.basename($0, '.*')
+ return true if load(File.expand_path("~/.options/#{basename}"), **keywords) rescue nil
+ basename << ".options"
+ if !(xdg = ENV['XDG_CONFIG_HOME']) or xdg.empty?
+ # https://specifications.freedesktop.org/basedir-spec/latest/#variables
+ #
+ # If $XDG_CONFIG_HOME is either not set or empty, a default
+ # equal to $HOME/.config should be used.
+ xdg = ['~/.config', true]
+ end
+ return [
+ xdg,
+
+ *ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR),
+
+ # Haiku
+ ['~/config/settings', true],
+ ].any? {|dir, expand|
+ next if !dir or dir.empty?
+ filename = File.join(dir, basename)
+ filename = File.expand_path(filename) if expand
+ load(filename, **keywords) rescue nil
+ }
+ end
+ begin
+ parse(*File.readlines(filename, chomp: true), **keywords)
+ true
+ rescue Errno::ENOENT, Errno::ENOTDIR
+ false
+ end
+ end
+
+ #
+ # Parses environment variable +env+ or its uppercase with splitting like a
+ # shell.
+ #
+ # +env+ defaults to the basename of the program.
+ #
+ def environment(env = File.basename($0, '.*'), **keywords)
+ env = ENV[env] || ENV[env.upcase] or return
+ require 'shellwords'
+ parse(*Shellwords.shellwords(env), **keywords)
+ end
+
+ #
+ # Acceptable argument classes
+ #
+
+ #
+ # Any string and no conversion. This is fall-back.
+ #
+ accept(Object) {|s,|s or s.nil?}
+
+ accept(NilClass) {|s,|s}
+
+ #
+ # Any non-empty string, and no conversion.
+ #
+ accept(String, /.+/m) {|s,*|s}
+
+ #
+ # Ruby/C-like integer, octal for 0-7 sequence, binary for 0b, hexadecimal
+ # for 0x, and decimal for others; with optional sign prefix. Converts to
+ # Integer.
+ #
+ decimal = '\d+(?:_\d+)*'
+ binary = 'b[01]+(?:_[01]+)*'
+ hex = 'x[\da-f]+(?:_[\da-f]+)*'
+ octal = "0(?:[0-7]+(?:_[0-7]+)*|#{binary}|#{hex})?"
+ integer = "#{octal}|#{decimal}"
+
+ accept(Integer, %r"\A[-+]?(?:#{integer})\z"io) {|s,|
+ begin
+ Integer(s)
+ rescue ArgumentError
+ raise Gem::OptionParser::InvalidArgument, s
+ end if s
+ }
+
+ #
+ # Float number format, and converts to Float.
+ #
+ float = "(?:#{decimal}(?=(.)?)(?:\\.(?:#{decimal})?)?|\\.#{decimal})(?:E[-+]?#{decimal})?"
+ floatpat = %r"\A[-+]?#{float}\z"io
+ accept(Float, floatpat) {|s,| s.to_f if s}
+
+ #
+ # Generic numeric format, converts to Integer for integer format, Float
+ # for float format, and Rational for rational format.
+ #
+ real = "[-+]?(?:#{octal}|#{float})"
+ accept(Numeric, /\A(#{real})(?:\/(#{real}))?\z/io) {|s, d, f, n,|
+ if n
+ Rational(d, n)
+ elsif f
+ Float(s)
+ else
+ Integer(s)
+ end
+ }
+
+ #
+ # Decimal integer format, to be converted to Integer.
+ #
+ DecimalInteger = /\A[-+]?#{decimal}\z/io
+ accept(DecimalInteger, DecimalInteger) {|s,|
+ begin
+ Integer(s, 10)
+ rescue ArgumentError
+ raise Gem::OptionParser::InvalidArgument, s
+ end if s
+ }
+
+ #
+ # Ruby/C like octal/hexadecimal/binary integer format, to be converted to
+ # Integer.
+ #
+ OctalInteger = /\A[-+]?(?:[0-7]+(?:_[0-7]+)*|0(?:#{binary}|#{hex}))\z/io
+ accept(OctalInteger, OctalInteger) {|s,|
+ begin
+ Integer(s, 8)
+ rescue ArgumentError
+ raise Gem::OptionParser::InvalidArgument, s
+ end if s
+ }
+
+ #
+ # Decimal integer/float number format, to be converted to Integer for
+ # integer format, Float for float format.
+ #
+ DecimalNumeric = floatpat # decimal integer is allowed as float also.
+ accept(DecimalNumeric, floatpat) {|s, f|
+ begin
+ if f
+ Float(s)
+ else
+ Integer(s)
+ end
+ rescue ArgumentError
+ raise Gem::OptionParser::InvalidArgument, s
+ end if s
+ }
+
+ #
+ # Boolean switch, which means whether it is present or not, whether it is
+ # absent or not with prefix no-, or it takes an argument
+ # yes/no/true/false/+/-.
+ #
+ yesno = CompletingHash.new
+ %w[- no false].each {|el| yesno[el] = false}
+ %w[+ yes true].each {|el| yesno[el] = true}
+ yesno['nil'] = false # should be nil?
+ accept(TrueClass, yesno) {|arg, val| val == nil or val}
+ #
+ # Similar to TrueClass, but defaults to false.
+ #
+ accept(FalseClass, yesno) {|arg, val| val != nil and val}
+
+ #
+ # List of strings separated by ",".
+ #
+ accept(Array) do |s, |
+ if s
+ s = s.split(',').collect {|ss| ss unless ss.empty?}
+ end
+ s
+ end
+
+ #
+ # Regular expression with options.
+ #
+ accept(Regexp, %r"\A/((?:\\.|[^\\])*)/([[:alpha:]]+)?\z|.*") do |all, s, o|
+ f = 0
+ if o
+ f |= Regexp::IGNORECASE if /i/ =~ o
+ f |= Regexp::MULTILINE if /m/ =~ o
+ f |= Regexp::EXTENDED if /x/ =~ o
+ case o = o.delete("imx")
+ when ""
+ when "u"
+ s = s.encode(Encoding::UTF_8)
+ when "e"
+ s = s.encode(Encoding::EUC_JP)
+ when "s"
+ s = s.encode(Encoding::SJIS)
+ when "n"
+ f |= Regexp::NOENCODING
+ else
+ raise Gem::OptionParser::InvalidArgument, "unknown regexp option - #{o}"
+ end
+ else
+ s ||= all
+ end
+ Regexp.new(s, f)
+ end
+
+ #
+ # Exceptions
+ #
+
+ #
+ # Base class of exceptions from Gem::OptionParser.
+ #
+ class ParseError < RuntimeError
+ # Reason which caused the error.
+ Reason = 'parse error'
+
+ # :nodoc:
+ def initialize(*args, additional: nil)
+ @additional = additional
+ @arg0, = args
+ @args = args
+ @reason = nil
+ end
+
+ attr_reader :args
+ attr_writer :reason
+ attr_accessor :additional
+
+ #
+ # Pushes back erred argument(s) to +argv+.
+ #
+ def recover(argv)
+ argv[0, 0] = @args
+ argv
+ end
+
+ DIR = File.join(__dir__, '')
+ def self.filter_backtrace(array)
+ unless $DEBUG
+ array.delete_if {|bt| bt.start_with?(DIR)}
+ end
+ array
+ end
+
+ def set_backtrace(array)
+ super(self.class.filter_backtrace(array))
+ end
+
+ def set_option(opt, eq)
+ if eq
+ @args[0] = opt
+ else
+ @args.unshift(opt)
+ end
+ self
+ end
+
+ #
+ # Returns error reason. Override this for I18N.
+ #
+ def reason
+ @reason || self.class::Reason
+ end
+
+ def inspect
+ "#<#{self.class}: #{args.join(' ')}>"
+ end
+
+ #
+ # Default stringizing method to emit standard error message.
+ #
+ def message
+ "#{reason}: #{args.join(' ')}#{additional[@arg0] if additional}"
+ end
+
+ alias to_s message
+ end
+
+ #
+ # Raises when ambiguously completable string is encountered.
+ #
+ class AmbiguousOption < ParseError
+ const_set(:Reason, 'ambiguous option')
+ end
+
+ #
+ # Raises when there is an argument for a switch which takes no argument.
+ #
+ class NeedlessArgument < ParseError
+ const_set(:Reason, 'needless argument')
+ end
+
+ #
+ # Raises when a switch with mandatory argument has no argument.
+ #
+ class MissingArgument < ParseError
+ const_set(:Reason, 'missing argument')
+ end
+
+ #
+ # Raises when switch is undefined.
+ #
+ class InvalidOption < ParseError
+ const_set(:Reason, 'invalid option')
+ end
+
+ #
+ # Raises when the given argument does not match required format.
+ #
+ class InvalidArgument < ParseError
+ const_set(:Reason, 'invalid argument')
+ end
+
+ #
+ # Raises when the given argument word can't be completed uniquely.
+ #
+ class AmbiguousArgument < InvalidArgument
+ const_set(:Reason, 'ambiguous argument')
+ end
+
+ #
+ # Miscellaneous
+ #
+
+ #
+ # Extends command line arguments array (ARGV) to parse itself.
+ #
+ module Arguable
+
+ #
+ # Sets Gem::OptionParser object, when +opt+ is +false+ or +nil+, methods
+ # Gem::OptionParser::Arguable#options and Gem::OptionParser::Arguable#options= are
+ # undefined. Thus, there is no ways to access the Gem::OptionParser object
+ # via the receiver object.
+ #
+ def options=(opt)
+ unless @optparse = opt
+ class << self
+ undef_method(:options)
+ undef_method(:options=)
+ end
+ end
+ end
+
+ #
+ # Actual Gem::OptionParser object, automatically created if nonexistent.
+ #
+ # If called with a block, yields the Gem::OptionParser object and returns the
+ # result of the block. If an Gem::OptionParser::ParseError exception occurs
+ # in the block, it is rescued, a error message printed to STDERR and
+ # +nil+ returned.
+ #
+ def options
+ @optparse ||= Gem::OptionParser.new
+ @optparse.default_argv = self
+ block_given? or return @optparse
+ begin
+ yield @optparse
+ rescue ParseError
+ @optparse.warn $!
+ nil
+ end
+ end
+
+ #
+ # Parses +self+ destructively in order and returns +self+ containing the
+ # rest arguments left unparsed.
+ #
+ def order!(**keywords, &blk) options.order!(self, **keywords, &blk) end
+
+ #
+ # Parses +self+ destructively in permutation mode and returns +self+
+ # containing the rest arguments left unparsed.
+ #
+ def permute!(**keywords) options.permute!(self, **keywords) end
+
+ #
+ # Parses +self+ destructively and returns +self+ containing the
+ # rest arguments left unparsed.
+ #
+ def parse!(**keywords) options.parse!(self, **keywords) end
+
+ #
+ # Substitution of getopts is possible as follows. Also see
+ # Gem::OptionParser#getopts.
+ #
+ # def getopts(*args)
+ # ($OPT = ARGV.getopts(*args)).each do |opt, val|
+ # eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val"
+ # end
+ # rescue Gem::OptionParser::ParseError
+ # end
+ #
+ def getopts(*args, symbolize_names: false, **keywords)
+ options.getopts(self, *args, symbolize_names: symbolize_names, **keywords)
+ end
+
+ #
+ # Initializes instance variable.
+ #
+ def self.extend_object(obj)
+ super
+ obj.instance_eval {@optparse = nil}
+ end
+
+ def initialize(*args) # :nodoc:
+ super
+ @optparse = nil
+ end
+ end
+
+ #
+ # Acceptable argument classes. Now contains DecimalInteger, OctalInteger
+ # and DecimalNumeric. See Acceptable argument classes (in source code).
+ #
+ module Acceptables
+ const_set(:DecimalInteger, Gem::OptionParser::DecimalInteger)
+ const_set(:OctalInteger, Gem::OptionParser::OctalInteger)
+ const_set(:DecimalNumeric, Gem::OptionParser::DecimalNumeric)
+ end
+end
+
+# ARGV is arguable by Gem::OptionParser
+ARGV.extend(Gem::OptionParser::Arguable)
diff --git a/lib/rubygems/vendor/optparse/lib/optparse/ac.rb b/lib/rubygems/vendor/optparse/lib/optparse/ac.rb
new file mode 100644
index 0000000000..28a5b1b33e
--- /dev/null
+++ b/lib/rubygems/vendor/optparse/lib/optparse/ac.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: false
+require_relative '../optparse'
+
+#
+# autoconf-like options.
+#
+class Gem::OptionParser::AC < Gem::OptionParser
+ # :stopdoc:
+ private
+
+ def _check_ac_args(name, block)
+ unless /\A\w[-\w]*\z/ =~ name
+ raise ArgumentError, name
+ end
+ unless block
+ raise ArgumentError, "no block given", ParseError.filter_backtrace(caller)
+ end
+ end
+
+ ARG_CONV = proc {|val| val.nil? ? true : val}
+ private_constant :ARG_CONV
+
+ def _ac_arg_enable(prefix, name, help_string, block)
+ _check_ac_args(name, block)
+
+ sdesc = []
+ ldesc = ["--#{prefix}-#{name}"]
+ desc = [help_string]
+ q = name.downcase
+ ac_block = proc {|val| block.call(ARG_CONV.call(val))}
+ enable = Switch::PlacedArgument.new(nil, ARG_CONV, sdesc, ldesc, nil, desc, ac_block)
+ disable = Switch::NoArgument.new(nil, proc {false}, sdesc, ldesc, nil, desc, ac_block)
+ top.append(enable, [], ["enable-" + q], disable, ['disable-' + q])
+ enable
+ end
+
+ # :startdoc:
+
+ public
+
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
+ #
+ # Appears as <tt>--enable-<i>name</i></tt> in help message.
+ def ac_arg_enable(name, help_string, &block)
+ _ac_arg_enable("enable", name, help_string, block)
+ end
+
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
+ #
+ # Appears as <tt>--disable-<i>name</i></tt> in help message.
+ def ac_arg_disable(name, help_string, &block)
+ _ac_arg_enable("disable", name, help_string, block)
+ end
+
+ # Define <tt>--with</tt> / <tt>--without</tt> style option
+ #
+ # Appears as <tt>--with-<i>name</i></tt> in help message.
+ def ac_arg_with(name, help_string, &block)
+ _check_ac_args(name, block)
+
+ sdesc = []
+ ldesc = ["--with-#{name}"]
+ desc = [help_string]
+ q = name.downcase
+ with = Switch::PlacedArgument.new(*search(:atype, String), sdesc, ldesc, nil, desc, block)
+ without = Switch::NoArgument.new(nil, proc {}, sdesc, ldesc, nil, desc, block)
+ top.append(with, [], ["with-" + q], without, ['without-' + q])
+ with
+ end
+end
diff --git a/lib/rubygems/optparse/lib/optparse/date.rb b/lib/rubygems/vendor/optparse/lib/optparse/date.rb
index d9a9f4f48a..d9a9f4f48a 100644
--- a/lib/rubygems/optparse/lib/optparse/date.rb
+++ b/lib/rubygems/vendor/optparse/lib/optparse/date.rb
diff --git a/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb b/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb
new file mode 100644
index 0000000000..70762f033b
--- /dev/null
+++ b/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+require_relative '../optparse'
+
+class Gem::OptionParser
+ # :call-seq:
+ # define_by_keywords(options, method, **params)
+ #
+ # :include: ../../doc/optparse/creates_option.rdoc
+ #
+ # Defines options which set in to _options_ for keyword parameters
+ # of _method_.
+ #
+ # Parameters for each keywords are given as elements of _params_.
+ #
+ def define_by_keywords(options, method, **params)
+ method.parameters.each do |type, name|
+ case type
+ when :key, :keyreq
+ op, cl = *(type == :key ? %w"[ ]" : ["", ""])
+ define("--#{name}=#{op}#{name.upcase}#{cl}", *params[name]) do |o|
+ options[name] = o
+ end
+ end
+ end
+ options
+ end
+end
diff --git a/lib/rubygems/optparse/lib/optparse/shellwords.rb b/lib/rubygems/vendor/optparse/lib/optparse/shellwords.rb
index d47ad60255..d47ad60255 100644
--- a/lib/rubygems/optparse/lib/optparse/shellwords.rb
+++ b/lib/rubygems/vendor/optparse/lib/optparse/shellwords.rb
diff --git a/lib/rubygems/optparse/lib/optparse/time.rb b/lib/rubygems/vendor/optparse/lib/optparse/time.rb
index c59e1e4ced..c59e1e4ced 100644
--- a/lib/rubygems/optparse/lib/optparse/time.rb
+++ b/lib/rubygems/vendor/optparse/lib/optparse/time.rb
diff --git a/lib/rubygems/vendor/optparse/lib/optparse/uri.rb b/lib/rubygems/vendor/optparse/lib/optparse/uri.rb
new file mode 100644
index 0000000000..398127479a
--- /dev/null
+++ b/lib/rubygems/vendor/optparse/lib/optparse/uri.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: false
+# -*- ruby -*-
+
+require_relative '../optparse'
+require_relative '../../../uri/lib/uri'
+
+Gem::OptionParser.accept(Gem::URI) {|s,| Gem::URI.parse(s) if s}
diff --git a/lib/rubygems/vendor/optparse/lib/optparse/version.rb b/lib/rubygems/vendor/optparse/lib/optparse/version.rb
new file mode 100644
index 0000000000..e39889ae87
--- /dev/null
+++ b/lib/rubygems/vendor/optparse/lib/optparse/version.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: false
+# Gem::OptionParser internal utility
+
+class << Gem::OptionParser
+ #
+ # Shows version string in packages if Version is defined.
+ #
+ # +pkgs+:: package list
+ #
+ def show_version(*pkgs)
+ progname = ARGV.options.program_name
+ result = false
+ show = proc do |klass, cname, version|
+ str = "#{progname}"
+ unless klass == ::Object and cname == :VERSION
+ version = version.join(".") if Array === version
+ str << ": #{klass}" unless klass == Object
+ str << " version #{version}"
+ end
+ [:Release, :RELEASE].find do |rel|
+ if klass.const_defined?(rel)
+ str << " (#{klass.const_get(rel)})"
+ end
+ end
+ puts str
+ result = true
+ end
+ if pkgs.size == 1 and pkgs[0] == "all"
+ self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
+ unless cname[1] == ?e and klass.const_defined?(:Version)
+ show.call(klass, cname.intern, version)
+ end
+ end
+ else
+ pkgs.each do |pkg|
+ begin
+ pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
+ v = case
+ when pkg.const_defined?(:Version)
+ pkg.const_get(n = :Version)
+ when pkg.const_defined?(:VERSION)
+ pkg.const_get(n = :VERSION)
+ else
+ n = nil
+ "unknown"
+ end
+ show.call(pkg, n, v)
+ rescue NameError
+ end
+ end
+ end
+ result
+ end
+
+ # :stopdoc:
+
+ def each_const(path, base = ::Object)
+ path.split(/::|\//).inject(base) do |klass, name|
+ raise NameError, path unless Module === klass
+ klass.constants.grep(/#{name}/i) do |c|
+ klass.const_defined?(c) or next
+ klass.const_get(c)
+ end
+ end
+ end
+
+ def search_const(klass, name)
+ klasses = [klass]
+ while klass = klasses.shift
+ klass.constants.each do |cname|
+ klass.const_defined?(cname) or next
+ const = klass.const_get(cname)
+ yield klass, cname, const if name === cname
+ klasses << const if Module === const and const != ::Object
+ end
+ end
+ end
+
+ # :startdoc:
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub.rb
new file mode 100644
index 0000000000..818e947477
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub.rb
@@ -0,0 +1,53 @@
+require_relative "pub_grub/package"
+require_relative "pub_grub/static_package_source"
+require_relative "pub_grub/term"
+require_relative "pub_grub/version_range"
+require_relative "pub_grub/version_constraint"
+require_relative "pub_grub/version_union"
+require_relative "pub_grub/version_solver"
+require_relative "pub_grub/incompatibility"
+require_relative 'pub_grub/solve_failure'
+require_relative 'pub_grub/failure_writer'
+require_relative 'pub_grub/version'
+
+module Gem::PubGrub
+ # Minimal logger that doesn't require the 'logger' gem
+ class NullLogger
+ def info(&block); end
+ def debug(&block); end
+ def warn(&block); end
+ def error(&block); end
+ end
+
+ class StderrLogger
+ def info(&block)
+ $stderr.puts "INFO: #{block.call}" if block
+ end
+
+ def debug(&block)
+ $stderr.puts "DEBUG: #{block.call}" if block
+ end
+
+ def warn(&block)
+ $stderr.puts "WARN: #{block.call}" if block
+ end
+
+ def error(&block)
+ $stderr.puts "ERROR: #{block.call}" if block
+ end
+ end
+
+ class << self
+ attr_writer :logger
+
+ def logger
+ @logger || default_logger
+ end
+
+ private
+
+ def default_logger
+ @logger = $DEBUG ? StderrLogger.new : NullLogger.new
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/assignment.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/assignment.rb
new file mode 100644
index 0000000000..7a11cf0933
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/assignment.rb
@@ -0,0 +1,20 @@
+module Gem::PubGrub
+ class Assignment
+ attr_reader :term, :cause, :decision_level, :index
+ def initialize(term, cause, decision_level, index)
+ @term = term
+ @cause = cause
+ @decision_level = decision_level
+ @index = index
+ end
+
+ def self.decision(package, version, decision_level, index)
+ term = Term.new(VersionConstraint.exact(package, version), true)
+ new(term, :decision, decision_level, index)
+ end
+
+ def decision?
+ cause == :decision
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/basic_package_source.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
new file mode 100644
index 0000000000..c8dbf2a5ab
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
@@ -0,0 +1,169 @@
+require_relative 'version_constraint'
+require_relative 'incompatibility'
+
+module Gem::PubGrub
+ # Types:
+ #
+ # Where possible, Gem::PubGrub will accept user-defined types, so long as they quack.
+ #
+ # ## "Package":
+ #
+ # This class will be used to represent the various packages being solved for.
+ # .to_s will be called when displaying errors and debugging info, it should
+ # probably return the package's name.
+ # It must also have a reasonable definition of #== and #hash
+ #
+ # Example classes: String ("rails")
+ #
+ #
+ # ## "Version":
+ #
+ # This class will be used to represent a single version number.
+ #
+ # Versions don't need to store their associated package, however they will
+ # only be compared against other versions of the same package.
+ #
+ # It must be Comparible (and implement <=> reasonably)
+ #
+ # Example classes: Gem::Version, Integer
+ #
+ #
+ # ## "Dependency"
+ #
+ # This class represents the requirement one package has on another. It is
+ # returned by dependencies_for(package, version) and will be passed to
+ # parse_dependency to convert it to a format Gem::PubGrub understands.
+ #
+ # It must also have a reasonable definition of #==
+ #
+ # Example classes: String ("~> 1.0"), Gem::Requirement
+ #
+ class BasicPackageSource
+ # Override me!
+ #
+ # This is called per package to find all possible versions of a package.
+ #
+ # It is called at most once per-package
+ #
+ # Returns: Array of versions for a package, in preferred order of selection
+ def all_versions_for(package)
+ raise NotImplementedError
+ end
+
+ # Override me!
+ #
+ # Returns: Hash in the form of { package => requirement, ... }
+ def dependencies_for(package, version)
+ raise NotImplementedError
+ end
+
+ # Override me!
+ #
+ # Convert a (user-defined) dependency into a format Gem::PubGrub understands.
+ #
+ # Package is passed to this method but for many implementations is not
+ # needed.
+ #
+ # Returns: either a Gem::PubGrub::VersionRange, Gem::PubGrub::VersionUnion, or a
+ # Gem::PubGrub::VersionConstraint
+ def parse_dependency(package, dependency)
+ raise NotImplementedError
+ end
+
+ # Override me!
+ #
+ # If not overridden, this will call dependencies_for with the root package.
+ #
+ # Returns: Hash in the form of { package => requirement, ... } (see dependencies_for)
+ def root_dependencies
+ dependencies_for(@root_package, @root_version)
+ end
+
+ def initialize
+ @root_package = Package.root
+ @root_version = Package.root_version
+
+ @sorted_versions = Hash.new do |h,k|
+ if k == @root_package
+ h[k] = [@root_version]
+ else
+ h[k] = all_versions_for(k).sort
+ end
+ end
+
+ @cached_dependencies = Hash.new do |packages, package|
+ if package == @root_package
+ packages[package] = {
+ @root_version => root_dependencies
+ }
+ else
+ packages[package] = Hash.new do |versions, version|
+ versions[version] = dependencies_for(package, version)
+ end
+ end
+ end
+ end
+
+ def versions_for(package, range=VersionRange.any)
+ range.select_versions(@sorted_versions[package])
+ end
+
+ def no_versions_incompatibility_for(_package, unsatisfied_term)
+ cause = Incompatibility::NoVersions.new(unsatisfied_term)
+
+ Incompatibility.new([unsatisfied_term], cause: cause)
+ end
+
+ def incompatibilities_for(package, version)
+ package_deps = @cached_dependencies[package]
+ sorted_versions = @sorted_versions[package]
+ package_deps[version].map do |dep_package, dep_constraint_name|
+ low = high = sorted_versions.index(version)
+
+ # find version low such that all >= low share the same dep
+ while low > 0 &&
+ package_deps[sorted_versions[low - 1]][dep_package] == dep_constraint_name
+ low -= 1
+ end
+ low =
+ if low == 0
+ nil
+ else
+ sorted_versions[low]
+ end
+
+ # find version high such that all < high share the same dep
+ while high < sorted_versions.length &&
+ package_deps[sorted_versions[high]][dep_package] == dep_constraint_name
+ high += 1
+ end
+ high =
+ if high == sorted_versions.length
+ nil
+ else
+ sorted_versions[high]
+ end
+
+ range = VersionRange.new(min: low, max: high, include_min: !low.nil?)
+
+ self_constraint = VersionConstraint.new(package, range: range)
+
+ if !@packages.include?(dep_package)
+ # no such package -> this version is invalid
+ end
+
+ dep_constraint = parse_dependency(dep_package, dep_constraint_name)
+ if !dep_constraint
+ # falsey indicates this dependency was invalid
+ cause = Gem::PubGrub::Incompatibility::InvalidDependency.new(dep_package, dep_constraint_name)
+ return [Incompatibility.new([Term.new(self_constraint, true)], cause: cause)]
+ elsif !dep_constraint.is_a?(VersionConstraint)
+ # Upgrade range/union to VersionConstraint
+ dep_constraint = VersionConstraint.new(dep_package, range: dep_constraint)
+ end
+
+ Incompatibility.new([Term.new(self_constraint, true), Term.new(dep_constraint, false)], cause: :dependency)
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/failure_writer.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/failure_writer.rb
new file mode 100644
index 0000000000..d8bfde0286
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/failure_writer.rb
@@ -0,0 +1,182 @@
+module Gem::PubGrub
+ class FailureWriter
+ def initialize(root)
+ @root = root
+
+ # { Incompatibility => Integer }
+ @derivations = {}
+
+ # [ [ String, Integer or nil ] ]
+ @lines = []
+
+ # { Incompatibility => Integer }
+ @line_numbers = {}
+
+ count_derivations(root)
+ end
+
+ def write
+ return @root.to_s unless @root.conflict?
+
+ visit(@root)
+
+ padding = @line_numbers.empty? ? 0 : "(#{@line_numbers.values.last}) ".length
+
+ @lines.map do |message, number|
+ next "" if message.empty?
+
+ lead = number ? "(#{number}) " : ""
+ lead = lead.ljust(padding)
+ message = message.gsub("\n", "\n" + " " * (padding + 2))
+ "#{lead}#{message}"
+ end.join("\n")
+ end
+
+ private
+
+ def write_line(incompatibility, message, numbered:)
+ if numbered
+ number = @line_numbers.length + 1
+ @line_numbers[incompatibility] = number
+ end
+
+ @lines << [message, number]
+ end
+
+ def visit(incompatibility, conclusion: false)
+ raise unless incompatibility.conflict?
+
+ numbered = conclusion || @derivations[incompatibility] > 1;
+ conjunction = conclusion || incompatibility == @root ? "So," : "And"
+
+ cause = incompatibility.cause
+
+ if cause.conflict.conflict? && cause.other.conflict?
+ conflict_line = @line_numbers[cause.conflict]
+ other_line = @line_numbers[cause.other]
+
+ if conflict_line && other_line
+ write_line(
+ incompatibility,
+ "Because #{cause.conflict} (#{conflict_line})\nand #{cause.other} (#{other_line}),\n#{incompatibility}.",
+ numbered: numbered
+ )
+ elsif conflict_line || other_line
+ with_line = conflict_line ? cause.conflict : cause.other
+ without_line = conflict_line ? cause.other : cause.conflict
+ line = @line_numbers[with_line]
+
+ visit(without_line);
+ write_line(
+ incompatibility,
+ "#{conjunction} because #{with_line} (#{line}),\n#{incompatibility}.",
+ numbered: numbered
+ )
+ else
+ single_line_conflict = single_line?(cause.conflict.cause)
+ single_line_other = single_line?(cause.other.cause)
+
+ if single_line_conflict || single_line_other
+ first = single_line_other ? cause.conflict : cause.other
+ second = single_line_other ? cause.other : cause.conflict
+ visit(first)
+ visit(second)
+ write_line(
+ incompatibility,
+ "Thus, #{incompatibility}.",
+ numbered: numbered
+ )
+ else
+ visit(cause.conflict, conclusion: true)
+ @lines << ["", nil]
+ visit(cause.other)
+
+ write_line(
+ incompatibility,
+ "#{conjunction} because #{cause.conflict} (#{@line_numbers[cause.conflict]}),\n#{incompatibility}.",
+ numbered: numbered
+ )
+ end
+ end
+ elsif cause.conflict.conflict? || cause.other.conflict?
+ derived = cause.conflict.conflict? ? cause.conflict : cause.other
+ ext = cause.conflict.conflict? ? cause.other : cause.conflict
+
+ derived_line = @line_numbers[derived]
+ if derived_line
+ write_line(
+ incompatibility,
+ "Because #{ext}\nand #{derived} (#{derived_line}),\n#{incompatibility}.",
+ numbered: numbered
+ )
+ elsif collapsible?(derived)
+ derived_cause = derived.cause
+ if derived_cause.conflict.conflict?
+ collapsed_derived = derived_cause.conflict
+ collapsed_ext = derived_cause.other
+ else
+ collapsed_derived = derived_cause.other
+ collapsed_ext = derived_cause.conflict
+ end
+
+ visit(collapsed_derived)
+
+ write_line(
+ incompatibility,
+ "#{conjunction} because #{collapsed_ext}\nand #{ext},\n#{incompatibility}.",
+ numbered: numbered
+ )
+ else
+ visit(derived)
+ write_line(
+ incompatibility,
+ "#{conjunction} because #{ext},\n#{incompatibility}.",
+ numbered: numbered
+ )
+ end
+ else
+ write_line(
+ incompatibility,
+ "Because #{cause.conflict}\nand #{cause.other},\n#{incompatibility}.",
+ numbered: numbered
+ )
+ end
+ end
+
+ def single_line?(cause)
+ !cause.conflict.conflict? && !cause.other.conflict?
+ end
+
+ def collapsible?(incompatibility)
+ return false if @derivations[incompatibility] > 1
+
+ cause = incompatibility.cause
+ # If incompatibility is derived from two derived incompatibilities,
+ # there are too many transitive causes to display concisely.
+ return false if cause.conflict.conflict? && cause.other.conflict?
+
+ # If incompatibility is derived from two external incompatibilities, it
+ # tends to be confusing to collapse it.
+ return false unless cause.conflict.conflict? || cause.other.conflict?
+
+ # If incompatibility's internal cause is numbered, collapsing it would
+ # get too noisy.
+ complex = cause.conflict.conflict? ? cause.conflict : cause.other
+
+ !@line_numbers.has_key?(complex)
+ end
+
+ def count_derivations(incompatibility)
+ if @derivations.has_key?(incompatibility)
+ @derivations[incompatibility] += 1
+ else
+ @derivations[incompatibility] = 1
+ if incompatibility.conflict?
+ cause = incompatibility.cause
+ count_derivations(cause.conflict)
+ count_derivations(cause.other)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/incompatibility.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/incompatibility.rb
new file mode 100644
index 0000000000..b5652b5e01
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/incompatibility.rb
@@ -0,0 +1,150 @@
+module Gem::PubGrub
+ class Incompatibility
+ ConflictCause = Struct.new(:incompatibility, :satisfier) do
+ alias_method :conflict, :incompatibility
+ alias_method :other, :satisfier
+ end
+
+ InvalidDependency = Struct.new(:package, :constraint) do
+ end
+
+ NoVersions = Struct.new(:constraint) do
+ end
+
+ attr_reader :terms, :cause
+
+ def initialize(terms, cause:, custom_explanation: nil)
+ @cause = cause
+ @terms = cleanup_terms(terms)
+ @custom_explanation = custom_explanation
+
+ if cause == :dependency && @terms.length != 2
+ raise ArgumentError, "a dependency Incompatibility must have exactly two terms. Got #{@terms.inspect}"
+ end
+ end
+
+ def hash
+ cause.hash ^ terms.hash
+ end
+
+ def eql?(other)
+ cause.eql?(other.cause) &&
+ terms.eql?(other.terms)
+ end
+
+ def failure?
+ terms.empty? || (terms.length == 1 && Package.root?(terms[0].package) && terms[0].positive?)
+ end
+
+ def conflict?
+ ConflictCause === cause
+ end
+
+ # Returns all external incompatibilities in this incompatibility's
+ # derivation graph
+ def external_incompatibilities
+ if conflict?
+ [
+ cause.conflict,
+ cause.other
+ ].flat_map(&:external_incompatibilities)
+ else
+ [this]
+ end
+ end
+
+ def to_s
+ return @custom_explanation if @custom_explanation
+
+ case cause
+ when :root
+ "(root dependency)"
+ when :dependency
+ "#{terms[0].to_s(allow_every: true)} depends on #{terms[1].invert}"
+ when Gem::PubGrub::Incompatibility::InvalidDependency
+ "#{terms[0].to_s(allow_every: true)} depends on unknown package #{cause.package}"
+ when Gem::PubGrub::Incompatibility::NoVersions
+ "no versions satisfy #{cause.constraint}"
+ when Gem::PubGrub::Incompatibility::ConflictCause
+ if failure?
+ "version solving has failed"
+ elsif terms.length == 1
+ term = terms[0]
+ if term.positive?
+ if term.constraint.any?
+ "#{term.package} cannot be used"
+ else
+ "#{term.to_s(allow_every: true)} cannot be used"
+ end
+ else
+ "#{term.invert} is required"
+ end
+ else
+ if terms.all?(&:positive?)
+ if terms.length == 2
+ "#{terms[0].to_s(allow_every: true)} is incompatible with #{terms[1]}"
+ else
+ "one of #{terms.map(&:to_s).join(" or ")} must be false"
+ end
+ elsif terms.all?(&:negative?)
+ if terms.length == 2
+ "either #{terms[0].invert} or #{terms[1].invert}"
+ else
+ "one of #{terms.map(&:invert).join(" or ")} must be true";
+ end
+ else
+ positive = terms.select(&:positive?)
+ negative = terms.select(&:negative?).map(&:invert)
+
+ if positive.length == 1
+ "#{positive[0].to_s(allow_every: true)} requires #{negative.join(" or ")}"
+ else
+ "if #{positive.join(" and ")} then #{negative.join(" or ")}"
+ end
+ end
+ end
+ else
+ raise "unhandled cause: #{cause.inspect}"
+ end
+ end
+
+ def inspect
+ "#<#{self.class} #{to_s}>"
+ end
+
+ def pretty_print(q)
+ q.group 2, "#<#{self.class}", ">" do
+ q.breakable
+ q.text to_s
+
+ q.breakable
+ q.text " caused by "
+ q.pp @cause
+ end
+ end
+
+ private
+
+ def cleanup_terms(terms)
+ terms.each do |term|
+ raise "#{term.inspect} must be a term" unless term.is_a?(Term)
+ end
+
+ if terms.length != 1 && ConflictCause === cause
+ terms = terms.reject do |term|
+ term.positive? && Package.root?(term.package)
+ end
+ end
+
+ # Optimized simple cases
+ return terms if terms.length <= 1
+ return terms if terms.length == 2 && terms[0].package != terms[1].package
+
+ terms.group_by(&:package).map do |package, common_terms|
+ common_terms.inject do |acc, term|
+ acc.intersect(term)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/package.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/package.rb
new file mode 100644
index 0000000000..6baa908f60
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/package.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module Gem::PubGrub
+ class Package
+
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ end
+
+ def inspect
+ "#<#{self.class} #{name.inspect}>"
+ end
+
+ def <=>(other)
+ name <=> other.name
+ end
+
+ ROOT = Package.new(:root)
+ ROOT_VERSION = 0
+
+ def self.root
+ ROOT
+ end
+
+ def self.root_version
+ ROOT_VERSION
+ end
+
+ def self.root?(package)
+ if package.respond_to?(:root?)
+ package.root?
+ else
+ package == root
+ end
+ end
+
+ def to_s
+ name.to_s
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/partial_solution.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/partial_solution.rb
new file mode 100644
index 0000000000..f6a6ae6964
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/partial_solution.rb
@@ -0,0 +1,121 @@
+require_relative 'assignment'
+
+module Gem::PubGrub
+ class PartialSolution
+ attr_reader :assignments, :decisions
+ attr_reader :attempted_solutions
+
+ def initialize
+ reset!
+
+ @attempted_solutions = 1
+ @backtracking = false
+ end
+
+ def decision_level
+ @decisions.length
+ end
+
+ def relation(term)
+ package = term.package
+ return :overlap if !@terms.key?(package)
+
+ @relation_cache[package][term] ||=
+ @terms[package].relation(term)
+ end
+
+ def satisfies?(term)
+ relation(term) == :subset
+ end
+
+ def derive(term, cause)
+ add_assignment(Assignment.new(term, cause, decision_level, assignments.length))
+ end
+
+ def satisfier(term)
+ assignment =
+ @assignments_by[term.package].bsearch do |assignment_by|
+ @cumulative_assignments[assignment_by].satisfies?(term)
+ end
+
+ assignment || raise("#{term} unsatisfied")
+ end
+
+ # A list of unsatisfied terms
+ def unsatisfied
+ @required.keys.reject do |package|
+ @decisions.key?(package)
+ end.map do |package|
+ @terms[package]
+ end
+ end
+
+ def decide(package, version)
+ @attempted_solutions += 1 if @backtracking
+ @backtracking = false;
+
+ decisions[package] = version
+ assignment = Assignment.decision(package, version, decision_level, assignments.length)
+ add_assignment(assignment)
+ end
+
+ def backtrack(previous_level)
+ @backtracking = true
+
+ new_assignments = assignments.select do |assignment|
+ assignment.decision_level <= previous_level
+ end
+
+ new_decisions = Hash[decisions.first(previous_level)]
+
+ reset!
+
+ @decisions = new_decisions
+
+ new_assignments.each do |assignment|
+ add_assignment(assignment)
+ end
+ end
+
+ private
+
+ def reset!
+ # { Array<Assignment> }
+ @assignments = []
+
+ # { Package => Array<Assignment> }
+ @assignments_by = Hash.new { |h,k| h[k] = [] }
+ @cumulative_assignments = {}.compare_by_identity
+
+ # { Package => Package::Version }
+ @decisions = {}
+
+ # { Package => Term }
+ @terms = {}
+ @relation_cache = Hash.new { |h,k| h[k] = {} }
+
+ # { Package => Boolean }
+ @required = {}
+ end
+
+ def add_assignment(assignment)
+ term = assignment.term
+ package = term.package
+
+ @assignments << assignment
+ @assignments_by[package] << assignment
+
+ @required[package] = true if term.positive?
+
+ if @terms.key?(package)
+ old_term = @terms[package]
+ @terms[package] = old_term.intersect(term)
+ else
+ @terms[package] = term
+ end
+ @relation_cache[package].clear
+
+ @cumulative_assignments[assignment] = @terms[package]
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/rubygems.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/rubygems.rb
new file mode 100644
index 0000000000..60ca3ca2ea
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/rubygems.rb
@@ -0,0 +1,45 @@
+module Gem::PubGrub
+ module RubyGems
+ extend self
+
+ def requirement_to_range(requirement)
+ ranges = requirement.requirements.map do |(op, ver)|
+ case op
+ when "~>"
+ name = "~> #{ver}"
+ bump = ver.class.new(ver.bump.to_s + ".A")
+ VersionRange.new(name: name, min: ver, max: bump, include_min: true)
+ when ">"
+ VersionRange.new(min: ver)
+ when ">="
+ VersionRange.new(min: ver, include_min: true)
+ when "<"
+ VersionRange.new(max: ver)
+ when "<="
+ VersionRange.new(max: ver, include_max: true)
+ when "="
+ VersionRange.new(min: ver, max: ver, include_min: true, include_max: true)
+ when "!="
+ VersionRange.new(min: ver, max: ver, include_min: true, include_max: true).invert
+ else
+ raise "bad version specifier: #{op}"
+ end
+ end
+
+ ranges.inject(&:intersect)
+ end
+
+ def requirement_to_constraint(package, requirement)
+ Gem::PubGrub::VersionConstraint.new(package, range: requirement_to_range(requirement))
+ end
+
+ def parse_range(dep)
+ requirement_to_range(Gem::Requirement.new(dep))
+ end
+
+ def parse_constraint(package, dep)
+ range = parse_range(dep)
+ Gem::PubGrub::VersionConstraint.new(package, range: range)
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/solve_failure.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/solve_failure.rb
new file mode 100644
index 0000000000..c4181d2b25
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/solve_failure.rb
@@ -0,0 +1,19 @@
+require_relative 'failure_writer'
+
+module Gem::PubGrub
+ class SolveFailure < StandardError
+ attr_reader :incompatibility
+
+ def initialize(incompatibility)
+ @incompatibility = incompatibility
+ end
+
+ def to_s
+ "Could not find compatible versions\n\n#{explanation}"
+ end
+
+ def explanation
+ @explanation ||= FailureWriter.new(@incompatibility).write
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/static_package_source.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/static_package_source.rb
new file mode 100644
index 0000000000..9e1de7d7a1
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/static_package_source.rb
@@ -0,0 +1,61 @@
+require_relative 'package'
+require_relative 'rubygems'
+require_relative 'version_constraint'
+require_relative 'incompatibility'
+require_relative 'basic_package_source'
+
+module Gem::PubGrub
+ class StaticPackageSource < BasicPackageSource
+ class DSL
+ def initialize(packages, root_deps)
+ @packages = packages
+ @root_deps = root_deps
+ end
+
+ def root(deps:)
+ @root_deps.update(deps)
+ end
+
+ def add(name, version, deps: {})
+ version = Gem::Version.new(version)
+ @packages[name] ||= {}
+ raise ArgumentError, "#{name} #{version} declared twice" if @packages[name].key?(version)
+ @packages[name][version] = clean_deps(name, version, deps)
+ end
+
+ private
+
+ # Exclude redundant self-referencing dependencies
+ def clean_deps(name, version, deps)
+ deps.reject {|dep_name, req| name == dep_name && Gem::PubGrub::RubyGems.parse_range(req).include?(version) }
+ end
+ end
+
+ def initialize
+ @root_deps = {}
+ @packages = {}
+
+ yield DSL.new(@packages, @root_deps)
+
+ super()
+ end
+
+ def all_versions_for(package)
+ @packages[package].keys
+ end
+
+ def root_dependencies
+ @root_deps
+ end
+
+ def dependencies_for(package, version)
+ @packages[package][version]
+ end
+
+ def parse_dependency(package, dependency)
+ return false unless @packages.key?(package)
+
+ Gem::PubGrub::RubyGems.parse_constraint(package, dependency)
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/strategy.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/strategy.rb
new file mode 100644
index 0000000000..b9874cdece
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/strategy.rb
@@ -0,0 +1,42 @@
+module Gem::PubGrub
+ class Strategy
+ def initialize(source)
+ @source = source
+
+ @root_package = Package.root
+ @root_version = Package.root_version
+
+ @version_indexes = Hash.new do |h,k|
+ if k == @root_package
+ h[k] = { @root_version => 0 }
+ else
+ h[k] = @source.all_versions_for(k).each.with_index.to_h
+ end
+ end
+ end
+
+ def next_package_and_version(unsatisfied)
+ package, range = next_term_to_try_from(unsatisfied)
+
+ [package, most_preferred_version_of(package, range)]
+ end
+
+ private
+
+ def most_preferred_version_of(package, range)
+ versions = @source.versions_for(package, range)
+
+ indexes = @version_indexes[package]
+ versions.min_by { |version| indexes[version] || Float::INFINITY }
+ end
+
+ def next_term_to_try_from(unsatisfied)
+ unsatisfied.min_by do |package, range|
+ matching_versions = @source.versions_for(package, range)
+ higher_versions = @source.versions_for(package, range.upper_invert)
+
+ [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
new file mode 100644
index 0000000000..bb26bdc911
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb
@@ -0,0 +1,105 @@
+module Gem::PubGrub
+ class Term
+ attr_reader :package, :constraint, :positive
+
+ def initialize(constraint, positive)
+ @constraint = constraint
+ @package = @constraint.package
+ @positive = positive
+ end
+
+ def to_s(allow_every: false)
+ if positive
+ @constraint.to_s(allow_every: allow_every)
+ else
+ "not #{@constraint}"
+ end
+ end
+
+ def hash
+ constraint.hash ^ positive.hash
+ end
+
+ def eql?(other)
+ positive == other.positive &&
+ constraint.eql?(other.constraint)
+ end
+
+ def invert
+ self.class.new(@constraint, !@positive)
+ end
+ alias_method :inverse, :invert
+
+ def intersect(other)
+ raise ArgumentError, "packages must match" if package != other.package
+
+ if positive? && other.positive?
+ self.class.new(constraint.intersect(other.constraint), true)
+ elsif negative? && other.negative?
+ self.class.new(constraint.union(other.constraint), false)
+ else
+ positive = positive? ? self : other
+ negative = negative? ? self : other
+ self.class.new(positive.constraint.intersect(negative.constraint.invert), true)
+ end
+ end
+
+ def difference(other)
+ intersect(other.invert)
+ end
+
+ def relation(other)
+ if positive? && other.positive?
+ constraint.relation(other.constraint)
+ elsif negative? && other.positive?
+ if constraint.allows_all?(other.constraint)
+ :disjoint
+ else
+ :overlap
+ end
+ elsif positive? && other.negative?
+ if !other.constraint.allows_any?(constraint)
+ :subset
+ elsif other.constraint.allows_all?(constraint)
+ :disjoint
+ else
+ :overlap
+ end
+ elsif negative? && other.negative?
+ if constraint.allows_all?(other.constraint)
+ :subset
+ else
+ :overlap
+ end
+ else
+ raise
+ end
+ end
+
+ def normalized_constraint
+ @normalized_constraint ||= positive ? constraint : constraint.invert
+ end
+
+ def satisfies?(other)
+ raise ArgumentError, "packages must match" unless package == other.package
+
+ relation(other) == :subset
+ end
+
+ def positive?
+ @positive
+ end
+
+ def negative?
+ !positive?
+ end
+
+ def empty?
+ @empty ||= normalized_constraint.empty?
+ end
+
+ def inspect
+ "#<#{self.class} #{self}>"
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/version.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version.rb
new file mode 100644
index 0000000000..5701bf0656
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version.rb
@@ -0,0 +1,3 @@
+module Gem::PubGrub
+ VERSION = "0.5.0"
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_constraint.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_constraint.rb
new file mode 100644
index 0000000000..ee998b3271
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_constraint.rb
@@ -0,0 +1,129 @@
+require_relative 'version_range'
+
+module Gem::PubGrub
+ class VersionConstraint
+ attr_reader :package, :range
+
+ # @param package [Gem::PubGrub::Package]
+ # @param range [Gem::PubGrub::VersionRange]
+ def initialize(package, range: nil)
+ @package = package
+ @range = range
+ end
+
+ def hash
+ package.hash ^ range.hash
+ end
+
+ def ==(other)
+ package == other.package &&
+ range == other.range
+ end
+
+ def eql?(other)
+ package.eql?(other.package) &&
+ range.eql?(other.range)
+ end
+
+ class << self
+ def exact(package, version)
+ range = VersionRange.new(min: version, max: version, include_min: true, include_max: true)
+ new(package, range: range)
+ end
+
+ def any(package)
+ new(package, range: VersionRange.any)
+ end
+
+ def empty(package)
+ new(package, range: VersionRange.empty)
+ end
+ end
+
+ def intersect(other)
+ unless package == other.package
+ raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
+ end
+
+ self.class.new(package, range: range.intersect(other.range))
+ end
+
+ def union(other)
+ unless package == other.package
+ raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
+ end
+
+ self.class.new(package, range: range.union(other.range))
+ end
+
+ def invert
+ new_range = range.invert
+ self.class.new(package, range: new_range)
+ end
+
+ def difference(other)
+ intersect(other.invert)
+ end
+
+ def allows_all?(other)
+ range.allows_all?(other.range)
+ end
+
+ def allows_any?(other)
+ range.intersects?(other.range)
+ end
+
+ def subset?(other)
+ other.allows_all?(self)
+ end
+
+ def overlap?(other)
+ other.allows_any?(self)
+ end
+
+ def disjoint?(other)
+ !overlap?(other)
+ end
+
+ def relation(other)
+ if subset?(other)
+ :subset
+ elsif overlap?(other)
+ :overlap
+ else
+ :disjoint
+ end
+ end
+
+ def to_s(allow_every: false)
+ if Package.root?(package)
+ package.to_s
+ elsif allow_every && any?
+ "every version of #{package}"
+ else
+ "#{package} #{constraint_string}"
+ end
+ end
+
+ def constraint_string
+ if any?
+ ">= 0"
+ else
+ range.to_s
+ end
+ end
+
+ def empty?
+ range.empty?
+ end
+
+ # Does this match every version of the package
+ def any?
+ range.any?
+ end
+
+ def inspect
+ "#<#{self.class} #{self}>"
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_range.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_range.rb
new file mode 100644
index 0000000000..fa0e2d5742
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_range.rb
@@ -0,0 +1,423 @@
+# frozen_string_literal: true
+
+module Gem::PubGrub
+ class VersionRange
+ attr_reader :min, :max, :include_min, :include_max
+
+ alias_method :include_min?, :include_min
+ alias_method :include_max?, :include_max
+
+ class Empty < VersionRange
+ undef_method :min, :max
+ undef_method :include_min, :include_min?
+ undef_method :include_max, :include_max?
+
+ def initialize
+ end
+
+ def empty?
+ true
+ end
+
+ def eql?(other)
+ other.empty?
+ end
+
+ def hash
+ [].hash
+ end
+
+ def intersects?(_)
+ false
+ end
+
+ def intersect(other)
+ self
+ end
+
+ def allows_all?(other)
+ other.empty?
+ end
+
+ def include?(_)
+ false
+ end
+
+ def any?
+ false
+ end
+
+ def to_s
+ "(no versions)"
+ end
+
+ def ==(other)
+ other.class == self.class
+ end
+
+ def invert
+ VersionRange.any
+ end
+
+ def select_versions(_)
+ []
+ end
+ end
+
+ EMPTY = Empty.new
+ Empty.singleton_class.undef_method(:new)
+
+ def self.empty
+ EMPTY
+ end
+
+ def self.any
+ new
+ end
+
+ def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
+ raise ArgumentError, "Ranges without a lower bound cannot have include_min == true" if !min && include_min == true
+ raise ArgumentError, "Ranges without an upper bound cannot have include_max == true" if !max && include_max == true
+
+ @min = min
+ @max = max
+ @include_min = include_min
+ @include_max = include_max
+ @name = name
+ end
+
+ def hash
+ @hash ||= min.hash ^ max.hash ^ include_min.hash ^ include_max.hash
+ end
+
+ def eql?(other)
+ if other.is_a?(VersionRange)
+ !other.empty? &&
+ min.eql?(other.min) &&
+ max.eql?(other.max) &&
+ include_min.eql?(other.include_min) &&
+ include_max.eql?(other.include_max)
+ else
+ ranges.eql?(other.ranges)
+ end
+ end
+
+ def ranges
+ [self]
+ end
+
+ def include?(version)
+ compare_version(version) == 0
+ end
+
+ # Partitions passed versions into [lower, within, higher]
+ #
+ # versions must be sorted
+ def partition_versions(versions)
+ min_index =
+ if !min || versions.empty?
+ 0
+ elsif include_min?
+ (0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= min }
+ else
+ (0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > min }
+ end
+
+ lower = versions.slice(0, min_index)
+ versions = versions.slice(min_index, versions.size)
+
+ max_index =
+ if !max || versions.empty?
+ versions.size
+ elsif include_max?
+ (0..versions.size).bsearch { |i| versions[i].nil? || versions[i] > max }
+ else
+ (0..versions.size).bsearch { |i| versions[i].nil? || versions[i] >= max }
+ end
+
+ [
+ lower,
+ versions.slice(0, max_index),
+ versions.slice(max_index, versions.size)
+ ]
+ end
+
+ # Returns versions which are included by this range.
+ #
+ # versions must be sorted
+ def select_versions(versions)
+ return versions if any?
+
+ partition_versions(versions)[1]
+ end
+
+ def compare_version(version)
+ if min
+ case version <=> min
+ when -1
+ return -1
+ when 0
+ return -1 if !include_min
+ when 1
+ end
+ end
+
+ if max
+ case version <=> max
+ when -1
+ when 0
+ return 1 if !include_max
+ when 1
+ return 1
+ end
+ end
+
+ 0
+ end
+
+ def strictly_lower?(other)
+ return false if !max || !other.min
+
+ case max <=> other.min
+ when 0
+ !include_max || !other.include_min
+ when -1
+ true
+ when 1
+ false
+ end
+ end
+
+ def strictly_higher?(other)
+ other.strictly_lower?(self)
+ end
+
+ def intersects?(other)
+ return false if other.empty?
+ return other.intersects?(self) if other.is_a?(VersionUnion)
+ !strictly_lower?(other) && !strictly_higher?(other)
+ end
+ alias_method :allows_any?, :intersects?
+
+ def intersect(other)
+ return other if other.empty?
+ return other.intersect(self) if other.is_a?(VersionUnion)
+
+ min_range =
+ if !min
+ other
+ elsif !other.min
+ self
+ else
+ case min <=> other.min
+ when 0
+ include_min ? other : self
+ when -1
+ other
+ when 1
+ self
+ end
+ end
+
+ max_range =
+ if !max
+ other
+ elsif !other.max
+ self
+ else
+ case max <=> other.max
+ when 0
+ include_max ? other : self
+ when -1
+ self
+ when 1
+ other
+ end
+ end
+
+ if !min_range.equal?(max_range) && min_range.min && max_range.max
+ case min_range.min <=> max_range.max
+ when -1
+ when 0
+ if !min_range.include_min || !max_range.include_max
+ return EMPTY
+ end
+ when 1
+ return EMPTY
+ end
+ end
+
+ VersionRange.new(
+ min: min_range.min,
+ include_min: min_range.include_min,
+ max: max_range.max,
+ include_max: max_range.include_max
+ )
+ end
+
+ # The span covered by two ranges
+ #
+ # If self and other are contiguous, this builds a union of the two ranges.
+ # (if they aren't you are probably calling the wrong method)
+ def span(other)
+ return self if other.empty?
+
+ min_range =
+ if !min
+ self
+ elsif !other.min
+ other
+ else
+ case min <=> other.min
+ when 0
+ include_min ? self : other
+ when -1
+ self
+ when 1
+ other
+ end
+ end
+
+ max_range =
+ if !max
+ self
+ elsif !other.max
+ other
+ else
+ case max <=> other.max
+ when 0
+ include_max ? self : other
+ when -1
+ other
+ when 1
+ self
+ end
+ end
+
+ VersionRange.new(
+ min: min_range.min,
+ include_min: min_range.include_min,
+ max: max_range.max,
+ include_max: max_range.include_max
+ )
+ end
+
+ def union(other)
+ return other.union(self) if other.is_a?(VersionUnion)
+
+ if contiguous_to?(other)
+ span(other)
+ else
+ VersionUnion.union([self, other])
+ end
+ end
+
+ def contiguous_to?(other)
+ return false if other.empty?
+ return true if any?
+
+ intersects?(other) || contiguous_below?(other) || contiguous_above?(other)
+ end
+
+ def contiguous_below?(other)
+ return false if !max || !other.min
+
+ max == other.min && (include_max || other.include_min)
+ end
+
+ def contiguous_above?(other)
+ other.contiguous_below?(self)
+ end
+
+ def allows_all?(other)
+ return true if other.empty?
+
+ if other.is_a?(VersionUnion)
+ return VersionUnion.new([self]).allows_all?(other)
+ end
+
+ return false if max && !other.max
+ return false if min && !other.min
+
+ if min
+ case min <=> other.min
+ when -1
+ when 0
+ return false if !include_min && other.include_min
+ when 1
+ return false
+ end
+ end
+
+ if max
+ case max <=> other.max
+ when -1
+ return false
+ when 0
+ return false if !include_max && other.include_max
+ when 1
+ end
+ end
+
+ true
+ end
+
+ def any?
+ !min && !max
+ end
+
+ def empty?
+ false
+ end
+
+ def to_s
+ @name ||= constraints.join(", ")
+ end
+
+ def inspect
+ "#<#{self.class} #{to_s}>"
+ end
+
+ def upper_invert
+ return self.class.empty unless max
+
+ VersionRange.new(min: max, include_min: !include_max)
+ end
+
+ def invert
+ return self.class.empty if any?
+
+ low = -> { VersionRange.new(max: min, include_max: !include_min) }
+ high = -> { VersionRange.new(min: max, include_min: !include_max) }
+
+ if !min
+ high.call
+ elsif !max
+ low.call
+ else
+ low.call.union(high.call)
+ end
+ end
+
+ def ==(other)
+ self.class == other.class &&
+ min == other.min &&
+ max == other.max &&
+ include_min == other.include_min &&
+ include_max == other.include_max
+ end
+
+ private
+
+ def constraints
+ return ["any"] if any?
+ return ["= #{min}"] if min.to_s == max.to_s
+
+ c = []
+ c << "#{include_min ? ">=" : ">"} #{min}" if min
+ c << "#{include_max ? "<=" : "<"} #{max}" if max
+ c
+ end
+
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_solver.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_solver.rb
new file mode 100644
index 0000000000..3341d8fe3b
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_solver.rb
@@ -0,0 +1,236 @@
+require_relative 'partial_solution'
+require_relative 'term'
+require_relative 'incompatibility'
+require_relative 'solve_failure'
+require_relative 'strategy'
+
+module Gem::PubGrub
+ class VersionSolver
+ attr_reader :logger
+ attr_reader :source
+ attr_reader :solution
+ attr_reader :strategy
+
+ def initialize(source:, root: Package.root, strategy: Strategy.new(source), logger: Gem::PubGrub.logger)
+ @logger = logger
+
+ @source = source
+ @strategy = strategy
+
+ # { package => [incompatibility, ...]}
+ @incompatibilities = Hash.new do |h, k|
+ h[k] = []
+ end
+
+ @seen_incompatibilities = {}
+
+ @solution = PartialSolution.new
+
+ add_incompatibility Incompatibility.new([
+ Term.new(VersionConstraint.any(root), false)
+ ], cause: :root)
+
+ propagate(root)
+ end
+
+ def solved?
+ solution.unsatisfied.empty?
+ end
+
+ # Returns true if there is more work to be done, false otherwise
+ def work
+ unsatisfied_terms = solution.unsatisfied
+ if unsatisfied_terms.empty?
+ logger.info { "Solution found after #{solution.attempted_solutions} attempts:" }
+ solution.decisions.each do |package, version|
+ next if Package.root?(package)
+ logger.info { "* #{package} #{version}" }
+ end
+
+ return false
+ end
+
+ next_package = choose_package_version_from(unsatisfied_terms)
+ propagate(next_package)
+
+ true
+ end
+
+ def solve
+ while work; end
+
+ solution.decisions
+ end
+
+ alias_method :result, :solve
+
+ private
+
+ def propagate(initial_package)
+ changed = [initial_package]
+ while package = changed.shift
+ @incompatibilities[package].reverse_each do |incompatibility|
+ result = propagate_incompatibility(incompatibility)
+ if result == :conflict
+ root_cause = resolve_conflict(incompatibility)
+ changed.clear
+ changed << propagate_incompatibility(root_cause)
+ elsif result # should be a Package
+ changed << result
+ end
+ end
+ changed.uniq!
+ end
+ end
+
+ def propagate_incompatibility(incompatibility)
+ unsatisfied = nil
+ incompatibility.terms.each do |term|
+ relation = solution.relation(term)
+ if relation == :disjoint
+ return nil
+ elsif relation == :overlap
+ # If more than one term is inconclusive, we can't deduce anything
+ return nil if unsatisfied
+ unsatisfied = term
+ end
+ end
+
+ if !unsatisfied
+ return :conflict
+ end
+
+ logger.debug { "derived: #{unsatisfied.invert}" }
+
+ solution.derive(unsatisfied.invert, incompatibility)
+
+ unsatisfied.package
+ end
+
+ def choose_package_version_from(unsatisfied_terms)
+ remaining = unsatisfied_terms.map { |t| [t.package, t.constraint.range] }.to_h
+
+ package, version = strategy.next_package_and_version(remaining)
+
+ logger.debug { "attempting #{package} #{version}" }
+
+ if version.nil?
+ unsatisfied_term = unsatisfied_terms.find { |t| t.package == package }
+ add_incompatibility source.no_versions_incompatibility_for(package, unsatisfied_term)
+ return package
+ end
+
+ conflict = false
+
+ source.incompatibilities_for(package, version).each do |incompatibility|
+ if @seen_incompatibilities.include?(incompatibility)
+ logger.debug { "knew: #{incompatibility}" }
+ next
+ end
+ @seen_incompatibilities[incompatibility] = true
+
+ add_incompatibility incompatibility
+
+ conflict ||= incompatibility.terms.all? do |term|
+ term.package == package || solution.satisfies?(term)
+ end
+ end
+
+ unless conflict
+ logger.info { "selected #{package} #{version}" }
+
+ solution.decide(package, version)
+ else
+ logger.info { "conflict: #{conflict.inspect}" }
+ end
+
+ package
+ end
+
+ def resolve_conflict(incompatibility)
+ logger.info { "conflict: #{incompatibility}" }
+
+ new_incompatibility = nil
+
+ while !incompatibility.failure?
+ most_recent_term = nil
+ most_recent_satisfier = nil
+ difference = nil
+
+ previous_level = 1
+
+ incompatibility.terms.each do |term|
+ satisfier = solution.satisfier(term)
+
+ if most_recent_satisfier.nil?
+ most_recent_term = term
+ most_recent_satisfier = satisfier
+ elsif most_recent_satisfier.index < satisfier.index
+ previous_level = [previous_level, most_recent_satisfier.decision_level].max
+ most_recent_term = term
+ most_recent_satisfier = satisfier
+ difference = nil
+ else
+ previous_level = [previous_level, satisfier.decision_level].max
+ end
+
+ if most_recent_term == term
+ difference = most_recent_satisfier.term.difference(most_recent_term)
+ if difference.empty?
+ difference = nil
+ else
+ difference_satisfier = solution.satisfier(difference.inverse)
+ previous_level = [previous_level, difference_satisfier.decision_level].max
+ end
+ end
+ end
+
+ if previous_level < most_recent_satisfier.decision_level ||
+ most_recent_satisfier.decision?
+
+ logger.info { "backtracking to #{previous_level}" }
+ solution.backtrack(previous_level)
+
+ if new_incompatibility
+ add_incompatibility(new_incompatibility)
+ end
+
+ return incompatibility
+ end
+
+ new_terms = []
+ new_terms += incompatibility.terms - [most_recent_term]
+ new_terms += most_recent_satisfier.cause.terms.reject { |term|
+ term.package == most_recent_satisfier.term.package
+ }
+ if difference
+ new_terms << difference.invert
+ end
+
+ new_incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
+
+ if incompatibility.to_s == new_incompatibility.to_s
+ logger.info { "!! failed to resolve conflicts, this shouldn't have happened" }
+ break
+ end
+
+ incompatibility = new_incompatibility
+
+ partially = difference ? " partially" : ""
+ logger.info { "! #{most_recent_term} is#{partially} satisfied by #{most_recent_satisfier.term}" }
+ logger.info { "! which is caused by #{most_recent_satisfier.cause}" }
+ logger.info { "! thus #{incompatibility}" }
+ end
+
+ raise SolveFailure.new(incompatibility)
+ end
+
+ def add_incompatibility(incompatibility)
+ logger.debug { "fact: #{incompatibility}" }
+ incompatibility.terms.each do |term|
+ package = term.package
+ @incompatibilities[package] << incompatibility
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_union.rb b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_union.rb
new file mode 100644
index 0000000000..4166318a98
--- /dev/null
+++ b/lib/rubygems/vendor/pub_grub/lib/pub_grub/version_union.rb
@@ -0,0 +1,178 @@
+# frozen_string_literal: true
+
+module Gem::PubGrub
+ class VersionUnion
+ attr_reader :ranges
+
+ def self.normalize_ranges(ranges)
+ ranges = ranges.flat_map do |range|
+ range.ranges
+ end
+
+ ranges.reject!(&:empty?)
+
+ return [] if ranges.empty?
+
+ mins, ranges = ranges.partition { |r| !r.min }
+ original_ranges = mins + ranges.sort_by { |r| [r.min, r.include_min ? 0 : 1] }
+ ranges = [original_ranges.shift]
+ original_ranges.each do |range|
+ if ranges.last.contiguous_to?(range)
+ ranges << ranges.pop.span(range)
+ else
+ ranges << range
+ end
+ end
+
+ ranges
+ end
+
+ def self.union(ranges, normalize: true)
+ ranges = normalize_ranges(ranges) if normalize
+
+ if ranges.size == 0
+ VersionRange.empty
+ elsif ranges.size == 1
+ ranges[0]
+ else
+ new(ranges)
+ end
+ end
+
+ def initialize(ranges)
+ raise ArgumentError unless ranges.all? { |r| r.instance_of?(VersionRange) }
+ @ranges = ranges
+ end
+
+ def hash
+ ranges.hash
+ end
+
+ def eql?(other)
+ ranges.eql?(other.ranges)
+ end
+
+ def include?(version)
+ !!ranges.bsearch {|r| r.compare_version(version) }
+ end
+
+ def select_versions(all_versions)
+ versions = []
+ ranges.inject(all_versions) do |acc, range|
+ _, matching, higher = range.partition_versions(acc)
+ versions.concat matching
+ higher
+ end
+ versions
+ end
+
+ def intersects?(other)
+ my_ranges = ranges.dup
+ other_ranges = other.ranges.dup
+
+ my_range = my_ranges.shift
+ other_range = other_ranges.shift
+ while my_range && other_range
+ if my_range.intersects?(other_range)
+ return true
+ end
+
+ if !my_range.max || other_range.empty? || (other_range.max && other_range.max < my_range.max)
+ other_range = other_ranges.shift
+ else
+ my_range = my_ranges.shift
+ end
+ end
+ end
+ alias_method :allows_any?, :intersects?
+
+ def allows_all?(other)
+ my_ranges = ranges.dup
+
+ my_range = my_ranges.shift
+
+ other.ranges.all? do |other_range|
+ while my_range
+ break if my_range.allows_all?(other_range)
+ my_range = my_ranges.shift
+ end
+
+ !!my_range
+ end
+ end
+
+ def empty?
+ false
+ end
+
+ def any?
+ false
+ end
+
+ def intersect(other)
+ my_ranges = ranges.dup
+ other_ranges = other.ranges.dup
+ new_ranges = []
+
+ my_range = my_ranges.shift
+ other_range = other_ranges.shift
+ while my_range && other_range
+ new_ranges << my_range.intersect(other_range)
+
+ if !my_range.max || other_range.empty? || (other_range.max && other_range.max < my_range.max)
+ other_range = other_ranges.shift
+ else
+ my_range = my_ranges.shift
+ end
+ end
+ new_ranges.reject!(&:empty?)
+ VersionUnion.union(new_ranges, normalize: false)
+ end
+
+ def upper_invert
+ ranges.last.upper_invert
+ end
+
+ def invert
+ ranges.map(&:invert).inject(:intersect)
+ end
+
+ def union(other)
+ VersionUnion.union([self, other])
+ end
+
+ def to_s
+ output = []
+
+ ranges = self.ranges.dup
+ while !ranges.empty?
+ ne = []
+ range = ranges.shift
+ while !ranges.empty? && ranges[0].min.to_s == range.max.to_s
+ ne << range.max
+ range = range.span(ranges.shift)
+ end
+
+ ne.map! {|x| "!= #{x}" }
+ if ne.empty?
+ output << range.to_s
+ elsif range.any?
+ output << ne.join(', ')
+ else
+ output << "#{range}, #{ne.join(', ')}"
+ end
+ end
+
+ output.join(" OR ")
+ end
+
+ def inspect
+ "#<#{self.class} #{to_s}>"
+ end
+
+ def ==(other)
+ self.class == other.class &&
+ self.ranges == other.ranges
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/resolv/lib/resolv.rb b/lib/rubygems/vendor/resolv/lib/resolv.rb
new file mode 100644
index 0000000000..4f48e0642b
--- /dev/null
+++ b/lib/rubygems/vendor/resolv/lib/resolv.rb
@@ -0,0 +1,3499 @@
+# frozen_string_literal: true
+
+require 'socket'
+require_relative '../../../vendored_timeout'
+require 'io/wait'
+require_relative '../../../vendored_securerandom'
+require 'rbconfig'
+
+# Gem::Resolv is a thread-aware DNS resolver library written in Ruby. Gem::Resolv can
+# handle multiple DNS requests concurrently without blocking the entire Ruby
+# interpreter.
+#
+# See also resolv-replace.rb to replace the libc resolver with Gem::Resolv.
+#
+# Gem::Resolv can look up various DNS resources using the DNS module directly.
+#
+# Examples:
+#
+# p Gem::Resolv.getaddress "www.ruby-lang.org"
+# p Gem::Resolv.getname "210.251.121.214"
+#
+# Gem::Resolv::DNS.open do |dns|
+# ress = dns.getresources "www.ruby-lang.org", Gem::Resolv::DNS::Resource::IN::A
+# p ress.map(&:address)
+# ress = dns.getresources "ruby-lang.org", Gem::Resolv::DNS::Resource::IN::MX
+# p ress.map { |r| [r.exchange.to_s, r.preference] }
+# end
+#
+#
+# == Bugs
+#
+# * NIS is not supported.
+# * /etc/nsswitch.conf is not supported.
+
+class Gem::Resolv
+
+ # The version string
+ VERSION = "0.7.0"
+
+ ##
+ # Looks up the first IP address for +name+.
+
+ def self.getaddress(name)
+ DefaultResolver.getaddress(name)
+ end
+
+ ##
+ # Looks up all IP address for +name+.
+
+ def self.getaddresses(name)
+ DefaultResolver.getaddresses(name)
+ end
+
+ ##
+ # Iterates over all IP addresses for +name+.
+
+ def self.each_address(name, &block)
+ DefaultResolver.each_address(name, &block)
+ end
+
+ ##
+ # Looks up the hostname of +address+.
+
+ def self.getname(address)
+ DefaultResolver.getname(address)
+ end
+
+ ##
+ # Looks up all hostnames for +address+.
+
+ def self.getnames(address)
+ DefaultResolver.getnames(address)
+ end
+
+ ##
+ # Iterates over all hostnames for +address+.
+
+ def self.each_name(address, &proc)
+ DefaultResolver.each_name(address, &proc)
+ end
+
+ ##
+ # Creates a new Gem::Resolv using +resolvers+.
+ #
+ # If +resolvers+ is not given, a hash, or +nil+, uses a Hosts resolver and
+ # and a DNS resolver. If +resolvers+ is a hash, uses the hash as
+ # configuration for the DNS resolver.
+
+ def initialize(resolvers=(arg_not_set = true; nil), use_ipv6: (keyword_not_set = true; nil))
+ if !keyword_not_set && !arg_not_set
+ warn "Support for separate use_ipv6 keyword is deprecated, as it is ignored if an argument is provided. Do not provide a positional argument if using the use_ipv6 keyword argument.", uplevel: 1
+ end
+
+ @resolvers = case resolvers
+ when Hash, nil
+ [Hosts.new, DNS.new(DNS::Config.default_config_hash.merge(resolvers || {}))]
+ else
+ resolvers
+ end
+ end
+
+ ##
+ # Looks up the first IP address for +name+.
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("no address for #{name}")
+ end
+
+ ##
+ # Looks up all IP address for +name+.
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ ##
+ # Iterates over all IP addresses for +name+.
+
+ def each_address(name)
+ if AddressRegex =~ name
+ yield name
+ return
+ end
+ yielded = false
+ @resolvers.each {|r|
+ r.each_address(name) {|address|
+ yield address.to_s
+ yielded = true
+ }
+ return if yielded
+ }
+ end
+
+ ##
+ # Looks up the hostname of +address+.
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("no name for #{address}")
+ end
+
+ ##
+ # Looks up all hostnames for +address+.
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ ##
+ # Iterates over all hostnames for +address+.
+
+ def each_name(address)
+ yielded = false
+ @resolvers.each {|r|
+ r.each_name(address) {|name|
+ yield name.to_s
+ yielded = true
+ }
+ return if yielded
+ }
+ end
+
+ ##
+ # Indicates a failure to resolve a name or address.
+
+ class ResolvError < StandardError; end
+
+ ##
+ # Indicates a timeout resolving a name or address.
+
+ class ResolvTimeout < Gem::Timeout::Error; end
+
+ ##
+ # Gem::Resolv::Hosts is a hostname resolver that uses the system hosts file.
+
+ class Hosts
+ if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/
+ begin
+ require 'win32/resolv' unless defined?(Win32::Resolv)
+ hosts = Win32::Resolv.get_hosts_path || IO::NULL
+ rescue LoadError
+ end
+ end
+ # The default file name for host names
+ DefaultFileName = hosts || '/etc/hosts'
+
+ ##
+ # Creates a new Gem::Resolv::Hosts, using +filename+ for its data source.
+
+ def initialize(filename = DefaultFileName)
+ @filename = filename
+ @mutex = Thread::Mutex.new
+ @initialized = nil
+ end
+
+ def lazy_initialize # :nodoc:
+ @mutex.synchronize {
+ unless @initialized
+ @name2addr = {}
+ @addr2name = {}
+ File.open(@filename, 'rb') {|f|
+ f.each {|line|
+ line.sub!(/#.*/, '')
+ addr, *hostnames = line.split(/\s+/)
+ next unless addr
+ (@addr2name[addr] ||= []).concat(hostnames)
+ hostnames.each {|hostname| (@name2addr[hostname] ||= []) << addr}
+ }
+ }
+ @name2addr.each {|name, arr| arr.reverse!}
+ @initialized = true
+ end
+ }
+ self
+ end
+
+ ##
+ # Gets the IP address of +name+ from the hosts file.
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("#{@filename} has no name: #{name}")
+ end
+
+ ##
+ # Gets all IP addresses for +name+ from the hosts file.
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ ##
+ # Iterates over all IP addresses for +name+ retrieved from the hosts file.
+
+ def each_address(name, &proc)
+ lazy_initialize
+ @name2addr[name]&.each(&proc)
+ end
+
+ ##
+ # Gets the hostname of +address+ from the hosts file.
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("#{@filename} has no address: #{address}")
+ end
+
+ ##
+ # Gets all hostnames for +address+ from the hosts file.
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ ##
+ # Iterates over all hostnames for +address+ retrieved from the hosts file.
+
+ def each_name(address, &proc)
+ lazy_initialize
+ @addr2name[address]&.each(&proc)
+ end
+ end
+
+ ##
+ # Gem::Resolv::DNS is a DNS stub resolver.
+ #
+ # Information taken from the following places:
+ #
+ # * STD0013
+ # * RFC 1035
+ # * ftp://ftp.isi.edu/in-notes/iana/assignments/dns-parameters
+ # * etc.
+
+ class DNS
+
+ ##
+ # Default DNS Port
+
+ Port = 53
+
+ ##
+ # Default DNS UDP packet size
+
+ UDPSize = 512
+
+ ##
+ # Creates a new DNS resolver. See Gem::Resolv::DNS.new for argument details.
+ #
+ # Yields the created DNS resolver to the block, if given, otherwise
+ # returns it.
+
+ def self.open(*args)
+ dns = new(*args)
+ return dns unless block_given?
+ begin
+ yield dns
+ ensure
+ dns.close
+ end
+ end
+
+ ##
+ # Creates a new DNS resolver.
+ #
+ # +config_info+ can be:
+ #
+ # nil:: Uses /etc/resolv.conf.
+ # String:: Path to a file using /etc/resolv.conf's format.
+ # Hash:: Must contain :nameserver, :search and :ndots keys.
+ # :nameserver_port can be used to specify port number of nameserver address.
+ # :raise_timeout_errors can be used to raise timeout errors
+ # as exceptions instead of treating the same as an NXDOMAIN response.
+ #
+ # The value of :nameserver should be an address string or
+ # an array of address strings.
+ # - :nameserver => '8.8.8.8'
+ # - :nameserver => ['8.8.8.8', '8.8.4.4']
+ #
+ # The value of :nameserver_port should be an array of
+ # pair of nameserver address and port number.
+ # - :nameserver_port => [['8.8.8.8', 53], ['8.8.4.4', 53]]
+ #
+ # Example:
+ #
+ # Gem::Resolv::DNS.new(:nameserver => ['210.251.121.21'],
+ # :search => ['ruby-lang.org'],
+ # :ndots => 1)
+
+ def initialize(config_info=nil)
+ @mutex = Thread::Mutex.new
+ @config = Config.new(config_info)
+ @initialized = nil
+ end
+
+ # Sets the resolver timeouts. This may be a single positive number
+ # or an array of positive numbers representing timeouts in seconds.
+ # If an array is specified, a DNS request will retry and wait for
+ # each successive interval in the array until a successful response
+ # is received. Specifying +nil+ reverts to the default timeouts:
+ # [ 5, second = 5 * 2 / nameserver_count, 2 * second, 4 * second ]
+ #
+ # Example:
+ #
+ # dns.timeouts = 3
+ #
+ def timeouts=(values)
+ @config.timeouts = values
+ end
+
+ def lazy_initialize # :nodoc:
+ @mutex.synchronize {
+ unless @initialized
+ @config.lazy_initialize
+ @initialized = true
+ end
+ }
+ self
+ end
+
+ ##
+ # Closes the DNS resolver.
+
+ def close
+ @mutex.synchronize {
+ if @initialized
+ @initialized = false
+ end
+ }
+ end
+
+ ##
+ # Gets the IP address of +name+ from the DNS resolver.
+ #
+ # +name+ can be a Gem::Resolv::DNS::Name or a String. Retrieved address will
+ # be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("DNS result has no information for #{name}")
+ end
+
+ ##
+ # Gets all IP addresses for +name+ from the DNS resolver.
+ #
+ # +name+ can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will
+ # be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ ##
+ # Iterates over all IP addresses for +name+ retrieved from the DNS
+ # resolver.
+ #
+ # +name+ can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will
+ # be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6
+
+ def each_address(name)
+ if use_ipv6?
+ each_resource(name, Resource::IN::AAAA) {|resource| yield resource.address}
+ end
+ each_resource(name, Resource::IN::A) {|resource| yield resource.address}
+ end
+
+ def use_ipv6? # :nodoc:
+ @config.lazy_initialize unless @config.instance_variable_get(:@initialized)
+
+ use_ipv6 = @config.use_ipv6?
+ unless use_ipv6.nil?
+ return use_ipv6
+ end
+
+ begin
+ list = Socket.ip_address_list
+ rescue NotImplementedError
+ return true
+ end
+ list.any? {|a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? }
+ end
+ private :use_ipv6?
+
+ ##
+ # Gets the hostname for +address+ from the DNS resolver.
+ #
+ # +address+ must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. Retrieved
+ # name will be a Gem::Resolv::DNS::Name.
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("DNS result has no information for #{address}")
+ end
+
+ ##
+ # Gets all hostnames for +address+ from the DNS resolver.
+ #
+ # +address+ must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. Retrieved
+ # names will be Gem::Resolv::DNS::Name instances.
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ ##
+ # Iterates over all hostnames for +address+ retrieved from the DNS
+ # resolver.
+ #
+ # +address+ must be a Gem::Resolv::IPv4, Gem::Resolv::IPv6 or a String. Retrieved
+ # names will be Gem::Resolv::DNS::Name instances.
+
+ def each_name(address)
+ case address
+ when Name
+ ptr = address
+ when IPv4, IPv6
+ ptr = address.to_name
+ when IPv4::Regex
+ ptr = IPv4.create(address).to_name
+ when IPv6::Regex
+ ptr = IPv6.create(address).to_name
+ else
+ raise ResolvError.new("cannot interpret as address: #{address}")
+ end
+ each_resource(ptr, Resource::IN::PTR) {|resource| yield resource.name}
+ end
+
+ ##
+ # Look up the +typeclass+ DNS resource of +name+.
+ #
+ # +name+ must be a Gem::Resolv::DNS::Name or a String.
+ #
+ # +typeclass+ should be one of the following:
+ #
+ # * Gem::Resolv::DNS::Resource::IN::A
+ # * Gem::Resolv::DNS::Resource::IN::AAAA
+ # * Gem::Resolv::DNS::Resource::IN::ANY
+ # * Gem::Resolv::DNS::Resource::IN::CNAME
+ # * Gem::Resolv::DNS::Resource::IN::HINFO
+ # * Gem::Resolv::DNS::Resource::IN::MINFO
+ # * Gem::Resolv::DNS::Resource::IN::MX
+ # * Gem::Resolv::DNS::Resource::IN::NS
+ # * Gem::Resolv::DNS::Resource::IN::PTR
+ # * Gem::Resolv::DNS::Resource::IN::SOA
+ # * Gem::Resolv::DNS::Resource::IN::TXT
+ # * Gem::Resolv::DNS::Resource::IN::WKS
+ #
+ # Returned resource is represented as a Gem::Resolv::DNS::Resource instance,
+ # i.e. Gem::Resolv::DNS::Resource::IN::A.
+
+ def getresource(name, typeclass)
+ each_resource(name, typeclass) {|resource| return resource}
+ raise ResolvError.new("DNS result has no information for #{name}")
+ end
+
+ ##
+ # Looks up all +typeclass+ DNS resources for +name+. See #getresource for
+ # argument details.
+
+ def getresources(name, typeclass)
+ ret = []
+ each_resource(name, typeclass) {|resource| ret << resource}
+ return ret
+ end
+
+ ##
+ # Iterates over all +typeclass+ DNS resources for +name+. See
+ # #getresource for argument details.
+
+ def each_resource(name, typeclass, &proc)
+ fetch_resource(name, typeclass) {|reply, reply_name|
+ extract_resources(reply, reply_name, typeclass, &proc)
+ }
+ end
+
+ # :stopdoc:
+
+ def fetch_resource(name, typeclass)
+ lazy_initialize
+ truncated = {}
+ requesters = {}
+ udp_requester = begin
+ make_udp_requester
+ rescue Errno::EACCES
+ # fall back to TCP
+ end
+ senders = {}
+
+ begin
+ @config.resolv(name) do |candidate, tout, nameserver, port|
+ msg = Message.new
+ msg.rd = 1
+ msg.add_question(candidate, typeclass)
+
+ requester = requesters.fetch([nameserver, port]) do
+ if !truncated[candidate] && udp_requester
+ udp_requester
+ else
+ requesters[[nameserver, port]] = make_tcp_requester(nameserver, port)
+ end
+ end
+
+ unless sender = senders[[candidate, requester, nameserver, port]]
+ sender = requester.sender(msg, candidate, nameserver, port)
+ next if !sender
+ senders[[candidate, requester, nameserver, port]] = sender
+ end
+ reply, reply_name = requester.request(sender, tout)
+ case reply.rcode
+ when RCode::NoError
+ if reply.tc == 1 and not Requester::TCP === requester
+ # Retry via TCP:
+ truncated[candidate] = true
+ redo
+ else
+ yield(reply, reply_name)
+ end
+ return
+ when RCode::NXDomain
+ raise Config::NXDomain.new(reply_name.to_s)
+ else
+ raise Config::OtherResolvError.new(reply_name.to_s)
+ end
+ end
+ ensure
+ udp_requester&.close
+ requesters.each_value { |requester| requester&.close }
+ end
+ end
+
+ def make_udp_requester # :nodoc:
+ nameserver_port = @config.nameserver_port
+ if nameserver_port.length == 1
+ Requester::ConnectedUDP.new(*nameserver_port[0])
+ else
+ Requester::UnconnectedUDP.new(*nameserver_port)
+ end
+ end
+
+ def make_tcp_requester(host, port) # :nodoc:
+ return Requester::TCP.new(host, port)
+ rescue Errno::ECONNREFUSED
+ # Treat a refused TCP connection attempt to a nameserver like a timeout,
+ # as Gem::Resolv::DNS::Config#resolv considers ResolvTimeout exceptions as a
+ # hint to try the next nameserver:
+ raise ResolvTimeout
+ end
+
+ def extract_resources(msg, name, typeclass) # :nodoc:
+ if typeclass < Resource::ANY
+ n0 = Name.create(name)
+ msg.each_resource {|n, ttl, data|
+ yield data if n0 == n
+ }
+ end
+ yielded = false
+ n0 = Name.create(name)
+ msg.each_resource {|n, ttl, data|
+ if n0 == n
+ case data
+ when typeclass
+ yield data
+ yielded = true
+ when Resource::CNAME
+ n0 = data.name
+ end
+ end
+ }
+ return if yielded
+ msg.each_resource {|n, ttl, data|
+ if n0 == n
+ case data
+ when typeclass
+ yield data
+ end
+ end
+ }
+ end
+
+ def self.random(arg) # :nodoc:
+ begin
+ Gem::SecureRandom.random_number(arg)
+ rescue NotImplementedError
+ rand(arg)
+ end
+ end
+
+ RequestID = {} # :nodoc:
+ RequestIDMutex = Thread::Mutex.new # :nodoc:
+
+ def self.allocate_request_id(host, port) # :nodoc:
+ id = nil
+ RequestIDMutex.synchronize {
+ h = (RequestID[[host, port]] ||= {})
+ begin
+ id = random(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
+
+ case RUBY_PLATFORM
+ when *[
+ # https://www.rfc-editor.org/rfc/rfc6056.txt
+ # Appendix A. Survey of the Algorithms in Use by Some Popular Implementations
+ /freebsd/, /linux/, /netbsd/, /openbsd/, /solaris/,
+ /darwin/, # the same as FreeBSD
+ ] then
+ def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
+ udpsock.bind(bind_host, 0)
+ end
+ else
+ # Sequential port assignment
+ def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
+ # Ephemeral port number range recommended by RFC 6056
+ port = random(1024..65535)
+ udpsock.bind(bind_host, port)
+ rescue Errno::EADDRINUSE, # POSIX
+ Errno::EACCES, # SunOS: See PRIV_SYS_NFS in privileges(5)
+ Errno::EPERM # FreeBSD: security.mac.portacl.port_high is configurable. See mac_portacl(4).
+ retry
+ end
+ end
+
+ class Requester # :nodoc:
+ def initialize
+ @senders = {}
+ @socks = nil
+ end
+
+ def request(sender, tout)
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ timelimit = start + tout
+ begin
+ sender.send
+ rescue Errno::EHOSTUNREACH, # multi-homed IPv6 may generate this
+ Errno::ENETUNREACH
+ raise ResolvTimeout
+ end
+ while true
+ before_select = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ timeout = timelimit - before_select
+ if timeout <= 0
+ raise ResolvTimeout
+ end
+ if @socks.size == 1
+ select_result = @socks[0].wait_readable(timeout) ? [ @socks ] : nil
+ else
+ select_result = IO.select(@socks, nil, nil, timeout)
+ end
+ if !select_result
+ after_select = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ next if after_select < timelimit
+ raise ResolvTimeout
+ end
+ begin
+ reply, from = recv_reply(select_result[0])
+ rescue Errno::ECONNREFUSED, # GNU/Linux, FreeBSD
+ Errno::ECONNRESET # Windows
+ # No name server running on the server?
+ # Don't wait anymore.
+ raise ResolvTimeout
+ end
+ begin
+ msg = Message.decode(reply)
+ rescue DecodeError
+ next # broken DNS message ignored
+ end
+ if sender == sender_for(from, msg)
+ break
+ else
+ # unexpected DNS message ignored
+ end
+ end
+ return msg, sender.data
+ end
+
+ def sender_for(addr, msg)
+ @senders[[addr,msg.id]]
+ end
+
+ def close
+ socks = @socks
+ @socks = nil
+ socks&.each(&:close)
+ end
+
+ class Sender # :nodoc:
+ def initialize(msg, data, sock)
+ @msg = msg
+ @data = data
+ @sock = sock
+ end
+ end
+
+ class UnconnectedUDP < Requester # :nodoc:
+ def initialize(*nameserver_port)
+ super()
+ @nameserver_port = nameserver_port
+ @initialized = false
+ @mutex = Thread::Mutex.new
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ next if @initialized
+ @initialized = true
+ @socks_hash = {}
+ @socks = []
+ @nameserver_port.each {|host, port|
+ if host.index(':')
+ bind_host = "::"
+ af = Socket::AF_INET6
+ else
+ bind_host = "0.0.0.0"
+ af = Socket::AF_INET
+ end
+ next if @socks_hash[bind_host]
+ begin
+ sock = UDPSocket.new(af)
+ rescue Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT
+ next # The kernel doesn't support the address family.
+ end
+ @socks << sock
+ @socks_hash[bind_host] = sock
+ sock.do_not_reverse_lookup = true
+ DNS.bind_random_port(sock, bind_host)
+ }
+ }
+ self
+ end
+
+ def recv_reply(readable_socks)
+ lazy_initialize
+ reply, from = readable_socks[0].recvfrom(UDPSize)
+ return reply, [from[3],from[1]]
+ end
+
+ def sender(msg, data, host, port=Port)
+ host = Addrinfo.ip(host).ip_address
+ lazy_initialize
+ sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"]
+ return nil if !sock
+ service = [host, port]
+ 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)
+ end
+
+ def close
+ @mutex.synchronize {
+ if @initialized
+ super
+ @senders.each_key {|service, id|
+ DNS.free_request_id(service[0], service[1], id)
+ }
+ @initialized = false
+ end
+ }
+ end
+
+ class Sender < Requester::Sender # :nodoc:
+ def initialize(msg, data, sock, host, port)
+ super(msg, data, sock)
+ @host = host
+ @port = port
+ end
+ attr_reader :data
+
+ def send
+ raise "@sock is nil." if @sock.nil?
+ @sock.send(@msg, 0, @host, @port)
+ end
+ end
+ end
+
+ class ConnectedUDP < Requester # :nodoc:
+ def initialize(host, port=Port)
+ super()
+ @host = host
+ @port = port
+ @mutex = Thread::Mutex.new
+ @initialized = false
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ next if @initialized
+ @initialized = true
+ is_ipv6 = @host.index(':')
+ sock = UDPSocket.new(is_ipv6 ? Socket::AF_INET6 : Socket::AF_INET)
+ @socks = [sock]
+ sock.do_not_reverse_lookup = true
+ DNS.bind_random_port(sock, is_ipv6 ? "::" : "0.0.0.0")
+ sock.connect(@host, @port)
+ }
+ self
+ end
+
+ def recv_reply(readable_socks)
+ lazy_initialize
+ reply = readable_socks[0].recv(UDPSize)
+ return reply, nil
+ end
+
+ def sender(msg, data, host=@host, port=@port)
+ lazy_initialize
+ unless host == @host && port == @port
+ raise RequestError.new("host/port don't match: #{host}:#{port}")
+ end
+ id = DNS.allocate_request_id(@host, @port)
+ request = msg.encode
+ request[0,2] = [id].pack('n')
+ return @senders[[nil,id]] = Sender.new(request, data, @socks[0])
+ end
+
+ def close
+ @mutex.synchronize do
+ if @initialized
+ super
+ @senders.each_key {|from, id|
+ DNS.free_request_id(@host, @port, id)
+ }
+ @initialized = false
+ end
+ end
+ end
+
+ class Sender < Requester::Sender # :nodoc:
+ def send
+ raise "@sock is nil." if @sock.nil?
+ @sock.send(@msg, 0)
+ end
+ attr_reader :data
+ end
+ end
+
+ class MDNSOneShot < UnconnectedUDP # :nodoc:
+ def sender(msg, data, host, port=Port)
+ lazy_initialize
+ id = DNS.allocate_request_id(host, port)
+ request = msg.encode
+ request[0,2] = [id].pack('n')
+ sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"]
+ return @senders[id] =
+ UnconnectedUDP::Sender.new(request, data, sock, host, port)
+ end
+
+ def sender_for(addr, msg)
+ lazy_initialize
+ @senders[msg.id]
+ end
+ end
+
+ class TCP < Requester # :nodoc:
+ def initialize(host, port=Port)
+ super()
+ @host = host
+ @port = port
+ sock = TCPSocket.new(@host, @port)
+ @socks = [sock]
+ @senders = {}
+ end
+
+ def recv_reply(readable_socks)
+ len = readable_socks[0].read(2).unpack('n')[0]
+ reply = @socks[0].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 = DNS.allocate_request_id(@host, @port)
+ request = msg.encode
+ request[0,2] = [request.length, id].pack('nn')
+ return @senders[[nil,id]] = Sender.new(request, data, @socks[0])
+ end
+
+ class Sender < Requester::Sender # :nodoc:
+ def send
+ @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
+
+ ##
+ # Indicates a problem with the DNS request.
+
+ class RequestError < StandardError
+ end
+ end
+
+ class Config # :nodoc:
+ def initialize(config_info=nil)
+ @mutex = Thread::Mutex.new
+ @config_info = config_info
+ @initialized = nil
+ @timeouts = nil
+ end
+
+ def timeouts=(values)
+ if values
+ values = Array(values)
+ values.each do |t|
+ Numeric === t or raise ArgumentError, "#{t.inspect} is not numeric"
+ t > 0.0 or raise ArgumentError, "timeout=#{t} must be positive"
+ end
+ @timeouts = values
+ else
+ @timeouts = nil
+ end
+ end
+
+ def Config.parse_resolv_conf(filename)
+ nameserver = []
+ search = nil
+ ndots = 1
+ File.open(filename, 'rb') {|f|
+ f.each {|line|
+ line.sub!(/[#;].*/, '')
+ keyword, *args = line.split(/\s+/)
+ next unless keyword
+ case keyword
+ when 'nameserver'
+ nameserver.concat(args.each(&:freeze))
+ when 'domain'
+ next if args.empty?
+ search = [args[0].freeze]
+ when 'search'
+ next if args.empty?
+ search = args.each(&:freeze)
+ when 'options'
+ args.each {|arg|
+ case arg
+ when /\Andots:(\d+)\z/
+ ndots = $1.to_i
+ end
+ }
+ end
+ }
+ }
+ return { :nameserver => nameserver.freeze, :search => search.freeze, :ndots => ndots.freeze }.freeze
+ end
+
+ def Config.default_config_hash(filename="/etc/resolv.conf")
+ if File.exist? filename
+ Config.parse_resolv_conf(filename)
+ elsif defined?(Win32::Resolv)
+ search, nameserver = Win32::Resolv.get_resolv_info
+ config_hash = {}
+ config_hash[:nameserver] = nameserver if nameserver
+ config_hash[:search] = [search].flatten if search
+ config_hash
+ else
+ {}
+ end
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ unless @initialized
+ @nameserver_port = []
+ @use_ipv6 = nil
+ @search = nil
+ @ndots = 1
+ case @config_info
+ when nil
+ config_hash = Config.default_config_hash
+ when String
+ config_hash = Config.parse_resolv_conf(@config_info)
+ when Hash
+ config_hash = @config_info.dup
+ if String === config_hash[:nameserver]
+ config_hash[:nameserver] = [config_hash[:nameserver]]
+ end
+ if String === config_hash[:search]
+ config_hash[:search] = [config_hash[:search]]
+ end
+ else
+ raise ArgumentError.new("invalid resolv configuration: #{@config_info.inspect}")
+ end
+ if config_hash.include? :nameserver
+ @nameserver_port = config_hash[:nameserver].map {|ns| [ns, Port] }
+ end
+ if config_hash.include? :nameserver_port
+ @nameserver_port = config_hash[:nameserver_port].map {|ns, port| [ns, (port || Port)] }
+ end
+ if config_hash.include? :use_ipv6
+ @use_ipv6 = config_hash[:use_ipv6]
+ end
+ @search = config_hash[:search] if config_hash.include? :search
+ @ndots = config_hash[:ndots] if config_hash.include? :ndots
+ @raise_timeout_errors = config_hash[:raise_timeout_errors]
+
+ if @nameserver_port.empty?
+ @nameserver_port << ['0.0.0.0', Port]
+ end
+ if @search
+ @search = @search.map {|arg| Label.split(arg) }
+ else
+ hostname = Socket.gethostname
+ if /\./ =~ hostname
+ @search = [Label.split($')]
+ else
+ @search = [[]]
+ end
+ end
+
+ if !@nameserver_port.kind_of?(Array) ||
+ @nameserver_port.any? {|ns_port|
+ !(Array === ns_port) ||
+ ns_port.length != 2
+ !(String === ns_port[0]) ||
+ !(Integer === ns_port[1])
+ }
+ raise ArgumentError.new("invalid nameserver config: #{@nameserver_port.inspect}")
+ end
+
+ if !@search.kind_of?(Array) ||
+ !@search.all? {|ls| ls.all? {|l| Label::Str === l } }
+ raise ArgumentError.new("invalid search config: #{@search.inspect}")
+ end
+
+ if !@ndots.kind_of?(Integer)
+ raise ArgumentError.new("invalid ndots config: #{@ndots.inspect}")
+ end
+
+ @initialized = true
+ end
+ }
+ self
+ end
+
+ def single?
+ lazy_initialize
+ if @nameserver_port.length == 1
+ return @nameserver_port[0]
+ else
+ return nil
+ end
+ end
+
+ def nameserver_port
+ @nameserver_port
+ end
+
+ def use_ipv6?
+ @use_ipv6
+ end
+
+ def generate_candidates(name)
+ candidates = nil
+ name = Name.create(name)
+ if name.absolute?
+ candidates = [name]
+ else
+ if @ndots <= name.length - 1
+ candidates = [Name.new(name.to_a)]
+ else
+ candidates = []
+ end
+ candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)})
+ fname = Name.create("#{name}.")
+ if !candidates.include?(fname)
+ candidates << fname
+ end
+ end
+ return candidates
+ end
+
+ InitialTimeout = 5
+
+ def generate_timeouts
+ ts = [InitialTimeout]
+ ts << ts[-1] * 2 / @nameserver_port.length
+ ts << ts[-1] * 2
+ ts << ts[-1] * 2
+ return ts
+ end
+
+ def resolv(name)
+ candidates = generate_candidates(name)
+ timeouts = @timeouts || generate_timeouts
+ timeout_error = false
+ begin
+ candidates.each {|candidate|
+ begin
+ timeouts.each {|tout|
+ @nameserver_port.each {|nameserver, port|
+ begin
+ yield candidate, tout, nameserver, port
+ rescue ResolvTimeout
+ end
+ }
+ }
+ timeout_error = true
+ raise ResolvError.new("DNS resolv timeout: #{name}")
+ rescue NXDomain
+ end
+ }
+ rescue ResolvError
+ raise if @raise_timeout_errors && timeout_error
+ end
+ end
+
+ ##
+ # Indicates no such domain was found.
+
+ class NXDomain < ResolvError
+ end
+
+ ##
+ # Indicates some other unhandled resolver error was encountered.
+
+ class OtherResolvError < ResolvError
+ end
+ end
+
+ module OpCode # :nodoc:
+ Query = 0
+ IQuery = 1
+ Status = 2
+ Notify = 4
+ Update = 5
+ end
+
+ module RCode # :nodoc:
+ NoError = 0
+ FormErr = 1
+ ServFail = 2
+ NXDomain = 3
+ NotImp = 4
+ Refused = 5
+ YXDomain = 6
+ YXRRSet = 7
+ NXRRSet = 8
+ NotAuth = 9
+ NotZone = 10
+ BADVERS = 16
+ BADSIG = 16
+ BADKEY = 17
+ BADTIME = 18
+ BADMODE = 19
+ BADNAME = 20
+ BADALG = 21
+ end
+
+ ##
+ # Indicates that the DNS response was unable to be decoded.
+
+ class DecodeError < StandardError
+ end
+
+ ##
+ # Indicates that the DNS request was unable to be encoded.
+
+ class EncodeError < StandardError
+ end
+
+ module Label # :nodoc:
+ def self.split(arg)
+ labels = []
+ arg.scan(/[^\.]+/) {labels << Str.new($&)}
+ return labels
+ end
+
+ class Str # :nodoc:
+ def initialize(string)
+ @string = string
+ # case insensivity of DNS labels doesn't apply non-ASCII characters. [RFC 4343]
+ # This assumes @string is given in ASCII compatible encoding.
+ @downcase = string.b.downcase
+ end
+ attr_reader :string, :downcase
+
+ def to_s
+ return @string
+ end
+
+ def inspect
+ return "#<#{self.class} #{self}>"
+ end
+
+ def ==(other)
+ return self.class == other.class && @downcase == other.downcase
+ end
+
+ def eql?(other)
+ return self == other
+ end
+
+ def hash
+ return @downcase.hash
+ end
+ end
+ end
+
+ ##
+ # A representation of a DNS name.
+
+ class Name
+
+ ##
+ # Creates a new DNS name from +arg+. +arg+ can be:
+ #
+ # Name:: returns +arg+.
+ # String:: Creates a new Name.
+
+ def self.create(arg)
+ case arg
+ when Name
+ return arg
+ when String
+ return Name.new(Label.split(arg), /\.\z/ =~ arg ? true : false)
+ else
+ raise ArgumentError.new("cannot interpret as DNS name: #{arg.inspect}")
+ end
+ end
+
+ def initialize(labels, absolute=true) # :nodoc:
+ labels = labels.map {|label|
+ case label
+ when String then Label::Str.new(label)
+ when Label::Str then label
+ else
+ raise ArgumentError, "unexpected label: #{label.inspect}"
+ end
+ }
+ @labels = labels
+ @absolute = absolute
+ end
+
+ def inspect # :nodoc:
+ "#<#{self.class}: #{self}#{@absolute ? '.' : ''}>"
+ end
+
+ ##
+ # True if this name is absolute.
+
+ def absolute?
+ return @absolute
+ end
+
+ def ==(other) # :nodoc:
+ return false unless Name === other
+ return false unless @absolute == other.absolute?
+ return @labels == other.to_a
+ end
+
+ alias eql? == # :nodoc:
+
+ ##
+ # Returns true if +other+ is a subdomain.
+ #
+ # Example:
+ #
+ # domain = Gem::Resolv::DNS::Name.create("y.z")
+ # p Gem::Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true
+ # p Gem::Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true
+ # p Gem::Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false
+ # p Gem::Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false
+ # p Gem::Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false
+ # p Gem::Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false
+ #
+
+ def subdomain_of?(other)
+ raise ArgumentError, "not a domain name: #{other.inspect}" unless Name === other
+ return false if @absolute != other.absolute?
+ other_len = other.length
+ return false if @labels.length <= other_len
+ return @labels[-other_len, other_len] == other.to_a
+ end
+
+ def hash # :nodoc:
+ return @labels.hash ^ @absolute.hash
+ end
+
+ def to_a # :nodoc:
+ return @labels
+ end
+
+ def length # :nodoc:
+ return @labels.length
+ end
+
+ def [](i) # :nodoc:
+ return @labels[i]
+ end
+
+ ##
+ # returns the domain name as a string.
+ #
+ # The domain name doesn't have a trailing dot even if the name object is
+ # absolute.
+ #
+ # Example:
+ #
+ # p Gem::Resolv::DNS::Name.create("x.y.z.").to_s #=> "x.y.z"
+ # p Gem::Resolv::DNS::Name.create("x.y.z").to_s #=> "x.y.z"
+
+ def to_s
+ return @labels.join('.')
+ end
+ end
+
+ class Message # :nodoc:
+ @@identifier = -1
+
+ def initialize(id = (@@identifier += 1) & 0xffff)
+ @id = id
+ @qr = 0
+ @opcode = 0
+ @aa = 0
+ @tc = 0
+ @rd = 0 # recursion desired
+ @ra = 0 # recursion available
+ @rcode = 0
+ @question = []
+ @answer = []
+ @authority = []
+ @additional = []
+ end
+
+ attr_accessor :id, :qr, :opcode, :aa, :tc, :rd, :ra, :rcode
+ attr_reader :question, :answer, :authority, :additional
+
+ def ==(other)
+ return @id == other.id &&
+ @qr == other.qr &&
+ @opcode == other.opcode &&
+ @aa == other.aa &&
+ @tc == other.tc &&
+ @rd == other.rd &&
+ @ra == other.ra &&
+ @rcode == other.rcode &&
+ @question == other.question &&
+ @answer == other.answer &&
+ @authority == other.authority &&
+ @additional == other.additional
+ end
+
+ def add_question(name, typeclass)
+ @question << [Name.create(name), typeclass]
+ end
+
+ def each_question
+ @question.each {|name, typeclass|
+ yield name, typeclass
+ }
+ end
+
+ def add_answer(name, ttl, data)
+ @answer << [Name.create(name), ttl, data]
+ end
+
+ def each_answer
+ @answer.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def add_authority(name, ttl, data)
+ @authority << [Name.create(name), ttl, data]
+ end
+
+ def each_authority
+ @authority.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def add_additional(name, ttl, data)
+ @additional << [Name.create(name), ttl, data]
+ end
+
+ def each_additional
+ @additional.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def each_resource
+ each_answer {|name, ttl, data| yield name, ttl, data}
+ each_authority {|name, ttl, data| yield name, ttl, data}
+ each_additional {|name, ttl, data| yield name, ttl, data}
+ end
+
+ def encode
+ return MessageEncoder.new {|msg|
+ msg.put_pack('nnnnnn',
+ @id,
+ (@qr & 1) << 15 |
+ (@opcode & 15) << 11 |
+ (@aa & 1) << 10 |
+ (@tc & 1) << 9 |
+ (@rd & 1) << 8 |
+ (@ra & 1) << 7 |
+ (@rcode & 15),
+ @question.length,
+ @answer.length,
+ @authority.length,
+ @additional.length)
+ @question.each {|q|
+ name, typeclass = q
+ msg.put_name(name)
+ msg.put_pack('nn', typeclass::TypeValue, typeclass::ClassValue)
+ }
+ [@answer, @authority, @additional].each {|rr|
+ rr.each {|r|
+ name, ttl, data = r
+ msg.put_name(name)
+ msg.put_pack('nnN', data.class::TypeValue, data.class::ClassValue, ttl)
+ msg.put_length16 {data.encode_rdata(msg)}
+ }
+ }
+ }.to_s
+ end
+
+ class MessageEncoder # :nodoc:
+ def initialize
+ @data = ''.dup
+ @names = {}
+ yield self
+ end
+
+ def to_s
+ return @data
+ end
+
+ def put_bytes(d)
+ @data << d
+ end
+
+ def put_pack(template, *d)
+ @data << d.pack(template)
+ end
+
+ def put_length16
+ length_index = @data.length
+ @data << "\0\0"
+ data_start = @data.length
+ yield
+ data_end = @data.length
+ @data[length_index, 2] = [data_end - data_start].pack("n")
+ end
+
+ def put_string(d)
+ self.put_pack("C", d.length)
+ @data << d
+ end
+
+ def put_string_list(ds)
+ ds.each {|d|
+ self.put_string(d)
+ }
+ end
+
+ def put_name(d, compress: true)
+ put_labels(d.to_a, compress: compress)
+ end
+
+ def put_labels(d, compress: true)
+ d.each_index {|i|
+ domain = d[i..-1]
+ if compress && idx = @names[domain]
+ self.put_pack("n", 0xc000 | idx)
+ return
+ else
+ if @data.length < 0x4000
+ @names[domain] = @data.length
+ end
+ self.put_label(d[i])
+ end
+ }
+ @data << "\0"
+ end
+
+ def put_label(d)
+ self.put_string(d.to_s)
+ end
+ end
+
+ def Message.decode(m)
+ o = Message.new(0)
+ MessageDecoder.new(m) {|msg|
+ id, flag, qdcount, ancount, nscount, arcount =
+ msg.get_unpack('nnnnnn')
+ o.id = id
+ o.tc = (flag >> 9) & 1
+ o.rcode = flag & 15
+ return o unless o.tc.zero?
+
+ o.qr = (flag >> 15) & 1
+ o.opcode = (flag >> 11) & 15
+ o.aa = (flag >> 10) & 1
+ o.rd = (flag >> 8) & 1
+ o.ra = (flag >> 7) & 1
+ (1..qdcount).each {
+ name, typeclass = msg.get_question
+ o.add_question(name, typeclass)
+ }
+ (1..ancount).each {
+ name, ttl, data = msg.get_rr
+ o.add_answer(name, ttl, data)
+ }
+ (1..nscount).each {
+ name, ttl, data = msg.get_rr
+ o.add_authority(name, ttl, data)
+ }
+ (1..arcount).each {
+ name, ttl, data = msg.get_rr
+ o.add_additional(name, ttl, data)
+ }
+ }
+ return o
+ end
+
+ class MessageDecoder # :nodoc:
+ def initialize(data)
+ @data = data
+ @index = 0
+ @limit = data.bytesize
+ yield self
+ end
+
+ def inspect
+ "\#<#{self.class}: #{@data.byteslice(0, @index).inspect} #{@data.byteslice(@index..-1).inspect}>"
+ end
+
+ def get_length16
+ len, = self.get_unpack('n')
+ save_limit = @limit
+ @limit = @index + len
+ d = yield(len)
+ if @index < @limit
+ raise DecodeError.new("junk exists")
+ elsif @limit < @index
+ raise DecodeError.new("limit exceeded")
+ end
+ @limit = save_limit
+ return d
+ end
+
+ def get_bytes(len = @limit - @index)
+ raise DecodeError.new("limit exceeded") if @limit < @index + len
+ d = @data.byteslice(@index, len)
+ @index += len
+ return d
+ end
+
+ def get_unpack(template)
+ len = 0
+ template.each_byte {|byte|
+ byte = "%c" % byte
+ case byte
+ when ?c, ?C
+ len += 1
+ when ?n
+ len += 2
+ when ?N
+ len += 4
+ else
+ raise StandardError.new("unsupported template: '#{byte.chr}' in '#{template}'")
+ end
+ }
+ raise DecodeError.new("limit exceeded") if @limit < @index + len
+ arr = @data.unpack("@#{@index}#{template}")
+ @index += len
+ return arr
+ end
+
+ def get_string
+ raise DecodeError.new("limit exceeded") if @limit <= @index
+ len = @data.getbyte(@index)
+ raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len
+ d = @data.byteslice(@index + 1, len)
+ @index += 1 + len
+ return d
+ end
+
+ def get_string_list
+ strings = []
+ while @index < @limit
+ strings << self.get_string
+ end
+ strings
+ end
+
+ def get_list
+ [].tap do |values|
+ while @index < @limit
+ values << yield
+ end
+ end
+ end
+
+ def get_name
+ return Name.new(self.get_labels)
+ end
+
+ def get_labels
+ prev_index = @index
+ save_index = nil
+ d = []
+ size = -1
+ while true
+ raise DecodeError.new("limit exceeded") if @limit <= @index
+ case @data.getbyte(@index)
+ when 0
+ @index += 1
+ if save_index
+ @index = save_index
+ end
+ return d
+ when 192..255
+ idx = self.get_unpack('n')[0] & 0x3fff
+ if prev_index <= idx
+ raise DecodeError.new("non-backward name pointer")
+ end
+ prev_index = idx
+ if !save_index
+ save_index = @index
+ end
+ @index = idx
+ else
+ l = self.get_label
+ d << l
+ size += 1 + l.string.bytesize
+ raise DecodeError.new("name label data exceed 255 octets") if size > 255
+ end
+ end
+ end
+
+ def get_label
+ return Label::Str.new(self.get_string)
+ end
+
+ def get_question
+ name = self.get_name
+ type, klass = self.get_unpack("nn")
+ return name, Resource.get_class(type, klass)
+ end
+
+ def get_rr
+ name = self.get_name
+ type, klass, ttl = self.get_unpack('nnN')
+ typeclass = Resource.get_class(type, klass)
+ res = self.get_length16 do
+ begin
+ typeclass.decode_rdata self
+ rescue => e
+ raise DecodeError, e.message, e.backtrace
+ end
+ end
+ res.instance_variable_set :@ttl, ttl
+ return name, ttl, res
+ end
+ end
+ end
+
+ ##
+ # SvcParams for service binding RRs. [RFC9460]
+
+ class SvcParams
+ include Enumerable
+
+ ##
+ # Create a list of SvcParams with the given initial content.
+ #
+ # +params+ has to be an enumerable of +SvcParam+s.
+ # If its content has +SvcParam+s with the duplicate key,
+ # the one appears last takes precedence.
+
+ def initialize(params = [])
+ @params = {}
+
+ params.each do |param|
+ add param
+ end
+ end
+
+ ##
+ # Get SvcParam for the given +key+ in this list.
+
+ def [](key)
+ @params[canonical_key(key)]
+ end
+
+ ##
+ # Get the number of SvcParams in this list.
+
+ def count
+ @params.count
+ end
+
+ ##
+ # Get whether this list is empty.
+
+ def empty?
+ @params.empty?
+ end
+
+ ##
+ # Add the SvcParam +param+ to this list, overwriting the existing one with the same key.
+
+ def add(param)
+ @params[param.class.key_number] = param
+ end
+
+ ##
+ # Remove the +SvcParam+ with the given +key+ and return it.
+
+ def delete(key)
+ @params.delete(canonical_key(key))
+ end
+
+ ##
+ # Enumerate the +SvcParam+s in this list.
+
+ def each(&block)
+ return enum_for(:each) unless block
+ @params.each_value(&block)
+ end
+
+ def encode(msg) # :nodoc:
+ @params.keys.sort.each do |key|
+ msg.put_pack('n', key)
+ msg.put_length16 do
+ @params.fetch(key).encode(msg)
+ end
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ params = msg.get_list do
+ key, = msg.get_unpack('n')
+ msg.get_length16 do
+ SvcParam::ClassHash[key].decode(msg)
+ end
+ end
+
+ return self.new(params)
+ end
+
+ private
+
+ def canonical_key(key) # :nodoc:
+ case key
+ when Integer
+ key
+ when /\Akey(\d+)\z/
+ Integer($1)
+ when Symbol
+ SvcParam::ClassHash[key].key_number
+ else
+ raise TypeError, 'key must be either String or Symbol'
+ end
+ end
+ end
+
+ ##
+ # Base class for SvcParam. [RFC9460]
+
+ class SvcParam
+
+ ##
+ # Get the presentation name of the SvcParamKey.
+
+ def self.key_name
+ const_get(:KeyName)
+ end
+
+ ##
+ # Get the registered number of the SvcParamKey.
+
+ def self.key_number
+ const_get(:KeyNumber)
+ end
+
+ ClassHash = Hash.new do |h, key| # :nodoc:
+ case key
+ when Integer
+ Generic.create(key)
+ when /\Akey(?<key>\d+)\z/
+ Generic.create(key.to_int)
+ when Symbol
+ raise KeyError, "unknown key #{key}"
+ else
+ raise TypeError, 'key must be either String or Symbol'
+ end
+ end
+
+ ##
+ # Generic SvcParam abstract class.
+
+ class Generic < SvcParam
+
+ ##
+ # SvcParamValue in wire-format byte string.
+
+ attr_reader :value
+
+ ##
+ # Create generic SvcParam
+
+ def initialize(value)
+ @value = value
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_bytes(@value)
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new(msg.get_bytes)
+ end
+
+ def self.create(key_number)
+ c = Class.new(Generic)
+ key_name = :"key#{key_number}"
+ c.const_set(:KeyName, key_name)
+ c.const_set(:KeyNumber, key_number)
+ self.const_set(:"Key#{key_number}", c)
+ ClassHash[key_name] = ClassHash[key_number] = c
+ return c
+ end
+ end
+
+ ##
+ # "mandatory" SvcParam -- Mandatory keys in service binding RR
+
+ class Mandatory < SvcParam
+ KeyName = :mandatory
+ KeyNumber = 0
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Mandatory keys.
+
+ attr_reader :keys
+
+ ##
+ # Initialize "mandatory" ScvParam.
+
+ def initialize(keys)
+ @keys = keys.map(&:to_int)
+ end
+
+ def encode(msg) # :nodoc:
+ @keys.sort.each do |key|
+ msg.put_pack('n', key)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ keys = msg.get_list { msg.get_unpack('n')[0] }
+ return self.new(keys)
+ end
+ end
+
+ ##
+ # "alpn" SvcParam -- Additional supported protocols
+
+ class ALPN < SvcParam
+ KeyName = :alpn
+ KeyNumber = 1
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Supported protocol IDs.
+
+ attr_reader :protocol_ids
+
+ ##
+ # Initialize "alpn" ScvParam.
+
+ def initialize(protocol_ids)
+ @protocol_ids = protocol_ids.map(&:to_str)
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_string_list(@protocol_ids)
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new(msg.get_string_list)
+ end
+ end
+
+ ##
+ # "no-default-alpn" SvcParam -- No support for default protocol
+
+ class NoDefaultALPN < SvcParam
+ KeyName = :'no-default-alpn'
+ KeyNumber = 2
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ def encode(msg) # :nodoc:
+ # no payload
+ end
+
+ def self.decode(msg) # :nodoc:
+ return self.new
+ end
+ end
+
+ ##
+ # "port" SvcParam -- Port for alternative endpoint
+
+ class Port < SvcParam
+ KeyName = :port
+ KeyNumber = 3
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Port number.
+
+ attr_reader :port
+
+ ##
+ # Initialize "port" ScvParam.
+
+ def initialize(port)
+ @port = port.to_int
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_pack('n', @port)
+ end
+
+ def self.decode(msg) # :nodoc:
+ port, = msg.get_unpack('n')
+ return self.new(port)
+ end
+ end
+
+ ##
+ # "ipv4hint" SvcParam -- IPv4 address hints
+
+ class IPv4Hint < SvcParam
+ KeyName = :ipv4hint
+ KeyNumber = 4
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Set of IPv4 addresses.
+
+ attr_reader :addresses
+
+ ##
+ # Initialize "ipv4hint" ScvParam.
+
+ def initialize(addresses)
+ @addresses = addresses.map {|address| IPv4.create(address) }
+ end
+
+ def encode(msg) # :nodoc:
+ @addresses.each do |address|
+ msg.put_bytes(address.address)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ addresses = msg.get_list { IPv4.new(msg.get_bytes(4)) }
+ return self.new(addresses)
+ end
+ end
+
+ ##
+ # "ipv6hint" SvcParam -- IPv6 address hints
+
+ class IPv6Hint < SvcParam
+ KeyName = :ipv6hint
+ KeyNumber = 6
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # Set of IPv6 addresses.
+
+ attr_reader :addresses
+
+ ##
+ # Initialize "ipv6hint" ScvParam.
+
+ def initialize(addresses)
+ @addresses = addresses.map {|address| IPv6.create(address) }
+ end
+
+ def encode(msg) # :nodoc:
+ @addresses.each do |address|
+ msg.put_bytes(address.address)
+ end
+ end
+
+ def self.decode(msg) # :nodoc:
+ addresses = msg.get_list { IPv6.new(msg.get_bytes(16)) }
+ return self.new(addresses)
+ end
+ end
+
+ ##
+ # "dohpath" SvcParam -- DNS over HTTPS path template [RFC9461]
+
+ class DoHPath < SvcParam
+ KeyName = :dohpath
+ KeyNumber = 7
+ ClassHash[KeyName] = ClassHash[KeyNumber] = self # :nodoc:
+
+ ##
+ # URI template for DoH queries.
+
+ attr_reader :template
+
+ ##
+ # Initialize "dohpath" ScvParam.
+
+ def initialize(template)
+ @template = template.encode('utf-8')
+ end
+
+ def encode(msg) # :nodoc:
+ msg.put_bytes(@template)
+ end
+
+ def self.decode(msg) # :nodoc:
+ template = msg.get_bytes.force_encoding('utf-8')
+ return self.new(template)
+ end
+ end
+ end
+
+ ##
+ # A DNS query abstract class.
+
+ class Query
+ def encode_rdata(msg) # :nodoc:
+ raise EncodeError.new("#{self.class} is query.")
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ raise DecodeError.new("#{self.class} is query.")
+ end
+ end
+
+ ##
+ # A DNS resource abstract class.
+
+ class Resource < Query
+
+ ##
+ # Remaining Time To Live for this Resource.
+
+ attr_reader :ttl
+
+ ClassHash = Module.new do
+ module_function
+
+ def []=(type_class_value, klass)
+ type_value, class_value = type_class_value
+ Resource.const_set(:"Type#{type_value}_Class#{class_value}", klass)
+ end
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ raise NotImplementedError.new
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ raise NotImplementedError.new
+ 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}
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ h = 0
+ vars = self.instance_variables
+ vars.delete :@ttl
+ vars.each {|name|
+ h ^= self.instance_variable_get(name).hash
+ }
+ return h
+ end
+
+ def self.get_class(type_value, class_value) # :nodoc:
+ cache = :"Type#{type_value}_Class#{class_value}"
+
+ return (const_defined?(cache) && const_get(cache)) ||
+ Generic.create(type_value, class_value)
+ end
+
+ ##
+ # A generic resource abstract class.
+
+ class Generic < Resource
+
+ ##
+ # Creates a new generic resource.
+
+ def initialize(data)
+ @data = data
+ end
+
+ ##
+ # Data for this generic resource.
+
+ attr_reader :data
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_bytes(data)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ return self.new(msg.get_bytes)
+ end
+
+ def self.create(type_value, class_value) # :nodoc:
+ c = Class.new(Generic)
+ c.const_set(:TypeValue, type_value)
+ c.const_set(:ClassValue, class_value)
+ Generic.const_set("Type#{type_value}_Class#{class_value}", c)
+ ClassHash[[type_value, class_value]] = c
+ return c
+ end
+ end
+
+ ##
+ # Domain Name resource abstract class.
+
+ class DomainName < Resource
+
+ ##
+ # Creates a new DomainName from +name+.
+
+ def initialize(name)
+ @name = name
+ end
+
+ ##
+ # The name of this DomainName.
+
+ attr_reader :name
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_name(@name)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ return self.new(msg.get_name)
+ end
+ end
+
+ # Standard (class generic) RRs
+
+ ClassValue = nil # :nodoc:
+
+ ##
+ # An authoritative name server.
+
+ class NS < DomainName
+ TypeValue = 2 # :nodoc:
+ end
+
+ ##
+ # The canonical name for an alias.
+
+ class CNAME < DomainName
+ TypeValue = 5 # :nodoc:
+ end
+
+ ##
+ # Start Of Authority resource.
+
+ class SOA < Resource
+
+ TypeValue = 6 # :nodoc:
+
+ ##
+ # Creates a new SOA record. See the attr documentation for the
+ # details of each argument.
+
+ def initialize(mname, rname, serial, refresh, retry_, expire, minimum)
+ @mname = mname
+ @rname = rname
+ @serial = serial
+ @refresh = refresh
+ @retry = retry_
+ @expire = expire
+ @minimum = minimum
+ end
+
+ ##
+ # Name of the host where the master zone file for this zone resides.
+
+ attr_reader :mname
+
+ ##
+ # The person responsible for this domain name.
+
+ attr_reader :rname
+
+ ##
+ # The version number of the zone file.
+
+ attr_reader :serial
+
+ ##
+ # How often, in seconds, a secondary name server is to check for
+ # updates from the primary name server.
+
+ attr_reader :refresh
+
+ ##
+ # How often, in seconds, a secondary name server is to retry after a
+ # failure to check for a refresh.
+
+ attr_reader :retry
+
+ ##
+ # Time in seconds that a secondary name server is to use the data
+ # before refreshing from the primary name server.
+
+ attr_reader :expire
+
+ ##
+ # The minimum number of seconds to be used for TTL values in RRs.
+
+ attr_reader :minimum
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_name(@mname)
+ msg.put_name(@rname)
+ msg.put_pack('NNNNN', @serial, @refresh, @retry, @expire, @minimum)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ mname = msg.get_name
+ rname = msg.get_name
+ serial, refresh, retry_, expire, minimum = msg.get_unpack('NNNNN')
+ return self.new(
+ mname, rname, serial, refresh, retry_, expire, minimum)
+ end
+ end
+
+ ##
+ # A Pointer to another DNS name.
+
+ class PTR < DomainName
+ TypeValue = 12 # :nodoc:
+ end
+
+ ##
+ # Host Information resource.
+
+ class HINFO < Resource
+
+ TypeValue = 13 # :nodoc:
+
+ ##
+ # Creates a new HINFO running +os+ on +cpu+.
+
+ def initialize(cpu, os)
+ @cpu = cpu
+ @os = os
+ end
+
+ ##
+ # CPU architecture for this resource.
+
+ attr_reader :cpu
+
+ ##
+ # Operating system for this resource.
+
+ attr_reader :os
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_string(@cpu)
+ msg.put_string(@os)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ cpu = msg.get_string
+ os = msg.get_string
+ return self.new(cpu, os)
+ end
+ end
+
+ ##
+ # Mailing list or mailbox information.
+
+ class MINFO < Resource
+
+ TypeValue = 14 # :nodoc:
+
+ def initialize(rmailbx, emailbx)
+ @rmailbx = rmailbx
+ @emailbx = emailbx
+ end
+
+ ##
+ # Domain name responsible for this mail list or mailbox.
+
+ attr_reader :rmailbx
+
+ ##
+ # Mailbox to use for error messages related to the mail list or mailbox.
+
+ attr_reader :emailbx
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_name(@rmailbx)
+ msg.put_name(@emailbx)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ rmailbx = msg.get_string
+ emailbx = msg.get_string
+ return self.new(rmailbx, emailbx)
+ end
+ end
+
+ ##
+ # Mail Exchanger resource.
+
+ class MX < Resource
+
+ TypeValue= 15 # :nodoc:
+
+ ##
+ # Creates a new MX record with +preference+, accepting mail at
+ # +exchange+.
+
+ def initialize(preference, exchange)
+ @preference = preference
+ @exchange = exchange
+ end
+
+ ##
+ # The preference for this MX.
+
+ attr_reader :preference
+
+ ##
+ # The host of this MX.
+
+ attr_reader :exchange
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack('n', @preference)
+ msg.put_name(@exchange)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ preference, = msg.get_unpack('n')
+ exchange = msg.get_name
+ return self.new(preference, exchange)
+ end
+ end
+
+ ##
+ # Unstructured text resource.
+
+ class TXT < Resource
+
+ TypeValue = 16 # :nodoc:
+
+ def initialize(first_string, *rest_strings)
+ @strings = [first_string, *rest_strings]
+ end
+
+ ##
+ # Returns an Array of Strings for this TXT record.
+
+ attr_reader :strings
+
+ ##
+ # Returns the concatenated string from +strings+.
+
+ def data
+ @strings.join("")
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_string_list(@strings)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ strings = msg.get_string_list
+ return self.new(*strings)
+ end
+ end
+
+ ##
+ # Location resource
+
+ class LOC < Resource
+
+ TypeValue = 29 # :nodoc:
+
+ def initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude)
+ @version = version
+ @ssize = Gem::Resolv::LOC::Size.create(ssize)
+ @hprecision = Gem::Resolv::LOC::Size.create(hprecision)
+ @vprecision = Gem::Resolv::LOC::Size.create(vprecision)
+ @latitude = Gem::Resolv::LOC::Coord.create(latitude)
+ @longitude = Gem::Resolv::LOC::Coord.create(longitude)
+ @altitude = Gem::Resolv::LOC::Alt.create(altitude)
+ end
+
+ ##
+ # Returns the version value for this LOC record which should always be 00
+
+ attr_reader :version
+
+ ##
+ # The spherical size of this LOC
+ # in meters using scientific notation as 2 integers of XeY
+
+ attr_reader :ssize
+
+ ##
+ # The horizontal precision using ssize type values
+ # in meters using scientific notation as 2 integers of XeY
+ # for precision use value/2 e.g. 2m = +/-1m
+
+ attr_reader :hprecision
+
+ ##
+ # The vertical precision using ssize type values
+ # in meters using scientific notation as 2 integers of XeY
+ # for precision use value/2 e.g. 2m = +/-1m
+
+ attr_reader :vprecision
+
+ ##
+ # The latitude for this LOC where 2**31 is the equator
+ # in thousandths of an arc second as an unsigned 32bit integer
+
+ attr_reader :latitude
+
+ ##
+ # The longitude for this LOC where 2**31 is the prime meridian
+ # in thousandths of an arc second as an unsigned 32bit integer
+
+ attr_reader :longitude
+
+ ##
+ # The altitude of the LOC above a reference sphere whose surface sits 100km below the WGS84 spheroid
+ # in centimeters as an unsigned 32bit integer
+
+ attr_reader :altitude
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_bytes(@version)
+ msg.put_bytes(@ssize.scalar)
+ msg.put_bytes(@hprecision.scalar)
+ msg.put_bytes(@vprecision.scalar)
+ msg.put_bytes(@latitude.coordinates)
+ msg.put_bytes(@longitude.coordinates)
+ msg.put_bytes(@altitude.altitude)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ version = msg.get_bytes(1)
+ ssize = msg.get_bytes(1)
+ hprecision = msg.get_bytes(1)
+ vprecision = msg.get_bytes(1)
+ latitude = msg.get_bytes(4)
+ longitude = msg.get_bytes(4)
+ altitude = msg.get_bytes(4)
+ return self.new(
+ version,
+ Gem::Resolv::LOC::Size.new(ssize),
+ Gem::Resolv::LOC::Size.new(hprecision),
+ Gem::Resolv::LOC::Size.new(vprecision),
+ Gem::Resolv::LOC::Coord.new(latitude,"lat"),
+ Gem::Resolv::LOC::Coord.new(longitude,"lon"),
+ Gem::Resolv::LOC::Alt.new(altitude)
+ )
+ end
+ end
+
+ ##
+ # A Query type requesting any RR.
+
+ class ANY < Query
+ TypeValue = 255 # :nodoc:
+ end
+
+ ##
+ # CAA resource record defined in RFC 8659
+ #
+ # These records identify certificate authority allowed to issue
+ # certificates for the given domain.
+
+ class CAA < Resource
+ TypeValue = 257
+
+ ##
+ # Creates a new CAA for +flags+, +tag+ and +value+.
+
+ def initialize(flags, tag, value)
+ unless (0..255) === flags
+ raise ArgumentError.new('flags must be an Integer between 0 and 255')
+ end
+ unless (1..15) === tag.bytesize
+ raise ArgumentError.new('length of tag must be between 1 and 15')
+ end
+
+ @flags = flags
+ @tag = tag
+ @value = value
+ end
+
+ ##
+ # Flags for this property:
+ # - Bit 0 : 0 = not critical, 1 = critical
+
+ attr_reader :flags
+
+ ##
+ # Property tag ("issue", "issuewild", "iodef"...).
+
+ attr_reader :tag
+
+ ##
+ # Property value.
+
+ attr_reader :value
+
+ ##
+ # Whether the critical flag is set on this property.
+
+ def critical?
+ flags & 0x80 != 0
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack('C', @flags)
+ msg.put_string(@tag)
+ msg.put_bytes(@value)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ flags, = msg.get_unpack('C')
+ tag = msg.get_string
+ value = msg.get_bytes
+ self.new flags, tag, value
+ end
+ end
+
+ ClassInsensitiveTypes = [ # :nodoc:
+ NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, LOC, ANY, CAA
+ ]
+
+ ##
+ # module IN contains ARPA Internet specific RRs.
+
+ module IN
+
+ ClassValue = 1 # :nodoc:
+
+ ClassInsensitiveTypes.each {|s|
+ c = Class.new(s)
+ c.const_set(:TypeValue, s::TypeValue)
+ c.const_set(:ClassValue, ClassValue)
+ ClassHash[[s::TypeValue, ClassValue]] = c
+ self.const_set(s.name.sub(/.*::/, ''), c)
+ }
+
+ ##
+ # IPv4 Address resource
+
+ class A < Resource
+ TypeValue = 1
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+
+ ##
+ # Creates a new A for +address+.
+
+ def initialize(address)
+ @address = IPv4.create(address)
+ end
+
+ ##
+ # The Gem::Resolv::IPv4 address for this A.
+
+ attr_reader :address
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_bytes(@address.address)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ return self.new(IPv4.new(msg.get_bytes(4)))
+ end
+ end
+
+ ##
+ # Well Known Service resource.
+
+ class WKS < Resource
+ TypeValue = 11
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+
+ def initialize(address, protocol, bitmap)
+ @address = IPv4.create(address)
+ @protocol = protocol
+ @bitmap = bitmap
+ end
+
+ ##
+ # The host these services run on.
+
+ attr_reader :address
+
+ ##
+ # IP protocol number for these services.
+
+ attr_reader :protocol
+
+ ##
+ # A bit map of enabled services on this host.
+ #
+ # If protocol is 6 (TCP) then the 26th bit corresponds to the SMTP
+ # service (port 25). If this bit is set, then an SMTP server should
+ # be listening on TCP port 25; if zero, SMTP service is not
+ # supported.
+
+ attr_reader :bitmap
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_bytes(@address.address)
+ msg.put_pack("n", @protocol)
+ msg.put_bytes(@bitmap)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ address = IPv4.new(msg.get_bytes(4))
+ protocol, = msg.get_unpack("n")
+ bitmap = msg.get_bytes
+ return self.new(address, protocol, bitmap)
+ end
+ end
+
+ ##
+ # An IPv6 address record.
+
+ class AAAA < Resource
+ TypeValue = 28
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+
+ ##
+ # Creates a new AAAA for +address+.
+
+ def initialize(address)
+ @address = IPv6.create(address)
+ end
+
+ ##
+ # The Gem::Resolv::IPv6 address for this AAAA.
+
+ attr_reader :address
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_bytes(@address.address)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ return self.new(IPv6.new(msg.get_bytes(16)))
+ end
+ end
+
+ ##
+ # SRV resource record defined in RFC 2782
+ #
+ # These records identify the hostname and port that a service is
+ # available at.
+
+ class SRV < Resource
+ TypeValue = 33
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+
+ # Create a SRV resource record.
+ #
+ # See the documentation for #priority, #weight, #port and #target
+ # for +priority+, +weight+, +port and +target+ respectively.
+
+ def initialize(priority, weight, port, target)
+ @priority = priority.to_int
+ @weight = weight.to_int
+ @port = port.to_int
+ @target = Name.create(target)
+ end
+
+ # The priority of this target host.
+ #
+ # A client MUST attempt to contact the target host with the
+ # lowest-numbered priority it can reach; target hosts with the same
+ # priority SHOULD be tried in an order defined by the weight field.
+ # The range is 0-65535. Note that it is not widely implemented and
+ # should be set to zero.
+
+ attr_reader :priority
+
+ # A server selection mechanism.
+ #
+ # The weight field specifies a relative weight for entries with the
+ # same priority. Larger weights SHOULD be given a proportionately
+ # higher probability of being selected. The range of this number is
+ # 0-65535. Domain administrators SHOULD use Weight 0 when there
+ # isn't any server selection to do, to make the RR easier to read
+ # for humans (less noisy). Note that it is not widely implemented
+ # and should be set to zero.
+
+ attr_reader :weight
+
+ # The port on this target host of this service.
+ #
+ # The range is 0-65535.
+
+ attr_reader :port
+
+ # The domain name of the target host.
+ #
+ # A target of "." means that the service is decidedly not available
+ # at this domain.
+
+ attr_reader :target
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack("n", @priority)
+ msg.put_pack("n", @weight)
+ msg.put_pack("n", @port)
+ msg.put_name(@target, compress: false)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ priority, = msg.get_unpack("n")
+ weight, = msg.get_unpack("n")
+ port, = msg.get_unpack("n")
+ target = msg.get_name
+ return self.new(priority, weight, port, target)
+ end
+ end
+
+ ##
+ # Common implementation for SVCB-compatible resource records.
+
+ class ServiceBinding
+
+ ##
+ # Create a service binding resource record.
+
+ def initialize(priority, target, params = [])
+ @priority = priority.to_int
+ @target = Name.create(target)
+ @params = SvcParams.new(params)
+ end
+
+ ##
+ # The priority of this target host.
+ #
+ # The range is 0-65535.
+ # If set to 0, this RR is in AliasMode. Otherwise, it is in ServiceMode.
+
+ attr_reader :priority
+
+ ##
+ # The domain name of the target host.
+
+ attr_reader :target
+
+ ##
+ # The service parameters for the target host.
+
+ attr_reader :params
+
+ ##
+ # Whether this RR is in AliasMode.
+
+ def alias_mode?
+ self.priority == 0
+ end
+
+ ##
+ # Whether this RR is in ServiceMode.
+
+ def service_mode?
+ !alias_mode?
+ end
+
+ def encode_rdata(msg) # :nodoc:
+ msg.put_pack("n", @priority)
+ msg.put_name(@target, compress: false)
+ @params.encode(msg)
+ end
+
+ def self.decode_rdata(msg) # :nodoc:
+ priority, = msg.get_unpack("n")
+ target = msg.get_name
+ params = SvcParams.decode(msg)
+ return self.new(priority, target, params)
+ end
+ end
+
+ ##
+ # SVCB resource record [RFC9460]
+
+ class SVCB < ServiceBinding
+ TypeValue = 64
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+ end
+
+ ##
+ # HTTPS resource record [RFC9460]
+
+ class HTTPS < ServiceBinding
+ TypeValue = 65
+ ClassValue = IN::ClassValue
+ ClassHash[[TypeValue, ClassValue]] = self # :nodoc:
+ end
+ end
+ end
+ end
+
+ ##
+ # A Gem::Resolv::DNS IPv4 address.
+
+ class IPv4
+
+ Regex256 = /0
+ |1(?:[0-9][0-9]?)?
+ |2(?:[0-4][0-9]?|5[0-5]?|[6-9])?
+ |[3-9][0-9]?/x # :nodoc:
+
+ ##
+ # Regular expression IPv4 addresses must match.
+ Regex = /\A(#{Regex256})\.(#{Regex256})\.(#{Regex256})\.(#{Regex256})\z/
+
+ ##
+ # Creates a new IPv4 address from +arg+ which may be:
+ #
+ # IPv4:: returns +arg+.
+ # String:: +arg+ must match the IPv4::Regex constant
+
+ def self.create(arg)
+ case arg
+ when IPv4
+ return arg
+ when Regex
+ if (0..255) === (a = $1.to_i) &&
+ (0..255) === (b = $2.to_i) &&
+ (0..255) === (c = $3.to_i) &&
+ (0..255) === (d = $4.to_i)
+ return self.new([a, b, c, d].pack("CCCC"))
+ else
+ raise ArgumentError.new("IPv4 address with invalid value: " + arg)
+ end
+ else
+ raise ArgumentError.new("cannot interpret as IPv4 address: #{arg.inspect}")
+ end
+ end
+
+ def initialize(address) # :nodoc:
+ unless address.kind_of?(String)
+ raise ArgumentError, 'IPv4 address must be a string'
+ end
+ unless address.length == 4
+ raise ArgumentError, "IPv4 address expects 4 bytes but #{address.length} bytes"
+ end
+ @address = address
+ end
+
+ ##
+ # A String representation of this IPv4 address.
+
+ ##
+ # The raw IPv4 address as a String.
+
+ attr_reader :address
+
+ def to_s # :nodoc:
+ return sprintf("%d.%d.%d.%d", *@address.unpack("CCCC"))
+ end
+
+ def inspect # :nodoc:
+ return "#<#{self.class} #{self}>"
+ end
+
+ ##
+ # Turns this IPv4 address into a Gem::Resolv::DNS::Name.
+
+ def to_name
+ return DNS::Name.create(
+ '%d.%d.%d.%d.in-addr.arpa.' % @address.unpack('CCCC').reverse)
+ end
+
+ def ==(other) # :nodoc:
+ return @address == other.address
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ return @address.hash
+ end
+ end
+
+ ##
+ # A Gem::Resolv::DNS IPv6 address.
+
+ class IPv6
+
+ ##
+ # IPv6 address format a:b:c:d:e:f:g:h
+ Regex_8Hex = /\A
+ (?:[0-9A-Fa-f]{1,4}:){7}
+ [0-9A-Fa-f]{1,4}
+ \z/x
+
+ ##
+ # Compressed IPv6 address format a::b
+
+ Regex_CompressedHex = /\A
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
+ \z/x
+
+ ##
+ # IPv4 mapped IPv6 address format a:b:c:d:e:f:w.x.y.z
+
+ Regex_6Hex4Dec = /\A
+ ((?:[0-9A-Fa-f]{1,4}:){6,6})
+ (\d+)\.(\d+)\.(\d+)\.(\d+)
+ \z/x
+
+ ##
+ # Compressed IPv4 mapped IPv6 address format a::b:w.x.y.z
+
+ Regex_CompressedHex4Dec = /\A
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::
+ ((?:[0-9A-Fa-f]{1,4}:)*)
+ (\d+)\.(\d+)\.(\d+)\.(\d+)
+ \z/x
+
+ ##
+ # IPv6 link local address format fe80:b:c:d:e:f:g:h%em1
+ Regex_8HexLinkLocal = /\A
+ [Ff][Ee]80
+ (?::[0-9A-Fa-f]{1,4}){7}
+ %[-0-9A-Za-z._~]+
+ \z/x
+
+ ##
+ # Compressed IPv6 link local address format fe80::b%em1
+
+ Regex_CompressedHexLinkLocal = /\A
+ [Ff][Ee]80:
+ (?:
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
+ |
+ :((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
+ )?
+ :[0-9A-Fa-f]{1,4}%[-0-9A-Za-z._~]+
+ \z/x
+
+ ##
+ # A composite IPv6 address Regexp.
+
+ Regex = /
+ (?:#{Regex_8Hex}) |
+ (?:#{Regex_CompressedHex}) |
+ (?:#{Regex_6Hex4Dec}) |
+ (?:#{Regex_CompressedHex4Dec}) |
+ (?:#{Regex_8HexLinkLocal}) |
+ (?:#{Regex_CompressedHexLinkLocal})
+ /x
+
+ ##
+ # Creates a new IPv6 address from +arg+ which may be:
+ #
+ # IPv6:: returns +arg+.
+ # String:: +arg+ must match one of the IPv6::Regex* constants
+
+ def self.create(arg)
+ case arg
+ when IPv6
+ return arg
+ when String
+ address = ''.b
+ if Regex_8Hex =~ arg
+ arg.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
+ elsif Regex_CompressedHex =~ arg
+ prefix = $1
+ suffix = $2
+ a1 = ''.b
+ a2 = ''.b
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
+ suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
+ omitlen = 16 - a1.length - a2.length
+ address << a1 << "\0" * omitlen << a2
+ elsif Regex_6Hex4Dec =~ arg
+ prefix, a, b, c, d = $1, $2.to_i, $3.to_i, $4.to_i, $5.to_i
+ if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
+ address << [a, b, c, d].pack('CCCC')
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ elsif Regex_CompressedHex4Dec =~ arg
+ prefix, suffix, a, b, c, d = $1, $2, $3.to_i, $4.to_i, $5.to_i, $6.to_i
+ if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
+ a1 = ''.b
+ a2 = ''.b
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
+ suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
+ omitlen = 12 - a1.length - a2.length
+ address << a1 << "\0" * omitlen << a2 << [a, b, c, d].pack('CCCC')
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ return IPv6.new(address)
+ else
+ raise ArgumentError.new("cannot interpret as IPv6 address: #{arg.inspect}")
+ end
+ end
+
+ def initialize(address) # :nodoc:
+ unless address.kind_of?(String) && address.length == 16
+ raise ArgumentError.new('IPv6 address must be 16 bytes')
+ end
+ @address = address
+ end
+
+ ##
+ # The raw IPv6 address as a String.
+
+ attr_reader :address
+
+ def to_s # :nodoc:
+ sprintf("%x:%x:%x:%x:%x:%x:%x:%x", *@address.unpack("nnnnnnnn")).sub(/(^|:)0(:0)+(:|$)/, '::')
+ end
+
+ def inspect # :nodoc:
+ return "#<#{self.class} #{self}>"
+ end
+
+ ##
+ # Turns this IPv6 address into a Gem::Resolv::DNS::Name.
+ #--
+ # ip6.arpa should be searched too. [RFC3152]
+
+ def to_name
+ return DNS::Name.new(
+ @address.unpack("H32")[0].split(//).reverse + ['ip6', 'arpa'])
+ end
+
+ def ==(other) # :nodoc:
+ return @address == other.address
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ return @address.hash
+ end
+ end
+
+ ##
+ # Gem::Resolv::MDNS is a one-shot Multicast DNS (mDNS) resolver. It blindly
+ # makes queries to the mDNS addresses without understanding anything about
+ # multicast ports.
+ #
+ # Information taken form the following places:
+ #
+ # * RFC 6762
+
+ class MDNS < DNS
+
+ ##
+ # Default mDNS Port
+
+ Port = 5353
+
+ ##
+ # Default IPv4 mDNS address
+
+ AddressV4 = '224.0.0.251'
+
+ ##
+ # Default IPv6 mDNS address
+
+ AddressV6 = 'ff02::fb'
+
+ ##
+ # Default mDNS addresses
+
+ Addresses = [
+ [AddressV4, Port],
+ [AddressV6, Port],
+ ]
+
+ ##
+ # Creates a new one-shot Multicast DNS (mDNS) resolver.
+ #
+ # +config_info+ can be:
+ #
+ # nil::
+ # Uses the default mDNS addresses
+ #
+ # Hash::
+ # Must contain :nameserver or :nameserver_port like
+ # Gem::Resolv::DNS#initialize.
+
+ def initialize(config_info=nil)
+ if config_info then
+ super({ nameserver_port: Addresses }.merge(config_info))
+ else
+ super(nameserver_port: Addresses)
+ end
+ end
+
+ ##
+ # Iterates over all IP addresses for +name+ retrieved from the mDNS
+ # resolver, provided name ends with "local". If the name does not end in
+ # "local" no records will be returned.
+ #
+ # +name+ can be a Gem::Resolv::DNS::Name or a String. Retrieved addresses will
+ # be a Gem::Resolv::IPv4 or Gem::Resolv::IPv6
+
+ def each_address(name)
+ name = Gem::Resolv::DNS::Name.create(name)
+
+ return unless name[-1].to_s == 'local'
+
+ super(name)
+ end
+
+ def make_udp_requester # :nodoc:
+ nameserver_port = @config.nameserver_port
+ Requester::MDNSOneShot.new(*nameserver_port)
+ end
+
+ end
+
+ module LOC # :nodoc:
+
+ ##
+ # A Gem::Resolv::LOC::Size
+
+ class Size
+
+ # Regular expression LOC size must match.
+
+ Regex = /^(\d+\.*\d*)[m]$/
+
+ ##
+ # Creates a new LOC::Size from +arg+ which may be:
+ #
+ # LOC::Size:: returns +arg+.
+ # String:: +arg+ must match the LOC::Size::Regex constant
+
+ def self.create(arg)
+ case arg
+ when Size
+ return arg
+ when String
+ scalar = ''
+ if Regex =~ arg
+ scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C")
+ else
+ raise ArgumentError.new("not a properly formed Size string: " + arg)
+ end
+ return Size.new(scalar)
+ else
+ raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}")
+ end
+ end
+
+ # Internal use; use self.create.
+ def initialize(scalar)
+ @scalar = scalar
+ end
+
+ ##
+ # The raw size
+
+ attr_reader :scalar
+
+ def to_s # :nodoc:
+ s = @scalar.unpack("H2").join.to_s
+ return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m"
+ end
+
+ def inspect # :nodoc:
+ return "#<#{self.class} #{self}>"
+ end
+
+ def ==(other) # :nodoc:
+ return @scalar == other.scalar
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ return @scalar.hash
+ end
+
+ end
+
+ ##
+ # A Gem::Resolv::LOC::Coord
+
+ class Coord
+
+ # Regular expression LOC Coord must match.
+
+ Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/
+
+ ##
+ # Creates a new LOC::Coord from +arg+ which may be:
+ #
+ # LOC::Coord:: returns +arg+.
+ # String:: +arg+ must match the LOC::Coord::Regex constant
+
+ def self.create(arg)
+ case arg
+ when Coord
+ return arg
+ when String
+ coordinates = ''
+ if Regex =~ arg && $1.to_f < 180
+ m = $~
+ hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
+ coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
+ (m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")
+ orientation = m[4][/[NS]/] ? 'lat' : 'lon'
+ else
+ raise ArgumentError.new("not a properly formed Coord string: " + arg)
+ end
+ return Coord.new(coordinates,orientation)
+ else
+ raise ArgumentError.new("cannot interpret as Coord: #{arg.inspect}")
+ end
+ end
+
+ # Internal use; use self.create.
+ def initialize(coordinates,orientation)
+ unless coordinates.kind_of?(String)
+ raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
+ end
+ unless orientation.kind_of?(String) && orientation[/^lon$|^lat$/]
+ raise ArgumentError.new('Coord expects orientation to be a String argument of "lat" or "lon"')
+ end
+ @coordinates = coordinates
+ @orientation = orientation
+ end
+
+ ##
+ # The raw coordinates
+
+ attr_reader :coordinates
+
+ ## The orientation of the hemisphere as 'lat' or 'lon'
+
+ attr_reader :orientation
+
+ def to_s # :nodoc:
+ c = @coordinates.unpack("N").join.to_i
+ val = (c - (2**31)).abs
+ fracsecs = (val % 1e3).to_i.to_s
+ val = val / 1e3
+ secs = (val % 60).to_i.to_s
+ val = val / 60
+ mins = (val % 60).to_i.to_s
+ degs = (val / 60).to_i.to_s
+ posi = (c >= 2**31)
+ case posi
+ when true
+ hemi = @orientation[/^lat$/] ? "N" : "E"
+ else
+ hemi = @orientation[/^lon$/] ? "W" : "S"
+ end
+ return degs << " " << mins << " " << secs << "." << fracsecs << " " << hemi
+ end
+
+ def inspect # :nodoc:
+ return "#<#{self.class} #{self}>"
+ end
+
+ def ==(other) # :nodoc:
+ return @coordinates == other.coordinates
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ return @coordinates.hash
+ end
+
+ end
+
+ ##
+ # A Gem::Resolv::LOC::Alt
+
+ class Alt
+
+ # Regular expression LOC Alt must match.
+
+ Regex = /^([+-]*\d+\.*\d*)[m]$/
+
+ ##
+ # Creates a new LOC::Alt from +arg+ which may be:
+ #
+ # LOC::Alt:: returns +arg+.
+ # String:: +arg+ must match the LOC::Alt::Regex constant
+
+ def self.create(arg)
+ case arg
+ when Alt
+ return arg
+ when String
+ altitude = ''
+ if Regex =~ arg
+ altitude = [($1.to_f*(1e2))+(1e7)].pack("N")
+ else
+ raise ArgumentError.new("not a properly formed Alt string: " + arg)
+ end
+ return Alt.new(altitude)
+ else
+ raise ArgumentError.new("cannot interpret as Alt: #{arg.inspect}")
+ end
+ end
+
+ # Internal use; use self.create.
+ def initialize(altitude)
+ @altitude = altitude
+ end
+
+ ##
+ # The raw altitude
+
+ attr_reader :altitude
+
+ def to_s # :nodoc:
+ a = @altitude.unpack("N").join.to_i
+ return ((a.to_f/1e2)-1e5).to_s + "m"
+ end
+
+ def inspect # :nodoc:
+ return "#<#{self.class} #{self}>"
+ end
+
+ def ==(other) # :nodoc:
+ return @altitude == other.altitude
+ end
+
+ def eql?(other) # :nodoc:
+ return self == other
+ end
+
+ def hash # :nodoc:
+ return @altitude.hash
+ end
+
+ end
+
+ end
+
+ ##
+ # Default resolver to use for Gem::Resolv class methods.
+
+ DefaultResolver = self.new
+
+ ##
+ # Replaces the resolvers in the default resolver with +new_resolvers+. This
+ # allows resolvers to be changed for resolv-replace.
+
+ def DefaultResolver.replace_resolvers new_resolvers
+ @resolvers = new_resolvers
+ end
+
+ ##
+ # Address Regexp to use for matching IP addresses.
+
+ AddressRegex = /(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/
+
+end
diff --git a/lib/rubygems/vendor/securerandom/lib/securerandom.rb b/lib/rubygems/vendor/securerandom/lib/securerandom.rb
new file mode 100644
index 0000000000..b6f1d71ad3
--- /dev/null
+++ b/lib/rubygems/vendor/securerandom/lib/securerandom.rb
@@ -0,0 +1,102 @@
+# -*- coding: us-ascii -*-
+# frozen_string_literal: true
+
+require 'random/formatter'
+
+# == Secure random number generator interface.
+#
+# This library is an interface to secure random number generators which are
+# suitable for generating session keys in HTTP cookies, etc.
+#
+# You can use this library in your application by requiring it:
+#
+# require 'rubygems/vendor/securerandom/lib/securerandom'
+#
+# It supports the following secure random number generators:
+#
+# * openssl
+# * /dev/urandom
+# * Win32
+#
+# Gem::SecureRandom is extended by the Random::Formatter module which
+# defines the following methods:
+#
+# * alphanumeric
+# * base64
+# * choose
+# * gen_random
+# * hex
+# * rand
+# * random_bytes
+# * random_number
+# * urlsafe_base64
+# * uuid
+#
+# These methods are usable as class methods of Gem::SecureRandom such as
+# +Gem::SecureRandom.hex+.
+#
+# If a secure random number generator is not available,
+# +NotImplementedError+ is raised.
+
+module Gem::SecureRandom
+
+ # The version
+ VERSION = "0.4.1"
+
+ class << self
+ # Returns a random binary string containing +size+ bytes.
+ #
+ # See Random.bytes
+ def bytes(n)
+ return gen_random(n)
+ end
+
+ # Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
+ def alphanumeric(n = nil, chars: ALPHANUMERIC)
+ n = 16 if n.nil?
+ choose(chars, n)
+ end if RUBY_VERSION < '3.3'
+
+ private
+
+ # :stopdoc:
+
+ # Implementation using OpenSSL
+ def gen_random_openssl(n)
+ return OpenSSL::Random.random_bytes(n)
+ end
+
+ # Implementation using system random device
+ def gen_random_urandom(n)
+ ret = Random.urandom(n)
+ unless ret
+ raise NotImplementedError, "No random device"
+ end
+ unless ret.length == n
+ raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
+ end
+ ret
+ end
+
+ begin
+ # Check if Random.urandom is available
+ Random.urandom(1)
+ alias gen_random gen_random_urandom
+ rescue RuntimeError
+ begin
+ require 'openssl'
+ rescue NoMethodError
+ raise NotImplementedError, "No random device"
+ else
+ alias gen_random gen_random_openssl
+ end
+ end
+
+ # :startdoc:
+
+ # Generate random data bytes for Random::Formatter
+ public :gen_random
+ end
+end
+
+Gem::SecureRandom.extend(Random::Formatter)
diff --git a/lib/rubygems/vendor/timeout/lib/timeout.rb b/lib/rubygems/vendor/timeout/lib/timeout.rb
new file mode 100644
index 0000000000..376b8c0e2b
--- /dev/null
+++ b/lib/rubygems/vendor/timeout/lib/timeout.rb
@@ -0,0 +1,201 @@
+# frozen_string_literal: true
+# Timeout long-running blocks
+#
+# == Synopsis
+#
+# require 'rubygems/vendor/timeout/lib/timeout'
+# status = Gem::Timeout.timeout(5) {
+# # Something that should be interrupted if it takes more than 5 seconds...
+# }
+#
+# == Description
+#
+# Gem::Timeout provides a way to auto-terminate a potentially long-running
+# operation if it hasn't finished in a fixed amount of time.
+#
+# == Copyright
+#
+# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
+# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
+
+module Gem::Timeout
+ # The version
+ VERSION = "0.4.4"
+
+ # Internal error raised to when a timeout is triggered.
+ class ExitException < Exception
+ def exception(*) # :nodoc:
+ self
+ end
+ end
+
+ # Raised by Gem::Timeout.timeout when the block times out.
+ class Error < RuntimeError
+ def self.handle_timeout(message) # :nodoc:
+ exc = ExitException.new(message)
+
+ begin
+ yield exc
+ rescue ExitException => e
+ raise new(message) if exc.equal?(e)
+ raise
+ end
+ end
+ end
+
+ # :stopdoc:
+ CONDVAR = ConditionVariable.new
+ QUEUE = Queue.new
+ QUEUE_MUTEX = Mutex.new
+ TIMEOUT_THREAD_MUTEX = Mutex.new
+ @timeout_thread = nil
+ private_constant :CONDVAR, :QUEUE, :QUEUE_MUTEX, :TIMEOUT_THREAD_MUTEX
+
+ class Request
+ attr_reader :deadline
+
+ def initialize(thread, timeout, exception_class, message)
+ @thread = thread
+ @deadline = GET_TIME.call(Process::CLOCK_MONOTONIC) + timeout
+ @exception_class = exception_class
+ @message = message
+
+ @mutex = Mutex.new
+ @done = false # protected by @mutex
+ end
+
+ def done?
+ @mutex.synchronize do
+ @done
+ end
+ end
+
+ def expired?(now)
+ now >= @deadline
+ end
+
+ def interrupt
+ @mutex.synchronize do
+ unless @done
+ @thread.raise @exception_class, @message
+ @done = true
+ end
+ end
+ end
+
+ def finished
+ @mutex.synchronize do
+ @done = true
+ end
+ end
+ end
+ private_constant :Request
+
+ def self.create_timeout_thread
+ watcher = Thread.new do
+ requests = []
+ while true
+ until QUEUE.empty? and !requests.empty? # wait to have at least one request
+ req = QUEUE.pop
+ requests << req unless req.done?
+ end
+ closest_deadline = requests.min_by(&:deadline).deadline
+
+ now = 0.0
+ QUEUE_MUTEX.synchronize do
+ while (now = GET_TIME.call(Process::CLOCK_MONOTONIC)) < closest_deadline and QUEUE.empty?
+ CONDVAR.wait(QUEUE_MUTEX, closest_deadline - now)
+ end
+ end
+
+ requests.each do |req|
+ req.interrupt if req.expired?(now)
+ end
+ requests.reject!(&:done?)
+ end
+ end
+ ThreadGroup::Default.add(watcher) unless watcher.group.enclosed?
+ watcher.name = "Gem::Timeout stdlib thread"
+ watcher.thread_variable_set(:"\0__detached_thread__", true)
+ watcher
+ end
+ private_class_method :create_timeout_thread
+
+ def self.ensure_timeout_thread_created
+ unless @timeout_thread and @timeout_thread.alive?
+ # If the Mutex is already owned we are in a signal handler.
+ # In that case, just return and let the main thread create the @timeout_thread.
+ return if TIMEOUT_THREAD_MUTEX.owned?
+ TIMEOUT_THREAD_MUTEX.synchronize do
+ unless @timeout_thread and @timeout_thread.alive?
+ @timeout_thread = create_timeout_thread
+ end
+ end
+ end
+ end
+
+ # We keep a private reference so that time mocking libraries won't break
+ # Gem::Timeout.
+ GET_TIME = Process.method(:clock_gettime)
+ private_constant :GET_TIME
+
+ # :startdoc:
+
+ # Perform an operation in a block, raising an error if it takes longer than
+ # +sec+ seconds to complete.
+ #
+ # +sec+:: Number of seconds to wait for the block to terminate. Any non-negative number
+ # or nil may be used, including Floats to specify fractional seconds. A
+ # value of 0 or +nil+ will execute the block without any timeout.
+ # Any negative number will raise an ArgumentError.
+ # +klass+:: Exception Class to raise if the block fails to terminate
+ # in +sec+ seconds. Omitting will use the default, Gem::Timeout::Error
+ # +message+:: Error message to raise with Exception Class.
+ # Omitting will use the default, "execution expired"
+ #
+ # Returns the result of the block *if* the block completed before
+ # +sec+ seconds, otherwise throws an exception, based on the value of +klass+.
+ #
+ # The exception thrown to terminate the given block cannot be rescued inside
+ # the block unless +klass+ is given explicitly. However, the block can use
+ # ensure to prevent the handling of the exception. For that reason, this
+ # method cannot be relied on to enforce timeouts for untrusted blocks.
+ #
+ # If a scheduler is defined, it will be used to handle the timeout by invoking
+ # Scheduler#timeout_after.
+ #
+ # Note that this is both a method of module Gem::Timeout, so you can <tt>include
+ # Gem::Timeout</tt> into your classes so they have a #timeout method, as well as
+ # a module method, so you can call it directly as Gem::Timeout.timeout().
+ def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
+ return yield(sec) if sec == nil or sec.zero?
+ raise ArgumentError, "Timeout sec must be a non-negative number" if 0 > sec
+
+ message ||= "execution expired"
+
+ if Fiber.respond_to?(:current_scheduler) && (scheduler = Fiber.current_scheduler)&.respond_to?(:timeout_after)
+ return scheduler.timeout_after(sec, klass || Error, message, &block)
+ end
+
+ Gem::Timeout.ensure_timeout_thread_created
+ perform = Proc.new do |exc|
+ request = Request.new(Thread.current, sec, exc, message)
+ QUEUE_MUTEX.synchronize do
+ QUEUE << request
+ CONDVAR.signal
+ end
+ begin
+ return yield(sec)
+ ensure
+ request.finished
+ end
+ end
+
+ if klass
+ perform.call(klass)
+ else
+ Error.handle_timeout(message, &perform)
+ end
+ end
+ module_function :timeout
+end
diff --git a/lib/rubygems/vendor/tsort/lib/tsort.rb b/lib/rubygems/vendor/tsort/lib/tsort.rb
new file mode 100644
index 0000000000..9dd7c09521
--- /dev/null
+++ b/lib/rubygems/vendor/tsort/lib/tsort.rb
@@ -0,0 +1,455 @@
+# frozen_string_literal: true
+
+#--
+# tsort.rb - provides a module for topological sorting and strongly connected components.
+#++
+#
+
+#
+# Gem::TSort implements topological sorting using Tarjan's algorithm for
+# strongly connected components.
+#
+# Gem::TSort is designed to be able to be used with any object which can be
+# interpreted as a directed graph.
+#
+# Gem::TSort requires two methods to interpret an object as a graph,
+# tsort_each_node and tsort_each_child.
+#
+# * tsort_each_node is used to iterate for all nodes over a graph.
+# * tsort_each_child is used to iterate for child nodes of a given node.
+#
+# The equality of nodes are defined by eql? and hash since
+# Gem::TSort uses Hash internally.
+#
+# == A Simple Example
+#
+# The following example demonstrates how to mix the Gem::TSort module into an
+# existing class (in this case, Hash). Here, we're treating each key in
+# the hash as a node in the graph, and so we simply alias the required
+# #tsort_each_node method to Hash's #each_key method. For each key in the
+# hash, the associated value is an array of the node's child nodes. This
+# choice in turn leads to our implementation of the required #tsort_each_child
+# method, which fetches the array of child nodes and then iterates over that
+# array using the user-supplied block.
+#
+# require 'rubygems/vendor/tsort/lib/tsort'
+#
+# class Hash
+# include Gem::TSort
+# alias tsort_each_node each_key
+# def tsort_each_child(node, &block)
+# fetch(node).each(&block)
+# end
+# end
+#
+# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
+# #=> [3, 2, 1, 4]
+#
+# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
+# #=> [[4], [2, 3], [1]]
+#
+# == A More Realistic Example
+#
+# A very simple `make' like tool can be implemented as follows:
+#
+# require 'rubygems/vendor/tsort/lib/tsort'
+#
+# class Make
+# def initialize
+# @dep = {}
+# @dep.default = []
+# end
+#
+# def rule(outputs, inputs=[], &block)
+# triple = [outputs, inputs, block]
+# outputs.each {|f| @dep[f] = [triple]}
+# @dep[triple] = inputs
+# end
+#
+# def build(target)
+# each_strongly_connected_component_from(target) {|ns|
+# if ns.length != 1
+# fs = ns.delete_if {|n| Array === n}
+# raise Gem::TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
+# end
+# n = ns.first
+# if Array === n
+# outputs, inputs, block = n
+# inputs_time = inputs.map {|f| File.mtime f}.max
+# begin
+# outputs_time = outputs.map {|f| File.mtime f}.min
+# rescue Errno::ENOENT
+# outputs_time = nil
+# end
+# if outputs_time == nil ||
+# inputs_time != nil && outputs_time <= inputs_time
+# sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
+# block.call
+# end
+# end
+# }
+# end
+#
+# def tsort_each_child(node, &block)
+# @dep[node].each(&block)
+# end
+# include Gem::TSort
+# end
+#
+# def command(arg)
+# print arg, "\n"
+# system arg
+# end
+#
+# m = Make.new
+# m.rule(%w[t1]) { command 'date > t1' }
+# m.rule(%w[t2]) { command 'date > t2' }
+# m.rule(%w[t3]) { command 'date > t3' }
+# m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
+# m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' }
+# m.build('t5')
+#
+# == Bugs
+#
+# * 'tsort.rb' is wrong name because this library uses
+# Tarjan's algorithm for strongly connected components.
+# Although 'strongly_connected_components.rb' is correct but too long.
+#
+# == References
+#
+# R. E. Tarjan, "Depth First Search and Linear Graph Algorithms",
+# <em>SIAM Journal on Computing</em>, Vol. 1, No. 2, pp. 146-160, June 1972.
+#
+
+module Gem::TSort
+
+ VERSION = "0.2.0"
+
+ class Cyclic < StandardError
+ end
+
+ # Returns a topologically sorted array of nodes.
+ # The array is sorted from children to parents, i.e.
+ # the first element has no child and the last node has no parent.
+ #
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
+ #
+ # class G
+ # include Gem::TSort
+ # def initialize(g)
+ # @g = g
+ # end
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
+ # def tsort_each_node(&b) @g.each_key(&b) end
+ # end
+ #
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
+ # p graph.tsort #=> [4, 2, 3, 1]
+ #
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
+ # p graph.tsort # raises Gem::TSort::Cyclic
+ #
+ def tsort
+ each_node = method(:tsort_each_node)
+ each_child = method(:tsort_each_child)
+ Gem::TSort.tsort(each_node, each_child)
+ end
+
+ # Returns a topologically sorted array of nodes.
+ # The array is sorted from children to parents, i.e.
+ # the first element has no child and the last node has no parent.
+ #
+ # The graph is represented by _each_node_ and _each_child_.
+ # _each_node_ should have +call+ method which yields for each node in the graph.
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
+ #
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
+ #
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # p Gem::TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1]
+ #
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # p Gem::TSort.tsort(each_node, each_child) # raises Gem::TSort::Cyclic
+ #
+ def self.tsort(each_node, each_child)
+ tsort_each(each_node, each_child).to_a
+ end
+
+ # The iterator version of the #tsort method.
+ # <tt><em>obj</em>.tsort_each</tt> is similar to <tt><em>obj</em>.tsort.each</tt>, but
+ # modification of _obj_ during the iteration may lead to unexpected results.
+ #
+ # #tsort_each returns +nil+.
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
+ #
+ # class G
+ # include Gem::TSort
+ # def initialize(g)
+ # @g = g
+ # end
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
+ # def tsort_each_node(&b) @g.each_key(&b) end
+ # end
+ #
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
+ # graph.tsort_each {|n| p n }
+ # #=> 4
+ # # 2
+ # # 3
+ # # 1
+ #
+ def tsort_each(&block) # :yields: node
+ each_node = method(:tsort_each_node)
+ each_child = method(:tsort_each_child)
+ Gem::TSort.tsort_each(each_node, each_child, &block)
+ end
+
+ # The iterator version of the Gem::TSort.tsort method.
+ #
+ # The graph is represented by _each_node_ and _each_child_.
+ # _each_node_ should have +call+ method which yields for each node in the graph.
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
+ #
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # Gem::TSort.tsort_each(each_node, each_child) {|n| p n }
+ # #=> 4
+ # # 2
+ # # 3
+ # # 1
+ #
+ def self.tsort_each(each_node, each_child) # :yields: node
+ return to_enum(__method__, each_node, each_child) unless block_given?
+
+ each_strongly_connected_component(each_node, each_child) {|component|
+ if component.size == 1
+ yield component.first
+ else
+ raise Cyclic.new("topological sort failed: #{component.inspect}")
+ end
+ }
+ end
+
+ # Returns strongly connected components as an array of arrays of nodes.
+ # The array is sorted from children to parents.
+ # Each elements of the array represents a strongly connected component.
+ #
+ # class G
+ # include Gem::TSort
+ # def initialize(g)
+ # @g = g
+ # end
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
+ # def tsort_each_node(&b) @g.each_key(&b) end
+ # end
+ #
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
+ # p graph.strongly_connected_components #=> [[4], [2], [3], [1]]
+ #
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
+ # p graph.strongly_connected_components #=> [[4], [2, 3], [1]]
+ #
+ def strongly_connected_components
+ each_node = method(:tsort_each_node)
+ each_child = method(:tsort_each_child)
+ Gem::TSort.strongly_connected_components(each_node, each_child)
+ end
+
+ # Returns strongly connected components as an array of arrays of nodes.
+ # The array is sorted from children to parents.
+ # Each elements of the array represents a strongly connected component.
+ #
+ # The graph is represented by _each_node_ and _each_child_.
+ # _each_node_ should have +call+ method which yields for each node in the graph.
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
+ #
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # p Gem::TSort.strongly_connected_components(each_node, each_child)
+ # #=> [[4], [2], [3], [1]]
+ #
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # p Gem::TSort.strongly_connected_components(each_node, each_child)
+ # #=> [[4], [2, 3], [1]]
+ #
+ def self.strongly_connected_components(each_node, each_child)
+ each_strongly_connected_component(each_node, each_child).to_a
+ end
+
+ # The iterator version of the #strongly_connected_components method.
+ # <tt><em>obj</em>.each_strongly_connected_component</tt> is similar to
+ # <tt><em>obj</em>.strongly_connected_components.each</tt>, but
+ # modification of _obj_ during the iteration may lead to unexpected results.
+ #
+ # #each_strongly_connected_component returns +nil+.
+ #
+ # class G
+ # include Gem::TSort
+ # def initialize(g)
+ # @g = g
+ # end
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
+ # def tsort_each_node(&b) @g.each_key(&b) end
+ # end
+ #
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
+ # graph.each_strongly_connected_component {|scc| p scc }
+ # #=> [4]
+ # # [2]
+ # # [3]
+ # # [1]
+ #
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
+ # graph.each_strongly_connected_component {|scc| p scc }
+ # #=> [4]
+ # # [2, 3]
+ # # [1]
+ #
+ def each_strongly_connected_component(&block) # :yields: nodes
+ each_node = method(:tsort_each_node)
+ each_child = method(:tsort_each_child)
+ Gem::TSort.each_strongly_connected_component(each_node, each_child, &block)
+ end
+
+ # The iterator version of the Gem::TSort.strongly_connected_components method.
+ #
+ # The graph is represented by _each_node_ and _each_child_.
+ # _each_node_ should have +call+ method which yields for each node in the graph.
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
+ #
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
+ # #=> [4]
+ # # [2]
+ # # [3]
+ # # [1]
+ #
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
+ # each_node = lambda {|&b| g.each_key(&b) }
+ # each_child = lambda {|n, &b| g[n].each(&b) }
+ # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
+ # #=> [4]
+ # # [2, 3]
+ # # [1]
+ #
+ def self.each_strongly_connected_component(each_node, each_child) # :yields: nodes
+ return to_enum(__method__, each_node, each_child) unless block_given?
+
+ id_map = {}
+ stack = []
+ each_node.call {|node|
+ unless id_map.include? node
+ each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
+ yield c
+ }
+ end
+ }
+ nil
+ end
+
+ # Iterates over strongly connected component in the subgraph reachable from
+ # _node_.
+ #
+ # Return value is unspecified.
+ #
+ # #each_strongly_connected_component_from doesn't call #tsort_each_node.
+ #
+ # class G
+ # include Gem::TSort
+ # def initialize(g)
+ # @g = g
+ # end
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
+ # def tsort_each_node(&b) @g.each_key(&b) end
+ # end
+ #
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
+ # graph.each_strongly_connected_component_from(2) {|scc| p scc }
+ # #=> [4]
+ # # [2]
+ #
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
+ # graph.each_strongly_connected_component_from(2) {|scc| p scc }
+ # #=> [4]
+ # # [2, 3]
+ #
+ def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) # :yields: nodes
+ Gem::TSort.each_strongly_connected_component_from(node, method(:tsort_each_child), id_map, stack, &block)
+ end
+
+ # Iterates over strongly connected components in a graph.
+ # The graph is represented by _node_ and _each_child_.
+ #
+ # _node_ is the first node.
+ # _each_child_ should have +call+ method which takes a node argument
+ # and yields for each child node.
+ #
+ # Return value is unspecified.
+ #
+ # #Gem::TSort.each_strongly_connected_component_from is a class method and
+ # it doesn't need a class to represent a graph which includes Gem::TSort.
+ #
+ # graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
+ # each_child = lambda {|n, &b| graph[n].each(&b) }
+ # Gem::TSort.each_strongly_connected_component_from(1, each_child) {|scc|
+ # p scc
+ # }
+ # #=> [4]
+ # # [2, 3]
+ # # [1]
+ #
+ def self.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
+ return to_enum(__method__, node, each_child, id_map, stack) unless block_given?
+
+ minimum_id = node_id = id_map[node] = id_map.size
+ stack_length = stack.length
+ stack << node
+
+ each_child.call(node) {|child|
+ if id_map.include? child
+ child_id = id_map[child]
+ minimum_id = child_id if child_id && child_id < minimum_id
+ else
+ sub_minimum_id =
+ each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
+ yield c
+ }
+ minimum_id = sub_minimum_id if sub_minimum_id < minimum_id
+ end
+ }
+
+ if node_id == minimum_id
+ component = stack.slice!(stack_length .. -1)
+ component.each {|n| id_map[n] = nil}
+ yield component
+ end
+
+ minimum_id
+ end
+
+ # Should be implemented by a extended class.
+ #
+ # #tsort_each_node is used to iterate for all nodes over a graph.
+ #
+ def tsort_each_node # :yields: node
+ raise NotImplementedError.new
+ end
+
+ # Should be implemented by a extended class.
+ #
+ # #tsort_each_child is used to iterate for child nodes of _node_.
+ #
+ def tsort_each_child(node) # :yields: child
+ raise NotImplementedError.new
+ end
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri.rb b/lib/rubygems/vendor/uri/lib/uri.rb
new file mode 100644
index 0000000000..4691b122b2
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri.rb
@@ -0,0 +1,104 @@
+# frozen_string_literal: false
+# Gem::URI is a module providing classes to handle Uniform Resource Identifiers
+# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
+#
+# == Features
+#
+# * Uniform way of handling URIs.
+# * Flexibility to introduce custom Gem::URI schemes.
+# * Flexibility to have an alternate Gem::URI::Parser (or just different patterns
+# and regexp's).
+#
+# == Basic example
+#
+# require 'rubygems/vendor/uri/lib/uri'
+#
+# uri = Gem::URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
+# #=> #<Gem::URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
+#
+# uri.scheme #=> "http"
+# uri.host #=> "foo.com"
+# uri.path #=> "/posts"
+# uri.query #=> "id=30&limit=5"
+# uri.fragment #=> "time=1305298413"
+#
+# uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
+#
+# == Adding custom URIs
+#
+# module Gem::URI
+# class RSYNC < Generic
+# DEFAULT_PORT = 873
+# end
+# register_scheme 'RSYNC', RSYNC
+# end
+# #=> Gem::URI::RSYNC
+#
+# Gem::URI.scheme_list
+# #=> {"FILE"=>Gem::URI::File, "FTP"=>Gem::URI::FTP, "HTTP"=>Gem::URI::HTTP,
+# # "HTTPS"=>Gem::URI::HTTPS, "LDAP"=>Gem::URI::LDAP, "LDAPS"=>Gem::URI::LDAPS,
+# # "MAILTO"=>Gem::URI::MailTo, "RSYNC"=>Gem::URI::RSYNC}
+#
+# uri = Gem::URI("rsync://rsync.foo.com")
+# #=> #<Gem::URI::RSYNC rsync://rsync.foo.com>
+#
+# == RFC References
+#
+# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
+#
+# Here is a list of all related RFC's:
+# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
+# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
+# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
+# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
+# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
+# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
+# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
+# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
+#
+# == Class tree
+#
+# - Gem::URI::Generic (in uri/generic.rb)
+# - Gem::URI::File - (in uri/file.rb)
+# - Gem::URI::FTP - (in uri/ftp.rb)
+# - Gem::URI::HTTP - (in uri/http.rb)
+# - Gem::URI::HTTPS - (in uri/https.rb)
+# - Gem::URI::LDAP - (in uri/ldap.rb)
+# - Gem::URI::LDAPS - (in uri/ldaps.rb)
+# - Gem::URI::MailTo - (in uri/mailto.rb)
+# - Gem::URI::Parser - (in uri/common.rb)
+# - Gem::URI::REGEXP - (in uri/common.rb)
+# - Gem::URI::REGEXP::PATTERN - (in uri/common.rb)
+# - Gem::URI::Util - (in uri/common.rb)
+# - Gem::URI::Error - (in uri/common.rb)
+# - Gem::URI::InvalidURIError - (in uri/common.rb)
+# - Gem::URI::InvalidComponentError - (in uri/common.rb)
+# - Gem::URI::BadURIError - (in uri/common.rb)
+#
+# == Copyright Info
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# Documentation::
+# Akira Yamada <akira@ruby-lang.org>
+# Dmitry V. Sabanin <sdmitry@lrn.ru>
+# Vincent Batts <vbatts@hashbangbash.com>
+# License::
+# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
+# You can redistribute it and/or modify it under the same term as Ruby.
+#
+
+module Gem::URI
+end
+
+require_relative 'uri/version'
+require_relative 'uri/common'
+require_relative 'uri/generic'
+require_relative 'uri/file'
+require_relative 'uri/ftp'
+require_relative 'uri/http'
+require_relative 'uri/https'
+require_relative 'uri/ldap'
+require_relative 'uri/ldaps'
+require_relative 'uri/mailto'
+require_relative 'uri/ws'
+require_relative 'uri/wss'
diff --git a/lib/rubygems/vendor/uri/lib/uri/common.rb b/lib/rubygems/vendor/uri/lib/uri/common.rb
new file mode 100644
index 0000000000..e9bdfa6a07
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/common.rb
@@ -0,0 +1,922 @@
+# frozen_string_literal: true
+#--
+# = uri/common.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License::
+# You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative "rfc2396_parser"
+require_relative "rfc3986_parser"
+
+module Gem::URI
+ # The default parser instance for RFC 2396.
+ RFC2396_PARSER = RFC2396_Parser.new
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
+
+ # The default parser instance for RFC 3986.
+ RFC3986_PARSER = RFC3986_Parser.new
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
+
+ # The default parser instance.
+ DEFAULT_PARSER = RFC3986_PARSER
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
+
+ # Set the default parser instance.
+ def self.parser=(parser = RFC3986_PARSER)
+ remove_const(:Parser) if defined?(::Gem::URI::Parser)
+ const_set("Parser", parser.class)
+
+ remove_const(:PARSER) if defined?(::Gem::URI::PARSER)
+ const_set("PARSER", parser)
+
+ remove_const(:REGEXP) if defined?(::Gem::URI::REGEXP)
+ remove_const(:PATTERN) if defined?(::Gem::URI::PATTERN)
+ if Parser == RFC2396_Parser
+ const_set("REGEXP", Gem::URI::RFC2396_REGEXP)
+ const_set("PATTERN", Gem::URI::RFC2396_REGEXP::PATTERN)
+ end
+
+ Parser.new.regexp.each_pair do |sym, str|
+ remove_const(sym) if const_defined?(sym, false)
+ const_set(sym, str)
+ end
+ end
+ self.parser = RFC3986_PARSER
+
+ def self.const_missing(const) # :nodoc:
+ if const == :REGEXP
+ warn "Gem::URI::REGEXP is obsolete. Use Gem::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
+ Gem::URI::RFC2396_REGEXP
+ elsif value = RFC2396_PARSER.regexp[const]
+ warn "Gem::URI::#{const} is obsolete. Use Gem::URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
+ value
+ elsif value = RFC2396_Parser.const_get(const)
+ warn "Gem::URI::#{const} is obsolete. Use Gem::URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
+ value
+ else
+ super
+ end
+ end
+
+ module Util # :nodoc:
+ def make_components_hash(klass, array_hash)
+ tmp = {}
+ if array_hash.kind_of?(Array) &&
+ array_hash.size == klass.component.size - 1
+ klass.component[1..-1].each_index do |i|
+ begin
+ tmp[klass.component[i + 1]] = array_hash[i].clone
+ rescue TypeError
+ tmp[klass.component[i + 1]] = array_hash[i]
+ end
+ end
+
+ elsif array_hash.kind_of?(Hash)
+ array_hash.each do |key, value|
+ begin
+ tmp[key] = value.clone
+ rescue TypeError
+ tmp[key] = value
+ end
+ end
+ else
+ raise ArgumentError,
+ "expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
+ end
+ tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
+
+ return tmp
+ end
+ module_function :make_components_hash
+ end
+
+ module Schemes # :nodoc:
+ class << self
+ ReservedChars = ".+-"
+ EscapedChars = "\u01C0\u01C1\u01C2"
+ # Use Lo category chars as escaped chars for TruffleRuby, which
+ # does not allow Symbol categories as identifiers.
+
+ def escape(name)
+ unless name and name.ascii_only?
+ return nil
+ end
+ name.upcase.tr(ReservedChars, EscapedChars)
+ end
+
+ def unescape(name)
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
+ end
+
+ def find(name)
+ const_get(name, false) if name and const_defined?(name, false)
+ end
+
+ def register(name, klass)
+ unless scheme = escape(name)
+ raise ArgumentError, "invalid character as scheme - #{name}"
+ end
+ const_set(scheme, klass)
+ end
+
+ def list
+ constants.map { |name|
+ [unescape(name.to_s), const_get(name)]
+ }.to_h
+ end
+ end
+ end
+ private_constant :Schemes
+
+ # Registers the given +klass+ as the class to be instantiated
+ # when parsing a \Gem::URI with the given +scheme+:
+ #
+ # Gem::URI.register_scheme('MS_SEARCH', Gem::URI::Generic) # => Gem::URI::Generic
+ # Gem::URI.scheme_list['MS_SEARCH'] # => Gem::URI::Generic
+ #
+ # Note that after calling String#upcase on +scheme+, it must be a valid
+ # constant name.
+ def self.register_scheme(scheme, klass)
+ Schemes.register(scheme, klass)
+ end
+
+ # Returns a hash of the defined schemes:
+ #
+ # Gem::URI.scheme_list
+ # # =>
+ # {"MAILTO"=>Gem::URI::MailTo,
+ # "LDAPS"=>Gem::URI::LDAPS,
+ # "WS"=>Gem::URI::WS,
+ # "HTTP"=>Gem::URI::HTTP,
+ # "HTTPS"=>Gem::URI::HTTPS,
+ # "LDAP"=>Gem::URI::LDAP,
+ # "FILE"=>Gem::URI::File,
+ # "FTP"=>Gem::URI::FTP}
+ #
+ # Related: Gem::URI.register_scheme.
+ def self.scheme_list
+ Schemes.list
+ end
+
+ # :stopdoc:
+ INITIAL_SCHEMES = scheme_list
+ private_constant :INITIAL_SCHEMES
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
+ # :startdoc:
+
+ # Returns a new object constructed from the given +scheme+, +arguments+,
+ # and +default+:
+ #
+ # - The new object is an instance of <tt>Gem::URI.scheme_list[scheme.upcase]</tt>.
+ # - The object is initialized by calling the class initializer
+ # using +scheme+ and +arguments+.
+ # See Gem::URI::Generic.new.
+ #
+ # Examples:
+ #
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
+ # Gem::URI.for('https', *values)
+ # # => #<Gem::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Gem::URI.for('foo', *values, default: Gem::URI::HTTP)
+ # # => #<Gem::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ #
+ def self.for(scheme, *arguments, default: Generic)
+ const_name = Schemes.escape(scheme)
+
+ uri_class = INITIAL_SCHEMES[const_name]
+ uri_class ||= Schemes.find(const_name)
+ uri_class ||= default
+
+ return uri_class.new(scheme, *arguments)
+ end
+
+ #
+ # Base class for all Gem::URI exceptions.
+ #
+ class Error < StandardError; end
+ #
+ # Not a Gem::URI.
+ #
+ class InvalidURIError < Error; end
+ #
+ # Not a Gem::URI component.
+ #
+ class InvalidComponentError < Error; end
+ #
+ # Gem::URI is valid, bad usage is not.
+ #
+ class BadURIError < Error; end
+
+ # Returns a 9-element array representing the parts of the \Gem::URI
+ # formed from the string +uri+;
+ # each array element is a string or +nil+:
+ #
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
+ # values = Gem::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # names.zip(values)
+ # # =>
+ # [["scheme", "https"],
+ # ["userinfo", "john.doe"],
+ # ["host", "www.example.com"],
+ # ["port", "123"],
+ # ["registry", nil],
+ # ["path", "/forum/questions/"],
+ # ["opaque", nil],
+ # ["query", "tag=networking&order=newest"],
+ # ["fragment", "top"]]
+ #
+ def self.split(uri)
+ PARSER.split(uri)
+ end
+
+ # Returns a new \Gem::URI object constructed from the given string +uri+:
+ #
+ # Gem::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Gem::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Gem::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Gem::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ #
+ # It's recommended to first Gem::URI::RFC2396_PARSER.escape string +uri+
+ # if it may contain invalid Gem::URI characters.
+ #
+ def self.parse(uri)
+ PARSER.parse(uri)
+ end
+
+ # Merges the given Gem::URI strings +str+
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
+ #
+ # Each string in +str+ is converted to an
+ # {RFC3986 Gem::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
+ #
+ # Examples:
+ #
+ # Gem::URI.join("http://example.com/","main.rbx")
+ # # => #<Gem::URI::HTTP http://example.com/main.rbx>
+ #
+ # Gem::URI.join('http://example.com', 'foo')
+ # # => #<Gem::URI::HTTP http://example.com/foo>
+ #
+ # Gem::URI.join('http://example.com', '/foo', '/bar')
+ # # => #<Gem::URI::HTTP http://example.com/bar>
+ #
+ # Gem::URI.join('http://example.com', '/foo', 'bar')
+ # # => #<Gem::URI::HTTP http://example.com/bar>
+ #
+ # Gem::URI.join('http://example.com', '/foo/', 'bar')
+ # # => #<Gem::URI::HTTP http://example.com/foo/bar>
+ #
+ def self.join(*str)
+ DEFAULT_PARSER.join(*str)
+ end
+
+ #
+ # == Synopsis
+ #
+ # Gem::URI::extract(str[, schemes][,&blk])
+ #
+ # == Args
+ #
+ # +str+::
+ # String to extract URIs from.
+ # +schemes+::
+ # Limit Gem::URI matching to specific schemes.
+ #
+ # == Description
+ #
+ # Extracts URIs from a string. If block given, iterates through all matched URIs.
+ # Returns nil if block given or array with matches.
+ #
+ # == Usage
+ #
+ # require "rubygems/vendor/uri/lib/uri"
+ #
+ # Gem::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
+ #
+ def self.extract(str, schemes = nil, &block) # :nodoc:
+ warn "Gem::URI.extract is obsolete", uplevel: 1 if $VERBOSE
+ PARSER.extract(str, schemes, &block)
+ end
+
+ #
+ # == Synopsis
+ #
+ # Gem::URI::regexp([match_schemes])
+ #
+ # == Args
+ #
+ # +match_schemes+::
+ # Array of schemes. If given, resulting regexp matches to URIs
+ # whose scheme is one of the match_schemes.
+ #
+ # == Description
+ #
+ # Returns a Regexp object which matches to Gem::URI-like strings.
+ # The Regexp object returned by this method includes arbitrary
+ # number of capture group (parentheses). Never rely on its number.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # # extract first Gem::URI from html_string
+ # html_string.slice(Gem::URI.regexp)
+ #
+ # # remove ftp URIs
+ # html_string.sub(Gem::URI.regexp(['ftp']), '')
+ #
+ # # You should not rely on the number of parentheses
+ # html_string.scan(Gem::URI.regexp) do |*matches|
+ # p $&
+ # end
+ #
+ def self.regexp(schemes = nil)# :nodoc:
+ warn "Gem::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
+ PARSER.make_regexp(schemes)
+ end
+
+ TBLENCWWWCOMP_ = {} # :nodoc:
+ 256.times do |i|
+ TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
+ end
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc:
+ TBLENCWWWCOMP_[' '] = '+'
+ TBLENCWWWCOMP_.freeze
+ TBLDECWWWCOMP_ = {} # :nodoc:
+ 256.times do |i|
+ h, l = i>>4, i&15
+ TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
+ TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
+ TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
+ TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
+ end
+ TBLDECWWWCOMP_['+'] = ' '
+ TBLDECWWWCOMP_.freeze
+
+ # Returns a URL-encoded string derived from the given string +str+.
+ #
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
+ # - Any other character to "percent notation";
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
+ #
+ # Encoding:
+ #
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
+ # (with suitable character replacements),
+ # and then to encoding +enc+.
+ #
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
+ #
+ # Related: Gem::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
+ def self.encode_www_form_component(str, enc=nil)
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
+ end
+
+ # Returns a string decoded from the given \URL-encoded string +str+.
+ #
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
+ #
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # Gem::URI.decode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
+ # - Each "percent notation" to an ASCII character.
+ #
+ # Example:
+ #
+ # Gem::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
+ # # => "Here are some punctuation characters: ,;?:"
+ #
+ # Related: Gem::URI.decode_uri_component (preserves <tt>'+'</tt>).
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
+ _decode_uri_component(/\+|%\h\h/, str, enc)
+ end
+
+ # Like Gem::URI.encode_www_form_component, except that <tt>' '</tt> (space)
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
+ def self.encode_uri_component(str, enc=nil)
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
+ end
+
+ # Like Gem::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
+ _decode_uri_component(/%\h\h/, str, enc)
+ end
+
+ # Returns a string derived from the given string +str+ with
+ # Gem::URI-encoded characters matching +regexp+ according to +table+.
+ def self._encode_uri_component(regexp, table, str, enc)
+ str = str.to_s.dup
+ if str.encoding != Encoding::ASCII_8BIT
+ if enc && enc != Encoding::ASCII_8BIT
+ str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
+ str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
+ end
+ str.force_encoding(Encoding::ASCII_8BIT)
+ end
+ str.gsub!(regexp, table)
+ str.force_encoding(Encoding::US_ASCII)
+ end
+ private_class_method :_encode_uri_component
+
+ # Returns a string decoding characters matching +regexp+ from the
+ # given \URL-encoded string +str+.
+ def self._decode_uri_component(regexp, str, enc)
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
+ end
+ private_class_method :_decode_uri_component
+
+ # Returns a URL-encoded string derived from the given
+ # {Enumerable}[rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes]
+ # +enum+.
+ #
+ # The result is suitable for use as form data
+ # for an \HTTP request whose <tt>Content-Type</tt> is
+ # <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned string consists of the elements of +enum+,
+ # each converted to one or more URL-encoded strings,
+ # and all joined with character <tt>'&'</tt>.
+ #
+ # Simple examples:
+ #
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
+ # # => "foo=0&bar=1&baz=2"
+ # Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
+ #
+ # The returned string is formed using method Gem::URI.encode_www_form_component,
+ # which converts certain characters:
+ #
+ # Gem::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
+ #
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
+ #
+ # - If +ele+ is an array of two or more elements,
+ # the field is formed from its first two elements
+ # (and any additional elements are ignored):
+ #
+ # name = Gem::URI.encode_www_form_component(ele[0], enc)
+ # value = Gem::URI.encode_www_form_component(ele[1], enc)
+ # "#{name}=#{value}"
+ #
+ # Examples:
+ #
+ # Gem::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
+ # # => "foo=bar&baz=bat"
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
+ # # => "foo=0&bar=baz"
+ #
+ # - If +ele+ is an array of one element,
+ # the field is formed from <tt>ele[0]</tt>:
+ #
+ # Gem::URI.encode_www_form_component(ele[0])
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form([['foo'], [:bar], [0]])
+ # # => "foo&bar&0"
+ #
+ # - Otherwise the field is formed from +ele+:
+ #
+ # Gem::URI.encode_www_form_component(ele)
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form(['foo', :bar, 0])
+ # # => "foo&bar&0"
+ #
+ # The elements of an Array-like +enum+ may be mixture:
+ #
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
+ # # => "foo=0&bar=1&baz&bat"
+ #
+ # When +enum+ is Hash-like,
+ # each +key+/+value+ pair is converted to one or more fields:
+ #
+ # - If +value+ is
+ # {Array-convertible}[rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects],
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
+ #
+ # name = Gem::URI.encode_www_form_component(key, enc)
+ # value = Gem::URI.encode_www_form_component(ele, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
+ #
+ # - Otherwise, +key+ and +value+ are paired to form a field:
+ #
+ # name = Gem::URI.encode_www_form_component(key, enc)
+ # value = Gem::URI.encode_www_form_component(value, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
+ #
+ # The elements of a Hash-like +enum+ may be mixture:
+ #
+ # Gem::URI.encode_www_form({foo: [0, 1], bar: 2})
+ # # => "foo=0&foo=1&bar=2"
+ #
+ def self.encode_www_form(enum, enc=nil)
+ enum.map do |k,v|
+ if v.nil?
+ encode_www_form_component(k, enc)
+ elsif v.respond_to?(:to_ary)
+ v.to_ary.map do |w|
+ str = encode_www_form_component(k, enc)
+ unless w.nil?
+ str << '='
+ str << encode_www_form_component(w, enc)
+ end
+ end.join('&')
+ else
+ str = encode_www_form_component(k, enc)
+ str << '='
+ str << encode_www_form_component(v, enc)
+ end
+ end.join('&')
+ end
+
+ # Returns name/value pairs derived from the given string +str+,
+ # which must be an ASCII string.
+ #
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned data is an array of 2-element subarrays;
+ # each subarray is a name/value pair (both are strings).
+ # Each returned string has encoding +enc+,
+ # and has had invalid characters removed via
+ # {String#scrub}[rdoc-ref:String#scrub].
+ #
+ # A simple example:
+ #
+ # Gem::URI.decode_www_form('foo=0&bar=1&baz')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
+ #
+ # The returned strings have certain conversions,
+ # similar to those performed in Gem::URI.decode_www_form_component:
+ #
+ # Gem::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
+ #
+ # The given string may contain consecutive separators:
+ #
+ # Gem::URI.decode_www_form('foo=0&&bar=1&&baz=2')
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
+ #
+ # A different separator may be specified:
+ #
+ # Gem::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
+ #
+ def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
+ raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
+ ary = []
+ return ary if str.empty?
+ enc = Encoding.find(enc)
+ str.b.each_line(separator) do |string|
+ string.chomp!(separator)
+ key, sep, val = string.partition('=')
+ if isindex
+ if sep.empty?
+ val = key
+ key = +''
+ end
+ isindex = false
+ end
+
+ if use__charset_ and key == '_charset_' and e = get_encoding(val)
+ enc = e
+ use__charset_ = false
+ end
+
+ key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
+ if val
+ val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
+ else
+ val = +''
+ end
+
+ ary << [key, val]
+ end
+ ary.each do |k, v|
+ k.force_encoding(enc)
+ k.scrub!
+ v.force_encoding(enc)
+ v.scrub!
+ end
+ ary
+ end
+
+ private
+=begin command for WEB_ENCODINGS_
+ curl https://encoding.spec.whatwg.org/encodings.json|
+ ruby -rjson -e 'H={}
+ h={
+ "shift_jis"=>"Windows-31J",
+ "euc-jp"=>"cp51932",
+ "iso-2022-jp"=>"cp50221",
+ "x-mac-cyrillic"=>"macCyrillic",
+ }
+ JSON($<.read).map{|x|x["encodings"]}.flatten.each{|x|
+ Encoding.find(n=h.fetch(n=x["name"].downcase,n))rescue next
+ x["labels"].each{|y|H[y]=n}
+ }
+ puts "{"
+ H.each{|k,v|puts %[ #{k.dump}=>#{v.dump},]}
+ puts "}"
+'
+=end
+ WEB_ENCODINGS_ = {
+ "unicode-1-1-utf-8"=>"utf-8",
+ "utf-8"=>"utf-8",
+ "utf8"=>"utf-8",
+ "866"=>"ibm866",
+ "cp866"=>"ibm866",
+ "csibm866"=>"ibm866",
+ "ibm866"=>"ibm866",
+ "csisolatin2"=>"iso-8859-2",
+ "iso-8859-2"=>"iso-8859-2",
+ "iso-ir-101"=>"iso-8859-2",
+ "iso8859-2"=>"iso-8859-2",
+ "iso88592"=>"iso-8859-2",
+ "iso_8859-2"=>"iso-8859-2",
+ "iso_8859-2:1987"=>"iso-8859-2",
+ "l2"=>"iso-8859-2",
+ "latin2"=>"iso-8859-2",
+ "csisolatin3"=>"iso-8859-3",
+ "iso-8859-3"=>"iso-8859-3",
+ "iso-ir-109"=>"iso-8859-3",
+ "iso8859-3"=>"iso-8859-3",
+ "iso88593"=>"iso-8859-3",
+ "iso_8859-3"=>"iso-8859-3",
+ "iso_8859-3:1988"=>"iso-8859-3",
+ "l3"=>"iso-8859-3",
+ "latin3"=>"iso-8859-3",
+ "csisolatin4"=>"iso-8859-4",
+ "iso-8859-4"=>"iso-8859-4",
+ "iso-ir-110"=>"iso-8859-4",
+ "iso8859-4"=>"iso-8859-4",
+ "iso88594"=>"iso-8859-4",
+ "iso_8859-4"=>"iso-8859-4",
+ "iso_8859-4:1988"=>"iso-8859-4",
+ "l4"=>"iso-8859-4",
+ "latin4"=>"iso-8859-4",
+ "csisolatincyrillic"=>"iso-8859-5",
+ "cyrillic"=>"iso-8859-5",
+ "iso-8859-5"=>"iso-8859-5",
+ "iso-ir-144"=>"iso-8859-5",
+ "iso8859-5"=>"iso-8859-5",
+ "iso88595"=>"iso-8859-5",
+ "iso_8859-5"=>"iso-8859-5",
+ "iso_8859-5:1988"=>"iso-8859-5",
+ "arabic"=>"iso-8859-6",
+ "asmo-708"=>"iso-8859-6",
+ "csiso88596e"=>"iso-8859-6",
+ "csiso88596i"=>"iso-8859-6",
+ "csisolatinarabic"=>"iso-8859-6",
+ "ecma-114"=>"iso-8859-6",
+ "iso-8859-6"=>"iso-8859-6",
+ "iso-8859-6-e"=>"iso-8859-6",
+ "iso-8859-6-i"=>"iso-8859-6",
+ "iso-ir-127"=>"iso-8859-6",
+ "iso8859-6"=>"iso-8859-6",
+ "iso88596"=>"iso-8859-6",
+ "iso_8859-6"=>"iso-8859-6",
+ "iso_8859-6:1987"=>"iso-8859-6",
+ "csisolatingreek"=>"iso-8859-7",
+ "ecma-118"=>"iso-8859-7",
+ "elot_928"=>"iso-8859-7",
+ "greek"=>"iso-8859-7",
+ "greek8"=>"iso-8859-7",
+ "iso-8859-7"=>"iso-8859-7",
+ "iso-ir-126"=>"iso-8859-7",
+ "iso8859-7"=>"iso-8859-7",
+ "iso88597"=>"iso-8859-7",
+ "iso_8859-7"=>"iso-8859-7",
+ "iso_8859-7:1987"=>"iso-8859-7",
+ "sun_eu_greek"=>"iso-8859-7",
+ "csiso88598e"=>"iso-8859-8",
+ "csisolatinhebrew"=>"iso-8859-8",
+ "hebrew"=>"iso-8859-8",
+ "iso-8859-8"=>"iso-8859-8",
+ "iso-8859-8-e"=>"iso-8859-8",
+ "iso-ir-138"=>"iso-8859-8",
+ "iso8859-8"=>"iso-8859-8",
+ "iso88598"=>"iso-8859-8",
+ "iso_8859-8"=>"iso-8859-8",
+ "iso_8859-8:1988"=>"iso-8859-8",
+ "visual"=>"iso-8859-8",
+ "csisolatin6"=>"iso-8859-10",
+ "iso-8859-10"=>"iso-8859-10",
+ "iso-ir-157"=>"iso-8859-10",
+ "iso8859-10"=>"iso-8859-10",
+ "iso885910"=>"iso-8859-10",
+ "l6"=>"iso-8859-10",
+ "latin6"=>"iso-8859-10",
+ "iso-8859-13"=>"iso-8859-13",
+ "iso8859-13"=>"iso-8859-13",
+ "iso885913"=>"iso-8859-13",
+ "iso-8859-14"=>"iso-8859-14",
+ "iso8859-14"=>"iso-8859-14",
+ "iso885914"=>"iso-8859-14",
+ "csisolatin9"=>"iso-8859-15",
+ "iso-8859-15"=>"iso-8859-15",
+ "iso8859-15"=>"iso-8859-15",
+ "iso885915"=>"iso-8859-15",
+ "iso_8859-15"=>"iso-8859-15",
+ "l9"=>"iso-8859-15",
+ "iso-8859-16"=>"iso-8859-16",
+ "cskoi8r"=>"koi8-r",
+ "koi"=>"koi8-r",
+ "koi8"=>"koi8-r",
+ "koi8-r"=>"koi8-r",
+ "koi8_r"=>"koi8-r",
+ "koi8-ru"=>"koi8-u",
+ "koi8-u"=>"koi8-u",
+ "dos-874"=>"windows-874",
+ "iso-8859-11"=>"windows-874",
+ "iso8859-11"=>"windows-874",
+ "iso885911"=>"windows-874",
+ "tis-620"=>"windows-874",
+ "windows-874"=>"windows-874",
+ "cp1250"=>"windows-1250",
+ "windows-1250"=>"windows-1250",
+ "x-cp1250"=>"windows-1250",
+ "cp1251"=>"windows-1251",
+ "windows-1251"=>"windows-1251",
+ "x-cp1251"=>"windows-1251",
+ "ansi_x3.4-1968"=>"windows-1252",
+ "ascii"=>"windows-1252",
+ "cp1252"=>"windows-1252",
+ "cp819"=>"windows-1252",
+ "csisolatin1"=>"windows-1252",
+ "ibm819"=>"windows-1252",
+ "iso-8859-1"=>"windows-1252",
+ "iso-ir-100"=>"windows-1252",
+ "iso8859-1"=>"windows-1252",
+ "iso88591"=>"windows-1252",
+ "iso_8859-1"=>"windows-1252",
+ "iso_8859-1:1987"=>"windows-1252",
+ "l1"=>"windows-1252",
+ "latin1"=>"windows-1252",
+ "us-ascii"=>"windows-1252",
+ "windows-1252"=>"windows-1252",
+ "x-cp1252"=>"windows-1252",
+ "cp1253"=>"windows-1253",
+ "windows-1253"=>"windows-1253",
+ "x-cp1253"=>"windows-1253",
+ "cp1254"=>"windows-1254",
+ "csisolatin5"=>"windows-1254",
+ "iso-8859-9"=>"windows-1254",
+ "iso-ir-148"=>"windows-1254",
+ "iso8859-9"=>"windows-1254",
+ "iso88599"=>"windows-1254",
+ "iso_8859-9"=>"windows-1254",
+ "iso_8859-9:1989"=>"windows-1254",
+ "l5"=>"windows-1254",
+ "latin5"=>"windows-1254",
+ "windows-1254"=>"windows-1254",
+ "x-cp1254"=>"windows-1254",
+ "cp1255"=>"windows-1255",
+ "windows-1255"=>"windows-1255",
+ "x-cp1255"=>"windows-1255",
+ "cp1256"=>"windows-1256",
+ "windows-1256"=>"windows-1256",
+ "x-cp1256"=>"windows-1256",
+ "cp1257"=>"windows-1257",
+ "windows-1257"=>"windows-1257",
+ "x-cp1257"=>"windows-1257",
+ "cp1258"=>"windows-1258",
+ "windows-1258"=>"windows-1258",
+ "x-cp1258"=>"windows-1258",
+ "x-mac-cyrillic"=>"macCyrillic",
+ "x-mac-ukrainian"=>"macCyrillic",
+ "chinese"=>"gbk",
+ "csgb2312"=>"gbk",
+ "csiso58gb231280"=>"gbk",
+ "gb2312"=>"gbk",
+ "gb_2312"=>"gbk",
+ "gb_2312-80"=>"gbk",
+ "gbk"=>"gbk",
+ "iso-ir-58"=>"gbk",
+ "x-gbk"=>"gbk",
+ "gb18030"=>"gb18030",
+ "big5"=>"big5",
+ "big5-hkscs"=>"big5",
+ "cn-big5"=>"big5",
+ "csbig5"=>"big5",
+ "x-x-big5"=>"big5",
+ "cseucpkdfmtjapanese"=>"cp51932",
+ "euc-jp"=>"cp51932",
+ "x-euc-jp"=>"cp51932",
+ "csiso2022jp"=>"cp50221",
+ "iso-2022-jp"=>"cp50221",
+ "csshiftjis"=>"Windows-31J",
+ "ms932"=>"Windows-31J",
+ "ms_kanji"=>"Windows-31J",
+ "shift-jis"=>"Windows-31J",
+ "shift_jis"=>"Windows-31J",
+ "sjis"=>"Windows-31J",
+ "windows-31j"=>"Windows-31J",
+ "x-sjis"=>"Windows-31J",
+ "cseuckr"=>"euc-kr",
+ "csksc56011987"=>"euc-kr",
+ "euc-kr"=>"euc-kr",
+ "iso-ir-149"=>"euc-kr",
+ "korean"=>"euc-kr",
+ "ks_c_5601-1987"=>"euc-kr",
+ "ks_c_5601-1989"=>"euc-kr",
+ "ksc5601"=>"euc-kr",
+ "ksc_5601"=>"euc-kr",
+ "windows-949"=>"euc-kr",
+ "utf-16be"=>"utf-16be",
+ "utf-16"=>"utf-16le",
+ "utf-16le"=>"utf-16le",
+ } # :nodoc:
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
+
+ # :nodoc:
+ # return encoding or nil
+ # http://encoding.spec.whatwg.org/#concept-encoding-get
+ def self.get_encoding(label)
+ Encoding.find(WEB_ENCODINGS_[label.to_str.strip.downcase]) rescue nil
+ end
+end # module Gem::URI
+
+module Gem
+
+ #
+ # Returns a \Gem::URI object derived from the given +uri+,
+ # which may be a \Gem::URI string or an existing \Gem::URI object:
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ # # Returns a new Gem::URI.
+ # uri = Gem::URI('http://github.com/ruby/ruby')
+ # # => #<Gem::URI::HTTP http://github.com/ruby/ruby>
+ # # Returns the given Gem::URI.
+ # Gem::URI(uri)
+ # # => #<Gem::URI::HTTP http://github.com/ruby/ruby>
+ #
+ # You must require 'rubygems/vendor/uri/lib/uri' to use this method.
+ #
+ def URI(uri)
+ if uri.is_a?(Gem::URI::Generic)
+ uri
+ elsif uri = String.try_convert(uri)
+ Gem::URI.parse(uri)
+ else
+ raise ArgumentError,
+ "bad argument (expected Gem::URI object or Gem::URI string)"
+ end
+ end
+ module_function :URI
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/file.rb b/lib/rubygems/vendor/uri/lib/uri/file.rb
new file mode 100644
index 0000000000..391c499716
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/file.rb
@@ -0,0 +1,100 @@
+# frozen_string_literal: true
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # The "file" Gem::URI is defined by RFC8089.
+ #
+ class File < Generic
+ # A Default port of nil for Gem::URI::File.
+ DEFAULT_PORT = nil
+
+ #
+ # An Array of the available components for Gem::URI::File.
+ #
+ COMPONENT = [
+ :scheme,
+ :host,
+ :path
+ ].freeze
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::File object from components, with syntax checking.
+ #
+ # The components accepted are +host+ and +path+.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the
+ # order <code>[host, path]</code>.
+ #
+ # A path from e.g. the File class should be escaped before
+ # being passed.
+ #
+ # Examples:
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri1 = Gem::URI::File.build(['host.example.com', '/path/file.zip'])
+ # uri1.to_s # => "file://host.example.com/path/file.zip"
+ #
+ # uri2 = Gem::URI::File.build({:host => 'host.example.com',
+ # :path => '/ruby/src'})
+ # uri2.to_s # => "file://host.example.com/ruby/src"
+ #
+ # uri3 = Gem::URI::File.build({:path => Gem::URI::RFC2396_PARSER.escape('/path/my file.txt')})
+ # uri3.to_s # => "file:///path/my%20file.txt"
+ #
+ def self.build(args)
+ tmp = Util::make_components_hash(self, args)
+ super(tmp)
+ end
+
+ # Protected setter for the host component +v+.
+ #
+ # See also Gem::URI::Generic.host=.
+ #
+ def set_host(v)
+ v = "" if v.nil? || v == "localhost"
+ @host = v
+ end
+
+ # do nothing
+ def set_port(v)
+ end
+
+ # raise InvalidURIError
+ def check_userinfo(user)
+ raise Gem::URI::InvalidURIError, "cannot set userinfo for file Gem::URI"
+ end
+
+ # raise InvalidURIError
+ def check_user(user)
+ raise Gem::URI::InvalidURIError, "cannot set user for file Gem::URI"
+ end
+
+ # raise InvalidURIError
+ def check_password(user)
+ raise Gem::URI::InvalidURIError, "cannot set password for file Gem::URI"
+ end
+
+ # do nothing
+ def set_userinfo(v)
+ end
+
+ # do nothing
+ def set_user(v)
+ end
+
+ # do nothing
+ def set_password(v)
+ end
+ end
+
+ register_scheme 'FILE', File
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/ftp.rb b/lib/rubygems/vendor/uri/lib/uri/ftp.rb
new file mode 100644
index 0000000000..7517813029
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/ftp.rb
@@ -0,0 +1,267 @@
+# frozen_string_literal: false
+# = uri/ftp.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # FTP Gem::URI syntax is defined by RFC1738 section 3.2.
+ #
+ # This class will be redesigned because of difference of implementations;
+ # the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
+ # is a good summary about the de facto spec.
+ # https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
+ #
+ class FTP < Generic
+ # A Default port of 21 for Gem::URI::FTP.
+ DEFAULT_PORT = 21
+
+ #
+ # An Array of the available components for Gem::URI::FTP.
+ #
+ COMPONENT = [
+ :scheme,
+ :userinfo, :host, :port,
+ :path, :typecode
+ ].freeze
+
+ #
+ # Typecode is "a", "i", or "d".
+ #
+ # * "a" indicates a text file (the FTP command was ASCII)
+ # * "i" indicates a binary file (FTP command IMAGE)
+ # * "d" indicates the contents of a directory should be displayed
+ #
+ TYPECODE = ['a', 'i', 'd'].freeze
+
+ # Typecode prefix ";type=".
+ TYPECODE_PREFIX = ';type='.freeze
+
+ def self.new2(user, password, host, port, path,
+ typecode = nil, arg_check = true) # :nodoc:
+ # Do not use this method! Not tested. [Bug #7301]
+ # This methods remains just for compatibility,
+ # Keep it undocumented until the active maintainer is assigned.
+ typecode = nil if typecode.size == 0
+ if typecode && !TYPECODE.include?(typecode)
+ raise ArgumentError,
+ "bad typecode is specified: #{typecode}"
+ end
+
+ # do escape
+
+ self.new('ftp',
+ [user, password],
+ host, port, nil,
+ typecode ? path + TYPECODE_PREFIX + typecode : path,
+ nil, nil, nil, arg_check)
+ end
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::FTP object from components, with syntax checking.
+ #
+ # The components accepted are +userinfo+, +host+, +port+, +path+, and
+ # +typecode+.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the
+ # order <code>[userinfo, host, port, path, typecode]</code>.
+ #
+ # If the path supplied is absolute, it will be escaped in order to
+ # make it absolute in the Gem::URI.
+ #
+ # Examples:
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri1 = Gem::URI::FTP.build(['user:password', 'ftp.example.com', nil,
+ # '/path/file.zip', 'i'])
+ # uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i"
+ #
+ # uri2 = Gem::URI::FTP.build({:host => 'ftp.example.com',
+ # :path => 'ruby/src'})
+ # uri2.to_s # => "ftp://ftp.example.com/ruby/src"
+ #
+ def self.build(args)
+
+ # Fix the incoming path to be generic URL syntax
+ # FTP path -> URL path
+ # foo/bar /foo/bar
+ # /foo/bar /%2Ffoo/bar
+ #
+ if args.kind_of?(Array)
+ args[3] = '/' + args[3].sub(/^\//, '%2F')
+ else
+ args[:path] = '/' + args[:path].sub(/^\//, '%2F')
+ end
+
+ tmp = Util::make_components_hash(self, args)
+
+ if tmp[:typecode]
+ if tmp[:typecode].size == 1
+ tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode]
+ end
+ tmp[:path] << tmp[:typecode]
+ end
+
+ return super(tmp)
+ end
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::FTP object from generic URL components with no
+ # syntax checking.
+ #
+ # Unlike build(), this method does not escape the path component as
+ # required by RFC1738; instead it is treated as per RFC2396.
+ #
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+ # +opaque+, +query+, and +fragment+, in that order.
+ #
+ def initialize(scheme,
+ userinfo, host, port, registry,
+ path, opaque,
+ query,
+ fragment,
+ parser = nil,
+ arg_check = false)
+ raise InvalidURIError unless path
+ path = path.sub(/^\//,'')
+ path.sub!(/^%2F/,'/')
+ super(scheme, userinfo, host, port, registry, path, opaque,
+ query, fragment, parser, arg_check)
+ @typecode = nil
+ if tmp = @path.index(TYPECODE_PREFIX)
+ typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
+ @path = @path[0..tmp - 1]
+
+ if arg_check
+ self.typecode = typecode
+ else
+ self.set_typecode(typecode)
+ end
+ end
+ end
+
+ # typecode accessor.
+ #
+ # See Gem::URI::FTP::COMPONENT.
+ attr_reader :typecode
+
+ # Validates typecode +v+,
+ # returns +true+ or +false+.
+ #
+ def check_typecode(v)
+ if TYPECODE.include?(v)
+ return true
+ else
+ raise InvalidComponentError,
+ "bad typecode(expected #{TYPECODE.join(', ')}): #{v}"
+ end
+ end
+ private :check_typecode
+
+ # Private setter for the typecode +v+.
+ #
+ # See also Gem::URI::FTP.typecode=.
+ #
+ def set_typecode(v)
+ @typecode = v
+ end
+ protected :set_typecode
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the typecode +v+
+ # (with validation).
+ #
+ # See also Gem::URI::FTP.check_typecode.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("ftp://john@ftp.example.com/my_file.img")
+ # #=> #<Gem::URI::FTP ftp://john@ftp.example.com/my_file.img>
+ # uri.typecode = "i"
+ # uri
+ # #=> #<Gem::URI::FTP ftp://john@ftp.example.com/my_file.img;type=i>
+ #
+ def typecode=(typecode)
+ check_typecode(typecode)
+ set_typecode(typecode)
+ typecode
+ end
+
+ def merge(oth) # :nodoc:
+ tmp = super(oth)
+ if self != tmp
+ tmp.set_typecode(oth.typecode)
+ end
+
+ return tmp
+ end
+
+ # Returns the path from an FTP Gem::URI.
+ #
+ # RFC 1738 specifically states that the path for an FTP Gem::URI does not
+ # include the / which separates the Gem::URI path from the Gem::URI host. Example:
+ #
+ # <code>ftp://ftp.example.com/pub/ruby</code>
+ #
+ # The above Gem::URI indicates that the client should connect to
+ # ftp.example.com then cd to pub/ruby from the initial login directory.
+ #
+ # If you want to cd to an absolute directory, you must include an
+ # escaped / (%2F) in the path. Example:
+ #
+ # <code>ftp://ftp.example.com/%2Fpub/ruby</code>
+ #
+ # This method will then return "/pub/ruby".
+ #
+ def path
+ return @path.sub(/^\//,'').sub(/^%2F/,'/')
+ end
+
+ # Private setter for the path of the Gem::URI::FTP.
+ def set_path(v)
+ super("/" + v.sub(/^\//, "%2F"))
+ end
+ protected :set_path
+
+ # Returns a String representation of the Gem::URI::FTP.
+ def to_s
+ save_path = nil
+ if @typecode
+ save_path = @path
+ @path = @path + TYPECODE_PREFIX + @typecode
+ end
+ str = super
+ if @typecode
+ @path = save_path
+ end
+
+ return str
+ end
+ end
+
+ register_scheme 'FTP', FTP
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/generic.rb b/lib/rubygems/vendor/uri/lib/uri/generic.rb
new file mode 100644
index 0000000000..d0bc77dfda
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/generic.rb
@@ -0,0 +1,1592 @@
+# frozen_string_literal: true
+
+# = uri/generic.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'common'
+autoload :IPSocket, 'socket'
+autoload :IPAddr, 'ipaddr'
+
+module Gem::URI
+
+ #
+ # Base class for all Gem::URI classes.
+ # Implements generic Gem::URI syntax as per RFC 2396.
+ #
+ class Generic
+ include Gem::URI
+
+ #
+ # A Default port of nil for Gem::URI::Generic.
+ #
+ DEFAULT_PORT = nil
+
+ #
+ # Returns default port.
+ #
+ def self.default_port
+ self::DEFAULT_PORT
+ end
+
+ #
+ # Returns default port.
+ #
+ def default_port
+ self.class.default_port
+ end
+
+ #
+ # An Array of the available components for Gem::URI::Generic.
+ #
+ COMPONENT = [
+ :scheme,
+ :userinfo, :host, :port, :registry,
+ :path, :opaque,
+ :query,
+ :fragment
+ ].freeze
+
+ #
+ # Components of the Gem::URI in the order.
+ #
+ def self.component
+ self::COMPONENT
+ end
+
+ USE_REGISTRY = false # :nodoc:
+
+ def self.use_registry # :nodoc:
+ self::USE_REGISTRY
+ end
+
+ #
+ # == Synopsis
+ #
+ # See ::new.
+ #
+ # == Description
+ #
+ # At first, tries to create a new Gem::URI::Generic instance using
+ # Gem::URI::Generic::build. But, if exception Gem::URI::InvalidComponentError is raised,
+ # then it does Gem::URI::RFC2396_PARSER.escape all Gem::URI components and tries again.
+ #
+ def self.build2(args)
+ begin
+ return self.build(args)
+ rescue InvalidComponentError
+ if args.kind_of?(Array)
+ return self.build(args.collect{|x|
+ if x.is_a?(String)
+ Gem::URI::RFC2396_PARSER.escape(x)
+ else
+ x
+ end
+ })
+ elsif args.kind_of?(Hash)
+ tmp = {}
+ args.each do |key, value|
+ tmp[key] = if value
+ Gem::URI::RFC2396_PARSER.escape(value)
+ else
+ value
+ end
+ end
+ return self.build(tmp)
+ end
+ end
+ end
+
+ #
+ # == Synopsis
+ #
+ # See ::new.
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::Generic instance from components of Gem::URI::Generic
+ # with check. Components are: scheme, userinfo, host, port, registry, path,
+ # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
+ # See ::new for hash keys to use or for order of array items.
+ #
+ def self.build(args)
+ if args.kind_of?(Array) &&
+ args.size == ::Gem::URI::Generic::COMPONENT.size
+ tmp = args.dup
+ elsif args.kind_of?(Hash)
+ tmp = ::Gem::URI::Generic::COMPONENT.collect do |c|
+ if args.include?(c)
+ args[c]
+ else
+ nil
+ end
+ end
+ else
+ component = self.component rescue ::Gem::URI::Generic::COMPONENT
+ raise ArgumentError,
+ "expected Array of or Hash of components of #{self} (#{component.join(', ')})"
+ end
+
+ tmp << nil
+ tmp << true
+ return self.new(*tmp)
+ end
+
+ #
+ # == Args
+ #
+ # +scheme+::
+ # Protocol scheme, i.e. 'http','ftp','mailto' and so on.
+ # +userinfo+::
+ # User name and password, i.e. 'sdmitry:bla'.
+ # +host+::
+ # Server host name.
+ # +port+::
+ # Server port.
+ # +registry+::
+ # Registry of naming authorities.
+ # +path+::
+ # Path on server.
+ # +opaque+::
+ # Opaque part.
+ # +query+::
+ # Query data.
+ # +fragment+::
+ # Part of the Gem::URI after '#' character.
+ # +parser+::
+ # Parser for internal use [Gem::URI::DEFAULT_PARSER by default].
+ # +arg_check+::
+ # Check arguments [false by default].
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::Generic instance from ``generic'' components without check.
+ #
+ def initialize(scheme,
+ userinfo, host, port, registry,
+ path, opaque,
+ query,
+ fragment,
+ parser = DEFAULT_PARSER,
+ arg_check = false)
+ @scheme = nil
+ @user = nil
+ @password = nil
+ @host = nil
+ @port = nil
+ @path = nil
+ @query = nil
+ @opaque = nil
+ @fragment = nil
+ @parser = parser == DEFAULT_PARSER ? nil : parser
+
+ if arg_check
+ self.scheme = scheme
+ self.hostname = host
+ self.port = port
+ self.userinfo = userinfo
+ self.path = path
+ self.query = query
+ self.opaque = opaque
+ self.fragment = fragment
+ else
+ self.set_scheme(scheme)
+ self.set_host(host)
+ self.set_port(port)
+ self.set_userinfo(userinfo)
+ self.set_path(path)
+ self.query = query
+ self.set_opaque(opaque)
+ self.fragment=(fragment)
+ end
+ if registry
+ raise InvalidURIError,
+ "the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)"
+ end
+
+ @scheme&.freeze
+ self.set_path('') if !@path && !@opaque # (see RFC2396 Section 5.2)
+ self.set_port(self.default_port) if self.default_port && !@port
+ end
+
+ #
+ # Returns the scheme component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz").scheme #=> "http"
+ #
+ attr_reader :scheme
+
+ # Returns the host component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz").host #=> "foo"
+ #
+ # It returns nil if no host component exists.
+ #
+ # Gem::URI("mailto:foo@example.org").host #=> nil
+ #
+ # The component does not contain the port number.
+ #
+ # Gem::URI("http://foo:8080/bar/baz").host #=> "foo"
+ #
+ # Since IPv6 addresses are wrapped with brackets in URIs,
+ # this method returns IPv6 addresses wrapped with brackets.
+ # This form is not appropriate to pass to socket methods such as TCPSocket.open.
+ # If unwrapped host names are required, use the #hostname method.
+ #
+ # Gem::URI("http://[::1]/bar/baz").host #=> "[::1]"
+ # Gem::URI("http://[::1]/bar/baz").hostname #=> "::1"
+ #
+ attr_reader :host
+
+ # Returns the port component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz").port #=> 80
+ # Gem::URI("http://foo:8080/bar/baz").port #=> 8080
+ #
+ attr_reader :port
+
+ def registry # :nodoc:
+ nil
+ end
+
+ # Returns the path component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz").path #=> "/bar/baz"
+ #
+ attr_reader :path
+
+ # Returns the query component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
+ #
+ attr_reader :query
+
+ # Returns the opaque part of the Gem::URI.
+ #
+ # Gem::URI("mailto:foo@example.org").opaque #=> "foo@example.org"
+ # Gem::URI("http://foo/bar/baz").opaque #=> nil
+ #
+ # The portion of the path that does not make use of the slash '/'.
+ # The path typically refers to an absolute path or an opaque part.
+ # (See RFC2396 Section 3 and 5.2.)
+ #
+ attr_reader :opaque
+
+ # Returns the fragment component of the Gem::URI.
+ #
+ # Gem::URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
+ #
+ attr_reader :fragment
+
+ # Returns the parser to be used.
+ #
+ # Unless the +parser+ is defined, DEFAULT_PARSER is used.
+ #
+ def parser
+ if !defined?(@parser) || !@parser
+ DEFAULT_PARSER
+ else
+ @parser || DEFAULT_PARSER
+ end
+ end
+
+ # Replaces self by other Gem::URI object.
+ #
+ def replace!(oth)
+ if self.class != oth.class
+ raise ArgumentError, "expected #{self.class} object"
+ end
+
+ component.each do |c|
+ self.__send__("#{c}=", oth.__send__(c))
+ end
+ end
+ private :replace!
+
+ #
+ # Components of the Gem::URI in the order.
+ #
+ def component
+ self.class.component
+ end
+
+ #
+ # Checks the scheme +v+ component against the +parser+ Regexp for :SCHEME.
+ #
+ def check_scheme(v)
+ if v && parser.regexp[:SCHEME] !~ v
+ raise InvalidComponentError,
+ "bad component(expected scheme component): #{v}"
+ end
+
+ return true
+ end
+ private :check_scheme
+
+ # Protected setter for the scheme component +v+.
+ #
+ # See also Gem::URI::Generic.scheme=.
+ #
+ def set_scheme(v)
+ @scheme = v&.downcase
+ end
+ protected :set_scheme
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the scheme component +v+
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_scheme.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.scheme = "https"
+ # uri.to_s #=> "https://my.example.com"
+ #
+ def scheme=(v)
+ check_scheme(v)
+ set_scheme(v)
+ v
+ end
+
+ #
+ # Checks the +user+ and +password+.
+ #
+ # If +password+ is not provided, then +user+ is
+ # split, using Gem::URI::Generic.split_userinfo, to
+ # pull +user+ and +password.
+ #
+ # See also Gem::URI::Generic.check_user, Gem::URI::Generic.check_password.
+ #
+ def check_userinfo(user, password = nil)
+ if !password
+ user, password = split_userinfo(user)
+ end
+ check_user(user)
+ check_password(password, user)
+
+ return true
+ end
+ private :check_userinfo
+
+ #
+ # Checks the user +v+ component for RFC2396 compliance
+ # and against the +parser+ Regexp for :USERINFO.
+ #
+ # Can not have a registry or opaque component defined,
+ # with a user component defined.
+ #
+ def check_user(v)
+ if @opaque
+ raise InvalidURIError,
+ "cannot set user with opaque"
+ end
+
+ return v unless v
+
+ if parser.regexp[:USERINFO] !~ v
+ raise InvalidComponentError,
+ "bad component(expected userinfo component or user component): #{v}"
+ end
+
+ return true
+ end
+ private :check_user
+
+ #
+ # Checks the password +v+ component for RFC2396 compliance
+ # and against the +parser+ Regexp for :USERINFO.
+ #
+ # Can not have a registry or opaque component defined,
+ # with a user component defined.
+ #
+ def check_password(v, user = @user)
+ if @opaque
+ raise InvalidURIError,
+ "cannot set password with opaque"
+ end
+ return v unless v
+
+ if !user
+ raise InvalidURIError,
+ "password component depends user component"
+ end
+
+ if parser.regexp[:USERINFO] !~ v
+ raise InvalidComponentError,
+ "bad password component"
+ end
+
+ return true
+ end
+ private :check_password
+
+ #
+ # Sets userinfo, argument is string like 'name:pass'.
+ #
+ def userinfo=(userinfo)
+ if userinfo.nil?
+ return nil
+ end
+ check_userinfo(*userinfo)
+ set_userinfo(*userinfo)
+ # returns userinfo
+ end
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the +user+ component
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_user.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://john:S3nsit1ve@my.example.com")
+ # uri.user = "sam"
+ # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
+ #
+ def user=(user)
+ check_user(user)
+ set_user(user)
+ # returns user
+ end
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the +password+ component
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_password.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://john:S3nsit1ve@my.example.com")
+ # uri.password = "V3ry_S3nsit1ve"
+ # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
+ #
+ def password=(password)
+ check_password(password)
+ set_password(password)
+ # returns password
+ end
+
+ # Protected setter for the +user+ component, and +password+ if available
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.userinfo=.
+ #
+ def set_userinfo(user, password = nil)
+ unless password
+ user, password = split_userinfo(user)
+ end
+ @user = user
+ @password = password
+
+ [@user, @password]
+ end
+ protected :set_userinfo
+
+ # Protected setter for the user component +v+.
+ #
+ # See also Gem::URI::Generic.user=.
+ #
+ def set_user(v)
+ set_userinfo(v, nil)
+ v
+ end
+ protected :set_user
+
+ # Protected setter for the password component +v+.
+ #
+ # See also Gem::URI::Generic.password=.
+ #
+ def set_password(v)
+ @password = v
+ # returns v
+ end
+ protected :set_password
+
+ # Returns the userinfo +ui+ as <code>[user, password]</code>
+ # if properly formatted as 'user:password'.
+ def split_userinfo(ui)
+ return nil, nil unless ui
+ user, password = ui.split(':', 2)
+
+ return user, password
+ end
+ private :split_userinfo
+
+ # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
+ def escape_userpass(v)
+ parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
+ end
+ private :escape_userpass
+
+ # Returns the userinfo, either as 'user' or 'user:password'.
+ def userinfo
+ if @user.nil?
+ nil
+ elsif @password.nil?
+ @user
+ else
+ @user + ':' + @password
+ end
+ end
+
+ # Returns the user component (without Gem::URI decoding).
+ def user
+ @user
+ end
+
+ # Returns the password component (without Gem::URI decoding).
+ def password
+ @password
+ end
+
+ # Returns the authority info (array of user, password, host and
+ # port), if any is set. Or returns +nil+.
+ def authority
+ return @user, @password, @host, @port if @user || @password || @host || @port
+ end
+
+ # Returns the user component after Gem::URI decoding.
+ def decoded_user
+ Gem::URI.decode_uri_component(@user) if @user
+ end
+
+ # Returns the password component after Gem::URI decoding.
+ def decoded_password
+ Gem::URI.decode_uri_component(@password) if @password
+ end
+
+ #
+ # Checks the host +v+ component for RFC2396 compliance
+ # and against the +parser+ Regexp for :HOST.
+ #
+ # Can not have a registry or opaque component defined,
+ # with a host component defined.
+ #
+ def check_host(v)
+ return v unless v
+
+ if @opaque
+ raise InvalidURIError,
+ "cannot set host with registry or opaque"
+ elsif parser.regexp[:HOST] !~ v
+ raise InvalidComponentError,
+ "bad component(expected host component): #{v}"
+ end
+
+ return true
+ end
+ private :check_host
+
+ # Protected setter for the host component +v+.
+ #
+ # See also Gem::URI::Generic.host=.
+ #
+ def set_host(v)
+ @host = v
+ end
+ protected :set_host
+
+ # Protected setter for the authority info (+user+, +password+, +host+
+ # and +port+). If +port+ is +nil+, +default_port+ will be set.
+ #
+ protected def set_authority(user, password, host, port = nil)
+ @user, @password, @host, @port = user, password, host, port || self.default_port
+ end
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the host component +v+
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_host.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.host = "foo.com"
+ # uri.to_s #=> "http://foo.com"
+ #
+ def host=(v)
+ check_host(v)
+ set_host(v)
+ set_userinfo(nil)
+ v
+ end
+
+ # Extract the host part of the Gem::URI and unwrap brackets for IPv6 addresses.
+ #
+ # This method is the same as Gem::URI::Generic#host except
+ # brackets for IPv6 (and future IP) addresses are removed.
+ #
+ # uri = Gem::URI("http://[::1]/bar")
+ # uri.hostname #=> "::1"
+ # uri.host #=> "[::1]"
+ #
+ def hostname
+ v = self.host
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
+ end
+
+ # Sets the host part of the Gem::URI as the argument with brackets for IPv6 addresses.
+ #
+ # This method is the same as Gem::URI::Generic#host= except
+ # the argument can be a bare IPv6 address.
+ #
+ # uri = Gem::URI("http://foo/bar")
+ # uri.hostname = "::1"
+ # uri.to_s #=> "http://[::1]/bar"
+ #
+ # If the argument seems to be an IPv6 address,
+ # it is wrapped with brackets.
+ #
+ def hostname=(v)
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
+ self.host = v
+ end
+
+ #
+ # Checks the port +v+ component for RFC2396 compliance
+ # and against the +parser+ Regexp for :PORT.
+ #
+ # Can not have a registry or opaque component defined,
+ # with a port component defined.
+ #
+ def check_port(v)
+ return v unless v
+
+ if @opaque
+ raise InvalidURIError,
+ "cannot set port with registry or opaque"
+ elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
+ raise InvalidComponentError,
+ "bad component(expected port component): #{v.inspect}"
+ end
+
+ return true
+ end
+ private :check_port
+
+ # Protected setter for the port component +v+.
+ #
+ # See also Gem::URI::Generic.port=.
+ #
+ def set_port(v)
+ v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)
+ @port = v
+ end
+ protected :set_port
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the port component +v+
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_port.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.port = 8080
+ # uri.to_s #=> "http://my.example.com:8080"
+ #
+ def port=(v)
+ check_port(v)
+ set_port(v)
+ set_userinfo(nil)
+ port
+ end
+
+ def check_registry(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
+ end
+ private :check_registry
+
+ def set_registry(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
+ end
+ protected :set_registry
+
+ def registry=(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
+ end
+
+ #
+ # Checks the path +v+ component for RFC2396 compliance
+ # and against the +parser+ Regexp
+ # for :ABS_PATH and :REL_PATH.
+ #
+ # Can not have a opaque component defined,
+ # with a path component defined.
+ #
+ def check_path(v)
+ # raise if both hier and opaque are not nil, because:
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
+ if v && @opaque
+ raise InvalidURIError,
+ "path conflicts with opaque"
+ end
+
+ # If scheme is ftp, path may be relative.
+ # See RFC 1738 section 3.2.2, and RFC 2396.
+ if @scheme && @scheme != "ftp"
+ if v && v != '' && parser.regexp[:ABS_PATH] !~ v
+ raise InvalidComponentError,
+ "bad component(expected absolute path component): #{v}"
+ end
+ else
+ if v && v != '' && parser.regexp[:ABS_PATH] !~ v &&
+ parser.regexp[:REL_PATH] !~ v
+ raise InvalidComponentError,
+ "bad component(expected relative path component): #{v}"
+ end
+ end
+
+ return true
+ end
+ private :check_path
+
+ # Protected setter for the path component +v+.
+ #
+ # See also Gem::URI::Generic.path=.
+ #
+ def set_path(v)
+ @path = v
+ end
+ protected :set_path
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the path component +v+
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_path.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com/pub/files")
+ # uri.path = "/faq/"
+ # uri.to_s #=> "http://my.example.com/faq/"
+ #
+ def path=(v)
+ check_path(v)
+ set_path(v)
+ v
+ end
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the query component +v+.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com/?id=25")
+ # uri.query = "id=1"
+ # uri.to_s #=> "http://my.example.com/?id=1"
+ #
+ def query=(v)
+ return @query = nil unless v
+ raise InvalidURIError, "query conflicts with opaque" if @opaque
+
+ x = v.to_str
+ v = x.dup if x.equal? v
+ v.encode!(Encoding::UTF_8) rescue nil
+ v.delete!("\t\r\n")
+ v.force_encoding(Encoding::ASCII_8BIT)
+ raise InvalidURIError, "invalid percent escape: #{$1}" if /(%\H\H)/n.match(v)
+ v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}
+ v.force_encoding(Encoding::US_ASCII)
+ @query = v
+ end
+
+ #
+ # Checks the opaque +v+ component for RFC2396 compliance and
+ # against the +parser+ Regexp for :OPAQUE.
+ #
+ # Can not have a host, port, user, or path component defined,
+ # with an opaque component defined.
+ #
+ def check_opaque(v)
+ return v unless v
+
+ # raise if both hier and opaque are not nil, because:
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
+ if @host || @port || @user || @path # userinfo = @user + ':' + @password
+ raise InvalidURIError,
+ "cannot set opaque with host, port, userinfo or path"
+ elsif v && parser.regexp[:OPAQUE] !~ v
+ raise InvalidComponentError,
+ "bad component(expected opaque component): #{v}"
+ end
+
+ return true
+ end
+ private :check_opaque
+
+ # Protected setter for the opaque component +v+.
+ #
+ # See also Gem::URI::Generic.opaque=.
+ #
+ def set_opaque(v)
+ @opaque = v
+ end
+ protected :set_opaque
+
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the opaque component +v+
+ # (with validation).
+ #
+ # See also Gem::URI::Generic.check_opaque.
+ #
+ def opaque=(v)
+ check_opaque(v)
+ set_opaque(v)
+ v
+ end
+
+ #
+ # Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT.
+ #
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # Public setter for the fragment component +v+
+ # (with validation).
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com/?id=25#time=1305212049")
+ # uri.fragment = "time=1305212086"
+ # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
+ #
+ def fragment=(v)
+ return @fragment = nil unless v
+
+ x = v.to_str
+ v = x.dup if x.equal? v
+ v.encode!(Encoding::UTF_8) rescue nil
+ v.delete!("\t\r\n")
+ v.force_encoding(Encoding::ASCII_8BIT)
+ v.gsub!(/(?!%\h\h|[!-~])./n){'%%%02X' % $&.ord}
+ v.force_encoding(Encoding::US_ASCII)
+ @fragment = v
+ end
+
+ #
+ # Returns true if Gem::URI is hierarchical.
+ #
+ # == Description
+ #
+ # Gem::URI has components listed in order of decreasing significance from left to right,
+ # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com/")
+ # uri.hierarchical?
+ # #=> true
+ # uri = Gem::URI.parse("mailto:joe@example.com")
+ # uri.hierarchical?
+ # #=> false
+ #
+ def hierarchical?
+ if @path
+ true
+ else
+ false
+ end
+ end
+
+ #
+ # Returns true if Gem::URI has a scheme (e.g. http:// or https://) specified.
+ #
+ def absolute?
+ if @scheme
+ true
+ else
+ false
+ end
+ end
+ alias absolute absolute?
+
+ #
+ # Returns true if Gem::URI does not have a scheme (e.g. http:// or https://) specified.
+ #
+ def relative?
+ !absolute?
+ end
+
+ #
+ # Returns an Array of the path split on '/'.
+ #
+ def split_path(path)
+ path.split("/", -1)
+ end
+ private :split_path
+
+ #
+ # Merges a base path +base+, with relative path +rel+,
+ # returns a modified base path.
+ #
+ def merge_path(base, rel)
+
+ # RFC2396, Section 5.2, 5)
+ # RFC2396, Section 5.2, 6)
+ base_path = split_path(base)
+ rel_path = split_path(rel)
+
+ # RFC2396, Section 5.2, 6), a)
+ base_path << '' if base_path.last == '..'
+ while i = base_path.index('..')
+ base_path.slice!(i - 1, 2)
+ end
+
+ if (first = rel_path.first) and first.empty?
+ base_path.clear
+ rel_path.shift
+ end
+
+ # RFC2396, Section 5.2, 6), c)
+ # RFC2396, Section 5.2, 6), d)
+ rel_path.push('') if rel_path.last == '.' || rel_path.last == '..'
+ rel_path.delete('.')
+
+ # RFC2396, Section 5.2, 6), e)
+ tmp = []
+ rel_path.each do |x|
+ if x == '..' &&
+ !(tmp.empty? || tmp.last == '..')
+ tmp.pop
+ else
+ tmp << x
+ end
+ end
+
+ add_trailer_slash = !tmp.empty?
+ if base_path.empty?
+ base_path = [''] # keep '/' for root directory
+ elsif add_trailer_slash
+ base_path.pop
+ end
+ while x = tmp.shift
+ if x == '..'
+ # RFC2396, Section 4
+ # a .. or . in an absolute path has no special meaning
+ base_path.pop if base_path.size > 1
+ else
+ # if x == '..'
+ # valid absolute (but abnormal) path "/../..."
+ # else
+ # valid absolute path
+ # end
+ base_path << x
+ tmp.each {|t| base_path << t}
+ add_trailer_slash = false
+ break
+ end
+ end
+ base_path.push('') if add_trailer_slash
+
+ return base_path.join('/')
+ end
+ private :merge_path
+
+ #
+ # == Args
+ #
+ # +oth+::
+ # Gem::URI or String
+ #
+ # == Description
+ #
+ # Destructive form of #merge.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.merge!("/main.rbx?page=1")
+ # uri.to_s # => "http://my.example.com/main.rbx?page=1"
+ #
+ def merge!(oth)
+ t = merge(oth)
+ if self == t
+ nil
+ else
+ replace!(t)
+ self
+ end
+ end
+
+ #
+ # == Args
+ #
+ # +oth+::
+ # Gem::URI or String
+ #
+ # == Description
+ #
+ # Merges two URIs.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.merge("/main.rbx?page=1")
+ # # => "http://my.example.com/main.rbx?page=1"
+ #
+ def merge(oth)
+ rel = parser.__send__(:convert_to_uri, oth)
+
+ if rel.absolute?
+ #raise BadURIError, "both Gem::URI are absolute" if absolute?
+ # hmm... should return oth for usability?
+ return rel
+ end
+
+ unless self.absolute?
+ raise BadURIError, "both Gem::URI are relative"
+ end
+
+ base = self.dup
+
+ authority = rel.authority
+
+ # RFC2396, Section 5.2, 2)
+ if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
+ base.fragment=(rel.fragment) if rel.fragment
+ return base
+ end
+
+ base.query = nil
+ base.fragment=(nil)
+
+ # RFC2396, Section 5.2, 4)
+ if authority
+ base.set_authority(*authority)
+ base.set_path(rel.path)
+ elsif base.path && rel.path
+ base.set_path(merge_path(base.path, rel.path))
+ end
+
+ # RFC2396, Section 5.2, 7)
+ base.query = rel.query if rel.query
+ base.fragment=(rel.fragment) if rel.fragment
+
+ return base
+ end # merge
+ alias + merge
+
+ # :stopdoc:
+ def route_from_path(src, dst)
+ case dst
+ when src
+ # RFC2396, Section 4.2
+ return ''
+ when %r{(?:\A|/)\.\.?(?:/|\z)}
+ # dst has abnormal absolute path,
+ # like "/./", "/../", "/x/../", ...
+ return dst.dup
+ end
+
+ src_path = src.scan(%r{[^/]*/})
+ dst_path = dst.scan(%r{[^/]*/?})
+
+ # discard same parts
+ while !dst_path.empty? && dst_path.first == src_path.first
+ src_path.shift
+ dst_path.shift
+ end
+
+ tmp = dst_path.join
+
+ # calculate
+ if src_path.empty?
+ if tmp.empty?
+ return './'
+ elsif dst_path.first.include?(':') # (see RFC2396 Section 5)
+ return './' + tmp
+ else
+ return tmp
+ end
+ end
+
+ return '../' * src_path.size + tmp
+ end
+ private :route_from_path
+ # :startdoc:
+
+ # :stopdoc:
+ def route_from0(oth)
+ oth = parser.__send__(:convert_to_uri, oth)
+ if self.relative?
+ raise BadURIError,
+ "relative Gem::URI: #{self}"
+ end
+ if oth.relative?
+ raise BadURIError,
+ "relative Gem::URI: #{oth}"
+ end
+
+ if self.scheme != oth.scheme
+ return self, self.dup
+ end
+ rel = Gem::URI::Generic.new(nil, # it is relative Gem::URI
+ self.userinfo, self.host, self.port,
+ nil, self.path, self.opaque,
+ self.query, self.fragment, parser)
+
+ if rel.userinfo != oth.userinfo ||
+ rel.host.to_s.downcase != oth.host.to_s.downcase ||
+ rel.port != oth.port
+
+ if self.userinfo.nil? && self.host.nil?
+ return self, self.dup
+ end
+
+ rel.set_port(nil) if rel.port == oth.default_port
+ return rel, rel
+ end
+ rel.set_userinfo(nil)
+ rel.set_host(nil)
+ rel.set_port(nil)
+
+ if rel.path && rel.path == oth.path
+ rel.set_path('')
+ rel.query = nil if rel.query == oth.query
+ return rel, rel
+ elsif rel.opaque && rel.opaque == oth.opaque
+ rel.set_opaque('')
+ rel.query = nil if rel.query == oth.query
+ return rel, rel
+ end
+
+ # you can modify `rel', but cannot `oth'.
+ return oth, rel
+ end
+ private :route_from0
+ # :startdoc:
+
+ #
+ # == Args
+ #
+ # +oth+::
+ # Gem::URI or String
+ #
+ # == Description
+ #
+ # Calculates relative path from oth to self.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse('http://my.example.com/main.rbx?page=1')
+ # uri.route_from('http://my.example.com')
+ # #=> #<Gem::URI::Generic /main.rbx?page=1>
+ #
+ def route_from(oth)
+ # you can modify `rel', but cannot `oth'.
+ begin
+ oth, rel = route_from0(oth)
+ rescue
+ raise $!.class, $!.message
+ end
+ if oth == rel
+ return rel
+ end
+
+ rel.set_path(route_from_path(oth.path, self.path))
+ if rel.path == './' && self.query
+ # "./?foo" -> "?foo"
+ rel.set_path('')
+ end
+
+ return rel
+ end
+
+ alias - route_from
+
+ #
+ # == Args
+ #
+ # +oth+::
+ # Gem::URI or String
+ #
+ # == Description
+ #
+ # Calculates relative path to oth from self.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse('http://my.example.com')
+ # uri.route_to('http://my.example.com/main.rbx?page=1')
+ # #=> #<Gem::URI::Generic /main.rbx?page=1>
+ #
+ def route_to(oth)
+ parser.__send__(:convert_to_uri, oth).route_from(self)
+ end
+
+ #
+ # Returns normalized Gem::URI.
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # Gem::URI("HTTP://my.EXAMPLE.com").normalize
+ # #=> #<Gem::URI::HTTP http://my.example.com/>
+ #
+ # Normalization here means:
+ #
+ # * scheme and host are converted to lowercase,
+ # * an empty path component is set to "/".
+ #
+ def normalize
+ uri = dup
+ uri.normalize!
+ uri
+ end
+
+ #
+ # Destructive version of #normalize.
+ #
+ def normalize!
+ if path&.empty?
+ set_path('/')
+ end
+ if scheme && scheme != scheme.downcase
+ set_scheme(self.scheme.downcase)
+ end
+ if host && host != host.downcase
+ set_host(self.host.downcase)
+ end
+ end
+
+ #
+ # Constructs String from Gem::URI.
+ #
+ def to_s
+ str = ''.dup
+ if @scheme
+ str << @scheme
+ str << ':'
+ end
+
+ if @opaque
+ str << @opaque
+ else
+ if @host || %w[file postgres].include?(@scheme)
+ str << '//'
+ end
+ if self.userinfo
+ str << self.userinfo
+ str << '@'
+ end
+ if @host
+ str << @host
+ end
+ if @port && @port != self.default_port
+ str << ':'
+ str << @port.to_s
+ end
+ if (@host || @port) && !@path.empty? && !@path.start_with?('/')
+ str << '/'
+ end
+ str << @path
+ if @query
+ str << '?'
+ str << @query
+ end
+ end
+ if @fragment
+ str << '#'
+ str << @fragment
+ end
+ str
+ end
+ alias to_str to_s
+
+ #
+ # Compares two URIs.
+ #
+ def ==(oth)
+ if self.class == oth.class
+ self.normalize.component_ary == oth.normalize.component_ary
+ else
+ false
+ end
+ end
+
+ # Returns the hash value.
+ def hash
+ self.component_ary.hash
+ end
+
+ # Compares with _oth_ for Hash.
+ def eql?(oth)
+ self.class == oth.class &&
+ parser == oth.parser &&
+ self.component_ary.eql?(oth.component_ary)
+ end
+
+ # Returns an Array of the components defined from the COMPONENT Array.
+ def component_ary
+ component.collect do |x|
+ self.__send__(x)
+ end
+ end
+ protected :component_ary
+
+ # == Args
+ #
+ # +components+::
+ # Multiple Symbol arguments defined in Gem::URI::HTTP.
+ #
+ # == Description
+ #
+ # Selects specified components from Gem::URI.
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse('http://myuser:mypass@my.example.com/test.rbx')
+ # uri.select(:userinfo, :host, :path)
+ # # => ["myuser:mypass", "my.example.com", "/test.rbx"]
+ #
+ def select(*components)
+ components.collect do |c|
+ if component.include?(c)
+ self.__send__(c)
+ else
+ raise ArgumentError,
+ "expected of components of #{self.class} (#{self.class.component.join(', ')})"
+ end
+ end
+ end
+
+ def inspect # :nodoc:
+ "#<#{self.class} #{self}>"
+ end
+
+ #
+ # == Args
+ #
+ # +v+::
+ # Gem::URI or String
+ #
+ # == Description
+ #
+ # Attempts to parse other Gem::URI +oth+,
+ # returns [parsed_oth, self].
+ #
+ # == Usage
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("http://my.example.com")
+ # uri.coerce("http://foo.com")
+ # #=> [#<Gem::URI::HTTP http://foo.com>, #<Gem::URI::HTTP http://my.example.com>]
+ #
+ def coerce(oth)
+ case oth
+ when String
+ oth = parser.parse(oth)
+ else
+ super
+ end
+
+ return oth, self
+ end
+
+ # Returns a proxy Gem::URI.
+ # The proxy Gem::URI is obtained from environment variables such as http_proxy,
+ # ftp_proxy, no_proxy, etc.
+ # If there is no proper proxy, nil is returned.
+ #
+ # If the optional parameter +env+ is specified, it is used instead of ENV.
+ #
+ # 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(env=ENV)
+ raise BadURIError, "relative Gem::URI: #{self}" if self.relative?
+ 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, _ = 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.to_hash[name]
+ end
+ if !proxy_uri
+ # Use CGI_HTTP_PROXY. cf. libwww-perl.
+ proxy_uri = env["CGI_#{name.upcase}"]
+ end
+ elsif name == 'http_proxy'
+ if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
+ p_port = ENV_JAVA['http.proxyPort']
+ if p_user = ENV_JAVA['http.proxyUser']
+ p_pass = ENV_JAVA['http.proxyPass']
+ proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
+ else
+ proxy_uri = "http://#{p_addr}:#{p_port}"
+ end
+ else
+ unless proxy_uri = env[name]
+ if proxy_uri = env[name.upcase]
+ warn 'The environment variable HTTP_PROXY is discouraged. Please use http_proxy instead.', uplevel: 1
+ end
+ end
+ end
+ else
+ proxy_uri = env[name] || env[name.upcase]
+ end
+
+ if proxy_uri.nil? || proxy_uri.empty?
+ return nil
+ end
+
+ if self.hostname
+ begin
+ addr = IPSocket.getaddress(self.hostname)
+ return nil if /\A127\.|\A::1\z/ =~ addr
+ rescue SocketError
+ end
+ end
+
+ name = 'no_proxy'
+ if no_proxy = env[name] || env[name.upcase]
+ return nil unless Gem::URI::Generic.use_proxy?(self.hostname, addr, self.port, no_proxy)
+ end
+ Gem::URI.parse(proxy_uri)
+ end
+
+ def self.use_proxy?(hostname, addr, port, no_proxy) # :nodoc:
+ hostname = hostname.downcase
+ dothostname = ".#{hostname}"
+ no_proxy.scan(/([^:,\s]+)(?::(\d+))?/) {|p_host, p_port|
+ if !p_port || port == p_port.to_i
+ if p_host.start_with?('.')
+ return false if hostname.end_with?(p_host.downcase)
+ else
+ return false if dothostname.end_with?(".#{p_host.downcase}")
+ end
+ if addr
+ begin
+ return false if IPAddr.new(p_host).include?(addr)
+ rescue IPAddr::InvalidAddressError
+ next
+ end
+ end
+ end
+ }
+ true
+ end
+ end
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/http.rb b/lib/rubygems/vendor/uri/lib/uri/http.rb
new file mode 100644
index 0000000000..99c78358ac
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/http.rb
@@ -0,0 +1,137 @@
+# frozen_string_literal: false
+# = uri/http.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # The syntax of HTTP URIs is defined in RFC1738 section 3.3.
+ #
+ # Note that the Ruby Gem::URI library allows HTTP URLs containing usernames and
+ # passwords. This is not legal as per the RFC, but used to be
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
+ # update. See <URL:http://support.microsoft.com/kb/834489>.
+ #
+ class HTTP < Generic
+ # A Default port of 80 for Gem::URI::HTTP.
+ DEFAULT_PORT = 80
+
+ # An Array of the available components for Gem::URI::HTTP.
+ COMPONENT = %i[
+ scheme
+ userinfo host port
+ path
+ query
+ fragment
+ ].freeze
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::HTTP object from components, with syntax checking.
+ #
+ # The components accepted are userinfo, host, port, path, query, and
+ # fragment.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the
+ # order <code>[userinfo, host, port, path, query, fragment]</code>.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
+ #
+ # uri = Gem::URI::HTTP.build([nil, "www.example.com", nil, "/path",
+ # "query", 'fragment'])
+ #
+ # Currently, if passed userinfo components this method generates
+ # invalid HTTP URIs as per RFC 1738.
+ #
+ def self.build(args)
+ tmp = Util.make_components_hash(self, args)
+ super(tmp)
+ end
+
+ # Do not allow empty host names, as they are not allowed by RFC 3986.
+ def check_host(v)
+ ret = super
+
+ if ret && v.empty?
+ raise InvalidComponentError,
+ "bad component(expected host component): #{v}"
+ end
+
+ ret
+ end
+
+ #
+ # == Description
+ #
+ # Returns the full path for an HTTP request, as required by Net::HTTP::Get.
+ #
+ # If the Gem::URI contains a query, the full path is Gem::URI#path + '?' + Gem::URI#query.
+ # Otherwise, the path is simply Gem::URI#path.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::HTTP.build(path: '/foo/bar', query: 'test=true')
+ # uri.request_uri # => "/foo/bar?test=true"
+ #
+ def request_uri
+ return unless @path
+
+ url = @query ? "#@path?#@query" : @path.dup
+ url.start_with?(?/.freeze) ? url : ?/ + url
+ end
+
+ #
+ # == Description
+ #
+ # Returns the authority for an HTTP uri, as defined in
+ # https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
+ #
+ #
+ # Example:
+ #
+ # Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
+ # Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
+ # Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
+ #
+ def authority
+ if port == default_port
+ host
+ else
+ "#{host}:#{port}"
+ end
+ end
+
+ #
+ # == Description
+ #
+ # Returns the origin for an HTTP uri, as defined in
+ # https://www.rfc-editor.org/rfc/rfc6454.
+ #
+ #
+ # Example:
+ #
+ # Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
+ # Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
+ # Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
+ # Gem::URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
+ #
+ def origin
+ "#{scheme}://#{authority}"
+ end
+ end
+
+ register_scheme 'HTTP', HTTP
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/https.rb b/lib/rubygems/vendor/uri/lib/uri/https.rb
new file mode 100644
index 0000000000..6e8e732e1d
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/https.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: false
+# = uri/https.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'http'
+
+module Gem::URI
+
+ # The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
+ # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
+ # see Gem::URI::HTTP.
+ class HTTPS < HTTP
+ # A Default port of 443 for Gem::URI::HTTPS
+ DEFAULT_PORT = 443
+ end
+
+ register_scheme 'HTTPS', HTTPS
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/ldap.rb b/lib/rubygems/vendor/uri/lib/uri/ldap.rb
new file mode 100644
index 0000000000..1a08b5ab7e
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/ldap.rb
@@ -0,0 +1,261 @@
+# frozen_string_literal: false
+# = uri/ldap.rb
+#
+# Author::
+# Takaaki Tateishi <ttate@jaist.ac.jp>
+# Akira Yamada <akira@ruby-lang.org>
+# License::
+# Gem::URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
+# You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # LDAP Gem::URI SCHEMA (described in RFC2255).
+ #--
+ # ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
+ #++
+ class LDAP < Generic
+
+ # A Default port of 389 for Gem::URI::LDAP.
+ DEFAULT_PORT = 389
+
+ # An Array of the available components for Gem::URI::LDAP.
+ COMPONENT = [
+ :scheme,
+ :host, :port,
+ :dn,
+ :attributes,
+ :scope,
+ :filter,
+ :extensions,
+ ].freeze
+
+ # Scopes available for the starting point.
+ #
+ # * SCOPE_BASE - the Base DN
+ # * SCOPE_ONE - one level under the Base DN, not including the base DN and
+ # not including any entries under this
+ # * SCOPE_SUB - subtrees, all entries at all levels
+ #
+ SCOPE = [
+ SCOPE_ONE = 'one',
+ SCOPE_SUB = 'sub',
+ SCOPE_BASE = 'base',
+ ].freeze
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::LDAP object from components, with syntax checking.
+ #
+ # The components accepted are host, port, dn, attributes,
+ # scope, filter, and extensions.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the
+ # order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::LDAP.build({:host => 'ldap.example.com',
+ # :dn => '/dc=example'})
+ #
+ # uri = Gem::URI::LDAP.build(["ldap.example.com", nil,
+ # "/dc=example;dc=com", "query", nil, nil, nil])
+ #
+ def self.build(args)
+ tmp = Util::make_components_hash(self, args)
+
+ if tmp[:dn]
+ tmp[:path] = tmp[:dn]
+ end
+
+ query = []
+ [:extensions, :filter, :scope, :attributes].collect do |x|
+ next if !tmp[x] && query.size == 0
+ query.unshift(tmp[x])
+ end
+
+ tmp[:query] = query.join('?')
+
+ return super(tmp)
+ end
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::LDAP object from generic Gem::URI components as per
+ # RFC 2396. No LDAP-specific syntax checking is performed.
+ #
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+ # +opaque+, +query+, and +fragment+, in that order.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
+ # "/dc=example;dc=com", nil, "query", nil)
+ #
+ # See also Gem::URI::Generic.new.
+ #
+ def initialize(*arg)
+ super(*arg)
+
+ if @fragment
+ raise InvalidURIError, 'bad LDAP URL'
+ end
+
+ parse_dn
+ parse_query
+ end
+
+ # Private method to cleanup +dn+ from using the +path+ component attribute.
+ def parse_dn
+ raise InvalidURIError, 'bad LDAP URL' unless @path
+ @dn = @path[1..-1]
+ end
+ private :parse_dn
+
+ # Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
+ # from using the +query+ component attribute.
+ def parse_query
+ @attributes = nil
+ @scope = nil
+ @filter = nil
+ @extensions = nil
+
+ if @query
+ attrs, scope, filter, extensions = @query.split('?')
+
+ @attributes = attrs if attrs && attrs.size > 0
+ @scope = scope if scope && scope.size > 0
+ @filter = filter if filter && filter.size > 0
+ @extensions = extensions if extensions && extensions.size > 0
+ end
+ end
+ private :parse_query
+
+ # Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
+ def build_path_query
+ @path = '/' + @dn
+
+ query = []
+ [@extensions, @filter, @scope, @attributes].each do |x|
+ next if !x && query.size == 0
+ query.unshift(x)
+ end
+ @query = query.join('?')
+ end
+ private :build_path_query
+
+ # Returns dn.
+ def dn
+ @dn
+ end
+
+ # Private setter for dn +val+.
+ def set_dn(val)
+ @dn = val
+ build_path_query
+ @dn
+ end
+ protected :set_dn
+
+ # Setter for dn +val+.
+ def dn=(val)
+ set_dn(val)
+ val
+ end
+
+ # Returns attributes.
+ def attributes
+ @attributes
+ end
+
+ # Private setter for attributes +val+.
+ def set_attributes(val)
+ @attributes = val
+ build_path_query
+ @attributes
+ end
+ protected :set_attributes
+
+ # Setter for attributes +val+.
+ def attributes=(val)
+ set_attributes(val)
+ val
+ end
+
+ # Returns scope.
+ def scope
+ @scope
+ end
+
+ # Private setter for scope +val+.
+ def set_scope(val)
+ @scope = val
+ build_path_query
+ @scope
+ end
+ protected :set_scope
+
+ # Setter for scope +val+.
+ def scope=(val)
+ set_scope(val)
+ val
+ end
+
+ # Returns filter.
+ def filter
+ @filter
+ end
+
+ # Private setter for filter +val+.
+ def set_filter(val)
+ @filter = val
+ build_path_query
+ @filter
+ end
+ protected :set_filter
+
+ # Setter for filter +val+.
+ def filter=(val)
+ set_filter(val)
+ val
+ end
+
+ # Returns extensions.
+ def extensions
+ @extensions
+ end
+
+ # Private setter for extensions +val+.
+ def set_extensions(val)
+ @extensions = val
+ build_path_query
+ @extensions
+ end
+ protected :set_extensions
+
+ # Setter for extensions +val+.
+ def extensions=(val)
+ set_extensions(val)
+ val
+ end
+
+ # Checks if Gem::URI has a path.
+ # For Gem::URI::LDAP this will return +false+.
+ def hierarchical?
+ false
+ end
+ end
+
+ register_scheme 'LDAP', LDAP
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/ldaps.rb b/lib/rubygems/vendor/uri/lib/uri/ldaps.rb
new file mode 100644
index 0000000000..b7a5b50e27
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/ldaps.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: false
+# = uri/ldap.rb
+#
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'ldap'
+
+module Gem::URI
+
+ # The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
+ # than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
+ # see Gem::URI::LDAP.
+ class LDAPS < LDAP
+ # A Default port of 636 for Gem::URI::LDAPS
+ DEFAULT_PORT = 636
+ end
+
+ register_scheme 'LDAPS', LDAPS
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/mailto.rb b/lib/rubygems/vendor/uri/lib/uri/mailto.rb
new file mode 100644
index 0000000000..7ae544d194
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/mailto.rb
@@ -0,0 +1,293 @@
+# frozen_string_literal: false
+# = uri/mailto.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # RFC6068, the mailto URL scheme.
+ #
+ class MailTo < Generic
+ include RFC2396_REGEXP
+
+ # A Default port of nil for Gem::URI::MailTo.
+ DEFAULT_PORT = nil
+
+ # An Array of the available components for Gem::URI::MailTo.
+ COMPONENT = [ :scheme, :to, :headers ].freeze
+
+ # :stopdoc:
+ # "hname" and "hvalue" are encodings of an RFC 822 header name and
+ # value, respectively. As with "to", all URL reserved characters must
+ # be encoded.
+ #
+ # "#mailbox" is as specified in RFC 822 [RFC822]. This means that it
+ # consists of zero or more comma-separated mail addresses, possibly
+ # including "phrase" and "comment" components. Note that all URL
+ # reserved characters in "to" must be encoded: in particular,
+ # parentheses, commas, and the percent sign ("%"), which commonly occur
+ # in the "mailbox" syntax.
+ #
+ # Within mailto URLs, the characters "?", "=", "&" are reserved.
+
+ # ; RFC 6068
+ # hfields = "?" hfield *( "&" hfield )
+ # hfield = hfname "=" hfvalue
+ # hfname = *qchar
+ # hfvalue = *qchar
+ # qchar = unreserved / pct-encoded / some-delims
+ # some-delims = "!" / "$" / "'" / "(" / ")" / "*"
+ # / "+" / "," / ";" / ":" / "@"
+ #
+ # ; RFC3986
+ # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+ # pct-encoded = "%" HEXDIG HEXDIG
+ HEADER_REGEXP = /\A(?<hfield>(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g<hfield>)*\z/
+ # practical regexp for email address
+ # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
+ EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
+ # :startdoc:
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::MailTo object from components, with syntax checking.
+ #
+ # Components can be provided as an Array or Hash. If an Array is used,
+ # the components must be supplied as <code>[to, headers]</code>.
+ #
+ # If a Hash is used, the keys are the component names preceded by colons.
+ #
+ # The headers can be supplied as a pre-encoded string, such as
+ # <code>"subject=subscribe&cc=address"</code>, or as an Array of Arrays
+ # like <code>[['subject', 'subscribe'], ['cc', 'address']]</code>.
+ #
+ # Examples:
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # m1 = Gem::URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
+ # m1.to_s # => "mailto:joe@example.com?subject=Ruby"
+ #
+ # m2 = Gem::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
+ # m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
+ #
+ # m3 = Gem::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
+ # m3.to_s # => "mailto:listman@example.com?subject=subscribe"
+ #
+ def self.build(args)
+ tmp = Util.make_components_hash(self, args)
+
+ case tmp[:to]
+ when Array
+ tmp[:opaque] = tmp[:to].join(',')
+ when String
+ tmp[:opaque] = tmp[:to].dup
+ else
+ tmp[:opaque] = ''
+ end
+
+ if tmp[:headers]
+ query =
+ case tmp[:headers]
+ when Array
+ tmp[:headers].collect { |x|
+ if x.kind_of?(Array)
+ x[0] + '=' + x[1..-1].join
+ else
+ x.to_s
+ end
+ }.join('&')
+ when Hash
+ tmp[:headers].collect { |h,v|
+ h + '=' + v
+ }.join('&')
+ else
+ tmp[:headers].to_s
+ end
+ unless query.empty?
+ tmp[:opaque] << '?' << query
+ end
+ end
+
+ super(tmp)
+ end
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::MailTo object from generic URL components with
+ # no syntax checking.
+ #
+ # This method is usually called from Gem::URI::parse, which checks
+ # the validity of each component.
+ #
+ def initialize(*arg)
+ super(*arg)
+
+ @to = nil
+ @headers = []
+
+ # The RFC3986 parser does not normally populate opaque
+ @opaque = "?#{@query}" if @query && !@opaque
+
+ unless @opaque
+ raise InvalidComponentError,
+ "missing opaque part for mailto URL"
+ end
+ to, header = @opaque.split('?', 2)
+ # allow semicolon as a addr-spec separator
+ # http://support.microsoft.com/kb/820868
+ unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to
+ raise InvalidComponentError,
+ "unrecognised opaque part for mailtoURL: #{@opaque}"
+ end
+
+ if arg[10] # arg_check
+ self.to = to
+ self.headers = header
+ else
+ set_to(to)
+ set_headers(header)
+ end
+ end
+
+ # The primary e-mail address of the URL, as a String.
+ attr_reader :to
+
+ # E-mail headers set by the URL, as an Array of Arrays.
+ attr_reader :headers
+
+ # Checks the to +v+ component.
+ def check_to(v)
+ return true unless v
+ return true if v.size == 0
+
+ v.split(/[,;]/).each do |addr|
+ # check url safety as path-rootless
+ if /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*\z/ !~ addr
+ raise InvalidComponentError,
+ "an address in 'to' is invalid as Gem::URI #{addr.dump}"
+ end
+
+ # check addr-spec
+ # don't s/\+/ /g
+ addr.gsub!(/%\h\h/, Gem::URI::TBLDECWWWCOMP_)
+ if EMAIL_REGEXP !~ addr
+ raise InvalidComponentError,
+ "an address in 'to' is invalid as uri-escaped addr-spec #{addr.dump}"
+ end
+ end
+
+ true
+ end
+ private :check_to
+
+ # Private setter for to +v+.
+ def set_to(v)
+ @to = v
+ end
+ protected :set_to
+
+ # Setter for to +v+.
+ def to=(v)
+ check_to(v)
+ set_to(v)
+ v
+ end
+
+ # Checks the headers +v+ component against either
+ # * HEADER_REGEXP
+ def check_headers(v)
+ return true unless v
+ return true if v.size == 0
+ if HEADER_REGEXP !~ v
+ raise InvalidComponentError,
+ "bad component(expected opaque component): #{v}"
+ end
+
+ true
+ end
+ private :check_headers
+
+ # Private setter for headers +v+.
+ def set_headers(v)
+ @headers = []
+ if v
+ v.split('&').each do |x|
+ @headers << x.split(/=/, 2)
+ end
+ end
+ end
+ protected :set_headers
+
+ # Setter for headers +v+.
+ def headers=(v)
+ check_headers(v)
+ set_headers(v)
+ v
+ end
+
+ # Constructs String from Gem::URI.
+ def to_s
+ @scheme + ':' +
+ if @to
+ @to
+ else
+ ''
+ end +
+ if @headers.size > 0
+ '?' + @headers.collect{|x| x.join('=')}.join('&')
+ else
+ ''
+ end +
+ if @fragment
+ '#' + @fragment
+ else
+ ''
+ end
+ end
+
+ # Returns the RFC822 e-mail text equivalent of the URL, as a String.
+ #
+ # Example:
+ #
+ # require 'rubygems/vendor/uri/lib/uri'
+ #
+ # uri = Gem::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
+ # uri.to_mailtext
+ # # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
+ #
+ def to_mailtext
+ to = Gem::URI.decode_www_form_component(@to)
+ head = ''
+ body = ''
+ @headers.each do |x|
+ case x[0]
+ when 'body'
+ body = Gem::URI.decode_www_form_component(x[1])
+ when 'to'
+ to << ', ' + Gem::URI.decode_www_form_component(x[1])
+ else
+ head << Gem::URI.decode_www_form_component(x[0]).capitalize + ': ' +
+ Gem::URI.decode_www_form_component(x[1]) + "\n"
+ end
+ end
+
+ "To: #{to}
+#{head}
+#{body}
+"
+ end
+ alias to_rfc822text to_mailtext
+ end
+
+ register_scheme 'MAILTO', MailTo
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb b/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb
new file mode 100644
index 0000000000..2bb4181649
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb
@@ -0,0 +1,547 @@
+# frozen_string_literal: false
+#--
+# = uri/common.rb
+#
+# Author:: Akira Yamada <akira@ruby-lang.org>
+# License::
+# You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+module Gem::URI
+ #
+ # Includes Gem::URI::REGEXP::PATTERN
+ #
+ module RFC2396_REGEXP
+ #
+ # Patterns used to parse Gem::URI's
+ #
+ module PATTERN
+ # :stopdoc:
+
+ # RFC 2396 (Gem::URI Generic Syntax)
+ # RFC 2732 (IPv6 Literal Addresses in URL's)
+ # RFC 2373 (IPv6 Addressing Architecture)
+
+ # alpha = lowalpha | upalpha
+ ALPHA = "a-zA-Z"
+ # alphanum = alpha | digit
+ ALNUM = "#{ALPHA}\\d"
+
+ # hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
+ # "a" | "b" | "c" | "d" | "e" | "f"
+ HEX = "a-fA-F\\d"
+ # escaped = "%" hex hex
+ ESCAPED = "%[#{HEX}]{2}"
+ # mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
+ # "(" | ")"
+ # unreserved = alphanum | mark
+ UNRESERVED = "\\-_.!~*'()#{ALNUM}"
+ # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
+ # "$" | ","
+ # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
+ # "$" | "," | "[" | "]" (RFC 2732)
+ RESERVED = ";/?:@&=+$,\\[\\]"
+
+ # domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
+ DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
+ # toplabel = alpha | alpha *( alphanum | "-" ) alphanum
+ TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
+ # hostname = *( domainlabel "." ) toplabel [ "." ]
+ HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
+
+ # :startdoc:
+ end # PATTERN
+
+ # :startdoc:
+ end # REGEXP
+
+ # Class that parses String's into Gem::URI's.
+ #
+ # It contains a Hash set of patterns and Regexp's that match and validate.
+ #
+ class RFC2396_Parser
+ include RFC2396_REGEXP
+
+ #
+ # == Synopsis
+ #
+ # Gem::URI::RFC2396_Parser.new([opts])
+ #
+ # == Args
+ #
+ # The constructor accepts a hash as options for parser.
+ # Keys of options are pattern names of Gem::URI components
+ # and values of options are pattern strings.
+ # The constructor generates set of regexps for parsing URIs.
+ #
+ # You can use the following keys:
+ #
+ # * :ESCAPED (Gem::URI::PATTERN::ESCAPED in default)
+ # * :UNRESERVED (Gem::URI::PATTERN::UNRESERVED in default)
+ # * :DOMLABEL (Gem::URI::PATTERN::DOMLABEL in default)
+ # * :TOPLABEL (Gem::URI::PATTERN::TOPLABEL in default)
+ # * :HOSTNAME (Gem::URI::PATTERN::HOSTNAME in default)
+ #
+ # == Examples
+ #
+ # p = Gem::URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
+ # u = p.parse("http://example.jp/%uABCD") #=> #<Gem::URI::HTTP http://example.jp/%uABCD>
+ # Gem::URI.parse(u.to_s) #=> raises Gem::URI::InvalidURIError
+ #
+ # s = "http://example.com/ABCD"
+ # u1 = p.parse(s) #=> #<Gem::URI::HTTP http://example.com/ABCD>
+ # u2 = Gem::URI.parse(s) #=> #<Gem::URI::HTTP http://example.com/ABCD>
+ # u1 == u2 #=> true
+ # u1.eql?(u2) #=> false
+ #
+ def initialize(opts = {})
+ @pattern = initialize_pattern(opts)
+ @pattern.each_value(&:freeze)
+ @pattern.freeze
+
+ @regexp = initialize_regexp(@pattern)
+ @regexp.each_value(&:freeze)
+ @regexp.freeze
+ end
+
+ # The Hash of patterns.
+ #
+ # See also #initialize_pattern.
+ attr_reader :pattern
+
+ # The Hash of Regexp.
+ #
+ # See also #initialize_regexp.
+ attr_reader :regexp
+
+ # Returns a split Gem::URI against +regexp[:ABS_URI]+.
+ def split(uri)
+ case uri
+ when ''
+ # null uri
+
+ when @regexp[:ABS_URI]
+ scheme, opaque, userinfo, host, port,
+ registry, path, query, fragment = $~[1..-1]
+
+ # Gem::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
+ # opaque_part = uric_no_slash *uric
+
+ # abs_path = "/" path_segments
+ # net_path = "//" authority [ abs_path ]
+
+ # authority = server | reg_name
+ # server = [ [ userinfo "@" ] hostport ]
+
+ if !scheme
+ raise InvalidURIError,
+ "bad Gem::URI (absolute but no scheme): #{uri}"
+ end
+ if !opaque && (!path && (!host && !registry))
+ raise InvalidURIError,
+ "bad Gem::URI (absolute but no path): #{uri}"
+ end
+
+ when @regexp[:REL_URI]
+ scheme = nil
+ opaque = nil
+
+ userinfo, host, port, registry,
+ rel_segment, abs_path, query, fragment = $~[1..-1]
+ if rel_segment && abs_path
+ path = rel_segment + abs_path
+ elsif rel_segment
+ path = rel_segment
+ elsif abs_path
+ path = abs_path
+ end
+
+ # Gem::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+
+ # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
+
+ # net_path = "//" authority [ abs_path ]
+ # abs_path = "/" path_segments
+ # rel_path = rel_segment [ abs_path ]
+
+ # authority = server | reg_name
+ # server = [ [ userinfo "@" ] hostport ]
+
+ else
+ raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri}"
+ end
+
+ path = '' if !path && !opaque # (see RFC2396 Section 5.2)
+ ret = [
+ scheme,
+ userinfo, host, port, # X
+ registry, # X
+ path, # Y
+ opaque, # Y
+ query,
+ fragment
+ ]
+ return ret
+ end
+
+ #
+ # == Args
+ #
+ # +uri+::
+ # String
+ #
+ # == Description
+ #
+ # Parses +uri+ and constructs either matching Gem::URI scheme object
+ # (File, FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or Gem::URI::Generic.
+ #
+ # == Usage
+ #
+ # Gem::URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john")
+ # #=> #<Gem::URI::LDAP ldap://ldap.example.com/dc=example?user=john>
+ #
+ def parse(uri)
+ Gem::URI.for(*self.split(uri), self)
+ end
+
+ #
+ # == Args
+ #
+ # +uris+::
+ # an Array of Strings
+ #
+ # == Description
+ #
+ # Attempts to parse and merge a set of URIs.
+ #
+ def join(*uris)
+ uris[0] = convert_to_uri(uris[0])
+ uris.inject :merge
+ end
+
+ #
+ # :call-seq:
+ # extract( str )
+ # extract( str, schemes )
+ # extract( str, schemes ) {|item| block }
+ #
+ # == Args
+ #
+ # +str+::
+ # String to search
+ # +schemes+::
+ # Patterns to apply to +str+
+ #
+ # == Description
+ #
+ # Attempts to parse and merge a set of URIs.
+ # If no +block+ given, then returns the result,
+ # else it calls +block+ for each element in result.
+ #
+ # See also #make_regexp.
+ #
+ def extract(str, schemes = nil)
+ if block_given?
+ str.scan(make_regexp(schemes)) { yield $& }
+ nil
+ else
+ result = []
+ str.scan(make_regexp(schemes)) { result.push $& }
+ result
+ end
+ end
+
+ # Returns Regexp that is default +self.regexp[:ABS_URI_REF]+,
+ # unless +schemes+ is provided. Then it is a Regexp.union with +self.pattern[:X_ABS_URI]+.
+ def make_regexp(schemes = nil)
+ unless schemes
+ @regexp[:ABS_URI_REF]
+ else
+ /(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
+ end
+ end
+
+ #
+ # :call-seq:
+ # escape( str )
+ # escape( str, unsafe )
+ #
+ # == Args
+ #
+ # +str+::
+ # String to make safe
+ # +unsafe+::
+ # Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
+ #
+ # == Description
+ #
+ # Constructs a safe String from +str+, removing unsafe characters,
+ # replacing them with codes.
+ #
+ def escape(str, unsafe = @regexp[:UNSAFE])
+ unless unsafe.kind_of?(Regexp)
+ # perhaps unsafe is String object
+ unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
+ end
+ str.gsub(unsafe) do
+ us = $&
+ tmp = ''
+ us.each_byte do |uc|
+ tmp << sprintf('%%%02X', uc)
+ end
+ tmp
+ end.force_encoding(Encoding::US_ASCII)
+ end
+
+ #
+ # :call-seq:
+ # unescape( str )
+ # unescape( str, escaped )
+ #
+ # == Args
+ #
+ # +str+::
+ # String to remove escapes from
+ # +escaped+::
+ # Regexp to apply. Defaults to +self.regexp[:ESCAPED]+
+ #
+ # == Description
+ #
+ # Removes escapes from +str+.
+ #
+ def unescape(str, escaped = @regexp[:ESCAPED])
+ enc = str.encoding
+ enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
+ str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
+ end
+
+ TO_S = Kernel.instance_method(:to_s) # :nodoc:
+ if TO_S.respond_to?(:bind_call)
+ def inspect # :nodoc:
+ TO_S.bind_call(self)
+ end
+ else
+ def inspect # :nodoc:
+ TO_S.bind(self).call
+ end
+ end
+
+ private
+
+ # Constructs the default Hash of patterns.
+ def initialize_pattern(opts = {})
+ ret = {}
+ ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
+ ret[:UNRESERVED] = unreserved = opts.delete(:UNRESERVED) || PATTERN::UNRESERVED
+ ret[:RESERVED] = reserved = opts.delete(:RESERVED) || PATTERN::RESERVED
+ ret[:DOMLABEL] = opts.delete(:DOMLABEL) || PATTERN::DOMLABEL
+ ret[:TOPLABEL] = opts.delete(:TOPLABEL) || PATTERN::TOPLABEL
+ ret[:HOSTNAME] = hostname = opts.delete(:HOSTNAME)
+
+ # RFC 2396 (Gem::URI Generic Syntax)
+ # RFC 2732 (IPv6 Literal Addresses in URL's)
+ # RFC 2373 (IPv6 Addressing Architecture)
+
+ # uric = reserved | unreserved | escaped
+ ret[:URIC] = uric = "(?:[#{unreserved}#{reserved}]|#{escaped})"
+ # uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
+ # "&" | "=" | "+" | "$" | ","
+ ret[:URIC_NO_SLASH] = uric_no_slash = "(?:[#{unreserved};?:@&=+$,]|#{escaped})"
+ # query = *uric
+ ret[:QUERY] = query = "#{uric}*"
+ # fragment = *uric
+ ret[:FRAGMENT] = fragment = "#{uric}*"
+
+ # hostname = *( domainlabel "." ) toplabel [ "." ]
+ # reg-name = *( unreserved / pct-encoded / sub-delims ) # RFC3986
+ unless hostname
+ ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-.]|%\\h\\h)+"
+ end
+
+ # RFC 2373, APPENDIX B:
+ # IPv6address = hexpart [ ":" IPv4address ]
+ # IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
+ # hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
+ # hexseq = hex4 *( ":" hex4)
+ # hex4 = 1*4HEXDIG
+ #
+ # XXX: This definition has a flaw. "::" + IPv4address must be
+ # allowed too. Here is a replacement.
+ #
+ # IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
+ ret[:IPV4ADDR] = ipv4addr = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
+ # hex4 = 1*4HEXDIG
+ hex4 = "[#{PATTERN::HEX}]{1,4}"
+ # lastpart = hex4 | IPv4address
+ lastpart = "(?:#{hex4}|#{ipv4addr})"
+ # hexseq1 = *( hex4 ":" ) hex4
+ hexseq1 = "(?:#{hex4}:)*#{hex4}"
+ # hexseq2 = *( hex4 ":" ) lastpart
+ hexseq2 = "(?:#{hex4}:)*#{lastpart}"
+ # IPv6address = hexseq2 | [ hexseq1 ] "::" [ hexseq2 ]
+ ret[:IPV6ADDR] = ipv6addr = "(?:#{hexseq2}|(?:#{hexseq1})?::(?:#{hexseq2})?)"
+
+ # IPv6prefix = ( hexseq1 | [ hexseq1 ] "::" [ hexseq1 ] ) "/" 1*2DIGIT
+ # unused
+
+ # ipv6reference = "[" IPv6address "]" (RFC 2732)
+ ret[:IPV6REF] = ipv6ref = "\\[#{ipv6addr}\\]"
+
+ # host = hostname | IPv4address
+ # host = hostname | IPv4address | IPv6reference (RFC 2732)
+ ret[:HOST] = host = "(?:#{hostname}|#{ipv4addr}|#{ipv6ref})"
+ # port = *digit
+ ret[:PORT] = port = '\d*'
+ # hostport = host [ ":" port ]
+ ret[:HOSTPORT] = hostport = "#{host}(?::#{port})?"
+
+ # userinfo = *( unreserved | escaped |
+ # ";" | ":" | "&" | "=" | "+" | "$" | "," )
+ ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,]|#{escaped})*"
+
+ # pchar = unreserved | escaped |
+ # ":" | "@" | "&" | "=" | "+" | "$" | ","
+ pchar = "(?:[#{unreserved}:@&=+$,]|#{escaped})"
+ # param = *pchar
+ param = "#{pchar}*"
+ # segment = *pchar *( ";" param )
+ segment = "#{pchar}*(?:;#{param})*"
+ # path_segments = segment *( "/" segment )
+ ret[:PATH_SEGMENTS] = path_segments = "#{segment}(?:/#{segment})*"
+
+ # server = [ [ userinfo "@" ] hostport ]
+ server = "(?:#{userinfo}@)?#{hostport}"
+ # reg_name = 1*( unreserved | escaped | "$" | "," |
+ # ";" | ":" | "@" | "&" | "=" | "+" )
+ ret[:REG_NAME] = reg_name = "(?:[#{unreserved}$,;:@&=+]|#{escaped})+"
+ # authority = server | reg_name
+ authority = "(?:#{server}|#{reg_name})"
+
+ # rel_segment = 1*( unreserved | escaped |
+ # ";" | "@" | "&" | "=" | "+" | "$" | "," )
+ ret[:REL_SEGMENT] = rel_segment = "(?:[#{unreserved};@&=+$,]|#{escaped})+"
+
+ # scheme = alpha *( alpha | digit | "+" | "-" | "." )
+ ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][\\-+.#{PATTERN::ALPHA}\\d]*"
+
+ # abs_path = "/" path_segments
+ ret[:ABS_PATH] = abs_path = "/#{path_segments}"
+ # rel_path = rel_segment [ abs_path ]
+ ret[:REL_PATH] = rel_path = "#{rel_segment}(?:#{abs_path})?"
+ # net_path = "//" authority [ abs_path ]
+ ret[:NET_PATH] = net_path = "//#{authority}(?:#{abs_path})?"
+
+ # hier_part = ( net_path | abs_path ) [ "?" query ]
+ ret[:HIER_PART] = hier_part = "(?:#{net_path}|#{abs_path})(?:\\?(?:#{query}))?"
+ # opaque_part = uric_no_slash *uric
+ ret[:OPAQUE_PART] = opaque_part = "#{uric_no_slash}#{uric}*"
+
+ # absoluteURI = scheme ":" ( hier_part | opaque_part )
+ ret[:ABS_URI] = abs_uri = "#{scheme}:(?:#{hier_part}|#{opaque_part})"
+ # relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
+ ret[:REL_URI] = rel_uri = "(?:#{net_path}|#{abs_path}|#{rel_path})(?:\\?#{query})?"
+
+ # Gem::URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+ ret[:URI_REF] = "(?:#{abs_uri}|#{rel_uri})?(?:##{fragment})?"
+
+ ret[:X_ABS_URI] = "
+ (#{scheme}): (?# 1: scheme)
+ (?:
+ (#{opaque_part}) (?# 2: opaque)
+ |
+ (?:(?:
+ //(?:
+ (?:(?:(#{userinfo})@)? (?# 3: userinfo)
+ (?:(#{host})(?::(\\d*))?))? (?# 4: host, 5: port)
+ |
+ (#{reg_name}) (?# 6: registry)
+ )
+ |
+ (?!//)) (?# XXX: '//' is the mark for hostport)
+ (#{abs_path})? (?# 7: path)
+ )(?:\\?(#{query}))? (?# 8: query)
+ )
+ (?:\\#(#{fragment}))? (?# 9: fragment)
+ "
+
+ ret[:X_REL_URI] = "
+ (?:
+ (?:
+ //
+ (?:
+ (?:(#{userinfo})@)? (?# 1: userinfo)
+ (#{host})?(?::(\\d*))? (?# 2: host, 3: port)
+ |
+ (#{reg_name}) (?# 4: registry)
+ )
+ )
+ |
+ (#{rel_segment}) (?# 5: rel_segment)
+ )?
+ (#{abs_path})? (?# 6: abs_path)
+ (?:\\?(#{query}))? (?# 7: query)
+ (?:\\#(#{fragment}))? (?# 8: fragment)
+ "
+
+ ret
+ end
+
+ # Constructs the default Hash of Regexp's.
+ def initialize_regexp(pattern)
+ ret = {}
+
+ # for Gem::URI::split
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
+
+ # for Gem::URI::extract
+ ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
+ ret[:ABS_URI_REF] = Regexp.new(pattern[:X_ABS_URI], Regexp::EXTENDED)
+ ret[:REL_URI_REF] = Regexp.new(pattern[:X_REL_URI], Regexp::EXTENDED)
+
+ # for Gem::URI::escape/unescape
+ ret[:ESCAPED] = Regexp.new(pattern[:ESCAPED])
+ ret[:UNSAFE] = Regexp.new("[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]")
+
+ # for Generic#initialize
+ ret[:SCHEME] = Regexp.new("\\A#{pattern[:SCHEME]}\\z")
+ ret[:USERINFO] = Regexp.new("\\A#{pattern[:USERINFO]}\\z")
+ ret[:HOST] = Regexp.new("\\A#{pattern[:HOST]}\\z")
+ ret[:PORT] = Regexp.new("\\A#{pattern[:PORT]}\\z")
+ ret[:OPAQUE] = Regexp.new("\\A#{pattern[:OPAQUE_PART]}\\z")
+ ret[:REGISTRY] = Regexp.new("\\A#{pattern[:REG_NAME]}\\z")
+ ret[:ABS_PATH] = Regexp.new("\\A#{pattern[:ABS_PATH]}\\z")
+ ret[:REL_PATH] = Regexp.new("\\A#{pattern[:REL_PATH]}\\z")
+ ret[:QUERY] = Regexp.new("\\A#{pattern[:QUERY]}\\z")
+ ret[:FRAGMENT] = Regexp.new("\\A#{pattern[:FRAGMENT]}\\z")
+
+ ret
+ end
+
+ # Returns +uri+ as-is if it is Gem::URI, or convert it to Gem::URI if it is
+ # a String.
+ def convert_to_uri(uri)
+ if uri.is_a?(Gem::URI::Generic)
+ uri
+ elsif uri = String.try_convert(uri)
+ parse(uri)
+ else
+ raise ArgumentError,
+ "bad argument (expected Gem::URI object or Gem::URI string)"
+ end
+ end
+
+ end # class Parser
+
+ # Backward compatibility for Gem::URI::REGEXP::PATTERN::*
+ RFC2396_Parser.new.pattern.each_pair do |sym, str|
+ unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false)
+ RFC2396_REGEXP::PATTERN.const_set(sym, str)
+ end
+ end
+end # module Gem::URI
diff --git a/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb b/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb
new file mode 100644
index 0000000000..3b6961abf6
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb
@@ -0,0 +1,206 @@
+# frozen_string_literal: true
+module Gem::URI
+ class RFC3986_Parser # :nodoc:
+ # Gem::URI defined in RFC3986
+ HOST = %r[
+ (?<IP-literal>\[(?:
+ (?<IPv6address>
+ (?:\h{1,4}:){6}
+ (?<ls32>\h{1,4}:\h{1,4}
+ | (?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)
+ \.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>)
+ )
+ | ::(?:\h{1,4}:){5}\g<ls32>
+ | \h{1,4}?::(?:\h{1,4}:){4}\g<ls32>
+ | (?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>
+ | (?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>
+ | (?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>
+ | (?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>
+ | (?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}
+ | (?:(?:\h{1,4}:){,6}\h{1,4})?::
+ )
+ | (?<IPvFuture>v\h++\.[!$&-.0-9:;=A-Z_a-z~]++)
+ )\])
+ | \g<IPv4address>
+ | (?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+)
+ ]x
+
+ USERINFO = /(?:%\h\h|[!$&-.0-9:;=A-Z_a-z~])*+/
+
+ SCHEME = %r[[A-Za-z][+\-.0-9A-Za-z]*+].source
+ SEG = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/])].source
+ SEG_NC = %r[(?:%\h\h|[!$&-.0-9;=@A-Z_a-z~])].source
+ FRAGMENT = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+].source
+
+ RFC3986_URI = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<Gem::URI>
+ (?<scheme>#{SCHEME}):
+ (?<hier-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")})
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/((?!/)\g<seg>++)?)
+ | (?<path-rootless>(?!/)\g<seg>++)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^\#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
+
+ RFC3986_relative_ref = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<relative-ref>
+ (?<relative-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")}(?<!/))?
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/\g<seg>*+)
+ | (?<path-noscheme>#{SEG_NC}++(?:/\g<seg>*+)?)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
+ attr_reader :regexp
+
+ def initialize
+ @regexp = default_regexp.each_value(&:freeze).freeze
+ end
+
+ def split(uri) #:nodoc:
+ begin
+ uri = uri.to_str
+ rescue NoMethodError
+ raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri.inspect}"
+ end
+ uri.ascii_only? or
+ raise InvalidURIError, "Gem::URI must be ascii only #{uri.dump}"
+ if m = RFC3986_URI.match(uri)
+ query = m["query"]
+ scheme = m["scheme"]
+ opaque = m["path-rootless"]
+ if opaque
+ opaque << "?#{query}" if query
+ [ scheme,
+ nil, # userinfo
+ nil, # host
+ nil, # port
+ nil, # registry
+ nil, # path
+ opaque,
+ nil, # query
+ m["fragment"]
+ ]
+ else # normal
+ [ scheme,
+ m["userinfo"],
+ m["host"],
+ m["port"],
+ nil, # registry
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-empty"]),
+ nil, # opaque
+ query,
+ m["fragment"]
+ ]
+ end
+ elsif m = RFC3986_relative_ref.match(uri)
+ [ nil, # scheme
+ m["userinfo"],
+ m["host"],
+ m["port"],
+ nil, # registry,
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-noscheme"] ||
+ m["path-empty"]),
+ nil, # opaque
+ m["query"],
+ m["fragment"]
+ ]
+ else
+ raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri.inspect}"
+ end
+ end
+
+ def parse(uri) # :nodoc:
+ Gem::URI.for(*self.split(uri), self)
+ end
+
+ def join(*uris) # :nodoc:
+ uris[0] = convert_to_uri(uris[0])
+ uris.inject :merge
+ end
+
+ # Compatibility for RFC2396 parser
+ def extract(str, schemes = nil, &block) # :nodoc:
+ warn "Gem::URI::RFC3986_PARSER.extract is obsolete. Use Gem::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.extract(str, schemes, &block)
+ end
+
+ # Compatibility for RFC2396 parser
+ def make_regexp(schemes = nil) # :nodoc:
+ warn "Gem::URI::RFC3986_PARSER.make_regexp is obsolete. Use Gem::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.make_regexp(schemes)
+ end
+
+ # Compatibility for RFC2396 parser
+ def escape(str, unsafe = nil) # :nodoc:
+ warn "Gem::URI::RFC3986_PARSER.escape is obsolete. Use Gem::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
+ unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
+ end
+
+ # Compatibility for RFC2396 parser
+ def unescape(str, escaped = nil) # :nodoc:
+ warn "Gem::URI::RFC3986_PARSER.unescape is obsolete. Use Gem::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
+ escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
+ end
+
+ @@to_s = Kernel.instance_method(:to_s)
+ if @@to_s.respond_to?(:bind_call)
+ def inspect
+ @@to_s.bind_call(self)
+ end
+ else
+ def inspect
+ @@to_s.bind(self).call
+ end
+ end
+
+ private
+
+ def default_regexp # :nodoc:
+ {
+ SCHEME: %r[\A#{SCHEME}\z]o,
+ USERINFO: %r[\A#{USERINFO}\z]o,
+ HOST: %r[\A#{HOST}\z]o,
+ ABS_PATH: %r[\A/#{SEG}*+\z]o,
+ REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
+ QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
+ FRAGMENT: %r[\A#{FRAGMENT}\z]o,
+ OPAQUE: %r[\A(?:[^/].*)?\z],
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
+ }
+ end
+
+ def convert_to_uri(uri)
+ if uri.is_a?(Gem::URI::Generic)
+ uri
+ elsif uri = String.try_convert(uri)
+ parse(uri)
+ else
+ raise ArgumentError,
+ "bad argument (expected Gem::URI object or Gem::URI string)"
+ end
+ end
+
+ end # class Parser
+end # module Gem::URI
diff --git a/lib/rubygems/vendor/uri/lib/uri/version.rb b/lib/rubygems/vendor/uri/lib/uri/version.rb
new file mode 100644
index 0000000000..7ee577887b
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/version.rb
@@ -0,0 +1,6 @@
+module Gem::URI
+ # :stopdoc:
+ VERSION = '1.1.1'.freeze
+ VERSION_CODE = VERSION.split('.').map{|s| s.rjust(2, '0')}.join.freeze
+ # :startdoc:
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/ws.rb b/lib/rubygems/vendor/uri/lib/uri/ws.rb
new file mode 100644
index 0000000000..0dd2a7a1bb
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/ws.rb
@@ -0,0 +1,83 @@
+# frozen_string_literal: false
+# = uri/ws.rb
+#
+# Author:: Matt Muller <mamuller@amazon.com>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'generic'
+
+module Gem::URI
+
+ #
+ # The syntax of WS URIs is defined in RFC6455 section 3.
+ #
+ # Note that the Ruby Gem::URI library allows WS URLs containing usernames and
+ # passwords. This is not legal as per the RFC, but used to be
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
+ # update. See <URL:http://support.microsoft.com/kb/834489>.
+ #
+ class WS < Generic
+ # A Default port of 80 for Gem::URI::WS.
+ DEFAULT_PORT = 80
+
+ # An Array of the available components for Gem::URI::WS.
+ COMPONENT = %i[
+ scheme
+ userinfo host port
+ path
+ query
+ ].freeze
+
+ #
+ # == Description
+ #
+ # Creates a new Gem::URI::WS object from components, with syntax checking.
+ #
+ # The components accepted are userinfo, host, port, path, and query.
+ #
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
+ #
+ # If an Array is used, the components must be passed in the
+ # order <code>[userinfo, host, port, path, query]</code>.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::WS.build(host: 'www.example.com', path: '/foo/bar')
+ #
+ # uri = Gem::URI::WS.build([nil, "www.example.com", nil, "/path", "query"])
+ #
+ # Currently, if passed userinfo components this method generates
+ # invalid WS URIs as per RFC 1738.
+ #
+ def self.build(args)
+ tmp = Util.make_components_hash(self, args)
+ super(tmp)
+ end
+
+ #
+ # == Description
+ #
+ # Returns the full path for a WS Gem::URI, as required by Net::HTTP::Get.
+ #
+ # If the Gem::URI contains a query, the full path is Gem::URI#path + '?' + Gem::URI#query.
+ # Otherwise, the path is simply Gem::URI#path.
+ #
+ # Example:
+ #
+ # uri = Gem::URI::WS.build(path: '/foo/bar', query: 'test=true')
+ # uri.request_uri # => "/foo/bar?test=true"
+ #
+ def request_uri
+ return unless @path
+
+ url = @query ? "#@path?#@query" : @path.dup
+ url.start_with?(?/.freeze) ? url : ?/ + url
+ end
+ end
+
+ register_scheme 'WS', WS
+end
diff --git a/lib/rubygems/vendor/uri/lib/uri/wss.rb b/lib/rubygems/vendor/uri/lib/uri/wss.rb
new file mode 100644
index 0000000000..0b91d334bb
--- /dev/null
+++ b/lib/rubygems/vendor/uri/lib/uri/wss.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: false
+# = uri/wss.rb
+#
+# Author:: Matt Muller <mamuller@amazon.com>
+# License:: You can redistribute it and/or modify it under the same term as Ruby.
+#
+# See Gem::URI for general documentation
+#
+
+require_relative 'ws'
+
+module Gem::URI
+
+ # The default port for WSS URIs is 443, and the scheme is 'wss:' rather
+ # than 'ws:'. Other than that, WSS URIs are identical to WS URIs;
+ # see Gem::URI::WS.
+ class WSS < WS
+ # A Default port of 443 for Gem::URI::WSS
+ DEFAULT_PORT = 443
+ end
+
+ register_scheme 'WSS', WSS
+end
diff --git a/lib/rubygems/vendored_net_http.rb b/lib/rubygems/vendored_net_http.rb
new file mode 100644
index 0000000000..a84c52a947
--- /dev/null
+++ b/lib/rubygems/vendored_net_http.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+# Ruby 3.3 and RubyGems 3.5 is already load Gem::Timeout from lib/rubygems/net/http.rb
+# We should avoid to load it again
+require_relative "vendor/net-http/lib/net/http" unless defined?(Gem::Net::HTTP)
diff --git a/lib/rubygems/vendored_optparse.rb b/lib/rubygems/vendored_optparse.rb
new file mode 100644
index 0000000000..a5611d32f0
--- /dev/null
+++ b/lib/rubygems/vendored_optparse.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+require_relative "vendor/optparse/lib/optparse"
diff --git a/lib/rubygems/vendored_pub_grub.rb b/lib/rubygems/vendored_pub_grub.rb
new file mode 100644
index 0000000000..844d243ab3
--- /dev/null
+++ b/lib/rubygems/vendored_pub_grub.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+require_relative "vendor/pub_grub/lib/pub_grub"
diff --git a/lib/rubygems/vendored_securerandom.rb b/lib/rubygems/vendored_securerandom.rb
new file mode 100644
index 0000000000..859b6d7d7a
--- /dev/null
+++ b/lib/rubygems/vendored_securerandom.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+require_relative "vendor/securerandom/lib/securerandom"
diff --git a/lib/rubygems/vendored_timeout.rb b/lib/rubygems/vendored_timeout.rb
new file mode 100644
index 0000000000..45541928e6
--- /dev/null
+++ b/lib/rubygems/vendored_timeout.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+# Ruby 3.3 and RubyGems 3.5 is already load Gem::Timeout from lib/rubygems/timeout.rb
+# We should avoid to load it again
+require_relative "vendor/timeout/lib/timeout" unless defined?(Gem::Timeout)
diff --git a/lib/rubygems/vendored_tsort.rb b/lib/rubygems/vendored_tsort.rb
new file mode 100644
index 0000000000..c3d815650d
--- /dev/null
+++ b/lib/rubygems/vendored_tsort.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+require_relative "vendor/tsort/lib/tsort"
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 307d429e74..306733c1d7 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -1,6 +1,9 @@
# frozen_string_literal: true
-require_relative "deprecate"
+#--
+# Workaround for directly loading Gem::Version in some cases
+module Gem; end
+#++
##
# The Version class processes string versions into comparable
@@ -27,142 +30,159 @@ require_relative "deprecate"
# 4. 0.9
#
# If you want to specify a version restriction that includes both prereleases
-# and regular releases of the 1.x series this is the best way:
+# and regular releases of 1.x or later versions:
#
-# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0'
+# s.add_dependency 'example', '>= 1.0.0.a'
#
# == How Software Changes
#
-# Users expect to be able to specify a version constraint that gives them
-# some reasonable expectation that new versions of a library will work with
-# their software if the version constraint is true, and not work with their
-# software if the version constraint is false. In other words, the perfect
-# system will accept all compatible versions of the library and reject all
-# incompatible versions.
-#
-# Libraries change in 3 ways (well, more than 3, but stay focused here!).
-#
-# 1. The change may be an implementation detail only and have no effect on
-# the client software.
-# 2. The change may add new features, but do so in a way that client software
-# written to an earlier version is still compatible.
-# 3. The change may change the public interface of the library in such a way
-# that old software is no longer compatible.
-#
-# Some examples are appropriate at this point. Suppose I have a Stack class
-# that supports a <tt>push</tt> and a <tt>pop</tt> method.
+# Libraries generally change in 3 ways:
#
-# === Examples of Category 1 changes:
+# 1. The change is an implementation detail, bug fix, security fix, or
+# optimization, and has no behavioral effect on the software using it.
#
-# * Switch from an array based implementation to a linked-list based
-# implementation.
-# * Provide an automatic (and transparent) backing store for large stacks.
+# 2. The change adds new features, and software using those new features is
+# not compatible with previous versions of the library, but software using
+# previous versions of the library is compatible with the change.
#
-# === Examples of Category 2 changes might be:
+# 3. The change modifies the public interface of some part of the library in
+# such a way that software that uses that part of the library must be
+# modified to work.
#
-# * Add a <tt>depth</tt> method to return the current depth of the stack.
-# * Add a <tt>top</tt> method that returns the current top of stack (without
-# changing the stack).
-# * Change <tt>push</tt> so that it returns the item pushed (previously it
-# had no usable return value).
-#
-# === Examples of Category 3 changes might be:
-#
-# * Changes <tt>pop</tt> so that it no longer returns a value (you must use
-# <tt>top</tt> to get the top of the stack).
-# * Rename the methods to <tt>push_item</tt> and <tt>pop_item</tt>.
-#
-# == RubyGems Rational Versioning
+# == RubyGems Rational Versioning (the recommended approach)
#
# * Versions shall be represented by three non-negative integers, separated
-# by periods (e.g. 3.1.4). The first integers is the "major" version
+# by periods (e.g. 3.1.4). The first integer is the "major" version
# number, the second integer is the "minor" version number, and the third
-# integer is the "build" number.
+# integer is the "patch" version number.
#
-# * A category 1 change (implementation detail) will increment the build
-# number.
+# * A category 1 change (implementation detail, bug fix, or security fix)
+# will increment the patch number.
#
# * A category 2 change (backwards compatible) will increment the minor
-# version number and reset the build number.
-#
-# * A category 3 change (incompatible) will increment the major build number
-# and reset the minor and build numbers.
-#
-# * Any "public" release of a gem should have a different version. Normally
-# that means incrementing the build number. This means a developer can
-# generate builds all day long, but as soon as they make a public release,
-# the version must be updated.
-#
-# === Examples
-#
-# Let's work through a project lifecycle using our Stack example from above.
+# version number and reset the patch number.
#
-# Version 0.0.1:: The initial Stack class is release.
-# Version 0.0.2:: Switched to a linked=list implementation because it is
-# cooler.
-# Version 0.1.0:: Added a <tt>depth</tt> method.
-# Version 1.0.0:: Added <tt>top</tt> and made <tt>pop</tt> return nil
-# (<tt>pop</tt> used to return the old top item).
-# Version 1.1.0:: <tt>push</tt> now returns the value pushed (it used it
-# return nil).
-# Version 1.1.1:: Fixed a bug in the linked list implementation.
-# Version 1.1.2:: Fixed a bug introduced in the last fix.
+# * A category 3 change (incompatible) will increment the major version number
+# and reset the minor and patch numbers.
#
-# Client A needs a stack with basic push/pop capability. They write to the
-# original interface (no <tt>top</tt>), so their version constraint looks like:
+# * Any "public" release of a gem should have a different version.
#
-# gem 'stack', '>= 0.0'
+# == Optimistic Vs. Pessimistic Dependency Versioning
#
-# Essentially, any version is OK with Client A. An incompatible change to
-# the library will cause them grief, but they are willing to take the chance
-# (we call Client A optimistic).
-#
-# Client B is just like Client A except for two things: (1) They use the
-# <tt>depth</tt> method and (2) they are worried about future
-# incompatibilities, so they write their version constraint like this:
-#
-# gem 'stack', '~> 0.1'
-#
-# The <tt>depth</tt> method was introduced in version 0.1.0, so that version
-# or anything later is fine, as long as the version stays below version 1.0
-# where incompatibilities are introduced. We call Client B pessimistic
-# because they are worried about incompatible future changes (it is OK to be
-# pessimistic!).
-#
-# == Preventing Version Catastrophe:
-#
-# From: http://blog.zenspider.com/2008/10/rubygems-howto-preventing-cata.html
-#
-# Let's say you're depending on the fnord gem version 2.y.z. If you
-# specify your dependency as ">= 2.0.0" then, you're good, right? What
-# happens if fnord 3.0 comes out and it isn't backwards compatible
-# with 2.y.z? Your stuff will break as a result of using ">=". The
-# better route is to specify your dependency with an "approximate" version
-# specifier ("~>"). They're a tad confusing, so here is how the dependency
-# specifiers work:
-#
-# Specification From ... To (exclusive)
-# ">= 3.0" 3.0 ... &infin;
-# "~> 3.0" 3.0 ... 4.0
-# "~> 3.0.0" 3.0.0 ... 3.1
-# "~> 3.5" 3.5 ... 4.0
-# "~> 3.5.0" 3.5.0 ... 3.6
-# "~> 3" 3.0 ... 4.0
-#
-# For the last example, single-digit versions are automatically extended with
-# a zero to give a sensible result.
+# Users expect to be able to specify a version constraint that gives them
+# a reasonable expectation that new versions of a library will work with
+# their software if the version constraint is true, and not work with their
+# software if the version constraint is false. In other words, the perfect
+# system will accept all compatible versions of the library and reject all
+# incompatible versions. Unfortunately, there is no perfect system, as you
+# cannot predict the future. You can never know whether a future version of
+# a library will contain which type of change.
+#
+# There are two common outlooks on dependency versioning:
+#
+# 1. Optimistic. This does not set an upper bound on a dependency. It is
+# possible that a future version of a dependency will break the software,
+# and in that case, the dependency version will need to be updated and
+# changes will need to be made.
+#
+# 2. Pessimistic. This assumes all major version changes of a dependency will
+# break the software, and that patch or minor changes of a dependency will
+# not break the software. If there is a major version of a dependency
+# released, the dependency version must be updated in order to use it, even
+# if no code changes are actually needed.
+#
+# In general, optimistic versioning is superior to pessimistic versioning.
+# Pessimistic versioning is often wrong in both directions. Dependencies can
+# release patch or minor versions that contain incompatibilities. One
+# common reason is that a security fix may require a backwards-incompatible API
+# change. In this case, even though pessimistic versioning was used, it
+# didn't even save effort, as you still need to make code changes and adjust
+# dependency versions. Similarly, for all but the smallest dependencies, just
+# because the dependency made a backwards incompatible change to one interface
+# doesn't mean the dependency made a backwards incompatible change to an
+# interface that the software is using. It is a common problem that a
+# dependency will release a new major version and the software does not require
+# any changes in order to use it. In this case, being pessimistic results in
+# additional work for no benefit.
+#
+# When a library uses pessimistic versioning of dependencies, it causes
+# significant problems if that library is not diligent about updating
+# dependency versions and any library is depending on that library.
+# For example:
+#
+# * Library A is currently on release 1.2.3.
+#
+# * Library B is at version 2.3.4 and has a pessimistic dependency on
+# library A, using ~> 1.0 (>= 1.0, < 2).
+#
+# * Library C is at version 3.4.5 and has an optimistic dependency on
+# library A, using >= 1.0.
+#
+# * Library D has optimistic dependencies on both libraries B and C.
+#
+# * Library A releases a new major version, 2.0.0, with new features, which
+# is mostly backwards compatible, but does contain some backwards
+# incompatible changes.
+#
+# * Library B would work with A 2.0.0, but cannot use it due to pessimistic
+# versioning.
+#
+# * Library C wants to use the new features in the major release of library
+# A to implement its own new features, so it does so, bumps the
+# dependency version of A to >= 2.0, and releases version 3.5.0.
+#
+# * Library D cannot upgrade to the new version of library C, because it
+# depends on library B, which has a pessimistic dependency on library A.
+#
+# * Library C releases a security fix patch version 3.5.1 to fix a
+# vulnerability present in all previous versions.
+#
+# * Library D is now in a terrible situation. It cannot upgrade to library
+# C 3.5.1, as that requires library A > 2.0, because it depends on library
+# B, which requires library A > 1.0, < 2, even though library B would work
+# fine with library A 2.0.0.
+#
+# This type of situation brought on by pessimistic versioning is unfortunately
+# both common and serious in practice.
+#
+# This is not to say that optimistic versioning never causes a problem.
+# However, with optimistic versioning, if there is a problem, it can be solved
+# with the addition of a single dependency. For example, continuing the
+# previous example:
+#
+# * Library A releases a new major version, 3.0.0, which makes backwards
+# incompatible changes that break library C.
+#
+# * Until library C releases an updated version with new changes, library
+# D only needs to set a specific dependency on library A for > 2.0, < 3,
+# until library C is updated to work with the new version of library A.
+#
+# Both optimistic versioning and pessimistic versioning have problems in
+# certain cases. However, it's significantly easier to fix optimistic
+# versioning problems than to fix pessimistic versioning problems.
+#
+# That is not to say that pessimistic versioning is never appropriate. If the
+# dependency is a library that adds a single method, where any change resulting
+# in a major version bump would probably break a library using it, then using
+# pessimistic versioning may be warranted. Additionally, if a dependency has
+# already announced or committed backwards incompatible changes that would
+# break a library's use of it, then having that library use a pessimistic
+# version constraint would likely be warranted. However, outside of
+# specific situations, you should avoid using pessimistic versioning, as the
+# costs typically exceed the benefits.
class Gem::Version
include Comparable
VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?' # :nodoc:
- ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/.freeze # :nodoc:
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc:
+ RADIX_OPT = [9_500, 3_500, 260_000, 22_227, 24].freeze # :nodoc:
##
# A string representation of this Version.
def version
- @version.dup
+ @version
end
alias_method :to_s, :version
@@ -171,9 +191,7 @@ class Gem::Version
# True if the +version+ string matches RubyGems' requirements.
def self.correct?(version)
- nil_versions_are_discouraged! if version.nil?
-
- !!(version.to_s =~ ANCHORED_VERSION_PATTERN)
+ version.nil? || ANCHORED_VERSION_PATTERN.match?(version.to_s)
end
##
@@ -182,15 +200,10 @@ class Gem::Version
#
# ver1 = Version.create('1.3.17') # -> (Version object)
# ver2 = Version.create(ver1) # -> (ver1)
- # ver3 = Version.create(nil) # -> nil
def self.create(input)
if self === input # check yourself before you wreck yourself
input
- elsif input.nil?
- nil_versions_are_discouraged!
-
- nil
else
new input
end
@@ -201,19 +214,11 @@ class Gem::Version
@@release = {}
def self.new(version) # :nodoc:
- return super unless Gem::Version == self
+ return super unless self == Gem::Version
@@all[version] ||= super
end
- def self.nil_versions_are_discouraged!
- unless Gem::Deprecate.skip
- warn "nil versions are discouraged and will be deprecated in Rubygems 4"
- end
- end
-
- private_class_method :nil_versions_are_discouraged!
-
##
# Constructs a Version from the +version+ string. A version string is a
# series of digits or ASCII letters separated by dots.
@@ -224,10 +229,19 @@ class Gem::Version
end
# If version is an empty string convert it to 0
- version = 0 if version.is_a?(String) && version =~ /\A\s*\Z/
+ version = 0 if version.nil? || (version.is_a?(String) && /\A\s*\Z/.match?(version))
+
+ @version = version.to_s
- @version = version.to_s.strip.gsub("-",".pre.")
+ # optimization to avoid allocation when given an integer, since we know
+ # it's to_s won't have any spaces or dashes
+ unless version.is_a?(Integer)
+ @version = @version.strip
+ @version.gsub!("-",".pre.")
+ end
+ @version = -@version
@segments = nil
+ @sort_key = compute_sort_key
end
##
@@ -252,7 +266,7 @@ class Gem::Version
# same precision. Version "1.0" is not the same as version "1".
def eql?(other)
- self.class === other && @version == other._version
+ self.class === other && @version == other.version
end
def hash # :nodoc:
@@ -280,19 +294,18 @@ class Gem::Version
# 1.3.5 and earlier) compatibility.
def marshal_load(array)
- initialize array[0]
+ string = array[0]
+ raise TypeError, "wrong version string" unless string.is_a?(String)
+
+ initialize string
end
def yaml_initialize(tag, map) # :nodoc:
- @version = map["version"]
+ @version = -map["version"]
@segments = nil
@hash = nil
end
- def to_yaml_properties # :nodoc:
- ["@version"]
- end
-
def encode_with(coder) # :nodoc:
coder.add "version", @version
end
@@ -302,7 +315,7 @@ class Gem::Version
def prerelease?
unless instance_variable_defined? :@prerelease
- @prerelease = !!(@version =~ /[a-zA-Z]/)
+ @prerelease = /[a-zA-Z]/.match?(version)
end
@prerelease
end
@@ -330,7 +343,7 @@ class Gem::Version
end
##
- # A recommended version for use with a ~> Requirement.
+ # A recommended version for use with a >= Requirement.
def approximate_recommendation
segments = self.segments
@@ -339,7 +352,7 @@ class Gem::Version
segments.pop while segments.size > 2
segments.push 0 while segments.size < 2
- recommendation = "~> #{segments.join(".")}"
+ recommendation = ">= #{segments.join(".")}"
recommendation += ".a" if prerelease?
recommendation
end
@@ -347,72 +360,113 @@ class Gem::Version
##
# Compares this version with +other+ returning -1, 0, or 1 if the
# other version is larger, the same, or smaller than this
- # one. Attempts to compare to something that's not a
- # <tt>Gem::Version</tt> or a valid version String return +nil+.
+ # one. +other+ must be an instance of Gem::Version, comparing with
+ # other types may raise an exception.
def <=>(other)
- return self <=> self.class.new(other) if (String === other) && self.class.correct?(other)
-
- return unless Gem::Version === other
- return 0 if @version == other._version || canonical_segments == other.canonical_segments
-
- lhsegments = canonical_segments
- rhsegments = other.canonical_segments
-
- lhsize = lhsegments.size
- rhsize = rhsegments.size
- limit = (lhsize > rhsize ? lhsize : rhsize) - 1
-
- i = 0
-
- while i <= limit
- lhs = lhsegments[i] || 0
- rhs = rhsegments[i] || 0
- i += 1
-
- next if lhs == rhs
- return -1 if String === lhs && Numeric === rhs
- return 1 if Numeric === lhs && String === rhs
-
- return lhs <=> rhs
+ if Gem::Version === other
+ # Fast path for comparison when available.
+ if @sort_key && other.sort_key
+ return @sort_key <=> other.sort_key
+ end
+
+ return 0 if @version == other.version || canonical_segments == other.canonical_segments
+
+ lhsegments = canonical_segments
+ rhsegments = other.canonical_segments
+
+ lhsize = lhsegments.size
+ rhsize = rhsegments.size
+ limit = (lhsize > rhsize ? rhsize : lhsize)
+
+ i = 0
+
+ while i < limit
+ lhs = lhsegments[i]
+ rhs = rhsegments[i]
+ i += 1
+
+ next if lhs == rhs
+ return -1 if String === lhs && Numeric === rhs
+ return 1 if Numeric === lhs && String === rhs
+
+ return lhs <=> rhs
+ end
+
+ lhs = lhsegments[i]
+
+ if lhs.nil?
+ rhs = rhsegments[i]
+
+ while i < rhsize
+ return 1 if String === rhs
+ return -1 unless rhs.zero?
+ rhs = rhsegments[i += 1]
+ end
+ else
+ while i < lhsize
+ return -1 if String === lhs
+ return 1 unless lhs.zero?
+ lhs = lhsegments[i += 1]
+ end
+ end
+
+ 0
+ elsif String === other
+ return unless self.class.correct?(other)
+ self <=> self.class.new(other)
end
-
- return 0
end
+ # remove trailing zeros segments before first letter or at the end of the version
def canonical_segments
- @canonical_segments ||=
- _split_segments.map! do |segments|
- segments.reverse_each.drop_while {|s| s == 0 }.reverse
- end.reduce(&:concat)
+ @canonical_segments ||= begin
+ # remove trailing 0 segments, using dot or letter as anchor
+ # may leave a trailing dot which will be ignored by partition_segments
+ canonical_version = @version.sub(/(?<=[a-zA-Z.])[.0]+\z/, "")
+ # remove 0 segments before the first letter in a prerelease version
+ canonical_version.sub!(/(?<=\.|\A)[0.]+(?=[a-zA-Z])/, "") if prerelease?
+ partition_segments(canonical_version)
+ end
end
def freeze
prerelease?
+ _segments
canonical_segments
super
end
protected
- def _version
- @version
+ attr_reader :sort_key # :nodoc:
+
+ def compute_sort_key
+ return if prerelease?
+
+ segments = canonical_segments
+ return if segments.size > 5
+
+ key = 0
+ RADIX_OPT.each_with_index do |radix, i|
+ seg = segments.fetch(i, 0)
+ return nil if seg >= radix
+ key = key * radix + seg
+ end
+
+ key
end
def _segments
# segments is lazy so it can pick up version values that come from
# old marshaled versions, which don't go through marshal_load.
# since this version object is cached in @@all, its @segments should be frozen
-
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
- /^\d+$/ =~ s ? s.to_i : s
- end.freeze
+ @segments ||= partition_segments(@version)
end
- def _split_segments
- string_start = _segments.index {|s| s.is_a?(String) }
- string_segments = segments
- numeric_segments = string_segments.slice!(0, string_start || string_segments.size)
- return numeric_segments, string_segments
+ def partition_segments(ver)
+ ver.scan(/\d+|[a-z]+/i).map! do |s|
+ /\A\d/.match?(s) ? s.to_i : -s
+ end.freeze
end
end
diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb
index 538433f640..7910fd3d1b 100644
--- a/lib/rubygems/version_option.rb
+++ b/lib/rubygems/version_option.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/win_platform.rb b/lib/rubygems/win_platform.rb
new file mode 100644
index 0000000000..10556871b2
--- /dev/null
+++ b/lib/rubygems/win_platform.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require "rbconfig"
+
+module Gem
+ ##
+ # An Array of Regexps that match windows Ruby platforms.
+
+ WIN_PATTERNS = [
+ /bccwin/i,
+ /djgpp/i,
+ /mingw/i,
+ /mswin/i,
+ /wince/i,
+ ].freeze
+
+ @@win_platform = nil
+
+ ##
+ # Is this a windows platform?
+
+ def self.win_platform?
+ if @@win_platform.nil?
+ ruby_platform = RbConfig::CONFIG["host_os"]
+ @@win_platform = !WIN_PATTERNS.find {|r| ruby_platform =~ r }.nil?
+ end
+
+ @@win_platform
+ end
+end
diff --git a/lib/rubygems/yaml_serializer.rb b/lib/rubygems/yaml_serializer.rb
new file mode 100644
index 0000000000..b2547b136b
--- /dev/null
+++ b/lib/rubygems/yaml_serializer.rb
@@ -0,0 +1,845 @@
+# frozen_string_literal: true
+
+unless defined?(Psych::VERSION)
+ module Psych
+ class Exception < ::RuntimeError; end
+ class SyntaxError < Exception; end
+ class DisallowedClass < Exception; end
+ class BadAlias < Exception; end
+ class AliasesNotEnabled < BadAlias; end
+ end
+end
+
+module Gem
+ module YAMLSerializer
+ Scalar = Struct.new(:value, :tag, :anchor, keyword_init: true)
+
+ Mapping = Struct.new(:pairs, :tag, :anchor, keyword_init: true) do
+ def initialize(pairs: [], tag: nil, anchor: nil)
+ super
+ end
+ end
+
+ Sequence = Struct.new(:items, :tag, :anchor, keyword_init: true) do
+ def initialize(items: [], tag: nil, anchor: nil)
+ super
+ end
+ end
+
+ AliasRef = Struct.new(:name, keyword_init: true)
+
+ class Parser
+ MAPPING_KEY_RE = /^((?:[^#:]|:[^ ])+):(?:[ ]+(.*))?$/
+ MAX_NESTING_DEPTH = 1_000
+
+ def initialize(source)
+ @lines = source.split("\n")
+ @anchors = {}
+ @depth = 0
+ strip_document_prefix
+ end
+
+ def parse
+ return nil if @lines.empty?
+
+ root = nil
+ while @lines.any?
+ before = @lines.size
+ node = parse_node(-1)
+ @lines.shift if @lines.size == before && @lines.any?
+
+ if root.is_a?(Mapping) && node.is_a?(Mapping)
+ root.pairs.concat(node.pairs)
+ elsif root.nil?
+ root = node
+ end
+ end
+ root
+ end
+
+ private
+
+ def strip_document_prefix
+ return if @lines.empty?
+ return unless @lines[0]&.start_with?("---")
+
+ if @lines[0].strip == "---"
+ @lines.shift
+ else
+ @lines[0] = @lines[0].sub(/^---\s*/, "")
+ end
+ end
+
+ def parse_node(base_indent)
+ @depth += 1
+ raise_max_nesting! if @depth > MAX_NESTING_DEPTH
+
+ skip_blank_and_comments
+ return nil if @lines.empty?
+
+ line = @lines[0]
+ stripped = line.lstrip
+ indent = line.size - stripped.size
+ return nil if indent < base_indent
+
+ return parse_alias_ref if stripped.start_with?("*")
+
+ anchor = consume_anchor
+
+ if anchor
+ line = @lines[0]
+ stripped = line.lstrip
+ end
+
+ if stripped.start_with?("- ") || stripped == "-"
+ parse_sequence(indent, anchor)
+ elsif stripped.start_with?("\"") && stripped.end_with?("\"")
+ # We don't need to care about the following case here:
+ # 1. "value with comment" # ...
+ # 2. "key": "value"
+ #
+ # 1. must not happen because YAMLSerializer doesn't emit any
+ # comment. YAMLSerializer parses only YAML that is generated
+ # by YAMLSerializer.
+ #
+ # 2. must not happen because #parse_node isn't used non
+ # top-level mapping. Non top-level mapping always uses
+ # #parse_mapping. Top-level mapping never use the '"key":
+ # "value"' form because all top-level keys
+ # ("!ruby/object:Gem::Specification"'s keys) are known and
+ # #emit_specification doesn't quote anything.
+ parse_plain_scalar(indent, anchor)
+ elsif stripped.start_with?("'") && stripped.end_with?("'")
+ # See also the above note for double quotation.
+ parse_plain_scalar(indent, anchor)
+ elsif stripped =~ MAPPING_KEY_RE && !stripped.start_with?("!ruby/object:")
+ parse_mapping(indent, anchor)
+ elsif stripped.start_with?("!ruby/object:")
+ parse_tagged_node(indent, anchor)
+ elsif stripped.start_with?("|")
+ modifier = stripped[1..].to_s.strip
+ @lines.shift
+ register_anchor(anchor, Scalar.new(value: parse_block_scalar(indent, modifier)))
+ else
+ parse_plain_scalar(indent, anchor)
+ end
+ ensure
+ @depth -= 1
+ end
+
+ def parse_sequence(indent, anchor)
+ items = []
+ while @lines.any?
+ line = @lines[0]
+ stripped = line.lstrip
+ break unless line.size - stripped.size == indent &&
+ (stripped.start_with?("- ") || stripped == "-")
+ content = @lines.shift.lstrip[1..].strip
+ item_anchor, content = extract_item_anchor(content)
+ item = parse_sequence_item(content, indent)
+ items << register_anchor(item_anchor, item)
+ end
+ register_anchor(anchor, Sequence.new(items: items))
+ end
+
+ def parse_sequence_item(content, indent)
+ if content.start_with?("*")
+ parse_inline_alias(content)
+ elsif content.empty?
+ @lines.any? && current_indent > indent ? parse_node(indent) : nil
+ elsif content.start_with?("!ruby/object:")
+ parse_tagged_content(content.strip, indent)
+ elsif content.start_with?("!binary ")
+ parse_binary_value(content, indent)
+ elsif content.start_with?("-")
+ @lines.unshift("#{" " * (indent + 2)}#{content}")
+ parse_node(indent)
+ elsif content =~ MAPPING_KEY_RE && !content.start_with?("!ruby/object:")
+ @lines.unshift("#{" " * (indent + 2)}#{content}")
+ parse_node(indent)
+ elsif content.start_with?("|")
+ Scalar.new(value: parse_block_scalar(indent, content[1..].to_s.strip))
+ else
+ parse_inline_scalar(content, indent)
+ end
+ end
+
+ def parse_mapping(indent, anchor)
+ pairs = []
+ while @lines.any?
+ line = @lines[0]
+ stripped = line.lstrip
+ break unless line.size - stripped.size == indent &&
+ stripped =~ MAPPING_KEY_RE && !stripped.start_with?("!ruby/object:")
+ key = $1.strip
+ @lines.shift
+ val = strip_comment($2.to_s.strip)
+
+ key = decode_binary_tag(key) if key.start_with?("!binary ")
+
+ val_anchor, val = consume_value_anchor(val)
+ value = parse_mapping_value(val, indent)
+ value = register_anchor(val_anchor, value) if val_anchor
+
+ pairs << [Scalar.new(value: key), value]
+ end
+ register_anchor(anchor, Mapping.new(pairs: pairs))
+ end
+
+ def parse_mapping_value(val, indent)
+ if val.start_with?("*")
+ parse_inline_alias(val)
+ elsif val.start_with?("!ruby/object:")
+ parse_tagged_content(val.strip, indent)
+ elsif val.start_with?("!binary ")
+ parse_binary_value(val, indent)
+ elsif val.empty?
+ next_stripped = nil
+ next_indent = nil
+ if @lines.any?
+ next_stripped = @lines[0].lstrip
+ next_indent = @lines[0].size - next_stripped.size
+ end
+ if next_stripped &&
+ (next_stripped.start_with?("- ") || next_stripped == "-") &&
+ next_indent == indent
+ parse_node(indent)
+ else
+ parse_node(indent + 1)
+ end
+ elsif val == "[]"
+ Sequence.new
+ elsif val == "{}"
+ Mapping.new
+ elsif val.start_with?("|")
+ Scalar.new(value: parse_block_scalar(indent, val[1..].to_s.strip))
+ else
+ parse_inline_scalar(val, indent)
+ end
+ end
+
+ def parse_tagged_node(indent, anchor)
+ tag = @lines.shift.strip
+ nested = parse_node(indent)
+ apply_tag(nested, tag, anchor)
+ end
+
+ def parse_tagged_content(tag, indent)
+ nested = parse_node(indent)
+ apply_tag(nested, tag, nil)
+ end
+
+ def apply_tag(node, tag, anchor)
+ if node.is_a?(Mapping)
+ node.tag = tag
+ node.anchor = anchor
+ node
+ else
+ Mapping.new(pairs: [[Scalar.new(value: "value"), node]], tag: tag, anchor: anchor)
+ end
+ end
+
+ def parse_block_scalar(base_indent, modifier)
+ parts = []
+ block_indent = nil
+
+ while @lines.any?
+ line = @lines[0]
+ if line.strip.empty?
+ parts << "\n"
+ @lines.shift
+ else
+ line_indent = line.size - line.lstrip.size
+ break if line_indent <= base_indent
+ block_indent ||= line_indent
+ parts << @lines.shift[block_indent..].to_s << "\n"
+ end
+ end
+
+ res = parts.join
+ res.chomp! if modifier == "-" && res.end_with?("\n")
+ res
+ end
+
+ def parse_plain_scalar(indent, anchor)
+ result = coerce(@lines.shift.strip)
+ return register_anchor(anchor, result) if result.is_a?(Mapping) || result.is_a?(Sequence)
+
+ while result.is_a?(String) && @lines.any? &&
+ !@lines[0].strip.empty? && current_indent > indent
+ result << " " << @lines.shift.strip
+ end
+ register_anchor(anchor, Scalar.new(value: result))
+ end
+
+ def parse_inline_scalar(val, indent)
+ result = coerce(val)
+ return result if result.is_a?(Mapping) || result.is_a?(Sequence)
+
+ while result.is_a?(String) && @lines.any? &&
+ !@lines[0].strip.empty? && current_indent > indent
+ result << " " << @lines.shift.strip
+ end
+ Scalar.new(value: result)
+ end
+
+ def coerce(val, depth = 0)
+ raise_max_nesting! if depth > MAX_NESTING_DEPTH
+
+ val = val.sub(/^! /, "") if val.start_with?("! ")
+
+ if val =~ /^"(.*)"$/
+ $1.gsub(/\\["nrt\\]/) do |m|
+ case m
+ when '\\"' then '"'
+ when "\\n" then "\n"
+ when "\\r" then "\r"
+ when "\\t" then "\t"
+ when "\\\\" then "\\"
+ end
+ end
+ elsif val =~ /^'(.*)'$/
+ $1.gsub(/''/, "'")
+ elsif val == "true"
+ true
+ elsif val == "false"
+ false
+ elsif ["~", "null"].include?(val)
+ nil
+ elsif val == "{}"
+ Mapping.new
+ elsif val =~ /^\[(.*)\]$/
+ inner = $1.strip
+ return Sequence.new if inner.empty?
+ items = inner.split(/\s*,\s*/).reject(&:empty?).map {|e| Scalar.new(value: coerce(e, depth + 1)) }
+ Sequence.new(items: items)
+ elsif /\A\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}:\d{2})?/.match?(val)
+ begin
+ Time.new(val)
+ rescue ArgumentError
+ # date-only format like "2024-06-15" is not supported by Time.new
+ if /\A(\d{4})-(\d{2})-(\d{2})\z/.match(val)
+ Time.utc($1.to_i, $2.to_i, $3.to_i)
+ else
+ val
+ end
+ end
+ elsif /^-?\d+$/.match?(val)
+ val.to_i
+ else
+ val
+ end
+ end
+
+ def decode_binary_tag(str)
+ content = str.sub(/\A!binary\s+/, "")
+ content = $1 if content =~ /\A"(.*)"\z/ || content =~ /\A'(.*)'\z/
+ content.unpack1("m")
+ end
+
+ def parse_binary_value(val, indent)
+ rest = val.sub(/\A!binary\s+/, "")
+ if rest.start_with?("|")
+ content = parse_block_scalar(indent, rest[1..].to_s.strip)
+ Scalar.new(value: content.unpack1("m"))
+ else
+ Scalar.new(value: decode_binary_tag(val))
+ end
+ end
+
+ def parse_alias_ref
+ AliasRef.new(name: @lines.shift.lstrip[1..].strip)
+ end
+
+ def parse_inline_alias(content)
+ AliasRef.new(name: content[1..].strip)
+ end
+
+ def current_indent
+ line = @lines[0]
+ line.size - line.lstrip.size
+ end
+
+ def consume_anchor
+ line = @lines[0]
+ stripped = line.lstrip
+ return nil unless stripped.start_with?("&") && stripped =~ /^&(\S+)\s+/
+
+ anchor = $1
+ @lines[0] = line.sub(/&#{Regexp.escape(anchor)}\s+/, "")
+ anchor
+ end
+
+ def extract_item_anchor(content)
+ return [nil, content] unless content =~ /^&(\S+)/
+
+ anchor = $1
+ [anchor, content.sub(/^&#{Regexp.escape(anchor)}\s*/, "")]
+ end
+
+ def consume_value_anchor(val)
+ return [nil, val] unless val =~ /^&(\S+)\s+/
+
+ anchor = $1
+ [anchor, val.sub(/^&#{Regexp.escape(anchor)}\s+/, "")]
+ end
+
+ def register_anchor(name, node)
+ if name
+ @anchors[name] = node
+ node.anchor = name if node.respond_to?(:anchor=)
+ end
+ node
+ end
+
+ def raise_max_nesting!
+ message = "exceeded maximum nesting depth (#{MAX_NESTING_DEPTH})"
+ if defined?(Psych::VERSION)
+ raise Psych::SyntaxError.new(nil, 0, 0, 0, message, nil)
+ else
+ raise Psych::SyntaxError, message
+ end
+ end
+
+ def skip_blank_and_comments
+ while @lines.any?
+ line = @lines[0]
+ stripped = line.lstrip
+ break unless stripped.empty? || stripped.start_with?("#")
+ @lines.shift
+ end
+ end
+
+ def strip_comment(val)
+ return val unless val.include?("#")
+ return val if val.lstrip.start_with?("#")
+
+ in_single = false
+ in_double = false
+ escape = false
+
+ val.each_char.with_index do |ch, i|
+ if escape
+ escape = false
+ next
+ end
+
+ if in_single
+ in_single = false if ch == "'"
+ elsif in_double
+ if ch == "\\"
+ escape = true
+ elsif ch == '"'
+ in_double = false
+ end
+ else
+ case ch
+ when "'" then in_single = true
+ when '"' then in_double = true
+ when "#" then return val[0...i].rstrip
+ end
+ end
+ end
+
+ val
+ end
+ end
+
+ class Builder
+ VALID_OPS = %w[= != > < >= <= ~>].freeze
+ ARRAY_FIELDS = %w[files test_files executables extra_rdoc_files].freeze
+ MAX_ALIAS_RESOLUTIONS = 1_000
+
+ def initialize(permitted_classes: [], permitted_symbols: [], aliases: true)
+ @permitted_classes = permitted_classes.map {|c| "!ruby/object:#{c}" }
+ @permitted_symbols = permitted_symbols
+ @aliases = aliases
+ @anchor_values = {}
+ @alias_count = 0
+ end
+
+ def build(node)
+ return nil if node.nil?
+
+ result = build_node(node)
+
+ if result.is_a?(Hash) && result[:tag] == "!ruby/object:Gem::Specification"
+ build_specification(result)
+ else
+ result
+ end
+ end
+
+ private
+
+ def build_node(node)
+ case node
+ when nil then nil
+ when AliasRef then resolve_alias(node)
+ when Scalar then store_anchor(node.anchor, node.value)
+ when Mapping then build_mapping(node)
+ when Sequence then store_anchor(node.anchor, node.items.map {|item| build_node(item) })
+ else node # already a Ruby object
+ end
+ end
+
+ def resolve_alias(node)
+ raise Psych::AliasesNotEnabled unless @aliases
+ @alias_count += 1
+ if @alias_count > MAX_ALIAS_RESOLUTIONS
+ raise Psych::BadAlias, "exceeded maximum alias resolutions (#{MAX_ALIAS_RESOLUTIONS})"
+ end
+ unless @anchor_values.key?(node.name)
+ klass = defined?(Psych::AnchorNotDefined) ? Psych::AnchorNotDefined : Psych::BadAlias
+ raise klass, "An alias referenced an unknown anchor: #{node.name}"
+ end
+ @anchor_values.fetch(node.name)
+ end
+
+ def store_anchor(name, value)
+ @anchor_values[name] = value if name
+ value
+ end
+
+ def build_mapping(node)
+ validate_tag!(node.tag) if node.tag
+
+ result = case node.tag
+ when "!ruby/object:Gem::Version"
+ build_version(node)
+ when "!ruby/object:Gem::Platform"
+ build_platform(node)
+ when "!ruby/object:Gem::Requirement", "!ruby/object:Gem::Version::Requirement"
+ build_requirement(node)
+ when "!ruby/object:Gem::Dependency"
+ build_dependency(node)
+ when nil
+ build_hash(node)
+ when "!ruby/object:Gem::Specification"
+ hash = build_hash(node)
+ hash[:tag] = node.tag
+ hash
+ else
+ raise ArgumentError, "undefined class/module #{node.tag.sub("!ruby/object:", "")}"
+ end
+
+ store_anchor(node.anchor, result)
+ end
+
+ def build_hash(node)
+ result = {}
+ node.pairs.each do |key_node, value_node|
+ key = key_node.is_a?(Scalar) ? key_node.value.to_s : build_node(key_node).to_s
+ value = build_node(value_node)
+
+ if ARRAY_FIELDS.include?(key)
+ value = normalize_array_field(value)
+ end
+
+ result[key] = value
+ end
+ result
+ end
+
+ def build_version(node)
+ hash = pairs_to_hash(node)
+ Gem::Version.new((hash["version"] || hash["value"]).to_s)
+ end
+
+ PLATFORM_FIELDS = %w[cpu os version].freeze
+ PLATFORM_ALLOWED_IVARS = %w[cpu os version value].freeze
+
+ def build_platform(node)
+ hash = pairs_to_hash(node)
+ if (hash.keys & PLATFORM_FIELDS).any?
+ Gem::Platform.new([hash["cpu"], hash["os"], hash["version"]])
+ elsif hash["value"].is_a?(Array)
+ # Malformed platform (e.g. sequence instead of mapping).
+ # Return the raw value so yaml_initialize handles it like Psych does.
+ hash["value"]
+ else
+ plat = Gem::Platform.allocate
+ hash.each do |k, v|
+ plat.instance_variable_set(:"@#{k}", v) if PLATFORM_ALLOWED_IVARS.include?(k)
+ end
+ plat
+ end
+ end
+
+ def build_requirement(node)
+ r = Gem::Requirement.allocate
+ hash = pairs_to_hash(node)
+ reqs = hash["requirements"] || hash["value"]
+
+ if reqs.is_a?(Array) && !reqs.empty?
+ safe_reqs = []
+ reqs.each do |item|
+ if item.is_a?(Array) && item.size == 2
+ op = item[0].to_s
+ ver = item[1]
+ if VALID_OPS.include?(op)
+ version_obj = ver.is_a?(Gem::Version) ? ver : Gem::Version.new(ver.to_s)
+ safe_reqs << [op, version_obj]
+ end
+ elsif item.is_a?(String)
+ parsed = Gem::Requirement.parse(item)
+ safe_reqs << parsed
+ end
+ rescue Gem::Requirement::BadRequirementError, Gem::Version::BadVersionError
+ # Skip malformed items silently
+ end
+ reqs = safe_reqs unless safe_reqs.empty?
+ end
+
+ r.instance_variable_set(:@requirements, reqs)
+ r
+ end
+
+ def build_dependency(node)
+ hash = pairs_to_hash(node)
+ d = Gem::Dependency.allocate
+ d.instance_variable_set(:@name, hash["name"])
+
+ d.instance_variable_set(:@requirement, hash["requirement"] || hash["version_requirements"])
+
+ raw_type = hash["type"]
+ if raw_type
+ name = raw_type.to_s.sub(/^:/, "")
+ validate_symbol!(name)
+ type = name.to_sym
+ else
+ type = :runtime
+ end
+ d.instance_variable_set(:@type, type)
+
+ d.instance_variable_set(:@prerelease, ["true", true].include?(hash["prerelease"]))
+ d.instance_variable_set(:@version_requirements, d.instance_variable_get(:@requirement))
+ d
+ end
+
+ def build_specification(hash)
+ spec = Gem::Specification.allocate
+
+ normalize_specification_version!(hash)
+ normalize_array_fields!(hash)
+
+ spec.yaml_initialize("!ruby/object:Gem::Specification", hash)
+ spec
+ end
+
+ def pairs_to_hash(node)
+ result = {}
+ node.pairs.each do |key_node, value_node|
+ key = key_node.is_a?(Scalar) ? key_node.value.to_s : build_node(key_node).to_s
+ result[key] = build_node(value_node)
+ end
+ result
+ end
+
+ def validate_tag!(tag)
+ return if @permitted_classes.include?(tag)
+ raise_disallowed_class!(tag)
+ end
+
+ def raise_disallowed_class!(tag)
+ if defined?(Psych::VERSION)
+ raise Psych::DisallowedClass.new("load", tag)
+ else
+ raise Psych::DisallowedClass, "Tried to load unspecified class: #{tag}"
+ end
+ end
+
+ def validate_symbol!(name)
+ return if @permitted_symbols.empty? || @permitted_symbols.include?(name)
+
+ label = ":#{name}"
+ if defined?(Psych::VERSION)
+ raise Psych::DisallowedClass.new("load", label)
+ else
+ raise Psych::DisallowedClass, "Tried to load unspecified class: #{label}"
+ end
+ end
+
+ def normalize_specification_version!(hash)
+ val = hash["specification_version"]
+ return unless val && !val.is_a?(Integer)
+ hash["specification_version"] = val.to_i if val.is_a?(String) && /\A\d+\z/.match?(val)
+ end
+
+ def normalize_array_fields!(hash)
+ ARRAY_FIELDS.each do |field|
+ hash[field] = normalize_array_field(hash[field]) if hash[field]
+ end
+ end
+
+ def normalize_array_field(value)
+ if value.is_a?(Hash)
+ value.values.flatten.compact
+ elsif !value.is_a?(Array) && value
+ [value].flatten.compact
+ else
+ value
+ end
+ end
+ end
+
+ class Emitter
+ def emit(obj)
+ "---#{emit_node(obj, 0)}"
+ end
+
+ private
+
+ def emit_node(obj, indent, quote: false)
+ case obj
+ when Gem::Specification then emit_specification(obj, indent)
+ when Gem::Version then emit_version(obj, indent)
+ when Gem::Platform then emit_platform(obj, indent)
+ when Gem::Requirement then emit_requirement(obj, indent)
+ when Gem::Dependency then emit_dependency(obj, indent)
+ when Hash then emit_hash(obj, indent)
+ when Array then emit_array(obj, indent)
+ when Time then emit_time(obj)
+ when String then emit_string(obj, indent, quote: quote)
+ when NilClass
+ "\n"
+ when Numeric, Symbol, TrueClass, FalseClass
+ " #{obj.inspect}\n"
+ else
+ " #{obj.to_s.inspect}\n"
+ end
+ end
+
+ def emit_specification(spec, indent)
+ parts = [" !ruby/object:Gem::Specification\n"]
+ parts << "#{pad(indent)}name:#{emit_node(spec.name, indent + 2)}"
+ parts << "#{pad(indent)}version:#{emit_node(spec.version, indent + 2)}"
+ parts << "#{pad(indent)}platform: #{spec.platform}\n"
+ if spec.platform.to_s != spec.original_platform.to_s
+ parts << "#{pad(indent)}original_platform: #{spec.original_platform}\n"
+ end
+
+ attributes = Gem::Specification.attribute_names.map(&:to_s).sort - %w[name version platform]
+ attributes.each do |name|
+ val = spec.instance_variable_get("@#{name}")
+ next if val.nil?
+ parts << "#{pad(indent)}#{name}:#{emit_node(val, indent + 2)}"
+ end
+
+ res = parts.join
+ res << "\n" unless res.end_with?("\n")
+ res
+ end
+
+ def emit_version(ver, indent)
+ " !ruby/object:Gem::Version\n" \
+ "#{pad(indent)}version: #{emit_node(ver.version.to_s, indent + 2).lstrip}"
+ end
+
+ def emit_platform(plat, indent)
+ " !ruby/object:Gem::Platform\n" \
+ "#{pad(indent)}cpu:#{emit_node(plat.cpu, indent + 2)}" \
+ "#{pad(indent)}os:#{emit_node(plat.os, indent + 2)}" \
+ "#{pad(indent)}version:#{emit_node(plat.version, indent + 2)}"
+ end
+
+ def emit_requirement(req, indent)
+ " !ruby/object:Gem::Requirement\n" \
+ "#{pad(indent)}requirements:#{emit_node(req.requirements, indent + 2)}"
+ end
+
+ def emit_dependency(dep, indent)
+ [
+ " !ruby/object:Gem::Dependency\n",
+ "#{pad(indent)}name: #{emit_node(dep.name, indent + 2).lstrip}",
+ "#{pad(indent)}requirement:#{emit_node(dep.requirement, indent + 2)}",
+ "#{pad(indent)}type: #{emit_node(dep.type, indent + 2).lstrip}",
+ "#{pad(indent)}prerelease: #{emit_node(dep.prerelease?, indent + 2).lstrip}",
+ "#{pad(indent)}version_requirements:#{emit_node(dep.requirement, indent + 2)}",
+ ].join
+ end
+
+ def emit_hash(hash, indent)
+ if hash.empty?
+ " {}\n"
+ else
+ parts = ["\n"]
+ hash.each do |k, v|
+ is_symbol = k.is_a?(Symbol) || (k.is_a?(String) && k.start_with?(":"))
+ key_str = k.is_a?(Symbol) ? k.inspect : k.to_s
+ parts << "#{pad(indent)}#{key_str}:#{emit_node(v, indent + 2, quote: is_symbol)}"
+ end
+ parts.join
+ end
+ end
+
+ def emit_array(arr, indent)
+ if arr.empty?
+ " []\n"
+ else
+ parts = ["\n"]
+ arr.each do |v|
+ parts << "#{pad(indent)}-#{emit_node(v, indent + 2)}"
+ end
+ parts.join
+ end
+ end
+
+ def emit_time(time)
+ " #{time.utc.strftime("%Y-%m-%d %H:%M:%S.%N Z")}\n"
+ end
+
+ def emit_string(str, indent, quote: false)
+ if str.include?("\n")
+ emit_block_scalar(str, indent)
+ elsif needs_quoting?(str, quote)
+ " #{str.to_s.inspect}\n"
+ else
+ " #{str}\n"
+ end
+ end
+
+ def emit_block_scalar(str, indent)
+ parts = [str.end_with?("\n") ? " |\n" : " |-\n"]
+ str.each_line do |line|
+ parts << "#{pad(indent + 2)}#{line}"
+ end
+ res = parts.join
+ res << "\n" unless res.end_with?("\n")
+ res
+ end
+
+ def needs_quoting?(str, quote)
+ quote || str.empty? ||
+ str =~ /^[!*&:@%$]/ || str =~ /^-?\d+(\.\d+)?$/ || str =~ /^[<>=-]/ ||
+ str == "true" || str == "false" || str == "nil" ||
+ str.include?(":") || str.include?("#") || str.include?("[") || str.include?("]") ||
+ str.include?("{") || str.include?("}") || str.include?(",")
+ end
+
+ def pad(indent)
+ " " * indent
+ end
+ end
+
+ module_function
+
+ def dump(obj)
+ Emitter.new.emit(obj)
+ end
+
+ def load(str, permitted_classes: [], permitted_symbols: [], aliases: true)
+ raise TypeError, "no implicit conversion of nil into String" if str.nil?
+ return nil if str.empty?
+
+ ast = Parser.new(str).parse
+ return nil if ast.nil?
+
+ Builder.new(
+ permitted_classes: permitted_classes,
+ permitted_symbols: permitted_symbols,
+ aliases: aliases
+ ).build(ast)
+ end
+ end
+end
diff --git a/lib/securerandom.gemspec b/lib/securerandom.gemspec
index e095244ce9..fe46c11013 100644
--- a/lib/securerandom.gemspec
+++ b/lib/securerandom.gemspec
@@ -1,20 +1,33 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "securerandom"
- spec.version = "0.2.2"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
spec.summary = %q{Interface for secure random number generator.}
spec.description = %q{Interface for secure random number generator.}
spec.homepage = "https://github.com/ruby/securerandom"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.metadata["changelog_uri"] = spec.homepage + "/releases"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(__dir__) do
+ `git ls-files -z`.split("\x0").reject do |f|
+ (File.expand_path(f) == __FILE__) ||
+ f.start_with?(*%w[bin/ test/ spec/ features/ docs/ rakelib/ .document .git Gemfile Rakefile])
+ end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 07ae048634..6079fdb5c4 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -39,28 +39,34 @@ require 'random/formatter'
# +NotImplementedError+ is raised.
module SecureRandom
+
+ # The version
+ VERSION = "0.4.1"
+
class << self
+ # Returns a random binary string containing +size+ bytes.
+ #
+ # See Random.bytes
def bytes(n)
return gen_random(n)
end
+ # Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
+ def alphanumeric(n = nil, chars: ALPHANUMERIC)
+ n = 16 if n.nil?
+ choose(chars, n)
+ end if RUBY_VERSION < '3.3'
+
private
+ # :stopdoc:
+
+ # Implementation using OpenSSL
def gen_random_openssl(n)
- @pid = 0 unless defined?(@pid)
- pid = $$
- unless @pid == pid
- now = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
- OpenSSL::Random.random_add([now, @pid, pid].join(""), 0.0)
- seed = Random.urandom(16)
- if (seed)
- OpenSSL::Random.random_add(seed, 16)
- end
- @pid = pid
- end
return OpenSSL::Random.random_bytes(n)
end
+ # Implementation using system random device
def gen_random_urandom(n)
ret = Random.urandom(n)
unless ret
@@ -86,6 +92,9 @@ module SecureRandom
end
end
+ # :startdoc:
+
+ # Generate random data bytes for Random::Formatter
public :gen_random
end
end
diff --git a/lib/set.rb b/lib/set.rb
deleted file mode 100644
index 95dd9217b1..0000000000
--- a/lib/set.rb
+++ /dev/null
@@ -1,858 +0,0 @@
-# frozen_string_literal: true
-# :markup: markdown
-#
-# set.rb - defines the Set class
-#
-# Copyright (c) 2002-2020 Akinori MUSHA <knu@iDaemons.org>
-#
-# Documentation by Akinori MUSHA and Gavin Sinclair.
-#
-# All rights reserved. You can redistribute and/or modify it under the same
-# terms as Ruby.
-
-
-##
-# This library provides the Set class, which implements a collection
-# of unordered values with no duplicates. It is a hybrid of Array's
-# intuitive inter-operation facilities and Hash's fast lookup.
-#
-# The method `to_set` is added to Enumerable for convenience.
-#
-# 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.
-#
-# Set uses Hash as storage, so you must note the following points:
-#
-# * Equality of elements is determined according to Object#eql? and
-# Object#hash. Use Set#compare_by_identity to make a set compare
-# its elements by their identity.
-# * Set assumes that the identity of each element does not change
-# while it is stored. Modifying an element of a set will render the
-# set to an unreliable state.
-# * When a string is to be stored, a frozen copy of the string is
-# stored instead unless the original string is already frozen.
-#
-# ## Comparison
-#
-# The comparison operators `<`, `>`, `<=`, and `>=` are implemented as
-# shorthand for the {proper_,}{subset?,superset?} methods. The `<=>`
-# operator reflects this order, or return `nil` for sets that both
-# have distinct elements (`{x, y}` vs. `{x, z}` for example).
-#
-# ## Example
-#
-# ```ruby
-# require 'set'
-# s1 = Set[1, 2] #=> #<Set: {1, 2}>
-# s2 = [1, 2].to_set #=> #<Set: {1, 2}>
-# s1 == s2 #=> true
-# s1.add("foo") #=> #<Set: {1, 2, "foo"}>
-# s1.merge([2, 6]) #=> #<Set: {1, 2, "foo", 6}>
-# s1.subset?(s2) #=> false
-# s2.subset?(s1) #=> true
-# ```
-#
-# ## Contact
-#
-# - Akinori MUSHA <<knu@iDaemons.org>> (current maintainer)
-#
-# ## What's Here
-#
-# First, what's elsewhere. \Class \Set:
-#
-# - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
-# - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
-# which provides dozens of additional methods.
-#
-# In particular, class \Set does not have many methods of its own
-# for fetching or for iterating.
-# Instead, it relies on those in \Enumerable.
-#
-# Here, class \Set provides methods that are useful for:
-#
-# - [Creating a Set](#class-Set-label-Methods+for+Creating+a+Set)
-# - [Set Operations](#class-Set-label-Methods+for+Set+Operations)
-# - [Comparing](#class-Set-label-Methods+for+Comparing)
-# - [Querying](#class-Set-label-Methods+for+Querying)
-# - [Assigning](#class-Set-label-Methods+for+Assigning)
-# - [Deleting](#class-Set-label-Methods+for+Deleting)
-# - [Converting](#class-Set-label-Methods+for+Converting)
-# - [Iterating](#class-Set-label-Methods+for+Iterating)
-# - [And more....](#class-Set-label-Other+Methods)
-#
-# ### Methods for Creating a \Set
-#
-# - ::[]:
-# Returns a new set containing the given objects.
-# - ::new:
-# Returns a new set containing either the given objects
-# (if no block given) or the return values from the called block
-# (if a block given).
-#
-# ### Methods for \Set Operations
-#
-# - [|](#method-i-7C) (aliased as #union and #+):
-# Returns a new set containing all elements from +self+
-# and all elements from a given enumerable (no duplicates).
-# - [&](#method-i-26) (aliased as #intersection):
-# Returns a new set containing all elements common to +self+
-# and a given enumerable.
-# - [-](#method-i-2D) (aliased as #difference):
-# Returns a copy of +self+ with all elements
-# in a given enumerable removed.
-# - [\^](#method-i-5E):
-# Returns a new set containing all elements from +self+
-# and a given enumerable except those common to both.
-#
-# ### Methods for Comparing
-#
-# - [<=>](#method-i-3C-3D-3E):
-# Returns -1, 0, or 1 as +self+ is less than, equal to,
-# or greater than a given object.
-# - [==](#method-i-3D-3D):
-# Returns whether +self+ and a given enumerable are equal,
-# as determined by Object#eql?.
-# - \#compare_by_identity?:
-# Returns whether the set considers only identity
-# when comparing elements.
-#
-# ### Methods for Querying
-#
-# - \#length (aliased as #size):
-# Returns the count of elements.
-# - \#empty?:
-# Returns whether the set has no elements.
-# - \#include? (aliased as #member? and #===):
-# Returns whether a given object is an element in the set.
-# - \#subset? (aliased as [<=](#method-i-3C-3D)):
-# Returns whether a given object is a subset of the set.
-# - \#proper_subset? (aliased as [<](#method-i-3C)):
-# Returns whether a given enumerable is a proper subset of the set.
-# - \#superset? (aliased as [>=](#method-i-3E-3D])):
-# Returns whether a given enumerable is a superset of the set.
-# - \#proper_superset? (aliased as [>](#method-i-3E)):
-# Returns whether a given enumerable is a proper superset of the set.
-# - \#disjoint?:
-# Returns +true+ if the set and a given enumerable
-# have no common elements, +false+ otherwise.
-# - \#intersect?:
-# Returns +true+ if the set and a given enumerable:
-# have any common elements, +false+ otherwise.
-# - \#compare_by_identity?:
-# Returns whether the set considers only identity
-# when comparing elements.
-#
-# ### Methods for Assigning
-#
-# - \#add (aliased as #<<):
-# Adds a given object to the set; returns +self+.
-# - \#add?:
-# If the given object is not an element in the set,
-# adds it and returns +self+; otherwise, returns +nil+.
-# - \#merge:
-# Merges the elements of each given enumerable object to the set; returns +self+.
-# - \#replace:
-# Replaces the contents of the set with the contents
-# of a given enumerable.
-#
-# ### Methods for Deleting
-#
-# - \#clear:
-# Removes all elements in the set; returns +self+.
-# - \#delete:
-# Removes a given object from the set; returns +self+.
-# - \#delete?:
-# If the given object is an element in the set,
-# removes it and returns +self+; otherwise, returns +nil+.
-# - \#subtract:
-# Removes each given object from the set; returns +self+.
-# - \#delete_if - Removes elements specified by a given block.
-# - \#select! (aliased as #filter!):
-# Removes elements not specified by a given block.
-# - \#keep_if:
-# Removes elements not specified by a given block.
-# - \#reject!
-# Removes elements specified by a given block.
-#
-# ### Methods for Converting
-#
-# - \#classify:
-# Returns a hash that classifies the elements,
-# as determined by the given block.
-# - \#collect! (aliased as #map!):
-# Replaces each element with a block return-value.
-# - \#divide:
-# Returns a hash that classifies the elements,
-# as determined by the given block;
-# differs from #classify in that the block may accept
-# either one or two arguments.
-# - \#flatten:
-# Returns a new set that is a recursive flattening of +self+.
-# \#flatten!:
-# Replaces each nested set in +self+ with the elements from that set.
-# - \#inspect (aliased as #to_s):
-# Returns a string displaying the elements.
-# - \#join:
-# Returns a string containing all elements, converted to strings
-# as needed, and joined by the given record separator.
-# - \#to_a:
-# Returns an array containing all set elements.
-# - \#to_set:
-# Returns +self+ if given no arguments and no block;
-# with a block given, returns a new set consisting of block
-# return values.
-#
-# ### Methods for Iterating
-#
-# - \#each:
-# Calls the block with each successive element; returns +self+.
-#
-# ### Other Methods
-#
-# - \#reset:
-# Resets the internal state; useful if an object
-# has been modified while an element in the set.
-#
-class Set
- include Enumerable
-
- # Creates a new set containing the given objects.
- #
- # Set[1, 2] # => #<Set: {1, 2}>
- # Set[1, 2, 1] # => #<Set: {1, 2}>
- # Set[1, 'c', :s] # => #<Set: {1, "c", :s}>
- def self.[](*ary)
- new(ary)
- end
-
- # Creates a new set containing the elements of the given enumerable
- # object.
- #
- # If a block is given, the elements of enum are preprocessed by the
- # given block.
- #
- # Set.new([1, 2]) #=> #<Set: {1, 2}>
- # Set.new([1, 2, 1]) #=> #<Set: {1, 2}>
- # Set.new([1, 'c', :s]) #=> #<Set: {1, "c", :s}>
- # Set.new(1..5) #=> #<Set: {1, 2, 3, 4, 5}>
- # Set.new([1, 2, 3]) { |x| x * x } #=> #<Set: {1, 4, 9}>
- def initialize(enum = nil, &block) # :yields: o
- @hash ||= Hash.new(false)
-
- enum.nil? and return
-
- if block
- do_with_enum(enum) { |o| add(block[o]) }
- else
- merge(enum)
- end
- end
-
- # Makes the set compare its elements by their identity and returns
- # self. This method may not be supported by all subclasses of Set.
- def compare_by_identity
- if @hash.respond_to?(:compare_by_identity)
- @hash.compare_by_identity
- self
- else
- raise NotImplementedError, "#{self.class.name}\##{__method__} is not implemented"
- end
- end
-
- # Returns true if the set will compare its elements by their
- # identity. Also see Set#compare_by_identity.
- def compare_by_identity?
- @hash.respond_to?(:compare_by_identity?) && @hash.compare_by_identity?
- end
-
- def do_with_enum(enum, &block) # :nodoc:
- if enum.respond_to?(:each_entry)
- enum.each_entry(&block) if block
- elsif enum.respond_to?(:each)
- enum.each(&block) if block
- else
- raise ArgumentError, "value must be enumerable"
- end
- end
- private :do_with_enum
-
- # Dup internal hash.
- def initialize_dup(orig)
- super
- @hash = orig.instance_variable_get(:@hash).dup
- end
-
- if Kernel.instance_method(:initialize_clone).arity != 1
- # Clone internal hash.
- def initialize_clone(orig, **options)
- super
- @hash = orig.instance_variable_get(:@hash).clone(**options)
- end
- else
- # Clone internal hash.
- def initialize_clone(orig)
- super
- @hash = orig.instance_variable_get(:@hash).clone
- end
- end
-
- def freeze # :nodoc:
- @hash.freeze
- super
- end
-
- # Returns the number of elements.
- def size
- @hash.size
- end
- alias length size
-
- # Returns true if the set contains no elements.
- def empty?
- @hash.empty?
- end
-
- # Removes all elements and returns self.
- #
- # set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}>
- # set.clear #=> #<Set: {}>
- # set #=> #<Set: {}>
- def clear
- @hash.clear
- self
- end
-
- # Replaces the contents of the set with the contents of the given
- # enumerable object and returns self.
- #
- # set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}>
- # set.replace([1, 2]) #=> #<Set: {1, 2}>
- # set #=> #<Set: {1, 2}>
- def replace(enum)
- if enum.instance_of?(self.class)
- @hash.replace(enum.instance_variable_get(:@hash))
- self
- else
- do_with_enum(enum) # make sure enum is enumerable before calling clear
- clear
- merge(enum)
- end
- end
-
- # Converts the set to an array. The order of elements is uncertain.
- #
- # Set[1, 2].to_a #=> [1, 2]
- # Set[1, 'c', :s].to_a #=> [1, "c", :s]
- def to_a
- @hash.keys
- end
-
- # Returns self if no arguments are given. Otherwise, converts the
- # set to another with `klass.new(self, *args, &block)`.
- #
- # In subclasses, returns `klass.new(self, *args, &block)` unless
- # overridden.
- def to_set(klass = Set, *args, &block)
- return self if instance_of?(Set) && klass == Set && block.nil? && args.empty?
- klass.new(self, *args, &block)
- end
-
- def flatten_merge(set, seen = Set.new) # :nodoc:
- set.each { |e|
- if e.is_a?(Set)
- if seen.include?(e_id = e.object_id)
- raise ArgumentError, "tried to flatten recursive Set"
- end
-
- seen.add(e_id)
- flatten_merge(e, seen)
- seen.delete(e_id)
- else
- add(e)
- end
- }
-
- self
- end
- protected :flatten_merge
-
- # Returns a new set that is a copy of the set, flattening each
- # containing set recursively.
- def flatten
- self.class.new.flatten_merge(self)
- end
-
- # Equivalent to Set#flatten, but replaces the receiver with the
- # result in place. Returns nil if no modifications were made.
- def flatten!
- replace(flatten()) if any? { |e| e.is_a?(Set) }
- end
-
- # Returns true if the set contains the given object.
- #
- # Note that <code>include?</code> and <code>member?</code> do not test member
- # equality using <code>==</code> as do other Enumerables.
- #
- # See also Enumerable#include?
- def include?(o)
- @hash[o]
- end
- alias member? include?
-
- # Returns true if the set is a superset of the given set.
- def superset?(set)
- case
- when set.instance_of?(self.class) && @hash.respond_to?(:>=)
- @hash >= set.instance_variable_get(:@hash)
- when set.is_a?(Set)
- size >= set.size && set.all? { |o| include?(o) }
- else
- raise ArgumentError, "value must be a set"
- end
- end
- alias >= superset?
-
- # Returns true if the set is a proper superset of the given set.
- def proper_superset?(set)
- case
- when set.instance_of?(self.class) && @hash.respond_to?(:>)
- @hash > set.instance_variable_get(:@hash)
- when set.is_a?(Set)
- size > set.size && set.all? { |o| include?(o) }
- else
- raise ArgumentError, "value must be a set"
- end
- end
- alias > proper_superset?
-
- # Returns true if the set is a subset of the given set.
- def subset?(set)
- case
- when set.instance_of?(self.class) && @hash.respond_to?(:<=)
- @hash <= set.instance_variable_get(:@hash)
- when set.is_a?(Set)
- size <= set.size && all? { |o| set.include?(o) }
- else
- raise ArgumentError, "value must be a set"
- end
- end
- alias <= subset?
-
- # Returns true if the set is a proper subset of the given set.
- def proper_subset?(set)
- case
- when set.instance_of?(self.class) && @hash.respond_to?(:<)
- @hash < set.instance_variable_get(:@hash)
- when set.is_a?(Set)
- size < set.size && all? { |o| set.include?(o) }
- else
- raise ArgumentError, "value must be a set"
- end
- end
- alias < proper_subset?
-
- # Returns 0 if the set are equal,
- # -1 / +1 if the set is a proper subset / superset of the given set,
- # or nil if they both have unique elements.
- def <=>(set)
- return unless set.is_a?(Set)
-
- case size <=> set.size
- when -1 then -1 if proper_subset?(set)
- when +1 then +1 if proper_superset?(set)
- else 0 if self.==(set)
- end
- end
-
- # Returns true if the set and the given enumerable have at least one
- # element in common.
- #
- # Set[1, 2, 3].intersect? Set[4, 5] #=> false
- # Set[1, 2, 3].intersect? Set[3, 4] #=> true
- # Set[1, 2, 3].intersect? 4..5 #=> false
- # Set[1, 2, 3].intersect? [3, 4] #=> true
- def intersect?(set)
- case set
- when Set
- if size < set.size
- any? { |o| set.include?(o) }
- else
- set.any? { |o| include?(o) }
- end
- when Enumerable
- set.any? { |o| include?(o) }
- else
- raise ArgumentError, "value must be enumerable"
- end
- end
-
- # Returns true if the set and the given enumerable have
- # no element in common. This method is the opposite of `intersect?`.
- #
- # Set[1, 2, 3].disjoint? Set[3, 4] #=> false
- # Set[1, 2, 3].disjoint? Set[4, 5] #=> true
- # Set[1, 2, 3].disjoint? [3, 4] #=> false
- # Set[1, 2, 3].disjoint? 4..5 #=> true
- def disjoint?(set)
- !intersect?(set)
- end
-
- # Calls the given block once for each element in the set, passing
- # the element as parameter. Returns an enumerator if no block is
- # given.
- def each(&block)
- block_given? or return enum_for(__method__) { size }
- @hash.each_key(&block)
- self
- end
-
- # Adds the given object to the set and returns self. Use `merge` to
- # add many elements at once.
- #
- # Set[1, 2].add(3) #=> #<Set: {1, 2, 3}>
- # Set[1, 2].add([3, 4]) #=> #<Set: {1, 2, [3, 4]}>
- # Set[1, 2].add(2) #=> #<Set: {1, 2}>
- def add(o)
- @hash[o] = true
- self
- end
- alias << add
-
- # Adds the given object to the set and returns self. If the
- # object is already in the set, returns nil.
- #
- # Set[1, 2].add?(3) #=> #<Set: {1, 2, 3}>
- # Set[1, 2].add?([3, 4]) #=> #<Set: {1, 2, [3, 4]}>
- # Set[1, 2].add?(2) #=> nil
- def add?(o)
- add(o) unless include?(o)
- end
-
- # Deletes the given object from the set and returns self. Use
- # `subtract` to delete many items at once.
- def delete(o)
- @hash.delete(o)
- self
- end
-
- # Deletes the given object from the set and returns self. If the
- # object is not in the set, returns nil.
- def delete?(o)
- delete(o) if include?(o)
- end
-
- # Deletes every element of the set for which block evaluates to
- # true, and returns self. Returns an enumerator if no block is
- # given.
- def delete_if
- block_given? or return enum_for(__method__) { size }
- # @hash.delete_if should be faster, but using it breaks the order
- # of enumeration in subclasses.
- select { |o| yield o }.each { |o| @hash.delete(o) }
- self
- end
-
- # Deletes every element of the set for which block evaluates to
- # false, and returns self. Returns an enumerator if no block is
- # given.
- def keep_if
- block_given? or return enum_for(__method__) { size }
- # @hash.keep_if should be faster, but using it breaks the order of
- # enumeration in subclasses.
- reject { |o| yield o }.each { |o| @hash.delete(o) }
- self
- end
-
- # Replaces the elements with ones returned by `collect()`.
- # Returns an enumerator if no block is given.
- def collect!
- block_given? or return enum_for(__method__) { size }
- set = self.class.new
- each { |o| set << yield(o) }
- replace(set)
- end
- alias map! collect!
-
- # Equivalent to Set#delete_if, but returns nil if no changes were
- # made. Returns an enumerator if no block is given.
- def reject!(&block)
- block_given? or return enum_for(__method__) { size }
- n = size
- delete_if(&block)
- self if size != n
- end
-
- # Equivalent to Set#keep_if, but returns nil if no changes were
- # made. Returns an enumerator if no block is given.
- def select!(&block)
- block_given? or return enum_for(__method__) { size }
- n = size
- keep_if(&block)
- self if size != n
- end
-
- # Equivalent to Set#select!
- alias filter! select!
-
- # Merges the elements of the given enumerable objects to the set and
- # returns self.
- def merge(*enums, **nil)
- enums.each do |enum|
- if enum.instance_of?(self.class)
- @hash.update(enum.instance_variable_get(:@hash))
- else
- do_with_enum(enum) { |o| add(o) }
- end
- end
-
- self
- end
-
- # Deletes every element that appears in the given enumerable object
- # and returns self.
- def subtract(enum)
- do_with_enum(enum) { |o| delete(o) }
- self
- end
-
- # Returns a new set built by merging the set and the elements of the
- # given enumerable object.
- #
- # Set[1, 2, 3] | Set[2, 4, 5] #=> #<Set: {1, 2, 3, 4, 5}>
- # Set[1, 5, 'z'] | (1..6) #=> #<Set: {1, 5, "z", 2, 3, 4, 6}>
- def |(enum)
- dup.merge(enum)
- end
- alias + |
- alias union |
-
- # Returns a new set built by duplicating the set, removing every
- # element that appears in the given enumerable object.
- #
- # Set[1, 3, 5] - Set[1, 5] #=> #<Set: {3}>
- # Set['a', 'b', 'z'] - ['a', 'c'] #=> #<Set: {"b", "z"}>
- def -(enum)
- dup.subtract(enum)
- end
- alias difference -
-
- # Returns a new set containing elements common to the set and the
- # given enumerable object.
- #
- # Set[1, 3, 5] & Set[3, 2, 1] #=> #<Set: {3, 1}>
- # Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> #<Set: {"a", "b"}>
- def &(enum)
- n = self.class.new
- if enum.is_a?(Set)
- if enum.size > size
- each { |o| n.add(o) if enum.include?(o) }
- else
- enum.each { |o| n.add(o) if include?(o) }
- end
- else
- do_with_enum(enum) { |o| n.add(o) if include?(o) }
- end
- n
- end
- alias intersection &
-
- # Returns a new set containing elements exclusive between the set
- # and the given enumerable object. `(set ^ enum)` is equivalent to
- # `((set | enum) - (set & enum))`.
- #
- # Set[1, 2] ^ Set[2, 3] #=> #<Set: {3, 1}>
- # Set[1, 'b', 'c'] ^ ['b', 'd'] #=> #<Set: {"d", 1, "c"}>
- def ^(enum)
- n = Set.new(enum)
- each { |o| n.add(o) unless n.delete?(o) }
- n
- end
-
- # Returns true if two sets are equal. The equality of each couple
- # of elements is defined according to Object#eql?.
- #
- # Set[1, 2] == Set[2, 1] #=> true
- # Set[1, 3, 5] == Set[1, 5] #=> false
- # Set['a', 'b', 'c'] == Set['a', 'c', 'b'] #=> true
- # Set['a', 'b', 'c'] == ['a', 'c', 'b'] #=> false
- def ==(other)
- if self.equal?(other)
- true
- elsif other.instance_of?(self.class)
- @hash == other.instance_variable_get(:@hash)
- elsif other.is_a?(Set) && self.size == other.size
- other.all? { |o| @hash.include?(o) }
- else
- false
- end
- end
-
- def hash # :nodoc:
- @hash.hash
- end
-
- def eql?(o) # :nodoc:
- return false unless o.is_a?(Set)
- @hash.eql?(o.instance_variable_get(:@hash))
- end
-
- # Resets the internal state after modification to existing elements
- # and returns self.
- #
- # Elements will be reindexed and deduplicated.
- def reset
- if @hash.respond_to?(:rehash)
- @hash.rehash # This should perform frozenness check.
- else
- raise FrozenError, "can't modify frozen #{self.class.name}" if frozen?
- end
- self
- end
-
- # Returns true if the given object is a member of the set,
- # and false otherwise.
- #
- # Used in case statements:
- #
- # require 'set'
- #
- # case :apple
- # when Set[:potato, :carrot]
- # "vegetable"
- # when Set[:apple, :banana]
- # "fruit"
- # end
- # # => "fruit"
- #
- # Or by itself:
- #
- # Set[1, 2, 3] === 2 #=> true
- # Set[1, 2, 3] === 4 #=> false
- #
- alias === include?
-
- # Classifies the set by the return value of the given block and
- # returns a hash of {value => set of elements} pairs. The block is
- # called once for each element of the set, passing the element as
- # parameter.
- #
- # require 'set'
- # files = Set.new(Dir.glob("*.rb"))
- # hash = files.classify { |f| File.mtime(f).year }
- # hash #=> {2000=>#<Set: {"a.rb", "b.rb"}>,
- # # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
- # # 2002=>#<Set: {"f.rb"}>}
- #
- # Returns an enumerator if no block is given.
- def classify # :yields: o
- block_given? or return enum_for(__method__) { size }
-
- h = {}
-
- each { |i|
- (h[yield(i)] ||= self.class.new).add(i)
- }
-
- h
- end
-
- # Divides the set into a set of subsets according to the commonality
- # defined by the given block.
- #
- # If the arity of the block is 2, elements o1 and o2 are in common
- # if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are
- # in common if block.call(o1) == block.call(o2).
- #
- # require 'set'
- # numbers = Set[1, 3, 4, 6, 9, 10, 11]
- # set = numbers.divide { |i,j| (i - j).abs == 1 }
- # set #=> #<Set: {#<Set: {1}>,
- # # #<Set: {11, 9, 10}>,
- # # #<Set: {3, 4}>,
- # # #<Set: {6}>}>
- #
- # Returns an enumerator if no block is given.
- def divide(&func)
- func or return enum_for(__method__) { size }
-
- if func.arity == 2
- require 'tsort'
-
- class << dig = {} # :nodoc:
- include TSort
-
- alias tsort_each_node each_key
- def tsort_each_child(node, &block)
- fetch(node).each(&block)
- end
- end
-
- each { |u|
- dig[u] = a = []
- each{ |v| func.call(u, v) and a << v }
- }
-
- set = Set.new()
- dig.each_strongly_connected_component { |css|
- set.add(self.class.new(css))
- }
- set
- else
- Set.new(classify(&func).values)
- end
- end
-
- # Returns a string created by converting each element of the set to a string
- # See also: Array#join
- def join(separator=nil)
- to_a.join(separator)
- end
-
- InspectKey = :__inspect_key__ # :nodoc:
-
- # Returns a string containing a human-readable representation of the
- # set ("#<Set: {element1, element2, ...}>").
- def inspect
- ids = (Thread.current[InspectKey] ||= [])
-
- if ids.include?(object_id)
- return sprintf('#<%s: {...}>', self.class.name)
- end
-
- ids << object_id
- begin
- return sprintf('#<%s: {%s}>', self.class, to_a.inspect[1..-2])
- ensure
- ids.pop
- end
- end
-
- alias to_s inspect
-
- def pretty_print(pp) # :nodoc:
- pp.group(1, sprintf('#<%s:', self.class.name), '>') {
- pp.breakable
- pp.group(1, '{', '}') {
- pp.seplist(self) { |o|
- pp.pp o
- }
- }
- }
- end
-
- def pretty_print_cycle(pp) # :nodoc:
- pp.text sprintf('#<%s: {%s}>', self.class.name, empty? ? '' : '...')
- end
-end
-
-module Enumerable
- # Makes a set from the enumerable object with given arguments.
- # Needs to `require "set"` to use this method.
- def to_set(klass = Set, *args, &block)
- klass.new(self, *args, &block)
- end unless method_defined?(:to_set)
-end
-
-autoload :SortedSet, "#{__dir__}/set/sorted_set"
diff --git a/lib/set/set.gemspec b/lib/set/set.gemspec
deleted file mode 100644
index 1e83287420..0000000000
--- a/lib/set/set.gemspec
+++ /dev/null
@@ -1,23 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "set"
- spec.version = "1.0.3"
- spec.authors = ["Akinori MUSHA"]
- spec.email = ["knu@idaemons.org"]
-
- spec.summary = %q{Provides a class to deal with collections of unordered, unique values}
- spec.description = %q{Provides a class to deal with collections of unordered, unique values}
- spec.homepage = "https://github.com/ruby/set"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
- spec.metadata["changelog_uri"] = "https://github.com/ruby/set/blob/v#{spec.version}/CHANGELOG.md"
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
-end
diff --git a/lib/set/sorted_set.rb b/lib/set/sorted_set.rb
deleted file mode 100644
index bc07bc1fb0..0000000000
--- a/lib/set/sorted_set.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-begin
- require 'sorted_set'
-rescue ::LoadError
- raise "The `SortedSet` class has been extracted from the `set` library. " \
- "You must use the `sorted_set` gem or other alternatives."
-end
diff --git a/lib/set/subclass_compatible.rb b/lib/set/subclass_compatible.rb
new file mode 100644
index 0000000000..f43c34f6a2
--- /dev/null
+++ b/lib/set/subclass_compatible.rb
@@ -0,0 +1,347 @@
+# frozen_string_literal: true
+
+# :markup: markdown
+#
+# set/subclass_compatible.rb - Provides compatibility for set subclasses
+#
+# Copyright (c) 2002-2024 Akinori MUSHA <knu@iDaemons.org>
+#
+# Documentation by Akinori MUSHA and Gavin Sinclair.
+#
+# All rights reserved. You can redistribute and/or modify it under the same
+# terms as Ruby.
+
+
+class Set
+ # This module is automatically included in subclasses of Set, to
+ # make them backwards compatible with the pure-Ruby set implementation
+ # used before Ruby 4. Users who want to use Set subclasses without
+ # this compatibility layer should subclass from Set::CoreSet.
+ #
+ # Note that Set subclasses that access `@hash` are not compatible even
+ # with this support. Such subclasses must be updated to support Ruby 4.
+ module SubclassCompatible
+ module ClassMethods
+ def [](*ary)
+ new(ary)
+ end
+ end
+
+ # Creates a new set containing the elements of the given enumerable
+ # object.
+ #
+ # If a block is given, the elements of enum are preprocessed by the
+ # given block.
+ #
+ # Set.new([1, 2]) #=> #<Set: {1, 2}>
+ # Set.new([1, 2, 1]) #=> #<Set: {1, 2}>
+ # Set.new([1, 'c', :s]) #=> #<Set: {1, "c", :s}>
+ # Set.new(1..5) #=> #<Set: {1, 2, 3, 4, 5}>
+ # Set.new([1, 2, 3]) { |x| x * x } #=> #<Set: {1, 4, 9}>
+ def initialize(enum = nil, &block) # :yields: o
+ enum.nil? and return
+
+ if block
+ do_with_enum(enum) { |o| add(block[o]) }
+ else
+ merge(enum)
+ end
+ end
+
+ def do_with_enum(enum, &block) # :nodoc:
+ if enum.respond_to?(:each_entry)
+ enum.each_entry(&block) if block
+ elsif enum.respond_to?(:each)
+ enum.each(&block) if block
+ else
+ raise ArgumentError, "value must be enumerable"
+ end
+ end
+ private :do_with_enum
+
+ def replace(enum)
+ if enum.instance_of?(self.class)
+ super
+ else
+ do_with_enum(enum) # make sure enum is enumerable before calling clear
+ clear
+ merge(enum)
+ end
+ end
+
+ def to_set(&block)
+ return self if instance_of?(Set) && block.nil?
+ Set.new(self, &block)
+ end
+
+ def flatten_merge(set, seen = {}) # :nodoc:
+ set.each { |e|
+ if e.is_a?(Set)
+ case seen[e_id = e.object_id]
+ when true
+ raise ArgumentError, "tried to flatten recursive Set"
+ when false
+ next
+ end
+
+ seen[e_id] = true
+ flatten_merge(e, seen)
+ seen[e_id] = false
+ else
+ add(e)
+ end
+ }
+
+ self
+ end
+ protected :flatten_merge
+
+ def flatten
+ self.class.new.flatten_merge(self)
+ end
+
+ def flatten!
+ replace(flatten()) if any?(Set)
+ end
+
+ def superset?(set)
+ case
+ when set.instance_of?(self.class)
+ super
+ when set.is_a?(Set)
+ size >= set.size && set.all?(self)
+ else
+ raise ArgumentError, "value must be a set"
+ end
+ end
+ alias >= superset?
+
+ def proper_superset?(set)
+ case
+ when set.instance_of?(self.class)
+ super
+ when set.is_a?(Set)
+ size > set.size && set.all?(self)
+ else
+ raise ArgumentError, "value must be a set"
+ end
+ end
+ alias > proper_superset?
+
+ def subset?(set)
+ case
+ when set.instance_of?(self.class)
+ super
+ when set.is_a?(Set)
+ size <= set.size && all?(set)
+ else
+ raise ArgumentError, "value must be a set"
+ end
+ end
+ alias <= subset?
+
+ def proper_subset?(set)
+ case
+ when set.instance_of?(self.class)
+ super
+ when set.is_a?(Set)
+ size < set.size && all?(set)
+ else
+ raise ArgumentError, "value must be a set"
+ end
+ end
+ alias < proper_subset?
+
+ def <=>(set)
+ return unless set.is_a?(Set)
+
+ case size <=> set.size
+ when -1 then -1 if proper_subset?(set)
+ when +1 then +1 if proper_superset?(set)
+ else 0 if self.==(set)
+ end
+ end
+
+ def intersect?(set)
+ case set
+ when Set
+ if size < set.size
+ any?(set)
+ else
+ set.any?(self)
+ end
+ when Enumerable
+ set.any?(self)
+ else
+ raise ArgumentError, "value must be enumerable"
+ end
+ end
+
+ def disjoint?(set)
+ !intersect?(set)
+ end
+
+ def add?(o)
+ add(o) unless include?(o)
+ end
+
+ def delete?(o)
+ delete(o) if include?(o)
+ end
+
+ def delete_if(&block)
+ block_given? or return enum_for(__method__) { size }
+ select(&block).each { |o| delete(o) }
+ self
+ end
+
+ def keep_if(&block)
+ block_given? or return enum_for(__method__) { size }
+ reject(&block).each { |o| delete(o) }
+ self
+ end
+
+ def collect!
+ block_given? or return enum_for(__method__) { size }
+ set = self.class.new
+ each { |o| set << yield(o) }
+ replace(set)
+ end
+ alias map! collect!
+
+ def reject!(&block)
+ block_given? or return enum_for(__method__) { size }
+ n = size
+ delete_if(&block)
+ self if size != n
+ end
+
+ def select!(&block)
+ block_given? or return enum_for(__method__) { size }
+ n = size
+ keep_if(&block)
+ self if size != n
+ end
+
+ alias filter! select!
+
+ def merge(*enums, **nil)
+ enums.each do |enum|
+ if enum.instance_of?(self.class)
+ super(enum)
+ else
+ do_with_enum(enum) { |o| add(o) }
+ end
+ end
+
+ self
+ end
+
+ def subtract(enum)
+ do_with_enum(enum) { |o| delete(o) }
+ self
+ end
+
+ def |(enum)
+ dup.merge(enum)
+ end
+ alias + |
+ alias union |
+
+ def -(enum)
+ dup.subtract(enum)
+ end
+ alias difference -
+
+ def &(enum)
+ n = self.class.new
+ if enum.is_a?(Set)
+ if enum.size > size
+ each { |o| n.add(o) if enum.include?(o) }
+ else
+ enum.each { |o| n.add(o) if include?(o) }
+ end
+ else
+ do_with_enum(enum) { |o| n.add(o) if include?(o) }
+ end
+ n
+ end
+ alias intersection &
+
+ def ^(enum)
+ n = self.class.new(enum)
+ each { |o| n.add(o) unless n.delete?(o) }
+ n
+ end
+
+ def ==(other)
+ if self.equal?(other)
+ true
+ elsif other.instance_of?(self.class)
+ super
+ elsif other.is_a?(Set) && self.size == other.size
+ other.all? { |o| include?(o) }
+ else
+ false
+ end
+ end
+
+ def eql?(o) # :nodoc:
+ return false unless o.is_a?(Set)
+ super
+ end
+
+ def classify
+ block_given? or return enum_for(__method__) { size }
+
+ h = {}
+
+ each { |i|
+ (h[yield(i)] ||= self.class.new).add(i)
+ }
+
+ h
+ end
+
+ def join(separator=nil)
+ to_a.join(separator)
+ end
+
+ InspectKey = :__inspect_key__ # :nodoc:
+
+ # Returns a string containing a human-readable representation of the
+ # set ("#<Set: {element1, element2, ...}>").
+ def inspect
+ ids = (Thread.current[InspectKey] ||= [])
+
+ if ids.include?(object_id)
+ return sprintf('#<%s: {...}>', self.class.name)
+ end
+
+ ids << object_id
+ begin
+ return sprintf('#<%s: {%s}>', self.class, to_a.inspect[1..-2])
+ ensure
+ ids.pop
+ end
+ end
+
+ alias to_s inspect
+
+ def pretty_print(pp) # :nodoc:
+ pp.group(1, sprintf('#<%s:', self.class.name), '>') {
+ pp.breakable
+ pp.group(1, '{', '}') {
+ pp.seplist(self) { |o|
+ pp.pp o
+ }
+ }
+ }
+ end
+
+ def pretty_print_cycle(pp) # :nodoc:
+ pp.text sprintf('#<%s: {%s}>', self.class.name, empty? ? '' : '...')
+ end
+ end
+ private_constant :SubclassCompatible
+end
diff --git a/lib/shellwords.gemspec b/lib/shellwords.gemspec
index 8ae87b230e..b601508f94 100644
--- a/lib/shellwords.gemspec
+++ b/lib/shellwords.gemspec
@@ -1,6 +1,14 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+
Gem::Specification.new do |spec|
- spec.name = "shellwords"
- spec.version = "0.1.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Akinori MUSHA"]
spec.email = ["knu@idaemons.org"]
@@ -13,10 +21,9 @@ Gem::Specification.new do |spec|
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ srcdir, gemspec_file = File.split(__FILE__)
+ spec.files = Dir.chdir(srcdir) do
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git|Rake)}) || f == gemspec_file}
end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
end
diff --git a/lib/shellwords.rb b/lib/shellwords.rb
index 4368a53ea8..20a85ed9d2 100644
--- a/lib/shellwords.rb
+++ b/lib/shellwords.rb
@@ -5,9 +5,9 @@
# This module manipulates strings according to the word parsing rules
# of the UNIX Bourne shell.
#
-# The shellwords() function was originally a port of shellwords.pl,
-# but modified to conform to the Shell & Utilities volume of the IEEE
-# Std 1003.1-2008, 2016 Edition [1].
+# The <tt>shellwords()</tt> function was originally a port of shellwords.pl, but
+# modified to conform to {the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016
+# Edition}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html]
#
# === Usage
#
@@ -62,18 +62,20 @@
#
# === Contact
# * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
-#
-# === Resources
-#
-# 1: {IEEE Std 1003.1-2008, 2016 Edition, the Shell & Utilities volume}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html]
module Shellwords
+ # The version number string.
+ VERSION = "0.2.2"
+
# Splits a string into an array of tokens in the same way the UNIX
# Bourne shell does.
#
# argv = Shellwords.split('here are "two words"')
# argv #=> ["here", "are", "two words"]
#
+ # +line+ must not contain NUL characters because of nature of
+ # +exec+ system call.
+ #
# Note, however, that this is not a command line parser. Shell
# metacharacters except for the single and double quotes and
# backslash are not treated as such.
@@ -88,9 +90,14 @@ module Shellwords
def shellsplit(line)
words = []
field = String.new
- line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
+ line.scan(/\G\s*(?>([^\0\s\\\'\"]+)|'([^\0\']*)'|"((?:[^\0\"\\]|\\[^\0])*)"|(\\[^\0]?)|(\S))(\s|\z)?/m) do
|word, sq, dq, esc, garbage, sep|
- raise ArgumentError, "Unmatched quote: #{line.inspect}" if garbage
+ if garbage
+ b = $~.begin(0)
+ line = $~[0]
+ line = "..." + line if b > 0
+ raise ArgumentError, "#{garbage == "\0" ? 'Nul character' : 'Unmatched quote'} at #{b}: #{line}"
+ end
# 2.2.3 Double-Quotes:
#
# The <backslash> shall retain its special meaning as an
@@ -119,6 +126,9 @@ module Shellwords
# command line. +str+ can be a non-string object that responds to
# +to_s+.
#
+ # +str+ must not contain NUL characters because of nature of +exec+
+ # system call.
+ #
# Note that a resulted string should be used unquoted and is not
# intended for use in double quotes nor in single quotes.
#
@@ -151,6 +161,9 @@ module Shellwords
# An empty argument will be skipped, so return empty quotes.
return "''".dup if str.empty?
+ # Shellwords cannot contain NUL characters.
+ raise ArgumentError, "NUL character" if str.index("\0")
+
str = str.dup
# Treat multibyte characters as is. It is the caller's responsibility
@@ -176,6 +189,7 @@ module Shellwords
# All elements are joined into a single string with fields separated by a
# space, where each element is escaped for the Bourne shell and stringified
# using +to_s+.
+ # See also Shellwords.shellescape.
#
# ary = ["There's", "a", "time", "and", "place", "for", "everything"]
# argv = Shellwords.join(ary)
diff --git a/lib/singleton.gemspec b/lib/singleton.gemspec
new file mode 100644
index 0000000000..7646914905
--- /dev/null
+++ b/lib/singleton.gemspec
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{The Singleton module implements the Singleton pattern.}
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/ruby/singleton"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 07420d2ea2..74aec8903c 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# The Singleton module implements the Singleton pattern.
#
@@ -92,22 +92,26 @@
# p a.strip # => nil
#
module Singleton
- VERSION = "0.1.1"
+ # The version string
+ VERSION = "0.3.0"
- # Raises a TypeError to prevent cloning.
- def clone
- raise TypeError, "can't clone instance of singleton #{self.class}"
- end
+ module SingletonInstanceMethods # :nodoc:
+ # Raises a TypeError to prevent cloning.
+ def clone
+ raise TypeError, "can't clone instance of singleton #{self.class}"
+ end
- # Raises a TypeError to prevent duping.
- def dup
- raise TypeError, "can't dup instance of singleton #{self.class}"
- end
+ # Raises a TypeError to prevent duping.
+ def dup
+ raise TypeError, "can't dup instance of singleton #{self.class}"
+ end
- # By default, do not retain any state when marshalling.
- def _dump(depth = -1)
- ''
+ # By default, do not retain any state when marshalling.
+ def _dump(depth = -1)
+ ''
+ end
end
+ include SingletonInstanceMethods
module SingletonClassMethods # :nodoc:
@@ -121,12 +125,7 @@ module Singleton
end
def instance # :nodoc:
- return @singleton__instance__ if @singleton__instance__
- @singleton__mutex__.synchronize {
- return @singleton__instance__ if @singleton__instance__
- @singleton__instance__ = new()
- }
- @singleton__instance__
+ @singleton__instance__ || @singleton__mutex__.synchronize { @singleton__instance__ ||= new }
end
private
@@ -135,22 +134,42 @@ module Singleton
super
Singleton.__init__(sub_klass)
end
+
+ def set_instance(val)
+ @singleton__instance__ = val
+ end
+
+ def set_mutex(val)
+ @singleton__mutex__ = val
+ end
+ end
+
+ def self.module_with_class_methods # :nodoc:
+ SingletonClassMethods
end
- class << Singleton # :nodoc:
+ module SingletonClassProperties # :nodoc:
+
+ def self.included(c)
+ # extending an object with Singleton is a bad idea
+ c.undef_method :extend_object
+ end
+
+ def self.extended(c)
+ # extending an object with Singleton is a bad idea
+ c.singleton_class.send(:undef_method, :extend_object)
+ end
+
def __init__(klass) # :nodoc:
klass.instance_eval {
- @singleton__instance__ = nil
- @singleton__mutex__ = Thread::Mutex.new
+ set_instance(nil)
+ set_mutex(Thread::Mutex.new)
}
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)
@@ -162,10 +181,11 @@ module Singleton
def included(klass)
super
klass.private_class_method :new, :allocate
- klass.extend SingletonClassMethods
+ klass.extend module_with_class_methods
Singleton.__init__(klass)
end
end
+ extend SingletonClassProperties
##
# :singleton-method: _load
@@ -175,3 +195,46 @@ module Singleton
# :singleton-method: instance
# Returns the singleton instance.
end
+
+if defined?(Ractor)
+ module RactorLocalSingleton # :nodoc:
+ include Singleton::SingletonInstanceMethods
+
+ module RactorLocalSingletonClassMethods # :nodoc:
+ include Singleton::SingletonClassMethods
+ def instance
+ set_mutex(Thread::Mutex.new) if Ractor.current[mutex_key].nil?
+ return Ractor.current[instance_key] if Ractor.current[instance_key]
+ Ractor.current[mutex_key].synchronize {
+ return Ractor.current[instance_key] if Ractor.current[instance_key]
+ set_instance(new())
+ }
+ Ractor.current[instance_key]
+ end
+
+ private
+
+ def instance_key
+ :"__RactorLocalSingleton_instance_with_class_id_#{object_id}__"
+ end
+
+ def mutex_key
+ :"__RactorLocalSingleton_mutex_with_class_id_#{object_id}__"
+ end
+
+ def set_instance(val)
+ Ractor.current[instance_key] = val
+ end
+
+ def set_mutex(val)
+ Ractor.current[mutex_key] = val
+ end
+ end
+
+ def self.module_with_class_methods
+ RactorLocalSingletonClassMethods
+ end
+
+ extend Singleton::SingletonClassProperties
+ end
+end
diff --git a/lib/singleton/singleton.gemspec b/lib/singleton/singleton.gemspec
deleted file mode 100644
index 88d3111b65..0000000000
--- a/lib/singleton/singleton.gemspec
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{The Singleton module implements the Singleton pattern.}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/singleton"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/syntax_suggest/api.rb b/lib/syntax_suggest/api.rb
index 5b725e13d7..5054efa888 100644
--- a/lib/syntax_suggest/api.rb
+++ b/lib/syntax_suggest/api.rb
@@ -5,9 +5,11 @@ require_relative "version"
require "tmpdir"
require "stringio"
require "pathname"
-require "ripper"
require "timeout"
+# Prism is the new parser, replacing Ripper
+require "prism"
+
module SyntaxSuggest
# Used to indicate a default value that cannot
# be confused with another input.
@@ -78,7 +80,7 @@ module SyntaxSuggest
code_lines: search.code_lines
).call
rescue Timeout::Error => e
- io.puts "Search timed out SYNTAX_SUGGEST_TIMEOUT=#{timeout}, run with DEBUG=1 for more info"
+ io.puts "Search timed out SYNTAX_SUGGEST_TIMEOUT=#{timeout}, run with SYNTAX_SUGGEST_DEBUG=1 for more info"
io.puts e.backtrace.first(3).join($/)
end
@@ -91,7 +93,9 @@ module SyntaxSuggest
dir = Pathname(dir)
dir.join(time).tap { |path|
path.mkpath
- FileUtils.ln_sf(time, dir.join("last"))
+ alias_dir = dir.join("last")
+ FileUtils.rm_rf(alias_dir) if alias_dir.exist?
+ FileUtils.ln_sf(time, alias_dir)
}
end
@@ -117,11 +121,7 @@ module SyntaxSuggest
def self.valid_without?(without_lines:, code_lines:)
lines = code_lines - Array(without_lines).flatten
- if lines.empty?
- true
- else
- valid?(lines)
- end
+ lines.empty? || valid?(lines)
end
# SyntaxSuggest.invalid? [Private]
@@ -131,7 +131,7 @@ module SyntaxSuggest
source = source.join if source.is_a?(Array)
source = source.to_s
- Ripper.new(source).tap(&:parse).error?
+ Prism.parse(source).failure?
end
# SyntaxSuggest.valid? [Private]
@@ -185,11 +185,10 @@ require_relative "explain_syntax"
require_relative "clean_document"
# Helpers
-require_relative "lex_all"
require_relative "code_line"
require_relative "code_block"
require_relative "block_expand"
-require_relative "ripper_errors"
+require_relative "mini_stringio"
require_relative "priority_queue"
require_relative "unvisited_lines"
require_relative "around_block_scan"
@@ -197,3 +196,5 @@ require_relative "priority_engulf_queue"
require_relative "pathname_from_message"
require_relative "display_invalid_blocks"
require_relative "parse_blocks_from_indent_line"
+require_relative "visitor"
+require_relative "token"
diff --git a/lib/syntax_suggest/around_block_scan.rb b/lib/syntax_suggest/around_block_scan.rb
index 2a57d1b19e..dd9af729c5 100644
--- a/lib/syntax_suggest/around_block_scan.rb
+++ b/lib/syntax_suggest/around_block_scan.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require_relative "scan_history"
+
module SyntaxSuggest
# This class is useful for exploring contents before and after
# a block
@@ -24,201 +26,207 @@ module SyntaxSuggest
# puts scan.before_index # => 0
# puts scan.after_index # => 3
#
- # Contents can also be filtered using AroundBlockScan#skip
- #
- # To grab the next surrounding indentation use AroundBlockScan#scan_adjacent_indent
class AroundBlockScan
def initialize(code_lines:, block:)
@code_lines = code_lines
- @orig_before_index = block.lines.first.index
- @orig_after_index = block.lines.last.index
@orig_indent = block.current_indent
- @skip_array = []
- @after_array = []
- @before_array = []
- @stop_after_kw = false
- @skip_hidden = false
- @skip_empty = false
+ @stop_after_kw = false
+ @force_add_empty = false
+ @force_add_hidden = false
+ @target_indent = nil
+
+ @scanner = ScanHistory.new(code_lines: code_lines, block: block)
+ end
+
+ # When using this flag, `scan_while` will
+ # bypass the block it's given and always add a
+ # line that responds truthy to `CodeLine#hidden?`
+ #
+ # Lines are hidden when they've been evaluated by
+ # the parser as part of a block and found to contain
+ # valid code.
+ def force_add_hidden
+ @force_add_hidden = true
+ self
end
- def skip(name)
- case name
- when :hidden?
- @skip_hidden = true
- when :empty?
- @skip_empty = true
- else
- raise "Unsupported skip #{name}"
- end
+ # When using this flag, `scan_while` will
+ # bypass the block it's given and always add a
+ # line that responds truthy to `CodeLine#empty?`
+ #
+ # Empty lines contain no code, only whitespace such
+ # as leading spaces a newline.
+ def force_add_empty
+ @force_add_empty = true
self
end
+ # Tells `scan_while` to look for mismatched keyword/end-s
+ #
+ # When scanning up, if we see more keywords then end-s it will
+ # stop. This might happen when scanning outside of a method body.
+ # the first scan line up would be a keyword and this setting would
+ # trigger a stop.
+ #
+ # When scanning down, stop if there are more end-s than keywords.
def stop_after_kw
@stop_after_kw = true
self
end
+ # Main work method
+ #
+ # The scan_while method takes a block that yields lines above and
+ # below the block. If the yield returns true, the @before_index
+ # or @after_index are modified to include the matched line.
+ #
+ # In addition to yielding individual lines, the internals of this
+ # object give a mini DSL to handle common situations such as
+ # stopping if we've found a keyword/end mis-match in one direction
+ # or the other.
def scan_while
- stop_next = false
-
- kw_count = 0
- end_count = 0
- index = before_lines.reverse_each.take_while do |line|
- next false if stop_next
- next true if @skip_hidden && line.hidden?
- next true if @skip_empty && line.empty?
+ stop_next_up = false
+ stop_next_down = false
- kw_count += 1 if line.is_kw?
- end_count += 1 if line.is_end?
- if @stop_after_kw && kw_count > end_count
- stop_next = true
- end
-
- yield line
- end.last&.index
+ @scanner.scan(
+ up: ->(line, kw_count, end_count) {
+ next false if stop_next_up
+ next true if @force_add_hidden && line.hidden?
+ next true if @force_add_empty && line.empty?
- if index && index < before_index
- @before_index = index
- end
+ if @stop_after_kw && kw_count > end_count
+ stop_next_up = true
+ end
- stop_next = false
- kw_count = 0
- end_count = 0
- index = after_lines.take_while do |line|
- next false if stop_next
- next true if @skip_hidden && line.hidden?
- next true if @skip_empty && line.empty?
+ yield line
+ },
+ down: ->(line, kw_count, end_count) {
+ next false if stop_next_down
+ next true if @force_add_hidden && line.hidden?
+ next true if @force_add_empty && line.empty?
- kw_count += 1 if line.is_kw?
- end_count += 1 if line.is_end?
- if @stop_after_kw && end_count > kw_count
- stop_next = true
- end
+ if @stop_after_kw && end_count > kw_count
+ stop_next_down = true
+ end
- yield line
- end.last&.index
+ yield line
+ }
+ )
- if index && index > after_index
- @after_index = index
- end
self
end
- def capture_neighbor_context
- lines = []
+ # Scanning is intentionally conservative because
+ # we have no way of rolling back an aggressive block (at this time)
+ #
+ # If a block was stopped for some trivial reason, (like an empty line)
+ # but the next line would have caused it to be balanced then we
+ # can check that condition and grab just one more line either up or
+ # down.
+ #
+ # For example, below if we're scanning up, line 2 might cause
+ # the scanning to stop. This is because empty lines might
+ # denote logical breaks where the user intended to chunk code
+ # which is a good place to stop and check validity. Unfortunately
+ # it also means we might have a "dangling" keyword or end.
+ #
+ # 1 def bark
+ # 2
+ # 3 end
+ #
+ # If lines 2 and 3 are in the block, then when this method is
+ # run it would see it is unbalanced, but that acquiring line 1
+ # would make it balanced, so that's what it does.
+ def lookahead_balance_one_line
kw_count = 0
end_count = 0
- before_lines.reverse_each do |line|
- next if line.empty?
- break if line.indent < @orig_indent
- next if line.indent != @orig_indent
-
+ lines.each do |line|
kw_count += 1 if line.is_kw?
end_count += 1 if line.is_end?
- if kw_count != 0 && kw_count == end_count
- lines << line
- break
- end
-
- lines << line
end
- lines.reverse!
-
- kw_count = 0
- end_count = 0
- after_lines.each do |line|
- next if line.empty?
- break if line.indent < @orig_indent
- next if line.indent != @orig_indent
-
- kw_count += 1 if line.is_kw?
- end_count += 1 if line.is_end?
- if kw_count != 0 && kw_count == end_count
- lines << line
- break
+ return self if kw_count == end_count # nothing to balance
+
+ @scanner.commit_if_changed # Rollback point if we don't find anything to optimize
+
+ # Try to eat up empty lines
+ @scanner.scan(
+ up: ->(line, _, _) { line.hidden? || line.empty? },
+ down: ->(line, _, _) { line.hidden? || line.empty? }
+ )
+
+ # More ends than keywords, check if we can balance expanding up
+ next_up = @scanner.next_up
+ next_down = @scanner.next_down
+ case end_count - kw_count
+ when 1
+ if next_up&.is_kw? && next_up.indent >= @target_indent
+ @scanner.scan(
+ up: ->(line, _, _) { line == next_up },
+ down: ->(line, _, _) { false }
+ )
+ @scanner.commit_if_changed
end
-
- lines << line
- end
-
- lines
- end
-
- def on_falling_indent
- last_indent = @orig_indent
- before_lines.reverse_each do |line|
- next if line.empty?
- if line.indent < last_indent
- yield line
- last_indent = line.indent
- end
- end
-
- last_indent = @orig_indent
- after_lines.each do |line|
- next if line.empty?
- if line.indent < last_indent
- yield line
- last_indent = line.indent
+ when -1
+ if next_down&.is_end? && next_down.indent >= @target_indent
+ @scanner.scan(
+ up: ->(line, _, _) { false },
+ down: ->(line, _, _) { line == next_down }
+ )
+ @scanner.commit_if_changed
end
end
- end
-
- def scan_neighbors
- scan_while { |line| line.not_empty? && line.indent >= @orig_indent }
- end
+ # Rollback any uncommitted changes
+ @scanner.stash_changes
- def next_up
- @code_lines[before_index.pred]
+ self
end
- def next_down
- @code_lines[after_index.next]
+ # Finds code lines at the same or greater indentation and adds them
+ # to the block
+ def scan_neighbors_not_empty
+ @target_indent = @orig_indent
+ scan_while { |line| line.not_empty? && line.indent >= @target_indent }
end
+ # Scan blocks based on indentation of next line above/below block
+ #
+ # Determines indentaion of the next line above/below the current block.
+ #
+ # Normally this is called when a block has expanded to capture all "neighbors"
+ # at the same (or greater) indentation and needs to expand out. For example
+ # the `def/end` lines surrounding a method.
def scan_adjacent_indent
before_after_indent = []
- before_after_indent << (next_up&.indent || 0)
- before_after_indent << (next_down&.indent || 0)
- indent = before_after_indent.min
- scan_while { |line| line.not_empty? && line.indent >= indent }
+ before_after_indent << (@scanner.next_up&.indent || 0)
+ before_after_indent << (@scanner.next_down&.indent || 0)
- self
- end
+ @target_indent = before_after_indent.min
+ scan_while { |line| line.not_empty? && line.indent >= @target_indent }
- def start_at_next_line
- before_index
- after_index
- @before_index -= 1
- @after_index += 1
self
end
+ # Return the currently matched lines as a `CodeBlock`
+ #
+ # When a `CodeBlock` is created it will gather metadata about
+ # itself, so this is not a free conversion. Avoid allocating
+ # more CodeBlock's than needed
def code_block
CodeBlock.new(lines: lines)
end
+ # Returns the lines matched by the current scan as an
+ # array of CodeLines
def lines
- @code_lines[before_index..after_index]
- end
-
- def before_index
- @before_index ||= @orig_before_index
- end
-
- def after_index
- @after_index ||= @orig_after_index
- end
-
- private def before_lines
- @code_lines[0...before_index] || []
+ @scanner.lines
end
- private def after_lines
- @code_lines[after_index.next..-1] || []
+ # Manageable rspec errors
+ def inspect
+ "#<#{self.class}:0x0000123843lol >"
end
end
end
diff --git a/lib/syntax_suggest/block_expand.rb b/lib/syntax_suggest/block_expand.rb
index 396b2c3a1a..2751ae2a64 100644
--- a/lib/syntax_suggest/block_expand.rb
+++ b/lib/syntax_suggest/block_expand.rb
@@ -35,30 +35,121 @@ module SyntaxSuggest
@code_lines = code_lines
end
+ # Main interface. Expand current indentation, before
+ # expanding to a lower indentation
def call(block)
if (next_block = expand_neighbors(block))
- return next_block
+ next_block
+ else
+ expand_indent(block)
end
-
- expand_indent(block)
end
+ # Expands code to the next lowest indentation
+ #
+ # For example:
+ #
+ # 1 def dog
+ # 2 print "dog"
+ # 3 end
+ #
+ # If a block starts on line 2 then it has captured all it's "neighbors" (code at
+ # the same indentation or higher). To continue expanding, this block must capture
+ # lines one and three which are at a different indentation level.
+ #
+ # This method allows fully expanded blocks to decrease their indentation level (so
+ # they can expand to capture more code up and down). It does this conservatively
+ # as there's no undo (currently).
def expand_indent(block)
- AroundBlockScan.new(code_lines: @code_lines, block: block)
- .skip(:hidden?)
+ now = AroundBlockScan.new(code_lines: @code_lines, block: block)
+ .force_add_hidden
.stop_after_kw
.scan_adjacent_indent
- .code_block
+
+ now.lookahead_balance_one_line
+
+ now.code_block
end
+ # A neighbor is code that is at or above the current indent line.
+ #
+ # First we build a block with all neighbors. If we can't go further
+ # then we decrease the indentation threshold and expand via indentation
+ # i.e. `expand_indent`
+ #
+ # Handles two general cases.
+ #
+ # ## Case #1: Check code inside of methods/classes/etc.
+ #
+ # It's important to note, that not everything in a given indentation level can be parsed
+ # as valid code even if it's part of valid code. For example:
+ #
+ # 1 hash = {
+ # 2 name: "richard",
+ # 3 dog: "cinco",
+ # 4 }
+ #
+ # In this case lines 2 and 3 will be neighbors, but they're invalid until `expand_indent`
+ # is called on them.
+ #
+ # When we are adding code within a method or class (at the same indentation level),
+ # use the empty lines to denote the programmer intended logical chunks.
+ # Stop and check each one. For example:
+ #
+ # 1 def dog
+ # 2 print "dog"
+ # 3
+ # 4 hash = {
+ # 5 end
+ #
+ # If we did not stop parsing at empty newlines then the block might mistakenly grab all
+ # the contents (lines 2, 3, and 4) and report them as being problems, instead of only
+ # line 4.
+ #
+ # ## Case #2: Expand/grab other logical blocks
+ #
+ # Once the search algorithm has converted all lines into blocks at a given indentation
+ # it will then `expand_indent`. Once the blocks that generates are expanded as neighbors
+ # we then begin seeing neighbors being other logical blocks i.e. a block's neighbors
+ # may be another method or class (something with keywords/ends).
+ #
+ # For example:
+ #
+ # 1 def bark
+ # 2
+ # 3 end
+ # 4
+ # 5 def sit
+ # 6 end
+ #
+ # In this case if lines 4, 5, and 6 are in a block when it tries to expand neighbors
+ # it will expand up. If it stops after line 2 or 3 it may cause problems since there's a
+ # valid kw/end pair, but the block will be checked without it.
+ #
+ # We try to resolve this edge case with `lookahead_balance_one_line` below.
def expand_neighbors(block)
- expanded_lines = AroundBlockScan.new(code_lines: @code_lines, block: block)
- .skip(:hidden?)
+ now = AroundBlockScan.new(code_lines: @code_lines, block: block)
+
+ # Initial scan
+ now
+ .force_add_hidden
.stop_after_kw
- .scan_neighbors
- .scan_while { |line| line.empty? } # Slurp up empties
+ .scan_neighbors_not_empty
+
+ # Slurp up empties
+ now
+ .scan_while { |line| line.empty? }
+
+ # If next line is kw and it will balance us, take it
+ expanded_lines = now
+ .lookahead_balance_one_line
.lines
+ # Don't allocate a block if it won't be used
+ #
+ # If nothing was taken, return nil to indicate that status
+ # used in `def call` to determine if
+ # we need to expand up/out (`expand_indent`)
if block.lines == expanded_lines
nil
else
@@ -66,7 +157,7 @@ module SyntaxSuggest
end
end
- # Managable rspec errors
+ # Manageable rspec errors
def inspect
"#<SyntaxSuggest::CodeBlock:0x0000123843lol >"
end
diff --git a/lib/syntax_suggest/capture/before_after_keyword_ends.rb b/lib/syntax_suggest/capture/before_after_keyword_ends.rb
new file mode 100644
index 0000000000..f53c57a4d1
--- /dev/null
+++ b/lib/syntax_suggest/capture/before_after_keyword_ends.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ module Capture
+ # Shows surrounding kw/end pairs
+ #
+ # The purpose of showing these extra pairs is due to cases
+ # of ambiguity when only one visible line is matched.
+ #
+ # For example:
+ #
+ # 1 class Dog
+ # 2 def bark
+ # 4 def eat
+ # 5 end
+ # 6 end
+ #
+ # In this case either line 2 could be missing an `end` or
+ # line 4 was an extra line added by mistake (it happens).
+ #
+ # When we detect the above problem it shows the issue
+ # as only being on line 2
+ #
+ # 2 def bark
+ #
+ # Showing "neighbor" keyword pairs gives extra context:
+ #
+ # 2 def bark
+ # 4 def eat
+ # 5 end
+ #
+ #
+ # Example:
+ #
+ # lines = BeforeAfterKeywordEnds.new(
+ # block: block,
+ # code_lines: code_lines
+ # ).call()
+ #
+ class BeforeAfterKeywordEnds
+ def initialize(code_lines:, block:)
+ @scanner = ScanHistory.new(code_lines: code_lines, block: block)
+ @original_indent = block.current_indent
+ end
+
+ def call
+ lines = []
+
+ @scanner.scan(
+ up: ->(line, kw_count, end_count) {
+ next true if line.empty?
+ break if line.indent < @original_indent
+ next true if line.indent != @original_indent
+
+ # If we're going up and have one complete kw/end pair, stop
+ if kw_count != 0 && kw_count == end_count
+ lines << line
+ break
+ end
+
+ lines << line if line.is_kw? || line.is_end?
+ true
+ },
+ down: ->(line, kw_count, end_count) {
+ next true if line.empty?
+ break if line.indent < @original_indent
+ next true if line.indent != @original_indent
+
+ # if we're going down and have one complete kw/end pair,stop
+ if kw_count != 0 && kw_count == end_count
+ lines << line
+ break
+ end
+
+ lines << line if line.is_kw? || line.is_end?
+ true
+ }
+ )
+ @scanner.stash_changes
+
+ lines
+ end
+ end
+ end
+end
diff --git a/lib/syntax_suggest/capture/falling_indent_lines.rb b/lib/syntax_suggest/capture/falling_indent_lines.rb
new file mode 100644
index 0000000000..1e046b2ba5
--- /dev/null
+++ b/lib/syntax_suggest/capture/falling_indent_lines.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ module Capture
+ # Shows the context around code provided by "falling" indentation
+ #
+ # If this is the original code lines:
+ #
+ # class OH
+ # def hello
+ # it "foo" do
+ # end
+ # end
+ #
+ # And this is the line that is captured
+ #
+ # it "foo" do
+ #
+ # It will yield its surrounding context:
+ #
+ # class OH
+ # def hello
+ # end
+ # end
+ #
+ # Example:
+ #
+ # FallingIndentLines.new(
+ # block: block,
+ # code_lines: @code_lines
+ # ).call do |line|
+ # @lines_to_output << line
+ # end
+ #
+ class FallingIndentLines
+ def initialize(code_lines:, block:)
+ @lines = nil
+ @scanner = ScanHistory.new(code_lines: code_lines, block: block)
+ @original_indent = block.current_indent
+ end
+
+ def call(&yieldable)
+ last_indent_up = @original_indent
+ last_indent_down = @original_indent
+
+ @scanner.commit_if_changed
+ @scanner.scan(
+ up: ->(line, _, _) {
+ next true if line.empty?
+
+ if line.indent < last_indent_up
+ yieldable.call(line)
+ last_indent_up = line.indent
+ end
+ true
+ },
+ down: ->(line, _, _) {
+ next true if line.empty?
+
+ if line.indent < last_indent_down
+ yieldable.call(line)
+ last_indent_down = line.indent
+ end
+ true
+ }
+ )
+ @scanner.stash_changes
+ end
+ end
+ end
+end
diff --git a/lib/syntax_suggest/capture_code_context.rb b/lib/syntax_suggest/capture_code_context.rb
index 7d6a550612..5de9ec09cc 100644
--- a/lib/syntax_suggest/capture_code_context.rb
+++ b/lib/syntax_suggest/capture_code_context.rb
@@ -1,13 +1,21 @@
# frozen_string_literal: true
module SyntaxSuggest
+ module Capture
+ end
+end
+
+require_relative "capture/falling_indent_lines"
+require_relative "capture/before_after_keyword_ends"
+
+module SyntaxSuggest
# Turns a "invalid block(s)" into useful context
#
# There are three main phases in the algorithm:
#
# 1. Sanitize/format input source
# 2. Search for invalid blocks
- # 3. Format invalid blocks into something meaninful
+ # 3. Format invalid blocks into something meaningful
#
# This class handles the third part.
#
@@ -18,7 +26,7 @@ module SyntaxSuggest
# they can't add extra data that's not present.
#
# In the case of known ambiguious cases, this class adds context
- # back to the ambiguitiy so the programmer has full information.
+ # back to the ambiguity so the programmer has full information.
#
# Beyond handling these ambiguities, it also captures surrounding
# code context information:
@@ -55,6 +63,10 @@ module SyntaxSuggest
capture_falling_indent(block)
end
+ sorted_lines
+ end
+
+ def sorted_lines
@lines_to_output.select!(&:not_empty?)
@lines_to_output.uniq!
@lines_to_output.sort!
@@ -76,12 +88,11 @@ module SyntaxSuggest
# end
# end
#
- #
def capture_falling_indent(block)
- AroundBlockScan.new(
+ Capture::FallingIndentLines.new(
block: block,
code_lines: @code_lines
- ).on_falling_indent do |line|
+ ).call do |line|
@lines_to_output << line
end
end
@@ -116,9 +127,10 @@ module SyntaxSuggest
def capture_before_after_kws(block)
return unless block.visible_lines.count == 1
- around_lines = AroundBlockScan.new(code_lines: @code_lines, block: block)
- .start_at_next_line
- .capture_neighbor_context
+ around_lines = Capture::BeforeAfterKeywordEnds.new(
+ code_lines: @code_lines,
+ block: block
+ ).call
around_lines -= block.lines
diff --git a/lib/syntax_suggest/clean_document.rb b/lib/syntax_suggest/clean_document.rb
index b572189259..94c68d8ad4 100644
--- a/lib/syntax_suggest/clean_document.rb
+++ b/lib/syntax_suggest/clean_document.rb
@@ -10,7 +10,7 @@ module SyntaxSuggest
#
# 1. Sanitize/format input source
# 2. Search for invalid blocks
- # 3. Format invalid blocks into something meaninful
+ # 3. Format invalid blocks into something meaningful
#
# This class handles the first part.
#
@@ -47,9 +47,9 @@ module SyntaxSuggest
# ## Heredocs
#
# A heredoc is an way of defining a multi-line string. They can cause many
- # problems. If left as a single line, Ripper would try to parse the contents
+ # problems. If left as a single line, the parser would try to parse the contents
# as ruby code rather than as a string. Even without this problem, we still
- # hit an issue with indentation
+ # hit an issue with indentation:
#
# 1 foo = <<~HEREDOC
# 2 "Be yourself; everyone else is already taken.""
@@ -66,27 +66,9 @@ module SyntaxSuggest
#
# All of these problems are fixed by joining the whole heredoc into a single
# line.
- #
- # ## Comments and whitespace
- #
- # Comments can throw off the way the lexer tells us that the line
- # logically belongs with the next line. This is valid ruby but
- # results in a different lex output than before:
- #
- # 1 User.
- # 2 where(name: "schneems").
- # 3 # Comment here
- # 4 first
- #
- # To handle this we can replace comment lines with empty lines
- # and then re-lex the source. This removal and re-lexing preserves
- # line index and document size, but generates an easier to work with
- # document.
- #
class CleanDocument
def initialize(source:)
- lines = clean_sweep(source: source)
- @document = CodeLine.from_source(lines.join, lines: lines)
+ @document = CodeLine.from_source(source)
end
# Call all of the document "cleaners"
@@ -110,60 +92,6 @@ module SyntaxSuggest
@document.join
end
- # Remove comments and whitespace only lines
- #
- # replace with empty newlines
- #
- # source = <<~'EOM'
- # # Comment 1
- # puts "hello"
- # # Comment 2
- # puts "world"
- # EOM
- #
- # lines = CleanDocument.new(source: source).lines
- # expect(lines[0].to_s).to eq("\n")
- # expect(lines[1].to_s).to eq("puts "hello")
- # expect(lines[2].to_s).to eq("\n")
- # expect(lines[3].to_s).to eq("puts "world")
- #
- # Important: This must be done before lexing.
- #
- # After this change is made, we lex the document because
- # removing comments can change how the doc is parsed.
- #
- # For example:
- #
- # values = LexAll.new(source: <<~EOM))
- # User.
- # # comment
- # where(name: 'schneems')
- # EOM
- # expect(
- # values.count {|v| v.type == :on_ignored_nl}
- # ).to eq(1)
- #
- # After the comment is removed:
- #
- # values = LexAll.new(source: <<~EOM))
- # User.
- #
- # where(name: 'schneems')
- # EOM
- # expect(
- # values.count {|v| v.type == :on_ignored_nl}
- # ).to eq(2)
- #
- def clean_sweep(source:)
- source.lines.map do |line|
- if line.match?(/^\s*(#[^{].*)?$/) # https://rubular.com/r/LLE10D8HKMkJvs
- $/
- else
- line
- end
- end
- end
-
# Smushes all heredoc lines into one line
#
# source = <<~'EOM'
@@ -180,11 +108,11 @@ module SyntaxSuggest
start_index_stack = []
heredoc_beg_end_index = []
lines.each do |line|
- line.lex.each do |lex_value|
- case lex_value.type
- when :on_heredoc_beg
+ line.tokens.each do |token|
+ case token.type
+ when :HEREDOC_START
start_index_stack << line.index
- when :on_heredoc_end
+ when :HEREDOC_END
start_index = start_index_stack.pop
end_index = line.index
heredoc_beg_end_index << [start_index, end_index]
@@ -210,20 +138,10 @@ module SyntaxSuggest
# expect(lines[0].to_s).to eq(source)
# expect(lines[1].to_s).to eq("")
#
- # The one known case this doesn't handle is:
- #
- # Ripper.lex <<~EOM
- # a &&
- # b ||
- # c
- # EOM
- #
- # For some reason this introduces `on_ignore_newline` but with BEG type
- #
def join_consecutive!
- consecutive_groups = @document.select(&:ignore_newline_not_beg?).map do |code_line|
- take_while_including(code_line.index..-1) do |line|
- line.ignore_newline_not_beg?
+ consecutive_groups = @document.select(&:consecutive?).map do |code_line|
+ take_while_including(code_line.index..) do |line|
+ line.consecutive?
end
end
@@ -243,7 +161,7 @@ module SyntaxSuggest
# expect(lines[1].to_s).to eq("")
def join_trailing_slash!
trailing_groups = @document.select(&:trailing_slash?).map do |code_line|
- take_while_including(code_line.index..-1) { |x| x.trailing_slash? }
+ take_while_including(code_line.index..) { |x| x.trailing_slash? }
end
join_groups(trailing_groups)
self
@@ -265,22 +183,23 @@ module SyntaxSuggest
groups.each do |lines|
line = lines.first
- # Handle the case of multiple groups in a a row
+ # Handle the case of multiple groups in a row
# if one is already replaced, move on
next if @document[line.index].empty?
# Join group into the first line
@document[line.index] = CodeLine.new(
- lex: lines.map(&:lex).flatten,
+ tokens: lines.map(&:tokens).flatten,
line: lines.join,
- index: line.index
+ index: line.index,
+ consecutive: false
)
# Hide the rest of the lines
- lines[1..-1].each do |line|
+ lines[1..].each do |line|
# The above lines already have newlines in them, if add more
# then there will be double newline, use an empty line instead
- @document[line.index] = CodeLine.new(line: "", index: line.index, lex: [])
+ @document[line.index] = CodeLine.new(line: "", index: line.index, tokens: [], consecutive: false)
end
end
self
@@ -291,7 +210,7 @@ module SyntaxSuggest
# Like `take_while` except when it stops
# iterating, it also returns the line
# that caused it to stop
- def take_while_including(range = 0..-1)
+ def take_while_including(range = 0..)
take_next_and_stop = false
@document[range].take_while do |line|
next if take_next_and_stop
diff --git a/lib/syntax_suggest/code_block.rb b/lib/syntax_suggest/code_block.rb
index 61e7986da4..d842890300 100644
--- a/lib/syntax_suggest/code_block.rb
+++ b/lib/syntax_suggest/code_block.rb
@@ -81,7 +81,7 @@ module SyntaxSuggest
# lines then the result cannot be invalid
#
# That means there's no reason to re-check all
- # lines with ripper (which is expensive).
+ # lines with the parser (which is expensive).
# Benchmark in commit message
@valid = if lines.all? { |l| l.hidden? || l.empty? }
true
diff --git a/lib/syntax_suggest/code_frontier.rb b/lib/syntax_suggest/code_frontier.rb
index 8e93b32514..38d5375ef4 100644
--- a/lib/syntax_suggest/code_frontier.rb
+++ b/lib/syntax_suggest/code_frontier.rb
@@ -8,7 +8,7 @@ module SyntaxSuggest
#
# 1. Sanitize/format input source
# 2. Search for invalid blocks
- # 3. Format invalid blocks into something meaninful
+ # 3. Format invalid blocks into something meaningful
#
# The Code frontier is a critical part of the second step
#
@@ -117,7 +117,7 @@ module SyntaxSuggest
if ENV["SYNTAX_SUGGEST_DEBUG"]
puts "```"
- puts @queue.peek.to_s
+ puts @queue.peek
puts "```"
puts " @frontier indent: #{frontier_indent}"
puts " @unvisited indent: #{unvisited_indent}"
diff --git a/lib/syntax_suggest/code_line.rb b/lib/syntax_suggest/code_line.rb
index dc738ab128..7fb1aae26a 100644
--- a/lib/syntax_suggest/code_line.rb
+++ b/lib/syntax_suggest/code_line.rb
@@ -26,34 +26,66 @@ module SyntaxSuggest
# Returns an array of CodeLine objects
# from the source string
- def self.from_source(source, lines: nil)
- lines ||= source.lines
- lex_array_for_line = LexAll.new(source: source, source_lines: lines).each_with_object(Hash.new { |h, k| h[k] = [] }) { |lex, hash| hash[lex.line] << lex }
- lines.map.with_index do |line, index|
+ def self.from_source(source)
+ source = +source
+ parse_result = Prism.parse_lex(source)
+ ast, tokens = parse_result.value
+
+ clean_comments!(source, parse_result.comments)
+
+ visitor = Visitor.new
+ visitor.visit(ast)
+ tokens.sort_by! { |token, _state| token.location.start_line }
+
+ prev_token = nil
+ tokens.map! do |token, _state|
+ prev_token = Token.new(token, prev_token, visitor)
+ end
+
+ tokens_for_line = tokens.each_with_object(Hash.new { |h, k| h[k] = [] }) { |token, hash| hash[token.line] << token }
+ source.lines.map.with_index do |line, index|
CodeLine.new(
line: line,
index: index,
- lex: lex_array_for_line[index + 1]
+ tokens: tokens_for_line[index + 1],
+ consecutive: visitor.consecutive_lines.include?(index + 1)
)
end
end
- attr_reader :line, :index, :lex, :line_number, :indent
- def initialize(line:, index:, lex:)
- @lex = lex
+ # Remove comments that apear on their own in source. They will never be the cause
+ # of syntax errors and are just visual noise. Example:
+ #
+ # source = +<<~RUBY
+ # # Comment-only line
+ # foo # Inline comment
+ # RUBY
+ # CodeLine.clean_comments!(source, Prism.parse(source).comments)
+ # source # => "\nfoo # Inline comment\n"
+ def self.clean_comments!(source, comments)
+ # Iterate backwards since we are modifying the source in place and must preserve
+ # the offsets. Prism comments are sorted by their location in the source.
+ comments.reverse_each do |comment|
+ next if comment.trailing?
+ source.bytesplice(comment.location.start_offset, comment.location.length, "")
+ end
+ end
+
+ attr_reader :line, :index, :tokens, :line_number, :indent
+ def initialize(line:, index:, tokens:, consecutive:)
+ @tokens = tokens
@line = line
@index = index
+ @consecutive = consecutive
@original = line
@line_number = @index + 1
strip_line = line.dup
strip_line.lstrip!
- if strip_line.empty?
- @empty = true
- @indent = 0
+ @indent = if (@empty = strip_line.empty?)
+ line.length - 1 # Newline removed from strip_line is not "whitespace"
else
- @empty = false
- @indent = line.length - strip_line.length
+ line.length - strip_line.length
end
set_kw_end
@@ -153,29 +185,16 @@ module SyntaxSuggest
index <=> other.index
end
- # [Not stable API]
- #
- # Lines that have a `on_ignored_nl` type token and NOT
- # a `BEG` type seem to be a good proxy for the ability
- # to join multiple lines into one.
- #
- # This predicate method is used to determine when those
- # two criteria have been met.
- #
- # The one known case this doesn't handle is:
- #
- # Ripper.lex <<~EOM
- # a &&
- # b ||
- # c
- # EOM
- #
- # For some reason this introduces `on_ignore_newline` but with BEG type
- def ignore_newline_not_beg?
- @ignore_newline_not_beg
+ # Can this line be logically joined together
+ # with the following line? Determined by walking
+ # the AST
+ def consecutive?
+ @consecutive
end
- # Determines if the given line has a trailing slash
+ # Determines if the given line has a trailing slash.
+ # Simply check if the line contains a backslash after
+ # the content of the last token.
#
# lines = CodeLine.from_source(<<~EOM)
# it "foo" \
@@ -183,55 +202,19 @@ module SyntaxSuggest
# expect(lines.first.trailing_slash?).to eq(true)
#
def trailing_slash?
- last = @lex.last
- return false unless last
- return false unless last.type == :on_sp
-
- last.token == TRAILING_SLASH
+ return unless (last = @tokens.last)
+ @line.byteindex(TRAILING_SLASH, last.location.end_column) != nil
end
- # Endless method detection
- #
- # From https://github.com/ruby/irb/commit/826ae909c9c93a2ddca6f9cfcd9c94dbf53d44ab
- # Detecting a "oneliner" seems to need a state machine.
- # This can be done by looking mostly at the "state" (last value):
- #
- # ENDFN -> BEG (token = '=' ) -> END
- #
private def set_kw_end
- oneliner_count = 0
- in_oneliner_def = nil
-
kw_count = 0
end_count = 0
- @ignore_newline_not_beg = false
- @lex.each do |lex|
- kw_count += 1 if lex.is_kw?
- end_count += 1 if lex.is_end?
-
- if lex.type == :on_ignored_nl
- @ignore_newline_not_beg = !lex.expr_beg?
- end
-
- if in_oneliner_def.nil?
- in_oneliner_def = :ENDFN if lex.state.allbits?(Ripper::EXPR_ENDFN)
- elsif lex.state.allbits?(Ripper::EXPR_ENDFN)
- # Continue
- elsif lex.state.allbits?(Ripper::EXPR_BEG)
- in_oneliner_def = :BODY if lex.token == "="
- elsif lex.state.allbits?(Ripper::EXPR_END)
- # We found an endless method, count it
- oneliner_count += 1 if in_oneliner_def == :BODY
-
- in_oneliner_def = nil
- else
- in_oneliner_def = nil
- end
+ @tokens.each do |token|
+ kw_count += 1 if token.is_kw?
+ end_count += 1 if token.is_end?
end
- kw_count -= oneliner_count
-
@is_kw = (kw_count - end_count) > 0
@is_end = (end_count - kw_count) > 0
end
diff --git a/lib/syntax_suggest/code_search.rb b/lib/syntax_suggest/code_search.rb
index 2a86dfea90..7628dcd131 100644
--- a/lib/syntax_suggest/code_search.rb
+++ b/lib/syntax_suggest/code_search.rb
@@ -43,7 +43,7 @@ module SyntaxSuggest
def initialize(source, record_dir: DEFAULT_VALUE)
record_dir = if record_dir == DEFAULT_VALUE
- ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"] ? "tmp" : nil
+ (ENV["SYNTAX_SUGGEST_RECORD_DIR"] || ENV["SYNTAX_SUGGEST_DEBUG"]) ? "tmp" : nil
else
record_dir
end
@@ -73,7 +73,7 @@ module SyntaxSuggest
if ENV["SYNTAX_SUGGEST_DEBUG"]
puts "\n\n==== #{filename} ===="
puts "\n```#{block.starts_at}..#{block.ends_at}"
- puts block.to_s
+ puts block
puts "```"
puts " block indent: #{block.current_indent}"
end
diff --git a/lib/syntax_suggest/core_ext.rb b/lib/syntax_suggest/core_ext.rb
index f2fbc7ac64..ffbc922eed 100644
--- a/lib/syntax_suggest/core_ext.rb
+++ b/lib/syntax_suggest/core_ext.rb
@@ -1,112 +1,47 @@
# frozen_string_literal: true
-# Ruby 3.2+ has a cleaner way to hook into Ruby that doesn't use `require`
-if SyntaxError.method_defined?(:detailed_message)
- module SyntaxSuggest
- # Mini String IO [Private]
- #
- # Acts like a StringIO with reduced API, but without having to require that
- # class.
- class MiniStringIO
- def initialize(isatty: $stderr.isatty)
- @string = +""
- @isatty = isatty
- end
-
- attr_reader :isatty
- def puts(value = $/, **)
- @string << value
- end
-
- attr_reader :string
- end
-
- # SyntaxSuggest.record_dir [Private]
- #
- # Used to monkeypatch SyntaxError via Module.prepend
- def self.module_for_detailed_message
- Module.new {
- def detailed_message(highlight: true, syntax_suggest: true, **kwargs)
- return super unless syntax_suggest
-
- require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
-
- message = super
-
- if path
- file = Pathname.new(path)
- io = SyntaxSuggest::MiniStringIO.new
-
- SyntaxSuggest.call(
- io: io,
- source: file.read,
- filename: file,
- terminal: highlight
- )
- annotation = io.string
-
- annotation + message
- else
- message
- end
- rescue => e
- if ENV["SYNTAX_SUGGEST_DEBUG"]
- $stderr.warn(e.message)
- $stderr.warn(e.backtrace)
- end
-
- # Ignore internal errors
+module SyntaxSuggest
+ # SyntaxSuggest.module_for_detailed_message [Private]
+ #
+ # Used to monkeypatch SyntaxError via Module.prepend
+ def self.module_for_detailed_message
+ Module.new {
+ def detailed_message(highlight: true, syntax_suggest: true, **kwargs)
+ return super unless syntax_suggest
+
+ require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
+
+ message = super
+
+ if path
+ file = Pathname.new(path)
+ io = SyntaxSuggest::MiniStringIO.new
+
+ SyntaxSuggest.call(
+ io: io,
+ source: file.read,
+ filename: file,
+ terminal: highlight
+ )
+ annotation = io.string
+
+ annotation += "\n" unless annotation.end_with?("\n")
+
+ annotation + message
+ else
message
end
- }
- end
- end
-
- SyntaxError.prepend(SyntaxSuggest.module_for_detailed_message)
-else
- autoload :Pathname, "pathname"
-
- #--
- # Monkey patch kernel to ensure that all `require` calls call the same
- # method
- #++
- module Kernel
- # :stopdoc:
-
- module_function
-
- alias_method :syntax_suggest_original_require, :require
- alias_method :syntax_suggest_original_require_relative, :require_relative
- alias_method :syntax_suggest_original_load, :load
-
- def load(file, wrap = false)
- syntax_suggest_original_load(file)
- rescue SyntaxError => e
- require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
-
- SyntaxSuggest.handle_error(e)
- end
-
- def require(file)
- syntax_suggest_original_require(file)
- rescue SyntaxError => e
- require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
-
- SyntaxSuggest.handle_error(e)
- end
+ rescue => e
+ if ENV["SYNTAX_SUGGEST_DEBUG"]
+ $stderr.warn(e.message)
+ $stderr.warn(e.backtrace)
+ end
- def require_relative(file)
- if Pathname.new(file).absolute?
- syntax_suggest_original_require file
- else
- relative_from = caller_locations(1..1).first
- relative_from_path = relative_from.absolute_path || relative_from.path
- syntax_suggest_original_require File.expand_path("../#{file}", relative_from_path)
+ # Ignore internal errors
+ message
end
- rescue SyntaxError => e
- require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
-
- SyntaxSuggest.handle_error(e)
- end
+ }
end
end
+
+SyntaxError.prepend(SyntaxSuggest.module_for_detailed_message)
diff --git a/lib/syntax_suggest/display_invalid_blocks.rb b/lib/syntax_suggest/display_invalid_blocks.rb
index 32ec0021a3..5e79b3a262 100644
--- a/lib/syntax_suggest/display_invalid_blocks.rb
+++ b/lib/syntax_suggest/display_invalid_blocks.rb
@@ -14,7 +14,7 @@ module SyntaxSuggest
@filename = filename
@code_lines = code_lines
- @terminal = terminal == DEFAULT_VALUE ? io.isatty : terminal
+ @terminal = (terminal == DEFAULT_VALUE) ? io.isatty : terminal
end
def document_ok?
diff --git a/lib/syntax_suggest/explain_syntax.rb b/lib/syntax_suggest/explain_syntax.rb
index 142ed2e269..d7f5262ddb 100644
--- a/lib/syntax_suggest/explain_syntax.rb
+++ b/lib/syntax_suggest/explain_syntax.rb
@@ -1,8 +1,14 @@
# frozen_string_literal: true
-require_relative "left_right_lex_count"
+require_relative "left_right_token_count"
module SyntaxSuggest
+ class GetParseErrors
+ def self.errors(source)
+ Prism.parse(source).errors.map(&:message)
+ end
+ end
+
# Explains syntax errors based on their source
#
# example:
@@ -15,8 +21,8 @@ module SyntaxSuggest
# # => "Unmatched keyword, missing `end' ?"
#
# When the error cannot be determined by lexical counting
- # then ripper is run against the input and the raw ripper
- # errors returned.
+ # then the parser is run against the input and the raw
+ # errors are returned.
#
# Example:
#
@@ -39,14 +45,14 @@ module SyntaxSuggest
def initialize(code_lines:)
@code_lines = code_lines
- @left_right = LeftRightLexCount.new
+ @left_right = LeftRightTokenCount.new
@missing = nil
end
def call
@code_lines.each do |line|
- line.lex.each do |lex|
- @left_right.count_lex(lex)
+ line.tokens.each do |token|
+ @left_right.count_token(token)
end
end
@@ -91,10 +97,10 @@ module SyntaxSuggest
# Returns an array of syntax error messages
#
# If no missing pairs are found it falls back
- # on the original ripper error messages
+ # on the original error messages
def errors
if missing.empty?
- return RipperErrors.new(@code_lines.map(&:original).join).call.errors
+ return GetParseErrors.errors(@code_lines.map(&:original).join).uniq
end
missing.map { |miss| why(miss) }
diff --git a/lib/syntax_suggest/left_right_lex_count.rb b/lib/syntax_suggest/left_right_lex_count.rb
deleted file mode 100644
index 6fcae7482b..0000000000
--- a/lib/syntax_suggest/left_right_lex_count.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-# frozen_string_literal: true
-
-module SyntaxSuggest
- # Find mis-matched syntax based on lexical count
- #
- # Used for detecting missing pairs of elements
- # each keyword needs an end, each '{' needs a '}'
- # etc.
- #
- # Example:
- #
- # left_right = LeftRightLexCount.new
- # left_right.count_kw
- # left_right.missing.first
- # # => "end"
- #
- # left_right = LeftRightLexCount.new
- # source = "{ a: b, c: d" # Note missing '}'
- # LexAll.new(source: source).each do |lex|
- # left_right.count_lex(lex)
- # end
- # left_right.missing.first
- # # => "}"
- class LeftRightLexCount
- def initialize
- @kw_count = 0
- @end_count = 0
-
- @count_for_char = {
- "{" => 0,
- "}" => 0,
- "[" => 0,
- "]" => 0,
- "(" => 0,
- ")" => 0,
- "|" => 0
- }
- end
-
- def count_kw
- @kw_count += 1
- end
-
- def count_end
- @end_count += 1
- end
-
- # Count source code characters
- #
- # Example:
- #
- # left_right = LeftRightLexCount.new
- # left_right.count_lex(LexValue.new(1, :on_lbrace, "{", Ripper::EXPR_BEG))
- # left_right.count_for_char("{")
- # # => 1
- # left_right.count_for_char("}")
- # # => 0
- def count_lex(lex)
- case lex.type
- when :on_tstring_content
- # ^^^
- # Means it's a string or a symbol `"{"` rather than being
- # part of a data structure (like a hash) `{ a: b }`
- # ignore it.
- when :on_words_beg, :on_symbos_beg, :on_qwords_beg,
- :on_qsymbols_beg, :on_regexp_beg, :on_tstring_beg
- # ^^^
- # Handle shorthand syntaxes like `%Q{ i am a string }`
- #
- # The start token will be the full thing `%Q{` but we
- # need to count it as if it's a `{`. Any token
- # can be used
- char = lex.token[-1]
- @count_for_char[char] += 1 if @count_for_char.key?(char)
- when :on_embexpr_beg
- # ^^^
- # Embedded string expressions like `"#{foo} <-embed"`
- # are parsed with chars:
- #
- # `#{` as :on_embexpr_beg
- # `}` as :on_embexpr_end
- #
- # We cannot ignore both :on_emb_expr_beg and :on_embexpr_end
- # because sometimes the lexer thinks something is an embed
- # string end, when it is not like `lol = }` (no clue why).
- #
- # When we see `#{` count it as a `{` or we will
- # have a mis-match count.
- #
- case lex.token
- when "\#{"
- @count_for_char["{"] += 1
- end
- else
- @end_count += 1 if lex.is_end?
- @kw_count += 1 if lex.is_kw?
- @count_for_char[lex.token] += 1 if @count_for_char.key?(lex.token)
- end
- end
-
- def count_for_char(char)
- @count_for_char[char]
- end
-
- # Returns an array of missing syntax characters
- # or `"end"` or `"keyword"`
- #
- # left_right.missing
- # # => ["}"]
- def missing
- out = missing_pairs
- out << missing_pipe
- out << missing_keyword_end
- out.compact!
- out
- end
-
- PAIRS = {
- "{" => "}",
- "[" => "]",
- "(" => ")"
- }.freeze
-
- # Opening characters like `{` need closing characters # like `}`.
- #
- # When a mis-match count is detected, suggest the
- # missing member.
- #
- # For example if there are 3 `}` and only two `{`
- # return `"{"`
- private def missing_pairs
- PAIRS.map do |(left, right)|
- case @count_for_char[left] <=> @count_for_char[right]
- when 1
- right
- when 0
- nil
- when -1
- left
- end
- end
- end
-
- # Keywords need ends and ends need keywords
- #
- # If we have more keywords, there's a missing `end`
- # if we have more `end`-s, there's a missing keyword
- private def missing_keyword_end
- case @kw_count <=> @end_count
- when 1
- "end"
- when 0
- nil
- when -1
- "keyword"
- end
- end
-
- # Pipes come in pairs.
- # If there's an odd number of pipes then we
- # are missing one
- private def missing_pipe
- if @count_for_char["|"].odd?
- "|"
- end
- end
- end
-end
diff --git a/lib/syntax_suggest/left_right_token_count.rb b/lib/syntax_suggest/left_right_token_count.rb
new file mode 100644
index 0000000000..e0562ba9cd
--- /dev/null
+++ b/lib/syntax_suggest/left_right_token_count.rb
@@ -0,0 +1,162 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ # Find mis-matched syntax based on lexical count
+ #
+ # Used for detecting missing pairs of elements
+ # each keyword needs an end, each '{' needs a '}'
+ # etc.
+ #
+ # Example:
+ #
+ # left_right = LeftRightTokenCount.new
+ # left_right.count_kw
+ # left_right.missing.first
+ # # => "end"
+ #
+ # left_right = LeftRightTokenCount.new
+ # source = "{ a: b, c: d" # Note missing '}'
+ # LexAll.new(source: source).each do |token|
+ # left_right.count_token(token)
+ # end
+ # left_right.missing.first
+ # # => "}"
+ class LeftRightTokenCount
+ def initialize
+ @kw_count = 0
+ @end_count = 0
+
+ @count_for_char = {
+ "{" => 0,
+ "}" => 0,
+ "[" => 0,
+ "]" => 0,
+ "(" => 0,
+ ")" => 0,
+ "|" => 0
+ }
+ end
+
+ def count_kw
+ @kw_count += 1
+ end
+
+ def count_end
+ @end_count += 1
+ end
+
+ # Count source code characters
+ #
+ # Example:
+ #
+ # token = CodeLine.from_source("{").first.tokens.first
+ # left_right = LeftRightTokenCount.new
+ # left_right.count_token(Token.new(token)
+ # left_right.count_for_char("{")
+ # # => 1
+ # left_right.count_for_char("}")
+ # # => 0
+ def count_token(token)
+ case token.type
+ when :STRING_CONTENT
+ # ^^^
+ # Means it's a string or a symbol `"{"` rather than being
+ # part of a data structure (like a hash) `{ a: b }`
+ # ignore it.
+ when :PERCENT_UPPER_W, :PERCENT_UPPER_I, :PERCENT_LOWER_W,
+ :PERCENT_LOWER_I, :REGEXP_BEGIN, :STRING_BEGIN
+ # ^^^
+ # Handle shorthand syntaxes like `%Q{ i am a string }`
+ #
+ # The start token will be the full thing `%Q{` but we
+ # need to count it as if it's a `{`. Any token
+ # can be used
+ char = token.value[-1]
+ @count_for_char[char] += 1 if @count_for_char.key?(char)
+ when :EMBEXPR_BEGIN
+ # ^^^
+ # Embedded string expressions like `"#{foo} <-embed"`
+ # are parsed with chars:
+ #
+ # `#{` as :EMBEXPR_BEGIN
+ # `}` as :EMBEXPR_END
+ #
+ # When we see `#{` count it as a `{` or we will
+ # have a mis-match count.
+ #
+ @count_for_char["{"] += 1
+ else
+ @end_count += 1 if token.is_end?
+ @kw_count += 1 if token.is_kw?
+ @count_for_char[token.value] += 1 if @count_for_char.key?(token.value)
+ end
+ end
+
+ def count_for_char(char)
+ @count_for_char[char]
+ end
+
+ # Returns an array of missing syntax characters
+ # or `"end"` or `"keyword"`
+ #
+ # left_right.missing
+ # # => ["}"]
+ def missing
+ out = missing_pairs
+ out << missing_pipe
+ out << missing_keyword_end
+ out.compact!
+ out
+ end
+
+ PAIRS = {
+ "{" => "}",
+ "[" => "]",
+ "(" => ")"
+ }.freeze
+
+ # Opening characters like `{` need closing characters # like `}`.
+ #
+ # When a mis-match count is detected, suggest the
+ # missing member.
+ #
+ # For example if there are 3 `}` and only two `{`
+ # return `"{"`
+ private def missing_pairs
+ PAIRS.map do |(left, right)|
+ case @count_for_char[left] <=> @count_for_char[right]
+ when 1
+ right
+ when 0
+ nil
+ when -1
+ left
+ end
+ end
+ end
+
+ # Keywords need ends and ends need keywords
+ #
+ # If we have more keywords, there's a missing `end`
+ # if we have more `end`-s, there's a missing keyword
+ private def missing_keyword_end
+ case @kw_count <=> @end_count
+ when 1
+ "end"
+ when 0
+ nil
+ when -1
+ "keyword"
+ end
+ end
+
+ # Pipes come in pairs.
+ # If there's an odd number of pipes then we
+ # are missing one
+ private def missing_pipe
+ if @count_for_char["|"].odd?
+ "|"
+ end
+ end
+ end
+end
diff --git a/lib/syntax_suggest/lex_all.rb b/lib/syntax_suggest/lex_all.rb
deleted file mode 100644
index 132cba9f5d..0000000000
--- a/lib/syntax_suggest/lex_all.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-module SyntaxSuggest
- # Ripper.lex is not guaranteed to lex the entire source document
- #
- # lex = LexAll.new(source: source)
- # lex.each do |value|
- # puts value.line
- # end
- class LexAll
- include Enumerable
-
- def initialize(source:, source_lines: nil)
- @lex = Ripper::Lexer.new(source, "-", 1).parse.sort_by(&:pos)
- lineno = @lex.last.pos.first + 1
- source_lines ||= source.lines
- last_lineno = source_lines.length
-
- until lineno >= last_lineno
- lines = source_lines[lineno..-1]
-
- @lex.concat(
- Ripper::Lexer.new(lines.join, "-", lineno + 1).parse.sort_by(&:pos)
- )
- lineno = @lex.last.pos.first + 1
- end
-
- last_lex = nil
- @lex.map! { |elem|
- last_lex = LexValue.new(elem.pos.first, elem.event, elem.tok, elem.state, last_lex)
- }
- end
-
- def to_a
- @lex
- end
-
- def each
- return @lex.each unless block_given?
- @lex.each do |x|
- yield x
- end
- end
-
- def [](index)
- @lex[index]
- end
-
- def last
- @lex.last
- end
- end
-end
-
-require_relative "lex_value"
diff --git a/lib/syntax_suggest/lex_value.rb b/lib/syntax_suggest/lex_value.rb
deleted file mode 100644
index 008cc105b5..0000000000
--- a/lib/syntax_suggest/lex_value.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# frozen_string_literal: true
-
-module SyntaxSuggest
- # Value object for accessing lex values
- #
- # This lex:
- #
- # [1, 0], :on_ident, "describe", CMDARG
- #
- # Would translate into:
- #
- # lex.line # => 1
- # lex.type # => :on_indent
- # lex.token # => "describe"
- class LexValue
- attr_reader :line, :type, :token, :state
-
- def initialize(line, type, token, state, last_lex = nil)
- @line = line
- @type = type
- @token = token
- @state = state
-
- set_kw_end(last_lex)
- end
-
- private def set_kw_end(last_lex)
- @is_end = false
- @is_kw = false
- return if type != :on_kw
- #
- return if last_lex && last_lex.fname? # https://github.com/ruby/ruby/commit/776759e300e4659bb7468e2b97c8c2d4359a2953
-
- case token
- when "if", "unless", "while", "until"
- # Only count if/unless when it's not a "trailing" if/unless
- # https://github.com/ruby/ruby/blob/06b44f819eb7b5ede1ff69cecb25682b56a1d60c/lib/irb/ruby-lex.rb#L374-L375
- @is_kw = true unless expr_label?
- when "def", "case", "for", "begin", "class", "module", "do"
- @is_kw = true
- when "end"
- @is_end = true
- end
- end
-
- def fname?
- state.allbits?(Ripper::EXPR_FNAME)
- end
-
- def ignore_newline?
- type == :on_ignored_nl
- end
-
- def is_end?
- @is_end
- end
-
- def is_kw?
- @is_kw
- end
-
- def expr_beg?
- state.anybits?(Ripper::EXPR_BEG)
- end
-
- def expr_label?
- state.allbits?(Ripper::EXPR_LABEL)
- end
- end
-end
diff --git a/lib/syntax_suggest/mini_stringio.rb b/lib/syntax_suggest/mini_stringio.rb
new file mode 100644
index 0000000000..1a82572eeb
--- /dev/null
+++ b/lib/syntax_suggest/mini_stringio.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ # Mini String IO [Private]
+ #
+ # Acts like a StringIO with reduced API, but without having to require that
+ # class.
+ #
+ # The original codebase emitted directly to $stderr, but now SyntaxError#detailed_message
+ # needs a string output. To accomplish that we kept the original print infrastructure in place and
+ # added this class to accumulate the print output into a string.
+ class MiniStringIO
+ EMPTY_ARG = Object.new
+
+ def initialize(isatty: $stderr.isatty)
+ @string = +""
+ @isatty = isatty
+ end
+
+ attr_reader :isatty
+ def puts(value = EMPTY_ARG, **)
+ if !value.equal?(EMPTY_ARG)
+ @string << value
+ end
+ @string << $/
+ end
+
+ attr_reader :string
+ end
+end
diff --git a/lib/syntax_suggest/parse_blocks_from_indent_line.rb b/lib/syntax_suggest/parse_blocks_from_indent_line.rb
index d1071732fe..39dfca55d2 100644
--- a/lib/syntax_suggest/parse_blocks_from_indent_line.rb
+++ b/lib/syntax_suggest/parse_blocks_from_indent_line.rb
@@ -8,7 +8,7 @@ module SyntaxSuggest
# grabbing one that contains only an "end". In this example:
#
# def dog
- # begonn # mispelled `begin`
+ # begonn # misspelled `begin`
# puts "bark"
# end
# end
@@ -36,8 +36,8 @@ module SyntaxSuggest
# Builds blocks from bottom up
def each_neighbor_block(target_line)
scan = AroundBlockScan.new(code_lines: code_lines, block: CodeBlock.new(lines: target_line))
- .skip(:empty?)
- .skip(:hidden?)
+ .force_add_empty
+ .force_add_hidden
.scan_while { |line| line.indent >= target_line.indent }
neighbors = scan.code_block.lines
diff --git a/lib/syntax_suggest/pathname_from_message.rb b/lib/syntax_suggest/pathname_from_message.rb
index b6fe1617be..ab90227427 100644
--- a/lib/syntax_suggest/pathname_from_message.rb
+++ b/lib/syntax_suggest/pathname_from_message.rb
@@ -13,7 +13,7 @@ module SyntaxSuggest
# # => "/tmp/scratch.rb"
#
class PathnameFromMessage
- EVAL_RE = /^\(eval\):\d+/
+ EVAL_RE = /^\(eval.*\):\d+/
STREAMING_RE = /^-:\d+/
attr_reader :name
diff --git a/lib/syntax_suggest/ripper_errors.rb b/lib/syntax_suggest/ripper_errors.rb
deleted file mode 100644
index 48eb206e48..0000000000
--- a/lib/syntax_suggest/ripper_errors.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-module SyntaxSuggest
- # Capture parse errors from ripper
- #
- # Example:
- #
- # puts RipperErrors.new(" def foo").call.errors
- # # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"]
- class RipperErrors < Ripper
- attr_reader :errors
-
- # Comes from ripper, called
- # on every parse error, msg
- # is a string
- def on_parse_error(msg)
- @errors ||= []
- @errors << msg
- end
-
- alias_method :on_alias_error, :on_parse_error
- alias_method :on_assign_error, :on_parse_error
- alias_method :on_class_name_error, :on_parse_error
- alias_method :on_param_error, :on_parse_error
- alias_method :compile_error, :on_parse_error
-
- def call
- @run_once ||= begin
- @errors = []
- parse
- true
- end
- self
- end
- end
-end
diff --git a/lib/syntax_suggest/scan_history.rb b/lib/syntax_suggest/scan_history.rb
new file mode 100644
index 0000000000..dc36e6ba2e
--- /dev/null
+++ b/lib/syntax_suggest/scan_history.rb
@@ -0,0 +1,134 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ # Scans up/down from the given block
+ #
+ # You can try out a change, stash it, or commit it to save for later
+ #
+ # Example:
+ #
+ # scanner = ScanHistory.new(code_lines: code_lines, block: block)
+ # scanner.scan(
+ # up: ->(_, _, _) { true },
+ # down: ->(_, _, _) { true }
+ # )
+ # scanner.changed? # => true
+ # expect(scanner.lines).to eq(code_lines)
+ #
+ # scanner.stash_changes
+ #
+ # expect(scanner.lines).to_not eq(code_lines)
+ class ScanHistory
+ attr_reader :before_index, :after_index
+
+ def initialize(code_lines:, block:)
+ @code_lines = code_lines
+ @history = [block]
+ refresh_index
+ end
+
+ def commit_if_changed
+ if changed?
+ @history << CodeBlock.new(lines: @code_lines[before_index..after_index])
+ end
+
+ self
+ end
+
+ # Discards any changes that have not been committed
+ def stash_changes
+ refresh_index
+ self
+ end
+
+ # Discard changes that have not been committed and revert the last commit
+ #
+ # Cannot revert the first commit
+ def revert_last_commit
+ if @history.length > 1
+ @history.pop
+ refresh_index
+ end
+
+ self
+ end
+
+ def changed?
+ @before_index != current.lines.first.index ||
+ @after_index != current.lines.last.index
+ end
+
+ # Iterates up and down
+ #
+ # Returns line, kw_count, end_count for each iteration
+ def scan(up:, down:)
+ kw_count = 0
+ end_count = 0
+
+ up_index = before_lines.reverse_each.take_while do |line|
+ kw_count += 1 if line.is_kw?
+ end_count += 1 if line.is_end?
+ up.call(line, kw_count, end_count)
+ end.last&.index
+
+ kw_count = 0
+ end_count = 0
+
+ down_index = after_lines.each.take_while do |line|
+ kw_count += 1 if line.is_kw?
+ end_count += 1 if line.is_end?
+ down.call(line, kw_count, end_count)
+ end.last&.index
+
+ @before_index = if up_index && up_index < @before_index
+ up_index
+ else
+ @before_index
+ end
+
+ @after_index = if down_index && down_index > @after_index
+ down_index
+ else
+ @after_index
+ end
+
+ self
+ end
+
+ def next_up
+ return nil if @before_index <= 0
+
+ @code_lines[@before_index - 1]
+ end
+
+ def next_down
+ return nil if @after_index >= @code_lines.length
+
+ @code_lines[@after_index + 1]
+ end
+
+ def lines
+ @code_lines[@before_index..@after_index]
+ end
+
+ private def before_lines
+ @code_lines[0...@before_index] || []
+ end
+
+ # Returns an array of all the CodeLines that exist after
+ # the currently scanned block
+ private def after_lines
+ @code_lines[@after_index.next..] || []
+ end
+
+ private def current
+ @history.last
+ end
+
+ private def refresh_index
+ @before_index = current.lines.first.index
+ @after_index = current.lines.last.index
+ self
+ end
+ end
+end
diff --git a/lib/syntax_suggest/syntax_suggest.gemspec b/lib/syntax_suggest/syntax_suggest.gemspec
index 73b25c6a5f..44e458aaad 100644
--- a/lib/syntax_suggest/syntax_suggest.gemspec
+++ b/lib/syntax_suggest/syntax_suggest.gemspec
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.description = 'When you get an "unexpected end" in your syntax this gem helps you find it'
spec.homepage = "https://github.com/ruby/syntax_suggest.git"
spec.license = "MIT"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/ruby/syntax_suggest.git"
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|assets)/}) }
end
spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.executables = ["syntax_suggest"]
spec.require_paths = ["lib"]
end
diff --git a/lib/syntax_suggest/token.rb b/lib/syntax_suggest/token.rb
new file mode 100644
index 0000000000..fc52639b1f
--- /dev/null
+++ b/lib/syntax_suggest/token.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ # Value object for accessing lex values
+ #
+ # This lex:
+ #
+ # [IDENTIFIER(1,0)-(1,8)("describe"), 32]
+ #
+ # Would translate into:
+ #
+ # lex.location # => (1,0)-(1,8)
+ # lex.type # => :IDENTIFIER
+ # lex.token # => "describe"
+ class Token
+ attr_reader :location, :type, :value
+
+ KW_TYPES = %i[
+ KEYWORD_IF KEYWORD_UNLESS KEYWORD_WHILE KEYWORD_UNTIL
+ KEYWORD_DEF KEYWORD_CASE KEYWORD_FOR KEYWORD_BEGIN KEYWORD_CLASS KEYWORD_MODULE KEYWORD_DO KEYWORD_DO_LOOP
+ ].to_set.freeze
+ private_constant :KW_TYPES
+
+ def initialize(prism_token, previous_prism_token, visitor)
+ @location = prism_token.location
+ @type = prism_token.type
+ @value = prism_token.value
+
+ # Prism lexes `:module` as SYMBOL_BEGIN, KEYWORD_MODULE
+ # https://github.com/ruby/prism/issues/3940
+ symbol_content = previous_prism_token&.type == :SYMBOL_BEGIN
+ @is_kw = KW_TYPES.include?(@type)
+ @is_kw = false if symbol_content || visitor.endless_def_keyword_offsets.include?(@location.start_offset)
+ @is_end = @type == :KEYWORD_END
+ end
+
+ def line
+ @location.start_line
+ end
+
+ def is_end?
+ @is_end
+ end
+
+ def is_kw?
+ @is_kw
+ end
+ end
+end
diff --git a/lib/syntax_suggest/version.rb b/lib/syntax_suggest/version.rb
index d9ea5200e6..9114a079f6 100644
--- a/lib/syntax_suggest/version.rb
+++ b/lib/syntax_suggest/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module SyntaxSuggest
- VERSION = "1.0.2"
+ VERSION = "3.0.0"
end
diff --git a/lib/syntax_suggest/visitor.rb b/lib/syntax_suggest/visitor.rb
new file mode 100644
index 0000000000..6e25f7239c
--- /dev/null
+++ b/lib/syntax_suggest/visitor.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+module SyntaxSuggest
+ # Walks the Prism AST to extract structural info that cannot be reliably determined from tokens
+ # alone.
+ #
+ # Such as the location of lines that must be logically joined so the search algorithm will
+ # treat them as one. Example:
+ #
+ # source = <<~RUBY
+ # User # 1
+ # .where(name: "Earlopain") # 2
+ # .first # 3
+ # RUBY
+ # ast, _tokens = Prism.parse_lex(source).value
+ # visitor = Visitor.new
+ # visitor.visit(ast)
+ # visitor.consecutive_lines # => Set[2, 1]
+ #
+ # This output means that line 1 and line 2 need to be joined with their next line.
+ #
+ # And determining the location of "endless" method definitions. For example:
+ #
+ # source = <<~RUBY
+ # def cube(x)
+ # x * x * x
+ # end
+ # def square(x) = x * x # 1
+ # RUBY
+ #
+ # ast, _tokens = Prism.parse_lex(source).value
+ # visitor = Visitor.new
+ # visitor.visit(ast)
+ # visitor.endless_def_keyword_offsets # => Set[28]
+ class Visitor < Prism::Visitor
+ attr_reader :endless_def_keyword_offsets, :consecutive_lines
+
+ def initialize
+ @endless_def_keyword_offsets = Set.new
+ @consecutive_lines = Set.new
+ end
+
+ # Called by Prism::Visitor for every method-call node in the AST
+ # (e.g. `foo.bar`, `foo.bar.baz`).
+ def visit_call_node(node)
+ receiver_loc = node.receiver&.location
+ call_operator_loc = node.call_operator_loc
+ message_loc = node.message_loc
+ if receiver_loc && call_operator_loc && message_loc
+ # dot-leading (dot on the next line)
+ # foo # line 1 - consecutive
+ # .bar # line 2
+ if receiver_loc.end_line != call_operator_loc.start_line && call_operator_loc.start_line == message_loc.start_line
+ (receiver_loc.end_line..call_operator_loc.start_line - 1).each do |line|
+ @consecutive_lines << line
+ end
+ end
+
+ # dot-trailing (dot on the same line as the receiver)
+ # foo. # line 1 - consecutive
+ # bar # line 2
+ if receiver_loc.end_line == call_operator_loc.start_line && call_operator_loc.start_line != message_loc.start_line
+ (call_operator_loc.start_line..message_loc.start_line - 1).each do |line|
+ @consecutive_lines << line
+ end
+ end
+ end
+ super
+ end
+
+ # Called by Prism::Visitor for every `def` node in the AST.
+ # Records the keyword start location for endless method definitions
+ # like `def foo = 123`. These are valid without a matching `end`,
+ # so Token must exclude them when deciding if a line is a keyword.
+ def visit_def_node(node)
+ @endless_def_keyword_offsets << node.def_keyword_loc.start_offset if node.equal_loc
+ super
+ end
+ end
+end
diff --git a/lib/tempfile.gemspec b/lib/tempfile.gemspec
index acb26b68db..0b362b0a86 100644
--- a/lib/tempfile.gemspec
+++ b/lib/tempfile.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "tempfile"
- spec.version = "0.1.3"
+ spec.name = name
+ spec.version = version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -15,8 +22,12 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ gemspec = File.basename(__FILE__)
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL, exception: false) do |ls|
+ ls.readlines("\x0", chomp: true).reject do |f|
+ (f == gemspec) ||
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git Gemfile])
+ end
end
spec.require_paths = ["lib"]
end
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 1bb13e9501..cd512bb1c5 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -8,18 +8,61 @@
require 'delegate'
require 'tmpdir'
-# A utility class for managing temporary files. When you create a Tempfile
-# object, it will create a temporary file with a unique filename. A Tempfile
-# objects behaves just like a File object, and you can perform all the usual
-# file operations on it: reading data, writing data, changing its permissions,
-# etc. So although this class does not explicitly document all instance methods
-# supported by File, you can in fact call any File instance method on a
-# Tempfile object.
+# A utility class for managing temporary files.
+#
+# There are two kind of methods of creating a temporary file:
+#
+# - Tempfile.create (recommended)
+# - Tempfile.new and Tempfile.open (mostly for backward compatibility, not recommended)
+#
+# Tempfile.create creates a usual \File object.
+# The timing of file deletion is predictable.
+# Also, it supports open-and-unlink technique which
+# removes the temporary file immediately after creation.
+#
+# Tempfile.new and Tempfile.open creates a \Tempfile object.
+# The created file is removed by the GC (finalizer).
+# The timing of file deletion is not predictable.
#
# == Synopsis
#
# require 'tempfile'
#
+# # Tempfile.create with a block
+# # The filename are chosen automatically.
+# # (You can specify the prefix and suffix of the filename by an optional argument.)
+# Tempfile.create {|f|
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# } # The file is removed at block exit.
+#
+# # Tempfile.create without a block
+# # You need to unlink the file in non-block form.
+# f = Tempfile.create
+# f.puts "foo"
+# f.close
+# File.unlink(f.path) # You need to unlink the file.
+#
+# # Tempfile.create(anonymous: true) without a block
+# f = Tempfile.create(anonymous: true)
+# # The file is already removed because anonymous.
+# f.path # => "/tmp/" (no filename since no file)
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# f.close
+#
+# # Tempfile.create(anonymous: true) with a block
+# Tempfile.create(anonymous: true) {|f|
+# # The file is already removed because anonymous.
+# f.path # => "/tmp/" (no filename since no file)
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# }
+#
+# # Not recommended: Tempfile.new without a block
# file = Tempfile.new('foo')
# file.path # => A unique filename in the OS's temp directory,
# # e.g.: "/tmp/foo.24722.0"
@@ -30,7 +73,27 @@ require 'tmpdir'
# file.close
# file.unlink # deletes the temp file
#
-# == Good practices
+# == About Tempfile.new and Tempfile.open
+#
+# This section does not apply to Tempfile.create because
+# it returns a File object (not a Tempfile object).
+#
+# When you create a Tempfile object,
+# it will create a temporary file with a unique filename. A Tempfile
+# objects behaves just like a File object, and you can perform all the usual
+# file operations on it: reading data, writing data, changing its permissions,
+# etc. So although this class does not explicitly document all instance methods
+# supported by File, you can in fact call any File instance method on a
+# Tempfile object.
+#
+# A Tempfile object has a finalizer to remove the temporary file.
+# This means that the temporary file is removed via GC.
+# This can cause several problems:
+#
+# - Long GC intervals and conservative GC can accumulate temporary files that are not removed.
+# - Temporary files are not removed if Ruby exits abnormally (such as SIGKILL, SEGV).
+#
+# There are legacy good practices for Tempfile.new and Tempfile.open as follows.
#
# === Explicit close
#
@@ -71,12 +134,17 @@ require 'tmpdir'
# be able to read from or write to the Tempfile, and you do not need to
# know the Tempfile's filename either.
#
+# Also, this guarantees the temporary file is removed even if Ruby exits abnormally.
+# The OS reclaims the storage for the temporary file when the file is closed or
+# the Ruby process exits (normally or abnormally).
+#
# For example, a practical use case for unlink-after-creation would be this:
# you need a large byte buffer that's too large to comfortably fit in RAM,
# e.g. when you're writing a web server and you want to buffer the client's
# file upload data.
#
-# Please refer to #unlink for more information and a code example.
+# `Tempfile.create(anonymous: true)` supports this behavior.
+# It also works on Windows.
#
# == Minor notes
#
@@ -88,6 +156,9 @@ require 'tmpdir'
# mutex.
class Tempfile < DelegateClass(File)
+ # The version
+ VERSION = "0.3.1"
+
# Creates a file in the underlying file system;
# returns a new \Tempfile object based on that file.
#
@@ -150,26 +221,52 @@ class Tempfile < DelegateClass(File)
@unlinked = false
@mode = mode|File::RDWR|File::CREAT|File::EXCL
+ tmpfile = nil
::Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
opts[:perm] = 0600
- @tmpfile = File.open(tmpname, @mode, **opts)
+ tmpfile = File.open(tmpname, @mode, **opts)
@opts = opts.freeze
end
- ObjectSpace.define_finalizer(self, Remover.new(@tmpfile))
- super(@tmpfile)
+ super(tmpfile)
+
+ @finalizer_manager = FinalizerManager.new(__getobj__.path)
+ @finalizer_manager.register(self, __getobj__)
+ end
+
+ def initialize_dup(other) # :nodoc:
+ initialize_copy_iv(other)
+ super(other)
+ @finalizer_manager.register(self, __getobj__)
+ end
+
+ def initialize_clone(other) # :nodoc:
+ initialize_copy_iv(other)
+ super(other)
+ @finalizer_manager.register(self, __getobj__)
+ end
+
+ private def initialize_copy_iv(other) # :nodoc:
+ @unlinked = other.unlinked
+ @mode = other.mode
+ @opts = other.opts
+ @finalizer_manager = other.finalizer_manager
end
# Opens or reopens the file with mode "r+".
def open
_close
+
mode = @mode & ~(File::CREAT|File::EXCL)
- @tmpfile = File.open(@tmpfile.path, mode, **@opts)
- __setobj__(@tmpfile)
+ __setobj__(File.open(__getobj__.path, mode, **@opts))
+
+ @finalizer_manager.register(self, __getobj__)
+
+ __getobj__
end
def _close # :nodoc:
- @tmpfile.close
+ __getobj__.close
end
protected :_close
@@ -226,13 +323,15 @@ class Tempfile < DelegateClass(File)
def unlink
return if @unlinked
begin
- File.unlink(@tmpfile.path)
+ File.unlink(__getobj__.path)
rescue Errno::ENOENT
rescue Errno::EACCES
# may not be able to unlink on Windows; just ignore
return
end
- ObjectSpace.undefine_finalizer(self)
+
+ @finalizer_manager.unlinked = true
+
@unlinked = true
end
alias delete unlink
@@ -240,47 +339,61 @@ class Tempfile < DelegateClass(File)
# Returns the full path name of the temporary file.
# This will be nil if #unlink has been called.
def path
- @unlinked ? nil : @tmpfile.path
+ @unlinked ? nil : __getobj__.path
end
# Returns the size of the temporary file. As a side effect, the IO
# buffer is flushed before determining the size.
def size
- if !@tmpfile.closed?
- @tmpfile.size # File#size calls rb_io_flush_raw()
+ if !__getobj__.closed?
+ __getobj__.size # File#size calls rb_io_flush_raw()
else
- File.size(@tmpfile.path)
+ File.size(__getobj__.path)
end
end
alias length size
# :stopdoc:
def inspect
- if @tmpfile.closed?
+ if __getobj__.closed?
"#<#{self.class}:#{path} (closed)>"
else
"#<#{self.class}:#{path}>"
end
end
+ alias to_s inspect
- class Remover # :nodoc:
- def initialize(tmpfile)
+ protected
+
+ attr_reader :unlinked, :mode, :opts, :finalizer_manager
+
+ class FinalizerManager # :nodoc:
+ attr_accessor :unlinked
+
+ def initialize(path)
+ @open_files = {}
+ @path = path
@pid = Process.pid
- @tmpfile = tmpfile
+ @unlinked = false
end
- def call(*args)
- return if @pid != Process.pid
+ def register(obj, file)
+ ObjectSpace.undefine_finalizer(obj)
+ ObjectSpace.define_finalizer(obj, self)
+ @open_files[obj.object_id] = file
+ end
- $stderr.puts "removing #{@tmpfile.path}..." if $DEBUG
+ def call(object_id)
+ @open_files.delete(object_id).close
- @tmpfile.close
- begin
- File.unlink(@tmpfile.path)
- rescue Errno::ENOENT
+ if @open_files.empty? && !@unlinked && Process.pid == @pid
+ $stderr.puts "removing #{@path}..." if $DEBUG
+ begin
+ File.unlink(@path)
+ rescue Errno::ENOENT
+ end
+ $stderr.puts "done" if $DEBUG
end
-
- $stderr.puts "done" if $DEBUG
end
end
@@ -351,8 +464,9 @@ end
# see {File Permissions}[rdoc-ref:File@File+Permissions].
# - Mode is <tt>'w+'</tt> (read/write mode, positioned at the end).
#
-# With no block, the file is not removed automatically,
-# and so should be explicitly removed.
+# The temporary file removal depends on the keyword argument +anonymous+ and
+# whether a block is given or not.
+# See the description about the +anonymous+ keyword argument later.
#
# Example:
#
@@ -360,11 +474,36 @@ end
# f.class # => File
# f.path # => "/tmp/20220505-9795-17ky6f6"
# f.stat.mode.to_s(8) # => "100600"
+# f.close
# File.exist?(f.path) # => true
# File.unlink(f.path)
# File.exist?(f.path) # => false
#
-# Argument +basename+, if given, may be one of:
+# Tempfile.create {|f|
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# f.path # => "/tmp/20240524-380207-oma0ny"
+# File.exist?(f.path) # => true
+# } # The file is removed at block exit.
+#
+# f = Tempfile.create(anonymous: true)
+# # The file is already removed because anonymous
+# f.path # => "/tmp/" (no filename since no file)
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# f.close
+#
+# Tempfile.create(anonymous: true) {|f|
+# # The file is already removed because anonymous
+# f.path # => "/tmp/" (no filename since no file)
+# f.puts "foo"
+# f.rewind
+# f.read # => "foo\n"
+# }
+#
+# The argument +basename+, if given, may be one of the following:
#
# - A string: the generated filename begins with +basename+:
#
@@ -375,27 +514,59 @@ end
#
# Tempfile.create(%w/foo .jpg/) # => #<File:/tmp/foo20220505-17839-tnjchh.jpg>
#
-# With arguments +basename+ and +tmpdir+, the file is created in directory +tmpdir+:
+# With arguments +basename+ and +tmpdir+, the file is created in the directory +tmpdir+:
#
# Tempfile.create('foo', '.') # => #<File:./foo20220505-9795-1emu6g8>
#
-# Keyword arguments +mode+ and +options+ are passed directly to method
+# Keyword arguments +mode+ and +options+ are passed directly to the method
# {File.open}[rdoc-ref:File.open]:
#
-# - The value given with +mode+ must be an integer,
+# - The value given for +mode+ must be an integer
# and may be expressed as the logical OR of constants defined in
# {File::Constants}[rdoc-ref:File::Constants].
# - For +options+, see {Open Options}[rdoc-ref:IO@Open+Options].
#
-# With a block given, creates the file as above, passes it to the block,
-# and returns the block's value;
-# before the return, the file object is closed and the underlying file is removed:
+# The keyword argument +anonymous+ specifies when the file is removed.
+#
+# - <tt>anonymous=false</tt> (default) without a block: the file is not removed.
+# - <tt>anonymous=false</tt> (default) with a block: the file is removed after the block exits.
+# - <tt>anonymous=true</tt> without a block: the file is removed before returning.
+# - <tt>anonymous=true</tt> with a block: the file is removed before the block is called.
+#
+# In the first case (<tt>anonymous=false</tt> without a block),
+# the file is not removed automatically.
+# It should be explicitly closed.
+# It can be used to rename to the desired filename.
+# If the file is not needed, it should be explicitly removed.
+#
+# The File#path method of the created file object returns the temporary directory with a trailing slash
+# when +anonymous+ is true.
+#
+# When a block is given, it creates the file as described above, passes it to the block,
+# and returns the block's value.
+# Before the returning, the file object is closed and the underlying file is removed:
#
# Tempfile.create {|file| file.path } # => "/tmp/20220505-9795-rkists"
#
+# Implementation note:
+#
+# The keyword argument <tt>anonymous=true</tt> is implemented using +FILE_SHARE_DELETE+ on Windows.
+# +O_TMPFILE+ is used on Linux.
+#
# Related: Tempfile.new.
#
-def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
+def Tempfile.create(basename="", tmpdir=nil, mode: 0, anonymous: false, **options, &block)
+ if anonymous
+ create_anonymous(basename, tmpdir, mode: mode, **options, &block)
+ else
+ create_with_filename(basename, tmpdir, mode: mode, **options, &block)
+ end
+end
+
+class << Tempfile
+# :stopdoc:
+
+private def create_with_filename(basename="", tmpdir=nil, mode: 0, **options)
tmpfile = nil
Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
mode |= File::RDWR|File::CREAT|File::EXCL
@@ -423,3 +594,49 @@ def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
tmpfile
end
end
+
+if RUBY_VERSION < "3.2"
+ module PathAttr # :nodoc:
+ attr_reader :path
+
+ def self.set_path(file, path)
+ file.extend(self).instance_variable_set(:@path, path)
+ end
+ end
+end
+
+private def create_anonymous(basename="", tmpdir=nil, mode: 0, **options, &block)
+ tmpfile = nil
+ tmpdir = Dir.tmpdir() if tmpdir.nil?
+ if defined?(File::TMPFILE) # O_TMPFILE since Linux 3.11
+ begin
+ tmpfile = File.open(tmpdir, File::RDWR | File::TMPFILE, 0600)
+ rescue Errno::EISDIR, Errno::ENOENT, Errno::EOPNOTSUPP
+ # kernel or the filesystem does not support O_TMPFILE
+ # fallback to create-and-unlink
+ end
+ end
+ if tmpfile.nil?
+ mode |= File::SHARE_DELETE | File::BINARY # Windows needs them to unlink the opened file.
+ tmpfile = create_with_filename(basename, tmpdir, mode: mode, **options)
+ File.unlink(tmpfile.path)
+ tmppath = tmpfile.path
+ end
+ path = File.join(tmpdir, '')
+ unless tmppath == path
+ # clear path.
+ tmpfile.autoclose = false
+ tmpfile = File.new(tmpfile.fileno, mode: File::RDWR, path: path)
+ PathAttr.set_path(tmpfile, path) if defined?(PathAttr)
+ end
+ if block
+ begin
+ yield tmpfile
+ ensure
+ tmpfile.close
+ end
+ else
+ tmpfile
+ end
+end
+end
diff --git a/lib/time.gemspec b/lib/time.gemspec
index e4b5502f28..73650ab12e 100644
--- a/lib/time.gemspec
+++ b/lib/time.gemspec
@@ -1,20 +1,32 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "time"
- spec.version = "0.2.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
spec.summary = %q{Extends the Time class with methods for parsing and conversion.}
spec.description = %q{Extends the Time class with methods for parsing and conversion.}
spec.homepage = "https://github.com/ruby/time"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/time/releases"
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ srcdir, gemspec = File.split(__FILE__)
+ spec.files = Dir.chdir(srcdir) do
+ `git ls-files -z`.split("\x0").reject { |f|
+ f == gemspec or
+ f.start_with?(".git", "bin/", "test/", "rakelib/", "Gemfile", "Rakefile")
+ }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/time.rb b/lib/time.rb
index 43c4d802e5..e6aab3fa5d 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -24,7 +24,11 @@ require 'date'
# :startdoc:
+# #
class Time
+
+ VERSION = "0.4.2" # :nodoc:
+
class << Time
#
@@ -76,7 +80,7 @@ class Time
#
# You must require 'time' to use this method.
#
- def zone_offset(zone, year=self.now.year)
+ def zone_offset(zone, year=nil)
off = nil
zone = zone.upcase
if /\A([+-])(\d\d)(:?)(\d\d)(?:\3(\d\d))?\z/ =~ zone
@@ -85,10 +89,13 @@ class Time
off = zone.to_i * 3600
elsif ZoneOffset.include?(zone)
off = ZoneOffset[zone] * 3600
- elsif ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false)
- off = t.utc_offset
- elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false)
- off = t.utc_offset
+ else
+ year ||= self.now.year
+ if ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false)
+ off = t.utc_offset
+ elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false)
+ off = t.utc_offset
+ end
end
off
end
@@ -277,7 +284,7 @@ class Time
#
# This method **does not** function as a validator. If the input
# string does not match valid formats strictly, you may get a
- # cryptic result. Should consider to use `Time.strptime` instead
+ # cryptic result. Should consider to use Time.strptime instead
# of this method as possible.
#
# require 'time'
@@ -388,6 +395,8 @@ class Time
# heuristic to detect the format of the input string, you provide
# a second argument that describes the format of the string.
#
+ # Raises ArgumentError if the date or format is invalid.
+ #
# If a block is given, the year described in +date+ is converted by the
# block. For example:
#
@@ -402,7 +411,7 @@ class Time
# %c :: The preferred local date and time representation
# %C :: Century (20 in 2009)
# %d :: Day of the month (01..31)
- # %D :: Date (%m/%d/%y)
+ # %D :: \Date (%m/%d/%y)
# %e :: Day of the month, blank-padded ( 1..31)
# %F :: Equivalent to %Y-%m-%d (the ISO 8601 date format)
# %g :: The last two digits of the commercial year
@@ -439,8 +448,8 @@ class Time
# %X :: Preferred representation for the time alone, no date
# %y :: Year without a century (00..99)
# %Y :: Year which may include century, if provided
- # %z :: Time zone as hour offset from UTC (e.g. +0900)
- # %Z :: Time zone name
+ # %z :: \Time zone as hour offset from UTC (e.g. +0900)
+ # %Z :: \Time zone name
# %% :: Literal "%" character
# %+ :: date(1) (%a %b %e %H:%M:%S %Z %Y)
#
@@ -452,7 +461,7 @@ class Time
#
def strptime(date, format, now=self.now)
d = Date._strptime(date, format)
- raise ArgumentError, "invalid date or strptime format - `#{date}' `#{format}'" unless d
+ raise ArgumentError, "invalid date or strptime format - '#{date}' '#{format}'" unless d
if seconds = d[:seconds]
if sec_fraction = d[:sec_fraction]
usec = sec_fraction * 1000000
@@ -509,8 +518,8 @@ class Time
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
(\d{2,})\s+
(\d{2})\s*
- :\s*(\d{2})\s*
- (?::\s*(\d{2}))?\s+
+ :\s*(\d{2})
+ (?:\s*:\s*(\d\d))?\s+
([+-]\d{4}|
UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/ix =~ date
# Since RFC 2822 permit comments, the regexp has no right anchor.
@@ -690,35 +699,36 @@ class Time
getutc.strftime('%a, %d %b %Y %T GMT')
end
- #
- # Returns a string which represents the time as a dateTime defined by XML
- # Schema:
- #
- # CCYY-MM-DDThh:mm:ssTZD
- # CCYY-MM-DDThh:mm:ss.sssTZD
- #
- # where TZD is Z or [+-]hh:mm.
- #
- # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
- #
- # +fraction_digits+ specifies a number of digits to use for fractional
- # seconds. Its default value is 0.
- #
- # require 'time'
- #
- # t = Time.now
- # t.iso8601 # => "2011-10-05T22:26:12-04:00"
- #
- # You must require 'time' to use this method.
- #
- def xmlschema(fraction_digits=0)
- fraction_digits = fraction_digits.to_i
- s = strftime("%FT%T")
- if fraction_digits > 0
- s << strftime(".%#{fraction_digits}N")
+ unless method_defined?(:xmlschema)
+ #
+ # Returns a string which represents the time as a dateTime defined by XML
+ # Schema:
+ #
+ # CCYY-MM-DDThh:mm:ssTZD
+ # CCYY-MM-DDThh:mm:ss.sssTZD
+ #
+ # where TZD is Z or [+-]hh:mm.
+ #
+ # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
+ #
+ # +fraction_digits+ specifies a number of digits to use for fractional
+ # seconds. Its default value is 0.
+ #
+ # require 'time'
+ #
+ # t = Time.now
+ # t.iso8601 # => "2011-10-05T22:26:12-04:00"
+ #
+ # You must require 'time' to use this method.
+ #
+ def xmlschema(fraction_digits=0)
+ fraction_digits = fraction_digits.to_i
+ s = strftime("%FT%T")
+ if fraction_digits > 0
+ s << strftime(".%#{fraction_digits}N")
+ end
+ s << (utc? ? 'Z' : strftime("%:z"))
end
- s << (utc? ? 'Z' : strftime("%:z"))
end
- alias iso8601 xmlschema
+ alias iso8601 xmlschema unless method_defined?(:iso8601)
end
-
diff --git a/lib/timeout.gemspec b/lib/timeout.gemspec
new file mode 100644
index 0000000000..5449494e07
--- /dev/null
+++ b/lib/timeout.gemspec
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Auto-terminate potentially long-running operations in Ruby.}
+ spec.description = %q{Auto-terminate potentially long-running operations in Ruby.}
+ spec.homepage = "https://github.com/ruby/timeout"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+ spec.metadata["changelog_uri"] = spec.homepage + "/releases"
+
+ spec.required_ruby_version = '>= 2.6.0'
+
+ spec.files = Dir.chdir(__dir__) do
+ `git ls-files -z`.split("\x0").reject do |f|
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|rakelib)/|\.(?:git|travis|circleci)|appveyor|Rakefile)})
+ end
+ end
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/timeout.rb b/lib/timeout.rb
index e1107765ab..91b04a9562 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -4,7 +4,7 @@
# == Synopsis
#
# require 'timeout'
-# status = Timeout::timeout(5) {
+# status = Timeout.timeout(5) {
# # Something that should be interrupted if it takes more than 5 seconds...
# }
#
@@ -13,49 +13,132 @@
# Timeout provides a way to auto-terminate a potentially long-running
# operation if it hasn't finished in a fixed amount of time.
#
-# Previous versions didn't use a module for namespacing, however
-# #timeout is provided for backwards compatibility. You
-# should prefer Timeout.timeout instead.
-#
# == Copyright
#
# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
module Timeout
- VERSION = "0.3.2"
+ # The version
+ VERSION = "0.6.1"
+
+ # Internal exception raised to when a timeout is triggered.
+ class ExitException < Exception
+ def exception(*) # :nodoc:
+ self
+ end
+ end
# Raised by Timeout.timeout when the block times out.
class Error < RuntimeError
- attr_reader :thread
+ def self.handle_timeout(message) # :nodoc:
+ exc = ExitException.new(message)
- def self.catch(*args)
- exc = new(*args)
- exc.instance_variable_set(:@thread, Thread.current)
- exc.instance_variable_set(:@catch_value, exc)
- ::Kernel.catch(exc) {yield exc}
+ begin
+ yield exc
+ rescue ExitException => e
+ raise new(message) if exc.equal?(e)
+ raise
+ end
end
+ end
- def exception(*)
- # TODO: use Fiber.current to see if self can be thrown
- if self.thread == Thread.current
- bt = caller
- begin
- throw(@catch_value, bt)
- rescue UncaughtThrowError
+ # :stopdoc:
+
+ # We keep a private reference so that time mocking libraries won't break Timeout.
+ GET_TIME = Process.method(:clock_gettime)
+ if defined?(Ractor.make_shareable)
+ # Ractor.make_shareable(Method) only works on Ruby 4+
+ Ractor.make_shareable(GET_TIME) rescue nil
+ end
+ private_constant :GET_TIME
+
+ class State
+ def initialize
+ @condvar = ConditionVariable.new
+ @queue = Queue.new
+ @queue_mutex = Mutex.new
+
+ @timeout_thread = nil
+ @timeout_thread_mutex = Mutex.new
+ end
+
+ if defined?(Ractor.store_if_absent) && defined?(Ractor.shareable?) && Ractor.shareable?(GET_TIME)
+ # Ractor support if
+ # 1. Ractor.store_if_absent is available
+ # 2. Method object can be shareable (4.0~)
+ def self.instance
+ Ractor.store_if_absent :timeout_gem_state do
+ State.new
+ end
+ end
+ else
+ GLOBAL_STATE = State.new
+
+ def self.instance
+ GLOBAL_STATE
+ end
+ end
+
+ def create_timeout_thread
+ # Threads unexpectedly inherit the interrupt mask: https://github.com/ruby/timeout/issues/41
+ # So reset the interrupt mask to the default one for the timeout thread
+ Thread.handle_interrupt(Object => :immediate) do
+ watcher = Thread.new do
+ requests = []
+ while true
+ until @queue.empty? and !requests.empty? # wait to have at least one request
+ req = @queue.pop
+ requests << req unless req.done?
+ end
+ closest_deadline = requests.min_by(&:deadline).deadline
+
+ now = 0.0
+ @queue_mutex.synchronize do
+ while (now = GET_TIME.call(Process::CLOCK_MONOTONIC)) < closest_deadline and @queue.empty?
+ @condvar.wait(@queue_mutex, closest_deadline - now)
+ end
+ end
+
+ requests.each do |req|
+ req.interrupt if req.expired?(now)
+ end
+ requests.reject!(&:done?)
+ end
+ end
+
+ if !watcher.group.enclosed? && (!defined?(Ractor.main?) || Ractor.main?)
+ ThreadGroup::Default.add(watcher)
end
+
+ watcher.name = "Timeout stdlib thread"
+ watcher.thread_variable_set(:"\0__detached_thread__", true)
+ watcher
end
- super
end
- end
- # :stopdoc:
- CONDVAR = ConditionVariable.new
- QUEUE = Queue.new
- QUEUE_MUTEX = Mutex.new
- TIMEOUT_THREAD_MUTEX = Mutex.new
- @timeout_thread = nil
- private_constant :CONDVAR, :QUEUE, :QUEUE_MUTEX, :TIMEOUT_THREAD_MUTEX
+ def ensure_timeout_thread_created
+ unless @timeout_thread&.alive?
+ # If the Mutex is already owned we are in a signal handler.
+ # In that case, just return and let the main thread create the Timeout thread.
+ return if @timeout_thread_mutex.owned?
+
+ Sync.synchronize @timeout_thread_mutex do
+ unless @timeout_thread&.alive?
+ @timeout_thread = create_timeout_thread
+ end
+ end
+ end
+ end
+
+ def add_request(request)
+ Sync.synchronize @queue_mutex do
+ @queue << request
+ @condvar.signal
+ end
+ end
+ end
+ private_constant :State
class Request
attr_reader :deadline
@@ -70,6 +153,7 @@ module Timeout
@done = false # protected by @mutex
end
+ # Only called by the timeout thread, so does not need Sync.synchronize
def done?
@mutex.synchronize do
@done
@@ -80,6 +164,7 @@ module Timeout
now >= @deadline
end
+ # Only called by the timeout thread, so does not need Sync.synchronize
def interrupt
@mutex.synchronize do
unless @done
@@ -90,114 +175,140 @@ module Timeout
end
def finished
- @mutex.synchronize do
+ Sync.synchronize @mutex do
@done = true
end
end
end
private_constant :Request
- def self.create_timeout_thread
- watcher = Thread.new do
- requests = []
- while true
- until QUEUE.empty? and !requests.empty? # wait to have at least one request
- req = QUEUE.pop
- requests << req unless req.done?
- end
- closest_deadline = requests.min_by(&:deadline).deadline
-
- now = 0.0
- QUEUE_MUTEX.synchronize do
- while (now = GET_TIME.call(Process::CLOCK_MONOTONIC)) < closest_deadline and QUEUE.empty?
- CONDVAR.wait(QUEUE_MUTEX, closest_deadline - now)
- end
- end
-
- requests.each do |req|
- req.interrupt if req.expired?(now)
- end
- requests.reject!(&:done?)
- end
- end
- ThreadGroup::Default.add(watcher) unless watcher.group.enclosed?
- watcher.name = "Timeout stdlib thread"
- watcher.thread_variable_set(:"\0__detached_thread__", true)
- watcher
- end
- private_class_method :create_timeout_thread
-
- def self.ensure_timeout_thread_created
- unless @timeout_thread and @timeout_thread.alive?
- TIMEOUT_THREAD_MUTEX.synchronize do
- unless @timeout_thread and @timeout_thread.alive?
- @timeout_thread = create_timeout_thread
- end
+ module Sync
+ # Calls mutex.synchronize(&block) but if that fails on CRuby due to being in a trap handler,
+ # run mutex.synchronize(&block) in a separate Thread instead.
+ def self.synchronize(mutex, &block)
+ begin
+ mutex.synchronize(&block)
+ rescue ThreadError => e
+ raise e unless e.message == "can't be called from trap context"
+ # Workaround CRuby issue https://bugs.ruby-lang.org/issues/19473
+ # which raises on Mutex#synchronize in trap handler.
+ # It's expensive to create a Thread just for this,
+ # but better than failing.
+ Thread.new {
+ mutex.synchronize(&block)
+ }.join
end
end
end
-
- # We keep a private reference so that time mocking libraries won't break
- # Timeout.
- GET_TIME = Process.method(:clock_gettime)
- private_constant :GET_TIME
+ private_constant :Sync
# :startdoc:
- # Perform an operation in a block, raising an error if it takes longer than
+ # Perform an operation in a block, raising an exception if it takes longer than
# +sec+ seconds to complete.
#
- # +sec+:: Number of seconds to wait for the block to terminate. Any number
- # may be used, including Floats to specify fractional seconds. A
+ # +sec+:: Number of seconds to wait for the block to terminate. Any non-negative number
+ # or nil may be used, including Floats to specify fractional seconds. A
# value of 0 or +nil+ will execute the block without any timeout.
+ # Any negative number will raise an ArgumentError.
# +klass+:: Exception Class to raise if the block fails to terminate
- # in +sec+ seconds. Omitting will use the default, Timeout::Error
+ # in +sec+ seconds. Omitting will use the default, Timeout::Error.
# +message+:: Error message to raise with Exception Class.
- # Omitting will use the default, "execution expired"
+ # Omitting will use the default, <tt>"execution expired"</tt>.
#
# Returns the result of the block *if* the block completed before
- # +sec+ seconds, otherwise throws an exception, based on the value of +klass+.
+ # +sec+ seconds, otherwise raises an exception, based on the value of +klass+.
#
- # The exception thrown to terminate the given block cannot be rescued inside
- # the block unless +klass+ is given explicitly. However, the block can use
- # ensure to prevent the handling of the exception. For that reason, this
- # method cannot be relied on to enforce timeouts for untrusted blocks.
+ # The exception raised to terminate the given block is the given +klass+, or
+ # Timeout::ExitException if +klass+ is not given. The reason for that behavior
+ # is that Timeout::Error inherits from RuntimeError and might be caught unexpectedly by +rescue+.
+ # Timeout::ExitException inherits from Exception so it will only be rescued by <tt>rescue Exception</tt>.
+ # Note that the Timeout::ExitException is translated to a Timeout::Error once it reaches the Timeout.timeout call,
+ # so outside that call it will be a Timeout::Error.
+ #
+ # In general, be aware that the code block may rescue the exception, and in such a case not respect the timeout.
+ # Also, the block can use +ensure+ to prevent the handling of the exception.
+ # For those reasons, this method cannot be relied on to enforce timeouts for untrusted blocks.
#
# If a scheduler is defined, it will be used to handle the timeout by invoking
- # Scheduler#timeout_after.
+ # Fiber::Scheduler#timeout_after.
#
# Note that this is both a method of module Timeout, so you can <tt>include
# Timeout</tt> 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, message = nil, &block) #:yield: +sec+
+ #
+ # ==== Ensuring the exception does not fire inside ensure blocks
+ #
+ # When using Timeout.timeout, it can be desirable to ensure the timeout exception does not fire inside an +ensure+ block.
+ # The simplest and best way to do so is to put the Timeout.timeout call inside the body of the +begin+/+ensure+/+end+:
+ #
+ # begin
+ # Timeout.timeout(sec) { some_long_operation }
+ # ensure
+ # cleanup # safe, cannot be interrupted by timeout
+ # end
+ #
+ # If that is not feasible, e.g. if there are +ensure+ blocks inside +some_long_operation+,
+ # they need to not be interrupted by timeout, and it's not possible to move these ensure blocks outside,
+ # one can use Thread.handle_interrupt to delay the timeout exception like so:
+ #
+ # Thread.handle_interrupt(Timeout::Error => :never) {
+ # Timeout.timeout(sec, Timeout::Error) do
+ # setup # timeout cannot happen here, no matter how long it takes
+ # Thread.handle_interrupt(Timeout::Error => :immediate) {
+ # some_long_operation # timeout can happen here
+ # }
+ # ensure
+ # cleanup # timeout cannot happen here, no matter how long it takes
+ # end
+ # }
+ #
+ # An important thing to note is the need to pass an exception +klass+ to Timeout.timeout,
+ # otherwise it does not work. Specifically, using <tt>Thread.handle_interrupt(Timeout::ExitException => ...)</tt>
+ # is unsupported and causes subtle errors like raising the wrong exception outside the block, do not use that.
+ #
+ # Note that Thread.handle_interrupt is somewhat dangerous because if setup or cleanup hangs
+ # then the current thread will hang too and the timeout will never fire.
+ # Also note the block might run for longer than +sec+ seconds:
+ # e.g. +some_long_operation+ executes for +sec+ seconds + whatever time cleanup takes.
+ #
+ # If you want the timeout to only happen on blocking operations, one can use +:on_blocking+
+ # instead of +:immediate+. However, that means if the block uses no blocking operations after +sec+ seconds,
+ # the block will not be interrupted.
+ def self.timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
return yield(sec) if sec == nil or sec.zero?
+ raise ArgumentError, "Timeout sec must be a non-negative number" if 0 > sec
message ||= "execution expired"
if Fiber.respond_to?(:current_scheduler) && (scheduler = Fiber.current_scheduler)&.respond_to?(:timeout_after)
- return scheduler.timeout_after(sec, klass || Error, message, &block)
- end
-
- Timeout.ensure_timeout_thread_created
- perform = Proc.new do |exc|
- request = Request.new(Thread.current, sec, exc, message)
- QUEUE_MUTEX.synchronize do
- QUEUE << request
- CONDVAR.signal
+ perform = Proc.new do |exc|
+ scheduler.timeout_after(sec, exc, message, &block)
end
- begin
- return yield(sec)
- ensure
- request.finished
+ else
+ state = State.instance
+ state.ensure_timeout_thread_created
+
+ perform = Proc.new do |exc|
+ request = Request.new(Thread.current, sec, exc, message)
+ state.add_request(request)
+ begin
+ return yield(sec)
+ ensure
+ request.finished
+ end
end
end
if klass
perform.call(klass)
else
- backtrace = Error.catch(&perform)
- raise Error, message, backtrace
+ Error.handle_timeout(message, &perform)
end
end
- module_function :timeout
+
+ # See Timeout.timeout
+ private def timeout(*args, &block)
+ Timeout.timeout(*args, &block)
+ end
end
diff --git a/lib/timeout/timeout.gemspec b/lib/timeout/timeout.gemspec
deleted file mode 100644
index 7449ae1980..0000000000
--- a/lib/timeout/timeout.gemspec
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Auto-terminate potentially long-running operations in Ruby.}
- spec.description = %q{Auto-terminate potentially long-running operations in Ruby.}
- spec.homepage = "https://github.com/ruby/timeout"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(__dir__) do
- `git ls-files -z`.split("\x0").reject do |f|
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|rakelib)/|\.(?:git|travis|circleci)|appveyor|Rakefile)})
- end
- end
- spec.require_paths = ["lib"]
-end
diff --git a/lib/tmpdir.gemspec b/lib/tmpdir.gemspec
index e42662ea3b..4935d1cb3c 100644
--- a/lib/tmpdir.gemspec
+++ b/lib/tmpdir.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "tmpdir"
- spec.version = "0.1.3"
+ spec.version = "0.3.1"
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -15,8 +15,12 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ gemspec = File.basename(__FILE__)
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL, exception: false) do |ls|
+ ls.readlines("\x0", chomp: true).reject do |f|
+ (f == gemspec) ||
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git Gemfile])
+ end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 55920a4a74..f78fd721b7 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -13,22 +13,28 @@ end
class Dir
- @@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
+ # Class variables are inaccessible from non-main Ractor.
+ # And instance variables too, in Ruby 3.0.
##
# Returns the operating system's temporary file path.
+ #
+ # require 'tmpdir'
+ # Dir.tmpdir # => "/tmp"
def self.tmpdir
- ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir|
+ Tmpname::TMPDIR_CANDIDATES.find do |name, dir|
unless dir
- next if !(dir = ENV[name]) or dir.empty?
+ next if !(dir = ENV[name] rescue next) or dir.empty?
end
dir = File.expand_path(dir)
stat = File.stat(dir) rescue next
case
when !stat.directory?
warn "#{name} is not a directory: #{dir}"
- when !stat.writable?
+ when !File.writable?(dir)
+ # We call File.writable?, not stat.writable?, because you can't tell if a dir is actually
+ # writable just from stat; OS mechanisms other than user/group/world bits can affect this.
warn "#{name} is not writable: #{dir}"
when stat.world_writable? && !stat.sticky?
warn "#{name} is world-writable: #{dir}"
@@ -40,6 +46,11 @@ class Dir
# Dir.mktmpdir creates a temporary directory.
#
+ # require 'tmpdir'
+ # Dir.mktmpdir {|dir|
+ # # use the directory
+ # }
+ #
# The directory is created with 0700 permission.
# Application should not change the permission to make the temporary directory accessible from other users.
#
@@ -83,20 +94,21 @@ class Dir
# FileUtils.remove_entry dir
# end
#
- def self.mktmpdir(prefix_suffix=nil, *rest, **options)
+ def self.mktmpdir(prefix_suffix=nil, *rest, **options, &block)
base = nil
path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|path, _, _, d|
base = d
mkdir(path, 0700)
}
- if block_given?
+ if block
begin
yield path.dup
ensure
unless base
- stat = File.stat(File.dirname(path))
+ base = File.dirname(path)
+ stat = File.stat(base)
if stat.world_writable? and !stat.sticky?
- raise ArgumentError, "parent directory is world writable but not sticky"
+ raise ArgumentError, "parent directory is world writable but not sticky: #{base}"
end
end
FileUtils.remove_entry path
@@ -110,6 +122,18 @@ class Dir
module Tmpname # :nodoc:
module_function
+ # System-wide temporary directory path
+ systmpdir = (defined?(Etc.systmpdir) ? Etc.systmpdir.freeze : '/tmp')
+
+ # Temporary directory candidates consisting of environment variable
+ # names or description and path pairs.
+ TMPDIR_CANDIDATES = [
+ 'TMPDIR', 'TMP', 'TEMP',
+ ['system temporary path', systmpdir],
+ %w[/tmp /tmp],
+ %w[. .],
+ ].each(&:freeze).freeze
+
def tmpdir
Dir.tmpdir
end
@@ -118,22 +142,27 @@ class Dir
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
# Dedicated random number generator
- RANDOM = Random.new
+ RANDOM = Object.new
class << RANDOM # :nodoc:
# Maximum random number
MAX = 36**6 # < 0x100000000
# Returns new random string upto 6 bytes
def next
- rand(MAX).to_s(36)
+ (::Random.urandom(4).unpack1("L")%MAX).to_s(36)
end
end
+ RANDOM.freeze
private_constant :RANDOM
# Generates and yields random names to create a temporary name
def create(basename, tmpdir=nil, max_try: nil, **opts)
- origdir = tmpdir
- tmpdir ||= tmpdir()
+ if tmpdir
+ origdir = tmpdir = File.path(tmpdir)
+ raise ArgumentError, "empty parent path" if tmpdir.empty?
+ else
+ tmpdir = tmpdir()
+ end
n = nil
prefix, suffix = basename
prefix = (String.try_convert(prefix) or
@@ -152,7 +181,7 @@ class Dir
n ||= 0
n += 1
retry if !max_try or n < max_try
- raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
+ raise "cannot generate temporary name using '#{basename}' under '#{tmpdir}'"
end
path
end
diff --git a/lib/tsort.gemspec b/lib/tsort.gemspec
deleted file mode 100644
index a82393b70b..0000000000
--- a/lib/tsort.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "tsort"
- spec.version = "0.1.1"
- spec.authors = ["Tanaka Akira"]
- spec.email = ["akr@fsij.org"]
-
- spec.summary = %q{Topological sorting using Tarjan's algorithm}
- spec.description = %q{Topological sorting using Tarjan's algorithm}
- spec.homepage = "https://github.com/ruby/tsort"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/tsort.rb b/lib/tsort.rb
deleted file mode 100644
index 00ee609d64..0000000000
--- a/lib/tsort.rb
+++ /dev/null
@@ -1,452 +0,0 @@
-# frozen_string_literal: true
-
-#--
-# tsort.rb - provides a module for topological sorting and strongly connected components.
-#++
-#
-
-#
-# TSort implements topological sorting using Tarjan's algorithm for
-# strongly connected components.
-#
-# TSort is designed to be able to be used with any object which can be
-# interpreted as a directed graph.
-#
-# TSort requires two methods to interpret an object as a graph,
-# tsort_each_node and tsort_each_child.
-#
-# * tsort_each_node is used to iterate for all nodes over a graph.
-# * tsort_each_child is used to iterate for child nodes of a given node.
-#
-# The equality of nodes are defined by eql? and hash since
-# TSort uses Hash internally.
-#
-# == A Simple Example
-#
-# The following example demonstrates how to mix the TSort module into an
-# existing class (in this case, Hash). Here, we're treating each key in
-# the hash as a node in the graph, and so we simply alias the required
-# #tsort_each_node method to Hash's #each_key method. For each key in the
-# hash, the associated value is an array of the node's child nodes. This
-# choice in turn leads to our implementation of the required #tsort_each_child
-# method, which fetches the array of child nodes and then iterates over that
-# array using the user-supplied block.
-#
-# require 'tsort'
-#
-# class Hash
-# include TSort
-# alias tsort_each_node each_key
-# def tsort_each_child(node, &block)
-# fetch(node).each(&block)
-# end
-# end
-#
-# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
-# #=> [3, 2, 1, 4]
-#
-# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
-# #=> [[4], [2, 3], [1]]
-#
-# == A More Realistic Example
-#
-# A very simple `make' like tool can be implemented as follows:
-#
-# require 'tsort'
-#
-# class Make
-# def initialize
-# @dep = {}
-# @dep.default = []
-# end
-#
-# def rule(outputs, inputs=[], &block)
-# triple = [outputs, inputs, block]
-# outputs.each {|f| @dep[f] = [triple]}
-# @dep[triple] = inputs
-# end
-#
-# def build(target)
-# each_strongly_connected_component_from(target) {|ns|
-# if ns.length != 1
-# fs = ns.delete_if {|n| Array === n}
-# raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
-# end
-# n = ns.first
-# if Array === n
-# outputs, inputs, block = n
-# inputs_time = inputs.map {|f| File.mtime f}.max
-# begin
-# outputs_time = outputs.map {|f| File.mtime f}.min
-# rescue Errno::ENOENT
-# outputs_time = nil
-# end
-# if outputs_time == nil ||
-# inputs_time != nil && outputs_time <= inputs_time
-# sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
-# block.call
-# end
-# end
-# }
-# end
-#
-# def tsort_each_child(node, &block)
-# @dep[node].each(&block)
-# end
-# include TSort
-# end
-#
-# def command(arg)
-# print arg, "\n"
-# system arg
-# end
-#
-# m = Make.new
-# m.rule(%w[t1]) { command 'date > t1' }
-# m.rule(%w[t2]) { command 'date > t2' }
-# m.rule(%w[t3]) { command 'date > t3' }
-# m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
-# m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' }
-# m.build('t5')
-#
-# == Bugs
-#
-# * 'tsort.rb' is wrong name because this library uses
-# Tarjan's algorithm for strongly connected components.
-# Although 'strongly_connected_components.rb' is correct but too long.
-#
-# == References
-#
-# R. E. Tarjan, "Depth First Search and Linear Graph Algorithms",
-# <em>SIAM Journal on Computing</em>, Vol. 1, No. 2, pp. 146-160, June 1972.
-#
-
-module TSort
- class Cyclic < StandardError
- end
-
- # Returns a topologically sorted array of nodes.
- # The array is sorted from children to parents, i.e.
- # the first element has no child and the last node has no parent.
- #
- # If there is a cycle, TSort::Cyclic is raised.
- #
- # class G
- # include TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # p graph.tsort #=> [4, 2, 3, 1]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # p graph.tsort # raises TSort::Cyclic
- #
- def tsort
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- TSort.tsort(each_node, each_child)
- end
-
- # Returns a topologically sorted array of nodes.
- # The array is sorted from children to parents, i.e.
- # the first element has no child and the last node has no parent.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # If there is a cycle, TSort::Cyclic is raised.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
- #
- def self.tsort(each_node, each_child)
- tsort_each(each_node, each_child).to_a
- end
-
- # The iterator version of the #tsort method.
- # <tt><em>obj</em>.tsort_each</tt> is similar to <tt><em>obj</em>.tsort.each</tt>, but
- # modification of _obj_ during the iteration may lead to unexpected results.
- #
- # #tsort_each returns +nil+.
- # If there is a cycle, TSort::Cyclic is raised.
- #
- # class G
- # include TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.tsort_each {|n| p n }
- # #=> 4
- # # 2
- # # 3
- # # 1
- #
- def tsort_each(&block) # :yields: node
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- TSort.tsort_each(each_node, each_child, &block)
- end
-
- # The iterator version of the TSort.tsort method.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # TSort.tsort_each(each_node, each_child) {|n| p n }
- # #=> 4
- # # 2
- # # 3
- # # 1
- #
- def self.tsort_each(each_node, each_child) # :yields: node
- return to_enum(__method__, each_node, each_child) unless block_given?
-
- each_strongly_connected_component(each_node, each_child) {|component|
- if component.size == 1
- yield component.first
- else
- raise Cyclic.new("topological sort failed: #{component.inspect}")
- end
- }
- end
-
- # Returns strongly connected components as an array of arrays of nodes.
- # The array is sorted from children to parents.
- # Each elements of the array represents a strongly connected component.
- #
- # class G
- # include TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # p graph.strongly_connected_components #=> [[4], [2], [3], [1]]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # p graph.strongly_connected_components #=> [[4], [2, 3], [1]]
- #
- def strongly_connected_components
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- TSort.strongly_connected_components(each_node, each_child)
- end
-
- # Returns strongly connected components as an array of arrays of nodes.
- # The array is sorted from children to parents.
- # Each elements of the array represents a strongly connected component.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p TSort.strongly_connected_components(each_node, each_child)
- # #=> [[4], [2], [3], [1]]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # p TSort.strongly_connected_components(each_node, each_child)
- # #=> [[4], [2, 3], [1]]
- #
- def self.strongly_connected_components(each_node, each_child)
- each_strongly_connected_component(each_node, each_child).to_a
- end
-
- # The iterator version of the #strongly_connected_components method.
- # <tt><em>obj</em>.each_strongly_connected_component</tt> is similar to
- # <tt><em>obj</em>.strongly_connected_components.each</tt>, but
- # modification of _obj_ during the iteration may lead to unexpected results.
- #
- # #each_strongly_connected_component returns +nil+.
- #
- # class G
- # include TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.each_strongly_connected_component {|scc| p scc }
- # #=> [4]
- # # [2]
- # # [3]
- # # [1]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # graph.each_strongly_connected_component {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def each_strongly_connected_component(&block) # :yields: nodes
- each_node = method(:tsort_each_node)
- each_child = method(:tsort_each_child)
- TSort.each_strongly_connected_component(each_node, each_child, &block)
- end
-
- # The iterator version of the TSort.strongly_connected_components method.
- #
- # The graph is represented by _each_node_ and _each_child_.
- # _each_node_ should have +call+ method which yields for each node in the graph.
- # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
- #
- # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
- # #=> [4]
- # # [2]
- # # [3]
- # # [1]
- #
- # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_node = lambda {|&b| g.each_key(&b) }
- # each_child = lambda {|n, &b| g[n].each(&b) }
- # TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def self.each_strongly_connected_component(each_node, each_child) # :yields: nodes
- return to_enum(__method__, each_node, each_child) unless block_given?
-
- id_map = {}
- stack = []
- each_node.call {|node|
- unless id_map.include? node
- each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
- yield c
- }
- end
- }
- nil
- end
-
- # Iterates over strongly connected component in the subgraph reachable from
- # _node_.
- #
- # Return value is unspecified.
- #
- # #each_strongly_connected_component_from doesn't call #tsort_each_node.
- #
- # class G
- # include TSort
- # def initialize(g)
- # @g = g
- # end
- # def tsort_each_child(n, &b) @g[n].each(&b) end
- # def tsort_each_node(&b) @g.each_key(&b) end
- # end
- #
- # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
- # graph.each_strongly_connected_component_from(2) {|scc| p scc }
- # #=> [4]
- # # [2]
- #
- # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
- # graph.each_strongly_connected_component_from(2) {|scc| p scc }
- # #=> [4]
- # # [2, 3]
- #
- def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) # :yields: nodes
- TSort.each_strongly_connected_component_from(node, method(:tsort_each_child), id_map, stack, &block)
- end
-
- # Iterates over strongly connected components in a graph.
- # The graph is represented by _node_ and _each_child_.
- #
- # _node_ is the first node.
- # _each_child_ should have +call+ method which takes a node argument
- # and yields for each child node.
- #
- # Return value is unspecified.
- #
- # #TSort.each_strongly_connected_component_from is a class method and
- # it doesn't need a class to represent a graph which includes TSort.
- #
- # graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
- # each_child = lambda {|n, &b| graph[n].each(&b) }
- # TSort.each_strongly_connected_component_from(1, each_child) {|scc|
- # p scc
- # }
- # #=> [4]
- # # [2, 3]
- # # [1]
- #
- def self.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
- return to_enum(__method__, node, each_child, id_map, stack) unless block_given?
-
- minimum_id = node_id = id_map[node] = id_map.size
- stack_length = stack.length
- stack << node
-
- each_child.call(node) {|child|
- if id_map.include? child
- child_id = id_map[child]
- minimum_id = child_id if child_id && child_id < minimum_id
- else
- sub_minimum_id =
- each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
- yield c
- }
- minimum_id = sub_minimum_id if sub_minimum_id < minimum_id
- end
- }
-
- if node_id == minimum_id
- component = stack.slice!(stack_length .. -1)
- component.each {|n| id_map[n] = nil}
- yield component
- end
-
- minimum_id
- end
-
- # Should be implemented by a extended class.
- #
- # #tsort_each_node is used to iterate for all nodes over a graph.
- #
- def tsort_each_node # :yields: node
- raise NotImplementedError.new
- end
-
- # Should be implemented by a extended class.
- #
- # #tsort_each_child is used to iterate for child nodes of _node_.
- #
- def tsort_each_child(node) # :yields: child
- raise NotImplementedError.new
- end
-end
diff --git a/lib/un.gemspec b/lib/un.gemspec
index 1a466fdebe..2ed49511cc 100644
--- a/lib/un.gemspec
+++ b/lib/un.gemspec
@@ -1,8 +1,15 @@
# frozen_string_literal: true
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "un"
- spec.version = "0.2.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["WATANABE Hirofumi"]
spec.email = ["eban@ruby-lang.org"]
diff --git a/lib/un.rb b/lib/un.rb
index 796b36fbab..8fb3c61a93 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -30,7 +30,6 @@ require "fileutils"
require "optparse"
module FileUtils
-# @fileutils_label = ""
@fileutils_output = $stdout
end
@@ -412,6 +411,9 @@ def help
end
module UN # :nodoc:
+
+ VERSION = "0.3.0"
+
module_function
def help(argv, output: $stdout)
all = argv.empty?
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index 1caf2cc8c8..0447df8de7 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -82,16 +82,22 @@ module UnicodeNormalize # :nodoc:
## Canonical Ordering
def self.canonical_ordering_one(string)
- sorting = string.each_char.collect { |c| [c, CLASS_TABLE[c]] }
- (sorting.length-2).downto(0) do |i| # almost, but not exactly bubble sort
- (0..i).each do |j|
- later_class = sorting[j+1].last
- if 0<later_class and later_class<sorting[j].last
- sorting[j], sorting[j+1] = sorting[j+1], sorting[j]
- end
+ result = ''
+ unordered = []
+ chars = string.chars
+ n = chars.size
+ chars.each_with_index do |char, i|
+ ccc = CLASS_TABLE[char]
+ if ccc == 0
+ unordered.sort!.each { result << chars[it % n] }
+ unordered.clear
+ result << char
+ else
+ unordered << ccc * n + i
end
end
- return sorting.collect(&:first).join('')
+ unordered.sort!.each { result << chars[it % n] }
+ result
end
## Normalization Forms for Patterns (not whole Strings)
@@ -105,16 +111,22 @@ module UnicodeNormalize # :nodoc:
start = nfd_string[0]
last_class = CLASS_TABLE[start]-1
accents = ''
+ result = ''
nfd_string[1..-1].each_char do |accent|
accent_class = CLASS_TABLE[accent]
if last_class<accent_class and composite = COMPOSITION_TABLE[start+accent]
start = composite
+ elsif accent_class == 0
+ result << start << accents
+ start = accent
+ accents = ''
+ last_class = -1
else
accents << accent
last_class = accent_class
end
end
- hangul_comp_one(start+accents)
+ hangul_comp_one(result+start+accents)
end
def self.normalize(string, form = :nfc)
diff --git a/lib/unicode_normalize/tables.rb b/lib/unicode_normalize/tables.rb
index 7448fad13f..dd5d3499b8 100644
--- a/lib/unicode_normalize/tables.rb
+++ b/lib/unicode_normalize/tables.rb
@@ -1,6 +1,9 @@
# coding: us-ascii
# frozen_string_literal: true
+Encoding::UNICODE_VERSION == "17.0.0" or
+ raise "Unicode version mismatch: 17.0.0 expected but #{Encoding::UNICODE_VERSION}"
+
# automatically generated by template/unicode_norm_gen.tmpl
module UnicodeNormalize # :nodoc:
@@ -29,7 +32,7 @@ module UnicodeNormalize # :nodoc:
"\u0825-\u0827" \
"\u0829-\u082D" \
"\u0859-\u085B" \
- "\u0898-\u089F" \
+ "\u0897-\u089F" \
"\u08CA-\u08E1" \
"\u08E3-\u08FF" \
"\u093C" \
@@ -96,7 +99,8 @@ module UnicodeNormalize # :nodoc:
"\u1A75-\u1A7C" \
"\u1A7F" \
"\u1AB0-\u1ABD" \
- "\u1ABF-\u1ACE" \
+ "\u1ABF-\u1ADD" \
+ "\u1AE0-\u1AEB" \
"\u1B34\u1B35" \
"\u1B44" \
"\u1B6B-\u1B73" \
@@ -149,7 +153,9 @@ module UnicodeNormalize # :nodoc:
"\u{10A3F}" \
"\u{10AE5}\u{10AE6}" \
"\u{10D24}-\u{10D27}" \
+ "\u{10D69}-\u{10D6D}" \
"\u{10EAB}\u{10EAC}" \
+ "\u{10EFA}\u{10EFB}" \
"\u{10EFD}-\u{10EFF}" \
"\u{10F46}-\u{10F50}" \
"\u{10F82}-\u{10F85}" \
@@ -171,6 +177,12 @@ module UnicodeNormalize # :nodoc:
"\u{11357}" \
"\u{11366}-\u{1136C}" \
"\u{11370}-\u{11374}" \
+ "\u{113B8}" \
+ "\u{113BB}" \
+ "\u{113C2}" \
+ "\u{113C5}" \
+ "\u{113C7}-\u{113C9}" \
+ "\u{113CE}-\u{113D0}" \
"\u{11442}" \
"\u{11446}" \
"\u{1145E}" \
@@ -196,8 +208,11 @@ module UnicodeNormalize # :nodoc:
"\u{11D44}\u{11D45}" \
"\u{11D97}" \
"\u{11F41}\u{11F42}" \
+ "\u{1611E}-\u{16129}" \
+ "\u{1612F}" \
"\u{16AF0}-\u{16AF4}" \
"\u{16B30}-\u{16B36}" \
+ "\u{16D67}\u{16D68}" \
"\u{16FF0}\u{16FF1}" \
"\u{1BC9E}" \
"\u{1D165}-\u{1D169}" \
@@ -216,6 +231,11 @@ module UnicodeNormalize # :nodoc:
"\u{1E2AE}" \
"\u{1E2EC}-\u{1E2EF}" \
"\u{1E4EC}-\u{1E4EF}" \
+ "\u{1E5EE}\u{1E5EF}" \
+ "\u{1E6E3}" \
+ "\u{1E6E6}" \
+ "\u{1E6EE}\u{1E6EF}" \
+ "\u{1E6F5}" \
"\u{1E8D0}-\u{1E8D6}" \
"\u{1E944}-\u{1E94A}" \
"]"
@@ -441,15 +461,25 @@ module UnicodeNormalize # :nodoc:
"\uFB40\uFB41" \
"\uFB43\uFB44" \
"\uFB46-\uFB4E" \
+ "\u{105C9}" \
+ "\u{105E4}" \
"\u{1109A}" \
"\u{1109C}" \
"\u{110AB}" \
"\u{1112E}\u{1112F}" \
"\u{1134B}\u{1134C}" \
+ "\u{11383}" \
+ "\u{11385}" \
+ "\u{1138E}" \
+ "\u{11391}" \
+ "\u{113C5}" \
+ "\u{113C7}\u{113C8}" \
"\u{114BB}\u{114BC}" \
"\u{114BE}" \
"\u{115BA}\u{115BB}" \
"\u{11938}" \
+ "\u{16121}-\u{16128}" \
+ "\u{16D68}-\u{16D6A}" \
"\u{1D15E}-\u{1D164}" \
"\u{1D1BB}-\u{1D1C0}" \
"\u{2F800}-\u{2FA1D}" \
@@ -613,14 +643,25 @@ module UnicodeNormalize # :nodoc:
"\u30DB" \
"\u30EF-\u30F2" \
"\u30FD" \
+ "\u{105D2}" \
+ "\u{105DA}" \
"\u{11099}" \
"\u{1109B}" \
"\u{110A5}" \
"\u{11131}\u{11132}" \
"\u{11347}" \
+ "\u{11382}" \
+ "\u{11384}" \
+ "\u{1138B}" \
+ "\u{11390}" \
+ "\u{113C2}" \
"\u{114B9}" \
"\u{115B8}\u{115B9}" \
"\u{11935}" \
+ "\u{1611E}" \
+ "\u{16129}" \
+ "\u{16D63}" \
+ "\u{16D67}" \
"]?#{accents}+" \
"|#{'' # precomposed Hangul syllables
}" \
@@ -891,6 +932,10 @@ module UnicodeNormalize # :nodoc:
"\u30F4" \
"\u30F7-\u30FA" \
"\u30FD\u30FE" \
+ "\u{105C9}" \
+ "\u{105D2}" \
+ "\u{105DA}" \
+ "\u{105E4}" \
"\u{11099}-\u{1109C}" \
"\u{110A5}" \
"\u{110AB}" \
@@ -898,12 +943,23 @@ module UnicodeNormalize # :nodoc:
"\u{11131}\u{11132}" \
"\u{11347}" \
"\u{1134B}\u{1134C}" \
+ "\u{11382}-\u{11385}" \
+ "\u{1138B}" \
+ "\u{1138E}" \
+ "\u{11390}\u{11391}" \
+ "\u{113C2}" \
+ "\u{113C5}" \
+ "\u{113C7}\u{113C8}" \
"\u{114B9}" \
"\u{114BB}\u{114BC}" \
"\u{114BE}" \
"\u{115B8}-\u{115BB}" \
"\u{11935}" \
"\u{11938}" \
+ "\u{1611E}" \
+ "\u{16121}-\u{16129}" \
+ "\u{16D63}" \
+ "\u{16D67}-\u{16D6A}" \
"]?#{accents}+" \
"|#{'' # Hangul syllables with separate trailer
}" \
@@ -1410,7 +1466,7 @@ module UnicodeNormalize # :nodoc:
"\u3280-\u33FF" \
"\uA69C\uA69D" \
"\uA770" \
- "\uA7F2-\uA7F4" \
+ "\uA7F1-\uA7F4" \
"\uA7F8\uA7F9" \
"\uAB5C-\uAB5F" \
"\uAB69" \
@@ -1440,6 +1496,7 @@ module UnicodeNormalize # :nodoc:
"\u{10781}-\u{10785}" \
"\u{10787}-\u{107B0}" \
"\u{107B2}-\u{107BA}" \
+ "\u{1CCD6}-\u{1CCF9}" \
"\u{1D400}-\u{1D454}" \
"\u{1D456}-\u{1D49C}" \
"\u{1D49E}\u{1D49F}" \
@@ -1789,6 +1846,7 @@ module UnicodeNormalize # :nodoc:
"\u0859"=>220,
"\u085A"=>220,
"\u085B"=>220,
+ "\u0897"=>230,
"\u0898"=>230,
"\u0899"=>220,
"\u089A"=>220,
@@ -1967,6 +2025,33 @@ module UnicodeNormalize # :nodoc:
"\u1ACC"=>230,
"\u1ACD"=>230,
"\u1ACE"=>230,
+ "\u1ACF"=>230,
+ "\u1AD0"=>230,
+ "\u1AD1"=>230,
+ "\u1AD2"=>230,
+ "\u1AD3"=>230,
+ "\u1AD4"=>230,
+ "\u1AD5"=>230,
+ "\u1AD6"=>230,
+ "\u1AD7"=>230,
+ "\u1AD8"=>230,
+ "\u1AD9"=>230,
+ "\u1ADA"=>230,
+ "\u1ADB"=>230,
+ "\u1ADC"=>230,
+ "\u1ADD"=>220,
+ "\u1AE0"=>230,
+ "\u1AE1"=>230,
+ "\u1AE2"=>230,
+ "\u1AE3"=>230,
+ "\u1AE4"=>230,
+ "\u1AE5"=>230,
+ "\u1AE6"=>220,
+ "\u1AE7"=>230,
+ "\u1AE8"=>230,
+ "\u1AE9"=>230,
+ "\u1AEA"=>230,
+ "\u1AEB"=>234,
"\u1B34"=>7,
"\u1B44"=>9,
"\u1B6B"=>230,
@@ -2234,8 +2319,15 @@ module UnicodeNormalize # :nodoc:
"\u{10D25}"=>230,
"\u{10D26}"=>230,
"\u{10D27}"=>230,
+ "\u{10D69}"=>230,
+ "\u{10D6A}"=>230,
+ "\u{10D6B}"=>230,
+ "\u{10D6C}"=>230,
+ "\u{10D6D}"=>230,
"\u{10EAB}"=>230,
"\u{10EAC}"=>230,
+ "\u{10EFA}"=>220,
+ "\u{10EFB}"=>220,
"\u{10EFD}"=>220,
"\u{10EFE}"=>220,
"\u{10EFF}"=>220,
@@ -2286,6 +2378,9 @@ module UnicodeNormalize # :nodoc:
"\u{11372}"=>230,
"\u{11373}"=>230,
"\u{11374}"=>230,
+ "\u{113CE}"=>9,
+ "\u{113CF}"=>9,
+ "\u{113D0}"=>9,
"\u{11442}"=>9,
"\u{11446}"=>7,
"\u{1145E}"=>230,
@@ -2313,6 +2408,7 @@ module UnicodeNormalize # :nodoc:
"\u{11D97}"=>9,
"\u{11F41}"=>9,
"\u{11F42}"=>9,
+ "\u{1612F}"=>9,
"\u{16AF0}"=>1,
"\u{16AF1}"=>1,
"\u{16AF2}"=>1,
@@ -2416,6 +2512,13 @@ module UnicodeNormalize # :nodoc:
"\u{1E4ED}"=>232,
"\u{1E4EE}"=>220,
"\u{1E4EF}"=>230,
+ "\u{1E5EE}"=>230,
+ "\u{1E5EF}"=>220,
+ "\u{1E6E3}"=>230,
+ "\u{1E6E6}"=>230,
+ "\u{1E6EE}"=>230,
+ "\u{1E6EF}"=>230,
+ "\u{1E6F5}"=>230,
"\u{1E8D0}"=>220,
"\u{1E8D1}"=>220,
"\u{1E8D2}"=>220,
@@ -3928,6 +4031,8 @@ module UnicodeNormalize # :nodoc:
"\uFB4C"=>"\u05D1\u05BF",
"\uFB4D"=>"\u05DB\u05BF",
"\uFB4E"=>"\u05E4\u05BF",
+ "\u{105C9}"=>"\u{105D2}\u0307",
+ "\u{105E4}"=>"\u{105DA}\u0307",
"\u{1109A}"=>"\u{11099}\u{110BA}",
"\u{1109C}"=>"\u{1109B}\u{110BA}",
"\u{110AB}"=>"\u{110A5}\u{110BA}",
@@ -3935,12 +4040,30 @@ module UnicodeNormalize # :nodoc:
"\u{1112F}"=>"\u{11132}\u{11127}",
"\u{1134B}"=>"\u{11347}\u{1133E}",
"\u{1134C}"=>"\u{11347}\u{11357}",
+ "\u{11383}"=>"\u{11382}\u{113C9}",
+ "\u{11385}"=>"\u{11384}\u{113BB}",
+ "\u{1138E}"=>"\u{1138B}\u{113C2}",
+ "\u{11391}"=>"\u{11390}\u{113C9}",
+ "\u{113C5}"=>"\u{113C2}\u{113C2}",
+ "\u{113C7}"=>"\u{113C2}\u{113B8}",
+ "\u{113C8}"=>"\u{113C2}\u{113C9}",
"\u{114BB}"=>"\u{114B9}\u{114BA}",
"\u{114BC}"=>"\u{114B9}\u{114B0}",
"\u{114BE}"=>"\u{114B9}\u{114BD}",
"\u{115BA}"=>"\u{115B8}\u{115AF}",
"\u{115BB}"=>"\u{115B9}\u{115AF}",
"\u{11938}"=>"\u{11935}\u{11930}",
+ "\u{16121}"=>"\u{1611E}\u{1611E}",
+ "\u{16122}"=>"\u{1611E}\u{16129}",
+ "\u{16123}"=>"\u{1611E}\u{1611F}",
+ "\u{16124}"=>"\u{16129}\u{1611F}",
+ "\u{16125}"=>"\u{1611E}\u{16120}",
+ "\u{16126}"=>"\u{1611E}\u{1611E}\u{1611F}",
+ "\u{16127}"=>"\u{1611E}\u{16129}\u{1611F}",
+ "\u{16128}"=>"\u{1611E}\u{1611E}\u{16120}",
+ "\u{16D68}"=>"\u{16D67}\u{16D67}",
+ "\u{16D69}"=>"\u{16D63}\u{16D67}",
+ "\u{16D6A}"=>"\u{16D63}\u{16D67}\u{16D67}",
"\u{1D15E}"=>"\u{1D157}\u{1D165}",
"\u{1D15F}"=>"\u{1D158}\u{1D165}",
"\u{1D160}"=>"\u{1D158}\u{1D165}\u{1D16E}",
@@ -5839,6 +5962,7 @@ module UnicodeNormalize # :nodoc:
"\uA69C"=>"\u044A",
"\uA69D"=>"\u044C",
"\uA770"=>"\uA76F",
+ "\uA7F1"=>"S",
"\uA7F2"=>"C",
"\uA7F3"=>"F",
"\uA7F4"=>"Q",
@@ -6950,6 +7074,42 @@ module UnicodeNormalize # :nodoc:
"\u{107B8}"=>"\u01C2",
"\u{107B9}"=>"\u{1DF0A}",
"\u{107BA}"=>"\u{1DF1E}",
+ "\u{1CCD6}"=>"A",
+ "\u{1CCD7}"=>"B",
+ "\u{1CCD8}"=>"C",
+ "\u{1CCD9}"=>"D",
+ "\u{1CCDA}"=>"E",
+ "\u{1CCDB}"=>"F",
+ "\u{1CCDC}"=>"G",
+ "\u{1CCDD}"=>"H",
+ "\u{1CCDE}"=>"I",
+ "\u{1CCDF}"=>"J",
+ "\u{1CCE0}"=>"K",
+ "\u{1CCE1}"=>"L",
+ "\u{1CCE2}"=>"M",
+ "\u{1CCE3}"=>"N",
+ "\u{1CCE4}"=>"O",
+ "\u{1CCE5}"=>"P",
+ "\u{1CCE6}"=>"Q",
+ "\u{1CCE7}"=>"R",
+ "\u{1CCE8}"=>"S",
+ "\u{1CCE9}"=>"T",
+ "\u{1CCEA}"=>"U",
+ "\u{1CCEB}"=>"V",
+ "\u{1CCEC}"=>"W",
+ "\u{1CCED}"=>"X",
+ "\u{1CCEE}"=>"Y",
+ "\u{1CCEF}"=>"Z",
+ "\u{1CCF0}"=>"0",
+ "\u{1CCF1}"=>"1",
+ "\u{1CCF2}"=>"2",
+ "\u{1CCF3}"=>"3",
+ "\u{1CCF4}"=>"4",
+ "\u{1CCF5}"=>"5",
+ "\u{1CCF6}"=>"6",
+ "\u{1CCF7}"=>"7",
+ "\u{1CCF8}"=>"8",
+ "\u{1CCF9}"=>"9",
"\u{1D400}"=>"A",
"\u{1D401}"=>"B",
"\u{1D402}"=>"C",
@@ -9242,6 +9402,8 @@ module UnicodeNormalize # :nodoc:
"\u30F1\u3099"=>"\u30F9",
"\u30F2\u3099"=>"\u30FA",
"\u30FD\u3099"=>"\u30FE",
+ "\u{105D2}\u0307"=>"\u{105C9}",
+ "\u{105DA}\u0307"=>"\u{105E4}",
"\u{11099}\u{110BA}"=>"\u{1109A}",
"\u{1109B}\u{110BA}"=>"\u{1109C}",
"\u{110A5}\u{110BA}"=>"\u{110AB}",
@@ -9249,11 +9411,29 @@ module UnicodeNormalize # :nodoc:
"\u{11132}\u{11127}"=>"\u{1112F}",
"\u{11347}\u{1133E}"=>"\u{1134B}",
"\u{11347}\u{11357}"=>"\u{1134C}",
+ "\u{11382}\u{113C9}"=>"\u{11383}",
+ "\u{11384}\u{113BB}"=>"\u{11385}",
+ "\u{1138B}\u{113C2}"=>"\u{1138E}",
+ "\u{11390}\u{113C9}"=>"\u{11391}",
+ "\u{113C2}\u{113C2}"=>"\u{113C5}",
+ "\u{113C2}\u{113B8}"=>"\u{113C7}",
+ "\u{113C2}\u{113C9}"=>"\u{113C8}",
"\u{114B9}\u{114BA}"=>"\u{114BB}",
"\u{114B9}\u{114B0}"=>"\u{114BC}",
"\u{114B9}\u{114BD}"=>"\u{114BE}",
"\u{115B8}\u{115AF}"=>"\u{115BA}",
"\u{115B9}\u{115AF}"=>"\u{115BB}",
"\u{11935}\u{11930}"=>"\u{11938}",
+ "\u{1611E}\u{1611E}"=>"\u{16121}",
+ "\u{1611E}\u{16129}"=>"\u{16122}",
+ "\u{1611E}\u{1611F}"=>"\u{16123}",
+ "\u{16129}\u{1611F}"=>"\u{16124}",
+ "\u{1611E}\u{16120}"=>"\u{16125}",
+ "\u{16121}\u{1611F}"=>"\u{16126}",
+ "\u{16122}\u{1611F}"=>"\u{16127}",
+ "\u{16121}\u{16120}"=>"\u{16128}",
+ "\u{16D67}\u{16D67}"=>"\u{16D68}",
+ "\u{16D63}\u{16D67}"=>"\u{16D69}",
+ "\u{16D69}\u{16D67}"=>"\u{16D6A}",
}.freeze
end
diff --git a/lib/uri.rb b/lib/uri.rb
index 59a7c4ad28..dfdb052a79 100644
--- a/lib/uri.rb
+++ b/lib/uri.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
# URI is a module providing classes to handle Uniform Resource Identifiers
-# (RFC2396[http://tools.ietf.org/html/rfc2396]).
+# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
#
# == Features
#
@@ -47,14 +47,14 @@
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
#
# Here is a list of all related RFC's:
-# - RFC822[http://tools.ietf.org/html/rfc822]
-# - RFC1738[http://tools.ietf.org/html/rfc1738]
-# - RFC2255[http://tools.ietf.org/html/rfc2255]
-# - RFC2368[http://tools.ietf.org/html/rfc2368]
-# - RFC2373[http://tools.ietf.org/html/rfc2373]
-# - RFC2396[http://tools.ietf.org/html/rfc2396]
-# - RFC2732[http://tools.ietf.org/html/rfc2732]
-# - RFC3986[http://tools.ietf.org/html/rfc3986]
+# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
+# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
+# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
+# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
+# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
+# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
+# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
+# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
#
# == Class tree
#
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index dce09fbc1e..a2fb531631 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -13,24 +13,54 @@ require_relative "rfc2396_parser"
require_relative "rfc3986_parser"
module URI
- include RFC2396_REGEXP
+ # The default parser instance for RFC 2396.
+ RFC2396_PARSER = RFC2396_Parser.new
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
- REGEXP = RFC2396_REGEXP
- Parser = RFC2396_Parser
+ # The default parser instance for RFC 3986.
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
- # URI::Parser.new
- DEFAULT_PARSER = Parser.new
- DEFAULT_PARSER.pattern.each_pair do |sym, str|
- unless REGEXP::PATTERN.const_defined?(sym)
- REGEXP::PATTERN.const_set(sym, str)
+ # The default parser instance.
+ DEFAULT_PARSER = RFC3986_PARSER
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
+
+ # Set the default parser instance.
+ def self.parser=(parser = RFC3986_PARSER)
+ remove_const(:Parser) if defined?(::URI::Parser)
+ const_set("Parser", parser.class)
+
+ remove_const(:PARSER) if defined?(::URI::PARSER)
+ const_set("PARSER", parser)
+
+ remove_const(:REGEXP) if defined?(::URI::REGEXP)
+ remove_const(:PATTERN) if defined?(::URI::PATTERN)
+ if Parser == RFC2396_Parser
+ const_set("REGEXP", URI::RFC2396_REGEXP)
+ const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN)
+ end
+
+ Parser.new.regexp.each_pair do |sym, str|
+ remove_const(sym) if const_defined?(sym, false)
+ const_set(sym, str)
end
end
- DEFAULT_PARSER.regexp.each_pair do |sym, str|
- const_set(sym, str)
+ self.parser = RFC3986_PARSER
+
+ def self.const_missing(const) # :nodoc:
+ if const == :REGEXP
+ warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
+ URI::RFC2396_REGEXP
+ elsif value = RFC2396_PARSER.regexp[const]
+ warn "URI::#{const} is obsolete. Use URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
+ value
+ elsif value = RFC2396_Parser.const_get(const)
+ warn "URI::#{const} is obsolete. Use URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
+ value
+ else
+ super
+ end
end
- Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
module Util # :nodoc:
def make_components_hash(klass, array_hash)
@@ -64,7 +94,41 @@ module URI
module_function :make_components_hash
end
- module Schemes
+ module Schemes # :nodoc:
+ class << self
+ ReservedChars = ".+-"
+ EscapedChars = "\u01C0\u01C1\u01C2"
+ # Use Lo category chars as escaped chars for TruffleRuby, which
+ # does not allow Symbol categories as identifiers.
+
+ def escape(name)
+ unless name and name.ascii_only?
+ return nil
+ end
+ name.upcase.tr(ReservedChars, EscapedChars)
+ end
+
+ def unescape(name)
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
+ end
+
+ def find(name)
+ const_get(name, false) if name and const_defined?(name, false)
+ end
+
+ def register(name, klass)
+ unless scheme = escape(name)
+ raise ArgumentError, "invalid character as scheme - #{name}"
+ end
+ const_set(scheme, klass)
+ end
+
+ def list
+ constants.map { |name|
+ [unescape(name.to_s), const_get(name)]
+ }.to_h
+ end
+ end
end
private_constant :Schemes
@@ -77,7 +141,7 @@ module URI
# Note that after calling String#upcase on +scheme+, it must be a valid
# constant name.
def self.register_scheme(scheme, klass)
- Schemes.const_set(scheme.to_s.upcase, klass)
+ Schemes.register(scheme, klass)
end
# Returns a hash of the defined schemes:
@@ -95,14 +159,14 @@ module URI
#
# Related: URI.register_scheme.
def self.scheme_list
- Schemes.constants.map { |name|
- [name.to_s.upcase, Schemes.const_get(name)]
- }.to_h
+ Schemes.list
end
+ # :stopdoc:
INITIAL_SCHEMES = scheme_list
private_constant :INITIAL_SCHEMES
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
+ # :startdoc:
# Returns a new object constructed from the given +scheme+, +arguments+,
# and +default+:
@@ -121,12 +185,10 @@ module URI
# # => #<URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
def self.for(scheme, *arguments, default: Generic)
- const_name = scheme.to_s.upcase
+ const_name = Schemes.escape(scheme)
uri_class = INITIAL_SCHEMES[const_name]
- uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
- Schemes.const_get(const_name, false)
- end
+ uri_class ||= Schemes.find(const_name)
uri_class ||= default
return uri_class.new(scheme, *arguments)
@@ -168,7 +230,7 @@ module URI
# ["fragment", "top"]]
#
def self.split(uri)
- RFC3986_PARSER.split(uri)
+ PARSER.split(uri)
end
# Returns a new \URI object constructed from the given string +uri+:
@@ -178,11 +240,11 @@ module URI
# URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
# # => #<URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
- # It's recommended to first ::escape string +uri+
+ # It's recommended to first URI::RFC2396_PARSER.escape string +uri+
# if it may contain invalid URI characters.
#
def self.parse(uri)
- RFC3986_PARSER.parse(uri)
+ PARSER.parse(uri)
end
# Merges the given URI strings +str+
@@ -209,7 +271,7 @@ module URI
# # => #<URI::HTTP http://example.com/foo/bar>
#
def self.join(*str)
- RFC3986_PARSER.join(*str)
+ PARSER.join(*str)
end
#
@@ -238,7 +300,7 @@ module URI
#
def self.extract(str, schemes = nil, &block) # :nodoc:
warn "URI.extract is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.extract(str, schemes, &block)
+ PARSER.extract(str, schemes, &block)
end
#
@@ -275,14 +337,14 @@ module URI
#
def self.regexp(schemes = nil)# :nodoc:
warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE
- DEFAULT_PARSER.make_regexp(schemes)
+ PARSER.make_regexp(schemes)
end
TBLENCWWWCOMP_ = {} # :nodoc:
256.times do |i|
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
end
- TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc:
TBLENCWWWCOMP_[' '] = '+'
TBLENCWWWCOMP_.freeze
TBLDECWWWCOMP_ = {} # :nodoc:
@@ -380,6 +442,8 @@ module URI
_decode_uri_component(/%\h\h/, str, enc)
end
+ # Returns a string derived from the given string +str+ with
+ # URI-encoded characters matching +regexp+ according to +table+.
def self._encode_uri_component(regexp, table, str, enc)
str = str.to_s.dup
if str.encoding != Encoding::ASCII_8BIT
@@ -394,6 +458,8 @@ module URI
end
private_class_method :_encode_uri_component
+ # Returns a string decoding characters matching +regexp+ from the
+ # given \URL-encoded string +str+.
def self._decode_uri_component(regexp, str, enc)
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
@@ -832,6 +898,7 @@ module Kernel
# Returns a \URI object derived from the given +uri+,
# which may be a \URI string or an existing \URI object:
#
+ # require 'uri'
# # Returns a new URI.
# uri = URI('http://github.com/ruby/ruby')
# # => #<URI::HTTP http://github.com/ruby/ruby>
@@ -839,6 +906,8 @@ module Kernel
# URI(uri)
# # => #<URI::HTTP http://github.com/ruby/ruby>
#
+ # You must require 'uri' to use this method.
+ #
def URI(uri)
if uri.is_a?(URI::Generic)
uri
diff --git a/lib/uri/file.rb b/lib/uri/file.rb
index 4ff0bc097e..47b5aef067 100644
--- a/lib/uri/file.rb
+++ b/lib/uri/file.rb
@@ -47,7 +47,7 @@ module URI
# :path => '/ruby/src'})
# uri2.to_s # => "file://host.example.com/ruby/src"
#
- # uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
+ # uri3 = URI::File.build({:path => URI::RFC2396_PARSER.escape('/path/my file.txt')})
# uri3.to_s # => "file:///path/my%20file.txt"
#
def self.build(args)
@@ -70,17 +70,17 @@ module URI
# raise InvalidURIError
def check_userinfo(user)
- raise URI::InvalidURIError, "can not set userinfo for file URI"
+ raise URI::InvalidURIError, "cannot set userinfo for file URI"
end
# raise InvalidURIError
def check_user(user)
- raise URI::InvalidURIError, "can not set user for file URI"
+ raise URI::InvalidURIError, "cannot set user for file URI"
end
# raise InvalidURIError
def check_password(user)
- raise URI::InvalidURIError, "can not set password for file URI"
+ raise URI::InvalidURIError, "cannot set password for file URI"
end
# do nothing
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index abad613c33..1c75e242ba 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -17,7 +17,7 @@ module URI
# This class will be redesigned because of difference of implementations;
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
# is a good summary about the de facto spec.
- # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
+ # https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
# A Default port of 21 for URI::FTP.
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 69698c4e2d..6a0f638d76 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -73,7 +73,7 @@ module URI
#
# At first, tries to create a new URI::Generic instance using
# URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
- # then it does URI::Escape.escape all URI components and tries again.
+ # then it does URI::RFC2396_PARSER.escape all URI components and tries again.
#
def self.build2(args)
begin
@@ -82,7 +82,7 @@ module URI
if args.kind_of?(Array)
return self.build(args.collect{|x|
if x.is_a?(String)
- DEFAULT_PARSER.escape(x)
+ URI::RFC2396_PARSER.escape(x)
else
x
end
@@ -91,7 +91,7 @@ module URI
tmp = {}
args.each do |key, value|
tmp[key] = if value
- DEFAULT_PARSER.escape(value)
+ URI::RFC2396_PARSER.escape(value)
else
value
end
@@ -126,9 +126,9 @@ module URI
end
end
else
- component = self.class.component rescue ::URI::Generic::COMPONENT
+ component = self.component rescue ::URI::Generic::COMPONENT
raise ArgumentError,
- "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
+ "expected Array of or Hash of components of #{self} (#{component.join(', ')})"
end
tmp << nil
@@ -186,18 +186,18 @@ module URI
if arg_check
self.scheme = scheme
- self.userinfo = userinfo
self.hostname = host
self.port = port
+ self.userinfo = userinfo
self.path = path
self.query = query
self.opaque = opaque
self.fragment = fragment
else
self.set_scheme(scheme)
- self.set_userinfo(userinfo)
self.set_host(host)
self.set_port(port)
+ self.set_userinfo(userinfo)
self.set_path(path)
self.query = query
self.set_opaque(opaque)
@@ -284,7 +284,7 @@ module URI
# Returns the parser to be used.
#
- # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
+ # Unless the +parser+ is defined, DEFAULT_PARSER is used.
#
def parser
if !defined?(@parser) || !@parser
@@ -315,7 +315,7 @@ module URI
end
#
- # Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME.
+ # Checks the scheme +v+ component against the +parser+ Regexp for :SCHEME.
#
def check_scheme(v)
if v && parser.regexp[:SCHEME] !~ v
@@ -385,7 +385,7 @@ module URI
#
# Checks the user +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :USERINFO.
+ # and against the +parser+ Regexp for :USERINFO.
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -393,7 +393,7 @@ module URI
def check_user(v)
if @opaque
raise InvalidURIError,
- "can not set user with opaque"
+ "cannot set user with opaque"
end
return v unless v
@@ -409,7 +409,7 @@ module URI
#
# Checks the password +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :USERINFO.
+ # and against the +parser+ Regexp for :USERINFO.
#
# Can not have a registry or opaque component defined,
# with a user component defined.
@@ -417,7 +417,7 @@ module URI
def check_password(v, user = @user)
if @opaque
raise InvalidURIError,
- "can not set password with opaque"
+ "cannot set password with opaque"
end
return v unless v
@@ -466,7 +466,7 @@ module URI
#
# uri = URI.parse("http://john:S3nsit1ve@my.example.com")
# uri.user = "sam"
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
+ # uri.to_s #=> "http://sam@my.example.com"
#
def user=(user)
check_user(user)
@@ -511,7 +511,7 @@ module URI
user, password = split_userinfo(user)
end
@user = user
- @password = password if password
+ @password = password
[@user, @password]
end
@@ -522,7 +522,7 @@ module URI
# See also URI::Generic.user=.
#
def set_user(v)
- set_userinfo(v, @password)
+ set_userinfo(v, nil)
v
end
protected :set_user
@@ -574,6 +574,12 @@ module URI
@password
end
+ # Returns the authority info (array of user, password, host and
+ # port), if any is set. Or returns +nil+.
+ def authority
+ return @user, @password, @host, @port if @user || @password || @host || @port
+ end
+
# Returns the user component after URI decoding.
def decoded_user
URI.decode_uri_component(@user) if @user
@@ -586,7 +592,7 @@ module URI
#
# Checks the host +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :HOST.
+ # and against the +parser+ Regexp for :HOST.
#
# Can not have a registry or opaque component defined,
# with a host component defined.
@@ -596,7 +602,7 @@ module URI
if @opaque
raise InvalidURIError,
- "can not set host with registry or opaque"
+ "cannot set host with registry or opaque"
elsif parser.regexp[:HOST] !~ v
raise InvalidComponentError,
"bad component(expected host component): #{v}"
@@ -615,6 +621,13 @@ module URI
end
protected :set_host
+ # Protected setter for the authority info (+user+, +password+, +host+
+ # and +port+). If +port+ is +nil+, +default_port+ will be set.
+ #
+ protected def set_authority(user, password, host, port = nil)
+ @user, @password, @host, @port = user, password, host, port || self.default_port
+ end
+
#
# == Args
#
@@ -639,6 +652,7 @@ module URI
def host=(v)
check_host(v)
set_host(v)
+ set_userinfo(nil)
v
end
@@ -675,7 +689,7 @@ module URI
#
# Checks the port +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp for :PORT.
+ # and against the +parser+ Regexp for :PORT.
#
# Can not have a registry or opaque component defined,
# with a port component defined.
@@ -685,7 +699,7 @@ module URI
if @opaque
raise InvalidURIError,
- "can not set port with registry or opaque"
+ "cannot set port with registry or opaque"
elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
raise InvalidComponentError,
"bad component(expected port component): #{v.inspect}"
@@ -729,26 +743,27 @@ module URI
def port=(v)
check_port(v)
set_port(v)
+ set_userinfo(nil)
port
end
def check_registry(v) # :nodoc:
- raise InvalidURIError, "can not set registry"
+ raise InvalidURIError, "cannot set registry"
end
private :check_registry
- def set_registry(v) #:nodoc:
- raise InvalidURIError, "can not set registry"
+ def set_registry(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
end
protected :set_registry
- def registry=(v)
- raise InvalidURIError, "can not set registry"
+ def registry=(v) # :nodoc:
+ raise InvalidURIError, "cannot set registry"
end
#
# Checks the path +v+ component for RFC2396 compliance
- # and against the URI::Parser Regexp
+ # and against the +parser+ Regexp
# for :ABS_PATH and :REL_PATH.
#
# Can not have a opaque component defined,
@@ -853,7 +868,7 @@ module URI
#
# Checks the opaque +v+ component for RFC2396 compliance and
- # against the URI::Parser Regexp for :OPAQUE.
+ # against the +parser+ Regexp for :OPAQUE.
#
# Can not have a host, port, user, or path component defined,
# with an opaque component defined.
@@ -866,7 +881,7 @@ module URI
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
raise InvalidURIError,
- "can not set opaque with host, port, userinfo or path"
+ "cannot set opaque with host, port, userinfo or path"
elsif v && parser.regexp[:OPAQUE] !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
@@ -905,7 +920,7 @@ module URI
end
#
- # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
+ # Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT.
#
#
# == Args
@@ -945,7 +960,7 @@ module URI
# == Description
#
# URI has components listed in order of decreasing significance from left to right,
- # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
+ # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
#
# == Usage
#
@@ -1121,7 +1136,7 @@ module URI
base = self.dup
- authority = rel.userinfo || rel.host || rel.port
+ authority = rel.authority
# RFC2396, Section 5.2, 2)
if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1133,17 +1148,14 @@ module URI
base.fragment=(nil)
# RFC2396, Section 5.2, 4)
- if !authority
- base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
- else
- # RFC2396, Section 5.2, 4)
- base.set_path(rel.path) if rel.path
+ if authority
+ base.set_authority(*authority)
+ base.set_path(rel.path)
+ elsif base.path && rel.path
+ base.set_path(merge_path(base.path, rel.path))
end
# RFC2396, Section 5.2, 7)
- base.set_userinfo(rel.userinfo) if rel.userinfo
- base.set_host(rel.host) if rel.host
- base.set_port(rel.port) if rel.port
base.query = rel.query if rel.query
base.fragment=(rel.fragment) if rel.fragment
@@ -1235,7 +1247,7 @@ module URI
return rel, rel
end
- # you can modify `rel', but can not `oth'.
+ # you can modify `rel', but cannot `oth'.
return oth, rel
end
private :route_from0
@@ -1260,7 +1272,7 @@ module URI
# #=> #<URI::Generic /main.rbx?page=1>
#
def route_from(oth)
- # you can modify `rel', but can not `oth'.
+ # you can modify `rel', but cannot `oth'.
begin
oth, rel = route_from0(oth)
rescue
@@ -1364,6 +1376,9 @@ module URI
str << ':'
str << @port.to_s
end
+ if (@host || @port) && !@path.empty? && !@path.start_with?('/')
+ str << '/'
+ end
str << @path
if @query
str << '?'
@@ -1376,6 +1391,7 @@ module URI
end
str
end
+ alias to_str to_s
#
# Compares two URIs.
@@ -1388,29 +1404,18 @@ module URI
end
end
+ # Returns the hash value.
def hash
self.component_ary.hash
end
+ # Compares with _oth_ for Hash.
def eql?(oth)
self.class == oth.class &&
parser == oth.parser &&
self.component_ary.eql?(oth.component_ary)
end
-=begin
-
---- URI::Generic#===(oth)
-
-=end
-# def ===(oth)
-# raise NotImplementedError
-# end
-
-=begin
-=end
-
-
# Returns an Array of the components defined from the COMPONENT Array.
def component_ary
component.collect do |x|
@@ -1447,7 +1452,7 @@ module URI
end
end
- def inspect
+ def inspect # :nodoc:
"#<#{self.class} #{self}>"
end
@@ -1535,7 +1540,7 @@ module URI
else
unless proxy_uri = env[name]
if proxy_uri = env[name.upcase]
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
+ warn 'The environment variable HTTP_PROXY is discouraged. Please use http_proxy instead.', uplevel: 1
end
end
end
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 306daf1965..3c41cd4e93 100644
--- a/lib/uri/http.rb
+++ b/lib/uri/http.rb
@@ -61,6 +61,18 @@ module URI
super(tmp)
end
+ # Do not allow empty host names, as they are not allowed by RFC 3986.
+ def check_host(v)
+ ret = super
+
+ if ret && v.empty?
+ raise InvalidComponentError,
+ "bad component(expected host component): #{v}"
+ end
+
+ ret
+ end
+
#
# == Description
#
@@ -85,7 +97,7 @@ module URI
# == Description
#
# Returns the authority for an HTTP uri, as defined in
- # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
+ # https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
#
#
# Example:
@@ -106,7 +118,7 @@ module URI
# == Description
#
# Returns the origin for an HTTP uri, as defined in
- # https://datatracker.ietf.org/doc/html/rfc6454.
+ # https://www.rfc-editor.org/rfc/rfc6454.
#
#
# Example:
diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb
index 76a8f99fd4..cefd126cc6 100644
--- a/lib/uri/rfc2396_parser.rb
+++ b/lib/uri/rfc2396_parser.rb
@@ -67,7 +67,7 @@ module URI
#
# == Synopsis
#
- # URI::Parser.new([opts])
+ # URI::RFC2396_Parser.new([opts])
#
# == Args
#
@@ -86,7 +86,7 @@ module URI
#
# == Examples
#
- # p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
+ # p = URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
# u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
# URI.parse(u.to_s) #=> raises URI::InvalidURIError
#
@@ -108,12 +108,12 @@ module URI
# The Hash of patterns.
#
- # See also URI::Parser.initialize_pattern.
+ # See also #initialize_pattern.
attr_reader :pattern
# The Hash of Regexp.
#
- # See also URI::Parser.initialize_regexp.
+ # See also #initialize_regexp.
attr_reader :regexp
# Returns a split URI against +regexp[:ABS_URI]+.
@@ -140,11 +140,11 @@ module URI
if !scheme
raise InvalidURIError,
- "bad URI(absolute but no scheme): #{uri}"
+ "bad URI (absolute but no scheme): #{uri}"
end
if !opaque && (!path && (!host && !registry))
raise InvalidURIError,
- "bad URI(absolute but no path): #{uri}"
+ "bad URI (absolute but no path): #{uri}"
end
when @regexp[:REL_URI]
@@ -173,7 +173,7 @@ module URI
# server = [ [ userinfo "@" ] hostport ]
else
- raise InvalidURIError, "bad URI(is not URI?): #{uri}"
+ raise InvalidURIError, "bad URI (is not URI?): #{uri}"
end
path = '' if !path && !opaque # (see RFC2396 Section 5.2)
@@ -202,8 +202,7 @@ module URI
#
# == Usage
#
- # p = URI::Parser.new
- # p.parse("ldap://ldap.example.com/dc=example?user=john")
+ # URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john")
# #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
#
def parse(uri)
@@ -244,7 +243,7 @@ module URI
# If no +block+ given, then returns the result,
# else it calls +block+ for each element in result.
#
- # See also URI::Parser.make_regexp.
+ # See also #make_regexp.
#
def extract(str, schemes = nil)
if block_given?
@@ -263,7 +262,7 @@ module URI
unless schemes
@regexp[:ABS_URI_REF]
else
- /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
+ /(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
end
end
@@ -321,14 +320,14 @@ module URI
str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
end
- @@to_s = Kernel.instance_method(:to_s)
- if @@to_s.respond_to?(:bind_call)
- def inspect
- @@to_s.bind_call(self)
+ TO_S = Kernel.instance_method(:to_s) # :nodoc:
+ if TO_S.respond_to?(:bind_call)
+ def inspect # :nodoc:
+ TO_S.bind_call(self)
end
else
- def inspect
- @@to_s.bind(self).call
+ def inspect # :nodoc:
+ TO_S.bind(self).call
end
end
@@ -497,8 +496,8 @@ module URI
ret = {}
# for URI::split
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
# for URI::extract
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
@@ -524,6 +523,8 @@ module URI
ret
end
+ # Returns +uri+ as-is if it is URI, or convert it to URI if it is
+ # a String.
def convert_to_uri(uri)
if uri.is_a?(URI::Generic)
uri
@@ -536,4 +537,11 @@ module URI
end
end # class Parser
+
+ # Backward compatibility for URI::REGEXP::PATTERN::*
+ RFC2396_Parser.new.pattern.each_pair do |sym, str|
+ unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false)
+ RFC2396_REGEXP::PATTERN.const_set(sym, str)
+ end
+ end
end # module URI
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb
index f3816d9ae5..0b5f0c4488 100644
--- a/lib/uri/rfc3986_parser.rb
+++ b/lib/uri/rfc3986_parser.rb
@@ -1,9 +1,73 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module URI
class RFC3986_Parser # :nodoc:
# URI defined in RFC3986
- RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
+ HOST = %r[
+ (?<IP-literal>\[(?:
+ (?<IPv6address>
+ (?:\h{1,4}:){6}
+ (?<ls32>\h{1,4}:\h{1,4}
+ | (?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)
+ \.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>)
+ )
+ | ::(?:\h{1,4}:){5}\g<ls32>
+ | \h{1,4}?::(?:\h{1,4}:){4}\g<ls32>
+ | (?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>
+ | (?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>
+ | (?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>
+ | (?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>
+ | (?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}
+ | (?:(?:\h{1,4}:){,6}\h{1,4})?::
+ )
+ | (?<IPvFuture>v\h++\.[!$&-.0-9:;=A-Z_a-z~]++)
+ )\])
+ | \g<IPv4address>
+ | (?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+)
+ ]x
+
+ USERINFO = /(?:%\h\h|[!$&-.0-9:;=A-Z_a-z~])*+/
+
+ SCHEME = %r[[A-Za-z][+\-.0-9A-Za-z]*+].source
+ SEG = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/])].source
+ SEG_NC = %r[(?:%\h\h|[!$&-.0-9;=@A-Z_a-z~])].source
+ FRAGMENT = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+].source
+
+ RFC3986_URI = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<URI>
+ (?<scheme>#{SCHEME}):
+ (?<hier-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")})
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/((?!/)\g<seg>++)?)
+ | (?<path-rootless>(?!/)\g<seg>++)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^\#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
+
+ RFC3986_relative_ref = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<relative-ref>
+ (?<relative-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")}(?<!/))?
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/\g<seg>*+)
+ | (?<path-noscheme>#{SEG_NC}++(?:/\g<seg>*+)?)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
attr_reader :regexp
def initialize
@@ -14,14 +78,14 @@ module URI
begin
uri = uri.to_str
rescue NoMethodError
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}"
end
uri.ascii_only? or
raise InvalidURIError, "URI must be ascii only #{uri.dump}"
if m = RFC3986_URI.match(uri)
- query = m["query".freeze]
- scheme = m["scheme".freeze]
- opaque = m["path-rootless".freeze]
+ query = m["query"]
+ scheme = m["scheme"]
+ opaque = m["path-rootless"]
if opaque
opaque << "?#{query}" if query
[ scheme,
@@ -32,38 +96,38 @@ module URI
nil, # path
opaque,
nil, # query
- m["fragment".freeze]
+ m["fragment"]
]
else # normal
[ scheme,
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-empty"]),
nil, # opaque
query,
- m["fragment".freeze]
+ m["fragment"]
]
end
elsif m = RFC3986_relative_ref.match(uri)
[ nil, # scheme
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry,
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-noscheme".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-noscheme"] ||
+ m["path-empty"]),
nil, # opaque
- m["query".freeze],
- m["fragment".freeze]
+ m["query"],
+ m["fragment"]
]
else
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
+ raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}"
end
end
@@ -71,12 +135,35 @@ module URI
URI.for(*self.split(uri), self)
end
-
def join(*uris) # :nodoc:
uris[0] = convert_to_uri(uris[0])
uris.inject :merge
end
+ # Compatibility for RFC2396 parser
+ def extract(str, schemes = nil, &block) # :nodoc:
+ warn "URI::RFC3986_PARSER.extract is obsolete. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.extract(str, schemes, &block)
+ end
+
+ # Compatibility for RFC2396 parser
+ def make_regexp(schemes = nil) # :nodoc:
+ warn "URI::RFC3986_PARSER.make_regexp is obsolete. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
+ RFC2396_PARSER.make_regexp(schemes)
+ end
+
+ # Compatibility for RFC2396 parser
+ def escape(str, unsafe = nil) # :nodoc:
+ warn "URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
+ unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
+ end
+
+ # Compatibility for RFC2396 parser
+ def unescape(str, escaped = nil) # :nodoc:
+ warn "URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
+ escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
+ end
+
@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
def inspect
@@ -92,15 +179,15 @@ module URI
def default_regexp # :nodoc:
{
- SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
- USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
- HOST: /\A(?:(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{,4}::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))\z/,
- ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- OPAQUE: /\A(?:[^\/].*)?\z/,
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
+ SCHEME: %r[\A#{SCHEME}\z]o,
+ USERINFO: %r[\A#{USERINFO}\z]o,
+ HOST: %r[\A#{HOST}\z]o,
+ ABS_PATH: %r[\A/#{SEG}*+\z]o,
+ REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
+ QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
+ FRAGMENT: %r[\A#{FRAGMENT}\z]o,
+ OPAQUE: %r[\A(?:[^/].*)?\z],
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
}
end
diff --git a/lib/uri/uri.gemspec b/lib/uri/uri.gemspec
index 57c3239c53..0d0f897cba 100644
--- a/lib/uri/uri.gemspec
+++ b/lib/uri/uri.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.homepage = github_link
spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = '>= 2.4'
+ spec.required_ruby_version = '>= 2.5'
spec.metadata = {
"bug_tracker_uri" => "#{github_link}/issues",
@@ -30,8 +30,11 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ gemspec = File.basename(__FILE__)
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject do |file|
+ (file == gemspec) || file.start_with?(*%w[bin/ test/ rakelib/ .github/ .gitignore Gemfile Rakefile])
+ end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/uri/version.rb b/lib/uri/version.rb
index a9643ef8bc..1f810602eb 100644
--- a/lib/uri/version.rb
+++ b/lib/uri/version.rb
@@ -1,6 +1,6 @@
module URI
# :stopdoc:
- VERSION_CODE = '001200'.freeze
- VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
+ VERSION = '1.1.1'.freeze
+ VERSION_CODE = VERSION.split('.').map{|s| s.rjust(2, '0')}.join.freeze
# :startdoc:
end
diff --git a/lib/weakref.gemspec b/lib/weakref.gemspec
new file mode 100644
index 0000000000..9d5c79851e
--- /dev/null
+++ b/lib/weakref.gemspec
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Allows a referenced object to be garbage-collected.}
+ spec.description = %q{Allows a referenced object to be garbage-collected.}
+ spec.homepage = "https://github.com/ruby/weakref"
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = "https://github.com/ruby/weakref"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.require_paths = ["lib"]
+
+ spec.add_dependency "delegate"
+end
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 2bbadf68f9..c7274f9664 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -17,7 +17,8 @@ require "delegate"
#
class WeakRef < Delegator
- VERSION = "0.1.2"
+ # The version string
+ VERSION = "0.1.4"
##
# RefError is raised when a referenced object has been recycled by the
@@ -41,7 +42,7 @@ class WeakRef < Delegator
super
end
- def __getobj__ # :nodoc:
+ def __getobj__(&_block) # :nodoc:
@@__map[self] or defined?(@delegate_sd_obj) ? @delegate_sd_obj :
Kernel::raise(RefError, "Invalid Reference - probably recycled", Kernel::caller(2))
end
diff --git a/lib/weakref/weakref.gemspec b/lib/weakref/weakref.gemspec
deleted file mode 100644
index 96a9765079..0000000000
--- a/lib/weakref/weakref.gemspec
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Allows a referenced object to be garbage-collected.}
- spec.description = %q{Allows a referenced object to be garbage-collected.}
- spec.homepage = "https://github.com/ruby/weakref"
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "https://github.com/ruby/weakref"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_dependency "delegate"
-end
diff --git a/lib/yaml.rb b/lib/yaml.rb
index 6d5d5ebd4c..c6f0f89fd2 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -66,4 +66,6 @@ YAML = Psych # :nodoc:
#
# Syck can also be found on github: https://github.com/ruby/syck
module YAML
+ # The version of YAML wrapper
+ LOADER_VERSION = "0.4.0"
end
diff --git a/lib/yaml/dbm.rb b/lib/yaml/dbm.rb
index e2508cd74b..a3cbaeccf6 100644
--- a/lib/yaml/dbm.rb
+++ b/lib/yaml/dbm.rb
@@ -1,6 +1,10 @@
# frozen_string_literal: false
require 'yaml'
-require 'dbm'
+
+begin
+ require 'dbm'
+rescue LoadError
+end
module YAML
@@ -16,7 +20,6 @@ module YAML
#
# See the documentation for ::DBM and ::YAML for more information.
class DBM < ::DBM
- VERSION = "0.1" # :nodoc:
# :call-seq:
# ydbm[key] -> value
@@ -56,7 +59,13 @@ class DBM < ::DBM
def fetch( keystr, ifnone = nil )
begin
val = super( keystr )
- return YAML.load( val ) if String === val
+ if String === val
+ if YAML.respond_to?(:safe_load)
+ return YAML.safe_load( val )
+ else
+ return YAML.load( val )
+ end
+ end
rescue IndexError
end
if block_given?
@@ -102,7 +111,11 @@ class DBM < ::DBM
def delete( key )
v = super( key )
if String === v
- v = YAML.load( v )
+ if YAML.respond_to?(:safe_load)
+ v = YAML.safe_load( v )
+ else
+ v = YAML.load( v )
+ end
end
v
end
@@ -149,7 +162,7 @@ class DBM < ::DBM
#
# Returns +self+.
def each_value # :yields: value
- super { |v| yield YAML.load( v ) }
+ super { |v| yield YAML.respond_to?(:safe_load) ? YAML.safe_load( v ) : YAML.load( v ) }
self
end
@@ -158,7 +171,7 @@ class DBM < ::DBM
#
# Returns an array of values from the database.
def values
- super.collect { |v| YAML.load( v ) }
+ super.collect { |v| YAML.respond_to?(:safe_load) ? YAML.safe_load( v ) : YAML.load( v ) }
end
# :call-seq:
@@ -204,7 +217,9 @@ class DBM < ::DBM
# The order in which values are removed/returned is not guaranteed.
def shift
a = super
- a[1] = YAML.load( a[1] ) if a
+ if a
+ a[1] = YAML.respond_to?(:safe_load) ? YAML.safe_load( a[1] ) : YAML.load( a[1] )
+ end
a
end
@@ -277,4 +292,4 @@ class DBM < ::DBM
alias :each :each_pair
end
-end
+end if defined?(DBM)
diff --git a/lib/yaml/store.rb b/lib/yaml/store.rb
index f8650b942f..27c823b9f9 100644
--- a/lib/yaml/store.rb
+++ b/lib/yaml/store.rb
@@ -3,7 +3,11 @@
# YAML::Store
#
require 'yaml'
-require 'pstore'
+
+begin
+ require 'pstore'
+rescue LoadError
+end
# YAML::Store provides the same functionality as PStore, except it uses YAML
# to dump objects instead of Marshal.
@@ -65,8 +69,16 @@ class YAML::Store < PStore
end
def load(content)
- table = YAML.unsafe_load(content)
- if table == false
+ table = if YAML.respond_to?(:safe_load)
+ if Psych::VERSION >= "3.1"
+ YAML.safe_load(content, permitted_classes: [Symbol])
+ else
+ YAML.safe_load(content, [Symbol])
+ end
+ else
+ YAML.load(content)
+ end
+ if table == false || table == nil
{}
else
table
@@ -83,4 +95,4 @@ class YAML::Store < PStore
def empty_marshal_checksum
CHECKSUM_ALGO.digest(empty_marshal_data)
end
-end
+end if defined?(::PStore)
diff --git a/lib/yaml/yaml.gemspec b/lib/yaml/yaml.gemspec
index 80554d8a7a..17e1ce89e0 100644
--- a/lib/yaml/yaml.gemspec
+++ b/lib/yaml/yaml.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*LOADER_VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "yaml"
- spec.version = "0.2.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
spec.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]
@@ -15,7 +22,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/libexec/bundle b/libexec/bundle
index eaf2246bc0..92387bc2cf 100755
--- a/libexec/bundle
+++ b/libexec/bundle
@@ -10,37 +10,20 @@ end
base_path = File.expand_path("../lib", __dir__)
if File.exist?(base_path)
- require_relative "../lib/bundler"
-else
- require "bundler"
+ $LOAD_PATH.unshift(base_path)
end
-if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.7.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
- Bundler.ui.warn \
- "Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
- "`required_ruby_version` from working for Bundler. Any scripts that use " \
- "`gem install bundler` will break as soon as Bundler drops support for " \
- "your Ruby version. Please upgrade RubyGems to avoid future breakage " \
- "and silence this warning by running `gem update --system 3.2.3`"
-end
+require "bundler"
-if File.exist?(base_path)
- require_relative "../lib/bundler/friendly_errors"
-else
- require "bundler/friendly_errors"
-end
+require "bundler/friendly_errors"
Bundler.with_friendly_errors do
- if File.exist?(base_path)
- require_relative "../lib/bundler/cli"
- else
- require "bundler/cli"
- end
+ require "bundler/cli"
# Allow any command to use --help flag to show help for that command
help_flags = %w[--help -h]
help_flag_used = ARGV.any? {|a| help_flags.include? a }
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
- Bundler::CLI.start(args, :debug => true)
+ Bundler::CLI.start(args, debug: true)
end
diff --git a/libexec/erb b/libexec/erb
index 4381671f25..de7d5888c3 100755
--- a/libexec/erb
+++ b/libexec/erb
@@ -90,29 +90,49 @@ class ERB
when '-P'
disable_percent = true
when '--help'
- raise "print this help"
+ raise ''
when /\A-/
- raise "unknown switch #{switch.dump}"
+ raise "Unknown switch: #{switch.dump}"
else
var, val = *switch.split('=', 2)
(variables ||= {})[var] = val
end
end
rescue # usage
- STDERR.puts $!.to_s
- STDERR.puts File.basename($0) +
- " [switches] [var=value...] [inputfile]"
+ message = $!.to_s
+ STDERR.puts message unless message.empty?
+ STDERR.puts 'Usage:'
+ STDERR.puts " #{File.basename($0)} [options] [filepaths]"
STDERR.puts <<EOU
- -x print ruby script
- -n print ruby script with line number
- -v enable verbose mode
- -d set $DEBUG to true
- -r library load a library
- -E ex[:in] set default external/internal encodings
- -U set default encoding to UTF-8
- -T trim_mode specify trim_mode (0..2, -)
- -P disable ruby code evaluation for lines beginning with %
- var=value set variable
+
+Options:
+ -d --debug Set $DEBUG to enable debugging.
+ -E ex[:in] --encoding ex[:in]
+ Set default external and internal encodings.
+ -h --help Print this text and exit.
+ -n Print generated Ruby source code with line numbers;
+ ignored if given without option -x.
+ -P Disable execution tag shorthand (for lines beginning with '%').
+ -r library Load the named library.
+ -T trim_mode Specify trim_mode:
+ '0' means '%'; '1' means '%>'; '2' means '<>'; '-' means '%-'.
+ -U Set default encoding to UTF-8.
+ -v Set $VERBOSE to enable debugging,
+ --version Print ERB version string and exit.
+ -x Print generated Ruby source code.
+ -- Treat all following words as filepaths (not options).
+ name=value Set the variable named name to the given string value.
+
+Filepaths:
+ The erb program reads the text from all files at the filepaths as a single ERB template:
+ plain text, possibly with embedded ERB tags;
+ filepaths may be repeated.
+
+ The pseudo-filepath '-' (hyphen character) specifies the standard input.
+
+ If no filepaths are given, the sole input is the standard input.
+
+See details and examples at https://docs.ruby-lang.org/en/master/erb_executable_md.html
EOU
exit 1
end
diff --git a/libexec/irb b/libexec/irb
deleted file mode 100755
index 12f41e4f0a..0000000000
--- a/libexec/irb
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env ruby
-#
-# irb.rb - interactive ruby
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require "irb"
-
-IRB.start(__FILE__)
diff --git a/libexec/racc b/libexec/racc
deleted file mode 100755
index 4507d04962..0000000000
--- a/libexec/racc
+++ /dev/null
@@ -1,320 +0,0 @@
-#!/usr/bin/env ruby
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-
-require 'racc/static'
-require 'optparse'
-
-def main
- output = nil
- debug_parser = false
- make_logfile = false
- logfilename = nil
- make_executable = false
- rubypath = nil
- embed_runtime = false
- debug_flags = Racc::DebugFlags.new
- line_convert = true
- line_convert_all = false
- omit_action_call = true
- superclass = nil
- check_only = false
- verbose = false
- profiler = RaccProfiler.new(false)
-
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [options] <input>"
- parser.on('-o', '--output-file=PATH',
- 'output file name [<input>.tab.rb]') {|name|
- output = name
- }
- parser.on('-t', '--debug', 'Outputs debugging parser.') {|fl|
- debug_parser = fl
- }
- parser.on('-g', 'Equivalent to -t (obsolete).') {|fl|
- $stderr.puts "racc -g is obsolete. Use racc -t instead." if $VERBOSE
- debug_parser = fl
- }
- parser.on('-v', '--verbose',
- 'Creates <filename>.output log file.') {|fl|
- make_logfile = fl
- }
- parser.on('-O', '--log-file=PATH',
- 'Log file name [<input>.output]') {|path|
- make_logfile = true
- logfilename = path
- }
- parser.on('-e', '--executable [RUBYPATH]', 'Makes executable parser.') {|path|
- make_executable = true
- rubypath = (path == 'ruby' ? nil : path)
- }
- parser.on('-E', '--embedded', "Embeds Racc runtime in output.") {
- embed_runtime = true
- }
- parser.on('--line-convert-all', 'Converts line numbers of user codes.') {
- line_convert_all = true
- }
- parser.on('-l', '--no-line-convert', 'Never convert line numbers.') {
- line_convert = false
- line_convert_all = false
- }
- parser.on('-a', '--no-omit-actions', 'Never omit actions.') {
- omit_action_call = false
- }
- parser.on('--superclass=CLASSNAME',
- 'Uses CLASSNAME instead of Racc::Parser.') {|name|
- superclass = name
- }
- parser.on('-C', '--check-only', 'Checks syntax and quit immediately.') {|fl|
- check_only = fl
- }
- parser.on('-S', '--output-status', 'Outputs internal status time to time.') {
- verbose = true
- }
- parser.on('-P', 'Enables generator profile') {
- profiler = RaccProfiler.new(true)
- }
- parser.on('-D flags', "Flags for Racc debugging (do not use).") {|flags|
- debug_flags = Racc::DebugFlags.parse_option_string(flags)
- }
- #parser.on('--no-extensions', 'Run Racc without any Ruby extension.') {
- # Racc.const_set :Racc_No_Extensions, true
- #}
- parser.on('--version', 'Prints version and quit.') {
- puts "racc version #{Racc::Version}"
- exit 0
- }
- parser.on('--runtime-version', 'Prints runtime version and quit.') {
- printf "racc runtime version %s; %s\n",
- Racc::Parser::Racc_Runtime_Version,
- if Racc::Parser.racc_runtime_type == 'ruby'
- sprintf('ruby core version %s',
- Racc::Parser::Racc_Runtime_Core_Version_R)
- else
- sprintf('c core version %s',
- Racc::Parser::Racc_Runtime_Core_Version_C)
- end
- exit 0
- }
- parser.on('--copyright', 'Prints copyright and quit.') {
- puts Racc::Copyright
- exit 0
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit 1
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit 1
- end
- if ARGV.empty?
- $stderr.puts 'no input'
- exit 1
- end
- if ARGV.size > 1
- $stderr.puts 'too many input'
- exit 1
- end
- input = ARGV[0]
-
- begin
- $stderr.puts 'Parsing grammar file...' if verbose
- result = profiler.section('parse') {
- parser = Racc::GrammarFileParser.new(debug_flags)
- parser.parse(File.read(input), File.basename(input))
- }
- if check_only
- $stderr.puts 'syntax ok'
- exit 0
- end
-
- $stderr.puts 'Generating LALR states...' if verbose
- states = profiler.section('nfa') {
- Racc::States.new(result.grammar).nfa
- }
-
- $stderr.puts "Resolving #{states.size} states..." if verbose
- profiler.section('dfa') {
- states.dfa
- }
-
- $stderr.puts 'Creating parser file...' if verbose
- params = result.params.dup
- # Overwrites parameters given by a grammar file with command line options.
- params.superclass = superclass if superclass
- params.omit_action_call = true if omit_action_call
- # From command line option
- if make_executable
- params.make_executable = true
- params.interpreter = rubypath
- end
- params.debug_parser = debug_parser
- params.convert_line = line_convert
- params.convert_line_all = line_convert_all
- params.embed_runtime = embed_runtime
- profiler.section('generation') {
- generator = Racc::ParserFileGenerator.new(states, params)
- generator.generate_parser_file(output || make_filename(input, '.tab.rb'))
- }
-
- if make_logfile
- profiler.section('logging') {
- $stderr.puts 'Creating log file...' if verbose
- logfilename ||= make_filename(output || File.basename(input), '.output')
- File.open(logfilename, 'w') {|f|
- Racc::LogFileGenerator.new(states, debug_flags).output f
- }
- }
- end
- if debug_flags.status_logging
- log_useless states.grammar
- log_conflict states
- else
- has_useless = report_useless states.grammar
- has_conflicts = report_conflict states
- if has_useless || has_conflicts
- preamble = make_logfile ? 'C' : 'Turn on logging with "-v" and c'
- $stderr.puts %Q{#{preamble}heck ".output" file for details}
- end
- end
-
- profiler.report
- rescue Racc::Error, Errno::ENOENT, Errno::EPERM => err
- raise if $DEBUG or debug_flags.any?
- lineno = err.message.slice(/\A\d+:/).to_s
- $stderr.puts "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}"
- exit 1
- end
-end
-
-def make_filename(path, suffix)
- path.sub(/(?:\..*?)?\z/, suffix)
-end
-
-LIST_LIMIT = 10
-def report_list(enum, label)
- c = enum.count
- if c > 0
- $stderr.puts "#{c} #{label}:"
- enum.first(LIST_LIMIT).each do |item|
- $stderr.puts " #{yield item}"
- end
- $stderr.puts " ..." if c > LIST_LIMIT
- end
-end
-
-# @return [Boolean] if anything was reported
-def report_conflict(states)
- if states.should_report_srconflict?
- reported = true
- $stderr.puts "#{states.n_srconflicts} shift/reduce conflicts"
- end
- if states.rrconflict_exist?
- reported = true
- $stderr.puts "#{states.n_rrconflicts} reduce/reduce conflicts"
- end
- reported
-end
-
-def log_conflict(states)
- logging('w') {|f|
- f.puts "ex#{states.grammar.n_expected_srconflicts}"
- if states.should_report_srconflict?
- f.puts "sr#{states.n_srconflicts}"
- end
- if states.rrconflict_exist?
- f.puts "rr#{states.n_rrconflicts}"
- end
- }
-end
-
-# @return [Boolean] if anything was reported
-def report_useless(grammar)
- reported = report_list(grammar.each_useless_nonterminal, 'useless nonterminals', &:to_s)
-
- reported ||= report_list(grammar.each_useless_rule, 'useless rules') { |r| "##{r.ident} (#{r.target})" }
-
- if grammar.start.useless?
- $stderr.puts 'fatal: start symbol does not derive any sentence'
- reported = true
- end
- reported
-end
-
-def log_useless(grammar)
- logging('a') {|f|
- if grammar.useless_nonterminal_exist?
- f.puts "un#{grammar.n_useless_nonterminals}"
- end
- if grammar.useless_rule_exist?
- f.puts "ur#{grammar.n_useless_rules}"
- end
- }
-end
-
-def logging(mode, &block)
- File.open("log/#{File.basename(ARGV[0])}", mode, &block)
-end
-
-class RaccProfiler
- def initialize(really)
- @really = really
- @log = []
- unless ::Process.respond_to?(:times)
- # Ruby 1.6
- @class = ::Time
- else
- @class = ::Process
- end
- end
-
- def section(name)
- if @really
- t1 = @class.times.utime
- result = yield
- t2 = @class.times.utime
- @log.push [name, t2 - t1]
- result
- else
- yield
- end
- end
-
- def report
- return unless @really
- f = $stderr
- total = cumulative_time()
- f.puts '--task-----------+--sec------+---%-'
- @log.each do |name, time|
- f.printf "%-19s %s %3d%%\n", name, pjust(time,4,4), (time/total*100).to_i
- end
- f.puts '-----------------+-----------+-----'
- f.printf "%-20s%s\n", 'total', pjust(total,4,4)
- end
-
- private
-
- def cumulative_time
- t = @log.inject(0) {|sum, (name, time)| sum + time }
- t == 0 ? 0.01 : t
- end
-
- def pjust(num, i, j)
- m = /(\d+)(\.\d+)?/.match(num.to_s)
- str = m[1].rjust(i)
- str.concat m[2].ljust(j+1)[0,j+1] if m[2]
- str
- end
-end
-
-main
diff --git a/libexec/rdoc b/libexec/rdoc
deleted file mode 100755
index 95b6eea277..0000000000
--- a/libexec/rdoc
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env ruby
-#
-# RDoc: Documentation tool for source code
-# (see lib/rdoc/rdoc.rb for more information)
-#
-# Copyright (c) 2003 Dave Thomas
-# Released under the same terms as Ruby
-
-begin
- gem 'rdoc'
-rescue NameError => e # --disable-gems
- raise unless e.name == :gem
-rescue Gem::LoadError
-end
-
-require 'rdoc/rdoc'
-
-begin
- r = RDoc::RDoc.new
- r.document ARGV
-rescue Errno::ENOSPC
- $stderr.puts 'Ran out of space creating documentation'
- $stderr.puts
- $stderr.puts 'Please free up some space and try again'
-rescue SystemExit
- raise
-rescue Exception => e
- if $DEBUG_RDOC then
- $stderr.puts e.message
- $stderr.puts "#{e.backtrace.join "\n\t"}"
- $stderr.puts
- elsif Interrupt === e then
- $stderr.puts
- $stderr.puts 'Interrupted'
- else
- $stderr.puts "uh-oh! RDoc had a problem:"
- $stderr.puts e.message
- $stderr.puts
- $stderr.puts "run with --debug for full backtrace"
- end
-
- exit 1
-end
diff --git a/libexec/ri b/libexec/ri
deleted file mode 100755
index 7fbed0c099..0000000000
--- a/libexec/ri
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env ruby
-
-begin
- gem 'rdoc'
-rescue NameError => e # --disable-gems
- raise unless e.name == :gem
-rescue Gem::LoadError
-end
-
-require 'rdoc/ri/driver'
-
-RDoc::RI::Driver.run ARGV
diff --git a/libexec/syntax_suggest b/libexec/syntax_suggest
index e4a0b0b658..3dc8eb94d1 100755
--- a/libexec/syntax_suggest
+++ b/libexec/syntax_suggest
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require_relative "../lib/syntax_suggest/api"
+require "syntax_suggest/api"
SyntaxSuggest::Cli.new(
argv: ARGV
diff --git a/load.c b/load.c
index 0f8d63a37f..1ee66e2bfc 100644
--- a/load.c
+++ b/load.c
@@ -5,11 +5,14 @@
#include "dln.h"
#include "eval_intern.h"
#include "internal.h"
+#include "internal/box.h"
#include "internal/dir.h"
#include "internal/error.h"
+#include "internal/eval.h"
#include "internal/file.h"
+#include "internal/hash.h"
#include "internal/load.h"
-#include "internal/parse.h"
+#include "internal/ruby_parser.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
@@ -17,13 +20,18 @@
#include "darray.h"
#include "ruby/encoding.h"
#include "ruby/util.h"
-
-static VALUE ruby_dln_librefs;
+#include "ractor_core.h"
+#include "vm_core.h"
#define IS_RBEXT(e) (strcmp((e), ".rb") == 0)
#define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
#define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
+enum {
+ loadable_ext_rb = (0+ /* .rb extension is the first in both tables */
+ 1) /* offset by rb_find_file_ext() */
+};
+
static const char *const loadable_ext[] = {
".rb", DLEXT,
0
@@ -47,10 +55,11 @@ enum expand_type {
string objects in $LOAD_PATH are frozen.
*/
static void
-rb_construct_expanded_load_path(rb_vm_t *vm, enum expand_type type, int *has_relative, int *has_non_cache)
+rb_construct_expanded_load_path(rb_box_t *box, enum expand_type type, int *has_relative, int *has_non_cache)
{
- VALUE load_path = vm->load_path;
- VALUE expanded_load_path = vm->expanded_load_path;
+ VALUE load_path = box->load_path;
+ VALUE expanded_load_path = box->expanded_load_path;
+ VALUE snapshot;
VALUE ary;
long i;
@@ -88,103 +97,91 @@ rb_construct_expanded_load_path(rb_vm_t *vm, enum expand_type type, int *has_rel
if (NIL_P(expanded_path)) expanded_path = as_str;
rb_ary_push(ary, rb_fstring(expanded_path));
}
- rb_obj_freeze(ary);
- vm->expanded_load_path = ary;
- rb_ary_replace(vm->load_path_snapshot, vm->load_path);
+ rb_ary_freeze(ary);
+ box->expanded_load_path = ary;
+ snapshot = box->load_path_snapshot;
+ load_path = box->load_path;
+ rb_ary_replace(snapshot, load_path);
}
static VALUE
-get_expanded_load_path(rb_vm_t *vm)
+get_expanded_load_path(rb_box_t *box)
{
+ VALUE check_cache;
const VALUE non_cache = Qtrue;
+ const VALUE load_path_snapshot = box->load_path_snapshot;
+ const VALUE load_path = box->load_path;
- if (!rb_ary_shared_with_p(vm->load_path_snapshot, vm->load_path)) {
+ if (!rb_ary_shared_with_p(load_path_snapshot, load_path)) {
/* The load path was modified. Rebuild the expanded load path. */
int has_relative = 0, has_non_cache = 0;
- rb_construct_expanded_load_path(vm, EXPAND_ALL, &has_relative, &has_non_cache);
+ rb_construct_expanded_load_path(box, EXPAND_ALL, &has_relative, &has_non_cache);
if (has_relative) {
- vm->load_path_check_cache = rb_dir_getwd_ospath();
+ box->load_path_check_cache = rb_dir_getwd_ospath();
}
else if (has_non_cache) {
/* Non string object. */
- vm->load_path_check_cache = non_cache;
+ box->load_path_check_cache = non_cache;
}
else {
- vm->load_path_check_cache = 0;
+ box->load_path_check_cache = 0;
}
}
- else if (vm->load_path_check_cache == non_cache) {
+ else if ((check_cache = box->load_path_check_cache) == non_cache) {
int has_relative = 1, has_non_cache = 1;
/* Expand only non-cacheable objects. */
- rb_construct_expanded_load_path(vm, EXPAND_NON_CACHE,
+ rb_construct_expanded_load_path(box, EXPAND_NON_CACHE,
&has_relative, &has_non_cache);
}
- else if (vm->load_path_check_cache) {
+ else if (check_cache) {
int has_relative = 1, has_non_cache = 1;
VALUE cwd = rb_dir_getwd_ospath();
- if (!rb_str_equal(vm->load_path_check_cache, cwd)) {
+ if (!rb_str_equal(check_cache, cwd)) {
/* Current working directory or filesystem encoding was changed.
Expand relative load path and non-cacheable objects again. */
- vm->load_path_check_cache = cwd;
- rb_construct_expanded_load_path(vm, EXPAND_RELATIVE,
+ box->load_path_check_cache = cwd;
+ rb_construct_expanded_load_path(box, EXPAND_RELATIVE,
&has_relative, &has_non_cache);
}
else {
/* Expand only tilde (User HOME) and non-cacheable objects. */
- rb_construct_expanded_load_path(vm, EXPAND_HOME,
+ rb_construct_expanded_load_path(box, EXPAND_HOME,
&has_relative, &has_non_cache);
}
}
- return vm->expanded_load_path;
+ return box->expanded_load_path;
}
VALUE
rb_get_expanded_load_path(void)
{
- return get_expanded_load_path(GET_VM());
-}
-
-static VALUE
-load_path_getter(ID id, VALUE * p)
-{
- rb_vm_t *vm = (void *)p;
- return vm->load_path;
-}
-
-static VALUE
-get_loaded_features(rb_vm_t *vm)
-{
- return vm->loaded_features;
+ return get_expanded_load_path((rb_box_t *)rb_loading_box());
}
static VALUE
-get_loaded_features_realpaths(rb_vm_t *vm)
+load_path_getter(ID _x, VALUE * _y)
{
- return vm->loaded_features_realpaths;
+ return rb_loading_box()->load_path;
}
static VALUE
get_LOADED_FEATURES(ID _x, VALUE *_y)
{
- return get_loaded_features(GET_VM());
+ return rb_loading_box()->loaded_features;
}
static void
-reset_loaded_features_snapshot(rb_vm_t *vm)
+reset_loaded_features_snapshot(const rb_box_t *box)
{
- rb_ary_replace(vm->loaded_features_snapshot, vm->loaded_features);
+ VALUE snapshot = box->loaded_features_snapshot;
+ VALUE loaded_features = box->loaded_features;
+ rb_ary_replace(snapshot, loaded_features);
}
static struct st_table *
-get_loaded_features_index_raw(rb_vm_t *vm)
-{
- return vm->loaded_features_index;
-}
-
-static st_table *
-get_loading_table(rb_vm_t *vm)
+get_loaded_features_index_raw(const rb_box_t *box)
{
- return vm->loading_table;
+ return box->loaded_features_index;
}
static st_data_t
@@ -205,7 +202,7 @@ is_rbext_path(VALUE feature_path)
typedef rb_darray(long) feature_indexes_t;
struct features_index_add_single_args {
- rb_vm_t *vm;
+ const rb_box_t *box;
VALUE offset;
bool rb;
};
@@ -214,7 +211,7 @@ static int
features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t raw_args, int existing)
{
struct features_index_add_single_args *args = (struct features_index_add_single_args *)raw_args;
- rb_vm_t *vm = args->vm;
+ const rb_box_t *box = args->box;
VALUE offset = args->offset;
bool rb = args->rb;
@@ -222,7 +219,7 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
VALUE this_feature_index = *value;
if (FIXNUM_P(this_feature_index)) {
- VALUE loaded_features = get_loaded_features(vm);
+ VALUE loaded_features = box->loaded_features;
VALUE this_feature_path = RARRAY_AREF(loaded_features, FIX2LONG(this_feature_index));
feature_indexes_t feature_indexes;
@@ -231,9 +228,9 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
rb_darray_set(feature_indexes, top^0, FIX2LONG(this_feature_index));
rb_darray_set(feature_indexes, top^1, FIX2LONG(offset));
- assert(rb_darray_size(feature_indexes) == 2);
+ RUBY_ASSERT(rb_darray_size(feature_indexes) == 2);
// assert feature_indexes does not look like a special const
- assert(!SPECIAL_CONST_P((VALUE)feature_indexes));
+ RUBY_ASSERT(!SPECIAL_CONST_P((VALUE)feature_indexes));
*value = (st_data_t)feature_indexes;
}
@@ -242,7 +239,7 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
long pos = -1;
if (rb) {
- VALUE loaded_features = get_loaded_features(vm);
+ VALUE loaded_features = box->loaded_features;
for (size_t i = 0; i < rb_darray_size(feature_indexes); ++i) {
long idx = rb_darray_get(feature_indexes, i);
VALUE this_feature_path = RARRAY_AREF(loaded_features, idx);
@@ -261,7 +258,7 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
if (pos >= 0) {
long *ptr = rb_darray_data_ptr(feature_indexes);
long len = rb_darray_size(feature_indexes);
- MEMMOVE(ptr + pos, ptr + pos + 1, long, len - pos - 1);
+ MEMMOVE(ptr + pos + 1, ptr + pos, long, len - pos - 1);
ptr[pos] = FIX2LONG(offset);
}
}
@@ -274,7 +271,7 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
}
static void
-features_index_add_single(rb_vm_t *vm, const char* str, size_t len, VALUE offset, bool rb)
+features_index_add_single(const rb_box_t *box, const char* str, size_t len, VALUE offset, bool rb)
{
struct st_table *features_index;
st_data_t short_feature_key;
@@ -282,10 +279,10 @@ features_index_add_single(rb_vm_t *vm, const char* str, size_t len, VALUE offset
Check_Type(offset, T_FIXNUM);
short_feature_key = feature_key(str, len);
- features_index = get_loaded_features_index_raw(vm);
+ features_index = get_loaded_features_index_raw(box);
struct features_index_add_single_args args = {
- .vm = vm,
+ .box = box,
.offset = offset,
.rb = rb,
};
@@ -302,8 +299,10 @@ features_index_add_single(rb_vm_t *vm, const char* str, size_t len, VALUE offset
relies on for its fast lookup.
*/
static void
-features_index_add(rb_vm_t *vm, VALUE feature, VALUE offset)
+features_index_add(const rb_box_t *box, VALUE feature, VALUE offset)
{
+ RUBY_ASSERT(rb_ractor_main_p());
+
const char *feature_str, *feature_end, *ext, *p;
bool rb = false;
@@ -328,14 +327,14 @@ features_index_add(rb_vm_t *vm, VALUE feature, VALUE offset)
if (p < feature_str)
break;
/* Now *p == '/'. We reach this point for every '/' in `feature`. */
- features_index_add_single(vm, p + 1, feature_end - p - 1, offset, false);
+ features_index_add_single(box, p + 1, feature_end - p - 1, offset, false);
if (ext) {
- features_index_add_single(vm, p + 1, ext - p - 1, offset, rb);
+ features_index_add_single(box, p + 1, ext - p - 1, offset, rb);
}
}
- features_index_add_single(vm, feature_str, feature_end - feature_str, offset, false);
+ features_index_add_single(box, feature_str, feature_end - feature_str, offset, false);
if (ext) {
- features_index_add_single(vm, feature_str, ext - feature_str, offset, rb);
+ features_index_add_single(box, feature_str, ext - feature_str, offset, rb);
}
}
@@ -344,25 +343,33 @@ loaded_features_index_clear_i(st_data_t key, st_data_t val, st_data_t arg)
{
VALUE obj = (VALUE)val;
if (!SPECIAL_CONST_P(obj)) {
- rb_darray_free((void *)obj);
+ rb_darray_free_sized((void *)obj, long);
}
return ST_DELETE;
}
static st_table *
-get_loaded_features_index(rb_vm_t *vm)
+get_loaded_features_index(const rb_box_t *box)
{
- VALUE features;
int i;
+ VALUE features = box->loaded_features;
+ const VALUE snapshot = box->loaded_features_snapshot;
- if (!rb_ary_shared_with_p(vm->loaded_features_snapshot, vm->loaded_features)) {
+ if (!rb_ary_shared_with_p(snapshot, features)) {
/* The sharing was broken; something (other than us in rb_provide_feature())
modified loaded_features. Rebuild the index. */
- st_foreach(vm->loaded_features_index, loaded_features_index_clear_i, 0);
+ st_foreach(box->loaded_features_index, loaded_features_index_clear_i, 0);
- VALUE realpaths = vm->loaded_features_realpaths;
+ VALUE realpaths = box->loaded_features_realpaths;
+ VALUE realpath_map = box->loaded_features_realpath_map;
+ VALUE previous_realpath_map = rb_hash_dup(realpath_map);
rb_hash_clear(realpaths);
- features = vm->loaded_features;
+ rb_hash_clear(realpath_map);
+
+ /* We have to make a copy of features here because the StringValue call
+ * below could call a Ruby method, which could modify $LOADED_FEATURES
+ * and cause it to be corrupt. */
+ features = rb_ary_resurrect(features);
for (i = 0; i < RARRAY_LEN(features); i++) {
VALUE entry, as_str;
as_str = entry = rb_ary_entry(features, i);
@@ -370,20 +377,29 @@ get_loaded_features_index(rb_vm_t *vm)
as_str = rb_fstring(as_str);
if (as_str != entry)
rb_ary_store(features, i, as_str);
- features_index_add(vm, as_str, INT2FIX(i));
+ features_index_add(box, as_str, INT2FIX(i));
}
- reset_loaded_features_snapshot(vm);
+ /* The user modified $LOADED_FEATURES, so we should restore the changes. */
+ if (!rb_ary_shared_with_p(features, box->loaded_features)) {
+ rb_ary_replace(box->loaded_features, features);
+ }
+ reset_loaded_features_snapshot(box);
- features = rb_ary_dup(vm->loaded_features_snapshot);
+ features = box->loaded_features_snapshot;
long j = RARRAY_LEN(features);
for (i = 0; i < j; i++) {
VALUE as_str = rb_ary_entry(features, i);
- VALUE realpath = rb_check_realpath(Qnil, as_str, NULL);
- if (NIL_P(realpath)) realpath = as_str;
- rb_hash_aset(realpaths, rb_fstring(realpath), Qtrue);
+ VALUE realpath = rb_hash_aref(previous_realpath_map, as_str);
+ if (NIL_P(realpath)) {
+ realpath = rb_check_realpath(Qnil, as_str, NULL);
+ if (NIL_P(realpath)) realpath = as_str;
+ realpath = rb_fstring(realpath);
+ }
+ rb_hash_aset(realpaths, realpath, Qtrue);
+ rb_hash_aset(realpath_map, as_str, realpath);
}
}
- return vm->loaded_features_index;
+ return box->loaded_features_index;
}
/* This searches `load_path` for a value such that
@@ -461,8 +477,14 @@ loaded_feature_path_i(st_data_t v, st_data_t b, st_data_t f)
return ST_STOP;
}
+/*
+ * Returns the type of already provided feature.
+ * 'r': ruby script (".rb")
+ * 's': shared object (".so"/"."DLEXT)
+ * 'u': unsuffixed
+ */
static int
-rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expanded, const char **fn)
+rb_feature_p(const rb_box_t *box, const char *feature, const char *ext, int rb, int expanded, const char **fn)
{
VALUE features, this_feature_index = Qnil, v, p, load_path = 0;
const char *f, *e;
@@ -483,8 +505,8 @@ rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expa
elen = 0;
type = 0;
}
- features = get_loaded_features(vm);
- features_index = get_loaded_features_index(vm);
+ features = box->loaded_features;
+ features_index = get_loaded_features_index(box);
key = feature_key(feature, strlen(feature));
/* We search `features` for an entry such that either
@@ -526,12 +548,13 @@ rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expa
index = rb_darray_get(feature_indexes, i);
}
+ if (index >= RARRAY_LEN(features)) continue;
v = RARRAY_AREF(features, index);
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_expanded_load_path(vm);
+ if (!load_path) load_path = get_expanded_load_path((rb_box_t *)box);
if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
continue;
expanded = 1;
@@ -551,14 +574,14 @@ rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expa
}
}
- loading_tbl = get_loading_table(vm);
+ loading_tbl = box->loading_table;
f = 0;
- if (!expanded) {
+ if (!expanded && !rb_is_absolute_path(feature)) {
struct loaded_feature_searching fs;
fs.name = feature;
fs.len = len;
fs.type = type;
- fs.load_path = load_path ? load_path : get_expanded_load_path(vm);
+ fs.load_path = load_path ? load_path : get_expanded_load_path((rb_box_t *)box);
fs.result = 0;
st_foreach(loading_tbl, loaded_feature_path_i, (st_data_t)&fs);
if ((f = fs.result) != 0) {
@@ -613,7 +636,7 @@ rb_provided(const char *feature)
}
static int
-feature_provided(rb_vm_t *vm, const char *feature, const char **loading)
+feature_provided(rb_box_t *box, const char *feature, const char **loading)
{
const char *ext = strrchr(feature, '.');
VALUE fullpath = 0;
@@ -625,15 +648,15 @@ feature_provided(rb_vm_t *vm, const char *feature, const char **loading)
}
if (ext && !strchr(ext, '/')) {
if (IS_RBEXT(ext)) {
- if (rb_feature_p(vm, feature, ext, TRUE, FALSE, loading)) return TRUE;
+ if (rb_feature_p(box, feature, ext, TRUE, FALSE, loading)) return TRUE;
return FALSE;
}
else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
- if (rb_feature_p(vm, feature, ext, FALSE, FALSE, loading)) return TRUE;
+ if (rb_feature_p(box, feature, ext, FALSE, FALSE, loading)) return TRUE;
return FALSE;
}
}
- if (rb_feature_p(vm, feature, 0, TRUE, FALSE, loading))
+ if (rb_feature_p(box, feature, 0, TRUE, FALSE, loading))
return TRUE;
RB_GC_GUARD(fullpath);
return FALSE;
@@ -642,65 +665,120 @@ feature_provided(rb_vm_t *vm, const char *feature, const char **loading)
int
rb_feature_provided(const char *feature, const char **loading)
{
- return feature_provided(GET_VM(), feature, loading);
+ rb_box_t *box = (rb_box_t *)rb_current_box();
+ return feature_provided(box, feature, loading);
}
static void
-rb_provide_feature(rb_vm_t *vm, VALUE feature)
+rb_provide_feature(const rb_box_t *box, VALUE feature)
{
VALUE features;
- features = get_loaded_features(vm);
+ features = box->loaded_features;
if (OBJ_FROZEN(features)) {
rb_raise(rb_eRuntimeError,
"$LOADED_FEATURES is frozen; cannot append feature");
}
feature = rb_fstring(feature);
- get_loaded_features_index(vm);
+ get_loaded_features_index(box);
// If loaded_features and loaded_features_snapshot share the same backing
// array, pushing into it would cause the whole array to be copied.
// To avoid this we first clear loaded_features_snapshot.
- rb_ary_clear(vm->loaded_features_snapshot);
+ rb_ary_clear(box->loaded_features_snapshot);
rb_ary_push(features, feature);
- features_index_add(vm, feature, INT2FIX(RARRAY_LEN(features)-1));
- reset_loaded_features_snapshot(vm);
+ features_index_add(box, feature, INT2FIX(RARRAY_LEN(features)-1));
+ reset_loaded_features_snapshot(box);
}
void
rb_provide(const char *feature)
{
- rb_provide_feature(GET_VM(), rb_fstring_cstr(feature));
+ /*
+ * rb_provide() must use rb_current_box to store provided features
+ * in the current box's loaded_features, etc.
+ */
+ rb_provide_feature(rb_current_box(), rb_fstring_cstr(feature));
}
NORETURN(static void load_failed(VALUE));
+static inline VALUE
+realpath_internal_cached(VALUE hash, VALUE path)
+{
+ VALUE ret = rb_hash_aref(hash, path);
+ if(RTEST(ret)) {
+ return ret;
+ }
+
+ VALUE realpath = rb_realpath_internal(Qnil, path, 1);
+ rb_hash_aset(hash, rb_fstring(path), rb_fstring(realpath));
+ return realpath;
+}
+
static inline void
load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
{
+ const rb_box_t *box = rb_loading_box();
const rb_iseq_t *iseq = rb_iseq_load_iseq(fname);
if (!iseq) {
rb_execution_context_t *ec = GET_EC();
VALUE v = rb_vm_push_frame_fname(ec, fname);
- rb_ast_t *ast;
- VALUE parser = rb_parser_new();
- rb_parser_set_context(parser, NULL, FALSE);
- ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
- iseq = rb_iseq_new_top(&ast->body, rb_fstring_lit("<top (required)>"),
- fname, rb_realpath_internal(Qnil, fname, 1), NULL);
- rb_ast_dispose(ast);
+
+ VALUE realpath_map = box->loaded_features_realpath_map;
+
+ if (rb_ruby_prism_p()) {
+ pm_parse_result_t result;
+ pm_parse_result_init(&result);
+ result.node.coverage_enabled = 1;
+
+ VALUE error = pm_load_parse_file(&result, fname, NULL);
+
+ if (error == Qnil) {
+ int error_state;
+ iseq = pm_iseq_new_top(&result.node, rb_fstring_lit("<top (required)>"), fname, realpath_internal_cached(realpath_map, fname), NULL, &error_state);
+
+ pm_parse_result_free(&result);
+
+ if (error_state) {
+ RUBY_ASSERT(iseq == NULL);
+ rb_jump_tag(error_state);
+ }
+ }
+ else {
+ rb_vm_pop_frame(ec);
+ RB_GC_GUARD(v);
+ pm_parse_result_free(&result);
+ rb_exc_raise(error);
+ }
+ }
+ else {
+ rb_ast_t *ast;
+ VALUE ast_value;
+ VALUE parser = rb_parser_new();
+ rb_parser_set_context(parser, NULL, FALSE);
+ ast_value = rb_parser_load_file(parser, fname);
+ ast = rb_ruby_ast_data_get(ast_value);
+
+ iseq = rb_iseq_new_top(ast_value, rb_fstring_lit("<top (required)>"),
+ fname, realpath_internal_cached(realpath_map, fname), NULL);
+ rb_ast_dispose(ast);
+ }
+
rb_vm_pop_frame(ec);
RB_GC_GUARD(v);
}
rb_exec_event_hook_script_compiled(ec, iseq, Qnil);
- rb_iseq_eval(iseq);
+
+ rb_iseq_eval(iseq, box);
}
static inline enum ruby_tag_type
load_wrapping(rb_execution_context_t *ec, VALUE fname, VALUE load_wrapper)
{
enum ruby_tag_type state;
+ rb_box_t *box;
rb_thread_t *th = rb_ec_thread_ptr(ec);
volatile VALUE wrapper = th->top_wrapper;
volatile VALUE self = th->top_self;
@@ -711,7 +789,16 @@ load_wrapping(rb_execution_context_t *ec, VALUE fname, VALUE load_wrapper)
ec->errinfo = Qnil; /* ensure */
/* load in module as toplevel */
- th->top_self = rb_obj_clone(rb_vm_top_self());
+ if (BOX_OBJ_P(load_wrapper)) {
+ box = rb_get_box_t(load_wrapper);
+ if (!box->top_self) {
+ box->top_self = rb_obj_clone(rb_vm_top_self());
+ }
+ th->top_self = box->top_self;
+ }
+ else {
+ th->top_self = rb_obj_clone(rb_vm_top_self());
+ }
th->top_wrapper = load_wrapper;
rb_extend_object(th->top_self, th->top_wrapper);
@@ -746,7 +833,9 @@ raise_load_if_failed(rb_execution_context_t *ec, enum ruby_tag_type state)
static void
rb_load_internal(VALUE fname, VALUE wrap)
{
+ VALUE box_value;
rb_execution_context_t *ec = GET_EC();
+ const rb_box_t *box = rb_loading_box();
enum ruby_tag_type state = TAG_NONE;
if (RTEST(wrap)) {
if (!RB_TYPE_P(wrap, T_MODULE)) {
@@ -754,6 +843,10 @@ rb_load_internal(VALUE fname, VALUE wrap)
}
state = load_wrapping(ec, fname, wrap);
}
+ else if (BOX_OPTIONAL_P(box)) {
+ box_value = box->box_object;
+ state = load_wrapping(ec, fname, box_value);
+ }
else {
load_iseq_eval(ec, fname);
}
@@ -782,6 +875,28 @@ rb_load_protect(VALUE fname, int wrap, int *pstate)
if (state != TAG_NONE) *pstate = state;
}
+VALUE
+rb_load_entrypoint(VALUE fname, VALUE wrap)
+{
+ VALUE path, orig_fname;
+
+ orig_fname = rb_get_path_check_to_string(fname);
+ fname = rb_str_encode_ospath(orig_fname);
+ RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname));
+
+ path = rb_find_file(fname);
+ if (!path) {
+ if (!rb_file_load_ok(RSTRING_PTR(fname)))
+ load_failed(orig_fname);
+ path = fname;
+ }
+ rb_load_internal(path, wrap);
+
+ RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname));
+
+ return Qtrue;
+}
+
/*
* call-seq:
* load(filename, wrap=false) -> true
@@ -806,9 +921,8 @@ rb_load_protect(VALUE fname, int wrap, int *pstate)
* LoadError will be raised.
*
* If the optional _wrap_ parameter is +true+, the loaded script will
- * be executed under an anonymous module, protecting the calling
- * program's global namespace. If the optional _wrap_ parameter is a
- * module, the loaded script will be executed under the given module.
+ * be executed under an anonymous module. If the optional _wrap_ parameter
+ * is a module, the loaded script will be executed under the given module.
* In no circumstance will any local variables in the loaded file be
* propagated to the loading environment.
*/
@@ -816,32 +930,16 @@ rb_load_protect(VALUE fname, int wrap, int *pstate)
static VALUE
rb_f_load(int argc, VALUE *argv, VALUE _)
{
- VALUE fname, wrap, path, orig_fname;
-
+ VALUE fname, wrap;
rb_scan_args(argc, argv, "11", &fname, &wrap);
-
- orig_fname = rb_get_path_check_to_string(fname);
- fname = rb_str_encode_ospath(orig_fname);
- RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname));
-
- path = rb_find_file(fname);
- if (!path) {
- if (!rb_file_load_ok(RSTRING_PTR(fname)))
- load_failed(orig_fname);
- path = fname;
- }
- rb_load_internal(path, wrap);
-
- RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname));
-
- return Qtrue;
+ return rb_load_entrypoint(fname, wrap);
}
static char *
-load_lock(rb_vm_t *vm, const char *ftptr, bool warn)
+load_lock(const rb_box_t *box, const char *ftptr, bool warn)
{
st_data_t data;
- st_table *loading_tbl = get_loading_table(vm);
+ st_table *loading_tbl = box->loading_table;
if (!st_lookup(loading_tbl, (st_data_t)ftptr, &data)) {
/* partial state */
@@ -883,16 +981,17 @@ release_thread_shield(st_data_t *key, st_data_t *value, st_data_t done, int exis
}
static void
-load_unlock(rb_vm_t *vm, const char *ftptr, int done)
+load_unlock(const rb_box_t *box, const char *ftptr, int done)
{
if (ftptr) {
st_data_t key = (st_data_t)ftptr;
- st_table *loading_tbl = get_loading_table(vm);
+ st_table *loading_tbl = box->loading_table;
st_update(loading_tbl, key, release_thread_shield, done);
}
}
+static VALUE rb_require_string_internal(VALUE fname, bool resurrect);
/*
* call-seq:
@@ -907,15 +1006,14 @@ load_unlock(rb_vm_t *vm, const char *ftptr, int done)
* If the filename starts with './' or '../', resolution is based on Dir.pwd.
*
* If the filename has the extension ".rb", it is loaded as a source file; if
- * the extension is ".so", ".o", or ".dll", or the default shared library
- * extension 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 until found. If the file named cannot be found, a LoadError
- * will be raised.
+ * the extension is ".so", ".o", or the default shared library extension 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 until
+ * found. If the file named cannot be found, a LoadError will be raised.
*
- * For Ruby extensions the filename given may use any shared library
- * extension. For example, on Linux the socket extension is "socket.so" and
- * <code>require 'socket.dll'</code> will load the socket extension.
+ * For Ruby extensions the filename given may use ".so" or ".o". For example,
+ * on macOS the socket extension is "socket.bundle" and
+ * <code>require 'socket.so'</code> will load the socket extension.
*
* The absolute path of the loaded file is added to
* <code>$LOADED_FEATURES</code> (<code>$"</code>). A file will not be
@@ -938,6 +1036,17 @@ rb_f_require(VALUE obj, VALUE fname)
return rb_require_string(fname);
}
+VALUE
+rb_require_relative_entrypoint(VALUE fname)
+{
+ VALUE base = rb_current_realfilepath();
+ if (NIL_P(base)) {
+ rb_loaderror("cannot infer basepath");
+ }
+ base = rb_file_dirname(base);
+ return rb_require_string_internal(rb_file_absolute_path(fname, base), false);
+}
+
/*
* call-seq:
* require_relative(string) -> true or false
@@ -950,42 +1059,37 @@ rb_f_require(VALUE obj, VALUE fname)
VALUE
rb_f_require_relative(VALUE obj, VALUE fname)
{
- VALUE base = rb_current_realfilepath();
- if (NIL_P(base)) {
- rb_loaderror("cannot infer basepath");
- }
- base = rb_file_dirname(base);
- return rb_require_string(rb_file_absolute_path(fname, base));
+ return rb_require_relative_entrypoint(fname);
}
-typedef int (*feature_func)(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expanded, const char **fn);
+typedef int (*feature_func)(const rb_box_t *box, const char *feature, const char *ext, int rb, int expanded, const char **fn);
static int
-search_required(rb_vm_t *vm, VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
+search_required(const rb_box_t *box, VALUE fname, volatile VALUE *path, feature_func rb_feature_p)
{
VALUE tmp;
char *ext, *ftptr;
- int type, ft = 0;
+ int 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(vm, ftptr, ext, TRUE, FALSE, &loading)) {
+ if (rb_feature_p(box, ftptr, ext, TRUE, FALSE, &loading)) {
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 'r';
}
if ((tmp = rb_find_file(fname)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(vm, ftptr, ext, TRUE, TRUE, &loading) || loading)
+ if (!rb_feature_p(box, ftptr, ext, TRUE, TRUE, &loading) || loading)
*path = tmp;
return 'r';
}
return 0;
}
else if (IS_SOEXT(ext)) {
- if (rb_feature_p(vm, ftptr, ext, FALSE, FALSE, &loading)) {
+ if (rb_feature_p(box, ftptr, ext, FALSE, FALSE, &loading)) {
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 's';
}
@@ -994,66 +1098,72 @@ search_required(rb_vm_t *vm, VALUE fname, volatile VALUE *path, feature_func rb_
OBJ_FREEZE(tmp);
if ((tmp = rb_find_file(tmp)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(vm, ftptr, ext, FALSE, TRUE, &loading) || loading)
+ if (!rb_feature_p(box, ftptr, ext, FALSE, TRUE, &loading) || loading)
*path = tmp;
return 's';
}
}
else if (IS_DLEXT(ext)) {
- if (rb_feature_p(vm, ftptr, ext, FALSE, FALSE, &loading)) {
+ if (rb_feature_p(box, ftptr, ext, FALSE, FALSE, &loading)) {
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 's';
}
if ((tmp = rb_find_file(fname)) != 0) {
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(vm, ftptr, ext, FALSE, TRUE, &loading) || loading)
+ if (!rb_feature_p(box, ftptr, ext, FALSE, TRUE, &loading) || loading)
*path = tmp;
return 's';
}
}
}
- else if ((ft = rb_feature_p(vm, ftptr, 0, FALSE, FALSE, &loading)) == 'r') {
+ else if ((ft = rb_feature_p(box, ftptr, 0, FALSE, FALSE, &loading)) == 'r') {
if (loading) *path = rb_filesystem_str_new_cstr(loading);
return 'r';
}
tmp = fname;
- type = rb_find_file_ext(&tmp, ft == 's' ? ruby_ext : loadable_ext);
-#if EXTSTATIC
- if (!ft && type != 1) { // not already a feature and not found as a dynamic library
- VALUE lookup_name = tmp;
- // Append ".so" if not already present so for example "etc" can find "etc.so".
- // We always register statically linked extensions with a ".so" extension.
- // See encinit.c and extinit.c (generated at build-time).
- if (!ext) {
- lookup_name = rb_str_dup(lookup_name);
- rb_str_cat_cstr(lookup_name, ".so");
- }
- ftptr = RSTRING_PTR(lookup_name);
- if (st_lookup(vm->static_ext_inits, (st_data_t)ftptr, NULL)) {
- *path = rb_filesystem_str_new_cstr(ftptr);
- return 's';
+ const unsigned int type = rb_find_file_ext(&tmp, ft == 's' ? ruby_ext : loadable_ext);
+
+ // Check if it's a statically linked extension when
+ // not already a feature and not found as a dynamic library.
+ if (!ft && type != loadable_ext_rb) {
+ rb_vm_t *vm = GET_VM();
+ if (vm->static_ext_inits.num_entries) {
+ VALUE lookup_name = tmp;
+ // Append ".so" if not already present so for example "etc" can find "etc.so".
+ // We always register statically linked extensions with a ".so" extension.
+ // See encinit.c and extinit.c (generated at build-time).
+ if (!ext) {
+ lookup_name = rb_str_dup(lookup_name);
+ rb_str_cat_cstr(lookup_name, ".so");
+ }
+ ftptr = RSTRING_PTR(lookup_name);
+ if (st_lookup(&vm->static_ext_inits, (st_data_t)ftptr, NULL)) {
+ *path = rb_filesystem_str_new_cstr(ftptr);
+ RB_GC_GUARD(lookup_name);
+ return 's';
+ }
}
}
-#endif
+
switch (type) {
case 0:
if (ft)
goto feature_present;
ftptr = RSTRING_PTR(tmp);
- return rb_feature_p(vm, ftptr, 0, FALSE, TRUE, 0);
+ return rb_feature_p(box, ftptr, 0, FALSE, TRUE, 0);
default:
if (ft) {
goto feature_present;
}
/* fall through */
- case 1:
+ case loadable_ext_rb:
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (rb_feature_p(vm, ftptr, ext, !--type, TRUE, &loading) && !loading)
+ if (rb_feature_p(box, ftptr, ext, type == loadable_ext_rb, TRUE, &loading) && !loading)
break;
*path = tmp;
}
- return type ? 's' : 'r';
+ return type > loadable_ext_rb ? 's' : 'r';
feature_present:
if (loading) *path = rb_filesystem_str_new_cstr(loading);
@@ -1067,43 +1177,57 @@ load_failed(VALUE fname)
}
static VALUE
-load_ext(VALUE path)
+load_ext(VALUE path, VALUE fname)
{
+ VALUE loaded = path;
+ const rb_box_t *box = rb_loading_box();
+ VALUE cleanup = 0;
+ if (BOX_USER_P(box)) {
+ loaded = rb_box_local_extension(box->box_object, fname, path, &cleanup);
+ }
rb_scope_visibility_set(METHOD_VISI_PUBLIC);
- return (VALUE)dln_load(RSTRING_PTR(path));
+ void *handle = dln_load_feature(RSTRING_PTR(loaded), RSTRING_PTR(fname));
+ if (cleanup) {
+ rb_box_cleanup_local_extension(cleanup);
+ }
+ RB_GC_GUARD(loaded);
+ RB_GC_GUARD(fname);
+ return (VALUE)handle;
}
-#if EXTSTATIC
-static bool
-run_static_ext_init(rb_vm_t *vm, const char *feature)
+static VALUE
+run_static_ext_init(VALUE vm_ptr, VALUE feature_value)
{
+ rb_vm_t *vm = (rb_vm_t *)vm_ptr;
+ const char *feature = RSTRING_PTR(feature_value);
st_data_t key = (st_data_t)feature;
st_data_t init_func;
- if (st_delete(vm->static_ext_inits, &key, &init_func)) {
+
+ if (st_delete(&vm->static_ext_inits, &key, &init_func)) {
((void (*)(void))init_func)();
- return true;
+ return Qtrue;
}
- return false;
+ return Qfalse;
}
-#endif
static int
-no_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expanded, const char **fn)
+no_feature_p(const rb_box_t *box, const char *feature, const char *ext, int rb, int expanded, const char **fn)
{
return 0;
}
-// Documented in doc/globals.rdoc
+// Documented in doc/language/globals.md
VALUE
rb_resolve_feature_path(VALUE klass, VALUE fname)
{
VALUE path;
int found;
VALUE sym;
+ const rb_box_t *box = rb_loading_box();
fname = rb_get_path(fname);
path = rb_str_encode_ospath(fname);
- found = search_required(GET_VM(), path, &path, no_feature_p);
+ found = search_required(box, path, &path, no_feature_p);
switch (found) {
case 'r':
@@ -1120,14 +1244,14 @@ rb_resolve_feature_path(VALUE klass, VALUE fname)
}
static void
-ext_config_push(rb_thread_t *th, struct rb_ext_config *prev)
+ext_config_push(rb_thread_t *th, volatile struct rb_ext_config *prev)
{
*prev = th->ext_config;
th->ext_config = (struct rb_ext_config){0};
}
static void
-ext_config_pop(rb_thread_t *th, struct rb_ext_config *prev)
+ext_config_pop(rb_thread_t *th, volatile struct rb_ext_config *prev)
{
th->ext_config = *prev;
}
@@ -1150,21 +1274,25 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
{
volatile int result = -1;
rb_thread_t *th = rb_ec_thread_ptr(ec);
+ const rb_box_t *box = rb_loading_box();
volatile const struct {
VALUE wrapper, self, errinfo;
+ rb_execution_context_t *ec;
+ const rb_box_t *box;
} saved = {
th->top_wrapper, th->top_self, ec->errinfo,
+ ec, box,
};
enum ruby_tag_type state;
char *volatile ftptr = 0;
VALUE path;
volatile VALUE saved_path;
volatile VALUE realpath = 0;
- VALUE realpaths = get_loaded_features_realpaths(th->vm);
+ VALUE realpaths = box->loaded_features_realpaths;
+ VALUE realpath_map = box->loaded_features_realpath_map;
volatile bool reset_ext_config = false;
- struct rb_ext_config prev_ext_config;
+ volatile struct rb_ext_config prev_ext_config;
- fname = rb_get_path(fname);
path = rb_str_encode_ospath(fname);
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, RSTRING_PTR(fname));
saved_path = path;
@@ -1173,42 +1301,39 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
ec->errinfo = Qnil; /* ensure */
th->top_wrapper = 0;
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- long handle;
+ VALUE handle;
int found;
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, RSTRING_PTR(fname));
- found = search_required(th->vm, path, &saved_path, rb_feature_p);
+ found = search_required(box, path, &saved_path, rb_feature_p);
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, RSTRING_PTR(fname));
path = saved_path;
if (found) {
- if (!path || !(ftptr = load_lock(th->vm, RSTRING_PTR(path), warn))) {
+ if (!path || !(ftptr = load_lock(box, RSTRING_PTR(path), warn))) {
result = 0;
}
else if (!*ftptr) {
result = TAG_RETURN;
}
-#if EXTSTATIC
- else if (found == 's' && run_static_ext_init(th->vm, RSTRING_PTR(path))) {
+ else if (found == 's' && RTEST(rb_vm_call_cfunc_in_box(Qnil, run_static_ext_init, (VALUE)th->vm, path, path, box))) {
result = TAG_RETURN;
}
-#endif
else if (RTEST(rb_hash_aref(realpaths,
- realpath = rb_realpath_internal(Qnil, path, 1)))) {
+ realpath = realpath_internal_cached(realpath_map, path)))) {
result = 0;
}
else {
switch (found) {
case 'r':
- load_iseq_eval(ec, path);
+ load_iseq_eval(saved.ec, path);
break;
case 's':
reset_ext_config = true;
ext_config_push(th, &prev_ext_config);
- handle = (long)rb_vm_call_cfunc(rb_vm_top_self(), load_ext,
- path, VM_BLOCK_HANDLER_NONE, path);
- rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
+ handle = rb_vm_call_cfunc_in_box(box->top_self, load_ext, path, fname, path, box);
+ rb_hash_aset(box->ruby_dln_libmap, path, PTR2NUM(handle));
break;
}
result = TAG_RETURN;
@@ -1217,13 +1342,15 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
}
EC_POP_TAG();
+ ec = saved.ec;
+ box = saved.box;
rb_thread_t *th2 = rb_ec_thread_ptr(ec);
th2->top_self = saved.self;
th2->top_wrapper = saved.wrapper;
if (reset_ext_config) ext_config_pop(th2, &prev_ext_config);
path = saved_path;
- if (ftptr) load_unlock(th2->vm, RSTRING_PTR(path), !state);
+ if (ftptr) load_unlock(box, RSTRING_PTR(path), !state);
if (state) {
if (state == TAG_FATAL || state == TAG_THROW) {
@@ -1249,10 +1376,11 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
}
if (result == TAG_RETURN) {
- rb_provide_feature(th2->vm, path);
+ rb_provide_feature(box, path);
VALUE real = realpath;
if (real) {
- rb_hash_aset(realpaths, rb_fstring(real), Qtrue);
+ real = rb_fstring(real);
+ rb_hash_aset(realpaths, real, Qtrue);
}
}
ec->errinfo = saved.errinfo;
@@ -1265,6 +1393,10 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
int
rb_require_internal_silent(VALUE fname)
{
+ if (!rb_ractor_main_p()) {
+ return NUM2INT(rb_ractor_require(fname, true));
+ }
+
rb_execution_context_t *ec = GET_EC();
return require_internal(ec, fname, 1, false);
}
@@ -1279,7 +1411,7 @@ rb_require_internal(VALUE fname)
int
ruby_require_internal(const char *fname, unsigned int len)
{
- struct RString fake;
+ struct RString fake = {RBASIC_INIT};
VALUE str = rb_setup_fake_str(&fake, fname, len, 0);
rb_execution_context_t *ec = GET_EC();
int result = require_internal(ec, str, 0, RTEST(ruby_verbose));
@@ -1290,26 +1422,42 @@ ruby_require_internal(const char *fname, unsigned int len)
VALUE
rb_require_string(VALUE fname)
{
+ return rb_require_string_internal(FilePathValue(fname), false);
+}
+
+static VALUE
+rb_require_string_internal(VALUE fname, bool resurrect)
+{
rb_execution_context_t *ec = GET_EC();
- int result = require_internal(ec, fname, 1, RTEST(ruby_verbose));
- if (result > TAG_RETURN) {
- EC_JUMP_TAG(ec, result);
- }
- if (result < 0) {
- load_failed(fname);
+ // main ractor check
+ if (!rb_ractor_main_p()) {
+ if (resurrect) fname = rb_str_resurrect(fname);
+ return rb_ractor_require(fname, false);
}
+ else {
+ int result = require_internal(ec, fname, 1, RTEST(ruby_verbose));
+
+ if (result > TAG_RETURN) {
+ EC_JUMP_TAG(ec, result);
+ }
+ if (result < 0) {
+ if (resurrect) fname = rb_str_resurrect(fname);
+ load_failed(fname);
+ }
- return RBOOL(result);
+ return RBOOL(result);
+ }
}
VALUE
rb_require(const char *fname)
{
- return rb_require_string(rb_str_new_cstr(fname));
+ struct RString fake = {RBASIC_INIT};
+ VALUE str = rb_setup_fake_str(&fake, fname, strlen(fname), 0);
+ return rb_require_string_internal(str, true);
}
-#if EXTSTATIC
static int
register_init_ext(st_data_t *key, st_data_t *value, st_data_t init, int existing)
{
@@ -1324,17 +1472,20 @@ register_init_ext(st_data_t *key, st_data_t *value, st_data_t init, int existing
return ST_CONTINUE;
}
+// Private API for statically linked extensions.
+// Used with the ext/Setup file, the --with-setup and
+// --with-static-linked-ext configuration option, etc.
void
ruby_init_ext(const char *name, void (*init)(void))
{
rb_vm_t *vm = GET_VM();
- st_table *inits_table = vm->static_ext_inits;
+ const rb_box_t *box = rb_loading_box();
- if (feature_provided(vm, name, 0))
+ if (feature_provided((rb_box_t *)box, name, 0))
return;
- st_update(inits_table, (st_data_t)name, register_init_ext, (st_data_t)init);
+
+ st_update(&vm->static_ext_inits, (st_data_t)name, register_init_ext, (st_data_t)init);
}
-#endif
/*
* call-seq:
@@ -1349,9 +1500,12 @@ ruby_init_ext(const char *name, void (*init)(void))
* A.autoload(:B, "b")
* A::B.doit # autoloads "b"
*
- * If _const_ in _mod_ is defined as autoload, the file name to be
- * loaded is replaced with _filename_. If _const_ is defined but not
- * as autoload, does nothing.
+ * If _const_ in _mod_ is defined as autoload, the file name to be
+ * loaded is replaced with _filename_. If _const_ is defined but not
+ * as autoload, does nothing.
+ *
+ * Files that are currently being loaded must not be registered for
+ * autoload.
*/
static VALUE
@@ -1366,6 +1520,49 @@ rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
/*
* call-seq:
+ * mod.autoload_relative(const, filename) -> nil
+ *
+ * Registers _filename_ to be loaded (using Kernel::require)
+ * the first time that _const_ (which may be a String or
+ * a symbol) is accessed in the namespace of _mod_. The _filename_
+ * is interpreted as relative to the directory of the file where
+ * autoload_relative is called.
+ *
+ * module A
+ * end
+ * A.autoload_relative(:B, "b.rb")
+ *
+ * If _const_ in _mod_ is defined as autoload, the file name to be
+ * loaded is replaced with _filename_. If _const_ is defined but not
+ * as autoload, does nothing.
+ *
+ * The relative path is converted to an absolute path, which is what
+ * will be returned by Module#autoload? for the constant.
+ *
+ * Raises LoadError if called without file context (e.g., from eval).
+ */
+
+static VALUE
+rb_mod_autoload_relative(VALUE mod, VALUE sym, VALUE file)
+{
+ ID id = rb_to_id(sym);
+ VALUE base, absolute_path;
+
+ FilePathValue(file);
+
+ base = rb_current_realfilepath();
+ if (NIL_P(base)) {
+ rb_loaderror("cannot infer basepath (autoload_relative called without file context)");
+ }
+ base = rb_file_dirname(base);
+ absolute_path = rb_file_absolute_path(file, base);
+
+ rb_autoload_str(mod, id, absolute_path);
+ return Qnil;
+}
+
+/*
+ * call-seq:
* mod.autoload?(name, inherit=true) -> String or nil
*
* Returns _filename_ to be loaded if _name_ is registered as
@@ -1413,9 +1610,12 @@ rb_mod_autoload_p(int argc, VALUE *argv, VALUE mod)
*
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
*
- * If _const_ is defined as autoload, the file name to be loaded is
- * replaced with _filename_. If _const_ is defined but not as
- * autoload, does nothing.
+ * If _const_ is defined as autoload, the file name to be loaded is
+ * replaced with _filename_. If _const_ is defined but not as
+ * autoload, does nothing.
+ *
+ * Files that are currently being loaded must not be registered for
+ * autoload.
*/
static VALUE
@@ -1430,13 +1630,57 @@ rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
/*
* call-seq:
+ * autoload_relative(const, filename) -> nil
+ *
+ * Registers _filename_ to be loaded (using Kernel::require)
+ * the first time that _const_ (which may be a String or
+ * a symbol) is accessed. The _filename_ is interpreted as
+ * relative to the directory of the file where autoload_relative
+ * is called.
+ *
+ * autoload_relative(:MyModule, "my_module.rb")
+ *
+ * If _const_ is defined as autoload, the file name to be loaded is
+ * replaced with _filename_. If _const_ is defined but not as
+ * autoload, does nothing.
+ *
+ * The relative path is converted to an absolute path, which is what
+ * will be returned by Kernel#autoload? for the constant.
+ *
+ * Raises LoadError if called without file context (e.g., from eval).
+ */
+
+static VALUE
+rb_f_autoload_relative(VALUE obj, VALUE sym, VALUE file)
+{
+ VALUE klass = rb_class_real(rb_vm_cbase());
+ if (!klass) {
+ rb_raise(rb_eTypeError, "Can not set autoload on singleton class");
+ }
+ return rb_mod_autoload_relative(klass, sym, file);
+}
+
+/*
+ * call-seq:
* autoload?(name, inherit=true) -> String or nil
*
* Returns _filename_ to be loaded if _name_ is registered as
- * +autoload+.
+ * +autoload+ in the current namespace or one of its ancestors.
*
* autoload(:B, "b")
* autoload?(:B) #=> "b"
+ *
+ * module C
+ * autoload(:D, "d")
+ * autoload?(:D) #=> "d"
+ * autoload?(:B) #=> nil
+ * end
+ *
+ * class E
+ * autoload(:F, "f")
+ * autoload?(:F) #=> "f"
+ * autoload?(:B) #=> "b"
+ * end
*/
static VALUE
@@ -1450,38 +1694,61 @@ rb_f_autoload_p(int argc, VALUE *argv, VALUE obj)
return rb_mod_autoload_p(argc, argv, klass);
}
+void *
+rb_ext_resolve_symbol(const char* fname, const char* symbol)
+{
+ VALUE handle;
+ VALUE resolved;
+ VALUE path;
+ const char *ext;
+ VALUE fname_str = rb_str_new_cstr(fname);
+ const rb_box_t *box = rb_loading_box();
+
+ resolved = rb_resolve_feature_path((VALUE)NULL, fname_str);
+ if (NIL_P(resolved)) {
+ ext = strrchr(fname, '.');
+ if (!ext || !IS_SOEXT(ext)) {
+ rb_str_cat_cstr(fname_str, ".so");
+ }
+ if (rb_feature_p(box, fname, 0, FALSE, FALSE, 0)) {
+ return dln_symbol(NULL, symbol);
+ }
+ return NULL;
+ }
+ if (RARRAY_LEN(resolved) != 2 || rb_ary_entry(resolved, 0) != ID2SYM(rb_intern("so"))) {
+ return NULL;
+ }
+ path = rb_ary_entry(resolved, 1);
+ handle = rb_hash_lookup(box->ruby_dln_libmap, path);
+ if (NIL_P(handle)) {
+ return NULL;
+ }
+ return dln_symbol(NUM2PTR(handle), symbol);
+}
+
void
Init_load(void)
{
- rb_vm_t *vm = GET_VM();
static const char var_load_path[] = "$:";
ID id_load_path = rb_intern2(var_load_path, sizeof(var_load_path)-1);
- rb_define_hooked_variable(var_load_path, (VALUE*)vm, load_path_getter, rb_gvar_readonly_setter);
+ rb_define_hooked_variable(var_load_path, 0, load_path_getter, rb_gvar_readonly_setter);
+ rb_gvar_box_ready(var_load_path);
rb_alias_variable(rb_intern_const("$-I"), id_load_path);
rb_alias_variable(rb_intern_const("$LOAD_PATH"), id_load_path);
- vm->load_path = rb_ary_new();
- vm->expanded_load_path = rb_ary_hidden_new(0);
- vm->load_path_snapshot = rb_ary_hidden_new(0);
- vm->load_path_check_cache = 0;
- rb_define_singleton_method(vm->load_path, "resolve_feature_path", rb_resolve_feature_path, 1);
rb_define_virtual_variable("$\"", get_LOADED_FEATURES, 0);
- rb_define_virtual_variable("$LOADED_FEATURES", get_LOADED_FEATURES, 0);
- vm->loaded_features = rb_ary_new();
- vm->loaded_features_snapshot = rb_ary_hidden_new(0);
- vm->loaded_features_index = st_init_numtable();
- vm->loaded_features_realpaths = rb_hash_new();
- rb_obj_hide(vm->loaded_features_realpaths);
+ rb_gvar_box_ready("$\"");
+ rb_define_virtual_variable("$LOADED_FEATURES", get_LOADED_FEATURES, 0); // TODO: rb_alias_variable ?
+ rb_gvar_box_ready("$LOADED_FEATURES");
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);
rb_define_global_function("require_relative", rb_f_require_relative, 1);
rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
+ rb_define_method(rb_cModule, "autoload_relative", rb_mod_autoload_relative, 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_relative", rb_f_autoload_relative, 2);
rb_define_global_function("autoload?", rb_f_autoload_p, -1);
-
- ruby_dln_librefs = rb_ary_hidden_new(0);
- rb_gc_register_mark_object(ruby_dln_librefs);
}
diff --git a/main.c b/main.c
index 072dc56dd5..525189db85 100644
--- a/main.c
+++ b/main.c
@@ -20,6 +20,7 @@
#undef RUBY_EXPORT
#include "ruby.h"
#include "vm_debug.h"
+#include "internal/sanitizers.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
@@ -31,6 +32,8 @@
# undef RUBY_DEBUG_ENV
#endif
+RUBY_GLOBAL_SETUP
+
static int
rb_main(int argc, char **argv)
{
@@ -39,9 +42,10 @@ rb_main(int argc, char **argv)
return ruby_run_node(ruby_options(argc, argv));
}
-#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
-int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv);
-#define rb_main(argc, argv) rb_wasm_rt_start(rb_main, argc, argv)
+#ifdef _WIN32
+#define main(argc, argv) w32_main(argc, argv)
+static int main(int argc, char **argv);
+int wmain(void) {return main(0, NULL);}
#endif
int
@@ -55,5 +59,5 @@ main(int argc, char **argv)
#endif
ruby_sysinit(&argc, &argv);
- return rb_main(argc, argv);
+ return ruby_start_main(rb_main, argc, argv);
}
diff --git a/man/erb.1 b/man/erb.1
index d8739a7639..38a4c14ea4 100644
--- a/man/erb.1
+++ b/man/erb.1
@@ -1,6 +1,6 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd December 16, 2018
-.Dt ERB \&1 "Ruby Programmer's Reference Guide"
+.Dd March 27, 2026
+.Dt ERB 1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
.Nm erb
diff --git a/man/goruby.1 b/man/goruby.1
index a305a5afce..732ecaa663 100644
--- a/man/goruby.1
+++ b/man/goruby.1
@@ -1,6 +1,6 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd April 20, 2017
-.Dt GORUBY \&1 "Ruby Programmer's Reference Guide"
+.Dd March 27, 2026
+.Dt GORUBY 1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
.Nm goruby
diff --git a/man/index.txt b/man/index.txt
deleted file mode 100644
index 400eb02267..0000000000
--- a/man/index.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Gemfile(5) gemfile.5
-bundle(1) bundle.1
-bundle-add(1) bundle-add.1
-bundle-binstubs(1) bundle-binstubs.1
-bundle-check(1) bundle-check.1
-bundle-clean(1) bundle-clean.1
-bundle-config(1) bundle-config.1
-bundle-doctor(1) bundle-doctor.1
-bundle-exec(1) bundle-exec.1
-bundle-gem(1) bundle-gem.1
-bundle-info(1) bundle-info.1
-bundle-init(1) bundle-init.1
-bundle-inject(1) bundle-inject.1
-bundle-install(1) bundle-install.1
-bundle-list(1) bundle-list.1
-bundle-lock(1) bundle-lock.1
-bundle-open(1) bundle-open.1
-bundle-outdated(1) bundle-outdated.1
-bundle-package(1) bundle-package.1
-bundle-platform(1) bundle-platform.1
-bundle-pristine(1) bundle-pristine.1
-bundle-remove(1) bundle-remove.1
-bundle-show(1) bundle-show.1
-bundle-update(1) bundle-update.1
-bundle-viz(1) bundle-viz.1
diff --git a/man/irb.1 b/man/irb.1
deleted file mode 100644
index c589c99c78..0000000000
--- a/man/irb.1
+++ /dev/null
@@ -1,250 +0,0 @@
-.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd August 11, 2019
-.Dt IRB \&1 "Ruby Programmer's Reference Guide"
-.Os UNIX
-.Sh NAME
-.Nm irb
-.Nd Interactive Ruby Shell
-.Sh SYNOPSIS
-.Nm
-.Op Fl -version
-.Op Fl dfUw
-.Op Fl I Ar directory
-.Op Fl r Ar library
-.Op Fl E Ar external Ns Op : Ns Ar internal
-.Op Fl W Ns Op Ar level
-.Op Fl - Ns Oo no Oc Ns inspect
-.Op Fl - Ns Oo no Oc Ns multiline
-.Op Fl - Ns Oo no Oc Ns singleline
-.Op Fl - Ns Oo no Oc Ns echo
-.Op Fl - Ns Oo no Oc Ns colorize
-.Op Fl - Ns Oo no Oc Ns autocomplete
-.Op Fl - Ns Oo no Oc Ns verbose
-.Op Fl -prompt Ar mode
-.Op Fl -prompt-mode Ar mode
-.Op Fl -inf-ruby-mode
-.Op Fl -simple-prompt
-.Op Fl -noprompt
-.Op Fl -tracer
-.Op Fl -back-trace-limit Ar n
-.Op Fl -
-.Op program_file
-.Op argument ...
-.Pp
-.Sh DESCRIPTION
-.Nm
-is the REPL(read-eval-print loop) environment for Ruby programs.
-.Pp
-.Sh OPTIONS
-.Bl -tag -width "1234567890123" -compact
-.Pp
-.It Fl -version
-Prints the version of
-.Nm .
-.Pp
-.It Fl E Ar external Ns Op : Ns Ar internal
-.It Fl -encoding Ar external Ns Op : Ns Ar internal
-Same as `ruby -E' .
-Specifies the default value(s) for external encodings and internal encoding. Values should be separated with colon (:).
-.Pp
-You can omit the one for internal encodings, then the value
-.Pf ( Li "Encoding.default_internal" ) will be nil.
-.Pp
-.It Fl I Ar path
-Same as `ruby -I' .
-Specifies
-.Li $LOAD_PATH
-directory
-.Pp
-.It Fl U
-Same as `ruby -U' .
-Sets the default value for internal encodings
-.Pf ( Li "Encoding.default_internal" ) to UTF-8.
-.Pp
-.It Fl d
-Same as `ruby -d' .
-Sets
-.Li $DEBUG
-to true.
-.Pp
-.It Fl f
-Suppresses read of
-.Pa ~/.irbrc .
-.Pp
-.It Fl w
-Same as `ruby -w' .
-.Pp
-.Pp
-.It Fl W
-Same as `ruby -W' .
-.Pp
-.It Fl h
-.It Fl -help
-Prints a summary of the options.
-.Pp
-.It Fl r Ar library
-Same as `ruby -r'.
-Causes irb to load the library using require.
-.Pp
-.It Fl -inspect
-Uses `inspect' for output (default except for bc mode)
-.Pp
-.It Fl -noinspect
-Doesn't use inspect for output
-.Pp
-.It Fl -multiline
-Uses multiline editor module.
-.Pp
-.It Fl -nomultiline
-Doesn't use multiline editor module.
-.Pp
-.It Fl -singleline
-Uses singleline editor module.
-.Pp
-.It Fl -nosingleline
-Doesn't use singleline editor module.
-.Pp
-.Pp
-.It Fl -extra-doc-dir
-Add an extra doc dir for the doc dialog.
-.Pp
-.Pp
-.It Fl -echo
-Show result (default).
-.Pp
-.It Fl -noecho
-Don't show result.
-.Pp
-.Pp
-.It Fl -echo-on-assignment
-Show result on assignment.
-.Pp
-.It Fl -noecho-on-assignment
-Don't show result on assignment.
-.Pp
-.It Fl -truncate-echo-on-assignment
-Show truncated result on assignment (default).
-.Pp
-.Pp
-.It Fl -colorize
-Use colorization.
-.Pp
-.It Fl -nocolorize
-Don't use colorization.
-.Pp
-.Pp
-.It Fl -autocomplete
-Use autocompletion.
-.Pp
-.It Fl -noautocomplete
-Don't use autocompletion.
-.Pp
-.Pp
-.It Fl -verbose
-Show details.
-.Pp
-.It Fl -noverbose
-Don't show details.
-.Pp
-.It Fl -prompt Ar mode
-.It Fl -prompt-mode Ar mode
-Switch prompt mode. Pre-defined prompt modes are
-`default', `simple', `xmp' and `inf-ruby'.
-.Pp
-.It Fl -inf-ruby-mode
-Uses prompt appropriate for inf-ruby-mode on emacs.
-Suppresses --multiline and --singleline.
-.Pp
-.It Fl -simple-prompt
-Makes prompts simple.
-.Pp
-.It Fl -noprompt
-No prompt mode.
-.Pp
-.It Fl -tracer
-Displays trace for each execution of commands.
-.Pp
-.It Fl -back-trace-limit Ar n
-Displays backtrace top
-.Ar n
-and tail
-.Ar n Ns .
-The default value is 16.
-.El
-.Pp
-.Sh ENVIRONMENT
-.Bl -tag -compact -width "XDG_CONFIG_HOME"
-.It Ev IRB_LANG
-The locale used for
-.Nm .
-.Pp
-.It Ev IRBRC
-The path to the personal initialization file.
-.Pp
-.It Ev XDG_CONFIG_HOME
-.Nm
-respects XDG_CONFIG_HOME. If this is set, load
-.Pa $XDG_CONFIG_HOME/irb/irbrc
-as a personal initialization file.
-.Pp
-.El
-.Pp
-Also
-.Nm
-depends on same variables as
-.Xr ruby 1 .
-.Pp
-.Sh FILES
-.Bl -tag -compact
-.It Pa ~/.irbrc
-Personal irb initialization. If
-.Ev IRBRC
-is set, read
-.Pa $IRBRC
-instead. If
-.Ev IRBRC
-is not set and
-.Ev XDG_CONFIG_HOME
-is set,
-.Pa $XDG_CONFIG_HOME/irb/irbrc
-is loaded.
-.Pp
-.El
-.Pp
-.Sh EXAMPLES
-.Dl % irb
-.Dl irb(main):001:0> Ic 1 + 1
-.Dl 2
-.Dl irb(main):002:0> Ic def t(x)
-.Dl irb(main):003:1> Ic x + 1
-.Dl irb(main):004:1> Ic end
-.Dl => :t
-.Dl irb(main):005:0> Ic t(3)
-.Dl => 4
-.Dl irb(main):006:0> Ic if t(3) == 4
-.Dl irb(main):007:1> Ic p :ok
-.Dl irb(main):008:1> Ic end
-.Dl :ok
-.Dl => :ok
-.Dl irb(main):009:0> Ic quit
-.Dl %
-.Pp
-.Sh SEE ALSO
-.Xr ruby 1 .
-.Pp
-.Sh REPORTING BUGS
-.Bl -bullet
-.It
-Security vulnerabilities should be reported via an email to
-.Mt security@ruby-lang.org .
-Reported problems will be published after being fixed.
-.Pp
-.It
-Other bugs and feature requests can be reported via the
-Ruby Issue Tracking System
-.Pq Lk https://bugs.ruby-lang.org/ .
-Do not report security vulnerabilities
-via this system because it publishes the vulnerabilities immediately.
-.El
-.Sh AUTHORS
-Written by Keiju ISHITSUKA.
diff --git a/man/ri.1 b/man/ri.1
deleted file mode 100644
index 85a6dfcd53..0000000000
--- a/man/ri.1
+++ /dev/null
@@ -1,247 +0,0 @@
-.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd April 20, 2017
-.Dt RI \&1 "Ruby Programmer's Reference Guide"
-.Os UNIX
-.Sh NAME
-.Nm ri
-.Nd Ruby API reference front end
-.Sh SYNOPSIS
-.Nm
-.Op Fl ahilTv
-.Op Fl d Ar DIRNAME
-.Op Fl f Ar FORMAT
-.Op Fl w Ar WIDTH
-.Op Fl - Ns Oo Cm no- Oc Ns Cm pager
-.Op Fl -server Ns Oo = Ns Ar PORT Oc
-.Op Fl - Ns Oo Cm no- Oc Ns Cm list-doc-dirs
-.Op Fl -no-standard-docs
-.Op Fl - Ns Oo Cm no- Oc Ns Bro Cm system Ns | Ns Cm site Ns | Ns Cm gems Ns | Ns Cm home Brc
-.Op Fl - Ns Oo Cm no- Oc Ns Cm profile
-.Op Fl -dump Ns = Ns Ar CACHE
-.Op Ar name ...
-.Sh DESCRIPTION
-.Nm
-is a command-line front end for the Ruby API reference.
-You can search and read the API reference for classes and methods with
-.Nm .
-.Pp
-.Nm
-is a part of Ruby.
-.Pp
-.Ar name
-can be:
-.Bl -diag -offset indent
-.It Class | Module | Module::Class
-.Pp
-.It Class::method | Class#method | Class.method | method
-.Pp
-.It gem_name: | gem_name:README | gem_name:History
-.El
-.Pp
-All class names may be abbreviated to their minimum unambiguous form.
-If a name is ambiguous, all valid options will be listed.
-.Pp
-A
-.Ql \&.
-matches either class or instance methods, while #method
-matches only instance and ::method matches only class methods.
-.Pp
-README and other files may be displayed by prefixing them with the gem name
-they're contained in. If the gem name is followed by a
-.Ql \&:
-all files in the gem will be shown.
-The file name extension may be omitted where it is unambiguous.
-.Pp
-For example:
-.Bd -literal -offset indent
-ri Fil
-ri File
-ri File.new
-ri zip
-ri rdoc:README
-.Ed
-.Pp
-Note that shell quoting or escaping may be required for method names
-containing punctuation:
-.Bd -literal -offset indent
-ri 'Array.[]'
-ri compact\e!
-.Ed
-.Pp
-To see the default directories
-.Nm
-will search, run:
-.Bd -literal -offset indent
-ri --list-doc-dirs
-.Ed
-.Pp
-Specifying the
-.Fl -system , Fl -site , Fl -home , Fl -gems ,
-or
-.Fl -doc-dir
-options will limit
-.Nm
-to searching only the specified directories.
-.Pp
-.Nm
-options may be set in the
-.Ev RI
-environment variable.
-.Pp
-The
-.Nm
-pager can be set with the
-.Ev RI_PAGER
-environment variable or the
-.Ev PAGER
-environment variable.
-.Pp
-.Sh OPTIONS
-.Bl -tag -width "1234567890123" -compact
-.Pp
-.It Fl i
-.It Fl - Ns Oo Cm no- Oc Ns Cm interactive
-In interactive mode you can repeatedly
-look up methods with autocomplete.
-.Pp
-.It Fl a
-.It Fl - Ns Oo Cm no- Oc Ns Cm all
-Show all documentation for a class or module.
-.Pp
-.It Fl l
-.It Fl - Ns Oo Cm no- Oc Ns Cm list
-List classes
-.Nm
-knows about.
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm pager
-Send output to a pager,
-rather than directly to stdout.
-.Pp
-.It Fl T
-Synonym for
-.Fl -no-pager .
-.Pp
-.It Fl w Ar WIDTH
-.It Fl -width Ns = Ns Ar WIDTH
-Set the width of the output.
-.Pp
-.It Fl -server Ns Oo = Ns Ar PORT Oc
-Run RDoc server on the given port.
-The default port is\~8214.
-.Pp
-.It Fl f Ar FORMAT
-.It Fl -format Ns = Ns Ar FORMAT
-Use the selected formatter.
-The default formatter is
-.Li bs
-for paged output and
-.Li ansi
-otherwise.
-Valid formatters are:
-.Li ansi , Li bs , Li markdown , Li rdoc .
-.Pp
-.It Fl h
-.It Fl -help
-Show help and exit.
-.Pp
-.It Fl v
-.It Fl -version
-Output version information and exit.
-.El
-.Pp
-Data source options:
-.Bl -tag -width "1234567890123" -compact
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm list-doc-dirs
-List the directories from which
-.Nm
-will source documentation on stdout and exit.
-.Pp
-.It Fl d Ar DIRNAME
-.It Fl -doc-dir Ns = Ns Ar DIRNAME
-List of directories from which to source
-documentation in addition to the standard
-directories. May be repeated.
-.Pp
-.It Fl -no-standard-docs
-Do not include documentation from the Ruby standard library,
-.Pa site_lib ,
-installed gems, or
-.Pa ~/.rdoc .
-Use with
-.Fl -doc-dir .
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm system
-Include documentation from Ruby's standard library. Defaults to true.
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm site
-Include documentation from libraries installed in
-.Pa site_lib .
-Defaults to true.
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm gems
-Include documentation from RubyGems. Defaults to true.
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm home
-Include documentation stored in
-.Pa ~/.rdoc .
-Defaults to true.
-.El
-.Pp
-Debug options:
-.Bl -tag -width "1234567890123" -compact
-.Pp
-.It Fl - Ns Oo Cm no- Oc Ns Cm profile
-Run with the Ruby profiler.
-.Pp
-.It Fl -dump Ns = Ns Ar CACHE
-Dump data from an ri cache or data file.
-.El
-.Pp
-.Sh ENVIRONMENT
-.Bl -tag -width "USERPROFILE" -compact
-.Pp
-.It Ev RI
-Options to prepend to those specified on the command-line.
-.Pp
-.It Ev RI_PAGER
-.It Ev PAGER
-Pager program to use for displaying.
-.Pp
-.It Ev HOME
-.It Ev USERPROFILE
-.It Ev HOMEPATH
-Path to the user's home directory.
-.El
-.Pp
-.Sh FILES
-.Bl -tag -width "USERPROFILE" -compact
-.Pp
-.It Pa ~/.rdoc
-Path for ri data in the user's home directory.
-.Pp
-.El
-.Pp
-.Sh SEE ALSO
-.Xr ruby 1 ,
-.Xr rdoc 1 ,
-.Xr gem 1
-.Pp
-.Sh REPORTING BUGS
-.Bl -bullet
-.It
-Security vulnerabilities should be reported via an email to
-.Mt security@ruby-lang.org .
-Reported problems will be published after being fixed.
-.Pp
-.It
-Other bugs and feature requests can be reported via the
-Ruby Issue Tracking System
-.Pq Lk https://bugs.ruby-lang.org/ .
-Do not report security vulnerabilities
-via this system because it publishes the vulnerabilities immediately.
-.El
-.Sh AUTHORS
-Written by
-.An Dave Thomas Aq dave@pragmaticprogrammer.com .
diff --git a/man/ruby.1 b/man/ruby.1
index 779167ac3e..bc776b8946 100644
--- a/man/ruby.1
+++ b/man/ruby.1
@@ -1,6 +1,6 @@
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
-.Dd April 14, 2018
-.Dt RUBY \&1 "Ruby Programmer's Reference Guide"
+.Dd March 27, 2026
+.Dt RUBY 1 "Ruby Programmer's Reference Guide"
.Os UNIX
.Sh NAME
.Nm ruby
@@ -25,6 +25,7 @@
.Op Fl - Ns Bro Cm enable Ns | Ns Cm disable Brc Ns - Ns Ar FEATURE
.Op Fl -dump Ns = Ns Ar target
.Op Fl -verbose
+.Op Fl -crash-report Ns = Ns Ar template
.Op Fl -
.Op Ar program_file
.Op Ar argument ...
@@ -100,10 +101,10 @@ different character encodings, without dependence on Unicode.
.It Sy "Bignums"
With built-in bignums, you can for example calculate factorial(400).
.Pp
-.It Sy "Reflection and domain specific languages"
+.It Sy "Reflection and domain-specific languages"
Class is also an instance of the Class class. Definition of classes and methods
is an expression just as 1+1 is. So your programs can even write and modify programs.
-Thus you can write your application in your own programming language on top of Ruby.
+Thus, you can write your application in your own programming language on top of Ruby.
.Pp
.It Sy "Exception handling"
As in Java(tm).
@@ -271,6 +272,11 @@ In auto-split mode, Ruby executes
.Dl $F = $_.split
at beginning of each loop.
.Pp
+.It Fl -backtrace-limit Ns = Ns Ar num
+Limits the maximum length of backtraces to
+.Ar num
+lines (default -1, meaning no limit).
+.Pp
.It Fl c
Causes Ruby to check the syntax of the script and exit without
executing. If there are no syntax errors, Ruby will print
@@ -281,6 +287,8 @@ to the standard output.
.It Fl -debug
Turns on debug mode.
.Li "$DEBUG"
+and
+.Li "$VERBOSE"
will be set to true.
.Pp
.It Fl e Ar command
@@ -388,7 +396,7 @@ before executing script.
.Pp
.It Fl y
.It Fl -yydebug
-DO NOT USE.
+This option is not guaranteed to be compatible.
.Pp
Turns on compiler debug mode. Ruby will print a bunch of internal
state messages during compilation. Only specify this switch you are going to
@@ -424,7 +432,7 @@ Dump some information.
Prints the specified target.
.Ar target
can be one of:
-.Bl -hang -offset indent
+.Bl -hang -offset indent -width "version"
.It Sy version
Print version description (same as
.Fl -version).
@@ -442,18 +450,20 @@ Check syntax (same as
.El
.Pp
Or one of the following, which are intended for debugging the interpreter:
-.Bl -hang -offset indent -tag -width "parsetree_with_comment"
+.Bl -hang -offset indent -width "parsetree"
.It Sy yydebug
Enable compiler debug mode (same as
.Fl -yydebug).
.It Sy parsetree
Print a textual representation of the Ruby AST for the program.
-.It Sy parsetree_with_comment
-Print a textual representation of the Ruby AST for the program, but with each node annoted with the associated Ruby source code.
.It Sy insns
Print a list of disassembled bytecode instructions.
-.It Sy insns_without_opt
-Print the list of disassembled bytecode instructions before various optimizations have been applied.
+.It Sy -optimize
+Disable various optimizations to print a list disassembled bytecode instructions.
+.It Sy +error-tolerant
+Enable error-tolerant parsing, when yydebug or parsetree.
+.It Sy +comment
+Annotate a textual representation of the Ruby AST for the program with the associated Ruby source code.
.El
.Pp
.It Fl -verbose
@@ -464,6 +474,12 @@ variable to true.
If this switch is given, and no script arguments (script file or
.Fl e
options) are present, Ruby quits immediately.
+.Pp
+.It Fl -crash-report Ns = Ns Ar template
+Sets the template of path name to save crash report.
+See
+.Ev RUBY_CRASH_REPORT
+environment variable for details.
.El
.Pp
.Sh ENVIRONMENT
@@ -503,6 +519,43 @@ enabled for only mswin32, mingw32, and OS/2 platforms. If this
variable is not defined, Ruby refers to
.Ev COMSPEC .
.Pp
+.It Ev RUBY_FREE_AT_EXIT
+If set, Ruby tries to free all dynamically allocated memories.
+Introduced in Ruby 3.3, default: unset.
+.Pp
+.It Ev RUBY_BOX
+If set to
+.Li 1 ,
+Ruby Box is enabled and users will be able to execute
+.Li Ruby::Box.new .
+Ruby Box is an experimental feature introduced in Ruby 4.0.
+.Pp
+.It Ev RUBY_IO_BUFFER_DEFAULT_SIZE
+The custom default buffer size of
+.Li IO::Buffer .
+.Pp
+.It Ev RUBY_MAX_CPU
+The maximum number of native threads used by M:N Threads scheduler
+Introduced in Ruby 3.3, default: 8.
+.Pp
+.It Ev RUBY_MN_THREADS
+If set to
+.Li 1 ,
+M:N Thread scheduler is enabled on the main Ractor.
+Introduced in Ruby 3.3, default: unset.
+.Pp
+.It Ev RUBY_PAGER
+The pager command that will be used for
+.Fl -help
+option.
+Introduced in Ruby 3.0, default:
+.Ev PAGER
+environment variable.
+.Pp
+.It Ev RUBY_THREAD_TIMESLICE
+Sets the default thread time slice (thread quantum) in milliseconds.
+Introduced in Ruby 3.4, default: 100ms.
+.Pp
.It Ev PATH
Ruby refers to the
.Ev PATH
@@ -525,7 +578,7 @@ malloc family of C standard library calls (
.Xr calloc 3 ,
and
.Xr realloc 3 ) .
-In this documentatation, the "heap" refers to the Ruby object heap
+In this documentation, the "heap" refers to the Ruby object heap
of fixed-sized slots, while "malloc" refers to auxiliary
allocations commonly referred to as the "process heap".
Thus there are at least two possible ways to trigger GC:
@@ -547,14 +600,15 @@ Reaching the old malloc limit.
.El
.Pp
There are currently 4 possible areas where the GC may be tuned by
-the following 11 environment variables:
-.Bl -hang -compact -width "RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR"
-.It Ev RUBY_GC_HEAP_INIT_SLOTS
-Initial allocation slots. Applies to all slot sizes. Introduced in Ruby 2.1, default: 10000.
-.Pp
-.It Ev RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS
-Initial allocation of slots in a specific size pool.
-The available size pools can be found in `GC.stat_heap`.
+the following environment variables:
+.Bl -hang -compact -width "RUBY_GC_HEAP_n_INIT_SLOTS"
+.Pp
+.It Ev RUBY_GC_HEAP_ Ns Ar n Ns Ev _INIT_SLOTS
+Initial allocation of slots in a specific heap.
+The available heaps can be found in the keys of
+.Li GC.stat_heap .
+.Ar n
+is a decimal number between 0 and 4.
Introduced in Ruby 3.3.
.Pp
.It Ev RUBY_GC_HEAP_FREE_SLOTS
@@ -577,6 +631,12 @@ where R is this factor and N is the number of old objects after the
last full GC.
Introduced in Ruby 2.1.1, default: 2.0
.Pp
+.It Ev RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO
+Used to calculate the
+.Li remembered_wb_unprotected_objects_limit
+using a ratio of
+.Li old_objects .
+Introduced in Ruby 3.3, default: 0.1, minimum: 0.0
.It Ev RUBY_GC_MALLOC_LIMIT
The initial limit of young generation allocation from the malloc-family.
GC will start when this limit is reached.
@@ -593,6 +653,31 @@ GC frequency but increasing malloc growth until RUBY_GC_MALLOC_LIMIT_MAX
is reached.
Introduced in Ruby 2.1, default: 1.4, minimum: 1.0 (no growth)
.Pp
+.It Ev RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO
+Allocate additional pages when the number of free slots is
+lower than the value
+.Li (total_slots * (this ratio)) .
+Introduced in Ruby 2.4, default: 0.2, minimum: 0.0, maximum: 1.0
+.Pp
+.It Ev RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO
+Allow to free pages when the number of free slots is greater than the value
+.Li (total_slots * (this ratio)) .
+Introduced in Ruby 2.4, default: 0.4, minimum:
+.Li RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO,
+maximum: 1.0
+.Pp
+.It Ev RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO
+Allocate slots to satisfy this formula:
+.Li free_slots = total_slots * goal_ratio
+In other words, prepare
+.Li (total_slots * goal_ratio)
+free slots.
+if this value is 0.0, then use RUBY_GC_HEAP_GROWTH_FACTOR directly.
+Introduced in Ruby 2.4, default: 0.65, minimum:
+.Li RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO,
+maximum:
+.Li RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO
+.Pp
.It Ev RUBY_GC_OLDMALLOC_LIMIT
The initial limit of old generation allocation from malloc,
a full GC will start when this limit is reached.
@@ -610,6 +695,21 @@ GC frequency but increasing malloc growth until RUBY_GC_OLDMALLOC_LIMIT_MAX
is reached.
Introduced in Ruby 2.1, default: 1.2, minimum: 1.0 (no growth)
.Pp
+.It Ev RUBY_SHARED_FIBER_POOL_FREE_STACKS
+Frees stacks of pooled fibers, if set to 1.
+Do not free the stacks if set to 0.
+Introduced in Ruby 2.7, default: 1 (no growth)
+.Pp
+.It Ev RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT
+If set to a non-negative integer, the shared fiber pool cannot allocate more
+than that many stacks; further fiber creation may fail with
+.Va FiberError .
+Unset or 0 means no explicit cap (subject to process limits).
+.Pp
+.It Ev RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT
+Initial and minimum growth chunk size for the shared fiber pool (stacks).
+Unset uses the implementation default.
+.Pp
.El
.Sh STACK SIZE ENVIRONMENT
Stack size environment variables are implementation-dependent and
@@ -625,11 +725,11 @@ All values are specified in bytes.
.Bl -hang -compact -width "RUBY_THREAD_MACHINE_STACK_SIZE"
.It Ev RUBY_THREAD_VM_STACK_SIZE
VM stack size used at thread creation.
-default: 524288 (32-bit CPU) or 1048575 (64-bit)
+default: 524288 (32-bit CPU) or 1048576 (64-bit)
.Pp
.It Ev RUBY_THREAD_MACHINE_STACK_SIZE
Machine stack size used at thread creation.
-default: 524288 or 1048575
+default: 524288 or 1048576
.Pp
.It Ev RUBY_FIBER_VM_STACK_SIZE
VM stack size used at fiber creation.
@@ -640,6 +740,72 @@ Machine stack size used at fiber creation.
default: 262144 or 524288
.Pp
.El
+.Sh CRASH REPORT ENVIRONMENT
+.Pp
+.Bl -tag -compact -width "RUBY_CRASH_REPORT"
+.It Ev RUBY_CRASH_REPORT
+The template of path name to save crash report.
+default: none
+.El
+.Ss Naming crash report files
+The template can contain
+.Li \fB%\fP
+specifiers which are substituted by the following values when a crash
+report file is created:
+.Pp
+.Bl -hang -compact -width "%NNN"
+.It Li \fB%%\fP
+A single
+.Li \fB%\fP
+character.
+.It Li \fB%e\fP
+Basename of executable.
+.It Li \fB%E\fP
+Pathname of executable,
+with slashes (\fB/\fP) replaced by exclamation marks (\fB!\fP).
+.It Li \fB%f\fP
+Basename of the program name,
+.Li "$0" .
+.It Li \fB%F\fP
+Pathname of the program name,
+.Li "$0",
+with slashes (\fB/\fP) replaced by exclamation marks (\fB!\fP).
+.It Li \fB%p\fP
+PID of dumped process.
+.It Li \fB%t\fP
+Time of dump, expressed as seconds since the
+Epoch, 1970-01-01 00:00:00 +0000 (UTC).
+.It Li \fB%NNN\fP
+A character code in octal.
+.El
+.Pp
+A single
+.Li \fB%\fP
+at the end of the template is dropped from the core filename, as is
+the combination of a
+.Li \fB%\fP
+followed by any character other than those listed above. All other
+characters in the template become a literal part of the core filename.
+The template may include \(aq/\(aq characters, which are interpreted
+as delimiters for directory names.
+.Ss Piping crash reports to a program
+If the first character of this file is a pipe symbol (\fB|\fP),
+then the remainder of the line is interpreted as the command-line for
+a program (or script) that is to be executed.
+.Pp
+The pipe template is split on spaces into an argument list before the
+template parameters are expanded.
+.Sh MISC ENVIRONMENT
+.Pp
+.Bl -hang -compact -width "RUBY_TCP_NO_FAST_FALLBACK"
+.It Ev RUBY_TCP_NO_FAST_FALLBACK
+If set to
+.Li 1 ,
+disables the fast fallback feature by default in TCPSocket.new and Socket.tcp.
+When set to
+.Li 0
+or left unset, the fast fallback feature is enabled.
+Introduced in Ruby 3.4, default: unset.
.Sh SEE ALSO
.Bl -hang -compact -width "https://www.ruby-toolbox.com/"
.It Lk https://www.ruby-lang.org/
@@ -667,5 +833,5 @@ Ruby is designed and implemented by
.An Yukihiro Matsumoto Aq matz@netlab.jp .
.Pp
See
-.Aq Lk https://bugs.ruby-lang.org/projects/ruby/wiki/Contributors
+.Aq Lk https://github.com/ruby/ruby/graphs/contributors
for contributors to Ruby.
diff --git a/marshal.c b/marshal.c
index cdf25df5aa..e6ee3b47b0 100644
--- a/marshal.c
+++ b/marshal.c
@@ -30,6 +30,7 @@
#include "internal/hash.h"
#include "internal/numeric.h"
#include "internal/object.h"
+#include "internal/re.h"
#include "internal/struct.h"
#include "internal/symbol.h"
#include "internal/util.h"
@@ -40,6 +41,7 @@
#include "ruby/util.h"
#include "builtin.h"
#include "shape.h"
+#include "ruby/internal/attr/nonstring.h"
#define BITSPERSHORT (2*CHAR_BIT)
#define SHORTMASK ((1<<BITSPERSHORT)-1)
@@ -100,6 +102,7 @@ static ID s_dump, s_load, s_mdump, s_mload;
static ID s_dump_data, s_load_data, s_alloc, s_call;
static ID s_getbyte, s_read, s_write, s_binmode;
static ID s_encoding_short, s_ruby2_keywords_flag;
+#define s_encoding_long rb_id_encoding()
#define name_s_dump "_dump"
#define name_s_load "_load"
@@ -114,6 +117,7 @@ static ID s_encoding_short, s_ruby2_keywords_flag;
#define name_s_write "write"
#define name_s_binmode "binmode"
#define name_s_encoding_short "E"
+#define name_s_encoding_long "encoding"
#define name_s_ruby2_keywords_flag "K"
typedef struct {
@@ -128,22 +132,6 @@ static VALUE compat_allocator_tbl_wrapper;
static VALUE rb_marshal_dump_limited(VALUE obj, VALUE port, int limit);
static VALUE rb_marshal_load_with_proc(VALUE port, VALUE proc, bool freeze);
-static int
-mark_marshal_compat_i(st_data_t key, st_data_t value, st_data_t _)
-{
- 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);
-}
-
static st_table *compat_allocator_table(void);
void
@@ -156,15 +144,16 @@ rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE),
rb_raise(rb_eTypeError, "no allocator");
}
+ compat_allocator_table();
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_table(), (st_data_t)allocator, (st_data_t)compat);
+ RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, newclass);
+ RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, oldclass);
}
struct dump_arg {
@@ -173,7 +162,8 @@ struct dump_arg {
st_table *data;
st_table *compat_tbl;
st_table *encodings;
- unsigned long num_entries;
+ st_table *userdefs;
+ st_index_t num_entries;
};
struct dump_call_arg {
@@ -221,6 +211,7 @@ mark_dump_arg(void *ptr)
rb_mark_set(p->symbols);
rb_mark_set(p->data);
rb_mark_hash(p->compat_tbl);
+ rb_mark_set(p->userdefs);
rb_gc_mark(p->str);
}
@@ -228,19 +219,25 @@ static void
free_dump_arg(void *ptr)
{
clear_dump_arg(ptr);
- xfree(ptr);
}
static size_t
memsize_dump_arg(const void *ptr)
{
- return sizeof(struct dump_arg);
+ const struct dump_arg *p = (struct dump_arg *)ptr;
+ size_t memsize = 0;
+ if (p->symbols) memsize += rb_st_memsize(p->symbols);
+ if (p->data) memsize += rb_st_memsize(p->data);
+ if (p->compat_tbl) memsize += rb_st_memsize(p->compat_tbl);
+ if (p->userdefs) memsize += rb_st_memsize(p->userdefs);
+ if (p->encodings) memsize += rb_st_memsize(p->encodings);
+ return memsize;
}
static const rb_data_type_t dump_arg_data = {
"dump_arg",
{mark_dump_arg, free_dump_arg, memsize_dump_arg,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
static VALUE
@@ -461,11 +458,36 @@ w_float(double d, struct dump_arg *arg)
memcpy(buf + len, p, digs);
len += digs;
}
- xfree(p);
+ free(p);
w_bytes(buf, len, arg);
}
}
+
+static VALUE
+w_encivar(VALUE str, struct dump_arg *arg)
+{
+ VALUE encname = encoding_name(str, arg);
+ if (NIL_P(encname) ||
+ is_ascii_string(str)) {
+ return Qnil;
+ }
+ w_byte(TYPE_IVAR, arg);
+ return encname;
+}
+
+static void
+w_encname(VALUE encname, struct dump_arg *arg)
+{
+ if (!NIL_P(encname)) {
+ struct dump_call_arg c_arg;
+ c_arg.limit = 1;
+ c_arg.arg = arg;
+ w_long(1L, arg);
+ w_encoding(encname, &c_arg);
+ }
+}
+
static void
w_symbol(VALUE sym, struct dump_arg *arg)
{
@@ -482,24 +504,11 @@ w_symbol(VALUE sym, struct dump_arg *arg)
if (!sym) {
rb_raise(rb_eTypeError, "can't dump anonymous ID %"PRIdVALUE, sym);
}
- encname = encoding_name(sym, arg);
- if (NIL_P(encname) ||
- is_ascii_string(sym)) {
- encname = Qnil;
- }
- else {
- w_byte(TYPE_IVAR, arg);
- }
+ encname = w_encivar(sym, arg);
w_byte(TYPE_SYMBOL, arg);
w_bytes(RSTRING_PTR(sym), RSTRING_LEN(sym), arg);
st_add_direct(arg->symbols, orig_sym, arg->symbols->num_entries);
- if (!NIL_P(encname)) {
- struct dump_call_arg c_arg;
- c_arg.limit = 1;
- c_arg.arg = arg;
- w_long(1L, arg);
- w_encoding(encname, &c_arg);
- }
+ w_encname(encname, arg);
}
}
@@ -528,7 +537,7 @@ hash_each(VALUE key, VALUE value, VALUE v)
static void
w_extended(VALUE klass, struct dump_arg *arg, int check)
{
- if (check && FL_TEST(klass, FL_SINGLETON)) {
+ if (check && RCLASS_SINGLETON_P(klass)) {
VALUE origin = RCLASS_ORIGIN(klass);
if (SINGLETON_DUMP_UNABLE_P(klass) ||
(origin != klass && SINGLETON_DUMP_UNABLE_P(origin))) {
@@ -537,7 +546,7 @@ w_extended(VALUE klass, struct dump_arg *arg, int check)
klass = RCLASS_SUPER(klass);
}
while (BUILTIN_TYPE(klass) == T_ICLASS) {
- if (!FL_TEST(klass, RICLASS_IS_ORIGIN) ||
+ if (!RICLASS_IS_ORIGIN_P(klass) ||
BUILTIN_TYPE(RBASIC(klass)->klass) != T_MODULE) {
VALUE path = rb_class_name(RBASIC(klass)->klass);
w_byte(TYPE_EXTENDED, arg);
@@ -590,13 +599,21 @@ rb_hash_ruby2_keywords(VALUE obj)
RHASH(obj)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
}
-static inline bool
-to_be_skipped_id(const ID id)
+/*
+ * if instance variable name `id` is a special name to be skipped,
+ * returns the name of it. otherwise it cannot be dumped (unnamed),
+ * returns `name` as-is. returns NULL for ID that can be dumped.
+ */
+static inline const char *
+skipping_ivar_name(const ID id, const char *name)
{
- if (id == s_encoding_short) return true;
- if (id == s_ruby2_keywords_flag) return true;
- if (id == rb_id_encoding()) return true;
- return !rb_id2str(id);
+#define IS_SKIPPED_IVAR(idname) \
+ ((id == idname) && (name = name_##idname, true))
+ if (IS_SKIPPED_IVAR(s_encoding_short)) return name;
+ if (IS_SKIPPED_IVAR(s_ruby2_keywords_flag)) return name;
+ if (IS_SKIPPED_IVAR(s_encoding_long)) return name;
+ if (!rb_id2str(id)) return name;
+ return NULL;
}
struct w_ivar_arg {
@@ -605,21 +622,16 @@ struct w_ivar_arg {
};
static int
-w_obj_each(st_data_t key, st_data_t val, st_data_t a)
+w_obj_each(ID id, VALUE value, st_data_t a)
{
- ID id = (ID)key;
- VALUE value = (VALUE)val;
struct w_ivar_arg *ivarg = (struct w_ivar_arg *)a;
struct dump_call_arg *arg = ivarg->dump;
+ const char unnamed[] = "", *ivname = skipping_ivar_name(id, unnamed);
- if (to_be_skipped_id(id)) {
- if (id == s_encoding_short) {
- rb_warn("instance variable `"name_s_encoding_short"' on class %"PRIsVALUE" is not dumped",
- CLASS_OF(arg->obj));
- }
- if (id == s_ruby2_keywords_flag) {
- rb_warn("instance variable `"name_s_ruby2_keywords_flag"' on class %"PRIsVALUE" is not dumped",
- CLASS_OF(arg->obj));
+ if (ivname) {
+ if (ivname != unnamed) {
+ rb_warn("instance variable '%s' on class %"PRIsVALUE" is not dumped",
+ ivname, CLASS_OF(arg->obj));
}
return ST_CONTINUE;
}
@@ -630,10 +642,9 @@ w_obj_each(st_data_t key, st_data_t val, st_data_t a)
}
static int
-obj_count_ivars(st_data_t key, st_data_t val, st_data_t a)
+obj_count_ivars(ID id, VALUE val, st_data_t a)
{
- ID id = (ID)key;
- if (!to_be_skipped_id(id) && UNLIKELY(!++*(st_index_t *)a)) {
+ if (!skipping_ivar_name(id, "") && UNLIKELY(!++*(st_index_t *)a)) {
rb_raise(rb_eRuntimeError, "too many instance variables");
}
return ST_CONTINUE;
@@ -717,28 +728,9 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
static void
w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
{
- shape_id_t shape_id = rb_shape_get_shape_id(arg->obj);
struct w_ivar_arg ivarg = {arg, num};
if (!num) return;
- rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
-
- if (shape_id != rb_shape_get_shape_id(arg->obj)) {
- rb_shape_t * expected_shape = rb_shape_get_shape_by_id(shape_id);
- rb_shape_t * actual_shape = rb_shape_get_shape(arg->obj);
-
- // If the shape tree got _shorter_ then we probably removed an IV
- // If the shape tree got longer, then we probably added an IV.
- // The exception message might not be accurate when someone adds and
- // removes the same number of IVs, but they will still get an exception
- if (rb_shape_depth(expected_shape) > rb_shape_depth(actual_shape)) {
- rb_raise(rb_eRuntimeError, "instance variable removed from %"PRIsVALUE" instance",
- CLASS_OF(arg->obj));
- }
- else {
- rb_raise(rb_eRuntimeError, "instance variable added to %"PRIsVALUE" instance",
- CLASS_OF(arg->obj));
- }
- }
+ rb_ivar_foreach_buffered(obj, w_obj_each, (st_data_t)&ivarg);
}
static void
@@ -902,6 +894,9 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
st_index_t hasiv2;
VALUE encname2;
+ if (arg->userdefs && st_is_member(arg->userdefs, (st_data_t)obj)) {
+ rb_raise(rb_eRuntimeError, "can't dump recursive object using _dump()");
+ }
v = INT2NUM(limit);
v = dump_funcall(arg, obj, s_dump, 1, &v);
if (!RB_TYPE_P(v, T_STRING)) {
@@ -918,7 +913,13 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
w_class(TYPE_USERDEF, obj, arg, FALSE);
w_bytes(RSTRING_PTR(v), RSTRING_LEN(v), arg);
if (hasiv) {
+ st_data_t userdefs = (st_data_t)obj;
+ if (!arg->userdefs) {
+ arg->userdefs = rb_init_identtable();
+ }
+ st_add_direct(arg->userdefs, userdefs, 0);
w_ivar(hasiv, ivobj, encname, &c_arg);
+ st_delete(arg->userdefs, &userdefs, NULL);
}
w_remember(obj, arg);
return;
@@ -929,8 +930,9 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
hasiv = has_ivars(obj, (encname = encoding_name(obj, arg)), &ivobj);
{
st_data_t compat_data;
- rb_alloc_func_t allocator = rb_get_alloc_func(RBASIC(obj)->klass);
- if (st_lookup(compat_allocator_tbl,
+ VALUE klass = CLASS_OF(obj);
+ rb_alloc_func_t allocator = RCLASS_SINGLETON_P(klass) ? 0 : rb_get_alloc_func(klass);
+ if (allocator && st_lookup(compat_allocator_tbl,
(st_data_t)allocator,
&compat_data)) {
marshal_compat_t *compat = (marshal_compat_t*)compat_data;
@@ -950,19 +952,23 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
if (FL_TEST(obj, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton class can't be dumped");
}
- w_byte(TYPE_CLASS, arg);
{
VALUE path = class2path(obj);
+ VALUE encname = w_encivar(path, arg);
+ w_byte(TYPE_CLASS, arg);
w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+ w_encname(encname, arg);
RB_GC_GUARD(path);
}
break;
case T_MODULE:
- w_byte(TYPE_MODULE, arg);
{
VALUE path = class2path(obj);
+ VALUE encname = w_encivar(path, arg);
+ w_byte(TYPE_MODULE, arg);
w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+ w_encname(encname, arg);
RB_GC_GUARD(path);
}
break;
@@ -1063,7 +1069,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
case T_STRUCT:
w_class(TYPE_STRUCT, obj, arg, TRUE);
{
- long len = RSTRUCT_LEN(obj);
+ long len = RSTRUCT_LEN_RAW(obj);
VALUE mem;
long i;
@@ -1071,7 +1077,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
mem = rb_struct_members(obj);
for (i=0; i<len; i++) {
w_symbol(RARRAY_AREF(mem, i), arg);
- w_object(RSTRUCT_GET(obj, i), arg, limit);
+ w_object(RSTRUCT_GET_RAW(obj, i), arg, limit);
}
}
break;
@@ -1125,6 +1131,10 @@ clear_dump_arg(struct dump_arg *arg)
st_free_table(arg->encodings);
arg->encodings = 0;
}
+ if (arg->userdefs) {
+ st_free_table(arg->userdefs);
+ arg->userdefs = 0;
+ }
}
NORETURN(static inline void io_needed(void));
@@ -1164,7 +1174,7 @@ io_needed(void)
* * anonymous Class/Module.
* * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
* and so on)
- * * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread,
+ * * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
* ThreadGroup, Continuation
* * objects which define singleton methods
*/
@@ -1202,6 +1212,7 @@ rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
arg->num_entries = 0;
arg->compat_tbl = 0;
arg->encodings = 0;
+ arg->userdefs = 0;
arg->str = rb_str_buf_new(0);
if (!NIL_P(port)) {
if (!rb_respond_to(port, s_write)) {
@@ -1231,6 +1242,7 @@ rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
struct load_arg {
VALUE src;
char *buf;
+ long bufsize;
long buflen;
long readable;
long offset;
@@ -1272,19 +1284,24 @@ static void
free_load_arg(void *ptr)
{
clear_load_arg(ptr);
- xfree(ptr);
}
static size_t
memsize_load_arg(const void *ptr)
{
- return sizeof(struct load_arg);
+ const struct load_arg *p = (struct load_arg *)ptr;
+ size_t memsize = 0;
+ if (p->symbols) memsize += rb_st_memsize(p->symbols);
+ if (p->data) memsize += rb_st_memsize(p->data);
+ if (p->partial_objects) memsize += rb_st_memsize(p->partial_objects);
+ if (p->compat_tbl) memsize += rb_st_memsize(p->compat_tbl);
+ return memsize;
}
static const rb_data_type_t load_arg_data = {
"load_arg",
{mark_load_arg, free_load_arg, memsize_load_arg,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
#define r_entry(v, arg) r_entry0((v), (arg)->data->num_entries, (arg))
@@ -1311,15 +1328,23 @@ static unsigned char
r_byte1_buffered(struct load_arg *arg)
{
if (arg->buflen == 0) {
- long readable = arg->readable < BUFSIZ ? arg->readable : BUFSIZ;
+ long readable = arg->readable < arg->bufsize ? arg->readable : arg->bufsize;
+ long read_len;
VALUE str, n = LONG2NUM(readable);
str = load_funcall(arg, arg->src, s_read, 1, &n);
if (NIL_P(str)) too_short();
StringValue(str);
- memcpy(arg->buf, RSTRING_PTR(str), RSTRING_LEN(str));
+ read_len = RSTRING_LEN(str);
+ if (UNLIKELY(read_len < readable)) too_short();
+ if (UNLIKELY(read_len > arg->bufsize)) {
+ arg->buf = ruby_sized_realloc_n(arg->buf, read_len, 1, arg->bufsize);
+ arg->bufsize = read_len;
+ }
+ memcpy(arg->buf, RSTRING_PTR(str), read_len);
arg->offset = 0;
- arg->buflen = RSTRING_LEN(str);
+ arg->buflen = read_len;
+ RB_GC_GUARD(str);
}
arg->buflen--;
return arg->buf[arg->offset++];
@@ -1397,7 +1422,7 @@ long
ruby_marshal_read_long(const char **buf, long len)
{
long x;
- struct RString src;
+ struct RString src = {RBASIC_INIT};
struct load_arg arg;
memset(&arg, 0, sizeof(arg));
arg.src = rb_setup_fake_str(&src, *buf, len, 0);
@@ -1406,6 +1431,18 @@ ruby_marshal_read_long(const char **buf, long len)
return x;
}
+static long
+r_keep_readable(struct load_arg *arg, long len, size_t size)
+{
+ if (UNLIKELY(len < 0)) {
+ rb_raise(rb_eArgError, "negative length");
+ }
+ if (UNLIKELY((unsigned long)len > SIZE_MAX / size || arg->readable >= LONG_MAX - len)) {
+ rb_raise(rb_eArgError, "marshaled data too big");
+ }
+ return len;
+}
+
static VALUE
r_bytes1(long len, struct load_arg *arg)
{
@@ -1435,7 +1472,7 @@ r_bytes1_buffered(long len, struct load_arg *arg)
long tmp_len, read_len, need_len = len - buflen;
VALUE tmp, n;
- readable = readable < BUFSIZ ? readable : BUFSIZ;
+ readable = readable < arg->bufsize ? readable : arg->bufsize;
read_len = need_len > readable ? need_len : readable;
n = LONG2NUM(read_len);
tmp = load_funcall(arg, arg->src, s_read, 1, &n);
@@ -1501,7 +1538,7 @@ name_equal(const char *name, size_t nlen, const char *p, long l)
static int
sym2encidx(VALUE sym, VALUE val)
{
- static const char name_encoding[8] = "encoding";
+ RBIMPL_ATTR_NONSTRING() static const char name_encoding[8] = "encoding";
const char *p;
long l;
if (rb_enc_get_index(sym) != ENCINDEX_US_ASCII) return -1;
@@ -1673,10 +1710,9 @@ r_leave(VALUE v, struct load_arg *arg, bool partial)
}
static int
-copy_ivar_i(st_data_t key, st_data_t val, st_data_t arg)
+copy_ivar_i(ID vid, VALUE value, st_data_t arg)
{
- VALUE obj = (VALUE)arg, value = (VALUE)val;
- ID vid = (ID)key;
+ VALUE obj = (VALUE)arg;
if (!rb_ivar_defined(obj, vid))
rb_ivar_set(obj, vid, value);
@@ -1690,6 +1726,42 @@ r_copy_ivar(VALUE v, VALUE data)
return v;
}
+#define override_ivar_error(type, str) \
+ rb_raise(rb_eTypeError, \
+ "can't override instance variable of "type" '%"PRIsVALUE"'", \
+ (str))
+
+static int
+r_ivar_encoding(VALUE obj, struct load_arg *arg, VALUE sym, VALUE val)
+{
+ int idx = sym2encidx(sym, val);
+ if (idx >= 0) {
+ if (rb_enc_capable(obj)) {
+ // Check if needed to avoid rb_check_frozen() check for Regexps
+ if (rb_enc_get_index(obj) != idx) {
+ rb_enc_associate_index(obj, idx);
+ }
+ }
+ else {
+ rb_raise(rb_eArgError, "%"PRIsVALUE" is not enc_capable", obj);
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static long
+r_encname(VALUE obj, struct load_arg *arg)
+{
+ long len = r_long(arg);
+ if (len > 0) {
+ VALUE sym = r_symbol(arg);
+ VALUE val = r_object(arg);
+ len -= r_ivar_encoding(obj, arg, sym, val);
+ }
+ return len;
+}
+
static void
r_ivar(VALUE obj, int *has_encoding, struct load_arg *arg)
{
@@ -1697,17 +1769,16 @@ r_ivar(VALUE obj, int *has_encoding, struct load_arg *arg)
len = r_long(arg);
if (len > 0) {
+ if (RB_TYPE_P(obj, T_MODULE)) {
+ override_ivar_error("module", rb_mod_name(obj));
+ }
+ else if (RB_TYPE_P(obj, T_CLASS)) {
+ override_ivar_error("class", rb_class_name(obj));
+ }
do {
VALUE sym = r_symbol(arg);
VALUE val = r_object(arg);
- int idx = sym2encidx(sym, val);
- if (idx >= 0) {
- if (rb_enc_capable(obj)) {
- rb_enc_associate_index(obj, idx);
- }
- else {
- rb_raise(rb_eArgError, "%"PRIsVALUE" is not enc_capable", obj);
- }
+ if (r_ivar_encoding(obj, arg, sym, val)) {
if (has_encoding) *has_encoding = TRUE;
}
else if (symname_equal_lit(sym, name_s_ruby2_keywords_flag)) {
@@ -1789,36 +1860,20 @@ append_extmod(VALUE obj, VALUE extmod)
#define prohibit_ivar(type, str) do { \
if (!ivp || !*ivp) break; \
- rb_raise(rb_eTypeError, \
- "can't override instance variable of "type" `%"PRIsVALUE"'", \
- (str)); \
+ override_ivar_error(type, str); \
} while (0)
-static VALUE r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int type);
+static VALUE r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE klass, VALUE extmod, int type);
static VALUE
r_object0(struct load_arg *arg, bool partial, int *ivp, VALUE extmod)
{
int type = r_byte(arg);
- return r_object_for(arg, partial, ivp, extmod, type);
-}
-
-static int
-r_move_ivar(st_data_t k, st_data_t v, st_data_t d)
-{
- ID key = (ID)k;
- VALUE value = (VALUE)v;
- VALUE dest = (VALUE)d;
-
- if (rb_is_instance_id(key)) {
- rb_ivar_set(dest, key, value);
- return ST_DELETE;
- }
- return ST_CONTINUE;
+ return r_object_for(arg, partial, ivp, 0, extmod, type);
}
static VALUE
-r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int type)
+r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE klass, VALUE extmod, int type)
{
VALUE (*hash_new_with_size)(st_index_t) = rb_hash_new_with_size;
VALUE v = Qnil;
@@ -1833,6 +1888,9 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
}
v = (VALUE)link;
if (!st_lookup(arg->partial_objects, (st_data_t)v, &link)) {
+ if (arg->freeze && RB_TYPE_P(v, T_STRING)) {
+ v = rb_str_to_interned_str(v);
+ }
v = r_post_proc(v, arg);
}
break;
@@ -1891,13 +1949,13 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
}
type = r_byte(arg);
if ((c == rb_cHash) &&
- /* Hack for compare_by_identify */
+ /* Hack for compare_by_identity */
(type == TYPE_HASH || type == TYPE_HASH_DEF)) {
hash_new_with_size = rb_ident_hash_new_with_size;
goto type_hash;
}
- v = r_object_for(arg, partial, 0, extmod, type);
- if (rb_special_const_p(v) || RB_TYPE_P(v, T_OBJECT) || RB_TYPE_P(v, T_CLASS)) {
+ v = r_object_for(arg, partial, 0, c, extmod, type);
+ if (RB_SPECIAL_CONST_P(v) || RB_TYPE_P(v, T_OBJECT) || RB_TYPE_P(v, T_CLASS)) {
goto format_error;
}
if (RB_TYPE_P(v, T_MODULE) || !RTEST(rb_class_inherited_p(c, RBASIC(v)->klass))) {
@@ -1968,7 +2026,10 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
int sign;
sign = r_byte(arg);
- len = r_long(arg);
+ if (sign != '+' && sign != '-') {
+ rb_raise(rb_eArgError, "invalid Bignum sign");
+ }
+ len = r_keep_readable(arg, r_long(arg), 2);
if (SIZEOF_VALUE >= 8 && len <= 4) {
// Representable within uintptr, likely FIXNUM
@@ -2033,8 +2094,11 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
}
rb_str_set_len(str, dst - ptr);
}
- VALUE regexp = rb_reg_new_str(str, options);
- rb_ivar_foreach(str, r_move_ivar, regexp);
+ if (!klass) {
+ klass = rb_cRegexp;
+ }
+ VALUE regexp = rb_reg_init_str(rb_reg_s_alloc(klass), str, options);
+ r_copy_ivar(regexp, str);
v = r_entry0(regexp, idx, arg);
v = r_leave(v, arg, partial);
@@ -2043,7 +2107,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
case TYPE_ARRAY:
{
- long len = r_long(arg);
+ long len = r_keep_readable(arg, r_long(arg), 1);
v = rb_ary_new2(len);
v = r_entry(v, arg);
@@ -2061,7 +2125,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
case TYPE_HASH_DEF:
type_hash:
{
- long len = r_long(arg);
+ long len = r_keep_readable(arg, r_long(arg), 2);
v = hash_new_with_size(len);
v = r_entry(v, arg);
@@ -2087,7 +2151,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
VALUE slot;
st_index_t idx = r_prepare(arg);
VALUE klass = path2class(r_unique(arg));
- long len = r_long(arg);
+ long len = r_keep_readable(arg, r_long(arg), 2);
v = rb_obj_alloc(klass);
if (!RB_TYPE_P(v, T_STRUCT)) {
@@ -2141,7 +2205,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
st_data_t d;
if (!rb_obj_respond_to(klass, s_load, TRUE)) {
- rb_raise(rb_eTypeError, "class %"PRIsVALUE" needs to have method `_load'",
+ rb_raise(rb_eTypeError, "class %"PRIsVALUE" needs to have method '_load'",
name);
}
data = r_string(arg);
@@ -2155,7 +2219,12 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
marshal_compat_t *compat = (marshal_compat_t*)d;
v = compat->loader(klass, v);
}
- if (!partial) v = r_post_proc(v, arg);
+ if (!partial) {
+ if (arg->freeze) {
+ OBJ_FREEZE(v);
+ }
+ v = r_post_proc(v, arg);
+ }
}
break;
@@ -2172,7 +2241,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
append_extmod(v, extmod);
}
if (!rb_obj_respond_to(v, s_mload, TRUE)) {
- rb_raise(rb_eTypeError, "instance of %"PRIsVALUE" needs to have method `marshal_load'",
+ rb_raise(rb_eTypeError, "instance of %"PRIsVALUE" needs to have method 'marshal_load'",
name);
}
v = r_entry(v, arg);
@@ -2180,6 +2249,9 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
load_funcall(arg, v, s_mload, 1, &data);
v = r_fixup_compat(v, arg);
v = r_copy_ivar(v, data);
+ if (arg->freeze) {
+ OBJ_FREEZE(v);
+ }
v = r_post_proc(v, arg);
if (!NIL_P(extmod)) {
if (oldclass) append_extmod(v, extmod);
@@ -2215,7 +2287,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
v = r_entry(v, arg);
if (!rb_obj_respond_to(v, s_load_data, TRUE)) {
rb_raise(rb_eTypeError,
- "class %"PRIsVALUE" needs to have instance method `_load_data'",
+ "class %"PRIsVALUE" needs to have instance method '_load_data'",
name);
}
r = r_object0(arg, partial, 0, extmod);
@@ -2239,6 +2311,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
{
VALUE str = r_bytes(arg);
+ if (ivp && *ivp > 0) *ivp = r_encname(str, arg) > 0;
v = path2class(str);
prohibit_ivar("class", str);
v = r_entry(v, arg);
@@ -2250,6 +2323,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
{
VALUE str = r_bytes(arg);
+ if (ivp && *ivp > 0) *ivp = r_encname(str, arg) > 0;
v = path2module(str);
prohibit_ivar("module", str);
v = r_entry(v, arg);
@@ -2294,10 +2368,9 @@ r_object(struct load_arg *arg)
static void
clear_load_arg(struct load_arg *arg)
{
- if (arg->buf) {
- xfree(arg->buf);
- arg->buf = 0;
- }
+ ruby_xfree_sized(arg->buf, arg->bufsize);
+ arg->buf = NULL;
+ arg->bufsize = 0;
arg->buflen = 0;
arg->offset = 0;
arg->readable = 0;
@@ -2343,10 +2416,14 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc, bool freeze)
arg->readable = 0;
arg->freeze = freeze;
- if (NIL_P(v))
+ if (NIL_P(v)) {
+ arg->bufsize = BUFSIZ;
arg->buf = xmalloc(BUFSIZ);
- else
+ }
+ else {
+ arg->bufsize = 0;
arg->buf = 0;
+ }
major = r_byte(arg);
minor = r_byte(arg);
@@ -2517,16 +2594,61 @@ Init_marshal(void)
rb_define_const(rb_mMarshal, "MINOR_VERSION", INT2FIX(MARSHAL_MINOR));
}
+static int
+marshal_compat_table_mark_and_move_i(st_data_t key, st_data_t value, st_data_t _)
+{
+ marshal_compat_t *p = (marshal_compat_t *)value;
+ rb_gc_mark_and_move(&p->newclass);
+ rb_gc_mark_and_move(&p->oldclass);
+ return ST_CONTINUE;
+}
+
+static void
+marshal_compat_table_mark_and_move(void *tbl)
+{
+ if (!tbl) return;
+ st_foreach(tbl, marshal_compat_table_mark_and_move_i, 0);
+}
+
+static int
+marshal_compat_table_free_i(st_data_t key, st_data_t value, st_data_t _)
+{
+ SIZED_FREE((marshal_compat_t *)value);
+ return ST_CONTINUE;
+}
+
+static void
+marshal_compat_table_free(void *data)
+{
+ st_foreach(data, marshal_compat_table_free_i, 0);
+ st_free_table(data);
+}
+
+static size_t
+marshal_compat_table_memsize(const void *data)
+{
+ return st_memsize(data) + sizeof(marshal_compat_t) * st_table_size(data);
+}
+
+static const rb_data_type_t marshal_compat_type = {
+ .wrap_struct_name = "marshal_compat_table",
+ .function = {
+ .dmark = marshal_compat_table_mark_and_move,
+ .dfree = marshal_compat_table_free,
+ .dsize = marshal_compat_table_memsize,
+ .dcompact = marshal_compat_table_mark_and_move,
+ },
+ .flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
static st_table *
compat_allocator_table(void)
{
if (compat_allocator_tbl) return compat_allocator_tbl;
compat_allocator_tbl = st_init_numtable();
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
compat_allocator_tbl_wrapper =
- Data_Wrap_Struct(0, mark_marshal_compat_t, 0, compat_allocator_tbl);
- rb_gc_register_mark_object(compat_allocator_tbl_wrapper);
+ TypedData_Wrap_Struct(0, &marshal_compat_type, compat_allocator_tbl);
+ rb_vm_register_global_object(compat_allocator_tbl_wrapper);
return compat_allocator_tbl;
}
diff --git a/math.c b/math.c
index 67bf8b7b63..852620da20 100644
--- a/math.c
+++ b/math.c
@@ -15,7 +15,6 @@
# define _USE_MATH_DEFINES 1
#endif
-#include <errno.h>
#include <float.h>
#include <math.h>
@@ -170,6 +169,12 @@ math_tan(VALUE unused_obj, VALUE x)
return DBL2NUM(tan(Get_Double(x)));
}
+#define math_arc(num, func) \
+ double d; \
+ d = Get_Double((num)); \
+ domain_check_range(d, -1.0, 1.0, #func); \
+ return DBL2NUM(func(d));
+
/*
* call-seq:
* Math.acos(x) -> float
@@ -190,11 +195,7 @@ math_tan(VALUE unused_obj, VALUE x)
static VALUE
math_acos(VALUE unused_obj, VALUE x)
{
- double d;
-
- d = Get_Double(x);
- domain_check_range(d, -1.0, 1.0, "acos");
- return DBL2NUM(acos(d));
+ math_arc(x, acos)
}
/*
@@ -217,11 +218,7 @@ math_acos(VALUE unused_obj, VALUE x)
static VALUE
math_asin(VALUE unused_obj, VALUE x)
{
- double d;
-
- d = Get_Double(x);
- domain_check_range(d, -1.0, 1.0, "asin");
- return DBL2NUM(asin(d));
+ math_arc(x, asin)
}
/*
@@ -460,6 +457,34 @@ math_exp(VALUE unused_obj, VALUE x)
return DBL2NUM(exp(Get_Double(x)));
}
+/*
+ * call-seq:
+ * Math.expm1(x) -> float
+ *
+ * Returns "exp(x) - 1", +e+ raised to the +x+ power, minus 1.
+ *
+ *
+ * - Domain: <tt>[-INFINITY, INFINITY]</tt>.
+ * - Range: <tt>[-1.0, INFINITY]</tt>.
+ *
+ * Examples:
+ *
+ * expm1(-INFINITY) # => 0.0
+ * expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
+ * expm1(0.0) # => 0.0
+ * expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
+ * expm1(1.0) # => 1.718281828459045 # E - 1
+ * expm1(2.0) # => 6.38905609893065 # E**2 - 1
+ * expm1(INFINITY) # => Infinity
+ *
+ */
+
+static VALUE
+math_expm1(VALUE unused_obj, VALUE x)
+{
+ return DBL2NUM(expm1(Get_Double(x)));
+}
+
#if defined __CYGWIN__
# include <cygwin/version.h>
# if CYGWIN_VERSION_DLL_MAJOR < 1005
@@ -476,7 +501,6 @@ math_exp(VALUE unused_obj, VALUE x)
# define M_LN10 2.30258509299404568401799145468436421
#endif
-static double math_log1(VALUE x);
FUNC_MINIMIZED(static VALUE math_log(int, const VALUE *, VALUE));
/*
@@ -511,20 +535,6 @@ math_log(int argc, const VALUE *argv, VALUE unused_obj)
return rb_math_log(argc, argv);
}
-VALUE
-rb_math_log(int argc, const VALUE *argv)
-{
- VALUE x, base;
- double d;
-
- rb_scan_args(argc, argv, "11", &x, &base);
- d = math_log1(x);
- if (argc == 2) {
- d /= math_log1(base);
- }
- return DBL2NUM(d);
-}
-
static double
get_double_rshift(VALUE x, size_t *pnumbits)
{
@@ -543,16 +553,51 @@ get_double_rshift(VALUE x, size_t *pnumbits)
}
static double
-math_log1(VALUE x)
+math_log_split(VALUE x, size_t *numbits)
{
- size_t numbits;
- double d = get_double_rshift(x, &numbits);
+ double d = get_double_rshift(x, numbits);
domain_check_min(d, 0.0, "log");
- /* check for pole error */
- if (d == 0.0) return -HUGE_VAL;
+ return d;
+}
+
+#if defined(log2) || defined(HAVE_LOG2)
+# define log_intermediate log2
+#else
+# define log_intermediate log10
+double log2(double x);
+#endif
+
+VALUE
+rb_math_log(int argc, const VALUE *argv)
+{
+ VALUE x, base;
+ double d;
+ size_t numbits;
- return log(d) + numbits * M_LN2; /* log(d * 2 ** numbits) */
+ argc = rb_scan_args(argc, argv, "11", &x, &base);
+ d = math_log_split(x, &numbits);
+ if (argc == 2) {
+ size_t numbits_2;
+ double b = math_log_split(base, &numbits_2);
+ /* check for pole error */
+ if (d == 0.0) {
+ // Already DomainError if b < 0.0
+ return b ? DBL2NUM(-HUGE_VAL) : DBL2NUM(NAN);
+ }
+ else if (b == 0.0) {
+ return DBL2NUM(-0.0);
+ }
+ d = log_intermediate(d) / log_intermediate(b);
+ d += (numbits - numbits_2) / log2(b);
+ }
+ else {
+ /* check for pole error */
+ if (d == 0.0) return DBL2NUM(-HUGE_VAL);
+ d = log(d);
+ d += numbits * M_LN2;
+ }
+ return DBL2NUM(d);
}
#ifndef log2
@@ -629,6 +674,47 @@ math_log10(VALUE unused_obj, VALUE x)
return DBL2NUM(log10(d) + numbits * log10(2)); /* log10(d * 2 ** numbits) */
}
+/*
+ * call-seq:
+ * Math.log1p(x) -> float
+ *
+ * Returns "log(x + 1)", the base E {logarithm}[https://en.wikipedia.org/wiki/Logarithm] of (+x+ + 1).
+ *
+ * - Domain: <tt>[-1, INFINITY]</tt>.
+ * - Range: <tt>[-INFINITY, INFINITY]</tt>.
+ *
+ * Examples:
+ *
+ * log1p(-1.0) # => -Infinity
+ * log1p(0.0) # => 0.0
+ * log1p(E - 1) # => 1.0
+ * log1p(INFINITY) # => Infinity
+ *
+ */
+
+static VALUE
+math_log1p(VALUE unused_obj, VALUE x)
+{
+ size_t numbits;
+ double d = get_double_rshift(x, &numbits);
+
+ if (numbits != 0) {
+ x = rb_big_plus(x, INT2FIX(1));
+ d = math_log_split(x, &numbits);
+ /* check for pole error */
+ if (d == 0.0) return DBL2NUM(-HUGE_VAL);
+ d = log(d);
+ d += numbits * M_LN2;
+ return DBL2NUM(d);
+ }
+
+ domain_check_min(d, -1.0, "log1p");
+ /* check for pole error */
+ if (d == -1.0) return DBL2NUM(-HUGE_VAL);
+
+ return DBL2NUM(log1p(d)); /* log10(d * 2 ** numbits) */
+}
+
static VALUE rb_math_sqrt(VALUE x);
/*
@@ -713,7 +799,7 @@ rb_math_sqrt(VALUE x)
* cbrt(1.0) # => 1.0
* cbrt(0.0) # => 0.0
* cbrt(1.0) # => 1.0
- cbrt(2.0) # => 1.2599210498948732
+ * cbrt(2.0) # => 1.2599210498948732
* cbrt(8.0) # => 2.0
* cbrt(27.0) # => 3.0
* cbrt(INFINITY) # => Infinity
@@ -968,7 +1054,7 @@ math_gamma(VALUE unused_obj, VALUE x)
*
* [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
*
- * See {logarithmic gamma function}[https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function].
+ * See {log gamma function}[https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function].
*
* - Domain: <tt>(-INFINITY, INFINITY]</tt>.
* - Range of first element: <tt>(-INFINITY, INFINITY]</tt>.
@@ -1103,9 +1189,11 @@ InitVM_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, "expm1", math_expm1, 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, "log10", math_log10, 1);
+ rb_define_module_function(rb_mMath, "log1p", math_log1p, 1);
rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
rb_define_module_function(rb_mMath, "cbrt", math_cbrt, 1);
diff --git a/memory_view.c b/memory_view.c
index 3fb79202f9..2de756d681 100644
--- a/memory_view.c
+++ b/memory_view.c
@@ -51,11 +51,11 @@ exported_object_registry_mark(void *ptr)
static void
exported_object_registry_free(void *ptr)
{
- RB_VM_LOCK_ENTER();
- st_clear(exported_object_table);
- st_free_table(exported_object_table);
- exported_object_table = NULL;
- RB_VM_LOCK_LEAVE();
+ RB_VM_LOCKING() {
+ st_clear(exported_object_table);
+ st_free_table(exported_object_table);
+ exported_object_table = NULL;
+ }
}
const rb_data_type_t rb_memory_view_exported_object_registry_data_type = {
@@ -65,7 +65,7 @@ const rb_data_type_t rb_memory_view_exported_object_registry_data_type = {
exported_object_registry_free,
0,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static int
@@ -99,18 +99,19 @@ exported_object_dec_ref(st_data_t *key, st_data_t *val, st_data_t arg, int exist
static void
register_exported_object(VALUE obj)
{
- RB_VM_LOCK_ENTER();
- st_update(exported_object_table, (st_data_t)obj, exported_object_add_ref, 0);
- RB_VM_LOCK_LEAVE();
+ RB_VM_LOCKING() {
+ st_update(exported_object_table, (st_data_t)obj, exported_object_add_ref, 0);
+ RB_OBJ_WRITTEN(rb_memory_view_exported_object_registry, Qundef, obj);
+ }
}
static void
unregister_exported_object(VALUE obj)
{
- RB_VM_LOCK_ENTER();
- if (exported_object_table)
- st_update(exported_object_table, (st_data_t)obj, exported_object_dec_ref, 0);
- RB_VM_LOCK_LEAVE();
+ RB_VM_LOCKING() {
+ if (exported_object_table)
+ st_update(exported_object_table, (st_data_t)obj, exported_object_dec_ref, 0);
+ }
}
// MemoryView
@@ -845,9 +846,7 @@ rb_memory_view_release(rb_memory_view_t* view)
if (rv) {
unregister_exported_object(view->obj);
view->obj = Qnil;
- if (view->item_desc.components) {
- xfree((void *)view->item_desc.components);
- }
+ SIZED_FREE_N((rb_memory_view_item_component_t *)view->item_desc.components, view->item_desc.length);
}
return rv;
}
@@ -865,7 +864,7 @@ Init_MemoryView(void)
VALUE obj = TypedData_Wrap_Struct(
0, &rb_memory_view_exported_object_registry_data_type,
exported_object_table);
- rb_gc_register_mark_object(obj);
+ rb_vm_register_global_object(obj);
rb_memory_view_exported_object_registry = obj;
id_memory_view = rb_intern_const("__memory_view__");
diff --git a/method.h b/method.h
index d33ab5053c..fdbab41cf7 100644
--- a/method.h
+++ b/method.h
@@ -15,6 +15,7 @@
#include "internal/imemo.h"
#include "internal/compilers.h"
#include "internal/static_assert.h"
+#include "ruby/atomic.h"
#ifndef END_OF_ENUMERATION
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
@@ -72,11 +73,18 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
-#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
static inline void
+METHOD_ENTRY_CACHED_SET(rb_callable_method_entry_t *me)
+{
+ if (!METHOD_ENTRY_CACHED(me)) {
+ me->flags |= IMEMO_FL_USER4;
+ }
+}
+
+static inline void
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
{
VM_ASSERT((int)visi >= 0 && visi <= 3);
@@ -101,8 +109,9 @@ static inline void
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
{
dst->flags =
- (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2
+ |IMEMO_FL_USER3)) |
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3));
}
typedef enum {
@@ -135,8 +144,9 @@ typedef struct rb_method_iseq_struct {
rb_cref_t * cref; /*!< class reference, should be marked */
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
+typedef VALUE (*rb_cfunc_t)(ANYARGS);
typedef struct rb_method_cfunc_struct {
- VALUE (*func)(ANYARGS);
+ rb_cfunc_t func;
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
int argc;
} rb_method_cfunc_t;
@@ -152,13 +162,12 @@ typedef struct rb_method_alias_struct {
typedef struct rb_method_refined_struct {
struct rb_method_entry_struct * orig_me;
- VALUE owner;
} rb_method_refined_t;
typedef struct rb_method_bmethod_struct {
VALUE proc; /* should be marked */
- struct rb_hook_list_struct *hooks;
- VALUE defined_ractor;
+ rb_serial_t defined_ractor_id;
+ unsigned int local_hooks_cnt;
} rb_method_bmethod_t;
enum method_optimized_type {
@@ -178,9 +187,10 @@ typedef struct rb_method_optimized {
struct rb_method_definition_struct {
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
unsigned int iseq_overload: 1;
- int alias_count : 27;
- int complemented_count : 28;
unsigned int no_redef_warning: 1;
+ unsigned int aliased : 1;
+
+ rb_atomic_t reference_count;
union {
rb_method_iseq_t iseq;
@@ -194,12 +204,15 @@ struct rb_method_definition_struct {
ID original_id;
uintptr_t method_serial;
+ const rb_box_t *box;
};
struct rb_id_table;
+struct rb_ractor_struct;
+struct rb_hook_list_struct;
typedef struct rb_method_definition_struct rb_method_definition_t;
-STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
+STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body) <= 8);
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
#define UNDEFINED_REFINED_METHOD_P(def) \
@@ -213,7 +226,7 @@ void rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type, un
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
-rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
+rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def);
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
@@ -236,6 +249,7 @@ st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
VALUE rb_method_entry_location(const rb_method_entry_t *me);
+void rb_free_method_entry_vm_weak_references(const rb_method_entry_t *me);
void rb_free_method_entry(const rb_method_entry_t *me);
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
@@ -243,12 +257,19 @@ const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
+void rb_method_table_insert0(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me, bool iclass_shared_mtbl);
void rb_scope_visibility_set(rb_method_visibility_t);
VALUE rb_unnamed_parameters(int arity);
+void rb_vm_insert_cc_refinement(const struct rb_callcache *cc);
+
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
-void rb_clear_method_cache_all(void);
+void rb_clear_all_refinement_method_cache(void);
+void rb_invalidate_method_caches(struct rb_id_table *cm_tbl, VALUE cc_tbl);
+struct rb_hook_list_struct *rb_method_def_local_hooks(rb_method_definition_t *def, struct rb_ractor_struct *cr, bool create);
+void rb_method_definition_addref(rb_method_definition_t *def);
+void rb_method_definition_release(rb_method_definition_t *def);
#endif /* RUBY_METHOD_H */
diff --git a/mini_builtin.c b/mini_builtin.c
index 1818f18cba..75ea94d37d 100644
--- a/mini_builtin.c
+++ b/mini_builtin.c
@@ -1,60 +1,98 @@
#include "internal.h"
#include "internal/array.h"
+#include "internal/eval.h"
#include "iseq.h"
#include "vm_core.h"
#include "builtin.h"
#include "miniprelude.c"
-// included from miniinit.c
+static VALUE
+prelude_ast_value(VALUE name, VALUE code, int line)
+{
+ rb_ast_t *ast;
+ VALUE ast_value = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
+ ast = rb_ruby_ast_data_get(ast_value);
+ if (!ast || !ast->body.root) {
+ if (ast) rb_ast_dispose(ast);
+ rb_exc_raise(rb_errinfo());
+ }
+ return ast_value;
+}
-#ifndef INCLUDED_BY_BUILTIN_C
-static struct st_table *loaded_builtin_table;
-#endif
+static void
+pm_prelude_load(pm_parse_result_t *result, VALUE name, VALUE code, int line)
+{
+ pm_parse_result_init(result);
+ pm_options_line_set(result->options, line);
+ VALUE error = pm_parse_string(result, code, name, NULL);
-rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
+ if (!NIL_P(error)) {
+ pm_parse_result_free(result);
+ rb_exc_raise(error);
+ }
+}
static const rb_iseq_t *
builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *table)
{
VALUE name_str = 0;
- rb_ast_t *ast = rb_builtin_ast(feature_name, &name_str);
- rb_vm_t *vm = GET_VM();
-
- if (!ast) {
+ int start_line;
+ const rb_iseq_t *iseq;
+ VALUE code = rb_builtin_find(feature_name, &name_str, &start_line);
+ if (NIL_P(code)) {
rb_fatal("builtin_iseq_load: can not find %s; "
"probably miniprelude.c is out of date",
feature_name);
}
- vm->builtin_function_table = table;
- vm->builtin_inline_index = 0;
+
+ rb_vm_t *vm = GET_VM();
static const rb_compile_option_t optimization = {
- TRUE, /* int inline_const_cache; */
- TRUE, /* int peephole_optimization; */
- FALSE,/* int tailcall_optimization; */
- TRUE, /* int specialized_instruction; */
- TRUE, /* int operands_unification; */
- TRUE, /* int instructions_unification; */
- TRUE, /* int stack_caching; */
- TRUE, /* int frozen_string_literal; */
- FALSE, /* int debug_frozen_string_literal; */
- FALSE, /* unsigned int coverage_enabled; */
- 0, /* int debug_level; */
+ .inline_const_cache = TRUE,
+ .peephole_optimization = TRUE,
+ .tailcall_optimization = FALSE,
+ .specialized_instruction = TRUE,
+ .operands_unification = TRUE,
+ .instructions_unification = TRUE,
+ .frozen_string_literal = TRUE,
+ .debug_frozen_string_literal = FALSE,
+ .coverage_enabled = FALSE,
+ .debug_level = 0,
};
- const rb_iseq_t *iseq = rb_iseq_new_with_opt(&ast->body, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization);
- GET_VM()->builtin_function_table = NULL;
- rb_ast_dispose(ast);
+ if (rb_ruby_prism_p()) {
+ pm_parse_result_t result;
+ pm_prelude_load(&result, name_str, code, start_line);
+
+ vm->builtin_function_table = table;
+ int error_state;
+ iseq = pm_iseq_new_with_opt(&result.node, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization, &error_state);
+
+ vm->builtin_function_table = NULL;
+ pm_parse_result_free(&result);
+
+ if (error_state) {
+ RUBY_ASSERT(iseq == NULL);
+ rb_jump_tag(error_state);
+ }
+ }
+ else {
+ VALUE ast_value = prelude_ast_value(name_str, code, start_line);
+ rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
+
+ vm->builtin_function_table = table;
+ iseq = rb_iseq_new_with_opt(ast_value, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization, Qnil);
+
+ vm->builtin_function_table = NULL;
+ rb_ast_dispose(ast);
+ }
// for debug
if (0 && strcmp("prelude", feature_name) == 0) {
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
}
-#ifndef INCLUDED_BY_BUILTIN_C
- st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
- rb_gc_register_mark_object((VALUE)iseq);
-#endif
+ BUILTIN_LOADED(feature_name, iseq);
return iseq;
}
@@ -63,40 +101,18 @@ void
rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
{
const rb_iseq_t *iseq = builtin_iseq_load(feature_name, table);
- rb_iseq_eval(iseq);
-}
-
-#ifndef INCLUDED_BY_BUILTIN_C
-
-static int
-each_builtin_i(st_data_t key, st_data_t val, st_data_t dmy)
-{
- const char *feature = (const char *)key;
- const rb_iseq_t *iseq = (const rb_iseq_t *)val;
-
- rb_yield_values(2, rb_str_new2(feature), rb_iseqw_new(iseq));
-
- return ST_CONTINUE;
+ rb_iseq_eval(iseq, rb_root_box());
}
-static VALUE
-each_builtin(VALUE self)
+VALUE
+rb_define_gem_modules(VALUE _a, VALUE _b)
{
- st_foreach(loaded_builtin_table, each_builtin_i, 0);
+ // do nothing - moniruby doesn't load gem_prelude.rb.
return Qnil;
}
void
-Init_builtin(void)
-{
- rb_define_singleton_method(rb_cRubyVM, "each_builtin", each_builtin, 0);
- loaded_builtin_table = st_init_strtable();
-}
-
-void
-Init_builtin_features(void)
+rb_load_gem_prelude(VALUE _)
{
- // register for ruby
- builtin_iseq_load("gem_prelude", NULL);
+ // do nothing - miniruby doesn't support loading RubyGems.
}
-#endif
diff --git a/miniinit.c b/miniinit.c
index 2a14a0d1c5..b0adf9da2a 100644
--- a/miniinit.c
+++ b/miniinit.c
@@ -48,4 +48,62 @@ Init_enc(void)
rb_encdb_alias("ASCII", "US-ASCII");
}
+/* miniruby does not support dynamic loading. */
+void
+Init_ext(void)
+{
+}
+
+static void builtin_loaded(const char *feature_name, VALUE iseq);
+#define BUILTIN_LOADED(feature_name, iseq) builtin_loaded(feature_name, (VALUE)(iseq))
+
#include "mini_builtin.c"
+
+static struct st_table *loaded_builtin_table;
+
+static void
+builtin_loaded(const char *feature_name, VALUE iseq)
+{
+ st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
+ rb_vm_register_global_object(iseq);
+}
+
+static int
+each_builtin_i(st_data_t key, st_data_t val, st_data_t dmy)
+{
+ const char *feature = (const char *)key;
+ const rb_iseq_t *iseq = (const rb_iseq_t *)val;
+
+ rb_yield_values(2, rb_str_new2(feature), rb_iseqw_new(iseq));
+
+ return ST_CONTINUE;
+}
+
+/* :nodoc: */
+static VALUE
+each_builtin(VALUE self)
+{
+ st_foreach(loaded_builtin_table, each_builtin_i, 0);
+ return Qnil;
+}
+
+void
+Init_builtin(void)
+{
+ rb_define_singleton_method(rb_cRubyVM, "each_builtin", each_builtin, 0);
+ loaded_builtin_table = st_init_strtable();
+}
+
+void
+Init_builtin_features(void)
+{
+ // register for ruby
+ builtin_iseq_load("gem_prelude", NULL);
+}
+
+void
+rb_free_loaded_builtin_table(void)
+{
+ if (loaded_builtin_table)
+ st_free_table(loaded_builtin_table);
+}
diff --git a/misc/.vscode/settings.json b/misc/.vscode/settings.json
index b0f3576025..a2e4e1ec69 100644
--- a/misc/.vscode/settings.json
+++ b/misc/.vscode/settings.json
@@ -2,4 +2,9 @@
"rust-analyzer.cargo.features": [
"disasm",
],
+ "rust-analyzer.cfg.setTest": false,
+ // rust-analyzer bundled in the VSCode extension may only support Rust newer than 1.85.0.
+ // To avoid warnings, install rust-analyzer with `rustup component add rust-analyzer` and
+ // use `~/.cargo/bin/rust-analyzer` with the following config.
+ "rust-analyzer.server.path": "rust-analyzer",
}
diff --git a/misc/call_fuzzer.rb b/misc/call_fuzzer.rb
new file mode 100644
index 0000000000..c3f9f90490
--- /dev/null
+++ b/misc/call_fuzzer.rb
@@ -0,0 +1,372 @@
+require 'optparse'
+require 'set'
+
+# Number of iterations to test
+num_iters = 10_000
+
+# Parse the command-line options
+OptionParser.new do |opts|
+ opts.on("--num-iters=N") do |n|
+ num_iters = n.to_i
+ end
+end.parse!
+
+# Format large numbers with comma separators for readability
+def format_number(pad, number)
+ s = number.to_s
+ i = s.index('.') || s.size
+ s.insert(i -= 3, ',') while i > 3
+ s.rjust(pad, ' ')
+end
+
+# Wrap an integer to pass as argument
+# We use this so we can have some object arguments
+class IntWrapper
+ def initialize(v)
+ # Force the object to have a random shape
+ if rand() < 50
+ @v0 = 1
+ end
+ if rand() < 50
+ @v1 = 1
+ end
+ if rand() < 50
+ @v2 = 1
+ end
+ if rand() < 50
+ @v3 = 1
+ end
+ if rand() < 50
+ @v4 = 1
+ end
+ if rand() < 50
+ @v5 = 1
+ end
+ if rand() < 50
+ @v6 = 1
+ end
+
+ @value = v
+ end
+
+ attr_reader :value
+end
+
+# Generate a random argument value, integer or string or object
+def sample_arg()
+ c = ['int', 'string', 'object'].sample()
+
+ if c == 'int'
+ return rand(0...100)
+ end
+
+ if c == 'string'
+ return 'f' * rand(0...100)
+ end
+
+ if c == 'object'
+ return IntWrapper.new(rand(0...100))
+ end
+
+ raise "should not get here"
+end
+
+# Evaluate the value of an argument with respect to the checksum
+def arg_val(arg)
+ if arg.kind_of? Integer
+ return arg
+ end
+
+ if arg.kind_of? String
+ return arg.length
+ end
+
+ if arg.kind_of? Object
+ return arg.value
+ end
+
+ raise "unknown arg type"
+end
+
+# List of parameters/arguments for a method
+class ParamList
+ def initialize()
+ self.sample_params()
+ self.sample_args()
+ end
+
+ # Sample/generate a random set of parameters for a method
+ def sample_params()
+ # Choose how many positional arguments to use, and how many are optional
+ num_pargs = rand(10)
+ @opt_parg_idx = rand(num_pargs)
+ @num_opt_pargs = rand(num_pargs + 1 - @opt_parg_idx)
+ @num_pargs_req = num_pargs - @num_opt_pargs
+ @pargs = (0...num_pargs).map do |i|
+ {
+ :name => "p#{i}",
+ :optional => (i >= @opt_parg_idx && i < @opt_parg_idx + @num_opt_pargs)
+ }
+ end
+
+ # Choose how many kwargs to use, and how many are optional
+ num_kwargs = rand(10)
+ @kwargs = (0...num_kwargs).map do |i|
+ {
+ :name => "k#{i}",
+ :optional => rand() < 0.5
+ }
+ end
+
+ # Choose whether to have rest parameters or not
+ @has_rest = @num_opt_pargs == 0 && rand() < 0.5
+ @has_kwrest = rand() < 0.25
+
+ # Choose whether to have a named block parameter or not
+ @has_block_param = rand() < 0.25
+ end
+
+ # Sample/generate a random set of arguments corresponding to the parameters
+ def sample_args()
+ # Choose how many positional args to pass
+ num_pargs_passed = rand(@num_pargs_req..@pargs.size)
+
+ # How many optional arguments will be filled
+ opt_pargs_filled = num_pargs_passed - @num_pargs_req
+
+ @pargs.each_with_index do |parg, i|
+ if parg[:optional]
+ parg[:default] = rand(100)
+ end
+
+ if !parg[:optional] || i < @opt_parg_idx + opt_pargs_filled
+ parg[:argval] = rand(100)
+ end
+ end
+
+ @kwargs.each_with_index do |kwarg, i|
+ if kwarg[:optional]
+ kwarg[:default] = rand(100)
+ end
+
+ if !kwarg[:optional] || rand() < 0.5
+ kwarg[:argval] = rand(100)
+ end
+ end
+
+ # Randomly pass a block or not
+ @block_arg = nil
+ if rand() < 0.5
+ @block_arg = rand(100)
+ end
+ end
+
+ # Compute the expected checksum of arguments ahead of time
+ def compute_checksum()
+ checksum = 0
+
+ @pargs.each_with_index do |arg, i|
+ value = (arg.key? :argval)? arg[:argval]:arg[:default]
+ checksum += (i+1) * arg_val(value)
+ end
+
+ @kwargs.each_with_index do |arg, i|
+ value = (arg.key? :argval)? arg[:argval]:arg[:default]
+ checksum += (i+1) * arg_val(value)
+ end
+
+ if @block_arg
+ if @has_block_param
+ checksum += arg_val(@block_arg)
+ end
+
+ checksum += arg_val(@block_arg)
+ end
+
+ checksum
+ end
+
+ # Generate code for the method signature and method body
+ def gen_method_str()
+ m_str = "def m("
+
+ @pargs.each do |arg|
+ if !m_str.end_with?("(")
+ m_str += ", "
+ end
+
+ m_str += arg[:name]
+
+ # If this has a default value
+ if arg[:optional]
+ m_str += " = #{arg[:default]}"
+ end
+ end
+
+ if @has_rest
+ if !m_str.end_with?("(")
+ m_str += ", "
+ end
+ m_str += "*rest"
+ end
+
+ @kwargs.each do |arg|
+ if !m_str.end_with?("(")
+ m_str += ", "
+ end
+
+ m_str += "#{arg[:name]}:"
+
+ # If this has a default value
+ if arg[:optional]
+ m_str += " #{arg[:default]}"
+ end
+ end
+
+ if @has_kwrest
+ if !m_str.end_with?("(")
+ m_str += ", "
+ end
+ m_str += "**kwrest"
+ end
+
+ if @has_block_param
+ if !m_str.end_with?("(")
+ m_str += ", "
+ end
+
+ m_str += "&block"
+ end
+
+ m_str += ")\n"
+
+ # Add some useless locals
+ rand(0...16).times do |i|
+ m_str += "local#{i} = #{i}\n"
+ end
+
+ # Add some useless if statements
+ @pargs.each_with_index do |arg, i|
+ if rand() < 50
+ m_str += "if #{arg[:name]} > 4; end\n"
+ end
+ end
+
+ m_str += "checksum = 0\n"
+
+ @pargs.each_with_index do |arg, i|
+ m_str += "checksum += #{i+1} * arg_val(#{arg[:name]})\n"
+ end
+
+ @kwargs.each_with_index do |arg, i|
+ m_str += "checksum += #{i+1} * arg_val(#{arg[:name]})\n"
+ end
+
+ if @has_block_param
+ m_str += "if block; r = block.call; checksum += arg_val(r); end\n"
+ end
+
+ m_str += "if block_given?; r = yield; checksum += arg_val(r); end\n"
+
+ if @has_rest
+ m_str += "raise 'rest is not array' unless rest.kind_of?(Array)\n"
+ m_str += "raise 'rest size not integer' unless rest.size.kind_of?(Integer)\n"
+ end
+
+ if @has_kwrest
+ m_str += "raise 'kwrest is not a hash' unless kwrest.kind_of?(Hash)\n"
+ m_str += "raise 'kwrest size not integer' unless kwrest.size.kind_of?(Integer)\n"
+ end
+
+ m_str += "checksum\n"
+ m_str += "end"
+
+ m_str
+ end
+
+ # Generate code to call into the method and pass the arguments
+ def gen_call_str()
+ c_str = "m("
+
+ @pargs.each_with_index do |arg, i|
+ if !arg.key? :argval
+ next
+ end
+
+ if !c_str.end_with?("(")
+ c_str += ", "
+ end
+
+ c_str += "#{arg[:argval]}"
+ end
+
+ @kwargs.each_with_index do |arg, i|
+ if !arg.key? :argval
+ next
+ end
+
+ if !c_str.end_with?("(")
+ c_str += ", "
+ end
+
+ c_str += "#{arg[:name]}: #{arg[:argval]}"
+ end
+
+ c_str += ")"
+
+ # Randomly pass a block or not
+ if @block_arg
+ c_str += " { #{@block_arg} }"
+ end
+
+ c_str
+ end
+end
+
+iseqs_compiled_start = RubyVM::YJIT.runtime_stats[:compiled_iseq_entry]
+start_time = Time.now.to_f
+
+num_iters.times do |i|
+ puts "Iteration #{i}"
+
+ lst = ParamList.new()
+ m_str = lst.gen_method_str()
+ c_str = lst.gen_call_str()
+ checksum = lst.compute_checksum()
+
+ f = Object.new
+
+ # Define the method on f
+ puts "Defining"
+ p m_str
+ f.instance_eval(m_str)
+ #puts RubyVM::InstructionSequence.disasm(f.method(:m))
+ #exit 0
+
+ puts "Calling"
+ c_str = "f.#{c_str}"
+ p c_str
+ r = eval(c_str)
+ puts "checksum=#{r}"
+
+ if r != checksum
+ raise "return value #{r} doesn't match checksum #{checksum}"
+ end
+
+ puts ""
+end
+
+# Make sure that YJIT actually compiled the tests we ran
+# Should be run with --yjit-call-threshold=1
+iseqs_compiled_end = RubyVM::YJIT.runtime_stats[:compiled_iseq_entry]
+if iseqs_compiled_end - iseqs_compiled_start < num_iters
+ raise "YJIT did not compile enough ISEQs"
+end
+
+puts "Code region size: #{ format_number(0, RubyVM::YJIT.runtime_stats[:code_region_size]) }"
+
+end_time = Time.now.to_f
+itrs_per_sec = num_iters / (end_time - start_time)
+itrs_per_hour = 3600 * itrs_per_sec
+puts "#{'%.1f' % itrs_per_sec} iterations/s"
+puts "#{format_number(0, itrs_per_hour.round)} iterations/hour"
diff --git a/misc/call_fuzzer.sh b/misc/call_fuzzer.sh
new file mode 100755
index 0000000000..cf4ec76fe8
--- /dev/null
+++ b/misc/call_fuzzer.sh
@@ -0,0 +1,13 @@
+# Stop at first error
+set -e
+
+# TODO
+# TODO: boost --num-iters to 1M+ for actual test
+# TODO
+export NUM_ITERS=25000
+
+# Enable code GC so we don't stop compiling when we hit the code size limit
+ruby --yjit-call-threshold=1 --yjit-code-gc misc/call_fuzzer.rb --num-iters=$NUM_ITERS
+
+# Do another pass with --verify-ctx
+ruby --yjit-call-threshold=1 --yjit-code-gc --yjit-verify-ctx misc/call_fuzzer.rb --num-iters=$NUM_ITERS
diff --git a/misc/expand_tabs.rb b/misc/expand_tabs.rb
index a94eea5046..d26568eefc 100755
--- a/misc/expand_tabs.rb
+++ b/misc/expand_tabs.rb
@@ -59,53 +59,31 @@ class Git
end
DEFAULT_GEM_LIBS = %w[
- abbrev
- base64
- benchmark
bundler
- cmath
- csv
- debug
delegate
did_you_mean
- drb
english
erb
+ error_highlight
fileutils
find
forwardable
- getoptlong
ipaddr
- irb
- logger
- mutex_m
net-http
net-protocol
- observer
open3
open-uri
optparse
ostruct
pp
prettyprint
- prime
- pstore
- rdoc
- readline
- reline
+ prism
resolv
- resolv-replace
- rexml
- rinda
- rss
rubygems
- scanf
securerandom
- set
shellwords
singleton
tempfile
- thwait
time
timeout
tmpdir
@@ -117,27 +95,19 @@ DEFAULT_GEM_LIBS = %w[
]
DEFAULT_GEM_EXTS = %w[
- bigdecimal
- cgi
date
digest
etc
fcntl
- fiddle
io-console
io-nonblock
io-wait
json
- nkf
openssl
pathname
psych
- racc
- readline-ext
stringio
strscan
- syslog
- win32ole
zlib
]
diff --git a/misc/gdb.py b/misc/gdb.py
new file mode 100644
index 0000000000..6034a389bb
--- /dev/null
+++ b/misc/gdb.py
@@ -0,0 +1,181 @@
+import argparse
+import textwrap
+
+# usage: [-h] [-a | --all | --no-all] [-s STACK_SIZE] [uplevel]
+#
+# Dump a control frame
+#
+# positional arguments:
+# uplevel CFP offset from the stack top
+#
+# options:
+# -h, --help show this help message and exit
+# -a, --all, --no-all dump all frames
+# -s STACK_SIZE, --stack-size STACK_SIZE
+# override stack_size (useful for JIT frames)
+class CFP(gdb.Command):
+ FRAME_MAGICS = [
+ # frame types
+ 'VM_FRAME_MAGIC_METHOD',
+ 'VM_FRAME_MAGIC_BLOCK',
+ 'VM_FRAME_MAGIC_CLASS',
+ 'VM_FRAME_MAGIC_TOP',
+ 'VM_FRAME_MAGIC_CFUNC',
+ 'VM_FRAME_MAGIC_IFUNC',
+ 'VM_FRAME_MAGIC_EVAL',
+ 'VM_FRAME_MAGIC_RESCUE',
+ 'VM_FRAME_MAGIC_DUMMY',
+ ]
+ FRAME_FLAGS = [
+ # frame flag
+ 'VM_FRAME_FLAG_FINISH',
+ 'VM_FRAME_FLAG_BMETHOD',
+ 'VM_FRAME_FLAG_CFRAME',
+ 'VM_FRAME_FLAG_LAMBDA',
+ 'VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM',
+ 'VM_FRAME_FLAG_CFRAME_KW',
+ 'VM_FRAME_FLAG_PASSED',
+ # env flag
+ 'VM_ENV_FLAG_LOCAL',
+ 'VM_ENV_FLAG_ESCAPED',
+ 'VM_ENV_FLAG_WB_REQUIRED',
+ 'VM_ENV_FLAG_ISOLATED',
+ ]
+
+ def __init__(self):
+ super(CFP, self).__init__('cfp', gdb.COMMAND_USER)
+
+ self.parser = argparse.ArgumentParser(description='Dump a control frame')
+ self.parser.add_argument('uplevel', type=int, nargs='?', default=0, help='CFP offset from the stack top')
+ self.parser.add_argument('-a', '--all', action=argparse.BooleanOptionalAction, help='dump all frames')
+ self.parser.add_argument('-s', '--stack-size', type=int, help='override stack_size (useful for JIT frames)')
+
+ def invoke(self, args, from_tty):
+ try:
+ args = self.parser.parse_args(args.split())
+ except SystemExit:
+ return
+ cfp = f'(ruby_current_ec->cfp + ({args.uplevel}))'
+ end_cfp = self.get_int('ruby_current_ec->vm_stack + ruby_current_ec->vm_stack_size')
+ cfp_index = int((end_cfp - self.get_int(cfp) - 1) / self.get_int('sizeof(rb_control_frame_t)'))
+
+ if args.all:
+ cfp_count = int((end_cfp - self.get_int('ruby_current_ec->cfp')) / self.get_int('sizeof(rb_control_frame_t)')) - 1 # exclude dummy CFP
+ for i in range(cfp_count):
+ print('-' * 80)
+ self.invoke(str(cfp_count - i - 1), from_tty)
+ return
+
+ print('CFP (addr=0x{:x}, index={}):'.format(self.get_int(cfp), cfp_index))
+ gdb.execute(f'p *({cfp})')
+ print()
+
+ if self.get_int(f'{cfp}->iseq'):
+ local_size = self.get_int(f'{cfp}->iseq->body->local_table_size - {cfp}->iseq->body->param.size')
+ param_size = self.get_int(f'{cfp}->iseq->body->param.size')
+
+ if local_size:
+ print(f'Params (size={param_size}):')
+ for i in range(-3 - local_size - param_size, -3 - local_size):
+ self.print_stack(cfp, i, self.rp(cfp, i))
+ print()
+
+ if param_size:
+ print(f'Locals (size={local_size}):')
+ for i in range(-3 - local_size, -3):
+ self.print_stack(cfp, i, self.rp(cfp, i))
+ print()
+
+ print('Env:')
+ self.print_env(cfp, -3, self.rp_env(cfp, -3))
+ self.print_env(cfp, -2, self.specval(cfp, -2))
+ self.print_env(cfp, -1, self.frame_types(cfp, -1))
+ print()
+
+ # We can't calculate BP for the first frame.
+ # vm_base_ptr doesn't work for C frames either.
+ if cfp_index > 0 and self.get_int(f'{cfp}->iseq'):
+ if args.stack_size is not None:
+ stack_size = args.stack_size
+ else:
+ stack_size = int((self.get_int(f'{cfp}->sp') - self.get_int(f'vm_base_ptr({cfp})')) / 8)
+ print(f'Stack (size={stack_size}):')
+ for i in range(0, stack_size):
+ self.print_stack(cfp, i, self.rp(cfp, i))
+ print(self.regs(cfp, stack_size))
+
+ def print_env(self, cfp, bp_index, content):
+ ep_index = bp_index + 1
+ address = self.get_int(f'((rb_control_frame_t *){cfp})->ep + {ep_index}')
+ value = self.get_env(cfp, bp_index)
+ regs = self.regs(cfp, bp_index)
+ if content:
+ content = textwrap.indent(content, ' ' * 3).lstrip() # Leave the regs column empty
+ content = f'{content} '
+ print('{:2} 0x{:x} [{}] {}(0x{:x})'.format(regs, address, bp_index, content, value))
+
+ def print_stack(self, cfp, bp_index, content):
+ address = self.get_int(f'vm_base_ptr({cfp}) + {bp_index}')
+ value = self.get_value(cfp, bp_index)
+ regs = self.regs(cfp, bp_index)
+ if content:
+ content = textwrap.indent(content, ' ' * 3).lstrip() # Leave the regs column empty
+ content = f'{content} '
+ print('{:2} 0x{:x} [{}] {}(0x{:x})'.format(regs, address, bp_index, content, value))
+
+ def regs(self, cfp, bp_index):
+ address = self.get_int(f'vm_base_ptr({cfp}) + {bp_index}')
+ regs = []
+ for reg, field in { 'EP': 'ep', 'SP': 'sp' }.items():
+ if address == self.get_int(f'{cfp}->{field}'):
+ regs.append(reg)
+ return ' '.join(regs)
+
+ def rp(self, cfp, bp_index):
+ value = self.get_value(cfp, bp_index)
+ return self.get_string(f'rp {value}').rstrip()
+
+ def rp_env(self, cfp, bp_index):
+ value = self.get_env(cfp, bp_index)
+ return self.get_string(f'rp {value}').rstrip()
+
+ # specval: block_handler or previous EP
+ def specval(self, cfp, bp_index):
+ value = self.get_env(cfp, bp_index)
+ if value == 0:
+ return 'VM_BLOCK_HANDLER_NONE'
+ if value == self.get_int('rb_block_param_proxy'):
+ return 'rb_block_param_proxy'
+ return ''
+
+ def frame_types(self, cfp, bp_index):
+ types = []
+ value = self.get_env(cfp, bp_index)
+
+ magic_mask = self.get_int('VM_FRAME_MAGIC_MASK')
+ for magic in self.FRAME_MAGICS:
+ magic_value = self.get_int(magic)
+ if value & magic_mask == magic_value:
+ types.append(magic)
+
+ for flag in self.FRAME_FLAGS:
+ flag_value = self.get_int(flag)
+ if value & flag_value:
+ types.append(flag)
+
+ return ' | '.join(types)
+
+ def get_env(self, cfp, bp_index):
+ ep_index = bp_index + 1
+ return self.get_int(f'((rb_control_frame_t *){cfp})->ep[{ep_index}]')
+
+ def get_value(self, cfp, bp_index):
+ return self.get_int(f'vm_base_ptr({cfp})[{bp_index}]')
+
+ def get_int(self, expr):
+ return int(self.get_string(f'printf "%ld", ({expr})'))
+
+ def get_string(self, expr):
+ return gdb.execute(expr, to_string=True)
+
+CFP()
diff --git a/misc/jit_perf.py b/misc/jit_perf.py
new file mode 100755
index 0000000000..bc0f961b20
--- /dev/null
+++ b/misc/jit_perf.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python3
+import os
+import sys
+from collections import Counter, defaultdict
+import os.path
+
+# Aggregating cycles per symbol and dso
+total_cycles = 0
+category_cycles = Counter()
+detailed_category_cycles = defaultdict(Counter)
+categories = set()
+
+def truncate_symbol(symbol, max_length=50):
+ """ Truncate the symbol name to a maximum length """
+ return symbol if len(symbol) <= max_length else symbol[:max_length-3] + '...'
+
+def categorize_symbol(dso, symbol):
+ """ Categorize the symbol based on the defined criteria """
+ if dso == 'sqlite3_native.so':
+ return '[sqlite3]'
+ elif 'SHA256' in symbol:
+ return '[sha256]'
+ elif symbol.startswith('[JIT] gen_send'):
+ return '[JIT send]'
+ elif symbol.startswith('[JIT]') or symbol.startswith('ZJIT: ') or dso.startswith('perf-'):
+ return '[JIT code]'
+ elif '::' in symbol or symbol.startswith('_ZN4yjit') or symbol.startswith('_ZN4zjit'):
+ return '[JIT compile]'
+ elif symbol.startswith('rb_vm_') or symbol.startswith('vm_') or symbol in {
+ "rb_call0", "callable_method_entry_or_negative", "invoke_block_from_c_bh",
+ "rb_funcallv_scope", "setup_parameters_complex", "rb_yield"}:
+ return '[interpreter]'
+ elif symbol.startswith('rb_hash_') or symbol.startswith('hash_'):
+ return '[rb_hash_*]'
+ elif symbol.startswith('rb_ary_') or symbol.startswith('ary_'):
+ return '[rb_ary_*]'
+ elif symbol.startswith('rb_str_') or symbol.startswith('str_'):
+ return '[rb_str_*]'
+ elif symbol.startswith('rb_sym') or symbol.startswith('sym_'):
+ return '[rb_sym_*]'
+ elif symbol.startswith('rb_st_') or symbol.startswith('st_'):
+ return '[rb_st_*]'
+ elif symbol.startswith('rb_ivar_') or 'shape' in symbol:
+ return '[ivars]'
+ elif 'match' in symbol or symbol.startswith('rb_reg') or symbol.startswith('onig'):
+ return '[regexp]'
+ elif 'alloc' in symbol or 'free' in symbol or 'gc' in symbol:
+ return '[GC]'
+ elif 'pthread' in symbol and 'lock' in symbol:
+ return '[pthread lock]'
+ else:
+ return symbol # Return the symbol itself for uncategorized symbols
+
+def process_event(event):
+ global total_cycles, category_cycles, detailed_category_cycles, categories
+
+ full_dso = event.get("dso", "Unknown_dso")
+ dso = os.path.basename(full_dso)
+ symbol = event.get("symbol", "[unknown]")
+ cycles = event["sample"]["period"]
+ total_cycles += cycles
+
+ category = categorize_symbol(dso, symbol)
+ category_cycles[category] += cycles
+ detailed_category_cycles[category][(dso, symbol)] += cycles
+
+ if category.startswith('[') and category.endswith(']'):
+ categories.add(category)
+
+def trace_end():
+ if total_cycles == 0:
+ return
+
+ print("Aggregated Event Data:")
+ print("{:<20} {:<50} {:>20} {:>15}".format("[dso]", "[symbol or category]", "[top-most cycle ratio]", "[num cycles]"))
+
+ for category, cycles in category_cycles.most_common():
+ ratio = (cycles / total_cycles) * 100
+ dsos = {dso for dso, _ in detailed_category_cycles[category]}
+ dso_display = next(iter(dsos)) if len(dsos) == 1 else "Multiple DSOs"
+ print("{:<20} {:<50} {:>20.2f}% {:>15}".format(dso_display, truncate_symbol(category), ratio, cycles))
+
+ # Category breakdown
+ for category in categories:
+ symbols = detailed_category_cycles[category]
+ category_total = sum(symbols.values())
+ category_ratio = (category_total / total_cycles) * 100
+ print(f"\nCategory: {category} ({category_ratio:.2f}%)")
+ print("{:<20} {:<50} {:>20} {:>15}".format("[dso]", "[symbol]", "[top-most cycle ratio]", "[num cycles]"))
+ for (dso, symbol), cycles in symbols.most_common():
+ symbol_ratio = (cycles / category_total) * 100
+ print("{:<20} {:<50} {:>20.2f}% {:>15}".format(dso, truncate_symbol(symbol), symbol_ratio, cycles))
+
+# There are two ways to use this script:
+# 1) perf script -s misc/yjit_perf.py -- native interface
+# 2) perf script > perf.txt && misc/yjit_perf.py perf.txt -- hack, which doesn't require perf with Python support
+#
+# In both cases, __name__ is "__main__". The following code implements (2) when sys.argv is 2.
+if __name__ == "__main__" and len(sys.argv) == 2:
+ if len(sys.argv) != 2:
+ print("Usage: yjit_perf.py <filename>")
+ sys.exit(1)
+
+ with open(sys.argv[1], "r") as file:
+ for line in file:
+ # [Example]
+ # ruby 78207 3482.848465: 1212775 cpu_core/cycles:P/: 5c0333f682e1 [JIT] getlocal_WC_0+0x0 (/tmp/perf-78207.map)
+ row = line.split(maxsplit=6)
+
+ period = row[3] # "1212775"
+ symbol, dso = row[6].rsplit(" (", 1) # "[JIT] getlocal_WC_0+0x0", "/tmp/perf-78207.map)\n"
+ symbol = symbol.split("+")[0] # "[JIT] getlocal_WC_0"
+ dso = dso.split(")")[0] # "/tmp/perf-78207.map"
+
+ process_event({"dso": dso, "symbol": symbol, "sample": {"period": int(period)}})
+ trace_end()
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py
index 9ef9d3967b..b3d4fb509a 100755..100644
--- a/misc/lldb_cruby.py
+++ b/misc/lldb_cruby.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#coding: utf-8
#
# Usage: run `command script import -r misc/lldb_cruby.py` on LLDB
@@ -14,6 +13,7 @@ import sys
import shlex
import platform
import glob
+import math
from lldb_rb.constants import *
@@ -67,7 +67,7 @@ class BackTrace:
return self.VM_FRAME_MAGIC_NAME.get(frame_type, "(none)")
def rb_iseq_path_str(self, iseq):
- tRBasic = self.target.FindFirstType("struct RBasic").GetPointerType()
+ tRBasic = self.target.FindFirstType("::RBasic").GetPointerType()
pathobj = iseq.GetValueForExpressionPath("->body->location.pathobj")
pathobj = pathobj.Cast(tRBasic)
@@ -197,18 +197,16 @@ def string2cstr(rstring):
flags = rstring.GetValueForExpressionPath(".basic->flags").unsigned
if flags & RUBY_T_MASK != RUBY_T_STRING:
raise TypeError("not a string")
+ clen = int(rstring.GetValueForExpressionPath(".len").value, 0)
if flags & RUBY_FL_USER1:
cptr = int(rstring.GetValueForExpressionPath(".as.heap.ptr").value, 0)
- clen = int(rstring.GetValueForExpressionPath(".as.heap.len").value, 0)
else:
cptr = int(rstring.GetValueForExpressionPath(".as.embed.ary").location, 0)
- clen = int(rstring.GetValueForExpressionPath(".as.embed.len").value, 0)
return cptr, clen
def output_string(debugger, result, rstring):
cptr, clen = string2cstr(rstring)
- expr = "print *(const char (*)[%d])%0#x" % (clen, cptr)
- append_command_output(debugger, expr, result)
+ append_expression(debugger, "*(const char (*)[%d])%0#x" % (clen, cptr), result)
def fixnum_p(x):
return x & RUBY_FIXNUM_FLAG != 0
@@ -227,6 +225,9 @@ def append_command_output(debugger, command, result):
result.write(output1)
result.write(output2)
+def append_expression(debugger, expression, result):
+ append_command_output(debugger, "expression " + expression, result)
+
def lldb_rp(debugger, command, result, internal_dict):
if not ('RUBY_Qfalse' in globals()):
lldb_init(debugger)
@@ -258,18 +259,17 @@ def lldb_inspect(debugger, target, result, val):
elif fixnum_p(num):
print(num >> 1, file=result)
elif flonum_p(num):
- append_command_output(debugger, "print rb_float_value(%0#x)" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "rb_float_value(%0#x)" % val.GetValueAsUnsigned(), result)
elif static_sym_p(num):
if num < 128:
print("T_SYMBOL: %c" % num, file=result)
else:
print("T_SYMBOL: (%x)" % num, file=result)
- append_command_output(debugger, "p rb_id2name(%0#x)" % (num >> 8), result)
+ append_expression(debugger, "rb_id2name(%0#x)" % (num >> 8), result)
elif num & RUBY_IMMEDIATE_MASK:
print('immediate(%x)' % num, file=result)
else:
- tRBasic = target.FindFirstType("struct RBasic").GetPointerType()
- tRValue = target.FindFirstType("struct RVALUE")
+ tRBasic = target.FindFirstType("::RBasic").GetPointerType()
val = val.Cast(tRBasic)
flags = val.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
@@ -292,13 +292,13 @@ def lldb_inspect(debugger, target, result, val):
print('T_NIL: %s%s' % (flaginfo, val.Dereference()), file=result)
elif flType == RUBY_T_OBJECT:
result.write('T_OBJECT: %s' % flaginfo)
- append_command_output(debugger, "print *(struct RObject*)%0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RObject*)%0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_CLASS or flType == RUBY_T_MODULE or flType == RUBY_T_ICLASS:
result.write('T_%s: %s' % ('CLASS' if flType == RUBY_T_CLASS else 'MODULE' if flType == RUBY_T_MODULE else 'ICLASS', flaginfo))
- append_command_output(debugger, "print *(struct RClass*)%0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RClass*)%0#x" % val.GetValueAsUnsigned(), result)
tRClass = target.FindFirstType("struct RClass")
if not val.Cast(tRClass).GetChildMemberWithName("ptr").IsValid():
- append_command_output(debugger, "print *(struct rb_classext_struct*)%0#x" % (val.GetValueAsUnsigned() + tRClass.GetByteSize()), result)
+ append_expression(debugger, "*(struct rb_classext_struct*)%0#x" % (val.GetValueAsUnsigned() + tRClass.GetByteSize()), result)
elif flType == RUBY_T_STRING:
result.write('T_STRING: %s' % flaginfo)
encidx = ((flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT)
@@ -312,12 +312,12 @@ def lldb_inspect(debugger, target, result, val):
if len == 0:
result.write("(empty)\n")
else:
- append_command_output(debugger, "print *(const char (*)[%d])%0#x" % (len, ptr), result)
+ append_expression(debugger, "*(const char (*)[%d])%0#x" % (len, ptr), result)
elif flType == RUBY_T_SYMBOL:
result.write('T_SYMBOL: %s' % flaginfo)
tRSymbol = target.FindFirstType("struct RSymbol").GetPointerType()
val = val.Cast(tRSymbol)
- append_command_output(debugger, 'print (ID)%0#x ' % val.GetValueForExpressionPath("->id").GetValueAsUnsigned(), result)
+ append_expression(debugger, '(ID)%0#x ' % val.GetValueForExpressionPath("->id").GetValueAsUnsigned(), result)
tRString = target.FindFirstType("struct RString").GetPointerType()
output_string(debugger, result, val.GetValueForExpressionPath("->fstr").Cast(tRString))
elif flType == RUBY_T_ARRAY:
@@ -343,12 +343,12 @@ def lldb_inspect(debugger, target, result, val):
else:
result.write("\n")
if ptr.GetValueAsSigned() == 0:
- append_command_output(debugger, "expression -fx -- ((struct RArray*)%0#x)->as.ary" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "-fx -- ((struct RArray*)%0#x)->as.ary" % val.GetValueAsUnsigned(), result)
else:
- append_command_output(debugger, "expression -Z %d -fx -- (const VALUE*)%0#x" % (len, ptr.GetValueAsUnsigned()), result)
+ append_expression(debugger, "-Z %d -fx -- (const VALUE*)%0#x" % (len, ptr.GetValueAsUnsigned()), result)
elif flType == RUBY_T_HASH:
result.write("T_HASH: %s" % flaginfo)
- append_command_output(debugger, "p *(struct RHash *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RHash *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_BIGNUM:
tRBignum = target.FindFirstType("struct RBignum").GetPointerType()
val = val.Cast(tRBignum)
@@ -356,15 +356,15 @@ def lldb_inspect(debugger, target, result, val):
if flags & RUBY_FL_USER2:
len = ((flags & (RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5)) >> (RUBY_FL_USHIFT+3))
print("T_BIGNUM: sign=%s len=%d (embed)" % (sign, len), file=result)
- append_command_output(debugger, "print ((struct RBignum *) %0#x)->as.ary" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "((struct RBignum *) %0#x)->as.ary" % val.GetValueAsUnsigned(), result)
else:
len = val.GetValueForExpressionPath("->as.heap.len").GetValueAsSigned()
print("T_BIGNUM: sign=%s len=%d" % (sign, len), file=result)
print(val.Dereference(), file=result)
- append_command_output(debugger, "expression -Z %x -fx -- (const BDIGIT*)((struct RBignum*)%d)->as.heap.digits" % (len, val.GetValueAsUnsigned()), result)
- # append_command_output(debugger, "x ((struct RBignum *) %0#x)->as.heap.digits / %d" % (val.GetValueAsUnsigned(), len), result)
+ append_expression(debugger, "-Z %x -fx -- (const BDIGIT*)((struct RBignum*)%d)->as.heap.digits" % (len, val.GetValueAsUnsigned()), result)
+ # append_expression(debugger, "((struct RBignum *) %0#x)->as.heap.digits / %d" % (val.GetValueAsUnsigned(), len), result)
elif flType == RUBY_T_FLOAT:
- append_command_output(debugger, "print ((struct RFloat *)%d)->float_value" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "((struct RFloat *)%d)->float_value" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_RATIONAL:
tRRational = target.FindFirstType("struct RRational").GetPointerType()
val = val.Cast(tRRational)
@@ -397,39 +397,39 @@ def lldb_inspect(debugger, target, result, val):
flag = val.GetValueForExpressionPath("->typed_flag")
if flag.GetValueAsUnsigned() == 1:
print("T_DATA: %s" % val.GetValueForExpressionPath("->type->wrap_struct_name"), file=result)
- append_command_output(debugger, "p *(struct RTypedData *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RTypedData *) %0#x" % val.GetValueAsUnsigned(), result)
else:
print("T_DATA:", file=result)
- append_command_output(debugger, "p *(struct RData *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RData *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_NODE:
tRTypedData = target.FindFirstType("struct RNode").GetPointerType()
nd_type = (flags & RUBY_NODE_TYPEMASK) >> RUBY_NODE_TYPESHIFT
- append_command_output(debugger, "p (node_type) %d" % nd_type, result)
+ append_expression(debugger, "(node_type) %d" % nd_type, result)
val = val.Cast(tRTypedData)
- append_command_output(debugger, "p *(struct RNode *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RNode *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_MOVED:
tRTypedData = target.FindFirstType("struct RMoved").GetPointerType()
val = val.Cast(tRTypedData)
- append_command_output(debugger, "p *(struct RMoved *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RMoved *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_MATCH:
tRTypedData = target.FindFirstType("struct RMatch").GetPointerType()
val = val.Cast(tRTypedData)
- append_command_output(debugger, "p *(struct RMatch *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RMatch *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_IMEMO:
# I'm not sure how to get IMEMO_MASK out of lldb. It's not in globals()
imemo_type = (flags >> RUBY_FL_USHIFT) & 0x0F # IMEMO_MASK
print("T_IMEMO: ", file=result)
- append_command_output(debugger, "p (enum imemo_type) %d" % imemo_type, result)
- append_command_output(debugger, "p *(struct MEMO *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "(enum imemo_type) %d" % imemo_type, result)
+ append_expression(debugger, "*(struct MEMO *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_STRUCT:
tRTypedData = target.FindFirstType("struct RStruct").GetPointerType()
val = val.Cast(tRTypedData)
- append_command_output(debugger, "p *(struct RStruct *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RStruct *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_ZOMBIE:
tRZombie = target.FindFirstType("struct RZombie").GetPointerType()
val = val.Cast(tRZombie)
- append_command_output(debugger, "p *(struct RZombie *) %0#x" % val.GetValueAsUnsigned(), result)
+ append_expression(debugger, "*(struct RZombie *) %0#x" % val.GetValueAsUnsigned(), result)
else:
print("Not-handled type %0#x" % flType, file=result)
print(val, file=result)
@@ -523,10 +523,11 @@ def rb_backtrace(debugger, command, result, internal_dict):
bt.print_bt(val)
def dump_bits(target, result, page, object_address, end = "\n"):
- tRValue = target.FindFirstType("struct RVALUE")
+ slot_size = page.GetChildMemberWithName("heap").GetChildMemberWithName("slot_size").unsigned
+ byte_size = 40 ** math.floor(math.log(slot_size, 40))
tUintPtr = target.FindFirstType("uintptr_t") # bits_t
- num_in_page = (object_address & HEAP_PAGE_ALIGN_MASK) // tRValue.GetByteSize();
+ num_in_page = (object_address & HEAP_PAGE_ALIGN_MASK) // byte_size;
bits_bitlength = tUintPtr.GetByteSize() * 8
bitmap_index = num_in_page // bits_bitlength
bitmap_offset = num_in_page & (bits_bitlength - 1)
@@ -546,10 +547,9 @@ class HeapPageIter:
self.target = target
self.start = page.GetChildMemberWithName('start').GetValueAsUnsigned();
self.num_slots = page.GetChildMemberWithName('total_slots').unsigned
- self.slot_size = page.GetChildMemberWithName('size_pool').GetChildMemberWithName('slot_size').unsigned
+ self.slot_size = page.GetChildMemberWithName('heap').GetChildMemberWithName('slot_size').unsigned
self.counter = 0
- self.tRBasic = target.FindFirstType("struct RBasic")
- self.tRValue = target.FindFirstType("struct RVALUE")
+ self.tRBasic = target.FindFirstType("::RBasic")
def is_valid(self):
heap_page_header_size = self.target.FindFirstType("struct heap_page_header").GetByteSize()
@@ -581,14 +581,13 @@ def dump_page_internal(page, target, process, thread, frame, result, debugger, h
freelist = []
fl_start = page.GetChildMemberWithName('freelist').GetValueAsUnsigned()
- tRVALUE = target.FindFirstType("struct RVALUE")
+ free_slot = target.FindFirstType("struct free_slot")
while fl_start > 0:
freelist.append(fl_start)
obj_addr = lldb.SBAddress(fl_start, target)
- obj = target.CreateValueFromAddress("object", obj_addr, tRVALUE)
- fl_start = obj.GetChildMemberWithName("as").GetChildMemberWithName("free").GetChildMemberWithName("next").GetValueAsUnsigned()
-
+ obj = target.CreateValueFromAddress("object", obj_addr, free_slot)
+ fl_start = obj.GetChildMemberWithName("next").GetValueAsUnsigned()
page_iter = HeapPageIter(page, target)
if page_iter.is_valid():
@@ -727,13 +726,13 @@ def __lldb_init_module(debugger, internal_dict):
# Register all classes that subclass RbBaseCommand
for memname, mem in inspect.getmembers(sys.modules["lldb_rb.rb_base_command"]):
- if inspect.isclass(mem):
+ if memname == "RbBaseCommand":
for sclass in mem.__subclasses__():
sclass.register_lldb_command(debugger, f"{__name__}.{sclass.__module__}")
## FUNCTION INITS - These should be removed when converted to class commands
- debugger.HandleCommand("command script add -f lldb_cruby.lldb_rp rp")
+ debugger.HandleCommand("command script add -f lldb_cruby.lldb_rp old_rp")
debugger.HandleCommand("command script add -f lldb_cruby.count_objects rb_count_objects")
debugger.HandleCommand("command script add -f lldb_cruby.stack_dump_raw SDR")
debugger.HandleCommand("command script add -f lldb_cruby.dump_node dump_node")
@@ -741,7 +740,7 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("command script add -f lldb_cruby.rb_backtrace rbbt")
debugger.HandleCommand("command script add -f lldb_cruby.dump_page dump_page")
debugger.HandleCommand("command script add -f lldb_cruby.dump_page_rvalue dump_page_rvalue")
- debugger.HandleCommand("command script add -f lldb_cruby.rb_id2str rb_id2str")
+ debugger.HandleCommand("command script add -f lldb_cruby.rb_id2str old_rb_id2str")
lldb_rb.rb_base_command.RbBaseCommand.lldb_init(debugger)
diff --git a/misc/lldb_rb/commands/heap_page_command.py b/misc/lldb_rb/commands/heap_page_command.py
index edb74a415b..2eed3c3bee 100644
--- a/misc/lldb_rb/commands/heap_page_command.py
+++ b/misc/lldb_rb/commands/heap_page_command.py
@@ -8,14 +8,15 @@ class HeapPageCommand(RbBaseCommand):
help_string = "prints out 'struct heap_page' for a VALUE pointer in the page"
def call(self, debugger, command, exe_ctx, result):
+ self.result = result
self.t_heap_page_body = self.target.FindFirstType("struct heap_page_body")
self.t_heap_page_ptr = self.target.FindFirstType("struct heap_page").GetPointerType()
page = self._get_page(self.frame.EvaluateExpression(command))
page.Cast(self.t_heap_page_ptr)
- self._append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
- self._append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
+ self._append_expression("(struct heap_page *) %0#x" % page.GetValueAsUnsigned())
+ self._append_expression("*(struct heap_page *) %0#x" % page.GetValueAsUnsigned())
def _get_page(self, val):
addr = val.GetValueAsUnsigned()
diff --git a/misc/lldb_rb/commands/print_flags_command.py b/misc/lldb_rb/commands/print_flags_command.py
index 00da4834bf..bc494ae01a 100644
--- a/misc/lldb_rb/commands/print_flags_command.py
+++ b/misc/lldb_rb/commands/print_flags_command.py
@@ -11,13 +11,13 @@ class PrintFlagsCommand(RbBaseCommand):
# call is where our command logic will be implemented
def call(self, debugger, command, exe_ctx, result):
- rclass_t = self.target.FindFirstType("struct RBasic")
+ rclass_t = self.target.FindFirstType("::RBasic")
rcass_ptr = self.target.EvaluateExpression(command).Cast(rclass_t.GetPointerType())
obj_flags = rcass_ptr.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
flags = [
- "RUBY_FL_WB_PROTECTED", "RUBY_FL_PROMOTED0", "RUBY_FL_PROMOTED1", "RUBY_FL_FINALIZE",
- "RUBY_FL_SHAREABLE", "RUBY_FL_EXIVAR", "RUBY_FL_FREEZE",
+ "RUBY_FL_WB_PROTECTED", "RUBY_FL_PROMOTED", "RUBY_FL_FINALIZE",
+ "RUBY_FL_SHAREABLE", "RUBY_FL_FREEZE",
"RUBY_FL_USER0", "RUBY_FL_USER1", "RUBY_FL_USER2", "RUBY_FL_USER3", "RUBY_FL_USER4",
"RUBY_FL_USER5", "RUBY_FL_USER6", "RUBY_FL_USER7", "RUBY_FL_USER8", "RUBY_FL_USER9",
"RUBY_FL_USER10", "RUBY_FL_USER11", "RUBY_FL_USER12", "RUBY_FL_USER13", "RUBY_FL_USER14",
diff --git a/misc/lldb_rb/commands/rb_id2str_command.py b/misc/lldb_rb/commands/rb_id2str_command.py
new file mode 100644
index 0000000000..6ee859ebf6
--- /dev/null
+++ b/misc/lldb_rb/commands/rb_id2str_command.py
@@ -0,0 +1,49 @@
+import lldb
+
+from lldb_rb.constants import *
+from lldb_rb.utils import *
+from lldb_rb.rb_base_command import RbBaseCommand
+
+class RbID2StrCommand(RbBaseCommand):
+ program = "rb_id2str"
+
+ help_string = "convert and print a Ruby ID to a C string and print it to the LLDB console"
+
+ def call(self, debugger, command, exe_ctx, result):
+ global_symbols = self.target.FindFirstGlobalVariable("ruby_global_symbols")
+
+ id_val = self.frame.EvaluateExpression(command).GetValueAsUnsigned()
+ num = self.rb_id_to_serial(id_val)
+
+ last_id = global_symbols.GetChildMemberWithName("last_id").GetValueAsUnsigned()
+ ID_ENTRY_SIZE = 2
+ ID_ENTRY_UNIT = int(self.target.FindFirstGlobalVariable("ID_ENTRY_UNIT").GetValue())
+
+ ids = global_symbols.GetChildMemberWithName("ids")
+
+ if num <= last_id:
+ idx = num // ID_ENTRY_UNIT
+ ary = self.rb_ary_entry(ids, idx, result)
+ pos = (num % ID_ENTRY_UNIT) * ID_ENTRY_SIZE
+ id_str = self.rb_ary_entry(ary, pos, result)
+
+ RbInspector(debugger, result, self.ruby_globals).inspect(id_str)
+
+ def rb_id_to_serial(self, id_val):
+ if id_val > self.ruby_globals["tLAST_OP_ID"]:
+ return id_val >> self.ruby_globals["RUBY_ID_SCOPE_SHIFT"]
+ else:
+ return id_val
+
+ def rb_ary_entry(self, ary, idx, result):
+ tRArray = self.target.FindFirstType("struct RArray").GetPointerType()
+ ary = ary.Cast(tRArray)
+ flags = ary.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
+
+ if flags & self.ruby_globals["RUBY_FL_USER1"]:
+ ptr = ary.GetValueForExpressionPath("->as.ary")
+ else:
+ ptr = ary.GetValueForExpressionPath("->as.heap.ptr")
+
+ ptr_addr = ptr.GetValueAsUnsigned() + (idx * ptr.GetType().GetByteSize())
+ return self.target.CreateValueFromAddress("ary_entry[%d]" % idx, lldb.SBAddress(ptr_addr, self.target), ptr.GetType().GetPointeeType())
diff --git a/misc/lldb_rb/commands/rp_command.py b/misc/lldb_rb/commands/rp_command.py
new file mode 100644
index 0000000000..06b2516d50
--- /dev/null
+++ b/misc/lldb_rb/commands/rp_command.py
@@ -0,0 +1,15 @@
+import lldb
+
+from lldb_rb.constants import *
+from lldb_rb.utils import *
+from lldb_rb.rb_base_command import RbBaseCommand
+
+class RbID2StrCommand(RbBaseCommand):
+ program = "rp"
+
+ help_string = "convert and print a Ruby ID to a C string and print it to the LLDB console"
+
+ def call(self, debugger, command, exe_ctx, result):
+ val = self.frame.EvaluateExpression(command)
+ inspector = RbInspector(debugger, result, self.ruby_globals)
+ inspector.inspect(val)
diff --git a/misc/lldb_rb/constants.py b/misc/lldb_rb/constants.py
index ec3050a399..9cd56eccb0 100644
--- a/misc/lldb_rb/constants.py
+++ b/misc/lldb_rb/constants.py
@@ -2,3 +2,5 @@ HEAP_PAGE_ALIGN_LOG = 16
HEAP_PAGE_ALIGN_MASK = (~(~0 << HEAP_PAGE_ALIGN_LOG))
HEAP_PAGE_ALIGN = (1 << HEAP_PAGE_ALIGN_LOG)
HEAP_PAGE_SIZE = HEAP_PAGE_ALIGN
+
+IMEMO_MASK = 0x0F
diff --git a/misc/lldb_rb/lldb_interface.py b/misc/lldb_rb/lldb_interface.py
new file mode 100644
index 0000000000..25930b2e16
--- /dev/null
+++ b/misc/lldb_rb/lldb_interface.py
@@ -0,0 +1,18 @@
+class LLDBInterface:
+ def build_environment(self, debugger):
+ self.debugger = debugger
+ self.target = debugger.GetSelectedTarget()
+ self.process = self.target.GetProcess()
+ self.thread = self.process.GetSelectedThread()
+ self.frame = self.thread.GetSelectedFrame()
+
+ def _append_command_output(self, command):
+ output1 = self.result.GetOutput()
+ self.debugger.GetCommandInterpreter().HandleCommand(command, self.result)
+ output2 = self.result.GetOutput()
+ self.result.Clear()
+ self.result.write(output1)
+ self.result.write(output2)
+
+ def _append_expression(self, expression):
+ self._append_command_output("expression " + expression)
diff --git a/misc/lldb_rb/rb_base_command.py b/misc/lldb_rb/rb_base_command.py
index dd58d59b97..70a5addd6d 100644
--- a/misc/lldb_rb/rb_base_command.py
+++ b/misc/lldb_rb/rb_base_command.py
@@ -1,7 +1,9 @@
import lldb
from pydoc import locate
+from lldb_rb.constants import *
+from lldb_rb.utils import *
-class RbBaseCommand:
+class RbBaseCommand(LLDBInterface):
@classmethod
def register_lldb_command(cls, debugger, module_name):
# Add any commands contained in this module to LLDB
@@ -41,6 +43,7 @@ class RbBaseCommand:
self.internal_dict = _internal_dict
def __call__(self, debugger, command, exe_ctx, result):
+ self.ruby_globals = RbBaseCommand.lldb_init(debugger)
self.build_environment(debugger)
self.call(debugger, command, exe_ctx, result)
@@ -52,17 +55,3 @@ class RbBaseCommand:
def get_long_help(self):
return self.__class__.help_string
-
- def build_environment(self, debugger):
- self.target = debugger.GetSelectedTarget()
- self.process = self.target.GetProcess()
- self.thread = self.process.GetSelectedThread()
- self.frame = self.thread.GetSelectedFrame()
-
- def _append_command_output(self, debugger, command, result):
- output1 = result.GetOutput()
- debugger.GetCommandInterpreter().HandleCommand(command, result)
- output2 = result.GetOutput()
- result.Clear()
- result.write(output1)
- result.write(output2)
diff --git a/misc/lldb_rb/rb_heap_structs.py b/misc/lldb_rb/rb_heap_structs.py
new file mode 100644
index 0000000000..798b838080
--- /dev/null
+++ b/misc/lldb_rb/rb_heap_structs.py
@@ -0,0 +1,152 @@
+import lldb
+import math
+from lldb_rb.lldb_interface import LLDBInterface
+from lldb_rb.constants import *
+
+class HeapPage(LLDBInterface):
+ def __init__(self, debugger, val):
+ self.build_environment(debugger)
+ self.page_type = self.target.FindFirstType("struct heap_page").GetPointerType()
+ self.val = val
+
+ def heap_page_body(self, command, ctx, result, internal_dict):
+ process = self.target.GetProcess()
+ thread = process.GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ val = frame.EvaluateExpression(command)
+ page = self.get_page_body(val)
+ print("Page body address: ", page.GetAddress(), file=result)
+ print(page, file=result)
+
+ def get_page_body(self, val):
+ tHeapPageBody = self.target.FindFirstType("struct heap_page_body")
+ addr = val.GetValueAsUnsigned()
+ page_addr = addr & ~(HEAP_PAGE_ALIGN_MASK)
+ address = lldb.SBAddress(page_addr, self.target)
+ return self.target.CreateValueFromAddress("page", address, tHeapPageBody)
+
+ def get_page_raw(self, val):
+ body = self.get_page_body(val)
+ return body.GetValueForExpressionPath("->header.page")
+
+ def to_heap_page_struct(self):
+ pagePtr = self.get_page_raw(self.val)
+ return pagePtr.Cast(self.page_type)
+
+
+class RbObject(LLDBInterface):
+ def __init__(self, ptr, debugger, ruby_globals):
+ self.build_environment(debugger)
+ self.ruby_globals = ruby_globals
+
+ self.flUser1 = self.ruby_globals["RUBY_FL_USER1"]
+ self.flUser2 = self.ruby_globals["RUBY_FL_USER2"]
+ self.flUser3 = self.ruby_globals["RUBY_FL_USER3"]
+ self.flUser4 = self.ruby_globals["RUBY_FL_USER4"]
+ self.flUser5 = self.ruby_globals["RUBY_FL_USER5"]
+ self.flUser6 = self.ruby_globals["RUBY_FL_USER6"]
+ self.flUser7 = self.ruby_globals["RUBY_FL_USER7"]
+ self.flUser8 = self.ruby_globals["RUBY_FL_USER8"]
+ self.flUser9 = self.ruby_globals["RUBY_FL_USER9"]
+ self.flUshift = self.ruby_globals["RUBY_FL_USHIFT"]
+
+ self.tRBasic = self.target.FindFirstType("::RBasic").GetPointerType()
+
+ self.val = ptr.Cast(self.tRBasic)
+ self.page = HeapPage(self.debugger, self.val)
+ self.flags = self.val.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
+
+ self.type = None
+ self.type_name = ""
+
+ def check_bits(self, bitmap_name, bitmap_index, bitmap_bit, v):
+ page = self.page.to_heap_page_struct()
+ bits = page.GetChildMemberWithName(bitmap_name)
+ plane = bits.GetChildAtIndex(bitmap_index).GetValueAsUnsigned()
+ if (plane & bitmap_bit) != 0:
+ return v
+ else:
+ return ' '
+
+ def dump_bits(self, result, end = "\n"):
+ tUintPtr = self.target.FindFirstType("uintptr_t") # bits_t
+
+ slot_size = self.page.to_heap_page_struct().GetChildMemberWithName("heap").GetChildMemberWithName("slot_size").unsigned
+ byte_size = 40 ** math.floor(math.log(slot_size, 40))
+
+ num_in_page = (self.val.GetValueAsUnsigned() & HEAP_PAGE_ALIGN_MASK) // byte_size;
+ bits_bitlength = tUintPtr.GetByteSize() * 8
+ bitmap_index = num_in_page // bits_bitlength
+ bitmap_offset = num_in_page & (bits_bitlength - 1)
+ bitmap_bit = 1 << bitmap_offset
+
+ page = self.page.to_heap_page_struct()
+ print("bits: [%s%s%s%s%s]" % (
+ self.check_bits("uncollectible_bits", bitmap_index, bitmap_bit, "L"),
+ self.check_bits("mark_bits", bitmap_index, bitmap_bit, "M"),
+ self.check_bits("pinned_bits", bitmap_index, bitmap_bit, "P"),
+ self.check_bits("marking_bits", bitmap_index, bitmap_bit, "R"),
+ self.check_bits("wb_unprotected_bits", bitmap_index, bitmap_bit, "U"),
+ ), end=end, file=result)
+
+ def promoted_p(self):
+ rbFlPromoted = self.ruby_globals["RUBY_FL_PROMOTED"]
+ return (self.flags & rbFlPromoted) == rbFlPromoted
+
+ def frozen_p(self):
+ rbFlFreeze = self.ruby_globals["RUBY_FL_FREEZE"]
+ return (self.flags & rbFlFreeze) == rbFlFreeze
+
+ def is_type(self, type_name):
+ if self.type is None:
+ flTMask = self.ruby_globals["RUBY_T_MASK"]
+ flType = self.flags & flTMask
+ self.type = flType
+
+ if self.type == self.ruby_globals[type_name]:
+ self.type_name = type_name
+ return True
+ else:
+ return False
+
+ def as_type(self, type_name):
+ if type_name == "array":
+ tRarray = self.target.FindFirstType("struct RArray")
+ return self.val.Cast(tRarray.GetPointerType())
+ elif type_name == "bignum":
+ tRbignum = self.target.FindFirstType("struct RBignum")
+ return self.val.Cast(tRbignum.GetPointerType())
+ else:
+ print("as_type is not implemented for:", type_name)
+
+ def ary_ptr(self):
+ rval = self.as_type("array")
+ if self.flags & self.ruby_globals["RUBY_FL_USER1"]:
+ ptr = rval.GetValueForExpressionPath("->as.ary")
+ else:
+ ptr = rval.GetValueForExpressionPath("->as.heap.ptr")
+ return ptr
+
+ def ary_len(self):
+ if self.flags & self.flUser1:
+ len = ((self.flags &
+ (self.flUser3 | self.flUser4 | self.flUser5 | self.flUser6 |
+ self.flUser7 | self.flUser8 | self.flUser9)
+ ) >> (self.flUshift + 3))
+ else:
+ rval = self.as_type("array")
+ len = rval.GetValueForExpressionPath("->as.heap.len").GetValueAsSigned()
+
+ return len
+
+ def bignum_len(self):
+ if self.flags & self.flUser2:
+ len = ((self.flags &
+ (self.flUser3 | self.flUser4 | self.flUser5)
+ ) >> (self.flUshift + 3))
+ else:
+ len = (self.as_type("bignum").GetValueForExpressionPath("->as.heap.len").
+ GetValueAsUnsigned())
+
+ return len
diff --git a/misc/lldb_rb/utils.py b/misc/lldb_rb/utils.py
new file mode 100644
index 0000000000..a2bcedc328
--- /dev/null
+++ b/misc/lldb_rb/utils.py
@@ -0,0 +1,506 @@
+from lldb_rb.lldb_interface import LLDBInterface
+from lldb_rb.rb_heap_structs import HeapPage, RbObject
+from lldb_rb.constants import *
+
+class RbInspector(LLDBInterface):
+ def __init__(self, debugger, result, ruby_globals):
+ self.build_environment(debugger)
+ self.result = result
+ self.ruby_globals = ruby_globals
+
+ def string2cstr(self, rstring):
+ """Returns the pointer to the C-string in the given String object"""
+ if rstring.TypeIsPointerType():
+ rstring = rstring.Dereference()
+
+ flags = rstring.GetValueForExpressionPath(".basic->flags").unsigned
+ clen = int(rstring.GetValueForExpressionPath(".len").value, 0)
+ if flags & self.ruby_globals["RUBY_FL_USER1"]:
+ cptr = int(rstring.GetValueForExpressionPath(".as.heap.ptr").value, 0)
+ else:
+ cptr = int(rstring.GetValueForExpressionPath(".as.embed.ary").location, 0)
+
+ return cptr, clen
+
+ def output_string(self, rstring):
+ cptr, clen = self.string2cstr(rstring)
+ self._append_expression("*(const char (*)[%d])%0#x" % (clen, cptr))
+
+ def fixnum_p(self, x):
+ return x & self.ruby_globals["RUBY_FIXNUM_FLAG"] != 0
+
+ def flonum_p(self, x):
+ return (x & self.ruby_globals["RUBY_FLONUM_MASK"]) == self.ruby_globals["RUBY_FLONUM_FLAG"]
+
+ def static_sym_p(self, x):
+ special_shift = self.ruby_globals["RUBY_SPECIAL_SHIFT"]
+ symbol_flag = self.ruby_globals["RUBY_SYMBOL_FLAG"]
+ return (x & ~(~0 << special_shift)) == symbol_flag
+
+ def generic_inspect(self, val, rtype):
+ tRType = self.target.FindFirstType("struct %s" % rtype).GetPointerType()
+ val = val.Cast(tRType)
+ self._append_expression("*(struct %s *) %0#x" % (rtype, val.GetValueAsUnsigned()))
+
+ def inspect(self, val):
+ rbTrue = self.ruby_globals["RUBY_Qtrue"]
+ rbFalse = self.ruby_globals["RUBY_Qfalse"]
+ rbNil = self.ruby_globals["RUBY_Qnil"]
+ rbUndef = self.ruby_globals["RUBY_Qundef"]
+ rbImmediateMask = self.ruby_globals["RUBY_IMMEDIATE_MASK"]
+
+ if self.inspect_node(val):
+ return
+
+ num = val.GetValueAsSigned()
+ if num == rbFalse:
+ print('false', file=self.result)
+ elif num == rbTrue:
+ print('true', file=self.result)
+ elif num == rbNil:
+ print('nil', file=self.result)
+ elif num == rbUndef:
+ print('undef', file=self.result)
+ elif self.fixnum_p(num):
+ print(num >> 1, file=self.result)
+ elif self.flonum_p(num):
+ self._append_expression("rb_float_value(%0#x)" % val.GetValueAsUnsigned())
+ elif self.static_sym_p(num):
+ if num < 128:
+ print("T_SYMBOL: %c" % num, file=self.result)
+ else:
+ print("T_SYMBOL: (%x)" % num, file=self.result)
+ self._append_expression("rb_id2name(%0#x)" % (num >> 8))
+
+ elif num & rbImmediateMask:
+ print('immediate(%x)' % num, file=self.result)
+ else:
+ rval = RbObject(val, self.debugger, self.ruby_globals)
+ rval.dump_bits(self.result)
+
+ flaginfo = ""
+ if rval.promoted_p():
+ flaginfo += "[PROMOTED] "
+ if rval.frozen_p():
+ flaginfo += "[FROZEN] "
+
+ if rval.is_type("RUBY_T_NONE"):
+ print('T_NONE: %s%s' % (flaginfo, val.Dereference()), file=self.result)
+
+ elif rval.is_type("RUBY_T_NIL"):
+ print('T_NIL: %s%s' % (flaginfo, val.Dereference()), file=self.result)
+
+ elif rval.is_type("RUBY_T_OBJECT"):
+ self.result.write('T_OBJECT: %s' % flaginfo)
+ self._append_expression("*(struct RObject*)%0#x" % val.GetValueAsUnsigned())
+
+ elif (rval.is_type("RUBY_T_CLASS") or
+ rval.is_type("RUBY_T_MODULE") or
+ rval.is_type("RUBY_T_ICLASS")):
+ self.result.write('T_%s: %s' % (rval.type_name.split('_')[-1], flaginfo))
+ tRClass = self.target.FindFirstType("struct RClass")
+
+ self._append_expression("*(struct RClass*)%0#x" % val.GetValueAsUnsigned())
+ if not val.Cast(tRClass).GetChildMemberWithName("ptr").IsValid():
+ self._append_expression(
+ "*(struct rb_classext_struct*)%0#x" %
+ (val.GetValueAsUnsigned() + tRClass.GetByteSize())
+ )
+
+ elif rval.is_type("RUBY_T_STRING"):
+ self.result.write('T_STRING: %s' % flaginfo)
+ tRString = self.target.FindFirstType("struct RString").GetPointerType()
+
+ chilled = self.ruby_globals["RUBY_FL_USER3"]
+ if (rval.flags & chilled) != 0:
+ self.result.write("[CHILLED] ")
+
+ rb_enc_mask = self.ruby_globals["RUBY_ENCODING_MASK"]
+ rb_enc_shift = self.ruby_globals["RUBY_ENCODING_SHIFT"]
+ encidx = ((rval.flags & rb_enc_mask) >> rb_enc_shift)
+ encname = self.target.FindFirstType("enum ruby_preserved_encindex") \
+ .GetEnumMembers().GetTypeEnumMemberAtIndex(encidx) \
+ .GetName()
+
+ if encname is not None:
+ self.result.write('[%s] ' % encname[14:])
+ else:
+ self.result.write('[enc=%d] ' % encidx)
+
+ coderange = rval.flags & self.ruby_globals["RUBY_ENC_CODERANGE_MASK"]
+ if coderange == self.ruby_globals["RUBY_ENC_CODERANGE_7BIT"]:
+ self.result.write('[7BIT] ')
+ elif coderange == self.ruby_globals["RUBY_ENC_CODERANGE_VALID"]:
+ self.result.write('[VALID] ')
+ elif coderange == self.ruby_globals["RUBY_ENC_CODERANGE_BROKEN"]:
+ self.result.write('[BROKEN] ')
+ else:
+ self.result.write('[UNKNOWN] ')
+
+ ptr, len = self.string2cstr(val.Cast(tRString))
+ if len == 0:
+ self.result.write("(empty)\n")
+ else:
+ self._append_expression("*(const char (*)[%d])%0#x" % (len, ptr))
+
+ elif rval.is_type("RUBY_T_SYMBOL"):
+ self.result.write('T_SYMBOL: %s' % flaginfo)
+ tRSymbol = self.target.FindFirstType("struct RSymbol").GetPointerType()
+ tRString = self.target.FindFirstType("struct RString").GetPointerType()
+
+ val = val.Cast(tRSymbol)
+ self._append_expression('(ID)%0#x ' % val.GetValueForExpressionPath("->id").GetValueAsUnsigned())
+ self.output_string(val.GetValueForExpressionPath("->fstr").Cast(tRString))
+
+ elif rval.is_type("RUBY_T_ARRAY"):
+ len = rval.ary_len()
+ ptr = rval.ary_ptr()
+
+ self.result.write("T_ARRAY: %slen=%d" % (flaginfo, len))
+
+ if rval.flags & self.ruby_globals["RUBY_FL_USER1"]:
+ self.result.write(" (embed)")
+ elif rval.flags & self.ruby_globals["RUBY_FL_USER2"]:
+ shared = val.GetValueForExpressionPath("->as.heap.aux.shared").GetValueAsUnsigned()
+ self.result.write(" (shared) shared=%016x" % shared)
+ else:
+ capa = val.GetValueForExpressionPath("->as.heap.aux.capa").GetValueAsSigned()
+ self.result.write(" (ownership) capa=%d" % capa)
+ if len == 0:
+ self.result.write(" {(empty)}\n")
+ else:
+ self.result.write("\n")
+ if ptr.GetValueAsSigned() == 0:
+ self._append_expression("-fx -- ((struct RArray*)%0#x)->as.ary" % val.GetValueAsUnsigned())
+ else:
+ self._append_expression("-Z %d -fx -- (const VALUE*)%0#x" % (len, ptr.GetValueAsUnsigned()))
+
+ elif rval.is_type("RUBY_T_HASH"):
+ self.result.write("T_HASH: %s" % flaginfo)
+ ptr = val.GetValueAsUnsigned()
+ self._append_expression("*(struct RHash *) %0#x" % ptr)
+ if rval.flags & self.ruby_globals["RUBY_FL_USER3"]:
+ self._append_expression("*(struct st_table *) (%0#x + sizeof(struct RHash))" % ptr)
+ else:
+ self._append_expression("*(struct ar_table *) (%0#x + sizeof(struct RHash))" % ptr)
+
+ elif rval.is_type("RUBY_T_BIGNUM"):
+ sign = '-'
+ if (rval.flags & self.ruby_globals["RUBY_FL_USER1"]) != 0:
+ sign = '+'
+ len = rval.bignum_len()
+
+ if rval.flags & self.ruby_globals["RUBY_FL_USER2"]:
+ print("T_BIGNUM: sign=%s len=%d (embed)" % (sign, len), file=self.result)
+ self._append_expression("((struct RBignum *) %0#x)->as.ary"
+ % val.GetValueAsUnsigned())
+ else:
+ print("T_BIGNUM: sign=%s len=%d" % (sign, len), file=self.result)
+ print(rval.as_type("bignum"), file=self.result)
+ self._append_expression("-Z %d -fx -- ((struct RBignum*)%d)->as.heap.digits" %
+ (len, val.GetValueAsUnsigned()))
+
+ elif rval.is_type("RUBY_T_FLOAT"):
+ self._append_expression("((struct RFloat *)%d)->float_value"
+ % val.GetValueAsUnsigned())
+
+ elif rval.is_type("RUBY_T_RATIONAL"):
+ tRRational = self.target.FindFirstType("struct RRational").GetPointerType()
+ val = val.Cast(tRRational)
+ self.inspect(val.GetValueForExpressionPath("->num"))
+ output = self.result.GetOutput()
+ self.result.Clear()
+ self.result.write("(Rational) " + output.rstrip() + " / ")
+ self.inspect(val.GetValueForExpressionPath("->den"))
+
+ elif rval.is_type("RUBY_T_COMPLEX"):
+ tRComplex = self.target.FindFirstType("struct RComplex").GetPointerType()
+ val = val.Cast(tRComplex)
+ self.inspect(val.GetValueForExpressionPath("->real"))
+ real = self.result.GetOutput().rstrip()
+ self.result.Clear()
+ self.inspect(val.GetValueForExpressionPath("->imag"))
+ imag = self.result.GetOutput().rstrip()
+ self.result.Clear()
+ if not imag.startswith("-"):
+ imag = "+" + imag
+ print("(Complex) " + real + imag + "i", file=self.result)
+
+ elif rval.is_type("RUBY_T_REGEXP"):
+ tRRegex = self.target.FindFirstType("struct RRegexp").GetPointerType()
+ val = val.Cast(tRRegex)
+ print("(Regex) ->src {", file=self.result)
+ self.inspect(val.GetValueForExpressionPath("->src"))
+ print("}", file=self.result)
+
+ elif rval.is_type("RUBY_T_DATA"):
+ tRTypedData = self.target.FindFirstType("struct RTypedData").GetPointerType()
+ val = val.Cast(tRTypedData)
+
+ type = val.GetValueForExpressionPath("->type").GetValueAsUnsigned()
+ embed = (type & 1)
+ if embed:
+ flaginfo += "[EMBED] "
+ type = self.frame.EvaluateExpression("(rb_data_type_t *)%0#x" % (type & ~1))
+ print("T_DATA: %s%s" %
+ (flaginfo, type.GetValueForExpressionPath("->wrap_struct_name")),
+ file=self.result)
+ print("%s", type.Dereference(), file=self.result)
+ ptr = val.GetValueForExpressionPath("->data")
+ if embed:
+ ptr = ptr.AddressOf()
+ self._append_expression("(void *)%0#x" % ptr.GetValueAsUnsigned())
+
+ elif rval.is_type("RUBY_T_IMEMO"):
+ imemo_type = ((rval.flags >> self.ruby_globals["RUBY_FL_USHIFT"])
+ & IMEMO_MASK)
+ print("T_IMEMO: ", file=self.result)
+
+ self._append_expression("(enum imemo_type) %d" % imemo_type)
+ self._append_expression("*(struct MEMO *) %0#x" % val.GetValueAsUnsigned())
+
+ elif rval.is_type("RUBY_T_FILE"):
+ self.generic_inspect(val, "RFile")
+
+ elif rval.is_type("RUBY_T_MOVED"):
+ self.generic_inspect(val, "RMoved")
+
+ elif rval.is_type("RUBY_T_MATCH"):
+ self.generic_inspect(val, "RMatch")
+
+ elif rval.is_type("RUBY_T_STRUCT"):
+ self.generic_inspect(val, "RStruct")
+
+ elif rval.is_type("RUBY_T_ZOMBIE"):
+ self.generic_inspect(val, "RZombie")
+
+ else:
+ print("Not-handled type %0#x" % rval.type, file=self.result)
+ print(val, file=self.result)
+
+ def inspect_node(self, val):
+ tRNode = self.target.FindFirstType("struct RNode").GetPointerType()
+
+ # if val.GetType() != tRNode: does not work for unknown reason
+
+ if val.GetType().GetPointeeType().GetCanonicalType().name != "RNode":
+ return False
+
+ rbNodeTypeMask = self.ruby_globals["RUBY_NODE_TYPEMASK"]
+ rbNodeTypeShift = self.ruby_globals["RUBY_NODE_TYPESHIFT"]
+ flags = val.Cast(tRNode).GetChildMemberWithName("flags").GetValueAsUnsigned()
+ nd_type = (flags & rbNodeTypeMask) >> rbNodeTypeShift
+
+ self._append_expression("(node_type) %d" % nd_type)
+
+ if nd_type == self.ruby_globals["NODE_SCOPE"]:
+ self._append_expression("*(rb_node_scope_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_BLOCK"]:
+ self._append_expression("*(rb_node_block_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_IF"]:
+ self._append_expression("*(rb_node_if_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_UNLESS"]:
+ self._append_expression("*(rb_node_unless_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CASE"]:
+ self._append_expression("*(rb_node_case_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CASE2"]:
+ self._append_expression("*(rb_node_case2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CASE3"]:
+ self._append_expression("*(rb_node_case3_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_WHEN"]:
+ self._append_expression("*(rb_node_when_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_IN"]:
+ self._append_expression("*(rb_node_in_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_WHILE"]:
+ self._append_expression("*(rb_node_while_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_UNTIL"]:
+ self._append_expression("*(rb_node_until_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ITER"]:
+ self._append_expression("*(rb_node_iter_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FOR"]:
+ self._append_expression("*(rb_node_for_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FOR_MASGN"]:
+ self._append_expression("*(rb_node_for_masgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_BREAK"]:
+ self._append_expression("*(rb_node_break_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_NEXT"]:
+ self._append_expression("*(rb_node_next_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_REDO"]:
+ self._append_expression("*(rb_node_redo_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_RETRY"]:
+ self._append_expression("*(rb_node_retry_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_BEGIN"]:
+ self._append_expression("*(rb_node_begin_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_RESCUE"]:
+ self._append_expression("*(rb_node_rescue_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_RESBODY"]:
+ self._append_expression("*(rb_node_resbody_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ENSURE"]:
+ self._append_expression("*(rb_node_ensure_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_AND"]:
+ self._append_expression("*(rb_node_and_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OR"]:
+ self._append_expression("*(rb_node_or_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_MASGN"]:
+ self._append_expression("*(rb_node_masgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_LASGN"]:
+ self._append_expression("*(rb_node_lasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DASGN"]:
+ self._append_expression("*(rb_node_dasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_GASGN"]:
+ self._append_expression("*(rb_node_gasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_IASGN"]:
+ self._append_expression("*(rb_node_iasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CDECL"]:
+ self._append_expression("*(rb_node_cdecl_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CVASGN"]:
+ self._append_expression("*(rb_node_cvasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OP_ASGN1"]:
+ self._append_expression("*(rb_node_op_asgn1_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OP_ASGN2"]:
+ self._append_expression("*(rb_node_op_asgn2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OP_ASGN_AND"]:
+ self._append_expression("*(rb_node_op_asgn_and_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OP_ASGN_OR"]:
+ self._append_expression("*(rb_node_op_asgn_or_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OP_CDECL"]:
+ self._append_expression("*(rb_node_op_cdecl_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CALL"]:
+ self._append_expression("*(rb_node_call_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OPCALL"]:
+ self._append_expression("*(rb_node_opcall_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FCALL"]:
+ self._append_expression("*(rb_node_fcall_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_VCALL"]:
+ self._append_expression("*(rb_node_vcall_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_QCALL"]:
+ self._append_expression("*(rb_node_qcall_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_SUPER"]:
+ self._append_expression("*(rb_node_super_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ZSUPER"]:
+ self._append_expression("*(rb_node_zsuper_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_LIST"]:
+ self._append_expression("*(rb_node_list_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ZLIST"]:
+ self._append_expression("*(rb_node_zlist_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_HASH"]:
+ self._append_expression("*(rb_node_hash_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_RETURN"]:
+ self._append_expression("*(rb_node_return_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_YIELD"]:
+ self._append_expression("*(rb_node_yield_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_LVAR"]:
+ self._append_expression("*(rb_node_lvar_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DVAR"]:
+ self._append_expression("*(rb_node_dvar_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_GVAR"]:
+ self._append_expression("*(rb_node_gvar_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CONST"]:
+ self._append_expression("*(rb_node_const_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CVAR"]:
+ self._append_expression("*(rb_node_cvar_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_NTH_REF"]:
+ self._append_expression("*(rb_node_nth_ref_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_BACK_REF"]:
+ self._append_expression("*(rb_node_back_ref_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_MATCH"]:
+ self._append_expression("*(rb_node_match_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_MATCH2"]:
+ self._append_expression("*(rb_node_match2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_MATCH3"]:
+ self._append_expression("*(rb_node_match3_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_STR"]:
+ self._append_expression("*(rb_node_str_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DSTR"]:
+ self._append_expression("*(rb_node_dstr_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_XSTR"]:
+ self._append_expression("*(rb_node_xstr_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DXSTR"]:
+ self._append_expression("*(rb_node_dxstr_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_EVSTR"]:
+ self._append_expression("*(rb_node_evstr_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_REGX"]:
+ self._append_expression("*(rb_node_regx_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DREGX"]:
+ self._append_expression("*(rb_node_dregx_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ONCE"]:
+ self._append_expression("*(rb_node_once_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ARGS"]:
+ self._append_expression("*(rb_node_args_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ARGS_AUX"]:
+ self._append_expression("*(rb_node_args_aux_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_OPT_ARG"]:
+ self._append_expression("*(rb_node_opt_arg_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_KW_ARG"]:
+ self._append_expression("*(rb_node_kw_arg_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_POSTARG"]:
+ self._append_expression("*(rb_node_postarg_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ARGSCAT"]:
+ self._append_expression("*(rb_node_argscat_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ARGSPUSH"]:
+ self._append_expression("*(rb_node_argspush_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_SPLAT"]:
+ self._append_expression("*(rb_node_splat_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DEFN"]:
+ self._append_expression("*(rb_node_defn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DEFS"]:
+ self._append_expression("*(rb_node_defs_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ALIAS"]:
+ self._append_expression("*(rb_node_alias_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_VALIAS"]:
+ self._append_expression("*(rb_node_valias_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_UNDEF"]:
+ self._append_expression("*(rb_node_undef_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_CLASS"]:
+ self._append_expression("*(rb_node_class_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_MODULE"]:
+ self._append_expression("*(rb_node_module_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_SCLASS"]:
+ self._append_expression("*(rb_node_sclass_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_COLON2"]:
+ self._append_expression("*(rb_node_colon2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_COLON3"]:
+ self._append_expression("*(rb_node_colon3_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DOT2"]:
+ self._append_expression("*(rb_node_dot2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DOT3"]:
+ self._append_expression("*(rb_node_dot3_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FLIP2"]:
+ self._append_expression("*(rb_node_flip2_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FLIP3"]:
+ self._append_expression("*(rb_node_flip3_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_SELF"]:
+ self._append_expression("*(rb_node_self_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_NIL"]:
+ self._append_expression("*(rb_node_nil_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_TRUE"]:
+ self._append_expression("*(rb_node_true_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FALSE"]:
+ self._append_expression("*(rb_node_false_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ERRINFO"]:
+ self._append_expression("*(rb_node_errinfo_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DEFINED"]:
+ self._append_expression("*(rb_node_defined_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_POSTEXE"]:
+ self._append_expression("*(rb_node_postexe_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_DSYM"]:
+ self._append_expression("*(rb_node_dsym_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ATTRASGN"]:
+ self._append_expression("*(rb_node_attrasgn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_LAMBDA"]:
+ self._append_expression("*(rb_node_lambda_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ARYPTN"]:
+ self._append_expression("*(rb_node_aryptn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_HSHPTN"]:
+ self._append_expression("*(rb_node_hshptn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FNDPTN"]:
+ self._append_expression("*(rb_node_fndptn_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_ERROR"]:
+ self._append_expression("*(rb_node_error_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_LINE"]:
+ self._append_expression("*(rb_node_line_t *) %0#x" % val.GetValueAsUnsigned())
+ elif nd_type == self.ruby_globals["NODE_FILE"]:
+ self._append_expression("*(rb_node_file_t *) %0#x" % val.GetValueAsUnsigned())
+ else:
+ self._append_expression("*(NODE *) %0#x" % val.GetValueAsUnsigned())
+ return True
diff --git a/misc/lldb_yjit.py b/misc/lldb_yjit.py
deleted file mode 100644
index cc37b990ea..0000000000
--- a/misc/lldb_yjit.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-#coding: utf-8
-#
-# Usage: run `command script import -r misc/lldb_yjit.py` on LLDB
-#
-
-from __future__ import print_function
-import lldb
-import os
-import shlex
-
-def list_comments(debugger, command, result, internal_dict):
- target = debugger.GetSelectedTarget()
- process = target.GetProcess()
- thread = process.GetSelectedThread()
- frame = thread.GetSelectedFrame()
-
- # Get the different types we need
- rb_darray_meta_t = target.FindFirstType("rb_darray_meta_t")
- codeblock_t = target.FindFirstType("codeblock_t")
- yjit_comment = target.FindFirstType("yjit_comment")
-
- # Get the global variables we need
- comments = target.FindFirstGlobalVariable("yjit_code_comments")
- cb = target.FindFirstGlobalVariable("cb").Cast(codeblock_t.GetPointerType())
-
- # Get the address of the memory block we're using
- mem_addr = cb.GetChildMemberWithName("mem_block").GetValueAsUnsigned()
-
- # Find the size of the darray comment list
- meta = comments.Cast(rb_darray_meta_t.GetPointerType())
- size = meta.GetChildMemberWithName("size").GetValueAsUnsigned()
-
- # Get the address of the block following the metadata header
- t_offset = comments.GetValueAsUnsigned() + rb_darray_meta_t.GetByteSize()
-
- # Loop through each comment and print
- for t in range(0, size):
- addr = lldb.SBAddress(t_offset + (t * yjit_comment.GetByteSize()), target)
- comment = target.CreateValueFromAddress("yjit_comment", addr, yjit_comment)
- string = comment.GetChildMemberWithName("comment")
- comment_offset = mem_addr + comment.GetChildMemberWithName("offset").GetValueAsUnsigned()
- print("%0#x %s" % (comment_offset, string.GetSummary()), file = result)
-
-
-def __lldb_init_module(debugger, internal_dict):
- debugger.HandleCommand("command script add -f lldb_yjit.list_comments lc")
diff --git a/misc/ruby-style.el b/misc/ruby-style.el
index 13aad77b3d..03d0830d3a 100644
--- a/misc/ruby-style.el
+++ b/misc/ruby-style.el
@@ -56,7 +56,9 @@
(c-basic-offset . 4)
(tab-width . 8)
(indent-tabs-mode . nil)
- (setq show-trailing-whitespace t)
+ (show-trailing-whitespace . t)
+ (c-backslash-column . 1)
+ (c-backslash-max-column . 1)
(c-offsets-alist
(case-label . *)
(label . (ruby-style-label-indent *))
@@ -66,6 +68,17 @@
(access-label /)
)))
+(c-add-style
+ "prism"
+ '("bsd"
+ (c-basic-offset . 4)
+ (tab-width . 8)
+ (indent-tabs-mode . nil)
+ (show-trailing-whitespace . t)
+ (c-offsets-alist
+ (case-label . +)
+ )))
+
;;;###autoload
(defun ruby-style-c-mode ()
(interactive)
diff --git a/misc/tsan_suppressions.txt b/misc/tsan_suppressions.txt
new file mode 100644
index 0000000000..5492500e7f
--- /dev/null
+++ b/misc/tsan_suppressions.txt
@@ -0,0 +1,109 @@
+# TSan: ThreadSanitizer
+# https://github.com/google/sanitizers/wiki/threadsanitizersuppressions
+#
+# This file describes a number of places where TSAN detects problems in CRuby.
+# Many of these indicate bugs. Others are benign (ex. data races that can be
+# replaced with relaxed atomic loads)
+#
+# Usage:
+# Configure with:
+# ./configure cflags='-fsanitize=thread' CC=clang
+# Build and run with:
+# TSAN_OPTIONS="suppressions=$(pwd)/misc/tsan_suppressions.txt:die_after_fork=0"
+#
+# Other useful TSAN_OPTIONS:
+# * halt_on_error=1
+# * strip_path_prefix=$(pwd)/
+
+# Namespaces
+race_top:push_subclass_entry_to_list
+
+# sub_nounderflow includes non-atomic read, possibly other issue
+race:objspace_malloc_increase_body
+
+# Signals and ubf
+race:unregister_ubf_list
+
+# It's already crashing. We're doing our best
+signal:rb_vm_bugreport
+race:check_reserved_signal_
+
+race_top:rb_check_deadlock
+
+# vm->ractor.sched.grq_cnt++
+race_top:ractor_sched_enq
+race_top:ractor_sched_deq
+
+# Race between vm_remove_ractor writing ractor count and
+# native_thread_check_and_create_shared reading it during thread creation.
+# The write happens when a ractor thread exits, the read happens when
+# checking if new shared threads need to be created.
+race:vm_remove_ractor
+
+# th->sched.finished at end of co_start
+race_top:rb_thread_sched_mark_zombies
+
+# Races against timer thread setting th->sched.waiting_reason.flags
+race_top:thread_sched_wait_events
+
+# At thread start
+race_top:rb_ractor_set_current_ec_
+
+# TSan reports a lock-order-inversion between thread_sched_lock_ and this lock.
+# It's unclear if that can cause a deadlock since the lock is on self
+deadlock:ractor_lock_self
+
+# TSan reports a deadlock when reacquiring the this lock after a barrier, but
+# we know the other threads have been stopped
+deadlock:rb_ractor_sched_barrier_start
+
+# RVALUE_AGE_SET manipulates flag bits on objects which may be accessed in Ractors
+race_top:RVALUE_AGE_SET
+
+# Inline caches and call cache updates
+# Multiple threads can race when updating shared call caches during method lookups
+# and argument forwarding. These races involve reading/writing cd->cc fields.
+race_top:vm_cc_call_set
+race_top:vm_cc_class_check
+race_top:vm_search_cc
+race_top:vm_search_method_slowpath0
+race_top:rb_vm_opt_getconstant_path
+race_top:vm_ic_attr_index_set
+race:vm_ic_update
+race:vm_caller_setup_fwd_args
+
+# Race in shape_get_next where multiple threads simultaneously access and modify
+# RCLASS_MAX_IV_COUNT and RCLASS_VARIATION_COUNT fields in class objects.
+# One thread reads the field while another thread calls RCLASS_SET_MAX_IV_COUNT.
+# This happens during instance variable shape transitions in multi-threaded code.
+race:shape_get_next
+
+# Non-atomic reads/writes
+race:gccct_method_search
+
+# Ignore exit for now
+race:rb_ec_finalize
+race:rb_ec_cleanup
+
+# TSan doesn't work well post-fork, this raises errors when creating the new
+# timer thread
+race:after_fork_ruby
+
+# Sets objspace->flags.dont_incremental while writebarrier may be running
+race_top:objspace_each_exec
+race_top:objspace_each_objects_ensure
+
+# Non-atomic lazy initialized static variable
+race_top:rbimpl_intern_const
+
+# Setting def->aliased bitfield non-atomically
+race_top:method_definition_addref
+
+# Switching to setting up tracing. Likely other ractors should be stopped for this.
+race_top:encoded_iseq_trace_instrument
+race:rb_iseq_trace_set_all
+race:rb_tracepoint_enable
+
+# GC enable/disable flag modifications race with object allocation flag reads
+race_top:rb_gc_impl_gc_disable
+race_top:rb_gc_impl_gc_enable
diff --git a/missing/dtoa.c b/missing/dtoa.c
index b7a8302875..ba8cd46ebd 100644
--- a/missing/dtoa.c
+++ b/missing/dtoa.c
@@ -98,17 +98,6 @@
* if memory is available and otherwise does something you deem
* appropriate. If MALLOC is undefined, malloc will be invoked
* directly -- and assumed always to succeed.
- * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
- * memory allocations from a private pool of memory when possible.
- * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
- * unless #defined to be a different length. This default length
- * suffices to get rid of MALLOC calls except for unusual cases,
- * such as decimal-to-binary conversion of a very long string of
- * digits. The longest string dtoa can return is about 751 bytes
- * long. For conversions by strtod of strings of 800 digits and
- * all dtoa conversions in single-threaded executions with 8-byte
- * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
- * pointers, PRIVATE_MEM >= 7112 appears adequate.
* #define INFNAN_CHECK on IEEE systems to cause strtod to check for
* Infinity and NaN (case insensitively). On some systems (e.g.,
* some HP systems), it may be necessary to #define NAN_WORD0
@@ -183,7 +172,10 @@
#undef Long
#undef ULong
+#include <assert.h>
#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
#if (INT_MAX >> 30) && !(INT_MAX >> 31)
#define Long int
@@ -195,7 +187,7 @@
#error No 32bit integer
#endif
-#if HAVE_LONG_LONG
+#if defined(HAVE_LONG_LONG) && (HAVE_LONG_LONG)
#define Llong LONG_LONG
#else
#define NO_LONG_LONG
@@ -218,28 +210,43 @@
#include <locale.h>
#endif
+#if defined(HAVE_STDCKDINT_H) || !defined(__has_include)
+#elif __has_include(<stdckdint.h>)
+# define HAVE_STDCKDINT_H 1
+#endif
+#ifdef HAVE_STDCKDINT_H
+# include <stdckdint.h>
+#endif
+
+#if !defined(ckd_add)
+static inline int /* bool */
+ckd_add(int *result, int x, int y)
+{
+ if (x < 0) {
+ if (y < INT_MIN - x) return 1;
+ }
+ else if (x > 0) {
+ if (y > INT_MAX - x) return 1;
+ }
+ *result = x + y;
+ return 0;
+}
+#endif
+
#ifdef MALLOC
extern void *MALLOC(size_t);
#else
-#define MALLOC xmalloc
+#define MALLOC malloc
#endif
#ifdef FREE
extern void FREE(void*);
#else
-#define FREE xfree
+#define FREE free
#endif
#ifndef NO_SANITIZE
#define NO_SANITIZE(x, y) y
#endif
-#ifndef Omit_Private_Memory
-#ifndef PRIVATE_MEM
-#define PRIVATE_MEM 2304
-#endif
-#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
-static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
-#endif
-
#undef IEEE_Arith
#undef Avoid_Underflow
#ifdef IEEE_BIG_ENDIAN
@@ -502,7 +509,7 @@ extern double rnd_prod(double, double), rnd_quot(double, double);
#endif
#ifndef ATOMIC_PTR_CAS
-#define ATOMIC_PTR_CAS(var, old, new) ((var) = (new), (old))
+#define ATOMIC_PTR_CAS(var, old, new) ((var) = (new), (void *)(old))
#endif
#ifndef LIKELY
#define LIKELY(x) (x)
@@ -524,83 +531,29 @@ struct Bigint {
typedef struct Bigint Bigint;
-static Bigint *freelist[Kmax+1];
-
-#define BLOCKING_BIGINT ((Bigint *)(-1))
-
static Bigint *
Balloc(int k)
{
int x;
Bigint *rv;
-#ifndef Omit_Private_Memory
- size_t len;
-#endif
-
- rv = 0;
- ACQUIRE_DTOA_LOCK(0);
- if (k <= Kmax) {
- rv = freelist[k];
- while (rv) {
- Bigint *rvn = rv;
- rv = ATOMIC_PTR_CAS(freelist[k], rv, BLOCKING_BIGINT);
- if (LIKELY(rv != BLOCKING_BIGINT && rvn == rv)) {
- rvn = ATOMIC_PTR_CAS(freelist[k], BLOCKING_BIGINT, rv->next);
- assert(rvn == BLOCKING_BIGINT);
- ASSUME(rv);
- break;
- }
- }
- }
- if (!rv) {
- x = 1 << k;
-#ifdef Omit_Private_Memory
- rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
-#else
- len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
- /sizeof(double);
- if (k <= Kmax) {
- double *pnext = pmem_next;
- while (pnext - private_mem + len <= PRIVATE_mem) {
- double *p = pnext;
- pnext = ATOMIC_PTR_CAS(pmem_next, pnext, pnext + len);
- if (LIKELY(p == pnext)) {
- rv = (Bigint*)pnext;
- ASSUME(rv);
- break;
- }
- }
- }
- if (!rv)
- rv = (Bigint*)MALLOC(len*sizeof(double));
-#endif
- rv->k = k;
- rv->maxwds = x;
- }
- FREE_DTOA_LOCK(0);
+
+ x = 1 << k;
+ rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
+ if (!rv) return NULL;
+ rv->k = k;
+ rv->maxwds = x;
rv->sign = rv->wds = 0;
return rv;
}
static void
-Bfree(Bigint *v)
+Bclear(Bigint **vp)
{
- Bigint *vn;
- if (v) {
- if (v->k > Kmax) {
- FREE(v);
- return;
- }
- ACQUIRE_DTOA_LOCK(0);
- do {
- do {
- vn = ATOMIC_PTR_CAS(freelist[v->k], 0, 0);
- } while (UNLIKELY(vn == BLOCKING_BIGINT));
- v->next = vn;
- } while (UNLIKELY(ATOMIC_PTR_CAS(freelist[v->k], vn, v) != vn));
- FREE_DTOA_LOCK(0);
- }
+ Bigint *v = *vp;
+ *vp = NULL;
+ if (v) FREE(v);
}
+#define Bfree(v) Bclear(&(v))
#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
(y)->wds*sizeof(Long) + 2*sizeof(int))
@@ -646,6 +599,10 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */
if (carry) {
if (wds >= b->maxwds) {
b1 = Balloc(b->k+1);
+ if (!b1) {
+ Bfree(b);
+ return NULL;
+ }
Bcopy(b1, b);
Bfree(b);
b = b1;
@@ -667,10 +624,12 @@ s2b(const char *s, int nd0, int nd, ULong y9)
for (k = 0, y = 1; x > y; y <<= 1, k++) ;
#ifdef Pack_32
b = Balloc(k);
+ if (!b) return NULL;
b->x[0] = y9;
b->wds = 1;
#else
b = Balloc(k+1);
+ if (!b) return NULL;
b->x[0] = y9 & 0xffff;
b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
#endif
@@ -680,13 +639,16 @@ s2b(const char *s, int nd0, int nd, ULong y9)
s += 9;
do {
b = multadd(b, 10, *s++ - '0');
+ if (!b) return NULL;
} while (++i < nd0);
s++;
}
else
s += 10;
- for (; i < nd; i++)
+ for (; i < nd; i++) {
b = multadd(b, 10, *s++ - '0');
+ if (!b) return NULL;
+ }
return b;
}
@@ -768,11 +730,14 @@ i2b(int i)
Bigint *b;
b = Balloc(1);
+ if (!b) return NULL;
b->x[0] = i;
b->wds = 1;
return b;
}
+#define Bzero_p(b) (!(b)->x[0] && (b)->wds <= 1)
+
static Bigint *
mult(Bigint *a, Bigint *b)
{
@@ -789,6 +754,14 @@ mult(Bigint *a, Bigint *b)
#endif
#endif
+ if (Bzero_p(a) || Bzero_p(b)) {
+ c = Balloc(0);
+ if (!c) return NULL;
+ c->wds = 1;
+ c->x[0] = 0;
+ return c;
+ }
+
if (a->wds < b->wds) {
c = a;
a = b;
@@ -801,6 +774,7 @@ mult(Bigint *a, Bigint *b)
if (wc > a->maxwds)
k++;
c = Balloc(k);
+ if (!c) return NULL;
for (x = c->x, xa = x + wc; x < xa; x++)
*x = 0;
xa = a->x;
@@ -880,50 +854,47 @@ static Bigint *
pow5mult(Bigint *b, int k)
{
Bigint *b1, *p5, *p51;
- Bigint *p5tmp;
int i;
static const int p05[3] = { 5, 25, 125 };
- if ((i = k & 3) != 0)
+ if ((i = k & 3) != 0) {
b = multadd(b, p05[i-1], 0);
+ if (!b) return NULL;
+ }
+
+#define b_cache(var, addr, new_expr) \
+ if ((var = addr) != 0) {} else { \
+ Bigint *tmp = 0; \
+ ACQUIRE_DTOA_LOCK(1); \
+ if (!(var = addr) && (var = (new_expr)) != 0) { \
+ var->next = 0; \
+ tmp = ATOMIC_PTR_CAS(addr, NULL, var); \
+ } \
+ FREE_DTOA_LOCK(1); \
+ if (UNLIKELY(tmp)) { \
+ Bfree(var); \
+ var = tmp; \
+ } \
+ else if (!var) { \
+ Bfree(b); \
+ return NULL; \
+ } \
+ }
if (!(k >>= 2))
return b;
- if (!(p5 = p5s)) {
- /* first time */
- ACQUIRE_DTOA_LOCK(1);
- if (!(p5 = p5s)) {
- p5 = i2b(625);
- p5->next = 0;
- p5tmp = ATOMIC_PTR_CAS(p5s, NULL, p5);
- if (UNLIKELY(p5tmp)) {
- Bfree(p5);
- p5 = p5tmp;
- }
- }
- FREE_DTOA_LOCK(1);
- }
+ /* first time */
+ b_cache(p5, p5s, i2b(625));
for (;;) {
if (k & 1) {
b1 = mult(b, p5);
Bfree(b);
b = b1;
+ if (!b) return NULL;
}
if (!(k >>= 1))
break;
- if (!(p51 = p5->next)) {
- ACQUIRE_DTOA_LOCK(1);
- if (!(p51 = p5->next)) {
- p51 = mult(p5,p5);
- p51->next = 0;
- p5tmp = ATOMIC_PTR_CAS(p5->next, NULL, p51);
- if (UNLIKELY(p5tmp)) {
- Bfree(p51);
- p51 = p5tmp;
- }
- }
- FREE_DTOA_LOCK(1);
- }
+ b_cache(p51, p5->next, mult(p5, p5));
p5 = p51;
}
return b;
@@ -936,6 +907,8 @@ lshift(Bigint *b, int k)
Bigint *b1;
ULong *x, *x1, *xe, z;
+ if (!k || Bzero_p(b)) return b;
+
#ifdef Pack_32
n = k >> 5;
#else
@@ -946,6 +919,10 @@ lshift(Bigint *b, int k)
for (i = b->maxwds; n1 > i; i <<= 1)
k1++;
b1 = Balloc(k1);
+ if (!b1) {
+ Bfree(b);
+ return NULL;
+ }
x1 = b1->x;
for (i = 0; i < n; i++)
*x1++ = 0;
@@ -1031,6 +1008,7 @@ diff(Bigint *a, Bigint *b)
i = cmp(a,b);
if (!i) {
c = Balloc(0);
+ if (!c) return NULL;
c->wds = 1;
c->x[0] = 0;
return c;
@@ -1044,6 +1022,7 @@ diff(Bigint *a, Bigint *b)
else
i = 0;
c = Balloc(a->k);
+ if (!c) return NULL;
c->sign = i;
wa = a->wds;
xa = a->x;
@@ -1229,6 +1208,7 @@ d2b(double d_, int *e, int *bits)
#else
b = Balloc(2);
#endif
+ if (!b) return NULL;
x = b->x;
z = d0 & Frac_mask;
@@ -1549,7 +1529,7 @@ break2:
aadj = 1.0;
nd0 = -4;
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
+ if (!*++s || (!(s1 = strchr(hexdigit, *s)) && *s != '.')) goto ret0;
if (*s == '0') {
while (*++s == '0');
if (!*s) goto ret;
@@ -1563,9 +1543,7 @@ break2:
} while (*++s && (s1 = strchr(hexdigit, *s)));
}
- if (*s == '.') {
- dsign = 1;
- if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
+ if ((*s == '.') && *++s && (s1 = strchr(hexdigit, *s))) {
if (nd0 < 0) {
while (*s == '0') {
s++;
@@ -1580,9 +1558,6 @@ break2:
}
}
}
- else {
- dsign = 0;
- }
if (*s == 'P' || *s == 'p') {
dsign = 0x2C - *++s; /* +: 2B, -: 2D */
@@ -1605,9 +1580,6 @@ break2:
} while ('0' <= c && c <= '9');
nd0 += nd * dsign;
}
- else {
- if (dsign) goto ret0;
- }
dval(rv) = ldexp(adj, nd0);
goto ret;
}
@@ -1644,9 +1616,9 @@ break2:
}
#endif
if (c == '.') {
- if (!ISDIGIT(s[1]))
- goto dig_done;
c = *++s;
+ if (!ISDIGIT(c))
+ goto dig_done;
if (!nd) {
for (; c == '0'; c = *++s)
nz++;
@@ -1987,12 +1959,16 @@ undfl:
/* Put digits into bd: true value = bd * 10^e */
bd0 = s2b(s0, nd0, nd, y);
+ if (!bd0) goto ret;
for (;;) {
bd = Balloc(bd0->k);
+ if (!bd) goto retfree;
Bcopy(bd, bd0);
bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
+ if (!bb) goto retfree;
bs = i2b(1);
+ if (!bs) goto retfree;
if (e >= 0) {
bb2 = bb5 = 0;
@@ -2049,19 +2025,30 @@ undfl:
}
if (bb5 > 0) {
bs = pow5mult(bs, bb5);
+ if (!bs) goto retfree;
bb1 = mult(bs, bb);
Bfree(bb);
bb = bb1;
+ if (!bb) goto retfree;
}
- if (bb2 > 0)
+ if (bb2 > 0) {
bb = lshift(bb, bb2);
- if (bd5 > 0)
+ if (!bb) goto retfree;
+ }
+ if (bd5 > 0) {
bd = pow5mult(bd, bd5);
- if (bd2 > 0)
+ if (!bd) goto retfree;
+ }
+ if (bd2 > 0) {
bd = lshift(bd, bd2);
- if (bs2 > 0)
+ if (!bd) goto retfree;
+ }
+ if (bs2 > 0) {
bs = lshift(bs, bs2);
+ if (!bs) goto retfree;
+ }
delta = diff(bb, bd);
+ if (!delta) goto retfree;
dsign = delta->sign;
delta->sign = 0;
i = cmp(delta, bs);
@@ -2094,6 +2081,7 @@ undfl:
#endif
{
delta = lshift(delta,Log2P);
+ if (!delta) goto nomem;
if (cmp(delta, bs) <= 0)
adj = -0.5;
}
@@ -2183,6 +2171,7 @@ apply_adj:
break;
}
delta = lshift(delta,Log2P);
+ if (!delta) goto retfree;
if (cmp(delta, bs) > 0)
goto drop_down;
break;
@@ -2585,6 +2574,7 @@ nrv_alloc(const char *s, char **rve, size_t n)
char *rv, *t;
t = rv = rv_alloc(n);
+ if (!rv) return NULL;
while ((*t = *s++) != 0) t++;
if (rve)
*rve = t;
@@ -2757,6 +2747,7 @@ dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
b = d2b(dval(d), &be, &bbits);
+ if (!b) return NULL;
#ifdef Sudden_Underflow
i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
#else
@@ -2876,13 +2867,20 @@ dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
leftright = 0;
/* no break */
case 5:
- i = ndigits + k + 1;
+ if (ckd_add(&i, ndigits, k + 1)) { /* k + 1 should be safe */
+ Bfree(b);
+ return NULL;
+ }
ilim = i;
ilim1 = i - 1;
if (i <= 0)
i = 1;
}
s = s0 = rv_alloc(i+1);
+ if (!s) {
+ Bfree(b);
+ return NULL;
+ }
#ifdef Honor_FLT_ROUNDS
if (mode > 1 && rounding != 1)
@@ -3063,6 +3061,7 @@ bump_up:
b2 += i;
s2 += i;
mhi = i2b(1);
+ if (!mhi) goto nomem;
}
if (m2 > 0 && s2 > 0) {
i = m2 < s2 ? m2 : s2;
@@ -3074,19 +3073,28 @@ bump_up:
if (leftright) {
if (m5 > 0) {
mhi = pow5mult(mhi, m5);
+ if (!mhi) goto nomem;
b1 = mult(mhi, b);
Bfree(b);
b = b1;
+ if (!b) goto nomem;
}
- if ((j = b5 - m5) != 0)
+ if ((j = b5 - m5) != 0) {
b = pow5mult(b, j);
+ if (!b) goto nomem;
+ }
}
- else
+ else {
b = pow5mult(b, b5);
+ if (!b) goto nomem;
+ }
}
S = i2b(1);
- if (s5 > 0)
+ if (!S) goto nomem;
+ if (s5 > 0) {
S = pow5mult(S, s5);
+ if (!S) goto nomem;
+ }
/* Check for special case that d is a normalized power of 2. */
@@ -3134,16 +3142,23 @@ bump_up:
m2 += i;
s2 += i;
}
- if (b2 > 0)
+ if (b2 > 0) {
b = lshift(b, b2);
- if (s2 > 0)
+ if (!b) goto nomem;
+ }
+ if (s2 > 0) {
S = lshift(S, s2);
+ if (!S) goto nomem;
+ }
if (k_check) {
if (cmp(b,S) < 0) {
k--;
b = multadd(b, 10, 0); /* we botched the k estimate */
- if (leftright)
+ if (!b) goto nomem;
+ if (leftright) {
mhi = multadd(mhi, 10, 0);
+ if (!mhi) goto nomem;
+ }
ilim = ilim1;
}
}
@@ -3160,8 +3175,10 @@ one_digit:
goto ret;
}
if (leftright) {
- if (m2 > 0)
+ if (m2 > 0) {
mhi = lshift(mhi, m2);
+ if (!mhi) goto nomem;
+ }
/* Compute mlo -- check for special case
* that d is a normalized power of 2.
@@ -3170,8 +3187,10 @@ one_digit:
mlo = mhi;
if (spec_case) {
mhi = Balloc(mhi->k);
+ if (!mhi) goto nomem;
Bcopy(mhi, mlo);
mhi = lshift(mhi, Log2P);
+ if (!mhi) goto nomem;
}
for (i = 1;;i++) {
@@ -3181,6 +3200,7 @@ one_digit:
*/
j = cmp(b, mlo);
delta = diff(S, mhi);
+ if (!delta) goto nomem;
j1 = delta->sign ? 1 : cmp(b, delta);
Bfree(delta);
#ifndef ROUND_BIASED
@@ -3221,6 +3241,7 @@ one_digit:
#endif /*Honor_FLT_ROUNDS*/
if (j1 > 0) {
b = lshift(b, 1);
+ if (!b) goto nomem;
j1 = cmp(b, S);
if ((j1 > 0 || (j1 == 0 && (dig & 1))) && dig++ == '9')
goto round_9_up;
@@ -3249,11 +3270,16 @@ keep_dig:
if (i == ilim)
break;
b = multadd(b, 10, 0);
- if (mlo == mhi)
+ if (!b) goto nomem;
+ if (mlo == mhi) {
mlo = mhi = multadd(mhi, 10, 0);
+ if (!mlo) goto nomem;
+ }
else {
mlo = multadd(mlo, 10, 0);
+ if (!mlo) goto nomem;
mhi = multadd(mhi, 10, 0);
+ if (!mhi) goto nomem;
}
}
}
@@ -3269,6 +3295,7 @@ keep_dig:
if (i >= ilim)
break;
b = multadd(b, 10, 0);
+ if (!b) goto nomem;
}
/* Round off last digit */
@@ -3280,6 +3307,7 @@ keep_dig:
}
#endif
b = lshift(b, 1);
+ if (!b) goto nomem;
j = cmp(b, S);
if (j > 0 || (j == 0 && (dig & 1))) {
roundoff:
@@ -3321,6 +3349,16 @@ ret1:
if (rve)
*rve = s;
return s0;
+ nomem:
+ if (S) Bfree(S);
+ if (mhi) {
+ if (mlo && mlo != mhi)
+ Bfree(mlo);
+ Bfree(mhi);
+ }
+ if (b) Bfree(b);
+ FREE(s0);
+ return NULL;
}
/*-
@@ -3429,6 +3467,7 @@ hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rv
*/
bufsize = (ndigits > 0) ? ndigits : SIGFIGS;
s0 = rv_alloc(bufsize+1);
+ if (!s0) return NULL;
/* Round to the desired number of digits. */
if (SIGFIGS > ndigits && ndigits > 0) {
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c
index 1220e5f9ad..59417e158e 100644
--- a/missing/explicit_bzero.c
+++ b/missing/explicit_bzero.c
@@ -1,12 +1,9 @@
#ifndef __STDC_WANT_LIB_EXT1__
-#define __STDC_WANT_LIB_EXT1__ 1
+#define __STDC_WANT_LIB_EXT1__ 1 /* for memset_s() */
#endif
#include "ruby/missing.h"
#include <string.h>
-#ifdef HAVE_MEMSET_S
-# include <string.h>
-#endif
#ifdef _WIN32
#include <windows.h>
diff --git a/missing/procstat_vm.c b/missing/procstat_vm.c
index 76fd8f61ba..155ee355d1 100644
--- a/missing/procstat_vm.c
+++ b/missing/procstat_vm.c
@@ -6,7 +6,7 @@
# define KVME_TYPE_MGTDEVICE 8
# endif
void
-procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
+procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp, FILE *errout)
{
struct kinfo_vmentry *freep, *kve;
int ptrwidth;
@@ -17,7 +17,7 @@ procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
#else
ptrwidth = 2*sizeof(void *) + 2;
#endif
- fprintf(stderr, "%*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
+ fprintf(errout, "%*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
ptrwidth, "START", ptrwidth, "END", "PRT", "RES",
"P""RES", "REF", "SHD", "FL", "TP", "PATH");
@@ -30,20 +30,20 @@ procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
return;
for (i = 0; i < cnt; i++) {
kve = &freep[i];
- fprintf(stderr, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
- fprintf(stderr, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
- fprintf(stderr, "%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
- fprintf(stderr, "%s", kve->kve_protection & KVME_PROT_WRITE ? "w" : "-");
- fprintf(stderr, "%s ", kve->kve_protection & KVME_PROT_EXEC ? "x" : "-");
- fprintf(stderr, "%4d ", kve->kve_resident);
- fprintf(stderr, "%4d ", kve->kve_private_resident);
- fprintf(stderr, "%3d ", kve->kve_ref_count);
- fprintf(stderr, "%3d ", kve->kve_shadow_count);
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_COW ? "C" : "-");
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" :
+ fprintf(errout, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
+ fprintf(errout, "%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
+ fprintf(errout, "%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
+ fprintf(errout, "%s", kve->kve_protection & KVME_PROT_WRITE ? "w" : "-");
+ fprintf(errout, "%s ", kve->kve_protection & KVME_PROT_EXEC ? "x" : "-");
+ fprintf(errout, "%4d ", kve->kve_resident);
+ fprintf(errout, "%4d ", kve->kve_private_resident);
+ fprintf(errout, "%3d ", kve->kve_ref_count);
+ fprintf(errout, "%3d ", kve->kve_shadow_count);
+ fprintf(errout, "%-1s", kve->kve_flags & KVME_FLAG_COW ? "C" : "-");
+ fprintf(errout, "%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" :
"-");
- fprintf(stderr, "%-1s", kve->kve_flags & KVME_FLAG_SUPER ? "S" : "-");
- fprintf(stderr, "%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ? "U" :
+ fprintf(errout, "%-1s", kve->kve_flags & KVME_FLAG_SUPER ? "S" : "-");
+ fprintf(errout, "%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ? "U" :
kve->kve_flags & KVME_FLAG_GROWS_DOWN ? "D" : "-");
switch (kve->kve_type) {
case KVME_TYPE_NONE:
@@ -78,8 +78,8 @@ procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
str = "??";
break;
}
- fprintf(stderr, "%-2s ", str);
- fprintf(stderr, "%-s\n", kve->kve_path);
+ fprintf(errout, "%-2s ", str);
+ fprintf(errout, "%-s\n", kve->kve_path);
}
free(freep);
}
diff --git a/missing/setproctitle.c b/missing/setproctitle.c
index 811829c060..5b2dfa65ce 100644
--- a/missing/setproctitle.c
+++ b/missing/setproctitle.c
@@ -80,10 +80,43 @@ static char **argv1_addr = NULL;
#endif /* HAVE_SETPROCTITLE */
+#if defined(SPT_TYPE) && SPT_TYPE == SPT_REUSEARGV
+# define ALLOCATE_ENVIRON 1
+#else
+# define ALLOCATE_ENVIRON 0
+#endif
+
+#if ALLOCATE_ENVIRON
+/* system_environ is the value of environ before we allocate a custom buffer.
+ *
+ * We use this to restore environ in ruby_free_proctitle.
+ */
+static char **system_environ = NULL;
+/* orig_environ is the buffer we allocate for environ.
+ *
+ * We use this to free this buffer in ruby_free_proctitle. When we add new
+ * environment variables using setenv, the system may change environ to a
+ * different buffer and will not free the original buffer, so we need to hold
+ * onto this so we can free it in ruby_free_proctitle.
+ *
+ * We must not free any of the contents because it may change if the system
+ * updates existing environment variables.
+ */
+static char **orig_environ = NULL;
+/* alloc_environ is a copy of orig_environ.
+ *
+ * We use this to free all the original string copies that were in orig_environ.
+ * Since environ could be changed to point to strings allocated by the system
+ * if environment variables are updated, so we need this to point to the
+ * original strings.
+ */
+static char **alloc_environ = NULL;
+#endif
+
void
compat_init_setproctitle(int argc, char *argv[])
{
-#if defined(SPT_TYPE) && SPT_TYPE == SPT_REUSEARGV
+#if ALLOCATE_ENVIRON
extern char **environ;
char *lastargv = NULL;
char *lastenvp = NULL;
@@ -100,9 +133,13 @@ compat_init_setproctitle(int argc, char *argv[])
return;
/* Fail if we can't allocate room for the new environment */
- for (i = 0; envp[i] != NULL; i++)
- ;
- if ((environ = calloc(i + 1, sizeof(*environ))) == NULL) {
+ for (i = 0; envp[i] != NULL; i++);
+
+ system_environ = environ;
+
+ alloc_environ = xcalloc(i + 1, sizeof(*environ));
+ orig_environ = environ = xcalloc(i + 1, sizeof(*environ));
+ if (environ == NULL) {
environ = envp; /* put it back */
return;
}
@@ -129,12 +166,31 @@ compat_init_setproctitle(int argc, char *argv[])
argv_env_len = lastenvp - argv[0];
for (i = 0; envp[i] != NULL; i++)
- environ[i] = ruby_strdup(envp[i]);
- environ[i] = NULL;
+ alloc_environ[i] = environ[i] = ruby_strdup(envp[i]);
+ alloc_environ[i] = environ[i] = NULL;
#endif /* SPT_REUSEARGV */
}
+void
+ruby_free_proctitle(void)
+{
+#if ALLOCATE_ENVIRON
+ extern char **environ;
+
+ if (!orig_environ) return; /* environ is allocated by OS */
+
+ for (int i = 0; alloc_environ[i] != NULL; i++) {
+ xfree(alloc_environ[i]);
+ }
+ xfree(alloc_environ);
+ xfree(orig_environ);
+
+ environ = system_environ;
+#endif
+}
+
#ifndef HAVE_SETPROCTITLE
+
void
setproctitle(const char *fmt, ...)
{
diff --git a/nilclass.rb b/nilclass.rb
index 5a2e19680d..acd5666c71 100644
--- a/nilclass.rb
+++ b/nilclass.rb
@@ -1,6 +1,32 @@
class NilClass
#
# call-seq:
+ # rationalize(eps = nil) -> (0/1)
+ #
+ # Returns zero as a Rational:
+ #
+ # nil.rationalize # => (0/1)
+ #
+ # Argument +eps+ is ignored.
+ #
+ def rationalize(eps = nil)
+ 0r
+ end
+
+ #
+ # call-seq:
+ # to_c -> (0+0i)
+ #
+ # Returns zero as a Complex:
+ #
+ # nil.to_c # => (0+0i)
+ #
+ def to_c
+ 0i
+ end
+
+ #
+ # call-seq:
# nil.to_i -> 0
#
# Always returns zero.
@@ -22,4 +48,16 @@ class NilClass
def to_f
return 0.0
end
+
+ #
+ # call-seq:
+ # to_r -> (0/1)
+ #
+ # Returns zero as a Rational:
+ #
+ # nil.to_r # => (0/1)
+ #
+ def to_r
+ 0r
+ end
end
diff --git a/node.c b/node.c
index a6cb498778..5d00823eb6 100644
--- a/node.c
+++ b/node.c
@@ -9,1204 +9,123 @@
**********************************************************************/
-#include "internal.h"
-#include "internal/hash.h"
-#include "internal/variable.h"
-#include "ruby/ruby.h"
-#include "vm_core.h"
-
-#define NODE_BUF_DEFAULT_LEN 16
-
-#define A(str) rb_str_cat2(buf, (str))
-#define AR(str) rb_str_concat(buf, (str))
-
-#define A_INDENT add_indent(buf, indent)
-#define D_INDENT rb_str_cat2(indent, next_indent)
-#define D_DEDENT rb_str_resize(indent, RSTRING_LEN(indent) - 4)
-#define A_ID(id) add_id(buf, (id))
-#define A_INT(val) rb_str_catf(buf, "%d", (val))
-#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
-#define A_LIT(lit) AR(rb_dump_literal(lit))
-#define A_NODE_HEADER(node, term) \
- rb_str_catf(buf, "@ %s (id: %d, line: %d, location: (%d,%d)-(%d,%d))%s"term, \
- ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node), \
- nd_first_lineno(node), nd_first_column(node), \
- nd_last_lineno(node), nd_last_column(node), \
- (node->flags & NODE_FL_NEWLINE ? "*" : ""))
-#define A_FIELD_HEADER(len, name, term) \
- rb_str_catf(buf, "+- %.*s:"term, (len), (name))
-#define D_FIELD_HEADER(len, name, term) (A_INDENT, A_FIELD_HEADER(len, name, term))
-
-#define D_NULL_NODE (A_INDENT, A("(null node)\n"))
-#define D_NODE_HEADER(node) (A_INDENT, A_NODE_HEADER(node, "\n"))
-
-#define COMPOUND_FIELD(len, name) \
- FIELD_BLOCK((D_FIELD_HEADER((len), (name), "\n"), D_INDENT), D_DEDENT)
-
-#define COMPOUND_FIELD1(name, ann) \
- COMPOUND_FIELD(FIELD_NAME_LEN(name, ann), \
- FIELD_NAME_DESC(name, ann))
-
-#define FIELD_NAME_DESC(name, ann) name " (" ann ")"
-#define FIELD_NAME_LEN(name, ann) (int)( \
- comment ? \
- rb_strlen_lit(FIELD_NAME_DESC(name, ann)) : \
- rb_strlen_lit(name))
-#define SIMPLE_FIELD(len, name) \
- FIELD_BLOCK(D_FIELD_HEADER((len), (name), " "), A("\n"))
-
-#define FIELD_BLOCK(init, reset) \
- for (init, field_flag = 1; \
- field_flag; /* should be optimized away */ \
- reset, field_flag = 0)
-
-#define SIMPLE_FIELD1(name, ann) SIMPLE_FIELD(FIELD_NAME_LEN(name, ann), FIELD_NAME_DESC(name, ann))
-#define F_CUSTOM1(name, ann) SIMPLE_FIELD1(#name, ann)
-#define F_ID(name, ann) SIMPLE_FIELD1(#name, ann) A_ID(node->name)
-#define F_GENTRY(name, ann) SIMPLE_FIELD1(#name, ann) A_ID(node->name)
-#define F_INT(name, ann) SIMPLE_FIELD1(#name, ann) A_INT(node->name)
-#define F_LONG(name, ann) SIMPLE_FIELD1(#name, ann) A_LONG(node->name)
-#define F_LIT(name, ann) SIMPLE_FIELD1(#name, ann) A_LIT(node->name)
-#define F_MSG(name, ann, desc) SIMPLE_FIELD1(#name, ann) A(desc)
+#ifdef UNIVERSAL_PARSER
+#include <stddef.h>
+#include "node.h"
+#include "rubyparser.h"
+#endif
-#define F_NODE(name, ann) \
- COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, node->name);}
-
-#define ANN(ann) \
- if (comment) { \
- A_INDENT; A("| # " ann "\n"); \
- }
-
-#define LAST_NODE (next_indent = " ")
+#include "internal/variable.h"
-VALUE
-rb_dump_literal(VALUE lit)
-{
- if (!RB_SPECIAL_CONST_P(lit)) {
- VALUE str;
- switch (RB_BUILTIN_TYPE(lit)) {
- case T_CLASS: case T_MODULE: case T_ICLASS:
- str = rb_class_path(lit);
- if (FL_TEST(lit, FL_SINGLETON)) {
- str = rb_sprintf("<%"PRIsVALUE">", str);
- }
- return str;
- default:
- break;
- }
- }
- return rb_inspect(lit);
-}
+#define NODE_BUF_DEFAULT_SIZE (sizeof(struct RNode) * 16)
static void
-add_indent(VALUE buf, VALUE indent)
+init_node_buffer_elem(node_buffer_elem_t *nbe, size_t allocated, void *xmalloc(size_t))
{
- AR(indent);
+ nbe->allocated = allocated;
+ nbe->used = 0;
+ nbe->len = 0;
+ nbe->nodes = xmalloc(allocated / sizeof(struct RNode) * sizeof(struct RNode *)); /* All node requires at least RNode */
}
static void
-add_id(VALUE buf, ID id)
+init_node_buffer_list(node_buffer_list_t *nb, node_buffer_elem_t *head, void *xmalloc(size_t))
{
- if (id == 0) {
- A("(null)");
- }
- else {
- VALUE str = rb_id2str(id);
- if (str) {
- A(":"); AR(str);
- }
- else {
- rb_str_catf(buf, "(internal variable: 0x%"PRIsVALUE")", id);
- }
- }
+ init_node_buffer_elem(head, NODE_BUF_DEFAULT_SIZE, xmalloc);
+ nb->head = nb->last = head;
+ nb->head->next = NULL;
}
-struct add_option_arg {
- VALUE buf, indent;
- st_index_t count;
-};
-
-static void dump_node(VALUE, VALUE, int, const NODE *);
-static const char default_indent[] = "| ";
+#ifdef UNIVERSAL_PARSER
+#define ruby_xmalloc config->malloc
+#endif
-static void
-dump_array(VALUE buf, VALUE indent, int comment, const NODE *node)
+#ifdef UNIVERSAL_PARSER
+static node_buffer_t *
+rb_node_buffer_new(const rb_parser_config_t *config)
+#else
+static node_buffer_t *
+rb_node_buffer_new(void)
+#endif
{
- int field_flag;
- const char *next_indent = default_indent;
- F_LONG(nd_alen, "length");
- F_NODE(nd_head, "element");
- while (node->nd_next && nd_type_p(node->nd_next, NODE_LIST)) {
- node = node->nd_next;
- F_NODE(nd_head, "element");
- }
- LAST_NODE;
- F_NODE(nd_next, "next element");
+ const size_t bucket_size = offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_SIZE;
+ const size_t alloc_size = sizeof(node_buffer_t) + (bucket_size);
+ STATIC_ASSERT(
+ integer_overflow,
+ offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_SIZE
+ > sizeof(node_buffer_t) + sizeof(node_buffer_elem_t));
+ node_buffer_t *nb = ruby_xmalloc(alloc_size);
+ init_node_buffer_list(&nb->buffer_list, (node_buffer_elem_t*)&nb[1], ruby_xmalloc);
+ nb->local_tables = 0;
+ nb->tokens = 0;
+ return nb;
}
-static void
-dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
-{
- int field_flag;
- int i;
- const char *next_indent = default_indent;
- enum node_type type;
-
- if (!node) {
- D_NULL_NODE;
- return;
- }
-
- D_NODE_HEADER(node);
-
- type = nd_type(node);
- switch (type) {
- case NODE_BLOCK:
- ANN("statement sequence");
- ANN("format: [nd_head]; ...; [nd_next]");
- ANN("example: foo; bar");
- i = 0;
- do {
- A_INDENT;
- rb_str_catf(buf, "+- nd_head (%s%d):\n",
- comment ? "statement #" : "", ++i);
- if (!node->nd_next) LAST_NODE;
- D_INDENT;
- dump_node(buf, indent, comment, node->nd_head);
- D_DEDENT;
- } while (node->nd_next &&
- nd_type_p(node->nd_next, NODE_BLOCK) &&
- (node = node->nd_next, 1));
- if (node->nd_next) {
- LAST_NODE;
- F_NODE(nd_next, "next block");
- }
- return;
-
- case NODE_IF:
- ANN("if statement");
- ANN("format: if [nd_cond] then [nd_body] else [nd_else] end");
- ANN("example: if x == 1 then foo else bar end");
- F_NODE(nd_cond, "condition expr");
- F_NODE(nd_body, "then clause");
- LAST_NODE;
- F_NODE(nd_else, "else clause");
- return;
-
- case NODE_UNLESS:
- ANN("unless statement");
- ANN("format: unless [nd_cond] then [nd_body] else [nd_else] end");
- ANN("example: unless x == 1 then foo else bar end");
- F_NODE(nd_cond, "condition expr");
- F_NODE(nd_body, "then clause");
- LAST_NODE;
- F_NODE(nd_else, "else clause");
- return;
-
- case NODE_CASE:
- ANN("case statement");
- ANN("format: case [nd_head]; [nd_body]; end");
- ANN("example: case x; when 1; foo; when 2; bar; else baz; end");
- F_NODE(nd_head, "case expr");
- LAST_NODE;
- F_NODE(nd_body, "when clauses");
- return;
- case NODE_CASE2:
- ANN("case statement with no head");
- ANN("format: case; [nd_body]; end");
- ANN("example: case; when 1; foo; when 2; bar; else baz; end");
- F_NODE(nd_head, "case expr");
- LAST_NODE;
- F_NODE(nd_body, "when clauses");
- return;
- case NODE_CASE3:
- ANN("case statement (pattern matching)");
- ANN("format: case [nd_head]; [nd_body]; end");
- ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
- F_NODE(nd_head, "case expr");
- LAST_NODE;
- F_NODE(nd_body, "in clauses");
- return;
-
- case NODE_WHEN:
- ANN("when clause");
- ANN("format: when [nd_head]; [nd_body]; (when or else) [nd_next]");
- ANN("example: case x; when 1; foo; when 2; bar; else baz; end");
- F_NODE(nd_head, "when value");
- F_NODE(nd_body, "when body");
- LAST_NODE;
- F_NODE(nd_next, "next when clause");
- return;
-
- case NODE_IN:
- ANN("in clause");
- ANN("format: in [nd_head]; [nd_body]; (in or else) [nd_next]");
- ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
- F_NODE(nd_head, "in pattern");
- F_NODE(nd_body, "in body");
- LAST_NODE;
- F_NODE(nd_next, "next in clause");
- return;
-
- case NODE_WHILE:
- ANN("while statement");
- ANN("format: while [nd_cond]; [nd_body]; end");
- ANN("example: while x == 1; foo; end");
- goto loop;
- case NODE_UNTIL:
- ANN("until statement");
- ANN("format: until [nd_cond]; [nd_body]; end");
- ANN("example: until x == 1; foo; end");
- loop:
- F_CUSTOM1(nd_state, "begin-end-while?") {
- A_INT((int)node->nd_state);
- A((node->nd_state == 1) ? " (while-end)" : " (begin-end-while)");
- }
- F_NODE(nd_cond, "condition");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
-
- case NODE_ITER:
- ANN("method call with block");
- ANN("format: [nd_iter] { [nd_body] }");
- ANN("example: 3.times { foo }");
- goto iter;
- case NODE_FOR:
- ANN("for statement");
- ANN("format: for * in [nd_iter] do [nd_body] end");
- ANN("example: for i in 1..3 do foo end");
- iter:
- F_NODE(nd_iter, "iteration receiver");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
-
- case NODE_FOR_MASGN:
- ANN("vars of for statement with masgn");
- ANN("format: for [nd_var] in ... do ... end");
- ANN("example: for x, y in 1..3 do foo end");
- LAST_NODE;
- F_NODE(nd_var, "var");
- return;
-
- case NODE_BREAK:
- ANN("break statement");
- ANN("format: break [nd_stts]");
- ANN("example: break 1");
- goto jump;
- case NODE_NEXT:
- ANN("next statement");
- ANN("format: next [nd_stts]");
- ANN("example: next 1");
- goto jump;
- case NODE_RETURN:
- ANN("return statement");
- ANN("format: return [nd_stts]");
- ANN("example: return 1");
- jump:
- LAST_NODE;
- F_NODE(nd_stts, "value");
- return;
-
- case NODE_REDO:
- ANN("redo statement");
- ANN("format: redo");
- ANN("example: redo");
- return;
-
- case NODE_RETRY:
- ANN("retry statement");
- ANN("format: retry");
- ANN("example: retry");
- return;
-
- case NODE_BEGIN:
- ANN("begin statement");
- ANN("format: begin; [nd_body]; end");
- ANN("example: begin; 1; end");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
-
- case NODE_RESCUE:
- ANN("rescue clause");
- ANN("format: begin; [nd_body]; (rescue) [nd_resq]; else [nd_else]; end");
- ANN("example: begin; foo; rescue; bar; else; baz; end");
- F_NODE(nd_head, "body");
- F_NODE(nd_resq, "rescue clause list");
- LAST_NODE;
- F_NODE(nd_else, "rescue else clause");
- return;
-
- case NODE_RESBODY:
- ANN("rescue clause (cont'd)");
- ANN("format: rescue [nd_args]; [nd_body]; (rescue) [nd_head]");
- ANN("example: begin; foo; rescue; bar; else; baz; end");
- F_NODE(nd_args, "rescue exceptions");
- F_NODE(nd_body, "rescue clause");
- LAST_NODE;
- F_NODE(nd_head, "next rescue clause");
- return;
-
- case NODE_ENSURE:
- ANN("ensure clause");
- ANN("format: begin; [nd_head]; ensure; [nd_ensr]; end");
- ANN("example: begin; foo; ensure; bar; end");
- F_NODE(nd_head, "body");
- LAST_NODE;
- F_NODE(nd_ensr, "ensure clause");
- return;
-
- case NODE_AND:
- ANN("&& operator");
- ANN("format: [nd_1st] && [nd_2nd]");
- ANN("example: foo && bar");
- goto andor;
- case NODE_OR:
- ANN("|| operator");
- ANN("format: [nd_1st] || [nd_2nd]");
- ANN("example: foo || bar");
- andor:
- while (1) {
- F_NODE(nd_1st, "left expr");
- if (!node->nd_2nd || !nd_type_p(node->nd_2nd, type))
- break;
- node = node->nd_2nd;
- }
- LAST_NODE;
- F_NODE(nd_2nd, "right expr");
- return;
-
- case NODE_MASGN:
- ANN("multiple assignment");
- ANN("format: [nd_head], [nd_args] = [nd_value]");
- ANN("example: a, b = foo");
- F_NODE(nd_value, "rhsn");
- F_NODE(nd_head, "lhsn");
- if (NODE_NAMED_REST_P(node->nd_args)) {
- LAST_NODE;
- F_NODE(nd_args, "splatn");
- }
- else {
- F_MSG(nd_args, "splatn", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- return;
-
- case NODE_LASGN:
- ANN("local variable assignment");
- ANN("format: [nd_vid](lvar) = [nd_value]");
- ANN("example: x = foo");
- F_ID(nd_vid, "local variable");
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
- }
- else {
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- }
- return;
- case NODE_DASGN:
- ANN("dynamic variable assignment");
- ANN("format: [nd_vid](dvar) = [nd_value]");
- ANN("example: x = nil; 1.times { x = foo }");
- ANN("example: 1.times { x = foo }");
- F_ID(nd_vid, "local variable");
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
- }
- else {
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- }
- return;
- case NODE_IASGN:
- ANN("instance variable assignment");
- ANN("format: [nd_vid](ivar) = [nd_value]");
- ANN("example: @x = foo");
- F_ID(nd_vid, "instance variable");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
- case NODE_CVASGN:
- ANN("class variable assignment");
- ANN("format: [nd_vid](cvar) = [nd_value]");
- ANN("example: @@x = foo");
- F_ID(nd_vid, "class variable");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
- case NODE_GASGN:
- ANN("global variable assignment");
- ANN("format: [nd_entry](gvar) = [nd_value]");
- ANN("example: $x = foo");
- F_GENTRY(nd_entry, "global variable");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
-
- case NODE_CDECL:
- ANN("constant declaration");
- ANN("format: [nd_else]::[nd_vid](constant) = [nd_value]");
- ANN("example: X = foo");
- if (node->nd_vid) {
- F_ID(nd_vid, "constant");
- F_MSG(nd_else, "extension", "not used");
- }
- else {
- F_MSG(nd_vid, "constant", "0 (see extension field)");
- F_NODE(nd_else, "extension");
- }
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
-
- case NODE_OP_ASGN1:
- ANN("array assignment with operator");
- ANN("format: [nd_recv] [ [nd_args->nd_head] ] [nd_mid]= [nd_args->nd_body]");
- ANN("example: ary[1] += foo");
- F_NODE(nd_recv, "receiver");
- F_ID(nd_mid, "operator");
- F_NODE(nd_args->nd_head, "index");
- LAST_NODE;
- F_NODE(nd_args->nd_body, "rvalue");
- return;
-
- case NODE_OP_ASGN2:
- ANN("attr assignment with operator");
- ANN("format: [nd_recv].[attr] [nd_next->nd_mid]= [nd_value]");
- ANN(" where [attr]: [nd_next->nd_vid]");
- ANN("example: struct.field += foo");
- F_NODE(nd_recv, "receiver");
- F_CUSTOM1(nd_next->nd_vid, "attr") {
- if (node->nd_next->nd_aid) A("? ");
- A_ID(node->nd_next->nd_vid);
- }
- F_ID(nd_next->nd_mid, "operator");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
-
- case NODE_OP_ASGN_AND:
- ANN("assignment with && operator");
- ANN("format: [nd_head] &&= [nd_value]");
- ANN("example: foo &&= bar");
- goto asgn_andor;
- case NODE_OP_ASGN_OR:
- ANN("assignment with || operator");
- ANN("format: [nd_head] ||= [nd_value]");
- ANN("example: foo ||= bar");
- asgn_andor:
- F_NODE(nd_head, "variable");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
-
- case NODE_OP_CDECL:
- ANN("constant declaration with operator");
- ANN("format: [nd_head](constant) [nd_aid]= [nd_value]");
- ANN("example: A::B ||= 1");
- F_NODE(nd_head, "constant");
- F_ID(nd_aid, "operator");
- LAST_NODE;
- F_NODE(nd_value, "rvalue");
- return;
-
- case NODE_CALL:
- ANN("method invocation");
- ANN("format: [nd_recv].[nd_mid]([nd_args])");
- ANN("example: obj.foo(1)");
- F_ID(nd_mid, "method id");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_OPCALL:
- ANN("method invocation");
- ANN("format: [nd_recv] [nd_mid] [nd_args]");
- ANN("example: foo + bar");
- F_ID(nd_mid, "method id");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_FCALL:
- ANN("function call");
- ANN("format: [nd_mid]([nd_args])");
- ANN("example: foo(1)");
- F_ID(nd_mid, "method id");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_VCALL:
- ANN("function call with no argument");
- ANN("format: [nd_mid]");
- ANN("example: foo");
- F_ID(nd_mid, "method id");
- return;
-
- case NODE_QCALL:
- ANN("safe method invocation");
- ANN("format: [nd_recv]&.[nd_mid]([nd_args])");
- ANN("example: obj&.foo(1)");
- F_ID(nd_mid, "method id");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_SUPER:
- ANN("super invocation");
- ANN("format: super [nd_args]");
- ANN("example: super 1");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_ZSUPER:
- ANN("super invocation with no argument");
- ANN("format: super");
- ANN("example: super");
- return;
-
- case NODE_LIST:
- ANN("list constructor");
- ANN("format: [ [nd_head], [nd_next].. ] (length: [nd_alen])");
- ANN("example: [1, 2, 3]");
- goto ary;
- case NODE_VALUES:
- ANN("return arguments");
- ANN("format: [ [nd_head], [nd_next].. ] (length: [nd_alen])");
- ANN("example: return 1, 2, 3");
- ary:
- dump_array(buf, indent, comment, node);
- return;
-
- case NODE_ZLIST:
- ANN("empty list constructor");
- ANN("format: []");
- ANN("example: []");
- return;
-
- case NODE_HASH:
- if (!node->nd_brace) {
- ANN("keyword arguments");
- ANN("format: nd_head");
- ANN("example: a: 1, b: 2");
- }
- else {
- ANN("hash constructor");
- ANN("format: { [nd_head] }");
- ANN("example: { 1 => 2, 3 => 4 }");
- }
- F_CUSTOM1(nd_brace, "keyword arguments or hash literal") {
- switch (node->nd_brace) {
- case 0: A("0 (keyword argument)"); break;
- case 1: A("1 (hash literal)"); break;
- }
- }
- LAST_NODE;
- F_NODE(nd_head, "contents");
- return;
-
- case NODE_YIELD:
- ANN("yield invocation");
- ANN("format: yield [nd_head]");
- ANN("example: yield 1");
- LAST_NODE;
- F_NODE(nd_head, "arguments");
- return;
-
- case NODE_LVAR:
- ANN("local variable reference");
- ANN("format: [nd_vid](lvar)");
- ANN("example: x");
- F_ID(nd_vid, "local variable");
- return;
- case NODE_DVAR:
- ANN("dynamic variable reference");
- ANN("format: [nd_vid](dvar)");
- ANN("example: 1.times { x = 1; x }");
- F_ID(nd_vid, "local variable");
- return;
- case NODE_IVAR:
- ANN("instance variable reference");
- ANN("format: [nd_vid](ivar)");
- ANN("example: @x");
- F_ID(nd_vid, "instance variable");
- return;
- case NODE_CONST:
- ANN("constant reference");
- ANN("format: [nd_vid](constant)");
- ANN("example: X");
- F_ID(nd_vid, "constant");
- return;
- case NODE_CVAR:
- ANN("class variable reference");
- ANN("format: [nd_vid](cvar)");
- ANN("example: @@x");
- F_ID(nd_vid, "class variable");
- return;
-
- case NODE_GVAR:
- ANN("global variable reference");
- ANN("format: [nd_entry](gvar)");
- ANN("example: $x");
- F_GENTRY(nd_entry, "global variable");
- return;
-
- case NODE_NTH_REF:
- ANN("nth special variable reference");
- ANN("format: $[nd_nth]");
- ANN("example: $1, $2, ..");
- F_CUSTOM1(nd_nth, "variable") { A("$"); A_LONG(node->nd_nth); }
- return;
-
- case NODE_BACK_REF:
- ANN("back special variable reference");
- ANN("format: $[nd_nth]");
- ANN("example: $&, $`, $', $+");
- F_CUSTOM1(nd_nth, "variable") {
- char name[3] = "$ ";
- name[1] = (char)node->nd_nth;
- A(name);
- }
- return;
-
- case NODE_MATCH:
- ANN("match expression (against $_ implicitly)");
- ANN("format: [nd_lit] (in condition)");
- ANN("example: if /foo/; foo; end");
- F_LIT(nd_lit, "regexp");
- return;
-
- case NODE_MATCH2:
- ANN("match expression (regexp first)");
- ANN("format: [nd_recv] =~ [nd_value]");
- ANN("example: /foo/ =~ 'foo'");
- F_NODE(nd_recv, "regexp (receiver)");
- if (!node->nd_args) LAST_NODE;
- F_NODE(nd_value, "string (argument)");
- if (node->nd_args) {
- LAST_NODE;
- F_NODE(nd_args, "named captures");
- }
- return;
-
- case NODE_MATCH3:
- ANN("match expression (regexp second)");
- ANN("format: [nd_recv] =~ [nd_value]");
- ANN("example: 'foo' =~ /foo/");
- F_NODE(nd_recv, "string (receiver)");
- LAST_NODE;
- F_NODE(nd_value, "regexp (argument)");
- return;
-
- case NODE_LIT:
- ANN("literal");
- ANN("format: [nd_lit]");
- ANN("example: 1, /foo/");
- goto lit;
- case NODE_STR:
- ANN("string literal");
- ANN("format: [nd_lit]");
- ANN("example: 'foo'");
- goto lit;
- case NODE_XSTR:
- ANN("xstring literal");
- ANN("format: [nd_lit]");
- ANN("example: `foo`");
- lit:
- F_LIT(nd_lit, "literal");
- return;
-
- case NODE_ONCE:
- ANN("once evaluation");
- ANN("format: [nd_body]");
- ANN("example: /foo#{ bar }baz/o");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
- case NODE_DSTR:
- ANN("string literal with interpolation");
- ANN("format: [nd_lit]");
- ANN("example: \"foo#{ bar }baz\"");
- goto dlit;
- case NODE_DXSTR:
- ANN("xstring literal with interpolation");
- ANN("format: [nd_lit]");
- ANN("example: `foo#{ bar }baz`");
- goto dlit;
- case NODE_DREGX:
- ANN("regexp literal with interpolation");
- ANN("format: [nd_lit]");
- ANN("example: /foo#{ bar }baz/");
- goto dlit;
- case NODE_DSYM:
- ANN("symbol literal with interpolation");
- ANN("format: [nd_lit]");
- ANN("example: :\"foo#{ bar }baz\"");
- dlit:
- F_LIT(nd_lit, "preceding string");
- if (!node->nd_next) return;
- F_NODE(nd_next->nd_head, "interpolation");
- LAST_NODE;
- F_NODE(nd_next->nd_next, "tailing strings");
- return;
-
- case NODE_EVSTR:
- ANN("interpolation expression");
- ANN("format: \"..#{ [nd_lit] }..\"");
- ANN("example: \"foo#{ bar }baz\"");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
-
- case NODE_ARGSCAT:
- ANN("splat argument following arguments");
- ANN("format: ..(*[nd_head], [nd_body..])");
- ANN("example: foo(*ary, post_arg1, post_arg2)");
- F_NODE(nd_head, "preceding array");
- LAST_NODE;
- F_NODE(nd_body, "following array");
- return;
-
- case NODE_ARGSPUSH:
- ANN("splat argument following one argument");
- ANN("format: ..(*[nd_head], [nd_body])");
- ANN("example: foo(*ary, post_arg)");
- F_NODE(nd_head, "preceding array");
- LAST_NODE;
- F_NODE(nd_body, "following element");
- return;
-
- case NODE_SPLAT:
- ANN("splat argument");
- ANN("format: *[nd_head]");
- ANN("example: foo(*ary)");
- LAST_NODE;
- F_NODE(nd_head, "splat'ed array");
- return;
-
- case NODE_BLOCK_PASS:
- ANN("arguments with block argument");
- ANN("format: ..([nd_head], &[nd_body])");
- ANN("example: foo(x, &blk)");
- F_NODE(nd_head, "other arguments");
- LAST_NODE;
- F_NODE(nd_body, "block argument");
- return;
-
- case NODE_DEFN:
- ANN("method definition");
- ANN("format: def [nd_mid] [nd_defn]; end");
- ANN("example: def foo; bar; end");
- F_ID(nd_mid, "method name");
- LAST_NODE;
- F_NODE(nd_defn, "method definition");
- return;
-
- case NODE_DEFS:
- ANN("singleton method definition");
- ANN("format: def [nd_recv].[nd_mid] [nd_defn]; end");
- ANN("example: def obj.foo; bar; end");
- F_NODE(nd_recv, "receiver");
- F_ID(nd_mid, "method name");
- LAST_NODE;
- F_NODE(nd_defn, "method definition");
- return;
-
- case NODE_ALIAS:
- ANN("method alias statement");
- ANN("format: alias [nd_1st] [nd_2nd]");
- ANN("example: alias bar foo");
- F_NODE(nd_1st, "new name");
- LAST_NODE;
- F_NODE(nd_2nd, "old name");
- return;
-
- case NODE_VALIAS:
- ANN("global variable alias statement");
- ANN("format: alias [nd_alias](gvar) [nd_orig](gvar)");
- ANN("example: alias $y $x");
- F_ID(nd_alias, "new name");
- F_ID(nd_orig, "old name");
- return;
-
- case NODE_UNDEF:
- ANN("method undef statement");
- ANN("format: undef [nd_undef]");
- ANN("example: undef foo");
- LAST_NODE;
- F_NODE(nd_undef, "old name");
- return;
-
- case NODE_CLASS:
- ANN("class definition");
- ANN("format: class [nd_cpath] < [nd_super]; [nd_body]; end");
- ANN("example: class C2 < C; ..; end");
- F_NODE(nd_cpath, "class path");
- F_NODE(nd_super, "superclass");
- LAST_NODE;
- F_NODE(nd_body, "class definition");
- return;
-
- case NODE_MODULE:
- ANN("module definition");
- ANN("format: module [nd_cpath]; [nd_body]; end");
- ANN("example: module M; ..; end");
- F_NODE(nd_cpath, "module path");
- LAST_NODE;
- F_NODE(nd_body, "module definition");
- return;
-
- case NODE_SCLASS:
- ANN("singleton class definition");
- ANN("format: class << [nd_recv]; [nd_body]; end");
- ANN("example: class << obj; ..; end");
- F_NODE(nd_recv, "receiver");
- LAST_NODE;
- F_NODE(nd_body, "singleton class definition");
- return;
-
- case NODE_COLON2:
- ANN("scoped constant reference");
- ANN("format: [nd_head]::[nd_mid]");
- ANN("example: M::C");
- F_ID(nd_mid, "constant name");
- LAST_NODE;
- F_NODE(nd_head, "receiver");
- return;
-
- case NODE_COLON3:
- ANN("top-level constant reference");
- ANN("format: ::[nd_mid]");
- ANN("example: ::Object");
- F_ID(nd_mid, "constant name");
- return;
-
- case NODE_DOT2:
- ANN("range constructor (incl.)");
- ANN("format: [nd_beg]..[nd_end]");
- ANN("example: 1..5");
- goto dot;
- case NODE_DOT3:
- ANN("range constructor (excl.)");
- ANN("format: [nd_beg]...[nd_end]");
- ANN("example: 1...5");
- goto dot;
- case NODE_FLIP2:
- ANN("flip-flop condition (incl.)");
- ANN("format: [nd_beg]..[nd_end]");
- ANN("example: if (x==1)..(x==5); foo; end");
- goto dot;
- case NODE_FLIP3:
- ANN("flip-flop condition (excl.)");
- ANN("format: [nd_beg]...[nd_end]");
- ANN("example: if (x==1)...(x==5); foo; end");
- dot:
- F_NODE(nd_beg, "begin");
- LAST_NODE;
- F_NODE(nd_end, "end");
- return;
-
- case NODE_SELF:
- ANN("self");
- ANN("format: self");
- ANN("example: self");
- return;
-
- case NODE_NIL:
- ANN("nil");
- ANN("format: nil");
- ANN("example: nil");
- return;
-
- case NODE_TRUE:
- ANN("true");
- ANN("format: true");
- ANN("example: true");
- return;
-
- case NODE_FALSE:
- ANN("false");
- ANN("format: false");
- ANN("example: false");
- return;
-
- case NODE_ERRINFO:
- ANN("virtual reference to $!");
- ANN("format: rescue => id");
- ANN("example: rescue => id");
- return;
-
- case NODE_DEFINED:
- ANN("defined? expression");
- ANN("format: defined?([nd_head])");
- ANN("example: defined?(foo)");
- F_NODE(nd_head, "expr");
- return;
-
- case NODE_POSTEXE:
- ANN("post-execution");
- ANN("format: END { [nd_body] }");
- ANN("example: END { foo }");
- LAST_NODE;
- F_NODE(nd_body, "END clause");
- return;
-
- case NODE_ATTRASGN:
- ANN("attr assignment");
- ANN("format: [nd_recv].[nd_mid] = [nd_args]");
- ANN("example: struct.field = foo");
- F_NODE(nd_recv, "receiver");
- F_ID(nd_mid, "method name");
- LAST_NODE;
- F_NODE(nd_args, "arguments");
- return;
-
- case NODE_LAMBDA:
- ANN("lambda expression");
- ANN("format: -> [nd_body]");
- ANN("example: -> { foo }");
- LAST_NODE;
- F_NODE(nd_body, "lambda clause");
- return;
-
- case NODE_OPT_ARG:
- ANN("optional arguments");
- ANN("format: def method_name([nd_body=some], [nd_next..])");
- ANN("example: def foo(a, b=1, c); end");
- F_NODE(nd_body, "body");
- LAST_NODE;
- F_NODE(nd_next, "next");
- return;
-
- case NODE_KW_ARG:
- ANN("keyword arguments");
- ANN("format: def method_name([nd_body=some], [nd_next..])");
- ANN("example: def foo(a:1, b:2); end");
- F_NODE(nd_body, "body");
- LAST_NODE;
- F_NODE(nd_next, "next");
- return;
-
- case NODE_POSTARG:
- ANN("post arguments");
- ANN("format: *[nd_1st], [nd_2nd..] = ..");
- ANN("example: a, *rest, z = foo");
- if (NODE_NAMED_REST_P(node->nd_1st)) {
- F_NODE(nd_1st, "rest argument");
- }
- else {
- F_MSG(nd_1st, "rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- LAST_NODE;
- F_NODE(nd_2nd, "post arguments");
- return;
-
- case NODE_ARGS:
- ANN("method parameters");
- ANN("format: def method_name(.., [nd_ainfo->nd_optargs], *[nd_ainfo->rest_arg], [nd_ainfo->first_post_arg], .., [nd_ainfo->kw_args], **[nd_ainfo->kw_rest_arg], &[nd_ainfo->block_arg])");
- ANN("example: def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk); end");
- F_INT(nd_ainfo->pre_args_num, "count of mandatory (pre-)arguments");
- F_NODE(nd_ainfo->pre_init, "initialization of (pre-)arguments");
- F_INT(nd_ainfo->post_args_num, "count of mandatory post-arguments");
- F_NODE(nd_ainfo->post_init, "initialization of post-arguments");
- F_ID(nd_ainfo->first_post_arg, "first post argument");
- F_CUSTOM1(nd_ainfo->rest_arg, "rest argument") {
- if (node->nd_ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA) {
- A("1 (excessed comma)");
- }
- else {
- A_ID(node->nd_ainfo->rest_arg);
- }
- }
- F_ID(nd_ainfo->block_arg, "block argument");
- F_NODE(nd_ainfo->opt_args, "optional arguments");
- F_NODE(nd_ainfo->kw_args, "keyword arguments");
- LAST_NODE;
- F_NODE(nd_ainfo->kw_rest_arg, "keyword rest argument");
- return;
-
- case NODE_SCOPE:
- ANN("new scope");
- ANN("format: [nd_tbl]: local table, [nd_args]: arguments, [nd_body]: body");
- F_CUSTOM1(nd_tbl, "local table") {
- rb_ast_id_table_t *tbl = node->nd_tbl;
- int i;
- int size = tbl ? tbl->size : 0;
- if (size == 0) A("(empty)");
- for (i = 0; i < size; i++) {
- A_ID(tbl->ids[i]); if (i < size - 1) A(",");
- }
- }
- F_NODE(nd_args, "arguments");
- LAST_NODE;
- F_NODE(nd_body, "body");
- return;
-
- case NODE_ARYPTN:
- ANN("array pattern");
- ANN("format: [nd_pconst]([pre_args], ..., *[rest_arg], [post_args], ...)");
- F_NODE(nd_pconst, "constant");
- F_NODE(nd_apinfo->pre_args, "pre arguments");
- if (NODE_NAMED_REST_P(node->nd_apinfo->rest_arg)) {
- F_NODE(nd_apinfo->rest_arg, "rest argument");
- }
- else {
- F_MSG(nd_apinfo->rest_arg, "rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- LAST_NODE;
- F_NODE(nd_apinfo->post_args, "post arguments");
- return;
-
- case NODE_FNDPTN:
- ANN("find pattern");
- ANN("format: [nd_pconst](*[pre_rest_arg], args, ..., *[post_rest_arg])");
- F_NODE(nd_pconst, "constant");
- if (NODE_NAMED_REST_P(node->nd_fpinfo->pre_rest_arg)) {
- F_NODE(nd_fpinfo->pre_rest_arg, "pre rest argument");
- }
- else {
- F_MSG(nd_fpinfo->pre_rest_arg, "pre rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- F_NODE(nd_fpinfo->args, "arguments");
-
- LAST_NODE;
- if (NODE_NAMED_REST_P(node->nd_fpinfo->post_rest_arg)) {
- F_NODE(nd_fpinfo->post_rest_arg, "post rest argument");
- }
- else {
- F_MSG(nd_fpinfo->post_rest_arg, "post rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
- }
- return;
-
- case NODE_HSHPTN:
- ANN("hash pattern");
- ANN("format: [nd_pconst]([nd_pkwargs], ..., **[nd_pkwrestarg])");
- F_NODE(nd_pconst, "constant");
- F_NODE(nd_pkwargs, "keyword arguments");
- LAST_NODE;
- if (node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
- F_MSG(nd_pkwrestarg, "keyword rest argument", "NODE_SPECIAL_NO_REST_KEYWORD (**nil)");
- }
- else {
- F_NODE(nd_pkwrestarg, "keyword rest argument");
- }
- return;
- case NODE_ERROR:
- ANN("Broken input recovered by Error Tolerant mode");
- return;
-
- case NODE_ARGS_AUX:
- case NODE_LAST:
- break;
- }
+#ifdef UNIVERSAL_PARSER
+#undef ruby_xmalloc
+#define ruby_xmalloc ast->config->malloc
+#undef xfree
+#define xfree ast->config->free
+#define rb_xmalloc_mul_add ast->config->xmalloc_mul_add
+#define ruby_xrealloc(var,size) (ast->config->realloc_n((void *)var, 1, size))
+#endif
- rb_bug("dump_node: unknown node: %s", ruby_node_name(nd_type(node)));
-}
+typedef void node_itr_t(rb_ast_t *ast, void *ctx, NODE *node);
+static void iterate_node_values(rb_ast_t *ast, node_buffer_list_t *nb, node_itr_t * func, void *ctx);
-VALUE
-rb_parser_dump_tree(const NODE *node, int comment)
+void
+rb_node_init(NODE *n, enum node_type type)
{
- VALUE buf = rb_str_new_cstr(
- "###########################################################\n"
- "## Do NOT use this node dump for any purpose other than ##\n"
- "## debug and research. Compatibility is not guaranteed. ##\n"
- "###########################################################\n\n"
- );
- dump_node(buf, rb_str_new_cstr("# "), comment, node);
- return buf;
+ RNODE(n)->flags = 0;
+ nd_init_type(RNODE(n), type);
+ RNODE(n)->nd_loc.beg_pos.lineno = 0;
+ RNODE(n)->nd_loc.beg_pos.column = 0;
+ RNODE(n)->nd_loc.end_pos.lineno = 0;
+ RNODE(n)->nd_loc.end_pos.column = 0;
+ RNODE(n)->node_id = -1;
}
-/* Setup NODE structure.
- * NODE is not an object managed by GC, but it imitates an object
- * so that it can work with `RB_TYPE_P(obj, T_NODE)`.
- * This dirty hack is needed because Ripper jumbles NODEs and other type
- * objects.
- */
-void
-rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
+const char *
+rb_node_name(int node)
{
- n->flags = T_NODE;
- nd_init_type(n, type);
- n->u1.value = a0;
- n->u2.value = a1;
- n->u3.value = a2;
- n->nd_loc.beg_pos.lineno = 0;
- n->nd_loc.beg_pos.column = 0;
- n->nd_loc.end_pos.lineno = 0;
- n->nd_loc.end_pos.column = 0;
- n->node_id = -1;
+ switch (node) {
+#include "node_name.inc"
+ default:
+ return 0;
+ }
}
-typedef struct node_buffer_elem_struct {
- struct node_buffer_elem_struct *next;
- long len;
- NODE buf[FLEX_ARY_LEN];
-} node_buffer_elem_t;
-
-typedef struct {
- long idx, len;
- node_buffer_elem_t *head;
- node_buffer_elem_t *last;
-} node_buffer_list_t;
-
-struct node_buffer_struct {
- node_buffer_list_t unmarkable;
- node_buffer_list_t markable;
- struct rb_ast_local_table_link *local_tables;
- VALUE mark_hash;
- // - id (sequence number)
- // - token_type
- // - text of token
- // - location info
- // Array, whose entry is array
- VALUE tokens;
-};
-
-static void
-init_node_buffer_list(node_buffer_list_t * nb, node_buffer_elem_t *head)
+#ifdef UNIVERSAL_PARSER
+const char *
+ruby_node_name(int node)
{
- nb->idx = 0;
- nb->len = NODE_BUF_DEFAULT_LEN;
- nb->head = nb->last = head;
- nb->head->len = nb->len;
- nb->head->next = NULL;
+ return rb_node_name(node);
}
-
-static node_buffer_t *
-rb_node_buffer_new(void)
+#else
+const char *
+ruby_node_name(int node)
{
- const size_t bucket_size = offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE);
- const size_t alloc_size = sizeof(node_buffer_t) + (bucket_size * 2);
- STATIC_ASSERT(
- integer_overflow,
- offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE)
- > sizeof(node_buffer_t) + 2 * sizeof(node_buffer_elem_t));
- node_buffer_t *nb = ruby_xmalloc(alloc_size);
- init_node_buffer_list(&nb->unmarkable, (node_buffer_elem_t*)&nb[1]);
- init_node_buffer_list(&nb->markable, (node_buffer_elem_t*)((size_t)nb->unmarkable.head + bucket_size));
- nb->local_tables = 0;
- nb->mark_hash = Qnil;
- nb->tokens = Qnil;
- return nb;
+ const char *name = rb_node_name(node);
+
+ if (!name) rb_bug("unknown node: %d", node);
+ return name;
}
+#endif
static void
-node_buffer_list_free(node_buffer_list_t * nb)
+node_buffer_list_free(rb_ast_t *ast, node_buffer_list_t * nb)
{
node_buffer_elem_t *nbe = nb->head;
-
while (nbe != nb->last) {
void *buf = nbe;
+ xfree(nbe->nodes);
nbe = nbe->next;
xfree(buf);
}
+
+ /* The last node_buffer_elem_t is allocated in the node_buffer_t, so we
+ * only need to free the nodes. */
+ xfree(nbe->nodes);
}
struct rb_ast_local_table_link {
@@ -1218,10 +137,99 @@ struct rb_ast_local_table_link {
};
static void
-rb_node_buffer_free(node_buffer_t *nb)
+parser_string_free(rb_ast_t *ast, rb_parser_string_t *str)
+{
+ if (!str) return;
+ xfree(str->ptr);
+ xfree(str);
+}
+
+static void
+parser_ast_token_free(rb_ast_t *ast, rb_parser_ast_token_t *token)
+{
+ if (!token) return;
+ parser_string_free(ast, token->str);
+ xfree(token);
+}
+
+static void
+parser_tokens_free(rb_ast_t *ast, rb_parser_ary_t *tokens)
+{
+ for (long i = 0; i < tokens->len; i++) {
+ parser_ast_token_free(ast, tokens->data[i]);
+ }
+ xfree(tokens->data);
+ xfree(tokens);
+}
+
+static void
+parser_nodes_free(rb_ast_t *ast, rb_parser_ary_t *nodes)
+{
+ /* Do nothing for nodes because nodes are freed when rb_ast_t is freed */
+ xfree(nodes->data);
+ xfree(nodes);
+}
+
+static void
+free_ast_value(rb_ast_t *ast, void *ctx, NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_STR:
+ parser_string_free(ast, RNODE_STR(node)->string);
+ break;
+ case NODE_DSTR:
+ parser_string_free(ast, RNODE_DSTR(node)->string);
+ break;
+ case NODE_XSTR:
+ parser_string_free(ast, RNODE_XSTR(node)->string);
+ break;
+ case NODE_DXSTR:
+ parser_string_free(ast, RNODE_DXSTR(node)->string);
+ break;
+ case NODE_SYM:
+ parser_string_free(ast, RNODE_SYM(node)->string);
+ break;
+ case NODE_REGX:
+ case NODE_MATCH:
+ parser_string_free(ast, RNODE_REGX(node)->string);
+ break;
+ case NODE_DSYM:
+ parser_string_free(ast, RNODE_DSYM(node)->string);
+ break;
+ case NODE_DREGX:
+ parser_string_free(ast, RNODE_DREGX(node)->string);
+ break;
+ case NODE_FILE:
+ parser_string_free(ast, RNODE_FILE(node)->path);
+ break;
+ case NODE_INTEGER:
+ xfree(RNODE_INTEGER(node)->val);
+ break;
+ case NODE_FLOAT:
+ xfree(RNODE_FLOAT(node)->val);
+ break;
+ case NODE_RATIONAL:
+ xfree(RNODE_RATIONAL(node)->val);
+ break;
+ case NODE_IMAGINARY:
+ xfree(RNODE_IMAGINARY(node)->val);
+ break;
+ case NODE_UNDEF:
+ parser_nodes_free(ast, RNODE_UNDEF(node)->nd_undefs);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+rb_node_buffer_free(rb_ast_t *ast, node_buffer_t *nb)
{
- node_buffer_list_free(&nb->unmarkable);
- node_buffer_list_free(&nb->markable);
+ if (nb->tokens) {
+ parser_tokens_free(ast, nb->tokens);
+ }
+ iterate_node_values(ast, &nb->buffer_list, free_ast_value, NULL);
+ node_buffer_list_free(ast, &nb->buffer_list);
struct rb_ast_local_table_link *local_table = nb->local_tables;
while (local_table) {
struct rb_ast_local_table_link *next_table = local_table->next;
@@ -1231,61 +239,39 @@ rb_node_buffer_free(node_buffer_t *nb)
xfree(nb);
}
+#define buf_add_offset(nbe, offset) ((char *)(nbe->buf) + (offset))
+
static NODE *
-ast_newnode_in_bucket(node_buffer_list_t *nb)
+ast_newnode_in_bucket(rb_ast_t *ast, node_buffer_list_t *nb, size_t size, size_t alignment)
{
- if (nb->idx >= nb->len) {
- long n = nb->len * 2;
+ size_t padding;
+ NODE *ptr;
+
+ padding = alignment - (size_t)buf_add_offset(nb->head, nb->head->used) % alignment;
+ padding = padding == alignment ? 0 : padding;
+
+ if (nb->head->used + size + padding > nb->head->allocated) {
+ size_t n = nb->head->allocated * 2;
node_buffer_elem_t *nbe;
- nbe = rb_xmalloc_mul_add(n, sizeof(NODE), offsetof(node_buffer_elem_t, buf));
- nbe->len = n;
- nb->idx = 0;
- nb->len = n;
+ nbe = rb_xmalloc_mul_add(n, sizeof(char *), offsetof(node_buffer_elem_t, buf));
+ init_node_buffer_elem(nbe, n, ruby_xmalloc);
nbe->next = nb->head;
nb->head = nbe;
+ padding = 0; /* malloc returns aligned address then no need to add padding */
}
- return &nb->head->buf[nb->idx++];
-}
-RBIMPL_ATTR_PURE()
-static bool
-nodetype_markable_p(enum node_type type)
-{
- switch (type) {
- case NODE_MATCH:
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- case NODE_ARGS:
- case NODE_ARYPTN:
- case NODE_FNDPTN:
- return true;
- default:
- return false;
- }
+ ptr = (NODE *)buf_add_offset(nb->head, nb->head->used + padding);
+ nb->head->used += (size + padding);
+ nb->head->nodes[nb->head->len++] = ptr;
+ return ptr;
}
NODE *
-rb_ast_newnode(rb_ast_t *ast, enum node_type type)
+rb_ast_newnode(rb_ast_t *ast, enum node_type type, size_t size, size_t alignment)
{
node_buffer_t *nb = ast->node_buffer;
- node_buffer_list_t *bucket =
- (nodetype_markable_p(type) ? &nb->markable : &nb->unmarkable);
- return ast_newnode_in_bucket(bucket);
-}
-
-void
-rb_ast_node_type_change(NODE *n, enum node_type type)
-{
- enum node_type old_type = nd_type(n);
- if (nodetype_markable_p(old_type) != nodetype_markable_p(type)) {
- rb_bug("node type changed: %s -> %s",
- ruby_node_name(old_type), ruby_node_name(type));
- }
+ node_buffer_list_t *bucket = &nb->buffer_list;
+ return ast_newnode_in_bucket(ast, bucket, size, alignment);
}
rb_ast_id_table_t *
@@ -1320,131 +306,63 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n)
/* should we implement freelist? */
}
+#ifdef UNIVERSAL_PARSER
+rb_ast_t *
+rb_ast_new(const rb_parser_config_t *config)
+{
+ node_buffer_t *nb = rb_node_buffer_new(config);
+ rb_ast_t *ast = (rb_ast_t *)config->calloc(1, sizeof(rb_ast_t));
+ ast->config = config;
+ ast->node_buffer = nb;
+ return ast;
+}
+#else
rb_ast_t *
rb_ast_new(void)
{
node_buffer_t *nb = rb_node_buffer_new();
- rb_ast_t *ast = (rb_ast_t *)rb_imemo_new(imemo_ast, 0, 0, 0, (VALUE)nb);
+ rb_ast_t *ast = ruby_xcalloc(1, sizeof(rb_ast_t));
+ ast->node_buffer = nb;
return ast;
}
-
-typedef void node_itr_t(void *ctx, NODE * node);
+#endif
static void
-iterate_buffer_elements(node_buffer_elem_t *nbe, long len, node_itr_t *func, void *ctx)
+iterate_buffer_elements(rb_ast_t *ast, node_buffer_elem_t *nbe, long len, node_itr_t *func, void *ctx)
{
long cursor;
for (cursor = 0; cursor < len; cursor++) {
- func(ctx, &nbe->buf[cursor]);
+ func(ast, ctx, nbe->nodes[cursor]);
}
}
static void
-iterate_node_values(node_buffer_list_t *nb, node_itr_t * func, void *ctx)
+iterate_node_values(rb_ast_t *ast, node_buffer_list_t *nb, node_itr_t * func, void *ctx)
{
node_buffer_elem_t *nbe = nb->head;
- /* iterate over the head first because it's not full */
- iterate_buffer_elements(nbe, nb->idx, func, ctx);
-
- nbe = nbe->next;
while (nbe) {
- iterate_buffer_elements(nbe, nbe->len, func, ctx);
+ iterate_buffer_elements(ast, nbe, nbe->len, func, ctx);
nbe = nbe->next;
}
}
static void
-mark_ast_value(void *ctx, NODE * node)
+script_lines_free(rb_ast_t *ast, rb_parser_ary_t *script_lines)
{
- switch (nd_type(node)) {
- case NODE_ARGS:
- {
- struct rb_args_info *args = node->nd_ainfo;
- rb_gc_mark_movable(args->imemo);
- break;
- }
- case NODE_MATCH:
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- rb_gc_mark_movable(node->nd_lit);
- break;
- case NODE_ARYPTN:
- case NODE_FNDPTN:
- rb_gc_mark_movable(node->nd_rval);
- break;
- default:
- rb_bug("unreachable node %s", ruby_node_name(nd_type(node)));
+ if (!script_lines) return;
+ for (long i = 0; i < script_lines->len; i++) {
+ parser_string_free(ast, (rb_parser_string_t *)script_lines->data[i]);
}
-}
-
-static void
-update_ast_value(void *ctx, NODE * node)
-{
- switch (nd_type(node)) {
- case NODE_ARGS:
- {
- struct rb_args_info *args = node->nd_ainfo;
- args->imemo = rb_gc_location(args->imemo);
- break;
- }
- case NODE_MATCH:
- case NODE_LIT:
- case NODE_STR:
- case NODE_XSTR:
- case NODE_DSTR:
- case NODE_DXSTR:
- case NODE_DREGX:
- case NODE_DSYM:
- node->nd_lit = rb_gc_location(node->nd_lit);
- break;
- case NODE_ARYPTN:
- case NODE_FNDPTN:
- node->nd_rval = rb_gc_location(node->nd_rval);
- break;
- default:
- rb_bug("unreachable");
- }
-}
-
-void
-rb_ast_update_references(rb_ast_t *ast)
-{
- if (ast->node_buffer) {
- node_buffer_t *nb = ast->node_buffer;
-
- iterate_node_values(&nb->markable, update_ast_value, NULL);
- }
-}
-
-void
-rb_ast_mark(rb_ast_t *ast)
-{
- if (ast->node_buffer) {
- rb_gc_mark(ast->node_buffer->mark_hash);
- rb_gc_mark(ast->node_buffer->tokens);
- }
- if (ast->body.compile_option) rb_gc_mark(ast->body.compile_option);
- if (ast->node_buffer) {
- node_buffer_t *nb = ast->node_buffer;
-
- iterate_node_values(&nb->markable, mark_ast_value, NULL);
- }
- if (ast->body.script_lines) rb_gc_mark(ast->body.script_lines);
+ xfree(script_lines->data);
+ xfree(script_lines);
}
void
rb_ast_free(rb_ast_t *ast)
{
- if (ast->node_buffer) {
- rb_node_buffer_free(ast->node_buffer);
- ast->node_buffer = 0;
- }
+ rb_ast_dispose(ast);
+ xfree(ast);
}
static size_t
@@ -1453,8 +371,8 @@ buffer_list_size(node_buffer_list_t *nb)
size_t size = 0;
node_buffer_elem_t *nbe = nb->head;
while (nbe != nb->last) {
+ size += offsetof(node_buffer_elem_t, buf) + nbe->used;
nbe = nbe->next;
- size += offsetof(node_buffer_elem_t, buf) + nb->len * sizeof(NODE);
}
return size;
}
@@ -1462,40 +380,67 @@ buffer_list_size(node_buffer_list_t *nb)
size_t
rb_ast_memsize(const rb_ast_t *ast)
{
- size_t size = 0;
+ size_t size = sizeof(rb_ast_t);
node_buffer_t *nb = ast->node_buffer;
+ rb_parser_ary_t *tokens = NULL;
+ struct rb_ast_local_table_link *link = NULL;
+ rb_parser_ary_t *script_lines = ast->body.script_lines;
+
+ long i;
if (nb) {
- size += sizeof(node_buffer_t) + offsetof(node_buffer_elem_t, buf) + NODE_BUF_DEFAULT_LEN * sizeof(NODE);
- size += buffer_list_size(&nb->unmarkable);
- size += buffer_list_size(&nb->markable);
+ size += sizeof(node_buffer_t);
+ size += buffer_list_size(&nb->buffer_list);
+ link = nb->local_tables;
+ tokens = nb->tokens;
+ }
+
+ while (link) {
+ size += sizeof(struct rb_ast_local_table_link);
+ size += link->size * sizeof(ID);
+ link = link->next;
}
+
+ if (tokens) {
+ size += sizeof(rb_parser_ary_t);
+ for (i = 0; i < tokens->len; i++) {
+ size += sizeof(rb_parser_ast_token_t);
+ rb_parser_ast_token_t *token = tokens->data[i];
+ size += sizeof(rb_parser_string_t);
+ size += token->str->len + 1;
+ }
+ }
+
+ if (script_lines) {
+ size += sizeof(rb_parser_ary_t);
+ for (i = 0; i < script_lines->len; i++) {
+ size += sizeof(rb_parser_string_t);
+ size += ((rb_parser_string_t *)script_lines->data[i])->len + 1;
+ }
+ }
+
return size;
}
void
rb_ast_dispose(rb_ast_t *ast)
{
- rb_ast_free(ast);
-}
-
-void
-rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
-{
- if (NIL_P(ast->node_buffer->mark_hash)) {
- RB_OBJ_WRITE(ast, &ast->node_buffer->mark_hash, rb_ident_hash_new());
+ if (ast && ast->node_buffer) {
+ script_lines_free(ast, ast->body.script_lines);
+ ast->body.script_lines = NULL;
+ rb_node_buffer_free(ast, ast->node_buffer);
+ ast->node_buffer = 0;
}
- rb_hash_aset(ast->node_buffer->mark_hash, obj, Qtrue);
}
VALUE
-rb_ast_tokens(rb_ast_t *ast)
+rb_node_set_type(NODE *n, enum node_type t)
{
- return ast->node_buffer->tokens;
+ return nd_init_type(n, t);
}
-void
-rb_ast_set_tokens(rb_ast_t *ast, VALUE tokens)
+enum node_type
+rb_node_get_type(const NODE *n)
{
- RB_OBJ_WRITE(ast, &ast->node_buffer->tokens, tokens);
+ return (enum node_type)nd_type(n);
}
diff --git a/node.h b/node.h
index befb1328fb..d8ee7dbb64 100644
--- a/node.h
+++ b/node.h
@@ -11,504 +11,112 @@
**********************************************************************/
-#include "internal/compilers.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-enum node_type {
- NODE_SCOPE,
- NODE_BLOCK,
- NODE_IF,
- NODE_UNLESS,
- NODE_CASE,
- NODE_CASE2,
- NODE_CASE3,
- NODE_WHEN,
- NODE_IN,
- NODE_WHILE,
- NODE_UNTIL,
- NODE_ITER,
- NODE_FOR,
- NODE_FOR_MASGN,
- NODE_BREAK,
- NODE_NEXT,
- NODE_REDO,
- NODE_RETRY,
- NODE_BEGIN,
- NODE_RESCUE,
- NODE_RESBODY,
- NODE_ENSURE,
- NODE_AND,
- NODE_OR,
- NODE_MASGN,
- NODE_LASGN,
- NODE_DASGN,
- NODE_GASGN,
- NODE_IASGN,
- NODE_CDECL,
- NODE_CVASGN,
- NODE_OP_ASGN1,
- NODE_OP_ASGN2,
- NODE_OP_ASGN_AND,
- NODE_OP_ASGN_OR,
- NODE_OP_CDECL,
- NODE_CALL,
- NODE_OPCALL,
- NODE_FCALL,
- NODE_VCALL,
- NODE_QCALL,
- NODE_SUPER,
- NODE_ZSUPER,
- NODE_LIST,
- NODE_ZLIST,
- NODE_VALUES,
- 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_ONCE,
- NODE_ARGS,
- NODE_ARGS_AUX,
- NODE_OPT_ARG,
- NODE_KW_ARG,
- NODE_POSTARG,
- NODE_ARGSCAT,
- NODE_ARGSPUSH,
- NODE_SPLAT,
- NODE_BLOCK_PASS,
- NODE_DEFN,
- NODE_DEFS,
- NODE_ALIAS,
- NODE_VALIAS,
- NODE_UNDEF,
- NODE_CLASS,
- NODE_MODULE,
- NODE_SCLASS,
- NODE_COLON2,
- NODE_COLON3,
- NODE_DOT2,
- NODE_DOT3,
- NODE_FLIP2,
- NODE_FLIP3,
- NODE_SELF,
- NODE_NIL,
- NODE_TRUE,
- NODE_FALSE,
- NODE_ERRINFO,
- NODE_DEFINED,
- NODE_POSTEXE,
- NODE_DSYM,
- NODE_ATTRASGN,
- NODE_LAMBDA,
- NODE_ARYPTN,
- NODE_HSHPTN,
- NODE_FNDPTN,
- NODE_ERROR,
- NODE_LAST
+#include <stdbool.h>
+#include "rubyparser.h"
+#include "ruby/backward/2/attributes.h"
+
+typedef void (*bug_report_func)(const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
+typedef struct node_buffer_elem_struct {
+ struct node_buffer_elem_struct *next;
+ long len; /* Length of nodes */
+ size_t allocated; /* Total memory size of allocated buf */
+ size_t used; /* Current usage of buf */
+ NODE **nodes; /* Array of node pointers */
+ NODE *buf[FLEX_ARY_LEN];
+} node_buffer_elem_t;
+
+typedef struct {
+ node_buffer_elem_t *head;
+ node_buffer_elem_t *last;
+} node_buffer_list_t;
+
+struct node_buffer_struct {
+ node_buffer_list_t buffer_list;
+ struct rb_ast_local_table_link *local_tables;
+ // - id (sequence number)
+ // - token_type
+ // - text of token
+ // - location info
+ // Array, whose entry is array
+ rb_parser_ary_t *tokens;
};
-typedef struct rb_code_position_struct {
- int lineno;
- int column;
-} rb_code_position_t;
-
-typedef struct rb_code_location_struct {
- rb_code_position_t beg_pos;
- rb_code_position_t end_pos;
-} rb_code_location_t;
-
-static inline rb_code_location_t
-code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2)
-{
- rb_code_location_t loc;
- loc.beg_pos = loc1->beg_pos;
- loc.end_pos = loc2->end_pos;
- return loc;
-}
-
-typedef struct rb_ast_id_table {
- int size;
- ID ids[FLEX_ARY_LEN];
-} rb_ast_id_table_t;
-
-typedef struct RNode {
- VALUE flags;
- union {
- struct RNode *node;
- ID id;
- VALUE value;
- rb_ast_id_table_t *tbl;
- } u1;
- union {
- struct RNode *node;
- ID id;
- long argc;
- VALUE value;
- } u2;
- union {
- struct RNode *node;
- ID id;
- long state;
- struct rb_args_info *args;
- struct rb_ary_pattern_info *apinfo;
- struct rb_fnd_pattern_info *fpinfo;
- VALUE value;
- } u3;
- rb_code_location_t nd_loc;
- int node_id;
-} NODE;
-
-#define RNODE(obj) ((struct RNode *)(obj))
-
-/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
-/* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
- * 8..14: nd_type,
- * 15..: nd_line
- */
-#define NODE_FL_NEWLINE (((VALUE)1)<<7)
-
-#define NODE_TYPESHIFT 8
-#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
-
-#define nd_type(n) ((int) (((n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
-#define nd_set_type(n,t) \
- rb_node_set_type(n, t)
-#define nd_init_type(n,t) \
- (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(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) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT)
-#define nd_set_line(n,l) \
- (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
-
-#define nd_first_column(n) ((int)((n)->nd_loc.beg_pos.column))
-#define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v))
-#define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno))
-#define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v))
-#define nd_first_loc(n) ((n)->nd_loc.beg_pos)
-#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
-
-#define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column))
-#define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v))
-#define nd_last_lineno(n) ((int)((n)->nd_loc.end_pos.lineno))
-#define nd_set_last_lineno(n, v) ((n)->nd_loc.end_pos.lineno = (v))
-#define nd_last_loc(n) ((n)->nd_loc.end_pos)
-#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
-#define nd_node_id(n) ((n)->node_id)
-#define nd_set_node_id(n,id) ((n)->node_id = (id))
-
-#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_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.id
-#define nd_vid u1.id
-
-#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_recv u1.node
-#define nd_mid u2.id
-#define nd_args u3.node
-#define nd_ainfo u3.args
-
-#define nd_defn u3.node
-
-#define nd_cpath u1.node
-#define nd_super u3.node
-
-#define nd_beg u1.node
-#define nd_end u2.node
-#define nd_state u3.state
-
-#define nd_nth u2.argc
-
-#define nd_alias u1.id
-#define nd_orig u2.id
-#define nd_undef u2.node
-
-#define nd_brace u2.argc
-
-#define nd_pconst u1.node
-#define nd_pkwargs u2.node
-#define nd_pkwrestarg u3.node
-
-#define nd_apinfo u3.apinfo
-
-#define nd_fpinfo u3.fpinfo
-
-// for NODE_SCOPE
-#define nd_tbl u1.tbl
-
-// for NODE_ARGS_AUX
-#define nd_pid u1.id
-#define nd_plen u2.argc
-#define nd_cflag u2.id
-
-// for ripper
-#define nd_cval u3.value
-#define nd_rval u2.value
-#define nd_tag u1.id
-
-#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
-#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
-
-#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
-#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
-#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
-#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
-#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
-#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
-#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
-#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
-#define NEW_CASE3(h,b,loc) NEW_NODE(NODE_CASE3,h,b,0,loc)
-#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
-#define NEW_IN(c,t,e,loc) NEW_NODE(NODE_IN,c,t,e,loc)
-#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
-#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
-#define NEW_FOR(i,b,loc) NEW_NODE(NODE_FOR,0,b,i,loc)
-#define NEW_FOR_MASGN(v,loc) NEW_NODE(NODE_FOR_MASGN,v,0,0,loc)
-#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
-#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
-#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
-#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
-#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
-#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
-#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
-#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
-#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
-#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
-#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
-#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
-#define NEW_LIST(a,loc) NEW_NODE(NODE_LIST,a,1,0,loc)
-#define NEW_ZLIST(loc) NEW_NODE(NODE_ZLIST,0,0,0,loc)
-#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
-#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
-#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,v,loc)
-#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
-#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
-#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
-#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
-#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
-#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
-#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
-#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
-#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
-#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
-#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
-#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,v,loc)
-#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
-#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
-#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
-#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
-#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
-#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
-#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
-#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
-#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
-#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
-#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
-#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
-#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
-#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
-#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
-#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
-#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
-#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
-#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
-#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
-#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
-#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
-#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
-#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
-#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
-#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
-#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
-#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
-#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
-#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
-#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
-#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
-#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
-#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
-#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
-#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
-#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
-#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
-#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
-#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
-#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
-#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc)
-#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
-#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
-#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
-#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
-#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
-#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
-#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
-#define NEW_ERROR(loc) NEW_NODE(NODE_ERROR,0,0,0,loc)
-
-#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
-#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
-#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
-#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
-#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
-#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
-
-VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
-
RUBY_SYMBOL_EXPORT_BEGIN
-typedef struct node_buffer_struct node_buffer_t;
-/* T_IMEMO/ast */
-typedef struct rb_ast_body_struct {
- const NODE *root;
- VALUE compile_option;
- VALUE script_lines;
- // script_lines is either:
- // - a Fixnum that represents the line count of the original source, or
- // - an Array that contains the lines of the original source
-} rb_ast_body_t;
-typedef struct rb_ast_struct {
- VALUE flags;
- node_buffer_t *node_buffer;
- rb_ast_body_t body;
-} rb_ast_t;
+#ifdef UNIVERSAL_PARSER
+rb_ast_t *rb_ast_new(const rb_parser_config_t *config);
+#else
rb_ast_t *rb_ast_new(void);
-void rb_ast_mark(rb_ast_t*);
-void rb_ast_update_references(rb_ast_t*);
+#endif
+size_t rb_ast_memsize(const rb_ast_t*);
void rb_ast_dispose(rb_ast_t*);
+const char *ruby_node_name(int node);
+void rb_node_init(NODE *n, enum node_type type);
+
+void rb_ast_update_references(rb_ast_t*);
void rb_ast_free(rb_ast_t*);
-size_t rb_ast_memsize(const rb_ast_t*);
-void rb_ast_add_mark_object(rb_ast_t*, VALUE);
-void rb_ast_set_tokens(rb_ast_t*, VALUE);
-VALUE rb_ast_tokens(rb_ast_t *ast);
-NODE *rb_ast_newnode(rb_ast_t*, enum node_type type);
+NODE *rb_ast_newnode(rb_ast_t*, enum node_type type, size_t size, size_t alignment);
void rb_ast_delete_node(rb_ast_t*, NODE *n);
rb_ast_id_table_t *rb_ast_new_local_table(rb_ast_t*, int);
rb_ast_id_table_t *rb_ast_resize_latest_local_table(rb_ast_t*, int);
-VALUE rb_parser_new(void);
-VALUE rb_parser_end_seen_p(VALUE);
-VALUE rb_parser_encoding(VALUE);
-VALUE rb_parser_set_yydebug(VALUE, VALUE);
VALUE rb_parser_dump_tree(const NODE *node, int comment);
-void rb_parser_set_options(VALUE, int, int, int, int);
-
-rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
-rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
-rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
-rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
-
-void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
-const char *ruby_node_name(int node);
const struct kwtable *rb_reserved_word(const char *, unsigned int);
-struct rb_args_info {
- NODE *pre_init;
- NODE *post_init;
-
- int pre_args_num; /* count of mandatory pre-arguments */
- int post_args_num; /* count of mandatory post-arguments */
-
- ID first_post_arg;
-
- ID rest_arg;
- ID block_arg;
-
- NODE *kw_args;
- NODE *kw_rest_arg;
-
- NODE *opt_args;
- unsigned int no_kwarg: 1;
- unsigned int ruby2_keywords: 1;
- unsigned int forwarding: 1;
-
- VALUE imemo;
-};
-
-struct rb_ary_pattern_info {
- NODE *pre_args;
- NODE *rest_arg;
- NODE *post_args;
-};
-
-struct rb_fnd_pattern_info {
- NODE *pre_rest_arg;
- NODE *args;
- NODE *post_rest_arg;
-};
-
struct parser_params;
-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 *);
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
-void rb_ast_node_type_change(NODE *n, enum node_type type);
+VALUE rb_node_set_type(NODE *n, enum node_type t);
+enum node_type rb_node_get_type(const NODE *n);
RUBY_SYMBOL_EXPORT_END
-static inline VALUE
-rb_node_set_type(NODE *n, enum node_type t)
+#define NODE_LSHIFT (NODE_TYPESHIFT+7)
+#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
+
+static inline int
+nd_line(const NODE *n)
{
-#if RUBY_DEBUG
- rb_ast_node_type_change(n, t);
-#endif
- return nd_init_type(n, t);
+ if (!n) return -1;
+ SIGNED_VALUE flags = (SIGNED_VALUE)n->flags;
+ return (int)(flags >> NODE_LSHIFT);
+}
+
+static inline void
+nd_set_line(NODE *n, SIGNED_VALUE l)
+{
+ n->flags &= ~(~(VALUE)0 << NODE_LSHIFT);
+ n->flags |= ((VALUE)(l & NODE_LMASK) << NODE_LSHIFT);
}
+#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
+#define NODE_REQUIRED_KEYWORD_P(node) ((node) == NODE_SPECIAL_REQUIRED_KEYWORD)
+#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
+#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
+#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
+#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
+
+#define nd_code_loc(n) (&RNODE(n)->nd_loc)
+#define nd_first_column(n) ((int)(RNODE(n)->nd_loc.beg_pos.column))
+#define nd_set_first_column(n, v) (RNODE(n)->nd_loc.beg_pos.column = (v))
+#define nd_first_lineno(n) ((int)(RNODE(n)->nd_loc.beg_pos.lineno))
+#define nd_set_first_lineno(n, v) (RNODE(n)->nd_loc.beg_pos.lineno = (v))
+#define nd_first_loc(n) (RNODE(n)->nd_loc.beg_pos)
+#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
+
+#define nd_last_column(n) ((int)(RNODE(n)->nd_loc.end_pos.column))
+#define nd_set_last_column(n, v) (RNODE(n)->nd_loc.end_pos.column = (v))
+#define nd_last_lineno(n) ((int)(RNODE(n)->nd_loc.end_pos.lineno))
+#define nd_set_last_lineno(n, v) (RNODE(n)->nd_loc.end_pos.lineno = (v))
+#define nd_last_loc(n) (RNODE(n)->nd_loc.end_pos)
+#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
+#define nd_node_id(n) (RNODE(n)->node_id)
+#define nd_set_node_id(n,id) (RNODE(n)->node_id = (id))
+
static inline bool
nd_type_p(const NODE *n, enum node_type t)
{
return (enum node_type)nd_type(n) == t;
}
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
#endif /* RUBY_NODE_H */
diff --git a/node_dump.c b/node_dump.c
new file mode 100644
index 0000000000..82a7d78c28
--- /dev/null
+++ b/node_dump.c
@@ -0,0 +1,1325 @@
+/**********************************************************************
+
+ node_dump.c - dump ruby node tree
+
+ $Author: mame $
+ created at: 09/12/06 21:23:44 JST
+
+ Copyright (C) 2009 Yusuke Endoh
+
+**********************************************************************/
+
+#include "internal.h"
+#include "internal/class.h"
+#include "internal/hash.h"
+#include "internal/ruby_parser.h"
+#include "internal/variable.h"
+#include "ruby/ruby.h"
+#include "vm_core.h"
+
+#define A(str) rb_str_cat2(buf, (str))
+#define AR(str) rb_str_concat(buf, (str))
+
+#define A_INDENT add_indent(buf, indent)
+#define D_INDENT rb_str_cat2(indent, next_indent)
+#define D_DEDENT rb_str_resize(indent, RSTRING_LEN(indent) - 4)
+#define A_ID(id) add_id(buf, (id))
+#define A_INT(val) rb_str_catf(buf, "%d", (val))
+#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
+#define A_LIT(lit) AR(rb_dump_literal(lit))
+#define A_LOC(loc) \
+ rb_str_catf(buf, "(%d,%d)-(%d,%d)", \
+ loc.beg_pos.lineno, loc.beg_pos.column, \
+ loc.end_pos.lineno, loc.end_pos.column)
+#define A_NODE_HEADER(node, term) \
+ rb_str_catf(buf, "@ %s (id: %d, line: %d, location: (%d,%d)-(%d,%d))%s"term, \
+ ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node), \
+ nd_first_lineno(node), nd_first_column(node), \
+ nd_last_lineno(node), nd_last_column(node), \
+ (nd_fl_newline(node) ? "*" : ""))
+#define A_FIELD_HEADER(len, name, term) \
+ rb_str_catf(buf, "+- %.*s:"term, (len), (name))
+#define D_FIELD_HEADER(len, name, term) (A_INDENT, A_FIELD_HEADER(len, name, term))
+
+#define D_NULL_NODE (A_INDENT, A("(null node)\n"))
+#define D_NODE_HEADER(node) (A_INDENT, A_NODE_HEADER(node, "\n"))
+
+#define COMPOUND_FIELD(len, name) \
+ FIELD_BLOCK((D_FIELD_HEADER((len), (name), "\n"), D_INDENT), D_DEDENT)
+
+#define COMPOUND_FIELD1(name, ann) \
+ COMPOUND_FIELD(FIELD_NAME_LEN(name, ann), \
+ FIELD_NAME_DESC(name, ann))
+
+#define FIELD_NAME_DESC(name, ann) name " (" ann ")"
+#define FIELD_NAME_LEN(name, ann) (int)( \
+ comment ? \
+ rb_strlen_lit(FIELD_NAME_DESC(name, ann)) : \
+ rb_strlen_lit(name))
+#define SIMPLE_FIELD(len, name) \
+ FIELD_BLOCK(D_FIELD_HEADER((len), (name), " "), A("\n"))
+
+#define FIELD_BLOCK(init, reset) \
+ for (init, field_flag = 1; \
+ field_flag; /* should be optimized away */ \
+ reset, field_flag = 0)
+
+#define A_SHAREABILITY(shareability) \
+ switch (shareability) { \
+ case rb_parser_shareable_none: \
+ rb_str_cat_cstr(buf, "none"); \
+ break; \
+ case rb_parser_shareable_literal: \
+ rb_str_cat_cstr(buf, "literal"); \
+ break; \
+ case rb_parser_shareable_copy: \
+ rb_str_cat_cstr(buf, "experimental_copy"); \
+ break; \
+ case rb_parser_shareable_everything: \
+ rb_str_cat_cstr(buf, "experimental_everything"); \
+ break; \
+ }
+
+#define SIMPLE_FIELD1(name, ann) SIMPLE_FIELD(FIELD_NAME_LEN(name, ann), FIELD_NAME_DESC(name, ann))
+#define F_CUSTOM1(name, ann) SIMPLE_FIELD1(#name, ann)
+#define F_ID(name, type, ann) SIMPLE_FIELD1(#name, ann) A_ID(type(node)->name)
+#define F_INT(name, type, ann) SIMPLE_FIELD1(#name, ann) A_INT(type(node)->name)
+#define F_LONG(name, type, ann) SIMPLE_FIELD1(#name, ann) A_LONG(type(node)->name)
+#define F_LIT(name, type, ann) SIMPLE_FIELD1(#name, ann) A_LIT(type(node)->name)
+#define F_VALUE(name, val, ann) SIMPLE_FIELD1(#name, ann) A_LIT(val)
+#define F_MSG(name, ann, desc) SIMPLE_FIELD1(#name, ann) A(desc)
+#define F_LOC(name, type) SIMPLE_FIELD1(#name, "") A_LOC(type(node)->name)
+#define F_SHAREABILITY(name, type, ann) SIMPLE_FIELD1(#name, ann) A_SHAREABILITY(type(node)->name)
+
+#define F_NODE(name, type, ann) \
+ COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, RNODE(type(node)->name));}
+
+#define F_NODE2(name, n, ann) \
+ COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, n);}
+
+#define F_ARRAY(name, type, ann) \
+ COMPOUND_FIELD1(#name, ann) {dump_parser_array(buf, indent, comment, type(node)->name);}
+
+#define ANN(ann) \
+ if (comment) { \
+ A_INDENT; A("| # " ann "\n"); \
+ }
+
+#define LAST_NODE (next_indent = " ")
+
+VALUE
+rb_dump_literal(VALUE lit)
+{
+ if (!RB_SPECIAL_CONST_P(lit)) {
+ VALUE str;
+ switch (RB_BUILTIN_TYPE(lit)) {
+ case T_CLASS: case T_MODULE: case T_ICLASS:
+ str = rb_class_path(lit);
+ if (RCLASS_SINGLETON_P(lit)) {
+ str = rb_sprintf("<%"PRIsVALUE">", str);
+ }
+ return str;
+ default:
+ break;
+ }
+ }
+ return rb_inspect(lit);
+}
+
+static void
+add_indent(VALUE buf, VALUE indent)
+{
+ AR(indent);
+}
+
+static void
+add_id(VALUE buf, ID id)
+{
+ if (id == 0) {
+ A("(null)");
+ }
+ else {
+ VALUE str = rb_id2str(id);
+ if (str) {
+ A(":"); AR(str);
+ }
+ else {
+ rb_str_catf(buf, "(internal variable: 0x%"PRIsVALUE")", id);
+ }
+ }
+}
+
+struct add_option_arg {
+ VALUE buf, indent;
+ st_index_t count;
+};
+
+static void dump_node(VALUE, VALUE, int, const NODE *);
+static const char default_indent[] = "| ";
+
+static void
+dump_array(VALUE buf, VALUE indent, int comment, const NODE *node)
+{
+ int field_flag;
+ const char *next_indent = default_indent;
+ F_LONG(as.nd_alen, RNODE_LIST, "length");
+ F_NODE(nd_head, RNODE_LIST, "element");
+ while (RNODE_LIST(node)->nd_next && nd_type_p(RNODE_LIST(node)->nd_next, NODE_LIST)) {
+ node = RNODE_LIST(node)->nd_next;
+ F_NODE(nd_head, RNODE_LIST, "element");
+ }
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_LIST, "next element");
+}
+
+static void
+dump_parser_array(VALUE buf, VALUE indent, int comment, const rb_parser_ary_t *ary)
+{
+ int field_flag;
+ const char *next_indent = default_indent;
+
+ if (ary->data_type != PARSER_ARY_DATA_NODE) {
+ rb_bug("unexpected rb_parser_ary_data_type: %d", ary->data_type);
+ }
+
+ F_CUSTOM1(length, "length") { A_LONG(ary->len); }
+ for (long i = 0; i < ary->len; i++) {
+ if (i == ary->len - 1) LAST_NODE;
+ A_INDENT;
+ rb_str_catf(buf, "+- element (%s%ld):\n",
+ comment ? "statement #" : "", i);
+ D_INDENT;
+ dump_node(buf, indent, comment, ary->data[i]);
+ D_DEDENT;
+ }
+}
+
+static void
+dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
+{
+ int field_flag;
+ int i;
+ const char *next_indent = default_indent;
+ enum node_type type;
+
+ if (!node) {
+ D_NULL_NODE;
+ return;
+ }
+
+ D_NODE_HEADER(node);
+
+ type = nd_type(node);
+ switch (type) {
+ case NODE_BLOCK:
+ ANN("statement sequence");
+ ANN("format: [nd_head]; ...; [nd_next]");
+ ANN("example: foo; bar");
+ i = 0;
+ do {
+ A_INDENT;
+ rb_str_catf(buf, "+- nd_head (%s%d):\n",
+ comment ? "statement #" : "", ++i);
+ if (!RNODE_BLOCK(node)->nd_next) LAST_NODE;
+ D_INDENT;
+ dump_node(buf, indent, comment, RNODE_BLOCK(node)->nd_head);
+ D_DEDENT;
+ } while (RNODE_BLOCK(node)->nd_next &&
+ nd_type_p(RNODE_BLOCK(node)->nd_next, NODE_BLOCK) &&
+ (node = RNODE_BLOCK(node)->nd_next, 1));
+ if (RNODE_BLOCK(node)->nd_next) {
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_BLOCK, "next block");
+ }
+ return;
+
+ case NODE_IF:
+ ANN("if statement");
+ ANN("format: if [nd_cond] then [nd_body] else [nd_else] end");
+ ANN("example: if x == 1 then foo else bar end");
+ F_NODE(nd_cond, RNODE_IF, "condition expr");
+ F_NODE(nd_body, RNODE_IF, "then clause");
+ F_NODE(nd_else, RNODE_IF, "else clause");
+ F_LOC(if_keyword_loc, RNODE_IF);
+ F_LOC(then_keyword_loc, RNODE_IF);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_IF);
+ return;
+
+ case NODE_UNLESS:
+ ANN("unless statement");
+ ANN("format: unless [nd_cond] then [nd_body] else [nd_else] end");
+ ANN("example: unless x == 1 then foo else bar end");
+ F_NODE(nd_cond, RNODE_UNLESS, "condition expr");
+ F_NODE(nd_body, RNODE_UNLESS, "then clause");
+ F_NODE(nd_else, RNODE_UNLESS, "else clause");
+ F_LOC(keyword_loc, RNODE_UNLESS);
+ F_LOC(then_keyword_loc, RNODE_UNLESS);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_UNLESS);
+ return;
+
+ case NODE_CASE:
+ ANN("case statement");
+ ANN("format: case [nd_head]; [nd_body]; end");
+ ANN("example: case x; when 1; foo; when 2; bar; else baz; end");
+ F_NODE(nd_head, RNODE_CASE, "case expr");
+ F_NODE(nd_body, RNODE_CASE, "when clauses");
+ F_LOC(case_keyword_loc, RNODE_CASE);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_CASE);
+ return;
+ case NODE_CASE2:
+ ANN("case statement with no head");
+ ANN("format: case; [nd_body]; end");
+ ANN("example: case; when 1; foo; when 2; bar; else baz; end");
+ F_NODE(nd_head, RNODE_CASE2, "case expr");
+ F_NODE(nd_body, RNODE_CASE2, "when clauses");
+ F_LOC(case_keyword_loc, RNODE_CASE2);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_CASE2);
+ return;
+ case NODE_CASE3:
+ ANN("case statement (pattern matching)");
+ ANN("format: case [nd_head]; [nd_body]; end");
+ ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
+ F_NODE(nd_head, RNODE_CASE3, "case expr");
+ F_NODE(nd_body, RNODE_CASE3, "in clauses");
+ F_LOC(case_keyword_loc, RNODE_CASE3);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_CASE3);
+ return;
+
+ case NODE_WHEN:
+ ANN("when clause");
+ ANN("format: when [nd_head]; [nd_body]; (when or else) [nd_next]");
+ ANN("example: case x; when 1; foo; when 2; bar; else baz; end");
+ F_NODE(nd_head, RNODE_WHEN, "when value");
+ F_NODE(nd_body, RNODE_WHEN, "when body");
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_WHEN, "next when clause");
+ F_LOC(keyword_loc, RNODE_WHEN);
+ LAST_NODE;
+ F_LOC(then_keyword_loc, RNODE_WHEN);
+ return;
+
+ case NODE_IN:
+ ANN("in clause");
+ ANN("format: in [nd_head]; [nd_body]; (in or else) [nd_next]");
+ ANN("example: case x; in 1; foo; in 2; bar; else baz; end");
+ F_NODE(nd_head, RNODE_IN, "in pattern");
+ F_NODE(nd_body, RNODE_IN, "in body");
+ F_NODE(nd_next, RNODE_IN, "next in clause");
+ F_LOC(in_keyword_loc, RNODE_IN);
+ F_LOC(then_keyword_loc, RNODE_IN);
+ LAST_NODE;
+ F_LOC(operator_loc, RNODE_IN);
+ return;
+
+ case NODE_WHILE:
+ ANN("while statement");
+ ANN("format: while [nd_cond]; [nd_body]; end");
+ ANN("example: while x == 1; foo; end");
+ goto loop;
+ case NODE_UNTIL:
+ ANN("until statement");
+ ANN("format: until [nd_cond]; [nd_body]; end");
+ ANN("example: until x == 1; foo; end");
+ loop:
+ F_CUSTOM1(nd_state, "begin-end-while?") {
+ A_INT((int)RNODE_WHILE(node)->nd_state);
+ A((RNODE_WHILE(node)->nd_state == 1) ? " (while-end)" : " (begin-end-while)");
+ }
+ F_NODE(nd_cond, RNODE_WHILE, "condition");
+ F_NODE(nd_body, RNODE_WHILE, "body");
+ F_LOC(keyword_loc, RNODE_WHILE);
+ LAST_NODE;
+ F_LOC(closing_loc, RNODE_WHILE);
+ return;
+
+ case NODE_ITER:
+ ANN("method call with block");
+ ANN("format: [nd_iter] { [nd_body] }");
+ ANN("example: 3.times { foo }");
+ F_NODE(nd_iter, RNODE_ITER, "iteration receiver");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_ITER, "body");
+ return;
+
+ case NODE_FOR:
+ ANN("for statement");
+ ANN("format: for * in [nd_iter] do [nd_body] end");
+ ANN("example: for i in 1..3 do foo end");
+ F_NODE(nd_iter, RNODE_FOR, "iteration receiver");
+ F_NODE(nd_body, RNODE_FOR, "body");
+ F_LOC(for_keyword_loc, RNODE_FOR);
+ F_LOC(in_keyword_loc, RNODE_FOR);
+ F_LOC(do_keyword_loc, RNODE_FOR);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_FOR);
+ return;
+
+ case NODE_FOR_MASGN:
+ ANN("vars of for statement with masgn");
+ ANN("format: for [nd_var] in ... do ... end");
+ ANN("example: for x, y in 1..3 do foo end");
+ LAST_NODE;
+ F_NODE(nd_var, RNODE_FOR_MASGN, "var");
+ return;
+
+ case NODE_BREAK:
+ ANN("break statement");
+ ANN("format: break [nd_stts]");
+ ANN("example: break 1");
+ F_NODE(nd_stts, RNODE_BREAK, "value");
+ LAST_NODE;
+ F_LOC(keyword_loc, RNODE_BREAK);
+ return;
+ case NODE_NEXT:
+ ANN("next statement");
+ ANN("format: next [nd_stts]");
+ ANN("example: next 1");
+ F_NODE(nd_stts, RNODE_NEXT, "value");
+ LAST_NODE;
+ F_LOC(keyword_loc, RNODE_NEXT);
+ return;
+ case NODE_RETURN:
+ ANN("return statement");
+ ANN("format: return [nd_stts]");
+ ANN("example: return 1");
+ F_NODE(nd_stts, RNODE_RETURN, "value");
+ LAST_NODE;
+ F_LOC(keyword_loc, RNODE_RETURN);
+ return;
+
+ case NODE_REDO:
+ ANN("redo statement");
+ ANN("format: redo");
+ ANN("example: redo");
+ F_LOC(keyword_loc, RNODE_REDO);
+ return;
+
+ case NODE_RETRY:
+ ANN("retry statement");
+ ANN("format: retry");
+ ANN("example: retry");
+ return;
+
+ case NODE_BEGIN:
+ ANN("begin statement");
+ ANN("format: begin; [nd_body]; end");
+ ANN("example: begin; 1; end");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_BEGIN, "body");
+ return;
+
+ case NODE_RESCUE:
+ ANN("rescue clause");
+ ANN("format: begin; [nd_body]; (rescue) [nd_resq]; else [nd_else]; end");
+ ANN("example: begin; foo; rescue; bar; else; baz; end");
+ F_NODE(nd_head, RNODE_RESCUE, "body");
+ F_NODE(nd_resq, RNODE_RESCUE, "rescue clause list");
+ LAST_NODE;
+ F_NODE(nd_else, RNODE_RESCUE, "rescue else clause");
+ return;
+
+ case NODE_RESBODY:
+ ANN("rescue clause (cont'd)");
+ ANN("format: rescue [nd_args] (=> [nd_exc_var]); [nd_body]; (rescue) [nd_next]");
+ ANN("example: begin; foo; rescue; bar; else; baz; end");
+ F_NODE(nd_args, RNODE_RESBODY, "rescue exceptions");
+ F_NODE(nd_exc_var, RNODE_RESBODY, "exception variable");
+ F_NODE(nd_body, RNODE_RESBODY, "rescue clause");
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_RESBODY, "next rescue clause");
+ return;
+
+ case NODE_ENSURE:
+ ANN("ensure clause");
+ ANN("format: begin; [nd_head]; ensure; [nd_ensr]; end");
+ ANN("example: begin; foo; ensure; bar; end");
+ F_NODE(nd_head, RNODE_ENSURE, "body");
+ LAST_NODE;
+ F_NODE(nd_ensr, RNODE_ENSURE, "ensure clause");
+ return;
+
+ case NODE_AND:
+ ANN("&& operator");
+ ANN("format: [nd_1st] && [nd_2nd]");
+ ANN("example: foo && bar");
+ goto andor;
+ case NODE_OR:
+ ANN("|| operator");
+ ANN("format: [nd_1st] || [nd_2nd]");
+ ANN("example: foo || bar");
+ andor:
+ while (1) {
+ F_NODE(nd_1st, RNODE_AND, "left expr");
+ if (!RNODE_AND(node)->nd_2nd || !nd_type_p(RNODE_AND(node)->nd_2nd, type))
+ break;
+ node = RNODE_AND(node)->nd_2nd;
+ }
+ F_NODE(nd_2nd, RNODE_AND, "right expr");
+ LAST_NODE;
+ F_LOC(operator_loc, RNODE_AND);
+ return;
+
+ case NODE_MASGN:
+ ANN("multiple assignment");
+ ANN("format: [nd_head], [nd_args] = [nd_value]");
+ ANN("example: a, b = foo");
+ F_NODE(nd_value, RNODE_MASGN, "rhsn");
+ F_NODE(nd_head, RNODE_MASGN, "lhsn");
+ if (NODE_NAMED_REST_P(RNODE_MASGN(node)->nd_args)) {
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_MASGN, "splatn");
+ }
+ else {
+ F_MSG(nd_args, "splatn", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
+ }
+ return;
+
+ case NODE_LASGN:
+ ANN("local variable assignment");
+ ANN("format: [nd_vid](lvar) = [nd_value]");
+ ANN("example: x = foo");
+ F_ID(nd_vid, RNODE_LASGN, "local variable");
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_LASGN(node)->nd_value)) {
+ F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
+ }
+ else {
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_LASGN, "rvalue");
+ }
+ return;
+ case NODE_DASGN:
+ ANN("dynamic variable assignment");
+ ANN("format: [nd_vid](dvar) = [nd_value]");
+ ANN("example: x = nil; 1.times { x = foo }");
+ ANN("example: 1.times { x = foo }");
+ F_ID(nd_vid, RNODE_DASGN, "local variable");
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_DASGN(node)->nd_value)) {
+ F_MSG(nd_value, "rvalue", "NODE_SPECIAL_REQUIRED_KEYWORD (required keyword argument)");
+ }
+ else {
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_DASGN, "rvalue");
+ }
+ return;
+ case NODE_IASGN:
+ ANN("instance variable assignment");
+ ANN("format: [nd_vid](ivar) = [nd_value]");
+ ANN("example: @x = foo");
+ F_ID(nd_vid, RNODE_IASGN, "instance variable");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_IASGN, "rvalue");
+ return;
+ case NODE_CVASGN:
+ ANN("class variable assignment");
+ ANN("format: [nd_vid](cvar) = [nd_value]");
+ ANN("example: @@x = foo");
+ F_ID(nd_vid, RNODE_CVASGN, "class variable");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_CVASGN, "rvalue");
+ return;
+ case NODE_GASGN:
+ ANN("global variable assignment");
+ ANN("format: [nd_vid](gvar) = [nd_value]");
+ ANN("example: $x = foo");
+ F_ID(nd_vid, RNODE_GASGN, "global variable");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_GASGN, "rvalue");
+ return;
+
+ case NODE_CDECL:
+ ANN("constant declaration");
+ ANN("format: [nd_else]::[nd_vid](constant) = [nd_value]");
+ ANN("example: X = foo");
+ if (RNODE_CDECL(node)->nd_vid) {
+ F_ID(nd_vid, RNODE_CDECL, "constant");
+ F_MSG(nd_else, "extension", "not used");
+ }
+ else {
+ F_MSG(nd_vid, "constant", "0 (see extension field)");
+ F_NODE(nd_else, RNODE_CDECL, "extension");
+ }
+ F_SHAREABILITY(shareability, RNODE_CDECL, "shareability");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_CDECL, "rvalue");
+ return;
+
+ case NODE_OP_ASGN1:
+ ANN("array assignment with operator");
+ ANN("format: [nd_recv] [ [nd_index] ] [nd_mid]= [nd_rvalue]");
+ ANN("example: ary[1] += foo");
+ F_NODE(nd_recv, RNODE_OP_ASGN1, "receiver");
+ F_ID(nd_mid, RNODE_OP_ASGN1, "operator");
+ F_NODE(nd_index, RNODE_OP_ASGN1, "index");
+ F_NODE(nd_rvalue, RNODE_OP_ASGN1, "rvalue");
+ F_LOC(call_operator_loc, RNODE_OP_ASGN1);
+ F_LOC(opening_loc, RNODE_OP_ASGN1);
+ F_LOC(closing_loc, RNODE_OP_ASGN1);
+ LAST_NODE;
+ F_LOC(binary_operator_loc, RNODE_OP_ASGN1);
+ return;
+
+ case NODE_OP_ASGN2:
+ ANN("attr assignment with operator");
+ ANN("format: [nd_recv].[nd_vid] [nd_mid]= [nd_value]");
+ ANN("example: struct.field += foo");
+ F_NODE(nd_recv, RNODE_OP_ASGN2, "receiver");
+ F_CUSTOM1(nd_vid, "attr") {
+ if (RNODE_OP_ASGN2(node)->nd_aid) A("? ");
+ A_ID(RNODE_OP_ASGN2(node)->nd_vid);
+ }
+ F_ID(nd_mid, RNODE_OP_ASGN2, "operator");
+ F_NODE(nd_value, RNODE_OP_ASGN2, "rvalue");
+ F_LOC(call_operator_loc, RNODE_OP_ASGN2);
+ F_LOC(message_loc, RNODE_OP_ASGN2);
+ LAST_NODE;
+ F_LOC(binary_operator_loc, RNODE_OP_ASGN2);
+ return;
+
+ case NODE_OP_ASGN_AND:
+ ANN("assignment with && operator");
+ ANN("format: [nd_head] &&= [nd_value]");
+ ANN("example: foo &&= bar");
+ goto asgn_andor;
+ case NODE_OP_ASGN_OR:
+ ANN("assignment with || operator");
+ ANN("format: [nd_head] ||= [nd_value]");
+ ANN("example: foo ||= bar");
+ asgn_andor:
+ F_NODE(nd_head, RNODE_OP_ASGN_AND, "variable");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_OP_ASGN_AND, "rvalue");
+ return;
+
+ case NODE_OP_CDECL:
+ ANN("constant declaration with operator");
+ ANN("format: [nd_head](constant) [nd_aid]= [nd_value]");
+ ANN("example: A::B ||= 1");
+ F_NODE(nd_head, RNODE_OP_CDECL, "constant");
+ F_ID(nd_aid, RNODE_OP_CDECL, "operator");
+ F_SHAREABILITY(shareability, RNODE_OP_CDECL, "shareability");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_OP_CDECL, "rvalue");
+ return;
+
+ case NODE_CALL:
+ ANN("method invocation");
+ ANN("format: [nd_recv].[nd_mid]([nd_args])");
+ ANN("example: obj.foo(1)");
+ F_ID(nd_mid, RNODE_CALL, "method id");
+ F_NODE(nd_recv, RNODE_CALL, "receiver");
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_CALL, "arguments");
+ return;
+
+ case NODE_OPCALL:
+ ANN("method invocation");
+ ANN("format: [nd_recv] [nd_mid] [nd_args]");
+ ANN("example: foo + bar");
+ F_ID(nd_mid, RNODE_OPCALL, "method id");
+ F_NODE(nd_recv, RNODE_OPCALL, "receiver");
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_OPCALL, "arguments");
+ return;
+
+ case NODE_FCALL:
+ ANN("function call");
+ ANN("format: [nd_mid]([nd_args])");
+ ANN("example: foo(1)");
+ F_ID(nd_mid, RNODE_FCALL, "method id");
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_FCALL, "arguments");
+ return;
+
+ case NODE_VCALL:
+ ANN("function call with no argument");
+ ANN("format: [nd_mid]");
+ ANN("example: foo");
+ F_ID(nd_mid, RNODE_VCALL, "method id");
+ return;
+
+ case NODE_QCALL:
+ ANN("safe method invocation");
+ ANN("format: [nd_recv]&.[nd_mid]([nd_args])");
+ ANN("example: obj&.foo(1)");
+ F_ID(nd_mid, RNODE_QCALL, "method id");
+ F_NODE(nd_recv, RNODE_QCALL, "receiver");
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_QCALL, "arguments");
+ return;
+
+ case NODE_SUPER:
+ ANN("super invocation");
+ ANN("format: super [nd_args]");
+ ANN("example: super 1");
+ F_NODE(nd_args, RNODE_SUPER, "arguments");
+ F_LOC(keyword_loc, RNODE_SUPER);
+ F_LOC(lparen_loc, RNODE_SUPER);
+ LAST_NODE;
+ F_LOC(rparen_loc, RNODE_SUPER);
+ return;
+
+ case NODE_ZSUPER:
+ ANN("super invocation with no argument");
+ ANN("format: super");
+ ANN("example: super");
+ return;
+
+ case NODE_LIST:
+ ANN("list constructor");
+ ANN("format: [ [nd_head], [nd_next].. ] (length: [nd_alen])");
+ ANN("example: [1, 2, 3]");
+ dump_array(buf, indent, comment, node);
+ return;
+
+ case NODE_ZLIST:
+ ANN("empty list constructor");
+ ANN("format: []");
+ ANN("example: []");
+ return;
+
+ case NODE_HASH:
+ if (!RNODE_HASH(node)->nd_brace) {
+ ANN("keyword arguments");
+ ANN("format: [nd_head]");
+ ANN("example: a: 1, b: 2");
+ }
+ else {
+ ANN("hash constructor");
+ ANN("format: { [nd_head] }");
+ ANN("example: { 1 => 2, 3 => 4 }");
+ }
+ F_CUSTOM1(nd_brace, "keyword arguments or hash literal") {
+ switch (RNODE_HASH(node)->nd_brace) {
+ case 0: A("0 (keyword argument)"); break;
+ case 1: A("1 (hash literal)"); break;
+ }
+ }
+ LAST_NODE;
+ F_NODE(nd_head, RNODE_HASH, "contents");
+ return;
+
+ case NODE_YIELD:
+ ANN("yield invocation");
+ ANN("format: yield [nd_head]");
+ ANN("example: yield 1");
+ F_NODE(nd_head, RNODE_YIELD, "arguments");
+ F_LOC(keyword_loc, RNODE_YIELD);
+ F_LOC(lparen_loc, RNODE_YIELD);
+ LAST_NODE;
+ F_LOC(rparen_loc, RNODE_YIELD);
+ return;
+
+ case NODE_LVAR:
+ ANN("local variable reference");
+ ANN("format: [nd_vid](lvar)");
+ ANN("example: x");
+ F_ID(nd_vid, RNODE_LVAR, "local variable");
+ return;
+ case NODE_DVAR:
+ ANN("dynamic variable reference");
+ ANN("format: [nd_vid](dvar)");
+ ANN("example: 1.times { x = 1; x }");
+ F_ID(nd_vid, RNODE_DVAR, "local variable");
+ return;
+ case NODE_IVAR:
+ ANN("instance variable reference");
+ ANN("format: [nd_vid](ivar)");
+ ANN("example: @x");
+ F_ID(nd_vid, RNODE_IVAR, "instance variable");
+ return;
+ case NODE_CONST:
+ ANN("constant reference");
+ ANN("format: [nd_vid](constant)");
+ ANN("example: X");
+ F_ID(nd_vid, RNODE_CONST, "constant");
+ return;
+ case NODE_CVAR:
+ ANN("class variable reference");
+ ANN("format: [nd_vid](cvar)");
+ ANN("example: @@x");
+ F_ID(nd_vid, RNODE_CVAR, "class variable");
+ return;
+
+ case NODE_GVAR:
+ ANN("global variable reference");
+ ANN("format: [nd_vid](gvar)");
+ ANN("example: $x");
+ F_ID(nd_vid, RNODE_GVAR, "global variable");
+ return;
+
+ case NODE_NTH_REF:
+ ANN("nth special variable reference");
+ ANN("format: $[nd_nth]");
+ ANN("example: $1, $2, ..");
+ F_CUSTOM1(nd_nth, "variable") { A("$"); A_LONG(RNODE_NTH_REF(node)->nd_nth); }
+ return;
+
+ case NODE_BACK_REF:
+ ANN("back special variable reference");
+ ANN("format: $[nd_nth]");
+ ANN("example: $&, $`, $', $+");
+ F_CUSTOM1(nd_nth, "variable") {
+ char name[3] = "$ ";
+ name[1] = (char)RNODE_BACK_REF(node)->nd_nth;
+ A(name);
+ }
+ return;
+
+ case NODE_MATCH:
+ ANN("match expression (against $_ implicitly)");
+ ANN("format: [nd_lit] (in condition)");
+ ANN("example: if /foo/; foo; end");
+ LAST_NODE;
+ F_VALUE(string, rb_node_regx_string_val(node), "string");
+ return;
+
+ case NODE_MATCH2:
+ ANN("match expression (regexp first)");
+ ANN("format: [nd_recv] =~ [nd_value]");
+ ANN("example: /foo/ =~ 'foo'");
+ F_NODE(nd_recv, RNODE_MATCH2, "regexp (receiver)");
+ if (!RNODE_MATCH2(node)->nd_args) LAST_NODE;
+ F_NODE(nd_value, RNODE_MATCH2, "string (argument)");
+ if (RNODE_MATCH2(node)->nd_args) {
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_MATCH2, "named captures");
+ }
+ return;
+
+ case NODE_MATCH3:
+ ANN("match expression (regexp second)");
+ ANN("format: [nd_recv] =~ [nd_value]");
+ ANN("example: 'foo' =~ /foo/");
+ F_NODE(nd_recv, RNODE_MATCH3, "string (receiver)");
+ LAST_NODE;
+ F_NODE(nd_value, RNODE_MATCH3, "regexp (argument)");
+ return;
+
+ case NODE_STR:
+ ANN("string literal");
+ ANN("format: [nd_lit]");
+ ANN("example: 'foo'");
+ goto str;
+ case NODE_XSTR:
+ ANN("xstring literal");
+ ANN("format: [nd_lit]");
+ ANN("example: `foo`");
+ str:
+ F_VALUE(string, rb_node_str_string_val(node), "literal");
+ return;
+
+ case NODE_INTEGER:
+ ANN("integer literal");
+ ANN("format: [val]");
+ ANN("example: 1");
+ F_VALUE(val, rb_node_integer_literal_val(node), "val");
+ return;
+
+ case NODE_FLOAT:
+ ANN("float literal");
+ ANN("format: [val]");
+ ANN("example: 1.2");
+ F_VALUE(val, rb_node_float_literal_val(node), "val");
+ return;
+
+ case NODE_RATIONAL:
+ ANN("rational number literal");
+ ANN("format: [val]");
+ ANN("example: 1r");
+ F_VALUE(val, rb_node_rational_literal_val(node), "val");
+ return;
+
+ case NODE_IMAGINARY:
+ ANN("complex number literal");
+ ANN("format: [val]");
+ ANN("example: 1i");
+ F_VALUE(val, rb_node_imaginary_literal_val(node), "val");
+ return;
+
+ case NODE_REGX:
+ ANN("regexp literal");
+ ANN("format: [string]");
+ ANN("example: /foo/");
+ F_VALUE(string, rb_node_regx_string_val(node), "string");
+ F_LOC(opening_loc, RNODE_REGX);
+ F_LOC(content_loc, RNODE_REGX);
+ LAST_NODE;
+ F_LOC(closing_loc, RNODE_REGX);
+ return;
+
+ case NODE_ONCE:
+ ANN("once evaluation");
+ ANN("format: [nd_body]");
+ ANN("example: /foo#{ bar }baz/o");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_ONCE, "body");
+ return;
+
+ case NODE_DSTR:
+ ANN("string literal with interpolation");
+ ANN("format: [nd_lit]");
+ ANN("example: \"foo#{ bar }baz\"");
+ goto dlit;
+ case NODE_DXSTR:
+ ANN("xstring literal with interpolation");
+ ANN("format: [nd_lit]");
+ ANN("example: `foo#{ bar }baz`");
+ goto dlit;
+ case NODE_DREGX:
+ ANN("regexp literal with interpolation");
+ ANN("format: [nd_lit]");
+ ANN("example: /foo#{ bar }baz/");
+ goto dlit;
+ case NODE_DSYM:
+ ANN("symbol literal with interpolation");
+ ANN("format: [nd_lit]");
+ ANN("example: :\"foo#{ bar }baz\"");
+ dlit:
+ F_VALUE(string, rb_node_dstr_string_val(node), "preceding string");
+ if (!RNODE_DSTR(node)->nd_next) return;
+ F_NODE(nd_next->nd_head, RNODE_DSTR, "interpolation");
+ LAST_NODE;
+ F_NODE(nd_next->nd_next, RNODE_DSTR, "tailing strings");
+ return;
+
+ case NODE_SYM:
+ ANN("symbol literal");
+ ANN("format: [string]");
+ ANN("example: :foo");
+ F_VALUE(string, rb_node_sym_string_val(node), "string");
+ return;
+
+ case NODE_EVSTR:
+ ANN("interpolation expression");
+ ANN("format: \"..#{ [nd_body] }..\"");
+ ANN("example: \"foo#{ bar }baz\"");
+ F_NODE(nd_body, RNODE_EVSTR, "body");
+ F_LOC(opening_loc, RNODE_EVSTR);
+ LAST_NODE;
+ F_LOC(closing_loc, RNODE_EVSTR);
+ return;
+
+ case NODE_ARGSCAT:
+ ANN("splat argument following arguments");
+ ANN("format: ..(*[nd_head], [nd_body..])");
+ ANN("example: foo(*ary, post_arg1, post_arg2)");
+ F_NODE(nd_head, RNODE_ARGSCAT, "preceding array");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_ARGSCAT, "following array");
+ return;
+
+ case NODE_ARGSPUSH:
+ ANN("splat argument following one argument");
+ ANN("format: ..(*[nd_head], [nd_body])");
+ ANN("example: foo(*ary, post_arg)");
+ F_NODE(nd_head, RNODE_ARGSPUSH, "preceding array");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_ARGSPUSH, "following element");
+ return;
+
+ case NODE_SPLAT:
+ ANN("splat argument");
+ ANN("format: *[nd_head]");
+ ANN("example: foo(*ary)");
+ F_NODE(nd_head, RNODE_SPLAT, "splat'ed array");
+ LAST_NODE;
+ F_LOC(operator_loc, RNODE_SPLAT);
+ return;
+
+ case NODE_BLOCK_PASS:
+ ANN("arguments with block argument");
+ ANN("format: ..([nd_head], &[nd_body])");
+ ANN("example: foo(x, &blk)");
+ F_CUSTOM1(forwarding, "arguments forwarding or not") {
+ switch (RNODE_BLOCK_PASS(node)->forwarding) {
+ case 0: A("0 (no forwarding)"); break;
+ case 1: A("1 (forwarding)"); break;
+ }
+ }
+ F_NODE(nd_head, RNODE_BLOCK_PASS, "other arguments");
+ F_NODE(nd_body, RNODE_BLOCK_PASS, "block argument");
+ LAST_NODE;
+ F_LOC(operator_loc, RNODE_BLOCK_PASS);
+ return;
+
+ case NODE_DEFN:
+ ANN("method definition");
+ ANN("format: def [nd_mid] [nd_defn]; end");
+ ANN("example: def foo; bar; end");
+ F_ID(nd_mid, RNODE_DEFN, "method name");
+ LAST_NODE;
+ F_NODE(nd_defn, RNODE_DEFN, "method definition");
+ return;
+
+ case NODE_DEFS:
+ ANN("singleton method definition");
+ ANN("format: def [nd_recv].[nd_mid] [nd_defn]; end");
+ ANN("example: def obj.foo; bar; end");
+ F_NODE(nd_recv, RNODE_DEFS, "receiver");
+ F_ID(nd_mid, RNODE_DEFS, "method name");
+ LAST_NODE;
+ F_NODE(nd_defn, RNODE_DEFS, "method definition");
+ return;
+
+ case NODE_ALIAS:
+ ANN("method alias statement");
+ ANN("format: alias [nd_1st] [nd_2nd]");
+ ANN("example: alias bar foo");
+ F_NODE(nd_1st, RNODE_ALIAS, "new name");
+ F_NODE(nd_2nd, RNODE_ALIAS, "old name");
+ LAST_NODE;
+ F_LOC(keyword_loc, RNODE_ALIAS);
+ return;
+
+ case NODE_VALIAS:
+ ANN("global variable alias statement");
+ ANN("format: alias [nd_alias](gvar) [nd_orig](gvar)");
+ ANN("example: alias $y $x");
+ F_ID(nd_alias, RNODE_VALIAS, "new name");
+ F_ID(nd_orig, RNODE_VALIAS, "old name");
+ F_LOC(keyword_loc, RNODE_VALIAS);
+ return;
+
+ case NODE_UNDEF:
+ ANN("method undef statement");
+ ANN("format: undef [nd_undefs]");
+ ANN("example: undef foo");
+ LAST_NODE;
+ F_ARRAY(nd_undefs, RNODE_UNDEF, "nd_undefs");
+ F_LOC(keyword_loc, RNODE_UNDEF);
+ return;
+
+ case NODE_CLASS:
+ ANN("class definition");
+ ANN("format: class [nd_cpath] < [nd_super]; [nd_body]; end");
+ ANN("example: class C2 < C; ..; end");
+ F_NODE(nd_cpath, RNODE_CLASS, "class path");
+ F_NODE(nd_super, RNODE_CLASS, "superclass");
+ F_NODE(nd_body, RNODE_CLASS, "class definition");
+ F_LOC(class_keyword_loc, RNODE_CLASS);
+ F_LOC(inheritance_operator_loc, RNODE_CLASS);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_CLASS);
+ return;
+
+ case NODE_MODULE:
+ ANN("module definition");
+ ANN("format: module [nd_cpath]; [nd_body]; end");
+ ANN("example: module M; ..; end");
+ F_NODE(nd_cpath, RNODE_MODULE, "module path");
+ F_NODE(nd_body, RNODE_MODULE, "module definition");
+ F_LOC(module_keyword_loc, RNODE_MODULE);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_MODULE);
+ return;
+
+ case NODE_SCLASS:
+ ANN("singleton class definition");
+ ANN("format: class << [nd_recv]; [nd_body]; end");
+ ANN("example: class << obj; ..; end");
+ F_NODE(nd_recv, RNODE_SCLASS, "receiver");
+ F_NODE(nd_body, RNODE_SCLASS, "singleton class definition");
+ F_LOC(class_keyword_loc, RNODE_SCLASS);
+ F_LOC(operator_loc, RNODE_SCLASS);
+ LAST_NODE;
+ F_LOC(end_keyword_loc, RNODE_SCLASS);
+ return;
+
+ case NODE_COLON2:
+ ANN("scoped constant reference");
+ ANN("format: [nd_head]::[nd_mid]");
+ ANN("example: M::C");
+ F_ID(nd_mid, RNODE_COLON2, "constant name");
+ F_NODE(nd_head, RNODE_COLON2, "receiver");
+ F_LOC(delimiter_loc, RNODE_COLON2);
+ LAST_NODE;
+ F_LOC(name_loc, RNODE_COLON2);
+ return;
+
+ case NODE_COLON3:
+ ANN("top-level constant reference");
+ ANN("format: ::[nd_mid]");
+ ANN("example: ::Object");
+ F_ID(nd_mid, RNODE_COLON3, "constant name");
+ F_LOC(delimiter_loc, RNODE_COLON3);
+ F_LOC(name_loc, RNODE_COLON3);
+ return;
+
+ case NODE_DOT2:
+ ANN("range constructor (incl.)");
+ ANN("format: [nd_beg]..[nd_end]");
+ ANN("example: 1..5");
+ goto dot;
+ case NODE_DOT3:
+ ANN("range constructor (excl.)");
+ ANN("format: [nd_beg]...[nd_end]");
+ ANN("example: 1...5");
+ goto dot;
+ case NODE_FLIP2:
+ ANN("flip-flop condition (incl.)");
+ ANN("format: [nd_beg]..[nd_end]");
+ ANN("example: if (x==1)..(x==5); foo; end");
+ goto dot;
+ case NODE_FLIP3:
+ ANN("flip-flop condition (excl.)");
+ ANN("format: [nd_beg]...[nd_end]");
+ ANN("example: if (x==1)...(x==5); foo; end");
+ dot:
+ F_NODE(nd_beg, RNODE_DOT2, "begin");
+ F_NODE(nd_end, RNODE_DOT2, "end");
+ LAST_NODE;
+ F_LOC(operator_loc, RNODE_DOT2);
+ return;
+
+ case NODE_SELF:
+ ANN("self");
+ ANN("format: self");
+ ANN("example: self");
+ F_CUSTOM1(nd_state, "nd_state") {
+ A_INT((int)RNODE_SELF(node)->nd_state);
+ }
+ return;
+
+ case NODE_NIL:
+ ANN("nil");
+ ANN("format: nil");
+ ANN("example: nil");
+ return;
+
+ case NODE_TRUE:
+ ANN("true");
+ ANN("format: true");
+ ANN("example: true");
+ return;
+
+ case NODE_FALSE:
+ ANN("false");
+ ANN("format: false");
+ ANN("example: false");
+ return;
+
+ case NODE_ERRINFO:
+ ANN("virtual reference to $!");
+ ANN("format: rescue => id");
+ ANN("example: rescue => id");
+ return;
+
+ case NODE_DEFINED:
+ ANN("defined? expression");
+ ANN("format: defined?([nd_head])");
+ ANN("example: defined?(foo)");
+ F_NODE(nd_head, RNODE_DEFINED, "expr");
+ LAST_NODE;
+ F_LOC(keyword_loc, RNODE_DEFINED);
+ return;
+
+ case NODE_POSTEXE:
+ ANN("post-execution");
+ ANN("format: END { [nd_body] }");
+ ANN("example: END { foo }");
+ F_NODE(nd_body, RNODE_POSTEXE, "END clause");
+ F_LOC(keyword_loc, RNODE_POSTEXE);
+ F_LOC(opening_loc, RNODE_POSTEXE);
+ LAST_NODE;
+ F_LOC(closing_loc, RNODE_POSTEXE);
+ return;
+
+ case NODE_ATTRASGN:
+ ANN("attr assignment");
+ ANN("format: [nd_recv].[nd_mid] = [nd_args]");
+ ANN("example: struct.field = foo");
+ F_NODE(nd_recv, RNODE_ATTRASGN, "receiver");
+ F_ID(nd_mid, RNODE_ATTRASGN, "method name");
+ LAST_NODE;
+ F_NODE(nd_args, RNODE_ATTRASGN, "arguments");
+ return;
+
+ case NODE_LAMBDA:
+ ANN("lambda expression");
+ ANN("format: -> [nd_body]");
+ ANN("example: -> { foo }");
+ F_NODE(nd_body, RNODE_LAMBDA, "lambda clause");
+ F_LOC(operator_loc, RNODE_LAMBDA);
+ F_LOC(opening_loc, RNODE_LAMBDA);
+ LAST_NODE;
+ F_LOC(closing_loc, RNODE_LAMBDA);
+ return;
+
+ case NODE_OPT_ARG:
+ ANN("optional arguments");
+ ANN("format: def method_name([nd_body=some], [nd_next..])");
+ ANN("example: def foo(a, b=1, c); end");
+ F_NODE(nd_body, RNODE_OPT_ARG, "body");
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_OPT_ARG, "next");
+ return;
+
+ case NODE_KW_ARG:
+ ANN("keyword arguments");
+ ANN("format: def method_name([nd_body=some], [nd_next..])");
+ ANN("example: def foo(a:1, b:2); end");
+ F_NODE(nd_body, RNODE_KW_ARG, "body");
+ LAST_NODE;
+ F_NODE(nd_next, RNODE_KW_ARG, "next");
+ return;
+
+ case NODE_POSTARG:
+ ANN("post arguments");
+ ANN("format: *[nd_1st], [nd_2nd..] = ..");
+ ANN("example: a, *rest, z = foo");
+ if (NODE_NAMED_REST_P(RNODE_POSTARG(node)->nd_1st)) {
+ F_NODE(nd_1st, RNODE_POSTARG, "rest argument");
+ }
+ else {
+ F_MSG(nd_1st, "rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
+ }
+ LAST_NODE;
+ F_NODE(nd_2nd, RNODE_POSTARG, "post arguments");
+ return;
+
+ case NODE_ARGS:
+ ANN("method parameters");
+ ANN("format: def method_name(.., [nd_ainfo.nd_optargs], *[nd_ainfo.rest_arg], [nd_ainfo.first_post_arg], .., [nd_ainfo.kw_args], **[nd_ainfo.kw_rest_arg], &[nd_ainfo.block_arg])");
+ ANN("example: def foo(a, b, opt1=1, opt2=2, *rest, y, z, kw: 1, **kwrest, &blk); end");
+ F_CUSTOM1(nd_ainfo.forwarding, "arguments forwarding or not") {
+ switch (RNODE_ARGS(node)->nd_ainfo.forwarding) {
+ case 0: A("0 (no forwarding)"); break;
+ case 1: A("1 (forwarding)"); break;
+ }
+ }
+ F_INT(nd_ainfo.pre_args_num, RNODE_ARGS, "count of mandatory (pre-)arguments");
+ F_NODE(nd_ainfo.pre_init, RNODE_ARGS, "initialization of (pre-)arguments");
+ F_INT(nd_ainfo.post_args_num, RNODE_ARGS, "count of mandatory post-arguments");
+ F_NODE(nd_ainfo.post_init, RNODE_ARGS, "initialization of post-arguments");
+ F_ID(nd_ainfo.first_post_arg, RNODE_ARGS, "first post argument");
+ F_CUSTOM1(nd_ainfo.rest_arg, "rest argument") {
+ if (RNODE_ARGS(node)->nd_ainfo.rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA) {
+ A("1 (excessed comma)");
+ }
+ else {
+ A_ID(RNODE_ARGS(node)->nd_ainfo.rest_arg);
+ }
+ }
+ F_ID(nd_ainfo.block_arg, RNODE_ARGS, "block argument");
+ F_NODE(nd_ainfo.opt_args, RNODE_ARGS, "optional arguments");
+ F_NODE(nd_ainfo.kw_args, RNODE_ARGS, "keyword arguments");
+ LAST_NODE;
+ F_NODE(nd_ainfo.kw_rest_arg, RNODE_ARGS, "keyword rest argument");
+ return;
+
+ case NODE_SCOPE:
+ ANN("new scope");
+ ANN("format: [nd_tbl]: local table, [nd_args]: arguments, [nd_body]: body");
+ F_CUSTOM1(nd_tbl, "local table") {
+ rb_ast_id_table_t *tbl = RNODE_SCOPE(node)->nd_tbl;
+ int i;
+ int size = tbl ? tbl->size : 0;
+ if (size == 0) A("(empty)");
+ for (i = 0; i < size; i++) {
+ A_ID(tbl->ids[i]); if (i < size - 1) A(",");
+ }
+ }
+ F_NODE(nd_args, RNODE_SCOPE, "arguments");
+ LAST_NODE;
+ F_NODE(nd_body, RNODE_SCOPE, "body");
+ return;
+
+ case NODE_ARYPTN:
+ ANN("array pattern");
+ ANN("format: [nd_pconst]([pre_args], ..., *[rest_arg], [post_args], ...)");
+ F_NODE(nd_pconst, RNODE_ARYPTN, "constant");
+ F_NODE(pre_args, RNODE_ARYPTN, "pre arguments");
+ if (NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg)) {
+ F_NODE(rest_arg, RNODE_ARYPTN, "rest argument");
+ }
+ else {
+ F_MSG(rest_arg, "rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
+ }
+ LAST_NODE;
+ F_NODE(post_args, RNODE_ARYPTN, "post arguments");
+ return;
+
+ case NODE_FNDPTN:
+ ANN("find pattern");
+ ANN("format: [nd_pconst](*[pre_rest_arg], args, ..., *[post_rest_arg])");
+ F_NODE(nd_pconst, RNODE_FNDPTN, "constant");
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->pre_rest_arg)) {
+ F_NODE(pre_rest_arg, RNODE_FNDPTN, "pre rest argument");
+ }
+ else {
+ F_MSG(pre_rest_arg, "pre rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
+ }
+ F_NODE(args, RNODE_FNDPTN, "arguments");
+
+ LAST_NODE;
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->post_rest_arg)) {
+ F_NODE(post_rest_arg, RNODE_FNDPTN, "post rest argument");
+ }
+ else {
+ F_MSG(post_rest_arg, "post rest argument", "NODE_SPECIAL_NO_NAME_REST (rest argument without name)");
+ }
+ return;
+
+ case NODE_HSHPTN:
+ ANN("hash pattern");
+ ANN("format: [nd_pconst]([nd_pkwargs], ..., **[nd_pkwrestarg])");
+ F_NODE(nd_pconst, RNODE_HSHPTN, "constant");
+ F_NODE(nd_pkwargs, RNODE_HSHPTN, "keyword arguments");
+ LAST_NODE;
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
+ F_MSG(nd_pkwrestarg, "keyword rest argument", "NODE_SPECIAL_NO_REST_KEYWORD (**nil)");
+ }
+ else {
+ F_NODE(nd_pkwrestarg, RNODE_HSHPTN, "keyword rest argument");
+ }
+ return;
+
+ case NODE_LINE:
+ ANN("line");
+ ANN("format: [lineno]");
+ ANN("example: __LINE__");
+ return;
+
+ case NODE_FILE:
+ ANN("line");
+ ANN("format: [path]");
+ ANN("example: __FILE__");
+ F_VALUE(path, rb_node_file_path_val(node), "path");
+ return;
+
+ case NODE_ENCODING:
+ ANN("encoding");
+ ANN("format: [enc]");
+ ANN("example: __ENCODING__");
+ F_VALUE(enc, rb_node_encoding_val(node), "enc");
+ return;
+
+ case NODE_ERROR:
+ ANN("Broken input recovered by Error Tolerant mode");
+ return;
+
+ case NODE_ARGS_AUX:
+ case NODE_LAST:
+ break;
+ }
+
+ rb_bug("dump_node: unknown node: %s", ruby_node_name(nd_type(node)));
+}
+
+VALUE
+rb_parser_dump_tree(const NODE *node, int comment)
+{
+ VALUE buf = rb_str_new_cstr(
+ "###########################################################\n"
+ "## Do NOT use this node dump for any purpose other than ##\n"
+ "## debug and research. Compatibility is not guaranteed. ##\n"
+ "###########################################################\n\n"
+ );
+ dump_node(buf, rb_str_new_cstr("# "), comment, node);
+ return buf;
+}
diff --git a/numeric.c b/numeric.c
index ab8dde52f4..f4dc0f8927 100644
--- a/numeric.c
+++ b/numeric.c
@@ -30,6 +30,7 @@
#include "internal/compilers.h"
#include "internal/complex.h"
#include "internal/enumerator.h"
+#include "internal/error.h"
#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/numeric.h"
@@ -74,6 +75,8 @@
#define DBL_EPSILON 2.2204460492503131e-16
#endif
+#define ACCURATE_POW10(ndigits) ((ndigits) < DBL_DIG)
+
#ifndef USE_RB_INFINITY
#elif !defined(WORDS_BIGENDIAN) /* BYTE_ORDER == LITTLE_ENDIAN */
const union bytesequence4_or_float rb_infinity = {{0x00, 0x00, 0x80, 0x7f}};
@@ -491,7 +494,7 @@ rb_num_coerce_cmp(VALUE x, VALUE y, ID func)
static VALUE
ensure_cmp(VALUE c, VALUE x, VALUE y)
{
- if (NIL_P(c)) rb_cmperr(x, y);
+ if (NIL_P(c)) rb_cmperr_reason(x, y, "comparator returned nil");
return c;
}
@@ -501,7 +504,7 @@ rb_num_coerce_relop(VALUE x, VALUE y, ID func)
VALUE x0 = x, y0 = y;
if (!do_coerce(&x, &y, FALSE)) {
- rb_cmperr(x0, y0);
+ rb_cmperr_reason(x0, y0, "coercion was not possible");
UNREACHABLE_RETURN(Qnil);
}
return ensure_cmp(rb_funcall(x, func, 1, y), x0, y0);
@@ -552,39 +555,6 @@ num_clone(int argc, VALUE *argv, VALUE x)
# define num_clone rb_immutable_obj_clone
#endif
-#if 0
-/*
- * call-seq:
- * dup -> self
- *
- * Returns +self+.
- *
- * Related: Numeric#clone.
- *
- */
-static VALUE
-num_dup(VALUE x)
-{
- return x;
-}
-#else
-# define num_dup num_uplus
-#endif
-
-/*
- * call-seq:
- * +self -> self
- *
- * Returns +self+.
- *
- */
-
-static VALUE
-num_uplus(VALUE num)
-{
- return num;
-}
-
/*
* call-seq:
* i -> complex
@@ -609,7 +579,7 @@ num_imaginary(VALUE num)
* call-seq:
* -self -> numeric
*
- * Unary Minus---Returns the receiver, negated.
+ * Returns +self+, negated.
*/
static VALUE
@@ -628,8 +598,8 @@ num_uminus(VALUE num)
* fdiv(other) -> float
*
* Returns the quotient <tt>self/other</tt> as a float,
- * using method +/+ in the derived class of +self+.
- * (\Numeric itself does not define method +/+.)
+ * using method +/+ as defined in the subclass of \Numeric.
+ * (\Numeric itself does not define +/+.)
*
* Of the Core and Standard Library classes,
* only BigDecimal uses this implementation.
@@ -647,8 +617,8 @@ num_fdiv(VALUE x, VALUE y)
* div(other) -> integer
*
* Returns the quotient <tt>self/other</tt> as an integer (via +floor+),
- * using method +/+ in the derived class of +self+.
- * (\Numeric itself does not define method +/+.)
+ * using method +/+ as defined in the subclass of \Numeric.
+ * (\Numeric itself does not define +/+.)
*
* Of the Core and Standard Library classes,
* Only Float and Rational use this implementation.
@@ -666,12 +636,12 @@ num_div(VALUE x, VALUE y)
* call-seq:
* self % other -> real_numeric
*
- * Returns +self+ modulo +other+ as a real number.
+ * Returns +self+ modulo +other+ as a real numeric (\Integer, \Float, or \Rational).
*
* Of the Core and Standard Library classes,
* only Rational uses this implementation.
*
- * For \Rational +r+ and real number +n+, these expressions are equivalent:
+ * For Rational +r+ and real number +n+, these expressions are equivalent:
*
* r % n
* r-n*(r/n).floor
@@ -836,7 +806,7 @@ int_zero_p(VALUE num)
if (FIXNUM_P(num)) {
return FIXNUM_ZERO_P(num);
}
- assert(RB_BIGNUM_TYPE_P(num));
+ RUBY_ASSERT(RB_BIGNUM_TYPE_P(num));
return rb_bigzero_p(num);
}
@@ -862,6 +832,8 @@ rb_int_zero_p(VALUE num)
* Of the Core and Standard Library classes,
* Integer, Float, Rational, and Complex use this implementation.
*
+ * Related: #zero?
+ *
*/
static VALUE
@@ -878,7 +850,8 @@ num_nonzero_p(VALUE num)
* to_int -> integer
*
* Returns +self+ as an integer;
- * converts using method +to_i+ in the derived class.
+ * converts using method +to_i+ in the subclass of \Numeric.
+ * (\Numeric itself does not define +to_i+.)
*
* Of the Core and Standard Library classes,
* only Rational and Complex use this implementation.
@@ -888,7 +861,7 @@ num_nonzero_p(VALUE num)
* Rational(1, 2).to_int # => 0
* Rational(2, 1).to_int # => 2
* Complex(2, 0).to_int # => 2
- * Complex(2, 1) # Raises RangeError (non-zero imaginary part)
+ * Complex(2, 1).to_int # Raises RangeError (non-zero imaginary part)
*
*/
@@ -936,89 +909,10 @@ num_negative_p(VALUE num)
return RBOOL(rb_num_negative_int_p(num));
}
-
-/********************************************************************
- *
- * Document-class: Float
- *
- * A \Float object represents a sometimes-inexact real number using the native
- * architecture's double-precision floating point representation.
- *
- * Floating point has a different arithmetic and is an inexact number.
- * So you should know its esoteric system. See following:
- *
- * - https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
- * - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_imprecise
- * - https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
- *
- * You can create a \Float object explicitly with:
- *
- * - A {floating-point literal}[rdoc-ref:syntax/literals.rdoc@Float+Literals].
- *
- * You can convert certain objects to Floats with:
- *
- * - \Method #Float.
- *
- * == What's Here
- *
- * First, what's elsewhere. \Class \Float:
- *
- * - Inherits from {class Numeric}[rdoc-ref:Numeric@What-27s+Here].
- *
- * Here, class \Float provides methods for:
- *
- * - {Querying}[rdoc-ref:Float@Querying]
- * - {Comparing}[rdoc-ref:Float@Comparing]
- * - {Converting}[rdoc-ref:Float@Converting]
- *
- * === Querying
- *
- * - #finite?: Returns whether +self+ is finite.
- * - #hash: Returns the integer hash code for +self+.
- * - #infinite?: Returns whether +self+ is infinite.
- * - #nan?: Returns whether +self+ is a NaN (not-a-number).
- *
- * === Comparing
- *
- * - #<: Returns whether +self+ is less than the given value.
- * - #<=: Returns whether +self+ is less than or equal to the given value.
- * - #<=>: Returns a number indicating whether +self+ is less than, equal
- * to, or greater than the given value.
- * - #== (aliased as #=== and #eql?): Returns whether +self+ is equal to
- * the given value.
- * - #>: Returns whether +self+ is greater than the given value.
- * - #>=: Returns whether +self+ is greater than or equal to the given value.
- *
- * === Converting
- *
- * - #% (aliased as #modulo): Returns +self+ modulo the given value.
- * - #*: Returns the product of +self+ and the given value.
- * - #**: Returns the value of +self+ raised to the power of the given value.
- * - #+: Returns the sum of +self+ and the given value.
- * - #-: Returns the difference of +self+ and the given value.
- * - #/: Returns the quotient of +self+ and the given value.
- * - #ceil: Returns the smallest number greater than or equal to +self+.
- * - #coerce: Returns a 2-element array containing the given value converted to a \Float
- and +self+
- * - #divmod: Returns a 2-element array containing the quotient and remainder
- * results of dividing +self+ by the given value.
- * - #fdiv: Returns the Float result of dividing +self+ by the given value.
- * - #floor: Returns the greatest number smaller than or equal to +self+.
- * - #next_float: Returns the next-larger representable \Float.
- * - #prev_float: Returns the next-smaller representable \Float.
- * - #quo: Returns the quotient from dividing +self+ by the given value.
- * - #round: Returns +self+ rounded to the nearest value, to a given precision.
- * - #to_i (aliased as #to_int): Returns +self+ truncated to an Integer.
- * - #to_s (aliased as #inspect): Returns a string containing the place-value
- * representation of +self+ in the given radix.
- * - #truncate: Returns +self+ truncated to a given precision.
- *
- */
-
VALUE
rb_float_new_in_heap(double d)
{
- NEWOBJ_OF(flt, struct RFloat, rb_cFloat, T_FLOAT | (RGENGC_WB_PROTECTED_FLOAT ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(flt, struct RFloat, rb_cFloat, T_FLOAT, sizeof(struct RFloat));
#if SIZEOF_DOUBLE <= SIZEOF_VALUE
flt->float_value = d;
@@ -1042,16 +936,15 @@ rb_float_new_in_heap(double d)
* may contain:
*
* - A fixed-point number.
+ * 3.14.to_s # => "3.14"
* - A number in "scientific notation" (containing an exponent).
+ * (10.1**50).to_s # => "1.644631821843879e+50"
* - 'Infinity'.
+ * (10.1**500).to_s # => "Infinity"
* - '-Infinity'.
+ * (-10.1**500).to_s # => "-Infinity"
* - 'NaN' (indicating not-a-number).
- *
- * 3.14.to_s # => "3.14"
- * (10.1**50).to_s # => "1.644631821843879e+50"
- * (10.1**500).to_s # => "Infinity"
- * (-10.1**500).to_s # => "-Infinity"
- * (0.0/0.0).to_s # => "NaN"
+ * (0.0/0.0).to_s # => "NaN"
*
*/
@@ -1078,7 +971,7 @@ flo_to_s(VALUE flt)
s = sign ? rb_usascii_str_new_cstr("-") : rb_usascii_str_new(0, 0);
if ((digs = (int)(e - p)) >= (int)sizeof(buf)) digs = (int)sizeof(buf) - 1;
memcpy(buf, p, digs);
- xfree(p);
+ free(p);
if (decpt > 0) {
if (decpt < digs) {
memmove(buf + decpt + 1, buf + decpt, digs - decpt);
@@ -1160,15 +1053,21 @@ rb_float_uminus(VALUE flt)
/*
* call-seq:
- * self + other -> numeric
+ * self + other -> float or complex
*
- * Returns a new \Float which is the sum of +self+ and +other+:
+ * Returns the sum of +self+ and +other+;
+ * the result may be inexact (see Float):
*
- * f = 3.14
- * f + 1 # => 4.140000000000001
- * f + 1.0 # => 4.140000000000001
- * f + Rational(1, 1) # => 4.140000000000001
- * f + Complex(1, 0) # => (4.140000000000001+0i)
+ * 3.14 + 0 # => 3.14
+ * 3.14 + 1 # => 4.140000000000001
+ * -3.14 + 0 # => -3.14
+ * -3.14 + 1 # => -2.14
+
+ * 3.14 + -3.14 # => 0.0
+ * -3.14 + -3.14 # => -6.28
+ *
+ * 3.14 + Complex(1, 0) # => (4.140000000000001+0i)
+ * 3.14 + Rational(1, 1) # => 4.140000000000001
*
*/
@@ -1193,7 +1092,7 @@ rb_float_plus(VALUE x, VALUE y)
* call-seq:
* self - other -> numeric
*
- * Returns a new \Float which is the difference of +self+ and +other+:
+ * Returns the difference of +self+ and +other+:
*
* f = 3.14
* f - 1 # => 2.14
@@ -1224,13 +1123,14 @@ rb_float_minus(VALUE x, VALUE y)
* call-seq:
* self * other -> numeric
*
- * Returns a new \Float which is the product of +self+ and +other+:
+ * Returns the numeric product of +self+ and +other+:
*
* f = 3.14
* f * 2 # => 6.28
* f * 2.0 # => 6.28
* f * Rational(1, 2) # => 1.57
* f * Complex(2, 0) # => (6.28+0.0i)
+ *
*/
VALUE
@@ -1278,7 +1178,7 @@ rb_flo_div_flo(VALUE x, VALUE y)
* call-seq:
* self / other -> numeric
*
- * Returns a new \Float which is the result of dividing +self+ by +other+:
+ * Returns the quotient of +self+ and +other+:
*
* f = 3.14
* f / 2 # => 1.57
@@ -1387,7 +1287,7 @@ ruby_float_mod(double x, double y)
* call-seq:
* self % other -> float
*
- * Returns +self+ modulo +other+ as a float.
+ * Returns +self+ modulo +other+ as a \Float.
*
* For float +f+ and real number +r+, these expressions are equivalent:
*
@@ -1493,9 +1393,9 @@ flo_divmod(VALUE x, VALUE y)
/*
* call-seq:
- * self ** other -> numeric
+ * self ** exponent -> numeric
*
- * Raises +self+ to the power of +other+:
+ * Returns +self+ raised to the power +exponent+:
*
* f = 3.14
* f ** 2 # => 9.8596
@@ -1550,8 +1450,8 @@ rb_float_pow(VALUE x, VALUE y)
* 1.eql?(Rational(1, 1)) # => false
* 1.eql?(Complex(1, 0)) # => false
*
- * \Method +eql?+ is different from +==+ in that +eql?+ requires matching types,
- * while +==+ does not.
+ * Method +eql?+ is different from <tt>==</tt> in that +eql?+ requires matching types,
+ * while <tt>==</tt> does not.
*
*/
@@ -1571,10 +1471,17 @@ num_eql(VALUE x, VALUE y)
* call-seq:
* self <=> other -> zero or nil
*
- * Returns zero if +self+ is the same as +other+, +nil+ otherwise.
+ * Compares +self+ and +other+.
*
- * No subclass in the Ruby Core or Standard Library uses this implementation.
+ * Returns:
+ *
+ * - Zero, if +self+ is the same as +other+.
+ * - +nil+, otherwise.
+ *
+ * \Class \Numeric includes module Comparable,
+ * each of whose methods uses Numeric#<=> for comparison.
*
+ * No subclass in the Ruby Core or Standard Library uses this implementation.
*/
static VALUE
@@ -1597,7 +1504,7 @@ num_equal(VALUE x, VALUE y)
* call-seq:
* self == other -> true or false
*
- * Returns +true+ if +other+ has the same value as +self+, +false+ otherwise:
+ * Returns whether +other+ is numerically equal to +self+:
*
* 2.0 == 2 # => true
* 2.0 == 2.0 # => true
@@ -1620,17 +1527,11 @@ rb_float_equal(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(b)) return Qfalse;
-#endif
}
else {
return num_equal(x, y);
}
a = RFLOAT_VALUE(x);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a)) return Qfalse;
-#endif
return RBOOL(a == b);
}
@@ -1670,30 +1571,32 @@ rb_dbl_cmp(double a, double b)
/*
* call-seq:
- * self <=> other -> -1, 0, +1, or nil
+ * self <=> other -> -1, 0, 1, or nil
*
- * Returns a value that depends on the numeric relation
- * between +self+ and +other+:
+ * Compares +self+ and +other+.
+ *
+ * Returns:
*
- * - -1, if +self+ is less than +other+.
- * - 0, if +self+ is equal to +other+.
- * - 1, if +self+ is greater than +other+.
+ * - +-1+, if +self+ is less than +other+.
+ * - +0+, if +self+ is equal to +other+.
+ * - +1+, if +self+ is greater than +other+.
* - +nil+, if the two values are incommensurate.
*
* Examples:
*
+ * 2.0 <=> 2.1 # => -1
* 2.0 <=> 2 # => 0
- 2.0 <=> 2.0 # => 0
- 2.0 <=> Rational(2, 1) # => 0
- 2.0 <=> Complex(2, 0) # => 0
- 2.0 <=> 1.9 # => 1
- 2.0 <=> 2.1 # => -1
- 2.0 <=> 'foo' # => nil
- *
- * This is the basis for the tests in the Comparable module.
+ * 2.0 <=> 2.0 # => 0
+ * 2.0 <=> Rational(2, 1) # => 0
+ * 2.0 <=> Complex(2, 0) # => 0
+ * 2.0 <=> 1.9 # => 1
+ * 2.0 <=> 'foo' # => nil
*
* <tt>Float::NAN <=> Float::NAN</tt> returns an implementation-dependent value.
*
+ * \Class \Float includes module Comparable,
+ * each of whose methods uses Float#<=> for comparison.
+ *
*/
static VALUE
@@ -1738,7 +1641,8 @@ rb_float_cmp(VALUE x, VALUE y)
* call-seq:
* self > other -> true or false
*
- * Returns +true+ if +self+ is numerically greater than +other+:
+ * Returns whether the value of +self+ is greater than the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 2.0 > 1 # => true
* 2.0 > 1.0 # => true
@@ -1763,16 +1667,10 @@ rb_float_gt(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(b)) return Qfalse;
-#endif
}
else {
return rb_num_coerce_relop(x, y, '>');
}
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a)) return Qfalse;
-#endif
return RBOOL(a > b);
}
@@ -1780,7 +1678,8 @@ rb_float_gt(VALUE x, VALUE y)
* call-seq:
* self >= other -> true or false
*
- * Returns +true+ if +self+ is numerically greater than or equal to +other+:
+ * Returns whether the value of +self+ is greater than or equal to the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 2.0 >= 1 # => true
* 2.0 >= 1.0 # => true
@@ -1806,16 +1705,10 @@ flo_ge(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(b)) return Qfalse;
-#endif
}
else {
return rb_num_coerce_relop(x, y, idGE);
}
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a)) return Qfalse;
-#endif
return RBOOL(a >= b);
}
@@ -1823,7 +1716,8 @@ flo_ge(VALUE x, VALUE y)
* call-seq:
* self < other -> true or false
*
- * Returns +true+ if +self+ is numerically less than +other+:
+ * Returns whether the value of +self+ is less than the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 2.0 < 3 # => true
* 2.0 < 3.0 # => true
@@ -1831,7 +1725,6 @@ flo_ge(VALUE x, VALUE y)
* 2.0 < 2.0 # => false
*
* <tt>Float::NAN < Float::NAN</tt> returns an implementation-dependent value.
- *
*/
static VALUE
@@ -1848,16 +1741,10 @@ flo_lt(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(b)) return Qfalse;
-#endif
}
else {
return rb_num_coerce_relop(x, y, '<');
}
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a)) return Qfalse;
-#endif
return RBOOL(a < b);
}
@@ -1865,7 +1752,8 @@ flo_lt(VALUE x, VALUE y)
* call-seq:
* self <= other -> true or false
*
- * Returns +true+ if +self+ is numerically less than or equal to +other+:
+ * Returns whether the value of +self+ is less than or equal to the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 2.0 <= 3 # => true
* 2.0 <= 3.0 # => true
@@ -1891,16 +1779,10 @@ flo_le(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(b)) return Qfalse;
-#endif
}
else {
return rb_num_coerce_relop(x, y, idLE);
}
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a)) return Qfalse;
-#endif
return RBOOL(a <= b);
}
@@ -1928,10 +1810,7 @@ rb_float_eql(VALUE x, VALUE y)
if (RB_FLOAT_TYPE_P(y)) {
double a = RFLOAT_VALUE(x);
double b = RFLOAT_VALUE(y);
-#if MSC_VERSION_BEFORE(1300)
- if (isnan(a) || isnan(b)) return Qfalse;
-#endif
- return RBOOL(a == b);
+ return RBOOL(a == b);
}
return Qfalse;
}
@@ -2141,6 +2020,9 @@ rb_float_floor(VALUE num, int ndigits)
if (float_round_overflow(ndigits, binexp)) return num;
if (number > 0.0 && float_round_underflow(ndigits, binexp))
return DBL2NUM(0.0);
+ if (!ACCURATE_POW10(ndigits)) {
+ return rb_flo_floor_by_rational(num, ndigits);
+ }
f = pow(10, ndigits);
mul = floor(number * f);
res = (mul + 1) / f;
@@ -2165,36 +2047,78 @@ flo_ndigits(int argc, VALUE *argv)
}
/*
+ * :markup: markdown
+ *
* call-seq:
* floor(ndigits = 0) -> float or integer
*
- * Returns the largest number less than or equal to +self+ with
- * a precision of +ndigits+ decimal digits.
+ * Returns a float or integer that is a "floor" value for `self`,
+ * as specified by `ndigits`,
+ * which must be an
+ * [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
*
- * When +ndigits+ is positive, returns a float with +ndigits+
- * digits after the decimal point (as available):
+ * When `self` is zero,
+ * returns a zero value:
+ * a float if `ndigits` is positive,
+ * an integer otherwise:
*
- * f = 12345.6789
- * f.floor(1) # => 12345.6
- * f.floor(3) # => 12345.678
- * f = -12345.6789
- * f.floor(1) # => -12345.7
- * f.floor(3) # => -12345.679
+ * ```
+ * f = 0.0 # => 0.0
+ * f.floor(20) # => 0.0
+ * f.floor(0) # => 0
+ * f.floor(-20) # => 0
+ * ```
*
- * When +ndigits+ is non-positive, returns an integer with at least
- * <code>ndigits.abs</code> trailing zeros:
+ * When `self` is non-zero and `ndigits` is positive, returns a float with `ndigits`
+ * digits after the decimal point (as available):
*
- * f = 12345.6789
- * f.floor(0) # => 12345
- * f.floor(-3) # => 12000
- * f = -12345.6789
- * f.floor(0) # => -12346
- * f.floor(-3) # => -13000
+ * ```
+ * f = 12345.6789
+ * f.floor(1) # => 12345.6
+ * f.floor(3) # => 12345.678
+ * f.floor(30) # => 12345.6789
+ * f = -12345.6789
+ * f.floor(1) # => -12345.7
+ * f.floor(3) # => -12345.679
+ * f.floor(30) # => -12345.6789
+ * ```
+ *
+ * When `self` is non-zero and `ndigits` is non-positive,
+ * returns an integer value based on a computed granularity:
+ *
+ * - The granularity is `10 ** ndigits.abs`.
+ * - The returned value is the largest multiple of the granularity
+ * that is less than or equal to `self`.
+ *
+ * Examples with positive `self`:
+ *
+ * | ndigits | Granularity | 12345.6789.floor(ndigits) |
+ * |--------:|------------:|--------------------------:|
+ * | 0 | 1 | 12345 |
+ * | -1 | 10 | 12340 |
+ * | -2 | 100 | 12300 |
+ * | -3 | 1000 | 12000 |
+ * | -4 | 10000 | 10000 |
+ * | -5 | 100000 | 0 |
+ *
+ * Examples with negative `self`:
+ *
+ * | ndigits | Granularity | -12345.6789.floor(ndigits) |
+ * |--------:|------------:|---------------------------:|
+ * | 0 | 1 | -12346 |
+ * | -1 | 10 | -12350 |
+ * | -2 | 100 | -12400 |
+ * | -3 | 1000 | -13000 |
+ * | -4 | 10000 | -20000 |
+ * | -5 | 100000 | -100000 |
+ * | -6 | 1000000 | -1000000 |
*
* Note that the limited precision of floating-point arithmetic
* may lead to surprising results:
*
- * (0.3 / 0.1).floor #=> 2 (!)
+ * ```
+ * (0.3 / 0.1).floor # => 2 # Not 3, (because (0.3 / 0.1) # => 2.9999999999999996, not 3.0)
+ * ```
*
* Related: Float#ceil.
*
@@ -2208,36 +2132,78 @@ flo_floor(int argc, VALUE *argv, VALUE num)
}
/*
+ * :markup: markdown
+ *
* call-seq:
* ceil(ndigits = 0) -> float or integer
*
- * Returns the smallest number greater than or equal to +self+ with
- * a precision of +ndigits+ decimal digits.
- *
- * When +ndigits+ is positive, returns a float with +ndigits+
- * digits after the decimal point (as available):
- *
- * f = 12345.6789
- * f.ceil(1) # => 12345.7
- * f.ceil(3) # => 12345.679
- * f = -12345.6789
- * f.ceil(1) # => -12345.6
- * f.ceil(3) # => -12345.678
- *
- * When +ndigits+ is non-positive, returns an integer with at least
- * <code>ndigits.abs</code> trailing zeros:
- *
- * f = 12345.6789
- * f.ceil(0) # => 12346
- * f.ceil(-3) # => 13000
- * f = -12345.6789
- * f.ceil(0) # => -12345
- * f.ceil(-3) # => -12000
+ * Returns a numeric that is a "ceiling" value for `self`,
+ * as specified by the given `ndigits`,
+ * which must be an
+ * [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
+ *
+ * When `ndigits` is positive, returns a Float with `ndigits`
+ * decimal digits after the decimal point
+ * (as available, but no fewer than 1):
+ *
+ * ```
+ * f = 12345.6789
+ * f.ceil(1) # => 12345.7
+ * f.ceil(3) # => 12345.679
+ * f.ceil(30) # => 12345.6789
+ * f = -12345.6789
+ * f.ceil(1) # => -12345.6
+ * f.ceil(3) # => -12345.678
+ * f.ceil(30) # => -12345.6789
+ * f = 0.0
+ * f.ceil(1) # => 0.0
+ * f.ceil(100) # => 0.0
+ * ```
+ *
+ * When `ndigits` is non-positive,
+ * returns an Integer based on a computed granularity:
+ *
+ * - The granularity is `10 ** ndigits.abs`.
+ * - The returned value is the largest multiple of the granularity
+ * that is less than or equal to `self`.
+ *
+ * Examples with positive `self`:
+ *
+ * | ndigits | Granularity | 12345.6789.ceil(ndigits) |
+ * |--------:|------------:|-------------------------:|
+ * | 0 | 1 | 12346 |
+ * | -1 | 10 | 12350 |
+ * | -2 | 100 | 12400 |
+ * | -3 | 1000 | 13000 |
+ * | -4 | 10000 | 20000 |
+ * | -5 | 100000 | 100000 |
+ *
+ * Examples with negative `self`:
+ *
+ * | ndigits | Granularity | -12345.6789.ceil(ndigits) |
+ * |--------:|------------:|--------------------------:|
+ * | 0 | 1 | -12345 |
+ * | -1 | 10 | -12340 |
+ * | -2 | 100 | -12300 |
+ * | -3 | 1000 | -12000 |
+ * | -4 | 10000 | -10000 |
+ * | -5 | 100000 | 0 |
+ *
+ * When `self` is zero and `ndigits` is non-positive,
+ * returns Integer zero:
+ *
+ * ```
+ * 0.0.ceil(0) # => 0
+ * 0.0.ceil(-1) # => 0
+ * 0.0.ceil(-2) # => 0
+ * ```
*
* Note that the limited precision of floating-point arithmetic
* may lead to surprising results:
*
- * (2.1 / 0.7).ceil #=> 4 (!)
+ * ```
+ * (2.1 / 0.7).ceil #=> 4 # Not 3 (because 2.1 / 0.7 # => 3.0000000000000004, not 3.0)
+ * ```
*
* Related: Float#floor.
*
@@ -2265,6 +2231,9 @@ rb_float_ceil(VALUE num, int ndigits)
if (float_round_overflow(ndigits, binexp)) return num;
if (number < 0.0 && float_round_underflow(ndigits, binexp))
return DBL2NUM(0.0);
+ if (!ACCURATE_POW10(ndigits)) {
+ return rb_flo_ceil_by_rational(num, ndigits);
+ }
f = pow(10, ndigits);
f = ceil(number * f) / f;
return DBL2NUM(f);
@@ -2335,7 +2304,7 @@ int_half_p_half_down(VALUE num, VALUE n, VALUE f)
}
/*
- * Assumes num is an Integer, ndigits <= 0
+ * Assumes num is an \Integer, ndigits <= 0
*/
static VALUE
rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode)
@@ -2373,11 +2342,7 @@ rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode)
static VALUE
rb_int_floor(VALUE num, int ndigits)
{
- VALUE f;
-
- if (int_round_zero_p(num, ndigits))
- return INT2FIX(0);
- f = int_pow(10, -ndigits);
+ VALUE f = int_pow(10, -ndigits);
if (FIXNUM_P(num) && FIXNUM_P(f)) {
SIGNED_VALUE x = FIX2LONG(num), y = FIX2LONG(f);
int neg = x < 0;
@@ -2386,21 +2351,19 @@ rb_int_floor(VALUE num, int ndigits)
if (neg) x = -x;
return LONG2NUM(x);
}
- if (RB_FLOAT_TYPE_P(f)) {
- /* then int_pow overflow */
- return INT2FIX(0);
+ else {
+ bool neg = int_neg_p(num);
+ if (neg) num = rb_int_minus(rb_int_plus(rb_int_uminus(num), f), INT2FIX(1));
+ num = rb_int_mul(rb_int_div(num, f), f);
+ if (neg) num = rb_int_uminus(num);
+ return num;
}
- return rb_int_minus(num, rb_int_modulo(num, f));
}
static VALUE
rb_int_ceil(VALUE num, int ndigits)
{
- VALUE f;
-
- if (int_round_zero_p(num, ndigits))
- return INT2FIX(0);
- f = int_pow(10, -ndigits);
+ VALUE f = int_pow(10, -ndigits);
if (FIXNUM_P(num) && FIXNUM_P(f)) {
SIGNED_VALUE x = FIX2LONG(num), y = FIX2LONG(f);
int neg = x < 0;
@@ -2410,11 +2373,16 @@ rb_int_ceil(VALUE num, int ndigits)
if (neg) x = -x;
return LONG2NUM(x);
}
- if (RB_FLOAT_TYPE_P(f)) {
- /* then int_pow overflow */
- return INT2FIX(0);
+ else {
+ bool neg = int_neg_p(num);
+ if (neg)
+ num = rb_int_uminus(num);
+ else
+ num = rb_int_plus(num, rb_int_minus(f, INT2FIX(1)));
+ num = rb_int_mul(rb_int_div(num, f), f);
+ if (neg) num = rb_int_uminus(num);
+ return num;
}
- return rb_int_plus(num, rb_int_minus(f, rb_int_modulo(num, f)));
}
VALUE
@@ -2449,7 +2417,7 @@ rb_int_truncate(VALUE num, int ndigits)
/*
* call-seq:
- * round(ndigits = 0, half: :up]) -> integer or float
+ * round(ndigits = 0, half: :up) -> integer or float
*
* Returns +self+ rounded to the nearest value with
* a precision of +ndigits+ decimal digits.
@@ -2530,9 +2498,8 @@ flo_round(int argc, VALUE *argv, VALUE num)
frexp(number, &binexp);
if (float_round_overflow(ndigits, binexp)) return num;
if (float_round_underflow(ndigits, binexp)) return DBL2NUM(0);
- if (ndigits > 14) {
- /* In this case, pow(10, ndigits) may not be accurate. */
- return rb_flo_round_by_rational(argc, argv, num);
+ if (!ACCURATE_POW10(ndigits)) {
+ return rb_flo_round_by_rational(num, ndigits, mode);
}
f = pow(10, ndigits);
x = ROUND_CALL(mode, round, (number, f));
@@ -2605,6 +2572,12 @@ flo_to_i(VALUE num)
return dbl2ival(f);
}
+VALUE
+rb_flo_to_i(VALUE num)
+{
+ return flo_to_i(num);
+}
+
/*
* call-seq:
* truncate(ndigits = 0) -> float or integer
@@ -2651,13 +2624,16 @@ flo_truncate(int argc, VALUE *argv, VALUE num)
/*
* call-seq:
- * floor(digits = 0) -> integer or float
+ * floor(ndigits = 0) -> float or integer
*
- * Returns the largest number that is less than or equal to +self+ with
- * a precision of +digits+ decimal digits.
+ * Returns the largest float or integer that is less than or equal to +self+,
+ * as specified by the given +ndigits+,
+ * which must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
*
- * \Numeric implements this by converting +self+ to a Float and
- * invoking Float#floor.
+ * Equivalent to <tt>self.to_f.floor(ndigits)</tt>.
+ *
+ * Related: #ceil, Float#floor.
*/
static VALUE
@@ -2668,13 +2644,16 @@ num_floor(int argc, VALUE *argv, VALUE num)
/*
* call-seq:
- * ceil(digits = 0) -> integer or float
+ * ceil(ndigits = 0) -> float or integer
*
- * Returns the smallest number that is greater than or equal to +self+ with
- * a precision of +digits+ decimal digits.
+ * Returns the smallest float or integer that is greater than or equal to +self+,
+ * as specified by the given +ndigits+,
+ * which must be an
+ * {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].
*
- * \Numeric implements this by converting +self+ to a Float and
- * invoking Float#ceil.
+ * Equivalent to <tt>self.to_f.ceil(ndigits)</tt>.
+ *
+ * Related: #floor, Float#ceil.
*/
static VALUE
@@ -2834,7 +2813,7 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
}
if (RTEST(rb_funcall(from, cmp, 1, to))) return INT2FIX(0);
result = rb_funcall(rb_funcall(to, '-', 1, from), id_div, 1, step);
- if (!excl || RTEST(rb_funcall(rb_funcall(from, '+', 1, rb_funcall(result, '*', 1, step)), cmp, 1, to))) {
+ if (!excl || RTEST(rb_funcall(to, cmp, 1, rb_funcall(from, '+', 1, rb_funcall(result, '*', 1, step))))) {
result = rb_funcall(result, '+', 1, INT2FIX(1));
}
return result;
@@ -2946,88 +2925,88 @@ num_step_size(VALUE from, VALUE args, VALUE eobj)
* step(by: , to: nil) {|n| ... } -> self
* step(by: , to: nil) -> enumerator
*
- * Generates a sequence of numbers; with a block given, traverses the sequence.
+ * Generates a sequence of numbers; with a block given, traverses the sequence.
*
- * Of the Core and Standard Library classes,
- * Integer, Float, and Rational use this implementation.
- *
- * A quick example:
- *
- * squares = []
- * 1.step(by: 2, to: 10) {|i| squares.push(i*i) }
- * squares # => [1, 9, 25, 49, 81]
- *
- * The generated sequence:
- *
- * - Begins with +self+.
- * - Continues at intervals of +step+ (which may not be zero).
- * - Ends with the last number that is within or equal to +limit+;
- * that is, less than or equal to +limit+ if +step+ is positive,
- * greater than or equal to +limit+ if +step+ is negative.
- * If +limit+ is not given, the sequence is of infinite length.
- *
- * If a block is given, calls the block with each number in the sequence;
- * returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence.
- *
- * <b>Keyword Arguments</b>
- *
- * With keyword arguments +by+ and +to+,
- * their values (or defaults) determine the step and limit:
- *
- * # Both keywords given.
- * squares = []
- * 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4
- * squares # => [16, 36, 64, 100]
- * cubes = []
- * 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3
- * cubes # => [27.0, 3.375, 0.0, -3.375, -27.0]
- * squares = []
- * 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) }
- * squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
- *
- * squares = []
- * Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) }
- * squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
- *
- * # Only keyword to given.
- * squares = []
- * 4.step(to: 10) {|i| squares.push(i*i) } # => 4
- * squares # => [16, 25, 36, 49, 64, 81, 100]
- * # Only by given.
- *
- * # Only keyword by given
- * squares = []
- * 4.step(by:2) {|i| squares.push(i*i); break if i > 10 }
- * squares # => [16, 36, 64, 100, 144]
- *
- * # No block given.
- * e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3))
- * e.class # => Enumerator::ArithmeticSequence
- *
- * <b>Positional Arguments</b>
- *
- * With optional positional arguments +limit+ and +step+,
- * their values (or defaults) determine the step and limit:
- *
- * squares = []
- * 4.step(10, 2) {|i| squares.push(i*i) } # => 4
- * squares # => [16, 36, 64, 100]
- * squares = []
- * 4.step(10) {|i| squares.push(i*i) }
- * squares # => [16, 25, 36, 49, 64, 81, 100]
- * squares = []
- * 4.step {|i| squares.push(i*i); break if i > 10 } # => nil
- * squares # => [16, 25, 36, 49, 64, 81, 100, 121]
+ * Of the Core and Standard Library classes,
+ * Integer, Float, and Rational use this implementation.
+ *
+ * A quick example:
+ *
+ * squares = []
+ * 1.step(by: 2, to: 10) {|i| squares.push(i*i) }
+ * squares # => [1, 9, 25, 49, 81]
+ *
+ * The generated sequence:
+ *
+ * - Begins with +self+.
+ * - Continues at intervals of +by+ (which may not be zero).
+ * - Ends with the last number that is within or equal to +to+;
+ * that is, less than or equal to +to+ if +by+ is positive,
+ * greater than or equal to +to+ if +by+ is negative.
+ * If +to+ is +nil+, the sequence is of infinite length.
+ *
+ * If a block is given, calls the block with each number in the sequence;
+ * returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence.
+ *
+ * <b>Keyword Arguments</b>
+ *
+ * With keyword arguments +by+ and +to+,
+ * their values (or defaults) determine the step and limit:
+ *
+ * # Both keywords given.
+ * squares = []
+ * 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4
+ * squares # => [16, 36, 64, 100]
+ * cubes = []
+ * 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3
+ * cubes # => [27.0, 3.375, 0.0, -3.375, -27.0]
+ * squares = []
+ * 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) }
+ * squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
+ *
+ * squares = []
+ * Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) }
+ * squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
+ *
+ * # Only keyword to given.
+ * squares = []
+ * 4.step(to: 10) {|i| squares.push(i*i) } # => 4
+ * squares # => [16, 25, 36, 49, 64, 81, 100]
+ * # Only by given.
+ *
+ * # Only keyword by given
+ * squares = []
+ * 4.step(by:2) {|i| squares.push(i*i); break if i > 10 }
+ * squares # => [16, 36, 64, 100, 144]
+ *
+ * # No block given.
+ * e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3))
+ * e.class # => Enumerator::ArithmeticSequence
+ *
+ * <b>Positional Arguments</b>
+ *
+ * With optional positional arguments +to+ and +by+,
+ * their values (or defaults) determine the step and limit:
+ *
+ * squares = []
+ * 4.step(10, 2) {|i| squares.push(i*i) } # => 4
+ * squares # => [16, 36, 64, 100]
+ * squares = []
+ * 4.step(10) {|i| squares.push(i*i) }
+ * squares # => [16, 25, 36, 49, 64, 81, 100]
+ * squares = []
+ * 4.step {|i| squares.push(i*i); break if i > 10 } # => nil
+ * squares # => [16, 25, 36, 49, 64, 81, 100, 121]
*
* <b>Implementation Notes</b>
*
- * If all the arguments are integers, the loop operates using an integer
- * counter.
+ * If all the arguments are integers, the loop operates using an integer
+ * counter.
*
- * If any of the arguments are floating point numbers, all are converted
- * to floats, and the loop is executed
- * <i>floor(n + n*Float::EPSILON) + 1</i> times,
- * where <i>n = (limit - self)/step</i>.
+ * If any of the arguments are floating point numbers, all are converted
+ * to floats, and the loop is executed
+ * <i>floor(n + n*Float::EPSILON) + 1</i> times,
+ * where <i>n = (limit - self)/step</i>.
*
*/
@@ -3137,7 +3116,7 @@ rb_num2long(VALUE val)
{
again:
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
+ rb_no_implicit_conversion(val, "Integer");
}
if (FIXNUM_P(val)) return FIX2LONG(val);
@@ -3165,7 +3144,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
{
again:
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
+ rb_no_implicit_conversion(val, "Integer");
}
if (FIXNUM_P(val)) {
@@ -3210,7 +3189,7 @@ rb_num2ulong(VALUE val)
void
rb_out_of_int(SIGNED_VALUE num)
{
- rb_raise(rb_eRangeError, "integer %"PRIdVALUE " too %s to convert to `int'",
+ rb_raise(rb_eRangeError, "integer %"PRIdVALUE " too %s to convert to 'int'",
num, num < 0 ? "small" : "big");
}
@@ -3229,12 +3208,12 @@ check_uint(unsigned long num, int sign)
if (sign) {
/* minus */
if (num < (unsigned long)INT_MIN)
- rb_raise(rb_eRangeError, "integer %ld too small to convert to `unsigned int'", (long)num);
+ rb_raise(rb_eRangeError, "integer %ld too small to convert to 'unsigned int'", (long)num);
}
else {
/* plus */
if (UINT_MAX < num)
- rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num);
+ rb_raise(rb_eRangeError, "integer %lu too big to convert to 'unsigned int'", num);
}
}
@@ -3309,7 +3288,7 @@ NORETURN(static void rb_out_of_short(SIGNED_VALUE num));
static void
rb_out_of_short(SIGNED_VALUE num)
{
- rb_raise(rb_eRangeError, "integer %"PRIdVALUE " too %s to convert to `short'",
+ rb_raise(rb_eRangeError, "integer %"PRIdVALUE " too %s to convert to 'short'",
num, num < 0 ? "small" : "big");
}
@@ -3327,12 +3306,12 @@ check_ushort(unsigned long num, int sign)
if (sign) {
/* minus */
if (num < (unsigned long)SHRT_MIN)
- rb_raise(rb_eRangeError, "integer %ld too small to convert to `unsigned short'", (long)num);
+ rb_raise(rb_eRangeError, "integer %ld too small to convert to 'unsigned short'", (long)num);
}
else {
/* plus */
if (USHRT_MAX < num)
- rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned short'", num);
+ rb_raise(rb_eRangeError, "integer %lu too big to convert to 'unsigned short'", num);
}
}
@@ -3408,7 +3387,7 @@ LONG_LONG
rb_num2ll(VALUE val)
{
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil");
+ rb_no_implicit_conversion(val, "Integer");
}
if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
@@ -3425,11 +3404,8 @@ rb_num2ll(VALUE val)
else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ll(val);
}
- else if (RB_TYPE_P(val, T_STRING)) {
- rb_raise(rb_eTypeError, "no implicit conversion from string");
- }
- else if (RB_TYPE_P(val, T_TRUE) || RB_TYPE_P(val, T_FALSE)) {
- rb_raise(rb_eTypeError, "no implicit conversion from boolean");
+ else if (val == Qfalse || val == Qtrue || RB_TYPE_P(val, T_STRING)) {
+ rb_no_implicit_conversion(val, "Integer");
}
val = rb_to_int(val);
@@ -3440,7 +3416,7 @@ unsigned LONG_LONG
rb_num2ull(VALUE val)
{
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil");
+ rb_no_implicit_conversion(val, "Integer");
}
else if (FIXNUM_P(val)) {
return (LONG_LONG)FIX2LONG(val); /* this is FIX2LONG, intended */
@@ -3459,18 +3435,239 @@ rb_num2ull(VALUE val)
else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ull(val);
}
- else if (RB_TYPE_P(val, T_STRING)) {
- rb_raise(rb_eTypeError, "no implicit conversion from string");
+ else {
+ val = rb_to_int(val);
+ return NUM2ULL(val);
}
- else if (RB_TYPE_P(val, T_TRUE) || RB_TYPE_P(val, T_FALSE)) {
- rb_raise(rb_eTypeError, "no implicit conversion from boolean");
+}
+
+#endif /* HAVE_LONG_LONG */
+
+// Conversion functions for unified 128-bit integer structures,
+// These work with or without native 128-bit integer support.
+
+#ifndef HAVE_UINT128_T
+// Helper function to build 128-bit value from bignum digits (fallback path).
+static inline void
+rb_uint128_from_bignum_digits_fallback(rb_uint128_t *result, BDIGIT *digits, size_t length)
+{
+ // Build the 128-bit value from bignum digits:
+ for (long i = length - 1; i >= 0; i--) {
+ // Shift both low and high parts:
+ uint64_t carry = result->parts.low >> (64 - (SIZEOF_BDIGIT * CHAR_BIT));
+ result->parts.low = (result->parts.low << (SIZEOF_BDIGIT * CHAR_BIT)) | digits[i];
+ result->parts.high = (result->parts.high << (SIZEOF_BDIGIT * CHAR_BIT)) | carry;
}
+}
- val = rb_to_int(val);
- return NUM2ULL(val);
+// Helper function to convert absolute value of negative bignum to two's complement.
+// Ruby stores negative bignums as absolute values, so we need to convert to two's complement.
+static inline void
+rb_uint128_twos_complement_negate(rb_uint128_t *value)
+{
+ if (value->parts.low == 0) {
+ value->parts.high = ~value->parts.high + 1;
+ }
+ else {
+ value->parts.low = ~value->parts.low + 1;
+ value->parts.high = ~value->parts.high + (value->parts.low == 0 ? 1 : 0);
+ }
}
+#endif
-#endif /* HAVE_LONG_LONG */
+rb_uint128_t
+rb_numeric_to_uint128(VALUE x)
+{
+ rb_uint128_t result = {0};
+ if (RB_FIXNUM_P(x)) {
+ long value = RB_FIX2LONG(x);
+ if (value < 0) {
+ rb_raise(rb_eRangeError, "negative integer cannot be converted to unsigned 128-bit integer");
+ }
+#ifdef HAVE_UINT128_T
+ result.value = (uint128_t)value;
+#else
+ result.parts.low = (uint64_t)value;
+ result.parts.high = 0;
+#endif
+ return result;
+ }
+ else if (RB_BIGNUM_TYPE_P(x)) {
+ if (BIGNUM_NEGATIVE_P(x)) {
+ rb_raise(rb_eRangeError, "negative integer cannot be converted to unsigned 128-bit integer");
+ }
+ size_t length = BIGNUM_LEN(x);
+#ifdef HAVE_UINT128_T
+ if (length > roomof(SIZEOF_INT128_T, SIZEOF_BDIGIT)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'unsigned 128-bit integer'");
+ }
+ BDIGIT *digits = BIGNUM_DIGITS(x);
+ result.value = 0;
+ for (long i = length - 1; i >= 0; i--) {
+ result.value = (result.value << (SIZEOF_BDIGIT * CHAR_BIT)) | digits[i];
+ }
+#else
+ // Check if bignum fits in 128 bits (16 bytes)
+ if (length > roomof(16, SIZEOF_BDIGIT)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'unsigned 128-bit integer'");
+ }
+ BDIGIT *digits = BIGNUM_DIGITS(x);
+ rb_uint128_from_bignum_digits_fallback(&result, digits, length);
+#endif
+ return result;
+ }
+ else {
+ rb_raise(rb_eTypeError, "not an integer");
+ }
+}
+
+rb_int128_t
+rb_numeric_to_int128(VALUE x)
+{
+ rb_int128_t result = {0};
+ if (RB_FIXNUM_P(x)) {
+ long value = RB_FIX2LONG(x);
+#ifdef HAVE_UINT128_T
+ result.value = (int128_t)value;
+#else
+ if (value < 0) {
+ // Two's complement representation: for negative values, sign extend
+ // Convert to unsigned: for -1, we want all bits set
+ result.parts.low = (uint64_t)value; // This will be the two's complement representation
+ result.parts.high = UINT64_MAX; // Sign extend: all bits set for negative
+ }
+ else {
+ result.parts.low = (uint64_t)value;
+ result.parts.high = 0;
+ }
+#endif
+ return result;
+ }
+ else if (RB_BIGNUM_TYPE_P(x)) {
+ size_t length = BIGNUM_LEN(x);
+#ifdef HAVE_UINT128_T
+ if (length > roomof(SIZEOF_INT128_T, SIZEOF_BDIGIT)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ BDIGIT *digits = BIGNUM_DIGITS(x);
+ uint128_t unsigned_result = 0;
+ for (long i = length - 1; i >= 0; i--) {
+ unsigned_result = (unsigned_result << (SIZEOF_BDIGIT * CHAR_BIT)) | digits[i];
+ }
+ if (BIGNUM_NEGATIVE_P(x)) {
+ // Convert from two's complement
+ // Maximum negative value is 2^127
+ if (unsigned_result > ((uint128_t)1 << 127)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ result.value = -(int128_t)(unsigned_result - 1) - 1;
+ }
+ else {
+ // Maximum positive value is 2^127 - 1
+ if (unsigned_result > (((uint128_t)1 << 127) - 1)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ result.value = (int128_t)unsigned_result;
+ }
+#else
+ if (length > roomof(16, SIZEOF_BDIGIT)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ BDIGIT *digits = BIGNUM_DIGITS(x);
+ rb_uint128_t unsigned_result = {0};
+ rb_uint128_from_bignum_digits_fallback(&unsigned_result, digits, length);
+ if (BIGNUM_NEGATIVE_P(x)) {
+ // Check if value fits in signed 128-bit (max negative is 2^127)
+ uint64_t max_neg_high = (uint64_t)1 << 63;
+ if (unsigned_result.parts.high > max_neg_high || (unsigned_result.parts.high == max_neg_high && unsigned_result.parts.low > 0)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ // Convert from absolute value to two's complement (Ruby stores negative as absolute value)
+ rb_uint128_twos_complement_negate(&unsigned_result);
+ result.parts.low = unsigned_result.parts.low;
+ result.parts.high = (int64_t)unsigned_result.parts.high; // Sign extend
+ }
+ else {
+ // Check if value fits in signed 128-bit (max positive is 2^127 - 1)
+ // Max positive: high = 0x7FFFFFFFFFFFFFFF, low = 0xFFFFFFFFFFFFFFFF
+ uint64_t max_pos_high = ((uint64_t)1 << 63) - 1;
+ if (unsigned_result.parts.high > max_pos_high) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into 'signed 128-bit integer'");
+ }
+ result.parts.low = unsigned_result.parts.low;
+ result.parts.high = unsigned_result.parts.high;
+ }
+#endif
+ return result;
+ }
+ else {
+ rb_raise(rb_eTypeError, "not an integer");
+ }
+}
+
+VALUE
+rb_uint128_to_numeric(rb_uint128_t n)
+{
+#ifdef HAVE_UINT128_T
+ if (n.value <= (uint128_t)RUBY_FIXNUM_MAX) {
+ return LONG2FIX((long)n.value);
+ }
+ return rb_uint128t2big(n.value);
+#else
+ // If high part is zero and low part fits in fixnum
+ if (n.parts.high == 0 && n.parts.low <= (uint64_t)RUBY_FIXNUM_MAX) {
+ return LONG2FIX((long)n.parts.low);
+ }
+ // Convert to bignum by building it from the two 64-bit parts
+ VALUE bignum = rb_ull2big(n.parts.low);
+ if (n.parts.high > 0) {
+ VALUE high_bignum = rb_ull2big(n.parts.high);
+ // Multiply high part by 2^64 and add to low part
+ VALUE shifted_value = rb_int_lshift(high_bignum, INT2FIX(64));
+ bignum = rb_int_plus(bignum, shifted_value);
+ }
+ return bignum;
+#endif
+}
+
+VALUE
+rb_int128_to_numeric(rb_int128_t n)
+{
+#ifdef HAVE_UINT128_T
+ if (FIXABLE(n.value)) {
+ return LONG2FIX((long)n.value);
+ }
+ return rb_int128t2big(n.value);
+#else
+ int64_t high = (int64_t)n.parts.high;
+ // If it's a small positive value that fits in fixnum
+ if (high == 0 && n.parts.low <= (uint64_t)RUBY_FIXNUM_MAX) {
+ return LONG2FIX((long)n.parts.low);
+ }
+ // Check if it's negative (high bit of high part is set)
+ if (high < 0) {
+ // Negative value - convert from two's complement to absolute value
+ rb_uint128_t unsigned_value = {0};
+ if (n.parts.low == 0) {
+ unsigned_value.parts.low = 0;
+ unsigned_value.parts.high = ~n.parts.high + 1;
+ }
+ else {
+ unsigned_value.parts.low = ~n.parts.low + 1;
+ unsigned_value.parts.high = ~n.parts.high + (unsigned_value.parts.low == 0 ? 1 : 0);
+ }
+ VALUE bignum = rb_uint128_to_numeric(unsigned_value);
+ return rb_int_uminus(bignum);
+ }
+ else {
+ // Positive value
+ union uint128_int128_conversion conversion = {
+ .int128 = n
+ };
+ return rb_uint128_to_numeric(conversion.uint128);
+ }
+#endif
+}
/********************************************************************
*
@@ -3484,16 +3681,19 @@ rb_num2ull(VALUE val)
*
* You can convert certain objects to Integers with:
*
- * - \Method #Integer.
+ * - Method #Integer.
*
* An attempt to add a singleton method to an instance of this class
* causes an exception to be raised.
*
* == What's Here
*
- * First, what's elsewhere. \Class \Integer:
+ * First, what's elsewhere. Class \Integer:
*
- * - Inherits from {class Numeric}[rdoc-ref:Numeric@What-27s+Here].
+ * - Inherits from
+ * {class Numeric}[rdoc-ref:Numeric@Whats+Here]
+ * and {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Includes {module Comparable}[rdoc-ref:Comparable@Whats+Here].
*
* Here, class \Integer provides methods for:
*
@@ -3534,6 +3734,7 @@ rb_num2ull(VALUE val)
* - #>>: Returns the value of +self+ after a rightward bit-shift.
* - #[]: Returns a slice of bits from +self+.
* - #^: Returns the bitwise EXCLUSIVE OR of +self+ and the given value.
+ * - #|: Returns the bitwise OR of +self+ and the given value.
* - #ceil: Returns the smallest number greater than or equal to +self+.
* - #chr: Returns a 1-character string containing the character
* represented by the value of +self+.
@@ -3553,7 +3754,6 @@ rb_num2ull(VALUE val)
* - #to_s (aliased as #inspect): Returns a string containing the place-value
* representation of +self+ in the given radix.
* - #truncate: Returns +self+ truncated to the given precision.
- * - #|: Returns the bitwise OR of +self+ and the given value.
*
* === Other
*
@@ -3573,7 +3773,7 @@ rb_int_odd_p(VALUE num)
return RBOOL(num & 2);
}
else {
- assert(RB_BIGNUM_TYPE_P(num));
+ RUBY_ASSERT(RB_BIGNUM_TYPE_P(num));
return rb_big_odd_p(num);
}
}
@@ -3585,7 +3785,7 @@ int_even_p(VALUE num)
return RBOOL((num & 2) == 0);
}
else {
- assert(RB_BIGNUM_TYPE_P(num));
+ RUBY_ASSERT(RB_BIGNUM_TYPE_P(num));
return rb_big_even_p(num);
}
}
@@ -3842,11 +4042,16 @@ rb_int_uminus(VALUE num)
return fix_uminus(num);
}
else {
- assert(RB_BIGNUM_TYPE_P(num));
+ RUBY_ASSERT(RB_BIGNUM_TYPE_P(num));
return rb_big_uminus(num);
}
}
+/* ruby_decimal_digit_pairs is defined in bignum.c and declared in
+ * internal/bignum.h. See there for the rationale of the 2-digit
+ * lookup-table itoa optimisation; both rb_fix2str here and big2str_2bdigits
+ * in bignum.c consume it. */
+
VALUE
rb_fix2str(VALUE x, int base)
{
@@ -3879,9 +4084,34 @@ rb_fix2str(VALUE x, int base)
else {
u = val;
}
- do {
- *--b = ruby_digitmap[(int)(u % base)];
- } while (u /= base);
+ if (base == 10) {
+ /* Emit two digits per iteration from a precomputed table. The
+ * compiler lowers `u % 100` and `u / 100` to a single multiply +
+ * shift, so each iteration costs roughly one multiply, one shift,
+ * and two stores. About 2x fewer iterations than the classic
+ * per-digit loop for multi-digit inputs. */
+ while (u >= 100) {
+ unsigned long idx = (u % 100) * 2;
+ u /= 100;
+ b -= 2;
+ b[0] = ruby_decimal_digit_pairs[idx];
+ b[1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ if (u >= 10) {
+ unsigned long idx = u * 2;
+ b -= 2;
+ b[0] = ruby_decimal_digit_pairs[idx];
+ b[1] = ruby_decimal_digit_pairs[idx + 1];
+ }
+ else {
+ *--b = (char)('0' + u);
+ }
+ }
+ else {
+ do {
+ *--b = ruby_digitmap[(int)(u % base)];
+ } while (u /= base);
+ }
if (neg) {
*--b = '-';
}
@@ -3972,17 +4202,20 @@ rb_fix_plus(VALUE x, VALUE y)
/*
* call-seq:
- * self + numeric -> numeric_result
+ * self + other -> numeric
*
- * Performs addition:
+ * Returns the sum of +self+ and +other+:
*
- * 2 + 2 # => 4
- * -2 + 2 # => 0
- * -2 + -2 # => -4
- * 2 + 2.0 # => 4.0
- * 2 + Rational(2, 1) # => (4/1)
- * 2 + Complex(2, 0) # => (4+0i)
+ * 1 + 1 # => 2
+ * 1 + -1 # => 0
+ * 1 + 0 # => 1
+ * 1 + -2 # => -1
+ * 1 + Complex(1, 0) # => (2+0i)
+ * 1 + Rational(1, 1) # => (2/1)
*
+ * For a computation involving Floats, the result may be inexact (see Float#+):
+ *
+ * 1 + 3.14 # => 4.140000000000001
*/
VALUE
@@ -4017,9 +4250,9 @@ fix_minus(VALUE x, VALUE y)
/*
* call-seq:
- * self - numeric -> numeric_result
+ * self - other -> numeric
*
- * Performs subtraction:
+ * Returns the difference of +self+ and +other+:
*
* 4 - 2 # => 2
* -4 - 2 # => -6
@@ -4073,16 +4306,17 @@ fix_mul(VALUE x, VALUE y)
/*
* call-seq:
- * self * numeric -> numeric_result
+ * self * other -> numeric
*
- * Performs multiplication:
+ * Returns the numeric product of +self+ and +other+:
*
* 4 * 2 # => 8
- * 4 * -2 # => -8
* -4 * 2 # => -8
+ * 4 * -2 # => -8
* 4 * 2.0 # => 8.0
* 4 * Rational(1, 3) # => (4/3)
* 4 * Complex(2, 0) # => (8+0i)
+ *
*/
VALUE
@@ -4097,11 +4331,25 @@ rb_int_mul(VALUE x, VALUE y)
return rb_num_coerce_bin(x, y, '*');
}
+static bool
+accurate_in_double(long i)
+{
+#if SIZEOF_LONG * CHAR_BIT > DBL_MANT_DIG
+ return ((i < 0 ? -i : i) < (1L << DBL_MANT_DIG));
+#else
+ return true;
+#endif
+}
+
static double
fix_fdiv_double(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
- return double_div_double(FIX2LONG(x), FIX2LONG(y));
+ long iy = FIX2LONG(y);
+ if (!accurate_in_double(iy)) {
+ return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), rb_int2big(iy));
+ }
+ return double_div_double(FIX2LONG(x), iy);
}
else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), y);
@@ -4114,12 +4362,31 @@ fix_fdiv_double(VALUE x, VALUE y)
}
}
+static bool
+int_accurate_in_double(VALUE n)
+{
+ if (FIXNUM_P(n)) {
+ return accurate_in_double(FIX2LONG(n));
+ }
+ RUBY_ASSERT(RB_TYPE_P(n, T_BIGNUM));
+#if SIZEOF_LONG * CHAR_BIT <= DBL_MANT_DIG
+ int nlz;
+ size_t size = rb_absint_size(n, &nlz);
+ const size_t mant_size = roomof(DBL_MANT_DIG, CHAR_BIT);
+ if (size < mant_size) return true;
+ if (size > mant_size) return false;
+ if ((size_t)nlz >= (CHAR_BIT * mant_size - DBL_MANT_DIG)) return true;
+#endif
+ return false;
+}
+
double
rb_int_fdiv_double(VALUE x, VALUE y)
{
- if (RB_INTEGER_TYPE_P(y) && !FIXNUM_ZERO_P(y)) {
+ if (RB_INTEGER_TYPE_P(y) && !FIXNUM_ZERO_P(y) &&
+ !(int_accurate_in_double(x) && int_accurate_in_double(y))) {
VALUE gcd = rb_gcd(x, y);
- if (!FIXNUM_ZERO_P(gcd)) {
+ if (!FIXNUM_ZERO_P(gcd) && gcd != INT2FIX(1)) {
x = rb_int_idiv(x, gcd);
y = rb_int_idiv(y, gcd);
}
@@ -4199,16 +4466,18 @@ fix_div(VALUE x, VALUE y)
/*
* call-seq:
- * self / numeric -> numeric_result
+ * self / other -> numeric
+ *
+ * Returns the quotient of +self+ and +other+.
*
- * Performs division; for integer +numeric+, truncates the result to an integer:
+ * For integer +other+, truncates the result to an integer:
*
* 4 / 3 # => 1
* 4 / -3 # => -2
* -4 / 3 # => -2
* -4 / -3 # => 1
*
- * For other +numeric+, returns non-integer result:
+ * For non-integer +other+, returns a non-integer result:
*
* 4 / 3.0 # => 1.3333333333333333
* 4 / Rational(3, 1) # => (4/3)
@@ -4241,14 +4510,14 @@ fix_idiv(VALUE x, VALUE y)
* Performs integer division; returns the integer result of dividing +self+
* by +numeric+:
*
- * 4.div(3) # => 1
- * 4.div(-3) # => -2
- * -4.div(3) # => -2
- * -4.div(-3) # => 1
- * 4.div(3.0) # => 1
- * 4.div(Rational(3, 1)) # => 1
+ * 4.div(3) # => 1
+ * 4.div(-3) # => -2
+ * -4.div(3) # => -2
+ * -4.div(-3) # => 1
+ * 4.div(3.0) # => 1
+ * 4.div(Rational(3, 1)) # => 1
*
- * Raises an exception if +numeric+ does not have method +div+.
+ * Raises an exception if +numeric+ does not have method +div+.
*
*/
@@ -4285,9 +4554,9 @@ fix_mod(VALUE x, VALUE y)
/*
* call-seq:
- * self % other -> real_number
+ * self % other -> real_numeric
*
- * Returns +self+ modulo +other+ as a real number.
+ * Returns +self+ modulo +other+ as a real numeric (\Integer, \Float, or \Rational).
*
* For integer +n+ and real number +r+, these expressions are equivalent:
*
@@ -4352,7 +4621,7 @@ int_remainder(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
if (FIXNUM_P(y)) {
VALUE z = fix_mod(x, y);
- assert(FIXNUM_P(z));
+ RUBY_ASSERT(FIXNUM_P(z));
if (z != INT2FIX(0) && (SIGNED_VALUE)(x ^ y) < 0)
z = fix_minus(z, y);
return z;
@@ -4436,9 +4705,9 @@ rb_int_divmod(VALUE x, VALUE y)
/*
* call-seq:
- * self ** numeric -> numeric_result
+ * self ** exponent -> numeric
*
- * Raises +self+ to the power of +numeric+:
+ * Returns +self+ raised to the power +exponent+:
*
* 2 ** 3 # => 8
* 2 ** -3 # => (1/8)
@@ -4559,17 +4828,47 @@ fix_pow(VALUE x, VALUE y)
/*
* call-seq:
- * self ** numeric -> numeric_result
- *
- * Raises +self+ to the power of +numeric+:
- *
- * 2 ** 3 # => 8
- * 2 ** -3 # => (1/8)
- * -2 ** 3 # => -8
- * -2 ** -3 # => (-1/8)
- * 2 ** 3.3 # => 9.849155306759329
- * 2 ** Rational(3, 1) # => (8/1)
- * 2 ** Complex(3, 0) # => (8+0i)
+ * self ** exponent -> numeric
+ *
+ * Returns +self+ raised to the power +exponent+:
+ *
+ * # Result for non-negative Integer exponent is Integer.
+ * 2 ** 0 # => 1
+ * 2 ** 1 # => 2
+ * 2 ** 2 # => 4
+ * 2 ** 3 # => 8
+ * -2 ** 3 # => -8
+ * # Result for negative Integer exponent is Rational, not Float.
+ * 2 ** -3 # => (1/8)
+ * -2 ** -3 # => (-1/8)
+ *
+ * # Result for Float exponent is Float.
+ * 2 ** 0.0 # => 1.0
+ * 2 ** 1.0 # => 2.0
+ * 2 ** 2.0 # => 4.0
+ * 2 ** 3.0 # => 8.0
+ * -2 ** 3.0 # => -8.0
+ * 2 ** -3.0 # => 0.125
+ * -2 ** -3.0 # => -0.125
+ *
+ * # Result for non-negative Complex exponent is Complex with Integer parts.
+ * 2 ** Complex(0, 0) # => (1+0i)
+ * 2 ** Complex(1, 0) # => (2+0i)
+ * 2 ** Complex(2, 0) # => (4+0i)
+ * 2 ** Complex(3, 0) # => (8+0i)
+ * -2 ** Complex(3, 0) # => (-8+0i)
+ * # Result for negative Complex exponent is Complex with Rational parts.
+ * 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
+ * -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
+ *
+ * # Result for Rational exponent is Rational.
+ * 2 ** Rational(0, 1) # => (1/1)
+ * 2 ** Rational(1, 1) # => (2/1)
+ * 2 ** Rational(2, 1) # => (4/1)
+ * 2 ** Rational(3, 1) # => (8/1)
+ * -2 ** Rational(3, 1) # => (-8/1)
+ * 2 ** Rational(-3, 1) # => (1/8)
+ * -2 ** Rational(-3, 1) # => (-1/8)
*
*/
VALUE
@@ -4622,7 +4921,7 @@ fix_equal(VALUE x, VALUE y)
* call-seq:
* self == other -> true or false
*
- * Returns +true+ if +self+ is numerically equal to +other+; +false+ otherwise.
+ * Returns whether +self+ is numerically equal to +other+:
*
* 1 == 2 #=> false
* 1 == 1.0 #=> true
@@ -4668,28 +4967,29 @@ fix_cmp(VALUE x, VALUE y)
/*
* call-seq:
- * self <=> other -> -1, 0, +1, or nil
+ * self <=> other -> -1, 0, 1, or nil
+ *
+ * Compares +self+ and +other+.
*
* Returns:
*
- * - -1, if +self+ is less than +other+.
- * - 0, if +self+ is equal to +other+.
- * - 1, if +self+ is greater then +other+.
+ * - +-1+, if +self+ is less than +other+.
+ * - +0+, if +self+ is equal to +other+.
+ * - +1+, if +self+ is greater then +other+.
* - +nil+, if +self+ and +other+ are incomparable.
*
* Examples:
*
* 1 <=> 2 # => -1
* 1 <=> 1 # => 0
- * 1 <=> 0 # => 1
- * 1 <=> 'foo' # => nil
- *
* 1 <=> 1.0 # => 0
* 1 <=> Rational(1, 1) # => 0
* 1 <=> Complex(1, 0) # => 0
+ * 1 <=> 0 # => 1
+ * 1 <=> 'foo' # => nil
*
- * This method is the basis for comparisons in module Comparable.
- *
+ * \Class \Integer includes module Comparable,
+ * each of whose methods uses Integer#<=> for comparison.
*/
VALUE
@@ -4702,7 +5002,7 @@ rb_int_cmp(VALUE x, VALUE y)
return rb_big_cmp(x, y);
}
else {
- rb_raise(rb_eNotImpError, "need to define `<=>' in %s", rb_obj_classname(x));
+ rb_raise(rb_eNotImpError, "need to define '<=>' in %s", rb_obj_classname(x));
}
}
@@ -4727,7 +5027,8 @@ fix_gt(VALUE x, VALUE y)
* call-seq:
* self > other -> true or false
*
- * Returns +true+ if the value of +self+ is greater than that of +other+:
+ * Returns whether the value of +self+ is greater than the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 1 > 0 # => true
* 1 > 1 # => false
@@ -4771,10 +5072,10 @@ fix_ge(VALUE x, VALUE y)
/*
* call-seq:
- * self >= real -> true or false
+ * self >= other -> true or false
*
- * Returns +true+ if the value of +self+ is greater than or equal to
- * that of +other+:
+ * Returns whether the value of +self+ is greater than or equal to the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 1 >= 0 # => true
* 1 >= 1 # => true
@@ -4819,7 +5120,8 @@ fix_lt(VALUE x, VALUE y)
* call-seq:
* self < other -> true or false
*
- * Returns +true+ if the value of +self+ is less than that of +other+:
+ * Returns whether the value of +self+ is less than the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 1 < 0 # => false
* 1 < 1 # => false
@@ -4827,8 +5129,6 @@ fix_lt(VALUE x, VALUE y)
* 1 < 0.5 # => false
* 1 < Rational(1, 2) # => false
*
- * Raises an exception if the comparison cannot be made.
- *
*/
static VALUE
@@ -4863,10 +5163,10 @@ fix_le(VALUE x, VALUE y)
/*
* call-seq:
- * self <= real -> true or false
+ * self <= other -> true or false
*
- * Returns +true+ if the value of +self+ is less than or equal to
- * that of +other+:
+ * Returns whether the value of +self+ is less than or equal to the value of +other+;
+ * +other+ must be numeric, but may not be Complex:
*
* 1 <= 0 # => false
* 1 <= 1 # => true
@@ -5051,8 +5351,8 @@ fix_xor(VALUE x, VALUE y)
*
*/
-static VALUE
-int_xor(VALUE x, VALUE y)
+VALUE
+rb_int_xor(VALUE x, VALUE y)
{
if (FIXNUM_P(x)) {
return fix_xor(x, y);
@@ -5162,7 +5462,7 @@ fix_rshift(long val, unsigned long i)
*
*/
-static VALUE
+VALUE
rb_int_rshift(VALUE x, VALUE y)
{
if (FIXNUM_P(x)) {
@@ -5225,9 +5525,22 @@ generate_mask(VALUE len)
}
static VALUE
+int_aref2(VALUE num, VALUE beg, VALUE len)
+{
+ if (RB_TYPE_P(num, T_BIGNUM)) {
+ return rb_big_aref2(num, beg, len);
+ }
+ else {
+ num = rb_int_rshift(num, beg);
+ VALUE mask = generate_mask(len);
+ return rb_int_and(num, mask);
+ }
+}
+
+static VALUE
int_aref1(VALUE num, VALUE arg)
{
- VALUE orig_num = num, beg, end;
+ VALUE beg, end;
int excl;
if (rb_range_values(arg, &beg, &end, &excl)) {
@@ -5247,22 +5560,19 @@ int_aref1(VALUE num, VALUE arg)
return INT2FIX(0);
}
}
- num = rb_int_rshift(num, beg);
int cmp = compare_indexes(beg, end);
if (!NIL_P(end) && cmp < 0) {
VALUE len = rb_int_minus(end, beg);
if (!excl) len = rb_int_plus(len, INT2FIX(1));
- VALUE mask = generate_mask(len);
- num = rb_int_and(num, mask);
+ return int_aref2(num, beg, len);
}
else if (cmp == 0) {
if (excl) return INT2FIX(0);
- num = orig_num;
arg = beg;
goto one_bit;
}
- return num;
+ return rb_int_rshift(num, beg);
}
one_bit:
@@ -5275,15 +5585,6 @@ one_bit:
return Qnil;
}
-static VALUE
-int_aref2(VALUE num, VALUE beg, VALUE len)
-{
- num = rb_int_rshift(num, beg);
- VALUE mask = generate_mask(len);
- num = rb_int_and(num, mask);
- return num;
-}
-
/*
* call-seq:
* self[offset] -> 0 or 1
@@ -5344,7 +5645,7 @@ int_aref(int const argc, VALUE * const argv, VALUE const num)
* 1.to_f # => 1.0
* -1.to_f # => -1.0
*
- * If the value of +self+ does not fit in a \Float,
+ * If the value of +self+ does not fit in a Float,
* the result is infinity:
*
* (10**400).to_f # => Infinity
@@ -5437,7 +5738,7 @@ rb_fix_digits(VALUE fix, long base)
VALUE digits;
long x = FIX2LONG(fix);
- assert(x >= 0);
+ RUBY_ASSERT(x >= 0);
if (base < 2)
rb_raise(rb_eArgError, "invalid radix %ld", base);
@@ -5446,11 +5747,12 @@ rb_fix_digits(VALUE fix, long base)
return rb_ary_new_from_args(1, INT2FIX(0));
digits = rb_ary_new();
- while (x > 0) {
+ while (x >= base) {
long q = x % base;
rb_ary_push(digits, LONG2NUM(q));
x /= base;
}
+ rb_ary_push(digits, LONG2NUM(x));
return digits;
}
@@ -5460,7 +5762,7 @@ rb_int_digits_bigbase(VALUE num, VALUE base)
{
VALUE digits, bases;
- assert(!rb_num_negative_p(num));
+ RUBY_ASSERT(!rb_num_negative_p(num));
if (RB_BIGNUM_TYPE_P(base))
base = rb_big_norm(base);
@@ -5487,7 +5789,7 @@ rb_int_digits_bigbase(VALUE num, VALUE base)
}
bases = rb_ary_new();
- for (VALUE b = base; int_lt(b, num) == Qtrue; b = rb_int_mul(b, b)) {
+ for (VALUE b = base; int_le(b, num) == Qtrue; b = rb_int_mul(b, b)) {
rb_ary_push(bases, b);
}
digits = rb_ary_new_from_args(1, num);
@@ -5652,7 +5954,7 @@ int_downto(VALUE from, VALUE to)
rb_yield(i);
i = rb_funcall(i, '-', 1, INT2FIX(1));
}
- if (NIL_P(c)) rb_cmperr(i, to);
+ ensure_cmp(c, i, to);
}
return from;
}
@@ -5660,53 +5962,7 @@ int_downto(VALUE from, VALUE to)
static VALUE
int_dotimes_size(VALUE num, VALUE args, VALUE eobj)
{
- if (FIXNUM_P(num)) {
- if (NUM2LONG(num) <= 0) return INT2FIX(0);
- }
- else {
- if (RTEST(rb_funcall(num, '<', 1, INT2FIX(0)))) return INT2FIX(0);
- }
- return num;
-}
-
-/*
- * call-seq:
- * times {|i| ... } -> self
- * times -> enumerator
- *
- * Calls the given block +self+ times with each integer in <tt>(0..self-1)</tt>:
- *
- * a = []
- * 5.times {|i| a.push(i) } # => 5
- * a # => [0, 1, 2, 3, 4]
- *
- * With no block given, returns an Enumerator.
- *
- */
-
-static VALUE
-int_dotimes(VALUE num)
-{
- RETURN_SIZED_ENUMERATOR(num, 0, 0, int_dotimes_size);
-
- if (FIXNUM_P(num)) {
- long i, end;
-
- end = FIX2LONG(num);
- for (i=0; i<end; i++) {
- rb_yield_1(LONG2FIX(i));
- }
- }
- else {
- VALUE i = INT2FIX(0);
-
- for (;;) {
- if (!RTEST(int_le(i, num))) break;
- rb_yield(i);
- i = rb_int_plus(i, INT2FIX(1));
- }
- }
- return num;
+ return int_neg_p(num) ? INT2FIX(0) : num;
}
/*
@@ -5775,24 +6031,56 @@ int_round(int argc, VALUE* argv, VALUE num)
}
/*
+ * :markup: markdown
+ *
* call-seq:
* floor(ndigits = 0) -> integer
*
- * Returns the largest number less than or equal to +self+ with
- * a precision of +ndigits+ decimal digits.
+ * Returns an integer that is a "floor" value for `self`,
+ * as specified by the given `ndigits`,
+ * which must be an
+ * [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
*
- * When +ndigits+ is negative, the returned value
- * has at least <tt>ndigits.abs</tt> trailing zeros:
+ * - When `self` is zero, returns zero (regardless of the value of `ndigits`):
*
- * 555.floor(-1) # => 550
- * 555.floor(-2) # => 500
- * -555.floor(-2) # => -600
- * 555.floor(-3) # => 0
+ * ```
+ * 0.floor(2) # => 0
+ * 0.floor(-2) # => 0
+ * ```
*
- * Returns +self+ when +ndigits+ is zero or positive.
+ * - When `self` is non-zero and `ndigits` is non-negative, returns `self`:
+ *
+ * ```
+ * 555.floor # => 555
+ * 555.floor(50) # => 555
+ * ```
+ *
+ * - When `self` is non-zero and `ndigits` is negative,
+ * returns a value based on a computed granularity:
+ *
+ * - The granularity is `10 ** ndigits.abs`.
+ * - The returned value is the largest multiple of the granularity
+ * that is less than or equal to `self`.
+ *
+ * Examples with positive `self`:
+ *
+ * | ndigits | Granularity | 1234.floor(ndigits) |
+ * |--------:|------------:|--------------------:|
+ * | -1 | 10 | 1230 |
+ * | -2 | 100 | 1200 |
+ * | -3 | 1000 | 1000 |
+ * | -4 | 10000 | 0 |
+ * | -5 | 100000 | 0 |
+ *
+ * Examples with negative `self`:
*
- * 555.floor # => 555
- * 555.floor(50) # => 555
+ * | ndigits | Granularity | -1234.floor(ndigits) |
+ * |--------:|------------:|---------------------:|
+ * | -1 | 10 | -1240 |
+ * | -2 | 100 | -1300 |
+ * | -3 | 1000 | -2000 |
+ * | -4 | 10000 | -10000 |
+ * | -5 | 100000 | -100000 |
*
* Related: Integer#ceil.
*
@@ -5812,27 +6100,58 @@ int_floor(int argc, VALUE* argv, VALUE num)
}
/*
+ * :markup: markdown
+ *
* call-seq:
* ceil(ndigits = 0) -> integer
*
- * Returns the smallest number greater than or equal to +self+ with
- * a precision of +ndigits+ decimal digits.
+ * Returns an integer that is a "ceiling" value for `self`,
+ * as specified by the given `ndigits`,
+ * which must be an
+ * [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
*
- * When the precision is negative, the returned value is an integer
- * with at least <code>ndigits.abs</code> trailing zeros:
+ * - When `self` is zero, returns zero (regardless of the value of `ndigits`):
*
- * 555.ceil(-1) # => 560
- * 555.ceil(-2) # => 600
- * -555.ceil(-2) # => -500
- * 555.ceil(-3) # => 1000
+ * ```
+ * 0.ceil(2) # => 0
+ * 0.ceil(-2) # => 0
+ * ```
*
- * Returns +self+ when +ndigits+ is zero or positive.
+ * - When `self` is non-zero and `ndigits` is non-negative, returns `self`:
*
- * 555.ceil # => 555
- * 555.ceil(50) # => 555
+ * ```
+ * 555.ceil # => 555
+ * 555.ceil(50) # => 555
+ * ```
*
- * Related: Integer#floor.
+ * - When `self` is non-zero and `ndigits` is negative,
+ * returns a value based on a computed granularity:
+ *
+ * - The granularity is `10 ** ndigits.abs`.
+ * - The returned value is the smallest multiple of the granularity
+ * that is greater than or equal to `self`.
+ *
+ * Examples with positive `self`:
*
+ * | ndigits | Granularity | 1234.ceil(ndigits) |
+ * |--------:|------------:|-------------------:|
+ * | -1 | 10 | 1240 |
+ * | -2 | 100 | 1300 |
+ * | -3 | 1000 | 2000 |
+ * | -4 | 10000 | 10000 |
+ * | -5 | 100000 | 100000 |
+ *
+ * Examples with negative `self`:
+ *
+ * | ndigits | Granularity | -1234.ceil(ndigits) |
+ * |--------:|------------:|--------------------:|
+ * | -1 | 10 | -1230 |
+ * | -2 | 100 | -1200 |
+ * | -3 | 1000 | -1000 |
+ * | -4 | 10000 | 0 |
+ * | -5 | 100000 | 0 |
+ *
+ * Related: Integer#floor.
*/
static VALUE
@@ -5896,7 +6215,11 @@ prefix##_isqrt(argtype n) \
while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \
return x; \
} \
- return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \
+ rettype x = (rettype)sqrt(argtype##_TO_DOUBLE(n)); \
+ /* libm sqrt may returns a larger approximation than actual. */ \
+ /* Our isqrt always returns a smaller approximation. */ \
+ if (x * x > n) x--; \
+ return x; \
}
#if SIZEOF_LONG*CHAR_BIT > DBL_MANT_DIG
@@ -6037,9 +6360,9 @@ int_s_try_convert(VALUE self, VALUE num)
/*
* Document-class: Numeric
*
- * Numeric is the class from which all higher-level numeric classes should inherit.
+ * \Numeric is the class from which all higher-level numeric classes should inherit.
*
- * Numeric allows instantiation of heap-allocated objects. Other core numeric classes such as
+ * \Numeric allows instantiation of heap-allocated objects. Other core numeric classes such as
* Integer are implemented as immediates, which means that each Integer is a single immutable
* object which is always passed by value.
*
@@ -6053,9 +6376,9 @@ int_s_try_convert(VALUE self, VALUE num)
* 1.dup #=> 1
* 1.object_id == 1.dup.object_id #=> true
*
- * For this reason, Numeric should be used when defining other numeric classes.
+ * For this reason, \Numeric should be used when defining other numeric classes.
*
- * Classes which inherit from Numeric must implement +coerce+, which returns a two-member
+ * Classes which inherit from \Numeric must implement +coerce+, which returns a two-member
* Array containing an object that has been coerced into an instance of the new class
* and +self+ (see #coerce).
*
@@ -6108,10 +6431,10 @@ int_s_try_convert(VALUE self, VALUE num)
*
* == What's Here
*
- * First, what's elsewhere. \Class \Numeric:
+ * First, what's elsewhere. Class \Numeric:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Includes {module Comparable}[rdoc-ref:Comparable@What-27s+Here].
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Includes {module Comparable}[rdoc-ref:Comparable@Whats+Here].
*
* Here, class \Numeric provides methods for:
*
@@ -6207,10 +6530,8 @@ Init_Numeric(void)
rb_include_module(rb_cNumeric, rb_mComparable);
rb_define_method(rb_cNumeric, "coerce", num_coerce, 1);
rb_define_method(rb_cNumeric, "clone", num_clone, -1);
- rb_define_method(rb_cNumeric, "dup", num_dup, 0);
rb_define_method(rb_cNumeric, "i", num_imaginary, 0);
- rb_define_method(rb_cNumeric, "+@", num_uplus, 0);
rb_define_method(rb_cNumeric, "-@", num_uminus, 0);
rb_define_method(rb_cNumeric, "<=>", num_cmp, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
@@ -6248,7 +6569,6 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "nobits?", int_nobits_p, 1);
rb_define_method(rb_cInteger, "upto", int_upto, 1);
rb_define_method(rb_cInteger, "downto", int_downto, 1);
- rb_define_method(rb_cInteger, "times", int_dotimes, 0);
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);
@@ -6283,7 +6603,7 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "&", rb_int_and, 1);
rb_define_method(rb_cInteger, "|", int_or, 1);
- rb_define_method(rb_cInteger, "^", int_xor, 1);
+ rb_define_method(rb_cInteger, "^", rb_int_xor, 1);
rb_define_method(rb_cInteger, "[]", int_aref, -1);
rb_define_method(rb_cInteger, "<<", rb_int_lshift, 1);
@@ -6291,19 +6611,25 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "digits", rb_int_digits, -1);
- rb_fix_to_s_static[0] = rb_fstring_literal("0");
- rb_fix_to_s_static[1] = rb_fstring_literal("1");
- rb_fix_to_s_static[2] = rb_fstring_literal("2");
- rb_fix_to_s_static[3] = rb_fstring_literal("3");
- rb_fix_to_s_static[4] = rb_fstring_literal("4");
- rb_fix_to_s_static[5] = rb_fstring_literal("5");
- rb_fix_to_s_static[6] = rb_fstring_literal("6");
- rb_fix_to_s_static[7] = rb_fstring_literal("7");
- rb_fix_to_s_static[8] = rb_fstring_literal("8");
- rb_fix_to_s_static[9] = rb_fstring_literal("9");
- for(int i = 0; i < 10; i++) {
- rb_gc_register_mark_object(rb_fix_to_s_static[i]);
- }
+#define fix_to_s_static(n) do { \
+ VALUE lit = rb_fstring_literal(#n); \
+ rb_fix_to_s_static[n] = lit; \
+ rb_vm_register_global_object(lit); \
+ RB_GC_GUARD(lit); \
+ } while (0)
+
+ fix_to_s_static(0);
+ fix_to_s_static(1);
+ fix_to_s_static(2);
+ fix_to_s_static(3);
+ fix_to_s_static(4);
+ fix_to_s_static(5);
+ fix_to_s_static(6);
+ fix_to_s_static(7);
+ fix_to_s_static(8);
+ fix_to_s_static(9);
+
+#undef fix_to_s_static
rb_cFloat = rb_define_class("Float", rb_cNumeric);
@@ -6365,7 +6691,7 @@ Init_Numeric(void)
*
* If the platform supports denormalized numbers,
* there are numbers between zero and Float::MIN.
- * 0.0.next_float returns the smallest positive floating point number
+ * +0.0.next_float+ returns the smallest positive floating point number
* including denormalized numbers.
*/
rb_define_const(rb_cFloat, "MIN", DBL2NUM(DBL_MIN));
diff --git a/numeric.rb b/numeric.rb
index c7ff585db8..306561943d 100644
--- a/numeric.rb
+++ b/numeric.rb
@@ -1,62 +1,66 @@
class Numeric
+ # call-seq:
+ # dup -> self
+ #
+ # Returns +self+.
#
+ # Related: Numeric#clone.
+ #
+ def dup
+ self
+ end
+
# call-seq:
- # num.real? -> true or false
+ # real? -> true or false
#
- # Returns +true+ if +num+ is a real number (i.e. not Complex).
+ # Returns +true+ if +self+ is a real number (i.e. not Complex).
#
def real?
true
end
- #
# call-seq:
- # num.real -> self
+ # real -> self
#
- # Returns self.
+ # Returns +self+.
#
def real
self
end
- #
# call-seq:
- # num.integer? -> true or false
+ # integer? -> true or false
#
- # Returns +true+ if +num+ is an Integer.
+ # Returns +true+ if +self+ is an Integer.
#
- # 1.0.integer? #=> false
- # 1.integer? #=> true
+ # 1.0.integer? # => false
+ # 1.integer? # => true
#
def integer?
false
end
- #
# call-seq:
- # num.finite? -> true or false
+ # finite? -> true or false
#
- # Returns +true+ if +num+ is a finite number, otherwise returns +false+.
+ # Returns +true+ if +self+ is a finite number, +false+ otherwise.
#
def finite?
true
end
- #
# call-seq:
- # num.infinite? -> -1, 1, or nil
+ # infinite? -> -1, 1, or nil
#
- # Returns +nil+, -1, or 1 depending on whether the value is
- # finite, <code>-Infinity</code>, or <code>+Infinity</code>.
+ # Returns +nil+, -1, or 1 depending on whether +self+ is
+ # finite, <tt>-Infinity</tt>, or <tt>+Infinity</tt>.
#
def infinite?
nil
end
- #
# call-seq:
- # num.imag -> 0
- # num.imaginary -> 0
+ # imag -> 0
#
# Returns zero.
#
@@ -66,55 +70,69 @@ class Numeric
alias imag imaginary
- #
# call-seq:
- # num.conj -> self
- # num.conjugate -> self
+ # conj -> self
#
- # Returns self.
+ # Returns +self+.
#
def conjugate
self
end
alias conj conjugate
+
+ # call-seq:
+ # +self -> self
+ #
+ # Returns +self+.
+ #
+ def +@
+ self
+ end
end
class Integer
# call-seq:
- # -int -> integer
+ # -self -> integer
+ #
+ # Returns +self+, negated:
+ #
+ # -1 # => -1
+ # -(-1) # => 1
+ # -0 # => 0
#
- # Returns +int+, negated.
def -@
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_uminus(self)'
end
# call-seq:
- # ~int -> integer
+ # ~int -> integer
#
- # One's complement: returns a number where each bit is flipped.
+ # One's complement:
+ # returns the value of +self+ with each bit inverted.
#
- # Inverts the bits in an Integer. As integers are conceptually of
- # infinite length, the result acts as if it had an infinite number of
- # one bits to the left. In hex representations, this is displayed
- # as two periods to the left of the digits.
+ # Because an integer value is conceptually of infinite length,
+ # the result acts as if it had an infinite number of
+ # one bits to the left.
+ # In hex representations, this is displayed
+ # as two periods to the left of the digits:
+ #
+ # sprintf("%X", ~0x1122334455) # => "..FEEDDCCBBAA"
#
- # sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
def ~
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_comp(self)'
end
# call-seq:
- # int.abs -> integer
- # int.magnitude -> integer
+ # abs -> integer
#
- # Returns the absolute value of +int+.
+ # Returns the absolute value of +self+.
#
- # (-12345).abs #=> 12345
- # -12345.abs #=> 12345
- # 12345.abs #=> 12345
+ # (-12345).abs # => 12345
+ # -12345.abs # => 12345
+ # 12345.abs # => 12345
#
def abs
Primitive.attr! :leaf
@@ -122,64 +140,65 @@ class Integer
end
# call-seq:
- # int.bit_length -> integer
- #
- # Returns the number of bits of the value of +int+.
+ # bit_length -> integer
#
- # "Number of bits" means the bit position of the highest bit
- # which is different from the sign bit
+ # Returns the number of bits of the value of +self+,
+ # which is the bit position of the highest-order bit
+ # that is different from the sign bit
# (where the least significant bit has bit position 1).
- # If there is no such bit (zero or minus one), zero is returned.
- #
- # I.e. this method returns <i>ceil(log2(int < 0 ? -int : int+1))</i>.
- #
- # (-2**1000-1).bit_length #=> 1001
- # (-2**1000).bit_length #=> 1000
- # (-2**1000+1).bit_length #=> 1000
- # (-2**12-1).bit_length #=> 13
- # (-2**12).bit_length #=> 12
- # (-2**12+1).bit_length #=> 12
- # -0x101.bit_length #=> 9
- # -0x100.bit_length #=> 8
- # -0xff.bit_length #=> 8
- # -2.bit_length #=> 1
- # -1.bit_length #=> 0
- # 0.bit_length #=> 0
- # 1.bit_length #=> 1
- # 0xff.bit_length #=> 8
- # 0x100.bit_length #=> 9
- # (2**12-1).bit_length #=> 12
- # (2**12).bit_length #=> 13
- # (2**12+1).bit_length #=> 13
- # (2**1000-1).bit_length #=> 1000
- # (2**1000).bit_length #=> 1001
- # (2**1000+1).bit_length #=> 1001
- #
- # This method can be used to detect overflow in Array#pack as follows:
- #
- # if n.bit_length < 32
- # [n].pack("l") # no overflow
- # else
- # raise "overflow"
- # end
+ # If there is no such bit (zero or minus one), returns zero.
+ #
+ # This method returns <tt>ceil(log2(self < 0 ? -self : self + 1))</tt>>.
+ #
+ # (-2**1000-1).bit_length # => 1001
+ # (-2**1000).bit_length # => 1000
+ # (-2**1000+1).bit_length # => 1000
+ # (-2**12-1).bit_length # => 13
+ # (-2**12).bit_length # => 12
+ # (-2**12+1).bit_length # => 12
+ # -0x101.bit_length # => 9
+ # -0x100.bit_length # => 8
+ # -0xff.bit_length # => 8
+ # -2.bit_length # => 1
+ # -1.bit_length # => 0
+ # 0.bit_length # => 0
+ # 1.bit_length # => 1
+ # 0xff.bit_length # => 8
+ # 0x100.bit_length # => 9
+ # (2**12-1).bit_length # => 12
+ # (2**12).bit_length # => 13
+ # (2**12+1).bit_length # => 13
+ # (2**1000-1).bit_length # => 1000
+ # (2**1000).bit_length # => 1001
+ # (2**1000+1).bit_length # => 1001
+ #
+ # For \Integer _n_,
+ # this method can be used to detect overflow in Array#pack:
+ #
+ # if n.bit_length < 32
+ # [n].pack('l') # No overflow.
+ # else
+ # raise 'Overflow'
+ # end
+ #
def bit_length
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_bit_length(self)'
end
# call-seq:
- # int.even? -> true or false
+ # even? -> true or false
#
- # Returns +true+ if +int+ is an even number.
+ # Returns +true+ if +self+ is an even number, +false+ otherwise.
def even?
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_even_p(self)'
end
# call-seq:
- # int.integer? -> true
+ # integer? -> true
#
- # Since +int+ is already an Integer, this always returns +true+.
+ # Since +self+ is already an \Integer, always returns +true+.
def integer?
true
end
@@ -187,183 +206,213 @@ class Integer
alias magnitude abs
# call-seq:
- # int.odd? -> true or false
+ # odd? -> true or false
#
- # Returns +true+ if +int+ is an odd number.
+ # Returns +true+ if +self+ is an odd number, +false+ otherwise.
def odd?
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_odd_p(self)'
end
# call-seq:
- # int.ord -> self
- #
- # Returns the +int+ itself.
- #
- # 97.ord #=> 97
- #
- # This method is intended for compatibility to character literals
- # in Ruby 1.9.
+ # ord -> self
#
- # For example, <code>?a.ord</code> returns 97 both in 1.8 and 1.9.
+ # Returns +self+;
+ # intended for compatibility to character literals in Ruby 1.9.
def ord
self
end
- #
- # Document-method: Integer#size
# call-seq:
- # int.size -> int
+ # size -> integer
#
- # Returns the number of bytes in the machine representation of +int+
- # (machine dependent).
+ # Returns the number of bytes in the machine representation of +self+;
+ # the value is system-dependent:
#
- # 1.size #=> 8
- # -1.size #=> 8
- # 2147483647.size #=> 8
- # (256**10 - 1).size #=> 10
- # (256**20 - 1).size #=> 20
- # (256**40 - 1).size #=> 40
+ # 1.size # => 8
+ # -1.size # => 8
+ # 2147483647.size # => 8
+ # (256**10 - 1).size # => 10
+ # (256**20 - 1).size # => 20
+ # (256**40 - 1).size # => 40
#
def size
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_size(self)'
end
+ # call-seq:
+ # times {|i| ... } -> self
+ # times -> enumerator
+ #
+ # Calls the given block +self+ times with each integer in <tt>(0..self-1)</tt>:
+ #
+ # a = []
+ # 5.times {|i| a.push(i) } # => 5
+ # a # => [0, 1, 2, 3, 4]
+ #
+ # With no block given, returns an Enumerator.
+ def times
+ Primitive.attr! :inline_block
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, int_dotimes_size)'
+ end
+ i = 0
+ while i < self
+ yield i
+ i = i.succ
+ end
+ self
+ end
+
# call-seq:
- # int.to_i -> integer
+ # to_i -> self
#
- # Since +int+ is already an Integer, returns +self+.
+ # Returns +self+ (which is already an \Integer).
def to_i
self
end
# call-seq:
- # int.to_int -> integer
+ # to_int -> self
#
- # Since +int+ is already an Integer, returns +self+.
+ # Returns +self+ (which is already an \Integer).
def to_int
self
end
# call-seq:
- # int.zero? -> true or false
+ # zero? -> true or false
#
- # Returns +true+ if +int+ has a zero value.
+ # Returns +true+ if +self+ has a zero value, +false+ otherwise.
def zero?
Primitive.attr! :leaf
Primitive.cexpr! 'rb_int_zero_p(self)'
end
# call-seq:
- # ceildiv(other) -> integer
+ # ceildiv(numeric) -> integer
#
- # Returns the result of division +self+ by +other+. The result is rounded up to the nearest integer.
+ # Returns the result of division +self+ by +numeric+.
+ # rounded up to the nearest integer.
#
- # 3.ceildiv(3) # => 1
- # 4.ceildiv(3) # => 2
+ # 3.ceildiv(3) # => 1
+ # 4.ceildiv(3) # => 2
#
- # 4.ceildiv(-3) # => -1
- # -4.ceildiv(3) # => -1
+ # 4.ceildiv(-3) # => -1
+ # -4.ceildiv(3) # => -1
# -4.ceildiv(-3) # => 2
#
# 3.ceildiv(1.2) # => 3
+ #
def ceildiv(other)
-div(0 - other)
end
#
# call-seq:
- # int.numerator -> self
+ # numerator -> self
#
- # Returns self.
+ # Returns +self+.
#
def numerator
self
end
- #
# call-seq:
- # int.denominator -> 1
- #
- # Returns 1.
+ # denominator -> 1
#
+ # Returns +1+.
def denominator
1
end
+
+ with_jit do
+ if Primitive.rb_builtin_basic_definition_p(:downto)
+ undef :downto
+
+ def downto(to) # :nodoc:
+ Primitive.attr! :inline_block, :c_trace
+
+ # When no block is given, return an Enumerator that enumerates from `self` to `to`.
+ # Not using `block_given?` and `to_enum` to keep them unaffected by redefinitions.
+ unless defined?(yield)
+ return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 1, &to, int_downto_size)'
+ end
+
+ from = self
+ while from >= to
+ yield from
+ from = from.pred
+ end
+ self
+ end
+ end
+ end
end
class Float
- #
+
# call-seq:
- # float.to_f -> self
- #
- # Since +float+ is already a Float, returns +self+.
+ # to_f -> self
#
+ # Returns +self+ (which is already a \Float).
def to_f
self
end
- #
# call-seq:
- # float.abs -> float
- # float.magnitude -> float
+ # float.abs -> float
#
- # Returns the absolute value of +float+.
+ # Returns the absolute value of +self+:
#
- # (-34.56).abs #=> 34.56
- # -34.56.abs #=> 34.56
- # 34.56.abs #=> 34.56
+ # (-34.56).abs # => 34.56
+ # -34.56.abs # => 34.56
+ # 34.56.abs # => 34.56
#
def abs
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_abs(self)'
end
- def magnitude
- Primitive.attr! :leaf
- Primitive.cexpr! 'rb_float_abs(self)'
- end
+ alias magnitude abs
- #
# call-seq:
- # -float -> float
+ # -self -> float
+ #
+ # Returns +self+, negated:
#
- # Returns +float+, negated.
+ # -3.14 # => -3.14
+ # -(-3.14) # => 3.14
+ # -0.0 # => -0.0
#
def -@
Primitive.attr! :leaf
Primitive.cexpr! 'rb_float_uminus(self)'
end
- #
# call-seq:
- # float.zero? -> true or false
- #
- # Returns +true+ if +float+ is 0.0.
+ # zero? -> true or false
#
+ # Returns +true+ if +self+ is 0.0, +false+ otherwise.
def zero?
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
end
- #
# call-seq:
- # float.positive? -> true or false
- #
- # Returns +true+ if +float+ is greater than 0.
+ # positive? -> true or false
#
+ # Returns +true+ if +self+ is greater than 0, +false+ otherwise.
def positive?
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
end
- #
# call-seq:
- # float.negative? -> true or false
- #
- # Returns +true+ if +float+ is less than 0.
+ # negative? -> true or false
#
+ # Returns +true+ if +self+ is less than 0, +false+ otherwise.
def negative?
Primitive.attr! :leaf
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
diff --git a/object.c b/object.c
index 983fde9b09..2e962b1c3c 100644
--- a/object.c
+++ b/object.c
@@ -31,6 +31,7 @@
#include "internal/object.h"
#include "internal/struct.h"
#include "internal/string.h"
+#include "internal/st.h"
#include "internal/symbol.h"
#include "internal/variable.h"
#include "variable.h"
@@ -41,6 +42,14 @@
#include "ruby/assert.h"
#include "builtin.h"
#include "shape.h"
+#include "yjit.h"
+
+/* Flags of RObject
+ *
+ * 4: ROBJECT_HEAP
+ * The object has its instance variables in a separately allocated buffer.
+ * This can be either a flat buffer of reference, or an st_table for complex objects.
+ */
/*!
* \addtogroup object
@@ -73,6 +82,7 @@ static VALUE rb_cFalseClass_to_s;
#define id_init_dup idInitialize_dup
#define id_const_missing idConst_missing
#define id_to_f idTo_f
+static ID id_instance_variables_to_inspect;
#define CLASS_OR_MODULE_P(obj) \
(!SPECIAL_CONST_P(obj) && \
@@ -80,6 +90,7 @@ static VALUE rb_cFalseClass_to_s;
/*! \endcond */
+
VALUE
rb_obj_hide(VALUE obj)
{
@@ -98,10 +109,12 @@ rb_obj_reveal(VALUE obj, VALUE klass)
return obj;
}
+
VALUE
rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
{
- RBASIC(obj)->flags = type;
+ VALUE ignored_flags = RUBY_FL_PROMOTED;
+ RBASIC(obj)->flags = (type & ~ignored_flags) | (RBASIC(obj)->flags & ignored_flags);
RBASIC_SET_CLASS(obj, klass);
return obj;
}
@@ -114,7 +127,7 @@ rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
*
* Returns +true+ or +false+.
*
- * Like Object#==, if +object+ is an instance of Object
+ * Like Object#==, if +other+ is an instance of \Object
* (and not an instance of one of its many subclasses).
*
* This method is commonly overridden by those subclasses,
@@ -152,14 +165,18 @@ rb_eql(VALUE obj1, VALUE obj2)
/**
* call-seq:
- * obj == other -> true or false
- * obj.equal?(other) -> true or false
- * obj.eql?(other) -> true or false
+ * self == other -> true or false
+ * equal?(other) -> true or false
+ * eql?(other) -> true or false
*
- * Equality --- At the Object level, #== returns <code>true</code>
- * only if +obj+ and +other+ are the same object. Typically, this
- * method is overridden in descendant classes to provide
- * class-specific meaning.
+ * Returns whether +self+ and +other+ are the same object:
+ *
+ * object = Object.new
+ * object == object # => true
+ * object == Object.new # => false
+ *
+ * Here in class \Object, #==, #equal?, and #eql? are the same method.
+ * A subclass may override #== to provide class-specific meaning.
*
* Unlike #==, the #equal? method should never be overridden by
* subclasses as it is used to determine object identity (that is,
@@ -232,12 +249,38 @@ rb_obj_not_equal(VALUE obj1, VALUE obj2)
return rb_obj_not(result);
}
+static inline VALUE
+fake_class_p(VALUE klass)
+{
+ RUBY_ASSERT(klass);
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_MODULE) || RB_TYPE_P(klass, T_ICLASS));
+ STATIC_ASSERT(t_iclass_overlap_t_class, !(T_CLASS & T_ICLASS));
+ STATIC_ASSERT(t_iclass_overlap_t_module, !(T_MODULE & T_ICLASS));
+
+ return FL_TEST_RAW(klass, T_ICLASS | FL_SINGLETON);
+}
+
+static inline VALUE
+class_real(VALUE cl)
+{
+ RUBY_ASSERT(cl);
+
+ // TODO: In the future we should only call this with T_CLASS
+ RUBY_ASSERT(RB_TYPE_P(cl, T_CLASS) || RB_TYPE_P(cl, T_ICLASS) || RB_TYPE_P(cl, T_MODULE));
+
+ while (RB_UNLIKELY(fake_class_p(cl))) {
+ // All paths through super in any box will eventually result in the
+ // same class.
+ cl = RCLASSEXT_SUPER(RCLASS_EXT_PRIME(cl));
+ }
+ return cl;
+}
+
VALUE
rb_class_real(VALUE cl)
{
- while (cl &&
- ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS)) {
- cl = RCLASS_SUPER(cl);
+ if (cl) {
+ cl = class_real(cl);
}
return cl;
}
@@ -245,7 +288,17 @@ rb_class_real(VALUE cl)
VALUE
rb_obj_class(VALUE obj)
{
- return rb_class_real(CLASS_OF(obj));
+ VALUE cl = CLASS_OF(obj);
+ if (cl) {
+ cl = class_real(cl);
+ }
+ return cl;
+}
+
+static inline VALUE
+rb_obj_class_must(VALUE obj)
+{
+ return class_real(CLASS_OF(obj));
}
/*
@@ -275,61 +328,47 @@ rb_obj_singleton_class(VALUE obj)
void
rb_obj_copy_ivar(VALUE dest, VALUE obj)
{
- RUBY_ASSERT(!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE));
-
- RUBY_ASSERT(BUILTIN_TYPE(dest) == BUILTIN_TYPE(obj));
- rb_shape_t * src_shape = rb_shape_get_shape(obj);
-
- if (rb_shape_id(src_shape) == OBJ_TOO_COMPLEX_SHAPE_ID) {
- struct rb_id_table * table = rb_id_table_create(rb_id_table_size(ROBJECT_IV_HASH(obj)));
-
- rb_ivar_foreach(obj, rb_obj_evacuate_ivs_to_hash_table, (st_data_t)table);
- rb_shape_set_too_complex(dest);
-
- ROBJECT(dest)->as.heap.ivptr = (VALUE *)table;
+ RUBY_ASSERT(RB_TYPE_P(obj, T_OBJECT));
+ RUBY_ASSERT(RB_TYPE_P(dest, T_OBJECT));
+ unsigned long src_num_ivs = rb_ivar_count(obj);
+ if (!src_num_ivs) {
return;
}
- uint32_t src_num_ivs = RBASIC_IV_COUNT(obj);
- rb_shape_t * shape_to_set_on_dest = src_shape;
- VALUE * src_buf;
- VALUE * dest_buf;
+ shape_id_t src_shape_id = RBASIC_SHAPE_ID(obj);
- if (!src_num_ivs) {
+ if (rb_shape_complex_p(src_shape_id)) {
+ rb_shape_copy_complex_ivars(dest, obj, src_shape_id, ROBJECT_FIELDS_HASH(obj));
return;
}
- // The copy should be mutable, so we don't want the frozen shape
- if (rb_shape_frozen_shape_p(src_shape)) {
- shape_to_set_on_dest = rb_shape_get_parent(src_shape);
- }
-
- src_buf = ROBJECT_IVPTR(obj);
- dest_buf = ROBJECT_IVPTR(dest);
-
- rb_shape_t * initial_shape = rb_shape_get_shape(dest);
+ shape_id_t initial_shape_id = RBASIC_SHAPE_ID(dest);
+ RUBY_ASSERT(RSHAPE_TYPE_P(initial_shape_id, SHAPE_ROOT));
- if (initial_shape->size_pool_index != src_shape->size_pool_index) {
- RUBY_ASSERT(initial_shape->type == SHAPE_T_OBJECT);
+ shape_id_t dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id);
+ if (UNLIKELY(rb_shape_complex_p(dest_shape_id))) {
+ st_table *table = rb_st_init_numtable_with_size(src_num_ivs);
+ rb_obj_copy_ivs_to_hash_table(obj, table);
+ rb_obj_init_complex(dest, table);
- shape_to_set_on_dest = rb_shape_rebuild_shape(initial_shape, src_shape);
+ return;
}
- RUBY_ASSERT(src_num_ivs <= shape_to_set_on_dest->capacity);
- if (initial_shape->capacity < shape_to_set_on_dest->capacity) {
- rb_ensure_iv_list_size(dest, initial_shape->capacity, shape_to_set_on_dest->capacity);
- dest_buf = ROBJECT_IVPTR(dest);
- }
+ VALUE *src_buf = ROBJECT_FIELDS(obj);
+ VALUE *dest_buf = ROBJECT_FIELDS(dest);
- MEMCPY(dest_buf, src_buf, VALUE, src_num_ivs);
+ attr_index_t initial_capa = RSHAPE_CAPACITY(initial_shape_id);
+ attr_index_t dest_capa = RSHAPE_CAPACITY(dest_shape_id);
- // Fire write barriers
- for (uint32_t i = 0; i < src_num_ivs; i++) {
- RB_OBJ_WRITTEN(dest, Qundef, dest_buf[i]);
+ RUBY_ASSERT(src_num_ivs <= dest_capa);
+ if (initial_capa < dest_capa) {
+ rb_ensure_iv_list_size(dest, 0, dest_capa);
+ dest_buf = ROBJECT_FIELDS(dest);
}
- rb_shape_set_shape(dest, shape_to_set_on_dest);
+ rb_shape_copy_fields(dest, dest_buf, dest_shape_id, src_buf, src_shape_id);
+ RBASIC_SET_SHAPE_ID(dest, dest_shape_id);
}
static void
@@ -338,16 +377,25 @@ init_copy(VALUE dest, VALUE 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 &= ~T_MASK;
// Copies the shape id from obj to dest
- RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR);
- rb_copy_wb_protected_attribute(dest, obj);
- rb_copy_generic_ivar(dest, obj);
- rb_gc_copy_finalizer(dest, obj);
-
- if (RB_TYPE_P(obj, T_OBJECT)) {
+ RBASIC(dest)->flags |= RBASIC(obj)->flags & T_MASK;
+ switch (BUILTIN_TYPE(obj)) {
+ case T_IMEMO:
+ rb_bug("Unreachable");
+ break;
+ case T_CLASS:
+ case T_MODULE:
+ rb_mod_init_copy(dest, obj);
+ break;
+ case T_OBJECT:
rb_obj_copy_ivar(dest, obj);
+ break;
+ default:
+ rb_copy_generic_ivar(dest, obj);
+ break;
}
+ rb_gc_copy_attributes(dest, obj);
}
static VALUE immutable_obj_clone(VALUE obj, VALUE kwfreeze);
@@ -430,17 +478,14 @@ immutable_obj_clone(VALUE obj, VALUE kwfreeze)
return obj;
}
-static VALUE
-mutable_obj_clone(VALUE obj, VALUE kwfreeze)
+VALUE
+rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
{
- VALUE clone, singleton;
VALUE argv[2];
- clone = rb_obj_alloc(rb_obj_class(obj));
-
- singleton = rb_singleton_class_clone_and_attach(obj, clone);
+ VALUE singleton = rb_singleton_class_clone_and_attach(obj, clone);
RBASIC_SET_CLASS(clone, singleton);
- if (FL_TEST(singleton, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(singleton)) {
rb_singleton_class_attached(singleton, clone);
}
@@ -450,15 +495,21 @@ mutable_obj_clone(VALUE obj, VALUE kwfreeze)
case Qnil:
rb_funcall(clone, id_init_clone, 1, obj);
RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE;
+
+ if (RB_TYPE_P(obj, T_STRING)) {
+ FL_SET_RAW(clone, FL_TEST_RAW(obj, STR_CHILLED));
+ }
+
if (RB_OBJ_FROZEN(obj)) {
- rb_shape_transition_shape_frozen(clone);
+ shape_id_t next_shape_id = rb_obj_shape_transition_frozen(clone);
+ RBASIC_SET_SHAPE_ID(clone, next_shape_id);
}
break;
case Qtrue: {
static VALUE freeze_true_hash;
if (!freeze_true_hash) {
freeze_true_hash = rb_hash_new();
- rb_gc_register_mark_object(freeze_true_hash);
+ rb_vm_register_global_object(freeze_true_hash);
rb_hash_aset(freeze_true_hash, ID2SYM(idFreeze), Qtrue);
rb_obj_freeze(freeze_true_hash);
}
@@ -466,15 +517,14 @@ mutable_obj_clone(VALUE obj, VALUE kwfreeze)
argv[0] = obj;
argv[1] = freeze_true_hash;
rb_funcallv_kw(clone, id_init_clone, 2, argv, RB_PASS_KEYWORDS);
- RBASIC(clone)->flags |= FL_FREEZE;
- rb_shape_transition_shape_frozen(clone);
+ OBJ_FREEZE(clone);
break;
}
case Qfalse: {
static VALUE freeze_false_hash;
if (!freeze_false_hash) {
freeze_false_hash = rb_hash_new();
- rb_gc_register_mark_object(freeze_false_hash);
+ rb_vm_register_global_object(freeze_false_hash);
rb_hash_aset(freeze_false_hash, ID2SYM(idFreeze), Qfalse);
rb_obj_freeze(freeze_false_hash);
}
@@ -491,6 +541,13 @@ mutable_obj_clone(VALUE obj, VALUE kwfreeze)
return clone;
}
+static VALUE
+mutable_obj_clone(VALUE obj, VALUE kwfreeze)
+{
+ VALUE clone = rb_obj_alloc(rb_obj_class(obj));
+ return rb_obj_clone_setup(obj, clone, kwfreeze);
+}
+
VALUE
rb_obj_clone(VALUE obj)
{
@@ -498,6 +555,15 @@ rb_obj_clone(VALUE obj)
return mutable_obj_clone(obj, Qnil);
}
+VALUE
+rb_obj_dup_setup(VALUE obj, VALUE dup)
+{
+ init_copy(dup, obj);
+ rb_funcall(dup, id_init_dup, 1, obj);
+
+ return dup;
+}
+
/*
* call-seq:
* obj.dup -> an_object
@@ -546,10 +612,7 @@ rb_obj_dup(VALUE obj)
return obj;
}
dup = rb_obj_alloc(rb_obj_class(obj));
- init_copy(dup, obj);
- rb_funcall(dup, id_init_dup, 1, obj);
-
- return dup;
+ return rb_obj_dup_setup(obj, dup);
}
/*
@@ -578,9 +641,9 @@ rb_obj_size(VALUE self, VALUE args, VALUE obj)
/**
* :nodoc:
*--
- * Default implementation of \c #initialize_copy
- * \param[in,out] obj the receiver being initialized
- * \param[in] orig the object to be copied from.
+ * Default implementation of `#initialize_copy`
+ * @param[in,out] obj the receiver being initialized
+ * @param[in] orig the object to be copied from.
*++
*/
VALUE
@@ -594,13 +657,13 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
return obj;
}
-/*!
+/**
* :nodoc:
*--
- * Default implementation of \c #initialize_dup
+ * Default implementation of `#initialize_dup`
*
- * \param[in,out] obj the receiver being initialized
- * \param[in] orig the object to be dup from.
+ * @param[in,out] obj the receiver being initialized
+ * @param[in] orig the object to be dup from.
*++
**/
VALUE
@@ -610,14 +673,14 @@ rb_obj_init_dup_clone(VALUE obj, VALUE orig)
return obj;
}
-/*!
+/**
* :nodoc:
*--
- * Default implementation of \c #initialize_clone
+ * Default implementation of `#initialize_clone`
*
- * \param[in] The number of arguments
- * \param[in] The array of arguments
- * \param[in] obj the receiver being initialized
+ * @param[in] The number of arguments
+ * @param[in] The array of arguments
+ * @param[in] obj the receiver being initialized
*++
**/
static VALUE
@@ -671,15 +734,19 @@ rb_inspect(VALUE obj)
}
static int
-inspect_i(st_data_t k, st_data_t v, st_data_t a)
+inspect_i(ID id, VALUE value, st_data_t a)
{
- ID id = (ID)k;
- VALUE value = (VALUE)v;
- VALUE str = (VALUE)a;
+ VALUE *args = (VALUE *)a, str = args[0], ivars = args[1];
/* need not to show internal data */
if (CLASS_OF(value) == 0) return ST_CONTINUE;
if (!rb_is_instance_id(id)) return ST_CONTINUE;
+ if (!NIL_P(ivars)) {
+ VALUE name = ID2SYM(id);
+ for (long i = 0; RARRAY_AREF(ivars, i) != name; ) {
+ if (++i >= RARRAY_LEN(ivars)) return ST_CONTINUE;
+ }
+ }
if (RSTRING_PTR(str)[0] == '-') { /* first element */
RSTRING_PTR(str)[0] = '#';
rb_str_cat2(str, " ");
@@ -694,13 +761,15 @@ inspect_i(st_data_t k, st_data_t v, st_data_t a)
}
static VALUE
-inspect_obj(VALUE obj, VALUE str, int recur)
+inspect_obj(VALUE obj, VALUE a, int recur)
{
+ VALUE *args = (VALUE *)a, str = args[0];
+
if (recur) {
rb_str_cat2(str, " ...");
}
else {
- rb_ivar_foreach(obj, inspect_i, str);
+ rb_ivar_foreach_buffered(obj, inspect_i, a);
}
rb_str_cat2(str, ">");
RSTRING_PTR(str)[0] = '#';
@@ -733,23 +802,67 @@ inspect_obj(VALUE obj, VALUE str, int recur)
* end
* end
* Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
+ *
+ * If _obj_ responds to +instance_variables_to_inspect+, then only
+ * the instance variables listed in the returned array will be included
+ * in the inspect string.
+ *
+ *
+ * class DatabaseConfig
+ * def initialize(host, user, password)
+ * @host = host
+ * @user = user
+ * @password = password
+ * end
+ *
+ * private
+ * def instance_variables_to_inspect = [:@host, :@user]
+ * end
+ *
+ * conf = DatabaseConfig.new("localhost", "root", "hunter2")
+ * conf.inspect #=> #<DatabaseConfig:0x0000000104def350 @host="localhost", @user="root">
*/
static VALUE
rb_obj_inspect(VALUE obj)
{
- if (rb_ivar_count(obj) > 0) {
- VALUE str;
- VALUE c = rb_class_name(CLASS_OF(obj));
+ VALUE ivars = rb_check_funcall(obj, id_instance_variables_to_inspect, 0, 0);
+ st_index_t n = 0;
+ if (UNDEF_P(ivars) || NIL_P(ivars)) {
+ n = rb_ivar_count(obj);
+ ivars = Qnil;
+ }
+ else if (RB_TYPE_P(ivars, T_ARRAY)) {
+ n = RARRAY_LEN(ivars);
+ }
+ else {
+ rb_raise(
+ rb_eTypeError,
+ "Expected #instance_variables_to_inspect to return an Array or nil, but it returned %"PRIsVALUE,
+ rb_obj_class(ivars)
+ );
+ }
- str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void*)obj);
- return rb_exec_recursive(inspect_obj, obj, str);
+ if (n > 0) {
+ VALUE c = rb_class_name(CLASS_OF(obj));
+ VALUE args[2] = {
+ rb_sprintf("-<%"PRIsVALUE":%p", c, (void*)obj),
+ ivars
+ };
+ return rb_exec_recursive(inspect_obj, obj, (VALUE)args);
}
else {
return rb_any_to_s(obj);
}
}
+/* :nodoc: */
+static VALUE
+rb_obj_instance_variables_to_inspect(VALUE obj)
+{
+ return Qnil;
+}
+
static VALUE
class_or_module_required(VALUE c)
{
@@ -791,7 +904,7 @@ rb_obj_is_instance_of(VALUE obj, VALUE c)
return RBOOL(rb_obj_class(obj) == c);
}
-// Returns whether c is a proper (c != cl) subclass of cl
+// Returns whether c is a proper (c != cl) superclass of cl
// Both c and cl must be T_CLASS
static VALUE
class_search_class_ancestor(VALUE cl, VALUE c)
@@ -804,7 +917,7 @@ class_search_class_ancestor(VALUE cl, VALUE c)
VALUE *classes = RCLASS_SUPERCLASSES(cl);
// If c's inheritance chain is longer, it cannot be an ancestor
- // We are checking for a proper subclass so don't check if they are equal
+ // We are checking for a proper superclass so don't check if they are equal
if (cl_depth <= c_depth)
return Qfalse;
@@ -1113,6 +1226,30 @@ rb_class_search_ancestor(VALUE cl, VALUE c)
*
* Added :FOO
*
+ * If we define a class using the <tt>class</tt> keyword, <tt>const_added</tt>
+ * runs before <tt>inherited</tt>:
+ *
+ * module M
+ * def self.const_added(const_name)
+ * super
+ * p :const_added
+ * end
+ *
+ * parent = Class.new do
+ * def self.inherited(subclass)
+ * super
+ * p :inherited
+ * end
+ * end
+ *
+ * class Child < parent
+ * end
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * :const_added
+ * :inherited
*/
#define rb_obj_mod_const_added rb_obj_dummy1
@@ -1277,6 +1414,10 @@ rb_obj_frozen_p(VALUE obj)
* - #to_r
* - #to_s
*
+ * While +nil+ doesn't have an explicitly defined #to_hash method,
+ * it can be used in <code>**</code> unpacking, not adding any
+ * keyword arguments.
+ *
* Another method provides inspection:
*
* - #inspect
@@ -1414,10 +1555,10 @@ rb_true_to_s(VALUE obj)
/*
- * call-seq:
- * true & object -> true or false
+ * call-seq:
+ * true & object -> true or false
*
- * Returns +false+ if +object+ is +false+ or +nil+, +true+ otherwise:
+ * Returns +false+ if +object+ is +false+ or +nil+, +true+ otherwise:
*
* true & Object.new # => true
* true & false # => false
@@ -1600,21 +1741,33 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
/*
* call-seq:
- * obj <=> other -> 0 or nil
+ * self <=> other -> 0 or nil
*
- * Returns 0 if +obj+ and +other+ are the same object
- * or <code>obj == other</code>, otherwise nil.
+ * Compares +self+ and +other+.
*
- * The #<=> is used by various methods to compare objects, for example
- * Enumerable#sort, Enumerable#max etc.
+ * Returns:
*
- * Your implementation of #<=> should return one of the following values: -1, 0,
- * 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
- * 1 means self is bigger than other. Nil means the two values could not be
- * compared.
+ * - +0+, if +self+ and +other+ are the same object,
+ * or if <tt>self == other</tt>.
+ * - +nil+, otherwise.
+ *
+ * Examples:
+ *
+ * o = Object.new
+ * o <=> o # => 0
+ * o <=> o.dup # => nil
+ *
+ * A class that includes module Comparable
+ * should override this method by defining an instance method that:
+ *
+ * - Take one argument, +other+.
+ * - Returns:
+ *
+ * - +-1+, if +self+ is less than +other+.
+ * - +0+, if +self+ is equal to +other+.
+ * - +1+, if +self+ is greater than +other+.
+ * - +nil+, if the two values are incommensurate.
*
- * When you define #<=>, you can include Comparable to gain the
- * methods #<=, #<, #==, #>=, #> and #between?.
*/
static VALUE
rb_obj_cmp(VALUE obj1, VALUE obj2)
@@ -1667,7 +1820,7 @@ rb_mod_to_s(VALUE klass)
ID id_defined_at;
VALUE refined_class, defined_at;
- if (FL_TEST(klass, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(klass)) {
VALUE s = rb_usascii_str_new2("#<Class:");
VALUE v = RCLASS_ATTACHED_OBJECT(klass);
@@ -1714,11 +1867,12 @@ rb_mod_freeze(VALUE mod)
/*
* call-seq:
- * mod === obj -> true or false
+ * self === other -> true or false
*
- * Case Equality---Returns <code>true</code> if <i>obj</i> is an
- * instance of <i>mod</i> or an instance of one of <i>mod</i>'s descendants.
- * Of limited use for modules, but can be used in <code>case</code> statements
+ * Returns whether +other+ is an instance of +self+,
+ * or is an instance of a subclass of +self+.
+ *
+ * Of limited use for modules, but can be used in +case+ statements
* to classify objects by class.
*/
@@ -1730,13 +1884,27 @@ rb_mod_eqq(VALUE mod, VALUE arg)
/*
* call-seq:
- * mod <= other -> true, false, or nil
+ * self <= other -> true, false, or nil
+ *
+ * Compares +self+ and +other+ with respect to ancestry and inclusion.
+ *
+ * Returns +nil+ if there is no such relationship between the two:
+ *
+ * Array <= Hash # => nil
+ *
+ * Otherwise, returns +true+ if +other+ is an ancestor of +self+,
+ * or if +self+ includes +other+,
+ * or if the two are the same:
+ *
+ * File <= IO # => true # IO is an ancestor of File.
+ * Array <= Enumerable # => true # Array includes Enumerable.
+ * Array <= Array # => true
+ *
+ * Otherwise, returns +false+:
+ *
+ * IO <= File # => false
+ * Enumerable <= Array # => false
*
- * Returns true if <i>mod</i> is a subclass of <i>other</i> or
- * is the same as <i>other</i>. Returns
- * <code>nil</code> if there's no relationship between the two.
- * (Think of the relationship in terms of the class definition:
- * "class A < B" implies "A < B".)
*/
VALUE
@@ -1782,14 +1950,26 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
/*
* call-seq:
- * mod < other -> true, false, or nil
+ * self < other -> true, false, or nil
+ *
+ * Returns +true+ if +self+ is a descendant of +other+
+ * (+self+ is a subclass of +other+ or +self+ includes +other+):
+ *
+ * Float < Numeric # => true
+ * Array < Enumerable # => true
*
- * Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
- * <code>false</code> if <i>mod</i> is the same as <i>other</i>
- * or <i>mod</i> is an ancestor of <i>other</i>.
- * Returns <code>nil</code> if there's no relationship between the two.
- * (Think of the relationship in terms of the class definition:
- * "class A < B" implies "A < B".)
+ * Returns +false+ if +self+ is an ancestor of +other+
+ * (+self+ is a superclass of +other+ or +self+ is included in +other+) or
+ * if +self+ is the same as +other+:
+ *
+ * Numeric < Float # => false
+ * Enumerable < Array # => false
+ * Float < Float # => false
+ *
+ * Returns +nil+ if there is no relationship between the two:
+ *
+ * Float < Hash # => nil
+ * Enumerable < String # => nil
*
*/
@@ -1803,13 +1983,28 @@ rb_mod_lt(VALUE mod, VALUE arg)
/*
* call-seq:
- * mod >= other -> true, false, or nil
+ * self >= other -> true, false, or nil
+ *
+ * Compares +self+ and +other+ with respect to ancestry and inclusion.
+ *
+ * Returns +true+ if +self+ is an ancestor of +other+
+ * (+self+ is a superclass of +other+ or +self+ is included in +other+) or
+ * if +self+ is the same as +other+:
+ *
+ * Numeric >= Float # => true
+ * Enumerable >= Array # => true
+ * Float >= Float # => true
+ *
+ * Returns +false+ if +self+ is a descendant of +other+
+ * (+self+ is a subclass of +other+ or +self+ includes +other+):
+ *
+ * Float >= Numeric # => false
+ * Array >= Enumerable # => false
+ *
+ * Returns +nil+ if there is no relationship between the two:
*
- * Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
- * two modules are the same. Returns
- * <code>nil</code> if there's no relationship between the two.
- * (Think of the relationship in terms of the class definition:
- * "class A < B" implies "B > A".)
+ * Float >= Hash # => nil
+ * Enumerable >= String # => nil
*
*/
@@ -1825,14 +2020,26 @@ rb_mod_ge(VALUE mod, VALUE arg)
/*
* call-seq:
- * mod > other -> true, false, or nil
+ * self > other -> true, false, or nil
*
- * Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
- * <code>false</code> if <i>mod</i> is the same as <i>other</i>
- * or <i>mod</i> is a descendant of <i>other</i>.
- * Returns <code>nil</code> if there's no relationship between the two.
- * (Think of the relationship in terms of the class definition:
- * "class A < B" implies "B > A".)
+ * Returns +true+ if +self+ is an ancestor of +other+
+ * (+self+ is a superclass of +other+ or +self+ is included in +other+):
+ *
+ * Numeric > Float # => true
+ * Enumerable > Array # => true
+ *
+ * Returns +false+ if +self+ is a descendant of +other+
+ * (+self+ is a subclass of +other+ or +self+ includes +other+) or
+ * if +self+ is the same as +other+:
+ *
+ * Float > Numeric # => false
+ * Array > Enumerable # => false
+ * Float > Float # => false
+ *
+ * Returns +nil+ if there is no relationship between the two:
+ *
+ * Float > Hash # => nil
+ * Enumerable > String # => nil
*
*/
@@ -1845,14 +2052,30 @@ rb_mod_gt(VALUE mod, VALUE arg)
/*
* call-seq:
- * module <=> other_module -> -1, 0, +1, or nil
+ * self <=> other -> -1, 0, 1, or nil
+ *
+ * Compares +self+ and +other+.
*
- * Comparison---Returns -1, 0, +1 or nil depending on whether +module+
- * includes +other_module+, they are the same, or if +module+ is included by
- * +other_module+.
+ * Returns:
+ *
+ * - +-1+, if +self+ includes +other+, if or +self+ is a subclass of +other+.
+ * - +0+, if +self+ and +other+ are the same.
+ * - +1+, if +other+ includes +self+, or if +other+ is a subclass of +self+.
+ * - +nil+, if none of the above is true.
+ *
+ * Examples:
+ *
+ * # Class Array includes module Enumerable.
+ * Array <=> Enumerable # => -1
+ * Enumerable <=> Enumerable # => 0
+ * Enumerable <=> Array # => 1
+ * # Class File is a subclass of class IO.
+ * File <=> IO # => -1
+ * File <=> File # => 0
+ * IO <=> File # => 1
+ * # Class File has no relationship to class String.
+ * File <=> String # => nil
*
- * Returns +nil+ if +module+ has no relationship with +other_module+, if
- * +other_module+ is not a module, or if the two values are incomparable.
*/
static VALUE
@@ -1877,28 +2100,52 @@ static VALUE rb_mod_initialize_exec(VALUE module);
/*
* call-seq:
- * Module.new -> mod
- * Module.new {|mod| block } -> mod
+ * Module.new -> new_module
+ * Module.new {|module| ... } -> new_module
*
- * Creates a new anonymous module. If a block is given, it is passed
- * the module object, and the block is evaluated in the context of this
- * module like #module_eval.
+ * Returns a new anonymous module.
*
- * fred = Module.new do
- * def meth1
- * "hello"
- * end
- * def meth2
- * "bye"
- * end
- * end
- * a = "my string"
- * a.extend(fred) #=> "my string"
- * a.meth1 #=> "hello"
- * a.meth2 #=> "bye"
+ * The module may be assigned to a name,
+ * which should be a constant name
+ * in capitalized {camel case}[https://en.wikipedia.org/wiki/Camel_case]
+ * (e.g., +MyModule+, not +MY_MODULE+).
+ *
+ * With no block given, returns the new module.
+ *
+ * MyModule = Module.new
+ * MyModule.class # => Module
+ * MyModule.name # => "MyModule"
+ *
+ * With a block given, calls the block with the new (not yet named) module:
+ *
+ * MyModule = Module.new {|m| p [m.class, m.name] }
+ * # => MyModule
+ * MyModule.class # => Module
+ MyModule.name # => "MyModule"
+ *
+ * Output (from the block):
+ *
+ * [Module, nil]
+ *
+ * The block may define methods and constants for the module:
+ *
+ * MyModule = Module.new do |m|
+ * MY_CONSTANT = "#{MyModule} constant value"
+ * def self.method1 = "#{MyModule} first method (singleton)"
+ * def method2 = "#{MyModule} Second method (instance)"
+ * end
+ * MyModule.method1 # => "MyModule first method (singleton)"
+ * class Foo
+ * include MyModule
+ * def speak
+ * MY_CONSTANT
+ * end
+ * end
+ * foo = Foo.new
+ * foo.method2 # => "MyModule Second method (instance)"
+ * foo.speak
+ * # => "MyModule constant value"
*
- * Assign the module to a constant (name starting uppercase) if you
- * want to treat it like a regular module.
*/
static VALUE
@@ -1972,11 +2219,13 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
else {
super = argv[0];
rb_check_inheritable(super);
- if (super != rb_cBasicObject && !RCLASS_SUPER(super)) {
+ if (!RCLASS_INITIALIZED_P(super)) {
rb_raise(rb_eTypeError, "can't inherit uninitialized class");
}
}
- RCLASS_SET_SUPER(klass, super);
+ rb_class_set_super(klass, super);
+ RCLASS_SET_MAX_IV_COUNT(klass, RCLASS_MAX_IV_COUNT(super));
+ RCLASS_SET_ALLOCATOR(klass, RCLASS_ALLOCATOR(super));
rb_make_metaclass(klass, RBASIC(super)->klass);
rb_class_inherited(super, klass);
rb_mod_initialize_exec(klass);
@@ -2018,19 +2267,9 @@ static VALUE class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass);
*/
static VALUE
-rb_class_alloc_m(VALUE klass)
-{
- rb_alloc_func_t allocator = class_get_alloc_func(klass);
- if (!rb_obj_respond_to(klass, rb_intern("allocate"), 1)) {
- rb_raise(rb_eTypeError, "calling %"PRIsVALUE".allocate is prohibited",
- klass);
- }
- return class_call_alloc_func(allocator, klass);
-}
-
-static VALUE
rb_class_alloc(VALUE klass)
{
+ RBIMPL_ASSERT_TYPE(klass, T_CLASS);
rb_alloc_func_t allocator = class_get_alloc_func(klass);
return class_call_alloc_func(allocator, klass);
}
@@ -2040,10 +2279,10 @@ class_get_alloc_func(VALUE klass)
{
rb_alloc_func_t allocator;
- if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) {
+ if (!RCLASS_INITIALIZED_P(klass)) {
rb_raise(rb_eTypeError, "can't instantiate uninitialized class");
}
- if (FL_TEST(klass, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(klass)) {
rb_raise(rb_eTypeError, "can't create instance of singleton class");
}
allocator = rb_get_alloc_func(klass);
@@ -2053,6 +2292,15 @@ class_get_alloc_func(VALUE klass)
return allocator;
}
+// Might return NULL.
+rb_alloc_func_t
+rb_zjit_class_get_alloc_func(VALUE klass)
+{
+ assert(RCLASS_INITIALIZED_P(klass));
+ assert(!RCLASS_SINGLETON_P(klass));
+ return rb_get_alloc_func(klass);
+}
+
static VALUE
class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass)
{
@@ -2062,9 +2310,7 @@ class_call_alloc_func(rb_alloc_func_t allocator, VALUE klass)
obj = (*allocator)(klass);
- if (rb_obj_class(obj) != rb_class_real(klass)) {
- rb_raise(rb_eTypeError, "wrong instance allocation");
- }
+ RUBY_ASSERT(rb_obj_class(obj) == rb_class_real(klass));
return obj;
}
@@ -2133,12 +2379,12 @@ rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
* BasicObject.superclass #=> nil
*
*--
- * Returns the superclass of \a klass. Equivalent to \c Class\#superclass in Ruby.
+ * Returns the superclass of `klass`. Equivalent to `Class#superclass` in Ruby.
*
* It skips modules.
- * \param[in] klass a Class object
- * \return the superclass, or \c Qnil if \a klass does not have a parent class.
- * \sa rb_class_get_superclass
+ * @param[in] klass a Class object
+ * @return the superclass, or `Qnil` if `klass` does not have a parent class.
+ * @sa rb_class_get_superclass
*++
*/
@@ -2147,15 +2393,22 @@ rb_class_superclass(VALUE klass)
{
RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
- VALUE super = RCLASS_SUPER(klass);
+ VALUE *superclasses = RCLASS_SUPERCLASSES(klass);
+ size_t superclasses_depth = RCLASS_SUPERCLASS_DEPTH(klass);
- if (!super) {
- if (klass == rb_cBasicObject) return Qnil;
+ if (klass == rb_cBasicObject) return Qnil;
+
+ if (!superclasses) {
+ RUBY_ASSERT(!RCLASS_SUPER(klass));
rb_raise(rb_eTypeError, "uninitialized class");
}
+
+ if (!superclasses_depth) {
+ return Qnil;
+ }
else {
- super = RCLASS_SUPERCLASSES(klass)[RCLASS_SUPERCLASS_DEPTH(klass) - 1];
- RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
+ VALUE super = superclasses[superclasses_depth - 1];
+ RUBY_ASSERT(RB_TYPE_P(super, T_CLASS));
return super;
}
}
@@ -2163,13 +2416,13 @@ rb_class_superclass(VALUE klass)
VALUE
rb_class_get_superclass(VALUE klass)
{
- return RCLASS(klass)->super;
+ return RCLASS_SUPER(klass);
}
-static const char bad_instance_name[] = "`%1$s' is not allowed as an instance variable name";
-static const char bad_class_name[] = "`%1$s' is not allowed as a class variable name";
+static const char bad_instance_name[] = "'%1$s' is not allowed as an instance variable name";
+static const char bad_class_name[] = "'%1$s' is not allowed as a class variable name";
static const char bad_const_name[] = "wrong constant name %1$s";
-static const char bad_attr_name[] = "invalid attribute name `%1$s'";
+static const char bad_attr_name[] = "invalid attribute name '%1$s'";
#define wrong_constant_name bad_const_name
/*! \private */
@@ -3000,7 +3253,7 @@ rb_mod_cvar_defined(VALUE obj, VALUE iv)
static VALUE
rb_mod_singleton_p(VALUE klass)
{
- return RBOOL(RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON));
+ return RBOOL(RCLASS_SINGLETON_P(klass));
}
/*! \private */
@@ -3049,19 +3302,12 @@ convert_type_with_id(VALUE val, const char *tname, ID method, int raise, int ind
VALUE r = rb_check_funcall(val, method, 0, 0);
if (UNDEF_P(r)) {
if (raise) {
- const char *msg =
- ((index < 0 ? conv_method_index(rb_id2name(method)) : index)
- < IMPLICIT_CONVERSIONS) ?
- "no implicit conversion of" : "can't convert";
- const char *cname = NIL_P(val) ? "nil" :
- val == Qtrue ? "true" :
- val == Qfalse ? "false" :
- NULL;
- if (cname)
- rb_raise(rb_eTypeError, "%s %s into %s", msg, cname, tname);
- rb_raise(rb_eTypeError, "%s %"PRIsVALUE" into %s", msg,
- rb_obj_class(val),
- tname);
+ if ((index < 0 ? conv_method_index(rb_id2name(method)) : index) < IMPLICIT_CONVERSIONS) {
+ rb_no_implicit_conversion(val, tname);
+ }
+ else {
+ rb_cant_convert(val, tname);
+ }
}
return Qnil;
}
@@ -3077,17 +3323,6 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
return convert_type_with_id(val, tname, m, raise, i);
}
-/*! \private */
-NORETURN(static void conversion_mismatch(VALUE, const char *, const char *, VALUE));
-static void
-conversion_mismatch(VALUE val, const char *tname, const char *method, VALUE result)
-{
- VALUE cname = rb_obj_class(val);
- rb_raise(rb_eTypeError,
- "can't convert %"PRIsVALUE" to %s (%"PRIsVALUE"#%s gives %"PRIsVALUE")",
- cname, tname, cname, method, rb_obj_class(result));
-}
-
VALUE
rb_convert_type(VALUE val, int type, const char *tname, const char *method)
{
@@ -3096,7 +3331,7 @@ rb_convert_type(VALUE val, int type, const char *tname, const char *method)
if (TYPE(val) == type) return val;
v = convert_type(val, tname, method, TRUE);
if (TYPE(v) != type) {
- conversion_mismatch(val, tname, method, v);
+ rb_cant_convert_invalid_return(val, tname, method, v);
}
return v;
}
@@ -3110,7 +3345,7 @@ rb_convert_type_with_id(VALUE val, int type, const char *tname, ID method)
if (TYPE(val) == type) return val;
v = convert_type_with_id(val, tname, method, TRUE, -1);
if (TYPE(v) != type) {
- conversion_mismatch(val, tname, RSTRING_PTR(rb_id2str(method)), v);
+ rb_cant_convert_invalid_return(val, tname, rb_id2name(method), v);
}
return v;
}
@@ -3125,7 +3360,7 @@ rb_check_convert_type(VALUE val, int type, const char *tname, const char *method
v = convert_type(val, tname, method, FALSE);
if (NIL_P(v)) return Qnil;
if (TYPE(v) != type) {
- conversion_mismatch(val, tname, method, v);
+ rb_cant_convert_invalid_return(val, tname, method, v);
}
return v;
}
@@ -3141,7 +3376,7 @@ rb_check_convert_type_with_id(VALUE val, int type, const char *tname, ID method)
v = convert_type_with_id(val, tname, method, FALSE, -1);
if (NIL_P(v)) return Qnil;
if (TYPE(v) != type) {
- conversion_mismatch(val, tname, RSTRING_PTR(rb_id2str(method)), v);
+ rb_cant_convert_invalid_return(val, tname, rb_id2name(method), v);
}
return v;
}
@@ -3154,14 +3389,22 @@ ALWAYS_INLINE(static VALUE rb_to_integer_with_id_exception(VALUE val, const char
static inline VALUE
rb_to_integer_with_id_exception(VALUE val, const char *method, ID mid, int raise)
{
+ // We need to pop the lazily pushed frame when not raising an exception.
+ rb_control_frame_t *current_cfp;
VALUE v;
if (RB_INTEGER_TYPE_P(val)) return val;
+ current_cfp = GET_EC()->cfp;
+ rb_yjit_lazy_push_frame(GET_EC()->cfp->pc);
v = try_to_int(val, mid, raise);
- if (!raise && NIL_P(v)) return Qnil;
+ if (!raise && NIL_P(v)) {
+ GET_EC()->cfp = current_cfp;
+ return Qnil;
+ }
if (!RB_INTEGER_TYPE_P(v)) {
- conversion_mismatch(val, "Integer", method, v);
+ rb_cant_convert_invalid_return(val, "Integer", method, v);
}
+ GET_EC()->cfp = current_cfp;
return v;
}
#define rb_to_integer(val, method, mid) \
@@ -3236,7 +3479,7 @@ rb_convert_to_integer(VALUE val, int base, int raise_exception)
}
else if (NIL_P(val)) {
if (!raise_exception) return Qnil;
- rb_raise(rb_eTypeError, "can't convert nil into Integer");
+ rb_cant_convert(val, "Integer");
}
tmp = rb_protect(rb_check_to_int, val, NULL);
@@ -3296,125 +3539,28 @@ rb_opts_exception_p(VALUE opts, int default_value)
return default_value;
}
-#define opts_exception_p(opts) rb_opts_exception_p((opts), TRUE)
-
-/*
- * call-seq:
- * Integer(object, base = 0, exception: true) -> integer or nil
- *
- * Returns an integer converted from +object+.
- *
- * Tries to convert +object+ to an integer
- * using +to_int+ first and +to_i+ second;
- * see below for exceptions.
- *
- * With a non-zero +base+, +object+ must be a string or convertible
- * to a string.
- *
- * ==== numeric objects
- *
- * With integer argument +object+ given, returns +object+:
- *
- * Integer(1) # => 1
- * Integer(-1) # => -1
- *
- * With floating-point argument +object+ given,
- * returns +object+ truncated to an integer:
- *
- * Integer(1.9) # => 1 # Rounds toward zero.
- * Integer(-1.9) # => -1 # Rounds toward zero.
- *
- * ==== string objects
- *
- * With string argument +object+ and zero +base+ given,
- * returns +object+ converted to an integer in base 10:
- *
- * Integer('100') # => 100
- * Integer('-100') # => -100
- *
- * With +base+ zero, string +object+ may contain leading characters
- * to specify the actual base (radix indicator):
- *
- * Integer('0100') # => 64 # Leading '0' specifies base 8.
- * Integer('0b100') # => 4 # Leading '0b', specifies base 2.
- * Integer('0x100') # => 256 # Leading '0x' specifies base 16.
- *
- * With a positive +base+ (in range 2..36) given, returns +object+
- * converted to an integer in the given base:
- *
- * Integer('100', 2) # => 4
- * Integer('100', 8) # => 64
- * Integer('-100', 16) # => -256
- *
- * With a negative +base+ (in range -36..-2) given, returns +object+
- * converted to an integer in the radix indicator if exists or
- * +-base+:
- *
- * Integer('0x100', -2) # => 256
- * Integer('100', -2) # => 4
- * Integer('0b100', -8) # => 4
- * Integer('100', -8) # => 64
- * Integer('0o100', -10) # => 64
- * Integer('100', -10) # => 100
- *
- * +base+ -1 is equal the -10 case.
- *
- * When converting strings, surrounding whitespace and embedded underscores
- * are allowed and ignored:
- *
- * Integer(' 100 ') # => 100
- * Integer('-1_0_0', 16) # => -256
- *
- * ==== other classes
- *
- * Examples with +object+ of various other classes:
- *
- * Integer(Rational(9, 10)) # => 0 # Rounds toward zero.
- * Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero.
- * Integer(Time.now) # => 1650974042
- *
- * ==== keywords
- *
- * With optional keyword argument +exception+ given as +true+ (the default):
- *
- * - Raises TypeError if +object+ does not respond to +to_int+ or +to_i+.
- * - Raises TypeError if +object+ is +nil+.
- * - Raise ArgumentError if +object+ is an invalid string.
- *
- * With +exception+ given as +false+, an exception of any kind is suppressed
- * and +nil+ is returned.
- *
- */
-
static VALUE
-rb_f_integer(int argc, VALUE *argv, VALUE obj)
+rb_f_integer1(rb_execution_context_t *ec, VALUE obj, VALUE arg)
{
- VALUE arg = Qnil, opts = Qnil;
- int base = 0;
+ return rb_convert_to_integer(arg, 0, TRUE);
+}
- if (argc > 1) {
- int narg = 1;
- VALUE vbase = rb_check_to_int(argv[1]);
- if (!NIL_P(vbase)) {
- base = NUM2INT(vbase);
- narg = 2;
- }
- if (argc > narg) {
- VALUE hash = rb_check_hash_type(argv[argc-1]);
- if (!NIL_P(hash)) {
- opts = rb_extract_keywords(&hash);
- if (!hash) --argc;
- }
- }
- }
- rb_check_arity(argc, 1, 2);
- arg = argv[0];
+static VALUE
+rb_f_integer(rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE base, VALUE exception)
+{
+ int exc = rb_bool_expected(exception, "exception", TRUE);
+ return rb_convert_to_integer(arg, NUM2INT(base), exc);
+}
- return rb_convert_to_integer(arg, base, opts_exception_p(opts));
+static bool
+is_digit_char(unsigned char c, int base)
+{
+ int i = ruby_digit36_to_number_table[c];
+ return (i >= 0 && i < base);
}
static double
-rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
+rb_cstr_to_dbl_raise(const char *p, rb_encoding *enc, int badcheck, int raise, int *error)
{
const char *q;
char *end;
@@ -3425,6 +3571,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
#define OutOfRange() ((end - p > max_width) ? \
(w = max_width, ellipsis = "...") : \
(w = (int)(end - p), ellipsis = ""))
+ /* p...end has been parsed with strtod, should be ASCII-only */
if (!p) return 0.0;
q = p;
@@ -3453,23 +3600,37 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
char *e = init_e;
char prev = 0;
int dot_seen = FALSE;
+ int base = 10;
+ char exp_letter = 'e';
switch (*p) {case '+': case '-': prev = *n++ = *p++;}
if (*p == '0') {
prev = *n++ = '0';
- while (*++p == '0');
+ switch (*++p) {
+ case 'x': case 'X':
+ prev = *n++ = 'x';
+ base = 16;
+ exp_letter = 'p';
+ if (*++p != '0') break;
+ /* fallthrough */
+ case '0': /* squeeze successive zeros */
+ while (*++p == '0');
+ break;
+ }
}
while (p < end && n < e) prev = *n++ = *p++;
while (*p) {
if (*p == '_') {
/* remove an underscore between digits */
- if (n == buf || !ISDIGIT(prev) || (++p, !ISDIGIT(*p))) {
+ if (n == buf ||
+ !is_digit_char(prev, base) ||
+ !is_digit_char(*++p, base)) {
if (badcheck) goto bad;
break;
}
}
prev = *p++;
- if (e == init_e && (prev == 'e' || prev == 'E' || prev == 'p' || prev == 'P')) {
+ if (e == init_e && (rb_tolower(prev) == exp_letter)) {
e = buf + sizeof(buf) - 1;
*n++ = prev;
switch (*p) {case '+': case '-': prev = *n++ = *p++;}
@@ -3477,6 +3638,10 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
prev = *n++ = '0';
while (*++p == '0');
}
+
+ /* reset base to decimal for underscore check of
+ * binary exponent part */
+ base = 10;
continue;
}
else if (ISSPACE(prev)) {
@@ -3486,7 +3651,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
break;
}
}
- else if (prev == '.' ? dot_seen++ : !ISDIGIT(prev)) {
+ else if (prev == '.' ? dot_seen++ : !is_digit_char(prev, base)) {
if (badcheck) goto bad;
break;
}
@@ -3520,7 +3685,8 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
bad:
if (raise) {
- rb_invalid_str(q, "Float()");
+ VALUE s = rb_enc_str_new_cstr(q, enc);
+ rb_raise(rb_eArgError, "invalid value for Float(): %+"PRIsVALUE, s);
UNREACHABLE_RETURN(nan(""));
}
else {
@@ -3532,7 +3698,7 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
double
rb_cstr_to_dbl(const char *p, int badcheck)
{
- return rb_cstr_to_dbl_raise(p, badcheck, TRUE, NULL);
+ return rb_cstr_to_dbl_raise(p, NULL, badcheck, TRUE, NULL);
}
static double
@@ -3544,6 +3710,7 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
VALUE v = 0;
StringValue(str);
+ rb_must_asciicompat(str);
s = RSTRING_PTR(str);
len = RSTRING_LEN(str);
if (s) {
@@ -3562,9 +3729,11 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
s = p;
}
}
- ret = rb_cstr_to_dbl_raise(s, badcheck, raise, error);
+ ret = rb_cstr_to_dbl_raise(s, rb_enc_get(str), badcheck, raise, error);
if (v)
ALLOCV_END(v);
+ else
+ RB_GC_GUARD(str);
return ret;
}
@@ -3604,18 +3773,6 @@ rat2dbl_without_to_f(VALUE x)
}
/*! \endcond */
-static inline void
-conversion_to_float(VALUE val)
-{
- special_const_to_float(val, "can't convert ", " into Float");
-}
-
-static inline void
-implicit_conversion_to_float(VALUE val)
-{
- special_const_to_float(val, "no implicit conversion to float from ", "");
-}
-
static int
to_float(VALUE *valp, int raise_exception)
{
@@ -3629,7 +3786,7 @@ to_float(VALUE *valp, int raise_exception)
return T_FLOAT;
}
else if (raise_exception) {
- conversion_to_float(val);
+ rb_cant_convert(val, "Float");
}
}
else {
@@ -3709,8 +3866,7 @@ static VALUE
numeric_to_float(VALUE val)
{
if (!rb_obj_is_kind_of(val, rb_cNumeric)) {
- rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into Float",
- rb_obj_class(val));
+ rb_cant_convert(val, "Float");
}
return rb_convert_type_with_id(val, T_FLOAT, "Float", id_to_f);
}
@@ -3754,7 +3910,7 @@ rb_num_to_dbl(VALUE val)
return rb_float_flonum_value(val);
}
else {
- conversion_to_float(val);
+ rb_cant_convert(val, "Float");
}
}
else {
@@ -3788,7 +3944,7 @@ rb_num2dbl(VALUE val)
return rb_float_flonum_value(val);
}
else {
- implicit_conversion_to_float(val);
+ rb_no_implicit_conversion(val, "Float");
}
}
else {
@@ -3800,7 +3956,7 @@ rb_num2dbl(VALUE val)
case T_RATIONAL:
return rat2dbl_without_to_f(val);
case T_STRING:
- rb_raise(rb_eTypeError, "no implicit conversion to float from string");
+ rb_no_implicit_conversion(val, "Float");
default:
break;
}
@@ -3830,7 +3986,7 @@ rb_String(VALUE val)
*
* String([0, 1, 2]) # => "[0, 1, 2]"
* String(0..5) # => "0..5"
- * String({foo: 0, bar: 1}) # => "{:foo=>0, :bar=>1}"
+ * String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}"
*
* Raises +TypeError+ if +object+ cannot be converted to a string.
*/
@@ -3894,7 +4050,7 @@ rb_Hash(VALUE val)
if (NIL_P(tmp)) {
if (RB_TYPE_P(val, T_ARRAY) && RARRAY_LEN(val) == 0)
return rb_hash_new();
- rb_raise(rb_eTypeError, "can't convert %s into Hash", rb_obj_classname(val));
+ rb_cant_convert(val, "Hash");
}
return tmp;
}
@@ -3915,7 +4071,7 @@ rb_Hash(VALUE val)
*
* Examples:
*
- * Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1}
+ * Hash({foo: 0, bar: 1}) # => {foo: 0, bar: 1}
* Hash(nil) # => {}
* Hash([]) # => {}
*
@@ -4002,7 +4158,7 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
* into +format_string+.
*
* For details on +format_string+, see
- * {Format Specifications}[rdoc-ref:format_specifications.rdoc].
+ * {Format Specifications}[rdoc-ref:language/format_specifications.rdoc].
*/
static VALUE
@@ -4011,6 +4167,12 @@ f_sprintf(int c, const VALUE *v, VALUE _)
return rb_f_sprintf(c, v);
}
+static VALUE
+rb_f_loop_size(VALUE self, VALUE args, VALUE eobj)
+{
+ return DBL2NUM(HUGE_VAL);
+}
+
/*
* Document-class: Class
*
@@ -4073,57 +4235,51 @@ f_sprintf(int c, const VALUE *v, VALUE _)
*/
-/* Document-class: BasicObject
+/*
+ * Document-class: BasicObject
*
- * BasicObject is the parent class of all classes in Ruby. It's an explicit
- * blank class.
+ * +BasicObject+ is the parent class of all classes in Ruby.
+ * In particular, +BasicObject+ is the parent class of class Object,
+ * which is itself the default parent class of every Ruby class:
*
- * BasicObject can be used for creating object hierarchies independent of
- * Ruby's object hierarchy, proxy objects like the Delegator class, or other
- * uses where namespace pollution from Ruby's methods and classes must be
- * avoided.
+ * class Foo; end
+ * Foo.superclass # => Object
+ * Object.superclass # => BasicObject
*
- * To avoid polluting BasicObject for other users an appropriately named
- * subclass of BasicObject should be created instead of directly modifying
- * BasicObject:
+ * +BasicObject+ is the only class that has no parent:
*
- * class MyObjectSystem < BasicObject
- * end
+ * BasicObject.superclass # => nil
*
- * BasicObject does not include Kernel (for methods like +puts+) and
- * BasicObject is outside of the namespace of the standard library so common
- * classes will not be found without using a full class path.
+ * Class +BasicObject+ can be used to create an object hierarchy
+ * (e.g., class Delegator) that is independent of Ruby's object hierarchy.
+ * Such objects:
*
- * A variety of strategies can be used to provide useful portions of the
- * standard library to subclasses of BasicObject. A subclass could
- * <code>include Kernel</code> to obtain +puts+, +exit+, etc. A custom
- * Kernel-like module could be created and included or delegation can be used
- * via #method_missing:
+ * - Do not have namespace "pollution" from the many methods
+ * provided in class Object and its included module Kernel.
+ * - Do not have definitions of common classes,
+ * and so references to such common classes must be fully qualified
+ * (+::String+, not +String+).
*
- * class MyObjectSystem < BasicObject
- * DELEGATE = [:puts, :p]
+ * A variety of strategies can be used to provide useful portions
+ * of the Standard Library in subclasses of +BasicObject+:
*
- * def method_missing(name, *args, &block)
- * return super unless DELEGATE.include? name
- * ::Kernel.send(name, *args, &block)
- * end
+ * - The immediate subclass could <tt>include Kernel</tt>,
+ * which would define methods such as +puts+, +exit+, etc.
+ * - A custom Kernel-like module could be created and included.
+ * - Delegation can be used via #method_missing:
*
- * def respond_to_missing?(name, include_private = false)
- * DELEGATE.include?(name) or super
- * end
- * end
+ * class MyObjectSystem < BasicObject
+ * DELEGATE = [:puts, :p]
*
- * Access to classes and modules from the Ruby standard library can be
- * obtained in a BasicObject subclass by referencing the desired constant
- * from the root like <code>::File</code> or <code>::Enumerator</code>.
- * Like #method_missing, #const_missing can be used to delegate constant
- * lookup to +Object+:
+ * def method_missing(name, *args, &block)
+ * return super unless DELEGATE.include? name
+ * ::Kernel.send(name, *args, &block)
+ * end
*
- * class MyObjectSystem < BasicObject
- * def self.const_missing(name)
- * ::Object.const_get(name)
+ * def respond_to_missing?(name, include_private = false)
+ * DELEGATE.include?(name)
+ * end
* end
- * end
*
* === What's Here
*
@@ -4137,8 +4293,11 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* - #__send__: Calls the method identified by the given symbol.
* - #equal?: Returns whether +self+ and the given object are the same object.
* - #instance_eval: Evaluates the given string or block in the context of +self+.
- * - #instance_exec: Executes the given block in the context of +self+,
- * passing the given arguments.
+ * - #instance_exec: Executes the given block in the context of +self+, passing the given arguments.
+ * - #method_missing: Called when +self+ is called with a method it does not define.
+ * - #singleton_method_added: Called when a singleton method is added to +self+.
+ * - #singleton_method_removed: Called when a singleton method is removed from +self+.
+ * - #singleton_method_undefined: Called when a singleton method is undefined in +self+.
*
*/
@@ -4162,10 +4321,10 @@ f_sprintf(int c, const VALUE *v, VALUE _)
*
* == What's Here
*
- * First, what's elsewhere. \Class \Object:
+ * First, what's elsewhere. Class \Object:
*
- * - Inherits from {class BasicObject}[rdoc-ref:BasicObject@What-27s+Here].
- * - Includes {module Kernel}[rdoc-ref:Kernel@What-27s+Here].
+ * - Inherits from {class BasicObject}[rdoc-ref:BasicObject@Whats+Here].
+ * - Includes {module Kernel}[rdoc-ref:Kernel@Whats+Here].
*
* Here, class \Object provides methods for:
*
@@ -4186,7 +4345,7 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* - #instance_of?: Returns whether +self+ is an instance of the given class.
* - #instance_variable_defined?: Returns whether the given instance variable
* is defined in +self+.
- * - #method: Returns the Method object for the given method in +self+.
+ * - #method: Returns the +Method+ object for the given method in +self+.
* - #methods: Returns an array of symbol names of public and protected methods
* in +self+.
* - #nil?: Returns +false+. (Only +nil+ responds +true+ to method <tt>nil?</tt>.)
@@ -4196,12 +4355,12 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* of the private methods in +self+.
* - #protected_methods: Returns an array of the symbol names
* of the protected methods in +self+.
- * - #public_method: Returns the Method object for the given public method in +self+.
+ * - #public_method: Returns the +Method+ object for the given public method in +self+.
* - #public_methods: Returns an array of the symbol names
* of the public methods in +self+.
* - #respond_to?: Returns whether +self+ responds to the given method.
* - #singleton_class: Returns the singleton class of +self+.
- * - #singleton_method: Returns the Method object for the given singleton method
+ * - #singleton_method: Returns the +Method+ object for the given singleton method
* in +self+.
* - #singleton_methods: Returns an array of the symbol names
* of the singleton methods in +self+.
@@ -4228,7 +4387,7 @@ f_sprintf(int c, const VALUE *v, VALUE _)
* and frozen state.
* - #define_singleton_method: Defines a singleton method in +self+
* for the given symbol method-name and block or proc.
- * - #display: Prints +self+ to the given \IO stream or <tt>$stdout</tt>.
+ * - #display: Prints +self+ to the given IO stream or <tt>$stdout</tt>.
* - #dup: Returns a shallow unfrozen copy of +self+.
* - #enum_for (aliased as #to_enum): Returns an Enumerator for +self+
* using the using the given method, arguments, and block.
@@ -4259,7 +4418,6 @@ InitVM_Object(void)
#endif
rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_initialize, 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);
@@ -4282,7 +4440,7 @@ InitVM_Object(void)
*
* == What's Here
*
- * \Module \Kernel provides methods that are useful for:
+ * Module \Kernel provides methods that are useful for:
*
* - {Converting}[rdoc-ref:Kernel@Converting]
* - {Querying}[rdoc-ref:Kernel@Querying]
@@ -4350,7 +4508,7 @@ InitVM_Object(void)
* - #print: Prints the given objects to standard output without a newline.
* - #printf: Prints the string resulting from applying the given format string
* to any additional arguments.
- * - #putc: Equivalent to <tt.$stdout.putc(object)</tt> for the given object.
+ * - #putc: Equivalent to <tt>$stdout.putc(object)</tt> for the given object.
* - #puts: Equivalent to <tt>$stdout.puts(*objects)</tt> for the given objects.
* - #readline: Similar to #gets, but raises an exception at the end of file.
* - #readlines: Returns an array of the remaining lines from the current input.
@@ -4440,6 +4598,7 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0);
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
+ rb_define_private_method(rb_mKernel, "instance_variables_to_inspect", rb_obj_instance_variables_to_inspect, 0);
rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1); /* in class.c */
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); /* in class.c */
@@ -4459,15 +4618,13 @@ InitVM_Object(void)
rb_define_global_function("sprintf", f_sprintf, -1);
rb_define_global_function("format", f_sprintf, -1);
- rb_define_global_function("Integer", rb_f_integer, -1);
-
rb_define_global_function("String", rb_f_string, 1);
rb_define_global_function("Array", rb_f_array, 1);
rb_define_global_function("Hash", rb_f_hash, 1);
rb_cNilClass = rb_define_class("NilClass", rb_cObject);
rb_cNilClass_to_s = rb_fstring_enc_lit("", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cNilClass_to_s);
+ rb_vm_register_global_object(rb_cNilClass_to_s);
rb_define_method(rb_cNilClass, "to_s", rb_nil_to_s, 0);
rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0);
rb_define_method(rb_cNilClass, "to_h", nil_to_h, 0);
@@ -4490,12 +4647,12 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "<=", rb_class_inherited_p, 1);
rb_define_method(rb_cModule, ">", rb_mod_gt, 1);
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_alias(rb_cModule, "inspect", "to_s");
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, "set_temporary_name", rb_mod_set_temporary_name, 1); /* in variable.c */
rb_define_method(rb_cModule, "ancestors", rb_mod_ancestors, 0); /* in class.c */
rb_define_method(rb_cModule, "attr", rb_mod_attr, -1);
@@ -4538,8 +4695,8 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
- rb_define_method(rb_singleton_class(rb_cClass), "allocate", rb_class_alloc_m, 0);
- rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0);
+ rb_define_method(rb_singleton_class(rb_cClass), "allocate", rb_class_alloc, 0);
+ rb_define_method(rb_cClass, "allocate", rb_class_alloc, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance_pass_kw, -1);
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
@@ -4552,7 +4709,7 @@ InitVM_Object(void)
rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
rb_cTrueClass_to_s = rb_fstring_enc_lit("true", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cTrueClass_to_s);
+ rb_vm_register_global_object(rb_cTrueClass_to_s);
rb_define_method(rb_cTrueClass, "to_s", rb_true_to_s, 0);
rb_define_alias(rb_cTrueClass, "inspect", "to_s");
rb_define_method(rb_cTrueClass, "&", true_and, 1);
@@ -4564,7 +4721,7 @@ InitVM_Object(void)
rb_cFalseClass = rb_define_class("FalseClass", rb_cObject);
rb_cFalseClass_to_s = rb_fstring_enc_lit("false", rb_usascii_encoding());
- rb_gc_register_mark_object(rb_cFalseClass_to_s);
+ rb_vm_register_global_object(rb_cFalseClass_to_s);
rb_define_method(rb_cFalseClass, "to_s", rb_false_to_s, 0);
rb_define_alias(rb_cFalseClass, "inspect", "to_s");
rb_define_method(rb_cFalseClass, "&", false_and, 1);
@@ -4582,6 +4739,7 @@ void
Init_Object(void)
{
id_dig = rb_intern_const("dig");
+ id_instance_variables_to_inspect = rb_intern_const("instance_variables_to_inspect");
InitVM(Object);
}
diff --git a/pack.c b/pack.c
index d5b78b6060..24221bc3d6 100644
--- a/pack.c
+++ b/pack.c
@@ -19,6 +19,7 @@
#include "internal.h"
#include "internal/array.h"
#include "internal/bits.h"
+#include "internal/numeric.h"
#include "internal/string.h"
#include "internal/symbol.h"
#include "internal/variable.h"
@@ -36,10 +37,11 @@
*/
#ifdef HAVE_TRUE_LONG_LONG
static const char natstr[] = "sSiIlLqQjJ";
+# define endstr natstr
#else
static const char natstr[] = "sSiIlLjJ";
-#endif
static const char endstr[] = "sSiIlLqQjJ";
+#endif
#ifdef HAVE_TRUE_LONG_LONG
/* It is intentional to use long long instead of LONG_LONG. */
@@ -60,7 +62,7 @@ is_bigendian(void)
{
static int init = 0;
static int endian_value;
- char *p;
+ const char *p;
if (init) return endian_value;
init = 1;
@@ -117,6 +119,7 @@ typedef union {
#define MAX_INTEGER_PACK_SIZE 8
static const char toofew[] = "too few arguments";
+static const char intoitself[] = "cannot pack buffer object into itself";
static void encodes(VALUE,const char*,long,int,int);
static void qpencode(VALUE,VALUE,long);
@@ -192,20 +195,69 @@ VALUE_to_float(VALUE obj)
}
}
+static void
+str_expand_fill(VALUE res, int c, long len)
+{
+ long olen = RSTRING_LEN(res);
+ memset(RSTRING_PTR(res) + olen, c, len);
+ rb_str_set_len(res, olen + len);
+}
+
+static char *
+skip_to_eol(const char *p, const char *pend)
+{
+ p = memchr(p, '\n', pend - p);
+ return (char *)(p ? p + 1 : pend);
+}
+
+#define skip_blank(p, type) \
+ (ISSPACE(type) || (type == '#' && (p = skip_to_eol(p, pend), 1)))
+
+#ifndef NATINT_PACK
+# define pack_modifiers(p, t, n, e) pack_modifiers(p, t, e)
+#endif
+static char *
+pack_modifiers(const char *p, char type, int *natint, int *explicit_endian)
+{
+ while (1) {
+ switch (*p) {
+ case '_':
+ case '!':
+ if (strchr(natstr, type)) {
+#ifdef NATINT_PACK
+ *natint = 1;
+#endif
+ p++;
+ }
+ else {
+ rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, natstr);
+ }
+ break;
+
+ case '<':
+ case '>':
+ if (!strchr(endstr, type)) {
+ rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, endstr);
+ }
+ if (*explicit_endian) {
+ rb_raise(rb_eRangeError, "Can't use both '<' and '>'");
+ }
+ *explicit_endian = *p++;
+ break;
+ default:
+ return (char *)p;
+ }
+ }
+}
+
static VALUE
pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
{
- static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0";
- static const char spc10[] = " ";
const char *p, *pend;
VALUE res, from, associates = 0;
- char type;
long len, idx, plen;
const char *ptr;
int enc_info = 1; /* 0 - BINARY, 1 - US-ASCII, 2 - UTF-8 */
-#ifdef NATINT_PACK
- int natint; /* native integer */
-#endif
int integer_size, bigendian_p;
StringValue(fmt);
@@ -229,53 +281,21 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
#define MORE_ITEM (idx < RARRAY_LEN(ary))
#define THISFROM (MORE_ITEM ? RARRAY_AREF(ary, idx) : TOO_FEW)
#define NEXTFROM (MORE_ITEM ? RARRAY_AREF(ary, idx++) : TOO_FEW)
+#define NOT_BUFFER(val) (((val) == res) ? rb_raise(rb_eArgError, intoitself) : (void)0)
+#define STR_FROM(val) NOT_BUFFER(StringValue(val))
while (p < pend) {
int explicit_endian = 0;
- if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) {
+ if (RSTRING_END(fmt) != pend) {
rb_raise(rb_eRuntimeError, "format string modified");
}
- type = *p++; /* get data type */
-#ifdef NATINT_PACK
- natint = 0;
-#endif
-
- if (ISSPACE(type)) continue;
- if (type == '#') {
- while ((p < pend) && (*p != '\n')) {
- p++;
- }
- continue;
- }
-
- {
- modifiers:
- switch (*p) {
- case '_':
- case '!':
- if (strchr(natstr, type)) {
+ const char type = *p++; /* get data type */
#ifdef NATINT_PACK
- natint = 1;
+ int natint = 0; /* native integer */
#endif
- p++;
- }
- else {
- rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, natstr);
- }
- goto modifiers;
- case '<':
- case '>':
- if (!strchr(endstr, type)) {
- rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, endstr);
- }
- if (explicit_endian) {
- rb_raise(rb_eRangeError, "Can't use both '<' and '>'");
- }
- explicit_endian = *p++;
- goto modifiers;
- }
- }
+ if (skip_blank(p, type)) continue;
+ p = pack_modifiers(p, type, &natint, &explicit_endian);
if (*p == '*') { /* set data length */
len = strchr("@Xxu", type) ? 0
@@ -286,7 +306,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
else if (ISDIGIT(*p)) {
errno = 0;
len = STRTOUL(p, (char**)&p, 10);
- if (errno) {
+ if (len < 0 || errno) {
rb_raise(rb_eRangeError, "pack length too big");
}
}
@@ -317,7 +337,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
plen = 0;
}
else {
- StringValue(from);
+ STR_FROM(from);
ptr = RSTRING_PTR(from);
plen = RSTRING_LEN(from);
}
@@ -332,16 +352,12 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
if (plen >= len) {
rb_str_buf_cat(res, ptr, len);
if (p[-1] == '*' && type == 'Z')
- rb_str_buf_cat(res, nul10, 1);
+ rb_str_buf_cat(res, "", 1);
}
else {
+ rb_str_modify_expand(res, len);
rb_str_buf_cat(res, ptr, plen);
- len -= plen;
- while (len >= 10) {
- rb_str_buf_cat(res, (type == 'A')?spc10:nul10, 10);
- len -= 10;
- }
- rb_str_buf_cat(res, (type == 'A')?spc10:nul10, len);
+ str_expand_fill(res, (type == 'A' ? ' ' : '\0'), len - plen);
}
break;
@@ -615,11 +631,8 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'x': /* null byte */
grow:
- while (len >= 10) {
- rb_str_buf_cat(res, nul10, 10);
- len -= 10;
- }
- rb_str_buf_cat(res, nul10, len);
+ rb_str_modify_expand(res, len);
+ str_expand_fill(res, '\0', len);
break;
case 'X': /* back up byte */
@@ -658,10 +671,58 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
}
break;
+ case 'r': /* r for SLEB128 encoding (signed) */
+ case 'R': /* R for ULEB128 encoding (unsigned) */
+ {
+ int pack_flags = INTEGER_PACK_LITTLE_ENDIAN;
+
+ if (type == 'r') {
+ pack_flags |= INTEGER_PACK_2COMP;
+ }
+
+ while (len-- > 0) {
+ size_t numbytes, nlz_bits;
+ int sign, extra = 0;
+ char *cp;
+ const long start = RSTRING_LEN(res);
+
+ from = NEXTFROM;
+ from = rb_to_int(from);
+ if (type == 'R' && rb_int_negative_p(from)) {
+ rb_raise(rb_eArgError, "can't encode negative numbers in ULEB128");
+ }
+
+ numbytes = rb_absint_numwords(from, 7, &nlz_bits);
+ if (numbytes == 0) {
+ numbytes = 1;
+ }
+ else if (nlz_bits == 0 && type == 'r') {
+ /* No leading zero bits, we need an extra byte for sign extension */
+ extra = 1;
+ }
+ rb_str_modify_expand(res, numbytes + extra);
+
+ cp = RSTRING_PTR(res) + start;
+ sign = rb_integer_pack(from, cp, numbytes, 1, 1, pack_flags);
+
+ if (extra) {
+ /* Need an extra byte */
+ cp[numbytes++] = sign < 0 ? 0x7f : 0x00;
+ }
+ rb_str_set_len(res, start + numbytes);
+
+ while (1 < numbytes) {
+ *cp |= 0x80;
+ cp++;
+ numbytes--;
+ }
+ }
+ }
+ break;
case 'u': /* uuencoded string */
case 'm': /* base64 encoded string */
from = NEXTFROM;
- StringValue(from);
+ STR_FROM(from);
ptr = RSTRING_PTR(from);
plen = RSTRING_LEN(from);
@@ -691,6 +752,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'M': /* quoted-printable encoded string */
from = rb_obj_as_string(NEXTFROM);
+ NOT_BUFFER(from);
if (len <= 1)
len = 72;
qpencode(res, from, len);
@@ -699,7 +761,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'P': /* pointer to packed byte string */
from = THISFROM;
if (!NIL_P(from)) {
- StringValue(from);
+ STR_FROM(from);
if (RSTRING_LEN(from) < len) {
rb_raise(rb_eArgError, "too short buffer for P(%ld for %ld)",
RSTRING_LEN(from), len);
@@ -709,13 +771,11 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
/* FALL THROUGH */
case 'p': /* pointer to string */
while (len-- > 0) {
- char *t;
+ const char *t = 0;
from = NEXTFROM;
- if (NIL_P(from)) {
- t = 0;
- }
- else {
- t = StringValuePtr(from);
+ if (!NIL_P(from)) {
+ STR_FROM(from);
+ t = RSTRING_PTR(from);
}
if (!associates) {
associates = rb_ary_new();
@@ -727,7 +787,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'w': /* BER compressed integer */
while (len-- > 0) {
- VALUE buf = rb_str_new(0, 0);
+ VALUE buf;
size_t numbytes;
int sign;
char *cp;
@@ -781,6 +841,12 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
return res;
}
+VALUE
+rb_ec_pack_ary(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
+{
+ return pack_pack(ec, ary, fmt, buffer);
+}
+
static const char uu_table[] =
"`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
static const char b64_table[] =
@@ -935,16 +1001,11 @@ static VALUE
pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
{
#define hexdigits ruby_hexdigits
- char *s, *send;
- char *p, *pend;
+ const char *s, *send;
+ const char *p, *pend;
VALUE ary, associates = Qfalse;
- char type;
long len;
AVOID_CC_BUG long tmp_len;
- int star;
-#ifdef NATINT_PACK
- int natint; /* native integer */
-#endif
int signed_p, integer_size, bigendian_p;
#define UNPACK_PUSH(item) do {\
VALUE item_val = (item);\
@@ -963,9 +1024,10 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
StringValue(fmt);
rb_must_asciicompat(fmt);
- if (offset < 0) rb_raise(rb_eArgError, "offset can't be negative");
len = RSTRING_LEN(str);
- if (offset > len) rb_raise(rb_eArgError, "offset outside of string");
+ if (offset < 0 ? (offset += len) < 0 : offset > len) {
+ rb_raise(rb_eArgError, "offset outside of string");
+ }
s = RSTRING_PTR(str);
send = s + len;
@@ -979,49 +1041,14 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
ary = mode == UNPACK_ARRAY ? rb_ary_new() : Qnil;
while (p < pend) {
int explicit_endian = 0;
- type = *p++;
+ const char type = *p++;
#ifdef NATINT_PACK
- natint = 0;
+ int natint = 0; /* native integer */
#endif
+ int star = 0;
- if (ISSPACE(type)) continue;
- if (type == '#') {
- while ((p < pend) && (*p != '\n')) {
- p++;
- }
- continue;
- }
-
- star = 0;
- {
- modifiers:
- switch (*p) {
- case '_':
- case '!':
-
- if (strchr(natstr, type)) {
-#ifdef NATINT_PACK
- natint = 1;
-#endif
- p++;
- }
- else {
- rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, natstr);
- }
- goto modifiers;
-
- case '<':
- case '>':
- if (!strchr(endstr, type)) {
- rb_raise(rb_eArgError, "'%c' allowed only after types %s", *p, endstr);
- }
- if (explicit_endian) {
- rb_raise(rb_eRangeError, "Can't use both '<' and '>'");
- }
- explicit_endian = *p++;
- goto modifiers;
- }
- }
+ if (skip_blank(p, type)) continue;
+ p = pack_modifiers(p, type, &natint, &explicit_endian);
if (p >= pend)
len = 1;
@@ -1050,7 +1077,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
if (len > send - s) len = send - s;
{
long end = len;
- char *t = s + len - 1;
+ const char *t = s + len - 1;
while (t >= s) {
if (*t != ' ' && *t != '\0') break;
@@ -1063,7 +1090,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
case 'Z':
{
- char *t = s;
+ const char *t = s;
if (len > send-s) len = send-s;
while (t < s+len && *t) t++;
@@ -1497,7 +1524,8 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
case 'M':
{
VALUE buf = rb_str_new(0, send - s);
- char *ptr = RSTRING_PTR(buf), *ss = s;
+ char *ptr = RSTRING_PTR(buf);
+ const char *ss = s;
int csum = 0;
int c1, c2;
@@ -1545,10 +1573,14 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
s += len;
break;
+ case '^':
+ UNPACK_PUSH(SSIZET2NUM(s - RSTRING_PTR(str)));
+ break;
+
case 'P':
if (sizeof(char *) <= (size_t)(send - s)) {
VALUE tmp = Qnil;
- char *t;
+ const char *t;
UNPACK_FETCH(&t, char *);
if (t) {
@@ -1571,7 +1603,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
break;
else {
VALUE tmp = Qnil;
- char *t;
+ const char *t;
UNPACK_FETCH(&t, char *);
if (t) {
@@ -1583,9 +1615,42 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
}
break;
+ case 'r':
+ case 'R':
+ {
+ int pack_flags = INTEGER_PACK_LITTLE_ENDIAN;
+
+ if (type == 'r') {
+ pack_flags |= INTEGER_PACK_2COMP;
+ }
+ const char *s0 = s;
+ while (len > 0 && s < send) {
+ if (*s & 0x80) {
+ s++;
+ }
+ else {
+ s++;
+ UNPACK_PUSH(rb_integer_unpack(s0, s-s0, 1, 1, pack_flags));
+ len--;
+ s0 = s;
+ }
+ }
+ /* Handle incomplete value and remaining expected values with nil (only if not using *) */
+ if (!star) {
+ if (s0 != s && len > 0) {
+ UNPACK_PUSH(Qnil);
+ len--;
+ }
+ while (len-- > 0) {
+ UNPACK_PUSH(Qnil);
+ }
+ }
+ }
+ break;
+
case 'w':
{
- char *s0 = s;
+ const char *s0 = s;
while (len > 0 && s < send) {
if (*s & 0x80) {
s++;
diff --git a/pack.rb b/pack.rb
index d505eaee35..78ef6973d4 100644
--- a/pack.rb
+++ b/pack.rb
@@ -3,28 +3,37 @@ class Array
# pack(template, buffer: nil) -> string
#
# Formats each element in +self+ into a binary string; returns that string.
- # See {Packed Data}[rdoc-ref:packed_data.rdoc].
+ # See {Packed Data}[rdoc-ref:language/packed_data.md].
def pack(fmt, buffer: nil)
Primitive.pack_pack(fmt, buffer)
end
end
class String
- # call-seq:
- # unpack(template, offset: 0) -> array
+ # call-seq:
+ # unpack(template, offset: 0) {|o| .... } -> object
+ # unpack(template, offset: 0) -> array
+ #
+ # Extracts data from +self+ to form new objects;
+ # see {Packed Data}[rdoc-ref:language/packed_data.md].
#
- # Extracts data from +self+, forming objects that become the elements of a new array;
- # returns that array.
- # See {Packed Data}[rdoc-ref:packed_data.rdoc].
+ # With a block given, calls the block with each unpacked object.
+ #
+ # With no block given, returns an array containing the unpacked objects.
+ #
+ # Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
def unpack(fmt, offset: 0)
+ Primitive.attr! :use_block
Primitive.pack_unpack(fmt, offset)
end
# call-seq:
# unpack1(template, offset: 0) -> object
#
- # Like String#unpack, but unpacks and returns only the first extracted object.
- # See {Packed Data}[rdoc-ref:packed_data.rdoc].
+ # Like String#unpack with no block, but unpacks and returns only the first extracted object.
+ # See {Packed Data}[rdoc-ref:language/packed_data.md].
+ #
+ # Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
def unpack1(fmt, offset: 0)
Primitive.pack_unpack1(fmt, offset)
end
diff --git a/parse.y b/parse.y
index b05f1ba76a..ecd26acbbb 100644
--- a/parse.y
+++ b/parse.y
@@ -9,8 +9,6 @@
**********************************************************************/
-%require "3.0"
-
%{
#if !YYPURE
@@ -19,16 +17,28 @@
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYSTACK_USE_ALLOCA 0
-#define YYLTYPE rb_code_location_t
-#define YYLTYPE_IS_DECLARED 1
+
+/* For Ripper */
+#ifdef RUBY_EXTCONF_H
+# include RUBY_EXTCONF_H
+#endif
#include "ruby/internal/config.h"
-#include <ctype.h>
#include <errno.h>
-#include <stdio.h>
-struct lex_context;
+#ifdef UNIVERSAL_PARSER
+
+#include "internal/ruby_parser.h"
+#include "parser_node.h"
+#include "universal_parser.c"
+
+#ifdef RIPPER
+#define STATIC_ID2SYM p->config->static_id2sym
+#define rb_str_coderange_scan_restartable p->config->str_coderange_scan_restartable
+#endif
+
+#else
#include "internal.h"
#include "internal/compile.h"
@@ -37,16 +47,17 @@ struct lex_context;
#include "internal/encoding.h"
#include "internal/error.h"
#include "internal/hash.h"
-#include "internal/imemo.h"
#include "internal/io.h"
#include "internal/numeric.h"
#include "internal/parse.h"
#include "internal/rational.h"
#include "internal/re.h"
+#include "internal/ruby_parser.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "node.h"
+#include "parser_node.h"
#include "probes.h"
#include "regenc.h"
#include "ruby/encoding.h"
@@ -57,11 +68,244 @@ struct lex_context;
#include "ruby/ractor.h"
#include "symbol.h"
-enum shareability {
- shareable_none,
- shareable_literal,
- shareable_copy,
- shareable_everything,
+#ifndef RIPPER
+static VALUE
+syntax_error_new(void)
+{
+ return rb_class_new_instance(0, 0, rb_eSyntaxError);
+}
+#endif
+
+static NODE *reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc, rb_parser_assignable_func assignable);
+
+#define compile_callback rb_suppress_tracing
+#endif /* !UNIVERSAL_PARSER */
+
+#define NODE_SPECIAL_EMPTY_ARGS ((NODE *)-1)
+#define NODE_EMPTY_ARGS_P(node) ((node) == NODE_SPECIAL_EMPTY_ARGS)
+
+static int rb_parser_string_hash_cmp(rb_parser_string_t *str1, rb_parser_string_t *str2);
+
+#ifndef RIPPER
+static rb_parser_string_t *rb_parser_string_deep_copy(struct parser_params *p, const rb_parser_string_t *original);
+#endif
+
+static int
+node_integer_cmp(rb_node_integer_t *n1, rb_node_integer_t *n2)
+{
+ return (n1->minus != n2->minus ||
+ n1->base != n2->base ||
+ strcmp(n1->val, n2->val));
+}
+
+static int
+node_float_cmp(rb_node_float_t *n1, rb_node_float_t *n2)
+{
+ return (n1->minus != n2->minus ||
+ strcmp(n1->val, n2->val));
+}
+
+static int
+node_rational_cmp(rb_node_rational_t *n1, rb_node_rational_t *n2)
+{
+ return (n1->minus != n2->minus ||
+ n1->base != n2->base ||
+ n1->seen_point != n2->seen_point ||
+ strcmp(n1->val, n2->val));
+}
+
+static int
+node_imaginary_cmp(rb_node_imaginary_t *n1, rb_node_imaginary_t *n2)
+{
+ return (n1->minus != n2->minus ||
+ n1->base != n2->base ||
+ n1->seen_point != n2->seen_point ||
+ n1->type != n2->type ||
+ strcmp(n1->val, n2->val));
+}
+
+static int
+rb_parser_regx_hash_cmp(rb_node_regx_t *n1, rb_node_regx_t *n2)
+{
+ return (n1->options != n2->options ||
+ rb_parser_string_hash_cmp(n1->string, n2->string));
+}
+
+static st_index_t rb_parser_str_hash(rb_parser_string_t *str);
+static st_index_t rb_char_p_hash(const char *c);
+
+static int
+literal_cmp(st_data_t val, st_data_t lit)
+{
+ if (val == lit) return 0;
+
+ NODE *node_val = RNODE(val);
+ NODE *node_lit = RNODE(lit);
+ enum node_type type_val = nd_type(node_val);
+ enum node_type type_lit = nd_type(node_lit);
+
+ if (type_val != type_lit) {
+ return -1;
+ }
+
+ switch (type_lit) {
+ case NODE_INTEGER:
+ return node_integer_cmp(RNODE_INTEGER(node_val), RNODE_INTEGER(node_lit));
+ case NODE_FLOAT:
+ return node_float_cmp(RNODE_FLOAT(node_val), RNODE_FLOAT(node_lit));
+ case NODE_RATIONAL:
+ return node_rational_cmp(RNODE_RATIONAL(node_val), RNODE_RATIONAL(node_lit));
+ case NODE_IMAGINARY:
+ return node_imaginary_cmp(RNODE_IMAGINARY(node_val), RNODE_IMAGINARY(node_lit));
+ case NODE_STR:
+ return rb_parser_string_hash_cmp(RNODE_STR(node_val)->string, RNODE_STR(node_lit)->string);
+ case NODE_SYM:
+ return rb_parser_string_hash_cmp(RNODE_SYM(node_val)->string, RNODE_SYM(node_lit)->string);
+ case NODE_REGX:
+ return rb_parser_regx_hash_cmp(RNODE_REGX(node_val), RNODE_REGX(node_lit));
+ case NODE_LINE:
+ return node_val->nd_loc.beg_pos.lineno != node_lit->nd_loc.beg_pos.lineno;
+ case NODE_FILE:
+ return rb_parser_string_hash_cmp(RNODE_FILE(node_val)->path, RNODE_FILE(node_lit)->path);
+ case NODE_ENCODING:
+ return RNODE_ENCODING(node_val)->enc != RNODE_ENCODING(node_lit)->enc;
+ default:
+#ifdef UNIVERSAL_PARSER
+ abort();
+#else
+ rb_bug("unexpected node: %s, %s", ruby_node_name(type_val), ruby_node_name(type_lit));
+#endif
+ }
+}
+
+static st_index_t
+literal_hash(st_data_t a)
+{
+ NODE *node = (NODE *)a;
+ enum node_type type = nd_type(node);
+
+ switch (type) {
+ case NODE_INTEGER:
+ return rb_char_p_hash(RNODE_INTEGER(node)->val);
+ case NODE_FLOAT:
+ return rb_char_p_hash(RNODE_FLOAT(node)->val);
+ case NODE_RATIONAL:
+ return rb_char_p_hash(RNODE_RATIONAL(node)->val);
+ case NODE_IMAGINARY:
+ return rb_char_p_hash(RNODE_IMAGINARY(node)->val);
+ case NODE_STR:
+ return rb_parser_str_hash(RNODE_STR(node)->string);
+ case NODE_SYM:
+ return rb_parser_str_hash(RNODE_SYM(node)->string);
+ case NODE_REGX:
+ return rb_parser_str_hash(RNODE_REGX(node)->string);
+ case NODE_LINE:
+ return (st_index_t)node->nd_loc.beg_pos.lineno;
+ case NODE_FILE:
+ return rb_parser_str_hash(RNODE_FILE(node)->path);
+ case NODE_ENCODING:
+ return (st_index_t)RNODE_ENCODING(node)->enc;
+ default:
+#ifdef UNIVERSAL_PARSER
+ abort();
+#else
+ rb_bug("unexpected node: %s", ruby_node_name(type));
+#endif
+ }
+}
+
+static inline int
+parse_isascii(int c)
+{
+ return '\0' <= c && c <= '\x7f';
+}
+
+#undef ISASCII
+#define ISASCII parse_isascii
+
+static inline int
+parse_isspace(int c)
+{
+ return c == ' ' || ('\t' <= c && c <= '\r');
+}
+
+#undef ISSPACE
+#define ISSPACE parse_isspace
+
+static inline int
+parse_iscntrl(int c)
+{
+ return ('\0' <= c && c < ' ') || c == '\x7f';
+}
+
+#undef ISCNTRL
+#define ISCNTRL(c) parse_iscntrl(c)
+
+static inline int
+parse_isupper(int c)
+{
+ return 'A' <= c && c <= 'Z';
+}
+
+static inline int
+parse_islower(int c)
+{
+ return 'a' <= c && c <= 'z';
+}
+
+static inline int
+parse_isalpha(int c)
+{
+ return parse_isupper(c) || parse_islower(c);
+}
+
+#undef ISALPHA
+#define ISALPHA(c) parse_isalpha(c)
+
+static inline int
+parse_isdigit(int c)
+{
+ return '0' <= c && c <= '9';
+}
+
+#undef ISDIGIT
+#define ISDIGIT(c) parse_isdigit(c)
+
+static inline int
+parse_isalnum(int c)
+{
+ return ISALPHA(c) || ISDIGIT(c);
+}
+
+#undef ISALNUM
+#define ISALNUM(c) parse_isalnum(c)
+
+static inline int
+parse_isxdigit(int c)
+{
+ return ISDIGIT(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
+}
+
+#undef ISXDIGIT
+#define ISXDIGIT(c) parse_isxdigit(c)
+
+#include "parser_st.h"
+
+#undef STRCASECMP
+#define STRCASECMP rb_parser_st_locale_insensitive_strcasecmp
+
+#undef STRNCASECMP
+#define STRNCASECMP rb_parser_st_locale_insensitive_strncasecmp
+
+#ifdef RIPPER
+#include "ripper_init.h"
+#endif
+
+enum rescue_context {
+ before_rescue,
+ after_rescue,
+ after_else,
+ after_ensure,
};
struct lex_context {
@@ -70,9 +314,16 @@ struct lex_context {
unsigned int in_argdef: 1;
unsigned int in_def: 1;
unsigned int in_class: 1;
- BITFIELD(enum shareability, shareable_constant_value, 2);
+ unsigned int has_trailing_semicolon: 1;
+ BITFIELD(enum rb_parser_shareability, shareable_constant_value, 2);
+ BITFIELD(enum rescue_context, in_rescue, 2);
+ unsigned int cant_return: 1;
+ unsigned int in_alt_pattern: 1;
+ unsigned int capture_in_pattern: 1;
};
+typedef struct RNode_DEF_TEMP rb_node_def_temp_t;
+
#if defined(__GNUC__) && !defined(__clang__)
// Suppress "parameter passing for argument of type 'struct
// lex_context' changed" notes. `struct lex_context` is file scope,
@@ -87,8 +338,6 @@ RBIMPL_WARNING_POP()
#define NO_LEX_CTXT (struct lex_context){0}
-#define AREF(ary, i) RARRAY_AREF(ary, i)
-
#ifndef WARN_PAST_SCOPE
# define WARN_PAST_SCOPE 0
#endif
@@ -97,12 +346,8 @@ RBIMPL_WARNING_POP()
#define yydebug (p->debug) /* disable the global variable definition */
-#define YYMALLOC(size) rb_parser_malloc(p, (size))
-#define YYREALLOC(ptr, size) rb_parser_realloc(p, (ptr), (size))
-#define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size))
-#define YYFREE(ptr) rb_parser_free(p, (ptr))
-#define YYFPRINTF rb_parser_printf
-#define YY_LOCATION_PRINT(File, loc) \
+#define YYFPRINTF(out, ...) rb_parser_printf(p, __VA_ARGS__)
+#define YY_LOCATION_PRINT(File, loc, p) \
rb_parser_printf(p, "%d.%d-%d.%d", \
(loc).beg_pos.lineno, (loc).beg_pos.column,\
(loc).end_pos.lineno, (loc).end_pos.column)
@@ -141,44 +386,6 @@ RBIMPL_WARNING_POP()
{p->ruby_sourceline, (int)(p->lex.pcur - p->lex.pbeg)}, \
}
-enum lex_state_bits {
- EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
- EXPR_END_bit, /* newline significant, +/- is an operator. */
- EXPR_ENDARG_bit, /* ditto, and unbound braces. */
- EXPR_ENDFN_bit, /* ditto, and unbound braces. */
- EXPR_ARG_bit, /* newline significant, +/- is an operator. */
- EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
- EXPR_MID_bit, /* newline significant, +/- is an operator. */
- EXPR_FNAME_bit, /* ignore newline, no reserved words. */
- EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
- EXPR_CLASS_bit, /* immediate after `class', no here document. */
- EXPR_LABEL_bit, /* flag bit, label is allowed. */
- EXPR_LABELED_bit, /* flag bit, just after a label. */
- EXPR_FITEM_bit, /* symbol literal as FNAME. */
- EXPR_MAX_STATE
-};
-/* examine combinations */
-enum lex_state_e {
-#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
- DEF_EXPR(BEG),
- DEF_EXPR(END),
- DEF_EXPR(ENDARG),
- DEF_EXPR(ENDFN),
- DEF_EXPR(ARG),
- DEF_EXPR(CMDARG),
- DEF_EXPR(MID),
- DEF_EXPR(FNAME),
- DEF_EXPR(DOT),
- DEF_EXPR(CLASS),
- DEF_EXPR(LABEL),
- DEF_EXPR(LABELED),
- DEF_EXPR(FITEM),
- EXPR_VALUE = EXPR_BEG,
- EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
- EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
- EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
- EXPR_NONE = 0
-};
#define IS_lex_state_for(x, ls) ((x) & (ls))
#define IS_lex_state_all_for(x, ls) (((x) & (ls)) == (ls))
#define IS_lex_state(ls) IS_lex_state_for(p->lex.state, (ls))
@@ -227,31 +434,24 @@ struct local_vars {
struct vtable *past;
# endif
struct local_vars *prev;
-# ifndef RIPPER
struct {
NODE *outer, *inner, *current;
} numparam;
-# endif
+ NODE *it;
};
+typedef struct rb_locations_lambda_body_t {
+ NODE *node;
+ YYLTYPE opening_loc;
+ YYLTYPE closing_loc;
+} rb_locations_lambda_body_t;
+
enum {
ORDINAL_PARAM = -1,
NO_PARAM = 0,
NUMPARAM_MAX = 9,
};
-#define NUMPARAM_ID_P(id) numparam_id_p(id)
-#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - (tNUMPARAM_1 - 1))
-#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 - 1 + (idx)))
-static int
-numparam_id_p(ID id)
-{
- if (!is_local_id(id) || id < (tNUMPARAM_1 << ID_SCOPE_SHIFT)) return 0;
- unsigned int idx = NUMPARAM_ID_TO_IDX(id);
- return idx > 0 && idx <= NUMPARAM_MAX;
-}
-static void numparam_name(struct parser_params *p, ID id);
-
#define DVARS_INHERIT ((void*)1)
#define DVARS_TOPSCOPE NULL
#define DVARS_TERMINAL_P(tbl) ((tbl) == DVARS_INHERIT || (tbl) == DVARS_TOPSCOPE)
@@ -264,7 +464,24 @@ typedef struct token_info {
struct token_info *next;
} token_info;
-typedef struct rb_strterm_struct rb_strterm_t;
+typedef struct end_expect_token_locations {
+ const rb_code_position_t *pos;
+ struct end_expect_token_locations *prev;
+} end_expect_token_locations_t;
+
+typedef struct parser_string_buffer_elem {
+ struct parser_string_buffer_elem *next;
+ long len; /* Total length of allocated buf */
+ long used; /* Current usage of buf */
+ rb_parser_string_t *buf[FLEX_ARY_LEN];
+} parser_string_buffer_elem_t;
+
+typedef struct parser_string_buffer {
+ parser_string_buffer_elem_t *head;
+ parser_string_buffer_elem_t *last;
+} parser_string_buffer_t;
+
+#define AFTER_HEREDOC_WITHOUT_TERMINATOR ((rb_parser_string_t *)1)
/*
Structure of Lexer Buffer:
@@ -276,25 +493,20 @@ typedef struct rb_strterm_struct rb_strterm_t;
token
*/
struct parser_params {
- rb_imemo_tmpbuf_t *heap;
-
YYSTYPE *lval;
YYLTYPE *yylloc;
struct {
rb_strterm_t *strterm;
- VALUE (*gets)(struct parser_params*,VALUE);
- VALUE input;
- VALUE lastline;
- VALUE nextline;
+ rb_parser_lex_gets_func *gets;
+ rb_parser_input_data input;
+ parser_string_buffer_t string_buffer;
+ rb_parser_string_t *lastline;
+ rb_parser_string_t *nextline;
const char *pbeg;
const char *pcur;
const char *pend;
const char *ptok;
- union {
- long ptr;
- VALUE (*call)(VALUE, int);
- } gets_;
enum lex_state_e state;
/* track the nest level of any parens "()[]{}" */
int paren_nest;
@@ -307,7 +519,6 @@ struct parser_params {
stack_type cmdarg_stack;
int tokidx;
int toksiz;
- int tokline;
int heredoc_end;
int heredoc_indent;
int heredoc_line_indent;
@@ -321,29 +532,40 @@ struct parser_params {
VALUE ruby_sourcefile_string;
rb_encoding *enc;
token_info *token_info;
- VALUE case_labels;
- VALUE compile_option;
+ st_table *case_labels;
+ rb_node_exits_t *exits;
VALUE debug_buffer;
VALUE debug_output;
struct {
- VALUE token;
+ rb_parser_string_t *token;
int beg_line;
int beg_col;
int end_line;
int end_col;
} delayed;
- ID cur_arg;
-
rb_ast_t *ast;
int node_id;
+ st_table *warn_duplicate_keys_table;
+
int max_numparam;
+ ID it_id;
struct lex_context ctxt;
+ NODE *eval_tree_begin;
+ NODE *eval_tree;
+ const struct rb_iseq_struct *parent_iseq;
+
+#ifdef UNIVERSAL_PARSER
+ const rb_parser_config_t *config;
+#endif
+ /* compile_option */
+ signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */
+
unsigned int command_start:1;
unsigned int eofp: 1;
unsigned int ruby__end__seen: 1;
@@ -364,45 +586,143 @@ struct parser_params {
unsigned int do_loop: 1;
unsigned int do_chomp: 1;
unsigned int do_split: 1;
- unsigned int keep_script_lines: 1;
unsigned int error_tolerant: 1;
unsigned int keep_tokens: 1;
- NODE *eval_tree_begin;
- NODE *eval_tree;
VALUE error_buffer;
- VALUE debug_lines;
- const struct rb_iseq_struct *parent_iseq;
- /* store specific keyword locations to generate dummy end token */
- VALUE end_expect_token_locations;
+ rb_parser_ary_t *debug_lines;
+ /*
+ * Store specific keyword locations to generate dummy end token.
+ * Refer to the tail of list element.
+ */
+ end_expect_token_locations_t *end_expect_token_locations;
/* id for terms */
int token_id;
/* Array for term tokens */
- VALUE tokens;
+ rb_parser_ary_t *tokens;
#else
/* Ripper only */
VALUE value;
VALUE result;
VALUE parsing_thread;
+ VALUE s_value; /* Token VALUE */
+ VALUE s_lvalue; /* VALUE generated by rule action (reduce) */
+ VALUE s_value_stack;
#endif
};
+#define NUMPARAM_ID_P(id) numparam_id_p(p, id)
+#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - (tNUMPARAM_1 - 1))
+#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 - 1 + (idx)))
+static int
+numparam_id_p(struct parser_params *p, ID id)
+{
+ if (!is_local_id(id) || id < (tNUMPARAM_1 << ID_SCOPE_SHIFT)) return 0;
+ unsigned int idx = NUMPARAM_ID_TO_IDX(id);
+ return idx > 0 && idx <= NUMPARAM_MAX;
+}
+static void numparam_name(struct parser_params *p, ID id);
+
+#ifdef RIPPER
+static void
+after_shift(struct parser_params *p)
+{
+ if (p->debug) {
+ rb_parser_printf(p, "after-shift: %+"PRIsVALUE"\n", p->s_value);
+ }
+ rb_ary_push(p->s_value_stack, p->s_value);
+ p->s_value = Qnil;
+}
+
+static void
+before_reduce(int len, struct parser_params *p)
+{
+ // Initialize $$ with $1.
+ if (len) p->s_lvalue = rb_ary_entry(p->s_value_stack, -len);
+}
+
+static void
+after_reduce(int len, struct parser_params *p)
+{
+ for (int i = 0; i < len; i++) {
+ VALUE tos = rb_ary_pop(p->s_value_stack);
+ if (p->debug) {
+ rb_parser_printf(p, "after-reduce pop: %+"PRIsVALUE"\n", tos);
+ }
+ }
+ if (p->debug) {
+ rb_parser_printf(p, "after-reduce push: %+"PRIsVALUE"\n", p->s_lvalue);
+ }
+ rb_ary_push(p->s_value_stack, p->s_lvalue);
+ p->s_lvalue = Qnil;
+}
+
+static void
+after_shift_error_token(struct parser_params *p)
+{
+ if (p->debug) {
+ rb_parser_printf(p, "after-shift-error-token:\n");
+ }
+ rb_ary_push(p->s_value_stack, Qnil);
+}
+
+static void
+after_pop_stack(int len, struct parser_params *p)
+{
+ for (int i = 0; i < len; i++) {
+ VALUE tos = rb_ary_pop(p->s_value_stack);
+ if (p->debug) {
+ rb_parser_printf(p, "after-pop-stack pop: %+"PRIsVALUE"\n", tos);
+ }
+ }
+}
+#else
+static void
+after_shift(struct parser_params *p)
+{
+}
+
+static void
+before_reduce(int len, struct parser_params *p)
+{
+}
+
+static void
+after_reduce(int len, struct parser_params *p)
+{
+}
+
+static void
+after_shift_error_token(struct parser_params *p)
+{
+}
+
+static void
+after_pop_stack(int len, struct parser_params *p)
+{
+}
+#endif
+
#define intern_cstr(n,l,en) rb_intern3(n,l,en)
+#define STRING_NEW0() rb_parser_encoding_string_new(p,0,0,p->enc)
+
#define STR_NEW(ptr,len) rb_enc_str_new((ptr),(len),p->enc)
#define STR_NEW0() rb_enc_str_new(0,0,p->enc)
#define STR_NEW2(ptr) rb_enc_str_new((ptr),strlen(ptr),p->enc)
-#define STR_NEW3(ptr,len,e,func) parser_str_new((ptr),(len),(e),(func),p->enc)
+#define STR_NEW3(ptr,len,e,func) parser_str_new(p, (ptr),(len),(e),(func),p->enc)
#define TOK_INTERN() intern_cstr(tok(p), toklen(p), p->enc)
+#define VALID_SYMNAME_P(s, l, enc, type) (rb_enc_symname_type(s, l, enc, (1U<<(type))) == (int)(type))
-static st_table *
-push_pvtbl(struct parser_params *p)
+#ifndef RIPPER
+static inline int
+char_at_end(struct parser_params *p, VALUE str, int when_empty)
{
- st_table *tbl = p->pvtbl;
- p->pvtbl = st_init_numtable();
- return tbl;
+ long len = RSTRING_LEN(str);
+ return len > 0 ? (unsigned char)RSTRING_PTR(str)[len-1] : when_empty;
}
+#endif
static void
pop_pvtbl(struct parser_params *p, st_table *tbl)
@@ -411,14 +731,6 @@ pop_pvtbl(struct parser_params *p, st_table *tbl)
p->pvtbl = tbl;
}
-static st_table *
-push_pktbl(struct parser_params *p)
-{
- st_table *tbl = p->pktbl;
- p->pktbl = 0;
- return tbl;
-}
-
static void
pop_pktbl(struct parser_params *p, st_table *tbl)
{
@@ -426,6 +738,57 @@ pop_pktbl(struct parser_params *p, st_table *tbl)
p->pktbl = tbl;
}
+#define STRING_BUF_DEFAULT_LEN 16
+
+static void
+string_buffer_init(struct parser_params *p)
+{
+ parser_string_buffer_t *buf = &p->lex.string_buffer;
+ const size_t size = offsetof(parser_string_buffer_elem_t, buf) + sizeof(rb_parser_string_t *) * STRING_BUF_DEFAULT_LEN;
+
+ buf->head = buf->last = xmalloc(size);
+ buf->head->len = STRING_BUF_DEFAULT_LEN;
+ buf->head->used = 0;
+ buf->head->next = NULL;
+}
+
+static void
+string_buffer_append(struct parser_params *p, rb_parser_string_t *str)
+{
+ parser_string_buffer_t *buf = &p->lex.string_buffer;
+
+ if (buf->head->used >= buf->head->len) {
+ parser_string_buffer_elem_t *elem;
+ long n = buf->head->len * 2;
+ const size_t size = offsetof(parser_string_buffer_elem_t, buf) + sizeof(rb_parser_string_t *) * n;
+
+ elem = xmalloc(size);
+ elem->len = n;
+ elem->used = 0;
+ elem->next = NULL;
+ buf->last->next = elem;
+ buf->last = elem;
+ }
+ buf->last->buf[buf->last->used++] = str;
+}
+
+static void
+string_buffer_free(struct parser_params *p)
+{
+ parser_string_buffer_elem_t *elem = p->lex.string_buffer.head;
+
+ while (elem) {
+ parser_string_buffer_elem_t *next_elem = elem->next;
+
+ for (long i = 0; i < elem->used; i++) {
+ rb_parser_string_free(p, elem->buf[i]);
+ }
+
+ xfree(elem);
+ elem = next_elem;
+ }
+}
+
#ifndef RIPPER
static void flush_debug_buffer(struct parser_params *p, VALUE out, VALUE str);
@@ -433,8 +796,15 @@ static void
debug_end_expect_token_locations(struct parser_params *p, const char *name)
{
if(p->debug) {
- VALUE mesg = rb_sprintf("%s: ", name);
- rb_str_catf(mesg, " %"PRIsVALUE"\n", p->end_expect_token_locations);
+ VALUE mesg = rb_sprintf("%s: [", name);
+ int i = 0;
+ for (end_expect_token_locations_t *loc = p->end_expect_token_locations; loc; loc = loc->prev) {
+ if (i > 0)
+ rb_str_cat_cstr(mesg, ", ");
+ rb_str_catf(mesg, "[%d, %d]", loc->pos->lineno, loc->pos->column);
+ i++;
+ }
+ rb_str_cat_cstr(mesg, "]\n");
flush_debug_buffer(p, p->debug_output, mesg);
}
}
@@ -442,196 +812,214 @@ debug_end_expect_token_locations(struct parser_params *p, const char *name)
static void
push_end_expect_token_locations(struct parser_params *p, const rb_code_position_t *pos)
{
- if(NIL_P(p->end_expect_token_locations)) return;
- rb_ary_push(p->end_expect_token_locations, rb_ary_new_from_args(2, INT2NUM(pos->lineno), INT2NUM(pos->column)));
+ if(!p->error_tolerant) return;
+
+ end_expect_token_locations_t *locations;
+ locations = ALLOC(end_expect_token_locations_t);
+ locations->pos = pos;
+ locations->prev = p->end_expect_token_locations;
+ p->end_expect_token_locations = locations;
+
debug_end_expect_token_locations(p, "push_end_expect_token_locations");
}
static void
pop_end_expect_token_locations(struct parser_params *p)
{
- if(NIL_P(p->end_expect_token_locations)) return;
- rb_ary_pop(p->end_expect_token_locations);
+ if(!p->end_expect_token_locations) return;
+
+ end_expect_token_locations_t *locations = p->end_expect_token_locations->prev;
+ ruby_xfree_sized(p->end_expect_token_locations, sizeof(end_expect_token_locations_t));
+ p->end_expect_token_locations = locations;
+
debug_end_expect_token_locations(p, "pop_end_expect_token_locations");
}
-static VALUE
+static end_expect_token_locations_t *
peek_end_expect_token_locations(struct parser_params *p)
{
- if(NIL_P(p->end_expect_token_locations)) return Qnil;
- return rb_ary_last(0, 0, p->end_expect_token_locations);
+ return p->end_expect_token_locations;
}
-static ID
-parser_token2id(enum yytokentype tok)
+static const char *
+parser_token2char(struct parser_params *p, enum yytokentype tok)
{
switch ((int) tok) {
-#define TOKEN2ID(tok) case tok: return rb_intern(#tok);
-#define TOKEN2ID2(tok, name) case tok: return rb_intern(name);
- TOKEN2ID2(' ', "words_sep")
- TOKEN2ID2('!', "!")
- TOKEN2ID2('%', "%");
- TOKEN2ID2('&', "&");
- TOKEN2ID2('*', "*");
- TOKEN2ID2('+', "+");
- TOKEN2ID2('-', "-");
- TOKEN2ID2('/', "/");
- TOKEN2ID2('<', "<");
- TOKEN2ID2('=', "=");
- TOKEN2ID2('>', ">");
- TOKEN2ID2('?', "?");
- TOKEN2ID2('^', "^");
- TOKEN2ID2('|', "|");
- TOKEN2ID2('~', "~");
- TOKEN2ID2(':', ":");
- TOKEN2ID2(',', ",");
- TOKEN2ID2('.', ".");
- TOKEN2ID2(';', ";");
- TOKEN2ID2('`', "`");
- TOKEN2ID2('\n', "nl");
- TOKEN2ID2('{', "{");
- TOKEN2ID2('}', "}");
- TOKEN2ID2('[', "[");
- TOKEN2ID2(']', "]");
- TOKEN2ID2('(', "(");
- TOKEN2ID2(')', ")");
- TOKEN2ID(keyword_class);
- TOKEN2ID(keyword_module);
- TOKEN2ID(keyword_def);
- TOKEN2ID(keyword_undef);
- TOKEN2ID(keyword_begin);
- TOKEN2ID(keyword_rescue);
- TOKEN2ID(keyword_ensure);
- TOKEN2ID(keyword_end);
- TOKEN2ID(keyword_if);
- TOKEN2ID(keyword_unless);
- TOKEN2ID(keyword_then);
- TOKEN2ID(keyword_elsif);
- TOKEN2ID(keyword_else);
- TOKEN2ID(keyword_case);
- TOKEN2ID(keyword_when);
- TOKEN2ID(keyword_while);
- TOKEN2ID(keyword_until);
- TOKEN2ID(keyword_for);
- TOKEN2ID(keyword_break);
- TOKEN2ID(keyword_next);
- TOKEN2ID(keyword_redo);
- TOKEN2ID(keyword_retry);
- TOKEN2ID(keyword_in);
- TOKEN2ID(keyword_do);
- TOKEN2ID(keyword_do_cond);
- TOKEN2ID(keyword_do_block);
- TOKEN2ID(keyword_do_LAMBDA);
- TOKEN2ID(keyword_return);
- TOKEN2ID(keyword_yield);
- TOKEN2ID(keyword_super);
- TOKEN2ID(keyword_self);
- TOKEN2ID(keyword_nil);
- TOKEN2ID(keyword_true);
- TOKEN2ID(keyword_false);
- TOKEN2ID(keyword_and);
- TOKEN2ID(keyword_or);
- TOKEN2ID(keyword_not);
- TOKEN2ID(modifier_if);
- TOKEN2ID(modifier_unless);
- TOKEN2ID(modifier_while);
- TOKEN2ID(modifier_until);
- TOKEN2ID(modifier_rescue);
- TOKEN2ID(keyword_alias);
- TOKEN2ID(keyword_defined);
- TOKEN2ID(keyword_BEGIN);
- TOKEN2ID(keyword_END);
- TOKEN2ID(keyword__LINE__);
- TOKEN2ID(keyword__FILE__);
- TOKEN2ID(keyword__ENCODING__);
- TOKEN2ID(tIDENTIFIER);
- TOKEN2ID(tFID);
- TOKEN2ID(tGVAR);
- TOKEN2ID(tIVAR);
- TOKEN2ID(tCONSTANT);
- TOKEN2ID(tCVAR);
- TOKEN2ID(tLABEL);
- TOKEN2ID(tINTEGER);
- TOKEN2ID(tFLOAT);
- TOKEN2ID(tRATIONAL);
- TOKEN2ID(tIMAGINARY);
- TOKEN2ID(tCHAR);
- TOKEN2ID(tNTH_REF);
- TOKEN2ID(tBACK_REF);
- TOKEN2ID(tSTRING_CONTENT);
- TOKEN2ID(tREGEXP_END);
- TOKEN2ID(tDUMNY_END);
- TOKEN2ID(tSP);
- TOKEN2ID(tUPLUS);
- TOKEN2ID(tUMINUS);
- TOKEN2ID(tPOW);
- TOKEN2ID(tCMP);
- TOKEN2ID(tEQ);
- TOKEN2ID(tEQQ);
- TOKEN2ID(tNEQ);
- TOKEN2ID(tGEQ);
- TOKEN2ID(tLEQ);
- TOKEN2ID(tANDOP);
- TOKEN2ID(tOROP);
- TOKEN2ID(tMATCH);
- TOKEN2ID(tNMATCH);
- TOKEN2ID(tDOT2);
- TOKEN2ID(tDOT3);
- TOKEN2ID(tBDOT2);
- TOKEN2ID(tBDOT3);
- TOKEN2ID(tAREF);
- TOKEN2ID(tASET);
- TOKEN2ID(tLSHFT);
- TOKEN2ID(tRSHFT);
- TOKEN2ID(tANDDOT);
- TOKEN2ID(tCOLON2);
- TOKEN2ID(tCOLON3);
- TOKEN2ID(tOP_ASGN);
- TOKEN2ID(tASSOC);
- TOKEN2ID(tLPAREN);
- TOKEN2ID(tLPAREN_ARG);
- TOKEN2ID(tRPAREN);
- TOKEN2ID(tLBRACK);
- TOKEN2ID(tLBRACE);
- TOKEN2ID(tLBRACE_ARG);
- TOKEN2ID(tSTAR);
- TOKEN2ID(tDSTAR);
- TOKEN2ID(tAMPER);
- TOKEN2ID(tLAMBDA);
- TOKEN2ID(tSYMBEG);
- TOKEN2ID(tSTRING_BEG);
- TOKEN2ID(tXSTRING_BEG);
- TOKEN2ID(tREGEXP_BEG);
- TOKEN2ID(tWORDS_BEG);
- TOKEN2ID(tQWORDS_BEG);
- TOKEN2ID(tSYMBOLS_BEG);
- TOKEN2ID(tQSYMBOLS_BEG);
- TOKEN2ID(tSTRING_END);
- TOKEN2ID(tSTRING_DEND);
- TOKEN2ID(tSTRING_DBEG);
- TOKEN2ID(tSTRING_DVAR);
- TOKEN2ID(tLAMBEG);
- TOKEN2ID(tLABEL_END);
- TOKEN2ID(tIGNORED_NL);
- TOKEN2ID(tCOMMENT);
- TOKEN2ID(tEMBDOC_BEG);
- TOKEN2ID(tEMBDOC);
- TOKEN2ID(tEMBDOC_END);
- TOKEN2ID(tHEREDOC_BEG);
- TOKEN2ID(tHEREDOC_END);
- TOKEN2ID(k__END__);
- TOKEN2ID(tLOWEST);
- TOKEN2ID(tUMINUS_NUM);
- TOKEN2ID(tLAST_TOKEN);
-#undef TOKEN2ID
-#undef TOKEN2ID2
+#define TOKEN2CHAR(tok) case tok: return (#tok);
+#define TOKEN2CHAR2(tok, name) case tok: return (name);
+ TOKEN2CHAR2(' ', "word_sep");
+ TOKEN2CHAR2('!', "!")
+ TOKEN2CHAR2('%', "%");
+ TOKEN2CHAR2('&', "&");
+ TOKEN2CHAR2('*', "*");
+ TOKEN2CHAR2('+', "+");
+ TOKEN2CHAR2('-', "-");
+ TOKEN2CHAR2('/', "/");
+ TOKEN2CHAR2('<', "<");
+ TOKEN2CHAR2('=', "=");
+ TOKEN2CHAR2('>', ">");
+ TOKEN2CHAR2('?', "?");
+ TOKEN2CHAR2('^', "^");
+ TOKEN2CHAR2('|', "|");
+ TOKEN2CHAR2('~', "~");
+ TOKEN2CHAR2(':', ":");
+ TOKEN2CHAR2(',', ",");
+ TOKEN2CHAR2('.', ".");
+ TOKEN2CHAR2(';', ";");
+ TOKEN2CHAR2('`', "`");
+ TOKEN2CHAR2('\n', "nl");
+ TOKEN2CHAR2('{', "\"{\"");
+ TOKEN2CHAR2('}', "\"}\"");
+ TOKEN2CHAR2('[', "\"[\"");
+ TOKEN2CHAR2(']', "\"]\"");
+ TOKEN2CHAR2('(', "\"(\"");
+ TOKEN2CHAR2(')', "\")\"");
+ TOKEN2CHAR2('\\', "backslash");
+ TOKEN2CHAR(keyword_class);
+ TOKEN2CHAR(keyword_module);
+ TOKEN2CHAR(keyword_def);
+ TOKEN2CHAR(keyword_undef);
+ TOKEN2CHAR(keyword_begin);
+ TOKEN2CHAR(keyword_rescue);
+ TOKEN2CHAR(keyword_ensure);
+ TOKEN2CHAR(keyword_end);
+ TOKEN2CHAR(keyword_if);
+ TOKEN2CHAR(keyword_unless);
+ TOKEN2CHAR(keyword_then);
+ TOKEN2CHAR(keyword_elsif);
+ TOKEN2CHAR(keyword_else);
+ TOKEN2CHAR(keyword_case);
+ TOKEN2CHAR(keyword_when);
+ TOKEN2CHAR(keyword_while);
+ TOKEN2CHAR(keyword_until);
+ TOKEN2CHAR(keyword_for);
+ TOKEN2CHAR(keyword_break);
+ TOKEN2CHAR(keyword_next);
+ TOKEN2CHAR(keyword_redo);
+ TOKEN2CHAR(keyword_retry);
+ TOKEN2CHAR(keyword_in);
+ TOKEN2CHAR(keyword_do);
+ TOKEN2CHAR(keyword_do_cond);
+ TOKEN2CHAR(keyword_do_block);
+ TOKEN2CHAR(keyword_do_LAMBDA);
+ TOKEN2CHAR(keyword_return);
+ TOKEN2CHAR(keyword_yield);
+ TOKEN2CHAR(keyword_super);
+ TOKEN2CHAR(keyword_self);
+ TOKEN2CHAR(keyword_nil);
+ TOKEN2CHAR(keyword_true);
+ TOKEN2CHAR(keyword_false);
+ TOKEN2CHAR(keyword_and);
+ TOKEN2CHAR(keyword_or);
+ TOKEN2CHAR(keyword_not);
+ TOKEN2CHAR(modifier_if);
+ TOKEN2CHAR(modifier_unless);
+ TOKEN2CHAR(modifier_while);
+ TOKEN2CHAR(modifier_until);
+ TOKEN2CHAR(modifier_rescue);
+ TOKEN2CHAR(keyword_alias);
+ TOKEN2CHAR(keyword_defined);
+ TOKEN2CHAR(keyword_BEGIN);
+ TOKEN2CHAR(keyword_END);
+ TOKEN2CHAR(keyword__LINE__);
+ TOKEN2CHAR(keyword__FILE__);
+ TOKEN2CHAR(keyword__ENCODING__);
+ TOKEN2CHAR(tIDENTIFIER);
+ TOKEN2CHAR(tFID);
+ TOKEN2CHAR(tGVAR);
+ TOKEN2CHAR(tIVAR);
+ TOKEN2CHAR(tCONSTANT);
+ TOKEN2CHAR(tCVAR);
+ TOKEN2CHAR(tLABEL);
+ TOKEN2CHAR(tINTEGER);
+ TOKEN2CHAR(tFLOAT);
+ TOKEN2CHAR(tRATIONAL);
+ TOKEN2CHAR(tIMAGINARY);
+ TOKEN2CHAR(tCHAR);
+ TOKEN2CHAR(tNTH_REF);
+ TOKEN2CHAR(tBACK_REF);
+ TOKEN2CHAR(tSTRING_CONTENT);
+ TOKEN2CHAR(tREGEXP_END);
+ TOKEN2CHAR(tDUMNY_END);
+ TOKEN2CHAR(tSP);
+ TOKEN2CHAR(tUPLUS);
+ TOKEN2CHAR(tUMINUS);
+ TOKEN2CHAR(tPOW);
+ TOKEN2CHAR(tCMP);
+ TOKEN2CHAR(tEQ);
+ TOKEN2CHAR(tEQQ);
+ TOKEN2CHAR(tNEQ);
+ TOKEN2CHAR(tGEQ);
+ TOKEN2CHAR(tLEQ);
+ TOKEN2CHAR(tANDOP);
+ TOKEN2CHAR(tOROP);
+ TOKEN2CHAR(tMATCH);
+ TOKEN2CHAR(tNMATCH);
+ TOKEN2CHAR(tDOT2);
+ TOKEN2CHAR(tDOT3);
+ TOKEN2CHAR(tBDOT2);
+ TOKEN2CHAR(tBDOT3);
+ TOKEN2CHAR(tAREF);
+ TOKEN2CHAR(tASET);
+ TOKEN2CHAR(tLSHFT);
+ TOKEN2CHAR(tRSHFT);
+ TOKEN2CHAR(tANDDOT);
+ TOKEN2CHAR(tCOLON2);
+ TOKEN2CHAR(tCOLON3);
+ TOKEN2CHAR(tOP_ASGN);
+ TOKEN2CHAR(tASSOC);
+ TOKEN2CHAR(tLPAREN);
+ TOKEN2CHAR(tLPAREN_ARG);
+ TOKEN2CHAR(tLBRACK);
+ TOKEN2CHAR(tLBRACE);
+ TOKEN2CHAR(tLBRACE_ARG);
+ TOKEN2CHAR(tSTAR);
+ TOKEN2CHAR(tDSTAR);
+ TOKEN2CHAR(tAMPER);
+ TOKEN2CHAR(tLAMBDA);
+ TOKEN2CHAR(tSYMBEG);
+ TOKEN2CHAR(tSTRING_BEG);
+ TOKEN2CHAR(tXSTRING_BEG);
+ TOKEN2CHAR(tREGEXP_BEG);
+ TOKEN2CHAR(tWORDS_BEG);
+ TOKEN2CHAR(tQWORDS_BEG);
+ TOKEN2CHAR(tSYMBOLS_BEG);
+ TOKEN2CHAR(tQSYMBOLS_BEG);
+ TOKEN2CHAR(tSTRING_END);
+ TOKEN2CHAR(tSTRING_DEND);
+ TOKEN2CHAR(tSTRING_DBEG);
+ TOKEN2CHAR(tSTRING_DVAR);
+ TOKEN2CHAR(tLAMBEG);
+ TOKEN2CHAR(tLABEL_END);
+ TOKEN2CHAR(tIGNORED_NL);
+ TOKEN2CHAR(tCOMMENT);
+ TOKEN2CHAR(tEMBDOC_BEG);
+ TOKEN2CHAR(tEMBDOC);
+ TOKEN2CHAR(tEMBDOC_END);
+ TOKEN2CHAR(tHEREDOC_BEG);
+ TOKEN2CHAR(tHEREDOC_END);
+ TOKEN2CHAR(k__END__);
+ TOKEN2CHAR(tLOWEST);
+ TOKEN2CHAR(tUMINUS_NUM);
+ TOKEN2CHAR(tLAST_TOKEN);
+#undef TOKEN2CHAR
+#undef TOKEN2CHAR2
}
rb_bug("parser_token2id: unknown token %d", tok);
UNREACHABLE_RETURN(0);
}
+#else
+static void
+push_end_expect_token_locations(struct parser_params *p, const rb_code_position_t *pos)
+{
+}
+static void
+pop_end_expect_token_locations(struct parser_params *p)
+{
+}
#endif
RBIMPL_ATTR_NONNULL((1, 2, 3))
@@ -643,8 +1031,10 @@ static int parser_yyerror0(struct parser_params*, const char*);
#define yyerror(yylloc, p, msg) parser_yyerror(p, yylloc, msg)
#define token_flush(ptr) ((ptr)->lex.ptok = (ptr)->lex.pcur)
#define lex_goto_eol(p) ((p)->lex.pcur = (p)->lex.pend)
-#define lex_eol_p(p) ((p)->lex.pcur >= (p)->lex.pend)
-#define lex_eol_n_p(p,n) ((p)->lex.pcur+(n) >= (p)->lex.pend)
+#define lex_eol_p(p) lex_eol_n_p(p, 0)
+#define lex_eol_n_p(p,n) lex_eol_ptr_n_p(p, (p)->lex.pcur, n)
+#define lex_eol_ptr_p(p,ptr) lex_eol_ptr_n_p(p,ptr,0)
+#define lex_eol_ptr_n_p(p,ptr,n) ((ptr)+(n) >= (p)->lex.pend)
static void token_info_setup(token_info *ptinfo, const char *ptr, const rb_code_location_t *loc);
static void token_info_push(struct parser_params*, const char *token, const rb_code_location_t *loc);
@@ -660,39 +1050,289 @@ static void token_info_drop(struct parser_params *p, const char *token, rb_code_
#define token_column ((int)(p->lex.ptok - p->lex.pbeg))
-#define CALL_Q_P(q) ((q) == TOKEN2VAL(tANDDOT))
-#define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL)
-#define NEW_QCALL(q,r,m,a,loc) NEW_NODE(NODE_CALL_Q(q),r,m,a,loc)
+#define CALL_Q_P(q) ((q) == tANDDOT)
+#define NEW_QCALL(q,r,m,a,loc) (CALL_Q_P(q) ? NEW_QCALL0(r,m,a,loc) : NEW_CALL(r,m,a,loc))
#define lambda_beginning_p() (p->lex.lpar_beg == p->lex.paren_nest)
static enum yytokentype yylex(YYSTYPE*, YYLTYPE*, struct parser_params*);
-#ifndef RIPPER
static inline void
rb_discard_node(struct parser_params *p, NODE *n)
{
rb_ast_delete_node(p->ast, n);
}
-#endif
-#ifdef RIPPER
-static inline VALUE
-add_mark_object(struct parser_params *p, VALUE obj)
+static rb_node_scope_t *rb_node_scope_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, NODE *nd_parent, const YYLTYPE *loc);
+static rb_node_scope_t *rb_node_scope_new2(struct parser_params *p, rb_ast_id_table_t *nd_tbl, rb_node_args_t *nd_args, NODE *nd_body, NODE *nd_parent, const YYLTYPE *loc);
+static rb_node_block_t *rb_node_block_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc);
+static rb_node_if_t *rb_node_if_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc, const YYLTYPE* if_keyword_loc, const YYLTYPE* then_keyword_loc, const YYLTYPE* end_keyword_loc);
+static rb_node_unless_t *rb_node_unless_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_case_t *rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_case2_t *rb_node_case2_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_case3_t *rb_node_case3_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_when_t *rb_node_when_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc);
+static rb_node_in_t *rb_node_in_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc, const YYLTYPE *in_keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *operator_loc);
+static rb_node_while_t *rb_node_while_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, long nd_state, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *closing_loc);
+static rb_node_until_t *rb_node_until_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, long nd_state, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *closing_loc);
+static rb_node_iter_t *rb_node_iter_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_for_t *rb_node_for_new(struct parser_params *p, NODE *nd_iter, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *for_keyword_loc, const YYLTYPE *in_keyword_loc, const YYLTYPE *do_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_for_masgn_t *rb_node_for_masgn_new(struct parser_params *p, NODE *nd_var, const YYLTYPE *loc);
+static rb_node_retry_t *rb_node_retry_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_begin_t *rb_node_begin_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_rescue_t *rb_node_rescue_new(struct parser_params *p, NODE *nd_head, NODE *nd_resq, NODE *nd_else, const YYLTYPE *loc);
+static rb_node_resbody_t *rb_node_resbody_new(struct parser_params *p, NODE *nd_args, NODE *nd_exc_var, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc);
+static rb_node_ensure_t *rb_node_ensure_new(struct parser_params *p, NODE *nd_head, NODE *nd_ensr, const YYLTYPE *loc);
+static rb_node_and_t *rb_node_and_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_or_t *rb_node_or_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_masgn_t *rb_node_masgn_new(struct parser_params *p, NODE *nd_head, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_lasgn_t *rb_node_lasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_dasgn_t *rb_node_dasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_gasgn_t *rb_node_gasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_iasgn_t *rb_node_iasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_cdecl_t *rb_node_cdecl_new(struct parser_params *p, ID nd_vid, NODE *nd_value, NODE *nd_else, enum rb_parser_shareability shareability, const YYLTYPE *loc);
+static rb_node_cvasgn_t *rb_node_cvasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_op_asgn1_t *rb_node_op_asgn1_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *index, NODE *rvalue, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc, const YYLTYPE *binary_operator_loc);
+static rb_node_op_asgn2_t *rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *message_loc, const YYLTYPE *binary_operator_loc);
+static rb_node_op_asgn_or_t *rb_node_op_asgn_or_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_op_asgn_and_t *rb_node_op_asgn_and_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_op_cdecl_t *rb_node_op_cdecl_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, ID nd_aid, enum rb_parser_shareability shareability, const YYLTYPE *loc);
+static rb_node_call_t *rb_node_call_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_opcall_t *rb_node_opcall_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_fcall_t *rb_node_fcall_new(struct parser_params *p, ID nd_mid, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_vcall_t *rb_node_vcall_new(struct parser_params *p, ID nd_mid, const YYLTYPE *loc);
+static rb_node_qcall_t *rb_node_qcall_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_super_t *rb_node_super_new(struct parser_params *p, NODE *nd_args, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *lparen_loc, const YYLTYPE *rparen_loc);
+static rb_node_zsuper_t * rb_node_zsuper_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_list_t *rb_node_list_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc);
+static rb_node_list_t *rb_node_list_new2(struct parser_params *p, NODE *nd_head, long nd_alen, NODE *nd_next, const YYLTYPE *loc);
+static rb_node_zlist_t *rb_node_zlist_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_hash_t *rb_node_hash_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc);
+static rb_node_return_t *rb_node_return_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_yield_t *rb_node_yield_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *lparen_loc, const YYLTYPE *rparen_loc);
+static rb_node_lvar_t *rb_node_lvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_dvar_t *rb_node_dvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_gvar_t *rb_node_gvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_ivar_t *rb_node_ivar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_const_t *rb_node_const_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_cvar_t *rb_node_cvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc);
+static rb_node_nth_ref_t *rb_node_nth_ref_new(struct parser_params *p, long nd_nth, const YYLTYPE *loc);
+static rb_node_back_ref_t *rb_node_back_ref_new(struct parser_params *p, long nd_nth, const YYLTYPE *loc);
+static rb_node_match2_t *rb_node_match2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_match3_t *rb_node_match3_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, const YYLTYPE *loc);
+static rb_node_integer_t * rb_node_integer_new(struct parser_params *p, char* val, int base, const YYLTYPE *loc);
+static rb_node_float_t * rb_node_float_new(struct parser_params *p, char* val, const YYLTYPE *loc);
+static rb_node_rational_t * rb_node_rational_new(struct parser_params *p, char* val, int base, int seen_point, const YYLTYPE *loc);
+static rb_node_imaginary_t * rb_node_imaginary_new(struct parser_params *p, char* val, int base, int seen_point, enum rb_numeric_type, const YYLTYPE *loc);
+static rb_node_str_t *rb_node_str_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc);
+static rb_node_dstr_t *rb_node_dstr_new0(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc);
+static rb_node_dstr_t *rb_node_dstr_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc);
+static rb_node_xstr_t *rb_node_xstr_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc);
+static rb_node_dxstr_t *rb_node_dxstr_new(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc);
+static rb_node_evstr_t *rb_node_evstr_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc);
+static rb_node_regx_t *rb_node_regx_new(struct parser_params *p, rb_parser_string_t *string, int options, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *content_loc, const YYLTYPE *closing_loc);
+static rb_node_once_t *rb_node_once_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_args_t *rb_node_args_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_args_aux_t *rb_node_args_aux_new(struct parser_params *p, ID nd_pid, int nd_plen, const YYLTYPE *loc);
+static rb_node_opt_arg_t *rb_node_opt_arg_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_kw_arg_t *rb_node_kw_arg_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_postarg_t *rb_node_postarg_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc);
+static rb_node_argscat_t *rb_node_argscat_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_argspush_t *rb_node_argspush_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc);
+static rb_node_splat_t *rb_node_splat_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_block_pass_t *rb_node_block_pass_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_defn_t *rb_node_defn_new(struct parser_params *p, ID nd_mid, NODE *nd_defn, const YYLTYPE *loc);
+static rb_node_defs_t *rb_node_defs_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_defn, const YYLTYPE *loc);
+static rb_node_alias_t *rb_node_alias_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_valias_t *rb_node_valias_new(struct parser_params *p, ID nd_alias, ID nd_orig, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_undef_t *rb_node_undef_new(struct parser_params *p, NODE *nd_undef, const YYLTYPE *loc);
+static rb_node_class_t *rb_node_class_new(struct parser_params *p, NODE *nd_cpath, NODE *nd_body, NODE *nd_super, const YYLTYPE *loc, const YYLTYPE *class_keyword_loc, const YYLTYPE *inheritance_operator_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_module_t *rb_node_module_new(struct parser_params *p, NODE *nd_cpath, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *module_keyword_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_sclass_t *rb_node_sclass_new(struct parser_params *p, NODE *nd_recv, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *class_keyword_loc, const YYLTYPE *operator_loc, const YYLTYPE *end_keyword_loc);
+static rb_node_colon2_t *rb_node_colon2_new(struct parser_params *p, NODE *nd_head, ID nd_mid, const YYLTYPE *loc, const YYLTYPE *delimiter_loc, const YYLTYPE *name_loc);
+static rb_node_colon3_t *rb_node_colon3_new(struct parser_params *p, ID nd_mid, const YYLTYPE *loc, const YYLTYPE *delimiter_loc, const YYLTYPE *name_loc);
+static rb_node_dot2_t *rb_node_dot2_new(struct parser_params *p, NODE *nd_beg, NODE *nd_end, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_dot3_t *rb_node_dot3_new(struct parser_params *p, NODE *nd_beg, NODE *nd_end, const YYLTYPE *loc, const YYLTYPE *operator_loc);
+static rb_node_self_t *rb_node_self_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_nil_t *rb_node_nil_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_true_t *rb_node_true_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_false_t *rb_node_false_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_errinfo_t *rb_node_errinfo_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_defined_t *rb_node_defined_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_postexe_t *rb_node_postexe_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc);
+static rb_node_sym_t *rb_node_sym_new(struct parser_params *p, VALUE str, const YYLTYPE *loc);
+static rb_node_dsym_t *rb_node_dsym_new(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc);
+static rb_node_attrasgn_t *rb_node_attrasgn_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc);
+static rb_node_lambda_t *rb_node_lambda_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc);
+static rb_node_aryptn_t *rb_node_aryptn_new(struct parser_params *p, NODE *pre_args, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc);
+static rb_node_hshptn_t *rb_node_hshptn_new(struct parser_params *p, NODE *nd_pconst, NODE *nd_pkwargs, NODE *nd_pkwrestarg, const YYLTYPE *loc);
+static rb_node_fndptn_t *rb_node_fndptn_new(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc);
+static rb_node_line_t *rb_node_line_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_file_t *rb_node_file_new(struct parser_params *p, VALUE str, const YYLTYPE *loc);
+static rb_node_error_t *rb_node_error_new(struct parser_params *p, const YYLTYPE *loc);
+
+#define NEW_SCOPE(a,b,c,loc) (NODE *)rb_node_scope_new(p,a,b,c,loc)
+#define NEW_SCOPE2(t,a,b,c,loc) (NODE *)rb_node_scope_new2(p,t,a,b,c,loc)
+#define NEW_BLOCK(a,loc) (NODE *)rb_node_block_new(p,a,loc)
+#define NEW_IF(c,t,e,loc,ik_loc,tk_loc,ek_loc) (NODE *)rb_node_if_new(p,c,t,e,loc,ik_loc,tk_loc,ek_loc)
+#define NEW_UNLESS(c,t,e,loc,k_loc,t_loc,e_loc) (NODE *)rb_node_unless_new(p,c,t,e,loc,k_loc,t_loc,e_loc)
+#define NEW_CASE(h,b,loc,ck_loc,ek_loc) (NODE *)rb_node_case_new(p,h,b,loc,ck_loc,ek_loc)
+#define NEW_CASE2(b,loc,ck_loc,ek_loc) (NODE *)rb_node_case2_new(p,b,loc,ck_loc,ek_loc)
+#define NEW_CASE3(h,b,loc,ck_loc,ek_loc) (NODE *)rb_node_case3_new(p,h,b,loc,ck_loc,ek_loc)
+#define NEW_WHEN(c,t,e,loc,k_loc,t_loc) (NODE *)rb_node_when_new(p,c,t,e,loc,k_loc,t_loc)
+#define NEW_IN(c,t,e,loc,ik_loc,tk_loc,o_loc) (NODE *)rb_node_in_new(p,c,t,e,loc,ik_loc,tk_loc,o_loc)
+#define NEW_WHILE(c,b,n,loc,k_loc,c_loc) (NODE *)rb_node_while_new(p,c,b,n,loc,k_loc,c_loc)
+#define NEW_UNTIL(c,b,n,loc,k_loc,c_loc) (NODE *)rb_node_until_new(p,c,b,n,loc,k_loc,c_loc)
+#define NEW_ITER(a,b,loc) (NODE *)rb_node_iter_new(p,a,b,loc)
+#define NEW_FOR(i,b,loc,f_loc,i_loc,d_loc,e_loc) (NODE *)rb_node_for_new(p,i,b,loc,f_loc,i_loc,d_loc,e_loc)
+#define NEW_FOR_MASGN(v,loc) (NODE *)rb_node_for_masgn_new(p,v,loc)
+#define NEW_RETRY(loc) (NODE *)rb_node_retry_new(p,loc)
+#define NEW_BEGIN(b,loc) (NODE *)rb_node_begin_new(p,b,loc)
+#define NEW_RESCUE(b,res,e,loc) (NODE *)rb_node_rescue_new(p,b,res,e,loc)
+#define NEW_RESBODY(a,v,ex,n,loc) (NODE *)rb_node_resbody_new(p,a,v,ex,n,loc)
+#define NEW_ENSURE(b,en,loc) (NODE *)rb_node_ensure_new(p,b,en,loc)
+#define NEW_AND(f,s,loc,op_loc) (NODE *)rb_node_and_new(p,f,s,loc,op_loc)
+#define NEW_OR(f,s,loc,op_loc) (NODE *)rb_node_or_new(p,f,s,loc,op_loc)
+#define NEW_MASGN(l,r,loc) rb_node_masgn_new(p,l,r,loc)
+#define NEW_LASGN(v,val,loc) (NODE *)rb_node_lasgn_new(p,v,val,loc)
+#define NEW_DASGN(v,val,loc) (NODE *)rb_node_dasgn_new(p,v,val,loc)
+#define NEW_GASGN(v,val,loc) (NODE *)rb_node_gasgn_new(p,v,val,loc)
+#define NEW_IASGN(v,val,loc) (NODE *)rb_node_iasgn_new(p,v,val,loc)
+#define NEW_CDECL(v,val,path,share,loc) (NODE *)rb_node_cdecl_new(p,v,val,path,share,loc)
+#define NEW_CVASGN(v,val,loc) (NODE *)rb_node_cvasgn_new(p,v,val,loc)
+#define NEW_OP_ASGN1(r,id,idx,rval,loc,c_op_loc,o_loc,c_loc,b_op_loc) (NODE *)rb_node_op_asgn1_new(p,r,id,idx,rval,loc,c_op_loc,o_loc,c_loc,b_op_loc)
+#define NEW_OP_ASGN2(r,t,i,o,val,loc,c_op_loc,m_loc,b_op_loc) (NODE *)rb_node_op_asgn2_new(p,r,val,i,o,t,loc,c_op_loc,m_loc,b_op_loc)
+#define NEW_OP_ASGN_OR(i,val,loc) (NODE *)rb_node_op_asgn_or_new(p,i,val,loc)
+#define NEW_OP_ASGN_AND(i,val,loc) (NODE *)rb_node_op_asgn_and_new(p,i,val,loc)
+#define NEW_OP_CDECL(v,op,val,share,loc) (NODE *)rb_node_op_cdecl_new(p,v,val,op,share,loc)
+#define NEW_CALL(r,m,a,loc) (NODE *)rb_node_call_new(p,r,m,a,loc)
+#define NEW_OPCALL(r,m,a,loc) (NODE *)rb_node_opcall_new(p,r,m,a,loc)
+#define NEW_FCALL(m,a,loc) rb_node_fcall_new(p,m,a,loc)
+#define NEW_VCALL(m,loc) (NODE *)rb_node_vcall_new(p,m,loc)
+#define NEW_QCALL0(r,m,a,loc) (NODE *)rb_node_qcall_new(p,r,m,a,loc)
+#define NEW_SUPER(a,loc,k_loc,l_loc,r_loc) (NODE *)rb_node_super_new(p,a,loc,k_loc,l_loc,r_loc)
+#define NEW_ZSUPER(loc) (NODE *)rb_node_zsuper_new(p,loc)
+#define NEW_LIST(a,loc) (NODE *)rb_node_list_new(p,a,loc)
+#define NEW_LIST2(h,l,n,loc) (NODE *)rb_node_list_new2(p,h,l,n,loc)
+#define NEW_ZLIST(loc) (NODE *)rb_node_zlist_new(p,loc)
+#define NEW_HASH(a,loc) (NODE *)rb_node_hash_new(p,a,loc)
+#define NEW_RETURN(s,loc,k_loc) (NODE *)rb_node_return_new(p,s,loc,k_loc)
+#define NEW_YIELD(a,loc,k_loc,l_loc,r_loc) (NODE *)rb_node_yield_new(p,a,loc,k_loc,l_loc,r_loc)
+#define NEW_LVAR(v,loc) (NODE *)rb_node_lvar_new(p,v,loc)
+#define NEW_DVAR(v,loc) (NODE *)rb_node_dvar_new(p,v,loc)
+#define NEW_GVAR(v,loc) (NODE *)rb_node_gvar_new(p,v,loc)
+#define NEW_IVAR(v,loc) (NODE *)rb_node_ivar_new(p,v,loc)
+#define NEW_CONST(v,loc) (NODE *)rb_node_const_new(p,v,loc)
+#define NEW_CVAR(v,loc) (NODE *)rb_node_cvar_new(p,v,loc)
+#define NEW_NTH_REF(n,loc) (NODE *)rb_node_nth_ref_new(p,n,loc)
+#define NEW_BACK_REF(n,loc) (NODE *)rb_node_back_ref_new(p,n,loc)
+#define NEW_MATCH2(n1,n2,loc) (NODE *)rb_node_match2_new(p,n1,n2,loc)
+#define NEW_MATCH3(r,n2,loc) (NODE *)rb_node_match3_new(p,r,n2,loc)
+#define NEW_INTEGER(val, base,loc) (NODE *)rb_node_integer_new(p,val,base,loc)
+#define NEW_FLOAT(val,loc) (NODE *)rb_node_float_new(p,val,loc)
+#define NEW_RATIONAL(val,base,seen_point,loc) (NODE *)rb_node_rational_new(p,val,base,seen_point,loc)
+#define NEW_IMAGINARY(val,base,seen_point,numeric_type,loc) (NODE *)rb_node_imaginary_new(p,val,base,seen_point,numeric_type,loc)
+#define NEW_STR(s,loc) (NODE *)rb_node_str_new(p,s,loc)
+#define NEW_DSTR0(s,l,n,loc) (NODE *)rb_node_dstr_new0(p,s,l,n,loc)
+#define NEW_DSTR(s,loc) (NODE *)rb_node_dstr_new(p,s,loc)
+#define NEW_XSTR(s,loc) (NODE *)rb_node_xstr_new(p,s,loc)
+#define NEW_DXSTR(s,l,n,loc) (NODE *)rb_node_dxstr_new(p,s,l,n,loc)
+#define NEW_EVSTR(n,loc,o_loc,c_loc) (NODE *)rb_node_evstr_new(p,n,loc,o_loc,c_loc)
+#define NEW_REGX(str,opts,loc,o_loc,ct_loc,c_loc) (NODE *)rb_node_regx_new(p,str,opts,loc,o_loc,ct_loc,c_loc)
+#define NEW_ONCE(b,loc) (NODE *)rb_node_once_new(p,b,loc)
+#define NEW_ARGS(loc) rb_node_args_new(p,loc)
+#define NEW_ARGS_AUX(r,b,loc) rb_node_args_aux_new(p,r,b,loc)
+#define NEW_OPT_ARG(v,loc) rb_node_opt_arg_new(p,v,loc)
+#define NEW_KW_ARG(v,loc) rb_node_kw_arg_new(p,v,loc)
+#define NEW_POSTARG(i,v,loc) (NODE *)rb_node_postarg_new(p,i,v,loc)
+#define NEW_ARGSCAT(a,b,loc) (NODE *)rb_node_argscat_new(p,a,b,loc)
+#define NEW_ARGSPUSH(a,b,loc) (NODE *)rb_node_argspush_new(p,a,b,loc)
+#define NEW_SPLAT(a,loc,op_loc) (NODE *)rb_node_splat_new(p,a,loc,op_loc)
+#define NEW_BLOCK_PASS(b,loc,o_loc) rb_node_block_pass_new(p,b,loc,o_loc)
+#define NEW_DEFN(i,s,loc) (NODE *)rb_node_defn_new(p,i,s,loc)
+#define NEW_DEFS(r,i,s,loc) (NODE *)rb_node_defs_new(p,r,i,s,loc)
+#define NEW_ALIAS(n,o,loc,k_loc) (NODE *)rb_node_alias_new(p,n,o,loc,k_loc)
+#define NEW_VALIAS(n,o,loc,k_loc) (NODE *)rb_node_valias_new(p,n,o,loc,k_loc)
+#define NEW_UNDEF(i,loc) (NODE *)rb_node_undef_new(p,i,loc)
+#define NEW_CLASS(n,b,s,loc,ck_loc,io_loc,ek_loc) (NODE *)rb_node_class_new(p,n,b,s,loc,ck_loc,io_loc,ek_loc)
+#define NEW_MODULE(n,b,loc,mk_loc,ek_loc) (NODE *)rb_node_module_new(p,n,b,loc,mk_loc,ek_loc)
+#define NEW_SCLASS(r,b,loc,ck_loc,op_loc,ek_loc) (NODE *)rb_node_sclass_new(p,r,b,loc,ck_loc,op_loc,ek_loc)
+#define NEW_COLON2(c,i,loc,d_loc,n_loc) (NODE *)rb_node_colon2_new(p,c,i,loc,d_loc,n_loc)
+#define NEW_COLON3(i,loc,d_loc,n_loc) (NODE *)rb_node_colon3_new(p,i,loc,d_loc,n_loc)
+#define NEW_DOT2(b,e,loc,op_loc) (NODE *)rb_node_dot2_new(p,b,e,loc,op_loc)
+#define NEW_DOT3(b,e,loc,op_loc) (NODE *)rb_node_dot3_new(p,b,e,loc,op_loc)
+#define NEW_SELF(loc) (NODE *)rb_node_self_new(p,loc)
+#define NEW_NIL(loc) (NODE *)rb_node_nil_new(p,loc)
+#define NEW_TRUE(loc) (NODE *)rb_node_true_new(p,loc)
+#define NEW_FALSE(loc) (NODE *)rb_node_false_new(p,loc)
+#define NEW_ERRINFO(loc) (NODE *)rb_node_errinfo_new(p,loc)
+#define NEW_DEFINED(e,loc,k_loc) (NODE *)rb_node_defined_new(p,e,loc, k_loc)
+#define NEW_POSTEXE(b,loc,k_loc,o_loc,c_loc) (NODE *)rb_node_postexe_new(p,b,loc,k_loc,o_loc,c_loc)
+#define NEW_SYM(str,loc) (NODE *)rb_node_sym_new(p,str,loc)
+#define NEW_DSYM(s,l,n,loc) (NODE *)rb_node_dsym_new(p,s,l,n,loc)
+#define NEW_ATTRASGN(r,m,a,loc) (NODE *)rb_node_attrasgn_new(p,r,m,a,loc)
+#define NEW_LAMBDA(a,b,loc,op_loc,o_loc,c_loc) (NODE *)rb_node_lambda_new(p,a,b,loc,op_loc,o_loc,c_loc)
+#define NEW_ARYPTN(pre,r,post,loc) (NODE *)rb_node_aryptn_new(p,pre,r,post,loc)
+#define NEW_HSHPTN(c,kw,kwrest,loc) (NODE *)rb_node_hshptn_new(p,c,kw,kwrest,loc)
+#define NEW_FNDPTN(pre,a,post,loc) (NODE *)rb_node_fndptn_new(p,pre,a,post,loc)
+#define NEW_LINE(loc) (NODE *)rb_node_line_new(p,loc)
+#define NEW_FILE(str,loc) (NODE *)rb_node_file_new(p,str,loc)
+#define NEW_ENCODING(loc) (NODE *)rb_node_encoding_new(p,loc)
+#define NEW_ERROR(loc) (NODE *)rb_node_error_new(p,loc)
+
+enum internal_node_type {
+ NODE_INTERNAL_ONLY = NODE_LAST,
+ NODE_DEF_TEMP,
+ NODE_EXITS,
+ NODE_INTERNAL_LAST
+};
+
+static const char *
+parser_node_name(int node)
{
- if (!SPECIAL_CONST_P(obj)
- && !RB_TYPE_P(obj, T_NODE) /* Ripper jumbles NODE objects and other objects... */
- ) {
- rb_ast_add_mark_object(p->ast, obj);
+ switch (node) {
+ case NODE_DEF_TEMP:
+ return "NODE_DEF_TEMP";
+ case NODE_EXITS:
+ return "NODE_EXITS";
+ default:
+ return ruby_node_name(node);
}
- return obj;
}
-#else
-static NODE* node_newnode_with_locals(struct parser_params *, enum node_type, VALUE, VALUE, const rb_code_location_t*);
-#endif
-static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*);
-#define rb_node_newnode(type, a1, a2, a3, loc) node_newnode(p, (type), (a1), (a2), (a3), (loc))
+/* This node is parse.y internal */
+struct RNode_DEF_TEMP {
+ NODE node;
+
+ /* for NODE_DEFN/NODE_DEFS */
+
+ struct RNode *nd_def;
+ ID nd_mid;
+
+ struct {
+ int max_numparam;
+ NODE *numparam_save;
+ struct lex_context ctxt;
+ } save;
+};
+
+#define RNODE_DEF_TEMP(node) ((struct RNode_DEF_TEMP *)(node))
+
+static rb_node_break_t *rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_next_t *rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_redo_t *rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
+static rb_node_def_temp_t *rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc);
+static rb_node_def_temp_t *def_head_save(struct parser_params *p, rb_node_def_temp_t *n);
+
+#define NEW_BREAK(s,loc,k_loc) (NODE *)rb_node_break_new(p,s,loc,k_loc)
+#define NEW_NEXT(s,loc,k_loc) (NODE *)rb_node_next_new(p,s,loc,k_loc)
+#define NEW_REDO(loc,k_loc) (NODE *)rb_node_redo_new(p,loc,k_loc)
+#define NEW_DEF_TEMP(loc) rb_node_def_temp_new(p,loc)
+
+/* Make a new internal node, which should not be appeared in the
+ * result AST and does not have node_id and location. */
+static NODE* node_new_internal(struct parser_params *p, enum node_type type, size_t size, size_t alignment);
+#define NODE_NEW_INTERNAL(ndtype, type) (type *)node_new_internal(p, (enum node_type)(ndtype), sizeof(type), RUBY_ALIGNOF(type))
static NODE *nd_set_loc(NODE *nd, const YYLTYPE *loc);
@@ -704,7 +1344,14 @@ parser_get_node_id(struct parser_params *p)
return node_id;
}
-#ifndef RIPPER
+static void
+anddot_multiple_assignment_check(struct parser_params* p, const YYLTYPE *loc, ID id)
+{
+ if (id == tANDDOT) {
+ yyerror1(loc, "&. inside multiple assignment destination");
+ }
+}
+
static inline void
set_line_body(NODE *body, int line)
{
@@ -716,24 +1363,47 @@ set_line_body(NODE *body, int line)
}
}
+static void
+set_embraced_location(NODE *node, const rb_code_location_t *beg, const rb_code_location_t *end)
+{
+ RNODE_ITER(node)->nd_body->nd_loc = code_loc_gen(beg, end);
+ nd_set_line(node, beg->end_pos.lineno);
+}
+
+static NODE *
+last_expr_node(NODE *expr)
+{
+ while (expr) {
+ if (nd_type_p(expr, NODE_BLOCK)) {
+ expr = RNODE_BLOCK(RNODE_BLOCK(expr)->nd_end)->nd_head;
+ }
+ else if (nd_type_p(expr, NODE_BEGIN) && RNODE_BEGIN(expr)->nd_body) {
+ expr = RNODE_BEGIN(expr)->nd_body;
+ }
+ else {
+ break;
+ }
+ }
+ return expr;
+}
+
+#ifndef RIPPER
#define yyparse ruby_yyparse
+#endif
static NODE* cond(struct parser_params *p, NODE *node, const YYLTYPE *loc);
static NODE* method_cond(struct parser_params *p, NODE *node, const YYLTYPE *loc);
-#define new_nil(loc) NEW_NIL(loc)
static NODE *new_nil_at(struct parser_params *p, const rb_code_position_t *pos);
-static NODE *new_if(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_unless(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
+static NODE *new_if(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*,const YYLTYPE*,const YYLTYPE*);
+static NODE *new_unless(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*,const YYLTYPE*,const YYLTYPE*);
static NODE *logop(struct parser_params*,ID,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
static NODE *newline_node(NODE*);
static void fixpos(NODE*,NODE*);
-static int value_expr_gen(struct parser_params*,NODE*);
+static int value_expr(struct parser_params*,NODE*);
static void void_expr(struct parser_params*,NODE*);
static NODE *remove_begin(NODE*);
-static NODE *remove_begin_all(NODE*);
-#define value_expr(node) value_expr_gen(p, (node))
static NODE *void_stmts(struct parser_params*,NODE*);
static void reduce_nodes(struct parser_params*,NODE**);
static void block_dup_check(struct parser_params*,NODE*,NODE*);
@@ -745,8 +1415,9 @@ static NODE *arg_append(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
static NODE *last_arg_append(struct parser_params *p, NODE *args, NODE *last_arg, const YYLTYPE *loc);
static NODE *rest_arg_append(struct parser_params *p, NODE *args, NODE *rest_arg, const YYLTYPE *loc);
static NODE *literal_concat(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_evstr(struct parser_params*,NODE*,const YYLTYPE*);
+static NODE *new_evstr(struct parser_params*,NODE*,const YYLTYPE*,const YYLTYPE*,const YYLTYPE*);
static NODE *new_dstr(struct parser_params*,NODE*,const YYLTYPE*);
+static NODE *str2dstr(struct parser_params*,NODE*);
static NODE *evstr2dstr(struct parser_params*,NODE*);
static NODE *splat_array(NODE*);
static void mark_lvar_used(struct parser_params *p, NODE *rhs);
@@ -755,25 +1426,26 @@ static NODE *call_bin_op(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,con
static NODE *call_uni_op(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*);
static NODE *new_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc);
static NODE *new_command_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *args, NODE *block, const YYLTYPE *op_loc, const YYLTYPE *loc);
-static NODE *method_add_block(struct parser_params*p, NODE *m, NODE *b, const YYLTYPE *loc) {b->nd_iter = m; b->nd_loc = *loc; return b;}
+static NODE *method_add_block(struct parser_params*p, NODE *m, NODE *b, const YYLTYPE *loc) {RNODE_ITER(b)->nd_iter = m; b->nd_loc = *loc; return b;}
static bool args_info_empty_p(struct rb_args_info *args);
-static NODE *new_args(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,const YYLTYPE*);
-static NODE *new_args_tail(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
+static rb_node_args_t *new_args(struct parser_params*,rb_node_args_aux_t*,rb_node_opt_arg_t*,ID,rb_node_args_aux_t*,rb_node_args_t*,const YYLTYPE*);
+static rb_node_args_t *new_args_tail(struct parser_params*,rb_node_kw_arg_t*,ID,ID,const YYLTYPE*);
+#define new_empty_args_tail(p, loc) new_args_tail(p, 0, 0, 0, loc)
static NODE *new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE *aryptn, const YYLTYPE *loc);
-static NODE *new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID rest_arg, NODE *post_args, const YYLTYPE *loc);
+static NODE *new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc);
static NODE *new_find_pattern(struct parser_params *p, NODE *constant, NODE *fndptn, const YYLTYPE *loc);
-static NODE *new_find_pattern_tail(struct parser_params *p, ID pre_rest_arg, NODE *args, ID post_rest_arg, const YYLTYPE *loc);
+static NODE *new_find_pattern_tail(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc);
static NODE *new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YYLTYPE *loc);
static NODE *new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc);
-static NODE *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc);
-static NODE *args_with_numbered(struct parser_params*,NODE*,int);
+static rb_node_kw_arg_t *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc);
+static rb_node_args_t *args_with_numbered(struct parser_params*,rb_node_args_t*,int,ID);
-static VALUE negate_lit(struct parser_params*, VALUE);
+static NODE* negate_lit(struct parser_params*, NODE*,const YYLTYPE*);
+static void no_blockarg(struct parser_params*,NODE*);
static NODE *ret_args(struct parser_params*,NODE*);
-static NODE *arg_blk_pass(NODE*,NODE*);
-static NODE *new_yield(struct parser_params*,NODE*,const YYLTYPE*);
+static NODE *arg_blk_pass(NODE*,rb_node_block_pass_t*);
static NODE *dsym_node(struct parser_params*,NODE*,const YYLTYPE*);
static NODE *gettable(struct parser_params*,ID,const YYLTYPE*);
@@ -782,26 +1454,26 @@ static NODE *assignable(struct parser_params*,ID,NODE*,const YYLTYPE*);
static NODE *aryset(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
static NODE *attrset(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
-static void rb_backref_error(struct parser_params*,NODE*);
+static VALUE rb_backref_error(struct parser_params*,NODE*);
static NODE *node_assign(struct parser_params*,NODE*,NODE*,struct lex_context,const YYLTYPE*);
static NODE *new_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, struct lex_context, const YYLTYPE *loc);
-static NODE *new_ary_op_assign(struct parser_params *p, NODE *ary, NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc);
-static NODE *new_attr_op_assign(struct parser_params *p, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc);
+static NODE *new_ary_op_assign(struct parser_params *p, NODE *ary, NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc, const YYLTYPE *binary_operator_loc);
+static NODE *new_attr_op_assign(struct parser_params *p, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *message_loc, const YYLTYPE *binary_operator_loc);
static NODE *new_const_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, struct lex_context, const YYLTYPE *loc);
static NODE *new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_else, NODE *ensure, const YYLTYPE *loc);
static NODE *const_decl(struct parser_params *p, NODE* path, const YYLTYPE *loc);
-static NODE *opt_arg_append(NODE*, NODE*);
-static NODE *kwd_append(NODE*, NODE*);
+static rb_node_opt_arg_t *opt_arg_append(rb_node_opt_arg_t*, rb_node_opt_arg_t*);
+static rb_node_kw_arg_t *kwd_append(rb_node_kw_arg_t*, rb_node_kw_arg_t*);
static NODE *new_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc);
static NODE *new_unique_key_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc);
-static NODE *new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc);
+static NODE *new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc, const YYLTYPE *keyword_loc);
-static NODE *new_regexp(struct parser_params *, NODE *, int, const YYLTYPE *);
+static NODE *new_regexp(struct parser_params *, NODE *, int, const YYLTYPE *, const YYLTYPE *, const YYLTYPE *, const YYLTYPE *);
#define make_list(list, loc) ((list) ? (nd_set_loc(list, loc), list) : NEW_ZLIST(loc))
@@ -813,81 +1485,28 @@ static NODE *match_op(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYL
static rb_ast_id_table_t *local_tbl(struct parser_params*);
-static VALUE reg_compile(struct parser_params*, VALUE, int);
-static void reg_fragment_setenc(struct parser_params*, VALUE, int);
-static int reg_fragment_check(struct parser_params*, VALUE, int);
-static NODE *reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc);
+static VALUE reg_compile(struct parser_params*, rb_parser_string_t*, int);
+static void reg_fragment_setenc(struct parser_params*, rb_parser_string_t*, int);
-static int literal_concat0(struct parser_params *p, VALUE head, VALUE tail);
+static int literal_concat0(struct parser_params *p, rb_parser_string_t *head, rb_parser_string_t *tail);
static NODE *heredoc_dedent(struct parser_params*,NODE*);
static void check_literal_when(struct parser_params *p, NODE *args, const YYLTYPE *loc);
-#define get_id(id) (id)
-#define get_value(val) (val)
-#define get_num(num) (num)
-#else /* RIPPER */
-#define NODE_RIPPER NODE_CDECL
-#define NEW_RIPPER(a,b,c,loc) (VALUE)NEW_CDECL(a,b,c,loc)
-
-static inline int ripper_is_node_yylval(VALUE n);
-
-static inline VALUE
-ripper_new_yylval(struct parser_params *p, ID a, VALUE b, VALUE c)
-{
- if (ripper_is_node_yylval(c)) c = RNODE(c)->nd_cval;
- add_mark_object(p, b);
- add_mark_object(p, c);
- return NEW_RIPPER(a, b, c, &NULL_LOC);
-}
-
-static inline int
-ripper_is_node_yylval(VALUE n)
-{
- return RB_TYPE_P(n, T_NODE) && nd_type_p(RNODE(n), NODE_RIPPER);
-}
-
-#define value_expr(node) ((void)(node))
-#define remove_begin(node) (node)
-#define void_stmts(p,x) (x)
-#define rb_dvar_defined(id, base) 0
-#define rb_local_defined(id, base) 0
-static ID ripper_get_id(VALUE);
-#define get_id(id) ripper_get_id(id)
-static VALUE ripper_get_value(VALUE);
-#define get_value(val) ripper_get_value(val)
-#define get_num(num) (int)get_id(num)
-static VALUE assignable(struct parser_params*,VALUE);
-static int id_is_var(struct parser_params *p, ID id);
-
-#define method_cond(p,node,loc) (node)
-#define call_bin_op(p, recv,id,arg1,op_loc,loc) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1))
-#define match_op(p,node1,node2,op_loc,loc) call_bin_op(0, (node1), idEqTilde, (node2), op_loc, loc)
-#define call_uni_op(p, recv,id,op_loc,loc) dispatch2(unary, STATIC_ID2SYM(id), (recv))
-#define logop(p,id,node1,node2,op_loc,loc) call_bin_op(0, (node1), (id), (node2), op_loc, loc)
+static rb_locations_lambda_body_t* new_locations_lambda_body(struct parser_params *p, NODE *node, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc);
-#define new_nil(loc) Qnil
-
-static VALUE new_regexp(struct parser_params *, VALUE, VALUE, const YYLTYPE *);
-
-static VALUE const_decl(struct parser_params *p, VALUE path);
-
-static VALUE var_field(struct parser_params *p, VALUE a);
+#ifdef RIPPER
+#define get_value(idx) (rb_ary_entry(p->s_value_stack, idx))
+#define set_value(val) (p->s_lvalue = val)
static VALUE assign_error(struct parser_params *p, const char *mesg, VALUE a);
-
-static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *);
-
-static VALUE backref_error(struct parser_params*, NODE *, VALUE);
-#endif /* !RIPPER */
-
-/* forward declaration */
-typedef struct rb_strterm_heredoc_struct rb_strterm_heredoc_t;
+static int id_is_var(struct parser_params *p, ID id);
+#endif
RUBY_SYMBOL_EXPORT_BEGIN
VALUE rb_parser_reg_compile(struct parser_params* p, VALUE str, int options);
-int rb_reg_fragment_setenc(struct parser_params*, VALUE, int);
+int rb_reg_fragment_setenc(struct parser_params*, rb_parser_string_t *, int);
enum lex_state_e rb_parser_trace_lex_state(struct parser_params *, enum lex_state_e, enum lex_state_e, int);
-VALUE rb_parser_lex_state_name(enum lex_state_e state);
+VALUE rb_parser_lex_state_name(struct parser_params *p, enum lex_state_e state);
void rb_parser_show_bitstack(struct parser_params *, stack_type, const char *, int);
PRINTF_ARGS(void rb_parser_fatal(struct parser_params *p, const char *fmt, ...), 2, 3);
YYLTYPE *rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
@@ -896,15 +1515,13 @@ YYLTYPE *rb_parser_set_location_of_heredoc_end(struct parser_params *p, YYLTYPE
YYLTYPE *rb_parser_set_location_of_dummy_end(struct parser_params *p, YYLTYPE *yylloc);
YYLTYPE *rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc);
YYLTYPE *rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc);
+void ruby_show_error_line(struct parser_params *p, VALUE errbuf, const YYLTYPE *yylloc, int lineno, rb_parser_string_t *str);
RUBY_SYMBOL_EXPORT_END
+static void flush_string_content(struct parser_params *p, rb_encoding *enc, size_t back);
static void error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *loc);
static void error_duplicate_pattern_key(struct parser_params *p, ID id, const YYLTYPE *loc);
-#ifndef RIPPER
-static ID formal_argument(struct parser_params*, ID);
-#else
-static ID formal_argument(struct parser_params*, VALUE);
-#endif
+static VALUE formal_argument_error(struct parser_params*, ID);
static ID shadowing_lvar(struct parser_params*,ID);
static void new_bv(struct parser_params*,ID);
@@ -914,19 +1531,20 @@ static void local_var(struct parser_params*, ID);
static void arg_var(struct parser_params*, ID);
static int local_id(struct parser_params *p, ID id);
static int local_id_ref(struct parser_params*, ID, ID **);
-#ifndef RIPPER
-static ID internal_id(struct parser_params*);
+#define internal_id rb_parser_internal_id
+ID internal_id(struct parser_params*);
static NODE *new_args_forward_call(struct parser_params*, NODE*, const YYLTYPE*, const YYLTYPE*);
-#endif
static int check_forwarding_args(struct parser_params*);
static void add_forwarding_args(struct parser_params *p);
+static void forwarding_arg_check(struct parser_params *p, ID arg, ID all, const char *var);
static const struct vtable *dyna_push(struct parser_params *);
static void dyna_pop(struct parser_params*, const struct vtable *);
static int dyna_in_block(struct parser_params*);
#define dyna_var(p, id) local_var(p, id)
static int dvar_defined(struct parser_params*, ID);
-static int dvar_defined_ref(struct parser_params*, ID, ID**);
+#define dvar_defined_ref rb_parser_dvar_defined_ref
+int dvar_defined_ref(struct parser_params*, ID, ID**);
static int dvar_curr(struct parser_params*,ID);
static int lvar_defined(struct parser_params*, ID);
@@ -934,18 +1552,17 @@ static int lvar_defined(struct parser_params*, ID);
static NODE *numparam_push(struct parser_params *p);
static void numparam_pop(struct parser_params *p, NODE *prev_inner);
-#ifdef RIPPER
-# define METHOD_NOT idNOT
-#else
-# define METHOD_NOT '!'
-#endif
+#define METHOD_NOT '!'
#define idFWD_REST '*'
#define idFWD_KWREST idPow /* Use simple "**", as tDSTAR is "**arg" */
#define idFWD_BLOCK '&'
#define idFWD_ALL idDot3
-#define FORWARD_ARGS_WITH_RUBY2_KEYWORDS
+#define arg_FWD_BLOCK idFWD_BLOCK
+#define RE_ONIG_OPTION_IGNORECASE 1
+#define RE_ONIG_OPTION_EXTEND (RE_ONIG_OPTION_IGNORECASE<<1)
+#define RE_ONIG_OPTION_MULTILINE (RE_ONIG_OPTION_EXTEND<<1)
#define RE_OPTION_ONCE (1<<16)
#define RE_OPTION_ENCODING_SHIFT 8
#define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
@@ -954,74 +1571,11 @@ static void numparam_pop(struct parser_params *p, NODE *prev_inner);
#define RE_OPTION_MASK 0xff
#define RE_OPTION_ARG_ENCODING_NONE 32
-/* structs for managing terminator of string literal and heredocment */
-typedef struct rb_strterm_literal_struct {
- union {
- VALUE dummy;
- long nest;
- } u0;
- union {
- VALUE dummy;
- long func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
- } u1;
- union {
- VALUE dummy;
- long paren; /* '(' of `%q(...)` */
- } u2;
- union {
- VALUE dummy;
- long term; /* ')' of `%q(...)` */
- } u3;
-} rb_strterm_literal_t;
-
-#define HERETERM_LENGTH_BITS ((SIZEOF_VALUE - 1) * CHAR_BIT - 1)
-
-struct rb_strterm_heredoc_struct {
- VALUE lastline; /* the string of line that contains `<<"END"` */
- long offset; /* the column of END in `<<"END"` */
- int sourceline; /* lineno of the line that contains `<<"END"` */
- unsigned length /* the length of END in `<<"END"` */
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- : HERETERM_LENGTH_BITS
-# define HERETERM_LENGTH_MAX ((1U << HERETERM_LENGTH_BITS) - 1)
-#else
-# define HERETERM_LENGTH_MAX UINT_MAX
-#endif
- ;
-#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
- unsigned quote: 1;
- unsigned func: 8;
-#else
- uint8_t quote;
- uint8_t func;
-#endif
-};
-STATIC_ASSERT(rb_strterm_heredoc_t, sizeof(rb_strterm_heredoc_t) <= 4 * SIZEOF_VALUE);
-
-#define STRTERM_HEREDOC IMEMO_FL_USER0
-
-struct rb_strterm_struct {
- VALUE flags;
- union {
- rb_strterm_literal_t literal;
- rb_strterm_heredoc_t heredoc;
- } u;
-};
-
-#ifndef RIPPER
-void
-rb_strterm_mark(VALUE obj)
-{
- rb_strterm_t *strterm = (rb_strterm_t*)obj;
- if (RBASIC(obj)->flags & STRTERM_HEREDOC) {
- rb_strterm_heredoc_t *heredoc = &strterm->u.heredoc;
- rb_gc_mark(heredoc->lastline);
- }
-}
-#endif
+#define CHECK_LITERAL_WHEN (st_table *)1
+#define CASE_LABELS_ENABLED_P(case_labels) (case_labels && case_labels != CHECK_LITERAL_WHEN)
#define yytnamerr(yyres, yystr) (YYSIZE_T)rb_yytnamerr(p, yyres, yystr)
-size_t rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr);
+RUBY_FUNC_EXPORTED size_t rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr);
#define TOKEN2ID(tok) ( \
tTOKEN_LOCAL_BEGIN<(tok)&&(tok)<tTOKEN_LOCAL_END ? TOKEN2LOCALID(tok) : \
@@ -1035,12 +1589,11 @@ size_t rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr);
/****** Ripper *******/
#ifdef RIPPER
-#define RIPPER_VERSION "0.1.0"
-static inline VALUE intern_sym(const char *name);
+#include "eventids1.h"
+#include "eventids2.h"
-#include "eventids1.c"
-#include "eventids2.c"
+extern const struct ripper_parser_ids ripper_parser_ids;
static VALUE ripper_dispatch0(struct parser_params*,ID);
static VALUE ripper_dispatch1(struct parser_params*,ID,VALUE);
@@ -1049,57 +1602,21 @@ 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);
static VALUE ripper_dispatch7(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE);
-static void ripper_error(struct parser_params *p);
+void ripper_error(struct parser_params *p);
-#define dispatch0(n) ripper_dispatch0(p, TOKEN_PASTE(ripper_id_, n))
-#define dispatch1(n,a) ripper_dispatch1(p, TOKEN_PASTE(ripper_id_, n), (a))
-#define dispatch2(n,a,b) ripper_dispatch2(p, TOKEN_PASTE(ripper_id_, n), (a), (b))
-#define dispatch3(n,a,b,c) ripper_dispatch3(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
-#define dispatch4(n,a,b,c,d) ripper_dispatch4(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
-#define dispatch5(n,a,b,c,d,e) ripper_dispatch5(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
-#define dispatch7(n,a,b,c,d,e,f,g) ripper_dispatch7(p, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e), (f), (g))
+#define dispatch0(n) ripper_dispatch0(p, RIPPER_ID(n))
+#define dispatch1(n,a) ripper_dispatch1(p, RIPPER_ID(n), (a))
+#define dispatch2(n,a,b) ripper_dispatch2(p, RIPPER_ID(n), (a), (b))
+#define dispatch3(n,a,b,c) ripper_dispatch3(p, RIPPER_ID(n), (a), (b), (c))
+#define dispatch4(n,a,b,c,d) ripper_dispatch4(p, RIPPER_ID(n), (a), (b), (c), (d))
+#define dispatch5(n,a,b,c,d,e) ripper_dispatch5(p, RIPPER_ID(n), (a), (b), (c), (d), (e))
+#define dispatch7(n,a,b,c,d,e,f,g) ripper_dispatch7(p, RIPPER_ID(n), (a), (b), (c), (d), (e), (f), (g))
#define yyparse ripper_yyparse
-#define ID2VAL(id) STATIC_ID2SYM(id)
-#define TOKEN2VAL(t) ID2VAL(TOKEN2ID(t))
-#define KWD2EID(t, v) ripper_new_yylval(p, keyword_##t, get_value(v), 0)
-
-#define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
- dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
-
-#define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
-
-static inline VALUE
-new_args(struct parser_params *p, VALUE pre_args, VALUE opt_args, VALUE rest_arg, VALUE post_args, VALUE tail, YYLTYPE *loc)
-{
- NODE *t = (NODE *)tail;
- VALUE kw_args = t->u1.value, kw_rest_arg = t->u2.value, block = t->u3.value;
- return params_new(pre_args, opt_args, rest_arg, post_args, kw_args, kw_rest_arg, escape_Qundef(block));
-}
-
-static inline VALUE
-new_args_tail(struct parser_params *p, VALUE kw_args, VALUE kw_rest_arg, VALUE block, YYLTYPE *loc)
-{
- NODE *t = rb_node_newnode(NODE_ARGS_AUX, kw_args, kw_rest_arg, block, &NULL_LOC);
- add_mark_object(p, kw_args);
- add_mark_object(p, kw_rest_arg);
- add_mark_object(p, block);
- return (VALUE)t;
-}
-
-static inline VALUE
-args_with_numbered(struct parser_params *p, VALUE args, int max_numparam)
-{
- return args;
-}
-
static VALUE
-new_array_pattern(struct parser_params *p, VALUE constant, VALUE pre_arg, VALUE aryptn, const YYLTYPE *loc)
+aryptn_pre_args(struct parser_params *p, VALUE pre_arg, VALUE pre_args)
{
- NODE *t = (NODE *)aryptn;
- VALUE pre_args = t->u1.value, rest_arg = t->u2.value, post_args = t->u3.value;
-
if (!NIL_P(pre_arg)) {
if (!NIL_P(pre_args)) {
rb_ary_unshift(pre_args, pre_arg);
@@ -1108,102 +1625,22 @@ new_array_pattern(struct parser_params *p, VALUE constant, VALUE pre_arg, VALUE
pre_args = rb_ary_new_from_args(1, pre_arg);
}
}
- return dispatch4(aryptn, constant, pre_args, rest_arg, post_args);
-}
-
-static VALUE
-new_array_pattern_tail(struct parser_params *p, VALUE pre_args, VALUE has_rest, VALUE rest_arg, VALUE post_args, const YYLTYPE *loc)
-{
- NODE *t;
-
- if (has_rest) {
- rest_arg = dispatch1(var_field, rest_arg ? rest_arg : Qnil);
- }
- else {
- rest_arg = Qnil;
- }
-
- t = rb_node_newnode(NODE_ARYPTN, pre_args, rest_arg, post_args, &NULL_LOC);
- add_mark_object(p, pre_args);
- add_mark_object(p, rest_arg);
- add_mark_object(p, post_args);
- return (VALUE)t;
+ return pre_args;
}
-static VALUE
-new_find_pattern(struct parser_params *p, VALUE constant, VALUE fndptn, const YYLTYPE *loc)
-{
- NODE *t = (NODE *)fndptn;
- VALUE pre_rest_arg = t->u1.value, args = t->u2.value, post_rest_arg = t->u3.value;
-
- return dispatch4(fndptn, constant, pre_rest_arg, args, post_rest_arg);
-}
-
-static VALUE
-new_find_pattern_tail(struct parser_params *p, VALUE pre_rest_arg, VALUE args, VALUE post_rest_arg, const YYLTYPE *loc)
-{
- NODE *t;
-
- pre_rest_arg = dispatch1(var_field, pre_rest_arg ? pre_rest_arg : Qnil);
- post_rest_arg = dispatch1(var_field, post_rest_arg ? post_rest_arg : Qnil);
-
- t = rb_node_newnode(NODE_FNDPTN, pre_rest_arg, args, post_rest_arg, &NULL_LOC);
- add_mark_object(p, pre_rest_arg);
- add_mark_object(p, args);
- add_mark_object(p, post_rest_arg);
- return (VALUE)t;
-}
-
-#define new_hash(p,h,l) rb_ary_new_from_args(0)
-
-static VALUE
-new_unique_key_hash(struct parser_params *p, VALUE ary, const YYLTYPE *loc)
-{
- return ary;
-}
-
-static VALUE
-new_hash_pattern(struct parser_params *p, VALUE constant, VALUE hshptn, const YYLTYPE *loc)
-{
- NODE *t = (NODE *)hshptn;
- VALUE kw_args = t->u1.value, kw_rest_arg = t->u2.value;
- return dispatch3(hshptn, constant, kw_args, kw_rest_arg);
-}
-
-static VALUE
-new_hash_pattern_tail(struct parser_params *p, VALUE kw_args, VALUE kw_rest_arg, const YYLTYPE *loc)
-{
- NODE *t;
- if (kw_rest_arg) {
- kw_rest_arg = dispatch1(var_field, kw_rest_arg);
- }
- else {
- kw_rest_arg = Qnil;
- }
- t = rb_node_newnode(NODE_HSHPTN, kw_args, kw_rest_arg, 0, &NULL_LOC);
-
- add_mark_object(p, kw_args);
- add_mark_object(p, kw_rest_arg);
- return (VALUE)t;
-}
-
-#define new_defined(p,expr,loc) dispatch1(defined, (expr))
-
-static VALUE heredoc_dedent(struct parser_params*,VALUE);
+#define ID2VAL(id) STATIC_ID2SYM(id)
+#define TOKEN2VAL(t) ID2VAL(TOKEN2ID(t))
+#endif /* RIPPER */
-#else
-#define ID2VAL(id) (id)
-#define TOKEN2VAL(t) ID2VAL(t)
#define KWD2EID(t, v) keyword_##t
static NODE *
-set_defun_body(struct parser_params *p, NODE *n, NODE *args, NODE *body, const YYLTYPE *loc)
+new_scope_body(struct parser_params *p, rb_node_args_t *args, NODE *body, NODE *parent, const YYLTYPE *loc)
{
body = remove_begin(body);
reduce_nodes(p, &body);
- n->nd_defn = NEW_SCOPE(args, body, loc);
- n->nd_loc = *loc;
- nd_set_line(n->nd_defn, loc->end_pos.lineno);
+ NODE *n = NEW_SCOPE(args, body, parent, loc);
+ nd_set_line(n, loc->end_pos.lineno);
set_line_body(body, loc->beg_pos.lineno);
return n;
}
@@ -1213,29 +1650,39 @@ rescued_expr(struct parser_params *p, NODE *arg, NODE *rescue,
const YYLTYPE *arg_loc, const YYLTYPE *mod_loc, const YYLTYPE *res_loc)
{
YYLTYPE loc = code_loc_gen(mod_loc, res_loc);
- rescue = NEW_RESBODY(0, remove_begin(rescue), 0, &loc);
+ rescue = NEW_RESBODY(0, 0, remove_begin(rescue), 0, &loc);
loc.beg_pos = arg_loc->beg_pos;
return NEW_RESCUE(arg, rescue, 0, &loc);
}
-#endif /* RIPPER */
+static NODE *add_block_exit(struct parser_params *p, NODE *node);
+static rb_node_exits_t *init_block_exit(struct parser_params *p);
+static rb_node_exits_t *allow_block_exit(struct parser_params *p);
+static void restore_block_exit(struct parser_params *p, rb_node_exits_t *exits);
+static void clear_block_exit(struct parser_params *p, bool error);
static void
-restore_defun(struct parser_params *p, NODE *name)
+next_rescue_context(struct lex_context *next, const struct lex_context *outer, enum rescue_context def)
{
- YYSTYPE c = {.val = name->nd_cval};
- p->cur_arg = name->nd_vid;
- p->ctxt.in_def = c.ctxt.in_def;
- p->ctxt.shareable_constant_value = c.ctxt.shareable_constant_value;
+ next->in_rescue = outer->in_rescue == after_rescue ? after_rescue : def;
}
static void
-endless_method_name(struct parser_params *p, NODE *defn, const YYLTYPE *loc)
+restore_defun(struct parser_params *p, rb_node_def_temp_t *temp)
+{
+ /* See: def_name action */
+ struct lex_context ctxt = temp->save.ctxt;
+ p->ctxt.in_def = ctxt.in_def;
+ p->ctxt.shareable_constant_value = ctxt.shareable_constant_value;
+ p->ctxt.in_rescue = ctxt.in_rescue;
+ p->max_numparam = temp->save.max_numparam;
+ numparam_pop(p, temp->save.numparam_save);
+ clear_block_exit(p, true);
+}
+
+static void
+endless_method_name(struct parser_params *p, ID mid, const YYLTYPE *loc)
{
-#ifdef RIPPER
- defn = defn->nd_defn;
-#endif
- ID mid = defn->nd_mid;
if (is_attrset_id(mid)) {
yyerror1(loc, "setter method cannot be defined in an endless method definition");
}
@@ -1252,14 +1699,29 @@ endless_method_name(struct parser_params *p, NODE *defn, const YYLTYPE *loc)
} \
} while (0)
+#define begin_definition(k, loc_beg, loc_end) \
+ do { \
+ if (!(p->ctxt.in_class = (k)[0] != 0)) { \
+ /* singleton class */ \
+ p->ctxt.cant_return = !p->ctxt.in_def; \
+ p->ctxt.in_def = 0; \
+ } \
+ else if (p->ctxt.in_def) { \
+ YYLTYPE loc = code_loc_gen(loc_beg, loc_end); \
+ yyerror1(&loc, k " definition in method body"); \
+ } \
+ else { \
+ p->ctxt.cant_return = 1; \
+ } \
+ local_push(p, 0); \
+ } while (0)
+
#ifndef RIPPER
-# define Qnone 0
-# define Qnull 0
# define ifndef_ripper(x) (x)
+# define ifdef_ripper(r,x) (x)
#else
-# define Qnone Qnil
-# define Qnull Qundef
# define ifndef_ripper(x)
+# define ifdef_ripper(r,x) (r)
#endif
# define rb_warn0(fmt) WARN_CALL(WARN_ARGS(fmt, 1))
@@ -1283,15 +1745,13 @@ endless_method_name(struct parser_params *p, NODE *defn, const YYLTYPE *loc)
# define rb_warning3L(l,fmt,a,b,c) WARNING_CALL(WARNING_ARGS_L(l, fmt, 4), (a), (b), (c))
# define rb_warning4L(l,fmt,a,b,c,d) WARNING_CALL(WARNING_ARGS_L(l, fmt, 5), (a), (b), (c), (d))
#ifdef RIPPER
-static ID id_warn, id_warning, id_gets, id_assoc;
+extern const ID id_warn, id_warning, id_gets, id_assoc;
# define ERR_MESG() STR_NEW2(mesg) /* to bypass Ripper DSL */
# define WARN_S_L(s,l) STR_NEW(s,l)
# define WARN_S(s) STR_NEW2(s)
# define WARN_I(i) INT2NUM(i)
# define WARN_ID(i) rb_id2str(i)
-# define WARN_IVAL(i) i
-# define PRIsWARN "s"
-# define rb_warn0L_experimental(l,fmt) WARN_CALL(WARN_ARGS_L(l, fmt, 1))
+# define PRIsWARN PRIsVALUE
# define WARN_ARGS(fmt,n) p->value, id_warn, n, rb_usascii_str_new_lit(fmt)
# define WARN_ARGS_L(l,fmt,n) WARN_ARGS(fmt,n)
# ifdef HAVE_VA_ARGS_MACRO
@@ -1306,141 +1766,980 @@ static ID id_warn, id_warning, id_gets, id_assoc;
# else
# define WARNING_CALL rb_funcall
# endif
-PRINTF_ARGS(static void ripper_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
# define compile_error ripper_compile_error
#else
# define WARN_S_L(s,l) s
# define WARN_S(s) s
# define WARN_I(i) i
# define WARN_ID(i) rb_id2name(i)
-# define WARN_IVAL(i) NUM2INT(i)
# define PRIsWARN PRIsVALUE
# define WARN_ARGS(fmt,n) WARN_ARGS_L(p->ruby_sourceline,fmt,n)
# define WARN_ARGS_L(l,fmt,n) p->ruby_sourcefile, (l), (fmt)
# define WARN_CALL rb_compile_warn
-# define rb_warn0L_experimental(l,fmt) rb_category_compile_warn(RB_WARN_CATEGORY_EXPERIMENTAL, WARN_ARGS_L(l, fmt, 1))
# define WARNING_ARGS(fmt,n) WARN_ARGS(fmt,n)
# define WARNING_ARGS_L(l,fmt,n) WARN_ARGS_L(l,fmt,n)
# define WARNING_CALL rb_compile_warning
-PRINTF_ARGS(static void parser_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
-# define compile_error parser_compile_error
+PRINTF_ARGS(static void parser_compile_error(struct parser_params*, const rb_code_location_t *loc, const char *fmt, ...), 3, 4);
+# define compile_error(p, ...) parser_compile_error(p, NULL, __VA_ARGS__)
#endif
+#define RNODE_EXITS(node) ((rb_node_exits_t*)(node))
+
+static NODE *
+add_block_exit(struct parser_params *p, NODE *node)
+{
+ if (!node) {
+ compile_error(p, "unexpected null node");
+ return 0;
+ }
+ switch (nd_type(node)) {
+ case NODE_BREAK: case NODE_NEXT: case NODE_REDO: break;
+ default:
+ compile_error(p, "add_block_exit: unexpected node: %s", parser_node_name(nd_type(node)));
+ return node;
+ }
+ if (!p->ctxt.in_defined) {
+ rb_node_exits_t *exits = p->exits;
+ if (exits) {
+ RNODE_EXITS(exits->nd_stts)->nd_chain = node;
+ exits->nd_stts = node;
+ }
+ }
+ return node;
+}
+
+static rb_node_exits_t *
+init_block_exit(struct parser_params *p)
+{
+ rb_node_exits_t *old = p->exits;
+ rb_node_exits_t *exits = NODE_NEW_INTERNAL(NODE_EXITS, rb_node_exits_t);
+ exits->nd_chain = 0;
+ exits->nd_stts = RNODE(exits);
+ p->exits = exits;
+ return old;
+}
+
+static rb_node_exits_t *
+allow_block_exit(struct parser_params *p)
+{
+ rb_node_exits_t *exits = p->exits;
+ p->exits = 0;
+ return exits;
+}
+
+static void
+restore_block_exit(struct parser_params *p, rb_node_exits_t *exits)
+{
+ p->exits = exits;
+}
+
+static void
+clear_block_exit(struct parser_params *p, bool error)
+{
+ rb_node_exits_t *exits = p->exits;
+ if (!exits) return;
+ if (error) {
+ for (NODE *e = RNODE(exits); (e = RNODE_EXITS(e)->nd_chain) != 0; ) {
+ switch (nd_type(e)) {
+ case NODE_BREAK:
+ yyerror1(&e->nd_loc, "Invalid break");
+ break;
+ case NODE_NEXT:
+ yyerror1(&e->nd_loc, "Invalid next");
+ break;
+ case NODE_REDO:
+ yyerror1(&e->nd_loc, "Invalid redo");
+ break;
+ default:
+ yyerror1(&e->nd_loc, "unexpected node");
+ goto end_checks; /* no nd_chain */
+ }
+ }
+ end_checks:;
+ }
+ exits->nd_stts = RNODE(exits);
+ exits->nd_chain = 0;
+}
+
#define WARN_EOL(tok) \
(looking_at_eol_p(p) ? \
- (void)rb_warning0("`" tok "' at the end of line without an expression") : \
+ (void)rb_warning0("'" tok "' at the end of line without an expression") : \
(void)0)
static int looking_at_eol_p(struct parser_params *p);
+
+static NODE *
+get_nd_value(struct parser_params *p, NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_GASGN:
+ return RNODE_GASGN(node)->nd_value;
+ case NODE_IASGN:
+ return RNODE_IASGN(node)->nd_value;
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_value;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_value;
+ case NODE_MASGN:
+ return RNODE_MASGN(node)->nd_value;
+ case NODE_CVASGN:
+ return RNODE_CVASGN(node)->nd_value;
+ case NODE_CDECL:
+ return RNODE_CDECL(node)->nd_value;
+ default:
+ compile_error(p, "get_nd_value: unexpected node: %s", parser_node_name(nd_type(node)));
+ return 0;
+ }
+}
+
+static void
+set_nd_value(struct parser_params *p, NODE *node, NODE *rhs)
+{
+ switch (nd_type(node)) {
+ case NODE_CDECL:
+ RNODE_CDECL(node)->nd_value = rhs;
+ break;
+ case NODE_GASGN:
+ RNODE_GASGN(node)->nd_value = rhs;
+ break;
+ case NODE_IASGN:
+ RNODE_IASGN(node)->nd_value = rhs;
+ break;
+ case NODE_LASGN:
+ RNODE_LASGN(node)->nd_value = rhs;
+ break;
+ case NODE_DASGN:
+ RNODE_DASGN(node)->nd_value = rhs;
+ break;
+ case NODE_MASGN:
+ RNODE_MASGN(node)->nd_value = rhs;
+ break;
+ case NODE_CVASGN:
+ RNODE_CVASGN(node)->nd_value = rhs;
+ break;
+ default:
+ compile_error(p, "set_nd_value: unexpected node: %s", parser_node_name(nd_type(node)));
+ break;
+ }
+}
+
+static ID
+get_nd_vid(struct parser_params *p, NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CDECL:
+ return RNODE_CDECL(node)->nd_vid;
+ case NODE_GASGN:
+ return RNODE_GASGN(node)->nd_vid;
+ case NODE_IASGN:
+ return RNODE_IASGN(node)->nd_vid;
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_vid;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_vid;
+ case NODE_CVASGN:
+ return RNODE_CVASGN(node)->nd_vid;
+ default:
+ compile_error(p, "get_nd_vid: unexpected node: %s", parser_node_name(nd_type(node)));
+ return 0;
+ }
+}
+
+static NODE *
+get_nd_args(struct parser_params *p, NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_args;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_args;
+ case NODE_FCALL:
+ return RNODE_FCALL(node)->nd_args;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_args;
+ case NODE_SUPER:
+ return RNODE_SUPER(node)->nd_args;
+ case NODE_VCALL:
+ case NODE_ZSUPER:
+ case NODE_YIELD:
+ case NODE_RETURN:
+ case NODE_BREAK:
+ case NODE_NEXT:
+ return 0;
+ default:
+ compile_error(p, "get_nd_args: unexpected node: %s", parser_node_name(nd_type(node)));
+ return 0;
+ }
+}
+
+static st_index_t
+djb2(const uint8_t *str, size_t len)
+{
+ st_index_t hash = 5381;
+
+ for (size_t i = 0; i < len; i++) {
+ hash = ((hash << 5) + hash) + str[i];
+ }
+
+ return hash;
+}
+
+static st_index_t
+parser_memhash(const void *ptr, long len)
+{
+ return djb2(ptr, len);
+}
+
+#define PARSER_STRING_PTR(str) (str->ptr)
+#define PARSER_STRING_LEN(str) (str->len)
+#define PARSER_STRING_END(str) (&str->ptr[str->len])
+#define STRING_SIZE(str) ((size_t)str->len + 1)
+#define STRING_TERM_LEN(str) (1)
+#define STRING_TERM_FILL(str) (str->ptr[str->len] = '\0')
+#define PARSER_STRING_RESIZE_CAPA_TERM(p,str,capacity,termlen) do {\
+ REALLOC_N(str->ptr, char, (size_t)total + termlen); \
+ str->len = total; \
+} while (0)
+#define STRING_SET_LEN(str, n) do { \
+ (str)->len = (n); \
+} while (0)
+#define PARSER_STRING_GETMEM(str, ptrvar, lenvar) \
+ ((ptrvar) = str->ptr, \
+ (lenvar) = str->len)
+
+static inline int
+parser_string_char_at_end(struct parser_params *p, rb_parser_string_t *str, int when_empty)
+{
+ return PARSER_STRING_LEN(str) > 0 ? (unsigned char)PARSER_STRING_END(str)[-1] : when_empty;
+}
+
+static rb_parser_string_t *
+rb_parser_string_new(rb_parser_t *p, const char *ptr, long len)
+{
+ rb_parser_string_t *str;
+
+ if (len < 0) {
+ rb_bug("negative string size (or size too big): %ld", len);
+ }
+
+ str = xcalloc(1, sizeof(rb_parser_string_t));
+ str->ptr = xcalloc(len + 1, sizeof(char));
+
+ if (ptr) {
+ memcpy(PARSER_STRING_PTR(str), ptr, len);
+ }
+ STRING_SET_LEN(str, len);
+ STRING_TERM_FILL(str);
+ return str;
+}
+
+static rb_parser_string_t *
+rb_parser_encoding_string_new(rb_parser_t *p, const char *ptr, long len, rb_encoding *enc)
+{
+ rb_parser_string_t *str = rb_parser_string_new(p, ptr, len);
+ str->coderange = RB_PARSER_ENC_CODERANGE_UNKNOWN;
+ str->enc = enc;
+ return str;
+}
+
+#ifndef RIPPER
+rb_parser_string_t *
+rb_str_to_parser_string(rb_parser_t *p, VALUE str)
+{
+ /* Type check */
+ rb_parser_string_t *ret = rb_parser_encoding_string_new(p, RSTRING_PTR(str), RSTRING_LEN(str), rb_enc_get(str));
+ RB_GC_GUARD(str);
+ return ret;
+}
+
+void
+rb_parser_string_free(rb_parser_t *p, rb_parser_string_t *str)
+{
+ if (!str) return;
+ xfree(PARSER_STRING_PTR(str));
+ xfree(str);
+}
+#endif
+
+static st_index_t
+rb_parser_str_hash(rb_parser_string_t *str)
+{
+ return parser_memhash((const void *)PARSER_STRING_PTR(str), PARSER_STRING_LEN(str));
+}
+
+static st_index_t
+rb_char_p_hash(const char *c)
+{
+ return parser_memhash((const void *)c, strlen(c));
+}
+
+static size_t
+rb_parser_str_capacity(rb_parser_string_t *str, const int termlen)
+{
+ return PARSER_STRING_LEN(str);
+}
+
+#ifndef RIPPER
+static char *
+rb_parser_string_end(rb_parser_string_t *str)
+{
+ return &str->ptr[str->len];
+}
+#endif
+
+static void
+rb_parser_string_set_encoding(rb_parser_string_t *str, rb_encoding *enc)
+{
+ str->enc = enc;
+}
+
+static rb_encoding *
+rb_parser_str_get_encoding(rb_parser_string_t *str)
+{
+ return str->enc;
+}
+
+#ifndef RIPPER
+static bool
+PARSER_ENCODING_IS_ASCII8BIT(struct parser_params *p, rb_parser_string_t *str)
+{
+ return rb_parser_str_get_encoding(str) == rb_ascii8bit_encoding();
+}
+#endif
+
+static int
+PARSER_ENC_CODERANGE(rb_parser_string_t *str)
+{
+ return str->coderange;
+}
+
+static void
+PARSER_ENC_CODERANGE_SET(rb_parser_string_t *str, int coderange)
+{
+ str->coderange = coderange;
+}
+
+static void
+PARSER_ENCODING_CODERANGE_SET(rb_parser_string_t *str, rb_encoding *enc, enum rb_parser_string_coderange_type cr)
+{
+ rb_parser_string_set_encoding(str, enc);
+ PARSER_ENC_CODERANGE_SET(str, cr);
+}
+
+static void
+PARSER_ENC_CODERANGE_CLEAR(rb_parser_string_t *str)
+{
+ str->coderange = RB_PARSER_ENC_CODERANGE_UNKNOWN;
+}
+
+static bool
+PARSER_ENC_CODERANGE_ASCIIONLY(rb_parser_string_t *str)
+{
+ return PARSER_ENC_CODERANGE(str) == RB_PARSER_ENC_CODERANGE_7BIT;
+}
+
+static bool
+PARSER_ENC_CODERANGE_CLEAN_P(int cr)
+{
+ return cr == RB_PARSER_ENC_CODERANGE_7BIT || cr == RB_PARSER_ENC_CODERANGE_VALID;
+}
+
+static const char *
+rb_parser_search_nonascii(const char *p, const char *e)
+{
+ const char *s = p;
+
+ for (; s < e; s++) {
+ if (*s & 0x80) return s;
+ }
+
+ return NULL;
+}
+
+static int
+rb_parser_coderange_scan(struct parser_params *p, const char *ptr, long len, rb_encoding *enc)
+{
+ const char *e = ptr + len;
+
+ if (enc == rb_ascii8bit_encoding()) {
+ /* enc is ASCII-8BIT. ASCII-8BIT string never be broken. */
+ ptr = rb_parser_search_nonascii(ptr, e);
+ return ptr ? RB_PARSER_ENC_CODERANGE_VALID : RB_PARSER_ENC_CODERANGE_7BIT;
+ }
+
+ /* parser string encoding is always asciicompat */
+ ptr = rb_parser_search_nonascii(ptr, e);
+ if (!ptr) return RB_PARSER_ENC_CODERANGE_7BIT;
+ for (;;) {
+ int ret = rb_enc_precise_mbclen(ptr, e, enc);
+ if (!MBCLEN_CHARFOUND_P(ret)) return RB_PARSER_ENC_CODERANGE_BROKEN;
+ ptr += MBCLEN_CHARFOUND_LEN(ret);
+ if (ptr == e) break;
+ ptr = rb_parser_search_nonascii(ptr, e);
+ if (!ptr) break;
+ }
+
+ return RB_PARSER_ENC_CODERANGE_VALID;
+}
+
+static int
+rb_parser_enc_coderange_scan(struct parser_params *p, rb_parser_string_t *str, rb_encoding *enc)
+{
+ return rb_parser_coderange_scan(p, PARSER_STRING_PTR(str), PARSER_STRING_LEN(str), enc);
+}
+
+static int
+rb_parser_enc_str_coderange(struct parser_params *p, rb_parser_string_t *str)
+{
+ int cr = PARSER_ENC_CODERANGE(str);
+
+ if (cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ cr = rb_parser_enc_coderange_scan(p, str, rb_parser_str_get_encoding(str));
+ PARSER_ENC_CODERANGE_SET(str, cr);
+ }
+
+ return cr;
+}
+
+static rb_parser_string_t *
+rb_parser_enc_associate(struct parser_params *p, rb_parser_string_t *str, rb_encoding *enc)
+{
+ if (rb_parser_str_get_encoding(str) == enc)
+ return str;
+ if (!PARSER_ENC_CODERANGE_ASCIIONLY(str)) {
+ PARSER_ENC_CODERANGE_CLEAR(str);
+ }
+ rb_parser_string_set_encoding(str, enc);
+ return str;
+}
+
+static bool
+rb_parser_is_ascii_string(struct parser_params *p, rb_parser_string_t *str)
+{
+ return rb_parser_enc_str_coderange(p, str) == RB_PARSER_ENC_CODERANGE_7BIT;
+}
+
+static rb_encoding *
+rb_parser_enc_compatible(struct parser_params *p, rb_parser_string_t *str1, rb_parser_string_t *str2)
+{
+ rb_encoding *enc1 = rb_parser_str_get_encoding(str1);
+ rb_encoding *enc2 = rb_parser_str_get_encoding(str2);
+
+ if (enc1 == NULL || enc2 == NULL)
+ return 0;
+
+ if (enc1 == enc2) {
+ return enc1;
+ }
+
+ if (PARSER_STRING_LEN(str2) == 0)
+ return enc1;
+ if (PARSER_STRING_LEN(str1) == 0)
+ return rb_parser_is_ascii_string(p, str2) ? enc1 : enc2;
+
+ int cr1, cr2;
+
+ cr1 = rb_parser_enc_str_coderange(p, str1);
+ cr2 = rb_parser_enc_str_coderange(p, str2);
+
+ if (cr1 != cr2) {
+ if (cr1 == RB_PARSER_ENC_CODERANGE_7BIT) return enc2;
+ if (cr2 == RB_PARSER_ENC_CODERANGE_7BIT) return enc1;
+ }
+
+ if (cr2 == RB_PARSER_ENC_CODERANGE_7BIT) {
+ return enc1;
+ }
+
+ if (cr1 == RB_PARSER_ENC_CODERANGE_7BIT) {
+ return enc2;
+ }
+
+ return 0;
+}
+
+static void
+rb_parser_str_modify(rb_parser_string_t *str)
+{
+ PARSER_ENC_CODERANGE_CLEAR(str);
+}
+
+static void
+rb_parser_str_set_len(struct parser_params *p, rb_parser_string_t *str, long len)
+{
+ long capa;
+ const int termlen = STRING_TERM_LEN(str);
+
+ if (len > (capa = (long)(rb_parser_str_capacity(str, termlen))) || len < 0) {
+ rb_bug("probable buffer overflow: %ld for %ld", len, capa);
+ }
+
+ int cr = PARSER_ENC_CODERANGE(str);
+ if (cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ /* Leave unknown. */
+ }
+ else if (len > PARSER_STRING_LEN(str)) {
+ PARSER_ENC_CODERANGE_SET(str, RB_PARSER_ENC_CODERANGE_UNKNOWN);
+ }
+ else if (len < PARSER_STRING_LEN(str)) {
+ if (cr != RB_PARSER_ENC_CODERANGE_7BIT) {
+ /* ASCII-only string is keeping after truncated. Valid
+ * and broken may be invalid or valid, leave unknown. */
+ PARSER_ENC_CODERANGE_SET(str, RB_PARSER_ENC_CODERANGE_UNKNOWN);
+ }
+ }
+
+ STRING_SET_LEN(str, len);
+ STRING_TERM_FILL(str);
+}
+
+static rb_parser_string_t *
+rb_parser_str_buf_cat(struct parser_params *p, rb_parser_string_t *str, const char *ptr, long len)
+{
+ rb_parser_str_modify(str);
+ if (len == 0) return 0;
+
+ long total, olen, off = -1;
+ char *sptr;
+ const int termlen = STRING_TERM_LEN(str);
+
+ PARSER_STRING_GETMEM(str, sptr, olen);
+ if (ptr >= sptr && ptr <= sptr + olen) {
+ off = ptr - sptr;
+ }
+
+ if (olen > LONG_MAX - len) {
+ compile_error(p, "string sizes too big");
+ return 0;
+ }
+ total = olen + len;
+ PARSER_STRING_RESIZE_CAPA_TERM(p, str, total, termlen);
+ sptr = PARSER_STRING_PTR(str);
+ if (off != -1) {
+ ptr = sptr + off;
+ }
+ memcpy(sptr + olen, ptr, len);
+ STRING_SET_LEN(str, total);
+ STRING_TERM_FILL(str);
+
+ return str;
+}
+
+#define parser_str_cat(str, ptr, len) rb_parser_str_buf_cat(p, str, ptr, len)
+#define parser_str_cat_cstr(str, lit) rb_parser_str_buf_cat(p, str, lit, strlen(lit))
+
+static rb_parser_string_t *
+rb_parser_enc_cr_str_buf_cat(struct parser_params *p, rb_parser_string_t *str, const char *ptr, long len,
+ rb_encoding *ptr_enc, int ptr_cr, int *ptr_cr_ret)
+{
+ int str_cr, res_cr;
+ rb_encoding *str_enc, *res_enc;
+
+ str_enc = rb_parser_str_get_encoding(str);
+ str_cr = PARSER_STRING_LEN(str) ? PARSER_ENC_CODERANGE(str) : RB_PARSER_ENC_CODERANGE_7BIT;
+
+ if (str_enc == ptr_enc) {
+ if (str_cr != RB_PARSER_ENC_CODERANGE_UNKNOWN && ptr_cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ ptr_cr = rb_parser_coderange_scan(p, ptr, len, ptr_enc);
+ }
+ }
+ else {
+ /* parser string encoding is always asciicompat */
+ if (ptr_cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ ptr_cr = rb_parser_coderange_scan(p, ptr, len, ptr_enc);
+ }
+ if (str_cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ if (str_enc == rb_ascii8bit_encoding() || ptr_cr != RB_PARSER_ENC_CODERANGE_7BIT) {
+ str_cr = rb_parser_enc_str_coderange(p, str);
+ }
+ }
+ }
+ if (ptr_cr_ret)
+ *ptr_cr_ret = ptr_cr;
+
+ if (str_enc != ptr_enc &&
+ str_cr != RB_PARSER_ENC_CODERANGE_7BIT &&
+ ptr_cr != RB_PARSER_ENC_CODERANGE_7BIT) {
+ goto incompatible;
+ }
+
+ if (str_cr == RB_PARSER_ENC_CODERANGE_UNKNOWN) {
+ res_enc = str_enc;
+ res_cr = RB_PARSER_ENC_CODERANGE_UNKNOWN;
+ }
+ else if (str_cr == RB_PARSER_ENC_CODERANGE_7BIT) {
+ if (ptr_cr == RB_PARSER_ENC_CODERANGE_7BIT) {
+ res_enc = str_enc;
+ res_cr = RB_PARSER_ENC_CODERANGE_7BIT;
+ }
+ else {
+ res_enc = ptr_enc;
+ res_cr = ptr_cr;
+ }
+ }
+ else if (str_cr == RB_PARSER_ENC_CODERANGE_VALID) {
+ res_enc = str_enc;
+ if (PARSER_ENC_CODERANGE_CLEAN_P(ptr_cr))
+ res_cr = str_cr;
+ else
+ res_cr = ptr_cr;
+ }
+ else { /* str_cr == RB_PARSER_ENC_CODERANGE_BROKEN */
+ res_enc = str_enc;
+ res_cr = str_cr;
+ if (0 < len) res_cr = RB_PARSER_ENC_CODERANGE_UNKNOWN;
+ }
+
+ if (len < 0) {
+ compile_error(p, "negative string size (or size too big)");
+ }
+ parser_str_cat(str, ptr, len);
+ PARSER_ENCODING_CODERANGE_SET(str, res_enc, res_cr);
+ return str;
+
+ incompatible:
+ compile_error(p, "incompatible character encodings: %s and %s",
+ rb_enc_name(str_enc), rb_enc_name(ptr_enc));
+ UNREACHABLE_RETURN(0);
+
+}
+
+static rb_parser_string_t *
+rb_parser_enc_str_buf_cat(struct parser_params *p, rb_parser_string_t *str, const char *ptr, long len,
+ rb_encoding *ptr_enc)
+{
+ return rb_parser_enc_cr_str_buf_cat(p, str, ptr, len, ptr_enc, RB_PARSER_ENC_CODERANGE_UNKNOWN, NULL);
+}
+
+static rb_parser_string_t *
+rb_parser_str_buf_append(struct parser_params *p, rb_parser_string_t *str, rb_parser_string_t *str2)
+{
+ int str2_cr = rb_parser_enc_str_coderange(p, str2);
+
+ rb_parser_enc_cr_str_buf_cat(p, str, PARSER_STRING_PTR(str2), PARSER_STRING_LEN(str2),
+ rb_parser_str_get_encoding(str2), str2_cr, &str2_cr);
+
+ PARSER_ENC_CODERANGE_SET(str2, str2_cr);
+
+ return str;
+}
+
+static rb_parser_string_t *
+rb_parser_str_resize(struct parser_params *p, rb_parser_string_t *str, long len)
+{
+ if (len < 0) {
+ rb_bug("negative string size (or size too big)");
+ }
+
+ long slen = PARSER_STRING_LEN(str);
+
+ if (slen > len && PARSER_ENC_CODERANGE(str) != RB_PARSER_ENC_CODERANGE_7BIT) {
+ PARSER_ENC_CODERANGE_CLEAR(str);
+ }
+
+ {
+ long capa;
+ const int termlen = STRING_TERM_LEN(str);
+
+ if ((capa = slen) < len) {
+ SIZED_REALLOC_N(str->ptr, char, (size_t)len + termlen, STRING_SIZE(str));
+ }
+ else if (len == slen) return str;
+ STRING_SET_LEN(str, len);
+ STRING_TERM_FILL(str);
+ }
+ return str;
+}
+
+# define PARSER_ENC_STRING_GETMEM(str, ptrvar, lenvar, encvar) \
+ ((ptrvar) = str->ptr, \
+ (lenvar) = str->len, \
+ (encvar) = str->enc)
+
+static int
+rb_parser_string_hash_cmp(rb_parser_string_t *str1, rb_parser_string_t *str2)
+{
+ long len1, len2;
+ const char *ptr1, *ptr2;
+ rb_encoding *enc1, *enc2;
+
+ PARSER_ENC_STRING_GETMEM(str1, ptr1, len1, enc1);
+ PARSER_ENC_STRING_GETMEM(str2, ptr2, len2, enc2);
+
+ return (len1 != len2 ||
+ enc1 != enc2 ||
+ memcmp(ptr1, ptr2, len1) != 0);
+}
+
+static void
+rb_parser_ary_extend(rb_parser_t *p, rb_parser_ary_t *ary, long len)
+{
+ long i;
+ if (ary->capa < len) {
+ ary->capa = len;
+ ary->data = (rb_parser_ary_data *)xrealloc(ary->data, sizeof(rb_parser_ary_data) * len);
+ for (i = ary->len; i < len; i++) {
+ ary->data[i] = 0;
+ }
+ }
+}
+
+/*
+ * Do not call this directly.
+ * Use rb_parser_ary_new_capa_for_XXX() instead.
+ */
+static rb_parser_ary_t *
+parser_ary_new_capa(rb_parser_t *p, long len)
+{
+ if (len < 0) {
+ rb_bug("negative array size (or size too big): %ld", len);
+ }
+ rb_parser_ary_t *ary = xcalloc(1, sizeof(rb_parser_ary_t));
+ ary->data_type = 0;
+ ary->len = 0;
+ ary->capa = len;
+ if (0 < len) {
+ ary->data = (rb_parser_ary_data *)xcalloc(len, sizeof(rb_parser_ary_data));
+ }
+ else {
+ ary->data = NULL;
+ }
+ return ary;
+}
+
+#ifndef RIPPER
+static rb_parser_ary_t *
+rb_parser_ary_new_capa_for_script_line(rb_parser_t *p, long len)
+{
+ rb_parser_ary_t *ary = parser_ary_new_capa(p, len);
+ ary->data_type = PARSER_ARY_DATA_SCRIPT_LINE;
+ return ary;
+}
+
+static rb_parser_ary_t *
+rb_parser_ary_new_capa_for_ast_token(rb_parser_t *p, long len)
+{
+ rb_parser_ary_t *ary = parser_ary_new_capa(p, len);
+ ary->data_type = PARSER_ARY_DATA_AST_TOKEN;
+ return ary;
+}
+#endif
+
+static rb_parser_ary_t *
+rb_parser_ary_new_capa_for_node(rb_parser_t *p, long len)
+{
+ rb_parser_ary_t *ary = parser_ary_new_capa(p, len);
+ ary->data_type = PARSER_ARY_DATA_NODE;
+ return ary;
+}
+
+/*
+ * Do not call this directly.
+ * Use rb_parser_ary_push_XXX() instead.
+ */
+static rb_parser_ary_t *
+parser_ary_push(rb_parser_t *p, rb_parser_ary_t *ary, rb_parser_ary_data val)
+{
+ if (ary->len == ary->capa) {
+ rb_parser_ary_extend(p, ary, ary->len == 0 ? 1 : ary->len * 2);
+ }
+ ary->data[ary->len++] = val;
+ return ary;
+}
+
+#ifndef RIPPER
+static rb_parser_ary_t *
+rb_parser_ary_push_ast_token(rb_parser_t *p, rb_parser_ary_t *ary, rb_parser_ast_token_t *val)
+{
+ if (ary->data_type != PARSER_ARY_DATA_AST_TOKEN) {
+ rb_bug("unexpected rb_parser_ary_data_type: %d", ary->data_type);
+ }
+ return parser_ary_push(p, ary, val);
+}
+
+static rb_parser_ary_t *
+rb_parser_ary_push_script_line(rb_parser_t *p, rb_parser_ary_t *ary, rb_parser_string_t *val)
+{
+ if (ary->data_type != PARSER_ARY_DATA_SCRIPT_LINE) {
+ rb_bug("unexpected rb_parser_ary_data_type: %d", ary->data_type);
+ }
+ return parser_ary_push(p, ary, val);
+}
+#endif
+
+static rb_parser_ary_t *
+rb_parser_ary_push_node(rb_parser_t *p, rb_parser_ary_t *ary, NODE *val)
+{
+ if (ary->data_type != PARSER_ARY_DATA_NODE) {
+ rb_bug("unexpected rb_parser_ary_data_type: %d", ary->data_type);
+ }
+ return parser_ary_push(p, ary, val);
+}
+
+#ifndef RIPPER
+static void
+rb_parser_ast_token_free(rb_parser_t *p, rb_parser_ast_token_t *token)
+{
+ if (!token) return;
+ rb_parser_string_free(p, token->str);
+ xfree(token);
+}
+
+static void
+rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
+{
+# define foreach_ary(ptr) \
+ for (rb_parser_ary_data *ptr = ary->data, *const end_ary_data = ptr + ary->len; \
+ ptr < end_ary_data; ptr++)
+ switch (ary->data_type) {
+ case PARSER_ARY_DATA_AST_TOKEN:
+ foreach_ary(data) {rb_parser_ast_token_free(p, *data);}
+ break;
+ case PARSER_ARY_DATA_SCRIPT_LINE:
+ foreach_ary(data) {rb_parser_string_free(p, *data);}
+ break;
+ case PARSER_ARY_DATA_NODE:
+ /* Do nothing because nodes are freed when rb_ast_t is freed */
+ break;
+ default:
+ rb_bug("unexpected rb_parser_ary_data_type: %d", ary->data_type);
+ break;
+ }
+# undef foreach_ary
+ xfree(ary->data);
+ xfree(ary);
+}
+
+#endif /* !RIPPER */
%}
%expect 0
%define api.pure
%define parse.error verbose
%printer {
-#ifndef RIPPER
- if ($$) {
- rb_parser_printf(p, "%s", ruby_node_name(nd_type($$)));
+ if ((NODE *)$$ == (NODE *)-1) {
+ rb_parser_printf(p, "NODE_SPECIAL");
}
-#else
-#endif
-} <node>
+ else if ($$) {
+ rb_parser_printf(p, "%s", parser_node_name(nd_type(RNODE($$))));
+ }
+} <node> <node_fcall> <node_args> <node_args_aux> <node_opt_arg>
+ <node_kw_arg> <node_block_pass> <node_masgn> <node_def_temp> <node_exits>
%printer {
-#ifndef RIPPER
rb_parser_printf(p, "%"PRIsVALUE, rb_id2str($$));
-#else
- rb_parser_printf(p, "%"PRIsVALUE, RNODE($$)->nd_rval);
-#endif
-} tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL tOP_ASGN
+} <id>
%printer {
-#ifndef RIPPER
- rb_parser_printf(p, "%+"PRIsVALUE, $$->nd_lit);
-#else
- rb_parser_printf(p, "%+"PRIsVALUE, get_value($$));
-#endif
+ switch (nd_type(RNODE($$))) {
+ case NODE_INTEGER:
+ rb_parser_printf(p, "%+"PRIsVALUE, rb_node_integer_literal_val($$));
+ break;
+ case NODE_FLOAT:
+ rb_parser_printf(p, "%+"PRIsVALUE, rb_node_float_literal_val($$));
+ break;
+ case NODE_RATIONAL:
+ rb_parser_printf(p, "%+"PRIsVALUE, rb_node_rational_literal_val($$));
+ break;
+ case NODE_IMAGINARY:
+ rb_parser_printf(p, "%+"PRIsVALUE, rb_node_imaginary_literal_val($$));
+ break;
+ default:
+ break;
+ }
} tINTEGER tFLOAT tRATIONAL tIMAGINARY tSTRING_CONTENT tCHAR
%printer {
-#ifndef RIPPER
- rb_parser_printf(p, "$%ld", $$->nd_nth);
-#else
- rb_parser_printf(p, "%"PRIsVALUE, $$);
-#endif
+ rb_parser_printf(p, "$%ld", RNODE_NTH_REF($$)->nd_nth);
} tNTH_REF
%printer {
-#ifndef RIPPER
- rb_parser_printf(p, "$%c", (int)$$->nd_nth);
-#else
- rb_parser_printf(p, "%"PRIsVALUE, $$);
-#endif
+ rb_parser_printf(p, "$%c", (int)RNODE_BACK_REF($$)->nd_nth);
} tBACK_REF
+%destructor {
+ if (CASE_LABELS_ENABLED_P($$)) st_free_table($$);
+} <labels>
+
%lex-param {struct parser_params *p}
%parse-param {struct parser_params *p}
%initial-action
{
RUBY_SET_YYLLOC_OF_NONE(@$);
};
+%after-shift after_shift
+%before-reduce before_reduce
+%after-reduce after_reduce
+%after-shift-error-token after_shift_error_token
+%after-pop-stack after_pop_stack
%union {
- VALUE val;
NODE *node;
+ rb_node_fcall_t *node_fcall;
+ rb_node_args_t *node_args;
+ rb_node_args_aux_t *node_args_aux;
+ rb_node_opt_arg_t *node_opt_arg;
+ rb_node_kw_arg_t *node_kw_arg;
+ rb_node_block_pass_t *node_block_pass;
+ rb_node_masgn_t *node_masgn;
+ rb_node_def_temp_t *node_def_temp;
+ rb_node_exits_t *node_exits;
+ struct rb_locations_lambda_body_t *locations_lambda_body;
ID id;
int num;
st_table *tbl;
+ st_table *labels;
const struct vtable *vars;
struct rb_strterm_struct *strterm;
struct lex_context ctxt;
+ enum lex_state_e state;
}
%token <id>
- 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' for condition"
- keyword_do_block "`do' for block"
- keyword_do_LAMBDA "`do' for lambda"
- 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"
- modifier_unless "`unless' modifier"
- modifier_while "`while' modifier"
- modifier_until "`until' modifier"
- modifier_rescue "`rescue' modifier"
- keyword_alias "`alias'"
- keyword_defined "`defined?'"
- keyword_BEGIN "`BEGIN'"
- keyword_END "`END'"
- keyword__LINE__ "`__LINE__'"
- keyword__FILE__ "`__FILE__'"
- keyword__ENCODING__ "`__ENCODING__'"
+ 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' for condition"
+ keyword_do_block "'do' for block"
+ keyword_do_LAMBDA "'do' for lambda"
+ 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"
+ modifier_unless "'unless' modifier"
+ modifier_while "'while' modifier"
+ modifier_until "'until' modifier"
+ modifier_rescue "'rescue' modifier"
+ keyword_alias "'alias'"
+ keyword_defined "'defined?'"
+ keyword_BEGIN "'BEGIN'"
+ keyword_END "'END'"
+ keyword__LINE__ "'__LINE__'"
+ keyword__FILE__ "'__FILE__'"
+ keyword__ENCODING__ "'__ENCODING__'"
%token <id> tIDENTIFIER "local variable or method"
%token <id> tFID "method"
@@ -1460,42 +2759,58 @@ static int looking_at_eol_p(struct parser_params *p);
%token <num> tREGEXP_END
%token <num> tDUMNY_END "dummy end"
-%type <node> singleton strings string string1 xstring regexp
+%type <node> singleton singleton_expr strings string string1 xstring regexp
%type <node> string_contents xstring_contents regexp_contents string_content
%type <node> words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
-%type <node> literal numeric simple_numeric ssym dsym symbol cpath def_name defn_head defs_head
-%type <node> top_compstmt top_stmts top_stmt begin_block endless_arg endless_command
-%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
-%type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr
+%type <node> literal numeric simple_numeric ssym dsym symbol cpath
+%type <node_def_temp> defn_head defs_head k_def
+%type <node_exits> block_open k_while k_until k_for allow_exits
+%type <node> top_stmts top_stmt begin_block endless_arg endless_command
+%type <node> bodystmt stmts stmt_or_begin stmt expr arg ternary primary
+%type <node> command command_call command_call_value method_call
+%type <node> expr_value expr_value_do arg_value primary_value rel_expr
+%type <node_fcall> fcall
%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
-%type <node> args call_args opt_call_args
-%type <node> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
-%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
+%type <node> args arg_splat call_args opt_call_args
+%type <node> paren_args opt_paren_args
+%type <node_args> args_tail block_args_tail
+%type <node> command_args aref_args
+%type <node_block_pass> opt_block_arg block_arg
+%type <node> var_ref var_lhs
%type <node> command_rhs arg_rhs
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
-%type <node> f_block_optarg f_block_opt
-%type <node> f_arglist f_opt_paren_args f_paren_args f_args f_arg f_arg_item
-%type <node> f_optarg f_marg f_marg_list f_margs f_rest_marg
+%type <node_args> f_arglist f_opt_paren_args f_paren_args f_args f_empty_arg
+%type <node_args_aux> f_arg f_arg_item
+%type <node> f_marg f_rest_marg
+%type <node_masgn> 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> f_kwarg f_kw f_block_kwarg f_block_kw
-%type <node> bv_decls opt_bv_decl bvar
-%type <node> lambda f_larglist lambda_body brace_body do_body
+%type <node_args> block_param opt_block_param_def block_param_def opt_block_param
+%type <id> do bv_decls opt_bv_decl bvar
+%type <node> lambda brace_body do_body
+%type <locations_lambda_body> lambda_body
+%type <node_args> f_larglist f_largs largs_tail
%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_head mlhs_item mlhs_node
+%type <node_masgn> mlhs mlhs_basic mlhs_inner
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
%type <node> p_expr p_as p_alt p_expr_basic p_find
-%type <node> p_args p_args_head p_args_tail p_args_post p_arg
+%type <node> p_args p_args_head p_args_tail p_args_post p_arg p_rest
%type <node> p_value p_primitive p_variable p_var_ref p_expr_ref p_const
%type <node> p_kwargs p_kwarg p_kw
-%type <id> keyword_variable user_variable sym 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 <id> keyword_variable user_variable sym operation2 operation3
+%type <id> cname fname op f_rest_arg f_block_arg opt_comma f_norm_arg f_bad_arg
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
-%type <id> p_rest p_kwrest p_kwnorest p_any_kwrest p_kw_label
-%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var
- %type <ctxt> lex_ctxt /* keep <ctxt> in ripper */
+%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
+%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var def_name
+%type <ctxt> lex_ctxt begin_defined k_class k_module k_END k_rescue k_ensure after_rescue
+%type <ctxt> p_in_kwarg
+%type <tbl> p_lparen p_lbracket p_pktbl p_pvtbl
+%type <num> max_numparam
+%type <node> numparam
+%type <id> it_id
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
+
/* escaped chars, should be ignored otherwise */
%token <id> '\\' "backslash"
%token tSP "escaped space"
@@ -1531,14 +2846,13 @@ static int looking_at_eol_p(struct parser_params *p);
%token tASSOC "=>"
%token tLPAREN "("
%token tLPAREN_ARG "( arg"
-%token tRPAREN ")"
%token tLBRACK "["
%token tLBRACE "{"
%token tLBRACE_ARG "{ arg"
%token tSTAR "*"
%token tDSTAR "**arg"
%token tAMPER "&"
-%token tLAMBDA "->"
+%token <num> tLAMBDA "->"
%token tSYMBEG "symbol literal"
%token tSTRING_BEG "string literal"
%token tXSTRING_BEG "backtick literal"
@@ -1549,7 +2863,8 @@ static int looking_at_eol_p(struct parser_params *p);
%token tQSYMBOLS_BEG "verbatim symbol list"
%token tSTRING_END "terminator"
%token tSTRING_DEND "'}'"
-%token tSTRING_DBEG tSTRING_DVAR tLAMBEG tLABEL_END
+%token <state> tSTRING_DBEG "'#{'"
+%token tSTRING_DVAR tLAMBEG tLABEL_END
%token tIGNORED_NL tCOMMENT tEMBDOC_BEG tEMBDOC tEMBDOC_END
%token tHEREDOC_BEG tHEREDOC_END k__END__
@@ -1584,135 +2899,389 @@ static int looking_at_eol_p(struct parser_params *p);
%token tLAST_TOKEN
+/*
+ * inlining rules
+ */
+%rule %inline ident_or_const
+ : tIDENTIFIER
+ | tCONSTANT
+ ;
+
+%rule %inline user_or_keyword_variable
+ : user_variable
+ | keyword_variable
+ ;
+
+/*
+ * parameterizing rules
+ */
+%rule asgn(rhs) <node>
+ : lhs '=' lex_ctxt rhs
+ {
+ $$ = node_assign(p, (NODE *)$lhs, $rhs, $lex_ctxt, &@$);
+ /*% ripper: assign!($:1, $:4) %*/
+ }
+ ;
+
+%rule args_tail_basic(value, trailing) <node_args>
+ : f_kwarg(value) ',' f_kwrest opt_f_block_arg(trailing)
+ {
+ $$ = new_args_tail(p, $1, $3, $4, &@3);
+ /*% ripper: [$:1, $:3, $:4] %*/
+ }
+ | f_kwarg(value) opt_f_block_arg(trailing)
+ {
+ $$ = new_args_tail(p, $1, 0, $2, &@1);
+ /*% ripper: [$:1, Qnil, $:2] %*/
+ }
+ | f_any_kwrest opt_f_block_arg(trailing)
+ {
+ $$ = new_args_tail(p, 0, $1, $2, &@1);
+ /*% ripper: [Qnil, $:1, $:2] %*/
+ }
+ | f_block_arg
+ {
+ $$ = new_args_tail(p, 0, 0, $1, &@1);
+ /*% ripper: [Qnil, Qnil, $:1] %*/
+ }
+ ;
+
+%rule opt_f_block_arg(trailing) <id>
+ : ',' f_block_arg
+ {
+ $$ = $2;
+ /*% ripper: $:2 %*/
+ }
+ | trailing
+ ;
+
+%rule def_endless_method(bodystmt) <node>
+ : defn_head[head] f_opt_paren_args[args] '=' bodystmt
+ {
+ endless_method_name(p, $head->nd_mid, &@head);
+ restore_defun(p, $head);
+ ($$ = $head->nd_def)->nd_loc = @$;
+ $bodystmt = new_scope_body(p, $args, $bodystmt, $$, &@$);
+ RNODE_DEFN($$)->nd_defn = $bodystmt;
+ /*% ripper: bodystmt!($:bodystmt, Qnil, Qnil, Qnil) %*/
+ /*% ripper: def!($:head, $:args, $:$) %*/
+ local_pop(p);
+ }
+ | defs_head[head] f_opt_paren_args[args] '=' bodystmt
+ {
+ endless_method_name(p, $head->nd_mid, &@head);
+ restore_defun(p, $head);
+ ($$ = $head->nd_def)->nd_loc = @$;
+ $bodystmt = new_scope_body(p, $args, $bodystmt, $$, &@$);
+ RNODE_DEFS($$)->nd_defn = $bodystmt;
+ /*% ripper: bodystmt!($:bodystmt, Qnil, Qnil, Qnil) %*/
+ /*% ripper: defs!(*$:head[0..2], $:args, $:$) %*/
+ local_pop(p);
+ }
+ ;
+
+%rule compstmt(stmts) <node>
+ : stmts terms?
+ {
+ void_stmts(p, $$ = $stmts);
+ }
+ ;
+
+%rule f_opt(value) <node_opt_arg>
+ : f_arg_asgn f_eq value
+ {
+ p->ctxt.in_argdef = 1;
+ $$ = NEW_OPT_ARG(assignable(p, $f_arg_asgn, $value, &@$), &@$);
+ /*% ripper: [$:$, $:3] %*/
+ }
+ ;
+
+%rule f_opt_arg(value) <node_opt_arg>
+ : f_opt(value)
+ {
+ $$ = $f_opt;
+ /*% ripper: rb_ary_new3(1, $:1) %*/
+ }
+ | f_opt_arg(value) ',' f_opt(value)
+ {
+ $$ = opt_arg_append($f_opt_arg, $f_opt);
+ /*% ripper: rb_ary_push($:1, $:3) %*/
+ }
+ ;
+
+%rule f_kw(value) <node_kw_arg>
+ : f_label value
+ {
+ p->ctxt.in_argdef = 1;
+ $$ = new_kw_arg(p, assignable(p, $f_label, $value, &@$), &@$);
+ /*% ripper: [$:$, $:value] %*/
+ }
+ | f_label
+ {
+ p->ctxt.in_argdef = 1;
+ $$ = new_kw_arg(p, assignable(p, $f_label, NODE_SPECIAL_REQUIRED_KEYWORD, &@$), &@$);
+ /*% ripper: [$:$, 0] %*/
+ }
+ ;
+
+%rule f_kwarg(value) <node_kw_arg>
+ : f_kw(value)
+ {
+ $$ = $f_kw;
+ /*% ripper: rb_ary_new3(1, $:1) %*/
+ }
+ | f_kwarg(value) ',' f_kw(value)
+ {
+ $$ = kwd_append($f_kwarg, $f_kw);
+ /*% ripper: rb_ary_push($:1, $:3) %*/
+ }
+ ;
+
+%rule mlhs_items(item) <node>
+ : item
+ {
+ $$ = NEW_LIST($1, &@$);
+ /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/
+ }
+ | mlhs_items(item) ',' item
+ {
+ $$ = list_append(p, $1, $3);
+ /*% ripper: mlhs_add!($:1, $:3) %*/
+ }
+ ;
+
+%rule op_asgn(rhs) <node>
+ : var_lhs tOP_ASGN lex_ctxt rhs
+ {
+ $$ = new_op_assign(p, $var_lhs, $tOP_ASGN, $rhs, $lex_ctxt, &@$);
+ /*% ripper: opassign!($:var_lhs, $:tOP_ASGN, $:rhs) %*/
+ }
+ | primary_value '['[lbracket] opt_call_args rbracket tOP_ASGN lex_ctxt rhs
+ {
+ $$ = new_ary_op_assign(p, $primary_value, $opt_call_args, $tOP_ASGN, $rhs, &@opt_call_args, &@$, &NULL_LOC, &@lbracket, &@rbracket, &@tOP_ASGN);
+ /*% ripper: opassign!(aref_field!($:primary_value, $:opt_call_args), $:tOP_ASGN, $:rhs) %*/
+ }
+ | primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt rhs
+ {
+ $$ = new_attr_op_assign(p, $primary_value, $call_op, $tIDENTIFIER, $tOP_ASGN, $rhs, &@$, &@call_op, &@tIDENTIFIER, &@tOP_ASGN);
+ /*% ripper: opassign!(field!($:primary_value, $:call_op, $:tIDENTIFIER), $:tOP_ASGN, $:rhs) %*/
+ }
+ | primary_value call_op tCONSTANT tOP_ASGN lex_ctxt rhs
+ {
+ $$ = new_attr_op_assign(p, $primary_value, $call_op, $tCONSTANT, $tOP_ASGN, $rhs, &@$, &@call_op, &@tCONSTANT, &@tOP_ASGN);
+ /*% ripper: opassign!(field!($:primary_value, $:call_op, $:tCONSTANT), $:tOP_ASGN, $:rhs) %*/
+ }
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt rhs
+ {
+ $$ = new_attr_op_assign(p, $primary_value, idCOLON2, $tIDENTIFIER, $tOP_ASGN, $rhs, &@$, &@tCOLON2, &@tIDENTIFIER, &@tOP_ASGN);
+ /*% ripper: opassign!(field!($:primary_value, $:tCOLON2, $:tIDENTIFIER), $:tOP_ASGN, $:rhs) %*/
+ }
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt rhs
+ {
+ YYLTYPE loc = code_loc_gen(&@primary_value, &@tCONSTANT);
+ $$ = new_const_op_assign(p, NEW_COLON2($primary_value, $tCONSTANT, &loc, &@tCOLON2, &@tCONSTANT), $tOP_ASGN, $rhs, $lex_ctxt, &@$);
+ /*% ripper: opassign!(const_path_field!($:primary_value, $:tCONSTANT), $:tOP_ASGN, $:rhs) %*/
+ }
+ | tCOLON3 tCONSTANT tOP_ASGN lex_ctxt rhs
+ {
+ YYLTYPE loc = code_loc_gen(&@tCOLON3, &@tCONSTANT);
+ $$ = new_const_op_assign(p, NEW_COLON3($tCONSTANT, &loc, &@tCOLON3, &@tCONSTANT), $tOP_ASGN, $rhs, $lex_ctxt, &@$);
+ /*% ripper: opassign!(top_const_field!($:tCONSTANT), $:tOP_ASGN, $:rhs) %*/
+ }
+ | backref tOP_ASGN lex_ctxt rhs
+ {
+ VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $backref);
+ $$ = NEW_ERROR(&@$);
+ /*% ripper[error]: assign_error!(?e, opassign!(var_field!($:backref), $:tOP_ASGN, $:rhs)) %*/
+ }
+ ;
+
+%rule opt_args_tail(tail, trailing) <node_args>
+ : ',' tail
+ {
+ $$ = $tail;
+ /*% ripper: $:tail %*/
+ }
+ | trailing
+ {
+ $$ = new_empty_args_tail(p, &@$);
+ /*% ripper: [Qnil, Qnil, Qnil] %*/
+ }
+ ;
+
+%rule range_expr(range) <node>
+ : range tDOT2 range
+ {
+ value_expr(p, $1);
+ value_expr(p, $3);
+ $$ = NEW_DOT2($1, $3, &@$, &@2);
+ /*% ripper: dot2!($:1, $:3) %*/
+ }
+ | range tDOT3 range
+ {
+ value_expr(p, $1);
+ value_expr(p, $3);
+ $$ = NEW_DOT3($1, $3, &@$, &@2);
+ /*% ripper: dot3!($:1, $:3) %*/
+ }
+ | range tDOT2
+ {
+ value_expr(p, $1);
+ $$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
+ /*% ripper: dot2!($:1, Qnil) %*/
+ }
+ | range tDOT3
+ {
+ value_expr(p, $1);
+ $$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$, &@2);
+ /*% ripper: dot3!($:1, Qnil) %*/
+ }
+ | tBDOT2 range
+ {
+ value_expr(p, $2);
+ $$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
+ /*% ripper: dot2!(Qnil, $:2) %*/
+ }
+ | tBDOT3 range
+ {
+ value_expr(p, $2);
+ $$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$, &@1);
+ /*% ripper: dot3!(Qnil, $:2) %*/
+ }
+ ;
+
+%rule value_expr(value) <node>
+ : value
+ {
+ value_expr(p, $1);
+ $$ = $1;
+ }
+ ;
+
+%rule words(begin, word_list) <node>
+ : begin ' '+ word_list tSTRING_END
+ {
+ $$ = make_list($word_list, &@$);
+ /*% ripper: array!($:word_list) %*/
+ }
+ ;
+
%%
program : {
SET_LEX_STATE(EXPR_BEG);
local_push(p, ifndef_ripper(1)+0);
+ /* jumps are possible in the top-level loop. */
+ if (!ifndef_ripper(p->do_loop) + 0) init_block_exit(p);
}
- top_compstmt
+ compstmt(top_stmts)
{
- /*%%%*/
if ($2 && !compile_for_eval) {
NODE *node = $2;
/* last expression should not be void */
if (nd_type_p(node, NODE_BLOCK)) {
- while (node->nd_next) {
- node = node->nd_next;
+ while (RNODE_BLOCK(node)->nd_next) {
+ node = RNODE_BLOCK(node)->nd_next;
}
- node = node->nd_head;
+ node = RNODE_BLOCK(node)->nd_head;
}
node = remove_begin(node);
void_expr(p, node);
}
- p->eval_tree = NEW_SCOPE(0, block_append(p, p->eval_tree, $2), &@$);
- /*% %*/
- /*% ripper[final]: program!($2) %*/
+ p->eval_tree = NEW_SCOPE(0, block_append(p, p->eval_tree, $2), NULL, &@$);
+ /*% ripper[final]: program!($:2) %*/
local_pop(p);
}
;
-top_compstmt : top_stmts opt_terms
- {
- $$ = void_stmts(p, $1);
- }
- ;
-
top_stmts : none
{
- /*%%%*/
$$ = NEW_BEGIN(0, &@$);
- /*% %*/
/*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/
}
| top_stmt
{
- /*%%%*/
$$ = newline_node($1);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, $1) %*/
+ /*% ripper: stmts_add!(stmts_new!, $:1) %*/
}
| top_stmts terms top_stmt
{
- /*%%%*/
$$ = block_append(p, $1, newline_node($3));
- /*% %*/
- /*% ripper: stmts_add!($1, $3) %*/
+ /*% ripper: stmts_add!($:1, $:3) %*/
}
;
top_stmt : stmt
+ {
+ clear_block_exit(p, true);
+ $$ = $1;
+ }
| keyword_BEGIN begin_block
{
$$ = $2;
+ /*% ripper: $:2 %*/
}
;
-begin_block : '{' top_compstmt '}'
+block_open : '{' {$$ = init_block_exit(p);};
+
+begin_block : block_open compstmt(top_stmts) '}'
{
- /*%%%*/
+ restore_block_exit(p, $block_open);
p->eval_tree_begin = block_append(p, p->eval_tree_begin,
- NEW_BEGIN($2, &@$));
+ NEW_BEGIN($compstmt, &@$));
$$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: BEGIN!($2) %*/
+ /*% ripper: BEGIN!($:compstmt) %*/
}
;
-bodystmt : compstmt
+bodystmt : compstmt(stmts)[body]
+ lex_ctxt[ctxt]
opt_rescue
- k_else {if (!$2) {yyerror1(&@3, "else without rescue is useless");}}
- compstmt
+ k_else
+ {
+ if (!$opt_rescue) yyerror1(&@k_else, "else without rescue is useless");
+ next_rescue_context(&p->ctxt, &$ctxt, after_else);
+ }
+ compstmt(stmts)[elsebody]
+ {
+ next_rescue_context(&p->ctxt, &$ctxt, after_ensure);
+ }
opt_ensure
{
- /*%%%*/
- $$ = new_bodystmt(p, $1, $2, $5, $6, &@$);
- /*% %*/
- /*% ripper: bodystmt!(escape_Qundef($1), escape_Qundef($2), escape_Qundef($5), escape_Qundef($6)) %*/
+ $$ = new_bodystmt(p, $body, $opt_rescue, $elsebody, $opt_ensure, &@$);
+ /*% ripper: bodystmt!($:body, $:opt_rescue, $:elsebody, $:opt_ensure) %*/
}
- | compstmt
+ | compstmt(stmts)[body]
+ lex_ctxt[ctxt]
opt_rescue
- opt_ensure
{
- /*%%%*/
- $$ = new_bodystmt(p, $1, $2, 0, $3, &@$);
- /*% %*/
- /*% ripper: bodystmt!(escape_Qundef($1), escape_Qundef($2), Qnil, escape_Qundef($3)) %*/
+ next_rescue_context(&p->ctxt, &$ctxt, after_ensure);
}
- ;
-
-compstmt : stmts opt_terms
+ opt_ensure
{
- $$ = void_stmts(p, $1);
+ $$ = new_bodystmt(p, $body, $opt_rescue, 0, $opt_ensure, &@$);
+ /*% ripper: bodystmt!($:body, $:opt_rescue, Qnil, $:opt_ensure) %*/
}
;
stmts : none
{
- /*%%%*/
$$ = NEW_BEGIN(0, &@$);
- /*% %*/
/*% ripper: stmts_add!(stmts_new!, void_stmt!) %*/
}
| stmt_or_begin
{
- /*%%%*/
$$ = newline_node($1);
- /*% %*/
- /*% ripper: stmts_add!(stmts_new!, $1) %*/
+ /*% ripper: stmts_add!(stmts_new!, $:1) %*/
}
| stmts terms stmt_or_begin
{
- /*%%%*/
$$ = block_append(p, $1, newline_node($3));
- /*% %*/
- /*% ripper: stmts_add!($1, $3) %*/
+ /*% ripper: stmts_add!($:1, $:3) %*/
}
;
stmt_or_begin : stmt
- {
- $$ = $1;
- }
| keyword_BEGIN
{
yyerror1(&@1, "BEGIN is permitted only at toplevel");
@@ -1723,390 +3292,267 @@ stmt_or_begin : stmt
}
;
-stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
+allow_exits : {$$ = allow_block_exit(p);};
+
+k_END : keyword_END lex_ctxt
{
- /*%%%*/
- $$ = NEW_ALIAS($2, $4, &@$);
- /*% %*/
- /*% ripper: alias!($2, $4) %*/
+ if (p->ctxt.in_def) {
+ rb_warn0("END in method; use at_exit");
+ }
+ $$ = $2;
+ p->ctxt.in_rescue = before_rescue;
+ /*% ripper: $:2 %*/
+ };
+
+stmt : keyword_alias[kw] fitem[new] {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem[old]
+ {
+ $$ = NEW_ALIAS($new, $old, &@$, &@kw);
+ /*% ripper: alias!($:new, $:old) %*/
}
- | keyword_alias tGVAR tGVAR
+ | keyword_alias[kw] tGVAR[new] tGVAR[old]
{
- /*%%%*/
- $$ = NEW_VALIAS($2, $3, &@$);
- /*% %*/
- /*% ripper: var_alias!($2, $3) %*/
+ $$ = NEW_VALIAS($new, $old, &@$, &@kw);
+ /*% ripper: var_alias!($:new, $:old) %*/
}
- | keyword_alias tGVAR tBACK_REF
+ | keyword_alias[kw] tGVAR[new] tBACK_REF[old]
{
- /*%%%*/
char buf[2];
buf[0] = '$';
- buf[1] = (char)$3->nd_nth;
- $$ = NEW_VALIAS($2, rb_intern2(buf, 2), &@$);
- /*% %*/
- /*% ripper: var_alias!($2, $3) %*/
+ buf[1] = (char)RNODE_BACK_REF($old)->nd_nth;
+ $$ = NEW_VALIAS($new, rb_intern2(buf, 2), &@$, &@kw);
+ /*% ripper: var_alias!($:new, $:old) %*/
}
- | keyword_alias tGVAR tNTH_REF
+ | keyword_alias tGVAR tNTH_REF[nth]
{
static const char mesg[] = "can't make alias for the number variables";
/*%%%*/
- yyerror1(&@3, mesg);
- $$ = NEW_BEGIN(0, &@$);
+ yyerror1(&@nth, mesg);
/*% %*/
- /*% ripper[error]: alias_error!(ERR_MESG(), $3) %*/
+ $$ = NEW_ERROR(&@$);
+ /*% ripper[error]: alias_error!(ERR_MESG(), $:nth) %*/
}
- | keyword_undef undef_list
+ | keyword_undef[kw] undef_list[list]
{
- /*%%%*/
- $$ = $2;
- /*% %*/
- /*% ripper: undef!($2) %*/
+ nd_set_first_loc($list, @kw.beg_pos);
+ RNODE_UNDEF($list)->keyword_loc = @kw;
+ $$ = $list;
+ /*% ripper: undef!($:list) %*/
}
- | stmt modifier_if expr_value
+ | stmt[body] modifier_if[mod] expr_value[cond]
{
- /*%%%*/
- $$ = new_if(p, $3, remove_begin($1), 0, &@$);
- fixpos($$, $3);
- /*% %*/
- /*% ripper: if_mod!($3, $1) %*/
+ $$ = new_if(p, $cond, remove_begin($body), 0, &@$, &@mod, &NULL_LOC, &NULL_LOC);
+ fixpos($$, $cond);
+ /*% ripper: if_mod!($:cond, $:body) %*/
}
- | stmt modifier_unless expr_value
+ | stmt[body] modifier_unless[mod] expr_value[cond]
{
- /*%%%*/
- $$ = new_unless(p, $3, remove_begin($1), 0, &@$);
- fixpos($$, $3);
- /*% %*/
- /*% ripper: unless_mod!($3, $1) %*/
+ $$ = new_unless(p, $cond, remove_begin($body), 0, &@$, &@mod, &NULL_LOC, &NULL_LOC);
+ fixpos($$, $cond);
+ /*% ripper: unless_mod!($:cond, $:body) %*/
}
- | stmt modifier_while expr_value
+ | stmt[body] modifier_while[mod] expr_value[cond_expr]
{
- /*%%%*/
- if ($1 && nd_type_p($1, NODE_BEGIN)) {
- $$ = NEW_WHILE(cond(p, $3, &@3), $1->nd_body, 0, &@$);
+ clear_block_exit(p, false);
+ if ($body && nd_type_p($body, NODE_BEGIN)) {
+ $$ = NEW_WHILE(cond(p, $cond_expr, &@cond_expr), RNODE_BEGIN($body)->nd_body, 0, &@$, &@mod, &NULL_LOC);
}
else {
- $$ = NEW_WHILE(cond(p, $3, &@3), $1, 1, &@$);
+ $$ = NEW_WHILE(cond(p, $cond_expr, &@cond_expr), $body, 1, &@$, &@mod, &NULL_LOC);
}
- /*% %*/
- /*% ripper: while_mod!($3, $1) %*/
+ /*% ripper: while_mod!($:cond_expr, $:body) %*/
}
- | stmt modifier_until expr_value
+ | stmt[body] modifier_until[mod] expr_value[cond_expr]
{
- /*%%%*/
- if ($1 && nd_type_p($1, NODE_BEGIN)) {
- $$ = NEW_UNTIL(cond(p, $3, &@3), $1->nd_body, 0, &@$);
+ clear_block_exit(p, 0);
+ if ($body && nd_type_p($body, NODE_BEGIN)) {
+ $$ = NEW_UNTIL(cond(p, $cond_expr, &@cond_expr), RNODE_BEGIN($body)->nd_body, 0, &@$, &@mod, &NULL_LOC);
}
else {
- $$ = NEW_UNTIL(cond(p, $3, &@3), $1, 1, &@$);
+ $$ = NEW_UNTIL(cond(p, $cond_expr, &@cond_expr), $body, 1, &@$, &@mod, &NULL_LOC);
}
- /*% %*/
- /*% ripper: until_mod!($3, $1) %*/
+ /*% ripper: until_mod!($:cond_expr, $:body) %*/
}
- | stmt modifier_rescue stmt
+ | stmt[body] modifier_rescue[mod] after_rescue[ctxt] stmt[resbody]
{
- /*%%%*/
+ p->ctxt.in_rescue = $ctxt.in_rescue;
NODE *resq;
- YYLTYPE loc = code_loc_gen(&@2, &@3);
- resq = NEW_RESBODY(0, remove_begin($3), 0, &loc);
- $$ = NEW_RESCUE(remove_begin($1), resq, 0, &@$);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ YYLTYPE loc = code_loc_gen(&@mod, &@resbody);
+ resq = NEW_RESBODY(0, 0, remove_begin($resbody), 0, &loc);
+ $$ = NEW_RESCUE(remove_begin($body), resq, 0, &@$);
+ /*% ripper: rescue_mod!($:body, $:resbody) %*/
}
- | keyword_END '{' compstmt '}'
+ | k_END[k_end] block_open[lbrace] compstmt(stmts)[body] '}'[rbrace]
{
- if (p->ctxt.in_def) {
- rb_warn0("END in method; use at_exit");
- }
- /*%%%*/
+ clear_block_exit(p, true);
+ restore_block_exit(p, $block_open);
+ p->ctxt = $k_end;
{
- NODE *scope = NEW_NODE(
- NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */, &@$);
- $$ = NEW_POSTEXE(scope, &@$);
+ NODE *scope = NEW_SCOPE2(0 /* tbl */, 0 /* args */, $body /* body */, NULL /* parent */, &@$);
+ $$ = NEW_POSTEXE(scope, &@$, &@k_end, &@lbrace, &@rbrace);
+ RNODE_SCOPE(scope)->nd_parent = $$;
}
- /*% %*/
- /*% ripper: END!($3) %*/
+ /*% ripper: END!($:body) %*/
}
| command_asgn
- | mlhs '=' lex_ctxt command_call
+ | mlhs[lhs] '=' lex_ctxt[ctxt] command_call_value[rhs]
{
- /*%%%*/
- value_expr($4);
- $$ = node_assign(p, $1, $4, $3, &@$);
- /*% %*/
- /*% ripper: massign!($1, $4) %*/
+ $$ = node_assign(p, (NODE *)$lhs, $rhs, $ctxt, &@$);
+ /*% ripper: massign!($:lhs, $:rhs) %*/
}
- | lhs '=' lex_ctxt mrhs
+ | asgn(mrhs)
+ | mlhs[lhs] '=' lex_ctxt[lex_ctxt] mrhs_arg[mrhs_arg] modifier_rescue[modifier_rescue]
+ after_rescue[after_rescue] stmt[resbody]
{
- /*%%%*/
- $$ = node_assign(p, $1, $4, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $4) %*/
+ p->ctxt.in_rescue = $after_rescue.in_rescue;
+ YYLTYPE loc = code_loc_gen(&@modifier_rescue, &@resbody);
+ $resbody = NEW_RESBODY(0, 0, remove_begin($resbody), 0, &loc);
+ loc.beg_pos = @mrhs_arg.beg_pos;
+ $mrhs_arg = NEW_RESCUE($mrhs_arg, $resbody, 0, &loc);
+ $$ = node_assign(p, (NODE *)$lhs, $mrhs_arg, $lex_ctxt, &@$);
+ /*% ripper: massign!($:lhs, rescue_mod!($:mrhs_arg, $:resbody)) %*/
}
- | mlhs '=' lex_ctxt mrhs_arg modifier_rescue stmt
+ | mlhs[lhs] '=' lex_ctxt[ctxt] mrhs_arg[rhs]
{
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@5, &@6);
- $$ = node_assign(p, $1, NEW_RESCUE($4, NEW_RESBODY(0, remove_begin($6), 0, &loc), 0, &@$), $3, &@$);
- /*% %*/
- /*% ripper: massign!($1, rescue_mod!($4, $6)) %*/
- }
- | mlhs '=' lex_ctxt mrhs_arg
- {
- /*%%%*/
- $$ = node_assign(p, $1, $4, $3, &@$);
- /*% %*/
- /*% ripper: massign!($1, $4) %*/
+ $$ = node_assign(p, (NODE *)$lhs, $rhs, $ctxt, &@$);
+ /*% ripper: massign!($:lhs, $:rhs) %*/
}
| expr
| error
{
(void)yynerrs;
- /*%%%*/
$$ = NEW_ERROR(&@$);
- /*% %*/
}
;
-command_asgn : lhs '=' lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = node_assign(p, $1, $4, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $4) %*/
- }
- | var_lhs tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = new_op_assign(p, $1, $2, $4, $3, &@$);
- /*% %*/
- /*% ripper: opassign!($1, $2, $4) %*/
- }
- | primary_value '[' opt_call_args rbracket tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = new_ary_op_assign(p, $1, $3, $5, $7, &@3, &@$);
- /*% %*/
- /*% ripper: opassign!(aref_field!($1, escape_Qundef($3)), $5, $7) %*/
-
- }
- | primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
- }
- | primary_value call_op tCONSTANT tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@3);
- $$ = new_const_op_assign(p, NEW_COLON2($1, $3, &loc), $4, $6, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(const_path_field!($1, $3), $4, $6) %*/
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/
- }
- | defn_head f_opt_paren_args '=' endless_command
- {
- endless_method_name(p, $<node>1, &@1);
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*% %*/
- /*% ripper: def!(get_value($1), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
- local_pop(p);
- }
- | defs_head f_opt_paren_args '=' endless_command
- {
- endless_method_name(p, $<node>1, &@1);
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*%
- $1 = get_value($1);
- %*/
- /*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
- local_pop(p);
- }
- | backref tOP_ASGN lex_ctxt command_rhs
- {
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: backref_error(p, RNODE($1), assign!(var_field(p, $1), $4)) %*/
- }
+command_asgn : asgn(command_rhs)
+ | op_asgn(command_rhs)
+ | def_endless_method(endless_command)
;
endless_command : command
- | endless_command modifier_rescue arg
+ | endless_command modifier_rescue after_rescue arg
{
- /*%%%*/
- $$ = rescued_expr(p, $1, $3, &@1, &@2, &@3);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ p->ctxt.in_rescue = $3.in_rescue;
+ $$ = rescued_expr(p, $1, $4, &@1, &@2, &@4);
+ /*% ripper: rescue_mod!($:1, $:4) %*/
}
- | keyword_not opt_nl endless_command
+ | keyword_not '\n'? endless_command
{
$$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
+ /*% ripper: unary!(ID2VAL(idNOT), $:3) %*/
}
;
-command_rhs : command_call %prec tOP_ASGN
+command_rhs : command_call_value %prec tOP_ASGN
+ | command_call_value modifier_rescue after_rescue stmt
{
- value_expr($1);
- $$ = $1;
- }
- | command_call modifier_rescue stmt
- {
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@2, &@3);
- value_expr($1);
- $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ p->ctxt.in_rescue = $3.in_rescue;
+ YYLTYPE loc = code_loc_gen(&@2, &@4);
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0, 0, remove_begin($4), 0, &loc), 0, &@$);
+ /*% ripper: rescue_mod!($:1, $:4) %*/
}
| command_asgn
;
expr : command_call
- | expr keyword_and expr
- {
- $$ = logop(p, idAND, $1, $3, &@2, &@$);
- }
- | expr keyword_or expr
+ | expr[left] keyword_and[op] expr[right]
{
- $$ = logop(p, idOR, $1, $3, &@2, &@$);
+ $$ = logop(p, idAND, $left, $right, &@op, &@$);
+ /*% ripper: binary!($:left, ID2VAL(idAND), $:right) %*/
}
- | keyword_not opt_nl expr
+ | expr[left] keyword_or[op] expr[right]
{
- $$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
+ $$ = logop(p, idOR, $left, $right, &@op, &@$);
+ /*% ripper: binary!($:left, ID2VAL(idOR), $:right) %*/
}
- | '!' command_call
+ | keyword_not[not] '\n'? expr[arg]
{
- $$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
+ $$ = call_uni_op(p, method_cond(p, $arg, &@arg), METHOD_NOT, &@not, &@$);
+ /*% ripper: unary!(ID2VAL(idNOT), $:arg) %*/
}
- | arg tASSOC
+ | '!'[not] command_call[arg]
{
- value_expr($1);
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- $<ctxt>2 = p->ctxt;
- p->ctxt.in_kwarg = 1;
- $<tbl>$ = push_pvtbl(p);
+ $$ = call_uni_op(p, method_cond(p, $arg, &@arg), '!', &@not, &@$);
+ /*% ripper: unary!(ID2VAL('\'!\''), $:arg) %*/
}
+ | arg tASSOC[assoc]
{
- $<tbl>$ = push_pktbl(p);
+ value_expr(p, $arg);
}
- p_top_expr_body
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
+ p_top_expr_body[body]
{
- pop_pktbl(p, $<tbl>4);
- pop_pvtbl(p, $<tbl>3);
- p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
- /*%%%*/
- $$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$);
- /*% %*/
- /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
+ pop_pktbl(p, $p_pktbl);
+ pop_pvtbl(p, $p_pvtbl);
+ p->ctxt.in_kwarg = $ctxt.in_kwarg;
+ p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
+ p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
+ $$ = NEW_CASE3($arg, NEW_IN($body, 0, 0, &@body, &NULL_LOC, &NULL_LOC, &@assoc), &@$, &NULL_LOC, &NULL_LOC);
+ /*% ripper: case!($:arg, in!($:body, Qnil, Qnil)) %*/
}
| arg keyword_in
{
- value_expr($1);
- SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
- p->command_start = FALSE;
- $<ctxt>2 = p->ctxt;
- p->ctxt.in_kwarg = 1;
- $<tbl>$ = push_pvtbl(p);
+ value_expr(p, $arg);
}
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
+ p_top_expr_body[body]
{
- $<tbl>$ = push_pktbl(p);
- }
- p_top_expr_body
- {
- pop_pktbl(p, $<tbl>4);
- pop_pvtbl(p, $<tbl>3);
- p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
- /*%%%*/
- $$ = NEW_CASE3($1, NEW_IN($5, NEW_TRUE(&@5), NEW_FALSE(&@5), &@5), &@$);
- /*% %*/
- /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
+ pop_pktbl(p, $p_pktbl);
+ pop_pvtbl(p, $p_pvtbl);
+ p->ctxt.in_kwarg = $ctxt.in_kwarg;
+ p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
+ p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
+ $$ = NEW_CASE3($arg, NEW_IN($body, NEW_TRUE(&@body), NEW_FALSE(&@body), &@body, &@keyword_in, &NULL_LOC, &NULL_LOC), &@$, &NULL_LOC, &NULL_LOC);
+ /*% ripper: case!($:arg, in!($:body, Qnil, Qnil)) %*/
}
| arg %prec tLBRACE_ARG
;
def_name : fname
{
- ID fname = get_id($1);
- ID cur_arg = p->cur_arg;
- YYSTYPE c = {.ctxt = p->ctxt};
- numparam_name(p, fname);
+ numparam_name(p, $fname);
local_push(p, 0);
- p->cur_arg = 0;
p->ctxt.in_def = 1;
- $<node>$ = NEW_NODE(NODE_SELF, /*vid*/cur_arg, /*mid*/fname, /*cval*/c.val, &@$);
- /*%%%*/
- /*%
- $$ = NEW_RIPPER(fname, get_value($1), $$, &NULL_LOC);
- %*/
+ p->ctxt.in_rescue = before_rescue;
+ p->ctxt.cant_return = 0;
+ $$ = $fname;
}
;
defn_head : k_def def_name
{
- $$ = $2;
- /*%%%*/
- $$ = NEW_NODE(NODE_DEFN, 0, $$->nd_mid, $$, &@$);
- /*% %*/
+ $$ = def_head_save(p, $k_def);
+ $$->nd_mid = $def_name;
+ $$->nd_def = NEW_DEFN($def_name, 0, &@$);
+ /*% ripper: $:def_name %*/
}
;
defs_head : k_def singleton dot_or_colon
{
SET_LEX_STATE(EXPR_FNAME);
- p->ctxt.in_argdef = 1;
}
def_name
{
SET_LEX_STATE(EXPR_ENDFN|EXPR_LABEL); /* force for args */
- $$ = $5;
- /*%%%*/
- $$ = NEW_NODE(NODE_DEFS, $2, $$->nd_mid, $$, &@$);
- /*%
- VALUE ary = rb_ary_new_from_args(3, $2, $3, get_value($$));
- add_mark_object(p, ary);
- $<node>$->nd_rval = ary;
- %*/
+ $$ = def_head_save(p, $k_def);
+ $$->nd_mid = $def_name;
+ $$->nd_def = NEW_DEFS($singleton, $def_name, 0, &@$);
+ /*% ripper: [$:singleton, $:dot_or_colon, $:def_name] %*/
}
;
-expr_value : expr
- {
- value_expr($1);
- $$ = $1;
- }
+expr_value : value_expr(expr)
| error
{
- /*%%%*/
$$ = NEW_ERROR(&@$);
- /*% %*/
}
;
expr_value_do : {COND_PUSH(1);} expr_value do {COND_POP();}
{
$$ = $2;
+ /*% ripper: $:2 %*/
}
;
@@ -2114,392 +3560,270 @@ command_call : command
| block_command
;
+command_call_value : value_expr(command_call)
+ ;
+
block_command : block_call
| block_call call_op2 operation2 command_args
{
- /*%%%*/
$$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, $2, $3), $4) %*/
+ /*% ripper: method_add_arg!(call!($:1, $:2, $:3), $:4) %*/
}
;
cmd_brace_block : tLBRACE_ARG brace_body '}'
{
$$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
+ set_embraced_location($$, &@1, &@3);
+ /*% ripper: $:2 %*/
}
;
fcall : operation
{
- /*%%%*/
$$ = NEW_FCALL($1, 0, &@$);
- nd_set_line($$, p->tokline);
- /*% %*/
- /*% ripper: $1 %*/
+ /*% ripper: $:1 %*/
}
;
command : fcall command_args %prec tLOWEST
{
- /*%%%*/
$1->nd_args = $2;
nd_set_last_loc($1, @2.end_pos);
- $$ = $1;
- /*% %*/
- /*% ripper: command!($1, $2) %*/
+ $$ = (NODE *)$1;
+ /*% ripper: command!($:1, $:2) %*/
}
| fcall command_args cmd_brace_block
{
- /*%%%*/
block_dup_check(p, $2, $3);
$1->nd_args = $2;
- $$ = method_add_block(p, $1, $3, &@$);
- fixpos($$, $1);
+ $$ = method_add_block(p, (NODE *)$1, $3, &@$);
+ fixpos($$, RNODE($1));
nd_set_last_loc($1, @2.end_pos);
- /*% %*/
- /*% ripper: method_add_block!(command!($1, $2), $3) %*/
+ /*% ripper: method_add_block!(command!($:1, $:2), $:3) %*/
}
| primary_value call_op operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = new_command_qcall(p, $2, $1, $3, $4, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: command_call!($1, $2, $3, $4) %*/
+ $$ = new_command_qcall(p, $2, $1, $3, $4, 0, &@3, &@$);
+ /*% ripper: command_call!($:1, $:2, $:3, $:4) %*/
}
| primary_value call_op operation2 command_args cmd_brace_block
{
- /*%%%*/
$$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, $2, $3, $4), $5) %*/
+ /*% ripper: method_add_block!(command_call!($:1, $:2, $:3, $:4), $:5) %*/
}
| primary_value tCOLON2 operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: command_call!($1, ID2VAL(idCOLON2), $3, $4) %*/
+ $$ = new_command_qcall(p, idCOLON2, $1, $3, $4, 0, &@3, &@$);
+ /*% ripper: command_call!($:1, $:2, $:3, $:4) %*/
}
| primary_value tCOLON2 operation2 command_args cmd_brace_block
{
- /*%%%*/
- $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, ID2VAL(idCOLON2), $3, $4), $5) %*/
+ $$ = new_command_qcall(p, idCOLON2, $1, $3, $4, $5, &@3, &@$);
+ /*% ripper: method_add_block!(command_call!($:1, $:2, $:3, $:4), $:5) %*/
+ }
+ | primary_value tCOLON2 tCONSTANT '{' brace_body '}'
+ {
+ set_embraced_location($5, &@4, &@6);
+ $$ = new_command_qcall(p, idCOLON2, $1, $3, 0, $5, &@3, &@$);
+ /*% ripper: method_add_block!(command_call!($:1, $:2, $:3, Qnil), $:5) %*/
}
| keyword_super command_args
{
- /*%%%*/
- $$ = NEW_SUPER($2, &@$);
+ $$ = NEW_SUPER($2, &@$, &@1, &NULL_LOC, &NULL_LOC);
fixpos($$, $2);
- /*% %*/
- /*% ripper: super!($2) %*/
+ /*% ripper: super!($:2) %*/
}
- | keyword_yield command_args
+ | k_yield command_args
{
- /*%%%*/
- $$ = new_yield(p, $2, &@$);
+ $$ = NEW_YIELD($2, &@$, &@1, &NULL_LOC, &NULL_LOC);
fixpos($$, $2);
- /*% %*/
- /*% ripper: yield!($2) %*/
+ /*% ripper: yield!($:2) %*/
}
| k_return call_args
{
- /*%%%*/
- $$ = NEW_RETURN(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: return!($2) %*/
+ $$ = NEW_RETURN(ret_args(p, $2), &@$, &@1);
+ /*% ripper: return!($:2) %*/
}
| keyword_break call_args
{
- /*%%%*/
- $$ = NEW_BREAK(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: break!($2) %*/
+ NODE *args = 0;
+ args = ret_args(p, $2);
+ $$ = add_block_exit(p, NEW_BREAK(args, &@$, &@1));
+ /*% ripper: break!($:2) %*/
}
| keyword_next call_args
{
- /*%%%*/
- $$ = NEW_NEXT(ret_args(p, $2), &@$);
- /*% %*/
- /*% ripper: next!($2) %*/
+ NODE *args = 0;
+ args = ret_args(p, $2);
+ $$ = add_block_exit(p, NEW_NEXT(args, &@$, &@1));
+ /*% ripper: next!($:2) %*/
}
;
mlhs : mlhs_basic
| tLPAREN mlhs_inner rparen
{
- /*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ /*% ripper: mlhs_paren!($:2) %*/
}
;
mlhs_inner : mlhs_basic
| tLPAREN mlhs_inner rparen
{
- /*%%%*/
- $$ = NEW_MASGN(NEW_LIST($2, &@$), 0, &@$);
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ $$ = NEW_MASGN(NEW_LIST((NODE *)$2, &@$), 0, &@$);
+ /*% ripper: mlhs_paren!($:2) %*/
}
;
mlhs_basic : mlhs_head
{
- /*%%%*/
$$ = NEW_MASGN($1, 0, &@$);
- /*% %*/
- /*% ripper: $1 %*/
+ /*% ripper: $:1 %*/
}
| mlhs_head mlhs_item
{
- /*%%%*/
- $$ = NEW_MASGN(list_append(p, $1,$2), 0, &@$);
- /*% %*/
- /*% ripper: mlhs_add!($1, $2) %*/
+ $$ = NEW_MASGN(list_append(p, $1, $2), 0, &@$);
+ /*% ripper: mlhs_add!($:1, $:2) %*/
}
| mlhs_head tSTAR mlhs_node
{
- /*%%%*/
$$ = NEW_MASGN($1, $3, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, $3) %*/
+ /*% ripper: mlhs_add_star!($:1, $:3) %*/
}
- | mlhs_head tSTAR mlhs_node ',' mlhs_post
+ | mlhs_head tSTAR mlhs_node ',' mlhs_items(mlhs_item)
{
- /*%%%*/
$$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, $3), $5) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/
}
| mlhs_head tSTAR
{
- /*%%%*/
$$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, Qnil) %*/
+ /*% ripper: mlhs_add_star!($:1, Qnil) %*/
}
- | mlhs_head tSTAR ',' mlhs_post
+ | mlhs_head tSTAR ',' mlhs_items(mlhs_item)
{
- /*%%%*/
$$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, Qnil), $4) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/
}
| tSTAR mlhs_node
{
- /*%%%*/
$$ = NEW_MASGN(0, $2, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!(mlhs_new!, $2) %*/
+ /*% ripper: mlhs_add_star!(mlhs_new!, $:2) %*/
}
- | tSTAR mlhs_node ',' mlhs_post
+ | tSTAR mlhs_node ',' mlhs_items(mlhs_item)
{
- /*%%%*/
$$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $2), $4) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:2), $:4) %*/
}
| tSTAR
{
- /*%%%*/
$$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$);
- /*% %*/
/*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/
}
- | tSTAR ',' mlhs_post
+ | tSTAR ',' mlhs_items(mlhs_item)
{
- /*%%%*/
$$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $3) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $:3) %*/
}
;
mlhs_item : mlhs_node
| tLPAREN mlhs_inner rparen
{
- /*%%%*/
- $$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ $$ = (NODE *)$2;
+ /*% ripper: mlhs_paren!($:2) %*/
}
;
mlhs_head : mlhs_item ','
{
- /*%%%*/
$$ = NEW_LIST($1, &@1);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
+ /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/
}
| mlhs_head mlhs_item ','
{
- /*%%%*/
$$ = list_append(p, $1, $2);
- /*% %*/
- /*% ripper: mlhs_add!($1, $2) %*/
+ /*% ripper: mlhs_add!($:1, $:2) %*/
}
;
-mlhs_post : mlhs_item
- {
- /*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
- }
- | mlhs_post ',' mlhs_item
- {
- /*%%%*/
- $$ = list_append(p, $1, $3);
- /*% %*/
- /*% ripper: mlhs_add!($1, $3) %*/
- }
- ;
-mlhs_node : user_variable
- {
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
- }
- | keyword_variable
+mlhs_node : user_or_keyword_variable
{
- /*%%%*/
+ /*% ripper: var_field!($:1) %*/
$$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
}
| primary_value '[' opt_call_args rbracket
{
- /*%%%*/
$$ = aryset(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: aref_field!($1, escape_Qundef($3)) %*/
+ /*% ripper: aref_field!($:1, $:3) %*/
}
- | primary_value call_op tIDENTIFIER
+ | primary_value call_op ident_or_const
{
- if ($2 == tANDDOT) {
- yyerror1(&@2, "&. inside multiple assignment destination");
- }
- /*%%%*/
+ anddot_multiple_assignment_check(p, &@2, $2);
$$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ /*% ripper: field!($:1, $:2, $:3) %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
- /*%%%*/
$$ = attrset(p, $1, idCOLON2, $3, &@$);
- /*% %*/
- /*% ripper: const_path_field!($1, $3) %*/
- }
- | primary_value call_op tCONSTANT
- {
- if ($2 == tANDDOT) {
- yyerror1(&@2, "&. inside multiple assignment destination");
- }
- /*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ /*% ripper: const_path_field!($:1, $:3) %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON2($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, const_path_field!($1, $3)) %*/
+ /*% ripper: const_path_field!($:1, $:3) %*/
+ $$ = const_decl(p, NEW_COLON2($1, $3, &@$, &@2, &@3), &@$);
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON3($2, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, top_const_field!($2)) %*/
+ /*% ripper: top_const_field!($:2) %*/
+ $$ = const_decl(p, NEW_COLON3($2, &@$, &@1, &@2), &@$);
}
| backref
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: backref_error(p, RNODE($1), var_field(p, $1)) %*/
+ VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $1);
+ $$ = NEW_ERROR(&@$);
+ /*% ripper[error]: assign_error!(?e, var_field!($:1)) %*/
}
;
-lhs : user_variable
- {
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
- }
- | keyword_variable
+lhs : user_or_keyword_variable
{
- /*%%%*/
+ /*% ripper: var_field!($:1) %*/
$$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
}
| primary_value '[' opt_call_args rbracket
{
- /*%%%*/
$$ = aryset(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: aref_field!($1, escape_Qundef($3)) %*/
+ /*% ripper: aref_field!($:1, $:3) %*/
}
- | primary_value call_op tIDENTIFIER
+ | primary_value call_op ident_or_const
{
- /*%%%*/
$$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ /*% ripper: field!($:1, $:2, $:3) %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
- /*%%%*/
$$ = attrset(p, $1, idCOLON2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, ID2VAL(idCOLON2), $3) %*/
- }
- | primary_value call_op tCONSTANT
- {
- /*%%%*/
- $$ = attrset(p, $1, $2, $3, &@$);
- /*% %*/
- /*% ripper: field!($1, $2, $3) %*/
+ /*% ripper: field!($:1, $:2, $:3) %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON2($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, const_path_field!($1, $3)) %*/
+ /*% ripper: const_path_field!($:1, $:3) %*/
+ $$ = const_decl(p, NEW_COLON2($1, $3, &@$, &@2, &@3), &@$);
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
- $$ = const_decl(p, NEW_COLON3($2, &@$), &@$);
- /*% %*/
- /*% ripper: const_decl(p, top_const_field!($2)) %*/
+ /*% ripper: top_const_field!($:2) %*/
+ $$ = const_decl(p, NEW_COLON3($2, &@$, &@1, &@2), &@$);
}
| backref
{
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: backref_error(p, RNODE($1), var_field(p, $1)) %*/
+ VALUE MAYBE_UNUSED(e) = rb_backref_error(p, $1);
+ $$ = NEW_ERROR(&@$);
+ /*% ripper[error]: assign_error!(?e, var_field!($:1)) %*/
}
;
@@ -2509,37 +3833,29 @@ cname : tIDENTIFIER
/*%%%*/
yyerror1(&@1, mesg);
/*% %*/
- /*% ripper[error]: class_name_error!(ERR_MESG(), $1) %*/
+ /*% ripper[error]: class_name_error!(ERR_MESG(), $:1) %*/
}
| tCONSTANT
;
cpath : tCOLON3 cname
{
- /*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
+ $$ = NEW_COLON3($2, &@$, &@1, &@2);
+ /*% ripper: top_const_ref!($:2) %*/
}
| cname
{
- /*%%%*/
- $$ = NEW_COLON2(0, $$, &@$);
- /*% %*/
- /*% ripper: const_ref!($1) %*/
+ $$ = NEW_COLON2(0, $1, &@$, &NULL_LOC, &@1);
+ /*% ripper: const_ref!($:1) %*/
}
| primary_value tCOLON2 cname
{
- /*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
+ $$ = NEW_COLON2($1, $3, &@$, &@2, &@3);
+ /*% ripper: const_path_ref!($:1, $:3) %*/
}
;
-fname : tIDENTIFIER
- | tCONSTANT
- | tFID
+fname : operation
| op
{
SET_LEX_STATE(EXPR_ENDFN);
@@ -2550,61 +3866,55 @@ fname : tIDENTIFIER
fitem : fname
{
- /*%%%*/
- $$ = NEW_LIT(ID2SYM($1), &@$);
- /*% %*/
- /*% ripper: symbol_literal!($1) %*/
+ $$ = NEW_SYM(rb_id2str($1), &@$);
+ /*% ripper: symbol_literal!($:1) %*/
}
| symbol
;
undef_list : fitem
{
- /*%%%*/
$$ = NEW_UNDEF($1, &@$);
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*% ripper: rb_ary_new3(1, $:1) %*/
}
| undef_list ',' {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
- /*%%%*/
- NODE *undef = NEW_UNDEF($4, &@4);
- $$ = block_append(p, $1, undef);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($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); }
- | tDSTAR { ifndef_ripper($$ = tDSTAR); }
- | '!' { ifndef_ripper($$ = '!'); }
- | '~' { ifndef_ripper($$ = '~'); }
- | tUPLUS { ifndef_ripper($$ = tUPLUS); }
- | tUMINUS { ifndef_ripper($$ = tUMINUS); }
- | tAREF { ifndef_ripper($$ = tAREF); }
- | tASET { ifndef_ripper($$ = tASET); }
- | '`' { ifndef_ripper($$ = '`'); }
+ nd_set_last_loc($1, @4.end_pos);
+ rb_parser_ary_push_node(p, RNODE_UNDEF($1)->nd_undefs, $4);
+ /*% ripper: rb_ary_push($:1, $:4) %*/
+ }
+ ;
+
+op : '|' { $$ = '|'; }
+ | '^' { $$ = '^'; }
+ | '&' { $$ = '&'; }
+ | tCMP { $$ = tCMP; }
+ | tEQ { $$ = tEQ; }
+ | tEQQ { $$ = tEQQ; }
+ | tMATCH { $$ = tMATCH; }
+ | tNMATCH { $$ = tNMATCH; }
+ | '>' { $$ = '>'; }
+ | tGEQ { $$ = tGEQ; }
+ | '<' { $$ = '<'; }
+ | tLEQ { $$ = tLEQ; }
+ | tNEQ { $$ = tNEQ; }
+ | tLSHFT { $$ = tLSHFT; }
+ | tRSHFT { $$ = tRSHFT; }
+ | '+' { $$ = '+'; }
+ | '-' { $$ = '-'; }
+ | '*' { $$ = '*'; }
+ | tSTAR { $$ = '*'; }
+ | '/' { $$ = '/'; }
+ | '%' { $$ = '%'; }
+ | tPOW { $$ = tPOW; }
+ | tDSTAR { $$ = tDSTAR; }
+ | '!' { $$ = '!'; }
+ | '~' { $$ = '~'; }
+ | tUPLUS { $$ = tUPLUS; }
+ | tUMINUS { $$ = tUMINUS; }
+ | tAREF { $$ = tAREF; }
+ | tASET { $$ = tASET; }
+ | '`' { $$ = '`'; }
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
@@ -2621,272 +3931,162 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
| keyword_while | keyword_until
;
-arg : lhs '=' lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = node_assign(p, $1, $4, $3, &@$);
- /*% %*/
- /*% ripper: assign!($1, $4) %*/
- }
- | var_lhs tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = new_op_assign(p, $1, $2, $4, $3, &@$);
- /*% %*/
- /*% ripper: opassign!($1, $2, $4) %*/
- }
- | primary_value '[' opt_call_args rbracket tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = new_ary_op_assign(p, $1, $3, $5, $7, &@3, &@$);
- /*% %*/
- /*% ripper: opassign!(aref_field!($1, escape_Qundef($3)), $5, $7) %*/
- }
- | primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
- }
- | primary_value call_op tCONSTANT tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, $2, $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
- }
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $6, &@$);
- /*% %*/
- /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/
- }
- | primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@3);
- $$ = new_const_op_assign(p, NEW_COLON2($1, $3, &loc), $4, $6, $5, &@$);
- /*% %*/
- /*% ripper: opassign!(const_path_field!($1, $3), $4, $6) %*/
- }
- | tCOLON3 tCONSTANT tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- YYLTYPE loc = code_loc_gen(&@1, &@2);
- $$ = new_const_op_assign(p, NEW_COLON3($2, &loc), $3, $5, $4, &@$);
- /*% %*/
- /*% ripper: opassign!(top_const_field!($2), $3, $5) %*/
- }
- | backref tOP_ASGN lex_ctxt arg_rhs
- {
- /*%%%*/
- rb_backref_error(p, $1);
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper[error]: backref_error(p, RNODE($1), opassign!(var_field(p, $1), $2, $4)) %*/
- }
- | arg tDOT2 arg
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT2($1, $3, &@$);
- /*% %*/
- /*% ripper: dot2!($1, $3) %*/
- }
- | arg tDOT3 arg
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT3($1, $3, &@$);
- /*% %*/
- /*% ripper: dot3!($1, $3) %*/
- }
- | arg tDOT2
- {
- /*%%%*/
- value_expr($1);
- $$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$);
- /*% %*/
- /*% ripper: dot2!($1, Qnil) %*/
- }
- | arg tDOT3
- {
- /*%%%*/
- value_expr($1);
- $$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$);
- /*% %*/
- /*% ripper: dot3!($1, Qnil) %*/
- }
- | tBDOT2 arg
- {
- /*%%%*/
- value_expr($2);
- $$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$);
- /*% %*/
- /*% ripper: dot2!(Qnil, $2) %*/
- }
- | tBDOT3 arg
- {
- /*%%%*/
- value_expr($2);
- $$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$);
- /*% %*/
- /*% ripper: dot3!(Qnil, $2) %*/
- }
+arg : asgn(arg_rhs)
+ | op_asgn(arg_rhs)
+ | range_expr(arg)
| arg '+' arg
{
$$ = call_bin_op(p, $1, '+', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'+\''), $:3) %*/
}
| arg '-' arg
{
$$ = call_bin_op(p, $1, '-', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'-\''), $:3) %*/
}
| arg '*' arg
{
$$ = call_bin_op(p, $1, '*', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'*\''), $:3) %*/
}
| arg '/' arg
{
$$ = call_bin_op(p, $1, '/', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'/\''), $:3) %*/
}
| arg '%' arg
{
$$ = call_bin_op(p, $1, '%', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'%\''), $:3) %*/
}
| arg tPOW arg
{
$$ = call_bin_op(p, $1, idPow, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idPow), $:3) %*/
}
| tUMINUS_NUM simple_numeric tPOW arg
{
$$ = call_uni_op(p, call_bin_op(p, $2, idPow, $4, &@2, &@$), idUMinus, &@1, &@$);
+ /*% ripper: unary!(ID2VAL(idUMinus), binary!($:2, ID2VAL(idPow), $:4)) %*/
}
| tUPLUS arg
{
$$ = call_uni_op(p, $2, idUPlus, &@1, &@$);
+ /*% ripper: unary!(ID2VAL(idUPlus), $:2) %*/
}
| tUMINUS arg
{
$$ = call_uni_op(p, $2, idUMinus, &@1, &@$);
+ /*% ripper: unary!(ID2VAL(idUMinus), $:2) %*/
}
| arg '|' arg
{
$$ = call_bin_op(p, $1, '|', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'|\''), $:3) %*/
}
| arg '^' arg
{
$$ = call_bin_op(p, $1, '^', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'^\''), $:3) %*/
}
| arg '&' arg
{
$$ = call_bin_op(p, $1, '&', $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL('\'&\''), $:3) %*/
}
| arg tCMP arg
{
$$ = call_bin_op(p, $1, idCmp, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idCmp), $:3) %*/
}
| rel_expr %prec tCMP
| arg tEQ arg
{
$$ = call_bin_op(p, $1, idEq, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idEq), $:3) %*/
}
| arg tEQQ arg
{
$$ = call_bin_op(p, $1, idEqq, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idEqq), $:3) %*/
}
| arg tNEQ arg
{
$$ = call_bin_op(p, $1, idNeq, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idNeq), $:3) %*/
}
| arg tMATCH arg
{
$$ = match_op(p, $1, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idEqTilde), $:3) %*/
}
| arg tNMATCH arg
{
$$ = call_bin_op(p, $1, idNeqTilde, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idNeqTilde), $:3) %*/
}
| '!' arg
{
$$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
+ /*% ripper: unary!(ID2VAL('\'!\''), $:2) %*/
}
| '~' arg
{
$$ = call_uni_op(p, $2, '~', &@1, &@$);
+ /*% ripper: unary!(ID2VAL('\'~\''), $:2) %*/
}
| arg tLSHFT arg
{
$$ = call_bin_op(p, $1, idLTLT, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idLTLT), $:3) %*/
}
| arg tRSHFT arg
{
$$ = call_bin_op(p, $1, idGTGT, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idGTGT), $:3) %*/
}
| arg tANDOP arg
{
$$ = logop(p, idANDOP, $1, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idANDOP), $:3) %*/
}
| arg tOROP arg
{
$$ = logop(p, idOROP, $1, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL(idOROP), $:3) %*/
}
- | keyword_defined opt_nl {p->ctxt.in_defined = 1;} arg
- {
- p->ctxt.in_defined = 0;
- $$ = new_defined(p, $4, &@$);
- }
- | arg '?' arg opt_nl ':' arg
+ | keyword_defined '\n'? begin_defined arg
{
- /*%%%*/
- value_expr($1);
- $$ = new_if(p, $1, $3, $6, &@$);
- fixpos($$, $1);
- /*% %*/
- /*% ripper: ifop!($1, $3, $6) %*/
- }
- | defn_head f_opt_paren_args '=' endless_arg
- {
- endless_method_name(p, $<node>1, &@1);
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*% %*/
- /*% ripper: def!(get_value($1), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
- local_pop(p);
- }
- | defs_head f_opt_paren_args '=' endless_arg
- {
- endless_method_name(p, $<node>1, &@1);
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*%
- $1 = get_value($1);
- %*/
- /*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
- local_pop(p);
+ p->ctxt.in_defined = $3.in_defined;
+ $$ = new_defined(p, $4, &@$, &@1);
+ p->ctxt.has_trailing_semicolon = $3.has_trailing_semicolon;
+ /*% ripper: defined!($:4) %*/
}
+ | def_endless_method(endless_arg)
+ | ternary
| primary
+ ;
+
+ternary : arg '?' arg '\n'? ':' arg
{
- $$ = $1;
+ value_expr(p, $1);
+ $$ = new_if(p, $1, $3, $6, &@$, &NULL_LOC, &@5, &NULL_LOC);
+ fixpos($$, $1);
+ /*% ripper: ifop!($:1, $:3, $:6) %*/
}
;
endless_arg : arg %prec modifier_rescue
- | endless_arg modifier_rescue arg
+ | endless_arg modifier_rescue after_rescue arg
{
- /*%%%*/
- $$ = rescued_expr(p, $1, $3, &@1, &@2, &@3);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ p->ctxt.in_rescue = $3.in_rescue;
+ $$ = rescued_expr(p, $1, $4, &@1, &@2, &@4);
+ /*% ripper: rescue_mod!($:1, $:4) %*/
}
- | keyword_not opt_nl endless_arg
+ | keyword_not '\n'? endless_arg
{
$$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
+ /*% ripper: unary!(ID2VAL(idNOT), $:3) %*/
}
;
@@ -2899,11 +4099,13 @@ relop : '>' {$$ = '>';}
rel_expr : arg relop arg %prec '>'
{
$$ = call_bin_op(p, $1, $2, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL($2), $:3) %*/
}
| rel_expr relop arg %prec '>'
{
rb_warning1("comparison '%s' after comparison", WARN_ID($2));
$$ = call_bin_op(p, $1, $2, $3, &@2, &@$);
+ /*% ripper: binary!($:1, ID2VAL($2), $:3) %*/
}
;
@@ -2913,141 +4115,129 @@ lex_ctxt : none
}
;
-arg_value : arg
+begin_defined : lex_ctxt
{
- value_expr($1);
+ p->ctxt.in_defined = 1;
$$ = $1;
}
;
-aref_args : none
- | args trailer
+after_rescue : lex_ctxt
{
+ p->ctxt.in_rescue = after_rescue;
$$ = $1;
}
+ ;
+
+arg_value : value_expr(arg)
+ ;
+
+aref_args : none
+ | args trailer
| args ',' assocs trailer
{
- /*%%%*/
$$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
- /*% %*/
- /*% ripper: args_add!($1, bare_assoc_hash!($3)) %*/
+ /*% ripper: args_add!($:1, bare_assoc_hash!($:3)) %*/
}
| assocs trailer
{
- /*%%%*/
$$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@$) : 0;
- /*% %*/
- /*% ripper: args_add!(args_new!, bare_assoc_hash!($1)) %*/
+ /*% ripper: args_add!(args_new!, bare_assoc_hash!($:1)) %*/
}
;
arg_rhs : arg %prec tOP_ASGN
{
- value_expr($1);
+ value_expr(p, $1);
$$ = $1;
}
- | arg modifier_rescue arg
+ | arg modifier_rescue after_rescue arg
{
- /*%%%*/
- value_expr($1);
- $$ = rescued_expr(p, $1, $3, &@1, &@2, &@3);
- /*% %*/
- /*% ripper: rescue_mod!($1, $3) %*/
+ p->ctxt.in_rescue = $3.in_rescue;
+ value_expr(p, $1);
+ $$ = rescued_expr(p, $1, $4, &@1, &@2, &@4);
+ /*% ripper: rescue_mod!($:1, $:4) %*/
}
;
paren_args : '(' opt_call_args rparen
{
- /*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: arg_paren!(escape_Qundef($2)) %*/
+ /*% ripper: arg_paren!($:2) %*/
}
| '(' args ',' args_forward rparen
{
if (!check_forwarding_args(p)) {
- $$ = Qnone;
+ $$ = 0;
}
else {
- /*%%%*/
$$ = new_args_forward_call(p, $2, &@4, &@$);
- /*% %*/
- /*% ripper: arg_paren!(args_add!($2, $4)) %*/
+ /*% ripper: arg_paren!(args_add!($:2, $:4)) %*/
}
}
| '(' args_forward rparen
{
if (!check_forwarding_args(p)) {
- $$ = Qnone;
+ $$ = 0;
}
else {
- /*%%%*/
$$ = new_args_forward_call(p, 0, &@2, &@$);
- /*% %*/
- /*% ripper: arg_paren!($2) %*/
+ /*% ripper: arg_paren!($:2) %*/
}
}
;
opt_paren_args : none
| paren_args
+ {
+ $$ = $1 ? $1 : NODE_SPECIAL_EMPTY_ARGS;
+ }
;
opt_call_args : none
| call_args
| args ','
- {
- $$ = $1;
- }
| args ',' assocs ','
{
- /*%%%*/
$$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
- /*% %*/
- /*% ripper: args_add!($1, bare_assoc_hash!($3)) %*/
+ /*% ripper: args_add!($:1, bare_assoc_hash!($:3)) %*/
}
| assocs ','
{
- /*%%%*/
$$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@1) : 0;
- /*% %*/
- /*% ripper: args_add!(args_new!, bare_assoc_hash!($1)) %*/
+ /*% ripper: args_add!(args_new!, bare_assoc_hash!($:1)) %*/
}
;
-call_args : command
+call_args : value_expr(command)
{
- /*%%%*/
- value_expr($1);
$$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
+ /*% ripper: args_add!(args_new!, $:1) %*/
+ }
+ | def_endless_method(endless_command)
+ {
+ $$ = NEW_LIST($1, &@$);
+ /*% ripper: args_add!(args_new!, $:1) %*/
}
| args opt_block_arg
{
- /*%%%*/
$$ = arg_blk_pass($1, $2);
- /*% %*/
- /*% ripper: args_add_block!($1, $2) %*/
+ /*% ripper: args_add_block!($:1, $:2) %*/
}
| assocs opt_block_arg
{
- /*%%%*/
$$ = $1 ? NEW_LIST(new_hash(p, $1, &@1), &@1) : 0;
$$ = arg_blk_pass($$, $2);
- /*% %*/
- /*% ripper: args_add_block!(args_add!(args_new!, bare_assoc_hash!($1)), $2) %*/
+ /*% ripper: args_add_block!(args_add!(args_new!, bare_assoc_hash!($:1)), $:2) %*/
}
| args ',' assocs opt_block_arg
{
- /*%%%*/
$$ = $3 ? arg_append(p, $1, new_hash(p, $3, &@3), &@$) : $1;
$$ = arg_blk_pass($$, $4);
- /*% %*/
- /*% ripper: args_add_block!(args_add!($1, bare_assoc_hash!($3)), $4) %*/
+ /*% ripper: args_add_block!(args_add!($:1, bare_assoc_hash!($:3)), $:4) %*/
}
| block_arg
- /*% ripper[brace]: args_add_block!(args_new!, $1) %*/
+ /*% ripper: args_add_block!(args_new!, $:1) %*/
;
command_args : {
@@ -3084,24 +4274,19 @@ command_args : {
CMDARG_POP();
if (lookahead) CMDARG_PUSH(0);
$$ = $2;
+ /*% ripper: $:2 %*/
}
;
block_arg : tAMPER arg_value
{
- /*%%%*/
- $$ = NEW_BLOCK_PASS($2, &@$);
- /*% %*/
- /*% ripper: $2 %*/
+ $$ = NEW_BLOCK_PASS($2, &@$, &@1);
+ /*% ripper: $:2 %*/
}
| tAMPER
{
- if (!local_id(p, idFWD_BLOCK)) {
- compile_error(p, "no anonymous block parameter");
- }
- /*%%%*/
- $$ = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, &@1), &@$);
- /*% %*/
+ forwarding_arg_check(p, idFWD_BLOCK, idFWD_ALL, "block");
+ $$ = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, &@1), &@$, &@1);
/*% ripper: Qnil %*/
}
;
@@ -3109,63 +4294,49 @@ block_arg : tAMPER arg_value
opt_block_arg : ',' block_arg
{
$$ = $2;
+ /*% ripper: $:2 %*/
}
| none
{
$$ = 0;
+ /*% ripper: Qfalse %*/
}
;
/* value */
args : arg_value
{
- /*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
+ $$ = NEW_LIST($arg_value, &@$);
+ /*% ripper: args_add!(args_new!, $:arg_value) %*/
}
- | tSTAR arg_value
+ | arg_splat
{
- /*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: args_add_star!(args_new!, $2) %*/
+ $$ = $arg_splat;
+ /*% ripper: args_add_star!(args_new!, $:arg_splat) %*/
}
- | tSTAR
+ | args[non_last_args] ',' arg_value
{
- if (!local_id(p, idFWD_REST) ||
- local_id(p, idFWD_ALL)) {
- compile_error(p, "no anonymous rest parameter");
- }
- /*%%%*/
- $$ = NEW_SPLAT(NEW_LVAR(idFWD_REST, &@1), &@$);
- /*% %*/
- /*% ripper: args_add_star!(args_new!, Qnil) %*/
+ $$ = last_arg_append(p, $non_last_args, $arg_value, &@$);
+ /*% ripper: args_add!($:non_last_args, $:arg_value) %*/
}
- | args ',' arg_value
+ | args[non_last_args] ',' arg_splat
{
- /*%%%*/
- $$ = last_arg_append(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: args_add!($1, $3) %*/
+ $$ = rest_arg_append(p, $non_last_args, RNODE_SPLAT($arg_splat)->nd_head, &@$);
+ /*% ripper: args_add_star!($:non_last_args, $:arg_splat) %*/
}
- | args ',' tSTAR arg_value
+ ;
+
+/* value */
+arg_splat : tSTAR arg_value
{
- /*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: args_add_star!($1, $4) %*/
+ $$ = NEW_SPLAT($arg_value, &@$, &@tSTAR);
+ /*% ripper: $:arg_value %*/
}
- | args ',' tSTAR
+ | tSTAR /* none */
{
- if (!local_id(p, idFWD_REST) ||
- local_id(p, idFWD_ALL)) {
- compile_error(p, "no anonymous rest parameter");
- }
- /*%%%*/
- $$ = rest_arg_append(p, $1, NEW_LVAR(idFWD_REST, &@3), &@$);
- /*% %*/
- /*% ripper: args_add_star!($1, Qnil) %*/
+ forwarding_arg_check(p, idFWD_REST, idFWD_ALL, "rest");
+ $$ = NEW_SPLAT(NEW_LVAR(idFWD_REST, &@tSTAR), &@$, &@tSTAR);
+ /*% ripper: Qnil %*/
}
;
@@ -3177,28 +4348,23 @@ mrhs_arg : mrhs
/* value */
mrhs : args ',' arg_value
{
- /*%%%*/
- $$ = last_arg_append(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: mrhs_add!(mrhs_new_from_args!($1), $3) %*/
+ $$ = last_arg_append(p, $args, $arg_value, &@$);
+ /*% ripper: mrhs_add!(mrhs_new_from_args!($:args), $:arg_value) %*/
}
| args ',' tSTAR arg_value
{
- /*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: mrhs_add_star!(mrhs_new_from_args!($1), $4) %*/
+ $$ = rest_arg_append(p, $args, $arg_value, &@$);
+ /*% ripper: mrhs_add_star!(mrhs_new_from_args!($:args), $:arg_value) %*/
}
| tSTAR arg_value
{
- /*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: mrhs_add_star!(mrhs_new!, $2) %*/
+ $$ = NEW_SPLAT($arg_value, &@$, &@tSTAR);
+ /*% ripper: mrhs_add_star!(mrhs_new!, $:arg_value) %*/
}
;
-primary : literal
+%rule %inline inline_primary
+ : literal
| strings
| xstring
| regexp
@@ -3206,411 +4372,355 @@ primary : literal
| qwords
| symbols
| qsymbols
- | var_ref
- | backref
- | tFID
- {
- /*%%%*/
- $$ = NEW_FCALL($1, 0, &@$);
- /*% %*/
- /*% ripper: method_add_arg!(fcall!($1), args_new!) %*/
- }
- | k_begin
- {
- CMDARG_PUSH(0);
- }
- bodystmt
- k_end
- {
- CMDARG_POP();
- /*%%%*/
- set_line_body($3, @1.end_pos.lineno);
- $$ = NEW_BEGIN($3, &@$);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
- /*% ripper: begin!($3) %*/
- }
- | tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen
- {
- /*%%%*/
- $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: paren!(0) %*/
- }
- | tLPAREN_ARG stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen
- {
- /*%%%*/
- if (nd_type_p($2, NODE_SELF)) $2->nd_state = 0;
- $$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
- }
- | tLPAREN compstmt ')'
- {
- /*%%%*/
- if (nd_type_p($2, NODE_SELF)) $2->nd_state = 0;
- $$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
- }
- | primary_value tCOLON2 tCONSTANT
- {
- /*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
- }
- | tCOLON3 tCONSTANT
- {
- /*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
- }
- | tLBRACK aref_args ']'
- {
- /*%%%*/
- $$ = make_list($2, &@$);
- /*% %*/
- /*% ripper: array!(escape_Qundef($2)) %*/
- }
- | tLBRACE assoc_list '}'
- {
- /*%%%*/
- $$ = new_hash(p, $2, &@$);
- $$->nd_brace = TRUE;
- /*% %*/
- /*% ripper: hash!(escape_Qundef($2)) %*/
- }
- | k_return
- {
- /*%%%*/
- $$ = NEW_RETURN(0, &@$);
- /*% %*/
- /*% ripper: return0! %*/
- }
- | keyword_yield '(' call_args rparen
- {
- /*%%%*/
- $$ = new_yield(p, $3, &@$);
- /*% %*/
- /*% ripper: yield!(paren!($3)) %*/
- }
- | keyword_yield '(' rparen
- {
- /*%%%*/
- $$ = NEW_YIELD(0, &@$);
- /*% %*/
- /*% ripper: yield!(paren!(args_new!)) %*/
- }
- | keyword_yield
- {
- /*%%%*/
- $$ = NEW_YIELD(0, &@$);
- /*% %*/
- /*% ripper: yield0! %*/
- }
- | keyword_defined opt_nl '(' {p->ctxt.in_defined = 1;} expr rparen
- {
- p->ctxt.in_defined = 0;
- $$ = new_defined(p, $5, &@$);
- }
- | keyword_not '(' expr rparen
- {
- $$ = call_uni_op(p, method_cond(p, $3, &@3), METHOD_NOT, &@1, &@$);
- }
- | keyword_not '(' rparen
- {
- $$ = call_uni_op(p, method_cond(p, new_nil(&@2), &@2), METHOD_NOT, &@1, &@$);
- }
- | fcall brace_block
- {
- /*%%%*/
- $$ = method_add_block(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: method_add_block!(method_add_arg!(fcall!($1), args_new!), $2) %*/
- }
- | method_call
- | method_call brace_block
- {
- /*%%%*/
- block_dup_check(p, $1->nd_args, $2);
- $$ = method_add_block(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: method_add_block!($1, $2) %*/
- }
- | lambda
- | k_if expr_value then
- compstmt
- if_tail
- k_end
- {
- /*%%%*/
- $$ = new_if(p, $2, $4, $5, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: if!($2, $4, escape_Qundef($5)) %*/
- }
- | k_unless expr_value then
- compstmt
- opt_else
- k_end
- {
- /*%%%*/
- $$ = new_unless(p, $2, $4, $5, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: unless!($2, $4, escape_Qundef($5)) %*/
- }
- | k_while expr_value_do
- compstmt
- k_end
- {
- /*%%%*/
- $$ = NEW_WHILE(cond(p, $2, &@2), $3, 1, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: while!($2, $3) %*/
- }
- | k_until expr_value_do
- compstmt
- k_end
- {
- /*%%%*/
- $$ = NEW_UNTIL(cond(p, $2, &@2), $3, 1, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: until!($2, $3) %*/
- }
- | k_case expr_value opt_terms
- {
- $<val>$ = p->case_labels;
- p->case_labels = Qnil;
- }
- case_body
- k_end
- {
- if (RTEST(p->case_labels)) rb_hash_clear(p->case_labels);
- p->case_labels = $<val>4;
- /*%%%*/
- $$ = NEW_CASE($2, $5, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: case!($2, $5) %*/
- }
- | k_case opt_terms
- {
- $<val>$ = p->case_labels;
- p->case_labels = 0;
- }
- case_body
- k_end
- {
- if (RTEST(p->case_labels)) rb_hash_clear(p->case_labels);
- p->case_labels = $<val>3;
- /*%%%*/
- $$ = NEW_CASE2($4, &@$);
- /*% %*/
- /*% ripper: case!(Qnil, $4) %*/
- }
- | k_case expr_value opt_terms
- p_case_body
- k_end
- {
- /*%%%*/
- $$ = NEW_CASE3($2, $4, &@$);
- /*% %*/
- /*% ripper: case!($2, $4) %*/
- }
- | k_for for_var keyword_in expr_value_do
- compstmt
- k_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(p);
- NODE *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
- NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
- rb_ast_id_table_t *tbl = rb_ast_new_local_table(p->ast, 1);
- tbl->ids[0] = id; /* internal id */
-
- switch (nd_type($2)) {
- case NODE_LASGN:
- case NODE_DASGN: /* e.each {|internal_var| a = internal_var; ... } */
- $2->nd_value = internal_var;
- id = 0;
- m->nd_plen = 1;
- m->nd_next = $2;
- break;
- case NODE_MASGN: /* e.each {|*internal_var| a, b, c = (internal_var.length == 1 && Array === (tmp = internal_var[0]) ? tmp : internal_var); ... } */
- m->nd_next = node_assign(p, $2, NEW_FOR_MASGN(internal_var, &@2), NO_LEX_CTXT, &@2);
- break;
- default: /* e.each {|*internal_var| @a, B, c[1], d.attr = internal_val; ... } */
- m->nd_next = node_assign(p, NEW_MASGN(NEW_LIST($2, &@2), 0, &@2), internal_var, NO_LEX_CTXT, &@2);
- }
- /* {|*internal_id| <m> = internal_id; ... } */
- args = new_args(p, m, 0, id, 0, new_args_tail(p, 0, 0, 0, &@2), &@2);
- scope = NEW_NODE(NODE_SCOPE, tbl, $5, args, &@$);
- $$ = NEW_FOR($4, scope, &@$);
- fixpos($$, $2);
- /*% %*/
- /*% ripper: for!($2, $4, $5) %*/
- }
- | k_class cpath superclass
- {
- if (p->ctxt.in_def) {
- YYLTYPE loc = code_loc_gen(&@1, &@2);
- yyerror1(&loc, "class definition in method body");
- }
- p->ctxt.in_class = 1;
- local_push(p, 0);
- }
- bodystmt
- k_end
- {
- /*%%%*/
- $$ = NEW_CLASS($2, $5, $3, &@$);
- nd_set_line($$->nd_body, @6.end_pos.lineno);
- set_line_body($5, @3.end_pos.lineno);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: class!($2, $3, $5) %*/
- local_pop(p);
- p->ctxt.in_class = $<ctxt>1.in_class;
- p->ctxt.shareable_constant_value = $<ctxt>1.shareable_constant_value;
- }
- | k_class tLSHFT expr
- {
- p->ctxt.in_def = 0;
- p->ctxt.in_class = 0;
- local_push(p, 0);
- }
- term
- bodystmt
- k_end
- {
- /*%%%*/
- $$ = NEW_SCLASS($3, $6, &@$);
- nd_set_line($$->nd_body, @7.end_pos.lineno);
- set_line_body($6, nd_line($3));
- fixpos($$, $3);
- /*% %*/
- /*% ripper: sclass!($3, $6) %*/
- local_pop(p);
- p->ctxt.in_def = $<ctxt>1.in_def;
- p->ctxt.in_class = $<ctxt>1.in_class;
- p->ctxt.shareable_constant_value = $<ctxt>1.shareable_constant_value;
- }
- | k_module cpath
- {
- if (p->ctxt.in_def) {
- YYLTYPE loc = code_loc_gen(&@1, &@2);
- yyerror1(&loc, "module definition in method body");
- }
- p->ctxt.in_class = 1;
- local_push(p, 0);
- }
- bodystmt
- k_end
- {
- /*%%%*/
- $$ = NEW_MODULE($2, $4, &@$);
- nd_set_line($$->nd_body, @5.end_pos.lineno);
- set_line_body($4, @2.end_pos.lineno);
- nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: module!($2, $4) %*/
- local_pop(p);
- p->ctxt.in_class = $<ctxt>1.in_class;
- p->ctxt.shareable_constant_value = $<ctxt>1.shareable_constant_value;
- }
- | defn_head
- f_arglist
- {
- /*%%%*/
- push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
- }
- bodystmt
- k_end
- {
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*% %*/
- /*% ripper: def!(get_value($1), $2, $4) %*/
- local_pop(p);
- }
- | defs_head
- f_arglist
- {
- /*%%%*/
- push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
- }
- bodystmt
- k_end
- {
- restore_defun(p, $<node>1->nd_defn);
- /*%%%*/
- $$ = set_defun_body(p, $1, $2, $4, &@$);
- /*%
- $1 = get_value($1);
- %*/
- /*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, $4) %*/
- local_pop(p);
- }
- | keyword_break
- {
- /*%%%*/
- $$ = NEW_BREAK(0, &@$);
- /*% %*/
- /*% ripper: break!(args_new!) %*/
- }
- | keyword_next
- {
- /*%%%*/
- $$ = NEW_NEXT(0, &@$);
- /*% %*/
- /*% ripper: next!(args_new!) %*/
- }
- | keyword_redo
- {
- /*%%%*/
- $$ = NEW_REDO(&@$);
- /*% %*/
- /*% ripper: redo! %*/
- }
- | keyword_retry
- {
- /*%%%*/
- $$ = NEW_RETRY(&@$);
- /*% %*/
- /*% ripper: retry! %*/
- }
;
-primary_value : primary
- {
- value_expr($1);
- $$ = $1;
+primary : inline_primary
+ | var_ref
+ | backref
+ | tFID[fid]
+ {
+ $$ = (NODE *)NEW_FCALL($fid, 0, &@$);
+ /*% ripper: method_add_arg!(fcall!($:fid), args_new!) %*/
+ }
+ | k_begin[kw]
+ {
+ CMDARG_PUSH(0);
+ }
+ bodystmt[body]
+ k_end[k_end]
+ {
+ CMDARG_POP();
+ set_line_body($body, @kw.end_pos.lineno);
+ $$ = NEW_BEGIN($body, &@$);
+ nd_set_line($$, @kw.end_pos.lineno);
+ /*% ripper: begin!($:body) %*/
+ }
+ | tLPAREN_ARG compstmt(stmts)[body] {SET_LEX_STATE(EXPR_ENDARG);} ')'
+ {
+ if (nd_type_p($body, NODE_SELF)) RNODE_SELF($body)->nd_state = 0;
+ $$ = $body;
+ /*% ripper: paren!($:body) %*/
+ }
+ | tLPAREN compstmt(stmts)[body] ')'
+ {
+ if (nd_type_p($body, NODE_SELF)) RNODE_SELF($body)->nd_state = 0;
+ $$ = NEW_BLOCK($body, &@$);
+ /*% ripper: paren!($:body) %*/
+ }
+ | primary_value[recv] tCOLON2[op] tCONSTANT[name]
+ {
+ $$ = NEW_COLON2($recv, $name, &@$, &@op, &@name);
+ /*% ripper: const_path_ref!($:recv, $:name) %*/
+ }
+ | tCOLON3[top] tCONSTANT[name]
+ {
+ $$ = NEW_COLON3($name, &@$, &@top, &@name);
+ /*% ripper: top_const_ref!($:name) %*/
+ }
+ | tLBRACK aref_args[args] ']'
+ {
+ $$ = make_list($args, &@$);
+ /*% ripper: array!($:args) %*/
+ }
+ | tLBRACE assoc_list[list] '}'
+ {
+ $$ = new_hash(p, $list, &@$);
+ RNODE_HASH($$)->nd_brace = TRUE;
+ /*% ripper: hash!($:list) %*/
+ }
+ | k_return[kw]
+ {
+ $$ = NEW_RETURN(0, &@$, &@kw);
+ /*% ripper: return0! %*/
+ }
+ | k_yield[kw] '('[lpar] call_args[args] rparen[rpar]
+ {
+ $$ = NEW_YIELD($args, &@$, &@kw, &@lpar, &@rpar);
+ /*% ripper: yield!(paren!($:args)) %*/
+ }
+ | k_yield[kw] '('[lpar] rparen[rpar]
+ {
+ $$ = NEW_YIELD(0, &@$, &@kw, &@lpar, &@rpar);
+ /*% ripper: yield!(paren!(args_new!)) %*/
+ }
+ | k_yield[kw]
+ {
+ $$ = NEW_YIELD(0, &@$, &@kw, &NULL_LOC, &NULL_LOC);
+ /*% ripper: yield0! %*/
+ }
+ | keyword_defined[kw] '\n'? '(' begin_defined[ctxt] expr[arg] rparen
+ {
+ p->ctxt.in_defined = $ctxt.in_defined;
+ $$ = new_defined(p, $arg, &@$, &@kw);
+ p->ctxt.has_trailing_semicolon = $ctxt.has_trailing_semicolon;
+ /*% ripper: defined!($:arg) %*/
+ }
+ | keyword_not[kw] '(' expr[arg] rparen
+ {
+ $$ = call_uni_op(p, method_cond(p, $arg, &@arg), METHOD_NOT, &@kw, &@$);
+ /*% ripper: unary!(ID2VAL(idNOT), $:arg) %*/
+ }
+ | keyword_not[kw] '('[lpar] rparen
+ {
+ $$ = call_uni_op(p, method_cond(p, NEW_NIL(&@lpar), &@lpar), METHOD_NOT, &@kw, &@$);
+ /*% ripper: unary!(ID2VAL(idNOT), Qnil) %*/
+ }
+ | fcall[call] brace_block[block]
+ {
+ $$ = method_add_block(p, (NODE *)$call, $block, &@$);
+ /*% ripper: method_add_block!(method_add_arg!(fcall!($:call), args_new!), $:block) %*/
+ }
+ | method_call
+ | method_call[call] brace_block[block]
+ {
+ block_dup_check(p, get_nd_args(p, $call), $block);
+ $$ = method_add_block(p, $call, $block, &@$);
+ /*% ripper: method_add_block!($:call, $:block) %*/
+ }
+ | lambda
+ | k_if[kw] expr_value[cond] then[then]
+ compstmt(stmts)[body]
+ if_tail[tail]
+ k_end[k_end]
+ {
+ if ($tail && nd_type_p($tail, NODE_IF))
+ RNODE_IF($tail)->end_keyword_loc = @k_end;
+
+ $$ = new_if(p, $cond, $body, $tail, &@$, &@kw, &@then, &@k_end);
+ fixpos($$, $cond);
+ /*% ripper: if!($:cond, $:body, $:tail) %*/
+ }
+ | k_unless[kw] expr_value[cond] then[then]
+ compstmt(stmts)[body]
+ opt_else[tail]
+ k_end[k_end]
+ {
+ $$ = new_unless(p, $cond, $body, $tail, &@$, &@kw, &@then, &@k_end);
+ fixpos($$, $cond);
+ /*% ripper: unless!($:cond, $:body, $:tail) %*/
+ }
+ | k_while[kw] expr_value_do[cond]
+ compstmt(stmts)[body]
+ k_end[k_end]
+ {
+ restore_block_exit(p, $kw);
+ $$ = NEW_WHILE(cond(p, $cond, &@cond), $body, 1, &@$, &@kw, &@k_end);
+ fixpos($$, $cond);
+ /*% ripper: while!($:cond, $:body) %*/
+ }
+ | k_until[kw] expr_value_do[cond]
+ compstmt(stmts)[body]
+ k_end[k_end]
+ {
+ restore_block_exit(p, $kw);
+ $$ = NEW_UNTIL(cond(p, $cond, &@cond), $body, 1, &@$, &@kw, &@k_end);
+ fixpos($$, $cond);
+ /*% ripper: until!($:cond, $:body) %*/
+ }
+ | k_case[k_case] expr_value[expr] terms?
+ {
+ $$ = p->case_labels;
+ p->case_labels = CHECK_LITERAL_WHEN;
+ }[labels]<labels>
+ case_body[body]
+ k_end[k_end]
+ {
+ if (CASE_LABELS_ENABLED_P(p->case_labels)) st_free_table(p->case_labels);
+ p->case_labels = $labels;
+ $$ = NEW_CASE($expr, $body, &@$, &@k_case, &@k_end);
+ fixpos($$, $expr);
+ /*% ripper: case!($:expr, $:body) %*/
+ }
+ | k_case[k_case] terms?
+ {
+ $$ = p->case_labels;
+ p->case_labels = 0;
+ }[labels]<labels>
+ case_body[body]
+ k_end[k_end]
+ {
+ if (p->case_labels) st_free_table(p->case_labels);
+ p->case_labels = $labels;
+ $$ = NEW_CASE2($body, &@$, &@k_case, &@k_end);
+ /*% ripper: case!(Qnil, $:body) %*/
+ }
+ | k_case[k_case] expr_value[expr] terms?
+ p_case_body[body]
+ k_end[k_end]
+ {
+ $$ = NEW_CASE3($expr, $body, &@$, &@k_case, &@k_end);
+ /*% ripper: case!($:expr, $:body) %*/
+ }
+ | k_for[k_for] for_var[for_var] keyword_in[keyword_in]
+ {COND_PUSH(1);} expr_value[expr_value] do[do] {COND_POP();}
+ compstmt(stmts)[compstmt]
+ k_end[k_end]
+ {
+ restore_block_exit(p, $k_for);
+ /*
+ * 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(p);
+ rb_node_args_aux_t *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
+ rb_node_args_t *args;
+ NODE *scope, *internal_var = NEW_DVAR(id, &@for_var);
+ rb_ast_id_table_t *tbl = rb_ast_new_local_table(p->ast, 1);
+ tbl->ids[0] = id; /* internal id */
+
+ switch (nd_type($for_var)) {
+ case NODE_LASGN:
+ case NODE_DASGN: /* e.each {|internal_var| a = internal_var; ... } */
+ set_nd_value(p, $for_var, internal_var);
+ id = 0;
+ m->nd_plen = 1;
+ m->nd_next = $for_var;
+ break;
+ case NODE_MASGN: /* e.each {|*internal_var| a, b, c = (internal_var.length == 1 && Array === (tmp = internal_var[0]) ? tmp : internal_var); ... } */
+ m->nd_next = node_assign(p, $for_var, NEW_FOR_MASGN(internal_var, &@for_var), NO_LEX_CTXT, &@for_var);
+ break;
+ default: /* e.each {|*internal_var| @a, B, c[1], d.attr = internal_val; ... } */
+ m->nd_next = node_assign(p, (NODE *)NEW_MASGN(NEW_LIST($for_var, &@for_var), 0, &@for_var), internal_var, NO_LEX_CTXT, &@for_var);
+ }
+ /* {|*internal_id| <m> = internal_id; ... } */
+ args = new_args(p, m, 0, id, 0, new_empty_args_tail(p, &@for_var), &@for_var);
+ scope = NEW_SCOPE2(tbl, args, $compstmt, NULL, &@$);
+ YYLTYPE do_keyword_loc = $do == keyword_do_cond ? @do : NULL_LOC;
+ $$ = NEW_FOR($expr_value, scope, &@$, &@k_for, &@keyword_in, &do_keyword_loc, &@k_end);
+ RNODE_SCOPE(scope)->nd_parent = $$;
+ fixpos($$, $for_var);
+ /*% ripper: for!($:for_var, $:expr_value, $:compstmt) %*/
+ }
+ | k_class cpath superclass
+ {
+ begin_definition("class", &@k_class, &@cpath);
+ }
+ bodystmt
+ k_end
+ {
+ YYLTYPE inheritance_operator_loc = NULL_LOC;
+ if ($superclass) {
+ inheritance_operator_loc = @superclass;
+ inheritance_operator_loc.end_pos.column = inheritance_operator_loc.beg_pos.column + 1;
+ }
+ $$ = NEW_CLASS($cpath, $bodystmt, $superclass, &@$, &@k_class, &inheritance_operator_loc, &@k_end);
+ nd_set_line(RNODE_CLASS($$)->nd_body, @k_end.end_pos.lineno);
+ set_line_body($bodystmt, @superclass.end_pos.lineno);
+ nd_set_line($$, @superclass.end_pos.lineno);
+ /*% ripper: class!($:cpath, $:superclass, $:bodystmt) %*/
+ local_pop(p);
+ p->ctxt.in_class = $k_class.in_class;
+ p->ctxt.cant_return = $k_class.cant_return;
+ p->ctxt.shareable_constant_value = $k_class.shareable_constant_value;
+ }
+ | k_class tLSHFT expr_value
+ {
+ begin_definition("", &@k_class, &@tLSHFT);
+ }
+ term
+ bodystmt
+ k_end
+ {
+ $$ = NEW_SCLASS($expr_value, $bodystmt, &@$, &@k_class, &@tLSHFT, &@k_end);
+ nd_set_line(RNODE_SCLASS($$)->nd_body, @k_end.end_pos.lineno);
+ set_line_body($bodystmt, nd_line($expr_value));
+ fixpos($$, $expr_value);
+ /*% ripper: sclass!($:expr_value, $:bodystmt) %*/
+ local_pop(p);
+ p->ctxt.in_def = $k_class.in_def;
+ p->ctxt.in_class = $k_class.in_class;
+ p->ctxt.cant_return = $k_class.cant_return;
+ p->ctxt.shareable_constant_value = $k_class.shareable_constant_value;
+ }
+ | k_module cpath
+ {
+ begin_definition("module", &@k_module, &@cpath);
+ }
+ bodystmt
+ k_end
+ {
+ $$ = NEW_MODULE($cpath, $bodystmt, &@$, &@k_module, &@k_end);
+ nd_set_line(RNODE_MODULE($$)->nd_body, @k_end.end_pos.lineno);
+ set_line_body($bodystmt, @cpath.end_pos.lineno);
+ nd_set_line($$, @cpath.end_pos.lineno);
+ /*% ripper: module!($:cpath, $:bodystmt) %*/
+ local_pop(p);
+ p->ctxt.in_class = $k_module.in_class;
+ p->ctxt.cant_return = $k_module.cant_return;
+ p->ctxt.shareable_constant_value = $k_module.shareable_constant_value;
+ }
+ | defn_head[head]
+ f_arglist[args]
+ {
+ push_end_expect_token_locations(p, &@head.beg_pos);
+ }
+ bodystmt
+ k_end
+ {
+ restore_defun(p, $head);
+ ($$ = $head->nd_def)->nd_loc = @$;
+ $bodystmt = new_scope_body(p, $args, $bodystmt, $$, &@$);
+ RNODE_DEFN($$)->nd_defn = $bodystmt;
+ /*% ripper: def!($:head, $:args, $:bodystmt) %*/
+ local_pop(p);
+ }
+ | defs_head[head]
+ f_arglist[args]
+ {
+ push_end_expect_token_locations(p, &@head.beg_pos);
+ }
+ bodystmt
+ k_end
+ {
+ restore_defun(p, $head);
+ ($$ = $head->nd_def)->nd_loc = @$;
+ $bodystmt = new_scope_body(p, $args, $bodystmt, $$, &@$);
+ RNODE_DEFS($$)->nd_defn = $bodystmt;
+ /*% ripper: defs!(*$:head[0..2], $:args, $:bodystmt) %*/
+ local_pop(p);
+ }
+ | keyword_break[kw]
+ {
+ $$ = add_block_exit(p, NEW_BREAK(0, &@$, &@kw));
+ /*% ripper: break!(args_new!) %*/
+ }
+ | keyword_next[kw]
+ {
+ $$ = add_block_exit(p, NEW_NEXT(0, &@$, &@kw));
+ /*% ripper: next!(args_new!) %*/
+ }
+ | keyword_redo[kw]
+ {
+ $$ = add_block_exit(p, NEW_REDO(&@$, &@kw));
+ /*% ripper: redo! %*/
+ }
+ | keyword_retry[kw]
+ {
+ if (!p->ctxt.in_defined) {
+ switch (p->ctxt.in_rescue) {
+ case before_rescue: yyerror1(&@kw, "Invalid retry without rescue"); break;
+ case after_rescue: /* ok */ break;
+ case after_else: yyerror1(&@kw, "Invalid retry after else"); break;
+ case after_ensure: yyerror1(&@kw, "Invalid retry after ensure"); break;
+ }
}
+ $$ = NEW_RETRY(&@$);
+ /*% ripper: retry! %*/
+ }
+ ;
+
+primary_value : value_expr(primary)
;
k_begin : keyword_begin
{
token_info_push(p, "begin", &@$);
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
@@ -3628,80 +4738,70 @@ k_if : keyword_if
p->token_info->nonspc = 0;
}
}
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
k_unless : keyword_unless
{
token_info_push(p, "unless", &@$);
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
-k_while : keyword_while
+k_while : keyword_while[kw] allow_exits
{
+ $$ = $allow_exits;
token_info_push(p, "while", &@$);
- /*%%%*/
- push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
+ push_end_expect_token_locations(p, &@kw.beg_pos);
}
;
-k_until : keyword_until
+k_until : keyword_until[kw] allow_exits
{
+ $$ = $allow_exits;
token_info_push(p, "until", &@$);
- /*%%%*/
- push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
+ push_end_expect_token_locations(p, &@kw.beg_pos);
}
;
k_case : keyword_case
{
token_info_push(p, "case", &@$);
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
-k_for : keyword_for
+k_for : keyword_for[kw] allow_exits
{
+ $$ = $allow_exits;
token_info_push(p, "for", &@$);
- /*%%%*/
- push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
+ push_end_expect_token_locations(p, &@kw.beg_pos);
}
;
k_class : keyword_class
{
token_info_push(p, "class", &@$);
- $<ctxt>$ = p->ctxt;
- /*%%%*/
+ $$ = p->ctxt;
+ p->ctxt.in_rescue = before_rescue;
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
k_module : keyword_module
{
token_info_push(p, "module", &@$);
- $<ctxt>$ = p->ctxt;
- /*%%%*/
+ $$ = p->ctxt;
+ p->ctxt.in_rescue = before_rescue;
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
k_def : keyword_def
{
token_info_push(p, "def", &@$);
+ $$ = NEW_DEF_TEMP(&@$);
p->ctxt.in_argdef = 1;
}
;
@@ -3709,31 +4809,29 @@ k_def : keyword_def
k_do : keyword_do
{
token_info_push(p, "do", &@$);
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
-
}
;
k_do_block : keyword_do_block
{
token_info_push(p, "do", &@$);
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
;
k_rescue : keyword_rescue
{
token_info_warn(p, "rescue", p->token_info, 1, &@$);
+ $$ = p->ctxt;
+ p->ctxt.in_rescue = after_rescue;
}
;
k_ensure : keyword_ensure
{
token_info_warn(p, "ensure", p->token_info, 1, &@$);
+ $$ = p->ctxt;
}
;
@@ -3768,9 +4866,7 @@ k_elsif : keyword_elsif
k_end : keyword_end
{
token_info_pop(p, "end", &@$);
- /*%%%*/
pop_end_expect_token_locations(p);
- /*% %*/
}
| tDUMNY_END
{
@@ -3780,40 +4876,43 @@ k_end : keyword_end
k_return : keyword_return
{
- if (p->ctxt.in_class && !p->ctxt.in_def && !dyna_in_block(p))
+ if (p->ctxt.cant_return && !dyna_in_block(p))
yyerror1(&@1, "Invalid return in class/module body");
}
;
+k_yield : keyword_yield
+ {
+ if (!p->ctxt.in_defined && !p->ctxt.in_def && !compile_for_eval)
+ yyerror1(&@1, "Invalid yield");
+ }
+ ;
+
then : term
| keyword_then
| term keyword_then
;
do : term
- | keyword_do_cond
+ | keyword_do_cond { $$ = keyword_do_cond; }
;
if_tail : opt_else
| k_elsif expr_value then
- compstmt
+ compstmt(stmts)
if_tail
{
- /*%%%*/
- $$ = new_if(p, $2, $4, $5, &@$);
+ $$ = new_if(p, $2, $4, $5, &@$, &@1, &@3, &NULL_LOC);
fixpos($$, $2);
- /*% %*/
- /*% ripper: elsif!($2, $4, escape_Qundef($5)) %*/
+ /*% ripper: elsif!($:2, $:4, $:5) %*/
}
;
opt_else : none
- | k_else compstmt
+ | k_else compstmt(stmts)
{
- /*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: else!($2) %*/
+ /*% ripper: else!($:2) %*/
}
;
@@ -3823,562 +4922,417 @@ for_var : lhs
f_marg : f_norm_arg
{
- /*%%%*/
$$ = assignable(p, $1, 0, &@$);
mark_lvar_used(p, $$);
- /*% %*/
- /*% ripper: assignable(p, $1) %*/
}
| tLPAREN f_margs rparen
{
- /*%%%*/
- $$ = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ $$ = (NODE *)$2;
+ /*% ripper: mlhs_paren!($:2) %*/
}
;
-f_marg_list : f_marg
- {
- /*%%%*/
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: mlhs_add!(mlhs_new!, $1) %*/
- }
- | f_marg_list ',' f_marg
- {
- /*%%%*/
- $$ = list_append(p, $1, $3);
- /*% %*/
- /*% ripper: mlhs_add!($1, $3) %*/
- }
- ;
-f_margs : f_marg_list
+f_margs : mlhs_items(f_marg)
{
- /*%%%*/
$$ = NEW_MASGN($1, 0, &@$);
- /*% %*/
- /*% ripper: $1 %*/
+ /*% ripper: $:1 %*/
}
- | f_marg_list ',' f_rest_marg
+ | mlhs_items(f_marg) ',' f_rest_marg
{
- /*%%%*/
$$ = NEW_MASGN($1, $3, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!($1, $3) %*/
+ /*% ripper: mlhs_add_star!($:1, $:3) %*/
}
- | f_marg_list ',' f_rest_marg ',' f_marg_list
+ | mlhs_items(f_marg) ',' f_rest_marg ',' mlhs_items(f_marg)
{
- /*%%%*/
$$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!($1, $3), $5) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/
}
| f_rest_marg
{
- /*%%%*/
$$ = NEW_MASGN(0, $1, &@$);
- /*% %*/
- /*% ripper: mlhs_add_star!(mlhs_new!, $1) %*/
+ /*% ripper: mlhs_add_star!(mlhs_new!, $:1) %*/
}
- | f_rest_marg ',' f_marg_list
+ | f_rest_marg ',' mlhs_items(f_marg)
{
- /*%%%*/
$$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $1), $3) %*/
+ /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/
}
;
f_rest_marg : tSTAR f_norm_arg
{
- /*%%%*/
+ /*% ripper: $:2 %*/
$$ = assignable(p, $2, 0, &@$);
mark_lvar_used(p, $$);
- /*% %*/
- /*% ripper: assignable(p, $2) %*/
}
| tSTAR
{
- /*%%%*/
$$ = NODE_SPECIAL_NO_NAME_REST;
- /*% %*/
/*% ripper: Qnil %*/
}
;
f_any_kwrest : f_kwrest
- | f_no_kwarg {$$ = ID2VAL(idNil);}
- ;
-
-f_eq : {p->ctxt.in_argdef = 0;} '=';
-
-block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg
+ | f_no_kwarg
{
- $$ = new_args_tail(p, $1, $3, $4, &@3);
- }
- | f_block_kwarg opt_f_block_arg
- {
- $$ = new_args_tail(p, $1, Qnone, $2, &@1);
- }
- | f_any_kwrest opt_f_block_arg
- {
- $$ = new_args_tail(p, Qnone, $1, $2, &@1);
- }
- | f_block_arg
- {
- $$ = new_args_tail(p, Qnone, Qnone, $1, &@1);
+ $$ = idNil;
+ /*% ripper: ID2VAL(idNil) %*/
}
;
-opt_block_args_tail : ',' block_args_tail
- {
- $$ = $2;
- }
- | /* none */
- {
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
- }
+f_eq : {p->ctxt.in_argdef = 0;} '=';
+
+block_args_tail : args_tail_basic(primary_value, none)
;
excessed_comma : ','
{
/* magic number for rest_id in iseq_set_arguments() */
- /*%%%*/
$$ = NODE_SPECIAL_EXCESSIVE_COMMA;
- /*% %*/
/*% ripper: excessed_comma! %*/
}
;
-block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
- {
- $$ = new_args(p, $1, $3, $5, Qnone, $6, &@$);
- }
- | f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
+block_param : args-list(primary_value, opt_args_tail(block_args_tail, none))
+ | f_arg[pre] excessed_comma
{
- $$ = new_args(p, $1, $3, $5, $7, $8, &@$);
+ $$ = new_empty_args_tail(p, &@excessed_comma);
+ $$ = new_args(p, $pre, 0, $excessed_comma, 0, $$, &@$);
+ /*% ripper: params!($:pre, Qnil, $:excessed_comma, Qnil, Qnil, Qnil, Qnil) %*/
}
- | f_arg ',' f_block_optarg opt_block_args_tail
+ | f_arg[pre] opt_args_tail(block_args_tail, none)[tail]
{
- $$ = new_args(p, $1, $3, Qnone, Qnone, $4, &@$);
- }
- | f_arg ',' f_block_optarg ',' f_arg opt_block_args_tail
- {
- $$ = new_args(p, $1, $3, Qnone, $5, $6, &@$);
- }
- | f_arg ',' f_rest_arg opt_block_args_tail
- {
- $$ = new_args(p, $1, Qnone, $3, Qnone, $4, &@$);
- }
- | f_arg excessed_comma
- {
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@2);
- $$ = new_args(p, $1, Qnone, $2, Qnone, $$, &@$);
- }
- | f_arg ',' f_rest_arg ',' f_arg opt_block_args_tail
- {
- $$ = new_args(p, $1, Qnone, $3, $5, $6, &@$);
- }
- | f_arg opt_block_args_tail
- {
- $$ = new_args(p, $1, Qnone, Qnone, Qnone, $2, &@$);
- }
- | f_block_optarg ',' f_rest_arg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, $1, $3, Qnone, $4, &@$);
- }
- | f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, $1, $3, $5, $6, &@$);
- }
- | f_block_optarg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, $1, Qnone, Qnone, $2, &@$);
- }
- | f_block_optarg ',' f_arg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, $1, Qnone, $3, $4, &@$);
- }
- | f_rest_arg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, Qnone, $1, Qnone, $2, &@$);
- }
- | f_rest_arg ',' f_arg opt_block_args_tail
- {
- $$ = new_args(p, Qnone, Qnone, $1, $3, $4, &@$);
- }
- | block_args_tail
- {
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $1, &@$);
+ $$ = new_args(p, $pre, 0, 0, 0, $tail, &@$);
+ /*% ripper: params!($:pre, Qnil, Qnil, Qnil, *$:tail[0..2]) %*/
}
+ | tail-only-args(block_args_tail)
;
-opt_block_param : none
- | block_param_def
- {
- p->command_start = TRUE;
- }
- ;
+opt_block_param_def : none
+ | block_param_def
+ {
+ p->command_start = TRUE;
+ }
+ ;
-block_param_def : '|' opt_bv_decl '|'
+block_param_def : '|' opt_block_param opt_bv_decl '|'
{
- p->cur_arg = 0;
p->max_numparam = ORDINAL_PARAM;
p->ctxt.in_argdef = 0;
- /*%%%*/
- $$ = 0;
- /*% %*/
- /*% ripper: block_var!(params!(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil,Qnil), escape_Qundef($2)) %*/
- }
- | '|' block_param opt_bv_decl '|'
- {
- p->cur_arg = 0;
- p->max_numparam = ORDINAL_PARAM;
- p->ctxt.in_argdef = 0;
- /*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: block_var!(escape_Qundef($2), escape_Qundef($3)) %*/
+ /*% ripper: block_var!($:2, $:3) %*/
}
;
+opt_block_param : /* none */
+ {
+ $$ = 0;
+ /*% ripper: params!(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil,Qnil) %*/
+ }
+ | block_param
+ ;
-opt_bv_decl : opt_nl
+opt_bv_decl : '\n'?
{
$$ = 0;
+ /*% ripper: Qfalse %*/
}
- | opt_nl ';' bv_decls opt_nl
+ | '\n'? ';' bv_decls '\n'?
{
- /*%%%*/
$$ = 0;
- /*% %*/
- /*% ripper: $3 %*/
+ /*% ripper: $:3 %*/
}
;
bv_decls : bvar
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*% ripper[brace]: rb_ary_new3(1, $:1) %*/
| bv_decls ',' bvar
- /*% ripper[brace]: rb_ary_push($1, get_value($3)) %*/
+ /*% ripper[brace]: rb_ary_push($:1, $:3) %*/
;
bvar : tIDENTIFIER
{
- new_bv(p, get_id($1));
- /*% ripper: get_value($1) %*/
+ new_bv(p, $1);
+ /*% ripper: $:1 %*/
}
| f_bad_arg
- {
- $$ = 0;
+ ;
+
+max_numparam : {
+ $$ = p->max_numparam;
+ p->max_numparam = 0;
}
;
-lambda : tLAMBDA
- {
- token_info_push(p, "->", &@1);
- $<vars>1 = dyna_push(p);
- $<num>$ = p->lex.lpar_beg;
- p->lex.lpar_beg = p->lex.paren_nest;
+numparam : {
+ $$ = numparam_push(p);
}
- {
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
+ ;
+
+it_id : {
+ $$ = p->it_id;
+ p->it_id = 0;
}
+ ;
+
+lambda : tLAMBDA[lpar]
{
- $<node>$ = numparam_push(p);
- }
- f_larglist
+ token_info_push(p, "->", &@lpar);
+ $$ = dyna_push(p);
+ }[dyna]<vars>
+ max_numparam numparam it_id allow_exits
+ f_larglist[args]
{
CMDARG_PUSH(0);
}
- lambda_body
+ lambda_body[body]
{
int max_numparam = p->max_numparam;
- p->lex.lpar_beg = $<num>2;
- p->max_numparam = $<num>3;
+ ID it_id = p->it_id;
+ p->lex.lpar_beg = $lpar;
+ p->max_numparam = $max_numparam;
+ p->it_id = $it_id;
+ restore_block_exit(p, $allow_exits);
CMDARG_POP();
- $5 = args_with_numbered(p, $5, max_numparam);
- /*%%%*/
+ $args = args_with_numbered(p, $args, max_numparam, it_id);
{
- YYLTYPE loc = code_loc_gen(&@5, &@7);
- $$ = NEW_LAMBDA($5, $7, &loc);
- nd_set_line($$->nd_body, @7.end_pos.lineno);
- nd_set_line($$, @5.end_pos.lineno);
- nd_set_first_loc($$, @1.beg_pos);
+ YYLTYPE loc = code_loc_gen(&@lpar, &@body);
+ $$ = NEW_LAMBDA($args, $body->node, &loc, &@lpar, &$body->opening_loc, &$body->closing_loc);
+ nd_set_line(RNODE_LAMBDA($$)->nd_body, @body.end_pos.lineno);
+ nd_set_line($$, @args.end_pos.lineno);
+ nd_set_first_loc($$, @lpar.beg_pos);
+ xfree($body);
}
- /*% %*/
- /*% ripper: lambda!($5, $7) %*/
- numparam_pop(p, $<node>4);
- dyna_pop(p, $<vars>1);
+ /*% ripper: lambda!($:args, $:body) %*/
+ numparam_pop(p, $numparam);
+ dyna_pop(p, $dyna);
}
;
-f_larglist : '(' f_args opt_bv_decl ')'
+f_larglist : '(' f_largs[args] opt_bv_decl ')'
{
p->ctxt.in_argdef = 0;
- /*%%%*/
- $$ = $2;
+ $$ = $args;
p->max_numparam = ORDINAL_PARAM;
- /*% %*/
- /*% ripper: paren!($2) %*/
+ /*% ripper: paren!($:args) %*/
}
- | f_args
+ | f_largs[args]
{
p->ctxt.in_argdef = 0;
- /*%%%*/
- if (!args_info_empty_p($1->nd_ainfo))
+ if (!args_info_empty_p(&$args->nd_ainfo))
p->max_numparam = ORDINAL_PARAM;
- /*% %*/
- $$ = $1;
+ $$ = $args;
}
;
-lambda_body : tLAMBEG compstmt '}'
+lambda_body : tLAMBEG compstmt(stmts) '}'
{
token_info_pop(p, "}", &@3);
- $$ = $2;
+ $$ = new_locations_lambda_body(p, $2, &@2, &@1, &@3);
+ /*% ripper: $:2 %*/
}
| keyword_do_LAMBDA
{
- /*%%%*/
push_end_expect_token_locations(p, &@1.beg_pos);
- /*% %*/
}
bodystmt k_end
{
- $$ = $3;
+ $$ = new_locations_lambda_body(p, $3, &@3, &@1, &@4);
+ /*% ripper: $:3 %*/
}
;
do_block : k_do_block do_body k_end
{
$$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
+ set_embraced_location($$, &@1, &@3);
+ /*% ripper: $:2 %*/
}
;
block_call : command do_block
{
- /*%%%*/
if (nd_type_p($1, NODE_YIELD)) {
compile_error(p, "block given to yield");
}
else {
- block_dup_check(p, $1->nd_args, $2);
+ block_dup_check(p, get_nd_args(p, $1), $2);
}
$$ = method_add_block(p, $1, $2, &@$);
fixpos($$, $1);
- /*% %*/
- /*% ripper: method_add_block!($1, $2) %*/
+ /*% ripper: method_add_block!($:1, $:2) %*/
}
| block_call call_op2 operation2 opt_paren_args
{
- /*%%%*/
+ bool has_args = $4 != 0;
+ if (NODE_EMPTY_ARGS_P($4)) $4 = 0;
$$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
- /*% %*/
- /*% ripper: opt_event(:method_add_arg!, call!($1, $2, $3), $4) %*/
+ /*% ripper: call!($:1, $:2, $:3) %*/
+ if (has_args) {
+ /*% ripper: method_add_arg!($:$, $:4) %*/
+ }
}
| block_call call_op2 operation2 opt_paren_args brace_block
{
- /*%%%*/
+ if (NODE_EMPTY_ARGS_P($4)) $4 = 0;
$$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: opt_event(:method_add_block!, command_call!($1, $2, $3, $4), $5) %*/
+ /*% ripper: method_add_block!(command_call!($:1, $:2, $:3, $:4), $:5) %*/
}
| block_call call_op2 operation2 command_args do_block
{
- /*%%%*/
$$ = new_command_qcall(p, $2, $1, $3, $4, $5, &@3, &@$);
- /*% %*/
- /*% ripper: method_add_block!(command_call!($1, $2, $3, $4), $5) %*/
+ /*% ripper: method_add_block!(command_call!($:1, $:2, $:3, $:4), $:5) %*/
+ }
+ | block_call call_op2 paren_args
+ {
+ $$ = new_qcall(p, $2, $1, idCall, $3, &@2, &@$);
+ nd_set_line($$, @2.end_pos.lineno);
+ /*% ripper: method_add_arg!(call!($:1, $:2, ID2VAL(idCall)), $:3) %*/
}
;
method_call : fcall paren_args
{
- /*%%%*/
- $$ = $1;
- $$->nd_args = $2;
+ $1->nd_args = $2;
+ $$ = (NODE *)$1;
nd_set_last_loc($1, @2.end_pos);
- /*% %*/
- /*% ripper: method_add_arg!(fcall!($1), $2) %*/
+ /*% ripper: method_add_arg!(fcall!($:1), $:2) %*/
}
| primary_value call_op operation2 opt_paren_args
{
- /*%%%*/
+ bool has_args = $4 != 0;
+ if (NODE_EMPTY_ARGS_P($4)) $4 = 0;
$$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$);
nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: opt_event(:method_add_arg!, call!($1, $2, $3), $4) %*/
+ /*% ripper: call!($:1, $:2, $:3) %*/
+ if (has_args) {
+ /*% ripper: method_add_arg!($:$, $:4) %*/
+ }
}
| primary_value tCOLON2 operation2 paren_args
{
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, &@3, &@$);
+ $$ = new_qcall(p, idCOLON2, $1, $3, $4, &@3, &@$);
nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), $3), $4) %*/
+ /*% ripper: method_add_arg!(call!($:1, $:2, $:3), $:4) %*/
}
| primary_value tCOLON2 operation3
{
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, Qnull, &@3, &@$);
- /*% %*/
- /*% ripper: call!($1, ID2VAL(idCOLON2), $3) %*/
+ $$ = new_qcall(p, idCOLON2, $1, $3, 0, &@3, &@$);
+ /*% ripper: call!($:1, $:2, $:3) %*/
}
- | primary_value call_op paren_args
+ | primary_value call_op2 paren_args
{
- /*%%%*/
- $$ = new_qcall(p, $2, $1, ID2VAL(idCall), $3, &@2, &@$);
+ $$ = new_qcall(p, $2, $1, idCall, $3, &@2, &@$);
nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, $2, ID2VAL(idCall)), $3) %*/
- }
- | primary_value tCOLON2 paren_args
- {
- /*%%%*/
- $$ = new_qcall(p, ID2VAL(idCOLON2), $1, ID2VAL(idCall), $3, &@2, &@$);
- nd_set_line($$, @2.end_pos.lineno);
- /*% %*/
- /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), ID2VAL(idCall)), $3) %*/
+ /*% ripper: method_add_arg!(call!($:1, $:2, ID2VAL(idCall)), $:3) %*/
}
| keyword_super paren_args
{
- /*%%%*/
- $$ = NEW_SUPER($2, &@$);
- /*% %*/
- /*% ripper: super!($2) %*/
+ rb_code_location_t lparen_loc = @2;
+ rb_code_location_t rparen_loc = @2;
+ lparen_loc.end_pos.column = lparen_loc.beg_pos.column + 1;
+ rparen_loc.beg_pos.column = rparen_loc.end_pos.column - 1;
+
+ $$ = NEW_SUPER($2, &@$, &@1, &lparen_loc, &rparen_loc);
+ /*% ripper: super!($:2) %*/
}
| keyword_super
{
- /*%%%*/
$$ = NEW_ZSUPER(&@$);
- /*% %*/
/*% ripper: zsuper! %*/
}
| primary_value '[' opt_call_args rbracket
{
- /*%%%*/
- if ($1 && nd_type_p($1, NODE_SELF))
- $$ = NEW_FCALL(tAREF, $3, &@$);
- else
- $$ = NEW_CALL($1, tAREF, $3, &@$);
+ $$ = NEW_CALL($1, tAREF, $3, &@$);
fixpos($$, $1);
- /*% %*/
- /*% ripper: aref!($1, escape_Qundef($3)) %*/
+ /*% ripper: aref!($:1, $:3) %*/
}
;
brace_block : '{' brace_body '}'
{
$$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
+ set_embraced_location($$, &@1, &@3);
+ /*% ripper: $:2 %*/
}
| k_do do_body k_end
{
$$ = $2;
- /*%%%*/
- $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
- nd_set_line($$, @1.end_pos.lineno);
- /*% %*/
+ set_embraced_location($$, &@1, &@3);
+ /*% ripper: $:2 %*/
}
;
-brace_body : {$<vars>$ = dyna_push(p);}
- {
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
- }
- {
- $<node>$ = numparam_push(p);
- }
- opt_block_param compstmt
+brace_body : {$$ = dyna_push(p);}[dyna]<vars>
+ max_numparam numparam it_id allow_exits
+ opt_block_param_def[args] compstmt(stmts)
{
int max_numparam = p->max_numparam;
- p->max_numparam = $<num>2;
- $4 = args_with_numbered(p, $4, max_numparam);
- /*%%%*/
- $$ = NEW_ITER($4, $5, &@$);
- /*% %*/
- /*% ripper: brace_block!(escape_Qundef($4), $5) %*/
- numparam_pop(p, $<node>3);
- dyna_pop(p, $<vars>1);
+ ID it_id = p->it_id;
+ p->max_numparam = $max_numparam;
+ p->it_id = $it_id;
+ $args = args_with_numbered(p, $args, max_numparam, it_id);
+ $$ = NEW_ITER($args, $compstmt, &@$);
+ /*% ripper: brace_block!($:args, $:compstmt) %*/
+ restore_block_exit(p, $allow_exits);
+ numparam_pop(p, $numparam);
+ dyna_pop(p, $dyna);
}
;
-do_body : {$<vars>$ = dyna_push(p);}
- {
- $<num>$ = p->max_numparam;
- p->max_numparam = 0;
- }
- {
- $<node>$ = numparam_push(p);
+do_body : {
+ $$ = dyna_push(p);
CMDARG_PUSH(0);
- }
- opt_block_param bodystmt
+ }[dyna]<vars>
+ max_numparam numparam it_id allow_exits
+ opt_block_param_def[args] bodystmt
{
int max_numparam = p->max_numparam;
- p->max_numparam = $<num>2;
- $4 = args_with_numbered(p, $4, max_numparam);
- /*%%%*/
- $$ = NEW_ITER($4, $5, &@$);
- /*% %*/
- /*% ripper: do_block!(escape_Qundef($4), $5) %*/
+ ID it_id = p->it_id;
+ p->max_numparam = $max_numparam;
+ p->it_id = $it_id;
+ $args = args_with_numbered(p, $args, max_numparam, it_id);
+ $$ = NEW_ITER($args, $bodystmt, &@$);
+ /*% ripper: do_block!($:args, $:bodystmt) %*/
CMDARG_POP();
- numparam_pop(p, $<node>3);
- dyna_pop(p, $<vars>1);
+ restore_block_exit(p, $allow_exits);
+ numparam_pop(p, $numparam);
+ dyna_pop(p, $dyna);
}
;
case_args : arg_value
{
- /*%%%*/
- check_literal_when(p, $1, &@1);
- $$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: args_add!(args_new!, $1) %*/
+ check_literal_when(p, $arg_value, &@arg_value);
+ $$ = NEW_LIST($arg_value, &@$);
+ /*% ripper: args_add!(args_new!, $:arg_value) %*/
}
| tSTAR arg_value
{
- /*%%%*/
- $$ = NEW_SPLAT($2, &@$);
- /*% %*/
- /*% ripper: args_add_star!(args_new!, $2) %*/
+ $$ = NEW_SPLAT($arg_value, &@$, &@tSTAR);
+ /*% ripper: args_add_star!(args_new!, $:arg_value) %*/
}
- | case_args ',' arg_value
+ | case_args[non_last_args] ',' arg_value
{
- /*%%%*/
- check_literal_when(p, $3, &@3);
- $$ = last_arg_append(p, $1, $3, &@$);
- /*% %*/
- /*% ripper: args_add!($1, $3) %*/
+ check_literal_when(p, $arg_value, &@arg_value);
+ $$ = last_arg_append(p, $non_last_args, $arg_value, &@$);
+ /*% ripper: args_add!($:non_last_args, $:arg_value) %*/
}
- | case_args ',' tSTAR arg_value
+ | case_args[non_last_args] ',' tSTAR arg_value
{
- /*%%%*/
- $$ = rest_arg_append(p, $1, $4, &@$);
- /*% %*/
- /*% ripper: args_add_star!($1, $4) %*/
+ $$ = rest_arg_append(p, $non_last_args, $arg_value, &@$);
+ /*% ripper: args_add_star!($:non_last_args, $:arg_value) %*/
}
;
case_body : k_when case_args then
- compstmt
+ compstmt(stmts)
cases
{
- /*%%%*/
- $$ = NEW_WHEN($2, $4, $5, &@$);
+ $$ = NEW_WHEN($2, $4, $5, &@$, &@1, &@3);
fixpos($$, $2);
- /*% %*/
- /*% ripper: when!($2, $4, escape_Qundef($5)) %*/
+ /*% ripper: when!($:2, $:4, $:5) %*/
}
;
@@ -4386,30 +5340,34 @@ cases : opt_else
| case_body
;
-p_case_body : keyword_in
- {
+p_pvtbl : {$$ = p->pvtbl; p->pvtbl = st_init_numtable();};
+p_pktbl : {$$ = p->pktbl; p->pktbl = 0;};
+
+p_in_kwarg : {
+ $$ = p->ctxt;
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p->command_start = FALSE;
- $<ctxt>1 = p->ctxt;
p->ctxt.in_kwarg = 1;
- $<tbl>$ = push_pvtbl(p);
+ p->ctxt.in_alt_pattern = 0;
+ p->ctxt.capture_in_pattern = 0;
}
+ ;
+
+p_case_body : keyword_in
+ p_in_kwarg[ctxt] p_pvtbl p_pktbl
+ p_top_expr[expr] then
{
- $<tbl>$ = push_pktbl(p);
- }
- p_top_expr then
- {
- pop_pktbl(p, $<tbl>3);
- pop_pvtbl(p, $<tbl>2);
- p->ctxt.in_kwarg = $<ctxt>1.in_kwarg;
+ pop_pktbl(p, $p_pktbl);
+ pop_pvtbl(p, $p_pvtbl);
+ p->ctxt.in_kwarg = $ctxt.in_kwarg;
+ p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
+ p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
}
- compstmt
- p_cases
+ compstmt(stmts)
+ p_cases[cases]
{
- /*%%%*/
- $$ = NEW_IN($4, $7, $8, &@$);
- /*% %*/
- /*% ripper: in!($4, $7, escape_Qundef($8)) %*/
+ $$ = NEW_IN($expr, $compstmt, $cases, &@$, &@keyword_in, &@then, &NULL_LOC);
+ /*% ripper: in!($:expr, $:compstmt, $:cases) %*/
}
;
@@ -4420,47 +5378,45 @@ p_cases : opt_else
p_top_expr : p_top_expr_body
| p_top_expr_body modifier_if expr_value
{
- /*%%%*/
- $$ = new_if(p, $3, $1, 0, &@$);
+ $$ = new_if(p, $3, $1, 0, &@$, &@2, &NULL_LOC, &NULL_LOC);
fixpos($$, $3);
- /*% %*/
- /*% ripper: if_mod!($3, $1) %*/
+ /*% ripper: if_mod!($:3, $:1) %*/
}
| p_top_expr_body modifier_unless expr_value
{
- /*%%%*/
- $$ = new_unless(p, $3, $1, 0, &@$);
+ $$ = new_unless(p, $3, $1, 0, &@$, &@2, &NULL_LOC, &NULL_LOC);
fixpos($$, $3);
- /*% %*/
- /*% ripper: unless_mod!($3, $1) %*/
+ /*% ripper: unless_mod!($:3, $:1) %*/
}
;
p_top_expr_body : p_expr
| p_expr ','
{
- $$ = new_array_pattern_tail(p, Qnone, 1, 0, Qnone, &@$);
- $$ = new_array_pattern(p, Qnone, get_value($1), $$, &@$);
+ $$ = new_array_pattern_tail(p, 0, 1, 0, 0, &@$);
+ $$ = new_array_pattern(p, 0, $1, $$, &@$);
+ /*% ripper: aryptn!(Qnil, [$:1], Qnil, Qnil) %*/
}
| p_expr ',' p_args
{
- $$ = new_array_pattern(p, Qnone, get_value($1), $3, &@$);
- /*%%%*/
+ $$ = new_array_pattern(p, 0, $1, $3, &@$);
nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ /*% ripper: aryptn!(Qnil, aryptn_pre_args(p, $:1, $:3[0]), *$:3[1..2]) %*/
}
| p_find
{
- $$ = new_find_pattern(p, Qnone, $1, &@$);
+ $$ = new_find_pattern(p, 0, $1, &@$);
+ /*% ripper: fndptn!(Qnil, *$:1[0..2]) %*/
}
| p_args_tail
{
- $$ = new_array_pattern(p, Qnone, Qnone, $1, &@$);
+ $$ = new_array_pattern(p, 0, 0, $1, &@$);
+ /*% ripper: aryptn!(Qnil, *$:1[0..2]) %*/
}
| p_kwargs
{
- $$ = new_hash_pattern(p, Qnone, $1, &@$);
+ $$ = new_hash_pattern(p, 0, $1, &@$);
+ /*% ripper: hshptn!(Qnil, *$:1[0..1]) %*/
}
;
@@ -4469,272 +5425,272 @@ p_expr : p_as
p_as : p_expr tASSOC p_variable
{
- /*%%%*/
NODE *n = NEW_LIST($1, &@$);
n = list_append(p, n, $3);
$$ = new_hash(p, n, &@$);
- /*% %*/
- /*% ripper: binary!($1, STATIC_ID2SYM((id_assoc)), $3) %*/
+ /*% ripper: binary!($:1, ID2VAL((id_assoc)), $:3) %*/
}
| p_alt
;
-p_alt : p_alt '|' p_expr_basic
+p_alt : p_alt[left] '|'[alt]
{
- /*%%%*/
- $$ = NEW_NODE(NODE_OR, $1, $3, 0, &@$);
- /*% %*/
- /*% ripper: binary!($1, STATIC_ID2SYM(idOr), $3) %*/
+ p->ctxt.in_alt_pattern = 1;
+ }
+ p_expr_basic[right]
+ {
+ if (p->ctxt.capture_in_pattern) {
+ yyerror1(&@alt, "alternative pattern after variable capture");
+ }
+ p->ctxt.in_alt_pattern = 0;
+ $$ = NEW_OR($left, $right, &@$, &@alt);
+ /*% ripper: binary!($:left, ID2VAL(idOr), $:right) %*/
}
| p_expr_basic
;
-p_lparen : '(' {$<tbl>$ = push_pktbl(p);};
-p_lbracket : '[' {$<tbl>$ = push_pktbl(p);};
+p_lparen : '(' p_pktbl
+ {
+ $$ = $2;
+ /*% ripper: $:2 %*/
+ }
+ ;
+
+p_lbracket : '[' p_pktbl
+ {
+ $$ = $2;
+ /*% ripper: $:2 %*/
+ }
+ ;
p_expr_basic : p_value
| p_variable
- | p_const p_lparen p_args rparen
+ | p_const p_lparen[p_pktbl] p_args rparen
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_array_pattern(p, $1, Qnone, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_array_pattern(p, $p_const, 0, $p_args, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: aryptn!($:p_const, *$:p_args[0..2]) %*/
}
- | p_const p_lparen p_find rparen
+ | p_const p_lparen[p_pktbl] p_find rparen
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_find_pattern(p, $1, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_find_pattern(p, $p_const, $p_find, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: fndptn!($:p_const, *$:p_find[0..2]) %*/
}
- | p_const p_lparen p_kwargs rparen
+ | p_const p_lparen[p_pktbl] p_kwargs rparen
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_hash_pattern(p, $1, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_hash_pattern(p, $p_const, $p_kwargs, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: hshptn!($:p_const, *$:p_kwargs[0..1]) %*/
}
| p_const '(' rparen
{
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, $1, Qnone, $$, &@$);
+ $$ = new_array_pattern_tail(p, 0, 0, 0, 0, &@$);
+ $$ = new_array_pattern(p, $p_const, 0, $$, &@$);
+ /*% ripper: aryptn!($:p_const, Qnil, Qnil, Qnil) %*/
}
- | p_const p_lbracket p_args rbracket
+ | p_const p_lbracket[p_pktbl] p_args rbracket
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_array_pattern(p, $1, Qnone, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_array_pattern(p, $p_const, 0, $p_args, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: aryptn!($:p_const, *$:p_args[0..2]) %*/
}
- | p_const p_lbracket p_find rbracket
+ | p_const p_lbracket[p_pktbl] p_find rbracket
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_find_pattern(p, $1, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_find_pattern(p, $p_const, $p_find, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: fndptn!($:p_const, *$:p_find[0..2]) %*/
}
- | p_const p_lbracket p_kwargs rbracket
+ | p_const p_lbracket[p_pktbl] p_kwargs rbracket
{
- pop_pktbl(p, $<tbl>2);
- $$ = new_hash_pattern(p, $1, $3, &@$);
- /*%%%*/
- nd_set_first_loc($$, @1.beg_pos);
- /*%
- %*/
+ pop_pktbl(p, $p_pktbl);
+ $$ = new_hash_pattern(p, $p_const, $p_kwargs, &@$);
+ nd_set_first_loc($$, @p_const.beg_pos);
+ /*% ripper: hshptn!($:p_const, *$:p_kwargs[0..1]) %*/
}
| p_const '[' rbracket
{
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, $1, Qnone, $$, &@$);
+ $$ = new_array_pattern_tail(p, 0, 0, 0, 0, &@$);
+ $$ = new_array_pattern(p, $p_const, 0, $$, &@$);
+ /*% ripper: aryptn!($:p_const, Qnil, Qnil, Qnil) %*/
}
| tLBRACK p_args rbracket
{
- $$ = new_array_pattern(p, Qnone, Qnone, $2, &@$);
+ $$ = new_array_pattern(p, 0, 0, $p_args, &@$);
+ /*% ripper: aryptn!(Qnil, *$:p_args[0..2]) %*/
}
| tLBRACK p_find rbracket
{
- $$ = new_find_pattern(p, Qnone, $2, &@$);
+ $$ = new_find_pattern(p, 0, $p_find, &@$);
+ /*% ripper: fndptn!(Qnil, *$:p_find[0..2]) %*/
}
| tLBRACK rbracket
{
- $$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
- $$ = new_array_pattern(p, Qnone, Qnone, $$, &@$);
+ $$ = new_array_pattern_tail(p, 0, 0, 0, 0, &@$);
+ $$ = new_array_pattern(p, 0, 0, $$, &@$);
+ /*% ripper: aryptn!(Qnil, Qnil, Qnil, Qnil) %*/
}
- | tLBRACE
+ | tLBRACE p_pktbl lex_ctxt[ctxt]
{
- $<tbl>$ = push_pktbl(p);
- $<ctxt>1 = p->ctxt;
p->ctxt.in_kwarg = 0;
}
p_kwargs rbrace
{
- pop_pktbl(p, $<tbl>2);
- p->ctxt.in_kwarg = $<ctxt>1.in_kwarg;
- $$ = new_hash_pattern(p, Qnone, $3, &@$);
+ pop_pktbl(p, $p_pktbl);
+ p->ctxt.in_kwarg = $ctxt.in_kwarg;
+ $$ = new_hash_pattern(p, 0, $p_kwargs, &@$);
+ /*% ripper: hshptn!(Qnil, *$:p_kwargs[0..1]) %*/
}
| tLBRACE rbrace
{
- $$ = new_hash_pattern_tail(p, Qnone, 0, &@$);
- $$ = new_hash_pattern(p, Qnone, $$, &@$);
+ $$ = new_hash_pattern_tail(p, 0, 0, &@$);
+ $$ = new_hash_pattern(p, 0, $$, &@$);
+ /*% ripper: hshptn!(Qnil, Qnil, Qnil) %*/
}
- | tLPAREN {$<tbl>$ = push_pktbl(p);} p_expr rparen
+ | tLPAREN p_pktbl p_expr rparen
{
- pop_pktbl(p, $<tbl>2);
- $$ = $3;
+ pop_pktbl(p, $p_pktbl);
+ $$ = $p_expr;
+ /*% ripper: $:p_expr %*/
}
;
p_args : p_expr
{
- /*%%%*/
NODE *pre_args = NEW_LIST($1, &@$);
- $$ = new_array_pattern_tail(p, pre_args, 0, 0, Qnone, &@$);
- /*%
- $$ = new_array_pattern_tail(p, rb_ary_new_from_args(1, get_value($1)), 0, 0, Qnone, &@$);
- %*/
+ $$ = new_array_pattern_tail(p, pre_args, 0, 0, 0, &@$);
+ /*% ripper: [[$:1], Qnil, Qnil] %*/
}
| p_args_head
{
- $$ = new_array_pattern_tail(p, $1, 1, 0, Qnone, &@$);
+ $$ = new_array_pattern_tail(p, $1, 1, 0, 0, &@$);
+ /*% ripper: [$:1, Qnil, Qnil] %*/
}
| p_args_head p_arg
{
- /*%%%*/
- $$ = new_array_pattern_tail(p, list_concat($1, $2), 0, 0, Qnone, &@$);
- /*%
- VALUE pre_args = rb_ary_concat($1, get_value($2));
- $$ = new_array_pattern_tail(p, pre_args, 0, 0, Qnone, &@$);
- %*/
+ $$ = new_array_pattern_tail(p, list_concat($1, $2), 0, 0, 0, &@$);
+ /*% ripper: [rb_ary_concat($:1, $:2), Qnil, Qnil] %*/
}
| p_args_head p_rest
{
- $$ = new_array_pattern_tail(p, $1, 1, $2, Qnone, &@$);
+ $$ = new_array_pattern_tail(p, $1, 1, $2, 0, &@$);
+ /*% ripper: [$:1, $:2, Qnil] %*/
}
| p_args_head p_rest ',' p_args_post
{
$$ = new_array_pattern_tail(p, $1, 1, $2, $4, &@$);
+ /*% ripper: [$:1, $:2, $:4] %*/
}
| p_args_tail
;
p_args_head : p_arg ','
- {
- $$ = $1;
- }
| p_args_head p_arg ','
{
- /*%%%*/
$$ = list_concat($1, $2);
- /*% %*/
- /*% ripper: rb_ary_concat($1, get_value($2)) %*/
+ /*% ripper: rb_ary_concat($:1, $:2) %*/
}
;
p_args_tail : p_rest
{
- $$ = new_array_pattern_tail(p, Qnone, 1, $1, Qnone, &@$);
+ $$ = new_array_pattern_tail(p, 0, 1, $1, 0, &@$);
+ /*% ripper: [Qnil, $:1, Qnil] %*/
}
| p_rest ',' p_args_post
{
- $$ = new_array_pattern_tail(p, Qnone, 1, $1, $3, &@$);
+ $$ = new_array_pattern_tail(p, 0, 1, $1, $3, &@$);
+ /*% ripper: [Qnil, $:1, $:3] %*/
}
;
p_find : p_rest ',' p_args_post ',' p_rest
{
$$ = new_find_pattern_tail(p, $1, $3, $5, &@$);
+ /*% ripper: [$:1, $:3, $:5] %*/
}
;
p_rest : tSTAR tIDENTIFIER
{
- $$ = $2;
+ error_duplicate_pattern_variable(p, $2, &@2);
+ /*% ripper: var_field!($:2) %*/
+ $$ = assignable(p, $2, 0, &@$);
}
| tSTAR
{
$$ = 0;
+ /*% ripper: var_field!(Qnil) %*/
}
;
p_args_post : p_arg
| p_args_post ',' p_arg
{
- /*%%%*/
$$ = list_concat($1, $3);
- /*% %*/
- /*% ripper: rb_ary_concat($1, get_value($3)) %*/
+ /*% ripper: rb_ary_concat($:1, $:3) %*/
}
;
p_arg : p_expr
{
- /*%%%*/
$$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: rb_ary_new_from_args(1, get_value($1)) %*/
+ /*% ripper: [$:1] %*/
}
;
p_kwargs : p_kwarg ',' p_any_kwrest
{
$$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), $3, &@$);
+ /*% ripper: [$:1, $:3] %*/
}
| p_kwarg
{
$$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), 0, &@$);
+ /*% ripper: [$:1, Qnil] %*/
}
| p_kwarg ','
{
$$ = new_hash_pattern_tail(p, new_unique_key_hash(p, $1, &@$), 0, &@$);
+ /*% ripper: [$:1, Qnil] %*/
}
| p_any_kwrest
{
- $$ = new_hash_pattern_tail(p, new_hash(p, Qnone, &@$), $1, &@$);
+ $$ = new_hash_pattern_tail(p, new_hash(p, 0, &@$), $1, &@$);
+ /*% ripper: [[], $:1] %*/
}
;
p_kwarg : p_kw
- /*% ripper[brace]: rb_ary_new_from_args(1, $1) %*/
+ /*% ripper[brace]: [$:1] %*/
| p_kwarg ',' p_kw
{
- /*%%%*/
$$ = list_concat($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, $3) %*/
+ /*% ripper: rb_ary_push($:1, $:3) %*/
}
;
p_kw : p_kw_label p_expr
{
- error_duplicate_pattern_key(p, get_id($1), &@1);
- /*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@1), &@$), $2);
- /*% %*/
- /*% ripper: rb_ary_new_from_args(2, get_value($1), get_value($2)) %*/
+ error_duplicate_pattern_key(p, $1, &@1);
+ $$ = list_append(p, NEW_LIST(NEW_SYM(rb_id2str($1), &@1), &@$), $2);
+ /*% ripper: [$:1, $:2] %*/
}
| p_kw_label
{
- error_duplicate_pattern_key(p, get_id($1), &@1);
- if ($1 && !is_local_id(get_id($1))) {
+ error_duplicate_pattern_key(p, $1, &@1);
+ if ($1 && !is_local_id($1)) {
yyerror1(&@1, "key must be valid as local variables");
}
- error_duplicate_pattern_variable(p, get_id($1), &@1);
- /*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@$), &@$), assignable(p, $1, 0, &@$));
- /*% %*/
- /*% ripper: rb_ary_new_from_args(2, get_value($1), Qnil) %*/
+ error_duplicate_pattern_variable(p, $1, &@1);
+ $$ = list_append(p, NEW_LIST(NEW_SYM(rb_id2str($1), &@$), &@$), assignable(p, $1, 0, &@$));
+ /*% ripper: [$:1, Qnil] %*/
}
;
@@ -4742,33 +5698,27 @@ p_kw_label : tLABEL
| tSTRING_BEG string_contents tLABEL_END
{
YYLTYPE loc = code_loc_gen(&@1, &@3);
- /*%%%*/
if (!$2 || nd_type_p($2, NODE_STR)) {
NODE *node = dsym_node(p, $2, &loc);
- $$ = SYM2ID(node->nd_lit);
- }
- /*%
- if (ripper_is_node_yylval($2) && RNODE($2)->nd_cval) {
- VALUE label = RNODE($2)->nd_cval;
- VALUE rval = RNODE($2)->nd_rval;
- $$ = ripper_new_yylval(p, rb_intern_str(label), rval, label);
- RNODE($$)->nd_loc = loc;
+ $$ = rb_sym2id(rb_node_sym_string_val(node));
}
- %*/
else {
yyerror1(&loc, "symbol literal with interpolation is not allowed");
- $$ = 0;
+ $$ = rb_intern_str(STR_NEW0());
}
+ /*% ripper: $:2 %*/
}
;
p_kwrest : kwrest_mark tIDENTIFIER
{
$$ = $2;
+ /*% ripper: var_field!($:2) %*/
}
| kwrest_mark
{
$$ = 0;
+ /*% ripper: Qnil %*/
}
;
@@ -4779,154 +5729,90 @@ p_kwnorest : kwrest_mark keyword_nil
;
p_any_kwrest : p_kwrest
- | p_kwnorest {$$ = ID2VAL(idNil);}
+ | p_kwnorest
+ {
+ $$ = idNil;
+ /*% ripper: var_field!(ID2VAL(idNil)) %*/
+ }
;
p_value : p_primitive
- | p_primitive tDOT2 p_primitive
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT2($1, $3, &@$);
- /*% %*/
- /*% ripper: dot2!($1, $3) %*/
- }
- | p_primitive tDOT3 p_primitive
- {
- /*%%%*/
- value_expr($1);
- value_expr($3);
- $$ = NEW_DOT3($1, $3, &@$);
- /*% %*/
- /*% ripper: dot3!($1, $3) %*/
- }
- | p_primitive tDOT2
- {
- /*%%%*/
- value_expr($1);
- $$ = NEW_DOT2($1, new_nil_at(p, &@2.end_pos), &@$);
- /*% %*/
- /*% ripper: dot2!($1, Qnil) %*/
- }
- | p_primitive tDOT3
- {
- /*%%%*/
- value_expr($1);
- $$ = NEW_DOT3($1, new_nil_at(p, &@2.end_pos), &@$);
- /*% %*/
- /*% ripper: dot3!($1, Qnil) %*/
- }
+ | range_expr(p_primitive)
| p_var_ref
| p_expr_ref
| p_const
- | tBDOT2 p_primitive
- {
- /*%%%*/
- value_expr($2);
- $$ = NEW_DOT2(new_nil_at(p, &@1.beg_pos), $2, &@$);
- /*% %*/
- /*% ripper: dot2!(Qnil, $2) %*/
- }
- | tBDOT3 p_primitive
- {
- /*%%%*/
- value_expr($2);
- $$ = NEW_DOT3(new_nil_at(p, &@1.beg_pos), $2, &@$);
- /*% %*/
- /*% ripper: dot3!(Qnil, $2) %*/
- }
;
-p_primitive : literal
- | strings
- | xstring
- | regexp
- | words
- | qwords
- | symbols
- | qsymbols
+p_primitive : inline_primary
| keyword_variable
{
- /*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ if (!($$ = gettable(p, $1, &@$))) $$ = NEW_ERROR(&@$);
+ /*% ripper: var_ref!($:1) %*/
}
| lambda
;
p_variable : tIDENTIFIER
{
- /*%%%*/
error_duplicate_pattern_variable(p, $1, &@1);
+ /*% ripper: var_field!($:1) %*/
$$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
}
;
p_var_ref : '^' tIDENTIFIER
{
- /*%%%*/
NODE *n = gettable(p, $2, &@$);
- if (!(nd_type_p(n, NODE_LVAR) || nd_type_p(n, NODE_DVAR))) {
+ if (!n) {
+ n = NEW_ERROR(&@$);
+ }
+ else if (!(nd_type_p(n, NODE_LVAR) || nd_type_p(n, NODE_DVAR))) {
compile_error(p, "%"PRIsVALUE": no such local variable", rb_id2str($2));
}
$$ = n;
- /*% %*/
- /*% ripper: var_ref!($2) %*/
+ /*% ripper: var_ref!($:2) %*/
}
| '^' nonlocal_var
{
- /*%%%*/
- if (!($$ = gettable(p, $2, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: var_ref!($2) %*/
+ if (!($$ = gettable(p, $2, &@$))) $$ = NEW_ERROR(&@$);
+ /*% ripper: var_ref!($:2) %*/
}
;
p_expr_ref : '^' tLPAREN expr_value rparen
{
- /*%%%*/
- $$ = NEW_BEGIN($3, &@$);
- /*% %*/
- /*% ripper: begin!($3) %*/
+ $$ = NEW_BLOCK($3, &@$);
+ /*% ripper: begin!($:3) %*/
}
;
p_const : tCOLON3 cname
{
- /*%%%*/
- $$ = NEW_COLON3($2, &@$);
- /*% %*/
- /*% ripper: top_const_ref!($2) %*/
+ $$ = NEW_COLON3($2, &@$, &@1, &@2);
+ /*% ripper: top_const_ref!($:2) %*/
}
| p_const tCOLON2 cname
{
- /*%%%*/
- $$ = NEW_COLON2($1, $3, &@$);
- /*% %*/
- /*% ripper: const_path_ref!($1, $3) %*/
+ $$ = NEW_COLON2($1, $3, &@$, &@2, &@3);
+ /*% ripper: const_path_ref!($:1, $:3) %*/
}
| tCONSTANT
{
- /*%%%*/
$$ = gettable(p, $1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ /*% ripper: var_ref!($:1) %*/
}
;
opt_rescue : k_rescue exc_list exc_var then
- compstmt
+ compstmt(stmts)
opt_rescue
{
- /*%%%*/
- $$ = NEW_RESBODY($2,
- $3 ? block_append(p, node_assign(p, $3, NEW_ERRINFO(&@3), NO_LEX_CTXT, &@3), $5) : $5,
- $6, &@$);
-
+ NODE *err = $3;
+ if ($3) {
+ err = NEW_ERRINFO(&@3);
+ err = node_assign(p, $3, err, NO_LEX_CTXT, &@3);
+ }
+ $$ = NEW_RESBODY($2, $3, $5, $6, &@$);
if ($2) {
fixpos($$, $2);
}
@@ -4936,25 +5822,19 @@ opt_rescue : k_rescue exc_list exc_var then
else {
fixpos($$, $5);
}
- /*% %*/
- /*% ripper: rescue!(escape_Qundef($2), escape_Qundef($3), escape_Qundef($5), escape_Qundef($6)) %*/
+ /*% ripper: rescue!($:2, $:3, $:5, $:6) %*/
}
| none
;
exc_list : arg_value
{
- /*%%%*/
$$ = NEW_LIST($1, &@$);
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
+ /*% ripper: rb_ary_new3(1, $:1) %*/
}
| mrhs
{
- /*%%%*/
if (!($$ = splat_array($1))) $$ = $1;
- /*% %*/
- /*% ripper: $1 %*/
}
| none
;
@@ -4962,16 +5842,17 @@ exc_list : arg_value
exc_var : tASSOC lhs
{
$$ = $2;
+ /*% ripper: $:2 %*/
}
| none
;
-opt_ensure : k_ensure compstmt
+opt_ensure : k_ensure stmts terms?
{
- /*%%%*/
+ p->ctxt.in_rescue = $1.in_rescue;
$$ = $2;
- /*% %*/
- /*% ripper: ensure!($2) %*/
+ void_expr(p, void_stmts(p, $$));
+ /*% ripper: ensure!($:2) %*/
}
| none
;
@@ -4982,18 +5863,13 @@ literal : numeric
strings : string
{
- /*%%%*/
- NODE *node = $1;
- if (!node) {
- node = NEW_STR(STR_NEW0(), &@$);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
+ if (!$1) {
+ $$ = NEW_STR(STRING_NEW0(), &@$);
}
else {
- node = evstr2dstr(p, node);
+ $$ = evstr2dstr(p, $1);
}
- $$ = node;
- /*% %*/
- /*% ripper: $1 %*/
+ /*% ripper: $:1 %*/
}
;
@@ -5001,208 +5877,143 @@ string : tCHAR
| string1
| string string1
{
- /*%%%*/
$$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: string_concat!($1, $2) %*/
+ /*% ripper: string_concat!($:1, $:2) %*/
}
;
string1 : tSTRING_BEG string_contents tSTRING_END
{
- /*%%%*/
$$ = heredoc_dedent(p, $2);
if ($$) nd_set_loc($$, &@$);
- /*% %*/
- /*% ripper: string_literal!(heredoc_dedent(p, $2)) %*/
+ /*% ripper: $:2 %*/
+ if (p->heredoc_indent > 0) {
+ /*% ripper: heredoc_dedent!($:$, INT2NUM(%{p->heredoc_indent})) %*/
+ p->heredoc_indent = 0;
+ }
+ /*% ripper: string_literal!($:$) %*/
}
;
xstring : tXSTRING_BEG xstring_contents tSTRING_END
{
- /*%%%*/
$$ = new_xstring(p, heredoc_dedent(p, $2), &@$);
- /*% %*/
- /*% ripper: xstring_literal!(heredoc_dedent(p, $2)) %*/
+ /*% ripper: $:2 %*/
+ if (p->heredoc_indent > 0) {
+ /*% ripper: heredoc_dedent!($:$, INT2NUM(%{p->heredoc_indent})) %*/
+ p->heredoc_indent = 0;
+ }
+ /*% ripper: xstring_literal!($:$) %*/
}
;
regexp : tREGEXP_BEG regexp_contents tREGEXP_END
{
- $$ = new_regexp(p, $2, $3, &@$);
+ $$ = new_regexp(p, $2, $3, &@$, &@1, &@2, &@3);
+ /*% ripper: regexp_literal!($:2, $:3) %*/
}
;
-words : tWORDS_BEG ' ' word_list tSTRING_END
- {
- /*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
- }
+words : words(tWORDS_BEG, word_list)
;
word_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: words_new! %*/
}
- | word_list word ' '
+ | word_list word ' '+
{
- /*%%%*/
$$ = list_append(p, $1, evstr2dstr(p, $2));
- /*% %*/
- /*% ripper: words_add!($1, $2) %*/
+ /*% ripper: words_add!($:1, $:2) %*/
}
;
word : string_content
- /*% ripper[brace]: word_add!(word_new!, $1) %*/
+ /*% ripper[brace]: word_add!(word_new!, $:1) %*/
| word string_content
{
- /*%%%*/
$$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: word_add!($1, $2) %*/
+ /*% ripper: word_add!($:1, $:2) %*/
}
;
-symbols : tSYMBOLS_BEG ' ' symbol_list tSTRING_END
- {
- /*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
- }
+symbols : words(tSYMBOLS_BEG, symbol_list)
;
symbol_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: symbols_new! %*/
}
- | symbol_list word ' '
+ | symbol_list word ' '+
{
- /*%%%*/
$$ = symbol_append(p, $1, evstr2dstr(p, $2));
- /*% %*/
- /*% ripper: symbols_add!($1, $2) %*/
+ /*% ripper: symbols_add!($:1, $:2) %*/
}
;
-qwords : tQWORDS_BEG ' ' qword_list tSTRING_END
- {
- /*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
- }
+qwords : words(tQWORDS_BEG, qword_list)
;
-qsymbols : tQSYMBOLS_BEG ' ' qsym_list tSTRING_END
- {
- /*%%%*/
- $$ = make_list($3, &@$);
- /*% %*/
- /*% ripper: array!($3) %*/
- }
+qsymbols : words(tQSYMBOLS_BEG, qsym_list)
;
qword_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: qwords_new! %*/
}
- | qword_list tSTRING_CONTENT ' '
+ | qword_list tSTRING_CONTENT ' '+
{
- /*%%%*/
$$ = list_append(p, $1, $2);
- /*% %*/
- /*% ripper: qwords_add!($1, $2) %*/
+ /*% ripper: qwords_add!($:1, $:2) %*/
}
;
qsym_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: qsymbols_new! %*/
}
- | qsym_list tSTRING_CONTENT ' '
+ | qsym_list tSTRING_CONTENT ' '+
{
- /*%%%*/
$$ = symbol_append(p, $1, $2);
- /*% %*/
- /*% ripper: qsymbols_add!($1, $2) %*/
+ /*% ripper: qsymbols_add!($:1, $:2) %*/
}
;
-string_contents : /* none */
+string_contents : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: string_content! %*/
- /*%%%*/
- /*%
- $$ = ripper_new_yylval(p, 0, $$, 0);
- %*/
}
| string_contents string_content
{
- /*%%%*/
$$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: string_add!($1, $2) %*/
- /*%%%*/
- /*%
- if (ripper_is_node_yylval($1) && ripper_is_node_yylval($2) &&
- !RNODE($1)->nd_cval) {
- RNODE($1)->nd_cval = RNODE($2)->nd_cval;
- RNODE($1)->nd_rval = add_mark_object(p, $$);
- $$ = $1;
- }
- %*/
+ /*% ripper: string_add!($:1, $:2) %*/
}
;
xstring_contents: /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: xstring_new! %*/
}
| xstring_contents string_content
{
- /*%%%*/
$$ = literal_concat(p, $1, $2, &@$);
- /*% %*/
- /*% ripper: xstring_add!($1, $2) %*/
+ /*% ripper: xstring_add!($:1, $:2) %*/
}
;
-regexp_contents: /* none */
+regexp_contents : /* none */
{
- /*%%%*/
$$ = 0;
- /*% %*/
/*% ripper: regexp_new! %*/
- /*%%%*/
- /*%
- $$ = ripper_new_yylval(p, 0, $$, 0);
- %*/
}
| regexp_contents string_content
{
- /*%%%*/
NODE *head = $1, *tail = $2;
if (!head) {
$$ = tail;
@@ -5213,111 +6024,76 @@ regexp_contents: /* none */
else {
switch (nd_type(head)) {
case NODE_STR:
- nd_set_type(head, NODE_DSTR);
+ head = str2dstr(p, head);
break;
case NODE_DSTR:
break;
default:
- head = list_append(p, NEW_DSTR(Qnil, &@$), head);
+ head = list_append(p, NEW_DSTR(0, &@$), head);
break;
}
$$ = list_append(p, head, tail);
}
- /*%
- VALUE s1 = 1, s2 = 0, n1 = $1, n2 = $2;
- if (ripper_is_node_yylval(n1)) {
- s1 = RNODE(n1)->nd_cval;
- n1 = RNODE(n1)->nd_rval;
- }
- if (ripper_is_node_yylval(n2)) {
- s2 = RNODE(n2)->nd_cval;
- n2 = RNODE(n2)->nd_rval;
- }
- $$ = dispatch2(regexp_add, n1, n2);
- if (!s1 && s2) {
- $$ = ripper_new_yylval(p, 0, $$, s2);
- }
- %*/
+ /*% ripper: regexp_add!($:1, $:2) %*/
}
;
-string_content : tSTRING_CONTENT
- /*% ripper[brace]: ripper_new_yylval(p, 0, get_value($1), $1) %*/
- | tSTRING_DVAR
+string_content : tSTRING_CONTENT[content]
+ /*% ripper[brace]: $:content %*/
+ | tSTRING_DVAR[state]
{
/* need to backup p->lex.strterm so that a string literal `%&foo,#$&,bar&` can be parsed */
- $<strterm>$ = p->lex.strterm;
+ $$ = p->lex.strterm;
p->lex.strterm = 0;
SET_LEX_STATE(EXPR_BEG);
- }
- string_dvar
+ }[strterm]<strterm>
+ string_dvar[dvar]
{
- p->lex.strterm = $<strterm>2;
- /*%%%*/
- $$ = NEW_EVSTR($3, &@$);
- nd_set_line($$, @3.end_pos.lineno);
- /*% %*/
- /*% ripper: string_dvar!($3) %*/
+ p->lex.strterm = $strterm;
+ $$ = NEW_EVSTR($dvar, &@$, &@state, &NULL_LOC);
+ nd_set_line($$, @dvar.end_pos.lineno);
+ /*% ripper: string_dvar!($:dvar) %*/
}
- | tSTRING_DBEG
+ | tSTRING_DBEG[state]
{
CMDARG_PUSH(0);
COND_PUSH(0);
- }
- {
/* need to backup p->lex.strterm so that a string literal `%!foo,#{ !0 },bar!` can be parsed */
- $<strterm>$ = p->lex.strterm;
+ $$ = p->lex.strterm;
p->lex.strterm = 0;
- }
- {
- $<num>$ = p->lex.state;
SET_LEX_STATE(EXPR_BEG);
- }
+ }[term]<strterm>
{
- $<num>$ = p->lex.brace_nest;
+ $$ = p->lex.brace_nest;
p->lex.brace_nest = 0;
- }
+ }[brace]<num>
{
- $<num>$ = p->heredoc_indent;
+ $$ = p->heredoc_indent;
p->heredoc_indent = 0;
- }
- compstmt tSTRING_DEND
+ }[indent]<num>
+ compstmt(stmts) string_dend
{
COND_POP();
CMDARG_POP();
- p->lex.strterm = $<strterm>3;
- SET_LEX_STATE($<num>4);
- p->lex.brace_nest = $<num>5;
- p->heredoc_indent = $<num>6;
+ p->lex.strterm = $term;
+ SET_LEX_STATE($state);
+ p->lex.brace_nest = $brace;
+ p->heredoc_indent = $indent;
p->heredoc_line_indent = -1;
- /*%%%*/
- if ($7) $7->flags &= ~NODE_FL_NEWLINE;
- $$ = new_evstr(p, $7, &@$);
- /*% %*/
- /*% ripper: string_embexpr!($7) %*/
+ if ($compstmt) nd_unset_fl_newline($compstmt);
+ $$ = new_evstr(p, $compstmt, &@$, &@state, &@string_dend);
+ /*% ripper: string_embexpr!($:compstmt) %*/
}
;
-string_dvar : tGVAR
- {
- /*%%%*/
- $$ = NEW_GVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
- }
- | tIVAR
- {
- /*%%%*/
- $$ = NEW_IVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
- }
- | tCVAR
+string_dend : tSTRING_DEND
+ | END_OF_INPUT
+ ;
+
+string_dvar : nonlocal_var
{
- /*%%%*/
- $$ = NEW_CVAR($1, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ if (!($$ = gettable(p, $1, &@$))) $$ = NEW_ERROR(&@$);
+ /*% ripper: var_ref!($:1) %*/
}
| backref
;
@@ -5329,10 +6105,16 @@ symbol : ssym
ssym : tSYMBEG sym
{
SET_LEX_STATE(EXPR_END);
- /*%%%*/
- $$ = NEW_LIT(ID2SYM($2), &@$);
- /*% %*/
- /*% ripper: symbol_literal!(symbol!($2)) %*/
+ VALUE str = rb_id2str($2);
+ /*
+ * TODO:
+ * set_yylval_noname sets invalid id to yylval.
+ * This branch can be removed once yylval is changed to
+ * hold lexed string.
+ */
+ if (!str) str = STR_NEW0();
+ $$ = NEW_SYM(str, &@$);
+ /*% ripper: symbol_literal!(symbol!($:2)) %*/
}
;
@@ -5343,21 +6125,17 @@ sym : fname
dsym : tSYMBEG string_contents tSTRING_END
{
SET_LEX_STATE(EXPR_END);
- /*%%%*/
$$ = dsym_node(p, $2, &@$);
- /*% %*/
- /*% ripper: dyna_symbol!($2) %*/
+ /*% ripper: dyna_symbol!($:2) %*/
}
;
numeric : simple_numeric
| tUMINUS_NUM simple_numeric %prec tLOWEST
{
- /*%%%*/
$$ = $2;
- RB_OBJ_WRITE(p->ast, &$$->nd_lit, negate_lit(p, $$->nd_lit));
- /*% %*/
- /*% ripper: unary!(ID2VAL(idUMinus), $2) %*/
+ negate_lit(p, $$, &@$);
+ /*% ripper: unary!(ID2VAL(idUMinus), $:2) %*/
}
;
@@ -5367,13 +6145,12 @@ simple_numeric : tINTEGER
| tIMAGINARY
;
-nonlocal_var : tIVAR
+nonlocal_var : tIVAR
| tGVAR
| tCVAR
;
-user_variable : tIDENTIFIER
- | tCONSTANT
+user_variable : ident_or_const
| nonlocal_var
;
@@ -5388,39 +6165,25 @@ keyword_variable: keyword_nil {$$ = KWD2EID(nil, $1);}
var_ref : user_variable
{
- /*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*%
- if (id_is_var(p, get_id($1))) {
- $$ = dispatch1(var_ref, $1);
+ if (!($$ = gettable(p, $1, &@$))) $$ = NEW_ERROR(&@$);
+ if (ifdef_ripper(id_is_var(p, $1), false)) {
+ /*% ripper: var_ref!($:1) %*/
}
else {
- $$ = dispatch1(vcall, $1);
+ /*% ripper: vcall!($:1) %*/
}
- %*/
}
| keyword_variable
{
- /*%%%*/
- if (!($$ = gettable(p, $1, &@$))) $$ = NEW_BEGIN(0, &@$);
- /*% %*/
- /*% ripper: var_ref!($1) %*/
+ if (!($$ = gettable(p, $1, &@$))) $$ = NEW_ERROR(&@$);
+ /*% ripper: var_ref!($:1) %*/
}
;
-var_lhs : user_variable
+var_lhs : user_or_keyword_variable
{
- /*%%%*/
+ /*% ripper: var_field!($:1) %*/
$$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
- }
- | keyword_variable
- {
- /*%%%*/
- $$ = assignable(p, $1, 0, &@$);
- /*% %*/
- /*% ripper: assignable(p, var_field(p, $1)) %*/
}
;
@@ -5436,31 +6199,30 @@ superclass : '<'
expr_value term
{
$$ = $3;
+ /*% ripper: $:3 %*/
}
- | /* none */
- {
- /*%%%*/
- $$ = 0;
- /*% %*/
- /*% ripper: Qnil %*/
- }
+ | none
;
f_opt_paren_args: f_paren_args
- | none
+ | f_empty_arg
{
p->ctxt.in_argdef = 0;
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0);
+ }
+ ;
+
+f_empty_arg : /* none */
+ {
+ $$ = new_empty_args_tail(p, &@$);
+ $$ = new_args(p, 0, 0, 0, 0, $$, &@$);
+ /*% ripper: params!(Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil) %*/
}
;
f_paren_args : '(' f_args rparen
{
- /*%%%*/
$$ = $2;
- /*% %*/
- /*% ripper: paren!($2) %*/
+ /*% ripper: paren!($:2) %*/
SET_LEX_STATE(EXPR_BEG);
p->command_start = TRUE;
p->ctxt.in_argdef = 0;
@@ -5469,129 +6231,133 @@ f_paren_args : '(' f_args rparen
f_arglist : f_paren_args
| {
- $<ctxt>$ = p->ctxt;
+ $$ = p->ctxt;
p->ctxt.in_kwarg = 1;
p->ctxt.in_argdef = 1;
SET_LEX_STATE(p->lex.state|EXPR_LABEL); /* force for args */
- }
+ }<ctxt>
f_args term
{
- p->ctxt.in_kwarg = $<ctxt>1.in_kwarg;
+ p->ctxt.in_kwarg = $1.in_kwarg;
p->ctxt.in_argdef = 0;
$$ = $2;
SET_LEX_STATE(EXPR_BEG);
p->command_start = TRUE;
+ /*% ripper: $:2 %*/
}
;
-args_tail : f_kwarg ',' f_kwrest opt_f_block_arg
- {
- $$ = new_args_tail(p, $1, $3, $4, &@3);
- }
- | f_kwarg opt_f_block_arg
- {
- $$ = new_args_tail(p, $1, Qnone, $2, &@1);
- }
- | f_any_kwrest opt_f_block_arg
- {
- $$ = new_args_tail(p, Qnone, $1, $2, &@1);
- }
- | f_block_arg
- {
- $$ = new_args_tail(p, Qnone, Qnone, $1, &@1);
- }
+args_tail : args_tail_basic(arg_value, opt_comma)
| args_forward
{
add_forwarding_args(p);
- $$ = new_args_tail(p, Qnone, $1, ID2VAL(idFWD_BLOCK), &@1);
- /*%%%*/
- ($$->nd_ainfo)->forwarding = 1;
- /*% %*/
+ $$ = new_args_tail(p, 0, $args_forward, arg_FWD_BLOCK, &@args_forward);
+ $$->nd_ainfo.forwarding = 1;
+ /*% ripper: [Qnil, $:args_forward, Qnil] %*/
}
;
-opt_args_tail : ',' args_tail
- {
- $$ = $2;
- }
- | /* none */
+largs_tail : args_tail_basic(arg_value, none)
+ | args_forward
{
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
+ yyerror1(&@args_forward, "unexpected ... in lambda argument");
+ $$ = new_args_tail(p, 0, 0, 0, &@args_forward);
+ $$->nd_ainfo.forwarding = 1;
+ /*% ripper: [Qnil, $:args_forward, Qnil] %*/
}
;
-f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail
+%rule args-list(value, tail) <node_args>
+ : f_arg[pre] ',' f_opt_arg(value)[opt] ',' f_rest_arg[rest] tail
{
- $$ = new_args(p, $1, $3, $5, Qnone, $6, &@$);
+ $$ = new_args(p, $pre, $opt, $rest, 0, $tail, &@$);
+ /*% ripper: params!($:pre, $:opt, $:rest, Qnil, *$:tail[0..2]) %*/
}
- | f_arg ',' f_optarg ',' f_rest_arg ',' f_arg opt_args_tail
+ | f_arg[pre] ',' f_opt_arg(value)[opt] ',' f_rest_arg[rest] ',' f_arg[post] tail
{
- $$ = new_args(p, $1, $3, $5, $7, $8, &@$);
+ $$ = new_args(p, $pre, $opt, $rest, $post, $tail, &@$);
+ /*% ripper: params!($:pre, $:opt, $:rest, $:post, *$:tail[0..2]) %*/
}
- | f_arg ',' f_optarg opt_args_tail
+ | f_arg[pre] ',' f_opt_arg(value)[opt] tail
{
- $$ = new_args(p, $1, $3, Qnone, Qnone, $4, &@$);
+ $$ = new_args(p, $pre, $opt, 0, 0, $tail, &@$);
+ /*% ripper: params!($:pre, $:opt, Qnil, Qnil, *$:tail[0..2]) %*/
}
- | f_arg ',' f_optarg ',' f_arg opt_args_tail
+ | f_arg[pre] ',' f_opt_arg(value)[opt] ',' f_arg[post] tail
{
- $$ = new_args(p, $1, $3, Qnone, $5, $6, &@$);
+ $$ = new_args(p, $pre, $opt, 0, $post, $tail, &@$);
+ /*% ripper: params!($:pre, $:opt, Qnil, $:post, *$:tail[0..2]) %*/
}
- | f_arg ',' f_rest_arg opt_args_tail
+ | f_arg[pre] ',' f_rest_arg[rest] tail
{
- $$ = new_args(p, $1, Qnone, $3, Qnone, $4, &@$);
+ $$ = new_args(p, $pre, 0, $rest, 0, $tail, &@$);
+ /*% ripper: params!($:pre, Qnil, $:rest, Qnil, *$:tail[0..2]) %*/
}
- | f_arg ',' f_rest_arg ',' f_arg opt_args_tail
+ | f_arg[pre] ',' f_rest_arg[rest] ',' f_arg[post] tail
{
- $$ = new_args(p, $1, Qnone, $3, $5, $6, &@$);
+ $$ = new_args(p, $pre, 0, $rest, $post, $tail, &@$);
+ /*% ripper: params!($:pre, Qnil, $:rest, $:post, *$:tail[0..2]) %*/
}
- | f_arg opt_args_tail
+ | f_opt_arg(value)[opt] ',' f_rest_arg[rest] tail
{
- $$ = new_args(p, $1, Qnone, Qnone, Qnone, $2, &@$);
+ $$ = new_args(p, 0, $opt, $rest, 0, $tail, &@$);
+ /*% ripper: params!(Qnil, $:opt, $:rest, Qnil, *$:tail[0..2]) %*/
}
- | f_optarg ',' f_rest_arg opt_args_tail
+ | f_opt_arg(value)[opt] ',' f_rest_arg[rest] ',' f_arg[post] tail
{
- $$ = new_args(p, Qnone, $1, $3, Qnone, $4, &@$);
+ $$ = new_args(p, 0, $opt, $rest, $post, $tail, &@$);
+ /*% ripper: params!(Qnil, $:opt, $:rest, $:post, *$:tail[0..2]) %*/
}
- | f_optarg ',' f_rest_arg ',' f_arg opt_args_tail
+ | f_opt_arg(value)[opt] tail
{
- $$ = new_args(p, Qnone, $1, $3, $5, $6, &@$);
+ $$ = new_args(p, 0, $opt, 0, 0, $tail, &@$);
+ /*% ripper: params!(Qnil, $:opt, Qnil, Qnil, *$:tail[0..2]) %*/
}
- | f_optarg opt_args_tail
+ | f_opt_arg(value)[opt] ',' f_arg[post] tail
{
- $$ = new_args(p, Qnone, $1, Qnone, Qnone, $2, &@$);
+ $$ = new_args(p, 0, $opt, 0, $post, $tail, &@$);
+ /*% ripper: params!(Qnil, $:opt, Qnil, $:post, *$:tail[0..2]) %*/
}
- | f_optarg ',' f_arg opt_args_tail
+ | f_rest_arg[rest] tail
{
- $$ = new_args(p, Qnone, $1, Qnone, $3, $4, &@$);
+ $$ = new_args(p, 0, 0, $rest, 0, $tail, &@$);
+ /*% ripper: params!(Qnil, Qnil, $:rest, Qnil, *$:tail[0..2]) %*/
}
- | f_rest_arg opt_args_tail
+ | f_rest_arg[rest] ',' f_arg[post] tail
{
- $$ = new_args(p, Qnone, Qnone, $1, Qnone, $2, &@$);
+ $$ = new_args(p, 0, 0, $rest, $post, $tail, &@$);
+ /*% ripper: params!(Qnil, Qnil, $:rest, $:post, *$:tail[0..2]) %*/
}
- | f_rest_arg ',' f_arg opt_args_tail
- {
- $$ = new_args(p, Qnone, Qnone, $1, $3, $4, &@$);
- }
- | args_tail
+ ;
+
+%rule tail-only-args(tail) <node_args>
+ : tail
{
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $1, &@$);
+ $$ = new_args(p, 0, 0, 0, 0, $tail, &@$);
+ /*% ripper: params!(Qnil, Qnil, Qnil, Qnil, *$:tail[0..2]) %*/
}
- | /* none */
+ ;
+
+%rule f_args-list(tail, trailing) <node_args>
+ : args-list(arg_value, opt_args_tail(tail, trailing))
+ | f_arg[pre] opt_args_tail(tail, trailing)[tail]
{
- $$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
- $$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0);
+ $$ = new_args(p, $pre, 0, 0, 0, $tail, &@$);
+ /*% ripper: params!($:pre, Qnil, Qnil, Qnil, *$:tail[0..2]) %*/
}
+ | tail-only-args(tail)
+ | f_empty_arg
+ ;
+
+f_args : f_args-list(args_tail, opt_comma)
+ ;
+
+f_largs : f_args-list(largs_tail, none)
;
args_forward : tBDOT3
{
- /*%%%*/
-#ifdef FORWARD_ARGS_WITH_RUBY2_KEYWORDS
- $$ = 0;
-#else
$$ = idFWD_KWREST;
-#endif
- /*% %*/
/*% ripper: args_forward! %*/
}
;
@@ -5601,68 +6367,64 @@ f_bad_arg : tCONSTANT
static const char mesg[] = "formal argument cannot be a constant";
/*%%%*/
yyerror1(&@1, mesg);
- $$ = 0;
/*% %*/
- /*% ripper[error]: param_error!(ERR_MESG(), $1) %*/
+ $$ = 0;
+ /*% ripper[error]: param_error!(ERR_MESG(), $:1) %*/
}
| tIVAR
{
static const char mesg[] = "formal argument cannot be an instance variable";
/*%%%*/
yyerror1(&@1, mesg);
- $$ = 0;
/*% %*/
- /*% ripper[error]: param_error!(ERR_MESG(), $1) %*/
+ $$ = 0;
+ /*% ripper[error]: param_error!(ERR_MESG(), $:1) %*/
}
| tGVAR
{
static const char mesg[] = "formal argument cannot be a global variable";
/*%%%*/
yyerror1(&@1, mesg);
- $$ = 0;
/*% %*/
- /*% ripper[error]: param_error!(ERR_MESG(), $1) %*/
+ $$ = 0;
+ /*% ripper[error]: param_error!(ERR_MESG(), $:1) %*/
}
| tCVAR
{
static const char mesg[] = "formal argument cannot be a class variable";
/*%%%*/
yyerror1(&@1, mesg);
- $$ = 0;
/*% %*/
- /*% ripper[error]: param_error!(ERR_MESG(), $1) %*/
+ $$ = 0;
+ /*% ripper[error]: param_error!(ERR_MESG(), $:1) %*/
}
;
f_norm_arg : f_bad_arg
| tIDENTIFIER
{
- formal_argument(p, $1);
+ VALUE e = formal_argument_error(p, $$ = $1);
+ if (e) {
+ /*% ripper[error]: param_error!(?e, $:1) %*/
+ }
p->max_numparam = ORDINAL_PARAM;
- $$ = $1;
}
;
f_arg_asgn : f_norm_arg
{
- ID id = get_id($1);
- arg_var(p, id);
- p->cur_arg = id;
+ arg_var(p, $1);
$$ = $1;
}
;
f_arg_item : f_arg_asgn
{
- p->cur_arg = 0;
- /*%%%*/
$$ = NEW_ARGS_AUX($1, 1, &NULL_LOC);
- /*% %*/
- /*% ripper: get_value($1) %*/
+ /*% ripper: $:1 %*/
}
| tLPAREN f_margs rparen
{
- /*%%%*/
ID tid = internal_id(p);
YYLTYPE loc;
loc.beg_pos = @2.beg_pos;
@@ -5675,105 +6437,41 @@ f_arg_item : f_arg_asgn
$2->nd_value = NEW_LVAR(tid, &loc);
}
$$ = NEW_ARGS_AUX(tid, 1, &NULL_LOC);
- $$->nd_next = $2;
- /*% %*/
- /*% ripper: mlhs_paren!($2) %*/
+ $$->nd_next = (NODE *)$2;
+ /*% ripper: mlhs_paren!($:2) %*/
}
;
f_arg : f_arg_item
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*% ripper[brace]: rb_ary_new3(1, $:1) %*/
| f_arg ',' f_arg_item
{
- /*%%%*/
$$ = $1;
$$->nd_plen++;
$$->nd_next = block_append(p, $$->nd_next, $3->nd_next);
- rb_discard_node(p, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ rb_discard_node(p, (NODE *)$3);
+ /*% ripper: rb_ary_push($:1, $:3) %*/
}
;
f_label : tLABEL
{
- arg_var(p, formal_argument(p, $1));
- p->cur_arg = get_id($1);
+ VALUE e = formal_argument_error(p, $$ = $1);
+ if (e) {
+ $$ = 0;
+ /*% ripper[error]: param_error!(?e, $:1) %*/
+ }
+ /*
+ * Workaround for Prism::ParseTest#test_filepath for
+ * "unparser/corpus/literal/def.txt"
+ *
+ * See the discussion on https://github.com/ruby/ruby/pull/9923
+ */
+ arg_var(p, ifdef_ripper(0, $1));
+ /*% ripper: $:1 %*/
p->max_numparam = ORDINAL_PARAM;
p->ctxt.in_argdef = 0;
- $$ = $1;
- }
- ;
-
-f_kw : f_label arg_value
- {
- p->cur_arg = 0;
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, $2, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($2)) %*/
- }
- | f_label
- {
- p->cur_arg = 0;
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), 0) %*/
- }
- ;
-
-f_block_kw : f_label primary_value
- {
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, $2, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($2)) %*/
- }
- | f_label
- {
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = new_kw_arg(p, assignable(p, $1, NODE_SPECIAL_REQUIRED_KEYWORD, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), 0) %*/
- }
- ;
-
-f_block_kwarg : f_block_kw
- {
- /*%%%*/
- $$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
- }
- | f_block_kwarg ',' f_block_kw
- {
- /*%%%*/
- $$ = kwd_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
- }
- ;
-
-
-f_kwarg : f_kw
- {
- /*%%%*/
- $$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
- }
- | f_kwarg ',' f_kw
- {
- /*%%%*/
- $$ = kwd_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
}
;
@@ -5783,102 +6481,38 @@ kwrest_mark : tPOW
f_no_kwarg : p_kwnorest
{
- /*%%%*/
- /*% %*/
/*% ripper: nokw_param!(Qnil) %*/
}
;
f_kwrest : kwrest_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
- /*%%%*/
+ arg_var(p, shadowing_lvar(p, $2));
$$ = $2;
- /*% %*/
- /*% ripper: kwrest_param!($2) %*/
+ /*% ripper: kwrest_param!($:2) %*/
}
| kwrest_mark
{
arg_var(p, idFWD_KWREST);
- /*%%%*/
$$ = idFWD_KWREST;
- /*% %*/
/*% ripper: kwrest_param!(Qnil) %*/
}
;
-f_opt : f_arg_asgn f_eq arg_value
- {
- p->cur_arg = 0;
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = NEW_OPT_ARG(0, assignable(p, $1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($3)) %*/
- }
- ;
-
-f_block_opt : f_arg_asgn f_eq primary_value
- {
- p->cur_arg = 0;
- p->ctxt.in_argdef = 1;
- /*%%%*/
- $$ = NEW_OPT_ARG(0, assignable(p, $1, $3, &@$), &@$);
- /*% %*/
- /*% ripper: rb_assoc_new(get_value(assignable(p, $1)), get_value($3)) %*/
- }
- ;
-
-f_block_optarg : f_block_opt
- {
- /*%%%*/
- $$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
- }
- | f_block_optarg ',' f_block_opt
- {
- /*%%%*/
- $$ = opt_arg_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
- }
- ;
-
-f_optarg : f_opt
- {
- /*%%%*/
- $$ = $1;
- /*% %*/
- /*% ripper: rb_ary_new3(1, get_value($1)) %*/
- }
- | f_optarg ',' f_opt
- {
- /*%%%*/
- $$ = opt_arg_append($1, $3);
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
- }
- ;
-
restarg_mark : '*'
| tSTAR
;
f_rest_arg : restarg_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
- /*%%%*/
+ arg_var(p, shadowing_lvar(p, $2));
$$ = $2;
- /*% %*/
- /*% ripper: rest_param!($2) %*/
+ /*% ripper: rest_param!($:2) %*/
}
| restarg_mark
{
arg_var(p, idFWD_REST);
- /*%%%*/
$$ = idFWD_REST;
- /*% %*/
/*% ripper: rest_param!(Qnil) %*/
}
;
@@ -5889,166 +6523,150 @@ blkarg_mark : '&'
f_block_arg : blkarg_mark tIDENTIFIER
{
- arg_var(p, shadowing_lvar(p, get_id($2)));
- /*%%%*/
+ arg_var(p, shadowing_lvar(p, $2));
$$ = $2;
- /*% %*/
- /*% ripper: blockarg!($2) %*/
+ /*% ripper: blockarg!($:2) %*/
+ }
+ | blkarg_mark keyword_nil
+ {
+ $$ = idNil;
+ /*% ripper: blockarg!(ID2VAL(idNil)) %*/
}
| blkarg_mark
{
arg_var(p, idFWD_BLOCK);
- /*%%%*/
$$ = idFWD_BLOCK;
- /*% %*/
/*% ripper: blockarg!(Qnil) %*/
}
;
-opt_f_block_arg : ',' f_block_arg
+opt_comma : ','?
{
- $$ = $2;
- }
- | none
- {
- $$ = Qnull;
+ $$ = 0;
+ /*% ripper: Qnil %*/
}
;
-singleton : var_ref
- {
- value_expr($1);
- $$ = $1;
- }
- | '(' {SET_LEX_STATE(EXPR_BEG);} expr rparen
+
+singleton : value_expr(singleton_expr)
{
- /*%%%*/
- switch (nd_type($3)) {
+ NODE *expr = last_expr_node($1);
+ switch (nd_type(expr)) {
case NODE_STR:
case NODE_DSTR:
case NODE_XSTR:
case NODE_DXSTR:
+ case NODE_REGX:
case NODE_DREGX:
- case NODE_LIT:
+ case NODE_SYM:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ case NODE_DSYM:
case NODE_LIST:
case NODE_ZLIST:
- yyerror1(&@3, "can't define singleton method for literals");
+ yyerror1(&expr->nd_loc, "can't define singleton method for literals");
break;
default:
- value_expr($3);
break;
}
+ $$ = $1;
+ }
+ ;
+
+singleton_expr : var_ref
+ | '('
+ {
+ SET_LEX_STATE(EXPR_BEG);
+ p->ctxt.in_argdef = 0;
+ }
+ expr rparen
+ {
+ p->ctxt.in_argdef = 1;
$$ = $3;
- /*% %*/
- /*% ripper: paren!($3) %*/
+ /*% ripper: paren!($:3) %*/
}
;
assoc_list : none
| assocs trailer
{
- /*%%%*/
$$ = $1;
- /*% %*/
- /*% ripper: assoclist_from_args!($1) %*/
+ /*% ripper: assoclist_from_args!($:1) %*/
}
;
assocs : assoc
- /*% ripper[brace]: rb_ary_new3(1, get_value($1)) %*/
+ /*% ripper[brace]: rb_ary_new3(1, $:1) %*/
| assocs ',' assoc
{
- /*%%%*/
NODE *assocs = $1;
NODE *tail = $3;
if (!assocs) {
assocs = tail;
}
else if (tail) {
- if (assocs->nd_head &&
- !tail->nd_head && nd_type_p(tail->nd_next, NODE_LIST) &&
- nd_type_p(tail->nd_next->nd_head, NODE_HASH)) {
- /* DSTAR */
- tail = tail->nd_next->nd_head->nd_head;
+ if (RNODE_LIST(assocs)->nd_head) {
+ NODE *n = RNODE_LIST(tail)->nd_next;
+ if (!RNODE_LIST(tail)->nd_head && nd_type_p(n, NODE_LIST) &&
+ nd_type_p((n = RNODE_LIST(n)->nd_head), NODE_HASH)) {
+ /* DSTAR */
+ tail = RNODE_HASH(n)->nd_head;
+ }
+ }
+ if (tail) {
+ assocs = list_concat(assocs, tail);
}
- assocs = list_concat(assocs, tail);
}
$$ = assocs;
- /*% %*/
- /*% ripper: rb_ary_push($1, get_value($3)) %*/
+ /*% ripper: rb_ary_push($:1, $:3) %*/
}
;
assoc : arg_value tASSOC arg_value
{
- /*%%%*/
- if (nd_type_p($1, NODE_STR)) {
- nd_set_type($1, NODE_LIT);
- RB_OBJ_WRITE(p->ast, &$1->nd_lit, rb_fstring($1->nd_lit));
- }
$$ = list_append(p, NEW_LIST($1, &@$), $3);
- /*% %*/
- /*% ripper: assoc_new!($1, $3) %*/
+ /*% ripper: assoc_new!($:1, $:3) %*/
}
| tLABEL arg_value
{
- /*%%%*/
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@1), &@$), $2);
- /*% %*/
- /*% ripper: assoc_new!($1, $2) %*/
+ $$ = list_append(p, NEW_LIST(NEW_SYM(rb_id2str($1), &@1), &@$), $2);
+ /*% ripper: assoc_new!($:1, $:2) %*/
}
| tLABEL
{
- /*%%%*/
NODE *val = gettable(p, $1, &@$);
- if (!val) val = NEW_BEGIN(0, &@$);
- $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@1), &@$), val);
- /*% %*/
- /*% ripper: assoc_new!($1, Qnil) %*/
+ if (!val) val = NEW_ERROR(&@$);
+ $$ = list_append(p, NEW_LIST(NEW_SYM(rb_id2str($1), &@1), &@$), val);
+ /*% ripper: assoc_new!($:1, Qnil) %*/
}
| tSTRING_BEG string_contents tLABEL_END arg_value
{
- /*%%%*/
YYLTYPE loc = code_loc_gen(&@1, &@3);
$$ = list_append(p, NEW_LIST(dsym_node(p, $2, &loc), &loc), $4);
- /*% %*/
- /*% ripper: assoc_new!(dyna_symbol!($2), $4) %*/
+ /*% ripper: assoc_new!(dyna_symbol!($:2), $:4) %*/
}
| tDSTAR arg_value
{
- /*%%%*/
- if (nd_type_p($2, NODE_HASH) &&
- !($2->nd_head && $2->nd_head->nd_alen)) {
- static VALUE empty_hash;
- if (!empty_hash) {
- empty_hash = rb_obj_freeze(rb_hash_new());
- rb_gc_register_mark_object(empty_hash);
- }
- $$ = list_append(p, NEW_LIST(0, &@$), NEW_LIT(empty_hash, &@$));
- }
- else
- $$ = list_append(p, NEW_LIST(0, &@$), $2);
- /*% %*/
- /*% ripper: assoc_splat!($2) %*/
+ $$ = list_append(p, NEW_LIST(0, &@$), $2);
+ /*% ripper: assoc_splat!($:2) %*/
}
| tDSTAR
{
- if (!local_id(p, idFWD_KWREST) ||
- local_id(p, idFWD_ALL)) {
- compile_error(p, "no anonymous keyword rest parameter");
- }
- /*%%%*/
+ forwarding_arg_check(p, idFWD_KWREST, idFWD_ALL, "keyword rest");
$$ = list_append(p, NEW_LIST(0, &@$),
NEW_LVAR(idFWD_KWREST, &@$));
- /*% %*/
/*% ripper: assoc_splat!(Qnil) %*/
}
;
-operation : tIDENTIFIER
- | tCONSTANT
- | tFID
- ;
+%rule %inline operation : ident_or_const
+ | tFID
+ ;
operation2 : operation
| op
@@ -6071,28 +6689,27 @@ call_op2 : call_op
| tCOLON2
;
-opt_terms : /* none */
- | terms
- ;
-
-opt_nl : /* none */
- | '\n'
- ;
-
-rparen : opt_nl ')'
+rparen : '\n'? ')'
;
-rbracket : opt_nl ']'
+rbracket : '\n'? ']'
;
-rbrace : opt_nl '}'
+rbrace : '\n'? '}'
;
-trailer : opt_nl
+trailer : '\n'?
| ','
;
-term : ';' {yyerrok;token_flush(p);}
+term : ';'
+ {
+ yyerrok;
+ token_flush(p);
+ if (p->ctxt.in_defined) {
+ p->ctxt.has_trailing_semicolon = 1;
+ }
+ }
| '\n'
{
@$.end_pos = @$.beg_pos;
@@ -6106,7 +6723,8 @@ terms : term
none : /* none */
{
- $$ = Qnull;
+ $$ = 0;
+ /*% ripper: Qnil %*/
}
;
%%
@@ -6121,44 +6739,32 @@ static void tokaddmbc(struct parser_params *p, int c, rb_encoding *enc);
static enum yytokentype parse_string(struct parser_params*,rb_strterm_literal_t*);
static enum yytokentype here_document(struct parser_params*,rb_strterm_heredoc_t*);
-#ifndef RIPPER
+#define set_parser_s_value(x) (ifdef_ripper(p->s_value = (x), (void)0))
+
# define set_yylval_node(x) { \
YYLTYPE _cur_loc; \
rb_parser_set_location(p, &_cur_loc); \
yylval.node = (x); \
+ set_parser_s_value(STR_NEW(p->lex.ptok, p->lex.pcur-p->lex.ptok)); \
}
# define set_yylval_str(x) \
do { \
set_yylval_node(NEW_STR(x, &_cur_loc)); \
- RB_OBJ_WRITTEN(p->ast, Qnil, x); \
+ set_parser_s_value(rb_str_new_mutable_parser_string(x)); \
} while(0)
-# define set_yylval_literal(x) \
-do { \
- set_yylval_node(NEW_LIT(x, &_cur_loc)); \
- RB_OBJ_WRITTEN(p->ast, Qnil, x); \
-} while(0)
-# define set_yylval_num(x) (yylval.num = (x))
-# define set_yylval_id(x) (yylval.id = (x))
-# define set_yylval_name(x) (yylval.id = (x))
+# define set_yylval_num(x) { \
+ yylval.num = (x); \
+ set_parser_s_value(x); \
+}
+# define set_yylval_id(x) (yylval.id = (x))
+# define set_yylval_name(x) { \
+ (yylval.id = (x)); \
+ set_parser_s_value(ID2SYM(x)); \
+}
# define yylval_id() (yylval.id)
-#else
-static inline VALUE
-ripper_yylval_id(struct parser_params *p, ID x)
-{
- return ripper_new_yylval(p, x, ID2SYM(x), 0);
-}
-# define set_yylval_str(x) (yylval.val = add_mark_object(p, (x)))
-# define set_yylval_num(x) (yylval.val = ripper_new_yylval(p, (x), 0, 0))
-# define set_yylval_id(x) (void)(x)
-# define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(p, x))
-# define set_yylval_literal(x) add_mark_object(p, (x))
-# define set_yylval_node(x) (yylval.val = ripper_new_yylval(p, 0, 0, STR_NEW(p->lex.ptok, p->lex.pcur-p->lex.ptok)))
-# define yylval_id() yylval.id
-# define _cur_loc NULL_LOC /* dummy */
-#endif
#define set_yylval_noname() set_yylval_id(keyword_nil)
-#define has_delayed_token(p) (!NIL_P(p->delayed.token))
+#define has_delayed_token(p) (p->delayed.token != NULL)
#ifndef RIPPER
#define literal_flush(p, ptr) ((p)->lex.ptok = (ptr))
@@ -6176,35 +6782,99 @@ parser_has_token(struct parser_params *p)
return pcur > ptok;
}
-static VALUE
-code_loc_to_ary(const rb_code_location_t *loc)
+static const char *
+escaped_char(int c)
{
- VALUE ary = rb_ary_new_from_args(4,
- INT2NUM(loc->beg_pos.lineno), INT2NUM(loc->beg_pos.column),
- INT2NUM(loc->end_pos.lineno), INT2NUM(loc->end_pos.column));
- rb_obj_freeze(ary);
-
- return ary;
+ switch (c) {
+ case '"': return "\\\"";
+ case '\\': return "\\\\";
+ case '\0': return "\\0";
+ case '\n': return "\\n";
+ case '\r': return "\\r";
+ case '\t': return "\\t";
+ case '\f': return "\\f";
+ case '\013': return "\\v";
+ case '\010': return "\\b";
+ case '\007': return "\\a";
+ case '\033': return "\\e";
+ case '\x7f': return "\\c?";
+ }
+ return NULL;
}
-static void
-parser_append_tokens(struct parser_params *p, VALUE str, enum yytokentype t, int line)
+static rb_parser_string_t *
+rb_parser_str_escape(struct parser_params *p, rb_parser_string_t *str)
{
- VALUE ary;
- int token_id;
+ rb_encoding *enc = p->enc;
+ const char *ptr = str->ptr;
+ const char *pend = ptr + str->len;
+ const char *prev = ptr;
+ char charbuf[5] = {'\\', 'x', 0, 0, 0};
+ rb_parser_string_t * result = rb_parser_string_new(p, 0, 0);
+
+ while (ptr < pend) {
+ unsigned int c;
+ const char *cc;
+ int n = rb_enc_precise_mbclen(ptr, pend, enc);
+ if (!MBCLEN_CHARFOUND_P(n)) {
+ if (ptr > prev) parser_str_cat(result, prev, ptr - prev);
+ n = rb_enc_mbminlen(enc);
+ if (pend < ptr + n)
+ n = (int)(pend - ptr);
+ while (n--) {
+ c = *ptr & 0xf0 >> 4;
+ charbuf[2] = (c < 10) ? '0' + c : 'A' + c - 10;
+ c = *ptr & 0x0f;
+ charbuf[3] = (c < 10) ? '0' + c : 'A' + c - 10;
+ parser_str_cat(result, charbuf, 4);
+ prev = ++ptr;
+ }
+ continue;
+ }
+ n = MBCLEN_CHARFOUND_LEN(n);
+ c = rb_enc_mbc_to_codepoint(ptr, pend, enc);
+ ptr += n;
+ cc = escaped_char(c);
+ if (cc) {
+ if (ptr - n > prev) parser_str_cat(result, prev, ptr - n - prev);
+ parser_str_cat_cstr(result, cc);
+ prev = ptr;
+ }
+ else if (rb_enc_isascii(c, enc) && ISPRINT(c)) {
+ }
+ else {
+ if (ptr - n > prev) {
+ parser_str_cat(result, prev, ptr - n - prev);
+ prev = ptr - n;
+ }
+ parser_str_cat(result, prev, ptr - prev);
+ prev = ptr;
+ }
+ }
+ if (ptr > prev) parser_str_cat(result, prev, ptr - prev);
- ary = rb_ary_new2(4);
- token_id = p->token_id;
- rb_ary_push(ary, INT2FIX(token_id));
- rb_ary_push(ary, ID2SYM(parser_token2id(t)));
- rb_ary_push(ary, str);
- rb_ary_push(ary, code_loc_to_ary(p->yylloc));
- rb_obj_freeze(ary);
- rb_ary_push(p->tokens, ary);
+ return result;
+}
+
+static void
+parser_append_tokens(struct parser_params *p, rb_parser_string_t *str, enum yytokentype t, int line)
+{
+ rb_parser_ast_token_t *token = xcalloc(1, sizeof(rb_parser_ast_token_t));
+ token->id = p->token_id;
+ token->type_name = parser_token2char(p, t);
+ token->str = str;
+ token->loc.beg_pos = p->yylloc->beg_pos;
+ token->loc.end_pos = p->yylloc->end_pos;
+ rb_parser_ary_push_ast_token(p, p->tokens, token);
p->token_id++;
if (p->debug) {
- rb_parser_printf(p, "Append tokens (line: %d) %"PRIsVALUE"\n", line, ary);
+ rb_parser_string_t *str_escaped = rb_parser_str_escape(p, str);
+ rb_parser_printf(p, "Append tokens (line: %d) [%d, :%s, \"%s\", [%d, %d, %d, %d]]\n",
+ line, token->id, token->type_name, str_escaped->ptr,
+ token->loc.beg_pos.lineno, token->loc.beg_pos.column,
+ token->loc.end_pos.lineno, token->loc.end_pos.column);
+ rb_parser_string_free(p, str_escaped);
}
}
@@ -6218,7 +6888,7 @@ parser_dispatch_scan_event(struct parser_params *p, enum yytokentype t, int line
RUBY_SET_YYLLOC(*p->yylloc);
if (p->keep_tokens) {
- VALUE str = STR_NEW(p->lex.ptok, p->lex.pcur - p->lex.ptok);
+ rb_parser_string_t *str = rb_parser_encoding_string_new(p, p->lex.ptok, p->lex.pcur - p->lex.ptok, p->enc);
parser_append_tokens(p, str, t, line);
}
@@ -6229,9 +6899,6 @@ parser_dispatch_scan_event(struct parser_params *p, enum yytokentype t, int line
static void
parser_dispatch_delayed_token(struct parser_params *p, enum yytokentype t, int line)
{
- int saved_line = p->ruby_sourceline;
- const char *saved_tokp = p->lex.ptok;
-
debug_token_line(p, "parser_dispatch_delayed_token", line);
if (!has_delayed_token(p)) return;
@@ -6239,27 +6906,18 @@ parser_dispatch_delayed_token(struct parser_params *p, enum yytokentype t, int l
RUBY_SET_YYLLOC_OF_DELAYED_TOKEN(*p->yylloc);
if (p->keep_tokens) {
- p->ruby_sourceline = p->delayed.beg_line;
- p->lex.ptok = p->lex.pbeg + p->delayed.beg_col;
+ /* p->delayed.token is freed by rb_parser_tokens_free */
parser_append_tokens(p, p->delayed.token, t, line);
- p->ruby_sourceline = saved_line;
- p->lex.ptok = saved_tokp;
+ }
+ else {
+ rb_parser_string_free(p, p->delayed.token);
}
- p->delayed.token = Qnil;
+ p->delayed.token = NULL;
}
#else
#define literal_flush(p, ptr) ((void)(ptr))
-#define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
-
-static inline VALUE
-intern_sym(const char *name)
-{
- ID id = rb_intern_const(name);
- return ID2SYM(id);
-}
-
static int
ripper_has_scan_event(struct parser_params *p)
{
@@ -6281,21 +6939,27 @@ static void
ripper_dispatch_scan_event(struct parser_params *p, enum yytokentype t)
{
if (!ripper_has_scan_event(p)) return;
- add_mark_object(p, yylval_rval = ripper_scan_event_val(p, t));
+
+ set_parser_s_value(ripper_scan_event_val(p, t));
}
#define dispatch_scan_event(p, t) ripper_dispatch_scan_event(p, t)
static void
ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t)
{
+ /* save and adjust the location to delayed token for callbacks */
int saved_line = p->ruby_sourceline;
const char *saved_tokp = p->lex.ptok;
+ VALUE s_value, str;
if (!has_delayed_token(p)) return;
p->ruby_sourceline = p->delayed.beg_line;
p->lex.ptok = p->lex.pbeg + p->delayed.beg_col;
- add_mark_object(p, yylval_rval = ripper_dispatch1(p, ripper_token2eventid(t), p->delayed.token));
- p->delayed.token = Qnil;
+ str = rb_str_new_mutable_parser_string(p->delayed.token);
+ rb_parser_string_free(p, p->delayed.token);
+ s_value = ripper_dispatch1(p, ripper_token2eventid(t), str);
+ set_parser_s_value(s_value);
+ p->delayed.token = NULL;
p->ruby_sourceline = saved_line;
p->lex.ptok = saved_tokp;
}
@@ -6303,15 +6967,28 @@ ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t)
#endif /* RIPPER */
static inline int
-is_identchar(const char *ptr, const char *MAYBE_UNUSED(ptr_end), rb_encoding *enc)
+is_identchar(struct parser_params *p, const char *ptr, const char *MAYBE_UNUSED(ptr_end), rb_encoding *enc)
{
return rb_enc_isalnum((unsigned char)*ptr, enc) || *ptr == '_' || !ISASCII(*ptr);
}
+static inline bool
+peek_word_at(struct parser_params *p, const char *str, size_t len, int at)
+{
+ const char *ptr = p->lex.pcur + at;
+ if (lex_eol_ptr_n_p(p, ptr, len-1)) return false;
+ if (memcmp(ptr, str, len)) return false;
+ if (lex_eol_ptr_n_p(p, ptr, len)) return true;
+ switch (ptr[len]) {
+ case '!': case '?': return false;
+ }
+ return !is_identchar(p, ptr+len, p->lex.pend, p->enc);
+}
+
static inline int
parser_is_identchar(struct parser_params *p)
{
- return !(p)->eofp && is_identchar(p->lex.pcur-1, p->lex.pend, p->enc);
+ return !(p)->eofp && is_identchar(p, p->lex.pcur-1, p->lex.pend, p->enc);
}
static inline int
@@ -6359,11 +7036,12 @@ token_info_pop(struct parser_params *p, const char *token, const rb_code_locatio
token_info *ptinfo_beg = p->token_info;
if (!ptinfo_beg) return;
- p->token_info = ptinfo_beg->next;
/* indentation check of matched keywords (begin..end, if..end, etc.) */
token_info_warn(p, token, ptinfo_beg, 1, loc);
- ruby_sized_xfree(ptinfo_beg, sizeof(*ptinfo_beg));
+
+ p->token_info = ptinfo_beg->next;
+ ruby_xfree_sized(ptinfo_beg, sizeof(*ptinfo_beg));
}
static void
@@ -6383,7 +7061,7 @@ token_info_drop(struct parser_params *p, const char *token, rb_code_position_t b
ptinfo_beg->token);
}
- ruby_sized_xfree(ptinfo_beg, sizeof(*ptinfo_beg));
+ ruby_xfree_sized(ptinfo_beg, sizeof(*ptinfo_beg));
}
static void
@@ -6414,12 +7092,10 @@ parser_precise_mbclen(struct parser_params *p, const char *ptr)
}
#ifndef RIPPER
-static void ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str);
-
static inline void
parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
{
- VALUE str;
+ rb_parser_string_t *str;
int lineno = p->ruby_sourceline;
if (!yylloc) {
return;
@@ -6430,11 +7106,11 @@ parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
else {
return;
}
- ruby_show_error_line(p->error_buffer, yylloc, lineno, str);
+ ruby_show_error_line(p, p->error_buffer, yylloc, lineno, str);
}
static int
-parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
+parser_yyerror(struct parser_params *p, const rb_code_location_t *yylloc, const char *msg)
{
#if 0
YYLTYPE current;
@@ -6447,7 +7123,7 @@ parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
yylloc = 0;
}
#endif
- compile_error(p, "%s", msg);
+ parser_compile_error(p, yylloc, "%s", msg);
parser_show_error_line(p, yylloc);
return 0;
}
@@ -6459,8 +7135,8 @@ parser_yyerror0(struct parser_params *p, const char *msg)
return parser_yyerror(p, RUBY_SET_YYLLOC(current), msg);
}
-static void
-ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
+void
+ruby_show_error_line(struct parser_params *p, VALUE errbuf, const YYLTYPE *yylloc, int lineno, rb_parser_string_t *str)
{
VALUE mesg;
const int max_line_margin = 30;
@@ -6468,13 +7144,13 @@ ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
const char *pre = "", *post = "", *pend;
const char *code = "", *caret = "";
const char *lim;
- const char *const pbeg = RSTRING_PTR(str);
+ const char *const pbeg = PARSER_STRING_PTR(str);
char *buf;
long len;
int i;
if (!yylloc) return;
- pend = RSTRING_END(str);
+ pend = rb_parser_string_end(str);
if (pend > pbeg && pend[-1] == '\n') {
if (--pend > pbeg && pend[-1] == '\r') --pend;
}
@@ -6495,11 +7171,11 @@ ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
len = ptr_end - ptr;
if (len > 4) {
if (ptr > pbeg) {
- ptr = rb_enc_prev_char(pbeg, ptr, pt, rb_enc_get(str));
+ ptr = rb_enc_prev_char(pbeg, ptr, pt, rb_parser_str_get_encoding(str));
if (ptr > pbeg) pre = "...";
}
if (ptr_end < pend) {
- ptr_end = rb_enc_prev_char(pt, ptr_end, pend, rb_enc_get(str));
+ ptr_end = rb_enc_prev_char(pt, ptr_end, pend, rb_parser_str_get_encoding(str));
if (ptr_end < pend) post = "...";
}
}
@@ -6514,11 +7190,11 @@ ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
}
if (RTEST(errbuf)) {
mesg = rb_attr_get(errbuf, idMesg);
- if (RSTRING_LEN(mesg) > 0 && *(RSTRING_END(mesg)-1) != '\n')
+ if (char_at_end(p, mesg, '\n') != '\n')
rb_str_cat_cstr(mesg, "\n");
}
else {
- mesg = rb_enc_str_new(0, 0, rb_enc_get(str));
+ mesg = rb_enc_str_new(0, 0, rb_parser_str_get_encoding(str));
}
if (!errbuf && rb_stderr_tty_p()) {
#define CSI_BEGIN "\033["
@@ -6564,6 +7240,7 @@ ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno, VALUE str)
if (!errbuf) rb_write_error_str(mesg);
}
#else
+
static int
parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg)
{
@@ -6597,7 +7274,6 @@ parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
}
#endif /* !RIPPER */
-#ifndef RIPPER
static int
vtable_size(const struct vtable *tbl)
{
@@ -6608,7 +7284,6 @@ vtable_size(const struct vtable *tbl)
return 0;
}
}
-#endif
static struct vtable *
vtable_alloc_gen(struct parser_params *p, int line, struct vtable *prev)
@@ -6638,9 +7313,9 @@ vtable_free_gen(struct parser_params *p, int line, const char *name,
#endif
if (!DVARS_TERMINAL_P(tbl)) {
if (tbl->tbl) {
- ruby_sized_xfree(tbl->tbl, tbl->capa * sizeof(ID));
+ ruby_xfree_sized(tbl->tbl, tbl->capa * sizeof(ID));
}
- ruby_sized_xfree(tbl, sizeof(*tbl));
+ ruby_xfree_sized(tbl, sizeof(*tbl));
}
}
#define vtable_free(tbl) vtable_free_gen(p, __LINE__, #tbl, tbl)
@@ -6667,7 +7342,6 @@ vtable_add_gen(struct parser_params *p, int line, const char *name,
}
#define vtable_add(tbl, id) vtable_add_gen(p, __LINE__, #tbl, tbl, id)
-#ifndef RIPPER
static void
vtable_pop_gen(struct parser_params *p, int line, const char *name,
struct vtable *tbl, int n)
@@ -6683,7 +7357,6 @@ vtable_pop_gen(struct parser_params *p, int line, const char *name,
tbl->pos -= n;
}
#define vtable_pop(tbl, n) vtable_pop_gen(p, __LINE__, #tbl, tbl, n)
-#endif
static int
vtable_included(const struct vtable * tbl, ID id)
@@ -6702,60 +7375,29 @@ vtable_included(const struct vtable * tbl, ID id)
static void parser_prepare(struct parser_params *p);
-#ifndef RIPPER
-static NODE *parser_append_options(struct parser_params *p, NODE *node);
-
-static VALUE
-debug_lines(VALUE fname)
-{
- ID script_lines;
- CONST_ID(script_lines, "SCRIPT_LINES__");
- if (rb_const_defined_at(rb_cObject, script_lines)) {
- VALUE hash = rb_const_get_at(rb_cObject, script_lines);
- if (RB_TYPE_P(hash, T_HASH)) {
- VALUE lines = rb_ary_new();
- rb_hash_aset(hash, fname, lines);
- return lines;
- }
- }
- return 0;
-}
-
static int
e_option_supplied(struct parser_params *p)
{
return strcmp(p->ruby_sourcefile, "-e") == 0;
}
+#ifndef RIPPER
+static NODE *parser_append_options(struct parser_params *p, NODE *node);
+
static VALUE
yycompile0(VALUE arg)
{
int n;
NODE *tree;
struct parser_params *p = (struct parser_params *)arg;
- VALUE cov = Qfalse;
+ int cov = FALSE;
- if (!compile_for_eval && !NIL_P(p->ruby_sourcefile_string)) {
- p->debug_lines = debug_lines(p->ruby_sourcefile_string);
- if (p->debug_lines && p->ruby_sourceline > 0) {
- VALUE str = rb_default_rs;
- n = p->ruby_sourceline;
- do {
- rb_ary_push(p->debug_lines, str);
- } while (--n);
- }
-
- if (!e_option_supplied(p)) {
- cov = Qtrue;
- }
+ if (!compile_for_eval && !NIL_P(p->ruby_sourcefile_string) && !e_option_supplied(p)) {
+ cov = TRUE;
}
- if (p->keep_script_lines || ruby_vm_keep_script_lines) {
- if (!p->debug_lines) {
- p->debug_lines = rb_ary_new();
- }
-
- RB_OBJ_WRITE(p->ast, &p->ast->body.script_lines, p->debug_lines);
+ if (p->debug_lines) {
+ p->ast->body.script_lines = p->debug_lines;
}
parser_prepare(p);
@@ -6766,14 +7408,16 @@ yycompile0(VALUE arg)
RUBY_DTRACE_PARSE_HOOK(BEGIN);
n = yyparse(p);
RUBY_DTRACE_PARSE_HOOK(END);
+
p->debug_lines = 0;
+ xfree(p->lex.strterm);
p->lex.strterm = 0;
p->lex.pcur = p->lex.pbeg = p->lex.pend = 0;
if (n || p->error_p) {
VALUE mesg = p->error_buffer;
if (!mesg) {
- mesg = rb_class_new_instance(0, 0, rb_eSyntaxError);
+ mesg = syntax_error_new();
}
if (!p->error_tolerant) {
rb_set_errinfo(mesg);
@@ -6785,27 +7429,25 @@ yycompile0(VALUE arg)
tree = NEW_NIL(&NULL_LOC);
}
else {
- VALUE opt = p->compile_option;
- VALUE tokens = p->tokens;
+ rb_parser_ary_t *tokens = p->tokens;
NODE *prelude;
- NODE *body = parser_append_options(p, tree->nd_body);
- if (!opt) opt = rb_obj_hide(rb_ident_hash_new());
- rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov);
+ NODE *body = parser_append_options(p, RNODE_SCOPE(tree)->nd_body);
prelude = block_append(p, p->eval_tree_begin, body);
- tree->nd_body = prelude;
- RB_OBJ_WRITE(p->ast, &p->ast->body.compile_option, opt);
+ RNODE_SCOPE(tree)->nd_body = prelude;
+ p->ast->body.frozen_string_literal = p->frozen_string_literal;
+ p->ast->body.coverage_enabled = cov;
if (p->keep_tokens) {
- rb_obj_freeze(tokens);
- rb_ast_set_tokens(p->ast, tokens);
+ p->ast->node_buffer->tokens = tokens;
+ p->tokens = NULL;
}
}
p->ast->body.root = tree;
- if (!p->ast->body.script_lines) p->ast->body.script_lines = INT2FIX(p->line_count);
+ p->ast->body.line_count = p->line_count;
return TRUE;
}
static rb_ast_t *
-yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
+yycompile(struct parser_params *p, VALUE fname, int line)
{
rb_ast_t *ast;
if (NIL_P(fname)) {
@@ -6813,7 +7455,7 @@ yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
p->ruby_sourcefile = "(none)";
}
else {
- p->ruby_sourcefile_string = rb_fstring(fname);
+ p->ruby_sourcefile_string = rb_str_to_interned_str(fname);
p->ruby_sourcefile = StringValueCStr(fname);
}
p->ruby_sourceline = line - 1;
@@ -6821,9 +7463,8 @@ yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
p->lvtbl = NULL;
p->ast = ast = rb_ast_new();
- rb_suppress_tracing(yycompile0, (VALUE)p);
+ compile_callback(yycompile0, (VALUE)p);
p->ast = 0;
- RB_GC_GUARD(vparser); /* prohibit tail call optimization */
while (p->lvtbl) {
local_pop(p);
@@ -6834,118 +7475,35 @@ yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
#endif /* !RIPPER */
static rb_encoding *
-must_be_ascii_compatible(VALUE s)
+must_be_ascii_compatible(struct parser_params *p, rb_parser_string_t *s)
{
- rb_encoding *enc = rb_enc_get(s);
+ rb_encoding *enc = rb_parser_str_get_encoding(s);
if (!rb_enc_asciicompat(enc)) {
rb_raise(rb_eArgError, "invalid source encoding");
}
return enc;
}
-static VALUE
-lex_get_str(struct parser_params *p, VALUE s)
-{
- char *beg, *end, *start;
- long len;
-
- beg = RSTRING_PTR(s);
- len = RSTRING_LEN(s);
- start = beg;
- if (p->lex.gets_.ptr) {
- if (len == p->lex.gets_.ptr) return Qnil;
- beg += p->lex.gets_.ptr;
- len -= p->lex.gets_.ptr;
- }
- end = memchr(beg, '\n', len);
- if (end) len = ++end - beg;
- p->lex.gets_.ptr += len;
- return rb_str_subseq(s, beg - start, len);
-}
-
-static VALUE
+static rb_parser_string_t *
lex_getline(struct parser_params *p)
{
- VALUE line = (*p->lex.gets)(p, p->lex.input);
- if (NIL_P(line)) return line;
- must_be_ascii_compatible(line);
- if (RB_OBJ_FROZEN(line)) line = rb_str_dup(line); // needed for RubyVM::AST.of because script_lines in iseq is deep-frozen
+ rb_parser_string_t *line = (*p->lex.gets)(p, p->lex.input, p->line_count);
+ if (!line) return 0;
p->line_count++;
+ string_buffer_append(p, line);
+ must_be_ascii_compatible(p, line);
return line;
}
-static const rb_data_type_t parser_data_type;
-
#ifndef RIPPER
-static rb_ast_t*
-parser_compile_string(VALUE vparser, VALUE fname, VALUE s, int line)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
-
- p->lex.gets = lex_get_str;
- p->lex.gets_.ptr = 0;
- p->lex.input = rb_str_new_frozen(s);
- p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
-
- return yycompile(vparser, p, fname, line);
-}
-
-rb_ast_t*
-rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
-{
- return rb_parser_compile_string_path(vparser, rb_filesystem_str_new_cstr(f), s, line);
-}
-
-rb_ast_t*
-rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
-{
- must_be_ascii_compatible(s);
- return parser_compile_string(vparser, f, s, line);
-}
-
-VALUE rb_io_gets_internal(VALUE io);
-
-static VALUE
-lex_io_gets(struct parser_params *p, VALUE io)
-{
- return rb_io_gets_internal(io);
-}
-
rb_ast_t*
-rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
+rb_parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, VALUE fname, rb_parser_input_data input, int line)
{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
-
- p->lex.gets = lex_io_gets;
- p->lex.input = file;
- p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
-
- return yycompile(vparser, p, fname, start);
-}
-
-static VALUE
-lex_generic_gets(struct parser_params *p, VALUE input)
-{
- return (*p->lex.gets_.call)(input, p->line_count);
-}
-
-rb_ast_t*
-rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
-
- p->lex.gets = lex_generic_gets;
- p->lex.gets_.call = lex_gets;
+ p->lex.gets = gets;
p->lex.input = input;
p->lex.pbeg = p->lex.pcur = p->lex.pend = 0;
- return yycompile(vparser, p, fname, start);
+ return yycompile(p, fname, line);
}
#endif /* !RIPPER */
@@ -6971,21 +7529,48 @@ enum string_type {
str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND)
};
-static VALUE
-parser_str_new(const char *ptr, long len, rb_encoding *enc, int func, rb_encoding *enc0)
+static rb_parser_string_t *
+parser_str_new(struct parser_params *p, const char *ptr, long len, rb_encoding *enc, int func, rb_encoding *enc0)
{
- VALUE str;
+ rb_parser_string_t *pstr;
+
+ pstr = rb_parser_encoding_string_new(p, ptr, len, enc);
- str = rb_enc_str_new(ptr, len, enc);
- if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) {
- if (is_ascii_string(str)) {
+ if (!(func & STR_FUNC_REGEXP)) {
+ if (rb_parser_is_ascii_string(p, pstr)) {
}
- else if (rb_is_usascii_enc(enc0) && enc != rb_utf8_encoding()) {
- rb_enc_associate(str, rb_ascii8bit_encoding());
+ else if (rb_is_usascii_enc((void *)enc0) && enc != rb_utf8_encoding()) {
+ /* everything is valid in ASCII-8BIT */
+ enc = rb_ascii8bit_encoding();
+ PARSER_ENCODING_CODERANGE_SET(pstr, enc, RB_PARSER_ENC_CODERANGE_VALID);
}
}
- return str;
+ return pstr;
+}
+
+static int
+strterm_is_heredoc(rb_strterm_t *strterm)
+{
+ return strterm->heredoc;
+}
+
+static rb_strterm_t *
+new_strterm(struct parser_params *p, int func, int term, int paren)
+{
+ rb_strterm_t *strterm = ZALLOC(rb_strterm_t);
+ strterm->u.literal.func = func;
+ strterm->u.literal.term = term;
+ strterm->u.literal.paren = paren;
+ return strterm;
+}
+
+static rb_strterm_t *
+new_heredoc(struct parser_params *p)
+{
+ rb_strterm_t *strterm = ZALLOC(rb_strterm_t);
+ strterm->heredoc = true;
+ return strterm;
}
#define peek(p,c) peek_n(p, (c), 0)
@@ -6993,21 +7578,28 @@ parser_str_new(const char *ptr, long len, rb_encoding *enc, int func, rb_encodin
#define peekc(p) peekc_n(p, 0)
#define peekc_n(p,n) (lex_eol_n_p(p, n) ? -1 : (unsigned char)(p)->lex.pcur[n])
+#define add_delayed_token(p, tok, end) parser_add_delayed_token(p, tok, end, __LINE__)
static void
-add_delayed_token(struct parser_params *p, const char *tok, const char *end, int line)
+parser_add_delayed_token(struct parser_params *p, const char *tok, const char *end, int line)
{
-#ifndef RIPPER
debug_token_line(p, "add_delayed_token", line);
-#endif
if (tok < end) {
+ if (has_delayed_token(p)) {
+ bool next_line = parser_string_char_at_end(p, p->delayed.token, 0) == '\n';
+ int end_line = (next_line ? 1 : 0) + p->delayed.end_line;
+ int end_col = (next_line ? 0 : p->delayed.end_col);
+ if (end_line != p->ruby_sourceline || end_col != tok - p->lex.pbeg) {
+ dispatch_delayed_token(p, tSTRING_CONTENT);
+ }
+ }
if (!has_delayed_token(p)) {
- p->delayed.token = rb_str_buf_new(end - tok);
- rb_enc_associate(p->delayed.token, p->enc);
+ p->delayed.token = rb_parser_string_new(p, 0, 0);
+ rb_parser_enc_associate(p, p->delayed.token, p->enc);
p->delayed.beg_line = p->ruby_sourceline;
p->delayed.beg_col = rb_long2int(tok - p->lex.pbeg);
}
- rb_str_buf_cat(p->delayed.token, tok, end - tok);
+ parser_str_cat(p->delayed.token, tok, end - tok);
p->delayed.end_line = p->ruby_sourceline;
p->delayed.end_col = rb_long2int(end - p->lex.pbeg);
p->lex.ptok = end;
@@ -7015,27 +7607,27 @@ add_delayed_token(struct parser_params *p, const char *tok, const char *end, int
}
static void
-set_lastline(struct parser_params *p, VALUE v)
+set_lastline(struct parser_params *p, rb_parser_string_t *str)
{
- p->lex.pbeg = p->lex.pcur = RSTRING_PTR(v);
- p->lex.pend = p->lex.pcur + RSTRING_LEN(v);
- p->lex.lastline = v;
+ p->lex.pbeg = p->lex.pcur = PARSER_STRING_PTR(str);
+ p->lex.pend = p->lex.pcur + PARSER_STRING_LEN(str);
+ p->lex.lastline = str;
}
static int
nextline(struct parser_params *p, int set_encoding)
{
- VALUE v = p->lex.nextline;
+ rb_parser_string_t *str = p->lex.nextline;
p->lex.nextline = 0;
- if (!v) {
+ if (!str) {
if (p->eofp)
return -1;
- if (p->lex.pend > p->lex.pbeg && *(p->lex.pend-1) != '\n') {
+ if (!lex_eol_ptr_p(p, p->lex.pbeg) && *(p->lex.pend-1) != '\n') {
goto end_of_input;
}
- if (!p->lex.input || NIL_P(v = lex_getline(p))) {
+ if (!p->lex.input || !(str = lex_getline(p))) {
end_of_input:
p->eofp = 1;
lex_goto_eol(p);
@@ -7043,23 +7635,24 @@ nextline(struct parser_params *p, int set_encoding)
}
#ifndef RIPPER
if (p->debug_lines) {
- if (set_encoding) rb_enc_associate(v, p->enc);
- rb_ary_push(p->debug_lines, v);
+ if (set_encoding) rb_parser_enc_associate(p, str, p->enc);
+ rb_parser_string_t *copy = rb_parser_string_deep_copy(p, str);
+ rb_parser_ary_push_script_line(p, p->debug_lines, copy);
}
#endif
p->cr_seen = FALSE;
}
- else if (NIL_P(v)) {
+ else if (str == AFTER_HEREDOC_WITHOUT_TERMINATOR) {
/* after here-document without terminator */
goto end_of_input;
}
- add_delayed_token(p, p->lex.ptok, p->lex.pend, __LINE__);
+ add_delayed_token(p, p->lex.ptok, p->lex.pend);
if (p->heredoc_end > 0) {
p->ruby_sourceline = p->heredoc_end;
p->heredoc_end = 0;
}
p->ruby_sourceline++;
- set_lastline(p, v);
+ set_lastline(p, str);
token_flush(p);
return 0;
}
@@ -7079,7 +7672,7 @@ nextc0(struct parser_params *p, int set_encoding)
{
int c;
- if (UNLIKELY((p->lex.pcur == p->lex.pend) || p->eofp || RTEST(p->lex.nextline))) {
+ if (UNLIKELY(lex_eol_p(p) || p->eofp || p->lex.nextline > AFTER_HEREDOC_WITHOUT_TERMINATOR)) {
if (nextline(p, set_encoding)) return -1;
}
c = (unsigned char)*p->lex.pcur++;
@@ -7095,6 +7688,7 @@ static void
pushback(struct parser_params *p, int c)
{
if (c == -1) return;
+ p->eofp = 0;
p->lex.pcur--;
if (p->lex.pcur > p->lex.pbeg && p->lex.pcur[0] == '\n' && p->lex.pcur[-1] == '\r') {
p->lex.pcur--;
@@ -7111,7 +7705,7 @@ static int
looking_at_eol_p(struct parser_params *p)
{
const char *ptr = p->lex.pcur;
- while (ptr < p->lex.pend) {
+ while (!lex_eol_ptr_p(p, ptr)) {
int c = (unsigned char)*ptr++;
int eol = (c == '\n' || c == '#');
if (eol || !ISSPACE(c)) {
@@ -7125,7 +7719,6 @@ static char*
newtok(struct parser_params *p)
{
p->tokidx = 0;
- p->tokline = p->ruby_sourceline;
if (!p->tokenbuf) {
p->toksiz = 60;
p->tokenbuf = ALLOC_N(char, 60);
@@ -7164,10 +7757,11 @@ tok_hex(struct parser_params *p, size_t *numlen)
{
int c;
- c = scan_hex(p->lex.pcur, 2, numlen);
+ c = (int)ruby_scan_hex(p->lex.pcur, 2, numlen);
if (!*numlen) {
+ flush_string_content(p, p->enc, rb_strlen_lit("\\x"));
yyerror0("invalid hex escape");
- token_flush(p);
+ dispatch_scan_event(p, tSTRING_CONTENT);
return 0;
}
p->lex.pcur += *numlen;
@@ -7204,31 +7798,37 @@ escaped_control_code(int c)
}
#define WARN_SPACE_CHAR(c, prefix) \
- rb_warn1("invalid character syntax; use "prefix"\\%c", WARN_I(c2))
+ rb_warn1("invalid character syntax; use "prefix"\\%c", WARN_I(c))
static int
tokadd_codepoint(struct parser_params *p, rb_encoding **encp,
- int regexp_literal, int wide)
+ int regexp_literal, const char *begin)
{
+ const int wide = !begin;
size_t numlen;
- int codepoint = scan_hex(p->lex.pcur, wide ? p->lex.pend - p->lex.pcur : 4, &numlen);
+ int codepoint = (int)ruby_scan_hex(p->lex.pcur, wide ? p->lex.pend - p->lex.pcur : 4, &numlen);
+
p->lex.pcur += numlen;
if (p->lex.strterm == NULL ||
- (p->lex.strterm->flags & STRTERM_HEREDOC) ||
- (p->lex.strterm->u.literal.u1.func != str_regexp)) {
+ strterm_is_heredoc(p->lex.strterm) ||
+ (p->lex.strterm->u.literal.func != str_regexp)) {
+ if (!begin) begin = p->lex.pcur;
if (wide ? (numlen == 0 || numlen > 6) : (numlen < 4)) {
- literal_flush(p, p->lex.pcur);
+ flush_string_content(p, rb_utf8_encoding(), p->lex.pcur - begin);
yyerror0("invalid Unicode escape");
+ dispatch_scan_event(p, tSTRING_CONTENT);
return wide && numlen > 0;
}
if (codepoint > 0x10ffff) {
- literal_flush(p, p->lex.pcur);
+ flush_string_content(p, rb_utf8_encoding(), p->lex.pcur - begin);
yyerror0("invalid Unicode codepoint (too large)");
+ dispatch_scan_event(p, tSTRING_CONTENT);
return wide;
}
if ((codepoint & 0xfffff800) == 0xd800) {
- literal_flush(p, p->lex.pcur);
+ flush_string_content(p, rb_utf8_encoding(), p->lex.pcur - begin);
yyerror0("invalid Unicode codepoint");
+ dispatch_scan_event(p, tSTRING_CONTENT);
return wide;
}
}
@@ -7252,6 +7852,18 @@ tokadd_codepoint(struct parser_params *p, rb_encoding **encp,
return TRUE;
}
+static int tokadd_mbchar(struct parser_params *p, int c);
+
+static int
+tokskip_mbchar(struct parser_params *p)
+{
+ int len = parser_precise_mbclen(p, p->lex.pcur-1);
+ if (len > 0) {
+ p->lex.pcur += len - 1;
+ }
+ return len;
+}
+
/* return value is for ?\u3042 */
static void
tokadd_utf8(struct parser_params *p, rb_encoding **encp,
@@ -7269,47 +7881,75 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp,
if (regexp_literal) { tokadd(p, '\\'); tokadd(p, 'u'); }
if (peek(p, open_brace)) { /* handle \u{...} form */
- const char *second = NULL;
- int c, last = nextc(p);
- if (p->lex.pcur >= p->lex.pend) goto unterminated;
- while (ISSPACE(c = *p->lex.pcur) && ++p->lex.pcur < p->lex.pend);
- while (c != close_brace) {
- if (c == term) goto unterminated;
- if (second == multiple_codepoints)
- second = p->lex.pcur;
- if (regexp_literal) tokadd(p, last);
- if (!tokadd_codepoint(p, encp, regexp_literal, TRUE)) {
- break;
- }
- while (ISSPACE(c = *p->lex.pcur)) {
- if (++p->lex.pcur >= p->lex.pend) goto unterminated;
- last = c;
+ if (regexp_literal && p->lex.strterm->u.literal.func == str_regexp) {
+ /*
+ * Skip parsing validation code and copy bytes as-is until term or
+ * closing brace, in order to correctly handle extended regexps where
+ * invalid unicode escapes are allowed in comments. The regexp parser
+ * does its own validation and will catch any issues.
+ */
+ tokadd(p, open_brace);
+ while (!lex_eol_ptr_p(p, ++p->lex.pcur)) {
+ int c = peekc(p);
+ if (c == close_brace) {
+ tokadd(p, c);
+ ++p->lex.pcur;
+ break;
+ }
+ else if (c == term) {
+ break;
+ }
+ if (c == '\\' && !lex_eol_n_p(p, 1)) {
+ tokadd(p, c);
+ c = *++p->lex.pcur;
+ }
+ tokadd_mbchar(p, c);
}
- if (term == -1 && !second)
- second = multiple_codepoints;
}
+ else {
+ const char *second = NULL;
+ int c, last = nextc(p);
+ if (lex_eol_p(p)) goto unterminated;
+ while (ISSPACE(c = peekc(p)) && !lex_eol_ptr_p(p, ++p->lex.pcur));
+ while (c != close_brace) {
+ if (c == term) goto unterminated;
+ if (second == multiple_codepoints)
+ second = p->lex.pcur;
+ if (regexp_literal) tokadd(p, last);
+ if (!tokadd_codepoint(p, encp, regexp_literal, NULL)) {
+ break;
+ }
+ while (ISSPACE(c = peekc(p))) {
+ if (lex_eol_ptr_p(p, ++p->lex.pcur)) goto unterminated;
+ last = c;
+ }
+ if (term == -1 && !second)
+ second = multiple_codepoints;
+ }
- if (c != close_brace) {
- unterminated:
- token_flush(p);
- yyerror0("unterminated Unicode escape");
- return;
- }
- if (second && second != multiple_codepoints) {
- const char *pcur = p->lex.pcur;
- p->lex.pcur = second;
- dispatch_scan_event(p, tSTRING_CONTENT);
- token_flush(p);
- p->lex.pcur = pcur;
- yyerror0(multiple_codepoints);
- token_flush(p);
- }
+ if (c != close_brace) {
+ unterminated:
+ flush_string_content(p, rb_utf8_encoding(), 0);
+ yyerror0("unterminated Unicode escape");
+ dispatch_scan_event(p, tSTRING_CONTENT);
+ return;
+ }
+ if (second && second != multiple_codepoints) {
+ const char *pcur = p->lex.pcur;
+ p->lex.pcur = second;
+ dispatch_scan_event(p, tSTRING_CONTENT);
+ token_flush(p);
+ p->lex.pcur = pcur;
+ yyerror0(multiple_codepoints);
+ token_flush(p);
+ }
- if (regexp_literal) tokadd(p, close_brace);
- nextc(p);
+ if (regexp_literal) tokadd(p, close_brace);
+ nextc(p);
+ }
}
else { /* handle \uxxxx form */
- if (!tokadd_codepoint(p, encp, regexp_literal, FALSE)) {
+ if (!tokadd_codepoint(p, encp, regexp_literal, p->lex.pcur - rb_strlen_lit("\\u"))) {
token_flush(p);
return;
}
@@ -7320,7 +7960,7 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp,
#define ESCAPE_META 2
static int
-read_escape(struct parser_params *p, int flags, rb_encoding **encp)
+read_escape(struct parser_params *p, int flags, const char *begin)
{
int c;
size_t numlen;
@@ -7353,7 +7993,7 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
pushback(p, c);
- c = scan_oct(p->lex.pcur, 3, &numlen);
+ c = (int)ruby_scan_oct(p->lex.pcur, 3, &numlen);
p->lex.pcur += numlen;
return c;
@@ -7379,9 +8019,13 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
nextc(p);
goto eof;
}
- return read_escape(p, flags|ESCAPE_META, encp) | 0x80;
+ return read_escape(p, flags|ESCAPE_META, begin) | 0x80;
+ }
+ else if (c == -1) goto eof;
+ else if (!ISASCII(c)) {
+ tokskip_mbchar(p);
+ goto eof;
}
- else if (c == -1 || !ISASCII(c)) goto eof;
else {
int c2 = escaped_control_code(c);
if (c2) {
@@ -7408,11 +8052,15 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
nextc(p);
goto eof;
}
- c = read_escape(p, flags|ESCAPE_CONTROL, encp);
+ c = read_escape(p, flags|ESCAPE_CONTROL, begin);
}
else if (c == '?')
return 0177;
- else if (c == -1 || !ISASCII(c)) goto eof;
+ else if (c == -1) goto eof;
+ else if (!ISASCII(c)) {
+ tokskip_mbchar(p);
+ goto eof;
+ }
else {
int c2 = escaped_control_code(c);
if (c2) {
@@ -7439,11 +8087,16 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
eof:
case -1:
+ flush_string_content(p, p->enc, p->lex.pcur - begin);
yyerror0("Invalid escape character syntax");
- token_flush(p);
+ dispatch_scan_event(p, tSTRING_CONTENT);
return '\0';
default:
+ if (!ISASCII(c)) {
+ tokskip_mbchar(p);
+ goto eof;
+ }
return c;
}
}
@@ -7456,10 +8109,11 @@ tokaddmbc(struct parser_params *p, int c, rb_encoding *enc)
}
static int
-tokadd_escape(struct parser_params *p, rb_encoding **encp)
+tokadd_escape(struct parser_params *p)
{
int c;
size_t numlen;
+ const char *begin = p->lex.pcur;
switch (c = nextc(p)) {
case '\n':
@@ -7485,6 +8139,7 @@ tokadd_escape(struct parser_params *p, rb_encoding **encp)
eof:
case -1:
+ flush_string_content(p, p->enc, p->lex.pcur - begin);
yyerror0("Invalid escape character syntax");
token_flush(p);
return -1;
@@ -7497,6 +8152,61 @@ tokadd_escape(struct parser_params *p, rb_encoding **encp)
}
static int
+char_to_option(int c)
+{
+ int val;
+
+ switch (c) {
+ case 'i':
+ val = RE_ONIG_OPTION_IGNORECASE;
+ break;
+ case 'x':
+ val = RE_ONIG_OPTION_EXTEND;
+ break;
+ case 'm':
+ val = RE_ONIG_OPTION_MULTILINE;
+ break;
+ default:
+ val = 0;
+ break;
+ }
+ return val;
+}
+
+#define ARG_ENCODING_FIXED 16
+#define ARG_ENCODING_NONE 32
+#define ENC_ASCII8BIT 1
+#define ENC_EUC_JP 2
+#define ENC_Windows_31J 3
+#define ENC_UTF8 4
+
+static int
+char_to_option_kcode(int c, int *option, int *kcode)
+{
+ *option = 0;
+
+ switch (c) {
+ case 'n':
+ *kcode = ENC_ASCII8BIT;
+ return (*option = ARG_ENCODING_NONE);
+ case 'e':
+ *kcode = ENC_EUC_JP;
+ break;
+ case 's':
+ *kcode = ENC_Windows_31J;
+ break;
+ case 'u':
+ *kcode = ENC_UTF8;
+ break;
+ default:
+ *kcode = -1;
+ return (*option = char_to_option(c));
+ }
+ *option = ARG_ENCODING_FIXED;
+ return 1;
+}
+
+static int
regx_options(struct parser_params *p)
{
int kcode = 0;
@@ -7509,9 +8219,9 @@ regx_options(struct parser_params *p)
if (c == 'o') {
options |= RE_OPTION_ONCE;
}
- else if (rb_char_to_option_kcode(c, &opt, &kc)) {
+ else if (char_to_option_kcode(c, &opt, &kc)) {
if (kc >= 0) {
- if (kc != rb_ascii8bit_encindex()) kcode = c;
+ if (kc != ENC_ASCII8BIT) kcode = c;
kopt = opt;
}
else {
@@ -7580,6 +8290,10 @@ parser_update_heredoc_indent(struct parser_params *p, int c)
}
p->heredoc_line_indent = -1;
}
+ else {
+ /* Whitespace only line has no indentation */
+ p->heredoc_line_indent = 0;
+ }
}
return FALSE;
}
@@ -7602,6 +8316,13 @@ parser_mixed_escape(struct parser_params *p, const char *beg, rb_encoding *enc1,
p->lex.pcur = pos;
}
+static inline char
+nibble_char_upper(unsigned int c)
+{
+ c &= 0xf;
+ return c + (c < 10 ? '0' : 'A' - 10);
+}
+
static int
tokadd_string(struct parser_params *p,
int func, int term, int paren, long *nest,
@@ -7640,8 +8361,8 @@ tokadd_string(struct parser_params *p,
}
--*nest;
}
- else if ((func & STR_FUNC_EXPAND) && c == '#' && p->lex.pcur < p->lex.pend) {
- int c2 = *p->lex.pcur;
+ else if ((func & STR_FUNC_EXPAND) && c == '#' && !lex_eol_p(p)) {
+ unsigned char c2 = *p->lex.pcur;
if (c2 == '$' || c2 == '@' || c2 == '{') {
pushback(p, c);
break;
@@ -7689,14 +8410,13 @@ tokadd_string(struct parser_params *p,
case 'C':
case 'M': {
pushback(p, c);
- c = read_escape(p, 0, enc);
+ c = read_escape(p, 0, p->lex.pcur - 1);
- int i;
- char escbuf[5];
- snprintf(escbuf, sizeof(escbuf), "\\x%02X", c);
- for (i = 0; i < 4; i++) {
- tokadd(p, escbuf[i]);
- }
+ char *t = tokspace(p, rb_strlen_lit("\\x00"));
+ *t++ = '\\';
+ *t++ = 'x';
+ *t++ = nibble_char_upper(c >> 4);
+ *t++ = nibble_char_upper(c);
continue;
}
}
@@ -7706,7 +8426,7 @@ tokadd_string(struct parser_params *p,
continue;
}
pushback(p, c);
- if ((c = tokadd_escape(p, enc)) < 0)
+ if ((c = tokadd_escape(p)) < 0)
return -1;
if (*enc && *enc != *encp) {
mixed_escape(p->lex.ptok+2, *enc, *encp);
@@ -7716,7 +8436,7 @@ tokadd_string(struct parser_params *p,
else if (func & STR_FUNC_EXPAND) {
pushback(p, c);
if (func & STR_FUNC_ESCAPE) tokadd(p, '\\');
- c = read_escape(p, 0, enc);
+ c = read_escape(p, 0, p->lex.pcur - 1);
}
else if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
/* ignore backslashed spaces in %w */
@@ -7763,45 +8483,16 @@ tokadd_string(struct parser_params *p,
return c;
}
-static inline rb_strterm_t *
-new_strterm(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
-{
- return (rb_strterm_t*)rb_imemo_new(imemo_parser_strterm, v1, v2, v3, v0);
-}
-
-/* imemo_parser_strterm for literal */
-#define NEW_STRTERM(func, term, paren) \
- new_strterm((VALUE)(func), (VALUE)(paren), (VALUE)(term), 0)
+#define NEW_STRTERM(func, term, paren) new_strterm(p, func, term, paren)
-#ifdef RIPPER
static void
-flush_string_content(struct parser_params *p, rb_encoding *enc)
+flush_string_content(struct parser_params *p, rb_encoding *enc, size_t back)
{
- VALUE content = yylval.val;
- if (!ripper_is_node_yylval(content))
- content = ripper_new_yylval(p, 0, 0, content);
+ p->lex.pcur -= back;
if (has_delayed_token(p)) {
ptrdiff_t len = p->lex.pcur - p->lex.ptok;
if (len > 0) {
- rb_enc_str_buf_cat(p->delayed.token, p->lex.ptok, len, enc);
- }
- dispatch_delayed_token(p, tSTRING_CONTENT);
- p->lex.ptok = p->lex.pcur;
- RNODE(content)->nd_rval = yylval.val;
- }
- dispatch_scan_event(p, tSTRING_CONTENT);
- if (yylval.val != content)
- RNODE(content)->nd_rval = yylval.val;
- yylval.val = content;
-}
-#else
-static void
-flush_string_content(struct parser_params *p, rb_encoding *enc)
-{
- if (has_delayed_token(p)) {
- ptrdiff_t len = p->lex.pcur - p->lex.ptok;
- if (len > 0) {
- rb_enc_str_buf_cat(p->delayed.token, p->lex.ptok, len, enc);
+ rb_parser_enc_str_buf_cat(p, p->delayed.token, p->lex.ptok, len, enc);
p->delayed.end_line = p->ruby_sourceline;
p->delayed.end_col = rb_long2int(p->lex.pcur - p->lex.pbeg);
}
@@ -7809,10 +8500,9 @@ flush_string_content(struct parser_params *p, rb_encoding *enc)
p->lex.ptok = p->lex.pcur;
}
dispatch_scan_event(p, tSTRING_CONTENT);
+ p->lex.pcur += back;
}
-#endif
-RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
/* this can be shared with ripper, since it's independent from struct
* parser_params. */
#ifndef RIPPER
@@ -7824,7 +8514,7 @@ RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 +
BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
BIT('0', idx))
-const unsigned int ruby_global_name_punct_bits[] = {
+const uint_least32_t ruby_global_name_punct_bits[] = {
SPECIAL_PUNCT(0),
SPECIAL_PUNCT(1),
SPECIAL_PUNCT(2),
@@ -7839,12 +8529,12 @@ parser_peek_variable_name(struct parser_params *p)
int c;
const char *ptr = p->lex.pcur;
- if (ptr + 1 >= p->lex.pend) return 0;
+ if (lex_eol_ptr_n_p(p, ptr, 1)) return 0;
c = *ptr++;
switch (c) {
case '$':
if ((c = *ptr) == '-') {
- if (++ptr >= p->lex.pend) return 0;
+ if (lex_eol_ptr_p(p, ++ptr)) return 0;
c = *ptr;
}
else if (is_global_name_punct(c) || ISDIGIT(c)) {
@@ -7853,13 +8543,14 @@ parser_peek_variable_name(struct parser_params *p)
break;
case '@':
if ((c = *ptr) == '@') {
- if (++ptr >= p->lex.pend) return 0;
+ if (lex_eol_ptr_p(p, ++ptr)) return 0;
c = *ptr;
}
break;
case '{':
p->lex.pcur = ptr;
p->command_start = TRUE;
+ yylval.state = p->lex.state;
return tSTRING_DBEG;
default:
return 0;
@@ -7882,6 +8573,7 @@ parser_peek_variable_name(struct parser_params *p)
static inline enum yytokentype
parser_string_term(struct parser_params *p, int func)
{
+ xfree(p->lex.strterm);
p->lex.strterm = 0;
if (func & STR_FUNC_REGEXP) {
set_yylval_num(regx_options(p));
@@ -7901,63 +8593,65 @@ parser_string_term(struct parser_params *p, int func)
static enum yytokentype
parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
{
- int func = (int)quote->u1.func;
- int term = (int)quote->u3.term;
- int paren = (int)quote->u2.paren;
+ int func = quote->func;
+ int term = quote->term;
+ int paren = quote->paren;
int c, space = 0;
rb_encoding *enc = p->enc;
rb_encoding *base_enc = 0;
- VALUE lit;
+ rb_parser_string_t *lit;
if (func & STR_FUNC_TERM) {
if (func & STR_FUNC_QWORDS) nextc(p); /* delayed term */
SET_LEX_STATE(EXPR_END);
+ xfree(p->lex.strterm);
p->lex.strterm = 0;
return func & STR_FUNC_REGEXP ? tREGEXP_END : tSTRING_END;
}
c = nextc(p);
if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
- do {c = nextc(p);} while (ISSPACE(c));
+ while (c != '\n' && ISSPACE(c = nextc(p)));
space = 1;
}
if (func & STR_FUNC_LIST) {
- quote->u1.func &= ~STR_FUNC_LIST;
+ quote->func &= ~STR_FUNC_LIST;
space = 1;
}
- if (c == term && !quote->u0.nest) {
+ if (c == term && !quote->nest) {
if (func & STR_FUNC_QWORDS) {
- quote->u1.func |= STR_FUNC_TERM;
+ quote->func |= STR_FUNC_TERM;
pushback(p, c); /* dispatch the term at tSTRING_END */
- add_delayed_token(p, p->lex.ptok, p->lex.pcur, __LINE__);
+ add_delayed_token(p, p->lex.ptok, p->lex.pcur);
return ' ';
}
return parser_string_term(p, func);
}
if (space) {
- pushback(p, c);
- add_delayed_token(p, p->lex.ptok, p->lex.pcur, __LINE__);
+ if (!ISSPACE(c)) pushback(p, c);
+ add_delayed_token(p, p->lex.ptok, p->lex.pcur);
return ' ';
}
newtok(p);
if ((func & STR_FUNC_EXPAND) && c == '#') {
- int t = parser_peek_variable_name(p);
+ enum yytokentype t = parser_peek_variable_name(p);
if (t) return t;
tokadd(p, '#');
c = nextc(p);
}
pushback(p, c);
- if (tokadd_string(p, func, term, paren, &quote->u0.nest,
+ if (tokadd_string(p, func, term, paren, &quote->nest,
&enc, &base_enc) == -1) {
if (p->eofp) {
#ifndef RIPPER
# define unterminated_literal(mesg) yyerror0(mesg)
#else
-# define unterminated_literal(mesg) compile_error(p, mesg)
+# define unterminated_literal(mesg) compile_error(p, mesg)
#endif
literal_flush(p, p->lex.pcur);
if (func & STR_FUNC_QWORDS) {
/* no content to add, bailing out here */
unterminated_literal("unterminated list meets end of file");
+ xfree(p->lex.strterm);
p->lex.strterm = 0;
return tSTRING_END;
}
@@ -7967,14 +8661,14 @@ parse_string(struct parser_params *p, rb_strterm_literal_t *quote)
else {
unterminated_literal("unterminated string meets end of file");
}
- quote->u1.func |= STR_FUNC_TERM;
+ quote->func |= STR_FUNC_TERM;
}
}
tokfix(p);
lit = STR_NEW3(tok(p), toklen(p), enc, func);
set_yylval_str(lit);
- flush_string_content(p, enc);
+ flush_string_content(p, enc, 0);
return tSTRING_CONTENT;
}
@@ -8048,14 +8742,14 @@ heredoc_identifier(struct parser_params *p)
dispatch_scan_event(p, tHEREDOC_BEG);
lex_goto_eol(p);
- p->lex.strterm = new_strterm(0, 0, 0, p->lex.lastline);
- p->lex.strterm->flags |= STRTERM_HEREDOC;
+ p->lex.strterm = new_heredoc(p);
rb_strterm_heredoc_t *here = &p->lex.strterm->u.heredoc;
here->offset = offset;
here->sourceline = p->ruby_sourceline;
- here->length = (int)len;
+ here->length = (unsigned)len;
here->quote = quote;
here->func = func;
+ here->lastline = p->lex.lastline;
token_flush(p);
p->heredoc_indent = indent;
@@ -8066,29 +8760,28 @@ heredoc_identifier(struct parser_params *p)
static void
heredoc_restore(struct parser_params *p, rb_strterm_heredoc_t *here)
{
- VALUE line;
+ rb_parser_string_t *line;
+ rb_strterm_t *term = p->lex.strterm;
p->lex.strterm = 0;
line = here->lastline;
p->lex.lastline = line;
- p->lex.pbeg = RSTRING_PTR(line);
- p->lex.pend = p->lex.pbeg + RSTRING_LEN(line);
+ p->lex.pbeg = PARSER_STRING_PTR(line);
+ p->lex.pend = p->lex.pbeg + PARSER_STRING_LEN(line);
p->lex.pcur = p->lex.pbeg + here->offset + here->length + here->quote;
p->lex.ptok = p->lex.pbeg + here->offset - here->quote;
p->heredoc_end = p->ruby_sourceline;
p->ruby_sourceline = (int)here->sourceline;
- if (p->eofp) p->lex.nextline = Qnil;
+ if (p->eofp) p->lex.nextline = AFTER_HEREDOC_WITHOUT_TERMINATOR;
p->eofp = 0;
+ xfree(term);
}
static int
-dedent_string(VALUE string, int width)
+dedent_string_column(const char *str, long len, int width)
{
- char *str;
- long len;
int i, col = 0;
- RSTRING_GETMEM(string, str, len);
for (i = 0; i < len && col < width; i++) {
if (str[i] == ' ') {
col++;
@@ -8102,35 +8795,49 @@ dedent_string(VALUE string, int width)
break;
}
}
+
+ return i;
+}
+
+static int
+dedent_string(struct parser_params *p, rb_parser_string_t *string, int width)
+{
+ char *str;
+ long len;
+ int i;
+
+ len = PARSER_STRING_LEN(string);
+ str = PARSER_STRING_PTR(string);
+
+ i = dedent_string_column(str, len, width);
if (!i) return 0;
- rb_str_modify(string);
- str = RSTRING_PTR(string);
- if (RSTRING_LEN(string) != len)
- rb_fatal("literal string changed: %+"PRIsVALUE, string);
+
+ rb_parser_str_modify(string);
+ str = PARSER_STRING_PTR(string);
+ if (PARSER_STRING_LEN(string) != len)
+ rb_fatal("literal string changed: %s", PARSER_STRING_PTR(string));
MEMMOVE(str, str + i, char, len - i);
- rb_str_set_len(string, len - i);
+ rb_parser_str_set_len(p, string, len - i);
return i;
}
-#ifndef RIPPER
static NODE *
heredoc_dedent(struct parser_params *p, NODE *root)
{
NODE *node, *str_node, *prev_node;
int indent = p->heredoc_indent;
- VALUE prev_lit = 0;
+ rb_parser_string_t *prev_lit = 0;
if (indent <= 0) return root;
- p->heredoc_indent = 0;
if (!root) return root;
prev_node = node = str_node = root;
- if (nd_type_p(root, NODE_LIST)) str_node = root->nd_head;
+ if (nd_type_p(root, NODE_LIST)) str_node = RNODE_LIST(root)->nd_head;
while (str_node) {
- VALUE lit = str_node->nd_lit;
- if (str_node->flags & NODE_FL_NEWLINE) {
- dedent_string(lit, indent);
+ rb_parser_string_t *lit = RNODE_STR(str_node)->string;
+ if (nd_fl_newline(str_node)) {
+ dedent_string(p, lit, indent);
}
if (!prev_lit) {
prev_lit = lit;
@@ -8139,22 +8846,22 @@ heredoc_dedent(struct parser_params *p, NODE *root)
return 0;
}
else {
- NODE *end = node->nd_end;
- node = prev_node->nd_next = node->nd_next;
+ NODE *end = RNODE_LIST(node)->as.nd_end;
+ node = RNODE_LIST(prev_node)->nd_next = RNODE_LIST(node)->nd_next;
if (!node) {
if (nd_type_p(prev_node, NODE_DSTR))
nd_set_type(prev_node, NODE_STR);
break;
}
- node->nd_end = end;
+ RNODE_LIST(node)->as.nd_end = end;
goto next_str;
}
str_node = 0;
- while ((node = (prev_node = node)->nd_next) != 0) {
+ while ((nd_type_p(node, NODE_LIST) || nd_type_p(node, NODE_DSTR)) && (node = RNODE_LIST(prev_node = node)->nd_next) != 0) {
next_str:
if (!nd_type_p(node, NODE_LIST)) break;
- if ((str_node = node->nd_head) != 0) {
+ if ((str_node = RNODE_LIST(node)->nd_head) != 0) {
enum node_type type = nd_type(str_node);
if (type == NODE_STR || type == NODE_DSTR) break;
prev_lit = 0;
@@ -8164,62 +8871,30 @@ heredoc_dedent(struct parser_params *p, NODE *root)
}
return root;
}
-#else /* RIPPER */
-static VALUE
-heredoc_dedent(struct parser_params *p, VALUE array)
-{
- int indent = p->heredoc_indent;
-
- if (indent <= 0) return array;
- p->heredoc_indent = 0;
- dispatch2(heredoc_dedent, array, INT2NUM(indent));
- return array;
-}
-
-/*
- * call-seq:
- * Ripper.dedent_string(input, width) -> Integer
- *
- * USE OF RIPPER LIBRARY ONLY.
- *
- * Strips up to +width+ leading whitespaces from +input+,
- * and returns the stripped column width.
- */
-static VALUE
-parser_dedent_string(VALUE self, VALUE input, VALUE width)
-{
- int wid, col;
-
- StringValue(input);
- wid = NUM2UINT(width);
- col = dedent_string(input, wid);
- return INT2NUM(col);
-}
-#endif
static int
whole_match_p(struct parser_params *p, const char *eos, long len, int indent)
{
- const char *ptr = p->lex.pbeg;
- long n;
+ const char *beg = p->lex.pbeg;
+ const char *ptr = p->lex.pend;
- if (indent) {
- while (*ptr && ISSPACE(*ptr)) ptr++;
+ if (ptr - beg < len) return FALSE;
+ if (ptr > beg && ptr[-1] == '\n') {
+ if (--ptr > beg && ptr[-1] == '\r') --ptr;
+ if (ptr - beg < len) return FALSE;
}
- n = p->lex.pend - (ptr + len);
- if (n < 0) return FALSE;
- if (n > 0 && ptr[len] != '\n') {
- if (ptr[len] != '\r') return FALSE;
- if (n <= 1 || ptr[len+1] != '\n') return FALSE;
+ if (strncmp(eos, ptr -= len, len)) return FALSE;
+ if (indent) {
+ while (beg < ptr && ISSPACE(*beg)) beg++;
}
- return strncmp(eos, ptr, len) == 0;
+ return beg == ptr;
}
static int
word_match_p(struct parser_params *p, const char *word, long len)
{
if (strncmp(p->lex.pcur, word, len)) return 0;
- if (p->lex.pcur + len == p->lex.pend) return 1;
+ if (lex_eol_n_p(p, len)) return 1;
int c = (unsigned char)p->lex.pcur[len];
if (ISSPACE(c)) return 1;
switch (c) {
@@ -8253,7 +8928,6 @@ number_literal_suffix(struct parser_params *p, int mask)
}
if (!ISASCII(c) || ISALPHA(c) || c == '_') {
p->lex.pcur = lastp;
- literal_flush(p, p->lex.pcur);
return 0;
}
pushback(p, c);
@@ -8263,44 +8937,43 @@ number_literal_suffix(struct parser_params *p, int mask)
}
static enum yytokentype
-set_number_literal(struct parser_params *p, VALUE v,
- enum yytokentype type, int suffix)
+set_number_literal(struct parser_params *p, enum yytokentype type, int suffix, int base, int seen_point)
{
- if (suffix & NUM_SUFFIX_I) {
- v = rb_complex_raw(INT2FIX(0), v);
- type = tIMAGINARY;
+ enum rb_numeric_type numeric_type = integer_literal;
+
+ if (type == tFLOAT) {
+ numeric_type = float_literal;
}
- set_yylval_literal(v);
- SET_LEX_STATE(EXPR_END);
- return type;
-}
-static enum yytokentype
-set_integer_literal(struct parser_params *p, VALUE v, int suffix)
-{
- enum yytokentype type = tINTEGER;
if (suffix & NUM_SUFFIX_R) {
- v = rb_rational_raw1(v);
type = tRATIONAL;
+ numeric_type = rational_literal;
+ }
+ if (suffix & NUM_SUFFIX_I) {
+ type = tIMAGINARY;
}
- return set_number_literal(p, v, type, suffix);
-}
-#ifdef RIPPER
-static void
-dispatch_heredoc_end(struct parser_params *p)
-{
- VALUE str;
- if (has_delayed_token(p))
- dispatch_delayed_token(p, tSTRING_CONTENT);
- str = STR_NEW(p->lex.ptok, p->lex.pend - p->lex.ptok);
- ripper_dispatch1(p, ripper_token2eventid(tHEREDOC_END), str);
- RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(*p->yylloc);
- lex_goto_eol(p);
- token_flush(p);
+ switch (type) {
+ case tINTEGER:
+ set_yylval_node(NEW_INTEGER(strdup(tok(p)), base, &_cur_loc));
+ break;
+ case tFLOAT:
+ set_yylval_node(NEW_FLOAT(strdup(tok(p)), &_cur_loc));
+ break;
+ case tRATIONAL:
+ set_yylval_node(NEW_RATIONAL(strdup(tok(p)), base, seen_point, &_cur_loc));
+ break;
+ case tIMAGINARY:
+ set_yylval_node(NEW_IMAGINARY(strdup(tok(p)), base, seen_point, numeric_type, &_cur_loc));
+ (void)numeric_type; /* for ripper */
+ break;
+ default:
+ rb_bug("unexpected token: %d", type);
+ }
+ SET_LEX_STATE(EXPR_END);
+ return type;
}
-#else
#define dispatch_heredoc_end(p) parser_dispatch_heredoc_end(p, __LINE__)
static void
parser_dispatch_heredoc_end(struct parser_params *p, int line)
@@ -8308,17 +8981,21 @@ parser_dispatch_heredoc_end(struct parser_params *p, int line)
if (has_delayed_token(p))
dispatch_delayed_token(p, tSTRING_CONTENT);
+#ifdef RIPPER
+ VALUE str = STR_NEW(p->lex.ptok, p->lex.pend - p->lex.ptok);
+ ripper_dispatch1(p, ripper_token2eventid(tHEREDOC_END), str);
+#else
if (p->keep_tokens) {
- VALUE str = STR_NEW(p->lex.ptok, p->lex.pend - p->lex.ptok);
+ rb_parser_string_t *str = rb_parser_encoding_string_new(p, p->lex.ptok, p->lex.pend - p->lex.ptok, p->enc);
RUBY_SET_YYLLOC_OF_HEREDOC_END(*p->yylloc);
parser_append_tokens(p, str, tHEREDOC_END, line);
}
+#endif
RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(*p->yylloc);
lex_goto_eol(p);
token_flush(p);
}
-#endif
static enum yytokentype
here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
@@ -8326,12 +9003,15 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
int c, func, indent = 0;
const char *eos, *ptr, *ptr_end;
long len;
- VALUE str = 0;
+ rb_parser_string_t *str = 0;
rb_encoding *enc = p->enc;
rb_encoding *base_enc = 0;
int bol;
+#ifdef RIPPER
+ VALUE s_value;
+#endif
- eos = RSTRING_PTR(here->lastline) + here->offset;
+ eos = PARSER_STRING_PTR(here->lastline) + here->offset;
len = here->length;
indent = (func = here->func) & STR_FUNC_INDENT;
@@ -8341,9 +9021,9 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
if (!has_delayed_token(p)) {
dispatch_scan_event(p, tSTRING_CONTENT);
}
- else {
+ else if (p->delayed.end_line + 1 == p->ruby_sourceline) {
if ((len = p->lex.pcur - p->lex.ptok) > 0) {
- if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) {
+ if (!(func & STR_FUNC_REGEXP)) {
int cr = ENC_CODERANGE_UNKNOWN;
rb_str_coderange_scan_restartable(p->lex.ptok, p->lex.pcur, enc, &cr);
if (cr != ENC_CODERANGE_7BIT &&
@@ -8352,17 +9032,20 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
enc = rb_ascii8bit_encoding();
}
}
- rb_enc_str_buf_cat(p->delayed.token, p->lex.ptok, len, enc);
+ rb_parser_enc_str_buf_cat(p, p->delayed.token, p->lex.ptok, len, enc);
}
dispatch_delayed_token(p, tSTRING_CONTENT);
}
+ else {
+ dispatch_delayed_token(p, tSTRING_CONTENT);
+ dispatch_scan_event(p, tSTRING_CONTENT);
+ }
lex_goto_eol(p);
#endif
heredoc_restore(p, &p->lex.strterm->u.heredoc);
compile_error(p, "can't find string \"%.*s\" anywhere before EOF",
(int)len, eos);
token_flush(p);
- p->lex.strterm = 0;
SET_LEX_STATE(EXPR_END);
return tSTRING_END;
}
@@ -8382,14 +9065,13 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
restore:
heredoc_restore(p, &p->lex.strterm->u.heredoc);
token_flush(p);
- p->lex.strterm = 0;
SET_LEX_STATE(EXPR_END);
return tSTRING_END;
}
if (!(func & STR_FUNC_EXPAND)) {
do {
- ptr = RSTRING_PTR(p->lex.lastline);
+ ptr = PARSER_STRING_PTR(p->lex.lastline);
ptr_end = p->lex.pend;
if (ptr_end > ptr) {
switch (ptr_end[-1]) {
@@ -8411,16 +9093,17 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
}
if (str)
- rb_str_cat(str, ptr, ptr_end - ptr);
+ parser_str_cat(str, ptr, ptr_end - ptr);
else
- str = STR_NEW(ptr, ptr_end - ptr);
- if (ptr_end < p->lex.pend) rb_str_cat(str, "\n", 1);
+ str = rb_parser_encoding_string_new(p, ptr, ptr_end - ptr, enc);
+ if (!lex_eol_ptr_p(p, ptr_end)) parser_str_cat_cstr(str, "\n");
lex_goto_eol(p);
if (p->heredoc_indent > 0) {
goto flush_str;
}
if (nextc(p) == -1) {
if (str) {
+ rb_parser_string_free(p, str);
str = 0;
}
goto error;
@@ -8431,7 +9114,7 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
/* int mb = ENC_CODERANGE_7BIT, *mbp = &mb;*/
newtok(p);
if (c == '#') {
- int t = parser_peek_variable_name(p);
+ enum yytokentype t = parser_peek_variable_name(p);
if (p->heredoc_line_indent != -1) {
if (p->heredoc_indent > p->heredoc_line_indent) {
p->heredoc_indent = p->heredoc_line_indent;
@@ -8456,9 +9139,9 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
flush_str:
set_yylval_str(str);
#ifndef RIPPER
- if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
+ if (bol) nd_set_fl_newline(yylval.node);
#endif
- flush_string_content(p, enc);
+ flush_string_content(p, enc, 0);
return tSTRING_CONTENT;
}
tokadd(p, nextc(p));
@@ -8472,16 +9155,20 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
str = STR_NEW3(tok(p), toklen(p), enc, func);
}
dispatch_heredoc_end(p);
-#ifdef RIPPER
- str = ripper_new_yylval(p, ripper_token2eventid(tSTRING_CONTENT),
- yylval.val, str);
-#endif
heredoc_restore(p, &p->lex.strterm->u.heredoc);
token_flush(p);
p->lex.strterm = NEW_STRTERM(func | STR_FUNC_TERM, 0, 0);
+#ifdef RIPPER
+ /* Preserve s_value for set_yylval_str */
+ s_value = p->s_value;
+#endif
set_yylval_str(str);
+#ifdef RIPPER
+ set_parser_s_value(s_value);
+#endif
+
#ifndef RIPPER
- if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
+ if (bol) nd_set_fl_newline(yylval.node);
#endif
return tSTRING_CONTENT;
}
@@ -8493,10 +9180,10 @@ arg_ambiguous(struct parser_params *p, char c)
{
#ifndef RIPPER
if (c == '/') {
- rb_warning1("ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `%c' operator", WARN_I(c));
+ rb_warning1("ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after '%c' operator", WARN_I(c));
}
else {
- rb_warning1("ambiguous first argument; put parentheses or a space even after `%c' operator", WARN_I(c));
+ rb_warning1("ambiguous first argument; put parentheses or a space even after '%c' operator", WARN_I(c));
}
#else
dispatch1(arg_ambiguous, rb_usascii_str_new(&c, 1));
@@ -8504,42 +9191,34 @@ arg_ambiguous(struct parser_params *p, char c)
return TRUE;
}
-static ID
-#ifndef RIPPER
-formal_argument(struct parser_params *p, ID lhs)
-#else
-formal_argument(struct parser_params *p, VALUE lhs)
-#endif
+/* returns true value if formal argument error;
+ * Qtrue, or error message if ripper */
+static VALUE
+formal_argument_error(struct parser_params *p, ID id)
{
- ID id = get_id(lhs);
-
switch (id_type(id)) {
case ID_LOCAL:
break;
#ifndef RIPPER
-# define ERR(mesg) yyerror0(mesg)
+# define ERR(mesg) (yyerror0(mesg), Qtrue)
#else
-# define ERR(mesg) (dispatch2(param_error, WARN_S(mesg), lhs), ripper_error(p))
+# define ERR(mesg) WARN_S(mesg)
#endif
case ID_CONST:
- ERR("formal argument cannot be a constant");
- return 0;
+ return ERR("formal argument cannot be a constant");
case ID_INSTANCE:
- ERR("formal argument cannot be an instance variable");
- return 0;
+ return ERR("formal argument cannot be an instance variable");
case ID_GLOBAL:
- ERR("formal argument cannot be a global variable");
- return 0;
+ return ERR("formal argument cannot be a global variable");
case ID_CLASS:
- ERR("formal argument cannot be a class variable");
- return 0;
+ return ERR("formal argument cannot be a class variable");
default:
- ERR("formal argument must be local variable");
- return 0;
+ return ERR("formal argument must be local variable");
#undef ERR
}
shadowing_lvar(p, id);
- return lhs;
+
+ return Qfalse;
}
static int
@@ -8572,17 +9251,33 @@ parser_encode_length(struct parser_params *p, const char *name, long len)
static void
parser_set_encode(struct parser_params *p, const char *name)
{
- int idx = rb_enc_find_index(name);
rb_encoding *enc;
VALUE excargs[3];
+ int idx = 0;
+ const char *wrong = 0;
+ switch (*name) {
+ case 'e': case 'E': wrong = "external"; break;
+ case 'i': case 'I': wrong = "internal"; break;
+ case 'f': case 'F': wrong = "filesystem"; break;
+ case 'l': case 'L': wrong = "locale"; break;
+ }
+ if (wrong && STRCASECMP(name, wrong) == 0) goto unknown;
+ idx = rb_enc_find_index(name);
if (idx < 0) {
+ unknown:
excargs[1] = rb_sprintf("unknown encoding name: %s", name);
error:
excargs[0] = rb_eArgError;
excargs[2] = rb_make_backtrace();
rb_ary_unshift(excargs[2], rb_sprintf("%"PRIsVALUE":%d", p->ruby_sourcefile_string, p->ruby_sourceline));
- rb_exc_raise(rb_make_exception(3, excargs));
+ VALUE exc = rb_make_exception(3, excargs);
+ ruby_show_error_line(p, exc, &(YYLTYPE)RUBY_INIT_YYLLOC(), p->ruby_sourceline, p->lex.lastline);
+
+ rb_ast_free(p->ast);
+ p->ast = NULL;
+
+ rb_exc_raise(exc);
}
enc = rb_enc_from_index(idx);
if (!rb_enc_asciicompat(enc)) {
@@ -8592,25 +9287,19 @@ parser_set_encode(struct parser_params *p, const char *name)
p->enc = enc;
#ifndef RIPPER
if (p->debug_lines) {
- VALUE lines = p->debug_lines;
- long i, n = RARRAY_LEN(lines);
- for (i = 0; i < n; ++i) {
- rb_enc_associate_index(RARRAY_AREF(lines, i), idx);
+ long i;
+ for (i = 0; i < p->debug_lines->len; i++) {
+ rb_parser_enc_associate(p, p->debug_lines->data[i], enc);
}
}
#endif
}
-static int
+static bool
comment_at_top(struct parser_params *p)
{
- const char *ptr = p->lex.pbeg, *ptr_end = p->lex.pcur - 1;
- if (p->line_count != (p->has_shebang ? 2 : 1)) return 0;
- while (ptr < ptr_end) {
- if (!ISSPACE(*ptr)) return 0;
- ptr++;
- }
- return 1;
+ if (p->token_seen) return false;
+ return (p->line_count == (p->has_shebang ? 2 : 1));
}
typedef long (*rb_magic_comment_length_t)(struct parser_params *p, const char *name, long len);
@@ -8660,22 +9349,19 @@ parser_set_token_info(struct parser_params *p, const char *name, const char *val
}
static void
-parser_set_compile_option_flag(struct parser_params *p, const char *name, const char *val)
+parser_set_frozen_string_literal(struct parser_params *p, const char *name, const char *val)
{
int b;
if (p->token_seen) {
- rb_warning1("`%s' is ignored after any tokens", WARN_S(name));
+ rb_warning1("'%s' is ignored after any tokens", WARN_S(name));
return;
}
b = parser_get_bool(p, name, val);
if (b < 0) return;
- if (!p->compile_option)
- p->compile_option = rb_obj_hide(rb_ident_hash_new());
- rb_hash_aset(p->compile_option, ID2SYM(rb_intern(name)),
- RBOOL(b));
+ p->frozen_string_literal = b;
}
static void
@@ -8684,30 +9370,30 @@ parser_set_shareable_constant_value(struct parser_params *p, const char *name, c
for (const char *s = p->lex.pbeg, *e = p->lex.pcur; s < e; ++s) {
if (*s == ' ' || *s == '\t') continue;
if (*s == '#') break;
- rb_warning1("`%s' is ignored unless in comment-only line", WARN_S(name));
+ rb_warning1("'%s' is ignored unless in comment-only line", WARN_S(name));
return;
}
switch (*val) {
case 'n': case 'N':
if (STRCASECMP(val, "none") == 0) {
- p->ctxt.shareable_constant_value = shareable_none;
+ p->ctxt.shareable_constant_value = rb_parser_shareable_none;
return;
}
break;
case 'l': case 'L':
if (STRCASECMP(val, "literal") == 0) {
- p->ctxt.shareable_constant_value = shareable_literal;
+ p->ctxt.shareable_constant_value = rb_parser_shareable_literal;
return;
}
break;
case 'e': case 'E':
if (STRCASECMP(val, "experimental_copy") == 0) {
- p->ctxt.shareable_constant_value = shareable_copy;
+ p->ctxt.shareable_constant_value = rb_parser_shareable_copy;
return;
}
if (STRCASECMP(val, "experimental_everything") == 0) {
- p->ctxt.shareable_constant_value = shareable_everything;
+ p->ctxt.shareable_constant_value = rb_parser_shareable_everything;
return;
}
break;
@@ -8733,7 +9419,7 @@ struct magic_comment {
static const struct magic_comment magic_comments[] = {
{"coding", magic_comment_encoding, parser_encode_length},
{"encoding", magic_comment_encoding, parser_encode_length},
- {"frozen_string_literal", parser_set_compile_option_flag},
+ {"frozen_string_literal", parser_set_frozen_string_literal},
{"shareable_constant_value", parser_set_shareable_constant_value},
{"warn_indent", parser_set_token_info},
# if WARN_PAST_SCOPE
@@ -8827,6 +9513,7 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
do str++; while (--len > 0 && ISSPACE(*str));
if (!len) break;
+ const char *tok_beg = str;
if (*str == '"') {
for (vbeg = ++str; --len > 0 && *str != '"'; str++) {
if (*str == '\\') {
@@ -8844,6 +9531,7 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
for (vbeg = str; len > 0 && *str != '"' && *str != ';' && !ISSPACE(*str); --len, str++);
vend = str;
}
+ const char *tok_end = str;
if (indicator) {
while (len > 0 && (*str == ';' || ISSPACE(*str))) --len, str++;
}
@@ -8865,6 +9553,8 @@ parser_magic_comment(struct parser_params *p, const char *str, long len)
n = (*mc->length)(p, vbeg, n);
}
str_copy(val, vbeg, n);
+ p->lex.ptok = tok_beg;
+ p->lex.pcur = tok_end;
(*mc->func)(p, mc->name, RSTRING_PTR(val));
break;
}
@@ -8918,6 +9608,8 @@ set_file_encoding(struct parser_params *p, const char *str, const char *send)
beg = str;
while ((*str == '-' || *str == '_' || ISALNUM(*str)) && ++str < send);
s = rb_str_new(beg, parser_encode_length(p, beg, str - beg));
+ p->lex.ptok = beg;
+ p->lex.pcur = str;
parser_set_encode(p, RSTRING_PTR(s));
rb_str_resize(s, 0);
}
@@ -8932,30 +9624,31 @@ parser_prepare(struct parser_params *p)
if (peek(p, '!')) p->has_shebang = 1;
break;
case 0xef: /* UTF-8 BOM marker */
- if (p->lex.pend - p->lex.pcur >= 2 &&
+ if (!lex_eol_n_p(p, 2) &&
(unsigned char)p->lex.pcur[0] == 0xbb &&
(unsigned char)p->lex.pcur[1] == 0xbf) {
p->enc = rb_utf8_encoding();
p->lex.pcur += 2;
#ifndef RIPPER
if (p->debug_lines) {
- rb_enc_associate(p->lex.lastline, p->enc);
+ rb_parser_string_set_encoding(p->lex.lastline, p->enc);
}
#endif
p->lex.pbeg = p->lex.pcur;
+ token_flush(p);
return;
}
break;
- case EOF:
+ case -1: /* end of script. */
return;
}
pushback(p, c);
- p->enc = rb_enc_get(p->lex.lastline);
+ p->enc = rb_parser_str_get_encoding(p->lex.lastline);
}
#ifndef RIPPER
#define ambiguous_operator(tok, op, syn) ( \
- rb_warning0("`"op"' after local variable or literal is interpreted as binary operator"), \
+ rb_warning0("'"op"' after local variable or literal is interpreted as binary operator"), \
rb_warning0("even though it seems like "syn""))
#else
#define ambiguous_operator(tok, op, syn) \
@@ -8967,24 +9660,13 @@ parser_prepare(struct parser_params *p)
(ambiguous_operator(tok, op, syn), 0)), \
(enum yytokentype)(tok))
-static VALUE
-parse_rational(struct parser_params *p, char *str, int len, int seen_point)
-{
- VALUE v;
- char *point = &str[seen_point];
- size_t fraclen = len-seen_point-1;
- memmove(point, point+1, fraclen+1);
- v = rb_cstr_to_inum(str, 10, FALSE);
- return rb_rational_new(v, rb_int_positive_pow(10, fraclen));
-}
-
static enum yytokentype
no_digits(struct parser_params *p)
{
yyerror0("numeric literal without digits");
if (peek(p, '_')) nextc(p);
/* dummy 0, for tUMINUS_NUM at numeric */
- return set_integer_literal(p, INT2FIX(0), 0);
+ return set_number_literal(p, tINTEGER, 0, 10, 0);
}
static enum yytokentype
@@ -9025,7 +9707,7 @@ parse_numeric(struct parser_params *p, int c)
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 16, FALSE), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 16, 0);
}
if (c == 'b' || c == 'B') {
/* binary */
@@ -9049,7 +9731,7 @@ parse_numeric(struct parser_params *p, int c)
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 2, FALSE), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 2, 0);
}
if (c == 'd' || c == 'D') {
/* decimal */
@@ -9073,7 +9755,7 @@ parse_numeric(struct parser_params *p, int c)
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 10, FALSE), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 10, 0);
}
if (c == '_') {
/* 0_0 */
@@ -9083,6 +9765,7 @@ parse_numeric(struct parser_params *p, int c)
/* prefixed octal */
c = nextc(p);
if (c == -1 || c == '_' || !ISDIGIT(c)) {
+ tokfix(p);
return no_digits(p);
}
}
@@ -9105,7 +9788,7 @@ parse_numeric(struct parser_params *p, int c)
tokfix(p);
if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 8, FALSE), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 8, 0);
}
if (nondigit) {
pushback(p, c);
@@ -9121,8 +9804,9 @@ parse_numeric(struct parser_params *p, int c)
}
else {
pushback(p, c);
+ tokfix(p);
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, INT2FIX(0), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 10, 0);
}
}
@@ -9168,6 +9852,7 @@ parse_numeric(struct parser_params *p, int c)
c = nextc(p);
if (c != '-' && c != '+' && !ISDIGIT(c)) {
pushback(p, c);
+ c = nondigit;
nondigit = 0;
goto decode_num;
}
@@ -9195,31 +9880,28 @@ parse_numeric(struct parser_params *p, int c)
trailing_uc:
literal_flush(p, p->lex.pcur - 1);
YYLTYPE loc = RUBY_INIT_YYLLOC();
- compile_error(p, "trailing `%c' in number", nondigit);
+ compile_error(p, "trailing '%c' in number", nondigit);
parser_show_error_line(p, &loc);
}
tokfix(p);
if (is_float) {
enum yytokentype type = tFLOAT;
- VALUE v;
suffix = number_literal_suffix(p, seen_e ? NUM_SUFFIX_I : NUM_SUFFIX_ALL);
if (suffix & NUM_SUFFIX_R) {
type = tRATIONAL;
- v = parse_rational(p, tok(p), toklen(p), seen_point);
}
else {
- double d = strtod(tok(p), 0);
+ strtod(tok(p), 0);
if (errno == ERANGE) {
rb_warning1("Float %s out of range", WARN_S(tok(p)));
errno = 0;
}
- v = DBL2NUM(d);
}
- return set_number_literal(p, v, type, suffix);
+ return set_number_literal(p, type, suffix, 0, seen_point);
}
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
- return set_integer_literal(p, rb_cstr_to_inum(tok(p), 10, FALSE), suffix);
+ return set_number_literal(p, tINTEGER, suffix, 10, 0);
}
static enum yytokentype
@@ -9227,7 +9909,8 @@ parse_qmark(struct parser_params *p, int space_seen)
{
rb_encoding *enc;
register int c;
- VALUE lit;
+ rb_parser_string_t *lit;
+ const char *start = p->lex.pcur;
if (IS_END()) {
SET_LEX_STATE(EXPR_VALUE);
@@ -9252,20 +9935,18 @@ parse_qmark(struct parser_params *p, int space_seen)
}
newtok(p);
enc = p->enc;
- if (!parser_isascii(p)) {
- if (tokadd_mbchar(p, c) == -1) return 0;
- }
- else if ((rb_enc_isalnum(c, p->enc) || c == '_') &&
- p->lex.pcur < p->lex.pend && is_identchar(p->lex.pcur, p->lex.pend, p->enc)) {
+ int w = parser_precise_mbclen(p, start);
+ if (is_identchar(p, start, p->lex.pend, p->enc) &&
+ !(lex_eol_ptr_n_p(p, start, w) || !is_identchar(p, start + w, p->lex.pend, p->enc))) {
if (space_seen) {
- const char *start = p->lex.pcur - 1, *ptr = start;
+ const char *ptr = start;
do {
int n = parser_precise_mbclen(p, ptr);
if (n < 0) return -1;
ptr += n;
- } while (ptr < p->lex.pend && is_identchar(ptr, p->lex.pend, p->enc));
- rb_warn2("`?' just followed by `%.*s' is interpreted as" \
- " a conditional operator, put a space after `?'",
+ } while (!lex_eol_ptr_p(p, ptr) && is_identchar(p, ptr, p->lex.pend, p->enc));
+ rb_warn2("'?' just followed by '%.*s' is interpreted as" \
+ " a conditional operator, put a space after '?'",
WARN_I((int)(ptr - start)), WARN_S_L(start, (ptr - start)));
}
goto ternary;
@@ -9276,17 +9957,17 @@ parse_qmark(struct parser_params *p, int space_seen)
enc = rb_utf8_encoding();
tokadd_utf8(p, &enc, -1, 0, 0);
}
- else if (!lex_eol_p(p) && !(c = *p->lex.pcur, ISASCII(c))) {
+ else if (!ISASCII(c = peekc(p)) && c != -1) {
nextc(p);
if (tokadd_mbchar(p, c) == -1) return 0;
}
else {
- c = read_escape(p, 0, &enc);
+ c = read_escape(p, 0, p->lex.pcur - rb_strlen_lit("?\\"));
tokadd(p, c);
}
}
else {
- tokadd(p, c);
+ if (tokadd_mbchar(p, c) == -1) return 0;
}
tokfix(p);
lit = STR_NEW3(tok(p), toklen(p), enc, 0);
@@ -9428,7 +10109,7 @@ parse_numvar(struct parser_params *p)
if (overflow || n > nth_ref_max) {
/* compile_error()? */
- rb_warn1("`%s' is too big for a number variable, always nil", WARN_S(tok(p)));
+ rb_warn1("'%s' is too big for a number variable, always nil", WARN_S(tok(p)));
return 0; /* $0 is $PROGRAM_NAME, not NTH_REF */
}
else {
@@ -9457,22 +10138,22 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
pushback(p, c);
c = '_';
/* fall through */
- case '~': /* $~: match-data */
- case '*': /* $*: argv */
- case '$': /* $$: pid */
- case '?': /* $?: last status */
- case '!': /* $!: error string */
- case '@': /* $@: error position */
- case '/': /* $/: input record separator */
- case '\\': /* $\: output record separator */
- case ';': /* $;: field separator */
- case ',': /* $,: output field separator */
- case '.': /* $.: last read line number */
- case '=': /* $=: ignorecase */
- case ':': /* $:: load path */
- case '<': /* $<: reading filename */
- case '>': /* $>: default output handle */
- case '\"': /* $": already loaded files */
+ case '~': /* $~: match-data */
+ case '*': /* $*: argv */
+ case '$': /* $$: pid */
+ case '?': /* $?: last status */
+ case '!': /* $!: error string */
+ case '@': /* $@: error position */
+ case '/': /* $/: input record separator */
+ case '\\': /* $\: output record separator */
+ case ';': /* $;: field separator */
+ case ',': /* $,: output field separator */
+ case '.': /* $.: last read line number */
+ case '=': /* $=: ignorecase */
+ case ':': /* $:: load path */
+ case '<': /* $<: default input handle */
+ case '>': /* $>: default output handle */
+ case '\"': /* $": already loaded files */
tokadd(p, '$');
tokadd(p, c);
goto gvar;
@@ -9490,13 +10171,13 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
return '$';
}
gvar:
- set_yylval_name(TOK_INTERN());
+ tokenize_ident(p);
return tGVAR;
- case '&': /* $&: last match */
- case '`': /* $`: string before last match */
- case '\'': /* $': string after last match */
- case '+': /* $+: string matches last paren. */
+ case '&': /* $&: last match */
+ case '`': /* $`: string before last match */
+ case '\'': /* $': string after last match */
+ case '+': /* $+: string matches last paren. */
if (IS_lex_state_for(last_state, EXPR_FNAME)) {
tokadd(p, '$');
tokadd(p, c);
@@ -9524,11 +10205,11 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
if (!parser_is_identchar(p)) {
YYLTYPE loc = RUBY_INIT_YYLLOC();
if (c == -1 || ISSPACE(c)) {
- compile_error(p, "`$' without identifiers is not allowed as a global variable name");
+ compile_error(p, "'$' without identifiers is not allowed as a global variable name");
}
else {
pushback(p, c);
- compile_error(p, "`$%c' is not allowed as a global variable name", c);
+ compile_error(p, "'$%c' is not allowed as a global variable name", c);
}
parser_show_error_line(p, &loc);
set_yylval_noname();
@@ -9541,11 +10222,16 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state)
if (tokadd_ident(p, c)) return 0;
SET_LEX_STATE(EXPR_END);
- tokenize_ident(p);
+ if (VALID_SYMNAME_P(tok(p), toklen(p), p->enc, ID_GLOBAL)) {
+ tokenize_ident(p);
+ }
+ else {
+ compile_error(p, "'%.*s' is not allowed as a global variable name", toklen(p), tok(p));
+ set_yylval_noname();
+ }
return tGVAR;
}
-#ifndef RIPPER
static bool
parser_numbered_param(struct parser_params *p, int n)
{
@@ -9567,7 +10253,6 @@ parser_numbered_param(struct parser_params *p, int n)
}
return true;
}
-#endif
static enum yytokentype
parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
@@ -9590,10 +10275,10 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
pushback(p, c);
RUBY_SET_YYLLOC(loc);
if (result == tIVAR) {
- compile_error(p, "`@' without identifiers is not allowed as an instance variable name");
+ compile_error(p, "'@' without identifiers is not allowed as an instance variable name");
}
else {
- compile_error(p, "`@@' without identifiers is not allowed as a class variable name");
+ compile_error(p, "'@@' without identifiers is not allowed as a class variable name");
}
parser_show_error_line(p, &loc);
set_yylval_noname();
@@ -9604,10 +10289,10 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state)
pushback(p, c);
RUBY_SET_YYLLOC(loc);
if (result == tIVAR) {
- compile_error(p, "`@%c' is not allowed as an instance variable name", c);
+ compile_error(p, "'@%c' is not allowed as an instance variable name", c);
}
else {
- compile_error(p, "`@@%c' is not allowed as a class variable name", c);
+ compile_error(p, "'@@%c' is not allowed as a class variable name", c);
}
parser_show_error_line(p, &loc);
set_yylval_noname();
@@ -9624,13 +10309,13 @@ static enum yytokentype
parse_ident(struct parser_params *p, int c, int cmd_state)
{
enum yytokentype result;
- int mb = ENC_CODERANGE_7BIT;
+ bool is_ascii = true;
const enum lex_state_e last_state = p->lex.state;
ID ident;
int enforce_keyword_end = 0;
do {
- if (!ISASCII(c)) mb = ENC_CODERANGE_UNKNOWN;
+ if (!ISASCII(c)) is_ascii = false;
if (tokadd_mbchar(p, c) == -1) return 0;
c = nextc(p);
} while (parser_is_identchar(p));
@@ -9653,20 +10338,20 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
if (IS_LABEL_SUFFIX(0)) {
SET_LEX_STATE(EXPR_ARG|EXPR_LABELED);
nextc(p);
- set_yylval_name(TOK_INTERN());
+ tokenize_ident(p);
return tLABEL;
}
}
#ifndef RIPPER
- if (!NIL_P(peek_end_expect_token_locations(p))) {
- VALUE end_loc;
+ if (peek_end_expect_token_locations(p)) {
+ const rb_code_position_t *end_pos;
int lineno, column;
int beg_pos = (int)(p->lex.ptok - p->lex.pbeg);
- end_loc = peek_end_expect_token_locations(p);
- lineno = NUM2INT(rb_ary_entry(end_loc, 0));
- column = NUM2INT(rb_ary_entry(end_loc, 1));
+ end_pos = peek_end_expect_token_locations(p)->pos;
+ lineno = end_pos->lineno;
+ column = end_pos->column;
if (p->debug) {
rb_parser_printf(p, "enforce_keyword_end check. current: (%d, %d), peek: (%d, %d)\n",
@@ -9684,7 +10369,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
}
#endif
- if (mb == ENC_CODERANGE_7BIT && (!IS_lex_state(EXPR_DOT) || enforce_keyword_end)) {
+ if (is_ascii && (!IS_lex_state(EXPR_DOT) || enforce_keyword_end)) {
const struct kwtable *kw;
/* See if it is a reserved word. */
@@ -9739,7 +10424,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
if (result == tCONSTANT && is_local_id(ident)) result = tIDENTIFIER;
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
- lvar_defined(p, ident)) {
+ (lvar_defined(p, ident) || NUMPARAM_ID_P(ident))) {
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
}
return result;
@@ -9767,7 +10452,7 @@ parser_yylex(struct parser_params *p)
int token_seen = p->token_seen;
if (p->lex.strterm) {
- if (p->lex.strterm->flags & STRTERM_HEREDOC) {
+ if (strterm_is_heredoc(p->lex.strterm)) {
token_flush(p);
return here_document(p, &p->lex.strterm->u.heredoc);
}
@@ -9789,9 +10474,9 @@ parser_yylex(struct parser_params *p)
case '\004': /* ^D */
case '\032': /* ^Z */
case -1: /* end of script. */
- p->eofp = 1;
+ p->eofp = 1;
#ifndef RIPPER
- if (!NIL_P(p->end_expect_token_locations) && RARRAY_LEN(p->end_expect_token_locations) > 0) {
+ if (p->end_expect_token_locations) {
pop_end_expect_token_locations(p);
RUBY_SET_YYLLOC_OF_DUMMY_END(*p->yylloc);
return tDUMNY_END;
@@ -9830,19 +10515,21 @@ parser_yylex(struct parser_params *p)
case '#': /* it's a comment */
p->token_seen = token_seen;
+ const char *const pcur = p->lex.pcur, *const ptok = p->lex.ptok;
/* no magic_comment in shebang line */
if (!parser_magic_comment(p, p->lex.pcur, p->lex.pend - p->lex.pcur)) {
if (comment_at_top(p)) {
set_file_encoding(p, p->lex.pcur, p->lex.pend);
}
}
+ p->lex.pcur = pcur, p->lex.ptok = ptok;
lex_goto_eol(p);
dispatch_scan_event(p, tCOMMENT);
fallthru = TRUE;
/* fall through */
case '\n':
p->token_seen = token_seen;
- VALUE prevline = p->lex.lastline;
+ rb_parser_string_t *prevline = p->lex.lastline;
c = (IS_lex_state(EXPR_BEG|EXPR_CLASS|EXPR_FNAME|EXPR_DOT) &&
!IS_lex_state(EXPR_LABELED));
if (c || IS_lex_state_all(EXPR_ARG|EXPR_LABELED)) {
@@ -9868,7 +10555,24 @@ parser_yylex(struct parser_params *p)
token_flush(p);
}
goto retry;
+ case 'a':
+ if (peek_word_at(p, "nd", 2, 0)) goto leading_logical;
+ goto bol;
+ case 'o':
+ if (peek_word_at(p, "r", 1, 0)) goto leading_logical;
+ goto bol;
+ case '|':
+ if (peek(p, '|')) goto leading_logical;
+ goto bol;
case '&':
+ if (peek(p, '&')) {
+ leading_logical:
+ pushback(p, c);
+ dispatch_delayed_token(p, tIGNORED_NL);
+ cmd_state = FALSE;
+ goto retry;
+ }
+ /* fall through */
case '.': {
dispatch_delayed_token(p, tIGNORED_NL);
if (peek(p, '.') == (c == '&')) {
@@ -9877,11 +10581,15 @@ parser_yylex(struct parser_params *p)
goto retry;
}
}
+ bol:
default:
p->ruby_sourceline--;
p->lex.nextline = p->lex.lastline;
set_lastline(p, prevline);
case -1: /* EOF no decrement*/
+ if (c == -1 && space_seen) {
+ dispatch_scan_event(p, tSP);
+ }
lex_goto_eol(p);
if (c != -1) {
token_flush(p);
@@ -9904,7 +10612,7 @@ parser_yylex(struct parser_params *p)
}
pushback(p, c);
if (IS_SPCARG(c)) {
- rb_warning0("`**' interpreted as argument prefix");
+ rb_warning0("'**' interpreted as argument prefix");
c = tDSTAR;
}
else if (IS_BEG()) {
@@ -9922,7 +10630,7 @@ parser_yylex(struct parser_params *p)
}
pushback(p, c);
if (IS_SPCARG(c)) {
- rb_warning0("`*' interpreted as argument prefix");
+ rb_warning0("'*' interpreted as argument prefix");
c = tSTAR;
}
else if (IS_BEG()) {
@@ -10008,7 +10716,7 @@ parser_yylex(struct parser_params *p)
!IS_lex_state(EXPR_DOT | EXPR_CLASS) &&
!IS_END() &&
(!IS_ARG() || IS_lex_state(EXPR_LABELED) || space_seen)) {
- int token = heredoc_identifier(p);
+ enum yytokentype token = heredoc_identifier(p);
if (token) return token < 0 ? 0 : token;
}
if (IS_AFTER_OPERATOR()) {
@@ -10111,8 +10819,8 @@ parser_yylex(struct parser_params *p)
if ((c != ':') ||
(c = peekc_n(p, 1)) == -1 ||
!(c == '\'' || c == '"' ||
- is_identchar((p->lex.pcur+1), p->lex.pend, p->enc))) {
- rb_warning0("`&' interpreted as argument prefix");
+ is_identchar(p, (p->lex.pcur+1), p->lex.pend, p->enc))) {
+ rb_warning0("'&' interpreted as argument prefix");
}
c = tAMPER;
}
@@ -10194,6 +10902,8 @@ parser_yylex(struct parser_params *p)
}
if (c == '>') {
SET_LEX_STATE(EXPR_ENDFN);
+ yylval.num = p->lex.lpar_beg;
+ p->lex.lpar_beg = p->lex.paren_nest;
return tLAMBDA;
}
if (IS_BEG() || (IS_SPCARG(c) && arg_ambiguous(p, '-'))) {
@@ -10213,17 +10923,13 @@ parser_yylex(struct parser_params *p)
SET_LEX_STATE(EXPR_BEG);
if ((c = nextc(p)) == '.') {
if ((c = nextc(p)) == '.') {
- if (p->ctxt.in_argdef) {
+ if (p->ctxt.in_argdef || IS_LABEL_POSSIBLE()) {
SET_LEX_STATE(EXPR_ENDARG);
return tBDOT3;
}
if (p->lex.paren_nest == 0 && looking_at_eol_p(p)) {
rb_warn0("... at EOL, should be parenthesized?");
}
- else if (p->lex.lpar_beg >= 0 && p->lex.lpar_beg+1 == p->lex.paren_nest) {
- if (IS_lex_state_for(last_state, EXPR_LABEL))
- return tDOT3;
- }
return is_beg ? tBDOT3 : tDOT3;
}
pushback(p, c);
@@ -10463,7 +11169,7 @@ parser_yylex(struct parser_params *p)
default:
if (!parser_is_identchar(p)) {
- compile_error(p, "Invalid char `\\x%02X' in expression", c);
+ compile_error(p, "Invalid char '\\x%02X' in expression", c);
token_flush(p);
goto retry;
}
@@ -10481,7 +11187,7 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *p)
enum yytokentype t;
p->lval = lval;
- lval->val = Qundef;
+ lval->node = 0;
p->yylloc = yylloc;
t = parser_yylex(p);
@@ -10497,14 +11203,11 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *p)
#define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
static NODE*
-node_newnode(struct parser_params *p, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_location_t *loc)
+node_new_internal(struct parser_params *p, enum node_type type, size_t size, size_t alignment)
{
- NODE *n = rb_ast_newnode(p->ast, type);
-
- rb_node_init(n, type, a0, a1, a2);
+ NODE *n = rb_ast_newnode(p->ast, type, size, alignment);
- nd_set_loc(n, loc);
- nd_set_node_id(n, parser_get_node_id(p));
+ rb_node_init(n, type);
return n;
}
@@ -10516,6 +11219,1238 @@ nd_set_loc(NODE *nd, const YYLTYPE *loc)
return nd;
}
+static NODE*
+node_newnode(struct parser_params *p, enum node_type type, size_t size, size_t alignment, const rb_code_location_t *loc)
+{
+ NODE *n = node_new_internal(p, type, size, alignment);
+
+ nd_set_loc(n, loc);
+ nd_set_node_id(n, parser_get_node_id(p));
+ return n;
+}
+
+#define NODE_NEWNODE(node_type, type, loc) (type *)(node_newnode(p, node_type, sizeof(type), RUBY_ALIGNOF(type), loc))
+
+static rb_node_scope_t *
+rb_node_scope_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, NODE *nd_parent, const YYLTYPE *loc)
+{
+ rb_ast_id_table_t *nd_tbl;
+ nd_tbl = local_tbl(p);
+ rb_node_scope_t *n = NODE_NEWNODE(NODE_SCOPE, rb_node_scope_t, loc);
+ n->nd_tbl = nd_tbl;
+ n->nd_body = nd_body;
+ n->nd_parent = nd_parent;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_scope_t *
+rb_node_scope_new2(struct parser_params *p, rb_ast_id_table_t *nd_tbl, rb_node_args_t *nd_args, NODE *nd_body, NODE *nd_parent, const YYLTYPE *loc)
+{
+ rb_node_scope_t *n = NODE_NEWNODE(NODE_SCOPE, rb_node_scope_t, loc);
+ n->nd_tbl = nd_tbl;
+ n->nd_body = nd_body;
+ n->nd_parent = nd_parent;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_defn_t *
+rb_node_defn_new(struct parser_params *p, ID nd_mid, NODE *nd_defn, const YYLTYPE *loc)
+{
+ rb_node_defn_t *n = NODE_NEWNODE(NODE_DEFN, rb_node_defn_t, loc);
+ n->nd_mid = nd_mid;
+ n->nd_defn = nd_defn;
+
+ return n;
+}
+
+static rb_node_defs_t *
+rb_node_defs_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_defn, const YYLTYPE *loc)
+{
+ rb_node_defs_t *n = NODE_NEWNODE(NODE_DEFS, rb_node_defs_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_defn = nd_defn;
+
+ return n;
+}
+
+static rb_node_block_t *
+rb_node_block_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc)
+{
+ rb_node_block_t *n = NODE_NEWNODE(NODE_BLOCK, rb_node_block_t, loc);
+ n->nd_head = nd_head;
+ n->nd_end = (NODE *)n;
+ n->nd_next = 0;
+
+ return n;
+}
+
+static rb_node_for_t *
+rb_node_for_new(struct parser_params *p, NODE *nd_iter, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *for_keyword_loc, const YYLTYPE *in_keyword_loc, const YYLTYPE *do_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ rb_node_for_t *n = NODE_NEWNODE(NODE_FOR, rb_node_for_t, loc);
+ n->nd_body = nd_body;
+ n->nd_iter = nd_iter;
+ n->for_keyword_loc = *for_keyword_loc;
+ n->in_keyword_loc = *in_keyword_loc;
+ n->do_keyword_loc = *do_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_for_masgn_t *
+rb_node_for_masgn_new(struct parser_params *p, NODE *nd_var, const YYLTYPE *loc)
+{
+ rb_node_for_masgn_t *n = NODE_NEWNODE(NODE_FOR_MASGN, rb_node_for_masgn_t, loc);
+ n->nd_var = nd_var;
+
+ return n;
+}
+
+static rb_node_retry_t *
+rb_node_retry_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_retry_t *n = NODE_NEWNODE(NODE_RETRY, rb_node_retry_t, loc);
+
+ return n;
+}
+
+static rb_node_begin_t *
+rb_node_begin_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_begin_t *n = NODE_NEWNODE(NODE_BEGIN, rb_node_begin_t, loc);
+ n->nd_body = nd_body;
+
+ return n;
+}
+
+static rb_node_rescue_t *
+rb_node_rescue_new(struct parser_params *p, NODE *nd_head, NODE *nd_resq, NODE *nd_else, const YYLTYPE *loc)
+{
+ rb_node_rescue_t *n = NODE_NEWNODE(NODE_RESCUE, rb_node_rescue_t, loc);
+ n->nd_head = nd_head;
+ n->nd_resq = nd_resq;
+ n->nd_else = nd_else;
+
+ return n;
+}
+
+static rb_node_resbody_t *
+rb_node_resbody_new(struct parser_params *p, NODE *nd_args, NODE *nd_exc_var, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc)
+{
+ rb_node_resbody_t *n = NODE_NEWNODE(NODE_RESBODY, rb_node_resbody_t, loc);
+ n->nd_args = nd_args;
+ n->nd_exc_var = nd_exc_var;
+ n->nd_body = nd_body;
+ n->nd_next = nd_next;
+
+ return n;
+}
+
+static rb_node_ensure_t *
+rb_node_ensure_new(struct parser_params *p, NODE *nd_head, NODE *nd_ensr, const YYLTYPE *loc)
+{
+ rb_node_ensure_t *n = NODE_NEWNODE(NODE_ENSURE, rb_node_ensure_t, loc);
+ n->nd_head = nd_head;
+ n->nd_ensr = nd_ensr;
+
+ return n;
+}
+
+static rb_node_and_t *
+rb_node_and_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_and_t *n = NODE_NEWNODE(NODE_AND, rb_node_and_t, loc);
+ n->nd_1st = nd_1st;
+ n->nd_2nd = nd_2nd;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_or_t *
+rb_node_or_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_or_t *n = NODE_NEWNODE(NODE_OR, rb_node_or_t, loc);
+ n->nd_1st = nd_1st;
+ n->nd_2nd = nd_2nd;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_return_t *
+rb_node_return_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_return_t *n = NODE_NEWNODE(NODE_RETURN, rb_node_return_t, loc);
+ n->nd_stts = nd_stts;
+ n->keyword_loc = *keyword_loc;
+ return n;
+}
+
+static rb_node_yield_t *
+rb_node_yield_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *lparen_loc, const YYLTYPE *rparen_loc)
+{
+ if (nd_head) no_blockarg(p, nd_head);
+
+ rb_node_yield_t *n = NODE_NEWNODE(NODE_YIELD, rb_node_yield_t, loc);
+ n->nd_head = nd_head;
+ n->keyword_loc = *keyword_loc;
+ n->lparen_loc = *lparen_loc;
+ n->rparen_loc = *rparen_loc;
+
+ return n;
+}
+
+static rb_node_if_t *
+rb_node_if_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc, const YYLTYPE* if_keyword_loc, const YYLTYPE* then_keyword_loc, const YYLTYPE* end_keyword_loc)
+{
+ rb_node_if_t *n = NODE_NEWNODE(NODE_IF, rb_node_if_t, loc);
+ n->nd_cond = nd_cond;
+ n->nd_body = nd_body;
+ n->nd_else = nd_else;
+ n->if_keyword_loc = *if_keyword_loc;
+ n->then_keyword_loc = *then_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_unless_t *
+rb_node_unless_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, NODE *nd_else, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ rb_node_unless_t *n = NODE_NEWNODE(NODE_UNLESS, rb_node_unless_t, loc);
+ n->nd_cond = nd_cond;
+ n->nd_body = nd_body;
+ n->nd_else = nd_else;
+ n->keyword_loc = *keyword_loc;
+ n->then_keyword_loc = *then_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_class_t *
+rb_node_class_new(struct parser_params *p, NODE *nd_cpath, NODE *nd_body, NODE *nd_super, const YYLTYPE *loc, const YYLTYPE *class_keyword_loc, const YYLTYPE *inheritance_operator_loc, const YYLTYPE *end_keyword_loc)
+{
+ /* Keep the order of node creation */
+ NODE *scope = NEW_SCOPE(0, nd_body, NULL, loc);
+ rb_node_class_t *n = NODE_NEWNODE(NODE_CLASS, rb_node_class_t, loc);
+ RNODE_SCOPE(scope)->nd_parent = &n->node;
+ n->nd_cpath = nd_cpath;
+ n->nd_body = scope;
+ n->nd_super = nd_super;
+ n->class_keyword_loc = *class_keyword_loc;
+ n->inheritance_operator_loc = *inheritance_operator_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_sclass_t *
+rb_node_sclass_new(struct parser_params *p, NODE *nd_recv, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *class_keyword_loc, const YYLTYPE *operator_loc, const YYLTYPE *end_keyword_loc)
+{
+ /* Keep the order of node creation */
+ NODE *scope = NEW_SCOPE(0, nd_body, NULL, loc);
+ rb_node_sclass_t *n = NODE_NEWNODE(NODE_SCLASS, rb_node_sclass_t, loc);
+ RNODE_SCOPE(scope)->nd_parent = &n->node;
+ n->nd_recv = nd_recv;
+ n->nd_body = scope;
+ n->class_keyword_loc = *class_keyword_loc;
+ n->operator_loc = *operator_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_module_t *
+rb_node_module_new(struct parser_params *p, NODE *nd_cpath, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *module_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ /* Keep the order of node creation */
+ NODE *scope = NEW_SCOPE(0, nd_body, NULL, loc);
+ rb_node_module_t *n = NODE_NEWNODE(NODE_MODULE, rb_node_module_t, loc);
+ RNODE_SCOPE(scope)->nd_parent = &n->node;
+ n->nd_cpath = nd_cpath;
+ n->nd_body = scope;
+ n->module_keyword_loc = *module_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_iter_t *
+rb_node_iter_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, const YYLTYPE *loc)
+{
+ /* Keep the order of node creation */
+ NODE *scope = NEW_SCOPE(nd_args, nd_body, NULL, loc);
+ rb_node_iter_t *n = NODE_NEWNODE(NODE_ITER, rb_node_iter_t, loc);
+ RNODE_SCOPE(scope)->nd_parent = &n->node;
+ n->nd_body = scope;
+ n->nd_iter = 0;
+
+ return n;
+}
+
+static rb_node_lambda_t *
+rb_node_lambda_new(struct parser_params *p, rb_node_args_t *nd_args, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc)
+{
+ /* Keep the order of node creation */
+ NODE *scope = NEW_SCOPE(nd_args, nd_body, NULL, loc);
+ YYLTYPE lambda_loc = code_loc_gen(operator_loc, closing_loc);
+ rb_node_lambda_t *n = NODE_NEWNODE(NODE_LAMBDA, rb_node_lambda_t, &lambda_loc);
+ RNODE_SCOPE(scope)->nd_parent = &n->node;
+ n->nd_body = scope;
+ n->operator_loc = *operator_loc;
+ n->opening_loc = *opening_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_case_t *
+rb_node_case_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ rb_node_case_t *n = NODE_NEWNODE(NODE_CASE, rb_node_case_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+ n->case_keyword_loc = *case_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_case2_t *
+rb_node_case2_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ rb_node_case2_t *n = NODE_NEWNODE(NODE_CASE2, rb_node_case2_t, loc);
+ n->nd_head = 0;
+ n->nd_body = nd_body;
+ n->case_keyword_loc = *case_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_case3_t *
+rb_node_case3_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *case_keyword_loc, const YYLTYPE *end_keyword_loc)
+{
+ rb_node_case3_t *n = NODE_NEWNODE(NODE_CASE3, rb_node_case3_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+ n->case_keyword_loc = *case_keyword_loc;
+ n->end_keyword_loc = *end_keyword_loc;
+
+ return n;
+}
+
+static rb_node_when_t *
+rb_node_when_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc)
+{
+ rb_node_when_t *n = NODE_NEWNODE(NODE_WHEN, rb_node_when_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+ n->nd_next = nd_next;
+ n->keyword_loc = *keyword_loc;
+ n->then_keyword_loc = *then_keyword_loc;
+
+ return n;
+}
+
+static rb_node_in_t *
+rb_node_in_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, NODE *nd_next, const YYLTYPE *loc, const YYLTYPE *in_keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *operator_loc)
+{
+ rb_node_in_t *n = NODE_NEWNODE(NODE_IN, rb_node_in_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+ n->nd_next = nd_next;
+ n->in_keyword_loc = *in_keyword_loc;
+ n->then_keyword_loc = *then_keyword_loc;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_while_t *
+rb_node_while_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, long nd_state, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *closing_loc)
+{
+ rb_node_while_t *n = NODE_NEWNODE(NODE_WHILE, rb_node_while_t, loc);
+ n->nd_cond = nd_cond;
+ n->nd_body = nd_body;
+ n->nd_state = nd_state;
+ n->keyword_loc = *keyword_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_until_t *
+rb_node_until_new(struct parser_params *p, NODE *nd_cond, NODE *nd_body, long nd_state, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *closing_loc)
+{
+ rb_node_until_t *n = NODE_NEWNODE(NODE_UNTIL, rb_node_until_t, loc);
+ n->nd_cond = nd_cond;
+ n->nd_body = nd_body;
+ n->nd_state = nd_state;
+ n->keyword_loc = *keyword_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_colon2_t *
+rb_node_colon2_new(struct parser_params *p, NODE *nd_head, ID nd_mid, const YYLTYPE *loc, const YYLTYPE *delimiter_loc, const YYLTYPE *name_loc)
+{
+ rb_node_colon2_t *n = NODE_NEWNODE(NODE_COLON2, rb_node_colon2_t, loc);
+ n->nd_head = nd_head;
+ n->nd_mid = nd_mid;
+ n->delimiter_loc = *delimiter_loc;
+ n->name_loc = *name_loc;
+
+ return n;
+}
+
+static rb_node_colon3_t *
+rb_node_colon3_new(struct parser_params *p, ID nd_mid, const YYLTYPE *loc, const YYLTYPE *delimiter_loc, const YYLTYPE *name_loc)
+{
+ rb_node_colon3_t *n = NODE_NEWNODE(NODE_COLON3, rb_node_colon3_t, loc);
+ n->nd_mid = nd_mid;
+ n->delimiter_loc = *delimiter_loc;
+ n->name_loc = *name_loc;
+
+ return n;
+}
+
+static rb_node_dot2_t *
+rb_node_dot2_new(struct parser_params *p, NODE *nd_beg, NODE *nd_end, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_dot2_t *n = NODE_NEWNODE(NODE_DOT2, rb_node_dot2_t, loc);
+ n->nd_beg = nd_beg;
+ n->nd_end = nd_end;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_dot3_t *
+rb_node_dot3_new(struct parser_params *p, NODE *nd_beg, NODE *nd_end, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_dot3_t *n = NODE_NEWNODE(NODE_DOT3, rb_node_dot3_t, loc);
+ n->nd_beg = nd_beg;
+ n->nd_end = nd_end;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_self_t *
+rb_node_self_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_self_t *n = NODE_NEWNODE(NODE_SELF, rb_node_self_t, loc);
+ n->nd_state = 1;
+
+ return n;
+}
+
+static rb_node_nil_t *
+rb_node_nil_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_nil_t *n = NODE_NEWNODE(NODE_NIL, rb_node_nil_t, loc);
+
+ return n;
+}
+
+static rb_node_true_t *
+rb_node_true_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_true_t *n = NODE_NEWNODE(NODE_TRUE, rb_node_true_t, loc);
+
+ return n;
+}
+
+static rb_node_false_t *
+rb_node_false_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_false_t *n = NODE_NEWNODE(NODE_FALSE, rb_node_false_t, loc);
+
+ return n;
+}
+
+static rb_node_super_t *
+rb_node_super_new(struct parser_params *p, NODE *nd_args, const YYLTYPE *loc,
+ const YYLTYPE *keyword_loc, const YYLTYPE *lparen_loc, const YYLTYPE *rparen_loc)
+{
+ rb_node_super_t *n = NODE_NEWNODE(NODE_SUPER, rb_node_super_t, loc);
+ n->nd_args = nd_args;
+ n->keyword_loc = *keyword_loc;
+ n->lparen_loc = *lparen_loc;
+ n->rparen_loc = *rparen_loc;
+
+ return n;
+}
+
+static rb_node_zsuper_t *
+rb_node_zsuper_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_zsuper_t *n = NODE_NEWNODE(NODE_ZSUPER, rb_node_zsuper_t, loc);
+
+ return n;
+}
+
+static rb_node_match2_t *
+rb_node_match2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_match2_t *n = NODE_NEWNODE(NODE_MATCH2, rb_node_match2_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_value = nd_value;
+ n->nd_args = 0;
+
+ return n;
+}
+
+static rb_node_match3_t *
+rb_node_match3_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_match3_t *n = NODE_NEWNODE(NODE_MATCH3, rb_node_match3_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_list_t *
+rb_node_list_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc)
+{
+ return rb_node_list_new2(p, nd_head, 1, 0, loc);
+}
+
+static rb_node_list_t *
+rb_node_list_new2(struct parser_params *p, NODE *nd_head, long nd_alen, NODE *nd_next, const YYLTYPE *loc)
+{
+ rb_node_list_t *n = NODE_NEWNODE(NODE_LIST, rb_node_list_t, loc);
+ n->nd_head = nd_head;
+ n->as.nd_alen = nd_alen;
+ n->nd_next = nd_next;
+
+ return n;
+}
+
+static rb_node_zlist_t *
+rb_node_zlist_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_zlist_t *n = NODE_NEWNODE(NODE_ZLIST, rb_node_zlist_t, loc);
+
+ return n;
+}
+
+static rb_node_hash_t *
+rb_node_hash_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc)
+{
+ rb_node_hash_t *n = NODE_NEWNODE(NODE_HASH, rb_node_hash_t, loc);
+ n->nd_head = nd_head;
+ n->nd_brace = 0;
+
+ return n;
+}
+
+static rb_node_masgn_t *
+rb_node_masgn_new(struct parser_params *p, NODE *nd_head, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_masgn_t *n = NODE_NEWNODE(NODE_MASGN, rb_node_masgn_t, loc);
+ n->nd_head = nd_head;
+ n->nd_value = 0;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_gasgn_t *
+rb_node_gasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_gasgn_t *n = NODE_NEWNODE(NODE_GASGN, rb_node_gasgn_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_lasgn_t *
+rb_node_lasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_lasgn_t *n = NODE_NEWNODE(NODE_LASGN, rb_node_lasgn_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_dasgn_t *
+rb_node_dasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_dasgn_t *n = NODE_NEWNODE(NODE_DASGN, rb_node_dasgn_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_iasgn_t *
+rb_node_iasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_iasgn_t *n = NODE_NEWNODE(NODE_IASGN, rb_node_iasgn_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_cvasgn_t *
+rb_node_cvasgn_new(struct parser_params *p, ID nd_vid, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_cvasgn_t *n = NODE_NEWNODE(NODE_CVASGN, rb_node_cvasgn_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_op_asgn1_t *
+rb_node_op_asgn1_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *index, NODE *rvalue, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc, const YYLTYPE *binary_operator_loc)
+{
+ rb_node_op_asgn1_t *n = NODE_NEWNODE(NODE_OP_ASGN1, rb_node_op_asgn1_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_index = index;
+ n->nd_rvalue = rvalue;
+ n->call_operator_loc = *call_operator_loc;
+ n->opening_loc = *opening_loc;
+ n->closing_loc = *closing_loc;
+ n->binary_operator_loc = *binary_operator_loc;
+
+ return n;
+}
+
+static rb_node_op_asgn2_t *
+rb_node_op_asgn2_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, ID nd_vid, ID nd_mid, bool nd_aid, const YYLTYPE *loc, const YYLTYPE *call_operator_loc, const YYLTYPE *message_loc, const YYLTYPE *binary_operator_loc)
+{
+ rb_node_op_asgn2_t *n = NODE_NEWNODE(NODE_OP_ASGN2, rb_node_op_asgn2_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_value = nd_value;
+ n->nd_vid = nd_vid;
+ n->nd_mid = nd_mid;
+ n->nd_aid = nd_aid;
+ n->call_operator_loc = *call_operator_loc;
+ n->message_loc = *message_loc;
+ n->binary_operator_loc = *binary_operator_loc;
+
+ return n;
+}
+
+static rb_node_op_asgn_or_t *
+rb_node_op_asgn_or_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_op_asgn_or_t *n = NODE_NEWNODE(NODE_OP_ASGN_OR, rb_node_op_asgn_or_t, loc);
+ n->nd_head = nd_head;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_op_asgn_and_t *
+rb_node_op_asgn_and_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, const YYLTYPE *loc)
+{
+ rb_node_op_asgn_and_t *n = NODE_NEWNODE(NODE_OP_ASGN_AND, rb_node_op_asgn_and_t, loc);
+ n->nd_head = nd_head;
+ n->nd_value = nd_value;
+
+ return n;
+}
+
+static rb_node_gvar_t *
+rb_node_gvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_gvar_t *n = NODE_NEWNODE(NODE_GVAR, rb_node_gvar_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_lvar_t *
+rb_node_lvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_lvar_t *n = NODE_NEWNODE(NODE_LVAR, rb_node_lvar_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_dvar_t *
+rb_node_dvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_dvar_t *n = NODE_NEWNODE(NODE_DVAR, rb_node_dvar_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_ivar_t *
+rb_node_ivar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_ivar_t *n = NODE_NEWNODE(NODE_IVAR, rb_node_ivar_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_const_t *
+rb_node_const_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_const_t *n = NODE_NEWNODE(NODE_CONST, rb_node_const_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_cvar_t *
+rb_node_cvar_new(struct parser_params *p, ID nd_vid, const YYLTYPE *loc)
+{
+ rb_node_cvar_t *n = NODE_NEWNODE(NODE_CVAR, rb_node_cvar_t, loc);
+ n->nd_vid = nd_vid;
+
+ return n;
+}
+
+static rb_node_nth_ref_t *
+rb_node_nth_ref_new(struct parser_params *p, long nd_nth, const YYLTYPE *loc)
+{
+ rb_node_nth_ref_t *n = NODE_NEWNODE(NODE_NTH_REF, rb_node_nth_ref_t, loc);
+ n->nd_nth = nd_nth;
+
+ return n;
+}
+
+static rb_node_back_ref_t *
+rb_node_back_ref_new(struct parser_params *p, long nd_nth, const YYLTYPE *loc)
+{
+ rb_node_back_ref_t *n = NODE_NEWNODE(NODE_BACK_REF, rb_node_back_ref_t, loc);
+ n->nd_nth = nd_nth;
+
+ return n;
+}
+
+static rb_node_integer_t *
+rb_node_integer_new(struct parser_params *p, char* val, int base, const YYLTYPE *loc)
+{
+ rb_node_integer_t *n = NODE_NEWNODE(NODE_INTEGER, rb_node_integer_t, loc);
+ n->val = val;
+ n->minus = FALSE;
+ n->base = base;
+
+ return n;
+}
+
+static rb_node_float_t *
+rb_node_float_new(struct parser_params *p, char* val, const YYLTYPE *loc)
+{
+ rb_node_float_t *n = NODE_NEWNODE(NODE_FLOAT, rb_node_float_t, loc);
+ n->val = val;
+ n->minus = FALSE;
+
+ return n;
+}
+
+static rb_node_rational_t *
+rb_node_rational_new(struct parser_params *p, char* val, int base, int seen_point, const YYLTYPE *loc)
+{
+ rb_node_rational_t *n = NODE_NEWNODE(NODE_RATIONAL, rb_node_rational_t, loc);
+ n->val = val;
+ n->minus = FALSE;
+ n->base = base;
+ n->seen_point = seen_point;
+
+ return n;
+}
+
+static rb_node_imaginary_t *
+rb_node_imaginary_new(struct parser_params *p, char* val, int base, int seen_point, enum rb_numeric_type numeric_type, const YYLTYPE *loc)
+{
+ rb_node_imaginary_t *n = NODE_NEWNODE(NODE_IMAGINARY, rb_node_imaginary_t, loc);
+ n->val = val;
+ n->minus = FALSE;
+ n->base = base;
+ n->seen_point = seen_point;
+ n->type = numeric_type;
+
+ return n;
+}
+
+static rb_node_str_t *
+rb_node_str_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc)
+{
+ rb_node_str_t *n = NODE_NEWNODE(NODE_STR, rb_node_str_t, loc);
+ n->string = string;
+
+ return n;
+}
+
+/* TODO; Use union for NODE_DSTR2 */
+static rb_node_dstr_t *
+rb_node_dstr_new0(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc)
+{
+ rb_node_dstr_t *n = NODE_NEWNODE(NODE_DSTR, rb_node_dstr_t, loc);
+ n->string = string;
+ n->as.nd_alen = nd_alen;
+ n->nd_next = (rb_node_list_t *)nd_next;
+
+ return n;
+}
+
+static rb_node_dstr_t *
+rb_node_dstr_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc)
+{
+ return rb_node_dstr_new0(p, string, 1, 0, loc);
+}
+
+static rb_node_xstr_t *
+rb_node_xstr_new(struct parser_params *p, rb_parser_string_t *string, const YYLTYPE *loc)
+{
+ rb_node_xstr_t *n = NODE_NEWNODE(NODE_XSTR, rb_node_xstr_t, loc);
+ n->string = string;
+
+ return n;
+}
+
+static rb_node_dxstr_t *
+rb_node_dxstr_new(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc)
+{
+ rb_node_dxstr_t *n = NODE_NEWNODE(NODE_DXSTR, rb_node_dxstr_t, loc);
+ n->string = string;
+ n->as.nd_alen = nd_alen;
+ n->nd_next = (rb_node_list_t *)nd_next;
+
+ return n;
+}
+
+static rb_node_sym_t *
+rb_node_sym_new(struct parser_params *p, VALUE str, const YYLTYPE *loc)
+{
+ rb_node_sym_t *n = NODE_NEWNODE(NODE_SYM, rb_node_sym_t, loc);
+ n->string = rb_str_to_parser_string(p, str);
+
+ return n;
+}
+
+static rb_node_dsym_t *
+rb_node_dsym_new(struct parser_params *p, rb_parser_string_t *string, long nd_alen, NODE *nd_next, const YYLTYPE *loc)
+{
+ rb_node_dsym_t *n = NODE_NEWNODE(NODE_DSYM, rb_node_dsym_t, loc);
+ n->string = string;
+ n->as.nd_alen = nd_alen;
+ n->nd_next = (rb_node_list_t *)nd_next;
+
+ return n;
+}
+
+static rb_node_evstr_t *
+rb_node_evstr_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc)
+{
+ rb_node_evstr_t *n = NODE_NEWNODE(NODE_EVSTR, rb_node_evstr_t, loc);
+ n->nd_body = nd_body;
+ n->opening_loc = *opening_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_regx_t *
+rb_node_regx_new(struct parser_params *p, rb_parser_string_t *string, int options, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *content_loc, const YYLTYPE *closing_loc)
+{
+ rb_node_regx_t *n = NODE_NEWNODE(NODE_REGX, rb_node_regx_t, loc);
+ n->string = string;
+ n->options = options & RE_OPTION_MASK;
+ n->opening_loc = *opening_loc;
+ n->content_loc = *content_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_call_t *
+rb_node_call_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_call_t *n = NODE_NEWNODE(NODE_CALL, rb_node_call_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_opcall_t *
+rb_node_opcall_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_opcall_t *n = NODE_NEWNODE(NODE_OPCALL, rb_node_opcall_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_fcall_t *
+rb_node_fcall_new(struct parser_params *p, ID nd_mid, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_fcall_t *n = NODE_NEWNODE(NODE_FCALL, rb_node_fcall_t, loc);
+ n->nd_mid = nd_mid;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_qcall_t *
+rb_node_qcall_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_qcall_t *n = NODE_NEWNODE(NODE_QCALL, rb_node_qcall_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_vcall_t *
+rb_node_vcall_new(struct parser_params *p, ID nd_mid, const YYLTYPE *loc)
+{
+ rb_node_vcall_t *n = NODE_NEWNODE(NODE_VCALL, rb_node_vcall_t, loc);
+ n->nd_mid = nd_mid;
+
+ return n;
+}
+
+static rb_node_once_t *
+rb_node_once_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_once_t *n = NODE_NEWNODE(NODE_ONCE, rb_node_once_t, loc);
+ n->nd_body = nd_body;
+
+ return n;
+}
+
+static rb_node_args_t *
+rb_node_args_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_args_t *n = NODE_NEWNODE(NODE_ARGS, rb_node_args_t, loc);
+ MEMZERO(&n->nd_ainfo, struct rb_args_info, 1);
+
+ return n;
+}
+
+static rb_node_args_aux_t *
+rb_node_args_aux_new(struct parser_params *p, ID nd_pid, int nd_plen, const YYLTYPE *loc)
+{
+ rb_node_args_aux_t *n = NODE_NEWNODE(NODE_ARGS_AUX, rb_node_args_aux_t, loc);
+ n->nd_pid = nd_pid;
+ n->nd_plen = nd_plen;
+ n->nd_next = 0;
+
+ return n;
+}
+
+static rb_node_opt_arg_t *
+rb_node_opt_arg_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_opt_arg_t *n = NODE_NEWNODE(NODE_OPT_ARG, rb_node_opt_arg_t, loc);
+ n->nd_body = nd_body;
+ n->nd_next = 0;
+
+ return n;
+}
+
+static rb_node_kw_arg_t *
+rb_node_kw_arg_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_kw_arg_t *n = NODE_NEWNODE(NODE_KW_ARG, rb_node_kw_arg_t, loc);
+ n->nd_body = nd_body;
+ n->nd_next = 0;
+
+ return n;
+}
+
+static rb_node_postarg_t *
+rb_node_postarg_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc)
+{
+ rb_node_postarg_t *n = NODE_NEWNODE(NODE_POSTARG, rb_node_postarg_t, loc);
+ n->nd_1st = nd_1st;
+ n->nd_2nd = nd_2nd;
+
+ return n;
+}
+
+static rb_node_argscat_t *
+rb_node_argscat_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_argscat_t *n = NODE_NEWNODE(NODE_ARGSCAT, rb_node_argscat_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+
+ return n;
+}
+
+static rb_node_argspush_t *
+rb_node_argspush_new(struct parser_params *p, NODE *nd_head, NODE *nd_body, const YYLTYPE *loc)
+{
+ rb_node_argspush_t *n = NODE_NEWNODE(NODE_ARGSPUSH, rb_node_argspush_t, loc);
+ n->nd_head = nd_head;
+ n->nd_body = nd_body;
+
+ return n;
+}
+
+static rb_node_splat_t *
+rb_node_splat_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_splat_t *n = NODE_NEWNODE(NODE_SPLAT, rb_node_splat_t, loc);
+ n->nd_head = nd_head;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_block_pass_t *
+rb_node_block_pass_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *operator_loc)
+{
+ rb_node_block_pass_t *n = NODE_NEWNODE(NODE_BLOCK_PASS, rb_node_block_pass_t, loc);
+ n->forwarding = 0;
+ n->nd_head = 0;
+ n->nd_body = nd_body;
+ n->operator_loc = *operator_loc;
+
+ return n;
+}
+
+static rb_node_alias_t *
+rb_node_alias_new(struct parser_params *p, NODE *nd_1st, NODE *nd_2nd, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_alias_t *n = NODE_NEWNODE(NODE_ALIAS, rb_node_alias_t, loc);
+ n->nd_1st = nd_1st;
+ n->nd_2nd = nd_2nd;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_valias_t *
+rb_node_valias_new(struct parser_params *p, ID nd_alias, ID nd_orig, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_valias_t *n = NODE_NEWNODE(NODE_VALIAS, rb_node_valias_t, loc);
+ n->nd_alias = nd_alias;
+ n->nd_orig = nd_orig;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_undef_t *
+rb_node_undef_new(struct parser_params *p, NODE *nd_undef, const YYLTYPE *loc)
+{
+ rb_node_undef_t *n = NODE_NEWNODE(NODE_UNDEF, rb_node_undef_t, loc);
+ n->nd_undefs = rb_parser_ary_new_capa_for_node(p, 1);
+ n->keyword_loc = NULL_LOC;
+ rb_parser_ary_push_node(p, n->nd_undefs, nd_undef);
+
+ return n;
+}
+
+static rb_node_errinfo_t *
+rb_node_errinfo_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_errinfo_t *n = NODE_NEWNODE(NODE_ERRINFO, rb_node_errinfo_t, loc);
+
+ return n;
+}
+
+static rb_node_defined_t *
+rb_node_defined_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_defined_t *n = NODE_NEWNODE(NODE_DEFINED, rb_node_defined_t, loc);
+ n->nd_head = nd_head;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_postexe_t *
+rb_node_postexe_new(struct parser_params *p, NODE *nd_body, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc)
+{
+ rb_node_postexe_t *n = NODE_NEWNODE(NODE_POSTEXE, rb_node_postexe_t, loc);
+ n->nd_body = nd_body;
+ n->keyword_loc = *keyword_loc;
+ n->opening_loc = *opening_loc;
+ n->closing_loc = *closing_loc;
+
+ return n;
+}
+
+static rb_node_attrasgn_t *
+rb_node_attrasgn_new(struct parser_params *p, NODE *nd_recv, ID nd_mid, NODE *nd_args, const YYLTYPE *loc)
+{
+ rb_node_attrasgn_t *n = NODE_NEWNODE(NODE_ATTRASGN, rb_node_attrasgn_t, loc);
+ n->nd_recv = nd_recv;
+ n->nd_mid = nd_mid;
+ n->nd_args = nd_args;
+
+ return n;
+}
+
+static rb_node_aryptn_t *
+rb_node_aryptn_new(struct parser_params *p, NODE *pre_args, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc)
+{
+ rb_node_aryptn_t *n = NODE_NEWNODE(NODE_ARYPTN, rb_node_aryptn_t, loc);
+ n->nd_pconst = 0;
+ n->pre_args = pre_args;
+ n->rest_arg = rest_arg;
+ n->post_args = post_args;
+
+ return n;
+}
+
+static rb_node_hshptn_t *
+rb_node_hshptn_new(struct parser_params *p, NODE *nd_pconst, NODE *nd_pkwargs, NODE *nd_pkwrestarg, const YYLTYPE *loc)
+{
+ rb_node_hshptn_t *n = NODE_NEWNODE(NODE_HSHPTN, rb_node_hshptn_t, loc);
+ n->nd_pconst = nd_pconst;
+ n->nd_pkwargs = nd_pkwargs;
+ n->nd_pkwrestarg = nd_pkwrestarg;
+
+ return n;
+}
+
+static rb_node_fndptn_t *
+rb_node_fndptn_new(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc)
+{
+ rb_node_fndptn_t *n = NODE_NEWNODE(NODE_FNDPTN, rb_node_fndptn_t, loc);
+ n->nd_pconst = 0;
+ n->pre_rest_arg = pre_rest_arg;
+ n->args = args;
+ n->post_rest_arg = post_rest_arg;
+
+ return n;
+}
+
+static rb_node_line_t *
+rb_node_line_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_line_t *n = NODE_NEWNODE(NODE_LINE, rb_node_line_t, loc);
+
+ return n;
+}
+
+static rb_node_file_t *
+rb_node_file_new(struct parser_params *p, VALUE str, const YYLTYPE *loc)
+{
+ rb_node_file_t *n = NODE_NEWNODE(NODE_FILE, rb_node_file_t, loc);
+ n->path = rb_str_to_parser_string(p, str);
+
+ return n;
+}
+
+static rb_node_encoding_t *
+rb_node_encoding_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_encoding_t *n = NODE_NEWNODE(NODE_ENCODING, rb_node_encoding_t, loc);
+ n->enc = p->enc;
+
+ return n;
+}
+
+static rb_node_cdecl_t *
+rb_node_cdecl_new(struct parser_params *p, ID nd_vid, NODE *nd_value, NODE *nd_else, enum rb_parser_shareability shareability, const YYLTYPE *loc)
+{
+ rb_node_cdecl_t *n = NODE_NEWNODE(NODE_CDECL, rb_node_cdecl_t, loc);
+ n->nd_vid = nd_vid;
+ n->nd_value = nd_value;
+ n->nd_else = nd_else;
+ n->shareability = shareability;
+
+ return n;
+}
+
+static rb_node_op_cdecl_t *
+rb_node_op_cdecl_new(struct parser_params *p, NODE *nd_head, NODE *nd_value, ID nd_aid, enum rb_parser_shareability shareability, const YYLTYPE *loc)
+{
+ rb_node_op_cdecl_t *n = NODE_NEWNODE(NODE_OP_CDECL, rb_node_op_cdecl_t, loc);
+ n->nd_head = nd_head;
+ n->nd_value = nd_value;
+ n->nd_aid = nd_aid;
+ n->shareability = shareability;
+
+ return n;
+}
+
+static rb_node_error_t *
+rb_node_error_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_error_t *n = NODE_NEWNODE(NODE_ERROR, rb_node_error_t, loc);
+
+ return n;
+}
+
+static rb_node_break_t *
+rb_node_break_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_break_t *n = NODE_NEWNODE(NODE_BREAK, rb_node_break_t, loc);
+ n->nd_stts = nd_stts;
+ n->nd_chain = 0;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_next_t *
+rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_next_t *n = NODE_NEWNODE(NODE_NEXT, rb_node_next_t, loc);
+ n->nd_stts = nd_stts;
+ n->nd_chain = 0;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_redo_t *
+rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ rb_node_redo_t *n = NODE_NEWNODE(NODE_REDO, rb_node_redo_t, loc);
+ n->nd_chain = 0;
+ n->keyword_loc = *keyword_loc;
+
+ return n;
+}
+
+static rb_node_def_temp_t *
+rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc)
+{
+ rb_node_def_temp_t *n = NODE_NEWNODE((enum node_type)NODE_DEF_TEMP, rb_node_def_temp_t, loc);
+ n->save.numparam_save = 0;
+ n->save.max_numparam = 0;
+ n->save.ctxt = p->ctxt;
+ n->nd_def = 0;
+ n->nd_mid = 0;
+
+ return n;
+}
+
+static rb_node_def_temp_t *
+def_head_save(struct parser_params *p, rb_node_def_temp_t *n)
+{
+ n->save.numparam_save = numparam_push(p);
+ n->save.max_numparam = p->max_numparam;
+ return n;
+}
+
#ifndef RIPPER
static enum node_type
nodetype(NODE *node) /* for debug */
@@ -10528,13 +12463,14 @@ nodeline(NODE *node)
{
return nd_line(node);
}
+#endif
static NODE*
newline_node(NODE *node)
{
if (node) {
node = remove_begin(node);
- node->flags |= NODE_FL_NEWLINE;
+ nd_set_fl_newline(node);
}
return node;
}
@@ -10547,18 +12483,6 @@ fixpos(NODE *node, NODE *orig)
nd_set_line(node, nd_line(orig));
}
-static void
-parser_warning(struct parser_params *p, NODE *node, const char *mesg)
-{
- rb_compile_warning(p->ruby_sourcefile, nd_line(node), "%s", mesg);
-}
-
-static void
-parser_warn(struct parser_params *p, NODE *node, const char *mesg)
-{
- rb_compile_warn(p->ruby_sourcefile, nd_line(node), "%s", mesg);
-}
-
static NODE*
block_append(struct parser_params *p, NODE *head, NODE *tail)
{
@@ -10568,34 +12492,23 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
if (h == 0) return tail;
switch (nd_type(h)) {
- case NODE_LIT:
- case NODE_STR:
- case NODE_SELF:
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_NIL:
- parser_warning(p, h, "unused literal ignored");
- return tail;
default:
h = end = NEW_BLOCK(head, &head->nd_loc);
- end->nd_end = end;
head = end;
break;
case NODE_BLOCK:
- end = h->nd_end;
+ end = RNODE_BLOCK(h)->nd_end;
break;
}
- nd = end->nd_head;
+ nd = RNODE_BLOCK(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)) {
- parser_warning(p, tail, "statement not reached");
- }
+ rb_warning0L(nd_line(tail), "statement not reached");
break;
default:
@@ -10604,10 +12517,9 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
if (!nd_type_p(tail, NODE_BLOCK)) {
tail = NEW_BLOCK(tail, &tail->nd_loc);
- tail->nd_end = tail;
}
- end->nd_next = tail;
- h->nd_end = tail->nd_end;
+ RNODE_BLOCK(end)->nd_next = tail;
+ RNODE_BLOCK(h)->nd_end = RNODE_BLOCK(tail)->nd_end;
nd_set_last_loc(head, nd_last_loc(tail));
return head;
}
@@ -10619,16 +12531,16 @@ list_append(struct parser_params *p, NODE *list, NODE *item)
NODE *last;
if (list == 0) return NEW_LIST(item, &item->nd_loc);
- if (list->nd_next) {
- last = list->nd_next->nd_end;
+ if (RNODE_LIST(list)->nd_next) {
+ last = RNODE_LIST(RNODE_LIST(list)->nd_next)->as.nd_end;
}
else {
last = list;
}
- list->nd_alen += 1;
- last->nd_next = NEW_LIST(item, &item->nd_loc);
- list->nd_next->nd_end = last->nd_next;
+ RNODE_LIST(list)->as.nd_alen += 1;
+ RNODE_LIST(last)->nd_next = NEW_LIST(item, &item->nd_loc);
+ RNODE_LIST(RNODE_LIST(list)->nd_next)->as.nd_end = RNODE_LIST(last)->nd_next;
nd_set_last_loc(list, nd_last_loc(item));
@@ -10641,20 +12553,20 @@ list_concat(NODE *head, NODE *tail)
{
NODE *last;
- if (head->nd_next) {
- last = head->nd_next->nd_end;
+ if (RNODE_LIST(head)->nd_next) {
+ last = RNODE_LIST(RNODE_LIST(head)->nd_next)->as.nd_end;
}
else {
last = head;
}
- head->nd_alen += tail->nd_alen;
- last->nd_next = tail;
- if (tail->nd_next) {
- head->nd_next->nd_end = tail->nd_next->nd_end;
+ RNODE_LIST(head)->as.nd_alen += RNODE_LIST(tail)->as.nd_alen;
+ RNODE_LIST(last)->nd_next = tail;
+ if (RNODE_LIST(tail)->nd_next) {
+ RNODE_LIST(RNODE_LIST(head)->nd_next)->as.nd_end = RNODE_LIST(RNODE_LIST(tail)->nd_next)->as.nd_end;
}
else {
- head->nd_next->nd_end = tail;
+ RNODE_LIST(RNODE_LIST(head)->nd_next)->as.nd_end = tail;
}
nd_set_last_loc(head, nd_last_loc(tail));
@@ -10663,40 +12575,53 @@ list_concat(NODE *head, NODE *tail)
}
static int
-literal_concat0(struct parser_params *p, VALUE head, VALUE tail)
+literal_concat0(struct parser_params *p, rb_parser_string_t *head, rb_parser_string_t *tail)
{
- if (NIL_P(tail)) return 1;
- if (!rb_enc_compatible(head, tail)) {
+ if (!tail) return 1;
+ if (!rb_parser_enc_compatible(p, head, tail)) {
compile_error(p, "string literal encodings differ (%s / %s)",
- rb_enc_name(rb_enc_get(head)),
- rb_enc_name(rb_enc_get(tail)));
- rb_str_resize(head, 0);
- rb_str_resize(tail, 0);
+ rb_enc_name(rb_parser_str_get_encoding(head)),
+ rb_enc_name(rb_parser_str_get_encoding(tail)));
+ rb_parser_str_resize(p, head, 0);
+ rb_parser_str_resize(p, tail, 0);
return 0;
}
- rb_str_buf_append(head, tail);
+ rb_parser_str_buf_append(p, head, tail);
return 1;
}
-static VALUE
-string_literal_head(enum node_type htype, NODE *head)
+static rb_parser_string_t *
+string_literal_head(struct parser_params *p, enum node_type htype, NODE *head)
{
- if (htype != NODE_DSTR) return Qfalse;
- if (head->nd_next) {
- head = head->nd_next->nd_end->nd_head;
- if (!head || !nd_type_p(head, NODE_STR)) return Qfalse;
+ if (htype != NODE_DSTR) return NULL;
+ if (RNODE_DSTR(head)->nd_next) {
+ head = RNODE_LIST(RNODE_LIST(RNODE_DSTR(head)->nd_next)->as.nd_end)->nd_head;
+ if (!head || !nd_type_p(head, NODE_STR)) return NULL;
}
- const VALUE lit = head->nd_lit;
- ASSUME(lit != Qfalse);
+ rb_parser_string_t *lit = RNODE_DSTR(head)->string;
+ ASSUME(lit);
return lit;
}
+#ifndef RIPPER
+static rb_parser_string_t *
+rb_parser_string_deep_copy(struct parser_params *p, const rb_parser_string_t *orig)
+{
+ rb_parser_string_t *copy;
+ if (!orig) return NULL;
+ copy = rb_parser_string_new(p, PARSER_STRING_PTR(orig), PARSER_STRING_LEN(orig));
+ copy->coderange = orig->coderange;
+ copy->enc = orig->enc;
+ return copy;
+}
+#endif
+
/* concat two string literals */
static NODE *
literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *loc)
{
enum node_type htype;
- VALUE lit;
+ rb_parser_string_t *lit;
if (!head) return tail;
if (!tail) return head;
@@ -10709,7 +12634,7 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
if (p->heredoc_indent > 0) {
switch (htype) {
case NODE_STR:
- nd_set_type(head, NODE_DSTR);
+ head = str2dstr(p, head);
case NODE_DSTR:
return list_append(p, head, tail);
default:
@@ -10718,14 +12643,14 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
}
switch (nd_type(tail)) {
case NODE_STR:
- if ((lit = string_literal_head(htype, head)) != Qfalse) {
+ if ((lit = string_literal_head(p, htype, head)) != false) {
htype = NODE_STR;
}
else {
- lit = head->nd_lit;
+ lit = RNODE_DSTR(head)->string;
}
if (htype == NODE_STR) {
- if (!literal_concat0(p, lit, tail->nd_lit)) {
+ if (!literal_concat0(p, lit, RNODE_STR(tail)->string)) {
error:
rb_discard_node(p, head);
rb_discard_node(p, tail);
@@ -10740,39 +12665,43 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
case NODE_DSTR:
if (htype == NODE_STR) {
- if (!literal_concat0(p, head->nd_lit, tail->nd_lit))
+ if (!literal_concat0(p, RNODE_STR(head)->string, RNODE_DSTR(tail)->string))
goto error;
- tail->nd_lit = head->nd_lit;
+ rb_parser_string_free(p, RNODE_DSTR(tail)->string);
+ RNODE_DSTR(tail)->string = RNODE_STR(head)->string;
+ RNODE_STR(head)->string = NULL;
rb_discard_node(p, head);
head = tail;
}
- else if (NIL_P(tail->nd_lit)) {
+ else if (!RNODE_DSTR(tail)->string) {
append:
- head->nd_alen += tail->nd_alen - 1;
- if (!head->nd_next) {
- head->nd_next = tail->nd_next;
+ RNODE_DSTR(head)->as.nd_alen += RNODE_DSTR(tail)->as.nd_alen - 1;
+ if (!RNODE_DSTR(head)->nd_next) {
+ RNODE_DSTR(head)->nd_next = RNODE_DSTR(tail)->nd_next;
}
- else if (tail->nd_next) {
- head->nd_next->nd_end->nd_next = tail->nd_next;
- head->nd_next->nd_end = tail->nd_next->nd_end;
+ else if (RNODE_DSTR(tail)->nd_next) {
+ RNODE_DSTR(RNODE_DSTR(RNODE_DSTR(head)->nd_next)->as.nd_end)->nd_next = RNODE_DSTR(tail)->nd_next;
+ RNODE_DSTR(RNODE_DSTR(head)->nd_next)->as.nd_end = RNODE_DSTR(RNODE_DSTR(tail)->nd_next)->as.nd_end;
}
rb_discard_node(p, tail);
}
- else if ((lit = string_literal_head(htype, head)) != Qfalse) {
- if (!literal_concat0(p, lit, tail->nd_lit))
+ else if ((lit = string_literal_head(p, htype, head)) != false) {
+ if (!literal_concat0(p, lit, RNODE_DSTR(tail)->string))
goto error;
- tail->nd_lit = Qnil;
+ rb_parser_string_free(p, RNODE_DSTR(tail)->string);
+ RNODE_DSTR(tail)->string = 0;
goto append;
}
else {
- list_concat(head, NEW_NODE(NODE_LIST, NEW_STR(tail->nd_lit, loc), tail->nd_alen, tail->nd_next, loc));
+ list_concat(head, NEW_LIST2(NEW_STR(RNODE_DSTR(tail)->string, loc), RNODE_DSTR(tail)->as.nd_alen, (NODE *)RNODE_DSTR(tail)->nd_next, loc));
+ RNODE_DSTR(tail)->string = 0;
}
break;
case NODE_EVSTR:
if (htype == NODE_STR) {
- nd_set_type(head, NODE_DSTR);
- head->nd_alen = 1;
+ head = str2dstr(p, head);
+ RNODE_DSTR(head)->as.nd_alen = 1;
}
list_append(p, head, tail);
break;
@@ -10780,6 +12709,44 @@ literal_concat(struct parser_params *p, NODE *head, NODE *tail, const YYLTYPE *l
return head;
}
+static void
+nd_copy_flag(NODE *new_node, NODE *old_node)
+{
+ if (nd_fl_newline(old_node)) nd_set_fl_newline(new_node);
+ nd_set_line(new_node, nd_line(old_node));
+ new_node->nd_loc = old_node->nd_loc;
+ new_node->node_id = old_node->node_id;
+}
+
+static NODE *
+str2dstr(struct parser_params *p, NODE *node)
+{
+ NODE *new_node = (NODE *)NODE_NEW_INTERNAL(NODE_DSTR, rb_node_dstr_t);
+ nd_copy_flag(new_node, node);
+ RNODE_DSTR(new_node)->string = RNODE_STR(node)->string;
+ RNODE_DSTR(new_node)->as.nd_alen = 0;
+ RNODE_DSTR(new_node)->nd_next = 0;
+ RNODE_STR(node)->string = 0;
+
+ return new_node;
+}
+
+static NODE *
+str2regx(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *content_loc, const YYLTYPE *closing_loc)
+{
+ NODE *new_node = (NODE *)NODE_NEW_INTERNAL(NODE_REGX, rb_node_regx_t);
+ nd_copy_flag(new_node, node);
+ RNODE_REGX(new_node)->string = RNODE_STR(node)->string;
+ RNODE_REGX(new_node)->options = options;
+ nd_set_loc(new_node, loc);
+ RNODE_REGX(new_node)->opening_loc = *opening_loc;
+ RNODE_REGX(new_node)->content_loc = *content_loc;
+ RNODE_REGX(new_node)->closing_loc = *closing_loc;
+ RNODE_STR(node)->string = 0;
+
+ return new_node;
+}
+
static NODE *
evstr2dstr(struct parser_params *p, NODE *node)
{
@@ -10790,30 +12757,27 @@ evstr2dstr(struct parser_params *p, NODE *node)
}
static NODE *
-new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
+new_evstr(struct parser_params *p, NODE *node, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc)
{
NODE *head = node;
if (node) {
switch (nd_type(node)) {
case NODE_STR:
- nd_set_type(node, NODE_DSTR);
- return node;
+ return str2dstr(p, node);
case NODE_DSTR:
break;
case NODE_EVSTR:
return node;
}
}
- return NEW_EVSTR(head, loc);
+ return NEW_EVSTR(head, loc, opening_loc, closing_loc);
}
static NODE *
new_dstr(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
- VALUE lit = STR_NEW0();
- NODE *dstr = NEW_DSTR(lit, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, lit);
+ NODE *dstr = NEW_DSTR(STRING_NEW0(), loc);
return list_append(p, dstr, node);
}
@@ -10822,8 +12786,8 @@ call_bin_op(struct parser_params *p, NODE *recv, ID id, NODE *arg1,
const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *expr;
- value_expr(recv);
- value_expr(arg1);
+ value_expr(p, recv);
+ value_expr(p, arg1);
expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_loc), loc);
nd_set_line(expr, op_loc->beg_pos.lineno);
return expr;
@@ -10833,7 +12797,7 @@ static NODE *
call_uni_op(struct parser_params *p, NODE *recv, ID id, const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *opcall;
- value_expr(recv);
+ value_expr(p, recv);
opcall = NEW_OPCALL(recv, id, 0, loc);
nd_set_line(opcall, op_loc->beg_pos.lineno);
return opcall;
@@ -10858,16 +12822,35 @@ new_command_qcall(struct parser_params* p, ID atype, NODE *recv, ID mid, NODE *a
return ret;
}
-#define nd_once_body(node) (nd_type_p((node), NODE_ONCE) ? (node)->nd_body : node)
+static rb_locations_lambda_body_t*
+new_locations_lambda_body(struct parser_params* p, NODE *node, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc)
+{
+ rb_locations_lambda_body_t *body = xcalloc(1, sizeof(rb_locations_lambda_body_t));
+ body->node = node;
+ body->opening_loc = *opening_loc;
+ body->closing_loc = *closing_loc;
+ return body;
+}
+
+#define nd_once_body(node) (nd_type_p((node), NODE_ONCE) ? RNODE_ONCE(node)->nd_body : node)
+
+static NODE*
+last_expr_once_body(NODE *node)
+{
+ if (!node) return 0;
+ return nd_once_body(node);
+}
+
static NODE*
match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *n;
int line = op_loc->beg_pos.lineno;
- value_expr(node1);
- value_expr(node2);
- if (node1 && (n = nd_once_body(node1)) != 0) {
+ value_expr(p, node1);
+ value_expr(p, node2);
+
+ if ((n = last_expr_once_body(node1)) != 0) {
switch (nd_type(n)) {
case NODE_DREGX:
{
@@ -10876,24 +12859,23 @@ match_op(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *op_lo
return match;
}
- case NODE_LIT:
- if (RB_TYPE_P(n->nd_lit, T_REGEXP)) {
- const VALUE lit = n->nd_lit;
- NODE *match = NEW_MATCH2(node1, node2, loc);
- match->nd_args = reg_named_capture_assign(p, lit, loc);
- nd_set_line(match, line);
- return match;
+ case NODE_REGX:
+ {
+ const VALUE lit = rb_node_regx_string_val(n);
+ if (!NIL_P(lit)) {
+ NODE *match = NEW_MATCH2(node1, node2, loc);
+ RNODE_MATCH2(match)->nd_args = reg_named_capture_assign(p, lit, loc, assignable);
+ nd_set_line(match, line);
+ return match;
+ }
}
}
}
- if (node2 && (n = nd_once_body(node2)) != 0) {
+ if ((n = last_expr_once_body(node2)) != 0) {
NODE *match3;
switch (nd_type(n)) {
- case NODE_LIT:
- if (!RB_TYPE_P(n->nd_lit, T_REGEXP)) break;
- /* fallthru */
case NODE_DREGX:
match3 = NEW_MATCH3(node2, node1, loc);
return match3;
@@ -10926,16 +12908,44 @@ numparam_nested_p(struct parser_params *p)
NODE *inner = local->numparam.inner;
if (outer || inner) {
NODE *used = outer ? outer : inner;
- compile_error(p, "numbered parameter is already used in\n"
- "%s:%d: %s block here",
- p->ruby_sourcefile, nd_line(used),
- outer ? "outer" : "inner");
+ compile_error(p, "numbered parameter is already used in %s block\n"
+ "%s:%d: numbered parameter is already used here",
+ outer ? "outer" : "inner",
+ p->ruby_sourcefile, nd_line(used));
parser_show_error_line(p, &used->nd_loc);
return 1;
}
return 0;
}
+static int
+numparam_used_p(struct parser_params *p)
+{
+ NODE *numparam = p->lvtbl->numparam.current;
+ if (numparam) {
+ compile_error(p, "'it' is not allowed when a numbered parameter is already used\n"
+ "%s:%d: numbered parameter is already used here",
+ p->ruby_sourcefile, nd_line(numparam));
+ parser_show_error_line(p, &numparam->nd_loc);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+it_used_p(struct parser_params *p)
+{
+ NODE *it = p->lvtbl->it;
+ if (it) {
+ compile_error(p, "numbered parameters are not allowed when 'it' is already used\n"
+ "%s:%d: 'it' is already used here",
+ p->ruby_sourcefile, nd_line(it));
+ parser_show_error_line(p, &it->nd_loc);
+ return 1;
+ }
+ return 0;
+}
+
static NODE*
gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
{
@@ -10955,44 +12965,31 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
VALUE file = p->ruby_sourcefile_string;
if (NIL_P(file))
file = rb_str_new(0, 0);
- else
- file = rb_str_dup(file);
- node = NEW_STR(file, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, file);
+ node = NEW_FILE(file, loc);
}
return node;
case keyword__LINE__:
- return NEW_LIT(INT2FIX(p->tokline), loc);
+ return NEW_LINE(loc);
case keyword__ENCODING__:
- node = NEW_LIT(rb_enc_from_encoding(p->enc), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
- return node;
+ return NEW_ENCODING(loc);
}
switch (id_type(id)) {
case ID_LOCAL:
if (dyna_in_block(p) && dvar_defined_ref(p, id, &vidp)) {
- if (NUMPARAM_ID_P(id) && numparam_nested_p(p)) return 0;
- if (id == p->cur_arg) {
- compile_error(p, "circular argument reference - %"PRIsWARN, rb_id2str(id));
- return 0;
- }
+ if (NUMPARAM_ID_P(id) && (numparam_nested_p(p) || it_used_p(p))) return 0;
if (vidp) *vidp |= LVAR_USED;
node = NEW_DVAR(id, loc);
return node;
}
if (local_id_ref(p, id, &vidp)) {
- if (id == p->cur_arg) {
- compile_error(p, "circular argument reference - %"PRIsWARN, rb_id2str(id));
- return 0;
- }
if (vidp) *vidp |= LVAR_USED;
node = NEW_LVAR(id, loc);
return node;
}
if (dyna_in_block(p) && NUMPARAM_ID_P(id) &&
parser_numbered_param(p, NUMPARAM_ID_TO_IDX(id))) {
- if (numparam_nested_p(p)) return 0;
+ if (numparam_nested_p(p) || it_used_p(p)) return 0;
node = NEW_DVAR(id, loc);
struct local_vars *local = p->lvtbl;
if (!local->numparam.current) local->numparam.current = node;
@@ -11004,6 +13001,20 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
}
# endif
/* method call without arguments */
+ if (dyna_in_block(p) && id == idIt && !(DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev))) {
+ if (numparam_used_p(p)) return 0;
+ if (p->max_numparam == ORDINAL_PARAM) {
+ compile_error(p, "ordinary parameter is defined");
+ return 0;
+ }
+ if (!p->it_id) {
+ p->it_id = idItImplicit;
+ vtable_add(p->lvtbl->args, p->it_id);
+ }
+ NODE *node = NEW_DVAR(p->it_id, loc);
+ if (!p->lvtbl->it) p->lvtbl->it = node;
+ return node;
+ }
return NEW_VCALL(id, loc);
case ID_GLOBAL:
return NEW_GVAR(id, loc);
@@ -11018,34 +13029,71 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
return 0;
}
-static NODE *
-opt_arg_append(NODE *opt_list, NODE *opt)
+static rb_node_opt_arg_t *
+opt_arg_append(rb_node_opt_arg_t *opt_list, rb_node_opt_arg_t *opt)
{
- NODE *opts = opt_list;
- opts->nd_loc.end_pos = opt->nd_loc.end_pos;
+ rb_node_opt_arg_t *opts = opt_list;
+ RNODE(opts)->nd_loc.end_pos = RNODE(opt)->nd_loc.end_pos;
while (opts->nd_next) {
opts = opts->nd_next;
- opts->nd_loc.end_pos = opt->nd_loc.end_pos;
+ RNODE(opts)->nd_loc.end_pos = RNODE(opt)->nd_loc.end_pos;
}
opts->nd_next = opt;
return opt_list;
}
-static NODE *
-kwd_append(NODE *kwlist, NODE *kw)
+static rb_node_kw_arg_t *
+kwd_append(rb_node_kw_arg_t *kwlist, rb_node_kw_arg_t *kw)
{
if (kwlist) {
- opt_arg_append(kwlist, kw);
+ /* Assume rb_node_kw_arg_t and rb_node_opt_arg_t has same structure */
+ opt_arg_append(RNODE_OPT_ARG(kwlist), RNODE_OPT_ARG(kw));
}
return kwlist;
}
static NODE *
-new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
+new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc, const YYLTYPE *keyword_loc)
+{
+ int had_trailing_semicolon = p->ctxt.has_trailing_semicolon;
+ p->ctxt.has_trailing_semicolon = 0;
+
+ NODE *n = expr;
+ while (n) {
+ if (nd_type_p(n, NODE_BEGIN)) {
+ n = RNODE_BEGIN(n)->nd_body;
+ }
+ else if (nd_type_p(n, NODE_BLOCK) && RNODE_BLOCK(n)->nd_end == n) {
+ n = RNODE_BLOCK(n)->nd_head;
+ }
+ else {
+ break;
+ }
+ }
+
+ if (had_trailing_semicolon && !nd_type_p(expr, NODE_BLOCK)) {
+ NODE *block = NEW_BLOCK(expr, loc);
+ return NEW_DEFINED(block, loc, keyword_loc);
+ }
+
+ return NEW_DEFINED(n, loc, keyword_loc);
+}
+
+static NODE*
+str_to_sym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
- return NEW_DEFINED(remove_begin_all(expr), loc);
+ VALUE lit;
+ rb_parser_string_t *str = RNODE_STR(node)->string;
+ if (rb_parser_enc_str_coderange(p, str) == RB_PARSER_ENC_CODERANGE_BROKEN) {
+ yyerror1(loc, "invalid symbol");
+ lit = STR_NEW0();
+ }
+ else {
+ lit = rb_str_new_parser_string(str);
+ }
+ return NEW_SYM(lit, loc);
}
static NODE*
@@ -11057,96 +13105,80 @@ symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol)
nd_set_type(symbol, NODE_DSYM);
break;
case NODE_STR:
- nd_set_type(symbol, NODE_LIT);
- RB_OBJ_WRITTEN(p->ast, Qnil, symbol->nd_lit = rb_str_intern(symbol->nd_lit));
+ symbol = str_to_sym_node(p, symbol, &RNODE(symbol)->nd_loc);
break;
default:
- compile_error(p, "unexpected node as symbol: %s", ruby_node_name(type));
+ compile_error(p, "unexpected node as symbol: %s", parser_node_name(type));
}
return list_append(p, symbols, symbol);
}
-static NODE *
-new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc)
+static void
+dregex_fragment_setenc(struct parser_params *p, rb_node_dregx_t *const dreg, int options)
{
- NODE *list, *prev;
- VALUE lit;
+ if (dreg->string) {
+ reg_fragment_setenc(p, dreg->string, options);
+ }
+ for (struct RNode_LIST *list = dreg->nd_next; list; list = RNODE_LIST(list->nd_next)) {
+ NODE *frag = list->nd_head;
+ if (nd_type_p(frag, NODE_STR)) {
+ reg_fragment_setenc(p, RNODE_STR(frag)->string, options);
+ }
+ else if (nd_type_p(frag, NODE_DSTR)) {
+ dregex_fragment_setenc(p, RNODE_DSTR(frag), options);
+ }
+ }
+}
+static NODE *
+new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc, const YYLTYPE *opening_loc, const YYLTYPE *content_loc, const YYLTYPE *closing_loc)
+{
if (!node) {
- node = NEW_LIT(reg_compile(p, STR_NEW0(), options), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit);
+ /* Check string is valid regex */
+ rb_parser_string_t *str = STRING_NEW0();
+ reg_compile(p, str, options);
+ node = NEW_REGX(str, options, loc, opening_loc, content_loc, closing_loc);
return node;
}
switch (nd_type(node)) {
case NODE_STR:
{
- VALUE src = node->nd_lit;
- nd_set_type(node, NODE_LIT);
- nd_set_loc(node, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = reg_compile(p, src, options));
+ /* Check string is valid regex */
+ reg_compile(p, RNODE_STR(node)->string, options);
+ node = str2regx(p, node, options, loc, opening_loc, content_loc, closing_loc);
}
break;
default:
- lit = STR_NEW0();
- node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, loc), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, lit);
+ node = NEW_DSTR0(STRING_NEW0(), 1, NEW_LIST(node, loc), loc);
/* fall through */
case NODE_DSTR:
nd_set_type(node, NODE_DREGX);
nd_set_loc(node, loc);
- node->nd_cflag = options & RE_OPTION_MASK;
- if (!NIL_P(node->nd_lit)) reg_fragment_check(p, node->nd_lit, options);
- for (list = (prev = node)->nd_next; list; list = list->nd_next) {
- NODE *frag = list->nd_head;
- enum node_type type = nd_type(frag);
- if (type == NODE_STR || (type == NODE_DSTR && !frag->nd_next)) {
- VALUE tail = frag->nd_lit;
- if (reg_fragment_check(p, tail, options) && prev && !NIL_P(prev->nd_lit)) {
- VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
- if (!literal_concat0(p, lit, tail)) {
- return NEW_NIL(loc); /* dummy node on error */
- }
- rb_str_resize(tail, 0);
- prev->nd_next = list->nd_next;
- rb_discard_node(p, list->nd_head);
- rb_discard_node(p, list);
- list = prev;
- }
- else {
- prev = list;
- }
- }
- else {
- prev = 0;
- }
- }
- if (!node->nd_next) {
- VALUE src = node->nd_lit;
- nd_set_type(node, NODE_LIT);
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = reg_compile(p, src, options));
+ rb_node_dregx_t *const dreg = RNODE_DREGX(node);
+ dreg->as.nd_cflag = options & RE_OPTION_MASK;
+ if (dreg->nd_next) {
+ dregex_fragment_setenc(p, dreg, options);
}
if (options & RE_OPTION_ONCE) {
- node = NEW_NODE(NODE_ONCE, 0, node, 0, loc);
+ node = NEW_ONCE(node, loc);
}
break;
}
return node;
}
-static NODE *
+static rb_node_kw_arg_t *
new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc)
{
if (!k) return 0;
- return NEW_KW_ARG(0, (k), loc);
+ return NEW_KW_ARG((k), loc);
}
static NODE *
new_xstring(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
if (!node) {
- VALUE lit = STR_NEW0();
- NODE *xstr = NEW_XSTR(lit, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, lit);
+ NODE *xstr = NEW_XSTR(STRING_NEW0(), loc);
return xstr;
}
switch (nd_type(node)) {
@@ -11159,40 +13191,42 @@ new_xstring(struct parser_params *p, NODE *node, const YYLTYPE *loc)
nd_set_loc(node, loc);
break;
default:
- node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, loc), loc);
+ node = NEW_DXSTR(0, 1, NEW_LIST(node, loc), loc);
break;
}
return node;
}
+static const
+struct st_hash_type literal_type = {
+ literal_cmp,
+ literal_hash,
+};
+
+static int nd_type_st_key_enable_p(NODE *node);
+
static void
check_literal_when(struct parser_params *p, NODE *arg, const YYLTYPE *loc)
{
- VALUE lit;
-
+ /* See https://bugs.ruby-lang.org/issues/20331 for discussion about what is warned. */
if (!arg || !p->case_labels) return;
+ if (!nd_type_st_key_enable_p(arg)) return;
- lit = rb_node_case_when_optimizable_literal(arg);
- if (UNDEF_P(lit)) return;
- if (nd_type_p(arg, NODE_STR)) {
- RB_OBJ_WRITTEN(p->ast, Qnil, arg->nd_lit = lit);
- }
-
- if (NIL_P(p->case_labels)) {
- p->case_labels = rb_obj_hide(rb_hash_new());
+ if (p->case_labels == CHECK_LITERAL_WHEN) {
+ p->case_labels = st_init_table(&literal_type);
}
else {
- VALUE line = rb_hash_lookup(p->case_labels, lit);
- if (!NIL_P(line)) {
- rb_warning1("duplicated `when' clause with line %d is ignored",
- WARN_IVAL(line));
+ st_data_t line;
+ if (st_lookup(p->case_labels, (st_data_t)arg, &line)) {
+ rb_warning2("'when' clause on line %d duplicates 'when' clause on line %d and is ignored",
+ WARN_I((int)nd_line(arg)), WARN_I((int)line));
return;
}
}
- rb_hash_aset(p->case_labels, lit, INT2NUM(p->ruby_sourceline));
+ st_insert(p->case_labels, (st_data_t)arg, (st_data_t)p->ruby_sourceline);
}
-#else /* !RIPPER */
+#ifdef RIPPER
static int
id_is_var(struct parser_params *p, ID id)
{
@@ -11212,26 +13246,7 @@ id_is_var(struct parser_params *p, ID id)
compile_error(p, "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
return 0;
}
-
-static VALUE
-new_regexp(struct parser_params *p, VALUE re, VALUE opt, const YYLTYPE *loc)
-{
- VALUE src = 0, err;
- int options = 0;
- if (ripper_is_node_yylval(re)) {
- src = RNODE(re)->nd_cval;
- re = RNODE(re)->nd_rval;
- }
- if (ripper_is_node_yylval(opt)) {
- options = (int)RNODE(opt)->nd_tag;
- opt = RNODE(opt)->nd_rval;
- }
- if (src && NIL_P(parser_reg_compile(p, src, options, &err))) {
- compile_error(p, "%"PRIsVALUE, err);
- }
- return dispatch2(regexp_literal, re, opt);
-}
-#endif /* !RIPPER */
+#endif
static inline enum lex_state_e
parser_set_lex_state(struct parser_params *p, enum lex_state_e ls, int line)
@@ -11243,6 +13258,20 @@ parser_set_lex_state(struct parser_params *p, enum lex_state_e ls, int line)
}
#ifndef RIPPER
+static void
+flush_debug_buffer(struct parser_params *p, VALUE out, VALUE str)
+{
+ VALUE mesg = p->debug_buffer;
+
+ if (!NIL_P(mesg) && RSTRING_LEN(mesg)) {
+ p->debug_buffer = Qnil;
+ rb_io_puts(1, &mesg, out);
+ }
+ if (!NIL_P(str) && RSTRING_LEN(str)) {
+ rb_io_write(p->debug_output, str);
+ }
+}
+
static const char rb_parser_lex_state_names[][8] = {
"BEG", "END", "ENDARG", "ENDFN", "ARG",
"CMDARG", "MID", "FNAME", "DOT", "CLASS",
@@ -11250,7 +13279,7 @@ static const char rb_parser_lex_state_names[][8] = {
};
static VALUE
-append_lex_state_name(enum lex_state_e state, VALUE buf)
+append_lex_state_name(struct parser_params *p, enum lex_state_e state, VALUE buf)
{
int i, sep = 0;
unsigned int mask = 1;
@@ -11271,42 +13300,28 @@ append_lex_state_name(enum lex_state_e state, VALUE buf)
return buf;
}
-static void
-flush_debug_buffer(struct parser_params *p, VALUE out, VALUE str)
-{
- VALUE mesg = p->debug_buffer;
-
- if (!NIL_P(mesg) && RSTRING_LEN(mesg)) {
- p->debug_buffer = Qnil;
- rb_io_puts(1, &mesg, out);
- }
- if (!NIL_P(str) && RSTRING_LEN(str)) {
- rb_io_write(p->debug_output, str);
- }
-}
-
enum lex_state_e
rb_parser_trace_lex_state(struct parser_params *p, enum lex_state_e from,
enum lex_state_e to, int line)
{
VALUE mesg;
mesg = rb_str_new_cstr("lex_state: ");
- append_lex_state_name(from, mesg);
+ append_lex_state_name(p, from, mesg);
rb_str_cat_cstr(mesg, " -> ");
- append_lex_state_name(to, mesg);
+ append_lex_state_name(p, to, mesg);
rb_str_catf(mesg, " at line %d\n", line);
flush_debug_buffer(p, p->debug_output, mesg);
return to;
}
VALUE
-rb_parser_lex_state_name(enum lex_state_e state)
+rb_parser_lex_state_name(struct parser_params *p, enum lex_state_e state)
{
- return rb_fstring(append_lex_state_name(state, rb_str_new(0, 0)));
+ return rb_str_to_interned_str(append_lex_state_name(p, state, rb_str_new(0, 0)));
}
static void
-append_bitstack_value(stack_type stack, VALUE mesg)
+append_bitstack_value(struct parser_params *p, stack_type stack, VALUE mesg)
{
if (stack == 0) {
rb_str_cat_cstr(mesg, "0");
@@ -11323,7 +13338,7 @@ rb_parser_show_bitstack(struct parser_params *p, stack_type stack,
const char *name, int line)
{
VALUE mesg = rb_sprintf("%s: ", name);
- append_bitstack_value(stack, mesg);
+ append_bitstack_value(p, stack, mesg);
rb_str_catf(mesg, " at line %d\n", line);
flush_debug_buffer(p, p->debug_output, mesg);
}
@@ -11341,13 +13356,13 @@ rb_parser_fatal(struct parser_params *p, const char *fmt, ...)
RB_GC_GUARD(mesg);
mesg = rb_str_new(0, 0);
- append_lex_state_name(p->lex.state, mesg);
+ append_lex_state_name(p, p->lex.state, mesg);
compile_error(p, "lex.state: %"PRIsVALUE, mesg);
rb_str_resize(mesg, 0);
- append_bitstack_value(p->cond_stack, mesg);
+ append_bitstack_value(p, p->cond_stack, mesg);
compile_error(p, "cond_stack: %"PRIsVALUE, mesg);
rb_str_resize(mesg, 0);
- append_bitstack_value(p->cmdarg_stack, mesg);
+ append_bitstack_value(p, p->cmdarg_stack, mesg);
compile_error(p, "cmdarg_stack: %"PRIsVALUE, mesg);
if (p->debug_output == rb_ractor_stdout())
p->debug_output = rb_ractor_stderr();
@@ -11481,7 +13496,6 @@ assignable0(struct parser_params *p, ID id, const char **err)
return -1;
}
-#ifndef RIPPER
static NODE*
assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc)
{
@@ -11492,25 +13506,20 @@ assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc)
case NODE_LASGN: return NEW_LASGN(id, val, loc);
case NODE_GASGN: return NEW_GASGN(id, val, loc);
case NODE_IASGN: return NEW_IASGN(id, val, loc);
- case NODE_CDECL: return NEW_CDECL(id, val, 0, loc);
+ case NODE_CDECL: return NEW_CDECL(id, val, 0, p->ctxt.shareable_constant_value, loc);
case NODE_CVASGN: return NEW_CVASGN(id, val, loc);
}
+/* TODO: FIXME */
+#ifndef RIPPER
if (err) yyerror1(loc, err);
- return NEW_BEGIN(0, loc);
-}
#else
-static VALUE
-assignable(struct parser_params *p, VALUE lhs)
-{
- const char *err = 0;
- assignable0(p, get_id(lhs), &err);
- if (err) lhs = assign_error(p, err, lhs);
- return lhs;
-}
+ if (err) set_value(assign_error(p, err, p->s_lvalue));
#endif
+ return NEW_ERROR(loc);
+}
static int
-is_private_local_id(ID name)
+is_private_local_id(struct parser_params *p, ID name)
{
VALUE s;
if (name == idUScore) return 1;
@@ -11525,7 +13534,7 @@ shadowing_lvar_0(struct parser_params *p, ID name)
{
if (dyna_in_block(p)) {
if (dvar_curr(p, name)) {
- if (is_private_local_id(name)) return 1;
+ if (is_private_local_id(p, name)) return 1;
yyerror0("duplicated argument name");
}
else if (dvar_defined(p, name) || local_id(p, name)) {
@@ -11538,7 +13547,7 @@ shadowing_lvar_0(struct parser_params *p, ID name)
}
else {
if (local_id(p, name)) {
- if (is_private_local_id(name)) return 1;
+ if (is_private_local_id(p, name)) return 1;
yyerror0("duplicated argument name");
}
}
@@ -11563,12 +13572,44 @@ new_bv(struct parser_params *p, ID name)
}
if (!shadowing_lvar_0(p, name)) return;
dyna_var(p, name);
+ ID *vidp = 0;
+ if (dvar_defined_ref(p, name, &vidp)) {
+ if (vidp) *vidp |= LVAR_USED;
+ }
+}
+
+static void
+aryset_check(struct parser_params *p, NODE *args)
+{
+ NODE *block = 0, *kwds = 0;
+ if (args && nd_type_p(args, NODE_BLOCK_PASS)) {
+ block = RNODE_BLOCK_PASS(args)->nd_body;
+ args = RNODE_BLOCK_PASS(args)->nd_head;
+ }
+ if (args && nd_type_p(args, NODE_ARGSCAT)) {
+ args = RNODE_ARGSCAT(args)->nd_body;
+ }
+ if (args && nd_type_p(args, NODE_ARGSPUSH)) {
+ kwds = RNODE_ARGSPUSH(args)->nd_body;
+ }
+ else {
+ for (NODE *next = args; next && nd_type_p(next, NODE_LIST);
+ next = RNODE_LIST(next)->nd_next) {
+ kwds = RNODE_LIST(next)->nd_head;
+ }
+ }
+ if (kwds && nd_type_p(kwds, NODE_HASH) && !RNODE_HASH(kwds)->nd_brace) {
+ yyerror1(&kwds->nd_loc, "keyword arg given in index assignment");
+ }
+ if (block) {
+ yyerror1(&block->nd_loc, "block arg given in index assignment");
+ }
}
-#ifndef RIPPER
static NODE *
aryset(struct parser_params *p, NODE *recv, NODE *idx, const YYLTYPE *loc)
{
+ aryset_check(p, idx);
return NEW_ATTRASGN(recv, tASET, idx, loc);
}
@@ -11587,29 +13628,24 @@ attrset(struct parser_params *p, NODE *recv, ID atype, ID id, const YYLTYPE *loc
return NEW_ATTRASGN(recv, id, 0, loc);
}
-static void
+static VALUE
rb_backref_error(struct parser_params *p, NODE *node)
{
+#ifndef RIPPER
+# define ERR(...) (compile_error(p, __VA_ARGS__), Qtrue)
+#else
+# define ERR(...) rb_sprintf(__VA_ARGS__)
+#endif
switch (nd_type(node)) {
case NODE_NTH_REF:
- compile_error(p, "Can't set variable $%ld", node->nd_nth);
- break;
+ return ERR("Can't set variable $%ld", RNODE_NTH_REF(node)->nd_nth);
case NODE_BACK_REF:
- compile_error(p, "Can't set variable $%c", (int)node->nd_nth);
- break;
+ return ERR("Can't set variable $%c", (int)RNODE_BACK_REF(node)->nd_nth);
}
+#undef ERR
+ UNREACHABLE_RETURN(Qfalse); /* only called on syntax error */
}
-#else
-static VALUE
-backref_error(struct parser_params *p, NODE *ref, VALUE expr)
-{
- VALUE mesg = rb_str_new_cstr("Can't set variable ");
- rb_str_append(mesg, ref->nd_cval);
- return dispatch2(assign_error, mesg, expr);
-}
-#endif
-#ifndef RIPPER
static NODE *
arg_append(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *loc)
{
@@ -11618,18 +13654,18 @@ arg_append(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *loc
case NODE_LIST:
return list_append(p, node1, node2);
case NODE_BLOCK_PASS:
- node1->nd_head = arg_append(p, node1->nd_head, node2, loc);
- node1->nd_loc.end_pos = node1->nd_head->nd_loc.end_pos;
+ RNODE_BLOCK_PASS(node1)->nd_head = arg_append(p, RNODE_BLOCK_PASS(node1)->nd_head, node2, loc);
+ node1->nd_loc.end_pos = RNODE_BLOCK_PASS(node1)->nd_head->nd_loc.end_pos;
return node1;
case NODE_ARGSPUSH:
- node1->nd_body = list_append(p, NEW_LIST(node1->nd_body, &node1->nd_body->nd_loc), node2);
- node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos;
+ RNODE_ARGSPUSH(node1)->nd_body = list_append(p, NEW_LIST(RNODE_ARGSPUSH(node1)->nd_body, &RNODE_ARGSPUSH(node1)->nd_body->nd_loc), node2);
+ node1->nd_loc.end_pos = RNODE_ARGSPUSH(node1)->nd_body->nd_loc.end_pos;
nd_set_type(node1, NODE_ARGSCAT);
return node1;
case NODE_ARGSCAT:
- if (!nd_type_p(node1->nd_body, NODE_LIST)) break;
- node1->nd_body = list_append(p, node1->nd_body, node2);
- node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos;
+ if (!nd_type_p(RNODE_ARGSCAT(node1)->nd_body, NODE_LIST)) break;
+ RNODE_ARGSCAT(node1)->nd_body = list_append(p, RNODE_ARGSCAT(node1)->nd_body, node2);
+ node1->nd_loc.end_pos = RNODE_ARGSCAT(node1)->nd_body->nd_loc.end_pos;
return node1;
}
return NEW_ARGSPUSH(node1, node2, loc);
@@ -11641,20 +13677,20 @@ arg_concat(struct parser_params *p, NODE *node1, NODE *node2, const YYLTYPE *loc
if (!node2) return node1;
switch (nd_type(node1)) {
case NODE_BLOCK_PASS:
- if (node1->nd_head)
- node1->nd_head = arg_concat(p, node1->nd_head, node2, loc);
+ if (RNODE_BLOCK_PASS(node1)->nd_head)
+ RNODE_BLOCK_PASS(node1)->nd_head = arg_concat(p, RNODE_BLOCK_PASS(node1)->nd_head, node2, loc);
else
- node1->nd_head = NEW_LIST(node2, loc);
+ RNODE_LIST(node1)->nd_head = NEW_LIST(node2, loc);
return node1;
case NODE_ARGSPUSH:
if (!nd_type_p(node2, NODE_LIST)) break;
- node1->nd_body = list_concat(NEW_LIST(node1->nd_body, loc), node2);
+ RNODE_ARGSPUSH(node1)->nd_body = list_concat(NEW_LIST(RNODE_ARGSPUSH(node1)->nd_body, loc), node2);
nd_set_type(node1, NODE_ARGSCAT);
return node1;
case NODE_ARGSCAT:
if (!nd_type_p(node2, NODE_LIST) ||
- !nd_type_p(node1->nd_body, NODE_LIST)) break;
- node1->nd_body = list_concat(node1->nd_body, node2);
+ !nd_type_p(RNODE_ARGSCAT(node1)->nd_body, NODE_LIST)) break;
+ RNODE_ARGSCAT(node1)->nd_body = list_concat(RNODE_ARGSCAT(node1)->nd_body, node2);
return node1;
}
return NEW_ARGSCAT(node1, node2, loc);
@@ -11683,7 +13719,7 @@ rest_arg_append(struct parser_params *p, NODE *args, NODE *rest_arg, const YYLTY
static NODE *
splat_array(NODE* node)
{
- if (nd_type_p(node, NODE_SPLAT)) node = node->nd_head;
+ if (nd_type_p(node, NODE_SPLAT)) node = RNODE_SPLAT(node)->nd_head;
if (nd_type_p(node, NODE_LIST)) return node;
return 0;
}
@@ -11695,12 +13731,12 @@ mark_lvar_used(struct parser_params *p, NODE *rhs)
if (!rhs) return;
switch (nd_type(rhs)) {
case NODE_LASGN:
- if (local_id_ref(p, rhs->nd_vid, &vidp)) {
+ if (local_id_ref(p, RNODE_LASGN(rhs)->nd_vid, &vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
break;
case NODE_DASGN:
- if (dvar_defined_ref(p, rhs->nd_vid, &vidp)) {
+ if (dvar_defined_ref(p, RNODE_DASGN(rhs)->nd_vid, &vidp)) {
if (vidp) *vidp |= LVAR_USED;
}
break;
@@ -11714,252 +13750,8 @@ mark_lvar_used(struct parser_params *p, NODE *rhs)
}
}
-static NODE *
-const_decl_path(struct parser_params *p, NODE **dest)
-{
- NODE *n = *dest;
- if (!nd_type_p(n, NODE_CALL)) {
- const YYLTYPE *loc = &n->nd_loc;
- VALUE path;
- if (n->nd_vid) {
- path = rb_id2str(n->nd_vid);
- }
- else {
- n = n->nd_else;
- path = rb_ary_new();
- for (; n && nd_type_p(n, NODE_COLON2); n = n->nd_head) {
- rb_ary_push(path, rb_id2str(n->nd_mid));
- }
- if (n && nd_type_p(n, NODE_CONST)) {
- // Const::Name
- rb_ary_push(path, rb_id2str(n->nd_vid));
- }
- else if (n && nd_type_p(n, NODE_COLON3)) {
- // ::Const::Name
- rb_ary_push(path, rb_str_new(0, 0));
- }
- else {
- // expression::Name
- rb_ary_push(path, rb_str_new_cstr("..."));
- }
- path = rb_ary_join(rb_ary_reverse(path), rb_str_new_cstr("::"));
- path = rb_fstring(path);
- }
- *dest = n = NEW_LIT(path, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, n->nd_lit);
- }
- return n;
-}
-
-extern VALUE rb_mRubyVMFrozenCore;
-
-static NODE *
-make_shareable_node(struct parser_params *p, NODE *value, bool copy, const YYLTYPE *loc)
-{
- NODE *fcore = NEW_LIT(rb_mRubyVMFrozenCore, loc);
-
- if (copy) {
- return NEW_CALL(fcore, rb_intern("make_shareable_copy"),
- NEW_LIST(value, loc), loc);
- }
- else {
- return NEW_CALL(fcore, rb_intern("make_shareable"),
- NEW_LIST(value, loc), loc);
- }
-}
-
-static NODE *
-ensure_shareable_node(struct parser_params *p, NODE **dest, NODE *value, const YYLTYPE *loc)
-{
- NODE *fcore = NEW_LIT(rb_mRubyVMFrozenCore, loc);
- NODE *args = NEW_LIST(value, loc);
- args = list_append(p, args, const_decl_path(p, dest));
- return NEW_CALL(fcore, rb_intern("ensure_shareable"), args, loc);
-}
-
static int is_static_content(NODE *node);
-static VALUE
-shareable_literal_value(NODE *node)
-{
- if (!node) return Qnil;
- enum node_type type = nd_type(node);
- switch (type) {
- case NODE_TRUE:
- return Qtrue;
- case NODE_FALSE:
- return Qfalse;
- case NODE_NIL:
- return Qnil;
- case NODE_LIT:
- return node->nd_lit;
- default:
- return Qundef;
- }
-}
-
-#ifndef SHAREABLE_BARE_EXPRESSION
-#define SHAREABLE_BARE_EXPRESSION 1
-#endif
-
-static NODE *
-shareable_literal_constant(struct parser_params *p, enum shareability shareable,
- NODE **dest, NODE *value, const YYLTYPE *loc, size_t level)
-{
-# define shareable_literal_constant_next(n) \
- shareable_literal_constant(p, shareable, dest, (n), &(n)->nd_loc, level+1)
- VALUE lit = Qnil;
-
- if (!value) return 0;
- enum node_type type = nd_type(value);
- switch (type) {
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_NIL:
- case NODE_LIT:
- return value;
-
- case NODE_DSTR:
- if (shareable == shareable_literal) {
- value = NEW_CALL(value, idUMinus, 0, loc);
- }
- return value;
-
- case NODE_STR:
- lit = rb_fstring(value->nd_lit);
- nd_set_type(value, NODE_LIT);
- RB_OBJ_WRITE(p->ast, &value->nd_lit, lit);
- return value;
-
- case NODE_ZLIST:
- lit = rb_ary_new();
- OBJ_FREEZE_RAW(lit);
- NODE *n = NEW_LIT(lit, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, n->nd_lit);
- return n;
-
- case NODE_LIST:
- lit = rb_ary_new();
- for (NODE *n = value; n; n = n->nd_next) {
- NODE *elt = n->nd_head;
- if (elt) {
- elt = shareable_literal_constant_next(elt);
- if (elt) {
- n->nd_head = elt;
- }
- else if (RTEST(lit)) {
- rb_ary_clear(lit);
- lit = Qfalse;
- }
- }
- if (RTEST(lit)) {
- VALUE e = shareable_literal_value(elt);
- if (!UNDEF_P(e)) {
- rb_ary_push(lit, e);
- }
- else {
- rb_ary_clear(lit);
- lit = Qnil; /* make shareable at runtime */
- }
- }
- }
- break;
-
- case NODE_HASH:
- if (!value->nd_brace) return 0;
- lit = rb_hash_new();
- for (NODE *n = value->nd_head; n; n = n->nd_next->nd_next) {
- NODE *key = n->nd_head;
- NODE *val = n->nd_next->nd_head;
- if (key) {
- key = shareable_literal_constant_next(key);
- if (key) {
- n->nd_head = key;
- }
- else if (RTEST(lit)) {
- rb_hash_clear(lit);
- lit = Qfalse;
- }
- }
- if (val) {
- val = shareable_literal_constant_next(val);
- if (val) {
- n->nd_next->nd_head = val;
- }
- else if (RTEST(lit)) {
- rb_hash_clear(lit);
- lit = Qfalse;
- }
- }
- if (RTEST(lit)) {
- VALUE k = shareable_literal_value(key);
- VALUE v = shareable_literal_value(val);
- if (!UNDEF_P(k) && !UNDEF_P(v)) {
- rb_hash_aset(lit, k, v);
- }
- else {
- rb_hash_clear(lit);
- lit = Qnil; /* make shareable at runtime */
- }
- }
- }
- break;
-
- default:
- if (shareable == shareable_literal &&
- (SHAREABLE_BARE_EXPRESSION || level > 0)) {
- return ensure_shareable_node(p, dest, value, loc);
- }
- return 0;
- }
-
- /* Array or Hash */
- if (!lit) return 0;
- if (NIL_P(lit)) {
- // if shareable_literal, all elements should have been ensured
- // as shareable
- value = make_shareable_node(p, value, false, loc);
- }
- else {
- value = NEW_LIT(rb_ractor_make_shareable(lit), loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, value->nd_lit);
- }
-
- return value;
-# undef shareable_literal_constant_next
-}
-
-static NODE *
-shareable_constant_value(struct parser_params *p, enum shareability shareable,
- NODE *lhs, NODE *value, const YYLTYPE *loc)
-{
- if (!value) return 0;
- switch (shareable) {
- case shareable_none:
- return value;
-
- case shareable_literal:
- {
- NODE *lit = shareable_literal_constant(p, shareable, &lhs, value, loc, 0);
- if (lit) return lit;
- return value;
- }
- break;
-
- case shareable_copy:
- case shareable_everything:
- {
- NODE *lit = shareable_literal_constant(p, shareable, &lhs, value, loc, 0);
- if (lit) return lit;
- return make_shareable_node(p, value, shareable == shareable_copy, loc);
- }
- break;
-
- default:
- UNREACHABLE_RETURN(0);
- }
-}
-
static NODE *
node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, struct lex_context ctxt, const YYLTYPE *loc)
{
@@ -11967,21 +13759,18 @@ node_assign(struct parser_params *p, NODE *lhs, NODE *rhs, struct lex_context ct
switch (nd_type(lhs)) {
case NODE_CDECL:
- rhs = shareable_constant_value(p, ctxt.shareable_constant_value, lhs, rhs, loc);
- /* fallthru */
-
case NODE_GASGN:
case NODE_IASGN:
case NODE_LASGN:
case NODE_DASGN:
case NODE_MASGN:
case NODE_CVASGN:
- lhs->nd_value = rhs;
+ set_nd_value(p, lhs, rhs);
nd_set_loc(lhs, loc);
break;
case NODE_ATTRASGN:
- lhs->nd_args = arg_append(p, lhs->nd_args, rhs, loc);
+ RNODE_ATTRASGN(lhs)->nd_args = arg_append(p, RNODE_ATTRASGN(lhs)->nd_args, rhs, loc);
nd_set_loc(lhs, loc);
break;
@@ -12003,52 +13792,106 @@ value_expr_check(struct parser_params *p, NODE *node)
}
while (node) {
switch (nd_type(node)) {
+ case NODE_ENSURE:
+ vn = RNODE_ENSURE(node)->nd_head;
+ node = RNODE_ENSURE(node)->nd_ensr;
+ /* nd_ensr should not be NULL, check it out next */
+ if (vn && (vn = value_expr_check(p, vn))) {
+ goto found;
+ }
+ break;
+
+ case NODE_RESCUE:
+ /* void only if all children are void */
+ vn = RNODE_RESCUE(node)->nd_head;
+ if (!vn || !(vn = value_expr_check(p, vn))) {
+ if (!RNODE_RESCUE(node)->nd_else) return NULL;
+ }
+ if (!void_node) void_node = vn;
+ for (NODE *r = RNODE_RESCUE(node)->nd_resq; r; r = RNODE_RESBODY(r)->nd_next) {
+ if (!nd_type_p(r, NODE_RESBODY)) {
+ compile_error(p, "unexpected node");
+ return NULL;
+ }
+ if (!(vn = value_expr_check(p, RNODE_RESBODY(r)->nd_body))) {
+ return NULL;
+ }
+ if (!void_node) void_node = vn;
+ }
+ node = RNODE_RESCUE(node)->nd_else;
+ if (!node) return void_node;
+ break;
+
case NODE_RETURN:
case NODE_BREAK:
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- return void_node ? void_node : node;
+ goto found;
- case NODE_CASE3:
- if (!node->nd_body || !nd_type_p(node->nd_body, NODE_IN)) {
- compile_error(p, "unexpected node");
- return NULL;
+ case NODE_CASE:
+ case NODE_CASE2:
+ for (node = RNODE_CASE(node)->nd_body;
+ node && nd_type_p(node, NODE_WHEN);
+ node = RNODE_WHEN(node)->nd_next) {
+ if (!(vn = value_expr_check(p, RNODE_WHEN(node)->nd_body))) {
+ return NULL;
+ }
+ if (!void_node) void_node = vn;
}
- if (node->nd_body->nd_body) {
- return NULL;
+ break;
+
+ case NODE_CASE3:
+ {
+ NODE *in = RNODE_CASE3(node)->nd_body;
+ if (!in || !nd_type_p(in, NODE_IN)) {
+ compile_error(p, "unexpected node");
+ return NULL;
+ }
+ if (!RNODE_IN(in)->nd_body) {
+ /* single line pattern matching with "=>" operator */
+ goto found;
+ }
+ do {
+ vn = value_expr_check(p, RNODE_IN(in)->nd_body);
+ if (!vn) return NULL;
+ if (!void_node) void_node = vn;
+ in = RNODE_IN(in)->nd_next;
+ } while (in && nd_type_p(in, NODE_IN));
+ node = in; /* else */
}
- /* single line pattern matching */
- return void_node ? void_node : node;
+ break;
case NODE_BLOCK:
- while (node->nd_next) {
- node = node->nd_next;
+ while (RNODE_BLOCK(node)->nd_next) {
+ vn = value_expr_check(p, RNODE_BLOCK(node)->nd_head);
+ if (vn) return vn;
+ node = RNODE_BLOCK(node)->nd_next;
}
- node = node->nd_head;
+ node = RNODE_BLOCK(node)->nd_head;
break;
case NODE_BEGIN:
- node = node->nd_body;
+ node = RNODE_BEGIN(node)->nd_body;
break;
case NODE_IF:
case NODE_UNLESS:
- if (!node->nd_body) {
+ if (!RNODE_IF(node)->nd_body) {
return NULL;
}
- else if (!node->nd_else) {
+ else if (!RNODE_IF(node)->nd_else) {
return NULL;
}
- vn = value_expr_check(p, node->nd_body);
+ vn = value_expr_check(p, RNODE_IF(node)->nd_body);
if (!vn) return NULL;
if (!void_node) void_node = vn;
- node = node->nd_else;
+ node = RNODE_IF(node)->nd_else;
break;
case NODE_AND:
case NODE_OR:
- node = node->nd_1st;
+ node = RNODE_AND(node)->nd_1st;
break;
case NODE_LASGN:
@@ -12063,10 +13906,14 @@ value_expr_check(struct parser_params *p, NODE *node)
}
return NULL;
+
+ found:
+ /* return the first found node */
+ return void_node ? void_node : node;
}
static int
-value_expr_gen(struct parser_params *p, NODE *node)
+value_expr(struct parser_params *p, NODE *node)
{
NODE *void_node = value_expr_check(p, node);
if (void_node) {
@@ -12076,6 +13923,7 @@ value_expr_gen(struct parser_params *p, NODE *node)
}
return TRUE;
}
+
static void
void_expr(struct parser_params *p, NODE *node)
{
@@ -12086,7 +13934,7 @@ void_expr(struct parser_params *p, NODE *node)
if (!node || !(node = nd_once_body(node))) return;
switch (nd_type(node)) {
case NODE_OPCALL:
- switch (node->nd_mid) {
+ switch (RNODE_OPCALL(node)->nd_mid) {
case '+':
case '-':
case '*':
@@ -12105,7 +13953,7 @@ void_expr(struct parser_params *p, NODE *node)
case tLEQ:
case tEQ:
case tNEQ:
- useless = rb_id2name(node->nd_mid);
+ useless = rb_id2name(RNODE_OPCALL(node)->nd_mid);
break;
}
break;
@@ -12122,9 +13970,17 @@ void_expr(struct parser_params *p, NODE *node)
case NODE_CONST:
useless = "a constant";
break;
- case NODE_LIT:
+ case NODE_SYM:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
case NODE_STR:
case NODE_DSTR:
+ case NODE_REGX:
case NODE_DREGX:
useless = "a literal";
break;
@@ -12160,6 +14016,7 @@ void_expr(struct parser_params *p, NODE *node)
}
}
+/* warns useless use of block and returns the last statement node */
static NODE *
void_stmts(struct parser_params *p, NODE *node)
{
@@ -12168,29 +14025,19 @@ void_stmts(struct parser_params *p, NODE *node)
if (!node) return n;
if (!nd_type_p(node, NODE_BLOCK)) return n;
- while (node->nd_next) {
- void_expr(p, node->nd_head);
- node = node->nd_next;
+ while (RNODE_BLOCK(node)->nd_next) {
+ void_expr(p, RNODE_BLOCK(node)->nd_head);
+ node = RNODE_BLOCK(node)->nd_next;
}
- return n;
+ return RNODE_BLOCK(node)->nd_head;
}
static NODE *
remove_begin(NODE *node)
{
NODE **n = &node, *n1 = node;
- while (n1 && nd_type_p(n1, NODE_BEGIN) && n1->nd_body) {
- *n = n1 = n1->nd_body;
- }
- return node;
-}
-
-static NODE *
-remove_begin_all(NODE *node)
-{
- NODE **n = &node, *n1 = node;
- while (n1 && nd_type_p(n1, NODE_BEGIN)) {
- *n = n1 = n1->nd_body;
+ while (n1 && nd_type_p(n1, NODE_BEGIN) && RNODE_BEGIN(n1)->nd_body) {
+ *n = n1 = RNODE_BEGIN(n1)->nd_body;
}
return node;
}
@@ -12204,54 +14051,51 @@ reduce_nodes(struct parser_params *p, NODE **body)
*body = NEW_NIL(&NULL_LOC);
return;
}
-#define subnodes(n1, n2) \
- ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
- (!node->n2) ? (body = &node->n1, 1) : \
- (reduce_nodes(p, &node->n1), body = &node->n2, 1))
+#define subnodes(type, n1, n2) \
+ ((!type(node)->n1) ? (type(node)->n2 ? (body = &type(node)->n2, 1) : 0) : \
+ (!type(node)->n2) ? (body = &type(node)->n1, 1) : \
+ (reduce_nodes(p, &type(node)->n1), body = &type(node)->n2, 1))
while (node) {
- int newline = (int)(node->flags & NODE_FL_NEWLINE);
+ int newline = (int)nd_fl_newline(node);
switch (nd_type(node)) {
end:
case NODE_NIL:
*body = 0;
return;
- case NODE_RETURN:
- *body = node = node->nd_stts;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
- continue;
case NODE_BEGIN:
- *body = node = node->nd_body;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
+ *body = node = RNODE_BEGIN(node)->nd_body;
+ if (newline && node) nd_set_fl_newline(node);
continue;
case NODE_BLOCK:
- body = &node->nd_end->nd_head;
+ body = &RNODE_BLOCK(RNODE_BLOCK(node)->nd_end)->nd_head;
break;
case NODE_IF:
case NODE_UNLESS:
- if (subnodes(nd_body, nd_else)) break;
+ if (subnodes(RNODE_IF, nd_body, nd_else)) break;
return;
case NODE_CASE:
- body = &node->nd_body;
+ body = &RNODE_CASE(node)->nd_body;
break;
case NODE_WHEN:
- if (!subnodes(nd_body, nd_next)) goto end;
+ if (!subnodes(RNODE_WHEN, nd_body, nd_next)) goto end;
break;
case NODE_ENSURE:
- if (!subnodes(nd_head, nd_resq)) goto end;
+ body = &RNODE_ENSURE(node)->nd_head;
break;
case NODE_RESCUE:
- if (node->nd_else) {
- body = &node->nd_resq;
+ newline = 0; // RESBODY should not be a NEWLINE
+ if (RNODE_RESCUE(node)->nd_else) {
+ body = &RNODE_RESCUE(node)->nd_resq;
break;
}
- if (!subnodes(nd_head, nd_resq)) goto end;
+ if (!subnodes(RNODE_RESCUE, nd_head, nd_resq)) goto end;
break;
default:
return;
}
node = *body;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
+ if (newline && node) nd_set_fl_newline(node);
}
#undef subnodes
@@ -12263,12 +14107,20 @@ is_static_content(NODE *node)
if (!node) return 1;
switch (nd_type(node)) {
case NODE_HASH:
- if (!(node = node->nd_head)) break;
+ if (!(node = RNODE_HASH(node)->nd_head)) break;
case NODE_LIST:
do {
- if (!is_static_content(node->nd_head)) return 0;
- } while ((node = node->nd_next) != 0);
- case NODE_LIT:
+ if (!is_static_content(RNODE_LIST(node)->nd_head)) return 0;
+ } while ((node = RNODE_LIST(node)->nd_next) != 0);
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
case NODE_STR:
case NODE_NIL:
case NODE_TRUE:
@@ -12290,16 +14142,18 @@ assign_in_cond(struct parser_params *p, NODE *node)
case NODE_DASGN:
case NODE_GASGN:
case NODE_IASGN:
+ case NODE_CVASGN:
+ case NODE_CDECL:
break;
default:
return 0;
}
- if (!node->nd_value) return 1;
- if (is_static_content(node->nd_value)) {
+ if (!get_nd_value(p, node)) return 1;
+ if (is_static_content(get_nd_value(p, node))) {
/* reports always */
- parser_warn(p, node->nd_value, "found `= literal' in conditional, should be ==");
+ rb_warn0L(nd_line(get_nd_value(p, node)), "found '= literal' in conditional, should be ==");
}
return 1;
}
@@ -12310,14 +14164,15 @@ enum cond_type {
COND_IN_FF
};
-#define SWITCH_BY_COND_TYPE(t, w, arg) \
+#define SWITCH_BY_COND_TYPE(t, w, arg) do { \
switch (t) { \
case COND_IN_OP: break; \
case COND_IN_COND: rb_##w##0(arg "literal in condition"); break; \
case COND_IN_FF: rb_##w##0(arg "literal in flip-flop"); break; \
- }
+ } \
+} while (0)
-static NODE *cond0(struct parser_params*,NODE*,enum cond_type,const YYLTYPE*);
+static NODE *cond0(struct parser_params*,NODE*,enum cond_type,const YYLTYPE*,bool);
static NODE*
range_op(struct parser_params *p, NODE *node, const YYLTYPE *loc)
@@ -12327,68 +14182,92 @@ range_op(struct parser_params *p, NODE *node, const YYLTYPE *loc)
if (node == 0) return 0;
type = nd_type(node);
- value_expr(node);
- if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- if (!e_option_supplied(p)) parser_warn(p, node, "integer literal in flip-flop");
+ value_expr(p, node);
+ if (type == NODE_INTEGER) {
+ if (!e_option_supplied(p)) rb_warn0L(nd_line(node), "integer literal in flip-flop");
ID lineno = rb_intern("$.");
return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(lineno, loc), loc), loc);
}
- return cond0(p, node, COND_IN_FF, loc);
+ return cond0(p, node, COND_IN_FF, loc, true);
}
static NODE*
-cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *loc)
+cond0(struct parser_params *p, NODE *node, enum cond_type type, const YYLTYPE *loc, bool top)
{
if (node == 0) return 0;
if (!(node = nd_once_body(node))) return 0;
assign_in_cond(p, node);
switch (nd_type(node)) {
+ case NODE_BEGIN:
+ RNODE_BEGIN(node)->nd_body = cond0(p, RNODE_BEGIN(node)->nd_body, type, loc, top);
+ break;
+
case NODE_DSTR:
case NODE_EVSTR:
case NODE_STR:
- SWITCH_BY_COND_TYPE(type, warn, "string ")
+ case NODE_FILE:
+ SWITCH_BY_COND_TYPE(type, warn, "string ");
+ break;
+
+ case NODE_REGX:
+ if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warn, "regex ");
+ nd_set_type(node, NODE_MATCH);
break;
case NODE_DREGX:
- if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warning, "regex ")
+ if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warning, "regex ");
return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, loc), loc);
+ case NODE_BLOCK:
+ {
+ NODE *end = RNODE_BLOCK(node)->nd_end;
+ NODE **expr = &RNODE_BLOCK(end)->nd_head;
+ if (top) top = node == end;
+ *expr = cond0(p, *expr, type, loc, top);
+ }
+ break;
+
case NODE_AND:
case NODE_OR:
- node->nd_1st = cond0(p, node->nd_1st, COND_IN_COND, loc);
- node->nd_2nd = cond0(p, node->nd_2nd, COND_IN_COND, loc);
+ RNODE_AND(node)->nd_1st = cond0(p, RNODE_AND(node)->nd_1st, COND_IN_COND, loc, true);
+ RNODE_AND(node)->nd_2nd = cond0(p, RNODE_AND(node)->nd_2nd, COND_IN_COND, loc, true);
break;
case NODE_DOT2:
case NODE_DOT3:
- node->nd_beg = range_op(p, node->nd_beg, loc);
- node->nd_end = range_op(p, node->nd_end, loc);
- if (nd_type_p(node, NODE_DOT2)) nd_set_type(node,NODE_FLIP2);
- else if (nd_type_p(node, NODE_DOT3)) nd_set_type(node, NODE_FLIP3);
+ if (!top) break;
+ RNODE_DOT2(node)->nd_beg = range_op(p, RNODE_DOT2(node)->nd_beg, loc);
+ RNODE_DOT2(node)->nd_end = range_op(p, RNODE_DOT2(node)->nd_end, loc);
+ switch (nd_type(node)) {
+ case NODE_DOT2:
+ nd_set_type(node,NODE_FLIP2);
+ rb_node_flip2_t *flip2 = RNODE_FLIP2(node); /* for debug info */
+ (void)flip2;
+ break;
+ case NODE_DOT3:
+ nd_set_type(node, NODE_FLIP3);
+ rb_node_flip3_t *flip3 = RNODE_FLIP3(node); /* for debug info */
+ (void)flip3;
+ break;
+ }
break;
+ case NODE_SYM:
case NODE_DSYM:
- warn_symbol:
- SWITCH_BY_COND_TYPE(type, warning, "symbol ")
+ SWITCH_BY_COND_TYPE(type, warning, "symbol ");
+ break;
+
+ case NODE_LINE:
+ case NODE_ENCODING:
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ SWITCH_BY_COND_TYPE(type, warning, "");
break;
- case NODE_LIT:
- if (RB_TYPE_P(node->nd_lit, T_REGEXP)) {
- if (!e_option_supplied(p)) SWITCH_BY_COND_TYPE(type, warn, "regex ")
- nd_set_type(node, NODE_MATCH);
- }
- else if (node->nd_lit == Qtrue ||
- node->nd_lit == Qfalse) {
- /* booleans are OK, e.g., while true */
- }
- else if (SYMBOL_P(node->nd_lit)) {
- goto warn_symbol;
- }
- else {
- SWITCH_BY_COND_TYPE(type, warning, "")
- }
default:
break;
}
@@ -12399,14 +14278,14 @@ static NODE*
cond(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
if (node == 0) return 0;
- return cond0(p, node, COND_IN_COND, loc);
+ return cond0(p, node, COND_IN_COND, loc, true);
}
static NODE*
method_cond(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
if (node == 0) return 0;
- return cond0(p, node, COND_IN_OP, loc);
+ return cond0(p, node, COND_IN_OP, loc, true);
}
static NODE*
@@ -12417,43 +14296,47 @@ new_nil_at(struct parser_params *p, const rb_code_position_t *pos)
}
static NODE*
-new_if(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
+new_if(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc, const YYLTYPE* if_keyword_loc, const YYLTYPE* then_keyword_loc, const YYLTYPE* end_keyword_loc)
{
if (!cc) return right;
- cc = cond0(p, cc, COND_IN_COND, loc);
- return newline_node(NEW_IF(cc, left, right, loc));
+ cc = cond0(p, cc, COND_IN_COND, loc, true);
+ return newline_node(NEW_IF(cc, left, right, loc, if_keyword_loc, then_keyword_loc, end_keyword_loc));
}
static NODE*
-new_unless(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
+new_unless(struct parser_params *p, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc, const YYLTYPE *keyword_loc, const YYLTYPE *then_keyword_loc, const YYLTYPE *end_keyword_loc)
{
if (!cc) return right;
- cc = cond0(p, cc, COND_IN_COND, loc);
- return newline_node(NEW_UNLESS(cc, left, right, loc));
+ cc = cond0(p, cc, COND_IN_COND, loc, true);
+ return newline_node(NEW_UNLESS(cc, left, right, loc, keyword_loc, then_keyword_loc, end_keyword_loc));
}
+#define NEW_AND_OR(type, f, s, loc, op_loc) (type == NODE_AND ? NEW_AND(f,s,loc,op_loc) : NEW_OR(f,s,loc,op_loc))
+
static NODE*
logop(struct parser_params *p, ID id, NODE *left, NODE *right,
const YYLTYPE *op_loc, const YYLTYPE *loc)
{
enum node_type type = id == idAND || id == idANDOP ? NODE_AND : NODE_OR;
NODE *op;
- value_expr(left);
+ value_expr(p, left);
if (left && nd_type_p(left, type)) {
NODE *node = left, *second;
- while ((second = node->nd_2nd) != 0 && nd_type_p(second, type)) {
+ while ((second = RNODE_AND(node)->nd_2nd) != 0 && nd_type_p(second, type)) {
node = second;
}
- node->nd_2nd = NEW_NODE(type, second, right, 0, loc);
- nd_set_line(node->nd_2nd, op_loc->beg_pos.lineno);
+ RNODE_AND(node)->nd_2nd = NEW_AND_OR(type, second, right, loc, op_loc);
+ nd_set_line(RNODE_AND(node)->nd_2nd, op_loc->beg_pos.lineno);
left->nd_loc.end_pos = loc->end_pos;
return left;
}
- op = NEW_NODE(type, left, right, 0, loc);
+ op = NEW_AND_OR(type, left, right, loc, op_loc);
nd_set_line(op, op_loc->beg_pos.lineno);
return op;
}
+#undef NEW_AND_OR
+
static void
no_blockarg(struct parser_params *p, NODE *node)
{
@@ -12467,73 +14350,43 @@ ret_args(struct parser_params *p, NODE *node)
{
if (node) {
no_blockarg(p, node);
- if (nd_type_p(node, NODE_LIST)) {
- if (node->nd_next == 0) {
- node = node->nd_head;
- }
- else {
- nd_set_type(node, NODE_VALUES);
- }
+ if (nd_type_p(node, NODE_LIST) && !RNODE_LIST(node)->nd_next) {
+ node = RNODE_LIST(node)->nd_head;
}
}
return node;
}
-static NODE *
-new_yield(struct parser_params *p, NODE *node, const YYLTYPE *loc)
-{
- if (node) no_blockarg(p, node);
-
- return NEW_YIELD(node, loc);
-}
-
-static VALUE
-negate_lit(struct parser_params *p, VALUE lit)
+static NODE*
+negate_lit(struct parser_params *p, NODE* node, const YYLTYPE *loc)
{
- if (FIXNUM_P(lit)) {
- return LONG2FIX(-FIX2LONG(lit));
- }
- if (SPECIAL_CONST_P(lit)) {
-#if USE_FLONUM
- if (FLONUM_P(lit)) {
- return DBL2NUM(-RFLOAT_VALUE(lit));
- }
-#endif
- goto unknown;
- }
- switch (BUILTIN_TYPE(lit)) {
- case T_BIGNUM:
- BIGNUM_NEGATE(lit);
- lit = rb_big_norm(lit);
- break;
- case T_RATIONAL:
- RATIONAL_SET_NUM(lit, negate_lit(p, RRATIONAL(lit)->num));
+ switch (nd_type(node)) {
+ case NODE_INTEGER:
+ RNODE_INTEGER(node)->minus = TRUE;
break;
- case T_COMPLEX:
- RCOMPLEX_SET_REAL(lit, negate_lit(p, RCOMPLEX(lit)->real));
- RCOMPLEX_SET_IMAG(lit, negate_lit(p, RCOMPLEX(lit)->imag));
+ case NODE_FLOAT:
+ RNODE_FLOAT(node)->minus = TRUE;
break;
- case T_FLOAT:
- lit = DBL2NUM(-RFLOAT_VALUE(lit));
+ case NODE_RATIONAL:
+ RNODE_RATIONAL(node)->minus = TRUE;
break;
- unknown:
- default:
- rb_parser_fatal(p, "unknown literal type (%s) passed to negate_lit",
- rb_builtin_class_name(lit));
+ case NODE_IMAGINARY:
+ RNODE_IMAGINARY(node)->minus = TRUE;
break;
}
- return lit;
+ node->nd_loc = *loc;
+ return node;
}
static NODE *
-arg_blk_pass(NODE *node1, NODE *node2)
+arg_blk_pass(NODE *node1, rb_node_block_pass_t *node2)
{
if (node2) {
- if (!node1) return node2;
+ if (!node1) return (NODE *)node2;
node2->nd_head = node1;
nd_set_first_lineno(node2, nd_first_lineno(node1));
nd_set_first_column(node2, nd_first_column(node1));
- return node2;
+ return (NODE *)node2;
}
return node1;
}
@@ -12551,24 +14404,23 @@ args_info_empty_p(struct rb_args_info *args)
return true;
}
-static NODE*
-new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, NODE *post_args, NODE *tail, const YYLTYPE *loc)
+static rb_node_args_t *
+new_args(struct parser_params *p, rb_node_args_aux_t *pre_args, rb_node_opt_arg_t *opt_args, ID rest_arg, rb_node_args_aux_t *post_args, rb_node_args_t *tail, const YYLTYPE *loc)
{
- int saved_line = p->ruby_sourceline;
- struct rb_args_info *args = tail->nd_ainfo;
+ struct rb_args_info *args = &tail->nd_ainfo;
if (args->forwarding) {
if (rest_arg) {
- yyerror1(&tail->nd_loc, "... after rest argument");
+ yyerror1(&RNODE(tail)->nd_loc, "... after rest argument");
return tail;
}
rest_arg = idFWD_REST;
}
- args->pre_args_num = pre_args ? rb_long2int(pre_args->nd_plen) : 0;
+ args->pre_args_num = pre_args ? pre_args->nd_plen : 0;
args->pre_init = pre_args ? pre_args->nd_next : 0;
- args->post_args_num = post_args ? rb_long2int(post_args->nd_plen) : 0;
+ args->post_args_num = post_args ? post_args->nd_plen : 0;
args->post_init = post_args ? post_args->nd_next : 0;
args->first_post_arg = post_args ? post_args->nd_pid : 0;
@@ -12576,31 +14428,22 @@ new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, N
args->opt_args = opt_args;
-#ifdef FORWARD_ARGS_WITH_RUBY2_KEYWORDS
- args->ruby2_keywords = args->forwarding;
-#else
- args->ruby2_keywords = 0;
-#endif
-
- p->ruby_sourceline = saved_line;
- nd_set_loc(tail, loc);
+ nd_set_loc(RNODE(tail), loc);
return tail;
}
-static NODE*
-new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, const YYLTYPE *kw_rest_loc)
+static rb_node_args_t *
+new_args_tail(struct parser_params *p, rb_node_kw_arg_t *kw_args, ID kw_rest_arg, ID block, const YYLTYPE *kw_rest_loc)
{
- int saved_line = p->ruby_sourceline;
- NODE *node;
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- struct rb_args_info *args = ZALLOC(struct rb_args_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, args);
- args->imemo = tmpbuf;
- node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
+ rb_node_args_t *node = NEW_ARGS(&NULL_LOC);
+ struct rb_args_info *args = &node->nd_ainfo;
if (p->error_p) return node;
+ if (block == idNil) {
+ block = 0;
+ args->no_blockarg = TRUE;
+ }
args->block_arg = block;
args->kw_args = kw_args;
@@ -12613,21 +14456,21 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
*/
ID kw_bits = internal_id(p), *required_kw_vars, *kw_vars;
struct vtable *vtargs = p->lvtbl->args;
- NODE *kwn = kw_args;
+ rb_node_kw_arg_t *kwn = kw_args;
if (block) block = vtargs->tbl[vtargs->pos-1];
vtable_pop(vtargs, !!block + !!kw_rest_arg);
required_kw_vars = kw_vars = &vtargs->tbl[vtargs->pos];
while (kwn) {
- if (!NODE_REQUIRED_KEYWORD_P(kwn->nd_body))
+ if (!NODE_REQUIRED_KEYWORD_P(get_nd_value(p, kwn->nd_body)))
--kw_vars;
--required_kw_vars;
kwn = kwn->nd_next;
}
for (kwn = kw_args; kwn; kwn = kwn->nd_next) {
- ID vid = kwn->nd_body->nd_vid;
- if (NODE_REQUIRED_KEYWORD_P(kwn->nd_body)) {
+ ID vid = get_nd_vid(p, kwn->nd_body);
+ if (NODE_REQUIRED_KEYWORD_P(get_nd_value(p, kwn->nd_body))) {
*required_kw_vars++ = vid;
}
else {
@@ -12640,7 +14483,6 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
if (block) arg_var(p, block);
args->kw_rest_arg = NEW_DVAR(kw_rest_arg, kw_rest_loc);
- args->kw_rest_arg->nd_cflag = kw_bits;
}
else if (kw_rest_arg == idNil) {
args->no_kwarg = 1;
@@ -12649,20 +14491,19 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
args->kw_rest_arg = NEW_DVAR(kw_rest_arg, kw_rest_loc);
}
- p->ruby_sourceline = saved_line;
return node;
}
-static NODE *
-args_with_numbered(struct parser_params *p, NODE *args, int max_numparam)
+static rb_node_args_t *
+args_with_numbered(struct parser_params *p, rb_node_args_t *args, int max_numparam, ID it_id)
{
- if (max_numparam > NO_PARAM) {
+ if (max_numparam > NO_PARAM || it_id) {
if (!args) {
YYLTYPE loc = RUBY_INIT_YYLLOC();
- args = new_args_tail(p, 0, 0, 0, 0);
- nd_set_loc(args, &loc);
+ args = new_empty_args_tail(p, 0);
+ nd_set_loc(RNODE(args), &loc);
}
- args->nd_ainfo->pre_args_num = max_numparam;
+ args->nd_ainfo.pre_args_num = it_id ? 1 : max_numparam;
}
return args;
}
@@ -12670,91 +14511,62 @@ args_with_numbered(struct parser_params *p, NODE *args, int max_numparam)
static NODE*
new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE *aryptn, const YYLTYPE *loc)
{
- struct rb_ary_pattern_info *apinfo = aryptn->nd_apinfo;
-
- aryptn->nd_pconst = constant;
+ RNODE_ARYPTN(aryptn)->nd_pconst = constant;
if (pre_arg) {
NODE *pre_args = NEW_LIST(pre_arg, loc);
- if (apinfo->pre_args) {
- apinfo->pre_args = list_concat(pre_args, apinfo->pre_args);
+ if (RNODE_ARYPTN(aryptn)->pre_args) {
+ RNODE_ARYPTN(aryptn)->pre_args = list_concat(pre_args, RNODE_ARYPTN(aryptn)->pre_args);
}
else {
- apinfo->pre_args = pre_args;
+ RNODE_ARYPTN(aryptn)->pre_args = pre_args;
}
}
return aryptn;
}
static NODE*
-new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID rest_arg, NODE *post_args, const YYLTYPE *loc)
+new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc)
{
- int saved_line = p->ruby_sourceline;
- NODE *node;
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- struct rb_ary_pattern_info *apinfo = ZALLOC(struct rb_ary_pattern_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, apinfo);
- node = NEW_NODE(NODE_ARYPTN, 0, tmpbuf, apinfo, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
-
- apinfo->pre_args = pre_args;
-
if (has_rest) {
- if (rest_arg) {
- apinfo->rest_arg = assignable(p, rest_arg, 0, loc);
- }
- else {
- apinfo->rest_arg = NODE_SPECIAL_NO_NAME_REST;
- }
+ rest_arg = rest_arg ? rest_arg : NODE_SPECIAL_NO_NAME_REST;
}
else {
- apinfo->rest_arg = NULL;
+ rest_arg = NULL;
}
+ NODE *node = NEW_ARYPTN(pre_args, rest_arg, post_args, loc);
- apinfo->post_args = post_args;
-
- p->ruby_sourceline = saved_line;
return node;
}
static NODE*
new_find_pattern(struct parser_params *p, NODE *constant, NODE *fndptn, const YYLTYPE *loc)
{
- fndptn->nd_pconst = constant;
+ RNODE_FNDPTN(fndptn)->nd_pconst = constant;
return fndptn;
}
static NODE*
-new_find_pattern_tail(struct parser_params *p, ID pre_rest_arg, NODE *args, ID post_rest_arg, const YYLTYPE *loc)
+new_find_pattern_tail(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc)
{
- int saved_line = p->ruby_sourceline;
- NODE *node;
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- struct rb_fnd_pattern_info *fpinfo = ZALLOC(struct rb_fnd_pattern_info);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, fpinfo);
- node = NEW_NODE(NODE_FNDPTN, 0, tmpbuf, fpinfo, loc);
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
+ pre_rest_arg = pre_rest_arg ? pre_rest_arg : NODE_SPECIAL_NO_NAME_REST;
+ post_rest_arg = post_rest_arg ? post_rest_arg : NODE_SPECIAL_NO_NAME_REST;
+ NODE *node = NEW_FNDPTN(pre_rest_arg, args, post_rest_arg, loc);
- fpinfo->pre_rest_arg = pre_rest_arg ? assignable(p, pre_rest_arg, 0, loc) : NODE_SPECIAL_NO_NAME_REST;
- fpinfo->args = args;
- fpinfo->post_rest_arg = post_rest_arg ? assignable(p, post_rest_arg, 0, loc) : NODE_SPECIAL_NO_NAME_REST;
-
- p->ruby_sourceline = saved_line;
return node;
}
static NODE*
new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YYLTYPE *loc)
{
- hshptn->nd_pconst = constant;
+ RNODE_HSHPTN(hshptn)->nd_pconst = constant;
return hshptn;
}
static NODE*
new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc)
{
- int saved_line = p->ruby_sourceline;
NODE *node, *kw_rest_arg_node;
if (kw_rest_arg == idNil) {
@@ -12767,19 +14579,16 @@ new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, co
kw_rest_arg_node = NULL;
}
- node = NEW_NODE(NODE_HSHPTN, 0, kw_args, kw_rest_arg_node, loc);
+ node = NEW_HSHPTN(0, kw_args, kw_rest_arg_node, loc);
- p->ruby_sourceline = saved_line;
return node;
}
static NODE*
dsym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
{
- VALUE lit;
-
if (!node) {
- return NEW_LIT(ID2SYM(idNULL), loc);
+ return NEW_SYM(STR_NEW0(), loc);
}
switch (nd_type(node)) {
@@ -12788,123 +14597,119 @@ dsym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
nd_set_loc(node, loc);
break;
case NODE_STR:
- lit = node->nd_lit;
- RB_OBJ_WRITTEN(p->ast, Qnil, node->nd_lit = ID2SYM(rb_intern_str(lit)));
- nd_set_type(node, NODE_LIT);
- nd_set_loc(node, loc);
+ node = str_to_sym_node(p, node, loc);
break;
default:
- node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, loc), loc);
+ node = NEW_DSYM(0, 1, NEW_LIST(node, loc), loc);
break;
}
return node;
}
static int
-append_literal_keys(st_data_t k, st_data_t v, st_data_t h)
-{
- NODE *node = (NODE *)v;
- NODE **result = (NODE **)h;
- node->nd_alen = 2;
- node->nd_next->nd_end = node->nd_next;
- node->nd_next->nd_next = 0;
- if (*result)
- list_concat(*result, node);
- else
- *result = node;
- return ST_CONTINUE;
-}
-
-static bool
-hash_literal_key_p(VALUE k)
+nd_type_st_key_enable_p(NODE *node)
{
- switch (OBJ_BUILTIN_TYPE(k)) {
- case T_NODE:
- return false;
- default:
+ switch (nd_type(node)) {
+ case NODE_INTEGER:
+ case NODE_FLOAT:
+ case NODE_RATIONAL:
+ case NODE_IMAGINARY:
+ case NODE_STR:
+ case NODE_SYM:
+ case NODE_REGX:
+ case NODE_LINE:
+ case NODE_FILE:
+ case NODE_ENCODING:
return true;
+ default:
+ return false;
}
}
-static int
-literal_cmp(VALUE val, VALUE lit)
+static VALUE
+nd_value(struct parser_params *p, NODE *node)
{
- if (val == lit) return 0;
- if (!hash_literal_key_p(val) || !hash_literal_key_p(lit)) return -1;
- return rb_iseq_cdhash_cmp(val, lit);
+ switch (nd_type(node)) {
+ case NODE_STR:
+ return rb_node_str_string_val(node);
+ case NODE_INTEGER:
+ return rb_node_integer_literal_val(node);
+ case NODE_FLOAT:
+ return rb_node_float_literal_val(node);
+ case NODE_RATIONAL:
+ return rb_node_rational_literal_val(node);
+ case NODE_IMAGINARY:
+ return rb_node_imaginary_literal_val(node);
+ case NODE_SYM:
+ return rb_node_sym_string_val(node);
+ case NODE_REGX:
+ return rb_node_regx_string_val(node);
+ case NODE_LINE:
+ return rb_node_line_lineno_val(node);
+ case NODE_ENCODING:
+ return rb_node_encoding_val(node);
+ case NODE_FILE:
+ return rb_node_file_path_val(node);
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ UNREACHABLE_RETURN(0);
+ }
}
-static st_index_t
-literal_hash(VALUE a)
-{
- if (!hash_literal_key_p(a)) return (st_index_t)a;
- return rb_iseq_cdhash_hash(a);
-}
+static void
+warn_duplicate_keys(struct parser_params *p, NODE *hash)
+{
+ /* See https://bugs.ruby-lang.org/issues/20331 for discussion about what is warned. */
+ p->warn_duplicate_keys_table = st_init_table_with_size(&literal_type, RNODE_LIST(hash)->as.nd_alen / 2);
+ while (hash && RNODE_LIST(hash)->nd_next) {
+ NODE *head = RNODE_LIST(hash)->nd_head;
+ NODE *value = RNODE_LIST(hash)->nd_next;
+ NODE *next = RNODE_LIST(value)->nd_next;
+ st_data_t key;
+ st_data_t data;
-static const struct st_hash_type literal_type = {
- literal_cmp,
- literal_hash,
-};
+ /* keyword splat, e.g. {k: 1, **z, k: 2} */
+ if (!head) {
+ head = value;
+ }
-static NODE *
-remove_duplicate_keys(struct parser_params *p, NODE *hash)
-{
- st_table *literal_keys = st_init_table_with_size(&literal_type, hash->nd_alen / 2);
- NODE *result = 0;
- NODE *last_expr = 0;
- rb_code_location_t loc = hash->nd_loc;
- while (hash && hash->nd_head && hash->nd_next) {
- NODE *head = hash->nd_head;
- NODE *value = hash->nd_next;
- NODE *next = value->nd_next;
- st_data_t key = (st_data_t)head;
- st_data_t data;
- value->nd_next = 0;
- if (nd_type_p(head, NODE_LIT) &&
- st_delete(literal_keys, (key = (st_data_t)head->nd_lit, &key), &data)) {
- NODE *dup_value = ((NODE *)data)->nd_next;
- rb_compile_warn(p->ruby_sourcefile, nd_line((NODE *)data),
- "key %+"PRIsVALUE" is duplicated and overwritten on line %d",
- head->nd_lit, nd_line(head));
- if (dup_value == last_expr) {
- value->nd_head = block_append(p, dup_value->nd_head, value->nd_head);
- }
- else {
- last_expr->nd_head = block_append(p, dup_value->nd_head, last_expr->nd_head);
+ if (nd_type_st_key_enable_p(head)) {
+ key = (st_data_t)head;
+
+ if (st_delete(p->warn_duplicate_keys_table, &key, &data)) {
+ rb_warn2L(nd_line((NODE *)data),
+ "key %+"PRIsWARN" is duplicated and overwritten on line %d",
+ nd_value(p, head), WARN_I(nd_line(head)));
}
+ st_insert(p->warn_duplicate_keys_table, (st_data_t)key, (st_data_t)hash);
}
- st_insert(literal_keys, (st_data_t)key, (st_data_t)hash);
- last_expr = nd_type_p(head, NODE_LIT) ? value : head;
hash = next;
}
- st_foreach(literal_keys, append_literal_keys, (st_data_t)&result);
- st_free_table(literal_keys);
- if (hash) {
- if (!result) result = hash;
- else list_concat(result, hash);
- }
- result->nd_loc = loc;
- return result;
+ st_free_table(p->warn_duplicate_keys_table);
+ p->warn_duplicate_keys_table = NULL;
}
static NODE *
new_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc)
{
- if (hash) hash = remove_duplicate_keys(p, hash);
+ if (hash) warn_duplicate_keys(p, hash);
return NEW_HASH(hash, loc);
}
-#endif
static void
error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *loc)
{
- if (is_private_local_id(id)) {
+ if (is_private_local_id(p, id)) {
return;
}
if (st_is_member(p->pvtbl, id)) {
yyerror1(loc, "duplicated variable name");
}
+ else if (p->ctxt.in_alt_pattern && id) {
+ yyerror1(loc, "variable capture in alternative pattern");
+ }
else {
+ p->ctxt.capture_in_pattern = 1;
st_insert(p->pvtbl, (st_data_t)id, 0);
}
}
@@ -12922,98 +14727,65 @@ error_duplicate_pattern_key(struct parser_params *p, VALUE key, const YYLTYPE *l
st_insert(p->pktbl, (st_data_t)key, 0);
}
-#ifndef RIPPER
static NODE *
new_unique_key_hash(struct parser_params *p, NODE *hash, const YYLTYPE *loc)
{
return NEW_HASH(hash, loc);
}
-#endif /* !RIPPER */
-#ifndef RIPPER
static NODE *
new_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, struct lex_context ctxt, const YYLTYPE *loc)
{
NODE *asgn;
if (lhs) {
- ID vid = lhs->nd_vid;
+ ID vid = get_nd_vid(p, lhs);
YYLTYPE lhs_loc = lhs->nd_loc;
- int shareable = ctxt.shareable_constant_value;
- if (shareable) {
- switch (nd_type(lhs)) {
- case NODE_CDECL:
- case NODE_COLON2:
- case NODE_COLON3:
- break;
- default:
- shareable = 0;
- break;
- }
- }
if (op == tOROP) {
- rhs = shareable_constant_value(p, shareable, lhs, rhs, &rhs->nd_loc);
- lhs->nd_value = rhs;
+ set_nd_value(p, lhs, rhs);
nd_set_loc(lhs, loc);
asgn = NEW_OP_ASGN_OR(gettable(p, vid, &lhs_loc), lhs, loc);
- if (is_notop_id(vid)) {
- switch (id_type(vid)) {
- case ID_GLOBAL:
- case ID_INSTANCE:
- case ID_CLASS:
- asgn->nd_aid = vid;
- }
- }
}
else if (op == tANDOP) {
- if (shareable) {
- rhs = shareable_constant_value(p, shareable, lhs, rhs, &rhs->nd_loc);
- }
- lhs->nd_value = rhs;
+ set_nd_value(p, lhs, rhs);
nd_set_loc(lhs, loc);
asgn = NEW_OP_ASGN_AND(gettable(p, vid, &lhs_loc), lhs, loc);
}
else {
asgn = lhs;
rhs = NEW_CALL(gettable(p, vid, &lhs_loc), op, NEW_LIST(rhs, &rhs->nd_loc), loc);
- if (shareable) {
- rhs = shareable_constant_value(p, shareable, lhs, rhs, &rhs->nd_loc);
- }
- asgn->nd_value = rhs;
+ set_nd_value(p, asgn, rhs);
nd_set_loc(asgn, loc);
}
}
else {
- asgn = NEW_BEGIN(0, loc);
+ asgn = NEW_ERROR(loc);
}
return asgn;
}
static NODE *
new_ary_op_assign(struct parser_params *p, NODE *ary,
- NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc)
+ NODE *args, ID op, NODE *rhs, const YYLTYPE *args_loc, const YYLTYPE *loc,
+ const YYLTYPE *call_operator_loc, const YYLTYPE *opening_loc, const YYLTYPE *closing_loc, const YYLTYPE *binary_operator_loc)
{
NODE *asgn;
+ aryset_check(p, args);
args = make_list(args, args_loc);
- if (nd_type_p(args, NODE_BLOCK_PASS)) {
- args = NEW_ARGSCAT(args, rhs, loc);
- }
- else {
- args = arg_concat(p, args, rhs, loc);
- }
- asgn = NEW_OP_ASGN1(ary, op, args, loc);
+ asgn = NEW_OP_ASGN1(ary, op, args, rhs, loc, call_operator_loc, opening_loc, closing_loc, binary_operator_loc);
fixpos(asgn, ary);
return asgn;
}
static NODE *
new_attr_op_assign(struct parser_params *p, NODE *lhs,
- ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc)
+ ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc,
+ const YYLTYPE *call_operator_loc, const YYLTYPE *message_loc, const YYLTYPE *binary_operator_loc)
{
NODE *asgn;
- asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, loc);
+ asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, loc, call_operator_loc, message_loc, binary_operator_loc);
fixpos(asgn, lhs);
return asgn;
}
@@ -13024,11 +14796,10 @@ new_const_op_assign(struct parser_params *p, NODE *lhs, ID op, NODE *rhs, struct
NODE *asgn;
if (lhs) {
- rhs = shareable_constant_value(p, ctxt.shareable_constant_value, lhs, rhs, loc);
- asgn = NEW_OP_CDECL(lhs, op, rhs, loc);
+ asgn = NEW_OP_CDECL(lhs, op, rhs, ctxt.shareable_constant_value, loc);
}
else {
- asgn = NEW_BEGIN(0, loc);
+ asgn = NEW_ERROR(loc);
}
fixpos(asgn, lhs);
return asgn;
@@ -13038,20 +14809,16 @@ static NODE *
const_decl(struct parser_params *p, NODE *path, const YYLTYPE *loc)
{
if (p->ctxt.in_def) {
+#ifndef RIPPER
yyerror1(loc, "dynamic constant assignment");
- }
- return NEW_CDECL(0, 0, (path), loc);
-}
#else
-static VALUE
-const_decl(struct parser_params *p, VALUE path)
-{
- if (p->ctxt.in_def) {
- path = assign_error(p, "dynamic constant assignment", path);
+ set_value(assign_error(p, "dynamic constant assignment", p->s_lvalue));
+#endif
}
- return path;
+ return NEW_CDECL(0, 0, (path), p->ctxt.shareable_constant_value, loc);
}
+#ifdef RIPPER
static VALUE
assign_error(struct parser_params *p, const char *mesg, VALUE a)
{
@@ -13059,15 +14826,8 @@ assign_error(struct parser_params *p, const char *mesg, VALUE a)
ripper_error(p);
return a;
}
-
-static VALUE
-var_field(struct parser_params *p, VALUE a)
-{
- return ripper_new_yylval(p, get_id(a), dispatch1(var_field, a), 0);
-}
#endif
-#ifndef RIPPER
static NODE *
new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_else, NODE *ensure, const YYLTYPE *loc)
{
@@ -13079,16 +14839,12 @@ new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_els
result = NEW_RESCUE(head, rescue, rescue_else, &rescue_loc);
nd_set_line(result, rescue->nd_loc.beg_pos.lineno);
}
- else if (rescue_else) {
- result = block_append(p, result, rescue_else);
- }
if (ensure) {
result = NEW_ENSURE(result, ensure, loc);
}
fixpos(result, head);
return result;
}
-#endif
static void
warn_unused_var(struct parser_params *p, struct local_vars *local)
@@ -13105,7 +14861,7 @@ warn_unused_var(struct parser_params *p, struct local_vars *local)
ID *u = local->used->tbl;
for (int i = 0; i < cnt; ++i) {
if (!v[i] || (u[i] & LVAR_USED)) continue;
- if (is_private_local_id(v[i])) continue;
+ if (is_private_local_id(p, v[i])) continue;
rb_warn1L((int)u[i], "assigned but unused variable - %"PRIsWARN, rb_id2str(v[i]));
}
#endif
@@ -13125,10 +14881,11 @@ local_push(struct parser_params *p, int toplevel_scope)
#ifndef RIPPER
if (toplevel_scope && compile_for_eval) warn_unused_vars = 0;
if (toplevel_scope && e_option_supplied(p)) warn_unused_vars = 0;
+#endif
local->numparam.outer = 0;
local->numparam.inner = 0;
local->numparam.current = 0;
-#endif
+ local->it = 0;
local->used = warn_unused_vars ? vtable_alloc(0) : 0;
# if WARN_PAST_SCOPE
@@ -13140,29 +14897,45 @@ local_push(struct parser_params *p, int toplevel_scope)
}
static void
+vtable_chain_free(struct parser_params *p, struct vtable *table)
+{
+ while (!DVARS_TERMINAL_P(table)) {
+ struct vtable *cur_table = table;
+ table = cur_table->prev;
+ vtable_free(cur_table);
+ }
+}
+
+static void
+local_free(struct parser_params *p, struct local_vars *local)
+{
+ vtable_chain_free(p, local->used);
+
+# if WARN_PAST_SCOPE
+ vtable_chain_free(p, local->past);
+# endif
+
+ vtable_chain_free(p, local->args);
+ vtable_chain_free(p, local->vars);
+
+ ruby_xfree_sized(local, sizeof(struct local_vars));
+}
+
+static void
local_pop(struct parser_params *p)
{
struct local_vars *local = p->lvtbl->prev;
if (p->lvtbl->used) {
warn_unused_var(p, p->lvtbl);
- vtable_free(p->lvtbl->used);
- }
-# if WARN_PAST_SCOPE
- while (p->lvtbl->past) {
- struct vtable *past = p->lvtbl->past;
- p->lvtbl->past = past->prev;
- vtable_free(past);
}
-# endif
- vtable_free(p->lvtbl->args);
- vtable_free(p->lvtbl->vars);
+
+ local_free(p, p->lvtbl);
+ p->lvtbl = local;
+
CMDARG_POP();
COND_POP();
- ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
- p->lvtbl = local;
}
-#ifndef RIPPER
static rb_ast_id_table_t *
local_tbl(struct parser_params *p)
{
@@ -13189,19 +14962,6 @@ local_tbl(struct parser_params *p)
return tbl;
}
-static NODE*
-node_newnode_with_locals(struct parser_params *p, enum node_type type, VALUE a1, VALUE a2, const rb_code_location_t *loc)
-{
- rb_ast_id_table_t *a0;
- NODE *n;
-
- a0 = local_tbl(p);
- n = NEW_NODE(type, a0, a1, a2, loc);
- return n;
-}
-
-#endif
-
static void
numparam_name(struct parser_params *p, ID id)
{
@@ -13227,6 +14987,14 @@ local_var(struct parser_params *p, ID id)
}
}
+#ifndef RIPPER
+int
+rb_parser_local_defined(struct parser_params *p, ID id, const struct rb_iseq_struct *iseq)
+{
+ return rb_local_defined(id, iseq);
+}
+#endif
+
static int
local_id_ref(struct parser_params *p, ID id, ID **vidrefp)
{
@@ -13243,7 +15011,7 @@ local_id_ref(struct parser_params *p, ID id, ID **vidrefp)
}
if (vars && vars->prev == DVARS_INHERIT) {
- return rb_local_defined(id, p->parent_iseq);
+ return rb_parser_local_defined(p, id, p->parent_iseq);
}
else if (vtable_included(args, id)) {
return 1;
@@ -13273,34 +15041,60 @@ static void
add_forwarding_args(struct parser_params *p)
{
arg_var(p, idFWD_REST);
-#ifndef FORWARD_ARGS_WITH_RUBY2_KEYWORDS
arg_var(p, idFWD_KWREST);
-#endif
arg_var(p, idFWD_BLOCK);
arg_var(p, idFWD_ALL);
}
-#ifndef RIPPER
+static void
+forwarding_arg_check(struct parser_params *p, ID arg, ID all, const char *var)
+{
+ bool conflict = false;
+
+ struct vtable *vars, *args;
+
+ vars = p->lvtbl->vars;
+ args = p->lvtbl->args;
+
+ while (vars && !DVARS_TERMINAL_P(vars->prev)) {
+ conflict |= (vtable_included(args, arg) && !(all && vtable_included(args, all)));
+ vars = vars->prev;
+ args = args->prev;
+ }
+
+ bool found = false;
+ if (vars && vars->prev == DVARS_INHERIT && !found) {
+ found = (rb_parser_local_defined(p, arg, p->parent_iseq) &&
+ !(all && rb_parser_local_defined(p, all, p->parent_iseq)));
+ }
+ else {
+ found = (vtable_included(args, arg) &&
+ !(all && vtable_included(args, all)));
+ }
+
+ if (!found) {
+ compile_error(p, "no anonymous %s parameter", var);
+ }
+ else if (conflict) {
+ compile_error(p, "anonymous %s parameter is also used within block", var);
+ }
+}
+
static NODE *
new_args_forward_call(struct parser_params *p, NODE *leading, const YYLTYPE *loc, const YYLTYPE *argsloc)
{
NODE *rest = NEW_LVAR(idFWD_REST, loc);
-#ifndef FORWARD_ARGS_WITH_RUBY2_KEYWORDS
NODE *kwrest = list_append(p, NEW_LIST(0, loc), NEW_LVAR(idFWD_KWREST, loc));
-#endif
- NODE *block = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, loc), loc);
- NODE *args = leading ? rest_arg_append(p, leading, rest, argsloc) : NEW_SPLAT(rest, loc);
-#ifndef FORWARD_ARGS_WITH_RUBY2_KEYWORDS
- args = arg_append(p, args, new_hash(p, kwrest, loc), loc);
-#endif
+ rb_node_block_pass_t *block = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, loc), argsloc, &NULL_LOC);
+ NODE *args = leading ? rest_arg_append(p, leading, rest, argsloc) : NEW_SPLAT(rest, loc, &NULL_LOC);
+ block->forwarding = TRUE;
+ args = arg_append(p, args, new_hash(p, kwrest, loc), argsloc);
return arg_blk_pass(args, block);
}
-#endif
static NODE *
numparam_push(struct parser_params *p)
{
-#ifndef RIPPER
struct local_vars *local = p->lvtbl;
NODE *inner = local->numparam.inner;
if (!local->numparam.outer) {
@@ -13308,16 +15102,13 @@ numparam_push(struct parser_params *p)
}
local->numparam.inner = 0;
local->numparam.current = 0;
+ local->it = 0;
return inner;
-#else
- return 0;
-#endif
}
static void
numparam_pop(struct parser_params *p, NODE *prev_inner)
{
-#ifndef RIPPER
struct local_vars *local = p->lvtbl;
if (prev_inner) {
/* prefer first one */
@@ -13336,7 +15127,7 @@ numparam_pop(struct parser_params *p, NODE *prev_inner)
/* no numbered parameter */
local->numparam.current = 0;
}
-#endif
+ local->it = 0;
}
static const struct vtable *
@@ -13386,7 +15177,7 @@ dyna_pop(struct parser_params *p, const struct vtable *lvargs)
dyna_pop_1(p);
if (!p->lvtbl->args) {
struct local_vars *local = p->lvtbl->prev;
- ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
+ ruby_xfree_sized(p->lvtbl, sizeof(*p->lvtbl));
p->lvtbl = local;
}
}
@@ -13399,7 +15190,8 @@ dyna_in_block(struct parser_params *p)
return !DVARS_TERMINAL_P(p->lvtbl->vars) && p->lvtbl->vars->prev != DVARS_TOPSCOPE;
}
-static int
+#ifndef RIPPER
+int
dvar_defined_ref(struct parser_params *p, ID id, ID **vidrefp)
{
struct vtable *vars, *args, *used;
@@ -13429,6 +15221,7 @@ dvar_defined_ref(struct parser_params *p, ID id, ID **vidrefp)
return 0;
}
+#endif
static int
dvar_defined(struct parser_params *p, ID id)
@@ -13444,77 +15237,100 @@ dvar_curr(struct parser_params *p, ID id)
}
static void
-reg_fragment_enc_error(struct parser_params* p, VALUE str, int c)
+reg_fragment_enc_error(struct parser_params* p, rb_parser_string_t *str, int c)
{
compile_error(p,
"regexp encoding option '%c' differs from source encoding '%s'",
- c, rb_enc_name(rb_enc_get(str)));
+ c, rb_enc_name(rb_parser_str_get_encoding(str)));
}
#ifndef RIPPER
+static rb_encoding *
+find_enc(struct parser_params* p, const char *name)
+{
+ int idx = rb_enc_find_index(name);
+ if (idx < 0) {
+ rb_bug("unknown encoding name: %s", name);
+ }
+
+ return rb_enc_from_index(idx);
+}
+
+static rb_encoding *
+kcode_to_enc(struct parser_params* p, int kcode)
+{
+ rb_encoding *enc;
+
+ switch (kcode) {
+ case ENC_ASCII8BIT:
+ enc = rb_ascii8bit_encoding();
+ break;
+ case ENC_EUC_JP:
+ enc = find_enc(p, "EUC-JP");
+ break;
+ case ENC_Windows_31J:
+ enc = find_enc(p, "Windows-31J");
+ break;
+ case ENC_UTF8:
+ enc = rb_utf8_encoding();
+ break;
+ default:
+ enc = NULL;
+ break;
+ }
+
+ return enc;
+}
+
int
-rb_reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
+rb_reg_fragment_setenc(struct parser_params* p, rb_parser_string_t *str, int options)
{
int c = RE_OPTION_ENCODING_IDX(options);
if (c) {
int opt, idx;
- rb_char_to_option_kcode(c, &opt, &idx);
- if (idx != ENCODING_GET(str) &&
- !is_ascii_string(str)) {
+ rb_encoding *enc;
+
+ char_to_option_kcode(c, &opt, &idx);
+ enc = kcode_to_enc(p, idx);
+ if (enc != rb_parser_str_get_encoding(str) &&
+ !rb_parser_is_ascii_string(p, str)) {
goto error;
}
- ENCODING_SET(str, idx);
+ rb_parser_string_set_encoding(str, enc);
}
else if (RE_OPTION_ENCODING_NONE(options)) {
- if (!ENCODING_IS_ASCII8BIT(str) &&
- !is_ascii_string(str)) {
+ if (!PARSER_ENCODING_IS_ASCII8BIT(p, str) &&
+ !rb_parser_is_ascii_string(p, str)) {
c = 'n';
goto error;
}
- rb_enc_associate(str, rb_ascii8bit_encoding());
+ rb_parser_enc_associate(p, str, rb_ascii8bit_encoding());
}
else if (rb_is_usascii_enc(p->enc)) {
- if (!is_ascii_string(str)) {
- /* raise in re.c */
- rb_enc_associate(str, rb_usascii_encoding());
- }
- else {
- rb_enc_associate(str, rb_ascii8bit_encoding());
- }
+ rb_parser_enc_associate(p, str, rb_ascii8bit_encoding());
}
return 0;
error:
return c;
}
+#endif
static void
-reg_fragment_setenc(struct parser_params* p, VALUE str, int options)
+reg_fragment_setenc(struct parser_params* p, rb_parser_string_t *str, int options)
{
int c = rb_reg_fragment_setenc(p, str, options);
if (c) reg_fragment_enc_error(p, str, c);
}
-static int
-reg_fragment_check(struct parser_params* p, VALUE str, int options)
-{
- VALUE err;
- reg_fragment_setenc(p, str, options);
- err = rb_reg_check_preprocess(str);
- if (err != Qnil) {
- err = rb_obj_as_string(err);
- compile_error(p, "%"PRIsVALUE, err);
- return 0;
- }
- return 1;
-}
-
+#ifndef UNIVERSAL_PARSER
typedef struct {
struct parser_params* parser;
rb_encoding *enc;
NODE *succ_block;
const YYLTYPE *loc;
+ rb_parser_assignable_func assignable;
} reg_named_capture_assign_t;
static int
@@ -13526,27 +15342,12 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
rb_encoding *enc = arg->enc;
long len = name_end - name;
const char *s = (const char *)name;
- ID var;
- NODE *node, *succ;
-
- if (!len) return ST_CONTINUE;
- if (rb_enc_symname_type(s, len, enc, (1U<<ID_LOCAL)) != ID_LOCAL)
- return ST_CONTINUE;
- var = intern_cstr(s, len, enc);
- if (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len)) {
- if (!lvar_defined(p, var)) return ST_CONTINUE;
- }
- node = node_assign(p, assignable(p, var, 0, arg->loc), NEW_LIT(ID2SYM(var), arg->loc), NO_LEX_CTXT, arg->loc);
- succ = arg->succ_block;
- if (!succ) succ = NEW_BEGIN(0, arg->loc);
- succ = block_append(p, succ, node);
- arg->succ_block = succ;
- return ST_CONTINUE;
+ return rb_reg_named_capture_assign_iter_impl(p, s, len, enc, &arg->succ_block, arg->loc, arg->assignable);
}
static NODE *
-reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc)
+reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *loc, rb_parser_assignable_func assignable)
{
reg_named_capture_assign_t arg;
@@ -13554,27 +15355,64 @@ reg_named_capture_assign(struct parser_params* p, VALUE regexp, const YYLTYPE *l
arg.enc = rb_enc_get(regexp);
arg.succ_block = 0;
arg.loc = loc;
+ arg.assignable = assignable;
onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
if (!arg.succ_block) return 0;
- return arg.succ_block->nd_next;
+ return RNODE_BLOCK(arg.succ_block)->nd_next;
}
+#endif
+
+#ifndef RIPPER
+NODE *
+rb_parser_assignable(struct parser_params *p, ID id, NODE *val, const YYLTYPE *loc)
+{
+ return assignable(p, id, val, loc);
+}
+
+int
+rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len,
+ rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc, rb_parser_assignable_func assignable)
+{
+ ID var;
+ NODE *node, *succ;
+
+ if (!len) return ST_CONTINUE;
+ if (!VALID_SYMNAME_P(s, len, enc, ID_LOCAL))
+ return ST_CONTINUE;
+
+ var = intern_cstr(s, len, enc);
+ if (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len)) {
+ if (!lvar_defined(p, var)) return ST_CONTINUE;
+ }
+ node = node_assign(p, assignable(p, var, 0, loc), NEW_SYM(rb_id2str(var), loc), NO_LEX_CTXT, loc);
+ succ = *succ_block;
+ if (!succ) succ = NEW_ERROR(loc);
+ succ = block_append(p, succ, node);
+ *succ_block = succ;
+ return ST_CONTINUE;
+}
+#endif
static VALUE
-parser_reg_compile(struct parser_params* p, VALUE str, int options)
+parser_reg_compile(struct parser_params* p, rb_parser_string_t *str, int options)
{
+ VALUE str2;
reg_fragment_setenc(p, str, options);
- return rb_parser_reg_compile(p, str, options);
+ str2 = rb_str_new_parser_string(str);
+ return rb_parser_reg_compile(p, str2, options);
}
+#ifndef RIPPER
VALUE
rb_parser_reg_compile(struct parser_params* p, VALUE str, int options)
{
return rb_reg_compile(str, options & RE_OPTION_MASK, p->ruby_sourcefile, p->ruby_sourceline);
}
+#endif
static VALUE
-reg_compile(struct parser_params* p, VALUE str, int options)
+reg_compile(struct parser_params* p, rb_parser_string_t *str, int options)
{
VALUE re;
VALUE err;
@@ -13589,30 +15427,11 @@ reg_compile(struct parser_params* p, VALUE str, int options)
}
return re;
}
-#else
-static VALUE
-parser_reg_compile(struct parser_params* p, VALUE str, int options, VALUE *errmsg)
-{
- VALUE err = rb_errinfo();
- VALUE re;
- str = ripper_is_node_yylval(str) ? RNODE(str)->nd_cval : str;
- int c = rb_reg_fragment_setenc(p, str, options);
- if (c) reg_fragment_enc_error(p, str, c);
- re = rb_parser_reg_compile(p, str, options);
- if (NIL_P(re)) {
- *errmsg = rb_attr_get(rb_errinfo(), idMesg);
- rb_set_errinfo(err);
- }
- return re;
-}
-#endif
#ifndef RIPPER
void
-rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split)
+rb_ruby_parser_set_options(struct parser_params *p, int print, int loop, int chomp, int split)
{
- struct parser_params *p;
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
p->do_print = print;
p->do_loop = loop;
p->do_chomp = chomp;
@@ -13626,7 +15445,7 @@ parser_append_options(struct parser_params *p, NODE *node)
const YYLTYPE *const LOC = &default_location;
if (p->do_print) {
- NODE *print = NEW_FCALL(rb_intern("print"),
+ NODE *print = (NODE *)NEW_FCALL(rb_intern("print"),
NEW_LIST(NEW_GVAR(idLASTLINE, LOC), LOC),
LOC);
node = block_append(p, node, print);
@@ -13646,12 +15465,12 @@ parser_append_options(struct parser_params *p, NODE *node)
node = block_append(p, split, node);
}
if (p->do_chomp) {
- NODE *chomp = NEW_LIT(ID2SYM(rb_intern("chomp")), LOC);
+ NODE *chomp = NEW_SYM(rb_str_new_cstr("chomp"), LOC);
chomp = list_append(p, NEW_LIST(chomp, LOC), NEW_TRUE(LOC));
irs = list_append(p, irs, NEW_HASH(chomp, LOC));
}
- node = NEW_WHILE(NEW_FCALL(idGets, irs, LOC), node, 1, LOC);
+ node = NEW_WHILE((NODE *)NEW_FCALL(idGets, irs, LOC), node, 1, LOC, &NULL_LOC, &NULL_LOC);
}
return node;
@@ -13665,7 +15484,7 @@ rb_init_parse(void)
(void)nodeline;
}
-static ID
+ID
internal_id(struct parser_params *p)
{
return rb_make_temporary_id(vtable_size(p->lvtbl->args) + vtable_size(p->lvtbl->vars));
@@ -13679,72 +15498,83 @@ parser_initialize(struct parser_params *p)
p->command_start = TRUE;
p->ruby_sourcefile_string = Qnil;
p->lex.lpar_beg = -1; /* make lambda_beginning_p() == FALSE at first */
+ string_buffer_init(p);
p->node_id = 0;
- p->delayed.token = Qnil;
-#ifdef RIPPER
- p->result = Qnil;
- p->parsing_thread = Qnil;
-#else
+ p->delayed.token = NULL;
+ p->frozen_string_literal = -1; /* not specified */
+#ifndef RIPPER
p->error_buffer = Qfalse;
- p->end_expect_token_locations = Qnil;
+ p->end_expect_token_locations = NULL;
p->token_id = 0;
- p->tokens = Qnil;
+ p->tokens = NULL;
+#else
+ p->result = Qnil;
+ p->parsing_thread = Qnil;
+ p->s_value = Qnil;
+ p->s_lvalue = Qnil;
+ p->s_value_stack = rb_ary_new();
#endif
p->debug_buffer = Qnil;
p->debug_output = rb_ractor_stdout();
p->enc = rb_utf8_encoding();
+ p->exits = 0;
}
#ifdef RIPPER
-#define parser_mark ripper_parser_mark
-#define parser_free ripper_parser_free
+#define rb_ruby_parser_mark ripper_parser_mark
+#define rb_ruby_parser_free ripper_parser_free
+#define rb_ruby_parser_memsize ripper_parser_memsize
#endif
-static void
-parser_mark(void *ptr)
+void
+rb_ruby_parser_mark(void *ptr)
{
struct parser_params *p = (struct parser_params*)ptr;
- rb_gc_mark(p->lex.input);
- rb_gc_mark(p->lex.lastline);
- rb_gc_mark(p->lex.nextline);
rb_gc_mark(p->ruby_sourcefile_string);
- rb_gc_mark((VALUE)p->lex.strterm);
- rb_gc_mark((VALUE)p->ast);
- rb_gc_mark(p->case_labels);
- rb_gc_mark(p->delayed.token);
#ifndef RIPPER
- rb_gc_mark(p->debug_lines);
- rb_gc_mark(p->compile_option);
rb_gc_mark(p->error_buffer);
- rb_gc_mark(p->end_expect_token_locations);
- rb_gc_mark(p->tokens);
#else
rb_gc_mark(p->value);
rb_gc_mark(p->result);
rb_gc_mark(p->parsing_thread);
+ rb_gc_mark(p->s_value);
+ rb_gc_mark(p->s_lvalue);
+ rb_gc_mark(p->s_value_stack);
#endif
rb_gc_mark(p->debug_buffer);
rb_gc_mark(p->debug_output);
-#ifdef YYMALLOC
- rb_gc_mark((VALUE)p->heap);
-#endif
}
-static void
-parser_free(void *ptr)
+void
+rb_ruby_parser_free(void *ptr)
{
struct parser_params *p = (struct parser_params*)ptr;
struct local_vars *local, *prev;
+ if (p->ast) {
+ rb_ast_free(p->ast);
+ }
+
+ if (p->warn_duplicate_keys_table) {
+ st_free_table(p->warn_duplicate_keys_table);
+ }
+
+#ifndef RIPPER
+ if (p->tokens) {
+ rb_parser_ary_free(p, p->tokens);
+ }
+#endif
+
if (p->tokenbuf) {
- ruby_sized_xfree(p->tokenbuf, p->toksiz);
+ ruby_xfree_sized(p->tokenbuf, p->toksiz);
}
+
for (local = p->lvtbl; local; local = prev) {
- if (local->vars) xfree(local->vars);
prev = local->prev;
- xfree(local);
+ local_free(p, local);
}
+
{
token_info *ptinfo;
while ((ptinfo = p->token_info) != 0) {
@@ -13752,11 +15582,24 @@ parser_free(void *ptr)
xfree(ptinfo);
}
}
+ string_buffer_free(p);
+
+ if (p->pvtbl) {
+ st_free_table(p->pvtbl);
+ }
+
+ if (CASE_LABELS_ENABLED_P(p->case_labels)) {
+ st_free_table(p->case_labels);
+ }
+
+ xfree(p->lex.strterm);
+ p->lex.strterm = 0;
+
xfree(ptr);
}
-static size_t
-parser_memsize(const void *ptr)
+size_t
+rb_ruby_parser_memsize(const void *ptr)
{
struct parser_params *p = (struct parser_params*)ptr;
struct local_vars *local;
@@ -13770,20 +15613,6 @@ parser_memsize(const void *ptr)
return size;
}
-static const rb_data_type_t parser_data_type = {
-#ifndef RIPPER
- "parser",
-#else
- "ripper",
-#endif
- {
- parser_mark,
- parser_free,
- parser_memsize,
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
#ifndef RIPPER
#undef rb_reserved_word
@@ -13793,245 +15622,246 @@ rb_reserved_word(const char *str, unsigned int len)
return reserved_word(str, len);
}
-VALUE
-rb_parser_new(void)
+#ifdef UNIVERSAL_PARSER
+rb_parser_t *
+rb_ruby_parser_allocate(const rb_parser_config_t *config)
+{
+ /* parser_initialize expects fields to be set to 0 */
+ rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t));
+ p->config = config;
+ return p;
+}
+
+rb_parser_t *
+rb_ruby_parser_new(const rb_parser_config_t *config)
{
- struct parser_params *p;
- VALUE parser = TypedData_Make_Struct(0, struct parser_params,
- &parser_data_type, p);
+ /* parser_initialize expects fields to be set to 0 */
+ rb_parser_t *p = rb_ruby_parser_allocate(config);
parser_initialize(p);
- return parser;
+ return p;
+}
+#else
+rb_parser_t *
+rb_ruby_parser_allocate(void)
+{
+ /* parser_initialize expects fields to be set to 0 */
+ rb_parser_t *p = (rb_parser_t *)ruby_xcalloc(1, sizeof(rb_parser_t));
+ return p;
}
-VALUE
-rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
+rb_parser_t *
+rb_ruby_parser_new(void)
{
- struct parser_params *p;
+ /* parser_initialize expects fields to be set to 0 */
+ rb_parser_t *p = rb_ruby_parser_allocate();
+ parser_initialize(p);
+ return p;
+}
+#endif
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
+rb_parser_t *
+rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main)
+{
p->error_buffer = main ? Qfalse : Qnil;
p->parent_iseq = base;
- return vparser;
+ return p;
}
void
-rb_parser_keep_script_lines(VALUE vparser)
+rb_ruby_parser_set_script_lines(rb_parser_t *p)
{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- p->keep_script_lines = 1;
+ p->debug_lines = rb_parser_ary_new_capa_for_script_line(p, 10);
}
void
-rb_parser_error_tolerant(VALUE vparser)
+rb_ruby_parser_error_tolerant(rb_parser_t *p)
{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
p->error_tolerant = 1;
- p->end_expect_token_locations = rb_ary_new();
}
void
-rb_parser_keep_tokens(VALUE vparser)
+rb_ruby_parser_keep_tokens(rb_parser_t *p)
{
- struct parser_params *p;
-
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
p->keep_tokens = 1;
- p->tokens = rb_ary_new();
+ p->tokens = rb_parser_ary_new_capa_for_ast_token(p, 10);
}
-#endif
+rb_encoding *
+rb_ruby_parser_encoding(rb_parser_t *p)
+{
+ return p->enc;
+}
-#ifdef RIPPER
-#define rb_parser_end_seen_p ripper_parser_end_seen_p
-#define rb_parser_encoding ripper_parser_encoding
-#define rb_parser_get_yydebug ripper_parser_get_yydebug
-#define rb_parser_set_yydebug ripper_parser_set_yydebug
-#define rb_parser_get_debug_output ripper_parser_get_debug_output
-#define rb_parser_set_debug_output ripper_parser_set_debug_output
-static VALUE ripper_parser_end_seen_p(VALUE vparser);
-static VALUE ripper_parser_encoding(VALUE vparser);
-static VALUE ripper_parser_get_yydebug(VALUE self);
-static VALUE ripper_parser_set_yydebug(VALUE self, VALUE flag);
-static VALUE ripper_parser_get_debug_output(VALUE self);
-static VALUE ripper_parser_set_debug_output(VALUE self, VALUE output);
+int
+rb_ruby_parser_end_seen_p(rb_parser_t *p)
+{
+ return p->ruby__end__seen;
+}
-/*
- * call-seq:
- * ripper.error? -> Boolean
- *
- * Return true if parsed source has errors.
- */
-static VALUE
-ripper_error_p(VALUE vparser)
+int
+rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag)
{
- struct parser_params *p;
+ p->debug = flag;
+ return flag;
+}
+#endif /* !RIPPER */
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return RBOOL(p->error_p);
+#ifdef RIPPER
+int
+rb_ruby_parser_get_yydebug(rb_parser_t *p)
+{
+ return p->debug;
}
-#endif
-/*
- * call-seq:
- * ripper.end_seen? -> Boolean
- *
- * Return true if parsed source ended by +\_\_END\_\_+.
- */
-VALUE
-rb_parser_end_seen_p(VALUE vparser)
+void
+rb_ruby_parser_set_value(rb_parser_t *p, VALUE value)
{
- struct parser_params *p;
+ p->value = value;
+}
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return RBOOL(p->ruby__end__seen);
+int
+rb_ruby_parser_error_p(rb_parser_t *p)
+{
+ return p->error_p;
}
-/*
- * call-seq:
- * ripper.encoding -> encoding
- *
- * Return encoding of the source.
- */
VALUE
-rb_parser_encoding(VALUE vparser)
+rb_ruby_parser_debug_output(rb_parser_t *p)
{
- struct parser_params *p;
+ return p->debug_output;
+}
- TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
- return rb_enc_from_encoding(p->enc);
+void
+rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output)
+{
+ p->debug_output = output;
}
-#ifdef RIPPER
-/*
- * call-seq:
- * ripper.yydebug -> true or false
- *
- * Get yydebug.
- */
VALUE
-rb_parser_get_yydebug(VALUE self)
+rb_ruby_parser_parsing_thread(rb_parser_t *p)
{
- struct parser_params *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return RBOOL(p->debug);
+ return p->parsing_thread;
}
-#endif
-/*
- * call-seq:
- * ripper.yydebug = flag
- *
- * Set yydebug.
- */
-VALUE
-rb_parser_set_yydebug(VALUE self, VALUE flag)
+void
+rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread)
{
- struct parser_params *p;
+ p->parsing_thread = parsing_thread;
+}
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- p->debug = RTEST(flag);
- return flag;
+void
+rb_ruby_parser_ripper_initialize(rb_parser_t *p, rb_parser_lex_gets_func *gets, rb_parser_input_data input, VALUE sourcefile_string, const char *sourcefile, int sourceline)
+{
+ p->lex.gets = gets;
+ p->lex.input = input;
+ p->eofp = 0;
+ p->ruby_sourcefile_string = sourcefile_string;
+ p->ruby_sourcefile = sourcefile;
+ p->ruby_sourceline = sourceline;
}
-/*
- * call-seq:
- * ripper.debug_output -> obj
- *
- * Get debug output.
- */
VALUE
-rb_parser_get_debug_output(VALUE self)
+rb_ruby_parser_result(rb_parser_t *p)
{
- struct parser_params *p;
+ return p->result;
+}
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return p->debug_output;
+rb_encoding *
+rb_ruby_parser_enc(rb_parser_t *p)
+{
+ return p->enc;
}
-/*
- * call-seq:
- * ripper.debug_output = obj
- *
- * Set debug output.
- */
VALUE
-rb_parser_set_debug_output(VALUE self, VALUE output)
+rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p)
{
- struct parser_params *p;
+ return p->ruby_sourcefile_string;
+}
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- return p->debug_output = output;
+int
+rb_ruby_parser_ruby_sourceline(rb_parser_t *p)
+{
+ return p->ruby_sourceline;
}
-#ifndef RIPPER
-#ifdef YYMALLOC
-#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-/* Keep the order; NEWHEAP then xmalloc and ADD2HEAP to get rid of
- * potential memory leak */
-#define NEWHEAP() rb_imemo_tmpbuf_parser_heap(0, p->heap, 0)
-#define ADD2HEAP(new, cnt, ptr) ((p->heap = (new))->ptr = (ptr), \
- (new)->cnt = (cnt), (ptr))
+int
+rb_ruby_parser_lex_state(rb_parser_t *p)
+{
+ return p->lex.state;
+}
-void *
-rb_parser_malloc(struct parser_params *p, size_t size)
+void
+rb_ruby_ripper_parse0(rb_parser_t *p)
{
- size_t cnt = HEAPCNT(1, size);
- rb_imemo_tmpbuf_t *n = NEWHEAP();
- void *ptr = xmalloc(size);
+ parser_prepare(p);
+ p->ast = rb_ast_new();
+ ripper_yyparse((void*)p);
+ rb_ast_free(p->ast);
+ p->ast = 0;
+ p->eval_tree = 0;
+ p->eval_tree_begin = 0;
+}
- return ADD2HEAP(n, cnt, ptr);
+int
+rb_ruby_ripper_dedent_string(rb_parser_t *p, rb_parser_string_t *string, int width)
+{
+ return dedent_string(p, string, width);
}
-void *
-rb_parser_calloc(struct parser_params *p, size_t nelem, size_t size)
+int
+rb_ruby_ripper_initialized_p(rb_parser_t *p)
{
- size_t cnt = HEAPCNT(nelem, size);
- rb_imemo_tmpbuf_t *n = NEWHEAP();
- void *ptr = xcalloc(nelem, size);
+ return p->lex.input != 0;
+}
- return ADD2HEAP(n, cnt, ptr);
+void
+rb_ruby_ripper_parser_initialize(rb_parser_t *p)
+{
+ parser_initialize(p);
}
-void *
-rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
+long
+rb_ruby_ripper_column(rb_parser_t *p)
{
- rb_imemo_tmpbuf_t *n;
- size_t cnt = HEAPCNT(1, size);
+ return p->lex.ptok - p->lex.pbeg;
+}
- if (ptr && (n = p->heap) != NULL) {
- do {
- if (n->ptr == ptr) {
- n->ptr = ptr = xrealloc(ptr, size);
- if (n->cnt) n->cnt = cnt;
- return ptr;
- }
- } while ((n = n->next) != NULL);
- }
- n = NEWHEAP();
- ptr = xrealloc(ptr, size);
- return ADD2HEAP(n, cnt, ptr);
+long
+rb_ruby_ripper_token_len(rb_parser_t *p)
+{
+ return p->lex.pcur - p->lex.ptok;
}
-void
-rb_parser_free(struct parser_params *p, void *ptr)
+rb_parser_string_t *
+rb_ruby_ripper_lex_lastline(rb_parser_t *p)
{
- rb_imemo_tmpbuf_t **prev = &p->heap, *n;
+ return p->lex.lastline;
+}
- while ((n = *prev) != NULL) {
- if (n->ptr == ptr) {
- *prev = n->next;
- break;
- }
- prev = &n->next;
- }
+VALUE
+rb_ruby_ripper_lex_state_name(struct parser_params *p, int state)
+{
+ return rb_parser_lex_state_name(p, (enum lex_state_e)state);
+}
+
+#ifdef UNIVERSAL_PARSER
+rb_parser_t *
+rb_ripper_parser_params_allocate(const rb_parser_config_t *config)
+{
+ rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t));
+ p->config = config;
+ return p;
}
#endif
+struct parser_params*
+rb_ruby_ripper_parser_allocate(void)
+{
+ return (struct parser_params *)ruby_xcalloc(1, sizeof(struct parser_params));
+}
+#endif /* RIPPER */
+
+#ifndef RIPPER
void
rb_parser_printf(struct parser_params *p, const char *fmt, ...)
{
@@ -14042,16 +15872,26 @@ rb_parser_printf(struct parser_params *p, const char *fmt, ...)
va_start(ap, fmt);
rb_str_vcatf(mesg, fmt, ap);
va_end(ap);
- if (RSTRING_END(mesg)[-1] == '\n') {
+ if (char_at_end(p, mesg, 0) == '\n') {
rb_io_write(p->debug_output, mesg);
p->debug_buffer = Qnil;
}
}
static void
-parser_compile_error(struct parser_params *p, const char *fmt, ...)
+parser_compile_error(struct parser_params *p, const rb_code_location_t *loc, const char *fmt, ...)
{
va_list ap;
+ int lineno, column;
+
+ if (loc) {
+ lineno = loc->end_pos.lineno;
+ column = loc->end_pos.column;
+ }
+ else {
+ lineno = p->ruby_sourceline;
+ column = rb_long2int(p->lex.pcur - p->lex.pbeg);
+ }
rb_io_flush(p->debug_output);
p->error_p = 1;
@@ -14059,8 +15899,7 @@ parser_compile_error(struct parser_params *p, const char *fmt, ...)
p->error_buffer =
rb_syntax_error_append(p->error_buffer,
p->ruby_sourcefile_string,
- p->ruby_sourceline,
- rb_long2int(p->lex.pcur - p->lex.pbeg),
+ lineno, column,
p->enc, fmt, ap);
va_end(ap);
}
@@ -14079,7 +15918,7 @@ count_char(const char *str, int c)
*
* "\"`class' keyword\"" => "`class' keyword"
*/
-RUBY_FUNC_EXPORTED size_t
+size_t
rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr)
{
if (*yystr == '"') {
@@ -14088,31 +15927,30 @@ rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr)
while (*++yyp) {
switch (*yyp) {
- case '`':
+ case '\'':
if (!bquote) {
- bquote = count_char(yyp+1, '`') + 1;
+ bquote = count_char(yyp+1, '\'') + 1;
if (yyres) memcpy(&yyres[yyn], yyp, bquote);
yyn += bquote;
yyp += bquote - 1;
break;
}
- goto default_char;
-
- case '\'':
- if (bquote && count_char(yyp+1, '\'') + 1 == bquote) {
- if (yyres) memcpy(yyres + yyn, yyp, bquote);
- yyn += bquote;
- yyp += bquote - 1;
- bquote = 0;
- break;
- }
- if (yyp[1] && yyp[1] != '\'' && yyp[2] == '\'') {
- if (yyres) memcpy(yyres + yyn, yyp, 3);
- yyn += 3;
- yyp += 2;
- break;
+ else {
+ if (bquote && count_char(yyp+1, '\'') + 1 == bquote) {
+ if (yyres) memcpy(yyres + yyn, yyp, bquote);
+ yyn += bquote;
+ yyp += bquote - 1;
+ bquote = 0;
+ break;
+ }
+ if (yyp[1] && yyp[1] != '\'' && yyp[2] == '\'') {
+ if (yyres) memcpy(yyres + yyn, yyp, 3);
+ yyn += 3;
+ yyp += 2;
+ break;
+ }
+ goto do_not_strip_quotes;
}
- goto do_not_strip_quotes;
case ',':
goto do_not_strip_quotes;
@@ -14121,7 +15959,6 @@ rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr)
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
- default_char:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -14145,46 +15982,7 @@ rb_yytnamerr(struct parser_params *p, char *yyres, const char *yystr)
#endif
#ifdef RIPPER
-#ifdef RIPPER_DEBUG
-/* :nodoc: */
-static VALUE
-ripper_validate_object(VALUE self, VALUE x)
-{
- if (x == Qfalse) return x;
- if (x == Qtrue) return x;
- if (NIL_P(x)) return x;
- if (UNDEF_P(x))
- rb_raise(rb_eArgError, "Qundef given");
- if (FIXNUM_P(x)) return x;
- if (SYMBOL_P(x)) return x;
- switch (BUILTIN_TYPE(x)) {
- case T_STRING:
- case T_OBJECT:
- case T_ARRAY:
- case T_BIGNUM:
- case T_FLOAT:
- case T_COMPLEX:
- case T_RATIONAL:
- break;
- case T_NODE:
- if (!nd_type_p((NODE *)x, NODE_RIPPER)) {
- rb_raise(rb_eArgError, "NODE given: %p", (void *)x);
- }
- x = ((NODE *)x)->nd_rval;
- break;
- default:
- rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
- (void *)x, rb_obj_classname(x));
- }
- if (!RBASIC_CLASS(x)) {
- rb_raise(rb_eArgError, "hidden ruby object: %p (%s)",
- (void *)x, rb_builtin_type_name(TYPE(x)));
- }
- return x;
-}
-#endif
-
-#define validate(x) ((x) = get_value(x))
+#define validate(x) (void)(x)
static VALUE
ripper_dispatch0(struct parser_params *p, ID mid)
@@ -14250,377 +16048,21 @@ ripper_dispatch7(struct parser_params *p, ID mid, VALUE a, VALUE b, VALUE c, VAL
return rb_funcall(p->value, mid, 7, a, b, c, d, e, f, g);
}
-static ID
-ripper_get_id(VALUE v)
-{
- NODE *nd;
- if (!RB_TYPE_P(v, T_NODE)) return 0;
- nd = (NODE *)v;
- if (!nd_type_p(nd, NODE_RIPPER)) return 0;
- return nd->nd_vid;
-}
-
-static VALUE
-ripper_get_value(VALUE v)
-{
- NODE *nd;
- if (UNDEF_P(v)) return Qnil;
- if (!RB_TYPE_P(v, T_NODE)) return v;
- nd = (NODE *)v;
- if (!nd_type_p(nd, NODE_RIPPER)) return Qnil;
- return nd->nd_rval;
-}
-
-static void
+void
ripper_error(struct parser_params *p)
{
p->error_p = TRUE;
}
-static void
-ripper_compile_error(struct parser_params *p, const char *fmt, ...)
-{
- VALUE str;
- va_list args;
-
- va_start(args, fmt);
- str = rb_vsprintf(fmt, args);
- va_end(args);
- rb_funcall(p->value, rb_intern("compile_error"), 1, str);
- ripper_error(p);
-}
-
-static VALUE
-ripper_lex_get_generic(struct parser_params *p, VALUE src)
-{
- VALUE line = rb_funcallv_public(src, id_gets, 0, 0);
- if (!NIL_P(line) && !RB_TYPE_P(line, T_STRING)) {
- rb_raise(rb_eTypeError,
- "gets returned %"PRIsVALUE" (expected String or nil)",
- rb_obj_class(line));
- }
- return line;
-}
-
-static VALUE
-ripper_lex_io_get(struct parser_params *p, VALUE src)
-{
- return rb_io_gets(src);
-}
-
-static VALUE
-ripper_s_allocate(VALUE klass)
-{
- struct parser_params *p;
- VALUE self = TypedData_Make_Struct(klass, struct parser_params,
- &parser_data_type, p);
- p->value = self;
- return self;
-}
-
-#define ripper_initialized_p(r) ((r)->lex.input != 0)
-
-/*
- * call-seq:
- * Ripper.new(src, filename="(ripper)", lineno=1) -> ripper
- *
- * Create a new Ripper object.
- * _src_ must be a String, an 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 *p;
- VALUE src, fname, lineno;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
- if (RB_TYPE_P(src, T_FILE)) {
- p->lex.gets = ripper_lex_io_get;
- }
- else if (rb_respond_to(src, id_gets)) {
- p->lex.gets = ripper_lex_get_generic;
- }
- else {
- StringValue(src);
- p->lex.gets = lex_get_str;
- }
- p->lex.input = src;
- p->eofp = 0;
- if (NIL_P(fname)) {
- fname = STR_NEW2("(ripper)");
- OBJ_FREEZE(fname);
- }
- else {
- StringValueCStr(fname);
- fname = rb_str_new_frozen(fname);
- }
- parser_initialize(p);
-
- p->ruby_sourcefile_string = fname;
- p->ruby_sourcefile = RSTRING_PTR(fname);
- p->ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
-
- return Qnil;
-}
-
-static VALUE
-ripper_parse0(VALUE parser_v)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, p);
- parser_prepare(p);
- p->ast = rb_ast_new();
- ripper_yyparse((void*)p);
- rb_ast_dispose(p->ast);
- p->ast = 0;
- return p->result;
-}
-
-static VALUE
-ripper_ensure(VALUE parser_v)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(parser_v, struct parser_params, &parser_data_type, p);
- p->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 *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (!NIL_P(p->parsing_thread)) {
- if (p->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");
- }
- p->parsing_thread = rb_thread_current();
- rb_ensure(ripper_parse0, self, ripper_ensure, self);
-
- return p->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 *p;
- long col;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(p->parsing_thread)) return Qnil;
- col = p->lex.ptok - p->lex.pbeg;
- return LONG2NUM(col);
-}
-
-/*
- * call-seq:
- * ripper.filename -> String
- *
- * Return current parsing filename.
- */
-static VALUE
-ripper_filename(VALUE self)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- return p->ruby_sourcefile_string;
-}
-
-/*
- * 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 *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(p->parsing_thread)) return Qnil;
- return INT2NUM(p->ruby_sourceline);
-}
-
-/*
- * call-seq:
- * ripper.state -> Integer
- *
- * Return scanner state of current token.
- */
-static VALUE
-ripper_state(VALUE self)
-{
- struct parser_params *p;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(p->parsing_thread)) return Qnil;
- return INT2NUM(p->lex.state);
-}
-
-/*
- * call-seq:
- * ripper.token -> String
- *
- * Return the current token string.
- */
-static VALUE
-ripper_token(VALUE self)
-{
- struct parser_params *p;
- long pos, len;
-
- TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
- if (!ripper_initialized_p(p)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(p->parsing_thread)) return Qnil;
- pos = p->lex.ptok - p->lex.pbeg;
- len = p->lex.pcur - p->lex.ptok;
- return rb_str_subseq(p->lex.lastline, pos, len);
-}
-
-#ifdef RIPPER_DEBUG
-/* :nodoc: */
-static VALUE
-ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
-{
- StringValue(msg);
- if (UNDEF_P(obj)) {
- rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
- }
- return Qnil;
-}
-
-/* :nodoc: */
-static VALUE
-ripper_value(VALUE self, VALUE obj)
-{
- return ULONG2NUM(obj);
-}
-#endif
-
-/*
- * call-seq:
- * Ripper.lex_state_name(integer) -> string
- *
- * Returns a string representation of lex_state.
- */
-static VALUE
-ripper_lex_state_name(VALUE self, VALUE state)
-{
- return rb_parser_lex_state_name(NUM2INT(state));
-}
-
-void
-Init_ripper(void)
+VALUE
+ripper_value(struct parser_params *p)
{
- ripper_init_eventids1();
- ripper_init_eventids2();
- id_warn = rb_intern_const("warn");
- id_warning = rb_intern_const("warning");
- id_gets = rb_intern_const("gets");
- id_assoc = rb_intern_const("=>");
-
(void)yystpcpy; /* may not used in newer bison */
- InitVM(ripper);
+ return p->value;
}
-void
-InitVM_ripper(void)
-{
- VALUE Ripper;
-
- Ripper = rb_define_class("Ripper", rb_cObject);
- /* version of Ripper */
- rb_define_const(Ripper, "Version", rb_usascii_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, "filename", ripper_filename, 0);
- rb_define_method(Ripper, "lineno", ripper_lineno, 0);
- rb_define_method(Ripper, "state", ripper_state, 0);
- rb_define_method(Ripper, "token", ripper_token, 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);
- rb_define_method(Ripper, "debug_output", rb_parser_get_debug_output, 0);
- rb_define_method(Ripper, "debug_output=", rb_parser_set_debug_output, 1);
- rb_define_method(Ripper, "error?", ripper_error_p, 0);
-#ifdef RIPPER_DEBUG
- rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2);
- rb_define_method(Ripper, "rawVALUE", ripper_value, 1);
- rb_define_method(Ripper, "validate_object", ripper_validate_object, 1);
-#endif
-
- rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2);
- rb_define_private_method(Ripper, "dedent_string", parser_dedent_string, 2);
-
- rb_define_singleton_method(Ripper, "lex_state_name", ripper_lex_state_name, 1);
-
-<% @exprs.each do |expr, desc| -%>
- /* <%=desc%> */
- rb_define_const(Ripper, "<%=expr%>", INT2NUM(<%=expr%>));
-<% end %>
- ripper_init_eventids1_table(Ripper);
- ripper_init_eventids2_table(Ripper);
-
-# if 0
- /* Hack to let RDoc document SCRIPT_LINES__ */
-
- /*
- * When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded
- * after the assignment will be added as an Array of lines with the file
- * name as the key.
- */
- rb_define_global_const("SCRIPT_LINES__", Qnil);
-#endif
-
-}
#endif /* RIPPER */
-
/*
* Local variables:
* mode: c
diff --git a/parser_bits.h b/parser_bits.h
new file mode 100644
index 0000000000..f894dde33e
--- /dev/null
+++ b/parser_bits.h
@@ -0,0 +1,647 @@
+#ifndef INTERNAL_BITS2_H /*-*-C-*-vi:se ft=c:*/
+#define INTERNAL_BITS2_H
+/**
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @brief Internal header for bitwise integer algorithms.
+ * @see Henry S. Warren Jr., "Hacker's Delight" (2nd ed.), 2013.
+ * @see SEI CERT C Coding Standard INT32-C. "Ensure that operations on
+ * signed integers do not result in overflow"
+ * @see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ * @see https://clang.llvm.org/docs/LanguageExtensions.html#builtin-rotateleft
+ * @see https://clang.llvm.org/docs/LanguageExtensions.html#builtin-rotateright
+ * @see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort
+ * @see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64
+ * @see https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64
+ * @see https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64
+ * @see https://docs.microsoft.com/en-us/cpp/intrinsics/lzcnt16-lzcnt-lzcnt64
+ * @see https://docs.microsoft.com/en-us/cpp/intrinsics/popcnt16-popcnt-popcnt64
+ * @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_lzcnt_u32
+ * @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_tzcnt_u32
+ * @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_rotl64
+ * @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_rotr64
+ * @see https://stackoverflow.com/a/776523
+ */
+#include "ruby/internal/config.h"
+#include <limits.h> /* for CHAR_BITS */
+#include <stdint.h> /* for uintptr_t */
+#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
+
+#ifdef _MSC_VER
+# include <stdlib.h> /* for _byteswap_uint64 */
+#endif
+
+#if defined(HAVE_X86INTRIN_H)
+# include <x86intrin.h> /* for _lzcnt_u64 */
+#elif defined(_MSC_VER)
+# include <intrin.h> /* for the following intrinsics */
+#endif
+
+#if defined(_MSC_VER) && defined(__AVX__)
+# pragma intrinsic(__popcnt)
+# pragma intrinsic(__popcnt64)
+#endif
+
+#if defined(_MSC_VER) && defined(__AVX2__)
+# pragma intrinsic(__lzcnt)
+# pragma intrinsic(__lzcnt64)
+#endif
+
+#if defined(_MSC_VER)
+# pragma intrinsic(_rotl)
+# pragma intrinsic(_rotr)
+# ifdef _WIN64
+# pragma intrinsic(_rotl64)
+# pragma intrinsic(_rotr64)
+# endif
+# pragma intrinsic(_BitScanForward)
+# pragma intrinsic(_BitScanReverse)
+# ifdef _WIN64
+# pragma intrinsic(_BitScanForward64)
+# pragma intrinsic(_BitScanReverse64)
+# endif
+#endif
+
+#include "parser_value.h" /* for VALUE */
+#include "internal/static_assert.h" /* for STATIC_ASSERT */
+
+/* The most significant bit of the lower part of half-long integer.
+ * If sizeof(long) == 4, this is 0x8000.
+ * If sizeof(long) == 8, this is 0x80000000.
+ */
+#define HALF_LONG_MSB ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
+
+#define SIGNED_INTEGER_TYPE_P(T) (0 > ((T)0)-1)
+
+#define SIGNED_INTEGER_MIN(T) \
+ ((sizeof(T) == sizeof(int8_t)) ? ((T)INT8_MIN) : \
+ ((sizeof(T) == sizeof(int16_t)) ? ((T)INT16_MIN) : \
+ ((sizeof(T) == sizeof(int32_t)) ? ((T)INT32_MIN) : \
+ ((sizeof(T) == sizeof(int64_t)) ? ((T)INT64_MIN) : \
+ 0))))
+
+#define SIGNED_INTEGER_MAX(T) ((T)(SIGNED_INTEGER_MIN(T) ^ ((T)~(T)0)))
+
+#define UNSIGNED_INTEGER_MAX(T) ((T)~(T)0)
+
+#ifndef MUL_OVERFLOW_SIGNED_INTEGER_P
+#if __has_builtin(__builtin_mul_overflow_p)
+# define MUL_OVERFLOW_P(a, b) \
+ __builtin_mul_overflow_p((a), (b), (__typeof__(a * b))0)
+#elif __has_builtin(__builtin_mul_overflow)
+# define MUL_OVERFLOW_P(a, b) \
+ __extension__ ({ __typeof__(a) c; __builtin_mul_overflow((a), (b), &c); })
+#endif
+
+#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (a) == 0 ? 0 : \
+ (a) == -1 ? (b) < -(max) : \
+ (a) > 0 ? \
+ ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
+ ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
+
+#if __has_builtin(__builtin_mul_overflow_p)
+/* __builtin_mul_overflow_p can take bitfield */
+/* and GCC permits bitfields for integers other than int */
+# define MUL_OVERFLOW_FIXNUM_P(a, b) \
+ __extension__ ({ \
+ struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
+ __builtin_mul_overflow_p((a), (b), c.fixnum); \
+ })
+#else
+# define MUL_OVERFLOW_FIXNUM_P(a, b) \
+ MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
+#endif
+
+#if defined(MUL_OVERFLOW_P) && defined(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG)
+# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
+#else
+# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef MUL_OVERFLOW_P
+# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
+# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
+#else
+# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
+# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
+#endif
+#endif
+
+#ifndef ADD_OVERFLOW_SIGNED_INTEGER_P
+#if __has_builtin(__builtin_add_overflow_p)
+# define ADD_OVERFLOW_P(a, b) \
+ __builtin_add_overflow_p((a), (b), (__typeof__(a * b))0)
+#elif __has_builtin(__builtin_add_overflow)
+# define ADD_OVERFLOW_P(a, b) \
+ __extension__ ({ __typeof__(a) c; __builtin_add_overflow((a), (b), &c); })
+#endif
+
+#define ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (a) > 0 ? (b) > (max) - (a) : (b) < (min) - (a))
+
+#if __has_builtin(__builtin_add_overflow_p)
+/* __builtin_add_overflow_p can take bitfield */
+/* and GCC permits bitfields for integers other than int */
+# define ADD_OVERFLOW_FIXNUM_P(a, b) \
+ __extension__ ({ \
+ struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
+ __builtin_add_overflow_p((a), (b), c.fixnum); \
+ })
+#else
+# define ADD_OVERFLOW_FIXNUM_P(a, b) \
+ ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
+#endif
+
+#if defined(ADD_OVERFLOW_P) && defined(USE___BUILTIN_ADD_OVERFLOW_LONG_LONG)
+# define ADD_OVERFLOW_LONG_LONG_P(a, b) ADD_OVERFLOW_P(a, b)
+#else
+# define ADD_OVERFLOW_LONG_LONG_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef ADD_OVERFLOW_P
+# define ADD_OVERFLOW_LONG_P(a, b) ADD_OVERFLOW_P(a, b)
+# define ADD_OVERFLOW_INT_P(a, b) ADD_OVERFLOW_P(a, b)
+#else
+# define ADD_OVERFLOW_LONG_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
+# define ADD_OVERFLOW_INT_P(a, b) ADD_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
+#endif
+#endif
+
+#ifndef SUB_OVERFLOW_SIGNED_INTEGER_P
+#if __has_builtin(__builtin_sub_overflow_p)
+# define SUB_OVERFLOW_P(a, b) \
+ __builtin_sub_overflow_p((a), (b), (__typeof__(a * b))0)
+#elif __has_builtin(__builtin_sub_overflow)
+# define SUB_OVERFLOW_P(a, b) \
+ __extension__ ({ __typeof__(a) c; __builtin_sub_overflow((a), (b), &c); })
+#endif
+
+#define SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (b) > 0 ? (a) < (min) + (b) : (a) > (max) + (b))
+
+#if __has_builtin(__builtin_sub_overflow_p)
+/* __builtin_sub_overflow_p can take bitfield */
+/* and GCC permits bitfields for integers other than int */
+# define SUB_OVERFLOW_FIXNUM_P(a, b) \
+ __extension__ ({ \
+ struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
+ __builtin_sub_overflow_p((a), (b), c.fixnum); \
+ })
+#else
+# define SUB_OVERFLOW_FIXNUM_P(a, b) \
+ SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
+#endif
+
+#if defined(SUB_OVERFLOW_P) && defined(USE___BUILTIN_SUB_OVERFLOW_LONG_LONG)
+# define SUB_OVERFLOW_LONG_LONG_P(a, b) SUB_OVERFLOW_P(a, b)
+#else
+# define SUB_OVERFLOW_LONG_LONG_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef SUB_OVERFLOW_P
+# define SUB_OVERFLOW_LONG_P(a, b) SUB_OVERFLOW_P(a, b)
+# define SUB_OVERFLOW_INT_P(a, b) SUB_OVERFLOW_P(a, b)
+#else
+# define SUB_OVERFLOW_LONG_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
+# define SUB_OVERFLOW_INT_P(a, b) SUB_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
+#endif
+#endif
+
+#ifdef HAVE_UINT128_T
+# define bit_length(x) \
+ (unsigned int) \
+ (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
+ sizeof(x) <= sizeof(int64_t) ? 64 - nlz_int64((uint64_t)(x)) : \
+ 128 - nlz_int128((uint128_t)(x)))
+#else
+# define bit_length(x) \
+ (unsigned int) \
+ (sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
+ 64 - nlz_int64((uint64_t)(x)))
+#endif
+
+#ifndef swap16
+# define swap16 ruby_swap16
+#endif
+
+#ifndef swap32
+# define swap32 ruby_swap32
+#endif
+
+#ifndef swap64
+# define swap64 ruby_swap64
+#endif
+
+static inline uint16_t ruby_swap16(uint16_t);
+static inline uint32_t ruby_swap32(uint32_t);
+static inline uint64_t ruby_swap64(uint64_t);
+static inline unsigned nlz_int(unsigned x);
+static inline unsigned nlz_long(unsigned long x);
+static inline unsigned nlz_long_long(unsigned long long x);
+static inline unsigned nlz_intptr(uintptr_t x);
+static inline unsigned nlz_int32(uint32_t x);
+static inline unsigned nlz_int64(uint64_t x);
+#ifdef HAVE_UINT128_T
+static inline unsigned nlz_int128(uint128_t x);
+#endif
+static inline unsigned rb_popcount32(uint32_t x);
+static inline unsigned rb_popcount64(uint64_t x);
+static inline unsigned rb_popcount_intptr(uintptr_t x);
+static inline int ntz_int32(uint32_t x);
+static inline int ntz_int64(uint64_t x);
+static inline int ntz_intptr(uintptr_t x);
+static inline VALUE RUBY_BIT_ROTL(VALUE, int);
+static inline VALUE RUBY_BIT_ROTR(VALUE, int);
+
+static inline uint16_t
+ruby_swap16(uint16_t x)
+{
+#if __has_builtin(__builtin_bswap16)
+ return __builtin_bswap16(x);
+
+#elif defined(_MSC_VER)
+ return _byteswap_ushort(x);
+
+#else
+ return (x << 8) | (x >> 8);
+
+#endif
+}
+
+static inline uint32_t
+ruby_swap32(uint32_t x)
+{
+#if __has_builtin(__builtin_bswap32)
+ return __builtin_bswap32(x);
+
+#elif defined(_MSC_VER)
+ return _byteswap_ulong(x);
+
+#else
+ x = ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16);
+ x = ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8);
+ return x;
+
+#endif
+}
+
+static inline uint64_t
+ruby_swap64(uint64_t x)
+{
+#if __has_builtin(__builtin_bswap64)
+ return __builtin_bswap64(x);
+
+#elif defined(_MSC_VER)
+ return _byteswap_uint64(x);
+
+#else
+ x = ((x & 0x00000000FFFFFFFFULL) << 32) | ((x & 0xFFFFFFFF00000000ULL) >> 32);
+ x = ((x & 0x0000FFFF0000FFFFULL) << 16) | ((x & 0xFFFF0000FFFF0000ULL) >> 16);
+ x = ((x & 0x00FF00FF00FF00FFULL) << 8) | ((x & 0xFF00FF00FF00FF00ULL) >> 8);
+ return x;
+
+#endif
+}
+
+static inline unsigned int
+nlz_int32(uint32_t x)
+{
+#if defined(_MSC_VER) && defined(__AVX2__)
+ /* Note: It seems there is no such thing like __LZCNT__ predefined in MSVC.
+ * AMD CPUs have had this instruction for decades (since K10) but for
+ * Intel, Haswell is the oldest one. We need to use __AVX2__ for maximum
+ * safety. */
+ return (unsigned int)__lzcnt(x);
+
+#elif defined(__x86_64__) && defined(__LZCNT__)
+ return (unsigned int)_lzcnt_u32(x);
+
+#elif defined(_MSC_VER) /* &&! defined(__AVX2__) */
+ unsigned long r;
+ return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
+
+#elif __has_builtin(__builtin_clz)
+ STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
+ return x ? (unsigned int)__builtin_clz(x) : 32;
+
+#else
+ uint32_t y;
+ unsigned n = 32;
+ y = x >> 16; if (y) {n -= 16; x = y;}
+ y = x >> 8; if (y) {n -= 8; x = y;}
+ y = x >> 4; if (y) {n -= 4; x = y;}
+ y = x >> 2; if (y) {n -= 2; x = y;}
+ y = x >> 1; if (y) {return n - 2;}
+ return (unsigned int)(n - x);
+#endif
+}
+
+static inline unsigned int
+nlz_int64(uint64_t x)
+{
+#if defined(_MSC_VER) && defined(__AVX2__)
+ return (unsigned int)__lzcnt64(x);
+
+#elif defined(__x86_64__) && defined(__LZCNT__)
+ return (unsigned int)_lzcnt_u64(x);
+
+#elif defined(_WIN64) && defined(_MSC_VER) /* &&! defined(__AVX2__) */
+ unsigned long r;
+ return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
+
+#elif __has_builtin(__builtin_clzl)
+ if (x == 0) {
+ return 64;
+ }
+ else if (sizeof(long) * CHAR_BIT == 64) {
+ return (unsigned int)__builtin_clzl((unsigned long)x);
+ }
+ else if (sizeof(long long) * CHAR_BIT == 64) {
+ return (unsigned int)__builtin_clzll((unsigned long long)x);
+ }
+ else {
+ /* :FIXME: Is there a way to make this branch a compile-time error? */
+ UNREACHABLE_RETURN(~0);
+ }
+
+#else
+ uint64_t y;
+ unsigned int n = 64;
+ y = x >> 32; if (y) {n -= 32; x = y;}
+ y = x >> 16; if (y) {n -= 16; x = y;}
+ y = x >> 8; if (y) {n -= 8; x = y;}
+ y = x >> 4; if (y) {n -= 4; x = y;}
+ y = x >> 2; if (y) {n -= 2; x = y;}
+ y = x >> 1; if (y) {return n - 2;}
+ return (unsigned int)(n - x);
+
+#endif
+}
+
+#ifdef HAVE_UINT128_T
+static inline unsigned int
+nlz_int128(uint128_t x)
+{
+ uint64_t y = (uint64_t)(x >> 64);
+
+ if (x == 0) {
+ return 128;
+ }
+ else if (y == 0) {
+ return (unsigned int)nlz_int64(x) + 64;
+ }
+ else {
+ return (unsigned int)nlz_int64(y);
+ }
+}
+#endif
+
+static inline unsigned int
+nlz_int(unsigned int x)
+{
+ if (sizeof(unsigned int) * CHAR_BIT == 32) {
+ return nlz_int32((uint32_t)x);
+ }
+ else if (sizeof(unsigned int) * CHAR_BIT == 64) {
+ return nlz_int64((uint64_t)x);
+ }
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline unsigned int
+nlz_long(unsigned long x)
+{
+ if (sizeof(unsigned long) * CHAR_BIT == 32) {
+ return nlz_int32((uint32_t)x);
+ }
+ else if (sizeof(unsigned long) * CHAR_BIT == 64) {
+ return nlz_int64((uint64_t)x);
+ }
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline unsigned int
+nlz_long_long(unsigned long long x)
+{
+ if (sizeof(unsigned long long) * CHAR_BIT == 64) {
+ return nlz_int64((uint64_t)x);
+ }
+#ifdef HAVE_UINT128_T
+ else if (sizeof(unsigned long long) * CHAR_BIT == 128) {
+ return nlz_int128((uint128_t)x);
+ }
+#endif
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline unsigned int
+nlz_intptr(uintptr_t x)
+{
+ if (sizeof(uintptr_t) == sizeof(unsigned int)) {
+ return nlz_int((unsigned int)x);
+ }
+ if (sizeof(uintptr_t) == sizeof(unsigned long)) {
+ return nlz_long((unsigned long)x);
+ }
+ if (sizeof(uintptr_t) == sizeof(unsigned long long)) {
+ return nlz_long_long((unsigned long long)x);
+ }
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline unsigned int
+rb_popcount32(uint32_t x)
+{
+#if defined(_MSC_VER) && defined(__AVX__)
+ /* Note: CPUs since Nehalem and Barcelona have had this instruction so SSE
+ * 4.2 should suffice, but it seems there is no such thing like __SSE_4_2__
+ * predefined macro in MSVC. They do have __AVX__ so use it instead. */
+ return (unsigned int)__popcnt(x);
+
+#elif __has_builtin(__builtin_popcount)
+ STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT >= 32);
+ return (unsigned int)__builtin_popcount(x);
+
+#else
+ x = (x & 0x55555555) + (x >> 1 & 0x55555555);
+ x = (x & 0x33333333) + (x >> 2 & 0x33333333);
+ x = (x & 0x07070707) + (x >> 4 & 0x07070707);
+ x = (x & 0x000f000f) + (x >> 8 & 0x000f000f);
+ x = (x & 0x0000001f) + (x >>16 & 0x0000001f);
+ return (unsigned int)x;
+
+#endif
+}
+
+static inline unsigned int
+rb_popcount64(uint64_t x)
+{
+#if defined(_MSC_VER) && defined(__AVX__)
+ return (unsigned int)__popcnt64(x);
+
+#elif __has_builtin(__builtin_popcount)
+ if (sizeof(long) * CHAR_BIT == 64) {
+ return (unsigned int)__builtin_popcountl((unsigned long)x);
+ }
+ else if (sizeof(long long) * CHAR_BIT == 64) {
+ return (unsigned int)__builtin_popcountll((unsigned long long)x);
+ }
+ else {
+ /* :FIXME: Is there a way to make this branch a compile-time error? */
+ UNREACHABLE_RETURN(~0);
+ }
+
+#else
+ x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
+ x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
+ x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
+ x = (x & 0x000f000f000f000f) + (x >> 8 & 0x000f000f000f000f);
+ x = (x & 0x0000001f0000001f) + (x >>16 & 0x0000001f0000001f);
+ x = (x & 0x000000000000003f) + (x >>32 & 0x000000000000003f);
+ return (unsigned int)x;
+
+#endif
+}
+
+static inline unsigned int
+rb_popcount_intptr(uintptr_t x)
+{
+ if (sizeof(uintptr_t) * CHAR_BIT == 64) {
+ return rb_popcount64((uint64_t)x);
+ }
+ else if (sizeof(uintptr_t) * CHAR_BIT == 32) {
+ return rb_popcount32((uint32_t)x);
+ }
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline int
+ntz_int32(uint32_t x)
+{
+#if defined(__x86_64__) && defined(__BMI__)
+ return (unsigned)_tzcnt_u32(x);
+
+#elif defined(_MSC_VER)
+ /* :FIXME: Is there any way to issue TZCNT instead of BSF, apart from using
+ * assembly? Because issuing LZCNT seems possible (see nlz.h). */
+ unsigned long r;
+ return _BitScanForward(&r, x) ? (int)r : 32;
+
+#elif __has_builtin(__builtin_ctz)
+ STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
+ return x ? (unsigned)__builtin_ctz(x) : 32;
+
+#else
+ return rb_popcount32((~x) & (x-1));
+
+#endif
+}
+
+static inline int
+ntz_int64(uint64_t x)
+{
+#if defined(__x86_64__) && defined(__BMI__)
+ return (unsigned)_tzcnt_u64(x);
+
+#elif defined(_WIN64) && defined(_MSC_VER)
+ unsigned long r;
+ return _BitScanForward64(&r, x) ? (int)r : 64;
+
+#elif __has_builtin(__builtin_ctzl)
+ if (x == 0) {
+ return 64;
+ }
+ else if (sizeof(long) * CHAR_BIT == 64) {
+ return (unsigned)__builtin_ctzl((unsigned long)x);
+ }
+ else if (sizeof(long long) * CHAR_BIT == 64) {
+ return (unsigned)__builtin_ctzll((unsigned long long)x);
+ }
+ else {
+ /* :FIXME: Is there a way to make this branch a compile-time error? */
+ UNREACHABLE_RETURN(~0);
+ }
+
+#else
+ return rb_popcount64((~x) & (x-1));
+
+#endif
+}
+
+static inline int
+ntz_intptr(uintptr_t x)
+{
+ if (sizeof(uintptr_t) * CHAR_BIT == 64) {
+ return ntz_int64((uint64_t)x);
+ }
+ else if (sizeof(uintptr_t) * CHAR_BIT == 32) {
+ return ntz_int32((uint32_t)x);
+ }
+ else {
+ UNREACHABLE_RETURN(~0);
+ }
+}
+
+static inline VALUE
+RUBY_BIT_ROTL(VALUE v, int n)
+{
+#if __has_builtin(__builtin_rotateleft32) && (SIZEOF_VALUE * CHAR_BIT == 32)
+ return __builtin_rotateleft32(v, n);
+
+#elif __has_builtin(__builtin_rotateleft64) && (SIZEOF_VALUE * CHAR_BIT == 64)
+ return __builtin_rotateleft64(v, n);
+
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
+ return _rotl(v, n);
+
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
+ return _rotl64(v, n);
+
+#elif defined(_lrotl) && (SIZEOF_VALUE == SIZEOF_LONG)
+ return _lrotl(v, n);
+
+#else
+ const int m = (sizeof(VALUE) * CHAR_BIT) - 1;
+ return (v << (n & m)) | (v >> (-n & m));
+#endif
+}
+
+static inline VALUE
+RUBY_BIT_ROTR(VALUE v, int n)
+{
+#if __has_builtin(__builtin_rotateright32) && (SIZEOF_VALUE * CHAR_BIT == 32)
+ return __builtin_rotateright32(v, n);
+
+#elif __has_builtin(__builtin_rotateright64) && (SIZEOF_VALUE * CHAR_BIT == 64)
+ return __builtin_rotateright64(v, n);
+
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
+ return _rotr(v, n);
+
+#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
+ return _rotr64(v, n);
+
+#elif defined(_lrotr) && (SIZEOF_VALUE == SIZEOF_LONG)
+ return _lrotr(v, n);
+
+#else
+ const int m = (sizeof(VALUE) * CHAR_BIT) - 1;
+ return (v << (-n & m)) | (v >> (n & m));
+#endif
+}
+
+#endif /* INTERNAL_BITS2_H */
diff --git a/parser_node.h b/parser_node.h
new file mode 100644
index 0000000000..2955720676
--- /dev/null
+++ b/parser_node.h
@@ -0,0 +1,32 @@
+#ifndef RUBY_PARSER_NODE_H
+#define RUBY_PARSER_NODE_H 1
+/*
+ * This is a header file used by only "parse.y"
+ */
+#include "rubyparser.h"
+#include "internal/compilers.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#if 0
+} /* satisfy cc-mode */
+#endif
+#endif
+
+static inline rb_code_location_t
+code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2)
+{
+ rb_code_location_t loc;
+ loc.beg_pos = loc1->beg_pos;
+ loc.end_pos = loc2->end_pos;
+ return loc;
+}
+
+#if defined(__cplusplus)
+#if 0
+{ /* satisfy cc-mode */
+#endif
+} /* extern "C" { */
+#endif
+
+#endif /* RUBY_PARSER_NODE_H */
diff --git a/parser_st.c b/parser_st.c
new file mode 100644
index 0000000000..77d9df702e
--- /dev/null
+++ b/parser_st.c
@@ -0,0 +1,171 @@
+#include "parser_st.h"
+#include "parser_bits.h"
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#undef NOT_RUBY
+#undef RUBY
+#undef RUBY_EXPORT
+
+#undef MEMCPY
+#define MEMCPY(p1,p2,type,n) nonempty_memcpy((p1), (p2), (sizeof(type) * (n)))
+/* The multiplication should not overflow since this macro is used
+ * only with the already allocated size. */
+static inline void *
+nonempty_memcpy(void *dest, const void *src, size_t n)
+{
+ if (n) {
+ return memcpy(dest, src, n);
+ }
+ else {
+ return dest;
+ }
+}
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <string.h>
+#include <assert.h>
+
+#ifdef __GNUC__
+#define PREFETCH(addr, write_p) __builtin_prefetch(addr, write_p)
+#define EXPECT(expr, val) __builtin_expect(expr, val)
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+#else
+#define PREFETCH(addr, write_p)
+#define EXPECT(expr, val) (expr)
+#define ATTRIBUTE_UNUSED
+#endif
+
+
+#define st_index_t parser_st_index_t
+#define st_hash_t parser_st_hash_t
+#define st_data_t parser_st_data_t
+#define st_hash_type parser_st_hash_type
+#define st_table parser_st_table
+#define st_table_entry parser_st_table_entry
+#define st_update_callback_func parser_st_update_callback_func
+#define st_foreach_check_callback_func parser_st_foreach_check_callback_func
+#define st_foreach_callback_func parser_st_foreach_callback_func
+#define st_retval parser_st_retval
+
+#define ST_CONTINUE ST2_CONTINUE
+#define ST_STOP ST2_STOP
+#define ST_DELETE ST2_DELETE
+#define ST_CHECK ST2_CHECK
+#define ST_REPLACE ST2_REPLACE
+
+#undef st_numcmp
+#define st_numcmp rb_parser_st_numcmp
+#undef st_numhash
+#define st_numhash rb_parser_st_numhash
+#undef st_free_table
+#define st_free_table rb_parser_st_free_table
+#define rb_st_hash_start rb_parser_st_hash_start
+#undef st_delete
+#define st_delete rb_parser_st_delete
+#undef st_foreach
+#define st_foreach rb_parser_st_foreach
+#undef st_init_numtable
+#define st_init_numtable rb_parser_st_init_numtable
+#undef st_init_table_with_size
+#define st_init_table_with_size rb_parser_st_init_table_with_size
+#undef st_init_existing_table_with_size
+#define st_init_existing_table_with_size rb_parser_st_init_existing_table_with_size
+#undef st_init_existing_strtable_with_size
+#define st_init_existing_strtable_with_size rb_parser_st_init_existing_strtable_with_size
+#undef st_init_existing_numtable_with_size
+#define st_init_existing_numtable_with_size rb_parser_st_init_existing_numtable_with_size
+#undef st_free_embedded_table
+#define st_free_embedded_table rb_parser_st_free_embedded_table
+#undef st_insert
+#define st_insert rb_parser_st_insert
+#undef st_lookup
+#define st_lookup rb_parser_st_lookup
+
+#undef st_table_size
+#define st_table_size rb_parser_st_table_size
+#undef st_clear
+#define st_clear rb_parser_st_clear
+#undef st_init_strtable
+#define st_init_strtable rb_parser_st_init_strtable
+#undef st_init_table
+#define st_init_table rb_parser_st_init_table
+#undef st_init_strcasetable
+#define st_init_strcasetable rb_parser_st_init_strcasetable
+#undef st_init_strtable_with_size
+#define st_init_strtable_with_size rb_parser_st_init_strtable_with_size
+#undef st_init_numtable_with_size
+#define st_init_numtable_with_size rb_parser_st_init_numtable_with_size
+#undef st_init_strcasetable_with_size
+#define st_init_strcasetable_with_size rb_parser_st_init_strcasetable_with_size
+#undef st_memsize
+#define st_memsize rb_parser_st_memsize
+#undef st_get_key
+#define st_get_key rb_parser_st_get_key
+#undef st_add_direct
+#define st_add_direct rb_parser_st_add_direct
+#define rb_st_add_direct_with_hash rb_parser_st_add_direct_with_hash
+#undef st_insert2
+#define st_insert2 rb_parser_st_insert2
+#undef st_replace
+#define st_replace rb_parser_st_replace
+#undef st_copy
+#define st_copy rb_parser_st_copy
+#undef st_delete_safe
+#define st_delete_safe rb_parser_st_delete_safe
+#undef st_shift
+#define st_shift rb_parser_st_shift
+#undef st_cleanup_safe
+#define st_cleanup_safe rb_parser_st_cleanup_safe
+#undef st_update
+#define st_update rb_parser_st_update
+#undef st_foreach_with_replace
+#define st_foreach_with_replace rb_parser_st_foreach_with_replace
+#undef st_foreach_check
+#define st_foreach_check rb_parser_st_foreach_check
+#undef st_keys
+#define st_keys rb_parser_st_keys
+#undef st_keys_check
+#define st_keys_check rb_parser_st_keys_check
+#undef st_values
+#define st_values rb_parser_st_values
+#undef st_values_check
+#define st_values_check rb_parser_st_values_check
+#undef st_hash
+#define st_hash rb_parser_st_hash
+#undef st_hash_uint32
+#define st_hash_uint32 rb_parser_st_hash_uint32
+#undef st_hash_uint
+#define st_hash_uint rb_parser_st_hash_uint
+#undef st_hash_end
+#define st_hash_end rb_parser_st_hash_end
+#undef st_locale_insensitive_strcasecmp
+#define st_locale_insensitive_strcasecmp rb_parser_st_locale_insensitive_strcasecmp
+#undef st_locale_insensitive_strncasecmp
+#define st_locale_insensitive_strncasecmp rb_parser_st_locale_insensitive_strncasecmp
+
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
+/* GCC warns about unknown sanitizer, which is annoying. */
+# undef NO_SANITIZE
+# define NO_SANITIZE(x, y) \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wattributes\"") \
+ __attribute__((__no_sanitize__(x))) y; \
+ _Pragma("GCC diagnostic pop") \
+ y
+#endif
+
+#ifndef NO_SANITIZE
+# define NO_SANITIZE(x, y) y
+#endif
+
+#include "st.c"
diff --git a/parser_st.h b/parser_st.h
new file mode 100644
index 0000000000..007ebb1bd4
--- /dev/null
+++ b/parser_st.h
@@ -0,0 +1,161 @@
+/* This is a public domain general purpose hash table package
+ originally written by Peter Moore @ UCB.
+
+ The hash table data structures were redesigned and the package was
+ rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
+
+#ifndef RUBY_ST2_H
+#define RUBY_ST2_H 1
+
+#if defined(__cplusplus)
+extern "C" {
+#if 0
+} /* satisfy cc-mode */
+#endif
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+#include "ruby/config.h"
+#include "ruby/backward/2/long_long.h"
+#include "ruby/defines.h"
+
+RUBY_SYMBOL_EXPORT_BEGIN
+
+#if SIZEOF_LONG == SIZEOF_VOIDP
+typedef unsigned long parser_st_data_t;
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+typedef unsigned LONG_LONG parser_st_data_t;
+#else
+# error ---->> parser_st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
+#endif
+#define ST2_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 parser_st_table parser_st_table;
+
+typedef parser_st_data_t parser_st_index_t;
+
+/* Maximal value of unsigned integer type parser_st_index_t. */
+#define MAX_ST2_INDEX_VAL (~(parser_st_index_t) 0)
+
+typedef int parser_st_compare_func(parser_st_data_t, parser_st_data_t);
+typedef parser_st_index_t parser_st_hash_func(parser_st_data_t);
+
+typedef char st_check_for_sizeof_parser_st_index_t[SIZEOF_VOIDP == (int)sizeof(parser_st_index_t) ? 1 : -1];
+#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
+
+struct parser_st_hash_type {
+ int (*compare)(parser_st_data_t, parser_st_data_t); /* parser_st_compare_func* */
+ parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
+};
+
+#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
+
+#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
+# define ST2_DATA_COMPATIBLE_P(type) \
+ __builtin_choose_expr(__builtin_types_compatible_p(type, parser_st_data_t), 1, 0)
+#else
+# define ST2_DATA_COMPATIBLE_P(type) 0
+#endif
+
+typedef struct parser_st_table_entry parser_st_table_entry;
+
+struct parser_st_table_entry; /* defined in parser_st.c */
+
+struct parser_st_table {
+ /* Cached features of the table -- see st.c for more details. */
+ unsigned char entry_power, bin_power, size_ind;
+ /* How many times the table was rebuilt. */
+ unsigned int rebuilds_num;
+ const struct parser_st_hash_type *type;
+ /* Number of entries currently in the table. */
+ parser_st_index_t num_entries;
+ /* Start and bound index of entries in array entries.
+ entries_starts and entries_bound are in interval
+ [0,allocated_entries]. */
+ parser_st_index_t entries_start, entries_bound;
+ /* Array of size 2^entry_power.
+ Optionnally followed by an array of bins used for access by keys. */
+ parser_st_table_entry *entries;
+};
+
+#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
+
+enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
+
+size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
+parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *);
+parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, parser_st_index_t);
+parser_st_table *rb_parser_st_init_existing_table_with_size(parser_st_table *, const struct parser_st_hash_type *, parser_st_index_t);
+parser_st_table *rb_parser_st_init_numtable(void);
+parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
+parser_st_table *rb_parser_st_init_strtable(void);
+parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
+parser_st_table *rb_parser_st_init_strcasetable(void);
+parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
+int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
+int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
+int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
+int rb_parser_st_insert(parser_st_table *, parser_st_data_t, parser_st_data_t);
+int rb_parser_st_insert2(parser_st_table *, parser_st_data_t, parser_st_data_t, parser_st_data_t (*)(parser_st_data_t));
+int rb_parser_st_lookup(parser_st_table *, parser_st_data_t, parser_st_data_t *);
+int rb_parser_st_get_key(parser_st_table *, parser_st_data_t, parser_st_data_t *);
+typedef int parser_st_update_callback_func(parser_st_data_t *key, parser_st_data_t *value, parser_st_data_t arg, int existing);
+/* *key may be altered, but must equal to the old key, i.e., the
+ * results of hash() are same and compare() returns 0, otherwise the
+ * behavior is undefined */
+int rb_parser_st_update(parser_st_table *table, parser_st_data_t key, parser_st_update_callback_func *func, parser_st_data_t arg);
+typedef int parser_st_foreach_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t);
+typedef int parser_st_foreach_check_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t, int);
+int rb_parser_st_foreach_with_replace(parser_st_table *tab, parser_st_foreach_check_callback_func *func, parser_st_update_callback_func *replace, parser_st_data_t arg);
+int rb_parser_st_foreach(parser_st_table *, parser_st_foreach_callback_func *, parser_st_data_t);
+int rb_parser_st_foreach_check(parser_st_table *, parser_st_foreach_check_callback_func *, parser_st_data_t, parser_st_data_t);
+parser_st_index_t rb_parser_st_keys(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size);
+parser_st_index_t rb_parser_st_keys_check(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size, parser_st_data_t never);
+parser_st_index_t rb_parser_st_values(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size);
+parser_st_index_t rb_parser_st_values_check(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size, parser_st_data_t never);
+void rb_parser_st_add_direct(parser_st_table *, parser_st_data_t, parser_st_data_t);
+void rb_parser_st_free_table(parser_st_table *);
+void rb_parser_st_cleanup_safe(parser_st_table *, parser_st_data_t);
+void rb_parser_st_clear(parser_st_table *);
+parser_st_table *rb_parser_st_replace(parser_st_table *, parser_st_table *);
+parser_st_table *rb_parser_st_copy(parser_st_table *);
+CONSTFUNC(int rb_parser_st_numcmp(parser_st_data_t, parser_st_data_t));
+CONSTFUNC(parser_st_index_t rb_parser_st_numhash(parser_st_data_t));
+PUREFUNC(int rb_parser_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
+PUREFUNC(int rb_parser_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
+PUREFUNC(size_t rb_parser_st_memsize(const parser_st_table *));
+PUREFUNC(parser_st_index_t rb_parser_st_hash(const void *ptr, size_t len, parser_st_index_t h));
+CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint32(parser_st_index_t h, uint32_t i));
+CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint(parser_st_index_t h, parser_st_index_t i));
+CONSTFUNC(parser_st_index_t rb_parser_st_hash_end(parser_st_index_t h));
+CONSTFUNC(parser_st_index_t rb_parser_st_hash_start(parser_st_index_t h));
+
+RUBY_SYMBOL_EXPORT_END
+
+#if defined(__cplusplus)
+#if 0
+{ /* satisfy cc-mode */
+#endif
+} /* extern "C" { */
+#endif
+
+#endif /* RUBY_ST2_H */
diff --git a/parser_value.h b/parser_value.h
new file mode 100644
index 0000000000..4fe444e82f
--- /dev/null
+++ b/parser_value.h
@@ -0,0 +1,106 @@
+#ifndef EXTERNAL_VALUE_H
+#define EXTERNAL_VALUE_H
+
+#include "ruby/config.h"
+
+#if defined(__DOXYGEN__)
+
+/**
+ * Type that represents a Ruby object. It is an unsigned integer of some kind,
+ * depending on platforms.
+ *
+ * ```CXX
+ * VALUE value = rb_eval_string("ARGF.readlines.map.with_index");
+ * ```
+ *
+ * @warning ::VALUE is not a pointer.
+ * @warning ::VALUE can be wider than `long`.
+ */
+typedef uintptr_t VALUE;
+
+/**
+ * Type that represents a Ruby identifier such as a variable name.
+ *
+ * ```CXX
+ * ID method = rb_intern("method");
+ * VALUE result = rb_funcall(obj, method, 0);
+ * ```
+ *
+ * @note ::rb_cSymbol is a Ruby-level data type for the same thing.
+ */
+typedef uintptr_t ID;
+
+/**
+ * A signed integer type that has the same width with ::VALUE.
+ *
+ * @internal
+ *
+ * @shyouhei wonders: is it guaranteed that `uintptr_t` and `intptr_t` are the
+ * same width? As far as I read ISO/IEC 9899:2018 section 7.20.1.4 paragraph 1
+ * no such description is given... or defined elsewhere?
+ */
+typedef intptr_t SIGNED_VALUE;
+
+/**
+ * Identical to `sizeof(VALUE)`, except it is a macro that can also be used
+ * inside of preprocessor directives such as `#if`. Handy on occasions.
+ */
+#define SIZEOF_VALUE SIZEOF_UINTPTR_T
+
+/**
+ * @private
+ *
+ * A compile-time constant of type ::VALUE whose value is 0.
+ */
+#define RBIMPL_VALUE_NULL UINTPTR_C(0)
+
+/**
+ * @private
+ *
+ * A compile-time constant of type ::VALUE whose value is 1.
+ */
+#define RBIMPL_VALUE_ONE UINTPTR_C(1)
+
+/**
+ * @private
+ *
+ * Maximum possible value that a ::VALUE can take.
+ */
+#define RBIMPL_VALUE_FULL UINTPTR_MAX
+
+#elif defined HAVE_UINTPTR_T && 0
+typedef uintptr_t VALUE;
+typedef uintptr_t ID;
+# define SIGNED_VALUE intptr_t
+# define SIZEOF_VALUE SIZEOF_UINTPTR_T
+# undef PRI_VALUE_PREFIX
+# define RBIMPL_VALUE_NULL UINTPTR_C(0)
+# define RBIMPL_VALUE_ONE UINTPTR_C(1)
+# define RBIMPL_VALUE_FULL UINTPTR_MAX
+
+#elif SIZEOF_LONG == SIZEOF_VOIDP
+typedef unsigned long VALUE;
+typedef unsigned long ID;
+# define SIGNED_VALUE long
+# define SIZEOF_VALUE SIZEOF_LONG
+# define PRI_VALUE_PREFIX "l"
+# define RBIMPL_VALUE_NULL 0UL
+# define RBIMPL_VALUE_ONE 1UL
+# define RBIMPL_VALUE_FULL ULONG_MAX
+
+#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
+# define PRI_VALUE_PREFIX PRI_LL_PREFIX
+# define RBIMPL_VALUE_NULL 0ULL
+# define RBIMPL_VALUE_ONE 1ULL
+# define RBIMPL_VALUE_FULL ULLONG_MAX
+
+#else
+# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
+#endif
+
+#endif /* EXTERNAL_VALUE_H */
diff --git a/pathname.c b/pathname.c
new file mode 100644
index 0000000000..b12f640373
--- /dev/null
+++ b/pathname.c
@@ -0,0 +1,372 @@
+#include "ruby.h"
+#include "internal.h"
+#include "internal/file.h"
+#include "internal/string.h"
+#include "internal/vm.h"
+
+#if defined __CYGWIN__ || defined DOSISH
+# define drive_letter 1
+# define alt_separator 1
+# define isdirsep(x) ((x) == '/' || (x) == '\\')
+#else
+# define drive_letter 0
+# define alt_separator 0
+# define isdirsep(x) ((x) == '/')
+#endif
+
+static VALUE rb_cPathname;
+static ID id_at_path;
+static ID id_sub;
+
+static VALUE
+check_strpath(VALUE path)
+{
+ Check_Type(path, T_STRING);
+ rb_get_path_check_no_convert(path);
+ return path;
+}
+
+static VALUE
+get_strpath(VALUE obj)
+{
+ VALUE strpath;
+ strpath = rb_ivar_get(obj, id_at_path);
+ if (!RB_TYPE_P(strpath, T_STRING))
+ rb_raise(rb_eTypeError, "unexpected @path");
+ rb_get_path_check_no_convert(strpath);
+ return strpath;
+}
+
+/*
+ * call-seq:
+ * self <=> other -> -1, 0, 1, or nil
+ *
+ * Compares the contents of +self+ and +other+ as strings;
+ * see String#<=>.
+ *
+ * Returns:
+ *
+ * - <tt>-1</tt> if +self+'s string is smaller than +other+'s string.
+ * - <tt>0</tt> if the two are equal.
+ * - <tt>1</tt> if +self+'s string is larger than +other+'s string.
+ * - <tt>nil</tt> if +other+ is not a \Pathname.
+ *
+ * Examples:
+ *
+ * Pathname('a') <=> Pathname('b') # => -1
+ * Pathname('a') <=> Pathname('ab') # => -1
+ * Pathname('a') <=> Pathname('a') # => 0
+ * Pathname('b') <=> Pathname('a') # => 1
+ * Pathname('ab') <=> Pathname('a') # => 1
+ * Pathname('ab') <=> 'a' # => nil
+ *
+ * Two pathnames that are different may refer to the same entry in the filesystem:
+ *
+ * Pathname('lib') <=> Pathname('./lib') # => 1
+ *
+ */
+static VALUE
+path_cmp(VALUE self, VALUE other)
+{
+ VALUE s1, s2;
+ char *p1, *p2;
+ char *e1, *e2;
+ if (!rb_obj_is_kind_of(other, rb_cPathname))
+ return Qnil;
+ s1 = get_strpath(self);
+ s2 = get_strpath(other);
+ p1 = RSTRING_PTR(s1);
+ p2 = RSTRING_PTR(s2);
+ e1 = p1 + RSTRING_LEN(s1);
+ e2 = p2 + RSTRING_LEN(s2);
+ while (p1 < e1 && p2 < e2) {
+ int c1, c2;
+ c1 = (unsigned char)*p1++;
+ c2 = (unsigned char)*p2++;
+ if (c1 == '/') c1 = '\0';
+ if (c2 == '/') c2 = '\0';
+ if (c1 != c2) {
+ if (c1 < c2)
+ return INT2FIX(-1);
+ else
+ return INT2FIX(1);
+ }
+ }
+ if (p1 < e1)
+ return INT2FIX(1);
+ if (p2 < e2)
+ return INT2FIX(-1);
+ return INT2FIX(0);
+}
+
+/*
+ * Return a pathname which is substituted by String#sub.
+ *
+ * path1 = Pathname.new('/usr/bin/perl')
+ * path1.sub('perl', 'ruby')
+ * #=> #<Pathname:/usr/bin/ruby>
+ */
+static VALUE
+path_sub(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+
+ if (rb_block_given_p()) {
+ str = rb_block_call(str, id_sub, argc, argv, 0, 0);
+ }
+ else {
+ str = rb_funcallv(str, id_sub, argc, argv);
+ }
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/* :nodoc: */
+static VALUE
+same_paths(VALUE self, VALUE a, VALUE b)
+{
+ check_strpath(a);
+ check_strpath(b);
+ if (CASEFOLD_FILESYSTEM)
+ return RBOOL(rb_str_casecmp(a, b) == INT2FIX(0));
+ else
+ return rb_str_equal(a, b);
+}
+
+/*
+ * Predicate method for root directories. Returns +true+ if the
+ * pathname consists of consecutive slashes.
+ *
+ * It doesn't access the filesystem. So it may return +false+ for some
+ * pathnames which points to roots such as <tt>/usr/..</tt>.
+ */
+static VALUE
+path_root_p(VALUE self)
+{
+ VALUE path = get_strpath(self);
+ if (RSTRING_LEN(path) == 0) return Qfalse;
+ const char *ptr = RSTRING_PTR(path), *end = RSTRING_END(path);
+ rb_encoding *enc = rb_enc_get(path);
+ const char *base = rb_enc_path_skip_prefix_root(ptr, end, enc);
+ return RBOOL(base == end);
+}
+
+/*
+ * call-seq:
+ * absolute? -> true or false
+ *
+ * Returns whether +self+ contains an absolute path:
+ *
+ * Pathname('/home').absolute? # => true
+ * Pathname('lib').absolute? # => false
+ *
+ * The result is OS-dependent for some paths:
+ *
+ * Pathname('C:/').absolute? # => true # On Windows.
+ * Pathname('C:/').absolute? # => false # Elsewhere.
+ *
+ */
+static VALUE
+path_absolute_p(VALUE self)
+{
+ VALUE path = get_strpath(self);
+ const char *ptr = RSTRING_PTR(path);
+ long len = RSTRING_LEN(path);
+ if (len < 1) return Qfalse;
+ if (drive_letter) {
+ if (len >= 2 && ISALPHA(ptr[0]) && (ptr[1] == ':')) return Qtrue;
+ }
+ return RBOOL(isdirsep(ptr[0]));
+}
+
+/* :nodoc: */
+static VALUE
+has_separator_p(VALUE self, VALUE path)
+{
+ const char *ptr = RSTRING_PTR(check_strpath(path));
+ const char *end = RSTRING_END(path);
+ if (alt_separator) {
+ rb_encoding *enc = rb_enc_get(path);
+ bool mb = !rb_str_enc_fastpath(path);
+ while (ptr < end) {
+ if (isdirsep(*ptr)) return Qtrue;
+ ptr += (mb ? rb_enc_mbclen(ptr, end, enc) : 1);
+ }
+ }
+ else {
+ /* assume '/' will never be trailing bytes */
+ if (memchr(ptr, '/', end - ptr)) return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * Return a pathname with +repl+ added as a suffix to the basename.
+ *
+ * If self has no extension part, +repl+ is appended.
+ *
+ * Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
+ * #=> #<Pathname:/usr/bin/shutdown.rb>
+ */
+static VALUE
+path_sub_ext(VALUE self, VALUE repl)
+{
+ VALUE path = get_strpath(self);
+ long len = RSTRING_LEN(path);
+ const char *ptr = RSTRING_PTR(path);
+ const char *ext = ruby_enc_find_extname(ptr, &len, rb_enc_get(path));
+ if (len > 0) {
+ RUBY_ASSERT(ext, "should point the last dot");
+ path = rb_str_subseq(path, 0, ext - ptr);
+ }
+ else {
+ /* no dot or dotted file */
+ path = rb_str_dup(path);
+ }
+ path = rb_str_append(path, repl);
+ return rb_class_new_instance(1, &path, rb_obj_class(self));
+}
+
+/* :nodoc: */
+/* chop_basename(path) -> [pre-basename, basename] or nil */
+static VALUE
+chop_basename(VALUE self, VALUE path)
+{
+ long baselen, alllen = RSTRING_LEN(check_strpath(path));
+ if (alllen <= 0) return Qnil;
+ rb_encoding *enc = rb_enc_get(path);
+ const char *name = RSTRING_PTR(path);
+ const char *base = ruby_enc_find_basename(name, &baselen, &alllen, enc);
+ if (baselen < 1) return Qnil;
+ if (baselen == 1 && isdirsep(*base)) return Qnil;
+ RUBY_ASSERT(base >= name);
+ RUBY_ASSERT(base <= RSTRING_END(path));
+ VALUE dir = rb_str_subseq(path, 0, base - name);
+ VALUE basename = rb_enc_str_new(base, alllen, enc);
+ RB_GC_GUARD(path);
+ return rb_assoc_new(dir, basename);
+}
+
+/* :nodoc: */
+/* split_names(path) -> prefix, [name, ...] */
+static VALUE
+split_names(VALUE self, VALUE path)
+{
+ rb_encoding *enc = rb_enc_get(check_strpath(path));
+ const char *beg = RSTRING_PTR(path), *ptr = beg;
+ const char *end = RSTRING_END(path);
+ const char *root = rb_enc_path_skip_prefix_root(ptr, end, enc);
+ VALUE pre = rb_str_subseq(path, 0, root - ptr);
+ VALUE names = rb_ary_new();
+ while (ptr < end) {
+ const char *next = rb_enc_path_next(ptr, end, enc);
+ if (next > ptr) rb_ary_push(names, rb_str_subseq(path, ptr - beg, next - ptr));
+ ptr = next;
+ while (ptr < end && isdirsep(*ptr)) ++ptr;
+ }
+ return rb_assoc_new(pre, names);
+}
+
+/* :nodoc: */
+/* has_trailing_separator?(path) -> bool */
+static VALUE
+has_trailing_separator(VALUE self, VALUE path)
+{
+ long baselen, alllen = RSTRING_LEN(check_strpath(path));
+ if (alllen <= 0) return Qfalse;
+ rb_encoding *enc = rb_enc_get(path);
+ const char *name = RSTRING_PTR(path);
+ const char *base = ruby_enc_find_basename(name, &baselen, &alllen, enc);
+ if (baselen < 1) return Qfalse;
+ if (baselen == 1 && isdirsep(*base)) return Qfalse;
+ return RBOOL(base + alllen < RSTRING_END(path));
+}
+
+/* :nodoc: */
+/* add_trailing_separator(path) -> path */
+static VALUE
+add_trailing_separator(VALUE self, VALUE path)
+{
+ if (RSTRING_LEN(check_strpath(path)) <= 0) return path;
+ rb_encoding *enc = rb_enc_get(path);
+ const char *name = RSTRING_PTR(path);
+ const char *end = RSTRING_END(path);
+ const char *top = rb_enc_path_skip_prefix(name, end, enc);
+ if (top < end && isdirsep(end[-1])) {
+ if (end[-1] == '/' || rb_enc_prev_char(top, end, end, enc) == end - 1)
+ return path;
+ }
+ return rb_str_cat_cstr(rb_str_dup(path), "/");
+}
+
+/* :nodoc: */
+static VALUE
+del_trailing_separator(VALUE self, VALUE path)
+{
+ long len = RSTRING_LEN(check_strpath(path));
+ if (len <= 0) return path;
+ rb_encoding *enc = rb_enc_get(path);
+ const char *name = RSTRING_PTR(path);
+ const char *end = name + len, *tail = end;
+ const char *top = rb_enc_path_skip_prefix(name, end, enc);
+ if (tail > top && isdirsep(tail[-1])) {
+ while (--tail > top && isdirsep(tail[-1]));
+ if (tail > top &&
+ tail[0] != '/' &&
+ !rb_str_enc_fastpath(path) &&
+ rb_enc_left_char_head(top, tail, end, enc) != tail) {
+ /* trailing byte, not a directory separator */
+ ++tail;
+ }
+ if (tail < end) {
+ if (tail == name || (drive_letter && tail == top && top[-1] == ':')) {
+ ++tail;
+ }
+ }
+ }
+ if (tail == end) return path;
+ return rb_str_subseq(path, 0, tail - name);
+}
+
+#include "pathname_builtin.rbinc"
+
+static void init_ids(void);
+
+void
+Init_pathname(void)
+{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
+ init_ids();
+ InitVM(pathname);
+}
+
+void
+InitVM_pathname(void)
+{
+ rb_cPathname = rb_define_class("Pathname", rb_cObject);
+ rb_define_method(rb_cPathname, "<=>", path_cmp, 1);
+ rb_define_method(rb_cPathname, "sub", path_sub, -1);
+ rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1);
+ rb_define_method(rb_cPathname, "root?", path_root_p, 0);
+ rb_define_method(rb_cPathname, "absolute?", path_absolute_p, 0);
+
+ rb_define_private_method(rb_cPathname, "same_paths?", same_paths, 2);
+ rb_define_private_method(rb_cPathname, "has_separator?", has_separator_p, 1);
+ rb_define_private_method(rb_cPathname, "chop_basename", chop_basename, 1);
+ rb_define_private_method(rb_cPathname, "split_names", split_names, 1);
+ rb_define_private_method(rb_cPathname, "has_trailing_separator?", has_trailing_separator, 1);
+ rb_define_private_method(rb_cPathname, "add_trailing_separator", add_trailing_separator, 1);
+ rb_define_private_method(rb_cPathname, "del_trailing_separator", del_trailing_separator, 1);
+
+ rb_provide("pathname.so");
+}
+
+void
+init_ids(void)
+{
+#undef rb_intern
+ id_at_path = rb_intern("@path");
+ id_sub = rb_intern("sub");
+}
diff --git a/pathname_builtin.rb b/pathname_builtin.rb
new file mode 100644
index 0000000000..11ade220f0
--- /dev/null
+++ b/pathname_builtin.rb
@@ -0,0 +1,1895 @@
+# frozen_string_literal: true
+#
+# A \Pathname object contains a string directory path or filepath;
+# it does not represent a corresponding actual file or directory
+# -- which in fact may or may not exist.
+#
+# A \Pathname object is immutable (except for method #freeze).
+#
+# A pathname may be relative or absolute:
+#
+# Pathname.new('lib') # => #<Pathname:lib>
+# Pathname.new('/usr/local/bin') # => #<Pathname:/usr/local/bin>
+#
+# == About the Examples
+#
+# Many examples here use these variables:
+#
+# :include: doc/examples/files.rdoc
+#
+# == Convenience Methods
+#
+# The class provides *all* functionality from class File and module FileTest,
+# along with some functionality from class Dir and module FileUtils.
+#
+# Here's an example string path and corresponding \Pathname object:
+#
+# path = 'lib/fileutils.rb'
+# pn = Pathname.new(path) # => #<Pathname:lib/fileutils.rb>
+#
+# Each of these method pairs (\Pathname vs. \File) gives exactly the same result:
+#
+# pn.size # => 83777
+# File.size(path) # => 83777
+#
+# pn.directory? # => false
+# File.directory?(path) # => false
+#
+# pn.read.size # => 81074
+# File.read(path).size# # => 81074
+#
+# Each of these method pairs gives similar results,
+# but each \Pathname method returns a more versatile \Pathname object,
+# instead of a string:
+#
+# pn.dirname # => #<Pathname:lib>
+# File.dirname(path) # => "lib"
+#
+# pn.basename # => #<Pathname:fileutils.rb>
+# File.basename(path) # => "fileutils.rb"
+#
+# pn.split # => [#<Pathname:lib>, #<Pathname:fileutils.rb>]
+# File.split(path) # => ["lib", "fileutils.rb"]
+#
+# Each of these methods takes a block:
+#
+# pn.open do |file|
+# p file
+# end
+# File.open(path) do |file|
+# p file
+# end
+#
+# The outputs for each:
+#
+# #<File:lib/fileutils.rb (closed)>
+# #<File:lib/fileutils.rb (closed)>
+#
+# Each of these methods takes a block:
+#
+# pn.each_line do |line|
+# p line
+# break
+# end
+# File.foreach(path) do |line|
+# p line
+# break
+# end
+#
+# The outputs for each:
+#
+# "# frozen_string_literal: true\n"
+# "# frozen_string_literal: true\n"
+#
+# == More Methods
+#
+# Here is a sampling of other available methods:
+#
+# p1 = Pathname.new('/usr/lib') # => #<Pathname:/usr/lib>
+# p1.absolute? # => true
+# p2 = p1 + 'ruby/4.0' # => #<Pathname:/usr/lib/ruby/4.0>
+# p3 = p1.parent # => #<Pathname:/usr>
+# p4 = p2.relative_path_from(p3) # => #<Pathname:lib/ruby/4.0>
+# p4.absolute? # => false
+# p5 = Pathname.new('.') # => #<Pathname:.>
+# p6 = p5 + 'usr/../var' # => #<Pathname:usr/../var>
+# p6.cleanpath # => #<Pathname:var>
+# p6.realpath # => #<Pathname:/var>
+# p6.children.take(2)
+# # => [#<Pathname:usr/../var/local>, #<Pathname:usr/../var/spool>]
+#
+# == Breakdown of functionality
+#
+# === Core methods
+#
+# These methods are effectively manipulating a String, because that's
+# all a path is. None of these access the file system except for
+# #mountpoint?, #children, #each_child, #realdirpath and #realpath.
+#
+# - +
+# - #join
+# - #parent
+# - #root?
+# - #absolute?
+# - #relative?
+# - #relative_path_from
+# - #each_filename
+# - #cleanpath
+# - #realpath
+# - #realdirpath
+# - #children
+# - #each_child
+# - #mountpoint?
+#
+# === File status predicate methods
+#
+# These methods are a facade for FileTest:
+# - #blockdev?
+# - #chardev?
+# - #directory?
+# - #executable?
+# - #executable_real?
+# - #exist?
+# - #file?
+# - #grpowned?
+# - #owned?
+# - #pipe?
+# - #readable?
+# - #world_readable?
+# - #readable_real?
+# - #setgid?
+# - #setuid?
+# - #size
+# - #size?
+# - #socket?
+# - #sticky?
+# - #symlink?
+# - #writable?
+# - #world_writable?
+# - #writable_real?
+# - #zero?
+#
+# === File property and manipulation methods
+#
+# These methods are a facade for File:
+# - #each_line(*args, &block)
+# - #read(*args)
+# - #binread(*args)
+# - #readlines(*args)
+# - #sysopen(*args)
+# - #write(*args)
+# - #binwrite(*args)
+# - #atime
+# - #birthtime
+# - #ctime
+# - #mtime
+# - #chmod(mode)
+# - #lchmod(mode)
+# - #chown(owner, group)
+# - #lchown(owner, group)
+# - #fnmatch(pattern, *args)
+# - #fnmatch?(pattern, *args)
+# - #ftype
+# - #make_link(old)
+# - #open(*args, &block)
+# - #readlink
+# - #rename(to)
+# - #stat
+# - #lstat
+# - #make_symlink(old)
+# - #truncate(length)
+# - #utime(atime, mtime)
+# - #lutime(atime, mtime)
+# - #basename(*args)
+# - #dirname
+# - #extname
+# - #expand_path(*args)
+# - #split
+#
+# === Directory methods
+#
+# These methods are a facade for Dir:
+# - Pathname.glob(*args)
+# - Pathname.getwd / Pathname.pwd
+# - #rmdir
+# - #entries
+# - #each_entry(&block)
+# - #mkdir(*args)
+# - #opendir(*args)
+#
+# === Utilities
+#
+# These methods are a mixture of Find, FileUtils, and others:
+# - #find(&block)
+# - #mkpath
+# - #rmtree
+# - #unlink / #delete
+#
+#
+# == Method documentation
+#
+# As the above section shows, most of the methods in Pathname are facades. The
+# documentation for these methods generally just says, for instance, "See
+# FileTest.writable?", as you should be familiar with the original method
+# anyway, and its documentation (e.g. through +ri+) will contain more
+# information. In some cases, a brief description will follow.
+#
+class Pathname
+
+ # The version string.
+ VERSION = "0.4.0"
+
+ # :stopdoc:
+
+ attr_reader :path
+ protected :path
+
+ # :startdoc:
+
+ # call-seq:
+ # Pathname.new(path) -> new_pathname
+ #
+ # Returns a new \Pathname object based on the given +path+,
+ # via <tt>File.path(path).dup</tt>.
+ # the +path+ may be a String, a File, a Dir, or another \Pathname;
+ # see File.path:
+ #
+ # Pathname.new('.') # => #<Pathname:.>
+ # Pathname.new('/usr/bin') # => #<Pathname:/usr/bin>
+ # Pathname.new(File.new('LEGAL')) # => #<Pathname:LEGAL>
+ # Pathname.new(Dir.new('.')) # => #<Pathname:.>
+ # Pathname.new(Pathname.new('.')) # => #<Pathname:.>
+ #
+ def initialize(path)
+ @path = File.path(path).dup
+ rescue TypeError => e
+ raise e.class, "Pathname.new requires a String, #to_path or #to_str", cause: nil
+ end
+
+ #
+ # Freze self.
+ #
+ def freeze
+ super
+ @path.freeze
+ self
+ end
+
+ # call-seq:
+ # self == other -> true or false
+ #
+ # Returns whether the stored paths in +self+ and +other+ are equal:
+ #
+ # pn = Pathname('lib')
+ # pn == Pathname('lib') # => true
+ # pn == Pathname('./lib') # => false
+ #
+ # Returns +false+ if +other+ is not a pathname:
+ #
+ # pn == 'lib' # => false
+ #
+ def ==(other)
+ return false unless Pathname === other
+ other.path == @path
+ end
+ alias === ==
+ alias eql? ==
+
+ def hash # :nodoc:
+ @path.hash
+ end
+
+ # Return the path as a String.
+ def to_s
+ @path.dup
+ end
+
+ # to_path is implemented so Pathname objects are usable with File.open, etc.
+ alias to_path to_s
+
+ def inspect # :nodoc:
+ "#<#{self.class}:#{@path}>"
+ end
+
+ # Creates a full path, including any intermediate directories that don't yet
+ # exist.
+ #
+ # See FileUtils.mkpath and FileUtils.mkdir_p
+ def mkpath(mode: nil)
+ path = @path == '/' ? @path : @path.chomp('/')
+
+ stack = []
+ until File.directory?(path) || (parent = File.dirname(path)) == path
+ stack.push path
+ path = parent
+ end
+
+ stack.reverse_each do |dir|
+ dir = dir == '/' ? dir : dir.chomp('/')
+ if mode
+ Dir.mkdir dir, mode
+ File.chmod mode, dir
+ else
+ Dir.mkdir dir
+ end
+ rescue SystemCallError
+ raise unless File.directory?(dir)
+ end
+
+ self
+ end
+
+ def prepend_prefix(prefix, relpath) # :nodoc:
+ if relpath.empty?
+ File.dirname(prefix)
+ elsif has_separator?(prefix)
+ add_trailing_separator(File.dirname(prefix)) + relpath
+ else
+ prefix + relpath
+ end
+ end
+ private :prepend_prefix
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # cleanpath(symlinks = false) -> new_pathname
+ #
+ # Returns a new \Pathname object, "cleaned" of unnecessary separators,
+ # single-dot entries, and double-dot entries.
+ #
+ # When `self` is empty, returns a pathname with a single-dot entry:
+ #
+ # ```
+ # Pathname('').cleanpath # => #<Pathname:.>
+ # ```
+ #
+ # <b>Separators</b>
+ #
+ # A lone separator is preserved:
+ #
+ # ```
+ # Pathname('/').cleanpath # => #<Pathname:/>
+ # ```
+ #
+ # Multiple trailing separators are removed:
+ #
+ # ```
+ # Pathname('foo/////').cleanpath # => #<Pathname:foo>
+ # Pathname('foo/').cleanpath # => #<Pathname:foo>
+ # ```
+ #
+ # Multiple embedded separators are reduced to a single separator:
+ #
+ # ```
+ # Pathname('foo///bar').cleanpath # => #<Pathname:foo/bar>
+ # ```
+ #
+ # Multiple leading separators are reduced:
+ #
+ # ```
+ # # On Windows, where File.dirname('//') == '//'.
+ # Pathname('/////foo').cleanpath # => #<Pathname://foo>
+ # Pathname('/////').cleanpath # => #<Pathname://>
+ # # Otherwise, where File.dirname('//') == '/'.
+ # Pathname('/////foo').cleanpath # => #<Pathname:/foo>
+ # Pathname('/////').cleanpath # => #<Pathname:/>
+ # ```
+ #
+ # <b>Single-Dot Entries</b>
+ #
+ # A lone single-dot entry is preserved:
+ #
+ # ```
+ # Pathname('.').cleanpath # => #<Pathname:.>
+ # ```
+ #
+ # A non-lone single-dot entry, regardless of its location, is removed:
+ #
+ # ```
+ # Pathname('foo/././././bar').cleanpath # => #<Pathname:foo/bar>
+ # Pathname('./foo/./././bar').cleanpath # => #<Pathname:foo/bar>
+ # Pathname('foo/./././bar/./').cleanpath # => #<Pathname:foo/bar>
+ # ```
+ #
+ # <b>Double-Dot Entries</b>
+ #
+ # A lone double-dot entry is preserved:
+ #
+ # ```
+ # Pathname('..').cleanpath # => #<Pathname:..>
+ # ```
+ #
+ # When a non-lone double-dot entry is preceded by a named entry, both are removed:
+ #
+ # ```
+ # Pathname('foo/..').cleanpath # => #<Pathname:.>
+ # Pathname('foo/../bar').cleanpath # => #<Pathname:bar>
+ # Pathname('foo/../bar/..').cleanpath # => #<Pathname:.>
+ # Pathname('foo/bar/./../..').cleanpath # => #<Pathname:.>
+ # ```
+ #
+ # When a non-lone double-dot entry is _not_ preceded by a named entry,
+ # it is preserved:
+ #
+ # ```
+ # Pathname('../..').cleanpath # => #<Pathname:../..>
+ # ```
+ #
+ # A non-lone meaningless double-dot entry is removed:
+ #
+ # ```
+ # Pathname('/..').cleanpath # => #<Pathname:/>
+ # Pathname('/../..').cleanpath # => #<Pathname:/>
+ # ```
+ #
+ # <b> Symbolic Links</b>
+ #
+ # If the path may contain [symbolic links][symbolic link],
+ # consider give optional argument `symlinks` as `true`;
+ # the method then uses a more conservative algorithm
+ # that avoids breaking symbolic links.
+ # This may preserve more double-dot entries than are absolutely necessary,
+ # but without accessing the filesystem, this can't be avoided.
+ #
+ # Examples:
+ #
+ # ```
+ # Pathname('a/').cleanpath # => #<Pathname:a>
+ # Pathname('a/').cleanpath(true) # => #<Pathname:a/>
+ #
+ # Pathname('a/.').cleanpath # => #<Pathname:a>
+ # Pathname('a/.').cleanpath(true) # => #<Pathname:a/.>
+ #
+ # Pathname('a/./').cleanpath # => #<Pathname:a>
+ # Pathname('a/./').cleanpath(true) # => #<Pathname:a/.>
+ #
+ # Pathname('a/b/.').cleanpath # => #<Pathname:a/b>
+ # Pathname('a/b/.').cleanpath(true) # => #<Pathname:a/b/.>
+ #
+ # Pathname('a/../.').cleanpath # => #<Pathname:.>
+ # Pathname('a/../.').cleanpath(true) # => #<Pathname:a/..>
+ #
+ # Pathname('a/b/../../../../c/../d').cleanpath
+ # # => #<Pathname:../../d>
+ # Pathname('a/b/../../../../c/../d').cleanpath(true)
+ # # => #<Pathname:a/b/../../../../c/../d>
+ # ```
+ #
+ # [symbolic link]: https://en.wikipedia.org/wiki/Symbolic_link
+ #
+ def cleanpath(consider_symlink=false)
+ if consider_symlink
+ cleanpath_conservative
+ else
+ cleanpath_aggressive
+ end
+ end
+
+ #
+ # Clean the path simply by resolving and removing excess +.+ and +..+ entries.
+ # Nothing more, nothing less.
+ #
+ def cleanpath_aggressive # :nodoc:
+ path = @path
+ names = []
+ pre = path
+ while r = chop_basename(pre)
+ pre, base = r
+ case base
+ when '.'
+ when '..'
+ names.unshift base
+ else
+ if names[0] == '..'
+ names.shift
+ else
+ names.unshift base
+ end
+ end
+ end
+ pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ if has_separator?(File.basename(pre))
+ names.shift while names[0] == '..'
+ end
+ self.class.new(prepend_prefix(pre, File.join(*names)))
+ end
+ private :cleanpath_aggressive
+
+ def cleanpath_conservative # :nodoc:
+ path = @path
+ names = []
+ pre = path
+ while r = chop_basename(pre)
+ pre, base = r
+ names.unshift base if base != '.'
+ end
+ pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ if has_separator?(File.basename(pre))
+ names.shift while names[0] == '..'
+ end
+ if names.empty?
+ self.class.new(File.dirname(pre))
+ else
+ if names.last != '..' && File.basename(path) == '.'
+ names << '.'
+ end
+ result = prepend_prefix(pre, File.join(*names))
+ if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
+ self.class.new(add_trailing_separator(result))
+ else
+ self.class.new(result)
+ end
+ end
+ end
+ private :cleanpath_conservative
+
+ # Returns the parent directory.
+ #
+ # This is same as <code>self + '..'</code>.
+ def parent
+ self + '..'
+ end
+
+ # Returns +true+ if +self+ points to a mountpoint.
+ def mountpoint?
+ begin
+ stat1 = self.lstat
+ stat2 = self.parent.lstat
+ stat1.dev != stat2.dev || stat1.ino == stat2.ino
+ rescue Errno::ENOENT
+ false
+ end
+ end
+
+ # The opposite of Pathname#absolute?
+ #
+ # It returns +false+ if the pathname begins with a slash.
+ #
+ # p = Pathname.new('/im/sure')
+ # p.relative?
+ # #=> false
+ #
+ # p = Pathname.new('not/so/sure')
+ # p.relative?
+ # #=> true
+ def relative?
+ !absolute?
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # each_filename {|component| ... } -> nil
+ # each_filename -> new_enumerator
+ #
+ # With a block given, yields each component of the string path:
+ #
+ # ```ruby
+ # Pathname('/foo/bar/baz').each_filename {|filename| p filename }
+ # => nil
+ # ```
+ #
+ # Output:
+ #
+ # ```text
+ # "foo"
+ # "bar"
+ # "baz"
+ # ```
+ #
+ # With no block given, returns a new Enumerator.
+ def each_filename # :yield: filename
+ return to_enum(__method__) unless block_given?
+ _, names = split_names(@path)
+ names.each {|filename| yield filename }
+ nil
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # descend {|entry| ... } -> nil
+ # descend -> new_enumerator
+ #
+ # With a block given, yields a new pathname for each successive dirname
+ # in the stored path; see File.dirname:
+ #
+ # ```ruby
+ # # Absolute path.
+ # Pathname('/path/to/some/file.rb').descend {|pn| p pn }
+ # # #<Pathname:/>
+ # # #<Pathname:/path>
+ # # #<Pathname:/path/to>
+ # # #<Pathname:/path/to/some>
+ # # #<Pathname:/path/to/some/file.rb>
+ # # Relative path.
+ # Pathname('path/to/some/file.rb').descend {|pn| p pn }
+ # # #<Pathname:path>
+ # # #<Pathname:path/to>
+ # # #<Pathname:path/to/some>
+ # # #<Pathname:path/to/some/file.rb>
+ # ```
+ #
+ # With no block given, returns a new Enumerator.
+ def descend
+ return to_enum(__method__) unless block_given?
+ vs = []
+ ascend {|v| vs << v }
+ vs.reverse_each {|v| yield v }
+ nil
+ end
+
+ # call-seq:
+ # ascend {|entry| ... } -> nil
+ # ascend -> new_enumerator
+ #
+ # With a block given,
+ # yields +self+, then a new pathname for each successive dirname in the stored path;
+ # see File.dirname:
+ #
+ # Pathname('/path/to/some/file.rb').ascend {|dirname| p dirname}
+ # #<Pathname:/path/to/some/file.rb>
+ # #<Pathname:/path/to/some>
+ # #<Pathname:/path/to>
+ # #<Pathname:/path>
+ # #<Pathname:/>
+ #
+ # With no block given, returns a new Enumerator.
+ def ascend
+ return to_enum(__method__) unless block_given?
+ path = @path
+ yield self
+ while r = chop_basename(path)
+ path, = r
+ break if path.empty?
+ yield self.class.new(del_trailing_separator(path))
+ end
+ end
+
+ # call-seq:
+ # self + other -> new_pathname
+ #
+ # Returns a new \Pathname object based on the content of +self+ and +other+;
+ # argument +other+ may be a String, a File, a Dir, or another \Pathname:
+ #
+ # pn = Pathname('foo') # => #<Pathname:foo>
+ # pn + 'bar' # => #<Pathname:foo/bar>
+ # pn + File.new('LEGAL') # => #<Pathname:foo/LEGAL>
+ # pn + Dir.new('lib') # => #<Pathname:foo/lib>
+ # pn + Pathname('bar') # => #<Pathname:foo/bar>
+ #
+ # When +other+ specifies a relative path (see #relative?),
+ # it is combined with +self+ to form a new pathname:
+ #
+ # Pathname('/a/b') + 'c' # => #<Pathname:/a/b/c>
+ #
+ # Extra component separators (<tt>'/'</tt>) are removed:
+ #
+ # Pathname('/a/b/') + 'c' # => #<Pathname:/a/b/c>
+ #
+ # Extra current-directory components (<tt>'.'</tt>) are removed:
+ #
+ # Pathname('a') + '.' # => #<Pathname:a>
+ # Pathname('.') + 'a' # => #<Pathname:a>
+ # Pathname('.') + '.' # => #<Pathname:.>
+ #
+ # Parent-directory components (<tt>'..'</tt>) are:
+ #
+ # - Resolved, when possible:
+ #
+ # Pathname('a') + '..' # => #<Pathname:.>
+ # Pathname('a/b') + '..' # => #<Pathname:a>
+ # Pathname('/') + '../a' # => #<Pathname:/a>
+ # Pathname('a') + '../b' # => #<Pathname:b>
+ # Pathname('a/b') + '../c' # => #<Pathname:a/c>
+ # Pathname('a//b/c') + '../d//e' # => #<Pathname:a//b/d//e>
+ #
+ # - Removed, when not needed:
+ #
+ # Pathname('/') + '..' # => #<Pathname:/>
+ #
+ # - Retained, when needed:
+ #
+ # Pathname('..') + '..' # => #<Pathname:../..>
+ # Pathname('..') + '../a' # => #<Pathname:../../a>
+ #
+ # When +other+ specifies an absolute path (see #absolute?),
+ # equivalent to <tt>Pathname(other.to_s)</tt>:
+ #
+ # Pathname('/a') + '/b/c' # => #<Pathname:/b/c>
+ #
+ # Occurrences of <tt>'/'</tt>, <tt>'.'</tt>, and <tt>'..'</tt> are preserved:
+ #
+ # Pathname('/a') + '//b//c/./../d' # => #<Pathname://b//c/./../d>
+ #
+ # This method does not access the file system, so +other+ need not represent
+ # an existing (or even a valid) file or directory path:
+ #
+ # Pathname('/var') + 'nosuch:ever' # => #<Pathname:/var/nosuch:ever>
+ #
+ def +(other)
+ other = Pathname.new(other) unless Pathname === other
+ Pathname.new(plus(@path, other.path))
+ end
+ alias / +
+
+ # (path1, path2) -> path
+ def plus(path1, path2) # :nodoc:
+ prefix2 = path2
+ index_list2 = []
+ basename_list2 = []
+ while r2 = chop_basename(prefix2)
+ prefix2, basename2 = r2
+ index_list2.unshift prefix2.length
+ basename_list2.unshift basename2
+ end
+ return path2 if prefix2 != ''
+ prefix1 = path1
+ while true
+ while !basename_list2.empty? && basename_list2.first == '.'
+ index_list2.shift
+ basename_list2.shift
+ end
+ break unless r1 = chop_basename(prefix1)
+ prefix1, basename1 = r1
+ next if basename1 == '.'
+ if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
+ prefix1 = prefix1 + basename1
+ break
+ end
+ index_list2.shift
+ basename_list2.shift
+ end
+ r1 = chop_basename(prefix1)
+ if !r1 && (r1 = has_separator?(File.basename(prefix1)))
+ while !basename_list2.empty? && basename_list2.first == '..'
+ index_list2.shift
+ basename_list2.shift
+ end
+ end
+ if !basename_list2.empty?
+ suffix2 = path2[index_list2.first..-1]
+ r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
+ else
+ r1 ? prefix1 : File.dirname(prefix1)
+ end
+ end
+ private :plus
+
+ #
+ # Joins the given pathnames onto +self+ to create a new Pathname object.
+ # This is effectively the same as using Pathname#+ to append +self+ and
+ # all arguments sequentially.
+ #
+ # path0 = Pathname.new("/usr") # Pathname:/usr
+ # path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
+ # # is the same as
+ # path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
+ # path0 == path1
+ # #=> true
+ #
+ def join(*args)
+ return self if args.empty?
+ result = args.pop
+ result = Pathname.new(result) unless Pathname === result
+ return result if result.absolute?
+ args.reverse_each {|arg|
+ arg = Pathname.new(arg) unless Pathname === arg
+ result = arg + result
+ return result if result.absolute?
+ }
+ self + result
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # children(with_dirnames = true) -> array_of_pathnames
+ #
+ # Returns an array of pathnames;
+ # each represents a child of the entry represented by `self`,
+ # which must be an existing directory in the underlying file system.
+ #
+ # With `with_dirnames` given as `true` (the default),
+ # each pathname contains the full entry:
+ #
+ # ```ruby
+ # Pathname('lib').children.size # => 72
+ # Pathname('lib').children.take(3)
+ # # => [#<Pathname:lib/bundled_gems.rb>, #<Pathname:lib/bundler>, #<Pathname:lib/bundler.rb>]
+ # ```
+ # With `with_dirnames` given as `false`,
+ # each pathname contains only the basename of the entry:
+ #
+ # ```ruby
+ # Pathname('lib').children(false).take(3)
+ # # => [#<Pathname:bundled_gems.rb>, #<Pathname:bundler>, #<Pathname:bundler.rb>]
+ # ```
+ #
+ # Note that entries `.` and `..` in directory are not actually children,
+ # and so are never included in the result.
+ def children(with_directory=true)
+ with_directory = false if @path == '.'
+ result = Dir.children(@path)
+ if with_directory
+ result.map! {|e| self.class.new(File.join(@path, e))}
+ else
+ result.map! {|e| self.class.new(e)}
+ end
+ result
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # each_child(with_dirnames = true) {|entry| ... } -> array_of_pathnames
+ # each_child(with_dirnames = true) -> new_enumerator
+ #
+ # With a block given and `with_dirnames` given as `true` (the default),
+ # yields a new pathname for each child
+ # of the entry represented by `self`;
+ # returns an array of those pathnames:
+ #
+ # ```ruby
+ # Pathname('include').each_child {|child| p child }
+ # # #<Pathname:include/ruby>
+ # # #<Pathname:include/ruby.h>
+ # # => [#<Pathname:include/ruby>, #<Pathname:include/ruby.h>]
+ # ```
+ #
+ # With a block given and `with_dirnames` given as `false`,
+ # yields a new pathname for each child
+ # of the entry represented by `self` with its dirname omitted;
+ # returns an array of those pathnames:
+ #
+ # ```ruby
+ # Pathname('include').each_child(false) {|child| p child }
+ # # #<Pathname:ruby>
+ # # #<Pathname:ruby.h>
+ # # => [#<Pathname:ruby>, #<Pathname:ruby.h>]
+ # ```
+ #
+ # Note that entries `'.'` and `'..'` are not children.
+ #
+ # With no block given, returns a new Enumerator.
+ def each_child(with_directory=true, &b)
+ children(with_directory).each(&b)
+ end
+
+ #
+ # Returns a relative path from the given +base_directory+ to the receiver.
+ #
+ # If +self+ is absolute, then +base_directory+ must be absolute too.
+ #
+ # If +self+ is relative, then +base_directory+ must be relative too.
+ #
+ # This method doesn't access the filesystem. It assumes no symlinks.
+ #
+ # ArgumentError is raised when it cannot find a relative path.
+ #
+ # Note that this method does not handle situations where the case sensitivity
+ # of the filesystem in use differs from the operating system default.
+ #
+ def relative_path_from(base_directory)
+ base_directory = Pathname.new(base_directory) unless base_directory.is_a? Pathname
+ dest_directory = self.cleanpath.path
+ base_directory = base_directory.cleanpath.path
+ dest_prefix = dest_directory
+ dest_names = []
+ while r = chop_basename(dest_prefix)
+ dest_prefix, basename = r
+ dest_names.unshift basename if basename != '.'
+ end
+ base_prefix = base_directory
+ base_names = []
+ while r = chop_basename(base_prefix)
+ base_prefix, basename = r
+ base_names.unshift basename if basename != '.'
+ end
+ unless same_paths?(dest_prefix, base_prefix)
+ raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
+ end
+ while !dest_names.empty? &&
+ !base_names.empty? &&
+ same_paths?(dest_names.first, base_names.first)
+ dest_names.shift
+ base_names.shift
+ end
+ if base_names.include? '..'
+ raise ArgumentError, "base_directory has ..: #{base_directory.inspect}"
+ end
+ base_names.fill('..')
+ relpath_names = base_names + dest_names
+ if relpath_names.empty?
+ Pathname.new('.')
+ else
+ Pathname.new(File.join(*relpath_names))
+ end
+ end
+end
+
+class Pathname # * File *
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # each_line(sep = $/, **opts) {|line| ... } → nil
+ # each_line(limit, **opts) {|line| ... } → nil
+ # each_line(sep, limit, **opts) {|line| ... } → nil
+ # each_line(...) → new_enumerator
+ #
+ # With a block given, calls the block with each line
+ # from the file represented by `self`;
+ # returns `nil`:
+ #
+ # ```ruby
+ # lines = []
+ # Pathname('COPYING').each_line {|line| lines << line }
+ # lines.take(3)
+ # # =>
+ # # ["{日本語}[rdoc-ref:COPYING.ja]\n",
+ # # "\n",
+ # # "Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.\n"]
+ # ```
+ #
+ # The lines are read using IO.foreach,
+ # all arguments and options are passed to that method;
+ # see details at IO.foreach.
+ #
+ # With no block given, returns a new Enumerator.
+ def each_line(...) # :yield: line
+ File.foreach(@path, ...)
+ end
+
+ # call-seq:
+ # read(length = nil, offset = 0, **opts) -> string or nil
+ #
+ # Reads and returns some or all of the content of the file
+ # whose path is <tt>self.to_s</tt>.
+ #
+ # With no arguments given,
+ # reads in text mode and returns the entire content of the file:
+ #
+ # Pathname.new('t.txt').read
+ # # => "First line\nSecond line\n\nFourth line\nFifth line\n"
+ # Pathname.new('t.ja').read
+ # # => "ã“ã‚“ã«ã¡ã¯"
+ # Pathname.new('t.dat').read
+ # # => "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
+ #
+ # On Windows, text mode can terminate reading and leave bytes in the file unread
+ # when encountering certain special bytes.
+ # Consider using #binread if all bytes in the file should be read.
+ #
+ # With argument +length+ given, returns +length+ bytes if available:
+ #
+ # Pathname.new('t.txt').read(7)
+ # # => "First l"
+ # Pathname.new('t.ja').read(7)
+ # # => "\xE3\x81\x93\xE3\x82\x93\xE3"
+ # Pathname.new('t.dat').read(7)
+ # # => "\xFE\xFF\x99\x90\x99\x91\x99"
+ #
+ # Returns all bytes if +length+ is larger than the files size:
+ #
+ # Pathname.new('t.txt').read(700)
+ # # => "First line\r\nSecond line\r\n\r\nFourth line\r\nFifth line\r\n"
+ # Pathname.new('t.ja').read(700)
+ # # => "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF"
+ # Pathname.new('t.dat').read(700)
+ # # => "\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
+ #
+ # With arguments +length+ and +offset+ given,
+ # returns +length+ bytes if available, beginning at the given +offset+:
+ #
+ # Pathname.new('t.txt').read(10, 2)
+ # # => "rst line\r\n"
+ # Pathname.new('t.ja').read(10, 2)
+ # # => "\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1"
+ # Pathname.new('t.dat').read(10, 2)
+ # # => "\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"
+ #
+ # Returns +nil+ if +offset+ is past the end of the file:
+ #
+ # Pathname.new('t.txt').read(10, 200) # => nil
+ #
+ # Optional keyword arguments +opts+ specify:
+ #
+ # - {Open Options}[rdoc-ref:IO@Open+Options].
+ # - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
+ #
+ def read(...) File.read(@path, ...) end
+
+ # call-seq:
+ # binread(length = nil, offset = 0) -> string or nil
+ #
+ # Behaves like #read, except that the file is opened in binary mode
+ # with ASCII-8BIT encoding.
+ #
+ def binread(...) File.binread(@path, ...) end
+
+ # See <tt>File.readlines</tt>. Returns all the lines from the file.
+ def readlines(...) File.readlines(@path, ...) end
+
+ # See <tt>File.sysopen</tt>.
+ def sysopen(...) File.sysopen(@path, ...) end
+
+ # call-seq:
+ # write(data, offset = 0, **opts) -> nonnegative_integer
+ #
+ # Opens the file at +self.to_s+, writes the given +data+ to it,
+ # and closes the file; returns the number of bytes written.
+ #
+ # With only argument +data+ given, writes the given data to the file:
+ #
+ # path = 't.tmp'
+ # pn = Pathname.new(path)
+ # pn.write('foo') # => 3
+ # File.read(path) # => "foo"
+ #
+ # If +offset+ is zero (the default), the file is overwritten:
+ #
+ # pn.write('bar')
+ # File.read(path) # => "bar"
+ #
+ # If +offset+ in within the file content, the file is partly overwritten:
+ #
+ # pn.write('foobarbaz')
+ # pn.write('BAR', 3)
+ # File.read(path) # => "fooBARbaz"
+ #
+ # If +offset+ is outside the file content,
+ # the file is padded with null characters <tt>"\u0000"</tt>:
+ #
+ # pn.write('bat', 12)
+ # File.read(path) # => "fooBARbaz\u0000\u0000\u0000bat"
+ #
+ # Optional keyword arguments +opts+ specify:
+ #
+ # - {Open Options}[rdoc-ref:IO@Open+Options].
+ # - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
+ #
+ def write(...) File.write(@path, ...) end
+
+ # call-seq:
+ # binwrite(string, offset = 0, **opts) -> nonnegative_integer
+ #
+ # Behaves like #write, except that the file is opened in binary mode
+ # with ASCII-8BIT encoding.
+ def binwrite(...) File.binwrite(@path, ...) end
+
+ # call-seq:
+ # atime -> new_time
+ #
+ # Returns a new Time object containing the time of the most recent
+ # access (read or write) to the entry represented by `self`;
+ # see {File System Timestamps}[rdoc-ref:file/timestamps.md]:
+ #
+ # # Work in a temporary directory.
+ # require 'tmpdir'
+ # Dir.mktmpdir do |tmpdirpath|
+ # # A subdirectory therein, and its Pathname.
+ # dirpath = File.join(tmpdirpath, 'subdir')
+ # Dir.mkdir(dirpath)
+ # dir_pn = Pathname(dirpath)
+ # puts "Create directory; establishes atime for directory."
+ # puts " Directory atime: #{dir_pn.atime}"
+ # sleep(1)
+ #
+ # # A file in the subdirectory, and its Pathname.
+ # filepath = File.join(dirpath, 't.txt')
+ # puts "Create file; establishes atime for file, updates atime for directory."
+ # File.write(filepath, 'foo')
+ # file_pn = Pathname(filepath)
+ # puts " File atime: #{file_pn.atime}"
+ # puts " Directory atime: #{dir_pn.atime}"
+ # sleep(1)
+ # puts "Write file; updates atimes for file and directory."
+ # File.write(filepath, 'bar')
+ # puts " File atime: #{file_pn.atime}"
+ # puts " Directory atime: #{dir_pn.atime}"
+ # end
+ #
+ # Output:
+ #
+ # Create directory; establishes atime for directory.
+ # Directory atime: 2026-05-14 14:36:43 +0100
+ # Create file; establishes atime for file, updates atime for directory.
+ # File atime: 2026-05-14 14:36:44 +0100
+ # Directory atime: 2026-05-14 14:36:44 +0100
+ # Write file; updates atimes for file and directory.
+ # File atime: 2026-05-14 14:36:45 +0100
+ # Directory atime: 2026-05-14 14:36:45 +0100
+ #
+ def atime() File.atime(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # birthtime -> new_time
+ #
+ # Returns a new Time object containing the create time of the entry
+ # represented by `self`;
+ # see [File System Timestamps](rdoc-ref:file/timestamps.md):
+ #
+ # ```ruby
+ # # Work in a temporary directory.
+ # Pathname.mktmpdir do |tmpdirpath|
+ # # A subdirectory therein, and its Pathname.
+ # dirpath = File.join(tmpdirpath, 'subdir')
+ # dir_pn = Pathname(dirpath)
+ # puts "Create directory; directory birthtime established."
+ # dir_pn.mkdir
+ # puts " Directory birthtime: #{dir_pn.birthtime}"
+ # sleep(1)
+ #
+ # # A file in the subdirectory, and its Pathname.
+ # filepath = File.join(dirpath, 't.txt')
+ # file_pn = Pathname(filepath)
+ # puts "Create file; file birthtime established; directory birthtime not updated."
+ # file_pn.write('foo')
+ # puts " File birthtime: #{file_pn.birthtime}"
+ # puts " Directory birthtime: #{dir_pn.birthtime}"
+ # sleep(1)
+ # puts "Write file; neither birthtime updated."
+ # file_pn.write('bar')
+ # puts " File birthtime: #{file_pn.birthtime}"
+ # puts " Directory birthtime: #{dir_pn.birthtime}"
+ # end
+ # ```
+ #
+ # Output:
+ #
+ # ```text
+ # Create directory; directory birthtime established.
+ # Directory birthtime: 2026-05-14 23:41:12 +0100
+ # Create file; file birthtime established; directory birthtime not updated.
+ # File birthtime: 2026-05-14 23:41:13 +0100
+ # Directory birthtime: 2026-05-14 23:41:12 +0100
+ # Write file; neither birthtime updated.
+ # File birthtime: 2026-05-14 23:41:13 +0100
+ # Directory birthtime: 2026-05-14 23:41:12 +0100
+ # ```
+ #
+ def birthtime() File.birthtime(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # ctime -> new_time
+ #
+ # On Windows, returns the #birthtime.
+ #
+ # On other systems,
+ # returns a new Time object containing the time of the most recent
+ # metadata change to the entry represented by `self`;
+ # see {File System Timestamps}[rdoc-ref:file/timestamps.md]:
+ #
+ # ```ruby
+ # # Work in a temporary directory.
+ # Pathname.mktmpdir do |tmpdirpath|
+ # # A subdirectory therein, and its Pathname.
+ # dirpath = File.join(tmpdirpath, 'subdir')
+ # dir_pn = Pathname(dirpath)
+ # puts "Create directory; directory ctime established."
+ # dir_pn.mkdir
+ # puts " Directory ctime: #{dir_pn.ctime}"
+ # sleep(1)
+ #
+ # # A file in the subdirectory, and its Pathname.
+ # filepath = File.join(dirpath, 't.txt')
+ # file_pn = Pathname(filepath)
+ # puts "Create file; file ctime established; directory ctime updated."
+ # file_pn.write('foo')
+ # puts " File ctime: #{file_pn.ctime}"
+ # puts " Directory ctime: #{dir_pn.ctime}"
+ # sleep(1)
+ # puts "Write file; file ctime updated; directory ctime not updated."
+ # file_pn.write('bar')
+ # puts " File ctime: #{file_pn.ctime}"
+ # puts " Directory ctime: #{dir_pn.ctime}"
+ # sleep(1)
+ # puts "Read file; neither ctime not updated."
+ # file_pn.read
+ # puts " File ctime: #{file_pn.ctime}"
+ # puts " Directory ctime: #{dir_pn.ctime}"
+ # end
+ # ```
+ #
+ # Output:
+ #
+ # ```text
+ # Create directory; directory ctime established.
+ # Directory ctime: 2026-05-20 14:05:05 -0500
+ # Create file; file ctime established; directory ctime updated.
+ # File ctime: 2026-05-20 14:05:06 -0500
+ # Directory ctime: 2026-05-20 14:05:06 -0500
+ # Write file; file ctime updated; directory ctime not updated.
+ # File ctime: 2026-05-20 14:05:07 -0500
+ # Directory ctime: 2026-05-20 14:05:06 -0500
+ # Read file; neither ctime not updated.
+ # File ctime: 2026-05-20 14:05:07 -0500
+ # Directory ctime: 2026-05-20 14:05:06 -0500
+ # ```
+ #
+ def ctime() File.ctime(@path) end
+
+ # See <tt>File.mtime</tt>. Returns last modification time.
+ def mtime() File.mtime(@path) end
+
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # chmod(mode) -> 1
+ #
+ # Changes the mode (i.e., permissions) of the entry represented by `self`;
+ # see {File Permissions}[rdoc-ref:File@File+Permissions];
+ # returns `1`:
+ #
+ # ```ruby
+ # # A helper method to make an integer mode display as octal.
+ # def pretty(mode); '0' + (mode & 0777).to_s(8); end
+ #
+ # # Work in a temporary directory.
+ # Pathname.mktmpdir do |tmpdirpath|
+ # # A subdirectory therein, and its Pathname.
+ # dirpath = File.join(tmpdirpath, 'subdir')
+ # dir_pn = Pathname(dirpath)
+ # dir_pn.mkdir
+ # # The directory mode.
+ # puts "Original directory mode: #{pretty(dir_pn.stat.mode)}"
+ # # Change the directory mode.
+ # dir_pn.chmod(0777)
+ # puts "New directory mode: #{pretty(dir_pn.stat.mode)}"
+ #
+ # # A file in the subdirectory, and its Pathname.
+ # filepath = File.join(dirpath, 't.txt')
+ # file_pn = Pathname(filepath)
+ # # Create the file.
+ # file_pn.write('foo')
+ # # The file mode.
+ # puts "Original file mode: #{pretty(file_pn.stat.mode)}"
+ # # Change the file modes.
+ # file_pn.chmod(0777)
+ # puts "New file mode: #{pretty(file_pn.stat.mode)}"
+ # end
+ # ```
+ #
+ # Output:
+ #
+ # ```text
+ # Original directory mode: 0775
+ # New directory mode: 0777
+ # Original file mode: 0664
+ # New file mode: 0777
+ # ```
+ #
+ def chmod(mode) File.chmod(mode, @path) end
+
+ # See <tt>File.lchmod</tt>.
+ def lchmod(mode) File.lchmod(mode, @path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # chown(owner_id, group_id) -> 0
+ #
+ # Changes the owner and group of an entry (directory or file):
+ #
+ # ```ruby
+ # # Work in a temporary directory.
+ # Pathname.mktmpdir do |tmpdirpath|
+ # # A subdirectory therein, and its Pathname.
+ # dirpath = File.join(tmpdirpath, 'subdir')
+ # dir_pn = Pathname(dirpath)
+ # dir_pn.mkdir
+ # dir_stat = File.stat(dirpath)
+ # puts "Original directory owner: #{dir_stat.uid}"
+ # puts "Original directory group: #{dir_stat.gid}"
+ # dir_pn.chown(1000, 1000)
+ # dir_stat = File.stat(dirpath)
+ # puts "New directory owner: #{dir_stat.uid}"
+ # puts "New directory group: #{dir_stat.gid}"
+ #
+ # # A file in the subdirectory, and its Pathname.
+ # filepath = File.join(dirpath, 't.txt')
+ # file_pn = Pathname(filepath)
+ # # Create the file.
+ # file_pn.write('foo')
+ # file_stat = File.stat(filepath)
+ # puts "Original file owner: #{file_stat.uid}"
+ # puts "Original file group: #{file_stat.gid}"
+ # file_pn = Pathname(dirpath)
+ # file_pn.chown(1000, 1000)
+ # file_stat = File.stat(dirpath)
+ # puts "New file owner: #{file_stat.uid}"
+ # puts "New file group: #{file_stat.gid}"
+ # end
+ # ```
+ #
+ # Output:
+ #
+ # ```text
+ # Original directory owner: 0
+ # Original directory group: 0
+ # New directory owner: 1000
+ # New directory group: 1000
+ # Original file owner: 0
+ # Original file group: 0
+ # New file owner: 1000
+ # New file group: 1000
+ # ```
+ #
+ # Notes:
+ #
+ # - On Windows, the owner and group are not changed.
+ # - Only a process with superuser privileges can change the owner of an entry.
+ # - The owner of an entry can change its group to any group
+ # to which the owner belongs.
+ # - A +nil+ or +-1+ owner or group id is ignored.
+ # - The method follows symbolic links to the target entry.
+ #
+ def chown(owner, group) File.chown(owner, group, @path) end
+
+ # See <tt>File.lchown</tt>.
+ def lchown(owner, group) File.lchown(owner, group, @path) end
+
+ # See <tt>File.fnmatch</tt>. Return +true+ if the receiver matches the given
+ # pattern.
+ def fnmatch(pattern, ...) File.fnmatch(pattern, @path, ...) end
+
+ # See <tt>File.fnmatch?</tt> (same as #fnmatch).
+ def fnmatch?(pattern, ...) File.fnmatch?(pattern, @path, ...) end
+
+ # See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory",
+ # etc).
+ def ftype() File.ftype(@path) end
+
+ # See <tt>File.link</tt>. Creates a hard link.
+ def make_link(old) File.link(old, @path) end
+
+ # See <tt>File.open</tt>. Opens the file for reading or writing.
+ def open(...) # :yield: file
+ File.open(@path, ...)
+ end
+
+ # See <tt>File.readlink</tt>. Read symbolic link.
+ def readlink() self.class.new(File.readlink(@path)) end
+
+ # See <tt>File.rename</tt>. Rename the file.
+ def rename(to) File.rename(@path, to) end
+
+ # See <tt>File.stat</tt>. Returns a <tt>File::Stat</tt> object.
+ def stat() File.stat(@path) end
+
+ # See <tt>File.lstat</tt>.
+ def lstat() File.lstat(@path) end
+
+ # See <tt>File.symlink</tt>. Creates a symbolic link.
+ def make_symlink(old) File.symlink(old, @path) end
+
+ # See <tt>File.truncate</tt>. Truncate the file to +length+ bytes.
+ def truncate(length) File.truncate(@path, length) end
+
+ # See <tt>File.utime</tt>. Update the access and modification times.
+ def utime(atime, mtime) File.utime(atime, mtime, @path) end
+
+ # Update the access and modification times of the file.
+ #
+ # Same as Pathname#utime, but does not follow symbolic links.
+ #
+ # See File.lutime.
+ def lutime(atime, mtime) File.lutime(atime, mtime, @path) end
+
+ # call-seq:
+ # basename(path, suffix = '') -> new_pathname
+ #
+ # Returns a new \Pathname object containing all or part of the last entry
+ # of the path represented by +self+.
+ # Entries are delimited by the value of constant File::SEPARATOR
+ # and, if non-nil, the value of constant File::ALT_SEPARATOR.
+ #
+ # When +suffix+ is the empty string <tt>''</tt>, returns all of the last entry:
+ #
+ # Pathname.new('foo/bar/baz/bat.txt').basename # => #<Pathname:bat.txt>
+ # Pathname.new('foo/bar/baz').basename # => #<Pathname:baz>
+ #
+ # File::SEPARATOR # => "/"
+ # Pathname.new('foo/bar.txt////').basename # => #<Pathname:bar.txt>
+ # File::ALT_SEPARATOR # => "\\" # On Windows.
+ # Pathname.new('foo/bar.txt//\\\\//').basename # => #<Pathname:bar.txt>
+ #
+ # When +suffix+ is <tt>'.*'</tt>,
+ # the last {filename extension}[https://en.wikipedia.org/wiki/Filename_extension],
+ # if any, is removed:
+ #
+ # Pathname.new('foo/bar.txt').basename('.*') # => #<Pathname:bar>
+ # Pathname.new('foo/bar.txt.old').basename('.*') # => #<Pathname:bar.txt>
+ # Pathname.new('foo/bar').basename('.*') # => #<Pathname:bar>
+ #
+ # When +suffix+ is any string other than <tt>''</tt> or <tt>'.*'</tt>,
+ # the matching trailing substring, if any, is removed:
+ #
+ # Pathname.new('foo/bar.txt').basename('.txt') # => #<Pathname:bar>
+ # Pathname.new('foo/bar.txt').basename('txt') # => #<Pathname:bar.>
+ # Pathname.new('foo/bar.txt').basename('*') # => #<Pathname:bar.txt>
+ # Pathname.new('foo/bar.txt').basename('.') # => #<Pathname:bar.txt>
+ #
+ def basename(...) self.class.new(File.basename(@path, ...)) end
+
+ # See <tt>File.dirname</tt>. Returns all but the last component of the path.
+ def dirname() self.class.new(File.dirname(@path)) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # extname -> extension
+ #
+ # Returns the filename extension of `self` --
+ # usually the portion of the string path beginning from the last period:
+ #
+ # ```ruby
+ # Pathname('t.rb').extname # => ".rb"
+ # Pathname('foo.bar.t.rb').extname # => ".rb"
+ # Pathname('foo/bar/t.rb').extname # => ".rb"
+ # Pathname('nosuch.txt').extname # => ".txt" # Path need not exist.
+ # ```
+ #
+ # Returns the entire string when there is no period:
+ #
+ # ```ruby
+ # Pathname('foo').extname # => ""
+ # ```
+ #
+ # Returns an empty string when the only period is the first character:
+ #
+ # ```ruby
+ # Pathname('.irbrc').extname # => ""
+ # ```
+ #
+ # Returns an empty string or `'.'` when `path` ends with a period:
+ #
+ # ```ruby
+ # Pathname('foo.').extname # => "" # On Windows.
+ # Pathname('foo.').extname # => "." # Elsewhere.
+ # Pathname('foo....').extname # => "" # On Windows.
+ # Pathname('foo....').extname # => "." # Elsewhere.
+ # ```
+ #
+ def extname() File.extname(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # expand_path(dirpath = '.') -> new_pathname
+ #
+ # Returns a new pathname containing the absolute path for `self`.
+ #
+ # Evaluates a relative path with respect to the directory given by `dirpath`:
+ #
+ # ```ruby
+ # Dir.chdir('/snap')
+ # # Default dirpath.
+ # Pathname('README').expand_path # => #<Pathname:/snap/README>
+ # Pathname('bin').expand_path # => #<Pathname:/snap/bin>
+ # Pathname('bin/../var').expand_path # => #<Pathname:/snap/var> # Cleaned.
+ # # Other dirpath.
+ # Pathname('../zip').expand_path('/usr/bin/ruby') # => #<Pathname:/usr/bin/zip>
+ # Dir.chdir('/usr/bin')
+ # Pathname('../../snap').expand_path(__FILE__) # => #<Pathname:/usr/snap>
+ # ```
+ #
+ # Evaluates an absolute path without respect to `dirpath`:
+ #
+ # ```ruby
+ # Pathname('/snap').expand_path # => #<Pathname:/snap>
+ # Pathname('/snap').expand_path.expand_path('nosuch') # => #<Pathname:/snap>
+ # Pathname('/snap/../snap').expand_path # => #<Pathname:/snap> # Cleaned.
+ # ```
+ #
+ # More examples:
+ #
+ # ```
+ # Dir.chdir('/usr/bin')
+ # Pathname('../../snap').expand_path(__FILE__) # => #<Pathname:/usr/snap>
+ # Pathname('../../snap').expand_path # => #<Pathname:/snap>
+ # ```
+ #
+ def expand_path(...) self.class.new(File.expand_path(@path, ...)) end
+
+ # See <tt>File.split</tt>. Returns the #dirname and the #basename in an
+ # Array.
+ def split()
+ array = File.split(@path)
+ raise TypeError, 'wrong argument type nil (expected Array)' unless Array === array
+ array.map {|f| self.class.new(f) }
+ end
+
+ # Returns the real (absolute) pathname for +self+ in the actual filesystem.
+ #
+ # Does not contain symlinks or useless dots, +..+ and +.+.
+ #
+ # All components of the pathname must exist when this method is called.
+ def realpath(...) self.class.new(File.realpath(@path, ...)) end
+
+ # Returns the real (absolute) pathname of +self+ in the actual filesystem.
+ #
+ # Does not contain symlinks or useless dots, +..+ and +.+.
+ #
+ # The last component of the real pathname can be nonexistent.
+ def realdirpath(...) self.class.new(File.realdirpath(@path, ...)) end
+end
+
+
+class Pathname # * FileTest *
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # blockdev? => true or false
+ #
+ # Returns whether `self` represents a path to a block device
+ # (i.e., a direct-access device):
+ #
+ # ```ruby
+ # Pathname('/dev/nvme0n1').blockdev? # => true
+ # Pathname('/dev/loop0').blockdev? # => true
+ # Pathname('/dev/tty').blockdev? # => false
+ # Pathname('/dev/null').blockdev? # => false
+ # Pathname('nosuch').blockdev? # => false
+ # Pathname($stdin).blockdev? # => false
+ # ```
+ #
+ # The returned value is OS-dependent; on Windows, almost always `false`.
+ def blockdev?() FileTest.blockdev?(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # chardev? => true or false
+ #
+ # Returns whether `self` represents a path to a character device
+ # (i.e., a sequential-access device):
+ #
+ # ```ruby
+ # Pathname('/dev/tty').chardev? # => true
+ # Pathname('/dev/null').chardev? # => true
+ # Pathname('/dev/nvme0n1').chardev? # => false
+ # Pathname('/dev/loop0').chardev? # => false
+ # Pathname($stdin).chardev? # => false
+ # Pathname('nosuch').chardev? # => false
+ # ```
+ #
+ # The returned value is OS-dependent; on Windows, almost always `false`.
+ def chardev?() FileTest.chardev?(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # empty? -> true or false
+ #
+ # Returns whether the entry represented by `self` exists and is empty:
+ #
+ # ```ruby
+ # dir_pn = Pathname('example_dir')
+ # dir_pn.empty? # => false # Dir does not exist.
+ # dir_pn.mkdir
+ # dir_pn.empty? # => true # Dir exists and is empty.
+ #
+ # file_pn = Pathname('example_dir/example.txt')
+ # file_pn.empty? # => false # File does not exist.
+ # file_pn.write('')
+ # file_pn.empty? # => true # File exists and is empty.
+ # dir_pn.empty? # => false # Dir exists and is not empty.
+ # file_pn.write('foo')
+ # file_pn.empty? # => false # File exists and is not empty.
+ #
+ # file_pn.delete
+ # dir_pn.delete
+ # ```
+ #
+ def empty?
+ if FileTest.directory?(@path)
+ Dir.empty?(@path)
+ else
+ File.empty?(@path)
+ end
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # executable? -> true or false
+ #
+ # Returns whether the entry represented by `self` is executable;
+ # calls FileTest.executable? with argument `self.to_s`:
+ #
+ # ```ruby
+ # Pathname('bin/gem').executable? # => true
+ # Pathname('README.md').executable? # => false
+ # ```
+ #
+ def executable?() FileTest.executable?(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # executable_real? -> true or false
+ #
+ # Returns whether the entry represented by `self` is executable
+ # by the real user and group id of the current process;
+ # calls FileTest.executable_real? with argument `self.to_s`:
+ #
+ # ```ruby
+ # pn = Pathname('example')
+ # pn.write('')
+ # pn.executable_real? # => false
+ # pn.chmod(0100)
+ # pn.executable_real? # => true
+ # ```
+ #
+ def executable_real?() FileTest.executable_real?(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # exist? -> true or false
+ #
+ # Returns whether the entry represented by `self` exists:
+ #
+ # ```ruby
+ # Pathname('.').exist? # => true
+ # Pathname('README.md').exist? # => true
+ # Pathname('nosuch').exist? # => false
+ # ```
+ #
+ def exist?() FileTest.exist?(@path) end
+
+ # See <tt>FileTest.grpowned?</tt>.
+ def grpowned?() FileTest.grpowned?(@path) end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # directory? -> true or false
+ #
+ # Returns whether the entry represented by `self` is a directory:
+ #
+ # ```ruby
+ # Pathname('/etc').directory? # => true
+ # Pathname('lib').directory? # => true
+ # Pathname('README.md').directory? # => false
+ # Pathname('nosuch').directory? # => false
+ # ```
+ #
+ def directory?() FileTest.directory?(@path) end
+
+ # See <tt>FileTest.file?</tt>.
+ def file?() FileTest.file?(@path) end
+
+ # See <tt>FileTest.pipe?</tt>.
+ def pipe?() FileTest.pipe?(@path) end
+
+ # See <tt>FileTest.socket?</tt>.
+ def socket?() FileTest.socket?(@path) end
+
+ # See <tt>FileTest.owned?</tt>.
+ def owned?() FileTest.owned?(@path) end
+
+ # See <tt>FileTest.readable?</tt>.
+ def readable?() FileTest.readable?(@path) end
+
+ # See <tt>FileTest.world_readable?</tt>.
+ def world_readable?() File.world_readable?(@path) end
+
+ # See <tt>FileTest.readable_real?</tt>.
+ def readable_real?() FileTest.readable_real?(@path) end
+
+ # See <tt>FileTest.setuid?</tt>.
+ def setuid?() FileTest.setuid?(@path) end
+
+ # See <tt>FileTest.setgid?</tt>.
+ def setgid?() FileTest.setgid?(@path) end
+
+ # See <tt>FileTest.size</tt>.
+ def size() FileTest.size(@path) end
+
+ # See <tt>FileTest.size?</tt>.
+ def size?() FileTest.size?(@path) end
+
+ # See <tt>FileTest.sticky?</tt>.
+ def sticky?() FileTest.sticky?(@path) end
+
+ # See <tt>FileTest.symlink?</tt>.
+ def symlink?() FileTest.symlink?(@path) end
+
+ # See <tt>FileTest.writable?</tt>.
+ def writable?() FileTest.writable?(@path) end
+
+ # See <tt>FileTest.world_writable?</tt>.
+ def world_writable?() File.world_writable?(@path) end
+
+ # See <tt>FileTest.writable_real?</tt>.
+ def writable_real?() FileTest.writable_real?(@path) end
+
+ # See <tt>FileTest.zero?</tt>.
+ def zero?() FileTest.zero?(@path) end
+end
+
+
+class Pathname # * Dir *
+ # call-seq:
+ # glob(patterns, **kwargs) → array_of_pathnames
+ # glob(patterns, **kwargs) {|pathname| ... } → nil
+ #
+ # Calls <tt>Dir.glob(patterns, **kwargs)</tt>, which yields or returns entry names;
+ # see Dir.glob.
+ #
+ # Required argument +patterns+ is a string pattern or an array of string patterns;
+ # note that these patterns are not regexps.
+ #
+ # Keyword arguments <tt>**kwargs</tt> are passed through to Dir.glob;
+ # see the documentation there.
+ #
+ # With no block given, returns an array of \Pathname objects;
+ # each is <tt>Pathname.new(entry_name)</tt> for an entry name returned by Dir.glob.
+ #
+ # Pathname.glob('*').take(3)
+ # # => [#<Pathname:BSDL>, #<Pathname:CONTRIBUTING.md>, #<Pathname:COPYING>]
+ # Pathname.glob(['o*', 'a*']).take(3)
+ # # => [#<Pathname:object.c>, #<Pathname:aclocal.m4>, #<Pathname:addr2line.c>]
+ #
+ # With a block given, calls the block with each pathname
+ # <tt>Pathname.new(entry_name)</tt>,
+ # where each +entry_name+ is a \Pathname object created by the value yielded by Dir.glob.
+ #
+ # a = []
+ # Pathname.glob(['o*', 'a*']) {|pathname| a << pathname }
+ # a.take(3)
+ # # => [#<Pathname:object.c>, #<Pathname:aclocal.m4>, #<Pathname:addr2line.c>]
+ #
+ # Optional keyword argument +base+ is of particular interest.
+ # When it is given, its value specifies the base directory for the pathnames;
+ # each pattern string specifies entries relative to the base directory:
+ #
+ # Pathname.glob('*', base: 'lib').take(2)
+ # # => [#<Pathname:English.gemspec>, #<Pathname:English.rb>]
+ # Pathname.glob('*', base: 'lib/bundler').take(2)
+ # # => [#<Pathname:build_metadata.rb>, #<Pathname:bundler.gemspec>]
+ #
+ # Note that the base directory is not prepended to the entry names in the result.
+ def Pathname.glob(*args, **kwargs) # :yield: pathname
+ if block_given?
+ Dir.glob(*args, **kwargs) {|f| yield self.new(f) }
+ else
+ Dir.glob(*args, **kwargs).map {|f| self.new(f) }
+ end
+ end
+
+ # Returns or yields Pathname objects.
+ #
+ # Pathname("ruby-2.4.2").glob("R*.md")
+ # #=> [#<Pathname:ruby-2.4.2/README.md>, #<Pathname:ruby-2.4.2/README.ja.md>]
+ #
+ # See Dir.glob.
+ # This method uses the +base+ keyword argument of Dir.glob.
+ def glob(*args, **kwargs) # :yield: pathname
+ if block_given?
+ Dir.glob(*args, **kwargs, base: @path) {|f| yield self + f }
+ else
+ Dir.glob(*args, **kwargs, base: @path).map {|f| self + f }
+ end
+ end
+
+ # call-seq:
+ # Pathname.getwd -> new_pathname
+ #
+ # Returns a new \Pathname object containing the path to the current working directory
+ # (equivalent to <tt>Pathname.new(Dir.getwd)</tt>):
+ #
+ # Pathname.getwd # => #<Pathname:/home>
+ #
+ def Pathname.getwd() self.new(Dir.getwd) end
+ class << self
+ alias pwd getwd
+ end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # entries -> array_of_pathnames
+ #
+ # Returns an array of pathnames,
+ # one for each entry in the directory represented by `self`:
+ #
+ # ```ruby
+ # Pathname('.').entries.take(5)
+ # # =>
+ # # [#<Pathname:.>,
+ # # #<Pathname:..>,
+ # # #<Pathname:gc.rb>,
+ # # #<Pathname:yjit.rb>,
+ # # #<Pathname:iseq.h>]
+ # ```
+ #
+ def entries() Dir.entries(@path).map {|f| self.class.new(f) } end
+
+ # :markup: markdown
+ #
+ # call-seq:
+ # each_entry {|entry| ... } -> nil
+ # each_entry -> new_enumerator
+ #
+ # With a block given,
+ # yields a new pathname for each entry
+ # in the entry represented by `self`;
+ # returns `nil`:
+ #
+ # ```ruby
+ # Pathname('include').each_entry {|entry| p entry }
+ # # #<Pathname:ruby>
+ # # #<Pathname:..>
+ # # #<Pathname:ruby.h>
+ # # #<Pathname:.>
+ # # => nil
+ # ```
+ #
+ # With no block given, returns a new Enumerator.
+ def each_entry(&block) # :yield: pathname
+ return to_enum(__method__) unless block_given?
+ Dir.foreach(@path) {|f| yield self.class.new(f) }
+ end
+
+ # See <tt>Dir.mkdir</tt>. Create the referenced directory.
+ def mkdir(...) Dir.mkdir(@path, ...) end
+
+ # See <tt>Dir.rmdir</tt>. Remove the referenced directory.
+ def rmdir() Dir.rmdir(@path) end
+
+ # See <tt>Dir.open</tt>.
+ def opendir(&block) # :yield: dir
+ Dir.open(@path, &block)
+ end
+end
+
+class Pathname # * mixed *
+ #
+ # :markup: markdown
+ #
+ # call-seq:
+ # unlink -> 1 or 0
+ #
+ # Removes the file or directory represented by `self`, using:
+ #
+ # - File.unlink, if `self` represents a file; returns `1`.
+ # - Dir.unlink, if `self` represents a directory; returns `0`.
+ #
+ # Examples:
+ #
+ # ```ruby
+ # Pathname(Tempfile.create).unlink # => 1
+ # Pathname(Pathname.mktmpdir).unlink # => 0
+ # ```
+ #
+ def unlink()
+ Dir.unlink @path
+ rescue Errno::ENOTDIR
+ File.unlink @path
+ end
+ alias delete unlink
+end
+
+class Pathname
+ undef =~ if Kernel.method_defined?(:=~)
+end
+
+module Kernel
+ # Creates a Pathname object.
+ def Pathname(path) # :doc:
+ return path if Pathname === path
+ Pathname.new(path)
+ end
+ module_function :Pathname
+end
diff --git a/prelude.rb b/prelude.rb
index ee78b44cc5..b6c610dd58 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -1,8 +1,18 @@
class Binding
# :nodoc:
- def irb
- require 'irb'
- irb
+ def irb(...)
+ suppress = Thread.current[:__bundled_gems_warning_suppression]
+ Thread.current[:__bundled_gems_warning_suppression] = ['reline', 'rdoc']
+
+ begin
+ require 'irb'
+ rescue LoadError, Gem::LoadError
+ Gem::BUNDLED_GEMS.force_activate 'irb'
+ require 'irb'
+ end
+ irb(...)
+ ensure
+ Thread.current[:__bundled_gems_warning_suppression] = suppress
end
# suppress redefinition warning
@@ -10,22 +20,22 @@ class Binding
end
module Kernel
+ # :stopdoc:
def pp(*objs)
require 'pp'
pp(*objs)
end
# suppress redefinition warning
- alias pp pp # :nodoc:
+ alias pp pp
private :pp
+ # :startdoc:
end
-autoload :Set, 'set'
-
module Enumerable
# Makes a set from the enumerable object with given arguments.
- def to_set(klass = Set, *args, &block)
- klass.new(self, *args, &block)
- end unless instance_methods.include?(:to_set) # RJIT could already load this from builtin prelude
+ def to_set(&block)
+ Set.new(self, &block)
+ end
end
diff --git a/prism/arena.c b/prism/arena.c
new file mode 100644
index 0000000000..64a731649d
--- /dev/null
+++ b/prism/arena.c
@@ -0,0 +1,117 @@
+#include "prism/internal/arena.h"
+
+#include "prism/internal/allocator.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/**
+ * Compute the block allocation size using offsetof so it is correct regardless
+ * of PM_FLEX_ARRAY_LENGTH.
+ */
+#define PM_ARENA_BLOCK_SIZE(data_size) (offsetof(pm_arena_block_t, data) + (data_size))
+
+/** Initial block data size: 8 KB. */
+#define PM_ARENA_INITIAL_SIZE 8192
+
+/** Double the block size every this many blocks. */
+#define PM_ARENA_GROWTH_INTERVAL 8
+
+/** Maximum block data size: 1 MB. */
+#define PM_ARENA_MAX_SIZE (1024 * 1024)
+
+/**
+ * Compute the data size for the next block.
+ */
+static size_t
+pm_arena_next_block_size(const pm_arena_t *arena, size_t min_size) {
+ size_t size = PM_ARENA_INITIAL_SIZE;
+
+ for (size_t exp = PM_ARENA_GROWTH_INTERVAL; exp <= arena->block_count; exp += PM_ARENA_GROWTH_INTERVAL) {
+ if (size < PM_ARENA_MAX_SIZE) size *= 2;
+ }
+
+ return size > min_size ? size : min_size;
+}
+
+/**
+ * Allocate a new block with the given data capacity and initial usage, link it
+ * into the arena, and return it. Aborts on allocation failure.
+ */
+static pm_arena_block_t *
+pm_arena_block_new(pm_arena_t *arena, size_t data_size, size_t initial_used) {
+ assert(initial_used <= data_size);
+ pm_arena_block_t *block = (pm_arena_block_t *) xmalloc(PM_ARENA_BLOCK_SIZE(data_size));
+
+ if (block == NULL) {
+ fprintf(stderr, "prism: out of memory; aborting\n");
+ abort();
+ }
+
+ block->capacity = data_size;
+ block->used = initial_used;
+ block->prev = arena->current;
+ arena->current = block;
+ arena->block_count++;
+
+ return block;
+}
+
+/**
+ * Ensure the arena has at least `capacity` bytes available in its current
+ * block, allocating a new block if necessary. This allows callers to
+ * pre-size the arena to avoid repeated small block allocations.
+ */
+void
+pm_arena_reserve(pm_arena_t *arena, size_t capacity) {
+ if (capacity <= PM_ARENA_INITIAL_SIZE) return;
+ if (arena->current != NULL && (arena->current->capacity - arena->current->used) >= capacity) return;
+ pm_arena_block_new(arena, capacity, 0);
+}
+
+/**
+ * Slow path for pm_arena_alloc: allocate a new block and return a pointer to
+ * the first `size` bytes. Called when the current block has insufficient space.
+ */
+void *
+pm_arena_alloc_slow(pm_arena_t *arena, size_t size) {
+ size_t block_data_size = pm_arena_next_block_size(arena, size);
+ pm_arena_block_t *block = pm_arena_block_new(arena, block_data_size, size);
+ return block->data;
+}
+
+/**
+ * Returns a newly allocated and initialized arena.
+ */
+pm_arena_t *
+pm_arena_new(void) {
+ pm_arena_t *arena = (pm_arena_t *) xcalloc(1, sizeof(pm_arena_t));
+ if (arena == NULL) abort();
+ return arena;
+}
+
+/**
+ * Free all blocks in the arena.
+ */
+void
+pm_arena_cleanup(pm_arena_t *arena) {
+ pm_arena_block_t *block = arena->current;
+
+ while (block != NULL) {
+ pm_arena_block_t *prev = block->prev;
+ xfree_sized(block, PM_ARENA_BLOCK_SIZE(block->capacity));
+ block = prev;
+ }
+
+ *arena = (pm_arena_t) { 0 };
+}
+
+/**
+ * Frees both the held memory and the arena itself.
+ */
+void
+pm_arena_free(pm_arena_t *arena) {
+ pm_arena_cleanup(arena);
+ xfree_sized(arena, sizeof(pm_arena_t));
+}
diff --git a/prism/arena.h b/prism/arena.h
new file mode 100644
index 0000000000..e1fa8fc6ad
--- /dev/null
+++ b/prism/arena.h
@@ -0,0 +1,37 @@
+/**
+ * @file arena.h
+ *
+ * A bump allocator for the prism parser.
+ */
+#ifndef PRISM_ARENA_H
+#define PRISM_ARENA_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+
+/**
+ * An opaque pointer to an arena that is used for allocations.
+ */
+typedef struct pm_arena_t pm_arena_t;
+
+/**
+ * Returns a newly allocated and initialized arena. If the arena cannot be
+ * allocated, this function aborts the process.
+ *
+ * @returns A pointer to the newly allocated arena. It is the responsibility of
+ * the caller to free the arena using pm_arena_free when it is no longer
+ * needed.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_arena_t * pm_arena_new(void);
+
+/**
+ * Frees both the held memory and the arena itself.
+ *
+ * @param arena The arena to free.
+ */
+PRISM_EXPORTED_FUNCTION void pm_arena_free(pm_arena_t *arena) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/buffer.c b/prism/buffer.c
new file mode 100644
index 0000000000..cb3b9a4fe8
--- /dev/null
+++ b/prism/buffer.c
@@ -0,0 +1,374 @@
+#include "prism/internal/buffer.h"
+
+#include "prism/compiler/inline.h"
+
+#include "prism/internal/char.h"
+#include "prism/internal/allocator.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Initialize a pm_buffer_t with the given capacity.
+ */
+void
+pm_buffer_init(pm_buffer_t *buffer, size_t capacity) {
+ buffer->length = 0;
+ buffer->capacity = capacity;
+
+ buffer->value = (char *) xmalloc(capacity);
+ if (buffer->value == NULL) abort();
+}
+
+/**
+ * Allocate and initialize a new buffer.
+ */
+pm_buffer_t *
+pm_buffer_new(void) {
+ pm_buffer_t *buffer = (pm_buffer_t *) xmalloc(sizeof(pm_buffer_t));
+ if (buffer == NULL) abort();
+
+ pm_buffer_init(buffer, 1024);
+ return buffer;
+}
+
+/**
+ * Return the value of the buffer.
+ */
+char *
+pm_buffer_value(const pm_buffer_t *buffer) {
+ return buffer->value;
+}
+
+/**
+ * Return the length of the buffer.
+ */
+size_t
+pm_buffer_length(const pm_buffer_t *buffer) {
+ return buffer->length;
+}
+
+/**
+ * Append the given amount of space to the buffer.
+ */
+static PRISM_INLINE bool
+pm_buffer_append_length(pm_buffer_t *buffer, size_t length) {
+ size_t next_length = buffer->length + length;
+ const size_t original_capacity = buffer->capacity;
+
+ if (next_length > buffer->capacity) {
+ if (buffer->capacity == 0) {
+ buffer->capacity = 1;
+ }
+
+ while (next_length > buffer->capacity) {
+ buffer->capacity *= 2;
+ }
+
+ buffer->value = xrealloc_sized(buffer->value, buffer->capacity, original_capacity);
+ if (buffer->value == NULL) return false;
+ }
+
+ buffer->length = next_length;
+ return true;
+}
+
+/**
+ * Append a generic pointer to memory to the buffer.
+ */
+static PRISM_INLINE void
+pm_buffer_append(pm_buffer_t *buffer, const void *source, size_t length) {
+ size_t cursor = buffer->length;
+ if (pm_buffer_append_length(buffer, length)) {
+ memcpy(buffer->value + cursor, source, length);
+ }
+}
+
+/**
+ * Append the given amount of space as zeroes to the buffer.
+ */
+void
+pm_buffer_append_zeroes(pm_buffer_t *buffer, size_t length) {
+ size_t cursor = buffer->length;
+ if (pm_buffer_append_length(buffer, length)) {
+ memset(buffer->value + cursor, 0, length);
+ }
+}
+
+/**
+ * Append a formatted string to the buffer.
+ */
+void
+pm_buffer_append_format(pm_buffer_t *buffer, const char *format, ...) {
+ va_list arguments;
+ va_start(arguments, format);
+ int result = vsnprintf(NULL, 0, format, arguments);
+ va_end(arguments);
+
+ if (result < 0) return;
+ size_t length = (size_t) (result + 1);
+
+ size_t cursor = buffer->length;
+ if (pm_buffer_append_length(buffer, length)) {
+ va_start(arguments, format);
+ vsnprintf(buffer->value + cursor, length, format, arguments);
+ va_end(arguments);
+ buffer->length--;
+ }
+}
+
+/**
+ * Append a string to the buffer.
+ */
+void
+pm_buffer_append_string(pm_buffer_t *buffer, const char *value, size_t length) {
+ pm_buffer_append(buffer, value, length);
+}
+
+/**
+ * Append a list of bytes to the buffer.
+ */
+void
+pm_buffer_append_bytes(pm_buffer_t *buffer, const uint8_t *value, size_t length) {
+ pm_buffer_append(buffer, (const char *) value, length);
+}
+
+/**
+ * Append a single byte to the buffer.
+ */
+void
+pm_buffer_append_byte(pm_buffer_t *buffer, uint8_t value) {
+ const void *source = &value;
+ pm_buffer_append(buffer, source, sizeof(uint8_t));
+}
+
+/**
+ * Append a 32-bit unsigned integer to the buffer as a variable-length integer.
+ */
+void
+pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value) {
+ if (value < 128) {
+ pm_buffer_append_byte(buffer, (uint8_t) value);
+ } else {
+ uint32_t n = value;
+ while (n >= 128) {
+ pm_buffer_append_byte(buffer, (uint8_t) (n | 128));
+ n >>= 7;
+ }
+ pm_buffer_append_byte(buffer, (uint8_t) n);
+ }
+}
+
+/**
+ * Append a 32-bit signed integer to the buffer as a variable-length integer.
+ */
+void
+pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value) {
+ uint32_t unsigned_int = ((uint32_t)(value) << 1) ^ ((uint32_t)(value >> 31));
+ pm_buffer_append_varuint(buffer, unsigned_int);
+}
+
+/**
+ * Append a double to the buffer.
+ */
+void
+pm_buffer_append_double(pm_buffer_t *buffer, double value) {
+ const void *source = &value;
+ pm_buffer_append(buffer, source, sizeof(double));
+}
+
+/**
+ * Append a unicode codepoint to the buffer.
+ */
+bool
+pm_buffer_append_unicode_codepoint(pm_buffer_t *buffer, uint32_t value) {
+ if (value <= 0x7F) {
+ pm_buffer_append_byte(buffer, (uint8_t) value); // 0xxxxxxx
+ return true;
+ } else if (value <= 0x7FF) {
+ uint8_t bytes[] = {
+ (uint8_t) (0xC0 | ((value >> 6) & 0x3F)), // 110xxxxx
+ (uint8_t) (0x80 | (value & 0x3F)) // 10xxxxxx
+ };
+
+ pm_buffer_append_bytes(buffer, bytes, 2);
+ return true;
+ } else if (value <= 0xFFFF) {
+ uint8_t bytes[] = {
+ (uint8_t) (0xE0 | ((value >> 12) & 0x3F)), // 1110xxxx
+ (uint8_t) (0x80 | ((value >> 6) & 0x3F)), // 10xxxxxx
+ (uint8_t) (0x80 | (value & 0x3F)) // 10xxxxxx
+ };
+
+ pm_buffer_append_bytes(buffer, bytes, 3);
+ return true;
+ } else if (value <= 0x10FFFF) {
+ uint8_t bytes[] = {
+ (uint8_t) (0xF0 | ((value >> 18) & 0x3F)), // 11110xxx
+ (uint8_t) (0x80 | ((value >> 12) & 0x3F)), // 10xxxxxx
+ (uint8_t) (0x80 | ((value >> 6) & 0x3F)), // 10xxxxxx
+ (uint8_t) (0x80 | (value & 0x3F)) // 10xxxxxx
+ };
+
+ pm_buffer_append_bytes(buffer, bytes, 4);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Append a slice of source code to the buffer.
+ */
+void
+pm_buffer_append_source(pm_buffer_t *buffer, const uint8_t *source, size_t length, pm_buffer_escaping_t escaping) {
+ for (size_t index = 0; index < length; index++) {
+ const uint8_t byte = source[index];
+
+ if ((byte <= 0x06) || (byte >= 0x0E && byte <= 0x1F) || (byte >= 0x7F)) {
+ if (escaping == PM_BUFFER_ESCAPING_RUBY) {
+ pm_buffer_append_format(buffer, "\\x%02X", byte);
+ } else {
+ pm_buffer_append_format(buffer, "\\u%04X", byte);
+ }
+ } else {
+ switch (byte) {
+ case '\a':
+ if (escaping == PM_BUFFER_ESCAPING_RUBY) {
+ pm_buffer_append_string(buffer, "\\a", 2);
+ } else {
+ pm_buffer_append_format(buffer, "\\u%04X", byte);
+ }
+ break;
+ case '\b':
+ pm_buffer_append_string(buffer, "\\b", 2);
+ break;
+ case '\t':
+ pm_buffer_append_string(buffer, "\\t", 2);
+ break;
+ case '\n':
+ pm_buffer_append_string(buffer, "\\n", 2);
+ break;
+ case '\v':
+ if (escaping == PM_BUFFER_ESCAPING_RUBY) {
+ pm_buffer_append_string(buffer, "\\v", 2);
+ } else {
+ pm_buffer_append_format(buffer, "\\u%04X", byte);
+ }
+ break;
+ case '\f':
+ pm_buffer_append_string(buffer, "\\f", 2);
+ break;
+ case '\r':
+ pm_buffer_append_string(buffer, "\\r", 2);
+ break;
+ case '"':
+ pm_buffer_append_string(buffer, "\\\"", 2);
+ break;
+ case '#': {
+ if (escaping == PM_BUFFER_ESCAPING_RUBY && index + 1 < length) {
+ const uint8_t next_byte = source[index + 1];
+ if (next_byte == '{' || next_byte == '@' || next_byte == '$') {
+ pm_buffer_append_byte(buffer, '\\');
+ }
+ }
+
+ pm_buffer_append_byte(buffer, '#');
+ break;
+ }
+ case '\\':
+ pm_buffer_append_string(buffer, "\\\\", 2);
+ break;
+ default:
+ pm_buffer_append_byte(buffer, byte);
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Prepend the given string to the buffer.
+ */
+void
+pm_buffer_prepend_string(pm_buffer_t *buffer, const char *value, size_t length) {
+ size_t cursor = buffer->length;
+ if (pm_buffer_append_length(buffer, length)) {
+ memmove(buffer->value + length, buffer->value, cursor);
+ memcpy(buffer->value, value, length);
+ }
+}
+
+/**
+ * Concatenate one buffer onto another.
+ */
+void
+pm_buffer_concat(pm_buffer_t *destination, const pm_buffer_t *source) {
+ if (source->length > 0) {
+ pm_buffer_append(destination, source->value, source->length);
+ }
+}
+
+/**
+ * Clear the buffer by reducing its size to 0. This does not free the allocated
+ * memory, but it does allow the buffer to be reused.
+ */
+void
+pm_buffer_clear(pm_buffer_t *buffer) {
+ buffer->length = 0;
+}
+
+/**
+ * Strip the whitespace from the end of the buffer.
+ */
+void
+pm_buffer_rstrip(pm_buffer_t *buffer) {
+ while (buffer->length > 0 && pm_char_is_whitespace((uint8_t) buffer->value[buffer->length - 1])) {
+ buffer->length--;
+ }
+}
+
+/**
+ * Checks if the buffer includes the given value.
+ */
+size_t
+pm_buffer_index(const pm_buffer_t *buffer, char value) {
+ const char *first = memchr(buffer->value, value, buffer->length);
+ return (first == NULL) ? SIZE_MAX : (size_t) (first - buffer->value);
+}
+
+/**
+ * Insert the given string into the buffer at the given index.
+ */
+void
+pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size_t length) {
+ assert(index <= buffer->length);
+
+ if (index == buffer->length) {
+ pm_buffer_append_string(buffer, value, length);
+ } else {
+ pm_buffer_append_zeroes(buffer, length);
+ memmove(buffer->value + index + length, buffer->value + index, buffer->length - length - index);
+ memcpy(buffer->value + index, value, length);
+ }
+}
+
+/**
+ * Free the memory held by the buffer.
+ */
+void
+pm_buffer_cleanup(pm_buffer_t *buffer) {
+ xfree_sized(buffer->value, buffer->capacity);
+}
+
+/**
+ * Free both the memory held by the buffer and the buffer itself.
+ */
+void
+pm_buffer_free(pm_buffer_t *buffer) {
+ pm_buffer_cleanup(buffer);
+ xfree_sized(buffer, sizeof(pm_buffer_t));
+}
diff --git a/prism/buffer.h b/prism/buffer.h
new file mode 100644
index 0000000000..24b572d2c3
--- /dev/null
+++ b/prism/buffer.h
@@ -0,0 +1,52 @@
+/**
+ * @file buffer.h
+ *
+ * A wrapper around a contiguous block of allocated memory.
+ */
+#ifndef PRISM_BUFFER_H
+#define PRISM_BUFFER_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+
+/**
+ * A wrapper around a contiguous block of allocated memory.
+ */
+typedef struct pm_buffer_t pm_buffer_t;
+
+/**
+ * Allocate and initialize a new buffer. If the buffer cannot be allocated, this
+ * function will abort the process.
+ *
+ * @returns A pointer to the initialized buffer. The caller is responsible for
+ * freeing the buffer with pm_buffer_free.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_buffer_t * pm_buffer_new(void);
+
+/**
+ * Free both the memory held by the buffer and the buffer itself.
+ *
+ * @param buffer The buffer to free.
+ */
+PRISM_EXPORTED_FUNCTION void pm_buffer_free(pm_buffer_t *buffer) PRISM_NONNULL(1);
+
+/**
+ * Return the value of the buffer.
+ *
+ * @param buffer The buffer to get the value of.
+ * @returns The value of the buffer.
+ */
+PRISM_EXPORTED_FUNCTION char * pm_buffer_value(const pm_buffer_t *buffer) PRISM_NONNULL(1);
+
+/**
+ * Return the length of the buffer.
+ *
+ * @param buffer The buffer to get the length of.
+ * @returns The length of the buffer.
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_buffer_length(const pm_buffer_t *buffer) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/char.c b/prism/char.c
new file mode 100644
index 0000000000..08e457aa1f
--- /dev/null
+++ b/prism/char.c
@@ -0,0 +1,274 @@
+#include "prism/internal/char.h"
+
+#include "prism/compiler/inline.h"
+#include "prism/internal/line_offset_list.h"
+
+#define PRISM_CHAR_BIT_REGEXP_OPTION (1 << 2)
+
+#define PRISM_NUMBER_BIT_BINARY_DIGIT (1 << 0)
+#define PRISM_NUMBER_BIT_BINARY_NUMBER (1 << 1)
+#define PRISM_NUMBER_BIT_OCTAL_DIGIT (1 << 2)
+#define PRISM_NUMBER_BIT_OCTAL_NUMBER (1 << 3)
+#define PRISM_NUMBER_BIT_DECIMAL_DIGIT (1 << 4)
+#define PRISM_NUMBER_BIT_DECIMAL_NUMBER (1 << 5)
+#define PRISM_NUMBER_BIT_HEXADECIMAL_DIGIT (1 << 6)
+#define PRISM_NUMBER_BIT_HEXADECIMAL_NUMBER (1 << 7)
+
+const uint8_t pm_byte_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 3, 3, 3, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 4x
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, // 5x
+ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 6x
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+static const uint8_t pm_number_table[256] = {
+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2x
+ 0xff, 0xff, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3x
+ 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, // 5x
+ 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 6x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9x
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Ax
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Bx
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Cx
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Dx
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Ex
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Fx
+};
+
+/**
+ * Returns the number of characters at the start of the string that match the
+ * given kind. Disallows searching past the given maximum number of characters.
+ */
+static PRISM_INLINE size_t
+pm_strspn_char_kind(const uint8_t *string, ptrdiff_t length, uint8_t kind) {
+ if (length <= 0) return 0;
+
+ size_t size = 0;
+ size_t maximum = (size_t) length;
+
+ while (size < maximum && (pm_byte_table[string[size]] & kind)) size++;
+ return size;
+}
+
+/**
+ * Returns the number of characters at the start of the string that are
+ * whitespace. Disallows searching past the given maximum number of characters.
+ */
+size_t
+pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length) {
+ return pm_strspn_char_kind(string, length, PRISM_CHAR_BIT_WHITESPACE);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are
+ * whitespace while also tracking the location of each newline. Disallows
+ * searching past the given maximum number of characters.
+ */
+size_t
+pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_arena_t *arena, pm_line_offset_list_t *line_offsets, uint32_t start_offset) {
+ if (length <= 0) return 0;
+
+ uint32_t size = 0;
+ uint32_t maximum = (uint32_t) length;
+
+ while (size < maximum && (pm_byte_table[string[size]] & PRISM_CHAR_BIT_WHITESPACE)) {
+ if (string[size] == '\n') {
+ pm_line_offset_list_append(arena, line_offsets, start_offset + size + 1);
+ }
+
+ size++;
+ }
+
+ return size;
+}
+
+/**
+ * Returns the number of characters at the start of the string that are regexp
+ * options. Disallows searching past the given maximum number of characters.
+ */
+size_t
+pm_strspn_regexp_option(const uint8_t *string, ptrdiff_t length) {
+ return pm_strspn_char_kind(string, length, PRISM_CHAR_BIT_REGEXP_OPTION);
+}
+
+
+/**
+ * Scan through the string and return the number of characters at the start of
+ * the string that match the given kind. Disallows searching past the given
+ * maximum number of characters.
+ */
+static PRISM_INLINE size_t
+pm_strspn_number_kind(const uint8_t *string, ptrdiff_t length, uint8_t kind) {
+ if (length <= 0) return 0;
+
+ size_t size = 0;
+ size_t maximum = (size_t) length;
+
+ while (size < maximum && (pm_number_table[string[size]] & kind)) size++;
+ return size;
+}
+
+/**
+ * Scan through the string and return the number of characters at the start of
+ * the string that match the given kind. Disallows searching past the given
+ * maximum number of characters.
+ *
+ * Additionally, report the location of the last invalid underscore character
+ * found in the string through the out invalid parameter.
+ */
+static PRISM_INLINE size_t
+pm_strspn_number_kind_underscores(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid, uint8_t kind) {
+ if (length <= 0) return 0;
+
+ size_t size = 0;
+ size_t maximum = (size_t) length;
+
+ bool underscore = false;
+ while (size < maximum && (pm_number_table[string[size]] & kind)) {
+ if (string[size] == '_') {
+ if (underscore) *invalid = string + size;
+ underscore = true;
+ } else {
+ underscore = false;
+ }
+
+ size++;
+ }
+
+ if (size > 0 && string[size - 1] == '_') *invalid = string + size - 1;
+ return size;
+}
+
+/**
+ * Returns the number of characters at the start of the string that are binary
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t
+pm_strspn_binary_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid) {
+ return pm_strspn_number_kind_underscores(string, length, invalid, PRISM_NUMBER_BIT_BINARY_NUMBER);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are octal
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t
+pm_strspn_octal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid) {
+ return pm_strspn_number_kind_underscores(string, length, invalid, PRISM_NUMBER_BIT_OCTAL_NUMBER);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are decimal
+ * digits. Disallows searching past the given maximum number of characters.
+ */
+size_t
+pm_strspn_decimal_digit(const uint8_t *string, ptrdiff_t length) {
+ return pm_strspn_number_kind(string, length, PRISM_NUMBER_BIT_DECIMAL_DIGIT);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are decimal
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore
+ */
+size_t
+pm_strspn_decimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid) {
+ return pm_strspn_number_kind_underscores(string, length, invalid, PRISM_NUMBER_BIT_DECIMAL_NUMBER);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are
+ * hexadecimal digits. Disallows searching past the given maximum number of
+ * characters.
+ */
+size_t
+pm_strspn_hexadecimal_digit(const uint8_t *string, ptrdiff_t length) {
+ return pm_strspn_number_kind(string, length, PRISM_NUMBER_BIT_HEXADECIMAL_DIGIT);
+}
+
+/**
+ * Returns the number of characters at the start of the string that are
+ * hexadecimal digits or underscores. Disallows searching past the given maximum
+ * number of characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t
+pm_strspn_hexadecimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid) {
+ return pm_strspn_number_kind_underscores(string, length, invalid, PRISM_NUMBER_BIT_HEXADECIMAL_NUMBER);
+}
+
+/**
+ * Returns true if the given character matches the given kind.
+ */
+static PRISM_INLINE bool
+pm_char_is_number_kind(const uint8_t b, uint8_t kind) {
+ return (pm_number_table[b] & kind) != 0;
+}
+
+/**
+ * Returns true if the given character is a binary digit.
+ */
+bool
+pm_char_is_binary_digit(const uint8_t b) {
+ return pm_char_is_number_kind(b, PRISM_NUMBER_BIT_BINARY_DIGIT);
+}
+
+/**
+ * Returns true if the given character is an octal digit.
+ */
+bool
+pm_char_is_octal_digit(const uint8_t b) {
+ return pm_char_is_number_kind(b, PRISM_NUMBER_BIT_OCTAL_DIGIT);
+}
+
+/**
+ * Returns true if the given character is a decimal digit.
+ */
+bool
+pm_char_is_decimal_digit(const uint8_t b) {
+ return pm_char_is_number_kind(b, PRISM_NUMBER_BIT_DECIMAL_DIGIT);
+}
+
+/**
+ * Returns true if the given character is a hexadecimal digit.
+ */
+bool
+pm_char_is_hexadecimal_digit(const uint8_t b) {
+ return pm_char_is_number_kind(b, PRISM_NUMBER_BIT_HEXADECIMAL_DIGIT);
+}
diff --git a/prism/comments.h b/prism/comments.h
new file mode 100644
index 0000000000..2270d53889
--- /dev/null
+++ b/prism/comments.h
@@ -0,0 +1,43 @@
+/**
+ * @file comments.h
+ *
+ * Types and functions related to comments found during parsing.
+ */
+#ifndef PRISM_COMMENTS_H
+#define PRISM_COMMENTS_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+
+#include <stddef.h>
+
+/** This is the type of a comment that we've found while parsing. */
+typedef enum {
+ PM_COMMENT_INLINE,
+ PM_COMMENT_EMBDOC
+} pm_comment_type_t;
+
+/** An opaque pointer to a comment found while parsing. */
+typedef struct pm_comment_t pm_comment_t;
+
+/**
+ * Returns the location associated with the given comment.
+ *
+ * @param comment the comment whose location we want to get
+ * @returns the location associated with the given comment
+ */
+PRISM_EXPORTED_FUNCTION pm_location_t pm_comment_location(const pm_comment_t *comment) PRISM_NONNULL(1);
+
+/**
+ * Returns the type associated with the given comment.
+ *
+ * @param comment the comment whose type we want to get
+ * @returns the type associated with the given comment. This can either be
+ * PM_COMMENT_INLINE or PM_COMMENT_EMBDOC.
+ */
+PRISM_EXPORTED_FUNCTION pm_comment_type_t pm_comment_type(const pm_comment_t *comment) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/compiler/accel.h b/prism/compiler/accel.h
new file mode 100644
index 0000000000..be23236d1d
--- /dev/null
+++ b/prism/compiler/accel.h
@@ -0,0 +1,19 @@
+/**
+ * @file compiler/accel.h
+ */
+#ifndef PRISM_COMPILER_ACCEL_H
+#define PRISM_COMPILER_ACCEL_H
+
+/**
+ * Platform detection for SIMD/fast-path implementations. At most one of these
+ * macros is defined, selecting the best available vectorization strategy.
+ */
+#if (defined(__aarch64__) && defined(__ARM_NEON)) || (defined(_MSC_VER) && defined(_M_ARM64))
+# define PRISM_HAS_NEON
+#elif (defined(__x86_64__) && defined(__SSSE3__)) || (defined(_MSC_VER) && defined(_M_X64))
+# define PRISM_HAS_SSSE3
+#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define PRISM_HAS_SWAR
+#endif
+
+#endif
diff --git a/prism/compiler/align.h b/prism/compiler/align.h
new file mode 100644
index 0000000000..22cb49a48c
--- /dev/null
+++ b/prism/compiler/align.h
@@ -0,0 +1,36 @@
+/**
+ * @file compiler/align.h
+ */
+#ifndef PRISM_COMPILER_ALIGN_H
+#define PRISM_COMPILER_ALIGN_H
+
+/**
+ * Compiler-agnostic macros for specifying alignment of types and variables.
+ */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L /* C11 or later */
+ /** Specify alignment for a type or variable. */
+ #define PRISM_ALIGNAS _Alignas
+
+ /** Get the alignment requirement of a type. */
+ #define PRISM_ALIGNOF _Alignof
+#elif defined(__GNUC__) || defined(__clang__)
+ /** Specify alignment for a type or variable. */
+ #define PRISM_ALIGNAS(size) __attribute__((aligned(size)))
+
+ /** Get the alignment requirement of a type. */
+ #define PRISM_ALIGNOF(type) __alignof__(type)
+#elif defined(_MSC_VER)
+ /** Specify alignment for a type or variable. */
+ #define PRISM_ALIGNAS(size) __declspec(align(size))
+
+ /** Get the alignment requirement of a type. */
+ #define PRISM_ALIGNOF(type) __alignof(type)
+#else
+ /** Void because this platform does not support specifying alignment. */
+ #define PRISM_ALIGNAS(size)
+
+ /** Fallback to sizeof as alignment requirement of a type. */
+ #define PRISM_ALIGNOF(type) sizeof(type)
+#endif
+
+#endif
diff --git a/prism/compiler/exported.h b/prism/compiler/exported.h
new file mode 100644
index 0000000000..823773ecbb
--- /dev/null
+++ b/prism/compiler/exported.h
@@ -0,0 +1,24 @@
+/**
+ * @file compiler/exported.h
+ */
+#ifndef PRISM_COMPILER_EXPORTED_H
+#define PRISM_COMPILER_EXPORTED_H
+
+/**
+ * By default, we compile with -fvisibility=hidden. When this is enabled, we
+ * need to mark certain functions as being publically-visible. This macro does
+ * that in a compiler-agnostic way.
+ */
+#ifndef PRISM_EXPORTED_FUNCTION
+# ifdef PRISM_EXPORT_SYMBOLS
+# ifdef _WIN32
+# define PRISM_EXPORTED_FUNCTION __declspec(dllexport) extern
+# else
+# define PRISM_EXPORTED_FUNCTION __attribute__((__visibility__("default"))) extern
+# endif
+# else
+# define PRISM_EXPORTED_FUNCTION
+# endif
+#endif
+
+#endif
diff --git a/prism/compiler/fallthrough.h b/prism/compiler/fallthrough.h
new file mode 100644
index 0000000000..ce1b450e8a
--- /dev/null
+++ b/prism/compiler/fallthrough.h
@@ -0,0 +1,22 @@
+/**
+ * @file compiler/fallthrough.h
+ */
+#ifndef PRISM_COMPILER_FALLTHROUGH_H
+#define PRISM_COMPILER_FALLTHROUGH_H
+
+/**
+ * We use -Wimplicit-fallthrough to guard potentially unintended fall-through
+ * between cases of a switch. Use PRISM_FALLTHROUGH to explicitly annotate cases
+ * where the fallthrough is intentional.
+ */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L /* C23 or later */
+ #define PRISM_FALLTHROUGH [[fallthrough]];
+#elif defined(__GNUC__) || defined(__clang__)
+ #define PRISM_FALLTHROUGH __attribute__((fallthrough));
+#elif defined(_MSC_VER)
+ #define PRISM_FALLTHROUGH __fallthrough;
+#else
+ #define PRISM_FALLTHROUGH
+#endif
+
+#endif
diff --git a/prism/compiler/filesystem.h b/prism/compiler/filesystem.h
new file mode 100644
index 0000000000..f988909db8
--- /dev/null
+++ b/prism/compiler/filesystem.h
@@ -0,0 +1,32 @@
+/**
+ * @file compiler/filesystem.h
+ *
+ * Platform detection for mmap and filesystem support.
+ */
+#ifndef PRISM_COMPILER_FILESYSTEM_H
+#define PRISM_COMPILER_FILESYSTEM_H
+
+/**
+ * In general, libc for embedded systems does not support memory-mapped files.
+ * If the target platform is POSIX or Windows, we can map a file in memory and
+ * read it in a more efficient manner.
+ */
+#ifdef _WIN32
+# define PRISM_HAS_MMAP
+#else
+# include <unistd.h>
+# ifdef _POSIX_MAPPED_FILES
+# define PRISM_HAS_MMAP
+# endif
+#endif
+
+/**
+ * If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem
+ * related code from the library. All filesystem related code should be guarded
+ * by PRISM_HAS_FILESYSTEM.
+ */
+#ifndef PRISM_HAS_NO_FILESYSTEM
+# define PRISM_HAS_FILESYSTEM
+#endif
+
+#endif
diff --git a/prism/compiler/flex_array.h b/prism/compiler/flex_array.h
new file mode 100644
index 0000000000..7504b5fdd3
--- /dev/null
+++ b/prism/compiler/flex_array.h
@@ -0,0 +1,19 @@
+/**
+ * @file compiler/flex_array.h
+ */
+#ifndef PRISM_COMPILER_FLEX_ARRAY_H
+#define PRISM_COMPILER_FLEX_ARRAY_H
+
+/**
+ * A macro for helper define a flexible array member. C99 supports `data[]`, GCC
+ * supports `data[0]` as an extension, and older compilers require `data[1]`.
+ */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ #define PM_FLEX_ARRAY_LENGTH /* data[] */
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+ #define PM_FLEX_ARRAY_LENGTH 0 /* data[0] */
+#else
+ #define PM_FLEX_ARRAY_LENGTH 1 /* data[1] */
+#endif
+
+#endif
diff --git a/prism/compiler/force_inline.h b/prism/compiler/force_inline.h
new file mode 100644
index 0000000000..e189d592d6
--- /dev/null
+++ b/prism/compiler/force_inline.h
@@ -0,0 +1,21 @@
+/**
+ * @file compiler/force_inline.h
+ */
+#ifndef PRISM_COMPILER_FORCE_INLINE_H
+#define PRISM_COMPILER_FORCE_INLINE_H
+
+#include "prism/compiler/inline.h"
+
+/**
+ * Force a function to be inlined at every call site. Use sparingly — only for
+ * small, hot functions where the compiler's heuristics fail to inline.
+ */
+#if defined(_MSC_VER)
+# define PRISM_FORCE_INLINE __forceinline
+#elif defined(__GNUC__) || defined(__clang__)
+# define PRISM_FORCE_INLINE PRISM_INLINE __attribute__((always_inline))
+#else
+# define PRISM_FORCE_INLINE PRISM_INLINE
+#endif
+
+#endif
diff --git a/prism/compiler/format.h b/prism/compiler/format.h
new file mode 100644
index 0000000000..32f4c3c6d7
--- /dev/null
+++ b/prism/compiler/format.h
@@ -0,0 +1,25 @@
+/**
+ * @file compiler/format.h
+ */
+#ifndef PRISM_COMPILER_FORMAT_H
+#define PRISM_COMPILER_FORMAT_H
+
+/**
+ * Certain compilers support specifying that a function accepts variadic
+ * parameters that look like printf format strings to provide a better developer
+ * experience when someone is using the function. This macro does that in a
+ * compiler-agnostic way.
+ */
+#if defined(__GNUC__)
+# if defined(__MINGW_PRINTF_FORMAT)
+# define PRISM_ATTRIBUTE_FORMAT(fmt_idx_, arg_idx_) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt_idx_, arg_idx_)))
+# else
+# define PRISM_ATTRIBUTE_FORMAT(fmt_idx_, arg_idx_) __attribute__((format(printf, fmt_idx_, arg_idx_)))
+# endif
+#elif defined(__clang__)
+# define PRISM_ATTRIBUTE_FORMAT(fmt_idx_, arg_idx_) __attribute__((__format__(__printf__, fmt_idx_, arg_idx_)))
+#else
+# define PRISM_ATTRIBUTE_FORMAT(fmt_idx_, arg_idx_)
+#endif
+
+#endif
diff --git a/prism/compiler/inline.h b/prism/compiler/inline.h
new file mode 100644
index 0000000000..856a375691
--- /dev/null
+++ b/prism/compiler/inline.h
@@ -0,0 +1,17 @@
+/**
+ * @file compiler/inline.h
+ */
+#ifndef PRISM_COMPILER_INLINE_H
+#define PRISM_COMPILER_INLINE_H
+
+/**
+ * Old Visual Studio versions do not support the inline keyword, so we need to
+ * define it to be __inline.
+ */
+#if defined(_MSC_VER) && !defined(inline)
+# define PRISM_INLINE __inline
+#else
+# define PRISM_INLINE inline
+#endif
+
+#endif
diff --git a/prism/compiler/nodiscard.h b/prism/compiler/nodiscard.h
new file mode 100644
index 0000000000..ccd6c00719
--- /dev/null
+++ b/prism/compiler/nodiscard.h
@@ -0,0 +1,22 @@
+/**
+ * @file compiler/nodiscard.h
+ */
+#ifndef PRISM_COMPILER_NODISCARD_H
+#define PRISM_COMPILER_NODISCARD_H
+
+/**
+ * Mark the return value of a function as important so that the compiler warns
+ * if a caller ignores it. This is useful for functions that return error codes
+ * or allocated resources that must be freed.
+ */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+# define PRISM_NODISCARD [[nodiscard]]
+#elif defined(__GNUC__) || defined(__clang__)
+# define PRISM_NODISCARD __attribute__((__warn_unused_result__))
+#elif defined(_MSC_VER)
+# define PRISM_NODISCARD _Check_return_
+#else
+# define PRISM_NODISCARD
+#endif
+
+#endif
diff --git a/prism/compiler/nonnull.h b/prism/compiler/nonnull.h
new file mode 100644
index 0000000000..9d19355665
--- /dev/null
+++ b/prism/compiler/nonnull.h
@@ -0,0 +1,18 @@
+/**
+ * @file compiler/nonnull.h
+ */
+#ifndef PRISM_COMPILER_NONNULL_H
+#define PRISM_COMPILER_NONNULL_H
+
+/**
+ * Mark the parameters of a function as non-null. This allows the compiler to
+ * warn if a caller passes NULL for a parameter that should never be NULL. The
+ * arguments are the 1-based indices of the parameters.
+ */
+#if defined(__GNUC__) || defined(__clang__)
+# define PRISM_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
+#else
+# define PRISM_NONNULL(...)
+#endif
+
+#endif
diff --git a/prism/compiler/unused.h b/prism/compiler/unused.h
new file mode 100644
index 0000000000..6a9e125dde
--- /dev/null
+++ b/prism/compiler/unused.h
@@ -0,0 +1,18 @@
+/**
+ * @file compiler/unused.h
+ */
+#ifndef PRISM_COMPILER_UNUSED_H
+#define PRISM_COMPILER_UNUSED_H
+
+/**
+ * GCC will warn if you specify a function or parameter that is unused at
+ * runtime. This macro allows you to mark a function or parameter as unused in a
+ * compiler-agnostic way.
+ */
+#if defined(__GNUC__)
+# define PRISM_UNUSED __attribute__((unused))
+#else
+# define PRISM_UNUSED
+#endif
+
+#endif
diff --git a/prism/config.yml b/prism/config.yml
new file mode 100644
index 0000000000..bbbc5f3d33
--- /dev/null
+++ b/prism/config.yml
@@ -0,0 +1,4740 @@
+errors:
+ - ALIAS_ARGUMENT
+ - ALIAS_ARGUMENT_NUMBERED_REFERENCE
+ - AMPAMPEQ_MULTI_ASSIGN
+ - ARGUMENT_AFTER_BLOCK
+ - ARGUMENT_AFTER_FORWARDING_ELLIPSES
+ - ARGUMENT_BARE_HASH
+ - ARGUMENT_BLOCK_FORWARDING
+ - ARGUMENT_BLOCK_MULTI
+ - ARGUMENT_CONFLICT_AMPERSAND
+ - ARGUMENT_CONFLICT_STAR
+ - ARGUMENT_CONFLICT_STAR_STAR
+ - ARGUMENT_FORMAL_CLASS
+ - ARGUMENT_FORMAL_CONSTANT
+ - ARGUMENT_FORMAL_GLOBAL
+ - ARGUMENT_FORMAL_IVAR
+ - ARGUMENT_FORWARDING_UNBOUND
+ - ARGUMENT_NO_FORWARDING_AMPERSAND
+ - ARGUMENT_NO_FORWARDING_ELLIPSES
+ - ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA
+ - ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK
+ - ARGUMENT_NO_FORWARDING_STAR
+ - ARGUMENT_NO_FORWARDING_STAR_STAR
+ - ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT
+ - ARGUMENT_SPLAT_AFTER_SPLAT
+ - ARGUMENT_TERM_PAREN
+ - ARGUMENT_UNEXPECTED_BLOCK
+ - ARRAY_ELEMENT
+ - ARRAY_EXPRESSION
+ - ARRAY_EXPRESSION_AFTER_STAR
+ - ARRAY_SEPARATOR
+ - ARRAY_TERM
+ - BEGIN_LONELY_ELSE
+ - BEGIN_TERM
+ - BEGIN_UPCASE_BRACE
+ - BEGIN_UPCASE_TERM
+ - BEGIN_UPCASE_TOPLEVEL
+ - BLOCK_PARAM_LOCAL_VARIABLE
+ - BLOCK_PARAM_PIPE_TERM
+ - BLOCK_TERM_BRACE
+ - BLOCK_TERM_END
+ - CANNOT_PARSE_EXPRESSION
+ - CANNOT_PARSE_STRING_PART
+ - CASE_EXPRESSION_AFTER_CASE
+ - CASE_EXPRESSION_AFTER_WHEN
+ - CASE_MATCH_MISSING_PREDICATE
+ - CASE_MISSING_CONDITIONS
+ - CASE_TERM
+ - CLASS_IN_METHOD
+ - CLASS_NAME
+ - CLASS_SUPERCLASS
+ - CLASS_TERM
+ - CLASS_UNEXPECTED_END
+ - CLASS_VARIABLE_BARE
+ - CONDITIONAL_ELSIF_PREDICATE
+ - CONDITIONAL_IF_PREDICATE
+ - CONDITIONAL_PREDICATE_TERM
+ - CONDITIONAL_TERM
+ - CONDITIONAL_TERM_ELSE
+ - CONDITIONAL_UNLESS_PREDICATE
+ - CONDITIONAL_UNTIL_PREDICATE
+ - CONDITIONAL_WHILE_PREDICATE
+ - CONSTANT_PATH_COLON_COLON_CONSTANT
+ - DEF_ENDLESS
+ - DEF_ENDLESS_PARAMETERS
+ - DEF_ENDLESS_SETTER
+ - DEF_ENDLESS_DO_BLOCK
+ - DEF_NAME
+ - DEF_PARAMS_TERM
+ - DEF_PARAMS_TERM_PAREN
+ - DEF_RECEIVER
+ - DEF_RECEIVER_TERM
+ - DEF_TERM
+ - DEFINED_EXPRESSION
+ - EMBDOC_TERM
+ - EMBEXPR_END
+ - EMBVAR_INVALID
+ - END_UPCASE_BRACE
+ - END_UPCASE_TERM
+ - ESCAPE_INVALID_CONTROL
+ - ESCAPE_INVALID_CONTROL_REPEAT
+ - ESCAPE_INVALID_HEXADECIMAL
+ - ESCAPE_INVALID_META
+ - ESCAPE_INVALID_META_REPEAT
+ - ESCAPE_INVALID_UNICODE
+ - ESCAPE_INVALID_UNICODE_CM_FLAGS
+ - ESCAPE_INVALID_UNICODE_LIST
+ - ESCAPE_INVALID_UNICODE_LITERAL
+ - ESCAPE_INVALID_UNICODE_LONG
+ - ESCAPE_INVALID_UNICODE_SHORT
+ - ESCAPE_INVALID_UNICODE_TERM
+ - EXPECT_ARGUMENT
+ - EXPECT_EOL_AFTER_STATEMENT
+ - EXPECT_EXPRESSION_AFTER_AMPAMPEQ
+ - EXPECT_EXPRESSION_AFTER_COMMA
+ - EXPECT_EXPRESSION_AFTER_EQUAL
+ - EXPECT_EXPRESSION_AFTER_LESS_LESS
+ - EXPECT_EXPRESSION_AFTER_LPAREN
+ - EXPECT_EXPRESSION_AFTER_OPERATOR
+ - EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ
+ - EXPECT_EXPRESSION_AFTER_QUESTION
+ - EXPECT_EXPRESSION_AFTER_SPLAT
+ - EXPECT_EXPRESSION_AFTER_SPLAT_HASH
+ - EXPECT_EXPRESSION_AFTER_STAR
+ - EXPECT_FOR_DELIMITER
+ - EXPECT_IDENT_REQ_PARAMETER
+ - EXPECT_IN_DELIMITER
+ - EXPECT_LPAREN_AFTER_NOT_LPAREN
+ - EXPECT_LPAREN_AFTER_NOT_OTHER
+ - EXPECT_LPAREN_REQ_PARAMETER
+ - EXPECT_MESSAGE
+ - EXPECT_RBRACKET
+ - EXPECT_RPAREN
+ - EXPECT_RPAREN_AFTER_MULTI
+ - EXPECT_RPAREN_REQ_PARAMETER
+ - EXPECT_SINGLETON_CLASS_DELIMITER
+ - EXPECT_STRING_CONTENT
+ - EXPECT_WHEN_DELIMITER
+ - EXPRESSION_BARE_HASH
+ - EXPRESSION_NOT_WRITABLE
+ - EXPRESSION_NOT_WRITABLE_ENCODING
+ - EXPRESSION_NOT_WRITABLE_FALSE
+ - EXPRESSION_NOT_WRITABLE_FILE
+ - EXPRESSION_NOT_WRITABLE_LINE
+ - EXPRESSION_NOT_WRITABLE_NIL
+ - EXPRESSION_NOT_WRITABLE_NUMBERED
+ - EXPRESSION_NOT_WRITABLE_SELF
+ - EXPRESSION_NOT_WRITABLE_TRUE
+ - FLOAT_PARSE
+ - FOR_COLLECTION
+ - FOR_IN
+ - FOR_INDEX
+ - FOR_TERM
+ - GLOBAL_VARIABLE_BARE
+ - HASH_EXPRESSION_AFTER_LABEL
+ - HASH_KEY
+ - HASH_ROCKET
+ - HASH_TERM
+ - HASH_VALUE
+ - HEREDOC_IDENTIFIER
+ - HEREDOC_TERM
+ - INCOMPLETE_QUESTION_MARK
+ - INCOMPLETE_VARIABLE_CLASS
+ - INCOMPLETE_VARIABLE_CLASS_3_3
+ - INCOMPLETE_VARIABLE_INSTANCE
+ - INCOMPLETE_VARIABLE_INSTANCE_3_3
+ - INSTANCE_VARIABLE_BARE
+ - INVALID_BLOCK_EXIT
+ - INVALID_CHARACTER
+ - INVALID_COMMA
+ - INVALID_ENCODING_MAGIC_COMMENT
+ - INVALID_ESCAPE_CHARACTER
+ - INVALID_FLOAT_EXPONENT
+ - INVALID_LOCAL_VARIABLE_READ
+ - INVALID_LOCAL_VARIABLE_WRITE
+ - INVALID_MULTIBYTE_CHAR
+ - INVALID_MULTIBYTE_CHARACTER
+ - INVALID_MULTIBYTE_ESCAPE
+ - INVALID_NUMBER_BINARY
+ - INVALID_NUMBER_DECIMAL
+ - INVALID_NUMBER_FRACTION
+ - INVALID_NUMBER_HEXADECIMAL
+ - INVALID_NUMBER_OCTAL
+ - INVALID_NUMBER_UNDERSCORE_INNER
+ - INVALID_NUMBER_UNDERSCORE_TRAILING
+ - INVALID_PERCENT
+ - INVALID_PERCENT_EOF
+ - INVALID_PRINTABLE_CHARACTER
+ - INVALID_RETRY_AFTER_ELSE
+ - INVALID_RETRY_AFTER_ENSURE
+ - INVALID_RETRY_WITHOUT_RESCUE
+ - INVALID_SYMBOL
+ - INVALID_VARIABLE_GLOBAL
+ - INVALID_VARIABLE_GLOBAL_3_3
+ - INVALID_YIELD
+ - IT_NOT_ALLOWED_NUMBERED
+ - IT_NOT_ALLOWED_ORDINARY
+ - LAMBDA_OPEN
+ - LAMBDA_TERM_BRACE
+ - LAMBDA_TERM_END
+ - LIST_I_LOWER_ELEMENT
+ - LIST_I_LOWER_TERM
+ - LIST_I_UPPER_ELEMENT
+ - LIST_I_UPPER_TERM
+ - LIST_W_LOWER_ELEMENT
+ - LIST_W_LOWER_TERM
+ - LIST_W_UPPER_ELEMENT
+ - LIST_W_UPPER_TERM
+ - MALLOC_FAILED
+ - MIXED_ENCODING
+ - MODULE_IN_METHOD
+ - MODULE_NAME
+ - MODULE_TERM
+ - MULTI_ASSIGN_MULTI_SPLATS
+ - MULTI_ASSIGN_UNEXPECTED_REST
+ - NESTING_TOO_DEEP
+ - NO_LOCAL_VARIABLE
+ - NON_ASSOCIATIVE_OPERATOR
+ - NOT_EXPRESSION
+ - NUMBER_LITERAL_UNDERSCORE
+ - NUMBERED_PARAMETER_INNER_BLOCK
+ - NUMBERED_PARAMETER_IT
+ - NUMBERED_PARAMETER_ORDINARY
+ - NUMBERED_PARAMETER_OUTER_BLOCK
+ - OPERATOR_MULTI_ASSIGN
+ - OPERATOR_WRITE_ARGUMENTS
+ - OPERATOR_WRITE_BLOCK
+ - PARAMETER_ASSOC_SPLAT_MULTI
+ - PARAMETER_BLOCK_MULTI
+ - PARAMETER_CIRCULAR
+ - PARAMETER_FORWARDING_AFTER_REST
+ - PARAMETER_METHOD_NAME
+ - PARAMETER_NAME_DUPLICATED
+ - PARAMETER_NO_DEFAULT
+ - PARAMETER_NO_DEFAULT_KW
+ - PARAMETER_NUMBERED_RESERVED
+ - PARAMETER_ORDER
+ - PARAMETER_SPLAT_MULTI
+ - PARAMETER_STAR
+ - PARAMETER_UNEXPECTED_FWD
+ - PARAMETER_UNEXPECTED_NO_KW
+ - PARAMETER_WILD_LOOSE_COMMA
+ - PATTERN_ARRAY_MULTIPLE_RESTS
+ - PATTERN_CAPTURE_DUPLICATE
+ - PATTERN_CAPTURE_IN_ALTERNATIVE
+ - PATTERN_EXPRESSION_AFTER_BRACKET
+ - PATTERN_EXPRESSION_AFTER_COMMA
+ - PATTERN_EXPRESSION_AFTER_HROCKET
+ - PATTERN_EXPRESSION_AFTER_IN
+ - PATTERN_EXPRESSION_AFTER_KEY
+ - PATTERN_EXPRESSION_AFTER_PAREN
+ - PATTERN_EXPRESSION_AFTER_PIN
+ - PATTERN_EXPRESSION_AFTER_PIPE
+ - PATTERN_EXPRESSION_AFTER_RANGE
+ - PATTERN_EXPRESSION_AFTER_REST
+ - PATTERN_FIND_MISSING_INNER
+ - PATTERN_HASH_IMPLICIT
+ - PATTERN_HASH_KEY
+ - PATTERN_HASH_KEY_DUPLICATE
+ - PATTERN_HASH_KEY_INTERPOLATED
+ - PATTERN_HASH_KEY_LABEL
+ - PATTERN_HASH_KEY_LOCALS
+ - PATTERN_IDENT_AFTER_HROCKET
+ - PATTERN_LABEL_AFTER_COMMA
+ - PATTERN_REST
+ - PATTERN_TERM_BRACE
+ - PATTERN_TERM_BRACKET
+ - PATTERN_TERM_PAREN
+ - PIPEPIPEEQ_MULTI_ASSIGN
+ - REGEXP_ENCODING_OPTION_MISMATCH
+ - REGEXP_ESCAPED_NON_ASCII_IN_UTF8
+ - REGEXP_INCOMPAT_CHAR_ENCODING
+ - REGEXP_INVALID_CHAR_PROPERTY
+ - REGEXP_INVALID_UNICODE_RANGE
+ - REGEXP_NON_ESCAPED_MBC
+ - REGEXP_PARSE_ERROR
+ - REGEXP_TERM
+ - REGEXP_UNKNOWN_OPTIONS
+ - REGEXP_UTF8_CHAR_NON_UTF8_REGEXP
+ - RESCUE_EXPRESSION
+ - RESCUE_MODIFIER_VALUE
+ - RESCUE_TERM
+ - RESCUE_VARIABLE
+ - RETURN_INVALID
+ - SCRIPT_NOT_FOUND
+ - SINGLETON_FOR_LITERALS
+ - STATEMENT_ALIAS
+ - STATEMENT_POSTEXE_END
+ - STATEMENT_PREEXE_BEGIN
+ - STATEMENT_UNDEF
+ - STRING_CONCATENATION
+ - STRING_INTERPOLATED_TERM
+ - STRING_LITERAL_EOF
+ - STRING_LITERAL_TERM
+ - SYMBOL_INVALID
+ - SYMBOL_TERM_DYNAMIC
+ - SYMBOL_TERM_INTERPOLATED
+ - TERNARY_COLON
+ - TERNARY_EXPRESSION_FALSE
+ - TERNARY_EXPRESSION_TRUE
+ - UNARY_DISALLOWED
+ - UNARY_RECEIVER
+ - UNDEF_ARGUMENT
+ - UNEXPECTED_BLOCK_ARGUMENT
+ - UNEXPECTED_INDEX_BLOCK
+ - UNEXPECTED_INDEX_KEYWORDS
+ - UNEXPECTED_LABEL
+ - UNEXPECTED_MULTI_WRITE
+ - UNEXPECTED_PARAMETER_DEFAULT_VALUE
+ - UNEXPECTED_RANGE_OPERATOR
+ - UNEXPECTED_SAFE_NAVIGATION
+ - UNEXPECTED_TOKEN_CLOSE_CONTEXT
+ - UNEXPECTED_TOKEN_IGNORE
+ - UNTIL_TERM
+ - VOID_EXPRESSION
+ - WHILE_TERM
+ - WRITE_TARGET_IN_METHOD
+ - WRITE_TARGET_READONLY
+ - WRITE_TARGET_UNEXPECTED
+ - XSTRING_TERM
+warnings:
+ - AMBIGUOUS_BINARY_OPERATOR
+ - AMBIGUOUS_FIRST_ARGUMENT_MINUS
+ - AMBIGUOUS_FIRST_ARGUMENT_PLUS
+ - AMBIGUOUS_PREFIX_AMPERSAND
+ - AMBIGUOUS_PREFIX_STAR
+ - AMBIGUOUS_PREFIX_STAR_STAR
+ - AMBIGUOUS_SLASH
+ - COMPARISON_AFTER_COMPARISON
+ - DOT_DOT_DOT_EOL
+ - EQUAL_IN_CONDITIONAL
+ - EQUAL_IN_CONDITIONAL_3_3
+ - END_IN_METHOD
+ - DUPLICATED_HASH_KEY
+ - DUPLICATED_WHEN_CLAUSE
+ - FLOAT_OUT_OF_RANGE
+ - IGNORED_FROZEN_STRING_LITERAL
+ - INDENTATION_MISMATCH
+ - INTEGER_IN_FLIP_FLOP
+ - INVALID_CHARACTER
+ - INVALID_MAGIC_COMMENT_VALUE
+ - INVALID_NUMBERED_REFERENCE
+ - KEYWORD_EOL
+ - LITERAL_IN_CONDITION_DEFAULT
+ - LITERAL_IN_CONDITION_VERBOSE
+ - SHAREABLE_CONSTANT_VALUE_LINE
+ - SHEBANG_CARRIAGE_RETURN
+ - UNEXPECTED_CARRIAGE_RETURN
+ - UNREACHABLE_STATEMENT
+ - UNUSED_LOCAL_VARIABLE
+ - VOID_STATEMENT
+tokens:
+ # The order of the tokens at the beginning is important, because we use them
+ # for a lookup table.
+ - name: EOF
+ value: 1
+ comment: final token in the file
+ - name: BRACE_RIGHT
+ comment: "}"
+ - name: COMMA
+ comment: ","
+ - name: EMBEXPR_END
+ comment: "}"
+ - name: KEYWORD_DO
+ comment: "do"
+ - name: KEYWORD_ELSE
+ comment: "else"
+ - name: KEYWORD_ELSIF
+ comment: "elsif"
+ - name: KEYWORD_END
+ comment: "end"
+ - name: KEYWORD_ENSURE
+ comment: "ensure"
+ - name: KEYWORD_IN
+ comment: "in"
+ - name: KEYWORD_RESCUE
+ comment: "rescue"
+ - name: KEYWORD_THEN
+ comment: "then"
+ - name: KEYWORD_WHEN
+ comment: "when"
+ - name: NEWLINE
+ comment: "a newline character outside of other tokens"
+ - name: PARENTHESIS_RIGHT
+ comment: ")"
+ - name: PIPE
+ comment: "|"
+ - name: SEMICOLON
+ comment: ";"
+ # Tokens from here on are not used for lookup, and can be in any order.
+ - name: AMPERSAND
+ comment: "&"
+ - name: AMPERSAND_AMPERSAND
+ comment: "&&"
+ - name: AMPERSAND_AMPERSAND_EQUAL
+ comment: "&&="
+ - name: AMPERSAND_DOT
+ comment: "&."
+ - name: AMPERSAND_EQUAL
+ comment: "&="
+ - name: BACKTICK
+ comment: "`"
+ - name: BACK_REFERENCE
+ comment: "a back reference"
+ - name: BANG
+ comment: "! or !@"
+ - name: BANG_EQUAL
+ comment: "!="
+ - name: BANG_TILDE
+ comment: "!~"
+ - name: BRACE_LEFT
+ comment: "{"
+ - name: BRACKET_LEFT
+ comment: "["
+ - name: BRACKET_LEFT_ARRAY
+ comment: "[ for the beginning of an array"
+ - name: BRACKET_LEFT_RIGHT
+ comment: "[]"
+ - name: BRACKET_LEFT_RIGHT_EQUAL
+ comment: "[]="
+ - name: BRACKET_RIGHT
+ comment: "]"
+ - name: CARET
+ comment: "^"
+ - name: CARET_EQUAL
+ comment: "^="
+ - name: CHARACTER_LITERAL
+ comment: "a character literal"
+ - name: CLASS_VARIABLE
+ comment: "a class variable"
+ - name: COLON
+ comment: ":"
+ - name: COLON_COLON
+ comment: "::"
+ - name: COMMENT
+ comment: "a comment"
+ - name: CONSTANT
+ comment: "a constant"
+ - name: DOT
+ comment: "the . call operator"
+ - name: DOT_DOT
+ comment: "the .. range operator"
+ - name: DOT_DOT_DOT
+ comment: "the ... range operator or forwarding parameter"
+ - name: EMBDOC_BEGIN
+ comment: "=begin"
+ - name: EMBDOC_END
+ comment: "=end"
+ - name: EMBDOC_LINE
+ comment: "a line inside of embedded documentation"
+ - name: EMBEXPR_BEGIN
+ comment: "#{"
+ - name: EMBVAR
+ comment: "#"
+ - name: EQUAL
+ comment: "="
+ - name: EQUAL_EQUAL
+ comment: "=="
+ - name: EQUAL_EQUAL_EQUAL
+ comment: "==="
+ - name: EQUAL_GREATER
+ comment: "=>"
+ - name: EQUAL_TILDE
+ comment: "=~"
+ - name: FLOAT
+ comment: "a floating point number"
+ - name: FLOAT_IMAGINARY
+ comment: "a floating pointer number with an imaginary suffix"
+ - name: FLOAT_RATIONAL
+ comment: "a floating pointer number with a rational suffix"
+ - name: FLOAT_RATIONAL_IMAGINARY
+ comment: "a floating pointer number with a rational and imaginary suffix"
+ - name: GLOBAL_VARIABLE
+ comment: "a global variable"
+ - name: GREATER
+ comment: ">"
+ - name: GREATER_EQUAL
+ comment: ">="
+ - name: GREATER_GREATER
+ comment: ">>"
+ - name: GREATER_GREATER_EQUAL
+ comment: ">>="
+ - name: HEREDOC_END
+ comment: "the end of a heredoc"
+ - name: HEREDOC_START
+ comment: "the start of a heredoc"
+ - name: IDENTIFIER
+ comment: "an identifier"
+ - name: IGNORED_NEWLINE
+ comment: "an ignored newline"
+ - name: INSTANCE_VARIABLE
+ comment: "an instance variable"
+ - name: INTEGER
+ comment: "an integer (any base)"
+ - name: INTEGER_IMAGINARY
+ comment: "an integer with an imaginary suffix"
+ - name: INTEGER_RATIONAL
+ comment: "an integer with a rational suffix"
+ - name: INTEGER_RATIONAL_IMAGINARY
+ comment: "an integer with a rational and imaginary suffix"
+ - name: KEYWORD_ALIAS
+ comment: "alias"
+ - name: KEYWORD_AND
+ comment: "and"
+ - name: KEYWORD_BEGIN
+ comment: "begin"
+ - name: KEYWORD_BEGIN_UPCASE
+ comment: "BEGIN"
+ - name: KEYWORD_BREAK
+ comment: "break"
+ - name: KEYWORD_CASE
+ comment: "case"
+ - name: KEYWORD_CLASS
+ comment: "class"
+ - name: KEYWORD_DEF
+ comment: "def"
+ - name: KEYWORD_DEFINED
+ comment: "defined?"
+ - name: KEYWORD_DO_BLOCK
+ comment: "do keyword for a block attached to a command"
+ - name: KEYWORD_DO_LOOP
+ comment: "do keyword for a predicate in a while, until, or for loop"
+ - name: KEYWORD_END_UPCASE
+ comment: "END"
+ - name: KEYWORD_FALSE
+ comment: "false"
+ - name: KEYWORD_FOR
+ comment: "for"
+ - name: KEYWORD_IF
+ comment: "if"
+ - name: KEYWORD_IF_MODIFIER
+ comment: "if in the modifier form"
+ - name: KEYWORD_MODULE
+ comment: "module"
+ - name: KEYWORD_NEXT
+ comment: "next"
+ - name: KEYWORD_NIL
+ comment: "nil"
+ - name: KEYWORD_NOT
+ comment: "not"
+ - name: KEYWORD_OR
+ comment: "or"
+ - name: KEYWORD_REDO
+ comment: "redo"
+ - name: KEYWORD_RESCUE_MODIFIER
+ comment: "rescue in the modifier form"
+ - name: KEYWORD_RETRY
+ comment: "retry"
+ - name: KEYWORD_RETURN
+ comment: "return"
+ - name: KEYWORD_SELF
+ comment: "self"
+ - name: KEYWORD_SUPER
+ comment: "super"
+ - name: KEYWORD_TRUE
+ comment: "true"
+ - name: KEYWORD_UNDEF
+ comment: "undef"
+ - name: KEYWORD_UNLESS
+ comment: "unless"
+ - name: KEYWORD_UNLESS_MODIFIER
+ comment: "unless in the modifier form"
+ - name: KEYWORD_UNTIL
+ comment: "until"
+ - name: KEYWORD_UNTIL_MODIFIER
+ comment: "until in the modifier form"
+ - name: KEYWORD_WHILE
+ comment: "while"
+ - name: KEYWORD_WHILE_MODIFIER
+ comment: "while in the modifier form"
+ - name: KEYWORD_YIELD
+ comment: "yield"
+ - name: KEYWORD___ENCODING__
+ comment: "__ENCODING__"
+ - name: KEYWORD___FILE__
+ comment: "__FILE__"
+ - name: KEYWORD___LINE__
+ comment: "__LINE__"
+ - name: LABEL
+ comment: "a label"
+ - name: LABEL_END
+ comment: "the end of a label"
+ - name: LAMBDA_BEGIN
+ comment: "{"
+ - name: LESS
+ comment: "<"
+ - name: LESS_EQUAL
+ comment: "<="
+ - name: LESS_EQUAL_GREATER
+ comment: "<=>"
+ - name: LESS_LESS
+ comment: "<<"
+ - name: LESS_LESS_EQUAL
+ comment: "<<="
+ - name: METHOD_NAME
+ comment: "a method name"
+ - name: MINUS
+ comment: "-"
+ - name: MINUS_EQUAL
+ comment: "-="
+ - name: MINUS_GREATER
+ comment: "->"
+ - name: NUMBERED_REFERENCE
+ comment: "a numbered reference to a capture group in the previous regular expression match"
+ - name: PARENTHESIS_LEFT
+ comment: "("
+ - name: PARENTHESIS_LEFT_PARENTHESES
+ comment: "( for a parentheses node"
+ - name: PERCENT
+ comment: "%"
+ - name: PERCENT_EQUAL
+ comment: "%="
+ - name: PERCENT_LOWER_I
+ comment: "%i"
+ - name: PERCENT_LOWER_W
+ comment: "%w"
+ - name: PERCENT_LOWER_X
+ comment: "%x"
+ - name: PERCENT_UPPER_I
+ comment: "%I"
+ - name: PERCENT_UPPER_W
+ comment: "%W"
+ - name: PIPE_EQUAL
+ comment: "|="
+ - name: PIPE_PIPE
+ comment: "||"
+ - name: PIPE_PIPE_EQUAL
+ comment: "||="
+ - name: PLUS
+ comment: "+"
+ - name: PLUS_EQUAL
+ comment: "+="
+ - name: QUESTION_MARK
+ comment: "?"
+ - name: REGEXP_BEGIN
+ comment: "the beginning of a regular expression"
+ - name: REGEXP_END
+ comment: "the end of a regular expression"
+ - name: SLASH
+ comment: "/"
+ - name: SLASH_EQUAL
+ comment: "/="
+ - name: STAR
+ comment: "*"
+ - name: STAR_EQUAL
+ comment: "*="
+ - name: STAR_STAR
+ comment: "**"
+ - name: STAR_STAR_EQUAL
+ comment: "**="
+ - name: STRING_BEGIN
+ comment: "the beginning of a string"
+ - name: STRING_CONTENT
+ comment: "the contents of a string"
+ - name: STRING_END
+ comment: "the end of a string"
+ - name: SYMBOL_BEGIN
+ comment: "the beginning of a symbol"
+ - name: TILDE
+ comment: "~ or ~@"
+ - name: UAMPERSAND
+ comment: "unary &"
+ - name: UCOLON_COLON
+ comment: "unary ::"
+ - name: UDOT_DOT
+ comment: "unary .. operator"
+ - name: UDOT_DOT_DOT
+ comment: "unary ... operator"
+ - name: UMINUS
+ comment: "-@"
+ - name: UMINUS_NUM
+ comment: "-@ for a number"
+ - name: UPLUS
+ comment: "+@"
+ - name: USTAR
+ comment: "unary *"
+ - name: USTAR_STAR
+ comment: "unary **"
+ - name: WORDS_SEP
+ comment: "a separator between words in a list"
+ - name: __END__
+ comment: "marker for the point in the file at which the parser should stop"
+flags:
+ - name: ArgumentsNodeFlags
+ values:
+ - name: CONTAINS_FORWARDING
+ comment: "if the arguments contain forwarding"
+ - name: CONTAINS_KEYWORDS
+ comment: "if the arguments contain keywords"
+ - name: CONTAINS_KEYWORD_SPLAT
+ comment: "if the arguments contain a keyword splat"
+ - name: CONTAINS_SPLAT
+ comment: "if the arguments contain a splat"
+ - name: CONTAINS_MULTIPLE_SPLATS
+ comment: "if the arguments contain multiple splats"
+ comment: Flags for arguments nodes.
+ - name: ArrayNodeFlags
+ values:
+ - name: CONTAINS_SPLAT
+ comment: "if array contains splat nodes"
+ comment: Flags for array nodes.
+ - name: CallNodeFlags
+ values:
+ - name: SAFE_NAVIGATION
+ comment: "&. operator"
+ - name: VARIABLE_CALL
+ comment: "a call that could have been a local variable"
+ - name: ATTRIBUTE_WRITE
+ comment: "a call that is an attribute write, so the value being written should be returned"
+ - name: IGNORE_VISIBILITY
+ comment: "a call that ignores method visibility"
+ comment: Flags for call nodes.
+ - name: EncodingFlags
+ values:
+ - name: FORCED_UTF8_ENCODING
+ comment: "internal bytes forced the encoding to UTF-8"
+ - name: FORCED_BINARY_ENCODING
+ comment: "internal bytes forced the encoding to binary"
+ comment: Flags for nodes that have unescaped content.
+ - name: IntegerBaseFlags
+ values:
+ - name: BINARY
+ comment: "0b prefix"
+ - name: DECIMAL
+ comment: "0d or no prefix"
+ - name: OCTAL
+ comment: "0o or 0 prefix"
+ - name: HEXADECIMAL
+ comment: "0x prefix"
+ comment: Flags for integer nodes that correspond to the base of the integer.
+ - name: InterpolatedStringNodeFlags
+ values:
+ - name: FROZEN
+ comment: "frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'`"
+ - name: MUTABLE
+ comment: "mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`; only for adjacent string literals like `'a' 'b'`"
+ comment: Flags for interpolated string nodes that indicated mutability if they are also marked as literals.
+ - name: KeywordHashNodeFlags
+ values:
+ - name: SYMBOL_KEYS
+ comment: "a keyword hash which only has `AssocNode` elements all with symbol keys, which means the elements can be treated as keyword arguments"
+ comment: Flags for keyword hash nodes.
+ - name: LoopFlags
+ values:
+ - name: BEGIN_MODIFIER
+ comment: "a loop after a begin statement, so the body is executed first before the condition"
+ comment: Flags for while and until loop nodes.
+ - name: ParameterFlags
+ values:
+ - name: REPEATED_PARAMETER
+ comment: "a parameter name that has been repeated in the method signature"
+ comment: Flags for parameter nodes.
+ - name: ParenthesesNodeFlags
+ values:
+ - name: MULTIPLE_STATEMENTS
+ comment: "parentheses that contain multiple potentially void statements"
+ comment: Flags for parentheses nodes.
+ - name: RangeFlags
+ values:
+ - name: EXCLUDE_END
+ comment: "... operator"
+ comment: Flags for range and flip-flop nodes.
+ - name: RegularExpressionFlags
+ values:
+ - name: IGNORE_CASE
+ comment: "i - ignores the case of characters when matching"
+ - name: EXTENDED
+ comment: "x - ignores whitespace and allows comments in regular expressions"
+ - name: MULTI_LINE
+ comment: "m - allows $ to match the end of lines within strings"
+ - name: ONCE
+ comment: "o - only interpolates values into the regular expression once"
+ - name: EUC_JP
+ comment: "e - forces the EUC-JP encoding"
+ - name: ASCII_8BIT
+ comment: "n - forces the ASCII-8BIT encoding"
+ - name: WINDOWS_31J
+ comment: "s - forces the Windows-31J encoding"
+ - name: UTF_8
+ comment: "u - forces the UTF-8 encoding"
+ - name: FORCED_UTF8_ENCODING
+ comment: "internal bytes forced the encoding to UTF-8"
+ - name: FORCED_BINARY_ENCODING
+ comment: "internal bytes forced the encoding to binary"
+ - name: FORCED_US_ASCII_ENCODING
+ comment: "internal bytes forced the encoding to US-ASCII"
+ comment: Flags for regular expression and match last line nodes.
+ - name: ShareableConstantNodeFlags
+ values:
+ - name: LITERAL
+ comment: "constant writes that should be modified with shareable constant value literal"
+ - name: EXPERIMENTAL_EVERYTHING
+ comment: "constant writes that should be modified with shareable constant value experimental everything"
+ - name: EXPERIMENTAL_COPY
+ comment: "constant writes that should be modified with shareable constant value experimental copy"
+ comment: Flags for shareable constant nodes.
+ - name: StringFlags
+ values:
+ - name: FORCED_UTF8_ENCODING
+ comment: "internal bytes forced the encoding to UTF-8"
+ - name: FORCED_BINARY_ENCODING
+ comment: "internal bytes forced the encoding to binary"
+ - name: FROZEN
+ comment: "frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`"
+ - name: MUTABLE
+ comment: "mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`"
+ comment: Flags for string nodes.
+ - name: SymbolFlags
+ values:
+ - name: FORCED_UTF8_ENCODING
+ comment: "internal bytes forced the encoding to UTF-8"
+ - name: FORCED_BINARY_ENCODING
+ comment: "internal bytes forced the encoding to binary"
+ - name: FORCED_US_ASCII_ENCODING
+ comment: "internal bytes forced the encoding to US-ASCII"
+ comment: Flags for symbol nodes.
+nodes:
+ - name: AliasGlobalVariableNode
+ fields:
+ - name: new_name
+ type: node
+ kind:
+ - GlobalVariableReadNode
+ - BackReferenceReadNode
+ - NumberedReferenceReadNode
+ comment: |
+ Represents the new name of the global variable that can be used after aliasing.
+
+ alias $foo $bar
+ ^^^^
+ - name: old_name
+ type: node
+ kind:
+ - GlobalVariableReadNode
+ - BackReferenceReadNode
+ - NumberedReferenceReadNode
+ comment: |
+ Represents the old name of the global variable that can be used before aliasing.
+
+ alias $foo $bar
+ ^^^^
+ - name: keyword_loc
+ type: location
+ comment: |
+ The Location of the `alias` keyword.
+
+ alias $foo $bar
+ ^^^^^
+ comment: |
+ Represents the use of the `alias` keyword to alias a global variable.
+
+ alias $foo $bar
+ ^^^^^^^^^^^^^^^
+ - name: AliasMethodNode
+ fields:
+ - name: new_name
+ type: node
+ kind:
+ - SymbolNode
+ - InterpolatedSymbolNode
+ comment: |
+ Represents the new name of the method that will be aliased.
+
+ alias foo bar
+ ^^^
+
+ alias :foo :bar
+ ^^^^
+
+ alias :"#{foo}" :"#{bar}"
+ ^^^^^^^^^
+ - name: old_name
+ type: node
+ kind:
+ - SymbolNode
+ - InterpolatedSymbolNode
+ comment: |
+ Represents the old name of the method that will be aliased.
+
+ alias foo bar
+ ^^^
+
+ alias :foo :bar
+ ^^^^
+
+ alias :"#{foo}" :"#{bar}"
+ ^^^^^^^^^
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `alias` keyword.
+
+ alias foo bar
+ ^^^^^
+ comment: |
+ Represents the use of the `alias` keyword to alias a method.
+
+ alias foo bar
+ ^^^^^^^^^^^^^
+ - name: AlternationPatternNode
+ fields:
+ - name: left
+ type: node
+ kind: pattern expression
+ comment: |
+ Represents the left side of the expression.
+
+ foo => bar | baz
+ ^^^
+ - name: right
+ type: node
+ kind: pattern expression
+ comment: |
+ Represents the right side of the expression.
+
+ foo => bar | baz
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the alternation operator Location.
+
+ foo => bar | baz
+ ^
+ comment: |
+ Represents an alternation pattern in pattern matching.
+
+ foo => bar | baz
+ ^^^^^^^^^
+ - name: AndNode
+ fields:
+ - name: left
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ left and right
+ ^^^^
+
+ 1 && 2
+ ^
+ - name: right
+ type: node
+ kind: Node
+ comment: |
+ Represents the right side of the expression.
+
+ left && right
+ ^^^^^
+
+ 1 and 2
+ ^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `and` keyword or the `&&` operator.
+
+ left and right
+ ^^^
+ comment: |
+ Represents the use of the `&&` operator or the `and` keyword.
+
+ left and right
+ ^^^^^^^^^^^^^^
+ - name: ArgumentsNode
+ flags: ArgumentsNodeFlags
+ fields:
+ - name: arguments
+ type: node[]
+ kind: non-void expression
+ comment: |
+ The list of arguments, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo(bar, baz)
+ ^^^^^^^^
+ comment: |
+ Represents a set of arguments to a method or a keyword.
+
+ return foo, bar, baz
+ ^^^^^^^^^^^^^
+ - name: ArrayNode
+ flags: ArrayNodeFlags
+ fields:
+ - name: elements
+ type: node[]
+ kind: non-void expression
+ comment: Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array.
+ - name: opening_loc
+ type: location?
+ comment: |
+ Represents the optional source Location for the opening token.
+
+ [1,2,3] # "["
+ %w[foo bar baz] # "%w["
+ %I(apple orange banana) # "%I("
+ foo = 1, 2, 3 # nil
+ - name: closing_loc
+ type: location?
+ comment: |
+ Represents the optional source Location for the closing token.
+
+ [1,2,3] # "]"
+ %w[foo bar baz] # "]"
+ %I(apple orange banana) # ")"
+ foo = 1, 2, 3 # nil
+ comment: |
+ Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
+
+ [1, 2, 3]
+ ^^^^^^^^^
+ - name: ArrayPatternNode
+ fields:
+ - name: constant
+ type: node?
+ kind:
+ - ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the Array
+
+ foo in Bar[]
+ ^^^
+
+ foo in Bar[1, 2, 3]
+ ^^^
+
+ foo in Bar::Baz[1, 2, 3]
+ ^^^^^^^^
+ - name: requireds
+ type: node[]
+ kind: pattern expression
+ comment: |
+ Represents the required elements of the array pattern.
+
+ foo in [1, 2]
+ ^ ^
+ - name: rest
+ type: node?
+ kind:
+ - ImplicitRestNode
+ - SplatNode
+ comment: |
+ Represents the rest element of the array pattern.
+
+ foo in *bar
+ ^^^^
+ - name: posts
+ type: node[]
+ kind: pattern expression
+ comment: |
+ Represents the elements after the rest element of the array pattern.
+
+ foo in *bar, baz
+ ^^^
+ - name: opening_loc
+ type: location?
+ comment: |
+ Represents the opening Location of the array pattern.
+
+ foo in [1, 2]
+ ^
+ - name: closing_loc
+ type: location?
+ comment: |
+ Represents the closing Location of the array pattern.
+
+ foo in [1, 2]
+ ^
+ comment: |
+ Represents an array pattern in pattern matching.
+
+ foo in 1, 2
+ ^^^^
+
+ foo in [1, 2]
+ ^^^^^^
+
+ foo in *bar
+ ^^^^
+
+ foo in Bar[]
+ ^^^^^
+
+ foo in Bar[1, 2, 3]
+ ^^^^^^^^^^^^
+ - name: AssocNode
+ fields:
+ - name: key
+ type: node
+ kind: non-void expression
+ comment: |
+ The key of the association. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ { a: b }
+ ^
+
+ { foo => bar }
+ ^^^
+
+ { def a; end => 1 }
+ ^^^^^^^^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value of the association, if present. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ { foo => bar }
+ ^^^
+
+ { x: 1 }
+ ^
+ - name: operator_loc
+ type: location?
+ comment: |
+ The Location of the `=>` operator, if present.
+
+ { foo => bar }
+ ^^
+ comment: |
+ Represents a hash key/value pair.
+
+ { a => b }
+ ^^^^^^
+ - name: AssocSplatNode
+ fields:
+ - name: value
+ type: node?
+ kind: non-void expression
+ comment: |
+ The value to be splatted, if present. Will be missing when keyword rest argument forwarding is used.
+
+ { **foo }
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `**` operator.
+
+ { **x }
+ ^^
+ comment: |
+ Represents a splat in a hash literal.
+
+ { **foo }
+ ^^^^^
+ - name: BackReferenceReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the back-reference variable, including the leading `$`.
+
+ $& # name `:$&`
+
+ $+ # name `:$+`
+ comment: |
+ Represents reading a reference to a field in the previous match.
+
+ $'
+ ^^
+ - name: BeginNode
+ fields:
+ - name: begin_keyword_loc
+ type: location?
+ comment: |
+ Represents the Location of the `begin` keyword.
+
+ begin x end
+ ^^^^^
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ comment: |
+ Represents the statements within the begin block.
+
+ begin x end
+ ^
+ - name: rescue_clause
+ type: node?
+ kind: RescueNode
+ comment: |
+ Represents the rescue clause within the begin block.
+
+ begin x; rescue y; end
+ ^^^^^^^^
+ - name: else_clause
+ type: node?
+ kind: ElseNode
+ comment: |
+ Represents the else clause within the begin block.
+
+ begin x; rescue y; else z; end
+ ^^^^^^^^^^^
+ - name: ensure_clause
+ type: node?
+ kind: EnsureNode
+ comment: |
+ Represents the ensure clause within the begin block.
+
+ begin x; ensure y; end
+ ^^^^^^^^
+ - name: end_keyword_loc
+ type: location?
+ comment: |
+ Represents the Location of the `end` keyword.
+
+ begin x end
+ ^^^
+ newline: false
+ comment: |
+ Represents a begin statement.
+
+ begin
+ foo
+ end
+ ^^^^^
+ - name: BlockArgumentNode
+ fields:
+ - name: expression
+ type: node?
+ kind: non-void expression
+ comment: |
+ The expression that is being passed as a block argument. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo(&args)
+ ^^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the `&` operator.
+
+ foo(&args)
+ ^
+ comment: |
+ Represents a block argument using `&`.
+
+ bar(&args)
+ ^^^^^
+ - name: BlockLocalVariableNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the block local variable.
+
+ a { |; b| } # name `:b`
+ ^
+ comment: |
+ Represents a block local variable.
+
+ a { |; b| }
+ ^
+ - name: BlockNode
+ fields:
+ - name: locals
+ type: constant[]
+ comment: |
+ The local variables declared in the block.
+
+ [1, 2, 3].each { |i| puts x } # locals: [:i]
+ ^
+ - name: parameters
+ type: node?
+ kind:
+ - BlockParametersNode
+ - NumberedParametersNode
+ - ItParametersNode
+ comment: |
+ The parameters of the block.
+
+ [1, 2, 3].each { |i| puts x }
+ ^^^
+ [1, 2, 3].each { puts _1 }
+ ^^^^^^^^^^^
+ [1, 2, 3].each { puts it }
+ ^^^^^^^^^^^
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ comment: |
+ The body of the block.
+
+ [1, 2, 3].each { |i| puts x }
+ ^^^^^^
+ - name: opening_loc
+ type: location
+ comment: |
+ Represents the Location of the opening `{` or `do`.
+
+ [1, 2, 3].each { |i| puts x }
+ ^
+ - name: closing_loc
+ type: location
+ comment: |
+ Represents the Location of the closing `}` or `end`.
+
+ [1, 2, 3].each { |i| puts x }
+ ^
+ comment: |
+ Represents a block of ruby code.
+
+ [1, 2, 3].each { |i| puts x }
+ ^^^^^^^^^^^^^^
+ - name: BlockParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant?
+ comment: |
+ The name of the block parameter.
+
+ def a(&b) # name `:b`
+ ^
+ end
+ - name: name_loc
+ type: location?
+ comment: |
+ Represents the Location of the block parameter name.
+
+ def a(&b)
+ ^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the `&` operator.
+
+ def a(&b)
+ ^
+ end
+ comment: |
+ Represents a block parameter of a method, block, or lambda definition.
+
+ def a(&b)
+ ^^
+ end
+ - name: BlockParametersNode
+ fields:
+ - name: parameters
+ type: node?
+ kind: ParametersNode
+ comment: |
+ Represents the parameters of the block.
+
+ -> (a, b = 1; local) { }
+ ^^^^^^^^
+
+ foo do |a, b = 1; local|
+ ^^^^^^^^
+ end
+ - name: locals
+ type: node[]
+ kind: BlockLocalVariableNode
+ comment: |
+ Represents the local variables of the block.
+
+ -> (a, b = 1; local) { }
+ ^^^^^
+
+ foo do |a, b = 1; local|
+ ^^^^^
+ end
+ - name: opening_loc
+ type: location?
+ comment: |
+ Represents the opening Location of the block parameters.
+
+ -> (a, b = 1; local) { }
+ ^
+
+ foo do |a, b = 1; local|
+ ^
+ end
+ - name: closing_loc
+ type: location?
+ comment: |
+ Represents the closing Location of the block parameters.
+
+ -> (a, b = 1; local) { }
+ ^
+
+ foo do |a, b = 1; local|
+ ^
+ end
+ comment: |
+ Represents a block's parameters declaration.
+
+ -> (a, b = 1; local) { }
+ ^^^^^^^^^^^^^^^^^
+
+ foo do |a, b = 1; local|
+ ^^^^^^^^^^^^^^^^^
+ end
+ - name: BreakNode
+ fields:
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ comment: |
+ The arguments to the break statement, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ break foo
+ ^^^
+ - name: keyword_loc
+ type: location
+ comment: |
+ The Location of the `break` keyword.
+
+ break foo
+ ^^^^^
+ comment: |
+ Represents the use of the `break` keyword.
+
+ break foo
+ ^^^^^^^^^
+ - name: CallAndWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ comment: |
+ The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo.bar &&= value
+ ^^^
+ - name: call_operator_loc
+ type: location?
+ comment: |
+ Represents the Location of the call operator.
+
+ foo.bar &&= value
+ ^
+ - name: message_loc
+ type: location?
+ comment: |
+ Represents the Location of the message.
+
+ foo.bar &&= value
+ ^^^
+ - name: read_name
+ type: constant
+ comment: |
+ Represents the name of the method being called.
+
+ foo.bar &&= value # read_name `:bar`
+ ^^^
+ - name: write_name
+ type: constant
+ comment: |
+ Represents the name of the method being written to.
+
+ foo.bar &&= value # write_name `:bar=`
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the operator.
+
+ foo.bar &&= value
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the value being assigned.
+
+ foo.bar &&= value
+ ^^^^^
+ comment: |
+ Represents the use of the `&&=` operator on a call.
+
+ foo.bar &&= value
+ ^^^^^^^^^^^^^^^^^
+ - name: CallNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ comment: |
+ The object that the method is being called on. This can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo.bar
+ ^^^
+
+ +foo
+ ^^^
+
+ foo + bar
+ ^^^
+ - name: call_operator_loc
+ type: location?
+ comment: |
+ Represents the Location of the call operator.
+
+ foo.bar
+ ^
+
+ foo&.bar
+ ^^
+ - name: name
+ type: constant
+ comment: |
+ Represents the name of the method being called.
+
+ foo.bar # name `:foo`
+ ^^^
+ - name: message_loc
+ type: location?
+ comment: |
+ Represents the Location of the message.
+
+ foo.bar
+ ^^^
+ - name: opening_loc
+ type: location?
+ comment: |
+ Represents the Location of the left parenthesis.
+
+ foo(bar)
+ ^
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ comment: |
+ Represents the arguments to the method call. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo(bar)
+ ^^^
+ - name: closing_loc
+ type: location?
+ comment: |
+ Represents the Location of the right parenthesis.
+
+ foo(bar)
+ ^
+ - name: equal_loc
+ type: location?
+ comment: |
+ Represents the Location of the equal sign, in the case that this is an attribute write.
+
+ foo.bar = value
+ ^
+
+ foo[bar] = value
+ ^
+ - name: block
+ type: node?
+ kind:
+ - BlockNode
+ - BlockArgumentNode
+ comment: |
+ Represents the block that is being passed to the method.
+
+ foo { |a| a }
+ ^^^^^^^^^
+ comment: |
+ Represents a method call, in all of the various forms that can take.
+
+ foo
+ ^^^
+
+ foo()
+ ^^^^^
+
+ +foo
+ ^^^^
+
+ foo + bar
+ ^^^^^^^^^
+
+ foo.bar
+ ^^^^^^^
+
+ foo&.bar
+ ^^^^^^^^
+ - name: CallOperatorWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ comment: |
+ The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo.bar += value
+ ^^^
+ - name: call_operator_loc
+ type: location?
+ comment: |
+ Represents the Location of the call operator.
+
+ foo.bar += value
+ ^
+ - name: message_loc
+ type: location?
+ comment: |
+ Represents the Location of the message.
+
+ foo.bar += value
+ ^^^
+ - name: read_name
+ type: constant
+ comment: |
+ Represents the name of the method being called.
+
+ foo.bar += value # read_name `:bar`
+ ^^^
+ - name: write_name
+ type: constant
+ comment: |
+ Represents the name of the method being written to.
+
+ foo.bar += value # write_name `:bar=`
+ ^^^
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents the binary operator being used.
+
+ foo.bar += value # binary_operator `:+`
+ ^
+ - name: binary_operator_loc
+ type: location
+ comment: |
+ Represents the Location of the binary operator.
+
+ foo.bar += value
+ ^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the value being assigned.
+
+ foo.bar += value
+ ^^^^^
+ comment: |
+ Represents the use of an assignment operator on a call.
+
+ foo.bar += baz
+ ^^^^^^^^^^^^^^
+ - name: CallOrWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ comment: |
+ The object that the method is being called on. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo.bar ||= value
+ ^^^
+ - name: call_operator_loc
+ type: location?
+ comment: |
+ Represents the Location of the call operator.
+
+ foo.bar ||= value
+ ^
+ - name: message_loc
+ type: location?
+ comment: |
+ Represents the Location of the message.
+
+ foo.bar ||= value
+ ^^^
+ - name: read_name
+ type: constant
+ comment: |
+ Represents the name of the method being called.
+
+ foo.bar ||= value # read_name `:bar`
+ ^^^
+ - name: write_name
+ type: constant
+ comment: |
+ Represents the name of the method being written to.
+
+ foo.bar ||= value # write_name `:bar=`
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the operator.
+
+ foo.bar ||= value
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the value being assigned.
+
+ foo.bar ||= value
+ ^^^^^
+ comment: |
+ Represents the use of the `||=` operator on a call.
+
+ foo.bar ||= value
+ ^^^^^^^^^^^^^^^^^
+ - name: CallTargetNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node
+ kind: non-void expression
+ comment: |
+ The object that the method is being called on. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo.bar = 1
+ ^^^
+ - name: call_operator_loc
+ type: location
+ comment: |
+ Represents the Location of the call operator.
+
+ foo.bar = 1
+ ^
+ - name: name
+ type: constant
+ comment: |
+ Represents the name of the method being called.
+
+ foo.bar = 1 # name `:foo`
+ ^^^
+ - name: message_loc
+ type: location
+ comment: |
+ Represents the Location of the message.
+
+ foo.bar = 1
+ ^^^
+ comment: |
+ Represents assigning to a method call.
+
+ foo.bar, = 1
+ ^^^^^^^
+
+ begin
+ rescue => foo.bar
+ ^^^^^^^
+ end
+
+ for foo.bar in baz do end
+ ^^^^^^^
+ - name: CapturePatternNode
+ fields:
+ - name: value
+ type: node
+ kind: pattern expression
+ comment: |
+ Represents the value to capture.
+
+ foo => bar
+ ^^^
+ - name: target
+ type: node
+ kind: LocalVariableTargetNode
+ comment: |
+ Represents the target of the capture.
+
+ foo => bar
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the `=>` operator.
+
+ foo => bar
+ ^^
+ comment: |
+ Represents assigning to a local variable in pattern matching.
+
+ foo => [bar => baz]
+ ^^^^^^^^^^
+ - name: CaseMatchNode
+ fields:
+ - name: predicate
+ type: node?
+ kind: non-void expression
+ comment: |
+ Represents the predicate of the case match. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ case true; in false; end
+ ^^^^
+ - name: conditions
+ type: node[]
+ kind: InNode
+ comment: |
+ Represents the conditions of the case match.
+
+ case true; in false; end
+ ^^^^^^^^
+ - name: else_clause
+ type: node?
+ kind: ElseNode
+ comment: |
+ Represents the else clause of the case match.
+
+ case true; in false; else; end
+ ^^^^^^^^^
+ - name: case_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `case` keyword.
+
+ case true; in false; end
+ ^^^^
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `end` keyword.
+
+ case true; in false; end
+ ^^^
+ comment: |
+ Represents the use of a case statement for pattern matching.
+
+ case true
+ in false
+ end
+ ^^^^^^^^^
+ - name: CaseNode
+ fields:
+ - name: predicate
+ type: node?
+ kind: non-void expression
+ comment: |
+ Represents the predicate of the case statement. This can be either `nil` or any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ case true; when false; end
+ ^^^^
+ - name: conditions
+ type: node[]
+ kind: WhenNode
+ comment: |
+ Represents the conditions of the case statement.
+
+ case true; when false; end
+ ^^^^^^^^^^
+ - name: else_clause
+ type: node?
+ kind: ElseNode
+ comment: |
+ Represents the else clause of the case statement.
+
+ case true; when false; else; end
+ ^^^^^^^^^
+ - name: case_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `case` keyword.
+
+ case true; when false; end
+ ^^^^
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `end` keyword.
+
+ case true; when false; end
+ ^^^
+ comment: |
+ Represents the use of a case statement.
+
+ case true
+ when false
+ end
+ ^^^^^^^^^^
+ - name: ClassNode
+ fields:
+ - name: locals
+ type: constant[]
+ - name: class_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `class` keyword.
+
+ class Foo end
+ ^^^^^
+ - name: constant_path
+ type: node
+ kind:
+ - ConstantReadNode
+ - ConstantPathNode
+ - name: inheritance_operator_loc
+ type: location?
+ comment: |
+ Represents the Location of the `<` operator.
+
+ class Foo < Bar
+ ^
+ - name: superclass
+ type: node?
+ kind: non-void expression
+ comment: |
+ Represents the superclass of the class.
+
+ class Foo < Bar
+ ^^^
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ comment: |
+ Represents the body of the class.
+
+ class Foo; bar; end
+ ^^^
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ Represents the Location of the `end` keyword.
+
+ class Foo end
+ ^^^
+ - name: name
+ type: constant
+ comment: |
+ The name of the class.
+
+ class Foo end # name `:Foo`
+ comment: |
+ Represents a class declaration involving the `class` keyword.
+
+ class Foo end
+ ^^^^^^^^^^^^^
+ - name: ClassVariableAndWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ @@target &&= value # name `:@@target`
+ ^^^^^^^^
+ - name: name_loc
+ type: location
+ comment: |
+ Represents the Location of the variable name.
+
+ @@target &&= value
+ ^^^^^^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the Location of the `&&=` operator.
+
+ @@target &&= value
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the value being assigned. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ @@target &&= value
+ ^^^^^
+ comment: |
+ Represents the use of the `&&=` operator for assignment to a class variable.
+
+ @@target &&= value
+ ^^^^^^^^^^^^^^^^^^
+ - name: ClassVariableOperatorWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents assigning to a class variable using an operator that isn't `=`.
+
+ @@target += value
+ ^^^^^^^^^^^^^^^^^
+ - name: ClassVariableOrWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator for assignment to a class variable.
+
+ @@target ||= value
+ ^^^^^^^^^^^^^^^^^^
+ - name: ClassVariableReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ @@abc # name `:@@abc`
+
+ @@_test # name `:@@_test`
+ comment: |
+ Represents referencing a class variable.
+
+ @@foo
+ ^^^^^
+ - name: ClassVariableTargetNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ Represents writing to a class variable in a context that doesn't have an explicit value.
+
+ @@foo, @@bar = baz
+ ^^^^^ ^^^^^
+ - name: ClassVariableWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ @@abc = 123 # name `@@abc`
+
+ @@_test = :test # name `@@_test`
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the variable name.
+
+ @@foo = :bar
+ ^^^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the class variable. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ @@foo = :bar
+ ^^^^
+
+ @@_xyz = 123
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ @@foo = :bar
+ ^
+ comment: |
+ Represents writing to a class variable.
+
+ @@foo = 1
+ ^^^^^^^^^
+ - name: ConstantAndWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `&&=` operator for assignment to a constant.
+
+ Target &&= value
+ ^^^^^^^^^^^^^^^^
+ - name: ConstantOperatorWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents assigning to a constant using an operator that isn't `=`.
+
+ Target += value
+ ^^^^^^^^^^^^^^^
+ - name: ConstantOrWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator for assignment to a constant.
+
+ Target ||= value
+ ^^^^^^^^^^^^^^^^
+ - name: ConstantPathAndWriteNode
+ fields:
+ - name: target
+ type: node
+ kind: ConstantPathNode
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `&&=` operator for assignment to a constant path.
+
+ Parent::Child &&= value
+ ^^^^^^^^^^^^^^^^^^^^^^^
+ - name: ConstantPathNode
+ fields:
+ - name: parent
+ type: node?
+ kind: non-void expression
+ comment: |
+ The left-hand node of the path, if present. It can be `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). It will be `nil` when the constant lookup is at the root of the module tree.
+
+ Foo::Bar
+ ^^^
+
+ self::Test
+ ^^^^
+
+ a.b::C
+ ^^^
+ - name: name
+ type: constant?
+ comment: The name of the constant being accessed. This could be `nil` in the event of a syntax error.
+ - name: delimiter_loc
+ type: location
+ comment: |
+ The Location of the `::` delimiter.
+
+ ::Foo
+ ^^
+
+ One::Two
+ ^^
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the name of the constant.
+
+ ::Foo
+ ^^^
+
+ One::Two
+ ^^^
+ comment: |
+ Represents accessing a constant through a path of `::` operators.
+
+ Foo::Bar
+ ^^^^^^^^
+ - name: ConstantPathOperatorWriteNode
+ fields:
+ - name: target
+ type: node
+ kind: ConstantPathNode
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents assigning to a constant path using an operator that isn't `=`.
+
+ Parent::Child += value
+ ^^^^^^^^^^^^^^^^^^^^^^
+ - name: ConstantPathOrWriteNode
+ fields:
+ - name: target
+ type: node
+ kind: ConstantPathNode
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator for assignment to a constant path.
+
+ Parent::Child ||= value
+ ^^^^^^^^^^^^^^^^^^^^^^^
+ - name: ConstantPathTargetNode
+ fields:
+ - name: parent
+ type: node?
+ kind: non-void expression
+ - name: name
+ type: constant?
+ - name: delimiter_loc
+ type: location
+ - name: name_loc
+ type: location
+ comment: |
+ Represents writing to a constant path in a context that doesn't have an explicit value.
+
+ Foo::Foo, Bar::Bar = baz
+ ^^^^^^^^ ^^^^^^^^
+ - name: ConstantPathWriteNode
+ fields:
+ - name: target
+ type: node
+ kind: ConstantPathNode
+ comment: |
+ A node representing the constant path being written to.
+
+ Foo::Bar = 1
+ ^^^^^^^^
+
+ ::Foo = :abc
+ ^^^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ ::ABC = 123
+ ^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the constant path. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ FOO::BAR = :abc
+ ^^^^
+ comment: |
+ Represents writing to a constant path.
+
+ ::Foo = 1
+ ^^^^^^^^^
+
+ Foo::Bar = 1
+ ^^^^^^^^^^^^
+
+ ::Foo::Bar = 1
+ ^^^^^^^^^^^^^^
+ - name: ConstantReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
+
+ X # name `:X`
+
+ SOME_CONSTANT # name `:SOME_CONSTANT`
+ comment: |
+ Represents referencing a constant.
+
+ Foo
+ ^^^
+ - name: ConstantTargetNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ Represents writing to a constant in a context that doesn't have an explicit value.
+
+ Foo, Bar = baz
+ ^^^ ^^^
+ - name: ConstantWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
+
+ Foo = :bar # name `:Foo`
+
+ XYZ = 1 # name `:XYZ`
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the constant name.
+
+ FOO = 1
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the constant. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ FOO = :bar
+ ^^^^
+
+ MyClass = Class.new
+ ^^^^^^^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ FOO = :bar
+ ^
+ comment: |
+ Represents writing to a constant.
+
+ Foo = 1
+ ^^^^^^^
+ - name: DefNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ - name: parameters
+ type: node?
+ kind: ParametersNode
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ - name: locals
+ type: constant[]
+ - name: def_keyword_loc
+ type: location
+ - name: operator_loc
+ type: location?
+ - name: lparen_loc
+ type: location?
+ - name: rparen_loc
+ type: location?
+ - name: equal_loc
+ type: location?
+ - name: end_keyword_loc
+ type: location?
+ comment: |
+ Represents a method definition.
+
+ def method
+ end
+ ^^^^^^^^^^
+ - name: DefinedNode
+ fields:
+ - name: lparen_loc
+ type: location?
+ - name: value
+ type: node
+ kind: Node # More than non-void expression as defined?(return) is allowed, yet defined?(BEGIN{}) is SyntaxError
+ - name: rparen_loc
+ type: location?
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of the `defined?` keyword.
+
+ defined?(a)
+ ^^^^^^^^^^^
+ - name: ElseNode
+ fields:
+ - name: else_keyword_loc
+ type: location
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: end_keyword_loc
+ type: location?
+ comment: |
+ Represents an `else` clause in a `case`, `if`, or `unless` statement.
+
+ if a then b else c end
+ ^^^^^^^^^^
+ - name: EmbeddedStatementsNode
+ fields:
+ - name: opening_loc
+ type: location
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: closing_loc
+ type: location
+ comment: |
+ Represents an interpolated set of statements.
+
+ "foo #{bar}"
+ ^^^^^^
+ - name: EmbeddedVariableNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: variable
+ type: node
+ kind:
+ - InstanceVariableReadNode
+ - ClassVariableReadNode
+ - GlobalVariableReadNode
+ - BackReferenceReadNode
+ - NumberedReferenceReadNode
+ comment: |
+ Represents an interpolated variable.
+
+ "foo #@bar"
+ ^^^^^
+ - name: EnsureNode
+ fields:
+ - name: ensure_keyword_loc
+ type: location
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ Represents an `ensure` clause in a `begin` statement.
+
+ begin
+ foo
+ ensure
+ ^^^^^^
+ bar
+ end
+ - name: ErrorRecoveryNode
+ fields:
+ - name: unexpected
+ type: node?
+ kind: Node
+ comment: |
+ The unexpected node that was found in the tree, if there was one.
+ comment: |
+ Represents a node that is either missing or unexpected and results in a syntax error.
+ - name: FalseNode
+ comment: |
+ Represents the use of the literal `false` keyword.
+
+ false
+ ^^^^^
+ - name: FindPatternNode
+ fields:
+ - name: constant
+ type: node?
+ kind:
+ - ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the pattern
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^
+ - name: left
+ type: node
+ kind: SplatNode
+ comment: |
+ Represents the first wildcard node in the pattern.
+
+ foo in *bar, baz, *qux
+ ^^^^
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^^
+ - name: requireds
+ type: node[]
+ kind: pattern expression
+ comment: |
+ Represents the nodes in between the wildcards.
+
+ foo in *bar, baz, *qux
+ ^^^
+
+ foo in Foo(*bar, baz, 1, *qux)
+ ^^^^^^
+ - name: right
+ type: node
+ kind: SplatNode
+ comment: |
+ Represents the second wildcard node in the pattern.
+
+ foo in *bar, baz, *qux
+ ^^^^
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^^
+ - name: opening_loc
+ type: location?
+ comment: |
+ The Location of the opening brace.
+
+ foo in [*bar, baz, *qux]
+ ^
+
+ foo in Foo(*bar, baz, *qux)
+ ^
+ - name: closing_loc
+ type: location?
+ comment: |
+ The Location of the closing brace.
+
+ foo in [*bar, baz, *qux]
+ ^
+
+ foo in Foo(*bar, baz, *qux)
+ ^
+ comment: |
+ Represents a find pattern in pattern matching.
+
+ foo in *bar, baz, *qux
+ ^^^^^^^^^^^^^^^
+
+ foo in [*bar, baz, *qux]
+ ^^^^^^^^^^^^^^^^^
+
+ foo in Foo(*bar, baz, *qux)
+ ^^^^^^^^^^^^^^^^^^^^
+
+ foo => *bar, baz, *qux
+ ^^^^^^^^^^^^^^^
+ - name: FlipFlopNode
+ flags: RangeFlags
+ fields:
+ - name: left
+ type: node?
+ kind: non-void expression
+ - name: right
+ type: node?
+ kind: non-void expression
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the use of the `..` or `...` operators to create flip flops.
+
+ baz if foo .. bar
+ ^^^^^^^^^^
+ - name: FloatNode
+ fields:
+ - name: value
+ type: double
+ comment: The value of the floating point number as a Float.
+ comment: |
+ Represents a floating point number literal.
+
+ 1.0
+ ^^^
+ - name: ForNode
+ fields:
+ - name: index
+ type: node
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - MultiTargetNode
+ comment: |
+ The index expression for `for` loops.
+
+ for i in a end
+ ^
+ - name: collection
+ type: node
+ kind: non-void expression
+ comment: |
+ The collection to iterate over.
+
+ for i in a end
+ ^
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ comment: |
+ Represents the body of statements to execute for each iteration of the loop.
+
+ for i in a
+ foo(i)
+ ^^^^^^
+ end
+ - name: for_keyword_loc
+ type: location
+ comment: |
+ The Location of the `for` keyword.
+
+ for i in a end
+ ^^^
+ - name: in_keyword_loc
+ type: location
+ comment: |
+ The Location of the `in` keyword.
+
+ for i in a end
+ ^^
+ - name: do_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `do` keyword, if present.
+
+ for i in a do end
+ ^^
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ The Location of the `end` keyword.
+
+ for i in a end
+ ^^^
+ comment: |
+ Represents the use of the `for` keyword.
+
+ for i in a end
+ ^^^^^^^^^^^^^^
+ - name: ForwardingArgumentsNode
+ comment: |
+ Represents forwarding all arguments to this method to another method.
+
+ def foo(...)
+ bar(...)
+ ^^^
+ end
+ - name: ForwardingParameterNode
+ comment: |
+ Represents the use of the forwarding parameter in a method, block, or lambda declaration.
+
+ def foo(...)
+ ^^^
+ end
+ - name: ForwardingSuperNode
+ fields:
+ - name: keyword_loc
+ type: location
+ comment: |
+ super
+ ^^^^^
+
+ super { 123 }
+ ^^^^^
+ - name: block
+ type: node?
+ kind: BlockNode
+ comment: |
+ All other arguments are forwarded as normal, except the original block is replaced with the new block.
+ comment: |
+ Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
+
+ super
+ ^^^^^
+
+ super { 123 }
+ ^^^^^^^^^^^^^
+
+ If it has any other arguments, it would be a `SuperNode` instead.
+ - name: GlobalVariableAndWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `&&=` operator for assignment to a global variable.
+
+ $target &&= value
+ ^^^^^^^^^^^^^^^^^
+ - name: GlobalVariableOperatorWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents assigning to a global variable using an operator that isn't `=`.
+
+ $target += value
+ ^^^^^^^^^^^^^^^^
+ - name: GlobalVariableOrWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator for assignment to a global variable.
+
+ $target ||= value
+ ^^^^^^^^^^^^^^^^^
+ - name: GlobalVariableReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
+
+ $foo # name `:$foo`
+
+ $_Test # name `:$_Test`
+ comment: |
+ Represents referencing a global variable.
+
+ $foo
+ ^^^^
+ - name: GlobalVariableTargetNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ Represents writing to a global variable in a context that doesn't have an explicit value.
+
+ $foo, $bar = baz
+ ^^^^ ^^^^
+ - name: GlobalVariableWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
+
+ $foo = :bar # name `:$foo`
+
+ $_Test = 123 # name `:$_Test`
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the global variable's name.
+
+ $foo = :bar
+ ^^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the global variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ $foo = :bar
+ ^^^^
+
+ $-xyz = 123
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ $foo = :bar
+ ^
+ comment: |
+ Represents writing to a global variable.
+
+ $foo = 1
+ ^^^^^^^^
+ - name: HashNode
+ fields:
+ - name: opening_loc
+ type: location
+ comment: |
+ The Location of the opening brace.
+
+ { a => b }
+ ^
+ - name: elements
+ type: node[]
+ kind:
+ - AssocNode
+ - AssocSplatNode
+ comment: |
+ The elements of the hash. These can be either `AssocNode`s or `AssocSplatNode`s.
+
+ { a: b }
+ ^^^^
+
+ { **foo }
+ ^^^^^
+ - name: closing_loc
+ type: location
+ comment: |
+ The Location of the closing brace.
+
+ { a => b }
+ ^
+ comment: |
+ Represents a hash literal.
+
+ { a => b }
+ ^^^^^^^^^^
+ - name: HashPatternNode
+ fields:
+ - name: constant
+ type: node?
+ kind:
+ - ConstantPathNode
+ - ConstantReadNode
+ comment: |
+ Represents the optional constant preceding the Hash.
+
+ foo => Bar[a: 1, b: 2]
+ ^^^
+
+ foo => Bar::Baz[a: 1, b: 2]
+ ^^^^^^^^
+ - name: elements
+ type: node[]
+ kind: AssocNode
+ comment: |
+ Represents the explicit named hash keys and values.
+
+ foo => { a: 1, b:, ** }
+ ^^^^^^^^
+ - name: rest
+ type: node?
+ kind:
+ - AssocSplatNode
+ - NoKeywordsParameterNode
+ comment: |
+ Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via `**nil`, this last one results in a `NoKeywordsParameterNode`.
+
+ foo => { a: 1, b:, **c }
+ ^^^
+
+ foo => { a: 1, b:, ** }
+ ^^
+
+ foo => { a: 1, b:, **nil }
+ ^^^^^
+ - name: opening_loc
+ type: location?
+ comment: |
+ The Location of the opening brace.
+
+ foo => { a: 1 }
+ ^
+
+ foo => Bar[a: 1]
+ ^
+ - name: closing_loc
+ type: location?
+ comment: |
+ The Location of the closing brace.
+
+ foo => { a: 1 }
+ ^
+
+ foo => Bar[a: 1]
+ ^
+ comment: |
+ Represents a hash pattern in pattern matching.
+
+ foo => { a: 1, b: 2 }
+ ^^^^^^^^^^^^^^
+
+ foo => { a: 1, b: 2, **c }
+ ^^^^^^^^^^^^^^^^^^^
+
+ foo => Bar[a: 1, b: 2]
+ ^^^^^^^^^^^^^^^
+
+ foo in { a: 1, b: 2 }
+ ^^^^^^^^^^^^^^
+ - name: IfNode
+ fields:
+ - name: if_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `if` keyword if present.
+
+ bar if foo
+ ^^
+
+ The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression.
+ - name: predicate
+ type: node
+ kind: non-void expression
+ comment: |
+ The node for the condition the `IfNode` is testing.
+
+ if foo
+ ^^^
+ bar
+ end
+
+ bar if foo
+ ^^^
+
+ foo ? bar : baz
+ ^^^
+ - name: then_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
+
+ if foo then bar end
+ ^^^^
+
+ a ? b : c
+ ^
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ comment: |
+ Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided.
+
+ if foo
+ bar
+ ^^^
+ baz
+ ^^^
+ end
+ - name: subsequent
+ type: node?
+ kind:
+ - ElseNode
+ - IfNode
+ comment: |
+ Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
+
+ if foo
+ bar
+ elsif baz
+ ^^^^^^^^^
+ qux
+ ^^^
+ end
+ ^^^
+
+ if foo then bar else baz end
+ ^^^^^^^^^^^^
+ - name: end_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `end` keyword if present, `nil` otherwise.
+
+ if foo
+ bar
+ end
+ ^^^
+ newline: predicate
+ comment: |
+ Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression.
+
+ bar if foo
+ ^^^^^^^^^^
+
+ if foo then bar end
+ ^^^^^^^^^^^^^^^^^^^
+
+ foo ? bar : baz
+ ^^^^^^^^^^^^^^^
+ - name: ImaginaryNode
+ fields:
+ - name: numeric
+ type: node
+ kind:
+ - FloatNode
+ - IntegerNode
+ - RationalNode
+ comment: |
+ Represents an imaginary number literal.
+
+ 1.0i
+ ^^^^
+ - name: ImplicitNode
+ fields:
+ - name: value
+ type: node
+ kind:
+ - LocalVariableReadNode
+ - CallNode
+ - ConstantReadNode
+ - LocalVariableTargetNode
+ comment: |
+ Represents a node that is implicitly being added to the tree but doesn't correspond directly to a node in the source.
+
+ { foo: }
+ ^^^^
+
+ { Foo: }
+ ^^^^
+
+ foo in { bar: }
+ ^^^^
+ - name: ImplicitRestNode
+ comment: |
+ Represents using a trailing comma to indicate an implicit rest parameter.
+
+ foo { |bar,| }
+ ^
+
+ foo in [bar,]
+ ^
+
+ for foo, in bar do end
+ ^
+
+ foo, = bar
+ ^
+ - name: InNode
+ fields:
+ - name: pattern
+ type: node
+ kind: pattern expression
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: in_loc
+ type: location
+ - name: then_loc
+ type: location?
+ comment: |
+ Represents the use of the `in` keyword in a case statement.
+
+ case a; in b then c end
+ ^^^^^^^^^^^
+ - name: IndexAndWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ - name: call_operator_loc
+ type: location?
+ - name: opening_loc
+ type: location
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: closing_loc
+ type: location
+ - name: block
+ type: node?
+ kind: BlockArgumentNode # foo[&b] &&= value, only valid on Ruby < 3.4
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `&&=` operator on a call to the `[]` method.
+
+ foo.bar[baz] &&= value
+ ^^^^^^^^^^^^^^^^^^^^^^
+ - name: IndexOperatorWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ - name: call_operator_loc
+ type: location?
+ - name: opening_loc
+ type: location
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: closing_loc
+ type: location
+ - name: block
+ type: node?
+ kind: BlockArgumentNode # foo[&b] += value, only valid on Ruby < 3.4
+ - name: binary_operator
+ type: constant
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of an assignment operator on a call to `[]`.
+
+ foo.bar[baz] += value
+ ^^^^^^^^^^^^^^^^^^^^^
+ - name: IndexOrWriteNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node?
+ kind: non-void expression
+ - name: call_operator_loc
+ type: location?
+ - name: opening_loc
+ type: location
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: closing_loc
+ type: location
+ - name: block
+ type: node?
+ kind: BlockArgumentNode # foo[&b] ||= value, only valid on Ruby < 3.4
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator on a call to `[]`.
+
+ foo.bar[baz] ||= value
+ ^^^^^^^^^^^^^^^^^^^^^^
+ - name: IndexTargetNode
+ flags: CallNodeFlags
+ fields:
+ - name: receiver
+ type: node
+ kind: non-void expression
+ - name: opening_loc
+ type: location
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: closing_loc
+ type: location
+ - name: block
+ type: node?
+ kind: BlockArgumentNode # foo[&b], = 1, only valid on Ruby < 3.4
+ comment: |
+ Represents assigning to an index.
+
+ foo[bar], = 1
+ ^^^^^^^^
+
+ begin
+ rescue => foo[bar]
+ ^^^^^^^^
+ end
+
+ for foo[bar] in baz do end
+ ^^^^^^^^
+ - name: InstanceVariableAndWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `&&=` operator for assignment to an instance variable.
+
+ @target &&= value
+ ^^^^^^^^^^^^^^^^^
+ - name: InstanceVariableOperatorWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: binary_operator
+ type: constant
+ comment: |
+ Represents assigning to an instance variable using an operator that isn't `=`.
+
+ @target += value
+ ^^^^^^^^^^^^^^^^
+ - name: InstanceVariableOrWriteNode
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the use of the `||=` operator for assignment to an instance variable.
+
+ @target ||= value
+ ^^^^^^^^^^^^^^^^^
+ - name: InstanceVariableReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ @x # name `:@x`
+
+ @_test # name `:@_test`
+ comment: |
+ Represents referencing an instance variable.
+
+ @foo
+ ^^^^
+ - name: InstanceVariableTargetNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ Represents writing to an instance variable in a context that doesn't have an explicit value.
+
+ @foo, @bar = baz
+ ^^^^ ^^^^
+ - name: InstanceVariableWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the instance variable, which is a `@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ @x = :y # name `:@x`
+
+ @_foo = "bar" # name `@_foo`
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the variable name.
+
+ @_x = 1
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the instance variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ @foo = :bar
+ ^^^^
+
+ @_x = 1234
+ ^^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ @x = y
+ ^
+ comment: |
+ Represents writing to an instance variable.
+
+ @foo = 1
+ ^^^^^^^^
+ - name: IntegerNode
+ flags: IntegerBaseFlags
+ fields:
+ - name: value
+ type: integer
+ comment: The value of the integer literal as a number.
+ comment: |
+ Represents an integer number literal.
+
+ 1
+ ^
+ - name: InterpolatedMatchLastLineNode
+ flags: RegularExpressionFlags
+ fields:
+ - name: opening_loc
+ type: location
+ - name: parts
+ type: node[]
+ kind:
+ - StringNode
+ - EmbeddedStatementsNode
+ - EmbeddedVariableNode
+ - name: closing_loc
+ type: location
+ newline: parts
+ comment: |
+ Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO object.
+
+ if /foo #{bar} baz/ then end
+ ^^^^^^^^^^^^^^^^
+ - name: InterpolatedRegularExpressionNode
+ flags: RegularExpressionFlags
+ fields:
+ - name: opening_loc
+ type: location
+ - name: parts
+ type: node[]
+ kind:
+ - StringNode
+ - EmbeddedStatementsNode
+ - EmbeddedVariableNode
+ - name: closing_loc
+ type: location
+ newline: parts
+ comment: |
+ Represents a regular expression literal that contains interpolation.
+
+ /foo #{bar} baz/
+ ^^^^^^^^^^^^^^^^
+ - name: InterpolatedStringNode
+ flags: InterpolatedStringNodeFlags
+ fields:
+ - name: opening_loc
+ type: location?
+ - name: parts
+ type: node[]
+ kind:
+ - StringNode
+ - EmbeddedStatementsNode
+ - EmbeddedVariableNode
+ - InterpolatedStringNode # `"a" "#{b}"`
+ - name: closing_loc
+ type: location?
+ newline: parts
+ comment: |
+ Represents a string literal that contains interpolation.
+
+ "foo #{bar} baz"
+ ^^^^^^^^^^^^^^^^
+ - name: InterpolatedSymbolNode
+ fields:
+ - name: opening_loc
+ type: location?
+ - name: parts
+ type: node[]
+ kind:
+ - StringNode
+ - EmbeddedStatementsNode
+ - EmbeddedVariableNode
+ - name: closing_loc
+ type: location?
+ newline: parts
+ comment: |
+ Represents a symbol literal that contains interpolation.
+
+ :"foo #{bar} baz"
+ ^^^^^^^^^^^^^^^^^
+ - name: InterpolatedXStringNode
+ fields:
+ - name: opening_loc
+ type: location
+ - name: parts
+ type: node[]
+ kind:
+ - StringNode
+ - EmbeddedStatementsNode
+ - EmbeddedVariableNode
+ - name: closing_loc
+ type: location
+ newline: parts
+ comment: |
+ Represents an xstring literal that contains interpolation.
+
+ `foo #{bar} baz`
+ ^^^^^^^^^^^^^^^^
+ - name: ItLocalVariableReadNode
+ comment: |
+ Represents reading from the implicit `it` local variable.
+
+ -> { it }
+ ^^
+ - name: ItParametersNode
+ comment: |
+ Represents an implicit set of parameters through the use of the `it` keyword within a block or lambda.
+
+ -> { it + it }
+ ^^^^^^^^^^^^^^
+ - name: KeywordHashNode
+ flags: KeywordHashNodeFlags
+ fields:
+ - name: elements
+ type: node[]
+ kind:
+ - AssocNode
+ - AssocSplatNode
+ comment: |
+ Represents a hash literal without opening and closing braces.
+
+ foo(a: b)
+ ^^^^
+ - name: KeywordRestParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant?
+ - name: name_loc
+ type: location?
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents a keyword rest parameter to a method, block, or lambda definition.
+
+ def a(**b)
+ ^^^
+ end
+ - name: LambdaNode
+ fields:
+ - name: locals
+ type: constant[]
+ - name: operator_loc
+ type: location
+ - name: opening_loc
+ type: location
+ - name: closing_loc
+ type: location
+ - name: parameters
+ type: node?
+ kind:
+ - BlockParametersNode
+ - NumberedParametersNode
+ - ItParametersNode
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ comment: |
+ Represents using a lambda literal (not the lambda method call).
+
+ ->(value) { value * 2 }
+ ^^^^^^^^^^^^^^^^^^^^^^^
+ - name: LocalVariableAndWriteNode
+ fields:
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: name
+ type: constant
+ - name: depth
+ type: uint32
+ comment: |
+ Represents the use of the `&&=` operator for assignment to a local variable.
+
+ target &&= value
+ ^^^^^^^^^^^^^^^^
+ - name: LocalVariableOperatorWriteNode
+ fields:
+ - name: name_loc
+ type: location
+ - name: binary_operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: name
+ type: constant
+ - name: binary_operator
+ type: constant
+ - name: depth
+ type: uint32
+ comment: |
+ Represents assigning to a local variable using an operator that isn't `=`.
+
+ target += value
+ ^^^^^^^^^^^^^^^
+ - name: LocalVariableOrWriteNode
+ fields:
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: name
+ type: constant
+ - name: depth
+ type: uint32
+ comment: |
+ Represents the use of the `||=` operator for assignment to a local variable.
+
+ target ||= value
+ ^^^^^^^^^^^^^^^^
+ - name: LocalVariableReadNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ x # name `:x`
+
+ _Test # name `:_Test`
+
+ Note that this can also be an underscore followed by a number for the default block parameters.
+
+ _1 # name `:_1`
+
+ - name: depth
+ type: uint32
+ comment: |
+ The number of visible scopes that should be searched to find the origin of this local variable.
+
+ foo = 1; foo # depth 0
+
+ bar = 2; tap { bar } # depth 1
+
+ The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
+ comment: |
+ Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.
+
+ foo
+ ^^^
+ - name: LocalVariableTargetNode
+ fields:
+ - name: name
+ type: constant
+ - name: depth
+ type: uint32
+ comment: |
+ Represents writing to a local variable in a context that doesn't have an explicit value.
+
+ foo, bar = baz
+ ^^^ ^^^
+
+ foo => baz
+ ^^^
+ - name: LocalVariableWriteNode
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
+
+ foo = :bar # name `:foo`
+
+ abc = 123 # name `:abc`
+ - name: depth
+ type: uint32
+ comment: |
+ The number of semantic scopes we have to traverse to find the declaration of this variable.
+
+ foo = 1 # depth 0
+
+ tap { foo = 1 } # depth 1
+
+ The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
+ - name: name_loc
+ type: location
+ comment: |
+ The Location of the variable name.
+
+ foo = :bar
+ ^^^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ foo = :bar
+ ^^^^
+
+ abc = 1234
+ ^^^^
+
+ Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write.
+
+ foo = foo
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `=` operator.
+
+ x = :y
+ ^
+ comment: |
+ Represents writing to a local variable.
+
+ foo = 1
+ ^^^^^^^
+ - name: MatchLastLineNode
+ flags: RegularExpressionFlags
+ fields:
+ - name: opening_loc
+ type: location
+ - name: content_loc
+ type: location
+ - name: closing_loc
+ type: location
+ - name: unescaped
+ type: string
+ comment: |
+ Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.
+
+ if /foo/i then end
+ ^^^^^^
+ - name: MatchPredicateNode
+ fields:
+ - name: value
+ type: node
+ kind: non-void expression
+ - name: pattern
+ type: node
+ kind: pattern expression
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents the use of the modifier `in` operator.
+
+ foo in bar
+ ^^^^^^^^^^
+ - name: MatchRequiredNode
+ fields:
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the left-hand side of the operator.
+
+ foo => bar
+ ^^^
+ - name: pattern
+ type: node
+ kind: pattern expression
+ comment: |
+ Represents the right-hand side of the operator. The type of the node depends on the expression.
+
+ Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`.
+
+ foo => a # This is equivalent to writing `a = foo`
+ ^
+
+ Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant.
+
+ foo => [a]
+ ^^^
+
+ foo => a, b
+ ^^^^
+
+ foo => Bar[a, b]
+ ^^^^^^^^^
+
+ If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead.
+
+ foo => *, 1, *a
+ ^^^^^
+
+ Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`.
+
+ foo => { a: 1, b: }
+
+ foo => Bar[a: 1, b:]
+
+ foo => Bar[**]
+
+ To use any variable that needs run time evaluation, pinning is required. This results in a `PinnedVariableNode`
+
+ foo => ^a
+ ^^
+
+ Similar, any expression can be used with pinning. This results in a `PinnedExpressionNode`.
+
+ foo => ^(a + 1)
+
+ Anything else will result in the regular node for that expression, for example a `ConstantReadNode`.
+
+ foo => CONST
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the operator.
+
+ foo => bar
+ ^^
+ comment: |
+ Represents the use of the `=>` operator.
+
+ foo => bar
+ ^^^^^^^^^^
+ - name: MatchWriteNode
+ fields:
+ - name: call
+ type: node
+ kind: CallNode
+ - name: targets
+ type: node[]
+ kind: LocalVariableTargetNode
+ comment: |
+ Represents writing local variables using a regular expression match with named capture groups.
+
+ /(?<foo>bar)/ =~ baz
+ ^^^^^^^^^^^^^^^^^^^^
+ - name: ModuleNode
+ fields:
+ - name: locals
+ type: constant[]
+ - name: module_keyword_loc
+ type: location
+ - name: constant_path
+ type: node
+ kind:
+ - ConstantReadNode
+ - ConstantPathNode
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ - name: end_keyword_loc
+ type: location
+ - name: name
+ type: constant
+ comment: |
+ Represents a module declaration involving the `module` keyword.
+
+ module Foo end
+ ^^^^^^^^^^^^^^
+ - name: MultiTargetNode
+ fields:
+ - name: lefts
+ type: node[]
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - MultiTargetNode
+ - RequiredParameterNode # def m((a,b)); end
+ comment: |
+ Represents the targets expressions before a splat node.
+
+ a, (b, c, *) = 1, 2, 3, 4, 5
+ ^^^^
+
+ The splat node can be absent, in that case all target expressions are in the left field.
+
+ a, (b, c) = 1, 2, 3, 4, 5
+ ^^^^
+ - name: rest
+ type: node?
+ kind:
+ - ImplicitRestNode
+ - SplatNode
+ comment: |
+ Represents a splat node in the target expression.
+
+ a, (b, *c) = 1, 2, 3, 4
+ ^^
+
+ The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
+
+ a, (b, *) = 1, 2, 3, 4
+ ^
+
+ If the `*` is omitted, this field will contain an `ImplicitRestNode`
+
+ a, (b,) = 1, 2, 3, 4
+ ^
+ - name: rights
+ type: node[]
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - MultiTargetNode
+ - RequiredParameterNode # def m((*,b)); end
+ comment: |
+ Represents the targets expressions after a splat node.
+
+ a, (*, b, c) = 1, 2, 3, 4, 5
+ ^^^^
+ - name: lparen_loc
+ type: location?
+ comment: |
+ The Location of the opening parenthesis.
+
+ a, (b, c) = 1, 2, 3
+ ^
+ - name: rparen_loc
+ type: location?
+ comment: |
+ The Location of the closing parenthesis.
+
+ a, (b, c) = 1, 2, 3
+ ^
+ comment: |
+ Represents a multi-target expression.
+
+ a, (b, c) = 1, 2, 3
+ ^^^^^^
+
+ This can be a part of `MultiWriteNode` as above, or the target of a `for` loop
+
+ for a, b in [[1, 2], [3, 4]]
+ ^^^^
+ - name: MultiWriteNode
+ fields:
+ - name: lefts
+ type: node[]
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - MultiTargetNode
+ comment: |
+ Represents the targets expressions before a splat node.
+
+ a, b, * = 1, 2, 3, 4, 5
+ ^^^^
+
+ The splat node can be absent, in that case all target expressions are in the left field.
+
+ a, b, c = 1, 2, 3, 4, 5
+ ^^^^^^^
+ - name: rest
+ type: node?
+ kind:
+ - ImplicitRestNode
+ - SplatNode
+ comment: |
+ Represents a splat node in the target expression.
+
+ a, b, *c = 1, 2, 3, 4
+ ^^
+
+ The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
+
+ a, b, * = 1, 2, 3, 4
+ ^
+
+ If the `*` is omitted, this field will contain an `ImplicitRestNode`
+
+ a, b, = 1, 2, 3, 4
+ ^
+ - name: rights
+ type: node[]
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - MultiTargetNode
+ comment: |
+ Represents the targets expressions after a splat node.
+
+ a, *, b, c = 1, 2, 3, 4, 5
+ ^^^^
+ - name: lparen_loc
+ type: location?
+ comment: |
+ The Location of the opening parenthesis.
+
+ (a, b, c) = 1, 2, 3
+ ^
+ - name: rparen_loc
+ type: location?
+ comment: |
+ The Location of the closing parenthesis.
+
+ (a, b, c) = 1, 2, 3
+ ^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the operator.
+
+ a, b, c = 1, 2, 3
+ ^
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ The value to write to the targets. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ a, b, c = 1, 2, 3
+ ^^^^^^^
+ comment: |
+ Represents a write to a multi-target expression.
+
+ a, b, c = 1, 2, 3
+ ^^^^^^^^^^^^^^^^^
+ - name: NextNode
+ fields:
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of the `next` keyword.
+
+ next 1
+ ^^^^^^
+ - name: NilNode
+ comment: |
+ Represents the use of the `nil` keyword.
+
+ nil
+ ^^^
+ - name: NoBlockParameterNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of `&nil` inside method arguments.
+
+ def a(&nil)
+ ^^^^
+ end
+ - name: NoKeywordsParameterNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of `**nil` inside method arguments.
+
+ def a(**nil)
+ ^^^^^
+ end
+ - name: NumberedParametersNode
+ fields:
+ - name: maximum
+ type: uint8
+ comment: |
+ Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.
+
+ -> { _1 + _2 }
+ ^^^^^^^^^^^^^^
+ - name: NumberedReferenceReadNode
+ fields:
+ - name: number
+ type: uint32
+ comment: |
+ The (1-indexed, from the left) number of the capture group. Numbered references that are too large result in this value being `0`.
+
+ $1 # number `1`
+
+ $5432 # number `5432`
+
+ $4294967296 # number `0`
+ comment: |
+ Represents reading a numbered reference to a capture in the previous match.
+
+ $1
+ ^^
+ - name: OptionalKeywordParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents an optional keyword parameter to a method, block, or lambda definition.
+
+ def a(b: 1)
+ ^^^^
+ end
+ - name: OptionalParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: value
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents an optional parameter to a method, block, or lambda definition.
+
+ def a(b = 1)
+ ^^^^^
+ end
+ - name: OrNode
+ fields:
+ - name: left
+ type: node
+ kind: non-void expression
+ comment: |
+ Represents the left side of the expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ left or right
+ ^^^^
+
+ 1 || 2
+ ^
+ - name: right
+ type: node
+ kind: Node
+ comment: |
+ Represents the right side of the expression.
+
+ left || right
+ ^^^^^
+
+ 1 or 2
+ ^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `or` keyword or the `||` operator.
+
+ left or right
+ ^^
+ comment: |
+ Represents the use of the `||` operator or the `or` keyword.
+
+ left or right
+ ^^^^^^^^^^^^^
+ - name: ParametersNode
+ fields:
+ - name: requireds
+ type: node[]
+ kind:
+ - RequiredParameterNode
+ - MultiTargetNode
+ - name: optionals
+ type: node[]
+ kind: OptionalParameterNode
+ - name: rest
+ type: node?
+ kind:
+ - RestParameterNode
+ - ImplicitRestNode # Only in block parameters
+ - name: posts
+ type: node[]
+ kind:
+ - RequiredParameterNode
+ - MultiTargetNode
+ - name: keywords
+ type: node[]
+ kind:
+ - RequiredKeywordParameterNode
+ - OptionalKeywordParameterNode
+ - name: keyword_rest
+ type: node?
+ kind:
+ - KeywordRestParameterNode
+ - ForwardingParameterNode
+ - NoKeywordsParameterNode
+ - name: block
+ type: node?
+ kind:
+ - BlockParameterNode
+ - NoBlockParameterNode
+ comment: |
+ Represents the list of parameters on a method, block, or lambda definition.
+
+ def a(b, c, d)
+ ^^^^^^^
+ end
+ - name: ParenthesesNode
+ flags: ParenthesesNodeFlags
+ fields:
+ - name: body
+ type: node?
+ kind: non-void expression # Usually a StatementsNode but not always e.g. `1 in (..10)`
+ - name: opening_loc
+ type: location
+ - name: closing_loc
+ type: location
+ newline: false
+ comment: |
+ Represents a parenthesized expression
+
+ (10 + 34)
+ ^^^^^^^^^
+ - name: PinnedExpressionNode
+ fields:
+ - name: expression
+ type: node
+ kind: non-void expression
+ comment: |
+ The expression used in the pinned expression
+
+ foo in ^(bar)
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `^` operator
+
+ foo in ^(bar)
+ ^
+ - name: lparen_loc
+ type: location
+ comment: |
+ The Location of the opening parenthesis.
+
+ foo in ^(bar)
+ ^
+ - name: rparen_loc
+ type: location
+ comment: |
+ The Location of the closing parenthesis.
+
+ foo in ^(bar)
+ ^
+ comment: |
+ Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
+
+ foo in ^(bar)
+ ^^^^^^
+ - name: PinnedVariableNode
+ fields:
+ - name: variable
+ type: node
+ kind:
+ - LocalVariableReadNode
+ - InstanceVariableReadNode
+ - ClassVariableReadNode
+ - GlobalVariableReadNode # foo in ^$a
+ - BackReferenceReadNode # foo in ^$&
+ - NumberedReferenceReadNode # foo in ^$1
+ - ItLocalVariableReadNode # proc { 1 in ^it }
+ comment: |
+ The variable used in the pinned expression
+
+ foo in ^bar
+ ^^^
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `^` operator
+
+ foo in ^bar
+ ^
+ comment: |
+ Represents the use of the `^` operator for pinning a variable in a pattern matching expression.
+
+ foo in ^bar
+ ^^^^
+ - name: PostExecutionNode
+ fields:
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: keyword_loc
+ type: location
+ - name: opening_loc
+ type: location
+ - name: closing_loc
+ type: location
+ comment: |
+ Represents the use of the `END` keyword.
+
+ END { foo }
+ ^^^^^^^^^^^
+ - name: PreExecutionNode
+ fields:
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: keyword_loc
+ type: location
+ - name: opening_loc
+ type: location
+ - name: closing_loc
+ type: location
+ comment: |
+ Represents the use of the `BEGIN` keyword.
+
+ BEGIN { foo }
+ ^^^^^^^^^^^^^
+ - name: ProgramNode
+ fields:
+ - name: locals
+ type: constant[]
+ - name: statements
+ type: node
+ kind: StatementsNode
+ comment: The top level node of any parse tree.
+ - name: RangeNode
+ flags: RangeFlags
+ fields:
+ - name: left
+ type: node?
+ kind: non-void expression
+ comment: |
+ The left-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ 1...
+ ^
+
+ hello...goodbye
+ ^^^^^
+ - name: right
+ type: node?
+ kind: non-void expression
+ comment: |
+ The right-hand side of the range, if present. It can be either `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ ..5
+ ^
+
+ 1...foo
+ ^^^
+ If neither right-hand or left-hand side was included, this will be an ErrorRecoveryNode.
+ - name: operator_loc
+ type: location
+ comment: |
+ The Location of the `..` or `...` operator.
+ comment: |
+ Represents the use of the `..` or `...` operators.
+
+ 1..2
+ ^^^^
+
+ c if a =~ /left/ ... b =~ /right/
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ - name: RationalNode
+ flags: IntegerBaseFlags
+ fields:
+ - name: numerator
+ type: integer
+ comment: |
+ The numerator of the rational number.
+
+ 1.5r # numerator 3
+ - name: denominator
+ type: integer
+ comment: |
+ The denominator of the rational number.
+
+ 1.5r # denominator 2
+ comment: |
+ Represents a rational number literal.
+
+ 1.0r
+ ^^^^
+ - name: RedoNode
+ comment: |
+ Represents the use of the `redo` keyword.
+
+ redo
+ ^^^^
+ - name: RegularExpressionNode
+ flags: RegularExpressionFlags
+ fields:
+ - name: opening_loc
+ type: location
+ - name: content_loc
+ type: location
+ - name: closing_loc
+ type: location
+ - name: unescaped
+ type: string
+ comment: |
+ Represents a regular expression literal with no interpolation.
+
+ /foo/i
+ ^^^^^^
+ - name: RequiredKeywordParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant
+ - name: name_loc
+ type: location
+ comment: |
+ Represents a required keyword parameter to a method, block, or lambda definition.
+
+ def a(b: )
+ ^^
+ end
+ - name: RequiredParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant
+ comment: |
+ Represents a required parameter to a method, block, or lambda definition.
+
+ def a(b)
+ ^
+ end
+ - name: RescueModifierNode
+ fields:
+ - name: expression
+ type: node
+ kind: Node
+ - name: keyword_loc
+ type: location
+ - name: rescue_expression
+ type: node
+ kind: Node
+ newline: expression
+ comment: |
+ Represents an expression modified with a rescue.
+
+ foo rescue nil
+ ^^^^^^^^^^^^^^
+ - name: RescueNode
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: exceptions
+ type: node[]
+ kind: non-void expression
+ - name: operator_loc
+ type: location?
+ - name: reference
+ type: node?
+ kind:
+ - LocalVariableTargetNode
+ - InstanceVariableTargetNode
+ - ClassVariableTargetNode
+ - GlobalVariableTargetNode
+ - ConstantTargetNode
+ - ConstantPathTargetNode
+ - CallTargetNode
+ - IndexTargetNode
+ - name: then_keyword_loc
+ type: location?
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ - name: subsequent
+ type: node?
+ kind: RescueNode
+ comment: |
+ Represents a rescue statement.
+
+ begin
+ rescue Foo, *splat, Bar => ex
+ foo
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ end
+
+ `Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `reference` field.
+ - name: RestParameterNode
+ flags: ParameterFlags
+ fields:
+ - name: name
+ type: constant?
+ - name: name_loc
+ type: location?
+ - name: operator_loc
+ type: location
+ comment: |
+ Represents a rest parameter to a method, block, or lambda definition.
+
+ def a(*b)
+ ^^
+ end
+ - name: RetryNode
+ comment: |
+ Represents the use of the `retry` keyword.
+
+ retry
+ ^^^^^
+ - name: ReturnNode
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ comment: |
+ Represents the use of the `return` keyword.
+
+ return 1
+ ^^^^^^^^
+ - name: SelfNode
+ comment: |
+ Represents the `self` keyword.
+
+ self
+ ^^^^
+ - name: ShareableConstantNode
+ flags: ShareableConstantNodeFlags
+ fields:
+ - name: write
+ type: node
+ kind:
+ - ConstantWriteNode
+ - ConstantAndWriteNode
+ - ConstantOrWriteNode
+ - ConstantOperatorWriteNode
+ - ConstantPathWriteNode
+ - ConstantPathAndWriteNode
+ - ConstantPathOrWriteNode
+ - ConstantPathOperatorWriteNode
+ comment: The constant write that should be modified with the shareability state.
+ comment: |
+ This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
+
+ # shareable_constant_value: literal
+ C = { a: 1 }
+ ^^^^^^^^^^^^
+ - name: SingletonClassNode
+ fields:
+ - name: locals
+ type: constant[]
+ - name: class_keyword_loc
+ type: location
+ - name: operator_loc
+ type: location
+ - name: expression
+ type: node
+ kind: non-void expression
+ - name: body
+ type: node?
+ kind:
+ - StatementsNode
+ - BeginNode
+ - name: end_keyword_loc
+ type: location
+ comment: |
+ Represents a singleton class declaration involving the `class` keyword.
+
+ class << self end
+ ^^^^^^^^^^^^^^^^^
+ - name: SourceEncodingNode
+ comment: |
+ Represents the use of the `__ENCODING__` keyword.
+
+ __ENCODING__
+ ^^^^^^^^^^^^
+ - name: SourceFileNode
+ flags: StringFlags
+ fields:
+ - name: filepath
+ type: string
+ comment: Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism.parse*` APIs.
+ comment: |
+ Represents the use of the `__FILE__` keyword.
+
+ __FILE__
+ ^^^^^^^^
+ - name: SourceLineNode
+ comment: |
+ Represents the use of the `__LINE__` keyword.
+
+ __LINE__
+ ^^^^^^^^
+ - name: SplatNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: expression
+ type: node?
+ kind: non-void expression
+ comment: |
+ Represents the use of the splat operator.
+
+ [*a]
+ ^^
+ - name: StatementsNode
+ fields:
+ - name: body
+ type: node[]
+ kind: Node
+ comment: |
+ Represents a set of statements contained within some scope.
+
+ foo; bar; baz
+ ^^^^^^^^^^^^^
+ - name: StringNode
+ flags: StringFlags
+ fields:
+ - name: opening_loc
+ type: location?
+ - name: content_loc
+ type: location
+ - name: closing_loc
+ type: location?
+ - name: unescaped
+ type: string
+ comment: |
+ Represents a string literal, a string contained within a `%w` list, or plain string content within an interpolated string.
+
+ "foo"
+ ^^^^^
+
+ %w[foo]
+ ^^^
+
+ "foo #{bar} baz"
+ ^^^^ ^^^^
+ - name: SuperNode
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: lparen_loc
+ type: location?
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ comment: "Can be only `nil` when there are empty parentheses, like `super()`."
+ - name: rparen_loc
+ type: location?
+ - name: block
+ type: node?
+ kind:
+ - BlockNode
+ - BlockArgumentNode
+ comment: |
+ Represents the use of the `super` keyword with parentheses or arguments.
+
+ super()
+ ^^^^^^^
+
+ super foo, bar
+ ^^^^^^^^^^^^^^
+
+ If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
+ - name: SymbolNode
+ flags: SymbolFlags
+ fields:
+ - name: opening_loc
+ type: location?
+ - name: value_loc
+ type: location?
+ - name: closing_loc
+ type: location?
+ - name: unescaped
+ type: string
+ comment: |
+ Represents a symbol literal or a symbol contained within a `%i` list.
+
+ :foo
+ ^^^^
+
+ %i[foo]
+ ^^^
+ - name: TrueNode
+ comment: |
+ Represents the use of the literal `true` keyword.
+
+ true
+ ^^^^
+ - name: UndefNode
+ fields:
+ - name: names
+ type: node[]
+ kind:
+ - SymbolNode
+ - InterpolatedSymbolNode
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of the `undef` keyword.
+
+ undef :foo, :bar, :baz
+ ^^^^^^^^^^^^^^^^^^^^^^
+ - name: UnlessNode
+ fields:
+ - name: keyword_loc
+ type: location
+ comment: |
+ The Location of the `unless` keyword.
+
+ unless cond then bar end
+ ^^^^^^
+
+ bar unless cond
+ ^^^^^^
+ - name: predicate
+ type: node
+ kind: non-void expression
+ comment: |
+ The condition to be evaluated for the unless expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
+
+ unless cond then bar end
+ ^^^^
+
+ bar unless cond
+ ^^^^
+ - name: then_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `then` keyword, if present.
+
+ unless cond then bar end
+ ^^^^
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ comment: |
+ The body of statements that will executed if the unless condition is
+ falsey. Will be `nil` if no body is provided.
+
+ unless cond then bar end
+ ^^^
+ - name: else_clause
+ type: node?
+ kind: ElseNode
+ comment: |
+ The else clause of the unless expression, if present.
+
+ unless cond then bar else baz end
+ ^^^^^^^^^^^^
+ - name: end_keyword_loc
+ type: location?
+ comment: |
+ The Location of the `end` keyword, if present.
+
+ unless cond then bar end
+ ^^^
+ newline: predicate
+ comment: |
+ Represents the use of the `unless` keyword, either in the block form or the modifier form.
+
+ bar unless foo
+ ^^^^^^^^^^^^^^
+
+ unless foo then bar end
+ ^^^^^^^^^^^^^^^^^^^^^^^
+ - name: UntilNode
+ flags: LoopFlags
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: do_keyword_loc
+ type: location?
+ - name: closing_loc
+ type: location?
+ - name: predicate
+ type: node
+ kind: non-void expression
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ newline: predicate
+ comment: |
+ Represents the use of the `until` keyword, either in the block form or the modifier form.
+
+ bar until foo
+ ^^^^^^^^^^^^^
+
+ until foo do bar end
+ ^^^^^^^^^^^^^^^^^^^^
+ - name: WhenNode
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: conditions
+ type: node[]
+ kind: non-void expression
+ - name: then_keyword_loc
+ type: location?
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ comment: |
+ Represents the use of the `when` keyword within a case statement.
+
+ case true
+ when true
+ ^^^^^^^^^
+ end
+ - name: WhileNode
+ flags: LoopFlags
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: do_keyword_loc
+ type: location?
+ - name: closing_loc
+ type: location?
+ - name: predicate
+ type: node
+ kind: non-void expression
+ - name: statements
+ type: node?
+ kind: StatementsNode
+ newline: predicate
+ comment: |
+ Represents the use of the `while` keyword, either in the block form or the modifier form.
+
+ bar while foo
+ ^^^^^^^^^^^^^
+
+ while foo do bar end
+ ^^^^^^^^^^^^^^^^^^^^
+ - name: XStringNode
+ flags: EncodingFlags
+ fields:
+ - name: opening_loc
+ type: location
+ - name: content_loc
+ type: location
+ - name: closing_loc
+ type: location
+ - name: unescaped
+ type: string
+ comment: |
+ Represents an xstring literal with no interpolation.
+
+ `foo`
+ ^^^^^
+ - name: YieldNode
+ fields:
+ - name: keyword_loc
+ type: location
+ - name: lparen_loc
+ type: location?
+ - name: arguments
+ type: node?
+ kind: ArgumentsNode
+ - name: rparen_loc
+ type: location?
+ comment: |
+ Represents the use of the `yield` keyword.
+
+ yield 1
+ ^^^^^^^
diff --git a/prism/constant_pool.c b/prism/constant_pool.c
new file mode 100644
index 0000000000..90201ebb8e
--- /dev/null
+++ b/prism/constant_pool.c
@@ -0,0 +1,360 @@
+#include "prism/internal/constant_pool.h"
+
+#include "prism/compiler/align.h"
+#include "prism/compiler/inline.h"
+#include "prism/internal/arena.h"
+
+#include <assert.h>
+#include <stdbool.h>
+
+/**
+ * Initialize a list of constant ids.
+ */
+void
+pm_constant_id_list_init(pm_constant_id_list_t *list) {
+ list->ids = NULL;
+ list->size = 0;
+ list->capacity = 0;
+}
+
+/**
+ * Initialize a list of constant ids with a given capacity.
+ */
+void
+pm_constant_id_list_init_capacity(pm_arena_t *arena, pm_constant_id_list_t *list, size_t capacity) {
+ if (capacity) {
+ list->ids = (pm_constant_id_t *) pm_arena_zalloc(arena, capacity * sizeof(pm_constant_id_t), PRISM_ALIGNOF(pm_constant_id_t));
+ } else {
+ list->ids = NULL;
+ }
+
+ list->size = 0;
+ list->capacity = capacity;
+}
+
+/**
+ * Append a constant id to a list of constant ids.
+ */
+void
+pm_constant_id_list_append(pm_arena_t *arena, pm_constant_id_list_t *list, pm_constant_id_t id) {
+ if (list->size >= list->capacity) {
+ size_t new_capacity = list->capacity == 0 ? 8 : list->capacity * 2;
+ pm_constant_id_t *new_ids = (pm_constant_id_t *) pm_arena_alloc(arena, sizeof(pm_constant_id_t) * new_capacity, PRISM_ALIGNOF(pm_constant_id_t));
+
+ if (list->size > 0) {
+ memcpy(new_ids, list->ids, list->size * sizeof(pm_constant_id_t));
+ }
+
+ list->ids = new_ids;
+ list->capacity = new_capacity;
+ }
+
+ list->ids[list->size++] = id;
+}
+
+/**
+ * Insert a constant id into a list of constant ids at the specified index.
+ */
+void
+pm_constant_id_list_insert(pm_constant_id_list_t *list, size_t index, pm_constant_id_t id) {
+ assert(index < list->capacity);
+ assert(list->ids[index] == PM_CONSTANT_ID_UNSET);
+
+ list->ids[index] = id;
+ list->size++;
+}
+
+/**
+ * Checks if the current constant id list includes the given constant id.
+ */
+bool
+pm_constant_id_list_includes(pm_constant_id_list_t *list, pm_constant_id_t id) {
+ for (size_t index = 0; index < list->size; index++) {
+ if (list->ids[index] == id) return true;
+ }
+ return false;
+}
+
+/**
+ * A multiply-xorshift hash that processes input a word at a time. This is
+ * significantly faster than the byte-at-a-time djb2 hash for the short strings
+ * typical in Ruby source (~15 bytes average). Each word is mixed into the hash
+ * by XOR followed by multiplication by a large odd constant, which spreads
+ * entropy across all bits. A final xorshift fold produces the 32-bit result.
+ */
+static PRISM_INLINE uint32_t
+pm_constant_pool_hash(const uint8_t *start, size_t length) {
+ // This constant is borrowed from wyhash. It is a 64-bit odd integer with
+ // roughly equal 0/1 bits, chosen for good avalanche behavior when used in
+ // multiply-xorshift sequences.
+ static const uint64_t secret = 0x517cc1b727220a95ULL;
+ uint64_t hash = (uint64_t) length;
+
+ if (length <= 8) {
+ // Short strings: read first and last 4 bytes (overlapping for len < 8).
+ // This covers the majority of Ruby identifiers with a single multiply.
+ if (length >= 4) {
+ uint32_t a, b;
+ memcpy(&a, start, 4);
+ memcpy(&b, start + length - 4, 4);
+ hash ^= (uint64_t) a | ((uint64_t) b << 32);
+ } else if (length > 0) {
+ hash ^= (uint64_t) start[0] | ((uint64_t) start[length >> 1] << 8) | ((uint64_t) start[length - 1] << 16);
+ }
+ hash *= secret;
+ } else if (length <= 16) {
+ // Medium strings: read first and last 8 bytes (overlapping).
+ // Two multiplies instead of the three the loop-based approach needs.
+ uint64_t word;
+ memcpy(&word, start, 8);
+ hash ^= word;
+ hash *= secret;
+ memcpy(&word, start + length - 8, 8);
+ hash ^= word;
+ hash *= secret;
+ } else {
+ const uint8_t *ptr = start;
+ size_t remaining = length;
+
+ while (remaining >= 8) {
+ uint64_t word;
+ memcpy(&word, ptr, 8);
+ hash ^= word;
+ hash *= secret;
+ ptr += 8;
+ remaining -= 8;
+ }
+
+ if (remaining > 0) {
+ // Read the last 8 bytes (overlapping with already-processed data).
+ uint64_t word;
+ memcpy(&word, start + length - 8, 8);
+ hash ^= word;
+ hash *= secret;
+ }
+ }
+
+ hash ^= hash >> 32;
+ return (uint32_t) hash;
+}
+
+/**
+ * https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+ */
+static uint32_t
+next_power_of_two(uint32_t v) {
+ // Avoid underflow in subtraction on next line.
+ if (v == 0) {
+ // 1 is the nearest power of 2 to 0 (2^0)
+ return 1;
+ }
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v++;
+ return v;
+}
+
+#ifndef NDEBUG
+static bool
+is_power_of_two(uint32_t size) {
+ return (size & (size - 1)) == 0;
+}
+#endif
+
+/**
+ * Resize a constant pool to a given capacity.
+ */
+static PRISM_INLINE void
+pm_constant_pool_resize(pm_arena_t *arena, pm_constant_pool_t *pool) {
+ assert(is_power_of_two(pool->capacity));
+
+ uint32_t next_capacity = pool->capacity * 2;
+ const uint32_t mask = next_capacity - 1;
+
+ pm_constant_pool_bucket_t *next_buckets = (pm_constant_pool_bucket_t *) pm_arena_zalloc(arena, next_capacity * sizeof(pm_constant_pool_bucket_t), PRISM_ALIGNOF(pm_constant_pool_bucket_t));
+ pm_constant_t *next_constants = (pm_constant_t *) pm_arena_alloc(arena, next_capacity * sizeof(pm_constant_t), PRISM_ALIGNOF(pm_constant_t));
+
+ // For each bucket in the current constant pool, find the index in the
+ // next constant pool, and insert it.
+ for (uint32_t index = 0; index < pool->capacity; index++) {
+ pm_constant_pool_bucket_t *bucket = &pool->buckets[index];
+
+ // If an id is set on this constant, then we know we have content here.
+ // In this case we need to insert it into the next constant pool.
+ if (bucket->id != PM_CONSTANT_ID_UNSET) {
+ uint32_t next_index = bucket->hash & mask;
+
+ // This implements linear scanning to find the next available slot
+ // in case this index is already taken. We don't need to bother
+ // comparing the values since we know that the hash is unique.
+ while (next_buckets[next_index].id != PM_CONSTANT_ID_UNSET) {
+ next_index = (next_index + 1) & mask;
+ }
+
+ // Here we copy over the entire bucket, which includes the id so
+ // that they are consistent between resizes.
+ next_buckets[next_index] = *bucket;
+ }
+ }
+
+ // The constants are stable with respect to hash table resizes.
+ memcpy(next_constants, pool->constants, pool->size * sizeof(pm_constant_t));
+
+ pool->constants = next_constants;
+ pool->buckets = next_buckets;
+ pool->capacity = next_capacity;
+}
+
+/**
+ * Initialize a new constant pool with a given capacity.
+ */
+void
+pm_constant_pool_init(pm_arena_t *arena, pm_constant_pool_t *pool, uint32_t capacity) {
+ capacity = next_power_of_two(capacity);
+
+ pool->buckets = (pm_constant_pool_bucket_t *) pm_arena_zalloc(arena, capacity * sizeof(pm_constant_pool_bucket_t), PRISM_ALIGNOF(pm_constant_pool_bucket_t));
+ pool->constants = (pm_constant_t *) pm_arena_alloc(arena, capacity * sizeof(pm_constant_t), PRISM_ALIGNOF(pm_constant_t));
+ pool->size = 0;
+ pool->capacity = capacity;
+}
+
+/**
+ * Return a pointer to the constant indicated by the given constant id.
+ */
+pm_constant_t *
+pm_constant_pool_id_to_constant(const pm_constant_pool_t *pool, pm_constant_id_t constant_id) {
+ assert(constant_id != PM_CONSTANT_ID_UNSET && constant_id <= pool->size);
+ return &pool->constants[constant_id - 1];
+}
+
+/**
+ * Find a constant in a constant pool. Returns the id of the constant, or 0 if
+ * the constant is not found.
+ */
+pm_constant_id_t
+pm_constant_pool_find(const pm_constant_pool_t *pool, const uint8_t *start, size_t length) {
+ assert(is_power_of_two(pool->capacity));
+ const uint32_t mask = pool->capacity - 1;
+
+ uint32_t hash = pm_constant_pool_hash(start, length);
+ uint32_t index = hash & mask;
+ pm_constant_pool_bucket_t *bucket;
+
+ while (bucket = &pool->buckets[index], bucket->id != PM_CONSTANT_ID_UNSET) {
+ if ((bucket->length == length) && memcmp(bucket->start, start, length) == 0) {
+ return bucket->id;
+ }
+
+ index = (index + 1) & mask;
+ }
+
+ return PM_CONSTANT_ID_UNSET;
+}
+
+/**
+ * Insert a constant into a constant pool and return its index in the pool.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_constant_pool_insert(pm_arena_t *arena, pm_constant_pool_t *pool, const uint8_t *start, size_t length, pm_constant_pool_bucket_type_t type) {
+ if (pool->size >= (pool->capacity / 4 * 3)) {
+ pm_constant_pool_resize(arena, pool);
+ }
+
+ assert(is_power_of_two(pool->capacity));
+ const uint32_t mask = pool->capacity - 1;
+
+ uint32_t hash = pm_constant_pool_hash(start, length);
+ uint32_t index = hash & mask;
+ pm_constant_pool_bucket_t *bucket;
+
+ while (bucket = &pool->buckets[index], bucket->id != PM_CONSTANT_ID_UNSET) {
+ // If there is a collision, then we need to check if the content is the
+ // same as the content we are trying to insert. If it is, then we can
+ // return the id of the existing constant.
+ if ((bucket->length == length) && memcmp(bucket->start, start, length) == 0) {
+ // Since we have found a match, we need to check if this is
+ // attempting to insert a shared or an owned constant. We want to
+ // prefer shared constants since they don't require allocations.
+ if (type != PM_CONSTANT_POOL_BUCKET_OWNED && bucket->type == PM_CONSTANT_POOL_BUCKET_OWNED) {
+ // If we're attempting to insert a shared constant and the
+ // existing constant is owned, then we can replace it with the
+ // shared constant to prefer non-owned references.
+ bucket->start = start;
+ bucket->type = (unsigned int) (type & 0x3);
+ pool->constants[bucket->id - 1].start = start;
+ }
+
+ return bucket->id;
+ }
+
+ index = (index + 1) & mask;
+ }
+
+ // IDs are allocated starting at 1, since the value 0 denotes a non-existent
+ // constant.
+ uint32_t id = ++pool->size;
+ assert(pool->size < ((uint32_t) (1 << 30)));
+
+ *bucket = (pm_constant_pool_bucket_t) {
+ .id = (unsigned int) (id & 0x3fffffff),
+ .type = (unsigned int) (type & 0x3),
+ .hash = hash,
+ .start = start,
+ .length = length
+ };
+
+ pool->constants[id - 1] = (pm_constant_t) {
+ .start = start,
+ .length = length,
+ };
+
+ return id;
+}
+
+/**
+ * Insert a constant into a constant pool. Returns the id of the constant, or
+ * PM_CONSTANT_ID_UNSET if any potential calls to resize fail.
+ */
+pm_constant_id_t
+pm_constant_pool_insert_shared(pm_arena_t *arena, pm_constant_pool_t *pool, const uint8_t *start, size_t length) {
+ return pm_constant_pool_insert(arena, pool, start, length, PM_CONSTANT_POOL_BUCKET_DEFAULT);
+}
+
+/**
+ * Insert a constant into a constant pool from memory that is now owned by the
+ * constant pool. Returns the id of the constant, or PM_CONSTANT_ID_UNSET if any
+ * potential calls to resize fail.
+ */
+pm_constant_id_t
+pm_constant_pool_insert_owned(pm_arena_t *arena, pm_constant_pool_t *pool, uint8_t *start, size_t length) {
+ return pm_constant_pool_insert(arena, pool, start, length, PM_CONSTANT_POOL_BUCKET_OWNED);
+}
+
+/**
+ * Insert a constant into a constant pool from memory that is constant. Returns
+ * the id of the constant, or PM_CONSTANT_ID_UNSET if any potential calls to
+ * resize fail.
+ */
+pm_constant_id_t
+pm_constant_pool_insert_constant(pm_arena_t *arena, pm_constant_pool_t *pool, const uint8_t *start, size_t length) {
+ return pm_constant_pool_insert(arena, pool, start, length, PM_CONSTANT_POOL_BUCKET_CONSTANT);
+}
+
+/**
+ * Return a raw pointer to the start of a constant.
+ */
+const uint8_t *
+pm_constant_start(const pm_constant_t *constant) {
+ return constant->start;
+}
+
+/**
+ * Return the length of a constant.
+ */
+size_t pm_constant_length(const pm_constant_t *constant) {
+ return constant->length;
+}
diff --git a/prism/constant_pool.h b/prism/constant_pool.h
new file mode 100644
index 0000000000..dc03235c70
--- /dev/null
+++ b/prism/constant_pool.h
@@ -0,0 +1,81 @@
+/**
+ * @file constant_pool.h
+ *
+ * A data structure that stores a set of strings.
+ *
+ * Each string is assigned a unique id, which can be used to compare strings for
+ * equality. This comparison ends up being much faster than strcmp, since it
+ * only requires a single integer comparison.
+ */
+#ifndef PRISM_CONSTANT_POOL_H
+#define PRISM_CONSTANT_POOL_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/arena.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * A constant id is a unique identifier for a constant in the constant pool.
+ */
+typedef uint32_t pm_constant_id_t;
+
+/**
+ * A list of constant IDs. Usually used to represent a set of locals.
+ */
+typedef struct {
+ /** The number of constant ids in the list. */
+ size_t size;
+
+ /** The number of constant ids that have been allocated in the list. */
+ size_t capacity;
+
+ /** The constant ids in the list. */
+ pm_constant_id_t *ids;
+} pm_constant_id_list_t;
+
+/** A constant in the pool which effectively stores a string. */
+typedef struct pm_constant_t pm_constant_t;
+
+/**
+ * The overall constant pool, which stores constants found while parsing.
+ */
+typedef struct pm_constant_pool_t pm_constant_pool_t;
+
+/**
+ * Return a raw pointer to the start of a constant.
+ *
+ * @param constant The constant to get the start of.
+ * @returns A raw pointer to the start of the constant.
+ */
+PRISM_EXPORTED_FUNCTION const uint8_t * pm_constant_start(const pm_constant_t *constant) PRISM_NONNULL(1);
+
+/**
+ * Return the length of a constant.
+ *
+ * @param constant The constant to get the length of.
+ * @returns The length of the constant.
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_constant_length(const pm_constant_t *constant) PRISM_NONNULL(1);
+
+/**
+ * Initialize a list of constant ids.
+ *
+ * @param list The list to initialize.
+ */
+PRISM_EXPORTED_FUNCTION void pm_constant_id_list_init(pm_constant_id_list_t *list) PRISM_NONNULL(1);
+
+/**
+ * Append a constant id to a list of constant ids.
+ *
+ * @param arena The arena to use for allocations.
+ * @param list The list to append to.
+ * @param id The constant id to append.
+ */
+PRISM_EXPORTED_FUNCTION void pm_constant_id_list_append(pm_arena_t *arena, pm_constant_id_list_t *list, pm_constant_id_t id) PRISM_NONNULL(1, 2);
+
+#endif
diff --git a/prism/diagnostic.h b/prism/diagnostic.h
new file mode 100644
index 0000000000..370061ec56
--- /dev/null
+++ b/prism/diagnostic.h
@@ -0,0 +1,93 @@
+/**
+ * @file diagnostic.h
+ *
+ * A list of diagnostics generated during parsing.
+ */
+#ifndef PRISM_DIAGNOSTIC_H
+#define PRISM_DIAGNOSTIC_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+
+/**
+ * An opaque pointer to a diagnostic generated during parsing.
+ */
+typedef struct pm_diagnostic_t pm_diagnostic_t;
+
+/**
+ * The levels of errors generated during parsing.
+ */
+typedef enum {
+ /** For errors that should raise a syntax error. */
+ PM_ERROR_LEVEL_SYNTAX = 0,
+
+ /** For errors that should raise an argument error. */
+ PM_ERROR_LEVEL_ARGUMENT = 1,
+
+ /** For errors that should raise a load error. */
+ PM_ERROR_LEVEL_LOAD = 2
+} pm_error_level_t;
+
+/**
+ * The levels of warnings generated during parsing.
+ */
+typedef enum {
+ /** For warnings which should be emitted if $VERBOSE != nil. */
+ PM_WARNING_LEVEL_DEFAULT = 0,
+
+ /** For warnings which should be emitted if $VERBOSE == true. */
+ PM_WARNING_LEVEL_VERBOSE = 1
+} pm_warning_level_t;
+
+/**
+ * Get the type of the given diagnostic.
+ *
+ * @param diagnostic The diagnostic to get the type of.
+ * @returns The type of the given diagnostic. Note that this is a string
+ * representation of an internal ID, and is not meant to be relied upon as a
+ * stable identifier for the diagnostic. We do not guarantee that these will
+ * not change in the future. This is meant to be used for debugging and
+ * error reporting purposes, and not for programmatic checks.
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_type(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
+
+/**
+ * Get the location of the given diagnostic.
+ *
+ * @param diagnostic The diagnostic to get the location of.
+ * @returns The location of the given diagnostic.
+ */
+PRISM_EXPORTED_FUNCTION pm_location_t pm_diagnostic_location(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
+
+/**
+ * Get the message of the given diagnostic.
+ *
+ * @param diagnostic The diagnostic to get the message of.
+ * @returns The message of the given diagnostic.
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_message(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
+
+/**
+ * Get the error level associated with the given diagnostic.
+ *
+ * @param diagnostic The diagnostic to get the error level of.
+ * @returns The error level of the given diagnostic. If the diagnostic was a
+ * warning, or is in any way not an error, then the return value is
+ * undefined and should not be relied upon.
+ */
+PRISM_EXPORTED_FUNCTION pm_error_level_t pm_diagnostic_error_level(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
+
+/**
+ * Get the warning level associated with the given diagnostic.
+ *
+ * @param diagnostic The diagnostic to get the warning level of.
+ * @returns The warning level of the given diagnostic. If the diagnostic was an
+ * error, or is in any way not a warning, then the return value is
+ * undefined and should not be relied upon.
+ */
+PRISM_EXPORTED_FUNCTION pm_warning_level_t pm_diagnostic_warning_level(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/encoding.c b/prism/encoding.c
new file mode 100644
index 0000000000..c9c2e13056
--- /dev/null
+++ b/prism/encoding.c
@@ -0,0 +1,5345 @@
+#include "prism/internal/encoding.h"
+
+#include "prism/compiler/unused.h"
+#include "prism/internal/strncasecmp.h"
+
+#include <assert.h>
+
+typedef uint32_t pm_unicode_codepoint_t;
+
+#define UNICODE_ALPHA_CODEPOINTS_LENGTH 1508
+static const pm_unicode_codepoint_t unicode_alpha_codepoints[UNICODE_ALPHA_CODEPOINTS_LENGTH] = {
+ 0x100, 0x2C1,
+ 0x2C6, 0x2D1,
+ 0x2E0, 0x2E4,
+ 0x2EC, 0x2EC,
+ 0x2EE, 0x2EE,
+ 0x345, 0x345,
+ 0x363, 0x374,
+ 0x376, 0x377,
+ 0x37A, 0x37D,
+ 0x37F, 0x37F,
+ 0x386, 0x386,
+ 0x388, 0x38A,
+ 0x38C, 0x38C,
+ 0x38E, 0x3A1,
+ 0x3A3, 0x3F5,
+ 0x3F7, 0x481,
+ 0x48A, 0x52F,
+ 0x531, 0x556,
+ 0x559, 0x559,
+ 0x560, 0x588,
+ 0x5B0, 0x5BD,
+ 0x5BF, 0x5BF,
+ 0x5C1, 0x5C2,
+ 0x5C4, 0x5C5,
+ 0x5C7, 0x5C7,
+ 0x5D0, 0x5EA,
+ 0x5EF, 0x5F2,
+ 0x610, 0x61A,
+ 0x620, 0x657,
+ 0x659, 0x65F,
+ 0x66E, 0x6D3,
+ 0x6D5, 0x6DC,
+ 0x6E1, 0x6E8,
+ 0x6ED, 0x6EF,
+ 0x6FA, 0x6FC,
+ 0x6FF, 0x6FF,
+ 0x710, 0x73F,
+ 0x74D, 0x7B1,
+ 0x7CA, 0x7EA,
+ 0x7F4, 0x7F5,
+ 0x7FA, 0x7FA,
+ 0x800, 0x817,
+ 0x81A, 0x82C,
+ 0x840, 0x858,
+ 0x860, 0x86A,
+ 0x870, 0x887,
+ 0x889, 0x88F,
+ 0x897, 0x897,
+ 0x8A0, 0x8C9,
+ 0x8D4, 0x8DF,
+ 0x8E3, 0x8E9,
+ 0x8F0, 0x93B,
+ 0x93D, 0x94C,
+ 0x94E, 0x950,
+ 0x955, 0x963,
+ 0x971, 0x983,
+ 0x985, 0x98C,
+ 0x98F, 0x990,
+ 0x993, 0x9A8,
+ 0x9AA, 0x9B0,
+ 0x9B2, 0x9B2,
+ 0x9B6, 0x9B9,
+ 0x9BD, 0x9C4,
+ 0x9C7, 0x9C8,
+ 0x9CB, 0x9CC,
+ 0x9CE, 0x9CE,
+ 0x9D7, 0x9D7,
+ 0x9DC, 0x9DD,
+ 0x9DF, 0x9E3,
+ 0x9F0, 0x9F1,
+ 0x9FC, 0x9FC,
+ 0xA01, 0xA03,
+ 0xA05, 0xA0A,
+ 0xA0F, 0xA10,
+ 0xA13, 0xA28,
+ 0xA2A, 0xA30,
+ 0xA32, 0xA33,
+ 0xA35, 0xA36,
+ 0xA38, 0xA39,
+ 0xA3E, 0xA42,
+ 0xA47, 0xA48,
+ 0xA4B, 0xA4C,
+ 0xA51, 0xA51,
+ 0xA59, 0xA5C,
+ 0xA5E, 0xA5E,
+ 0xA70, 0xA75,
+ 0xA81, 0xA83,
+ 0xA85, 0xA8D,
+ 0xA8F, 0xA91,
+ 0xA93, 0xAA8,
+ 0xAAA, 0xAB0,
+ 0xAB2, 0xAB3,
+ 0xAB5, 0xAB9,
+ 0xABD, 0xAC5,
+ 0xAC7, 0xAC9,
+ 0xACB, 0xACC,
+ 0xAD0, 0xAD0,
+ 0xAE0, 0xAE3,
+ 0xAF9, 0xAFC,
+ 0xB01, 0xB03,
+ 0xB05, 0xB0C,
+ 0xB0F, 0xB10,
+ 0xB13, 0xB28,
+ 0xB2A, 0xB30,
+ 0xB32, 0xB33,
+ 0xB35, 0xB39,
+ 0xB3D, 0xB44,
+ 0xB47, 0xB48,
+ 0xB4B, 0xB4C,
+ 0xB56, 0xB57,
+ 0xB5C, 0xB5D,
+ 0xB5F, 0xB63,
+ 0xB71, 0xB71,
+ 0xB82, 0xB83,
+ 0xB85, 0xB8A,
+ 0xB8E, 0xB90,
+ 0xB92, 0xB95,
+ 0xB99, 0xB9A,
+ 0xB9C, 0xB9C,
+ 0xB9E, 0xB9F,
+ 0xBA3, 0xBA4,
+ 0xBA8, 0xBAA,
+ 0xBAE, 0xBB9,
+ 0xBBE, 0xBC2,
+ 0xBC6, 0xBC8,
+ 0xBCA, 0xBCC,
+ 0xBD0, 0xBD0,
+ 0xBD7, 0xBD7,
+ 0xC00, 0xC0C,
+ 0xC0E, 0xC10,
+ 0xC12, 0xC28,
+ 0xC2A, 0xC39,
+ 0xC3D, 0xC44,
+ 0xC46, 0xC48,
+ 0xC4A, 0xC4C,
+ 0xC55, 0xC56,
+ 0xC58, 0xC5A,
+ 0xC5C, 0xC5D,
+ 0xC60, 0xC63,
+ 0xC80, 0xC83,
+ 0xC85, 0xC8C,
+ 0xC8E, 0xC90,
+ 0xC92, 0xCA8,
+ 0xCAA, 0xCB3,
+ 0xCB5, 0xCB9,
+ 0xCBD, 0xCC4,
+ 0xCC6, 0xCC8,
+ 0xCCA, 0xCCC,
+ 0xCD5, 0xCD6,
+ 0xCDC, 0xCDE,
+ 0xCE0, 0xCE3,
+ 0xCF1, 0xCF3,
+ 0xD00, 0xD0C,
+ 0xD0E, 0xD10,
+ 0xD12, 0xD3A,
+ 0xD3D, 0xD44,
+ 0xD46, 0xD48,
+ 0xD4A, 0xD4C,
+ 0xD4E, 0xD4E,
+ 0xD54, 0xD57,
+ 0xD5F, 0xD63,
+ 0xD7A, 0xD7F,
+ 0xD81, 0xD83,
+ 0xD85, 0xD96,
+ 0xD9A, 0xDB1,
+ 0xDB3, 0xDBB,
+ 0xDBD, 0xDBD,
+ 0xDC0, 0xDC6,
+ 0xDCF, 0xDD4,
+ 0xDD6, 0xDD6,
+ 0xDD8, 0xDDF,
+ 0xDF2, 0xDF3,
+ 0xE01, 0xE3A,
+ 0xE40, 0xE46,
+ 0xE4D, 0xE4D,
+ 0xE81, 0xE82,
+ 0xE84, 0xE84,
+ 0xE86, 0xE8A,
+ 0xE8C, 0xEA3,
+ 0xEA5, 0xEA5,
+ 0xEA7, 0xEB9,
+ 0xEBB, 0xEBD,
+ 0xEC0, 0xEC4,
+ 0xEC6, 0xEC6,
+ 0xECD, 0xECD,
+ 0xEDC, 0xEDF,
+ 0xF00, 0xF00,
+ 0xF40, 0xF47,
+ 0xF49, 0xF6C,
+ 0xF71, 0xF83,
+ 0xF88, 0xF97,
+ 0xF99, 0xFBC,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103B, 0x103F,
+ 0x1050, 0x108F,
+ 0x109A, 0x109D,
+ 0x10A0, 0x10C5,
+ 0x10C7, 0x10C7,
+ 0x10CD, 0x10CD,
+ 0x10D0, 0x10FA,
+ 0x10FC, 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, 0x13F5,
+ 0x13F8, 0x13FD,
+ 0x1401, 0x166C,
+ 0x166F, 0x167F,
+ 0x1681, 0x169A,
+ 0x16A0, 0x16EA,
+ 0x16EE, 0x16F8,
+ 0x1700, 0x1713,
+ 0x171F, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176C,
+ 0x176E, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17B3,
+ 0x17B6, 0x17C8,
+ 0x17D7, 0x17D7,
+ 0x17DC, 0x17DC,
+ 0x1820, 0x1878,
+ 0x1880, 0x18AA,
+ 0x18B0, 0x18F5,
+ 0x1900, 0x191E,
+ 0x1920, 0x192B,
+ 0x1930, 0x1938,
+ 0x1950, 0x196D,
+ 0x1970, 0x1974,
+ 0x1980, 0x19AB,
+ 0x19B0, 0x19C9,
+ 0x1A00, 0x1A1B,
+ 0x1A20, 0x1A5E,
+ 0x1A61, 0x1A74,
+ 0x1AA7, 0x1AA7,
+ 0x1ABF, 0x1AC0,
+ 0x1ACC, 0x1ACE,
+ 0x1B00, 0x1B33,
+ 0x1B35, 0x1B43,
+ 0x1B45, 0x1B4C,
+ 0x1B80, 0x1BA9,
+ 0x1BAC, 0x1BAF,
+ 0x1BBA, 0x1BE5,
+ 0x1BE7, 0x1BF1,
+ 0x1C00, 0x1C36,
+ 0x1C4D, 0x1C4F,
+ 0x1C5A, 0x1C7D,
+ 0x1C80, 0x1C8A,
+ 0x1C90, 0x1CBA,
+ 0x1CBD, 0x1CBF,
+ 0x1CE9, 0x1CEC,
+ 0x1CEE, 0x1CF3,
+ 0x1CF5, 0x1CF6,
+ 0x1CFA, 0x1CFA,
+ 0x1D00, 0x1DBF,
+ 0x1DD3, 0x1DF4,
+ 0x1E00, 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, 0x209C,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210A, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211D,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212A, 0x212D,
+ 0x212F, 0x2139,
+ 0x213C, 0x213F,
+ 0x2145, 0x2149,
+ 0x214E, 0x214E,
+ 0x2160, 0x2188,
+ 0x24B6, 0x24E9,
+ 0x2C00, 0x2CE4,
+ 0x2CEB, 0x2CEE,
+ 0x2CF2, 0x2CF3,
+ 0x2D00, 0x2D25,
+ 0x2D27, 0x2D27,
+ 0x2D2D, 0x2D2D,
+ 0x2D30, 0x2D67,
+ 0x2D6F, 0x2D6F,
+ 0x2D80, 0x2D96,
+ 0x2DA0, 0x2DA6,
+ 0x2DA8, 0x2DAE,
+ 0x2DB0, 0x2DB6,
+ 0x2DB8, 0x2DBE,
+ 0x2DC0, 0x2DC6,
+ 0x2DC8, 0x2DCE,
+ 0x2DD0, 0x2DD6,
+ 0x2DD8, 0x2DDE,
+ 0x2DE0, 0x2DFF,
+ 0x2E2F, 0x2E2F,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303C,
+ 0x3041, 0x3096,
+ 0x309D, 0x309F,
+ 0x30A1, 0x30FA,
+ 0x30FC, 0x30FF,
+ 0x3105, 0x312F,
+ 0x3131, 0x318E,
+ 0x31A0, 0x31BF,
+ 0x31F0, 0x31FF,
+ 0x3400, 0x4DBF,
+ 0x4E00, 0xA48C,
+ 0xA4D0, 0xA4FD,
+ 0xA500, 0xA60C,
+ 0xA610, 0xA61F,
+ 0xA62A, 0xA62B,
+ 0xA640, 0xA66E,
+ 0xA674, 0xA67B,
+ 0xA67F, 0xA6EF,
+ 0xA717, 0xA71F,
+ 0xA722, 0xA788,
+ 0xA78B, 0xA7DC,
+ 0xA7F1, 0xA805,
+ 0xA807, 0xA827,
+ 0xA840, 0xA873,
+ 0xA880, 0xA8C3,
+ 0xA8C5, 0xA8C5,
+ 0xA8F2, 0xA8F7,
+ 0xA8FB, 0xA8FB,
+ 0xA8FD, 0xA8FF,
+ 0xA90A, 0xA92A,
+ 0xA930, 0xA952,
+ 0xA960, 0xA97C,
+ 0xA980, 0xA9B2,
+ 0xA9B4, 0xA9BF,
+ 0xA9CF, 0xA9CF,
+ 0xA9E0, 0xA9EF,
+ 0xA9FA, 0xA9FE,
+ 0xAA00, 0xAA36,
+ 0xAA40, 0xAA4D,
+ 0xAA60, 0xAA76,
+ 0xAA7A, 0xAABE,
+ 0xAAC0, 0xAAC0,
+ 0xAAC2, 0xAAC2,
+ 0xAADB, 0xAADD,
+ 0xAAE0, 0xAAEF,
+ 0xAAF2, 0xAAF5,
+ 0xAB01, 0xAB06,
+ 0xAB09, 0xAB0E,
+ 0xAB11, 0xAB16,
+ 0xAB20, 0xAB26,
+ 0xAB28, 0xAB2E,
+ 0xAB30, 0xAB5A,
+ 0xAB5C, 0xAB69,
+ 0xAB70, 0xABEA,
+ 0xAC00, 0xD7A3,
+ 0xD7B0, 0xD7C6,
+ 0xD7CB, 0xD7FB,
+ 0xF900, 0xFA6D,
+ 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,
+ 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029C,
+ 0x102A0, 0x102D0,
+ 0x10300, 0x1031F,
+ 0x1032D, 0x1034A,
+ 0x10350, 0x1037A,
+ 0x10380, 0x1039D,
+ 0x103A0, 0x103C3,
+ 0x103C8, 0x103CF,
+ 0x103D1, 0x103D5,
+ 0x10400, 0x1049D,
+ 0x104B0, 0x104D3,
+ 0x104D8, 0x104FB,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057A,
+ 0x1057C, 0x1058A,
+ 0x1058C, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105A1,
+ 0x105A3, 0x105B1,
+ 0x105B3, 0x105B9,
+ 0x105BB, 0x105BC,
+ 0x105C0, 0x105F3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107B0,
+ 0x107B2, 0x107BA,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080A, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083C, 0x1083C,
+ 0x1083F, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089E,
+ 0x108E0, 0x108F2,
+ 0x108F4, 0x108F5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109B7,
+ 0x109BE, 0x109BF,
+ 0x10A00, 0x10A03,
+ 0x10A05, 0x10A06,
+ 0x10A0C, 0x10A13,
+ 0x10A15, 0x10A17,
+ 0x10A19, 0x10A35,
+ 0x10A60, 0x10A7C,
+ 0x10A80, 0x10A9C,
+ 0x10AC0, 0x10AC7,
+ 0x10AC9, 0x10AE4,
+ 0x10B00, 0x10B35,
+ 0x10B40, 0x10B55,
+ 0x10B60, 0x10B72,
+ 0x10B80, 0x10B91,
+ 0x10C00, 0x10C48,
+ 0x10C80, 0x10CB2,
+ 0x10CC0, 0x10CF2,
+ 0x10D00, 0x10D27,
+ 0x10D4A, 0x10D65,
+ 0x10D69, 0x10D69,
+ 0x10D6F, 0x10D85,
+ 0x10E80, 0x10EA9,
+ 0x10EAB, 0x10EAC,
+ 0x10EB0, 0x10EB1,
+ 0x10EC2, 0x10EC7,
+ 0x10EFA, 0x10EFC,
+ 0x10F00, 0x10F1C,
+ 0x10F27, 0x10F27,
+ 0x10F30, 0x10F45,
+ 0x10F70, 0x10F81,
+ 0x10FB0, 0x10FC4,
+ 0x10FE0, 0x10FF6,
+ 0x11000, 0x11045,
+ 0x11071, 0x11075,
+ 0x11080, 0x110B8,
+ 0x110C2, 0x110C2,
+ 0x110D0, 0x110E8,
+ 0x11100, 0x11132,
+ 0x11144, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111BF,
+ 0x111C1, 0x111C4,
+ 0x111CE, 0x111CF,
+ 0x111DA, 0x111DA,
+ 0x111DC, 0x111DC,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123E, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128A, 0x1128D,
+ 0x1128F, 0x1129D,
+ 0x1129F, 0x112A8,
+ 0x112B0, 0x112E8,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130C,
+ 0x1130F, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132A, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133D, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134B, 0x1134C,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135D, 0x11363,
+ 0x11380, 0x11389,
+ 0x1138B, 0x1138B,
+ 0x1138E, 0x1138E,
+ 0x11390, 0x113B5,
+ 0x113B7, 0x113C0,
+ 0x113C2, 0x113C2,
+ 0x113C5, 0x113C5,
+ 0x113C7, 0x113CA,
+ 0x113CC, 0x113CD,
+ 0x113D1, 0x113D1,
+ 0x113D3, 0x113D3,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144A,
+ 0x1145F, 0x11461,
+ 0x11480, 0x114C1,
+ 0x114C4, 0x114C5,
+ 0x114C7, 0x114C7,
+ 0x11580, 0x115B5,
+ 0x115B8, 0x115BE,
+ 0x115D8, 0x115DD,
+ 0x11600, 0x1163E,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11680, 0x116B5,
+ 0x116B8, 0x116B8,
+ 0x11700, 0x1171A,
+ 0x1171D, 0x1172A,
+ 0x11740, 0x11746,
+ 0x11800, 0x11838,
+ 0x118A0, 0x118DF,
+ 0x118FF, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190C, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193B, 0x1193C,
+ 0x1193F, 0x11942,
+ 0x119A0, 0x119A7,
+ 0x119AA, 0x119D7,
+ 0x119DA, 0x119DF,
+ 0x119E1, 0x119E1,
+ 0x119E3, 0x119E4,
+ 0x11A00, 0x11A32,
+ 0x11A35, 0x11A3E,
+ 0x11A50, 0x11A97,
+ 0x11A9D, 0x11A9D,
+ 0x11AB0, 0x11AF8,
+ 0x11B60, 0x11B67,
+ 0x11BC0, 0x11BE0,
+ 0x11C00, 0x11C08,
+ 0x11C0A, 0x11C36,
+ 0x11C38, 0x11C3E,
+ 0x11C40, 0x11C40,
+ 0x11C72, 0x11C8F,
+ 0x11C92, 0x11CA7,
+ 0x11CA9, 0x11CB6,
+ 0x11D00, 0x11D06,
+ 0x11D08, 0x11D09,
+ 0x11D0B, 0x11D36,
+ 0x11D3A, 0x11D3A,
+ 0x11D3C, 0x11D3D,
+ 0x11D3F, 0x11D41,
+ 0x11D43, 0x11D43,
+ 0x11D46, 0x11D47,
+ 0x11D60, 0x11D65,
+ 0x11D67, 0x11D68,
+ 0x11D6A, 0x11D8E,
+ 0x11D90, 0x11D91,
+ 0x11D93, 0x11D96,
+ 0x11D98, 0x11D98,
+ 0x11DB0, 0x11DDB,
+ 0x11EE0, 0x11EF6,
+ 0x11F00, 0x11F10,
+ 0x11F12, 0x11F3A,
+ 0x11F3E, 0x11F40,
+ 0x11FB0, 0x11FB0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246E,
+ 0x12480, 0x12543,
+ 0x12F90, 0x12FF0,
+ 0x13000, 0x1342F,
+ 0x13441, 0x13446,
+ 0x13460, 0x143FA,
+ 0x14400, 0x14646,
+ 0x16100, 0x1612E,
+ 0x16800, 0x16A38,
+ 0x16A40, 0x16A5E,
+ 0x16A70, 0x16ABE,
+ 0x16AD0, 0x16AED,
+ 0x16B00, 0x16B2F,
+ 0x16B40, 0x16B43,
+ 0x16B63, 0x16B77,
+ 0x16B7D, 0x16B8F,
+ 0x16D40, 0x16D6C,
+ 0x16E40, 0x16E7F,
+ 0x16EA0, 0x16EB8,
+ 0x16EBB, 0x16ED3,
+ 0x16F00, 0x16F4A,
+ 0x16F4F, 0x16F87,
+ 0x16F8F, 0x16F9F,
+ 0x16FE0, 0x16FE1,
+ 0x16FE3, 0x16FE3,
+ 0x16FF0, 0x16FF6,
+ 0x17000, 0x18CD5,
+ 0x18CFF, 0x18D1E,
+ 0x18D80, 0x18DF2,
+ 0x1AFF0, 0x1AFF3,
+ 0x1AFF5, 0x1AFFB,
+ 0x1AFFD, 0x1AFFE,
+ 0x1B000, 0x1B122,
+ 0x1B132, 0x1B132,
+ 0x1B150, 0x1B152,
+ 0x1B155, 0x1B155,
+ 0x1B164, 0x1B167,
+ 0x1B170, 0x1B2FB,
+ 0x1BC00, 0x1BC6A,
+ 0x1BC70, 0x1BC7C,
+ 0x1BC80, 0x1BC88,
+ 0x1BC90, 0x1BC99,
+ 0x1BC9E, 0x1BC9E,
+ 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, 0x1D7CB,
+ 0x1DF00, 0x1DF1E,
+ 0x1DF25, 0x1DF2A,
+ 0x1E000, 0x1E006,
+ 0x1E008, 0x1E018,
+ 0x1E01B, 0x1E021,
+ 0x1E023, 0x1E024,
+ 0x1E026, 0x1E02A,
+ 0x1E030, 0x1E06D,
+ 0x1E08F, 0x1E08F,
+ 0x1E100, 0x1E12C,
+ 0x1E137, 0x1E13D,
+ 0x1E14E, 0x1E14E,
+ 0x1E290, 0x1E2AD,
+ 0x1E2C0, 0x1E2EB,
+ 0x1E4D0, 0x1E4EB,
+ 0x1E5D0, 0x1E5ED,
+ 0x1E5F0, 0x1E5F0,
+ 0x1E6C0, 0x1E6DE,
+ 0x1E6E0, 0x1E6F5,
+ 0x1E6FE, 0x1E6FF,
+ 0x1E7E0, 0x1E7E6,
+ 0x1E7E8, 0x1E7EB,
+ 0x1E7ED, 0x1E7EE,
+ 0x1E7F0, 0x1E7FE,
+ 0x1E800, 0x1E8C4,
+ 0x1E900, 0x1E943,
+ 0x1E947, 0x1E947,
+ 0x1E94B, 0x1E94B,
+ 0x1EE00, 0x1EE03,
+ 0x1EE05, 0x1EE1F,
+ 0x1EE21, 0x1EE22,
+ 0x1EE24, 0x1EE24,
+ 0x1EE27, 0x1EE27,
+ 0x1EE29, 0x1EE32,
+ 0x1EE34, 0x1EE37,
+ 0x1EE39, 0x1EE39,
+ 0x1EE3B, 0x1EE3B,
+ 0x1EE42, 0x1EE42,
+ 0x1EE47, 0x1EE47,
+ 0x1EE49, 0x1EE49,
+ 0x1EE4B, 0x1EE4B,
+ 0x1EE4D, 0x1EE4F,
+ 0x1EE51, 0x1EE52,
+ 0x1EE54, 0x1EE54,
+ 0x1EE57, 0x1EE57,
+ 0x1EE59, 0x1EE59,
+ 0x1EE5B, 0x1EE5B,
+ 0x1EE5D, 0x1EE5D,
+ 0x1EE5F, 0x1EE5F,
+ 0x1EE61, 0x1EE62,
+ 0x1EE64, 0x1EE64,
+ 0x1EE67, 0x1EE6A,
+ 0x1EE6C, 0x1EE72,
+ 0x1EE74, 0x1EE77,
+ 0x1EE79, 0x1EE7C,
+ 0x1EE7E, 0x1EE7E,
+ 0x1EE80, 0x1EE89,
+ 0x1EE8B, 0x1EE9B,
+ 0x1EEA1, 0x1EEA3,
+ 0x1EEA5, 0x1EEA9,
+ 0x1EEAB, 0x1EEBB,
+ 0x1F130, 0x1F149,
+ 0x1F150, 0x1F169,
+ 0x1F170, 0x1F189,
+ 0x20000, 0x2A6DF,
+ 0x2A700, 0x2B81D,
+ 0x2B820, 0x2CEAD,
+ 0x2CEB0, 0x2EBE0,
+ 0x2EBF0, 0x2EE5D,
+ 0x2F800, 0x2FA1D,
+ 0x30000, 0x3134A,
+ 0x31350, 0x33479,
+};
+
+#define UNICODE_ALNUM_CODEPOINTS_LENGTH 1598
+static const pm_unicode_codepoint_t unicode_alnum_codepoints[UNICODE_ALNUM_CODEPOINTS_LENGTH] = {
+ 0x100, 0x2C1,
+ 0x2C6, 0x2D1,
+ 0x2E0, 0x2E4,
+ 0x2EC, 0x2EC,
+ 0x2EE, 0x2EE,
+ 0x345, 0x345,
+ 0x363, 0x374,
+ 0x376, 0x377,
+ 0x37A, 0x37D,
+ 0x37F, 0x37F,
+ 0x386, 0x386,
+ 0x388, 0x38A,
+ 0x38C, 0x38C,
+ 0x38E, 0x3A1,
+ 0x3A3, 0x3F5,
+ 0x3F7, 0x481,
+ 0x48A, 0x52F,
+ 0x531, 0x556,
+ 0x559, 0x559,
+ 0x560, 0x588,
+ 0x5B0, 0x5BD,
+ 0x5BF, 0x5BF,
+ 0x5C1, 0x5C2,
+ 0x5C4, 0x5C5,
+ 0x5C7, 0x5C7,
+ 0x5D0, 0x5EA,
+ 0x5EF, 0x5F2,
+ 0x610, 0x61A,
+ 0x620, 0x657,
+ 0x659, 0x669,
+ 0x66E, 0x6D3,
+ 0x6D5, 0x6DC,
+ 0x6E1, 0x6E8,
+ 0x6ED, 0x6FC,
+ 0x6FF, 0x6FF,
+ 0x710, 0x73F,
+ 0x74D, 0x7B1,
+ 0x7C0, 0x7EA,
+ 0x7F4, 0x7F5,
+ 0x7FA, 0x7FA,
+ 0x800, 0x817,
+ 0x81A, 0x82C,
+ 0x840, 0x858,
+ 0x860, 0x86A,
+ 0x870, 0x887,
+ 0x889, 0x88F,
+ 0x897, 0x897,
+ 0x8A0, 0x8C9,
+ 0x8D4, 0x8DF,
+ 0x8E3, 0x8E9,
+ 0x8F0, 0x93B,
+ 0x93D, 0x94C,
+ 0x94E, 0x950,
+ 0x955, 0x963,
+ 0x966, 0x96F,
+ 0x971, 0x983,
+ 0x985, 0x98C,
+ 0x98F, 0x990,
+ 0x993, 0x9A8,
+ 0x9AA, 0x9B0,
+ 0x9B2, 0x9B2,
+ 0x9B6, 0x9B9,
+ 0x9BD, 0x9C4,
+ 0x9C7, 0x9C8,
+ 0x9CB, 0x9CC,
+ 0x9CE, 0x9CE,
+ 0x9D7, 0x9D7,
+ 0x9DC, 0x9DD,
+ 0x9DF, 0x9E3,
+ 0x9E6, 0x9F1,
+ 0x9FC, 0x9FC,
+ 0xA01, 0xA03,
+ 0xA05, 0xA0A,
+ 0xA0F, 0xA10,
+ 0xA13, 0xA28,
+ 0xA2A, 0xA30,
+ 0xA32, 0xA33,
+ 0xA35, 0xA36,
+ 0xA38, 0xA39,
+ 0xA3E, 0xA42,
+ 0xA47, 0xA48,
+ 0xA4B, 0xA4C,
+ 0xA51, 0xA51,
+ 0xA59, 0xA5C,
+ 0xA5E, 0xA5E,
+ 0xA66, 0xA75,
+ 0xA81, 0xA83,
+ 0xA85, 0xA8D,
+ 0xA8F, 0xA91,
+ 0xA93, 0xAA8,
+ 0xAAA, 0xAB0,
+ 0xAB2, 0xAB3,
+ 0xAB5, 0xAB9,
+ 0xABD, 0xAC5,
+ 0xAC7, 0xAC9,
+ 0xACB, 0xACC,
+ 0xAD0, 0xAD0,
+ 0xAE0, 0xAE3,
+ 0xAE6, 0xAEF,
+ 0xAF9, 0xAFC,
+ 0xB01, 0xB03,
+ 0xB05, 0xB0C,
+ 0xB0F, 0xB10,
+ 0xB13, 0xB28,
+ 0xB2A, 0xB30,
+ 0xB32, 0xB33,
+ 0xB35, 0xB39,
+ 0xB3D, 0xB44,
+ 0xB47, 0xB48,
+ 0xB4B, 0xB4C,
+ 0xB56, 0xB57,
+ 0xB5C, 0xB5D,
+ 0xB5F, 0xB63,
+ 0xB66, 0xB6F,
+ 0xB71, 0xB71,
+ 0xB82, 0xB83,
+ 0xB85, 0xB8A,
+ 0xB8E, 0xB90,
+ 0xB92, 0xB95,
+ 0xB99, 0xB9A,
+ 0xB9C, 0xB9C,
+ 0xB9E, 0xB9F,
+ 0xBA3, 0xBA4,
+ 0xBA8, 0xBAA,
+ 0xBAE, 0xBB9,
+ 0xBBE, 0xBC2,
+ 0xBC6, 0xBC8,
+ 0xBCA, 0xBCC,
+ 0xBD0, 0xBD0,
+ 0xBD7, 0xBD7,
+ 0xBE6, 0xBEF,
+ 0xC00, 0xC0C,
+ 0xC0E, 0xC10,
+ 0xC12, 0xC28,
+ 0xC2A, 0xC39,
+ 0xC3D, 0xC44,
+ 0xC46, 0xC48,
+ 0xC4A, 0xC4C,
+ 0xC55, 0xC56,
+ 0xC58, 0xC5A,
+ 0xC5C, 0xC5D,
+ 0xC60, 0xC63,
+ 0xC66, 0xC6F,
+ 0xC80, 0xC83,
+ 0xC85, 0xC8C,
+ 0xC8E, 0xC90,
+ 0xC92, 0xCA8,
+ 0xCAA, 0xCB3,
+ 0xCB5, 0xCB9,
+ 0xCBD, 0xCC4,
+ 0xCC6, 0xCC8,
+ 0xCCA, 0xCCC,
+ 0xCD5, 0xCD6,
+ 0xCDC, 0xCDE,
+ 0xCE0, 0xCE3,
+ 0xCE6, 0xCEF,
+ 0xCF1, 0xCF3,
+ 0xD00, 0xD0C,
+ 0xD0E, 0xD10,
+ 0xD12, 0xD3A,
+ 0xD3D, 0xD44,
+ 0xD46, 0xD48,
+ 0xD4A, 0xD4C,
+ 0xD4E, 0xD4E,
+ 0xD54, 0xD57,
+ 0xD5F, 0xD63,
+ 0xD66, 0xD6F,
+ 0xD7A, 0xD7F,
+ 0xD81, 0xD83,
+ 0xD85, 0xD96,
+ 0xD9A, 0xDB1,
+ 0xDB3, 0xDBB,
+ 0xDBD, 0xDBD,
+ 0xDC0, 0xDC6,
+ 0xDCF, 0xDD4,
+ 0xDD6, 0xDD6,
+ 0xDD8, 0xDDF,
+ 0xDE6, 0xDEF,
+ 0xDF2, 0xDF3,
+ 0xE01, 0xE3A,
+ 0xE40, 0xE46,
+ 0xE4D, 0xE4D,
+ 0xE50, 0xE59,
+ 0xE81, 0xE82,
+ 0xE84, 0xE84,
+ 0xE86, 0xE8A,
+ 0xE8C, 0xEA3,
+ 0xEA5, 0xEA5,
+ 0xEA7, 0xEB9,
+ 0xEBB, 0xEBD,
+ 0xEC0, 0xEC4,
+ 0xEC6, 0xEC6,
+ 0xECD, 0xECD,
+ 0xED0, 0xED9,
+ 0xEDC, 0xEDF,
+ 0xF00, 0xF00,
+ 0xF20, 0xF29,
+ 0xF40, 0xF47,
+ 0xF49, 0xF6C,
+ 0xF71, 0xF83,
+ 0xF88, 0xF97,
+ 0xF99, 0xFBC,
+ 0x1000, 0x1036,
+ 0x1038, 0x1038,
+ 0x103B, 0x1049,
+ 0x1050, 0x109D,
+ 0x10A0, 0x10C5,
+ 0x10C7, 0x10C7,
+ 0x10CD, 0x10CD,
+ 0x10D0, 0x10FA,
+ 0x10FC, 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, 0x13F5,
+ 0x13F8, 0x13FD,
+ 0x1401, 0x166C,
+ 0x166F, 0x167F,
+ 0x1681, 0x169A,
+ 0x16A0, 0x16EA,
+ 0x16EE, 0x16F8,
+ 0x1700, 0x1713,
+ 0x171F, 0x1733,
+ 0x1740, 0x1753,
+ 0x1760, 0x176C,
+ 0x176E, 0x1770,
+ 0x1772, 0x1773,
+ 0x1780, 0x17B3,
+ 0x17B6, 0x17C8,
+ 0x17D7, 0x17D7,
+ 0x17DC, 0x17DC,
+ 0x17E0, 0x17E9,
+ 0x1810, 0x1819,
+ 0x1820, 0x1878,
+ 0x1880, 0x18AA,
+ 0x18B0, 0x18F5,
+ 0x1900, 0x191E,
+ 0x1920, 0x192B,
+ 0x1930, 0x1938,
+ 0x1946, 0x196D,
+ 0x1970, 0x1974,
+ 0x1980, 0x19AB,
+ 0x19B0, 0x19C9,
+ 0x19D0, 0x19D9,
+ 0x1A00, 0x1A1B,
+ 0x1A20, 0x1A5E,
+ 0x1A61, 0x1A74,
+ 0x1A80, 0x1A89,
+ 0x1A90, 0x1A99,
+ 0x1AA7, 0x1AA7,
+ 0x1ABF, 0x1AC0,
+ 0x1ACC, 0x1ACE,
+ 0x1B00, 0x1B33,
+ 0x1B35, 0x1B43,
+ 0x1B45, 0x1B4C,
+ 0x1B50, 0x1B59,
+ 0x1B80, 0x1BA9,
+ 0x1BAC, 0x1BE5,
+ 0x1BE7, 0x1BF1,
+ 0x1C00, 0x1C36,
+ 0x1C40, 0x1C49,
+ 0x1C4D, 0x1C7D,
+ 0x1C80, 0x1C8A,
+ 0x1C90, 0x1CBA,
+ 0x1CBD, 0x1CBF,
+ 0x1CE9, 0x1CEC,
+ 0x1CEE, 0x1CF3,
+ 0x1CF5, 0x1CF6,
+ 0x1CFA, 0x1CFA,
+ 0x1D00, 0x1DBF,
+ 0x1DD3, 0x1DF4,
+ 0x1E00, 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, 0x209C,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210A, 0x2113,
+ 0x2115, 0x2115,
+ 0x2119, 0x211D,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212A, 0x212D,
+ 0x212F, 0x2139,
+ 0x213C, 0x213F,
+ 0x2145, 0x2149,
+ 0x214E, 0x214E,
+ 0x2160, 0x2188,
+ 0x24B6, 0x24E9,
+ 0x2C00, 0x2CE4,
+ 0x2CEB, 0x2CEE,
+ 0x2CF2, 0x2CF3,
+ 0x2D00, 0x2D25,
+ 0x2D27, 0x2D27,
+ 0x2D2D, 0x2D2D,
+ 0x2D30, 0x2D67,
+ 0x2D6F, 0x2D6F,
+ 0x2D80, 0x2D96,
+ 0x2DA0, 0x2DA6,
+ 0x2DA8, 0x2DAE,
+ 0x2DB0, 0x2DB6,
+ 0x2DB8, 0x2DBE,
+ 0x2DC0, 0x2DC6,
+ 0x2DC8, 0x2DCE,
+ 0x2DD0, 0x2DD6,
+ 0x2DD8, 0x2DDE,
+ 0x2DE0, 0x2DFF,
+ 0x2E2F, 0x2E2F,
+ 0x3005, 0x3007,
+ 0x3021, 0x3029,
+ 0x3031, 0x3035,
+ 0x3038, 0x303C,
+ 0x3041, 0x3096,
+ 0x309D, 0x309F,
+ 0x30A1, 0x30FA,
+ 0x30FC, 0x30FF,
+ 0x3105, 0x312F,
+ 0x3131, 0x318E,
+ 0x31A0, 0x31BF,
+ 0x31F0, 0x31FF,
+ 0x3400, 0x4DBF,
+ 0x4E00, 0xA48C,
+ 0xA4D0, 0xA4FD,
+ 0xA500, 0xA60C,
+ 0xA610, 0xA62B,
+ 0xA640, 0xA66E,
+ 0xA674, 0xA67B,
+ 0xA67F, 0xA6EF,
+ 0xA717, 0xA71F,
+ 0xA722, 0xA788,
+ 0xA78B, 0xA7DC,
+ 0xA7F1, 0xA805,
+ 0xA807, 0xA827,
+ 0xA840, 0xA873,
+ 0xA880, 0xA8C3,
+ 0xA8C5, 0xA8C5,
+ 0xA8D0, 0xA8D9,
+ 0xA8F2, 0xA8F7,
+ 0xA8FB, 0xA8FB,
+ 0xA8FD, 0xA92A,
+ 0xA930, 0xA952,
+ 0xA960, 0xA97C,
+ 0xA980, 0xA9B2,
+ 0xA9B4, 0xA9BF,
+ 0xA9CF, 0xA9D9,
+ 0xA9E0, 0xA9FE,
+ 0xAA00, 0xAA36,
+ 0xAA40, 0xAA4D,
+ 0xAA50, 0xAA59,
+ 0xAA60, 0xAA76,
+ 0xAA7A, 0xAABE,
+ 0xAAC0, 0xAAC0,
+ 0xAAC2, 0xAAC2,
+ 0xAADB, 0xAADD,
+ 0xAAE0, 0xAAEF,
+ 0xAAF2, 0xAAF5,
+ 0xAB01, 0xAB06,
+ 0xAB09, 0xAB0E,
+ 0xAB11, 0xAB16,
+ 0xAB20, 0xAB26,
+ 0xAB28, 0xAB2E,
+ 0xAB30, 0xAB5A,
+ 0xAB5C, 0xAB69,
+ 0xAB70, 0xABEA,
+ 0xABF0, 0xABF9,
+ 0xAC00, 0xD7A3,
+ 0xD7B0, 0xD7C6,
+ 0xD7CB, 0xD7FB,
+ 0xF900, 0xFA6D,
+ 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,
+ 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,
+ 0x10140, 0x10174,
+ 0x10280, 0x1029C,
+ 0x102A0, 0x102D0,
+ 0x10300, 0x1031F,
+ 0x1032D, 0x1034A,
+ 0x10350, 0x1037A,
+ 0x10380, 0x1039D,
+ 0x103A0, 0x103C3,
+ 0x103C8, 0x103CF,
+ 0x103D1, 0x103D5,
+ 0x10400, 0x1049D,
+ 0x104A0, 0x104A9,
+ 0x104B0, 0x104D3,
+ 0x104D8, 0x104FB,
+ 0x10500, 0x10527,
+ 0x10530, 0x10563,
+ 0x10570, 0x1057A,
+ 0x1057C, 0x1058A,
+ 0x1058C, 0x10592,
+ 0x10594, 0x10595,
+ 0x10597, 0x105A1,
+ 0x105A3, 0x105B1,
+ 0x105B3, 0x105B9,
+ 0x105BB, 0x105BC,
+ 0x105C0, 0x105F3,
+ 0x10600, 0x10736,
+ 0x10740, 0x10755,
+ 0x10760, 0x10767,
+ 0x10780, 0x10785,
+ 0x10787, 0x107B0,
+ 0x107B2, 0x107BA,
+ 0x10800, 0x10805,
+ 0x10808, 0x10808,
+ 0x1080A, 0x10835,
+ 0x10837, 0x10838,
+ 0x1083C, 0x1083C,
+ 0x1083F, 0x10855,
+ 0x10860, 0x10876,
+ 0x10880, 0x1089E,
+ 0x108E0, 0x108F2,
+ 0x108F4, 0x108F5,
+ 0x10900, 0x10915,
+ 0x10920, 0x10939,
+ 0x10940, 0x10959,
+ 0x10980, 0x109B7,
+ 0x109BE, 0x109BF,
+ 0x10A00, 0x10A03,
+ 0x10A05, 0x10A06,
+ 0x10A0C, 0x10A13,
+ 0x10A15, 0x10A17,
+ 0x10A19, 0x10A35,
+ 0x10A60, 0x10A7C,
+ 0x10A80, 0x10A9C,
+ 0x10AC0, 0x10AC7,
+ 0x10AC9, 0x10AE4,
+ 0x10B00, 0x10B35,
+ 0x10B40, 0x10B55,
+ 0x10B60, 0x10B72,
+ 0x10B80, 0x10B91,
+ 0x10C00, 0x10C48,
+ 0x10C80, 0x10CB2,
+ 0x10CC0, 0x10CF2,
+ 0x10D00, 0x10D27,
+ 0x10D30, 0x10D39,
+ 0x10D40, 0x10D65,
+ 0x10D69, 0x10D69,
+ 0x10D6F, 0x10D85,
+ 0x10E80, 0x10EA9,
+ 0x10EAB, 0x10EAC,
+ 0x10EB0, 0x10EB1,
+ 0x10EC2, 0x10EC7,
+ 0x10EFA, 0x10EFC,
+ 0x10F00, 0x10F1C,
+ 0x10F27, 0x10F27,
+ 0x10F30, 0x10F45,
+ 0x10F70, 0x10F81,
+ 0x10FB0, 0x10FC4,
+ 0x10FE0, 0x10FF6,
+ 0x11000, 0x11045,
+ 0x11066, 0x1106F,
+ 0x11071, 0x11075,
+ 0x11080, 0x110B8,
+ 0x110C2, 0x110C2,
+ 0x110D0, 0x110E8,
+ 0x110F0, 0x110F9,
+ 0x11100, 0x11132,
+ 0x11136, 0x1113F,
+ 0x11144, 0x11147,
+ 0x11150, 0x11172,
+ 0x11176, 0x11176,
+ 0x11180, 0x111BF,
+ 0x111C1, 0x111C4,
+ 0x111CE, 0x111DA,
+ 0x111DC, 0x111DC,
+ 0x11200, 0x11211,
+ 0x11213, 0x11234,
+ 0x11237, 0x11237,
+ 0x1123E, 0x11241,
+ 0x11280, 0x11286,
+ 0x11288, 0x11288,
+ 0x1128A, 0x1128D,
+ 0x1128F, 0x1129D,
+ 0x1129F, 0x112A8,
+ 0x112B0, 0x112E8,
+ 0x112F0, 0x112F9,
+ 0x11300, 0x11303,
+ 0x11305, 0x1130C,
+ 0x1130F, 0x11310,
+ 0x11313, 0x11328,
+ 0x1132A, 0x11330,
+ 0x11332, 0x11333,
+ 0x11335, 0x11339,
+ 0x1133D, 0x11344,
+ 0x11347, 0x11348,
+ 0x1134B, 0x1134C,
+ 0x11350, 0x11350,
+ 0x11357, 0x11357,
+ 0x1135D, 0x11363,
+ 0x11380, 0x11389,
+ 0x1138B, 0x1138B,
+ 0x1138E, 0x1138E,
+ 0x11390, 0x113B5,
+ 0x113B7, 0x113C0,
+ 0x113C2, 0x113C2,
+ 0x113C5, 0x113C5,
+ 0x113C7, 0x113CA,
+ 0x113CC, 0x113CD,
+ 0x113D1, 0x113D1,
+ 0x113D3, 0x113D3,
+ 0x11400, 0x11441,
+ 0x11443, 0x11445,
+ 0x11447, 0x1144A,
+ 0x11450, 0x11459,
+ 0x1145F, 0x11461,
+ 0x11480, 0x114C1,
+ 0x114C4, 0x114C5,
+ 0x114C7, 0x114C7,
+ 0x114D0, 0x114D9,
+ 0x11580, 0x115B5,
+ 0x115B8, 0x115BE,
+ 0x115D8, 0x115DD,
+ 0x11600, 0x1163E,
+ 0x11640, 0x11640,
+ 0x11644, 0x11644,
+ 0x11650, 0x11659,
+ 0x11680, 0x116B5,
+ 0x116B8, 0x116B8,
+ 0x116C0, 0x116C9,
+ 0x116D0, 0x116E3,
+ 0x11700, 0x1171A,
+ 0x1171D, 0x1172A,
+ 0x11730, 0x11739,
+ 0x11740, 0x11746,
+ 0x11800, 0x11838,
+ 0x118A0, 0x118E9,
+ 0x118FF, 0x11906,
+ 0x11909, 0x11909,
+ 0x1190C, 0x11913,
+ 0x11915, 0x11916,
+ 0x11918, 0x11935,
+ 0x11937, 0x11938,
+ 0x1193B, 0x1193C,
+ 0x1193F, 0x11942,
+ 0x11950, 0x11959,
+ 0x119A0, 0x119A7,
+ 0x119AA, 0x119D7,
+ 0x119DA, 0x119DF,
+ 0x119E1, 0x119E1,
+ 0x119E3, 0x119E4,
+ 0x11A00, 0x11A32,
+ 0x11A35, 0x11A3E,
+ 0x11A50, 0x11A97,
+ 0x11A9D, 0x11A9D,
+ 0x11AB0, 0x11AF8,
+ 0x11B60, 0x11B67,
+ 0x11BC0, 0x11BE0,
+ 0x11BF0, 0x11BF9,
+ 0x11C00, 0x11C08,
+ 0x11C0A, 0x11C36,
+ 0x11C38, 0x11C3E,
+ 0x11C40, 0x11C40,
+ 0x11C50, 0x11C59,
+ 0x11C72, 0x11C8F,
+ 0x11C92, 0x11CA7,
+ 0x11CA9, 0x11CB6,
+ 0x11D00, 0x11D06,
+ 0x11D08, 0x11D09,
+ 0x11D0B, 0x11D36,
+ 0x11D3A, 0x11D3A,
+ 0x11D3C, 0x11D3D,
+ 0x11D3F, 0x11D41,
+ 0x11D43, 0x11D43,
+ 0x11D46, 0x11D47,
+ 0x11D50, 0x11D59,
+ 0x11D60, 0x11D65,
+ 0x11D67, 0x11D68,
+ 0x11D6A, 0x11D8E,
+ 0x11D90, 0x11D91,
+ 0x11D93, 0x11D96,
+ 0x11D98, 0x11D98,
+ 0x11DA0, 0x11DA9,
+ 0x11DB0, 0x11DDB,
+ 0x11DE0, 0x11DE9,
+ 0x11EE0, 0x11EF6,
+ 0x11F00, 0x11F10,
+ 0x11F12, 0x11F3A,
+ 0x11F3E, 0x11F40,
+ 0x11F50, 0x11F59,
+ 0x11FB0, 0x11FB0,
+ 0x12000, 0x12399,
+ 0x12400, 0x1246E,
+ 0x12480, 0x12543,
+ 0x12F90, 0x12FF0,
+ 0x13000, 0x1342F,
+ 0x13441, 0x13446,
+ 0x13460, 0x143FA,
+ 0x14400, 0x14646,
+ 0x16100, 0x1612E,
+ 0x16130, 0x16139,
+ 0x16800, 0x16A38,
+ 0x16A40, 0x16A5E,
+ 0x16A60, 0x16A69,
+ 0x16A70, 0x16ABE,
+ 0x16AC0, 0x16AC9,
+ 0x16AD0, 0x16AED,
+ 0x16B00, 0x16B2F,
+ 0x16B40, 0x16B43,
+ 0x16B50, 0x16B59,
+ 0x16B63, 0x16B77,
+ 0x16B7D, 0x16B8F,
+ 0x16D40, 0x16D6C,
+ 0x16D70, 0x16D79,
+ 0x16E40, 0x16E7F,
+ 0x16EA0, 0x16EB8,
+ 0x16EBB, 0x16ED3,
+ 0x16F00, 0x16F4A,
+ 0x16F4F, 0x16F87,
+ 0x16F8F, 0x16F9F,
+ 0x16FE0, 0x16FE1,
+ 0x16FE3, 0x16FE3,
+ 0x16FF0, 0x16FF6,
+ 0x17000, 0x18CD5,
+ 0x18CFF, 0x18D1E,
+ 0x18D80, 0x18DF2,
+ 0x1AFF0, 0x1AFF3,
+ 0x1AFF5, 0x1AFFB,
+ 0x1AFFD, 0x1AFFE,
+ 0x1B000, 0x1B122,
+ 0x1B132, 0x1B132,
+ 0x1B150, 0x1B152,
+ 0x1B155, 0x1B155,
+ 0x1B164, 0x1B167,
+ 0x1B170, 0x1B2FB,
+ 0x1BC00, 0x1BC6A,
+ 0x1BC70, 0x1BC7C,
+ 0x1BC80, 0x1BC88,
+ 0x1BC90, 0x1BC99,
+ 0x1BC9E, 0x1BC9E,
+ 0x1CCF0, 0x1CCF9,
+ 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, 0x1D7CB,
+ 0x1D7CE, 0x1D7FF,
+ 0x1DF00, 0x1DF1E,
+ 0x1DF25, 0x1DF2A,
+ 0x1E000, 0x1E006,
+ 0x1E008, 0x1E018,
+ 0x1E01B, 0x1E021,
+ 0x1E023, 0x1E024,
+ 0x1E026, 0x1E02A,
+ 0x1E030, 0x1E06D,
+ 0x1E08F, 0x1E08F,
+ 0x1E100, 0x1E12C,
+ 0x1E137, 0x1E13D,
+ 0x1E140, 0x1E149,
+ 0x1E14E, 0x1E14E,
+ 0x1E290, 0x1E2AD,
+ 0x1E2C0, 0x1E2EB,
+ 0x1E2F0, 0x1E2F9,
+ 0x1E4D0, 0x1E4EB,
+ 0x1E4F0, 0x1E4F9,
+ 0x1E5D0, 0x1E5ED,
+ 0x1E5F0, 0x1E5FA,
+ 0x1E6C0, 0x1E6DE,
+ 0x1E6E0, 0x1E6F5,
+ 0x1E6FE, 0x1E6FF,
+ 0x1E7E0, 0x1E7E6,
+ 0x1E7E8, 0x1E7EB,
+ 0x1E7ED, 0x1E7EE,
+ 0x1E7F0, 0x1E7FE,
+ 0x1E800, 0x1E8C4,
+ 0x1E900, 0x1E943,
+ 0x1E947, 0x1E947,
+ 0x1E94B, 0x1E94B,
+ 0x1E950, 0x1E959,
+ 0x1EE00, 0x1EE03,
+ 0x1EE05, 0x1EE1F,
+ 0x1EE21, 0x1EE22,
+ 0x1EE24, 0x1EE24,
+ 0x1EE27, 0x1EE27,
+ 0x1EE29, 0x1EE32,
+ 0x1EE34, 0x1EE37,
+ 0x1EE39, 0x1EE39,
+ 0x1EE3B, 0x1EE3B,
+ 0x1EE42, 0x1EE42,
+ 0x1EE47, 0x1EE47,
+ 0x1EE49, 0x1EE49,
+ 0x1EE4B, 0x1EE4B,
+ 0x1EE4D, 0x1EE4F,
+ 0x1EE51, 0x1EE52,
+ 0x1EE54, 0x1EE54,
+ 0x1EE57, 0x1EE57,
+ 0x1EE59, 0x1EE59,
+ 0x1EE5B, 0x1EE5B,
+ 0x1EE5D, 0x1EE5D,
+ 0x1EE5F, 0x1EE5F,
+ 0x1EE61, 0x1EE62,
+ 0x1EE64, 0x1EE64,
+ 0x1EE67, 0x1EE6A,
+ 0x1EE6C, 0x1EE72,
+ 0x1EE74, 0x1EE77,
+ 0x1EE79, 0x1EE7C,
+ 0x1EE7E, 0x1EE7E,
+ 0x1EE80, 0x1EE89,
+ 0x1EE8B, 0x1EE9B,
+ 0x1EEA1, 0x1EEA3,
+ 0x1EEA5, 0x1EEA9,
+ 0x1EEAB, 0x1EEBB,
+ 0x1F130, 0x1F149,
+ 0x1F150, 0x1F169,
+ 0x1F170, 0x1F189,
+ 0x1FBF0, 0x1FBF9,
+ 0x20000, 0x2A6DF,
+ 0x2A700, 0x2B81D,
+ 0x2B820, 0x2CEAD,
+ 0x2CEB0, 0x2EBE0,
+ 0x2EBF0, 0x2EE5D,
+ 0x2F800, 0x2FA1D,
+ 0x30000, 0x3134A,
+ 0x31350, 0x33479,
+};
+
+#define UNICODE_ISUPPER_CODEPOINTS_LENGTH 1320
+static const pm_unicode_codepoint_t unicode_isupper_codepoints[UNICODE_ISUPPER_CODEPOINTS_LENGTH] = {
+ 0x100, 0x100,
+ 0x102, 0x102,
+ 0x104, 0x104,
+ 0x106, 0x106,
+ 0x108, 0x108,
+ 0x10A, 0x10A,
+ 0x10C, 0x10C,
+ 0x10E, 0x10E,
+ 0x110, 0x110,
+ 0x112, 0x112,
+ 0x114, 0x114,
+ 0x116, 0x116,
+ 0x118, 0x118,
+ 0x11A, 0x11A,
+ 0x11C, 0x11C,
+ 0x11E, 0x11E,
+ 0x120, 0x120,
+ 0x122, 0x122,
+ 0x124, 0x124,
+ 0x126, 0x126,
+ 0x128, 0x128,
+ 0x12A, 0x12A,
+ 0x12C, 0x12C,
+ 0x12E, 0x12E,
+ 0x130, 0x130,
+ 0x132, 0x132,
+ 0x134, 0x134,
+ 0x136, 0x136,
+ 0x139, 0x139,
+ 0x13B, 0x13B,
+ 0x13D, 0x13D,
+ 0x13F, 0x13F,
+ 0x141, 0x141,
+ 0x143, 0x143,
+ 0x145, 0x145,
+ 0x147, 0x147,
+ 0x14A, 0x14A,
+ 0x14C, 0x14C,
+ 0x14E, 0x14E,
+ 0x150, 0x150,
+ 0x152, 0x152,
+ 0x154, 0x154,
+ 0x156, 0x156,
+ 0x158, 0x158,
+ 0x15A, 0x15A,
+ 0x15C, 0x15C,
+ 0x15E, 0x15E,
+ 0x160, 0x160,
+ 0x162, 0x162,
+ 0x164, 0x164,
+ 0x166, 0x166,
+ 0x168, 0x168,
+ 0x16A, 0x16A,
+ 0x16C, 0x16C,
+ 0x16E, 0x16E,
+ 0x170, 0x170,
+ 0x172, 0x172,
+ 0x174, 0x174,
+ 0x176, 0x176,
+ 0x178, 0x179,
+ 0x17B, 0x17B,
+ 0x17D, 0x17D,
+ 0x181, 0x182,
+ 0x184, 0x184,
+ 0x186, 0x187,
+ 0x189, 0x18B,
+ 0x18E, 0x191,
+ 0x193, 0x194,
+ 0x196, 0x198,
+ 0x19C, 0x19D,
+ 0x19F, 0x1A0,
+ 0x1A2, 0x1A2,
+ 0x1A4, 0x1A4,
+ 0x1A6, 0x1A7,
+ 0x1A9, 0x1A9,
+ 0x1AC, 0x1AC,
+ 0x1AE, 0x1AF,
+ 0x1B1, 0x1B3,
+ 0x1B5, 0x1B5,
+ 0x1B7, 0x1B8,
+ 0x1BC, 0x1BC,
+ 0x1C4, 0x1C5,
+ 0x1C7, 0x1C8,
+ 0x1CA, 0x1CB,
+ 0x1CD, 0x1CD,
+ 0x1CF, 0x1CF,
+ 0x1D1, 0x1D1,
+ 0x1D3, 0x1D3,
+ 0x1D5, 0x1D5,
+ 0x1D7, 0x1D7,
+ 0x1D9, 0x1D9,
+ 0x1DB, 0x1DB,
+ 0x1DE, 0x1DE,
+ 0x1E0, 0x1E0,
+ 0x1E2, 0x1E2,
+ 0x1E4, 0x1E4,
+ 0x1E6, 0x1E6,
+ 0x1E8, 0x1E8,
+ 0x1EA, 0x1EA,
+ 0x1EC, 0x1EC,
+ 0x1EE, 0x1EE,
+ 0x1F1, 0x1F2,
+ 0x1F4, 0x1F4,
+ 0x1F6, 0x1F8,
+ 0x1FA, 0x1FA,
+ 0x1FC, 0x1FC,
+ 0x1FE, 0x1FE,
+ 0x200, 0x200,
+ 0x202, 0x202,
+ 0x204, 0x204,
+ 0x206, 0x206,
+ 0x208, 0x208,
+ 0x20A, 0x20A,
+ 0x20C, 0x20C,
+ 0x20E, 0x20E,
+ 0x210, 0x210,
+ 0x212, 0x212,
+ 0x214, 0x214,
+ 0x216, 0x216,
+ 0x218, 0x218,
+ 0x21A, 0x21A,
+ 0x21C, 0x21C,
+ 0x21E, 0x21E,
+ 0x220, 0x220,
+ 0x222, 0x222,
+ 0x224, 0x224,
+ 0x226, 0x226,
+ 0x228, 0x228,
+ 0x22A, 0x22A,
+ 0x22C, 0x22C,
+ 0x22E, 0x22E,
+ 0x230, 0x230,
+ 0x232, 0x232,
+ 0x23A, 0x23B,
+ 0x23D, 0x23E,
+ 0x241, 0x241,
+ 0x243, 0x246,
+ 0x248, 0x248,
+ 0x24A, 0x24A,
+ 0x24C, 0x24C,
+ 0x24E, 0x24E,
+ 0x370, 0x370,
+ 0x372, 0x372,
+ 0x376, 0x376,
+ 0x37F, 0x37F,
+ 0x386, 0x386,
+ 0x388, 0x38A,
+ 0x38C, 0x38C,
+ 0x38E, 0x38F,
+ 0x391, 0x3A1,
+ 0x3A3, 0x3AB,
+ 0x3CF, 0x3CF,
+ 0x3D2, 0x3D4,
+ 0x3D8, 0x3D8,
+ 0x3DA, 0x3DA,
+ 0x3DC, 0x3DC,
+ 0x3DE, 0x3DE,
+ 0x3E0, 0x3E0,
+ 0x3E2, 0x3E2,
+ 0x3E4, 0x3E4,
+ 0x3E6, 0x3E6,
+ 0x3E8, 0x3E8,
+ 0x3EA, 0x3EA,
+ 0x3EC, 0x3EC,
+ 0x3EE, 0x3EE,
+ 0x3F4, 0x3F4,
+ 0x3F7, 0x3F7,
+ 0x3F9, 0x3FA,
+ 0x3FD, 0x42F,
+ 0x460, 0x460,
+ 0x462, 0x462,
+ 0x464, 0x464,
+ 0x466, 0x466,
+ 0x468, 0x468,
+ 0x46A, 0x46A,
+ 0x46C, 0x46C,
+ 0x46E, 0x46E,
+ 0x470, 0x470,
+ 0x472, 0x472,
+ 0x474, 0x474,
+ 0x476, 0x476,
+ 0x478, 0x478,
+ 0x47A, 0x47A,
+ 0x47C, 0x47C,
+ 0x47E, 0x47E,
+ 0x480, 0x480,
+ 0x48A, 0x48A,
+ 0x48C, 0x48C,
+ 0x48E, 0x48E,
+ 0x490, 0x490,
+ 0x492, 0x492,
+ 0x494, 0x494,
+ 0x496, 0x496,
+ 0x498, 0x498,
+ 0x49A, 0x49A,
+ 0x49C, 0x49C,
+ 0x49E, 0x49E,
+ 0x4A0, 0x4A0,
+ 0x4A2, 0x4A2,
+ 0x4A4, 0x4A4,
+ 0x4A6, 0x4A6,
+ 0x4A8, 0x4A8,
+ 0x4AA, 0x4AA,
+ 0x4AC, 0x4AC,
+ 0x4AE, 0x4AE,
+ 0x4B0, 0x4B0,
+ 0x4B2, 0x4B2,
+ 0x4B4, 0x4B4,
+ 0x4B6, 0x4B6,
+ 0x4B8, 0x4B8,
+ 0x4BA, 0x4BA,
+ 0x4BC, 0x4BC,
+ 0x4BE, 0x4BE,
+ 0x4C0, 0x4C1,
+ 0x4C3, 0x4C3,
+ 0x4C5, 0x4C5,
+ 0x4C7, 0x4C7,
+ 0x4C9, 0x4C9,
+ 0x4CB, 0x4CB,
+ 0x4CD, 0x4CD,
+ 0x4D0, 0x4D0,
+ 0x4D2, 0x4D2,
+ 0x4D4, 0x4D4,
+ 0x4D6, 0x4D6,
+ 0x4D8, 0x4D8,
+ 0x4DA, 0x4DA,
+ 0x4DC, 0x4DC,
+ 0x4DE, 0x4DE,
+ 0x4E0, 0x4E0,
+ 0x4E2, 0x4E2,
+ 0x4E4, 0x4E4,
+ 0x4E6, 0x4E6,
+ 0x4E8, 0x4E8,
+ 0x4EA, 0x4EA,
+ 0x4EC, 0x4EC,
+ 0x4EE, 0x4EE,
+ 0x4F0, 0x4F0,
+ 0x4F2, 0x4F2,
+ 0x4F4, 0x4F4,
+ 0x4F6, 0x4F6,
+ 0x4F8, 0x4F8,
+ 0x4FA, 0x4FA,
+ 0x4FC, 0x4FC,
+ 0x4FE, 0x4FE,
+ 0x500, 0x500,
+ 0x502, 0x502,
+ 0x504, 0x504,
+ 0x506, 0x506,
+ 0x508, 0x508,
+ 0x50A, 0x50A,
+ 0x50C, 0x50C,
+ 0x50E, 0x50E,
+ 0x510, 0x510,
+ 0x512, 0x512,
+ 0x514, 0x514,
+ 0x516, 0x516,
+ 0x518, 0x518,
+ 0x51A, 0x51A,
+ 0x51C, 0x51C,
+ 0x51E, 0x51E,
+ 0x520, 0x520,
+ 0x522, 0x522,
+ 0x524, 0x524,
+ 0x526, 0x526,
+ 0x528, 0x528,
+ 0x52A, 0x52A,
+ 0x52C, 0x52C,
+ 0x52E, 0x52E,
+ 0x531, 0x556,
+ 0x10A0, 0x10C5,
+ 0x10C7, 0x10C7,
+ 0x10CD, 0x10CD,
+ 0x13A0, 0x13F5,
+ 0x1C89, 0x1C89,
+ 0x1C90, 0x1CBA,
+ 0x1CBD, 0x1CBF,
+ 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,
+ 0x1E9E, 0x1E9E,
+ 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,
+ 0x1EFA, 0x1EFA,
+ 0x1EFC, 0x1EFC,
+ 0x1EFE, 0x1EFE,
+ 0x1F08, 0x1F0F,
+ 0x1F18, 0x1F1D,
+ 0x1F28, 0x1F2F,
+ 0x1F38, 0x1F3F,
+ 0x1F48, 0x1F4D,
+ 0x1F59, 0x1F59,
+ 0x1F5B, 0x1F5B,
+ 0x1F5D, 0x1F5D,
+ 0x1F5F, 0x1F5F,
+ 0x1F68, 0x1F6F,
+ 0x1F88, 0x1F8F,
+ 0x1F98, 0x1F9F,
+ 0x1FA8, 0x1FAF,
+ 0x1FB8, 0x1FBC,
+ 0x1FC8, 0x1FCC,
+ 0x1FD8, 0x1FDB,
+ 0x1FE8, 0x1FEC,
+ 0x1FF8, 0x1FFC,
+ 0x2102, 0x2102,
+ 0x2107, 0x2107,
+ 0x210B, 0x210D,
+ 0x2110, 0x2112,
+ 0x2115, 0x2115,
+ 0x2119, 0x211D,
+ 0x2124, 0x2124,
+ 0x2126, 0x2126,
+ 0x2128, 0x2128,
+ 0x212A, 0x212D,
+ 0x2130, 0x2133,
+ 0x213E, 0x213F,
+ 0x2145, 0x2145,
+ 0x2160, 0x216F,
+ 0x2183, 0x2183,
+ 0x24B6, 0x24CF,
+ 0x2C00, 0x2C2F,
+ 0x2C60, 0x2C60,
+ 0x2C62, 0x2C64,
+ 0x2C67, 0x2C67,
+ 0x2C69, 0x2C69,
+ 0x2C6B, 0x2C6B,
+ 0x2C6D, 0x2C70,
+ 0x2C72, 0x2C72,
+ 0x2C75, 0x2C75,
+ 0x2C7E, 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,
+ 0x2CEB, 0x2CEB,
+ 0x2CED, 0x2CED,
+ 0x2CF2, 0x2CF2,
+ 0xA640, 0xA640,
+ 0xA642, 0xA642,
+ 0xA644, 0xA644,
+ 0xA646, 0xA646,
+ 0xA648, 0xA648,
+ 0xA64A, 0xA64A,
+ 0xA64C, 0xA64C,
+ 0xA64E, 0xA64E,
+ 0xA650, 0xA650,
+ 0xA652, 0xA652,
+ 0xA654, 0xA654,
+ 0xA656, 0xA656,
+ 0xA658, 0xA658,
+ 0xA65A, 0xA65A,
+ 0xA65C, 0xA65C,
+ 0xA65E, 0xA65E,
+ 0xA660, 0xA660,
+ 0xA662, 0xA662,
+ 0xA664, 0xA664,
+ 0xA666, 0xA666,
+ 0xA668, 0xA668,
+ 0xA66A, 0xA66A,
+ 0xA66C, 0xA66C,
+ 0xA680, 0xA680,
+ 0xA682, 0xA682,
+ 0xA684, 0xA684,
+ 0xA686, 0xA686,
+ 0xA688, 0xA688,
+ 0xA68A, 0xA68A,
+ 0xA68C, 0xA68C,
+ 0xA68E, 0xA68E,
+ 0xA690, 0xA690,
+ 0xA692, 0xA692,
+ 0xA694, 0xA694,
+ 0xA696, 0xA696,
+ 0xA698, 0xA698,
+ 0xA69A, 0xA69A,
+ 0xA722, 0xA722,
+ 0xA724, 0xA724,
+ 0xA726, 0xA726,
+ 0xA728, 0xA728,
+ 0xA72A, 0xA72A,
+ 0xA72C, 0xA72C,
+ 0xA72E, 0xA72E,
+ 0xA732, 0xA732,
+ 0xA734, 0xA734,
+ 0xA736, 0xA736,
+ 0xA738, 0xA738,
+ 0xA73A, 0xA73A,
+ 0xA73C, 0xA73C,
+ 0xA73E, 0xA73E,
+ 0xA740, 0xA740,
+ 0xA742, 0xA742,
+ 0xA744, 0xA744,
+ 0xA746, 0xA746,
+ 0xA748, 0xA748,
+ 0xA74A, 0xA74A,
+ 0xA74C, 0xA74C,
+ 0xA74E, 0xA74E,
+ 0xA750, 0xA750,
+ 0xA752, 0xA752,
+ 0xA754, 0xA754,
+ 0xA756, 0xA756,
+ 0xA758, 0xA758,
+ 0xA75A, 0xA75A,
+ 0xA75C, 0xA75C,
+ 0xA75E, 0xA75E,
+ 0xA760, 0xA760,
+ 0xA762, 0xA762,
+ 0xA764, 0xA764,
+ 0xA766, 0xA766,
+ 0xA768, 0xA768,
+ 0xA76A, 0xA76A,
+ 0xA76C, 0xA76C,
+ 0xA76E, 0xA76E,
+ 0xA779, 0xA779,
+ 0xA77B, 0xA77B,
+ 0xA77D, 0xA77E,
+ 0xA780, 0xA780,
+ 0xA782, 0xA782,
+ 0xA784, 0xA784,
+ 0xA786, 0xA786,
+ 0xA78B, 0xA78B,
+ 0xA78D, 0xA78D,
+ 0xA790, 0xA790,
+ 0xA792, 0xA792,
+ 0xA796, 0xA796,
+ 0xA798, 0xA798,
+ 0xA79A, 0xA79A,
+ 0xA79C, 0xA79C,
+ 0xA79E, 0xA79E,
+ 0xA7A0, 0xA7A0,
+ 0xA7A2, 0xA7A2,
+ 0xA7A4, 0xA7A4,
+ 0xA7A6, 0xA7A6,
+ 0xA7A8, 0xA7A8,
+ 0xA7AA, 0xA7AE,
+ 0xA7B0, 0xA7B4,
+ 0xA7B6, 0xA7B6,
+ 0xA7B8, 0xA7B8,
+ 0xA7BA, 0xA7BA,
+ 0xA7BC, 0xA7BC,
+ 0xA7BE, 0xA7BE,
+ 0xA7C0, 0xA7C0,
+ 0xA7C2, 0xA7C2,
+ 0xA7C4, 0xA7C7,
+ 0xA7C9, 0xA7C9,
+ 0xA7CB, 0xA7CC,
+ 0xA7CE, 0xA7CE,
+ 0xA7D0, 0xA7D0,
+ 0xA7D2, 0xA7D2,
+ 0xA7D4, 0xA7D4,
+ 0xA7D6, 0xA7D6,
+ 0xA7D8, 0xA7D8,
+ 0xA7DA, 0xA7DA,
+ 0xA7DC, 0xA7DC,
+ 0xA7F5, 0xA7F5,
+ 0xFF21, 0xFF3A,
+ 0x10400, 0x10427,
+ 0x104B0, 0x104D3,
+ 0x10570, 0x1057A,
+ 0x1057C, 0x1058A,
+ 0x1058C, 0x10592,
+ 0x10594, 0x10595,
+ 0x10C80, 0x10CB2,
+ 0x10D50, 0x10D65,
+ 0x118A0, 0x118BF,
+ 0x16E40, 0x16E5F,
+ 0x16EA0, 0x16EB8,
+ 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,
+ 0x1D7CA, 0x1D7CA,
+ 0x1E900, 0x1E921,
+ 0x1F130, 0x1F149,
+ 0x1F150, 0x1F169,
+ 0x1F170, 0x1F189,
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding unicode codepoint. Note that
+ * this table is different from other encodings where we used a lookup table
+ * because the indices of those tables are the byte representations, not the
+ * codepoints themselves.
+ */
+const uint8_t pm_encoding_unicode_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Binary search through the given list of codepoints to see if the given
+ * codepoint is in the list.
+ */
+static bool
+pm_unicode_codepoint_match(pm_unicode_codepoint_t codepoint, const pm_unicode_codepoint_t *codepoints, size_t size) {
+ size_t start = 0;
+ size_t end = size;
+
+ while (start < end) {
+ size_t middle = start + (end - start) / 2;
+ if ((middle % 2) != 0) middle--;
+
+ if (codepoint >= codepoints[middle] && codepoint <= codepoints[middle + 1]) {
+ return true;
+ }
+
+ if (codepoint < codepoints[middle]) {
+ end = middle;
+ } else {
+ start = middle + 2;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * A state transition table for decoding UTF-8.
+ *
+ * Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
+ *
+ * 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.
+ */
+static const uint8_t pm_utf_8_dfa[] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf
+ 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df
+ 0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef
+ 0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff
+ 0x0,0x1,0x2,0x3,0x5,0x8,0x7,0x1,0x1,0x1,0x4,0x6,0x1,0x1,0x1,0x1, // s0..s0
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1, // s1..s2
+ 1,2,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1, // s3..s4
+ 1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, // s5..s6
+ 1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8
+};
+
+/**
+ * Given a pointer to a string and the number of bytes remaining in the string,
+ * decode the next UTF-8 codepoint and return it. The number of bytes consumed
+ * is returned in the width out parameter.
+ */
+static pm_unicode_codepoint_t
+pm_utf_8_codepoint(const uint8_t *b, ptrdiff_t n, size_t *width) {
+ assert(n >= 0);
+
+ size_t maximum = (n > 4) ? 4 : ((size_t) n);
+ uint32_t codepoint;
+ uint32_t state = 0;
+
+ for (size_t index = 0; index < maximum; index++) {
+ uint32_t byte = b[index];
+ uint32_t type = pm_utf_8_dfa[byte];
+
+ codepoint = (state != 0) ?
+ (byte & 0x3fu) | (codepoint << 6) :
+ (0xffu >> type) & (byte);
+
+ state = pm_utf_8_dfa[256 + (state * 16) + type];
+ if (state == 0) {
+ *width = index + 1;
+ return (pm_unicode_codepoint_t) codepoint;
+ }
+ }
+
+ *width = 0;
+ return 0;
+}
+
+/**
+ * Return the size of the next character in the UTF-8 encoding.
+ */
+size_t
+pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n) {
+ assert(n >= 0);
+
+ size_t maximum = (n > 4) ? 4 : ((size_t) n);
+ uint32_t state = 0;
+
+ for (size_t index = 0; index < maximum; index++) {
+ state = pm_utf_8_dfa[256 + (state * 16) + pm_utf_8_dfa[b[index]]];
+ if (state == 0) return index + 1;
+ }
+
+ return 0;
+}
+
+/**
+ * Return the size of the next character in the UTF-8 encoding if it is an
+ * alphabetical character.
+ */
+size_t
+pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT) ? 1 : 0;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & PRISM_ENCODING_ALPHABETIC_BIT) ? width : 0;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_alpha_codepoints, UNICODE_ALPHA_CODEPOINTS_LENGTH) ? width : 0;
+ }
+}
+
+/**
+ * Return the size of the next character in the UTF-8 encoding if it is an
+ * alphanumeric character.
+ */
+size_t
+pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? 1 : 0;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? width : 0;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_alnum_codepoints, UNICODE_ALNUM_CODEPOINTS_LENGTH) ? width : 0;
+ }
+}
+
+/**
+ * Return true if the next character in the UTF-8 encoding if it is an uppercase
+ * character.
+ */
+bool
+pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_UPPERCASE_BIT) ? true : false;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & PRISM_ENCODING_UPPERCASE_BIT) ? true : false;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_isupper_codepoints, UNICODE_ISUPPER_CODEPOINTS_LENGTH) ? true : false;
+ }
+}
+
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+
+static pm_unicode_codepoint_t
+pm_cesu_8_codepoint(const uint8_t *b, ptrdiff_t n, size_t *width) {
+
+ if ((n > 0) && (b[0] < 0x80)) {
+ *width = 1;
+ return (pm_unicode_codepoint_t) b[0];
+ }
+
+ if (n > 1 && b[0] >= 0xC2 && b[0] <= 0xDF && b[1] >= 0x80 && b[1] <= 0xBF) {
+ *width = 2;
+
+ // 110xxxxx 10xxxxxx
+ return (pm_unicode_codepoint_t) (((b[0] & 0x1F) << 6) | (b[1] & 0x3F));
+ }
+
+ if (n > 5 && b[0] == 0xED && b[1] >= 0xA0 && b[1] <= 0xAF && b[2] >= 0x80 && b[2] <= 0xBF && b[3] == 0xED && b[4] >= 0xB0 && b[4] <= 0xBF && b[5] >= 0x80 && b[5] <= 0xBF) {
+ *width = 6;
+
+ // 11101101 1010xxxx 10xxxxxx 11101101 1011xxxx 10xxxxxx
+ return (pm_unicode_codepoint_t) (0x10000 + (((b[1] & 0xF) << 16) | ((b[2] & 0x3F) << 10) | ((b[4] & 0xF) << 6) | (b[5] & 0x3F)));
+ }
+
+ if (n > 2 && b[0] == 0xED && b[1] >= 0xA0 && b[1] <= 0xBF) {
+ *width = 3;
+
+ // 11101101 1010xxxx 10xxxxx
+ return (pm_unicode_codepoint_t) (0x10000 + (((b[0] & 0x03) << 16) | ((b[1] & 0x3F) << 10) | (b[2] & 0x3F)));
+ }
+
+ if (n > 2 && ((b[0] == 0xE0 && b[1] >= 0xA0) || (b[0] >= 0xE1 && b[0] <= 0xEF && b[1] >= 0x80)) && b[1] <= 0xBF && b[2] >= 0x80 && b[2] <= 0xBF) {
+ *width = 3;
+
+ // 1110xxxx 10xxxxxx 10xxxxx
+ return (pm_unicode_codepoint_t) (((b[0] & 0xF) << 12) | ((b[1] & 0x3F) << 6) | (b[2] & 0x3F));
+ }
+
+ *width = 0;
+ return 0;
+}
+
+static size_t
+pm_encoding_cesu_8_char_width(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ size_t width;
+ pm_cesu_8_codepoint(b, n, &width);
+ return width;
+}
+
+static size_t
+pm_encoding_cesu_8_alpha_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT) ? 1 : 0;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_cesu_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & PRISM_ENCODING_ALPHABETIC_BIT) ? width : 0;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_alpha_codepoints, UNICODE_ALPHA_CODEPOINTS_LENGTH) ? width : 0;
+ }
+}
+
+static size_t
+pm_encoding_cesu_8_alnum_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? 1 : 0;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_cesu_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? width : 0;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_alnum_codepoints, UNICODE_ALNUM_CODEPOINTS_LENGTH) ? width : 0;
+ }
+}
+
+static bool
+pm_encoding_cesu_8_isupper_char(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+
+ if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_UPPERCASE_BIT) ? true : false;
+ }
+
+ size_t width;
+ pm_unicode_codepoint_t codepoint = pm_cesu_8_codepoint(b, n, &width);
+
+ if (codepoint <= 0xFF) {
+ return (pm_encoding_unicode_table[(uint8_t) codepoint] & PRISM_ENCODING_UPPERCASE_BIT) ? true : false;
+ } else {
+ return pm_unicode_codepoint_match(codepoint, unicode_isupper_codepoints, UNICODE_ISUPPER_CODEPOINTS_LENGTH) ? true : false;
+ }
+}
+
+#endif
+
+#undef UNICODE_ALPHA_CODEPOINTS_LENGTH
+#undef UNICODE_ALNUM_CODEPOINTS_LENGTH
+#undef UNICODE_ISUPPER_CODEPOINTS_LENGTH
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding US-ASCII character.
+ */
+static const uint8_t pm_encoding_ascii_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding CP850 character.
+ */
+static const uint8_t pm_encoding_cp850_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding CP852 character.
+ */
+static const uint8_t pm_encoding_cp852_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding CP855 character.
+ */
+static const uint8_t pm_encoding_cp855_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding GB1988 character.
+ */
+static const uint8_t pm_encoding_gb1988_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM437 character.
+ */
+static const uint8_t pm_encoding_ibm437_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM720 character.
+ */
+static const uint8_t pm_encoding_ibm720_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM737 character.
+ */
+static const uint8_t pm_encoding_ibm737_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM775 character.
+ */
+static const uint8_t pm_encoding_ibm775_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM852 character.
+ */
+static const uint8_t pm_encoding_ibm852_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM855 character.
+ */
+static const uint8_t pm_encoding_ibm855_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM857 character.
+ */
+static const uint8_t pm_encoding_ibm857_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM860 character.
+ */
+static const uint8_t pm_encoding_ibm860_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM861 character.
+ */
+static const uint8_t pm_encoding_ibm861_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM862 character.
+ */
+static const uint8_t pm_encoding_ibm862_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM863 character.
+ */
+static const uint8_t pm_encoding_ibm863_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM864 character.
+ */
+static const uint8_t pm_encoding_ibm864_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM865 character.
+ */
+static const uint8_t pm_encoding_ibm865_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM866 character.
+ */
+static const uint8_t pm_encoding_ibm866_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM869 character.
+ */
+static const uint8_t pm_encoding_ibm869_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-1 character.
+ */
+static const uint8_t pm_encoding_iso_8859_1_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-2 character.
+ */
+static const uint8_t pm_encoding_iso_8859_2_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 0, 7, 0, 7, 7, 0, 0, 7, 7, 7, 7, 0, 7, 7, // Ax
+ 0, 3, 0, 3, 0, 3, 3, 0, 0, 3, 3, 3, 3, 0, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-3 character.
+ */
+static const uint8_t pm_encoding_iso_8859_3_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 0, 0, 0, 0, 7, 0, 0, 7, 7, 7, 7, 0, 0, 7, // Ax
+ 0, 3, 0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 3, // Bx
+ 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 0, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 0, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-4 character.
+ */
+static const uint8_t pm_encoding_iso_8859_4_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 3, 7, 0, 7, 7, 0, 0, 7, 7, 7, 7, 0, 7, 0, // Ax
+ 0, 3, 0, 3, 0, 3, 3, 0, 0, 3, 3, 3, 3, 7, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-5 character.
+ */
+static const uint8_t pm_encoding_iso_8859_5_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, // Ax
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-6 character.
+ */
+static const uint8_t pm_encoding_iso_8859_6_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-7 character.
+ */
+static const uint8_t pm_encoding_iso_8859_7_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, // Bx
+ 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-8 character.
+ */
+static const uint8_t pm_encoding_iso_8859_8_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-9 character.
+ */
+static const uint8_t pm_encoding_iso_8859_9_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-10 character.
+ */
+static const uint8_t pm_encoding_iso_8859_10_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, // Ax
+ 0, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 0, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-11 character.
+ */
+static const uint8_t pm_encoding_iso_8859_11_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ax
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Bx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-13 character.
+ */
+static const uint8_t pm_encoding_iso_8859_13_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 3, 0, 0, 0, 0, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-14 character.
+ */
+static const uint8_t pm_encoding_iso_8859_14_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 3, 0, 7, 3, 7, 0, 7, 0, 7, 3, 7, 0, 0, 7, // Ax
+ 7, 3, 7, 3, 7, 3, 0, 7, 3, 3, 3, 7, 3, 7, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-15 character.
+ */
+static const uint8_t pm_encoding_iso_8859_15_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 7, 0, 3, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 7, 3, 0, 0, 3, 0, 3, 0, 7, 3, 7, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding ISO-8859-16 character.
+ */
+static const uint8_t pm_encoding_iso_8859_16_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 7, 3, 7, 0, 0, 7, 0, 3, 0, 7, 0, 7, 0, 3, 7, // Ax
+ 0, 0, 7, 3, 7, 0, 0, 0, 3, 3, 3, 0, 7, 3, 7, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding KOI8-R character.
+ */
+static const uint8_t pm_encoding_koi8_r_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Ex
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding KOI8-U character.
+ */
+static const uint8_t pm_encoding_koi8_u_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 3, 0, 0, // Ax
+ 0, 0, 0, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0, // Bx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Ex
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macCentEuro character.
+ */
+static const uint8_t pm_encoding_mac_cent_euro_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macCroatian character.
+ */
+static const uint8_t pm_encoding_mac_croatian_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+ /**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macCyrillic character.
+ */
+static const uint8_t pm_encoding_mac_cyrillic_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macGreek character.
+ */
+static const uint8_t pm_encoding_mac_greek_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macIceland character.
+ */
+static const uint8_t pm_encoding_mac_iceland_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macRoman character.
+ */
+static const uint8_t pm_encoding_mac_roman_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macRomania character.
+ */
+static const uint8_t pm_encoding_mac_romania_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macThai character.
+ */
+static const uint8_t pm_encoding_mac_thai_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding TIS-620 character.
+ */
+static const uint8_t pm_encoding_tis_620_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ax
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Bx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macTurkish character.
+ */
+static const uint8_t pm_encoding_mac_turkish_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macUkraine character.
+ */
+static const uint8_t pm_encoding_mac_ukraine_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1250 character.
+ */
+static const uint8_t pm_encoding_windows_1250_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3, 3, 3, // 9x
+ 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, // Ax
+ 0, 0, 0, 3, 0, 3, 0, 0, 0, 3, 3, 0, 7, 0, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1251 character.
+ */
+static const uint8_t pm_encoding_windows_1251_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 7, 7, 0, 3, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, // 8x
+ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3, 3, 3, // 9x
+ 0, 7, 3, 7, 0, 7, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, // Ax
+ 0, 0, 7, 3, 3, 3, 0, 0, 3, 0, 3, 0, 3, 7, 3, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1252 character.
+ */
+static const uint8_t pm_encoding_windows_1252_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 7, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 7, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1253 character.
+ */
+static const uint8_t pm_encoding_windows_1253_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, // Bx
+ 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1254 character.
+ */
+static const uint8_t pm_encoding_windows_1254_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 7, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1255 character.
+ */
+static const uint8_t pm_encoding_windows_1255_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1256 character.
+ */
+static const uint8_t pm_encoding_windows_1256_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1257 character.
+ */
+static const uint8_t pm_encoding_windows_1257_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, // Ax
+ 0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 3, 0, 0, 0, 0, 3, // Bx
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx
+ 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex
+ 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-1258 character.
+ */
+static const uint8_t pm_encoding_windows_1258_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+/**
+ * Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding windows-874 character.
+ */
+static const uint8_t pm_encoding_windows_874_table[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
+ 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
+ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
+};
+
+#define PRISM_ENCODING_TABLE(name) \
+ static size_t pm_encoding_ ##name ## _alpha_char(const uint8_t *b, ptrdiff_t n) { \
+ return ((n > 0) && (pm_encoding_ ##name ## _table[*b] & PRISM_ENCODING_ALPHABETIC_BIT)); \
+ } \
+ static size_t pm_encoding_ ##name ## _alnum_char(const uint8_t *b, ptrdiff_t n) { \
+ return ((n > 0) && (pm_encoding_ ##name ## _table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT)) ? 1 : 0; \
+ } \
+ static bool pm_encoding_ ##name ## _isupper_char(const uint8_t *b, ptrdiff_t n) { \
+ return ((n > 0) && (pm_encoding_ ##name ## _table[*b] & PRISM_ENCODING_UPPERCASE_BIT)); \
+ }
+
+PRISM_ENCODING_TABLE(cp850)
+PRISM_ENCODING_TABLE(cp852)
+PRISM_ENCODING_TABLE(cp855)
+PRISM_ENCODING_TABLE(gb1988)
+PRISM_ENCODING_TABLE(ibm437)
+PRISM_ENCODING_TABLE(ibm720)
+PRISM_ENCODING_TABLE(ibm737)
+PRISM_ENCODING_TABLE(ibm775)
+PRISM_ENCODING_TABLE(ibm852)
+PRISM_ENCODING_TABLE(ibm855)
+PRISM_ENCODING_TABLE(ibm857)
+PRISM_ENCODING_TABLE(ibm860)
+PRISM_ENCODING_TABLE(ibm861)
+PRISM_ENCODING_TABLE(ibm862)
+PRISM_ENCODING_TABLE(ibm863)
+PRISM_ENCODING_TABLE(ibm864)
+PRISM_ENCODING_TABLE(ibm865)
+PRISM_ENCODING_TABLE(ibm866)
+PRISM_ENCODING_TABLE(ibm869)
+PRISM_ENCODING_TABLE(iso_8859_1)
+PRISM_ENCODING_TABLE(iso_8859_2)
+PRISM_ENCODING_TABLE(iso_8859_3)
+PRISM_ENCODING_TABLE(iso_8859_4)
+PRISM_ENCODING_TABLE(iso_8859_5)
+PRISM_ENCODING_TABLE(iso_8859_6)
+PRISM_ENCODING_TABLE(iso_8859_7)
+PRISM_ENCODING_TABLE(iso_8859_8)
+PRISM_ENCODING_TABLE(iso_8859_9)
+PRISM_ENCODING_TABLE(iso_8859_10)
+PRISM_ENCODING_TABLE(iso_8859_11)
+PRISM_ENCODING_TABLE(iso_8859_13)
+PRISM_ENCODING_TABLE(iso_8859_14)
+PRISM_ENCODING_TABLE(iso_8859_15)
+PRISM_ENCODING_TABLE(iso_8859_16)
+PRISM_ENCODING_TABLE(koi8_r)
+PRISM_ENCODING_TABLE(koi8_u)
+PRISM_ENCODING_TABLE(mac_cent_euro)
+PRISM_ENCODING_TABLE(mac_croatian)
+PRISM_ENCODING_TABLE(mac_cyrillic)
+PRISM_ENCODING_TABLE(mac_greek)
+PRISM_ENCODING_TABLE(mac_iceland)
+PRISM_ENCODING_TABLE(mac_roman)
+PRISM_ENCODING_TABLE(mac_romania)
+PRISM_ENCODING_TABLE(mac_thai)
+PRISM_ENCODING_TABLE(mac_turkish)
+PRISM_ENCODING_TABLE(mac_ukraine)
+PRISM_ENCODING_TABLE(tis_620)
+PRISM_ENCODING_TABLE(windows_1250)
+PRISM_ENCODING_TABLE(windows_1251)
+PRISM_ENCODING_TABLE(windows_1252)
+PRISM_ENCODING_TABLE(windows_1253)
+PRISM_ENCODING_TABLE(windows_1254)
+PRISM_ENCODING_TABLE(windows_1255)
+PRISM_ENCODING_TABLE(windows_1256)
+PRISM_ENCODING_TABLE(windows_1257)
+PRISM_ENCODING_TABLE(windows_1258)
+PRISM_ENCODING_TABLE(windows_874)
+
+#undef PRISM_ENCODING_TABLE
+#endif
+
+/**
+ * Returns the size of the next character in the ASCII encoding. This basically
+ * means that if the top bit is not set, the character is 1 byte long.
+ */
+static size_t
+pm_encoding_ascii_char_width(const uint8_t *b, ptrdiff_t n) {
+ return ((n > 0) && (*b < 0x80)) ? 1 : 0;
+}
+
+/**
+ * Return the size of the next character in the ASCII encoding if it is an
+ * alphabetical character.
+ */
+static size_t
+pm_encoding_ascii_alpha_char(const uint8_t *b, ptrdiff_t n) {
+ return (n > 0) ? (pm_encoding_ascii_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT) : 0;
+}
+
+/**
+ * Certain encodings are equivalent to ASCII below 0x80, so it works for our
+ * purposes to have a function here that first checks the bounds and then falls
+ * back to checking the ASCII lookup table.
+ */
+static size_t
+pm_encoding_ascii_alpha_char_7bit(const uint8_t *b, ptrdiff_t n) {
+ return ((n > 0) && (*b < 0x80)) ? pm_encoding_ascii_alpha_char(b, n) : 0;
+}
+
+/**
+ * Return the size of the next character in the ASCII encoding if it is an
+ * alphanumeric character.
+ */
+static size_t
+pm_encoding_ascii_alnum_char(const uint8_t *b, ptrdiff_t n) {
+ return ((n > 0) && (pm_encoding_ascii_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT)) ? 1 : 0;
+}
+
+/**
+ * Certain encodings are equivalent to ASCII below 0x80, so it works for our
+ * purposes to have a function here that first checks the bounds and then falls
+ * back to checking the ASCII lookup table.
+ */
+static size_t
+pm_encoding_ascii_alnum_char_7bit(const uint8_t *b, ptrdiff_t n) {
+ return ((n > 0) && (*b < 0x80)) ? pm_encoding_ascii_alnum_char(b, n) : 0;
+}
+
+/**
+ * Return true if the next character in the ASCII encoding if it is an uppercase
+ * character.
+ */
+static bool
+pm_encoding_ascii_isupper_char(const uint8_t *b, ptrdiff_t n) {
+ return (n > 0) && (pm_encoding_ascii_table[*b] & PRISM_ENCODING_UPPERCASE_BIT);
+}
+
+/**
+ * For a lot of encodings the default is that they are a single byte long no
+ * matter what the codepoint, so this function is shared between them.
+ */
+static size_t
+pm_encoding_single_char_width(PRISM_UNUSED const uint8_t *b, PRISM_UNUSED ptrdiff_t n) {
+ return 1;
+}
+
+/**
+ * Returns the size of the next character in the EUC-JP encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_euc_jp_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if ((n > 1) && ((b[0] == 0x8E) || (b[0] >= 0xA1 && b[0] <= 0xFE)) && (b[1] >= 0xA1 && b[1] <= 0xFE)) {
+ return 2;
+ }
+
+ // These are the triple byte characters.
+ if ((n > 2) && (b[0] == 0x8F) && (b[1] >= 0xA1 && b[2] <= 0xFE) && (b[2] >= 0xA1 && b[2] <= 0xFE)) {
+ return 3;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the EUC-JP encoding if it is an
+ * uppercase character.
+ */
+static bool
+pm_encoding_euc_jp_isupper_char(const uint8_t *b, ptrdiff_t n) {
+ size_t width = pm_encoding_euc_jp_char_width(b, n);
+
+ if (width == 1) {
+ return pm_encoding_ascii_isupper_char(b, n);
+ } else if (width == 2) {
+ return (
+ (b[0] == 0xA3 && b[1] >= 0xC1 && b[1] <= 0xDA) ||
+ (b[0] == 0xA6 && b[1] >= 0xA1 && b[1] <= 0xB8) ||
+ (b[0] == 0xA7 && b[1] >= 0xA1 && b[1] <= 0xC1)
+ );
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Returns the size of the next character in the Shift_JIS encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_shift_jis_char_width(const uint8_t *b, ptrdiff_t n) {
+ if (n == 0) {
+ return 0;
+ }
+ // These are the single byte characters.
+ if (b[0] < 0x80 || (b[0] >= 0xA1 && b[0] <= 0xDF)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if ((n > 1) && ((b[0] >= 0x81 && b[0] <= 0x9F) || (b[0] >= 0xE0 && b[0] <= 0xFC)) && (b[1] >= 0x40 && b[1] <= 0xFC && b[1] != 0x7F)) {
+ return 2;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the Shift_JIS encoding if it is an
+ * alphanumeric character.
+ */
+static size_t
+pm_encoding_shift_jis_alnum_char(const uint8_t *b, ptrdiff_t n) {
+ size_t width = pm_encoding_shift_jis_char_width(b, n);
+ return width == 1 ? ((b[0] >= 0x80) || pm_encoding_ascii_alnum_char(b, n)) : width;
+}
+
+/**
+ * Returns the size of the next character in the Shift_JIS encoding if it is an
+ * alphabetical character.
+ */
+static size_t
+pm_encoding_shift_jis_alpha_char(const uint8_t *b, ptrdiff_t n) {
+ size_t width = pm_encoding_shift_jis_char_width(b, n);
+ return width == 1 ? ((b[0] >= 0x80) || pm_encoding_ascii_alpha_char(b, n)) : width;
+}
+
+/**
+ * Returns the size of the next character in the Shift_JIS encoding if it is an
+ * uppercase character.
+ */
+static bool
+pm_encoding_shift_jis_isupper_char(const uint8_t *b, ptrdiff_t n) {
+ size_t width = pm_encoding_shift_jis_char_width(b, n);
+
+ if (width == 1) {
+ return pm_encoding_ascii_isupper_char(b, n);
+ } else if (width == 2) {
+ return (
+ ((b[0] == 0x82) && (b[1] >= 0x60 && b[1] <= 0x79)) ||
+ ((b[0] == 0x83) && (b[1] >= 0x9F && b[1] <= 0xB6)) ||
+ ((b[0] == 0x84) && (b[1] >= 0x40 && b[1] <= 0x60))
+ );
+ } else {
+ return width;
+ }
+}
+
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+
+/**
+ * Certain encodings are equivalent to ASCII below 0x80, so it works for our
+ * purposes to have a function here that first checks the bounds and then falls
+ * back to checking the ASCII lookup table.
+ */
+static bool
+pm_encoding_ascii_isupper_char_7bit(const uint8_t *b, ptrdiff_t n) {
+ return (n > 0) && (*b < 0x80) && pm_encoding_ascii_isupper_char(b, n);
+}
+
+/**
+ * Returns the size of the next character in the Big5 encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_big5_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if ((n > 1) && (b[0] >= 0xA1 && b[0] <= 0xFE) && ((b[1] >= 0x40 && b[1] <= 0x7E) || (b[1] >= 0xA1 && b[1] <= 0xFE))) {
+ return 2;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the CP949 encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_cp949_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters
+ if ((n > 0) && (*b <= 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters
+ if ((n > 1) && (b[0] >= 0x81 && b[0] <= 0xFE) && ((b[1] >= 0x41 && b[1] <= 0x5A) || (b[1] >= 0x61 && b[1] <= 0x7A) || (b[1] >= 0x81 && b[1] <= 0xFE))) {
+ return 2;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the Emacs MULE encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_emacs_mule_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the 1 byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the 2 byte characters.
+ if ((n > 1) && (b[0] >= 0x81 && b[0] <= 0x8F) && (b[1] >= 0xA0)) {
+ return 2;
+ }
+
+ // These are the 3 byte characters.
+ if (
+ (n > 2) &&
+ (
+ ((b[0] >= 0x90 && b[0] <= 0x99) && (b[1] >= 0xA0)) ||
+ ((b[0] == 0x9A || b[0] == 0x9B) && (b[1] >= 0xE0 && b[1] <= 0xEF))
+ ) &&
+ (b[2] >= 0xA0)
+ ) {
+ return 3;
+ }
+
+ // These are the 4 byte characters.
+ if (
+ (n > 3) &&
+ (
+ ((b[0] == 0x9C) && (b[1] >= 0xF0) && (b[1] <= 0xF4)) ||
+ ((b[0] == 0x9D) && (b[1] >= 0xF5) && (b[1] <= 0xFE))
+ ) &&
+ (b[2] >= 0xA0) && (b[3] >= 0xA0)
+ ) {
+ return 4;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the EUC-KR encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_euc_kr_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if ((n > 1) && (b[0] >= 0xA1 && b[0] <= 0xFE) && (b[1] >= 0xA1 && b[1] <= 0xFE)) {
+ return 2;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the EUC-TW encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_euc_tw_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if ((n > 1) && (b[0] >= 0xA1) && (b[0] <= 0xFE) && (b[1] >= 0xA1) && (b[1] <= 0xFE)) {
+ return 2;
+ }
+
+ // These are the quadruple byte characters.
+ if ((n > 3) && (b[0] == 0x8E) && (b[1] >= 0xA1) && (b[1] <= 0xB0) && (b[2] >= 0xA1) && (b[2] <= 0xFE) && (b[3] >= 0xA1) && (b[3] <= 0xFE)) {
+ return 4;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the GB18030 encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_gb18030_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the 1 byte characters.
+ if ((n > 0) && (*b < 0x80)) {
+ return 1;
+ }
+
+ // These are the 2 byte characters.
+ if ((n > 1) && (b[0] >= 0x81 && b[0] <= 0xFE) && (b[1] >= 0x40 && b[1] <= 0xFE && b[1] != 0x7F)) {
+ return 2;
+ }
+
+ // These are the 4 byte characters.
+ if ((n > 3) && ((b[0] >= 0x81 && b[0] <= 0xFE) && (b[1] >= 0x30 && b[1] <= 0x39) && (b[2] >= 0x81 && b[2] <= 0xFE) && (b[3] >= 0x30 && b[3] <= 0x39))) {
+ return 4;
+ }
+
+ return 0;
+}
+
+/**
+ * Returns the size of the next character in the GBK encoding, or 0 if a
+ * character cannot be decoded from the given bytes.
+ */
+static size_t
+pm_encoding_gbk_char_width(const uint8_t *b, ptrdiff_t n) {
+ // These are the single byte characters.
+ if ((n > 0) && (*b <= 0x80)) {
+ return 1;
+ }
+
+ // These are the double byte characters.
+ if (
+ (n > 1) &&
+ (
+ ((b[0] >= 0xA1 && b[0] <= 0xA9) && (b[1] >= 0xA1 && b[1] <= 0xFE)) || // GBK/1
+ ((b[0] >= 0xB0 && b[0] <= 0xF7) && (b[1] >= 0xA1 && b[1] <= 0xFE)) || // GBK/2
+ ((b[0] >= 0x81 && b[0] <= 0xA0) && (b[1] >= 0x40 && b[1] <= 0xFE) && (b[1] != 0x7F)) || // GBK/3
+ ((b[0] >= 0xAA && b[0] <= 0xFE) && (b[1] >= 0x40 && b[1] <= 0xA0) && (b[1] != 0x7F)) || // GBK/4
+ ((b[0] >= 0xA8 && b[0] <= 0xA9) && (b[1] >= 0x40 && b[1] <= 0xA0) && (b[1] != 0x7F)) || // GBK/5
+ ((b[0] >= 0xAA && b[0] <= 0xAF) && (b[1] >= 0xA1 && b[1] <= 0xFE)) || // user-defined 1
+ ((b[0] >= 0xF8 && b[0] <= 0xFE) && (b[1] >= 0xA1 && b[1] <= 0xFE)) || // user-defined 2
+ ((b[0] >= 0xA1 && b[0] <= 0xA7) && (b[1] >= 0x40 && b[1] <= 0xA0) && (b[1] != 0x7F)) // user-defined 3
+ )
+ ) {
+ return 2;
+ }
+
+ return 0;
+}
+
+#endif
+
+/**
+ * This is the table of all of the encodings that prism supports.
+ */
+const pm_encoding_t pm_encodings[] = {
+ [PM_ENCODING_UTF_8] = {
+ .name = "UTF-8",
+ .char_width = pm_encoding_utf_8_char_width,
+ .alnum_char = pm_encoding_utf_8_alnum_char,
+ .alpha_char = pm_encoding_utf_8_alpha_char,
+ .isupper_char = pm_encoding_utf_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_US_ASCII] = {
+ .name = "US-ASCII",
+ .char_width = pm_encoding_ascii_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char,
+ .alpha_char = pm_encoding_ascii_alpha_char,
+ .isupper_char = pm_encoding_ascii_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ASCII_8BIT] = {
+ .name = "ASCII-8BIT",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char,
+ .alpha_char = pm_encoding_ascii_alpha_char,
+ .isupper_char = pm_encoding_ascii_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_EUC_JP] = {
+ .name = "EUC-JP",
+ .char_width = pm_encoding_euc_jp_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_euc_jp_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_WINDOWS_31J] = {
+ .name = "Windows-31J",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ [PM_ENCODING_BIG5] = {
+ .name = "Big5",
+ .char_width = pm_encoding_big5_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_BIG5_HKSCS] = {
+ .name = "Big5-HKSCS",
+ .char_width = pm_encoding_big5_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_BIG5_UAO] = {
+ .name = "Big5-UAO",
+ .char_width = pm_encoding_big5_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_CESU_8] = {
+ .name = "CESU-8",
+ .char_width = pm_encoding_cesu_8_char_width,
+ .alnum_char = pm_encoding_cesu_8_alnum_char,
+ .alpha_char = pm_encoding_cesu_8_alpha_char,
+ .isupper_char = pm_encoding_cesu_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_CP51932] = {
+ .name = "CP51932",
+ .char_width = pm_encoding_euc_jp_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_euc_jp_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_CP850] = {
+ .name = "CP850",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_cp850_alnum_char,
+ .alpha_char = pm_encoding_cp850_alpha_char,
+ .isupper_char = pm_encoding_cp850_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_CP852] = {
+ .name = "CP852",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_cp852_alnum_char,
+ .alpha_char = pm_encoding_cp852_alpha_char,
+ .isupper_char = pm_encoding_cp852_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_CP855] = {
+ .name = "CP855",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_cp855_alnum_char,
+ .alpha_char = pm_encoding_cp855_alpha_char,
+ .isupper_char = pm_encoding_cp855_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_CP949] = {
+ .name = "CP949",
+ .char_width = pm_encoding_cp949_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_CP950] = {
+ .name = "CP950",
+ .char_width = pm_encoding_big5_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_CP951] = {
+ .name = "CP951",
+ .char_width = pm_encoding_big5_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_EMACS_MULE] = {
+ .name = "Emacs-Mule",
+ .char_width = pm_encoding_emacs_mule_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_EUC_JP_MS] = {
+ .name = "eucJP-ms",
+ .char_width = pm_encoding_euc_jp_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_euc_jp_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_EUC_JIS_2004] = {
+ .name = "EUC-JIS-2004",
+ .char_width = pm_encoding_euc_jp_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_euc_jp_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_EUC_KR] = {
+ .name = "EUC-KR",
+ .char_width = pm_encoding_euc_kr_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_EUC_TW] = {
+ .name = "EUC-TW",
+ .char_width = pm_encoding_euc_tw_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_GB12345] = {
+ .name = "GB12345",
+ .char_width = pm_encoding_euc_kr_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_GB18030] = {
+ .name = "GB18030",
+ .char_width = pm_encoding_gb18030_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_GB1988] = {
+ .name = "GB1988",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_gb1988_alnum_char,
+ .alpha_char = pm_encoding_gb1988_alpha_char,
+ .isupper_char = pm_encoding_gb1988_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_GB2312] = {
+ .name = "GB2312",
+ .char_width = pm_encoding_euc_kr_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_GBK] = {
+ .name = "GBK",
+ .char_width = pm_encoding_gbk_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_IBM437] = {
+ .name = "IBM437",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm437_alnum_char,
+ .alpha_char = pm_encoding_ibm437_alpha_char,
+ .isupper_char = pm_encoding_ibm437_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM720] = {
+ .name = "IBM720",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm720_alnum_char,
+ .alpha_char = pm_encoding_ibm720_alpha_char,
+ .isupper_char = pm_encoding_ibm720_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM737] = {
+ .name = "IBM737",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm737_alnum_char,
+ .alpha_char = pm_encoding_ibm737_alpha_char,
+ .isupper_char = pm_encoding_ibm737_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM775] = {
+ .name = "IBM775",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm775_alnum_char,
+ .alpha_char = pm_encoding_ibm775_alpha_char,
+ .isupper_char = pm_encoding_ibm775_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM852] = {
+ .name = "IBM852",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm852_alnum_char,
+ .alpha_char = pm_encoding_ibm852_alpha_char,
+ .isupper_char = pm_encoding_ibm852_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM855] = {
+ .name = "IBM855",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm855_alnum_char,
+ .alpha_char = pm_encoding_ibm855_alpha_char,
+ .isupper_char = pm_encoding_ibm855_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM857] = {
+ .name = "IBM857",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm857_alnum_char,
+ .alpha_char = pm_encoding_ibm857_alpha_char,
+ .isupper_char = pm_encoding_ibm857_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM860] = {
+ .name = "IBM860",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm860_alnum_char,
+ .alpha_char = pm_encoding_ibm860_alpha_char,
+ .isupper_char = pm_encoding_ibm860_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM861] = {
+ .name = "IBM861",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm861_alnum_char,
+ .alpha_char = pm_encoding_ibm861_alpha_char,
+ .isupper_char = pm_encoding_ibm861_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM862] = {
+ .name = "IBM862",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm862_alnum_char,
+ .alpha_char = pm_encoding_ibm862_alpha_char,
+ .isupper_char = pm_encoding_ibm862_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM863] = {
+ .name = "IBM863",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm863_alnum_char,
+ .alpha_char = pm_encoding_ibm863_alpha_char,
+ .isupper_char = pm_encoding_ibm863_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM864] = {
+ .name = "IBM864",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm864_alnum_char,
+ .alpha_char = pm_encoding_ibm864_alpha_char,
+ .isupper_char = pm_encoding_ibm864_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM865] = {
+ .name = "IBM865",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm865_alnum_char,
+ .alpha_char = pm_encoding_ibm865_alpha_char,
+ .isupper_char = pm_encoding_ibm865_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM866] = {
+ .name = "IBM866",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm866_alnum_char,
+ .alpha_char = pm_encoding_ibm866_alpha_char,
+ .isupper_char = pm_encoding_ibm866_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_IBM869] = {
+ .name = "IBM869",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm869_alnum_char,
+ .alpha_char = pm_encoding_ibm869_alpha_char,
+ .isupper_char = pm_encoding_ibm869_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_1] = {
+ .name = "ISO-8859-1",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_1_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_1_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_1_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_2] = {
+ .name = "ISO-8859-2",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_2_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_2_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_2_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_3] = {
+ .name = "ISO-8859-3",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_3_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_3_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_3_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_4] = {
+ .name = "ISO-8859-4",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_4_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_4_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_4_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_5] = {
+ .name = "ISO-8859-5",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_5_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_5_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_5_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_6] = {
+ .name = "ISO-8859-6",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_6_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_6_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_6_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_7] = {
+ .name = "ISO-8859-7",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_7_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_7_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_7_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_8] = {
+ .name = "ISO-8859-8",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_8_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_8_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_8_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_9] = {
+ .name = "ISO-8859-9",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_9_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_9_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_9_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_10] = {
+ .name = "ISO-8859-10",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_10_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_10_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_10_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_11] = {
+ .name = "ISO-8859-11",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_11_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_11_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_11_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_13] = {
+ .name = "ISO-8859-13",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_13_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_13_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_13_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_14] = {
+ .name = "ISO-8859-14",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_14_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_14_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_14_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_15] = {
+ .name = "ISO-8859-15",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_15_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_15_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_15_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_ISO_8859_16] = {
+ .name = "ISO-8859-16",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_iso_8859_16_alnum_char,
+ .alpha_char = pm_encoding_iso_8859_16_alpha_char,
+ .isupper_char = pm_encoding_iso_8859_16_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_KOI8_R] = {
+ .name = "KOI8-R",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_koi8_r_alnum_char,
+ .alpha_char = pm_encoding_koi8_r_alpha_char,
+ .isupper_char = pm_encoding_koi8_r_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_KOI8_U] = {
+ .name = "KOI8-U",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_koi8_u_alnum_char,
+ .alpha_char = pm_encoding_koi8_u_alpha_char,
+ .isupper_char = pm_encoding_koi8_u_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_CENT_EURO] = {
+ .name = "macCentEuro",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_cent_euro_alnum_char,
+ .alpha_char = pm_encoding_mac_cent_euro_alpha_char,
+ .isupper_char = pm_encoding_mac_cent_euro_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_CROATIAN] = {
+ .name = "macCroatian",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_croatian_alnum_char,
+ .alpha_char = pm_encoding_mac_croatian_alpha_char,
+ .isupper_char = pm_encoding_mac_croatian_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_CYRILLIC] = {
+ .name = "macCyrillic",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_cyrillic_alnum_char,
+ .alpha_char = pm_encoding_mac_cyrillic_alpha_char,
+ .isupper_char = pm_encoding_mac_cyrillic_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_GREEK] = {
+ .name = "macGreek",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_greek_alnum_char,
+ .alpha_char = pm_encoding_mac_greek_alpha_char,
+ .isupper_char = pm_encoding_mac_greek_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_ICELAND] = {
+ .name = "macIceland",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_iceland_alnum_char,
+ .alpha_char = pm_encoding_mac_iceland_alpha_char,
+ .isupper_char = pm_encoding_mac_iceland_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_JAPANESE] = {
+ .name = "MacJapanese",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_MAC_ROMAN] = {
+ .name = "macRoman",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_roman_alnum_char,
+ .alpha_char = pm_encoding_mac_roman_alpha_char,
+ .isupper_char = pm_encoding_mac_roman_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_ROMANIA] = {
+ .name = "macRomania",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_romania_alnum_char,
+ .alpha_char = pm_encoding_mac_romania_alpha_char,
+ .isupper_char = pm_encoding_mac_romania_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_THAI] = {
+ .name = "macThai",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_thai_alnum_char,
+ .alpha_char = pm_encoding_mac_thai_alpha_char,
+ .isupper_char = pm_encoding_mac_thai_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_TURKISH] = {
+ .name = "macTurkish",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_turkish_alnum_char,
+ .alpha_char = pm_encoding_mac_turkish_alpha_char,
+ .isupper_char = pm_encoding_mac_turkish_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_MAC_UKRAINE] = {
+ .name = "macUkraine",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_ukraine_alnum_char,
+ .alpha_char = pm_encoding_mac_ukraine_alpha_char,
+ .isupper_char = pm_encoding_mac_ukraine_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_SHIFT_JIS] = {
+ .name = "Shift_JIS",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_SJIS_DOCOMO] = {
+ .name = "SJIS-DoCoMo",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_SJIS_KDDI] = {
+ .name = "SJIS-KDDI",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_SJIS_SOFTBANK] = {
+ .name = "SJIS-SoftBank",
+ .char_width = pm_encoding_shift_jis_char_width,
+ .alnum_char = pm_encoding_shift_jis_alnum_char,
+ .alpha_char = pm_encoding_shift_jis_alpha_char,
+ .isupper_char = pm_encoding_shift_jis_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_STATELESS_ISO_2022_JP] = {
+ .name = "stateless-ISO-2022-JP",
+ .char_width = pm_encoding_emacs_mule_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_STATELESS_ISO_2022_JP_KDDI] = {
+ .name = "stateless-ISO-2022-JP-KDDI",
+ .char_width = pm_encoding_emacs_mule_char_width,
+ .alnum_char = pm_encoding_ascii_alnum_char_7bit,
+ .alpha_char = pm_encoding_ascii_alpha_char_7bit,
+ .isupper_char = pm_encoding_ascii_isupper_char_7bit,
+ .multibyte = true
+ },
+ [PM_ENCODING_TIS_620] = {
+ .name = "TIS-620",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_tis_620_alnum_char,
+ .alpha_char = pm_encoding_tis_620_alpha_char,
+ .isupper_char = pm_encoding_tis_620_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_UTF8_MAC] = {
+ .name = "UTF8-MAC",
+ .char_width = pm_encoding_utf_8_char_width,
+ .alnum_char = pm_encoding_utf_8_alnum_char,
+ .alpha_char = pm_encoding_utf_8_alpha_char,
+ .isupper_char = pm_encoding_utf_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_UTF8_DOCOMO] = {
+ .name = "UTF8-DoCoMo",
+ .char_width = pm_encoding_utf_8_char_width,
+ .alnum_char = pm_encoding_utf_8_alnum_char,
+ .alpha_char = pm_encoding_utf_8_alpha_char,
+ .isupper_char = pm_encoding_utf_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_UTF8_KDDI] = {
+ .name = "UTF8-KDDI",
+ .char_width = pm_encoding_utf_8_char_width,
+ .alnum_char = pm_encoding_utf_8_alnum_char,
+ .alpha_char = pm_encoding_utf_8_alpha_char,
+ .isupper_char = pm_encoding_utf_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_UTF8_SOFTBANK] = {
+ .name = "UTF8-SoftBank",
+ .char_width = pm_encoding_utf_8_char_width,
+ .alnum_char = pm_encoding_utf_8_alnum_char,
+ .alpha_char = pm_encoding_utf_8_alpha_char,
+ .isupper_char = pm_encoding_utf_8_isupper_char,
+ .multibyte = true
+ },
+ [PM_ENCODING_WINDOWS_1250] = {
+ .name = "Windows-1250",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1250_alnum_char,
+ .alpha_char = pm_encoding_windows_1250_alpha_char,
+ .isupper_char = pm_encoding_windows_1250_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1251] = {
+ .name = "Windows-1251",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1251_alnum_char,
+ .alpha_char = pm_encoding_windows_1251_alpha_char,
+ .isupper_char = pm_encoding_windows_1251_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1252] = {
+ .name = "Windows-1252",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1252_alnum_char,
+ .alpha_char = pm_encoding_windows_1252_alpha_char,
+ .isupper_char = pm_encoding_windows_1252_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1253] = {
+ .name = "Windows-1253",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1253_alnum_char,
+ .alpha_char = pm_encoding_windows_1253_alpha_char,
+ .isupper_char = pm_encoding_windows_1253_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1254] = {
+ .name = "Windows-1254",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1254_alnum_char,
+ .alpha_char = pm_encoding_windows_1254_alpha_char,
+ .isupper_char = pm_encoding_windows_1254_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1255] = {
+ .name = "Windows-1255",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1255_alnum_char,
+ .alpha_char = pm_encoding_windows_1255_alpha_char,
+ .isupper_char = pm_encoding_windows_1255_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1256] = {
+ .name = "Windows-1256",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1256_alnum_char,
+ .alpha_char = pm_encoding_windows_1256_alpha_char,
+ .isupper_char = pm_encoding_windows_1256_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1257] = {
+ .name = "Windows-1257",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1257_alnum_char,
+ .alpha_char = pm_encoding_windows_1257_alpha_char,
+ .isupper_char = pm_encoding_windows_1257_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_1258] = {
+ .name = "Windows-1258",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_1258_alnum_char,
+ .alpha_char = pm_encoding_windows_1258_alpha_char,
+ .isupper_char = pm_encoding_windows_1258_isupper_char,
+ .multibyte = false
+ },
+ [PM_ENCODING_WINDOWS_874] = {
+ .name = "Windows-874",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_windows_874_alnum_char,
+ .alpha_char = pm_encoding_windows_874_alpha_char,
+ .isupper_char = pm_encoding_windows_874_isupper_char,
+ .multibyte = false
+ }
+#endif
+};
+
+/**
+ * Parse the given name of an encoding and return a pointer to the corresponding
+ * encoding struct if one can be found, otherwise return NULL.
+ */
+const pm_encoding_t *
+pm_encoding_find(const uint8_t *start, const uint8_t *end) {
+ size_t width = (size_t) (end - start);
+
+ // First, we're going to check for UTF-8. This is the most common encoding.
+ // UTF-8 can contain extra information at the end about the platform it is
+ // encoded on, such as UTF-8-MAC or UTF-8-UNIX. We'll ignore those suffixes.
+ if ((start + 5 <= end) && (pm_strncasecmp(start, (const uint8_t *) "UTF-8", 5) == 0)) {
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ // We need to explicitly handle UTF-8-HFS, as that one needs to switch
+ // over to being UTF8-MAC.
+ if (width == 9 && (pm_strncasecmp(start + 5, (const uint8_t *) "-HFS", 4) == 0)) {
+ return &pm_encodings[PM_ENCODING_UTF8_MAC];
+ }
+#endif
+
+ // Otherwise we'll return the default UTF-8 encoding.
+ return PM_ENCODING_UTF_8_ENTRY;
+ }
+
+ // Next, we're going to loop through each of the encodings that we handle
+ // explicitly. If we found one that we understand, we'll use that value.
+#define ENCODING1(name, encoding) if (width == sizeof(name) - 1 && pm_strncasecmp(start, (const uint8_t *) name, width) == 0) return &pm_encodings[encoding];
+#define ENCODING2(name1, name2, encoding) ENCODING1(name1, encoding) ENCODING1(name2, encoding)
+
+ if (width >= 3) {
+ switch (*start) {
+ case 'A': case 'a':
+ ENCODING1("ASCII", PM_ENCODING_US_ASCII);
+ ENCODING1("ASCII-8BIT", PM_ENCODING_ASCII_8BIT);
+ ENCODING1("ANSI_X3.4-1968", PM_ENCODING_US_ASCII);
+ break;
+ case 'B': case 'b':
+ ENCODING1("BINARY", PM_ENCODING_ASCII_8BIT);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("Big5", PM_ENCODING_BIG5);
+ ENCODING2("Big5-HKSCS", "Big5-HKSCS:2008", PM_ENCODING_BIG5_HKSCS);
+ ENCODING1("Big5-UAO", PM_ENCODING_BIG5_UAO);
+#endif
+ break;
+ case 'C': case 'c':
+ ENCODING1("CP65001", PM_ENCODING_UTF_8);
+ ENCODING2("CP932", "csWindows31J", PM_ENCODING_WINDOWS_31J);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("CESU-8", PM_ENCODING_CESU_8);
+ ENCODING1("CP437", PM_ENCODING_IBM437);
+ ENCODING1("CP720", PM_ENCODING_IBM720);
+ ENCODING1("CP737", PM_ENCODING_IBM737);
+ ENCODING1("CP775", PM_ENCODING_IBM775);
+ ENCODING1("CP850", PM_ENCODING_CP850);
+ ENCODING1("CP852", PM_ENCODING_CP852);
+ ENCODING1("CP855", PM_ENCODING_CP855);
+ ENCODING1("CP857", PM_ENCODING_IBM857);
+ ENCODING1("CP860", PM_ENCODING_IBM860);
+ ENCODING1("CP861", PM_ENCODING_IBM861);
+ ENCODING1("CP862", PM_ENCODING_IBM862);
+ ENCODING1("CP864", PM_ENCODING_IBM864);
+ ENCODING1("CP865", PM_ENCODING_IBM865);
+ ENCODING1("CP866", PM_ENCODING_IBM866);
+ ENCODING1("CP869", PM_ENCODING_IBM869);
+ ENCODING1("CP874", PM_ENCODING_WINDOWS_874);
+ ENCODING1("CP878", PM_ENCODING_KOI8_R);
+ ENCODING1("CP863", PM_ENCODING_IBM863);
+ ENCODING1("CP936", PM_ENCODING_GBK);
+ ENCODING1("CP949", PM_ENCODING_CP949);
+ ENCODING1("CP950", PM_ENCODING_CP950);
+ ENCODING1("CP951", PM_ENCODING_CP951);
+ ENCODING1("CP1250", PM_ENCODING_WINDOWS_1250);
+ ENCODING1("CP1251", PM_ENCODING_WINDOWS_1251);
+ ENCODING1("CP1252", PM_ENCODING_WINDOWS_1252);
+ ENCODING1("CP1253", PM_ENCODING_WINDOWS_1253);
+ ENCODING1("CP1254", PM_ENCODING_WINDOWS_1254);
+ ENCODING1("CP1255", PM_ENCODING_WINDOWS_1255);
+ ENCODING1("CP1256", PM_ENCODING_WINDOWS_1256);
+ ENCODING1("CP1257", PM_ENCODING_WINDOWS_1257);
+ ENCODING1("CP1258", PM_ENCODING_WINDOWS_1258);
+ ENCODING1("CP51932", PM_ENCODING_CP51932);
+#endif
+ break;
+ case 'E': case 'e':
+ ENCODING2("EUC-JP", "eucJP", PM_ENCODING_EUC_JP);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING2("eucJP-ms", "euc-jp-ms", PM_ENCODING_EUC_JP_MS);
+ ENCODING2("EUC-JIS-2004", "EUC-JISX0213", PM_ENCODING_EUC_JIS_2004);
+ ENCODING2("EUC-KR", "eucKR", PM_ENCODING_EUC_KR);
+ ENCODING2("EUC-CN", "eucCN", PM_ENCODING_GB2312);
+ ENCODING2("EUC-TW", "eucTW", PM_ENCODING_EUC_TW);
+ ENCODING1("Emacs-Mule", PM_ENCODING_EMACS_MULE);
+#endif
+ break;
+ case 'G': case 'g':
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("GBK", PM_ENCODING_GBK);
+ ENCODING1("GB12345", PM_ENCODING_GB12345);
+ ENCODING1("GB18030", PM_ENCODING_GB18030);
+ ENCODING1("GB1988", PM_ENCODING_GB1988);
+ ENCODING1("GB2312", PM_ENCODING_GB2312);
+#endif
+ break;
+ case 'I': case 'i':
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("IBM437", PM_ENCODING_IBM437);
+ ENCODING1("IBM720", PM_ENCODING_IBM720);
+ ENCODING1("IBM737", PM_ENCODING_IBM737);
+ ENCODING1("IBM775", PM_ENCODING_IBM775);
+ ENCODING1("IBM850", PM_ENCODING_CP850);
+ ENCODING1("IBM852", PM_ENCODING_IBM852);
+ ENCODING1("IBM855", PM_ENCODING_IBM855);
+ ENCODING1("IBM857", PM_ENCODING_IBM857);
+ ENCODING1("IBM860", PM_ENCODING_IBM860);
+ ENCODING1("IBM861", PM_ENCODING_IBM861);
+ ENCODING1("IBM862", PM_ENCODING_IBM862);
+ ENCODING1("IBM863", PM_ENCODING_IBM863);
+ ENCODING1("IBM864", PM_ENCODING_IBM864);
+ ENCODING1("IBM865", PM_ENCODING_IBM865);
+ ENCODING1("IBM866", PM_ENCODING_IBM866);
+ ENCODING1("IBM869", PM_ENCODING_IBM869);
+ ENCODING2("ISO-8859-1", "ISO8859-1", PM_ENCODING_ISO_8859_1);
+ ENCODING2("ISO-8859-2", "ISO8859-2", PM_ENCODING_ISO_8859_2);
+ ENCODING2("ISO-8859-3", "ISO8859-3", PM_ENCODING_ISO_8859_3);
+ ENCODING2("ISO-8859-4", "ISO8859-4", PM_ENCODING_ISO_8859_4);
+ ENCODING2("ISO-8859-5", "ISO8859-5", PM_ENCODING_ISO_8859_5);
+ ENCODING2("ISO-8859-6", "ISO8859-6", PM_ENCODING_ISO_8859_6);
+ ENCODING2("ISO-8859-7", "ISO8859-7", PM_ENCODING_ISO_8859_7);
+ ENCODING2("ISO-8859-8", "ISO8859-8", PM_ENCODING_ISO_8859_8);
+ ENCODING2("ISO-8859-9", "ISO8859-9", PM_ENCODING_ISO_8859_9);
+ ENCODING2("ISO-8859-10", "ISO8859-10", PM_ENCODING_ISO_8859_10);
+ ENCODING2("ISO-8859-11", "ISO8859-11", PM_ENCODING_ISO_8859_11);
+ ENCODING2("ISO-8859-13", "ISO8859-13", PM_ENCODING_ISO_8859_13);
+ ENCODING2("ISO-8859-14", "ISO8859-14", PM_ENCODING_ISO_8859_14);
+ ENCODING2("ISO-8859-15", "ISO8859-15", PM_ENCODING_ISO_8859_15);
+ ENCODING2("ISO-8859-16", "ISO8859-16", PM_ENCODING_ISO_8859_16);
+#endif
+ break;
+ case 'K': case 'k':
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("KOI8-R", PM_ENCODING_KOI8_R);
+ ENCODING1("KOI8-U", PM_ENCODING_KOI8_U);
+#endif
+ break;
+ case 'M': case 'm':
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("macCentEuro", PM_ENCODING_MAC_CENT_EURO);
+ ENCODING1("macCroatian", PM_ENCODING_MAC_CROATIAN);
+ ENCODING1("macCyrillic", PM_ENCODING_MAC_CYRILLIC);
+ ENCODING1("macGreek", PM_ENCODING_MAC_GREEK);
+ ENCODING1("macIceland", PM_ENCODING_MAC_ICELAND);
+ ENCODING1("MacJapanese", PM_ENCODING_MAC_JAPANESE);
+ ENCODING1("MacJapan", PM_ENCODING_MAC_JAPANESE);
+ ENCODING1("macRoman", PM_ENCODING_MAC_ROMAN);
+ ENCODING1("macRomania", PM_ENCODING_MAC_ROMANIA);
+ ENCODING1("macThai", PM_ENCODING_MAC_THAI);
+ ENCODING1("macTurkish", PM_ENCODING_MAC_TURKISH);
+ ENCODING1("macUkraine", PM_ENCODING_MAC_UKRAINE);
+#endif
+ break;
+ case 'P': case 'p':
+ ENCODING1("PCK", PM_ENCODING_WINDOWS_31J);
+ break;
+ case 'S': case 's':
+ ENCODING1("SJIS", PM_ENCODING_WINDOWS_31J);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("Shift_JIS", PM_ENCODING_SHIFT_JIS);
+ ENCODING1("SJIS-DoCoMo", PM_ENCODING_SJIS_DOCOMO);
+ ENCODING1("SJIS-KDDI", PM_ENCODING_SJIS_KDDI);
+ ENCODING1("SJIS-SoftBank", PM_ENCODING_SJIS_SOFTBANK);
+ ENCODING1("stateless-ISO-2022-JP", PM_ENCODING_STATELESS_ISO_2022_JP);
+ ENCODING1("stateless-ISO-2022-JP-KDDI", PM_ENCODING_STATELESS_ISO_2022_JP_KDDI);
+#endif
+ break;
+ case 'T': case 't':
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("TIS-620", PM_ENCODING_TIS_620);
+#endif
+ break;
+ case 'U': case 'u':
+ ENCODING1("US-ASCII", PM_ENCODING_US_ASCII);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING2("UTF8-MAC", "UTF-8-HFS", PM_ENCODING_UTF8_MAC);
+ ENCODING1("UTF8-DoCoMo", PM_ENCODING_UTF8_DOCOMO);
+ ENCODING1("UTF8-KDDI", PM_ENCODING_UTF8_KDDI);
+ ENCODING1("UTF8-SoftBank", PM_ENCODING_UTF8_SOFTBANK);
+#endif
+ break;
+ case 'W': case 'w':
+ ENCODING1("Windows-31J", PM_ENCODING_WINDOWS_31J);
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ ENCODING1("Windows-874", PM_ENCODING_WINDOWS_874);
+ ENCODING1("Windows-1250", PM_ENCODING_WINDOWS_1250);
+ ENCODING1("Windows-1251", PM_ENCODING_WINDOWS_1251);
+ ENCODING1("Windows-1252", PM_ENCODING_WINDOWS_1252);
+ ENCODING1("Windows-1253", PM_ENCODING_WINDOWS_1253);
+ ENCODING1("Windows-1254", PM_ENCODING_WINDOWS_1254);
+ ENCODING1("Windows-1255", PM_ENCODING_WINDOWS_1255);
+ ENCODING1("Windows-1256", PM_ENCODING_WINDOWS_1256);
+ ENCODING1("Windows-1257", PM_ENCODING_WINDOWS_1257);
+ ENCODING1("Windows-1258", PM_ENCODING_WINDOWS_1258);
+#endif
+ break;
+ case '6':
+ ENCODING1("646", PM_ENCODING_US_ASCII);
+ break;
+ }
+ }
+
+#undef ENCODING2
+#undef ENCODING1
+
+ // If we didn't match any encodings, return NULL.
+ return NULL;
+}
diff --git a/prism/excludes.h b/prism/excludes.h
new file mode 100644
index 0000000000..8600622f63
--- /dev/null
+++ b/prism/excludes.h
@@ -0,0 +1,29 @@
+/**
+ * @file excludes.h
+ *
+ * A header file that defines macros to exclude certain features of the prism
+ * library. This is useful for reducing the size of the library when certain
+ * features are not needed.
+ */
+#ifndef PRISM_EXCLUDES_H
+#define PRISM_EXCLUDES_H
+
+/**
+ * If PRISM_BUILD_MINIMAL is defined, then we're going to define every possible
+ * switch that will turn off certain features of prism.
+ */
+#ifdef PRISM_BUILD_MINIMAL
+ /** Exclude the serialization API. */
+ #define PRISM_EXCLUDE_SERIALIZATION
+
+ /** Exclude the JSON serialization API. */
+ #define PRISM_EXCLUDE_JSON
+
+ /** Exclude the prettyprint API. */
+ #define PRISM_EXCLUDE_PRETTYPRINT
+
+ /** Exclude the full set of encodings, using the minimal only. */
+ #define PRISM_ENCODING_EXCLUDE_FULL
+#endif
+
+#endif
diff --git a/prism/extension.c b/prism/extension.c
new file mode 100644
index 0000000000..27df8dac50
--- /dev/null
+++ b/prism/extension.c
@@ -0,0 +1,1489 @@
+#include "prism/extension.h"
+
+#ifdef _WIN32
+#include <ruby/win32.h>
+#endif
+
+#include <errno.h>
+
+// NOTE: this file should contain only bindings. All non-trivial logic should be
+// in libprism so it can be shared its the various callers.
+
+VALUE rb_cPrism;
+VALUE rb_cPrismNode;
+VALUE rb_cPrismSource;
+VALUE rb_cPrismToken;
+VALUE rb_cPrismLocation;
+
+VALUE rb_cPrismComment;
+VALUE rb_cPrismInlineComment;
+VALUE rb_cPrismEmbDocComment;
+VALUE rb_cPrismMagicComment;
+VALUE rb_cPrismParseError;
+VALUE rb_cPrismParseWarning;
+VALUE rb_cPrismResult;
+VALUE rb_cPrismParseResult;
+VALUE rb_cPrismLexResult;
+VALUE rb_cPrismParseLexResult;
+VALUE rb_cPrismStringQuery;
+VALUE rb_cPrismScope;
+VALUE rb_cPrismCurrentVersionError;
+
+VALUE rb_cPrismDebugEncoding;
+
+ID rb_id_option_command_line;
+ID rb_id_option_encoding;
+ID rb_id_option_filepath;
+ID rb_id_option_freeze;
+ID rb_id_option_frozen_string_literal;
+ID rb_id_option_line;
+ID rb_id_option_main_script;
+ID rb_id_option_partial_script;
+ID rb_id_option_scopes;
+ID rb_id_option_version;
+ID rb_id_source_for;
+ID rb_id_forwarding_positionals;
+ID rb_id_forwarding_keywords;
+ID rb_id_forwarding_block;
+ID rb_id_forwarding_all;
+
+/******************************************************************************/
+/* IO of Ruby code */
+/******************************************************************************/
+
+/**
+ * Check if the given VALUE is a string. If it's not a string, then raise a
+ * TypeError. Otherwise return the VALUE as a C string.
+ */
+static const char *
+check_string(VALUE value) {
+ // Check if the value is a string. If it's not, then raise a type error.
+ if (!RB_TYPE_P(value, T_STRING)) {
+ rb_raise(rb_eTypeError, "wrong argument type %" PRIsVALUE " (expected String)", rb_obj_class(value));
+ }
+
+ // Otherwise, return the value as a C string.
+ return RSTRING_PTR(value);
+}
+
+
+/******************************************************************************/
+/* Building C options from Ruby options */
+/******************************************************************************/
+
+/**
+ * Build the scopes associated with the provided Ruby keyword value.
+ */
+static void
+build_options_scopes(pm_options_t *options, VALUE scopes) {
+ // Check if the value is an array. If it's not, then raise a type error.
+ if (!RB_TYPE_P(scopes, T_ARRAY)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(scopes));
+ }
+
+ // Initialize the scopes array.
+ size_t scopes_count = RARRAY_LEN(scopes);
+ if (!pm_options_scopes_init(options, scopes_count)) {
+ rb_raise(rb_eNoMemError, "failed to allocate memory");
+ }
+
+ // Iterate over the scopes and add them to the options.
+ for (size_t scope_index = 0; scope_index < scopes_count; scope_index++) {
+ VALUE scope = rb_ary_entry(scopes, scope_index);
+
+ // The scope can be either an array or it can be a Prism::Scope object.
+ // Parse out the correct values here from either.
+ VALUE locals;
+ uint8_t forwarding = PM_OPTIONS_SCOPE_FORWARDING_NONE;
+
+ if (RB_TYPE_P(scope, T_ARRAY)) {
+ locals = scope;
+ } else if (rb_obj_is_kind_of(scope, rb_cPrismScope)) {
+ locals = rb_ivar_get(scope, rb_intern("@locals"));
+ if (!RB_TYPE_P(locals, T_ARRAY)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(locals));
+ }
+
+ VALUE names = rb_ivar_get(scope, rb_intern("@forwarding"));
+ if (!RB_TYPE_P(names, T_ARRAY)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array)", rb_obj_class(names));
+ }
+
+ size_t names_count = RARRAY_LEN(names);
+ for (size_t name_index = 0; name_index < names_count; name_index++) {
+ VALUE name = rb_ary_entry(names, name_index);
+
+ // Check that the name is a symbol. If it's not, then raise
+ // a type error.
+ if (!RB_TYPE_P(name, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Symbol)", rb_obj_class(name));
+ }
+
+ ID id = SYM2ID(name);
+ if (id == rb_id_forwarding_positionals) {
+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_POSITIONALS;
+ } else if (id == rb_id_forwarding_keywords) {
+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_KEYWORDS;
+ } else if (id == rb_id_forwarding_block) {
+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_BLOCK;
+ } else if (id == rb_id_forwarding_all) {
+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_ALL;
+ } else {
+ rb_raise(rb_eArgError, "invalid forwarding value: %" PRIsVALUE, name);
+ }
+ }
+ } else {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array or Prism::Scope)", rb_obj_class(scope));
+ }
+
+ // Initialize the scope array.
+ size_t locals_count = RARRAY_LEN(locals);
+ pm_options_scope_t *options_scope = pm_options_scope_mut(options, scope_index);
+ pm_options_scope_init(options_scope, locals_count);
+
+ // Iterate over the locals and add them to the scope.
+ for (size_t local_index = 0; local_index < locals_count; local_index++) {
+ VALUE local = rb_ary_entry(locals, local_index);
+
+ // Check that the local is a symbol. If it's not, then raise a
+ // type error.
+ if (!RB_TYPE_P(local, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Symbol)", rb_obj_class(local));
+ }
+
+ // Add the local to the scope.
+ pm_string_t *scope_local = pm_options_scope_local_mut(options_scope, local_index);
+ const char *name = rb_id2name(SYM2ID(local));
+ pm_string_constant_init(scope_local, name, strlen(name));
+ }
+
+ // Now set the forwarding options.
+ pm_options_scope_forwarding_set(options_scope, forwarding);
+ }
+}
+
+/**
+ * An iterator function that is called for each key-value in the keywords hash.
+ */
+static int
+build_options_i(VALUE key, VALUE value, VALUE argument) {
+ pm_options_t *options = (pm_options_t *) argument;
+ ID key_id = SYM2ID(key);
+
+ if (key_id == rb_id_option_filepath) {
+ if (!NIL_P(value)) pm_options_filepath_set(options, check_string(value));
+ } else if (key_id == rb_id_option_encoding) {
+ if (!NIL_P(value)) {
+ if (value == Qfalse) {
+ pm_options_encoding_locked_set(options, true);
+ } else {
+ pm_options_encoding_set(options, rb_enc_name(rb_to_encoding(value)));
+ }
+ }
+ } else if (key_id == rb_id_option_line) {
+ if (!NIL_P(value)) pm_options_line_set(options, NUM2INT(value));
+ } else if (key_id == rb_id_option_frozen_string_literal) {
+ if (!NIL_P(value)) pm_options_frozen_string_literal_set(options, RTEST(value));
+ } else if (key_id == rb_id_option_version) {
+ if (!NIL_P(value)) {
+ const char *version = check_string(value);
+
+ if (RSTRING_LEN(value) == 7 && strncmp(version, "current", 7) == 0) {
+ if (!pm_options_version_set(options, ruby_version, 3)) {
+ rb_exc_raise(rb_exc_new_cstr(rb_cPrismCurrentVersionError, ruby_version));
+ }
+ } else if (RSTRING_LEN(value) == 7 && strncmp(version, "nearest", 7) == 0) {
+ if (!pm_options_version_set(options, ruby_version, 3)) {
+ // Prism doesn't know this specific version. Is it lower?
+ if (ruby_version[0] < '3' || (ruby_version[0] == '3' && ruby_version[2] < '3')) {
+ pm_options_version_set_lowest(options);
+ } else {
+ // Must be higher.
+ pm_options_version_set_highest(options);
+ }
+ }
+ } else if (!pm_options_version_set(options, version, RSTRING_LEN(value))) {
+ rb_raise(rb_eArgError, "invalid version: %" PRIsVALUE, value);
+ }
+ }
+ } else if (key_id == rb_id_option_scopes) {
+ if (!NIL_P(value)) build_options_scopes(options, value);
+ } else if (key_id == rb_id_option_command_line) {
+ if (!NIL_P(value)) {
+ const char *string = check_string(value);
+ uint8_t command_line = 0;
+
+ for (size_t index = 0; index < strlen(string); index++) {
+ switch (string[index]) {
+ case 'a': command_line |= PM_OPTIONS_COMMAND_LINE_A; break;
+ case 'e': command_line |= PM_OPTIONS_COMMAND_LINE_E; break;
+ case 'l': command_line |= PM_OPTIONS_COMMAND_LINE_L; break;
+ case 'n': command_line |= PM_OPTIONS_COMMAND_LINE_N; break;
+ case 'p': command_line |= PM_OPTIONS_COMMAND_LINE_P; break;
+ case 'x': command_line |= PM_OPTIONS_COMMAND_LINE_X; break;
+ default: rb_raise(rb_eArgError, "invalid command line flag: '%c'", string[index]); break;
+ }
+ }
+
+ pm_options_command_line_set(options, command_line);
+ }
+ } else if (key_id == rb_id_option_main_script) {
+ if (!NIL_P(value)) pm_options_main_script_set(options, RTEST(value));
+ } else if (key_id == rb_id_option_partial_script) {
+ if (!NIL_P(value)) pm_options_partial_script_set(options, RTEST(value));
+ } else if (key_id == rb_id_option_freeze) {
+ if (!NIL_P(value)) pm_options_freeze_set(options, RTEST(value));
+ } else {
+ rb_raise(rb_eArgError, "unknown keyword: %" PRIsVALUE, key);
+ }
+
+ return ST_CONTINUE;
+}
+
+/**
+ * We need a struct here to pass through rb_protect and it has to be a single
+ * value. Because the sizeof(VALUE) == sizeof(void *), we're going to pass this
+ * through as an opaque pointer and cast it on both sides.
+ */
+struct build_options_data {
+ pm_options_t *options;
+ VALUE keywords;
+};
+
+/**
+ * Build the set of options from the given keywords. Note that this can raise a
+ * Ruby error if the options are not valid.
+ */
+static VALUE
+build_options(VALUE argument) {
+ struct build_options_data *data = (struct build_options_data *) argument;
+ rb_hash_foreach(data->keywords, build_options_i, (VALUE) data->options);
+ return Qnil;
+}
+
+/**
+ * Extract the options from the given keyword arguments.
+ */
+static void
+extract_options(pm_options_t *options, VALUE filepath, VALUE keywords) {
+ pm_options_line_set(options, 1); /* default */
+
+ if (!NIL_P(keywords)) {
+ struct build_options_data data = { .options = options, .keywords = keywords };
+ struct build_options_data *argument = &data;
+
+ int state = 0;
+ rb_protect(build_options, (VALUE) argument, &state);
+
+ if (state != 0) {
+ pm_options_free(options);
+ rb_jump_tag(state);
+ }
+ }
+
+ if (!NIL_P(filepath)) {
+ if (!RB_TYPE_P(filepath, T_STRING)) {
+ pm_options_free(options);
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected String)", rb_obj_class(filepath));
+ }
+
+ pm_options_filepath_set(options, RSTRING_PTR(filepath));
+ }
+}
+
+/**
+ * Read options for methods that look like (source, **options).
+ */
+static VALUE
+string_options(int argc, VALUE *argv, pm_options_t *options) {
+ VALUE string;
+ VALUE keywords;
+ rb_scan_args(argc, argv, "1:", &string, &keywords);
+
+ if (!RB_TYPE_P(string, T_STRING)) {
+ pm_options_free(options);
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected String)", rb_obj_class(string));
+ }
+
+ extract_options(options, Qnil, keywords);
+ return string;
+}
+
+/**
+ * Read options for methods that look like (filepath, **options).
+ */
+static pm_source_t *
+file_options(int argc, VALUE *argv, pm_options_t *options, VALUE *encoded_filepath) {
+ VALUE filepath;
+ VALUE keywords;
+ rb_scan_args(argc, argv, "1:", &filepath, &keywords);
+
+ if (!RB_TYPE_P(filepath, T_STRING)) {
+ pm_options_free(options);
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected String)", rb_obj_class(filepath));
+ }
+
+ *encoded_filepath = rb_str_encode_ospath(filepath);
+ extract_options(options, *encoded_filepath, keywords);
+
+ const char *source = (const char *) pm_string_source(pm_options_filepath(options));
+ pm_source_init_result_t result;
+ pm_source_t *pm_src = pm_source_file_new(source, &result);
+
+ switch (result) {
+ case PM_SOURCE_INIT_SUCCESS:
+ break;
+ case PM_SOURCE_INIT_ERROR_GENERIC: {
+ pm_options_free(options);
+
+#ifdef _WIN32
+ int e = rb_w32_map_errno(GetLastError());
+#else
+ int e = errno;
+#endif
+
+ rb_syserr_fail(e, source);
+ break;
+ }
+ case PM_SOURCE_INIT_ERROR_DIRECTORY:
+ pm_options_free(options);
+ rb_syserr_fail(EISDIR, source);
+ break;
+ default:
+ pm_options_free(options);
+ rb_raise(rb_eRuntimeError, "Unknown error (%d) initializing file: %s", result, source);
+ break;
+ }
+
+ return pm_src;
+}
+
+#ifndef PRISM_EXCLUDE_SERIALIZATION
+
+/******************************************************************************/
+/* Serializing the AST */
+/******************************************************************************/
+
+/**
+ * Dump the AST corresponding to the given input to a string.
+ */
+static VALUE
+dump_input(const uint8_t *input, size_t input_length, const pm_options_t *options) {
+ pm_buffer_t *buffer = pm_buffer_new();
+ if (!buffer) {
+ rb_raise(rb_eNoMemError, "failed to allocate memory");
+ }
+
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+
+ pm_node_t *node = pm_parse(parser);
+ pm_serialize(parser, node, buffer);
+
+ VALUE result = rb_str_new(pm_buffer_value(buffer), pm_buffer_length(buffer));
+ pm_buffer_free(buffer);
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * dump(source, **options) -> String
+ *
+ * Dump the AST corresponding to the given string to a string. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+dump(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ const uint8_t *source = (const uint8_t *) RSTRING_PTR(string);
+ size_t length = RSTRING_LEN(string);
+
+#ifdef PRISM_BUILD_DEBUG
+ char* dup = xmalloc(length);
+ memcpy(dup, source, length);
+ source = (const uint8_t *) dup;
+#endif
+
+ VALUE value = dump_input(source, length, options);
+ if (pm_options_freeze(options)) rb_obj_freeze(value);
+
+#ifdef PRISM_BUILD_DEBUG
+#ifdef xfree_sized
+ xfree_sized(dup, length);
+#else
+ xfree(dup);
+#endif
+#endif
+
+ pm_options_free(options);
+
+ return value;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * dump_file(filepath, **options) -> String
+ *
+ * Dump the AST corresponding to the given file to a string. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+dump_file(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE value = dump_input(pm_source_source(src), pm_source_length(src), options);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return value;
+}
+
+#endif
+
+/******************************************************************************/
+/* Extracting values for the parse result */
+/******************************************************************************/
+
+/**
+ * The same as rb_class_new_instance, but accepts an additional boolean to
+ * indicate whether or not the resulting class instance should be frozen.
+ */
+static inline VALUE
+rb_class_new_instance_freeze(int argc, const VALUE *argv, VALUE klass, bool freeze) {
+ VALUE value = rb_class_new_instance(argc, argv, klass);
+ if (freeze) rb_obj_freeze(value);
+ return value;
+}
+
+/**
+ * Create a new Location instance from the given parser and bounds.
+ */
+static inline VALUE
+parser_location(VALUE source, bool freeze, uint32_t start, uint32_t length) {
+ VALUE argv[] = { source, LONG2FIX(start), LONG2FIX(length) };
+ return rb_class_new_instance_freeze(3, argv, rb_cPrismLocation, freeze);
+}
+
+/**
+ * Create a new Location instance from the given parser and location.
+ */
+#define PARSER_LOCATION(source, freeze, location) \
+ parser_location(source, freeze, location.start, location.length)
+
+/**
+ * Build a new Comment instance from the given parser and comment.
+ */
+static inline VALUE
+parser_comment(VALUE source, bool freeze, const pm_comment_t *comment) {
+ VALUE argv[] = { PARSER_LOCATION(source, freeze, pm_comment_location(comment)) };
+ VALUE type = (pm_comment_type(comment) == PM_COMMENT_EMBDOC) ? rb_cPrismEmbDocComment : rb_cPrismInlineComment;
+ return rb_class_new_instance_freeze(1, argv, type, freeze);
+}
+
+typedef struct {
+ VALUE comments;
+ VALUE source;
+ bool freeze;
+} parser_comments_each_data_t;
+
+static void
+parser_comments_each(const pm_comment_t *comment, void *data) {
+ parser_comments_each_data_t *each_data = (parser_comments_each_data_t *) data;
+ VALUE value = parser_comment(each_data->source, each_data->freeze, comment);
+ rb_ary_push(each_data->comments, value);
+}
+
+/**
+ * Extract the comments out of the parser into an array.
+ */
+static VALUE
+parser_comments(const pm_parser_t *parser, VALUE source, bool freeze) {
+ VALUE comments = rb_ary_new_capa(pm_parser_comments_size(parser));
+
+ parser_comments_each_data_t each_data = { comments, source, freeze };
+ pm_parser_comments_each(parser, parser_comments_each, &each_data);
+
+ if (freeze) rb_obj_freeze(comments);
+ return comments;
+}
+
+/**
+ * Build a new MagicComment instance from the given parser and magic comment.
+ */
+static inline VALUE
+parser_magic_comment(VALUE source, bool freeze, const pm_magic_comment_t *magic_comment) {
+ pm_location_t key = pm_magic_comment_key(magic_comment);
+ pm_location_t value = pm_magic_comment_value(magic_comment);
+
+ VALUE key_loc = parser_location(source, freeze, key.start, key.length);
+ VALUE value_loc = parser_location(source, freeze, value.start, value.length);
+
+ VALUE argv[] = { key_loc, value_loc };
+ return rb_class_new_instance_freeze(2, argv, rb_cPrismMagicComment, freeze);
+}
+
+typedef struct {
+ VALUE magic_comments;
+ VALUE source;
+ bool freeze;
+} parser_magic_comments_each_data_t;
+
+static void
+parser_magic_comments_each(const pm_magic_comment_t *magic_comment, void *data) {
+ parser_magic_comments_each_data_t *each_data = (parser_magic_comments_each_data_t *) data;
+ VALUE value = parser_magic_comment(each_data->source, each_data->freeze, magic_comment);
+ rb_ary_push(each_data->magic_comments, value);
+}
+
+/**
+ * Extract the magic comments out of the parser into an array.
+ */
+static VALUE
+parser_magic_comments(const pm_parser_t *parser, VALUE source, bool freeze) {
+ VALUE magic_comments = rb_ary_new_capa(pm_parser_magic_comments_size(parser));
+
+ parser_magic_comments_each_data_t each_data = { magic_comments, source, freeze };
+ pm_parser_magic_comments_each(parser, parser_magic_comments_each, &each_data);
+
+ if (freeze) rb_obj_freeze(magic_comments);
+ return magic_comments;
+}
+
+/**
+ * Extract out the data location from the parser into a Location instance if one
+ * exists.
+ */
+static VALUE
+parser_data_loc(const pm_parser_t *parser, VALUE source, bool freeze) {
+ const pm_location_t *data_loc = pm_parser_data_loc(parser);
+
+ if (data_loc->length == 0) {
+ return Qnil;
+ } else {
+ return parser_location(source, freeze, data_loc->start, data_loc->length);
+ }
+}
+
+typedef struct {
+ VALUE errors;
+ rb_encoding *encoding;
+ VALUE source;
+ bool freeze;
+} parser_errors_each_data_t;
+
+static void
+parser_errors_each(const pm_diagnostic_t *diagnostic, void *data) {
+ parser_errors_each_data_t *each_data = (parser_errors_each_data_t *) data;
+
+ VALUE type = ID2SYM(rb_intern(pm_diagnostic_type(diagnostic)));
+ VALUE message = rb_obj_freeze(rb_enc_str_new_cstr(pm_diagnostic_message(diagnostic), each_data->encoding));
+ VALUE location = PARSER_LOCATION(each_data->source, each_data->freeze, pm_diagnostic_location(diagnostic));
+
+ pm_error_level_t error_level = pm_diagnostic_error_level(diagnostic);
+ VALUE level = Qnil;
+
+ switch (error_level) {
+ case PM_ERROR_LEVEL_SYNTAX:
+ level = ID2SYM(rb_intern("syntax"));
+ break;
+ case PM_ERROR_LEVEL_ARGUMENT:
+ level = ID2SYM(rb_intern("argument"));
+ break;
+ case PM_ERROR_LEVEL_LOAD:
+ level = ID2SYM(rb_intern("load"));
+ break;
+ default:
+ rb_raise(rb_eRuntimeError, "Unknown level: %" PRIu8, error_level);
+ }
+
+ VALUE argv[] = { type, message, location, level };
+ VALUE value = rb_class_new_instance_freeze(4, argv, rb_cPrismParseError, each_data->freeze);
+ rb_ary_push(each_data->errors, value);
+}
+
+/**
+ * Extract the errors out of the parser into an array.
+ */
+static VALUE
+parser_errors(const pm_parser_t *parser, rb_encoding *encoding, VALUE source, bool freeze) {
+ VALUE errors = rb_ary_new_capa(pm_parser_errors_size(parser));
+
+ parser_errors_each_data_t each_data = { errors, encoding, source, freeze };
+ pm_parser_errors_each(parser, parser_errors_each, &each_data);
+
+ if (freeze) rb_obj_freeze(errors);
+ return errors;
+}
+
+typedef struct {
+ VALUE warnings;
+ rb_encoding *encoding;
+ VALUE source;
+ bool freeze;
+} parser_warnings_each_data_t;
+
+static void
+parser_warnings_each(const pm_diagnostic_t *diagnostic, void *data) {
+ parser_warnings_each_data_t *each_data = (parser_warnings_each_data_t *) data;
+
+ VALUE type = ID2SYM(rb_intern(pm_diagnostic_type(diagnostic)));
+ VALUE message = rb_obj_freeze(rb_enc_str_new_cstr(pm_diagnostic_message(diagnostic), each_data->encoding));
+ VALUE location = PARSER_LOCATION(each_data->source, each_data->freeze, pm_diagnostic_location(diagnostic));
+
+ pm_warning_level_t warning_level = pm_diagnostic_warning_level(diagnostic);
+ VALUE level = Qnil;
+
+ switch (warning_level) {
+ case PM_WARNING_LEVEL_DEFAULT:
+ level = ID2SYM(rb_intern("default"));
+ break;
+ case PM_WARNING_LEVEL_VERBOSE:
+ level = ID2SYM(rb_intern("verbose"));
+ break;
+ default:
+ rb_raise(rb_eRuntimeError, "Unknown level: %" PRIu8, warning_level);
+ }
+
+ VALUE argv[] = { type, message, location, level };
+ VALUE value = rb_class_new_instance_freeze(4, argv, rb_cPrismParseWarning, each_data->freeze);
+ rb_ary_push(each_data->warnings, value);
+}
+
+/**
+ * Extract the warnings out of the parser into an array.
+ */
+static VALUE
+parser_warnings(const pm_parser_t *parser, rb_encoding *encoding, VALUE source, bool freeze) {
+ VALUE warnings = rb_ary_new_capa(pm_parser_warnings_size(parser));
+
+ parser_warnings_each_data_t each_data = { warnings, encoding, source, freeze };
+ pm_parser_warnings_each(parser, parser_warnings_each, &each_data);
+
+ if (freeze) rb_obj_freeze(warnings);
+ return warnings;
+}
+
+/**
+ * Create a new parse result from the given parser, value, encoding, and source.
+ */
+static VALUE
+parse_result_create(VALUE class, const pm_parser_t *parser, VALUE value, rb_encoding *encoding, VALUE source, bool freeze) {
+ VALUE result_argv[] = {
+ value,
+ parser_comments(parser, source, freeze),
+ parser_magic_comments(parser, source, freeze),
+ parser_data_loc(parser, source, freeze),
+ parser_errors(parser, encoding, source, freeze),
+ parser_warnings(parser, encoding, source, freeze),
+ pm_parser_continuable(parser) ? Qtrue : Qfalse,
+ source
+ };
+
+ return rb_class_new_instance_freeze(8, result_argv, class, freeze);
+}
+
+/******************************************************************************/
+/* Lexing Ruby code */
+/******************************************************************************/
+
+/**
+ * This struct gets stored in the parser and passed in to the lex callback any
+ * time a new token is found. We use it to store the necessary information to
+ * initialize a Token instance.
+ */
+typedef struct {
+ VALUE source;
+ VALUE tokens;
+ rb_encoding *encoding;
+ bool freeze;
+} parse_lex_data_t;
+
+/**
+ * This is passed as a callback to the parser. It gets called every time a new
+ * token is found. Once found, we initialize a new instance of Token and push it
+ * onto the tokens array.
+ */
+static void
+parse_lex_token(pm_parser_t *parser, pm_token_t *token, void *data) {
+ parse_lex_data_t *parse_lex_data = (parse_lex_data_t *) data;
+
+ VALUE value = pm_token_new(parser, token, parse_lex_data->encoding, parse_lex_data->source, parse_lex_data->freeze);
+ VALUE yields = rb_assoc_new(value, INT2FIX(pm_parser_lex_state(parser)));
+
+ if (parse_lex_data->freeze) {
+ rb_obj_freeze(value);
+ rb_obj_freeze(yields);
+ }
+
+ rb_ary_push(parse_lex_data->tokens, yields);
+}
+
+/**
+ * This is called whenever the encoding changes based on the magic comment at
+ * the top of the file. We use it to update the encoding that we are using to
+ * create tokens.
+ */
+static void
+parse_lex_encoding_changed_callback(pm_parser_t *parser) {
+ parse_lex_data_t *parse_lex_data = (parse_lex_data_t *) pm_parser_lex_callback_data(parser);
+ parse_lex_data->encoding = rb_enc_find(pm_parser_encoding_name(parser));
+
+ // Since the encoding changed, we need to go back and change the encoding of
+ // the tokens that were already lexed. This is only going to end up being
+ // one or two tokens, since the encoding can only change at the top of the
+ // file.
+ VALUE tokens = parse_lex_data->tokens;
+ VALUE next_tokens = rb_ary_new();
+
+ for (long index = 0; index < RARRAY_LEN(tokens); index++) {
+ VALUE yields = rb_ary_entry(tokens, index);
+ VALUE token = rb_ary_entry(yields, 0);
+
+ VALUE value = rb_ivar_get(token, rb_intern("@value"));
+ VALUE next_value = rb_str_dup(value);
+
+ rb_enc_associate(next_value, parse_lex_data->encoding);
+ if (parse_lex_data->freeze) rb_obj_freeze(next_value);
+
+ VALUE next_token_argv[] = {
+ parse_lex_data->source,
+ rb_ivar_get(token, rb_intern("@type")),
+ next_value,
+ rb_ivar_get(token, rb_intern("@location"))
+ };
+
+ VALUE next_token = rb_class_new_instance(4, next_token_argv, rb_cPrismToken);
+ VALUE next_yields = rb_assoc_new(next_token, rb_ary_entry(yields, 1));
+
+ if (parse_lex_data->freeze) {
+ rb_obj_freeze(next_token);
+ rb_obj_freeze(next_yields);
+ }
+
+ rb_ary_push(next_tokens, next_yields);
+ }
+
+ rb_ary_replace(parse_lex_data->tokens, next_tokens);
+}
+
+/**
+ * Parse the given input and return a ParseResult containing just the tokens or
+ * the nodes and tokens.
+ */
+static VALUE
+parse_lex_input(const uint8_t *input, size_t input_length, const pm_options_t *options, bool return_nodes) {
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+ pm_parser_encoding_changed_callback_set(parser, parse_lex_encoding_changed_callback);
+
+ VALUE source_string = rb_str_new((const char *) input, input_length);
+ VALUE offsets = rb_ary_new_capa(pm_parser_line_offsets(parser)->size);
+ VALUE source = rb_funcall(rb_cPrismSource, rb_id_source_for, 3, source_string, LONG2NUM(pm_parser_start_line(parser)), offsets);
+
+ parse_lex_data_t parse_lex_data = {
+ .source = source,
+ .tokens = rb_ary_new(),
+ .encoding = rb_enc_find(pm_parser_encoding_name(parser)),
+ .freeze = pm_options_freeze(options),
+ };
+
+ parse_lex_data_t *data = &parse_lex_data;
+ pm_parser_lex_callback_set(parser, parse_lex_token, data);
+
+ pm_node_t *node = pm_parse(parser);
+
+ /* Update the Source object with the correct encoding and line offsets,
+ * which are only available after pm_parse() completes. */
+ rb_encoding *encoding = rb_enc_find(pm_parser_encoding_name(parser));
+ rb_enc_associate(source_string, encoding);
+
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+ for (size_t index = 0; index < line_offsets->size; index++) {
+ rb_ary_store(offsets, (long) index, ULONG2NUM(line_offsets->offsets[index]));
+ }
+
+ if (pm_options_freeze(options)) {
+ rb_obj_freeze(source_string);
+ rb_obj_freeze(offsets);
+ rb_obj_freeze(source);
+ rb_obj_freeze(parse_lex_data.tokens);
+ }
+
+ VALUE result;
+ if (return_nodes) {
+ VALUE value = rb_ary_new_capa(2);
+ rb_ary_push(value, pm_ast_new(parser, node, parse_lex_data.encoding, source, pm_options_freeze(options)));
+ rb_ary_push(value, parse_lex_data.tokens);
+ if (pm_options_freeze(options)) rb_obj_freeze(value);
+ result = parse_result_create(rb_cPrismParseLexResult, parser, value, parse_lex_data.encoding, source, pm_options_freeze(options));
+ } else {
+ result = parse_result_create(rb_cPrismLexResult, parser, parse_lex_data.tokens, parse_lex_data.encoding, source, pm_options_freeze(options));
+ }
+
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * lex(source, **options) -> LexResult
+ *
+ * Return a LexResult instance that contains an array of Token instances
+ * corresponding to the given string. For supported options, see Prism.parse.
+ */
+static VALUE
+lex(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ VALUE result = parse_lex_input((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), options, false);
+ pm_options_free(options);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * lex_file(filepath, **options) -> LexResult
+ *
+ * Return a LexResult instance that contains an array of Token instances
+ * corresponding to the given file. For supported options, see Prism.parse.
+ */
+static VALUE
+lex_file(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE value = parse_lex_input(pm_source_source(src), pm_source_length(src), options, false);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return value;
+}
+
+/******************************************************************************/
+/* Parsing Ruby code */
+/******************************************************************************/
+
+/**
+ * Parse the given input and return a ParseResult instance.
+ */
+static VALUE
+parse_input(const uint8_t *input, size_t input_length, const pm_options_t *options) {
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+
+ pm_node_t *node = pm_parse(parser);
+ rb_encoding *encoding = rb_enc_find(pm_parser_encoding_name(parser));
+
+ bool freeze = pm_options_freeze(options);
+ VALUE source = pm_source_new(parser, encoding, freeze);
+ VALUE value = pm_ast_new(parser, node, encoding, source, freeze);
+ VALUE result = parse_result_create(rb_cPrismParseResult, parser, value, encoding, source, freeze);
+
+ if (freeze) {
+ rb_obj_freeze(source);
+ }
+
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse(source, **options) -> ParseResult
+ *
+ * Parse the given string and return a ParseResult instance. The options that
+ * are supported are:
+ *
+ * * `command_line` - either nil or a string of the various options that were
+ * set on the command line. Valid values are combinations of "a", "l",
+ * "n", "p", and "x".
+ * * `encoding` - the encoding of the source being parsed. This should be an
+ * encoding or nil.
+ * * `filepath` - the filepath of the source being parsed. This should be a
+ * string or nil.
+ * * `freeze` - whether or not to deeply freeze the AST. This should be a
+ * boolean or nil.
+ * * `frozen_string_literal` - whether or not the frozen string literal pragma
+ * has been set. This should be a boolean or nil.
+ * * `line` - the line number that the parse starts on. This should be an
+ * integer or nil. Note that this is 1-indexed.
+ * * `main_script` - a boolean indicating whether or not the source being parsed
+ * is the main script being run by the interpreter. This controls whether
+ * or not shebangs are parsed for additional flags and whether or not the
+ * parser will attempt to find a matching shebang if the first one does
+ * not contain the word "ruby".
+ * * `partial_script` - when the file being parsed is considered a "partial"
+ * script, jumps will not be marked as errors if they are not contained
+ * within loops/blocks. This is used in the case that you're parsing a
+ * script that you know will be embedded inside another script later, but
+ * you do not have that context yet. For example, when parsing an ERB
+ * template that will be evaluated inside another script.
+ * * `scopes` - the locals that are in scope surrounding the code that is being
+ * parsed. This should be an array of arrays of symbols or nil. Scopes are
+ * ordered from the outermost scope to the innermost one.
+ * * `version` - the version of Ruby syntax that prism should used to parse Ruby
+ * code. By default prism assumes you want to parse with the latest
+ * version of Ruby syntax (which you can trigger with `nil` or
+ * `"latest"`). You may also restrict the syntax to a specific version of
+ * Ruby, e.g., with `"3.3.0"`. To parse with the same syntax version that
+ * the current Ruby is running use `version: "current"`. To parse with the
+ * nearest version to the current Ruby that is running, use
+ * `version: "nearest"`. Raises ArgumentError if the version is not
+ * currently supported by Prism.
+ */
+static VALUE
+parse(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ const uint8_t *source = (const uint8_t *) RSTRING_PTR(string);
+ size_t length = RSTRING_LEN(string);
+
+#ifdef PRISM_BUILD_DEBUG
+ char* dup = xmalloc(length);
+ memcpy(dup, source, length);
+ source = (const uint8_t *) dup;
+#endif
+
+ VALUE value = parse_input(source, length, options);
+
+#ifdef PRISM_BUILD_DEBUG
+#ifdef xfree_sized
+ xfree_sized(dup, length);
+#else
+ xfree(dup);
+#endif
+#endif
+
+ pm_options_free(options);
+ return value;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_file(filepath, **options) -> ParseResult
+ *
+ * Parse the given file and return a ParseResult instance. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+parse_file(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE value = parse_input(pm_source_source(src), pm_source_length(src), options);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return value;
+}
+
+/**
+ * Parse the given input and return nothing.
+ */
+static void
+profile_input(const uint8_t *input, size_t input_length, const pm_options_t *options) {
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+
+ pm_parse(parser);
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * profile(source, **options) -> nil
+ *
+ * Parse the given string and return nothing. This method is meant to allow
+ * profilers to avoid the overhead of reifying the AST to Ruby. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+profile(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ profile_input((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), options);
+ pm_options_free(options);
+
+ return Qnil;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * profile_file(filepath, **options) -> nil
+ *
+ * Parse the given file and return nothing. This method is meant to allow
+ * profilers to avoid the overhead of reifying the AST to Ruby. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+profile_file(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ profile_input(pm_source_source(src), pm_source_length(src), options);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return Qnil;
+}
+
+static int
+parse_stream_eof(void *stream) {
+ if (rb_funcall((VALUE) stream, rb_intern("eof?"), 0)) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * An implementation of fgets that is suitable for use with Ruby IO objects.
+ */
+static char *
+parse_stream_fgets(char *string, int size, void *stream) {
+ RUBY_ASSERT(size > 0);
+
+ VALUE line = rb_funcall((VALUE) stream, rb_intern("gets"), 1, INT2FIX(size - 1));
+ if (NIL_P(line)) {
+ return NULL;
+ }
+
+ const char *cstr = RSTRING_PTR(line);
+ long length = RSTRING_LEN(line);
+
+ memcpy(string, cstr, length);
+ string[length] = '\0';
+
+ return string;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_stream(stream, **options) -> ParseResult
+ *
+ * Parse the given object that responds to `gets` and return a ParseResult
+ * instance. The options that are supported are the same as Prism.parse.
+ */
+static VALUE
+parse_stream(int argc, VALUE *argv, VALUE self) {
+ VALUE stream;
+ VALUE keywords;
+ rb_scan_args(argc, argv, "1:", &stream, &keywords);
+
+ pm_options_t *options = pm_options_new();
+ extract_options(options, Qnil, keywords);
+
+ pm_source_t *src = pm_source_stream_new((void *) stream, parse_stream_fgets, parse_stream_eof);
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser;
+
+ pm_node_t *node = pm_parse_stream(&parser, arena, src, options);
+ rb_encoding *encoding = rb_enc_find(pm_parser_encoding_name(parser));
+
+ VALUE source = pm_source_new(parser, encoding, pm_options_freeze(options));
+ VALUE value = pm_ast_new(parser, node, encoding, source, pm_options_freeze(options));
+ VALUE result = parse_result_create(rb_cPrismParseResult, parser, value, encoding, source, pm_options_freeze(options));
+
+ pm_source_free(src);
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+ pm_options_free(options);
+
+ return result;
+}
+
+/**
+ * Parse the given input and return an array of Comment objects.
+ */
+static VALUE
+parse_input_comments(const uint8_t *input, size_t input_length, const pm_options_t *options) {
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+
+ pm_parse(parser);
+ rb_encoding *encoding = rb_enc_find(pm_parser_encoding_name(parser));
+
+ VALUE source = pm_source_new(parser, encoding, pm_options_freeze(options));
+ VALUE comments = parser_comments(parser, source, pm_options_freeze(options));
+
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+
+ return comments;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_comments(source, **options) -> Array
+ *
+ * Parse the given string and return an array of Comment objects. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+parse_comments(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ VALUE result = parse_input_comments((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), options);
+ pm_options_free(options);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_file_comments(filepath, **options) -> Array
+ *
+ * Parse the given file and return an array of Comment objects. For supported
+ * options, see Prism.parse.
+ */
+static VALUE
+parse_file_comments(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE value = parse_input_comments(pm_source_source(src), pm_source_length(src), options);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return value;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_lex(source, **options) -> ParseLexResult
+ *
+ * Parse the given string and return a ParseLexResult instance that contains a
+ * 2-element array, where the first element is the AST and the second element is
+ * an array of Token instances.
+ *
+ * This API is only meant to be used in the case where you need both the AST and
+ * the tokens. If you only need one or the other, use either Prism.parse or
+ * Prism.lex.
+ *
+ * For supported options, see Prism.parse.
+ */
+static VALUE
+parse_lex(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ VALUE value = parse_lex_input((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), options, true);
+ pm_options_free(options);
+
+ return value;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_lex_file(filepath, **options) -> ParseLexResult
+ *
+ * Parse the given file and return a ParseLexResult instance that contains a
+ * 2-element array, where the first element is the AST and the second element is
+ * an array of Token instances.
+ *
+ * This API is only meant to be used in the case where you need both the AST and
+ * the tokens. If you only need one or the other, use either Prism.parse_file
+ * or Prism.lex_file.
+ *
+ * For supported options, see Prism.parse.
+ */
+static VALUE
+parse_lex_file(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE value = parse_lex_input(pm_source_source(src), pm_source_length(src), options, true);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return value;
+}
+
+/**
+ * Parse the given input and return true if it parses without errors.
+ */
+static VALUE
+parse_input_success_p(const uint8_t *input, size_t input_length, const pm_options_t *options) {
+ pm_arena_t *arena = pm_arena_new();
+ pm_parser_t *parser = pm_parser_new(arena, input, input_length, options);
+
+ pm_parse(parser);
+
+ VALUE result = pm_parser_errors_size(parser) == 0 ? Qtrue : Qfalse;
+ pm_parser_free(parser);
+ pm_arena_free(arena);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_success?(source, **options) -> bool
+ *
+ * Parse the given string and return true if it parses without errors. For
+ * supported options, see Prism.parse.
+ */
+static VALUE
+parse_success_p(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+ VALUE string = string_options(argc, argv, options);
+
+ VALUE result = parse_input_success_p((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), options);
+ pm_options_free(options);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_failure?(source, **options) -> bool
+ *
+ * Parse the given string and return true if it parses with errors. For
+ * supported options, see Prism.parse.
+ */
+static VALUE
+parse_failure_p(int argc, VALUE *argv, VALUE self) {
+ return RTEST(parse_success_p(argc, argv, self)) ? Qfalse : Qtrue;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_file_success?(filepath, **options) -> bool
+ *
+ * Parse the given file and return true if it parses without errors. For
+ * supported options, see Prism.parse.
+ */
+static VALUE
+parse_file_success_p(int argc, VALUE *argv, VALUE self) {
+ pm_options_t *options = pm_options_new();
+
+ VALUE encoded_filepath;
+ pm_source_t *src = file_options(argc, argv, options, &encoded_filepath);
+
+ VALUE result = parse_input_success_p(pm_source_source(src), pm_source_length(src), options);
+ pm_source_free(src);
+ pm_options_free(options);
+
+ return result;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * parse_file_failure?(filepath, **options) -> bool
+ *
+ * Parse the given file and return true if it parses with errors. For
+ * supported options, see Prism.parse.
+ */
+static VALUE
+parse_file_failure_p(int argc, VALUE *argv, VALUE self) {
+ return RTEST(parse_file_success_p(argc, argv, self)) ? Qfalse : Qtrue;
+}
+
+/******************************************************************************/
+/* String query methods */
+/******************************************************************************/
+
+/**
+ * Process the result of a call to a string query method and return an
+ * appropriate value.
+ */
+static VALUE
+string_query(pm_string_query_t result) {
+ switch (result) {
+ case PM_STRING_QUERY_ERROR:
+ rb_raise(rb_eArgError, "Invalid or non ascii-compatible encoding");
+ return Qfalse;
+ case PM_STRING_QUERY_FALSE:
+ return Qfalse;
+ case PM_STRING_QUERY_TRUE:
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * local?(string) -> bool
+ *
+ * Returns true if the string constitutes a valid local variable name. Note that
+ * this means the names that can be set through Binding#local_variable_set, not
+ * necessarily the ones that can be set through a local variable assignment.
+ */
+static VALUE
+string_query_local_p(VALUE self, VALUE string) {
+ const uint8_t *source = (const uint8_t *) check_string(string);
+ return string_query(pm_string_query_local(source, RSTRING_LEN(string), rb_enc_get(string)->name));
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * constant?(string) -> bool
+ *
+ * Returns true if the string constitutes a valid constant name. Note that this
+ * means the names that can be set through Module#const_set, not necessarily the
+ * ones that can be set through a constant assignment.
+ */
+static VALUE
+string_query_constant_p(VALUE self, VALUE string) {
+ const uint8_t *source = (const uint8_t *) check_string(string);
+ return string_query(pm_string_query_constant(source, RSTRING_LEN(string), rb_enc_get(string)->name));
+}
+
+/**
+ * :markup: markdown
+ * call-seq:
+ * method_name?(string) -> bool
+ *
+ * Returns true if the string constitutes a valid method name.
+ */
+static VALUE
+string_query_method_name_p(VALUE self, VALUE string) {
+ const uint8_t *source = (const uint8_t *) check_string(string);
+ return string_query(pm_string_query_method_name(source, RSTRING_LEN(string), rb_enc_get(string)->name));
+}
+
+/******************************************************************************/
+/* Initialization of the extension */
+/******************************************************************************/
+
+/**
+ * The init function that Ruby calls when loading this extension.
+ */
+RUBY_FUNC_EXPORTED void
+Init_prism(void) {
+ // Make sure that the prism library version matches the expected version.
+ // Otherwise something was compiled incorrectly.
+ if (strcmp(pm_version(), EXPECTED_PRISM_VERSION) != 0) {
+ rb_raise(
+ rb_eRuntimeError,
+ "The prism library version (%s) does not match the expected version (%s)",
+ pm_version(),
+ EXPECTED_PRISM_VERSION
+ );
+ }
+
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ // Mark this extension as Ractor-safe.
+ rb_ext_ractor_safe(true);
+#endif
+
+ // Grab up references to all of the constants that we're going to need to
+ // reference throughout this extension.
+ rb_cPrism = rb_define_module("Prism");
+ rb_cPrismNode = rb_define_class_under(rb_cPrism, "Node", rb_cObject);
+ rb_cPrismSource = rb_define_class_under(rb_cPrism, "Source", rb_cObject);
+ rb_cPrismToken = rb_define_class_under(rb_cPrism, "Token", rb_cObject);
+ rb_cPrismLocation = rb_define_class_under(rb_cPrism, "Location", rb_cObject);
+ rb_cPrismComment = rb_define_class_under(rb_cPrism, "Comment", rb_cObject);
+ rb_cPrismInlineComment = rb_define_class_under(rb_cPrism, "InlineComment", rb_cPrismComment);
+ rb_cPrismEmbDocComment = rb_define_class_under(rb_cPrism, "EmbDocComment", rb_cPrismComment);
+ rb_cPrismMagicComment = rb_define_class_under(rb_cPrism, "MagicComment", rb_cObject);
+ rb_cPrismParseError = rb_define_class_under(rb_cPrism, "ParseError", rb_cObject);
+ rb_cPrismParseWarning = rb_define_class_under(rb_cPrism, "ParseWarning", rb_cObject);
+ rb_cPrismResult = rb_define_class_under(rb_cPrism, "Result", rb_cObject);
+ rb_cPrismParseResult = rb_define_class_under(rb_cPrism, "ParseResult", rb_cPrismResult);
+ rb_cPrismLexResult = rb_define_class_under(rb_cPrism, "LexResult", rb_cPrismResult);
+ rb_cPrismParseLexResult = rb_define_class_under(rb_cPrism, "ParseLexResult", rb_cPrismResult);
+ rb_cPrismStringQuery = rb_define_class_under(rb_cPrism, "StringQuery", rb_cObject);
+ rb_cPrismScope = rb_define_class_under(rb_cPrism, "Scope", rb_cObject);
+
+ rb_cPrismCurrentVersionError = rb_const_get(rb_cPrism, rb_intern("CurrentVersionError"));
+
+ // Intern all of the IDs eagerly that we support so that we don't have to do
+ // it every time we parse.
+ rb_id_option_command_line = rb_intern_const("command_line");
+ rb_id_option_encoding = rb_intern_const("encoding");
+ rb_id_option_filepath = rb_intern_const("filepath");
+ rb_id_option_freeze = rb_intern_const("freeze");
+ rb_id_option_frozen_string_literal = rb_intern_const("frozen_string_literal");
+ rb_id_option_line = rb_intern_const("line");
+ rb_id_option_main_script = rb_intern_const("main_script");
+ rb_id_option_partial_script = rb_intern_const("partial_script");
+ rb_id_option_scopes = rb_intern_const("scopes");
+ rb_id_option_version = rb_intern_const("version");
+ rb_id_source_for = rb_intern("for");
+ rb_id_forwarding_positionals = rb_intern("*");
+ rb_id_forwarding_keywords = rb_intern("**");
+ rb_id_forwarding_block = rb_intern("&");
+ rb_id_forwarding_all = rb_intern("...");
+
+ /**
+ * The version of the prism library.
+ */
+ rb_define_const(rb_cPrism, "VERSION", rb_str_freeze(rb_str_new_cstr(EXPECTED_PRISM_VERSION)));
+
+ // First, the functions that have to do with lexing and parsing.
+ rb_define_singleton_method(rb_cPrism, "lex", lex, -1);
+ rb_define_singleton_method(rb_cPrism, "lex_file", lex_file, -1);
+ rb_define_singleton_method(rb_cPrism, "parse", parse, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_file", parse_file, -1);
+ rb_define_singleton_method(rb_cPrism, "profile", profile, -1);
+ rb_define_singleton_method(rb_cPrism, "profile_file", profile_file, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_stream", parse_stream, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_comments", parse_comments, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_file_comments", parse_file_comments, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_lex", parse_lex, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_lex_file", parse_lex_file, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_success?", parse_success_p, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_failure?", parse_failure_p, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_file_success?", parse_file_success_p, -1);
+ rb_define_singleton_method(rb_cPrism, "parse_file_failure?", parse_file_failure_p, -1);
+
+#ifndef PRISM_EXCLUDE_SERIALIZATION
+ rb_define_singleton_method(rb_cPrism, "dump", dump, -1);
+ rb_define_singleton_method(rb_cPrism, "dump_file", dump_file, -1);
+#endif
+
+ rb_define_singleton_method(rb_cPrismStringQuery, "local?", string_query_local_p, 1);
+ rb_define_singleton_method(rb_cPrismStringQuery, "constant?", string_query_constant_p, 1);
+ rb_define_singleton_method(rb_cPrismStringQuery, "method_name?", string_query_method_name_p, 1);
+
+ // Next, initialize the other APIs.
+ Init_prism_api_node();
+}
diff --git a/prism/extension.h b/prism/extension.h
new file mode 100644
index 0000000000..d0cbc2ff53
--- /dev/null
+++ b/prism/extension.h
@@ -0,0 +1,19 @@
+#ifndef PRISM_EXT_NODE_H
+#define PRISM_EXT_NODE_H
+
+#define EXPECTED_PRISM_VERSION "1.9.0"
+
+#include <ruby.h>
+#include <ruby/encoding.h>
+#include <ruby/version.h>
+#include "prism.h"
+
+VALUE pm_source_new(const pm_parser_t *parser, rb_encoding *encoding, bool freeze);
+VALUE pm_token_new(const pm_parser_t *parser, const pm_token_t *token, rb_encoding *encoding, VALUE source, bool freeze);
+VALUE pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encoding, VALUE source, bool freeze);
+VALUE pm_integer_new(const pm_integer_t *integer);
+
+void Init_prism_api_node(void);
+RUBY_FUNC_EXPORTED void Init_prism(void);
+
+#endif
diff --git a/prism/integer.c b/prism/integer.c
new file mode 100644
index 0000000000..1b69dbdceb
--- /dev/null
+++ b/prism/integer.c
@@ -0,0 +1,681 @@
+#include "prism/internal/integer.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/buffer.h"
+
+#include <assert.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Free the internal memory of an integer. This memory will only be allocated if
+ * the integer exceeds the size of a single uint32_t.
+ */
+static void
+pm_integer_free(pm_integer_t *integer) {
+ if (integer->values) {
+ xfree(integer->values);
+ }
+}
+
+/**
+ * Pull out the length and values from the integer, regardless of the form in
+ * which the length/values are stored.
+ */
+#define INTEGER_EXTRACT(integer, length_variable, values_variable) \
+ if ((integer)->values == NULL) { \
+ length_variable = 1; \
+ values_variable = &(integer)->value; \
+ } else { \
+ length_variable = (integer)->length; \
+ values_variable = (integer)->values; \
+ }
+
+/**
+ * Adds two positive pm_integer_t with the given base.
+ * Return pm_integer_t with values allocated. Not normalized.
+ */
+static void
+big_add(pm_integer_t *destination, pm_integer_t *left, pm_integer_t *right, uint64_t base) {
+ size_t left_length;
+ uint32_t *left_values;
+ INTEGER_EXTRACT(left, left_length, left_values)
+
+ size_t right_length;
+ uint32_t *right_values;
+ INTEGER_EXTRACT(right, right_length, right_values)
+
+ size_t length = left_length < right_length ? right_length : left_length;
+ uint32_t *values = (uint32_t *) xmalloc(sizeof(uint32_t) * (length + 1));
+ if (values == NULL) return;
+
+ uint64_t carry = 0;
+ for (size_t index = 0; index < length; index++) {
+ uint64_t sum = carry + (index < left_length ? left_values[index] : 0) + (index < right_length ? right_values[index] : 0);
+ values[index] = (uint32_t) (sum % base);
+ carry = sum / base;
+ }
+
+ if (carry > 0) {
+ values[length] = (uint32_t) carry;
+ length++;
+ }
+
+ *destination = (pm_integer_t) { length, values, 0, false };
+}
+
+/**
+ * Internal use for karatsuba_multiply. Calculates `a - b - c` with the given
+ * base. Assume a, b, c, a - b - c all to be positive.
+ * Return pm_integer_t with values allocated. Not normalized.
+ */
+static void
+big_sub2(pm_integer_t *destination, pm_integer_t *a, pm_integer_t *b, pm_integer_t *c, uint64_t base) {
+ size_t a_length;
+ uint32_t *a_values;
+ INTEGER_EXTRACT(a, a_length, a_values)
+
+ size_t b_length;
+ uint32_t *b_values;
+ INTEGER_EXTRACT(b, b_length, b_values)
+
+ size_t c_length;
+ uint32_t *c_values;
+ INTEGER_EXTRACT(c, c_length, c_values)
+
+ uint32_t *values = (uint32_t*) xmalloc(sizeof(uint32_t) * a_length);
+ int64_t carry = 0;
+
+ for (size_t index = 0; index < a_length; index++) {
+ int64_t sub = (
+ carry +
+ a_values[index] -
+ (index < b_length ? b_values[index] : 0) -
+ (index < c_length ? c_values[index] : 0)
+ );
+
+ if (sub >= 0) {
+ values[index] = (uint32_t) sub;
+ carry = 0;
+ } else {
+ sub += 2 * (int64_t) base;
+ values[index] = (uint32_t) ((uint64_t) sub % base);
+ carry = sub / (int64_t) base - 2;
+ }
+ }
+
+ while (a_length > 1 && values[a_length - 1] == 0) a_length--;
+ *destination = (pm_integer_t) { a_length, values, 0, false };
+}
+
+/**
+ * Multiply two positive integers with the given base using karatsuba algorithm.
+ * Return pm_integer_t with values allocated. Not normalized.
+ */
+static void
+karatsuba_multiply(pm_integer_t *destination, pm_integer_t *left, pm_integer_t *right, uint64_t base) {
+ size_t left_length;
+ uint32_t *left_values;
+ INTEGER_EXTRACT(left, left_length, left_values)
+
+ size_t right_length;
+ uint32_t *right_values;
+ INTEGER_EXTRACT(right, right_length, right_values)
+
+ if (left_length > right_length) {
+ size_t temporary_length = left_length;
+ left_length = right_length;
+ right_length = temporary_length;
+
+ uint32_t *temporary_values = left_values;
+ left_values = right_values;
+ right_values = temporary_values;
+ }
+
+ if (left_length <= 10) {
+ size_t length = left_length + right_length;
+ uint32_t *values = (uint32_t *) xcalloc(length, sizeof(uint32_t));
+ if (values == NULL) return;
+
+ for (size_t left_index = 0; left_index < left_length; left_index++) {
+ uint32_t carry = 0;
+ for (size_t right_index = 0; right_index < right_length; right_index++) {
+ uint64_t product = (uint64_t) left_values[left_index] * right_values[right_index] + values[left_index + right_index] + carry;
+ values[left_index + right_index] = (uint32_t) (product % base);
+ carry = (uint32_t) (product / base);
+ }
+ values[left_index + right_length] = carry;
+ }
+
+ while (length > 1 && values[length - 1] == 0) length--;
+ *destination = (pm_integer_t) { length, values, 0, false };
+ return;
+ }
+
+ if (left_length * 2 <= right_length) {
+ uint32_t *values = (uint32_t *) xcalloc(left_length + right_length, sizeof(uint32_t));
+
+ for (size_t start_offset = 0; start_offset < right_length; start_offset += left_length) {
+ size_t end_offset = start_offset + left_length;
+ if (end_offset > right_length) end_offset = right_length;
+
+ pm_integer_t sliced_left = {
+ .length = left_length,
+ .values = left_values,
+ .value = 0,
+ .negative = false
+ };
+
+ pm_integer_t sliced_right = {
+ .length = end_offset - start_offset,
+ .values = right_values + start_offset,
+ .value = 0,
+ .negative = false
+ };
+
+ pm_integer_t product;
+ karatsuba_multiply(&product, &sliced_left, &sliced_right, base);
+
+ uint32_t carry = 0;
+ for (size_t index = 0; index < product.length; index++) {
+ uint64_t sum = (uint64_t) values[start_offset + index] + product.values[index] + carry;
+ values[start_offset + index] = (uint32_t) (sum % base);
+ carry = (uint32_t) (sum / base);
+ }
+
+ if (carry > 0) values[start_offset + product.length] += carry;
+ pm_integer_free(&product);
+ }
+
+ *destination = (pm_integer_t) { left_length + right_length, values, 0, false };
+ return;
+ }
+
+ size_t half = left_length / 2;
+ pm_integer_t x0 = { half, left_values, 0, false };
+ pm_integer_t x1 = { left_length - half, left_values + half, 0, false };
+ pm_integer_t y0 = { half, right_values, 0, false };
+ pm_integer_t y1 = { right_length - half, right_values + half, 0, false };
+
+ pm_integer_t z0 = { 0 };
+ karatsuba_multiply(&z0, &x0, &y0, base);
+
+ pm_integer_t z2 = { 0 };
+ karatsuba_multiply(&z2, &x1, &y1, base);
+
+ // For simplicity to avoid considering negative values,
+ // use `z1 = (x0 + x1) * (y0 + y1) - z0 - z2` instead of original karatsuba algorithm.
+ pm_integer_t x01 = { 0 };
+ big_add(&x01, &x0, &x1, base);
+
+ pm_integer_t y01 = { 0 };
+ big_add(&y01, &y0, &y1, base);
+
+ pm_integer_t xy = { 0 };
+ karatsuba_multiply(&xy, &x01, &y01, base);
+
+ pm_integer_t z1;
+ big_sub2(&z1, &xy, &z0, &z2, base);
+
+ size_t length = left_length + right_length;
+ uint32_t *values = (uint32_t*) xcalloc(length, sizeof(uint32_t));
+
+ assert(z0.values != NULL);
+ memcpy(values, z0.values, sizeof(uint32_t) * z0.length);
+
+ assert(z2.values != NULL);
+ memcpy(values + 2 * half, z2.values, sizeof(uint32_t) * z2.length);
+
+ uint32_t carry = 0;
+ for(size_t index = 0; index < z1.length; index++) {
+ uint64_t sum = (uint64_t) carry + values[index + half] + z1.values[index];
+ values[index + half] = (uint32_t) (sum % base);
+ carry = (uint32_t) (sum / base);
+ }
+
+ for(size_t index = half + z1.length; carry > 0; index++) {
+ uint64_t sum = (uint64_t) carry + values[index];
+ values[index] = (uint32_t) (sum % base);
+ carry = (uint32_t) (sum / base);
+ }
+
+ while (length > 1 && values[length - 1] == 0) length--;
+ pm_integer_free(&z0);
+ pm_integer_free(&z1);
+ pm_integer_free(&z2);
+ pm_integer_free(&x01);
+ pm_integer_free(&y01);
+ pm_integer_free(&xy);
+
+ *destination = (pm_integer_t) { length, values, 0, false };
+}
+
+/**
+ * The values of a hexadecimal digit, where the index is the ASCII character.
+ * Note that there's an odd exception here where _ is mapped to 0. This is
+ * because it's possible for us to end up trying to parse a number that has
+ * already had an error attached to it, and we want to provide _something_ to
+ * the user.
+ */
+static const int8_t pm_integer_parse_digit_values[256] = {
+// 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 1x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 2x
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 3x
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 4x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, // 5x
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 6x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 7x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 8x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 9x
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Ax
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Bx
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Cx
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Dx
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Ex
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Fx
+};
+
+/**
+ * Return the value of a hexadecimal digit in a uint8_t.
+ */
+static uint8_t
+pm_integer_parse_digit(const uint8_t character) {
+ int8_t value = pm_integer_parse_digit_values[character];
+ assert(value != -1 && "invalid digit");
+
+ return (uint8_t) value;
+}
+
+/**
+ * Create a pm_integer_t from uint64_t with the given base. It is assumed that
+ * the memory for the pm_integer_t pointer has been zeroed.
+ */
+static void
+pm_integer_from_uint64(pm_integer_t *integer, uint64_t value, uint64_t base) {
+ if (value < base) {
+ integer->value = (uint32_t) value;
+ return;
+ }
+
+ size_t length = 0;
+ uint64_t length_value = value;
+ while (length_value > 0) {
+ length++;
+ length_value /= base;
+ }
+
+ uint32_t *values = (uint32_t *) xmalloc(sizeof(uint32_t) * length);
+ if (values == NULL) return;
+
+ for (size_t value_index = 0; value_index < length; value_index++) {
+ values[value_index] = (uint32_t) (value % base);
+ value /= base;
+ }
+
+ integer->length = length;
+ integer->values = values;
+}
+
+/**
+ * Normalize pm_integer_t.
+ * Heading zero values will be removed. If the integer fits into uint32_t,
+ * values is set to NULL, length is set to 0, and value field will be used.
+ */
+static void
+pm_integer_normalize(pm_integer_t *integer) {
+ if (integer->values == NULL) {
+ return;
+ }
+
+ while (integer->length > 1 && integer->values[integer->length - 1] == 0) {
+ integer->length--;
+ }
+
+ if (integer->length > 1) {
+ return;
+ }
+
+ uint32_t value = integer->values[0];
+ bool negative = integer->negative && value != 0;
+
+ pm_integer_free(integer);
+ *integer = (pm_integer_t) { .values = NULL, .value = value, .length = 0, .negative = negative };
+}
+
+/**
+ * Convert base of the integer.
+ * In practice, it converts 10**9 to 1<<32 or 1<<32 to 10**9.
+ */
+static void
+pm_integer_convert_base(pm_integer_t *destination, const pm_integer_t *source, uint64_t base_from, uint64_t base_to) {
+ size_t source_length;
+ const uint32_t *source_values;
+ INTEGER_EXTRACT(source, source_length, source_values)
+
+ size_t bigints_length = (source_length + 1) / 2;
+ assert(bigints_length > 0);
+
+ pm_integer_t *bigints = (pm_integer_t *) xcalloc(bigints_length, sizeof(pm_integer_t));
+ if (bigints == NULL) return;
+
+ for (size_t index = 0; index < source_length; index += 2) {
+ uint64_t value = source_values[index] + base_from * (index + 1 < source_length ? source_values[index + 1] : 0);
+ pm_integer_from_uint64(&bigints[index / 2], value, base_to);
+ }
+
+ pm_integer_t base = { 0 };
+ pm_integer_from_uint64(&base, base_from, base_to);
+
+ while (bigints_length > 1) {
+ pm_integer_t next_base;
+ karatsuba_multiply(&next_base, &base, &base, base_to);
+
+ pm_integer_free(&base);
+ base = next_base;
+
+ size_t next_length = (bigints_length + 1) / 2;
+ pm_integer_t *next_bigints = (pm_integer_t *) xcalloc(next_length, sizeof(pm_integer_t));
+
+ for (size_t bigints_index = 0; bigints_index < bigints_length; bigints_index += 2) {
+ if (bigints_index + 1 == bigints_length) {
+ next_bigints[bigints_index / 2] = bigints[bigints_index];
+ } else {
+ pm_integer_t multiplied = { 0 };
+ karatsuba_multiply(&multiplied, &base, &bigints[bigints_index + 1], base_to);
+
+ big_add(&next_bigints[bigints_index / 2], &bigints[bigints_index], &multiplied, base_to);
+ pm_integer_free(&bigints[bigints_index]);
+ pm_integer_free(&bigints[bigints_index + 1]);
+ pm_integer_free(&multiplied);
+ }
+ }
+
+ xfree_sized(bigints, bigints_length * sizeof(pm_integer_t));
+ bigints = next_bigints;
+ bigints_length = next_length;
+ }
+
+ *destination = bigints[0];
+ destination->negative = source->negative;
+ pm_integer_normalize(destination);
+
+ xfree_sized(bigints, bigints_length * sizeof(pm_integer_t));
+ pm_integer_free(&base);
+}
+
+#undef INTEGER_EXTRACT
+
+/**
+ * Convert digits to integer with the given power-of-two base.
+ */
+static void
+pm_integer_parse_powof2(pm_integer_t *integer, uint32_t base, const uint8_t *digits, size_t digits_length) {
+ size_t bit = 1;
+ while (base > (uint32_t) (1 << bit)) bit++;
+
+ size_t length = (digits_length * bit + 31) / 32;
+ uint32_t *values = (uint32_t *) xcalloc(length, sizeof(uint32_t));
+
+ for (size_t digit_index = 0; digit_index < digits_length; digit_index++) {
+ size_t bit_position = bit * (digits_length - digit_index - 1);
+ uint32_t value = digits[digit_index];
+
+ size_t index = bit_position / 32;
+ size_t shift = bit_position % 32;
+
+ values[index] |= value << shift;
+ if (32 - shift < bit) values[index + 1] |= value >> (32 - shift);
+ }
+
+ while (length > 1 && values[length - 1] == 0) length--;
+ *integer = (pm_integer_t) { .length = length, .values = values, .value = 0, .negative = false };
+ pm_integer_normalize(integer);
+}
+
+/**
+ * Convert decimal digits to pm_integer_t.
+ */
+static void
+pm_integer_parse_decimal(pm_integer_t *integer, const uint8_t *digits, size_t digits_length) {
+ const size_t batch = 9;
+ const size_t length = (digits_length + batch - 1) / batch;
+
+ uint32_t *values = (uint32_t *) xcalloc(length, sizeof(uint32_t));
+ uint32_t value = 0;
+
+ for (size_t digits_index = 0; digits_index < digits_length; digits_index++) {
+ value = value * 10 + digits[digits_index];
+
+ size_t reverse_index = digits_length - digits_index - 1;
+ if (reverse_index % batch == 0) {
+ values[reverse_index / batch] = value;
+ value = 0;
+ }
+ }
+
+ // Convert base from 10**9 to 1<<32.
+ pm_integer_convert_base(integer, &((pm_integer_t) { .length = length, .values = values, .value = 0, .negative = false }), 1000000000, ((uint64_t) 1 << 32));
+ xfree_sized(values, length * sizeof(uint32_t));
+}
+
+/**
+ * Parse a large integer from a string that does not fit into uint32_t.
+ */
+static void
+pm_integer_parse_big(pm_integer_t *integer, uint32_t multiplier, const uint8_t *start, const uint8_t *end) {
+ // Allocate an array to store digits.
+ const size_t digits_capa = sizeof(uint8_t) * (size_t) (end - start);
+ uint8_t *digits = xmalloc(digits_capa);
+ size_t digits_length = 0;
+
+ for (; start < end; start++) {
+ if (*start == '_') continue;
+ digits[digits_length++] = pm_integer_parse_digit(*start);
+ }
+
+ // Construct pm_integer_t from the digits.
+ if (multiplier == 10) {
+ pm_integer_parse_decimal(integer, digits, digits_length);
+ } else {
+ pm_integer_parse_powof2(integer, multiplier, digits, digits_length);
+ }
+
+ xfree_sized(digits, digits_capa);
+}
+
+/**
+ * Parse an integer from a string. This assumes that the format of the integer
+ * has already been validated, as internal validation checks are not performed
+ * here.
+ */
+void
+pm_integer_parse(pm_integer_t *integer, pm_integer_base_t base, const uint8_t *start, const uint8_t *end) {
+ // Ignore unary +. Unary - is parsed differently and will not end up here.
+ // Instead, it will modify the parsed integer later.
+ if (*start == '+') start++;
+
+ // Determine the multiplier from the base, and skip past any prefixes.
+ uint32_t multiplier = 10;
+ switch (base) {
+ case PM_INTEGER_BASE_DEFAULT:
+ while (*start == '0') start++; // 01 -> 1
+ break;
+ case PM_INTEGER_BASE_BINARY:
+ start += 2; // 0b
+ multiplier = 2;
+ break;
+ case PM_INTEGER_BASE_OCTAL:
+ start++; // 0
+ if (*start == '_' || *start == 'o' || *start == 'O') start++; // o
+ multiplier = 8;
+ break;
+ case PM_INTEGER_BASE_DECIMAL:
+ if (*start == '0' && (end - start) > 1) start += 2; // 0d
+ break;
+ case PM_INTEGER_BASE_HEXADECIMAL:
+ start += 2; // 0x
+ multiplier = 16;
+ break;
+ case PM_INTEGER_BASE_UNKNOWN:
+ if (*start == '0' && (end - start) > 1) {
+ switch (start[1]) {
+ case '_': start += 2; multiplier = 8; break;
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': start++; multiplier = 8; break;
+ case 'b': case 'B': start += 2; multiplier = 2; break;
+ case 'o': case 'O': start += 2; multiplier = 8; break;
+ case 'd': case 'D': start += 2; break;
+ case 'x': case 'X': start += 2; multiplier = 16; break;
+ default: assert(false && "unreachable"); break;
+ }
+ }
+ break;
+ }
+
+ // It's possible that we've consumed everything at this point if there is an
+ // invalid integer. If this is the case, we'll just return 0.
+ if (start >= end) return;
+
+ const uint8_t *cursor = start;
+ uint64_t value = (uint64_t) pm_integer_parse_digit(*cursor++);
+
+ for (; cursor < end; cursor++) {
+ if (*cursor == '_') continue;
+ value = value * multiplier + (uint64_t) pm_integer_parse_digit(*cursor);
+
+ if (value > UINT32_MAX) {
+ // If the integer is too large to fit into a single uint32_t, then
+ // we'll parse it as a big integer.
+ pm_integer_parse_big(integer, multiplier, start, end);
+ return;
+ }
+ }
+
+ integer->value = (uint32_t) value;
+}
+
+/**
+ * Compare two integers. This function returns -1 if the left integer is less
+ * than the right integer, 0 if they are equal, and 1 if the left integer is
+ * greater than the right integer.
+ */
+int
+pm_integer_compare(const pm_integer_t *left, const pm_integer_t *right) {
+ if (left->negative != right->negative) return left->negative ? -1 : 1;
+ int negative = left->negative ? -1 : 1;
+
+ if (left->values == NULL && right->values == NULL) {
+ if (left->value < right->value) return -1 * negative;
+ if (left->value > right->value) return 1 * negative;
+ return 0;
+ }
+
+ if (left->values == NULL || left->length < right->length) return -1 * negative;
+ if (right->values == NULL || left->length > right->length) return 1 * negative;
+
+ for (size_t index = 0; index < left->length; index++) {
+ size_t value_index = left->length - index - 1;
+ uint32_t left_value = left->values[value_index];
+ uint32_t right_value = right->values[value_index];
+
+ if (left_value < right_value) return -1 * negative;
+ if (left_value > right_value) return 1 * negative;
+ }
+
+ return 0;
+}
+
+/**
+ * Reduce a ratio of integers to its simplest form.
+ */
+void pm_integers_reduce(pm_integer_t *numerator, pm_integer_t *denominator) {
+ // If either the numerator or denominator do not fit into a 32-bit integer,
+ // then this function is a no-op. In the future, we may consider reducing
+ // even the larger numbers, but for now we're going to keep it simple.
+ if (
+ // If the numerator doesn't fit into a 32-bit integer, return early.
+ numerator->length != 0 ||
+ // If the denominator doesn't fit into a 32-bit integer, return early.
+ denominator->length != 0 ||
+ // If the numerator is 0, then return early.
+ numerator->value == 0 ||
+ // If the denominator is 1, then return early.
+ denominator->value == 1
+ ) return;
+
+ // Find the greatest common divisor of the numerator and denominator.
+ uint32_t divisor = numerator->value;
+ uint32_t remainder = denominator->value;
+
+ while (remainder != 0) {
+ uint32_t temporary = remainder;
+ remainder = divisor % remainder;
+ divisor = temporary;
+ }
+
+ // Divide the numerator and denominator by the greatest common divisor.
+ numerator->value /= divisor;
+ denominator->value /= divisor;
+}
+
+/**
+ * Convert an integer to a decimal string.
+ */
+void
+pm_integer_string(pm_buffer_t *buffer, const pm_integer_t *integer) {
+ if (integer->negative) {
+ pm_buffer_append_byte(buffer, '-');
+ }
+
+ // If the integer fits into a single uint32_t, then we can just append the
+ // value directly to the buffer.
+ if (integer->values == NULL) {
+ pm_buffer_append_format(buffer, "%" PRIu32, integer->value);
+ return;
+ }
+
+ // If the integer is two uint32_t values, then we can | them together and
+ // append the result to the buffer.
+ if (integer->length == 2) {
+ const uint64_t value = ((uint64_t) integer->values[0]) | ((uint64_t) integer->values[1] << 32);
+ pm_buffer_append_format(buffer, "%" PRIu64, value);
+ return;
+ }
+
+ // Otherwise, first we'll convert the base from 1<<32 to 10**9.
+ pm_integer_t converted = { 0 };
+ pm_integer_convert_base(&converted, integer, (uint64_t) 1 << 32, 1000000000);
+
+ if (converted.values == NULL) {
+ pm_buffer_append_format(buffer, "%" PRIu32, converted.value);
+ pm_integer_free(&converted);
+ return;
+ }
+
+ // Allocate a buffer that we'll copy the decimal digits into.
+ const size_t digits_length = converted.length * 9;
+ char *digits = xcalloc(digits_length, sizeof(char));
+ if (digits == NULL) return;
+
+ // Pack bigdecimal to digits.
+ for (size_t value_index = 0; value_index < converted.length; value_index++) {
+ uint32_t value = converted.values[value_index];
+
+ for (size_t digit_index = 0; digit_index < 9; digit_index++) {
+ digits[digits_length - 9 * value_index - digit_index - 1] = (char) ('0' + value % 10);
+ value /= 10;
+ }
+ }
+
+ size_t start_offset = 0;
+ while (start_offset < digits_length - 1 && digits[start_offset] == '0') start_offset++;
+
+ // Finally, append the string to the buffer and free the digits.
+ pm_buffer_append_string(buffer, digits + start_offset, digits_length - start_offset);
+ xfree_sized(digits, sizeof(char) * digits_length);
+ pm_integer_free(&converted);
+}
diff --git a/prism/integer.h b/prism/integer.h
new file mode 100644
index 0000000000..9285986885
--- /dev/null
+++ b/prism/integer.h
@@ -0,0 +1,41 @@
+/**
+ * @file integer.h
+ *
+ * This module provides functions for working with arbitrary-sized integers.
+ */
+#ifndef PRISM_INTEGER_H
+#define PRISM_INTEGER_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * A structure represents an arbitrary-sized integer.
+ */
+typedef struct {
+ /**
+ * The number of allocated values. length is set to 0 if the integer fits
+ * into uint32_t.
+ */
+ size_t length;
+
+ /**
+ * List of 32-bit integers. Set to NULL if the integer fits into uint32_t.
+ */
+ uint32_t *values;
+
+ /**
+ * Embedded value for small integer. This value is set to 0 if the value
+ * does not fit into uint32_t.
+ */
+ uint32_t value;
+
+ /**
+ * Whether or not the integer is negative. It is stored this way so that a
+ * zeroed pm_integer_t is always positive zero.
+ */
+ bool negative;
+} pm_integer_t;
+
+#endif
diff --git a/prism/internal/allocator.h b/prism/internal/allocator.h
new file mode 100644
index 0000000000..6c54010dbf
--- /dev/null
+++ b/prism/internal/allocator.h
@@ -0,0 +1,68 @@
+#ifndef PRISM_INTERNAL_ALLOCATOR_H
+#define PRISM_INTERNAL_ALLOCATOR_H
+
+/* If you build Prism with a custom allocator, configure it with
+ * "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
+ * xrealloc, xcalloc, and xfree.
+ *
+ * For example, your `prism_xallocator.h` file could look like this:
+ *
+ * ```
+ * #ifndef PRISM_XALLOCATOR_H
+ * #define PRISM_XALLOCATOR_H
+ * #define xmalloc my_malloc
+ * #define xrealloc my_realloc
+ * #define xcalloc my_calloc
+ * #define xfree my_free
+ * #define xrealloc_sized my_realloc_sized // (optional)
+ * #define xfree_sized my_free_sized // (optional)
+ * #endif
+ * ```
+ */
+#ifdef PRISM_XALLOCATOR
+ #include "prism_xallocator.h"
+#else
+ #ifndef xmalloc
+ /* The malloc function that should be used. This can be overridden with
+ * the PRISM_XALLOCATOR define. */
+ #define xmalloc malloc
+ #endif
+
+ #ifndef xrealloc
+ /* The realloc function that should be used. This can be overridden with
+ * the PRISM_XALLOCATOR define. */
+ #define xrealloc realloc
+ #endif
+
+ #ifndef xcalloc
+ /* The calloc function that should be used. This can be overridden with
+ * the PRISM_XALLOCATOR define. */
+ #define xcalloc calloc
+ #endif
+
+ #ifndef xfree
+ /* The free function that should be used. This can be overridden with
+ * the PRISM_XALLOCATOR define. */
+ #define xfree free
+ #endif
+#endif
+
+#ifndef xfree_sized
+ /* The free_sized function that should be used. This can be overridden with
+ * the PRISM_XALLOCATOR define. If not defined, defaults to calling xfree.
+ */
+ #define xfree_sized(p, s) xfree(((void)(s), (p)))
+#endif
+
+#ifndef xrealloc_sized
+ /* The xrealloc_sized function that should be used. This can be overridden
+ * with the PRISM_XALLOCATOR define. If not defined, defaults to calling
+ * xrealloc. */
+ #define xrealloc_sized(p, ns, os) xrealloc((p), ((void)(os), (ns)))
+#endif
+
+#ifdef PRISM_BUILD_DEBUG
+ #include "prism/internal/allocator_debug.h"
+#endif
+
+#endif
diff --git a/prism/internal/allocator_debug.h b/prism/internal/allocator_debug.h
new file mode 100644
index 0000000000..846e96ba2d
--- /dev/null
+++ b/prism/internal/allocator_debug.h
@@ -0,0 +1,88 @@
+#ifndef PRISM_INTERNAL_ALLOCATOR_DEBUG_H
+#define PRISM_INTERNAL_ALLOCATOR_DEBUG_H
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static inline void *
+pm_allocator_debug_malloc(size_t size) {
+ size_t *memory = xmalloc(size + sizeof(size_t));
+ memory[0] = size;
+ return memory + 1;
+}
+
+static inline void *
+pm_allocator_debug_calloc(size_t nmemb, size_t size) {
+ size_t total_size = nmemb * size;
+ void *ptr = pm_allocator_debug_malloc(total_size);
+ memset(ptr, 0, total_size);
+ return ptr;
+}
+
+static inline void *
+pm_allocator_debug_realloc(void *ptr, size_t size) {
+ if (ptr == NULL) {
+ return pm_allocator_debug_malloc(size);
+ }
+
+ size_t *memory = (size_t *)ptr;
+ void *raw_memory = memory - 1;
+ memory = (size_t *)xrealloc(raw_memory, size + sizeof(size_t));
+ memory[0] = size;
+ return memory + 1;
+}
+
+static inline void
+pm_allocator_debug_free(void *ptr) {
+ if (ptr != NULL) {
+ size_t *memory = (size_t *)ptr;
+ xfree(memory - 1);
+ }
+}
+
+static inline void
+pm_allocator_debug_free_sized(void *ptr, size_t old_size) {
+ if (ptr != NULL) {
+ size_t *memory = (size_t *)ptr;
+ if (old_size != memory[-1]) {
+ fprintf(stderr, "[BUG] buffer %p was allocated with size %lu but freed with size %lu\n", ptr, memory[-1], old_size);
+ abort();
+ }
+ xfree_sized(memory - 1, old_size + sizeof(size_t));
+ }
+}
+
+static inline void *
+pm_allocator_debug_realloc_sized(void *ptr, size_t size, size_t old_size) {
+ if (ptr == NULL) {
+ if (old_size != 0) {
+ fprintf(stderr, "[BUG] realloc_sized called with NULL pointer and old size %lu\n", old_size);
+ abort();
+ }
+ return pm_allocator_debug_malloc(size);
+ }
+
+ size_t *memory = (size_t *)ptr;
+ if (old_size != memory[-1]) {
+ fprintf(stderr, "[BUG] buffer %p was allocated with size %lu but realloced with size %lu\n", ptr, memory[-1], old_size);
+ abort();
+ }
+ return pm_allocator_debug_realloc(ptr, size);
+}
+
+#undef xmalloc
+#undef xrealloc
+#undef xcalloc
+#undef xfree
+#undef xrealloc_sized
+#undef xfree_sized
+
+#define xmalloc pm_allocator_debug_malloc
+#define xrealloc pm_allocator_debug_realloc
+#define xcalloc pm_allocator_debug_calloc
+#define xfree pm_allocator_debug_free
+#define xrealloc_sized pm_allocator_debug_realloc_sized
+#define xfree_sized pm_allocator_debug_free_sized
+
+#endif
diff --git a/prism/internal/arena.h b/prism/internal/arena.h
new file mode 100644
index 0000000000..2e413b42bf
--- /dev/null
+++ b/prism/internal/arena.h
@@ -0,0 +1,108 @@
+#ifndef PRISM_INTERNAL_ARENA_H
+#define PRISM_INTERNAL_ARENA_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/flex_array.h"
+#include "prism/compiler/force_inline.h"
+#include "prism/compiler/inline.h"
+
+#include "prism/arena.h"
+
+#include <stddef.h>
+#include <string.h>
+
+/*
+ * A single block of memory in the arena. Blocks are linked via prev pointers so
+ * they can be freed by walking the chain.
+ */
+typedef struct pm_arena_block {
+ /* The previous block in the chain (for freeing). */
+ struct pm_arena_block *prev;
+
+ /* The total usable bytes in data[]. */
+ size_t capacity;
+
+ /* The number of bytes consumed so far. */
+ size_t used;
+
+ /* The block's data. */
+ char data[PM_FLEX_ARRAY_LENGTH];
+} pm_arena_block_t;
+
+/*
+ * A bump allocator. Allocations are made by bumping a pointer within the
+ * current block. When a block is full, a new block is allocated and linked to
+ * the previous one. All blocks are freed at once by walking the chain.
+ */
+struct pm_arena_t {
+ /* The active block (allocate from here). */
+ pm_arena_block_t *current;
+
+ /* The number of blocks allocated. */
+ size_t block_count;
+};
+
+/*
+ * Free all blocks in the arena. After this call, all pointers returned by
+ * pm_arena_alloc and pm_arena_zalloc are invalid.
+ */
+void pm_arena_cleanup(pm_arena_t *arena);
+
+/*
+ * Ensure the arena has at least `capacity` bytes available in its current
+ * block, allocating a new block if necessary. This allows callers to
+ * pre-size the arena to avoid repeated small block allocations.
+ */
+void pm_arena_reserve(pm_arena_t *arena, size_t capacity);
+
+/*
+ * Slow path for pm_arena_alloc: allocate a new block and return a pointer to
+ * the first `size` bytes. Do not call directly — use pm_arena_alloc instead.
+ */
+void * pm_arena_alloc_slow(pm_arena_t *arena, size_t size);
+
+/*
+ * Allocate memory from the arena. The returned memory is NOT zeroed. This
+ * function is infallible — it aborts on allocation failure.
+ *
+ * The fast path (bump pointer within the current block) is inlined at each
+ * call site. The slow path (new block allocation) is out-of-line.
+ */
+static PRISM_FORCE_INLINE void *
+pm_arena_alloc(pm_arena_t *arena, size_t size, size_t alignment) {
+ if (arena->current != NULL) {
+ size_t used_aligned = (arena->current->used + alignment - 1) & ~(alignment - 1);
+ size_t needed = used_aligned + size;
+
+ if (used_aligned >= arena->current->used && needed >= used_aligned && needed <= arena->current->capacity) {
+ arena->current->used = needed;
+ return arena->current->data + used_aligned;
+ }
+ }
+
+ return pm_arena_alloc_slow(arena, size);
+}
+
+/*
+ * Allocate zero-initialized memory from the arena. This function is infallible
+ * — it aborts on allocation failure.
+ */
+static PRISM_INLINE void *
+pm_arena_zalloc(pm_arena_t *arena, size_t size, size_t alignment) {
+ void *ptr = pm_arena_alloc(arena, size, alignment);
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+/*
+ * Allocate memory from the arena and copy the given data into it. This is a
+ * convenience wrapper around pm_arena_alloc + memcpy.
+ */
+static PRISM_INLINE void *
+pm_arena_memdup(pm_arena_t *arena, const void *src, size_t size, size_t alignment) {
+ void *dst = pm_arena_alloc(arena, size, alignment);
+ memcpy(dst, src, size);
+ return dst;
+}
+
+#endif
diff --git a/prism/internal/bit.h b/prism/internal/bit.h
new file mode 100644
index 0000000000..b0111a4c2c
--- /dev/null
+++ b/prism/internal/bit.h
@@ -0,0 +1,42 @@
+#ifndef PRISM_INTERNAL_BIT_H
+#define PRISM_INTERNAL_BIT_H
+
+#include "prism/compiler/inline.h"
+
+/*
+ * Count trailing zero bits in a 64-bit value. Used by SWAR identifier scanning
+ * to find the first non-matching byte in a word.
+ *
+ * Precondition: v must be nonzero. The result is undefined when v == 0
+ * (matching the behavior of __builtin_ctzll and _BitScanForward64).
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#define pm_ctzll(v) ((unsigned) __builtin_ctzll(v))
+#elif defined(_MSC_VER)
+#include <intrin.h>
+#include <stdint.h>
+
+static PRISM_INLINE unsigned
+pm_ctzll(uint64_t v) {
+ unsigned long index;
+ _BitScanForward64(&index, v);
+ return (unsigned) index;
+}
+#else
+#include <stdint.h>
+
+static PRISM_INLINE unsigned
+pm_ctzll(uint64_t v) {
+ unsigned c = 0;
+ v &= (uint64_t) (-(int64_t) v);
+ if (v & 0x00000000FFFFFFFFULL) c += 0; else c += 32;
+ if (v & 0x0000FFFF0000FFFFULL) c += 0; else c += 16;
+ if (v & 0x00FF00FF00FF00FFULL) c += 0; else c += 8;
+ if (v & 0x0F0F0F0F0F0F0F0FULL) c += 0; else c += 4;
+ if (v & 0x3333333333333333ULL) c += 0; else c += 2;
+ if (v & 0x5555555555555555ULL) c += 0; else c += 1;
+ return c;
+}
+#endif
+
+#endif
diff --git a/prism/internal/buffer.h b/prism/internal/buffer.h
new file mode 100644
index 0000000000..a849bbf8e6
--- /dev/null
+++ b/prism/internal/buffer.h
@@ -0,0 +1,91 @@
+#ifndef PRISM_INTERNAL_BUFFER_H
+#define PRISM_INTERNAL_BUFFER_H
+
+#include "prism/compiler/format.h"
+
+#include "prism/buffer.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/*
+ * A simple memory buffer that stores data in a contiguous block of memory.
+ */
+struct pm_buffer_t {
+ /* The length of the buffer in bytes. */
+ size_t length;
+
+ /* The capacity of the buffer in bytes that has been allocated. */
+ size_t capacity;
+
+ /* A pointer to the start of the buffer. */
+ char *value;
+};
+
+/* Initialize a pm_buffer_t with the given capacity. */
+void pm_buffer_init(pm_buffer_t *buffer, size_t capacity);
+
+/* Free the memory held by the buffer. */
+void pm_buffer_cleanup(pm_buffer_t *buffer);
+
+/* Append the given amount of space as zeroes to the buffer. */
+void pm_buffer_append_zeroes(pm_buffer_t *buffer, size_t length);
+
+/* Append a formatted string to the buffer. */
+void pm_buffer_append_format(pm_buffer_t *buffer, const char *format, ...) PRISM_ATTRIBUTE_FORMAT(2, 3);
+
+/* Append a string to the buffer. */
+void pm_buffer_append_string(pm_buffer_t *buffer, const char *value, size_t length);
+
+/* Append a list of bytes to the buffer. */
+void pm_buffer_append_bytes(pm_buffer_t *buffer, const uint8_t *value, size_t length);
+
+/* Append a single byte to the buffer. */
+void pm_buffer_append_byte(pm_buffer_t *buffer, uint8_t value);
+
+/* Append a 32-bit unsigned integer to the buffer as a variable-length integer. */
+void pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value);
+
+/* Append a 32-bit signed integer to the buffer as a variable-length integer. */
+void pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value);
+
+/* Append a double to the buffer. */
+void pm_buffer_append_double(pm_buffer_t *buffer, double value);
+
+/* Append a unicode codepoint to the buffer. */
+bool pm_buffer_append_unicode_codepoint(pm_buffer_t *buffer, uint32_t value);
+
+/*
+ * The different types of escaping that can be performed by the buffer when
+ * appending a slice of Ruby source code.
+ */
+typedef enum {
+ PM_BUFFER_ESCAPING_RUBY,
+ PM_BUFFER_ESCAPING_JSON
+} pm_buffer_escaping_t;
+
+/* Append a slice of source code to the buffer. */
+void pm_buffer_append_source(pm_buffer_t *buffer, const uint8_t *source, size_t length, pm_buffer_escaping_t escaping);
+
+/* Prepend the given string to the buffer. */
+void pm_buffer_prepend_string(pm_buffer_t *buffer, const char *value, size_t length);
+
+/* Concatenate one buffer onto another. */
+void pm_buffer_concat(pm_buffer_t *destination, const pm_buffer_t *source);
+
+/*
+ * Clear the buffer by reducing its size to 0. This does not free the allocated
+ * memory, but it does allow the buffer to be reused.
+ */
+void pm_buffer_clear(pm_buffer_t *buffer);
+
+/* Strip the whitespace from the end of the buffer. */
+void pm_buffer_rstrip(pm_buffer_t *buffer);
+
+/* Checks if the buffer includes the given value. */
+size_t pm_buffer_index(const pm_buffer_t *buffer, char value);
+
+/* Insert the given string into the buffer at the given index. */
+void pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size_t length);
+
+#endif
diff --git a/prism/internal/char.h b/prism/internal/char.h
new file mode 100644
index 0000000000..9a58fba8c5
--- /dev/null
+++ b/prism/internal/char.h
@@ -0,0 +1,139 @@
+#ifndef PRISM_INTERNAL_CHAR_H
+#define PRISM_INTERNAL_CHAR_H
+
+#include "prism/compiler/force_inline.h"
+
+#include "prism/arena.h"
+#include "prism/line_offset_list.h"
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/* Bit flag for whitespace characters in pm_byte_table. */
+#define PRISM_CHAR_BIT_WHITESPACE (1 << 0)
+
+/* Bit flag for inline whitespace characters in pm_byte_table. */
+#define PRISM_CHAR_BIT_INLINE_WHITESPACE (1 << 1)
+
+/*
+ * A lookup table for classifying bytes. Each entry is a bitfield of
+ * PRISM_CHAR_BIT_* flags. Defined in char.c.
+ */
+extern const uint8_t pm_byte_table[256];
+
+/* Returns true if the given character is a whitespace character. */
+static PRISM_FORCE_INLINE bool
+pm_char_is_whitespace(const uint8_t b) {
+ return (pm_byte_table[b] & PRISM_CHAR_BIT_WHITESPACE) != 0;
+}
+
+/* Returns true if the given character is an inline whitespace character. */
+static PRISM_FORCE_INLINE bool
+pm_char_is_inline_whitespace(const uint8_t b) {
+ return (pm_byte_table[b] & PRISM_CHAR_BIT_INLINE_WHITESPACE) != 0;
+}
+
+/*
+ * Returns the number of characters at the start of the string that are inline
+ * whitespace (space/tab). Scans the byte table directly for use in hot paths.
+ */
+static PRISM_FORCE_INLINE size_t
+pm_strspn_inline_whitespace(const uint8_t *string, ptrdiff_t length) {
+ if (length <= 0) return 0;
+ size_t size = 0;
+ size_t maximum = (size_t) length;
+ while (size < maximum && (pm_byte_table[string[size]] & PRISM_CHAR_BIT_INLINE_WHITESPACE)) size++;
+ return size;
+}
+
+/*
+ * Returns the number of characters at the start of the string that are
+ * whitespace. Disallows searching past the given maximum number of characters.
+ */
+size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
+
+/*
+ * Returns the number of characters at the start of the string that are
+ * whitespace while also tracking the location of each newline. Disallows
+ * searching past the given maximum number of characters.
+ */
+size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_arena_t *arena, pm_line_offset_list_t *line_offsets, uint32_t start_offset);
+
+/*
+ * Returns the number of characters at the start of the string that are decimal
+ * digits. Disallows searching past the given maximum number of characters.
+ */
+size_t pm_strspn_decimal_digit(const uint8_t *string, ptrdiff_t length);
+
+/*
+ * Returns the number of characters at the start of the string that are
+ * hexadecimal digits. Disallows searching past the given maximum number of
+ * characters.
+ */
+size_t pm_strspn_hexadecimal_digit(const uint8_t *string, ptrdiff_t length);
+
+/*
+ * Returns the number of characters at the start of the string that are octal
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t pm_strspn_octal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
+
+/*
+ * Returns the number of characters at the start of the string that are decimal
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t pm_strspn_decimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
+
+/*
+ * Returns the number of characters at the start of the string that are
+ * hexadecimal digits or underscores. Disallows searching past the given maximum
+ * number of characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t pm_strspn_hexadecimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
+
+/*
+ * Returns the number of characters at the start of the string that are regexp
+ * options. Disallows searching past the given maximum number of characters.
+ */
+size_t pm_strspn_regexp_option(const uint8_t *string, ptrdiff_t length);
+
+/*
+ * Returns the number of characters at the start of the string that are binary
+ * digits or underscores. Disallows searching past the given maximum number of
+ * characters.
+ *
+ * If multiple underscores are found in a row or if an underscore is
+ * found at the end of the number, then the invalid pointer is set to the index
+ * of the first invalid underscore.
+ */
+size_t pm_strspn_binary_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
+
+
+/* Returns true if the given character is a binary digit. */
+bool pm_char_is_binary_digit(const uint8_t b);
+
+/* Returns true if the given character is an octal digit. */
+bool pm_char_is_octal_digit(const uint8_t b);
+
+/* Returns true if the given character is a decimal digit. */
+bool pm_char_is_decimal_digit(const uint8_t b);
+
+/* Returns true if the given character is a hexadecimal digit. */
+bool pm_char_is_hexadecimal_digit(const uint8_t b);
+
+#endif
diff --git a/prism/internal/comments.h b/prism/internal/comments.h
new file mode 100644
index 0000000000..bb3039a658
--- /dev/null
+++ b/prism/internal/comments.h
@@ -0,0 +1,20 @@
+#ifndef PRISM_INTERNAL_COMMENTS_H
+#define PRISM_INTERNAL_COMMENTS_H
+
+#include "prism/comments.h"
+
+#include "prism/internal/list.h"
+
+/* A comment found while parsing. */
+struct pm_comment_t {
+ /* The embedded base node. */
+ pm_list_node_t node;
+
+ /* The location of the comment in the source. */
+ pm_location_t location;
+
+ /* The type of the comment. */
+ pm_comment_type_t type;
+};
+
+#endif
diff --git a/prism/internal/constant_pool.h b/prism/internal/constant_pool.h
new file mode 100644
index 0000000000..fa2be783f5
--- /dev/null
+++ b/prism/internal/constant_pool.h
@@ -0,0 +1,117 @@
+#ifndef PRISM_INTERNAL_CONSTANT_POOL_H
+#define PRISM_INTERNAL_CONSTANT_POOL_H
+
+#include "prism/constant_pool.h"
+
+#include "prism/arena.h"
+
+#include <stdbool.h>
+
+/* A constant in the pool which effectively stores a string. */
+struct pm_constant_t {
+ /* A pointer to the start of the string. */
+ const uint8_t *start;
+
+ /* The length of the string. */
+ size_t length;
+};
+
+/*
+ * The type of bucket in the constant pool hash map. This determines how the
+ * bucket should be freed.
+ */
+typedef unsigned int pm_constant_pool_bucket_type_t;
+
+/* By default, each constant is a slice of the source. */
+static const pm_constant_pool_bucket_type_t PM_CONSTANT_POOL_BUCKET_DEFAULT = 0;
+
+/* An owned constant is one for which memory has been allocated. */
+static const pm_constant_pool_bucket_type_t PM_CONSTANT_POOL_BUCKET_OWNED = 1;
+
+/* A constant constant is known at compile time. */
+static const pm_constant_pool_bucket_type_t PM_CONSTANT_POOL_BUCKET_CONSTANT = 2;
+
+/* A bucket in the hash map. */
+typedef struct {
+ /* The incremental ID used for indexing back into the pool. */
+ unsigned int id: 30;
+
+ /* The type of the bucket, which determines how to free it. */
+ pm_constant_pool_bucket_type_t type: 2;
+
+ /* The hash of the bucket. */
+ uint32_t hash;
+
+ /*
+ * A pointer to the start of the string, stored directly in the bucket to
+ * avoid a pointer chase to the constants array during probing.
+ */
+ const uint8_t *start;
+
+ /* The length of the string. */
+ size_t length;
+} pm_constant_pool_bucket_t;
+
+/* The overall constant pool, which stores constants found while parsing. */
+struct pm_constant_pool_t {
+ /* The buckets in the hash map. */
+ pm_constant_pool_bucket_t *buckets;
+
+ /* The constants that are stored in the buckets. */
+ pm_constant_t *constants;
+
+ /* The number of buckets in the hash map. */
+ uint32_t size;
+
+ /* The number of buckets that have been allocated in the hash map. */
+ uint32_t capacity;
+};
+
+/*
+ * When we allocate constants into the pool, we reserve 0 to mean that the slot
+ * is not yet filled. This constant is reused in other places to indicate the
+ * lack of a constant id.
+ */
+#define PM_CONSTANT_ID_UNSET 0
+
+/* Initialize a list of constant ids with a given capacity. */
+void pm_constant_id_list_init_capacity(pm_arena_t *arena, pm_constant_id_list_t *list, size_t capacity);
+
+/* Insert a constant id into a list of constant ids at the specified index. */
+void pm_constant_id_list_insert(pm_constant_id_list_t *list, size_t index, pm_constant_id_t id);
+
+/* Checks if the current constant id list includes the given constant id. */
+bool pm_constant_id_list_includes(pm_constant_id_list_t *list, pm_constant_id_t id);
+
+/* Initialize a new constant pool with a given capacity. */
+void pm_constant_pool_init(pm_arena_t *arena, pm_constant_pool_t *pool, uint32_t capacity);
+
+/* Return a pointer to the constant indicated by the given constant id. */
+pm_constant_t * pm_constant_pool_id_to_constant(const pm_constant_pool_t *pool, pm_constant_id_t constant_id);
+
+/*
+ * Find a constant in a constant pool. Returns the id of the constant, or 0 if
+ * the constant is not found.
+ */
+pm_constant_id_t pm_constant_pool_find(const pm_constant_pool_t *pool, const uint8_t *start, size_t length);
+
+/*
+ * Insert a constant into a constant pool that is a slice of a source string.
+ * Returns the id of the constant, or 0 if any potential calls to resize fail.
+ */
+pm_constant_id_t pm_constant_pool_insert_shared(pm_arena_t *arena, pm_constant_pool_t *pool, const uint8_t *start, size_t length);
+
+/*
+ * Insert a constant into a constant pool from memory that is now owned by the
+ * constant pool. Returns the id of the constant, or 0 if any potential calls to
+ * resize fail.
+ */
+pm_constant_id_t pm_constant_pool_insert_owned(pm_arena_t *arena, pm_constant_pool_t *pool, uint8_t *start, size_t length);
+
+/*
+ * Insert a constant into a constant pool from memory that is constant. Returns
+ * the id of the constant, or 0 if any potential calls to resize fail.
+ */
+pm_constant_id_t pm_constant_pool_insert_constant(pm_arena_t *arena, pm_constant_pool_t *pool, const uint8_t *start, size_t length);
+
+#endif
diff --git a/prism/internal/encoding.h b/prism/internal/encoding.h
new file mode 100644
index 0000000000..62392ef970
--- /dev/null
+++ b/prism/internal/encoding.h
@@ -0,0 +1,242 @@
+#ifndef PRISM_INTERNAL_ENCODING_H
+#define PRISM_INTERNAL_ENCODING_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * This struct defines the functions necessary to implement the encoding
+ * interface so we can determine how many bytes the subsequent character takes.
+ * Each callback should return the number of bytes, or 0 if the next bytes are
+ * invalid for the encoding and type.
+ */
+typedef struct {
+ /*
+ * Return the number of bytes that the next character takes if it is valid
+ * in the encoding. Does not read more than n bytes. It is assumed that n is
+ * at least 1.
+ */
+ size_t (*char_width)(const uint8_t *b, ptrdiff_t n);
+
+ /*
+ * Return the number of bytes that the next character takes if it is valid
+ * in the encoding and is alphabetical. Does not read more than n bytes. It
+ * is assumed that n is at least 1.
+ */
+ size_t (*alpha_char)(const uint8_t *b, ptrdiff_t n);
+
+ /*
+ * Return the number of bytes that the next character takes if it is valid
+ * in the encoding and is alphanumeric. Does not read more than n bytes. It
+ * is assumed that n is at least 1.
+ */
+ size_t (*alnum_char)(const uint8_t *b, ptrdiff_t n);
+
+ /*
+ * Return true if the next character is valid in the encoding and is an
+ * uppercase character. Does not read more than n bytes. It is assumed that
+ * n is at least 1.
+ */
+ bool (*isupper_char)(const uint8_t *b, ptrdiff_t n);
+
+ /*
+ * The name of the encoding. This should correspond to a value that can be
+ * passed to Encoding.find in Ruby.
+ */
+ const char *name;
+
+ /* Return true if the encoding is a multibyte encoding. */
+ bool multibyte;
+} pm_encoding_t;
+
+/*
+ * All of the lookup tables use the first bit of each embedded byte to indicate
+ * whether the codepoint is alphabetical.
+ */
+#define PRISM_ENCODING_ALPHABETIC_BIT 1 << 0
+
+/*
+ * All of the lookup tables use the second bit of each embedded byte to indicate
+ * whether the codepoint is alphanumeric.
+ */
+#define PRISM_ENCODING_ALPHANUMERIC_BIT 1 << 1
+
+/*
+ * All of the lookup tables use the third bit of each embedded byte to indicate
+ * whether the codepoint is uppercase.
+ */
+#define PRISM_ENCODING_UPPERCASE_BIT 1 << 2
+
+/* Return the size of the next character in the UTF-8 encoding. */
+size_t pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n);
+
+/*
+ * Return the size of the next character in the UTF-8 encoding if it is an
+ * alphabetical character.
+ */
+size_t pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n);
+
+/*
+ * Return the size of the next character in the UTF-8 encoding if it is an
+ * alphanumeric character.
+ */
+size_t pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n);
+
+/*
+ * Return true if the next character in the UTF-8 encoding if it is an uppercase
+ * character.
+ */
+bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n);
+
+/*
+ * This lookup table is referenced in both the UTF-8 encoding file and the
+ * parser directly in order to speed up the default encoding processing. It is
+ * used to indicate whether a character is alphabetical, alphanumeric, or
+ * uppercase in unicode mappings.
+ */
+extern const uint8_t pm_encoding_unicode_table[256];
+
+/* These are all of the encodings that prism supports. */
+typedef enum {
+ PM_ENCODING_UTF_8 = 0,
+ PM_ENCODING_US_ASCII,
+ PM_ENCODING_ASCII_8BIT,
+ PM_ENCODING_EUC_JP,
+ PM_ENCODING_WINDOWS_31J,
+
+/* We optionally support excluding the full set of encodings to only support the
+ * minimum necessary to process Ruby code without encoding comments. */
+#ifndef PRISM_ENCODING_EXCLUDE_FULL
+ PM_ENCODING_BIG5,
+ PM_ENCODING_BIG5_HKSCS,
+ PM_ENCODING_BIG5_UAO,
+ PM_ENCODING_CESU_8,
+ PM_ENCODING_CP51932,
+ PM_ENCODING_CP850,
+ PM_ENCODING_CP852,
+ PM_ENCODING_CP855,
+ PM_ENCODING_CP949,
+ PM_ENCODING_CP950,
+ PM_ENCODING_CP951,
+ PM_ENCODING_EMACS_MULE,
+ PM_ENCODING_EUC_JP_MS,
+ PM_ENCODING_EUC_JIS_2004,
+ PM_ENCODING_EUC_KR,
+ PM_ENCODING_EUC_TW,
+ PM_ENCODING_GB12345,
+ PM_ENCODING_GB18030,
+ PM_ENCODING_GB1988,
+ PM_ENCODING_GB2312,
+ PM_ENCODING_GBK,
+ PM_ENCODING_IBM437,
+ PM_ENCODING_IBM720,
+ PM_ENCODING_IBM737,
+ PM_ENCODING_IBM775,
+ PM_ENCODING_IBM852,
+ PM_ENCODING_IBM855,
+ PM_ENCODING_IBM857,
+ PM_ENCODING_IBM860,
+ PM_ENCODING_IBM861,
+ PM_ENCODING_IBM862,
+ PM_ENCODING_IBM863,
+ PM_ENCODING_IBM864,
+ PM_ENCODING_IBM865,
+ PM_ENCODING_IBM866,
+ PM_ENCODING_IBM869,
+ PM_ENCODING_ISO_8859_1,
+ PM_ENCODING_ISO_8859_2,
+ PM_ENCODING_ISO_8859_3,
+ PM_ENCODING_ISO_8859_4,
+ PM_ENCODING_ISO_8859_5,
+ PM_ENCODING_ISO_8859_6,
+ PM_ENCODING_ISO_8859_7,
+ PM_ENCODING_ISO_8859_8,
+ PM_ENCODING_ISO_8859_9,
+ PM_ENCODING_ISO_8859_10,
+ PM_ENCODING_ISO_8859_11,
+ PM_ENCODING_ISO_8859_13,
+ PM_ENCODING_ISO_8859_14,
+ PM_ENCODING_ISO_8859_15,
+ PM_ENCODING_ISO_8859_16,
+ PM_ENCODING_KOI8_R,
+ PM_ENCODING_KOI8_U,
+ PM_ENCODING_MAC_CENT_EURO,
+ PM_ENCODING_MAC_CROATIAN,
+ PM_ENCODING_MAC_CYRILLIC,
+ PM_ENCODING_MAC_GREEK,
+ PM_ENCODING_MAC_ICELAND,
+ PM_ENCODING_MAC_JAPANESE,
+ PM_ENCODING_MAC_ROMAN,
+ PM_ENCODING_MAC_ROMANIA,
+ PM_ENCODING_MAC_THAI,
+ PM_ENCODING_MAC_TURKISH,
+ PM_ENCODING_MAC_UKRAINE,
+ PM_ENCODING_SHIFT_JIS,
+ PM_ENCODING_SJIS_DOCOMO,
+ PM_ENCODING_SJIS_KDDI,
+ PM_ENCODING_SJIS_SOFTBANK,
+ PM_ENCODING_STATELESS_ISO_2022_JP,
+ PM_ENCODING_STATELESS_ISO_2022_JP_KDDI,
+ PM_ENCODING_TIS_620,
+ PM_ENCODING_UTF8_MAC,
+ PM_ENCODING_UTF8_DOCOMO,
+ PM_ENCODING_UTF8_KDDI,
+ PM_ENCODING_UTF8_SOFTBANK,
+ PM_ENCODING_WINDOWS_1250,
+ PM_ENCODING_WINDOWS_1251,
+ PM_ENCODING_WINDOWS_1252,
+ PM_ENCODING_WINDOWS_1253,
+ PM_ENCODING_WINDOWS_1254,
+ PM_ENCODING_WINDOWS_1255,
+ PM_ENCODING_WINDOWS_1256,
+ PM_ENCODING_WINDOWS_1257,
+ PM_ENCODING_WINDOWS_1258,
+ PM_ENCODING_WINDOWS_874,
+#endif
+
+ PM_ENCODING_MAXIMUM
+} pm_encoding_type_t;
+
+/* This is the table of all of the encodings that prism supports. */
+extern const pm_encoding_t pm_encodings[PM_ENCODING_MAXIMUM];
+
+/*
+ * This is the default UTF-8 encoding. We need a reference to it to quickly
+ * create parsers.
+ */
+#define PM_ENCODING_UTF_8_ENTRY (&pm_encodings[PM_ENCODING_UTF_8])
+
+/*
+ * This is the US-ASCII encoding. We need a reference to it to be able to
+ * compare against it when a string is being created because it could possibly
+ * need to fall back to ASCII-8BIT.
+ */
+#define PM_ENCODING_US_ASCII_ENTRY (&pm_encodings[PM_ENCODING_US_ASCII])
+
+/*
+ * This is the ASCII-8BIT encoding. We need a reference to it so that pm_strpbrk
+ * can compare against it because invalid multibyte characters are not a thing
+ * in this encoding. It is also needed for handling Regexp encoding flags.
+ */
+#define PM_ENCODING_ASCII_8BIT_ENTRY (&pm_encodings[PM_ENCODING_ASCII_8BIT])
+
+/*
+ * This is the EUC-JP encoding. We need a reference to it to quickly process
+ * regular expression modifiers.
+ */
+#define PM_ENCODING_EUC_JP_ENTRY (&pm_encodings[PM_ENCODING_EUC_JP])
+
+/*
+ * This is the Windows-31J encoding. We need a reference to it to quickly
+ * process regular expression modifiers.
+ */
+#define PM_ENCODING_WINDOWS_31J_ENTRY (&pm_encodings[PM_ENCODING_WINDOWS_31J])
+
+/*
+ * Parse the given name of an encoding and return a pointer to the corresponding
+ * encoding struct if one can be found, otherwise return NULL.
+ */
+const pm_encoding_t * pm_encoding_find(const uint8_t *start, const uint8_t *end);
+
+#endif
diff --git a/prism/internal/integer.h b/prism/internal/integer.h
new file mode 100644
index 0000000000..7c9767e323
--- /dev/null
+++ b/prism/internal/integer.h
@@ -0,0 +1,68 @@
+/*
+ * This module provides functions for working with arbitrary-sized integers.
+ */
+#ifndef PRISM_INTERNAL_INTEGER_H
+#define PRISM_INTERNAL_INTEGER_H
+
+#include "prism/buffer.h"
+#include "prism/integer.h"
+
+#include <stdint.h>
+
+/*
+ * An enum controlling the base of an integer. It is expected that the base is
+ * already known before parsing the integer, even though it could be derived
+ * from the string itself.
+ */
+typedef enum {
+ /* The default decimal base, with no prefix. Leading 0s will be ignored. */
+ PM_INTEGER_BASE_DEFAULT,
+
+ /* The binary base, indicated by a 0b or 0B prefix. */
+ PM_INTEGER_BASE_BINARY,
+
+ /* The octal base, indicated by a 0, 0o, or 0O prefix. */
+ PM_INTEGER_BASE_OCTAL,
+
+ /* The decimal base, indicated by a 0d, 0D, or empty prefix. */
+ PM_INTEGER_BASE_DECIMAL,
+
+ /* The hexadecimal base, indicated by a 0x or 0X prefix. */
+ PM_INTEGER_BASE_HEXADECIMAL,
+
+ /*
+ * An unknown base, in which case pm_integer_parse will derive it based on
+ * the content of the string. This is less efficient and does more
+ * comparisons, so if callers know the base ahead of time, they should use
+ * that instead.
+ */
+ PM_INTEGER_BASE_UNKNOWN
+} pm_integer_base_t;
+
+/*
+ * Parse an integer from a string. This assumes that the format of the integer
+ * has already been validated, as internal validation checks are not performed
+ * here.
+ */
+void pm_integer_parse(pm_integer_t *integer, pm_integer_base_t base, const uint8_t *start, const uint8_t *end);
+
+/*
+ * Compare two integers. This function returns -1 if the left integer is less
+ * than the right integer, 0 if they are equal, and 1 if the left integer is
+ * greater than the right integer.
+ */
+int pm_integer_compare(const pm_integer_t *left, const pm_integer_t *right);
+
+/*
+ * Reduce a ratio of integers to its simplest form.
+ *
+ * If either the numerator or denominator do not fit into a 32-bit integer, then
+ * this function is a no-op. In the future, we may consider reducing even the
+ * larger numbers, but for now we're going to keep it simple.
+ */
+void pm_integers_reduce(pm_integer_t *numerator, pm_integer_t *denominator);
+
+/* Convert an integer to a decimal string. */
+void pm_integer_string(pm_buffer_t *buffer, const pm_integer_t *integer);
+
+#endif
diff --git a/prism/internal/isinf.h b/prism/internal/isinf.h
new file mode 100644
index 0000000000..41c160f56d
--- /dev/null
+++ b/prism/internal/isinf.h
@@ -0,0 +1,16 @@
+#ifndef PRISM_INTERNAL_ISINF_H
+#define PRISM_INTERNAL_ISINF_H
+
+/*
+ * isinf on POSIX systems accepts a float, a double, or a long double. But mingw
+ * didn't provide an isinf macro, only an isinf function that only accepts
+ * floats, so we need to use _finite instead.
+ */
+#ifdef __MINGW64__
+ #include <float.h>
+ #define PRISM_ISINF(x) (!_finite(x))
+#else
+ #define PRISM_ISINF(x) isinf(x)
+#endif
+
+#endif
diff --git a/prism/internal/line_offset_list.h b/prism/internal/line_offset_list.h
new file mode 100644
index 0000000000..dac9f7052e
--- /dev/null
+++ b/prism/internal/line_offset_list.h
@@ -0,0 +1,34 @@
+#ifndef PRISM_INTERNAL_LINE_OFFSET_LIST_H
+#define PRISM_INTERNAL_LINE_OFFSET_LIST_H
+
+#include "prism/compiler/force_inline.h"
+
+#include "prism/arena.h"
+#include "prism/line_offset_list.h"
+
+/* Initialize a new line offset list with the given capacity. */
+void pm_line_offset_list_init(pm_arena_t *arena, pm_line_offset_list_t *list, size_t capacity);
+
+/* Clear out the offsets that have been appended to the list. */
+void pm_line_offset_list_clear(pm_line_offset_list_t *list);
+
+/* Append a new offset to the list (slow path with resize). */
+void pm_line_offset_list_append_slow(pm_arena_t *arena, pm_line_offset_list_t *list, uint32_t cursor);
+
+/* Append a new offset to the list. */
+static PRISM_FORCE_INLINE void
+pm_line_offset_list_append(pm_arena_t *arena, pm_line_offset_list_t *list, uint32_t cursor) {
+ if (list->size < list->capacity) {
+ list->offsets[list->size++] = cursor;
+ } else {
+ pm_line_offset_list_append_slow(arena, list, cursor);
+ }
+}
+
+/*
+ * Returns the line of the given offset. If the offset is not in the list, the
+ * line of the closest offset less than the given offset is returned.
+ */
+int32_t pm_line_offset_list_line(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line);
+
+#endif
diff --git a/prism/internal/list.h b/prism/internal/list.h
new file mode 100644
index 0000000000..0ab59ef32a
--- /dev/null
+++ b/prism/internal/list.h
@@ -0,0 +1,62 @@
+#ifndef PRISM_INTERNAL_LIST_H
+#define PRISM_INTERNAL_LIST_H
+
+#include <stddef.h>
+
+/*
+ * This struct represents an abstract linked list that provides common
+ * functionality. It is meant to be used any time a linked list is necessary to
+ * store data.
+ *
+ * The linked list itself operates off a set of pointers. Because the pointers
+ * are not necessarily sequential, they can be of any size. We use this fact to
+ * allow the consumer of this linked list to extend the node struct to include
+ * any data they want. This is done by using the pm_list_node_t as the first
+ * member of the struct.
+ *
+ * For example, if we want to store a list of integers, we can do the following:
+ *
+ * ```c
+ * typedef struct {
+ * pm_list_node_t node;
+ * int value;
+ * } pm_int_node_t;
+ *
+ * pm_list_t list = { 0 };
+ * pm_int_node_t *node = xmalloc(sizeof(pm_int_node_t));
+ * node->value = 5;
+ *
+ * pm_list_append(&list, &node->node);
+ * ```
+ *
+ * The pm_list_t struct is used to represent the overall linked list. It
+ * contains a pointer to the head and tail of the list. This allows for easy
+ * iteration and appending of new nodes.
+ */
+typedef struct pm_list_node {
+ /* A pointer to the next node in the list. */
+ struct pm_list_node *next;
+} pm_list_node_t;
+
+/*
+ * This represents the overall linked list. It keeps a pointer to the head and
+ * tail so that iteration is easy and pushing new nodes is easy.
+ */
+typedef struct {
+ /* The size of the list. */
+ size_t size;
+
+ /* A pointer to the head of the list. */
+ pm_list_node_t *head;
+
+ /* A pointer to the tail of the list. */
+ pm_list_node_t *tail;
+} pm_list_t;
+
+/* Returns the size of the list. */
+size_t pm_list_size(pm_list_t *list);
+
+/* Append a node to the given list. */
+void pm_list_append(pm_list_t *list, pm_list_node_t *node);
+
+#endif
diff --git a/prism/internal/magic_comments.h b/prism/internal/magic_comments.h
new file mode 100644
index 0000000000..72a581c5d7
--- /dev/null
+++ b/prism/internal/magic_comments.h
@@ -0,0 +1,23 @@
+#ifndef PRISM_INTERNAL_MAGIC_COMMENTS_H
+#define PRISM_INTERNAL_MAGIC_COMMENTS_H
+
+#include "prism/magic_comments.h"
+
+#include "prism/internal/list.h"
+
+/*
+ * This is a node in the linked list of magic comments that we've found while
+ * parsing.
+ */
+struct pm_magic_comment_t {
+ /* The embedded base node. */
+ pm_list_node_t node;
+
+ /* The key of the magic comment. */
+ pm_location_t key;
+
+ /* The value of the magic comment. */
+ pm_location_t value;
+};
+
+#endif
diff --git a/prism/internal/memchr.h b/prism/internal/memchr.h
new file mode 100644
index 0000000000..6f6b0bca30
--- /dev/null
+++ b/prism/internal/memchr.h
@@ -0,0 +1,15 @@
+#ifndef PRISM_INTERNAL_MEMCHR_H
+#define PRISM_INTERNAL_MEMCHR_H
+
+#include "prism/internal/encoding.h"
+
+#include <stddef.h>
+
+/*
+ * We need to roll our own memchr to handle cases where the encoding changes and
+ * we need to search for a character in a buffer that could be the trailing byte
+ * of a multibyte character.
+ */
+const void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding);
+
+#endif
diff --git a/prism/internal/node.h b/prism/internal/node.h
new file mode 100644
index 0000000000..ca6d5616d7
--- /dev/null
+++ b/prism/internal/node.h
@@ -0,0 +1,32 @@
+#ifndef PRISM_INTERNAL_NODE_H
+#define PRISM_INTERNAL_NODE_H
+
+#include "prism/node.h"
+
+#include "prism/compiler/force_inline.h"
+
+#include "prism/arena.h"
+
+/*
+ * Slow path for pm_node_list_append: grow the list and append the node.
+ * Do not call directly — use pm_node_list_append instead.
+ */
+void pm_node_list_append_slow(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
+
+/* Append a new node onto the end of the node list. */
+static PRISM_FORCE_INLINE void
+pm_node_list_append(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) {
+ if (list->size < list->capacity) {
+ list->nodes[list->size++] = node;
+ } else {
+ pm_node_list_append_slow(arena, list, node);
+ }
+}
+
+/* Prepend a new node onto the beginning of the node list. */
+void pm_node_list_prepend(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node);
+
+/* Concatenate the given node list onto the end of the other node list. */
+void pm_node_list_concat(pm_arena_t *arena, pm_node_list_t *list, pm_node_list_t *other);
+
+#endif
diff --git a/prism/internal/options.h b/prism/internal/options.h
new file mode 100644
index 0000000000..7e37742a8b
--- /dev/null
+++ b/prism/internal/options.h
@@ -0,0 +1,212 @@
+#ifndef PRISM_INTERNAL_OPTIONS_H
+#define PRISM_INTERNAL_OPTIONS_H
+
+#include "prism/options.h"
+
+/* A scope of locals surrounding the code that is being parsed. */
+struct pm_options_scope_t {
+ /* The number of locals in the scope. */
+ size_t locals_count;
+
+ /* The names of the locals in the scope. */
+ pm_string_t *locals;
+
+ /* Flags for the set of forwarding parameters in this scope. */
+ uint8_t forwarding;
+};
+
+/*
+ * The version of Ruby syntax that we should be parsing with. This is used to
+ * allow consumers to specify which behavior they want in case they need to
+ * parse in the same way as a specific version of CRuby would have.
+ */
+typedef enum {
+ /*
+ * If an explicit version is not provided, the current version of prism will
+ * be used.
+ */
+ PM_OPTIONS_VERSION_UNSET = 0,
+
+ /* The vendored version of prism in CRuby 3.3.x. */
+ PM_OPTIONS_VERSION_CRUBY_3_3 = 1,
+
+ /* The vendored version of prism in CRuby 3.4.x. */
+ PM_OPTIONS_VERSION_CRUBY_3_4 = 2,
+
+ /* The vendored version of prism in CRuby 4.0.x. */
+ PM_OPTIONS_VERSION_CRUBY_3_5 = 3,
+
+ /* The vendored version of prism in CRuby 4.0.x. */
+ PM_OPTIONS_VERSION_CRUBY_4_0 = 3,
+
+ /* The vendored version of prism in CRuby 4.1.x. */
+ PM_OPTIONS_VERSION_CRUBY_4_1 = 4,
+
+ /* The current version of prism. */
+ PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_1
+} pm_options_version_t;
+
+/* The options that can be passed to the parser. */
+struct pm_options_t {
+ /*
+ * The callback to call when additional switches are found in a shebang
+ * comment.
+ */
+ pm_options_shebang_callback_t shebang_callback;
+
+ /*
+ * Any additional data that should be passed along to the shebang callback
+ * if one was set.
+ */
+ void *shebang_callback_data;
+
+ /* The name of the file that is currently being parsed. */
+ pm_string_t filepath;
+
+ /*
+ * The line within the file that the parse starts on. This value is
+ * 1-indexed.
+ */
+ int32_t line;
+
+ /*
+ * The name of the encoding that the source file is in. Note that this must
+ * correspond to a name that can be found with Encoding.find in Ruby.
+ */
+ pm_string_t encoding;
+
+ /* The number of scopes surrounding the code that is being parsed. */
+ size_t scopes_count;
+
+ /*
+ * The scopes surrounding the code that is being parsed. For most parses
+ * this will be NULL, but for evals it will be the locals that are in scope
+ * surrounding the eval. Scopes are ordered from the outermost scope to the
+ * innermost one.
+ */
+ pm_options_scope_t *scopes;
+
+ /*
+ * The version of prism that we should be parsing with. This is used to
+ * allow consumers to specify which behavior they want in case they need to
+ * parse exactly as a specific version of CRuby.
+ */
+ pm_options_version_t version;
+
+ /* A bitset of the various options that were set on the command line. */
+ uint8_t command_line;
+
+ /*
+ * Whether or not the frozen string literal option has been set.
+ * May be:
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET
+ */
+ int8_t frozen_string_literal;
+
+ /*
+ * Whether or not the encoding magic comments should be respected. This is a
+ * niche use-case where you want to parse a file with a specific encoding
+ * but ignore any encoding magic comments at the top of the file.
+ */
+ bool encoding_locked;
+
+ /*
+ * When the file being parsed is the main script, the shebang will be
+ * considered for command-line flags (or for implicit -x). The caller needs
+ * to pass this information to the parser so that it can behave correctly.
+ */
+ bool main_script;
+
+ /*
+ * When the file being parsed is considered a "partial" script, jumps will
+ * not be marked as errors if they are not contained within loops/blocks.
+ * This is used in the case that you're parsing a script that you know will
+ * be embedded inside another script later, but you do not have that context
+ * yet. For example, when parsing an ERB template that will be evaluated
+ * inside another script.
+ */
+ bool partial_script;
+
+ /*
+ * Whether or not the parser should freeze the nodes that it creates. This
+ * makes it possible to have a deeply frozen AST that is safe to share
+ * between concurrency primitives.
+ */
+ bool freeze;
+};
+
+/* Free the internal memory associated with the options. */
+void pm_options_cleanup(pm_options_t *options);
+
+/*
+ * Deserialize an options struct from the given binary string. This is used to
+ * pass options to the parser from an FFI call so that consumers of the library
+ * from an FFI perspective don't have to worry about the structure of our
+ * options structs. Since the source of these calls will be from Ruby
+ * implementation internals we assume it is from a trusted source.
+ *
+ * `data` is assumed to be a valid pointer pointing to well-formed data. The
+ * layout of this data should be the same every time, and is described below:
+ *
+ * | # bytes | field |
+ * | ------- | -------------------------- |
+ * | `4` | the length of the filepath |
+ * | ... | the filepath bytes |
+ * | `4` | the line number |
+ * | `4` | the length the encoding |
+ * | ... | the encoding bytes |
+ * | `1` | frozen string literal |
+ * | `1` | -p command line option |
+ * | `1` | -n command line option |
+ * | `1` | -l command line option |
+ * | `1` | -a command line option |
+ * | `1` | the version |
+ * | `1` | encoding locked |
+ * | `1` | main script |
+ * | `1` | partial script |
+ * | `1` | freeze |
+ * | `4` | the number of scopes |
+ * | ... | the scopes |
+ *
+ * The version field is an enum, so it should be one of the following values:
+ *
+ * | value | version |
+ * | ----- | ------------------------- |
+ * | `0` | use the latest version of prism |
+ * | `1` | use the version of prism that is vendored in CRuby 3.3.0 |
+ * | `2` | use the version of prism that is vendored in CRuby 3.4.0 |
+ * | `3` | use the version of prism that is vendored in CRuby 4.0.0 |
+ * | `4` | use the version of prism that is vendored in CRuby 4.1.0 |
+ *
+ * Each scope is laid out as follows:
+ *
+ * | # bytes | field |
+ * | ------- | -------------------------- |
+ * | `4` | the number of locals |
+ * | `1` | the forwarding flags |
+ * | ... | the locals |
+ *
+ * Each local is laid out as follows:
+ *
+ * | # bytes | field |
+ * | ------- | -------------------------- |
+ * | `4` | the length of the local |
+ * | ... | the local bytes |
+ *
+ * Some additional things to note about this layout:
+ *
+ * * The filepath can have a length of 0, in which case we'll consider it an
+ * empty string.
+ * * The line number should be 0-indexed.
+ * * The encoding can have a length of 0, in which case we'll use the default
+ * encoding (UTF-8). If it's not 0, it should correspond to a name of an
+ * encoding that can be passed to `Encoding.find` in Ruby.
+ * * The frozen string literal, encoding locked, main script, and partial script
+ * fields are booleans, so their values should be either 0 or 1.
+ * * The number of scopes can be 0.
+ */
+void pm_options_read(pm_options_t *options, const char *data);
+
+#endif
diff --git a/prism/internal/parser.h b/prism/internal/parser.h
new file mode 100644
index 0000000000..4320cf4029
--- /dev/null
+++ b/prism/internal/parser.h
@@ -0,0 +1,958 @@
+#ifndef PRISM_INTERNAL_PARSER_H
+#define PRISM_INTERNAL_PARSER_H
+
+#include "prism/compiler/accel.h"
+
+#include "prism/internal/arena.h"
+#include "prism/internal/constant_pool.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/list.h"
+#include "prism/internal/options.h"
+#include "prism/internal/static_literals.h"
+#include "prism/internal/strpbrk.h"
+
+#include "prism/ast.h"
+#include "prism/line_offset_list.h"
+#include "prism/parser.h"
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * This enum provides various bits that represent different kinds of states that
+ * the lexer can track. This is used to determine which kind of token to return
+ * based on the context of the parser.
+ */
+typedef enum {
+ PM_LEX_STATE_BIT_BEG,
+ PM_LEX_STATE_BIT_END,
+ PM_LEX_STATE_BIT_ENDARG,
+ PM_LEX_STATE_BIT_ENDFN,
+ PM_LEX_STATE_BIT_ARG,
+ PM_LEX_STATE_BIT_CMDARG,
+ PM_LEX_STATE_BIT_MID,
+ PM_LEX_STATE_BIT_FNAME,
+ PM_LEX_STATE_BIT_DOT,
+ PM_LEX_STATE_BIT_CLASS,
+ PM_LEX_STATE_BIT_LABEL,
+ PM_LEX_STATE_BIT_LABELED,
+ PM_LEX_STATE_BIT_FITEM
+} pm_lex_state_bit_t;
+
+/*
+ * This enum combines the various bits from the above enum into individual
+ * values that represent the various states of the lexer.
+ */
+typedef enum {
+ PM_LEX_STATE_NONE = 0,
+ PM_LEX_STATE_BEG = (1 << PM_LEX_STATE_BIT_BEG),
+ PM_LEX_STATE_END = (1 << PM_LEX_STATE_BIT_END),
+ PM_LEX_STATE_ENDARG = (1 << PM_LEX_STATE_BIT_ENDARG),
+ PM_LEX_STATE_ENDFN = (1 << PM_LEX_STATE_BIT_ENDFN),
+ PM_LEX_STATE_ARG = (1 << PM_LEX_STATE_BIT_ARG),
+ PM_LEX_STATE_CMDARG = (1 << PM_LEX_STATE_BIT_CMDARG),
+ PM_LEX_STATE_MID = (1 << PM_LEX_STATE_BIT_MID),
+ PM_LEX_STATE_FNAME = (1 << PM_LEX_STATE_BIT_FNAME),
+ PM_LEX_STATE_DOT = (1 << PM_LEX_STATE_BIT_DOT),
+ PM_LEX_STATE_CLASS = (1 << PM_LEX_STATE_BIT_CLASS),
+ PM_LEX_STATE_LABEL = (1 << PM_LEX_STATE_BIT_LABEL),
+ PM_LEX_STATE_LABELED = (1 << PM_LEX_STATE_BIT_LABELED),
+ PM_LEX_STATE_FITEM = (1 << PM_LEX_STATE_BIT_FITEM),
+ PM_LEX_STATE_BEG_ANY = PM_LEX_STATE_BEG | PM_LEX_STATE_MID | PM_LEX_STATE_CLASS,
+ PM_LEX_STATE_ARG_ANY = PM_LEX_STATE_ARG | PM_LEX_STATE_CMDARG,
+ PM_LEX_STATE_END_ANY = PM_LEX_STATE_END | PM_LEX_STATE_ENDARG | PM_LEX_STATE_ENDFN
+} pm_lex_state_t;
+
+/*
+ * The type of quote that a heredoc uses.
+ */
+typedef enum {
+ PM_HEREDOC_QUOTE_NONE,
+ PM_HEREDOC_QUOTE_SINGLE = '\'',
+ PM_HEREDOC_QUOTE_DOUBLE = '"',
+ PM_HEREDOC_QUOTE_BACKTICK = '`',
+} pm_heredoc_quote_t;
+
+/*
+ * The type of indentation that a heredoc uses.
+ */
+typedef enum {
+ PM_HEREDOC_INDENT_NONE,
+ PM_HEREDOC_INDENT_DASH,
+ PM_HEREDOC_INDENT_TILDE,
+} pm_heredoc_indent_t;
+
+/*
+ * All of the information necessary to store to lexing a heredoc.
+ */
+typedef struct {
+ /* A pointer to the start of the heredoc identifier. */
+ const uint8_t *ident_start;
+
+ /* The length of the heredoc identifier. */
+ size_t ident_length;
+
+ /* The type of quote that the heredoc uses. */
+ pm_heredoc_quote_t quote;
+
+ /* The type of indentation that the heredoc uses. */
+ pm_heredoc_indent_t indent;
+} pm_heredoc_lex_mode_t;
+
+/*
+ * When lexing Ruby source, the lexer has a small amount of state to tell which
+ * kind of token it is currently lexing. For example, when we find the start of
+ * a string, the first token that we return is a TOKEN_STRING_BEGIN token. After
+ * that the lexer is now in the PM_LEX_STRING mode, and will return tokens that
+ * are found as part of a string.
+ */
+typedef struct pm_lex_mode {
+ /* The type of this lex mode. */
+ enum {
+ /* This state is used when any given token is being lexed. */
+ PM_LEX_DEFAULT,
+
+ /*
+ * This state is used when we're lexing as normal but inside an embedded
+ * expression of a string.
+ */
+ PM_LEX_EMBEXPR,
+
+ /*
+ * This state is used when we're lexing a variable that is embedded
+ * directly inside of a string with the # shorthand.
+ */
+ PM_LEX_EMBVAR,
+
+ /* This state is used when you are inside the content of a heredoc. */
+ PM_LEX_HEREDOC,
+
+ /*
+ * This state is used when we are lexing a list of tokens, as in a %w
+ * word list literal or a %i symbol list literal.
+ */
+ PM_LEX_LIST,
+
+ /*
+ * This state is used when a regular expression has been begun and we
+ * are looking for the terminator.
+ */
+ PM_LEX_REGEXP,
+
+ /*
+ * This state is used when we are lexing a string or a string-like
+ * token, as in string content with either quote or an xstring.
+ */
+ PM_LEX_STRING
+ } mode;
+
+ /* The data associated with this type of lex mode. */
+ union {
+ struct {
+ /* This keeps track of the nesting level of the list. */
+ size_t nesting;
+
+ /* Whether or not interpolation is allowed in this list. */
+ bool interpolation;
+
+ /*
+ * When lexing a list, it takes into account balancing the
+ * terminator if the terminator is one of (), [], {}, or <>.
+ */
+ uint8_t incrementor;
+
+ /* This is the terminator of the list literal. */
+ uint8_t terminator;
+
+ /*
+ * This is the character set that should be used to delimit the
+ * tokens within the list.
+ */
+ uint8_t breakpoints[PM_STRPBRK_CACHE_SIZE];
+ } list;
+
+ struct {
+ /*
+ * This keeps track of the nesting level of the regular expression.
+ */
+ size_t nesting;
+
+ /*
+ * When lexing a regular expression, it takes into account balancing
+ * the terminator if the terminator is one of (), [], {}, or <>.
+ */
+ uint8_t incrementor;
+
+ /* This is the terminator of the regular expression. */
+ uint8_t terminator;
+
+ /*
+ * This is the character set that should be used to delimit the
+ * tokens within the regular expression.
+ */
+ uint8_t breakpoints[PM_STRPBRK_CACHE_SIZE];
+ } regexp;
+
+ struct {
+ /* This keeps track of the nesting level of the string. */
+ size_t nesting;
+
+ /* Whether or not interpolation is allowed in this string. */
+ bool interpolation;
+
+ /*
+ * Whether or not at the end of the string we should allow a :,
+ * which would indicate this was a dynamic symbol instead of a
+ * string.
+ */
+ bool label_allowed;
+
+ /*
+ * When lexing a string, it takes into account balancing the
+ * terminator if the terminator is one of (), [], {}, or <>.
+ */
+ uint8_t incrementor;
+
+ /*
+ * This is the terminator of the string. It is typically either a
+ * single or double quote.
+ */
+ uint8_t terminator;
+
+ /*
+ * This is the character set that should be used to delimit the
+ * tokens within the string.
+ */
+ uint8_t breakpoints[PM_STRPBRK_CACHE_SIZE];
+ } string;
+
+ struct {
+ /*
+ * All of the data necessary to lex a heredoc.
+ */
+ pm_heredoc_lex_mode_t base;
+
+ /*
+ * This is the pointer to the character where lexing should resume
+ * once the heredoc has been completely processed.
+ */
+ const uint8_t *next_start;
+
+ /*
+ * This is used to track the amount of common whitespace on each
+ * line so that we know how much to dedent each line in the case of
+ * a tilde heredoc.
+ */
+ size_t *common_whitespace;
+
+ /* True if the previous token ended with a line continuation. */
+ bool line_continuation;
+ } heredoc;
+ } as;
+
+ /* The previous lex state so that it knows how to pop. */
+ struct pm_lex_mode *prev;
+} pm_lex_mode_t;
+
+/*
+ * We pre-allocate a certain number of lex states in order to avoid having to
+ * call malloc too many times while parsing. You really shouldn't need more than
+ * this because you only really nest deeply when doing string interpolation.
+ */
+#define PM_LEX_STACK_SIZE 4
+
+/*
+ * While parsing, we keep track of a stack of contexts. This is helpful for
+ * error recovery so that we can pop back to a previous context when we hit a
+ * token that is understood by a parent context but not by the current context.
+ */
+typedef enum {
+ /* a null context, used for returning a value from a function */
+ PM_CONTEXT_NONE = 0,
+
+ /* a begin statement */
+ PM_CONTEXT_BEGIN,
+
+ /* an ensure statement with an explicit begin */
+ PM_CONTEXT_BEGIN_ENSURE,
+
+ /* a rescue else statement with an explicit begin */
+ PM_CONTEXT_BEGIN_ELSE,
+
+ /* a rescue statement with an explicit begin */
+ PM_CONTEXT_BEGIN_RESCUE,
+
+ /* expressions in block arguments using braces */
+ PM_CONTEXT_BLOCK_BRACES,
+
+ /* expressions in block arguments using do..end */
+ PM_CONTEXT_BLOCK_KEYWORDS,
+
+ /* an ensure statement within a do..end block */
+ PM_CONTEXT_BLOCK_ENSURE,
+
+ /* a rescue else statement within a do..end block */
+ PM_CONTEXT_BLOCK_ELSE,
+
+ /* expressions in block parameters `foo do |...| end ` */
+ PM_CONTEXT_BLOCK_PARAMETERS,
+
+ /* a rescue statement within a do..end block */
+ PM_CONTEXT_BLOCK_RESCUE,
+
+ /* a case when statements */
+ PM_CONTEXT_CASE_WHEN,
+
+ /* a case in statements */
+ PM_CONTEXT_CASE_IN,
+
+ /* a class declaration */
+ PM_CONTEXT_CLASS,
+
+ /* an ensure statement within a class statement */
+ PM_CONTEXT_CLASS_ENSURE,
+
+ /* a rescue else statement within a class statement */
+ PM_CONTEXT_CLASS_ELSE,
+
+ /* a rescue statement within a class statement */
+ PM_CONTEXT_CLASS_RESCUE,
+
+ /* a method definition */
+ PM_CONTEXT_DEF,
+
+ /* an ensure statement within a method definition */
+ PM_CONTEXT_DEF_ENSURE,
+
+ /* a rescue else statement within a method definition */
+ PM_CONTEXT_DEF_ELSE,
+
+ /* a rescue statement within a method definition */
+ PM_CONTEXT_DEF_RESCUE,
+
+ /* a method definition's parameters */
+ PM_CONTEXT_DEF_PARAMS,
+
+ /* a defined? expression */
+ PM_CONTEXT_DEFINED,
+
+ /* a method definition's default parameter */
+ PM_CONTEXT_DEFAULT_PARAMS,
+
+ /* an else clause */
+ PM_CONTEXT_ELSE,
+
+ /* an elsif clause */
+ PM_CONTEXT_ELSIF,
+
+ /* an interpolated expression */
+ PM_CONTEXT_EMBEXPR,
+
+ /* a for loop */
+ PM_CONTEXT_FOR,
+
+ /* a for loop's index */
+ PM_CONTEXT_FOR_INDEX,
+
+ /* an if statement */
+ PM_CONTEXT_IF,
+
+ /* a lambda expression with braces */
+ PM_CONTEXT_LAMBDA_BRACES,
+
+ /* a lambda expression with do..end */
+ PM_CONTEXT_LAMBDA_DO_END,
+
+ /* an ensure statement within a lambda expression */
+ PM_CONTEXT_LAMBDA_ENSURE,
+
+ /* a rescue else statement within a lambda expression */
+ PM_CONTEXT_LAMBDA_ELSE,
+
+ /* a rescue statement within a lambda expression */
+ PM_CONTEXT_LAMBDA_RESCUE,
+
+ /* the predicate clause of a loop statement */
+ PM_CONTEXT_LOOP_PREDICATE,
+
+ /* the top level context */
+ PM_CONTEXT_MAIN,
+
+ /* a module declaration */
+ PM_CONTEXT_MODULE,
+
+ /* an ensure statement within a module statement */
+ PM_CONTEXT_MODULE_ENSURE,
+
+ /* a rescue else statement within a module statement */
+ PM_CONTEXT_MODULE_ELSE,
+
+ /* a rescue statement within a module statement */
+ PM_CONTEXT_MODULE_RESCUE,
+
+ /* a multiple target expression */
+ PM_CONTEXT_MULTI_TARGET,
+
+ /* a parenthesized expression */
+ PM_CONTEXT_PARENS,
+
+ /* an END block */
+ PM_CONTEXT_POSTEXE,
+
+ /* a predicate inside an if/elsif/unless statement */
+ PM_CONTEXT_PREDICATE,
+
+ /* a BEGIN block */
+ PM_CONTEXT_PREEXE,
+
+ /* a modifier rescue clause */
+ PM_CONTEXT_RESCUE_MODIFIER,
+
+ /* a singleton class definition */
+ PM_CONTEXT_SCLASS,
+
+ /* an ensure statement with a singleton class */
+ PM_CONTEXT_SCLASS_ENSURE,
+
+ /* a rescue else statement with a singleton class */
+ PM_CONTEXT_SCLASS_ELSE,
+
+ /* a rescue statement with a singleton class */
+ PM_CONTEXT_SCLASS_RESCUE,
+
+ /* a ternary expression */
+ PM_CONTEXT_TERNARY,
+
+ /* an unless statement */
+ PM_CONTEXT_UNLESS,
+
+ /* an until statement */
+ PM_CONTEXT_UNTIL,
+
+ /* a while statement */
+ PM_CONTEXT_WHILE,
+} pm_context_t;
+
+/* This is a node in a linked list of contexts. */
+typedef struct pm_context_node {
+ /* The context that this node represents. */
+ pm_context_t context;
+
+ /* A pointer to the previous context in the linked list. */
+ struct pm_context_node *prev;
+} pm_context_node_t;
+
+/* The type of shareable constant value that can be set. */
+typedef uint8_t pm_shareable_constant_value_t;
+static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_NONE = 0x0;
+static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_LITERAL = PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL;
+static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_EVERYTHING = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING;
+static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_COPY = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY;
+
+/*
+ * This tracks an individual local variable in a certain lexical context, as
+ * well as the number of times is it read.
+ */
+typedef struct {
+ /* The name of the local variable. */
+ pm_constant_id_t name;
+
+ /* The location of the local variable in the source. */
+ pm_location_t location;
+
+ /* The index of the local variable in the local table. */
+ uint32_t index;
+
+ /* The number of times the local variable is read. */
+ uint32_t reads;
+
+ /* The hash of the local variable. */
+ uint32_t hash;
+} pm_local_t;
+
+/*
+ * This is a set of local variables in a certain lexical context (method, class,
+ * module, etc.). We need to track how many times these variables are read in
+ * order to warn if they only get written.
+ */
+typedef struct pm_locals {
+ /* The number of local variables in the set. */
+ uint32_t size;
+
+ /* The capacity of the local variables set. */
+ uint32_t capacity;
+
+ /*
+ * A bloom filter over constant IDs stored in this set. Used to quickly
+ * reject lookups for names that are definitely not present, avoiding the
+ * cost of a linear scan or hash probe.
+ */
+ uint32_t bloom;
+
+ /* The nullable allocated memory for the local variables in the set. */
+ pm_local_t *locals;
+} pm_locals_t;
+
+/* The flags about scope parameters that can be set. */
+typedef uint8_t pm_scope_parameters_t;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NONE = 0x0;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS = 0x1;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS = 0x2;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_BLOCK = 0x4;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_ALL = 0x8;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED = 0x10;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_INNER = 0x20;
+static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_FOUND = 0x40;
+
+/*
+ * This struct represents a node in a linked list of scopes. Some scopes can see
+ * into their parent scopes, while others cannot.
+ */
+typedef struct pm_scope {
+ /* A pointer to the previous scope in the linked list. */
+ struct pm_scope *previous;
+
+ /* The IDs of the locals in the given scope. */
+ pm_locals_t locals;
+
+ /*
+ * This is a list of the implicit parameters contained within the block.
+ * These will be processed after the block is parsed to determine the kind
+ * of parameters node that should be used and to check if any errors need to
+ * be added.
+ */
+ pm_node_list_t implicit_parameters;
+
+ /*
+ * This is a bitfield that indicates the parameters that are being used in
+ * this scope. It is a combination of the PM_SCOPE_PARAMETERS_* constants.
+ * There are three different kinds of parameters that can be used in a
+ * scope:
+ *
+ * - Ordinary parameters (e.g., def foo(bar); end)
+ * - Numbered parameters (e.g., def foo; _1; end)
+ * - The it parameter (e.g., def foo; it; end)
+ *
+ * If ordinary parameters are being used, then certain parameters can be
+ * forwarded to another method/structure. Those are indicated by four
+ * additional bits in the params field. For example, some combinations of:
+ *
+ * - def foo(*); end
+ * - def foo(**); end
+ * - def foo(&); end
+ * - def foo(...); end
+ */
+ pm_scope_parameters_t parameters;
+
+ /*
+ * The current state of constant shareability for this scope. This is
+ * changed by magic shareable_constant_value comments.
+ */
+ pm_shareable_constant_value_t shareable_constant;
+
+ /*
+ * A boolean indicating whether or not this scope can see into its parent.
+ * If closed is true, then the scope cannot see into its parent.
+ */
+ bool closed;
+} pm_scope_t;
+
+/*
+ * A struct that represents a stack of boolean values.
+ */
+typedef uint32_t pm_state_stack_t;
+
+/*
+ * This struct represents the overall parser. It contains a reference to the
+ * source file, as well as pointers that indicate where in the source it's
+ * currently parsing. It also contains the most recent and current token that
+ * it's considering.
+ */
+struct pm_parser_t {
+ /* The arena used for all AST-lifetime allocations. Caller-owned. */
+ pm_arena_t *arena;
+
+ /* The arena used for parser metadata (comments, diagnostics, etc.). */
+ pm_arena_t metadata_arena;
+
+ /*
+ * The next node identifier that will be assigned. This is a unique
+ * identifier used to track nodes such that the syntax tree can be dropped
+ * but the node can be found through another parse.
+ */
+ uint32_t node_id;
+
+ /*
+ * A single-entry cache for pm_parser_constant_id_raw. Avoids redundant
+ * constant pool lookups when the same token is resolved multiple times
+ * (e.g., once during lexing for local variable detection, and again
+ * during parsing for node creation).
+ */
+ struct {
+ const uint8_t *start;
+ const uint8_t *end;
+ pm_constant_id_t id;
+ } constant_cache;
+
+ /* The current state of the lexer. */
+ pm_lex_state_t lex_state;
+
+ /* Tracks the current nesting of (), [], and {}. */
+ int enclosure_nesting;
+
+ /*
+ * Used to temporarily track the nesting of enclosures to determine if a {
+ * is the beginning of a lambda following the parameters of a lambda.
+ */
+ int lambda_enclosure_nesting;
+
+ /*
+ * Used to track the nesting of braces to ensure we get the correct value
+ * when we are interpolating blocks with braces.
+ */
+ int brace_nesting;
+
+ /*
+ * The stack used to determine if a do keyword belongs to the predicate of a
+ * while, until, or for loop.
+ */
+ pm_state_stack_t do_loop_stack;
+
+ /*
+ * The stack used to determine if a do keyword belongs to the beginning of a
+ * block.
+ */
+ pm_state_stack_t accepts_block_stack;
+
+ /* A stack of lex modes. */
+ struct {
+ /* The current mode of the lexer. */
+ pm_lex_mode_t *current;
+
+ /* The stack of lexer modes. */
+ pm_lex_mode_t stack[PM_LEX_STACK_SIZE];
+
+ /* The current index into the lexer mode stack. */
+ size_t index;
+ } lex_modes;
+
+ /* The pointer to the start of the source. */
+ const uint8_t *start;
+
+ /* The pointer to the end of the source. */
+ const uint8_t *end;
+
+ /* The previous token we were considering. */
+ pm_token_t previous;
+
+ /* The current token we're considering. */
+ pm_token_t current;
+
+ /*
+ * This is a special field set on the parser when we need the parser to jump
+ * to a specific location when lexing the next token, as opposed to just
+ * using the end of the previous token. Normally this is NULL.
+ */
+ const uint8_t *next_start;
+
+ /*
+ * This field indicates the end of a heredoc whose identifier was found on
+ * the current line. If another heredoc is found on the same line, then this
+ * will be moved forward to the end of that heredoc. If no heredocs are
+ * found on a line then this is NULL.
+ */
+ const uint8_t *heredoc_end;
+
+ /* The list of comments that have been found while parsing. */
+ pm_list_t comment_list;
+
+ /* The list of magic comments that have been found while parsing. */
+ pm_list_t magic_comment_list;
+
+ /*
+ * An optional location that represents the location of the __END__ marker
+ * and the rest of the content of the file. This content is loaded into the
+ * DATA constant when the file being parsed is the main file being executed.
+ */
+ pm_location_t data_loc;
+
+ /* The list of warnings that have been found while parsing. */
+ pm_list_t warning_list;
+
+ /* The list of errors that have been found while parsing. */
+ pm_list_t error_list;
+
+ /* The current local scope. */
+ pm_scope_t *current_scope;
+
+ /* The current parsing context. */
+ pm_context_node_t *current_context;
+
+ /*
+ * The hash keys for the hash that is currently being parsed. This is not
+ * usually necessary because it can pass it down the various call chains,
+ * but in the event that you're parsing a hash that is being directly
+ * pushed into another hash with **, we need to share the hash keys so that
+ * we can warn for the nested hash as well.
+ */
+ pm_static_literals_t *current_hash_keys;
+
+ /*
+ * The encoding functions for the current file is attached to the parser as
+ * it's parsing so that it can change with a magic comment.
+ */
+ const pm_encoding_t *encoding;
+
+ /*
+ * When the encoding that is being used to parse the source is changed by
+ * prism, we provide the ability here to call out to a user-defined
+ * function.
+ */
+ pm_encoding_changed_callback_t encoding_changed_callback;
+
+ /*
+ * This pointer indicates where a comment must start if it is to be
+ * considered an encoding comment.
+ */
+ const uint8_t *encoding_comment_start;
+
+ /*
+ * When you are lexing through a file, the lexer needs all of the information
+ * that the parser additionally provides (for example, the local table). So if
+ * you want to properly lex Ruby, you need to actually lex it in the context of
+ * the parser. In order to provide this functionality, we optionally allow a
+ * struct to be attached to the parser that calls back out to a user-provided
+ * callback when each token is lexed.
+ */
+ struct {
+ /*
+ * This is the callback that is called when a token is lexed. It is
+ * passed the opaque data pointer, the parser, and the token that was
+ * lexed.
+ */
+ pm_lex_callback_t callback;
+
+ /*
+ * This opaque pointer is used to provide whatever information the user
+ * deemed necessary to the callback. In our case we use it to pass the
+ * array that the tokens get appended into.
+ */
+ void *data;
+ } lex_callback;
+
+ /*
+ * This is the path of the file being parsed. We use the filepath when
+ * constructing SourceFileNodes.
+ */
+ pm_string_t filepath;
+
+ /*
+ * This constant pool keeps all of the constants defined throughout the file
+ * so that we can reference them later.
+ */
+ pm_constant_pool_t constant_pool;
+
+ /* This is the list of line offsets in the source file. */
+ pm_line_offset_list_t line_offsets;
+
+ /*
+ * State communicated from the lexer to the parser for integer tokens.
+ */
+ struct {
+ /*
+ * A flag indicating the base of the integer (binary, octal, decimal,
+ * hexadecimal). Set during lexing and read during node creation.
+ */
+ pm_node_flags_t base;
+
+ /*
+ * When lexing a decimal integer that fits in a uint32_t, we compute
+ * the value during lexing to avoid re-scanning the digits during
+ * parsing. If lexed is true, this holds the result and
+ * pm_integer_parse can be skipped.
+ */
+ uint32_t value;
+
+ /* Whether value holds a valid pre-computed integer. */
+ bool lexed;
+ } integer;
+
+ /*
+ * This string is used to pass information from the lexer to the parser. It
+ * is particularly necessary because of escape sequences.
+ */
+ pm_string_t current_string;
+
+ /*
+ * The line number at the start of the parse. This will be used to offset
+ * the line numbers of all of the locations.
+ */
+ int32_t start_line;
+
+ /*
+ * When a string-like expression is being lexed, any byte or escape sequence
+ * that resolves to a value whose top bit is set (i.e., >= 0x80) will
+ * explicitly set the encoding to the same encoding as the source.
+ * Alternatively, if a unicode escape sequence is used (e.g., \\u{80}) that
+ * resolves to a value whose top bit is set, then the encoding will be
+ * explicitly set to UTF-8.
+ *
+ * The _next_ time this happens, if the encoding that is about to become the
+ * explicitly set encoding does not match the previously set explicit
+ * encoding, a mixed encoding error will be emitted.
+ *
+ * When the expression is finished being lexed, the explicit encoding
+ * controls the encoding of the expression. For the most part this means
+ * that the expression will either be encoded in the source encoding or
+ * UTF-8. This holds for all encodings except US-ASCII. If the source is
+ * US-ASCII and an explicit encoding was set that was _not_ UTF-8, then the
+ * expression will be encoded as ASCII-8BIT.
+ *
+ * Note that if the expression is a list, different elements within the same
+ * list can have different encodings, so this will get reset between each
+ * element. Furthermore all of this only applies to lists that support
+ * interpolation, because otherwise escapes that could change the encoding
+ * are ignored.
+ *
+ * At first glance, it may make more sense for this to live on the lexer
+ * mode, but we need it here to communicate back to the parser for character
+ * literals that do not push a new lexer mode.
+ */
+ const pm_encoding_t *explicit_encoding;
+
+ /*
+ * When parsing block exits (e.g., break, next, redo), we need to validate
+ * that they are in correct contexts. For the most part we can do this by
+ * looking at our parent contexts. However, modifier while and until
+ * expressions can change that context to make block exits valid. In these
+ * cases, we need to keep track of the block exits and then validate them
+ * after the expression has been parsed.
+ *
+ * We use a pointer here because we don't want to keep a whole list attached
+ * since this will only be used in the context of begin/end expressions.
+ */
+ pm_node_list_t *current_block_exits;
+
+ /* The version of prism that we should use to parse. */
+ pm_options_version_t version;
+
+ /* The command line flags given from the options. */
+ uint8_t command_line;
+
+ /*
+ * Whether or not we have found a frozen_string_literal magic comment with
+ * a true or false value.
+ * May be:
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED
+ * - PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET
+ */
+ int8_t frozen_string_literal;
+
+ /*
+ * Whether or not we are parsing an eval string. This impacts whether or not
+ * we should evaluate if block exits/yields are valid.
+ */
+ bool parsing_eval;
+
+ /*
+ * Whether or not we are parsing a "partial" script, which is a script that
+ * will be evaluated in the context of another script, so we should not
+ * check jumps (next/break/etc.) for validity.
+ */
+ bool partial_script;
+
+ /* Whether or not we're at the beginning of a command. */
+ bool command_start;
+
+ /*
+ * Whether or not we're currently parsing the body of an endless method
+ * definition. In this context, PM_TOKEN_KEYWORD_DO_BLOCK should not be
+ * consumed by commands (it should bubble up to the outer context).
+ */
+ bool in_endless_def_body;
+
+ /* Whether or not we're currently recovering from a syntax error. */
+ bool recovering;
+
+ /*
+ * Whether or not the source being parsed could become valid if more input
+ * were appended. This is set to false when the parser encounters a token
+ * that is definitively wrong (e.g., a stray `end` or `]`) as opposed to
+ * merely incomplete.
+ */
+ bool continuable;
+
+ /*
+ * This is very specialized behavior for when you want to parse in a context
+ * that does not respect encoding comments. Its main use case is translating
+ * into the whitequark/parser AST which re-encodes source files in UTF-8
+ * before they are parsed and ignores encoding comments.
+ */
+ bool encoding_locked;
+
+ /*
+ * Whether or not the encoding has been changed by a magic comment. We use
+ * this to provide a fast path for the lexer instead of going through the
+ * function pointer.
+ */
+ bool encoding_changed;
+
+ /*
+ * This flag indicates that we are currently parsing a pattern matching
+ * expression and impacts that calculation of newlines.
+ */
+ bool pattern_matching_newlines;
+
+ /* This flag indicates that we are currently parsing a keyword argument. */
+ bool in_keyword_arg;
+
+ /*
+ * Whether or not the parser has seen a token that has semantic meaning
+ * (i.e., a token that is not a comment or whitespace).
+ */
+ bool semantic_token_seen;
+
+ /*
+ * By default, Ruby always warns about mismatched indentation. This can be
+ * toggled with a magic comment.
+ */
+ bool warn_mismatched_indentation;
+
+#if defined(PRISM_HAS_NEON) || defined(PRISM_HAS_SSSE3) || defined(PRISM_HAS_SWAR)
+ /*
+ * Cached lookup tables for pm_strpbrk's SIMD fast path. Avoids rebuilding
+ * the nibble-based tables on every call when the charset hasn't changed
+ * (which is the common case during string/regex/list lexing).
+ */
+ struct {
+ /* The cached charset (null-terminated, max 11 chars + NUL). */
+ uint8_t charset[12];
+
+ /* Nibble-based low lookup table for SIMD matching. */
+ uint8_t low_lut[16];
+
+ /* Nibble-based high lookup table for SIMD matching. */
+ uint8_t high_lut[16];
+
+ /* Scalar fallback table (4 x 64-bit bitmasks covering all ASCII). */
+ uint64_t table[4];
+ } strpbrk_cache;
+#endif
+};
+
+/*
+ * Initialize a parser with the given start and end pointers.
+ */
+void pm_parser_init(pm_arena_t *arena, pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options);
+
+/*
+ * Free the memory held by the given parser.
+ *
+ * This does not free the `pm_options_t` object that was used to initialize the
+ * parser.
+ */
+void pm_parser_cleanup(pm_parser_t *parser);
+
+#endif
diff --git a/prism/internal/regexp.h b/prism/internal/regexp.h
new file mode 100644
index 0000000000..3710c984fc
--- /dev/null
+++ b/prism/internal/regexp.h
@@ -0,0 +1,41 @@
+#ifndef PRISM_INTERNAL_REGEXP_H
+#define PRISM_INTERNAL_REGEXP_H
+
+#include "prism/ast.h"
+#include "prism/parser.h"
+
+/*
+ * Accumulation state for named capture groups found during regexp parsing.
+ * The caller initializes this with the call node and passes it to
+ * pm_regexp_parse. The regexp parser populates match and names as groups
+ * are found.
+ */
+typedef struct {
+ /* The call node wrapping the regular expression node (for =~). */
+ pm_call_node_t *call;
+
+ /* The match write node being built, or NULL if no captures found yet. */
+ pm_match_write_node_t *match;
+
+ /* The list of capture names found so far (for deduplication). */
+ pm_constant_id_list_t names;
+} pm_regexp_name_data_t;
+
+/*
+ * Callback invoked by pm_regexp_parse() for each named capture group found.
+ */
+typedef void (*pm_regexp_name_callback_t)(pm_parser_t *parser, const pm_string_t *name, bool shared, pm_regexp_name_data_t *data);
+
+/*
+ * Parse a regular expression, validate its encoding, and optionally extract
+ * named capture groups. Returns the encoding flags to set on the node.
+ */
+PRISM_EXPORTED_FUNCTION pm_node_flags_t pm_regexp_parse(pm_parser_t *parser, pm_regular_expression_node_t *node, pm_regexp_name_callback_t name_callback, pm_regexp_name_data_t *name_data);
+
+/*
+ * Parse an interpolated regular expression for named capture groups only.
+ * No encoding validation is performed.
+ */
+void pm_regexp_parse_named_captures(pm_parser_t *parser, const uint8_t *source, size_t size, bool shared, bool extended_mode, pm_regexp_name_callback_t name_callback, pm_regexp_name_data_t *name_data);
+
+#endif
diff --git a/prism/internal/serialize.h b/prism/internal/serialize.h
new file mode 100644
index 0000000000..e611a0374b
--- /dev/null
+++ b/prism/internal/serialize.h
@@ -0,0 +1,34 @@
+#ifndef PRISM_INTERNAL_SERIALIZE_H
+#define PRISM_INTERNAL_SERIALIZE_H
+
+#include "prism/internal/encoding.h"
+#include "prism/internal/list.h"
+
+#include "prism/ast.h"
+#include "prism/buffer.h"
+#include "prism/excludes.h"
+#include "prism/parser.h"
+
+/* We optionally support serializing to a binary string. For systems that do not
+ * want or need this functionality, it can be turned off with the
+ * PRISM_EXCLUDE_SERIALIZATION define. */
+#ifndef PRISM_EXCLUDE_SERIALIZATION
+
+/*
+ * Serialize the given list of comments to the given buffer.
+ */
+void pm_serialize_comment_list(pm_list_t *list, pm_buffer_t *buffer);
+
+/*
+ * Serialize the name of the encoding to the buffer.
+ */
+void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer);
+
+/*
+ * Serialize the encoding, metadata, nodes, and constant pool.
+ */
+void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
+
+#endif
+
+#endif
diff --git a/prism/internal/source.h b/prism/internal/source.h
new file mode 100644
index 0000000000..b3c2b55be3
--- /dev/null
+++ b/prism/internal/source.h
@@ -0,0 +1,72 @@
+#ifndef PRISM_INTERNAL_SOURCE_H
+#define PRISM_INTERNAL_SOURCE_H
+
+#include "prism/source.h"
+#include "prism/buffer.h"
+
+#include <stdbool.h>
+
+/*
+ * The type of source, which determines cleanup behavior.
+ */
+typedef enum {
+ /* Wraps existing constant memory, no cleanup. */
+ PM_SOURCE_CONSTANT,
+
+ /* Wraps existing shared memory (non-owning slice), no cleanup. */
+ PM_SOURCE_SHARED,
+
+ /* Owns a heap-allocated buffer, freed on cleanup. */
+ PM_SOURCE_OWNED,
+
+ /* Memory-mapped file, unmapped on cleanup. */
+ PM_SOURCE_MAPPED,
+
+ /* Stream source backed by a pm_buffer_t. */
+ PM_SOURCE_STREAM
+} pm_source_type_t;
+
+/*
+ * The internal representation of a source.
+ */
+struct pm_source_t {
+ /* A pointer to the start of the source data. */
+ const uint8_t *source;
+
+ /* The length of the source data in bytes. */
+ size_t length;
+
+ /* The type of the source. */
+ pm_source_type_t type;
+
+ /* Stream-specific data, only used for PM_SOURCE_STREAM sources. */
+ struct {
+ /* The buffer that holds the accumulated stream data. */
+ pm_buffer_t *buffer;
+
+ /* The stream object to read from. */
+ void *stream;
+
+ /* The function to use to read from the stream. */
+ pm_source_stream_fgets_t *fgets;
+
+ /* The function to use to check if the stream is at EOF. */
+ pm_source_stream_feof_t *feof;
+
+ /* Whether the stream has reached EOF. */
+ bool eof;
+ } stream;
+};
+
+/*
+ * Read from a stream into the source's internal buffer. This is used by
+ * pm_parse_stream to incrementally read the source.
+ */
+bool pm_source_stream_read(pm_source_t *source);
+
+/*
+ * Returns whether the stream source has reached EOF.
+ */
+bool pm_source_stream_eof(const pm_source_t *source);
+
+#endif
diff --git a/prism/internal/static_literals.h b/prism/internal/static_literals.h
new file mode 100644
index 0000000000..d59002ac0a
--- /dev/null
+++ b/prism/internal/static_literals.h
@@ -0,0 +1,98 @@
+#ifndef PRISM_INTERNAL_STATIC_LITERALS_H
+#define PRISM_INTERNAL_STATIC_LITERALS_H
+
+#include "prism/ast.h"
+#include "prism/buffer.h"
+#include "prism/line_offset_list.h"
+
+/*
+ * An internal hash table for a set of nodes.
+ */
+typedef struct {
+ /* The array of nodes in the hash table. */
+ pm_node_t **nodes;
+
+ /* The size of the hash table. */
+ uint32_t size;
+
+ /* The space that has been allocated in the hash table. */
+ uint32_t capacity;
+} pm_node_hash_t;
+
+/*
+ * Certain sets of nodes (hash keys and when clauses) check for duplicate nodes
+ * to alert the user of potential issues. To do this, we keep a set of the nodes
+ * that have been seen so far, and compare whenever we find a new node.
+ *
+ * We bucket the nodes based on their type to minimize the number of comparisons
+ * that need to be performed.
+ */
+typedef struct {
+ /*
+ * This is the set of IntegerNode and SourceLineNode instances.
+ */
+ pm_node_hash_t integer_nodes;
+
+ /*
+ * This is the set of FloatNode instances.
+ */
+ pm_node_hash_t float_nodes;
+
+ /*
+ * This is the set of RationalNode and ImaginaryNode instances.
+ */
+ pm_node_hash_t number_nodes;
+
+ /*
+ * This is the set of StringNode and SourceFileNode instances.
+ */
+ pm_node_hash_t string_nodes;
+
+ /*
+ * This is the set of RegularExpressionNode instances.
+ */
+ pm_node_hash_t regexp_nodes;
+
+ /*
+ * This is the set of SymbolNode instances.
+ */
+ pm_node_hash_t symbol_nodes;
+
+ /*
+ * A pointer to the last TrueNode instance that was inserted, or NULL.
+ */
+ pm_node_t *true_node;
+
+ /*
+ * A pointer to the last FalseNode instance that was inserted, or NULL.
+ */
+ pm_node_t *false_node;
+
+ /*
+ * A pointer to the last NilNode instance that was inserted, or NULL.
+ */
+ pm_node_t *nil_node;
+
+ /*
+ * A pointer to the last SourceEncodingNode instance that was inserted, or
+ * NULL.
+ */
+ pm_node_t *source_encoding_node;
+} pm_static_literals_t;
+
+/*
+ * Add a node to the set of static literals.
+ */
+pm_node_t * pm_static_literals_add(const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace);
+
+/*
+ * Free the internal memory associated with the given static literals set.
+ */
+void pm_static_literals_free(pm_static_literals_t *literals);
+
+/*
+ * Create a string-based representation of the given static literal.
+ */
+void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, const char *encoding_name, const pm_node_t *node);
+
+#endif
diff --git a/prism/internal/stringy.h b/prism/internal/stringy.h
new file mode 100644
index 0000000000..1aaa23ea75
--- /dev/null
+++ b/prism/internal/stringy.h
@@ -0,0 +1,30 @@
+#ifndef PRISM_INTERNAL_STRINGY_H
+#define PRISM_INTERNAL_STRINGY_H
+
+#include "prism/stringy.h"
+
+/*
+ * Defines an empty string. This is useful for initializing a string that will
+ * be filled in later.
+ */
+#define PM_STRING_EMPTY ((pm_string_t) { .type = PM_STRING_CONSTANT, .source = NULL, .length = 0 })
+
+/*
+ * Initialize a shared string that is based on initial input.
+ */
+void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end);
+
+/*
+ * Compare the underlying lengths and bytes of two strings. Returns 0 if the
+ * strings are equal, a negative number if the left string is less than the
+ * right string, and a positive number if the left string is greater than the
+ * right string.
+ */
+int pm_string_compare(const pm_string_t *left, const pm_string_t *right);
+
+/*
+ * Free the associated memory of the given string.
+ */
+void pm_string_cleanup(pm_string_t *string);
+
+#endif
diff --git a/prism/internal/strncasecmp.h b/prism/internal/strncasecmp.h
new file mode 100644
index 0000000000..775f6a993e
--- /dev/null
+++ b/prism/internal/strncasecmp.h
@@ -0,0 +1,18 @@
+#ifndef PRISM_INTERNAL_STRNCASECMP_H
+#define PRISM_INTERNAL_STRNCASECMP_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * Compare two strings, ignoring case, up to the given length. Returns 0 if the
+ * strings are equal, a negative number if string1 is less than string2, or a
+ * positive number if string1 is greater than string2.
+ *
+ * Note that this is effectively our own implementation of strncasecmp, but it's
+ * not available on all of the platforms we want to support so we're rolling it
+ * here.
+ */
+int pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length);
+
+#endif
diff --git a/prism/internal/strpbrk.h b/prism/internal/strpbrk.h
new file mode 100644
index 0000000000..d64156c002
--- /dev/null
+++ b/prism/internal/strpbrk.h
@@ -0,0 +1,33 @@
+#ifndef PRISM_INTERNAL_STRPBRK_H
+#define PRISM_INTERNAL_STRPBRK_H
+
+#include "prism/parser.h"
+
+/* The maximum number of bytes in a strpbrk charset. */
+#define PM_STRPBRK_CACHE_SIZE 16
+
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * Here we have rolled our own version of strpbrk. The standard library strpbrk
+ * has undefined behavior when the source string is not null-terminated. We want
+ * to support strings that are not null-terminated because pm_parse does not
+ * have the contract that the string is null-terminated. (This is desirable
+ * because it means the extension can call pm_parse with the result of a call to
+ * mmap).
+ *
+ * The standard library strpbrk also does not support passing a maximum length
+ * to search. We want to support this for the reason mentioned above, but we
+ * also don't want it to stop on null bytes. Ruby actually allows null bytes
+ * within strings, comments, regular expressions, etc. So we need to be able to
+ * skip past them.
+ *
+ * Finally, we want to support encodings wherein the charset could contain
+ * characters that are trailing bytes of multi-byte characters. For example, in
+ * Shift-JIS, the backslash character can be a trailing byte. In that case we
+ * need to take a slower path and iterate one multi-byte character at a time.
+ */
+const uint8_t * pm_strpbrk(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, ptrdiff_t length, bool validate);
+
+#endif
diff --git a/prism/internal/tokens.h b/prism/internal/tokens.h
new file mode 100644
index 0000000000..3a983e54ae
--- /dev/null
+++ b/prism/internal/tokens.h
@@ -0,0 +1,11 @@
+#ifndef PRISM_INTERNAL_TOKENS_H
+#define PRISM_INTERNAL_TOKENS_H
+
+#include "prism/ast.h"
+
+/*
+ * Returns the human name of the given token type.
+ */
+const char * pm_token_str(pm_token_type_t token_type);
+
+#endif
diff --git a/prism/json.h b/prism/json.h
new file mode 100644
index 0000000000..11039e7796
--- /dev/null
+++ b/prism/json.h
@@ -0,0 +1,32 @@
+/**
+ * @file json.h
+ */
+#ifndef PRISM_JSON_H
+#define PRISM_JSON_H
+
+#include "prism/excludes.h"
+
+/* We optionally support dumping to JSON. For systems that don't want or need
+ * this functionality, it can be turned off with the PRISM_EXCLUDE_JSON define.
+ */
+#ifndef PRISM_EXCLUDE_JSON
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+#include "prism/buffer.h"
+#include "prism/parser.h"
+
+/**
+ * Dump JSON to the given buffer.
+ *
+ * @param buffer The buffer to serialize to.
+ * @param parser The parser that parsed the node.
+ * @param node The node to serialize.
+ */
+PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *node) PRISM_NONNULL(1, 2, 3);
+
+#endif
+
+#endif
diff --git a/prism/line_offset_list.c b/prism/line_offset_list.c
new file mode 100644
index 0000000000..ce217ebd3f
--- /dev/null
+++ b/prism/line_offset_list.c
@@ -0,0 +1,100 @@
+#include "prism/compiler/align.h"
+#include "prism/internal/line_offset_list.h"
+#include "prism/internal/arena.h"
+
+#include <assert.h>
+#include <string.h>
+
+/**
+ * Initialize a new line offset list with the given capacity.
+ */
+void
+pm_line_offset_list_init(pm_arena_t *arena, pm_line_offset_list_t *list, size_t capacity) {
+ list->offsets = (uint32_t *) pm_arena_alloc(arena, capacity * sizeof(uint32_t), PRISM_ALIGNOF(uint32_t));
+
+ // The first line always has offset 0.
+ list->offsets[0] = 0;
+ list->size = 1;
+ list->capacity = capacity;
+}
+
+/**
+ * Clear out the newlines that have been appended to the list.
+ */
+void
+pm_line_offset_list_clear(pm_line_offset_list_t *list) {
+ list->size = 1;
+}
+
+/**
+ * Append a new offset to the newline list (slow path: resize and store).
+ */
+void
+pm_line_offset_list_append_slow(pm_arena_t *arena, pm_line_offset_list_t *list, uint32_t cursor) {
+ size_t new_capacity = (list->capacity * 3) / 2;
+ uint32_t *new_offsets = (uint32_t *) pm_arena_alloc(arena, new_capacity * sizeof(uint32_t), PRISM_ALIGNOF(uint32_t));
+
+ memcpy(new_offsets, list->offsets, list->size * sizeof(uint32_t));
+
+ list->offsets = new_offsets;
+ list->capacity = new_capacity;
+
+ assert(list->size == 0 || cursor > list->offsets[list->size - 1]);
+ list->offsets[list->size++] = cursor;
+}
+
+/**
+ * Returns the line of the given offset. If the offset is not in the list, the
+ * line of the closest offset less than the given offset is returned.
+ */
+int32_t
+pm_line_offset_list_line(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line) {
+ size_t left = 0;
+ size_t right = list->size - 1;
+
+ while (left <= right) {
+ size_t mid = left + (right - left) / 2;
+
+ if (list->offsets[mid] == cursor) {
+ return ((int32_t) mid) + start_line;
+ }
+
+ if (list->offsets[mid] < cursor) {
+ left = mid + 1;
+ } else {
+ right = mid - 1;
+ }
+ }
+
+ return ((int32_t) left) + start_line - 1;
+}
+
+/**
+ * Returns the line and column of the given offset. If the offset is not in the
+ * list, the line and column of the closest offset less than the given offset
+ * are returned.
+ */
+pm_line_column_t
+pm_line_offset_list_line_column(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line) {
+ size_t left = 0;
+ size_t right = list->size - 1;
+
+ while (left <= right) {
+ size_t mid = left + (right - left) / 2;
+
+ if (list->offsets[mid] == cursor) {
+ return ((pm_line_column_t) { ((int32_t) mid) + start_line, 0 });
+ }
+
+ if (list->offsets[mid] < cursor) {
+ left = mid + 1;
+ } else {
+ right = mid - 1;
+ }
+ }
+
+ return ((pm_line_column_t) {
+ .line = ((int32_t) left) + start_line - 1,
+ .column = cursor - list->offsets[left - 1]
+ });
+}
diff --git a/prism/line_offset_list.h b/prism/line_offset_list.h
new file mode 100644
index 0000000000..848bc49139
--- /dev/null
+++ b/prism/line_offset_list.h
@@ -0,0 +1,61 @@
+/**
+ * @file line_offset_list.h
+ *
+ * A list of byte offsets of newlines in a string.
+ *
+ * When compiling the syntax tree, it's necessary to know the line and column
+ * of many nodes. This is necessary to support things like error messages,
+ * tracepoints, etc.
+ *
+ * It's possible that we could store the start line, start column, end line, and
+ * end column on every node in addition to the offsets that we already store,
+ * but that would be quite a lot of memory overhead.
+ */
+#ifndef PRISM_LINE_OFFSET_LIST_H
+#define PRISM_LINE_OFFSET_LIST_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * A list of offsets of the start of lines in a string. The offsets are assumed
+ * to be sorted/inserted in ascending order.
+ */
+typedef struct {
+ /** The number of offsets in the list. */
+ size_t size;
+
+ /** The capacity of the list that has been allocated. */
+ size_t capacity;
+
+ /** The list of offsets. */
+ uint32_t *offsets;
+} pm_line_offset_list_t;
+
+/**
+ * A line and column in a string.
+ */
+typedef struct {
+ /** The line number. */
+ int32_t line;
+
+ /** The column in bytes. */
+ uint32_t column;
+} pm_line_column_t;
+
+/**
+ * Returns the line and column of the given offset. If the offset is not in the
+ * list, the line and column of the closest offset less than the given offset
+ * are returned.
+ *
+ * @param list The list to search.
+ * @param cursor The offset to search for.
+ * @param start_line The line to start counting from.
+ * @returns The line and column of the given offset.
+ */
+PRISM_EXPORTED_FUNCTION pm_line_column_t pm_line_offset_list_line_column(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/list.c b/prism/list.c
new file mode 100644
index 0000000000..8d4cd1be94
--- /dev/null
+++ b/prism/list.c
@@ -0,0 +1,24 @@
+#include "prism/internal/list.h"
+
+/**
+ * Returns the size of the list.
+ */
+size_t
+pm_list_size(pm_list_t *list) {
+ return list->size;
+}
+
+/**
+ * Append a node to the given list.
+ */
+void
+pm_list_append(pm_list_t *list, pm_list_node_t *node) {
+ if (list->head == NULL) {
+ list->head = node;
+ } else {
+ list->tail->next = node;
+ }
+
+ list->tail = node;
+ list->size++;
+}
diff --git a/prism/magic_comments.h b/prism/magic_comments.h
new file mode 100644
index 0000000000..c9d6b600e8
--- /dev/null
+++ b/prism/magic_comments.h
@@ -0,0 +1,35 @@
+/**
+ * @file magic_comments.h
+ *
+ * Types and functions related to magic comments found during parsing.
+ */
+#ifndef PRISM_MAGIC_COMMENTS_H
+#define PRISM_MAGIC_COMMENTS_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+
+#include <stddef.h>
+
+/** An opaque pointer to a magic comment found while parsing. */
+typedef struct pm_magic_comment_t pm_magic_comment_t;
+
+/**
+ * Returns the location of the key associated with the given magic comment.
+ *
+ * @param magic_comment the magic comment whose key location we want to get
+ * @returns the location of the key associated with the given magic comment
+ */
+PRISM_EXPORTED_FUNCTION pm_location_t pm_magic_comment_key(const pm_magic_comment_t *magic_comment) PRISM_NONNULL(1);
+
+/**
+ * Returns the location of the value associated with the given magic comment.
+ *
+ * @param magic_comment the magic comment whose value location we want to get
+ * @returns the location of the value associated with the given magic comment
+ */
+PRISM_EXPORTED_FUNCTION pm_location_t pm_magic_comment_value(const pm_magic_comment_t *magic_comment) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/memchr.c b/prism/memchr.c
new file mode 100644
index 0000000000..900e6245b7
--- /dev/null
+++ b/prism/memchr.c
@@ -0,0 +1,37 @@
+#include "prism/internal/memchr.h"
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+#define TRAILING_BYTE_MINIMUM 0x40
+
+/**
+ * We need to roll our own memchr to handle cases where the encoding changes and
+ * we need to search for a character in a buffer that could be the trailing byte
+ * of a multibyte character.
+ */
+const void *
+pm_memchr(const void *memory, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding) {
+ if (encoding_changed && encoding->multibyte && character >= TRAILING_BYTE_MINIMUM) {
+ const uint8_t *source = (const uint8_t *) memory;
+ size_t index = 0;
+
+ while (index < number) {
+ if (source[index] == character) {
+ return (void *) (source + index);
+ }
+
+ size_t width = encoding->char_width(source + index, (ptrdiff_t) (number - index));
+ if (width == 0) {
+ return NULL;
+ }
+
+ index += width;
+ }
+
+ return NULL;
+ } else {
+ return memchr(memory, character, number);
+ }
+}
diff --git a/prism/node.h b/prism/node.h
new file mode 100644
index 0000000000..75bc3c9b2d
--- /dev/null
+++ b/prism/node.h
@@ -0,0 +1,94 @@
+/**
+ * @file node.h
+ *
+ * Functions related to nodes in the AST.
+ */
+#ifndef PRISM_NODE_H
+#define PRISM_NODE_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+
+/**
+ * Loop through each node in the node list, writing each node to the given
+ * pm_node_t pointer.
+ */
+#define PM_NODE_LIST_FOREACH(list, index, node) \
+ for (size_t index = 0; index < (list)->size && ((node) = (list)->nodes[index]); index++)
+
+/**
+ * Returns a string representation of the given node type.
+ *
+ * @param node_type The node type to convert to a string.
+ * @returns A string representation of the given node type.
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_node_type(pm_node_type_t node_type);
+
+/**
+ * Visit each of the nodes in this subtree using the given visitor callback. The
+ * callback function will be called for each node in the subtree. If it returns
+ * false, then that node's children will not be visited. If it returns true,
+ * then the children will be visited. The data parameter is treated as an opaque
+ * pointer and is passed to the visitor callback for consumers to use as they
+ * see fit.
+ *
+ * As an example:
+ *
+ * ```c
+ * #include "prism.h"
+ *
+ * bool visit(const pm_node_t *node, void *data) {
+ * size_t *indent = (size_t *) data;
+ * for (size_t i = 0; i < *indent * 2; i++) putc(' ', stdout);
+ * printf("%s\n", pm_node_type(node->type));
+ *
+ * size_t next_indent = *indent + 1;
+ * size_t *next_data = &next_indent;
+ * pm_visit_child_nodes(node, visit, next_data);
+ *
+ * return false;
+ * }
+ *
+ * int main(void) {
+ * const char *source = "1 + 2; 3 + 4";
+ * size_t size = strlen(source);
+ *
+ * pm_arena_t *arena = pm_arena_new();
+ * pm_options_t *options = pm_options_new();
+ *
+ * pm_parser_t *parser = pm_parser_new(arena, (const uint8_t *) source, size, options);
+ *
+ * size_t indent = 0;
+ * pm_node_t *node = pm_parse(parser);
+ *
+ * size_t *data = &indent;
+ * pm_visit_node(node, visit, data);
+ *
+ * pm_parser_free(parser);
+ * pm_options_free(options);
+ * pm_arena_free(arena);
+ *
+ * return EXIT_SUCCESS;
+ * }
+ * ```
+ *
+ * @param node The root node to start visiting from.
+ * @param visitor The callback to call for each node in the subtree.
+ * @param data An opaque pointer that is passed to the visitor callback.
+ */
+PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data) PRISM_NONNULL(1);
+
+/**
+ * Visit the children of the given node with the given callback. This is the
+ * default behavior for walking the tree that is called from pm_visit_node if
+ * the callback returns true.
+ *
+ * @param node The node to visit the children of.
+ * @param visitor The callback to call for each child node.
+ * @param data An opaque pointer that is passed to the visitor callback.
+ */
+PRISM_EXPORTED_FUNCTION void pm_visit_child_nodes(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/options.c b/prism/options.c
new file mode 100644
index 0000000000..b589865a2a
--- /dev/null
+++ b/prism/options.c
@@ -0,0 +1,420 @@
+#include "prism/internal/options.h"
+
+#include "prism/compiler/inline.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/char.h"
+#include "prism/internal/stringy.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Allocate a new options struct. If the options struct cannot be allocated,
+ * this function aborts the process.
+ */
+pm_options_t *
+pm_options_new(void) {
+ pm_options_t *options = xcalloc(1, sizeof(pm_options_t));
+ if (options == NULL) abort();
+ return options;
+}
+
+/**
+ * Free the internal memory associated with the options.
+ */
+void
+pm_options_cleanup(pm_options_t *options) {
+ pm_string_cleanup(&options->filepath);
+ pm_string_cleanup(&options->encoding);
+
+ for (size_t scope_index = 0; scope_index < options->scopes_count; scope_index++) {
+ pm_options_scope_t *scope = &options->scopes[scope_index];
+
+ for (size_t local_index = 0; local_index < scope->locals_count; local_index++) {
+ pm_string_cleanup(&scope->locals[local_index]);
+ }
+
+ xfree_sized(scope->locals, scope->locals_count * sizeof(pm_string_t));
+ }
+
+ xfree_sized(options->scopes, options->scopes_count * sizeof(pm_options_scope_t));
+}
+
+/**
+ * Free both the held memory of the given options struct and the struct itself.
+ *
+ * @param options The options struct to free.
+ */
+void
+pm_options_free(pm_options_t *options) {
+ pm_options_cleanup(options);
+ xfree_sized(options, sizeof(pm_options_t));
+}
+
+/**
+ * Set the shebang callback option on the given options struct.
+ */
+void
+pm_options_shebang_callback_set(pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data) {
+ options->shebang_callback = shebang_callback;
+ options->shebang_callback_data = shebang_callback_data;
+}
+
+/**
+ * Get the filepath option on the given options struct.
+ */
+const pm_string_t *
+pm_options_filepath(const pm_options_t *options) {
+ return &options->filepath;
+}
+
+/**
+ * Set the filepath option on the given options struct.
+ */
+void
+pm_options_filepath_set(pm_options_t *options, const char *filepath) {
+ pm_string_constant_init(&options->filepath, filepath, strlen(filepath));
+}
+
+/**
+ * Set the encoding option on the given options struct.
+ */
+void
+pm_options_encoding_set(pm_options_t *options, const char *encoding) {
+ pm_string_constant_init(&options->encoding, encoding, strlen(encoding));
+}
+
+/**
+ * Set the encoding_locked option on the given options struct.
+ */
+void
+pm_options_encoding_locked_set(pm_options_t *options, bool encoding_locked) {
+ options->encoding_locked = encoding_locked;
+}
+
+/**
+ * Set the line option on the given options struct.
+ */
+void
+pm_options_line_set(pm_options_t *options, int32_t line) {
+ options->line = line;
+}
+
+/**
+ * Set the frozen string literal option on the given options struct.
+ */
+void
+pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal) {
+ options->frozen_string_literal = frozen_string_literal ? PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED : PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED;
+}
+
+/**
+ * Sets the command line option on the given options struct.
+ */
+void
+pm_options_command_line_set(pm_options_t *options, uint8_t command_line) {
+ options->command_line = command_line;
+}
+
+/**
+ * Checks if the given slice represents a number.
+ */
+static PRISM_INLINE bool
+is_number(const char *string, size_t length) {
+ return pm_strspn_decimal_digit((const uint8_t *) string, (ptrdiff_t) length) == length;
+}
+
+/**
+ * Set the version option on the given options struct by parsing the given
+ * string. If the string contains an invalid option, this returns false.
+ * Otherwise, it returns true.
+ */
+bool
+pm_options_version_set(pm_options_t *options, const char *version, size_t length) {
+ if (version == NULL) {
+ options->version = PM_OPTIONS_VERSION_LATEST;
+ return true;
+ }
+
+ if (length == 3) {
+ if (strncmp(version, "3.3", 3) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
+ return true;
+ }
+
+ if (strncmp(version, "3.4", 3) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
+ return true;
+ }
+
+ if (strncmp(version, "3.5", 3) == 0 || strncmp(version, "4.0", 3) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
+ return true;
+ }
+
+ if (strncmp(version, "4.1", 3) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_4_1;
+ return true;
+ }
+
+ return false;
+ }
+
+ if (length >= 4 && is_number(version + 4, length - 4)) {
+ if (strncmp(version, "3.3.", 4) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
+ return true;
+ }
+
+ if (strncmp(version, "3.4.", 4) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
+ return true;
+ }
+
+ if (strncmp(version, "3.5.", 4) == 0 || strncmp(version, "4.0.", 4) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
+ return true;
+ }
+
+ if (strncmp(version, "4.1.", 4) == 0) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_4_1;
+ return true;
+ }
+ }
+
+ if (length == 6) {
+ if (strncmp(version, "latest", 6) == 0) {
+ options->version = PM_OPTIONS_VERSION_LATEST;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Set the version option on the given options struct to the lowest version of
+ * Ruby that prism supports.
+ */
+void
+pm_options_version_set_lowest(pm_options_t *options) {
+ options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
+}
+
+/**
+ * Set the version option on the given options struct to the highest version of
+ * Ruby that prism supports.
+ */
+void
+pm_options_version_set_highest(pm_options_t *options) {
+ options->version = PM_OPTIONS_VERSION_LATEST;
+}
+
+/**
+ * Set the main script option on the given options struct.
+ */
+void
+pm_options_main_script_set(pm_options_t *options, bool main_script) {
+ options->main_script = main_script;
+}
+
+/**
+ * Set the partial script option on the given options struct.
+ */
+void
+pm_options_partial_script_set(pm_options_t *options, bool partial_script) {
+ options->partial_script = partial_script;
+}
+
+/**
+ * Get the freeze option on the given options struct.
+ */
+bool
+pm_options_freeze(const pm_options_t *options) {
+ return options->freeze;
+}
+
+/**
+ * Set the freeze option on the given options struct.
+ */
+void
+pm_options_freeze_set(pm_options_t *options, bool freeze) {
+ options->freeze = freeze;
+}
+
+// For some reason, GCC analyzer thinks we're leaking allocated scopes and
+// locals here, even though we definitely aren't. This is a false positive.
+// Ideally we wouldn't need to suppress this.
+#if defined(__GNUC__) && (__GNUC__ >= 10)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
+#endif
+
+/**
+ * Allocate and zero out the scopes array on the given options struct.
+ */
+bool
+pm_options_scopes_init(pm_options_t *options, size_t scopes_count) {
+ options->scopes_count = scopes_count;
+ options->scopes = xcalloc(scopes_count, sizeof(pm_options_scope_t));
+ return options->scopes != NULL;
+}
+
+/**
+ * Return a constant pointer to the scope at the given index within the given
+ * options.
+ */
+const pm_options_scope_t *
+pm_options_scope(const pm_options_t *options, size_t index) {
+ return &options->scopes[index];
+}
+
+/**
+ * Return a mutable pointer to the scope at the given index within the given
+ * options.
+ */
+pm_options_scope_t *
+pm_options_scope_mut(pm_options_t *options, size_t index) {
+ return &options->scopes[index];
+}
+
+/**
+ * Create a new options scope struct. This will hold a set of locals that are in
+ * scope surrounding the code that is being parsed.
+ */
+void
+pm_options_scope_init(pm_options_scope_t *scope, size_t locals_count) {
+ scope->locals_count = locals_count;
+ scope->locals = xcalloc(locals_count, sizeof(pm_string_t));
+ scope->forwarding = PM_OPTIONS_SCOPE_FORWARDING_NONE;
+ if (scope->locals == NULL) abort();
+}
+
+/**
+ * Return a constant pointer to the local at the given index within the given
+ * scope.
+ */
+const pm_string_t *
+pm_options_scope_local(const pm_options_scope_t *scope, size_t index) {
+ return &scope->locals[index];
+}
+
+/**
+ * Return a mutable pointer to the local at the given index within the given
+ * scope.
+ */
+pm_string_t *
+pm_options_scope_local_mut(pm_options_scope_t *scope, size_t index) {
+ return &scope->locals[index];
+}
+
+/**
+ * Set the forwarding option on the given scope struct.
+ */
+void
+pm_options_scope_forwarding_set(pm_options_scope_t *scope, uint8_t forwarding) {
+ scope->forwarding = forwarding;
+}
+
+/**
+ * Read a 32-bit unsigned integer from a pointer. This function is used to read
+ * the options that are passed into the parser from the Ruby implementation. It
+ * handles aligned and unaligned reads.
+ */
+static uint32_t
+pm_options_read_u32(const char *data) {
+ if (((uintptr_t) data) % sizeof(uint32_t) == 0) {
+ return *((uint32_t *) data);
+ } else {
+ uint32_t value;
+ memcpy(&value, data, sizeof(uint32_t));
+ return value;
+ }
+}
+
+/**
+ * Read a 32-bit signed integer from a pointer. This function is used to read
+ * the options that are passed into the parser from the Ruby implementation. It
+ * handles aligned and unaligned reads.
+ */
+static int32_t
+pm_options_read_s32(const char *data) {
+ if (((uintptr_t) data) % sizeof(int32_t) == 0) {
+ return *((int32_t *) data);
+ } else {
+ int32_t value;
+ memcpy(&value, data, sizeof(int32_t));
+ return value;
+ }
+}
+
+/**
+ * Deserialize an options struct from the given binary string. This is used to
+ * pass options to the parser from an FFI call so that consumers of the library
+ * from an FFI perspective don't have to worry about the structure of our
+ * options structs. Since the source of these calls will be from Ruby
+ * implementation internals we assume it is from a trusted source.
+ */
+void
+pm_options_read(pm_options_t *options, const char *data) {
+ options->line = 1; // default
+ if (data == NULL) return;
+
+ uint32_t filepath_length = pm_options_read_u32(data);
+ data += 4;
+
+ if (filepath_length > 0) {
+ pm_string_constant_init(&options->filepath, data, filepath_length);
+ data += filepath_length;
+ }
+
+ options->line = pm_options_read_s32(data);
+ data += 4;
+
+ uint32_t encoding_length = pm_options_read_u32(data);
+ data += 4;
+
+ if (encoding_length > 0) {
+ pm_string_constant_init(&options->encoding, data, encoding_length);
+ data += encoding_length;
+ }
+
+ options->frozen_string_literal = (int8_t) *data++;
+ options->command_line = (uint8_t) *data++;
+ options->version = (pm_options_version_t) *data++;
+ options->encoding_locked = ((uint8_t) *data++) > 0;
+ options->main_script = ((uint8_t) *data++) > 0;
+ options->partial_script = ((uint8_t) *data++) > 0;
+ options->freeze = ((uint8_t) *data++) > 0;
+
+ uint32_t scopes_count = pm_options_read_u32(data);
+ data += 4;
+
+ if (scopes_count > 0) {
+ if (!pm_options_scopes_init(options, scopes_count)) return;
+
+ for (size_t scope_index = 0; scope_index < scopes_count; scope_index++) {
+ uint32_t locals_count = pm_options_read_u32(data);
+ data += 4;
+
+ pm_options_scope_t *scope = &options->scopes[scope_index];
+ pm_options_scope_init(scope, locals_count);
+
+ uint8_t forwarding = (uint8_t) *data++;
+ pm_options_scope_forwarding_set(&options->scopes[scope_index], forwarding);
+
+ for (size_t local_index = 0; local_index < locals_count; local_index++) {
+ uint32_t local_length = pm_options_read_u32(data);
+ data += 4;
+
+ pm_string_constant_init(&scope->locals[local_index], data, local_length);
+ data += local_length;
+ }
+ }
+ }
+}
+
+#if defined(__GNUC__) && (__GNUC__ >= 10)
+#pragma GCC diagnostic pop
+#endif
diff --git a/prism/options.h b/prism/options.h
new file mode 100644
index 0000000000..0f5d7529b1
--- /dev/null
+++ b/prism/options.h
@@ -0,0 +1,319 @@
+/**
+ * @file options.h
+ *
+ * The options that can be passed to parsing.
+ */
+#ifndef PRISM_OPTIONS_H
+#define PRISM_OPTIONS_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/stringy.h"
+
+#include <stdbool.h>
+#include <stddef.h>
+
+/**
+ * A scope of locals surrounding the code that is being parsed.
+ */
+typedef struct pm_options_scope_t pm_options_scope_t;
+
+/**
+ * The options that can be passed to the parser.
+ */
+typedef struct pm_options_t pm_options_t;
+
+/**
+ * String literals should not be frozen.
+ */
+#define PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED ((int8_t) -1)
+
+/**
+ * String literals may be frozen or mutable depending on the implementation
+ * default.
+ */
+#define PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET ((int8_t) 0)
+
+/**
+ * String literals should be made frozen.
+ */
+#define PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED ((int8_t) 1)
+
+/** The default value for parameters. */
+static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_NONE = 0x0;
+
+/** When the scope is forwarding with the * parameter. */
+static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_POSITIONALS = 0x1;
+
+/** When the scope is forwarding with the ** parameter. */
+static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_KEYWORDS = 0x2;
+
+/** When the scope is forwarding with the & parameter. */
+static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_BLOCK = 0x4;
+
+/** When the scope is forwarding with the ... parameter. */
+static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_ALL = 0x8;
+
+/**
+ * The callback called when additional switches are found in a shebang comment
+ * that need to be processed by the runtime.
+ *
+ * @param options The options struct that may be updated by this callback.
+ * Certain fields will be checked for changes, specifically encoding,
+ * command_line, and frozen_string_literal.
+ * @param source The source of the shebang comment.
+ * @param length The length of the source.
+ * @param shebang_callback_data Any additional data that should be passed along
+ * to the callback.
+ */
+typedef void (*pm_options_shebang_callback_t)(pm_options_t *options, const uint8_t *source, size_t length, void *shebang_callback_data);
+
+/**
+ * A bit representing whether or not the command line -a option was set. -a
+ * splits the input line $_ into $F.
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_A = 0x1;
+
+/**
+ * A bit representing whether or not the command line -e option was set. -e
+ * allow the user to specify a script to be executed. This is necessary for
+ * prism to know because certain warnings are not generated when -e is used.
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_E = 0x2;
+
+/**
+ * A bit representing whether or not the command line -l option was set. -l
+ * chomps the input line by default.
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_L = 0x4;
+
+/**
+ * A bit representing whether or not the command line -n option was set. -n
+ * wraps the script in a while gets loop.
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_N = 0x8;
+
+/**
+ * A bit representing whether or not the command line -p option was set. -p
+ * prints the value of $_ at the end of each loop.
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_P = 0x10;
+
+/**
+ * A bit representing whether or not the command line -x option was set. -x
+ * searches the input file for a shebang that includes "ruby".
+ */
+static const uint8_t PM_OPTIONS_COMMAND_LINE_X = 0x20;
+
+/**
+ * Allocate a new options struct. If the options struct cannot be allocated,
+ * this function aborts the process.
+ *
+ * @returns A new options struct with default values. It is the responsibility
+ * of the caller to free this struct using pm_options_free().
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_options_t * pm_options_new(void);
+
+/**
+ * Free both the held memory of the given options struct and the struct itself.
+ *
+ * @param options The options struct to free.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Set the shebang callback option on the given options struct.
+ *
+ * @param options The options struct to set the shebang callback on.
+ * @param shebang_callback The shebang callback to set.
+ * @param shebang_callback_data Any additional data that should be passed along
+ * to the callback.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set(pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data) PRISM_NONNULL(1);
+
+/**
+ * Get the filepath option on the given options struct.
+ *
+ * @param options The options struct to get the filepath from.
+ * @returns The filepath.
+ */
+PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_filepath(const pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Set the filepath option on the given options struct.
+ *
+ * @param options The options struct to set the filepath on.
+ * @param filepath The filepath to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, const char *filepath) PRISM_NONNULL(1);
+
+/**
+ * Set the line option on the given options struct.
+ *
+ * @param options The options struct to set the line on.
+ * @param line The line to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t line) PRISM_NONNULL(1);
+
+/**
+ * Set the encoding option on the given options struct.
+ *
+ * @param options The options struct to set the encoding on.
+ * @param encoding The encoding to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, const char *encoding) PRISM_NONNULL(1);
+
+/**
+ * Set the encoding_locked option on the given options struct.
+ *
+ * @param options The options struct to set the encoding_locked value on.
+ * @param encoding_locked The encoding_locked value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set(pm_options_t *options, bool encoding_locked) PRISM_NONNULL(1);
+
+/**
+ * Set the frozen string literal option on the given options struct.
+ *
+ * @param options The options struct to set the frozen string literal value on.
+ * @param frozen_string_literal The frozen string literal value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal) PRISM_NONNULL(1);
+
+/**
+ * Sets the command line option on the given options struct.
+ *
+ * @param options The options struct to set the command line option on.
+ * @param command_line The command_line value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options, uint8_t command_line) PRISM_NONNULL(1);
+
+/**
+ * Set the version option on the given options struct by parsing the given
+ * string. If the string contains an invalid option, this returns false.
+ * Otherwise, it returns true.
+ *
+ * @param options The options struct to set the version on.
+ * @param version The version to set.
+ * @param length The length of the version string.
+ * @returns Whether or not the version was parsed successfully.
+ */
+PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length) PRISM_NONNULL(1);
+
+/**
+ * Set the version option on the given options struct to the lowest version of
+ * Ruby that prism supports.
+ *
+ * @param options The options struct to set the version on.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_version_set_lowest(pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Set the version option on the given options struct to the highest version of
+ * Ruby that prism supports.
+ *
+ * @param options The options struct to set the version on.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_version_set_highest(pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Set the main script option on the given options struct.
+ *
+ * @param options The options struct to set the main script value on.
+ * @param main_script The main script value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_main_script_set(pm_options_t *options, bool main_script) PRISM_NONNULL(1);
+
+/**
+ * Set the partial script option on the given options struct.
+ *
+ * @param options The options struct to set the partial script value on.
+ * @param partial_script The partial script value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_partial_script_set(pm_options_t *options, bool partial_script) PRISM_NONNULL(1);
+
+/**
+ * Get the freeze option on the given options struct.
+ *
+ * @param options The options struct to get the freeze value from.
+ * @returns The freeze value.
+ */
+PRISM_EXPORTED_FUNCTION bool pm_options_freeze(const pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Set the freeze option on the given options struct.
+ *
+ * @param options The options struct to set the freeze value on.
+ * @param freeze The freeze value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_freeze_set(pm_options_t *options, bool freeze) PRISM_NONNULL(1);
+
+/**
+ * Allocate and zero out the scopes array on the given options struct.
+ *
+ * @param options The options struct to initialize the scopes array on.
+ * @param scopes_count The number of scopes to allocate.
+ * @returns Whether or not the scopes array was initialized successfully.
+ */
+PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init(pm_options_t *options, size_t scopes_count) PRISM_NONNULL(1);
+
+/**
+ * Return a constant pointer to the scope at the given index within the given
+ * options.
+ *
+ * @param options The options struct to get the scope from.
+ * @param index The index of the scope to get.
+ * @returns A constant pointer to the scope at the given index.
+ */
+PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope(const pm_options_t *options, size_t index) PRISM_NONNULL(1);
+
+/**
+ * Return a mutable pointer to the scope at the given index within the given
+ * options.
+ *
+ * @param options The options struct to get the scope from.
+ * @param index The index of the scope to get.
+ * @returns A mutable pointer to the scope at the given index.
+ */
+PRISM_EXPORTED_FUNCTION pm_options_scope_t * pm_options_scope_mut(pm_options_t *options, size_t index) PRISM_NONNULL(1);
+
+/**
+ * Create a new options scope struct. This will hold a set of locals that are in
+ * scope surrounding the code that is being parsed. If the scope was unable to
+ * allocate its locals, this function will abort the process.
+ *
+ * @param scope The scope struct to initialize.
+ * @param locals_count The number of locals to allocate.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_scope_init(pm_options_scope_t *scope, size_t locals_count) PRISM_NONNULL(1);
+
+/**
+ * Return a constant pointer to the local at the given index within the given
+ * scope.
+ *
+ * @param scope The scope struct to get the local from.
+ * @param index The index of the local to get.
+ * @returns A constant pointer to the local at the given index.
+ */
+PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local(const pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
+
+/**
+ * Return a mutable pointer to the local at the given index within the given
+ * scope.
+ *
+ * @param scope The scope struct to get the local from.
+ * @param index The index of the local to get.
+ * @returns A mutable pointer to the local at the given index.
+ */
+PRISM_EXPORTED_FUNCTION pm_string_t * pm_options_scope_local_mut(pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
+
+/**
+ * Set the forwarding option on the given scope struct.
+ *
+ * @param scope The scope struct to set the forwarding on.
+ * @param forwarding The forwarding value to set.
+ */
+PRISM_EXPORTED_FUNCTION void pm_options_scope_forwarding_set(pm_options_scope_t *scope, uint8_t forwarding) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/parser.c b/prism/parser.c
new file mode 100644
index 0000000000..415cd31984
--- /dev/null
+++ b/prism/parser.c
@@ -0,0 +1,302 @@
+#include "prism/internal/parser.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/comments.h"
+#include "prism/internal/diagnostic.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/magic_comments.h"
+
+#include <stdlib.h>
+
+/**
+ * Register a callback that will be called whenever prism changes the encoding
+ * it is using to parse based on the magic comment.
+ */
+void
+pm_parser_encoding_changed_callback_set(pm_parser_t *parser, pm_encoding_changed_callback_t callback) {
+ parser->encoding_changed_callback = callback;
+}
+
+/**
+ * Register a callback that will be called whenever a token is lexed.
+ */
+void
+pm_parser_lex_callback_set(pm_parser_t *parser, pm_lex_callback_t callback, void *data) {
+ parser->lex_callback.callback = callback;
+ parser->lex_callback.data = data;
+}
+
+/**
+ * Returns the opaque data that is passed to the lex callback when it is called.
+ */
+void *
+pm_parser_lex_callback_data(const pm_parser_t *parser) {
+ return parser->lex_callback.data;
+}
+
+/**
+ * Returns the raw pointer to the start of the source that is being parsed.
+ */
+const uint8_t *
+pm_parser_start(const pm_parser_t *parser) {
+ return parser->start;
+}
+
+/**
+ * Returns the raw pointer to the end of the source that is being parsed.
+ */
+const uint8_t *
+pm_parser_end(const pm_parser_t *parser) {
+ return parser->end;
+}
+
+/**
+ * Returns the line that the parser was considered to have started on.
+ *
+ * @param parser the parser whose start line we want to get
+ * @return the line that the parser was considered to have started on
+ */
+int32_t
+pm_parser_start_line(const pm_parser_t *parser) {
+ return parser->start_line;
+}
+
+/**
+ * Returns the name of the encoding that is being used to parse the source.
+ */
+const char *
+pm_parser_encoding_name(const pm_parser_t *parser) {
+ return parser->encoding->name;
+}
+
+/**
+ * Returns the width of the character at the given pointer in the encoding that
+ * is being used to parse the source.
+ */
+size_t
+pm_parser_encoding_char_width(const pm_parser_t *parser, const uint8_t *start, ptrdiff_t remaining) {
+ return parser->encoding->char_width(start, remaining);
+}
+
+/**
+ * Returns whether or not the parser is using the US-ASCII encoding.
+ */
+bool
+pm_parser_encoding_us_ascii(const pm_parser_t *parser) {
+ return parser->encoding == PM_ENCODING_US_ASCII_ENTRY;
+}
+
+/**
+ * Returns the filepath that is being used to parse the source.
+ */
+const pm_string_t *
+pm_parser_filepath(const pm_parser_t *parser) {
+ return &parser->filepath;
+}
+
+/**
+ * Find a constant in the parser's constant pool. Returns the id of the
+ * constant, or 0 if the constant is not found.
+ */
+pm_constant_id_t
+pm_parser_constant_find(const pm_parser_t *parser, const uint8_t *start, size_t length) {
+ return pm_constant_pool_find(&parser->constant_pool, start, length);
+}
+
+/**
+ * Returns the frozen string literal value of the parser.
+ */
+int8_t
+pm_parser_frozen_string_literal(const pm_parser_t *parser) {
+ return parser->frozen_string_literal;
+}
+
+/**
+ * Returns the line offsets that are associated with the given parser.
+ *
+ * @param parser the parser whose line offsets we want to get
+ * @return the line offsets that are associated with the given parser
+ */
+const pm_line_offset_list_t *
+pm_parser_line_offsets(const pm_parser_t *parser) {
+ return &parser->line_offsets;
+}
+
+/**
+ * Returns the location of the __DATA__ section that is associated with the
+ * given parser, if it exists.
+ */
+const pm_location_t *
+pm_parser_data_loc(const pm_parser_t *parser) {
+ return &parser->data_loc;
+}
+
+/**
+ * Returns whether the given parser is continuable, meaning that it could become
+ * valid if more input were appended, as opposed to being definitively invalid.
+ */
+bool
+pm_parser_continuable(const pm_parser_t *parser) {
+ return parser->continuable;
+}
+
+/**
+ * Returns the lex state of the parser. Note that this is an internal detail,
+ * and we are purposefully not returning an instance of the internal enum that
+ * we use to track this. This is only exposed because we need it for some very
+ * niche use cases. Most consumers should avoid this function.
+ */
+int
+pm_parser_lex_state(const pm_parser_t *parser) {
+ return (int) parser->lex_state;
+}
+
+/**
+ * Returns the location associated with the given comment.
+ */
+pm_location_t
+pm_comment_location(const pm_comment_t *comment) {
+ return comment->location;
+}
+
+/**
+ * Returns the type associated with the given comment.
+ */
+pm_comment_type_t
+pm_comment_type(const pm_comment_t *comment) {
+ return comment->type;
+}
+
+/**
+ * Returns the number of comments associated with the given parser.
+ */
+size_t
+pm_parser_comments_size(const pm_parser_t *parser) {
+ return parser->comment_list.size;
+}
+
+/**
+ * Iterates over the comments associated with the given parser and calls the
+ * given callback for each comment.
+ */
+void
+pm_parser_comments_each(const pm_parser_t *parser, pm_comment_callback_t callback, void *data) {
+ const pm_list_node_t *current = parser->comment_list.head;
+ while (current != NULL) {
+ const pm_comment_t *comment = (const pm_comment_t *) current;
+ callback(comment, data);
+ current = current->next;
+ }
+}
+
+/**
+ * Returns the location associated with the given magic comment key.
+ */
+pm_location_t
+pm_magic_comment_key(const pm_magic_comment_t *magic_comment) {
+ return magic_comment->key;
+}
+
+/**
+ * Returns the location associated with the given magic comment value.
+ */
+pm_location_t
+pm_magic_comment_value(const pm_magic_comment_t *magic_comment) {
+ return magic_comment->value;
+}
+
+/**
+ * Returns the number of magic comments associated with the given parser.
+ */
+size_t
+pm_parser_magic_comments_size(const pm_parser_t *parser) {
+ return parser->magic_comment_list.size;
+}
+
+/**
+ * Iterates over the magic comments associated with the given parser and calls
+ * the given callback for each magic comment.
+ */
+void
+pm_parser_magic_comments_each(const pm_parser_t *parser, pm_magic_comment_callback_t callback, void *data) {
+ const pm_list_node_t *current = parser->magic_comment_list.head;
+ while (current != NULL) {
+ const pm_magic_comment_t *magic_comment = (const pm_magic_comment_t *) current;
+ callback(magic_comment, data);
+ current = current->next;
+ }
+}
+
+/**
+ * Returns the number of errors associated with the given parser.
+ */
+size_t
+pm_parser_errors_size(const pm_parser_t *parser) {
+ return parser->error_list.size;
+}
+
+/**
+ * Returns the number of warnings associated with the given parser.
+ */
+size_t
+pm_parser_warnings_size(const pm_parser_t *parser) {
+ return parser->warning_list.size;
+}
+
+static inline void
+pm_parser_diagnostics_each(const pm_list_t *list, pm_diagnostic_callback_t callback, void *data) {
+ const pm_list_node_t *current = list->head;
+ while (current != NULL) {
+ const pm_diagnostic_t *diagnostic = (const pm_diagnostic_t *) current;
+ callback(diagnostic, data);
+ current = current->next;
+ }
+}
+
+/**
+ * Iterates over the errors associated with the given parser and calls the
+ * given callback for each error.
+ */
+void
+pm_parser_errors_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) {
+ pm_parser_diagnostics_each(&parser->error_list, callback, data);
+}
+
+/**
+ * Iterates over the warnings associated with the given parser and calls the
+ * given callback for each warning.
+ */
+void
+pm_parser_warnings_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) {
+ pm_parser_diagnostics_each(&parser->warning_list, callback, data);
+}
+
+/**
+ * Returns the number of constants in the constant pool associated with the
+ * given parser.
+ */
+size_t
+pm_parser_constants_size(const pm_parser_t *parser) {
+ return parser->constant_pool.size;
+}
+
+/**
+ * Iterates over the constants in the constant pool associated with the given
+ * parser and calls the given callback for each constant.
+ */
+void
+pm_parser_constants_each(const pm_parser_t *parser, pm_constant_callback_t callback, void *data) {
+ for (uint32_t index = 0; index < parser->constant_pool.size; index++) {
+ const pm_constant_t *constant = &parser->constant_pool.constants[index];
+ callback(constant, data);
+ }
+}
+
+/**
+ * Returns a pointer to the constant at the given id in the constant pool
+ * associated with the given parser.
+ */
+const pm_constant_t *
+pm_parser_constant(const pm_parser_t *parser, pm_constant_id_t constant_id) {
+ return pm_constant_pool_id_to_constant(&parser->constant_pool, constant_id);
+}
diff --git a/prism/parser.h b/prism/parser.h
new file mode 100644
index 0000000000..2c8c4b3a7a
--- /dev/null
+++ b/prism/parser.h
@@ -0,0 +1,348 @@
+/**
+ * @file parser.h
+ *
+ * The parser used to parse Ruby source.
+ */
+#ifndef PRISM_PARSER_H
+#define PRISM_PARSER_H
+
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+#include "prism/comments.h"
+#include "prism/diagnostic.h"
+#include "prism/line_offset_list.h"
+#include "prism/magic_comments.h"
+#include "prism/options.h"
+
+/**
+ * The parser used to parse Ruby source.
+ */
+typedef struct pm_parser_t pm_parser_t;
+
+/**
+ * Allocate and initialize a parser with the given start and end pointers.
+ *
+ * @param arena The arena to use for all AST-lifetime allocations. It is caller-
+ * owned and must outlive the parser.
+ * @param source The source to parse.
+ * @param size The size of the source.
+ * @param options The optional options to use when parsing. These options must
+ * live for the whole lifetime of this parser.
+ * @returns The initialized parser. It is the responsibility of the caller to
+ * free the parser with `pm_parser_free()`.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_parser_t * pm_parser_new(pm_arena_t *arena, const uint8_t *source, size_t size, const pm_options_t *options) PRISM_NONNULL(1);
+
+/**
+ * Free both the memory held by the given parser and the parser itself.
+ *
+ * @param parser The parser to free.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * When the encoding that is being used to parse the source is changed by prism,
+ * we provide the ability here to call out to a user-defined function.
+ */
+typedef void (*pm_encoding_changed_callback_t)(pm_parser_t *parser);
+
+/**
+ * This is the callback that is called when a token is lexed. It is passed
+ * the opaque data pointer, the parser, and the token that was lexed.
+ */
+typedef void (*pm_lex_callback_t)(pm_parser_t *parser, pm_token_t *token, void *data);
+
+/**
+ * Register a callback that will be called whenever prism changes the encoding
+ * it is using to parse based on the magic comment.
+ *
+ * @param parser The parser to register the callback with.
+ * @param callback The callback to register.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_encoding_changed_callback_set(pm_parser_t *parser, pm_encoding_changed_callback_t callback) PRISM_NONNULL(1);
+
+/**
+ * Register a callback that will be called whenever a token is lexed.
+ *
+ * @param parser The parser to register the callback with.
+ * @param data The opaque data to pass to the callback when it is called.
+ * @param callback The callback to register.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_lex_callback_set(pm_parser_t *parser, pm_lex_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Returns the opaque data that is passed to the lex callback when it is called.
+ *
+ * @param parser The parser whose lex callback data we want to get.
+ * @returns The opaque data that is passed to the lex callback when it is called.
+ */
+PRISM_EXPORTED_FUNCTION void * pm_parser_lex_callback_data(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the raw pointer to the start of the source that is being parsed.
+ *
+ * @param parser the parser whose start pointer we want to get
+ * @returns the raw pointer to the start of the source that is being parsed
+ */
+PRISM_EXPORTED_FUNCTION const uint8_t * pm_parser_start(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the raw pointer to the end of the source that is being parsed.
+ *
+ * @param parser the parser whose end pointer we want to get
+ * @returns the raw pointer to the end of the source that is being parsed
+ */
+PRISM_EXPORTED_FUNCTION const uint8_t * pm_parser_end(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the line that the parser was considered to have started on.
+ *
+ * @param parser the parser whose start line we want to get
+ * @returns the line that the parser was considered to have started on
+ */
+PRISM_EXPORTED_FUNCTION int32_t pm_parser_start_line(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the name of the encoding that is being used to parse the source.
+ *
+ * @param parser the parser whose encoding name we want to get
+ * @returns the name of the encoding that is being used to parse the source
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_parser_encoding_name(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the width of the character at the given pointer in the encoding that
+ * is being used to parse the source.
+ *
+ * @param parser the parser whose encoding we want to use
+ * @param start a pointer to the start of the character
+ * @param remaining the number of bytes remaining in the source
+ * @returns the width of the character in bytes
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_encoding_char_width(const pm_parser_t *parser, const uint8_t *start, ptrdiff_t remaining) PRISM_NONNULL(1, 2);
+
+/**
+ * Returns whether or not the parser is using the US-ASCII encoding.
+ *
+ * @param parser the parser to check
+ * @returns true if the parser is using US-ASCII encoding, false otherwise
+ */
+PRISM_EXPORTED_FUNCTION bool pm_parser_encoding_us_ascii(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the filepath that is being used to parse the source.
+ *
+ * @param parser the parser whose filepath we want to get
+ * @returns a pointer to the filepath string
+ */
+PRISM_EXPORTED_FUNCTION const pm_string_t * pm_parser_filepath(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Find a constant in the parser's constant pool. Returns the id of the
+ * constant, or 0 if the constant is not found.
+ *
+ * @param parser the parser whose constant pool we want to search
+ * @param start a pointer to the start of the string to search for
+ * @param length the length of the string to search for
+ * @returns the id of the constant, or 0 if the constant is not found
+ */
+PRISM_EXPORTED_FUNCTION pm_constant_id_t pm_parser_constant_find(const pm_parser_t *parser, const uint8_t *start, size_t length) PRISM_NONNULL(1, 2);
+
+/**
+ * Returns the frozen string literal value of the parser, as determined by the
+ * frozen_string_literal magic comment or the option set on the parser.
+ *
+ * @param parser the parser whose frozen string literal value we want to get
+ * @returns -1 if disabled, 0 if unset, 1 if enabled
+ */
+PRISM_EXPORTED_FUNCTION int8_t pm_parser_frozen_string_literal(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the line offsets that are associated with the given parser.
+ *
+ * @param parser the parser whose line offsets we want to get
+ * @returns the line offsets that are associated with the given parser
+ */
+PRISM_EXPORTED_FUNCTION const pm_line_offset_list_t * pm_parser_line_offsets(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the location of the __DATA__ section that is associated with the
+ * given parser.
+ *
+ * @param parser the parser whose data location we want to get
+ * @returns the location of the __DATA__ section that is associated with the
+ * given parser. If it is unset, then the length will be set to 0.
+ */
+PRISM_EXPORTED_FUNCTION const pm_location_t * pm_parser_data_loc(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns whether the given parser is continuable, meaning that it could become
+ * valid if more input were appended, as opposed to being definitively invalid.
+ *
+ * @param parser the parser whose continuable status we want to get
+ * @returns whether the given parser is continuable
+ */
+PRISM_EXPORTED_FUNCTION bool pm_parser_continuable(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the lex state of the parser. Note that this is an internal detail,
+ * and we are purposefully not returning an instance of the internal enum that
+ * we use to track this. This is only exposed because we need it for some very
+ * niche use cases. Most consumers should avoid this function.
+ *
+ * @param parser the parser whose lex state we want to get
+ * @returns the lex state of the parser
+ */
+PRISM_EXPORTED_FUNCTION int pm_parser_lex_state(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the number of comments associated with the given parser.
+ *
+ * @param parser the parser whose comments we want to get the size of
+ * @returns the number of comments associated with the given parser
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_comments_size(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * A callback function that can be used to process comments found while parsing.
+ */
+typedef void (*pm_comment_callback_t)(const pm_comment_t *comment, void *data);
+
+/**
+ * Iterates over the comments associated with the given parser and calls the
+ * given callback for each comment.
+ *
+ * @param parser the parser whose comments we want to iterate over
+ * @param callback the callback function to call for each comment. This function
+ * will be passed a pointer to the comment and the data parameter passed to
+ * this function.
+ * @param data the data to pass to the callback function for each comment. This
+ * can be NULL if no data needs to be passed to the callback function.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_comments_each(const pm_parser_t *parser, pm_comment_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Returns the number of magic comments associated with the given parser.
+ *
+ * @param parser the parser whose magic comments we want to get the size of
+ * @returns the number of magic comments associated with the given parser
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_magic_comments_size(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * A callback function that can be used to process magic comments found while parsing.
+ */
+typedef void (*pm_magic_comment_callback_t)(const pm_magic_comment_t *magic_comment, void *data);
+
+/**
+ * Iterates over the magic comments associated with the given parser and calls the
+ * given callback for each magic comment.
+ *
+ * @param parser the parser whose magic comments we want to iterate over
+ * @param callback the callback function to call for each magic comment. This
+ * function will be passed a pointer to the magic comment and the data
+ * parameter passed to this function.
+ * @param data the data to pass to the callback function for each magic comment.
+ * This can be NULL if no data needs to be passed to the callback function.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_magic_comments_each(const pm_parser_t *parser, pm_magic_comment_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Returns the number of errors associated with the given parser.
+ *
+ * @param parser the parser whose errors we want to get the size of
+ * @returns the number of errors associated with the given parser
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_errors_size(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * Returns the number of warnings associated with the given parser.
+ *
+ * @param parser the parser whose warnings we want to get the size of
+ * @returns the number of warnings associated with the given parser
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_warnings_size(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * A callback function that can be used to process diagnostics found while
+ * parsing.
+ */
+typedef void (*pm_diagnostic_callback_t)(const pm_diagnostic_t *diagnostic, void *data);
+
+/**
+ * Iterates over the errors associated with the given parser and calls the
+ * given callback for each error.
+ *
+ * @param parser the parser whose errors we want to iterate over
+ * @param callback the callback function to call for each error. This function
+ * will be passed a pointer to the error and the data parameter passed to
+ * this function.
+ * @param data the data to pass to the callback function for each error. This
+ * can be NULL if no data needs to be passed to the callback function.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_errors_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Iterates over the warnings associated with the given parser and calls the
+ * given callback for each warning.
+ *
+ * @param parser the parser whose warnings we want to iterate over
+ * @param callback the callback function to call for each warning. This function
+ * will be passed a pointer to the warning and the data parameter passed to
+ * this function.
+ * @param data the data to pass to the callback function for each warning. This
+ * can be NULL if no data needs to be passed to the callback function.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_warnings_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Returns the number of constants in the constant pool associated with the
+ * given parser.
+ *
+ * @param parser the parser whose constant pool constants we want to get the
+ * size of
+ * @returns the number of constants in the constant pool associated with the
+ * given parser
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_parser_constants_size(const pm_parser_t *parser) PRISM_NONNULL(1);
+
+/**
+ * A callback function that can be used to process constants found while
+ * parsing.
+ */
+typedef void (*pm_constant_callback_t)(const pm_constant_t *constant, void *data);
+
+/**
+ * Iterates over the constants in the constant pool associated with the given
+ * parser and calls the given callback for each constant.
+ *
+ * @param parser the parser whose constants we want to iterate over
+ * @param callback the callback function to call for each constant. This function
+ * will be passed a pointer to the constant and the data parameter passed to
+ * this function.
+ * @param data the data to pass to the callback function for each constant. This
+ * can be NULL if no data needs to be passed to the callback function.
+ */
+PRISM_EXPORTED_FUNCTION void pm_parser_constants_each(const pm_parser_t *parser, pm_constant_callback_t callback, void *data) PRISM_NONNULL(1);
+
+/**
+ * Returns a pointer to the constant at the given id in the constant pool
+ * associated with the given parser.
+ *
+ * @param parser the parser whose constant pool we want to look up from
+ * @param constant_id the id of the constant to look up (1-based)
+ * @returns a pointer to the constant at the given id
+ */
+PRISM_EXPORTED_FUNCTION const pm_constant_t * pm_parser_constant(const pm_parser_t *parser, pm_constant_id_t constant_id) PRISM_NONNULL(1);
+
+/**
+ * Initiate the parser with the given parser.
+ *
+ * @param parser The parser to use.
+ * @returns The AST representing the source.
+ */
+PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/prettyprint.h b/prism/prettyprint.h
new file mode 100644
index 0000000000..0d8e416341
--- /dev/null
+++ b/prism/prettyprint.h
@@ -0,0 +1,31 @@
+/**
+ * @file prettyprint.h
+ *
+ * An AST node pretty-printer.
+ */
+#ifndef PRISM_PRETTYPRINT_H
+#define PRISM_PRETTYPRINT_H
+
+#include "prism/excludes.h"
+
+#ifndef PRISM_EXCLUDE_PRETTYPRINT
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/ast.h"
+#include "prism/buffer.h"
+#include "prism/parser.h"
+
+/**
+ * Pretty-prints the AST represented by the given node to the given buffer.
+ *
+ * @param output_buffer The buffer to write the pretty-printed AST to.
+ * @param parser The parser that parsed the AST.
+ * @param node The root node of the AST to pretty-print.
+ */
+PRISM_EXPORTED_FUNCTION void pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node) PRISM_NONNULL(1, 2, 3);
+
+#endif
+
+#endif
diff --git a/prism/prism.c b/prism/prism.c
new file mode 100644
index 0000000000..a2e04ed106
--- /dev/null
+++ b/prism/prism.c
@@ -0,0 +1,22943 @@
+#include "prism/compiler/accel.h"
+#include "prism/compiler/fallthrough.h"
+#include "prism/compiler/unused.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/arena.h"
+#include "prism/internal/bit.h"
+#include "prism/internal/buffer.h"
+#include "prism/internal/char.h"
+#include "prism/internal/comments.h"
+#include "prism/internal/constant_pool.h"
+#include "prism/internal/diagnostic.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/integer.h"
+#include "prism/internal/isinf.h"
+#include "prism/internal/line_offset_list.h"
+#include "prism/internal/list.h"
+#include "prism/internal/magic_comments.h"
+#include "prism/internal/memchr.h"
+#include "prism/internal/node.h"
+#include "prism/internal/options.h"
+#include "prism/internal/parser.h"
+#include "prism/internal/regexp.h"
+#include "prism/internal/serialize.h"
+#include "prism/internal/source.h"
+#include "prism/internal/static_literals.h"
+#include "prism/internal/stringy.h"
+#include "prism/internal/strncasecmp.h"
+#include "prism/internal/strpbrk.h"
+#include "prism/internal/tokens.h"
+
+#include "prism/excludes.h"
+#include "prism/serialize.h"
+#include "prism/stream.h"
+#include "prism/version.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/**
+ * When we are parsing using recursive descent, we want to protect against
+ * malicious payloads that could attempt to crash our parser. We do this by
+ * specifying a maximum depth to which we are allowed to recurse.
+ */
+#ifndef PRISM_DEPTH_MAXIMUM
+ #define PRISM_DEPTH_MAXIMUM 10000
+#endif
+
+/**
+ * A simple utility macro to concatenate two tokens together, necessary when one
+ * of the tokens is itself a macro.
+ */
+#define PM_CONCATENATE(left, right) left ## right
+
+/**
+ * We want to be able to use static assertions, but they weren't standardized
+ * until C11. As such, we polyfill it here by making a hacky typedef that will
+ * fail to compile due to a negative array size if the condition is false.
+ */
+#if defined(_Static_assert)
+# define PM_STATIC_ASSERT(line, condition, message) _Static_assert(condition, message)
+#else
+# define PM_STATIC_ASSERT(line, condition, message) typedef char PM_CONCATENATE(static_assert_, line)[(condition) ? 1 : -1]
+#endif
+
+/**
+ * Support PRISM_LIKELY and PRISM_UNLIKELY to help the compiler optimize its
+ * branch predication.
+ */
+#if defined(__GNUC__) || defined(__clang__)
+ /** The compiler should predicate that this branch will be taken. */
+ #define PRISM_LIKELY(x) __builtin_expect(!!(x), 1)
+
+ /** The compiler should predicate that this branch will not be taken. */
+ #define PRISM_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+ /** Void because this platform does not support branch prediction hints. */
+ #define PRISM_LIKELY(x) (x)
+
+ /** Void because this platform does not support branch prediction hints. */
+ #define PRISM_UNLIKELY(x) (x)
+#endif
+
+/**
+ * The prism version and the serialization format.
+ */
+const char *
+pm_version(void) {
+ return PRISM_VERSION;
+}
+
+/**
+ * In heredocs, tabs automatically complete up to the next 8 spaces. This is
+ * defined in CRuby as TAB_WIDTH.
+ */
+#define PM_TAB_WHITESPACE_SIZE 8
+
+// Macros for min/max.
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+/******************************************************************************/
+/* Helpful AST-related macros */
+/******************************************************************************/
+
+#define U32(value_) ((uint32_t) (value_))
+
+#define FL PM_NODE_FLAGS
+#define UP PM_NODE_UPCAST
+
+#define PM_LOCATION_START(location_) ((location_)->start)
+#define PM_LOCATION_END(location_) ((location_)->start + (location_)->length)
+
+#define PM_TOKEN_START(parser_, token_) U32((token_)->start - (parser_)->start)
+#define PM_TOKEN_END(parser_, token_) U32((token_)->end - (parser_)->start)
+#define PM_TOKEN_LENGTH(token_) U32((token_)->end - (token_)->start)
+#define PM_TOKENS_LENGTH(left_, right_) U32((right_)->end - (left_)->start)
+
+#define PM_NODE_START(node_) (UP(node_)->location.start)
+#define PM_NODE_LENGTH(node_) (UP(node_)->location.length)
+#define PM_NODE_END(node_) (UP(node_)->location.start + UP(node_)->location.length)
+#define PM_NODES_LENGTH(left_, right_) (PM_NODE_END(right_) - PM_NODE_START(left_))
+
+#define PM_TOKEN_NODE_LENGTH(parser_, token_, node_) (PM_NODE_END(node_) - PM_TOKEN_START(parser_, token_))
+#define PM_NODE_TOKEN_LENGTH(parser_, node_, token_) (PM_TOKEN_END(parser_, token_) - PM_NODE_START(node_))
+
+#define PM_NODE_START_SET_NODE(left_, right_) (PM_NODE_START(left_) = PM_NODE_START(right_))
+#define PM_NODE_START_SET_TOKEN(parser_, node_, token_) (PM_NODE_START(node_) = PM_TOKEN_START(parser_, token_))
+#define PM_NODE_LENGTH_SET_NODE(left_, right_) (PM_NODE_LENGTH(left_) = PM_NODE_END(right_) - PM_NODE_START(left_))
+#define PM_NODE_LENGTH_SET_TOKEN(parser_, node_, token_) (PM_NODE_LENGTH(node_) = PM_TOKEN_END(parser_, token_) - PM_NODE_START(node_))
+#define PM_NODE_LENGTH_SET_LOCATION(node_, location_) (PM_NODE_LENGTH(node_) = PM_LOCATION_END(location_) - PM_NODE_START(node_))
+
+#define PM_LOCATION_INIT(start_, length_) ((pm_location_t) { .start = (start_), .length = (length_) })
+#define PM_LOCATION_INIT_UNSET PM_LOCATION_INIT(0, 0)
+#define PM_LOCATION_INIT_TOKEN(parser_, token_) PM_LOCATION_INIT(PM_TOKEN_START(parser_, token_), PM_TOKEN_LENGTH(token_))
+#define PM_LOCATION_INIT_NODE(node_) UP(node_)->location
+
+#define PM_LOCATION_INIT_TOKENS(parser_, left_, right_) PM_LOCATION_INIT(PM_TOKEN_START(parser_, left_), PM_TOKENS_LENGTH(left_, right_))
+#define PM_LOCATION_INIT_NODES(left_, right_) PM_LOCATION_INIT(PM_NODE_START(left_), PM_NODES_LENGTH(left_, right_))
+#define PM_LOCATION_INIT_TOKEN_NODE(parser_, token_, node_) PM_LOCATION_INIT(PM_TOKEN_START(parser_, token_), PM_TOKEN_NODE_LENGTH(parser_, token_, node_))
+#define PM_LOCATION_INIT_NODE_TOKEN(parser_, node_, token_) PM_LOCATION_INIT(PM_NODE_START(node_), PM_NODE_TOKEN_LENGTH(parser_, node_, token_))
+
+#define TOK2LOC(parser_, token_) PM_LOCATION_INIT_TOKEN(parser_, token_)
+#define NTOK2LOC(parser_, token_) ((token_) == NULL ? PM_LOCATION_INIT_UNSET : TOK2LOC(parser_, token_))
+#define NTOK2PTR(token_) ((token_).start == NULL ? NULL : &(token_))
+
+/******************************************************************************/
+/* Lex mode manipulations */
+/******************************************************************************/
+
+/**
+ * Returns the incrementor character that should be used to increment the
+ * nesting count if one is possible.
+ */
+static PRISM_INLINE uint8_t
+lex_mode_incrementor(const uint8_t start) {
+ switch (start) {
+ case '(':
+ case '[':
+ case '{':
+ case '<':
+ return start;
+ default:
+ return '\0';
+ }
+}
+
+/**
+ * Returns the matching character that should be used to terminate a list
+ * beginning with the given character.
+ */
+static PRISM_INLINE uint8_t
+lex_mode_terminator(const uint8_t start) {
+ switch (start) {
+ case '(':
+ return ')';
+ case '[':
+ return ']';
+ case '{':
+ return '}';
+ case '<':
+ return '>';
+ default:
+ return start;
+ }
+}
+
+/**
+ * Push a new lex state onto the stack. If we're still within the pre-allocated
+ * space of the lex state stack, then we'll just use a new slot. Otherwise we'll
+ * allocate a new pointer and use that.
+ */
+static bool
+lex_mode_push(pm_parser_t *parser, pm_lex_mode_t lex_mode) {
+ lex_mode.prev = parser->lex_modes.current;
+ parser->lex_modes.index++;
+
+ if (parser->lex_modes.index > PM_LEX_STACK_SIZE - 1) {
+ parser->lex_modes.current = (pm_lex_mode_t *) xmalloc(sizeof(pm_lex_mode_t));
+ if (parser->lex_modes.current == NULL) return false;
+
+ *parser->lex_modes.current = lex_mode;
+ } else {
+ parser->lex_modes.stack[parser->lex_modes.index] = lex_mode;
+ parser->lex_modes.current = &parser->lex_modes.stack[parser->lex_modes.index];
+ }
+
+ return true;
+}
+
+/**
+ * Push on a new list lex mode.
+ */
+static PRISM_INLINE bool
+lex_mode_push_list(pm_parser_t *parser, bool interpolation, uint8_t delimiter) {
+ uint8_t incrementor = lex_mode_incrementor(delimiter);
+ uint8_t terminator = lex_mode_terminator(delimiter);
+
+ pm_lex_mode_t lex_mode = {
+ .mode = PM_LEX_LIST,
+ .as.list = {
+ .nesting = 0,
+ .interpolation = interpolation,
+ .incrementor = incrementor,
+ .terminator = terminator
+ }
+ };
+
+ // These are the places where we need to split up the content of the list.
+ // We'll use strpbrk to find the first of these characters.
+ uint8_t *breakpoints = lex_mode.as.list.breakpoints;
+ memset(breakpoints, 0, PM_STRPBRK_CACHE_SIZE);
+ memcpy(breakpoints, "\\ \t\f\r\v\n", sizeof("\\ \t\f\r\v\n") - 1);
+ size_t index = 7;
+
+ // Now we'll add the terminator to the list of breakpoints. If the
+ // terminator is not already a NULL byte, add it to the list.
+ if (terminator != '\0') {
+ breakpoints[index++] = terminator;
+ }
+
+ // If interpolation is allowed, then we're going to check for the #
+ // character. Otherwise we'll only look for escapes and the terminator.
+ if (interpolation) {
+ breakpoints[index++] = '#';
+ }
+
+ // If there is an incrementor, then we'll check for that as well.
+ if (incrementor != '\0') {
+ breakpoints[index++] = incrementor;
+ }
+
+ parser->explicit_encoding = NULL;
+ return lex_mode_push(parser, lex_mode);
+}
+
+/**
+ * Push on a new list lex mode that is only used for compatibility. This is
+ * called when we're at the end of the file. We want the parser to be able to
+ * perform its normal error tolerance.
+ */
+static PRISM_INLINE bool
+lex_mode_push_list_eof(pm_parser_t *parser) {
+ return lex_mode_push_list(parser, false, '\0');
+}
+
+/**
+ * Push on a new regexp lex mode.
+ */
+static PRISM_INLINE bool
+lex_mode_push_regexp(pm_parser_t *parser, uint8_t incrementor, uint8_t terminator) {
+ pm_lex_mode_t lex_mode = {
+ .mode = PM_LEX_REGEXP,
+ .as.regexp = {
+ .nesting = 0,
+ .incrementor = incrementor,
+ .terminator = terminator
+ }
+ };
+
+ // These are the places where we need to split up the content of the
+ // regular expression. We'll use strpbrk to find the first of these
+ // characters.
+ uint8_t *breakpoints = lex_mode.as.regexp.breakpoints;
+ memset(breakpoints, 0, PM_STRPBRK_CACHE_SIZE);
+ memcpy(breakpoints, "\r\n\\#", sizeof("\r\n\\#") - 1);
+ size_t index = 4;
+
+ // First we'll add the terminator.
+ if (terminator != '\0') {
+ breakpoints[index++] = terminator;
+ }
+
+ // Next, if there is an incrementor, then we'll check for that as well.
+ if (incrementor != '\0') {
+ breakpoints[index++] = incrementor;
+ }
+
+ parser->explicit_encoding = NULL;
+ return lex_mode_push(parser, lex_mode);
+}
+
+/**
+ * Push on a new string lex mode.
+ */
+static PRISM_INLINE bool
+lex_mode_push_string(pm_parser_t *parser, bool interpolation, bool label_allowed, uint8_t incrementor, uint8_t terminator) {
+ pm_lex_mode_t lex_mode = {
+ .mode = PM_LEX_STRING,
+ .as.string = {
+ .nesting = 0,
+ .interpolation = interpolation,
+ .label_allowed = label_allowed,
+ .incrementor = incrementor,
+ .terminator = terminator
+ }
+ };
+
+ // These are the places where we need to split up the content of the
+ // string. We'll use strpbrk to find the first of these characters.
+ uint8_t *breakpoints = lex_mode.as.string.breakpoints;
+ memset(breakpoints, 0, PM_STRPBRK_CACHE_SIZE);
+ memcpy(breakpoints, "\r\n\\", sizeof("\r\n\\") - 1);
+ size_t index = 3;
+
+ // Now add in the terminator. If the terminator is not already a NULL byte,
+ // then we'll add it.
+ if (terminator != '\0') {
+ breakpoints[index++] = terminator;
+ }
+
+ // If interpolation is allowed, then we're going to check for the #
+ // character. Otherwise we'll only look for escapes and the terminator.
+ if (interpolation) {
+ breakpoints[index++] = '#';
+ }
+
+ // If we have an incrementor, then we'll add that in as a breakpoint as
+ // well.
+ if (incrementor != '\0') {
+ breakpoints[index++] = incrementor;
+ }
+
+ parser->explicit_encoding = NULL;
+ return lex_mode_push(parser, lex_mode);
+}
+
+/**
+ * Push on a new string lex mode that is only used for compatibility. This is
+ * called when we're at the end of the file. We want the parser to be able to
+ * perform its normal error tolerance.
+ */
+static PRISM_INLINE bool
+lex_mode_push_string_eof(pm_parser_t *parser) {
+ return lex_mode_push_string(parser, false, false, '\0', '\0');
+}
+
+/**
+ * Pop the current lex state off the stack. If we're within the pre-allocated
+ * space of the lex state stack, then we'll just decrement the index. Otherwise
+ * we'll free the current pointer and use the previous pointer.
+ */
+static void
+lex_mode_pop(pm_parser_t *parser) {
+ if (parser->lex_modes.index == 0) {
+ parser->lex_modes.current->mode = PM_LEX_DEFAULT;
+ } else if (parser->lex_modes.index < PM_LEX_STACK_SIZE) {
+ parser->lex_modes.index--;
+ parser->lex_modes.current = &parser->lex_modes.stack[parser->lex_modes.index];
+ } else {
+ parser->lex_modes.index--;
+ pm_lex_mode_t *prev = parser->lex_modes.current->prev;
+ xfree_sized(parser->lex_modes.current, sizeof(pm_lex_mode_t));
+ parser->lex_modes.current = prev;
+ }
+}
+
+/**
+ * This is the equivalent of IS_lex_state is CRuby.
+ */
+static PRISM_INLINE bool
+lex_state_p(const pm_parser_t *parser, pm_lex_state_t state) {
+ return parser->lex_state & state;
+}
+
+typedef enum {
+ PM_IGNORED_NEWLINE_NONE = 0,
+ PM_IGNORED_NEWLINE_ALL,
+ PM_IGNORED_NEWLINE_PATTERN
+} pm_ignored_newline_type_t;
+
+static PRISM_INLINE pm_ignored_newline_type_t
+lex_state_ignored_p(pm_parser_t *parser) {
+ bool ignored = lex_state_p(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_CLASS | PM_LEX_STATE_FNAME | PM_LEX_STATE_DOT) && !lex_state_p(parser, PM_LEX_STATE_LABELED);
+
+ if (ignored) {
+ return PM_IGNORED_NEWLINE_ALL;
+ } else if ((parser->lex_state & ~((unsigned int) PM_LEX_STATE_LABEL)) == (PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED)) {
+ return PM_IGNORED_NEWLINE_PATTERN;
+ } else {
+ return PM_IGNORED_NEWLINE_NONE;
+ }
+}
+
+static PRISM_INLINE bool
+lex_state_beg_p(pm_parser_t *parser) {
+ return lex_state_p(parser, PM_LEX_STATE_BEG_ANY) || ((parser->lex_state & (PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED)) == (PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED));
+}
+
+static PRISM_INLINE bool
+lex_state_arg_p(pm_parser_t *parser) {
+ return lex_state_p(parser, PM_LEX_STATE_ARG_ANY);
+}
+
+static PRISM_INLINE bool
+lex_state_spcarg_p(pm_parser_t *parser, bool space_seen) {
+ if (parser->current.end >= parser->end) {
+ return false;
+ }
+ return lex_state_arg_p(parser) && space_seen && !pm_char_is_whitespace(*parser->current.end);
+}
+
+static PRISM_INLINE bool
+lex_state_end_p(pm_parser_t *parser) {
+ return lex_state_p(parser, PM_LEX_STATE_END_ANY);
+}
+
+/**
+ * This is the equivalent of IS_AFTER_OPERATOR in CRuby.
+ */
+static PRISM_INLINE bool
+lex_state_operator_p(pm_parser_t *parser) {
+ return lex_state_p(parser, PM_LEX_STATE_FNAME | PM_LEX_STATE_DOT);
+}
+
+/**
+ * Set the state of the lexer. This is defined as a function to be able to put a
+ * breakpoint in it.
+ */
+static PRISM_INLINE void
+lex_state_set(pm_parser_t *parser, pm_lex_state_t state) {
+ parser->lex_state = state;
+}
+
+#ifndef PM_DEBUG_LOGGING
+/**
+ * Debugging logging will print additional information to stdout whenever the
+ * lexer state changes.
+ */
+#define PM_DEBUG_LOGGING 0
+#endif
+
+#if PM_DEBUG_LOGGING
+PRISM_UNUSED static void
+debug_state(pm_parser_t *parser) {
+ fprintf(stderr, "STATE: ");
+ bool first = true;
+
+ if (parser->lex_state == PM_LEX_STATE_NONE) {
+ fprintf(stderr, "NONE\n");
+ return;
+ }
+
+#define CHECK_STATE(state) \
+ if (parser->lex_state & state) { \
+ if (!first) fprintf(stderr, "|"); \
+ fprintf(stderr, "%s", #state); \
+ first = false; \
+ }
+
+ CHECK_STATE(PM_LEX_STATE_BEG)
+ CHECK_STATE(PM_LEX_STATE_END)
+ CHECK_STATE(PM_LEX_STATE_ENDARG)
+ CHECK_STATE(PM_LEX_STATE_ENDFN)
+ CHECK_STATE(PM_LEX_STATE_ARG)
+ CHECK_STATE(PM_LEX_STATE_CMDARG)
+ CHECK_STATE(PM_LEX_STATE_MID)
+ CHECK_STATE(PM_LEX_STATE_FNAME)
+ CHECK_STATE(PM_LEX_STATE_DOT)
+ CHECK_STATE(PM_LEX_STATE_CLASS)
+ CHECK_STATE(PM_LEX_STATE_LABEL)
+ CHECK_STATE(PM_LEX_STATE_LABELED)
+ CHECK_STATE(PM_LEX_STATE_FITEM)
+
+#undef CHECK_STATE
+
+ fprintf(stderr, "\n");
+}
+
+static void
+debug_lex_state_set(pm_parser_t *parser, pm_lex_state_t state, char const * caller_name, int line_number) {
+ fprintf(stderr, "Caller: %s:%d\nPrevious: ", caller_name, line_number);
+ debug_state(parser);
+ lex_state_set(parser, state);
+ fprintf(stderr, "Now: ");
+ debug_state(parser);
+ fprintf(stderr, "\n");
+}
+
+#define lex_state_set(parser, state) debug_lex_state_set(parser, state, __func__, __LINE__)
+#endif
+
+/******************************************************************************/
+/* Command-line macro helpers */
+/******************************************************************************/
+
+/** True if the parser has the given command-line option. */
+#define PM_PARSER_COMMAND_LINE_OPTION(parser, option) ((parser)->command_line & (option))
+
+/** True if the -a command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_A(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_A)
+
+/** True if the -e command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_E(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_E)
+
+/** True if the -l command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_L(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_L)
+
+/** True if the -n command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_N(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_N)
+
+/** True if the -p command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_P(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_P)
+
+/** True if the -x command line option was given. */
+#define PM_PARSER_COMMAND_LINE_OPTION_X(parser) PM_PARSER_COMMAND_LINE_OPTION(parser, PM_OPTIONS_COMMAND_LINE_X)
+
+/******************************************************************************/
+/* Diagnostic-related functions */
+/******************************************************************************/
+
+/**
+ * Append an error to the list of errors on the parser.
+ */
+static PRISM_INLINE void
+pm_parser_err(pm_parser_t *parser, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id) {
+ pm_diagnostic_list_append(&parser->metadata_arena, &parser->error_list, start, length, diag_id);
+}
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given token.
+ */
+static PRISM_INLINE void
+pm_parser_err_token(pm_parser_t *parser, const pm_token_t *token, pm_diagnostic_id_t diag_id) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, token), PM_TOKEN_LENGTH(token), diag_id);
+}
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * current token.
+ */
+static PRISM_INLINE void
+pm_parser_err_current(pm_parser_t *parser, pm_diagnostic_id_t diag_id) {
+ pm_parser_err_token(parser, &parser->current, diag_id);
+}
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * previous token.
+ */
+static PRISM_INLINE void
+pm_parser_err_previous(pm_parser_t *parser, pm_diagnostic_id_t diag_id) {
+ pm_parser_err_token(parser, &parser->previous, diag_id);
+}
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given node.
+ */
+static PRISM_INLINE void
+pm_parser_err_node(pm_parser_t *parser, const pm_node_t *node, pm_diagnostic_id_t diag_id) {
+ pm_parser_err(parser, PM_NODE_START(node), PM_NODE_LENGTH(node), diag_id);
+}
+
+/**
+ * Append an error to the list of errors on the parser using a format string.
+ */
+#define PM_PARSER_ERR_FORMAT(parser_, start_, length_, diag_id_, ...) \
+ pm_diagnostic_list_append_format(&(parser_)->metadata_arena, &(parser_)->error_list, start_, length_, diag_id_, __VA_ARGS__)
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given node and a format string.
+ */
+#define PM_PARSER_ERR_NODE_FORMAT(parser_, node_, diag_id_, ...) \
+ PM_PARSER_ERR_FORMAT(parser_, PM_NODE_START(node_), PM_NODE_LENGTH(node_), diag_id_, __VA_ARGS__)
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given node and a format string, and add on the content of the node.
+ */
+#define PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser_, node_, diag_id_) \
+ PM_PARSER_ERR_NODE_FORMAT(parser_, node_, diag_id_, (int) PM_NODE_LENGTH(node_), (const char *) (parser_->start + PM_NODE_START(node_)))
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given token and a format string.
+ */
+#define PM_PARSER_ERR_TOKEN_FORMAT(parser_, token_, diag_id, ...) \
+ PM_PARSER_ERR_FORMAT(parser_, PM_TOKEN_START(parser_, token_), PM_TOKEN_LENGTH(token_), diag_id, __VA_ARGS__)
+
+/**
+ * Append an error to the list of errors on the parser using the location of the
+ * given token and a format string, and add on the content of the token.
+ */
+#define PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser_, token_, diag_id_) \
+ PM_PARSER_ERR_TOKEN_FORMAT(parser_, token_, diag_id_, (int) PM_TOKEN_LENGTH(token_), (const char *) (token_)->start)
+
+/**
+ * Append a warning to the list of warnings on the parser.
+ */
+static PRISM_INLINE void
+pm_parser_warn(pm_parser_t *parser, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id) {
+ pm_diagnostic_list_append(&parser->metadata_arena, &parser->warning_list, start, length, diag_id);
+}
+
+/**
+ * Append a warning to the list of warnings on the parser using the location of
+ * the given token.
+ */
+static PRISM_INLINE void
+pm_parser_warn_token(pm_parser_t *parser, const pm_token_t *token, pm_diagnostic_id_t diag_id) {
+ pm_parser_warn(parser, PM_TOKEN_START(parser, token), PM_TOKEN_LENGTH(token), diag_id);
+}
+
+/**
+ * Append a warning to the list of warnings on the parser using the location of
+ * the given node.
+ */
+static PRISM_INLINE void
+pm_parser_warn_node(pm_parser_t *parser, const pm_node_t *node, pm_diagnostic_id_t diag_id) {
+ pm_parser_warn(parser, PM_NODE_START(node), PM_NODE_LENGTH(node), diag_id);
+}
+
+/**
+ * Append a warning to the list of warnings on the parser using a format string
+ * and the given location.
+ */
+#define PM_PARSER_WARN_FORMAT(parser_, start_, length_, diag_id_, ...) \
+ pm_diagnostic_list_append_format(&(parser_)->metadata_arena, &(parser_)->warning_list, start_, length_, diag_id_, __VA_ARGS__)
+
+/**
+ * Append a warning to the list of warnings on the parser using the location of
+ * the given token and a format string.
+ */
+#define PM_PARSER_WARN_TOKEN_FORMAT(parser_, token_, diag_id_, ...) \
+ PM_PARSER_WARN_FORMAT(parser_, PM_TOKEN_START(parser_, token_), PM_TOKEN_LENGTH(token_), diag_id_, __VA_ARGS__)
+
+/**
+ * Append a warning to the list of warnings on the parser using the location of
+ * the given token and a format string, and add on the content of the token.
+ */
+#define PM_PARSER_WARN_TOKEN_FORMAT_CONTENT(parser_, token_, diag_id_) \
+ PM_PARSER_WARN_TOKEN_FORMAT(parser_, token_, diag_id_, (int) PM_TOKEN_LENGTH(token_), (const char *) (token_)->start)
+
+/**
+ * Append a warning to the list of warnings on the parser using the location of
+ * the given node and a format string.
+ */
+#define PM_PARSER_WARN_NODE_FORMAT(parser_, node_, diag_id_, ...) \
+ PM_PARSER_WARN_FORMAT(parser_, PM_NODE_START(node_), PM_NODE_LENGTH(node_), diag_id_, __VA_ARGS__)
+
+/**
+ * Add an error for an expected heredoc terminator. This is a special function
+ * only because it grabs its location off of a lex mode instead of a node or a
+ * token.
+ */
+static void
+pm_parser_err_heredoc_term(pm_parser_t *parser, const uint8_t *ident_start, size_t ident_length) {
+ PM_PARSER_ERR_FORMAT(
+ parser,
+ U32(ident_start - parser->start),
+ U32(ident_length),
+ PM_ERR_HEREDOC_TERM,
+ (int) ident_length,
+ (const char *) ident_start
+ );
+}
+
+/******************************************************************************/
+/* Scope-related functions */
+/******************************************************************************/
+
+/**
+ * Allocate and initialize a new scope. Push it onto the scope stack.
+ */
+static bool
+pm_parser_scope_push(pm_parser_t *parser, bool closed) {
+ pm_scope_t *scope = (pm_scope_t *) xmalloc(sizeof(pm_scope_t));
+ if (scope == NULL) return false;
+
+ *scope = (pm_scope_t) {
+ .previous = parser->current_scope,
+ .locals = { 0 },
+ .parameters = PM_SCOPE_PARAMETERS_NONE,
+ .implicit_parameters = { 0 },
+ .shareable_constant = parser->current_scope == NULL ? PM_SCOPE_SHAREABLE_CONSTANT_NONE : parser->current_scope->shareable_constant,
+ .closed = closed
+ };
+
+ parser->current_scope = scope;
+ return true;
+}
+
+/**
+ * Determine if the current scope is at the top level. This means it is either
+ * the top-level scope or it is open to the top-level.
+ */
+static bool
+pm_parser_scope_toplevel_p(pm_parser_t *parser) {
+ pm_scope_t *scope = parser->current_scope;
+
+ do {
+ if (scope->previous == NULL) return true;
+ if (scope->closed) return false;
+ } while ((scope = scope->previous) != NULL);
+
+ assert(false && "unreachable");
+ return true;
+}
+
+/**
+ * Retrieve the scope at the given depth.
+ */
+static pm_scope_t *
+pm_parser_scope_find(pm_parser_t *parser, uint32_t depth) {
+ pm_scope_t *scope = parser->current_scope;
+
+ while (depth-- > 0) {
+ assert(scope != NULL);
+ scope = scope->previous;
+ }
+
+ return scope;
+}
+
+typedef enum {
+ PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS,
+ PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT,
+ PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL
+} pm_scope_forwarding_param_check_result_t;
+
+static pm_scope_forwarding_param_check_result_t
+pm_parser_scope_forwarding_param_check(pm_parser_t *parser, const uint8_t mask) {
+ pm_scope_t *scope = parser->current_scope;
+ bool conflict = false;
+
+ while (scope != NULL) {
+ if (scope->parameters & mask) {
+ if (scope->closed) {
+ if (conflict) {
+ return PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT;
+ } else {
+ return PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS;
+ }
+ }
+
+ conflict = true;
+ }
+
+ if (scope->closed) break;
+ scope = scope->previous;
+ }
+
+ return PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL;
+}
+
+static void
+pm_parser_scope_forwarding_block_check(pm_parser_t *parser, const pm_token_t * token) {
+ switch (pm_parser_scope_forwarding_param_check(parser, PM_SCOPE_PARAMETERS_FORWARDING_BLOCK)) {
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS:
+ // Pass.
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_CONFLICT_AMPERSAND);
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND);
+ break;
+ }
+}
+
+static void
+pm_parser_scope_forwarding_positionals_check(pm_parser_t *parser, const pm_token_t * token) {
+ switch (pm_parser_scope_forwarding_param_check(parser, PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS)) {
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS:
+ // Pass.
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_CONFLICT_STAR);
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_NO_FORWARDING_STAR);
+ break;
+ }
+}
+
+static void
+pm_parser_scope_forwarding_all_check(pm_parser_t *parser, const pm_token_t *token) {
+ switch (pm_parser_scope_forwarding_param_check(parser, PM_SCOPE_PARAMETERS_FORWARDING_ALL)) {
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS:
+ // Pass.
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT:
+ // This shouldn't happen, because ... is not allowed in the
+ // declaration of blocks. If we get here, we assume we already have
+ // an error for this.
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES);
+ break;
+ }
+}
+
+static void
+pm_parser_scope_forwarding_keywords_check(pm_parser_t *parser, const pm_token_t * token) {
+ switch (pm_parser_scope_forwarding_param_check(parser, PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS)) {
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_PASS:
+ // Pass.
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_CONFLICT:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_CONFLICT_STAR_STAR);
+ break;
+ case PM_SCOPE_FORWARDING_PARAM_CHECK_RESULT_FAIL:
+ pm_parser_err_token(parser, token, PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR);
+ break;
+ }
+}
+
+/**
+ * Get the current state of constant shareability.
+ */
+static PRISM_INLINE pm_shareable_constant_value_t
+pm_parser_scope_shareable_constant_get(pm_parser_t *parser) {
+ return parser->current_scope->shareable_constant;
+}
+
+/**
+ * Set the current state of constant shareability. We'll set it on all of the
+ * open scopes so that reads are quick.
+ */
+static void
+pm_parser_scope_shareable_constant_set(pm_parser_t *parser, pm_shareable_constant_value_t shareable_constant) {
+ pm_scope_t *scope = parser->current_scope;
+
+ do {
+ scope->shareable_constant = shareable_constant;
+ } while (!scope->closed && (scope = scope->previous) != NULL);
+}
+
+/******************************************************************************/
+/* Local variable-related functions */
+/******************************************************************************/
+
+/**
+ * The point at which the set of locals switches from being a list to a hash.
+ */
+#define PM_LOCALS_HASH_THRESHOLD 5
+
+static void
+pm_locals_free(pm_locals_t *locals) {
+ if (locals->capacity > 0) {
+ xfree_sized(locals->locals, locals->capacity * sizeof(pm_local_t));
+ }
+}
+
+/**
+ * Use as simple and fast a hash function as we can that still properly mixes
+ * the bits.
+ */
+static uint32_t
+pm_locals_hash(pm_constant_id_t name) {
+ name = ((name >> 16) ^ name) * 0x45d9f3b;
+ name = ((name >> 16) ^ name) * 0x45d9f3b;
+ name = (name >> 16) ^ name;
+ return name;
+}
+
+/**
+ * Resize the locals list to be twice its current size. If the next capacity is
+ * above the threshold for switching to a hash, then we'll switch to a hash.
+ */
+static void
+pm_locals_resize(pm_locals_t *locals) {
+ uint32_t next_capacity = locals->capacity == 0 ? 4 : (locals->capacity * 2);
+ assert(next_capacity > locals->capacity);
+
+ pm_local_t *next_locals = xcalloc(next_capacity, sizeof(pm_local_t));
+ if (next_locals == NULL) abort();
+
+ if (next_capacity < PM_LOCALS_HASH_THRESHOLD) {
+ if (locals->size > 0) {
+ memcpy(next_locals, locals->locals, locals->size * sizeof(pm_local_t));
+ }
+ } else {
+ // If we just switched from a list to a hash, then we need to fill in
+ // the hash values of all of the locals.
+ bool hash_needed = (locals->capacity <= PM_LOCALS_HASH_THRESHOLD);
+ uint32_t mask = next_capacity - 1;
+
+ for (uint32_t index = 0; index < locals->capacity; index++) {
+ pm_local_t *local = &locals->locals[index];
+
+ if (local->name != PM_CONSTANT_ID_UNSET) {
+ if (hash_needed) local->hash = pm_locals_hash(local->name);
+
+ uint32_t hash = local->hash;
+ while (next_locals[hash & mask].name != PM_CONSTANT_ID_UNSET) hash++;
+ next_locals[hash & mask] = *local;
+ }
+ }
+ }
+
+ pm_locals_free(locals);
+ locals->locals = next_locals;
+ locals->capacity = next_capacity;
+}
+
+/**
+ * Add a new local to the set of locals. This will automatically rehash the
+ * locals if the size is greater than 3/4 of the capacity.
+ *
+ * @param locals The set of locals to add to.
+ * @param name The name of the local.
+ * @param start The source location that represents the start of the local. This
+ * is used for the location of the warning in case this local is not read.
+ * @param end The source location that represents the end of the local. This is
+ * used for the location of the warning in case this local is not read.
+ * @param reads The initial number of reads for this local. Usually this is set
+ * to 0, but for some locals (like parameters) we want to initialize it with
+ * 1 so that we never warn on unused parameters.
+ * @return True if the local was added, and false if the local already exists.
+ */
+static bool
+pm_locals_write(pm_locals_t *locals, pm_constant_id_t name, uint32_t start, uint32_t length, uint32_t reads) {
+ if (locals->size >= (locals->capacity / 4 * 3)) {
+ pm_locals_resize(locals);
+ }
+
+ locals->bloom |= (1u << (name & 31));
+
+ if (locals->capacity < PM_LOCALS_HASH_THRESHOLD) {
+ for (uint32_t index = 0; index < locals->capacity; index++) {
+ pm_local_t *local = &locals->locals[index];
+
+ if (local->name == PM_CONSTANT_ID_UNSET) {
+ *local = (pm_local_t) {
+ .name = name,
+ .location = { .start = start, .length = length },
+ .index = locals->size++,
+ .reads = reads,
+ .hash = 0
+ };
+ return true;
+ } else if (local->name == name) {
+ return false;
+ }
+ }
+ } else {
+ uint32_t mask = locals->capacity - 1;
+ uint32_t hash = pm_locals_hash(name);
+ uint32_t initial_hash = hash;
+
+ do {
+ pm_local_t *local = &locals->locals[hash & mask];
+
+ if (local->name == PM_CONSTANT_ID_UNSET) {
+ *local = (pm_local_t) {
+ .name = name,
+ .location = { .start = start, .length = length },
+ .index = locals->size++,
+ .reads = reads,
+ .hash = initial_hash
+ };
+ return true;
+ } else if (local->name == name) {
+ return false;
+ } else {
+ hash++;
+ }
+ } while ((hash & mask) != initial_hash);
+ }
+
+ assert(false && "unreachable");
+ return true;
+}
+
+/**
+ * Finds the index of a local variable in the locals set. If it is not found,
+ * this returns UINT32_MAX.
+ */
+static uint32_t
+pm_locals_find(pm_locals_t *locals, pm_constant_id_t name) {
+ if (!(locals->bloom & (1u << (name & 31)))) return UINT32_MAX;
+
+ if (locals->capacity < PM_LOCALS_HASH_THRESHOLD) {
+ for (uint32_t index = 0; index < locals->size; index++) {
+ pm_local_t *local = &locals->locals[index];
+ if (local->name == name) return index;
+ }
+ } else {
+ uint32_t mask = locals->capacity - 1;
+ uint32_t hash = pm_locals_hash(name);
+ uint32_t initial_hash = hash & mask;
+
+ do {
+ pm_local_t *local = &locals->locals[hash & mask];
+
+ if (local->name == PM_CONSTANT_ID_UNSET) {
+ return UINT32_MAX;
+ } else if (local->name == name) {
+ return hash & mask;
+ } else {
+ hash++;
+ }
+ } while ((hash & mask) != initial_hash);
+ }
+
+ return UINT32_MAX;
+}
+
+/**
+ * Called when a variable is read in a certain lexical context. Tracks the read
+ * by adding to the reads count.
+ */
+static void
+pm_locals_read(pm_locals_t *locals, pm_constant_id_t name) {
+ uint32_t index = pm_locals_find(locals, name);
+ assert(index != UINT32_MAX);
+
+ pm_local_t *local = &locals->locals[index];
+ assert(local->reads < UINT32_MAX);
+
+ local->reads++;
+}
+
+/**
+ * Called when a variable read is transformed into a variable write, because a
+ * write operator is found after the variable name.
+ */
+static void
+pm_locals_unread(pm_locals_t *locals, pm_constant_id_t name) {
+ uint32_t index = pm_locals_find(locals, name);
+ assert(index != UINT32_MAX);
+
+ pm_local_t *local = &locals->locals[index];
+ assert(local->reads > 0);
+
+ local->reads--;
+}
+
+/**
+ * Returns the current number of reads for a local variable.
+ */
+static uint32_t
+pm_locals_reads(pm_locals_t *locals, pm_constant_id_t name) {
+ uint32_t index = pm_locals_find(locals, name);
+ assert(index != UINT32_MAX);
+
+ return locals->locals[index].reads;
+}
+
+/**
+ * Write out the locals into the given list of constant ids in the correct
+ * order. This is used to set the list of locals on the nodes in the tree once
+ * we're sure no additional locals will be added to the set.
+ *
+ * This function is also responsible for warning when a local variable has been
+ * written but not read in certain contexts.
+ */
+static void
+pm_locals_order(pm_parser_t *parser, pm_locals_t *locals, pm_constant_id_list_t *list, bool toplevel) {
+ pm_constant_id_list_init_capacity(parser->arena, list, locals->size);
+
+ // If we're still below the threshold for switching to a hash, then we only
+ // need to loop over the locals until we hit the size because the locals are
+ // stored in a list.
+ uint32_t capacity = locals->capacity < PM_LOCALS_HASH_THRESHOLD ? locals->size : locals->capacity;
+
+ // We will only warn for unused variables if we're not at the top level, or
+ // if we're parsing a file outside of eval or -e.
+ bool warn_unused = !toplevel || (!parser->parsing_eval && !PM_PARSER_COMMAND_LINE_OPTION_E(parser));
+
+ for (uint32_t index = 0; index < capacity; index++) {
+ pm_local_t *local = &locals->locals[index];
+
+ if (local->name != PM_CONSTANT_ID_UNSET) {
+ pm_constant_id_list_insert(list, (size_t) local->index, local->name);
+
+ if (warn_unused && local->reads == 0 && ((parser->start_line >= 0) || (pm_line_offset_list_line(&parser->line_offsets, local->location.start, parser->start_line) >= 0))) {
+ pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name);
+
+ if (constant->length >= 1 && *constant->start != '_') {
+ PM_PARSER_WARN_FORMAT(
+ parser,
+ local->location.start,
+ local->location.length,
+ PM_WARN_UNUSED_LOCAL_VARIABLE,
+ (int) constant->length,
+ (const char *) constant->start
+ );
+ }
+ }
+ }
+ }
+}
+
+/******************************************************************************/
+/* Node-related functions */
+/******************************************************************************/
+
+/**
+ * Retrieve the constant pool id for the given location.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_constant_id_raw(pm_parser_t *parser, const uint8_t *start, const uint8_t *end) {
+ /* Fast path: if this is the same token as the last lookup (same pointer
+ * range), return the cached result. */
+ if (start == parser->constant_cache.start && end == parser->constant_cache.end) {
+ return parser->constant_cache.id;
+ }
+
+ pm_constant_id_t id = pm_constant_pool_insert_shared(&parser->metadata_arena, &parser->constant_pool, start, (size_t) (end - start));
+
+ parser->constant_cache.start = start;
+ parser->constant_cache.end = end;
+ parser->constant_cache.id = id;
+
+ return id;
+}
+
+/**
+ * Retrieve the constant pool id for the given string.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_constant_id_owned(pm_parser_t *parser, uint8_t *start, size_t length) {
+ return pm_constant_pool_insert_owned(&parser->metadata_arena, &parser->constant_pool, start, length);
+}
+
+/**
+ * Retrieve the constant pool id for the given static literal C string.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_constant_id_constant(pm_parser_t *parser, const char *start, size_t length) {
+ return pm_constant_pool_insert_constant(&parser->metadata_arena, &parser->constant_pool, (const uint8_t *) start, length);
+}
+
+/**
+ * Retrieve the constant pool id for the given token.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_constant_id_token(pm_parser_t *parser, const pm_token_t *token) {
+ return pm_parser_constant_id_raw(parser, token->start, token->end);
+}
+
+/**
+ * This macro allows you to define a case statement for all of the nodes that
+ * may result in a void value.
+ */
+#define PM_CASE_VOID_VALUE PM_RETURN_NODE: case PM_BREAK_NODE: case PM_NEXT_NODE: \
+ case PM_REDO_NODE: case PM_RETRY_NODE: case PM_MATCH_REQUIRED_NODE
+
+/**
+ * Check whether or not the given node is value expression.
+ * If the node is value node, it returns NULL.
+ * If not, it returns the pointer to the node to be inspected as "void expression".
+ */
+static pm_node_t *
+pm_check_value_expression(pm_parser_t *parser, pm_node_t *node) {
+ pm_node_t *void_node = NULL;
+
+ while (node != NULL) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CASE_VOID_VALUE:
+ return void_node != NULL ? void_node : node;
+ case PM_MATCH_PREDICATE_NODE:
+ return NULL;
+ case PM_BEGIN_NODE: {
+ pm_begin_node_t *cast = (pm_begin_node_t *) node;
+
+ if (cast->ensure_clause != NULL) {
+ if (cast->rescue_clause != NULL) {
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->rescue_clause));
+ if (vn != NULL) return vn;
+ }
+
+ if (cast->statements != NULL) {
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn != NULL) return vn;
+ }
+
+ node = UP(cast->ensure_clause);
+ } else if (cast->rescue_clause != NULL) {
+ // https://bugs.ruby-lang.org/issues/21669
+ if (cast->else_clause == NULL || parser->version < PM_OPTIONS_VERSION_CRUBY_4_1) {
+ if (cast->statements == NULL) return NULL;
+
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn == NULL) return NULL;
+ if (void_node == NULL) void_node = vn;
+ }
+
+ for (pm_rescue_node_t *rescue_clause = cast->rescue_clause; rescue_clause != NULL; rescue_clause = rescue_clause->subsequent) {
+ pm_node_t *vn = pm_check_value_expression(parser, UP(rescue_clause->statements));
+
+ if (vn == NULL) {
+ // https://bugs.ruby-lang.org/issues/21669
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_1) {
+ return NULL;
+ }
+ void_node = NULL;
+ break;
+ }
+ }
+
+ if (cast->else_clause != NULL) {
+ node = UP(cast->else_clause);
+
+ // https://bugs.ruby-lang.org/issues/21669
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_1) {
+ pm_node_t *vn = pm_check_value_expression(parser, node);
+ if (vn != NULL) return vn;
+ }
+ } else {
+ return void_node;
+ }
+ } else {
+ node = UP(cast->statements);
+ }
+
+ break;
+ }
+ case PM_CASE_NODE: {
+ // https://bugs.ruby-lang.org/issues/21669
+ if (parser->version < PM_OPTIONS_VERSION_CRUBY_4_1) {
+ return NULL;
+ }
+
+ pm_case_node_t *cast = (pm_case_node_t *) node;
+ if (cast->else_clause == NULL) return NULL;
+
+ pm_node_t *condition;
+ PM_NODE_LIST_FOREACH(&cast->conditions, index, condition) {
+ assert(PM_NODE_TYPE_P(condition, PM_WHEN_NODE));
+
+ pm_when_node_t *cast = (pm_when_node_t *) condition;
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn == NULL) return NULL;
+ if (void_node == NULL) void_node = vn;
+ }
+
+ node = UP(cast->else_clause);
+ break;
+ }
+ case PM_CASE_MATCH_NODE: {
+ // https://bugs.ruby-lang.org/issues/21669
+ if (parser->version < PM_OPTIONS_VERSION_CRUBY_4_1) {
+ return NULL;
+ }
+
+ pm_case_match_node_t *cast = (pm_case_match_node_t *) node;
+ if (cast->else_clause == NULL) return NULL;
+
+ pm_node_t *condition;
+ PM_NODE_LIST_FOREACH(&cast->conditions, index, condition) {
+ assert(PM_NODE_TYPE_P(condition, PM_IN_NODE));
+
+ pm_in_node_t *cast = (pm_in_node_t *) condition;
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn == NULL) return NULL;
+ if (void_node == NULL) void_node = vn;
+ }
+
+ node = UP(cast->else_clause);
+ break;
+ }
+ case PM_ENSURE_NODE: {
+ pm_ensure_node_t *cast = (pm_ensure_node_t *) node;
+ node = UP(cast->statements);
+ break;
+ }
+ case PM_PARENTHESES_NODE: {
+ pm_parentheses_node_t *cast = (pm_parentheses_node_t *) node;
+ node = UP(cast->body);
+ break;
+ }
+ case PM_STATEMENTS_NODE: {
+ pm_statements_node_t *cast = (pm_statements_node_t *) node;
+
+ // https://bugs.ruby-lang.org/issues/21669
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_1) {
+ pm_node_t *body_part;
+ PM_NODE_LIST_FOREACH(&cast->body, index, body_part) {
+ switch (PM_NODE_TYPE(body_part)) {
+ case PM_CASE_VOID_VALUE:
+ if (void_node == NULL) {
+ void_node = body_part;
+ }
+ return void_node;
+ default: break;
+ }
+ }
+ }
+
+ node = cast->body.nodes[cast->body.size - 1];
+ break;
+ }
+ case PM_IF_NODE: {
+ pm_if_node_t *cast = (pm_if_node_t *) node;
+ if (cast->statements == NULL || cast->subsequent == NULL) {
+ return NULL;
+ }
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn == NULL) {
+ return NULL;
+ }
+ if (void_node == NULL) {
+ void_node = vn;
+ }
+ node = cast->subsequent;
+ break;
+ }
+ case PM_UNLESS_NODE: {
+ pm_unless_node_t *cast = (pm_unless_node_t *) node;
+ if (cast->statements == NULL || cast->else_clause == NULL) {
+ return NULL;
+ }
+ pm_node_t *vn = pm_check_value_expression(parser, UP(cast->statements));
+ if (vn == NULL) {
+ return NULL;
+ }
+ if (void_node == NULL) {
+ void_node = vn;
+ }
+ node = UP(cast->else_clause);
+ break;
+ }
+ case PM_ELSE_NODE: {
+ pm_else_node_t *cast = (pm_else_node_t *) node;
+ node = UP(cast->statements);
+ break;
+ }
+ case PM_AND_NODE: {
+ pm_and_node_t *cast = (pm_and_node_t *) node;
+ node = cast->left;
+ break;
+ }
+ case PM_OR_NODE: {
+ pm_or_node_t *cast = (pm_or_node_t *) node;
+ node = cast->left;
+ break;
+ }
+ case PM_LOCAL_VARIABLE_WRITE_NODE: {
+ pm_local_variable_write_node_t *cast = (pm_local_variable_write_node_t *) node;
+
+ pm_scope_t *scope = parser->current_scope;
+ for (uint32_t depth = 0; depth < cast->depth; depth++) scope = scope->previous;
+
+ pm_locals_read(&scope->locals, cast->name);
+ return NULL;
+ }
+ default:
+ return NULL;
+ }
+ }
+
+ return NULL;
+}
+
+static PRISM_INLINE void
+pm_assert_value_expression(pm_parser_t *parser, pm_node_t *node) {
+ pm_node_t *void_node = pm_check_value_expression(parser, node);
+ if (void_node != NULL) {
+ pm_parser_err_node(parser, void_node, PM_ERR_VOID_EXPRESSION);
+ }
+}
+
+/**
+ * Warn if the given node is a "void" statement.
+ */
+static void
+pm_void_statement_check(pm_parser_t *parser, const pm_node_t *node) {
+ const char *type = NULL;
+ int length = 0;
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_CLASS_VARIABLE_READ_NODE:
+ case PM_GLOBAL_VARIABLE_READ_NODE:
+ case PM_INSTANCE_VARIABLE_READ_NODE:
+ case PM_LOCAL_VARIABLE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ type = "a variable";
+ length = 10;
+ break;
+ case PM_CALL_NODE: {
+ const pm_call_node_t *cast = (const pm_call_node_t *) node;
+ if (cast->call_operator_loc.length > 0 || cast->message_loc.length == 0) break;
+
+ const pm_constant_t *message = pm_constant_pool_id_to_constant(&parser->constant_pool, cast->name);
+ switch (message->length) {
+ case 1:
+ switch (message->start[0]) {
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '%':
+ case '|':
+ case '^':
+ case '&':
+ case '>':
+ case '<':
+ type = (const char *) message->start;
+ length = 1;
+ break;
+ }
+ break;
+ case 2:
+ switch (message->start[1]) {
+ case '=':
+ if (message->start[0] == '<' || message->start[0] == '>' || message->start[0] == '!' || message->start[0] == '=') {
+ type = (const char *) message->start;
+ length = 2;
+ }
+ break;
+ case '@':
+ if (message->start[0] == '+' || message->start[0] == '-') {
+ type = (const char *) message->start;
+ length = 2;
+ }
+ break;
+ case '*':
+ if (message->start[0] == '*') {
+ type = (const char *) message->start;
+ length = 2;
+ }
+ break;
+ }
+ break;
+ case 3:
+ if (memcmp(message->start, "<=>", 3) == 0) {
+ type = "<=>";
+ length = 3;
+ }
+ break;
+ }
+
+ break;
+ }
+ case PM_CONSTANT_PATH_NODE:
+ type = "::";
+ length = 2;
+ break;
+ case PM_CONSTANT_READ_NODE:
+ type = "a constant";
+ length = 10;
+ break;
+ case PM_DEFINED_NODE:
+ type = "defined?";
+ length = 8;
+ break;
+ case PM_FALSE_NODE:
+ type = "false";
+ length = 5;
+ break;
+ case PM_FLOAT_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INTEGER_NODE:
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
+ case PM_INTERPOLATED_STRING_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ type = "a literal";
+ length = 9;
+ break;
+ case PM_NIL_NODE:
+ type = "nil";
+ length = 3;
+ break;
+ case PM_RANGE_NODE: {
+ const pm_range_node_t *cast = (const pm_range_node_t *) node;
+
+ if (PM_NODE_FLAG_P(cast, PM_RANGE_FLAGS_EXCLUDE_END)) {
+ type = "...";
+ length = 3;
+ } else {
+ type = "..";
+ length = 2;
+ }
+
+ break;
+ }
+ case PM_SELF_NODE:
+ type = "self";
+ length = 4;
+ break;
+ case PM_TRUE_NODE:
+ type = "true";
+ length = 4;
+ break;
+ default:
+ break;
+ }
+
+ if (type != NULL) {
+ PM_PARSER_WARN_NODE_FORMAT(parser, node, PM_WARN_VOID_STATEMENT, length, type);
+ }
+}
+
+/**
+ * Warn if any of the statements that are not the last statement in the list are
+ * a "void" statement.
+ */
+static void
+pm_void_statements_check(pm_parser_t *parser, const pm_statements_node_t *node, bool last_value) {
+ assert(node->body.size > 0);
+ const size_t size = node->body.size - (last_value ? 1 : 0);
+ for (size_t index = 0; index < size; index++) {
+ pm_void_statement_check(parser, node->body.nodes[index]);
+ }
+}
+
+/**
+ * When we're handling the predicate of a conditional, we need to know our
+ * context in order to determine the kind of warning we should deliver to the
+ * user.
+ */
+typedef enum {
+ PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL,
+ PM_CONDITIONAL_PREDICATE_TYPE_FLIP_FLOP,
+ PM_CONDITIONAL_PREDICATE_TYPE_NOT
+} pm_conditional_predicate_type_t;
+
+/**
+ * Add a warning to the parser if the predicate of a conditional is a literal.
+ */
+static void
+pm_parser_warn_conditional_predicate_literal(pm_parser_t *parser, pm_node_t *node, pm_conditional_predicate_type_t type, pm_diagnostic_id_t diag_id, const char *prefix) {
+ switch (type) {
+ case PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL:
+ PM_PARSER_WARN_NODE_FORMAT(parser, node, diag_id, prefix, "condition");
+ break;
+ case PM_CONDITIONAL_PREDICATE_TYPE_FLIP_FLOP:
+ PM_PARSER_WARN_NODE_FORMAT(parser, node, diag_id, prefix, "flip-flop");
+ break;
+ case PM_CONDITIONAL_PREDICATE_TYPE_NOT:
+ break;
+ }
+}
+
+/**
+ * Return true if the value being written within the predicate of a conditional
+ * is a literal value.
+ */
+static bool
+pm_conditional_predicate_warn_write_literal_p(const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ARRAY_NODE: {
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) return true;
+
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ if (!pm_conditional_predicate_warn_write_literal_p(cast->elements.nodes[index])) return false;
+ }
+
+ return true;
+ }
+ case PM_HASH_NODE: {
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) return true;
+
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ const pm_node_t *element = cast->elements.nodes[index];
+ if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE)) return false;
+
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) element;
+ if (!pm_conditional_predicate_warn_write_literal_p(assoc->key) || !pm_conditional_predicate_warn_write_literal_p(assoc->value)) return false;
+ }
+
+ return true;
+ }
+ case PM_FALSE_NODE:
+ case PM_FLOAT_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INTEGER_NODE:
+ case PM_NIL_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_TRUE_NODE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**
+ * Add a warning to the parser if the value that is being written inside of a
+ * predicate to a conditional is a literal.
+ */
+static PRISM_INLINE void
+pm_conditional_predicate_warn_write_literal(pm_parser_t *parser, const pm_node_t *node) {
+ if (pm_conditional_predicate_warn_write_literal_p(node)) {
+ pm_parser_warn_node(parser, node, parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_WARN_EQUAL_IN_CONDITIONAL_3_3 : PM_WARN_EQUAL_IN_CONDITIONAL);
+ }
+}
+
+/**
+ * The predicate of conditional nodes can change what would otherwise be regular
+ * nodes into specialized nodes. For example:
+ *
+ * if foo .. bar => RangeNode becomes FlipFlopNode
+ * if foo and bar .. baz => RangeNode becomes FlipFlopNode
+ * if /foo/ => RegularExpressionNode becomes MatchLastLineNode
+ * if /foo #{bar}/ => InterpolatedRegularExpressionNode becomes InterpolatedMatchLastLineNode
+ *
+ * We also want to warn the user if they're using a static literal as a
+ * predicate or writing a static literal as the predicate.
+ */
+static void
+pm_conditional_predicate(pm_parser_t *parser, pm_node_t *node, pm_conditional_predicate_type_t type) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_AND_NODE: {
+ pm_and_node_t *cast = (pm_and_node_t *) node;
+ pm_conditional_predicate(parser, cast->left, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ pm_conditional_predicate(parser, cast->right, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ break;
+ }
+ case PM_OR_NODE: {
+ pm_or_node_t *cast = (pm_or_node_t *) node;
+ pm_conditional_predicate(parser, cast->left, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ pm_conditional_predicate(parser, cast->right, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ break;
+ }
+ case PM_PARENTHESES_NODE: {
+ pm_parentheses_node_t *cast = (pm_parentheses_node_t *) node;
+
+ if ((cast->body != NULL) && PM_NODE_TYPE_P(cast->body, PM_STATEMENTS_NODE)) {
+ pm_statements_node_t *statements = (pm_statements_node_t *) cast->body;
+ if (statements->body.size == 1) pm_conditional_predicate(parser, statements->body.nodes[0], type);
+ }
+
+ break;
+ }
+ case PM_BEGIN_NODE: {
+ pm_begin_node_t *cast = (pm_begin_node_t *) node;
+ if (cast->statements != NULL) {
+ pm_statements_node_t *statements = cast->statements;
+ if (statements->body.size == 1) pm_conditional_predicate(parser, statements->body.nodes[0], type);
+ }
+ break;
+ }
+ case PM_RANGE_NODE: {
+ pm_range_node_t *cast = (pm_range_node_t *) node;
+
+ if (cast->left != NULL) pm_conditional_predicate(parser, cast->left, PM_CONDITIONAL_PREDICATE_TYPE_FLIP_FLOP);
+ if (cast->right != NULL) pm_conditional_predicate(parser, cast->right, PM_CONDITIONAL_PREDICATE_TYPE_FLIP_FLOP);
+
+ // Here we change the range node into a flip flop node. We can do
+ // this since the nodes are exactly the same except for the type.
+ // We're only asserting against the size when we should probably
+ // assert against the entire layout, but we'll assume tests will
+ // catch this.
+ assert(sizeof(pm_range_node_t) == sizeof(pm_flip_flop_node_t));
+ node->type = PM_FLIP_FLOP_NODE;
+
+ break;
+ }
+ case PM_REGULAR_EXPRESSION_NODE:
+ // Here we change the regular expression node into a match last line
+ // node. We can do this since the nodes are exactly the same except
+ // for the type.
+ assert(sizeof(pm_regular_expression_node_t) == sizeof(pm_match_last_line_node_t));
+ node->type = PM_MATCH_LAST_LINE_NODE;
+
+ if (!PM_PARSER_COMMAND_LINE_OPTION_E(parser)) {
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_DEFAULT, "regex ");
+ }
+
+ break;
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
+ // Here we change the interpolated regular expression node into an
+ // interpolated match last line node. We can do this since the nodes
+ // are exactly the same except for the type.
+ assert(sizeof(pm_interpolated_regular_expression_node_t) == sizeof(pm_interpolated_match_last_line_node_t));
+ node->type = PM_INTERPOLATED_MATCH_LAST_LINE_NODE;
+
+ if (!PM_PARSER_COMMAND_LINE_OPTION_E(parser)) {
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_VERBOSE, "regex ");
+ }
+
+ break;
+ case PM_INTEGER_NODE:
+ if (type == PM_CONDITIONAL_PREDICATE_TYPE_FLIP_FLOP) {
+ if (!PM_PARSER_COMMAND_LINE_OPTION_E(parser)) {
+ pm_parser_warn_node(parser, node, PM_WARN_INTEGER_IN_FLIP_FLOP);
+ }
+ } else {
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_VERBOSE, "");
+ }
+ break;
+ case PM_STRING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_INTERPOLATED_STRING_NODE:
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_DEFAULT, "string ");
+ break;
+ case PM_SYMBOL_NODE:
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_VERBOSE, "symbol ");
+ break;
+ case PM_SOURCE_LINE_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_FLOAT_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_IMAGINARY_NODE:
+ pm_parser_warn_conditional_predicate_literal(parser, node, type, PM_WARN_LITERAL_IN_CONDITION_VERBOSE, "");
+ break;
+ case PM_CLASS_VARIABLE_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_class_variable_write_node_t *) node)->value);
+ break;
+ case PM_CONSTANT_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_constant_write_node_t *) node)->value);
+ break;
+ case PM_GLOBAL_VARIABLE_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_global_variable_write_node_t *) node)->value);
+ break;
+ case PM_INSTANCE_VARIABLE_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_instance_variable_write_node_t *) node)->value);
+ break;
+ case PM_LOCAL_VARIABLE_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_local_variable_write_node_t *) node)->value);
+ break;
+ case PM_MULTI_WRITE_NODE:
+ pm_conditional_predicate_warn_write_literal(parser, ((pm_multi_write_node_t *) node)->value);
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * This is a special out parameter to the parse_arguments_list function that
+ * includes opening and closing parentheses in addition to the arguments since
+ * it's so common. It is handy to use when passing argument information to one
+ * of the call node creation functions.
+ */
+typedef struct {
+ /** The optional location of the opening parenthesis or bracket. */
+ pm_location_t opening_loc;
+
+ /** The lazily-allocated optional arguments node. */
+ pm_arguments_node_t *arguments;
+
+ /** The optional location of the closing parenthesis or bracket. */
+ pm_location_t closing_loc;
+
+ /** The optional block attached to the call. */
+ pm_node_t *block;
+
+ /** The flag indicating whether this arguments list has forwarding argument. */
+ bool has_forwarding;
+} pm_arguments_t;
+
+/**
+ * Retrieve the end location of a `pm_arguments_t` object.
+ */
+static PRISM_INLINE const pm_location_t *
+pm_arguments_end(pm_arguments_t *arguments) {
+ if (arguments->block != NULL) {
+ uint32_t end = PM_NODE_END(arguments->block);
+
+ if (arguments->closing_loc.length > 0) {
+ uint32_t arguments_end = PM_LOCATION_END(&arguments->closing_loc);
+ if (arguments_end > end) {
+ return &arguments->closing_loc;
+ }
+ }
+ return &arguments->block->location;
+ }
+ if (arguments->closing_loc.length > 0) {
+ return &arguments->closing_loc;
+ }
+ if (arguments->arguments != NULL) {
+ return &arguments->arguments->base.location;
+ }
+ if (arguments->opening_loc.length > 0) {
+ return &arguments->opening_loc;
+ }
+ return NULL;
+}
+
+/**
+ * Check that we're not about to attempt to attach a brace block to a call that
+ * has arguments without parentheses.
+ */
+static void
+pm_arguments_validate_block(pm_parser_t *parser, pm_arguments_t *arguments, pm_block_node_t *block) {
+ // First, check that we have arguments and that we don't have a closing
+ // location for them.
+ if (arguments->arguments == NULL || arguments->closing_loc.length > 0) {
+ return;
+ }
+
+ // Next, check that we don't have a single parentheses argument. This would
+ // look like:
+ //
+ // foo (1) {}
+ //
+ // In this case, it's actually okay for the block to be attached to the
+ // call, even though it looks like it's attached to the argument.
+ if (arguments->arguments->arguments.size == 1 && PM_NODE_TYPE_P(arguments->arguments->arguments.nodes[0], PM_PARENTHESES_NODE)) {
+ return;
+ }
+
+ // If we didn't hit a case before this check, then at this point we need to
+ // add a syntax error.
+ pm_parser_err_node(parser, UP(block), PM_ERR_ARGUMENT_UNEXPECTED_BLOCK);
+}
+
+/******************************************************************************/
+/* Basic character checks */
+/******************************************************************************/
+
+/**
+ * This function is used extremely frequently to lex all of the identifiers in a
+ * source file, so it's important that it be as fast as possible. For this
+ * reason we have the encoding_changed boolean to check if we need to go through
+ * the function pointer or can just directly use the UTF-8 functions.
+ */
+static PRISM_INLINE size_t
+char_is_identifier_start(const pm_parser_t *parser, const uint8_t *b, ptrdiff_t n) {
+ if (n <= 0) return 0;
+
+ if (parser->encoding_changed) {
+ size_t width;
+
+ if ((width = parser->encoding->alpha_char(b, n)) != 0) {
+ return width;
+ } else if (*b == '_') {
+ return 1;
+ } else if (*b >= 0x80) {
+ return parser->encoding->char_width(b, n);
+ } else {
+ return 0;
+ }
+ } else if (*b < 0x80) {
+ return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT ? 1 : 0) || (*b == '_');
+ } else {
+ return pm_encoding_utf_8_char_width(b, n);
+ }
+}
+
+/**
+ * Similar to char_is_identifier but this function assumes that the encoding
+ * has not been changed.
+ */
+static PRISM_INLINE size_t
+char_is_identifier_utf8(const uint8_t *b, ptrdiff_t n) {
+ if (n <= 0) {
+ return 0;
+ } else if (*b < 0x80) {
+ return (*b == '_') || (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT ? 1 : 0);
+ } else {
+ return pm_encoding_utf_8_char_width(b, n);
+ }
+}
+
+/**
+ * Scan forward through ASCII identifier characters (a-z, A-Z, 0-9, _) using
+ * wide operations. Returns the number of leading ASCII identifier bytes.
+ * Callers must handle any remaining bytes (short tail or non-ASCII/UTF-8)
+ * with a byte-at-a-time loop.
+ *
+ * Up to three optimized implementations are selected at compile time, with a
+ * no-op fallback for unsupported platforms:
+ * 1. NEON — processes 16 bytes per iteration on aarch64.
+ * 2. SSSE3 — processes 16 bytes per iteration on x86-64.
+ * 3. SWAR — little-endian fallback, processes 8 bytes per iteration.
+ */
+
+#if defined(PRISM_HAS_NEON)
+#include <arm_neon.h>
+
+static PRISM_INLINE size_t
+scan_identifier_ascii(const uint8_t *start, const uint8_t *end) {
+ const uint8_t *cursor = start;
+
+ // Nibble-based lookup tables for classifying [a-zA-Z0-9_].
+ // Each high nibble is assigned a unique bit; the low nibble table
+ // contains the OR of bits for all high nibbles that have an
+ // identifier character at that low nibble position. A byte is an
+ // identifier character iff (low_lut[lo] & high_lut[hi]) != 0.
+ static const uint8_t low_lut_data[16] = {
+ 0x15, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
+ 0x1F, 0x1F, 0x1E, 0x0A, 0x0A, 0x0A, 0x0A, 0x0E
+ };
+ static const uint8_t high_lut_data[16] = {
+ 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ const uint8x16_t low_lut = vld1q_u8(low_lut_data);
+ const uint8x16_t high_lut = vld1q_u8(high_lut_data);
+ const uint8x16_t mask_0f = vdupq_n_u8(0x0F);
+
+ while (cursor + 16 <= end) {
+ uint8x16_t v = vld1q_u8(cursor);
+
+ uint8x16_t lo_class = vqtbl1q_u8(low_lut, vandq_u8(v, mask_0f));
+ uint8x16_t hi_class = vqtbl1q_u8(high_lut, vshrq_n_u8(v, 4));
+ uint8x16_t ident = vandq_u8(lo_class, hi_class);
+
+ // Fast check: if the per-byte minimum is nonzero, every byte matched.
+ if (vminvq_u8(ident) != 0) {
+ cursor += 16;
+ continue;
+ }
+
+ // Find the first non-identifier byte (zero in ident).
+ uint8x16_t is_zero = vceqq_u8(ident, vdupq_n_u8(0));
+ uint64_t lo = vgetq_lane_u64(vreinterpretq_u64_u8(is_zero), 0);
+
+ if (lo != 0) {
+ cursor += pm_ctzll(lo) / 8;
+ } else {
+ uint64_t hi = vgetq_lane_u64(vreinterpretq_u64_u8(is_zero), 1);
+ cursor += 8 + pm_ctzll(hi) / 8;
+ }
+
+ return (size_t) (cursor - start);
+ }
+
+ return (size_t) (cursor - start);
+}
+
+#elif defined(PRISM_HAS_SSSE3)
+#include <tmmintrin.h>
+
+static PRISM_INLINE size_t
+scan_identifier_ascii(const uint8_t *start, const uint8_t *end) {
+ const uint8_t *cursor = start;
+
+ while (cursor + 16 <= end) {
+ __m128i v = _mm_loadu_si128((const __m128i *) cursor);
+ __m128i zero = _mm_setzero_si128();
+
+ // Unsigned range check via saturating subtraction:
+ // byte >= lo ⟺ saturate(lo - byte) == 0
+ // byte <= hi ⟺ saturate(byte - hi) == 0
+
+ // Fold case: OR with 0x20 maps A-Z to a-z.
+ __m128i lowered = _mm_or_si128(v, _mm_set1_epi8(0x20));
+ __m128i letter = _mm_and_si128(
+ _mm_cmpeq_epi8(_mm_subs_epu8(_mm_set1_epi8(0x61), lowered), zero),
+ _mm_cmpeq_epi8(_mm_subs_epu8(lowered, _mm_set1_epi8(0x7A)), zero));
+
+ __m128i digit = _mm_and_si128(
+ _mm_cmpeq_epi8(_mm_subs_epu8(_mm_set1_epi8(0x30), v), zero),
+ _mm_cmpeq_epi8(_mm_subs_epu8(v, _mm_set1_epi8(0x39)), zero));
+
+ __m128i underscore = _mm_cmpeq_epi8(v, _mm_set1_epi8(0x5F));
+
+ __m128i ident = _mm_or_si128(_mm_or_si128(letter, digit), underscore);
+ int mask = _mm_movemask_epi8(ident);
+
+ if (mask == 0xFFFF) {
+ cursor += 16;
+ continue;
+ }
+
+ cursor += pm_ctzll((uint64_t) (~mask & 0xFFFF));
+ return (size_t) (cursor - start);
+ }
+
+ return (size_t) (cursor - start);
+}
+
+// The SWAR path uses pm_ctzll to find the first non-matching byte within a
+// word, which only yields the correct byte index on little-endian targets.
+// We gate on a positive little-endian check so that unknown-endianness
+// platforms safely fall through to the no-op fallback.
+#elif defined(PRISM_HAS_SWAR)
+
+/**
+ * Portable SWAR fallback — processes 8 bytes per iteration.
+ *
+ * The byte-wise range checks avoid cross-byte borrows by pre-setting the high
+ * bit of each byte before subtraction: (byte | 0x80) - lo has a minimum value
+ * of 0x80 - 0x7F = 1, so underflow (and thus a borrow into the next byte) is
+ * impossible. The result has bit 7 set if and only if byte >= lo. The same
+ * reasoning applies to the upper-bound direction.
+ */
+static PRISM_INLINE size_t
+scan_identifier_ascii(const uint8_t *start, const uint8_t *end) {
+ static const uint64_t ones = 0x0101010101010101ULL;
+ static const uint64_t highs = 0x8080808080808080ULL;
+ const uint8_t *cursor = start;
+
+ while (cursor + 8 <= end) {
+ uint64_t word;
+ memcpy(&word, cursor, 8);
+
+ // Bail on any non-ASCII byte.
+ if (word & highs) break;
+
+ uint64_t digit = ((word | highs) - ones * 0x30) & ((ones * 0x39 | highs) - word) & highs;
+
+ // Fold upper- and lowercase together by forcing bit 5 (OR 0x20),
+ // then check the lowercase range once. A-Z maps to a-z; the
+ // only non-letter byte that could alias into [0x61,0x7A] is one
+ // whose original value was in [0x41,0x5A] — which is exactly
+ // the uppercase letters we want to match.
+ uint64_t lowered = word | (ones * 0x20);
+ uint64_t letter = ((lowered | highs) - ones * 0x61) & ((ones * 0x7A | highs) - lowered) & highs;
+
+ // Standard SWAR "has zero byte" idiom on (word XOR 0x5F) to find
+ // bytes equal to underscore. Safe from cross-byte borrows because
+ // the ASCII guard above ensures all bytes are < 0x80.
+ uint64_t xor_us = word ^ (ones * 0x5F);
+ uint64_t underscore = (xor_us - ones) & ~xor_us & highs;
+
+ uint64_t ident = digit | letter | underscore;
+
+ if (ident == highs) {
+ cursor += 8;
+ continue;
+ }
+
+ // Find the first non-identifier byte. On little-endian the first
+ // byte sits in the least-significant position.
+ uint64_t not_ident = ~ident & highs;
+ cursor += pm_ctzll(not_ident) / 8;
+ return (size_t) (cursor - start);
+ }
+
+ return (size_t) (cursor - start);
+}
+
+#else
+
+// No-op fallback for big-endian or other unsupported platforms.
+// The caller's byte-at-a-time loop handles everything.
+#define scan_identifier_ascii(start, end) ((size_t) 0)
+
+#endif
+
+/**
+ * Like the above, this function is also used extremely frequently to lex all of
+ * the identifiers in a source file once the first character has been found. So
+ * it's important that it be as fast as possible.
+ */
+static PRISM_INLINE size_t
+char_is_identifier(const pm_parser_t *parser, const uint8_t *b, ptrdiff_t n) {
+ if (n <= 0) {
+ return 0;
+ } else if (parser->encoding_changed) {
+ size_t width;
+
+ if ((width = parser->encoding->alnum_char(b, n)) != 0) {
+ return width;
+ } else if (*b == '_') {
+ return 1;
+ } else if (*b >= 0x80) {
+ return parser->encoding->char_width(b, n);
+ } else {
+ return 0;
+ }
+ } else {
+ return char_is_identifier_utf8(b, n);
+ }
+}
+
+// Here we're defining a perfect hash for the characters that are allowed in
+// global names. This is used to quickly check the next character after a $ to
+// see if it's a valid character for a global name.
+#define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
+#define PUNCT(idx) ( \
+ BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
+ BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
+ BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
+ BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
+ BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
+ BIT('0', idx))
+
+const unsigned int pm_global_name_punctuation_hash[(0x7e - 0x20 + 31) / 32] = { PUNCT(0), PUNCT(1), PUNCT(2) };
+
+#undef BIT
+#undef PUNCT
+
+static PRISM_INLINE bool
+char_is_global_name_punctuation(const uint8_t b) {
+ const unsigned int i = (const unsigned int) b;
+ if (i <= 0x20 || 0x7e < i) return false;
+
+ return (pm_global_name_punctuation_hash[(i - 0x20) / 32] >> (i % 32)) & 1;
+}
+
+static PRISM_INLINE bool
+token_is_setter_name(pm_token_t *token) {
+ return (
+ (token->type == PM_TOKEN_BRACKET_LEFT_RIGHT_EQUAL) ||
+ ((token->type == PM_TOKEN_IDENTIFIER) &&
+ (token->end - token->start >= 2) &&
+ (token->end[-1] == '='))
+ );
+}
+
+/**
+ * Returns true if the given local variable is a keyword.
+ */
+static bool
+pm_local_is_keyword(const char *source, size_t length) {
+#define KEYWORD(name) if (memcmp(source, name, length) == 0) return true
+
+ switch (length) {
+ case 2:
+ switch (source[0]) {
+ case 'd': KEYWORD("do"); return false;
+ case 'i': KEYWORD("if"); KEYWORD("in"); return false;
+ case 'o': KEYWORD("or"); return false;
+ default: return false;
+ }
+ case 3:
+ switch (source[0]) {
+ case 'a': KEYWORD("and"); return false;
+ case 'd': KEYWORD("def"); return false;
+ case 'e': KEYWORD("end"); return false;
+ case 'f': KEYWORD("for"); return false;
+ case 'n': KEYWORD("nil"); KEYWORD("not"); return false;
+ default: return false;
+ }
+ case 4:
+ switch (source[0]) {
+ case 'c': KEYWORD("case"); return false;
+ case 'e': KEYWORD("else"); return false;
+ case 'n': KEYWORD("next"); return false;
+ case 'r': KEYWORD("redo"); return false;
+ case 's': KEYWORD("self"); return false;
+ case 't': KEYWORD("then"); KEYWORD("true"); return false;
+ case 'w': KEYWORD("when"); return false;
+ default: return false;
+ }
+ case 5:
+ switch (source[0]) {
+ case 'a': KEYWORD("alias"); return false;
+ case 'b': KEYWORD("begin"); KEYWORD("break"); return false;
+ case 'c': KEYWORD("class"); return false;
+ case 'e': KEYWORD("elsif"); return false;
+ case 'f': KEYWORD("false"); return false;
+ case 'r': KEYWORD("retry"); return false;
+ case 's': KEYWORD("super"); return false;
+ case 'u': KEYWORD("undef"); KEYWORD("until"); return false;
+ case 'w': KEYWORD("while"); return false;
+ case 'y': KEYWORD("yield"); return false;
+ default: return false;
+ }
+ case 6:
+ switch (source[0]) {
+ case 'e': KEYWORD("ensure"); return false;
+ case 'm': KEYWORD("module"); return false;
+ case 'r': KEYWORD("rescue"); KEYWORD("return"); return false;
+ case 'u': KEYWORD("unless"); return false;
+ default: return false;
+ }
+ case 8:
+ KEYWORD("__LINE__");
+ KEYWORD("__FILE__");
+ return false;
+ case 12:
+ KEYWORD("__ENCODING__");
+ return false;
+ default:
+ return false;
+ }
+
+#undef KEYWORD
+}
+
+/******************************************************************************/
+/* Node flag handling functions */
+/******************************************************************************/
+
+/**
+ * Set the given flag on the given node.
+ */
+static PRISM_INLINE void
+pm_node_flag_set(pm_node_t *node, pm_node_flags_t flag) {
+ node->flags |= flag;
+}
+
+/**
+ * Remove the given flag from the given node.
+ */
+static PRISM_INLINE void
+pm_node_flag_unset(pm_node_t *node, pm_node_flags_t flag) {
+ node->flags &= (pm_node_flags_t) ~flag;
+}
+
+/**
+ * Set the repeated parameter flag on the given node.
+ */
+static PRISM_INLINE void
+pm_node_flag_set_repeated_parameter(pm_node_t *node) {
+ assert(PM_NODE_TYPE(node) == PM_BLOCK_LOCAL_VARIABLE_NODE ||
+ PM_NODE_TYPE(node) == PM_BLOCK_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_KEYWORD_REST_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_OPTIONAL_KEYWORD_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_OPTIONAL_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_REQUIRED_KEYWORD_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_REQUIRED_PARAMETER_NODE ||
+ PM_NODE_TYPE(node) == PM_REST_PARAMETER_NODE);
+
+ pm_node_flag_set(node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER);
+}
+
+/******************************************************************************/
+/* Node creation functions */
+/******************************************************************************/
+
+/**
+ * When you have an encoding flag on a regular expression, it takes precedence
+ * over all of the previously set encoding flags. So we need to mask off any
+ * previously set encoding flags before setting the new one.
+ */
+#define PM_REGULAR_EXPRESSION_ENCODING_MASK ~(PM_REGULAR_EXPRESSION_FLAGS_EUC_JP | PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT | PM_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J | PM_REGULAR_EXPRESSION_FLAGS_UTF_8)
+
+/**
+ * Parse out the options for a regular expression.
+ */
+static PRISM_INLINE pm_node_flags_t
+pm_regular_expression_flags_create(pm_parser_t *parser, const pm_token_t *closing) {
+ pm_node_flags_t flags = 0;
+
+ if (closing->type == PM_TOKEN_REGEXP_END) {
+ pm_buffer_t unknown_flags = { 0 };
+
+ for (const uint8_t *flag = closing->start + 1; flag < closing->end; flag++) {
+ switch (*flag) {
+ case 'i': flags |= PM_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE; break;
+ case 'm': flags |= PM_REGULAR_EXPRESSION_FLAGS_MULTI_LINE; break;
+ case 'x': flags |= PM_REGULAR_EXPRESSION_FLAGS_EXTENDED; break;
+ case 'o': flags |= PM_REGULAR_EXPRESSION_FLAGS_ONCE; break;
+
+ case 'e': flags = (pm_node_flags_t) (((pm_node_flags_t) (flags & PM_REGULAR_EXPRESSION_ENCODING_MASK)) | PM_REGULAR_EXPRESSION_FLAGS_EUC_JP); break;
+ case 'n': flags = (pm_node_flags_t) (((pm_node_flags_t) (flags & PM_REGULAR_EXPRESSION_ENCODING_MASK)) | PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT); break;
+ case 's': flags = (pm_node_flags_t) (((pm_node_flags_t) (flags & PM_REGULAR_EXPRESSION_ENCODING_MASK)) | PM_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J); break;
+ case 'u': flags = (pm_node_flags_t) (((pm_node_flags_t) (flags & PM_REGULAR_EXPRESSION_ENCODING_MASK)) | PM_REGULAR_EXPRESSION_FLAGS_UTF_8); break;
+
+ default: pm_buffer_append_byte(&unknown_flags, *flag);
+ }
+ }
+
+ size_t unknown_flags_length = pm_buffer_length(&unknown_flags);
+ if (unknown_flags_length != 0) {
+ const char *word = unknown_flags_length >= 2 ? "options" : "option";
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, PM_ERR_REGEXP_UNKNOWN_OPTIONS, word, unknown_flags_length, pm_buffer_value(&unknown_flags));
+ }
+ pm_buffer_cleanup(&unknown_flags);
+ }
+
+ return flags;
+}
+
+#undef PM_REGULAR_EXPRESSION_ENCODING_MASK
+
+static pm_statements_node_t *
+pm_statements_node_create(pm_parser_t *parser);
+
+static void
+pm_statements_node_body_append(pm_parser_t *parser, pm_statements_node_t *node, pm_node_t *statement, bool newline);
+
+static size_t
+pm_statements_node_body_length(pm_statements_node_t *node);
+
+/**
+ * Move an integer's values array into the arena. If the integer has heap-
+ * allocated values, copy them to the arena and free the original.
+ */
+static PRISM_INLINE void
+pm_integer_arena_move(pm_arena_t *arena, pm_integer_t *integer) {
+ if (integer->values != NULL) {
+ size_t byte_size = integer->length * sizeof(uint32_t);
+ uint32_t *old_values = integer->values;
+ integer->values = (uint32_t *) pm_arena_memdup(arena, old_values, byte_size, PRISM_ALIGNOF(uint32_t));
+ xfree(old_values);
+ }
+}
+
+/**
+ * Allocate a new ErrorRecoveryNode node with no unexpected child.
+ */
+static pm_error_recovery_node_t *
+pm_error_recovery_node_create(pm_parser_t *parser, uint32_t start, uint32_t length) {
+ return pm_error_recovery_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = length }),
+ NULL
+ );
+}
+
+/**
+ * Allocate a new ErrorRecoveryNode node wrapping an unexpected child node.
+ */
+static pm_error_recovery_node_t *
+pm_error_recovery_node_create_unexpected(pm_parser_t *parser, pm_node_t *unexpected) {
+ return pm_error_recovery_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ unexpected->location,
+ unexpected
+ );
+}
+
+/**
+ * Allocate and initialize a new AliasGlobalVariableNode node.
+ */
+static pm_alias_global_variable_node_t *
+pm_alias_global_variable_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t *new_name, pm_node_t *old_name) {
+ assert(keyword->type == PM_TOKEN_KEYWORD_ALIAS);
+
+ return pm_alias_global_variable_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, old_name),
+ new_name,
+ old_name,
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new AliasMethodNode node.
+ */
+static pm_alias_method_node_t *
+pm_alias_method_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t *new_name, pm_node_t *old_name) {
+ assert(keyword->type == PM_TOKEN_KEYWORD_ALIAS);
+
+ return pm_alias_method_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, old_name),
+ new_name,
+ old_name,
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate a new AlternationPatternNode node.
+ */
+static pm_alternation_pattern_node_t *
+pm_alternation_pattern_node_create(pm_parser_t *parser, pm_node_t *left, pm_node_t *right, const pm_token_t *operator) {
+ return pm_alternation_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(left, right),
+ left,
+ right,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new and node.
+ */
+static pm_and_node_t *
+pm_and_node_create(pm_parser_t *parser, pm_node_t *left, const pm_token_t *operator, pm_node_t *right) {
+ pm_assert_value_expression(parser, left);
+
+ return pm_and_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(left, right),
+ left,
+ right,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate an initialize a new arguments node.
+ */
+static pm_arguments_node_t *
+pm_arguments_node_create(pm_parser_t *parser) {
+ return pm_arguments_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 })
+ );
+}
+
+/**
+ * Return the size of the given arguments node.
+ */
+static size_t
+pm_arguments_node_size(pm_arguments_node_t *node) {
+ return node->arguments.size;
+}
+
+/**
+ * Append an argument to an arguments node.
+ */
+static void
+pm_arguments_node_arguments_append(pm_arena_t *arena, pm_arguments_node_t *node, pm_node_t *argument) {
+ if (pm_arguments_node_size(node) == 0) {
+ PM_NODE_START_SET_NODE(node, argument);
+ }
+
+ if (PM_NODE_END(node) < PM_NODE_END(argument)) {
+ PM_NODE_LENGTH_SET_NODE(node, argument);
+ }
+
+ pm_node_list_append(arena, &node->arguments, argument);
+
+ if (PM_NODE_TYPE_P(argument, PM_SPLAT_NODE)) {
+ if (PM_NODE_FLAG_P(node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT)) {
+ pm_node_flag_set(UP(node), PM_ARGUMENTS_NODE_FLAGS_CONTAINS_MULTIPLE_SPLATS);
+ } else {
+ pm_node_flag_set(UP(node), PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
+ }
+ }
+}
+
+/**
+ * Allocate and initialize a new ArrayNode node.
+ */
+static pm_array_node_t *
+pm_array_node_create(pm_parser_t *parser, const pm_token_t *opening) {
+ if (opening == NULL) {
+ return pm_array_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+ } else {
+ return pm_array_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, opening)
+ );
+ }
+}
+
+/**
+ * Append an argument to an array node.
+ */
+static PRISM_INLINE void
+pm_array_node_elements_append(pm_arena_t *arena, pm_array_node_t *node, pm_node_t *element) {
+ if (!node->elements.size && !node->opening_loc.length) {
+ PM_NODE_START_SET_NODE(node, element);
+ }
+
+ pm_node_list_append(arena, &node->elements, element);
+ PM_NODE_LENGTH_SET_NODE(node, element);
+
+ // If the element is not a static literal, then the array is not a static
+ // literal. Turn that flag off.
+ if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || !PM_NODE_FLAG_P(element, PM_NODE_FLAG_STATIC_LITERAL)) {
+ pm_node_flag_unset(UP(node), PM_NODE_FLAG_STATIC_LITERAL);
+ }
+
+ if (PM_NODE_TYPE_P(element, PM_SPLAT_NODE)) {
+ pm_node_flag_set(UP(node), PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT);
+ }
+}
+
+/**
+ * Set the closing token and end location of an array node.
+ */
+static void
+pm_array_node_close_set(const pm_parser_t *parser, pm_array_node_t *node, const pm_token_t *closing) {
+ assert(closing->type == PM_TOKEN_BRACKET_RIGHT || closing->type == PM_TOKEN_STRING_END || closing->type == 0);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+ node->closing_loc = TOK2LOC(parser, closing);
+}
+
+/**
+ * Allocate and initialize a new array pattern node. The node list given in the
+ * nodes parameter is guaranteed to have at least two nodes.
+ */
+static pm_array_pattern_node_t *
+pm_array_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *nodes) {
+ pm_array_pattern_node_t *node = pm_array_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(nodes->nodes[0], nodes->nodes[nodes->size - 1]),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+
+ // For now we're going to just copy over each pointer manually. This could be
+ // much more efficient, as we could instead resize the node list.
+ bool found_rest = false;
+ pm_node_t *child;
+
+ PM_NODE_LIST_FOREACH(nodes, index, child) {
+ if (!found_rest && (PM_NODE_TYPE_P(child, PM_SPLAT_NODE) || PM_NODE_TYPE_P(child, PM_IMPLICIT_REST_NODE))) {
+ node->rest = child;
+ found_rest = true;
+ } else if (found_rest) {
+ pm_node_list_append(parser->arena, &node->posts, child);
+ } else {
+ pm_node_list_append(parser->arena, &node->requireds, child);
+ }
+ }
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new array pattern node from a single rest node.
+ */
+static pm_array_pattern_node_t *
+pm_array_pattern_node_rest_create(pm_parser_t *parser, pm_node_t *rest) {
+ return pm_array_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODE(rest),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ rest,
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Allocate and initialize a new array pattern node from a constant and opening
+ * and closing tokens.
+ */
+static pm_array_pattern_node_t *
+pm_array_pattern_node_constant_create(pm_parser_t *parser, pm_node_t *constant, const pm_token_t *opening, const pm_token_t *closing) {
+ return pm_array_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODE_TOKEN(parser, constant, closing),
+ constant,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new array pattern node from an opening and closing
+ * token.
+ */
+static pm_array_pattern_node_t *
+pm_array_pattern_node_empty_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *closing) {
+ return pm_array_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+static PRISM_INLINE void
+pm_array_pattern_node_requireds_append(pm_arena_t *arena, pm_array_pattern_node_t *node, pm_node_t *inner) {
+ pm_node_list_append(arena, &node->requireds, inner);
+}
+
+/**
+ * Allocate and initialize a new assoc node.
+ */
+static pm_assoc_node_t *
+pm_assoc_node_create(pm_parser_t *parser, pm_node_t *key, const pm_token_t *operator, pm_node_t *value) {
+ uint32_t end;
+
+ if (value != NULL && PM_NODE_END(value) > PM_NODE_END(key)) {
+ end = PM_NODE_END(value);
+ } else if (operator != NULL) {
+ end = PM_TOKEN_END(parser, operator);
+ } else {
+ end = PM_NODE_END(key);
+ }
+
+ // Hash string keys will be frozen, so we can mark them as frozen here so
+ // that the compiler picks them up and also when we check for static literal
+ // on the keys it gets factored in.
+ if (PM_NODE_TYPE_P(key, PM_STRING_NODE)) {
+ key->flags |= PM_STRING_FLAGS_FROZEN | PM_NODE_FLAG_STATIC_LITERAL;
+ }
+
+ // If the key and value of this assoc node are both static literals, then
+ // we can mark this node as a static literal.
+ pm_node_flags_t flags = 0;
+ if (
+ !PM_NODE_TYPE_P(key, PM_ARRAY_NODE) && !PM_NODE_TYPE_P(key, PM_HASH_NODE) && !PM_NODE_TYPE_P(key, PM_RANGE_NODE) &&
+ value && !PM_NODE_TYPE_P(value, PM_ARRAY_NODE) && !PM_NODE_TYPE_P(value, PM_HASH_NODE) && !PM_NODE_TYPE_P(value, PM_RANGE_NODE)
+ ) {
+ flags = key->flags & value->flags & PM_NODE_FLAG_STATIC_LITERAL;
+ }
+
+ return pm_assoc_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ ((pm_location_t) { .start = PM_NODE_START(key), .length = U32(end - PM_NODE_START(key)) }),
+ key,
+ value,
+ NTOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new assoc splat node.
+ */
+static pm_assoc_splat_node_t *
+pm_assoc_splat_node_create(pm_parser_t *parser, pm_node_t *value, const pm_token_t *operator) {
+ assert(operator->type == PM_TOKEN_USTAR_STAR);
+
+ return pm_assoc_splat_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (value == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKEN_NODE(parser, operator, value),
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate a new BackReferenceReadNode node.
+ */
+static pm_back_reference_read_node_t *
+pm_back_reference_read_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ assert(name->type == PM_TOKEN_BACK_REFERENCE);
+
+ return pm_back_reference_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Allocate and initialize new a begin node.
+ */
+static pm_begin_node_t *
+pm_begin_node_create(pm_parser_t *parser, const pm_token_t *begin_keyword, pm_statements_node_t *statements) {
+ uint32_t start = begin_keyword == NULL ? 0 : PM_TOKEN_START(parser, begin_keyword);
+ uint32_t end = statements == NULL ? (begin_keyword == NULL ? 0 : PM_TOKEN_END(parser, begin_keyword)) : PM_NODE_END(statements);
+
+ return pm_begin_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NTOK2LOC(parser, begin_keyword),
+ statements,
+ NULL,
+ NULL,
+ NULL,
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Set the rescue clause, optionally start, and end location of a begin node.
+ */
+static void
+pm_begin_node_rescue_clause_set(pm_begin_node_t *node, pm_rescue_node_t *rescue_clause) {
+ if (node->begin_keyword_loc.length == 0) {
+ PM_NODE_START_SET_NODE(node, rescue_clause);
+ }
+ PM_NODE_LENGTH_SET_NODE(node, rescue_clause);
+ node->rescue_clause = rescue_clause;
+}
+
+/**
+ * Set the else clause and end location of a begin node.
+ */
+static void
+pm_begin_node_else_clause_set(pm_begin_node_t *node, pm_else_node_t *else_clause) {
+ if ((node->begin_keyword_loc.length == 0) && PM_NODE_START(node) == 0) {
+ PM_NODE_START_SET_NODE(node, else_clause);
+ }
+ PM_NODE_LENGTH_SET_NODE(node, else_clause);
+ node->else_clause = else_clause;
+}
+
+/**
+ * Set the ensure clause and end location of a begin node.
+ */
+static void
+pm_begin_node_ensure_clause_set(pm_begin_node_t *node, pm_ensure_node_t *ensure_clause) {
+ if ((node->begin_keyword_loc.length == 0) && PM_NODE_START(node) == 0) {
+ PM_NODE_START_SET_NODE(node, ensure_clause);
+ }
+ PM_NODE_LENGTH_SET_NODE(node, ensure_clause);
+ node->ensure_clause = ensure_clause;
+}
+
+/**
+ * Set the end keyword and end location of a begin node.
+ */
+static void
+pm_begin_node_end_keyword_set(const pm_parser_t *parser, pm_begin_node_t *node, const pm_token_t *end_keyword) {
+ assert(end_keyword->type == PM_TOKEN_KEYWORD_END || end_keyword->type == 0);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, end_keyword);
+ node->end_keyword_loc = TOK2LOC(parser, end_keyword);
+}
+
+/**
+ * Allocate and initialize a new BlockArgumentNode node.
+ */
+static pm_block_argument_node_t *
+pm_block_argument_node_create(pm_parser_t *parser, const pm_token_t *operator, pm_node_t *expression) {
+ assert(operator->type == PM_TOKEN_UAMPERSAND);
+
+ return pm_block_argument_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (expression == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKEN_NODE(parser, operator, expression),
+ expression,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new BlockNode node.
+ */
+static pm_block_node_t *
+pm_block_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *opening, pm_node_t *parameters, pm_node_t *body, const pm_token_t *closing) {
+ return pm_block_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ *locals,
+ parameters,
+ body,
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new BlockParameterNode node.
+ */
+static pm_block_parameter_node_t *
+pm_block_parameter_node_create(pm_parser_t *parser, const pm_token_t *name, const pm_token_t *operator) {
+ assert(operator->type == PM_TOKEN_UAMPERSAND || operator->type == PM_TOKEN_AMPERSAND);
+
+ return pm_block_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (name == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKENS(parser, operator, name),
+ name == NULL ? 0 : pm_parser_constant_id_token(parser, name),
+ NTOK2LOC(parser, name),
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new BlockParametersNode node.
+ */
+static pm_block_parameters_node_t *
+pm_block_parameters_node_create(pm_parser_t *parser, pm_parameters_node_t *parameters, const pm_token_t *opening) {
+ uint32_t start;
+ if (opening != NULL) {
+ start = PM_TOKEN_START(parser, opening);
+ } else if (parameters != NULL) {
+ start = PM_NODE_START(parameters);
+ } else {
+ start = 0;
+ }
+
+ uint32_t end;
+ if (parameters != NULL) {
+ end = PM_NODE_END(parameters);
+ } else if (opening != NULL) {
+ end = PM_TOKEN_END(parser, opening);
+ } else {
+ end = 0;
+ }
+
+ return pm_block_parameters_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ parameters,
+ ((pm_node_list_t) { 0 }),
+ NTOK2LOC(parser, opening),
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Set the closing location of a BlockParametersNode node.
+ */
+static void
+pm_block_parameters_node_closing_set(const pm_parser_t *parser, pm_block_parameters_node_t *node, const pm_token_t *closing) {
+ assert(closing->type == PM_TOKEN_PIPE || closing->type == PM_TOKEN_PARENTHESIS_RIGHT || closing->type == 0);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+ node->closing_loc = TOK2LOC(parser, closing);
+}
+
+/**
+ * Allocate and initialize a new BlockLocalVariableNode node.
+ */
+static pm_block_local_variable_node_t *
+pm_block_local_variable_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ return pm_block_local_variable_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Append a new block-local variable to a BlockParametersNode node.
+ */
+static void
+pm_block_parameters_node_append_local(pm_arena_t *arena, pm_block_parameters_node_t *node, const pm_block_local_variable_node_t *local) {
+ pm_node_list_append(arena, &node->locals, UP(local));
+
+ if (PM_NODE_LENGTH(node) == 0) {
+ PM_NODE_START_SET_NODE(node, local);
+ }
+
+ PM_NODE_LENGTH_SET_NODE(node, local);
+}
+
+/**
+ * Allocate and initialize a new BreakNode node.
+ */
+static pm_break_node_t *
+pm_break_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_arguments_node_t *arguments) {
+ assert(keyword->type == PM_TOKEN_KEYWORD_BREAK);
+
+ return pm_break_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (arguments == NULL) ? PM_LOCATION_INIT_TOKEN(parser, keyword) : PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, arguments),
+ arguments,
+ TOK2LOC(parser, keyword)
+ );
+}
+
+// There are certain flags that we want to use internally but don't want to
+// expose because they are not relevant beyond parsing. Therefore we'll define
+// them here and not define them in config.yml/a header file.
+static const pm_node_flags_t PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY = (1 << 2);
+
+static const pm_node_flags_t PM_CALL_NODE_FLAGS_IMPLICIT_ARRAY = ((PM_CALL_NODE_FLAGS_LAST - 1) << 1);
+static const pm_node_flags_t PM_CALL_NODE_FLAGS_COMPARISON = ((PM_CALL_NODE_FLAGS_LAST - 1) << 2);
+static const pm_node_flags_t PM_CALL_NODE_FLAGS_INDEX = ((PM_CALL_NODE_FLAGS_LAST - 1) << 3);
+
+/**
+ * Allocate and initialize a new CallNode node. This sets everything to NULL
+ * such that its values can be overridden in the various specializations of this
+ * function.
+ */
+static pm_call_node_t *
+pm_call_node_create(pm_parser_t *parser, pm_node_flags_t flags) {
+ return pm_call_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_UNSET,
+ NULL,
+ ((pm_location_t) { 0 }),
+ 0,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ NULL,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ NULL
+ );
+}
+
+/**
+ * Returns the value that the ignore visibility flag should be set to for the
+ * given receiver.
+ */
+static PRISM_INLINE pm_node_flags_t
+pm_call_node_ignore_visibility_flag(const pm_node_t *receiver) {
+ return PM_NODE_TYPE_P(receiver, PM_SELF_NODE) ? PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY : 0;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from an aref or an aset
+ * expression.
+ */
+static pm_call_node_t *
+pm_call_node_aref_create(pm_parser_t *parser, pm_node_t *receiver, pm_arguments_t *arguments) {
+ pm_assert_value_expression(parser, receiver);
+
+ pm_node_flags_t flags = pm_call_node_ignore_visibility_flag(receiver);
+ if (arguments->block == NULL || PM_NODE_TYPE_P(arguments->block, PM_BLOCK_ARGUMENT_NODE)) {
+ flags |= PM_CALL_NODE_FLAGS_INDEX;
+ }
+
+ pm_call_node_t *node = pm_call_node_create(parser, flags);
+
+ PM_NODE_START_SET_NODE(node, receiver);
+
+ const pm_location_t *end = pm_arguments_end(arguments);
+ assert(end != NULL && "unreachable");
+ PM_NODE_LENGTH_SET_LOCATION(node, end);
+
+ node->receiver = receiver;
+ node->message_loc.start = arguments->opening_loc.start;
+ node->message_loc.length = (arguments->closing_loc.start + arguments->closing_loc.length) - arguments->opening_loc.start;
+
+ node->opening_loc = arguments->opening_loc;
+ node->arguments = arguments->arguments;
+ node->closing_loc = arguments->closing_loc;
+ node->block = arguments->block;
+
+ node->name = pm_parser_constant_id_constant(parser, "[]", 2);
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a binary expression.
+ */
+static pm_call_node_t *
+pm_call_node_binary_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_node_t *argument, pm_node_flags_t flags) {
+ pm_assert_value_expression(parser, receiver);
+ pm_assert_value_expression(parser, argument);
+
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) | flags);
+
+ PM_NODE_START_SET_NODE(node, PM_NODE_START(receiver) < PM_NODE_START(argument) ? receiver : argument);
+ PM_NODE_LENGTH_SET_NODE(node, PM_NODE_END(receiver) > PM_NODE_END(argument) ? receiver : argument);
+
+ node->receiver = receiver;
+ node->message_loc = TOK2LOC(parser, operator);
+
+ pm_arguments_node_t *arguments = pm_arguments_node_create(parser);
+ pm_arguments_node_arguments_append(parser->arena, arguments, argument);
+ node->arguments = arguments;
+
+ node->name = pm_parser_constant_id_token(parser, operator);
+ return node;
+}
+
+static const uint8_t * parse_operator_symbol_name(const pm_token_t *);
+
+/**
+ * Allocate and initialize a new CallNode node from a call expression.
+ */
+static pm_call_node_t *
+pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_token_t *message, pm_arguments_t *arguments) {
+ pm_assert_value_expression(parser, receiver);
+
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver));
+
+ PM_NODE_START_SET_NODE(node, receiver);
+ const pm_location_t *end = pm_arguments_end(arguments);
+ if (end == NULL) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, message);
+ } else {
+ PM_NODE_LENGTH_SET_LOCATION(node, end);
+ }
+
+ node->receiver = receiver;
+ node->call_operator_loc = TOK2LOC(parser, operator);
+ node->message_loc = TOK2LOC(parser, message);
+ node->opening_loc = arguments->opening_loc;
+ node->arguments = arguments->arguments;
+ node->closing_loc = arguments->closing_loc;
+ node->block = arguments->block;
+
+ if (operator->type == PM_TOKEN_AMPERSAND_DOT) {
+ pm_node_flag_set(UP(node), PM_CALL_NODE_FLAGS_SAFE_NAVIGATION);
+ }
+
+ /**
+ * If the final character is `@` as is the case for `foo.~@`,
+ * we should ignore the @ in the same way we do for symbols.
+ */
+ node->name = pm_parser_constant_id_raw(parser, message->start, parse_operator_symbol_name(message));
+ return node;
+}
+
+/**
+ * Allocate and initialize a new synthesized CallNode node from a call expression.
+ */
+static pm_call_node_t *
+pm_call_node_call_synthesized_create(pm_parser_t *parser, pm_node_t *receiver, const char *message, pm_arguments_node_t *arguments) {
+ pm_call_node_t *node = pm_call_node_create(parser, 0);
+ node->base.location = (pm_location_t) { .start = 0, .length = U32(parser->end - parser->start) };
+
+ node->receiver = receiver;
+ node->arguments = arguments;
+
+ node->name = pm_parser_constant_id_constant(parser, message, strlen(message));
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a call to a method name
+ * without a receiver that could not have been a local variable read.
+ */
+static pm_call_node_t *
+pm_call_node_fcall_create(pm_parser_t *parser, pm_token_t *message, pm_arguments_t *arguments) {
+ pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY);
+
+ PM_NODE_START_SET_TOKEN(parser, node, message);
+ const pm_location_t *end = pm_arguments_end(arguments);
+ assert(end != NULL && "unreachable");
+ PM_NODE_LENGTH_SET_LOCATION(node, end);
+
+ node->message_loc = TOK2LOC(parser, message);
+ node->opening_loc = arguments->opening_loc;
+ node->arguments = arguments->arguments;
+ node->closing_loc = arguments->closing_loc;
+ node->block = arguments->block;
+
+ node->name = pm_parser_constant_id_token(parser, message);
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a synthesized call to a
+ * method name with the given arguments.
+ */
+static pm_call_node_t *
+pm_call_node_fcall_synthesized_create(pm_parser_t *parser, pm_arguments_node_t *arguments, pm_constant_id_t name) {
+ pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY);
+
+ node->base.location = (pm_location_t) { 0 };
+ node->arguments = arguments;
+
+ node->name = name;
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a not expression.
+ */
+static pm_call_node_t *
+pm_call_node_not_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *message, pm_arguments_t *arguments) {
+ pm_assert_value_expression(parser, receiver);
+ if (receiver != NULL) pm_conditional_predicate(parser, receiver, PM_CONDITIONAL_PREDICATE_TYPE_NOT);
+
+ pm_call_node_t *node = pm_call_node_create(parser, receiver == NULL ? 0 : pm_call_node_ignore_visibility_flag(receiver));
+
+ PM_NODE_START_SET_TOKEN(parser, node, message);
+ if (arguments->closing_loc.length > 0) {
+ PM_NODE_LENGTH_SET_LOCATION(node, &arguments->closing_loc);
+ } else {
+ assert(receiver != NULL);
+ PM_NODE_LENGTH_SET_NODE(node, receiver);
+ }
+
+ node->receiver = receiver;
+ node->message_loc = TOK2LOC(parser, message);
+ node->opening_loc = arguments->opening_loc;
+ node->arguments = arguments->arguments;
+ node->closing_loc = arguments->closing_loc;
+
+ node->name = pm_parser_constant_id_constant(parser, "!", 1);
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a call shorthand expression.
+ */
+static pm_call_node_t *
+pm_call_node_shorthand_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_arguments_t *arguments) {
+ pm_assert_value_expression(parser, receiver);
+
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver));
+
+ PM_NODE_START_SET_NODE(node, receiver);
+ const pm_location_t *end = pm_arguments_end(arguments);
+ assert(end != NULL && "unreachable");
+ PM_NODE_LENGTH_SET_LOCATION(node, end);
+
+ node->receiver = receiver;
+ node->call_operator_loc = TOK2LOC(parser, operator);
+ node->opening_loc = arguments->opening_loc;
+ node->arguments = arguments->arguments;
+ node->closing_loc = arguments->closing_loc;
+ node->block = arguments->block;
+
+ if (operator->type == PM_TOKEN_AMPERSAND_DOT) {
+ pm_node_flag_set(UP(node), PM_CALL_NODE_FLAGS_SAFE_NAVIGATION);
+ }
+
+ node->name = pm_parser_constant_id_constant(parser, "call", 4);
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a unary operator expression.
+ */
+static pm_call_node_t *
+pm_call_node_unary_create(pm_parser_t *parser, pm_token_t *operator, pm_node_t *receiver, const char *name) {
+ pm_assert_value_expression(parser, receiver);
+
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver));
+
+ PM_NODE_START_SET_TOKEN(parser, node, operator);
+ PM_NODE_LENGTH_SET_NODE(node, receiver);
+
+ node->receiver = receiver;
+ node->message_loc = TOK2LOC(parser, operator);
+
+ node->name = pm_parser_constant_id_constant(parser, name, strlen(name));
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallNode node from a call to a method name
+ * without a receiver that could also have been a local variable read.
+ */
+static pm_call_node_t *
+pm_call_node_variable_call_create(pm_parser_t *parser, pm_token_t *message) {
+ pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY);
+
+ node->base.location = TOK2LOC(parser, message);
+ node->message_loc = TOK2LOC(parser, message);
+
+ node->name = pm_parser_constant_id_token(parser, message);
+ return node;
+}
+
+/**
+ * Returns whether or not this call can be used on the left-hand side of an
+ * operator assignment.
+ */
+static PRISM_INLINE bool
+pm_call_node_writable_p(const pm_parser_t *parser, const pm_call_node_t *node) {
+ return (
+ (node->message_loc.length > 0) &&
+ (parser->start[node->message_loc.start + node->message_loc.length - 1] != '!') &&
+ (parser->start[node->message_loc.start + node->message_loc.length - 1] != '?') &&
+ char_is_identifier_start(parser, parser->start + node->message_loc.start, (ptrdiff_t) node->message_loc.length) &&
+ (node->opening_loc.length == 0) &&
+ (node->arguments == NULL) &&
+ (node->block == NULL)
+ );
+}
+
+/**
+ * Initialize the read name by reading the write name and chopping off the '='.
+ */
+static void
+pm_call_write_read_name_init(pm_parser_t *parser, pm_constant_id_t *read_name, pm_constant_id_t *write_name) {
+ pm_constant_t *write_constant = pm_constant_pool_id_to_constant(&parser->constant_pool, *write_name);
+
+ if (write_constant->length > 0) {
+ size_t length = write_constant->length - 1;
+
+ uint8_t *memory = (uint8_t *) pm_arena_alloc(parser->arena, length, 1);
+ memcpy(memory, write_constant->start, length);
+
+ *read_name = pm_constant_pool_insert_owned(&parser->metadata_arena, &parser->constant_pool, memory, length);
+ } else {
+ // We can get here if the message was missing because of a syntax error.
+ *read_name = pm_parser_constant_id_constant(parser, "", 0);
+ }
+}
+
+/**
+ * Allocate and initialize a new CallAndWriteNode node.
+ */
+static pm_call_and_write_node_t *
+pm_call_and_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(target->block == NULL);
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ pm_call_and_write_node_t *node = pm_call_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->message_loc,
+ 0,
+ target->name,
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ pm_call_write_read_name_init(parser, &node->read_name, &node->write_name);
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Validate that index expressions do not have keywords or blocks if we are
+ * parsing as Ruby 3.4+.
+ */
+static void
+pm_index_arguments_check(pm_parser_t *parser, const pm_arguments_node_t *arguments, const pm_node_t *block) {
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_4) {
+ if (arguments != NULL && PM_NODE_FLAG_P(arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS)) {
+ pm_node_t *node;
+ PM_NODE_LIST_FOREACH(&arguments->arguments, index, node) {
+ if (PM_NODE_TYPE_P(node, PM_KEYWORD_HASH_NODE)) {
+ pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_INDEX_KEYWORDS);
+ break;
+ }
+ }
+ }
+
+ if (block != NULL) {
+ pm_parser_err_node(parser, block, PM_ERR_UNEXPECTED_INDEX_BLOCK);
+ }
+ }
+}
+
+/**
+ * Allocate and initialize a new IndexAndWriteNode node.
+ */
+static pm_index_and_write_node_t *
+pm_index_and_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ pm_index_arguments_check(parser, target->arguments, target->block);
+
+ assert(!target->block || PM_NODE_TYPE_P(target->block, PM_BLOCK_ARGUMENT_NODE));
+
+ pm_index_and_write_node_t *node = pm_index_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->opening_loc,
+ target->arguments,
+ target->closing_loc,
+ (pm_block_argument_node_t *) target->block,
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate a new CallOperatorWriteNode node.
+ */
+static pm_call_operator_write_node_t *
+pm_call_operator_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(target->block == NULL);
+
+ pm_call_operator_write_node_t *node = pm_call_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->message_loc,
+ 0,
+ target->name,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1),
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ pm_call_write_read_name_init(parser, &node->read_name, &node->write_name);
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate a new IndexOperatorWriteNode node.
+ */
+static pm_index_operator_write_node_t *
+pm_index_operator_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ pm_index_arguments_check(parser, target->arguments, target->block);
+
+ assert(!target->block || PM_NODE_TYPE_P(target->block, PM_BLOCK_ARGUMENT_NODE));
+
+ pm_index_operator_write_node_t *node = pm_index_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->opening_loc,
+ target->arguments,
+ target->closing_loc,
+ (pm_block_argument_node_t *) target->block,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1),
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallOrWriteNode node.
+ */
+static pm_call_or_write_node_t *
+pm_call_or_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(target->block == NULL);
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ pm_call_or_write_node_t *node = pm_call_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->message_loc,
+ 0,
+ target->name,
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ pm_call_write_read_name_init(parser, &node->read_name, &node->write_name);
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new IndexOrWriteNode node.
+ */
+static pm_index_or_write_node_t *
+pm_index_or_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ pm_index_arguments_check(parser, target->arguments, target->block);
+
+ assert(!target->block || PM_NODE_TYPE_P(target->block, PM_BLOCK_ARGUMENT_NODE));
+
+ pm_index_or_write_node_t *node = pm_index_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->receiver,
+ target->call_operator_loc,
+ target->opening_loc,
+ target->arguments,
+ target->closing_loc,
+ (pm_block_argument_node_t *) target->block,
+ TOK2LOC(parser, operator),
+ value
+ );
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CallTargetNode node from an existing call
+ * node.
+ */
+static pm_call_target_node_t *
+pm_call_target_node_create(pm_parser_t *parser, pm_call_node_t *target) {
+ pm_call_target_node_t *node = pm_call_target_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target),
+ PM_LOCATION_INIT_NODE(target),
+ target->receiver,
+ target->call_operator_loc,
+ target->name,
+ target->message_loc
+ );
+
+ /* It is possible to get here where we have parsed an invalid syntax tree
+ * where the call operator was not present. In that case we will have a
+ * problem because it is a required location. In this case we need to fill
+ * it in with a fake location so that the syntax tree remains valid. */
+ if (node->call_operator_loc.length == 0) {
+ node->call_operator_loc = target->base.location;
+ }
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new IndexTargetNode node from an existing call
+ * node.
+ */
+static pm_index_target_node_t *
+pm_index_target_node_create(pm_parser_t *parser, pm_call_node_t *target) {
+ pm_index_arguments_check(parser, target->arguments, target->block);
+ assert(!target->block || PM_NODE_TYPE_P(target->block, PM_BLOCK_ARGUMENT_NODE));
+
+ pm_index_target_node_t *node = pm_index_target_node_new(
+ parser->arena,
+ ++parser->node_id,
+ FL(target) | PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE,
+ PM_LOCATION_INIT_NODE(target),
+ target->receiver,
+ target->opening_loc,
+ target->arguments,
+ target->closing_loc,
+ (pm_block_argument_node_t *) target->block
+ );
+
+ // The target is no longer necessary because we've reused its children.
+ // It is arena-allocated so no explicit free is needed.
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new CapturePatternNode node.
+ */
+static pm_capture_pattern_node_t *
+pm_capture_pattern_node_create(pm_parser_t *parser, pm_node_t *value, pm_local_variable_target_node_t *target, const pm_token_t *operator) {
+ return pm_capture_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(value, target),
+ value,
+ target,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new CaseNode node.
+ */
+static pm_case_node_t *
+pm_case_node_create(pm_parser_t *parser, const pm_token_t *case_keyword, pm_node_t *predicate, const pm_token_t *end_keyword) {
+ return pm_case_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, case_keyword, end_keyword == NULL ? case_keyword : end_keyword),
+ predicate,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ TOK2LOC(parser, case_keyword),
+ NTOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Append a new condition to a CaseNode node.
+ */
+static void
+pm_case_node_condition_append(pm_arena_t *arena, pm_case_node_t *node, pm_node_t *condition) {
+ assert(PM_NODE_TYPE_P(condition, PM_WHEN_NODE));
+
+ pm_node_list_append(arena, &node->conditions, condition);
+ PM_NODE_LENGTH_SET_NODE(node, condition);
+}
+
+/**
+ * Set the else clause of a CaseNode node.
+ */
+static void
+pm_case_node_else_clause_set(pm_case_node_t *node, pm_else_node_t *else_clause) {
+ node->else_clause = else_clause;
+ PM_NODE_LENGTH_SET_NODE(node, else_clause);
+}
+
+/**
+ * Set the end location for a CaseNode node.
+ */
+static void
+pm_case_node_end_keyword_loc_set(const pm_parser_t *parser, pm_case_node_t *node, const pm_token_t *end_keyword) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, end_keyword);
+ node->end_keyword_loc = TOK2LOC(parser, end_keyword);
+}
+
+/**
+ * Allocate and initialize a new CaseMatchNode node.
+ */
+static pm_case_match_node_t *
+pm_case_match_node_create(pm_parser_t *parser, const pm_token_t *case_keyword, pm_node_t *predicate) {
+ return pm_case_match_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, case_keyword),
+ predicate,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ TOK2LOC(parser, case_keyword),
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Append a new condition to a CaseMatchNode node.
+ */
+static void
+pm_case_match_node_condition_append(pm_arena_t *arena, pm_case_match_node_t *node, pm_node_t *condition) {
+ assert(PM_NODE_TYPE_P(condition, PM_IN_NODE));
+
+ pm_node_list_append(arena, &node->conditions, condition);
+ PM_NODE_LENGTH_SET_NODE(node, condition);
+}
+
+/**
+ * Set the else clause of a CaseMatchNode node.
+ */
+static void
+pm_case_match_node_else_clause_set(pm_case_match_node_t *node, pm_else_node_t *else_clause) {
+ node->else_clause = else_clause;
+ PM_NODE_LENGTH_SET_NODE(node, else_clause);
+}
+
+/**
+ * Set the end location for a CaseMatchNode node.
+ */
+static void
+pm_case_match_node_end_keyword_loc_set(const pm_parser_t *parser, pm_case_match_node_t *node, const pm_token_t *end_keyword) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, end_keyword);
+ node->end_keyword_loc = TOK2LOC(parser, end_keyword);
+}
+
+/**
+ * Allocate a new ClassNode node.
+ */
+static pm_class_node_t *
+pm_class_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *class_keyword, pm_node_t *constant_path, const pm_token_t *name, const pm_token_t *inheritance_operator, pm_node_t *superclass, pm_node_t *body, const pm_token_t *end_keyword) {
+ return pm_class_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, class_keyword, end_keyword),
+ *locals,
+ TOK2LOC(parser, class_keyword),
+ constant_path,
+ NTOK2LOC(parser, inheritance_operator),
+ superclass,
+ body,
+ TOK2LOC(parser, end_keyword),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Allocate and initialize a new ClassVariableAndWriteNode node.
+ */
+static pm_class_variable_and_write_node_t *
+pm_class_variable_and_write_node_create(pm_parser_t *parser, pm_class_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_class_variable_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ClassVariableOperatorWriteNode node.
+ */
+static pm_class_variable_operator_write_node_t *
+pm_class_variable_operator_write_node_create(pm_parser_t *parser, pm_class_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_class_variable_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1)
+ );
+}
+
+/**
+ * Allocate and initialize a new ClassVariableOrWriteNode node.
+ */
+static pm_class_variable_or_write_node_t *
+pm_class_variable_or_write_node_create(pm_parser_t *parser, pm_class_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_class_variable_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ClassVariableReadNode node.
+ */
+static pm_class_variable_read_node_t *
+pm_class_variable_read_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_CLASS_VARIABLE);
+
+ return pm_class_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ pm_parser_constant_id_token(parser, token)
+ );
+}
+
+/**
+ * True if the given node is an implicit array node on a write, as in:
+ *
+ * a = *b
+ * a = 1, 2, 3
+ */
+static PRISM_INLINE pm_node_flags_t
+pm_implicit_array_write_flags(const pm_node_t *node, pm_node_flags_t flags) {
+ if (PM_NODE_TYPE_P(node, PM_ARRAY_NODE) && ((const pm_array_node_t *) node)->opening_loc.length == 0) {
+ return flags;
+ }
+ return 0;
+}
+
+/**
+ * Initialize a new ClassVariableWriteNode node from a ClassVariableRead node.
+ */
+static pm_class_variable_write_node_t *
+pm_class_variable_write_node_create(pm_parser_t *parser, pm_class_variable_read_node_t *read_node, pm_token_t *operator, pm_node_t *value) {
+ return pm_class_variable_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(read_node, value),
+ read_node->name,
+ read_node->base.location,
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantPathAndWriteNode node.
+ */
+static pm_constant_path_and_write_node_t *
+pm_constant_path_and_write_node_create(pm_parser_t *parser, pm_constant_path_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_constant_path_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantPathOperatorWriteNode node.
+ */
+static pm_constant_path_operator_write_node_t *
+pm_constant_path_operator_write_node_create(pm_parser_t *parser, pm_constant_path_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_constant_path_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target,
+ TOK2LOC(parser, operator),
+ value,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1)
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantPathOrWriteNode node.
+ */
+static pm_constant_path_or_write_node_t *
+pm_constant_path_or_write_node_create(pm_parser_t *parser, pm_constant_path_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_constant_path_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantPathNode node.
+ */
+static pm_constant_path_node_t *
+pm_constant_path_node_create(pm_parser_t *parser, pm_node_t *parent, const pm_token_t *delimiter, const pm_token_t *name_token) {
+ pm_assert_value_expression(parser, parent);
+
+ pm_constant_id_t name = PM_CONSTANT_ID_UNSET;
+ if (name_token->type == PM_TOKEN_CONSTANT) {
+ name = pm_parser_constant_id_token(parser, name_token);
+ }
+
+ return pm_constant_path_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (parent == NULL) ? PM_LOCATION_INIT_TOKENS(parser, delimiter, name_token) : PM_LOCATION_INIT_NODE_TOKEN(parser, parent, name_token),
+ parent,
+ name,
+ TOK2LOC(parser, delimiter),
+ TOK2LOC(parser, name_token)
+ );
+}
+
+/**
+ * Allocate a new ConstantPathWriteNode node.
+ */
+static pm_constant_path_write_node_t *
+pm_constant_path_write_node_create(pm_parser_t *parser, pm_constant_path_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_constant_path_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(target, value),
+ target,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantAndWriteNode node.
+ */
+static pm_constant_and_write_node_t *
+pm_constant_and_write_node_create(pm_parser_t *parser, pm_constant_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_constant_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantOperatorWriteNode node.
+ */
+static pm_constant_operator_write_node_t *
+pm_constant_operator_write_node_create(pm_parser_t *parser, pm_constant_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_constant_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1)
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantOrWriteNode node.
+ */
+static pm_constant_or_write_node_t *
+pm_constant_or_write_node_create(pm_parser_t *parser, pm_constant_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_constant_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ConstantReadNode node.
+ */
+static pm_constant_read_node_t *
+pm_constant_read_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ assert(name->type == PM_TOKEN_CONSTANT || name->type == 0);
+
+ return pm_constant_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Allocate a new ConstantWriteNode node.
+ */
+static pm_constant_write_node_t *
+pm_constant_write_node_create(pm_parser_t *parser, pm_constant_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_constant_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Check if the receiver of a `def` node is allowed.
+ */
+static void
+pm_def_node_receiver_check(pm_parser_t *parser, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BEGIN_NODE: {
+ const pm_begin_node_t *cast = (pm_begin_node_t *) node;
+ if (cast->statements != NULL) pm_def_node_receiver_check(parser, UP(cast->statements));
+ break;
+ }
+ case PM_PARENTHESES_NODE: {
+ const pm_parentheses_node_t *cast = (const pm_parentheses_node_t *) node;
+ if (cast->body != NULL) pm_def_node_receiver_check(parser, cast->body);
+ break;
+ }
+ case PM_STATEMENTS_NODE: {
+ const pm_statements_node_t *cast = (const pm_statements_node_t *) node;
+ pm_def_node_receiver_check(parser, cast->body.nodes[cast->body.size - 1]);
+ break;
+ }
+ case PM_ARRAY_NODE:
+ case PM_FLOAT_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INTEGER_NODE:
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
+ case PM_INTERPOLATED_STRING_NODE:
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ case PM_INTERPOLATED_X_STRING_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_X_STRING_NODE:
+ pm_parser_err_node(parser, node, PM_ERR_SINGLETON_FOR_LITERALS);
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Allocate and initialize a new DefNode node.
+ */
+static pm_def_node_t *
+pm_def_node_create(
+ pm_parser_t *parser,
+ pm_constant_id_t name,
+ const pm_token_t *name_loc,
+ pm_node_t *receiver,
+ pm_parameters_node_t *parameters,
+ pm_node_t *body,
+ pm_constant_id_list_t *locals,
+ const pm_token_t *def_keyword,
+ const pm_token_t *operator,
+ const pm_token_t *lparen,
+ const pm_token_t *rparen,
+ const pm_token_t *equal,
+ const pm_token_t *end_keyword
+) {
+ if (receiver != NULL) {
+ pm_def_node_receiver_check(parser, receiver);
+ }
+
+ return pm_def_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (end_keyword == NULL) ? PM_LOCATION_INIT_TOKEN_NODE(parser, def_keyword, body) : PM_LOCATION_INIT_TOKENS(parser, def_keyword, end_keyword),
+ name,
+ TOK2LOC(parser, name_loc),
+ receiver,
+ parameters,
+ body,
+ *locals,
+ TOK2LOC(parser, def_keyword),
+ NTOK2LOC(parser, operator),
+ NTOK2LOC(parser, lparen),
+ NTOK2LOC(parser, rparen),
+ NTOK2LOC(parser, equal),
+ NTOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate a new DefinedNode node.
+ */
+static pm_defined_node_t *
+pm_defined_node_create(pm_parser_t *parser, const pm_token_t *lparen, pm_node_t *value, const pm_token_t *rparen, const pm_token_t *keyword) {
+ return pm_defined_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (rparen == NULL) ? PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, value) : PM_LOCATION_INIT_TOKENS(parser, keyword, rparen),
+ NTOK2LOC(parser, lparen),
+ value,
+ NTOK2LOC(parser, rparen),
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new ElseNode node.
+ */
+static pm_else_node_t *
+pm_else_node_create(pm_parser_t *parser, const pm_token_t *else_keyword, pm_statements_node_t *statements, const pm_token_t *end_keyword) {
+ return pm_else_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((end_keyword == NULL) && (statements != NULL)) ? PM_LOCATION_INIT_TOKEN_NODE(parser, else_keyword, statements) : PM_LOCATION_INIT_TOKENS(parser, else_keyword, end_keyword),
+ TOK2LOC(parser, else_keyword),
+ statements,
+ NTOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new EmbeddedStatementsNode node.
+ */
+static pm_embedded_statements_node_t *
+pm_embedded_statements_node_create(pm_parser_t *parser, const pm_token_t *opening, pm_statements_node_t *statements, const pm_token_t *closing) {
+ return pm_embedded_statements_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ TOK2LOC(parser, opening),
+ statements,
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new EmbeddedVariableNode node.
+ */
+static pm_embedded_variable_node_t *
+pm_embedded_variable_node_create(pm_parser_t *parser, const pm_token_t *operator, pm_node_t *variable) {
+ return pm_embedded_variable_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, operator, variable),
+ TOK2LOC(parser, operator),
+ variable
+ );
+}
+
+/**
+ * Allocate a new EnsureNode node.
+ */
+static pm_ensure_node_t *
+pm_ensure_node_create(pm_parser_t *parser, const pm_token_t *ensure_keyword, pm_statements_node_t *statements, const pm_token_t *end_keyword) {
+ return pm_ensure_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, ensure_keyword, end_keyword),
+ TOK2LOC(parser, ensure_keyword),
+ statements,
+ TOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new FalseNode node.
+ */
+static pm_false_node_t *
+pm_false_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_FALSE);
+
+ return pm_false_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new find pattern node. The node list given in the
+ * nodes parameter is guaranteed to have at least two nodes.
+ */
+static pm_find_pattern_node_t *
+pm_find_pattern_node_create(pm_parser_t *parser, pm_node_list_t *nodes) {
+ assert(nodes->size >= 2);
+ pm_node_t *left = nodes->nodes[0];
+ pm_node_t *right = nodes->nodes[nodes->size - 1];
+
+ assert(PM_NODE_TYPE_P(left, PM_SPLAT_NODE));
+ assert(PM_NODE_TYPE_P(right, PM_SPLAT_NODE));
+
+ pm_find_pattern_node_t *node = pm_find_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(left, right),
+ NULL,
+ (pm_splat_node_t *) left,
+ ((pm_node_list_t) { 0 }),
+ (pm_splat_node_t *) right,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+
+ // For now we're going to just copy over each pointer manually. This could be
+ // much more efficient, as we could instead resize the node list to only point
+ // to 1...-1.
+ for (size_t index = 1; index < nodes->size - 1; index++) {
+ pm_node_list_append(parser->arena, &node->requireds, nodes->nodes[index]);
+ }
+
+ return node;
+}
+
+/**
+ * Parse the value of a double, add appropriate errors if there is an issue, and
+ * return the value that should be saved on the PM_FLOAT_NODE node.
+ */
+static double
+pm_double_parse(pm_parser_t *parser, const pm_token_t *token) {
+ ptrdiff_t diff = token->end - token->start;
+ if (diff <= 0) return 0.0;
+
+ // First, get a buffer of the content.
+ size_t length = (size_t) diff;
+ const size_t buffer_size = sizeof(char) * (length + 1);
+ char *buffer = xmalloc(buffer_size);
+ memcpy((void *) buffer, token->start, length);
+
+ // Next, determine if we need to replace the decimal point because of
+ // locale-specific options, and then normalize them if we have to.
+ char decimal_point = *localeconv()->decimal_point;
+ if (decimal_point != '.') {
+ for (size_t index = 0; index < length; index++) {
+ if (buffer[index] == '.') buffer[index] = decimal_point;
+ }
+ }
+
+ // Next, handle underscores by removing them from the buffer.
+ for (size_t index = 0; index < length; index++) {
+ if (buffer[index] == '_') {
+ memmove((void *) (buffer + index), (void *) (buffer + index + 1), length - index);
+ length--;
+ }
+ }
+
+ // Null-terminate the buffer so that strtod cannot read off the end.
+ buffer[length] = '\0';
+
+ // Now, call strtod to parse the value. Note that CRuby has their own
+ // version of strtod which avoids locales. We're okay using the locale-aware
+ // version because we've already validated through the parser that the token
+ // is in a valid format.
+ errno = 0;
+ char *eptr;
+ double value = strtod(buffer, &eptr);
+
+ // This should never happen, because we've already checked that the token
+ // is in a valid format. However it's good to be safe.
+ if ((eptr != buffer + length) || (errno != 0 && errno != ERANGE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, token, PM_ERR_FLOAT_PARSE);
+ xfree_sized(buffer, buffer_size);
+ return 0.0;
+ }
+
+ // If errno is set, then it should only be ERANGE. At this point we need to
+ // check if it's infinity (it should be).
+ if (errno == ERANGE && PRISM_ISINF(value)) {
+ int warn_width;
+ const char *ellipsis;
+
+ if (length > 20) {
+ warn_width = 20;
+ ellipsis = "...";
+ } else {
+ warn_width = (int) length;
+ ellipsis = "";
+ }
+
+ pm_diagnostic_list_append_format(&parser->metadata_arena, &parser->warning_list, PM_TOKEN_START(parser, token), PM_TOKEN_LENGTH(token), PM_WARN_FLOAT_OUT_OF_RANGE, warn_width, (const char *) token->start, ellipsis);
+ value = (value < 0.0) ? -HUGE_VAL : HUGE_VAL;
+ }
+
+ // Finally we can free the buffer and return the value.
+ xfree_sized(buffer, buffer_size);
+ return value;
+}
+
+/**
+ * Allocate and initialize a new FloatNode node.
+ */
+static pm_float_node_t *
+pm_float_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_FLOAT);
+
+ return pm_float_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ pm_double_parse(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new FloatNode node from a FLOAT_IMAGINARY token.
+ */
+static pm_imaginary_node_t *
+pm_float_node_imaginary_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_FLOAT_IMAGINARY);
+
+ return pm_imaginary_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ UP(pm_float_node_create(parser, &((pm_token_t) {
+ .type = PM_TOKEN_FLOAT,
+ .start = token->start,
+ .end = token->end - 1
+ })))
+ );
+}
+
+/**
+ * Allocate and initialize a new RationalNode node from a FLOAT_RATIONAL token.
+ */
+static pm_rational_node_t *
+pm_float_node_rational_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_FLOAT_RATIONAL);
+
+ pm_rational_node_t *node = pm_rational_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_INTEGER_BASE_FLAGS_DECIMAL | PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ ((pm_integer_t) { 0 }),
+ ((pm_integer_t) { 0 })
+ );
+
+ const uint8_t *start = token->start;
+ const uint8_t *end = token->end - 1; // r
+
+ while (start < end && *start == '0') start++; // 0.1 -> .1
+ while (end > start && end[-1] == '0') end--; // 1.0 -> 1.
+
+ size_t length = (size_t) (end - start);
+ if (length == 1) {
+ node->denominator.value = 1;
+ return node;
+ }
+
+ const uint8_t *point = memchr(start, '.', length);
+ assert(point && "should have a decimal point");
+
+ uint8_t *digits = xmalloc(length);
+ if (digits == NULL) {
+ fputs("[pm_float_node_rational_create] Failed to allocate memory", stderr);
+ abort();
+ }
+
+ memcpy(digits, start, (unsigned long) (point - start));
+ memcpy(digits + (point - start), point + 1, (unsigned long) (end - point - 1));
+ pm_integer_parse(&node->numerator, PM_INTEGER_BASE_DEFAULT, digits, digits + length - 1);
+
+ size_t fract_length = 0;
+ for (const uint8_t *fract = point; fract < end; ++fract) {
+ if (*fract != '_') ++fract_length;
+ }
+ digits[0] = '1';
+ if (fract_length > 1) memset(digits + 1, '0', fract_length - 1);
+ pm_integer_parse(&node->denominator, PM_INTEGER_BASE_DEFAULT, digits, digits + fract_length);
+ xfree_sized(digits, length);
+
+ pm_integers_reduce(&node->numerator, &node->denominator);
+ pm_integer_arena_move(parser->arena, &node->numerator);
+ pm_integer_arena_move(parser->arena, &node->denominator);
+ return node;
+}
+
+/**
+ * Allocate and initialize a new FloatNode node from a FLOAT_RATIONAL_IMAGINARY
+ * token.
+ */
+static pm_imaginary_node_t *
+pm_float_node_rational_imaginary_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_FLOAT_RATIONAL_IMAGINARY);
+
+ return pm_imaginary_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ UP(pm_float_node_rational_create(parser, &((pm_token_t) {
+ .type = PM_TOKEN_FLOAT_RATIONAL,
+ .start = token->start,
+ .end = token->end - 1
+ })))
+ );
+}
+
+/**
+ * Allocate and initialize a new ForNode node.
+ */
+static pm_for_node_t *
+pm_for_node_create(
+ pm_parser_t *parser,
+ pm_node_t *index,
+ pm_node_t *collection,
+ pm_statements_node_t *statements,
+ const pm_token_t *for_keyword,
+ const pm_token_t *in_keyword,
+ const pm_token_t *do_keyword,
+ const pm_token_t *end_keyword
+) {
+ return pm_for_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, for_keyword, end_keyword),
+ index,
+ collection,
+ statements,
+ TOK2LOC(parser, for_keyword),
+ TOK2LOC(parser, in_keyword),
+ NTOK2LOC(parser, do_keyword),
+ TOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new ForwardingArgumentsNode node.
+ */
+static pm_forwarding_arguments_node_t *
+pm_forwarding_arguments_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_UDOT_DOT_DOT);
+
+ return pm_forwarding_arguments_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new ForwardingParameterNode node.
+ */
+static pm_forwarding_parameter_node_t *
+pm_forwarding_parameter_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_UDOT_DOT_DOT);
+
+ return pm_forwarding_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new ForwardingSuper node.
+ */
+static pm_forwarding_super_node_t *
+pm_forwarding_super_node_create(pm_parser_t *parser, const pm_token_t *token, pm_arguments_t *arguments) {
+ assert(arguments->block == NULL || PM_NODE_TYPE_P(arguments->block, PM_BLOCK_NODE));
+ assert(token->type == PM_TOKEN_KEYWORD_SUPER);
+
+ pm_block_node_t *block = NULL;
+ if (arguments->block != NULL) {
+ block = (pm_block_node_t *) arguments->block;
+ }
+
+ return pm_forwarding_super_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (block == NULL) ? PM_LOCATION_INIT_TOKEN(parser, token) : PM_LOCATION_INIT_TOKEN_NODE(parser, token, block),
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ block
+ );
+}
+
+/**
+ * Allocate and initialize a new hash pattern node from an opening and closing
+ * token.
+ */
+static pm_hash_pattern_node_t *
+pm_hash_pattern_node_empty_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *closing) {
+ return pm_hash_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new hash pattern node.
+ */
+static pm_hash_pattern_node_t *
+pm_hash_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *elements, pm_node_t *rest) {
+ uint32_t start;
+ uint32_t end;
+
+ if (elements->size > 0) {
+ if (rest) {
+ start = MIN(PM_NODE_START(rest), PM_NODE_START(elements->nodes[0]));
+ end = MAX(PM_NODE_END(rest), PM_NODE_END(elements->nodes[elements->size - 1]));
+ } else {
+ start = PM_NODE_START(elements->nodes[0]);
+ end = PM_NODE_END(elements->nodes[elements->size - 1]);
+ }
+ } else {
+ assert(rest != NULL);
+ start = PM_NODE_START(rest);
+ end = PM_NODE_END(rest);
+ }
+
+ pm_hash_pattern_node_t *node = pm_hash_pattern_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ rest,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+
+ pm_node_list_concat(parser->arena, &node->elements, elements);
+ return node;
+}
+
+/**
+ * Retrieve the name from a node that will become a global variable write node.
+ */
+static pm_constant_id_t
+pm_global_variable_write_name(pm_parser_t *parser, const pm_node_t *target) {
+ switch (PM_NODE_TYPE(target)) {
+ case PM_GLOBAL_VARIABLE_READ_NODE:
+ return ((pm_global_variable_read_node_t *) target)->name;
+ case PM_BACK_REFERENCE_READ_NODE:
+ return ((pm_back_reference_read_node_t *) target)->name;
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ // This will only ever happen in the event of a syntax error, but we
+ // still need to provide something for the node.
+ return pm_parser_constant_id_raw(parser, parser->start + PM_NODE_START(target), parser->start + PM_NODE_END(target));
+ default:
+ assert(false && "unreachable");
+ return (pm_constant_id_t) -1;
+ }
+}
+
+/**
+ * Allocate and initialize a new GlobalVariableAndWriteNode node.
+ */
+static pm_global_variable_and_write_node_t *
+pm_global_variable_and_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_global_variable_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ pm_global_variable_write_name(parser, target),
+ target->location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new GlobalVariableOperatorWriteNode node.
+ */
+static pm_global_variable_operator_write_node_t *
+pm_global_variable_operator_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_global_variable_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ pm_global_variable_write_name(parser, target),
+ target->location,
+ TOK2LOC(parser, operator),
+ value,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1)
+ );
+}
+
+/**
+ * Allocate and initialize a new GlobalVariableOrWriteNode node.
+ */
+static pm_global_variable_or_write_node_t *
+pm_global_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_global_variable_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ pm_global_variable_write_name(parser, target),
+ target->location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate a new GlobalVariableReadNode node.
+ */
+static pm_global_variable_read_node_t *
+pm_global_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ return pm_global_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Allocate and initialize a new synthesized GlobalVariableReadNode node.
+ */
+static pm_global_variable_read_node_t *
+pm_global_variable_read_node_synthesized_create(pm_parser_t *parser, pm_constant_id_t name) {
+ return pm_global_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ name
+ );
+}
+
+/**
+ * Allocate and initialize a new GlobalVariableWriteNode node.
+ */
+static pm_global_variable_write_node_t *
+pm_global_variable_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_global_variable_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(target, value),
+ pm_global_variable_write_name(parser, target),
+ target->location,
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new synthesized GlobalVariableWriteNode node.
+ */
+static pm_global_variable_write_node_t *
+pm_global_variable_write_node_synthesized_create(pm_parser_t *parser, pm_constant_id_t name, pm_node_t *value) {
+ return pm_global_variable_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ name,
+ ((pm_location_t) { 0 }),
+ value,
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Allocate a new HashNode node.
+ */
+static pm_hash_node_t *
+pm_hash_node_create(pm_parser_t *parser, const pm_token_t *opening) {
+ assert(opening != NULL);
+
+ return pm_hash_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, opening),
+ TOK2LOC(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Append a new element to a hash node.
+ */
+static PRISM_INLINE void
+pm_hash_node_elements_append(pm_arena_t *arena, pm_hash_node_t *hash, pm_node_t *element) {
+ pm_node_list_append(arena, &hash->elements, element);
+
+ bool static_literal = PM_NODE_TYPE_P(element, PM_ASSOC_NODE);
+ if (static_literal) {
+ pm_assoc_node_t *assoc = (pm_assoc_node_t *) element;
+ static_literal = !PM_NODE_TYPE_P(assoc->key, PM_ARRAY_NODE) && !PM_NODE_TYPE_P(assoc->key, PM_HASH_NODE) && !PM_NODE_TYPE_P(assoc->key, PM_RANGE_NODE);
+ static_literal = static_literal && PM_NODE_FLAG_P(assoc->key, PM_NODE_FLAG_STATIC_LITERAL);
+ static_literal = static_literal && PM_NODE_FLAG_P(assoc, PM_NODE_FLAG_STATIC_LITERAL);
+ }
+
+ if (!static_literal) {
+ pm_node_flag_unset(UP(hash), PM_NODE_FLAG_STATIC_LITERAL);
+ }
+}
+
+static PRISM_INLINE void
+pm_hash_node_closing_loc_set(const pm_parser_t *parser, pm_hash_node_t *hash, pm_token_t *token) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, hash, token);
+ hash->closing_loc = TOK2LOC(parser, token);
+}
+
+/**
+ * Allocate a new IfNode node.
+ */
+static pm_if_node_t *
+pm_if_node_create(pm_parser_t *parser,
+ const pm_token_t *if_keyword,
+ pm_node_t *predicate,
+ const pm_token_t *then_keyword,
+ pm_statements_node_t *statements,
+ pm_node_t *subsequent,
+ const pm_token_t *end_keyword
+) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ uint32_t start = PM_TOKEN_START(parser, if_keyword);
+ uint32_t end;
+
+ if (end_keyword != NULL) {
+ end = PM_TOKEN_END(parser, end_keyword);
+ } else if (subsequent != NULL) {
+ end = PM_NODE_END(subsequent);
+ } else if (pm_statements_node_body_length(statements) != 0) {
+ end = PM_NODE_END(statements);
+ } else {
+ end = PM_NODE_END(predicate);
+ }
+
+ return pm_if_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_NEWLINE,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ TOK2LOC(parser, if_keyword),
+ predicate,
+ NTOK2LOC(parser, then_keyword),
+ statements,
+ subsequent,
+ NTOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize new IfNode node in the modifier form.
+ */
+static pm_if_node_t *
+pm_if_node_modifier_create(pm_parser_t *parser, pm_node_t *statement, const pm_token_t *if_keyword, pm_node_t *predicate) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, statement, true);
+
+ return pm_if_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_NEWLINE,
+ PM_LOCATION_INIT_NODES(statement, predicate),
+ TOK2LOC(parser, if_keyword),
+ predicate,
+ ((pm_location_t) { 0 }),
+ statements,
+ NULL,
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Allocate and initialize an if node from a ternary expression.
+ */
+static pm_if_node_t *
+pm_if_node_ternary_create(pm_parser_t *parser, pm_node_t *predicate, const pm_token_t *qmark, pm_node_t *true_expression, const pm_token_t *colon, pm_node_t *false_expression) {
+ pm_assert_value_expression(parser, predicate);
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ pm_statements_node_t *if_statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, if_statements, true_expression, true);
+
+ pm_statements_node_t *else_statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, else_statements, false_expression, true);
+
+ pm_else_node_t *else_node = pm_else_node_create(parser, colon, else_statements, NULL);
+ return pm_if_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_NEWLINE,
+ PM_LOCATION_INIT_NODES(predicate, false_expression),
+ ((pm_location_t) { 0 }),
+ predicate,
+ TOK2LOC(parser, qmark),
+ if_statements,
+ UP(else_node),
+ ((pm_location_t) { 0 })
+ );
+}
+
+static PRISM_INLINE void
+pm_if_node_end_keyword_loc_set(const pm_parser_t *parser, pm_if_node_t *node, const pm_token_t *keyword) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, keyword);
+ node->end_keyword_loc = TOK2LOC(parser, keyword);
+}
+
+static PRISM_INLINE void
+pm_else_node_end_keyword_loc_set(const pm_parser_t *parser, pm_else_node_t *node, const pm_token_t *keyword) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, keyword);
+ node->end_keyword_loc = TOK2LOC(parser, keyword);
+}
+
+/**
+ * Allocate and initialize a new ImplicitNode node.
+ */
+static pm_implicit_node_t *
+pm_implicit_node_create(pm_parser_t *parser, pm_node_t *value) {
+ return pm_implicit_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODE(value),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new ImplicitRestNode node.
+ */
+static pm_implicit_rest_node_t *
+pm_implicit_rest_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_COMMA);
+
+ return pm_implicit_rest_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new IntegerNode node.
+ */
+static pm_integer_node_t *
+pm_integer_node_create(pm_parser_t *parser, pm_node_flags_t base, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_INTEGER);
+
+ pm_integer_node_t *node = pm_integer_node_new(
+ parser->arena,
+ ++parser->node_id,
+ base | PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ ((pm_integer_t) { 0 })
+ );
+
+ if (parser->integer.lexed) {
+ // The value was already computed during lexing.
+ node->value.value = parser->integer.value;
+ parser->integer.lexed = false;
+ } else {
+ pm_integer_base_t integer_base = PM_INTEGER_BASE_DECIMAL;
+ switch (base) {
+ case PM_INTEGER_BASE_FLAGS_BINARY: integer_base = PM_INTEGER_BASE_BINARY; break;
+ case PM_INTEGER_BASE_FLAGS_OCTAL: integer_base = PM_INTEGER_BASE_OCTAL; break;
+ case PM_INTEGER_BASE_FLAGS_DECIMAL: break;
+ case PM_INTEGER_BASE_FLAGS_HEXADECIMAL: integer_base = PM_INTEGER_BASE_HEXADECIMAL; break;
+ default: assert(false && "unreachable"); break;
+ }
+
+ pm_integer_parse(&node->value, integer_base, token->start, token->end);
+ pm_integer_arena_move(parser->arena, &node->value);
+ }
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new IntegerNode node from an INTEGER_IMAGINARY
+ * token.
+ */
+static pm_imaginary_node_t *
+pm_integer_node_imaginary_create(pm_parser_t *parser, pm_node_flags_t base, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_INTEGER_IMAGINARY);
+
+ return pm_imaginary_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ UP(pm_integer_node_create(parser, base, &((pm_token_t) {
+ .type = PM_TOKEN_INTEGER,
+ .start = token->start,
+ .end = token->end - 1
+ })))
+ );
+}
+
+/**
+ * Allocate and initialize a new RationalNode node from an INTEGER_RATIONAL
+ * token.
+ */
+static pm_rational_node_t *
+pm_integer_node_rational_create(pm_parser_t *parser, pm_node_flags_t base, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_INTEGER_RATIONAL);
+
+ pm_rational_node_t *node = pm_rational_node_new(
+ parser->arena,
+ ++parser->node_id,
+ base | PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ ((pm_integer_t) { 0 }),
+ ((pm_integer_t) { .value = 1 })
+ );
+
+ pm_integer_base_t integer_base = PM_INTEGER_BASE_DECIMAL;
+ switch (base) {
+ case PM_INTEGER_BASE_FLAGS_BINARY: integer_base = PM_INTEGER_BASE_BINARY; break;
+ case PM_INTEGER_BASE_FLAGS_OCTAL: integer_base = PM_INTEGER_BASE_OCTAL; break;
+ case PM_INTEGER_BASE_FLAGS_DECIMAL: break;
+ case PM_INTEGER_BASE_FLAGS_HEXADECIMAL: integer_base = PM_INTEGER_BASE_HEXADECIMAL; break;
+ default: assert(false && "unreachable"); break;
+ }
+
+ pm_integer_parse(&node->numerator, integer_base, token->start, token->end - 1);
+ pm_integer_arena_move(parser->arena, &node->numerator);
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new IntegerNode node from an
+ * INTEGER_RATIONAL_IMAGINARY token.
+ */
+static pm_imaginary_node_t *
+pm_integer_node_rational_imaginary_create(pm_parser_t *parser, pm_node_flags_t base, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_INTEGER_RATIONAL_IMAGINARY);
+
+ return pm_imaginary_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ UP(pm_integer_node_rational_create(parser, base, &((pm_token_t) {
+ .type = PM_TOKEN_INTEGER_RATIONAL,
+ .start = token->start,
+ .end = token->end - 1
+ })))
+ );
+}
+
+/**
+ * Allocate and initialize a new InNode node.
+ */
+static pm_in_node_t *
+pm_in_node_create(pm_parser_t *parser, pm_node_t *pattern, pm_statements_node_t *statements, const pm_token_t *in_keyword, const pm_token_t *then_keyword) {
+ uint32_t start = PM_TOKEN_START(parser, in_keyword);
+ uint32_t end;
+
+ if (statements != NULL) {
+ end = PM_NODE_END(statements);
+ } else if (then_keyword != NULL) {
+ end = PM_TOKEN_END(parser, then_keyword);
+ } else {
+ end = PM_NODE_END(pattern);
+ }
+
+ return pm_in_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ pattern,
+ statements,
+ TOK2LOC(parser, in_keyword),
+ NTOK2LOC(parser, then_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new InstanceVariableAndWriteNode node.
+ */
+static pm_instance_variable_and_write_node_t *
+pm_instance_variable_and_write_node_create(pm_parser_t *parser, pm_instance_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_instance_variable_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new InstanceVariableOperatorWriteNode node.
+ */
+static pm_instance_variable_operator_write_node_t *
+pm_instance_variable_operator_write_node_create(pm_parser_t *parser, pm_instance_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ return pm_instance_variable_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1)
+ );
+}
+
+/**
+ * Allocate and initialize a new InstanceVariableOrWriteNode node.
+ */
+static pm_instance_variable_or_write_node_t *
+pm_instance_variable_or_write_node_create(pm_parser_t *parser, pm_instance_variable_read_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_instance_variable_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->name,
+ target->base.location,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new InstanceVariableReadNode node.
+ */
+static pm_instance_variable_read_node_t *
+pm_instance_variable_read_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_INSTANCE_VARIABLE);
+
+ return pm_instance_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ pm_parser_constant_id_token(parser, token)
+ );
+}
+
+/**
+ * Initialize a new InstanceVariableWriteNode node from an InstanceVariableRead
+ * node.
+ */
+static pm_instance_variable_write_node_t *
+pm_instance_variable_write_node_create(pm_parser_t *parser, pm_instance_variable_read_node_t *read_node, pm_token_t *operator, pm_node_t *value) {
+ return pm_instance_variable_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(read_node, value),
+ read_node->name,
+ read_node->base.location,
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Append a part into a list of string parts. Importantly this handles nested
+ * interpolated strings by not necessarily removing the marker for static
+ * literals.
+ */
+static void
+pm_interpolated_node_append(pm_arena_t *arena, pm_node_t *node, pm_node_list_t *parts, pm_node_t *part) {
+ switch (PM_NODE_TYPE(part)) {
+ case PM_STRING_NODE:
+ pm_node_flag_set(part, PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN);
+ break;
+ case PM_EMBEDDED_STATEMENTS_NODE: {
+ pm_embedded_statements_node_t *cast = (pm_embedded_statements_node_t *) part;
+ pm_node_t *embedded = (cast->statements != NULL && cast->statements->body.size == 1) ? cast->statements->body.nodes[0] : NULL;
+
+ if (embedded == NULL) {
+ // If there are no statements or more than one statement, then
+ // we lose the static literal flag.
+ pm_node_flag_unset(node, PM_NODE_FLAG_STATIC_LITERAL);
+ } else if (PM_NODE_TYPE_P(embedded, PM_STRING_NODE)) {
+ // If the embedded statement is a string, then we can keep the
+ // static literal flag and mark the string as frozen.
+ pm_node_flag_set(embedded, PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN);
+ } else if (PM_NODE_TYPE_P(embedded, PM_INTERPOLATED_STRING_NODE) && PM_NODE_FLAG_P(embedded, PM_NODE_FLAG_STATIC_LITERAL)) {
+ // If the embedded statement is an interpolated string and it's
+ // a static literal, then we can keep the static literal flag.
+ } else {
+ // Otherwise we lose the static literal flag.
+ pm_node_flag_unset(node, PM_NODE_FLAG_STATIC_LITERAL);
+ }
+
+ break;
+ }
+ case PM_EMBEDDED_VARIABLE_NODE:
+ pm_node_flag_unset(UP(node), PM_NODE_FLAG_STATIC_LITERAL);
+ break;
+ default:
+ assert(false && "unexpected node type");
+ break;
+ }
+
+ pm_node_list_append(arena, parts, part);
+}
+
+/**
+ * Allocate a new InterpolatedRegularExpressionNode node.
+ */
+static pm_interpolated_regular_expression_node_t *
+pm_interpolated_regular_expression_node_create(pm_parser_t *parser, const pm_token_t *opening) {
+ return pm_interpolated_regular_expression_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, opening),
+ TOK2LOC(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, opening)
+ );
+}
+
+static PRISM_INLINE void
+pm_interpolated_regular_expression_node_append(pm_arena_t *arena, pm_interpolated_regular_expression_node_t *node, pm_node_t *part) {
+ if (PM_NODE_START(node) > PM_NODE_START(part)) {
+ PM_NODE_START_SET_NODE(node, part);
+ }
+ if (PM_NODE_END(node) < PM_NODE_END(part)) {
+ PM_NODE_LENGTH_SET_NODE(node, part);
+ }
+
+ pm_interpolated_node_append(arena, UP(node), &node->parts, part);
+}
+
+static PRISM_INLINE void
+pm_interpolated_regular_expression_node_closing_set(pm_parser_t *parser, pm_interpolated_regular_expression_node_t *node, const pm_token_t *closing) {
+ node->closing_loc = TOK2LOC(parser, closing);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+ pm_node_flag_set(UP(node), pm_regular_expression_flags_create(parser, closing));
+}
+
+/**
+ * Append a part to an InterpolatedStringNode node.
+ *
+ * This has some somewhat complicated semantics, because we need to update
+ * multiple flags that have somewhat confusing interactions.
+ *
+ * PM_NODE_FLAG_STATIC_LITERAL indicates that the node should be treated as a
+ * single static literal string that can be pushed onto the stack on its own.
+ * Note that this doesn't necessarily mean that the string will be frozen or
+ * not; the instructions in CRuby will be either putobject, dupstring or dupchilledstring,
+ * depending on the combination of `--enable-frozen-string-literal`,
+ * `# frozen_string_literal: true`, and whether or not there is interpolation.
+ *
+ * PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN indicates that the string should be
+ * explicitly frozen. This will only happen if the string is comprised entirely
+ * of string parts that are themselves static literals and frozen.
+ *
+ * PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE indicates that the string should
+ * be explicitly marked as mutable. This will happen from
+ * `--disable-frozen-string-literal` or `# frozen_string_literal: false`. This
+ * is necessary to indicate that the string should be left up to the runtime,
+ * which could potentially use a chilled string otherwise.
+ */
+static PRISM_INLINE void
+pm_interpolated_string_node_append(pm_parser_t *parser, pm_interpolated_string_node_t *node, pm_node_t *part) {
+ pm_arena_t *arena = parser->arena;
+#define CLEAR_FLAGS(node) \
+ node->base.flags = (pm_node_flags_t) (FL(node) & ~(PM_NODE_FLAG_STATIC_LITERAL | PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN | PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE))
+
+#define MUTABLE_FLAGS(node) \
+ node->base.flags = (pm_node_flags_t) ((FL(node) | PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE) & ~PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN);
+
+ if (node->parts.size == 0 && node->opening_loc.length == 0) {
+ PM_NODE_START_SET_NODE(node, part);
+ }
+
+ if (PM_NODE_END(part) > PM_NODE_END(node)) {
+ PM_NODE_LENGTH_SET_NODE(node, part);
+ }
+
+ switch (PM_NODE_TYPE(part)) {
+ case PM_STRING_NODE:
+ // If inner string is not frozen, it stops being a static literal. We should *not* clear other flags,
+ // because concatenating two frozen strings (`'foo' 'bar'`) is still frozen. This holds true for
+ // as long as this interpolation only consists of other string literals.
+ if (!PM_NODE_FLAG_P(part, PM_STRING_FLAGS_FROZEN)) {
+ pm_node_flag_unset(UP(node), PM_NODE_FLAG_STATIC_LITERAL);
+ }
+ part->flags = (pm_node_flags_t) ((part->flags | PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN) & ~PM_STRING_FLAGS_MUTABLE);
+ break;
+ case PM_INTERPOLATED_STRING_NODE:
+ if (PM_NODE_FLAG_P(part, PM_NODE_FLAG_STATIC_LITERAL)) {
+ // If the string that we're concatenating is a static literal,
+ // then we can keep the static literal flag for this string.
+ } else {
+ // Otherwise, we lose the static literal flag here and we should
+ // also clear the mutability flags.
+ CLEAR_FLAGS(node);
+ }
+ break;
+ case PM_EMBEDDED_STATEMENTS_NODE: {
+ pm_embedded_statements_node_t *cast = (pm_embedded_statements_node_t *) part;
+ pm_node_t *embedded = (cast->statements != NULL && cast->statements->body.size == 1) ? cast->statements->body.nodes[0] : NULL;
+
+ if (embedded == NULL) {
+ // If we're embedding multiple statements or no statements, then
+ // the string is not longer a static literal.
+ CLEAR_FLAGS(node);
+ } else if (PM_NODE_TYPE_P(embedded, PM_STRING_NODE)) {
+ // If the embedded statement is a string, then we can make that
+ // string as frozen and static literal, and not touch the static
+ // literal status of this string.
+ embedded->flags = (pm_node_flags_t) ((embedded->flags | PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN) & ~PM_STRING_FLAGS_MUTABLE);
+
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ MUTABLE_FLAGS(node);
+ }
+ } else if (PM_NODE_TYPE_P(embedded, PM_INTERPOLATED_STRING_NODE) && PM_NODE_FLAG_P(embedded, PM_NODE_FLAG_STATIC_LITERAL)) {
+ // If the embedded statement is an interpolated string, but that
+ // string is marked as static literal, then we can keep our
+ // static literal status for this string.
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ MUTABLE_FLAGS(node);
+ }
+ } else {
+ // In all other cases, we lose the static literal flag here and
+ // become mutable.
+ CLEAR_FLAGS(node);
+ }
+
+ break;
+ }
+ case PM_EMBEDDED_VARIABLE_NODE:
+ // Embedded variables clear static literal, which means we also
+ // should clear the mutability flags.
+ CLEAR_FLAGS(node);
+ break;
+ case PM_X_STRING_NODE:
+ case PM_INTERPOLATED_X_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ // These will only happen in error cases. But we want to handle it
+ // here so that we don't fail the assertion.
+ CLEAR_FLAGS(node);
+ pm_node_list_append(arena, &node->parts, UP(pm_error_recovery_node_create_unexpected(parser, part)));
+ return;
+ case PM_ERROR_RECOVERY_NODE:
+ CLEAR_FLAGS(node);
+ break;
+ default:
+ assert(false && "unexpected node type");
+ break;
+ }
+
+ pm_node_list_append(arena, &node->parts, part);
+
+#undef CLEAR_FLAGS
+#undef MUTABLE_FLAGS
+}
+
+/**
+ * Allocate and initialize a new InterpolatedStringNode node.
+ */
+static pm_interpolated_string_node_t *
+pm_interpolated_string_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_node_list_t *parts, const pm_token_t *closing) {
+ pm_node_flags_t flags = PM_NODE_FLAG_STATIC_LITERAL;
+
+ switch (parser->frozen_string_literal) {
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED:
+ flags |= PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE;
+ break;
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED:
+ flags |= PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN;
+ break;
+ }
+
+ uint32_t start = opening == NULL ? 0 : PM_TOKEN_START(parser, opening);
+ uint32_t end = closing == NULL ? 0 : PM_TOKEN_END(parser, closing);
+
+ pm_interpolated_string_node_t *node = pm_interpolated_string_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NTOK2LOC(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ NTOK2LOC(parser, closing)
+ );
+
+ if (parts != NULL) {
+ pm_node_t *part;
+ PM_NODE_LIST_FOREACH(parts, index, part) {
+ pm_interpolated_string_node_append(parser, node, part);
+ }
+ }
+
+ return node;
+}
+
+/**
+ * Set the closing token of the given InterpolatedStringNode node.
+ */
+static void
+pm_interpolated_string_node_closing_set(const pm_parser_t *parser, pm_interpolated_string_node_t *node, const pm_token_t *closing) {
+ node->closing_loc = TOK2LOC(parser, closing);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+}
+
+static void
+pm_interpolated_symbol_node_append(pm_arena_t *arena, pm_interpolated_symbol_node_t *node, pm_node_t *part) {
+ if (node->parts.size == 0 && node->opening_loc.length == 0) {
+ PM_NODE_START_SET_NODE(node, part);
+ }
+
+ pm_interpolated_node_append(arena, UP(node), &node->parts, part);
+
+ if (PM_NODE_END(part) > PM_NODE_END(node)) {
+ PM_NODE_LENGTH_SET_NODE(node, part);
+ }
+}
+
+static void
+pm_interpolated_symbol_node_closing_loc_set(const pm_parser_t *parser, pm_interpolated_symbol_node_t *node, const pm_token_t *closing) {
+ node->closing_loc = TOK2LOC(parser, closing);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+}
+
+/**
+ * Allocate and initialize a new InterpolatedSymbolNode node.
+ */
+static pm_interpolated_symbol_node_t *
+pm_interpolated_symbol_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_node_list_t *parts, const pm_token_t *closing) {
+ uint32_t start = opening == NULL ? 0 : PM_TOKEN_START(parser, opening);
+ uint32_t end = closing == NULL ? 0 : PM_TOKEN_END(parser, closing);
+
+ pm_interpolated_symbol_node_t *node = pm_interpolated_symbol_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NTOK2LOC(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ NTOK2LOC(parser, closing)
+ );
+
+ if (parts != NULL) {
+ pm_node_t *part;
+ PM_NODE_LIST_FOREACH(parts, index, part) {
+ pm_interpolated_symbol_node_append(parser->arena, node, part);
+ }
+ }
+
+ return node;
+}
+
+/**
+ * Allocate a new InterpolatedXStringNode node.
+ */
+static pm_interpolated_x_string_node_t *
+pm_interpolated_xstring_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *closing) {
+ return pm_interpolated_x_string_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ TOK2LOC(parser, opening),
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, closing)
+ );
+}
+
+static PRISM_INLINE void
+pm_interpolated_xstring_node_append(pm_arena_t *arena, pm_interpolated_x_string_node_t *node, pm_node_t *part) {
+ pm_interpolated_node_append(arena, UP(node), &node->parts, part);
+ PM_NODE_LENGTH_SET_NODE(node, part);
+}
+
+static PRISM_INLINE void
+pm_interpolated_xstring_node_closing_set(const pm_parser_t *parser, pm_interpolated_x_string_node_t *node, const pm_token_t *closing) {
+ node->closing_loc = TOK2LOC(parser, closing);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, closing);
+}
+
+/**
+ * Create a local variable read that is reading the implicit 'it' variable.
+ */
+static pm_it_local_variable_read_node_t *
+pm_it_local_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ return pm_it_local_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name)
+ );
+}
+
+/**
+ * Allocate and initialize a new ItParametersNode node.
+ */
+static pm_it_parameters_node_t *
+pm_it_parameters_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *closing) {
+ return pm_it_parameters_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing)
+ );
+}
+
+/**
+ * Allocate a new KeywordHashNode node.
+ */
+static pm_keyword_hash_node_t *
+pm_keyword_hash_node_create(pm_parser_t *parser) {
+ return pm_keyword_hash_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 })
+ );
+}
+
+/**
+ * Append an element to a KeywordHashNode node.
+ */
+static void
+pm_keyword_hash_node_elements_append(pm_arena_t *arena, pm_keyword_hash_node_t *hash, pm_node_t *element) {
+ // If the element being added is not an AssocNode or does not have a symbol
+ // key, then we want to turn the SYMBOL_KEYS flag off.
+ if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE) || !PM_NODE_TYPE_P(((pm_assoc_node_t *) element)->key, PM_SYMBOL_NODE)) {
+ pm_node_flag_unset(UP(hash), PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS);
+ }
+
+ pm_node_list_append(arena, &hash->elements, element);
+ if (PM_NODE_LENGTH(hash) == 0) {
+ PM_NODE_START_SET_NODE(hash, element);
+ }
+ PM_NODE_LENGTH_SET_NODE(hash, element);
+}
+
+/**
+ * Allocate and initialize a new RequiredKeywordParameterNode node.
+ */
+static pm_required_keyword_parameter_node_t *
+pm_required_keyword_parameter_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ return pm_required_keyword_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_parser_constant_id_raw(parser, name->start, name->end - 1),
+ TOK2LOC(parser, name)
+ );
+}
+
+/**
+ * Allocate a new OptionalKeywordParameterNode node.
+ */
+static pm_optional_keyword_parameter_node_t *
+pm_optional_keyword_parameter_node_create(pm_parser_t *parser, const pm_token_t *name, pm_node_t *value) {
+ return pm_optional_keyword_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, name, value),
+ pm_parser_constant_id_raw(parser, name->start, name->end - 1),
+ TOK2LOC(parser, name),
+ value
+ );
+}
+
+/**
+ * Allocate a new KeywordRestParameterNode node.
+ */
+static pm_keyword_rest_parameter_node_t *
+pm_keyword_rest_parameter_node_create(pm_parser_t *parser, const pm_token_t *operator, const pm_token_t *name) {
+ return pm_keyword_rest_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (name == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKENS(parser, operator, name),
+ name == NULL ? 0 : pm_parser_constant_id_token(parser, name),
+ NTOK2LOC(parser, name),
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate a new LambdaNode node.
+ */
+static pm_lambda_node_t *
+pm_lambda_node_create(
+ pm_parser_t *parser,
+ pm_constant_id_list_t *locals,
+ const pm_token_t *operator,
+ const pm_token_t *opening,
+ const pm_token_t *closing,
+ pm_node_t *parameters,
+ pm_node_t *body
+) {
+ return pm_lambda_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, operator, closing),
+ *locals,
+ TOK2LOC(parser, operator),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing),
+ parameters,
+ body
+ );
+}
+
+/**
+ * Allocate and initialize a new LocalVariableAndWriteNode node.
+ */
+static pm_local_variable_and_write_node_t *
+pm_local_variable_and_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value, pm_constant_id_t name, uint32_t depth) {
+ assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_IT_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE));
+ assert(operator->type == PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+
+ return pm_local_variable_and_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->location,
+ TOK2LOC(parser, operator),
+ value,
+ name,
+ depth
+ );
+}
+
+/**
+ * Allocate and initialize a new LocalVariableOperatorWriteNode node.
+ */
+static pm_local_variable_operator_write_node_t *
+pm_local_variable_operator_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value, pm_constant_id_t name, uint32_t depth) {
+ return pm_local_variable_operator_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->location,
+ TOK2LOC(parser, operator),
+ value,
+ name,
+ pm_parser_constant_id_raw(parser, operator->start, operator->end - 1),
+ depth
+ );
+}
+
+/**
+ * Allocate and initialize a new LocalVariableOrWriteNode node.
+ */
+static pm_local_variable_or_write_node_t *
+pm_local_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, const pm_token_t *operator, pm_node_t *value, pm_constant_id_t name, uint32_t depth) {
+ assert(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_IT_LOCAL_VARIABLE_READ_NODE) || PM_NODE_TYPE_P(target, PM_CALL_NODE));
+ assert(operator->type == PM_TOKEN_PIPE_PIPE_EQUAL);
+
+ return pm_local_variable_or_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(target, value),
+ target->location,
+ TOK2LOC(parser, operator),
+ value,
+ name,
+ depth
+ );
+}
+
+/**
+ * Allocate a new LocalVariableReadNode node with constant_id.
+ */
+static pm_local_variable_read_node_t *
+pm_local_variable_read_node_create_constant_id(pm_parser_t *parser, const pm_token_t *name, pm_constant_id_t name_id, uint32_t depth, bool missing) {
+ if (!missing) pm_locals_read(&pm_parser_scope_find(parser, depth)->locals, name_id);
+
+ return pm_local_variable_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ name_id,
+ depth
+ );
+}
+
+/**
+ * Allocate and initialize a new LocalVariableReadNode node.
+ */
+static pm_local_variable_read_node_t *
+pm_local_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name, uint32_t depth) {
+ pm_constant_id_t name_id = pm_parser_constant_id_token(parser, name);
+ return pm_local_variable_read_node_create_constant_id(parser, name, name_id, depth, false);
+}
+
+/**
+ * Allocate and initialize a new LocalVariableReadNode node for a missing local
+ * variable. (This will only happen when there is a syntax error.)
+ */
+static pm_local_variable_read_node_t *
+pm_local_variable_read_node_missing_create(pm_parser_t *parser, const pm_token_t *name, uint32_t depth) {
+ pm_constant_id_t name_id = pm_parser_constant_id_token(parser, name);
+ return pm_local_variable_read_node_create_constant_id(parser, name, name_id, depth, true);
+}
+
+/**
+ * Allocate and initialize a new LocalVariableWriteNode node.
+ */
+static pm_local_variable_write_node_t *
+pm_local_variable_write_node_create(pm_parser_t *parser, pm_constant_id_t name, uint32_t depth, pm_node_t *value, const pm_location_t *name_loc, const pm_token_t *operator) {
+ return pm_local_variable_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ ((pm_location_t) { .start = name_loc->start, .length = PM_NODE_END(value) - name_loc->start }),
+ name,
+ depth,
+ *name_loc,
+ value,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Returns true if the given bounds comprise `it`.
+ */
+static PRISM_INLINE bool
+pm_token_is_it(const uint8_t *start, const uint8_t *end) {
+ return (end - start == 2) && (start[0] == 'i') && (start[1] == 't');
+}
+
+/**
+ * Returns true if the given bounds comprise a numbered parameter (i.e., they
+ * are of the form /^_\d$/).
+ */
+static PRISM_INLINE bool
+pm_token_is_numbered_parameter(const pm_parser_t *parser, uint32_t start, uint32_t length) {
+ return (
+ (length == 2) &&
+ (parser->start[start] == '_') &&
+ (parser->start[start + 1] != '0') &&
+ pm_char_is_decimal_digit(parser->start[start + 1])
+ );
+}
+
+/**
+ * Ensure the given bounds do not comprise a numbered parameter. If they do, add
+ * an appropriate error message to the parser.
+ */
+static PRISM_INLINE void
+pm_refute_numbered_parameter(pm_parser_t *parser, uint32_t start, uint32_t length) {
+ if (pm_token_is_numbered_parameter(parser, start, length)) {
+ PM_PARSER_ERR_FORMAT(parser, start, length, PM_ERR_PARAMETER_NUMBERED_RESERVED, parser->start + start);
+ }
+}
+
+/**
+ * Allocate and initialize a new LocalVariableTargetNode node with the given
+ * name and depth.
+ */
+static pm_local_variable_target_node_t *
+pm_local_variable_target_node_create(pm_parser_t *parser, const pm_location_t *location, pm_constant_id_t name, uint32_t depth) {
+ pm_refute_numbered_parameter(parser, location->start, location->length);
+
+ return pm_local_variable_target_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = location->start, .length = location->length }),
+ name,
+ depth
+ );
+}
+
+/**
+ * Allocate and initialize a new MatchPredicateNode node.
+ */
+static pm_match_predicate_node_t *
+pm_match_predicate_node_create(pm_parser_t *parser, pm_node_t *value, pm_node_t *pattern, const pm_token_t *operator) {
+ pm_assert_value_expression(parser, value);
+
+ return pm_match_predicate_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(value, pattern),
+ value,
+ pattern,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new MatchRequiredNode node.
+ */
+static pm_match_required_node_t *
+pm_match_required_node_create(pm_parser_t *parser, pm_node_t *value, pm_node_t *pattern, const pm_token_t *operator) {
+ pm_assert_value_expression(parser, value);
+
+ return pm_match_required_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(value, pattern),
+ value,
+ pattern,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new MatchWriteNode node.
+ */
+static pm_match_write_node_t *
+pm_match_write_node_create(pm_parser_t *parser, pm_call_node_t *call) {
+ return pm_match_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODE(call),
+ call,
+ ((pm_node_list_t) { 0 })
+ );
+}
+
+/**
+ * Allocate a new ModuleNode node.
+ */
+static pm_module_node_t *
+pm_module_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *module_keyword, pm_node_t *constant_path, const pm_token_t *name, pm_node_t *body, const pm_token_t *end_keyword) {
+ return pm_module_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, module_keyword, end_keyword),
+ (locals == NULL ? ((pm_constant_id_list_t) { .ids = NULL, .size = 0, .capacity = 0 }) : *locals),
+ TOK2LOC(parser, module_keyword),
+ constant_path,
+ body,
+ TOK2LOC(parser, end_keyword),
+ pm_parser_constant_id_token(parser, name)
+ );
+}
+
+/**
+ * Allocate and initialize new MultiTargetNode node.
+ */
+static pm_multi_target_node_t *
+pm_multi_target_node_create(pm_parser_t *parser) {
+ return pm_multi_target_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Append a target to a MultiTargetNode node.
+ */
+static void
+pm_multi_target_node_targets_append(pm_parser_t *parser, pm_multi_target_node_t *node, pm_node_t *target) {
+ if (PM_NODE_TYPE_P(target, PM_SPLAT_NODE)) {
+ if (node->rest == NULL) {
+ node->rest = target;
+ } else {
+ pm_parser_err_node(parser, target, PM_ERR_MULTI_ASSIGN_MULTI_SPLATS);
+ pm_node_list_append(parser->arena, &node->rights, target);
+ }
+ } else if (PM_NODE_TYPE_P(target, PM_IMPLICIT_REST_NODE)) {
+ if (node->rest == NULL) {
+ node->rest = target;
+ } else {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &parser->current, PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST);
+ pm_node_list_append(parser->arena, &node->rights, target);
+ }
+ } else if (node->rest == NULL) {
+ pm_node_list_append(parser->arena, &node->lefts, target);
+ } else {
+ pm_node_list_append(parser->arena, &node->rights, target);
+ }
+
+ if (PM_NODE_LENGTH(node) == 0 || (PM_NODE_START(node) > PM_NODE_START(target))) {
+ PM_NODE_START_SET_NODE(node, target);
+ }
+
+ if (PM_NODE_LENGTH(node) == 0 || (PM_NODE_END(node) < PM_NODE_END(target))) {
+ PM_NODE_LENGTH_SET_NODE(node, target);
+ }
+}
+
+/**
+ * Set the opening of a MultiTargetNode node.
+ */
+static void
+pm_multi_target_node_opening_set(const pm_parser_t *parser, pm_multi_target_node_t *node, const pm_token_t *lparen) {
+ PM_NODE_START_SET_TOKEN(parser, node, lparen);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, lparen);
+ node->lparen_loc = TOK2LOC(parser, lparen);
+}
+
+/**
+ * Set the closing of a MultiTargetNode node.
+ */
+static void
+pm_multi_target_node_closing_set(const pm_parser_t *parser, pm_multi_target_node_t *node, const pm_token_t *rparen) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, rparen);
+ node->rparen_loc = TOK2LOC(parser, rparen);
+}
+
+/**
+ * Allocate a new MultiWriteNode node.
+ */
+static pm_multi_write_node_t *
+pm_multi_write_node_create(pm_parser_t *parser, pm_multi_target_node_t *target, const pm_token_t *operator, pm_node_t *value) {
+ /* The target is no longer necessary because we have reused its children. It
+ * is arena-allocated so no explicit free is needed. */
+ return pm_multi_write_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_implicit_array_write_flags(value, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY),
+ PM_LOCATION_INIT_NODES(target, value),
+ target->lefts,
+ target->rest,
+ target->rights,
+ target->lparen_loc,
+ target->rparen_loc,
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new NextNode node.
+ */
+static pm_next_node_t *
+pm_next_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_arguments_node_t *arguments) {
+ assert(keyword->type == PM_TOKEN_KEYWORD_NEXT);
+
+ return pm_next_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (arguments == NULL) ? PM_LOCATION_INIT_TOKEN(parser, keyword) : PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, arguments),
+ arguments,
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new NilNode node.
+ */
+static pm_nil_node_t *
+pm_nil_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_NIL);
+
+ return pm_nil_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new NoKeywordsParameterNode node.
+ */
+static pm_no_block_parameter_node_t *
+pm_no_block_parameter_node_create(pm_parser_t *parser, const pm_token_t *operator, const pm_token_t *keyword) {
+ assert(operator->type == PM_TOKEN_AMPERSAND || operator->type == PM_TOKEN_UAMPERSAND);
+ assert(keyword->type == PM_TOKEN_KEYWORD_NIL);
+
+ return pm_no_block_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, operator, keyword),
+ TOK2LOC(parser, operator),
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new NoKeywordsParameterNode node.
+ */
+static pm_no_keywords_parameter_node_t *
+pm_no_keywords_parameter_node_create(pm_parser_t *parser, const pm_token_t *operator, const pm_token_t *keyword) {
+ assert(operator->type == PM_TOKEN_USTAR_STAR || operator->type == PM_TOKEN_STAR_STAR);
+ assert(keyword->type == PM_TOKEN_KEYWORD_NIL);
+
+ return pm_no_keywords_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, operator, keyword),
+ TOK2LOC(parser, operator),
+ TOK2LOC(parser, keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new NumberedParametersNode node.
+ */
+static pm_numbered_parameters_node_t *
+pm_numbered_parameters_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *closing, uint8_t maximum) {
+ return pm_numbered_parameters_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ maximum
+ );
+}
+
+/**
+ * The maximum numbered reference value is defined as the maximum value that an
+ * integer can hold minus 1 bit for CRuby instruction sequence operand tagging.
+ */
+#define NTH_REF_MAX ((uint32_t) (INT_MAX >> 1))
+
+/**
+ * Parse the decimal number represented by the range of bytes. Returns
+ * 0 if the number fails to parse or if the number is greater than the maximum
+ * value representable by a numbered reference. This function assumes that the
+ * range of bytes has already been validated to contain only decimal digits.
+ */
+static uint32_t
+pm_numbered_reference_read_node_number(pm_parser_t *parser, const pm_token_t *token) {
+ const uint8_t *start = token->start + 1;
+ const uint8_t *end = token->end;
+
+ ptrdiff_t diff = end - start;
+ assert(diff > 0);
+#if PTRDIFF_MAX > SIZE_MAX
+ assert(diff < (ptrdiff_t) SIZE_MAX);
+#endif
+ size_t length = (size_t) diff;
+
+ char *digits = xcalloc(length + 1, sizeof(char));
+ memcpy(digits, start, length);
+ digits[length] = '\0';
+
+ char *endptr;
+ errno = 0;
+ unsigned long value = strtoul(digits, &endptr, 10);
+
+ if ((digits == endptr) || (*endptr != '\0')) {
+ pm_parser_err(parser, U32(start - parser->start), U32(length), PM_ERR_INVALID_NUMBER_DECIMAL);
+ value = 0;
+ }
+
+ xfree_sized(digits, sizeof(char) * (length + 1));
+
+ if ((errno == ERANGE) || (value > NTH_REF_MAX)) {
+ PM_PARSER_WARN_FORMAT(parser, U32(start - parser->start), U32(length), PM_WARN_INVALID_NUMBERED_REFERENCE, (int) (length + 1), (const char *) token->start);
+ value = 0;
+ }
+
+ return (uint32_t) value;
+}
+
+#undef NTH_REF_MAX
+
+/**
+ * Allocate and initialize a new NthReferenceReadNode node.
+ */
+static pm_numbered_reference_read_node_t *
+pm_numbered_reference_read_node_create(pm_parser_t *parser, const pm_token_t *name) {
+ assert(name->type == PM_TOKEN_NUMBERED_REFERENCE);
+
+ return pm_numbered_reference_read_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, name),
+ pm_numbered_reference_read_node_number(parser, name)
+ );
+}
+
+/**
+ * Allocate a new OptionalParameterNode node.
+ */
+static pm_optional_parameter_node_t *
+pm_optional_parameter_node_create(pm_parser_t *parser, const pm_token_t *name, const pm_token_t *operator, pm_node_t *value) {
+ return pm_optional_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, name, value),
+ pm_parser_constant_id_token(parser, name),
+ TOK2LOC(parser, name),
+ TOK2LOC(parser, operator),
+ value
+ );
+}
+
+/**
+ * Allocate and initialize a new OrNode node.
+ */
+static pm_or_node_t *
+pm_or_node_create(pm_parser_t *parser, pm_node_t *left, const pm_token_t *operator, pm_node_t *right) {
+ pm_assert_value_expression(parser, left);
+
+ return pm_or_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(left, right),
+ left,
+ right,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new ParametersNode node.
+ */
+static pm_parameters_node_t *
+pm_parameters_node_create(pm_parser_t *parser) {
+ return pm_parameters_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 }),
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ ((pm_node_list_t) { 0 }),
+ ((pm_node_list_t) { 0 }),
+ NULL,
+ NULL
+ );
+}
+
+/**
+ * Set the location properly for the parameters node.
+ */
+static void
+pm_parameters_node_location_set(pm_parameters_node_t *params, pm_node_t *param) {
+ if ((params->base.location.length == 0) || PM_NODE_START(params) > PM_NODE_START(param)) {
+ PM_NODE_START_SET_NODE(params, param);
+ }
+
+ if ((params->base.location.length == 0) || (PM_NODE_END(params) < PM_NODE_END(param))) {
+ PM_NODE_LENGTH_SET_NODE(params, param);
+ }
+}
+
+/**
+ * Append a required parameter to a ParametersNode node.
+ */
+static void
+pm_parameters_node_requireds_append(pm_arena_t *arena, pm_parameters_node_t *params, pm_node_t *param) {
+ pm_parameters_node_location_set(params, param);
+ pm_node_list_append(arena, &params->requireds, param);
+}
+
+/**
+ * Append an optional parameter to a ParametersNode node.
+ */
+static void
+pm_parameters_node_optionals_append(pm_arena_t *arena, pm_parameters_node_t *params, pm_optional_parameter_node_t *param) {
+ pm_parameters_node_location_set(params, UP(param));
+ pm_node_list_append(arena, &params->optionals, UP(param));
+}
+
+/**
+ * Append a post optional arguments parameter to a ParametersNode node.
+ */
+static void
+pm_parameters_node_posts_append(pm_arena_t *arena, pm_parameters_node_t *params, pm_node_t *param) {
+ pm_parameters_node_location_set(params, param);
+ pm_node_list_append(arena, &params->posts, param);
+}
+
+/**
+ * Set the rest parameter on a ParametersNode node.
+ */
+static void
+pm_parameters_node_rest_set(pm_parameters_node_t *params, pm_node_t *param) {
+ pm_parameters_node_location_set(params, param);
+ params->rest = param;
+}
+
+/**
+ * Append a keyword parameter to a ParametersNode node.
+ */
+static void
+pm_parameters_node_keywords_append(pm_arena_t *arena, pm_parameters_node_t *params, pm_node_t *param) {
+ pm_parameters_node_location_set(params, param);
+ pm_node_list_append(arena, &params->keywords, param);
+}
+
+/**
+ * Set the keyword rest parameter on a ParametersNode node.
+ */
+static void
+pm_parameters_node_keyword_rest_set(pm_parameters_node_t *params, pm_node_t *param) {
+ assert(params->keyword_rest == NULL);
+ pm_parameters_node_location_set(params, param);
+ params->keyword_rest = param;
+}
+
+/**
+ * Set the block parameter on a ParametersNode node.
+ */
+static void
+pm_parameters_node_block_set(pm_parameters_node_t *params, pm_node_t *param) {
+ assert(params->block == NULL);
+ pm_parameters_node_location_set(params, param);
+ params->block = param;
+}
+
+/**
+ * Allocate a new ProgramNode node.
+ */
+static pm_program_node_t *
+pm_program_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, pm_statements_node_t *statements) {
+ return pm_program_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODE(statements),
+ *locals,
+ statements
+ );
+}
+
+/**
+ * Allocate and initialize new ParenthesesNode node.
+ */
+static pm_parentheses_node_t *
+pm_parentheses_node_create(pm_parser_t *parser, const pm_token_t *opening, pm_node_t *body, const pm_token_t *closing, pm_node_flags_t flags) {
+ return pm_parentheses_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ body,
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new PinnedExpressionNode node.
+ */
+static pm_pinned_expression_node_t *
+pm_pinned_expression_node_create(pm_parser_t *parser, pm_node_t *expression, const pm_token_t *operator, const pm_token_t *lparen, const pm_token_t *rparen) {
+ return pm_pinned_expression_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, operator, rparen),
+ expression,
+ TOK2LOC(parser, operator),
+ TOK2LOC(parser, lparen),
+ TOK2LOC(parser, rparen)
+ );
+}
+
+/**
+ * Allocate and initialize a new PinnedVariableNode node.
+ */
+static pm_pinned_variable_node_t *
+pm_pinned_variable_node_create(pm_parser_t *parser, const pm_token_t *operator, pm_node_t *variable) {
+ return pm_pinned_variable_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, operator, variable),
+ variable,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new PostExecutionNode node.
+ */
+static pm_post_execution_node_t *
+pm_post_execution_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_token_t *opening, pm_statements_node_t *statements, const pm_token_t *closing) {
+ return pm_post_execution_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, keyword, closing),
+ statements,
+ TOK2LOC(parser, keyword),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize a new PreExecutionNode node.
+ */
+static pm_pre_execution_node_t *
+pm_pre_execution_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_token_t *opening, pm_statements_node_t *statements, const pm_token_t *closing) {
+ return pm_pre_execution_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, keyword, closing),
+ statements,
+ TOK2LOC(parser, keyword),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, closing)
+ );
+}
+
+/**
+ * Allocate and initialize new RangeNode node.
+ */
+static pm_range_node_t *
+pm_range_node_create(pm_parser_t *parser, pm_node_t *left, const pm_token_t *operator, pm_node_t *right) {
+ pm_assert_value_expression(parser, left);
+ pm_assert_value_expression(parser, right);
+ pm_node_flags_t flags = 0;
+
+ // Indicate that this node is an exclusive range if the operator is `...`.
+ if (operator->type == PM_TOKEN_DOT_DOT_DOT || operator->type == PM_TOKEN_UDOT_DOT_DOT) {
+ flags |= PM_RANGE_FLAGS_EXCLUDE_END;
+ }
+
+ // Indicate that this node is a static literal (i.e., can be compiled with
+ // a putobject in CRuby) if the left and right are implicit nil, explicit
+ // nil, or integers.
+ if (
+ (left == NULL || PM_NODE_TYPE_P(left, PM_NIL_NODE) || PM_NODE_TYPE_P(left, PM_INTEGER_NODE)) &&
+ (right == NULL || PM_NODE_TYPE_P(right, PM_NIL_NODE) || PM_NODE_TYPE_P(right, PM_INTEGER_NODE))
+ ) {
+ flags |= PM_NODE_FLAG_STATIC_LITERAL;
+ }
+
+ uint32_t start = left == NULL ? PM_TOKEN_START(parser, operator) : PM_NODE_START(left);
+ uint32_t end = right == NULL ? PM_TOKEN_END(parser, operator) : PM_NODE_END(right);
+
+ return pm_range_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ left,
+ right,
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new RedoNode node.
+ */
+static pm_redo_node_t *
+pm_redo_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_REDO);
+
+ return pm_redo_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate a new initialize a new RegularExpressionNode node with the given
+ * unescaped string.
+ */
+static pm_regular_expression_node_t *
+pm_regular_expression_node_create_unescaped(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing, const pm_string_t *unescaped) {
+ return pm_regular_expression_node_new(
+ parser->arena,
+ ++parser->node_id,
+ pm_regular_expression_flags_create(parser, closing) | PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, content),
+ TOK2LOC(parser, closing),
+ *unescaped
+ );
+}
+
+/**
+ * Allocate a new initialize a new RegularExpressionNode node.
+ */
+static PRISM_INLINE pm_regular_expression_node_t *
+pm_regular_expression_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing) {
+ return pm_regular_expression_node_create_unescaped(parser, opening, content, closing, &PM_STRING_EMPTY);
+}
+
+/**
+ * Allocate a new RequiredParameterNode node.
+ */
+static pm_required_parameter_node_t *
+pm_required_parameter_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ return pm_required_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ pm_parser_constant_id_token(parser, token)
+ );
+}
+
+/**
+ * Allocate a new RescueModifierNode node.
+ */
+static pm_rescue_modifier_node_t *
+pm_rescue_modifier_node_create(pm_parser_t *parser, pm_node_t *expression, const pm_token_t *keyword, pm_node_t *rescue_expression) {
+ return pm_rescue_modifier_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_NODES(expression, rescue_expression),
+ expression,
+ TOK2LOC(parser, keyword),
+ rescue_expression
+ );
+}
+
+/**
+ * Allocate and initialize a new RescueNode node.
+ */
+static pm_rescue_node_t *
+pm_rescue_node_create(pm_parser_t *parser, const pm_token_t *keyword) {
+ return pm_rescue_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, keyword),
+ TOK2LOC(parser, keyword),
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ NULL,
+ ((pm_location_t) { 0 }),
+ NULL,
+ NULL
+ );
+}
+
+static PRISM_INLINE void
+pm_rescue_node_operator_set(const pm_parser_t *parser, pm_rescue_node_t *node, const pm_token_t *operator) {
+ node->operator_loc = TOK2LOC(parser, operator);
+}
+
+/**
+ * Set the reference of a rescue node, and update the location of the node.
+ */
+static void
+pm_rescue_node_reference_set(pm_rescue_node_t *node, pm_node_t *reference) {
+ node->reference = reference;
+ PM_NODE_LENGTH_SET_NODE(node, reference);
+}
+
+/**
+ * Set the statements of a rescue node, and update the location of the node.
+ */
+static void
+pm_rescue_node_statements_set(pm_rescue_node_t *node, pm_statements_node_t *statements) {
+ node->statements = statements;
+ if (pm_statements_node_body_length(statements) > 0) {
+ PM_NODE_LENGTH_SET_NODE(node, statements);
+ }
+}
+
+/**
+ * Set the subsequent of a rescue node, and update the location.
+ */
+static void
+pm_rescue_node_subsequent_set(pm_rescue_node_t *node, pm_rescue_node_t *subsequent) {
+ node->subsequent = subsequent;
+ PM_NODE_LENGTH_SET_NODE(node, subsequent);
+}
+
+/**
+ * Append an exception node to a rescue node, and update the location.
+ */
+static void
+pm_rescue_node_exceptions_append(pm_arena_t *arena, pm_rescue_node_t *node, pm_node_t *exception) {
+ pm_node_list_append(arena, &node->exceptions, exception);
+ PM_NODE_LENGTH_SET_NODE(node, exception);
+}
+
+/**
+ * Allocate a new RestParameterNode node.
+ */
+static pm_rest_parameter_node_t *
+pm_rest_parameter_node_create(pm_parser_t *parser, const pm_token_t *operator, const pm_token_t *name) {
+ return pm_rest_parameter_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (name == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKENS(parser, operator, name),
+ name == NULL ? 0 : pm_parser_constant_id_token(parser, name),
+ NTOK2LOC(parser, name),
+ TOK2LOC(parser, operator)
+ );
+}
+
+/**
+ * Allocate and initialize a new RetryNode node.
+ */
+static pm_retry_node_t *
+pm_retry_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_RETRY);
+
+ return pm_retry_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate a new ReturnNode node.
+ */
+static pm_return_node_t *
+pm_return_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_arguments_node_t *arguments) {
+ return pm_return_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (arguments == NULL) ? PM_LOCATION_INIT_TOKEN(parser, keyword) : PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, arguments),
+ TOK2LOC(parser, keyword),
+ arguments
+ );
+}
+
+/**
+ * Allocate and initialize a new SelfNode node.
+ */
+static pm_self_node_t *
+pm_self_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_SELF);
+
+ return pm_self_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new ShareableConstantNode node.
+ */
+static pm_shareable_constant_node_t *
+pm_shareable_constant_node_create(pm_parser_t *parser, pm_node_t *write, pm_shareable_constant_value_t value) {
+ return pm_shareable_constant_node_new(
+ parser->arena,
+ ++parser->node_id,
+ (pm_node_flags_t) value,
+ PM_LOCATION_INIT_NODE(write),
+ write
+ );
+}
+
+/**
+ * Allocate a new SingletonClassNode node.
+ */
+static pm_singleton_class_node_t *
+pm_singleton_class_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *class_keyword, const pm_token_t *operator, pm_node_t *expression, pm_node_t *body, const pm_token_t *end_keyword) {
+ return pm_singleton_class_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKENS(parser, class_keyword, end_keyword),
+ *locals,
+ TOK2LOC(parser, class_keyword),
+ TOK2LOC(parser, operator),
+ expression,
+ body,
+ TOK2LOC(parser, end_keyword)
+ );
+}
+
+/**
+ * Allocate and initialize a new SourceEncodingNode node.
+ */
+static pm_source_encoding_node_t *
+pm_source_encoding_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD___ENCODING__);
+
+ return pm_source_encoding_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new SourceFileNode node.
+ */
+static pm_source_file_node_t*
+pm_source_file_node_create(pm_parser_t *parser, const pm_token_t *file_keyword) {
+ assert(file_keyword->type == PM_TOKEN_KEYWORD___FILE__);
+
+ pm_node_flags_t flags = 0;
+
+ switch (parser->frozen_string_literal) {
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED:
+ flags |= PM_STRING_FLAGS_MUTABLE;
+ break;
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED:
+ flags |= PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN;
+ break;
+ }
+
+ return pm_source_file_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_TOKEN(parser, file_keyword),
+ parser->filepath
+ );
+}
+
+/**
+ * Allocate and initialize a new SourceLineNode node.
+ */
+static pm_source_line_node_t *
+pm_source_line_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD___LINE__);
+
+ return pm_source_line_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate a new SplatNode node.
+ */
+static pm_splat_node_t *
+pm_splat_node_create(pm_parser_t *parser, const pm_token_t *operator, pm_node_t *expression) {
+ return pm_splat_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ (expression == NULL) ? PM_LOCATION_INIT_TOKEN(parser, operator) : PM_LOCATION_INIT_TOKEN_NODE(parser, operator, expression),
+ TOK2LOC(parser, operator),
+ expression
+ );
+}
+
+/**
+ * Allocate and initialize a new StatementsNode node.
+ */
+static pm_statements_node_t *
+pm_statements_node_create(pm_parser_t *parser) {
+ return pm_statements_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_node_list_t) { 0 })
+ );
+}
+
+/**
+ * Get the length of the given StatementsNode node's body.
+ */
+static size_t
+pm_statements_node_body_length(pm_statements_node_t *node) {
+ return node && node->body.size;
+}
+
+/**
+ * Update the location of the statements node based on the statement that is
+ * being added to the list.
+ */
+static PRISM_INLINE void
+pm_statements_node_body_update(pm_statements_node_t *node, pm_node_t *statement) {
+ if (pm_statements_node_body_length(node) == 0 || PM_NODE_START(statement) < PM_NODE_START(node)) {
+ PM_NODE_START_SET_NODE(node, statement);
+ }
+
+ if (PM_NODE_END(statement) > PM_NODE_END(node)) {
+ PM_NODE_LENGTH_SET_NODE(node, statement);
+ }
+}
+
+/**
+ * Append a new node to the given StatementsNode node's body.
+ */
+static void
+pm_statements_node_body_append(pm_parser_t *parser, pm_statements_node_t *node, pm_node_t *statement, bool newline) {
+ pm_statements_node_body_update(node, statement);
+
+ if (node->body.size > 0) {
+ const pm_node_t *previous = node->body.nodes[node->body.size - 1];
+
+ switch (PM_NODE_TYPE(previous)) {
+ case PM_BREAK_NODE:
+ case PM_NEXT_NODE:
+ case PM_REDO_NODE:
+ case PM_RETRY_NODE:
+ case PM_RETURN_NODE:
+ pm_parser_warn_node(parser, statement, PM_WARN_UNREACHABLE_STATEMENT);
+ break;
+ default:
+ break;
+ }
+ }
+
+ pm_node_list_append(parser->arena, &node->body, statement);
+ if (newline) pm_node_flag_set(statement, PM_NODE_FLAG_NEWLINE);
+}
+
+/**
+ * Prepend a new node to the given StatementsNode node's body.
+ */
+static void
+pm_statements_node_body_prepend(pm_arena_t *arena, pm_statements_node_t *node, pm_node_t *statement) {
+ pm_statements_node_body_update(node, statement);
+ pm_node_list_prepend(arena, &node->body, statement);
+ pm_node_flag_set(statement, PM_NODE_FLAG_NEWLINE);
+}
+
+/**
+ * Allocate a new StringNode node with the current string on the parser.
+ */
+static PRISM_INLINE pm_string_node_t *
+pm_string_node_create_unescaped(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing, const pm_string_t *string) {
+ pm_node_flags_t flags = 0;
+
+ switch (parser->frozen_string_literal) {
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED:
+ flags = PM_STRING_FLAGS_MUTABLE;
+ break;
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED:
+ flags = PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN;
+ break;
+ }
+
+ uint32_t start = PM_TOKEN_START(parser, opening == NULL ? content : opening);
+ uint32_t end = PM_TOKEN_END(parser, closing == NULL ? content : closing);
+
+ return pm_string_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NTOK2LOC(parser, opening),
+ TOK2LOC(parser, content),
+ NTOK2LOC(parser, closing),
+ *string
+ );
+}
+
+/**
+ * Allocate a new StringNode node.
+ */
+static pm_string_node_t *
+pm_string_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing) {
+ return pm_string_node_create_unescaped(parser, opening, content, closing, &PM_STRING_EMPTY);
+}
+
+/**
+ * Allocate a new StringNode node and create it using the current string on the
+ * parser.
+ */
+static pm_string_node_t *
+pm_string_node_create_current_string(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing) {
+ pm_string_node_t *node = pm_string_node_create_unescaped(parser, opening, content, closing, &parser->current_string);
+ parser->current_string = PM_STRING_EMPTY;
+ return node;
+}
+
+/**
+ * Allocate and initialize a new SuperNode node.
+ */
+static pm_super_node_t *
+pm_super_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_arguments_t *arguments) {
+ assert(keyword->type == PM_TOKEN_KEYWORD_SUPER);
+
+ const pm_location_t *end = pm_arguments_end(arguments);
+ assert(end != NULL && "unreachable");
+
+ return pm_super_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = PM_TOKEN_START(parser, keyword), .length = PM_LOCATION_END(end) - PM_TOKEN_START(parser, keyword) }),
+ TOK2LOC(parser, keyword),
+ arguments->opening_loc,
+ arguments->arguments,
+ arguments->closing_loc,
+ arguments->block
+ );
+}
+
+/**
+ * Read through the contents of a string and check if it consists solely of
+ * US-ASCII code points.
+ */
+static bool
+pm_ascii_only_p(const pm_string_t *contents) {
+ const size_t length = pm_string_length(contents);
+ const uint8_t *source = pm_string_source(contents);
+
+ for (size_t index = 0; index < length; index++) {
+ if (source[index] & 0x80) return false;
+ }
+
+ return true;
+}
+
+/**
+ * Validate that the contents of the given symbol are all valid UTF-8.
+ */
+static void
+parse_symbol_encoding_validate_utf8(pm_parser_t *parser, const pm_token_t *location, const pm_string_t *contents) {
+ for (const uint8_t *cursor = pm_string_source(contents), *end = cursor + pm_string_length(contents); cursor < end;) {
+ size_t width = pm_encoding_utf_8_char_width(cursor, end - cursor);
+
+ if (width == 0) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, location), PM_TOKEN_LENGTH(location), PM_ERR_INVALID_SYMBOL);
+ break;
+ }
+
+ cursor += width;
+ }
+}
+
+/**
+ * Validate that the contents of the given symbol are all valid in the encoding
+ * of the parser.
+ */
+static void
+parse_symbol_encoding_validate_other(pm_parser_t *parser, const pm_token_t *location, const pm_string_t *contents) {
+ const pm_encoding_t *encoding = parser->encoding;
+
+ for (const uint8_t *cursor = pm_string_source(contents), *end = cursor + pm_string_length(contents); cursor < end;) {
+ size_t width = encoding->char_width(cursor, end - cursor);
+
+ if (width == 0) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, location), PM_TOKEN_LENGTH(location), PM_ERR_INVALID_SYMBOL);
+ break;
+ }
+
+ cursor += width;
+ }
+}
+
+/**
+ * Ruby "downgrades" the encoding of Symbols to US-ASCII if the associated
+ * encoding is ASCII-compatible and the Symbol consists only of US-ASCII code
+ * points. Otherwise, the encoding may be explicitly set with an escape
+ * sequence.
+ *
+ * If the validate flag is set, then it will check the contents of the symbol
+ * to ensure that all characters are valid in the encoding.
+ */
+static PRISM_INLINE pm_node_flags_t
+parse_symbol_encoding(pm_parser_t *parser, const pm_token_t *location, const pm_string_t *contents, bool validate) {
+ if (parser->explicit_encoding != NULL) {
+ // A Symbol may optionally have its encoding explicitly set. This will
+ // happen if an escape sequence results in a non-ASCII code point.
+ if (parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY) {
+ if (validate) parse_symbol_encoding_validate_utf8(parser, location, contents);
+ return PM_SYMBOL_FLAGS_FORCED_UTF8_ENCODING;
+ } else if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY) {
+ return PM_SYMBOL_FLAGS_FORCED_BINARY_ENCODING;
+ } else if (validate) {
+ parse_symbol_encoding_validate_other(parser, location, contents);
+ }
+ } else if (pm_ascii_only_p(contents)) {
+ // Ruby stipulates that all source files must use an ASCII-compatible
+ // encoding. Thus, all symbols appearing in source are eligible for
+ // "downgrading" to US-ASCII.
+ return PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING;
+ } else if (validate) {
+ parse_symbol_encoding_validate_other(parser, location, contents);
+ }
+
+ return 0;
+}
+
+/**
+ * Allocate and initialize a new SymbolNode node with the given unescaped
+ * string.
+ */
+static pm_symbol_node_t *
+pm_symbol_node_create_unescaped(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *value, const pm_token_t *closing, const pm_string_t *unescaped, pm_node_flags_t flags) {
+ uint32_t start = opening == NULL ? PM_TOKEN_START(parser, value) : PM_TOKEN_START(parser, opening);
+ uint32_t end = closing == NULL ? PM_TOKEN_END(parser, value) : PM_TOKEN_END(parser, closing);
+
+ return pm_symbol_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL | flags,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ NTOK2LOC(parser, opening),
+ NTOK2LOC(parser, value),
+ NTOK2LOC(parser, closing),
+ *unescaped
+ );
+}
+
+/**
+ * Allocate and initialize a new SymbolNode node.
+ */
+static PRISM_INLINE pm_symbol_node_t *
+pm_symbol_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *value, const pm_token_t *closing) {
+ return pm_symbol_node_create_unescaped(parser, opening, value, closing, &PM_STRING_EMPTY, 0);
+}
+
+/**
+ * Allocate and initialize a new SymbolNode node with the current string.
+ */
+static pm_symbol_node_t *
+pm_symbol_node_create_current_string(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *value, const pm_token_t *closing) {
+ pm_symbol_node_t *node = pm_symbol_node_create_unescaped(parser, opening, value, closing, &parser->current_string, parse_symbol_encoding(parser, value, &parser->current_string, false));
+ parser->current_string = PM_STRING_EMPTY;
+ return node;
+}
+
+/**
+ * Allocate and initialize a new SymbolNode node from a label.
+ */
+static pm_symbol_node_t *
+pm_symbol_node_label_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_LABEL);
+
+ pm_token_t closing = { .type = PM_TOKEN_LABEL_END, .start = token->end - 1, .end = token->end };
+ pm_token_t label = { .type = PM_TOKEN_LABEL, .start = token->start, .end = token->end - 1 };
+ pm_symbol_node_t *node = pm_symbol_node_create(parser, NULL, &label, &closing);
+
+ assert((label.end - label.start) >= 0);
+ pm_string_shared_init(&node->unescaped, label.start, label.end);
+ pm_node_flag_set(UP(node), parse_symbol_encoding(parser, &label, &node->unescaped, false));
+
+ return node;
+}
+
+/**
+ * Allocate and initialize a new synthesized SymbolNode node.
+ */
+static pm_symbol_node_t *
+pm_symbol_node_synthesized_create(pm_parser_t *parser, const char *content) {
+ pm_symbol_node_t *node = pm_symbol_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL | PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_string_t) { 0 })
+ );
+
+ pm_string_constant_init(&node->unescaped, content, strlen(content));
+ return node;
+}
+
+/**
+ * Check if the given node is a label in a hash.
+ */
+static bool
+pm_symbol_node_label_p(const pm_parser_t *parser, const pm_node_t *node) {
+ const pm_location_t *location = NULL;
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_SYMBOL_NODE: {
+ const pm_symbol_node_t *cast = (pm_symbol_node_t *) node;
+ if (cast->closing_loc.length > 0) {
+ location = &cast->closing_loc;
+ }
+ break;
+ }
+ case PM_INTERPOLATED_SYMBOL_NODE: {
+ const pm_interpolated_symbol_node_t *cast = (pm_interpolated_symbol_node_t *) node;
+ if (cast->closing_loc.length > 0) {
+ location = &cast->closing_loc;
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return (location != NULL) && (parser->start[PM_LOCATION_END(location) - 1] == ':');
+}
+
+/**
+ * Convert the given StringNode node to a SymbolNode node.
+ */
+static pm_symbol_node_t *
+pm_string_node_to_symbol_node(pm_parser_t *parser, pm_string_node_t *node, const pm_token_t *opening, const pm_token_t *closing) {
+ pm_symbol_node_t *new_node = pm_symbol_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ TOK2LOC(parser, opening),
+ node->content_loc,
+ TOK2LOC(parser, closing),
+ node->unescaped
+ );
+
+ pm_token_t content = {
+ .type = PM_TOKEN_IDENTIFIER,
+ .start = parser->start + node->content_loc.start,
+ .end = parser->start + node->content_loc.start + node->content_loc.length
+ };
+
+ pm_node_flag_set(UP(new_node), parse_symbol_encoding(parser, &content, &node->unescaped, true));
+
+ /* The old node is arena-allocated so no explicit free is needed. */
+ return new_node;
+}
+
+/**
+ * Convert the given SymbolNode node to a StringNode node.
+ */
+static pm_string_node_t *
+pm_symbol_node_to_string_node(pm_parser_t *parser, pm_symbol_node_t *node) {
+ pm_node_flags_t flags = 0;
+
+ switch (parser->frozen_string_literal) {
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED:
+ flags = PM_STRING_FLAGS_MUTABLE;
+ break;
+ case PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED:
+ flags = PM_NODE_FLAG_STATIC_LITERAL | PM_STRING_FLAGS_FROZEN;
+ break;
+ }
+
+ pm_string_node_t *new_node = pm_string_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_NODE(node),
+ node->opening_loc,
+ node->value_loc,
+ node->closing_loc,
+ node->unescaped
+ );
+
+ /* The old node is arena-allocated so no explicit free is needed. */
+ return new_node;
+}
+
+/**
+ * Allocate and initialize a new TrueNode node.
+ */
+static pm_true_node_t *
+pm_true_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_TRUE);
+
+ return pm_true_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_TOKEN(parser, token)
+ );
+}
+
+/**
+ * Allocate and initialize a new synthesized TrueNode node.
+ */
+static pm_true_node_t *
+pm_true_node_synthesized_create(pm_parser_t *parser) {
+ return pm_true_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_STATIC_LITERAL,
+ PM_LOCATION_INIT_UNSET
+ );
+}
+
+/**
+ * Allocate and initialize a new UndefNode node.
+ */
+static pm_undef_node_t *
+pm_undef_node_create(pm_parser_t *parser, const pm_token_t *token) {
+ assert(token->type == PM_TOKEN_KEYWORD_UNDEF);
+
+ return pm_undef_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, token),
+ ((pm_node_list_t) { 0 }),
+ TOK2LOC(parser, token)
+ );
+}
+
+/**
+ * Append a name to an undef node.
+ */
+static void
+pm_undef_node_append(pm_arena_t *arena, pm_undef_node_t *node, pm_node_t *name) {
+ PM_NODE_LENGTH_SET_NODE(node, name);
+ pm_node_list_append(arena, &node->names, name);
+}
+
+/**
+ * Allocate a new UnlessNode node.
+ */
+static pm_unless_node_t *
+pm_unless_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t *predicate, const pm_token_t *then_keyword, pm_statements_node_t *statements) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ pm_node_t *end = statements == NULL ? predicate : UP(statements);
+
+ return pm_unless_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_NEWLINE,
+ PM_LOCATION_INIT_TOKEN_NODE(parser, keyword, end),
+ TOK2LOC(parser, keyword),
+ predicate,
+ NTOK2LOC(parser, then_keyword),
+ statements,
+ NULL,
+ ((pm_location_t) { 0 })
+ );
+}
+
+/**
+ * Allocate and initialize new UnlessNode node in the modifier form.
+ */
+static pm_unless_node_t *
+pm_unless_node_modifier_create(pm_parser_t *parser, pm_node_t *statement, const pm_token_t *unless_keyword, pm_node_t *predicate) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, statement, true);
+
+ return pm_unless_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_NODE_FLAG_NEWLINE,
+ PM_LOCATION_INIT_NODES(statement, predicate),
+ TOK2LOC(parser, unless_keyword),
+ predicate,
+ ((pm_location_t) { 0 }),
+ statements,
+ NULL,
+ ((pm_location_t) { 0 })
+ );
+}
+
+static PRISM_INLINE void
+pm_unless_node_end_keyword_loc_set(const pm_parser_t *parser, pm_unless_node_t *node, const pm_token_t *end_keyword) {
+ node->end_keyword_loc = TOK2LOC(parser, end_keyword);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, end_keyword);
+}
+
+/**
+ * Loop modifiers could potentially modify an expression that contains block
+ * exits. In this case we need to loop through them and remove them from the
+ * list of block exits so that they do not later get marked as invalid.
+ */
+static void
+pm_loop_modifier_block_exits(pm_parser_t *parser, pm_statements_node_t *statements) {
+ assert(parser->current_block_exits != NULL);
+
+ // All of the block exits that we want to remove should be within the
+ // statements, and since we are modifying the statements, we shouldn't have
+ // to check the end location.
+ uint32_t start = statements->base.location.start;
+
+ for (size_t index = parser->current_block_exits->size; index > 0; index--) {
+ pm_node_t *block_exit = parser->current_block_exits->nodes[index - 1];
+ if (block_exit->location.start < start) break;
+
+ // Implicitly remove from the list by lowering the size.
+ parser->current_block_exits->size--;
+ }
+}
+
+/**
+ * Allocate a new UntilNode node.
+ */
+static pm_until_node_t *
+pm_until_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_token_t *do_keyword, const pm_token_t *closing, pm_node_t *predicate, pm_statements_node_t *statements, pm_node_flags_t flags) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ return pm_until_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_TOKENS(parser, keyword, closing),
+ TOK2LOC(parser, keyword),
+ NTOK2LOC(parser, do_keyword),
+ TOK2LOC(parser, closing),
+ predicate,
+ statements
+ );
+}
+
+/**
+ * Allocate a new UntilNode node.
+ */
+static pm_until_node_t *
+pm_until_node_modifier_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t *predicate, pm_statements_node_t *statements, pm_node_flags_t flags) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ pm_loop_modifier_block_exits(parser, statements);
+
+ return pm_until_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_NODES(statements, predicate),
+ TOK2LOC(parser, keyword),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ predicate,
+ statements
+ );
+}
+
+/**
+ * Allocate and initialize a new WhenNode node.
+ */
+static pm_when_node_t *
+pm_when_node_create(pm_parser_t *parser, const pm_token_t *keyword) {
+ return pm_when_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_TOKEN(parser, keyword),
+ TOK2LOC(parser, keyword),
+ ((pm_node_list_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ NULL
+ );
+}
+
+/**
+ * Append a new condition to a when node.
+ */
+static void
+pm_when_node_conditions_append(pm_arena_t *arena, pm_when_node_t *node, pm_node_t *condition) {
+ PM_NODE_LENGTH_SET_NODE(node, condition);
+ pm_node_list_append(arena, &node->conditions, condition);
+}
+
+/**
+ * Set the location of the then keyword of a when node.
+ */
+static PRISM_INLINE void
+pm_when_node_then_keyword_loc_set(const pm_parser_t *parser, pm_when_node_t *node, const pm_token_t *then_keyword) {
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, then_keyword);
+ node->then_keyword_loc = TOK2LOC(parser, then_keyword);
+}
+
+/**
+ * Set the statements list of a when node.
+ */
+static void
+pm_when_node_statements_set(pm_when_node_t *node, pm_statements_node_t *statements) {
+ if (PM_NODE_END(statements) > PM_NODE_END(node)) {
+ PM_NODE_LENGTH_SET_NODE(node, statements);
+ }
+
+ node->statements = statements;
+}
+
+/**
+ * Allocate a new WhileNode node.
+ */
+static pm_while_node_t *
+pm_while_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_token_t *do_keyword, const pm_token_t *closing, pm_node_t *predicate, pm_statements_node_t *statements, pm_node_flags_t flags) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+
+ return pm_while_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_TOKENS(parser, keyword, closing),
+ TOK2LOC(parser, keyword),
+ NTOK2LOC(parser, do_keyword),
+ TOK2LOC(parser, closing),
+ predicate,
+ statements
+ );
+}
+
+/**
+ * Allocate a new WhileNode node.
+ */
+static pm_while_node_t *
+pm_while_node_modifier_create(pm_parser_t *parser, const pm_token_t *keyword, pm_node_t *predicate, pm_statements_node_t *statements, pm_node_flags_t flags) {
+ pm_conditional_predicate(parser, predicate, PM_CONDITIONAL_PREDICATE_TYPE_CONDITIONAL);
+ pm_loop_modifier_block_exits(parser, statements);
+
+ return pm_while_node_new(
+ parser->arena,
+ ++parser->node_id,
+ flags,
+ PM_LOCATION_INIT_NODES(statements, predicate),
+ TOK2LOC(parser, keyword),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ predicate,
+ statements
+ );
+}
+
+/**
+ * Allocate and initialize a new synthesized while loop.
+ */
+static pm_while_node_t *
+pm_while_node_synthesized_create(pm_parser_t *parser, pm_node_t *predicate, pm_statements_node_t *statements) {
+ return pm_while_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ PM_LOCATION_INIT_UNSET,
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ ((pm_location_t) { 0 }),
+ predicate,
+ statements
+ );
+}
+
+/**
+ * Allocate and initialize a new XStringNode node with the given unescaped
+ * string.
+ */
+static pm_x_string_node_t *
+pm_xstring_node_create_unescaped(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing, const pm_string_t *unescaped) {
+ return pm_x_string_node_new(
+ parser->arena,
+ ++parser->node_id,
+ PM_STRING_FLAGS_FROZEN,
+ PM_LOCATION_INIT_TOKENS(parser, opening, closing),
+ TOK2LOC(parser, opening),
+ TOK2LOC(parser, content),
+ TOK2LOC(parser, closing),
+ *unescaped
+ );
+}
+
+/**
+ * Allocate and initialize a new XStringNode node.
+ */
+static PRISM_INLINE pm_x_string_node_t *
+pm_xstring_node_create(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing) {
+ return pm_xstring_node_create_unescaped(parser, opening, content, closing, &PM_STRING_EMPTY);
+}
+
+/**
+ * Allocate a new YieldNode node.
+ */
+static pm_yield_node_t *
+pm_yield_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_location_t *lparen_loc, pm_arguments_node_t *arguments, const pm_location_t *rparen_loc) {
+ uint32_t start = PM_TOKEN_START(parser, keyword);
+ uint32_t end;
+
+ if (rparen_loc->length > 0) {
+ end = PM_LOCATION_END(rparen_loc);
+ } else if (arguments != NULL) {
+ end = PM_NODE_END(arguments);
+ } else if (lparen_loc->length > 0) {
+ end = PM_LOCATION_END(lparen_loc);
+ } else {
+ end = PM_TOKEN_END(parser, keyword);
+ }
+
+ return pm_yield_node_new(
+ parser->arena,
+ ++parser->node_id,
+ 0,
+ ((pm_location_t) { .start = start, .length = U32(end - start) }),
+ TOK2LOC(parser, keyword),
+ *lparen_loc,
+ arguments,
+ *rparen_loc
+ );
+}
+
+/**
+ * Check if any of the currently visible scopes contain a local variable
+ * described by the given constant id.
+ */
+static int
+pm_parser_local_depth_constant_id(pm_parser_t *parser, pm_constant_id_t constant_id) {
+ pm_scope_t *scope = parser->current_scope;
+ int depth = 0;
+
+ while (scope != NULL) {
+ if (pm_locals_find(&scope->locals, constant_id) != UINT32_MAX) return depth;
+ if (scope->closed) break;
+
+ scope = scope->previous;
+ depth++;
+ }
+
+ return -1;
+}
+
+/**
+ * Check if any of the currently visible scopes contain a local variable
+ * described by the given token. This function implicitly inserts a constant
+ * into the constant pool.
+ */
+static PRISM_INLINE int
+pm_parser_local_depth(pm_parser_t *parser, pm_token_t *token) {
+ return pm_parser_local_depth_constant_id(parser, pm_parser_constant_id_token(parser, token));
+}
+
+/**
+ * Add a constant id to the local table of the current scope.
+ */
+static PRISM_INLINE void
+pm_parser_local_add(pm_parser_t *parser, pm_constant_id_t constant_id, const uint8_t *start, const uint8_t *end, uint32_t reads) {
+ pm_locals_write(&parser->current_scope->locals, constant_id, U32(start - parser->start), U32(end - start), reads);
+}
+
+/**
+ * Add a local variable from a location to the current scope.
+ */
+static pm_constant_id_t
+pm_parser_local_add_raw(pm_parser_t *parser, const uint8_t *start, const uint8_t *end, uint32_t reads) {
+ pm_constant_id_t constant_id = pm_parser_constant_id_raw(parser, start, end);
+ if (constant_id != 0) pm_parser_local_add(parser, constant_id, start, end, reads);
+ return constant_id;
+}
+
+/**
+ * Add a local variable from a location to the current scope.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_local_add_location(pm_parser_t *parser, pm_location_t *location, uint32_t reads) {
+ return pm_parser_local_add_raw(parser, parser->start + location->start, parser->start + location->start + location->length, reads);
+}
+
+/**
+ * Add a local variable from a token to the current scope.
+ */
+static PRISM_INLINE pm_constant_id_t
+pm_parser_local_add_token(pm_parser_t *parser, pm_token_t *token, uint32_t reads) {
+ return pm_parser_local_add_raw(parser, token->start, token->end, reads);
+}
+
+/**
+ * Add a local variable from an owned string to the current scope.
+ */
+static pm_constant_id_t
+pm_parser_local_add_owned(pm_parser_t *parser, uint8_t *start, size_t length) {
+ pm_constant_id_t constant_id = pm_parser_constant_id_owned(parser, start, length);
+ if (constant_id != 0) pm_parser_local_add(parser, constant_id, parser->start, parser->start, 1);
+ return constant_id;
+}
+
+/**
+ * Add a local variable from a constant string to the current scope.
+ */
+static pm_constant_id_t
+pm_parser_local_add_constant(pm_parser_t *parser, const char *start, size_t length) {
+ pm_constant_id_t constant_id = pm_parser_constant_id_constant(parser, start, length);
+ if (constant_id != 0) pm_parser_local_add(parser, constant_id, parser->start, parser->start, 1);
+ return constant_id;
+}
+
+/**
+ * Add a parameter name to the current scope and check whether the name of the
+ * parameter is unique or not.
+ *
+ * Returns `true` if this is a duplicate parameter name, otherwise returns
+ * false.
+ */
+static bool
+pm_parser_parameter_name_check(pm_parser_t *parser, const pm_token_t *name) {
+ // We want to check whether the parameter name is a numbered parameter or
+ // not.
+ pm_refute_numbered_parameter(parser, PM_TOKEN_START(parser, name), PM_TOKEN_LENGTH(name));
+
+ // Otherwise we'll fetch the constant id for the parameter name and check
+ // whether it's already in the current scope.
+ pm_constant_id_t constant_id = pm_parser_constant_id_token(parser, name);
+
+ if (pm_locals_find(&parser->current_scope->locals, constant_id) != UINT32_MAX) {
+ // Add an error if the parameter doesn't start with _ and has been seen before
+ if ((name->start < name->end) && (*name->start != '_')) {
+ pm_parser_err_token(parser, name, PM_ERR_PARAMETER_NAME_DUPLICATED);
+ }
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Pop the current scope off the scope stack.
+ */
+static void
+pm_parser_scope_pop(pm_parser_t *parser) {
+ pm_scope_t *scope = parser->current_scope;
+ parser->current_scope = scope->previous;
+ pm_locals_free(&scope->locals);
+ xfree_sized(scope, sizeof(pm_scope_t));
+}
+
+/******************************************************************************/
+/* Stack helpers */
+/******************************************************************************/
+
+/**
+ * Pushes a value onto the stack.
+ */
+static PRISM_INLINE void
+pm_state_stack_push(pm_state_stack_t *stack, bool value) {
+ *stack = (*stack << 1) | (value & 1);
+}
+
+/**
+ * Pops a value off the stack.
+ */
+static PRISM_INLINE void
+pm_state_stack_pop(pm_state_stack_t *stack) {
+ *stack >>= 1;
+}
+
+/**
+ * Returns the value at the top of the stack.
+ */
+static PRISM_INLINE bool
+pm_state_stack_p(const pm_state_stack_t *stack) {
+ return *stack & 1;
+}
+
+static PRISM_INLINE void
+pm_accepts_block_stack_push(pm_parser_t *parser, bool value) {
+ // Use the negation of the value to prevent stack overflow.
+ pm_state_stack_push(&parser->accepts_block_stack, !value);
+}
+
+static PRISM_INLINE void
+pm_accepts_block_stack_pop(pm_parser_t *parser) {
+ pm_state_stack_pop(&parser->accepts_block_stack);
+}
+
+static PRISM_INLINE bool
+pm_accepts_block_stack_p(pm_parser_t *parser) {
+ return !pm_state_stack_p(&parser->accepts_block_stack);
+}
+
+static PRISM_INLINE void
+pm_do_loop_stack_push(pm_parser_t *parser, bool value) {
+ pm_state_stack_push(&parser->do_loop_stack, value);
+}
+
+static PRISM_INLINE void
+pm_do_loop_stack_pop(pm_parser_t *parser) {
+ pm_state_stack_pop(&parser->do_loop_stack);
+}
+
+static PRISM_INLINE bool
+pm_do_loop_stack_p(pm_parser_t *parser) {
+ return pm_state_stack_p(&parser->do_loop_stack);
+}
+
+/******************************************************************************/
+/* Lexer check helpers */
+/******************************************************************************/
+
+/**
+ * Get the next character in the source starting from +cursor+. If that position
+ * is beyond the end of the source then return '\0'.
+ */
+static PRISM_INLINE uint8_t
+peek_at(const pm_parser_t *parser, const uint8_t *cursor) {
+ if (cursor < parser->end) {
+ return *cursor;
+ } else {
+ return '\0';
+ }
+}
+
+/**
+ * Get the next character in the source starting from parser->current.end and
+ * adding the given offset. If that position is beyond the end of the source
+ * then return '\0'.
+ */
+static PRISM_INLINE uint8_t
+peek_offset(pm_parser_t *parser, ptrdiff_t offset) {
+ return peek_at(parser, parser->current.end + offset);
+}
+
+/**
+ * Get the next character in the source starting from parser->current.end. If
+ * that position is beyond the end of the source then return '\0'.
+ */
+static PRISM_INLINE uint8_t
+peek(const pm_parser_t *parser) {
+ return peek_at(parser, parser->current.end);
+}
+
+/**
+ * If the character to be read matches the given value, then returns true and
+ * advances the current pointer.
+ */
+static PRISM_INLINE bool
+match(pm_parser_t *parser, uint8_t value) {
+ if (peek(parser) == value) {
+ parser->current.end++;
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Return the length of the line ending string starting at +cursor+, or 0 if it
+ * is not a line ending. This function is intended to be CRLF/LF agnostic.
+ */
+static PRISM_INLINE size_t
+match_eol_at(pm_parser_t *parser, const uint8_t *cursor) {
+ if (peek_at(parser, cursor) == '\n') {
+ return 1;
+ }
+ if (peek_at(parser, cursor) == '\r' && peek_at(parser, cursor + 1) == '\n') {
+ return 2;
+ }
+ return 0;
+}
+
+/**
+ * Return the length of the line ending string starting at
+ * `parser->current.end + offset`, or 0 if it is not a line ending. This
+ * function is intended to be CRLF/LF agnostic.
+ */
+static PRISM_INLINE size_t
+match_eol_offset(pm_parser_t *parser, ptrdiff_t offset) {
+ return match_eol_at(parser, parser->current.end + offset);
+}
+
+/**
+ * Return the length of the line ending string starting at parser->current.end,
+ * or 0 if it is not a line ending. This function is intended to be CRLF/LF
+ * agnostic.
+ */
+static PRISM_INLINE size_t
+match_eol(pm_parser_t *parser) {
+ return match_eol_at(parser, parser->current.end);
+}
+
+/**
+ * Skip to the next newline character or NUL byte.
+ */
+static PRISM_INLINE const uint8_t *
+next_newline(const uint8_t *cursor, ptrdiff_t length) {
+ assert(length >= 0);
+
+ // Note that it's okay for us to use memchr here to look for \n because none
+ // of the encodings that we support have \n as a component of a multi-byte
+ // character.
+ return memchr(cursor, '\n', (size_t) length);
+}
+
+/**
+ * This is equivalent to the predicate of warn_balanced in CRuby.
+ */
+static PRISM_INLINE bool
+ambiguous_operator_p(const pm_parser_t *parser, bool space_seen) {
+ return !lex_state_p(parser, PM_LEX_STATE_CLASS | PM_LEX_STATE_DOT | PM_LEX_STATE_FNAME | PM_LEX_STATE_ENDFN) && space_seen && !pm_char_is_whitespace(peek(parser));
+}
+
+/**
+ * Here we're going to check if this is a "magic" comment, and perform whatever
+ * actions are necessary for it here.
+ */
+static bool
+parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *start, const uint8_t *end) {
+ const pm_encoding_t *encoding = pm_encoding_find(start, end);
+
+ if (encoding != NULL) {
+ if (parser->encoding != encoding) {
+ parser->encoding = encoding;
+ if (parser->encoding_changed_callback != NULL) parser->encoding_changed_callback(parser);
+ }
+
+ parser->encoding_changed = (encoding != PM_ENCODING_UTF_8_ENTRY);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Look for a specific pattern of "coding" and potentially set the encoding on
+ * the parser.
+ */
+static void
+parser_lex_magic_comment_encoding(pm_parser_t *parser) {
+ const uint8_t *cursor = parser->current.start + 1;
+ const uint8_t *end = parser->current.end;
+
+ bool separator = false;
+ while (true) {
+ if (end - cursor <= 6) return;
+ switch (cursor[6]) {
+ case 'C': case 'c': cursor += 6; continue;
+ case 'O': case 'o': cursor += 5; continue;
+ case 'D': case 'd': cursor += 4; continue;
+ case 'I': case 'i': cursor += 3; continue;
+ case 'N': case 'n': cursor += 2; continue;
+ case 'G': case 'g': cursor += 1; continue;
+ case '=': case ':':
+ separator = true;
+ cursor += 6;
+ break;
+ default:
+ cursor += 6;
+ if (pm_char_is_whitespace(*cursor)) break;
+ continue;
+ }
+ if (pm_strncasecmp(cursor - 6, (const uint8_t *) "coding", 6) == 0) break;
+ separator = false;
+ }
+
+ while (true) {
+ do {
+ if (++cursor >= end) return;
+ } while (pm_char_is_whitespace(*cursor));
+
+ if (separator) break;
+ if (*cursor != '=' && *cursor != ':') return;
+
+ separator = true;
+ cursor++;
+ }
+
+ const uint8_t *value_start = cursor;
+ while ((*cursor == '-' || *cursor == '_' || parser->encoding->alnum_char(cursor, 1)) && ++cursor < end);
+
+ if (!parser_lex_magic_comment_encoding_value(parser, value_start, cursor)) {
+ // If we were unable to parse the encoding value, then we've got an
+ // issue because we didn't understand the encoding that the user was
+ // trying to use. In this case we'll keep using the default encoding but
+ // add an error to the parser to indicate an unsuccessful parse.
+ pm_parser_err(parser, U32(value_start - parser->start), U32(cursor - value_start), PM_ERR_INVALID_ENCODING_MAGIC_COMMENT);
+ }
+}
+
+typedef enum {
+ PM_MAGIC_COMMENT_BOOLEAN_VALUE_TRUE,
+ PM_MAGIC_COMMENT_BOOLEAN_VALUE_FALSE,
+ PM_MAGIC_COMMENT_BOOLEAN_VALUE_INVALID
+} pm_magic_comment_boolean_value_t;
+
+/**
+ * Check if this is a magic comment that includes the frozen_string_literal
+ * pragma. If it does, set that field on the parser.
+ */
+static pm_magic_comment_boolean_value_t
+parser_lex_magic_comment_boolean_value(const uint8_t *value_start, uint32_t value_length) {
+ if (value_length == 4 && pm_strncasecmp(value_start, (const uint8_t *) "true", 4) == 0) {
+ return PM_MAGIC_COMMENT_BOOLEAN_VALUE_TRUE;
+ } else if (value_length == 5 && pm_strncasecmp(value_start, (const uint8_t *) "false", 5) == 0) {
+ return PM_MAGIC_COMMENT_BOOLEAN_VALUE_FALSE;
+ } else {
+ return PM_MAGIC_COMMENT_BOOLEAN_VALUE_INVALID;
+ }
+}
+
+static PRISM_INLINE bool
+pm_char_is_magic_comment_key_delimiter(const uint8_t b) {
+ return b == '\'' || b == '"' || b == ':' || b == ';';
+}
+
+/**
+ * Find an emacs magic comment marker (-*-) within the given bounds. If one is
+ * found, it returns a pointer to the start of the marker. Otherwise it returns
+ * NULL.
+ */
+static PRISM_INLINE const uint8_t *
+parser_lex_magic_comment_emacs_marker(pm_parser_t *parser, const uint8_t *cursor, const uint8_t *end) {
+ // Scan for '*' as the middle character, since it is rarer than '-' in
+ // typical comments and avoids repeated memchr calls for '-' that hit
+ // dashes in words like "foo-bar".
+ while ((cursor + 3 <= end) && (cursor = pm_memchr(cursor + 1, '*', (size_t) (end - cursor - 1), parser->encoding_changed, parser->encoding)) != NULL) {
+ if (cursor[-1] == '-' && cursor + 1 < end && cursor[1] == '-') {
+ return cursor - 1;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * Parse the current token on the parser to see if it's a magic comment and
+ * potentially perform some action based on that. A regular expression that this
+ * function is effectively matching is:
+ *
+ * %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*"
+ *
+ * It returns true if it consumes the entire comment. Otherwise it returns
+ * false.
+ */
+static PRISM_INLINE bool
+parser_lex_magic_comment(pm_parser_t *parser, bool semantic_token_seen) {
+ bool result = true;
+
+ const uint8_t *start = parser->current.start + 1;
+ const uint8_t *end = parser->current.end;
+ if (end - start <= 7) return false;
+
+ const uint8_t *cursor;
+ bool indicator = false;
+
+ if ((cursor = parser_lex_magic_comment_emacs_marker(parser, start, end)) != NULL) {
+ start = cursor + 3;
+
+ if ((cursor = parser_lex_magic_comment_emacs_marker(parser, start, end)) != NULL) {
+ end = cursor;
+ indicator = true;
+ } else {
+ // If we have a start marker but not an end marker, then we cannot
+ // have a magic comment.
+ return false;
+ }
+ } else {
+ // Non-emacs magic comments must contain a colon for `key: value`.
+ // Reject early if there is no colon to avoid scanning the entire
+ // comment character-by-character.
+ if (pm_memchr(start, ':', (size_t) (end - start), parser->encoding_changed, parser->encoding) == NULL) {
+ return false;
+ }
+
+ // Advance start past leading whitespace so the main loop begins
+ // directly at the key, avoiding a redundant whitespace scan.
+ start += pm_strspn_whitespace(start, end - start);
+ }
+
+ cursor = start;
+ while (cursor < end) {
+ if (indicator) {
+ while (cursor < end && (pm_char_is_magic_comment_key_delimiter(*cursor) || pm_char_is_whitespace(*cursor))) cursor++;
+ }
+
+ const uint8_t *key_start = cursor;
+ while (cursor < end && (!pm_char_is_magic_comment_key_delimiter(*cursor) && !pm_char_is_whitespace(*cursor))) cursor++;
+
+ const uint8_t *key_end = cursor;
+ while (cursor < end && pm_char_is_whitespace(*cursor)) cursor++;
+ if (cursor == end) break;
+
+ if (*cursor == ':') {
+ cursor++;
+ } else {
+ if (!indicator) return false;
+ continue;
+ }
+
+ while (cursor < end && pm_char_is_whitespace(*cursor)) cursor++;
+ if (cursor == end) break;
+
+ const uint8_t *value_start;
+ const uint8_t *value_end;
+
+ if (*cursor == '"') {
+ value_start = ++cursor;
+ for (; cursor < end && *cursor != '"'; cursor++) {
+ if (*cursor == '\\' && (cursor + 1 < end)) cursor++;
+ }
+ value_end = cursor;
+ if (cursor < end && *cursor == '"') cursor++;
+ } else {
+ value_start = cursor;
+ while (cursor < end && *cursor != '"' && *cursor != ';' && !pm_char_is_whitespace(*cursor)) cursor++;
+ value_end = cursor;
+ }
+
+ if (indicator) {
+ while (cursor < end && (*cursor == ';' || pm_char_is_whitespace(*cursor))) cursor++;
+ } else {
+ while (cursor < end && pm_char_is_whitespace(*cursor)) cursor++;
+ if (cursor != end) return false;
+ }
+
+ // Here, we need to do some processing on the key to swap out dashes for
+ // underscores. We only need to do this if there _is_ a dash in the key.
+ pm_string_t key;
+ const size_t key_length = (size_t) (key_end - key_start);
+ const uint8_t *dash = pm_memchr(key_start, '-', key_length, parser->encoding_changed, parser->encoding);
+
+ if (dash == NULL) {
+ pm_string_shared_init(&key, key_start, key_end);
+ } else {
+ uint8_t *buffer = xmalloc(key_length);
+ if (buffer == NULL) break;
+
+ memcpy(buffer, key_start, key_length);
+ buffer[dash - key_start] = '_';
+
+ while ((dash = pm_memchr(dash + 1, '-', (size_t) (key_end - dash - 1), parser->encoding_changed, parser->encoding)) != NULL) {
+ buffer[dash - key_start] = '_';
+ }
+
+ pm_string_owned_init(&key, buffer, key_length);
+ }
+
+ // Finally, we can start checking the key against the list of known
+ // magic comment keys, and potentially change state based on that.
+ const uint8_t *key_source = pm_string_source(&key);
+ uint32_t value_length = (uint32_t) (value_end - value_start);
+
+ // We only want to attempt to compare against encoding comments if it's
+ // the first line in the file (or the second in the case of a shebang).
+ if (parser->current.start == parser->encoding_comment_start && !parser->encoding_locked) {
+ if (
+ (key_length == 8 && pm_strncasecmp(key_source, (const uint8_t *) "encoding", 8) == 0) ||
+ (key_length == 6 && pm_strncasecmp(key_source, (const uint8_t *) "coding", 6) == 0)
+ ) {
+ result = parser_lex_magic_comment_encoding_value(parser, value_start, value_end);
+ }
+ }
+
+ if (key_length == 11) {
+ if (pm_strncasecmp(key_source, (const uint8_t *) "warn_indent", 11) == 0) {
+ switch (parser_lex_magic_comment_boolean_value(value_start, value_length)) {
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_INVALID:
+ PM_PARSER_WARN_TOKEN_FORMAT(
+ parser,
+ &parser->current,
+ PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
+ (int) key_length,
+ (const char *) key_source,
+ (int) value_length,
+ (const char *) value_start
+ );
+ break;
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_FALSE:
+ parser->warn_mismatched_indentation = false;
+ break;
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_TRUE:
+ parser->warn_mismatched_indentation = true;
+ break;
+ }
+ }
+ } else if (key_length == 21) {
+ if (pm_strncasecmp(key_source, (const uint8_t *) "frozen_string_literal", 21) == 0) {
+ // We only want to handle frozen string literal comments if it's
+ // before any semantic tokens have been seen.
+ if (semantic_token_seen) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_IGNORED_FROZEN_STRING_LITERAL);
+ } else {
+ switch (parser_lex_magic_comment_boolean_value(value_start, value_length)) {
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_INVALID:
+ PM_PARSER_WARN_TOKEN_FORMAT(
+ parser,
+ &parser->current,
+ PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
+ (int) key_length,
+ (const char *) key_source,
+ (int) value_length,
+ (const char *) value_start
+ );
+ break;
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_FALSE:
+ parser->frozen_string_literal = PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED;
+ break;
+ case PM_MAGIC_COMMENT_BOOLEAN_VALUE_TRUE:
+ parser->frozen_string_literal = PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED;
+ break;
+ }
+ }
+ }
+ } else if (key_length == 24) {
+ if (pm_strncasecmp(key_source, (const uint8_t *) "shareable_constant_value", 24) == 0) {
+ const uint8_t *cursor = parser->current.start;
+ while ((cursor > parser->start) && ((cursor[-1] == ' ') || (cursor[-1] == '\t'))) cursor--;
+
+ if (!((cursor == parser->start) || (cursor[-1] == '\n'))) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE);
+ } else if (value_length == 4 && pm_strncasecmp(value_start, (const uint8_t *) "none", 4) == 0) {
+ pm_parser_scope_shareable_constant_set(parser, PM_SCOPE_SHAREABLE_CONSTANT_NONE);
+ } else if (value_length == 7 && pm_strncasecmp(value_start, (const uint8_t *) "literal", 7) == 0) {
+ pm_parser_scope_shareable_constant_set(parser, PM_SCOPE_SHAREABLE_CONSTANT_LITERAL);
+ } else if (value_length == 23 && pm_strncasecmp(value_start, (const uint8_t *) "experimental_everything", 23) == 0) {
+ pm_parser_scope_shareable_constant_set(parser, PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_EVERYTHING);
+ } else if (value_length == 17 && pm_strncasecmp(value_start, (const uint8_t *) "experimental_copy", 17) == 0) {
+ pm_parser_scope_shareable_constant_set(parser, PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_COPY);
+ } else {
+ PM_PARSER_WARN_TOKEN_FORMAT(
+ parser,
+ &parser->current,
+ PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
+ (int) key_length,
+ (const char *) key_source,
+ (int) value_length,
+ (const char *) value_start
+ );
+ }
+ }
+ }
+
+ // When we're done, we want to free the string in case we had to
+ // allocate memory for it.
+ pm_string_cleanup(&key);
+
+ // Allocate a new magic comment node to append to the parser's list.
+ pm_magic_comment_t *magic_comment = (pm_magic_comment_t *) pm_arena_alloc(&parser->metadata_arena, sizeof(pm_magic_comment_t), PRISM_ALIGNOF(pm_magic_comment_t));
+ magic_comment->node.next = NULL;
+ magic_comment->key = (pm_location_t) { .start = U32(key_start - parser->start), .length = U32(key_length) };
+ magic_comment->value = (pm_location_t) { .start = U32(value_start - parser->start), .length = value_length };
+ pm_list_append(&parser->magic_comment_list, (pm_list_node_t *) magic_comment);
+ }
+
+ return result;
+}
+
+/******************************************************************************/
+/* Context manipulations */
+/******************************************************************************/
+
+static const uint32_t context_terminators[] = {
+ [PM_CONTEXT_NONE] = 0,
+ [PM_CONTEXT_BEGIN] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BEGIN_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BEGIN_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BEGIN_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BLOCK_BRACES] = (1U << PM_TOKEN_BRACE_RIGHT),
+ [PM_CONTEXT_BLOCK_KEYWORDS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_BLOCK_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BLOCK_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_BLOCK_PARAMETERS] = (1U << PM_TOKEN_PIPE),
+ [PM_CONTEXT_BLOCK_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_CASE_WHEN] = (1U << PM_TOKEN_KEYWORD_WHEN) | (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_ELSE),
+ [PM_CONTEXT_CASE_IN] = (1U << PM_TOKEN_KEYWORD_IN) | (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_ELSE),
+ [PM_CONTEXT_CLASS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_CLASS_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_CLASS_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_CLASS_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_DEF] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_DEF_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_DEF_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_DEF_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_DEF_PARAMS] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_DEFINED] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_DEFAULT_PARAMS] = (1U << PM_TOKEN_COMMA) | (1U << PM_TOKEN_PARENTHESIS_RIGHT),
+ [PM_CONTEXT_ELSE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_ELSIF] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_ELSIF) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_EMBEXPR] = (1U << PM_TOKEN_EMBEXPR_END),
+ [PM_CONTEXT_FOR] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_FOR_INDEX] = (1U << PM_TOKEN_KEYWORD_IN),
+ [PM_CONTEXT_IF] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_ELSIF) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_LAMBDA_BRACES] = (1U << PM_TOKEN_BRACE_RIGHT),
+ [PM_CONTEXT_LAMBDA_DO_END] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_LAMBDA_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_LAMBDA_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_LAMBDA_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_LOOP_PREDICATE] = (1U << PM_TOKEN_KEYWORD_DO) | (1U << PM_TOKEN_KEYWORD_THEN),
+ [PM_CONTEXT_MAIN] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_MODULE] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_MODULE_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_MODULE_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_MODULE_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_MULTI_TARGET] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_PARENS] = (1U << PM_TOKEN_PARENTHESIS_RIGHT),
+ [PM_CONTEXT_POSTEXE] = (1U << PM_TOKEN_BRACE_RIGHT),
+ [PM_CONTEXT_PREDICATE] = (1U << PM_TOKEN_KEYWORD_THEN) | (1U << PM_TOKEN_NEWLINE) | (1U << PM_TOKEN_SEMICOLON),
+ [PM_CONTEXT_PREEXE] = (1U << PM_TOKEN_BRACE_RIGHT),
+ [PM_CONTEXT_RESCUE_MODIFIER] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_SCLASS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
+ [PM_CONTEXT_SCLASS_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_SCLASS_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_SCLASS_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_TERNARY] = (1U << PM_TOKEN_EOF),
+ [PM_CONTEXT_UNLESS] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_UNTIL] = (1U << PM_TOKEN_KEYWORD_END),
+ [PM_CONTEXT_WHILE] = (1U << PM_TOKEN_KEYWORD_END),
+};
+
+static PRISM_INLINE bool
+context_terminator(pm_context_t context, pm_token_t *token) {
+ return token->type < 32 && (context_terminators[context] & (1U << token->type));
+}
+
+/**
+ * Returns the context that the given token is found to be terminating, or
+ * returns PM_CONTEXT_NONE.
+ */
+static pm_context_t
+context_recoverable(const pm_parser_t *parser, pm_token_t *token) {
+ pm_context_node_t *context_node = parser->current_context;
+
+ while (context_node != NULL) {
+ if (context_terminator(context_node->context, token)) return context_node->context;
+ context_node = context_node->prev;
+ }
+
+ return PM_CONTEXT_NONE;
+}
+
+static bool
+context_push(pm_parser_t *parser, pm_context_t context) {
+ pm_context_node_t *context_node = (pm_context_node_t *) xmalloc(sizeof(pm_context_node_t));
+ if (context_node == NULL) return false;
+
+ *context_node = (pm_context_node_t) { .context = context, .prev = NULL };
+
+ if (parser->current_context == NULL) {
+ parser->current_context = context_node;
+ } else {
+ context_node->prev = parser->current_context;
+ parser->current_context = context_node;
+ }
+
+ return true;
+}
+
+static void
+context_pop(pm_parser_t *parser) {
+ pm_context_node_t *prev = parser->current_context->prev;
+ xfree_sized(parser->current_context, sizeof(pm_context_node_t));
+ parser->current_context = prev;
+}
+
+static bool
+context_p(const pm_parser_t *parser, pm_context_t context) {
+ pm_context_node_t *context_node = parser->current_context;
+
+ while (context_node != NULL) {
+ if (context_node->context == context) return true;
+ context_node = context_node->prev;
+ }
+
+ return false;
+}
+
+static bool
+context_def_p(const pm_parser_t *parser) {
+ pm_context_node_t *context_node = parser->current_context;
+
+ while (context_node != NULL) {
+ switch (context_node->context) {
+ case PM_CONTEXT_DEF:
+ case PM_CONTEXT_DEF_PARAMS:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_DEF_ELSE:
+ return true;
+ case PM_CONTEXT_CLASS:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_MODULE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_SCLASS:
+ case PM_CONTEXT_SCLASS_ENSURE:
+ case PM_CONTEXT_SCLASS_RESCUE:
+ case PM_CONTEXT_SCLASS_ELSE:
+ return false;
+ default:
+ context_node = context_node->prev;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Returns a human readable string for the given context, used in error
+ * messages.
+ */
+static const char *
+context_human(pm_context_t context) {
+ switch (context) {
+ case PM_CONTEXT_NONE:
+ assert(false && "unreachable");
+ return "";
+ case PM_CONTEXT_BEGIN: return "begin statement";
+ case PM_CONTEXT_BLOCK_BRACES: return "'{'..'}' block";
+ case PM_CONTEXT_BLOCK_KEYWORDS: return "'do'..'end' block";
+ case PM_CONTEXT_BLOCK_PARAMETERS: return "'|'..'|' block parameter";
+ case PM_CONTEXT_CASE_WHEN: return "'when' clause";
+ case PM_CONTEXT_CASE_IN: return "'in' clause";
+ case PM_CONTEXT_CLASS: return "class definition";
+ case PM_CONTEXT_DEF: return "method definition";
+ case PM_CONTEXT_DEF_PARAMS: return "method parameters";
+ case PM_CONTEXT_DEFAULT_PARAMS: return "parameter default value";
+ case PM_CONTEXT_DEFINED: return "'defined?' expression";
+ case PM_CONTEXT_ELSE:
+ case PM_CONTEXT_BEGIN_ELSE:
+ case PM_CONTEXT_BLOCK_ELSE:
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_DEF_ELSE:
+ case PM_CONTEXT_LAMBDA_ELSE:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_SCLASS_ELSE: return "'else' clause";
+ case PM_CONTEXT_ELSIF: return "'elsif' clause";
+ case PM_CONTEXT_EMBEXPR: return "embedded expression";
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_BLOCK_ENSURE:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_LAMBDA_ENSURE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_SCLASS_ENSURE: return "'ensure' clause";
+ case PM_CONTEXT_FOR: return "for loop";
+ case PM_CONTEXT_FOR_INDEX: return "for loop index";
+ case PM_CONTEXT_IF: return "if statement";
+ case PM_CONTEXT_LAMBDA_BRACES: return "'{'..'}' lambda block";
+ case PM_CONTEXT_LAMBDA_DO_END: return "'do'..'end' lambda block";
+ case PM_CONTEXT_LOOP_PREDICATE: return "loop predicate";
+ case PM_CONTEXT_MAIN: return "top level context";
+ case PM_CONTEXT_MODULE: return "module definition";
+ case PM_CONTEXT_MULTI_TARGET: return "multiple targets";
+ case PM_CONTEXT_PARENS: return "parentheses";
+ case PM_CONTEXT_POSTEXE: return "'END' block";
+ case PM_CONTEXT_PREDICATE: return "predicate";
+ case PM_CONTEXT_PREEXE: return "'BEGIN' block";
+ case PM_CONTEXT_BEGIN_RESCUE:
+ case PM_CONTEXT_BLOCK_RESCUE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_LAMBDA_RESCUE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_RESCUE_MODIFIER:
+ case PM_CONTEXT_SCLASS_RESCUE: return "'rescue' clause";
+ case PM_CONTEXT_SCLASS: return "singleton class definition";
+ case PM_CONTEXT_TERNARY: return "ternary expression";
+ case PM_CONTEXT_UNLESS: return "unless statement";
+ case PM_CONTEXT_UNTIL: return "until statement";
+ case PM_CONTEXT_WHILE: return "while statement";
+ }
+
+ assert(false && "unreachable");
+ return "";
+}
+
+/******************************************************************************/
+/* Specific token lexers */
+/******************************************************************************/
+
+static PRISM_INLINE void
+pm_strspn_number_validate(pm_parser_t *parser, const uint8_t *string, size_t length, const uint8_t *invalid) {
+ if (invalid != NULL) {
+ pm_diagnostic_id_t diag_id = (invalid == (string + length - 1)) ? PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING : PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER;
+ pm_parser_err(parser, U32(invalid - parser->start), 1, diag_id);
+ }
+}
+
+static size_t
+pm_strspn_binary_number_validate(pm_parser_t *parser, const uint8_t *string) {
+ const uint8_t *invalid = NULL;
+ size_t length = pm_strspn_binary_number(string, parser->end - string, &invalid);
+ pm_strspn_number_validate(parser, string, length, invalid);
+ return length;
+}
+
+static size_t
+pm_strspn_octal_number_validate(pm_parser_t *parser, const uint8_t *string) {
+ const uint8_t *invalid = NULL;
+ size_t length = pm_strspn_octal_number(string, parser->end - string, &invalid);
+ pm_strspn_number_validate(parser, string, length, invalid);
+ return length;
+}
+
+static size_t
+pm_strspn_decimal_number_validate(pm_parser_t *parser, const uint8_t *string) {
+ const uint8_t *invalid = NULL;
+ size_t length = pm_strspn_decimal_number(string, parser->end - string, &invalid);
+ pm_strspn_number_validate(parser, string, length, invalid);
+ return length;
+}
+
+static size_t
+pm_strspn_hexadecimal_number_validate(pm_parser_t *parser, const uint8_t *string) {
+ const uint8_t *invalid = NULL;
+ size_t length = pm_strspn_hexadecimal_number(string, parser->end - string, &invalid);
+ pm_strspn_number_validate(parser, string, length, invalid);
+ return length;
+}
+
+static pm_token_type_t
+lex_optional_float_suffix(pm_parser_t *parser, bool* seen_e) {
+ pm_token_type_t type = PM_TOKEN_INTEGER;
+
+ // Here we're going to attempt to parse the optional decimal portion of a
+ // float. If it's not there, then it's okay and we'll just continue on.
+ if (peek(parser) == '.') {
+ if (pm_char_is_decimal_digit(peek_offset(parser, 1))) {
+ parser->current.end += 2;
+ parser->current.end += pm_strspn_decimal_number_validate(parser, parser->current.end);
+ type = PM_TOKEN_FLOAT;
+ } else {
+ // If we had a . and then something else, then it's not a float
+ // suffix on a number it's a method call or something else.
+ return type;
+ }
+ }
+
+ // Here we're going to attempt to parse the optional exponent portion of a
+ // float. If it's not there, it's okay and we'll just continue on.
+ if ((peek(parser) == 'e') || (peek(parser) == 'E')) {
+ if ((peek_offset(parser, 1) == '+') || (peek_offset(parser, 1) == '-')) {
+ parser->current.end += 2;
+
+ if (pm_char_is_decimal_digit(peek(parser))) {
+ parser->current.end++;
+ parser->current.end += pm_strspn_decimal_number_validate(parser, parser->current.end);
+ } else {
+ pm_parser_err_current(parser, PM_ERR_INVALID_FLOAT_EXPONENT);
+ }
+ } else if (pm_char_is_decimal_digit(peek_offset(parser, 1))) {
+ parser->current.end++;
+ parser->current.end += pm_strspn_decimal_number_validate(parser, parser->current.end);
+ } else {
+ return type;
+ }
+
+ *seen_e = true;
+ type = PM_TOKEN_FLOAT;
+ }
+
+ return type;
+}
+
+static pm_token_type_t
+lex_numeric_prefix(pm_parser_t *parser, bool* seen_e) {
+ pm_token_type_t type = PM_TOKEN_INTEGER;
+ *seen_e = false;
+
+ if (peek_offset(parser, -1) == '0') {
+ switch (*parser->current.end) {
+ // 0d1111 is a decimal number
+ case 'd':
+ case 'D':
+ parser->current.end++;
+ if (pm_char_is_decimal_digit(peek(parser))) {
+ parser->current.end += pm_strspn_decimal_number_validate(parser, parser->current.end);
+ } else {
+ match(parser, '_');
+ pm_parser_err_current(parser, PM_ERR_INVALID_NUMBER_DECIMAL);
+ }
+
+ break;
+
+ // 0b1111 is a binary number
+ case 'b':
+ case 'B':
+ parser->current.end++;
+ if (pm_char_is_binary_digit(peek(parser))) {
+ parser->current.end += pm_strspn_binary_number_validate(parser, parser->current.end);
+ } else {
+ match(parser, '_');
+ pm_parser_err_current(parser, PM_ERR_INVALID_NUMBER_BINARY);
+ }
+
+ parser->integer.base = PM_INTEGER_BASE_FLAGS_BINARY;
+ break;
+
+ // 0o1111 is an octal number
+ case 'o':
+ case 'O':
+ parser->current.end++;
+ if (pm_char_is_octal_digit(peek(parser))) {
+ parser->current.end += pm_strspn_octal_number_validate(parser, parser->current.end);
+ } else {
+ match(parser, '_');
+ pm_parser_err_current(parser, PM_ERR_INVALID_NUMBER_OCTAL);
+ }
+
+ parser->integer.base = PM_INTEGER_BASE_FLAGS_OCTAL;
+ break;
+
+ // 01111 is an octal number
+ case '_':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ parser->current.end += pm_strspn_octal_number_validate(parser, parser->current.end);
+ parser->integer.base = PM_INTEGER_BASE_FLAGS_OCTAL;
+ break;
+
+ // 0x1111 is a hexadecimal number
+ case 'x':
+ case 'X':
+ parser->current.end++;
+ if (pm_char_is_hexadecimal_digit(peek(parser))) {
+ parser->current.end += pm_strspn_hexadecimal_number_validate(parser, parser->current.end);
+ } else {
+ match(parser, '_');
+ pm_parser_err_current(parser, PM_ERR_INVALID_NUMBER_HEXADECIMAL);
+ }
+
+ parser->integer.base = PM_INTEGER_BASE_FLAGS_HEXADECIMAL;
+ break;
+
+ // 0.xxx is a float
+ case '.': {
+ type = lex_optional_float_suffix(parser, seen_e);
+ break;
+ }
+
+ // 0exxx is a float
+ case 'e':
+ case 'E': {
+ type = lex_optional_float_suffix(parser, seen_e);
+ break;
+ }
+ }
+ } else {
+ // If it didn't start with a 0, then we'll lex as far as we can into a
+ // decimal number. We compute the integer value inline to avoid
+ // re-scanning the digits later in pm_integer_parse.
+ {
+ const uint8_t *cursor = parser->current.end;
+ const uint8_t *end = parser->end;
+ uint64_t value = (uint64_t) (cursor[-1] - '0');
+
+ bool has_underscore = false;
+ bool prev_underscore = false;
+ const uint8_t *invalid = NULL;
+
+ while (cursor < end) {
+ uint8_t c = *cursor;
+ if (c >= '0' && c <= '9') {
+ if (value <= UINT32_MAX) value = value * 10 + (uint64_t) (c - '0');
+ prev_underscore = false;
+ cursor++;
+ } else if (c == '_') {
+ has_underscore = true;
+ if (prev_underscore && invalid == NULL) invalid = cursor;
+ prev_underscore = true;
+ cursor++;
+ } else {
+ break;
+ }
+ }
+
+ if (has_underscore) {
+ if (prev_underscore && invalid == NULL) invalid = cursor - 1;
+ pm_strspn_number_validate(parser, parser->current.end, (size_t) (cursor - parser->current.end), invalid);
+ }
+
+ if (value <= UINT32_MAX) {
+ parser->integer.value = (uint32_t) value;
+ parser->integer.lexed = true;
+ }
+
+ parser->current.end = cursor;
+ }
+
+ // Afterward, we'll lex as far as we can into an optional float suffix.
+ // Guard the function call: the vast majority of decimal numbers are
+ // plain integers, so avoid the call when the next byte cannot start a
+ // float suffix.
+ {
+ uint8_t next = peek(parser);
+ if (next == '.' || next == 'e' || next == 'E') {
+ type = lex_optional_float_suffix(parser, seen_e);
+
+ // If it turned out to be a float, the cached integer value is
+ // invalid.
+ if (type != PM_TOKEN_INTEGER) {
+ parser->integer.lexed = false;
+ }
+ }
+ }
+ }
+
+ // At this point we have a completed number, but we want to provide the user
+ // with a good experience if they put an additional .xxx fractional
+ // component on the end, so we'll check for that here.
+ if (peek_offset(parser, 0) == '.' && pm_char_is_decimal_digit(peek_offset(parser, 1))) {
+ const uint8_t *fraction_start = parser->current.end;
+ const uint8_t *fraction_end = parser->current.end + 2;
+ fraction_end += pm_strspn_decimal_digit(fraction_end, parser->end - fraction_end);
+ pm_parser_err(parser, U32(fraction_start - parser->start), U32(fraction_end - fraction_start), PM_ERR_INVALID_NUMBER_FRACTION);
+ }
+
+ return type;
+}
+
+static pm_token_type_t
+lex_numeric(pm_parser_t *parser) {
+ pm_token_type_t type = PM_TOKEN_INTEGER;
+ parser->integer.base = PM_INTEGER_BASE_FLAGS_DECIMAL;
+ parser->integer.lexed = false;
+
+ if (parser->current.end < parser->end) {
+ bool seen_e = false;
+ type = lex_numeric_prefix(parser, &seen_e);
+
+ const uint8_t *end = parser->current.end;
+ pm_token_type_t suffix_type = type;
+
+ if (type == PM_TOKEN_INTEGER) {
+ if (match(parser, 'r')) {
+ suffix_type = PM_TOKEN_INTEGER_RATIONAL;
+
+ if (match(parser, 'i')) {
+ suffix_type = PM_TOKEN_INTEGER_RATIONAL_IMAGINARY;
+ }
+ } else if (match(parser, 'i')) {
+ suffix_type = PM_TOKEN_INTEGER_IMAGINARY;
+ }
+ } else {
+ if (!seen_e && match(parser, 'r')) {
+ suffix_type = PM_TOKEN_FLOAT_RATIONAL;
+
+ if (match(parser, 'i')) {
+ suffix_type = PM_TOKEN_FLOAT_RATIONAL_IMAGINARY;
+ }
+ } else if (match(parser, 'i')) {
+ suffix_type = PM_TOKEN_FLOAT_IMAGINARY;
+ }
+ }
+
+ const uint8_t b = peek(parser);
+ if (b != '\0' && (b >= 0x80 || ((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z')) || b == '_')) {
+ parser->current.end = end;
+ } else {
+ type = suffix_type;
+ }
+ }
+
+ return type;
+}
+
+static pm_token_type_t
+lex_global_variable(pm_parser_t *parser) {
+ if (parser->current.end >= parser->end) {
+ pm_parser_err_token(parser, &parser->current, PM_ERR_GLOBAL_VARIABLE_BARE);
+ return PM_TOKEN_GLOBAL_VARIABLE;
+ }
+
+ // True if multiple characters are allowed after the declaration of the
+ // global variable. Not true when it starts with "$-".
+ bool allow_multiple = true;
+
+ switch (*parser->current.end) {
+ case '~': // $~: match-data
+ case '*': // $*: argv
+ case '$': // $$: pid
+ case '?': // $?: last status
+ case '!': // $!: error string
+ case '@': // $@: error position
+ case '/': // $/: input record separator
+ case '\\': // $\: output record separator
+ case ';': // $;: field separator
+ case ',': // $,: output field separator
+ case '.': // $.: last read line number
+ case '=': // $=: ignorecase
+ case ':': // $:: load path
+ case '<': // $<: reading filename
+ case '>': // $>: default output handle
+ case '\"': // $": already loaded files
+ parser->current.end++;
+ return PM_TOKEN_GLOBAL_VARIABLE;
+
+ case '&': // $&: last match
+ case '`': // $`: string before last match
+ case '\'': // $': string after last match
+ case '+': // $+: string matches last paren.
+ parser->current.end++;
+ return lex_state_p(parser, PM_LEX_STATE_FNAME) ? PM_TOKEN_GLOBAL_VARIABLE : PM_TOKEN_BACK_REFERENCE;
+
+ case '0': {
+ parser->current.end++;
+ size_t width;
+
+ if ((width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) > 0) {
+ do {
+ parser->current.end += width;
+ } while ((width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) > 0);
+
+ // $0 isn't allowed to be followed by anything.
+ pm_diagnostic_id_t diag_id = parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &parser->current, diag_id);
+ }
+
+ return PM_TOKEN_GLOBAL_VARIABLE;
+ }
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ parser->current.end += pm_strspn_decimal_digit(parser->current.end, parser->end - parser->current.end);
+ return lex_state_p(parser, PM_LEX_STATE_FNAME) ? PM_TOKEN_GLOBAL_VARIABLE : PM_TOKEN_NUMBERED_REFERENCE;
+
+ case '-':
+ parser->current.end++;
+ allow_multiple = false;
+ PRISM_FALLTHROUGH
+ default: {
+ size_t width;
+
+ if ((width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) > 0) {
+ do {
+ parser->current.end += width;
+ } while (allow_multiple && (width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) > 0);
+ } else if (pm_char_is_whitespace(peek(parser))) {
+ // If we get here, then we have a $ followed by whitespace,
+ // which is not allowed.
+ pm_parser_err_token(parser, &parser->current, PM_ERR_GLOBAL_VARIABLE_BARE);
+ } else {
+ // If we get here, then we have a $ followed by something that
+ // isn't recognized as a global variable.
+ pm_diagnostic_id_t diag_id = parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ PM_PARSER_ERR_FORMAT(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), diag_id, (int) (PM_TOKEN_LENGTH(&parser->current) + U32(width)), (const char *) parser->current.start);
+ }
+
+ return PM_TOKEN_GLOBAL_VARIABLE;
+ }
+ }
+}
+
+/**
+ * This function checks if the current token matches a keyword. If it does, it
+ * returns the token type. Otherwise, it returns PM_TOKEN_EOF. The arguments are as follows:
+ *
+ * * `parser` - the parser object
+ * * `current_start` - pointer to the start of the current token
+ * * `value` - the literal string that we're checking for
+ * * `vlen` - the length of the token
+ * * `state` - the state that we should transition to if the token matches
+ * * `type` - the expected token type
+ * * `modifier_type` - the expected modifier token type
+ */
+static PRISM_INLINE pm_token_type_t
+lex_keyword(pm_parser_t *parser, const uint8_t *current_start, const char *value, size_t vlen, pm_lex_state_t state, pm_token_type_t type, pm_token_type_t modifier_type) {
+ if (memcmp(current_start, value, vlen) == 0) {
+ pm_lex_state_t last_state = parser->lex_state;
+
+ if (parser->lex_state & PM_LEX_STATE_FNAME) {
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ } else {
+ lex_state_set(parser, state);
+ if (state == PM_LEX_STATE_BEG) {
+ parser->command_start = true;
+ }
+
+ if ((modifier_type != PM_TOKEN_EOF) && !(last_state & (PM_LEX_STATE_BEG | PM_LEX_STATE_LABELED | PM_LEX_STATE_CLASS))) {
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ return modifier_type;
+ }
+ }
+
+ return type;
+ }
+
+ return PM_TOKEN_EOF;
+}
+
+static pm_token_type_t
+lex_identifier(pm_parser_t *parser, bool previous_command_start) {
+ // Lex as far as we can into the current identifier.
+ size_t width;
+ const uint8_t *end = parser->end;
+ const uint8_t *current_start = parser->current.start;
+ const uint8_t *current_end = parser->current.end;
+ bool encoding_changed = parser->encoding_changed;
+
+ if (encoding_changed) {
+ while ((width = char_is_identifier(parser, current_end, end - current_end)) > 0) {
+ current_end += width;
+ }
+ } else {
+ // Fast path: scan ASCII identifier bytes using wide operations.
+ current_end += scan_identifier_ascii(current_end, end);
+
+ // Byte-at-a-time fallback for the tail and any UTF-8 sequences.
+ while ((width = char_is_identifier_utf8(current_end, end - current_end)) > 0) {
+ current_end += width;
+ }
+ }
+ parser->current.end = current_end;
+
+ // Now cache the length of the identifier so that we can quickly compare it
+ // against known keywords.
+ width = (size_t) (current_end - current_start);
+
+ if (current_end < end) {
+ if (((current_end + 1 >= end) || (current_end[1] != '=')) && (match(parser, '!') || match(parser, '?'))) {
+ // First we'll attempt to extend the identifier by a ! or ?. Then we'll
+ // check if we're returning the defined? keyword or just an identifier.
+ width++;
+
+ if (
+ ((lex_state_p(parser, PM_LEX_STATE_LABEL | PM_LEX_STATE_ENDFN) && !previous_command_start) || lex_state_arg_p(parser)) &&
+ (peek(parser) == ':') && (peek_offset(parser, 1) != ':')
+ ) {
+ // If we're in a position where we can accept a : at the end of an
+ // identifier, then we'll optionally accept it.
+ lex_state_set(parser, PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED);
+ (void) match(parser, ':');
+ return PM_TOKEN_LABEL;
+ }
+
+ if (parser->lex_state != PM_LEX_STATE_DOT) {
+ if (width == 8 && (lex_keyword(parser, current_start, "defined?", width, PM_LEX_STATE_ARG, PM_TOKEN_KEYWORD_DEFINED, PM_TOKEN_EOF) != PM_TOKEN_EOF)) {
+ return PM_TOKEN_KEYWORD_DEFINED;
+ }
+ }
+
+ return PM_TOKEN_METHOD_NAME;
+ }
+
+ if (lex_state_p(parser, PM_LEX_STATE_FNAME) && peek_offset(parser, 1) != '~' && peek_offset(parser, 1) != '>' && (peek_offset(parser, 1) != '=' || peek_offset(parser, 2) == '>') && match(parser, '=')) {
+ // If we're in a position where we can accept a = at the end of an
+ // identifier, then we'll optionally accept it.
+ return PM_TOKEN_IDENTIFIER;
+ }
+
+ if (
+ ((lex_state_p(parser, PM_LEX_STATE_LABEL | PM_LEX_STATE_ENDFN) && !previous_command_start) || lex_state_arg_p(parser)) &&
+ peek(parser) == ':' && peek_offset(parser, 1) != ':'
+ ) {
+ // If we're in a position where we can accept a : at the end of an
+ // identifier, then we'll optionally accept it.
+ lex_state_set(parser, PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED);
+ (void) match(parser, ':');
+ return PM_TOKEN_LABEL;
+ }
+ }
+
+ if (parser->lex_state != PM_LEX_STATE_DOT) {
+ pm_token_type_t type;
+ switch (width) {
+ case 2:
+ if (lex_keyword(parser, current_start, "do", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_DO, PM_TOKEN_EOF) != PM_TOKEN_EOF) {
+ if (parser->enclosure_nesting == parser->lambda_enclosure_nesting) {
+ return PM_TOKEN_KEYWORD_DO;
+ }
+ if (pm_do_loop_stack_p(parser)) {
+ return PM_TOKEN_KEYWORD_DO_LOOP;
+ }
+ if (!pm_accepts_block_stack_p(parser)) {
+ return PM_TOKEN_KEYWORD_DO_BLOCK;
+ }
+ return PM_TOKEN_KEYWORD_DO;
+ }
+
+ if ((type = lex_keyword(parser, current_start, "if", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_IF, PM_TOKEN_KEYWORD_IF_MODIFIER)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "in", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_IN, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "or", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_OR, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ case 3:
+ if ((type = lex_keyword(parser, current_start, "and", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_AND, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "def", width, PM_LEX_STATE_FNAME, PM_TOKEN_KEYWORD_DEF, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "end", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_END, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "END", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_END_UPCASE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "for", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_FOR, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "nil", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_NIL, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "not", width, PM_LEX_STATE_ARG, PM_TOKEN_KEYWORD_NOT, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ case 4:
+ if ((type = lex_keyword(parser, current_start, "case", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_CASE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "else", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "next", width, PM_LEX_STATE_MID, PM_TOKEN_KEYWORD_NEXT, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "redo", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_REDO, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "self", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_SELF, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "then", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "true", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_TRUE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "when", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_WHEN, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ case 5:
+ if ((type = lex_keyword(parser, current_start, "alias", width, PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM, PM_TOKEN_KEYWORD_ALIAS, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "begin", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_BEGIN, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "BEGIN", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_BEGIN_UPCASE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "break", width, PM_LEX_STATE_MID, PM_TOKEN_KEYWORD_BREAK, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "class", width, PM_LEX_STATE_CLASS, PM_TOKEN_KEYWORD_CLASS, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "elsif", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_ELSIF, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "false", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_FALSE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "retry", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD_RETRY, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "super", width, PM_LEX_STATE_ARG, PM_TOKEN_KEYWORD_SUPER, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "undef", width, PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM, PM_TOKEN_KEYWORD_UNDEF, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "until", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_UNTIL, PM_TOKEN_KEYWORD_UNTIL_MODIFIER)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "while", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_WHILE, PM_TOKEN_KEYWORD_WHILE_MODIFIER)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "yield", width, PM_LEX_STATE_ARG, PM_TOKEN_KEYWORD_YIELD, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ case 6:
+ if ((type = lex_keyword(parser, current_start, "ensure", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "module", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_MODULE, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "rescue", width, PM_LEX_STATE_MID, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_RESCUE_MODIFIER)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "return", width, PM_LEX_STATE_MID, PM_TOKEN_KEYWORD_RETURN, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "unless", width, PM_LEX_STATE_BEG, PM_TOKEN_KEYWORD_UNLESS, PM_TOKEN_KEYWORD_UNLESS_MODIFIER)) != PM_TOKEN_EOF) return type;
+ break;
+ case 8:
+ if ((type = lex_keyword(parser, current_start, "__LINE__", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD___LINE__, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ if ((type = lex_keyword(parser, current_start, "__FILE__", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD___FILE__, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ case 12:
+ if ((type = lex_keyword(parser, current_start, "__ENCODING__", width, PM_LEX_STATE_END, PM_TOKEN_KEYWORD___ENCODING__, PM_TOKEN_EOF)) != PM_TOKEN_EOF) return type;
+ break;
+ }
+ }
+
+ if (encoding_changed) {
+ return parser->encoding->isupper_char(current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER;
+ }
+ return pm_encoding_utf_8_isupper_char(current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER;
+}
+
+/**
+ * Returns true if the current token that the parser is considering is at the
+ * beginning of a line or the beginning of the source.
+ */
+static bool
+current_token_starts_line(pm_parser_t *parser) {
+ return (parser->current.start == parser->start) || (parser->current.start[-1] == '\n');
+}
+
+/**
+ * When we hit a # while lexing something like a string, we need to potentially
+ * handle interpolation. This function performs that check. It returns a token
+ * type representing what it found. Those cases are:
+ *
+ * * 0 - No interpolation was found at this point. The caller should keep
+ * lexing.
+ * * PM_TOKEN_STRING_CONTENT - No interpolation was found at this point. The
+ * caller should return this token type.
+ * * PM_TOKEN_EMBEXPR_BEGIN - An embedded expression was found. The caller
+ * should return this token type.
+ * * PM_TOKEN_EMBVAR - An embedded variable was found. The caller should return
+ * this token type.
+ */
+static pm_token_type_t
+lex_interpolation(pm_parser_t *parser, const uint8_t *pound) {
+ // If there is no content following this #, then we're at the end of
+ // the string and we can safely return string content.
+ if (pound + 1 >= parser->end) {
+ parser->current.end = pound + 1;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ // Now we'll check against the character that follows the #. If it
+ // constitutes valid interplation, we'll handle that, otherwise we'll return
+ // 0.
+ switch (pound[1]) {
+ case '@': {
+ // In this case we may have hit an embedded instance or class variable.
+ if (pound + 2 >= parser->end) {
+ parser->current.end = pound + 1;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ // If we're looking at a @ and there's another @, then we'll skip past the
+ // second @.
+ const uint8_t *variable = pound + 2;
+ if (*variable == '@' && pound + 3 < parser->end) variable++;
+
+ if (char_is_identifier_start(parser, variable, parser->end - variable)) {
+ // At this point we're sure that we've either hit an embedded instance
+ // or class variable. In this case we'll first need to check if we've
+ // already consumed content.
+ if (pound > parser->current.start) {
+ parser->current.end = pound;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ // Otherwise we need to return the embedded variable token
+ // and then switch to the embedded variable lex mode.
+ lex_mode_push(parser, (pm_lex_mode_t) { .mode = PM_LEX_EMBVAR });
+ parser->current.end = pound + 1;
+ return PM_TOKEN_EMBVAR;
+ }
+
+ // If we didn't get a valid interpolation, then this is just regular
+ // string content. This is like if we get "#@-". In this case the caller
+ // should keep lexing.
+ parser->current.end = pound + 1;
+ return 0;
+ }
+ case '$':
+ // In this case we may have hit an embedded global variable. If there's
+ // not enough room, then we'll just return string content.
+ if (pound + 2 >= parser->end) {
+ parser->current.end = pound + 1;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ // This is the character that we're going to check to see if it is the
+ // start of an identifier that would indicate that this is a global
+ // variable.
+ const uint8_t *check = pound + 2;
+
+ if (pound[2] == '-') {
+ if (pound + 3 >= parser->end) {
+ parser->current.end = pound + 2;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ check++;
+ }
+
+ // If the character that we're going to check is the start of an
+ // identifier, or we don't have a - and the character is a decimal number
+ // or a global name punctuation character, then we've hit an embedded
+ // global variable.
+ if (
+ char_is_identifier_start(parser, check, parser->end - check) ||
+ (pound[2] != '-' && (pm_char_is_decimal_digit(pound[2]) || char_is_global_name_punctuation(pound[2])))
+ ) {
+ // In this case we've hit an embedded global variable. First check to
+ // see if we've already consumed content. If we have, then we need to
+ // return that content as string content first.
+ if (pound > parser->current.start) {
+ parser->current.end = pound;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ // Otherwise, we need to return the embedded variable token and switch
+ // to the embedded variable lex mode.
+ lex_mode_push(parser, (pm_lex_mode_t) { .mode = PM_LEX_EMBVAR });
+ parser->current.end = pound + 1;
+ return PM_TOKEN_EMBVAR;
+ }
+
+ // In this case we've hit a #$ that does not indicate a global variable.
+ // In this case we'll continue lexing past it.
+ parser->current.end = pound + 1;
+ return 0;
+ case '{':
+ // In this case it's the start of an embedded expression. If we have
+ // already consumed content, then we need to return that content as string
+ // content first.
+ if (pound > parser->current.start) {
+ parser->current.end = pound;
+ return PM_TOKEN_STRING_CONTENT;
+ }
+
+ parser->enclosure_nesting++;
+
+ // Otherwise we'll skip past the #{ and begin lexing the embedded
+ // expression.
+ lex_mode_push(parser, (pm_lex_mode_t) { .mode = PM_LEX_EMBEXPR });
+ parser->current.end = pound + 2;
+ parser->command_start = true;
+ pm_do_loop_stack_push(parser, false);
+ return PM_TOKEN_EMBEXPR_BEGIN;
+ default:
+ // In this case we've hit a # that doesn't constitute interpolation. We'll
+ // mark that by returning the not provided token type. This tells the
+ // consumer to keep lexing forward.
+ parser->current.end = pound + 1;
+ return 0;
+ }
+}
+
+static const uint8_t PM_ESCAPE_FLAG_NONE = 0x0;
+static const uint8_t PM_ESCAPE_FLAG_CONTROL = 0x1;
+static const uint8_t PM_ESCAPE_FLAG_META = 0x2;
+static const uint8_t PM_ESCAPE_FLAG_SINGLE = 0x4;
+static const uint8_t PM_ESCAPE_FLAG_REGEXP = 0x8;
+
+/**
+ * This is a lookup table for whether or not an ASCII character is printable.
+ */
+static const bool ascii_printable_chars[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 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, 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, 0
+};
+
+static PRISM_INLINE bool
+char_is_ascii_printable(const uint8_t b) {
+ return (b < 0x80) && ascii_printable_chars[b];
+}
+
+/**
+ * Return the value that a hexadecimal digit character represents. For example,
+ * transform 'a' into 10, 'b' into 11, etc.
+ */
+static PRISM_INLINE uint8_t
+escape_hexadecimal_digit(const uint8_t value) {
+ return (uint8_t) ((value <= '9') ? (value - '0') : (value & 0x7) + 9);
+}
+
+/**
+ * Scan the 4 digits of a Unicode escape into the value. Returns the number of
+ * digits scanned. This function assumes that the characters have already been
+ * validated.
+ */
+static PRISM_INLINE uint32_t
+escape_unicode(pm_parser_t *parser, const uint8_t *string, size_t length, const pm_location_t *error_location, const uint8_t flags) {
+ uint32_t value = 0;
+ for (size_t index = 0; index < length; index++) {
+ if (index != 0) value <<= 4;
+ value |= escape_hexadecimal_digit(string[index]);
+ }
+
+ // Here we're going to verify that the value is actually a valid Unicode
+ // codepoint and not a surrogate pair.
+ if (value >= 0xD800 && value <= 0xDFFF) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // In regexp context, defer the error to regexp encoding
+ // validation where we can produce a regexp-specific message.
+ } else if (error_location != NULL) {
+ pm_parser_err(parser, error_location->start, error_location->length, PM_ERR_ESCAPE_INVALID_UNICODE);
+ } else {
+ pm_parser_err(parser, U32(string - parser->start), U32(length), PM_ERR_ESCAPE_INVALID_UNICODE);
+ }
+ return 0xFFFD;
+ }
+
+ return value;
+}
+
+/**
+ * Escape a single character value based on the given flags.
+ */
+static PRISM_INLINE uint8_t
+escape_byte(uint8_t value, const uint8_t flags) {
+ if (flags & PM_ESCAPE_FLAG_CONTROL) value &= 0x9f;
+ if (flags & PM_ESCAPE_FLAG_META) value |= 0x80;
+ return value;
+}
+
+/**
+ * Write a unicode codepoint to the given buffer.
+ */
+static PRISM_INLINE void
+escape_write_unicode(pm_parser_t *parser, pm_buffer_t *buffer, const uint8_t flags, const uint8_t *start, const uint8_t *end, uint32_t value) {
+ // \u escape sequences in string-like structures implicitly change the
+ // encoding to UTF-8 if they are >= 0x80 or if they are used in a character
+ // literal.
+ if (value >= 0x80 || flags & PM_ESCAPE_FLAG_SINGLE) {
+ if (parser->explicit_encoding != NULL && parser->explicit_encoding != PM_ENCODING_UTF_8_ENTRY) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // In regexp context, suppress this error — the regexp encoding
+ // validation will produce a more specific error message.
+ } else {
+ PM_PARSER_ERR_FORMAT(parser, U32(start - parser->start), U32(end - start), PM_ERR_MIXED_ENCODING, parser->explicit_encoding->name);
+ }
+ }
+
+ parser->explicit_encoding = PM_ENCODING_UTF_8_ENTRY;
+ }
+
+ if (!pm_buffer_append_unicode_codepoint(buffer, value)) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // In regexp context, defer the error to the regexp encoding
+ // validation which produces a regexp-specific message.
+ } else {
+ pm_parser_err(parser, U32(start - parser->start), U32(end - start), PM_ERR_ESCAPE_INVALID_UNICODE);
+ }
+
+ pm_buffer_append_byte(buffer, 0xEF);
+ pm_buffer_append_byte(buffer, 0xBF);
+ pm_buffer_append_byte(buffer, 0xBD);
+ }
+}
+
+/**
+ * When you're writing a byte to the unescape buffer, if the byte is non-ASCII
+ * (i.e., the top bit is set) then it locks in the encoding.
+ */
+static PRISM_INLINE void
+escape_write_byte_encoded(pm_parser_t *parser, pm_buffer_t *buffer, const uint8_t flags, uint8_t byte) {
+ if (byte >= 0x80) {
+ if (parser->explicit_encoding != NULL && parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY && parser->encoding != PM_ENCODING_UTF_8_ENTRY) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // In regexp context, suppress this error — the regexp encoding
+ // validation will produce a more specific error message.
+ } else {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_MIXED_ENCODING, parser->encoding->name);
+ }
+ }
+
+ parser->explicit_encoding = parser->encoding;
+ }
+
+ pm_buffer_append_byte(buffer, byte);
+}
+
+/**
+ * The regular expression engine doesn't support the same escape sequences as
+ * Ruby does. So first we have to read the escape sequence, and then we have to
+ * format it like the regular expression engine expects it. For example, in Ruby
+ * if we have:
+ *
+ * /\M-\C-?/
+ *
+ * then the first byte is actually 255, so we have to rewrite this as:
+ *
+ * /\xFF/
+ *
+ * Note that in this case there is a literal \ byte in the regular expression
+ * source so that the regular expression engine will perform its own unescaping.
+ */
+static PRISM_INLINE void
+escape_write_byte(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expression_buffer, uint8_t flags, uint8_t byte) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ pm_buffer_append_format(regular_expression_buffer, "\\x%02X", byte);
+ }
+
+ escape_write_byte_encoded(parser, buffer, flags, byte);
+}
+
+/**
+ * Write each byte of the given escaped character into the buffer.
+ */
+static PRISM_INLINE void
+escape_write_escape_encoded(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expression_buffer, uint8_t flags) {
+ size_t width;
+ if (parser->encoding_changed) {
+ width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ } else {
+ width = pm_encoding_utf_8_char_width(parser->current.end, parser->end - parser->current.end);
+ }
+
+ if (width == 1) {
+ if (*parser->current.end == '\n') pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(*parser->current.end++, flags));
+ } else if (width > 1) {
+ // Valid multibyte character. Just ignore escape.
+ pm_buffer_t *b = (flags & PM_ESCAPE_FLAG_REGEXP) ? regular_expression_buffer : buffer;
+ pm_buffer_append_bytes(b, parser->current.end, width);
+ parser->current.end += width;
+ } else {
+ // Assume the next character wasn't meant to be part of this escape
+ // sequence since it is invalid. Add an error and move on.
+ parser->current.end++;
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
+ }
+}
+
+/**
+ * Warn about using a space or a tab character in an escape, as opposed to using
+ * \\s or \\t. Note that we can quite copy the source because the warning
+ * message replaces \\c with \\C.
+ */
+static void
+escape_read_warn(pm_parser_t *parser, uint8_t flags, uint8_t flag, const char *type) {
+#define FLAG(value) ((value & PM_ESCAPE_FLAG_CONTROL) ? "\\C-" : (value & PM_ESCAPE_FLAG_META) ? "\\M-" : "")
+
+ PM_PARSER_WARN_TOKEN_FORMAT(
+ parser,
+ &parser->current,
+ PM_WARN_INVALID_CHARACTER,
+ FLAG(flags),
+ FLAG(flag),
+ type
+ );
+
+#undef FLAG
+}
+
+/**
+ * Read the value of an escape into the buffer.
+ */
+static void
+escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expression_buffer, uint8_t flags) {
+ uint8_t peeked = peek(parser);
+ switch (peeked) {
+ case '\\': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\\', flags));
+ return;
+ }
+ case '\'': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\'', flags));
+ return;
+ }
+ case 'a': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\a', flags));
+ return;
+ }
+ case 'b': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\b', flags));
+ return;
+ }
+ case 'e': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\033', flags));
+ return;
+ }
+ case 'f': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\f', flags));
+ return;
+ }
+ case 'n': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\n', flags));
+ return;
+ }
+ case 'r': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\r', flags));
+ return;
+ }
+ case 's': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(' ', flags));
+ return;
+ }
+ case 't': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\t', flags));
+ return;
+ }
+ case 'v': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte('\v', flags));
+ return;
+ }
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': {
+ uint8_t value = (uint8_t) (*parser->current.end - '0');
+ parser->current.end++;
+
+ if (pm_char_is_octal_digit(peek(parser))) {
+ value = ((uint8_t) (value << 3)) | ((uint8_t) (*parser->current.end - '0'));
+ parser->current.end++;
+
+ if (pm_char_is_octal_digit(peek(parser))) {
+ value = ((uint8_t) (value << 3)) | ((uint8_t) (*parser->current.end - '0'));
+ parser->current.end++;
+ }
+ }
+
+ value = escape_byte(value, flags);
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, value);
+ return;
+ }
+ case 'x': {
+ const uint8_t *start = parser->current.end - 1;
+
+ parser->current.end++;
+ uint8_t byte = peek(parser);
+
+ if (pm_char_is_hexadecimal_digit(byte)) {
+ uint8_t value = escape_hexadecimal_digit(byte);
+ parser->current.end++;
+
+ byte = peek(parser);
+ if (pm_char_is_hexadecimal_digit(byte)) {
+ value = (uint8_t) ((value << 4) | escape_hexadecimal_digit(byte));
+ parser->current.end++;
+ }
+
+ value = escape_byte(value, flags);
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ if (flags & (PM_ESCAPE_FLAG_CONTROL | PM_ESCAPE_FLAG_META)) {
+ pm_buffer_append_format(regular_expression_buffer, "\\x%02X", value);
+ } else {
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end - start));
+ }
+ }
+
+ escape_write_byte_encoded(parser, buffer, flags, value);
+ } else {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_HEXADECIMAL);
+ }
+
+ return;
+ }
+ case 'u': {
+ const uint8_t *start = parser->current.end - 1;
+ parser->current.end++;
+
+ if (parser->current.end == parser->end) {
+ const uint8_t *start = parser->current.end - 2;
+ PM_PARSER_ERR_FORMAT(parser, U32(start - parser->start), U32(parser->current.end - start), PM_ERR_ESCAPE_INVALID_UNICODE_SHORT, 2, start);
+ } else if (peek(parser) == '{') {
+ const uint8_t *unicode_codepoints_start = parser->current.end - 2;
+ parser->current.end++;
+
+ size_t whitespace;
+ while (true) {
+ if ((whitespace = pm_strspn_inline_whitespace(parser->current.end, parser->end - parser->current.end)) > 0) {
+ parser->current.end += whitespace;
+ } else if (peek(parser) == '\\' && peek_offset(parser, 1) == 'n') {
+ // This is super hacky, but it gets us nicer error
+ // messages because we can still pass it off to the
+ // regular expression engine even if we hit an
+ // unterminated regular expression.
+ parser->current.end += 2;
+ } else {
+ break;
+ }
+ }
+
+ const uint8_t *extra_codepoints_start = NULL;
+ int codepoints_count = 0;
+
+ while ((parser->current.end < parser->end) && (*parser->current.end != '}')) {
+ const uint8_t *unicode_start = parser->current.end;
+ size_t hexadecimal_length = pm_strspn_hexadecimal_digit(parser->current.end, parser->end - parser->current.end);
+
+ if (hexadecimal_length > 6) {
+ // \u{nnnn} character literal allows only 1-6 hexadecimal digits
+ pm_parser_err(parser, U32(unicode_start - parser->start), U32(hexadecimal_length), PM_ERR_ESCAPE_INVALID_UNICODE_LONG);
+ } else if (hexadecimal_length == 0) {
+ // there are not hexadecimal characters
+
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // If this is a regular expression, we are going to
+ // let the regular expression engine handle this
+ // error instead of us because we don't know at this
+ // point if we're inside a comment in /x mode.
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end - start));
+ } else {
+ pm_parser_err(parser, PM_TOKEN_END(parser, &parser->current), 0, PM_ERR_ESCAPE_INVALID_UNICODE);
+ pm_parser_err(parser, PM_TOKEN_END(parser, &parser->current), 0, PM_ERR_ESCAPE_INVALID_UNICODE_TERM);
+ }
+
+ return;
+ }
+
+ parser->current.end += hexadecimal_length;
+ codepoints_count++;
+ if (flags & PM_ESCAPE_FLAG_SINGLE && codepoints_count == 2) {
+ extra_codepoints_start = unicode_start;
+ }
+
+ uint32_t value = escape_unicode(parser, unicode_start, hexadecimal_length, NULL, flags);
+ escape_write_unicode(parser, buffer, flags, unicode_start, parser->current.end, value);
+
+ parser->current.end += pm_strspn_inline_whitespace(parser->current.end, parser->end - parser->current.end);
+ }
+
+ // ?\u{nnnn} character literal should contain only one codepoint
+ // and cannot be like ?\u{nnnn mmmm}.
+ if (flags & PM_ESCAPE_FLAG_SINGLE && codepoints_count > 1) {
+ pm_parser_err(parser, U32(extra_codepoints_start - parser->start), U32(parser->current.end - 1 - extra_codepoints_start), PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL);
+ }
+
+ if (parser->current.end == parser->end) {
+ PM_PARSER_ERR_FORMAT(parser, U32(start - parser->start), U32(parser->current.end - start), PM_ERR_ESCAPE_INVALID_UNICODE_LIST, (int) (parser->current.end - start), start);
+ } else if (peek(parser) == '}') {
+ parser->current.end++;
+ } else {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // If this is a regular expression, we are going to let
+ // the regular expression engine handle this error
+ // instead of us because we don't know at this point if
+ // we're inside a comment in /x mode.
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end - start));
+ } else {
+ pm_parser_err(parser, U32(unicode_codepoints_start - parser->start), U32(parser->current.end - unicode_codepoints_start), PM_ERR_ESCAPE_INVALID_UNICODE_TERM);
+ }
+ }
+
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ pm_buffer_append_bytes(regular_expression_buffer, unicode_codepoints_start, (size_t) (parser->current.end - unicode_codepoints_start));
+ }
+ } else {
+ size_t length = pm_strspn_hexadecimal_digit(parser->current.end, MIN(parser->end - parser->current.end, 4));
+
+ if (length == 0) {
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end - start));
+ } else {
+ const uint8_t *start = parser->current.end - 2;
+ PM_PARSER_ERR_FORMAT(parser, U32(start - parser->start), U32(parser->current.end - start), PM_ERR_ESCAPE_INVALID_UNICODE_SHORT, 2, start);
+ }
+ } else if (length == 4) {
+ uint32_t value = escape_unicode(parser, parser->current.end, 4, NULL, flags);
+
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end + 4 - start));
+ }
+
+ escape_write_unicode(parser, buffer, flags, start, parser->current.end + 4, value);
+ parser->current.end += 4;
+ } else {
+ parser->current.end += length;
+
+ if (flags & PM_ESCAPE_FLAG_REGEXP) {
+ // If this is a regular expression, we are going to let
+ // the regular expression engine handle this error
+ // instead of us.
+ pm_buffer_append_bytes(regular_expression_buffer, start, (size_t) (parser->current.end - start));
+ } else {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_UNICODE);
+ }
+ }
+ }
+
+ return;
+ }
+ case 'c': {
+ parser->current.end++;
+ if (flags & PM_ESCAPE_FLAG_CONTROL) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT);
+ }
+
+ if (parser->current.end == parser->end) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
+ return;
+ }
+
+ uint8_t peeked = peek(parser);
+ switch (peeked) {
+ case '?': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(0x7f, flags));
+ return;
+ }
+ case '\\':
+ parser->current.end++;
+
+ if (match(parser, 'u') || match(parser, 'U')) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current), PM_ERR_INVALID_ESCAPE_CHARACTER);
+ return;
+ }
+
+ escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_CONTROL);
+ return;
+ case ' ':
+ parser->current.end++;
+ escape_read_warn(parser, flags, PM_ESCAPE_FLAG_CONTROL, "\\s");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ case '\t':
+ parser->current.end++;
+ escape_read_warn(parser, flags, 0, "\\t");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ default: {
+ if (!char_is_ascii_printable(peeked)) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
+ return;
+ }
+
+ if (peeked == '\n') pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ }
+ }
+ }
+ case 'C': {
+ parser->current.end++;
+ if (flags & PM_ESCAPE_FLAG_CONTROL) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT);
+ }
+
+ if (peek(parser) != '-') {
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), PM_ERR_ESCAPE_INVALID_CONTROL);
+ return;
+ }
+
+ parser->current.end++;
+ if (parser->current.end == parser->end) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
+ return;
+ }
+
+ uint8_t peeked = peek(parser);
+ switch (peeked) {
+ case '?': {
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(0x7f, flags));
+ return;
+ }
+ case '\\':
+ parser->current.end++;
+
+ if (match(parser, 'u') || match(parser, 'U')) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current), PM_ERR_INVALID_ESCAPE_CHARACTER);
+ return;
+ }
+
+ escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_CONTROL);
+ return;
+ case ' ':
+ parser->current.end++;
+ escape_read_warn(parser, flags, PM_ESCAPE_FLAG_CONTROL, "\\s");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ case '\t':
+ parser->current.end++;
+ escape_read_warn(parser, flags, 0, "\\t");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ default: {
+ if (!char_is_ascii_printable(peeked)) {
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), PM_ERR_ESCAPE_INVALID_CONTROL);
+ return;
+ }
+
+ if (peeked == '\n') pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_CONTROL));
+ return;
+ }
+ }
+ }
+ case 'M': {
+ parser->current.end++;
+ if (flags & PM_ESCAPE_FLAG_META) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_META_REPEAT);
+ }
+
+ if (peek(parser) != '-') {
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), PM_ERR_ESCAPE_INVALID_META);
+ return;
+ }
+
+ parser->current.end++;
+ if (parser->current.end == parser->end) {
+ pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_META);
+ return;
+ }
+
+ uint8_t peeked = peek(parser);
+ switch (peeked) {
+ case '\\':
+ parser->current.end++;
+
+ if (match(parser, 'u') || match(parser, 'U')) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current), PM_ERR_INVALID_ESCAPE_CHARACTER);
+ return;
+ }
+
+ escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_META);
+ return;
+ case ' ':
+ parser->current.end++;
+ escape_read_warn(parser, flags, PM_ESCAPE_FLAG_META, "\\s");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_META));
+ return;
+ case '\t':
+ parser->current.end++;
+ escape_read_warn(parser, flags & ((uint8_t) ~PM_ESCAPE_FLAG_CONTROL), PM_ESCAPE_FLAG_META, "\\t");
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_META));
+ return;
+ default:
+ if (!char_is_ascii_printable(peeked)) {
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), PM_ERR_ESCAPE_INVALID_META);
+ return;
+ }
+
+ if (peeked == '\n') pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ parser->current.end++;
+ escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(peeked, flags | PM_ESCAPE_FLAG_META));
+ return;
+ }
+ }
+ case '\r': {
+ if (peek_offset(parser, 1) == '\n') {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 2);
+ parser->current.end += 2;
+ escape_write_byte_encoded(parser, buffer, flags, escape_byte('\n', flags));
+ return;
+ }
+ PRISM_FALLTHROUGH
+ }
+ default: {
+ if ((flags & (PM_ESCAPE_FLAG_CONTROL | PM_ESCAPE_FLAG_META)) && !char_is_ascii_printable(peeked)) {
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ pm_parser_err(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current) + U32(width), PM_ERR_ESCAPE_INVALID_META);
+ return;
+ }
+ if (parser->current.end < parser->end) {
+ escape_write_escape_encoded(parser, buffer, regular_expression_buffer, flags);
+ } else {
+ pm_parser_err_current(parser, PM_ERR_INVALID_ESCAPE_CHARACTER);
+ }
+ return;
+ }
+ }
+}
+
+/**
+ * This function is responsible for lexing either a character literal or the ?
+ * operator. The supported character literals are described below.
+ *
+ * \\a bell, ASCII 07h (BEL)
+ * \\b backspace, ASCII 08h (BS)
+ * \t horizontal tab, ASCII 09h (TAB)
+ * \\n newline (line feed), ASCII 0Ah (LF)
+ * \v vertical tab, ASCII 0Bh (VT)
+ * \f form feed, ASCII 0Ch (FF)
+ * \r carriage return, ASCII 0Dh (CR)
+ * \\e escape, ASCII 1Bh (ESC)
+ * \s space, ASCII 20h (SPC)
+ * \\ backslash
+ * \nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7])
+ * \xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F])
+ * \unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F])
+ * \u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F])
+ * \cx or \C-x control character, where x is an ASCII printable character
+ * \M-x meta character, where x is an ASCII printable character
+ * \M-\C-x meta control character, where x is an ASCII printable character
+ * \M-\cx same as above
+ * \\c\M-x same as above
+ * \\c? or \C-? delete, ASCII 7Fh (DEL)
+ */
+static pm_token_type_t
+lex_question_mark(pm_parser_t *parser) {
+ if (lex_state_end_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ return PM_TOKEN_QUESTION_MARK;
+ }
+
+ if (parser->current.end >= parser->end) {
+ pm_parser_err_current(parser, PM_ERR_INCOMPLETE_QUESTION_MARK);
+ pm_string_shared_init(&parser->current_string, parser->current.start + 1, parser->current.end);
+ return PM_TOKEN_CHARACTER_LITERAL;
+ }
+
+ if (pm_char_is_whitespace(*parser->current.end)) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ return PM_TOKEN_QUESTION_MARK;
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+
+ if (match(parser, '\\')) {
+ lex_state_set(parser, PM_LEX_STATE_END);
+
+ pm_buffer_t buffer;
+ pm_buffer_init(&buffer, 3);
+
+ escape_read(parser, &buffer, NULL, PM_ESCAPE_FLAG_SINGLE);
+
+ // Copy buffer data into the arena and free the heap buffer.
+ void *arena_data = pm_arena_memdup(parser->arena, buffer.value, buffer.length, PRISM_ALIGNOF(uint8_t));
+ pm_string_constant_init(&parser->current_string, (const char *) arena_data, buffer.length);
+ pm_buffer_cleanup(&buffer);
+
+ return PM_TOKEN_CHARACTER_LITERAL;
+ } else {
+ size_t encoding_width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+
+ // Ternary operators can have a ? immediately followed by an identifier
+ // which starts with an underscore. We check for this case here.
+ if (
+ !(parser->encoding->alnum_char(parser->current.end, parser->end - parser->current.end) || peek(parser) == '_') ||
+ (
+ (parser->current.end + encoding_width >= parser->end) ||
+ !char_is_identifier(parser, parser->current.end + encoding_width, parser->end - (parser->current.end + encoding_width))
+ )
+ ) {
+ lex_state_set(parser, PM_LEX_STATE_END);
+ parser->current.end += encoding_width;
+ pm_string_shared_init(&parser->current_string, parser->current.start + 1, parser->current.end);
+ return PM_TOKEN_CHARACTER_LITERAL;
+ }
+ }
+
+ return PM_TOKEN_QUESTION_MARK;
+}
+
+/**
+ * Lex a variable that starts with an @ sign (either an instance or class
+ * variable).
+ */
+static pm_token_type_t
+lex_at_variable(pm_parser_t *parser) {
+ pm_token_type_t type = match(parser, '@') ? PM_TOKEN_CLASS_VARIABLE : PM_TOKEN_INSTANCE_VARIABLE;
+ const uint8_t *end = parser->end;
+
+ size_t width;
+ if ((width = char_is_identifier_start(parser, parser->current.end, end - parser->current.end)) > 0) {
+ parser->current.end += width;
+
+ while ((width = char_is_identifier(parser, parser->current.end, end - parser->current.end)) > 0) {
+ parser->current.end += width;
+ }
+ } else if (parser->current.end < end && pm_char_is_decimal_digit(*parser->current.end)) {
+ pm_diagnostic_id_t diag_id = (type == PM_TOKEN_CLASS_VARIABLE) ? PM_ERR_INCOMPLETE_VARIABLE_CLASS : PM_ERR_INCOMPLETE_VARIABLE_INSTANCE;
+ if (parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3) {
+ diag_id = (type == PM_TOKEN_CLASS_VARIABLE) ? PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3 : PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3;
+ }
+
+ size_t width = parser->encoding->char_width(parser->current.end, end - parser->current.end);
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, diag_id, (int) ((parser->current.end + width) - parser->current.start), (const char *) parser->current.start);
+ } else {
+ pm_diagnostic_id_t diag_id = (type == PM_TOKEN_CLASS_VARIABLE) ? PM_ERR_CLASS_VARIABLE_BARE : PM_ERR_INSTANCE_VARIABLE_BARE;
+ pm_parser_err_token(parser, &parser->current, diag_id);
+ }
+
+ // If we're lexing an embedded variable, then we need to pop back into the
+ // parent lex context.
+ if (parser->lex_modes.current->mode == PM_LEX_EMBVAR) {
+ lex_mode_pop(parser);
+ }
+
+ return type;
+}
+
+/**
+ * Optionally call out to the lex callback if one is provided.
+ */
+static PRISM_INLINE void
+parser_lex_callback(pm_parser_t *parser) {
+ if (parser->lex_callback.callback) {
+ parser->lex_callback.callback(parser, &parser->current, parser->lex_callback.data);
+ }
+}
+
+/**
+ * Return a new comment node of the specified type.
+ */
+static PRISM_INLINE pm_comment_t *
+parser_comment(pm_parser_t *parser, pm_comment_type_t type) {
+ pm_comment_t *comment = (pm_comment_t *) pm_arena_alloc(&parser->metadata_arena, sizeof(pm_comment_t), PRISM_ALIGNOF(pm_comment_t));
+
+ *comment = (pm_comment_t) {
+ .type = type,
+ .location = TOK2LOC(parser, &parser->current)
+ };
+
+ return comment;
+}
+
+/**
+ * Lex out embedded documentation, and return when we have either hit the end of
+ * the file or the end of the embedded documentation. This calls the callback
+ * manually because only the lexer should see these tokens, not the parser.
+ */
+static pm_token_type_t
+lex_embdoc(pm_parser_t *parser) {
+ // First, lex out the EMBDOC_BEGIN token.
+ const uint8_t *newline = next_newline(parser->current.end, parser->end - parser->current.end);
+
+ if (newline == NULL) {
+ parser->current.end = parser->end;
+ } else {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(newline - parser->start + 1));
+ parser->current.end = newline + 1;
+ }
+
+ parser->current.type = PM_TOKEN_EMBDOC_BEGIN;
+ parser_lex_callback(parser);
+
+ // Now, create a comment that is going to be attached to the parser.
+ const uint8_t *comment_start = parser->current.start;
+ pm_comment_t *comment = parser_comment(parser, PM_COMMENT_EMBDOC);
+
+ // Now, loop until we find the end of the embedded documentation or the end
+ // of the file.
+ while (parser->current.end + 4 <= parser->end) {
+ parser->current.start = parser->current.end;
+
+ // If we've hit the end of the embedded documentation then we'll return
+ // that token here.
+ if (
+ (memcmp(parser->current.end, "=end", 4) == 0) &&
+ (
+ (parser->current.end + 4 == parser->end) || // end of file
+ pm_char_is_whitespace(parser->current.end[4]) || // whitespace
+ (parser->current.end[4] == '\0') || // NUL or end of script
+ (parser->current.end[4] == '\004') || // ^D
+ (parser->current.end[4] == '\032') // ^Z
+ )
+ ) {
+ const uint8_t *newline = next_newline(parser->current.end, parser->end - parser->current.end);
+
+ if (newline == NULL) {
+ parser->current.end = parser->end;
+ } else {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(newline - parser->start + 1));
+ parser->current.end = newline + 1;
+ }
+
+ parser->current.type = PM_TOKEN_EMBDOC_END;
+ parser_lex_callback(parser);
+
+ comment->location.length = (uint32_t) (parser->current.end - comment_start);
+ pm_list_append(&parser->comment_list, (pm_list_node_t *) comment);
+
+ return PM_TOKEN_EMBDOC_END;
+ }
+
+ // Otherwise, we'll parse until the end of the line and return a line of
+ // embedded documentation.
+ const uint8_t *newline = next_newline(parser->current.end, parser->end - parser->current.end);
+
+ if (newline == NULL) {
+ parser->current.end = parser->end;
+ } else {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(newline - parser->start + 1));
+ parser->current.end = newline + 1;
+ }
+
+ parser->current.type = PM_TOKEN_EMBDOC_LINE;
+ parser_lex_callback(parser);
+ }
+
+ pm_parser_err_current(parser, PM_ERR_EMBDOC_TERM);
+
+ comment->location.length = (uint32_t) (parser->current.end - comment_start);
+ pm_list_append(&parser->comment_list, (pm_list_node_t *) comment);
+
+ return PM_TOKEN_EOF;
+}
+
+/**
+ * Set the current type to an ignored newline and then call the lex callback.
+ * This happens in a couple places depending on whether or not we have already
+ * lexed a comment.
+ */
+static PRISM_INLINE void
+parser_lex_ignored_newline(pm_parser_t *parser) {
+ parser->current.type = PM_TOKEN_IGNORED_NEWLINE;
+ parser_lex_callback(parser);
+}
+
+/**
+ * This function will be called when a newline is encountered. In some newlines,
+ * we need to check if there is a heredoc or heredocs that we have already lexed
+ * the body of that we need to now skip past. That will be indicated by the
+ * heredoc_end field on the parser.
+ *
+ * If it is set, then we need to skip past the heredoc body and then clear the
+ * heredoc_end field.
+ */
+static PRISM_INLINE void
+parser_flush_heredoc_end(pm_parser_t *parser) {
+ assert(parser->heredoc_end <= parser->end);
+ parser->next_start = parser->heredoc_end;
+ parser->heredoc_end = NULL;
+}
+
+/**
+ * Returns true if the parser has lexed the last token on the current line.
+*/
+static bool
+parser_end_of_line_p(const pm_parser_t *parser) {
+ const uint8_t *cursor = parser->current.end;
+
+ while (cursor < parser->end && *cursor != '\n' && *cursor != '#') {
+ if (!pm_char_is_inline_whitespace(*cursor++)) return false;
+ }
+
+ return true;
+}
+
+/**
+ * When we're lexing certain types (strings, symbols, lists, etc.) we have
+ * string content associated with the tokens. For example:
+ *
+ * "foo"
+ *
+ * In this case, the string content is foo. Since there is no escaping, there's
+ * no need to track additional information and the token can be returned as
+ * normal. However, if we have escape sequences:
+ *
+ * "foo\n"
+ *
+ * then the bytes in the string are "f", "o", "o", "\", "n", but we want to
+ * provide our consumers with the string content "f", "o", "o", "\n". In these
+ * cases, when we find the first escape sequence, we initialize a pm_buffer_t
+ * to keep track of the string content. Then in the parser, it will
+ * automatically attach the string content to the node that it belongs to.
+ */
+typedef struct {
+ /**
+ * The buffer that we're using to keep track of the string content. It will
+ * only be initialized if we receive an escape sequence.
+ */
+ pm_buffer_t buffer;
+
+ /**
+ * The cursor into the source string that points to how far we have
+ * currently copied into the buffer.
+ */
+ const uint8_t *cursor;
+} pm_token_buffer_t;
+
+/**
+ * In order to properly set a regular expression's encoding and to validate
+ * the byte sequence for the underlying encoding we must process any escape
+ * sequences. The unescaped byte sequence will be stored in `buffer` just like
+ * for other string-like types. However, we also need to store the regular
+ * expression's source string. That string may be different from what we see
+ * during lexing because some escape sequences rewrite the source.
+ *
+ * This value will only be initialized for regular expressions and only if we
+ * receive an escape sequence. It will contain the regular expression's source
+ * string's byte sequence.
+ */
+typedef struct {
+ /** The embedded base buffer. */
+ pm_token_buffer_t base;
+
+ /** The buffer holding the regexp source. */
+ pm_buffer_t regexp_buffer;
+} pm_regexp_token_buffer_t;
+
+/**
+ * Push the given byte into the token buffer.
+ */
+static PRISM_INLINE void
+pm_token_buffer_push_byte(pm_token_buffer_t *token_buffer, uint8_t byte) {
+ pm_buffer_append_byte(&token_buffer->buffer, byte);
+}
+
+static PRISM_INLINE void
+pm_regexp_token_buffer_push_byte(pm_regexp_token_buffer_t *token_buffer, uint8_t byte) {
+ pm_buffer_append_byte(&token_buffer->regexp_buffer, byte);
+}
+
+/**
+ * Return the width of the character at the end of the current token.
+ */
+static PRISM_INLINE size_t
+parser_char_width(const pm_parser_t *parser) {
+ size_t width;
+ if (parser->encoding_changed) {
+ width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
+ } else {
+ width = pm_encoding_utf_8_char_width(parser->current.end, parser->end - parser->current.end);
+ }
+
+ // TODO: If the character is invalid in the given encoding, then we'll just
+ // push one byte into the buffer. This should actually be an error.
+ return (width == 0 ? 1 : width);
+}
+
+/**
+ * Push an escaped character into the token buffer.
+ */
+static void
+pm_token_buffer_push_escaped(pm_token_buffer_t *token_buffer, pm_parser_t *parser) {
+ size_t width = parser_char_width(parser);
+ pm_buffer_append_bytes(&token_buffer->buffer, parser->current.end, width);
+ parser->current.end += width;
+}
+
+static void
+pm_regexp_token_buffer_push_escaped(pm_regexp_token_buffer_t *token_buffer, pm_parser_t *parser) {
+ size_t width = parser_char_width(parser);
+ const uint8_t *start = parser->current.end;
+ pm_buffer_append_bytes(&token_buffer->base.buffer, start, width);
+ pm_buffer_append_bytes(&token_buffer->regexp_buffer, start, width);
+ parser->current.end += width;
+}
+
+/**
+ * When we're about to return from lexing the current token and we know for sure
+ * that we have found an escape sequence, this function is called to copy the
+ * contents of the token buffer into the current string on the parser so that it
+ * can be attached to the correct node.
+ */
+static PRISM_INLINE void
+pm_token_buffer_copy(pm_parser_t *parser, pm_token_buffer_t *token_buffer) {
+ // Copy buffer data into the arena and free the heap buffer.
+ size_t len = pm_buffer_length(&token_buffer->buffer);
+ void *arena_data = pm_arena_memdup(parser->arena, pm_buffer_value(&token_buffer->buffer), len, PRISM_ALIGNOF(uint8_t));
+ pm_string_constant_init(&parser->current_string, (const char *) arena_data, len);
+ pm_buffer_cleanup(&token_buffer->buffer);
+}
+
+static PRISM_INLINE void
+pm_regexp_token_buffer_copy(pm_parser_t *parser, pm_regexp_token_buffer_t *token_buffer) {
+ pm_token_buffer_copy(parser, &token_buffer->base);
+ pm_buffer_cleanup(&token_buffer->regexp_buffer);
+}
+
+/**
+ * When we're about to return from lexing the current token, we need to flush
+ * all of the content that we have pushed into the buffer into the current
+ * string. If we haven't pushed anything into the buffer, this means that we
+ * never found an escape sequence, so we can directly reference the bounds of
+ * the current string. Either way, at the return of this function it is expected
+ * that parser->current_string is established in such a way that it can be
+ * attached to a node.
+ */
+static void
+pm_token_buffer_flush(pm_parser_t *parser, pm_token_buffer_t *token_buffer) {
+ if (token_buffer->cursor == NULL) {
+ pm_string_shared_init(&parser->current_string, parser->current.start, parser->current.end);
+ } else {
+ pm_buffer_append_bytes(&token_buffer->buffer, token_buffer->cursor, (size_t) (parser->current.end - token_buffer->cursor));
+ pm_token_buffer_copy(parser, token_buffer);
+ }
+}
+
+static void
+pm_regexp_token_buffer_flush(pm_parser_t *parser, pm_regexp_token_buffer_t *token_buffer) {
+ if (token_buffer->base.cursor == NULL) {
+ pm_string_shared_init(&parser->current_string, parser->current.start, parser->current.end);
+ } else {
+ const uint8_t *cursor = token_buffer->base.cursor;
+ size_t length = (size_t) (parser->current.end - cursor);
+ pm_buffer_append_bytes(&token_buffer->base.buffer, cursor, length);
+ pm_buffer_append_bytes(&token_buffer->regexp_buffer, cursor, length);
+ pm_regexp_token_buffer_copy(parser, token_buffer);
+ }
+}
+
+#define PM_TOKEN_BUFFER_DEFAULT_SIZE 16
+
+/**
+ * When we've found an escape sequence, we need to copy everything up to this
+ * point into the buffer because we're about to provide a string that has
+ * different content than a direct slice of the source.
+ *
+ * It is expected that the parser's current token end will be pointing at one
+ * byte past the backslash that starts the escape sequence.
+ */
+static void
+pm_token_buffer_escape(pm_parser_t *parser, pm_token_buffer_t *token_buffer) {
+ const uint8_t *start;
+ if (token_buffer->cursor == NULL) {
+ pm_buffer_init(&token_buffer->buffer, PM_TOKEN_BUFFER_DEFAULT_SIZE);
+ start = parser->current.start;
+ } else {
+ start = token_buffer->cursor;
+ }
+
+ const uint8_t *end = parser->current.end - 1;
+ assert(end >= start);
+ pm_buffer_append_bytes(&token_buffer->buffer, start, (size_t) (end - start));
+
+ token_buffer->cursor = end;
+}
+
+static void
+pm_regexp_token_buffer_escape(pm_parser_t *parser, pm_regexp_token_buffer_t *token_buffer) {
+ const uint8_t *start;
+ if (token_buffer->base.cursor == NULL) {
+ pm_buffer_init(&token_buffer->base.buffer, PM_TOKEN_BUFFER_DEFAULT_SIZE);
+ pm_buffer_init(&token_buffer->regexp_buffer, PM_TOKEN_BUFFER_DEFAULT_SIZE);
+ start = parser->current.start;
+ } else {
+ start = token_buffer->base.cursor;
+ }
+
+ const uint8_t *end = parser->current.end - 1;
+ pm_buffer_append_bytes(&token_buffer->base.buffer, start, (size_t) (end - start));
+ pm_buffer_append_bytes(&token_buffer->regexp_buffer, start, (size_t) (end - start));
+
+ token_buffer->base.cursor = end;
+}
+
+#undef PM_TOKEN_BUFFER_DEFAULT_SIZE
+
+/**
+ * Effectively the same thing as pm_strspn_inline_whitespace, but in the case of
+ * a tilde heredoc expands out tab characters to the nearest tab boundaries.
+ */
+static PRISM_INLINE size_t
+pm_heredoc_strspn_inline_whitespace(pm_parser_t *parser, const uint8_t **cursor, pm_heredoc_indent_t indent) {
+ size_t whitespace = 0;
+
+ switch (indent) {
+ case PM_HEREDOC_INDENT_NONE:
+ // Do nothing, we can't match a terminator with
+ // indentation and there's no need to calculate common
+ // whitespace.
+ break;
+ case PM_HEREDOC_INDENT_DASH:
+ // Skip past inline whitespace.
+ *cursor += pm_strspn_inline_whitespace(*cursor, parser->end - *cursor);
+ break;
+ case PM_HEREDOC_INDENT_TILDE:
+ // Skip past inline whitespace and calculate common
+ // whitespace.
+ while (*cursor < parser->end && pm_char_is_inline_whitespace(**cursor)) {
+ if (**cursor == '\t') {
+ whitespace = (whitespace / PM_TAB_WHITESPACE_SIZE + 1) * PM_TAB_WHITESPACE_SIZE;
+ } else {
+ whitespace++;
+ }
+ (*cursor)++;
+ }
+
+ break;
+ }
+
+ return whitespace;
+}
+
+/**
+ * Lex past the delimiter of a percent literal. Handle newlines and heredocs
+ * appropriately.
+ */
+static uint8_t
+pm_lex_percent_delimiter(pm_parser_t *parser) {
+ size_t eol_length = match_eol(parser);
+
+ if (eol_length) {
+ if (parser->heredoc_end) {
+ // If we have already lexed a heredoc, then the newline has already
+ // been added to the list. In this case we want to just flush the
+ // heredoc end.
+ parser_flush_heredoc_end(parser);
+ } else {
+ // Otherwise, we'll add the newline to the list of newlines.
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + U32(eol_length));
+ }
+
+ uint8_t delimiter = *parser->current.end;
+
+ // If our delimiter is \r\n, we want to treat it as if it's \n.
+ // For example, %\r\nfoo\r\n should be "foo"
+ if (eol_length == 2) {
+ delimiter = *(parser->current.end + 1);
+ }
+
+ parser->current.end += eol_length;
+ return delimiter;
+ }
+
+ return *parser->current.end++;
+}
+
+/**
+ * This is a convenience macro that will set the current token type, call the
+ * lex callback, and then return from the parser_lex function.
+ */
+#define LEX(token_type) parser->current.type = token_type; parser_lex_callback(parser); return
+
+/**
+ * Called when the parser requires a new token. The parser maintains a moving
+ * window of two tokens at a time: parser.previous and parser.current. This
+ * function will move the current token into the previous token and then
+ * lex a new token into the current token.
+ */
+static void
+parser_lex(pm_parser_t *parser) {
+ assert(parser->current.end <= parser->end);
+ parser->previous = parser->current;
+
+ // This value mirrors cmd_state from CRuby.
+ bool previous_command_start = parser->command_start;
+ parser->command_start = false;
+
+ // This is used to communicate to the newline lexing function that we've
+ // already seen a comment.
+ bool lexed_comment = false;
+
+ // Here we cache the current value of the semantic token seen flag. This is
+ // used to reset it in case we find a token that shouldn't flip this flag.
+ unsigned int semantic_token_seen = parser->semantic_token_seen;
+ parser->semantic_token_seen = true;
+
+ // We'll jump to this label when we are about to encounter an EOF.
+ // If we still have lex_modes on the stack, we pop them so that cleanup
+ // can happen. For example, we should still continue parsing after a heredoc
+ // identifier, even if the heredoc body was syntax invalid.
+ switch_lex_modes:
+
+ switch (parser->lex_modes.current->mode) {
+ case PM_LEX_DEFAULT:
+ case PM_LEX_EMBEXPR:
+ case PM_LEX_EMBVAR:
+
+ // We have a specific named label here because we are going to jump back to
+ // this location in the event that we have lexed a token that should not be
+ // returned to the parser. This includes comments, ignored newlines, and
+ // invalid tokens of some form.
+ lex_next_token: {
+ // If we have the special next_start pointer set, then we're going to jump
+ // to that location and start lexing from there.
+ if (parser->next_start != NULL) {
+ parser->current.end = parser->next_start;
+ parser->next_start = NULL;
+ }
+
+ // This value mirrors space_seen from CRuby. It tracks whether or not
+ // space has been eaten before the start of the next token.
+ bool space_seen = false;
+
+ // First, we're going to skip past any whitespace at the front of the next
+ // token. Skip runs of inline whitespace in bulk to avoid per-character
+ // stores back to parser->current.end.
+ bool chomping = true;
+ while (parser->current.end < parser->end && chomping) {
+ {
+ static const uint8_t inline_whitespace[256] = {
+ [' '] = 1, ['\t'] = 1, ['\f'] = 1, ['\v'] = 1
+ };
+ const uint8_t *scan = parser->current.end;
+ while (scan < parser->end && inline_whitespace[*scan]) scan++;
+ if (scan > parser->current.end) {
+ parser->current.end = scan;
+ space_seen = true;
+ continue;
+ }
+ }
+
+ switch (*parser->current.end) {
+ case '\r':
+ if (match_eol_offset(parser, 1)) {
+ chomping = false;
+ } else {
+ pm_parser_warn(parser, PM_TOKEN_END(parser, &parser->current), 1, PM_WARN_UNEXPECTED_CARRIAGE_RETURN);
+ parser->current.end++;
+ space_seen = true;
+ }
+ break;
+ case '\\': {
+ size_t eol_length = match_eol_offset(parser, 1);
+ if (eol_length) {
+ if (parser->heredoc_end) {
+ parser->current.end = parser->heredoc_end;
+ parser->heredoc_end = NULL;
+ } else {
+ parser->current.end += eol_length + 1;
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current));
+ space_seen = true;
+ }
+ } else if (pm_char_is_inline_whitespace(*parser->current.end)) {
+ parser->current.end += 2;
+ } else {
+ chomping = false;
+ }
+
+ break;
+ }
+ default:
+ chomping = false;
+ break;
+ }
+ }
+
+ // Next, we'll set to start of this token to be the current end.
+ parser->current.start = parser->current.end;
+
+ // We'll check if we're at the end of the file. If we are, then we
+ // need to return the EOF token.
+ if (parser->current.end >= parser->end) {
+ // We may be missing closing tokens. We should pop modes one by one
+ // to do the appropriate cleanup like moving next_start for heredocs.
+ // Only when no mode is remaining will we actually emit the EOF token.
+ if (parser->lex_modes.current->mode != PM_LEX_DEFAULT) {
+ lex_mode_pop(parser);
+ goto switch_lex_modes;
+ }
+
+ // If we hit EOF, but the EOF came immediately after a newline,
+ // set the start of the token to the newline. This way any EOF
+ // errors will be reported as happening on that line rather than
+ // a line after. For example "foo(\n" should report an error
+ // on line 1 even though EOF technically occurs on line 2.
+ if (parser->current.start > parser->start && (*(parser->current.start - 1) == '\n')) {
+ parser->current.start -= 1;
+ }
+ LEX(PM_TOKEN_EOF);
+ }
+
+ // Finally, we'll check the current character to determine the next
+ // token.
+ switch (*parser->current.end++) {
+ case '\0': // NUL or end of script
+ case '\004': // ^D
+ case '\032': // ^Z
+ parser->current.end--;
+ LEX(PM_TOKEN_EOF);
+
+ case '#': { // comments
+ const uint8_t *ending = next_newline(parser->current.end, parser->end - parser->current.end);
+ parser->current.end = ending == NULL ? parser->end : ending;
+
+ // If we found a comment while lexing, then we're going to
+ // add it to the list of comments in the file and keep
+ // lexing.
+ pm_comment_t *comment = parser_comment(parser, PM_COMMENT_INLINE);
+ pm_list_append(&parser->comment_list, (pm_list_node_t *) comment);
+
+ if (ending) parser->current.end++;
+ parser->current.type = PM_TOKEN_COMMENT;
+ parser_lex_callback(parser);
+
+ // Here, parse the comment to see if it's a magic comment
+ // and potentially change state on the parser.
+ if (!parser_lex_magic_comment(parser, semantic_token_seen) && (parser->current.start == parser->encoding_comment_start)) {
+ ptrdiff_t length = parser->current.end - parser->current.start;
+
+ // If we didn't find a magic comment within the first
+ // pass and we're at the start of the file, then we need
+ // to do another pass to potentially find other patterns
+ // for encoding comments.
+ if (length >= 10 && !parser->encoding_locked) {
+ parser_lex_magic_comment_encoding(parser);
+ }
+ }
+
+ lexed_comment = true;
+ }
+ PRISM_FALLTHROUGH
+ case '\r':
+ case '\n': {
+ parser->semantic_token_seen = semantic_token_seen & 0x1;
+ size_t eol_length = match_eol_at(parser, parser->current.end - 1);
+
+ if (eol_length) {
+ // The only way you can have carriage returns in this
+ // particular loop is if you have a carriage return
+ // followed by a newline. In that case we'll just skip
+ // over the carriage return and continue lexing, in
+ // order to make it so that the newline token
+ // encapsulates both the carriage return and the
+ // newline. Note that we need to check that we haven't
+ // already lexed a comment here because that falls
+ // through into here as well.
+ if (!lexed_comment) {
+ parser->current.end += eol_length - 1; // skip CR
+ }
+
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current));
+ }
+ }
+
+ if (parser->heredoc_end) {
+ parser_flush_heredoc_end(parser);
+ }
+
+ // If this is an ignored newline, then we can continue lexing after
+ // calling the callback with the ignored newline token.
+ switch (lex_state_ignored_p(parser)) {
+ case PM_IGNORED_NEWLINE_NONE:
+ break;
+ case PM_IGNORED_NEWLINE_PATTERN:
+ if (parser->pattern_matching_newlines || parser->in_keyword_arg) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+ parser->current.type = PM_TOKEN_NEWLINE;
+ return;
+ }
+ PRISM_FALLTHROUGH
+ case PM_IGNORED_NEWLINE_ALL:
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lexed_comment = false;
+ goto lex_next_token;
+ }
+
+ // Here we need to look ahead and see if there is a call operator
+ // (either . or &.) that starts the next line. If there is, then this
+ // is going to become an ignored newline and we're going to instead
+ // return the call operator.
+ const uint8_t *next_content = parser->next_start == NULL ? parser->current.end : parser->next_start;
+ next_content += pm_strspn_inline_whitespace(next_content, parser->end - next_content);
+
+ if (next_content < parser->end) {
+ // If we hit a comment after a newline, then we're going to check
+ // if it's ignored or if it's followed by a method call ('.').
+ // If it is, then we're going to call the
+ // callback with an ignored newline and then continue lexing.
+ // Otherwise we'll return a regular newline.
+ if (next_content[0] == '#') {
+ // Here we look for a "." or "&." following a "\n".
+ const uint8_t *following = next_newline(next_content, parser->end - next_content);
+
+ while (following && (following + 1 < parser->end)) {
+ following++;
+ following += pm_strspn_inline_whitespace(following, parser->end - following);
+
+ // If this is not followed by a comment, then we can break out
+ // of this loop.
+ if (peek_at(parser, following) != '#') break;
+
+ // If there is a comment, then we need to find the end of the
+ // comment and continue searching from there.
+ following = next_newline(following, parser->end - following);
+ }
+
+ // If the lex state was ignored, we will lex the
+ // ignored newline.
+ if (lex_state_ignored_p(parser)) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lexed_comment = false;
+ goto lex_next_token;
+ }
+
+ // If we hit a '.' or a '&.' we will lex the ignored
+ // newline.
+ if (following && (
+ (peek_at(parser, following) == '.') ||
+ (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '.')
+ )) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lexed_comment = false;
+ goto lex_next_token;
+ }
+
+
+ // If we are parsing as CRuby 4.0 or later and we
+ // hit a '&&' or a '||' then we will lex the ignored
+ // newline.
+ if (
+ (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) &&
+ following && (
+ (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '&') ||
+ (peek_at(parser, following) == '|' && peek_at(parser, following + 1) == '|') ||
+ (
+ peek_at(parser, following) == 'a' &&
+ peek_at(parser, following + 1) == 'n' &&
+ peek_at(parser, following + 2) == 'd' &&
+ peek_at(parser, next_content + 3) != '!' &&
+ peek_at(parser, next_content + 3) != '?' &&
+ !char_is_identifier(parser, following + 3, parser->end - (following + 3))
+ ) ||
+ (
+ peek_at(parser, following) == 'o' &&
+ peek_at(parser, following + 1) == 'r' &&
+ peek_at(parser, next_content + 2) != '!' &&
+ peek_at(parser, next_content + 2) != '?' &&
+ !char_is_identifier(parser, following + 2, parser->end - (following + 2))
+ )
+ )
+ ) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lexed_comment = false;
+ goto lex_next_token;
+ }
+ }
+
+ // If we hit a . after a newline, then we're in a call chain and
+ // we need to return the call operator.
+ if (next_content[0] == '.') {
+ // To match ripper, we need to emit an ignored newline even though
+ // it's a real newline in the case that we have a beginless range
+ // on a subsequent line.
+ if (peek_at(parser, next_content + 1) == '.') {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+ parser->current.type = PM_TOKEN_NEWLINE;
+ return;
+ }
+
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_DOT);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 1;
+ parser->next_start = NULL;
+ LEX(PM_TOKEN_DOT);
+ }
+
+ // If we hit a &. after a newline, then we're in a call chain and
+ // we need to return the call operator.
+ if (peek_at(parser, next_content) == '&' && peek_at(parser, next_content + 1) == '.') {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_DOT);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 2;
+ parser->next_start = NULL;
+ LEX(PM_TOKEN_AMPERSAND_DOT);
+ }
+
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) {
+ // If we hit an && then we are in a logical chain
+ // and we need to return the logical operator.
+ if (peek_at(parser, next_content) == '&' && peek_at(parser, next_content + 1) == '&') {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 2;
+ parser->next_start = NULL;
+ LEX(PM_TOKEN_AMPERSAND_AMPERSAND);
+ }
+
+ // If we hit a || then we are in a logical chain and
+ // we need to return the logical operator.
+ if (peek_at(parser, next_content) == '|' && peek_at(parser, next_content + 1) == '|') {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 2;
+ parser->next_start = NULL;
+ LEX(PM_TOKEN_PIPE_PIPE);
+ }
+
+ // If we hit an 'and' then we are in a logical chain
+ // and we need to return the logical operator.
+ if (
+ peek_at(parser, next_content) == 'a' &&
+ peek_at(parser, next_content + 1) == 'n' &&
+ peek_at(parser, next_content + 2) == 'd' &&
+ peek_at(parser, next_content + 3) != '!' &&
+ peek_at(parser, next_content + 3) != '?' &&
+ !char_is_identifier(parser, next_content + 3, parser->end - (next_content + 3))
+ ) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 3;
+ parser->next_start = NULL;
+ parser->command_start = true;
+ LEX(PM_TOKEN_KEYWORD_AND);
+ }
+
+ // If we hit a 'or' then we are in a logical chain
+ // and we need to return the logical operator.
+ if (
+ peek_at(parser, next_content) == 'o' &&
+ peek_at(parser, next_content + 1) == 'r' &&
+ peek_at(parser, next_content + 2) != '!' &&
+ peek_at(parser, next_content + 2) != '?' &&
+ !char_is_identifier(parser, next_content + 2, parser->end - (next_content + 2))
+ ) {
+ if (!lexed_comment) parser_lex_ignored_newline(parser);
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->current.start = next_content;
+ parser->current.end = next_content + 2;
+ parser->next_start = NULL;
+ parser->command_start = true;
+ LEX(PM_TOKEN_KEYWORD_OR);
+ }
+ }
+ }
+
+ // At this point we know this is a regular newline, and we can set the
+ // necessary state and return the token.
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+ parser->current.type = PM_TOKEN_NEWLINE;
+ if (!lexed_comment) parser_lex_callback(parser);
+ return;
+ }
+
+ // ,
+ case ',':
+ if ((parser->previous.type == PM_TOKEN_COMMA) && (parser->enclosure_nesting > 0)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_ARRAY_TERM, pm_token_str(parser->current.type));
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ LEX(PM_TOKEN_COMMA);
+
+ // (
+ case '(': {
+ pm_token_type_t type = PM_TOKEN_PARENTHESIS_LEFT;
+
+ if (space_seen && (lex_state_arg_p(parser) || parser->lex_state == (PM_LEX_STATE_END | PM_LEX_STATE_LABEL))) {
+ type = PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES;
+ }
+
+ parser->enclosure_nesting++;
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ pm_do_loop_stack_push(parser, false);
+ LEX(type);
+ }
+
+ // )
+ case ')':
+ parser->enclosure_nesting--;
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ pm_do_loop_stack_pop(parser);
+ LEX(PM_TOKEN_PARENTHESIS_RIGHT);
+
+ // ;
+ case ';':
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+ LEX(PM_TOKEN_SEMICOLON);
+
+ // [ [] []=
+ case '[':
+ parser->enclosure_nesting++;
+ pm_token_type_t type = PM_TOKEN_BRACKET_LEFT;
+
+ if (lex_state_operator_p(parser)) {
+ if (match(parser, ']')) {
+ parser->enclosure_nesting--;
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ LEX(match(parser, '=') ? PM_TOKEN_BRACKET_LEFT_RIGHT_EQUAL : PM_TOKEN_BRACKET_LEFT_RIGHT);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_ARG | PM_LEX_STATE_LABEL);
+ LEX(type);
+ }
+
+ if (lex_state_beg_p(parser) || (lex_state_arg_p(parser) && (space_seen || lex_state_p(parser, PM_LEX_STATE_LABELED)))) {
+ type = PM_TOKEN_BRACKET_LEFT_ARRAY;
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ pm_do_loop_stack_push(parser, false);
+ LEX(type);
+
+ // ]
+ case ']':
+ parser->enclosure_nesting--;
+ lex_state_set(parser, PM_LEX_STATE_END);
+ pm_do_loop_stack_pop(parser);
+ LEX(PM_TOKEN_BRACKET_RIGHT);
+
+ // {
+ case '{': {
+ pm_token_type_t type = PM_TOKEN_BRACE_LEFT;
+
+ if (parser->enclosure_nesting == parser->lambda_enclosure_nesting) {
+ // This { begins a lambda
+ parser->command_start = true;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ type = PM_TOKEN_LAMBDA_BEGIN;
+ } else if (lex_state_p(parser, PM_LEX_STATE_LABELED)) {
+ // This { begins a hash literal
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ } else if (lex_state_p(parser, PM_LEX_STATE_ARG_ANY | PM_LEX_STATE_END | PM_LEX_STATE_ENDFN)) {
+ // This { begins a block
+ parser->command_start = true;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ } else if (lex_state_p(parser, PM_LEX_STATE_ENDARG)) {
+ // This { begins a block on a command
+ parser->command_start = true;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ } else {
+ // This { begins a hash literal
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ }
+
+ parser->enclosure_nesting++;
+ parser->brace_nesting++;
+ pm_do_loop_stack_push(parser, false);
+
+ LEX(type);
+ }
+
+ // }
+ case '}':
+ parser->enclosure_nesting--;
+ pm_do_loop_stack_pop(parser);
+
+ if ((parser->lex_modes.current->mode == PM_LEX_EMBEXPR) && (parser->brace_nesting == 0)) {
+ lex_mode_pop(parser);
+ LEX(PM_TOKEN_EMBEXPR_END);
+ }
+
+ parser->brace_nesting--;
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(PM_TOKEN_BRACE_RIGHT);
+
+ // * ** **= *=
+ case '*': {
+ if (match(parser, '*')) {
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_STAR_STAR_EQUAL);
+ }
+
+ pm_token_type_t type = PM_TOKEN_STAR_STAR;
+
+ if (lex_state_spcarg_p(parser, space_seen)) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR);
+ type = PM_TOKEN_USTAR_STAR;
+ } else if (lex_state_beg_p(parser)) {
+ type = PM_TOKEN_USTAR_STAR;
+ } else if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "**", "argument prefix");
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(type);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_STAR_EQUAL);
+ }
+
+ pm_token_type_t type = PM_TOKEN_STAR;
+
+ if (lex_state_spcarg_p(parser, space_seen)) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_STAR);
+ type = PM_TOKEN_USTAR;
+ } else if (lex_state_beg_p(parser)) {
+ type = PM_TOKEN_USTAR;
+ } else if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "*", "argument prefix");
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(type);
+ }
+
+ // ! != !~ !@
+ case '!':
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ if (match(parser, '@')) {
+ LEX(PM_TOKEN_BANG);
+ }
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ if (match(parser, '=')) {
+ LEX(PM_TOKEN_BANG_EQUAL);
+ }
+
+ if (match(parser, '~')) {
+ LEX(PM_TOKEN_BANG_TILDE);
+ }
+
+ LEX(PM_TOKEN_BANG);
+
+ // = => =~ == === =begin
+ case '=':
+ if (
+ current_token_starts_line(parser) &&
+ (parser->current.end + 5 <= parser->end) &&
+ memcmp(parser->current.end, "begin", 5) == 0 &&
+ (pm_char_is_whitespace(peek_offset(parser, 5)) || (peek_offset(parser, 5) == '\0'))
+ ) {
+ pm_token_type_t type = lex_embdoc(parser);
+ if (type == PM_TOKEN_EOF) {
+ LEX(type);
+ }
+
+ goto lex_next_token;
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ if (match(parser, '>')) {
+ LEX(PM_TOKEN_EQUAL_GREATER);
+ }
+
+ if (match(parser, '~')) {
+ LEX(PM_TOKEN_EQUAL_TILDE);
+ }
+
+ if (match(parser, '=')) {
+ LEX(match(parser, '=') ? PM_TOKEN_EQUAL_EQUAL_EQUAL : PM_TOKEN_EQUAL_EQUAL);
+ }
+
+ LEX(PM_TOKEN_EQUAL);
+
+ // < << <<= <= <=>
+ case '<':
+ if (match(parser, '<')) {
+ if (
+ !lex_state_p(parser, PM_LEX_STATE_DOT | PM_LEX_STATE_CLASS) &&
+ !lex_state_end_p(parser) &&
+ (!lex_state_p(parser, PM_LEX_STATE_ARG_ANY) || lex_state_p(parser, PM_LEX_STATE_LABELED) || space_seen)
+ ) {
+ const uint8_t *end = parser->current.end;
+
+ pm_heredoc_quote_t quote = PM_HEREDOC_QUOTE_NONE;
+ pm_heredoc_indent_t indent = PM_HEREDOC_INDENT_NONE;
+
+ if (match(parser, '-')) {
+ indent = PM_HEREDOC_INDENT_DASH;
+ }
+ else if (match(parser, '~')) {
+ indent = PM_HEREDOC_INDENT_TILDE;
+ }
+
+ if (match(parser, '`')) {
+ quote = PM_HEREDOC_QUOTE_BACKTICK;
+ }
+ else if (match(parser, '"')) {
+ quote = PM_HEREDOC_QUOTE_DOUBLE;
+ }
+ else if (match(parser, '\'')) {
+ quote = PM_HEREDOC_QUOTE_SINGLE;
+ }
+
+ const uint8_t *ident_start = parser->current.end;
+ size_t width = 0;
+
+ if (parser->current.end >= parser->end) {
+ parser->current.end = end;
+ } else if (quote == PM_HEREDOC_QUOTE_NONE && (width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) == 0) {
+ parser->current.end = end;
+ } else {
+ if (quote == PM_HEREDOC_QUOTE_NONE) {
+ parser->current.end += width;
+
+ while ((width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end))) {
+ parser->current.end += width;
+ }
+ } else {
+ // If we have quotes, then we're going to go until we find the
+ // end quote.
+ while ((parser->current.end < parser->end) && quote != (pm_heredoc_quote_t) (*parser->current.end)) {
+ if (*parser->current.end == '\r' || *parser->current.end == '\n') break;
+ parser->current.end++;
+ }
+ }
+
+ size_t ident_length = (size_t) (parser->current.end - ident_start);
+ bool ident_error = false;
+
+ if (quote != PM_HEREDOC_QUOTE_NONE && !match(parser, (uint8_t) quote)) {
+ pm_parser_err(parser, U32(ident_start - parser->start), U32(ident_length), PM_ERR_HEREDOC_IDENTIFIER);
+ ident_error = true;
+ }
+
+ parser->explicit_encoding = NULL;
+ lex_mode_push(parser, (pm_lex_mode_t) {
+ .mode = PM_LEX_HEREDOC,
+ .as.heredoc = {
+ .base = {
+ .ident_start = ident_start,
+ .ident_length = ident_length,
+ .quote = quote,
+ .indent = indent
+ },
+ .next_start = parser->current.end,
+ .common_whitespace = NULL,
+ .line_continuation = false
+ }
+ });
+
+ if (parser->heredoc_end == NULL) {
+ const uint8_t *body_start = next_newline(parser->current.end, parser->end - parser->current.end);
+
+ if (body_start == NULL) {
+ // If there is no newline after the heredoc identifier, then
+ // this is not a valid heredoc declaration. In this case we
+ // will add an error, but we will still return a heredoc
+ // start.
+ if (!ident_error) pm_parser_err_heredoc_term(parser, ident_start, ident_length);
+ body_start = parser->end;
+ } else {
+ // Otherwise, we want to indicate that the body of the
+ // heredoc starts on the character after the next newline.
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(body_start - parser->start + 1));
+ body_start++;
+ }
+
+ parser->next_start = body_start;
+ } else {
+ parser->next_start = parser->heredoc_end;
+ }
+
+ LEX(PM_TOKEN_HEREDOC_START);
+ }
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_LESS_LESS_EQUAL);
+ }
+
+ if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "<<", "here document");
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ if (lex_state_p(parser, PM_LEX_STATE_CLASS)) parser->command_start = true;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(PM_TOKEN_LESS_LESS);
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ if (lex_state_p(parser, PM_LEX_STATE_CLASS)) parser->command_start = true;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ if (match(parser, '=')) {
+ if (match(parser, '>')) {
+ LEX(PM_TOKEN_LESS_EQUAL_GREATER);
+ }
+
+ LEX(PM_TOKEN_LESS_EQUAL);
+ }
+
+ LEX(PM_TOKEN_LESS);
+
+ // > >> >>= >=
+ case '>':
+ if (match(parser, '>')) {
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+ LEX(match(parser, '=') ? PM_TOKEN_GREATER_GREATER_EQUAL : PM_TOKEN_GREATER_GREATER);
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(match(parser, '=') ? PM_TOKEN_GREATER_EQUAL : PM_TOKEN_GREATER);
+
+ // double-quoted string literal
+ case '"': {
+ bool label_allowed = (lex_state_p(parser, PM_LEX_STATE_LABEL | PM_LEX_STATE_ENDFN) && !previous_command_start) || lex_state_arg_p(parser);
+ lex_mode_push_string(parser, true, label_allowed, '\0', '"');
+ LEX(PM_TOKEN_STRING_BEGIN);
+ }
+
+ // xstring literal
+ case '`': {
+ if (lex_state_p(parser, PM_LEX_STATE_FNAME)) {
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ LEX(PM_TOKEN_BACKTICK);
+ }
+
+ if (lex_state_p(parser, PM_LEX_STATE_DOT)) {
+ if (previous_command_start) {
+ lex_state_set(parser, PM_LEX_STATE_CMDARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ }
+
+ LEX(PM_TOKEN_BACKTICK);
+ }
+
+ lex_mode_push_string(parser, true, false, '\0', '`');
+ LEX(PM_TOKEN_BACKTICK);
+ }
+
+ // single-quoted string literal
+ case '\'': {
+ bool label_allowed = (lex_state_p(parser, PM_LEX_STATE_LABEL | PM_LEX_STATE_ENDFN) && !previous_command_start) || lex_state_arg_p(parser);
+ lex_mode_push_string(parser, false, label_allowed, '\0', '\'');
+ LEX(PM_TOKEN_STRING_BEGIN);
+ }
+
+ // ? character literal
+ case '?':
+ LEX(lex_question_mark(parser));
+
+ // & && &&= &=
+ case '&': {
+ if (match(parser, '&')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+
+ if (match(parser, '=')) {
+ LEX(PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
+ }
+
+ LEX(PM_TOKEN_AMPERSAND_AMPERSAND);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_AMPERSAND_EQUAL);
+ }
+
+ if (match(parser, '.')) {
+ lex_state_set(parser, PM_LEX_STATE_DOT);
+ LEX(PM_TOKEN_AMPERSAND_DOT);
+ }
+
+ pm_token_type_t type = PM_TOKEN_AMPERSAND;
+ if (lex_state_spcarg_p(parser, space_seen)) {
+ if ((peek(parser) != ':') || (peek_offset(parser, 1) == '\0')) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND);
+ } else {
+ const uint8_t delim = peek_offset(parser, 1);
+
+ if ((delim != '\'') && (delim != '"') && !char_is_identifier(parser, parser->current.end + 1, parser->end - (parser->current.end + 1))) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND);
+ }
+ }
+
+ type = PM_TOKEN_UAMPERSAND;
+ } else if (lex_state_beg_p(parser)) {
+ type = PM_TOKEN_UAMPERSAND;
+ } else if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "&", "argument prefix");
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(type);
+ }
+
+ // | || ||= |=
+ case '|':
+ if (match(parser, '|')) {
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PIPE_PIPE_EQUAL);
+ }
+
+ if (lex_state_p(parser, PM_LEX_STATE_BEG)) {
+ parser->current.end--;
+ LEX(PM_TOKEN_PIPE);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PIPE_PIPE);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PIPE_EQUAL);
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ }
+
+ LEX(PM_TOKEN_PIPE);
+
+ // + += +@
+ case '+': {
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+
+ if (match(parser, '@')) {
+ LEX(PM_TOKEN_UPLUS);
+ }
+
+ LEX(PM_TOKEN_PLUS);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PLUS_EQUAL);
+ }
+
+ if (
+ lex_state_beg_p(parser) ||
+ (lex_state_spcarg_p(parser, space_seen) ? (pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS), true) : false)
+ ) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+
+ if (pm_char_is_decimal_digit(peek(parser))) {
+ parser->current.end++;
+ pm_token_type_t type = lex_numeric(parser);
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(type);
+ }
+
+ LEX(PM_TOKEN_UPLUS);
+ }
+
+ if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "+", "unary operator");
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PLUS);
+ }
+
+ // - -= -@
+ case '-': {
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+
+ if (match(parser, '@')) {
+ LEX(PM_TOKEN_UMINUS);
+ }
+
+ LEX(PM_TOKEN_MINUS);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_MINUS_EQUAL);
+ }
+
+ if (match(parser, '>')) {
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ LEX(PM_TOKEN_MINUS_GREATER);
+ }
+
+ bool spcarg = lex_state_spcarg_p(parser, space_seen);
+ bool is_beg = lex_state_beg_p(parser);
+ if (!is_beg && spcarg) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS);
+ }
+
+ if (is_beg || spcarg) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(pm_char_is_decimal_digit(peek(parser)) ? PM_TOKEN_UMINUS_NUM : PM_TOKEN_UMINUS);
+ }
+
+ if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "-", "unary operator");
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_MINUS);
+ }
+
+ // . .. ...
+ case '.': {
+ bool beg_p = lex_state_beg_p(parser);
+
+ if (match(parser, '.')) {
+ if (match(parser, '.')) {
+ // If we're _not_ inside a range within default parameters
+ if (!context_p(parser, PM_CONTEXT_DEFAULT_PARAMS) && context_p(parser, PM_CONTEXT_DEF_PARAMS)) {
+ if (lex_state_p(parser, PM_LEX_STATE_END)) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_ENDARG);
+ }
+ LEX(PM_TOKEN_UDOT_DOT_DOT);
+ }
+
+ if (parser->enclosure_nesting == 0 && parser_end_of_line_p(parser)) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_DOT_DOT_DOT_EOL);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(beg_p ? PM_TOKEN_UDOT_DOT_DOT : PM_TOKEN_DOT_DOT_DOT);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(beg_p ? PM_TOKEN_UDOT_DOT : PM_TOKEN_DOT_DOT);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_DOT);
+ LEX(PM_TOKEN_DOT);
+ }
+
+ // integer
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
+ pm_token_type_t type = lex_numeric(parser);
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(type);
+ }
+
+ // :: symbol
+ case ':':
+ if (match(parser, ':')) {
+ if (lex_state_beg_p(parser) || lex_state_p(parser, PM_LEX_STATE_CLASS) || (lex_state_p(parser, PM_LEX_STATE_ARG_ANY) && space_seen)) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_UCOLON_COLON);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_DOT);
+ LEX(PM_TOKEN_COLON_COLON);
+ }
+
+ if (lex_state_end_p(parser) || pm_char_is_whitespace(peek(parser)) || peek(parser) == '#') {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_COLON);
+ }
+
+ if (peek(parser) == '"' || peek(parser) == '\'') {
+ lex_mode_push_string(parser, peek(parser) == '"', false, '\0', *parser->current.end);
+ parser->current.end++;
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_FNAME);
+ LEX(PM_TOKEN_SYMBOL_BEGIN);
+
+ // / /=
+ case '/':
+ if (lex_state_beg_p(parser)) {
+ lex_mode_push_regexp(parser, '\0', '/');
+ LEX(PM_TOKEN_REGEXP_BEGIN);
+ }
+
+ if (match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_SLASH_EQUAL);
+ }
+
+ if (lex_state_spcarg_p(parser, space_seen)) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_SLASH);
+ lex_mode_push_regexp(parser, '\0', '/');
+ LEX(PM_TOKEN_REGEXP_BEGIN);
+ }
+
+ if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "/", "regexp literal");
+ }
+
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(PM_TOKEN_SLASH);
+
+ // ^ ^=
+ case '^':
+ if (lex_state_operator_p(parser)) {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+ LEX(match(parser, '=') ? PM_TOKEN_CARET_EQUAL : PM_TOKEN_CARET);
+
+ // ~ ~@
+ case '~':
+ if (lex_state_operator_p(parser)) {
+ (void) match(parser, '@');
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ }
+
+ LEX(PM_TOKEN_TILDE);
+
+ // % %= %i %I %q %Q %w %W
+ case '%': {
+ // If there is no subsequent character then we have an
+ // invalid token. We're going to say it's the percent
+ // operator because we don't want to move into the string
+ // lex mode unnecessarily.
+ if ((lex_state_beg_p(parser) || lex_state_arg_p(parser)) && (parser->current.end >= parser->end)) {
+ pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT_EOF);
+ LEX(PM_TOKEN_PERCENT);
+ }
+
+ if (!lex_state_beg_p(parser) && match(parser, '=')) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PERCENT_EQUAL);
+ } else if (
+ lex_state_beg_p(parser) ||
+ (lex_state_p(parser, PM_LEX_STATE_FITEM) && (peek(parser) == 's')) ||
+ lex_state_spcarg_p(parser, space_seen)
+ ) {
+ if (!parser->encoding->alnum_char(parser->current.end, parser->end - parser->current.end)) {
+ if (*parser->current.end >= 0x80) {
+ pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT);
+ }
+
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_string(parser, true, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ LEX(PM_TOKEN_STRING_BEGIN);
+ }
+
+ // Delimiters for %-literals cannot be alphanumeric. We
+ // validate that here.
+ uint8_t delimiter = peek_offset(parser, 1);
+ if (delimiter >= 0x80 || parser->encoding->alnum_char(&delimiter, 1)) {
+ pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT);
+ goto lex_next_token;
+ }
+
+ switch (peek(parser)) {
+ case 'i': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ lex_mode_push_list(parser, false, pm_lex_percent_delimiter(parser));
+ } else {
+ lex_mode_push_list_eof(parser);
+ }
+
+ LEX(PM_TOKEN_PERCENT_LOWER_I);
+ }
+ case 'I': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ lex_mode_push_list(parser, true, pm_lex_percent_delimiter(parser));
+ } else {
+ lex_mode_push_list_eof(parser);
+ }
+
+ LEX(PM_TOKEN_PERCENT_UPPER_I);
+ }
+ case 'r': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_regexp(parser, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ } else {
+ lex_mode_push_regexp(parser, '\0', '\0');
+ }
+
+ LEX(PM_TOKEN_REGEXP_BEGIN);
+ }
+ case 'q': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_string(parser, false, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ } else {
+ lex_mode_push_string_eof(parser);
+ }
+
+ LEX(PM_TOKEN_STRING_BEGIN);
+ }
+ case 'Q': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_string(parser, true, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ } else {
+ lex_mode_push_string_eof(parser);
+ }
+
+ LEX(PM_TOKEN_STRING_BEGIN);
+ }
+ case 's': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_string(parser, false, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ lex_state_set(parser, PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM);
+ } else {
+ lex_mode_push_string_eof(parser);
+ }
+
+ LEX(PM_TOKEN_SYMBOL_BEGIN);
+ }
+ case 'w': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ lex_mode_push_list(parser, false, pm_lex_percent_delimiter(parser));
+ } else {
+ lex_mode_push_list_eof(parser);
+ }
+
+ LEX(PM_TOKEN_PERCENT_LOWER_W);
+ }
+ case 'W': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ lex_mode_push_list(parser, true, pm_lex_percent_delimiter(parser));
+ } else {
+ lex_mode_push_list_eof(parser);
+ }
+
+ LEX(PM_TOKEN_PERCENT_UPPER_W);
+ }
+ case 'x': {
+ parser->current.end++;
+
+ if (parser->current.end < parser->end) {
+ const uint8_t delimiter = pm_lex_percent_delimiter(parser);
+ lex_mode_push_string(parser, true, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter));
+ } else {
+ lex_mode_push_string_eof(parser);
+ }
+
+ LEX(PM_TOKEN_PERCENT_LOWER_X);
+ }
+ default:
+ // If we get to this point, then we have a % that is completely
+ // unparsable. In this case we'll just drop it from the parser
+ // and skip past it and hope that the next token is something
+ // that we can parse.
+ pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT);
+ goto lex_next_token;
+ }
+ }
+
+ if (ambiguous_operator_p(parser, space_seen)) {
+ PM_PARSER_WARN_TOKEN_FORMAT(parser, &parser->current, PM_WARN_AMBIGUOUS_BINARY_OPERATOR, "%", "string literal");
+ }
+
+ lex_state_set(parser, lex_state_operator_p(parser) ? PM_LEX_STATE_ARG : PM_LEX_STATE_BEG);
+ LEX(PM_TOKEN_PERCENT);
+ }
+
+ // global variable
+ case '$': {
+ pm_token_type_t type = lex_global_variable(parser);
+
+ // If we're lexing an embedded variable, then we need to pop back into
+ // the parent lex context.
+ if (parser->lex_modes.current->mode == PM_LEX_EMBVAR) {
+ lex_mode_pop(parser);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(type);
+ }
+
+ // instance variable, class variable
+ case '@':
+ lex_state_set(parser, parser->lex_state & PM_LEX_STATE_FNAME ? PM_LEX_STATE_ENDFN : PM_LEX_STATE_END);
+ LEX(lex_at_variable(parser));
+
+ default: {
+ if (*parser->current.start != '_') {
+ size_t width = char_is_identifier_start(parser, parser->current.start, parser->end - parser->current.start);
+
+ // If this isn't the beginning of an identifier, then
+ // it's an invalid token as we've exhausted all of the
+ // other options. We'll skip past it and return the next
+ // token after adding an appropriate error message.
+ if (!width) {
+ if (*parser->current.start >= 0x80) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_INVALID_MULTIBYTE_CHARACTER, *parser->current.start);
+ } else if (*parser->current.start == '\\') {
+ switch (peek_at(parser, parser->current.start + 1)) {
+ case ' ':
+ parser->current.end++;
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "escaped space");
+ break;
+ case '\f':
+ parser->current.end++;
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "escaped form feed");
+ break;
+ case '\t':
+ parser->current.end++;
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "escaped horizontal tab");
+ break;
+ case '\v':
+ parser->current.end++;
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "escaped vertical tab");
+ break;
+ case '\r':
+ if (peek_at(parser, parser->current.start + 2) != '\n') {
+ parser->current.end++;
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "escaped carriage return");
+ break;
+ }
+ PRISM_FALLTHROUGH
+ default:
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, "backslash");
+ break;
+ }
+ } else if (char_is_ascii_printable(*parser->current.start)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_INVALID_PRINTABLE_CHARACTER, *parser->current.start);
+ } else {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_INVALID_CHARACTER, *parser->current.start);
+ }
+
+ goto lex_next_token;
+ }
+
+ parser->current.end = parser->current.start + width;
+ }
+
+ pm_token_type_t type = lex_identifier(parser, previous_command_start);
+
+ // If we've hit a __END__ and it was at the start of the
+ // line or the start of the file and it is followed by
+ // either a \n or a \r\n, then this is the last token of the
+ // file.
+ if (
+ ((parser->current.end - parser->current.start) == 7) &&
+ current_token_starts_line(parser) &&
+ (memcmp(parser->current.start, "__END__", 7) == 0) &&
+ (parser->current.end == parser->end || match_eol(parser))
+ ) {
+ // Since we know we're about to add an __END__ comment,
+ // we know we need to add all of the newlines to get the
+ // correct column information for it.
+ const uint8_t *cursor = parser->current.end;
+ while ((cursor = next_newline(cursor, parser->end - cursor)) != NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(++cursor - parser->start));
+ }
+
+ parser->current.end = parser->end;
+ parser->current.type = PM_TOKEN___END__;
+ parser_lex_callback(parser);
+
+ parser->data_loc.start = PM_TOKEN_START(parser, &parser->current);
+ parser->data_loc.length = PM_TOKEN_LENGTH(&parser->current);
+
+ LEX(PM_TOKEN_EOF);
+ }
+
+ pm_lex_state_t last_state = parser->lex_state;
+
+ if (type == PM_TOKEN_IDENTIFIER || type == PM_TOKEN_CONSTANT || type == PM_TOKEN_METHOD_NAME) {
+ if (lex_state_p(parser, PM_LEX_STATE_BEG_ANY | PM_LEX_STATE_ARG_ANY | PM_LEX_STATE_DOT)) {
+ if (previous_command_start) {
+ lex_state_set(parser, PM_LEX_STATE_CMDARG);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_ARG);
+ }
+ } else if (parser->lex_state == PM_LEX_STATE_FNAME) {
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ } else {
+ lex_state_set(parser, PM_LEX_STATE_END);
+ }
+ }
+
+ if (
+ !(last_state & (PM_LEX_STATE_DOT | PM_LEX_STATE_FNAME)) &&
+ (type == PM_TOKEN_IDENTIFIER) &&
+ ((pm_parser_local_depth(parser, &parser->current) != -1) ||
+ pm_token_is_numbered_parameter(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)))
+ ) {
+ lex_state_set(parser, PM_LEX_STATE_END | PM_LEX_STATE_LABEL);
+ }
+
+ LEX(type);
+ }
+ }
+ }
+ case PM_LEX_LIST: {
+ if (parser->next_start != NULL) {
+ parser->current.end = parser->next_start;
+ parser->next_start = NULL;
+ }
+
+ // First we'll set the beginning of the token.
+ parser->current.start = parser->current.end;
+
+ // If there's any whitespace at the start of the list, then we're
+ // going to trim it off the beginning and create a new token.
+ size_t whitespace;
+
+ if (parser->heredoc_end) {
+ whitespace = pm_strspn_inline_whitespace(parser->current.end, parser->end - parser->current.end);
+ if (peek_offset(parser, (ptrdiff_t)whitespace) == '\n') {
+ whitespace += 1;
+ }
+ } else {
+ whitespace = pm_strspn_whitespace_newlines(parser->current.end, parser->end - parser->current.end, &parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current));
+ }
+
+ if (whitespace > 0) {
+ parser->current.end += whitespace;
+ if (peek_offset(parser, -1) == '\n') {
+ // mutates next_start
+ parser_flush_heredoc_end(parser);
+ }
+ LEX(PM_TOKEN_WORDS_SEP);
+ }
+
+ // We'll check if we're at the end of the file. If we are, then we
+ // need to return the EOF token.
+ if (parser->current.end >= parser->end) {
+ LEX(PM_TOKEN_EOF);
+ }
+
+ // Here we'll get a list of the places where strpbrk should break,
+ // and then find the first one.
+ pm_lex_mode_t *lex_mode = parser->lex_modes.current;
+ const uint8_t *breakpoints = lex_mode->as.list.breakpoints;
+ const uint8_t *breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+
+ // If we haven't found an escape yet, then this buffer will be
+ // unallocated since we can refer directly to the source string.
+ pm_token_buffer_t token_buffer = { 0 };
+
+ while (breakpoint != NULL) {
+ // If we hit whitespace, then we must have received content by
+ // now, so we can return an element of the list.
+ if (pm_char_is_whitespace(*breakpoint)) {
+ parser->current.end = breakpoint;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // If we hit the terminator, we need to check which token to
+ // return.
+ if (*breakpoint == lex_mode->as.list.terminator) {
+ // If this terminator doesn't actually close the list, then
+ // we need to continue on past it.
+ if (lex_mode->as.list.nesting > 0) {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ lex_mode->as.list.nesting--;
+ continue;
+ }
+
+ // If we've hit the terminator and we've already skipped
+ // past content, then we can return a list node.
+ if (breakpoint > parser->current.start) {
+ parser->current.end = breakpoint;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // Otherwise, switch back to the default state and return
+ // the end of the list.
+ parser->current.end = breakpoint + 1;
+ lex_mode_pop(parser);
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(PM_TOKEN_STRING_END);
+ }
+
+ // If we hit a null byte, skip directly past it.
+ if (*breakpoint == '\0') {
+ breakpoint = pm_strpbrk(parser, breakpoint + 1, breakpoints, parser->end - (breakpoint + 1), true);
+ continue;
+ }
+
+ // If we hit escapes, then we need to treat the next token
+ // literally. In this case we'll skip past the next character
+ // and find the next breakpoint.
+ if (*breakpoint == '\\') {
+ parser->current.end = breakpoint + 1;
+
+ // If we've hit the end of the file, then break out of the
+ // loop by setting the breakpoint to NULL.
+ if (parser->current.end == parser->end) {
+ breakpoint = NULL;
+ continue;
+ }
+
+ pm_token_buffer_escape(parser, &token_buffer);
+ uint8_t peeked = peek(parser);
+
+ switch (peeked) {
+ case ' ':
+ case '\f':
+ case '\t':
+ case '\v':
+ case '\\':
+ pm_token_buffer_push_byte(&token_buffer, peeked);
+ parser->current.end++;
+ break;
+ case '\r':
+ parser->current.end++;
+ if (peek(parser) != '\n') {
+ pm_token_buffer_push_byte(&token_buffer, '\r');
+ break;
+ }
+ PRISM_FALLTHROUGH
+ case '\n':
+ pm_token_buffer_push_byte(&token_buffer, '\n');
+
+ if (parser->heredoc_end) {
+ // ... if we are on the same line as a heredoc,
+ // flush the heredoc and continue parsing after
+ // heredoc_end.
+ parser_flush_heredoc_end(parser);
+ pm_token_buffer_copy(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ } else {
+ // ... else track the newline.
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ }
+
+ parser->current.end++;
+ break;
+ default:
+ if (peeked == lex_mode->as.list.incrementor || peeked == lex_mode->as.list.terminator) {
+ pm_token_buffer_push_byte(&token_buffer, peeked);
+ parser->current.end++;
+ } else if (lex_mode->as.list.interpolation) {
+ escape_read(parser, &token_buffer.buffer, NULL, PM_ESCAPE_FLAG_NONE);
+ } else {
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_escaped(&token_buffer, parser);
+ }
+
+ break;
+ }
+
+ token_buffer.cursor = parser->current.end;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ continue;
+ }
+
+ // If we hit a #, then we will attempt to lex interpolation.
+ if (*breakpoint == '#') {
+ pm_token_type_t type = lex_interpolation(parser, breakpoint);
+
+ if (!type) {
+ // If we haven't returned at this point then we had something
+ // that looked like an interpolated class or instance variable
+ // like "#@" but wasn't actually. In this case we'll just skip
+ // to the next breakpoint.
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ continue;
+ }
+
+ if (type == PM_TOKEN_STRING_CONTENT) {
+ pm_token_buffer_flush(parser, &token_buffer);
+ }
+
+ LEX(type);
+ }
+
+ // If we've hit the incrementor, then we need to skip past it
+ // and find the next breakpoint.
+ assert(*breakpoint == lex_mode->as.list.incrementor);
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ lex_mode->as.list.nesting++;
+ continue;
+ }
+
+ if (parser->current.end > parser->current.start) {
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // If we were unable to find a breakpoint, then this token hits the
+ // end of the file.
+ parser->current.end = parser->end;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+ case PM_LEX_REGEXP: {
+ // First, we'll set to start of this token to be the current end.
+ if (parser->next_start == NULL) {
+ parser->current.start = parser->current.end;
+ } else {
+ parser->current.start = parser->next_start;
+ parser->current.end = parser->next_start;
+ parser->next_start = NULL;
+ }
+
+ // We'll check if we're at the end of the file. If we are, then we
+ // need to return the EOF token.
+ if (parser->current.end >= parser->end) {
+ LEX(PM_TOKEN_EOF);
+ }
+
+ // Get a reference to the current mode.
+ pm_lex_mode_t *lex_mode = parser->lex_modes.current;
+
+ // These are the places where we need to split up the content of the
+ // regular expression. We'll use strpbrk to find the first of these
+ // characters.
+ const uint8_t *breakpoints = lex_mode->as.regexp.breakpoints;
+ const uint8_t *breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ pm_regexp_token_buffer_t token_buffer = { 0 };
+
+ while (breakpoint != NULL) {
+ uint8_t term = lex_mode->as.regexp.terminator;
+ bool is_terminator = (*breakpoint == term);
+
+ // If the terminator is newline, we need to consider \r\n _also_ a newline
+ // For example: `%\nfoo\r\n`
+ // The string should be "foo", not "foo\r"
+ if (*breakpoint == '\r' && peek_at(parser, breakpoint + 1) == '\n') {
+ if (term == '\n') {
+ is_terminator = true;
+ }
+
+ // If the terminator is a CR, but we see a CRLF, we need to
+ // treat the CRLF as a newline, meaning this is _not_ the
+ // terminator
+ if (term == '\r') {
+ is_terminator = false;
+ }
+ }
+
+ // If we hit the terminator, we need to determine what kind of
+ // token to return.
+ if (is_terminator) {
+ if (lex_mode->as.regexp.nesting > 0) {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ lex_mode->as.regexp.nesting--;
+ continue;
+ }
+
+ // Here we've hit the terminator. If we have already consumed
+ // content then we need to return that content as string content
+ // first.
+ if (breakpoint > parser->current.start) {
+ parser->current.end = breakpoint;
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // Check here if we need to track the newline.
+ size_t eol_length = match_eol_at(parser, breakpoint);
+ if (eol_length) {
+ parser->current.end = breakpoint + eol_length;
+
+ // Track the newline if we're not in a heredoc that
+ // would have already have added the newline to the
+ // list.
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current));
+ }
+ } else {
+ parser->current.end = breakpoint + 1;
+ }
+
+ // Since we've hit the terminator of the regular expression,
+ // we now need to parse the options.
+ parser->current.end += pm_strspn_regexp_option(parser->current.end, parser->end - parser->current.end);
+
+ lex_mode_pop(parser);
+ lex_state_set(parser, PM_LEX_STATE_END);
+ LEX(PM_TOKEN_REGEXP_END);
+ }
+
+ // If we've hit the incrementor, then we need to skip past it
+ // and find the next breakpoint.
+ if (*breakpoint && *breakpoint == lex_mode->as.regexp.incrementor) {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ lex_mode->as.regexp.nesting++;
+ continue;
+ }
+
+ switch (*breakpoint) {
+ case '\0':
+ // If we hit a null byte, skip directly past it.
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
+ case '\r':
+ if (peek_at(parser, breakpoint + 1) != '\n') {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
+ }
+
+ breakpoint++;
+ parser->current.end = breakpoint;
+ pm_regexp_token_buffer_escape(parser, &token_buffer);
+ token_buffer.base.cursor = breakpoint;
+
+ PRISM_FALLTHROUGH
+ case '\n':
+ // If we've hit a newline, then we need to track that in
+ // the list of newlines.
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(breakpoint - parser->start + 1));
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
+ }
+
+ parser->current.end = breakpoint + 1;
+ parser_flush_heredoc_end(parser);
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ case '\\': {
+ // If we hit escapes, then we need to treat the next
+ // token literally. In this case we'll skip past the
+ // next character and find the next breakpoint.
+ parser->current.end = breakpoint + 1;
+
+ // If we've hit the end of the file, then break out of
+ // the loop by setting the breakpoint to NULL.
+ if (parser->current.end == parser->end) {
+ breakpoint = NULL;
+ break;
+ }
+
+ pm_regexp_token_buffer_escape(parser, &token_buffer);
+ uint8_t peeked = peek(parser);
+
+ switch (peeked) {
+ case '\r':
+ parser->current.end++;
+ if (peek(parser) != '\n') {
+ if (lex_mode->as.regexp.terminator != '\r') {
+ pm_token_buffer_push_byte(&token_buffer.base, '\\');
+ }
+ pm_regexp_token_buffer_push_byte(&token_buffer, '\r');
+ pm_token_buffer_push_byte(&token_buffer.base, '\r');
+ break;
+ }
+ PRISM_FALLTHROUGH
+ case '\n':
+ if (parser->heredoc_end) {
+ // ... if we are on the same line as a heredoc,
+ // flush the heredoc and continue parsing after
+ // heredoc_end.
+ parser_flush_heredoc_end(parser);
+ pm_regexp_token_buffer_copy(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ } else {
+ // ... else track the newline.
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ }
+
+ parser->current.end++;
+ break;
+ case 'c':
+ case 'C':
+ case 'M':
+ case 'u':
+ case 'x':
+ escape_read(parser, &token_buffer.regexp_buffer, &token_buffer.base.buffer, PM_ESCAPE_FLAG_REGEXP);
+ break;
+ default:
+ if (lex_mode->as.regexp.terminator == peeked) {
+ // Some characters when they are used as the
+ // terminator also receive an escape. They are
+ // enumerated here.
+ switch (peeked) {
+ case '$': case ')': case '*': case '+':
+ case '.': case '>': case '?': case ']':
+ case '^': case '|': case '}':
+ pm_token_buffer_push_byte(&token_buffer.base, '\\');
+ break;
+ default:
+ break;
+ }
+
+ pm_regexp_token_buffer_push_byte(&token_buffer, peeked);
+ pm_token_buffer_push_byte(&token_buffer.base, peeked);
+ parser->current.end++;
+ break;
+ }
+
+ if (peeked < 0x80) pm_token_buffer_push_byte(&token_buffer.base, '\\');
+ pm_regexp_token_buffer_push_escaped(&token_buffer, parser);
+ break;
+ }
+
+ token_buffer.base.cursor = parser->current.end;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
+ }
+ case '#': {
+ // If we hit a #, then we will attempt to lex
+ // interpolation.
+ pm_token_type_t type = lex_interpolation(parser, breakpoint);
+
+ if (!type) {
+ // If we haven't returned at this point then we had
+ // something that looked like an interpolated class or
+ // instance variable like "#@" but wasn't actually. In
+ // this case we'll just skip to the next breakpoint.
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
+ }
+
+ if (type == PM_TOKEN_STRING_CONTENT) {
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ }
+
+ LEX(type);
+ }
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+ }
+
+ if (parser->current.end > parser->current.start) {
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // If we were unable to find a breakpoint, then this token hits the
+ // end of the file.
+ parser->current.end = parser->end;
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+ case PM_LEX_STRING: {
+ // First, we'll set to start of this token to be the current end.
+ if (parser->next_start == NULL) {
+ parser->current.start = parser->current.end;
+ } else {
+ parser->current.start = parser->next_start;
+ parser->current.end = parser->next_start;
+ parser->next_start = NULL;
+ }
+
+ // We'll check if we're at the end of the file. If we are, then we need to
+ // return the EOF token.
+ if (parser->current.end >= parser->end) {
+ LEX(PM_TOKEN_EOF);
+ }
+
+ // These are the places where we need to split up the content of the
+ // string. We'll use strpbrk to find the first of these characters.
+ pm_lex_mode_t *lex_mode = parser->lex_modes.current;
+ const uint8_t *breakpoints = lex_mode->as.string.breakpoints;
+ const uint8_t *breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+
+ // If we haven't found an escape yet, then this buffer will be
+ // unallocated since we can refer directly to the source string.
+ pm_token_buffer_t token_buffer = { 0 };
+
+ while (breakpoint != NULL) {
+ // If we hit the incrementor, then we'll increment then nesting and
+ // continue lexing.
+ if (lex_mode->as.string.incrementor != '\0' && *breakpoint == lex_mode->as.string.incrementor) {
+ lex_mode->as.string.nesting++;
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ continue;
+ }
+
+ uint8_t term = lex_mode->as.string.terminator;
+ bool is_terminator = (*breakpoint == term);
+
+ // If the terminator is newline, we need to consider \r\n _also_ a newline
+ // For example: `%r\nfoo\r\n`
+ // The string should be /foo/, not /foo\r/
+ if (*breakpoint == '\r' && peek_at(parser, breakpoint + 1) == '\n') {
+ if (term == '\n') {
+ is_terminator = true;
+ }
+
+ // If the terminator is a CR, but we see a CRLF, we need to
+ // treat the CRLF as a newline, meaning this is _not_ the
+ // terminator
+ if (term == '\r') {
+ is_terminator = false;
+ }
+ }
+
+ // Note that we have to check the terminator here first because we could
+ // potentially be parsing a % string that has a # character as the
+ // terminator.
+ if (is_terminator) {
+ // If this terminator doesn't actually close the string, then we need
+ // to continue on past it.
+ if (lex_mode->as.string.nesting > 0) {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ lex_mode->as.string.nesting--;
+ continue;
+ }
+
+ // Here we've hit the terminator. If we have already consumed content
+ // then we need to return that content as string content first.
+ if (breakpoint > parser->current.start) {
+ parser->current.end = breakpoint;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // Otherwise we need to switch back to the parent lex mode and
+ // return the end of the string.
+ size_t eol_length = match_eol_at(parser, breakpoint);
+ if (eol_length) {
+ parser->current.end = breakpoint + eol_length;
+
+ // Track the newline if we're not in a heredoc that
+ // would have already have added the newline to the
+ // list.
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current));
+ }
+ } else {
+ parser->current.end = breakpoint + 1;
+ }
+
+ if (lex_mode->as.string.label_allowed && (peek(parser) == ':') && (peek_offset(parser, 1) != ':')) {
+ parser->current.end++;
+ lex_state_set(parser, PM_LEX_STATE_ARG | PM_LEX_STATE_LABELED);
+ lex_mode_pop(parser);
+ LEX(PM_TOKEN_LABEL_END);
+ }
+
+ // When the delimiter itself is a newline, we won't
+ // get a chance to flush heredocs in the usual places since
+ // the newline is already consumed.
+ if (term == '\n' && parser->heredoc_end) {
+ parser_flush_heredoc_end(parser);
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_END);
+ lex_mode_pop(parser);
+ LEX(PM_TOKEN_STRING_END);
+ }
+
+ switch (*breakpoint) {
+ case '\0':
+ // Skip directly past the null character.
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ case '\r':
+ if (peek_at(parser, breakpoint + 1) != '\n') {
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+
+ // If we hit a \r\n sequence, then we need to treat it
+ // as a newline.
+ breakpoint++;
+ parser->current.end = breakpoint;
+ pm_token_buffer_escape(parser, &token_buffer);
+ token_buffer.cursor = breakpoint;
+
+ PRISM_FALLTHROUGH
+ case '\n':
+ // When we hit a newline, we need to flush any potential
+ // heredocs. Note that this has to happen after we check
+ // for the terminator in case the terminator is a
+ // newline character.
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(breakpoint - parser->start + 1));
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+
+ parser->current.end = breakpoint + 1;
+ parser_flush_heredoc_end(parser);
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ case '\\': {
+ // Here we hit escapes.
+ parser->current.end = breakpoint + 1;
+
+ // If we've hit the end of the file, then break out of
+ // the loop by setting the breakpoint to NULL.
+ if (parser->current.end == parser->end) {
+ breakpoint = NULL;
+ continue;
+ }
+
+ pm_token_buffer_escape(parser, &token_buffer);
+ uint8_t peeked = peek(parser);
+
+ switch (peeked) {
+ case '\\':
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ parser->current.end++;
+ break;
+ case '\r':
+ parser->current.end++;
+ if (peek(parser) != '\n') {
+ if (!lex_mode->as.string.interpolation) {
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ }
+ pm_token_buffer_push_byte(&token_buffer, '\r');
+ break;
+ }
+ PRISM_FALLTHROUGH
+ case '\n':
+ if (!lex_mode->as.string.interpolation) {
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_byte(&token_buffer, '\n');
+ }
+
+ if (parser->heredoc_end) {
+ // ... if we are on the same line as a heredoc,
+ // flush the heredoc and continue parsing after
+ // heredoc_end.
+ parser_flush_heredoc_end(parser);
+ pm_token_buffer_copy(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ } else {
+ // ... else track the newline.
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, PM_TOKEN_END(parser, &parser->current) + 1);
+ }
+
+ parser->current.end++;
+ break;
+ default:
+ if (lex_mode->as.string.incrementor != '\0' && peeked == lex_mode->as.string.incrementor) {
+ pm_token_buffer_push_byte(&token_buffer, peeked);
+ parser->current.end++;
+ } else if (lex_mode->as.string.terminator != '\0' && peeked == lex_mode->as.string.terminator) {
+ pm_token_buffer_push_byte(&token_buffer, peeked);
+ parser->current.end++;
+ } else if (lex_mode->as.string.interpolation) {
+ escape_read(parser, &token_buffer.buffer, NULL, PM_ESCAPE_FLAG_NONE);
+ } else {
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_escaped(&token_buffer, parser);
+ }
+
+ break;
+ }
+
+ token_buffer.cursor = parser->current.end;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+ case '#': {
+ pm_token_type_t type = lex_interpolation(parser, breakpoint);
+
+ if (!type) {
+ // If we haven't returned at this point then we had something that
+ // looked like an interpolated class or instance variable like "#@"
+ // but wasn't actually. In this case we'll just skip to the next
+ // breakpoint.
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+
+ if (type == PM_TOKEN_STRING_CONTENT) {
+ pm_token_buffer_flush(parser, &token_buffer);
+ }
+
+ LEX(type);
+ }
+ default:
+ assert(false && "unreachable");
+ }
+ }
+
+ if (parser->current.end > parser->current.start) {
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // If we've hit the end of the string, then this is an unterminated
+ // string. In that case we'll return a string content token.
+ parser->current.end = parser->end;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+ case PM_LEX_HEREDOC: {
+ // First, we'll set to start of this token.
+ if (parser->next_start == NULL) {
+ parser->current.start = parser->current.end;
+ } else {
+ parser->current.start = parser->next_start;
+ parser->current.end = parser->next_start;
+ parser->heredoc_end = NULL;
+ parser->next_start = NULL;
+ }
+
+ // Now let's grab the information about the identifier off of the
+ // current lex mode.
+ pm_lex_mode_t *lex_mode = parser->lex_modes.current;
+ pm_heredoc_lex_mode_t *heredoc_lex_mode = &lex_mode->as.heredoc.base;
+
+ bool line_continuation = lex_mode->as.heredoc.line_continuation;
+ lex_mode->as.heredoc.line_continuation = false;
+
+ // We'll check if we're at the end of the file. If we are, then we
+ // will add an error (because we weren't able to find the
+ // terminator) but still continue parsing so that content after the
+ // declaration of the heredoc can be parsed.
+ if (parser->current.end >= parser->end) {
+ pm_parser_err_heredoc_term(parser, heredoc_lex_mode->ident_start, heredoc_lex_mode->ident_length);
+ parser->next_start = lex_mode->as.heredoc.next_start;
+ parser->heredoc_end = parser->current.end;
+ lex_state_set(parser, PM_LEX_STATE_END);
+ lex_mode_pop(parser);
+ LEX(PM_TOKEN_HEREDOC_END);
+ }
+
+ const uint8_t *ident_start = heredoc_lex_mode->ident_start;
+ size_t ident_length = heredoc_lex_mode->ident_length;
+
+ // If we are immediately following a newline and we have hit the
+ // terminator, then we need to return the ending of the heredoc.
+ if (current_token_starts_line(parser)) {
+ const uint8_t *start = parser->current.start;
+
+ if (!line_continuation && (start + ident_length <= parser->end)) {
+ const uint8_t *newline = next_newline(start, parser->end - start);
+ const uint8_t *ident_end = newline;
+ const uint8_t *terminator_end = newline;
+
+ if (newline == NULL) {
+ terminator_end = parser->end;
+ ident_end = parser->end;
+ } else {
+ terminator_end++;
+ if (newline[-1] == '\r') {
+ ident_end--; // Remove \r
+ }
+ }
+
+ const uint8_t *terminator_start = ident_end - ident_length;
+ const uint8_t *cursor = start;
+
+ if (heredoc_lex_mode->indent == PM_HEREDOC_INDENT_DASH || heredoc_lex_mode->indent == PM_HEREDOC_INDENT_TILDE) {
+ while (cursor < terminator_start && pm_char_is_inline_whitespace(*cursor)) {
+ cursor++;
+ }
+ }
+
+ if (
+ (cursor == terminator_start) &&
+ (memcmp(terminator_start, ident_start, ident_length) == 0)
+ ) {
+ if (newline != NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(newline - parser->start + 1));
+ }
+
+ parser->current.end = terminator_end;
+ if (*lex_mode->as.heredoc.next_start == '\\') {
+ parser->next_start = NULL;
+ } else {
+ parser->next_start = lex_mode->as.heredoc.next_start;
+ parser->heredoc_end = parser->current.end;
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_END);
+ lex_mode_pop(parser);
+ LEX(PM_TOKEN_HEREDOC_END);
+ }
+ }
+
+ size_t whitespace = pm_heredoc_strspn_inline_whitespace(parser, &start, heredoc_lex_mode->indent);
+ if (
+ heredoc_lex_mode->indent == PM_HEREDOC_INDENT_TILDE &&
+ lex_mode->as.heredoc.common_whitespace != NULL &&
+ (*lex_mode->as.heredoc.common_whitespace > whitespace) &&
+ peek_at(parser, start) != '\n'
+ ) {
+ *lex_mode->as.heredoc.common_whitespace = whitespace;
+ }
+ }
+
+ // Otherwise we'll be parsing string content. These are the places
+ // where we need to split up the content of the heredoc. We'll use
+ // strpbrk to find the first of these characters.
+ uint8_t breakpoints[PM_STRPBRK_CACHE_SIZE] = "\r\n\\#";
+
+ pm_heredoc_quote_t quote = heredoc_lex_mode->quote;
+ if (quote == PM_HEREDOC_QUOTE_SINGLE) {
+ breakpoints[3] = '\0';
+ }
+
+ const uint8_t *breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ pm_token_buffer_t token_buffer = { 0 };
+ bool was_line_continuation = false;
+
+ while (breakpoint != NULL) {
+ switch (*breakpoint) {
+ case '\0':
+ // Skip directly past the null character.
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ case '\r':
+ parser->current.end = breakpoint + 1;
+
+ if (peek_at(parser, breakpoint + 1) != '\n') {
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+
+ // If we hit a \r\n sequence, then we want to replace it
+ // with a single \n character in the final string.
+ breakpoint++;
+ pm_token_buffer_escape(parser, &token_buffer);
+ token_buffer.cursor = breakpoint;
+
+ PRISM_FALLTHROUGH
+ case '\n': {
+ if (parser->heredoc_end != NULL && (parser->heredoc_end > breakpoint)) {
+ parser_flush_heredoc_end(parser);
+ parser->current.end = breakpoint + 1;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(breakpoint - parser->start + 1));
+
+ // If we have a - or ~ heredoc, then we can match after
+ // some leading whitespace.
+ const uint8_t *start = breakpoint + 1;
+
+ if (!was_line_continuation && (start + ident_length <= parser->end)) {
+ // We want to match the terminator starting from the end of the line in case
+ // there is whitespace in the ident such as <<-' DOC' or <<~' DOC'.
+ const uint8_t *newline = next_newline(start, parser->end - start);
+
+ if (newline == NULL) {
+ newline = parser->end;
+ } else if (newline[-1] == '\r') {
+ newline--; // Remove \r
+ }
+
+ // Start of a possible terminator.
+ const uint8_t *terminator_start = newline - ident_length;
+
+ // Cursor to check for the leading whitespace. We skip the
+ // leading whitespace if we have a - or ~ heredoc.
+ const uint8_t *cursor = start;
+
+ if (heredoc_lex_mode->indent == PM_HEREDOC_INDENT_DASH || heredoc_lex_mode->indent == PM_HEREDOC_INDENT_TILDE) {
+ while (cursor < terminator_start && pm_char_is_inline_whitespace(*cursor)) {
+ cursor++;
+ }
+ }
+
+ if (
+ cursor == terminator_start &&
+ (memcmp(terminator_start, ident_start, ident_length) == 0)
+ ) {
+ parser->current.end = breakpoint + 1;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+ }
+
+ size_t whitespace = pm_heredoc_strspn_inline_whitespace(parser, &start, lex_mode->as.heredoc.base.indent);
+
+ // If we have hit a newline that is followed by a valid
+ // terminator, then we need to return the content of the
+ // heredoc here as string content. Then, the next time a
+ // token is lexed, it will match again and return the
+ // end of the heredoc.
+ if (lex_mode->as.heredoc.base.indent == PM_HEREDOC_INDENT_TILDE) {
+ if ((lex_mode->as.heredoc.common_whitespace != NULL) && (*lex_mode->as.heredoc.common_whitespace > whitespace) && peek_at(parser, start) != '\n') {
+ *lex_mode->as.heredoc.common_whitespace = whitespace;
+ }
+
+ parser->current.end = breakpoint + 1;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // Otherwise we hit a newline and it wasn't followed by
+ // a terminator, so we can continue parsing.
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+ case '\\': {
+ // If we hit an escape, then we need to skip past
+ // however many characters the escape takes up. However
+ // it's important that if \n or \r\n are escaped, we
+ // stop looping before the newline and not after the
+ // newline so that we can still potentially find the
+ // terminator of the heredoc.
+ parser->current.end = breakpoint + 1;
+
+ // If we've hit the end of the file, then break out of
+ // the loop by setting the breakpoint to NULL.
+ if (parser->current.end == parser->end) {
+ breakpoint = NULL;
+ continue;
+ }
+
+ pm_token_buffer_escape(parser, &token_buffer);
+ uint8_t peeked = peek(parser);
+
+ if (quote == PM_HEREDOC_QUOTE_SINGLE) {
+ switch (peeked) {
+ case '\r':
+ parser->current.end++;
+ if (peek(parser) != '\n') {
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_byte(&token_buffer, '\r');
+ break;
+ }
+ PRISM_FALLTHROUGH
+ case '\n':
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_byte(&token_buffer, '\n');
+ token_buffer.cursor = parser->current.end + 1;
+ breakpoint = parser->current.end;
+ continue;
+ default:
+ pm_token_buffer_push_byte(&token_buffer, '\\');
+ pm_token_buffer_push_escaped(&token_buffer, parser);
+ break;
+ }
+ } else {
+ switch (peeked) {
+ case '\r':
+ parser->current.end++;
+ if (peek(parser) != '\n') {
+ pm_token_buffer_push_byte(&token_buffer, '\r');
+ break;
+ }
+ PRISM_FALLTHROUGH
+ case '\n':
+ // If we are in a tilde here, we should
+ // break out of the loop and return the
+ // string content.
+ if (heredoc_lex_mode->indent == PM_HEREDOC_INDENT_TILDE) {
+ const uint8_t *end = parser->current.end;
+
+ if (parser->heredoc_end == NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(end - parser->start + 1));
+ }
+
+ // Here we want the buffer to only
+ // include up to the backslash.
+ parser->current.end = breakpoint;
+ pm_token_buffer_flush(parser, &token_buffer);
+
+ // Now we can advance the end of the
+ // token past the newline.
+ parser->current.end = end + 1;
+ lex_mode->as.heredoc.line_continuation = true;
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ was_line_continuation = true;
+ token_buffer.cursor = parser->current.end + 1;
+ breakpoint = parser->current.end;
+ continue;
+ default:
+ escape_read(parser, &token_buffer.buffer, NULL, PM_ESCAPE_FLAG_NONE);
+ break;
+ }
+ }
+
+ token_buffer.cursor = parser->current.end;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+ case '#': {
+ pm_token_type_t type = lex_interpolation(parser, breakpoint);
+
+ if (!type) {
+ // If we haven't returned at this point then we had
+ // something that looked like an interpolated class
+ // or instance variable like "#@" but wasn't
+ // actually. In this case we'll just skip to the
+ // next breakpoint.
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, true);
+ break;
+ }
+
+ if (type == PM_TOKEN_STRING_CONTENT) {
+ pm_token_buffer_flush(parser, &token_buffer);
+ }
+
+ LEX(type);
+ }
+ default:
+ assert(false && "unreachable");
+ }
+
+ was_line_continuation = false;
+ }
+
+ if (parser->current.end > parser->current.start) {
+ parser->current.end = parser->end;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+
+ // If we've hit the end of the string, then this is an unterminated
+ // heredoc. In that case we'll return a string content token.
+ parser->current.end = parser->end;
+ pm_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
+ }
+ }
+
+ assert(false && "unreachable");
+}
+
+#undef LEX
+
+/******************************************************************************/
+/* Parse functions */
+/******************************************************************************/
+
+/**
+ * These are the various precedence rules. Because we are using a Pratt parser,
+ * they are named binding power to represent the manner in which nodes are bound
+ * together in the stack.
+ *
+ * We increment by 2 because we want to leave room for the infix operators to
+ * specify their associativity by adding or subtracting one.
+ */
+typedef enum {
+ PM_BINDING_POWER_UNSET = 0, // used to indicate this token cannot be used as an infix operator
+ PM_BINDING_POWER_STATEMENT = 2,
+ PM_BINDING_POWER_MODIFIER_RESCUE = 4, // rescue
+ PM_BINDING_POWER_MODIFIER = 6, // if unless until while
+ PM_BINDING_POWER_COMPOSITION = 8, // and or
+ PM_BINDING_POWER_NOT = 10, // not
+ PM_BINDING_POWER_MATCH = 12, // => in
+ PM_BINDING_POWER_DEFINED = 14, // defined?
+ PM_BINDING_POWER_MULTI_ASSIGNMENT = 16, // =
+ PM_BINDING_POWER_ASSIGNMENT = 18, // = += -= *= /= %= &= |= ^= &&= ||= <<= >>= **=
+ PM_BINDING_POWER_TERNARY = 20, // ?:
+ PM_BINDING_POWER_RANGE = 22, // .. ...
+ PM_BINDING_POWER_LOGICAL_OR = 24, // ||
+ PM_BINDING_POWER_LOGICAL_AND = 26, // &&
+ PM_BINDING_POWER_EQUALITY = 28, // <=> == === != =~ !~
+ PM_BINDING_POWER_COMPARISON = 30, // > >= < <=
+ PM_BINDING_POWER_BITWISE_OR = 32, // | ^
+ PM_BINDING_POWER_BITWISE_AND = 34, // &
+ PM_BINDING_POWER_SHIFT = 36, // << >>
+ PM_BINDING_POWER_TERM = 38, // + -
+ PM_BINDING_POWER_FACTOR = 40, // * / %
+ PM_BINDING_POWER_UMINUS = 42, // -@
+ PM_BINDING_POWER_EXPONENT = 44, // **
+ PM_BINDING_POWER_UNARY = 46, // ! ~ +@
+ PM_BINDING_POWER_INDEX = 48, // [] []=
+ PM_BINDING_POWER_CALL = 50, // :: .
+ PM_BINDING_POWER_MAX = 52
+} pm_binding_power_t;
+
+/**
+ * This struct represents a set of binding powers used for a given token. They
+ * are combined in this way to make it easier to represent associativity.
+ */
+typedef struct {
+ /** The left binding power. */
+ pm_binding_power_t left;
+
+ /** The right binding power. */
+ pm_binding_power_t right;
+
+ /** Whether or not this token can be used as a binary operator. */
+ bool binary;
+
+ /**
+ * Whether or not this token can be used as non-associative binary operator.
+ * Non-associative operators (e.g. in and =>) need special treatment in parse_expression.
+ */
+ bool nonassoc;
+} pm_binding_powers_t;
+
+#define BINDING_POWER_ASSIGNMENT { PM_BINDING_POWER_UNARY, PM_BINDING_POWER_ASSIGNMENT, true, false }
+#define LEFT_ASSOCIATIVE(precedence) { precedence, precedence + 1, true, false }
+#define RIGHT_ASSOCIATIVE(precedence) { precedence, precedence, true, false }
+#define NON_ASSOCIATIVE(precedence) { precedence, precedence + 1, true, true }
+#define RIGHT_ASSOCIATIVE_UNARY(precedence) { precedence, precedence, false, false }
+
+pm_binding_powers_t pm_binding_powers[PM_TOKEN_MAXIMUM] = {
+ // rescue
+ [PM_TOKEN_KEYWORD_RESCUE_MODIFIER] = { PM_BINDING_POWER_MODIFIER_RESCUE, PM_BINDING_POWER_COMPOSITION, true, false },
+
+ // if unless until while
+ [PM_TOKEN_KEYWORD_IF_MODIFIER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_MODIFIER),
+ [PM_TOKEN_KEYWORD_UNLESS_MODIFIER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_MODIFIER),
+ [PM_TOKEN_KEYWORD_UNTIL_MODIFIER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_MODIFIER),
+ [PM_TOKEN_KEYWORD_WHILE_MODIFIER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_MODIFIER),
+
+ // and or
+ [PM_TOKEN_KEYWORD_AND] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPOSITION),
+ [PM_TOKEN_KEYWORD_OR] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPOSITION),
+
+ // => in
+ [PM_TOKEN_EQUAL_GREATER] = NON_ASSOCIATIVE(PM_BINDING_POWER_MATCH),
+ [PM_TOKEN_KEYWORD_IN] = NON_ASSOCIATIVE(PM_BINDING_POWER_MATCH),
+
+ // &&= &= ^= = >>= <<= -= %= |= ||= += /= *= **=
+ [PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_AMPERSAND_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_CARET_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_GREATER_GREATER_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_LESS_LESS_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_MINUS_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_PERCENT_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_PIPE_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_PIPE_PIPE_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_PLUS_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_SLASH_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_STAR_EQUAL] = BINDING_POWER_ASSIGNMENT,
+ [PM_TOKEN_STAR_STAR_EQUAL] = BINDING_POWER_ASSIGNMENT,
+
+ // ?:
+ [PM_TOKEN_QUESTION_MARK] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_TERNARY),
+
+ // .. ...
+ [PM_TOKEN_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
+ [PM_TOKEN_DOT_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
+ [PM_TOKEN_UDOT_DOT] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_LOGICAL_OR),
+ [PM_TOKEN_UDOT_DOT_DOT] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_LOGICAL_OR),
+
+ // ||
+ [PM_TOKEN_PIPE_PIPE] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_LOGICAL_OR),
+
+ // &&
+ [PM_TOKEN_AMPERSAND_AMPERSAND] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_LOGICAL_AND),
+
+ // != !~ == === =~ <=>
+ [PM_TOKEN_BANG_EQUAL] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+ [PM_TOKEN_BANG_TILDE] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+ [PM_TOKEN_EQUAL_EQUAL] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+ [PM_TOKEN_EQUAL_EQUAL_EQUAL] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+ [PM_TOKEN_EQUAL_TILDE] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+ [PM_TOKEN_LESS_EQUAL_GREATER] = NON_ASSOCIATIVE(PM_BINDING_POWER_EQUALITY),
+
+ // > >= < <=
+ [PM_TOKEN_GREATER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPARISON),
+ [PM_TOKEN_GREATER_EQUAL] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPARISON),
+ [PM_TOKEN_LESS] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPARISON),
+ [PM_TOKEN_LESS_EQUAL] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_COMPARISON),
+
+ // ^ |
+ [PM_TOKEN_CARET] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_BITWISE_OR),
+ [PM_TOKEN_PIPE] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_BITWISE_OR),
+
+ // &
+ [PM_TOKEN_AMPERSAND] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_BITWISE_AND),
+
+ // >> <<
+ [PM_TOKEN_GREATER_GREATER] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_SHIFT),
+ [PM_TOKEN_LESS_LESS] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_SHIFT),
+
+ // - +
+ [PM_TOKEN_MINUS] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_TERM),
+ [PM_TOKEN_PLUS] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_TERM),
+
+ // % / *
+ [PM_TOKEN_PERCENT] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_FACTOR),
+ [PM_TOKEN_SLASH] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_FACTOR),
+ [PM_TOKEN_STAR] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_FACTOR),
+ [PM_TOKEN_USTAR] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_FACTOR),
+
+ // -@
+ [PM_TOKEN_UMINUS] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_UMINUS),
+ [PM_TOKEN_UMINUS_NUM] = { PM_BINDING_POWER_UMINUS, PM_BINDING_POWER_MAX, false, false },
+
+ // **
+ [PM_TOKEN_STAR_STAR] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_EXPONENT),
+ [PM_TOKEN_USTAR_STAR] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_UNARY),
+
+ // ! ~ +@
+ [PM_TOKEN_BANG] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_UNARY),
+ [PM_TOKEN_TILDE] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_UNARY),
+ [PM_TOKEN_UPLUS] = RIGHT_ASSOCIATIVE_UNARY(PM_BINDING_POWER_UNARY),
+
+ // [
+ [PM_TOKEN_BRACKET_LEFT] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_INDEX),
+
+ // :: . &.
+ [PM_TOKEN_COLON_COLON] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_CALL),
+ [PM_TOKEN_DOT] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_CALL),
+ [PM_TOKEN_AMPERSAND_DOT] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_CALL)
+};
+
+#undef BINDING_POWER_ASSIGNMENT
+#undef LEFT_ASSOCIATIVE
+#undef RIGHT_ASSOCIATIVE
+#undef RIGHT_ASSOCIATIVE_UNARY
+
+/**
+ * Returns true if the current token is of the given type.
+ */
+static PRISM_INLINE bool
+match1(const pm_parser_t *parser, pm_token_type_t type) {
+ return parser->current.type == type;
+}
+
+/**
+ * Returns true if the current token is of either of the given types.
+ */
+static PRISM_INLINE bool
+match2(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2) {
+ return match1(parser, type1) || match1(parser, type2);
+}
+
+/**
+ * Returns true if the current token is any of the three given types.
+ */
+static PRISM_INLINE bool
+match3(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3) {
+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3);
+}
+
+/**
+ * Returns true if the current token is any of the four given types.
+ */
+static PRISM_INLINE bool
+match4(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4) {
+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4);
+}
+
+/**
+ * Returns true if the current token is any of the six given types.
+ */
+static PRISM_INLINE bool
+match6(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4, pm_token_type_t type5, pm_token_type_t type6) {
+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4) || match1(parser, type5) || match1(parser, type6);
+}
+
+/**
+ * Returns true if the current token is any of the seven given types.
+ */
+static PRISM_INLINE bool
+match7(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4, pm_token_type_t type5, pm_token_type_t type6, pm_token_type_t type7) {
+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4) || match1(parser, type5) || match1(parser, type6) || match1(parser, type7);
+}
+
+/**
+ * Returns true if the current token is any of the eight given types.
+ */
+static PRISM_INLINE bool
+match8(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4, pm_token_type_t type5, pm_token_type_t type6, pm_token_type_t type7, pm_token_type_t type8) {
+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4) || match1(parser, type5) || match1(parser, type6) || match1(parser, type7) || match1(parser, type8);
+}
+
+/**
+ * If the current token is of the specified type, lex forward by one token and
+ * return true. Otherwise, return false. For example:
+ *
+ * if (accept1(parser, PM_TOKEN_COLON)) { ... }
+ */
+static bool
+accept1(pm_parser_t *parser, pm_token_type_t type) {
+ if (match1(parser, type)) {
+ parser_lex(parser);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * If the current token is either of the two given types, lex forward by one
+ * token and return true. Otherwise return false.
+ */
+static PRISM_INLINE bool
+accept2(pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2) {
+ if (match2(parser, type1, type2)) {
+ parser_lex(parser);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * This function indicates that the parser expects a token in a specific
+ * position. For example, if you're parsing a BEGIN block, you know that a { is
+ * expected immediately after the keyword. In that case you would call this
+ * function to indicate that that token should be found.
+ *
+ * If we didn't find the token that we were expecting, then we're going to add
+ * an error to the parser's list of errors (to indicate that the tree is not
+ * valid) and create an artificial token instead. This allows us to recover from
+ * the fact that the token isn't present and continue parsing.
+ */
+static void
+expect1(pm_parser_t *parser, pm_token_type_t type, pm_diagnostic_id_t diag_id) {
+ if (accept1(parser, type)) return;
+
+ const uint8_t *location = parser->previous.end;
+ pm_parser_err(parser, U32(location - parser->start), 0, diag_id);
+
+ parser->previous.start = location;
+ parser->previous.type = 0;
+}
+
+/**
+ * This function is the same as expect1, but it expects either of two token
+ * types.
+ */
+static void
+expect2(pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_diagnostic_id_t diag_id) {
+ if (accept2(parser, type1, type2)) return;
+
+ const uint8_t *location = parser->previous.end;
+ pm_parser_err(parser, U32(location - parser->start), 0, diag_id);
+
+ parser->previous.start = location;
+ parser->previous.type = 0;
+}
+
+/**
+ * A special expect1 that expects a heredoc terminator and handles popping the
+ * lex mode accordingly.
+ */
+static void
+expect1_heredoc_term(pm_parser_t *parser, const uint8_t *ident_start, size_t ident_length) {
+ if (match1(parser, PM_TOKEN_HEREDOC_END)) {
+ parser_lex(parser);
+ } else {
+ pm_parser_err_heredoc_term(parser, ident_start, ident_length);
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+}
+
+/**
+ * A special expect1 that attaches the error to the opening token location
+ * rather than the current position. This is useful for errors about missing
+ * closing tokens, where we want to point to the line with the opening token
+ * (e.g., `def`, `class`, `if`, `{`) rather than the end of the file.
+ */
+static void
+expect1_opening(pm_parser_t *parser, pm_token_type_t type, pm_diagnostic_id_t diag_id, const pm_token_t *opening) {
+ if (accept1(parser, type)) return;
+
+ const uint8_t *start = opening->start;
+ pm_parser_err(parser, U32(start - parser->start), U32(opening->end - start), diag_id);
+
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+}
+
+/** Flags for controlling expression parsing behavior. */
+#define PM_PARSE_ACCEPTS_COMMAND_CALL ((uint8_t) 0x1)
+#define PM_PARSE_ACCEPTS_LABEL ((uint8_t) 0x2)
+#define PM_PARSE_ACCEPTS_DO_BLOCK ((uint8_t) 0x4)
+#define PM_PARSE_IN_ENDLESS_DEF ((uint8_t) 0x8)
+
+static pm_node_t *
+parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth);
+
+/**
+ * This is a wrapper of parse_expression, which also checks whether the
+ * resulting node is a value expression.
+ */
+static pm_node_t *
+parse_value_expression(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ pm_node_t *node = parse_expression(parser, binding_power, flags, diag_id, depth);
+ pm_assert_value_expression(parser, node);
+ return node;
+}
+
+/**
+ * This function controls whether or not we will attempt to parse an expression
+ * beginning at the subsequent token. It is used when we are in a context where
+ * an expression is optional.
+ *
+ * For example, looking at a range object when we've already lexed the operator,
+ * we need to know if we should attempt to parse an expression on the right.
+ *
+ * For another example, if we've parsed an identifier or a method call and we do
+ * not have parentheses, then the next token may be the start of an argument or
+ * it may not.
+ *
+ * CRuby parsers that are generated would resolve this by using a lookahead and
+ * potentially backtracking. We attempt to do this by just looking at the next
+ * token and making a decision based on that. I am not sure if this is going to
+ * work in all cases, it may need to be refactored later. But it appears to work
+ * for now.
+ */
+static PRISM_INLINE bool
+token_begins_expression_p(pm_token_type_t type) {
+ switch (type) {
+ case PM_TOKEN_EQUAL_GREATER:
+ case PM_TOKEN_KEYWORD_IN:
+ // We need to special case this because it is a binary operator that
+ // should not be marked as beginning an expression.
+ return false;
+ case PM_TOKEN_BRACE_RIGHT:
+ case PM_TOKEN_BRACKET_RIGHT:
+ case PM_TOKEN_COLON:
+ case PM_TOKEN_COMMA:
+ case PM_TOKEN_EMBEXPR_END:
+ case PM_TOKEN_EOF:
+ case PM_TOKEN_LAMBDA_BEGIN:
+ case PM_TOKEN_KEYWORD_DO:
+ case PM_TOKEN_KEYWORD_DO_BLOCK:
+ case PM_TOKEN_KEYWORD_DO_LOOP:
+ case PM_TOKEN_KEYWORD_END:
+ case PM_TOKEN_KEYWORD_ELSE:
+ case PM_TOKEN_KEYWORD_ELSIF:
+ case PM_TOKEN_KEYWORD_ENSURE:
+ case PM_TOKEN_KEYWORD_THEN:
+ case PM_TOKEN_KEYWORD_RESCUE:
+ case PM_TOKEN_KEYWORD_WHEN:
+ case PM_TOKEN_NEWLINE:
+ case PM_TOKEN_PARENTHESIS_RIGHT:
+ case PM_TOKEN_SEMICOLON:
+ // The reason we need this short-circuit is because we're using the
+ // binding powers table to tell us if the subsequent token could
+ // potentially be the start of an expression. If there _is_ a binding
+ // power for one of these tokens, then we should remove it from this list
+ // and let it be handled by the default case below.
+ assert(pm_binding_powers[type].left == PM_BINDING_POWER_UNSET);
+ return false;
+ case PM_TOKEN_UAMPERSAND:
+ // This is a special case because this unary operator cannot appear
+ // as a general operator, it only appears in certain circumstances.
+ return false;
+ case PM_TOKEN_UCOLON_COLON:
+ case PM_TOKEN_UMINUS:
+ case PM_TOKEN_UMINUS_NUM:
+ case PM_TOKEN_UPLUS:
+ case PM_TOKEN_BANG:
+ case PM_TOKEN_TILDE:
+ case PM_TOKEN_UDOT_DOT:
+ case PM_TOKEN_UDOT_DOT_DOT:
+ // These unary tokens actually do have binding power associated with them
+ // so that we can correctly place them into the precedence order. But we
+ // want them to be marked as beginning an expression, so we need to
+ // special case them here.
+ return true;
+ default:
+ return pm_binding_powers[type].left == PM_BINDING_POWER_UNSET;
+ }
+}
+
+/**
+ * Parse an expression with the given binding power that may be optionally
+ * prefixed by the * operator.
+ */
+static pm_node_t *
+parse_starred_expression(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ pm_token_t operator = parser->previous;
+ pm_node_t *expression = parse_value_expression(parser, binding_power, (uint8_t) (flags & PM_PARSE_ACCEPTS_DO_BLOCK), PM_ERR_EXPECT_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+ return UP(pm_splat_node_create(parser, &operator, expression));
+ }
+
+ return parse_value_expression(parser, binding_power, flags, diag_id, depth);
+}
+
+static bool
+pm_node_unreference_each(const pm_node_t *node, void *data) {
+ switch (PM_NODE_TYPE(node)) {
+ /* When we are about to destroy a set of nodes that could potentially
+ * contain block exits for the current scope, we need to check if they
+ * are contained in the list of block exits and remove them if they are.
+ */
+ case PM_BREAK_NODE:
+ case PM_NEXT_NODE:
+ case PM_REDO_NODE: {
+ pm_parser_t *parser = (pm_parser_t *) data;
+ size_t index = 0;
+
+ while (index < parser->current_block_exits->size) {
+ pm_node_t *block_exit = parser->current_block_exits->nodes[index];
+
+ if (block_exit == node) {
+ if (index + 1 < parser->current_block_exits->size) {
+ memmove(
+ &parser->current_block_exits->nodes[index],
+ &parser->current_block_exits->nodes[index + 1],
+ (parser->current_block_exits->size - index - 1) * sizeof(pm_node_t *)
+ );
+ }
+ parser->current_block_exits->size--;
+
+ /* Note returning true here because these nodes could have
+ * arguments that are themselves block exits. */
+ return true;
+ }
+
+ index++;
+ }
+
+ return true;
+ }
+ /* When an implicit local variable is written to or targeted, it becomes
+ * a regular, named local variable. This branch removes it from the list
+ * of implicit parameters when that happens. */
+ case PM_LOCAL_VARIABLE_READ_NODE:
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_parser_t *parser = (pm_parser_t *) data;
+ pm_node_list_t *implicit_parameters = &parser->current_scope->implicit_parameters;
+
+ for (size_t index = 0; index < implicit_parameters->size; index++) {
+ if (implicit_parameters->nodes[index] == node) {
+ /* If the node is not the last one in the list, we need to
+ * shift the remaining nodes down to fill the gap. This is
+ * extremely unlikely to happen. */
+ if (index != implicit_parameters->size - 1) {
+ memmove(&implicit_parameters->nodes[index], &implicit_parameters->nodes[index + 1], (implicit_parameters->size - index - 1) * sizeof(pm_node_t *));
+ }
+
+ implicit_parameters->size--;
+ break;
+ }
+ }
+
+ return false;
+ }
+ default:
+ return true;
+ }
+}
+
+/**
+ * When we are about to destroy a set of nodes that could potentially be
+ * referenced by one or more lists on the parser, then remove them from those
+ * lists so we don't get a use-after-free.
+ */
+static void
+pm_node_unreference(pm_parser_t *parser, const pm_node_t *node) {
+ pm_visit_node(node, pm_node_unreference_each, parser);
+}
+
+/**
+ * Convert the name of a method into the corresponding write method name. For
+ * example, foo would be turned into foo=.
+ */
+static void
+parse_write_name(pm_parser_t *parser, pm_constant_id_t *name_field) {
+ // The method name needs to change. If we previously had
+ // foo, we now need foo=. In this case we'll allocate a new
+ // owned string, copy the previous method name in, and
+ // append an =.
+ pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, *name_field);
+ size_t length = constant->length;
+ uint8_t *name = (uint8_t *) pm_arena_alloc(parser->arena, length + 1, 1);
+
+ memcpy(name, constant->start, length);
+ name[length] = '=';
+
+ *name_field = pm_constant_pool_insert_owned(&parser->metadata_arena, &parser->constant_pool, name, length + 1);
+}
+
+/**
+ * Certain expressions are not targetable, but in order to provide a better
+ * experience we give a specific error message. In order to maintain as much
+ * information in the tree as possible, we replace them with local variable
+ * writes.
+ */
+static pm_node_t *
+parse_unwriteable_target(pm_parser_t *parser, pm_node_t *target) {
+ switch (PM_NODE_TYPE(target)) {
+ case PM_SOURCE_ENCODING_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING); break;
+ case PM_FALSE_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE); break;
+ case PM_SOURCE_FILE_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_FILE); break;
+ case PM_SOURCE_LINE_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_LINE); break;
+ case PM_NIL_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_NIL); break;
+ case PM_SELF_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_SELF); break;
+ case PM_TRUE_NODE: pm_parser_err_node(parser, target, PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE); break;
+ default: break;
+ }
+
+ pm_constant_id_t name = pm_parser_constant_id_raw(parser, parser->start + PM_NODE_START(target), parser->start + PM_NODE_END(target));
+ pm_local_variable_target_node_t *result = pm_local_variable_target_node_create(parser, &target->location, name, 0);
+
+ return UP(result);
+}
+
+/**
+ * Convert the given node into a valid target node.
+ *
+ * @param multiple Whether or not this target is part of a larger set of
+ * targets. If it is, then the &. operator is not allowed.
+ * @param splat Whether or not this target is a child of a splat target. If it
+ * is, then fewer patterns are allowed.
+ */
+static pm_node_t *
+parse_target(pm_parser_t *parser, pm_node_t *target, bool multiple, bool splat_parent) {
+ switch (PM_NODE_TYPE(target)) {
+ case PM_ERROR_RECOVERY_NODE:
+ return target;
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_FALSE_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_NIL_NODE:
+ case PM_SELF_NODE:
+ case PM_TRUE_NODE: {
+ // In these special cases, we have specific error messages and we
+ // will replace them with local variable writes.
+ return parse_unwriteable_target(parser, target);
+ }
+ case PM_CLASS_VARIABLE_READ_NODE:
+ assert(sizeof(pm_class_variable_target_node_t) == sizeof(pm_class_variable_read_node_t));
+ target->type = PM_CLASS_VARIABLE_TARGET_NODE;
+ return target;
+ case PM_CONSTANT_PATH_NODE:
+ if (context_def_p(parser)) {
+ pm_parser_err_node(parser, target, PM_ERR_WRITE_TARGET_IN_METHOD);
+ }
+
+ assert(sizeof(pm_constant_path_target_node_t) == sizeof(pm_constant_path_node_t));
+ target->type = PM_CONSTANT_PATH_TARGET_NODE;
+
+ return target;
+ case PM_CONSTANT_READ_NODE:
+ if (context_def_p(parser)) {
+ pm_parser_err_node(parser, target, PM_ERR_WRITE_TARGET_IN_METHOD);
+ }
+
+ assert(sizeof(pm_constant_target_node_t) == sizeof(pm_constant_read_node_t));
+ target->type = PM_CONSTANT_TARGET_NODE;
+
+ return target;
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser, target, PM_ERR_WRITE_TARGET_READONLY);
+ return UP(pm_error_recovery_node_create_unexpected(parser, target));
+ case PM_GLOBAL_VARIABLE_READ_NODE:
+ assert(sizeof(pm_global_variable_target_node_t) == sizeof(pm_global_variable_read_node_t));
+ target->type = PM_GLOBAL_VARIABLE_TARGET_NODE;
+ return target;
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ if (pm_token_is_numbered_parameter(parser, PM_NODE_START(target), PM_NODE_LENGTH(target))) {
+ PM_PARSER_ERR_FORMAT(parser, PM_NODE_START(target), PM_NODE_LENGTH(target), PM_ERR_PARAMETER_NUMBERED_RESERVED, parser->start + PM_NODE_START(target));
+ pm_node_unreference(parser, target);
+ }
+
+ const pm_local_variable_read_node_t *cast = (const pm_local_variable_read_node_t *) target;
+ uint32_t name = cast->name;
+ uint32_t depth = cast->depth;
+ pm_locals_unread(&pm_parser_scope_find(parser, depth)->locals, name);
+
+ assert(sizeof(pm_local_variable_target_node_t) == sizeof(pm_local_variable_read_node_t));
+ target->type = PM_LOCAL_VARIABLE_TARGET_NODE;
+
+ return target;
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
+ pm_node_t *node = UP(pm_local_variable_target_node_create(parser, &target->location, name, 0));
+
+ pm_node_unreference(parser, target);
+
+ return node;
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE:
+ assert(sizeof(pm_instance_variable_target_node_t) == sizeof(pm_instance_variable_read_node_t));
+ target->type = PM_INSTANCE_VARIABLE_TARGET_NODE;
+ return target;
+ case PM_MULTI_TARGET_NODE:
+ if (splat_parent) {
+ // Multi target is not accepted in all positions. If this is one
+ // of them, then we need to add an error.
+ pm_parser_err_node(parser, target, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ return target;
+ case PM_SPLAT_NODE: {
+ pm_splat_node_t *splat = (pm_splat_node_t *) target;
+
+ if (splat->expression != NULL) {
+ splat->expression = parse_target(parser, splat->expression, multiple, true);
+ }
+
+ return UP(splat);
+ }
+ case PM_CALL_NODE: {
+ pm_call_node_t *call = (pm_call_node_t *) target;
+
+ // If we have no arguments to the call node and we need this to be a
+ // target then this is either a method call or a local variable
+ // write.
+ if (
+ (call->message_loc.length > 0) &&
+ (parser->start[call->message_loc.start + call->message_loc.length - 1] != '!') &&
+ (parser->start[call->message_loc.start + call->message_loc.length - 1] != '?') &&
+ (call->opening_loc.length == 0) &&
+ (call->arguments == NULL) &&
+ (call->block == NULL)
+ ) {
+ if (call->receiver == NULL) {
+ // When we get here, we have a local variable write, because it
+ // was previously marked as a method call but now we have an =.
+ // This looks like:
+ //
+ // foo = 1
+ //
+ // When it was parsed in the prefix position, foo was seen as a
+ // method call with no receiver and no arguments. Now we have an
+ // =, so we know it's a local variable write.
+ pm_location_t message_loc = call->message_loc;
+ pm_constant_id_t name = pm_parser_local_add_location(parser, &message_loc, 0);
+
+ return UP(pm_local_variable_target_node_create(parser, &message_loc, name, 0));
+ }
+
+ if (peek_at(parser, parser->start + call->message_loc.start) == '_' || parser->encoding->alnum_char(parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length)) {
+ if (multiple && PM_NODE_FLAG_P(call, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) {
+ pm_parser_err_node(parser, (const pm_node_t *) call, PM_ERR_UNEXPECTED_SAFE_NAVIGATION);
+ }
+
+ parse_write_name(parser, &call->name);
+ return UP(pm_call_target_node_create(parser, call));
+ }
+ }
+
+ // If there is no call operator and the message is "[]" then this is
+ // an aref expression, and we can transform it into an aset
+ // expression.
+ if (PM_NODE_FLAG_P(call, PM_CALL_NODE_FLAGS_INDEX)) {
+ return UP(pm_index_target_node_create(parser, call));
+ }
+ }
+ PRISM_FALLTHROUGH
+ default:
+ // In this case we have a node that we don't know how to convert
+ // into a target. We need to treat it as an error. For now, we'll
+ // mark it as an error and just skip right past it.
+ pm_parser_err_node(parser, target, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ return target;
+ }
+}
+
+/**
+ * Parse a write target and validate that it is in a valid position for
+ * assignment.
+ */
+static pm_node_t *
+parse_target_validate(pm_parser_t *parser, pm_node_t *target, bool multiple) {
+ pm_node_t *result = parse_target(parser, target, multiple, false);
+
+ // Ensure that we have one of an =, an 'in' in for indexes, and a ')' in
+ // parens after the targets.
+ if (
+ !match1(parser, PM_TOKEN_EQUAL) &&
+ !(context_p(parser, PM_CONTEXT_FOR_INDEX) && match1(parser, PM_TOKEN_KEYWORD_IN)) &&
+ !(context_p(parser, PM_CONTEXT_PARENS) && match1(parser, PM_TOKEN_PARENTHESIS_RIGHT))
+ ) {
+ pm_parser_err_node(parser, result, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ return result;
+}
+
+/**
+ * Potentially wrap a constant write node in a shareable constant node depending
+ * on the current state.
+ */
+static pm_node_t *
+parse_shareable_constant_write(pm_parser_t *parser, pm_node_t *write) {
+ pm_shareable_constant_value_t shareable_constant = pm_parser_scope_shareable_constant_get(parser);
+
+ if (shareable_constant != PM_SCOPE_SHAREABLE_CONSTANT_NONE) {
+ return UP(pm_shareable_constant_node_create(parser, write, shareable_constant));
+ }
+
+ return write;
+}
+
+/**
+ * Convert the given node into a valid write node.
+ */
+static pm_node_t *
+parse_write(pm_parser_t *parser, pm_node_t *target, pm_token_t *operator, pm_node_t *value) {
+ switch (PM_NODE_TYPE(target)) {
+ case PM_ERROR_RECOVERY_NODE:
+ return target;
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ pm_class_variable_write_node_t *node = pm_class_variable_write_node_create(parser, (pm_class_variable_read_node_t *) target, operator, value);
+ return UP(node);
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ pm_node_t *node = UP(pm_constant_path_write_node_create(parser, (pm_constant_path_node_t *) target, operator, value));
+
+ if (context_def_p(parser)) {
+ pm_parser_err_node(parser, node, PM_ERR_WRITE_TARGET_IN_METHOD);
+ }
+
+ return parse_shareable_constant_write(parser, node);
+ }
+ case PM_CONSTANT_READ_NODE: {
+ pm_node_t *node = UP(pm_constant_write_node_create(parser, (pm_constant_read_node_t *) target, operator, value));
+
+ if (context_def_p(parser)) {
+ pm_parser_err_node(parser, node, PM_ERR_WRITE_TARGET_IN_METHOD);
+ }
+
+ return parse_shareable_constant_write(parser, node);
+ }
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser, target, PM_ERR_WRITE_TARGET_READONLY);
+ PRISM_FALLTHROUGH
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ pm_global_variable_write_node_t *node = pm_global_variable_write_node_create(parser, target, operator, value);
+ return UP(node);
+ }
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ pm_local_variable_read_node_t *local_read = (pm_local_variable_read_node_t *) target;
+
+ pm_location_t location = target->location;
+ pm_constant_id_t name = local_read->name;
+ uint32_t depth = local_read->depth;
+ pm_scope_t *scope = pm_parser_scope_find(parser, depth);
+
+ if (pm_token_is_numbered_parameter(parser, PM_NODE_START(target), PM_NODE_LENGTH(target))) {
+ pm_diagnostic_id_t diag_id = (scope->parameters & PM_SCOPE_PARAMETERS_NUMBERED_FOUND) ? PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED : PM_ERR_PARAMETER_NUMBERED_RESERVED;
+ PM_PARSER_ERR_FORMAT(parser, PM_NODE_START(target), PM_NODE_LENGTH(target), diag_id, parser->start + PM_NODE_START(target));
+ pm_node_unreference(parser, target);
+ }
+
+ pm_locals_unread(&scope->locals, name);
+
+ return UP(pm_local_variable_write_node_create(parser, name, depth, value, &location, operator));
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
+ pm_node_t *node = UP(pm_local_variable_write_node_create(parser, name, 0, value, &target->location, operator));
+
+ pm_node_unreference(parser, target);
+
+ return node;
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ pm_node_t *write_node = UP(pm_instance_variable_write_node_create(parser, (pm_instance_variable_read_node_t *) target, operator, value));
+ return write_node;
+ }
+ case PM_MULTI_TARGET_NODE:
+ return UP(pm_multi_write_node_create(parser, (pm_multi_target_node_t *) target, operator, value));
+ case PM_SPLAT_NODE: {
+ pm_splat_node_t *splat = (pm_splat_node_t *) target;
+
+ if (splat->expression != NULL) {
+ splat->expression = parse_write(parser, splat->expression, operator, value);
+ }
+
+ pm_multi_target_node_t *multi_target = pm_multi_target_node_create(parser);
+ pm_multi_target_node_targets_append(parser, multi_target, UP(splat));
+
+ return UP(pm_multi_write_node_create(parser, multi_target, operator, value));
+ }
+ case PM_CALL_NODE: {
+ pm_call_node_t *call = (pm_call_node_t *) target;
+
+ // If we have no arguments to the call node and we need this to be a
+ // target then this is either a method call or a local variable
+ // write.
+ if (
+ (call->message_loc.length > 0) &&
+ (parser->start[call->message_loc.start + call->message_loc.length - 1] != '!') &&
+ (parser->start[call->message_loc.start + call->message_loc.length - 1] != '?') &&
+ (call->opening_loc.length == 0) &&
+ (call->arguments == NULL) &&
+ (call->block == NULL)
+ ) {
+ if (call->receiver == NULL) {
+ // When we get here, we have a local variable write, because it
+ // was previously marked as a method call but now we have an =.
+ // This looks like:
+ //
+ // foo = 1
+ //
+ // When it was parsed in the prefix position, foo was seen as a
+ // method call with no receiver and no arguments. Now we have an
+ // =, so we know it's a local variable write.
+ pm_location_t message_loc = call->message_loc;
+
+ pm_refute_numbered_parameter(parser, message_loc.start, message_loc.length);
+ pm_parser_local_add_location(parser, &message_loc, 0);
+
+ pm_constant_id_t constant_id = pm_parser_constant_id_raw(parser, parser->start + PM_LOCATION_START(&message_loc), parser->start + PM_LOCATION_END(&message_loc));
+ target = UP(pm_local_variable_write_node_create(parser, constant_id, 0, value, &message_loc, operator));
+
+ return target;
+ }
+
+ if (char_is_identifier_start(parser, parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length)) {
+ // When we get here, we have a method call, because it was
+ // previously marked as a method call but now we have an =. This
+ // looks like:
+ //
+ // foo.bar = 1
+ //
+ // When it was parsed in the prefix position, foo.bar was seen as a
+ // method call with no arguments. Now we have an =, so we know it's
+ // a method call with an argument. In this case we will create the
+ // arguments node, parse the argument, and add it to the list.
+ pm_arguments_node_t *arguments = pm_arguments_node_create(parser);
+ call->arguments = arguments;
+
+ pm_arguments_node_arguments_append(parser->arena, arguments, value);
+ PM_NODE_LENGTH_SET_NODE(call, arguments);
+ call->equal_loc = TOK2LOC(parser, operator);
+
+ parse_write_name(parser, &call->name);
+ pm_node_flag_set(UP(call), PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE | pm_implicit_array_write_flags(value, PM_CALL_NODE_FLAGS_IMPLICIT_ARRAY));
+
+ return UP(call);
+ }
+ }
+
+ // If there is no call operator and the message is "[]" then this is
+ // an aref expression, and we can transform it into an aset
+ // expression.
+ if (PM_NODE_FLAG_P(call, PM_CALL_NODE_FLAGS_INDEX)) {
+ if (call->arguments == NULL) {
+ call->arguments = pm_arguments_node_create(parser);
+ }
+
+ pm_arguments_node_arguments_append(parser->arena, call->arguments, value);
+ PM_NODE_LENGTH_SET_NODE(target, value);
+
+ // Replace the name with "[]=".
+ call->name = pm_parser_constant_id_constant(parser, "[]=", 3);
+ call->equal_loc = TOK2LOC(parser, operator);
+
+ // Ensure that the arguments for []= don't contain keywords
+ pm_index_arguments_check(parser, call->arguments, call->block);
+ pm_node_flag_set(UP(call), PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE | pm_implicit_array_write_flags(value, PM_CALL_NODE_FLAGS_IMPLICIT_ARRAY));
+
+ return target;
+ }
+
+ // If there are arguments on the call node, then it can't be a
+ // method call ending with = or a local variable write, so it must
+ // be a syntax error. In this case we'll fall through to our default
+ // handling. We need to free the value that we parsed because there
+ // is no way for us to attach it to the tree at this point.
+ //
+ // Since it is possible for the value to contain an implicit
+ // parameter somewhere in its subtree, we need to walk it and remove
+ // any implicit parameters from the list of implicit parameters for
+ // the current scope.
+ pm_node_unreference(parser, value);
+ }
+ PRISM_FALLTHROUGH
+ default:
+ // In this case we have a node that we don't know how to convert into a
+ // target. We need to treat it as an error. For now, we'll mark it as an
+ // error and just skip right past it.
+ pm_parser_err_token(parser, operator, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ return target;
+ }
+}
+
+/**
+ * Certain expressions are not writable, but in order to provide a better
+ * experience we give a specific error message. In order to maintain as much
+ * information in the tree as possible, we replace them with local variable
+ * writes.
+ */
+static pm_node_t *
+parse_unwriteable_write(pm_parser_t *parser, pm_node_t *target, const pm_token_t *equals, pm_node_t *value) {
+ switch (PM_NODE_TYPE(target)) {
+ case PM_SOURCE_ENCODING_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING); break;
+ case PM_FALSE_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE); break;
+ case PM_SOURCE_FILE_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_FILE); break;
+ case PM_SOURCE_LINE_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_LINE); break;
+ case PM_NIL_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_NIL); break;
+ case PM_SELF_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_SELF); break;
+ case PM_TRUE_NODE: pm_parser_err_token(parser, equals, PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE); break;
+ default: break;
+ }
+
+ pm_constant_id_t name = pm_parser_local_add_location(parser, &target->location, 1);
+ pm_local_variable_write_node_t *result = pm_local_variable_write_node_create(parser, name, 0, value, &target->location, equals);
+
+ return UP(result);
+}
+
+/**
+ * Parse a list of targets for assignment. This is used in the case of a for
+ * loop or a multi-assignment. For example, in the following code:
+ *
+ * for foo, bar in baz
+ * ^^^^^^^^
+ *
+ * The targets are `foo` and `bar`. This function will either return a single
+ * target node or a multi-target node.
+ */
+static pm_node_t *
+parse_targets(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t binding_power, uint16_t depth) {
+ bool has_rest = PM_NODE_TYPE_P(first_target, PM_SPLAT_NODE);
+
+ pm_multi_target_node_t *result = pm_multi_target_node_create(parser);
+ pm_multi_target_node_targets_append(parser, result, parse_target(parser, first_target, true, false));
+
+ while (accept1(parser, PM_TOKEN_COMMA)) {
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ // Here we have a splat operator. It can have a name or be
+ // anonymous. It can be the final target or be in the middle if
+ // there haven't been any others yet.
+ if (has_rest) {
+ pm_parser_err_previous(parser, PM_ERR_MULTI_ASSIGN_MULTI_SPLATS);
+ }
+
+ pm_token_t star_operator = parser->previous;
+ pm_node_t *name = NULL;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ name = parse_expression(parser, binding_power, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+ name = parse_target(parser, name, true, true);
+ }
+
+ pm_node_t *splat = UP(pm_splat_node_create(parser, &star_operator, name));
+ pm_multi_target_node_targets_append(parser, result, splat);
+ has_rest = true;
+ } else if (match1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ context_push(parser, PM_CONTEXT_MULTI_TARGET);
+ pm_node_t *target = parse_expression(parser, binding_power, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA, (uint16_t) (depth + 1));
+ target = parse_target(parser, target, true, false);
+
+ pm_multi_target_node_targets_append(parser, result, target);
+ context_pop(parser);
+ } else if (token_begins_expression_p(parser->current.type)) {
+ pm_node_t *target = parse_expression(parser, binding_power, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA, (uint16_t) (depth + 1));
+ target = parse_target(parser, target, true, false);
+
+ pm_multi_target_node_targets_append(parser, result, target);
+ } else if (!match1(parser, PM_TOKEN_EOF)) {
+ // If we get here, then we have a trailing , in a multi target node.
+ // We'll add an implicit rest node to represent this.
+ pm_node_t *rest = UP(pm_implicit_rest_node_create(parser, &parser->previous));
+ pm_multi_target_node_targets_append(parser, result, rest);
+ break;
+ }
+ }
+
+ return UP(result);
+}
+
+/**
+ * Parse a list of targets and validate that it is in a valid position for
+ * assignment.
+ */
+static pm_node_t *
+parse_targets_validate(pm_parser_t *parser, pm_node_t *first_target, pm_binding_power_t binding_power, uint16_t depth) {
+ pm_node_t *result = parse_targets(parser, first_target, binding_power, depth);
+
+ // If we're inside parentheses, then we allow a newline before the
+ // closing parenthesis or equals sign. Outside of parentheses, a newline
+ // is not allowed (e.g., `a, b\n= 1, 2` is not valid).
+ if (context_p(parser, PM_CONTEXT_PARENS) || context_p(parser, PM_CONTEXT_MULTI_TARGET)) {
+ accept1(parser, PM_TOKEN_NEWLINE);
+ }
+
+ // Ensure that we have either an = or a ) after the targets.
+ if (!match2(parser, PM_TOKEN_EQUAL, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ pm_parser_err_node(parser, result, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ return result;
+}
+
+/**
+ * Parse a list of statements separated by newlines or semicolons.
+ */
+static pm_statements_node_t *
+parse_statements(pm_parser_t *parser, pm_context_t context, uint16_t depth) {
+ // First, skip past any optional terminators that might be at the beginning
+ // of the statements.
+ while (accept2(parser, PM_TOKEN_SEMICOLON, PM_TOKEN_NEWLINE));
+
+ // If we have a terminator, then we can just return NULL.
+ if (context_terminator(context, &parser->current)) return NULL;
+
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+
+ // At this point we know we have at least one statement, and that it
+ // immediately follows the current token.
+ context_push(parser, context);
+
+ while (true) {
+ pm_node_t *node = parse_expression(parser, PM_BINDING_POWER_STATEMENT, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_CANNOT_PARSE_EXPRESSION, (uint16_t) (depth + 1));
+ pm_statements_node_body_append(parser, statements, node, true);
+
+ // If we're recovering from a syntax error, then we need to stop parsing
+ // the statements now.
+ if (parser->recovering) {
+ // If this is the level of context where the recovery has happened,
+ // then we can mark the parser as done recovering.
+ if (context_terminator(context, &parser->current)) parser->recovering = false;
+ break;
+ }
+
+ // If we have a terminator, then we will parse all consecutive
+ // terminators and then continue parsing the statements list.
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ // If we have a terminator, then we will continue parsing the
+ // statements list.
+ while (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON));
+ if (context_terminator(context, &parser->current)) break;
+
+ // Now we can continue parsing the list of statements.
+ continue;
+ }
+
+ // At this point we have a list of statements that are not terminated by
+ // a newline or semicolon. At this point we need to check if we're at
+ // the end of the statements list. If we are, then we should break out
+ // of the loop.
+ if (context_terminator(context, &parser->current)) break;
+
+ // At this point, we have a syntax error, because the statement was not
+ // terminated by a newline or semicolon, and we're not at the end of the
+ // statements list. Ideally we should scan forward to determine if we
+ // should insert a missing terminator or break out of parsing the
+ // statements list at this point.
+ //
+ // We don't have that yet, so instead we'll do a more naive approach. If
+ // we were unable to parse an expression, then we will skip past this
+ // token and continue parsing the statements list. Otherwise we'll add
+ // an error and continue parsing the statements list.
+ if (PM_NODE_TYPE_P(node, PM_ERROR_RECOVERY_NODE)) {
+ parser_lex(parser);
+
+ // If we are at the end of the file, then we need to stop parsing
+ // the statements entirely at this point. Mark the parser as
+ // recovering, as we know that EOF closes the top-level context, and
+ // then break out of the loop.
+ if (match1(parser, PM_TOKEN_EOF)) {
+ parser->recovering = true;
+ break;
+ }
+
+ while (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON));
+ if (context_terminator(context, &parser->current)) break;
+ } else if (!accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_EOF)) {
+ // This is an inlined version of accept1 because the error that we
+ // want to add has varargs. If this happens again, we should
+ // probably extract a helper function.
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+ }
+
+ context_pop(parser);
+
+ bool last_value = true;
+ switch (context) {
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_DEF_ENSURE:
+ last_value = false;
+ break;
+ default:
+ break;
+ }
+ pm_void_statements_check(parser, statements, last_value);
+
+ return statements;
+}
+
+/**
+ * Add a node to a set of static literals that holds a set of hash keys. If the
+ * node is a duplicate, then add an appropriate warning.
+ */
+static void
+pm_hash_key_static_literals_add(pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *node) {
+ const pm_node_t *duplicated = pm_static_literals_add(&parser->line_offsets, parser->start, parser->start_line, literals, node, true);
+
+ if (duplicated != NULL) {
+ pm_buffer_t buffer = { 0 };
+ pm_static_literal_inspect(&buffer, &parser->line_offsets, parser->start, parser->start_line, parser->encoding->name, duplicated);
+
+ pm_diagnostic_list_append_format(
+ &parser->metadata_arena,
+ &parser->warning_list,
+ duplicated->location.start,
+ duplicated->location.length,
+ PM_WARN_DUPLICATED_HASH_KEY,
+ (int) pm_buffer_length(&buffer),
+ pm_buffer_value(&buffer),
+ pm_line_offset_list_line_column(&parser->line_offsets, PM_NODE_START(node), parser->start_line).line
+ );
+
+ pm_buffer_cleanup(&buffer);
+ }
+}
+
+/**
+ * Add a node to a set of static literals that holds a set of hash keys. If the
+ * node is a duplicate, then add an appropriate warning.
+ */
+static void
+pm_when_clause_static_literals_add(pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *node) {
+ pm_node_t *previous;
+
+ if ((previous = pm_static_literals_add(&parser->line_offsets, parser->start, parser->start_line, literals, node, false)) != NULL) {
+ pm_diagnostic_list_append_format(
+ &parser->metadata_arena,
+ &parser->warning_list,
+ PM_NODE_START(node),
+ PM_NODE_LENGTH(node),
+ PM_WARN_DUPLICATED_WHEN_CLAUSE,
+ pm_line_offset_list_line_column(&parser->line_offsets, PM_NODE_START(node), parser->start_line).line,
+ pm_line_offset_list_line_column(&parser->line_offsets, PM_NODE_START(previous), parser->start_line).line
+ );
+ }
+}
+
+/**
+ * Parse all of the elements of a hash. Return true if a double splat was found.
+ */
+static bool
+parse_assocs(pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *node, uint16_t depth) {
+ assert(PM_NODE_TYPE_P(node, PM_HASH_NODE) || PM_NODE_TYPE_P(node, PM_KEYWORD_HASH_NODE));
+ bool contains_keyword_splat = false;
+
+ while (true) {
+ pm_node_t *element;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_USTAR_STAR: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+ pm_node_t *value = NULL;
+
+ if (match1(parser, PM_TOKEN_BRACE_LEFT)) {
+ // If we're about to parse a nested hash that is being
+ // pushed into this hash directly with **, then we want the
+ // inner hash to share the static literals with the outer
+ // hash.
+ parser->current_hash_keys = literals;
+ value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH, (uint16_t) (depth + 1));
+ } else if (token_begins_expression_p(parser->current.type)) {
+ value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH, (uint16_t) (depth + 1));
+ } else {
+ pm_parser_scope_forwarding_keywords_check(parser, &operator);
+ }
+
+ element = UP(pm_assoc_splat_node_create(parser, value, &operator));
+ contains_keyword_splat = true;
+ break;
+ }
+ case PM_TOKEN_LABEL: {
+ pm_token_t label = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *key = UP(pm_symbol_node_label_create(parser, &label));
+ pm_hash_key_static_literals_add(parser, literals, key);
+
+ pm_node_t *value = NULL;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_HASH_EXPRESSION_AFTER_LABEL, (uint16_t) (depth + 1));
+ } else {
+ if (parser->encoding->isupper_char(label.start, (label.end - 1) - label.start)) {
+ pm_token_t constant = { .type = PM_TOKEN_CONSTANT, .start = label.start, .end = label.end - 1 };
+ value = UP(pm_constant_read_node_create(parser, &constant));
+ } else {
+ int depth = -1;
+ pm_token_t identifier = { .type = PM_TOKEN_IDENTIFIER, .start = label.start, .end = label.end - 1 };
+
+ if (identifier.end[-1] == '!' || identifier.end[-1] == '?') {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &identifier, PM_ERR_INVALID_LOCAL_VARIABLE_READ);
+ } else {
+ depth = pm_parser_local_depth(parser, &identifier);
+ }
+
+ if (depth == -1) {
+ value = UP(pm_call_node_variable_call_create(parser, &identifier));
+ } else {
+ value = UP(pm_local_variable_read_node_create(parser, &identifier, (uint32_t) depth));
+ }
+ }
+
+ value->location.length++;
+ value = UP(pm_implicit_node_create(parser, value));
+ }
+
+ element = UP(pm_assoc_node_create(parser, key, NULL, value));
+ break;
+ }
+ default: {
+ pm_node_t *key = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK | PM_PARSE_ACCEPTS_LABEL, PM_ERR_HASH_KEY, (uint16_t) (depth + 1));
+
+ // Hash keys that are strings are automatically frozen. We will
+ // mark that here.
+ if (PM_NODE_TYPE_P(key, PM_STRING_NODE)) {
+ pm_node_flag_set(key, PM_STRING_FLAGS_FROZEN | PM_NODE_FLAG_STATIC_LITERAL);
+ }
+
+ pm_hash_key_static_literals_add(parser, literals, key);
+
+ pm_token_t operator = { 0 };
+ if (!pm_symbol_node_label_p(parser, key)) {
+ expect1(parser, PM_TOKEN_EQUAL_GREATER, PM_ERR_HASH_ROCKET);
+ operator = parser->previous;
+ }
+
+ pm_node_t *value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_HASH_VALUE, (uint16_t) (depth + 1));
+ element = UP(pm_assoc_node_create(parser, key, NTOK2PTR(operator), value));
+ break;
+ }
+ }
+
+ if (PM_NODE_TYPE_P(node, PM_HASH_NODE)) {
+ pm_hash_node_elements_append(parser->arena, (pm_hash_node_t *) node, element);
+ } else {
+ pm_keyword_hash_node_elements_append(parser->arena, (pm_keyword_hash_node_t *) node, element);
+ }
+
+ // If there's no comma after the element, then we're done.
+ if (!accept1(parser, PM_TOKEN_COMMA)) break;
+
+ // If the next element starts with a label or a **, then we know we have
+ // another element in the hash, so we'll continue parsing.
+ if (match2(parser, PM_TOKEN_USTAR_STAR, PM_TOKEN_LABEL)) continue;
+
+ // Otherwise we need to check if the subsequent token begins an expression.
+ // If it does, then we'll continue parsing.
+ if (token_begins_expression_p(parser->current.type)) continue;
+
+ // Otherwise by default we will exit out of this loop.
+ break;
+ }
+
+ return contains_keyword_splat;
+}
+
+static PRISM_INLINE bool
+argument_allowed_for_bare_hash(pm_parser_t *parser, pm_node_t *argument) {
+ if (pm_symbol_node_label_p(parser, argument)) {
+ return true;
+ }
+
+ switch (PM_NODE_TYPE(argument)) {
+ case PM_CALL_NODE: {
+ pm_call_node_t *cast = (pm_call_node_t *) argument;
+ if (cast->opening_loc.length == 0 && cast->arguments != NULL) {
+ if (PM_NODE_FLAG_P(cast->arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS | PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT)) {
+ return false;
+ }
+ if (cast->block != NULL) {
+ return false;
+ }
+ }
+ break;
+ }
+ default: break;
+ }
+ return accept1(parser, PM_TOKEN_EQUAL_GREATER);
+}
+
+/**
+ * Append an argument to a list of arguments.
+ */
+static PRISM_INLINE void
+parse_arguments_append(pm_parser_t *parser, pm_arguments_t *arguments, pm_node_t *argument) {
+ if (arguments->arguments == NULL) {
+ arguments->arguments = pm_arguments_node_create(parser);
+ }
+
+ pm_arguments_node_arguments_append(parser->arena, arguments->arguments, argument);
+}
+
+/**
+ * Parse a list of arguments.
+ */
+static void
+parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_forwarding, pm_token_type_t terminator, uint8_t flags, uint16_t depth) {
+ pm_binding_power_t binding_power = pm_binding_powers[parser->current.type].left;
+
+ // First we need to check if the next token is one that could be the start
+ // of an argument. If it's not, then we can just return.
+ if (
+ match2(parser, terminator, PM_TOKEN_EOF) ||
+ (binding_power != PM_BINDING_POWER_UNSET && binding_power < PM_BINDING_POWER_RANGE) ||
+ context_terminator(parser->current_context->context, &parser->current)
+ ) {
+ return;
+ }
+
+ bool parsed_first_argument = false;
+ bool parsed_bare_hash = false;
+ bool parsed_block_argument = false;
+ bool parsed_forwarding_arguments = false;
+
+ while (!match1(parser, PM_TOKEN_EOF)) {
+ if (parsed_forwarding_arguments) {
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES);
+ }
+
+ pm_node_t *argument = NULL;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_USTAR_STAR:
+ case PM_TOKEN_LABEL: {
+ if (parsed_bare_hash) {
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_BARE_HASH);
+ }
+
+ pm_keyword_hash_node_t *hash = pm_keyword_hash_node_create(parser);
+ argument = UP(hash);
+
+ pm_static_literals_t hash_keys = { 0 };
+ bool contains_keyword_splat = parse_assocs(parser, &hash_keys, UP(hash), (uint16_t) (depth + 1));
+
+ parse_arguments_append(parser, arguments, argument);
+
+ pm_node_flags_t node_flags = PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS;
+ if (contains_keyword_splat) node_flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT;
+ pm_node_flag_set(UP(arguments->arguments), node_flags);
+
+ pm_static_literals_free(&hash_keys);
+ parsed_bare_hash = true;
+
+ break;
+ }
+ case PM_TOKEN_UAMPERSAND: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+ pm_node_t *expression = NULL;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ expression = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_ARGUMENT, (uint16_t) (depth + 1));
+ } else {
+ pm_parser_scope_forwarding_block_check(parser, &operator);
+ }
+
+ argument = UP(pm_block_argument_node_create(parser, &operator, expression));
+ if (parsed_block_argument) {
+ parse_arguments_append(parser, arguments, argument);
+ } else {
+ arguments->block = argument;
+ }
+
+ if (match1(parser, PM_TOKEN_COMMA)) {
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_AFTER_BLOCK);
+ }
+
+ parsed_block_argument = true;
+ break;
+ }
+ case PM_TOKEN_USTAR: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+
+ if (match4(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_SEMICOLON, PM_TOKEN_BRACKET_RIGHT)) {
+ pm_parser_scope_forwarding_positionals_check(parser, &operator);
+ argument = UP(pm_splat_node_create(parser, &operator, NULL));
+ if (parsed_bare_hash) {
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT);
+ }
+ } else {
+ pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT, (uint16_t) (depth + 1));
+
+ if (parsed_bare_hash) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, &operator), PM_NODE_END(expression) - PM_TOKEN_START(parser, &operator), PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT);
+ }
+
+ argument = UP(pm_splat_node_create(parser, &operator, expression));
+ }
+
+ parse_arguments_append(parser, arguments, argument);
+ break;
+ }
+ case PM_TOKEN_UDOT_DOT_DOT: {
+ if (accepts_forwarding) {
+ parser_lex(parser);
+
+ if (token_begins_expression_p(parser->current.type)) {
+ // If the token begins an expression then this ... was
+ // not actually argument forwarding but was instead a
+ // range.
+ pm_token_t operator = parser->previous;
+ pm_node_t *right = parse_expression(parser, PM_BINDING_POWER_RANGE, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+
+ // If we parse a range, we need to validate that we
+ // didn't accidentally violate the nonassoc rules of the
+ // ... operator.
+ if (PM_NODE_TYPE_P(right, PM_RANGE_NODE)) {
+ pm_range_node_t *range = (pm_range_node_t *) right;
+ pm_parser_err(parser, range->operator_loc.start, range->operator_loc.length, PM_ERR_UNEXPECTED_RANGE_OPERATOR);
+ }
+
+ argument = UP(pm_range_node_create(parser, NULL, &operator, right));
+ } else {
+ pm_parser_scope_forwarding_all_check(parser, &parser->previous);
+ if (parsed_first_argument && terminator == PM_TOKEN_EOF) {
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_FORWARDING_UNBOUND);
+ }
+
+ argument = UP(pm_forwarding_arguments_node_create(parser, &parser->previous));
+ parse_arguments_append(parser, arguments, argument);
+ pm_node_flag_set(UP(arguments->arguments), PM_ARGUMENTS_NODE_FLAGS_CONTAINS_FORWARDING);
+ arguments->has_forwarding = true;
+ parsed_forwarding_arguments = true;
+ break;
+ }
+ }
+ }
+ PRISM_FALLTHROUGH
+ default: {
+ if (argument == NULL) {
+ argument = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (!parsed_first_argument ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0u) | PM_PARSE_ACCEPTS_LABEL), PM_ERR_EXPECT_ARGUMENT, (uint16_t) (depth + 1));
+ }
+
+ bool contains_keywords = false;
+ bool contains_keyword_splat = false;
+
+ if (argument_allowed_for_bare_hash(parser, argument)) {
+ if (parsed_bare_hash) {
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_BARE_HASH);
+ }
+
+ pm_token_t operator = { 0 };
+ if (parser->previous.type == PM_TOKEN_EQUAL_GREATER) {
+ operator = parser->previous;
+ }
+
+ pm_keyword_hash_node_t *bare_hash = pm_keyword_hash_node_create(parser);
+ contains_keywords = true;
+
+ // Create the set of static literals for this hash.
+ pm_static_literals_t hash_keys = { 0 };
+ pm_hash_key_static_literals_add(parser, &hash_keys, argument);
+
+ // Finish parsing the one we are part way through.
+ pm_node_t *value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_HASH_VALUE, (uint16_t) (depth + 1));
+ argument = UP(pm_assoc_node_create(parser, argument, NTOK2PTR(operator), value));
+
+ pm_keyword_hash_node_elements_append(parser->arena, bare_hash, argument);
+ argument = UP(bare_hash);
+
+ // Then parse more if we have a comma
+ if (accept1(parser, PM_TOKEN_COMMA) && (
+ token_begins_expression_p(parser->current.type) ||
+ match2(parser, PM_TOKEN_USTAR_STAR, PM_TOKEN_LABEL)
+ )) {
+ contains_keyword_splat = parse_assocs(parser, &hash_keys, UP(bare_hash), (uint16_t) (depth + 1));
+ }
+
+ pm_static_literals_free(&hash_keys);
+ parsed_bare_hash = true;
+ }
+
+ parse_arguments_append(parser, arguments, argument);
+
+ pm_node_flags_t node_flags = 0;
+ if (contains_keywords) node_flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS;
+ if (contains_keyword_splat) node_flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT;
+ pm_node_flag_set(UP(arguments->arguments), node_flags);
+
+ break;
+ }
+ }
+
+ parsed_first_argument = true;
+
+ // If parsing the argument failed, we need to stop parsing arguments.
+ if (PM_NODE_TYPE_P(argument, PM_ERROR_RECOVERY_NODE) || parser->recovering) break;
+
+ // If the terminator of these arguments is not EOF, then we have a
+ // specific token we're looking for. In that case we can accept a
+ // newline here because it is not functioning as a statement terminator.
+ bool accepted_newline = false;
+ if (terminator != PM_TOKEN_EOF) {
+ accepted_newline = accept1(parser, PM_TOKEN_NEWLINE);
+ }
+
+ if (parser->previous.type == PM_TOKEN_COMMA && parsed_bare_hash) {
+ // If we previously were on a comma and we just parsed a bare hash,
+ // then we want to continue parsing arguments. This is because the
+ // comma was grabbed up by the hash parser.
+ } else if (accept1(parser, PM_TOKEN_COMMA)) {
+ // If there was a comma, then we need to check if we also accepted a
+ // newline. If we did, then this is a syntax error.
+ if (accepted_newline) {
+ pm_parser_err_previous(parser, PM_ERR_INVALID_COMMA);
+ }
+
+ // If this is a command call and an argument takes a block,
+ // there can be no further arguments. For example,
+ // `foo(bar 1 do end, 2)` should be rejected.
+ if (PM_NODE_TYPE_P(argument, PM_CALL_NODE)) {
+ pm_call_node_t *call = (pm_call_node_t *) argument;
+ if (call->opening_loc.length == 0 && call->arguments != NULL && call->block != NULL) {
+ pm_parser_err_previous(parser, PM_ERR_INVALID_COMMA);
+ break;
+ }
+ }
+ } else {
+ // If there is no comma at the end of the argument list then we're
+ // done parsing arguments and can break out of this loop.
+ break;
+ }
+
+ // If we hit the terminator, then that means we have a trailing comma so
+ // we can accept that output as well.
+ if (match1(parser, terminator)) break;
+ }
+}
+
+/**
+ * Required parameters on method, block, and lambda declarations can be
+ * destructured using parentheses. This looks like:
+ *
+ * def foo((bar, baz))
+ * end
+ *
+ *
+ * It can recurse infinitely down, and splats are allowed to group arguments.
+ */
+static pm_multi_target_node_t *
+parse_required_destructured_parameter(pm_parser_t *parser) {
+ expect1(parser, PM_TOKEN_PARENTHESIS_LEFT, PM_ERR_EXPECT_LPAREN_REQ_PARAMETER);
+
+ pm_multi_target_node_t *node = pm_multi_target_node_create(parser);
+ pm_multi_target_node_opening_set(parser, node, &parser->previous);
+
+ do {
+ pm_node_t *param;
+
+ // If we get here then we have a trailing comma, which isn't allowed in
+ // the grammar. In other places, multi targets _do_ allow trailing
+ // commas, so here we'll assume this is a mistake of the user not
+ // knowing it's not allowed here.
+ if (node->lefts.size > 0 && match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ param = UP(pm_implicit_rest_node_create(parser, &parser->previous));
+ pm_multi_target_node_targets_append(parser, node, param);
+ pm_parser_err_current(parser, PM_ERR_PARAMETER_WILD_LOOSE_COMMA);
+ break;
+ }
+
+ if (match1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ param = UP(parse_required_destructured_parameter(parser));
+ } else if (accept1(parser, PM_TOKEN_USTAR)) {
+ pm_token_t star = parser->previous;
+ pm_node_t *value = NULL;
+
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ pm_token_t name = parser->previous;
+ value = UP(pm_required_parameter_node_create(parser, &name));
+ if (pm_parser_parameter_name_check(parser, &name)) {
+ pm_node_flag_set_repeated_parameter(value);
+ }
+ pm_parser_local_add_token(parser, &name, 1);
+ }
+
+ param = UP(pm_splat_node_create(parser, &star, value));
+ } else {
+ expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_EXPECT_IDENT_REQ_PARAMETER);
+ pm_token_t name = parser->previous;
+
+ param = UP(pm_required_parameter_node_create(parser, &name));
+ if (pm_parser_parameter_name_check(parser, &name)) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+ pm_parser_local_add_token(parser, &name, 1);
+ }
+
+ pm_multi_target_node_targets_append(parser, node, param);
+ } while (accept1(parser, PM_TOKEN_COMMA));
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN_REQ_PARAMETER);
+ pm_multi_target_node_closing_set(parser, node, &parser->previous);
+
+ return node;
+}
+
+/**
+ * This represents the different order states we can be in when parsing
+ * method parameters.
+ */
+typedef enum {
+ PM_PARAMETERS_NO_CHANGE = 0, // Extra state for tokens that should not change the state
+ PM_PARAMETERS_ORDER_NOTHING_AFTER = 1,
+ PM_PARAMETERS_ORDER_KEYWORDS_REST,
+ PM_PARAMETERS_ORDER_KEYWORDS,
+ PM_PARAMETERS_ORDER_REST,
+ PM_PARAMETERS_ORDER_AFTER_OPTIONAL,
+ PM_PARAMETERS_ORDER_OPTIONAL,
+ PM_PARAMETERS_ORDER_NAMED,
+ PM_PARAMETERS_ORDER_NONE,
+} pm_parameters_order_t;
+
+/**
+ * This matches parameters tokens with parameters state.
+ */
+static pm_parameters_order_t parameters_ordering[PM_TOKEN_MAXIMUM] = {
+ [0] = PM_PARAMETERS_NO_CHANGE,
+ [PM_TOKEN_UAMPERSAND] = PM_PARAMETERS_ORDER_NOTHING_AFTER,
+ [PM_TOKEN_AMPERSAND] = PM_PARAMETERS_ORDER_NOTHING_AFTER,
+ [PM_TOKEN_UDOT_DOT_DOT] = PM_PARAMETERS_ORDER_NOTHING_AFTER,
+ [PM_TOKEN_IDENTIFIER] = PM_PARAMETERS_ORDER_NAMED,
+ [PM_TOKEN_PARENTHESIS_LEFT] = PM_PARAMETERS_ORDER_NAMED,
+ [PM_TOKEN_EQUAL] = PM_PARAMETERS_ORDER_OPTIONAL,
+ [PM_TOKEN_LABEL] = PM_PARAMETERS_ORDER_KEYWORDS,
+ [PM_TOKEN_USTAR] = PM_PARAMETERS_ORDER_AFTER_OPTIONAL,
+ [PM_TOKEN_STAR] = PM_PARAMETERS_ORDER_AFTER_OPTIONAL,
+ [PM_TOKEN_USTAR_STAR] = PM_PARAMETERS_ORDER_KEYWORDS_REST,
+ [PM_TOKEN_STAR_STAR] = PM_PARAMETERS_ORDER_KEYWORDS_REST
+};
+
+/**
+ * Check if current parameter follows valid parameters ordering. If not it adds
+ * an error to the list without stopping the parsing, otherwise sets the
+ * parameters state to the one corresponding to the current parameter.
+ *
+ * It returns true if it was successful, and false otherwise.
+ */
+static bool
+update_parameter_state(pm_parser_t *parser, pm_token_t *token, pm_parameters_order_t *current) {
+ pm_parameters_order_t state = parameters_ordering[token->type];
+ if (state == PM_PARAMETERS_NO_CHANGE) return true;
+
+ // If we see another ordered argument after a optional argument
+ // we only continue parsing ordered arguments until we stop seeing ordered arguments.
+ if (*current == PM_PARAMETERS_ORDER_OPTIONAL && state == PM_PARAMETERS_ORDER_NAMED) {
+ *current = PM_PARAMETERS_ORDER_AFTER_OPTIONAL;
+ return true;
+ } else if (*current == PM_PARAMETERS_ORDER_AFTER_OPTIONAL && state == PM_PARAMETERS_ORDER_NAMED) {
+ return true;
+ }
+
+ if (token->type == PM_TOKEN_USTAR && *current == PM_PARAMETERS_ORDER_AFTER_OPTIONAL) {
+ pm_parser_err_token(parser, token, PM_ERR_PARAMETER_STAR);
+ return false;
+ } else if (token->type == PM_TOKEN_UDOT_DOT_DOT && (*current >= PM_PARAMETERS_ORDER_KEYWORDS_REST && *current <= PM_PARAMETERS_ORDER_AFTER_OPTIONAL)) {
+ pm_parser_err_token(parser, token, *current == PM_PARAMETERS_ORDER_AFTER_OPTIONAL ? PM_ERR_PARAMETER_FORWARDING_AFTER_REST : PM_ERR_PARAMETER_ORDER);
+ return false;
+ } else if (*current == PM_PARAMETERS_ORDER_NOTHING_AFTER || state > *current) {
+ // We know what transition we failed on, so we can provide a better error here.
+ pm_parser_err_token(parser, token, PM_ERR_PARAMETER_ORDER);
+ return false;
+ }
+
+ if (state < *current) *current = state;
+ return true;
+}
+
+static PRISM_INLINE void
+parse_parameters_handle_trailing_comma(
+ pm_parser_t *parser,
+ pm_parameters_node_t *params,
+ pm_parameters_order_t order,
+ bool in_block,
+ bool allows_trailing_comma
+) {
+ if (!allows_trailing_comma) {
+ pm_parser_err_previous(parser, PM_ERR_PARAMETER_WILD_LOOSE_COMMA);
+ return;
+ }
+
+ if (in_block) {
+ if (order >= PM_PARAMETERS_ORDER_NAMED) {
+ // foo do |bar,|; end
+ pm_node_t *param = UP(pm_implicit_rest_node_create(parser, &parser->previous));
+
+ if (params->rest == NULL) {
+ pm_parameters_node_rest_set(params, param);
+ } else {
+ pm_parser_err_node(parser, UP(param), PM_ERR_PARAMETER_SPLAT_MULTI);
+ pm_parameters_node_posts_append(parser->arena, params, UP(param));
+ }
+ } else {
+ // foo do |*bar,|; end
+ pm_parser_err_previous(parser, PM_ERR_PARAMETER_WILD_LOOSE_COMMA);
+ }
+ } else {
+ // https://bugs.ruby-lang.org/issues/19107
+ // Allow `def foo(bar,); end`, `def foo(*bar,); end`, etc. but not `def foo(...,); end`
+ if (parser->version < PM_OPTIONS_VERSION_CRUBY_4_1 || order == PM_PARAMETERS_ORDER_NOTHING_AFTER) {
+ pm_parser_err_previous(parser, PM_ERR_PARAMETER_WILD_LOOSE_COMMA);
+ }
+ }
+}
+
+/**
+ * Parse a list of parameters on a method definition.
+ */
+static pm_parameters_node_t *
+parse_parameters(
+ pm_parser_t *parser,
+ pm_binding_power_t binding_power,
+ bool uses_parentheses,
+ bool allows_trailing_comma,
+ bool allows_forwarding_parameters,
+ bool accepts_blocks_in_defaults,
+ bool in_block,
+ pm_diagnostic_id_t diag_id_forwarding,
+ uint16_t depth
+) {
+ pm_do_loop_stack_push(parser, false);
+
+ pm_parameters_node_t *params = pm_parameters_node_create(parser);
+ pm_parameters_order_t order = PM_PARAMETERS_ORDER_NONE;
+
+ while (true) {
+ bool parsing = true;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ update_parameter_state(parser, &parser->current, &order);
+ pm_node_t *param = UP(parse_required_destructured_parameter(parser));
+
+ if (order > PM_PARAMETERS_ORDER_AFTER_OPTIONAL) {
+ pm_parameters_node_requireds_append(parser->arena, params, param);
+ } else {
+ pm_parameters_node_posts_append(parser->arena, params, param);
+ }
+ break;
+ }
+ case PM_TOKEN_UAMPERSAND:
+ case PM_TOKEN_AMPERSAND: {
+ update_parameter_state(parser, &parser->current, &order);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *param;
+
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_1 && accept1(parser, PM_TOKEN_KEYWORD_NIL)) {
+ param = (pm_node_t *) pm_no_block_parameter_node_create(parser, &operator, &parser->previous);
+ } else {
+ pm_token_t name = {0};
+
+ bool repeated = false;
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ name = parser->previous;
+ repeated = pm_parser_parameter_name_check(parser, &name);
+ pm_parser_local_add_token(parser, &name, 1);
+ } else {
+ parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_BLOCK;
+ }
+
+ param = (pm_node_t *) pm_block_parameter_node_create(parser, NTOK2PTR(name), &operator);
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+ }
+
+ if (params->block == NULL) {
+ pm_parameters_node_block_set(params, param);
+ } else {
+ pm_parser_err_node(parser, param, PM_ERR_PARAMETER_BLOCK_MULTI);
+ pm_parameters_node_posts_append(parser->arena, params, UP(pm_error_recovery_node_create_unexpected(parser, param)));
+ }
+
+ break;
+ }
+ case PM_TOKEN_UDOT_DOT_DOT: {
+ if (!allows_forwarding_parameters) {
+ pm_parser_err_current(parser, diag_id_forwarding);
+ }
+
+ bool succeeded = update_parameter_state(parser, &parser->current, &order);
+ parser_lex(parser);
+
+ parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_ALL;
+ pm_forwarding_parameter_node_t *param = pm_forwarding_parameter_node_create(parser, &parser->previous);
+
+ if (params->keyword_rest != NULL) {
+ // If we already have a keyword rest parameter, then we replace it with the
+ // forwarding parameter and move the keyword rest parameter to the posts list.
+ pm_node_t *keyword_rest = params->keyword_rest;
+ pm_parameters_node_posts_append(parser->arena, params, UP(pm_error_recovery_node_create_unexpected(parser, keyword_rest)));
+ if (succeeded) pm_parser_err_previous(parser, PM_ERR_PARAMETER_UNEXPECTED_FWD);
+ params->keyword_rest = NULL;
+ }
+
+ pm_parameters_node_keyword_rest_set(params, UP(param));
+ break;
+ }
+ case PM_TOKEN_CLASS_VARIABLE:
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+ switch (parser->previous.type) {
+ case PM_TOKEN_CONSTANT:
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_FORMAL_CONSTANT);
+ break;
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_FORMAL_IVAR);
+ break;
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_FORMAL_GLOBAL);
+ break;
+ case PM_TOKEN_CLASS_VARIABLE:
+ pm_parser_err_previous(parser, PM_ERR_ARGUMENT_FORMAL_CLASS);
+ break;
+ case PM_TOKEN_METHOD_NAME:
+ pm_parser_err_previous(parser, PM_ERR_PARAMETER_METHOD_NAME);
+ break;
+ default: break;
+ }
+
+ if (parser->current.type == PM_TOKEN_EQUAL) {
+ update_parameter_state(parser, &parser->current, &order);
+ } else {
+ update_parameter_state(parser, &parser->previous, &order);
+ }
+
+ pm_token_t name = parser->previous;
+ bool repeated = pm_parser_parameter_name_check(parser, &name);
+ pm_parser_local_add_token(parser, &name, 1);
+
+ if (match1(parser, PM_TOKEN_EQUAL)) {
+ pm_token_t operator = parser->current;
+ context_push(parser, PM_CONTEXT_DEFAULT_PARAMS);
+ parser_lex(parser);
+
+ pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &name);
+ uint32_t reads = parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
+
+ if (accepts_blocks_in_defaults) pm_accepts_block_stack_push(parser, true);
+ pm_node_t *value = parse_value_expression(parser, binding_power, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_PARAMETER_NO_DEFAULT, (uint16_t) (depth + 1));
+ if (accepts_blocks_in_defaults) pm_accepts_block_stack_pop(parser);
+
+ pm_optional_parameter_node_t *param = pm_optional_parameter_node_create(parser, &name, &operator, value);
+
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(UP(param));
+ }
+ pm_parameters_node_optionals_append(parser->arena, params, param);
+
+ // If the value of the parameter increased the number of
+ // reads of that parameter, then we need to warn that we
+ // have a circular definition.
+ if ((parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3) && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &name, PM_ERR_PARAMETER_CIRCULAR);
+ }
+
+ context_pop(parser);
+
+ // If parsing the value of the parameter resulted in error recovery,
+ // then we can put a missing node in its place and stop parsing the
+ // parameters entirely now.
+ if (parser->recovering) {
+ parsing = false;
+ break;
+ }
+ } else if (order > PM_PARAMETERS_ORDER_AFTER_OPTIONAL) {
+ pm_required_parameter_node_t *param = pm_required_parameter_node_create(parser, &name);
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(UP(param));
+ }
+ pm_parameters_node_requireds_append(parser->arena, params, UP(param));
+ } else {
+ pm_required_parameter_node_t *param = pm_required_parameter_node_create(parser, &name);
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(UP(param));
+ }
+ pm_parameters_node_posts_append(parser->arena, params, UP(param));
+ }
+
+ break;
+ }
+ case PM_TOKEN_LABEL: {
+ if (!uses_parentheses && !in_block) parser->in_keyword_arg = true;
+ update_parameter_state(parser, &parser->current, &order);
+
+ context_push(parser, PM_CONTEXT_DEFAULT_PARAMS);
+ parser_lex(parser);
+
+ pm_token_t name = parser->previous;
+ pm_token_t local = name;
+ local.end -= 1;
+
+ if (parser->encoding_changed ? parser->encoding->isupper_char(local.start, local.end - local.start) : pm_encoding_utf_8_isupper_char(local.start, local.end - local.start)) {
+ pm_parser_err(parser, PM_TOKEN_START(parser, &local), PM_TOKEN_LENGTH(&local), PM_ERR_ARGUMENT_FORMAL_CONSTANT);
+ } else if (local.end[-1] == '!' || local.end[-1] == '?') {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &local, PM_ERR_INVALID_LOCAL_VARIABLE_WRITE);
+ }
+
+ bool repeated = pm_parser_parameter_name_check(parser, &local);
+ pm_parser_local_add_token(parser, &local, 1);
+
+ switch (parser->current.type) {
+ case PM_TOKEN_COMMA:
+ case PM_TOKEN_PARENTHESIS_RIGHT:
+ case PM_TOKEN_PIPE: {
+ context_pop(parser);
+
+ pm_node_t *param = UP(pm_required_keyword_parameter_node_create(parser, &name));
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+
+ pm_parameters_node_keywords_append(parser->arena, params, param);
+ break;
+ }
+ case PM_TOKEN_SEMICOLON:
+ case PM_TOKEN_NEWLINE: {
+ context_pop(parser);
+
+ if (uses_parentheses) {
+ parsing = false;
+ break;
+ }
+
+ pm_node_t *param = UP(pm_required_keyword_parameter_node_create(parser, &name));
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+
+ pm_parameters_node_keywords_append(parser->arena, params, param);
+ break;
+ }
+ default: {
+ pm_node_t *param;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &local);
+ uint32_t reads = parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
+
+ if (accepts_blocks_in_defaults) pm_accepts_block_stack_push(parser, true);
+ pm_node_t *value = parse_value_expression(parser, binding_power, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_PARAMETER_NO_DEFAULT_KW, (uint16_t) (depth + 1));
+ if (accepts_blocks_in_defaults) pm_accepts_block_stack_pop(parser);
+
+ if (parser->version <= PM_OPTIONS_VERSION_CRUBY_3_3 && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &local, PM_ERR_PARAMETER_CIRCULAR);
+ }
+
+ param = UP(pm_optional_keyword_parameter_node_create(parser, &name, value));
+ }
+ else {
+ param = UP(pm_required_keyword_parameter_node_create(parser, &name));
+ }
+
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+
+ context_pop(parser);
+ pm_parameters_node_keywords_append(parser->arena, params, param);
+
+ // If parsing the value of the parameter resulted in error recovery,
+ // then we can put a missing node in its place and stop parsing the
+ // parameters entirely now.
+ if (parser->recovering) {
+ parsing = false;
+ break;
+ }
+ }
+ }
+
+ parser->in_keyword_arg = false;
+ break;
+ }
+ case PM_TOKEN_USTAR:
+ case PM_TOKEN_STAR: {
+ update_parameter_state(parser, &parser->current, &order);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_token_t name = { 0 };
+ bool repeated = false;
+
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ name = parser->previous;
+ repeated = pm_parser_parameter_name_check(parser, &name);
+ pm_parser_local_add_token(parser, &name, 1);
+ } else {
+ parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS;
+ }
+
+ pm_node_t *param = UP(pm_rest_parameter_node_create(parser, &operator, NTOK2PTR(name)));
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+
+ if (params->rest == NULL) {
+ pm_parameters_node_rest_set(params, param);
+ } else {
+ pm_parser_err_node(parser, param, PM_ERR_PARAMETER_SPLAT_MULTI);
+ pm_parameters_node_posts_append(parser->arena, params, param);
+ }
+
+ break;
+ }
+ case PM_TOKEN_STAR_STAR:
+ case PM_TOKEN_USTAR_STAR: {
+ pm_parameters_order_t previous_order = order;
+ update_parameter_state(parser, &parser->current, &order);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *param;
+
+ if (accept1(parser, PM_TOKEN_KEYWORD_NIL)) {
+ if (previous_order <= PM_PARAMETERS_ORDER_KEYWORDS) {
+ pm_parser_err_previous(parser, PM_ERR_PARAMETER_UNEXPECTED_NO_KW);
+ }
+
+ param = UP(pm_no_keywords_parameter_node_create(parser, &operator, &parser->previous));
+ } else {
+ pm_token_t name = { 0 };
+
+ bool repeated = false;
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ name = parser->previous;
+ repeated = pm_parser_parameter_name_check(parser, &name);
+ pm_parser_local_add_token(parser, &name, 1);
+ } else {
+ parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS;
+ }
+
+ param = UP(pm_keyword_rest_parameter_node_create(parser, &operator, NTOK2PTR(name)));
+ if (repeated) {
+ pm_node_flag_set_repeated_parameter(param);
+ }
+ }
+
+ if (params->keyword_rest == NULL) {
+ pm_parameters_node_keyword_rest_set(params, param);
+ } else {
+ pm_parser_err_node(parser, param, PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI);
+ pm_parameters_node_posts_append(parser->arena, params, UP(pm_error_recovery_node_create_unexpected(parser, param)));
+ }
+
+ break;
+ }
+ default:
+ if (parser->previous.type == PM_TOKEN_COMMA) {
+ parse_parameters_handle_trailing_comma(parser, params, order, in_block, allows_trailing_comma);
+ }
+
+ parsing = false;
+ break;
+ }
+
+ // If we hit some kind of issue while parsing the parameter, this would
+ // have been set to false. In that case, we need to break out of the
+ // loop.
+ if (!parsing) break;
+
+ bool accepted_newline = false;
+ if (uses_parentheses) {
+ accepted_newline = accept1(parser, PM_TOKEN_NEWLINE);
+ }
+
+ if (accept1(parser, PM_TOKEN_COMMA)) {
+ // If there was a comma, but we also accepted a newline, then this
+ // is a syntax error.
+ if (accepted_newline) {
+ pm_parser_err_previous(parser, PM_ERR_INVALID_COMMA);
+ }
+ } else {
+ // If there was no comma, then we're done parsing parameters.
+ break;
+ }
+ }
+
+ pm_do_loop_stack_pop(parser);
+
+ // If we don't have any parameters, return `NULL` instead of an empty `ParametersNode`.
+ if (PM_NODE_START(params) == PM_NODE_END(params)) {
+ return NULL;
+ }
+
+ return params;
+}
+
+/**
+ * Accepts a parser returns the index of the last newline in the file that was
+ * ecorded before the current token within the newline list.
+ */
+static size_t
+token_newline_index(const pm_parser_t *parser) {
+ if (parser->heredoc_end == NULL) {
+ // This is the common case. In this case we can look at the previously
+ // recorded newline in the newline list and subtract from the current
+ // offset.
+ return parser->line_offsets.size - 1;
+ } else {
+ // This is unlikely. This is the case that we have already parsed the
+ // start of a heredoc, so we cannot rely on looking at the previous
+ // offset of the newline list, and instead must go through the whole
+ // process of a binary search for the line number.
+ return (size_t) pm_line_offset_list_line(&parser->line_offsets, PM_TOKEN_START(parser, &parser->current), 0);
+ }
+}
+
+/**
+ * Accepts a parser, a newline index, and a token and returns the column. The
+ * important piece of this is that it expands tabs out to the next tab stop.
+ */
+static int64_t
+token_column(const pm_parser_t *parser, size_t newline_index, const pm_token_t *token, bool break_on_non_space) {
+ const uint8_t *cursor = parser->start + parser->line_offsets.offsets[newline_index];
+ const uint8_t *end = token->start;
+
+ // Skip over the BOM if it is present.
+ if (
+ newline_index == 0 &&
+ parser->start[0] == 0xef &&
+ parser->start[1] == 0xbb &&
+ parser->start[2] == 0xbf
+ ) cursor += 3;
+
+ int64_t column = 0;
+ for (; cursor < end; cursor++) {
+ switch (*cursor) {
+ case '\t':
+ column = ((column / PM_TAB_WHITESPACE_SIZE) + 1) * PM_TAB_WHITESPACE_SIZE;
+ break;
+ case ' ':
+ column++;
+ break;
+ default:
+ column++;
+ if (break_on_non_space) return -1;
+ break;
+ }
+ }
+
+ return column;
+}
+
+/**
+ * Accepts a parser, two newline indices, and pointers to two tokens. This
+ * function warns if the indentation of the two tokens does not match.
+ */
+static void
+parser_warn_indentation_mismatch(pm_parser_t *parser, size_t opening_newline_index, const pm_token_t *opening_token, bool if_after_else, bool allow_indent) {
+ // If these warnings are disabled (unlikely), then we can just return.
+ if (!parser->warn_mismatched_indentation) return;
+
+ // If the tokens are on the same line, we do not warn.
+ size_t closing_newline_index = token_newline_index(parser);
+ if (opening_newline_index == closing_newline_index) return;
+
+ // If the opening token has anything other than spaces or tabs before it,
+ // then we do not warn. This is unless we are matching up an `if`/`end` pair
+ // and the `if` immediately follows an `else` keyword.
+ int64_t opening_column = token_column(parser, opening_newline_index, opening_token, !if_after_else);
+ if (!if_after_else && (opening_column == -1)) return;
+
+ // Get a reference to the closing token off the current parser. This assumes
+ // that the caller has placed this in the correct position.
+ pm_token_t *closing_token = &parser->current;
+
+ // If the tokens are at the same indentation, we do not warn.
+ int64_t closing_column = token_column(parser, closing_newline_index, closing_token, true);
+ if ((closing_column == -1) || (opening_column == closing_column)) return;
+
+ // If the closing column is greater than the opening column and we are
+ // allowing indentation, then we do not warn.
+ if (allow_indent && (closing_column > opening_column)) return;
+
+ // Otherwise, add a warning.
+ PM_PARSER_WARN_FORMAT(
+ parser,
+ PM_TOKEN_START(parser, closing_token),
+ PM_TOKEN_LENGTH(closing_token),
+ PM_WARN_INDENTATION_MISMATCH,
+ (int) (closing_token->end - closing_token->start),
+ (const char *) closing_token->start,
+ (int) (opening_token->end - opening_token->start),
+ (const char *) opening_token->start,
+ ((int32_t) opening_newline_index) + parser->start_line
+ );
+}
+
+typedef enum {
+ PM_RESCUES_BEGIN = 1,
+ PM_RESCUES_BLOCK,
+ PM_RESCUES_CLASS,
+ PM_RESCUES_DEF,
+ PM_RESCUES_LAMBDA,
+ PM_RESCUES_MODULE,
+ PM_RESCUES_SCLASS
+} pm_rescues_type_t;
+
+/**
+ * Parse any number of rescue clauses. This will form a linked list of if
+ * nodes pointing to each other from the top.
+ */
+static PRISM_INLINE void
+parse_rescues(pm_parser_t *parser, size_t opening_newline_index, const pm_token_t *opening, pm_begin_node_t *parent_node, pm_rescues_type_t type, uint16_t depth) {
+ pm_rescue_node_t *current = NULL;
+
+ while (match1(parser, PM_TOKEN_KEYWORD_RESCUE)) {
+ if (opening != NULL) parser_warn_indentation_mismatch(parser, opening_newline_index, opening, false, false);
+ parser_lex(parser);
+
+ pm_rescue_node_t *rescue = pm_rescue_node_create(parser, &parser->previous);
+
+ switch (parser->current.type) {
+ case PM_TOKEN_EQUAL_GREATER: {
+ // Here we have an immediate => after the rescue keyword, in which case
+ // we're going to have an empty list of exceptions to rescue (which
+ // implies StandardError).
+ parser_lex(parser);
+ pm_rescue_node_operator_set(parser, rescue, &parser->previous);
+
+ pm_node_t *reference = parse_expression(parser, PM_BINDING_POWER_INDEX, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_RESCUE_VARIABLE, (uint16_t) (depth + 1));
+ reference = parse_target(parser, reference, false, false);
+
+ pm_rescue_node_reference_set(rescue, reference);
+ break;
+ }
+ case PM_TOKEN_NEWLINE:
+ case PM_TOKEN_SEMICOLON:
+ case PM_TOKEN_KEYWORD_THEN:
+ // Here we have a terminator for the rescue keyword, in which
+ // case we're going to just continue on.
+ break;
+ default: {
+ if (token_begins_expression_p(parser->current.type) || match1(parser, PM_TOKEN_USTAR)) {
+ // Here we have something that could be an exception expression, so
+ // we'll attempt to parse it here and any others delimited by commas.
+
+ do {
+ pm_node_t *expression = parse_starred_expression(parser, PM_BINDING_POWER_DEFINED, false, PM_ERR_RESCUE_EXPRESSION, (uint16_t) (depth + 1));
+ pm_rescue_node_exceptions_append(parser->arena, rescue, expression);
+
+ // If we hit a newline, then this is the end of the rescue expression. We
+ // can continue on to parse the statements.
+ if (match3(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_KEYWORD_THEN)) break;
+
+ // If we hit a `=>` then we're going to parse the exception variable. Once
+ // we've done that, we'll break out of the loop and parse the statements.
+ if (accept1(parser, PM_TOKEN_EQUAL_GREATER)) {
+ pm_rescue_node_operator_set(parser, rescue, &parser->previous);
+
+ pm_node_t *reference = parse_expression(parser, PM_BINDING_POWER_INDEX, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_RESCUE_VARIABLE, (uint16_t) (depth + 1));
+ reference = parse_target(parser, reference, false, false);
+
+ pm_rescue_node_reference_set(rescue, reference);
+ break;
+ }
+ } while (accept1(parser, PM_TOKEN_COMMA));
+ }
+ }
+ }
+
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ if (accept1(parser, PM_TOKEN_KEYWORD_THEN)) {
+ rescue->then_keyword_loc = TOK2LOC(parser, &parser->previous);
+ }
+ } else {
+ expect1(parser, PM_TOKEN_KEYWORD_THEN, PM_ERR_RESCUE_TERM);
+ rescue->then_keyword_loc = TOK2LOC(parser, &parser->previous);
+ }
+
+ if (!match3(parser, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ pm_context_t context;
+
+ switch (type) {
+ case PM_RESCUES_BEGIN: context = PM_CONTEXT_BEGIN_RESCUE; break;
+ case PM_RESCUES_BLOCK: context = PM_CONTEXT_BLOCK_RESCUE; break;
+ case PM_RESCUES_CLASS: context = PM_CONTEXT_CLASS_RESCUE; break;
+ case PM_RESCUES_DEF: context = PM_CONTEXT_DEF_RESCUE; break;
+ case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_RESCUE; break;
+ case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_RESCUE; break;
+ case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_RESCUE; break;
+ default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_RESCUE; break;
+ }
+
+ pm_statements_node_t *statements = parse_statements(parser, context, (uint16_t) (depth + 1));
+ if (statements != NULL) pm_rescue_node_statements_set(rescue, statements);
+
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ if (current == NULL) {
+ pm_begin_node_rescue_clause_set(parent_node, rescue);
+ } else {
+ pm_rescue_node_subsequent_set(current, rescue);
+ }
+
+ current = rescue;
+ }
+
+ // The end node locations on rescue nodes will not be set correctly
+ // since we won't know the end until we've found all subsequent
+ // clauses. This sets the end location on all rescues once we know it.
+ if (current != NULL) {
+ pm_rescue_node_t *clause = parent_node->rescue_clause;
+
+ while (clause != NULL) {
+ PM_NODE_LENGTH_SET_NODE(clause, current);
+ clause = clause->subsequent;
+ }
+ }
+
+ pm_token_t else_keyword;
+ if (match1(parser, PM_TOKEN_KEYWORD_ELSE)) {
+ if (opening != NULL) parser_warn_indentation_mismatch(parser, opening_newline_index, opening, false, false);
+ opening_newline_index = token_newline_index(parser);
+
+ else_keyword = parser->current;
+ opening = &else_keyword;
+
+ parser_lex(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+
+ pm_statements_node_t *else_statements = NULL;
+ if (!match2(parser, PM_TOKEN_KEYWORD_END, PM_TOKEN_KEYWORD_ENSURE)) {
+ pm_accepts_block_stack_push(parser, true);
+ pm_context_t context;
+
+ switch (type) {
+ case PM_RESCUES_BEGIN: context = PM_CONTEXT_BEGIN_ELSE; break;
+ case PM_RESCUES_BLOCK: context = PM_CONTEXT_BLOCK_ELSE; break;
+ case PM_RESCUES_CLASS: context = PM_CONTEXT_CLASS_ELSE; break;
+ case PM_RESCUES_DEF: context = PM_CONTEXT_DEF_ELSE; break;
+ case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_ELSE; break;
+ case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_ELSE; break;
+ case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_ELSE; break;
+ default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_ELSE; break;
+ }
+
+ else_statements = parse_statements(parser, context, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ pm_else_node_t *else_clause = pm_else_node_create(parser, &else_keyword, else_statements, &parser->current);
+ pm_begin_node_else_clause_set(parent_node, else_clause);
+
+ // If we don't have a `current` rescue node, then this is a dangling
+ // else, and it's an error.
+ if (current == NULL) pm_parser_err_node(parser, UP(else_clause), PM_ERR_BEGIN_LONELY_ELSE);
+ }
+
+ if (match1(parser, PM_TOKEN_KEYWORD_ENSURE)) {
+ if (opening != NULL) parser_warn_indentation_mismatch(parser, opening_newline_index, opening, false, false);
+ pm_token_t ensure_keyword = parser->current;
+
+ parser_lex(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+
+ pm_statements_node_t *ensure_statements = NULL;
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ pm_context_t context;
+
+ switch (type) {
+ case PM_RESCUES_BEGIN: context = PM_CONTEXT_BEGIN_ENSURE; break;
+ case PM_RESCUES_BLOCK: context = PM_CONTEXT_BLOCK_ENSURE; break;
+ case PM_RESCUES_CLASS: context = PM_CONTEXT_CLASS_ENSURE; break;
+ case PM_RESCUES_DEF: context = PM_CONTEXT_DEF_ENSURE; break;
+ case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_ENSURE; break;
+ case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_ENSURE; break;
+ case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_ENSURE; break;
+ default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_RESCUE; break;
+ }
+
+ ensure_statements = parse_statements(parser, context, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ pm_ensure_node_t *ensure_clause = pm_ensure_node_create(parser, &ensure_keyword, ensure_statements, &parser->current);
+ pm_begin_node_ensure_clause_set(parent_node, ensure_clause);
+ }
+
+ if (match1(parser, PM_TOKEN_KEYWORD_END)) {
+ if (opening != NULL) parser_warn_indentation_mismatch(parser, opening_newline_index, opening, false, false);
+ pm_begin_node_end_keyword_set(parser, parent_node, &parser->current);
+ } else {
+ pm_token_t end_keyword = (pm_token_t) { .type = PM_TOKEN_KEYWORD_END, .start = parser->previous.end, .end = parser->previous.end };
+ pm_begin_node_end_keyword_set(parser, parent_node, &end_keyword);
+ }
+}
+
+/**
+ * Parse a set of rescue clauses with an implicit begin (for example when on a
+ * class, module, def, etc.).
+ */
+static pm_begin_node_t *
+parse_rescues_implicit_begin(pm_parser_t *parser, size_t opening_newline_index, const pm_token_t *opening, const uint8_t *start, pm_statements_node_t *statements, pm_rescues_type_t type, uint16_t depth) {
+ pm_begin_node_t *node = pm_begin_node_create(parser, NULL, statements);
+ parse_rescues(parser, opening_newline_index, opening, node, type, (uint16_t) (depth + 1));
+
+ node->base.location.start = U32(start - parser->start);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, &parser->current);
+
+ return node;
+}
+
+/**
+ * Parse a list of parameters and local on a block definition.
+ */
+static pm_block_parameters_node_t *
+parse_block_parameters(
+ pm_parser_t *parser,
+ bool allows_trailing_comma,
+ const pm_token_t *opening,
+ bool is_lambda_literal,
+ bool accepts_blocks_in_defaults,
+ uint16_t depth
+) {
+ pm_parameters_node_t *parameters = NULL;
+ if (!match1(parser, PM_TOKEN_SEMICOLON)) {
+ if (!is_lambda_literal) {
+ context_push(parser, PM_CONTEXT_BLOCK_PARAMETERS);
+ }
+ parameters = parse_parameters(
+ parser,
+ is_lambda_literal ? PM_BINDING_POWER_DEFINED : PM_BINDING_POWER_INDEX,
+ false,
+ allows_trailing_comma,
+ false,
+ accepts_blocks_in_defaults,
+ true,
+ is_lambda_literal ? PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA : PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK,
+ (uint16_t) (depth + 1)
+ );
+ if (!is_lambda_literal) {
+ context_pop(parser);
+ }
+ }
+
+ pm_block_parameters_node_t *block_parameters = pm_block_parameters_node_create(parser, parameters, opening);
+ if (opening != NULL) {
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (accept1(parser, PM_TOKEN_SEMICOLON)) {
+ do {
+ switch (parser->current.type) {
+ case PM_TOKEN_CONSTANT:
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_FORMAL_CONSTANT);
+ parser_lex(parser);
+ break;
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_FORMAL_IVAR);
+ parser_lex(parser);
+ break;
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_FORMAL_GLOBAL);
+ parser_lex(parser);
+ break;
+ case PM_TOKEN_CLASS_VARIABLE:
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_FORMAL_CLASS);
+ parser_lex(parser);
+ break;
+ default:
+ expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE);
+ break;
+ }
+
+ bool repeated = pm_parser_parameter_name_check(parser, &parser->previous);
+ pm_parser_local_add_token(parser, &parser->previous, 1);
+
+ pm_block_local_variable_node_t *local = pm_block_local_variable_node_create(parser, &parser->previous);
+ if (repeated) pm_node_flag_set_repeated_parameter(UP(local));
+
+ pm_block_parameters_node_append_local(parser->arena, block_parameters, local);
+ } while (accept1(parser, PM_TOKEN_COMMA));
+ }
+ }
+
+ return block_parameters;
+}
+
+/**
+ * Return true if any of the visible scopes to the current context are using
+ * numbered parameters.
+ */
+static bool
+outer_scope_using_numbered_parameters_p(pm_parser_t *parser) {
+ for (pm_scope_t *scope = parser->current_scope->previous; scope != NULL && !scope->closed; scope = scope->previous) {
+ if (scope->parameters & PM_SCOPE_PARAMETERS_NUMBERED_FOUND) return true;
+ }
+
+ return false;
+}
+
+/**
+ * These are the names of the various numbered parameters. We have them here so
+ * that when we insert them into the constant pool we can use a constant string
+ * and not have to allocate.
+ */
+static const char * const pm_numbered_parameter_names[] = {
+ "_1", "_2", "_3", "_4", "_5", "_6", "_7", "_8", "_9"
+};
+
+/**
+ * Return the node that should be used in the parameters field of a block-like
+ * (block or lambda) node, depending on the kind of parameters that were
+ * declared in the current scope.
+ */
+static pm_node_t *
+parse_blocklike_parameters(pm_parser_t *parser, pm_node_t *parameters, const pm_token_t *opening, const pm_token_t *closing) {
+ pm_node_list_t *implicit_parameters = &parser->current_scope->implicit_parameters;
+
+ // If we have ordinary parameters, then we will return them as the set of
+ // parameters.
+ if (parameters != NULL) {
+ // If we also have implicit parameters, then this is an error.
+ if (implicit_parameters->size > 0) {
+ pm_node_t *node = implicit_parameters->nodes[0];
+
+ if (PM_NODE_TYPE_P(node, PM_LOCAL_VARIABLE_READ_NODE)) {
+ pm_parser_err_node(parser, node, PM_ERR_NUMBERED_PARAMETER_ORDINARY);
+ } else if (PM_NODE_TYPE_P(node, PM_IT_LOCAL_VARIABLE_READ_NODE)) {
+ pm_parser_err_node(parser, node, PM_ERR_IT_NOT_ALLOWED_ORDINARY);
+ } else {
+ assert(false && "unreachable");
+ }
+ }
+
+ return parameters;
+ }
+
+ // If we don't have any implicit parameters, then the set of parameters is
+ // NULL.
+ if (implicit_parameters->size == 0) {
+ return NULL;
+ }
+
+ // If we don't have ordinary parameters, then we now must validate our set
+ // of implicit parameters. We can only have numbered parameters or it, but
+ // they cannot be mixed.
+ uint8_t numbered_parameter = 0;
+ bool it_parameter = false;
+
+ for (size_t index = 0; index < implicit_parameters->size; index++) {
+ pm_node_t *node = implicit_parameters->nodes[index];
+
+ if (PM_NODE_TYPE_P(node, PM_LOCAL_VARIABLE_READ_NODE)) {
+ if (it_parameter) {
+ pm_parser_err_node(parser, node, PM_ERR_NUMBERED_PARAMETER_IT);
+ } else if (outer_scope_using_numbered_parameters_p(parser)) {
+ pm_parser_err_node(parser, node, PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK);
+ } else if (parser->current_scope->parameters & PM_SCOPE_PARAMETERS_NUMBERED_INNER) {
+ pm_parser_err_node(parser, node, PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK);
+ } else if (pm_token_is_numbered_parameter(parser, PM_NODE_START(node), PM_NODE_LENGTH(node))) {
+ numbered_parameter = MAX(numbered_parameter, (uint8_t) (parser->start[node->location.start + 1] - '0'));
+ } else {
+ assert(false && "unreachable");
+ }
+ } else if (PM_NODE_TYPE_P(node, PM_IT_LOCAL_VARIABLE_READ_NODE)) {
+ if (numbered_parameter > 0) {
+ pm_parser_err_node(parser, node, PM_ERR_IT_NOT_ALLOWED_NUMBERED);
+ } else {
+ it_parameter = true;
+ }
+ }
+ }
+
+ if (numbered_parameter > 0) {
+ // Go through the parent scopes and mark them as being disallowed from
+ // using numbered parameters because this inner scope is using them.
+ for (pm_scope_t *scope = parser->current_scope->previous; scope != NULL && !scope->closed; scope = scope->previous) {
+ scope->parameters |= PM_SCOPE_PARAMETERS_NUMBERED_INNER;
+ }
+ return UP(pm_numbered_parameters_node_create(parser, opening, closing, numbered_parameter));
+ }
+
+ if (it_parameter) {
+ return UP(pm_it_parameters_node_create(parser, opening, closing));
+ }
+
+ return NULL;
+}
+
+/**
+ * Parse a block.
+ */
+static pm_block_node_t *
+parse_block(pm_parser_t *parser, uint16_t depth) {
+ pm_token_t opening = parser->previous;
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ pm_accepts_block_stack_push(parser, true);
+ pm_parser_scope_push(parser, false);
+
+ pm_block_parameters_node_t *block_parameters = NULL;
+
+ if (accept1(parser, PM_TOKEN_PIPE)) {
+ pm_token_t block_parameters_opening = parser->previous;
+ if (match1(parser, PM_TOKEN_PIPE)) {
+ block_parameters = pm_block_parameters_node_create(parser, NULL, &block_parameters_opening);
+ parser->command_start = true;
+ parser_lex(parser);
+ } else {
+ block_parameters = parse_block_parameters(parser, true, &block_parameters_opening, false, true, (uint16_t) (depth + 1));
+ accept1(parser, PM_TOKEN_NEWLINE);
+ parser->command_start = true;
+ expect1(parser, PM_TOKEN_PIPE, PM_ERR_BLOCK_PARAM_PIPE_TERM);
+ }
+
+ pm_block_parameters_node_closing_set(parser, block_parameters, &parser->previous);
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ pm_node_t *statements = NULL;
+
+ if (opening.type == PM_TOKEN_BRACE_LEFT) {
+ if (!match1(parser, PM_TOKEN_BRACE_RIGHT)) {
+ statements = UP(parse_statements(parser, PM_CONTEXT_BLOCK_BRACES, (uint16_t) (depth + 1)));
+ }
+
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_BLOCK_TERM_BRACE, &opening);
+ } else {
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ if (!match3(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_ENSURE)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = UP(parse_statements(parser, PM_CONTEXT_BLOCK_KEYWORDS, (uint16_t) (depth + 1)));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) {
+ assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE));
+ statements = UP(parse_rescues_implicit_begin(parser, 0, NULL, opening.start, (pm_statements_node_t *) statements, PM_RESCUES_BLOCK, (uint16_t) (depth + 1)));
+ }
+ }
+
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_BLOCK_TERM_END, &opening);
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, pm_parser_scope_toplevel_p(parser));
+ pm_node_t *parameters = parse_blocklike_parameters(parser, UP(block_parameters), &opening, &parser->previous);
+
+ pm_parser_scope_pop(parser);
+ pm_accepts_block_stack_pop(parser);
+
+ return pm_block_node_create(parser, &locals, &opening, parameters, statements, &parser->previous);
+}
+
+/**
+ * Parse a list of arguments and their surrounding parentheses if they are
+ * present. It returns true if it found any pieces of arguments (parentheses,
+ * arguments, or blocks).
+ */
+static bool
+parse_arguments_list(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_block, uint8_t flags, uint16_t depth) {
+ /* Fast path: if the current token can't begin an expression and isn't
+ * a parenthesis, block opener, or splat/block-pass operator, there are
+ * no arguments to parse. */
+ if (
+ !token_begins_expression_p(parser->current.type) &&
+ !match6(parser, PM_TOKEN_PARENTHESIS_LEFT, PM_TOKEN_KEYWORD_DO, PM_TOKEN_KEYWORD_DO_BLOCK, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR, PM_TOKEN_UAMPERSAND)
+ ) {
+ return false;
+ }
+
+ bool found = false;
+ bool parsed_command_args = false;
+
+ if (accept1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ found |= true;
+ arguments->opening_loc = TOK2LOC(parser, &parser->previous);
+
+ if (accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ arguments->closing_loc = TOK2LOC(parser, &parser->previous);
+ } else {
+ pm_accepts_block_stack_push(parser, true);
+ parse_arguments(parser, arguments, accepts_block, PM_TOKEN_PARENTHESIS_RIGHT, (uint8_t) (flags & ~PM_PARSE_ACCEPTS_DO_BLOCK), (uint16_t) (depth + 1));
+
+ if (!accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_ARGUMENT_TERM_PAREN, pm_token_str(parser->current.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+
+ pm_accepts_block_stack_pop(parser);
+ arguments->closing_loc = TOK2LOC(parser, &parser->previous);
+ }
+ } else if ((flags & PM_PARSE_ACCEPTS_COMMAND_CALL) && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR, PM_TOKEN_UAMPERSAND)) && !match1(parser, PM_TOKEN_BRACE_LEFT)) {
+ found |= true;
+ parsed_command_args = true;
+ pm_accepts_block_stack_push(parser, false);
+
+ // If we get here, then the subsequent token cannot be used as an infix
+ // operator. In this case we assume the subsequent token is part of an
+ // argument to this method call.
+ parse_arguments(parser, arguments, accepts_block, PM_TOKEN_EOF, flags, (uint16_t) (depth + 1));
+
+ // If we have done with the arguments and still not consumed the comma,
+ // then we have a trailing comma where we need to check whether it is
+ // allowed or not.
+ if (parser->previous.type == PM_TOKEN_COMMA && !match1(parser, PM_TOKEN_SEMICOLON)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, PM_ERR_EXPECT_ARGUMENT, pm_token_str(parser->current.type));
+ }
+
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ // If we're at the end of the arguments, we can now check if there is a block
+ // node that starts with a {. If there is, then we can parse it and add it to
+ // the arguments.
+ if (accepts_block) {
+ pm_block_node_t *block = NULL;
+
+ if (accept1(parser, PM_TOKEN_BRACE_LEFT)) {
+ found |= true;
+ block = parse_block(parser, (uint16_t) (depth + 1));
+ pm_arguments_validate_block(parser, arguments, block);
+ } else if (pm_accepts_block_stack_p(parser) && accept1(parser, PM_TOKEN_KEYWORD_DO)) {
+ found |= true;
+ block = parse_block(parser, (uint16_t) (depth + 1));
+ } else if (parsed_command_args && pm_accepts_block_stack_p(parser) && (flags & PM_PARSE_ACCEPTS_DO_BLOCK) && accept1(parser, PM_TOKEN_KEYWORD_DO_BLOCK)) {
+ found |= true;
+ block = parse_block(parser, (uint16_t) (depth + 1));
+ }
+
+ if (block != NULL) {
+ if (arguments->block == NULL && !arguments->has_forwarding) {
+ arguments->block = UP(block);
+ } else {
+ pm_parser_err_node(parser, UP(block), PM_ERR_ARGUMENT_BLOCK_MULTI);
+
+ if (arguments->block != NULL) {
+ if (arguments->arguments == NULL) {
+ arguments->arguments = pm_arguments_node_create(parser);
+ }
+ pm_arguments_node_arguments_append(parser->arena, arguments->arguments, arguments->block);
+ }
+ arguments->block = UP(block);
+ }
+ }
+ }
+
+ return found;
+}
+
+/**
+ * Check that the return is allowed in the current context. If it isn't, add an
+ * error to the parser.
+ */
+static void
+parse_return(pm_parser_t *parser, pm_node_t *node) {
+ bool in_sclass = false;
+ for (pm_context_node_t *context_node = parser->current_context; context_node != NULL; context_node = context_node->prev) {
+ switch (context_node->context) {
+ case PM_CONTEXT_BEGIN_ELSE:
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_BEGIN_RESCUE:
+ case PM_CONTEXT_BEGIN:
+ case PM_CONTEXT_CASE_IN:
+ case PM_CONTEXT_CASE_WHEN:
+ case PM_CONTEXT_DEFAULT_PARAMS:
+ case PM_CONTEXT_DEFINED:
+ case PM_CONTEXT_ELSE:
+ case PM_CONTEXT_ELSIF:
+ case PM_CONTEXT_EMBEXPR:
+ case PM_CONTEXT_FOR_INDEX:
+ case PM_CONTEXT_FOR:
+ case PM_CONTEXT_IF:
+ case PM_CONTEXT_LOOP_PREDICATE:
+ case PM_CONTEXT_MAIN:
+ case PM_CONTEXT_MULTI_TARGET:
+ case PM_CONTEXT_PARENS:
+ case PM_CONTEXT_POSTEXE:
+ case PM_CONTEXT_PREDICATE:
+ case PM_CONTEXT_PREEXE:
+ case PM_CONTEXT_RESCUE_MODIFIER:
+ case PM_CONTEXT_TERNARY:
+ case PM_CONTEXT_UNLESS:
+ case PM_CONTEXT_UNTIL:
+ case PM_CONTEXT_WHILE:
+ // Keep iterating up the lists of contexts, because returns can
+ // see through these.
+ continue;
+ case PM_CONTEXT_SCLASS_ELSE:
+ case PM_CONTEXT_SCLASS_ENSURE:
+ case PM_CONTEXT_SCLASS_RESCUE:
+ case PM_CONTEXT_SCLASS:
+ in_sclass = true;
+ continue;
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_CLASS:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_MODULE:
+ // These contexts are invalid for a return.
+ pm_parser_err_node(parser, node, PM_ERR_RETURN_INVALID);
+ return;
+ case PM_CONTEXT_BLOCK_BRACES:
+ case PM_CONTEXT_BLOCK_ELSE:
+ case PM_CONTEXT_BLOCK_ENSURE:
+ case PM_CONTEXT_BLOCK_KEYWORDS:
+ case PM_CONTEXT_BLOCK_RESCUE:
+ case PM_CONTEXT_BLOCK_PARAMETERS:
+ case PM_CONTEXT_DEF_ELSE:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_DEF_PARAMS:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_DEF:
+ case PM_CONTEXT_LAMBDA_BRACES:
+ case PM_CONTEXT_LAMBDA_DO_END:
+ case PM_CONTEXT_LAMBDA_ELSE:
+ case PM_CONTEXT_LAMBDA_ENSURE:
+ case PM_CONTEXT_LAMBDA_RESCUE:
+ // These contexts are valid for a return, and we should not
+ // continue to loop.
+ return;
+ case PM_CONTEXT_NONE:
+ // This case should never happen.
+ assert(false && "unreachable");
+ break;
+ }
+ }
+ if (in_sclass && parser->version >= PM_OPTIONS_VERSION_CRUBY_3_4) {
+ pm_parser_err_node(parser, node, PM_ERR_RETURN_INVALID);
+ }
+}
+
+/**
+ * Check that the block exit (next, break, redo) is allowed in the current
+ * context. If it isn't, add an error to the parser.
+ */
+static void
+parse_block_exit(pm_parser_t *parser, pm_node_t *node) {
+ for (pm_context_node_t *context_node = parser->current_context; context_node != NULL; context_node = context_node->prev) {
+ switch (context_node->context) {
+ case PM_CONTEXT_BLOCK_BRACES:
+ case PM_CONTEXT_BLOCK_KEYWORDS:
+ case PM_CONTEXT_BLOCK_ELSE:
+ case PM_CONTEXT_BLOCK_ENSURE:
+ case PM_CONTEXT_BLOCK_PARAMETERS:
+ case PM_CONTEXT_BLOCK_RESCUE:
+ case PM_CONTEXT_DEFINED:
+ case PM_CONTEXT_FOR:
+ case PM_CONTEXT_LAMBDA_BRACES:
+ case PM_CONTEXT_LAMBDA_DO_END:
+ case PM_CONTEXT_LAMBDA_ELSE:
+ case PM_CONTEXT_LAMBDA_ENSURE:
+ case PM_CONTEXT_LAMBDA_RESCUE:
+ case PM_CONTEXT_LOOP_PREDICATE:
+ case PM_CONTEXT_UNTIL:
+ case PM_CONTEXT_WHILE:
+ // These are the good cases. We're allowed to have a block exit
+ // in these contexts.
+ return;
+ case PM_CONTEXT_POSTEXE:
+ // https://bugs.ruby-lang.org/issues/20409
+ if (context_node->context == PM_CONTEXT_POSTEXE) {
+ if (parser->version < PM_OPTIONS_VERSION_CRUBY_4_1) {
+ return;
+ }
+ }
+ PRISM_FALLTHROUGH
+ case PM_CONTEXT_DEF:
+ case PM_CONTEXT_DEF_PARAMS:
+ case PM_CONTEXT_DEF_ELSE:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_MAIN:
+ case PM_CONTEXT_PREEXE:
+ case PM_CONTEXT_SCLASS:
+ case PM_CONTEXT_SCLASS_ELSE:
+ case PM_CONTEXT_SCLASS_ENSURE:
+ case PM_CONTEXT_SCLASS_RESCUE:
+ // These are the bad cases. We're not allowed to have a block
+ // exit in these contexts.
+ //
+ // If we get here, then we're about to mark this block exit
+ // as invalid. However, it could later _become_ valid if we
+ // find a trailing while/until on the expression. In this
+ // case instead of adding the error here, we'll add the
+ // block exit to the list of exits for the expression, and
+ // the node parsing will handle validating it instead.
+ assert(parser->current_block_exits != NULL);
+ pm_node_list_append(parser->arena, parser->current_block_exits, node);
+ return;
+ case PM_CONTEXT_BEGIN_ELSE:
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_BEGIN_RESCUE:
+ case PM_CONTEXT_BEGIN:
+ case PM_CONTEXT_CASE_IN:
+ case PM_CONTEXT_CASE_WHEN:
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_CLASS:
+ case PM_CONTEXT_DEFAULT_PARAMS:
+ case PM_CONTEXT_ELSE:
+ case PM_CONTEXT_ELSIF:
+ case PM_CONTEXT_EMBEXPR:
+ case PM_CONTEXT_FOR_INDEX:
+ case PM_CONTEXT_IF:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_MODULE:
+ case PM_CONTEXT_MULTI_TARGET:
+ case PM_CONTEXT_PARENS:
+ case PM_CONTEXT_PREDICATE:
+ case PM_CONTEXT_RESCUE_MODIFIER:
+ case PM_CONTEXT_TERNARY:
+ case PM_CONTEXT_UNLESS:
+ // In these contexts we should continue walking up the list of
+ // contexts.
+ break;
+ case PM_CONTEXT_NONE:
+ // This case should never happen.
+ assert(false && "unreachable");
+ break;
+ }
+ }
+}
+
+/**
+ * When we hit an expression that could contain block exits, we need to stash
+ * the previous set and create a new one.
+ */
+static pm_node_list_t *
+push_block_exits(pm_parser_t *parser, pm_node_list_t *current_block_exits) {
+ pm_node_list_t *previous_block_exits = parser->current_block_exits;
+ parser->current_block_exits = current_block_exits;
+ return previous_block_exits;
+}
+
+/**
+ * If we did not match a trailing while/until and this was the last chance to do
+ * so, then all of the block exits in the list are invalid and we need to add an
+ * error for each of them.
+ */
+static void
+flush_block_exits(pm_parser_t *parser, pm_node_list_t *previous_block_exits) {
+ pm_node_t *block_exit;
+ PM_NODE_LIST_FOREACH(parser->current_block_exits, index, block_exit) {
+ const char *type;
+
+ switch (PM_NODE_TYPE(block_exit)) {
+ case PM_BREAK_NODE: type = "break"; break;
+ case PM_NEXT_NODE: type = "next"; break;
+ case PM_REDO_NODE: type = "redo"; break;
+ default: assert(false && "unreachable"); type = ""; break;
+ }
+
+ PM_PARSER_ERR_NODE_FORMAT(parser, block_exit, PM_ERR_INVALID_BLOCK_EXIT, type);
+ }
+
+ parser->current_block_exits = previous_block_exits;
+}
+
+/**
+ * Pop the current level of block exits from the parser, and add errors to the
+ * parser if any of them are deemed to be invalid.
+ */
+static void
+pop_block_exits(pm_parser_t *parser, pm_node_list_t *previous_block_exits) {
+ if (match2(parser, PM_TOKEN_KEYWORD_WHILE_MODIFIER, PM_TOKEN_KEYWORD_UNTIL_MODIFIER)) {
+ // If we matched a trailing while/until, then all of the block exits in
+ // the contained list are valid. In this case we do not need to do
+ // anything.
+ parser->current_block_exits = previous_block_exits;
+ } else if (previous_block_exits != NULL) {
+ // If we did not matching a trailing while/until, then all of the block
+ // exits contained in the list are invalid for this specific context.
+ // However, they could still become valid in a higher level context if
+ // there is another list above this one. In this case we'll push all of
+ // the block exits up to the previous list.
+ pm_node_list_concat(parser->arena, previous_block_exits, parser->current_block_exits);
+ parser->current_block_exits = previous_block_exits;
+ } else {
+ // If we did not match a trailing while/until and this was the last
+ // chance to do so, then all of the block exits in the list are invalid
+ // and we need to add an error for each of them.
+ flush_block_exits(parser, previous_block_exits);
+ }
+}
+
+static PRISM_INLINE pm_node_t *
+parse_predicate(pm_parser_t *parser, pm_binding_power_t binding_power, pm_context_t context, pm_token_t *then_keyword, uint16_t depth) {
+ context_push(parser, PM_CONTEXT_PREDICATE);
+ pm_diagnostic_id_t error_id = context == PM_CONTEXT_IF ? PM_ERR_CONDITIONAL_IF_PREDICATE : PM_ERR_CONDITIONAL_UNLESS_PREDICATE;
+ pm_node_t *predicate = parse_value_expression(parser, binding_power, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, error_id, (uint16_t) (depth + 1));
+
+ // Predicates are closed by a term, a "then", or a term and then a "then".
+ bool predicate_closed = accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+
+ if (accept1(parser, PM_TOKEN_KEYWORD_THEN)) {
+ predicate_closed = true;
+ *then_keyword = parser->previous;
+ }
+
+ if (!predicate_closed) {
+ pm_parser_err_current(parser, PM_ERR_CONDITIONAL_PREDICATE_TERM);
+ }
+
+ context_pop(parser);
+ return predicate;
+}
+
+static PRISM_INLINE pm_node_t *
+parse_conditional(pm_parser_t *parser, pm_context_t context, size_t opening_newline_index, bool if_after_else, uint16_t depth) {
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ pm_token_t keyword = parser->previous;
+ pm_token_t then_keyword = { 0 };
+
+ pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_COMPOSITION, context, &then_keyword, (uint16_t) (depth + 1));
+ pm_statements_node_t *statements = NULL;
+
+ if (!match3(parser, PM_TOKEN_KEYWORD_ELSIF, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = parse_statements(parser, context, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ pm_node_t *parent = NULL;
+
+ switch (context) {
+ case PM_CONTEXT_IF:
+ parent = UP(pm_if_node_create(parser, &keyword, predicate, NTOK2PTR(then_keyword), statements, NULL, NULL));
+ break;
+ case PM_CONTEXT_UNLESS:
+ parent = UP(pm_unless_node_create(parser, &keyword, predicate, NTOK2PTR(then_keyword), statements));
+ break;
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+
+ pm_node_t *current = parent;
+
+ // Parse any number of elsif clauses. This will form a linked list of if
+ // nodes pointing to each other from the top.
+ if (context == PM_CONTEXT_IF) {
+ while (match1(parser, PM_TOKEN_KEYWORD_ELSIF)) {
+ if (parser_end_of_line_p(parser)) {
+ PM_PARSER_WARN_TOKEN_FORMAT_CONTENT(parser, &parser->current, PM_WARN_KEYWORD_EOL);
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &keyword, false, false);
+ pm_token_t elsif_keyword = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_COMPOSITION, PM_CONTEXT_ELSIF, &then_keyword, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_push(parser, true);
+
+ pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_ELSIF, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+
+ pm_node_t *elsif = UP(pm_if_node_create(parser, &elsif_keyword, predicate, NTOK2PTR(then_keyword), statements, NULL, NULL));
+ ((pm_if_node_t *) current)->subsequent = elsif;
+ current = elsif;
+ }
+ }
+
+ if (match1(parser, PM_TOKEN_KEYWORD_ELSE)) {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &keyword, false, false);
+ opening_newline_index = token_newline_index(parser);
+
+ parser_lex(parser);
+ pm_token_t else_keyword = parser->previous;
+
+ pm_accepts_block_stack_push(parser, true);
+ pm_statements_node_t *else_statements = parse_statements(parser, PM_CONTEXT_ELSE, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &else_keyword, false, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CONDITIONAL_TERM_ELSE, &keyword);
+
+ pm_else_node_t *else_node = pm_else_node_create(parser, &else_keyword, else_statements, &parser->previous);
+
+ switch (context) {
+ case PM_CONTEXT_IF:
+ ((pm_if_node_t *) current)->subsequent = UP(else_node);
+ break;
+ case PM_CONTEXT_UNLESS:
+ ((pm_unless_node_t *) parent)->else_clause = else_node;
+ break;
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &keyword, if_after_else, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CONDITIONAL_TERM, &keyword);
+ }
+
+ // Set the appropriate end location for all of the nodes in the subtree.
+ switch (context) {
+ case PM_CONTEXT_IF: {
+ pm_node_t *current = parent;
+ bool recursing = true;
+
+ while (recursing) {
+ switch (PM_NODE_TYPE(current)) {
+ case PM_IF_NODE:
+ pm_if_node_end_keyword_loc_set(parser, (pm_if_node_t *) current, &parser->previous);
+ current = ((pm_if_node_t *) current)->subsequent;
+ recursing = current != NULL;
+ break;
+ case PM_ELSE_NODE:
+ pm_else_node_end_keyword_loc_set(parser, (pm_else_node_t *) current, &parser->previous);
+ recursing = false;
+ break;
+ default: {
+ recursing = false;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ case PM_CONTEXT_UNLESS:
+ pm_unless_node_end_keyword_loc_set(parser, (pm_unless_node_t *) parent, &parser->previous);
+ break;
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+
+ pop_block_exits(parser, previous_block_exits);
+ return parent;
+}
+
+/**
+ * This macro allows you to define a case statement for all of the keywords.
+ * It's meant to be used in a switch statement.
+ */
+#define PM_CASE_KEYWORD PM_TOKEN_KEYWORD___ENCODING__: case PM_TOKEN_KEYWORD___FILE__: case PM_TOKEN_KEYWORD___LINE__: \
+ case PM_TOKEN_KEYWORD_ALIAS: case PM_TOKEN_KEYWORD_AND: case PM_TOKEN_KEYWORD_BEGIN: case PM_TOKEN_KEYWORD_BEGIN_UPCASE: \
+ case PM_TOKEN_KEYWORD_BREAK: case PM_TOKEN_KEYWORD_CASE: case PM_TOKEN_KEYWORD_CLASS: case PM_TOKEN_KEYWORD_DEF: \
+ case PM_TOKEN_KEYWORD_DEFINED: case PM_TOKEN_KEYWORD_DO: case PM_TOKEN_KEYWORD_DO_BLOCK: case PM_TOKEN_KEYWORD_DO_LOOP: case PM_TOKEN_KEYWORD_ELSE: \
+ case PM_TOKEN_KEYWORD_ELSIF: case PM_TOKEN_KEYWORD_END: case PM_TOKEN_KEYWORD_END_UPCASE: case PM_TOKEN_KEYWORD_ENSURE: \
+ case PM_TOKEN_KEYWORD_FALSE: case PM_TOKEN_KEYWORD_FOR: case PM_TOKEN_KEYWORD_IF: case PM_TOKEN_KEYWORD_IN: \
+ case PM_TOKEN_KEYWORD_MODULE: case PM_TOKEN_KEYWORD_NEXT: case PM_TOKEN_KEYWORD_NIL: case PM_TOKEN_KEYWORD_NOT: \
+ case PM_TOKEN_KEYWORD_OR: case PM_TOKEN_KEYWORD_REDO: case PM_TOKEN_KEYWORD_RESCUE: case PM_TOKEN_KEYWORD_RETRY: \
+ case PM_TOKEN_KEYWORD_RETURN: case PM_TOKEN_KEYWORD_SELF: case PM_TOKEN_KEYWORD_SUPER: case PM_TOKEN_KEYWORD_THEN: \
+ case PM_TOKEN_KEYWORD_TRUE: case PM_TOKEN_KEYWORD_UNDEF: case PM_TOKEN_KEYWORD_UNLESS: case PM_TOKEN_KEYWORD_UNTIL: \
+ case PM_TOKEN_KEYWORD_WHEN: case PM_TOKEN_KEYWORD_WHILE: case PM_TOKEN_KEYWORD_YIELD
+
+/**
+ * This macro allows you to define a case statement for all of the operators.
+ * It's meant to be used in a switch statement.
+ */
+#define PM_CASE_OPERATOR PM_TOKEN_AMPERSAND: case PM_TOKEN_BACKTICK: case PM_TOKEN_BANG_EQUAL: \
+ case PM_TOKEN_BANG_TILDE: case PM_TOKEN_BANG: case PM_TOKEN_BRACKET_LEFT_RIGHT_EQUAL: \
+ case PM_TOKEN_BRACKET_LEFT_RIGHT: case PM_TOKEN_CARET: case PM_TOKEN_EQUAL_EQUAL_EQUAL: case PM_TOKEN_EQUAL_EQUAL: \
+ case PM_TOKEN_EQUAL_TILDE: case PM_TOKEN_GREATER_EQUAL: case PM_TOKEN_GREATER_GREATER: case PM_TOKEN_GREATER: \
+ case PM_TOKEN_LESS_EQUAL_GREATER: case PM_TOKEN_LESS_EQUAL: case PM_TOKEN_LESS_LESS: case PM_TOKEN_LESS: \
+ case PM_TOKEN_MINUS: case PM_TOKEN_PERCENT: case PM_TOKEN_PIPE: case PM_TOKEN_PLUS: case PM_TOKEN_SLASH: \
+ case PM_TOKEN_STAR_STAR: case PM_TOKEN_STAR: case PM_TOKEN_TILDE: case PM_TOKEN_UAMPERSAND: case PM_TOKEN_UMINUS: \
+ case PM_TOKEN_UMINUS_NUM: case PM_TOKEN_UPLUS: case PM_TOKEN_USTAR: case PM_TOKEN_USTAR_STAR
+
+/**
+ * This macro allows you to define a case statement for all of the token types
+ * that represent the beginning of nodes that are "primitives" in a pattern
+ * matching expression.
+ */
+#define PM_CASE_PRIMITIVE PM_TOKEN_INTEGER: case PM_TOKEN_INTEGER_IMAGINARY: case PM_TOKEN_INTEGER_RATIONAL: \
+ case PM_TOKEN_INTEGER_RATIONAL_IMAGINARY: case PM_TOKEN_FLOAT: case PM_TOKEN_FLOAT_IMAGINARY: \
+ case PM_TOKEN_FLOAT_RATIONAL: case PM_TOKEN_FLOAT_RATIONAL_IMAGINARY: case PM_TOKEN_SYMBOL_BEGIN: \
+ case PM_TOKEN_REGEXP_BEGIN: case PM_TOKEN_BACKTICK: case PM_TOKEN_PERCENT_LOWER_X: case PM_TOKEN_PERCENT_LOWER_I: \
+ case PM_TOKEN_PERCENT_LOWER_W: case PM_TOKEN_PERCENT_UPPER_I: case PM_TOKEN_PERCENT_UPPER_W: \
+ case PM_TOKEN_STRING_BEGIN: case PM_TOKEN_KEYWORD_NIL: case PM_TOKEN_KEYWORD_SELF: case PM_TOKEN_KEYWORD_TRUE: \
+ case PM_TOKEN_KEYWORD_FALSE: case PM_TOKEN_KEYWORD___FILE__: case PM_TOKEN_KEYWORD___LINE__: \
+ case PM_TOKEN_KEYWORD___ENCODING__: case PM_TOKEN_MINUS_GREATER: case PM_TOKEN_HEREDOC_START: \
+ case PM_TOKEN_UMINUS_NUM: case PM_TOKEN_CHARACTER_LITERAL
+
+/**
+ * This macro allows you to define a case statement for all of the token types
+ * that could begin a parameter.
+ */
+#define PM_CASE_PARAMETER PM_TOKEN_UAMPERSAND: case PM_TOKEN_AMPERSAND: case PM_TOKEN_UDOT_DOT_DOT: \
+ case PM_TOKEN_IDENTIFIER: case PM_TOKEN_LABEL: case PM_TOKEN_USTAR: case PM_TOKEN_STAR: case PM_TOKEN_STAR_STAR: \
+ case PM_TOKEN_USTAR_STAR: case PM_TOKEN_CONSTANT: case PM_TOKEN_INSTANCE_VARIABLE: case PM_TOKEN_GLOBAL_VARIABLE: \
+ case PM_TOKEN_CLASS_VARIABLE
+
+/**
+ * This macro allows you to define a case statement for all of the nodes that
+ * can be transformed into write targets.
+ */
+#define PM_CASE_WRITABLE PM_CLASS_VARIABLE_READ_NODE: case PM_CONSTANT_PATH_NODE: \
+ case PM_CONSTANT_READ_NODE: case PM_GLOBAL_VARIABLE_READ_NODE: case PM_LOCAL_VARIABLE_READ_NODE: \
+ case PM_INSTANCE_VARIABLE_READ_NODE: case PM_MULTI_TARGET_NODE: case PM_BACK_REFERENCE_READ_NODE: \
+ case PM_NUMBERED_REFERENCE_READ_NODE: case PM_IT_LOCAL_VARIABLE_READ_NODE
+
+// Assert here that the flags are the same so that we can safely switch the type
+// of the node without having to move the flags.
+PM_STATIC_ASSERT(__LINE__, ((int) PM_STRING_FLAGS_FORCED_UTF8_ENCODING) == ((int) PM_ENCODING_FLAGS_FORCED_UTF8_ENCODING), "Expected the flags to match.");
+
+/**
+ * If the encoding was explicitly set through the lexing process, then we need
+ * to potentially mark the string's flags to indicate how to encode it.
+ */
+static PRISM_INLINE pm_node_flags_t
+parse_unescaped_encoding(const pm_parser_t *parser) {
+ if (parser->explicit_encoding != NULL) {
+ if (parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY) {
+ // If the there's an explicit encoding and it's using a UTF-8 escape
+ // sequence, then mark the string as UTF-8.
+ return PM_STRING_FLAGS_FORCED_UTF8_ENCODING;
+ } else if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY) {
+ // If there's a non-UTF-8 escape sequence being used, then the
+ // string uses the source encoding, unless the source is marked as
+ // US-ASCII. In that case the string is forced as ASCII-8BIT in
+ // order to keep the string valid.
+ return PM_STRING_FLAGS_FORCED_BINARY_ENCODING;
+ }
+ }
+ return 0;
+}
+
+/**
+ * Parse a node that is part of a string. If the subsequent tokens cannot be
+ * parsed as a string part, then NULL is returned.
+ */
+static pm_node_t *
+parse_string_part(pm_parser_t *parser, uint16_t depth) {
+ switch (parser->current.type) {
+ // Here the lexer has returned to us plain string content. In this case
+ // we'll create a string node that has no opening or closing and return that
+ // as the part. These kinds of parts look like:
+ //
+ // "aaa #{bbb} #@ccc ddd"
+ // ^^^^ ^ ^^^^
+ case PM_TOKEN_STRING_CONTENT: {
+ pm_node_t *node = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+ pm_node_flag_set(node, parse_unescaped_encoding(parser));
+
+ parser_lex(parser);
+ return node;
+ }
+ // Here the lexer has returned the beginning of an embedded expression. In
+ // that case we'll parse the inner statements and return that as the part.
+ // These kinds of parts look like:
+ //
+ // "aaa #{bbb} #@ccc ddd"
+ // ^^^^^^
+ case PM_TOKEN_EMBEXPR_BEGIN: {
+ // Ruby disallows seeing encoding around interpolation in strings,
+ // even though it is known at parse time.
+ parser->explicit_encoding = NULL;
+
+ pm_lex_state_t state = parser->lex_state;
+ int brace_nesting = parser->brace_nesting;
+
+ parser->brace_nesting = 0;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser_lex(parser);
+
+ pm_token_t opening = parser->previous;
+ pm_statements_node_t *statements = NULL;
+
+ if (!match3(parser, PM_TOKEN_EMBEXPR_END, PM_TOKEN_HEREDOC_END, PM_TOKEN_EOF)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = parse_statements(parser, PM_CONTEXT_EMBEXPR, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ parser->brace_nesting = brace_nesting;
+ lex_state_set(parser, state);
+ expect1(parser, PM_TOKEN_EMBEXPR_END, PM_ERR_EMBEXPR_END);
+
+ // If this set of embedded statements only contains a single
+ // statement, then Ruby does not consider it as a possible statement
+ // that could emit a line event.
+ if (statements != NULL && statements->body.size == 1) {
+ pm_node_flag_unset(statements->body.nodes[0], PM_NODE_FLAG_NEWLINE);
+ }
+
+ return UP(pm_embedded_statements_node_create(parser, &opening, statements, &parser->previous));
+ }
+
+ // Here the lexer has returned the beginning of an embedded variable.
+ // In that case we'll parse the variable and create an appropriate node
+ // for it and then return that node. These kinds of parts look like:
+ //
+ // "aaa #{bbb} #@ccc ddd"
+ // ^^^^^
+ case PM_TOKEN_EMBVAR: {
+ // Ruby disallows seeing encoding around interpolation in strings,
+ // even though it is known at parse time.
+ parser->explicit_encoding = NULL;
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *variable;
+
+ switch (parser->current.type) {
+ // In this case a back reference is being interpolated. We'll
+ // create a global variable read node.
+ case PM_TOKEN_BACK_REFERENCE:
+ parser_lex(parser);
+ variable = UP(pm_back_reference_read_node_create(parser, &parser->previous));
+ break;
+ // In this case an nth reference is being interpolated. We'll
+ // create a global variable read node.
+ case PM_TOKEN_NUMBERED_REFERENCE:
+ parser_lex(parser);
+ variable = UP(pm_numbered_reference_read_node_create(parser, &parser->previous));
+ break;
+ // In this case a global variable is being interpolated. We'll
+ // create a global variable read node.
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ parser_lex(parser);
+ variable = UP(pm_global_variable_read_node_create(parser, &parser->previous));
+ break;
+ // In this case an instance variable is being interpolated.
+ // We'll create an instance variable read node.
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ parser_lex(parser);
+ variable = UP(pm_instance_variable_read_node_create(parser, &parser->previous));
+ break;
+ // In this case a class variable is being interpolated. We'll
+ // create a class variable read node.
+ case PM_TOKEN_CLASS_VARIABLE:
+ parser_lex(parser);
+ variable = UP(pm_class_variable_read_node_create(parser, &parser->previous));
+ break;
+ // We can hit here if we got an invalid token. In that case
+ // we'll not attempt to lex this token and instead just return a
+ // missing node.
+ default:
+ expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_EMBVAR_INVALID);
+ variable = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ break;
+ }
+
+ return UP(pm_embedded_variable_node_create(parser, &operator, variable));
+ }
+ default:
+ parser_lex(parser);
+ pm_parser_err_previous(parser, PM_ERR_CANNOT_PARSE_STRING_PART);
+ return NULL;
+ }
+}
+
+/**
+ * When creating a symbol, unary operators that cannot be binary operators
+ * automatically drop trailing `@` characters. This happens at the parser level,
+ * such that `~@` is parsed as `~` and `!@` is parsed as `!`. We do that here.
+ */
+static const uint8_t *
+parse_operator_symbol_name(const pm_token_t *name) {
+ switch (name->type) {
+ case PM_TOKEN_TILDE:
+ case PM_TOKEN_BANG:
+ if (name->end[-1] == '@') return name->end - 1;
+ PRISM_FALLTHROUGH
+ default:
+ return name->end;
+ }
+}
+
+static pm_node_t *
+parse_operator_symbol(pm_parser_t *parser, const pm_token_t *opening, pm_lex_state_t next_state) {
+ pm_symbol_node_t *symbol = pm_symbol_node_create(parser, opening, &parser->current, NULL);
+ const uint8_t *end = parse_operator_symbol_name(&parser->current);
+
+ if (next_state != PM_LEX_STATE_NONE) lex_state_set(parser, next_state);
+ parser_lex(parser);
+
+ pm_string_shared_init(&symbol->unescaped, parser->previous.start, end);
+ pm_node_flag_set(UP(symbol), PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING);
+
+ return UP(symbol);
+}
+
+/**
+ * Parse a symbol node. This function will get called immediately after finding
+ * a symbol opening token. This handles parsing bare symbols and interpolated
+ * symbols.
+ */
+static pm_node_t *
+parse_symbol(pm_parser_t *parser, pm_lex_mode_t *lex_mode, pm_lex_state_t next_state, uint16_t depth) {
+ const pm_token_t opening = parser->previous;
+
+ if (lex_mode->mode != PM_LEX_STRING) {
+ if (next_state != PM_LEX_STATE_NONE) lex_state_set(parser, next_state);
+
+ switch (parser->current.type) {
+ case PM_CASE_OPERATOR:
+ return parse_operator_symbol(parser, &opening, next_state == PM_LEX_STATE_NONE ? PM_LEX_STATE_ENDFN : next_state);
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ case PM_TOKEN_METHOD_NAME:
+ case PM_TOKEN_CLASS_VARIABLE:
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ case PM_TOKEN_NUMBERED_REFERENCE:
+ case PM_TOKEN_BACK_REFERENCE:
+ case PM_CASE_KEYWORD:
+ parser_lex(parser);
+ break;
+ default:
+ expect2(parser, PM_TOKEN_IDENTIFIER, PM_TOKEN_METHOD_NAME, PM_ERR_SYMBOL_INVALID);
+ break;
+ }
+
+ pm_symbol_node_t *symbol = pm_symbol_node_create(parser, &opening, &parser->previous, NULL);
+ pm_string_shared_init(&symbol->unescaped, parser->previous.start, parser->previous.end);
+ pm_node_flag_set(UP(symbol), parse_symbol_encoding(parser, &parser->previous, &symbol->unescaped, false));
+
+ return UP(symbol);
+ }
+
+ if (lex_mode->as.string.interpolation) {
+ // If we have the end of the symbol, then we can return an empty symbol.
+ if (match1(parser, PM_TOKEN_STRING_END)) {
+ if (next_state != PM_LEX_STATE_NONE) lex_state_set(parser, next_state);
+ parser_lex(parser);
+ pm_token_t content = {
+ .type = PM_TOKEN_STRING_CONTENT,
+ .start = parser->previous.start,
+ .end = parser->previous.start
+ };
+
+ return UP(pm_symbol_node_create(parser, &opening, &content, &parser->previous));
+ }
+
+ // Now we can parse the first part of the symbol.
+ pm_node_t *part = parse_string_part(parser, (uint16_t) (depth + 1));
+
+ // If we got a string part, then it's possible that we could transform
+ // what looks like an interpolated symbol into a regular symbol.
+ if (part && PM_NODE_TYPE_P(part, PM_STRING_NODE) && match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ if (next_state != PM_LEX_STATE_NONE) lex_state_set(parser, next_state);
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_SYMBOL_TERM_INTERPOLATED);
+
+ return UP(pm_string_node_to_symbol_node(parser, (pm_string_node_t *) part, &opening, &parser->previous));
+ }
+
+ pm_interpolated_symbol_node_t *symbol = pm_interpolated_symbol_node_create(parser, &opening, NULL, &opening);
+ if (part) pm_interpolated_symbol_node_append(parser->arena, symbol, part);
+
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_interpolated_symbol_node_append(parser->arena, symbol, part);
+ }
+ }
+
+ if (next_state != PM_LEX_STATE_NONE) lex_state_set(parser, next_state);
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_SYMBOL_TERM_INTERPOLATED);
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_SYMBOL_TERM_INTERPOLATED);
+ }
+
+ pm_interpolated_symbol_node_closing_loc_set(parser, symbol, &parser->previous);
+ return UP(symbol);
+ }
+
+ pm_token_t content;
+ pm_string_t unescaped;
+
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ content = parser->current;
+ unescaped = parser->current_string;
+ parser_lex(parser);
+
+ // If we have two string contents in a row, then the content of this
+ // symbol is split because of heredoc contents. This looks like:
+ //
+ // <<A; :'a
+ // A
+ // b'
+ //
+ // In this case, the best way we have to represent this is as an
+ // interpolated string node, so that's what we'll do here.
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ pm_interpolated_symbol_node_t *symbol = pm_interpolated_symbol_node_create(parser, &opening, NULL, &opening);
+ pm_node_t *part = UP(pm_string_node_create_unescaped(parser, NULL, &content, NULL, &unescaped));
+ pm_interpolated_symbol_node_append(parser->arena, symbol, part);
+
+ part = UP(pm_string_node_create_unescaped(parser, NULL, &parser->current, NULL, &parser->current_string));
+ pm_interpolated_symbol_node_append(parser->arena, symbol, part);
+
+ if (next_state != PM_LEX_STATE_NONE) {
+ lex_state_set(parser, next_state);
+ }
+
+ parser_lex(parser);
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_SYMBOL_TERM_DYNAMIC);
+
+ pm_interpolated_symbol_node_closing_loc_set(parser, symbol, &parser->previous);
+ return UP(symbol);
+ }
+ } else {
+ content = (pm_token_t) { .type = PM_TOKEN_STRING_CONTENT, .start = parser->previous.end, .end = parser->previous.end };
+ pm_string_shared_init(&unescaped, content.start, content.end);
+ }
+
+ if (next_state != PM_LEX_STATE_NONE) {
+ lex_state_set(parser, next_state);
+ }
+
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_SYMBOL_TERM_DYNAMIC);
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_SYMBOL_TERM_DYNAMIC);
+ }
+
+ return UP(pm_symbol_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped, parse_symbol_encoding(parser, &content, &unescaped, false)));
+}
+
+/**
+ * Parse an argument to undef which can either be a bare word, a symbol, a
+ * constant, or an interpolated symbol.
+ */
+static PRISM_INLINE pm_node_t *
+parse_undef_argument(pm_parser_t *parser, uint16_t depth) {
+ switch (parser->current.type) {
+ case PM_CASE_OPERATOR:
+ return parse_operator_symbol(parser, NULL, PM_LEX_STATE_NONE);
+ case PM_CASE_KEYWORD:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+
+ pm_symbol_node_t *symbol = pm_symbol_node_create(parser, NULL, &parser->previous, NULL);
+ pm_string_shared_init(&symbol->unescaped, parser->previous.start, parser->previous.end);
+ pm_node_flag_set(UP(symbol), parse_symbol_encoding(parser, &parser->previous, &symbol->unescaped, false));
+
+ return UP(symbol);
+ }
+ case PM_TOKEN_SYMBOL_BEGIN: {
+ pm_lex_mode_t lex_mode = *parser->lex_modes.current;
+ parser_lex(parser);
+
+ return parse_symbol(parser, &lex_mode, PM_LEX_STATE_NONE, (uint16_t) (depth + 1));
+ }
+ default:
+ pm_parser_err_current(parser, PM_ERR_UNDEF_ARGUMENT);
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ }
+}
+
+/**
+ * Parse an argument to alias which can either be a bare word, a symbol, an
+ * interpolated symbol or a global variable. If this is the first argument, then
+ * we need to set the lex state to PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM
+ * between the first and second arguments.
+ */
+static PRISM_INLINE pm_node_t *
+parse_alias_argument(pm_parser_t *parser, bool first, uint16_t depth) {
+ switch (parser->current.type) {
+ case PM_CASE_OPERATOR:
+ return parse_operator_symbol(parser, NULL, first ? PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM : PM_LEX_STATE_NONE);
+ case PM_CASE_KEYWORD:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ if (first) lex_state_set(parser, PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM);
+ parser_lex(parser);
+
+ pm_symbol_node_t *symbol = pm_symbol_node_create(parser, NULL, &parser->previous, NULL);
+ pm_string_shared_init(&symbol->unescaped, parser->previous.start, parser->previous.end);
+ pm_node_flag_set(UP(symbol), parse_symbol_encoding(parser, &parser->previous, &symbol->unescaped, false));
+
+ return UP(symbol);
+ }
+ case PM_TOKEN_SYMBOL_BEGIN: {
+ pm_lex_mode_t lex_mode = *parser->lex_modes.current;
+ parser_lex(parser);
+
+ return parse_symbol(parser, &lex_mode, first ? PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM : PM_LEX_STATE_NONE, (uint16_t) (depth + 1));
+ }
+ case PM_TOKEN_BACK_REFERENCE:
+ parser_lex(parser);
+ return UP(pm_back_reference_read_node_create(parser, &parser->previous));
+ case PM_TOKEN_NUMBERED_REFERENCE:
+ parser_lex(parser);
+ return UP(pm_numbered_reference_read_node_create(parser, &parser->previous));
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ parser_lex(parser);
+ return UP(pm_global_variable_read_node_create(parser, &parser->previous));
+ default:
+ pm_parser_err_current(parser, PM_ERR_ALIAS_ARGUMENT);
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ }
+}
+
+/**
+ * Parse an identifier into either a local variable read. If the local variable
+ * is not found, it returns NULL instead.
+ */
+static pm_node_t *
+parse_variable(pm_parser_t *parser) {
+ pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &parser->previous);
+ int depth;
+ bool is_numbered_param = pm_token_is_numbered_parameter(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous));
+
+ if (!is_numbered_param && ((depth = pm_parser_local_depth_constant_id(parser, name_id)) != -1)) {
+ return UP(pm_local_variable_read_node_create_constant_id(parser, &parser->previous, name_id, (uint32_t) depth, false));
+ }
+
+ pm_scope_t *current_scope = parser->current_scope;
+ if (!current_scope->closed && !(current_scope->parameters & PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED)) {
+ if (is_numbered_param) {
+ // When you use a numbered parameter, it implies the existence of
+ // all of the locals that exist before it. For example, referencing
+ // _2 means that _1 must exist. Therefore here we loop through all
+ // of the possibilities and add them into the constant pool.
+ uint8_t maximum = (uint8_t) (parser->previous.start[1] - '0');
+ for (uint8_t number = 1; number <= maximum; number++) {
+ pm_parser_local_add_constant(parser, pm_numbered_parameter_names[number - 1], 2);
+ }
+
+ if (!match1(parser, PM_TOKEN_EQUAL)) {
+ parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_NUMBERED_FOUND;
+ }
+
+ pm_node_t *node = UP(pm_local_variable_read_node_create_constant_id(parser, &parser->previous, name_id, 0, false));
+ pm_node_list_append(parser->arena, &current_scope->implicit_parameters, node);
+
+ return node;
+ } else if ((parser->version >= PM_OPTIONS_VERSION_CRUBY_3_4) && pm_token_is_it(parser->previous.start, parser->previous.end)) {
+ pm_node_t *node = UP(pm_it_local_variable_read_node_create(parser, &parser->previous));
+ pm_node_list_append(parser->arena, &current_scope->implicit_parameters, node);
+
+ return node;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Parse an identifier into either a local variable read or a call.
+ */
+static pm_node_t *
+parse_variable_call(pm_parser_t *parser) {
+ pm_node_flags_t flags = 0;
+
+ if (!match1(parser, PM_TOKEN_PARENTHESIS_LEFT) && (parser->previous.end[-1] != '!') && (parser->previous.end[-1] != '?')) {
+ pm_node_t *node = parse_variable(parser);
+ if (node != NULL) return node;
+ flags |= PM_CALL_NODE_FLAGS_VARIABLE_CALL;
+ }
+
+ pm_call_node_t *node = pm_call_node_variable_call_create(parser, &parser->previous);
+ pm_node_flag_set(UP(node), flags);
+
+ return UP(node);
+}
+
+/**
+ * Parse the method definition name based on the current token available on the
+ * parser. If it does not match a valid method definition name, then a missing
+ * token is returned.
+ */
+static PRISM_INLINE pm_token_t
+parse_method_definition_name(pm_parser_t *parser) {
+ switch (parser->current.type) {
+ case PM_CASE_KEYWORD:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_METHOD_NAME:
+ parser_lex(parser);
+ return parser->previous;
+ case PM_TOKEN_IDENTIFIER:
+ pm_refute_numbered_parameter(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current));
+ parser_lex(parser);
+ return parser->previous;
+ case PM_CASE_OPERATOR:
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ parser_lex(parser);
+ return parser->previous;
+ default:
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_DEF_NAME, pm_token_str(parser->current.type));
+ return (pm_token_t) { .type = 0, .start = parser->current.start, .end = parser->current.end };
+ }
+}
+
+static void
+parse_heredoc_dedent_string(pm_arena_t *arena, pm_string_t *string, size_t common_whitespace) {
+ // Make a writable copy in the arena if the string isn't already writable.
+ // We keep a mutable pointer to the arena memory so we can memmove into it
+ // below without casting away const from the string's source field.
+ uint8_t *writable;
+
+ if (string->type != PM_STRING_OWNED) {
+ size_t length = pm_string_length(string);
+ writable = (uint8_t *) pm_arena_memdup(arena, pm_string_source(string), length, PRISM_ALIGNOF(uint8_t));
+ pm_string_constant_init(string, (const char *) writable, length);
+ } else {
+ writable = (uint8_t *) string->source;
+ }
+
+ // Now get the bounds of the existing string. We'll use this as a
+ // destination to move bytes into. We'll also use it for bounds checking
+ // since we don't require that these strings be null terminated.
+ size_t dest_length = pm_string_length(string);
+ const uint8_t *source_cursor = writable;
+ const uint8_t *source_end = source_cursor + dest_length;
+
+ // We're going to move bytes backward in the string when we get leading
+ // whitespace, so we'll maintain a pointer to the current position in the
+ // string that we're writing to.
+ size_t trimmed_whitespace = 0;
+
+ // While we haven't reached the amount of common whitespace that we need to
+ // trim and we haven't reached the end of the string, we'll keep trimming
+ // whitespace. Trimming in this context means skipping over these bytes such
+ // that they aren't copied into the new string.
+ while ((source_cursor < source_end) && pm_char_is_inline_whitespace(*source_cursor) && trimmed_whitespace < common_whitespace) {
+ if (*source_cursor == '\t') {
+ trimmed_whitespace = (trimmed_whitespace / PM_TAB_WHITESPACE_SIZE + 1) * PM_TAB_WHITESPACE_SIZE;
+ if (trimmed_whitespace > common_whitespace) break;
+ } else {
+ trimmed_whitespace++;
+ }
+
+ source_cursor++;
+ dest_length--;
+ }
+
+ memmove(writable, source_cursor, (size_t) (source_end - source_cursor));
+ string->length = dest_length;
+}
+
+/**
+ * If we end up trimming all of the whitespace from a node and it isn't
+ * part of a line continuation, then we'll drop it from the list entirely.
+ */
+static PRISM_INLINE bool
+heredoc_dedent_discard_string_node(pm_parser_t *parser, pm_string_node_t *string_node) {
+ if (string_node->unescaped.length == 0) {
+ const uint8_t *cursor = parser->start + PM_LOCATION_START(&string_node->content_loc);
+ return pm_memchr(cursor, '\\', string_node->content_loc.length, parser->encoding_changed, parser->encoding) == NULL;
+ }
+ return false;
+}
+
+/**
+ * Take a heredoc node that is indented by a ~ and trim the leading whitespace.
+ */
+static void
+parse_heredoc_dedent(pm_parser_t *parser, pm_node_list_t *nodes, size_t common_whitespace) {
+ // The next node should be dedented if it's the first node in the list or if
+ // it follows a string node.
+ bool dedent_next = true;
+
+ // Iterate over all nodes, and trim whitespace accordingly. We're going to
+ // keep around two indices: a read and a write.
+ size_t write_index = 0;
+
+ pm_node_t *node;
+ PM_NODE_LIST_FOREACH(nodes, read_index, node) {
+ // We're not manipulating child nodes that aren't strings. In this case
+ // we'll skip past it and indicate that the subsequent node should not
+ // be dedented.
+ if (!PM_NODE_TYPE_P(node, PM_STRING_NODE)) {
+ nodes->nodes[write_index++] = node;
+ dedent_next = false;
+ continue;
+ }
+
+ pm_string_node_t *string_node = ((pm_string_node_t *) node);
+ if (dedent_next) {
+ parse_heredoc_dedent_string(parser->arena, &string_node->unescaped, common_whitespace);
+ }
+
+ if (heredoc_dedent_discard_string_node(parser, string_node)) {
+ } else {
+ nodes->nodes[write_index++] = node;
+ }
+
+ // We always dedent the next node if it follows a string node.
+ dedent_next = true;
+ }
+
+ nodes->size = write_index;
+}
+
+/**
+ * Return a string content token at a particular location that is empty.
+ */
+static pm_token_t
+parse_strings_empty_content(const uint8_t *location) {
+ return (pm_token_t) { .type = PM_TOKEN_STRING_CONTENT, .start = location, .end = location };
+}
+
+/**
+ * Parse a set of strings that could be concatenated together.
+ */
+static PRISM_INLINE pm_node_t *
+parse_strings(pm_parser_t *parser, pm_node_t *current, bool accepts_label, uint16_t depth) {
+ assert(parser->current.type == PM_TOKEN_STRING_BEGIN);
+ bool concating = false;
+
+ while (match1(parser, PM_TOKEN_STRING_BEGIN)) {
+ pm_node_t *node = NULL;
+
+ // Here we have found a string literal. We'll parse it and add it to
+ // the list of strings.
+ const pm_lex_mode_t *lex_mode = parser->lex_modes.current;
+ assert(lex_mode->mode == PM_LEX_STRING);
+ bool lex_interpolation = lex_mode->as.string.interpolation;
+ bool label_allowed = lex_mode->as.string.label_allowed && accepts_label;
+
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ if (match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_LITERAL_EOF);
+ // If we get here, then we have an end immediately after a
+ // start. In that case we'll create an empty content token and
+ // return an uninterpolated string.
+ pm_token_t content = parse_strings_empty_content(parser->previous.start);
+ pm_string_node_t *string = pm_string_node_create(parser, &opening, &content, &parser->previous);
+
+ pm_string_shared_init(&string->unescaped, content.start, content.end);
+ node = UP(string);
+ } else if (accept1(parser, PM_TOKEN_LABEL_END)) {
+ // If we get here, then we have an end of a label immediately
+ // after a start. In that case we'll create an empty symbol
+ // node.
+ pm_symbol_node_t *symbol = pm_symbol_node_create(parser, &opening, NULL, &parser->previous);
+ pm_string_shared_init(&symbol->unescaped, parser->previous.start, parser->previous.start);
+ node = UP(symbol);
+
+ if (!label_allowed) pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_LABEL);
+ } else if (!lex_interpolation) {
+ // If we don't accept interpolation then we expect the string to
+ // start with a single string content node.
+ pm_string_t unescaped;
+ pm_token_t content;
+
+ if (match1(parser, PM_TOKEN_EOF)) {
+ unescaped = PM_STRING_EMPTY;
+ content = (pm_token_t) { .type = PM_TOKEN_STRING_CONTENT, .start = parser->start, .end = parser->start };
+ } else {
+ unescaped = parser->current_string;
+ expect1(parser, PM_TOKEN_STRING_CONTENT, PM_ERR_EXPECT_STRING_CONTENT);
+ content = parser->previous;
+ }
+
+ // It is unfortunately possible to have multiple string content
+ // nodes in a row in the case that there's heredoc content in
+ // the middle of the string, like this cursed example:
+ //
+ // <<-END+'b
+ // a
+ // END
+ // c'+'d'
+ //
+ // In that case we need to switch to an interpolated string to
+ // be able to contain all of the parts.
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ pm_node_list_t parts = { 0 };
+ pm_node_t *part = UP(pm_string_node_create_unescaped(parser, NULL, &content, NULL, &unescaped));
+ pm_node_list_append(parser->arena, &parts, part);
+
+ do {
+ part = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+ pm_node_list_append(parser->arena, &parts, part);
+ parser_lex(parser);
+ } while (match1(parser, PM_TOKEN_STRING_CONTENT));
+
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_LITERAL_EOF);
+ node = UP(pm_interpolated_string_node_create(parser, &opening, &parts, &parser->previous));
+ } else if (accept1(parser, PM_TOKEN_LABEL_END)) {
+ node = UP(pm_symbol_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped, parse_symbol_encoding(parser, &content, &unescaped, true)));
+ if (!label_allowed) pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_LABEL);
+ } else if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_STRING_LITERAL_EOF);
+ node = UP(pm_string_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped));
+ } else if (accept1(parser, PM_TOKEN_STRING_END)) {
+ node = UP(pm_string_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped));
+ } else {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, PM_ERR_STRING_LITERAL_TERM, pm_token_str(parser->previous.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ node = UP(pm_string_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped));
+ }
+ } else if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ // In this case we've hit string content so we know the string
+ // at least has something in it. We'll need to check if the
+ // following token is the end (in which case we can return a
+ // plain string) or if it's not then it has interpolation.
+ pm_token_t content = parser->current;
+ pm_string_t unescaped = parser->current_string;
+ parser_lex(parser);
+
+ if (match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ node = UP(pm_string_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped));
+ pm_node_flag_set(node, parse_unescaped_encoding(parser));
+
+ // Kind of odd behavior, but basically if we have an
+ // unterminated string and it ends in a newline, we back up one
+ // character so that the error message is on the last line of
+ // content in the string.
+ if (!accept1(parser, PM_TOKEN_STRING_END)) {
+ const uint8_t *location = parser->previous.end;
+ if (location > parser->start && location[-1] == '\n') location--;
+ pm_parser_err(parser, U32(location - parser->start), 0, PM_ERR_STRING_LITERAL_EOF);
+
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+ } else if (accept1(parser, PM_TOKEN_LABEL_END)) {
+ node = UP(pm_symbol_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped, parse_symbol_encoding(parser, &content, &unescaped, true)));
+ if (!label_allowed) pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_LABEL);
+ } else {
+ // If we get here, then we have interpolation so we'll need
+ // to create a string or symbol node with interpolation.
+ pm_node_list_t parts = { 0 };
+ pm_node_t *part = UP(pm_string_node_create_unescaped(parser, NULL, &parser->previous, NULL, &unescaped));
+ pm_node_flag_set(part, parse_unescaped_encoding(parser));
+ pm_node_list_append(parser->arena, &parts, part);
+
+ while (!match3(parser, PM_TOKEN_STRING_END, PM_TOKEN_LABEL_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_node_list_append(parser->arena, &parts, part);
+ }
+ }
+
+ if (accept1(parser, PM_TOKEN_LABEL_END)) {
+ node = UP(pm_interpolated_symbol_node_create(parser, &opening, &parts, &parser->previous));
+ if (!label_allowed) pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_LABEL);
+ } else if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_STRING_INTERPOLATED_TERM);
+ node = UP(pm_interpolated_string_node_create(parser, &opening, &parts, &parser->current));
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_INTERPOLATED_TERM);
+ node = UP(pm_interpolated_string_node_create(parser, &opening, &parts, &parser->previous));
+ }
+ }
+ } else {
+ // If we get here, then the first part of the string is not plain
+ // string content, in which case we need to parse the string as an
+ // interpolated string.
+ pm_node_list_t parts = { 0 };
+ pm_node_t *part;
+
+ while (!match3(parser, PM_TOKEN_STRING_END, PM_TOKEN_LABEL_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_node_list_append(parser->arena, &parts, part);
+ }
+ }
+
+ if (accept1(parser, PM_TOKEN_LABEL_END)) {
+ node = UP(pm_interpolated_symbol_node_create(parser, &opening, &parts, &parser->previous));
+ if (!label_allowed) pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_LABEL);
+ } else if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_STRING_INTERPOLATED_TERM);
+ node = UP(pm_interpolated_string_node_create(parser, &opening, &parts, &parser->current));
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_INTERPOLATED_TERM);
+ node = UP(pm_interpolated_string_node_create(parser, &opening, &parts, &parser->previous));
+ }
+ }
+
+ if (current == NULL) {
+ // If the node we just parsed is a symbol node, then we can't
+ // concatenate it with anything else, so we can now return that
+ // node.
+ if (PM_NODE_TYPE_P(node, PM_SYMBOL_NODE) || PM_NODE_TYPE_P(node, PM_INTERPOLATED_SYMBOL_NODE)) {
+ return node;
+ }
+
+ // If we don't already have a node, then it's fine and we can just
+ // set the result to be the node we just parsed.
+ current = node;
+ } else {
+ // Otherwise we need to check the type of the node we just parsed.
+ // If it cannot be concatenated with the previous node, then we'll
+ // need to add a syntax error.
+ if (!PM_NODE_TYPE_P(node, PM_STRING_NODE) && !PM_NODE_TYPE_P(node, PM_INTERPOLATED_STRING_NODE)) {
+ pm_parser_err_node(parser, node, PM_ERR_STRING_CONCATENATION);
+ }
+
+ // If we haven't already created our container for concatenation,
+ // we'll do that now.
+ if (!concating) {
+ if (!PM_NODE_TYPE_P(current, PM_STRING_NODE) && !PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) {
+ pm_parser_err_node(parser, current, PM_ERR_STRING_CONCATENATION);
+ }
+
+ concating = true;
+ pm_interpolated_string_node_t *container = pm_interpolated_string_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_string_node_append(parser, container, current);
+ current = UP(container);
+ }
+
+ pm_interpolated_string_node_append(parser, (pm_interpolated_string_node_t *) current, node);
+ }
+ }
+
+ return current;
+}
+
+#define PM_PARSE_PATTERN_SINGLE 0
+#define PM_PARSE_PATTERN_TOP 1
+#define PM_PARSE_PATTERN_MULTI 2
+
+static pm_node_t *
+parse_pattern(pm_parser_t *parser, pm_constant_id_list_t *captures, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth);
+
+/**
+ * Add the newly created local to the list of captures for this pattern matching
+ * expression. If it is duplicated from a previous local, then we'll need to add
+ * an error to the parser.
+ */
+static void
+parse_pattern_capture(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_constant_id_t capture, const pm_location_t *location) {
+ // Skip this capture if it starts with an underscore.
+ if (peek_at(parser, parser->start + location->start) == '_') return;
+
+ if (pm_constant_id_list_includes(captures, capture)) {
+ pm_parser_err(parser, location->start, location->length, PM_ERR_PATTERN_CAPTURE_DUPLICATE);
+ } else {
+ pm_constant_id_list_append(parser->arena, captures, capture);
+ }
+}
+
+/**
+ * Accept any number of constants joined by :: delimiters.
+ */
+static pm_node_t *
+parse_pattern_constant_path(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_node_t *node, uint16_t depth) {
+ // Now, if there are any :: operators that follow, parse them as constant
+ // path nodes.
+ while (accept1(parser, PM_TOKEN_COLON_COLON)) {
+ pm_token_t delimiter = parser->previous;
+ expect1(parser, PM_TOKEN_CONSTANT, PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT);
+ node = UP(pm_constant_path_node_create(parser, node, &delimiter, &parser->previous));
+ }
+
+ // If there is a [ or ( that follows, then this is part of a larger pattern
+ // expression. We'll parse the inner pattern here, then modify the returned
+ // inner pattern with our constant path attached.
+ if (!match2(parser, PM_TOKEN_BRACKET_LEFT, PM_TOKEN_PARENTHESIS_LEFT)) {
+ return node;
+ }
+
+ pm_token_t opening;
+ pm_token_t closing;
+ pm_node_t *inner = NULL;
+
+ if (accept1(parser, PM_TOKEN_BRACKET_LEFT)) {
+ opening = parser->previous;
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (!accept1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ inner = parse_pattern(parser, captures, PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET, (uint16_t) (depth + 1));
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_BRACKET_RIGHT, PM_ERR_PATTERN_TERM_BRACKET, &opening);
+ }
+
+ closing = parser->previous;
+ } else {
+ parser_lex(parser);
+ opening = parser->previous;
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (!accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ inner = parse_pattern(parser, captures, PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN, (uint16_t) (depth + 1));
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_PATTERN_TERM_PAREN, &opening);
+ }
+
+ closing = parser->previous;
+ }
+
+ if (!inner) {
+ // If there was no inner pattern, then we have something like Foo() or
+ // Foo[]. In that case we'll create an array pattern with no requireds.
+ return UP(pm_array_pattern_node_constant_create(parser, node, &opening, &closing));
+ }
+
+ // Now that we have the inner pattern, check to see if it's an array, find,
+ // or hash pattern. If it is, then we'll attach our constant path to it if
+ // it doesn't already have a constant. If it's not one of those node types
+ // or it does have a constant, then we'll create an array pattern.
+ switch (PM_NODE_TYPE(inner)) {
+ case PM_ARRAY_PATTERN_NODE: {
+ pm_array_pattern_node_t *pattern_node = (pm_array_pattern_node_t *) inner;
+
+ if (pattern_node->constant == NULL && pattern_node->opening_loc.length == 0) {
+ PM_NODE_START_SET_NODE(pattern_node, node);
+ PM_NODE_LENGTH_SET_TOKEN(parser, pattern_node, &closing);
+
+ pattern_node->constant = node;
+ pattern_node->opening_loc = TOK2LOC(parser, &opening);
+ pattern_node->closing_loc = TOK2LOC(parser, &closing);
+
+ return UP(pattern_node);
+ }
+
+ break;
+ }
+ case PM_FIND_PATTERN_NODE: {
+ pm_find_pattern_node_t *pattern_node = (pm_find_pattern_node_t *) inner;
+
+ if (pattern_node->constant == NULL && pattern_node->opening_loc.length == 0) {
+ PM_NODE_START_SET_NODE(pattern_node, node);
+ PM_NODE_LENGTH_SET_TOKEN(parser, pattern_node, &closing);
+
+ pattern_node->constant = node;
+ pattern_node->opening_loc = TOK2LOC(parser, &opening);
+ pattern_node->closing_loc = TOK2LOC(parser, &closing);
+
+ return UP(pattern_node);
+ }
+
+ break;
+ }
+ case PM_HASH_PATTERN_NODE: {
+ pm_hash_pattern_node_t *pattern_node = (pm_hash_pattern_node_t *) inner;
+
+ if (pattern_node->constant == NULL && pattern_node->opening_loc.length == 0) {
+ PM_NODE_START_SET_NODE(pattern_node, node);
+ PM_NODE_LENGTH_SET_TOKEN(parser, pattern_node, &closing);
+
+ pattern_node->constant = node;
+ pattern_node->opening_loc = TOK2LOC(parser, &opening);
+ pattern_node->closing_loc = TOK2LOC(parser, &closing);
+
+ return UP(pattern_node);
+ }
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ // If we got here, then we didn't return one of the inner patterns by
+ // attaching its constant. In this case we'll create an array pattern and
+ // attach our constant to it.
+ pm_array_pattern_node_t *pattern_node = pm_array_pattern_node_constant_create(parser, node, &opening, &closing);
+ pm_array_pattern_node_requireds_append(parser->arena, pattern_node, inner);
+ return UP(pattern_node);
+}
+
+/**
+ * Parse a rest pattern.
+ */
+static pm_splat_node_t *
+parse_pattern_rest(pm_parser_t *parser, pm_constant_id_list_t *captures) {
+ assert(parser->previous.type == PM_TOKEN_USTAR);
+ pm_token_t operator = parser->previous;
+ pm_node_t *name = NULL;
+
+ // Rest patterns don't necessarily have a name associated with them. So we
+ // will check for that here. If they do, then we'll add it to the local
+ // table since this pattern will cause it to become a local variable.
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ pm_constant_id_t constant_id = pm_parser_constant_id_token(parser, &parser->previous);
+
+ int depth;
+ if ((depth = pm_parser_local_depth_constant_id(parser, constant_id)) == -1) {
+ pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
+ }
+
+ parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
+ name = UP(pm_local_variable_target_node_create(
+ parser,
+ &TOK2LOC(parser, &parser->previous),
+ constant_id,
+ (uint32_t) (depth == -1 ? 0 : depth)
+ ));
+ }
+
+ // Finally we can return the created node.
+ return pm_splat_node_create(parser, &operator, name);
+}
+
+/**
+ * Parse a keyword rest node.
+ */
+static pm_node_t *
+parse_pattern_keyword_rest(pm_parser_t *parser, pm_constant_id_list_t *captures) {
+ assert(parser->current.type == PM_TOKEN_USTAR_STAR);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *value = NULL;
+
+ if (accept1(parser, PM_TOKEN_KEYWORD_NIL)) {
+ return UP(pm_no_keywords_parameter_node_create(parser, &operator, &parser->previous));
+ }
+
+ if (accept1(parser, PM_TOKEN_IDENTIFIER)) {
+ pm_constant_id_t constant_id = pm_parser_constant_id_token(parser, &parser->previous);
+
+ int depth;
+ if ((depth = pm_parser_local_depth_constant_id(parser, constant_id)) == -1) {
+ pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
+ }
+
+ parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
+ value = UP(pm_local_variable_target_node_create(
+ parser,
+ &TOK2LOC(parser, &parser->previous),
+ constant_id,
+ (uint32_t) (depth == -1 ? 0 : depth)
+ ));
+ }
+
+ return UP(pm_assoc_splat_node_create(parser, value, &operator));
+}
+
+/**
+ * Check that the slice of the source given by the bounds parameters constitutes
+ * a valid local variable name.
+ */
+static bool
+pm_slice_is_valid_local(const pm_parser_t *parser, const uint8_t *start, const uint8_t *end) {
+ ptrdiff_t length = end - start;
+ if (length == 0) return false;
+
+ // First ensure that it starts with a valid identifier starting character.
+ size_t width = char_is_identifier_start(parser, start, end - start);
+ if (width == 0) return false;
+
+ // Next, ensure that it's not an uppercase character.
+ if (parser->encoding_changed) {
+ if (parser->encoding->isupper_char(start, length)) return false;
+ } else {
+ if (pm_encoding_utf_8_isupper_char(start, length)) return false;
+ }
+
+ // Next, iterate through all of the bytes of the string to ensure that they
+ // are all valid identifier characters.
+ const uint8_t *cursor = start + width;
+ while ((width = char_is_identifier(parser, cursor, end - cursor))) cursor += width;
+ return cursor == end;
+}
+
+/**
+ * Create an implicit node for the value of a hash pattern that has omitted the
+ * value. This will use an implicit local variable target.
+ */
+static pm_node_t *
+parse_pattern_hash_implicit_value(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_symbol_node_t *key) {
+ const pm_location_t *value_loc = &((pm_symbol_node_t *) key)->value_loc;
+ const uint8_t *start = parser->start + PM_LOCATION_START(value_loc);
+ const uint8_t *end = parser->start + PM_LOCATION_END(value_loc);
+
+ pm_constant_id_t constant_id = pm_parser_constant_id_raw(parser, start, end);
+ int depth = -1;
+
+ if (pm_slice_is_valid_local(parser, start, end)) {
+ depth = pm_parser_local_depth_constant_id(parser, constant_id);
+ } else {
+ pm_parser_err(parser, PM_NODE_START(key), PM_NODE_LENGTH(key), PM_ERR_PATTERN_HASH_KEY_LOCALS);
+
+ if ((end > start) && ((end[-1] == '!') || (end[-1] == '?'))) {
+ PM_PARSER_ERR_FORMAT(parser, value_loc->start, value_loc->length, PM_ERR_INVALID_LOCAL_VARIABLE_WRITE, (int) (end - start), (const char *) start);
+ }
+ }
+
+ if (depth == -1) {
+ pm_parser_local_add(parser, constant_id, start, end, 0);
+ }
+
+ parse_pattern_capture(parser, captures, constant_id, value_loc);
+ pm_local_variable_target_node_t *target = pm_local_variable_target_node_create(
+ parser,
+ value_loc,
+ constant_id,
+ (uint32_t) (depth == -1 ? 0 : depth)
+ );
+
+ return UP(pm_implicit_node_create(parser, UP(target)));
+}
+
+/**
+ * Add a node to the list of keys for a hash pattern, and if it is a duplicate
+ * then add an error to the parser.
+ */
+static void
+parse_pattern_hash_key(pm_parser_t *parser, pm_static_literals_t *keys, pm_node_t *node) {
+ if (pm_static_literals_add(&parser->line_offsets, parser->start, parser->start_line, keys, node, true) != NULL) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_HASH_KEY_DUPLICATE);
+ }
+}
+
+/**
+ * Parse a hash pattern.
+ */
+static pm_hash_pattern_node_t *
+parse_pattern_hash(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_node_t *first_node, uint16_t depth) {
+ pm_node_list_t assocs = { 0 };
+ pm_static_literals_t keys = { 0 };
+ pm_node_t *rest = NULL;
+
+ switch (PM_NODE_TYPE(first_node)) {
+ case PM_ASSOC_SPLAT_NODE:
+ case PM_NO_KEYWORDS_PARAMETER_NODE:
+ rest = first_node;
+ break;
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ case PM_SYMBOL_NODE: {
+ if (pm_symbol_node_label_p(parser, first_node)) {
+ if (PM_NODE_TYPE_P(first_node, PM_INTERPOLATED_SYMBOL_NODE)) {
+ pm_parser_err_node(parser, first_node, PM_ERR_PATTERN_HASH_KEY_INTERPOLATED);
+ } else {
+ parse_pattern_hash_key(parser, &keys, first_node);
+ }
+
+ pm_node_t *value;
+
+ if (match8(parser, PM_TOKEN_COMMA, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_EOF)) {
+ if (PM_NODE_TYPE_P(first_node, PM_SYMBOL_NODE)) {
+ value = parse_pattern_hash_implicit_value(parser, captures, (pm_symbol_node_t *) first_node);
+ } else {
+ value = UP(pm_error_recovery_node_create(parser, PM_NODE_END(first_node), 0));
+ }
+ } else {
+ // Here we have a value for the first assoc in the list, so
+ // we will parse it now.
+ value = parse_pattern(parser, captures, PM_PARSE_PATTERN_SINGLE, PM_ERR_PATTERN_EXPRESSION_AFTER_KEY, (uint16_t) (depth + 1));
+ }
+
+ pm_node_t *assoc = UP(pm_assoc_node_create(parser, first_node, NULL, value));
+ pm_node_list_append(parser->arena, &assocs, assoc);
+ break;
+ }
+ }
+ PRISM_FALLTHROUGH
+ default: {
+ // If we get anything else, then this is an error. For this we'll
+ // create a missing node for the value and create an assoc node for
+ // the first node in the list.
+ pm_diagnostic_id_t diag_id = PM_NODE_TYPE_P(first_node, PM_INTERPOLATED_SYMBOL_NODE) ? PM_ERR_PATTERN_HASH_KEY_INTERPOLATED : PM_ERR_PATTERN_HASH_KEY_LABEL;
+ pm_parser_err_node(parser, first_node, diag_id);
+
+ pm_node_t *value = UP(pm_error_recovery_node_create(parser, PM_NODE_START(first_node), PM_NODE_LENGTH(first_node)));
+ pm_node_t *assoc = UP(pm_assoc_node_create(parser, first_node, NULL, value));
+
+ pm_node_list_append(parser->arena, &assocs, assoc);
+ break;
+ }
+ }
+
+ // If there are any other assocs, then we'll parse them now.
+ while (accept1(parser, PM_TOKEN_COMMA)) {
+ // Here we need to break to support trailing commas.
+ if (match7(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_EOF)) {
+ // Trailing commas are not allowed to follow a rest pattern.
+ if (rest != NULL) {
+ pm_parser_err_token(parser, &parser->current, PM_ERR_PATTERN_EXPRESSION_AFTER_REST);
+ }
+
+ break;
+ }
+
+ if (match1(parser, PM_TOKEN_USTAR_STAR)) {
+ pm_node_t *assoc = parse_pattern_keyword_rest(parser, captures);
+
+ if (rest == NULL) {
+ rest = assoc;
+ } else {
+ pm_parser_err_node(parser, assoc, PM_ERR_PATTERN_EXPRESSION_AFTER_REST);
+ pm_node_list_append(parser->arena, &assocs, assoc);
+ }
+ } else {
+ pm_node_t *key;
+
+ if (match1(parser, PM_TOKEN_STRING_BEGIN)) {
+ key = parse_strings(parser, NULL, true, (uint16_t) (depth + 1));
+
+ if (PM_NODE_TYPE_P(key, PM_INTERPOLATED_SYMBOL_NODE)) {
+ pm_parser_err_node(parser, key, PM_ERR_PATTERN_HASH_KEY_INTERPOLATED);
+ } else if (!pm_symbol_node_label_p(parser, key)) {
+ pm_parser_err_node(parser, key, PM_ERR_PATTERN_LABEL_AFTER_COMMA);
+ }
+ } else if (accept1(parser, PM_TOKEN_LABEL)) {
+ key = UP(pm_symbol_node_label_create(parser, &parser->previous));
+ } else {
+ expect1(parser, PM_TOKEN_LABEL, PM_ERR_PATTERN_LABEL_AFTER_COMMA);
+
+ pm_token_t label = { .type = PM_TOKEN_LABEL, .start = parser->previous.end, .end = parser->previous.end };
+ key = UP(pm_symbol_node_create(parser, NULL, &label, NULL));
+ }
+
+ parse_pattern_hash_key(parser, &keys, key);
+ pm_node_t *value = NULL;
+
+ if (match7(parser, PM_TOKEN_COMMA, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ if (PM_NODE_TYPE_P(key, PM_SYMBOL_NODE)) {
+ value = parse_pattern_hash_implicit_value(parser, captures, (pm_symbol_node_t *) key);
+ } else {
+ value = UP(pm_error_recovery_node_create(parser, PM_NODE_END(key), 0));
+ }
+ } else {
+ value = parse_pattern(parser, captures, PM_PARSE_PATTERN_SINGLE, PM_ERR_PATTERN_EXPRESSION_AFTER_KEY, (uint16_t) (depth + 1));
+ }
+
+ pm_node_t *assoc = UP(pm_assoc_node_create(parser, key, NULL, value));
+
+ if (rest != NULL) {
+ pm_parser_err_node(parser, assoc, PM_ERR_PATTERN_EXPRESSION_AFTER_REST);
+ }
+
+ pm_node_list_append(parser->arena, &assocs, assoc);
+ }
+ }
+
+ pm_hash_pattern_node_t *node = pm_hash_pattern_node_node_list_create(parser, &assocs, rest);
+ // assocs.nodes is arena-allocated; no explicit free needed.
+
+ pm_static_literals_free(&keys);
+ return node;
+}
+
+/**
+ * Parse a pattern expression primitive.
+ */
+static pm_node_t *
+parse_pattern_primitive(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ switch (parser->current.type) {
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+ pm_constant_id_t constant_id = pm_parser_constant_id_token(parser, &parser->previous);
+
+ int depth;
+ if ((depth = pm_parser_local_depth_constant_id(parser, constant_id)) == -1) {
+ pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
+ }
+
+ parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
+ return UP(pm_local_variable_target_node_create(
+ parser,
+ &TOK2LOC(parser, &parser->previous),
+ constant_id,
+ (uint32_t) (depth == -1 ? 0 : depth)
+ ));
+ }
+ case PM_TOKEN_BRACKET_LEFT_ARRAY: {
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ if (accept1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ // If we have an empty array pattern, then we'll just return a new
+ // array pattern node.
+ return UP(pm_array_pattern_node_empty_create(parser, &opening, &parser->previous));
+ }
+
+ // Otherwise, we'll parse the inner pattern, then deal with it depending
+ // on the type it returns.
+ pm_node_t *inner = parse_pattern(parser, captures, PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET, (uint16_t) (depth + 1));
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_BRACKET_RIGHT, PM_ERR_PATTERN_TERM_BRACKET, &opening);
+ pm_token_t closing = parser->previous;
+
+ switch (PM_NODE_TYPE(inner)) {
+ case PM_ARRAY_PATTERN_NODE: {
+ pm_array_pattern_node_t *pattern_node = (pm_array_pattern_node_t *) inner;
+ if (pattern_node->opening_loc.length == 0) {
+ PM_NODE_START_SET_TOKEN(parser, pattern_node, &opening);
+ PM_NODE_LENGTH_SET_TOKEN(parser, pattern_node, &closing);
+
+ pattern_node->opening_loc = TOK2LOC(parser, &opening);
+ pattern_node->closing_loc = TOK2LOC(parser, &closing);
+
+ return UP(pattern_node);
+ }
+
+ break;
+ }
+ case PM_FIND_PATTERN_NODE: {
+ pm_find_pattern_node_t *pattern_node = (pm_find_pattern_node_t *) inner;
+ if (pattern_node->opening_loc.length == 0) {
+ PM_NODE_START_SET_TOKEN(parser, pattern_node, &opening);
+ PM_NODE_LENGTH_SET_TOKEN(parser, pattern_node, &closing);
+
+ pattern_node->opening_loc = TOK2LOC(parser, &opening);
+ pattern_node->closing_loc = TOK2LOC(parser, &closing);
+
+ return UP(pattern_node);
+ }
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ pm_array_pattern_node_t *node = pm_array_pattern_node_empty_create(parser, &opening, &closing);
+ pm_array_pattern_node_requireds_append(parser->arena, node, inner);
+ return UP(node);
+ }
+ case PM_TOKEN_BRACE_LEFT: {
+ bool previous_pattern_matching_newlines = parser->pattern_matching_newlines;
+ parser->pattern_matching_newlines = false;
+
+ pm_hash_pattern_node_t *node;
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ if (accept1(parser, PM_TOKEN_BRACE_RIGHT)) {
+ // If we have an empty hash pattern, then we'll just return a new hash
+ // pattern node.
+ node = pm_hash_pattern_node_empty_create(parser, &opening, &parser->previous);
+ } else {
+ pm_node_t *first_node;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_LABEL:
+ parser_lex(parser);
+ first_node = UP(pm_symbol_node_label_create(parser, &parser->previous));
+ break;
+ case PM_TOKEN_USTAR_STAR:
+ first_node = parse_pattern_keyword_rest(parser, captures);
+ break;
+ case PM_TOKEN_STRING_BEGIN:
+ first_node = parse_expression(parser, PM_BINDING_POWER_MAX, PM_PARSE_ACCEPTS_DO_BLOCK | PM_PARSE_ACCEPTS_LABEL, PM_ERR_PATTERN_HASH_KEY_LABEL, (uint16_t) (depth + 1));
+ break;
+ default: {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_PATTERN_HASH_KEY, pm_token_str(parser->current.type));
+ parser_lex(parser);
+
+ first_node = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous)));
+ break;
+ }
+ }
+
+ node = parse_pattern_hash(parser, captures, first_node, (uint16_t) (depth + 1));
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_PATTERN_TERM_BRACE, &opening);
+ pm_token_t closing = parser->previous;
+
+ PM_NODE_START_SET_TOKEN(parser, node, &opening);
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, &closing);
+
+ node->opening_loc = TOK2LOC(parser, &opening);
+ node->closing_loc = TOK2LOC(parser, &closing);
+ }
+
+ parser->pattern_matching_newlines = previous_pattern_matching_newlines;
+ return UP(node);
+ }
+ case PM_TOKEN_UDOT_DOT:
+ case PM_TOKEN_UDOT_DOT_DOT: {
+ pm_token_t operator = parser->current;
+ parser_lex(parser);
+
+ // Since we have a unary range operator, we need to parse the subsequent
+ // expression as the right side of the range.
+ switch (parser->current.type) {
+ case PM_CASE_PRIMITIVE: {
+ pm_node_t *right = parse_expression(parser, PM_BINDING_POWER_MAX, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE, (uint16_t) (depth + 1));
+ return UP(pm_range_node_create(parser, NULL, &operator, right));
+ }
+ default: {
+ pm_parser_err_token(parser, &operator, PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE);
+ pm_node_t *right = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &operator), PM_TOKEN_LENGTH(&operator)));
+ return UP(pm_range_node_create(parser, NULL, &operator, right));
+ }
+ }
+ }
+ case PM_CASE_PRIMITIVE: {
+ pm_node_t *node = parse_expression(parser, PM_BINDING_POWER_MAX, PM_PARSE_ACCEPTS_LABEL | PM_PARSE_ACCEPTS_DO_BLOCK, diag_id, (uint16_t) (depth + 1));
+
+ // If we found a label, we need to immediately return to the caller.
+ if (pm_symbol_node_label_p(parser, node)) return node;
+
+ // Call nodes (arithmetic operations) are not allowed in patterns
+ if (PM_NODE_TYPE(node) == PM_CALL_NODE) {
+ pm_parser_err_node(parser, node, diag_id);
+ return UP(pm_error_recovery_node_create_unexpected(parser, node));
+ }
+
+ // Now that we have a primitive, we need to check if it's part of a range.
+ if (accept2(parser, PM_TOKEN_DOT_DOT, PM_TOKEN_DOT_DOT_DOT)) {
+ pm_token_t operator = parser->previous;
+
+ // Now that we have the operator, we need to check if this is followed
+ // by another expression. If it is, then we will create a full range
+ // node. Otherwise, we'll create an endless range.
+ switch (parser->current.type) {
+ case PM_CASE_PRIMITIVE: {
+ pm_node_t *right = parse_expression(parser, PM_BINDING_POWER_MAX, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE, (uint16_t) (depth + 1));
+ return UP(pm_range_node_create(parser, node, &operator, right));
+ }
+ default:
+ return UP(pm_range_node_create(parser, node, &operator, NULL));
+ }
+ }
+
+ return node;
+ }
+ case PM_TOKEN_CARET: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+
+ // At this point we have a pin operator. We need to check the subsequent
+ // expression to determine if it's a variable or an expression.
+ switch (parser->current.type) {
+ case PM_TOKEN_IDENTIFIER: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(parse_variable(parser));
+
+ if (variable == NULL) {
+ PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &parser->previous, PM_ERR_NO_LOCAL_VARIABLE);
+ variable = UP(pm_local_variable_read_node_missing_create(parser, &parser->previous, 0));
+ }
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_INSTANCE_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(pm_instance_variable_read_node_create(parser, &parser->previous));
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_CLASS_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(pm_class_variable_read_node_create(parser, &parser->previous));
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_GLOBAL_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(pm_global_variable_read_node_create(parser, &parser->previous));
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_NUMBERED_REFERENCE: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(pm_numbered_reference_read_node_create(parser, &parser->previous));
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_BACK_REFERENCE: {
+ parser_lex(parser);
+ pm_node_t *variable = UP(pm_back_reference_read_node_create(parser, &parser->previous));
+
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ bool previous_pattern_matching_newlines = parser->pattern_matching_newlines;
+ parser->pattern_matching_newlines = false;
+
+ pm_token_t lparen = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, PM_PARSE_ACCEPTS_DO_BLOCK | PM_PARSE_ACCEPTS_COMMAND_CALL, PM_ERR_PATTERN_EXPRESSION_AFTER_PIN, (uint16_t) (depth + 1));
+ parser->pattern_matching_newlines = previous_pattern_matching_newlines;
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_PATTERN_TERM_PAREN, &lparen);
+ return UP(pm_pinned_expression_node_create(parser, expression, &operator, &lparen, &parser->previous));
+ }
+ default: {
+ // If we get here, then we have a pin operator followed by something
+ // not understood. We'll create a missing node and return that.
+ pm_parser_err_token(parser, &operator, PM_ERR_PATTERN_EXPRESSION_AFTER_PIN);
+ pm_node_t *variable = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &operator), PM_TOKEN_LENGTH(&operator)));
+ return UP(pm_pinned_variable_node_create(parser, &operator, variable));
+ }
+ }
+ }
+ case PM_TOKEN_UCOLON_COLON: {
+ pm_token_t delimiter = parser->current;
+ parser_lex(parser);
+
+ expect1(parser, PM_TOKEN_CONSTANT, PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT);
+ pm_constant_path_node_t *node = pm_constant_path_node_create(parser, NULL, &delimiter, &parser->previous);
+
+ return parse_pattern_constant_path(parser, captures, UP(node), (uint16_t) (depth + 1));
+ }
+ case PM_TOKEN_CONSTANT: {
+ pm_token_t constant = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *node = UP(pm_constant_read_node_create(parser, &constant));
+ return parse_pattern_constant_path(parser, captures, node, (uint16_t) (depth + 1));
+ }
+ default:
+ pm_parser_err_current(parser, diag_id);
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ }
+}
+
+static bool
+parse_pattern_alternation_error_each(const pm_node_t *node, void *data) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_LOCAL_VARIABLE_TARGET_NODE: {
+ pm_parser_t *parser = (pm_parser_t *) data;
+ pm_parser_err(parser, PM_NODE_START(node), PM_NODE_LENGTH(node), PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE);
+ return false;
+ }
+ default:
+ return true;
+ }
+}
+
+/**
+ * When we get here, we know that we already have a syntax error, because we
+ * know we have captured a variable and that we are in an alternation.
+ */
+static void
+parse_pattern_alternation_error(pm_parser_t *parser, const pm_node_t *node) {
+ pm_visit_node(node, parse_pattern_alternation_error_each, parser);
+}
+
+/**
+ * Parse any number of primitives joined by alternation and ended optionally by
+ * assignment.
+ */
+static pm_node_t *
+parse_pattern_primitives(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_node_t *first_node, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ pm_node_t *node = first_node;
+ bool alternation = false;
+
+ while ((node == NULL) || (alternation = accept1(parser, PM_TOKEN_PIPE))) {
+ if (alternation && !PM_NODE_TYPE_P(node, PM_ALTERNATION_PATTERN_NODE) && captures->size) {
+ parse_pattern_alternation_error(parser, node);
+ }
+
+ switch (parser->current.type) {
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_BRACKET_LEFT_ARRAY:
+ case PM_TOKEN_BRACE_LEFT:
+ case PM_TOKEN_CARET:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_UCOLON_COLON:
+ case PM_TOKEN_UDOT_DOT:
+ case PM_TOKEN_UDOT_DOT_DOT:
+ case PM_CASE_PRIMITIVE: {
+ if (!alternation) {
+ node = parse_pattern_primitive(parser, captures, diag_id, (uint16_t) (depth + 1));
+ } else {
+ pm_token_t operator = parser->previous;
+ pm_node_t *right = parse_pattern_primitive(parser, captures, PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE, (uint16_t) (depth + 1));
+
+ if (captures->size) parse_pattern_alternation_error(parser, right);
+ node = UP(pm_alternation_pattern_node_create(parser, node, right, &operator));
+ }
+
+ break;
+ }
+ case PM_TOKEN_PARENTHESIS_LEFT:
+ case PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES: {
+ pm_token_t operator = parser->previous;
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *body = parse_pattern(parser, captures, PM_PARSE_PATTERN_SINGLE, PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN, (uint16_t) (depth + 1));
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1_opening(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_PATTERN_TERM_PAREN, &opening);
+ pm_node_t *right = UP(pm_parentheses_node_create(parser, &opening, body, &parser->previous, 0));
+
+ if (!alternation) {
+ node = right;
+ } else {
+ if (captures->size) parse_pattern_alternation_error(parser, right);
+ node = UP(pm_alternation_pattern_node_create(parser, node, right, &operator));
+ }
+
+ break;
+ }
+ default: {
+ pm_parser_err_current(parser, diag_id);
+ pm_node_t *right = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+
+ if (!alternation) {
+ node = right;
+ } else {
+ if (captures->size) parse_pattern_alternation_error(parser, right);
+ node = UP(pm_alternation_pattern_node_create(parser, node, right, &parser->previous));
+ }
+
+ break;
+ }
+ }
+ }
+
+ // If we have an =>, then we are assigning this pattern to a variable.
+ // In this case we should create an assignment node.
+ while (accept1(parser, PM_TOKEN_EQUAL_GREATER)) {
+ pm_token_t operator = parser->previous;
+ expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_PATTERN_IDENT_AFTER_HROCKET);
+
+ pm_constant_id_t constant_id = pm_parser_constant_id_token(parser, &parser->previous);
+ int depth;
+
+ if ((depth = pm_parser_local_depth_constant_id(parser, constant_id)) == -1) {
+ pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
+ }
+
+ parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
+ pm_local_variable_target_node_t *target = pm_local_variable_target_node_create(
+ parser,
+ &TOK2LOC(parser, &parser->previous),
+ constant_id,
+ (uint32_t) (depth == -1 ? 0 : depth)
+ );
+
+ node = UP(pm_capture_pattern_node_create(parser, node, target, &operator));
+ }
+
+ return node;
+}
+
+/**
+ * Parse a pattern matching expression.
+ */
+static pm_node_t *
+parse_pattern(pm_parser_t *parser, pm_constant_id_list_t *captures, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ pm_node_t *node = NULL;
+
+ bool leading_rest = false;
+ bool trailing_rest = false;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_LABEL: {
+ parser_lex(parser);
+ pm_node_t *key = UP(pm_symbol_node_label_create(parser, &parser->previous));
+ node = UP(parse_pattern_hash(parser, captures, key, (uint16_t) (depth + 1)));
+
+ if (!(flags & PM_PARSE_PATTERN_TOP)) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_HASH_IMPLICIT);
+ }
+
+ return node;
+ }
+ case PM_TOKEN_USTAR_STAR: {
+ node = parse_pattern_keyword_rest(parser, captures);
+ node = UP(parse_pattern_hash(parser, captures, node, (uint16_t) (depth + 1)));
+
+ if (!(flags & PM_PARSE_PATTERN_TOP)) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_HASH_IMPLICIT);
+ }
+
+ return node;
+ }
+ case PM_TOKEN_STRING_BEGIN: {
+ // We need special handling for string beginnings because they could
+ // be dynamic symbols leading to hash patterns.
+ node = parse_pattern_primitive(parser, captures, diag_id, (uint16_t) (depth + 1));
+
+ if (pm_symbol_node_label_p(parser, node)) {
+ node = UP(parse_pattern_hash(parser, captures, node, (uint16_t) (depth + 1)));
+
+ if (!(flags & PM_PARSE_PATTERN_TOP)) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_HASH_IMPLICIT);
+ }
+
+ return node;
+ }
+
+ node = parse_pattern_primitives(parser, captures, node, diag_id, (uint16_t) (depth + 1));
+ break;
+ }
+ case PM_TOKEN_USTAR: {
+ if (flags & (PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI)) {
+ parser_lex(parser);
+ node = UP(parse_pattern_rest(parser, captures));
+ leading_rest = true;
+ break;
+ }
+ }
+ PRISM_FALLTHROUGH
+ default:
+ node = parse_pattern_primitives(parser, captures, NULL, diag_id, (uint16_t) (depth + 1));
+ break;
+ }
+
+ // If we got a dynamic label symbol, then we need to treat it like the
+ // beginning of a hash pattern.
+ if (pm_symbol_node_label_p(parser, node)) {
+ return UP(parse_pattern_hash(parser, captures, node, (uint16_t) (depth + 1)));
+ }
+
+ if ((flags & PM_PARSE_PATTERN_MULTI) && match1(parser, PM_TOKEN_COMMA)) {
+ // If we have a comma, then we are now parsing either an array pattern
+ // or a find pattern. We need to parse all of the patterns, put them
+ // into a big list, and then determine which type of node we have.
+ pm_node_list_t nodes = { 0 };
+ pm_node_list_append(parser->arena, &nodes, node);
+
+ // Gather up all of the patterns into the list.
+ while (accept1(parser, PM_TOKEN_COMMA)) {
+ // Break early here in case we have a trailing comma.
+ if (match7(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_SEMICOLON, PM_TOKEN_KEYWORD_AND, PM_TOKEN_KEYWORD_OR)) {
+ node = UP(pm_implicit_rest_node_create(parser, &parser->previous));
+ pm_node_list_append(parser->arena, &nodes, node);
+ trailing_rest = true;
+ break;
+ }
+
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ node = UP(parse_pattern_rest(parser, captures));
+
+ // If we have already parsed a splat pattern, then this is an
+ // error. We will continue to parse the rest of the patterns,
+ // but we will indicate it as an error.
+ if (trailing_rest) {
+ pm_parser_err_previous(parser, PM_ERR_PATTERN_REST);
+ }
+
+ trailing_rest = true;
+ } else {
+ node = parse_pattern_primitives(parser, captures, NULL, PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA, (uint16_t) (depth + 1));
+ }
+
+ pm_node_list_append(parser->arena, &nodes, node);
+ }
+
+ // If the first pattern and the last pattern are rest patterns, then we
+ // will call this a find pattern, regardless of how many rest patterns
+ // are in between because we know we already added the appropriate
+ // errors. Otherwise we will create an array pattern.
+ if (leading_rest && PM_NODE_TYPE_P(nodes.nodes[nodes.size - 1], PM_SPLAT_NODE)) {
+ node = UP(pm_find_pattern_node_create(parser, &nodes));
+
+ if (nodes.size == 2) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_FIND_MISSING_INNER);
+ }
+ } else {
+ node = UP(pm_array_pattern_node_node_list_create(parser, &nodes));
+
+ if (leading_rest && trailing_rest) {
+ pm_parser_err_node(parser, node, PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS);
+ }
+ }
+
+ // nodes.nodes is arena-allocated; no explicit free needed.
+ } else if (leading_rest) {
+ // Otherwise, if we parsed a single splat pattern, then we know we have
+ // an array pattern, so we can go ahead and create that node.
+ node = UP(pm_array_pattern_node_rest_create(parser, node));
+ }
+
+ return node;
+}
+
+/**
+ * Incorporate a negative sign into a numeric node by subtracting 1 character
+ * from its start bounds. If it's a compound node, then we will recursively
+ * apply this function to its value.
+ */
+static PRISM_INLINE void
+parse_negative_numeric(pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_INTEGER_NODE: {
+ pm_integer_node_t *cast = (pm_integer_node_t *) node;
+ cast->base.location.start--;
+ cast->base.location.length++;
+ cast->value.negative = true;
+ break;
+ }
+ case PM_FLOAT_NODE: {
+ pm_float_node_t *cast = (pm_float_node_t *) node;
+ cast->base.location.start--;
+ cast->base.location.length++;
+ cast->value = -cast->value;
+ break;
+ }
+ case PM_RATIONAL_NODE: {
+ pm_rational_node_t *cast = (pm_rational_node_t *) node;
+ cast->base.location.start--;
+ cast->base.location.length++;
+ cast->numerator.negative = true;
+ break;
+ }
+ case PM_IMAGINARY_NODE:
+ node->location.start--;
+ node->location.length++;
+ parse_negative_numeric(((pm_imaginary_node_t *) node)->numeric);
+ break;
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+}
+
+/**
+ * Append an error to the error list on the parser using the given diagnostic
+ * ID. This function is a specialization that handles formatting the specific
+ * kind of error that is being appended.
+ */
+static void
+pm_parser_err_prefix(pm_parser_t *parser, pm_diagnostic_id_t diag_id) {
+ switch (diag_id) {
+ case PM_ERR_HASH_KEY: {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, diag_id, pm_token_str(parser->previous.type));
+ break;
+ }
+ case PM_ERR_HASH_VALUE:
+ case PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR: {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, diag_id, pm_token_str(parser->current.type));
+ break;
+ }
+ case PM_ERR_UNARY_RECEIVER: {
+ const char *human = (parser->current.type == PM_TOKEN_EOF ? "end-of-input" : pm_token_str(parser->current.type));
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, diag_id, human, parser->previous.start[0]);
+ break;
+ }
+ case PM_ERR_UNARY_DISALLOWED:
+ case PM_ERR_EXPECT_ARGUMENT: {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, diag_id, pm_token_str(parser->current.type));
+ break;
+ }
+ default:
+ pm_parser_err_previous(parser, diag_id);
+ break;
+ }
+}
+
+/**
+ * Ensures that the current retry token is valid in the current context.
+ */
+static void
+parse_retry(pm_parser_t *parser, const pm_node_t *node) {
+#define CONTEXT_NONE 0
+#define CONTEXT_THROUGH_ENSURE 1
+#define CONTEXT_THROUGH_ELSE 2
+
+ pm_context_node_t *context_node = parser->current_context;
+ int context = CONTEXT_NONE;
+
+ while (context_node != NULL) {
+ switch (context_node->context) {
+ case PM_CONTEXT_BEGIN_RESCUE:
+ case PM_CONTEXT_BLOCK_RESCUE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_LAMBDA_RESCUE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_SCLASS_RESCUE:
+ case PM_CONTEXT_DEFINED:
+ case PM_CONTEXT_RESCUE_MODIFIER:
+ // These are the good cases. We're allowed to have a retry here.
+ return;
+ case PM_CONTEXT_CLASS:
+ case PM_CONTEXT_DEF:
+ case PM_CONTEXT_DEF_PARAMS:
+ case PM_CONTEXT_MAIN:
+ case PM_CONTEXT_MODULE:
+ case PM_CONTEXT_PREEXE:
+ case PM_CONTEXT_SCLASS:
+ // These are the bad cases. We're not allowed to have a retry in
+ // these contexts.
+ if (context == CONTEXT_NONE) {
+ pm_parser_err_node(parser, node, PM_ERR_INVALID_RETRY_WITHOUT_RESCUE);
+ } else if (context == CONTEXT_THROUGH_ENSURE) {
+ pm_parser_err_node(parser, node, PM_ERR_INVALID_RETRY_AFTER_ENSURE);
+ } else if (context == CONTEXT_THROUGH_ELSE) {
+ pm_parser_err_node(parser, node, PM_ERR_INVALID_RETRY_AFTER_ELSE);
+ }
+ return;
+ case PM_CONTEXT_BEGIN_ELSE:
+ case PM_CONTEXT_BLOCK_ELSE:
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_DEF_ELSE:
+ case PM_CONTEXT_LAMBDA_ELSE:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_SCLASS_ELSE:
+ // These are also bad cases, but with a more specific error
+ // message indicating the else.
+ context = CONTEXT_THROUGH_ELSE;
+ break;
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_BLOCK_ENSURE:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_LAMBDA_ENSURE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_SCLASS_ENSURE:
+ // These are also bad cases, but with a more specific error
+ // message indicating the ensure.
+ context = CONTEXT_THROUGH_ENSURE;
+ break;
+ case PM_CONTEXT_NONE:
+ // This case should never happen.
+ assert(false && "unreachable");
+ break;
+ case PM_CONTEXT_BEGIN:
+ case PM_CONTEXT_BLOCK_BRACES:
+ case PM_CONTEXT_BLOCK_KEYWORDS:
+ case PM_CONTEXT_BLOCK_PARAMETERS:
+ case PM_CONTEXT_CASE_IN:
+ case PM_CONTEXT_CASE_WHEN:
+ case PM_CONTEXT_DEFAULT_PARAMS:
+ case PM_CONTEXT_ELSE:
+ case PM_CONTEXT_ELSIF:
+ case PM_CONTEXT_EMBEXPR:
+ case PM_CONTEXT_FOR_INDEX:
+ case PM_CONTEXT_FOR:
+ case PM_CONTEXT_IF:
+ case PM_CONTEXT_LAMBDA_BRACES:
+ case PM_CONTEXT_LAMBDA_DO_END:
+ case PM_CONTEXT_LOOP_PREDICATE:
+ case PM_CONTEXT_MULTI_TARGET:
+ case PM_CONTEXT_PARENS:
+ case PM_CONTEXT_POSTEXE:
+ case PM_CONTEXT_PREDICATE:
+ case PM_CONTEXT_TERNARY:
+ case PM_CONTEXT_UNLESS:
+ case PM_CONTEXT_UNTIL:
+ case PM_CONTEXT_WHILE:
+ // In these contexts we should continue walking up the list of
+ // contexts.
+ break;
+ }
+
+ context_node = context_node->prev;
+ }
+
+#undef CONTEXT_NONE
+#undef CONTEXT_ENSURE
+#undef CONTEXT_ELSE
+}
+
+/**
+ * Ensures that the current yield token is valid in the current context.
+ */
+static void
+parse_yield(pm_parser_t *parser, const pm_node_t *node) {
+ pm_context_node_t *context_node = parser->current_context;
+
+ while (context_node != NULL) {
+ switch (context_node->context) {
+ case PM_CONTEXT_DEF:
+ case PM_CONTEXT_DEF_PARAMS:
+ case PM_CONTEXT_DEFINED:
+ case PM_CONTEXT_DEF_ENSURE:
+ case PM_CONTEXT_DEF_RESCUE:
+ case PM_CONTEXT_DEF_ELSE:
+ // These are the good cases. We're allowed to have a block exit
+ // in these contexts.
+ return;
+ case PM_CONTEXT_CLASS:
+ case PM_CONTEXT_CLASS_ENSURE:
+ case PM_CONTEXT_CLASS_RESCUE:
+ case PM_CONTEXT_CLASS_ELSE:
+ case PM_CONTEXT_MAIN:
+ case PM_CONTEXT_MODULE:
+ case PM_CONTEXT_MODULE_ENSURE:
+ case PM_CONTEXT_MODULE_RESCUE:
+ case PM_CONTEXT_MODULE_ELSE:
+ case PM_CONTEXT_SCLASS:
+ case PM_CONTEXT_SCLASS_RESCUE:
+ case PM_CONTEXT_SCLASS_ENSURE:
+ case PM_CONTEXT_SCLASS_ELSE:
+ // These are the bad cases. We're not allowed to have a retry in
+ // these contexts.
+ pm_parser_err_node(parser, node, PM_ERR_INVALID_YIELD);
+ return;
+ case PM_CONTEXT_NONE:
+ // This case should never happen.
+ assert(false && "unreachable");
+ break;
+ case PM_CONTEXT_BEGIN:
+ case PM_CONTEXT_BEGIN_ELSE:
+ case PM_CONTEXT_BEGIN_ENSURE:
+ case PM_CONTEXT_BEGIN_RESCUE:
+ case PM_CONTEXT_BLOCK_BRACES:
+ case PM_CONTEXT_BLOCK_KEYWORDS:
+ case PM_CONTEXT_BLOCK_ELSE:
+ case PM_CONTEXT_BLOCK_ENSURE:
+ case PM_CONTEXT_BLOCK_PARAMETERS:
+ case PM_CONTEXT_BLOCK_RESCUE:
+ case PM_CONTEXT_CASE_IN:
+ case PM_CONTEXT_CASE_WHEN:
+ case PM_CONTEXT_DEFAULT_PARAMS:
+ case PM_CONTEXT_ELSE:
+ case PM_CONTEXT_ELSIF:
+ case PM_CONTEXT_EMBEXPR:
+ case PM_CONTEXT_FOR_INDEX:
+ case PM_CONTEXT_FOR:
+ case PM_CONTEXT_IF:
+ case PM_CONTEXT_LAMBDA_BRACES:
+ case PM_CONTEXT_LAMBDA_DO_END:
+ case PM_CONTEXT_LAMBDA_ELSE:
+ case PM_CONTEXT_LAMBDA_ENSURE:
+ case PM_CONTEXT_LAMBDA_RESCUE:
+ case PM_CONTEXT_LOOP_PREDICATE:
+ case PM_CONTEXT_MULTI_TARGET:
+ case PM_CONTEXT_PARENS:
+ case PM_CONTEXT_POSTEXE:
+ case PM_CONTEXT_PREDICATE:
+ case PM_CONTEXT_PREEXE:
+ case PM_CONTEXT_RESCUE_MODIFIER:
+ case PM_CONTEXT_TERNARY:
+ case PM_CONTEXT_UNLESS:
+ case PM_CONTEXT_UNTIL:
+ case PM_CONTEXT_WHILE:
+ // In these contexts we should continue walking up the list of
+ // contexts.
+ break;
+ }
+
+ context_node = context_node->prev;
+ }
+}
+
+/**
+ * Determine if a given call node looks like a "command", which means it has
+ * arguments but does not have parentheses.
+ */
+static PRISM_INLINE bool
+pm_call_node_command_p(const pm_call_node_t *node) {
+ return (
+ (node->opening_loc.length == 0) &&
+ (node->block == NULL || PM_NODE_TYPE_P(node->block, PM_BLOCK_ARGUMENT_NODE)) &&
+ (node->arguments != NULL || node->block != NULL)
+ );
+}
+
+/**
+ * Returns true if the given node is a command-style call (a method call without
+ * parentheses that has arguments), excluding operator calls (e.g., a + b) which
+ * satisfy the same structural criteria but are not commands.
+ */
+static bool
+pm_command_call_value_p(const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CALL_NODE: {
+ const pm_call_node_t *call = (const pm_call_node_t *) node;
+
+ // Command-style calls (e.g., foo bar, obj.foo bar).
+ // Attribute writes (e.g., a.b = 1) are not commands.
+ if (pm_call_node_command_p(call) && !PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE) && (call->receiver == NULL || call->call_operator_loc.length > 0)) {
+ return true;
+ }
+
+ // A `!` or `not` prefix wrapping a command call (e.g.,
+ // `!foo bar`, `not foo bar`) is also a command-call value.
+ if (call->receiver != NULL && call->arguments == NULL && call->opening_loc.length == 0 && call->call_operator_loc.length == 0) {
+ return pm_command_call_value_p(call->receiver);
+ }
+
+ return false;
+ }
+ case PM_SUPER_NODE: {
+ const pm_super_node_t *cast = (const pm_super_node_t *) node;
+ return cast->lparen_loc.length == 0 && (cast->arguments != NULL || cast->block != NULL);
+ }
+ case PM_YIELD_NODE: {
+ const pm_yield_node_t *cast = (const pm_yield_node_t *) node;
+ return cast->lparen_loc.length == 0 && cast->arguments != NULL;
+ }
+ case PM_RESCUE_MODIFIER_NODE:
+ return pm_command_call_value_p(((const pm_rescue_modifier_node_t *) node)->expression);
+ case PM_DEF_NODE: {
+ const pm_def_node_t *cast = (const pm_def_node_t *) node;
+ if (cast->equal_loc.length > 0 && cast->body != NULL) {
+ const pm_node_t *body = cast->body;
+ if (PM_NODE_TYPE_P(body, PM_STATEMENTS_NODE)) {
+ body = ((const pm_statements_node_t *) body)->body.nodes[((const pm_statements_node_t *) body)->body.size - 1];
+ }
+ return pm_command_call_value_p(body);
+ }
+ return false;
+ }
+ default:
+ return false;
+ }
+}
+
+/**
+ * Returns true if the given node is a block call: a command
+ * with a do-block, or any call chained (via `.`, `::`, `&.`) from such a node.
+ * Block calls can only be followed by call chaining, composition (and/or), and
+ * modifier operators.
+ */
+static bool
+pm_block_call_p(const pm_node_t *node) {
+ while (PM_NODE_TYPE_P(node, PM_CALL_NODE)) {
+ const pm_call_node_t *call = (const pm_call_node_t *) node;
+ if (call->opening_loc.length > 0) return false;
+
+ // Root: command with do-block (e.g., `foo bar do end`).
+ if (call->arguments != NULL && call->block != NULL && PM_NODE_TYPE_P(call->block, PM_BLOCK_NODE)) {
+ return true;
+ }
+
+ // Walk up the receiver chain (e.g., `foo bar do end.baz`).
+ if (call->call_operator_loc.length > 0 && call->receiver != NULL) {
+ node = call->receiver;
+ continue;
+ }
+
+ return false;
+ }
+
+ return false;
+}
+
+/**
+ * Parse a case expression (the `case` keyword). This handles both case-when and
+ * case-in (pattern matching) forms.
+ */
+static pm_node_t *
+parse_case(pm_parser_t *parser, uint8_t flags, uint16_t depth) {
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+
+ pm_token_t case_keyword = parser->previous;
+ pm_node_t *predicate = NULL;
+
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ while (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON));
+ predicate = NULL;
+ } else if (match3(parser, PM_TOKEN_KEYWORD_WHEN, PM_TOKEN_KEYWORD_IN, PM_TOKEN_KEYWORD_END)) {
+ predicate = NULL;
+ } else if (!token_begins_expression_p(parser->current.type)) {
+ predicate = NULL;
+ } else {
+ predicate = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CASE_EXPRESSION_AFTER_CASE, (uint16_t) (depth + 1));
+ while (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON));
+ }
+
+ if (match1(parser, PM_TOKEN_KEYWORD_END)) {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &case_keyword, false, false);
+ parser_lex(parser);
+ pop_block_exits(parser, previous_block_exits);
+ pm_parser_err_token(parser, &case_keyword, PM_ERR_CASE_MISSING_CONDITIONS);
+ return UP(pm_case_node_create(parser, &case_keyword, predicate, &parser->previous));
+ }
+
+ /* At this point we can create a case node, though we don't yet know if it
+ * is a case-in or case-when node. */
+ pm_node_t *node;
+
+ if (match1(parser, PM_TOKEN_KEYWORD_WHEN)) {
+ pm_case_node_t *case_node = pm_case_node_create(parser, &case_keyword, predicate, NULL);
+ pm_static_literals_t literals = { 0 };
+
+ /* At this point we've seen a when keyword, so we know this is a
+ * case-when node. We will continue to parse the when nodes until we hit
+ * the end of the list. */
+ while (match1(parser, PM_TOKEN_KEYWORD_WHEN)) {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &case_keyword, false, true);
+ parser_lex(parser);
+
+ pm_token_t when_keyword = parser->previous;
+ pm_when_node_t *when_node = pm_when_node_create(parser, &when_keyword);
+
+ do {
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ pm_token_t operator = parser->previous;
+ pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+
+ pm_splat_node_t *splat_node = pm_splat_node_create(parser, &operator, expression);
+ pm_when_node_conditions_append(parser->arena, when_node, UP(splat_node));
+
+ if (PM_NODE_TYPE_P(expression, PM_ERROR_RECOVERY_NODE)) break;
+ } else {
+ pm_node_t *condition = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_CASE_EXPRESSION_AFTER_WHEN, (uint16_t) (depth + 1));
+ pm_when_node_conditions_append(parser->arena, when_node, condition);
+
+ /* If we found a missing node, then this is a syntax error
+ * and we should stop looping. */
+ if (PM_NODE_TYPE_P(condition, PM_ERROR_RECOVERY_NODE)) break;
+
+ /* If this is a string node, then we need to mark it as
+ * frozen because when clause strings are frozen. */
+ if (PM_NODE_TYPE_P(condition, PM_STRING_NODE)) {
+ pm_node_flag_set(condition, PM_STRING_FLAGS_FROZEN | PM_NODE_FLAG_STATIC_LITERAL);
+ } else if (PM_NODE_TYPE_P(condition, PM_SOURCE_FILE_NODE)) {
+ pm_node_flag_set(condition, PM_NODE_FLAG_STATIC_LITERAL);
+ }
+
+ pm_when_clause_static_literals_add(parser, &literals, condition);
+ }
+ } while (accept1(parser, PM_TOKEN_COMMA));
+
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ if (accept1(parser, PM_TOKEN_KEYWORD_THEN)) {
+ pm_when_node_then_keyword_loc_set(parser, when_node, &parser->previous);
+ }
+ } else {
+ expect1(parser, PM_TOKEN_KEYWORD_THEN, PM_ERR_EXPECT_WHEN_DELIMITER);
+ pm_when_node_then_keyword_loc_set(parser, when_node, &parser->previous);
+ }
+
+ if (!match3(parser, PM_TOKEN_KEYWORD_WHEN, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_CASE_WHEN, (uint16_t) (depth + 1));
+ if (statements != NULL) {
+ pm_when_node_statements_set(when_node, statements);
+ }
+ }
+
+ pm_case_node_condition_append(parser->arena, case_node, UP(when_node));
+ }
+
+ /* If we didn't parse any conditions (in or when) then we need to
+ * indicate that we have an error. */
+ if (case_node->conditions.size == 0) {
+ pm_parser_err_token(parser, &case_keyword, PM_ERR_CASE_MISSING_CONDITIONS);
+ }
+
+ pm_static_literals_free(&literals);
+ node = UP(case_node);
+ } else {
+ pm_case_match_node_t *case_node = pm_case_match_node_create(parser, &case_keyword, predicate);
+
+ /* If this is a case-match node (i.e., it is a pattern matching case
+ * statement) then we must have a predicate. */
+ if (predicate == NULL) {
+ pm_parser_err_token(parser, &case_keyword, PM_ERR_CASE_MATCH_MISSING_PREDICATE);
+ }
+
+ /* At this point we expect that we're parsing a case-in node. We will
+ * continue to parse the in nodes until we hit the end of the list. */
+ while (match1(parser, PM_TOKEN_KEYWORD_IN)) {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &case_keyword, false, true);
+
+ bool previous_pattern_matching_newlines = parser->pattern_matching_newlines;
+ parser->pattern_matching_newlines = true;
+
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ parser->command_start = false;
+ parser_lex(parser);
+
+ pm_token_t in_keyword = parser->previous;
+
+ pm_constant_id_list_t captures = { 0 };
+ pm_node_t *pattern = parse_pattern(parser, &captures, PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_IN, (uint16_t) (depth + 1));
+
+ parser->pattern_matching_newlines = previous_pattern_matching_newlines;
+
+ /* Since we're in the top-level of the case-in node we need to
+ * check for guard clauses in the form of `if` or `unless`
+ * statements. */
+ if (accept1(parser, PM_TOKEN_KEYWORD_IF_MODIFIER)) {
+ pm_token_t keyword = parser->previous;
+ pm_node_t *predicate = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_IF_PREDICATE, (uint16_t) (depth + 1));
+ pattern = UP(pm_if_node_modifier_create(parser, pattern, &keyword, predicate));
+ } else if (accept1(parser, PM_TOKEN_KEYWORD_UNLESS_MODIFIER)) {
+ pm_token_t keyword = parser->previous;
+ pm_node_t *predicate = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_UNLESS_PREDICATE, (uint16_t) (depth + 1));
+ pattern = UP(pm_unless_node_modifier_create(parser, pattern, &keyword, predicate));
+ }
+
+ /* Now we need to check for the terminator of the in node's pattern.
+ * It can be a newline or semicolon optionally followed by a `then`
+ * keyword. */
+ pm_token_t then_keyword = { 0 };
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ if (accept1(parser, PM_TOKEN_KEYWORD_THEN)) {
+ then_keyword = parser->previous;
+ }
+ } else {
+ expect1(parser, PM_TOKEN_KEYWORD_THEN, PM_ERR_EXPECT_IN_DELIMITER);
+ then_keyword = parser->previous;
+ }
+
+ /* Now we can actually parse the statements associated with the in
+ * node. */
+ pm_statements_node_t *statements;
+ if (match3(parser, PM_TOKEN_KEYWORD_IN, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ statements = NULL;
+ } else {
+ statements = parse_statements(parser, PM_CONTEXT_CASE_IN, (uint16_t) (depth + 1));
+ }
+
+ /* Now that we have the full pattern and statements, we can create
+ * the node and attach it to the case node. */
+ pm_node_t *condition = UP(pm_in_node_create(parser, pattern, statements, &in_keyword, NTOK2PTR(then_keyword)));
+ pm_case_match_node_condition_append(parser->arena, case_node, condition);
+ }
+
+ /* If we didn't parse any conditions (in or when) then we need to
+ * indicate that we have an error. */
+ if (case_node->conditions.size == 0) {
+ pm_parser_err_token(parser, &case_keyword, PM_ERR_CASE_MISSING_CONDITIONS);
+ }
+
+ node = UP(case_node);
+ }
+
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ if (accept1(parser, PM_TOKEN_KEYWORD_ELSE)) {
+ pm_token_t else_keyword = parser->previous;
+ pm_else_node_t *else_node;
+
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ else_node = pm_else_node_create(parser, &else_keyword, parse_statements(parser, PM_CONTEXT_ELSE, (uint16_t) (depth + 1)), &parser->current);
+ } else {
+ else_node = pm_else_node_create(parser, &else_keyword, NULL, &parser->current);
+ }
+
+ if (PM_NODE_TYPE_P(node, PM_CASE_NODE)) {
+ pm_case_node_else_clause_set((pm_case_node_t *) node, else_node);
+ } else {
+ pm_case_match_node_else_clause_set((pm_case_match_node_t *) node, else_node);
+ }
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &case_keyword, false, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CASE_TERM, &case_keyword);
+
+ if (PM_NODE_TYPE_P(node, PM_CASE_NODE)) {
+ pm_case_node_end_keyword_loc_set(parser, (pm_case_node_t *) node, &parser->previous);
+ } else {
+ pm_case_match_node_end_keyword_loc_set(parser, (pm_case_match_node_t *) node, &parser->previous);
+ }
+
+ pop_block_exits(parser, previous_block_exits);
+ return node;
+}
+
+/**
+ * Parse a class definition expression (the `class` keyword). This handles both
+ * regular class definitions and singleton class definitions (`class << expr`).
+ */
+static pm_node_t *
+parse_class(pm_parser_t *parser, uint8_t flags, uint16_t depth) {
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+
+ pm_token_t class_keyword = parser->previous;
+ pm_do_loop_stack_push(parser, false);
+
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ if (accept1(parser, PM_TOKEN_LESS_LESS)) {
+ pm_token_t operator = parser->previous;
+ pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS, (uint16_t) (depth + 1));
+
+ pm_parser_scope_push(parser, true);
+ if (!match2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER, pm_token_str(parser->current.type));
+ }
+
+ pm_node_t *statements = NULL;
+ if (!match4(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = UP(parse_statements(parser, PM_CONTEXT_SCLASS, (uint16_t) (depth + 1)));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) {
+ assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE));
+ statements = UP(parse_rescues_implicit_begin(parser, opening_newline_index, &class_keyword, class_keyword.start, (pm_statements_node_t *) statements, PM_RESCUES_SCLASS, (uint16_t) (depth + 1)));
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &class_keyword, false, false);
+ }
+
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CLASS_TERM, &class_keyword);
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, false);
+
+ pm_parser_scope_pop(parser);
+ pm_do_loop_stack_pop(parser);
+
+ flush_block_exits(parser, previous_block_exits);
+ return UP(pm_singleton_class_node_create(parser, &locals, &class_keyword, &operator, expression, statements, &parser->previous));
+ }
+
+ pm_node_t *constant_path = parse_expression(parser, PM_BINDING_POWER_INDEX, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_CLASS_NAME, (uint16_t) (depth + 1));
+ pm_token_t name = parser->previous;
+ if (name.type != PM_TOKEN_CONSTANT) {
+ pm_parser_err_token(parser, &name, PM_ERR_CLASS_NAME);
+ }
+
+ pm_token_t inheritance_operator = { 0 };
+ pm_node_t *superclass;
+
+ if (match1(parser, PM_TOKEN_LESS)) {
+ inheritance_operator = parser->current;
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+
+ parser->command_start = true;
+ parser_lex(parser);
+
+ superclass = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CLASS_SUPERCLASS, (uint16_t) (depth + 1));
+ } else {
+ superclass = NULL;
+ }
+
+ pm_parser_scope_push(parser, true);
+
+ if (inheritance_operator.start != NULL) {
+ expect2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_ERR_CLASS_UNEXPECTED_END);
+ } else {
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+ pm_node_t *statements = NULL;
+
+ if (!match4(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = UP(parse_statements(parser, PM_CONTEXT_CLASS, (uint16_t) (depth + 1)));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) {
+ assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE));
+ statements = UP(parse_rescues_implicit_begin(parser, opening_newline_index, &class_keyword, class_keyword.start, (pm_statements_node_t *) statements, PM_RESCUES_CLASS, (uint16_t) (depth + 1)));
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &class_keyword, false, false);
+ }
+
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_CLASS_TERM, &class_keyword);
+
+ if (context_def_p(parser)) {
+ pm_parser_err_token(parser, &class_keyword, PM_ERR_CLASS_IN_METHOD);
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, false);
+
+ pm_parser_scope_pop(parser);
+ pm_do_loop_stack_pop(parser);
+
+ if (!PM_NODE_TYPE_P(constant_path, PM_CONSTANT_PATH_NODE) && !(PM_NODE_TYPE_P(constant_path, PM_CONSTANT_READ_NODE))) {
+ pm_parser_err_node(parser, constant_path, PM_ERR_CLASS_NAME);
+ if (!PM_NODE_TYPE_P(constant_path, PM_ERROR_RECOVERY_NODE)) {
+ constant_path = UP(pm_error_recovery_node_create_unexpected(parser, constant_path));
+ }
+ }
+
+ pop_block_exits(parser, previous_block_exits);
+ return UP(pm_class_node_create(parser, &locals, &class_keyword, constant_path, &name, NTOK2PTR(inheritance_operator), superclass, statements, &parser->previous));
+}
+
+/**
+ * Parse a method definition expression (the `def` keyword).
+ */
+static pm_node_t *
+parse_def(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, uint16_t depth) {
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ pm_token_t def_keyword = parser->current;
+ size_t opening_newline_index = token_newline_index(parser);
+
+ pm_node_t *receiver = NULL;
+ pm_token_t operator = { 0 };
+ pm_token_t name;
+
+ /* This context is necessary for lexing `...` in a bare params correctly. It
+ * must be pushed before lexing the first param, so it is here. */
+ context_push(parser, PM_CONTEXT_DEF_PARAMS);
+ parser_lex(parser);
+
+ /* This will be false if the method name is not a valid identifier but could
+ * be followed by an operator. */
+ bool valid_name = true;
+
+ switch (parser->current.type) {
+ case PM_CASE_OPERATOR:
+ pm_parser_scope_push(parser, true);
+ lex_state_set(parser, PM_LEX_STATE_ENDFN);
+ parser_lex(parser);
+
+ name = parser->previous;
+ break;
+ case PM_TOKEN_IDENTIFIER: {
+ parser_lex(parser);
+
+ if (match2(parser, PM_TOKEN_DOT, PM_TOKEN_COLON_COLON)) {
+ receiver = parse_variable_call(parser);
+
+ pm_parser_scope_push(parser, true);
+ lex_state_set(parser, PM_LEX_STATE_FNAME);
+ parser_lex(parser);
+
+ operator = parser->previous;
+ name = parse_method_definition_name(parser);
+ } else {
+ pm_refute_numbered_parameter(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous));
+ pm_parser_scope_push(parser, true);
+
+ name = parser->previous;
+ }
+
+ break;
+ }
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ case PM_TOKEN_CLASS_VARIABLE:
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ valid_name = false;
+ PRISM_FALLTHROUGH
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_KEYWORD_NIL:
+ case PM_TOKEN_KEYWORD_SELF:
+ case PM_TOKEN_KEYWORD_TRUE:
+ case PM_TOKEN_KEYWORD_FALSE:
+ case PM_TOKEN_KEYWORD___FILE__:
+ case PM_TOKEN_KEYWORD___LINE__:
+ case PM_TOKEN_KEYWORD___ENCODING__: {
+ pm_parser_scope_push(parser, true);
+ parser_lex(parser);
+
+ pm_token_t identifier = parser->previous;
+
+ if (match2(parser, PM_TOKEN_DOT, PM_TOKEN_COLON_COLON)) {
+ lex_state_set(parser, PM_LEX_STATE_FNAME);
+ parser_lex(parser);
+ operator = parser->previous;
+
+ switch (identifier.type) {
+ case PM_TOKEN_CONSTANT:
+ receiver = UP(pm_constant_read_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ receiver = UP(pm_instance_variable_read_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_CLASS_VARIABLE:
+ receiver = UP(pm_class_variable_read_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ receiver = UP(pm_global_variable_read_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD_NIL:
+ receiver = UP(pm_nil_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD_SELF:
+ receiver = UP(pm_self_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD_TRUE:
+ receiver = UP(pm_true_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD_FALSE:
+ receiver = UP(pm_false_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD___FILE__:
+ receiver = UP(pm_source_file_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD___LINE__:
+ receiver = UP(pm_source_line_node_create(parser, &identifier));
+ break;
+ case PM_TOKEN_KEYWORD___ENCODING__:
+ receiver = UP(pm_source_encoding_node_create(parser, &identifier));
+ break;
+ default:
+ break;
+ }
+
+ name = parse_method_definition_name(parser);
+ } else {
+ if (!valid_name) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &identifier, PM_ERR_DEF_NAME, pm_token_str(identifier.type));
+ }
+
+ name = identifier;
+ }
+ break;
+ }
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ /* The current context is `PM_CONTEXT_DEF_PARAMS`, however the inner
+ * expression of this parenthesis should not be processed under this
+ * context. Thus, the context is popped here. */
+ context_pop(parser);
+ parser_lex(parser);
+
+ pm_token_t lparen = parser->previous;
+ pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_DEF_RECEIVER, (uint16_t) (depth + 1));
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+ pm_token_t rparen = parser->previous;
+
+ lex_state_set(parser, PM_LEX_STATE_FNAME);
+ expect2(parser, PM_TOKEN_DOT, PM_TOKEN_COLON_COLON, PM_ERR_DEF_RECEIVER_TERM);
+
+ operator = parser->previous;
+ receiver = UP(pm_parentheses_node_create(parser, &lparen, expression, &rparen, 0));
+
+ /* To push `PM_CONTEXT_DEF_PARAMS` again is for the same reason as
+ * described the above. */
+ pm_parser_scope_push(parser, true);
+ context_push(parser, PM_CONTEXT_DEF_PARAMS);
+ name = parse_method_definition_name(parser);
+ break;
+ }
+ default:
+ pm_parser_scope_push(parser, true);
+ name = parse_method_definition_name(parser);
+ break;
+ }
+
+ pm_token_t lparen = { 0 };
+ pm_token_t rparen = { 0 };
+ pm_parameters_node_t *params;
+
+ bool accept_endless_def = true;
+ switch (parser->current.type) {
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ parser_lex(parser);
+ lparen = parser->previous;
+
+ if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ params = NULL;
+ } else {
+ /* https://bugs.ruby-lang.org/issues/19107 */
+ bool allow_trailing_comma = parser->version >= PM_OPTIONS_VERSION_CRUBY_4_1;
+ params = parse_parameters(
+ parser,
+ PM_BINDING_POWER_DEFINED,
+ true,
+ allow_trailing_comma,
+ true,
+ true,
+ false,
+ PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
+ (uint16_t) (depth + 1)
+ );
+ }
+
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+
+ context_pop(parser);
+ if (!accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_DEF_PARAMS_TERM_PAREN, pm_token_str(parser->current.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+
+ rparen = parser->previous;
+ break;
+ }
+ case PM_CASE_PARAMETER: {
+ /* If we're about to lex a label, we need to add the label state to
+ * make sure the next newline is ignored. */
+ if (parser->current.type == PM_TOKEN_LABEL) {
+ lex_state_set(parser, parser->lex_state | PM_LEX_STATE_LABEL);
+ }
+
+ params = parse_parameters(
+ parser,
+ PM_BINDING_POWER_DEFINED,
+ false,
+ false,
+ true,
+ true,
+ false,
+ PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
+ (uint16_t) (depth + 1)
+ );
+
+ /* Reject `def * = 1` and similar. We have to specifically check for
+ * them because they create ambiguity with optional arguments. */
+ accept_endless_def = false;
+
+ context_pop(parser);
+ break;
+ }
+ default: {
+ params = NULL;
+ context_pop(parser);
+ break;
+ }
+ }
+
+ pm_node_t *statements = NULL;
+ pm_token_t equal = { 0 };
+ pm_token_t end_keyword = { 0 };
+
+ if (accept1(parser, PM_TOKEN_EQUAL)) {
+ if (token_is_setter_name(&name)) {
+ pm_parser_err_token(parser, &name, PM_ERR_DEF_ENDLESS_SETTER);
+ }
+ if (!accept_endless_def) {
+ pm_parser_err_previous(parser, PM_ERR_DEF_ENDLESS_PARAMETERS);
+ }
+ if (
+ parser->current_context->context == PM_CONTEXT_DEFAULT_PARAMS &&
+ parser->current_context->prev->context == PM_CONTEXT_BLOCK_PARAMETERS
+ ) {
+ PM_PARSER_ERR_FORMAT(parser, PM_TOKEN_START(parser, &def_keyword), PM_TOKENS_LENGTH(&def_keyword, &parser->previous), PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE, "endless method definition");
+ }
+ equal = parser->previous;
+
+ context_push(parser, PM_CONTEXT_DEF);
+ pm_do_loop_stack_push(parser, false);
+ statements = UP(pm_statements_node_create(parser));
+
+ uint8_t allow_flags;
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) {
+ allow_flags = flags & PM_PARSE_ACCEPTS_COMMAND_CALL;
+ } else {
+ /* Allow `def foo = puts "Hello"` but not
+ * `private def foo = puts "Hello"` */
+ allow_flags = (binding_power == PM_BINDING_POWER_ASSIGNMENT || binding_power < PM_BINDING_POWER_COMPOSITION) ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0;
+ }
+
+ /* Inside a def body, we push true onto the accepts_block_stack so that
+ * `do` is lexed as PM_TOKEN_KEYWORD_DO (which can only start a block
+ * for primary-level constructs, not commands). During command argument
+ * parsing, the stack is pushed to false, causing `do` to be lexed as
+ * PM_TOKEN_KEYWORD_DO_BLOCK, which is not consumed inside the endless
+ * def body and instead left for the outer context. */
+ pm_accepts_block_stack_push(parser, true);
+ pm_node_t *statement = parse_expression(parser, PM_BINDING_POWER_DEFINED + 1, allow_flags | PM_PARSE_IN_ENDLESS_DEF, PM_ERR_DEF_ENDLESS, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+
+ /* If an unconsumed PM_TOKEN_KEYWORD_DO follows the body, it is an error
+ * (e.g., `def f = 1 do end`). PM_TOKEN_KEYWORD_DO_BLOCK is
+ * intentionally not caught here — it should bubble up to the outer
+ * context (e.g., `private def f = puts "Hello" do end` where the block
+ * attaches to `private`). */
+ if (accept1(parser, PM_TOKEN_KEYWORD_DO)) {
+ pm_block_node_t *block = parse_block(parser, (uint16_t) (depth + 1));
+ pm_parser_err_node(parser, UP(block), PM_ERR_DEF_ENDLESS_DO_BLOCK);
+ }
+
+ if (accept1(parser, PM_TOKEN_KEYWORD_RESCUE_MODIFIER)) {
+ context_push(parser, PM_CONTEXT_RESCUE_MODIFIER);
+
+ pm_token_t rescue_keyword = parser->previous;
+
+ /* In the Ruby grammar, the rescue value of an endless method
+ * command excludes and/or and in/=>. */
+ pm_node_t *value = parse_expression(parser, PM_BINDING_POWER_MATCH + 1, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_RESCUE_MODIFIER_VALUE, (uint16_t) (depth + 1));
+ context_pop(parser);
+
+ statement = UP(pm_rescue_modifier_node_create(parser, statement, &rescue_keyword, value));
+ }
+
+ /* A nested endless def whose body is a command call (e.g.,
+ * `def f = def g = foo bar`) is a command assignment and cannot appear
+ * as a def body. */
+ if (PM_NODE_TYPE_P(statement, PM_DEF_NODE) && pm_command_call_value_p(statement)) {
+ PM_PARSER_ERR_NODE_FORMAT(parser, statement, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ }
+
+ pm_statements_node_body_append(parser, (pm_statements_node_t *) statements, statement, false);
+ pm_do_loop_stack_pop(parser);
+ context_pop(parser);
+ } else {
+ if (lparen.start == NULL) {
+ lex_state_set(parser, PM_LEX_STATE_BEG);
+ parser->command_start = true;
+ expect2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_ERR_DEF_PARAMS_TERM);
+ } else {
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ pm_accepts_block_stack_push(parser, true);
+ pm_do_loop_stack_push(parser, false);
+
+ if (!match4(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = UP(parse_statements(parser, PM_CONTEXT_DEF, (uint16_t) (depth + 1)));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ if (match3(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE)) {
+ assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE));
+ statements = UP(parse_rescues_implicit_begin(parser, opening_newline_index, &def_keyword, def_keyword.start, (pm_statements_node_t *) statements, PM_RESCUES_DEF, (uint16_t) (depth + 1)));
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &def_keyword, false, false);
+ }
+
+ pm_accepts_block_stack_pop(parser);
+ pm_do_loop_stack_pop(parser);
+
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_DEF_TERM, &def_keyword);
+ end_keyword = parser->previous;
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, false);
+ pm_parser_scope_pop(parser);
+
+ /* If the final character is `@` as is the case when defining methods to
+ * override the unary operators, we should ignore the @ in the same way we
+ * do for symbols. */
+ pm_constant_id_t name_id = pm_parser_constant_id_raw(parser, name.start, parse_operator_symbol_name(&name));
+
+ flush_block_exits(parser, previous_block_exits);
+
+ return UP(pm_def_node_create(
+ parser,
+ name_id,
+ &name,
+ receiver,
+ params,
+ statements,
+ &locals,
+ &def_keyword,
+ NTOK2PTR(operator),
+ NTOK2PTR(lparen),
+ NTOK2PTR(rparen),
+ NTOK2PTR(equal),
+ NTOK2PTR(end_keyword)
+ ));
+}
+
+/**
+ * Parse a module definition expression (the `module` keyword).
+ */
+static pm_node_t *
+parse_module(pm_parser_t *parser, uint8_t flags, uint16_t depth) {
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+ pm_token_t module_keyword = parser->previous;
+
+ pm_node_t *constant_path = parse_expression(parser, PM_BINDING_POWER_INDEX, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_MODULE_NAME, (uint16_t) (depth + 1));
+ pm_token_t name;
+
+ /* If we can recover from a syntax error that occurred while parsing the
+ * name of the module, then we'll handle that here. */
+ if (PM_NODE_TYPE_P(constant_path, PM_ERROR_RECOVERY_NODE)) {
+ pop_block_exits(parser, previous_block_exits);
+
+ pm_token_t missing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ return UP(pm_module_node_create(parser, NULL, &module_keyword, constant_path, &missing, NULL, &missing));
+ }
+
+ while (accept1(parser, PM_TOKEN_COLON_COLON)) {
+ pm_token_t double_colon = parser->previous;
+
+ expect1(parser, PM_TOKEN_CONSTANT, PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT);
+ constant_path = UP(pm_constant_path_node_create(parser, constant_path, &double_colon, &parser->previous));
+ }
+
+ /* Here we retrieve the name of the module. If it wasn't a constant, then
+ * it's possible that `module foo` was passed, which is a syntax error. We
+ * handle that here as well. */
+ name = parser->previous;
+ if (name.type != PM_TOKEN_CONSTANT) {
+ pm_parser_err_token(parser, &name, PM_ERR_MODULE_NAME);
+ }
+
+ if (!PM_NODE_TYPE_P(constant_path, PM_CONSTANT_READ_NODE) && !PM_NODE_TYPE_P(constant_path, PM_CONSTANT_PATH_NODE) && !PM_NODE_TYPE_P(constant_path, PM_ERROR_RECOVERY_NODE)) {
+ constant_path = UP(pm_error_recovery_node_create_unexpected(parser, constant_path));
+ }
+
+ pm_parser_scope_push(parser, true);
+ accept2(parser, PM_TOKEN_SEMICOLON, PM_TOKEN_NEWLINE);
+ pm_node_t *statements = NULL;
+
+ if (!match4(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = UP(parse_statements(parser, PM_CONTEXT_MODULE, (uint16_t) (depth + 1)));
+ pm_accepts_block_stack_pop(parser);
+ }
+
+ if (match3(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE)) {
+ assert(statements == NULL || PM_NODE_TYPE_P(statements, PM_STATEMENTS_NODE));
+ statements = UP(parse_rescues_implicit_begin(parser, opening_newline_index, &module_keyword, module_keyword.start, (pm_statements_node_t *) statements, PM_RESCUES_MODULE, (uint16_t) (depth + 1)));
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &module_keyword, false, false);
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, false);
+
+ pm_parser_scope_pop(parser);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_MODULE_TERM, &module_keyword);
+
+ if (context_def_p(parser)) {
+ pm_parser_err_token(parser, &module_keyword, PM_ERR_MODULE_IN_METHOD);
+ }
+
+ pop_block_exits(parser, previous_block_exits);
+
+ return UP(pm_module_node_create(parser, &locals, &module_keyword, constant_path, &name, statements, &parser->previous));
+}
+
+/**
+ * Parse an interpolated word array literal (`%W[...]`).
+ */
+static pm_node_t *
+parse_string_array(pm_parser_t *parser, uint16_t depth) {
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+ pm_array_node_t *array = pm_array_node_create(parser, &opening);
+
+ /* This is the current node that we are parsing that will be added to the
+ * list of elements. */
+ pm_node_t *current = NULL;
+
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ switch (parser->current.type) {
+ case PM_TOKEN_WORDS_SEP: {
+ /* Reset the explicit encoding if we hit a separator since each
+ * element can have its own encoding. */
+ parser->explicit_encoding = NULL;
+
+ if (current == NULL) {
+ /* If we hit a separator before we have any content, then we
+ * don't need to do anything. */
+ } else {
+ /* If we hit a separator after we've hit content, then we
+ * need to append that content to the list and reset the
+ * current node. */
+ pm_array_node_elements_append(parser->arena, array, current);
+ current = NULL;
+ }
+
+ parser_lex(parser);
+ break;
+ }
+ case PM_TOKEN_STRING_CONTENT: {
+ pm_node_t *string = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+ pm_node_flag_set(string, parse_unescaped_encoding(parser));
+ parser_lex(parser);
+
+ if (current == NULL) {
+ /* If we hit content and the current node is NULL, then this
+ * is the first string content we've seen. In that case
+ * we're going to create a new string node and set that to
+ * the current. */
+ current = string;
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) {
+ /* If we hit string content and the current node is an
+ * interpolated string, then we need to append the string
+ * content to the list of child nodes. */
+ pm_interpolated_string_node_append(parser, (pm_interpolated_string_node_t *) current, string);
+ } else if (PM_NODE_TYPE_P(current, PM_STRING_NODE)) {
+ /* If we hit string content and the current node is a string
+ * node, then we need to convert the current node into an
+ * interpolated string and add the string content to the
+ * list of child nodes. */
+ pm_interpolated_string_node_t *interpolated = pm_interpolated_string_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_string_node_append(parser, interpolated, current);
+ pm_interpolated_string_node_append(parser, interpolated, string);
+ current = UP(interpolated);
+ } else {
+ assert(false && "unreachable");
+ }
+
+ break;
+ }
+ case PM_TOKEN_EMBVAR: {
+ if (current == NULL) {
+ /* If we hit an embedded variable and the current node is
+ * NULL, then this is the start of a new string. We'll set
+ * the current node to a new interpolated string. */
+ current = UP(pm_interpolated_string_node_create(parser, NULL, NULL, NULL));
+ } else if (PM_NODE_TYPE_P(current, PM_STRING_NODE)) {
+ /* If we hit an embedded variable and the current node is a
+ * string node, then we'll convert the current into an
+ * interpolated string and add the string node to the list
+ * of parts. */
+ pm_interpolated_string_node_t *interpolated = pm_interpolated_string_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_string_node_append(parser, interpolated, current);
+ current = UP(interpolated);
+ } else {
+ /* If we hit an embedded variable and the current node is an
+ * interpolated string, then we'll just add the embedded
+ * variable. */
+ }
+
+ pm_node_t *part = parse_string_part(parser, (uint16_t) (depth + 1));
+ pm_interpolated_string_node_append(parser, (pm_interpolated_string_node_t *) current, part);
+ break;
+ }
+ case PM_TOKEN_EMBEXPR_BEGIN: {
+ if (current == NULL) {
+ /* If we hit an embedded expression and the current node is
+ * NULL, then this is the start of a new string. We'll set
+ * the current node to a new interpolated string. */
+ current = UP(pm_interpolated_string_node_create(parser, NULL, NULL, NULL));
+ } else if (PM_NODE_TYPE_P(current, PM_STRING_NODE)) {
+ /* If we hit an embedded expression and the current node is
+ * a string node, then we'll convert the current into an
+ * interpolated string and add the string node to the list
+ * of parts. */
+ pm_interpolated_string_node_t *interpolated = pm_interpolated_string_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_string_node_append(parser, interpolated, current);
+ current = UP(interpolated);
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) {
+ /* If we hit an embedded expression and the current node is
+ * an interpolated string, then we'll just continue on. */
+ } else {
+ assert(false && "unreachable");
+ }
+
+ pm_node_t *part = parse_string_part(parser, (uint16_t) (depth + 1));
+ pm_interpolated_string_node_append(parser, (pm_interpolated_string_node_t *) current, part);
+ break;
+ }
+ default:
+ expect1(parser, PM_TOKEN_STRING_CONTENT, PM_ERR_LIST_W_UPPER_ELEMENT);
+ parser_lex(parser);
+ break;
+ }
+ }
+
+ /* If we have a current node, then we need to append it to the list. */
+ if (current) {
+ pm_array_node_elements_append(parser->arena, array, current);
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_LIST_W_UPPER_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_LIST_W_UPPER_TERM);
+ }
+
+ pm_array_node_close_set(parser, array, &closing);
+ return UP(array);
+}
+
+/**
+ * Parse an interpolated symbol array literal (`%I[...]`).
+ */
+static pm_node_t *
+parse_symbol_array(pm_parser_t *parser, uint16_t depth) {
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+ pm_array_node_t *array = pm_array_node_create(parser, &opening);
+
+ /* This is the current node that we are parsing that will be added to the
+ * list of elements. */
+ pm_node_t *current = NULL;
+
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ switch (parser->current.type) {
+ case PM_TOKEN_WORDS_SEP: {
+ if (current == NULL) {
+ /* If we hit a separator before we have any content, then we
+ * don't need to do anything. */
+ } else {
+ /* If we hit a separator after we've hit content, then we
+ * need to append that content to the list and reset the
+ * current node. */
+ pm_array_node_elements_append(parser->arena, array, current);
+ current = NULL;
+ }
+
+ parser_lex(parser);
+ break;
+ }
+ case PM_TOKEN_STRING_CONTENT: {
+ if (current == NULL) {
+ /* If we hit content and the current node is NULL, then this
+ * is the first string content we've seen. In that case
+ * we're going to create a new string node and set that to
+ * the current. */
+ current = UP(pm_symbol_node_create_current_string(parser, NULL, &parser->current, NULL));
+ parser_lex(parser);
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_SYMBOL_NODE)) {
+ /* If we hit string content and the current node is an
+ * interpolated string, then we need to append the string
+ * content to the list of child nodes. */
+ pm_node_t *string = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+ parser_lex(parser);
+
+ pm_interpolated_symbol_node_append(parser->arena, (pm_interpolated_symbol_node_t *) current, string);
+ } else if (PM_NODE_TYPE_P(current, PM_SYMBOL_NODE)) {
+ /* If we hit string content and the current node is a symbol
+ * node, then we need to convert the current node into an
+ * interpolated string and add the string content to the
+ * list of child nodes. */
+ pm_symbol_node_t *cast = (pm_symbol_node_t *) current;
+ pm_token_t content = {
+ .type = PM_TOKEN_STRING_CONTENT,
+ .start = parser->start + cast->value_loc.start,
+ .end = parser->start + cast->value_loc.start + cast->value_loc.length
+ };
+
+ pm_node_t *first_string = UP(pm_string_node_create_unescaped(parser, NULL, &content, NULL, &cast->unescaped));
+ pm_node_t *second_string = UP(pm_string_node_create_current_string(parser, NULL, &parser->previous, NULL));
+ parser_lex(parser);
+
+ pm_interpolated_symbol_node_t *interpolated = pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, first_string);
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, second_string);
+
+ current = UP(interpolated);
+ } else {
+ assert(false && "unreachable");
+ }
+
+ break;
+ }
+ case PM_TOKEN_EMBVAR: {
+ bool start_location_set = false;
+ if (current == NULL) {
+ /* If we hit an embedded variable and the current node is
+ * NULL, then this is the start of a new string. We'll set
+ * the current node to a new interpolated string. */
+ current = UP(pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL));
+ } else if (PM_NODE_TYPE_P(current, PM_SYMBOL_NODE)) {
+ /* If we hit an embedded variable and the current node is a
+ * string node, then we'll convert the current into an
+ * interpolated string and add the string node to the list
+ * of parts. */
+ pm_interpolated_symbol_node_t *interpolated = pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL);
+
+ current = UP(pm_symbol_node_to_string_node(parser, (pm_symbol_node_t *) current));
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, current);
+ PM_NODE_START_SET_NODE(interpolated, current);
+ start_location_set = true;
+ current = UP(interpolated);
+ } else {
+ /* If we hit an embedded variable and the current node is an
+ * interpolated string, then we'll just add the embedded
+ * variable. */
+ }
+
+ pm_node_t *part = parse_string_part(parser, (uint16_t) (depth + 1));
+ pm_interpolated_symbol_node_append(parser->arena, (pm_interpolated_symbol_node_t *) current, part);
+ if (!start_location_set) {
+ PM_NODE_START_SET_NODE(current, part);
+ }
+ break;
+ }
+ case PM_TOKEN_EMBEXPR_BEGIN: {
+ bool start_location_set = false;
+ if (current == NULL) {
+ /* If we hit an embedded expression and the current node is
+ * NULL, then this is the start of a new string. We'll set
+ * the current node to a new interpolated string. */
+ current = UP(pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL));
+ } else if (PM_NODE_TYPE_P(current, PM_SYMBOL_NODE)) {
+ /* If we hit an embedded expression and the current node is
+ * a string node, then we'll convert the current into an
+ * interpolated string and add the string node to the list
+ * of parts. */
+ pm_interpolated_symbol_node_t *interpolated = pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL);
+
+ current = UP(pm_symbol_node_to_string_node(parser, (pm_symbol_node_t *) current));
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, current);
+ PM_NODE_START_SET_NODE(interpolated, current);
+ start_location_set = true;
+ current = UP(interpolated);
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_SYMBOL_NODE)) {
+ /* If we hit an embedded expression and the current node is
+ * an interpolated string, then we'll just continue on. */
+ } else {
+ assert(false && "unreachable");
+ }
+
+ pm_node_t *part = parse_string_part(parser, (uint16_t) (depth + 1));
+ pm_interpolated_symbol_node_append(parser->arena, (pm_interpolated_symbol_node_t *) current, part);
+ if (!start_location_set) {
+ PM_NODE_START_SET_NODE(current, part);
+ }
+ break;
+ }
+ default:
+ expect1(parser, PM_TOKEN_STRING_CONTENT, PM_ERR_LIST_I_UPPER_ELEMENT);
+ parser_lex(parser);
+ break;
+ }
+ }
+
+ /* If we have a current node, then we need to append it to the list. */
+ if (current) {
+ pm_array_node_elements_append(parser->arena, array, current);
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_LIST_I_UPPER_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_LIST_I_UPPER_TERM);
+ }
+ pm_array_node_close_set(parser, array, &closing);
+
+ return UP(array);
+}
+
+/**
+ * Parse a parenthesized expression, which could be a grouping, a multi-target
+ * assignment, or a set of statements.
+ */
+static pm_node_t *
+parse_parentheses(pm_parser_t *parser, pm_binding_power_t binding_power, uint16_t depth) {
+ pm_token_t opening = parser->current;
+ pm_node_flags_t paren_flags = 0;
+
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ parser_lex(parser);
+ while (true) {
+ if (accept1(parser, PM_TOKEN_SEMICOLON)) {
+ paren_flags |= PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS;
+ } else if (!accept1(parser, PM_TOKEN_NEWLINE)) {
+ break;
+ }
+ }
+
+ /* If this is the end of the file or we match a right parenthesis, then we
+ * have an empty parentheses node, and we can immediately return. */
+ if (match2(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_EOF)) {
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+ pop_block_exits(parser, previous_block_exits);
+ return UP(pm_parentheses_node_create(parser, &opening, NULL, &parser->previous, paren_flags));
+ }
+
+ /* Otherwise, we're going to parse the first statement in the list of
+ * statements within the parentheses. */
+ pm_accepts_block_stack_push(parser, true);
+ context_push(parser, PM_CONTEXT_PARENS);
+ pm_node_t *statement = parse_expression(parser, PM_BINDING_POWER_STATEMENT, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_CANNOT_PARSE_EXPRESSION, (uint16_t) (depth + 1));
+ context_pop(parser);
+
+ /* Determine if this statement is followed by a terminator. In the case of a
+ * single statement, this is fine. But in the case of multiple statements
+ * it's required. */
+ bool terminator_found = false;
+
+ if (accept1(parser, PM_TOKEN_SEMICOLON)) {
+ terminator_found = true;
+ paren_flags |= PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS;
+ } else if (accept1(parser, PM_TOKEN_NEWLINE)) {
+ terminator_found = true;
+ }
+
+ if (terminator_found) {
+ while (true) {
+ if (accept1(parser, PM_TOKEN_SEMICOLON)) {
+ paren_flags |= PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS;
+ } else if (!accept1(parser, PM_TOKEN_NEWLINE)) {
+ break;
+ }
+ }
+ }
+
+ /* If we hit a right parenthesis, then we're done parsing the parentheses
+ * node, and we can check which kind of node we should return. */
+ if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ if (opening.type == PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES) {
+ lex_state_set(parser, PM_LEX_STATE_ENDARG);
+ }
+
+ parser_lex(parser);
+ pm_accepts_block_stack_pop(parser);
+ pop_block_exits(parser, previous_block_exits);
+
+ if (PM_NODE_TYPE_P(statement, PM_MULTI_TARGET_NODE) || PM_NODE_TYPE_P(statement, PM_SPLAT_NODE)) {
+ /* If we have a single statement and are ending on a right
+ * parenthesis, then we need to check if this is possibly a multiple
+ * target node. */
+ pm_multi_target_node_t *multi_target;
+
+ if (PM_NODE_TYPE_P(statement, PM_MULTI_TARGET_NODE) && ((pm_multi_target_node_t *) statement)->lparen_loc.length == 0) {
+ multi_target = (pm_multi_target_node_t *) statement;
+ } else {
+ multi_target = pm_multi_target_node_create(parser);
+ pm_multi_target_node_targets_append(parser, multi_target, statement);
+ }
+
+ multi_target->lparen_loc = TOK2LOC(parser, &opening);
+ multi_target->rparen_loc = TOK2LOC(parser, &parser->previous);
+ PM_NODE_START_SET_TOKEN(parser, multi_target, &opening);
+ PM_NODE_LENGTH_SET_TOKEN(parser, multi_target, &parser->previous);
+
+ pm_node_t *result;
+ if (match1(parser, PM_TOKEN_COMMA) && (binding_power == PM_BINDING_POWER_STATEMENT)) {
+ result = parse_targets(parser, UP(multi_target), PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ accept1(parser, PM_TOKEN_NEWLINE);
+ } else {
+ result = UP(multi_target);
+ }
+
+ if (context_p(parser, PM_CONTEXT_MULTI_TARGET)) {
+ /* All set, this is explicitly allowed by the parent context. */
+ } else if (context_p(parser, PM_CONTEXT_FOR_INDEX) && match1(parser, PM_TOKEN_KEYWORD_IN)) {
+ /* All set, we're inside a for loop and we're parsing multiple
+ * targets. */
+ } else if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ /* Multi targets are not allowed when it's not a statement
+ * level. */
+ pm_parser_err_node(parser, result, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ } else if (!match2(parser, PM_TOKEN_EQUAL, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ /* Multi targets must be followed by an equal sign in order to
+ * be valid (or a right parenthesis if they are nested). */
+ pm_parser_err_node(parser, result, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ return result;
+ }
+
+ /* If we have a single statement and are ending on a right parenthesis
+ * and we didn't return a multiple assignment node, then we can return a
+ * regular parentheses node now. */
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, statement, true);
+
+ return UP(pm_parentheses_node_create(parser, &opening, UP(statements), &parser->previous, paren_flags));
+ }
+
+ /* If we have more than one statement in the set of parentheses, then we are
+ * going to parse all of them as a list of statements. We'll do that here.
+ */
+ context_push(parser, PM_CONTEXT_PARENS);
+ paren_flags |= PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS;
+
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, statement, true);
+
+ /* If we didn't find a terminator and we didn't find a right parenthesis,
+ * then this is a syntax error. */
+ if (!terminator_found && !match1(parser, PM_TOKEN_EOF)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ }
+
+ /* Parse each statement within the parentheses. */
+ while (true) {
+ pm_node_t *node = parse_expression(parser, PM_BINDING_POWER_STATEMENT, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_CANNOT_PARSE_EXPRESSION, (uint16_t) (depth + 1));
+ pm_statements_node_body_append(parser, statements, node, true);
+
+ /* If we're recovering from a syntax error, then we need to stop parsing
+ * the statements now. */
+ if (parser->recovering) {
+ /* If this is the level of context where the recovery has happened,
+ * then we can mark the parser as done recovering. */
+ if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) parser->recovering = false;
+ break;
+ }
+
+ /* If we couldn't parse an expression at all, then we need to bail out
+ * of the loop. */
+ if (PM_NODE_TYPE_P(node, PM_ERROR_RECOVERY_NODE)) break;
+
+ /* If we successfully parsed a statement, then we are going to need a
+ * terminator to delimit them. */
+ if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
+ while (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON));
+ if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) break;
+ } else if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ break;
+ } else if (!match1(parser, PM_TOKEN_EOF)) {
+ /* If we're at the end of the file, then we're going to add an error
+ * after this for the ) anyway. */
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ }
+ }
+
+ context_pop(parser);
+ pm_accepts_block_stack_pop(parser);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+
+ /* When we're parsing multi targets, we allow them to be followed by a right
+ * parenthesis if they are at the statement level. This is only possible if
+ * they are the final statement in a parentheses. We need to explicitly
+ * reject that here. */
+ {
+ pm_node_t *statement = statements->body.nodes[statements->body.size - 1];
+
+ if (PM_NODE_TYPE_P(statement, PM_SPLAT_NODE)) {
+ pm_multi_target_node_t *multi_target = pm_multi_target_node_create(parser);
+ pm_multi_target_node_targets_append(parser, multi_target, statement);
+
+ statement = UP(multi_target);
+ statements->body.nodes[statements->body.size - 1] = statement;
+ }
+
+ if (PM_NODE_TYPE_P(statement, PM_MULTI_TARGET_NODE)) {
+ const uint8_t *offset = parser->start + PM_NODE_END(statement);
+ pm_token_t operator = { .type = PM_TOKEN_EQUAL, .start = offset, .end = offset };
+ pm_node_t *value = UP(pm_error_recovery_node_create(parser, PM_NODE_END(statement), 0));
+
+ statement = UP(pm_multi_write_node_create(parser, (pm_multi_target_node_t *) statement, &operator, value));
+ statements->body.nodes[statements->body.size - 1] = statement;
+
+ pm_parser_err_node(parser, statement, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+ }
+
+ pop_block_exits(parser, previous_block_exits);
+ pm_void_statements_check(parser, statements, true);
+ return UP(pm_parentheses_node_create(parser, &opening, UP(statements), &parser->previous, paren_flags));
+}
+
+/**
+ * Parse an expression that begins with the previous node that we just lexed.
+ */
+static PRISM_INLINE pm_node_t *
+parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ switch (parser->current.type) {
+ case PM_TOKEN_BRACKET_LEFT_ARRAY: {
+ parser_lex(parser);
+
+ pm_array_node_t *array = pm_array_node_create(parser, &parser->previous);
+ pm_accepts_block_stack_push(parser, true);
+ bool parsed_bare_hash = false;
+
+ while (!match2(parser, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_EOF)) {
+ bool accepted_newline = accept1(parser, PM_TOKEN_NEWLINE);
+
+ // Handle the case where we don't have a comma and we have a
+ // newline followed by a right bracket.
+ if (accepted_newline && match1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ break;
+ }
+
+ // Ensure that we have a comma between elements in the array.
+ if (array->elements.size > 0) {
+ if (accept1(parser, PM_TOKEN_COMMA)) {
+ // If there was a comma but we also accepts a newline,
+ // then this is a syntax error.
+ if (accepted_newline) {
+ pm_parser_err_previous(parser, PM_ERR_INVALID_COMMA);
+ }
+ } else {
+ // If there was no comma, then we need to add a syntax
+ // error.
+ PM_PARSER_ERR_FORMAT(parser, PM_TOKEN_END(parser, &parser->previous), 0, PM_ERR_ARRAY_SEPARATOR, pm_token_str(parser->current.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+ }
+
+ // If we have a right bracket immediately following a comma,
+ // this is allowed since it's a trailing comma. In this case we
+ // can break out of the loop.
+ if (match1(parser, PM_TOKEN_BRACKET_RIGHT)) break;
+
+ pm_node_t *element;
+
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ pm_token_t operator = parser->previous;
+ pm_node_t *expression = NULL;
+
+ if (match3(parser, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_EOF)) {
+ pm_parser_scope_forwarding_positionals_check(parser, &operator);
+ } else {
+ expression = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_ARRAY_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+ }
+
+ element = UP(pm_splat_node_create(parser, &operator, expression));
+ } else if (match2(parser, PM_TOKEN_LABEL, PM_TOKEN_USTAR_STAR)) {
+ if (parsed_bare_hash) {
+ pm_parser_err_current(parser, PM_ERR_EXPRESSION_BARE_HASH);
+ }
+
+ element = UP(pm_keyword_hash_node_create(parser));
+ pm_static_literals_t hash_keys = { 0 };
+
+ if (!match8(parser, PM_TOKEN_EOF, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_KEYWORD_DO_BLOCK, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_KEYWORD_DO, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ parse_assocs(parser, &hash_keys, element, (uint16_t) (depth + 1));
+ }
+
+ pm_static_literals_free(&hash_keys);
+ parsed_bare_hash = true;
+ } else {
+ element = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_LABEL), PM_ERR_ARRAY_EXPRESSION, (uint16_t) (depth + 1));
+
+ if (pm_symbol_node_label_p(parser, element) || accept1(parser, PM_TOKEN_EQUAL_GREATER)) {
+ if (parsed_bare_hash) {
+ pm_parser_err_previous(parser, PM_ERR_EXPRESSION_BARE_HASH);
+ }
+
+ pm_keyword_hash_node_t *hash = pm_keyword_hash_node_create(parser);
+ pm_static_literals_t hash_keys = { 0 };
+ pm_hash_key_static_literals_add(parser, &hash_keys, element);
+
+ pm_token_t operator = { 0 };
+ if (parser->previous.type == PM_TOKEN_EQUAL_GREATER) {
+ operator = parser->previous;
+ }
+
+ pm_node_t *value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_HASH_VALUE, (uint16_t) (depth + 1));
+ pm_node_t *assoc = UP(pm_assoc_node_create(parser, element, NTOK2PTR(operator), value));
+ pm_keyword_hash_node_elements_append(parser->arena, hash, assoc);
+
+ element = UP(hash);
+ if (accept1(parser, PM_TOKEN_COMMA) && !match1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ parse_assocs(parser, &hash_keys, element, (uint16_t) (depth + 1));
+ }
+
+ pm_static_literals_free(&hash_keys);
+ parsed_bare_hash = true;
+ }
+ }
+
+ pm_array_node_elements_append(parser->arena, array, element);
+ if (PM_NODE_TYPE_P(element, PM_ERROR_RECOVERY_NODE)) break;
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (!accept1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_ARRAY_TERM, pm_token_str(parser->current.type));
+ parser->previous.start = parser->previous.end;
+ parser->previous.type = 0;
+ }
+
+ pm_array_node_close_set(parser, array, &parser->previous);
+ pm_accepts_block_stack_pop(parser);
+
+ return UP(array);
+ }
+ case PM_TOKEN_PARENTHESIS_LEFT:
+ case PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES:
+ return parse_parentheses(parser, binding_power, depth);
+ case PM_TOKEN_BRACE_LEFT: {
+ // If we were passed a current_hash_keys via the parser, then that
+ // means we're already parsing a hash and we want to share the set
+ // of hash keys with this inner hash we're about to parse for the
+ // sake of warnings. We'll set it to NULL after we grab it to make
+ // sure subsequent expressions don't use it. Effectively this is a
+ // way of getting around passing it to every call to
+ // parse_expression.
+ pm_static_literals_t *current_hash_keys = parser->current_hash_keys;
+ parser->current_hash_keys = NULL;
+
+ pm_accepts_block_stack_push(parser, true);
+ parser_lex(parser);
+
+ pm_token_t opening = parser->previous;
+ pm_hash_node_t *node = pm_hash_node_create(parser, &opening);
+
+ if (!match2(parser, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_EOF)) {
+ if (current_hash_keys != NULL) {
+ parse_assocs(parser, current_hash_keys, UP(node), (uint16_t) (depth + 1));
+ } else {
+ pm_static_literals_t hash_keys = { 0 };
+ parse_assocs(parser, &hash_keys, UP(node), (uint16_t) (depth + 1));
+ pm_static_literals_free(&hash_keys);
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ }
+
+ pm_accepts_block_stack_pop(parser);
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_HASH_TERM, &opening);
+ pm_hash_node_closing_loc_set(parser, node, &parser->previous);
+
+ return UP(node);
+ }
+ case PM_TOKEN_CHARACTER_LITERAL: {
+ pm_node_t *node = UP(pm_string_node_create_current_string(
+ parser,
+ &(pm_token_t) {
+ .type = PM_TOKEN_STRING_BEGIN,
+ .start = parser->current.start,
+ .end = parser->current.start + 1
+ },
+ &(pm_token_t) {
+ .type = PM_TOKEN_STRING_CONTENT,
+ .start = parser->current.start + 1,
+ .end = parser->current.end
+ },
+ NULL
+ ));
+
+ pm_node_flag_set(node, parse_unescaped_encoding(parser));
+
+ // Skip past the character literal here, since now we have handled
+ // parser->explicit_encoding correctly.
+ parser_lex(parser);
+
+ // Characters can be followed by strings in which case they are
+ // automatically concatenated.
+ if (match1(parser, PM_TOKEN_STRING_BEGIN)) {
+ return parse_strings(parser, node, false, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_CLASS_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *node = UP(pm_class_variable_read_node_create(parser, &parser->previous));
+
+ if (binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_CONSTANT: {
+ parser_lex(parser);
+ pm_token_t constant = parser->previous;
+
+ // If a constant is immediately followed by parentheses, then this is in
+ // fact a method call, not a constant read.
+ if (
+ match1(parser, PM_TOKEN_PARENTHESIS_LEFT) ||
+ ((flags & PM_PARSE_ACCEPTS_COMMAND_CALL) && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR))) ||
+ (pm_accepts_block_stack_p(parser) && match1(parser, PM_TOKEN_KEYWORD_DO)) ||
+ match1(parser, PM_TOKEN_BRACE_LEFT)
+ ) {
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+ return UP(pm_call_node_fcall_create(parser, &constant, &arguments));
+ }
+
+ pm_node_t *node = UP(pm_constant_read_node_create(parser, &parser->previous));
+
+ if ((binding_power == PM_BINDING_POWER_STATEMENT) && match1(parser, PM_TOKEN_COMMA)) {
+ // If we get here, then we have a comma immediately following a
+ // constant, so we're going to parse this as a multiple assignment.
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_UCOLON_COLON: {
+ parser_lex(parser);
+ pm_token_t delimiter = parser->previous;
+
+ expect1(parser, PM_TOKEN_CONSTANT, PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT);
+ pm_node_t *node = UP(pm_constant_path_node_create(parser, NULL, &delimiter, &parser->previous));
+
+ if ((binding_power == PM_BINDING_POWER_STATEMENT) && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_UDOT_DOT:
+ case PM_TOKEN_UDOT_DOT_DOT: {
+ pm_token_t operator = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *right = parse_expression(parser, pm_binding_powers[operator.type].left, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+
+ // Unary .. and ... are special because these are non-associative
+ // operators that can also be unary operators. In this case we need
+ // to explicitly reject code that has a .. or ... that follows this
+ // expression.
+ if (match2(parser, PM_TOKEN_DOT_DOT, PM_TOKEN_DOT_DOT_DOT)) {
+ pm_parser_err_current(parser, PM_ERR_UNEXPECTED_RANGE_OPERATOR);
+ }
+
+ return UP(pm_range_node_create(parser, NULL, &operator, right));
+ }
+ case PM_TOKEN_FLOAT:
+ parser_lex(parser);
+ return UP(pm_float_node_create(parser, &parser->previous));
+ case PM_TOKEN_FLOAT_IMAGINARY:
+ parser_lex(parser);
+ return UP(pm_float_node_imaginary_create(parser, &parser->previous));
+ case PM_TOKEN_FLOAT_RATIONAL:
+ parser_lex(parser);
+ return UP(pm_float_node_rational_create(parser, &parser->previous));
+ case PM_TOKEN_FLOAT_RATIONAL_IMAGINARY:
+ parser_lex(parser);
+ return UP(pm_float_node_rational_imaginary_create(parser, &parser->previous));
+ case PM_TOKEN_NUMBERED_REFERENCE: {
+ parser_lex(parser);
+ pm_node_t *node = UP(pm_numbered_reference_read_node_create(parser, &parser->previous));
+
+ if (binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_GLOBAL_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *node = UP(pm_global_variable_read_node_create(parser, &parser->previous));
+
+ if (binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_BACK_REFERENCE: {
+ parser_lex(parser);
+ pm_node_t *node = UP(pm_back_reference_read_node_create(parser, &parser->previous));
+
+ if (binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+ pm_token_t identifier = parser->previous;
+ pm_node_t *node = parse_variable_call(parser);
+
+ if (PM_NODE_TYPE_P(node, PM_CALL_NODE)) {
+ // If parse_variable_call returned with a call node, then we
+ // know the identifier is not in the local table. In that case
+ // we need to check if there are arguments following the
+ // identifier.
+ pm_call_node_t *call = (pm_call_node_t *) node;
+ pm_arguments_t arguments = { 0 };
+
+ if (parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1))) {
+ // Since we found arguments, we need to turn off the
+ // variable call bit in the flags.
+ pm_node_flag_unset(UP(call), PM_CALL_NODE_FLAGS_VARIABLE_CALL);
+
+ call->opening_loc = arguments.opening_loc;
+ call->arguments = arguments.arguments;
+ call->closing_loc = arguments.closing_loc;
+ call->block = arguments.block;
+
+ const pm_location_t *end = pm_arguments_end(&arguments);
+ if (end == NULL) {
+ PM_NODE_LENGTH_SET_LOCATION(call, &call->message_loc);
+ } else {
+ PM_NODE_LENGTH_SET_LOCATION(call, end);
+ }
+ }
+ } else {
+ // Otherwise, we know the identifier is in the local table. This
+ // can still be a method call if it is followed by arguments or
+ // a block, so we need to check for that here.
+ if (
+ ((flags & PM_PARSE_ACCEPTS_COMMAND_CALL) && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR))) ||
+ (pm_accepts_block_stack_p(parser) && match1(parser, PM_TOKEN_KEYWORD_DO)) ||
+ match1(parser, PM_TOKEN_BRACE_LEFT)
+ ) {
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+ pm_call_node_t *fcall = pm_call_node_fcall_create(parser, &identifier, &arguments);
+
+ if (PM_NODE_TYPE_P(node, PM_IT_LOCAL_VARIABLE_READ_NODE)) {
+ // If we're about to convert an 'it' implicit local
+ // variable read into a method call, we need to remove
+ // it from the list of implicit local variables.
+ pm_node_unreference(parser, node);
+ } else {
+ // Otherwise, we're about to convert a regular local
+ // variable read into a method call, in which case we
+ // need to indicate that this was not a read for the
+ // purposes of warnings.
+ assert(PM_NODE_TYPE_P(node, PM_LOCAL_VARIABLE_READ_NODE));
+
+ if (pm_token_is_numbered_parameter(parser, PM_TOKEN_START(parser, &identifier), PM_TOKEN_LENGTH(&identifier))) {
+ pm_node_unreference(parser, node);
+ } else {
+ pm_local_variable_read_node_t *cast = (pm_local_variable_read_node_t *) node;
+ pm_locals_unread(&pm_parser_scope_find(parser, cast->depth)->locals, cast->name);
+ }
+ }
+
+ return UP(fcall);
+ }
+ }
+
+ if ((binding_power == PM_BINDING_POWER_STATEMENT) && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_HEREDOC_START: {
+ // Here we have found a heredoc. We'll parse it and add it to the
+ // list of strings.
+ assert(parser->lex_modes.current->mode == PM_LEX_HEREDOC);
+ pm_heredoc_lex_mode_t lex_mode = parser->lex_modes.current->as.heredoc.base;
+
+ size_t common_whitespace = (size_t) -1;
+ parser->lex_modes.current->as.heredoc.common_whitespace = &common_whitespace;
+
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+
+ pm_node_t *node;
+ pm_node_t *part;
+
+ if (match2(parser, PM_TOKEN_HEREDOC_END, PM_TOKEN_EOF)) {
+ // If we get here, then we have an empty heredoc. We'll create
+ // an empty content token and return an empty string node.
+ expect1_heredoc_term(parser, lex_mode.ident_start, lex_mode.ident_length);
+ pm_token_t content = parse_strings_empty_content(parser->previous.start);
+
+ if (lex_mode.quote == PM_HEREDOC_QUOTE_BACKTICK) {
+ node = UP(pm_xstring_node_create_unescaped(parser, &opening, &content, &parser->previous, &PM_STRING_EMPTY));
+ } else {
+ node = UP(pm_string_node_create_unescaped(parser, &opening, &content, &parser->previous, &PM_STRING_EMPTY));
+ }
+
+ PM_NODE_LENGTH_SET_TOKEN(parser, node, &opening);
+ } else if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) == NULL) {
+ // If we get here, then we tried to find something in the
+ // heredoc but couldn't actually parse anything, so we'll just
+ // return a missing node.
+ //
+ // parse_string_part handles its own errors, so there is no need
+ // for us to add one here.
+ node = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous)));
+ } else if (PM_NODE_TYPE_P(part, PM_STRING_NODE) && match2(parser, PM_TOKEN_HEREDOC_END, PM_TOKEN_EOF)) {
+ // If we get here, then the part that we parsed was plain string
+ // content and we're at the end of the heredoc, so we can return
+ // just a string node with the heredoc opening and closing as
+ // its opening and closing.
+ pm_node_flag_set(part, parse_unescaped_encoding(parser));
+ pm_string_node_t *cast = (pm_string_node_t *) part;
+
+ cast->opening_loc = TOK2LOC(parser, &opening);
+ cast->closing_loc = TOK2LOC(parser, &parser->current);
+ cast->base.location = cast->opening_loc;
+
+ if (lex_mode.quote == PM_HEREDOC_QUOTE_BACKTICK) {
+ assert(sizeof(pm_string_node_t) == sizeof(pm_x_string_node_t));
+ cast->base.type = PM_X_STRING_NODE;
+ }
+
+ if (lex_mode.indent == PM_HEREDOC_INDENT_TILDE && (common_whitespace != (size_t) -1) && (common_whitespace != 0)) {
+ parse_heredoc_dedent_string(parser->arena, &cast->unescaped, common_whitespace);
+ }
+
+ node = UP(cast);
+ expect1_heredoc_term(parser, lex_mode.ident_start, lex_mode.ident_length);
+ } else {
+ // If we get here, then we have multiple parts in the heredoc,
+ // so we'll need to create an interpolated string node to hold
+ // them all.
+ pm_node_list_t parts = { 0 };
+ pm_node_list_append(parser->arena, &parts, part);
+
+ while (!match2(parser, PM_TOKEN_HEREDOC_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_node_list_append(parser->arena, &parts, part);
+ }
+ }
+
+ // Now that we have all of the parts, create the correct type of
+ // interpolated node.
+ if (lex_mode.quote == PM_HEREDOC_QUOTE_BACKTICK) {
+ pm_interpolated_x_string_node_t *cast = pm_interpolated_xstring_node_create(parser, &opening, &opening);
+ cast->parts = parts;
+
+ expect1_heredoc_term(parser, lex_mode.ident_start, lex_mode.ident_length);
+ pm_interpolated_xstring_node_closing_set(parser, cast, &parser->previous);
+
+ cast->base.location = cast->opening_loc;
+ node = UP(cast);
+ } else {
+ pm_interpolated_string_node_t *cast = pm_interpolated_string_node_create(parser, &opening, &parts, &opening);
+
+ expect1_heredoc_term(parser, lex_mode.ident_start, lex_mode.ident_length);
+ pm_interpolated_string_node_closing_set(parser, cast, &parser->previous);
+
+ cast->base.location = cast->opening_loc;
+ node = UP(cast);
+ }
+
+ // If this is a heredoc that is indented with a ~, then we need
+ // to dedent each line by the common leading whitespace.
+ if (lex_mode.indent == PM_HEREDOC_INDENT_TILDE && (common_whitespace != (size_t) -1) && (common_whitespace != 0)) {
+ pm_node_list_t *nodes;
+ if (lex_mode.quote == PM_HEREDOC_QUOTE_BACKTICK) {
+ nodes = &((pm_interpolated_x_string_node_t *) node)->parts;
+ } else {
+ nodes = &((pm_interpolated_string_node_t *) node)->parts;
+ }
+
+ parse_heredoc_dedent(parser, nodes, common_whitespace);
+ }
+ }
+
+ if (match1(parser, PM_TOKEN_STRING_BEGIN)) {
+ return parse_strings(parser, node, false, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_INSTANCE_VARIABLE: {
+ parser_lex(parser);
+ pm_node_t *node = UP(pm_instance_variable_read_node_create(parser, &parser->previous));
+
+ if (binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ node = parse_targets_validate(parser, node, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return node;
+ }
+ case PM_TOKEN_INTEGER: {
+ pm_node_flags_t base = parser->integer.base;
+ parser_lex(parser);
+ return UP(pm_integer_node_create(parser, base, &parser->previous));
+ }
+ case PM_TOKEN_INTEGER_IMAGINARY: {
+ pm_node_flags_t base = parser->integer.base;
+ parser_lex(parser);
+ return UP(pm_integer_node_imaginary_create(parser, base, &parser->previous));
+ }
+ case PM_TOKEN_INTEGER_RATIONAL: {
+ pm_node_flags_t base = parser->integer.base;
+ parser_lex(parser);
+ return UP(pm_integer_node_rational_create(parser, base, &parser->previous));
+ }
+ case PM_TOKEN_INTEGER_RATIONAL_IMAGINARY: {
+ pm_node_flags_t base = parser->integer.base;
+ parser_lex(parser);
+ return UP(pm_integer_node_rational_imaginary_create(parser, base, &parser->previous));
+ }
+ case PM_TOKEN_KEYWORD___ENCODING__:
+ parser_lex(parser);
+ return UP(pm_source_encoding_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD___FILE__:
+ parser_lex(parser);
+ return UP(pm_source_file_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD___LINE__:
+ parser_lex(parser);
+ return UP(pm_source_line_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD_ALIAS: {
+ if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_current(parser, PM_ERR_STATEMENT_ALIAS);
+ }
+
+ parser_lex(parser);
+ pm_token_t keyword = parser->previous;
+
+ pm_node_t *new_name = parse_alias_argument(parser, true, (uint16_t) (depth + 1));
+ pm_node_t *old_name = parse_alias_argument(parser, false, (uint16_t) (depth + 1));
+
+ switch (PM_NODE_TYPE(new_name)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ if (PM_NODE_TYPE_P(old_name, PM_BACK_REFERENCE_READ_NODE) || PM_NODE_TYPE_P(old_name, PM_NUMBERED_REFERENCE_READ_NODE) || PM_NODE_TYPE_P(old_name, PM_GLOBAL_VARIABLE_READ_NODE)) {
+ if (PM_NODE_TYPE_P(old_name, PM_NUMBERED_REFERENCE_READ_NODE)) {
+ pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE);
+ }
+ } else if (!PM_NODE_TYPE_P(old_name, PM_ERROR_RECOVERY_NODE)) {
+ pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT);
+ old_name = UP(pm_error_recovery_node_create_unexpected(parser, old_name));
+ }
+
+ return UP(pm_alias_global_variable_node_create(parser, &keyword, new_name, old_name));
+ }
+ case PM_SYMBOL_NODE:
+ case PM_INTERPOLATED_SYMBOL_NODE: {
+ if (!PM_NODE_TYPE_P(old_name, PM_SYMBOL_NODE) && !PM_NODE_TYPE_P(old_name, PM_INTERPOLATED_SYMBOL_NODE) && !PM_NODE_TYPE_P(old_name, PM_ERROR_RECOVERY_NODE)) {
+ pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT);
+ old_name = UP(pm_error_recovery_node_create_unexpected(parser, old_name));
+ }
+ }
+ PRISM_FALLTHROUGH
+ default:
+ return UP(pm_alias_method_node_create(parser, &keyword, new_name, old_name));
+ }
+ }
+ case PM_TOKEN_KEYWORD_CASE:
+ return parse_case(parser, flags, depth);
+ case PM_TOKEN_KEYWORD_BEGIN: {
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+
+ pm_token_t begin_keyword = parser->previous;
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+ pm_statements_node_t *begin_statements = NULL;
+
+ if (!match4(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ begin_statements = parse_statements(parser, PM_CONTEXT_BEGIN, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ pm_begin_node_t *begin_node = pm_begin_node_create(parser, &begin_keyword, begin_statements);
+ parse_rescues(parser, opening_newline_index, &begin_keyword, begin_node, PM_RESCUES_BEGIN, (uint16_t) (depth + 1));
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_BEGIN_TERM, &begin_keyword);
+
+ PM_NODE_LENGTH_SET_TOKEN(parser, begin_node, &parser->previous);
+ pm_begin_node_end_keyword_set(parser, begin_node, &parser->previous);
+ pop_block_exits(parser, previous_block_exits);
+ return UP(begin_node);
+ }
+ case PM_TOKEN_KEYWORD_BEGIN_UPCASE: {
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_current(parser, PM_ERR_STATEMENT_PREEXE_BEGIN);
+ }
+
+ parser_lex(parser);
+ pm_token_t keyword = parser->previous;
+
+ expect1(parser, PM_TOKEN_BRACE_LEFT, PM_ERR_BEGIN_UPCASE_BRACE);
+ pm_token_t opening = parser->previous;
+ pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_PREEXE, (uint16_t) (depth + 1));
+
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_BEGIN_UPCASE_TERM, &opening);
+ pm_context_t context = parser->current_context->context;
+ if ((context != PM_CONTEXT_MAIN) && (context != PM_CONTEXT_PREEXE)) {
+ pm_parser_err_token(parser, &keyword, PM_ERR_BEGIN_UPCASE_TOPLEVEL);
+ }
+
+ flush_block_exits(parser, previous_block_exits);
+ return UP(pm_pre_execution_node_create(parser, &keyword, &opening, statements, &parser->previous));
+ }
+ case PM_TOKEN_KEYWORD_BREAK:
+ case PM_TOKEN_KEYWORD_NEXT:
+ case PM_TOKEN_KEYWORD_RETURN: {
+ parser_lex(parser);
+
+ pm_token_t keyword = parser->previous;
+ pm_arguments_t arguments = { 0 };
+
+ if (
+ token_begins_expression_p(parser->current.type) ||
+ match2(parser, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR)
+ ) {
+ pm_binding_power_t binding_power = pm_binding_powers[parser->current.type].left;
+
+ if (binding_power == PM_BINDING_POWER_UNSET || binding_power >= PM_BINDING_POWER_RANGE) {
+ pm_token_t next = parser->current;
+ parse_arguments(parser, &arguments, false, PM_TOKEN_EOF, flags, (uint16_t) (depth + 1));
+
+ // Reject `foo && return bar`.
+ if (!(flags & PM_PARSE_ACCEPTS_COMMAND_CALL) && arguments.arguments != NULL) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &next, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(next.type));
+ }
+ }
+
+ // It's possible that we've parsed a block argument through our
+ // call to parse_arguments. If we found one, we should mark it
+ // as invalid and destroy it, as we don't have a place for it.
+ if (arguments.block != NULL) {
+ pm_parser_err_node(parser, arguments.block, PM_ERR_UNEXPECTED_BLOCK_ARGUMENT);
+ pm_node_unreference(parser, arguments.block);
+ arguments.block = NULL;
+ }
+ }
+
+ switch (keyword.type) {
+ case PM_TOKEN_KEYWORD_BREAK: {
+ pm_node_t *node = UP(pm_break_node_create(parser, &keyword, arguments.arguments));
+ if (!parser->partial_script) parse_block_exit(parser, node);
+ return node;
+ }
+ case PM_TOKEN_KEYWORD_NEXT: {
+ pm_node_t *node = UP(pm_next_node_create(parser, &keyword, arguments.arguments));
+ if (!parser->partial_script) parse_block_exit(parser, node);
+ return node;
+ }
+ case PM_TOKEN_KEYWORD_RETURN: {
+ pm_node_t *node = UP(pm_return_node_create(parser, &keyword, arguments.arguments));
+ parse_return(parser, node);
+ return node;
+ }
+ default:
+ assert(false && "unreachable");
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous)));
+ }
+ }
+ case PM_TOKEN_KEYWORD_SUPER: {
+ parser_lex(parser);
+
+ pm_token_t keyword = parser->previous;
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+
+ if (
+ arguments.opening_loc.length == 0 &&
+ arguments.arguments == NULL &&
+ ((arguments.block == NULL) || PM_NODE_TYPE_P(arguments.block, PM_BLOCK_NODE))
+ ) {
+ return UP(pm_forwarding_super_node_create(parser, &keyword, &arguments));
+ }
+
+ return UP(pm_super_node_create(parser, &keyword, &arguments));
+ }
+ case PM_TOKEN_KEYWORD_YIELD: {
+ parser_lex(parser);
+
+ pm_token_t keyword = parser->previous;
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, false, flags, (uint16_t) (depth + 1));
+
+ // It's possible that we've parsed a block argument through our
+ // call to parse_arguments_list. If we found one, we should mark it
+ // as invalid and destroy it, as we don't have a place for it on the
+ // yield node.
+ if (arguments.block != NULL) {
+ pm_parser_err_node(parser, arguments.block, PM_ERR_UNEXPECTED_BLOCK_ARGUMENT);
+ pm_node_unreference(parser, arguments.block);
+ arguments.block = NULL;
+ }
+
+ pm_node_t *node = UP(pm_yield_node_create(parser, &keyword, &arguments.opening_loc, arguments.arguments, &arguments.closing_loc));
+ if (!parser->parsing_eval && !parser->partial_script) parse_yield(parser, node);
+
+ return node;
+ }
+ case PM_TOKEN_KEYWORD_CLASS:
+ return parse_class(parser, flags, depth);
+ case PM_TOKEN_KEYWORD_DEF:
+ return parse_def(parser, binding_power, flags, depth);
+ case PM_TOKEN_KEYWORD_DEFINED: {
+ parser_lex(parser);
+
+ pm_token_t keyword = parser->previous;
+ pm_token_t lparen = { 0 };
+ pm_token_t rparen = { 0 };
+ pm_node_t *expression;
+
+ context_push(parser, PM_CONTEXT_DEFINED);
+ bool newline = accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (accept1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ lparen = parser->previous;
+
+ if (newline && accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ expression = UP(pm_parentheses_node_create(parser, &lparen, NULL, &parser->previous, 0));
+ lparen = (pm_token_t) { 0 };
+ } else {
+ expression = parse_expression(parser, PM_BINDING_POWER_COMPOSITION, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_DEFINED_EXPRESSION, (uint16_t) (depth + 1));
+
+ if (!parser->recovering) {
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+ rparen = parser->previous;
+ }
+ }
+ } else {
+ expression = parse_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_DEFINED_EXPRESSION, (uint16_t) (depth + 1));
+ }
+
+ context_pop(parser);
+ return UP(pm_defined_node_create(
+ parser,
+ NTOK2PTR(lparen),
+ expression,
+ NTOK2PTR(rparen),
+ &keyword
+ ));
+ }
+ case PM_TOKEN_KEYWORD_END_UPCASE: {
+ if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_current(parser, PM_ERR_STATEMENT_POSTEXE_END);
+ }
+
+ parser_lex(parser);
+ pm_token_t keyword = parser->previous;
+
+ if (context_def_p(parser)) {
+ pm_parser_warn_token(parser, &keyword, PM_WARN_END_IN_METHOD);
+ }
+
+ expect1(parser, PM_TOKEN_BRACE_LEFT, PM_ERR_END_UPCASE_BRACE);
+ pm_token_t opening = parser->previous;
+ pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_POSTEXE, (uint16_t) (depth + 1));
+
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_END_UPCASE_TERM, &opening);
+ return UP(pm_post_execution_node_create(parser, &keyword, &opening, statements, &parser->previous));
+ }
+ case PM_TOKEN_KEYWORD_FALSE:
+ parser_lex(parser);
+ return UP(pm_false_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD_FOR: {
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+
+ pm_token_t for_keyword = parser->previous;
+ pm_node_t *index;
+
+ context_push(parser, PM_CONTEXT_FOR_INDEX);
+
+ // First, parse out the first index expression.
+ if (accept1(parser, PM_TOKEN_USTAR)) {
+ pm_token_t star_operator = parser->previous;
+ pm_node_t *name = NULL;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ name = parse_expression(parser, PM_BINDING_POWER_INDEX, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+ }
+
+ index = UP(pm_splat_node_create(parser, &star_operator, name));
+ } else if (token_begins_expression_p(parser->current.type)) {
+ index = parse_expression(parser, PM_BINDING_POWER_INDEX, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA, (uint16_t) (depth + 1));
+ } else {
+ pm_parser_err_token(parser, &for_keyword, PM_ERR_FOR_INDEX);
+ index = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &for_keyword), PM_TOKEN_LENGTH(&for_keyword)));
+ }
+
+ // Now, if there are multiple index expressions, parse them out.
+ if (match1(parser, PM_TOKEN_COMMA)) {
+ index = parse_targets(parser, index, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ } else {
+ index = parse_target(parser, index, false, false);
+ }
+
+ context_pop(parser);
+ pm_do_loop_stack_push(parser, true);
+
+ expect1(parser, PM_TOKEN_KEYWORD_IN, PM_ERR_FOR_IN);
+ pm_token_t in_keyword = parser->previous;
+
+ pm_node_t *collection = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_FOR_COLLECTION, (uint16_t) (depth + 1));
+ pm_do_loop_stack_pop(parser);
+
+ pm_token_t do_keyword = { 0 };
+ if (accept1(parser, PM_TOKEN_KEYWORD_DO_LOOP)) {
+ do_keyword = parser->previous;
+ } else {
+ if (!match2(parser, PM_TOKEN_SEMICOLON, PM_TOKEN_NEWLINE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_FOR_DELIMITER, pm_token_str(parser->current.type));
+ }
+ }
+
+ pm_statements_node_t *statements = NULL;
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ statements = parse_statements(parser, PM_CONTEXT_FOR, (uint16_t) (depth + 1));
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &for_keyword, false, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_FOR_TERM, &for_keyword);
+
+ return UP(pm_for_node_create(parser, index, collection, statements, &for_keyword, &in_keyword, NTOK2PTR(do_keyword), &parser->previous));
+ }
+ case PM_TOKEN_KEYWORD_IF:
+ if (parser_end_of_line_p(parser)) {
+ PM_PARSER_WARN_TOKEN_FORMAT_CONTENT(parser, &parser->current, PM_WARN_KEYWORD_EOL);
+ }
+
+ size_t opening_newline_index = token_newline_index(parser);
+ bool if_after_else = parser->previous.type == PM_TOKEN_KEYWORD_ELSE;
+ parser_lex(parser);
+
+ return parse_conditional(parser, PM_CONTEXT_IF, opening_newline_index, if_after_else, (uint16_t) (depth + 1));
+ case PM_TOKEN_KEYWORD_UNDEF: {
+ if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_current(parser, PM_ERR_STATEMENT_UNDEF);
+ }
+
+ parser_lex(parser);
+ pm_undef_node_t *undef = pm_undef_node_create(parser, &parser->previous);
+ pm_node_t *name = parse_undef_argument(parser, (uint16_t) (depth + 1));
+
+ if (PM_NODE_TYPE_P(name, PM_ERROR_RECOVERY_NODE)) {
+ } else {
+ pm_undef_node_append(parser->arena, undef, name);
+
+ while (match1(parser, PM_TOKEN_COMMA)) {
+ lex_state_set(parser, PM_LEX_STATE_FNAME | PM_LEX_STATE_FITEM);
+ parser_lex(parser);
+ name = parse_undef_argument(parser, (uint16_t) (depth + 1));
+
+ if (PM_NODE_TYPE_P(name, PM_ERROR_RECOVERY_NODE)) {
+ break;
+ }
+
+ pm_undef_node_append(parser->arena, undef, name);
+ }
+ }
+
+ return UP(undef);
+ }
+ case PM_TOKEN_KEYWORD_NOT: {
+ parser_lex(parser);
+
+ pm_token_t message = parser->previous;
+ pm_arguments_t arguments = { 0 };
+ pm_node_t *receiver = NULL;
+
+ // The `not` keyword without parentheses is only valid in contexts
+ // where it would be parsed as an expression (i.e., at or below
+ // the `not` binding power level). In other contexts (e.g., method
+ // arguments, array elements, assignment right-hand sides),
+ // parentheses are required: `not(x)`. An exception is made for
+ // endless def bodies, where `not` is valid as both `arg` and
+ // `command` (e.g., `def f = not 1`, `def f = not foo bar`).
+ if (binding_power > PM_BINDING_POWER_NOT && !(flags & PM_PARSE_IN_ENDLESS_DEF) && !match1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ if (match1(parser, PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES)) {
+ pm_parser_err(parser, PM_TOKEN_END(parser, &parser->previous), 1, PM_ERR_EXPECT_LPAREN_AFTER_NOT_LPAREN);
+ } else {
+ accept1(parser, PM_TOKEN_NEWLINE);
+ pm_parser_err_current(parser, PM_ERR_EXPECT_LPAREN_AFTER_NOT_OTHER);
+ }
+
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ if (accept1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ pm_token_t lparen = parser->previous;
+
+ if (accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ receiver = UP(pm_parentheses_node_create(parser, &lparen, NULL, &parser->previous, 0));
+ } else {
+ arguments.opening_loc = TOK2LOC(parser, &lparen);
+ receiver = parse_expression(parser, PM_BINDING_POWER_COMPOSITION, PM_PARSE_ACCEPTS_COMMAND_CALL | PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_NOT_EXPRESSION, (uint16_t) (depth + 1));
+
+ if (!parser->recovering) {
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+ arguments.closing_loc = TOK2LOC(parser, &parser->previous);
+ }
+ }
+ } else {
+ receiver = parse_expression(parser, PM_BINDING_POWER_NOT, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_NOT_EXPRESSION, (uint16_t) (depth + 1));
+ }
+
+ return UP(pm_call_node_not_create(parser, receiver, &message, &arguments));
+ }
+ case PM_TOKEN_KEYWORD_UNLESS: {
+ size_t opening_newline_index = token_newline_index(parser);
+ parser_lex(parser);
+
+ return parse_conditional(parser, PM_CONTEXT_UNLESS, opening_newline_index, false, (uint16_t) (depth + 1));
+ }
+ case PM_TOKEN_KEYWORD_MODULE:
+ return parse_module(parser, flags, depth);
+ case PM_TOKEN_KEYWORD_NIL:
+ parser_lex(parser);
+ return UP(pm_nil_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD_REDO: {
+ parser_lex(parser);
+
+ pm_node_t *node = UP(pm_redo_node_create(parser, &parser->previous));
+ if (!parser->partial_script) parse_block_exit(parser, node);
+
+ return node;
+ }
+ case PM_TOKEN_KEYWORD_RETRY: {
+ parser_lex(parser);
+
+ pm_node_t *node = UP(pm_retry_node_create(parser, &parser->previous));
+ parse_retry(parser, node);
+
+ return node;
+ }
+ case PM_TOKEN_KEYWORD_SELF:
+ parser_lex(parser);
+ return UP(pm_self_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD_TRUE:
+ parser_lex(parser);
+ return UP(pm_true_node_create(parser, &parser->previous));
+ case PM_TOKEN_KEYWORD_UNTIL: {
+ size_t opening_newline_index = token_newline_index(parser);
+
+ context_push(parser, PM_CONTEXT_LOOP_PREDICATE);
+ pm_do_loop_stack_push(parser, true);
+
+ parser_lex(parser);
+ pm_token_t keyword = parser->previous;
+ pm_node_t *predicate = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_UNTIL_PREDICATE, (uint16_t) (depth + 1));
+
+ pm_do_loop_stack_pop(parser);
+ context_pop(parser);
+
+ pm_token_t do_keyword = { 0 };
+ if (accept1(parser, PM_TOKEN_KEYWORD_DO_LOOP)) {
+ do_keyword = parser->previous;
+ } else {
+ expect2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_ERR_CONDITIONAL_UNTIL_PREDICATE);
+ }
+
+ pm_statements_node_t *statements = NULL;
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = parse_statements(parser, PM_CONTEXT_UNTIL, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &keyword, false, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_UNTIL_TERM, &keyword);
+
+ return UP(pm_until_node_create(parser, &keyword, NTOK2PTR(do_keyword), &parser->previous, predicate, statements, 0));
+ }
+ case PM_TOKEN_KEYWORD_WHILE: {
+ size_t opening_newline_index = token_newline_index(parser);
+
+ context_push(parser, PM_CONTEXT_LOOP_PREDICATE);
+ pm_do_loop_stack_push(parser, true);
+
+ parser_lex(parser);
+ pm_token_t keyword = parser->previous;
+ pm_node_t *predicate = parse_value_expression(parser, PM_BINDING_POWER_COMPOSITION, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_WHILE_PREDICATE, (uint16_t) (depth + 1));
+
+ pm_do_loop_stack_pop(parser);
+ context_pop(parser);
+
+ pm_token_t do_keyword = { 0 };
+ if (accept1(parser, PM_TOKEN_KEYWORD_DO_LOOP)) {
+ do_keyword = parser->previous;
+ } else {
+ expect2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_ERR_CONDITIONAL_WHILE_PREDICATE);
+ }
+
+ pm_statements_node_t *statements = NULL;
+ if (!match1(parser, PM_TOKEN_KEYWORD_END)) {
+ pm_accepts_block_stack_push(parser, true);
+ statements = parse_statements(parser, PM_CONTEXT_WHILE, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &keyword, false, false);
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_WHILE_TERM, &keyword);
+
+ return UP(pm_while_node_create(parser, &keyword, NTOK2PTR(do_keyword), &parser->previous, predicate, statements, 0));
+ }
+ case PM_TOKEN_PERCENT_LOWER_I: {
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+ pm_array_node_t *array = pm_array_node_create(parser, &opening);
+ pm_node_t *current = NULL;
+
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ accept1(parser, PM_TOKEN_WORDS_SEP);
+ if (match1(parser, PM_TOKEN_STRING_END)) break;
+
+ // Interpolation is not possible but nested heredocs can still lead to
+ // consecutive (disjoint) string tokens when the final newline is escaped.
+ while (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ // Record the string node, moving to interpolation if needed.
+ if (current == NULL) {
+ current = UP(pm_symbol_node_create_current_string(parser, NULL, &parser->current, NULL));
+ parser_lex(parser);
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_SYMBOL_NODE)) {
+ pm_node_t *string = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+ parser_lex(parser);
+ pm_interpolated_symbol_node_append(parser->arena, (pm_interpolated_symbol_node_t *) current, string);
+ } else if (PM_NODE_TYPE_P(current, PM_SYMBOL_NODE)) {
+ pm_symbol_node_t *cast = (pm_symbol_node_t *) current;
+ pm_token_t content = { .type = PM_TOKEN_STRING_CONTENT, .start = parser->start + cast->value_loc.start, .end = parser->start + cast->value_loc.start + cast->value_loc.length };
+ pm_node_t *first_string = UP(pm_string_node_create_unescaped(parser, NULL, &content, NULL, &cast->unescaped));
+ pm_node_t *second_string = UP(pm_string_node_create_current_string(parser, NULL, &parser->previous, NULL));
+ parser_lex(parser);
+
+ pm_interpolated_symbol_node_t *interpolated = pm_interpolated_symbol_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, first_string);
+ pm_interpolated_symbol_node_append(parser->arena, interpolated, second_string);
+
+ // current is arena-allocated so no explicit free is needed.
+ current = UP(interpolated);
+ } else {
+ assert(false && "unreachable");
+ }
+ }
+
+ if (current) {
+ pm_array_node_elements_append(parser->arena, array, current);
+ current = NULL;
+ } else {
+ expect1(parser, PM_TOKEN_STRING_CONTENT, PM_ERR_LIST_I_LOWER_ELEMENT);
+ }
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_LIST_I_LOWER_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_LIST_I_LOWER_TERM);
+ }
+ pm_array_node_close_set(parser, array, &closing);
+
+ return UP(array);
+ }
+ case PM_TOKEN_PERCENT_UPPER_I:
+ return parse_symbol_array(parser, depth);
+ case PM_TOKEN_PERCENT_LOWER_W: {
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+ pm_array_node_t *array = pm_array_node_create(parser, &opening);
+ pm_node_t *current = NULL;
+
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ accept1(parser, PM_TOKEN_WORDS_SEP);
+ if (match1(parser, PM_TOKEN_STRING_END)) break;
+
+ // Interpolation is not possible but nested heredocs can still lead to
+ // consecutive (disjoint) string tokens when the final newline is escaped.
+ while (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ pm_node_t *string = UP(pm_string_node_create_current_string(parser, NULL, &parser->current, NULL));
+
+ // Record the string node, moving to interpolation if needed.
+ if (current == NULL) {
+ current = string;
+ } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) {
+ pm_interpolated_string_node_append(parser, (pm_interpolated_string_node_t *) current, string);
+ } else if (PM_NODE_TYPE_P(current, PM_STRING_NODE)) {
+ pm_interpolated_string_node_t *interpolated = pm_interpolated_string_node_create(parser, NULL, NULL, NULL);
+ pm_interpolated_string_node_append(parser, interpolated, current);
+ pm_interpolated_string_node_append(parser, interpolated, string);
+ current = UP(interpolated);
+ } else {
+ assert(false && "unreachable");
+ }
+ parser_lex(parser);
+ }
+
+ if (current) {
+ pm_array_node_elements_append(parser->arena, array, current);
+ current = NULL;
+ } else {
+ expect1(parser, PM_TOKEN_STRING_CONTENT, PM_ERR_LIST_W_LOWER_ELEMENT);
+ }
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_LIST_W_LOWER_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_LIST_W_LOWER_TERM);
+ }
+
+ pm_array_node_close_set(parser, array, &closing);
+ return UP(array);
+ }
+ case PM_TOKEN_PERCENT_UPPER_W:
+ return parse_string_array(parser, depth);
+ case PM_TOKEN_REGEXP_BEGIN: {
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ if (match1(parser, PM_TOKEN_REGEXP_END)) {
+ // If we get here, then we have an end immediately after a start. In
+ // that case we'll create an empty content token and return an
+ // uninterpolated regular expression.
+ pm_token_t content = (pm_token_t) {
+ .type = PM_TOKEN_STRING_CONTENT,
+ .start = parser->previous.end,
+ .end = parser->previous.end
+ };
+
+ parser_lex(parser);
+
+ pm_regular_expression_node_t *node = pm_regular_expression_node_create(parser, &opening, &content, &parser->previous);
+ pm_node_flag_set(UP(node), pm_regexp_parse(parser, node, NULL, NULL));
+ return UP(node);
+ }
+
+ pm_interpolated_regular_expression_node_t *interpolated;
+
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ // In this case we've hit string content so we know the regular
+ // expression at least has something in it. We'll need to check if the
+ // following token is the end (in which case we can return a plain
+ // regular expression) or if it's not then it has interpolation.
+ pm_string_t unescaped = parser->current_string;
+ pm_token_t content = parser->current;
+ parser_lex(parser);
+
+ // If we hit an end, then we can create a regular expression
+ // node without interpolation, which can be represented more
+ // succinctly and more easily compiled.
+ if (accept1(parser, PM_TOKEN_REGEXP_END)) {
+ pm_regular_expression_node_t *node = (pm_regular_expression_node_t *) pm_regular_expression_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped);
+
+ // If we're not immediately followed by a =~, then we
+ // parse and validate now. If it is followed by a =~,
+ // then it will get parsed in the =~ handler where
+ // named captures can also be extracted.
+ if (!match1(parser, PM_TOKEN_EQUAL_TILDE)) {
+ pm_node_flag_set(UP(node), pm_regexp_parse(parser, node, NULL, NULL));
+ }
+
+ return UP(node);
+ }
+
+ // If we get here, then we have interpolation so we'll need to create
+ // a regular expression node with interpolation.
+ interpolated = pm_interpolated_regular_expression_node_create(parser, &opening);
+
+ pm_node_t *part = UP(pm_string_node_create_unescaped(parser, NULL, &parser->previous, NULL, &unescaped));
+ if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY) {
+ // This is extremely strange, but the first string part of a
+ // regular expression will always be tagged as binary if we
+ // are in a US-ASCII file, no matter its contents.
+ pm_node_flag_set(part, PM_STRING_FLAGS_FORCED_BINARY_ENCODING);
+ }
+
+ pm_interpolated_regular_expression_node_append(parser->arena, interpolated, part);
+ } else {
+ // If the first part of the body of the regular expression is not a
+ // string content, then we have interpolation and we need to create an
+ // interpolated regular expression node.
+ interpolated = pm_interpolated_regular_expression_node_create(parser, &opening);
+ }
+
+ // Now that we're here and we have interpolation, we'll parse all of the
+ // parts into the list.
+ pm_node_t *part;
+ while (!match2(parser, PM_TOKEN_REGEXP_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_interpolated_regular_expression_node_append(parser->arena, interpolated, part);
+ }
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_REGEXP_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_REGEXP_END, PM_ERR_REGEXP_TERM);
+ }
+
+ pm_interpolated_regular_expression_node_closing_set(parser, interpolated, &closing);
+ return UP(interpolated);
+ }
+ case PM_TOKEN_BACKTICK:
+ case PM_TOKEN_PERCENT_LOWER_X: {
+ parser_lex(parser);
+ pm_token_t opening = parser->previous;
+
+ // When we get here, we don't know if this string is going to have
+ // interpolation or not, even though it is allowed. Still, we want to be
+ // able to return a string node without interpolation if we can since
+ // it'll be faster.
+ if (match1(parser, PM_TOKEN_STRING_END)) {
+ // If we get here, then we have an end immediately after a start. In
+ // that case we'll create an empty content token and return an
+ // uninterpolated string.
+ pm_token_t content = (pm_token_t) {
+ .type = PM_TOKEN_STRING_CONTENT,
+ .start = parser->previous.end,
+ .end = parser->previous.end
+ };
+
+ parser_lex(parser);
+ return UP(pm_xstring_node_create(parser, &opening, &content, &parser->previous));
+ }
+
+ pm_interpolated_x_string_node_t *node;
+
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ // In this case we've hit string content so we know the string
+ // at least has something in it. We'll need to check if the
+ // following token is the end (in which case we can return a
+ // plain string) or if it's not then it has interpolation.
+ pm_string_t unescaped = parser->current_string;
+ pm_token_t content = parser->current;
+ parser_lex(parser);
+
+ if (match1(parser, PM_TOKEN_STRING_END)) {
+ pm_node_t *node = UP(pm_xstring_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped));
+ pm_node_flag_set(node, parse_unescaped_encoding(parser));
+ parser_lex(parser);
+ return node;
+ }
+
+ // If we get here, then we have interpolation so we'll need to
+ // create a string node with interpolation.
+ node = pm_interpolated_xstring_node_create(parser, &opening, &opening);
+
+ pm_node_t *part = UP(pm_string_node_create_unescaped(parser, NULL, &parser->previous, NULL, &unescaped));
+ pm_node_flag_set(part, parse_unescaped_encoding(parser));
+
+ pm_interpolated_xstring_node_append(parser->arena, node, part);
+ } else {
+ // If the first part of the body of the string is not a string
+ // content, then we have interpolation and we need to create an
+ // interpolated string node.
+ node = pm_interpolated_xstring_node_create(parser, &opening, &opening);
+ }
+
+ pm_node_t *part;
+ while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
+ if ((part = parse_string_part(parser, (uint16_t) (depth + 1))) != NULL) {
+ pm_interpolated_xstring_node_append(parser->arena, node, part);
+ }
+ }
+
+ pm_token_t closing = parser->current;
+ if (match1(parser, PM_TOKEN_EOF)) {
+ pm_parser_err_token(parser, &opening, PM_ERR_XSTRING_TERM);
+ closing = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ } else {
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_XSTRING_TERM);
+ }
+ pm_interpolated_xstring_node_closing_set(parser, node, &closing);
+
+ return UP(node);
+ }
+ case PM_TOKEN_USTAR: {
+ parser_lex(parser);
+
+ // * operators at the beginning of expressions are only valid in the
+ // context of a multiple assignment. We enforce that here. We'll
+ // still lex past it though and create a missing node place.
+ if (binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_prefix(parser, diag_id);
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous)));
+ }
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *name = NULL;
+
+ if (token_begins_expression_p(parser->current.type)) {
+ name = parse_expression(parser, PM_BINDING_POWER_INDEX, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_STAR, (uint16_t) (depth + 1));
+ }
+
+ pm_node_t *splat = UP(pm_splat_node_create(parser, &operator, name));
+
+ if (match1(parser, PM_TOKEN_COMMA)) {
+ return parse_targets_validate(parser, splat, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ } else {
+ return parse_target_validate(parser, splat, true);
+ }
+ }
+ case PM_TOKEN_BANG: {
+ if (binding_power > PM_BINDING_POWER_UNARY) {
+ pm_parser_err_prefix(parser, PM_ERR_UNARY_DISALLOWED);
+ }
+
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *receiver = parse_expression(parser, pm_binding_powers[parser->previous.type].right, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (binding_power < PM_BINDING_POWER_MATCH ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0)), PM_ERR_UNARY_RECEIVER, (uint16_t) (depth + 1));
+ pm_call_node_t *node = pm_call_node_unary_create(parser, &operator, receiver, "!");
+
+ pm_conditional_predicate(parser, receiver, PM_CONDITIONAL_PREDICATE_TYPE_NOT);
+ return UP(node);
+ }
+ case PM_TOKEN_TILDE: {
+ if (binding_power > PM_BINDING_POWER_UNARY) {
+ pm_parser_err_prefix(parser, PM_ERR_UNARY_DISALLOWED);
+ }
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *receiver = parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_UNARY_RECEIVER, (uint16_t) (depth + 1));
+ pm_call_node_t *node = pm_call_node_unary_create(parser, &operator, receiver, "~");
+
+ return UP(node);
+ }
+ case PM_TOKEN_UMINUS: {
+ if (binding_power > PM_BINDING_POWER_UNARY) {
+ pm_parser_err_prefix(parser, PM_ERR_UNARY_DISALLOWED);
+ }
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *receiver = parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_UNARY_RECEIVER, (uint16_t) (depth + 1));
+ pm_call_node_t *node = pm_call_node_unary_create(parser, &operator, receiver, "-@");
+
+ return UP(node);
+ }
+ case PM_TOKEN_UMINUS_NUM: {
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *node = parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_UNARY_RECEIVER, (uint16_t) (depth + 1));
+
+ if (accept1(parser, PM_TOKEN_STAR_STAR)) {
+ pm_token_t exponent_operator = parser->previous;
+ pm_node_t *exponent = parse_expression(parser, pm_binding_powers[exponent_operator.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_ARGUMENT, (uint16_t) (depth + 1));
+ node = UP(pm_call_node_binary_create(parser, node, &exponent_operator, exponent, 0));
+ node = UP(pm_call_node_unary_create(parser, &operator, node, "-@"));
+ } else {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_INTEGER_NODE:
+ case PM_FLOAT_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_IMAGINARY_NODE:
+ parse_negative_numeric(node);
+ break;
+ default:
+ node = UP(pm_call_node_unary_create(parser, &operator, node, "-@"));
+ break;
+ }
+ }
+
+ return node;
+ }
+ case PM_TOKEN_MINUS_GREATER: {
+ int previous_lambda_enclosure_nesting = parser->lambda_enclosure_nesting;
+ parser->lambda_enclosure_nesting = parser->enclosure_nesting;
+
+ size_t opening_newline_index = token_newline_index(parser);
+ pm_accepts_block_stack_push(parser, true);
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_parser_scope_push(parser, false);
+
+ pm_block_parameters_node_t *block_parameters;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ pm_token_t opening = parser->current;
+ parser_lex(parser);
+
+ if (match1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
+ block_parameters = pm_block_parameters_node_create(parser, NULL, &opening);
+ } else {
+ block_parameters = parse_block_parameters(parser, false, &opening, true, true, (uint16_t) (depth + 1));
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_ERR_EXPECT_RPAREN);
+
+ pm_block_parameters_node_closing_set(parser, block_parameters, &parser->previous);
+ break;
+ }
+ case PM_CASE_PARAMETER: {
+ pm_accepts_block_stack_push(parser, false);
+ block_parameters = parse_block_parameters(parser, false, NULL, true, false, (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ break;
+ }
+ default: {
+ block_parameters = NULL;
+ break;
+ }
+ }
+
+ pm_token_t opening;
+ pm_node_t *body = NULL;
+ parser->lambda_enclosure_nesting = previous_lambda_enclosure_nesting;
+
+ if (accept1(parser, PM_TOKEN_LAMBDA_BEGIN)) {
+ opening = parser->previous;
+
+ if (!match1(parser, PM_TOKEN_BRACE_RIGHT)) {
+ body = UP(parse_statements(parser, PM_CONTEXT_LAMBDA_BRACES, (uint16_t) (depth + 1)));
+ }
+
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &operator, false, false);
+ expect1_opening(parser, PM_TOKEN_BRACE_RIGHT, PM_ERR_LAMBDA_TERM_BRACE, &opening);
+ } else {
+ expect1(parser, PM_TOKEN_KEYWORD_DO, PM_ERR_LAMBDA_OPEN);
+ opening = parser->previous;
+
+ if (!match3(parser, PM_TOKEN_KEYWORD_END, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) {
+ body = UP(parse_statements(parser, PM_CONTEXT_LAMBDA_DO_END, (uint16_t) (depth + 1)));
+ }
+
+ if (match2(parser, PM_TOKEN_KEYWORD_RESCUE, PM_TOKEN_KEYWORD_ENSURE)) {
+ assert(body == NULL || PM_NODE_TYPE_P(body, PM_STATEMENTS_NODE));
+ body = UP(parse_rescues_implicit_begin(parser, opening_newline_index, &operator, opening.start, (pm_statements_node_t *) body, PM_RESCUES_LAMBDA, (uint16_t) (depth + 1)));
+ } else {
+ parser_warn_indentation_mismatch(parser, opening_newline_index, &operator, false, false);
+ }
+
+ expect1_opening(parser, PM_TOKEN_KEYWORD_END, PM_ERR_LAMBDA_TERM_END, &operator);
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, pm_parser_scope_toplevel_p(parser));
+ pm_node_t *parameters = parse_blocklike_parameters(parser, UP(block_parameters), &operator, &parser->previous);
+
+ pm_parser_scope_pop(parser);
+ pm_accepts_block_stack_pop(parser);
+
+ return UP(pm_lambda_node_create(parser, &locals, &operator, &opening, &parser->previous, parameters, body));
+ }
+ case PM_TOKEN_UPLUS: {
+ if (binding_power > PM_BINDING_POWER_UNARY) {
+ pm_parser_err_prefix(parser, PM_ERR_UNARY_DISALLOWED);
+ }
+ parser_lex(parser);
+
+ pm_token_t operator = parser->previous;
+ pm_node_t *receiver = parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_UNARY_RECEIVER, (uint16_t) (depth + 1));
+ pm_call_node_t *node = pm_call_node_unary_create(parser, &operator, receiver, "+@");
+
+ return UP(node);
+ }
+ case PM_TOKEN_STRING_BEGIN:
+ return parse_strings(parser, NULL, flags & PM_PARSE_ACCEPTS_LABEL, (uint16_t) (depth + 1));
+ case PM_TOKEN_SYMBOL_BEGIN: {
+ pm_lex_mode_t lex_mode = *parser->lex_modes.current;
+ parser_lex(parser);
+
+ return parse_symbol(parser, &lex_mode, PM_LEX_STATE_END, (uint16_t) (depth + 1));
+ }
+ default: {
+ pm_context_t recoverable = context_recoverable(parser, &parser->current);
+
+ if (recoverable != PM_CONTEXT_NONE) {
+ parser->recovering = true;
+
+ // If the given error is not the generic one, then we'll add it
+ // here because it will provide more context in addition to the
+ // recoverable error that we will also add.
+ if (diag_id != PM_ERR_CANNOT_PARSE_EXPRESSION) {
+ pm_parser_err_prefix(parser, diag_id);
+ }
+
+ // If we get here, then we are assuming this token is closing a
+ // parent context, so we'll indicate that to the user so that
+ // they know how we behaved.
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT, pm_token_str(parser->current.type), context_human(recoverable));
+ } else if (diag_id == PM_ERR_CANNOT_PARSE_EXPRESSION) {
+ // We're going to make a special case here, because "cannot
+ // parse expression" is pretty generic, and we know here that we
+ // have an unexpected token.
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_UNEXPECTED_TOKEN_IGNORE, pm_token_str(parser->current.type));
+ } else {
+ pm_parser_err_prefix(parser, diag_id);
+ }
+
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->previous), PM_TOKEN_LENGTH(&parser->previous)));
+ }
+ }
+}
+
+/**
+ * Parse a value that is going to be written to some kind of variable or method
+ * call. We need to handle this separately because the rescue modifier is
+ * permitted on the end of the these expressions, which is a deviation from its
+ * normal binding power.
+ *
+ * Note that this will only be called after an operator write, as in &&=, ||=,
+ * or any of the binary operators that can be written to a variable.
+ */
+static pm_node_t *
+parse_assignment_value(pm_parser_t *parser, pm_binding_power_t previous_binding_power, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ pm_node_t *value = parse_value_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (previous_binding_power == PM_BINDING_POWER_ASSIGNMENT ? (flags & PM_PARSE_ACCEPTS_COMMAND_CALL) : (previous_binding_power < PM_BINDING_POWER_MATCH ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0))), diag_id, (uint16_t) (depth + 1));
+
+ // Assignments whose value is a command call (e.g., a = b c) can only
+ // be followed by modifiers (if/unless/while/until/rescue) and not by
+ // operators with higher binding power. If we find one, emit an error
+ // and skip the operator and its right-hand side.
+ if (pm_binding_powers[parser->current.type].left > PM_BINDING_POWER_MODIFIER && (pm_command_call_value_p(value) || pm_block_call_p(value))) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ parser_lex(parser);
+ parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ }
+
+ // Contradicting binding powers, the right-hand-side value of the assignment
+ // allows the `rescue` modifier.
+ if (match1(parser, PM_TOKEN_KEYWORD_RESCUE_MODIFIER)) {
+ context_push(parser, PM_CONTEXT_RESCUE_MODIFIER);
+
+ pm_token_t rescue = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *right = parse_expression(parser, pm_binding_powers[PM_TOKEN_KEYWORD_RESCUE_MODIFIER].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_RESCUE_MODIFIER_VALUE, (uint16_t) (depth + 1));
+ context_pop(parser);
+
+ return UP(pm_rescue_modifier_node_create(parser, value, &rescue, right));
+ }
+
+ return value;
+}
+
+/**
+ * When a local variable write node is the value being written in a different
+ * write, the local variable is considered "used".
+ */
+static void
+parse_assignment_value_local(pm_parser_t *parser, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BEGIN_NODE: {
+ const pm_begin_node_t *cast = (const pm_begin_node_t *) node;
+ if (cast->statements != NULL) parse_assignment_value_local(parser, (const pm_node_t *) cast->statements);
+ break;
+ }
+ case PM_LOCAL_VARIABLE_WRITE_NODE: {
+ const pm_local_variable_write_node_t *cast = (const pm_local_variable_write_node_t *) node;
+ pm_locals_read(&pm_parser_scope_find(parser, cast->depth)->locals, cast->name);
+ break;
+ }
+ case PM_PARENTHESES_NODE: {
+ const pm_parentheses_node_t *cast = (const pm_parentheses_node_t *) node;
+ if (cast->body != NULL) parse_assignment_value_local(parser, cast->body);
+ break;
+ }
+ case PM_STATEMENTS_NODE: {
+ const pm_statements_node_t *cast = (const pm_statements_node_t *) node;
+ const pm_node_t *statement;
+
+ PM_NODE_LIST_FOREACH(&cast->body, index, statement) {
+ parse_assignment_value_local(parser, statement);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+/**
+ * Parse the value (or values, through an implicit array) that is going to be
+ * written to some kind of variable or method call. We need to handle this
+ * separately because the rescue modifier is permitted on the end of the these
+ * expressions, which is a deviation from its normal binding power.
+ *
+ * Additionally, if the value is a local variable write node (e.g., a = a = 1),
+ * the "a" is marked as being used so the parser should not warn on it.
+ *
+ * Note that this will only be called after an = operator, as that is the only
+ * operator that allows multiple values after it.
+ */
+static pm_node_t *
+parse_assignment_values(pm_parser_t *parser, pm_binding_power_t previous_binding_power, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ bool permitted = true;
+ if (previous_binding_power != PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_USTAR)) permitted = false;
+
+ pm_node_t *value = parse_starred_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (previous_binding_power == PM_BINDING_POWER_ASSIGNMENT ? (flags & PM_PARSE_ACCEPTS_COMMAND_CALL) : (previous_binding_power < PM_BINDING_POWER_MODIFIER ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0))), diag_id, (uint16_t) (depth + 1));
+ if (!permitted) pm_parser_err_node(parser, value, PM_ERR_UNEXPECTED_MULTI_WRITE);
+
+ parse_assignment_value_local(parser, value);
+ bool single_value = true;
+
+ // Block calls (command call + do block, e.g., `foo bar do end`) cannot
+ // be followed by a comma to form a multi-value RHS because each element
+ // of a multi-value assignment must be an `arg`, not a `block_call`.
+ if (previous_binding_power == PM_BINDING_POWER_STATEMENT && !pm_block_call_p(value) && (PM_NODE_TYPE_P(value, PM_SPLAT_NODE) || match1(parser, PM_TOKEN_COMMA))) {
+ single_value = false;
+
+ pm_array_node_t *array = pm_array_node_create(parser, NULL);
+ pm_array_node_elements_append(parser->arena, array, value);
+ value = UP(array);
+
+ while (accept1(parser, PM_TOKEN_COMMA)) {
+ pm_node_t *element = parse_starred_expression(parser, binding_power, false, PM_ERR_ARRAY_ELEMENT, (uint16_t) (depth + 1));
+
+ pm_array_node_elements_append(parser->arena, array, element);
+ if (PM_NODE_TYPE_P(element, PM_ERROR_RECOVERY_NODE)) break;
+
+ parse_assignment_value_local(parser, element);
+ }
+ }
+
+ // Assignments whose value is a command call (e.g., a = b c) can only
+ // be followed by modifiers (if/unless/while/until/rescue) and not by
+ // operators with higher binding power. If we find one, emit an error
+ // and skip the operator and its right-hand side.
+ if (single_value && pm_binding_powers[parser->current.type].left > PM_BINDING_POWER_MODIFIER && (pm_command_call_value_p(value) || pm_block_call_p(value))) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(parser->current.type));
+ parser_lex(parser);
+ parse_expression(parser, pm_binding_powers[parser->previous.type].right, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ }
+
+ // Contradicting binding powers, the right-hand-side value of the assignment
+ // allows the `rescue` modifier.
+ if ((single_value || (binding_power == (PM_BINDING_POWER_MULTI_ASSIGNMENT + 1))) && match1(parser, PM_TOKEN_KEYWORD_RESCUE_MODIFIER)) {
+ context_push(parser, PM_CONTEXT_RESCUE_MODIFIER);
+
+ pm_token_t rescue = parser->current;
+ parser_lex(parser);
+
+ bool accepts_command_call_inner = false;
+
+ // RHS can accept command call iff the value is a call with arguments
+ // but without parenthesis.
+ if (PM_NODE_TYPE_P(value, PM_CALL_NODE)) {
+ pm_call_node_t *call_node = (pm_call_node_t *) value;
+ if ((call_node->arguments != NULL) && (call_node->opening_loc.length == 0)) {
+ accepts_command_call_inner = true;
+ }
+ }
+
+ pm_node_t *right = parse_expression(parser, pm_binding_powers[PM_TOKEN_KEYWORD_RESCUE_MODIFIER].right, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (accepts_command_call_inner ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0)), PM_ERR_RESCUE_MODIFIER_VALUE, (uint16_t) (depth + 1));
+ context_pop(parser);
+
+ return UP(pm_rescue_modifier_node_create(parser, value, &rescue, right));
+ }
+
+ return value;
+}
+
+/**
+ * Ensure a call node that is about to become a call operator node does not
+ * have arguments or a block attached. If it does, then we'll need to add an
+ * error message and destroy the arguments/block. Ideally we would keep the node
+ * around so that consumers would still have access to it, but we don't have a
+ * great structure for that at the moment.
+ */
+static void
+parse_call_operator_write(pm_parser_t *parser, pm_call_node_t *call_node, const pm_token_t *operator) {
+ if (call_node->arguments != NULL) {
+ pm_parser_err_token(parser, operator, PM_ERR_OPERATOR_WRITE_ARGUMENTS);
+ pm_node_unreference(parser, UP(call_node->arguments));
+ call_node->arguments = NULL;
+ }
+
+ if (call_node->block != NULL) {
+ pm_parser_err_token(parser, operator, PM_ERR_OPERATOR_WRITE_BLOCK);
+ pm_node_unreference(parser, UP(call_node->block));
+ call_node->block = NULL;
+ }
+}
+
+static PRISM_INLINE const uint8_t *
+pm_named_capture_escape_hex(pm_buffer_t *unescaped, const uint8_t *cursor, const uint8_t *end) {
+ cursor++;
+
+ if (cursor < end && pm_char_is_hexadecimal_digit(*cursor)) {
+ uint8_t value = escape_hexadecimal_digit(*cursor);
+ cursor++;
+
+ if (cursor < end && pm_char_is_hexadecimal_digit(*cursor)) {
+ value = (uint8_t) ((value << 4) | escape_hexadecimal_digit(*cursor));
+ cursor++;
+ }
+
+ pm_buffer_append_byte(unescaped, value);
+ } else {
+ pm_buffer_append_string(unescaped, "\\x", 2);
+ }
+
+ return cursor;
+}
+
+static PRISM_INLINE const uint8_t *
+pm_named_capture_escape_octal(pm_buffer_t *unescaped, const uint8_t *cursor, const uint8_t *end) {
+ uint8_t value = (uint8_t) (*cursor - '0');
+ cursor++;
+
+ if (cursor < end && pm_char_is_octal_digit(*cursor)) {
+ value = ((uint8_t) (value << 3)) | ((uint8_t) (*cursor - '0'));
+ cursor++;
+
+ if (cursor < end && pm_char_is_octal_digit(*cursor)) {
+ value = ((uint8_t) (value << 3)) | ((uint8_t) (*cursor - '0'));
+ cursor++;
+ }
+ }
+
+ pm_buffer_append_byte(unescaped, value);
+ return cursor;
+}
+
+static PRISM_INLINE const uint8_t *
+pm_named_capture_escape_unicode(pm_parser_t *parser, pm_buffer_t *unescaped, const uint8_t *cursor, const uint8_t *end, const pm_location_t *error_location) {
+ const uint8_t *start = cursor - 1;
+ cursor++;
+
+ if (cursor >= end) {
+ pm_buffer_append_string(unescaped, "\\u", 2);
+ return cursor;
+ }
+
+ if (*cursor != '{') {
+ size_t length = pm_strspn_hexadecimal_digit(cursor, MIN(end - cursor, 4));
+ uint32_t value = escape_unicode(parser, cursor, length, error_location, 0);
+
+ if (!pm_buffer_append_unicode_codepoint(unescaped, value)) {
+ pm_buffer_append_string(unescaped, (const char *) start, (size_t) ((cursor + length) - start));
+ }
+
+ return cursor + length;
+ }
+
+ cursor++;
+ for (;;) {
+ while (cursor < end && *cursor == ' ') cursor++;
+
+ if (cursor >= end) break;
+ if (*cursor == '}') {
+ cursor++;
+ break;
+ }
+
+ size_t length = pm_strspn_hexadecimal_digit(cursor, end - cursor);
+ if (length == 0) {
+ break;
+ }
+ uint32_t value = escape_unicode(parser, cursor, length, error_location, 0);
+
+ (void) pm_buffer_append_unicode_codepoint(unescaped, value);
+ cursor += length;
+ }
+
+ return cursor;
+}
+
+static void
+pm_named_capture_escape(pm_parser_t *parser, pm_buffer_t *unescaped, const uint8_t *source, const size_t length, const uint8_t *cursor, const pm_location_t *error_location) {
+ const uint8_t *end = source + length;
+ pm_buffer_append_string(unescaped, (const char *) source, (size_t) (cursor - source));
+
+ for (;;) {
+ if (++cursor >= end) {
+ pm_buffer_append_byte(unescaped, '\\');
+ return;
+ }
+
+ switch (*cursor) {
+ case 'x':
+ cursor = pm_named_capture_escape_hex(unescaped, cursor, end);
+ break;
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
+ cursor = pm_named_capture_escape_octal(unescaped, cursor, end);
+ break;
+ case 'u':
+ cursor = pm_named_capture_escape_unicode(parser, unescaped, cursor, end, error_location);
+ break;
+ default:
+ pm_buffer_append_byte(unescaped, '\\');
+ break;
+ }
+
+ const uint8_t *next_cursor = pm_memchr(cursor, '\\', (size_t) (end - cursor), parser->encoding_changed, parser->encoding);
+ if (next_cursor == NULL) break;
+
+ pm_buffer_append_string(unescaped, (const char *) cursor, (size_t) (next_cursor - cursor));
+ cursor = next_cursor;
+ }
+
+ pm_buffer_append_string(unescaped, (const char *) cursor, (size_t) (end - cursor));
+}
+
+/**
+ * This callback is called when the regular expression parser encounters a named
+ * capture group.
+ */
+static void
+parse_regular_expression_named_capture(pm_parser_t *parser, const pm_string_t *capture, bool shared, pm_regexp_name_data_t *callback_data) {
+ pm_call_node_t *call = callback_data->call;
+ pm_constant_id_list_t *names = &callback_data->names;
+
+ const uint8_t *source = pm_string_source(capture);
+ size_t length = pm_string_length(capture);
+ pm_buffer_t unescaped = { 0 };
+
+ // First, we need to handle escapes within the name of the capture group.
+ // This is because regular expressions have three different representations
+ // in prism. The first is the plain source code. The second is the
+ // representation that will be sent to the regular expression engine, which
+ // is the value of the "unescaped" field. This is poorly named, because it
+ // actually still contains escapes, just a subset of them that the regular
+ // expression engine knows how to handle. The third representation is fully
+ // unescaped, which is what we need.
+ const uint8_t *cursor = pm_memchr(source, '\\', length, parser->encoding_changed, parser->encoding);
+ if (PRISM_UNLIKELY(cursor != NULL)) {
+ pm_named_capture_escape(parser, &unescaped, source, length, cursor, shared ? NULL : &call->receiver->location);
+ source = (const uint8_t *) pm_buffer_value(&unescaped);
+ length = pm_buffer_length(&unescaped);
+ }
+
+ const uint8_t *start;
+ const uint8_t *end;
+ pm_constant_id_t name;
+
+ // If the name of the capture group isn't a valid identifier, we do
+ // not add it to the local table.
+ if (!pm_slice_is_valid_local(parser, source, source + length)) {
+ pm_buffer_cleanup(&unescaped);
+ return;
+ }
+
+ if (shared) {
+ // If the unescaped string is a slice of the source, then we can
+ // copy the names directly. The pointers will line up.
+ start = source;
+ end = source + length;
+ name = pm_parser_constant_id_raw(parser, start, end);
+ } else {
+ // Otherwise, the name is a slice of the malloc-ed owned string,
+ // in which case we need to copy it out into a new string.
+ start = parser->start + PM_NODE_START(call->receiver);
+ end = parser->start + PM_NODE_END(call->receiver);
+
+ uint8_t *memory = (uint8_t *) pm_arena_alloc(parser->arena, length, 1);
+ memcpy(memory, source, length);
+ name = pm_parser_constant_id_owned(parser, memory, length);
+ }
+
+ // Add this name to the list of constants if it is valid, not duplicated,
+ // and not a keyword.
+ if (name != 0 && !pm_constant_id_list_includes(names, name)) {
+ pm_constant_id_list_append(parser->arena, names, name);
+
+ int depth;
+ if ((depth = pm_parser_local_depth_constant_id(parser, name)) == -1) {
+ // If the local is not already a local but it is a keyword, then we
+ // do not want to add a capture for this.
+ if (pm_local_is_keyword((const char *) source, length)) {
+ pm_buffer_cleanup(&unescaped);
+ return;
+ }
+
+ // If the identifier is not already a local, then we will add it to
+ // the local table.
+ pm_parser_local_add(parser, name, start, end, 0);
+ }
+
+ // Here we lazily create the MatchWriteNode since we know we're
+ // about to add a target.
+ if (callback_data->match == NULL) {
+ callback_data->match = pm_match_write_node_create(parser, call);
+ }
+
+ // Next, create the local variable target and add it to the list of
+ // targets for the match.
+ pm_node_t *target = UP(pm_local_variable_target_node_create(parser, &TOK2LOC(parser, &((pm_token_t) { .type = 0, .start = start, .end = end })), name, depth == -1 ? 0 : (uint32_t) depth));
+ pm_node_list_append(parser->arena, &callback_data->match->targets, target);
+ }
+
+ pm_buffer_cleanup(&unescaped);
+}
+
+/**
+ * Potentially change a =~ with an interpolated regular expression with named
+ * captures into a match write node. This is for the interpolated case where
+ * we have concatenated content rather than a regular expression node.
+ */
+static pm_node_t *
+parse_interpolated_regular_expression_named_captures(pm_parser_t *parser, const pm_string_t *content, pm_call_node_t *call, bool extended_mode) {
+ pm_regexp_name_data_t callback_data = {
+ .call = call,
+ .match = NULL,
+ .names = { 0 },
+ };
+
+ pm_regexp_parse_named_captures(parser, pm_string_source(content), pm_string_length(content), false, extended_mode, parse_regular_expression_named_capture, &callback_data);
+
+ if (callback_data.match != NULL) {
+ return UP(callback_data.match);
+ } else {
+ return UP(call);
+ }
+}
+
+static PRISM_INLINE pm_node_t *
+parse_expression_infix(pm_parser_t *parser, pm_node_t *node, pm_binding_power_t previous_binding_power, pm_binding_power_t binding_power, uint8_t flags, uint16_t depth) {
+ pm_token_t token = parser->current;
+
+ switch (token.type) {
+ case PM_TOKEN_EQUAL: {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CALL_NODE: {
+ // If we have no arguments to the call node and we need this
+ // to be a target then this is either a method call or a
+ // local variable write. This _must_ happen before the value
+ // is parsed because it could be referenced in the value.
+ pm_call_node_t *call_node = (pm_call_node_t *) node;
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ pm_parser_local_add_location(parser, &call_node->message_loc, 0);
+ }
+ }
+ PRISM_FALLTHROUGH
+ case PM_CASE_WRITABLE: {
+ // When we have `it = value`, we need to add `it` as a local
+ // variable before parsing the value, in case the value
+ // references the variable.
+ if (PM_NODE_TYPE_P(node, PM_IT_LOCAL_VARIABLE_READ_NODE)) {
+ pm_parser_local_add_location(parser, &node->location, 0);
+ }
+
+ parser_lex(parser);
+ pm_node_t *value = parse_assignment_values(parser, previous_binding_power, PM_NODE_TYPE_P(node, PM_MULTI_TARGET_NODE) ? PM_BINDING_POWER_MULTI_ASSIGNMENT + 1 : binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL, (uint16_t) (depth + 1));
+
+ if (PM_NODE_TYPE_P(node, PM_MULTI_TARGET_NODE) && previous_binding_power != PM_BINDING_POWER_STATEMENT) {
+ pm_parser_err_node(parser, node, PM_ERR_UNEXPECTED_MULTI_WRITE);
+ }
+
+ return parse_write(parser, node, &token, value);
+ }
+ case PM_SPLAT_NODE: {
+ pm_multi_target_node_t *multi_target = pm_multi_target_node_create(parser);
+ pm_multi_target_node_targets_append(parser, multi_target, node);
+
+ parser_lex(parser);
+ pm_node_t *value = parse_assignment_values(parser, previous_binding_power, PM_BINDING_POWER_MULTI_ASSIGNMENT + 1, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL, (uint16_t) (depth + 1));
+ return parse_write(parser, UP(multi_target), &token, value);
+ }
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_FALSE_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_NIL_NODE:
+ case PM_SELF_NODE:
+ case PM_TRUE_NODE: {
+ // In these special cases, we have specific error messages
+ // and we will replace them with local variable writes.
+ parser_lex(parser);
+ pm_node_t *value = parse_assignment_values(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL, (uint16_t) (depth + 1));
+ return parse_unwriteable_write(parser, node, &token, value);
+ }
+ default:
+ // In this case we have an = sign, but we don't know what
+ // it's for. We need to treat it as an error. We'll mark it
+ // as an error and skip past it.
+ parser_lex(parser);
+ pm_parser_err_token(parser, &token, PM_ERR_EXPRESSION_NOT_WRITABLE);
+ return node;
+ }
+ }
+ case PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL: {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser, node, PM_ERR_WRITE_TARGET_READONLY);
+ PRISM_FALLTHROUGH
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_global_variable_and_write_node_create(parser, node, &token, value));
+
+ return result;
+ }
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_class_variable_and_write_node_create(parser, (pm_class_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_path_and_write_node_create(parser, (pm_constant_path_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_and_write_node_create(parser, (pm_constant_read_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_instance_variable_and_write_node_create(parser, (pm_instance_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_and_write_node_create(parser, node, &token, value, name, 0));
+
+ pm_node_unreference(parser, node);
+ return result;
+ }
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ if (pm_token_is_numbered_parameter(parser, PM_NODE_START(node), PM_NODE_LENGTH(node))) {
+ PM_PARSER_ERR_FORMAT(parser, node->location.start, node->location.length, PM_ERR_PARAMETER_NUMBERED_RESERVED, parser->start + node->location.start);
+ pm_node_unreference(parser, node);
+ }
+
+ pm_local_variable_read_node_t *cast = (pm_local_variable_read_node_t *) node;
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_and_write_node_create(parser, node, &token, value, cast->name, cast->depth));
+
+ return result;
+ }
+ case PM_CALL_NODE: {
+ pm_call_node_t *cast = (pm_call_node_t *) node;
+
+ // If we have a vcall (a method with no arguments and no
+ // receiver that could have been a local variable) then we
+ // will transform it into a local variable write.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ pm_refute_numbered_parameter(parser, cast->message_loc.start, cast->message_loc.length);
+ pm_constant_id_t constant_id = pm_parser_local_add_location(parser, &cast->message_loc, 1);
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_and_write_node_create(parser, UP(cast), &token, value, constant_id, 0));
+
+ return result;
+ }
+
+ // Move past the token here so that we have already added
+ // the local variable by this point.
+ parser_lex(parser);
+
+ // If there is no call operator and the message is "[]" then
+ // this is an aref expression, and we can transform it into
+ // an aset expression.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_INDEX)) {
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ return UP(pm_index_and_write_node_create(parser, cast, &token, value));
+ }
+
+ // If this node cannot be writable, then we have an error.
+ if (pm_call_node_writable_p(parser, cast)) {
+ parse_write_name(parser, &cast->name);
+ } else {
+ pm_parser_err_node(parser, node, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ parse_call_operator_write(parser, cast, &token);
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ, (uint16_t) (depth + 1));
+ return UP(pm_call_and_write_node_create(parser, cast, &token, value));
+ }
+ case PM_MULTI_WRITE_NODE: {
+ parser_lex(parser);
+ pm_parser_err_token(parser, &token, PM_ERR_AMPAMPEQ_MULTI_ASSIGN);
+ return node;
+ }
+ default:
+ parser_lex(parser);
+
+ // In this case we have an &&= sign, but we don't know what it's for.
+ // We need to treat it as an error. For now, we'll mark it as an error
+ // and just skip right past it.
+ pm_parser_err_token(parser, &token, PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ);
+ return node;
+ }
+ }
+ case PM_TOKEN_PIPE_PIPE_EQUAL: {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser, node, PM_ERR_WRITE_TARGET_READONLY);
+ PRISM_FALLTHROUGH
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_global_variable_or_write_node_create(parser, node, &token, value));
+
+ return result;
+ }
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_class_variable_or_write_node_create(parser, (pm_class_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_path_or_write_node_create(parser, (pm_constant_path_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_or_write_node_create(parser, (pm_constant_read_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_instance_variable_or_write_node_create(parser, (pm_instance_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_or_write_node_create(parser, node, &token, value, name, 0));
+
+ pm_node_unreference(parser, node);
+ return result;
+ }
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ if (pm_token_is_numbered_parameter(parser, PM_NODE_START(node), PM_NODE_LENGTH(node))) {
+ PM_PARSER_ERR_FORMAT(parser, PM_NODE_START(node), PM_NODE_LENGTH(node), PM_ERR_PARAMETER_NUMBERED_RESERVED, parser->start + PM_NODE_START(node));
+ pm_node_unreference(parser, node);
+ }
+
+ pm_local_variable_read_node_t *cast = (pm_local_variable_read_node_t *) node;
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_or_write_node_create(parser, node, &token, value, cast->name, cast->depth));
+
+ return result;
+ }
+ case PM_CALL_NODE: {
+ pm_call_node_t *cast = (pm_call_node_t *) node;
+
+ // If we have a vcall (a method with no arguments and no
+ // receiver that could have been a local variable) then we
+ // will transform it into a local variable write.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ pm_refute_numbered_parameter(parser, cast->message_loc.start, cast->message_loc.length);
+ pm_constant_id_t constant_id = pm_parser_local_add_location(parser, &cast->message_loc, 1);
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_or_write_node_create(parser, UP(cast), &token, value, constant_id, 0));
+
+ return result;
+ }
+
+ // Move past the token here so that we have already added
+ // the local variable by this point.
+ parser_lex(parser);
+
+ // If there is no call operator and the message is "[]" then
+ // this is an aref expression, and we can transform it into
+ // an aset expression.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_INDEX)) {
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ return UP(pm_index_or_write_node_create(parser, cast, &token, value));
+ }
+
+ // If this node cannot be writable, then we have an error.
+ if (pm_call_node_writable_p(parser, cast)) {
+ parse_write_name(parser, &cast->name);
+ } else {
+ pm_parser_err_node(parser, node, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ parse_call_operator_write(parser, cast, &token);
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ, (uint16_t) (depth + 1));
+ return UP(pm_call_or_write_node_create(parser, cast, &token, value));
+ }
+ case PM_MULTI_WRITE_NODE: {
+ parser_lex(parser);
+ pm_parser_err_token(parser, &token, PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN);
+ return node;
+ }
+ default:
+ parser_lex(parser);
+
+ // In this case we have an ||= sign, but we don't know what it's for.
+ // We need to treat it as an error. For now, we'll mark it as an error
+ // and just skip right past it.
+ pm_parser_err_token(parser, &token, PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ);
+ return node;
+ }
+ }
+ case PM_TOKEN_AMPERSAND_EQUAL:
+ case PM_TOKEN_CARET_EQUAL:
+ case PM_TOKEN_GREATER_GREATER_EQUAL:
+ case PM_TOKEN_LESS_LESS_EQUAL:
+ case PM_TOKEN_MINUS_EQUAL:
+ case PM_TOKEN_PERCENT_EQUAL:
+ case PM_TOKEN_PIPE_EQUAL:
+ case PM_TOKEN_PLUS_EQUAL:
+ case PM_TOKEN_SLASH_EQUAL:
+ case PM_TOKEN_STAR_EQUAL:
+ case PM_TOKEN_STAR_STAR_EQUAL: {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ PM_PARSER_ERR_NODE_FORMAT_CONTENT(parser, node, PM_ERR_WRITE_TARGET_READONLY);
+ PRISM_FALLTHROUGH
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_global_variable_operator_write_node_create(parser, node, &token, value));
+
+ return result;
+ }
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_class_variable_operator_write_node_create(parser, (pm_class_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_path_operator_write_node_create(parser, (pm_constant_path_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_CONSTANT_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *write = UP(pm_constant_operator_write_node_create(parser, (pm_constant_read_node_t *) node, &token, value));
+
+ return parse_shareable_constant_write(parser, write);
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_instance_variable_operator_write_node_create(parser, (pm_instance_variable_read_node_t *) node, &token, value));
+
+ return result;
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ pm_constant_id_t name = pm_parser_local_add_constant(parser, "it", 2);
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_operator_write_node_create(parser, node, &token, value, name, 0));
+
+ pm_node_unreference(parser, node);
+ return result;
+ }
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ if (pm_token_is_numbered_parameter(parser, PM_NODE_START(node), PM_NODE_LENGTH(node))) {
+ PM_PARSER_ERR_FORMAT(parser, PM_NODE_START(node), PM_NODE_LENGTH(node), PM_ERR_PARAMETER_NUMBERED_RESERVED, parser->start + PM_NODE_START(node));
+ pm_node_unreference(parser, node);
+ }
+
+ pm_local_variable_read_node_t *cast = (pm_local_variable_read_node_t *) node;
+ parser_lex(parser);
+
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_operator_write_node_create(parser, node, &token, value, cast->name, cast->depth));
+
+ return result;
+ }
+ case PM_CALL_NODE: {
+ parser_lex(parser);
+ pm_call_node_t *cast = (pm_call_node_t *) node;
+
+ // If we have a vcall (a method with no arguments and no
+ // receiver that could have been a local variable) then we
+ // will transform it into a local variable write.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ pm_refute_numbered_parameter(parser, cast->message_loc.start, cast->message_loc.length);
+ pm_constant_id_t constant_id = pm_parser_local_add_location(parser, &cast->message_loc, 1);
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ pm_node_t *result = UP(pm_local_variable_operator_write_node_create(parser, UP(cast), &token, value, constant_id, 0));
+
+ return result;
+ }
+
+ // If there is no call operator and the message is "[]" then
+ // this is an aref expression, and we can transform it into
+ // an aset expression.
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_INDEX)) {
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_index_operator_write_node_create(parser, cast, &token, value));
+ }
+
+ // If this node cannot be writable, then we have an error.
+ if (pm_call_node_writable_p(parser, cast)) {
+ parse_write_name(parser, &cast->name);
+ } else {
+ pm_parser_err_node(parser, node, PM_ERR_WRITE_TARGET_UNEXPECTED);
+ }
+
+ parse_call_operator_write(parser, cast, &token);
+ pm_node_t *value = parse_assignment_value(parser, previous_binding_power, binding_power, flags, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_call_operator_write_node_create(parser, cast, &token, value));
+ }
+ case PM_MULTI_WRITE_NODE: {
+ parser_lex(parser);
+ pm_parser_err_token(parser, &token, PM_ERR_OPERATOR_MULTI_ASSIGN);
+ return node;
+ }
+ default:
+ parser_lex(parser);
+
+ // In this case we have an operator but we don't know what it's for.
+ // We need to treat it as an error. For now, we'll mark it as an error
+ // and just skip right past it.
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->previous, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, pm_token_str(parser->current.type));
+ return node;
+ }
+ }
+ case PM_TOKEN_AMPERSAND_AMPERSAND:
+ case PM_TOKEN_KEYWORD_AND: {
+ parser_lex(parser);
+
+ pm_node_t *right = parse_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (parser->previous.type == PM_TOKEN_KEYWORD_AND ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0)), PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_and_node_create(parser, node, &token, right));
+ }
+ case PM_TOKEN_KEYWORD_OR:
+ case PM_TOKEN_PIPE_PIPE: {
+ parser_lex(parser);
+
+ pm_node_t *right = parse_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | (parser->previous.type == PM_TOKEN_KEYWORD_OR ? PM_PARSE_ACCEPTS_COMMAND_CALL : 0)), PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_or_node_create(parser, node, &token, right));
+ }
+ case PM_TOKEN_EQUAL_TILDE: {
+ // Note that we _must_ parse the value before adding the local
+ // variables in order to properly mirror the behavior of Ruby. For
+ // example,
+ //
+ // /(?<foo>bar)/ =~ foo
+ //
+ // In this case, `foo` should be a method call and not a local yet.
+ parser_lex(parser);
+ pm_node_t *argument = parse_expression(parser, binding_power, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+
+ // By default, we're going to create a call node and then return it.
+ pm_call_node_t *call = pm_call_node_binary_create(parser, node, &token, argument, 0);
+ pm_node_t *result = UP(call);
+
+ // If the receiver of this =~ is a regular expression node, then we
+ // need to introduce local variables for it based on its named
+ // capture groups.
+ if (PM_NODE_TYPE_P(node, PM_INTERPOLATED_REGULAR_EXPRESSION_NODE)) {
+ // It's possible to have an interpolated regular expression node
+ // that only contains strings. This is because it can be split
+ // up by a heredoc. In this case we need to concat the unescaped
+ // strings together and then parse them as a regular expression.
+ pm_node_list_t *parts = &((pm_interpolated_regular_expression_node_t *) node)->parts;
+
+ bool interpolated = false;
+ size_t total_length = 0;
+
+ pm_node_t *part;
+ PM_NODE_LIST_FOREACH(parts, index, part) {
+ if (PM_NODE_TYPE_P(part, PM_STRING_NODE)) {
+ total_length += pm_string_length(&((pm_string_node_t *) part)->unescaped);
+ } else {
+ interpolated = true;
+ break;
+ }
+ }
+
+ if (!interpolated && total_length > 0) {
+ void *memory = xmalloc(total_length);
+ if (!memory) abort();
+
+ uint8_t *cursor = memory;
+ PM_NODE_LIST_FOREACH(parts, index, part) {
+ pm_string_t *unescaped = &((pm_string_node_t *) part)->unescaped;
+ size_t length = pm_string_length(unescaped);
+
+ memcpy(cursor, pm_string_source(unescaped), length);
+ cursor += length;
+ }
+
+ pm_string_t owned;
+ pm_string_owned_init(&owned, (uint8_t *) memory, total_length);
+
+ result = parse_interpolated_regular_expression_named_captures(parser, &owned, call, PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED));
+ pm_string_cleanup(&owned);
+ }
+ } else if (PM_NODE_TYPE_P(node, PM_REGULAR_EXPRESSION_NODE)) {
+ // If we have a regular expression node, then we can parse
+ // the named captures and validate encoding in one pass.
+ pm_regular_expression_node_t *regexp = (pm_regular_expression_node_t *) node;
+
+ pm_regexp_name_data_t name_data = {
+ .call = call,
+ .match = NULL,
+ .names = { 0 },
+ };
+
+ pm_node_flag_set(UP(regexp), pm_regexp_parse(parser, regexp, parse_regular_expression_named_capture, &name_data));
+
+ if (name_data.match != NULL) {
+ result = UP(name_data.match);
+ }
+ }
+
+ return result;
+ }
+ case PM_TOKEN_UAMPERSAND:
+ case PM_TOKEN_USTAR:
+ case PM_TOKEN_USTAR_STAR:
+ // The only times this will occur are when we are in an error state,
+ // but we'll put them in here so that errors can propagate.
+ case PM_TOKEN_BANG_EQUAL:
+ case PM_TOKEN_BANG_TILDE:
+ case PM_TOKEN_EQUAL_EQUAL:
+ case PM_TOKEN_EQUAL_EQUAL_EQUAL:
+ case PM_TOKEN_LESS_EQUAL_GREATER:
+ case PM_TOKEN_CARET:
+ case PM_TOKEN_PIPE:
+ case PM_TOKEN_AMPERSAND:
+ case PM_TOKEN_GREATER_GREATER:
+ case PM_TOKEN_LESS_LESS:
+ case PM_TOKEN_MINUS:
+ case PM_TOKEN_PLUS:
+ case PM_TOKEN_PERCENT:
+ case PM_TOKEN_SLASH:
+ case PM_TOKEN_STAR:
+ case PM_TOKEN_STAR_STAR: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+ switch (PM_NODE_TYPE(node)) {
+ case PM_RESCUE_MODIFIER_NODE: {
+ pm_rescue_modifier_node_t *cast = (pm_rescue_modifier_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->rescue_expression, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->rescue_expression, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ case PM_AND_NODE: {
+ pm_and_node_t *cast = (pm_and_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->right, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->right, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ case PM_OR_NODE: {
+ pm_or_node_t *cast = (pm_or_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->right, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->right, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ pm_node_t *argument = parse_expression(parser, binding_power, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_call_node_binary_create(parser, node, &token, argument, 0));
+ }
+ case PM_TOKEN_GREATER:
+ case PM_TOKEN_GREATER_EQUAL:
+ case PM_TOKEN_LESS:
+ case PM_TOKEN_LESS_EQUAL: {
+ if (PM_NODE_TYPE_P(node, PM_CALL_NODE) && PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_COMPARISON)) {
+ PM_PARSER_WARN_TOKEN_FORMAT_CONTENT(parser, &parser->current, PM_WARN_COMPARISON_AFTER_COMPARISON);
+ }
+
+ parser_lex(parser);
+ pm_node_t *argument = parse_expression(parser, binding_power, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ return UP(pm_call_node_binary_create(parser, node, &token, argument, PM_CALL_NODE_FLAGS_COMPARISON));
+ }
+ case PM_TOKEN_AMPERSAND_DOT:
+ case PM_TOKEN_DOT: {
+ parser_lex(parser);
+ pm_token_t operator = parser->previous;
+ pm_arguments_t arguments = { 0 };
+
+ // This if statement handles the foo.() syntax.
+ if (match1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
+ parse_arguments_list(parser, &arguments, true, false, (uint16_t) (depth + 1));
+ return UP(pm_call_node_shorthand_create(parser, node, &operator, &arguments));
+ }
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_RESCUE_MODIFIER_NODE: {
+ pm_rescue_modifier_node_t *cast = (pm_rescue_modifier_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->rescue_expression, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->rescue_expression, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ case PM_AND_NODE: {
+ pm_and_node_t *cast = (pm_and_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->right, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->right, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ case PM_OR_NODE: {
+ pm_or_node_t *cast = (pm_or_node_t *) node;
+ if (PM_NODE_TYPE_P(cast->right, PM_MATCH_PREDICATE_NODE) || PM_NODE_TYPE_P(cast->right, PM_MATCH_REQUIRED_NODE)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &operator, PM_ERR_EXPECT_EOL_AFTER_STATEMENT, pm_token_str(operator.type));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ pm_token_t message;
+
+ switch (parser->current.type) {
+ case PM_CASE_OPERATOR:
+ case PM_CASE_KEYWORD:
+ case PM_TOKEN_CONSTANT:
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+ message = parser->previous;
+ break;
+ }
+ default: {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_EXPECT_MESSAGE, pm_token_str(parser->current.type));
+ message = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ }
+ }
+
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+ pm_call_node_t *call = pm_call_node_call_create(parser, node, &operator, &message, &arguments);
+
+ if (
+ (previous_binding_power == PM_BINDING_POWER_STATEMENT) &&
+ arguments.arguments == NULL &&
+ arguments.opening_loc.length == 0 &&
+ match1(parser, PM_TOKEN_COMMA)
+ ) {
+ return parse_targets_validate(parser, UP(call), PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ } else {
+ return UP(call);
+ }
+ }
+ case PM_TOKEN_DOT_DOT:
+ case PM_TOKEN_DOT_DOT_DOT: {
+ parser_lex(parser);
+
+ pm_node_t *right = NULL;
+ if (token_begins_expression_p(parser->current.type)) {
+ right = parse_expression(parser, binding_power, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR, (uint16_t) (depth + 1));
+ }
+
+ return UP(pm_range_node_create(parser, node, &token, right));
+ }
+ case PM_TOKEN_KEYWORD_IF_MODIFIER: {
+ pm_token_t keyword = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *predicate = parse_value_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_IF_PREDICATE, (uint16_t) (depth + 1));
+ return UP(pm_if_node_modifier_create(parser, node, &keyword, predicate));
+ }
+ case PM_TOKEN_KEYWORD_UNLESS_MODIFIER: {
+ pm_token_t keyword = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *predicate = parse_value_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_UNLESS_PREDICATE, (uint16_t) (depth + 1));
+ return UP(pm_unless_node_modifier_create(parser, node, &keyword, predicate));
+ }
+ case PM_TOKEN_KEYWORD_UNTIL_MODIFIER: {
+ parser_lex(parser);
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, node, true);
+
+ pm_node_t *predicate = parse_value_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_UNTIL_PREDICATE, (uint16_t) (depth + 1));
+ return UP(pm_until_node_modifier_create(parser, &token, predicate, statements, PM_NODE_TYPE_P(node, PM_BEGIN_NODE) ? PM_LOOP_FLAGS_BEGIN_MODIFIER : 0));
+ }
+ case PM_TOKEN_KEYWORD_WHILE_MODIFIER: {
+ parser_lex(parser);
+ pm_statements_node_t *statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, statements, node, true);
+
+ pm_node_t *predicate = parse_value_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_CONDITIONAL_WHILE_PREDICATE, (uint16_t) (depth + 1));
+ return UP(pm_while_node_modifier_create(parser, &token, predicate, statements, PM_NODE_TYPE_P(node, PM_BEGIN_NODE) ? PM_LOOP_FLAGS_BEGIN_MODIFIER : 0));
+ }
+ case PM_TOKEN_QUESTION_MARK: {
+ context_push(parser, PM_CONTEXT_TERNARY);
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ pm_token_t qmark = parser->current;
+ parser_lex(parser);
+
+ pm_node_t *true_expression = parse_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_TERNARY_EXPRESSION_TRUE, (uint16_t) (depth + 1));
+
+ if (parser->recovering) {
+ // If parsing the true expression of this ternary resulted in a syntax
+ // error that we can recover from, then we're going to put missing nodes
+ // and tokens into the remaining places. We want to be sure to do this
+ // before the `expect` function call to make sure it doesn't
+ // accidentally move past a ':' token that occurs after the syntax
+ // error.
+ pm_token_t colon = (pm_token_t) { .type = 0, .start = parser->previous.end, .end = parser->previous.end };
+ pm_node_t *false_expression = UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &colon), PM_TOKEN_LENGTH(&colon)));
+
+ context_pop(parser);
+ pop_block_exits(parser, previous_block_exits);
+ return UP(pm_if_node_ternary_create(parser, node, &qmark, true_expression, &colon, false_expression));
+ }
+
+ accept1(parser, PM_TOKEN_NEWLINE);
+ expect1(parser, PM_TOKEN_COLON, PM_ERR_TERNARY_COLON);
+
+ pm_token_t colon = parser->previous;
+ pm_node_t *false_expression = parse_expression(parser, PM_BINDING_POWER_DEFINED, flags & PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_TERNARY_EXPRESSION_FALSE, (uint16_t) (depth + 1));
+
+ context_pop(parser);
+ pop_block_exits(parser, previous_block_exits);
+ return UP(pm_if_node_ternary_create(parser, node, &qmark, true_expression, &colon, false_expression));
+ }
+ case PM_TOKEN_COLON_COLON: {
+ parser_lex(parser);
+ pm_token_t delimiter = parser->previous;
+
+ switch (parser->current.type) {
+ case PM_TOKEN_CONSTANT: {
+ parser_lex(parser);
+ pm_node_t *path;
+
+ if (
+ (parser->current.type == PM_TOKEN_PARENTHESIS_LEFT) ||
+ ((flags & PM_PARSE_ACCEPTS_COMMAND_CALL) && (token_begins_expression_p(parser->current.type) || match3(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR)))
+ ) {
+ // If we have a constant immediately following a '::' operator, then
+ // this can either be a constant path or a method call, depending on
+ // what follows the constant.
+ //
+ // If we have parentheses, then this is a method call. That would
+ // look like Foo::Bar().
+ pm_token_t message = parser->previous;
+ pm_arguments_t arguments = { 0 };
+
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+ path = UP(pm_call_node_call_create(parser, node, &delimiter, &message, &arguments));
+ } else {
+ // Otherwise, this is a constant path. That would look like Foo::Bar.
+ path = UP(pm_constant_path_node_create(parser, node, &delimiter, &parser->previous));
+ }
+
+ // If this is followed by a comma then it is a multiple assignment.
+ if (previous_binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ return parse_targets_validate(parser, path, PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return path;
+ }
+ case PM_CASE_OPERATOR:
+ case PM_CASE_KEYWORD:
+ case PM_TOKEN_IDENTIFIER:
+ case PM_TOKEN_METHOD_NAME: {
+ parser_lex(parser);
+ pm_token_t message = parser->previous;
+
+ // If we have an identifier following a '::' operator, then it is for
+ // sure a method call.
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, true, flags, (uint16_t) (depth + 1));
+ pm_call_node_t *call = pm_call_node_call_create(parser, node, &delimiter, &message, &arguments);
+
+ // If this is followed by a comma then it is a multiple assignment.
+ if (previous_binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ return parse_targets_validate(parser, UP(call), PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ return UP(call);
+ }
+ case PM_TOKEN_PARENTHESIS_LEFT: {
+ // If we have a parenthesis following a '::' operator, then it is the
+ // method call shorthand. That would look like Foo::(bar).
+ pm_arguments_t arguments = { 0 };
+ parse_arguments_list(parser, &arguments, true, false, (uint16_t) (depth + 1));
+
+ return UP(pm_call_node_shorthand_create(parser, node, &delimiter, &arguments));
+ }
+ default: {
+ expect1(parser, PM_TOKEN_CONSTANT, PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT);
+ return UP(pm_constant_path_node_create(parser, node, &delimiter, &parser->previous));
+ }
+ }
+ }
+ case PM_TOKEN_KEYWORD_RESCUE_MODIFIER: {
+ context_push(parser, PM_CONTEXT_RESCUE_MODIFIER);
+ parser_lex(parser);
+ accept1(parser, PM_TOKEN_NEWLINE);
+
+ pm_node_t *value = parse_expression(parser, binding_power, (uint8_t) ((flags & PM_PARSE_ACCEPTS_DO_BLOCK) | PM_PARSE_ACCEPTS_COMMAND_CALL), PM_ERR_RESCUE_MODIFIER_VALUE, (uint16_t) (depth + 1));
+ context_pop(parser);
+
+ return UP(pm_rescue_modifier_node_create(parser, node, &token, value));
+ }
+ case PM_TOKEN_BRACKET_LEFT: {
+ parser_lex(parser);
+
+ pm_arguments_t arguments = { 0 };
+ arguments.opening_loc = TOK2LOC(parser, &parser->previous);
+
+ if (!accept1(parser, PM_TOKEN_BRACKET_RIGHT)) {
+ pm_accepts_block_stack_push(parser, true);
+ parse_arguments(parser, &arguments, false, PM_TOKEN_BRACKET_RIGHT, (uint8_t) (flags & ~PM_PARSE_ACCEPTS_DO_BLOCK), (uint16_t) (depth + 1));
+ pm_accepts_block_stack_pop(parser);
+ expect1(parser, PM_TOKEN_BRACKET_RIGHT, PM_ERR_EXPECT_RBRACKET);
+ }
+
+ arguments.closing_loc = TOK2LOC(parser, &parser->previous);
+
+ // If we have a comma after the closing bracket then this is a multiple
+ // assignment and we should parse the targets.
+ if (previous_binding_power == PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_COMMA)) {
+ pm_call_node_t *aref = pm_call_node_aref_create(parser, node, &arguments);
+ return parse_targets_validate(parser, UP(aref), PM_BINDING_POWER_INDEX, (uint16_t) (depth + 1));
+ }
+
+ // If we're at the end of the arguments, we can now check if there is a
+ // block node that starts with a {. If there is, then we can parse it and
+ // add it to the arguments.
+ pm_block_node_t *block = NULL;
+ if (accept1(parser, PM_TOKEN_BRACE_LEFT)) {
+ block = parse_block(parser, (uint16_t) (depth + 1));
+ pm_arguments_validate_block(parser, &arguments, block);
+ } else if (pm_accepts_block_stack_p(parser) && accept1(parser, PM_TOKEN_KEYWORD_DO)) {
+ block = parse_block(parser, (uint16_t) (depth + 1));
+ }
+
+ if (block != NULL) {
+ if (arguments.block != NULL) {
+ pm_parser_err_node(parser, UP(block), PM_ERR_ARGUMENT_AFTER_BLOCK);
+ if (arguments.arguments == NULL) {
+ arguments.arguments = pm_arguments_node_create(parser);
+ }
+ pm_arguments_node_arguments_append(parser->arena, arguments.arguments, arguments.block);
+ }
+
+ arguments.block = UP(block);
+ }
+
+ return UP(pm_call_node_aref_create(parser, node, &arguments));
+ }
+ case PM_TOKEN_KEYWORD_IN: {
+ bool previous_pattern_matching_newlines = parser->pattern_matching_newlines;
+ parser->pattern_matching_newlines = true;
+
+ pm_token_t operator = parser->current;
+ parser->command_start = false;
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ parser_lex(parser);
+
+ pm_constant_id_list_t captures = { 0 };
+ pm_node_t *pattern = parse_pattern(parser, &captures, PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_IN, (uint16_t) (depth + 1));
+
+ parser->pattern_matching_newlines = previous_pattern_matching_newlines;
+
+ return UP(pm_match_predicate_node_create(parser, node, pattern, &operator));
+ }
+ case PM_TOKEN_EQUAL_GREATER: {
+ bool previous_pattern_matching_newlines = parser->pattern_matching_newlines;
+ parser->pattern_matching_newlines = true;
+
+ pm_token_t operator = parser->current;
+ parser->command_start = false;
+ lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
+ parser_lex(parser);
+
+ pm_constant_id_list_t captures = { 0 };
+ pm_node_t *pattern = parse_pattern(parser, &captures, PM_PARSE_PATTERN_TOP | PM_PARSE_PATTERN_MULTI, PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET, (uint16_t) (depth + 1));
+
+ parser->pattern_matching_newlines = previous_pattern_matching_newlines;
+
+ return UP(pm_match_required_node_create(parser, node, pattern, &operator));
+ }
+ default:
+ assert(false && "unreachable");
+ return NULL;
+ }
+}
+
+#undef PM_PARSE_PATTERN_SINGLE
+#undef PM_PARSE_PATTERN_TOP
+#undef PM_PARSE_PATTERN_MULTI
+
+/**
+ * Some nodes act as statements and limit which operators can follow. This
+ * function inspects the node and the upcoming token to determine whether the
+ * expression loop should stop. It is called both after prefix parsing and after
+ * each infix operator.
+ *
+ * As a side effect, this function also attaches do-blocks to command-style call
+ * nodes when appropriate.
+ *
+ * Returns true if the expression loop should stop (i.e., the next operator
+ * should not be consumed).
+ */
+static bool
+parse_expression_terminator(pm_parser_t *parser, pm_node_t *node) {
+ pm_binding_power_t left = pm_binding_powers[parser->current.type].left;
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_MULTI_WRITE_NODE:
+ case PM_RETURN_NODE:
+ case PM_BREAK_NODE:
+ case PM_NEXT_NODE:
+ return left > PM_BINDING_POWER_MODIFIER;
+ case PM_CLASS_VARIABLE_WRITE_NODE:
+ case PM_CONSTANT_PATH_WRITE_NODE:
+ case PM_CONSTANT_WRITE_NODE:
+ case PM_GLOBAL_VARIABLE_WRITE_NODE:
+ case PM_INSTANCE_VARIABLE_WRITE_NODE:
+ case PM_LOCAL_VARIABLE_WRITE_NODE:
+ return PM_NODE_FLAG_P(node, PM_WRITE_NODE_FLAGS_IMPLICIT_ARRAY) && left > PM_BINDING_POWER_MODIFIER;
+ case PM_CALL_NODE: {
+ // Calls with an implicit array on the right-hand side are
+ // statements and can only be followed by modifiers.
+ if (PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_IMPLICIT_ARRAY)) {
+ return left > PM_BINDING_POWER_MODIFIER;
+ }
+
+ // Command-style calls (including block commands like
+ // `foo bar do end`) can only be followed by composition
+ // (and/or) and modifier (if/unless/etc.) operators.
+ if (pm_command_call_value_p(node)) {
+ return left > PM_BINDING_POWER_COMPOSITION;
+ }
+
+ // A block call (command with do-block, or any call chained
+ // from one) can only be followed by call chaining (., ::,
+ // &.), composition (and/or), and modifier operators.
+ if (pm_block_call_p(node)) {
+ return left > PM_BINDING_POWER_COMPOSITION && left < PM_BINDING_POWER_CALL;
+ }
+
+ return false;
+ }
+ case PM_SUPER_NODE:
+ case PM_YIELD_NODE:
+ // Command-style super/yield (without parens) can only be followed
+ // by composition and modifier operators.
+ if (pm_command_call_value_p(node)) {
+ return left > PM_BINDING_POWER_COMPOSITION;
+ }
+ return false;
+ case PM_DEF_NODE:
+ // An endless method whose body is a command-style call (e.g.,
+ // `def f = foo bar`) is a command assignment and can only be
+ // followed by modifiers.
+ return left > PM_BINDING_POWER_MODIFIER && pm_command_call_value_p(node);
+ case PM_RESCUE_MODIFIER_NODE:
+ // A rescue modifier whose handler is a pattern match (=> or in)
+ // produces a statement and cannot be followed by operators above
+ // the modifier level.
+ if (left > PM_BINDING_POWER_MODIFIER) {
+ pm_rescue_modifier_node_t *cast = (pm_rescue_modifier_node_t *) node;
+ pm_node_t *rescue_expression = cast->rescue_expression;
+ return PM_NODE_TYPE_P(rescue_expression, PM_MATCH_REQUIRED_NODE) || PM_NODE_TYPE_P(rescue_expression, PM_MATCH_PREDICATE_NODE);
+ }
+ return false;
+ default:
+ return false;
+ }
+}
+
+/**
+ * Parse an expression at the given point of the parser using the given binding
+ * power to parse subsequent chains. If this function finds a syntax error, it
+ * will append the error message to the parser's error list.
+ *
+ * Consumers of this function should always check parser->recovering to
+ * determine if they need to perform additional cleanup.
+ */
+static pm_node_t *
+parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, uint8_t flags, pm_diagnostic_id_t diag_id, uint16_t depth) {
+ if (PRISM_UNLIKELY(depth >= PRISM_DEPTH_MAXIMUM)) {
+ pm_parser_err_current(parser, PM_ERR_NESTING_TOO_DEEP);
+ return UP(pm_error_recovery_node_create(parser, PM_TOKEN_START(parser, &parser->current), PM_TOKEN_LENGTH(&parser->current)));
+ }
+
+ pm_node_t *node = parse_expression_prefix(parser, binding_power, flags, diag_id, depth);
+
+ // Some prefix nodes are statements and can only be followed by modifiers
+ // (if/unless/while/until/rescue) or nothing at all. We check these cheaply
+ // here before entering the infix loop.
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ERROR_RECOVERY_NODE:
+ return node;
+ case PM_PRE_EXECUTION_NODE:
+ return node;
+ case PM_POST_EXECUTION_NODE:
+ case PM_ALIAS_GLOBAL_VARIABLE_NODE:
+ case PM_ALIAS_METHOD_NODE:
+ case PM_UNDEF_NODE:
+ if (pm_binding_powers[parser->current.type].left > PM_BINDING_POWER_MODIFIER) {
+ return node;
+ }
+ break;
+ case PM_CALL_NODE:
+ case PM_SUPER_NODE:
+ case PM_YIELD_NODE:
+ case PM_DEF_NODE:
+ if (parse_expression_terminator(parser, node)) {
+ return node;
+ }
+ break;
+ case PM_SYMBOL_NODE:
+ if (pm_symbol_node_label_p(parser, node)) {
+ return node;
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Look and see if the next token can be parsed as an infix operator. If it
+ // can, then we'll parse it using parse_expression_infix.
+ pm_binding_powers_t current_binding_powers;
+ pm_token_type_t current_token_type;
+
+ while (
+ current_token_type = parser->current.type,
+ current_binding_powers = pm_binding_powers[current_token_type],
+ binding_power <= current_binding_powers.left &&
+ current_binding_powers.binary
+ ) {
+ node = parse_expression_infix(parser, node, binding_power, current_binding_powers.right, flags, (uint16_t) (depth + 1));
+ if (parse_expression_terminator(parser, node)) return node;
+
+ // If the operator is nonassoc and we should not be able to parse the
+ // upcoming infix operator, break.
+ if (current_binding_powers.nonassoc) {
+ // If this is a non-assoc operator and we are about to parse the
+ // exact same operator, then we need to add an error.
+ if (match1(parser, current_token_type)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_NON_ASSOCIATIVE_OPERATOR, pm_token_str(parser->current.type), pm_token_str(current_token_type));
+ break;
+ }
+
+ // If this is an endless range, then we need to reject a couple of
+ // additional operators because it violates the normal operator
+ // precedence rules. Those patterns are:
+ //
+ // 1.. & 2
+ // 1.. * 2
+ //
+ if (PM_NODE_TYPE_P(node, PM_RANGE_NODE) && ((pm_range_node_t *) node)->right == NULL) {
+ if (match4(parser, PM_TOKEN_UAMPERSAND, PM_TOKEN_USTAR, PM_TOKEN_DOT, PM_TOKEN_AMPERSAND_DOT)) {
+ PM_PARSER_ERR_TOKEN_FORMAT(parser, &parser->current, PM_ERR_NON_ASSOCIATIVE_OPERATOR, pm_token_str(parser->current.type), pm_token_str(current_token_type));
+ break;
+ }
+
+ if (PM_BINDING_POWER_TERM <= pm_binding_powers[parser->current.type].left) {
+ break;
+ }
+ } else if (current_binding_powers.left <= pm_binding_powers[parser->current.type].left) {
+ break;
+ }
+ }
+
+ if (flags & PM_PARSE_ACCEPTS_COMMAND_CALL) {
+ // A command-style method call is only accepted on method chains.
+ // Thus, we check whether the parsed node can continue method chains.
+ // The method chain can continue if the parsed node is one of the following five kinds:
+ // (1) index access: foo[1]
+ // (2) attribute access: foo.bar
+ // (3) method call with parenthesis: foo.bar(1)
+ // (4) method call with a block: foo.bar do end
+ // (5) constant path: foo::Bar
+ switch (node->type) {
+ case PM_CALL_NODE: {
+ pm_call_node_t *cast = (pm_call_node_t *)node;
+ if (
+ // (1) foo[1]
+ !(
+ cast->call_operator_loc.length == 0 &&
+ cast->message_loc.length > 0 &&
+ parser->start[cast->message_loc.start] == '[' &&
+ parser->start[cast->message_loc.start + cast->message_loc.length - 1] == ']'
+ ) &&
+ // (2) foo.bar
+ !(
+ cast->call_operator_loc.length > 0 &&
+ cast->arguments == NULL &&
+ cast->block == NULL &&
+ cast->opening_loc.length == 0
+ ) &&
+ // (3) foo.bar(1)
+ !(
+ cast->call_operator_loc.length > 0 &&
+ cast->opening_loc.length > 0
+ ) &&
+ // (4) foo.bar do end
+ !(
+ cast->block != NULL && PM_NODE_TYPE_P(cast->block, PM_BLOCK_NODE)
+ )
+ ) {
+ flags &= (uint8_t) ~PM_PARSE_ACCEPTS_COMMAND_CALL;
+ }
+ break;
+ }
+ // (5) foo::Bar
+ case PM_CONSTANT_PATH_NODE:
+ break;
+ default:
+ flags &= (uint8_t) ~PM_PARSE_ACCEPTS_COMMAND_CALL;
+ break;
+ }
+ }
+
+ if (context_terminator(parser->current_context->context, &parser->current)) {
+ pm_binding_powers_t next_binding_powers = pm_binding_powers[parser->current.type];
+ if (
+ !next_binding_powers.binary ||
+ binding_power > next_binding_powers.left ||
+ (PM_NODE_TYPE_P(node, PM_CALL_NODE) && pm_call_node_command_p((pm_call_node_t *) node))
+ ) {
+ return node;
+ }
+ }
+ }
+
+ return node;
+}
+
+/**
+ * ruby -p, ruby -n, ruby -a, and ruby -l options will mutate the AST. We
+ * perform that mutation here.
+ */
+static pm_statements_node_t *
+wrap_statements(pm_parser_t *parser, pm_statements_node_t *statements) {
+ if (PM_PARSER_COMMAND_LINE_OPTION_P(parser)) {
+ if (statements == NULL) {
+ statements = pm_statements_node_create(parser);
+ }
+
+ pm_arguments_node_t *arguments = pm_arguments_node_create(parser);
+ pm_arguments_node_arguments_append(
+ parser->arena,
+ arguments,
+ UP(pm_global_variable_read_node_synthesized_create(parser, pm_parser_constant_id_constant(parser, "$_", 2)))
+ );
+
+ pm_statements_node_body_append(parser, statements, UP(pm_call_node_fcall_synthesized_create(
+ parser,
+ arguments,
+ pm_parser_constant_id_constant(parser, "print", 5)
+ )), true);
+ }
+
+ if (PM_PARSER_COMMAND_LINE_OPTION_N(parser)) {
+ if (PM_PARSER_COMMAND_LINE_OPTION_A(parser)) {
+ if (statements == NULL) {
+ statements = pm_statements_node_create(parser);
+ }
+
+ pm_arguments_node_t *arguments = pm_arguments_node_create(parser);
+ pm_arguments_node_arguments_append(
+ parser->arena,
+ arguments,
+ UP(pm_global_variable_read_node_synthesized_create(parser, pm_parser_constant_id_constant(parser, "$;", 2)))
+ );
+
+ pm_global_variable_read_node_t *receiver = pm_global_variable_read_node_synthesized_create(parser, pm_parser_constant_id_constant(parser, "$_", 2));
+ pm_call_node_t *call = pm_call_node_call_synthesized_create(parser, UP(receiver), "split", arguments);
+
+ pm_global_variable_write_node_t *write = pm_global_variable_write_node_synthesized_create(
+ parser,
+ pm_parser_constant_id_constant(parser, "$F", 2),
+ UP(call)
+ );
+
+ pm_statements_node_body_prepend(parser->arena, statements, UP(write));
+ }
+
+ pm_arguments_node_t *arguments = pm_arguments_node_create(parser);
+ pm_arguments_node_arguments_append(
+ parser->arena,
+ arguments,
+ UP(pm_global_variable_read_node_synthesized_create(parser, pm_parser_constant_id_constant(parser, "$/", 2)))
+ );
+
+ if (PM_PARSER_COMMAND_LINE_OPTION_L(parser)) {
+ pm_keyword_hash_node_t *keywords = pm_keyword_hash_node_create(parser);
+ pm_keyword_hash_node_elements_append(parser->arena, keywords, UP(pm_assoc_node_create(
+ parser,
+ UP(pm_symbol_node_synthesized_create(parser, "chomp")),
+ NULL,
+ UP(pm_true_node_synthesized_create(parser))
+ )));
+
+ pm_arguments_node_arguments_append(parser->arena, arguments, UP(keywords));
+ pm_node_flag_set(UP(arguments), PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS);
+ }
+
+ pm_statements_node_t *wrapped_statements = pm_statements_node_create(parser);
+ pm_statements_node_body_append(parser, wrapped_statements, UP(pm_while_node_synthesized_create(
+ parser,
+ UP(pm_call_node_fcall_synthesized_create(parser, arguments, pm_parser_constant_id_constant(parser, "gets", 4))),
+ statements
+ )), true);
+
+ statements = wrapped_statements;
+ }
+
+ return statements;
+}
+
+/**
+ * Parse the top-level program node.
+ */
+static pm_node_t *
+parse_program(pm_parser_t *parser) {
+ // If the current scope is NULL, then we want to push a new top level scope.
+ // The current scope could exist in the event that we are parsing an eval
+ // and the user has passed into scopes that already exist.
+ if (parser->current_scope == NULL) {
+ pm_parser_scope_push(parser, true);
+ }
+
+ pm_node_list_t current_block_exits = { 0 };
+ pm_node_list_t *previous_block_exits = push_block_exits(parser, &current_block_exits);
+
+ parser_lex(parser);
+ pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_MAIN, 0);
+
+ if (statements != NULL && !parser->parsing_eval) {
+ // If we have statements, then the top-level statement should be
+ // explicitly checked as well. We have to do this here because
+ // everywhere else we check all but the last statement.
+ assert(statements->body.size > 0);
+ pm_void_statement_check(parser, statements->body.nodes[statements->body.size - 1]);
+ }
+
+ pm_constant_id_list_t locals;
+ pm_locals_order(parser, &parser->current_scope->locals, &locals, true);
+ pm_parser_scope_pop(parser);
+
+ // At the top level, see if we need to wrap the statements in a program
+ // node with a while loop based on the options.
+ if (parser->command_line & (PM_OPTIONS_COMMAND_LINE_P | PM_OPTIONS_COMMAND_LINE_N)) {
+ statements = wrap_statements(parser, statements);
+ } else {
+ flush_block_exits(parser, previous_block_exits);
+ }
+
+ // If this is an empty file, then we're still going to parse all of the
+ // statements in order to gather up all of the comments and such. Here we'll
+ // correct the location information.
+ if (statements == NULL) {
+ statements = pm_statements_node_create(parser);
+ statements->base.location = (pm_location_t) { 0 };
+ }
+
+ return UP(pm_program_node_create(parser, &locals, statements));
+}
+
+/******************************************************************************/
+/* External functions */
+/******************************************************************************/
+
+/**
+ * A vendored version of strnstr that is used to find a substring within a
+ * string with a given length. This function is used to search for "ruby"
+ * within a shebang when the -x option is passed to Ruby.
+ *
+ * The only modification that we made here is that we don't do NULL byte checks
+ * because we know the little parameter will not have a NULL byte and we allow
+ * the big parameter to have them.
+ */
+static const char *
+pm_strnstr(const char *big, const char *little, size_t big_length) {
+ size_t little_length = strlen(little);
+
+ for (const char *max = big + big_length - little_length; big <= max; big++) {
+ if (*big == *little && memcmp(big, little, little_length) == 0) return big;
+ }
+
+ return NULL;
+}
+
+#ifdef _WIN32
+#define pm_parser_warn_shebang_carriage_return(parser, start, length) ((void) 0)
+#else
+/**
+ * Potentially warn the user if the shebang that has been found to include
+ * "ruby" has a carriage return at the end, as that can cause problems on some
+ * platforms.
+ */
+static void
+pm_parser_warn_shebang_carriage_return(pm_parser_t *parser, const uint8_t *start, size_t length) {
+ if (length > 2 && start[length - 2] == '\r' && start[length - 1] == '\n') {
+ pm_parser_warn(parser, U32(start - parser->start), U32(length), PM_WARN_SHEBANG_CARRIAGE_RETURN);
+ }
+}
+#endif
+
+/**
+ * Process the shebang when initializing the parser. This function assumes that
+ * the shebang_callback option has already been checked for nullability.
+ */
+static void
+pm_parser_init_shebang(pm_parser_t *parser, const pm_options_t *options, const char *engine, size_t length) {
+ const char *switches = pm_strnstr(engine, " -", length);
+ if (switches == NULL) return;
+
+ pm_options_t next_options = *options;
+ options->shebang_callback(
+ &next_options,
+ (const uint8_t *) (switches + 1),
+ length - ((size_t) (switches - engine)) - 1,
+ options->shebang_callback_data
+ );
+
+ size_t encoding_length;
+ if ((encoding_length = pm_string_length(&next_options.encoding)) > 0) {
+ const uint8_t *encoding_source = pm_string_source(&next_options.encoding);
+ parser_lex_magic_comment_encoding_value(parser, encoding_source, encoding_source + encoding_length);
+ }
+
+ parser->command_line = next_options.command_line;
+ parser->frozen_string_literal = next_options.frozen_string_literal;
+}
+
+/**
+ * Initialize a parser with the given start and end pointers.
+ */
+void
+pm_parser_init(pm_arena_t *arena, pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options) {
+ assert(arena != NULL);
+ assert(source != NULL);
+
+ *parser = (pm_parser_t) {
+ .arena = arena,
+ .metadata_arena = { 0 },
+ .node_id = 0,
+ .lex_state = PM_LEX_STATE_BEG,
+ .enclosure_nesting = 0,
+ .lambda_enclosure_nesting = -1,
+ .brace_nesting = 0,
+ .do_loop_stack = 0,
+ .accepts_block_stack = 0,
+ .lex_modes = {
+ .index = 0,
+ .stack = {{ .mode = PM_LEX_DEFAULT }},
+ .current = &parser->lex_modes.stack[0],
+ },
+ .start = source,
+ .end = source + size,
+ .previous = { .type = PM_TOKEN_EOF, .start = source, .end = source },
+ .current = { .type = PM_TOKEN_EOF, .start = source, .end = source },
+ .next_start = NULL,
+ .heredoc_end = NULL,
+ .data_loc = { 0 },
+ .comment_list = { 0 },
+ .magic_comment_list = { 0 },
+ .warning_list = { 0 },
+ .error_list = { 0 },
+ .current_scope = NULL,
+ .current_context = NULL,
+ .encoding = PM_ENCODING_UTF_8_ENTRY,
+ .encoding_changed_callback = NULL,
+ .encoding_comment_start = source,
+ .lex_callback = { 0 },
+ .filepath = { 0 },
+ .constant_pool = { 0 },
+ .line_offsets = { 0 },
+ .integer = { 0 },
+ .current_string = PM_STRING_EMPTY,
+ .start_line = 1,
+ .explicit_encoding = NULL,
+ .command_line = 0,
+ .parsing_eval = false,
+ .partial_script = false,
+ .command_start = true,
+ .recovering = false,
+ .continuable = true,
+ .encoding_locked = false,
+ .encoding_changed = false,
+ .pattern_matching_newlines = false,
+ .in_keyword_arg = false,
+ .current_block_exits = NULL,
+ .semantic_token_seen = false,
+ .frozen_string_literal = PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET,
+ .warn_mismatched_indentation = true
+ };
+
+ /* Pre-size the arenas based on input size to reduce the number of block
+ * allocations (and the kernel page zeroing they trigger). The ratios were
+ * measured empirically: AST arena ~3.3x input, metadata arena ~1.1x input.
+ * The reserve call is a no-op when the capacity is at or below the default
+ * arena block size, so small inputs don't waste an extra allocation. */
+ if (size <= SIZE_MAX / 4) pm_arena_reserve(arena, size * 4);
+ if (size <= SIZE_MAX / 5 * 4) pm_arena_reserve(&parser->metadata_arena, size + size / 4);
+
+ /* Initialize the constant pool. Measured across 1532 Ruby stdlib files, the
+ * bytes/constant ratio has a median of ~56 and a 90th percentile of ~135.
+ * We use 120 as a balance between over-allocation waste and resize
+ * frequency. Resizes are cheap with arena allocation, so we lean toward
+ * under-estimating. */
+ uint32_t constant_size = ((uint32_t) size) / 120;
+ pm_constant_pool_init(&parser->metadata_arena, &parser->constant_pool, constant_size < 4 ? 4 : constant_size);
+
+ /* Initialize the line offset list. Similar to the constant pool, we are
+ * going to estimate the number of newlines that we will need based on the
+ * size of the input. */
+ size_t newline_size = size / 22;
+ pm_line_offset_list_init(&parser->metadata_arena, &parser->line_offsets, newline_size < 4 ? 4 : newline_size);
+
+ // If options were provided to this parse, establish them here.
+ if (options != NULL) {
+ // filepath option
+ parser->filepath = options->filepath;
+
+ // line option
+ parser->start_line = options->line;
+
+ // encoding option
+ size_t encoding_length = pm_string_length(&options->encoding);
+ if (encoding_length > 0) {
+ const uint8_t *encoding_source = pm_string_source(&options->encoding);
+ parser_lex_magic_comment_encoding_value(parser, encoding_source, encoding_source + encoding_length);
+ }
+
+ // encoding_locked option
+ parser->encoding_locked = options->encoding_locked;
+
+ // frozen_string_literal option
+ parser->frozen_string_literal = options->frozen_string_literal;
+
+ // command_line option
+ parser->command_line = options->command_line;
+
+ // version option
+ parser->version = options->version;
+
+ // partial_script
+ parser->partial_script = options->partial_script;
+
+ // scopes option
+ parser->parsing_eval = options->scopes_count > 0;
+ if (parser->parsing_eval) parser->warn_mismatched_indentation = false;
+
+ for (size_t scope_index = 0; scope_index < options->scopes_count; scope_index++) {
+ const pm_options_scope_t *scope = pm_options_scope(options, scope_index);
+ pm_parser_scope_push(parser, scope_index == 0);
+
+ // Scopes given from the outside are not allowed to have numbered
+ // parameters.
+ parser->current_scope->parameters = ((pm_scope_parameters_t) scope->forwarding) | PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED;
+
+ for (size_t local_index = 0; local_index < scope->locals_count; local_index++) {
+ const pm_string_t *local = pm_options_scope_local(scope, local_index);
+
+ const uint8_t *source = pm_string_source(local);
+ size_t length = pm_string_length(local);
+
+ uint8_t *allocated = (uint8_t *) pm_arena_alloc(&parser->metadata_arena, length, 1);
+ memcpy(allocated, source, length);
+ pm_parser_local_add_owned(parser, allocated, length);
+ }
+ }
+ }
+
+ // Now that we have established the user-provided options, check if
+ // a version was given and parse as the latest version otherwise.
+ if (parser->version == PM_OPTIONS_VERSION_UNSET) {
+ parser->version = PM_OPTIONS_VERSION_LATEST;
+ }
+
+ pm_accepts_block_stack_push(parser, true);
+
+ // Skip past the UTF-8 BOM if it exists.
+ if (size >= 3 && source[0] == 0xef && source[1] == 0xbb && source[2] == 0xbf) {
+ parser->current.end += 3;
+ parser->encoding_comment_start += 3;
+
+ if (parser->encoding != PM_ENCODING_UTF_8_ENTRY) {
+ parser->encoding = PM_ENCODING_UTF_8_ENTRY;
+ if (parser->encoding_changed_callback != NULL) parser->encoding_changed_callback(parser);
+ }
+ }
+
+ // If the -x command line flag is set, or the first shebang of the file does
+ // not include "ruby", then we'll search for a shebang that does include
+ // "ruby" and start parsing from there.
+ bool search_shebang = PM_PARSER_COMMAND_LINE_OPTION_X(parser);
+
+ // If the first two bytes of the source are a shebang, then we will do a bit
+ // of extra processing.
+ //
+ // First, we'll indicate that the encoding comment is at the end of the
+ // shebang. This means that when a shebang is present the encoding comment
+ // can begin on the second line.
+ //
+ // Second, we will check if the shebang includes "ruby". If it does, then we
+ // we will start parsing from there. We will also potentially warning the
+ // user if there is a carriage return at the end of the shebang. We will
+ // also potentially call the shebang callback if this is the main script to
+ // allow the caller to parse the shebang and find any command-line options.
+ // If the shebang does not include "ruby" and this is the main script being
+ // parsed, then we will start searching the file for a shebang that does
+ // contain "ruby" as if -x were passed on the command line.
+ const uint8_t *newline = next_newline(parser->current.end, parser->end - parser->current.end);
+ size_t length = (size_t) ((newline != NULL ? newline : parser->end) - parser->current.end);
+
+ if (length > 2 && parser->current.end[0] == '#' && parser->current.end[1] == '!') {
+ const char *engine;
+
+ if ((engine = pm_strnstr((const char *) parser->start, "ruby", length)) != NULL) {
+ if (newline != NULL) {
+ parser->encoding_comment_start = newline + 1;
+
+ if (options == NULL || options->main_script) {
+ pm_parser_warn_shebang_carriage_return(parser, parser->start, length + 1);
+ }
+ }
+
+ if (options != NULL && options->main_script && options->shebang_callback != NULL) {
+ pm_parser_init_shebang(parser, options, engine, length - ((size_t) (engine - (const char *) parser->start)));
+ }
+
+ search_shebang = false;
+ } else if (options != NULL && options->main_script && !parser->parsing_eval) {
+ search_shebang = true;
+ }
+ }
+
+ // Here we're going to find the first shebang that includes "ruby" and start
+ // parsing from there.
+ if (search_shebang) {
+ // If a shebang that includes "ruby" is not found, then we're going to a
+ // a load error to the list of errors on the parser.
+ bool found_shebang = false;
+
+ // This is going to point to the start of each line as we check it.
+ // We'll maintain a moving window looking at each line at they come.
+ const uint8_t *cursor = parser->start;
+
+ // The newline pointer points to the end of the current line that we're
+ // considering. If it is NULL, then we're at the end of the file.
+ const uint8_t *newline = next_newline(cursor, parser->end - cursor);
+
+ while (newline != NULL) {
+ pm_line_offset_list_append(&parser->metadata_arena, &parser->line_offsets, U32(newline - parser->start + 1));
+
+ cursor = newline + 1;
+ newline = next_newline(cursor, parser->end - cursor);
+
+ size_t length = (size_t) ((newline != NULL ? newline : parser->end) - cursor);
+ if (length > 2 && cursor[0] == '#' && cursor[1] == '!') {
+ const char *engine;
+ if ((engine = pm_strnstr((const char *) cursor, "ruby", length)) != NULL) {
+ found_shebang = true;
+
+ if (newline != NULL) {
+ pm_parser_warn_shebang_carriage_return(parser, cursor, length + 1);
+ parser->encoding_comment_start = newline + 1;
+ }
+
+ if (options != NULL && options->shebang_callback != NULL) {
+ pm_parser_init_shebang(parser, options, engine, length - ((size_t) (engine - (const char *) cursor)));
+ }
+
+ break;
+ }
+ }
+ }
+
+ if (found_shebang) {
+ parser->previous = (pm_token_t) { .type = PM_TOKEN_EOF, .start = cursor, .end = cursor };
+ parser->current = (pm_token_t) { .type = PM_TOKEN_EOF, .start = cursor, .end = cursor };
+ } else {
+ pm_parser_err(parser, 0, 0, PM_ERR_SCRIPT_NOT_FOUND);
+ pm_line_offset_list_clear(&parser->line_offsets);
+ }
+ }
+
+ // The encoding comment can start after any amount of inline whitespace, so
+ // here we'll advance it to the first non-inline-whitespace character so
+ // that it is ready for future comparisons.
+ parser->encoding_comment_start += pm_strspn_inline_whitespace(parser->encoding_comment_start, parser->end - parser->encoding_comment_start);
+}
+
+/**
+ * Allocate and initialize a parser with the given start and end pointers.
+ *
+ * The resulting parser must eventually be freed with `pm_parser_free()`. The
+ * arena is caller-owned and must outlive the parser — `pm_parser_cleanup()`
+ * does not free the arena.
+ */
+pm_parser_t *
+pm_parser_new(pm_arena_t *arena, const uint8_t *source, size_t size, const pm_options_t *options) {
+ pm_parser_t *parser = (pm_parser_t *) xmalloc(sizeof(pm_parser_t));
+ if (parser == NULL) abort();
+
+ pm_parser_init(arena, parser, source, size, options);
+ return parser;
+}
+
+/**
+ * Free any memory associated with the given parser.
+ */
+void
+pm_parser_cleanup(pm_parser_t *parser) {
+ pm_string_cleanup(&parser->filepath);
+ pm_arena_cleanup(&parser->metadata_arena);
+
+ while (parser->current_scope != NULL) {
+ // Normally, popping the scope doesn't free the locals since it is
+ // assumed that ownership has transferred to the AST. However if we have
+ // scopes while we're freeing the parser, it's likely they came from
+ // eval scopes and we need to free them explicitly here.
+ pm_parser_scope_pop(parser);
+ }
+
+ while (parser->lex_modes.index >= PM_LEX_STACK_SIZE) {
+ lex_mode_pop(parser);
+ }
+}
+
+/**
+ * Free both the memory held by the given parser and the parser itself.
+ */
+void
+pm_parser_free(pm_parser_t *parser) {
+ pm_parser_cleanup(parser);
+ xfree_sized(parser, sizeof(pm_parser_t));
+}
+
+/**
+ * Returns true if the given diagnostic ID represents an error that cannot be
+ * fixed by appending more input. These are errors where the existing source
+ * contains definitively invalid syntax (as opposed to merely incomplete input).
+ */
+static bool
+pm_parse_err_is_fatal(pm_diagnostic_id_t diag_id) {
+ switch (diag_id) {
+ case PM_ERR_ARRAY_EXPRESSION_AFTER_STAR:
+ case PM_ERR_BEGIN_UPCASE_BRACE:
+ case PM_ERR_CLASS_VARIABLE_BARE:
+ case PM_ERR_END_UPCASE_BRACE:
+ case PM_ERR_ESCAPE_INVALID_HEXADECIMAL:
+ case PM_ERR_ESCAPE_INVALID_UNICODE_LIST:
+ case PM_ERR_ESCAPE_INVALID_UNICODE_SHORT:
+ case PM_ERR_EXPRESSION_NOT_WRITABLE:
+ case PM_ERR_EXPRESSION_NOT_WRITABLE_SELF:
+ case PM_ERR_FLOAT_PARSE:
+ case PM_ERR_GLOBAL_VARIABLE_BARE:
+ case PM_ERR_HASH_KEY:
+ case PM_ERR_HEREDOC_IDENTIFIER:
+ case PM_ERR_INSTANCE_VARIABLE_BARE:
+ case PM_ERR_INVALID_BLOCK_EXIT:
+ case PM_ERR_INVALID_ENCODING_MAGIC_COMMENT:
+ case PM_ERR_INVALID_FLOAT_EXPONENT:
+ case PM_ERR_INVALID_NUMBER_BINARY:
+ case PM_ERR_INVALID_NUMBER_DECIMAL:
+ case PM_ERR_INVALID_NUMBER_HEXADECIMAL:
+ case PM_ERR_INVALID_NUMBER_OCTAL:
+ case PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING:
+ case PM_ERR_NO_LOCAL_VARIABLE:
+ case PM_ERR_PARAMETER_ORDER:
+ case PM_ERR_STATEMENT_UNDEF:
+ case PM_ERR_VOID_EXPRESSION:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**
+ * Determine whether the source parsed by the given parser could become valid if
+ * more input were appended. This is used by tools like IRB to decide whether to
+ * prompt for continuation or to display an error.
+ *
+ * The parser starts with continuable=true. This function scans all errors to
+ * detect two categories of non-continuable errors:
+ *
+ * 1. Fatal errors: errors like invalid number literals or bare global variables
+ * that indicate definitively invalid syntax. These are only considered fatal
+ * if they occur before EOF (at EOF they could be from truncated input, e.g.
+ * `"\x` is an incomplete hex escape).
+ *
+ * 2. Stray tokens: unexpected_token_ignore and unexpected_token_close_context
+ * errors indicate tokens that don't belong. A stray token is a cascade
+ * effect (and does not prevent continuability) if:
+ *
+ * a. A non-stray, non-fatal error appeared earlier in the error list at a
+ * strictly earlier source position (the stray was caused by a preceding
+ * parse failure, e.g. a truncated heredoc), OR
+ * b. The stray token is at EOF, starts after position 0 (there is valid
+ * code before it), and either is a single byte (likely a truncated
+ * token like `\`) or there are non-stray errors elsewhere.
+ *
+ * Closing delimiters (`)`, `]`, `}`) at EOF are always genuinely stray —
+ * they are complete tokens and cannot become part of a longer valid
+ * construct by appending more input.
+ *
+ * c. The stray token is `=` at the start of a line, which could be the
+ * beginning of `=begin` (an embedded document). The remaining bytes
+ * after `=` may parse as an identifier, so the error is not at EOF,
+ * but the construct is genuinely incomplete.
+ */
+static void
+pm_parse_continuable(pm_parser_t *parser) {
+ // If there are no errors then there is nothing to continue.
+ if (parser->error_list.size == 0) {
+ parser->continuable = false;
+ return;
+ }
+
+ if (!parser->continuable) return;
+
+ size_t source_length = (size_t) (parser->end - parser->start);
+
+ // First pass: check if there are any non-stray, non-fatal errors.
+ bool has_non_stray_error = false;
+ for (pm_diagnostic_t *error = (pm_diagnostic_t *) parser->error_list.head; error != NULL; error = (pm_diagnostic_t *) error->node.next) {
+ if (error->diag_id != PM_ERR_UNEXPECTED_TOKEN_IGNORE && error->diag_id != PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT && !pm_parse_err_is_fatal(error->diag_id)) {
+ has_non_stray_error = true;
+ break;
+ }
+ }
+
+ // Second pass: check each error. We track the minimum source position
+ // among non-stray, non-fatal errors seen so far in list order, which
+ // lets us detect cascade stray tokens.
+ size_t non_stray_min_start = SIZE_MAX;
+
+ for (pm_diagnostic_t *error = (pm_diagnostic_t *) parser->error_list.head; error != NULL; error = (pm_diagnostic_t *) error->node.next) {
+ size_t error_start = (size_t) error->location.start;
+ size_t error_end = error_start + (size_t) error->location.length;
+ bool at_eof = error_end >= source_length;
+
+ // Fatal errors are non-continuable unless they occur at EOF.
+ if (pm_parse_err_is_fatal(error->diag_id) && !at_eof) {
+ parser->continuable = false;
+ return;
+ }
+
+ // Track non-stray, non-fatal error positions in list order.
+ if (error->diag_id != PM_ERR_UNEXPECTED_TOKEN_IGNORE &&
+ error->diag_id != PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT) {
+ if (error_start < non_stray_min_start) non_stray_min_start = error_start;
+ continue;
+ }
+
+ // This is a stray token. Determine if it is a cascade effect
+ // of a preceding error or genuinely stray.
+
+ // Rule (a): a non-stray error was seen earlier in the list at a
+ // strictly earlier position — this stray is a cascade effect.
+ if (non_stray_min_start < error_start) continue;
+
+ // Rule (b): this stray is at EOF with valid code before it.
+ // Single-byte stray tokens at EOF (like `\` for line continuation)
+ // are likely truncated tokens. Multi-byte stray tokens (like the
+ // keyword `end`) need additional evidence that they are cascade
+ // effects (i.e. non-stray errors exist elsewhere).
+ if (at_eof && error_start > 0) {
+ // Exception: closing delimiters at EOF are genuinely stray.
+ if (error->location.length == 1) {
+ const uint8_t *byte = parser->start + error_start;
+ if (*byte == ')' || *byte == ']' || *byte == '}') {
+ parser->continuable = false;
+ return;
+ }
+
+ // Single-byte non-delimiter stray at EOF: cascade.
+ continue;
+ }
+
+ // Multi-byte stray at EOF: cascade only if there are
+ // non-stray errors (evidence of a preceding parse failure).
+ if (has_non_stray_error) continue;
+ }
+
+ // Rule (c): a stray `=` at the start of a line could be the
+ // beginning of an embedded document (`=begin`). The remaining
+ // bytes after `=` parse as an identifier, so the error is not
+ // at EOF, but the construct is genuinely incomplete.
+ if (error->location.length == 1) {
+ const uint8_t *byte = parser->start + error_start;
+ if (*byte == '=' && (error_start == 0 || *(byte - 1) == '\n')) continue;
+ }
+
+ // This stray token is genuinely non-continuable.
+ parser->continuable = false;
+ return;
+ }
+}
+
+/**
+ * Parse the Ruby source associated with the given parser and return the tree.
+ */
+pm_node_t *
+pm_parse(pm_parser_t *parser) {
+ pm_node_t *node = parse_program(parser);
+ pm_parse_continuable(parser);
+ return node;
+}
+
+/**
+ * Parse a stream of Ruby source and return the tree.
+ *
+ * Prism is designed around having the entire source in memory at once, but you
+ * can stream stdin in to Ruby so we need to support a streaming API.
+ */
+pm_node_t *
+pm_parse_stream(pm_parser_t **parser, pm_arena_t *arena, pm_source_t *source, const pm_options_t *options) {
+ bool eof = pm_source_stream_read(source);
+
+ pm_parser_t *tmp = pm_parser_new(arena, pm_source_source(source), pm_source_length(source), options);
+ pm_node_t *node = pm_parse(tmp);
+
+ while (!eof && tmp->error_list.size > 0) {
+ eof = pm_source_stream_read(source);
+
+ pm_parser_free(tmp);
+ pm_arena_cleanup(arena);
+
+ tmp = pm_parser_new(arena, pm_source_source(source), pm_source_length(source), options);
+ node = pm_parse(tmp);
+ }
+
+ *parser = tmp;
+ return node;
+}
+
+#undef PM_CASE_KEYWORD
+#undef PM_CASE_OPERATOR
+#undef PM_CASE_WRITABLE
+#undef PM_STRING_EMPTY
+
+// We optionally support serializing to a binary string. For systems that don't
+// want or need this functionality, it can be turned off with the
+// PRISM_EXCLUDE_SERIALIZATION define.
+#ifndef PRISM_EXCLUDE_SERIALIZATION
+
+static PRISM_INLINE void
+pm_serialize_header(pm_buffer_t *buffer) {
+ pm_buffer_append_string(buffer, "PRISM", 5);
+ pm_buffer_append_byte(buffer, PRISM_VERSION_MAJOR);
+ pm_buffer_append_byte(buffer, PRISM_VERSION_MINOR);
+ pm_buffer_append_byte(buffer, PRISM_VERSION_PATCH);
+ pm_buffer_append_byte(buffer, PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS ? 1 : 0);
+}
+
+/**
+ * Serialize the AST represented by the given node to the given buffer.
+ */
+void
+pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
+ pm_serialize_header(buffer);
+ pm_serialize_content(parser, node, buffer);
+ pm_buffer_append_byte(buffer, '\0');
+}
+
+/**
+ * Parse and serialize the AST represented by the given source to the given
+ * buffer.
+ */
+void
+pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) {
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_arena_t arena = { 0 };
+ pm_parser_t parser;
+ pm_parser_init(&arena, &parser, source, size, &options);
+
+ pm_node_t *node = pm_parse(&parser);
+
+ pm_serialize_header(buffer);
+ pm_serialize_content(&parser, node, buffer);
+ pm_buffer_append_byte(buffer, '\0');
+
+ pm_parser_cleanup(&parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+}
+
+/**
+ * Parse and serialize the AST represented by the source that is read out of the
+ * given stream into to the given buffer.
+ */
+void
+pm_serialize_parse_stream(pm_buffer_t *buffer, pm_source_t *source, const char *data) {
+ pm_arena_t arena = { 0 };
+ pm_parser_t *parser;
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_node_t *node = pm_parse_stream(&parser, &arena, source, &options);
+ pm_serialize_header(buffer);
+ pm_serialize_content(parser, node, buffer);
+ pm_buffer_append_byte(buffer, '\0');
+
+ pm_parser_free(parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+}
+
+/**
+ * Parse and serialize the comments in the given source to the given buffer.
+ */
+void
+pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) {
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_arena_t arena = { 0 };
+ pm_parser_t parser;
+ pm_parser_init(&arena, &parser, source, size, &options);
+
+ pm_parse(&parser);
+ pm_serialize_header(buffer);
+ pm_serialize_encoding(parser.encoding, buffer);
+ pm_buffer_append_varsint(buffer, parser.start_line);
+ pm_serialize_comment_list(&parser.comment_list, buffer);
+
+ pm_parser_cleanup(&parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+}
+
+#endif
diff --git a/prism/prism.h b/prism/prism.h
new file mode 100644
index 0000000000..b342bb32c6
--- /dev/null
+++ b/prism/prism.h
@@ -0,0 +1,130 @@
+/**
+ * @file prism.h
+ *
+ * The main header file for the prism parser.
+ */
+#ifndef PRISM_H
+#define PRISM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "prism/arena.h"
+#include "prism/ast.h"
+#include "prism/buffer.h"
+#include "prism/diagnostic.h"
+#include "prism/json.h"
+#include "prism/node.h"
+#include "prism/options.h"
+#include "prism/parser.h"
+#include "prism/prettyprint.h"
+#include "prism/serialize.h"
+#include "prism/source.h"
+#include "prism/stream.h"
+#include "prism/string_query.h"
+#include "prism/version.h"
+
+/**
+ * @mainpage
+ *
+ * Prism is a parser for the Ruby programming language. It is designed to be
+ * portable, error tolerant, and maintainable. It is written in C99 and has no
+ * dependencies. It is currently being integrated into
+ * [CRuby](https://github.com/ruby/ruby),
+ * [JRuby](https://github.com/jruby/jruby),
+ * [TruffleRuby](https://github.com/truffleruby/truffleruby),
+ * [Sorbet](https://github.com/sorbet/sorbet), and
+ * [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree).
+ *
+ * @section getting-started Getting started
+ *
+ * If you're vendoring this project and compiling it statically then as long as
+ * you have a C99 compiler you will be fine. If you're linking against it as
+ * shared library, then you should compile with `-fvisibility=hidden` and
+ * `-DPRISM_EXPORT_SYMBOLS` to tell prism to make only its public interface
+ * visible.
+ *
+ * @section parsing Parsing
+ *
+ * In order to parse Ruby code, the functions that you are going to want to use
+ * and be aware of are:
+ *
+ * * `pm_arena_new()` - create a new arena to hold all AST-lifetime allocations
+ * * `pm_parser_new()` - allocate and initialize a new parser
+ * * `pm_parse()` - parse and return the root node
+ * * `pm_parser_free()` - free the parser and its internal memory
+ * * `pm_arena_free()` - free all AST-lifetime memory
+ *
+ * Putting all of this together would look something like:
+ *
+ * ```c
+ * void parse(const uint8_t *source, size_t length) {
+ * pm_arena_t *arena = pm_arena_new();
+ * pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
+ *
+ * pm_node_t *root = pm_parse(parser);
+ * printf("PARSED!\n");
+ *
+ * pm_parser_free(parser);
+ * pm_arena_free(arena);
+ * }
+ * ```
+ *
+ * All of the nodes "inherit" from `pm_node_t` by embedding those structures
+ * as their first member. This means you can downcast and upcast any node in the
+ * tree to a `pm_node_t`.
+ *
+ * @section serializing Serializing
+ *
+ * Prism provides the ability to serialize the AST and its related metadata into
+ * a binary format. This format is designed to be portable to different
+ * languages and runtimes so that you only need to make one FFI call in order to
+ * parse Ruby code. The functions that you are going to want to use and be
+ * aware of are:
+ *
+ * * `pm_buffer_new()` - create a new buffer
+ * * `pm_buffer_free()` - free the buffer and its internal memory
+ * * `pm_serialize_parse()` - parse and serialize the AST into a buffer
+ *
+ * Putting all of this together would look something like:
+ *
+ * ```c
+ * void serialize(const uint8_t *source, size_t length) {
+ * pm_buffer_t *buffer = pm_buffer_new();
+ *
+ * pm_serialize_parse(buffer, source, length, NULL);
+ * printf("SERIALIZED!\n");
+ *
+ * pm_buffer_free(buffer);
+ * }
+ * ```
+ *
+ * @section inspecting Inspecting
+ *
+ * Prism provides the ability to inspect the AST by pretty-printing nodes. You
+ * can do this with the `pm_prettyprint()` function, which you would use like:
+ *
+ * ```c
+ * void prettyprint(const uint8_t *source, size_t length) {
+ * pm_arena_t *arena = pm_arena_new();
+ * pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
+ *
+ * pm_node_t *root = pm_parse(parser);
+ * pm_buffer_t *buffer = pm_buffer_new();
+ *
+ * pm_prettyprint(buffer, parser, root);
+ * printf("%*.s\n", (int) pm_buffer_length(buffer), pm_buffer_value(buffer));
+ *
+ * pm_buffer_free(buffer);
+ * pm_parser_free(parser);
+ * pm_arena_free(arena);
+ * }
+ * ```
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/prism/regexp.c b/prism/regexp.c
new file mode 100644
index 0000000000..cc17aa4d09
--- /dev/null
+++ b/prism/regexp.c
@@ -0,0 +1,1717 @@
+#include "prism/internal/regexp.h"
+
+#include "prism/compiler/inline.h"
+#include "prism/compiler/fallthrough.h"
+#include "prism/internal/buffer.h"
+#include "prism/internal/char.h"
+#include "prism/internal/diagnostic.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/memchr.h"
+#include "prism/internal/parser.h"
+#include "prism/internal/stringy.h"
+#include "prism/internal/strncasecmp.h"
+
+#include <assert.h>
+#include <string.h>
+
+/** The maximum depth of nested groups allowed in a regular expression. */
+#define PM_REGEXP_PARSE_DEPTH_MAX 4096
+
+/**
+ * This is the parser that is going to handle parsing regular expressions.
+ */
+typedef struct {
+ /** The parser that is currently being used. */
+ pm_parser_t *parser;
+
+ /** A pointer to the start of the source that we are parsing. */
+ const uint8_t *start;
+
+ /** A pointer to the current position in the source. */
+ const uint8_t *cursor;
+
+ /** A pointer to the end of the source that we are parsing. */
+ const uint8_t *end;
+
+ /** The encoding of the source. */
+ const pm_encoding_t *encoding;
+
+ /** The callback to call when a named capture group is found. */
+ pm_regexp_name_callback_t name_callback;
+
+ /** The data to pass to the name callback. */
+ pm_regexp_name_data_t *name_data;
+
+ /** The start of the regexp node (for error locations). */
+ const uint8_t *node_start;
+
+ /** The end of the regexp node (for error locations). */
+ const uint8_t *node_end;
+
+ /**
+ * The explicit encoding determined by escape sequences. NULL if no
+ * encoding-setting escape has been seen, UTF-8 for `\u` escapes, or the
+ * source encoding for `\x` escapes.
+ */
+ const pm_encoding_t *explicit_encoding;
+
+ /**
+ * Pointer to the first non-POSIX property name (for /n error messages).
+ * POSIX properties (Alnum, Alpha, etc.) work in all encodings.
+ * Script properties (Hiragana, Katakana, etc.) work in /e, /s, /u.
+ * Unicode-only properties (L, Ll, etc.) work only in /u.
+ */
+ const uint8_t *property_name;
+
+ /** Length of the first non-POSIX property name found. */
+ size_t property_name_length;
+
+ /**
+ * Pointer to the first Unicode-only property name (for /e, /s error
+ * messages). NULL if only POSIX or script properties have been seen.
+ */
+ const uint8_t *unicode_property_name;
+
+ /** Length of the first Unicode-only property name found. */
+ size_t unicode_property_name_length;
+
+ /** Buffer of hex escape byte values >= 0x80, separated by 0x00 sentinels. */
+ pm_buffer_t hex_escape_buffer;
+
+ /** Count of non-ASCII literal bytes (not from escapes). */
+ uint32_t non_ascii_literal_count;
+
+ /**
+ * Whether or not the regular expression currently being parsed is in
+ * extended mode, wherein whitespace is ignored and comments are allowed.
+ */
+ bool extended_mode;
+
+ /** Whether the encoding has changed from the default. */
+ bool encoding_changed;
+
+ /** Whether the source content is shared (for named capture callback). */
+ bool shared;
+
+ /** Whether a `\u{...}` escape with value >= 0x80 was seen. */
+ bool has_unicode_escape;
+
+ /** Whether a `\xNN` escape (or `\M-x`, etc.) with value >= 0x80 was seen. */
+ bool has_hex_escape;
+
+ /**
+ * Tracks whether the last encoding-setting escape was `\u` (true) or `\x`
+ * (false). This matters for error messages when both types are mixed.
+ */
+ bool last_escape_was_unicode;
+
+ /** Whether any `\p{...}` or `\P{...}` property escape was found. */
+ bool has_property_escape;
+
+ /** Whether a Unicode-only property escape was found (not POSIX or script). */
+ bool has_unicode_property_escape;
+
+ /** Whether a `\u` escape with invalid range (surrogate or > 0x10FFFF) was seen. */
+ bool invalid_unicode_range;
+
+ /** Whether we are accumulating consecutive hex escape bytes. */
+ bool hex_group_active;
+
+ /** Whether an invalid multibyte character was found during parsing. */
+ bool has_invalid_multibyte;
+} pm_regexp_parser_t;
+
+/**
+ * Append a syntax error to the parser's error list. If the source is shared
+ * (points into the original source), we can point to the exact error location.
+ * Otherwise, we point to the whole regexp node.
+ */
+static PRISM_INLINE void
+pm_regexp_parse_error(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, const char *message) {
+ pm_parser_t *pm = parser->parser;
+ uint32_t loc_start, loc_length;
+
+ if (parser->shared) {
+ loc_start = (uint32_t) (start - pm->start);
+ loc_length = (uint32_t) (end - start);
+ } else {
+ loc_start = (uint32_t) (parser->node_start - pm->start);
+ loc_length = (uint32_t) (parser->node_end - parser->node_start);
+ }
+
+ pm_diagnostic_list_append_format(&pm->metadata_arena, &pm->error_list, loc_start, loc_length, PM_ERR_REGEXP_PARSE_ERROR, message);
+}
+
+/**
+ * Append a formatted diagnostic error with proper shared/non-shared location
+ * handling. This is a macro because we need variadic args for the format string.
+ */
+#define pm_regexp_parse_error_format(parser_, err_start_, err_end_, diag_id, ...) \
+ do { \
+ pm_parser_t *pm__ = (parser_)->parser; \
+ uint32_t loc_start__, loc_length__; \
+ if ((parser_)->shared) { \
+ loc_start__ = (uint32_t) ((err_start_) - pm__->start); \
+ loc_length__ = (uint32_t) ((err_end_) - (err_start_)); \
+ } else { \
+ loc_start__ = (uint32_t) ((parser_)->node_start - pm__->start); \
+ loc_length__ = (uint32_t) ((parser_)->node_end - (parser_)->node_start); \
+ } \
+ pm_diagnostic_list_append_format(&pm__->metadata_arena, &pm__->error_list, loc_start__, loc_length__, diag_id, __VA_ARGS__); \
+ } while (0)
+
+/**
+ * This appends a new string to the list of named captures. This function
+ * assumes the caller has already checked the validity of the name callback.
+ */
+static void
+pm_regexp_parser_named_capture(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end) {
+ pm_string_t string;
+ pm_string_shared_init(&string, start, end);
+ parser->name_callback(parser->parser, &string, parser->shared, parser->name_data);
+ pm_string_cleanup(&string);
+}
+
+/**
+ * Returns true if the next character is the end of the source.
+ */
+static PRISM_INLINE bool
+pm_regexp_char_is_eof(pm_regexp_parser_t *parser) {
+ return parser->cursor >= parser->end;
+}
+
+/**
+ * Optionally accept a char and consume it if it exists.
+ */
+static PRISM_INLINE bool
+pm_regexp_char_accept(pm_regexp_parser_t *parser, uint8_t value) {
+ if (!pm_regexp_char_is_eof(parser) && *parser->cursor == value) {
+ parser->cursor++;
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Expect a character to be present and consume it.
+ */
+static PRISM_INLINE bool
+pm_regexp_char_expect(pm_regexp_parser_t *parser, uint8_t value) {
+ if (!pm_regexp_char_is_eof(parser) && *parser->cursor == value) {
+ parser->cursor++;
+ return true;
+ }
+ return false;
+}
+
+/**
+ * This advances the current token to the next instance of the given character.
+ */
+static bool
+pm_regexp_char_find(pm_regexp_parser_t *parser, uint8_t value) {
+ if (pm_regexp_char_is_eof(parser)) {
+ return false;
+ }
+
+ const uint8_t *end = (const uint8_t *) pm_memchr(parser->cursor, value, (size_t) (parser->end - parser->cursor), parser->encoding_changed, parser->encoding);
+ if (end == NULL) {
+ return false;
+ }
+
+ parser->cursor = end + 1;
+ return true;
+}
+
+/**
+ * Mark a group boundary in the hex escape byte buffer. When consecutive hex
+ * escape bytes >= 0x80 are followed by a non-hex-escape, this appends a 0x00
+ * sentinel to separate the groups for later multibyte validation.
+ */
+static PRISM_INLINE void
+pm_regexp_hex_group_boundary(pm_regexp_parser_t *parser) {
+ if (parser->hex_group_active) {
+ pm_buffer_append_byte(&parser->hex_escape_buffer, 0x00);
+ parser->hex_group_active = false;
+ }
+}
+
+/**
+ * Track a hex escape byte value >= 0x80 for multibyte validation.
+ */
+static PRISM_INLINE void
+pm_regexp_track_hex_escape(pm_regexp_parser_t *parser, uint8_t byte) {
+ if (byte >= 0x80) {
+ pm_buffer_append_byte(&parser->hex_escape_buffer, byte);
+ parser->hex_group_active = true;
+ parser->has_hex_escape = true;
+
+ parser->explicit_encoding = parser->encoding;
+ parser->last_escape_was_unicode = false;
+ } else {
+ pm_regexp_hex_group_boundary(parser);
+ }
+}
+
+/**
+ * Parse a hex digit character and return its value, or -1 if not a hex digit.
+ */
+static PRISM_INLINE int
+pm_regexp_hex_digit_value(uint8_t byte) {
+ if (byte >= '0' && byte <= '9') return byte - '0';
+ if (byte >= 'a' && byte <= 'f') return byte - 'a' + 10;
+ if (byte >= 'A' && byte <= 'F') return byte - 'A' + 10;
+ return -1;
+}
+
+/**
+ * Range quantifiers are a special class of quantifiers that look like
+ *
+ * * {digit}
+ * * {digit,}
+ * * {digit,digit}
+ * * {,digit}
+ *
+ * If there are any spaces in between, then this just becomes a regular
+ * character match expression and we have to backtrack. So when this function
+ * first starts running, we'll create a "save" point and then attempt to parse
+ * the quantifier. If it fails, we'll restore the save point and return.
+ *
+ * To properly track everything, we're going to build a little state machine.
+ * It looks something like the following:
+ *
+ * +-------+ +---------+ ------------+
+ * ---- lbrace ---> | start | ---- digit ---> | minimum | |
+ * +-------+ +---------+ <--- digit -+
+ * | | |
+ * +-------+ | | rbrace
+ * | comma | <----- comma +---- comma -------+ |
+ * +-------+ V V
+ * | +---------+ +---------+
+ * +-- digit --> | maximum | -- rbrace --> || final ||
+ * +---------+ +---------+
+ * | ^
+ * +- digit -+
+ *
+ * Note that by the time we've hit this function, the lbrace has already been
+ * consumed so we're in the start state.
+ */
+static bool
+pm_regexp_parse_range_quantifier(pm_regexp_parser_t *parser) {
+ const uint8_t *savepoint = parser->cursor;
+
+ enum {
+ PM_REGEXP_RANGE_QUANTIFIER_STATE_START,
+ PM_REGEXP_RANGE_QUANTIFIER_STATE_MINIMUM,
+ PM_REGEXP_RANGE_QUANTIFIER_STATE_MAXIMUM,
+ PM_REGEXP_RANGE_QUANTIFIER_STATE_COMMA
+ } state = PM_REGEXP_RANGE_QUANTIFIER_STATE_START;
+
+ while (1) {
+ if (parser->cursor >= parser->end) {
+ parser->cursor = savepoint;
+ return true;
+ }
+
+ switch (state) {
+ case PM_REGEXP_RANGE_QUANTIFIER_STATE_START:
+ switch (*parser->cursor) {
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ parser->cursor++;
+ state = PM_REGEXP_RANGE_QUANTIFIER_STATE_MINIMUM;
+ break;
+ case ',':
+ parser->cursor++;
+ state = PM_REGEXP_RANGE_QUANTIFIER_STATE_COMMA;
+ break;
+ default:
+ parser->cursor = savepoint;
+ return true;
+ }
+ break;
+ case PM_REGEXP_RANGE_QUANTIFIER_STATE_MINIMUM:
+ switch (*parser->cursor) {
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ parser->cursor++;
+ break;
+ case ',':
+ parser->cursor++;
+ state = PM_REGEXP_RANGE_QUANTIFIER_STATE_MAXIMUM;
+ break;
+ case '}':
+ parser->cursor++;
+ return true;
+ default:
+ parser->cursor = savepoint;
+ return true;
+ }
+ break;
+ case PM_REGEXP_RANGE_QUANTIFIER_STATE_COMMA:
+ switch (*parser->cursor) {
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ parser->cursor++;
+ state = PM_REGEXP_RANGE_QUANTIFIER_STATE_MAXIMUM;
+ break;
+ default:
+ parser->cursor = savepoint;
+ return true;
+ }
+ break;
+ case PM_REGEXP_RANGE_QUANTIFIER_STATE_MAXIMUM:
+ switch (*parser->cursor) {
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+ parser->cursor++;
+ break;
+ case '}':
+ parser->cursor++;
+ return true;
+ default:
+ parser->cursor = savepoint;
+ return true;
+ }
+ break;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * quantifier : star-quantifier
+ * | plus-quantifier
+ * | optional-quantifier
+ * | range-quantifier
+ * | <empty>
+ * ;
+ */
+static bool
+pm_regexp_parse_quantifier(pm_regexp_parser_t *parser) {
+ while (!pm_regexp_char_is_eof(parser)) {
+ switch (*parser->cursor) {
+ case '*':
+ case '+':
+ case '?':
+ parser->cursor++;
+ break;
+ case '{':
+ parser->cursor++;
+ if (!pm_regexp_parse_range_quantifier(parser)) return false;
+ break;
+ default:
+ // In this case there is no quantifier.
+ return true;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * match-posix-class : '[' '[' ':' '^'? CHAR+ ':' ']' ']'
+ * ;
+ */
+static bool
+pm_regexp_parse_posix_class(pm_regexp_parser_t *parser) {
+ if (!pm_regexp_char_expect(parser, ':')) {
+ return false;
+ }
+
+ pm_regexp_char_accept(parser, '^');
+
+ return (
+ pm_regexp_char_find(parser, ':') &&
+ pm_regexp_char_expect(parser, ']') &&
+ pm_regexp_char_expect(parser, ']')
+ );
+}
+
+/**
+ * Property escape classification. Onigmo supports three tiers of property
+ * names depending on the encoding:
+ *
+ * - POSIX properties (Alnum, Alpha, ASCII, Blank, Cntrl, Digit, Graph, Lower,
+ * Print, Punct, Space, Upper, XDigit, Word): valid in all encodings.
+ * - Script properties (Hiragana, Katakana, Han, Latin, Greek, Cyrillic): valid
+ * in EUC-JP (/e), Windows-31J (/s), and UTF-8 (/u), but not ASCII-8BIT (/n).
+ * - Unicode-only properties (general categories like L, Ll, Lu, etc., plus
+ * Any, Assigned): valid only in UTF-8 (/u).
+ */
+typedef enum {
+ PM_REGEXP_PROPERTY_POSIX,
+ PM_REGEXP_PROPERTY_SCRIPT,
+ PM_REGEXP_PROPERTY_UNICODE
+} pm_regexp_property_type_t;
+
+/**
+ * Classify a property name. The name may start with '^' for negation, which
+ * is skipped before matching.
+ */
+static pm_regexp_property_type_t
+pm_regexp_classify_property(const uint8_t *name, size_t length) {
+ // Skip leading '^' for negated properties like \p{^Hiragana}.
+ if (length > 0 && name[0] == '^') {
+ name++;
+ length--;
+ }
+
+#define PM_REGEXP_CASECMP(str_) (pm_strncasecmp(name, (const uint8_t *) (str_), length) == 0)
+
+ switch (length) {
+ case 3:
+ if (PM_REGEXP_CASECMP("Han")) return PM_REGEXP_PROPERTY_SCRIPT;
+ break;
+ case 4:
+ if (PM_REGEXP_CASECMP("Word")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 5:
+ /* Most properties are length 5, so dispatch on first character. */
+ switch (name[0] | 0x20) {
+ case 'a':
+ if (PM_REGEXP_CASECMP("Alnum")) return PM_REGEXP_PROPERTY_POSIX;
+ if (PM_REGEXP_CASECMP("Alpha")) return PM_REGEXP_PROPERTY_POSIX;
+ if (PM_REGEXP_CASECMP("ASCII")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 'b':
+ if (PM_REGEXP_CASECMP("Blank")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 'c':
+ if (PM_REGEXP_CASECMP("Cntrl")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 'd':
+ if (PM_REGEXP_CASECMP("Digit")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 'g':
+ if (PM_REGEXP_CASECMP("Graph")) return PM_REGEXP_PROPERTY_POSIX;
+ if (PM_REGEXP_CASECMP("Greek")) return PM_REGEXP_PROPERTY_SCRIPT;
+ break;
+ case 'l':
+ if (PM_REGEXP_CASECMP("Lower")) return PM_REGEXP_PROPERTY_POSIX;
+ if (PM_REGEXP_CASECMP("Latin")) return PM_REGEXP_PROPERTY_SCRIPT;
+ break;
+ case 'p':
+ if (PM_REGEXP_CASECMP("Print")) return PM_REGEXP_PROPERTY_POSIX;
+ if (PM_REGEXP_CASECMP("Punct")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 's':
+ if (PM_REGEXP_CASECMP("Space")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 'u':
+ if (PM_REGEXP_CASECMP("Upper")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ }
+ break;
+ case 6:
+ if (PM_REGEXP_CASECMP("XDigit")) return PM_REGEXP_PROPERTY_POSIX;
+ break;
+ case 8:
+ if (PM_REGEXP_CASECMP("Hiragana")) return PM_REGEXP_PROPERTY_SCRIPT;
+ if (PM_REGEXP_CASECMP("Katakana")) return PM_REGEXP_PROPERTY_SCRIPT;
+ if (PM_REGEXP_CASECMP("Cyrillic")) return PM_REGEXP_PROPERTY_SCRIPT;
+ break;
+ }
+
+#undef PM_REGEXP_CASECMP
+
+ // Everything else is Unicode-only (general categories, other scripts, etc.).
+ return PM_REGEXP_PROPERTY_UNICODE;
+}
+
+/**
+ * Check for and skip a `\p{...}` or `\P{...}` Unicode property escape. The
+ * cursor should be pointing at 'p' or 'P' when this is called. If a property
+ * escape is found, record it on the regexp parser and advance past the closing
+ * '}'.
+ *
+ * Properties are classified into three tiers (POSIX, script, Unicode-only) to
+ * determine which encoding modifiers they are valid with.
+ */
+static bool
+pm_regexp_parse_property_escape(pm_regexp_parser_t *parser) {
+ assert(*parser->cursor == 'p' || *parser->cursor == 'P');
+
+ if (parser->cursor + 1 < parser->end && parser->cursor[1] == '{') {
+ const uint8_t *name_start = parser->cursor + 2;
+ const uint8_t *search = name_start;
+
+ while (search < parser->end && *search != '}') search++;
+
+ if (search < parser->end) {
+ size_t name_length = (size_t) (search - name_start);
+ parser->has_property_escape = true;
+
+ pm_regexp_property_type_t type = pm_regexp_classify_property(name_start, name_length);
+
+ // Track the first non-POSIX property name (for /n error messages).
+ if (type >= PM_REGEXP_PROPERTY_SCRIPT && parser->property_name == NULL) {
+ parser->property_name = name_start;
+ parser->property_name_length = name_length;
+ }
+
+ // Track the first Unicode-only property name (for /e, /s error messages).
+ if (type == PM_REGEXP_PROPERTY_UNICODE) {
+ parser->has_unicode_property_escape = true;
+ if (parser->unicode_property_name == NULL) {
+ parser->unicode_property_name = name_start;
+ parser->unicode_property_name_length = name_length;
+ }
+ }
+
+ parser->cursor = search + 1; // skip past '}'
+ return true;
+ }
+ }
+
+ // Not a property escape, just skip the single character after '\'.
+ parser->cursor++;
+ return false;
+}
+
+/**
+ * Validate and skip a \u escape sequence in a regular expression. The cursor
+ * should be pointing at the character after 'u' when this is called. This
+ * handles both the \u{NNNN MMMM} and \uNNNN forms. Also tracks encoding
+ * state for validation.
+ */
+static void
+pm_regexp_parse_unicode_escape(pm_regexp_parser_t *parser) {
+ const uint8_t *escape_start = parser->cursor - 2; // points to '\'
+
+ if (pm_regexp_char_is_eof(parser)) {
+ pm_regexp_parse_error(parser, escape_start, parser->cursor, "invalid Unicode escape");
+ return;
+ }
+
+ if (*parser->cursor == '{') {
+ parser->cursor++; // skip '{'
+
+ // Skip leading whitespace.
+ while (!pm_regexp_char_is_eof(parser) && pm_char_is_whitespace(*parser->cursor)) {
+ parser->cursor++;
+ }
+
+ bool has_codepoint = false;
+
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != '}') {
+ // Parse the hex digits to compute the codepoint value.
+ uint32_t value = 0;
+ size_t hex_count = 0;
+
+ int digit;
+ while (!pm_regexp_char_is_eof(parser) && (digit = pm_regexp_hex_digit_value(*parser->cursor)) >= 0) {
+ value = (value << 4) | (uint32_t) digit;
+ hex_count++;
+ parser->cursor++;
+ }
+
+ if (hex_count == 0) {
+ // Skip to '}' or end of regexp to find the full extent.
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != '}') {
+ parser->cursor++;
+ }
+
+ const uint8_t *escape_end = parser->cursor;
+ if (!pm_regexp_char_is_eof(parser)) {
+ escape_end++;
+ parser->cursor++; // skip '}'
+ }
+
+ pm_regexp_parse_error_format(parser, escape_start, escape_end, PM_ERR_ESCAPE_INVALID_UNICODE_LIST, (int) (escape_end - escape_start), (const char *) escape_start);
+ return;
+ }
+
+ if (hex_count > 6) {
+ pm_regexp_parse_error(parser, escape_start, parser->cursor, "invalid Unicode range");
+ }
+
+ // Track encoding state for this codepoint.
+ if (value >= 0x80) {
+ parser->has_unicode_escape = true;
+ parser->explicit_encoding = PM_ENCODING_UTF_8_ENTRY;
+ parser->last_escape_was_unicode = true;
+ pm_regexp_hex_group_boundary(parser);
+ }
+
+ // Check for invalid Unicode range (surrogates or > 0x10FFFF).
+ if (value > 0x10FFFF || (value >= 0xD800 && value <= 0xDFFF)) {
+ parser->invalid_unicode_range = true;
+ }
+
+ has_codepoint = true;
+
+ // Skip whitespace between codepoints.
+ while (!pm_regexp_char_is_eof(parser) && pm_char_is_whitespace(*parser->cursor)) {
+ parser->cursor++;
+ }
+ }
+
+ if (pm_regexp_char_is_eof(parser)) {
+ pm_regexp_parse_error(parser, escape_start, parser->cursor, "unterminated Unicode escape");
+ } else {
+ if (!has_codepoint) {
+ pm_regexp_parse_error_format(parser, escape_start, parser->cursor + 1, PM_ERR_ESCAPE_INVALID_UNICODE_LIST, (int) (parser->cursor + 1 - escape_start), (const char *) escape_start);
+ }
+ parser->cursor++; // skip '}'
+ }
+ } else {
+ // \uNNNN form — need exactly 4 hex digits.
+ uint32_t value = 0;
+ size_t hex_count = 0;
+
+ int digit;
+ while (hex_count < 4 && !pm_regexp_char_is_eof(parser) && (digit = pm_regexp_hex_digit_value(*parser->cursor)) >= 0) {
+ value = (value << 4) | (uint32_t) digit;
+ hex_count++;
+ parser->cursor++;
+ }
+
+ if (hex_count < 4) {
+ pm_regexp_parse_error(parser, escape_start, parser->cursor, "invalid Unicode escape");
+ } else if (value >= 0x80) {
+ parser->has_unicode_escape = true;
+ parser->explicit_encoding = PM_ENCODING_UTF_8_ENTRY;
+ parser->last_escape_was_unicode = true;
+ pm_regexp_hex_group_boundary(parser);
+ }
+
+ // Check for invalid Unicode range.
+ if (hex_count == 4 && (value > 0x10FFFF || (value >= 0xD800 && value <= 0xDFFF))) {
+ parser->invalid_unicode_range = true;
+ }
+ }
+}
+
+// Forward declaration because character sets can be nested.
+static bool
+pm_regexp_parse_lbracket(pm_regexp_parser_t *parser, uint16_t depth);
+
+/**
+ * Parse a \x escape and return the byte value. The cursor should be pointing
+ * at the character after 'x'. Returns -1 if no hex digits follow.
+ */
+static int
+pm_regexp_parse_hex_escape(pm_regexp_parser_t *parser) {
+ int value = -1;
+
+ if (!pm_regexp_char_is_eof(parser)) {
+ int digit = pm_regexp_hex_digit_value(*parser->cursor);
+ if (digit >= 0) {
+ value = digit;
+ parser->cursor++;
+
+ if (!pm_regexp_char_is_eof(parser)) {
+ digit = pm_regexp_hex_digit_value(*parser->cursor);
+ if (digit >= 0) {
+ value = (value << 4) | digit;
+ parser->cursor++;
+ }
+ }
+ }
+ }
+
+ if (value >= 0) {
+ pm_regexp_track_hex_escape(parser, (uint8_t) value);
+ }
+
+ return value;
+}
+
+/**
+ * Parse a backslash escape sequence in a regexp, handling \u (unicode),
+ * \p/\P (property), \x (hex), and other single-character escapes. Also
+ * tracks encoding state for \M-x and \C-\M-x escapes.
+ */
+static void
+pm_regexp_parse_backslash_escape(pm_regexp_parser_t *parser) {
+ if (pm_regexp_char_is_eof(parser)) return;
+
+ switch (*parser->cursor) {
+ case 'u':
+ parser->cursor++; // skip 'u'
+ pm_regexp_parse_unicode_escape(parser);
+ break;
+ case 'p':
+ case 'P':
+ pm_regexp_parse_property_escape(parser);
+ break;
+ case 'x':
+ parser->cursor++; // skip 'x'
+ pm_regexp_parse_hex_escape(parser);
+ break;
+ case 'M':
+ // \M-x produces (x | 0x80), always >= 0x80
+ if (parser->cursor + 2 < parser->end && parser->cursor[1] == '-') {
+ parser->cursor += 2; // skip 'M-'
+ if (!pm_regexp_char_is_eof(parser)) {
+ if (*parser->cursor == '\\') {
+ parser->cursor++;
+ // \M-\C-x or \M-\cx — the resulting byte is always >= 0x80
+ // We just need to track it as a hex escape >= 0x80.
+ pm_regexp_parse_backslash_escape(parser);
+ } else {
+ parser->cursor++;
+ }
+ // \M-x always produces a byte >= 0x80
+ pm_regexp_track_hex_escape(parser, 0x80);
+ }
+ } else {
+ parser->cursor++;
+ }
+ break;
+ case 'C':
+ // \C-x produces (x & 0x1F)
+ if (parser->cursor + 2 < parser->end && parser->cursor[1] == '-') {
+ parser->cursor += 2; // skip 'C-'
+ if (!pm_regexp_char_is_eof(parser)) {
+ if (*parser->cursor == '\\') {
+ parser->cursor++;
+ pm_regexp_parse_backslash_escape(parser);
+ } else {
+ parser->cursor++;
+ }
+ }
+ } else {
+ parser->cursor++;
+ }
+ break;
+ case 'c':
+ // \cx produces (x & 0x1F)
+ parser->cursor++; // skip 'c'
+ if (!pm_regexp_char_is_eof(parser)) {
+ if (*parser->cursor == '\\') {
+ parser->cursor++;
+ pm_regexp_parse_backslash_escape(parser);
+ } else {
+ parser->cursor++;
+ }
+ }
+ break;
+ default:
+ pm_regexp_hex_group_boundary(parser);
+ parser->cursor++;
+ break;
+ }
+}
+
+/**
+ * Check if a byte at the current position is a non-ASCII byte in a multibyte
+ * encoding that produces an invalid character. If so, emit an error at the
+ * byte location immediately.
+ */
+static void
+pm_regexp_parse_invalid_multibyte(pm_regexp_parser_t *parser, const uint8_t *cursor) {
+ uint8_t byte = *cursor;
+ if (byte >= 0x80 && parser->encoding_changed && parser->encoding->multibyte) {
+ size_t width = parser->encoding->char_width(cursor, (ptrdiff_t) (parser->end - cursor));
+ if (width > 1) {
+ parser->cursor += width - 1;
+ } else if (width == 0) {
+ parser->has_invalid_multibyte = true;
+ pm_regexp_parse_error_format(parser, cursor, cursor + 1, PM_ERR_INVALID_MULTIBYTE_CHAR, parser->encoding->name);
+ }
+ }
+}
+
+/**
+ * match-char-set : '[' '^'? (match-range | match-char)* ']'
+ * ;
+ */
+static bool
+pm_regexp_parse_character_set(pm_regexp_parser_t *parser, uint16_t depth) {
+ pm_regexp_char_accept(parser, '^');
+
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != ']') {
+ switch (*parser->cursor++) {
+ case '[':
+ pm_regexp_parse_lbracket(parser, (uint16_t) (depth + 1));
+ break;
+ case '\\':
+ pm_regexp_parse_backslash_escape(parser);
+ break;
+ default:
+ // We've already advanced the cursor by one byte. If the byte
+ // was >= 0x80 in a multibyte encoding, we may need to consume
+ // additional continuation bytes and validate the character.
+ if (*(parser->cursor - 1) >= 0x80) {
+ parser->non_ascii_literal_count++;
+ }
+ pm_regexp_parse_invalid_multibyte(parser, parser->cursor - 1);
+ break;
+ }
+ }
+
+ return pm_regexp_char_expect(parser, ']');
+}
+
+/**
+ * A left bracket can either mean a POSIX class or a character set.
+ */
+static bool
+pm_regexp_parse_lbracket(pm_regexp_parser_t *parser, uint16_t depth) {
+ if (depth >= PM_REGEXP_PARSE_DEPTH_MAX) {
+ pm_regexp_parse_error(parser, parser->start, parser->end, "parse depth limit over");
+ return false;
+ }
+
+ if ((parser->cursor < parser->end) && parser->cursor[0] == ']') {
+ parser->cursor++;
+ pm_regexp_parse_error(parser, parser->cursor - 1, parser->cursor, "empty char-class");
+ return true;
+ }
+
+ const uint8_t *reset = parser->cursor;
+
+ if ((parser->cursor + 2 < parser->end) && parser->cursor[0] == '[' && parser->cursor[1] == ':') {
+ parser->cursor++;
+ if (pm_regexp_parse_posix_class(parser)) return true;
+
+ parser->cursor = reset;
+ }
+
+ return pm_regexp_parse_character_set(parser, depth);
+}
+
+// Forward declaration here since parsing groups needs to go back up the grammar
+// to parse expressions within them.
+static bool
+pm_regexp_parse_expression(pm_regexp_parser_t *parser, uint16_t depth);
+
+/**
+ * These are the states of the options that are configurable on the regular
+ * expression (or from within a group).
+ */
+typedef enum {
+ PM_REGEXP_OPTION_STATE_INVALID,
+ PM_REGEXP_OPTION_STATE_TOGGLEABLE,
+ PM_REGEXP_OPTION_STATE_ADDABLE,
+ PM_REGEXP_OPTION_STATE_ADDED,
+ PM_REGEXP_OPTION_STATE_REMOVED
+} pm_regexp_option_state_t;
+
+// These are the options that are configurable on the regular expression (or
+// from within a group).
+
+/** The minimum character value for a regexp option slot. */
+#define PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM 'a'
+
+/** The maximum character value for a regexp option slot. */
+#define PRISM_REGEXP_OPTION_STATE_SLOT_MAXIMUM 'x'
+
+/** The number of regexp option slots. */
+#define PRISM_REGEXP_OPTION_STATE_SLOTS (PRISM_REGEXP_OPTION_STATE_SLOT_MAXIMUM - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM + 1)
+
+/**
+ * This is the set of options that are configurable on the regular expression.
+ */
+typedef struct {
+ /** The current state of each option. */
+ uint8_t values[PRISM_REGEXP_OPTION_STATE_SLOTS];
+} pm_regexp_options_t;
+
+/**
+ * Initialize a new set of options to their default values.
+ */
+static void
+pm_regexp_options_init(pm_regexp_options_t *options) {
+ memset(options, PM_REGEXP_OPTION_STATE_INVALID, sizeof(uint8_t) * PRISM_REGEXP_OPTION_STATE_SLOTS);
+ options->values['i' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_TOGGLEABLE;
+ options->values['m' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_TOGGLEABLE;
+ options->values['x' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_TOGGLEABLE;
+ options->values['d' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_ADDABLE;
+ options->values['a' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_ADDABLE;
+ options->values['u' - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM] = PM_REGEXP_OPTION_STATE_ADDABLE;
+}
+
+/**
+ * Attempt to add the given option to the set of options. Returns true if it was
+ * added, false if it was already present.
+ */
+static bool
+pm_regexp_options_add(pm_regexp_options_t *options, uint8_t key) {
+ if (key >= PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM && key <= PRISM_REGEXP_OPTION_STATE_SLOT_MAXIMUM) {
+ key = (uint8_t) (key - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM);
+
+ switch (options->values[key]) {
+ case PM_REGEXP_OPTION_STATE_INVALID:
+ case PM_REGEXP_OPTION_STATE_REMOVED:
+ return false;
+ case PM_REGEXP_OPTION_STATE_TOGGLEABLE:
+ case PM_REGEXP_OPTION_STATE_ADDABLE:
+ options->values[key] = PM_REGEXP_OPTION_STATE_ADDED;
+ return true;
+ case PM_REGEXP_OPTION_STATE_ADDED:
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Attempt to remove the given option from the set of options. Returns true if
+ * it was removed, false if it was already absent.
+ */
+static bool
+pm_regexp_options_remove(pm_regexp_options_t *options, uint8_t key) {
+ if (key >= PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM && key <= PRISM_REGEXP_OPTION_STATE_SLOT_MAXIMUM) {
+ key = (uint8_t) (key - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM);
+
+ switch (options->values[key]) {
+ case PM_REGEXP_OPTION_STATE_INVALID:
+ case PM_REGEXP_OPTION_STATE_ADDABLE:
+ return false;
+ case PM_REGEXP_OPTION_STATE_TOGGLEABLE:
+ case PM_REGEXP_OPTION_STATE_ADDED:
+ case PM_REGEXP_OPTION_STATE_REMOVED:
+ options->values[key] = PM_REGEXP_OPTION_STATE_REMOVED;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * True if the given key is set in the options.
+ */
+static uint8_t
+pm_regexp_options_state(pm_regexp_options_t *options, uint8_t key) {
+ if (key >= PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM && key <= PRISM_REGEXP_OPTION_STATE_SLOT_MAXIMUM) {
+ key = (uint8_t) (key - PRISM_REGEXP_OPTION_STATE_SLOT_MINIMUM);
+ return options->values[key];
+ }
+
+ return false;
+}
+
+/**
+ * Groups can have quite a few different patterns for syntax. They basically
+ * just wrap a set of expressions, but they can potentially have options after a
+ * question mark. If there _isn't_ a question mark, then it's just a set of
+ * expressions. If there _is_, then here are the options:
+ *
+ * * (?#...) - inline comments
+ * * (?:subexp) - non-capturing group
+ * * (?=subexp) - positive lookahead
+ * * (?!subexp) - negative lookahead
+ * * (?>subexp) - atomic group
+ * * (?~subexp) - absence operator
+ * * (?<=subexp) - positive lookbehind
+ * * (?<!subexp) - negative lookbehind
+ * * (?<name>subexp) - named capturing group
+ * * (?'name'subexp) - named capturing group
+ * * (?(cond)yes-subexp) - conditional expression
+ * * (?(cond)yes-subexp|no-subexp) - conditional expression
+ * * (?imxdau-imx) - turn on and off configuration
+ * * (?imxdau-imx:subexp) - turn on and off configuration for an expression
+ */
+static bool
+pm_regexp_parse_group(pm_regexp_parser_t *parser, uint16_t depth) {
+ const uint8_t *group_start = parser->cursor;
+
+ pm_regexp_options_t options;
+ pm_regexp_options_init(&options);
+
+ // First, parse any options for the group.
+ if (pm_regexp_char_accept(parser, '?')) {
+ if (pm_regexp_char_is_eof(parser)) {
+ pm_regexp_parse_error(parser, group_start, parser->cursor, "end pattern in group");
+ return false;
+ }
+
+ switch (*parser->cursor) {
+ case '#': { // inline comments
+ parser->cursor++;
+ if (pm_regexp_char_is_eof(parser)) {
+ pm_regexp_parse_error(parser, group_start, parser->cursor, "end pattern in group");
+ return false;
+ }
+
+ if (parser->encoding_changed && parser->encoding->multibyte) {
+ bool escaped = false;
+
+ // Here we're going to take a slow path and iterate through
+ // each multibyte character to find the close paren. We do
+ // this because \ can be a trailing byte in some encodings.
+ while (parser->cursor < parser->end) {
+ if (!escaped && *parser->cursor == ')') {
+ parser->cursor++;
+ return true;
+ }
+
+ size_t width = parser->encoding->char_width(parser->cursor, (ptrdiff_t) (parser->end - parser->cursor));
+ if (width == 0) {
+ if (*parser->cursor >= 0x80) {
+ parser->has_invalid_multibyte = true;
+ pm_regexp_parse_error_format(parser, parser->cursor, parser->cursor + 1, PM_ERR_INVALID_MULTIBYTE_CHAR, parser->encoding->name);
+ parser->cursor++;
+ continue;
+ }
+ return false;
+ }
+
+ escaped = (width == 1) && (*parser->cursor == '\\');
+ parser->cursor += width;
+ }
+
+ return false;
+ } else {
+ // Here we can take the fast path and use memchr to find the
+ // next ) because we are safe checking backward for \ since
+ // it cannot be a trailing character.
+ bool found = pm_regexp_char_find(parser, ')');
+
+ while (found && (parser->start <= parser->cursor - 2) && (*(parser->cursor - 2) == '\\')) {
+ found = pm_regexp_char_find(parser, ')');
+ }
+
+ return found;
+ }
+ }
+ case ':': // non-capturing group
+ case '=': // positive lookahead
+ case '!': // negative lookahead
+ case '>': // atomic group
+ case '~': // absence operator
+ parser->cursor++;
+ break;
+ case '<':
+ parser->cursor++;
+ if (pm_regexp_char_is_eof(parser)) {
+ pm_regexp_parse_error(parser, group_start, parser->cursor, "end pattern with unmatched parenthesis");
+ return false;
+ }
+
+ switch (*parser->cursor) {
+ case '=': // positive lookbehind
+ case '!': // negative lookbehind
+ parser->cursor++;
+ break;
+ default: { // named capture group
+ const uint8_t *start = parser->cursor;
+ if (!pm_regexp_char_find(parser, '>')) {
+ return false;
+ }
+
+ if (parser->cursor - start == 1) {
+ pm_regexp_parse_error(parser, start, parser->cursor, "group name is empty");
+ }
+
+ if (parser->name_callback != NULL) {
+ pm_regexp_parser_named_capture(parser, start, parser->cursor - 1);
+ }
+
+ break;
+ }
+ }
+ break;
+ case '\'': { // named capture group
+ const uint8_t *start = ++parser->cursor;
+ if (!pm_regexp_char_find(parser, '\'')) {
+ return false;
+ }
+
+ if (parser->name_callback != NULL) {
+ pm_regexp_parser_named_capture(parser, start, parser->cursor - 1);
+ }
+
+ break;
+ }
+ case '(': // conditional expression
+ if (!pm_regexp_char_find(parser, ')')) {
+ return false;
+ }
+ break;
+ case 'i': case 'm': case 'x': case 'd': case 'a': case 'u': // options
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != '-' && *parser->cursor != ':' && *parser->cursor != ')') {
+ if (!pm_regexp_options_add(&options, *parser->cursor)) {
+ return false;
+ }
+ parser->cursor++;
+ }
+
+ if (pm_regexp_char_is_eof(parser)) {
+ return false;
+ }
+
+ // If we are at the end of the group of options and there is no
+ // subexpression, then we are going to be setting the options
+ // for the parent group. In this case we are safe to return now.
+ if (*parser->cursor == ')') {
+ if (pm_regexp_options_state(&options, 'x') == PM_REGEXP_OPTION_STATE_ADDED) {
+ parser->extended_mode = true;
+ }
+
+ parser->cursor++;
+ return true;
+ }
+
+ // If we hit a -, then we're done parsing options.
+ if (*parser->cursor != '-') break;
+
+ PRISM_FALLTHROUGH
+ case '-':
+ parser->cursor++;
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != ':' && *parser->cursor != ')') {
+ if (!pm_regexp_options_remove(&options, *parser->cursor)) {
+ return false;
+ }
+ parser->cursor++;
+ }
+
+ if (pm_regexp_char_is_eof(parser)) {
+ return false;
+ }
+
+ // If we are at the end of the group of options and there is no
+ // subexpression, then we are going to be setting the options
+ // for the parent group. In this case we are safe to return now.
+ if (*parser->cursor == ')') {
+ switch (pm_regexp_options_state(&options, 'x')) {
+ case PM_REGEXP_OPTION_STATE_ADDED:
+ parser->extended_mode = true;
+ break;
+ case PM_REGEXP_OPTION_STATE_REMOVED:
+ parser->extended_mode = false;
+ break;
+ }
+
+ parser->cursor++;
+ return true;
+ }
+
+ break;
+ default:
+ parser->cursor++;
+ pm_regexp_parse_error(parser, parser->cursor - 1, parser->cursor, "undefined group option");
+ break;
+ }
+ }
+
+ bool extended_mode = parser->extended_mode;
+ switch (pm_regexp_options_state(&options, 'x')) {
+ case PM_REGEXP_OPTION_STATE_ADDED:
+ parser->extended_mode = true;
+ break;
+ case PM_REGEXP_OPTION_STATE_REMOVED:
+ parser->extended_mode = false;
+ break;
+ }
+
+ // Now, parse the expressions within this group.
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != ')') {
+ if (!pm_regexp_parse_expression(parser, (uint16_t) (depth + 1))) {
+ parser->extended_mode = extended_mode;
+ return false;
+ }
+ pm_regexp_char_accept(parser, '|');
+ }
+
+ // Finally, make sure we have a closing parenthesis.
+ parser->extended_mode = extended_mode;
+ if (pm_regexp_char_expect(parser, ')')) return true;
+
+ pm_regexp_parse_error(parser, group_start, parser->cursor, "end pattern with unmatched parenthesis");
+ return false;
+}
+
+/**
+ * item : anchor
+ * | match-posix-class
+ * | match-char-set
+ * | match-char-class
+ * | match-char-prop
+ * | match-char
+ * | match-any
+ * | group
+ * | quantified
+ * ;
+ */
+static bool
+pm_regexp_parse_item(pm_regexp_parser_t *parser, uint16_t depth) {
+ switch (*parser->cursor) {
+ case '^':
+ case '$':
+ parser->cursor++;
+ return pm_regexp_parse_quantifier(parser);
+ case '\\':
+ parser->cursor++;
+ pm_regexp_parse_backslash_escape(parser);
+ return pm_regexp_parse_quantifier(parser);
+ case '(':
+ parser->cursor++;
+ return pm_regexp_parse_group(parser, depth) && pm_regexp_parse_quantifier(parser);
+ case '[':
+ parser->cursor++;
+ return pm_regexp_parse_lbracket(parser, depth) && pm_regexp_parse_quantifier(parser);
+ case '*':
+ case '?':
+ case '+':
+ parser->cursor++;
+ pm_regexp_parse_error(parser, parser->cursor - 1, parser->cursor, "target of repeat operator is not specified");
+ return true;
+ case ')':
+ parser->cursor++;
+ pm_regexp_parse_error(parser, parser->cursor - 1, parser->cursor, "unmatched close parenthesis");
+ return true;
+ case '#':
+ if (parser->extended_mode) {
+ if (!pm_regexp_char_find(parser, '\n')) parser->cursor = parser->end;
+ return true;
+ }
+ PRISM_FALLTHROUGH
+ default: {
+ size_t width;
+ if (!parser->encoding_changed) {
+ width = pm_encoding_utf_8_char_width(parser->cursor, (ptrdiff_t) (parser->end - parser->cursor));
+ } else {
+ width = parser->encoding->char_width(parser->cursor, (ptrdiff_t) (parser->end - parser->cursor));
+ }
+
+ if (width == 0) {
+ if (*parser->cursor >= 0x80 && parser->encoding_changed) {
+ if (parser->encoding->multibyte) {
+ // Invalid multibyte character in a multibyte encoding.
+ // Emit the error at the byte location immediately.
+ parser->has_invalid_multibyte = true;
+ pm_regexp_parse_error_format(parser, parser->cursor, parser->cursor + 1, PM_ERR_INVALID_MULTIBYTE_CHAR, parser->encoding->name);
+ } else {
+ // Non-ASCII byte in a single-byte encoding (e.g.,
+ // US-ASCII). Count it for later error reporting.
+ parser->non_ascii_literal_count++;
+ }
+ parser->cursor++;
+ return pm_regexp_parse_quantifier(parser);
+ }
+ return false;
+ }
+
+ // Count non-ASCII literal bytes.
+ for (size_t i = 0; i < width; i++) {
+ if (parser->cursor[i] >= 0x80) parser->non_ascii_literal_count++;
+ }
+
+ parser->cursor += width;
+ return pm_regexp_parse_quantifier(parser);
+ }
+ }
+}
+
+/**
+ * expression : item+
+ * ;
+ */
+static bool
+pm_regexp_parse_expression(pm_regexp_parser_t *parser, uint16_t depth) {
+ if (depth >= PM_REGEXP_PARSE_DEPTH_MAX) {
+ pm_regexp_parse_error(parser, parser->start, parser->end, "parse depth limit over");
+ return false;
+ }
+
+ if (!pm_regexp_parse_item(parser, depth)) {
+ return false;
+ }
+
+ while (!pm_regexp_char_is_eof(parser) && *parser->cursor != ')' && *parser->cursor != '|') {
+ if (!pm_regexp_parse_item(parser, depth)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * pattern : EOF
+ * | expression EOF
+ * | expression '|' pattern
+ * ;
+ */
+static bool
+pm_regexp_parse_pattern(pm_regexp_parser_t *parser) {
+ do {
+ if (pm_regexp_char_is_eof(parser)) return true;
+ if (!pm_regexp_parse_expression(parser, 0)) return false;
+ } while (pm_regexp_char_accept(parser, '|'));
+
+ return pm_regexp_char_is_eof(parser);
+}
+
+// ---------------------------------------------------------------------------
+// Encoding validation
+// ---------------------------------------------------------------------------
+
+/**
+ * Validate that groups of hex escape bytes in the buffer form valid multibyte
+ * characters in the given encoding. Groups are separated by 0x00 sentinels.
+ */
+static bool
+pm_regexp_validate_hex_escapes(const pm_encoding_t *encoding, const pm_buffer_t *buffer) {
+ const uint8_t *data = (const uint8_t *) pm_buffer_value(buffer);
+ size_t len = pm_buffer_length(buffer);
+ size_t i = 0;
+
+ while (i < len) {
+ size_t group_start = i;
+ while (i < len && data[i] != 0x00) i++;
+
+ for (size_t j = group_start; j < i; ) {
+ size_t width = encoding->char_width(data + j, (ptrdiff_t) (i - j));
+ if (width == 0) return false;
+ j += width;
+ }
+
+ if (i < len) i++; // skip sentinel
+ }
+
+ return true;
+}
+
+/**
+ * Format regexp source content for use in error messages, hex-escaping
+ * non-ASCII bytes.
+ */
+static void
+pm_regexp_format_for_error(pm_buffer_t *buffer, const pm_encoding_t *encoding, const uint8_t *source, size_t length) {
+ size_t index = 0;
+
+ if (encoding == PM_ENCODING_UTF_8_ENTRY) {
+ pm_buffer_append_string(buffer, (const char *) source, length);
+ return;
+ }
+
+ while (index < length) {
+ if (source[index] < 0x80) {
+ pm_buffer_append_byte(buffer, source[index]);
+ index++;
+ } else if (encoding->multibyte) {
+ size_t width = encoding->char_width(source + index, (ptrdiff_t) (length - index));
+
+ if (width > 1) {
+ pm_buffer_append_string(buffer, "\\x{", 3);
+ for (size_t i = 0; i < width; i++) {
+ pm_buffer_append_format(buffer, "%02X", source[index + i]);
+ }
+ pm_buffer_append_byte(buffer, '}');
+ index += width;
+ } else {
+ pm_buffer_append_format(buffer, "\\x%02X", source[index]);
+ index++;
+ }
+ } else {
+ pm_buffer_append_format(buffer, "\\x%02X", source[index]);
+ index++;
+ }
+ }
+}
+
+/**
+ * Emit an encoding validation error on the regexp node.
+ */
+#define PM_REGEXP_ENCODING_ERROR(parser, diag_id, ...) \
+ pm_diagnostic_list_append_format( \
+ &(parser)->parser->metadata_arena, \
+ &(parser)->parser->error_list, \
+ (uint32_t) ((parser)->node_start - (parser)->parser->start), \
+ (uint32_t) ((parser)->node_end - (parser)->node_start), \
+ diag_id, __VA_ARGS__)
+
+/**
+ * Validate encoding for a regexp with an encoding modifier (/e, /s, /u, /n).
+ *
+ * The decision tree is:
+ *
+ * 1. No escape-set encoding (explicit_encoding == NULL):
+ * a. ASCII-only content: validate property escapes, return forced US-ASCII
+ * for /n or the modifier flags for others.
+ * b. US-ASCII source with non-ASCII literals: emit per-byte errors.
+ * c. Source encoding differs from modifier encoding: emit mismatch error.
+ *
+ * 2. Mixed \u and \x escapes: emit the appropriate conflict error depending
+ * on the modifier and which escape type was last.
+ *
+ * 3. \u escape with non-/u modifier: incompatible encoding error.
+ *
+ * 4. Validate that hex escape byte sequences form valid multibyte characters
+ * in the modifier's encoding.
+ */
+static pm_node_flags_t
+pm_regexp_validate_encoding_modifier(pm_regexp_parser_t *parser, bool ascii_only, pm_node_flags_t flags, char modifier, const pm_encoding_t *modifier_encoding, const char *source_start, int source_length) {
+
+ if (parser->explicit_encoding == NULL) {
+ if (ascii_only) {
+ // Check property escapes against the modifier's encoding tier.
+ // /n (ASCII-8BIT): only POSIX properties are valid.
+ // /e, /s: POSIX and script properties are valid.
+ // /u: all properties are valid.
+ if (modifier == 'n' && parser->property_name != NULL) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_INVALID_CHAR_PROPERTY,
+ (int) parser->property_name_length, (const char *) parser->property_name,
+ source_length, source_start);
+ } else if (modifier != 'u' && parser->has_unicode_property_escape) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_INVALID_CHAR_PROPERTY,
+ (int) parser->unicode_property_name_length, (const char *) parser->unicode_property_name,
+ source_length, source_start);
+ }
+ return modifier == 'n' ? PM_REGULAR_EXPRESSION_FLAGS_FORCED_US_ASCII_ENCODING : flags;
+ }
+
+ if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY) {
+ for (uint32_t i = 0; i < parser->non_ascii_literal_count; i++) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_CHAR, parser->encoding->name);
+ }
+ } else if (parser->encoding != modifier_encoding) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH, modifier, parser->encoding->name);
+
+ if (modifier == 'n' && !ascii_only) {
+ pm_buffer_t formatted = { 0 };
+ pm_regexp_format_for_error(&formatted, parser->encoding, (const uint8_t *) source_start, (size_t) source_length);
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_NON_ESCAPED_MBC, (int) formatted.length, (const char *) formatted.value);
+ pm_buffer_cleanup(&formatted);
+ }
+ }
+
+ return flags;
+ }
+
+ // Mixed unicode + hex escapes.
+ if (parser->has_unicode_escape && parser->has_hex_escape) {
+ if (modifier == 'n') {
+ if (parser->last_escape_was_unicode) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP, source_length, source_start);
+ } else {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8, source_length, source_start);
+ }
+ } else {
+ if (!pm_regexp_validate_hex_escapes(modifier_encoding, &parser->hex_escape_buffer)) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_ESCAPE, source_length, source_start);
+ }
+ }
+
+ return flags;
+ }
+
+ if (modifier != 'u' && parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY) {
+ if (parser->last_escape_was_unicode) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING, source_length, source_start);
+ } else if (parser->encoding != PM_ENCODING_UTF_8_ENTRY) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING, source_length, source_start);
+ }
+ }
+
+ if (modifier != 'n' && !pm_regexp_validate_hex_escapes(modifier_encoding, &parser->hex_escape_buffer)) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_ESCAPE, source_length, source_start);
+ }
+
+ return flags;
+}
+
+/**
+ * Validate encoding for a regexp without a modifier and compute the encoding
+ * flags to set on the node.
+ *
+ * The decision tree is:
+ *
+ * 1. If a modifier (/n, /u, /e, /s) is present, delegate to
+ * pm_regexp_validate_encoding_modifier.
+ * 2. Invalid multibyte chars or unicode ranges: suppress further checks (errors
+ * were already emitted during parsing).
+ * 3. US-ASCII source with non-ASCII literals: emit per-byte errors.
+ * 4. ASCII-only content: return forced US-ASCII (or forced UTF-8 if \p{...}).
+ * 5. Escape-set encoding present: validate hex escapes against the target
+ * encoding, handle mixed \u + \x conflicts, and return the appropriate
+ * forced encoding flag.
+ */
+static pm_node_flags_t
+pm_regexp_validate_encoding(pm_regexp_parser_t *parser, bool ascii_only, pm_node_flags_t flags, const char *source_start, int source_length) {
+
+ // Invalid multibyte characters suppress further validation.
+ // Errors were already emitted at the byte locations during parsing.
+ if (parser->has_invalid_multibyte) {
+ return flags;
+ }
+
+ if (parser->invalid_unicode_range) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_INVALID_UNICODE_RANGE, source_length, source_start);
+ return flags;
+ }
+
+ // Check modifier flags first.
+ if (flags & PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT) {
+ return pm_regexp_validate_encoding_modifier(parser, ascii_only, flags, 'n', PM_ENCODING_ASCII_8BIT_ENTRY, source_start, source_length);
+ }
+ if (flags & PM_REGULAR_EXPRESSION_FLAGS_UTF_8) {
+ return pm_regexp_validate_encoding_modifier(parser, ascii_only, flags, 'u', PM_ENCODING_UTF_8_ENTRY, source_start, source_length);
+ }
+ if (flags & PM_REGULAR_EXPRESSION_FLAGS_EUC_JP) {
+ return pm_regexp_validate_encoding_modifier(parser, ascii_only, flags, 'e', PM_ENCODING_EUC_JP_ENTRY, source_start, source_length);
+ }
+ if (flags & PM_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J) {
+ return pm_regexp_validate_encoding_modifier(parser, ascii_only, flags, 's', PM_ENCODING_WINDOWS_31J_ENTRY, source_start, source_length);
+ }
+
+ // No modifier — check for non-ASCII literals in US-ASCII encoding.
+ if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY && parser->explicit_encoding == NULL && !ascii_only) {
+ for (uint32_t i = 0; i < parser->non_ascii_literal_count; i++) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_CHAR, parser->encoding->name);
+ }
+ }
+
+ // ASCII-only regexps get downgraded to US-ASCII, unless property escapes
+ // force UTF-8.
+ if (ascii_only) {
+ if (parser->has_property_escape) {
+ return PM_REGULAR_EXPRESSION_FLAGS_FORCED_UTF8_ENCODING;
+ }
+ return PM_REGULAR_EXPRESSION_FLAGS_FORCED_US_ASCII_ENCODING;
+ }
+
+ // Check explicit encoding from escape sequences.
+ if (parser->explicit_encoding != NULL) {
+ // Mixed unicode + hex escapes without modifier.
+ if (parser->has_unicode_escape && parser->has_hex_escape && parser->encoding != PM_ENCODING_UTF_8_ENTRY) {
+ if (parser->encoding != PM_ENCODING_US_ASCII_ENTRY &&
+ parser->encoding != PM_ENCODING_ASCII_8BIT_ENTRY &&
+ !pm_regexp_validate_hex_escapes(parser->encoding, &parser->hex_escape_buffer)) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_ESCAPE, source_length, source_start);
+ } else if (parser->last_escape_was_unicode) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP, source_length, source_start);
+ } else {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8, source_length, source_start);
+ }
+
+ return 0;
+ }
+
+ if (parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY) {
+ if (!pm_regexp_validate_hex_escapes(parser->explicit_encoding, &parser->hex_escape_buffer)) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_ESCAPE, source_length, source_start);
+ }
+
+ return PM_REGULAR_EXPRESSION_FLAGS_FORCED_UTF8_ENCODING;
+ } else if (parser->encoding == PM_ENCODING_US_ASCII_ENTRY) {
+ return PM_REGULAR_EXPRESSION_FLAGS_FORCED_BINARY_ENCODING;
+ } else {
+ if (!pm_regexp_validate_hex_escapes(parser->explicit_encoding, &parser->hex_escape_buffer)) {
+ PM_REGEXP_ENCODING_ERROR(parser, PM_ERR_INVALID_MULTIBYTE_ESCAPE, source_length, source_start);
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Parse a regular expression, validate its encoding, and optionally extract
+ * named capture groups. Encoding validation walks the raw source (content_loc)
+ * to distinguish escape-produced bytes from literal bytes. Named capture
+ * extraction walks the unescaped content since escape sequences in group names
+ * (e.g., line continuations) have already been processed by the lexer.
+ */
+pm_node_flags_t
+pm_regexp_parse(pm_parser_t *parser, pm_regular_expression_node_t *node, pm_regexp_name_callback_t name_callback, pm_regexp_name_data_t *name_data) {
+ const uint8_t *source = parser->start + node->content_loc.start;
+ size_t size = node->content_loc.length;
+ bool extended_mode = PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED);
+ pm_node_flags_t flags = PM_NODE_FLAGS(node);
+
+ const uint8_t *node_start = parser->start + node->base.location.start;
+ const uint8_t *node_end = parser->start + node->base.location.start + node->base.location.length;
+
+ // First pass: walk raw source for encoding validation (no name extraction).
+ pm_regexp_parser_t regexp_parser = {
+ .parser = parser,
+ .start = source,
+ .cursor = source,
+ .end = source + size,
+ .extended_mode = extended_mode,
+ .encoding_changed = parser->encoding_changed,
+ .encoding = parser->encoding,
+ .name_callback = NULL,
+ .name_data = NULL,
+ .shared = true,
+ .node_start = node_start,
+ .node_end = node_end,
+ .has_unicode_escape = false,
+ .has_hex_escape = false,
+ .last_escape_was_unicode = false,
+ .explicit_encoding = NULL,
+ .has_property_escape = false,
+ .has_unicode_property_escape = false,
+ .property_name = NULL,
+ .property_name_length = 0,
+ .unicode_property_name = NULL,
+ .unicode_property_name_length = 0,
+ .non_ascii_literal_count = 0,
+ .invalid_unicode_range = false,
+ .hex_escape_buffer = { 0 },
+ .hex_group_active = false,
+ .has_invalid_multibyte = false,
+ };
+
+ pm_regexp_parse_pattern(&regexp_parser);
+
+ // Compute ascii_only from the regexp parser's tracked state. We cannot
+ // use node->unescaped for this because regexp unescaped content preserves
+ // escape text (e.g., \x80 is 4 ASCII chars), not the binary values.
+ bool ascii_only = !regexp_parser.has_hex_escape && !regexp_parser.has_unicode_escape && regexp_parser.non_ascii_literal_count == 0;
+ // Use the unescaped content for error messages to match CRuby's format,
+ // where Ruby escapes like \M-\C-? are resolved to bytes but regexp escapes
+ // like \u{80} are preserved as text.
+ const char *error_source = (const char *) pm_string_source(&node->unescaped);
+ int error_source_length = (int) pm_string_length(&node->unescaped);
+ pm_node_flags_t encoding_flags = pm_regexp_validate_encoding(&regexp_parser, ascii_only, flags, error_source, error_source_length);
+ pm_buffer_cleanup(&regexp_parser.hex_escape_buffer);
+
+ // Second pass: walk unescaped content for named capture extraction.
+ if (name_callback != NULL) {
+ bool shared = node->unescaped.type == PM_STRING_SHARED;
+ pm_regexp_parse_named_captures(parser, pm_string_source(&node->unescaped), pm_string_length(&node->unescaped), shared, extended_mode, name_callback, name_data);
+ }
+
+ return encoding_flags;
+}
+
+/**
+ * Parse an interpolated regular expression for named capture groups only.
+ * This is used for the =~ operator with interpolated regexps where we don't
+ * have a pm_regular_expression_node_t. No encoding validation is performed.
+ *
+ * Note: The encoding-tracking fields (has_unicode_escape, has_hex_escape, etc.)
+ * are initialized but not used for the result. They exist because the parsing
+ * functions (pm_regexp_parse_backslash_escape, etc.) unconditionally update
+ * them as they walk through the content.
+ */
+void
+pm_regexp_parse_named_captures(pm_parser_t *parser, const uint8_t *source, size_t size, bool shared, bool extended_mode, pm_regexp_name_callback_t name_callback, pm_regexp_name_data_t *name_data) {
+ pm_regexp_parser_t regexp_parser = {
+ .parser = parser,
+ .start = source,
+ .cursor = source,
+ .end = source + size,
+ .extended_mode = extended_mode,
+ .encoding_changed = parser->encoding_changed,
+ .encoding = parser->encoding,
+ .name_callback = name_callback,
+ .name_data = name_data,
+ .shared = shared,
+ .node_start = source,
+ .node_end = source + size,
+ .has_unicode_escape = false,
+ .has_hex_escape = false,
+ .last_escape_was_unicode = false,
+ .explicit_encoding = NULL,
+ .has_property_escape = false,
+ .has_unicode_property_escape = false,
+ .property_name = NULL,
+ .property_name_length = 0,
+ .unicode_property_name = NULL,
+ .unicode_property_name_length = 0,
+ .non_ascii_literal_count = 0,
+ .invalid_unicode_range = false,
+ .hex_escape_buffer = { 0 },
+ .hex_group_active = false,
+ .has_invalid_multibyte = false,
+ };
+
+ pm_regexp_parse_pattern(&regexp_parser);
+ pm_buffer_cleanup(&regexp_parser.hex_escape_buffer);
+}
diff --git a/prism/serialize.h b/prism/serialize.h
new file mode 100644
index 0000000000..786a1514bc
--- /dev/null
+++ b/prism/serialize.h
@@ -0,0 +1,96 @@
+/**
+ * @file serialize.h
+ *
+ * The functions related to serializing the AST to a binary format.
+ */
+#ifndef PRISM_SERIALIZE_H
+#define PRISM_SERIALIZE_H
+
+#include "prism/excludes.h"
+
+/* We optionally support serializing to a binary string. For systems that do not
+ * want or need this functionality, it can be turned off with the
+ * PRISM_EXCLUDE_SERIALIZATION define. */
+#ifndef PRISM_EXCLUDE_SERIALIZATION
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/buffer.h"
+#include "prism/parser.h"
+#include "prism/source.h"
+#include "prism/stream.h"
+
+/**
+ * Serialize the AST represented by the given node to the given buffer.
+ *
+ * @param parser The parser to serialize.
+ * @param node The node to serialize.
+ * @param buffer The buffer to serialize to.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) PRISM_NONNULL(1, 2, 3);
+
+/**
+ * Parse the given source to the AST and dump the AST to the given buffer.
+ *
+ * @param buffer The buffer to serialize to.
+ * @param source The source to parse.
+ * @param size The size of the source.
+ * @param data The optional data to pass to the parser.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
+
+/**
+ * Parse and serialize the AST represented by the given source into the given
+ * buffer.
+ *
+ * @param buffer The buffer to serialize to.
+ * @param source The source to parse.
+ * @param data The optional data to pass to the parser.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, pm_source_t *source, const char *data) PRISM_NONNULL(1, 2);
+
+/**
+ * Parse and serialize the comments in the given source to the given buffer.
+ *
+ * @param buffer The buffer to serialize to.
+ * @param source The source to parse.
+ * @param size The size of the source.
+ * @param data The optional data to pass to the parser.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
+
+/**
+ * Lex the given source and serialize to the given buffer.
+ *
+ * @param source The source to lex.
+ * @param size The size of the source.
+ * @param buffer The buffer to serialize to.
+ * @param data The optional data to pass to the lexer.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
+
+/**
+ * Parse and serialize both the AST and the tokens represented by the given
+ * source to the given buffer.
+ *
+ * @param buffer The buffer to serialize to.
+ * @param source The source to parse.
+ * @param size The size of the source.
+ * @param data The optional data to pass to the parser.
+ */
+PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
+
+/**
+ * Parse the source and return true if it parses without errors or warnings.
+ *
+ * @param source The source to parse.
+ * @param size The size of the source.
+ * @param data The optional data to pass to the parser.
+ * @returns True if the source parses without errors or warnings.
+ */
+PRISM_EXPORTED_FUNCTION bool pm_serialize_parse_success_p(const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1);
+
+#endif
+
+#endif
diff --git a/prism/source.c b/prism/source.c
new file mode 100644
index 0000000000..f61cb19c1b
--- /dev/null
+++ b/prism/source.c
@@ -0,0 +1,491 @@
+#include "prism/internal/source.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/buffer.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* The following headers are necessary to read files using demand paging. */
+#ifdef _WIN32
+#include <windows.h>
+#elif defined(_POSIX_MAPPED_FILES)
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#elif defined(PRISM_HAS_FILESYSTEM)
+#include <fcntl.h>
+#include <sys/stat.h>
+#endif
+
+static const uint8_t empty_source[] = "";
+
+/**
+ * Allocate and initialize a pm_source_t with the given fields.
+ */
+static pm_source_t *
+pm_source_alloc(const uint8_t *source, size_t length, pm_source_type_t type) {
+ pm_source_t *result = xmalloc(sizeof(pm_source_t));
+ if (result == NULL) abort();
+
+ *result = (struct pm_source_t) {
+ .source = source,
+ .length = length,
+ .type = type
+ };
+
+ return result;
+}
+
+/**
+ * Create a new source that wraps existing constant memory.
+ */
+pm_source_t *
+pm_source_constant_new(const uint8_t *data, size_t length) {
+ return pm_source_alloc(data, length, PM_SOURCE_CONSTANT);
+}
+
+/**
+ * Create a new source that wraps existing shared memory.
+ */
+pm_source_t *
+pm_source_shared_new(const uint8_t *data, size_t length) {
+ return pm_source_alloc(data, length, PM_SOURCE_SHARED);
+}
+
+/**
+ * Create a new source that owns its memory.
+ */
+pm_source_t *
+pm_source_owned_new(uint8_t *data, size_t length) {
+ return pm_source_alloc(data, length, PM_SOURCE_OWNED);
+}
+
+#ifdef _WIN32
+/**
+ * Represents a file handle on Windows, where the path will need to be freed
+ * when the file is closed.
+ */
+typedef struct {
+ /** The path to the file, which will become allocated memory. */
+ WCHAR *path;
+
+ /** The size of the allocated path in bytes. */
+ size_t path_size;
+
+ /** The handle to the file, which will start as uninitialized memory. */
+ HANDLE file;
+} pm_source_file_handle_t;
+
+/**
+ * Open the file indicated by the filepath parameter for reading on Windows.
+ */
+static pm_source_init_result_t
+pm_source_file_handle_open(pm_source_file_handle_t *handle, const char *filepath) {
+ int length = MultiByteToWideChar(CP_UTF8, 0, filepath, -1, NULL, 0);
+ if (length == 0) return PM_SOURCE_INIT_ERROR_GENERIC;
+
+ handle->path_size = sizeof(WCHAR) * ((size_t) length);
+ handle->path = xmalloc(handle->path_size);
+ if ((handle->path == NULL) || (MultiByteToWideChar(CP_UTF8, 0, filepath, -1, handle->path, length) == 0)) {
+ xfree_sized(handle->path, handle->path_size);
+ return PM_SOURCE_INIT_ERROR_GENERIC;
+ }
+
+ handle->file = CreateFileW(handle->path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
+ if (handle->file == INVALID_HANDLE_VALUE) {
+ pm_source_init_result_t result = PM_SOURCE_INIT_ERROR_GENERIC;
+
+ if (GetLastError() == ERROR_ACCESS_DENIED) {
+ DWORD attributes = GetFileAttributesW(handle->path);
+ if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ result = PM_SOURCE_INIT_ERROR_DIRECTORY;
+ }
+ }
+
+ xfree_sized(handle->path, handle->path_size);
+ return result;
+ }
+
+ return PM_SOURCE_INIT_SUCCESS;
+}
+
+/**
+ * Close the file handle and free the path.
+ */
+static void
+pm_source_file_handle_close(pm_source_file_handle_t *handle) {
+ xfree_sized(handle->path, handle->path_size);
+ CloseHandle(handle->file);
+}
+#endif
+
+/**
+ * Create a new source by memory-mapping a file.
+ */
+pm_source_t *
+pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) {
+#ifdef _WIN32
+ (void) open_flags;
+
+ /* Open the file for reading. */
+ pm_source_file_handle_t handle;
+ *result = pm_source_file_handle_open(&handle, filepath);
+ if (*result != PM_SOURCE_INIT_SUCCESS) return NULL;
+
+ /* Get the file size. */
+ DWORD file_size = GetFileSize(handle.file, NULL);
+ if (file_size == INVALID_FILE_SIZE) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* If the file is empty, then return a constant source. */
+ if (file_size == 0) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(empty_source, 0, PM_SOURCE_CONSTANT);
+ }
+
+ /* Create a mapping of the file. */
+ HANDLE mapping = CreateFileMapping(handle.file, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (mapping == NULL) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Map the file into memory. */
+ uint8_t *source = (uint8_t *) MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
+ CloseHandle(mapping);
+ pm_source_file_handle_close(&handle);
+
+ if (source == NULL) {
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(source, (size_t) file_size, PM_SOURCE_MAPPED);
+#elif defined(_POSIX_MAPPED_FILES)
+ /* Open the file for reading. */
+ int fd = open(filepath, O_RDONLY | open_flags);
+ if (fd == -1) {
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Stat the file to get the file size. */
+ struct stat sb;
+ if (fstat(fd, &sb) == -1) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Ensure it is a file and not a directory. */
+ if (S_ISDIR(sb.st_mode)) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_DIRECTORY;
+ return NULL;
+ }
+
+ /*
+ * For non-regular files (pipes, character devices), return a specific
+ * error so the caller can handle reading through their own I/O layer.
+ */
+ if (!S_ISREG(sb.st_mode)) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_NON_REGULAR;
+ return NULL;
+ }
+
+ /* mmap the file descriptor to virtually get the contents. */
+ size_t size = (size_t) sb.st_size;
+
+ if (size == 0) {
+ close(fd);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(empty_source, 0, PM_SOURCE_CONSTANT);
+ }
+
+ uint8_t *source = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (source == MAP_FAILED) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ close(fd);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(source, size, PM_SOURCE_MAPPED);
+#else
+ (void) open_flags;
+ return pm_source_file_new(filepath, result);
+#endif
+}
+
+/**
+ * Create a new source by reading a file into a heap-allocated buffer.
+ */
+pm_source_t *
+pm_source_file_new(const char *filepath, pm_source_init_result_t *result) {
+#ifdef _WIN32
+ /* Open the file for reading. */
+ pm_source_file_handle_t handle;
+ *result = pm_source_file_handle_open(&handle, filepath);
+ if (*result != PM_SOURCE_INIT_SUCCESS) return NULL;
+
+ /* Get the file size. */
+ const DWORD file_size = GetFileSize(handle.file, NULL);
+ if (file_size == INVALID_FILE_SIZE) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* If the file is empty, return a constant source. */
+ if (file_size == 0) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(empty_source, 0, PM_SOURCE_CONSTANT);
+ }
+
+ /* Create a buffer to read the file into. */
+ uint8_t *source = xmalloc(file_size);
+ if (source == NULL) {
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Read the contents of the file. */
+ DWORD bytes_read;
+ if (!ReadFile(handle.file, source, file_size, &bytes_read, NULL)) {
+ xfree_sized(source, file_size);
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Check the number of bytes read. */
+ if (bytes_read != file_size) {
+ xfree_sized(source, file_size);
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ pm_source_file_handle_close(&handle);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(source, (size_t) file_size, PM_SOURCE_OWNED);
+#elif defined(PRISM_HAS_FILESYSTEM)
+ /* Open the file for reading. */
+ int fd = open(filepath, O_RDONLY);
+ if (fd == -1) {
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Stat the file to get the file size. */
+ struct stat sb;
+ if (fstat(fd, &sb) == -1) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ /* Ensure it is a file and not a directory. */
+ if (S_ISDIR(sb.st_mode)) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_DIRECTORY;
+ return NULL;
+ }
+
+ /* Check the size to see if it's empty. */
+ size_t size = (size_t) sb.st_size;
+ if (size == 0) {
+ close(fd);
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(empty_source, 0, PM_SOURCE_CONSTANT);
+ }
+
+ const size_t length = (size_t) size;
+ uint8_t *source = xmalloc(length);
+ if (source == NULL) {
+ close(fd);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ ssize_t bytes_read = read(fd, source, length);
+ close(fd);
+
+ if (bytes_read == -1 || (size_t) bytes_read != length) {
+ xfree_sized(source, length);
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ return NULL;
+ }
+
+ *result = PM_SOURCE_INIT_SUCCESS;
+ return pm_source_alloc(source, length, PM_SOURCE_OWNED);
+#else
+ (void) filepath;
+ *result = PM_SOURCE_INIT_ERROR_GENERIC;
+ perror("pm_source_file_new is not implemented for this platform");
+ return NULL;
+#endif
+}
+
+/**
+ * Create a new source by reading from a stream. This allocates the source
+ * but does not read from the stream yet. Use pm_source_stream_read to read
+ * data.
+ */
+pm_source_t *
+pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof) {
+ pm_source_t *source = pm_source_alloc(NULL, 0, PM_SOURCE_STREAM);
+ source->stream.buffer = pm_buffer_new();
+ source->stream.stream = stream;
+ source->stream.fgets = fgets;
+ source->stream.feof = feof;
+ source->stream.eof = false;
+
+ return source;
+}
+
+/**
+ * Read from the stream into the source's internal buffer until __END__ is
+ * encountered or EOF is reached. Updates the source pointer and length.
+ *
+ * Returns true if EOF was reached, false if __END__ was encountered.
+ */
+bool
+pm_source_stream_read(pm_source_t *source) {
+ pm_buffer_t *buffer = source->stream.buffer;
+
+#define LINE_SIZE 4096
+ char line[LINE_SIZE];
+
+ while (memset(line, '\n', LINE_SIZE), source->stream.fgets(line, LINE_SIZE, source->stream.stream) != NULL) {
+ size_t length = LINE_SIZE;
+ while (length > 0 && line[length - 1] == '\n') length--;
+
+ if (length == LINE_SIZE) {
+ /*
+ * If we read a line that is the maximum size and it doesn't end
+ * with a newline, then we'll just append it to the buffer and
+ * continue reading.
+ */
+ length--;
+ pm_buffer_append_string(buffer, line, length);
+ continue;
+ }
+
+ /* Append the line to the buffer. */
+ length--;
+ pm_buffer_append_string(buffer, line, length);
+
+ /*
+ * Check if the line matches the __END__ marker. If it does, then stop
+ * reading and return false. In most circumstances, this means we should
+ * stop reading from the stream so that the DATA constant can pick it
+ * up.
+ */
+ switch (length) {
+ case 7:
+ if (strncmp(line, "__END__", 7) == 0) {
+ source->source = (const uint8_t *) pm_buffer_value(buffer);
+ source->length = pm_buffer_length(buffer);
+ return false;
+ }
+ break;
+ case 8:
+ if (strncmp(line, "__END__\n", 8) == 0) {
+ source->source = (const uint8_t *) pm_buffer_value(buffer);
+ source->length = pm_buffer_length(buffer);
+ return false;
+ }
+ break;
+ case 9:
+ if (strncmp(line, "__END__\r\n", 9) == 0) {
+ source->source = (const uint8_t *) pm_buffer_value(buffer);
+ source->length = pm_buffer_length(buffer);
+ return false;
+ }
+ break;
+ }
+
+ /*
+ * All data should be read via gets. If the string returned by gets
+ * _doesn't_ end with a newline, then we assume we hit EOF condition.
+ */
+ if (source->stream.feof(source->stream.stream)) {
+ break;
+ }
+ }
+
+#undef LINE_SIZE
+
+ source->stream.eof = true;
+ source->source = (const uint8_t *) pm_buffer_value(buffer);
+ source->length = pm_buffer_length(buffer);
+ return true;
+}
+
+/**
+ * Returns whether the stream source has reached EOF.
+ */
+bool
+pm_source_stream_eof(const pm_source_t *source) {
+ return source->stream.eof;
+}
+
+/**
+ * Free the given source and any memory it owns.
+ */
+void
+pm_source_free(pm_source_t *source) {
+ switch (source->type) {
+ case PM_SOURCE_CONSTANT:
+ case PM_SOURCE_SHARED:
+ /* No cleanup needed for the data. */
+ break;
+ case PM_SOURCE_OWNED:
+ xfree_sized((void *) source->source, source->length);
+ break;
+ case PM_SOURCE_MAPPED:
+#if defined(_WIN32)
+ if (source->length > 0) {
+ UnmapViewOfFile((void *) source->source);
+ }
+#elif defined(_POSIX_MAPPED_FILES)
+ if (source->length > 0) {
+ munmap((void *) source->source, source->length);
+ }
+#endif
+ break;
+ case PM_SOURCE_STREAM:
+ pm_buffer_free(source->stream.buffer);
+ break;
+ }
+
+ xfree_sized(source, sizeof(pm_source_t));
+}
+
+/**
+ * Returns the length of the source data in bytes.
+ */
+size_t
+pm_source_length(const pm_source_t *source) {
+ return source->length;
+}
+
+/**
+ * Returns a pointer to the source data.
+ */
+const uint8_t *
+pm_source_source(const pm_source_t *source) {
+ return source->source;
+}
diff --git a/prism/source.h b/prism/source.h
new file mode 100644
index 0000000000..c79987d3fb
--- /dev/null
+++ b/prism/source.h
@@ -0,0 +1,148 @@
+/**
+ * @file source.h
+ *
+ * An opaque type representing the source code being parsed, regardless of
+ * origin (constant memory, file, memory-mapped file, or stream).
+ */
+#ifndef PRISM_SOURCE_H
+#define PRISM_SOURCE_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/filesystem.h"
+#include "prism/compiler/nodiscard.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * An opaque type representing source code being parsed.
+ */
+typedef struct pm_source_t pm_source_t;
+
+/**
+ * This function is used to retrieve a line of input from a stream. It closely
+ * mirrors that of fgets so that fgets can be used as the default
+ * implementation.
+ */
+typedef char * (pm_source_stream_fgets_t)(char *string, int size, void *stream);
+
+/**
+ * This function is used to check whether a stream is at EOF. It closely mirrors
+ * that of feof so that feof can be used as the default implementation.
+ */
+typedef int (pm_source_stream_feof_t)(void *stream);
+
+/**
+ * Represents the result of initializing a source from a file.
+ */
+typedef enum {
+ /** Indicates that the source was successfully initialized. */
+ PM_SOURCE_INIT_SUCCESS = 0,
+
+ /**
+ * Indicates a generic error from a source init function, where the type
+ * of error should be read from `errno` or `GetLastError()`.
+ */
+ PM_SOURCE_INIT_ERROR_GENERIC = 1,
+
+ /**
+ * Indicates that the file that was attempted to be opened was a directory.
+ */
+ PM_SOURCE_INIT_ERROR_DIRECTORY = 2,
+
+ /**
+ * Indicates that the file is not a regular file (e.g. a pipe or character
+ * device) and the caller should handle reading it.
+ */
+ PM_SOURCE_INIT_ERROR_NON_REGULAR = 3
+} pm_source_init_result_t;
+
+/**
+ * Create a new source that wraps existing constant memory. The memory is not
+ * owned and will not be freed.
+ *
+ * @param data The pointer to the source data.
+ * @param length The length of the source data in bytes.
+ * @returns A new source. Aborts on allocation failure.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_constant_new(const uint8_t *data, size_t length);
+
+/**
+ * Create a new source that wraps existing shared memory. The memory is not
+ * owned and will not be freed. Semantically a "slice" of another source.
+ *
+ * @param data The pointer to the source data.
+ * @param length The length of the source data in bytes.
+ * @returns A new source. Aborts on allocation failure.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_shared_new(const uint8_t *data, size_t length);
+
+/**
+ * Create a new source that owns its memory. The memory will be freed with
+ * xfree when the source is freed.
+ *
+ * @param data The pointer to the heap-allocated source data.
+ * @param length The length of the source data in bytes.
+ * @returns A new source. Aborts on allocation failure.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_owned_new(uint8_t *data, size_t length);
+
+/**
+ * Create a new source by reading a file into a heap-allocated buffer.
+ *
+ * @param filepath The path to the file to read.
+ * @param result Out parameter for the result of the initialization.
+ * @returns A new source, or NULL on error (with result written to out param).
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_file_new(const char *filepath, pm_source_init_result_t *result) PRISM_NONNULL(1, 2);
+
+/**
+ * Create a new source by memory-mapping a file. Falls back to file reading on
+ * platforms without mmap support.
+ *
+ * If the file is a non-regular file (e.g. a pipe or character device),
+ * PM_SOURCE_INIT_ERROR_NON_REGULAR is returned, allowing the caller to handle
+ * it appropriately (e.g. by reading it through their own I/O layer).
+ *
+ * @param filepath The path to the file to read.
+ * @param open_flags Additional flags to pass to open(2) (e.g. O_NONBLOCK).
+ * @param result Out parameter for the result of the initialization.
+ * @returns A new source, or NULL on error (with result written to out param).
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) PRISM_NONNULL(1, 3);
+
+/**
+ * Create a new source by reading from a stream using the provided callbacks.
+ *
+ * @param stream The stream to read from.
+ * @param fgets The function to use to read from the stream.
+ * @param feof The function to use to check if the stream is at EOF.
+ * @returns A new source. Aborts on allocation failure.
+ */
+PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof);
+
+/**
+ * Free the given source and any memory it owns.
+ *
+ * @param source The source to free.
+ */
+PRISM_EXPORTED_FUNCTION void pm_source_free(pm_source_t *source) PRISM_NONNULL(1);
+
+/**
+ * Returns the length of the source data in bytes.
+ *
+ * @param source The source to get the length of.
+ * @returns The length of the source data.
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_source_length(const pm_source_t *source) PRISM_NONNULL(1);
+
+/**
+ * Returns a pointer to the source data.
+ *
+ * @param source The source to get the data of.
+ * @returns A pointer to the source data.
+ */
+PRISM_EXPORTED_FUNCTION const uint8_t * pm_source_source(const pm_source_t *source) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/srcs.mk b/prism/srcs.mk
new file mode 100644
index 0000000000..93ad8f579f
--- /dev/null
+++ b/prism/srcs.mk
@@ -0,0 +1,160 @@
+PRISM_TEMPLATES_DIR = $(PRISM_SRCDIR)/templates
+PRISM_TEMPLATE = $(PRISM_TEMPLATES_DIR)/template.rb
+PRISM_CONFIG = $(PRISM_SRCDIR)/config.yml
+
+srcs uncommon.mk: prism/.srcs.mk.time
+
+prism/.srcs.mk.time: $(order_only) $(PRISM_BUILD_DIR)/.time
+prism/$(HAVE_BASERUBY:no=.srcs.mk.time):
+ touch $@
+prism/$(HAVE_BASERUBY:yes=.srcs.mk.time): \
+ $(PRISM_SRCDIR)/templates/template.rb \
+ $(PRISM_SRCDIR)/srcs.mk.in
+ $(BASERUBY) $(tooldir)/generic_erb.rb -c -t$@ -o $(PRISM_SRCDIR)/srcs.mk $(PRISM_SRCDIR)/srcs.mk.in
+
+distclean-prism-srcs::
+ $(RM) prism/.srcs.mk.time
+ $(RMDIRS) prism || $(NULLCMD)
+
+distclean-srcs-local:: distclean-prism-srcs
+
+realclean-prism-srcs:: distclean-prism-srcs
+ $(RM) $(PRISM_SRCDIR)/srcs.mk
+
+realclean-srcs-local:: realclean-prism-srcs
+
+main srcs: prism-srcs
+main incs: prism-incs
+
+prism-srcs: $(srcdir)/prism/api_node.c
+$(srcdir)/prism/api_node.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/ext/prism/api_node.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) ext/prism/api_node.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/api_node.c
+
+prism-incs: $(srcdir)/prism/ast.h
+$(srcdir)/prism/ast.h: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/include/prism/ast.h.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) include/prism/ast.h $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/ast.h
+
+prism-incs: $(srcdir)/prism/internal/diagnostic.h
+$(srcdir)/prism/internal/diagnostic.h: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/include/prism/internal/diagnostic.h.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) include/prism/internal/diagnostic.h $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/internal/diagnostic.h
+
+prism-srcs: $(srcdir)/lib/prism/compiler.rb
+$(srcdir)/lib/prism/compiler.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/compiler.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/compiler.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/compiler.rb
+
+prism-srcs: $(srcdir)/lib/prism/dispatcher.rb
+$(srcdir)/lib/prism/dispatcher.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/dispatcher.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/dispatcher.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/dispatcher.rb
+
+prism-srcs: $(srcdir)/lib/prism/dot_visitor.rb
+$(srcdir)/lib/prism/dot_visitor.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/dot_visitor.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/dot_visitor.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/dot_visitor.rb
+
+prism-srcs: $(srcdir)/lib/prism/dsl.rb
+$(srcdir)/lib/prism/dsl.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/dsl.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/dsl.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/dsl.rb
+
+prism-srcs: $(srcdir)/lib/prism/inspect_visitor.rb
+$(srcdir)/lib/prism/inspect_visitor.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/inspect_visitor.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/inspect_visitor.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/inspect_visitor.rb
+
+prism-srcs: $(srcdir)/lib/prism/mutation_compiler.rb
+$(srcdir)/lib/prism/mutation_compiler.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/mutation_compiler.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/mutation_compiler.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/mutation_compiler.rb
+
+prism-srcs: $(srcdir)/lib/prism/node.rb
+$(srcdir)/lib/prism/node.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/node.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/node.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/node.rb
+
+prism-srcs: $(srcdir)/lib/prism/reflection.rb
+$(srcdir)/lib/prism/reflection.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/reflection.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/reflection.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/reflection.rb
+
+prism-srcs: $(srcdir)/lib/prism/serialize.rb
+$(srcdir)/lib/prism/serialize.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/serialize.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/serialize.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/serialize.rb
+
+prism-srcs: $(srcdir)/lib/prism/visitor.rb
+$(srcdir)/lib/prism/visitor.rb: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/lib/prism/visitor.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) lib/prism/visitor.rb $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/lib/prism/visitor.rb
+
+prism-srcs: $(srcdir)/prism/diagnostic.c
+$(srcdir)/prism/diagnostic.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/diagnostic.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/diagnostic.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/diagnostic.c
+
+prism-srcs: $(srcdir)/prism/json.c
+$(srcdir)/prism/json.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/json.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/json.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/json.c
+
+prism-srcs: $(srcdir)/prism/node.c
+$(srcdir)/prism/node.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/node.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/node.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/node.c
+
+prism-srcs: $(srcdir)/prism/prettyprint.c
+$(srcdir)/prism/prettyprint.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/prettyprint.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/prettyprint.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/prettyprint.c
+
+prism-srcs: $(srcdir)/prism/serialize.c
+$(srcdir)/prism/serialize.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/serialize.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/serialize.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/serialize.c
+
+prism-srcs: $(srcdir)/prism/tokens.c
+$(srcdir)/prism/tokens.c: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/src/tokens.c.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) src/tokens.c $@
+
+realclean-prism-srcs::
+ $(RM) $(srcdir)/prism/tokens.c
diff --git a/prism/srcs.mk.in b/prism/srcs.mk.in
new file mode 100644
index 0000000000..6149e4ae9d
--- /dev/null
+++ b/prism/srcs.mk.in
@@ -0,0 +1,52 @@
+<% # -*- ruby -*-
+# :stopdoc:
+require_relative 'templates/template'
+
+script = File.basename(__FILE__)
+srcs = output ? File.basename(output) : script.chomp('.in')
+mk = 'uncommon.mk'
+
+# %>
+PRISM_TEMPLATES_DIR = $(PRISM_SRCDIR)/templates
+PRISM_TEMPLATE = $(PRISM_TEMPLATES_DIR)/template.rb
+PRISM_CONFIG = $(PRISM_SRCDIR)/config.yml
+
+srcs <%=%><%=mk%>: prism/.srcs.mk.time
+
+prism/.srcs.mk.time: $(order_only) $(PRISM_BUILD_DIR)/.time
+prism/$(HAVE_BASERUBY:no=.srcs.mk.time):
+ touch $@
+prism/$(HAVE_BASERUBY:yes=.srcs.mk.time): \
+ $(PRISM_SRCDIR)/templates/template.rb \
+ $(PRISM_SRCDIR)/<%=%><%=script%>
+ $(BASERUBY) $(tooldir)/generic_erb.rb -c -t$@ -o $(PRISM_SRCDIR)/<%=%><%=srcs%> $(PRISM_SRCDIR)/<%=%><%=script%>
+
+distclean-prism-srcs::
+ $(RM) prism/.srcs.mk.time
+ $(RMDIRS) prism || $(NULLCMD)
+
+distclean-srcs-local:: distclean-prism-srcs
+
+realclean-prism-srcs:: distclean-prism-srcs
+ $(RM) $(PRISM_SRCDIR)/<%=%><%=srcs%>
+
+realclean-srcs-local:: realclean-prism-srcs
+
+main srcs: prism-srcs
+main incs: prism-incs
+<% Prism::Template::TEMPLATES.map do |t|
+ /\.(?:[ch]|rb)\z/ =~ t or next
+ s = '$(srcdir)/' + t.sub(%r[\A(?:(src)|ext|include)/]) {$1 && 'prism/'}
+ s.sub!(%r[\A\$(srcdir)/prism/], '$(PRISM_SRCDIR)/')
+ target = s.end_with?('.h') ? 'incs' : 'srcs'
+# %>
+
+prism-<%=%><%=target%>: <%=%><%=s%>
+<%=%><%=s%>: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/<%=%><%=t%>.erb
+ $(Q) $(BASERUBY) $(PRISM_TEMPLATE) <%=%><%=t%> $@
+
+realclean-prism-srcs::
+ $(RM) <%=%><%=s%>
+<%
+end
+# %>
diff --git a/prism/static_literals.c b/prism/static_literals.c
new file mode 100644
index 0000000000..9af1eadf5d
--- /dev/null
+++ b/prism/static_literals.c
@@ -0,0 +1,641 @@
+#include "prism/internal/static_literals.h"
+
+#include "prism/compiler/inline.h"
+#include "prism/compiler/unused.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/buffer.h"
+#include "prism/internal/integer.h"
+#include "prism/internal/isinf.h"
+#include "prism/internal/stringy.h"
+
+#include <assert.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * A small struct used for passing around a subset of the information that is
+ * stored on the parser. We use this to avoid having static literals explicitly
+ * depend on the parser struct.
+ */
+typedef struct {
+ /** The list of newline offsets to use to calculate line numbers. */
+ const pm_line_offset_list_t *line_offsets;
+
+ /** The start of the source being parsed. */
+ const uint8_t *start;
+
+ /** The line number that the parser starts on. */
+ int32_t start_line;
+
+ /** The name of the encoding that the parser is using. */
+ const char *encoding_name;
+} pm_static_literals_metadata_t;
+
+static PRISM_INLINE uint32_t
+murmur_scramble(uint32_t value) {
+ value *= 0xcc9e2d51;
+ value = (value << 15) | (value >> 17);
+ value *= 0x1b873593;
+ return value;
+}
+
+/**
+ * Murmur hash (https://en.wikipedia.org/wiki/MurmurHash) is a non-cryptographic
+ * general-purpose hash function. It is fast, which is what we care about in
+ * this case.
+ */
+static uint32_t
+murmur_hash(const uint8_t *key, size_t length) {
+ uint32_t hash = 0x9747b28c;
+ uint32_t segment;
+
+ for (size_t index = length >> 2; index; index--) {
+ memcpy(&segment, key, sizeof(uint32_t));
+ key += sizeof(uint32_t);
+ hash ^= murmur_scramble(segment);
+ hash = (hash << 13) | (hash >> 19);
+ hash = hash * 5 + 0xe6546b64;
+ }
+
+ segment = 0;
+ for (size_t index = length & 3; index; index--) {
+ segment <<= 8;
+ segment |= key[index - 1];
+ }
+
+ hash ^= murmur_scramble(segment);
+ hash ^= (uint32_t) length;
+ hash ^= hash >> 16;
+ hash *= 0x85ebca6b;
+ hash ^= hash >> 13;
+ hash *= 0xc2b2ae35;
+ hash ^= hash >> 16;
+ return hash;
+}
+
+/**
+ * Hash the value of an integer and return it.
+ */
+static uint32_t
+integer_hash(const pm_integer_t *integer) {
+ uint32_t hash;
+ if (integer->values) {
+ hash = murmur_hash((const uint8_t *) integer->values, sizeof(uint32_t) * integer->length);
+ } else {
+ hash = murmur_hash((const uint8_t *) &integer->value, sizeof(uint32_t));
+ }
+
+ if (integer->negative) {
+ hash ^= murmur_scramble((uint32_t) 1);
+ }
+
+ return hash;
+}
+
+/**
+ * Return the hash of the given node. It is important that nodes that have
+ * equivalent static literal values have the same hash. This is because we use
+ * these hashes to look for duplicates.
+ */
+static uint32_t
+node_hash(const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_INTEGER_NODE: {
+ // Integers hash their value.
+ const pm_integer_node_t *cast = (const pm_integer_node_t *) node;
+ return integer_hash(&cast->value);
+ }
+ case PM_SOURCE_LINE_NODE: {
+ // Source lines hash their line number.
+ const pm_line_column_t line_column = pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line);
+ const int32_t *value = &line_column.line;
+ return murmur_hash((const uint8_t *) value, sizeof(int32_t));
+ }
+ case PM_FLOAT_NODE: {
+ // Floats hash their value.
+ const double *value = &((const pm_float_node_t *) node)->value;
+ return murmur_hash((const uint8_t *) value, sizeof(double));
+ }
+ case PM_RATIONAL_NODE: {
+ // Rationals hash their numerator and denominator.
+ const pm_rational_node_t *cast = (const pm_rational_node_t *) node;
+ return integer_hash(&cast->numerator) ^ integer_hash(&cast->denominator) ^ murmur_scramble((uint32_t) cast->base.type);
+ }
+ case PM_IMAGINARY_NODE: {
+ // Imaginaries hash their numeric value. Because their numeric value
+ // is stored as a subnode, we hash that node and then mix in the
+ // fact that this is an imaginary node.
+ const pm_node_t *numeric = ((const pm_imaginary_node_t *) node)->numeric;
+ return node_hash(metadata, numeric) ^ murmur_scramble((uint32_t) node->type);
+ }
+ case PM_STRING_NODE: {
+ // Strings hash their value and mix in their flags so that different
+ // encodings are not considered equal.
+ const pm_string_t *value = &((const pm_string_node_t *) node)->unescaped;
+
+ pm_node_flags_t flags = node->flags;
+ flags &= (PM_STRING_FLAGS_FORCED_BINARY_ENCODING | PM_STRING_FLAGS_FORCED_UTF8_ENCODING);
+
+ return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) flags);
+ }
+ case PM_SOURCE_FILE_NODE: {
+ // Source files hash their value and mix in their flags so that
+ // different encodings are not considered equal.
+ const pm_string_t *value = &((const pm_source_file_node_t *) node)->filepath;
+ return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t));
+ }
+ case PM_REGULAR_EXPRESSION_NODE: {
+ // Regular expressions hash their value and mix in their flags so
+ // that different encodings are not considered equal.
+ const pm_string_t *value = &((const pm_regular_expression_node_t *) node)->unescaped;
+ return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) node->flags);
+ }
+ case PM_SYMBOL_NODE: {
+ // Symbols hash their value and mix in their flags so that different
+ // encodings are not considered equal.
+ const pm_string_t *value = &((const pm_symbol_node_t *) node)->unescaped;
+ return murmur_hash(pm_string_source(value), pm_string_length(value) * sizeof(uint8_t)) ^ murmur_scramble((uint32_t) node->flags);
+ }
+ default:
+ assert(false && "unreachable");
+ return 0;
+ }
+}
+
+/**
+ * Insert a node into the node hash. It accepts the hash that should hold the
+ * new node, the parser that generated the node, the node to insert, and a
+ * comparison function. The comparison function is used for collision detection,
+ * and must be able to compare all node types that will be stored in this hash.
+ */
+static pm_node_t *
+pm_node_hash_insert(pm_node_hash_t *hash, const pm_static_literals_metadata_t *metadata, pm_node_t *node, bool replace, int (*compare)(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right)) {
+ // If we are out of space, we need to resize the hash. This will cause all
+ // of the nodes to be rehashed and reinserted into the new hash.
+ if (hash->size * 2 >= hash->capacity) {
+ // First, allocate space for the new node list.
+ uint32_t new_capacity = hash->capacity == 0 ? 4 : hash->capacity * 2;
+ pm_node_t **new_nodes = xcalloc(new_capacity, sizeof(pm_node_t *));
+ if (new_nodes == NULL) return NULL;
+
+ // It turns out to be more efficient to mask the hash value than to use
+ // the modulo operator. Because our capacities are always powers of two,
+ // we can use a bitwise AND to get the same result as the modulo
+ // operator.
+ uint32_t mask = new_capacity - 1;
+
+ // Now, rehash all of the nodes into the new list.
+ for (uint32_t index = 0; index < hash->capacity; index++) {
+ pm_node_t *node = hash->nodes[index];
+
+ if (node != NULL) {
+ uint32_t index = node_hash(metadata, node) & mask;
+ new_nodes[index] = node;
+ }
+ }
+
+ // Finally, free the old node list and update the hash.
+ xfree_sized(hash->nodes, hash->capacity * sizeof(pm_node_t *));
+ hash->nodes = new_nodes;
+ hash->capacity = new_capacity;
+ }
+
+ // Now, insert the node into the hash.
+ uint32_t mask = hash->capacity - 1;
+ uint32_t index = node_hash(metadata, node) & mask;
+
+ // We use linear probing to resolve collisions. This means that if the
+ // current index is occupied, we will move to the next index and try again.
+ // We are guaranteed that this will eventually find an empty slot because we
+ // resize the hash when it gets too full.
+ while (hash->nodes[index] != NULL) {
+ if (compare(metadata, hash->nodes[index], node) == 0) break;
+ index = (index + 1) & mask;
+ }
+
+ // If the current index is occupied, we need to return the node that was
+ // already in the hash. Otherwise, we can just increment the size and insert
+ // the new node.
+ pm_node_t *result = hash->nodes[index];
+
+ if (result == NULL) {
+ hash->size++;
+ hash->nodes[index] = node;
+ } else if (replace) {
+ hash->nodes[index] = node;
+ }
+
+ return result;
+}
+
+/**
+ * Free the internal memory associated with the given node hash.
+ */
+static void
+pm_node_hash_free(pm_node_hash_t *hash) {
+ if (hash->capacity > 0) xfree_sized(hash->nodes, hash->capacity * sizeof(pm_node_t *));
+}
+
+/**
+ * Compare two values that can be compared with a simple numeric comparison.
+ */
+#define PM_NUMERIC_COMPARISON(left, right) ((left < right) ? -1 : (left > right) ? 1 : 0)
+
+/**
+ * Return the integer value of the given node as an int64_t.
+ */
+static int64_t
+pm_int64_value(const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_INTEGER_NODE: {
+ const pm_integer_t *integer = &((const pm_integer_node_t *) node)->value;
+ if (integer->values) return integer->negative ? INT64_MIN : INT64_MAX;
+
+ int64_t value = (int64_t) integer->value;
+ return integer->negative ? -value : value;
+ }
+ case PM_SOURCE_LINE_NODE:
+ return (int64_t) pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line).line;
+ default:
+ assert(false && "unreachable");
+ return 0;
+ }
+}
+
+/**
+ * A comparison function for comparing two IntegerNode or SourceLineNode
+ * instances.
+ */
+static int
+pm_compare_integer_nodes(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
+ if (PM_NODE_TYPE_P(left, PM_SOURCE_LINE_NODE) || PM_NODE_TYPE_P(right, PM_SOURCE_LINE_NODE)) {
+ int64_t left_value = pm_int64_value(metadata, left);
+ int64_t right_value = pm_int64_value(metadata, right);
+ return PM_NUMERIC_COMPARISON(left_value, right_value);
+ }
+
+ const pm_integer_t *left_integer = &((const pm_integer_node_t *) left)->value;
+ const pm_integer_t *right_integer = &((const pm_integer_node_t *) right)->value;
+ return pm_integer_compare(left_integer, right_integer);
+}
+
+/**
+ * A comparison function for comparing two FloatNode instances.
+ */
+static int
+pm_compare_float_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
+ const double left_value = ((const pm_float_node_t *) left)->value;
+ const double right_value = ((const pm_float_node_t *) right)->value;
+ return PM_NUMERIC_COMPARISON(left_value, right_value);
+}
+
+/**
+ * A comparison function for comparing two nodes that have attached numbers.
+ */
+static int
+pm_compare_number_nodes(const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
+ if (PM_NODE_TYPE(left) != PM_NODE_TYPE(right)) {
+ return PM_NUMERIC_COMPARISON(PM_NODE_TYPE(left), PM_NODE_TYPE(right));
+ }
+
+ switch (PM_NODE_TYPE(left)) {
+ case PM_IMAGINARY_NODE:
+ return pm_compare_number_nodes(metadata, ((const pm_imaginary_node_t *) left)->numeric, ((const pm_imaginary_node_t *) right)->numeric);
+ case PM_RATIONAL_NODE: {
+ const pm_rational_node_t *left_rational = (const pm_rational_node_t *) left;
+ const pm_rational_node_t *right_rational = (const pm_rational_node_t *) right;
+
+ int result = pm_integer_compare(&left_rational->denominator, &right_rational->denominator);
+ if (result != 0) return result;
+
+ return pm_integer_compare(&left_rational->numerator, &right_rational->numerator);
+ }
+ case PM_INTEGER_NODE:
+ return pm_compare_integer_nodes(metadata, left, right);
+ case PM_FLOAT_NODE:
+ return pm_compare_float_nodes(metadata, left, right);
+ default:
+ assert(false && "unreachable");
+ return 0;
+ }
+}
+
+/**
+ * Return a pointer to the string value of the given node.
+ */
+static const pm_string_t *
+pm_string_value(const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_STRING_NODE:
+ return &((const pm_string_node_t *) node)->unescaped;
+ case PM_SOURCE_FILE_NODE:
+ return &((const pm_source_file_node_t *) node)->filepath;
+ case PM_SYMBOL_NODE:
+ return &((const pm_symbol_node_t *) node)->unescaped;
+ default:
+ assert(false && "unreachable");
+ return NULL;
+ }
+}
+
+/**
+ * A comparison function for comparing two nodes that have attached strings.
+ */
+static int
+pm_compare_string_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
+ const pm_string_t *left_string = pm_string_value(left);
+ const pm_string_t *right_string = pm_string_value(right);
+ return pm_string_compare(left_string, right_string);
+}
+
+/**
+ * A comparison function for comparing two RegularExpressionNode instances.
+ */
+static int
+pm_compare_regular_expression_nodes(PRISM_UNUSED const pm_static_literals_metadata_t *metadata, const pm_node_t *left, const pm_node_t *right) {
+ const pm_regular_expression_node_t *left_regexp = (const pm_regular_expression_node_t *) left;
+ const pm_regular_expression_node_t *right_regexp = (const pm_regular_expression_node_t *) right;
+
+ int result = pm_string_compare(&left_regexp->unescaped, &right_regexp->unescaped);
+ if (result != 0) return result;
+
+ return PM_NUMERIC_COMPARISON(left_regexp->base.flags, right_regexp->base.flags);
+}
+
+#undef PM_NUMERIC_COMPARISON
+
+/**
+ * Add a node to the set of static literals.
+ */
+pm_node_t *
+pm_static_literals_add(const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_INTEGER_NODE:
+ case PM_SOURCE_LINE_NODE:
+ return pm_node_hash_insert(
+ &literals->integer_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_integer_nodes
+ );
+ case PM_FLOAT_NODE:
+ return pm_node_hash_insert(
+ &literals->float_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_float_nodes
+ );
+ case PM_RATIONAL_NODE:
+ case PM_IMAGINARY_NODE:
+ return pm_node_hash_insert(
+ &literals->number_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_number_nodes
+ );
+ case PM_STRING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ return pm_node_hash_insert(
+ &literals->string_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_string_nodes
+ );
+ case PM_REGULAR_EXPRESSION_NODE:
+ return pm_node_hash_insert(
+ &literals->regexp_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_regular_expression_nodes
+ );
+ case PM_SYMBOL_NODE:
+ return pm_node_hash_insert(
+ &literals->symbol_nodes,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = NULL
+ },
+ node,
+ replace,
+ pm_compare_string_nodes
+ );
+ case PM_TRUE_NODE: {
+ pm_node_t *duplicated = literals->true_node;
+ if ((duplicated == NULL) || replace) literals->true_node = node;
+ return duplicated;
+ }
+ case PM_FALSE_NODE: {
+ pm_node_t *duplicated = literals->false_node;
+ if ((duplicated == NULL) || replace) literals->false_node = node;
+ return duplicated;
+ }
+ case PM_NIL_NODE: {
+ pm_node_t *duplicated = literals->nil_node;
+ if ((duplicated == NULL) || replace) literals->nil_node = node;
+ return duplicated;
+ }
+ case PM_SOURCE_ENCODING_NODE: {
+ pm_node_t *duplicated = literals->source_encoding_node;
+ if ((duplicated == NULL) || replace) literals->source_encoding_node = node;
+ return duplicated;
+ }
+ default:
+ return NULL;
+ }
+}
+
+/**
+ * Free the internal memory associated with the given static literals set.
+ */
+void
+pm_static_literals_free(pm_static_literals_t *literals) {
+ pm_node_hash_free(&literals->integer_nodes);
+ pm_node_hash_free(&literals->float_nodes);
+ pm_node_hash_free(&literals->number_nodes);
+ pm_node_hash_free(&literals->string_nodes);
+ pm_node_hash_free(&literals->regexp_nodes);
+ pm_node_hash_free(&literals->symbol_nodes);
+}
+
+/**
+ * A helper to determine if the given node is a static literal that is positive.
+ * This is used for formatting imaginary nodes.
+ */
+static bool
+pm_static_literal_positive_p(const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_FLOAT_NODE:
+ return ((const pm_float_node_t *) node)->value > 0;
+ case PM_INTEGER_NODE:
+ return !((const pm_integer_node_t *) node)->value.negative;
+ case PM_RATIONAL_NODE:
+ return !((const pm_rational_node_t *) node)->numerator.negative;
+ case PM_IMAGINARY_NODE:
+ return pm_static_literal_positive_p(((const pm_imaginary_node_t *) node)->numeric);
+ default:
+ assert(false && "unreachable");
+ return false;
+ }
+}
+
+/**
+ * Create a string-based representation of the given static literal.
+ */
+static PRISM_INLINE void
+pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_metadata_t *metadata, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_FALSE_NODE:
+ pm_buffer_append_string(buffer, "false", 5);
+ break;
+ case PM_FLOAT_NODE: {
+ const double value = ((const pm_float_node_t *) node)->value;
+
+ if (PRISM_ISINF(value)) {
+ if (metadata->start[node->location.start] == '-') {
+ pm_buffer_append_byte(buffer, '-');
+ }
+ pm_buffer_append_string(buffer, "Infinity", 8);
+ } else if (value == 0.0) {
+ if (metadata->start[node->location.start] == '-') {
+ pm_buffer_append_byte(buffer, '-');
+ }
+ pm_buffer_append_string(buffer, "0.0", 3);
+ } else {
+ pm_buffer_append_format(buffer, "%g", value);
+
+ // %g will not insert a .0 for 1e100 (we'll get back 1e+100). So
+ // we check for the decimal point and add it in here if it's not
+ // present.
+ if (pm_buffer_index(buffer, '.') == SIZE_MAX) {
+ size_t exponent_index = pm_buffer_index(buffer, 'e');
+ size_t index = exponent_index == SIZE_MAX ? pm_buffer_length(buffer) : exponent_index;
+ pm_buffer_insert(buffer, index, ".0", 2);
+ }
+ }
+
+ break;
+ }
+ case PM_IMAGINARY_NODE: {
+ const pm_node_t *numeric = ((const pm_imaginary_node_t *) node)->numeric;
+ pm_buffer_append_string(buffer, "(0", 2);
+ if (pm_static_literal_positive_p(numeric)) pm_buffer_append_byte(buffer, '+');
+ pm_static_literal_inspect_node(buffer, metadata, numeric);
+ if (PM_NODE_TYPE_P(numeric, PM_RATIONAL_NODE)) {
+ pm_buffer_append_byte(buffer, '*');
+ }
+ pm_buffer_append_string(buffer, "i)", 2);
+ break;
+ }
+ case PM_INTEGER_NODE:
+ pm_integer_string(buffer, &((const pm_integer_node_t *) node)->value);
+ break;
+ case PM_NIL_NODE:
+ pm_buffer_append_string(buffer, "nil", 3);
+ break;
+ case PM_RATIONAL_NODE: {
+ const pm_rational_node_t *rational = (const pm_rational_node_t *) node;
+ pm_buffer_append_byte(buffer, '(');
+ pm_integer_string(buffer, &rational->numerator);
+ pm_buffer_append_byte(buffer, '/');
+ pm_integer_string(buffer, &rational->denominator);
+ pm_buffer_append_byte(buffer, ')');
+ break;
+ }
+ case PM_REGULAR_EXPRESSION_NODE: {
+ const pm_string_t *unescaped = &((const pm_regular_expression_node_t *) node)->unescaped;
+ pm_buffer_append_byte(buffer, '/');
+ pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_byte(buffer, '/');
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_MULTI_LINE)) pm_buffer_append_string(buffer, "m", 1);
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE)) pm_buffer_append_string(buffer, "i", 1);
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED)) pm_buffer_append_string(buffer, "x", 1);
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT)) pm_buffer_append_string(buffer, "n", 1);
+
+ break;
+ }
+ case PM_SOURCE_ENCODING_NODE:
+ pm_buffer_append_format(buffer, "#<Encoding:%s>", metadata->encoding_name);
+ break;
+ case PM_SOURCE_FILE_NODE: {
+ const pm_string_t *filepath = &((const pm_source_file_node_t *) node)->filepath;
+ pm_buffer_append_byte(buffer, '"');
+ pm_buffer_append_source(buffer, pm_string_source(filepath), pm_string_length(filepath), PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_byte(buffer, '"');
+ break;
+ }
+ case PM_SOURCE_LINE_NODE:
+ pm_buffer_append_format(buffer, "%d", pm_line_offset_list_line_column(metadata->line_offsets, node->location.start, metadata->start_line).line);
+ break;
+ case PM_STRING_NODE: {
+ const pm_string_t *unescaped = &((const pm_string_node_t *) node)->unescaped;
+ pm_buffer_append_byte(buffer, '"');
+ pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_byte(buffer, '"');
+ break;
+ }
+ case PM_SYMBOL_NODE: {
+ const pm_string_t *unescaped = &((const pm_symbol_node_t *) node)->unescaped;
+ pm_buffer_append_byte(buffer, ':');
+ pm_buffer_append_source(buffer, pm_string_source(unescaped), pm_string_length(unescaped), PM_BUFFER_ESCAPING_RUBY);
+ break;
+ }
+ case PM_TRUE_NODE:
+ pm_buffer_append_string(buffer, "true", 4);
+ break;
+ default:
+ assert(false && "unreachable");
+ break;
+ }
+}
+
+/**
+ * Create a string-based representation of the given static literal.
+ */
+void
+pm_static_literal_inspect(pm_buffer_t *buffer, const pm_line_offset_list_t *line_offsets, const uint8_t *start, int32_t start_line, const char *encoding_name, const pm_node_t *node) {
+ pm_static_literal_inspect_node(
+ buffer,
+ &(pm_static_literals_metadata_t) {
+ .line_offsets = line_offsets,
+ .start = start,
+ .start_line = start_line,
+ .encoding_name = encoding_name
+ },
+ node
+ );
+}
diff --git a/prism/stream.h b/prism/stream.h
new file mode 100644
index 0000000000..678322b442
--- /dev/null
+++ b/prism/stream.h
@@ -0,0 +1,28 @@
+/**
+ * @file stream.h
+ *
+ * Functions for parsing streams.
+ */
+#ifndef PRISM_STREAM_H
+#define PRISM_STREAM_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include "prism/arena.h"
+#include "prism/options.h"
+#include "prism/parser.h"
+#include "prism/source.h"
+
+/**
+ * Parse a stream of Ruby source and return the tree.
+ *
+ * @param parser The out parameter to write the parser to.
+ * @param arena The arena to use for all AST-lifetime allocations.
+ * @param source The source to use, created via pm_source_stream_new.
+ * @param options The optional options to use when parsing.
+ * @returns The AST representing the source.
+ */
+PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t **parser, pm_arena_t *arena, pm_source_t *source, const pm_options_t *options) PRISM_NONNULL(1, 2, 3);
+
+#endif
diff --git a/prism/string_query.c b/prism/string_query.c
new file mode 100644
index 0000000000..ccedaf9c00
--- /dev/null
+++ b/prism/string_query.c
@@ -0,0 +1,166 @@
+#include "prism/string_query.h"
+
+#include "prism/internal/char.h"
+#include "prism/internal/encoding.h"
+
+#include <assert.h>
+#include <string.h>
+
+/** The category of slice returned from pm_slice_type. */
+typedef enum {
+ /** Returned when the given encoding name is invalid. */
+ PM_SLICE_TYPE_ERROR = -1,
+
+ /** Returned when no other types apply to the slice. */
+ PM_SLICE_TYPE_NONE,
+
+ /** Returned when the slice is a valid local variable name. */
+ PM_SLICE_TYPE_LOCAL,
+
+ /** Returned when the slice is a valid constant name. */
+ PM_SLICE_TYPE_CONSTANT,
+
+ /** Returned when the slice is a valid method name. */
+ PM_SLICE_TYPE_METHOD_NAME
+} pm_slice_type_t;
+
+/**
+ * Check that the slice is a valid local variable name or constant.
+ */
+static pm_slice_type_t
+pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name) {
+ // first, get the right encoding object
+ const pm_encoding_t *encoding = pm_encoding_find((const uint8_t *) encoding_name, (const uint8_t *) (encoding_name + strlen(encoding_name)));
+ if (encoding == NULL) return PM_SLICE_TYPE_ERROR;
+
+ // check that there is at least one character
+ if (length == 0) return PM_SLICE_TYPE_NONE;
+
+ size_t width;
+ if ((width = encoding->alpha_char(source, (ptrdiff_t) length)) != 0) {
+ // valid because alphabetical
+ } else if (*source == '_') {
+ // valid because underscore
+ width = 1;
+ } else if ((*source >= 0x80) && ((width = encoding->char_width(source, (ptrdiff_t) length)) > 0)) {
+ // valid because multibyte
+ } else {
+ // invalid because no match
+ return PM_SLICE_TYPE_NONE;
+ }
+
+ // determine the type of the slice based on the first character
+ const uint8_t *end = source + length;
+ pm_slice_type_t result = encoding->isupper_char(source, end - source) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL;
+
+ // next, iterate through all of the bytes of the string to ensure that they
+ // are all valid identifier characters
+ source += width;
+
+ while (source < end) {
+ if ((width = encoding->alnum_char(source, end - source)) != 0) {
+ // valid because alphanumeric
+ source += width;
+ } else if (*source == '_') {
+ // valid because underscore
+ source++;
+ } else if ((*source >= 0x80) && ((width = encoding->char_width(source, end - source)) > 0)) {
+ // valid because multibyte
+ source += width;
+ } else {
+ // invalid because no match
+ break;
+ }
+ }
+
+ // accept a ! or ? at the end of the slice as a method name
+ if (*source == '!' || *source == '?' || *source == '=') {
+ source++;
+ result = PM_SLICE_TYPE_METHOD_NAME;
+ }
+
+ // valid if we are at the end of the slice
+ return source == end ? result : PM_SLICE_TYPE_NONE;
+}
+
+/**
+ * Check that the slice is a valid local variable name.
+ */
+pm_string_query_t
+pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) {
+ switch (pm_slice_type(source, length, encoding_name)) {
+ case PM_SLICE_TYPE_ERROR:
+ return PM_STRING_QUERY_ERROR;
+ case PM_SLICE_TYPE_NONE:
+ case PM_SLICE_TYPE_CONSTANT:
+ case PM_SLICE_TYPE_METHOD_NAME:
+ return PM_STRING_QUERY_FALSE;
+ case PM_SLICE_TYPE_LOCAL:
+ return PM_STRING_QUERY_TRUE;
+ }
+
+ assert(false && "unreachable");
+ return PM_STRING_QUERY_FALSE;
+}
+
+/**
+ * Check that the slice is a valid constant name.
+ */
+pm_string_query_t
+pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) {
+ switch (pm_slice_type(source, length, encoding_name)) {
+ case PM_SLICE_TYPE_ERROR:
+ return PM_STRING_QUERY_ERROR;
+ case PM_SLICE_TYPE_NONE:
+ case PM_SLICE_TYPE_LOCAL:
+ case PM_SLICE_TYPE_METHOD_NAME:
+ return PM_STRING_QUERY_FALSE;
+ case PM_SLICE_TYPE_CONSTANT:
+ return PM_STRING_QUERY_TRUE;
+ }
+
+ assert(false && "unreachable");
+ return PM_STRING_QUERY_FALSE;
+}
+
+/**
+ * Check that the slice is a valid method name.
+ */
+pm_string_query_t
+pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) {
+#define B(p) ((p) ? PM_STRING_QUERY_TRUE : PM_STRING_QUERY_FALSE)
+#define C1(c) (*source == c)
+#define C2(s) (memcmp(source, s, 2) == 0)
+#define C3(s) (memcmp(source, s, 3) == 0)
+
+ switch (pm_slice_type(source, length, encoding_name)) {
+ case PM_SLICE_TYPE_ERROR:
+ return PM_STRING_QUERY_ERROR;
+ case PM_SLICE_TYPE_NONE:
+ break;
+ case PM_SLICE_TYPE_LOCAL:
+ // numbered parameters are not valid method names
+ return B((length != 2) || (source[0] != '_') || (source[1] == '0') || !pm_char_is_decimal_digit(source[1]));
+ case PM_SLICE_TYPE_CONSTANT:
+ // all constants are valid method names
+ case PM_SLICE_TYPE_METHOD_NAME:
+ // all method names are valid method names
+ return PM_STRING_QUERY_TRUE;
+ }
+
+ switch (length) {
+ case 1:
+ return B(C1('&') || C1('`') || C1('!') || C1('^') || C1('>') || C1('<') || C1('-') || C1('%') || C1('|') || C1('+') || C1('/') || C1('*') || C1('~'));
+ case 2:
+ return B(C2("!=") || C2("!~") || C2("[]") || C2("==") || C2("=~") || C2(">=") || C2(">>") || C2("<=") || C2("<<") || C2("**"));
+ case 3:
+ return B(C3("===") || C3("<=>") || C3("[]="));
+ default:
+ return PM_STRING_QUERY_FALSE;
+ }
+
+#undef B
+#undef C1
+#undef C2
+#undef C3
+}
diff --git a/prism/string_query.h b/prism/string_query.h
new file mode 100644
index 0000000000..6ee1a9d9b6
--- /dev/null
+++ b/prism/string_query.h
@@ -0,0 +1,63 @@
+/**
+ * @file string_query.h
+ *
+ * Functions for querying properties of strings, such as whether they are valid
+ * local variable names, constant names, or method names.
+ */
+#ifndef PRISM_STRING_QUERY_H
+#define PRISM_STRING_QUERY_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * Represents the results of a slice query.
+ */
+typedef enum {
+ /** Returned if the encoding given to a slice query was invalid. */
+ PM_STRING_QUERY_ERROR = -1,
+
+ /** Returned if the result of the slice query is false. */
+ PM_STRING_QUERY_FALSE,
+
+ /** Returned if the result of the slice query is true. */
+ PM_STRING_QUERY_TRUE
+} pm_string_query_t;
+
+/**
+ * Check that the slice is a valid local variable name.
+ *
+ * @param source The source to check.
+ * @param length The length of the source.
+ * @param encoding_name The name of the encoding of the source.
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
+ */
+PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
+
+/**
+ * Check that the slice is a valid constant name.
+ *
+ * @param source The source to check.
+ * @param length The length of the source.
+ * @param encoding_name The name of the encoding of the source.
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
+ */
+PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
+
+/**
+ * Check that the slice is a valid method name.
+ *
+ * @param source The source to check.
+ * @param length The length of the source.
+ * @param encoding_name The name of the encoding of the source.
+ * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
+ * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
+ */
+PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
+
+#endif
diff --git a/prism/stringy.c b/prism/stringy.c
new file mode 100644
index 0000000000..d6f4c4a777
--- /dev/null
+++ b/prism/stringy.c
@@ -0,0 +1,91 @@
+#include "prism/internal/stringy.h"
+
+#include "prism/internal/allocator.h"
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Initialize a shared string that is based on initial input.
+ */
+void
+pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end) {
+ assert(start <= end);
+
+ *string = (pm_string_t) {
+ .type = PM_STRING_SHARED,
+ .source = start,
+ .length = (size_t) (end - start)
+ };
+}
+
+/**
+ * Initialize an owned string that is responsible for freeing allocated memory.
+ */
+void
+pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) {
+ *string = (pm_string_t) {
+ .type = PM_STRING_OWNED,
+ .source = source,
+ .length = length
+ };
+}
+
+/**
+ * Initialize a constant string that doesn't own its memory source.
+ */
+void
+pm_string_constant_init(pm_string_t *string, const char *source, size_t length) {
+ *string = (pm_string_t) {
+ .type = PM_STRING_CONSTANT,
+ .source = (const uint8_t *) source,
+ .length = length
+ };
+}
+
+/**
+ * Compare the underlying lengths and bytes of two strings. Returns 0 if the
+ * strings are equal, a negative number if the left string is less than the
+ * right string, and a positive number if the left string is greater than the
+ * right string.
+ */
+int
+pm_string_compare(const pm_string_t *left, const pm_string_t *right) {
+ size_t left_length = pm_string_length(left);
+ size_t right_length = pm_string_length(right);
+
+ if (left_length < right_length) {
+ return -1;
+ } else if (left_length > right_length) {
+ return 1;
+ }
+
+ return memcmp(pm_string_source(left), pm_string_source(right), left_length);
+}
+
+/**
+ * Returns the length associated with the string.
+ */
+size_t
+pm_string_length(const pm_string_t *string) {
+ return string->length;
+}
+
+/**
+ * Returns the start pointer associated with the string.
+ */
+const uint8_t *
+pm_string_source(const pm_string_t *string) {
+ return string->source;
+}
+
+/**
+ * Free the associated memory of the given string.
+ */
+void
+pm_string_cleanup(pm_string_t *string) {
+ if (string->type == PM_STRING_OWNED) {
+ xfree_sized((void *) string->source, string->length);
+ }
+}
diff --git a/prism/stringy.h b/prism/stringy.h
new file mode 100644
index 0000000000..0d64387ac3
--- /dev/null
+++ b/prism/stringy.h
@@ -0,0 +1,72 @@
+/**
+ * @file stringy.h
+ *
+ * A generic string type that can have various ownership semantics.
+ */
+#ifndef PRISM_STRINGY_H
+#define PRISM_STRINGY_H
+
+#include "prism/compiler/exported.h"
+#include "prism/compiler/nonnull.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * A generic string type that can have various ownership semantics.
+ */
+typedef struct {
+ /** A pointer to the start of the string. */
+ const uint8_t *source;
+
+ /** The length of the string in bytes of memory. */
+ size_t length;
+
+ /** The type of the string. This field determines how the string should be freed. */
+ enum {
+ /** This string is a constant string, and should not be freed. */
+ PM_STRING_CONSTANT,
+
+ /** This is a slice of another string, and should not be freed. */
+ PM_STRING_SHARED,
+
+ /** This string owns its memory, and should be freed internally. */
+ PM_STRING_OWNED
+ } type;
+} pm_string_t;
+
+/**
+ * Initialize a constant string that doesn't own its memory source.
+ *
+ * @param string The string to initialize.
+ * @param source The source of the string.
+ * @param length The length of the string.
+ */
+PRISM_EXPORTED_FUNCTION void pm_string_constant_init(pm_string_t *string, const char *source, size_t length) PRISM_NONNULL(1);
+
+/**
+ * Initialize an owned string that is responsible for freeing allocated memory.
+ *
+ * @param string The string to initialize.
+ * @param source The source of the string.
+ * @param length The length of the string.
+ */
+PRISM_EXPORTED_FUNCTION void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) PRISM_NONNULL(1, 2);
+
+/**
+ * Returns the length associated with the string.
+ *
+ * @param string The string to get the length of.
+ * @returns The length of the string.
+ */
+PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string) PRISM_NONNULL(1);
+
+/**
+ * Returns the start pointer associated with the string.
+ *
+ * @param string The string to get the start pointer of.
+ * @returns The start pointer of the string.
+ */
+PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string) PRISM_NONNULL(1);
+
+#endif
diff --git a/prism/strncasecmp.c b/prism/strncasecmp.c
new file mode 100644
index 0000000000..a373cad6d7
--- /dev/null
+++ b/prism/strncasecmp.c
@@ -0,0 +1,37 @@
+#include "prism/internal/strncasecmp.h"
+
+#include "prism/compiler/inline.h"
+
+/**
+ * A locale-insensitive version of `tolower(3)`
+ */
+static PRISM_INLINE int
+pm_tolower(int c) {
+ if ('A' <= c && c <= 'Z') {
+ return c | 0x20;
+ }
+ return c;
+}
+
+/**
+ * Compare two strings, ignoring case, up to the given length. Returns 0 if the
+ * strings are equal, a negative number if string1 is less than string2, or a
+ * positive number if string1 is greater than string2.
+ *
+ * Note that this is effectively our own implementation of strncasecmp, but it's
+ * not available on all of the platforms we want to support so we're rolling it
+ * here.
+ */
+int
+pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
+ size_t offset = 0;
+ int difference = 0;
+
+ while (offset < length && string1[offset] != '\0') {
+ if (string2[offset] == '\0') return string1[offset];
+ if ((difference = pm_tolower(string1[offset]) - pm_tolower(string2[offset])) != 0) return difference;
+ offset++;
+ }
+
+ return difference;
+}
diff --git a/prism/strpbrk.c b/prism/strpbrk.c
new file mode 100644
index 0000000000..383707eb72
--- /dev/null
+++ b/prism/strpbrk.c
@@ -0,0 +1,439 @@
+#include "prism/internal/strpbrk.h"
+
+#include "prism/compiler/accel.h"
+#include "prism/compiler/inline.h"
+#include "prism/compiler/unused.h"
+
+#include "prism/internal/bit.h"
+#include "prism/internal/diagnostic.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/parser.h"
+
+#include <assert.h>
+#include <stdbool.h>
+#include <string.h>
+
+/**
+ * Add an invalid multibyte character error to the parser.
+ */
+static PRISM_INLINE void
+pm_strpbrk_invalid_multibyte_character(pm_parser_t *parser, uint32_t start, uint32_t length) {
+ pm_diagnostic_list_append_format(&parser->metadata_arena, &parser->error_list, start, length, PM_ERR_INVALID_MULTIBYTE_CHARACTER, parser->start[start]);
+}
+
+/**
+ * Set the explicit encoding for the parser to the current encoding.
+ */
+static PRISM_INLINE void
+pm_strpbrk_explicit_encoding_set(pm_parser_t *parser, uint32_t start, uint32_t length) {
+ if (parser->explicit_encoding != NULL) {
+ if (parser->explicit_encoding == parser->encoding) {
+ // Okay, we already locked to this encoding.
+ } else if (parser->explicit_encoding == PM_ENCODING_UTF_8_ENTRY) {
+ // Not okay, we already found a Unicode escape sequence and this
+ // conflicts.
+ pm_diagnostic_list_append_format(&parser->metadata_arena, &parser->error_list, start, length, PM_ERR_MIXED_ENCODING, parser->encoding->name);
+ } else {
+ // Should not be anything else.
+ assert(false && "unreachable");
+ }
+ }
+
+ parser->explicit_encoding = parser->encoding;
+}
+
+/**
+ * Scan forward through ASCII bytes looking for a byte that is in the given
+ * charset. Returns true if a match was found, storing its offset in *index.
+ * Returns false if no match was found, storing the number of ASCII bytes
+ * consumed in *index (so the caller can skip past them).
+ *
+ * All charset characters must be ASCII (< 0x80). The scanner stops at non-ASCII
+ * bytes, returning control to the caller's encoding-aware loop.
+ *
+ * Up to three optimized implementations are selected at compile time, with a
+ * no-op fallback for unsupported platforms:
+ * 1. NEON — processes 16 bytes per iteration on aarch64.
+ * 2. SSSE3 — processes 16 bytes per iteration on x86-64.
+ * 3. SWAR — little-endian fallback, processes 8 bytes per iteration.
+ */
+
+#if defined(PRISM_HAS_NEON) || defined(PRISM_HAS_SSSE3) || defined(PRISM_HAS_SWAR)
+
+/**
+ * Update the cached strpbrk lookup tables if the charset has changed. The
+ * parser caches the last charset's precomputed tables so that repeated calls
+ * with the same breakpoints (the common case during string/regex/list lexing)
+ * skip table construction entirely.
+ *
+ * Builds three structures:
+ * - low_lut/high_lut: nibble-based lookup tables for SIMD matching (NEON/SSSE3)
+ * - table: 256-bit bitmap for scalar fallback matching (all platforms)
+ */
+static PRISM_INLINE void
+pm_strpbrk_cache_update(pm_parser_t *parser, const uint8_t *charset) {
+ // The cache key is the full charset buffer (PM_STRPBRK_CACHE_SIZE bytes).
+ // Since it is always NUL-padded, a fixed-size comparison covers both
+ // content and length.
+ if (memcmp(parser->strpbrk_cache.charset, charset, sizeof(parser->strpbrk_cache.charset)) == 0) return;
+
+ memset(parser->strpbrk_cache.low_lut, 0, sizeof(parser->strpbrk_cache.low_lut));
+ memset(parser->strpbrk_cache.high_lut, 0, sizeof(parser->strpbrk_cache.high_lut));
+ memset(parser->strpbrk_cache.table, 0, sizeof(parser->strpbrk_cache.table));
+
+ // Always include NUL in the tables. The slow path uses strchr, which
+ // always matches NUL (it finds the C string terminator), so NUL is
+ // effectively always a breakpoint. Replicating that here lets the fast
+ // scanner handle NUL at full speed instead of bailing to the slow path.
+ parser->strpbrk_cache.low_lut[0x00] |= (uint8_t) (1 << 0);
+ parser->strpbrk_cache.high_lut[0x00] = (uint8_t) (1 << 0);
+ parser->strpbrk_cache.table[0] |= (uint64_t) 1;
+
+ size_t charset_len = 0;
+ for (const uint8_t *c = charset; *c != '\0'; c++) {
+ parser->strpbrk_cache.low_lut[*c & 0x0F] |= (uint8_t) (1 << (*c >> 4));
+ parser->strpbrk_cache.high_lut[*c >> 4] = (uint8_t) (1 << (*c >> 4));
+ parser->strpbrk_cache.table[*c >> 6] |= (uint64_t) 1 << (*c & 0x3F);
+ charset_len++;
+ }
+
+ // Store the new charset key, NUL-padded to the full buffer size.
+ memcpy(parser->strpbrk_cache.charset, charset, charset_len + 1);
+ memset(parser->strpbrk_cache.charset + charset_len + 1, 0, sizeof(parser->strpbrk_cache.charset) - charset_len - 1);
+}
+
+#endif
+
+#if defined(PRISM_HAS_NEON)
+#include <arm_neon.h>
+
+static PRISM_INLINE bool
+scan_strpbrk_ascii(pm_parser_t *parser, const uint8_t *source, size_t maximum, const uint8_t *charset, size_t *index) {
+ pm_strpbrk_cache_update(parser, charset);
+
+ uint8x16_t low_lut = vld1q_u8(parser->strpbrk_cache.low_lut);
+ uint8x16_t high_lut = vld1q_u8(parser->strpbrk_cache.high_lut);
+ uint8x16_t mask_0f = vdupq_n_u8(0x0F);
+ uint8x16_t mask_80 = vdupq_n_u8(0x80);
+
+ size_t idx = 0;
+
+ while (idx + 16 <= maximum) {
+ uint8x16_t v = vld1q_u8(source + idx);
+
+ // If any byte has the high bit set, we have non-ASCII data.
+ // Return to let the caller's encoding-aware loop handle it.
+ if (vmaxvq_u8(vandq_u8(v, mask_80)) != 0) break;
+
+ uint8x16_t lo_class = vqtbl1q_u8(low_lut, vandq_u8(v, mask_0f));
+ uint8x16_t hi_class = vqtbl1q_u8(high_lut, vshrq_n_u8(v, 4));
+ uint8x16_t matched = vtstq_u8(lo_class, hi_class);
+
+ if (vmaxvq_u8(matched) == 0) {
+ idx += 16;
+ continue;
+ }
+
+ // Find the position of the first matching byte.
+ uint64_t lo64 = vgetq_lane_u64(vreinterpretq_u64_u8(matched), 0);
+ if (lo64 != 0) {
+ *index = idx + pm_ctzll(lo64) / 8;
+ return true;
+ }
+ uint64_t hi64 = vgetq_lane_u64(vreinterpretq_u64_u8(matched), 1);
+ *index = idx + 8 + pm_ctzll(hi64) / 8;
+ return true;
+ }
+
+ // Scalar tail for remaining < 16 ASCII bytes.
+ while (idx < maximum && source[idx] < 0x80) {
+ uint8_t byte = source[idx];
+ if (parser->strpbrk_cache.table[byte >> 6] & ((uint64_t) 1 << (byte & 0x3F))) {
+ *index = idx;
+ return true;
+ }
+ idx++;
+ }
+
+ *index = idx;
+ return false;
+}
+
+#elif defined(PRISM_HAS_SSSE3)
+#include <tmmintrin.h>
+
+static PRISM_INLINE bool
+scan_strpbrk_ascii(pm_parser_t *parser, const uint8_t *source, size_t maximum, const uint8_t *charset, size_t *index) {
+ pm_strpbrk_cache_update(parser, charset);
+
+ __m128i low_lut = _mm_loadu_si128((const __m128i *) parser->strpbrk_cache.low_lut);
+ __m128i high_lut = _mm_loadu_si128((const __m128i *) parser->strpbrk_cache.high_lut);
+ __m128i mask_0f = _mm_set1_epi8(0x0F);
+
+ size_t idx = 0;
+
+ while (idx + 16 <= maximum) {
+ __m128i v = _mm_loadu_si128((const __m128i *) (source + idx));
+
+ // If any byte has the high bit set, stop.
+ if (_mm_movemask_epi8(v) != 0) break;
+
+ // Nibble-based classification using pshufb (SSSE3), same as NEON
+ // vqtbl1q_u8. A byte matches iff (low_lut[lo_nib] & high_lut[hi_nib]) != 0.
+ __m128i lo_class = _mm_shuffle_epi8(low_lut, _mm_and_si128(v, mask_0f));
+ __m128i hi_class = _mm_shuffle_epi8(high_lut, _mm_and_si128(_mm_srli_epi16(v, 4), mask_0f));
+ __m128i matched = _mm_and_si128(lo_class, hi_class);
+
+ // Check if any byte matched.
+ int mask = _mm_movemask_epi8(_mm_cmpeq_epi8(matched, _mm_setzero_si128()));
+
+ if (mask == 0xFFFF) {
+ // All bytes were zero — no match in this chunk.
+ idx += 16;
+ continue;
+ }
+
+ // Find the first matching byte (first non-zero in matched).
+ *index = idx + pm_ctzll((uint64_t) (~mask & 0xFFFF));
+ return true;
+ }
+
+ // Scalar tail.
+ while (idx < maximum && source[idx] < 0x80) {
+ uint8_t byte = source[idx];
+ if (parser->strpbrk_cache.table[byte >> 6] & ((uint64_t) 1 << (byte & 0x3F))) {
+ *index = idx;
+ return true;
+ }
+ idx++;
+ }
+
+ *index = idx;
+ return false;
+}
+
+#elif defined(PRISM_HAS_SWAR)
+
+static PRISM_INLINE bool
+scan_strpbrk_ascii(pm_parser_t *parser, const uint8_t *source, size_t maximum, const uint8_t *charset, size_t *index) {
+ pm_strpbrk_cache_update(parser, charset);
+
+ static const uint64_t highs = 0x8080808080808080ULL;
+ size_t idx = 0;
+
+ while (idx + 8 <= maximum) {
+ uint64_t word;
+ memcpy(&word, source + idx, 8);
+
+ // Bail on any non-ASCII byte.
+ if (word & highs) break;
+
+ // Check each byte against the charset table.
+ for (size_t j = 0; j < 8; j++) {
+ uint8_t byte = source[idx + j];
+ if (parser->strpbrk_cache.table[byte >> 6] & ((uint64_t) 1 << (byte & 0x3F))) {
+ *index = idx + j;
+ return true;
+ }
+ }
+
+ idx += 8;
+ }
+
+ // Scalar tail.
+ while (idx < maximum && source[idx] < 0x80) {
+ uint8_t byte = source[idx];
+ if (parser->strpbrk_cache.table[byte >> 6] & ((uint64_t) 1 << (byte & 0x3F))) {
+ *index = idx;
+ return true;
+ }
+ idx++;
+ }
+
+ *index = idx;
+ return false;
+}
+
+#else
+
+static PRISM_INLINE bool
+scan_strpbrk_ascii(PRISM_UNUSED pm_parser_t *parser, PRISM_UNUSED const uint8_t *source, PRISM_UNUSED size_t maximum, PRISM_UNUSED const uint8_t *charset, size_t *index) {
+ *index = 0;
+ return false;
+}
+
+#endif
+
+/**
+ * This is the default path.
+ */
+static PRISM_INLINE const uint8_t *
+pm_strpbrk_utf8(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t index, size_t maximum, bool validate) {
+ while (index < maximum) {
+ if (strchr((const char *) charset, source[index]) != NULL) {
+ return source + index;
+ }
+
+ if (source[index] < 0x80) {
+ index++;
+ } else {
+ size_t width = pm_encoding_utf_8_char_width(source + index, (ptrdiff_t) (maximum - index));
+
+ if (width > 0) {
+ index += width;
+ } else if (!validate) {
+ index++;
+ } else {
+ // At this point we know we have an invalid multibyte character.
+ // We'll walk forward as far as we can until we find the next
+ // valid character so that we don't spam the user with a ton of
+ // the same kind of error.
+ const size_t start = index;
+
+ do {
+ index++;
+ } while (index < maximum && pm_encoding_utf_8_char_width(source + index, (ptrdiff_t) (maximum - index)) == 0);
+
+ pm_strpbrk_invalid_multibyte_character(parser, (uint32_t) ((source + start) - parser->start), (uint32_t) (index - start));
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * This is the path when the encoding is ASCII-8BIT.
+ */
+static PRISM_INLINE const uint8_t *
+pm_strpbrk_ascii_8bit(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t index, size_t maximum, bool validate) {
+ while (index < maximum) {
+ if (strchr((const char *) charset, source[index]) != NULL) {
+ return source + index;
+ }
+
+ if (validate && source[index] >= 0x80) pm_strpbrk_explicit_encoding_set(parser, (uint32_t) (source - parser->start), 1);
+ index++;
+ }
+
+ return NULL;
+}
+
+/**
+ * This is the slow path that does care about the encoding.
+ */
+static PRISM_INLINE const uint8_t *
+pm_strpbrk_multi_byte(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t index, size_t maximum, bool validate) {
+ const pm_encoding_t *encoding = parser->encoding;
+
+ while (index < maximum) {
+ if (strchr((const char *) charset, source[index]) != NULL) {
+ return source + index;
+ }
+
+ if (source[index] < 0x80) {
+ index++;
+ } else {
+ size_t width = encoding->char_width(source + index, (ptrdiff_t) (maximum - index));
+ if (validate) pm_strpbrk_explicit_encoding_set(parser, (uint32_t) (source - parser->start), (uint32_t) width);
+
+ if (width > 0) {
+ index += width;
+ } else if (!validate) {
+ index++;
+ } else {
+ // At this point we know we have an invalid multibyte character.
+ // We'll walk forward as far as we can until we find the next
+ // valid character so that we don't spam the user with a ton of
+ // the same kind of error.
+ const size_t start = index;
+
+ do {
+ index++;
+ } while (index < maximum && encoding->char_width(source + index, (ptrdiff_t) (maximum - index)) == 0);
+
+ pm_strpbrk_invalid_multibyte_character(parser, (uint32_t) ((source + start) - parser->start), (uint32_t) (index - start));
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * This is the fast path that does not care about the encoding because we know
+ * the encoding only supports single-byte characters.
+ */
+static PRISM_INLINE const uint8_t *
+pm_strpbrk_single_byte(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t index, size_t maximum, bool validate) {
+ const pm_encoding_t *encoding = parser->encoding;
+
+ while (index < maximum) {
+ if (strchr((const char *) charset, source[index]) != NULL) {
+ return source + index;
+ }
+
+ if (source[index] < 0x80 || !validate) {
+ index++;
+ } else {
+ size_t width = encoding->char_width(source + index, (ptrdiff_t) (maximum - index));
+ pm_strpbrk_explicit_encoding_set(parser, (uint32_t) (source - parser->start), (uint32_t) width);
+
+ if (width > 0) {
+ index += width;
+ } else {
+ // At this point we know we have an invalid multibyte character.
+ // We'll walk forward as far as we can until we find the next
+ // valid character so that we don't spam the user with a ton of
+ // the same kind of error.
+ const size_t start = index;
+
+ do {
+ index++;
+ } while (index < maximum && encoding->char_width(source + index, (ptrdiff_t) (maximum - index)) == 0);
+
+ pm_strpbrk_invalid_multibyte_character(parser, (uint32_t) ((source + start) - parser->start), (uint32_t) (index - start));
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Here we have rolled our own version of strpbrk. The standard library strpbrk
+ * has undefined behavior when the source string is not null-terminated. We want
+ * to support strings that are not null-terminated because pm_parse does not
+ * have the contract that the string is null-terminated. (This is desirable
+ * because it means the extension can call pm_parse with the result of a call to
+ * mmap).
+ *
+ * The standard library strpbrk also does not support passing a maximum length
+ * to search. We want to support this for the reason mentioned above, but we
+ * also don't want it to stop on null bytes. Ruby actually allows null bytes
+ * within strings, comments, regular expressions, etc. So we need to be able to
+ * skip past them.
+ *
+ * Finally, we want to support encodings wherein the charset could contain
+ * characters that are trailing bytes of multi-byte characters. For example, in
+ * Shift_JIS, the backslash character can be a trailing byte. In that case we
+ * need to take a slower path and iterate one multi-byte character at a time.
+ */
+const uint8_t *
+pm_strpbrk(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, ptrdiff_t length, bool validate) {
+ if (length <= 0) return NULL;
+
+ size_t maximum = (size_t) length;
+ size_t index = 0;
+ if (scan_strpbrk_ascii(parser, source, maximum, charset, &index)) return source + index;
+
+ if (!parser->encoding_changed) {
+ return pm_strpbrk_utf8(parser, source, charset, index, maximum, validate);
+ } else if (parser->encoding == PM_ENCODING_ASCII_8BIT_ENTRY) {
+ return pm_strpbrk_ascii_8bit(parser, source, charset, index, maximum, validate);
+ } else if (parser->encoding->multibyte) {
+ return pm_strpbrk_multi_byte(parser, source, charset, index, maximum, validate);
+ } else {
+ return pm_strpbrk_single_byte(parser, source, charset, index, maximum, validate);
+ }
+}
diff --git a/prism/templates/ext/prism/api_node.c.erb b/prism/templates/ext/prism/api_node.c.erb
new file mode 100644
index 0000000000..41d7165930
--- /dev/null
+++ b/prism/templates/ext/prism/api_node.c.erb
@@ -0,0 +1,296 @@
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+#include "prism/extension.h"
+#include "prism/internal/allocator.h"
+#include "prism/internal/arena.h"
+
+#include <assert.h>
+
+extern VALUE rb_cPrism;
+extern VALUE rb_cPrismNode;
+extern VALUE rb_cPrismSource;
+extern VALUE rb_cPrismToken;
+extern VALUE rb_cPrismLocation;
+
+<%- nodes.each do |node| -%>
+static VALUE rb_cPrism<%= node.name %>;
+<%- end -%>
+
+static VALUE
+pm_location_new(const uint32_t start, const uint32_t length, VALUE source, bool freeze) {
+ if (freeze) {
+ VALUE location_argv[] = { source, LONG2FIX(start), LONG2FIX(length) };
+ return rb_obj_freeze(rb_class_new_instance(3, location_argv, rb_cPrismLocation));
+ } else {
+ uint64_t value = ((((uint64_t) start) << 32) | ((uint64_t) length));
+ return ULL2NUM(value);
+ }
+}
+
+VALUE
+pm_token_new(const pm_parser_t *parser, const pm_token_t *token, rb_encoding *encoding, VALUE source, bool freeze) {
+ ID type = rb_intern(pm_token_type(token->type));
+ VALUE location = pm_location_new((uint32_t) (token->start - pm_parser_start(parser)), (uint32_t) (token->end - token->start), source, freeze);
+
+ VALUE slice = rb_enc_str_new((const char *) token->start, token->end - token->start, encoding);
+ if (freeze) rb_obj_freeze(slice);
+
+ VALUE argv[] = { source, ID2SYM(type), slice, location };
+ VALUE value = rb_class_new_instance(4, argv, rb_cPrismToken);
+ if (freeze) rb_obj_freeze(value);
+
+ return value;
+}
+
+static VALUE
+pm_string_new(const pm_string_t *string, rb_encoding *encoding) {
+ return rb_obj_freeze(rb_enc_str_new((const char *) pm_string_source(string), pm_string_length(string), encoding));
+}
+
+VALUE
+pm_integer_new(const pm_integer_t *integer) {
+ VALUE result;
+ if (integer->values == NULL) {
+ result = UINT2NUM(integer->value);
+ } else {
+ VALUE string = rb_str_new(NULL, integer->length * 8);
+ unsigned char *bytes = (unsigned char *) RSTRING_PTR(string);
+
+ size_t offset = integer->length * 8;
+ for (size_t value_index = 0; value_index < integer->length; value_index++) {
+ uint32_t value = integer->values[value_index];
+
+ for (int index = 0; index < 8; index++) {
+ int byte = (value >> (4 * index)) & 0xf;
+ bytes[--offset] = byte < 10 ? byte + '0' : byte - 10 + 'a';
+ }
+ }
+
+ result = rb_funcall(string, rb_intern("to_i"), 1, UINT2NUM(16));
+ }
+
+ if (integer->negative) {
+ result = rb_funcall(result, rb_intern("-@"), 0);
+ }
+
+ return result;
+}
+
+// Create a Prism::Source object from the given parser, after pm_parse() was called.
+VALUE
+pm_source_new(const pm_parser_t *parser, rb_encoding *encoding, bool freeze) {
+ const uint8_t *start = pm_parser_start(parser);
+ VALUE source_string = rb_enc_str_new((const char *) start, pm_parser_end(parser) - start, encoding);
+
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+ VALUE offsets;
+
+ if (freeze) {
+ offsets = rb_ary_new_capa(line_offsets->size);
+ for (size_t index = 0; index < line_offsets->size; index++) {
+ rb_ary_push(offsets, ULONG2NUM(line_offsets->offsets[index]));
+ }
+
+ rb_obj_freeze(source_string);
+ rb_obj_freeze(offsets);
+ } else {
+ offsets = rb_str_new((const char *) line_offsets->offsets, line_offsets->size * sizeof(uint32_t));
+ }
+
+ VALUE source = rb_funcall(rb_cPrismSource, rb_intern("for"), 3, source_string, LONG2NUM(pm_parser_start_line(parser)), offsets);
+ if (freeze) rb_obj_freeze(source);
+
+ return source;
+}
+
+typedef struct pm_node_stack_node {
+ struct pm_node_stack_node *prev;
+ const pm_node_t *visit;
+ bool visited;
+} pm_node_stack_node_t;
+
+static void
+pm_node_stack_push(pm_arena_t *arena, pm_node_stack_node_t **stack, const pm_node_t *visit) {
+ pm_node_stack_node_t *node = (pm_node_stack_node_t *) pm_arena_alloc(arena, sizeof(pm_node_stack_node_t), PRISM_ALIGNOF(pm_node_stack_node_t));
+ node->prev = *stack;
+ node->visit = visit;
+ node->visited = false;
+ *stack = node;
+}
+
+static const pm_node_t *
+pm_node_stack_pop(pm_node_stack_node_t **stack) {
+ pm_node_stack_node_t *current = *stack;
+ const pm_node_t *visit = current->visit;
+
+ *stack = current->prev;
+
+ return visit;
+}
+
+typedef struct {
+ VALUE constants;
+ rb_encoding *encoding;
+} pm_ast_constants_each_data_t;
+
+static void
+pm_ast_constants_each(const pm_constant_t *constant, void *data) {
+ pm_ast_constants_each_data_t *constants_data = (pm_ast_constants_each_data_t *) data;
+ int state = 0;
+
+ VALUE string = rb_enc_str_new((const char *) pm_constant_start(constant), pm_constant_length(constant), constants_data->encoding);
+ VALUE value = rb_protect(rb_str_intern, string, &state);
+
+ if (state != 0) {
+ value = ID2SYM(rb_intern_const("?"));
+ rb_set_errinfo(Qnil);
+ }
+
+ rb_ary_push(constants_data->constants, value);
+}
+
+VALUE
+pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encoding, VALUE source, bool freeze) {
+ VALUE constants = rb_ary_new_capa(pm_parser_constants_size(parser));
+ pm_ast_constants_each_data_t constants_data = { .constants = constants, .encoding = encoding };
+ pm_parser_constants_each(parser, pm_ast_constants_each, &constants_data);
+
+ pm_arena_t *node_arena = pm_arena_new();
+ pm_node_stack_node_t *node_stack = NULL;
+ pm_node_stack_push(node_arena, &node_stack, node);
+ VALUE value_stack = rb_ary_new();
+
+ while (node_stack != NULL) {
+ if (!node_stack->visited) {
+ if (node_stack->visit == NULL) {
+ pm_node_stack_pop(&node_stack);
+ rb_ary_push(value_stack, Qnil);
+ continue;
+ }
+
+ const pm_node_t *node = node_stack->visit;
+ node_stack->visited = true;
+
+ switch (PM_NODE_TYPE(node)) {
+ <%- nodes.each do |node| -%>
+ <%- if node.fields.any? { |field| [Prism::Template::NodeField, Prism::Template::OptionalNodeField, Prism::Template::NodeListField].include?(field.class) } -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ case <%= node.type %>: {
+ pm_<%= node.human %>_t *cast = (pm_<%= node.human %>_t *) node;
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField, Prism::Template::OptionalNodeField -%>
+ pm_node_stack_push(node_arena, &node_stack, (pm_node_t *) cast-><%= field.name %>);
+ <%- when Prism::Template::NodeListField -%>
+ for (size_t index = 0; index < cast-><%= field.name %>.size; index++) {
+ pm_node_stack_push(node_arena, &node_stack, (pm_node_t *) cast-><%= field.name %>.nodes[index]);
+ }
+ <%- end -%>
+ <%- end -%>
+ break;
+ }
+ <%- end -%>
+ <%- end -%>
+ default:
+ break;
+ }
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ } else {
+ const pm_node_t *node = pm_node_stack_pop(&node_stack);
+
+ switch (PM_NODE_TYPE(node)) {
+ <%- nodes.each do |node| -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ case <%= node.type %>: {
+ <%- if node.fields.any? { |field| ![Prism::Template::NodeField, Prism::Template::OptionalNodeField].include?(field.class) } -%>
+ pm_<%= node.human %>_t *cast = (pm_<%= node.human %>_t *) node;
+ <%- end -%>
+ VALUE argv[<%= node.fields.length + 4 %>];
+
+ // source
+ argv[0] = source;
+
+ // node_id
+ argv[1] = ULONG2NUM(node->node_id);
+
+ // location
+ argv[2] = pm_location_new(node->location.start, node->location.length, source, freeze);
+
+ // flags
+ argv[3] = ULONG2NUM(node->flags);
+ <%- node.fields.each.with_index(4) do |field, index| -%>
+
+ // <%= field.name %>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField, Prism::Template::OptionalNodeField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = rb_ary_pop(value_stack);
+ <%- when Prism::Template::NodeListField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = rb_ary_new_capa(cast-><%= field.name %>.size);
+ for (size_t index = 0; index < cast-><%= field.name %>.size; index++) {
+ rb_ary_push(argv[<%= index %>], rb_ary_pop(value_stack));
+ }
+ if (freeze) rb_obj_freeze(argv[<%= index %>]);
+ <%- when Prism::Template::StringField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = pm_string_new(&cast-><%= field.name %>, encoding);
+ <%- when Prism::Template::ConstantField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ assert(cast-><%= field.name %> != 0);
+ argv[<%= index %>] = RARRAY_AREF(constants, cast-><%= field.name %> - 1);
+ <%- when Prism::Template::OptionalConstantField -%>
+ argv[<%= index %>] = cast-><%= field.name %> == 0 ? Qnil : RARRAY_AREF(constants, cast-><%= field.name %> - 1);
+ <%- when Prism::Template::ConstantListField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = rb_ary_new_capa(cast-><%= field.name %>.size);
+ for (size_t index = 0; index < cast-><%= field.name %>.size; index++) {
+ assert(cast-><%= field.name %>.ids[index] != 0);
+ rb_ary_push(argv[<%= index %>], RARRAY_AREF(constants, cast-><%= field.name %>.ids[index] - 1));
+ }
+ if (freeze) rb_obj_freeze(argv[<%= index %>]);
+ <%- when Prism::Template::LocationField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = pm_location_new(cast-><%= field.name %>.start, cast-><%= field.name %>.length, source, freeze);
+ <%- when Prism::Template::OptionalLocationField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = cast-><%= field.name %>.length == 0 ? Qnil : pm_location_new(cast-><%= field.name %>.start, cast-><%= field.name %>.length, source, freeze);
+ <%- when Prism::Template::UInt8Field -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = UINT2NUM(cast-><%= field.name %>);
+ <%- when Prism::Template::UInt32Field -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = ULONG2NUM(cast-><%= field.name %>);
+ <%- when Prism::Template::IntegerField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = pm_integer_new(&cast-><%= field.name %>);
+ <%- when Prism::Template::DoubleField -%>
+#line <%= __LINE__ + 1 %> "prism/templates/ext/prism/<%= File.basename(__FILE__) %>"
+ argv[<%= index %>] = DBL2NUM(cast-><%= field.name %>);
+ <%- else -%>
+ <%- raise -%>
+ <%- end -%>
+ <%- end -%>
+
+ VALUE value = rb_class_new_instance(<%= node.fields.length + 4 %>, argv, rb_cPrism<%= node.name %>);
+ if (freeze) rb_obj_freeze(value);
+
+ rb_ary_push(value_stack, value);
+ break;
+ }
+ <%- end -%>
+ default:
+ rb_raise(rb_eRuntimeError, "unknown node type: %d", PM_NODE_TYPE(node));
+ }
+ }
+ }
+
+ pm_arena_free(node_arena);
+ return rb_ary_pop(value_stack);
+}
+
+void
+Init_prism_api_node(void) {
+ <%- nodes.each do |node| -%>
+ rb_cPrism<%= node.name %> = rb_define_class_under(rb_cPrism, "<%= node.name %>", rb_cPrismNode);
+ <%- end -%>
+}
diff --git a/prism/templates/include/prism/ast.h.erb b/prism/templates/include/prism/ast.h.erb
new file mode 100644
index 0000000000..3b3be25e76
--- /dev/null
+++ b/prism/templates/include/prism/ast.h.erb
@@ -0,0 +1,278 @@
+/**
+ * @file ast.h
+ *
+ * The abstract syntax tree.
+ *
+ * --
+ */
+#ifndef PRISM_AST_H
+#define PRISM_AST_H
+
+#include "prism/compiler/align.h"
+#include "prism/compiler/exported.h"
+
+#include "prism/arena.h"
+#include "prism/constant_pool.h"
+#include "prism/integer.h"
+#include "prism/stringy.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * This enum represents every type of token in the Ruby source.
+ */
+typedef enum pm_token_type {
+<%- tokens.each do |token| -%>
+ /** <%= Prism::Template::Doxygen.verbatim(token.comment) %> */
+ PM_TOKEN_<%= token.name %><%= " = #{token.value}" if token.value %>,
+
+<%- end -%>
+ /** The maximum token value. */
+ PM_TOKEN_MAXIMUM,
+} pm_token_type_t;
+
+/**
+ * This struct represents a token in the Ruby source. We use it to track both
+ * type and location information.
+ */
+typedef struct {
+ /** The type of the token. */
+ pm_token_type_t type;
+
+ /** A pointer to the start location of the token in the source. */
+ const uint8_t *start;
+
+ /** A pointer to the end location of the token in the source. */
+ const uint8_t *end;
+} pm_token_t;
+
+/**
+ * Returns a string representation of the given token type.
+ *
+ * @param token_type The type of the token to get the string representation of.
+ * @returns A string representation of the given token type. This is meant for
+ * debugging purposes and is not guaranteed to be stable across versions.
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_token_type(pm_token_type_t token_type);
+
+/**
+ * This struct represents a slice in the source code, defined by an offset and
+ * a length. Note that we have confirmation that we can represent all locations
+ * within Ruby source files using 32-bit integers per:
+ *
+ * https://bugs.ruby-lang.org/issues/20488#note-1
+ *
+ */
+typedef struct {
+ /** The offset of the location from the start of the source. */
+ uint32_t start;
+
+ /** The length of the location. */
+ uint32_t length;
+} pm_location_t;
+
+struct pm_node;
+
+/**
+ * A list of nodes in the source, most often used for lists of children.
+ */
+typedef struct pm_node_list {
+ /** The number of nodes in the list. */
+ size_t size;
+
+ /** The capacity of the list that has been allocated. */
+ size_t capacity;
+
+ /** The nodes in the list. */
+ struct pm_node **nodes;
+} pm_node_list_t;
+
+/**
+ * This enum represents every type of node in the Ruby syntax tree.
+ */
+enum pm_node_type {
+<%- nodes.each_with_index do |node, index| -%>
+ /** <%= node.name %> */
+ <%= node.type %> = <%= index + 1 %>,
+
+<%- end -%>
+ /** A special kind of node used for compilation. */
+ PM_SCOPE_NODE
+};
+
+/**
+ * This is the type of node embedded in the node struct. We explicitly control
+ * the size of it here to avoid having the variable-width enum.
+ */
+typedef uint16_t pm_node_type_t;
+
+/**
+ * These are the flags embedded in the node struct. We explicitly control the
+ * size of it here to avoid having the variable-width enum.
+ */
+typedef uint16_t pm_node_flags_t;
+
+/**
+ * We store the flags enum in every node in the tree. Some flags are common to
+ * all nodes (the ones listed below). Others are specific to certain node types.
+ */
+static const pm_node_flags_t PM_NODE_FLAG_NEWLINE = 0x1;
+static const pm_node_flags_t PM_NODE_FLAG_STATIC_LITERAL = 0x2;
+
+/**
+ * This is the base structure that represents a node in the syntax tree. It is
+ * embedded into every node type.
+ */
+typedef struct pm_node {
+ /**
+ * This represents the type of the node. It somewhat maps to the nodes that
+ * existed in the original grammar and ripper, but it is not a 1:1 mapping.
+ */
+ pm_node_type_t type;
+
+ /**
+ * This represents any flags on the node. Some are common to all nodes, and
+ * some are specific to the type of node.
+ */
+ pm_node_flags_t flags;
+
+ /**
+ * The unique identifier for this node, which is deterministic based on the
+ * source. It is used to identify unique nodes across parses.
+ */
+ uint32_t node_id;
+
+ /**
+ * This is the location of the node in the source. It is a range of bytes
+ * containing a start and an end.
+ */
+ pm_location_t location;
+} pm_node_t;
+
+/**
+ * Cast the given node to the base pm_node_t type.
+ */
+#define PM_NODE_UPCAST(node_) ((pm_node_t *) (node_))
+
+/**
+ * Cast the type to an enum to allow the compiler to provide exhaustiveness
+ * checking.
+ */
+#define PM_NODE_TYPE(node_) ((enum pm_node_type) (node_)->type)
+
+/**
+ * Return true if the type of the given node matches the given type.
+ */
+#define PM_NODE_TYPE_P(node_, type_) (PM_NODE_TYPE(node_) == (type_))
+
+/**
+ * Return the flags associated with the given node.
+ */
+#define PM_NODE_FLAGS(node_) (PM_NODE_UPCAST(node_)->flags)
+
+/**
+ * Return true if the given flag is set on the given node.
+ */
+#define PM_NODE_FLAG_P(node_, flag_) ((PM_NODE_FLAGS(node_) & (flag_)) != 0)
+
+/**
+ * The alignment required for a child node within a parent node.
+ */
+#ifdef _MSC_VER
+#define PM_NODE_ALIGNAS __declspec(align(8))
+#else
+#define PM_NODE_ALIGNAS PRISM_ALIGNAS(PRISM_ALIGNOF(void *))
+#endif
+<%- nodes.each do |node| -%>
+
+/**
+ * <%= node.name %>
+ *
+<%- node.each_comment_line do |line| -%>
+ *<%= line %>
+<%- end -%>
+ *
+ * Type: ::<%= node.type %>
+<% if (node_flags = node.flags) %>
+ * Flags (#pm_<%= node_flags.human %>):
+<%- node_flags.values.each do |value| -%>
+ * * ::PM_<%= node_flags.human.upcase %>_<%= value.name %>
+<%- end -%>
+<%- end -%>
+ *
+ * @extends pm_node_t
+ */
+typedef struct pm_<%= node.human %> {
+ /** The embedded base node. */
+ pm_node_t base;
+<%- node.fields.each do |field| -%>
+
+ /**
+ * <%= node.name %>#<%= field.name %>
+ <%- if field.comment -%>
+ *
+ <%- field.each_comment_line do |line| -%>
+ *<%= line %>
+ <%- end -%>
+ <%- end -%>
+ */
+ <%= case field
+ when Prism::Template::NodeField, Prism::Template::OptionalNodeField then "PM_NODE_ALIGNAS struct #{field.c_type} *#{field.name}"
+ when Prism::Template::NodeListField then "struct pm_node_list #{field.name}"
+ when Prism::Template::ConstantField, Prism::Template::OptionalConstantField then "pm_constant_id_t #{field.name}"
+ when Prism::Template::ConstantListField then "pm_constant_id_list_t #{field.name}"
+ when Prism::Template::StringField then "pm_string_t #{field.name}"
+ when Prism::Template::LocationField, Prism::Template::OptionalLocationField then "pm_location_t #{field.name}"
+ when Prism::Template::UInt8Field then "uint8_t #{field.name}"
+ when Prism::Template::UInt32Field then "uint32_t #{field.name}"
+ when Prism::Template::IntegerField then "pm_integer_t #{field.name}"
+ when Prism::Template::DoubleField then "double #{field.name}"
+ else raise field.class.name
+ end
+ %>;
+<%- end -%>
+} pm_<%= node.human %>_t;
+<%- end -%>
+<%- flags.each do |flag| -%>
+
+/**
+ * <%= flag.comment %>
+ */
+typedef enum pm_<%= flag.human %> {
+ <%- flag.values.each_with_index do |value, index| -%>
+<%= "\n" if index > 0 -%>
+ /** <%= value.comment %> */
+ PM_<%= flag.human.upcase %>_<%= value.name %> = <%= 1 << (index + Prism::Template::COMMON_FLAGS_COUNT) %>,
+ <%- end -%>
+
+ PM_<%= flag.human.upcase %>_LAST,
+} pm_<%= flag.human %>_t;
+<%- end -%>
+<%- nodes.each do |node| -%>
+
+<%- params = node.fields.map(&:c_param) -%>
+/**
+ * Allocate and initialize a new <%= node.name %> node.
+ *
+ * @param arena The arena to allocate from.
+ * @param node_id The unique identifier for this node.
+ * @param flags The flags for this node.
+ * @param location The location of this node in the source.
+<%- node.fields.each do |field| -%>
+ * @param <%= field.name %> <%= field.comment ? Prism::Template::Doxygen.verbatim(field.comment.lines.first.strip) : "The #{field.name} field." %>
+<%- end -%>
+ * @returns The newly allocated and initialized node.
+ */
+PRISM_EXPORTED_FUNCTION pm_<%= node.human %>_t * pm_<%= node.human %>_new(pm_arena_t *arena, uint32_t node_id, pm_node_flags_t flags, pm_location_t location<%= params.empty? ? "" : ", #{params.join(", ")}" %>);
+<%- end -%>
+
+/**
+ * When we're serializing to Java, we want to skip serializing the location
+ * fields as they won't be used by JRuby or TruffleRuby. This boolean allows us
+ * to specify that through the environment. It will never be true except for in
+ * those build systems.
+ */
+#define PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS <%= Prism::Template::SERIALIZE_ONLY_SEMANTICS_FIELDS ? 1 : 0 %>
+
+#endif
diff --git a/prism/templates/include/prism/internal/diagnostic.h.erb b/prism/templates/include/prism/internal/diagnostic.h.erb
new file mode 100644
index 0000000000..ee44ff5382
--- /dev/null
+++ b/prism/templates/include/prism/internal/diagnostic.h.erb
@@ -0,0 +1,60 @@
+#ifndef PRISM_INTERNAL_DIAGNOSTIC_H
+#define PRISM_INTERNAL_DIAGNOSTIC_H
+
+#include "prism/internal/list.h"
+
+#include "prism/arena.h"
+#include "prism/diagnostic.h"
+
+/*
+ * The diagnostic IDs of all of the diagnostics, used to communicate the types
+ * of errors between the parser and the user.
+ */
+typedef enum {
+ /* These are the error diagnostics. */
+ <%- errors.each do |error| -%>
+ PM_ERR_<%= error.name %>,
+ <%- end -%>
+
+ /* These are the warning diagnostics. */
+ <%- warnings.each do |warning| -%>
+ PM_WARN_<%= warning.name %>,
+ <%- end -%>
+} pm_diagnostic_id_t;
+
+/*
+ * This struct represents a diagnostic generated during parsing.
+ */
+struct pm_diagnostic_t {
+ /* The embedded base node. */
+ pm_list_node_t node;
+
+ /* The location of the diagnostic in the source. */
+ pm_location_t location;
+
+ /* The ID of the diagnostic. */
+ pm_diagnostic_id_t diag_id;
+
+ /* The message associated with the diagnostic. */
+ const char *message;
+
+ /*
+ * The level of the diagnostic, see `pm_error_level_t` and
+ * `pm_warning_level_t` for possible values.
+ */
+ uint8_t level;
+};
+
+/*
+ * Append a diagnostic to the given list of diagnostics that is using shared
+ * memory for its message.
+ */
+void pm_diagnostic_list_append(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id);
+
+/*
+ * Append a diagnostic to the given list of diagnostics that is using a format
+ * string for its message.
+ */
+void pm_diagnostic_list_append_format(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id, ...);
+
+#endif
diff --git a/prism/templates/lib/prism/compiler.rb.erb b/prism/templates/lib/prism/compiler.rb.erb
new file mode 100644
index 0000000000..13317cac04
--- /dev/null
+++ b/prism/templates/lib/prism/compiler.rb.erb
@@ -0,0 +1,52 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # A compiler is a visitor that returns the value of each node as it visits.
+ # This is as opposed to a visitor which will only walk the tree. This can be
+ # useful when you are trying to compile a tree into a different format.
+ #
+ # For example, to build a representation of the tree as s-expressions, you
+ # could write:
+ #
+ # class SExpressions < Prism::Compiler
+ # def visit_arguments_node(node) = [:arguments, super]
+ # def visit_call_node(node) = [:call, super]
+ # def visit_integer_node(node) = [:integer]
+ # def visit_program_node(node) = [:program, super]
+ # end
+ #
+ # Prism.parse("1 + 2").value.accept(SExpressions.new)
+ # # => [:program, [[[:call, [[:integer], [:arguments, [[:integer]]]]]]]]
+ #
+ class Compiler < Visitor
+ # Visit an individual node.
+ #--
+ #: (node?) -> untyped
+ def visit(node) # :nodoc:
+ node&.accept(self)
+ end
+
+ # Visit a list of nodes.
+ #--
+ #: (Array[node?]) -> untyped
+ def visit_all(nodes) # :nodoc:
+ nodes.map { |node| node&.accept(self) }
+ end
+
+ # Visit the child nodes of the given node.
+ #--
+ #: (node) -> Array[untyped]
+ def visit_child_nodes(node) # :nodoc:
+ node.each_child_node.map { |node| node.accept(self) }
+ end
+
+ <%- nodes.each_with_index do |node, index| -%>
+<%= "\n" if index != 0 -%>
+ #: (<%= node.name %>) -> Array[untyped]
+ def visit_<%= node.human %>(node) # :nodoc:
+ node.each_child_node.map { |node| node.accept(self) }
+ end
+ <%- end -%>
+ end
+end
diff --git a/prism/templates/lib/prism/dispatcher.rb.erb b/prism/templates/lib/prism/dispatcher.rb.erb
new file mode 100644
index 0000000000..5991b0c904
--- /dev/null
+++ b/prism/templates/lib/prism/dispatcher.rb.erb
@@ -0,0 +1,111 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # The dispatcher class fires events for nodes that are found while walking an
+ # AST to all registered listeners. It's useful for performing different types
+ # of analysis on the AST while only having to walk the tree once.
+ #
+ # To use the dispatcher, you would first instantiate it and register listeners
+ # for the events you're interested in:
+ #
+ # class OctalListener
+ # def on_integer_node_enter(node)
+ # if node.octal? && !node.slice.start_with?("0o")
+ # warn("Octal integers should be written with the 0o prefix")
+ # end
+ # end
+ # end
+ #
+ # listener = OctalListener.new
+ # dispatcher = Prism::Dispatcher.new
+ # dispatcher.register(listener, :on_integer_node_enter)
+ #
+ # Then, you can walk any number of trees and dispatch events to the listeners:
+ #
+ # result = Prism.parse("001 + 002 + 003")
+ # dispatcher.dispatch(result.value)
+ #
+ # Optionally, you can also use `#dispatch_once` to dispatch enter and leave
+ # events for a single node without recursing further down the tree. This can
+ # be useful in circumstances where you want to reuse the listeners you already
+ # have registers but want to stop walking the tree at a certain point.
+ #
+ # integer = result.value.statements.body.first.receiver.receiver
+ # dispatcher.dispatch_once(integer)
+ #
+ class Dispatcher < Visitor
+ # A hash mapping event names to arrays of listeners that should be notified
+ # when that event is fired.
+ attr_reader :listeners #: Hash[Symbol, Array[untyped]]
+
+ # Initialize a new dispatcher.
+ #--
+ #: () -> void
+ def initialize
+ @listeners = {}
+ end
+
+ # Register a listener for one or more events.
+ #--
+ #: (untyped, *Symbol) -> void
+ def register(listener, *events)
+ register_events(listener, events)
+ end
+
+ # Register all public methods of a listener that match the pattern
+ # `on_<node_name>_(enter|leave)`.
+ #--
+ #: (untyped) -> void
+ def register_public_methods(listener)
+ register_events(listener, listener.public_methods(false).grep(/\Aon_.+_(?:enter|leave)\z/))
+ end
+
+ # Register a listener for the given events.
+ #--
+ #: (untyped, Array[Symbol]) -> void
+ private def register_events(listener, events) # :nodoc:
+ events.each { |event| (listeners[event] ||= []) << listener }
+ end
+
+ # Walks `root` dispatching events to all registered listeners.
+ alias dispatch visit
+
+ # Dispatches a single event for `node` to all registered listeners.
+ #--
+ #: (node node) -> void
+ def dispatch_once(node)
+ node.accept(DispatchOnce.new(listeners))
+ end
+ <%- nodes.each do |node| -%>
+
+ #: (<%= node.name %> node) -> void
+ def visit_<%= node.human %>(node) # :nodoc:
+ listeners[:on_<%= node.human %>_enter]&.each { |listener| listener.on_<%= node.human %>_enter(node) }
+ super
+ listeners[:on_<%= node.human %>_leave]&.each { |listener| listener.on_<%= node.human %>_leave(node) }
+ end
+ <%- end -%>
+
+ class DispatchOnce < Visitor # :nodoc:
+ attr_reader :listeners #: Hash[Symbol, Array[untyped]]
+
+ #: (Hash[Symbol, Array[untyped]] listeners) -> void
+ def initialize(listeners)
+ @listeners = listeners
+ end
+ <%- nodes.each do |node| -%>
+
+ # Dispatch enter and leave events for <%= node.name %> nodes.
+ #--
+ #: (<%= node.name %> node) -> void
+ def visit_<%= node.human %>(node)
+ listeners[:on_<%= node.human %>_enter]&.each { |listener| listener.on_<%= node.human %>_enter(node) }
+ listeners[:on_<%= node.human %>_leave]&.each { |listener| listener.on_<%= node.human %>_leave(node) }
+ end
+ <%- end -%>
+ end
+
+ private_constant :DispatchOnce
+ end
+end
diff --git a/prism/templates/lib/prism/dot_visitor.rb.erb b/prism/templates/lib/prism/dot_visitor.rb.erb
new file mode 100644
index 0000000000..88ef1e1f36
--- /dev/null
+++ b/prism/templates/lib/prism/dot_visitor.rb.erb
@@ -0,0 +1,215 @@
+#--
+# rbs_inline: enabled
+
+require "cgi/escape"
+require "cgi/util" unless defined?(CGI::EscapeExt)
+
+module Prism
+ # This visitor provides the ability to call Node#to_dot, which converts a
+ # subtree into a graphviz dot graph.
+ class DotVisitor < Visitor
+ class Field # :nodoc:
+ attr_reader :name #: String
+ attr_reader :value #: String?
+ attr_reader :port #: bool
+
+ #: (String name, String? value, bool port) -> void
+ def initialize(name, value, port)
+ @name = name
+ @value = value
+ @port = port
+ end
+
+ #: () -> String
+ def to_dot
+ if port
+ "<tr><td align=\"left\" colspan=\"2\" port=\"#{name}\">#{name}</td></tr>"
+ else
+ "<tr><td align=\"left\">#{name}</td><td>#{CGI.escapeHTML(value || raise)}</td></tr>"
+ end
+ end
+ end
+
+ class Table # :nodoc:
+ attr_reader :name #: String
+ attr_reader :fields #: Array[Field]
+
+ #: (String name) -> void
+ def initialize(name)
+ @name = name
+ @fields = []
+ end
+
+ #: (String name, ?String? value, ?port: bool) -> void
+ def field(name, value = nil, port: false)
+ fields << Field.new(name, value, port)
+ end
+
+ #: () -> String
+ def to_dot
+ dot = <<~DOT
+ <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
+ <tr><td colspan="2"><b>#{name}</b></td></tr>
+ DOT
+
+ if fields.any?
+ "#{dot} #{fields.map(&:to_dot).join("\n ")}\n</table>"
+ else
+ "#{dot}</table>"
+ end
+ end
+ end
+
+ class Digraph # :nodoc:
+ attr_reader :nodes, :waypoints, :edges #: Array[String]
+
+ #: () -> void
+ def initialize
+ @nodes = []
+ @waypoints = []
+ @edges = []
+ end
+
+ #: (String value) -> void
+ def node(value)
+ nodes << value
+ end
+
+ #: (String value) -> void
+ def waypoint(value)
+ waypoints << value
+ end
+
+ #: (String value) -> void
+ def edge(value)
+ edges << value
+ end
+
+ #: () -> String
+ def to_dot
+ <<~DOT
+ digraph "Prism" {
+ node [
+ fontname=\"Courier New\"
+ shape=plain
+ style=filled
+ fillcolor=gray95
+ ];
+
+ #{nodes.map { |node| node.gsub(/\n/, "\n ") }.join("\n ")}
+ node [shape=point];
+ #{waypoints.join("\n ")}
+
+ #{edges.join("\n ")}
+ }
+ DOT
+ end
+ end
+
+ private_constant :Field, :Table, :Digraph
+
+ # The digraph that is being built.
+ attr_reader :digraph #: Digraph
+
+ # Initialize a new dot visitor.
+ #--
+ #: () -> void
+ def initialize
+ @digraph = Digraph.new
+ end
+
+ # Convert this visitor into a graphviz dot graph string.
+ #--
+ #: () -> String
+ def to_dot
+ digraph.to_dot
+ end
+ <%- nodes.each do |node| -%>
+
+ #: (<%= node.name %>) -> void
+ def visit_<%= node.human %>(node) # :nodoc:
+ table = Table.new("<%= node.name %>")
+ id = node_id(node)
+ <%- if (node_flags = node.flags) -%>
+
+ # flags
+ table.field("flags", <%= node_flags.human %>_inspect(node))
+ <%- end -%>
+ <%- node.fields.each do |field| -%>
+
+ # <%= field.name %>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ table.field("<%= field.name %>", port: true)
+ digraph.edge("#{id}:<%= field.name %> -> #{node_id(node.<%= field.name %>)};")
+ <%- when Prism::Template::OptionalNodeField -%>
+ unless (<%= field.name %> = node.<%= field.name %>).nil?
+ table.field("<%= field.name %>", port: true)
+ digraph.edge("#{id}:<%= field.name %> -> #{node_id(<%= field.name %>)};")
+ end
+ <%- when Prism::Template::NodeListField -%>
+ if node.<%= field.name %>.any?
+ table.field("<%= field.name %>", port: true)
+
+ waypoint = "#{id}_<%= field.name %>"
+ digraph.waypoint("#{waypoint};")
+
+ digraph.edge("#{id}:<%= field.name %> -> #{waypoint};")
+ node.<%= field.name %>.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
+ else
+ table.field("<%= field.name %>", "[]")
+ end
+ <%- when Prism::Template::StringField, Prism::Template::ConstantField, Prism::Template::OptionalConstantField, Prism::Template::UInt8Field, Prism::Template::UInt32Field, Prism::Template::ConstantListField, Prism::Template::IntegerField, Prism::Template::DoubleField -%>
+ table.field("<%= field.name %>", node.<%= field.name %>.inspect)
+ <%- when Prism::Template::LocationField -%>
+ table.field("<%= field.name %>", location_inspect(node.<%= field.name %>))
+ <%- when Prism::Template::OptionalLocationField -%>
+ unless (<%= field.name %> = node.<%= field.name %>).nil?
+ table.field("<%= field.name %>", location_inspect(<%= field.name %>))
+ end
+ <%- else -%>
+ <%- raise -%>
+ <%- end -%>
+ <%- end -%>
+
+ digraph.node(<<~DOT)
+ #{id} [
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
+ ];
+ DOT
+
+ super
+ end
+ <%- end -%>
+
+ private
+
+ # Generate a unique node ID for a node throughout the digraph.
+ #--
+ #: (node) -> String
+ def node_id(node) # :nodoc:
+ "Node_#{node.object_id}"
+ end
+
+ # Inspect a location to display the start and end line and columns in bytes.
+ #--
+ #: (Location) -> String
+ def location_inspect(location) # :nodoc:
+ "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column})"
+ end
+ <%- flags.each do |flag| -%>
+
+ # Inspect a node that has <%= flag.human %> flags to display the flags as a
+ # comma-separated list.
+ #--
+ #: (<%= nodes.filter_map { |node| node.name if node.flags == flag }.join(" | ") %> node) -> String
+ def <%= flag.human %>_inspect(node) # :nodoc:
+ flags = [] #: Array[String]
+ <%- flag.values.each do |value| -%>
+ flags << "<%= value.name.downcase %>" if node.<%= value.name.downcase %>?
+ <%- end -%>
+ flags.join(", ")
+ end
+ <%- end -%>
+ end
+end
diff --git a/prism/templates/lib/prism/dsl.rb.erb b/prism/templates/lib/prism/dsl.rb.erb
new file mode 100644
index 0000000000..be7dc6d9c1
--- /dev/null
+++ b/prism/templates/lib/prism/dsl.rb.erb
@@ -0,0 +1,172 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # The DSL module provides a set of methods that can be used to create prism
+ # nodes in a more concise manner. For example, instead of writing:
+ #
+ # source = Prism::Source.for("[1]", 1, [0])
+ #
+ # Prism::ArrayNode.new(
+ # source,
+ # 0,
+ # Prism::Location.new(source, 0, 3),
+ # 0,
+ # [
+ # Prism::IntegerNode.new(
+ # source,
+ # 0,
+ # Prism::Location.new(source, 1, 1),
+ # Prism::IntegerBaseFlags::DECIMAL,
+ # 1
+ # )
+ # ],
+ # Prism::Location.new(source, 0, 1),
+ # Prism::Location.new(source, 2, 1)
+ # )
+ #
+ # you could instead write:
+ #
+ # class Builder
+ # include Prism::DSL
+ #
+ # attr_reader :default_source
+ #
+ # def initialize
+ # @default_source = source("[1]")
+ # end
+ #
+ # def build
+ # array_node(
+ # location: location(start_offset: 0, length: 3),
+ # elements: [
+ # integer_node(
+ # location: location(start_offset: 1, length: 1),
+ # flags: integer_base_flag(:decimal),
+ # value: 1
+ # )
+ # ],
+ # opening_loc: location(start_offset: 0, length: 1),
+ # closing_loc: location(start_offset: 2, length: 1)
+ # )
+ # end
+ # end
+ #
+ # This is mostly helpful in the context of generating trees programmatically.
+ module DSL
+ # Provide all of these methods as module methods as well, to allow for
+ # building nodes like Prism::DSL.nil_node.
+ extend self
+
+ # Create a new Source object.
+ #--
+ #: (String string) -> Source
+ def source(string)
+ Source.for(string, 1, build_offsets(string))
+ end
+
+ # Create a new Location object.
+ #--
+ #: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location
+ def location(source: default_source, start_offset: 0, length: 0)
+ Location.new(source, start_offset, length)
+ end
+ <%- nodes.each do |node| -%>
+ <%-
+ params = [
+ ["source", "Source"],
+ ["node_id", "Integer"],
+ ["location", "Location"],
+ ["flags", "Integer"]
+ ].concat(node.fields.map { |field| [field.name, field.rbs_class] })
+ -%>
+
+ # Create a new <%= node.name %> node.
+ #--
+ #: (<%= params.map { |(name, type)| "?#{name}: #{type}" }.join(", ") %>) -> <%= node.name %>
+ def <%= node.human %>(<%= ["source: default_source", "node_id: 0", "location: default_location", "flags: 0", *node.fields.map { |field|
+ case field
+ when Prism::Template::NodeField
+ kind = field.specific_kind || field.union_kind&.first
+ if kind.nil?
+ "#{field.name}: default_node(source, location)"
+ else
+ "#{field.name}: #{kind.gsub(/(?<=.)[A-Z]/, "_\\0").downcase}(source: source)"
+ end
+ when Prism::Template::ConstantField
+ "#{field.name}: :\"\""
+ when Prism::Template::OptionalNodeField, Prism::Template::OptionalConstantField, Prism::Template::OptionalLocationField
+ "#{field.name}: nil"
+ when Prism::Template::NodeListField, Prism::Template::ConstantListField
+ "#{field.name}: []"
+ when Prism::Template::StringField
+ "#{field.name}: \"\""
+ when Prism::Template::LocationField
+ "#{field.name}: location"
+ when Prism::Template::UInt8Field, Prism::Template::UInt32Field, Prism::Template::IntegerField
+ "#{field.name}: 0"
+ when Prism::Template::DoubleField
+ "#{field.name}: 0.0"
+ else
+ raise
+ end
+ }].join(", ") %>)
+ <%= node.name %>.new(<%= ["source", "node_id", "location", "flags", *node.fields.map(&:name)].join(", ") %>)
+ end
+ <%- end -%>
+ <%- flags.each do |flag| -%>
+
+ # Retrieve the value of one of the <%= flag.name %> flags.
+ #--
+ #: (Symbol name) -> Integer
+ def <%= flag.human.chomp("s") %>(name)
+ case name
+ <%- flag.values.each do |value| -%>
+ when :<%= value.name.downcase %> then <%= flag.name %>::<%= value.name %>
+ <%- end -%>
+ else Kernel.raise ArgumentError, "invalid <%= flag.name %> flag: #{name.inspect}"
+ end
+ end
+ <%- end -%>
+
+ private
+
+ # The default source object that gets attached to nodes and locations if no
+ # source is specified.
+ #--
+ #: () -> Source
+ def default_source
+ Source.for("", 1, [0])
+ end
+
+ # The default location object that gets attached to nodes if no location is
+ # specified, which uses the given source.
+ #--
+ #: () -> Location
+ def default_location
+ Location.new(default_source, 0, 0)
+ end
+
+ # The default node that gets attached to nodes if no node is specified for a
+ # required node field.
+ #--
+ #: (Source source, Location location) -> node
+ def default_node(source, location)
+ ErrorRecoveryNode.new(source, -1, location, 0, nil)
+ end
+
+ private
+
+ # Build the newline byte offset array for the given source string.
+ #--
+ #: (String source) -> Array[Integer]
+ def build_offsets(source)
+ offsets = [0]
+ start = 0
+ while (index = source.byteindex("\n", start))
+ offsets << (start = index + 1)
+ end
+ offsets
+ end
+ end
+end
diff --git a/prism/templates/lib/prism/inspect_visitor.rb.erb b/prism/templates/lib/prism/inspect_visitor.rb.erb
new file mode 100644
index 0000000000..820f5ae75f
--- /dev/null
+++ b/prism/templates/lib/prism/inspect_visitor.rb.erb
@@ -0,0 +1,147 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # This visitor is responsible for composing the strings that get returned by
+ # the various #inspect methods defined on each of the nodes.
+ class InspectVisitor < Visitor
+ # Most of the time, we can simply pass down the indent to the next node.
+ # However, when we are inside a list we want some extra special formatting
+ # when we hit an element in that list. In this case, we have a special
+ # command that replaces the subsequent indent with the given value.
+ class Replace # :nodoc:
+ attr_reader :value #: String
+
+ #: (String value) -> void
+ def initialize(value)
+ @value = value
+ end
+ end
+
+ private_constant :Replace
+
+ # The current prefix string.
+ # :stopdoc:
+ attr_reader :indent #: String
+ # :startdoc:
+
+ # The list of commands that we need to execute in order to compose the
+ # final string.
+ #: stopdoc:
+ attr_reader :commands #: Array[[String | node | Replace, String]]
+ # :startdoc:
+
+ #: (?String indent) -> void
+ def initialize(indent = +"") # :nodoc:
+ @indent = indent
+ @commands = []
+ end
+
+ # Compose an inspect string for the given node.
+ #--
+ #: (node node) -> String
+ def self.compose(node)
+ visitor = new
+ node.accept(visitor)
+ visitor.compose
+ end
+
+ # Compose the final string.
+ #--
+ #: () -> String
+ def compose # :nodoc:
+ buffer = +""
+ replace = nil
+
+ until commands.empty?
+ # @type var command: String | node | Replace
+ # @type var indent: String
+ command, indent = *commands.shift
+
+ case command
+ when String
+ buffer << (replace || indent)
+ buffer << command
+ replace = nil
+ when Node
+ visitor = InspectVisitor.new(indent)
+ command.accept(visitor)
+ @commands = [*visitor.commands, *@commands]
+ when Replace
+ replace = command.value
+ else
+ raise "Unknown command: #{command.inspect}"
+ end
+ end
+
+ buffer
+ end
+ <%- nodes.each do |node| -%>
+
+ #: (<%= node.name %> node) -> void
+ def visit_<%= node.human %>(node) # :nodoc:
+ commands << [inspect_node(<%= node.name.inspect %>, node), indent]
+ <%- (fields = [node.flags || Prism::Template::Flags.empty, *node.fields]).each_with_index do |field, index| -%>
+ <%- pointer = index == fields.length - 1 ? "└── " : "├── " -%>
+ <%- preadd = index == fields.length - 1 ? " " : "│ " -%>
+ <%- case field -%>
+ <%- when Prism::Template::Flags -%>
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), <%= field.values.map { |value| "(\"#{value.name.downcase}\" if node.#{value.name.downcase}?)" }.join(", ") %>].compact
+ commands << ["<%= pointer %>flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
+ <%- when Prism::Template::NodeListField -%>
+ commands << ["<%= pointer %><%= field.name %>: (length: #{(<%= field.name %> = node.<%= field.name %>).length})\n", indent]
+ if <%= field.name %>.any?
+ <%= field.name %>[0...-1].each do |child|
+ commands << [Replace.new("#{indent}<%= preadd %>├── "), indent]
+ commands << [child, "#{indent}<%= preadd %>│ "]
+ end
+ commands << [Replace.new("#{indent}<%= preadd %>└── "), indent]
+ commands << [<%= field.name %>[-1], "#{indent}<%= preadd %> "]
+ end
+ <%- when Prism::Template::NodeField -%>
+ commands << ["<%= pointer %><%= field.name %>:\n", indent]
+ commands << [node.<%= field.name %>, "#{indent}<%= preadd %>"]
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (<%= field.name %> = node.<%= field.name %>).nil?
+ commands << ["<%= pointer %><%= field.name %>: ∅\n", indent]
+ else
+ commands << ["<%= pointer %><%= field.name %>:\n", indent]
+ commands << [<%= field.name %>, "#{indent}<%= preadd %>"]
+ end
+ <%- when Prism::Template::ConstantField, Prism::Template::ConstantListField, Prism::Template::StringField, Prism::Template::UInt8Field, Prism::Template::UInt32Field, Prism::Template::IntegerField, Prism::Template::DoubleField -%>
+ commands << ["<%= pointer %><%= field.name %>: #{node.<%= field.name %>.inspect}\n", indent]
+ <%- when Prism::Template::OptionalConstantField -%>
+ if (<%= field.name %> = node.<%= field.name %>).nil?
+ commands << ["<%= pointer %><%= field.name %>: ∅\n", indent]
+ else
+ commands << ["<%= pointer %><%= field.name %>: #{<%= field.name %>.inspect}\n", indent]
+ end
+ <%- when Prism::Template::LocationField, Prism::Template::OptionalLocationField -%>
+ commands << ["<%= pointer %><%= field.name %>: #{inspect_location(node.<%= field.name %>)}\n", indent]
+ <%- end -%>
+ <%- end -%>
+ end
+ <%- end -%>
+
+ private
+
+ # Compose a header for the given node.
+ #--
+ #: (String name, node node) -> String
+ def inspect_node(name, node) # :nodoc:
+ location = node.location
+ "@ #{name} (location: (#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}))\n"
+ end
+
+ # Compose a string representing the given inner location field.
+ #--
+ #: (Location? location) -> String
+ def inspect_location(location) # :nodoc:
+ if location
+ "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}) = #{location.slice.inspect}"
+ else
+ "∅"
+ end
+ end
+ end
+end
diff --git a/prism/templates/lib/prism/mutation_compiler.rb.erb b/prism/templates/lib/prism/mutation_compiler.rb.erb
new file mode 100644
index 0000000000..2d555048d2
--- /dev/null
+++ b/prism/templates/lib/prism/mutation_compiler.rb.erb
@@ -0,0 +1,22 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # This visitor walks through the tree and copies each node as it is being
+ # visited. This is useful for consumers that want to mutate the tree, as you
+ # can change subtrees in place without effecting the rest of the tree.
+ class MutationCompiler < Compiler
+ <%- nodes.each_with_index do |node, index| -%>
+<%= "\n" if index != 0 -%>
+ #: (<%= node.name %>) -> node?
+ def visit_<%= node.human %>(node) # :nodoc:
+ <%- fields = node.fields.select { |field| [Prism::Template::NodeField, Prism::Template::OptionalNodeField, Prism::Template::NodeListField].include?(field.class) } -%>
+ <%- if fields.any? -%>
+ node.copy(<%= fields.map { |field| "#{field.name}: #{field.is_a?(Prism::Template::NodeListField) ? "visit_all" : "visit"}(node.#{field.name})" }.join(", ") %>)
+ <%- else -%>
+ node.copy
+ <%- end -%>
+ end
+ <%- end -%>
+ end
+end
diff --git a/prism/templates/lib/prism/node.rb.erb b/prism/templates/lib/prism/node.rb.erb
new file mode 100644
index 0000000000..fb13051aba
--- /dev/null
+++ b/prism/templates/lib/prism/node.rb.erb
@@ -0,0 +1,748 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # @rbs!
+ # interface _Repository
+ # def enter: (Integer node_id, Symbol field_name) -> Relocation::Entry
+ # end
+ #
+ # interface _Node
+ # def deconstruct: () -> Array[Prism::node?]
+ # def inspect: () -> String
+ # end
+ #
+ # type node = Node & _Node
+
+ # This represents a node in the tree. It is the parent class of all of the
+ # various node types.
+ class Node
+ # A pointer to the source that this node was created from.
+ # :stopdoc:
+ attr_reader :source #: Source
+ private :source
+ # :startdoc:
+
+ # A unique identifier for this node. This is used in a very specific
+ # use case where you want to keep around a reference to a node without
+ # having to keep around the syntax tree in memory. This unique identifier
+ # will be consistent across multiple parses of the same source code.
+ attr_reader :node_id #: Integer
+
+ # The location associated with this node. For lazily loading Location
+ # objects, we keep it as a packed integer until it is accessed.
+ # @rbs @location: Location | Integer
+
+ # Save this node using a saved source so that it can be retrieved later.
+ #--
+ #: (_Repository repository) -> Relocation::Entry
+ def save(repository)
+ repository.enter(node_id, :itself)
+ end
+
+ # A Location instance that represents the location of this node in the
+ # source.
+ #--
+ #: () -> Location
+ def location
+ location = @location
+ return location if location.is_a?(Location)
+ @location = Location.new(source, location >> 32, location & 0xFFFFFFFF)
+ end
+
+ # Save the location using a saved source so that it can be retrieved later.
+ #--
+ #: (_Repository repository) -> Relocation::Entry
+ def save_location(repository)
+ repository.enter(node_id, :location)
+ end
+
+ # --------------------------------------------------------------------------
+ # :section: Location Delegators
+ # These methods provide convenient access to the underlying Location object.
+ # --------------------------------------------------------------------------
+
+ # Delegates to [`start_line`](rdoc-ref:Location#start_line) of the associated location object.
+ #--
+ #: () -> Integer
+ def start_line
+ location.start_line
+ end
+
+ # Delegates to [`end_line`](rdoc-ref:Location#end_line) of the associated location object.
+ #--
+ #: () -> Integer
+ def end_line
+ location.end_line
+ end
+
+ # Delegates to [`start_offset`](rdoc-ref:Location#start_offset) of the associated location object.
+ #--
+ #: () -> Integer
+ def start_offset
+ location = @location
+ location.is_a?(Location) ? location.start_offset : location >> 32
+ end
+
+ # Delegates to [`end_offset`](rdoc-ref:Location#end_offset) of the associated location object.
+ #--
+ #: () -> Integer
+ def end_offset
+ location = @location
+ location.is_a?(Location) ? location.end_offset : ((location >> 32) + (location & 0xFFFFFFFF))
+ end
+
+ # Delegates to [`start_character_offset`](rdoc-ref:Location#start_character_offset)
+ # of the associated location object.
+ #--
+ #: () -> Integer
+ def start_character_offset
+ location.start_character_offset
+ end
+
+ # Delegates to [`end_character_offset`](rdoc-ref:Location#end_character_offset)
+ # of the associated location object.
+ #--
+ #: () -> Integer
+ def end_character_offset
+ location.end_character_offset
+ end
+
+ # Delegates to [`cached_start_code_units_offset`](rdoc-ref:Location#cached_start_code_units_offset)
+ # of the associated location object.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_start_code_units_offset(cache)
+ location.cached_start_code_units_offset(cache)
+ end
+
+ # Delegates to [`cached_end_code_units_offset`](rdoc-ref:Location#cached_end_code_units_offset)
+ # of the associated location object.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_end_code_units_offset(cache)
+ location.cached_end_code_units_offset(cache)
+ end
+
+ # Delegates to [`start_column`](rdoc-ref:Location#start_column) of the associated location object.
+ #--
+ #: () -> Integer
+ def start_column
+ location.start_column
+ end
+
+ # Delegates to [`end_column`](rdoc-ref:Location#end_column) of the associated location object.
+ #--
+ #: () -> Integer
+ def end_column
+ location.end_column
+ end
+
+ # Delegates to [`start_character_column`](rdoc-ref:Location#start_character_column)
+ # of the associated location object.
+ #--
+ #: () -> Integer
+ def start_character_column
+ location.start_character_column
+ end
+
+ # Delegates to [`end_character_column`](rdoc-ref:Location#end_character_column)
+ # of the associated location object.
+ #--
+ #: () -> Integer
+ def end_character_column
+ location.end_character_column
+ end
+
+ # Delegates to [`cached_start_code_units_column`](rdoc-ref:Location#cached_start_code_units_column)
+ # of the associated location object.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_start_code_units_column(cache)
+ location.cached_start_code_units_column(cache)
+ end
+
+ # Delegates to [`cached_end_code_units_column`](rdoc-ref:Location#cached_end_code_units_column)
+ # of the associated location object.
+ #--
+ #: (_CodeUnitsCache cache) -> Integer
+ def cached_end_code_units_column(cache)
+ location.cached_end_code_units_column(cache)
+ end
+
+ # Delegates to [`leading_comments`](rdoc-ref:Location#leading_comments) of the associated location object.
+ #--
+ #: () -> Array[Comment]
+ def leading_comments
+ location.leading_comments
+ end
+
+ # Delegates to [`trailing_comments`](rdoc-ref:Location#trailing_comments) of the associated location object.
+ #--
+ #: () -> Array[Comment]
+ def trailing_comments
+ location.trailing_comments
+ end
+
+ # Delegates to [`comments`](rdoc-ref:Location#comments) of the associated location object.
+ #--
+ #: () -> Array[Comment]
+ def comments
+ location.comments
+ end
+
+ # :section:
+
+ # Returns all of the lines of the source code associated with this node.
+ #--
+ #: () -> Array[String]
+ def source_lines
+ location.source_lines
+ end
+
+ # An alias for source_lines, used to mimic the API from
+ # RubyVM::AbstractSyntaxTree to make it easier to migrate.
+ alias script_lines source_lines
+
+ # Slice the location of the node from the source.
+ #--
+ #: () -> String
+ def slice
+ location.slice
+ end
+
+ # Slice the location of the node from the source, starting at the beginning
+ # of the line that the location starts on, ending at the end of the line
+ # that the location ends on.
+ #--
+ #: () -> String
+ def slice_lines
+ location.slice_lines
+ end
+
+ # An bitset of flags for this node. There are certain flags that are common
+ # for all nodes, and then some nodes have specific flags.
+ # :stopdoc:
+ attr_reader :flags #: Integer
+ protected :flags
+ # :startdoc:
+
+ # Returns true if the node has the newline flag set.
+ #--
+ #: () -> bool
+ def newline?
+ flags.anybits?(NodeFlags::NEWLINE)
+ end
+
+ # Returns true if the node has the static literal flag set.
+ #--
+ #: () -> bool
+ def static_literal?
+ flags.anybits?(NodeFlags::STATIC_LITERAL)
+ end
+
+ # Similar to inspect, but respects the current level of indentation given by
+ # the pretty print object.
+ #--
+ #: (PP q) -> void
+ def pretty_print(q) # :nodoc:
+ q.seplist(inspect.chomp.each_line, -> { q.breakable }) do |line|
+ q.text(line.chomp)
+ end
+ q.current_group.break
+ end
+
+ # Convert this node into a graphviz dot graph string.
+ #--
+ #: () -> String
+ def to_dot
+ # @type self: node
+ DotVisitor.new.tap { |visitor| accept(visitor) }.to_dot
+ end
+
+ # Returns a list of nodes that are descendants of this node that contain the
+ # given line and column. This is useful for locating a node that is selected
+ # based on the line and column of the source code.
+ #
+ # Important to note is that the column given to this method should be in
+ # bytes, as opposed to characters or code units.
+ #--
+ #: (Integer line, Integer column) -> Array[node]
+ def tunnel(line, column)
+ queue = [self] #: Array[node]
+ result = [] #: Array[node]
+ offset = source.byte_offset(line, column)
+
+ while (node = queue.shift)
+ result << node
+
+ node.each_child_node do |child_node|
+ if child_node.start_offset <= offset && offset < child_node.end_offset
+ queue << child_node
+ break
+ end
+ end
+ end
+
+ result
+ end
+
+ # Returns the first node that matches the given block when visited in a
+ # breadth-first search. This is useful for finding a node that matches a
+ # particular condition.
+ #
+ # node.breadth_first_search { |node| node.node_id == node_id }
+ #--
+ #: () { (node) -> bool } -> node?
+ def breadth_first_search(&blk)
+ queue = [self] #: Array[node]
+
+ while (node = queue.shift)
+ return node if yield node
+ queue.concat(node.compact_child_nodes)
+ end
+
+ nil
+ end
+ alias find breadth_first_search
+
+ # Returns all of the nodes that match the given block when visited in a
+ # breadth-first search. This is useful for finding all nodes that match a
+ # particular condition.
+ #
+ # node.breadth_first_search_all { |node| node.is_a?(Prism::CallNode) }
+ #--
+ #: () { (node) -> bool } -> Array[node]
+ def breadth_first_search_all(&blk)
+ queue = [self] #: Array[Prism::node]
+ results = [] #: Array[Prism::node]
+
+ while (node = queue.shift)
+ results << node if yield node
+ queue.concat(node.compact_child_nodes)
+ end
+
+ results
+ end
+ alias find_all breadth_first_search_all
+
+ # Returns a list of the fields that exist for this node class. Fields
+ # describe the structure of the node. This kind of reflection is useful for
+ # things like recursively visiting each node _and_ field in the tree.
+ #--
+ #: () -> Array[Reflection::Field]
+ def self.fields
+ # This method should only be called on subclasses of Node, not Node
+ # itself.
+ raise NoMethodError, "undefined method `fields' for #{inspect}" if self == Node
+
+ Reflection.fields_for(self)
+ end
+
+ # --------------------------------------------------------------------------
+ # :section: Node Interface
+ # These methods are effectively abstract methods that are implemented by
+ # the various subclasses of Node.
+ # --------------------------------------------------------------------------
+
+ # Accepts a visitor and calls back into the specialized visit function.
+ #--
+ #: (_Visitor visitor) -> untyped
+ def accept(visitor)
+ raise NoMethodError, "undefined method `accept' for #{inspect}"
+ end
+
+ # Returns an array of child nodes, including `nil`s in the place of optional
+ # nodes that were not present.
+ #--
+ #: () -> Array[node?]
+ def child_nodes
+ raise NoMethodError, "undefined method `child_nodes' for #{inspect}"
+ end
+
+ alias deconstruct child_nodes
+
+ # With a block given, yields each child node. Without a block, returns
+ # an enumerator that contains each child node. Excludes any `nil`s in
+ # the place of optional nodes that were not present.
+ #--
+ #: () -> Enumerator[node, void]
+ #: () { (node) -> void } -> void
+ def each_child_node(&blk)
+ raise NoMethodError, "undefined method `each_child_node' for #{inspect}"
+ end
+
+ # Returns an array of child nodes, excluding any `nil`s in the place of
+ # optional nodes that were not present.
+ #--
+ #: () -> Array[node]
+ def compact_child_nodes
+ raise NoMethodError, "undefined method `compact_child_nodes' for #{inspect}"
+ end
+
+ # Returns an array of child nodes and locations that could potentially have
+ # comments attached to them.
+ #--
+ #: () -> Array[node | Location]
+ def comment_targets
+ raise NoMethodError, "undefined method `comment_targets' for #{inspect}"
+ end
+
+ # Returns a string representation of the node.
+ #--
+ #: () -> String
+ def inspect
+ raise NoMethodError, "undefined method `inspect' for #{inspect}"
+ end
+
+ # Sometimes you want to check an instance of a node against a list of
+ # classes to see what kind of behavior to perform. Usually this is done by
+ # calling `[cls1, cls2].include?(node.class)` or putting the node into a
+ # case statement and doing `case node; when cls1; when cls2; end`. Both of
+ # these approaches are relatively slow because of the constant lookups,
+ # method calls, and/or array allocations.
+ #
+ # Instead, you can call #type, which will return to you a symbol that you
+ # can use for comparison. This is faster than the other approaches because
+ # it uses a single integer comparison, but also because if you're on CRuby
+ # you can take advantage of the fact that case statements with all symbol
+ # keys will use a jump table.
+ #--
+ #: () -> Symbol
+ def type
+ raise NoMethodError, "undefined method `type' for #{inspect}"
+ end
+
+ # Similar to #type, this method returns a symbol that you can use for
+ # splitting on the type of the node without having to do a long === chain.
+ # Note that like #type, it will still be slower than using == for a single
+ # class, but should be faster in a case statement or an array comparison.
+ #--
+ #: () -> Symbol
+ def self.type
+ raise NoMethodError, "undefined method `type' for #{inspect}"
+ end
+ end
+ <%- nodes.each do |node| -%>
+
+ <%- node.each_comment_line do |line| -%>
+ #<%= line %>
+ <%- end -%>
+ class <%= node.name -%> < Node
+ <%- node.fields.each do |field| -%>
+ # @rbs @<%= field.name %>: <%= field.rbs_class %>
+ <%- end -%>
+
+ # Initialize a new <%= node.name %> node.
+ #--
+ #: (Source source, Integer node_id, Location location, Integer flags, <%= node.fields.map { |field| "#{field.rbs_class} #{field.name}" }.join(", ") %>) -> void
+ def initialize(<%= ["source", "node_id", "location", "flags", *node.fields.map(&:name)].join(", ") %>)
+ @source = source
+ @node_id = node_id
+ @location = location
+ @flags = flags
+ <%- node.fields.each do |field| -%>
+ <%- if Prism::Template::CHECK_FIELD_KIND && field.respond_to?(:check_field_kind) -%>
+ raise "<%= node.name %>#<%= field.name %> was of unexpected type:\n#{<%= field.name %>.inspect}" unless <%= field.check_field_kind %>
+ <%- end -%>
+ @<%= field.name %> = <%= field.name %>
+ <%- end -%>
+ end
+
+ # ---------
+ # :section: Repository
+ # Methods related to Relocation.
+ # ---------
+
+ # ----------------------------------------------------------------------------------
+ # :section: Node Interface
+ # These methods are present on all subclasses of Node.
+ # Read the [node interface docs](Node.html#node-interface) for more information.
+ # ----------------------------------------------------------------------------------
+
+ # See Node.accept.
+ #--
+ #: (_Visitor visitor) -> untyped
+ def accept(visitor)
+ visitor.visit_<%= node.human %>(self)
+ end
+
+ # See Node.child_nodes.
+ #--
+ #: () -> Array[node?]
+ def child_nodes
+ [<%= node.fields.map { |field|
+ case field
+ when Prism::Template::NodeField, Prism::Template::OptionalNodeField then field.name
+ when Prism::Template::NodeListField then "*#{field.name}"
+ end
+ }.compact.join(", ") %>]
+ end
+
+ # See Node.each_child_node.
+ #--
+ #: () -> Enumerator[node, void]
+ #: () { (node) -> void } -> void
+ def each_child_node(&blk)
+ return to_enum(:each_child_node) unless block_given?
+
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ yield <%= field.name %>
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (<%= field.name %> = self.<%= field.name %>); yield <%= field.name %>; end
+ <%- when Prism::Template::NodeListField -%>
+ <%= field.name %>.each { |node| yield node }
+ <%- end -%>
+ <%- end -%>
+ end
+
+ # See Node.compact_child_nodes.
+ #--
+ #: () -> Array[node]
+ def compact_child_nodes
+ <%- if node.fields.any? { |field| field.is_a?(Prism::Template::OptionalNodeField) } -%>
+ compact = [] #: Array[Prism::node]
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ compact << <%= field.name %>
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (<%= field.name %> = self.<%= field.name %>); compact << <%= field.name %>; end
+ <%- when Prism::Template::NodeListField -%>
+ compact.concat(<%= field.name %>)
+ <%- end -%>
+ <%- end -%>
+ compact
+ <%- else -%>
+ [<%= node.fields.map { |field|
+ case field
+ when Prism::Template::NodeField then field.name
+ when Prism::Template::NodeListField then "*#{field.name}"
+ end
+ }.compact.join(", ") %>]
+ <%- end -%>
+ end
+
+ # See Node.comment_targets.
+ #--
+ #: () -> Array[node | Location]
+ def comment_targets
+ [<%= node.fields.map { |field|
+ case field
+ when Prism::Template::NodeField, Prism::Template::LocationField then field.name
+ when Prism::Template::OptionalNodeField, Prism::Template::NodeListField, Prism::Template::OptionalLocationField then "*#{field.name}"
+ end
+ }.compact.join(", ") %>] #: Array[Prism::node | Location]
+ end
+
+ # :call-seq:
+ # copy(**fields) -> <%= node.name %>
+ #
+ # Creates a copy of self with the given fields, using self as the template.
+ #--
+ #: (?node_id: Integer, ?location: Location, ?flags: Integer, <%= node.fields.map { |field| "?#{field.name}: #{field.rbs_class}" }.join(", ") %>) -> <%= node.name %>
+ def copy(<%= (["node_id", "location", "flags"] + node.fields.map(&:name)).map { |field| "#{field}: self.#{field}" }.join(", ") %>)
+ <%= node.name %>.new(<%= ["source", "node_id", "location", "flags", *node.fields.map(&:name)].join(", ") %>)
+ end
+
+ alias deconstruct child_nodes
+
+ #: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
+ def deconstruct_keys(keys) # :nodoc:
+ { <%= (["node_id: node_id", "location: location"] + node.fields.map { |field| "#{field.name}: #{field.name}" }).join(", ") %> }
+ end
+
+ # See `Node#type`.
+ #--
+ #: () -> :<%= node.human %>
+ def type
+ :<%= node.human %>
+ end
+
+ # See `Node.type`.
+ #--
+ #: () -> :<%= node.human %>
+ def self.type
+ :<%= node.human %>
+ end
+
+ #: () -> String
+ def inspect # :nodoc:
+ InspectVisitor.compose(self)
+ end
+
+ # :section:
+
+ <%- if (node_flags = node.flags) -%>
+ <%- node_flags.values.each do |value| -%>
+ # :category: Flags
+ # <%= value.comment %>
+ #--
+ #: () -> bool
+ def <%= value.name.downcase %>?
+ flags.anybits?(<%= node_flags.name %>::<%= value.name %>)
+ end
+
+ <%- end -%>
+ <%- end -%>
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::LocationField -%>
+ # :category: Locations
+ # :call-seq:
+ # <%= field.name %> -> <%= field.call_seq_type %>
+ #
+ <%- if field.comment.nil? -%>
+ # Returns the Location represented by `<%= field.name %>`.
+ <%- else -%>
+ <%- field.each_comment_line do |line| -%>
+ #<%= line %>
+ <%- end -%>
+ <%- end -%>
+ #--
+ #: () -> Location
+ def <%= field.name %>
+ location = @<%= field.name %>
+ return location if location.is_a?(Location)
+ @<%= field.name %> = Location.new(source, location >> 32, location & 0xFFFFFFFF)
+ end
+
+ # :category: Repository
+ # Save the <%= field.name %> location using the given saved source so that
+ # it can be retrieved later.
+ #--
+ #: (_Repository repository) -> Relocation::Entry
+ def save_<%= field.name %>(repository)
+ repository.enter(node_id, :<%= field.name %>)
+ end
+
+ <%- when Prism::Template::OptionalLocationField -%>
+ # :category: Locations
+ # :call-seq:
+ # <%= field.name %> -> <%= field.call_seq_type %>
+ #
+ <%- if field.comment.nil? -%>
+ # Returns the Location represented by `<%= field.name %>`.
+ <%- else -%>
+ <%- field.each_comment_line do |line| -%>
+ #<%= line %>
+ <%- end -%>
+ <%- end -%>
+ #--
+ #: () -> Location?
+ def <%= field.name %>
+ location = @<%= field.name %>
+ case location
+ when nil
+ nil
+ when Location
+ location
+ else
+ @<%= field.name %> = Location.new(source, location >> 32, location & 0xFFFFFFFF)
+ end
+ end
+
+ # :category: Repository
+ # Save the <%= field.name %> location using the given saved source so that
+ # it can be retrieved later.
+ #--
+ #: (_Repository repository) -> Relocation::Entry?
+ def save_<%= field.name %>(repository)
+ repository.enter(node_id, :<%= field.name %>) unless @<%= field.name %>.nil?
+ end
+ <%- else -%>
+ # :call-seq:
+ # <%= field.name %> -> <%= field.call_seq_type %>
+ #
+ <%- if field.comment.nil? -%>
+ # Returns the `<%= field.name %>` attribute.
+ <%- else -%>
+ <%- field.each_comment_line do |line| -%>
+ #<%= line %>
+ <%- end -%>
+ <%- end -%>
+ #--
+ #: () -> <%= field.rbs_class %>
+ def <%= field.name %>
+ @<%= field.name %>
+ end
+
+ <%- end -%>
+ <%- end -%>
+ # :section: Slicing
+
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::LocationField -%>
+ <%- raise unless field.name.end_with?("_loc") -%>
+ <%- next if node.fields.any? { |other| other.name == field.name.delete_suffix("_loc") } -%>
+ # :call-seq:
+ # <%= field.name.delete_suffix("_loc") %> -> String
+ #
+ # Slice the location of <%= field.name %> from the source.
+ #--
+ #: () -> String
+ def <%= field.name.delete_suffix("_loc") %>
+ <%= field.name %>.slice
+ end
+
+ <%- when Prism::Template::OptionalLocationField -%>
+ <%- raise unless field.name.end_with?("_loc") -%>
+ <%- next if node.fields.any? { |other| other.name == field.name.delete_suffix("_loc") } -%>
+ # :call-seq:
+ # <%= field.name.delete_suffix("_loc") %> -> String | nil
+ #
+ # Slice the location of <%= field.name %> from the source.
+ #--
+ #: () -> String?
+ def <%= field.name.delete_suffix("_loc") %>
+ <%= field.name %>&.slice
+ end
+
+ <%- end -%>
+ <%- end -%>
+ # :section:
+
+ #: (untyped other) -> boolish
+ def ===(other) # :nodoc:
+ other.is_a?(<%= node.name %>)<%= " &&" if (fields = [*node.flags, *node.fields]).any? %>
+ <%- fields.each_with_index do |field, index| -%>
+ <%- if field.is_a?(Prism::Template::LocationField) || field.is_a?(Prism::Template::OptionalLocationField) -%>
+ (<%= field.name %>.nil? == other.<%= field.name %>.nil?)<%= " &&" if index != fields.length - 1 %>
+ <%- elsif field.is_a?(Prism::Template::NodeListField) || field.is_a?(Prism::Template::ConstantListField) -%>
+ (<%= field.name %>.length == other.<%= field.name %>.length) &&
+ <%= field.name %>.zip(other.<%= field.name %>).all? { |left, right| left === right }<%= " &&" if index != fields.length - 1 %>
+ <%- elsif field.is_a?(Prism::Template::Flags) -%>
+ (flags === other.flags)<%= " &&" if index != fields.length - 1 %>
+ <%- else -%>
+ (<%= field.name %> === other.<%= field.name %>)<%= " &&" if index != fields.length - 1 %>
+ <%- end -%>
+ <%- end -%>
+ end
+ end
+ <%- end -%>
+ <%- flags.each do |flag| -%>
+
+ # <%= flag.comment %>
+ module <%= flag.name %>
+ <%- flag.values.each_with_index do |value, index| -%>
+ # <%= value.comment %>
+ <%= value.name %> = 1 << <%= index + Prism::Template::COMMON_FLAGS_COUNT %>
+<%= "\n" if value != flag.values.last -%>
+ <%- end -%>
+ end
+ <%- end -%>
+
+ # The flags that are common to all nodes.
+ module NodeFlags
+ # A flag to indicate that the node is a candidate to emit a :line event
+ # through tracepoint when compiled.
+ NEWLINE = 1
+
+ # A flag to indicate that the value that the node represents is a value that
+ # can be determined at parse-time.
+ STATIC_LITERAL = 2
+ end
+end
diff --git a/prism/templates/lib/prism/reflection.rb.erb b/prism/templates/lib/prism/reflection.rb.erb
new file mode 100644
index 0000000000..0012f120b2
--- /dev/null
+++ b/prism/templates/lib/prism/reflection.rb.erb
@@ -0,0 +1,145 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # The Reflection module provides the ability to reflect on the structure of
+ # the syntax tree itself, as opposed to looking at a single syntax tree. This
+ # is useful in metaprogramming contexts.
+ module Reflection
+ # A field represents a single piece of data on a node. It is the base class
+ # for all other field types.
+ class Field
+ # The name of the field.
+ attr_reader :name #: Symbol
+
+ # Initializes the field with the given name.
+ #--
+ #: (Symbol name) -> void
+ def initialize(name)
+ @name = name
+ end
+ end
+
+ # A node field represents a single child node in the syntax tree. It
+ # resolves to a Prism::Node in Ruby.
+ class NodeField < Field
+ end
+
+ # An optional node field represents a single child node in the syntax tree
+ # that may or may not be present. It resolves to either a Prism::Node or nil
+ # in Ruby.
+ class OptionalNodeField < Field
+ end
+
+ # A node list field represents a list of child nodes in the syntax tree. It
+ # resolves to an array of Prism::Node instances in Ruby.
+ class NodeListField < Field
+ end
+
+ # A constant field represents a constant value on a node. Effectively, it
+ # represents an identifier found within the source. It resolves to a symbol
+ # in Ruby.
+ class ConstantField < Field
+ end
+
+ # An optional constant field represents a constant value on a node that may
+ # or may not be present. It resolves to either a symbol or nil in Ruby.
+ class OptionalConstantField < Field
+ end
+
+ # A constant list field represents a list of constant values on a node. It
+ # resolves to an array of symbols in Ruby.
+ class ConstantListField < Field
+ end
+
+ # A string field represents a string value on a node. It almost always
+ # represents the unescaped value of a string-like literal. It resolves to a
+ # string in Ruby.
+ class StringField < Field
+ end
+
+ # A location field represents the location of some part of the node in the
+ # source code. For example, the location of a keyword or an operator. It
+ # resolves to a Prism::Location in Ruby.
+ class LocationField < Field
+ end
+
+ # An optional location field represents the location of some part of the
+ # node in the source code that may or may not be present. It resolves to
+ # either a Prism::Location or nil in Ruby.
+ class OptionalLocationField < Field
+ end
+
+ # An integer field represents an integer value. It is used to represent the
+ # value of an integer literal, the depth of local variables, and the number
+ # of a numbered reference. It resolves to an Integer in Ruby.
+ class IntegerField < Field
+ end
+
+ # A float field represents a double-precision floating point value. It is
+ # used exclusively to represent the value of a floating point literal. It
+ # resolves to a Float in Ruby.
+ class FloatField < Field
+ end
+
+ # A flags field represents a bitset of flags on a node. It resolves to an
+ # integer in Ruby. Note that the flags cannot be accessed directly on the
+ # node because the integer is kept private. Instead, the various flags in
+ # the bitset should be accessed through their query methods.
+ class FlagsField < Field
+ # The names of the flags in the bitset.
+ attr_reader :flags #: Array[Symbol]
+
+ # Initializes the flags field with the given name and flags.
+ #--
+ #: (Symbol name, Array[Symbol] flags) -> void
+ def initialize(name, flags)
+ super(name)
+ @flags = flags
+ end
+ end
+
+ # Returns the fields for the given node.
+ #--
+ #: (singleton(Node) node) -> Array[Field]
+ def self.fields_for(node)
+ case node.type
+ <%- nodes.each do |node| -%>
+ when :<%= node.human %>
+ [<%= [*node.flags, *node.fields].map { |field|
+ case field
+ when Prism::Template::NodeField
+ "NodeField.new(:#{field.name})"
+ when Prism::Template::OptionalNodeField
+ "OptionalNodeField.new(:#{field.name})"
+ when Prism::Template::NodeListField
+ "NodeListField.new(:#{field.name})"
+ when Prism::Template::ConstantField
+ "ConstantField.new(:#{field.name})"
+ when Prism::Template::OptionalConstantField
+ "OptionalConstantField.new(:#{field.name})"
+ when Prism::Template::ConstantListField
+ "ConstantListField.new(:#{field.name})"
+ when Prism::Template::StringField
+ "StringField.new(:#{field.name})"
+ when Prism::Template::LocationField
+ "LocationField.new(:#{field.name})"
+ when Prism::Template::OptionalLocationField
+ "OptionalLocationField.new(:#{field.name})"
+ when Prism::Template::UInt8Field, Prism::Template::UInt32Field, Prism::Template::IntegerField
+ "IntegerField.new(:#{field.name})"
+ when Prism::Template::DoubleField
+ "FloatField.new(:#{field.name})"
+ when Prism::Template::Flags
+ "FlagsField.new(:flags, [#{field.values.map { |value| ":#{value.name.downcase}?" }.join(", ")}])"
+ else
+ raise field.class.name
+ end
+ }.join(", ") %>]
+ <%- end -%>
+ else
+ raise "Unknown node type: #{node.type.inspect}"
+ end
+ end
+ end
+end
diff --git a/prism/templates/lib/prism/serialize.rb.erb b/prism/templates/lib/prism/serialize.rb.erb
new file mode 100644
index 0000000000..a676f957af
--- /dev/null
+++ b/prism/templates/lib/prism/serialize.rb.erb
@@ -0,0 +1,702 @@
+#--
+# rbs_inline: enabled
+
+require "stringio"
+require_relative "polyfill/unpack1"
+
+module Prism
+ # A module responsible for deserializing parse results.
+ module Serialize # :nodoc:
+ # The major version of prism that we are expecting to find in the serialized
+ # strings.
+ MAJOR_VERSION = 1
+
+ # The minor version of prism that we are expecting to find in the serialized
+ # strings.
+ MINOR_VERSION = 9
+
+ # The patch version of prism that we are expecting to find in the serialized
+ # strings.
+ PATCH_VERSION = 0
+
+ # Deserialize the dumped output from a request to parse or parse_file.
+ #
+ # The formatting of the source of this method is purposeful to illustrate
+ # the structure of the serialized data.
+ #--
+ #: (String input, String serialized, bool freeze) -> ParseResult
+ def self.load_parse(input, serialized, freeze)
+ input = input.dup
+ source = Source.for(input, 1, [])
+ loader = Loader.new(source, serialized)
+
+ loader.load_header
+ encoding = loader.load_encoding
+ start_line = loader.load_varsint
+ offsets = loader.load_line_offsets(freeze)
+
+ source.replace_start_line(start_line)
+ source.replace_offsets(offsets)
+
+ comments = loader.load_comments(freeze)
+ magic_comments = loader.load_magic_comments(freeze)
+ data_loc = loader.load_optional_location_object(freeze)
+ errors = loader.load_errors(encoding, freeze)
+ warnings = loader.load_warnings(encoding, freeze)
+ continuable = loader.load_bool
+ cpool_base = loader.load_uint32
+ cpool_size = loader.load_varuint
+
+ constant_pool = ConstantPool.new(serialized, cpool_base, cpool_size)
+
+ node = loader.load_node(constant_pool, encoding, freeze) #: ProgramNode
+ loader.load_constant_pool(constant_pool)
+ raise unless loader.eof?
+
+ result = ParseResult.new(node, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+ result.freeze if freeze
+
+ input.force_encoding(encoding)
+
+ # This is an extremely niche use-case where the file was marked as binary
+ # but it contained UTF-8-encoded characters. In that case we will actually
+ # put it back to UTF-8 to give the location APIs the best chance of being
+ # correct.
+ if !input.ascii_only? && input.encoding == Encoding::BINARY
+ input.force_encoding(Encoding::UTF_8)
+ input.force_encoding(Encoding::BINARY) unless input.valid_encoding?
+ end
+
+ if freeze
+ input.freeze
+ source.deep_freeze
+ end
+
+ result
+ end
+
+ # Deserialize the dumped output from a request to lex or lex_file.
+ #
+ # The formatting of the source of this method is purposeful to illustrate
+ # the structure of the serialized data.
+ #--
+ #: (String input, String serialized, bool freeze) -> LexResult
+ def self.load_lex(input, serialized, freeze)
+ source = Source.for(input, 1, [])
+ loader = Loader.new(source, serialized)
+
+ tokens = loader.load_tokens
+ encoding = loader.load_encoding
+ start_line = loader.load_varsint
+ offsets = loader.load_line_offsets(freeze)
+
+ source.replace_start_line(start_line)
+ source.replace_offsets(offsets)
+
+ comments = loader.load_comments(freeze)
+ magic_comments = loader.load_magic_comments(freeze)
+ data_loc = loader.load_optional_location_object(freeze)
+ errors = loader.load_errors(encoding, freeze)
+ warnings = loader.load_warnings(encoding, freeze)
+ continuable = loader.load_bool
+ raise unless loader.eof?
+
+ result = LexResult.new(tokens, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+
+ tokens.each do |token|
+ token[0].value.force_encoding(encoding)
+
+ if freeze
+ token[0].deep_freeze
+ token.freeze
+ end
+ end
+
+ if freeze
+ source.deep_freeze
+ tokens.freeze
+ result.freeze
+ end
+
+ result
+ end
+
+ # Deserialize the dumped output from a request to parse_comments or
+ # parse_file_comments.
+ #
+ # The formatting of the source of this method is purposeful to illustrate
+ # the structure of the serialized data.
+ #--
+ #: (String input, String serialized, bool freeze) -> Array[Comment]
+ def self.load_parse_comments(input, serialized, freeze)
+ source = Source.for(input, 1, [])
+ loader = Loader.new(source, serialized)
+
+ loader.load_header
+ loader.load_encoding
+ start_line = loader.load_varsint
+
+ source.replace_start_line(start_line)
+
+ result = loader.load_comments(freeze)
+ raise unless loader.eof?
+
+ source.deep_freeze if freeze
+ result
+ end
+
+ # Deserialize the dumped output from a request to parse_lex or
+ # parse_lex_file.
+ #
+ # The formatting of the source of this method is purposeful to illustrate
+ # the structure of the serialized data.
+ #--
+ #: (String input, String serialized, bool freeze) -> ParseLexResult
+ def self.load_parse_lex(input, serialized, freeze)
+ source = Source.for(input, 1, [])
+ loader = Loader.new(source, serialized)
+
+ tokens = loader.load_tokens
+ loader.load_header
+ encoding = loader.load_encoding
+ start_line = loader.load_varsint
+ offsets = loader.load_line_offsets(freeze)
+
+ source.replace_start_line(start_line)
+ source.replace_offsets(offsets)
+
+ comments = loader.load_comments(freeze)
+ magic_comments = loader.load_magic_comments(freeze)
+ data_loc = loader.load_optional_location_object(freeze)
+ errors = loader.load_errors(encoding, freeze)
+ warnings = loader.load_warnings(encoding, freeze)
+ continuable = loader.load_bool
+ cpool_base = loader.load_uint32
+ cpool_size = loader.load_varuint
+
+ constant_pool = ConstantPool.new(serialized, cpool_base, cpool_size)
+
+ node = loader.load_node(constant_pool, encoding, freeze) #: ProgramNode
+ loader.load_constant_pool(constant_pool)
+ raise unless loader.eof?
+
+ value = [node, tokens] #: [ProgramNode, Array[[Token, Integer]]]
+ result = ParseLexResult.new(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
+
+ tokens.each do |token|
+ token[0].value.force_encoding(encoding)
+
+ if freeze
+ token[0].deep_freeze
+ token.freeze
+ end
+ end
+
+ if freeze
+ source.deep_freeze
+ tokens.freeze
+ value.freeze
+ result.freeze
+ end
+
+ result
+ end
+
+ class ConstantPool # :nodoc:
+ attr_reader :size #: Integer
+
+ # @rbs @serialized: String
+ # @rbs @base: Integer
+ # @rbs @pool: Array[Symbol?]
+
+ #: (String serialized, Integer base, Integer size) -> void
+ def initialize(serialized, base, size)
+ @serialized = serialized
+ @base = base
+ @size = size
+ @pool = Array.new(size, nil)
+ end
+
+ #: (Integer index, Encoding encoding) -> Symbol
+ def get(index, encoding)
+ @pool[index] ||=
+ begin
+ offset = @base + index * 8
+ start = @serialized.unpack1("L", offset: offset) #: Integer
+ length = @serialized.unpack1("L", offset: offset + 4) #: Integer
+
+ (@serialized.byteslice(start, length) or raise).force_encoding(encoding).to_sym
+ end
+ end
+ end
+
+ if RUBY_ENGINE == "truffleruby"
+ # StringIO is synchronized and that adds a high overhead on TruffleRuby.
+ # @rbs skip
+ class FastStringIO # :nodoc:
+ attr_accessor :pos
+
+ def initialize(string)
+ @string = string
+ @pos = 0
+ end
+
+ def getbyte
+ byte = @string.getbyte(@pos)
+ @pos += 1
+ byte
+ end
+
+ def read(n)
+ slice = @string.byteslice(@pos, n)
+ @pos += n
+ slice
+ end
+
+ def eof?
+ @pos >= @string.bytesize
+ end
+ end
+ else
+ FastStringIO = ::StringIO # :nodoc:
+ end
+
+ class Loader # :nodoc:
+ attr_reader :input #: String
+ attr_reader :io #: StringIO
+ attr_reader :source #: Source
+
+ #: (Source source, String serialized) -> void
+ def initialize(source, serialized)
+ @input = source.source.dup
+ raise unless serialized.encoding == Encoding::BINARY
+ @io = FastStringIO.new(serialized)
+ @source = source
+ define_load_node_lambdas if RUBY_ENGINE != "ruby"
+ end
+
+ #: () -> bool
+ def eof?
+ io.getbyte
+ io.eof?
+ end
+
+ #: (ConstantPool constant_pool) -> void
+ def load_constant_pool(constant_pool)
+ trailer = 0
+
+ constant_pool.size.times do |index|
+ length = (io.read(8) or raise).unpack1("L", offset: 4) #: Integer
+ trailer += length
+ end
+
+ io.read(trailer)
+ end
+
+ #: () -> void
+ def load_header
+ raise "Invalid serialization" if io.read(5) != "PRISM"
+ raise "Invalid serialization" if (io.read(3) or raise).unpack("C3") != [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION]
+ raise "Invalid serialization (location fields must be included but are not)" if io.getbyte != 0
+ end
+
+ #: () -> Encoding
+ def load_encoding
+ encoding = Encoding.find((io.read(load_varuint) or raise)) or raise
+ @input = input.force_encoding(encoding).freeze
+ encoding
+ end
+
+ #: (bool freeze) -> Array[Integer]
+ def load_line_offsets(freeze)
+ offsets = Array.new(load_varuint) { load_varuint }
+ offsets.freeze if freeze
+ offsets
+ end
+
+ #: (bool freeze) -> Array[Comment]
+ def load_comments(freeze)
+ comments =
+ Array.new(load_varuint) do
+ comment =
+ case load_varuint
+ when 0 then InlineComment.new(load_location_object(freeze))
+ when 1 then EmbDocComment.new(load_location_object(freeze))
+ else raise
+ end
+
+ comment.freeze if freeze
+ comment
+ end
+
+ comments.freeze if freeze
+ comments
+ end
+
+ #: (bool freeze) -> Array[MagicComment]
+ def load_magic_comments(freeze)
+ magic_comments =
+ Array.new(load_varuint) do
+ magic_comment =
+ MagicComment.new(
+ load_location_object(freeze),
+ load_location_object(freeze)
+ )
+
+ magic_comment.freeze if freeze
+ magic_comment
+ end
+
+ magic_comments.freeze if freeze
+ magic_comments
+ end
+
+ DIAGNOSTIC_TYPES = [
+ <%- errors.each do |error| -%>
+ <%= error.name.downcase.to_sym.inspect %>,
+ <%- end -%>
+ <%- warnings.each do |warning| -%>
+ <%= warning.name.downcase.to_sym.inspect %>,
+ <%- end -%>
+ ].freeze #: Array[Symbol]
+
+ private_constant :DIAGNOSTIC_TYPES
+
+ #: () -> Symbol
+ def load_error_level
+ level = io.getbyte
+
+ case level
+ when 0
+ :syntax
+ when 1
+ :argument
+ when 2
+ :load
+ else
+ raise "Unknown level: #{level}"
+ end
+ end
+
+ #: (Encoding encoding, bool freeze) -> Array[ParseError]
+ def load_errors(encoding, freeze)
+ errors =
+ Array.new(load_varuint) do
+ error =
+ ParseError.new(
+ DIAGNOSTIC_TYPES.fetch(load_varuint),
+ load_string(encoding),
+ load_location_object(freeze),
+ load_error_level
+ )
+
+ error.freeze if freeze
+ error
+ end
+
+ errors.freeze if freeze
+ errors
+ end
+
+ #: () -> Symbol
+ def load_warning_level
+ level = io.getbyte
+
+ case level
+ when 0
+ :default
+ when 1
+ :verbose
+ else
+ raise "Unknown level: #{level}"
+ end
+ end
+
+ #: (Encoding encoding, bool freeze) -> Array[ParseWarning]
+ def load_warnings(encoding, freeze)
+ warnings =
+ Array.new(load_varuint) do
+ warning =
+ ParseWarning.new(
+ DIAGNOSTIC_TYPES.fetch(load_varuint),
+ load_string(encoding),
+ load_location_object(freeze),
+ load_warning_level
+ )
+
+ warning.freeze if freeze
+ warning
+ end
+
+ warnings.freeze if freeze
+ warnings
+ end
+
+ #: () -> Array[[Token, Integer]]
+ def load_tokens
+ tokens = [] #: Array[[Token, Integer]]
+
+ while (type = TOKEN_TYPES.fetch(load_varuint))
+ location = load_location_object(false)
+
+ lex_state = load_varuint
+
+ token = Token.new(@source, type, location.slice, location)
+
+ tokens << [token, lex_state]
+ end
+
+ tokens
+ end
+
+ # variable-length integer using https://en.wikipedia.org/wiki/LEB128
+ # This is also what protobuf uses: https://protobuf.dev/programming-guides/encoding/#varints
+ #--
+ #: () -> Integer
+ def load_varuint
+ n = (io.getbyte or raise)
+ if n < 128
+ n
+ else
+ n -= 128
+ shift = 0
+ while (b = (io.getbyte or raise)) >= 128
+ n += (b - 128) << (shift += 7)
+ end
+ n + (b << (shift + 7))
+ end
+ end
+
+ #: () -> Integer
+ def load_varsint
+ n = load_varuint
+ (n >> 1) ^ (-(n & 1))
+ end
+
+ #: () -> Integer
+ def load_integer
+ negative = io.getbyte != 0
+ length = load_varuint
+
+ value = 0
+ length.times { |index| value |= (load_varuint << (index * 32)) }
+
+ value = -value if negative
+ value
+ end
+
+ #: () -> Float
+ def load_double
+ (io.read(8) or raise).unpack1("D") #: Float
+ end
+
+ #: () -> bool
+ def load_bool
+ (io.getbyte or raise) != 0
+ end
+
+ #: () -> Integer
+ def load_uint32
+ (io.read(4) or raise).unpack1("L") #: Integer
+ end
+
+ #: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node?
+ def load_optional_node(constant_pool, encoding, freeze)
+ if io.getbyte != 0
+ io.pos -= 1
+ load_node(constant_pool, encoding, freeze)
+ end
+ end
+
+ #: (Encoding encoding) -> String
+ def load_string(encoding)
+ (io.read(load_varuint) or raise).force_encoding(encoding).freeze
+ end
+
+ #: (bool freeze) -> Location
+ def load_location_object(freeze)
+ location = Location.new(source, load_varuint, load_varuint)
+ location.freeze if freeze
+ location
+ end
+
+ # Load a location object from the serialized data. Note that we are lying
+ # about the signature a bit here, because we sometimes load it as a packed
+ # integer instead of an object.
+ #--
+ #: (bool freeze) -> Location
+ def load_location(freeze)
+ return load_location_object(freeze) if freeze
+ (load_varuint << 32) | load_varuint #: Location
+ end
+
+ # Load an optional location object from the serialized data if it is
+ # present. Note that we are lying about the signature a bit here, because
+ # we sometimes load it as a packed integer instead of an object.
+ #--
+ #: (bool freeze) -> Location?
+ def load_optional_location(freeze)
+ load_location(freeze) if io.getbyte != 0
+ end
+
+ #: (bool freeze) -> Location?
+ def load_optional_location_object(freeze)
+ load_location_object(freeze) if io.getbyte != 0
+ end
+
+ #: (ConstantPool constant_pool, Encoding encoding) -> Symbol
+ def load_constant(constant_pool, encoding)
+ index = load_varuint
+ constant_pool.get(index - 1, encoding)
+ end
+
+ #: (ConstantPool constant_pool, Encoding encoding) -> Symbol?
+ def load_optional_constant(constant_pool, encoding)
+ index = load_varuint
+ constant_pool.get(index - 1, encoding) if index != 0
+ end
+
+ if RUBY_ENGINE == "ruby"
+ #: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node
+ def load_node(constant_pool, encoding, freeze)
+ type = io.getbyte
+ node_id = load_varuint
+ location = load_location(freeze) #: Location
+ value =
+ case type
+ <%- nodes.each_with_index do |node, index| -%>
+ when <%= index + 1 %>
+ <%- if node.needs_serialized_length? -%>
+ load_uint32
+ <%- end -%>
+ <%= node.name %>.new(
+ source,
+ node_id,
+ location,
+ load_varuint,
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ load_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %>
+ <%- when Prism::Template::OptionalNodeField -%>
+ load_optional_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %>
+ <%- when Prism::Template::StringField -%>
+ load_string(encoding),
+ <%- when Prism::Template::NodeListField -%>
+ Array.new(load_varuint) do
+ load_node(constant_pool, encoding, freeze) #: <%= field.element_rbs_class %>
+ end.tap { |nodes| nodes.freeze if freeze },
+ <%- when Prism::Template::ConstantField -%>
+ load_constant(constant_pool, encoding),
+ <%- when Prism::Template::OptionalConstantField -%>
+ load_optional_constant(constant_pool, encoding),
+ <%- when Prism::Template::ConstantListField -%>
+ Array.new(load_varuint) { load_constant(constant_pool, encoding) }.tap { |constants| constants.freeze if freeze },
+ <%- when Prism::Template::LocationField -%>
+ load_location(freeze),
+ <%- when Prism::Template::OptionalLocationField -%>
+ load_optional_location(freeze),
+ <%- when Prism::Template::UInt8Field -%>
+ (io.getbyte or raise),
+ <%- when Prism::Template::UInt32Field -%>
+ load_varuint,
+ <%- when Prism::Template::IntegerField -%>
+ load_integer,
+ <%- when Prism::Template::DoubleField -%>
+ load_double,
+ <%- else raise -%>
+ <%- end -%>
+ <%- end -%>
+ )
+ <%- end -%>
+ else
+ raise "Unknown node type: #{type}"
+ end
+
+ value.freeze if freeze
+ value
+ end
+ else
+ # @rbs skip
+ def load_node(constant_pool, encoding, freeze)
+ @load_node_lambdas[(io.getbyte or raise)].call(constant_pool, encoding, freeze)
+ end
+
+ # @rbs skip
+ def define_load_node_lambdas
+ @load_node_lambdas = [
+ nil,
+ <%- nodes.each do |node| -%>
+ -> (constant_pool, encoding, freeze) {
+ node_id = load_varuint
+ location = load_location(freeze)
+ <%- if node.needs_serialized_length? -%>
+ load_uint32
+ <%- end -%>
+ value =
+ <%= node.name %>.new(
+ source,
+ node_id,
+ location,
+ load_varuint,
+ <%- node.fields.map do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ load_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %>
+ <%- when Prism::Template::OptionalNodeField -%>
+ load_optional_node(constant_pool, encoding, freeze), #: <%= field.rbs_class %>
+ <%- when Prism::Template::StringField -%>
+ load_string(encoding),
+ <%- when Prism::Template::NodeListField -%>
+ Array.new(load_varuint) do
+ load_node(constant_pool, encoding, freeze) #: <%= field.element_rbs_class %>
+ end,
+ <%- when Prism::Template::ConstantField -%>
+ load_constant(constant_pool, encoding),
+ <%- when Prism::Template::OptionalConstantField -%>
+ load_optional_constant(constant_pool, encoding),
+ <%- when Prism::Template::ConstantListField -%>
+ Array.new(load_varuint) { load_constant(constant_pool, encoding) },
+ <%- when Prism::Template::LocationField -%>
+ load_location(freeze),
+ <%- when Prism::Template::OptionalLocationField -%>
+ load_optional_location(freeze),
+ <%- when Prism::Template::UInt8Field -%>
+ (io.getbyte or raise),
+ <%- when Prism::Template::UInt32Field -%>
+ load_varuint,
+ <%- when Prism::Template::IntegerField -%>
+ load_integer,
+ <%- when Prism::Template::DoubleField -%>
+ load_double,
+ <%- else raise -%>
+ <%- end -%>
+ <%- end -%>
+ )
+ value.freeze if freeze
+ value
+ },
+ <%- end -%>
+ ]
+ end
+ end
+
+ # @rbs!
+ # @load_node_lambdas: Array[Proc]
+ # def define_load_node_lambdas: () -> void
+ end
+
+ # The token types that can be indexed by their enum values.
+ TOKEN_TYPES = [
+ nil,
+ <%- tokens.each do |token| -%>
+ <%= token.name.to_sym.inspect %>,
+ <%- end -%>
+ ].freeze #: Array[Symbol?]
+
+ private_constant :MAJOR_VERSION, :MINOR_VERSION, :PATCH_VERSION
+ private_constant :ConstantPool, :FastStringIO, :Loader, :TOKEN_TYPES
+ end
+
+ private_constant :Serialize
+end
diff --git a/prism/templates/lib/prism/visitor.rb.erb b/prism/templates/lib/prism/visitor.rb.erb
new file mode 100644
index 0000000000..f23e87d99e
--- /dev/null
+++ b/prism/templates/lib/prism/visitor.rb.erb
@@ -0,0 +1,73 @@
+#--
+# rbs_inline: enabled
+
+module Prism
+ # @rbs!
+ # interface _Visitor
+ # <% nodes.each do |node| %>
+ # def visit_<%= node.human %>: (<%= node.name %>) -> void
+ # <% end %>
+ # end
+
+ # A class that knows how to walk down the tree. None of the individual visit
+ # methods are implemented on this visitor, so it forces the consumer to
+ # implement each one that they need. For a default implementation that
+ # continues walking the tree, see the Visitor class.
+ class BasicVisitor
+ # Calls `accept` on the given node if it is not `nil`, which in turn should
+ # call back into this visitor by calling the appropriate `visit_*` method.
+ #--
+ #: (node? node) -> void
+ def visit(node)
+ # @type self: _Visitor
+ node&.accept(self)
+ end
+
+ # Visits each node in `nodes` by calling `accept` on each one.
+ #--
+ #: (Array[node?] nodes) -> void
+ def visit_all(nodes)
+ # @type self: _Visitor
+ nodes.each { |node| node&.accept(self) }
+ end
+
+ # Visits the child nodes of `node` by calling `accept` on each one.
+ #--
+ #: (node node) -> void
+ def visit_child_nodes(node)
+ # @type self: _Visitor
+ node.each_child_node { |node| node.accept(self) }
+ end
+ end
+
+ # A visitor is a class that provides a default implementation for every accept
+ # method defined on the nodes. This means it can walk a tree without the
+ # caller needing to define any special handling. This allows you to handle a
+ # subset of the tree, while still walking the whole tree.
+ #
+ # For example, to find all of the method calls that call the `foo` method, you
+ # could write:
+ #
+ # class FooCalls < Prism::Visitor
+ # def visit_call_node(node)
+ # if node.name == :foo
+ # # Do something with the node
+ # end
+ #
+ # # Call super so that the visitor continues walking the tree
+ # super
+ # end
+ # end
+ #
+ class Visitor < BasicVisitor
+ <%- nodes.each_with_index do |node, index| -%>
+<%= "\n" if index != 0 -%>
+ # Visit a <%= node.name %> node
+ #--
+ #: (<%= node.name %> node) -> void
+ def visit_<%= node.human %>(node)
+ node.each_child_node { |node| node.accept(self) }
+ end
+ <%- end -%>
+ end
+end
diff --git a/prism/templates/src/diagnostic.c.erb b/prism/templates/src/diagnostic.c.erb
new file mode 100644
index 0000000000..0dea732869
--- /dev/null
+++ b/prism/templates/src/diagnostic.c.erb
@@ -0,0 +1,554 @@
+#include "prism/internal/diagnostic.h"
+
+#include "prism/compiler/inline.h"
+
+#include "prism/internal/allocator.h"
+#include "prism/internal/arena.h"
+#include "prism/internal/list.h"
+
+#include <assert.h>
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define PM_DIAGNOSTIC_ID_MAX <%= errors.length + warnings.length %>
+
+/** This struct holds the data for each diagnostic. */
+typedef struct {
+ /** The message associated with the diagnostic. */
+ const char* message;
+
+ /** The level associated with the diagnostic. */
+ uint8_t level;
+} pm_diagnostic_data_t;
+
+/**
+ * ## Message composition
+ *
+ * When composing an error message, use sentence fragments.
+ *
+ * Try describing the property of the code that caused the error, rather than
+ * the rule that is being violated. It may help to use a fragment that completes
+ * a sentence beginning, "the parser encountered (a) ...". If appropriate, add a
+ * description of the rule violation (or other helpful context) after a
+ * semicolon.
+ *
+ * For example:, instead of "control escape sequence cannot be doubled", prefer:
+ *
+ * > "invalid control escape sequence; control cannot be repeated"
+ *
+ * In some cases, where the failure is more general or syntax expectations are
+ * violated, it may make more sense to use a fragment that completes a sentence
+ * beginning, "the parser ...".
+ *
+ * For example:
+ *
+ * > "expected an expression after `(`"
+ * > "cannot parse the expression"
+ *
+ * ## Message style guide
+ *
+ * - Use articles like "a", "an", and "the" when appropriate.
+ * - e.g., prefer "cannot parse the expression" to "cannot parse expression".
+ * - Use the common name for tokens and nodes.
+ * - e.g., prefer "keyword splat" to "assoc splat"
+ * - e.g., prefer "embedded document" to "embdoc"
+ * - Do not capitalize the initial word of the message.
+ * - Use back ticks around token literals
+ * - e.g., "Expected a `=>` between the hash key and value"
+ * - Do not use `.` or other punctuation at the end of the message.
+ * - Do not use contractions like "can't". Prefer "cannot" to "can not".
+ * - For tokens that can have multiple meanings, reference the token and its meaning.
+ * - e.g., "`*` splat argument" is clearer and more complete than "splat argument" or "`*` argument"
+ *
+ * ## Error names (PM_ERR_*)
+ *
+ * - When appropriate, prefer node name to token name.
+ * - e.g., prefer "SPLAT" to "STAR" in the context of argument parsing.
+ * - Prefer token name to common name.
+ * - e.g., prefer "STAR" to "ASTERISK".
+ * - Try to order the words in the name from more general to more specific,
+ * - e.g., "INVALID_NUMBER_DECIMAL" is better than "DECIMAL_INVALID_NUMBER".
+ * - When in doubt, look for similar patterns and name them so that they are grouped when lexically
+ * sorted. See PM_ERR_ARGUMENT_NO_FORWARDING_* for an example.
+ *
+ * ## Level
+ *
+ * For errors, they are:
+ *
+ * * `PM_ERROR_LEVEL_SYNTAX` - Errors that should raise SyntaxError.
+ * * `PM_ERROR_LEVEL_ARGUMENT` - Errors that should raise ArgumentError.
+ * * `PM_ERROR_LEVEL_LOAD` - Errors that should raise LoadError.
+ *
+ * For warnings, they are:
+ *
+ * * `PM_WARNING_LEVEL_DEFAULT` - Warnings that appear for `ruby -c -e 'code'`.
+ * * `PM_WARNING_LEVEL_VERBOSE` - Warnings that appear with `-w`, as in `ruby -w -c -e 'code'`.
+ */
+static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
+ /* Special error that can be replaced */
+ [PM_ERR_CANNOT_PARSE_EXPRESSION] = { "cannot parse the expression", PM_ERROR_LEVEL_SYNTAX },
+
+ /* Errors that should raise argument errors */
+ [PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = { "unknown or invalid encoding in the magic comment", PM_ERROR_LEVEL_ARGUMENT },
+
+ /* Errors that should raise load errors */
+ [PM_ERR_SCRIPT_NOT_FOUND] = { "no Ruby script found in input", PM_ERROR_LEVEL_LOAD },
+
+ /* Errors that should raise syntax errors */
+ [PM_ERR_ALIAS_ARGUMENT] = { "invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE] = { "invalid argument being passed to `alias`; can't make alias for the number variables", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = { "unexpected `&&=` in a multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_AFTER_BLOCK] = { "unexpected argument after a block argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = { "unexpected argument after `...`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_BARE_HASH] = { "unexpected bare hash argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_BLOCK_MULTI] = { "both block arg and actual block given; only one block is allowed", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_CONFLICT_AMPERSAND] = { "unexpected `&`; anonymous block parameter is also used within block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_CONFLICT_STAR] = { "unexpected `*`; anonymous rest parameter is also used within block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_CONFLICT_STAR_STAR] = { "unexpected `**`; anonymous keyword rest parameter is also used within block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_FORMAL_CLASS] = { "invalid formal argument; formal argument cannot be a class variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_FORMAL_CONSTANT] = { "invalid formal argument; formal argument cannot be a constant", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_FORMAL_GLOBAL] = { "invalid formal argument; formal argument cannot be a global variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_FORMAL_IVAR] = { "invalid formal argument; formal argument cannot be an instance variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = { "unexpected `...` in an non-parenthesized call", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND] = { "unexpected `&`; no anonymous block parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = { "unexpected ... when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA] = { "unexpected ... in lambda argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK] = { "unexpected ... in block argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = { "unexpected `*`; no anonymous rest parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR] = { "unexpected `**`; no anonymous keyword rest parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = { "unexpected `*` splat argument after a `**` keyword splat argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = { "unexpected `*` splat argument after a `*` splat argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_TERM_PAREN] = { "unexpected %s; expected a `)` to close the arguments", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARGUMENT_UNEXPECTED_BLOCK] = { "unexpected '{' after a method call without parenthesis", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARRAY_ELEMENT] = { "expected an element for the array", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARRAY_EXPRESSION] = { "expected an expression for the array element", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARRAY_EXPRESSION_AFTER_STAR] = { "expected an expression after `*` in the array", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARRAY_SEPARATOR] = { "unexpected %s; expected a `,` separator for the array elements", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ARRAY_TERM] = { "unexpected %s; expected a `]` to close the array", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BEGIN_LONELY_ELSE] = { "unexpected `else` in `begin` block; else without rescue is useless", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BEGIN_TERM] = { "expected an `end` to close the `begin` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BEGIN_UPCASE_BRACE] = { "expected a `{` after `BEGIN`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BEGIN_UPCASE_TERM] = { "expected a `}` to close the `BEGIN` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BEGIN_UPCASE_TOPLEVEL] = { "BEGIN is permitted only at toplevel", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE] = { "expected a local variable name in the block parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BLOCK_PARAM_PIPE_TERM] = { "expected the block parameters to end with `|`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BLOCK_TERM_BRACE] = { "expected a block beginning with `{` to end with `}`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_BLOCK_TERM_END] = { "expected a block beginning with `do` to end with `end`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CANNOT_PARSE_STRING_PART] = { "cannot parse the string part", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CASE_EXPRESSION_AFTER_CASE] = { "expected an expression after `case`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CASE_EXPRESSION_AFTER_WHEN] = { "expected an expression after `when`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CASE_MATCH_MISSING_PREDICATE] = { "expected a predicate for a case matching statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CASE_MISSING_CONDITIONS] = { "expected a `when` or `in` clause after `case`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CASE_TERM] = { "expected an `end` to close the `case` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_IN_METHOD] = { "unexpected class definition in method body", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_NAME] = { "unexpected constant path after `class`; class/module name must be CONSTANT", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_SUPERCLASS] = { "expected a superclass after `<`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_TERM] = { "expected an `end` to close the `class` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_UNEXPECTED_END] = { "unexpected `end`, expecting ';' or '\\n'", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CLASS_VARIABLE_BARE] = { "'@@' without identifiers is not allowed as a class variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_ELSIF_PREDICATE] = { "expected a predicate expression for the `elsif` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_IF_PREDICATE] = { "expected a predicate expression for the `if` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_PREDICATE_TERM] = { "expected `then` or `;` or '\\n'", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_TERM] = { "expected an `end` to close the conditional clause", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_TERM_ELSE] = { "expected an `end` to close the `else` clause", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_UNLESS_PREDICATE] = { "expected a predicate expression for the `unless` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_UNTIL_PREDICATE] = { "expected a predicate expression for the `until` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONDITIONAL_WHILE_PREDICATE] = { "expected a predicate expression for the `while` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT] = { "expected a constant after the `::` operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_ENDLESS] = { "could not parse the endless method body", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_ENDLESS_PARAMETERS] = { "could not parse the endless method parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_ENDLESS_SETTER] = { "invalid method name; a setter method cannot be defined in an endless method definition", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_ENDLESS_DO_BLOCK] = { "unexpected `do` for block in an endless method definition", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_NAME] = { "unexpected %s; expected a method name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_PARAMS_TERM] = { "expected a delimiter to close the parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_PARAMS_TERM_PAREN] = { "unexpected %s; expected a `)` to close the parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_RECEIVER] = { "expected a receiver for the method definition", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_RECEIVER_TERM] = { "expected a `.` or `::` after the receiver in a method definition", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEF_TERM] = { "expected an `end` to close the `def` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_DEFINED_EXPRESSION] = { "expected an expression after `defined?`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EMBDOC_TERM] = { "embedded document meets end of file", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EMBEXPR_END] = { "expected a `}` to close the embedded expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EMBVAR_INVALID] = { "invalid embedded variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_END_UPCASE_BRACE] = { "expected a `{` after `END`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_END_UPCASE_TERM] = { "expected a `}` to close the `END` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_CONTROL] = { "Invalid escape character syntax", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT] = { "invalid control escape sequence; control cannot be repeated", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_HEXADECIMAL] = { "invalid hex escape sequence", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_META] = { "Invalid escape character syntax", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_META_REPEAT] = { "invalid meta escape sequence; meta cannot be repeated", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE] = { "invalid Unicode escape sequence", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS] = { "invalid Unicode escape sequence; Unicode cannot be combined with control or meta flags", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_LIST] = { "invalid Unicode list: %.*s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL] = { "invalid Unicode escape sequence; Multiple codepoints at single character literal are disallowed", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_LONG] = { "invalid Unicode escape sequence; maximum length is 6 digits", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_SHORT] = { "too short escape sequence: %.*s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_ESCAPE_INVALID_UNICODE_TERM] = { "unterminated Unicode escape", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_ARGUMENT] = { "unexpected %s; expected an argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EOL_AFTER_STATEMENT] = { "unexpected %s, expecting end-of-input", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ] = { "expected an expression after `&&=`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ] = { "expected an expression after `||=`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA] = { "expected an expression after `,`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL] = { "expected an expression after `=`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS] = { "expected an expression after `<<`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN] = { "expected an expression after `(`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR] = { "unexpected %s; expected an expression after the operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT] = { "expected an expression after `*` splat in an argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH] = { "expected an expression after `**` in a hash", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_STAR] = { "expected an expression after `*`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_FOR_DELIMITER] = { "unexpected %s; expected a 'do', newline, or ';' after the 'for' loop collection", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_IDENT_REQ_PARAMETER] = { "expected an identifier for the required parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_IN_DELIMITER] = { "expected a delimiter after the patterns of an `in` clause", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_LPAREN_AFTER_NOT_LPAREN] = { "expected a `(` immediately after `not`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_LPAREN_AFTER_NOT_OTHER] = { "expected a `(` after `not`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_LPAREN_REQ_PARAMETER] = { "expected a `(` to start a required parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_MESSAGE] = { "unexpected %s; expecting a message to send to the receiver", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_RBRACKET] = { "expected a matching `]`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_RPAREN] = { "expected a matching `)`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_RPAREN_AFTER_MULTI] = { "expected a `)` after multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_RPAREN_REQ_PARAMETER] = { "expected a `)` to end a required parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER] = { "unexpected %s; expected a newline or a ';' after the singleton class", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_STRING_CONTENT] = { "expected string content after opening string delimiter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPECT_WHEN_DELIMITER] = { "expected a delimiter after the predicates of a `when` clause", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_BARE_HASH] = { "unexpected bare hash in expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE] = { "unexpected '='; target cannot be written", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING] = { "Can't assign to __ENCODING__", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE] = { "Can't assign to false", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_FILE] = { "Can't assign to __FILE__", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_LINE] = { "Can't assign to __LINE__", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_NIL] = { "Can't assign to nil", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED] = { "Can't assign to numbered parameter %.2s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_SELF] = { "Can't change the value of self", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE] = { "Can't assign to true", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_FLOAT_PARSE] = { "could not parse the float '%.*s'", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_FOR_COLLECTION] = { "expected a collection after the `in` in a `for` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_FOR_INDEX] = { "expected an index after `for`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_FOR_IN] = { "expected an `in` after the index in a `for` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_FOR_TERM] = { "expected an `end` to close the `for` loop", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_GLOBAL_VARIABLE_BARE] = { "'$' without identifiers is not allowed as a global variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HASH_EXPRESSION_AFTER_LABEL] = { "expected an expression after the label in a hash", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HASH_KEY] = { "unexpected %s, expecting '}' or a key in the hash literal", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HASH_ROCKET] = { "expected a `=>` between the hash key and value", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HASH_TERM] = { "expected a `}` to close the hash literal", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HASH_VALUE] = { "unexpected %s; expected a value in the hash literal", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HEREDOC_IDENTIFIER] = { "unterminated here document identifier", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_HEREDOC_TERM] = { "unterminated heredoc; can't find string \"%.*s\" anywhere before EOF", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INCOMPLETE_QUESTION_MARK] = { "incomplete expression at `?`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3] = { "`%.*s' is not allowed as a class variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INCOMPLETE_VARIABLE_CLASS] = { "'%.*s' is not allowed as a class variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3] = { "`%.*s' is not allowed as an instance variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE] = { "'%.*s' is not allowed as an instance variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INSTANCE_VARIABLE_BARE] = { "'@' without identifiers is not allowed as an instance variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_BLOCK_EXIT] = { "Invalid %s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_COMMA] = { "invalid comma", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_ESCAPE_CHARACTER] = { "Invalid escape character syntax", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_FLOAT_EXPONENT] = { "invalid exponent", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_LOCAL_VARIABLE_READ] = { "identifier %.*s is not valid to get", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_LOCAL_VARIABLE_WRITE] = { "identifier %.*s is not valid to set", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_BINARY] = { "invalid binary number; numeric literal without digits", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_DECIMAL] = { "invalid decimal number; numeric literal without digits", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_FRACTION] = { "unexpected fraction part after numeric literal", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_HEXADECIMAL] = { "invalid hexadecimal number; numeric literal without digits", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_OCTAL] = { "invalid octal number; numeric literal without digits", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER] = { "invalid underscore placement in number", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING] = { "trailing '_' in number", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_CHARACTER] = { "Invalid char '\\x%02X' in expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_MULTIBYTE_CHAR] = { "invalid multibyte char (%s)", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_MULTIBYTE_CHARACTER] = { "invalid multibyte character 0x%X", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_MULTIBYTE_ESCAPE] = { "invalid multibyte escape: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_PRINTABLE_CHARACTER] = { "invalid character `%c`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_PERCENT] = { "unknown type of %string", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_PERCENT_EOF] = { "unterminated quoted string meets end of file", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_RETRY_AFTER_ELSE] = { "Invalid retry after else", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_RETRY_AFTER_ENSURE] = { "Invalid retry after ensure", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_RETRY_WITHOUT_RESCUE] = { "Invalid retry without rescue", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_SYMBOL] = { "invalid symbol", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_VARIABLE_GLOBAL_3_3] = { "`%.*s' is not allowed as a global variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_VARIABLE_GLOBAL] = { "'%.*s' is not allowed as a global variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_INVALID_YIELD] = { "Invalid yield", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_IT_NOT_ALLOWED_NUMBERED] = { "'it' is not allowed when a numbered parameter is already used", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_IT_NOT_ALLOWED_ORDINARY] = { "'it' is not allowed when an ordinary parameter is defined", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LAMBDA_OPEN] = { "expected a `do` keyword or a `{` to open the lambda block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LAMBDA_TERM_BRACE] = { "expected a lambda block beginning with `{` to end with `}`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LAMBDA_TERM_END] = { "expected a lambda block beginning with `do` to end with `end`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_I_LOWER_ELEMENT] = { "expected a symbol in a `%i` list", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_I_LOWER_TERM] = { "unterminated list; expected a closing delimiter for the `%i`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_I_UPPER_ELEMENT] = { "expected a symbol in a `%I` list", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_I_UPPER_TERM] = { "unterminated list; expected a closing delimiter for the `%I`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_W_LOWER_ELEMENT] = { "expected a string in a `%w` list", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_W_LOWER_TERM] = { "unterminated list; expected a closing delimiter for the `%w`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_W_UPPER_ELEMENT] = { "expected a string in a `%W` list", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_LIST_W_UPPER_TERM] = { "unterminated list; expected a closing delimiter for the `%W`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MALLOC_FAILED] = { "failed to allocate memory", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MIXED_ENCODING] = { "UTF-8 mixed within %s source", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MODULE_IN_METHOD] = { "unexpected module definition in method body", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MODULE_NAME] = { "unexpected constant path after `module`; class/module name must be CONSTANT", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MODULE_TERM] = { "expected an `end` to close the `module` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MULTI_ASSIGN_MULTI_SPLATS] = { "multiple splats in multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST] = { "unexpected '%.*s' resulting in multiple splats in multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NESTING_TOO_DEEP] = { "nesting too deep", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NO_LOCAL_VARIABLE] = { "%.*s: no such local variable", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NON_ASSOCIATIVE_OPERATOR] = { "unexpected %s; %s is a non-associative operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NOT_EXPRESSION] = { "expected an expression after `not`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NUMBER_LITERAL_UNDERSCORE] = { "number literal ending with a `_`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK] = { "numbered parameter is already used in inner block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NUMBERED_PARAMETER_IT] = { "numbered parameters are not allowed when 'it' is already used", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NUMBERED_PARAMETER_ORDINARY] = { "numbered parameters are not allowed when an ordinary parameter is defined", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK] = { "numbered parameter is already used in outer block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_OPERATOR_MULTI_ASSIGN] = { "unexpected operator for a multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_OPERATOR_WRITE_ARGUMENTS] = { "unexpected operator after a call with arguments", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_OPERATOR_WRITE_BLOCK] = { "unexpected operator after a call with a block", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = { "unexpected multiple `**` splat parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_BLOCK_MULTI] = { "multiple block parameters; only one block is allowed", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_CIRCULAR] = { "circular argument reference - %.*s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_FORWARDING_AFTER_REST] = { "... after rest argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_METHOD_NAME] = { "unexpected name for a parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_NAME_DUPLICATED] = { "duplicated argument name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_NO_DEFAULT] = { "expected a default value for the parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_NO_DEFAULT_KW] = { "expected a default value for the keyword parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_NUMBERED_RESERVED] = { "%.2s is reserved for numbered parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_ORDER] = { "unexpected parameter order", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_SPLAT_MULTI] = { "unexpected multiple `*` splat parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_STAR] = { "unexpected parameter `*`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_UNEXPECTED_FWD] = { "unexpected `...` in parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_WILD_LOOSE_COMMA] = { "unexpected `,` in parameters", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_UNEXPECTED_NO_KW] = { "unexpected **nil; no keywords marker disallowed after keywords", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS] = { "unexpected multiple '*' rest patterns in an array pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_CAPTURE_DUPLICATE] = { "duplicated variable name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE] = { "variable capture in alternative pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = { "expected a pattern expression after the `[` operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = { "expected a pattern expression after `,`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = { "expected a pattern expression after `=>`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_IN] = { "expected a pattern expression after the `in` keyword", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_KEY] = { "expected a pattern expression after the key", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN] = { "expected a pattern expression after the `(` operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PIN] = { "expected a pattern expression after the `^` pin operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE] = { "expected a pattern expression after the `|` operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE] = { "expected a pattern expression after the range operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_REST] = { "unexpected pattern expression after the `**` expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_FIND_MISSING_INNER] = { "find patterns need at least one required inner pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_IMPLICIT] = { "unexpected implicit hash in pattern; use '{' to delineate", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_KEY] = { "unexpected %s; expected a key in the hash pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_KEY_DUPLICATE] = { "duplicated key name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_KEY_INTERPOLATED] = { "symbol literal with interpolation is not allowed", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_KEY_LABEL] = { "expected a label as the key in the hash pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_HASH_KEY_LOCALS] = { "key must be valid as local variables", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_IDENT_AFTER_HROCKET] = { "expected an identifier after the `=>` operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_LABEL_AFTER_COMMA] = { "expected a label after the `,` in the hash pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_REST] = { "unexpected rest pattern", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_TERM_BRACE] = { "expected a `}` to close the pattern expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_TERM_BRACKET] = { "expected a `]` to close the pattern expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PATTERN_TERM_PAREN] = { "expected a `)` to close the pattern expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = { "unexpected `||=` in a multiple assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH] = { "regexp encoding option '%c' differs from source encoding '%s'", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8] = { "escaped non ASCII character in UTF-8 regexp: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING] = { "incompatible character encoding: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_INVALID_CHAR_PROPERTY] = { "invalid character property name {%.*s}: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_INVALID_UNICODE_RANGE] = { "invalid Unicode range: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_NON_ESCAPED_MBC] = { "/.../n has a non escaped non ASCII character in non ASCII-8BIT script: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_PARSE_ERROR] = { "%s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_UNKNOWN_OPTIONS] = { "unknown regexp %s - %.*s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_TERM] = { "unterminated regexp meets end of file; expected a closing delimiter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP] = { "UTF-8 character in non UTF-8 regexp: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_RESCUE_EXPRESSION] = { "expected a rescued expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_RESCUE_MODIFIER_VALUE] = { "expected a value after the `rescue` modifier", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_RESCUE_TERM] = { "expected a closing delimiter for the `rescue` clause", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_RESCUE_VARIABLE] = { "expected an exception variable after `=>` in a rescue statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_RETURN_INVALID] = { "Invalid return in class/module body", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_SINGLETON_FOR_LITERALS] = { "cannot define singleton method for literals", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STATEMENT_ALIAS] = { "unexpected an `alias` at a non-statement position", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STATEMENT_POSTEXE_END] = { "unexpected an `END` at a non-statement position", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STATEMENT_PREEXE_BEGIN] = { "unexpected a `BEGIN` at a non-statement position", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STATEMENT_UNDEF] = { "unexpected an `undef` at a non-statement position", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STRING_CONCATENATION] = { "expected a string for concatenation", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STRING_INTERPOLATED_TERM] = { "unterminated string; expected a closing delimiter for the interpolated string", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STRING_LITERAL_EOF] = { "unterminated string meets end of file", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_STRING_LITERAL_TERM] = { "unexpected %s, expected a string literal terminator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_SYMBOL_INVALID] = { "invalid symbol", PM_ERROR_LEVEL_SYNTAX }, /* TODO expected symbol? prism.c ~9719 */
+ [PM_ERR_SYMBOL_TERM_DYNAMIC] = { "unterminated quoted string; expected a closing delimiter for the dynamic symbol", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_SYMBOL_TERM_INTERPOLATED] = { "unterminated symbol; expected a closing delimiter for the interpolated symbol", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_TERNARY_COLON] = { "expected a `:` after the true expression of a ternary operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_TERNARY_EXPRESSION_FALSE] = { "expected an expression after `:` in the ternary operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_TERNARY_EXPRESSION_TRUE] = { "expected an expression after `?` in the ternary operator", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNARY_RECEIVER] = { "unexpected %s, expected a receiver for unary `%c`", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNARY_DISALLOWED] = { "unexpected %s; unary calls are not allowed in this context", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNDEF_ARGUMENT] = { "invalid argument being passed to `undef`; expected a bare word, constant, or symbol argument", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_BLOCK_ARGUMENT] = { "block argument should not be given", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_INDEX_BLOCK] = { "unexpected block arg given in index assignment; blocks are not allowed in index assignment expressions", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_INDEX_KEYWORDS] = { "unexpected keyword arg given in index assignment; keywords are not allowed in index assignment expressions", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_LABEL] = { "unexpected label", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_MULTI_WRITE] = { "unexpected multiple assignment; multiple assignment is not allowed in this context", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE] = { "unexpected %s; expected a default value for a parameter", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_RANGE_OPERATOR] = { "unexpected range operator; .. and ... are non-associative and cannot be chained", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_SAFE_NAVIGATION] = { "&. inside multiple assignment destination", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT] = { "unexpected %s, assuming it is closing the parent %s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNEXPECTED_TOKEN_IGNORE] = { "unexpected %s, ignoring it", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_UNTIL_TERM] = { "expected an `end` to close the `until` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_VOID_EXPRESSION] = { "unexpected void value expression", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_WHILE_TERM] = { "expected an `end` to close the `while` statement", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_WRITE_TARGET_IN_METHOD] = { "dynamic constant assignment", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_WRITE_TARGET_READONLY] = { "Can't set variable %.*s", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_WRITE_TARGET_UNEXPECTED] = { "unexpected write target", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_XSTRING_TERM] = { "expected a closing delimiter for the `%x` or backtick string", PM_ERROR_LEVEL_SYNTAX },
+
+ /* Warnings */
+ [PM_WARN_AMBIGUOUS_BINARY_OPERATOR] = { "'%s' after local variable or literal is interpreted as binary operator even though it seems like %s", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = { "ambiguous first argument; put parentheses or a space even after `-` operator", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = { "ambiguous first argument; put parentheses or a space even after `+` operator", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND] = { "ambiguous `&` has been interpreted as an argument prefix", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_PREFIX_STAR] = { "ambiguous `*` has been interpreted as an argument prefix", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR] = { "ambiguous `**` has been interpreted as an argument prefix", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_AMBIGUOUS_SLASH] = { "ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_COMPARISON_AFTER_COMPARISON] = { "comparison '%.*s' after comparison", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_DOT_DOT_DOT_EOL] = { "... at EOL, should be parenthesized?", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_DUPLICATED_HASH_KEY] = { "key %.*s is duplicated and overwritten on line %" PRIi32, PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_DUPLICATED_WHEN_CLAUSE] = { "'when' clause on line %" PRIi32 " duplicates 'when' clause on line %" PRIi32 " and is ignored", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_EQUAL_IN_CONDITIONAL_3_3] = { "found `= literal' in conditional, should be ==", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_EQUAL_IN_CONDITIONAL] = { "found '= literal' in conditional, should be ==", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_END_IN_METHOD] = { "END in method; use at_exit", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_FLOAT_OUT_OF_RANGE] = { "Float %.*s%s out of range", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_IGNORED_FROZEN_STRING_LITERAL] = { "'frozen_string_literal' is ignored after any tokens", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_INDENTATION_MISMATCH] = { "mismatched indentations at '%.*s' with '%.*s' at %" PRIi32, PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_INTEGER_IN_FLIP_FLOP] = { "integer literal in flip-flop", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_INVALID_CHARACTER] = { "invalid character syntax; use %s%s%s", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_INVALID_MAGIC_COMMENT_VALUE] = { "invalid value for %.*s: %.*s", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_INVALID_NUMBERED_REFERENCE] = { "'%.*s' is too big for a number variable, always nil", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_KEYWORD_EOL] = { "`%.*s` at the end of line without an expression", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_LITERAL_IN_CONDITION_DEFAULT] = { "%sliteral in %s", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_LITERAL_IN_CONDITION_VERBOSE] = { "%sliteral in %s", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE] = { "'shareable_constant_value' is ignored unless in comment-only line", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_SHEBANG_CARRIAGE_RETURN] = { "shebang line ending with \\r may cause problems", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_UNEXPECTED_CARRIAGE_RETURN] = { "encountered \\r in middle of line, treated as a mere space", PM_WARNING_LEVEL_DEFAULT },
+ [PM_WARN_UNREACHABLE_STATEMENT] = { "statement not reached", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_UNUSED_LOCAL_VARIABLE] = { "assigned but unused variable - %.*s", PM_WARNING_LEVEL_VERBOSE },
+ [PM_WARN_VOID_STATEMENT] = { "possibly useless use of %.*s in void context", PM_WARNING_LEVEL_VERBOSE }
+};
+
+/**
+ * Get the human-readable name of the given diagnostic ID.
+ */
+static const char *
+pm_diagnostic_id_name(pm_diagnostic_id_t diag_id) {
+ switch (diag_id) {
+ <%- errors.each do |error| -%>
+ case PM_ERR_<%= error.name %>: return "<%= error.name.downcase %>";
+ <%- end -%>
+ <%- warnings.each do |warning| -%>
+ case PM_WARN_<%= warning.name %>: return "<%= warning.name.downcase %>";
+ <%- end -%>
+ }
+
+ assert(false && "unreachable");
+ return "";
+}
+
+static PRISM_INLINE const char *
+pm_diagnostic_id_message(pm_diagnostic_id_t diag_id) {
+ assert(diag_id < PM_DIAGNOSTIC_ID_MAX);
+
+ const char *message = diagnostic_messages[diag_id].message;
+ assert(message);
+
+ return message;
+}
+
+static PRISM_INLINE uint8_t
+pm_diagnostic_id_level(pm_diagnostic_id_t diag_id) {
+ assert(diag_id < PM_DIAGNOSTIC_ID_MAX);
+
+ return (uint8_t) diagnostic_messages[diag_id].level;
+}
+
+/**
+ * Get the type of the given diagnostic.
+ */
+const char *
+pm_diagnostic_type(const pm_diagnostic_t *diagnostic) {
+ return pm_diagnostic_id_name(diagnostic->diag_id);
+}
+
+/**
+ * Get the location of the given diagnostic.
+ */
+pm_location_t
+pm_diagnostic_location(const pm_diagnostic_t *diagnostic) {
+ return diagnostic->location;
+}
+
+/**
+ * Get the message of the given diagnostic.
+ */
+const char *
+pm_diagnostic_message(const pm_diagnostic_t *diagnostic) {
+ return diagnostic->message;
+}
+
+/**
+ * Get the error level associated with the given diagnostic.
+ */
+pm_error_level_t
+pm_diagnostic_error_level(const pm_diagnostic_t *diagnostic) {
+ return (pm_error_level_t) pm_diagnostic_id_level(diagnostic->diag_id);
+}
+
+/**
+ * Get the warning level associated with the given diagnostic.
+ */
+pm_warning_level_t
+pm_diagnostic_warning_level(const pm_diagnostic_t *diagnostic) {
+ return (pm_warning_level_t) pm_diagnostic_id_level(diagnostic->diag_id);
+}
+
+/**
+ * Append an error to the given list of diagnostic.
+ */
+void
+pm_diagnostic_list_append(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id) {
+ pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) pm_arena_zalloc(arena, sizeof(pm_diagnostic_t), PRISM_ALIGNOF(pm_diagnostic_t));
+
+ *diagnostic = (pm_diagnostic_t) {
+ .location = { .start = start, .length = length },
+ .diag_id = diag_id,
+ .message = pm_diagnostic_id_message(diag_id),
+ .level = pm_diagnostic_id_level(diag_id)
+ };
+
+ pm_list_append(list, (pm_list_node_t *) diagnostic);
+}
+
+/**
+ * Append a diagnostic to the given list of diagnostics that is using a format
+ * string for its message.
+ */
+void
+pm_diagnostic_list_append_format(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id, ...) {
+ va_list arguments;
+ va_start(arguments, diag_id);
+
+ const char *format = pm_diagnostic_id_message(diag_id);
+ int result = vsnprintf(NULL, 0, format, arguments);
+ va_end(arguments);
+
+ if (result < 0) {
+ return;
+ }
+
+ pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) pm_arena_zalloc(arena, sizeof(pm_diagnostic_t), PRISM_ALIGNOF(pm_diagnostic_t));
+
+ size_t message_length = (size_t) (result + 1);
+ char *message = (char *) pm_arena_alloc(arena, message_length, 1);
+
+ va_start(arguments, diag_id);
+ vsnprintf(message, message_length, format, arguments);
+ va_end(arguments);
+
+ *diagnostic = (pm_diagnostic_t) {
+ .location = { .start = start, .length = length },
+ .diag_id = diag_id,
+ .message = message,
+ .level = pm_diagnostic_id_level(diag_id)
+ };
+
+ pm_list_append(list, (pm_list_node_t *) diagnostic);
+}
diff --git a/prism/templates/src/json.c.erb b/prism/templates/src/json.c.erb
new file mode 100644
index 0000000000..5c4ab8d92a
--- /dev/null
+++ b/prism/templates/src/json.c.erb
@@ -0,0 +1,130 @@
+#include "prism/json.h"
+
+// Ensure this translation unit is never empty, even when JSON is excluded.
+typedef int pm_json_unused_t;
+
+#ifndef PRISM_EXCLUDE_JSON
+
+#include "prism/internal/buffer.h"
+#include "prism/internal/constant_pool.h"
+#include "prism/internal/integer.h"
+#include "prism/internal/parser.h"
+
+#include <inttypes.h>
+
+static void
+pm_dump_json_constant(pm_buffer_t *buffer, const pm_parser_t *parser, pm_constant_id_t constant_id) {
+ const pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, constant_id);
+ pm_buffer_append_byte(buffer, '"');
+ pm_buffer_append_source(buffer, constant->start, constant->length, PM_BUFFER_ESCAPING_JSON);
+ pm_buffer_append_byte(buffer, '"');
+}
+
+static void
+pm_dump_json_location(pm_buffer_t *buffer, const pm_location_t *location) {
+ pm_buffer_append_format(buffer, "{\"start\":%" PRIu32 ",\"length\":%" PRIu32 "}", location->start, location->length);
+}
+
+/**
+ * Dump JSON to the given buffer.
+ */
+void
+pm_dump_json(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *node) {
+ switch (PM_NODE_TYPE(node)) {
+ <%- nodes.each do |node| -%>
+ case <%= node.type %>: {
+ pm_buffer_append_string(buffer, "{\"type\":\"<%= node.name %>\",\"location\":", <%= node.name.bytesize + 22 %>);
+
+ const pm_<%= node.human %>_t *cast = (const pm_<%= node.human %>_t *) node;
+ pm_dump_json_location(buffer, &cast->base.location);
+ <%- [*node.flags, *node.fields].each_with_index do |field, index| -%>
+
+ // Dump the <%= field.name %> field
+ pm_buffer_append_byte(buffer, ',');
+ <%- if field.is_a?(Prism::Template::Flags) -%>
+ pm_buffer_append_string(buffer, "\"flags\":", 8);
+ <%- else -%>
+ pm_buffer_append_string(buffer, "\"<%= field.name %>\":", <%= field.name.bytesize + 3 %>);
+ <%- end -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ pm_dump_json(buffer, parser, (const pm_node_t *) cast-><%= field.name %>);
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (cast-><%= field.name %> != NULL) {
+ pm_dump_json(buffer, parser, (const pm_node_t *) cast-><%= field.name %>);
+ } else {
+ pm_buffer_append_string(buffer, "null", 4);
+ }
+ <%- when Prism::Template::NodeListField -%>
+ const pm_node_list_t *<%= field.name %> = &cast-><%= field.name %>;
+ pm_buffer_append_byte(buffer, '[');
+
+ for (size_t index = 0; index < <%= field.name %>->size; index++) {
+ if (index != 0) pm_buffer_append_byte(buffer, ',');
+ pm_dump_json(buffer, parser, <%= field.name %>->nodes[index]);
+ }
+ pm_buffer_append_byte(buffer, ']');
+ <%- when Prism::Template::StringField -%>
+ const pm_string_t *<%= field.name %> = &cast-><%= field.name %>;
+ pm_buffer_append_byte(buffer, '"');
+ pm_buffer_append_source(buffer, pm_string_source(<%= field.name %>), pm_string_length(<%= field.name %>), PM_BUFFER_ESCAPING_JSON);
+ pm_buffer_append_byte(buffer, '"');
+ <%- when Prism::Template::ConstantField -%>
+ pm_dump_json_constant(buffer, parser, cast-><%= field.name %>);
+ <%- when Prism::Template::OptionalConstantField -%>
+ if (cast-><%= field.name %> != PM_CONSTANT_ID_UNSET) {
+ pm_dump_json_constant(buffer, parser, cast-><%= field.name %>);
+ } else {
+ pm_buffer_append_string(buffer, "null", 4);
+ }
+ <%- when Prism::Template::ConstantListField -%>
+ const pm_constant_id_list_t *<%= field.name %> = &cast-><%= field.name %>;
+ pm_buffer_append_byte(buffer, '[');
+
+ for (size_t index = 0; index < <%= field.name %>->size; index++) {
+ if (index != 0) pm_buffer_append_byte(buffer, ',');
+ pm_dump_json_constant(buffer, parser, <%= field.name %>->ids[index]);
+ }
+ pm_buffer_append_byte(buffer, ']');
+ <%- when Prism::Template::LocationField -%>
+ pm_dump_json_location(buffer, &cast-><%= field.name %>);
+ <%- when Prism::Template::OptionalLocationField -%>
+ if (cast-><%= field.name %>.length != 0) {
+ pm_dump_json_location(buffer, &cast-><%= field.name %>);
+ } else {
+ pm_buffer_append_string(buffer, "null", 4);
+ }
+ <%- when Prism::Template::UInt8Field -%>
+ pm_buffer_append_format(buffer, "%" PRIu8, cast-><%= field.name %>);
+ <%- when Prism::Template::UInt32Field -%>
+ pm_buffer_append_format(buffer, "%" PRIu32, cast-><%= field.name %>);
+ <%- when Prism::Template::Flags -%>
+ size_t flags = 0;
+ pm_buffer_append_byte(buffer, '[');
+ <%- node.flags.values.each_with_index do |value, index| -%>
+ if (PM_NODE_FLAG_P(cast, PM_<%= node.flags.human.upcase %>_<%= value.name %>)) {
+ if (flags != 0) pm_buffer_append_byte(buffer, ',');
+ pm_buffer_append_string(buffer, "\"<%= value.name %>\"", <%= value.name.bytesize + 2 %>);
+ flags++;
+ }
+ <%- end -%>
+ pm_buffer_append_byte(buffer, ']');
+ <%- when Prism::Template::IntegerField -%>
+ pm_integer_string(buffer, &cast-><%= field.name %>);
+ <%- when Prism::Template::DoubleField -%>
+ pm_buffer_append_format(buffer, "%f", cast-><%= field.name %>);
+ <%- else -%>
+ <%- raise %>
+ <%- end -%>
+ <%- end -%>
+
+ pm_buffer_append_byte(buffer, '}');
+ break;
+ }
+ <%- end -%>
+ case PM_SCOPE_NODE:
+ break;
+ }
+}
+
+#endif
diff --git a/prism/templates/src/node.c.erb b/prism/templates/src/node.c.erb
new file mode 100644
index 0000000000..f51aff6e53
--- /dev/null
+++ b/prism/templates/src/node.c.erb
@@ -0,0 +1,166 @@
+#line <%= __LINE__ + 1 %> "prism/templates/src/<%= File.basename(__FILE__) %>"
+#include "prism/internal/node.h"
+
+#include "prism/internal/arena.h"
+
+#include <stdlib.h>
+
+/**
+ * Attempts to grow the node list to the next size. If there is already
+ * capacity in the list, this function does nothing. Otherwise it allocates a
+ * new array from the arena (abandon-and-copy strategy) and copies the existing
+ * data into it.
+ */
+static void
+pm_node_list_grow(pm_arena_t *arena, pm_node_list_t *list, size_t size) {
+ size_t requested_size = list->size + size;
+
+ // Guard against overflow on the addition.
+ if (requested_size < list->size) abort();
+
+ // If the requested size is within the existing capacity, return.
+ if (requested_size <= list->capacity) return;
+
+ // Otherwise, compute the next capacity by doubling.
+ size_t next_capacity = list->capacity == 0 ? 4 : list->capacity * 2;
+
+ // Guard against overflow on the doubling.
+ while (requested_size > next_capacity) {
+ if (next_capacity == 0) abort();
+ next_capacity *= 2;
+ }
+
+ // Allocate a new array from the arena (old array is abandoned).
+ pm_node_t **nodes = (pm_node_t **) pm_arena_alloc(arena, sizeof(pm_node_t *) * next_capacity, PRISM_ALIGNOF(pm_node_t *));
+
+ // Copy old data into the new array.
+ if (list->size > 0) {
+ memcpy(nodes, list->nodes, list->size * sizeof(pm_node_t *));
+ }
+
+ list->nodes = nodes;
+ list->capacity = next_capacity;
+}
+
+/**
+ * Slow path for pm_node_list_append: grow the list and append the node.
+ * Do not call directly - use pm_node_list_append instead.
+ */
+void
+pm_node_list_append_slow(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) {
+ pm_node_list_grow(arena, list, 1);
+ list->nodes[list->size++] = node;
+}
+
+/**
+ * Prepend a new node onto the beginning of the node list.
+ */
+void
+pm_node_list_prepend(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) {
+ pm_node_list_grow(arena, list, 1);
+ memmove(list->nodes + 1, list->nodes, list->size * sizeof(pm_node_t *));
+ list->nodes[0] = node;
+ list->size++;
+}
+
+/**
+ * Concatenate the given node list onto the end of the other node list.
+ */
+void
+pm_node_list_concat(pm_arena_t *arena, pm_node_list_t *list, pm_node_list_t *other) {
+ if (other->size > 0) {
+ pm_node_list_grow(arena, list, other->size);
+ memcpy(list->nodes + list->size, other->nodes, other->size * sizeof(pm_node_t *));
+ list->size += other->size;
+ }
+}
+
+/**
+ * Returns a string representation of the given node type.
+ */
+const char *
+pm_node_type(pm_node_type_t node_type)
+{
+ switch (node_type) {
+<%- nodes.each do |node| -%>
+ case <%= node.type %>:
+ return "<%= node.type %>";
+<%- end -%>
+ }
+ return "";
+}
+
+/**
+ * Visit each of the nodes in this subtree using the given visitor callback. The
+ * callback function will be called for each node in the subtree. If it returns
+ * false, then that node's children will not be visited. If it returns true,
+ * then the children will be visited. The data parameter is treated as an opaque
+ * pointer and is passed to the visitor callback for consumers to use as they
+ * see fit.
+ */
+void
+pm_visit_node(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data) {
+ if (visitor(node, data)) pm_visit_child_nodes(node, visitor, data);
+}
+
+/**
+ * Visit the children of the given node with the given callback. This is the
+ * default behavior for walking the tree that is called from pm_visit_node if
+ * the callback returns true.
+ */
+void
+pm_visit_child_nodes(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data) {
+ switch (PM_NODE_TYPE(node)) {
+ <%- nodes.each do |node| -%>
+ <%- if (fields = node.fields.select { |field| field.is_a?(Prism::Template::NodeField) || field.is_a?(Prism::Template::OptionalNodeField) || field.is_a?(Prism::Template::NodeListField) }).any? -%>
+ case <%= node.type %>: {
+ const pm_<%= node.human %>_t *cast = (const pm_<%= node.human %>_t *) node;
+ <%- fields.each do |field| -%>
+
+ // Visit the <%= field.name %> field
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ pm_visit_node((const pm_node_t *) cast-><%= field.name %>, visitor, data);
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (cast-><%= field.name %> != NULL) {
+ pm_visit_node((const pm_node_t *) cast-><%= field.name %>, visitor, data);
+ }
+ <%- when Prism::Template::NodeListField -%>
+ const pm_node_list_t *<%= field.name %> = &cast-><%= field.name %>;
+ for (size_t index = 0; index < <%= field.name %>->size; index++) {
+ pm_visit_node(<%= field.name %>->nodes[index], visitor, data);
+ }
+ <%- end -%>
+ <%- end -%>
+
+ break;
+ }
+ <%- else -%>
+ case <%= node.type %>:
+ break;
+ <%- end -%>
+ <%- end -%>
+ case PM_SCOPE_NODE:
+ break;
+ }
+}
+<%- nodes.each do |node| -%>
+
+<%- params = node.fields.map(&:c_param) -%>
+/**
+ * Allocate and initialize a new <%= node.name %> node.
+ */
+pm_<%= node.human %>_t *
+pm_<%= node.human %>_new(pm_arena_t *arena, uint32_t node_id, pm_node_flags_t flags, pm_location_t location<%= params.empty? ? "" : ", #{params.join(", ")}" %>) {
+ pm_<%= node.human %>_t *node = (pm_<%= node.human %>_t *) pm_arena_alloc(arena, sizeof(pm_<%= node.human %>_t), PRISM_ALIGNOF(pm_<%= node.human %>_t));
+
+ *node = (pm_<%= node.human %>_t) {
+ .base = { .type = <%= node.type %>, .flags = flags, .node_id = node_id, .location = location }<%= node.fields.empty? ? "" : "," %>
+<%- node.fields.each_with_index do |field, index| -%>
+ .<%= field.name %> = <%= field.name %><%= index < node.fields.size - 1 ? "," : "" %>
+<%- end -%>
+ };
+
+ return node;
+}
+<%- end -%>
diff --git a/prism/templates/src/prettyprint.c.erb b/prism/templates/src/prettyprint.c.erb
new file mode 100644
index 0000000000..f12531d934
--- /dev/null
+++ b/prism/templates/src/prettyprint.c.erb
@@ -0,0 +1,177 @@
+<%# encoding: ASCII -%>
+#include "prism/prettyprint.h"
+
+/* We optionally support pretty printing nodes. For systems that don't want or
+ * need this functionality, it can be turned off with the
+ * PRISM_EXCLUDE_PRETTYPRINT define. */
+#ifdef PRISM_EXCLUDE_PRETTYPRINT
+
+/* Ensure this translation unit is never empty, even when prettyprint is
+ * excluded. */
+typedef int pm_prettyprint_unused_t;
+
+#else
+
+#include "prism/compiler/inline.h"
+#include "prism/internal/buffer.h"
+#include "prism/internal/constant_pool.h"
+#include "prism/internal/integer.h"
+#include "prism/internal/parser.h"
+#include "prism/line_offset_list.h"
+
+#include <inttypes.h>
+
+static PRISM_INLINE void
+prettyprint_location(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_location_t *location) {
+ pm_line_column_t start = pm_line_offset_list_line_column(&parser->line_offsets, location->start, parser->start_line);
+ pm_line_column_t end = pm_line_offset_list_line_column(&parser->line_offsets, location->start + location->length, parser->start_line);
+ pm_buffer_append_format(output_buffer, "(%" PRIi32 ",%" PRIu32 ")-(%" PRIi32 ",%" PRIu32 ")", start.line, start.column, end.line, end.column);
+}
+
+static PRISM_INLINE void
+prettyprint_constant(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_constant_id_t constant_id) {
+ pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, constant_id);
+ pm_buffer_append_format(output_buffer, ":%.*s", (int) constant->length, constant->start);
+}
+
+static void
+prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node, pm_buffer_t *prefix_buffer) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_SCOPE_NODE:
+ // We do not need to print a ScopeNode as it's not part of the AST.
+ return;
+ <%- nodes.each do |node| -%>
+ case <%= node.type %>: {
+ <%- if !node.flags.nil? || node.fields.any? -%>
+ pm_<%= node.human %>_t *cast = (pm_<%= node.human %>_t *) node;
+ <%- end -%>
+ pm_buffer_append_string(output_buffer, "@ <%= node.name %> (location: ", <%= node.name.length + 14 %>);
+ prettyprint_location(output_buffer, parser, &node->location);
+ pm_buffer_append_string(output_buffer, ")\n", 2);
+ <%- (fields = [*node.flags, *node.fields]).each_with_index do |field, index| -%>
+ <%- preadd = index == fields.length - 1 ? " " : "| " -%>
+
+ // <%= field.name %>
+ {
+ pm_buffer_concat(output_buffer, prefix_buffer);
+ pm_buffer_append_string(output_buffer, "+-- <%= field.name %>:", <%= 4 + field.name.length + 1 %>);
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ pm_buffer_append_byte(output_buffer, '\n');
+
+ size_t prefix_length = prefix_buffer->length;
+ pm_buffer_append_string(prefix_buffer, "<%= preadd %>", 4);
+ pm_buffer_concat(output_buffer, prefix_buffer);
+ prettyprint_node(output_buffer, parser, (pm_node_t *) cast-><%= field.name %>, prefix_buffer);
+ prefix_buffer->length = prefix_length;
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (cast-><%= field.name %> == NULL) {
+ pm_buffer_append_string(output_buffer, " nil\n", 5);
+ } else {
+ pm_buffer_append_byte(output_buffer, '\n');
+
+ size_t prefix_length = prefix_buffer->length;
+ pm_buffer_append_string(prefix_buffer, "<%= preadd %>", 4);
+ pm_buffer_concat(output_buffer, prefix_buffer);
+ prettyprint_node(output_buffer, parser, (pm_node_t *) cast-><%= field.name %>, prefix_buffer);
+ prefix_buffer->length = prefix_length;
+ }
+ <%- when Prism::Template::StringField -%>
+ pm_buffer_append_string(output_buffer, " \"", 2);
+ pm_buffer_append_source(output_buffer, pm_string_source(&cast-><%= field.name %>), pm_string_length(&cast-><%= field.name %>), PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_string(output_buffer, "\"\n", 2);
+ <%- when Prism::Template::NodeListField -%>
+ pm_buffer_append_format(output_buffer, " (length: %lu)\n", (unsigned long) (cast-><%= field.name %>.size));
+
+ size_t last_index = cast-><%= field.name %>.size;
+ for (uint32_t index = 0; index < last_index; index++) {
+ size_t prefix_length = prefix_buffer->length;
+ pm_buffer_append_string(prefix_buffer, "<%= preadd %>", 4);
+ pm_buffer_concat(output_buffer, prefix_buffer);
+ pm_buffer_append_string(output_buffer, "+-- ", 4);
+ pm_buffer_append_string(prefix_buffer, (index == last_index - 1) ? " " : "| ", 4);
+ prettyprint_node(output_buffer, parser, (pm_node_t *) cast-><%= field.name %>.nodes[index], prefix_buffer);
+ prefix_buffer->length = prefix_length;
+ }
+ <%- when Prism::Template::ConstantField -%>
+ pm_buffer_append_byte(output_buffer, ' ');
+ prettyprint_constant(output_buffer, parser, cast-><%= field.name %>);
+ pm_buffer_append_byte(output_buffer, '\n');
+ <%- when Prism::Template::OptionalConstantField -%>
+ if (cast-><%= field.name %> == 0) {
+ pm_buffer_append_string(output_buffer, " nil\n", 5);
+ } else {
+ pm_buffer_append_byte(output_buffer, ' ');
+ prettyprint_constant(output_buffer, parser, cast-><%= field.name %>);
+ pm_buffer_append_byte(output_buffer, '\n');
+ }
+ <%- when Prism::Template::ConstantListField -%>
+ pm_buffer_append_string(output_buffer, " [", 2);
+ for (uint32_t index = 0; index < cast-><%= field.name %>.size; index++) {
+ if (index != 0) pm_buffer_append_string(output_buffer, ", ", 2);
+ prettyprint_constant(output_buffer, parser, cast-><%= field.name %>.ids[index]);
+ }
+ pm_buffer_append_string(output_buffer, "]\n", 2);
+ <%- when Prism::Template::LocationField -%>
+ pm_location_t *location = &cast-><%= field.name %>;
+ pm_buffer_append_byte(output_buffer, ' ');
+ prettyprint_location(output_buffer, parser, location);
+ pm_buffer_append_string(output_buffer, " = \"", 4);
+ pm_buffer_append_source(output_buffer, parser->start + location->start, (size_t) location->length, PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_string(output_buffer, "\"\n", 2);
+ <%- when Prism::Template::OptionalLocationField -%>
+ pm_location_t *location = &cast-><%= field.name %>;
+ if (location->length == 0) {
+ pm_buffer_append_string(output_buffer, " nil\n", 5);
+ } else {
+ pm_buffer_append_byte(output_buffer, ' ');
+ prettyprint_location(output_buffer, parser, location);
+ pm_buffer_append_string(output_buffer, " = \"", 4);
+ pm_buffer_append_source(output_buffer, parser->start + location->start, (size_t) location->length, PM_BUFFER_ESCAPING_RUBY);
+ pm_buffer_append_string(output_buffer, "\"\n", 2);
+ }
+ <%- when Prism::Template::UInt8Field -%>
+ pm_buffer_append_format(output_buffer, " %" PRIu8 "\n", cast-><%= field.name %>);
+ <%- when Prism::Template::UInt32Field -%>
+ pm_buffer_append_format(output_buffer, " %" PRIu32 "\n", cast-><%= field.name %>);
+ <%- when Prism::Template::Flags -%>
+ bool found = false;
+ <%- field.values.each do |value| -%>
+ if (cast->base.flags & PM_<%= field.human.upcase %>_<%= value.name %>) {
+ if (found) pm_buffer_append_byte(output_buffer, ',');
+ pm_buffer_append_string(output_buffer, " <%= value.name.downcase %>", <%= value.name.bytesize + 1 %>);
+ found = true;
+ }
+ <%- end -%>
+ if (!found) pm_buffer_append_string(output_buffer, " nil", 4);
+ pm_buffer_append_byte(output_buffer, '\n');
+ <%- when Prism::Template::IntegerField -%>
+ const pm_integer_t *integer = &cast-><%= field.name %>;
+ pm_buffer_append_byte(output_buffer, ' ');
+ pm_integer_string(output_buffer, integer);
+ pm_buffer_append_byte(output_buffer, '\n');
+ <%- when Prism::Template::DoubleField -%>
+ pm_buffer_append_format(output_buffer, " %f\n", cast-><%= field.name %>);
+ <%- else -%>
+ <%- raise -%>
+ <%- end -%>
+ }
+ <%- end -%>
+
+ break;
+ }
+ <%- end -%>
+ }
+}
+
+/**
+ * Pretty-prints the AST represented by the given node to the given buffer.
+ */
+void
+pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node) {
+ pm_buffer_t prefix_buffer = { 0 };
+ prettyprint_node(output_buffer, parser, node, &prefix_buffer);
+ pm_buffer_cleanup(&prefix_buffer);
+}
+
+#endif
diff --git a/prism/templates/src/serialize.c.erb b/prism/templates/src/serialize.c.erb
new file mode 100644
index 0000000000..3d9811e5db
--- /dev/null
+++ b/prism/templates/src/serialize.c.erb
@@ -0,0 +1,404 @@
+#include "prism/excludes.h"
+
+/* We optionally support serializing to a binary string. For systems that do not
+ * want or need this functionality, it can be turned off with the
+ * PRISM_EXCLUDE_SERIALIZATION define. */
+#ifdef PRISM_EXCLUDE_SERIALIZATION
+
+/* Ensure this translation unit is never empty, even when serialization is
+ * excluded. */
+typedef int pm_serialize_unused_t;
+
+#else
+
+#include "prism/compiler/inline.h"
+
+#include "prism/internal/buffer.h"
+#include "prism/internal/comments.h"
+#include "prism/internal/diagnostic.h"
+#include "prism/internal/encoding.h"
+#include "prism/internal/list.h"
+#include "prism/internal/magic_comments.h"
+#include "prism/internal/options.h"
+#include "prism/internal/parser.h"
+
+#include "prism.h"
+#include "prism/ast.h"
+#include "prism/line_offset_list.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+static PRISM_INLINE uint32_t
+pm_ptrdifft_to_u32(ptrdiff_t value) {
+ assert(value >= 0 && ((unsigned long) value) < UINT32_MAX);
+ return (uint32_t) value;
+}
+
+static PRISM_INLINE uint32_t
+pm_sizet_to_u32(size_t value) {
+ assert(value < UINT32_MAX);
+ return (uint32_t) value;
+}
+
+static void
+pm_serialize_location(const pm_location_t *location, pm_buffer_t *buffer) {
+ pm_buffer_append_varuint(buffer, location->start);
+ pm_buffer_append_varuint(buffer, location->length);
+}
+
+static void
+pm_serialize_string(const pm_string_t *string, pm_buffer_t *buffer) {
+ uint32_t length = pm_sizet_to_u32(pm_string_length(string));
+ pm_buffer_append_varuint(buffer, length);
+ pm_buffer_append_bytes(buffer, pm_string_source(string), length);
+}
+
+static void
+pm_serialize_integer(const pm_integer_t *integer, pm_buffer_t *buffer) {
+ pm_buffer_append_byte(buffer, integer->negative ? 1 : 0);
+ if (integer->values == NULL) {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(1));
+ pm_buffer_append_varuint(buffer, integer->value);
+ } else {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(integer->length));
+ for (size_t i = 0; i < integer->length; i++) {
+ pm_buffer_append_varuint(buffer, integer->values[i]);
+ }
+ }
+}
+
+static void
+pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
+ pm_buffer_append_byte(buffer, (uint8_t) PM_NODE_TYPE(node));
+
+ <%- if Prism::Template::INCLUDE_NODE_ID -%>
+ pm_buffer_append_varuint(buffer, node->node_id);
+ <%- end -%>
+ pm_serialize_location(&node->location, buffer);
+
+ switch (PM_NODE_TYPE(node)) {
+ // We do not need to serialize a ScopeNode ever as
+ // it is not part of the AST
+ case PM_SCOPE_NODE:
+ return;
+ <%- nodes.each do |node| -%>
+ case <%= node.type %>: {
+ <%- if node.needs_serialized_length? -%>
+ // serialize length
+ // encoding of location u32s make us need to save this offset.
+ size_t length_offset = buffer->length;
+ pm_buffer_append_string(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
+ <%- end -%>
+ <%- unless Prism::Template::SERIALIZE_ONLY_SEMANTICS_FIELDS && !node.flags -%>
+ pm_buffer_append_varuint(buffer, (uint32_t) node->flags);
+ <%- end -%>
+ <%- node.fields.each do |field| -%>
+ <%- case field -%>
+ <%- when Prism::Template::NodeField -%>
+ pm_serialize_node(parser, (pm_node_t *)((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ <%- when Prism::Template::OptionalNodeField -%>
+ if (((pm_<%= node.human %>_t *)node)-><%= field.name %> == NULL) {
+ pm_buffer_append_byte(buffer, 0);
+ } else {
+ pm_serialize_node(parser, (pm_node_t *)((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ }
+ <%- when Prism::Template::StringField -%>
+ pm_serialize_string(&((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ <%- when Prism::Template::NodeListField -%>
+ uint32_t <%= field.name %>_size = pm_sizet_to_u32(((pm_<%= node.human %>_t *)node)-><%= field.name %>.size);
+ pm_buffer_append_varuint(buffer, <%= field.name %>_size);
+ for (uint32_t index = 0; index < <%= field.name %>_size; index++) {
+ pm_serialize_node(parser, (pm_node_t *) ((pm_<%= node.human %>_t *)node)-><%= field.name %>.nodes[index], buffer);
+ }
+ <%- when Prism::Template::ConstantField, Prism::Template::OptionalConstantField -%>
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_<%= node.human %>_t *)node)-><%= field.name %>));
+ <%- when Prism::Template::ConstantListField -%>
+ uint32_t <%= field.name %>_size = pm_sizet_to_u32(((pm_<%= node.human %>_t *)node)-><%= field.name %>.size);
+ pm_buffer_append_varuint(buffer, <%= field.name %>_size);
+ for (uint32_t index = 0; index < <%= field.name %>_size; index++) {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(((pm_<%= node.human %>_t *)node)-><%= field.name %>.ids[index]));
+ }
+ <%- when Prism::Template::LocationField -%>
+ <%- if field.should_be_serialized? -%>
+ pm_serialize_location(&((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ <%- end -%>
+ <%- when Prism::Template::OptionalLocationField -%>
+ <%- if field.should_be_serialized? -%>
+ if (((pm_<%= node.human %>_t *)node)-><%= field.name %>.length == 0) {
+ pm_buffer_append_byte(buffer, 0);
+ } else {
+ pm_buffer_append_byte(buffer, 1);
+ pm_serialize_location(&((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ }
+ <%- end -%>
+ <%- when Prism::Template::UInt8Field -%>
+ pm_buffer_append_byte(buffer, ((pm_<%= node.human %>_t *)node)-><%= field.name %>);
+ <%- when Prism::Template::UInt32Field -%>
+ pm_buffer_append_varuint(buffer, ((pm_<%= node.human %>_t *)node)-><%= field.name %>);
+ <%- when Prism::Template::IntegerField -%>
+ pm_serialize_integer(&((pm_<%= node.human %>_t *)node)-><%= field.name %>, buffer);
+ <%- when Prism::Template::DoubleField -%>
+ pm_buffer_append_double(buffer, ((pm_<%= node.human %>_t *)node)-><%= field.name %>);
+ <%- else -%>
+ <%- raise -%>
+ <%- end -%>
+ <%- end -%>
+ <%- if node.needs_serialized_length? -%>
+ // serialize length
+ uint32_t length = pm_sizet_to_u32(buffer->length - length_offset);
+ memcpy(buffer->value + length_offset, &length, sizeof(uint32_t));
+ <%- end -%>
+ break;
+ }
+ <%- end -%>
+ }
+}
+
+static void
+pm_serialize_line_offset_list(pm_line_offset_list_t *list, pm_buffer_t *buffer) {
+ uint32_t size = pm_sizet_to_u32(list->size);
+ pm_buffer_append_varuint(buffer, size);
+
+ for (uint32_t i = 0; i < size; i++) {
+ uint32_t offset = pm_sizet_to_u32(list->offsets[i]);
+ pm_buffer_append_varuint(buffer, offset);
+ }
+}
+
+static void
+pm_serialize_comment(pm_comment_t *comment, pm_buffer_t *buffer) {
+ // serialize type
+ pm_buffer_append_byte(buffer, (uint8_t) comment->type);
+
+ // serialize location
+ pm_serialize_location(&comment->location, buffer);
+}
+
+/**
+ * Serialize the given list of comments to the given buffer.
+ */
+void
+pm_serialize_comment_list(pm_list_t *list, pm_buffer_t *buffer) {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list)));
+
+ pm_comment_t *comment;
+ for (comment = (pm_comment_t *) list->head; comment != NULL; comment = (pm_comment_t *) comment->node.next) {
+ pm_serialize_comment(comment, buffer);
+ }
+}
+
+static void
+pm_serialize_magic_comment(pm_magic_comment_t *magic_comment, pm_buffer_t *buffer) {
+ // serialize key location
+ pm_buffer_append_varuint(buffer, magic_comment->key.start);
+ pm_buffer_append_varuint(buffer, magic_comment->key.length);
+
+ // serialize value location
+ pm_buffer_append_varuint(buffer, magic_comment->value.start);
+ pm_buffer_append_varuint(buffer, magic_comment->value.length);
+}
+
+static void
+pm_serialize_magic_comment_list(pm_list_t *list, pm_buffer_t *buffer) {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list)));
+
+ pm_magic_comment_t *magic_comment;
+ for (magic_comment = (pm_magic_comment_t *) list->head; magic_comment != NULL; magic_comment = (pm_magic_comment_t *) magic_comment->node.next) {
+ pm_serialize_magic_comment(magic_comment, buffer);
+ }
+}
+
+static void
+pm_serialize_data_loc(const pm_parser_t *parser, pm_buffer_t *buffer) {
+ if (parser->data_loc.length == 0) {
+ pm_buffer_append_byte(buffer, 0);
+ } else {
+ pm_buffer_append_byte(buffer, 1);
+ pm_serialize_location(&parser->data_loc, buffer);
+ }
+}
+
+static void
+pm_serialize_diagnostic(pm_diagnostic_t *diagnostic, pm_buffer_t *buffer) {
+ // serialize the type
+ pm_buffer_append_varuint(buffer, (uint32_t) diagnostic->diag_id);
+
+ // serialize message
+ size_t message_length = strlen(diagnostic->message);
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(message_length));
+ pm_buffer_append_string(buffer, diagnostic->message, message_length);
+
+ // serialize location
+ pm_serialize_location(&diagnostic->location, buffer);
+
+ pm_buffer_append_byte(buffer, diagnostic->level);
+}
+
+static void
+pm_serialize_diagnostic_list(pm_list_t *list, pm_buffer_t *buffer) {
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(pm_list_size(list)));
+
+ pm_diagnostic_t *diagnostic;
+ for (diagnostic = (pm_diagnostic_t *) list->head; diagnostic != NULL; diagnostic = (pm_diagnostic_t *) diagnostic->node.next) {
+ pm_serialize_diagnostic(diagnostic, buffer);
+ }
+}
+
+/**
+ * Serialize the name of the encoding to the buffer.
+ */
+void
+pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer) {
+ size_t encoding_length = strlen(encoding->name);
+ pm_buffer_append_varuint(buffer, pm_sizet_to_u32(encoding_length));
+ pm_buffer_append_string(buffer, encoding->name, encoding_length);
+}
+
+static void
+pm_serialize_metadata(pm_parser_t *parser, pm_buffer_t *buffer) {
+ pm_serialize_encoding(parser->encoding, buffer);
+ pm_buffer_append_varsint(buffer, parser->start_line);
+ pm_serialize_line_offset_list(&parser->line_offsets, buffer);
+<%- unless Prism::Template::SERIALIZE_ONLY_SEMANTICS_FIELDS -%>
+ pm_serialize_comment_list(&parser->comment_list, buffer);
+<%- end -%>
+ pm_serialize_magic_comment_list(&parser->magic_comment_list, buffer);
+ pm_serialize_data_loc(parser, buffer);
+ pm_serialize_diagnostic_list(&parser->error_list, buffer);
+ pm_serialize_diagnostic_list(&parser->warning_list, buffer);
+ pm_buffer_append_byte(buffer, (uint8_t) parser->continuable);
+}
+
+#line <%= __LINE__ + 1 %> "prism/templates/src/<%= File.basename(__FILE__) %>"
+/**
+ * Serialize the metadata, nodes, and constant pool.
+ */
+void
+pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
+ pm_serialize_metadata(parser, buffer);
+
+ // Here we're going to leave space for the offset of the constant pool in
+ // the buffer.
+ size_t offset = buffer->length;
+ pm_buffer_append_zeroes(buffer, 4);
+
+ // Next, encode the length of the constant pool.
+ pm_buffer_append_varuint(buffer, parser->constant_pool.size);
+
+ // Now we're going to serialize the content of the node.
+ pm_serialize_node(parser, node, buffer);
+
+ // Now we're going to serialize the offset of the constant pool back where
+ // we left space for it.
+ uint32_t length = pm_sizet_to_u32(buffer->length);
+ memcpy(buffer->value + offset, &length, sizeof(uint32_t));
+
+ // Now we're going to serialize the constant pool.
+ offset = buffer->length;
+ pm_buffer_append_zeroes(buffer, parser->constant_pool.size * 8);
+
+ for (uint32_t index = 0; index < parser->constant_pool.capacity; index++) {
+ pm_constant_pool_bucket_t *bucket = &parser->constant_pool.buckets[index];
+
+ // If we find a constant at this index, serialize it at the correct
+ // index in the buffer.
+ if (bucket->id != 0) {
+ pm_constant_t *constant = &parser->constant_pool.constants[bucket->id - 1];
+ size_t buffer_offset = offset + ((((size_t)bucket->id) - 1) * 8);
+
+ // Write the constant contents into the buffer after the constant
+ // pool. In place of the source offset, we store a buffer offset.
+ uint32_t content_offset = pm_sizet_to_u32(buffer->length);
+ memcpy(buffer->value + buffer_offset, &content_offset, 4);
+ pm_buffer_append_bytes(buffer, constant->start, constant->length);
+
+ uint32_t constant_length = pm_sizet_to_u32(constant->length);
+ memcpy(buffer->value + buffer_offset + 4, &constant_length, 4);
+ }
+ }
+}
+
+static void
+serialize_token(pm_parser_t *parser, pm_token_t *token, void *data) {
+ pm_buffer_t *buffer = (pm_buffer_t *) data;
+
+ pm_buffer_append_varuint(buffer, token->type);
+ pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(token->start - parser->start));
+ pm_buffer_append_varuint(buffer, pm_ptrdifft_to_u32(token->end - token->start));
+ pm_buffer_append_varuint(buffer, parser->lex_state);
+}
+
+/**
+ * Lex the given source and serialize to the given buffer.
+ */
+void
+pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) {
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_arena_t arena = { 0 };
+ pm_parser_t parser;
+ pm_parser_init(&arena, &parser, source, size, &options);
+
+ pm_parser_lex_callback_set(&parser, serialize_token, buffer);
+ pm_parse(&parser);
+
+ // Append 0 to mark end of tokens.
+ pm_buffer_append_byte(buffer, 0);
+
+ pm_serialize_metadata(&parser, buffer);
+
+ pm_parser_cleanup(&parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+}
+
+/**
+ * Parse and serialize both the AST and the tokens represented by the given
+ * source to the given buffer.
+ */
+void
+pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) {
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_arena_t arena = { 0 };
+ pm_parser_t parser;
+ pm_parser_init(&arena, &parser, source, size, &options);
+
+ pm_parser_lex_callback_set(&parser, serialize_token, buffer);
+ pm_node_t *node = pm_parse(&parser);
+
+ pm_buffer_append_byte(buffer, 0);
+ pm_serialize(&parser, node, buffer);
+
+ pm_parser_cleanup(&parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+}
+
+/**
+ * Parse the source and return true if it parses without errors or warnings.
+ */
+bool
+pm_serialize_parse_success_p(const uint8_t *source, size_t size, const char *data) {
+ pm_options_t options = { 0 };
+ pm_options_read(&options, data);
+
+ pm_arena_t arena = { 0 };
+ pm_parser_t parser;
+ pm_parser_init(&arena, &parser, source, size, &options);
+
+ pm_parse(&parser);
+
+ bool result = parser.error_list.size == 0;
+ pm_parser_cleanup(&parser);
+ pm_arena_cleanup(&arena);
+ pm_options_cleanup(&options);
+
+ return result;
+}
+
+#endif
diff --git a/prism/templates/src/tokens.c.erb b/prism/templates/src/tokens.c.erb
new file mode 100644
index 0000000000..1e82954738
--- /dev/null
+++ b/prism/templates/src/tokens.c.erb
@@ -0,0 +1,367 @@
+#include "prism/ast.h"
+
+#include <assert.h>
+
+/**
+ * Returns a string representation of the given token type.
+ */
+const char *
+pm_token_type(pm_token_type_t token_type) {
+ switch (token_type) {
+<%- tokens.each do |token| -%>
+ case PM_TOKEN_<%= token.name %>:
+ return "<%= token.name %>";
+<%- end -%>
+ case PM_TOKEN_MAXIMUM:
+ assert(false && "unreachable");
+ return "";
+ }
+
+ // Provide a default, because some compilers can't determine that the above
+ // switch is exhaustive.
+ assert(false && "unreachable");
+ return "";
+}
+
+/**
+ * Returns the human name of the given token type.
+ */
+const char *
+pm_token_str(pm_token_type_t token_type) {
+ switch (token_type) {
+ case PM_TOKEN_EOF:
+ return "end-of-input";
+ case PM_TOKEN_AMPERSAND:
+ return "'&'";
+ case PM_TOKEN_AMPERSAND_AMPERSAND:
+ return "'&&'";
+ case PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL:
+ return "'&&='";
+ case PM_TOKEN_AMPERSAND_DOT:
+ return "'&.'";
+ case PM_TOKEN_AMPERSAND_EQUAL:
+ return "'&='";
+ case PM_TOKEN_BACKTICK:
+ return "'`'";
+ case PM_TOKEN_BACK_REFERENCE:
+ return "back reference";
+ case PM_TOKEN_BANG:
+ return "'!'";
+ case PM_TOKEN_BANG_EQUAL:
+ return "'!='";
+ case PM_TOKEN_BANG_TILDE:
+ return "'!~'";
+ case PM_TOKEN_BRACE_LEFT:
+ return "'{'";
+ case PM_TOKEN_BRACE_RIGHT:
+ return "'}'";
+ case PM_TOKEN_BRACKET_LEFT:
+ return "'['";
+ case PM_TOKEN_BRACKET_LEFT_ARRAY:
+ return "'['";
+ case PM_TOKEN_BRACKET_LEFT_RIGHT:
+ return "'[]'";
+ case PM_TOKEN_BRACKET_LEFT_RIGHT_EQUAL:
+ return "'[]='";
+ case PM_TOKEN_BRACKET_RIGHT:
+ return "']'";
+ case PM_TOKEN_CARET:
+ return "'^'";
+ case PM_TOKEN_CARET_EQUAL:
+ return "'^='";
+ case PM_TOKEN_CHARACTER_LITERAL:
+ return "character literal";
+ case PM_TOKEN_CLASS_VARIABLE:
+ return "class variable";
+ case PM_TOKEN_COLON:
+ return "':'";
+ case PM_TOKEN_COLON_COLON:
+ return "'::'";
+ case PM_TOKEN_COMMA:
+ return "','";
+ case PM_TOKEN_COMMENT:
+ return "comment";
+ case PM_TOKEN_CONSTANT:
+ return "constant";
+ case PM_TOKEN_DOT:
+ return "'.'";
+ case PM_TOKEN_DOT_DOT:
+ return "..";
+ case PM_TOKEN_DOT_DOT_DOT:
+ return "...";
+ case PM_TOKEN_EMBDOC_BEGIN:
+ return "'=begin'";
+ case PM_TOKEN_EMBDOC_END:
+ return "'=end'";
+ case PM_TOKEN_EMBDOC_LINE:
+ return "embedded documentation line";
+ case PM_TOKEN_EMBEXPR_BEGIN:
+ return "'#{'";
+ case PM_TOKEN_EMBEXPR_END:
+ return "'}'";
+ case PM_TOKEN_EMBVAR:
+ return "'#'";
+ case PM_TOKEN_EQUAL:
+ return "'='";
+ case PM_TOKEN_EQUAL_EQUAL:
+ return "'=='";
+ case PM_TOKEN_EQUAL_EQUAL_EQUAL:
+ return "'==='";
+ case PM_TOKEN_EQUAL_GREATER:
+ return "'=>'";
+ case PM_TOKEN_EQUAL_TILDE:
+ return "'=~'";
+ case PM_TOKEN_FLOAT:
+ return "float";
+ case PM_TOKEN_FLOAT_IMAGINARY:
+ return "imaginary";
+ case PM_TOKEN_FLOAT_RATIONAL:
+ return "rational";
+ case PM_TOKEN_FLOAT_RATIONAL_IMAGINARY:
+ return "imaginary";
+ case PM_TOKEN_GLOBAL_VARIABLE:
+ return "global variable";
+ case PM_TOKEN_GREATER:
+ return "'>'";
+ case PM_TOKEN_GREATER_EQUAL:
+ return "'>='";
+ case PM_TOKEN_GREATER_GREATER:
+ return ">>";
+ case PM_TOKEN_GREATER_GREATER_EQUAL:
+ return ">>=";
+ case PM_TOKEN_HEREDOC_END:
+ return "heredoc ending";
+ case PM_TOKEN_HEREDOC_START:
+ return "heredoc beginning";
+ case PM_TOKEN_IDENTIFIER:
+ return "local variable or method";
+ case PM_TOKEN_IGNORED_NEWLINE:
+ return "ignored newline";
+ case PM_TOKEN_INSTANCE_VARIABLE:
+ return "instance variable";
+ case PM_TOKEN_INTEGER:
+ return "integer";
+ case PM_TOKEN_INTEGER_IMAGINARY:
+ return "imaginary";
+ case PM_TOKEN_INTEGER_RATIONAL:
+ return "rational";
+ case PM_TOKEN_INTEGER_RATIONAL_IMAGINARY:
+ return "imaginary";
+ case PM_TOKEN_KEYWORD_ALIAS:
+ return "'alias'";
+ case PM_TOKEN_KEYWORD_AND:
+ return "'and'";
+ case PM_TOKEN_KEYWORD_BEGIN:
+ return "'begin'";
+ case PM_TOKEN_KEYWORD_BEGIN_UPCASE:
+ return "'BEGIN'";
+ case PM_TOKEN_KEYWORD_BREAK:
+ return "'break'";
+ case PM_TOKEN_KEYWORD_CASE:
+ return "'case'";
+ case PM_TOKEN_KEYWORD_CLASS:
+ return "'class'";
+ case PM_TOKEN_KEYWORD_DEF:
+ return "'def'";
+ case PM_TOKEN_KEYWORD_DEFINED:
+ return "'defined?'";
+ case PM_TOKEN_KEYWORD_DO:
+ return "'do'";
+ case PM_TOKEN_KEYWORD_DO_BLOCK:
+ return "'do'";
+ case PM_TOKEN_KEYWORD_DO_LOOP:
+ return "'do'";
+ case PM_TOKEN_KEYWORD_ELSE:
+ return "'else'";
+ case PM_TOKEN_KEYWORD_ELSIF:
+ return "'elsif'";
+ case PM_TOKEN_KEYWORD_END:
+ return "'end'";
+ case PM_TOKEN_KEYWORD_END_UPCASE:
+ return "'END'";
+ case PM_TOKEN_KEYWORD_ENSURE:
+ return "'ensure'";
+ case PM_TOKEN_KEYWORD_FALSE:
+ return "'false'";
+ case PM_TOKEN_KEYWORD_FOR:
+ return "'for'";
+ case PM_TOKEN_KEYWORD_IF:
+ return "'if'";
+ case PM_TOKEN_KEYWORD_IF_MODIFIER:
+ return "'if'";
+ case PM_TOKEN_KEYWORD_IN:
+ return "'in'";
+ case PM_TOKEN_KEYWORD_MODULE:
+ return "'module'";
+ case PM_TOKEN_KEYWORD_NEXT:
+ return "'next'";
+ case PM_TOKEN_KEYWORD_NIL:
+ return "'nil'";
+ case PM_TOKEN_KEYWORD_NOT:
+ return "'not'";
+ case PM_TOKEN_KEYWORD_OR:
+ return "'or'";
+ case PM_TOKEN_KEYWORD_REDO:
+ return "'redo'";
+ case PM_TOKEN_KEYWORD_RESCUE:
+ return "'rescue'";
+ case PM_TOKEN_KEYWORD_RESCUE_MODIFIER:
+ return "'rescue' modifier";
+ case PM_TOKEN_KEYWORD_RETRY:
+ return "'retry'";
+ case PM_TOKEN_KEYWORD_RETURN:
+ return "'return'";
+ case PM_TOKEN_KEYWORD_SELF:
+ return "'self'";
+ case PM_TOKEN_KEYWORD_SUPER:
+ return "'super'";
+ case PM_TOKEN_KEYWORD_THEN:
+ return "'then'";
+ case PM_TOKEN_KEYWORD_TRUE:
+ return "'true'";
+ case PM_TOKEN_KEYWORD_UNDEF:
+ return "'undef'";
+ case PM_TOKEN_KEYWORD_UNLESS:
+ return "'unless'";
+ case PM_TOKEN_KEYWORD_UNLESS_MODIFIER:
+ return "'unless'";
+ case PM_TOKEN_KEYWORD_UNTIL:
+ return "'until'";
+ case PM_TOKEN_KEYWORD_UNTIL_MODIFIER:
+ return "'until'";
+ case PM_TOKEN_KEYWORD_WHEN:
+ return "'when'";
+ case PM_TOKEN_KEYWORD_WHILE:
+ return "'while'";
+ case PM_TOKEN_KEYWORD_WHILE_MODIFIER:
+ return "'while'";
+ case PM_TOKEN_KEYWORD_YIELD:
+ return "'yield'";
+ case PM_TOKEN_KEYWORD___ENCODING__:
+ return "'__ENCODING__'";
+ case PM_TOKEN_KEYWORD___FILE__:
+ return "'__FILE__'";
+ case PM_TOKEN_KEYWORD___LINE__:
+ return "'__LINE__'";
+ case PM_TOKEN_LABEL:
+ return "label";
+ case PM_TOKEN_LABEL_END:
+ return "label terminator";
+ case PM_TOKEN_LAMBDA_BEGIN:
+ return "'{'";
+ case PM_TOKEN_LESS:
+ return "'<'";
+ case PM_TOKEN_LESS_EQUAL:
+ return "'<='";
+ case PM_TOKEN_LESS_EQUAL_GREATER:
+ return "'<=>'";
+ case PM_TOKEN_LESS_LESS:
+ return "<<";
+ case PM_TOKEN_LESS_LESS_EQUAL:
+ return "<<=";
+ case PM_TOKEN_METHOD_NAME:
+ return "method name";
+ case PM_TOKEN_MINUS:
+ return "'-'";
+ case PM_TOKEN_MINUS_EQUAL:
+ return "'-='";
+ case PM_TOKEN_MINUS_GREATER:
+ return "'->'";
+ case PM_TOKEN_NEWLINE:
+ return "newline";
+ case PM_TOKEN_NUMBERED_REFERENCE:
+ return "numbered reference";
+ case PM_TOKEN_PARENTHESIS_LEFT:
+ return "'('";
+ case PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES:
+ return "'('";
+ case PM_TOKEN_PARENTHESIS_RIGHT:
+ return "')'";
+ case PM_TOKEN_PERCENT:
+ return "'%'";
+ case PM_TOKEN_PERCENT_EQUAL:
+ return "'%='";
+ case PM_TOKEN_PERCENT_LOWER_I:
+ return "'%i'";
+ case PM_TOKEN_PERCENT_LOWER_W:
+ return "'%w'";
+ case PM_TOKEN_PERCENT_LOWER_X:
+ return "'%x'";
+ case PM_TOKEN_PERCENT_UPPER_I:
+ return "'%I'";
+ case PM_TOKEN_PERCENT_UPPER_W:
+ return "'%W'";
+ case PM_TOKEN_PIPE:
+ return "'|'";
+ case PM_TOKEN_PIPE_EQUAL:
+ return "'|='";
+ case PM_TOKEN_PIPE_PIPE:
+ return "'||'";
+ case PM_TOKEN_PIPE_PIPE_EQUAL:
+ return "'||='";
+ case PM_TOKEN_PLUS:
+ return "'+'";
+ case PM_TOKEN_PLUS_EQUAL:
+ return "'+='";
+ case PM_TOKEN_QUESTION_MARK:
+ return "'?'";
+ case PM_TOKEN_REGEXP_BEGIN:
+ return "regular expression beginning";
+ case PM_TOKEN_REGEXP_END:
+ return "regular expression ending";
+ case PM_TOKEN_SEMICOLON:
+ return "';'";
+ case PM_TOKEN_SLASH:
+ return "'/'";
+ case PM_TOKEN_SLASH_EQUAL:
+ return "'/='";
+ case PM_TOKEN_STAR:
+ return "'*'";
+ case PM_TOKEN_STAR_EQUAL:
+ return "'*='";
+ case PM_TOKEN_STAR_STAR:
+ return "'**'";
+ case PM_TOKEN_STAR_STAR_EQUAL:
+ return "'**='";
+ case PM_TOKEN_STRING_BEGIN:
+ return "string literal";
+ case PM_TOKEN_STRING_CONTENT:
+ return "string content";
+ case PM_TOKEN_STRING_END:
+ return "string ending";
+ case PM_TOKEN_SYMBOL_BEGIN:
+ return "symbol literal";
+ case PM_TOKEN_TILDE:
+ return "'~'";
+ case PM_TOKEN_UAMPERSAND:
+ return "'&'";
+ case PM_TOKEN_UCOLON_COLON:
+ return "'::'";
+ case PM_TOKEN_UDOT_DOT:
+ return "'..'";
+ case PM_TOKEN_UDOT_DOT_DOT:
+ return "'...'";
+ case PM_TOKEN_UMINUS:
+ return "'-'";
+ case PM_TOKEN_UMINUS_NUM:
+ return "'-'";
+ case PM_TOKEN_UPLUS:
+ return "'+'";
+ case PM_TOKEN_USTAR:
+ return "*";
+ case PM_TOKEN_USTAR_STAR:
+ return "**";
+ case PM_TOKEN_WORDS_SEP:
+ return "string separator";
+ case PM_TOKEN___END__:
+ return "'__END__'";
+ case PM_TOKEN_MAXIMUM:
+ assert(false && "unreachable");
+ return "";
+ }
+
+ /* Provide a default, because some compilers cannot determine that the above
+ * switch is exhaustive. */
+ assert(false && "unreachable");
+ return "";
+}
diff --git a/prism/templates/template.rb b/prism/templates/template.rb
new file mode 100755
index 0000000000..0fdeda561f
--- /dev/null
+++ b/prism/templates/template.rb
@@ -0,0 +1,723 @@
+#!/usr/bin/env ruby
+# typed: ignore
+
+require "erb"
+require "fileutils"
+require "yaml"
+
+module Prism
+ module Template # :nodoc: all
+ SERIALIZE_ONLY_SEMANTICS_FIELDS = ENV.fetch("PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS", false)
+ CHECK_FIELD_KIND = ENV.fetch("CHECK_FIELD_KIND", false)
+
+ JAVA_BACKEND = ENV["PRISM_JAVA_BACKEND"] || "default"
+ JAVA_IDENTIFIER_TYPE = JAVA_BACKEND == "truffleruby" ? "String" : "byte[]"
+ INCLUDE_NODE_ID = !SERIALIZE_ONLY_SEMANTICS_FIELDS || JAVA_BACKEND == "jruby"
+
+ COMMON_FLAGS_COUNT = 2
+
+ class Error
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ end
+ end
+
+ class Warning
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ end
+ end
+
+ # This module contains methods for escaping characters in JavaDoc comments.
+ module JavaDoc
+ ESCAPES = {
+ "'" => "&#39;",
+ "\"" => "&quot;",
+ "@" => "&#64;",
+ "&" => "&amp;",
+ "<" => "&lt;",
+ ">" => "&gt;"
+ }.freeze
+
+ def self.escape(value)
+ value.gsub(/['&"<>@]/, ESCAPES)
+ end
+ end
+
+ # This module contains methods for escaping characters in Doxygen comments.
+ module Doxygen
+ # Similar to /verbatim ... /endverbatim but doesn't wrap the result in a code block.
+ def self.verbatim(value)
+ value.gsub(/[*%!`#<>_+@-]/, '\\\\\0')
+ end
+ end
+
+ # A comment attached to a field or node.
+ class ConfigComment
+ attr_reader :value
+
+ def initialize(value)
+ @value = value
+ end
+
+ def each_line(&block)
+ value.each_line { |line| yield line.prepend(" ").rstrip }
+ end
+
+ def each_java_line(&block)
+ ConfigComment.new(JavaDoc.escape(value)).each_line(&block)
+ end
+ end
+
+ # This represents a field on a node. It contains all of the necessary
+ # information to template out the code for that field.
+ class Field
+ attr_reader :name, :comment, :options
+
+ def initialize(name:, comment: nil, **options)
+ @name = name
+ @comment = comment
+ @options = options
+ end
+
+ def each_comment_line(&block)
+ ConfigComment.new(comment).each_line(&block) if comment
+ end
+
+ def each_comment_java_line(&block)
+ ConfigComment.new(comment).each_java_line(&block) if comment
+ end
+
+ def semantic_field?
+ true
+ end
+
+ def should_be_serialized?
+ SERIALIZE_ONLY_SEMANTICS_FIELDS ? semantic_field? : true
+ end
+ end
+
+ # Some node fields can be specialized if they point to a specific kind of
+ # node and not just a generic node.
+ class NodeKindField < Field
+ # The C type to use for this field as a function parameter.
+ def c_param
+ "struct #{c_type} *#{name}"
+ end
+
+ def initialize(kind:, **options)
+ @kind = kind
+ super(**options)
+ end
+
+ def c_type
+ if specific_kind
+ "pm_#{specific_kind.gsub(/(?<=.)[A-Z]/, "_\\0").downcase}"
+ else
+ "pm_node"
+ end
+ end
+
+ def ruby_type
+ specific_kind || "Node"
+ end
+
+ def java_type
+ specific_kind || "Node"
+ end
+
+ def java_cast
+ if specific_kind
+ "(Nodes.#{@kind}) "
+ else
+ ""
+ end
+ end
+
+ def specific_kind
+ @kind unless @kind.is_a?(Array)
+ end
+
+ def union_kind
+ @kind if @kind.is_a?(Array)
+ end
+ end
+
+ # This represents a field on a node that is itself a node. We pass them as
+ # references and store them as references.
+ class NodeField < NodeKindField
+ def rbs_class
+ if specific_kind
+ specific_kind
+ elsif union_kind
+ "(#{union_kind.join(" | ")})"
+ else
+ "Prism::node"
+ end
+ end
+
+ def call_seq_type
+ if specific_kind
+ specific_kind
+ elsif union_kind
+ union_kind.join(" | ")
+ else
+ "Node"
+ end
+ end
+
+ def check_field_kind
+ if union_kind
+ "[#{union_kind.join(', ')}, ErrorRecoveryNode].include?(#{name}.class)"
+ else
+ "#{name}.is_a?(#{ruby_type}) || #{name}.is_a?(ErrorRecoveryNode)"
+ end
+ end
+ end
+
+ # This represents a field on a node that is itself a node and can be
+ # optionally null. We pass them as references and store them as references.
+ class OptionalNodeField < NodeKindField
+ def rbs_class
+ if specific_kind
+ "#{specific_kind}?"
+ elsif union_kind
+ "(#{union_kind.join(" | ")})?"
+ else
+ "Prism::node?"
+ end
+ end
+
+ def call_seq_type
+ if specific_kind
+ "#{specific_kind} | nil"
+ elsif union_kind
+ [*union_kind, "nil"].join(" | ")
+ else
+ "Node | nil"
+ end
+ end
+
+ def check_field_kind
+ if union_kind
+ "[#{union_kind.join(', ')}, ErrorRecoveryNode, NilClass].include?(#{name}.class)"
+ else
+ "#{name}.nil? || #{name}.is_a?(#{ruby_type}) || #{name}.is_a?(ErrorRecoveryNode)"
+ end
+ end
+ end
+
+ # This represents a field on a node that is a list of nodes. We pass them as
+ # references and store them directly on the struct.
+ class NodeListField < NodeKindField
+ def c_param
+ "pm_node_list_t #{name}"
+ end
+
+ def element_rbs_class
+ if specific_kind
+ "#{specific_kind}"
+ elsif union_kind
+ "#{union_kind.join(" | ")}"
+ else
+ "Prism::node"
+ end
+ end
+
+ def rbs_class
+ "Array[#{element_rbs_class}]"
+ end
+
+ def call_seq_type
+ if specific_kind
+ "Array[#{specific_kind}]"
+ elsif union_kind
+ "Array[#{union_kind.join(" | ")}]"
+ else
+ "Array[Node]"
+ end
+ end
+
+ def java_type
+ "#{super}[]"
+ end
+
+ def check_field_kind
+ if union_kind
+ "#{name}.all? { |n| [#{union_kind.join(', ')}, ErrorRecoveryNode].include?(n.class) }"
+ else
+ "#{name}.all? { |n| n.is_a?(#{ruby_type}) || n.is_a?(ErrorRecoveryNode) }"
+ end
+ end
+ end
+
+ # This represents a field on a node that is the ID of a string interned
+ # through the parser's constant pool.
+ class ConstantField < Field
+ def c_param
+ "pm_constant_id_t #{name}"
+ end
+
+ def rbs_class
+ "Symbol"
+ end
+
+ def call_seq_type
+ "Symbol"
+ end
+
+ def java_type
+ JAVA_IDENTIFIER_TYPE
+ end
+ end
+
+ # This represents a field on a node that is the ID of a string interned
+ # through the parser's constant pool and can be optionally null.
+ class OptionalConstantField < Field
+ def c_param
+ "pm_constant_id_t #{name}"
+ end
+
+ def rbs_class
+ "Symbol?"
+ end
+
+ def call_seq_type
+ "Symbol | nil"
+ end
+
+ def java_type
+ JAVA_IDENTIFIER_TYPE
+ end
+ end
+
+ # This represents a field on a node that is a list of IDs that are associated
+ # with strings interned through the parser's constant pool.
+ class ConstantListField < Field
+ def c_param
+ "pm_constant_id_list_t #{name}"
+ end
+
+ def rbs_class
+ "Array[Symbol]"
+ end
+
+ def call_seq_type
+ "Array[Symbol]"
+ end
+
+ def java_type
+ "#{JAVA_IDENTIFIER_TYPE}[]"
+ end
+ end
+
+ # This represents a field on a node that is a string.
+ class StringField < Field
+ def c_param
+ "pm_string_t #{name}"
+ end
+
+ def rbs_class
+ "String"
+ end
+
+ def call_seq_type
+ "String"
+ end
+
+ def java_type
+ "byte[]"
+ end
+ end
+
+ # This represents a field on a node that is a location.
+ class LocationField < Field
+ def c_param
+ "pm_location_t #{name}"
+ end
+
+ def semantic_field?
+ false
+ end
+
+ def rbs_class
+ "Location"
+ end
+
+ def call_seq_type
+ "Location"
+ end
+
+ def java_type
+ "Location"
+ end
+ end
+
+ # This represents a field on a node that is a location that is optional.
+ class OptionalLocationField < Field
+ def c_param
+ "pm_location_t #{name}"
+ end
+
+ def semantic_field?
+ false
+ end
+
+ def rbs_class
+ "Location?"
+ end
+
+ def call_seq_type
+ "Location | nil"
+ end
+
+ def java_type
+ "Location"
+ end
+ end
+
+ # This represents an integer field.
+ class UInt8Field < Field
+ def c_param
+ "uint8_t #{name}"
+ end
+
+ def rbs_class
+ "Integer"
+ end
+
+ def call_seq_type
+ "Integer"
+ end
+
+ def java_type
+ "int"
+ end
+ end
+
+ # This represents an integer field.
+ class UInt32Field < Field
+ def c_param
+ "uint32_t #{name}"
+ end
+
+ def rbs_class
+ "Integer"
+ end
+
+ def call_seq_type
+ "Integer"
+ end
+
+ def java_type
+ "int"
+ end
+ end
+
+ # This represents an arbitrarily-sized integer. When it gets to Ruby it will
+ # be an Integer.
+ class IntegerField < Field
+ def c_param
+ "pm_integer_t #{name}"
+ end
+
+ def rbs_class
+ "Integer"
+ end
+
+ def call_seq_type
+ "Integer"
+ end
+
+ def java_type
+ "Object"
+ end
+ end
+
+ # This represents a double-precision floating point number. When it gets to
+ # Ruby it will be a Float.
+ class DoubleField < Field
+ def c_param
+ "double #{name}"
+ end
+
+ def rbs_class
+ "Float"
+ end
+
+ def call_seq_type
+ "Float"
+ end
+
+ def java_type
+ "double"
+ end
+ end
+
+ # This class represents a node in the tree, configured by the config.yml file
+ # in YAML format. It contains information about the name of the node and the
+ # various child nodes it contains.
+ class NodeType
+ attr_reader :name, :type, :human, :flags, :fields, :newline, :comment
+
+ def initialize(config, flags)
+ @name = config.fetch("name")
+
+ type = @name.gsub(/(?<=.)[A-Z]/, "_\\0")
+ @type = "PM_#{type.upcase}"
+ @human = type.downcase
+
+ @fields =
+ config.fetch("fields", []).map do |field|
+ type = field_type_for(field.fetch("type"))
+
+ options = field.transform_keys(&:to_sym)
+ options.delete(:type)
+
+ # If/when we have documentation on every field, this should be
+ # changed to use fetch instead of delete.
+ comment = options.delete(:comment)
+
+ if kinds = options[:kind]
+ kinds = [kinds] unless kinds.is_a?(Array)
+ kinds = kinds.map do |kind|
+ case kind
+ when "non-void expression"
+ # the actual list of types would be way too long
+ "Node"
+ when "pattern expression"
+ # the list of all possible types is too long with 37+ different classes
+ "Node"
+ else
+ kind
+ end
+ end.compact
+ if kinds.size == 1
+ kinds = kinds.first
+ kinds = nil if kinds == "Node"
+ end
+ options[:kind] = kinds
+ else
+ if type < NodeKindField
+ raise "Missing kind in config.yml for field #{@name}##{options.fetch(:name)}"
+ end
+ end
+
+ type.new(comment: comment, **options)
+ end
+
+ @flags = config.key?("flags") ? flags.fetch(config.fetch("flags")) : nil
+ @newline = config.fetch("newline", true)
+ @comment = config.fetch("comment")
+ end
+
+ def each_comment_line(&block)
+ ConfigComment.new(comment).each_line(&block)
+ end
+
+ def each_comment_java_line(&block)
+ ConfigComment.new(comment).each_java_line(&block)
+ end
+
+ def semantic_fields
+ @semantic_fields ||= @fields.select(&:semantic_field?)
+ end
+
+ # Should emit serialized length of node so implementations can skip
+ # the node to enable lazy parsing.
+ def needs_serialized_length?
+ name == "DefNode"
+ end
+
+ private
+
+ def field_type_for(name)
+ case name
+ when "node" then NodeField
+ when "node?" then OptionalNodeField
+ when "node[]" then NodeListField
+ when "string" then StringField
+ when "constant" then ConstantField
+ when "constant?" then OptionalConstantField
+ when "constant[]" then ConstantListField
+ when "location" then LocationField
+ when "location?" then OptionalLocationField
+ when "uint8" then UInt8Field
+ when "uint32" then UInt32Field
+ when "integer" then IntegerField
+ when "double" then DoubleField
+ else raise("Unknown field type: #{name.inspect}")
+ end
+ end
+ end
+
+ # This represents a token in the lexer.
+ class Token
+ attr_reader :name, :value, :comment
+
+ def initialize(config)
+ @name = config.fetch("name")
+ @value = config["value"]
+ @comment = config.fetch("comment")
+ end
+ end
+
+ # Represents a set of flags that should be internally represented with an enum.
+ class Flags
+ # Represents an individual flag within a set of flags.
+ class Flag
+ attr_reader :name, :camelcase, :comment
+
+ def initialize(config)
+ @name = config.fetch("name")
+ @camelcase = @name.split("_").map(&:capitalize).join
+ @comment = config.fetch("comment")
+ end
+ end
+
+ attr_reader :name, :human, :values, :comment
+
+ def initialize(config)
+ @name = config.fetch("name")
+ @human = @name.gsub(/(?<=.)[A-Z]/, "_\\0").downcase
+ @values = config.fetch("values").map { |flag| Flag.new(flag) }
+ @comment = config.fetch("comment")
+ end
+
+ def self.empty
+ new("name" => "", "values" => [], "comment" => "")
+ end
+ end
+
+ class << self
+ # This templates out a file using ERB with the given locals. The locals are
+ # derived from the config.yml file.
+ def render(name, write_to: nil)
+ filepath = "templates/#{name}.erb"
+ template = File.expand_path("../#{filepath}", __dir__)
+
+ erb = read_template(template)
+ extension = File.extname(filepath.gsub(".erb", ""))
+
+ heading =
+ if extension == ".rb"
+ <<~HEADING
+ # frozen_string_literal: true
+ # :markup: markdown
+
+ =begin
+ --
+ This file is generated by the templates/template.rb script and should not be
+ modified manually. See #{filepath}
+ if you are looking to modify the template
+ ++
+ =end
+
+ HEADING
+ else
+ <<~HEADING
+ /*----------------------------------------------------------------------------*/
+ /* This file is generated by the templates/template.rb script and should not */
+ /* be modified manually. See */
+ /* #{filepath.ljust(74)} */
+ /* if you are looking to modify the */
+ /* template */
+ /*----------------------------------------------------------------------------*/
+
+ HEADING
+ end
+
+ write_to ||= File.expand_path("../#{name}", __dir__)
+ contents = heading + erb.result_with_hash(locals)
+
+ if (extension == ".c" || extension == ".h") && !contents.ascii_only?
+ # Enforce that we only have ASCII characters here. This is necessary
+ # for non-UTF-8 locales that only allow ASCII characters in C source
+ # files.
+ contents.each_line.with_index(1) do |line, line_number|
+ raise "Non-ASCII character on line #{line_number} of #{write_to}" unless line.ascii_only?
+ end
+ end
+
+ begin
+ FileUtils.mkdir_p(File.dirname(write_to))
+ File.write(write_to, contents)
+ rescue SystemCallError # EACCES, EPERM, EROFS, etc.
+ # Fall back to the current directory
+ FileUtils.mkdir_p(File.dirname(name))
+ File.write(name, contents)
+ end
+ end
+
+ private
+
+ def read_template(filepath)
+ template = File.read(filepath, encoding: Encoding::UTF_8)
+ erb = erb(template)
+ erb.filename = filepath
+ erb
+ end
+
+ def erb(template)
+ ERB.new(template, trim_mode: "-")
+ end
+
+ def locals
+ @locals ||=
+ begin
+ config = YAML.load_file(File.expand_path("../config.yml", __dir__))
+ flags = config.fetch("flags").to_h { |flags| [flags["name"], Flags.new(flags)] }
+
+ {
+ errors: config.fetch("errors").map { |name| Error.new(name) },
+ warnings: config.fetch("warnings").map { |name| Warning.new(name) },
+ nodes: config.fetch("nodes").map { |node| NodeType.new(node, flags) }.sort_by(&:name),
+ tokens: config.fetch("tokens").map { |token| Token.new(token) },
+ flags: flags.values
+ }
+ end
+ end
+ end
+
+ TEMPLATES = [
+ "ext/prism/api_node.c",
+ "include/prism/ast.h",
+ "include/prism/internal/diagnostic.h",
+ "javascript/src/deserialize.js",
+ "javascript/src/nodes.js",
+ "javascript/src/visitor.js",
+ "java/api/src/main/java-templates/org/ruby_lang/prism/Loader.java",
+ "java/api/src/main/java-templates/org/ruby_lang/prism/Nodes.java",
+ "java/api/src/main/java-templates/org/ruby_lang/prism/AbstractNodeVisitor.java",
+ "lib/prism/compiler.rb",
+ "lib/prism/dispatcher.rb",
+ "lib/prism/dot_visitor.rb",
+ "lib/prism/dsl.rb",
+ "lib/prism/inspect_visitor.rb",
+ "lib/prism/mutation_compiler.rb",
+ "lib/prism/node.rb",
+ "lib/prism/reflection.rb",
+ "lib/prism/serialize.rb",
+ "lib/prism/visitor.rb",
+ "src/diagnostic.c",
+ "src/json.c",
+ "src/node.c",
+ "src/prettyprint.c",
+ "src/serialize.c",
+ "src/tokens.c"
+ ]
+ end
+end
+
+if __FILE__ == $0
+ if ARGV.empty?
+ Prism::Template::TEMPLATES.each { |filepath| Prism::Template.render(filepath) }
+ else # ruby/ruby
+ name, write_to = ARGV
+ Prism::Template.render(name, write_to: write_to)
+ end
+end
diff --git a/prism/version.h b/prism/version.h
new file mode 100644
index 0000000000..181b398462
--- /dev/null
+++ b/prism/version.h
@@ -0,0 +1,38 @@
+/**
+ * @file version.h
+ *
+ * The version of the Prism library.
+ */
+#ifndef PRISM_VERSION_H
+#define PRISM_VERSION_H
+
+#include "prism/compiler/exported.h"
+
+/**
+ * The major version of the Prism library as an int.
+ */
+#define PRISM_VERSION_MAJOR 1
+
+/**
+ * The minor version of the Prism library as an int.
+ */
+#define PRISM_VERSION_MINOR 9
+
+/**
+ * The patch version of the Prism library as an int.
+ */
+#define PRISM_VERSION_PATCH 0
+
+/**
+ * The version of the Prism library as a constant string.
+ */
+#define PRISM_VERSION "1.9.0"
+
+/**
+ * The prism version and the serialization format.
+ *
+ * @returns The prism version as a constant string.
+ */
+PRISM_EXPORTED_FUNCTION const char * pm_version(void);
+
+#endif
diff --git a/prism_compile.c b/prism_compile.c
new file mode 100644
index 0000000000..45e1de8a9c
--- /dev/null
+++ b/prism_compile.c
@@ -0,0 +1,11720 @@
+#include "prism.h"
+#include "ruby/version.h"
+
+#include <fcntl.h>
+
+/**
+ * This compiler defines its own concept of the location of a node. We do this
+ * because we want to pair line information with node identifier so that we can
+ * have reproducible parses.
+ */
+typedef struct {
+ /** This is the line number of a node. */
+ int32_t line;
+
+ /** This is a unique identifier for the node. */
+ uint32_t node_id;
+} pm_node_location_t;
+
+/******************************************************************************/
+/* These macros operate on pm_node_location_t structs as opposed to NODE*s. */
+/******************************************************************************/
+
+#define PUSH_ADJUST(seq, location, label) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (int) (location).line))
+
+#define PUSH_ADJUST_RESTORE(seq, label) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))
+
+#define PUSH_INSN(seq, location, insn) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (int) (location).line, (int) (location).node_id, BIN(insn), 0))
+
+#define PUSH_INSN1(seq, location, insn, op1) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (int) (location).line, (int) (location).node_id, BIN(insn), 1, (VALUE)(op1)))
+
+#define PUSH_INSN2(seq, location, insn, op1, op2) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (int) (location).line, (int) (location).node_id, BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))
+
+#define PUSH_INSN3(seq, location, insn, op1, op2, op3) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (int) (location).line, (int) (location).node_id, BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))
+
+#define PUSH_INSNL(seq, location, insn, label) \
+ (PUSH_INSN1(seq, location, insn, label), LABEL_REF(label))
+
+#define PUSH_LABEL(seq, label) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) (label))
+
+#define PUSH_SEND_R(seq, location, id, argc, block, flag, keywords) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (int) (location).line, (int) (location).node_id, (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
+
+#define PUSH_SEND(seq, location, id, argc) \
+ PUSH_SEND_R((seq), location, (id), (argc), NULL, (VALUE)INT2FIX(0), NULL)
+
+#define PUSH_SEND_WITH_FLAG(seq, location, id, argc, flag) \
+ PUSH_SEND_R((seq), location, (id), (argc), NULL, (VALUE)(flag), NULL)
+
+#define PUSH_SEND_WITH_BLOCK(seq, location, id, argc, block) \
+ PUSH_SEND_R((seq), location, (id), (argc), (block), (VALUE)INT2FIX(0), NULL)
+
+#define PUSH_CALL(seq, location, id, argc) \
+ PUSH_SEND_R((seq), location, (id), (argc), NULL, (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
+
+#define PUSH_CALL_WITH_BLOCK(seq, location, id, argc, block) \
+ PUSH_SEND_R((seq), location, (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
+
+#define PUSH_TRACE(seq, event) \
+ ADD_ELEM((seq), (LINK_ELEMENT *) new_trace_body(iseq, (event), 0))
+
+#define PUSH_CATCH_ENTRY(type, ls, le, iseqv, lc) \
+ ADD_CATCH_ENTRY((type), (ls), (le), (iseqv), (lc))
+
+#define PUSH_SEQ(seq1, seq2) \
+ APPEND_LIST((seq1), (seq2))
+
+#define PUSH_SYNTHETIC_PUTNIL(seq, iseq) \
+ do { \
+ int lineno = ISEQ_COMPILE_DATA(iseq)->last_line; \
+ if (lineno == 0) lineno = FIX2INT(rb_iseq_first_lineno(iseq)); \
+ ADD_SYNTHETIC_INSN(seq, lineno, -1, putnil); \
+ } while (0)
+
+/******************************************************************************/
+/* These functions compile getlocal/setlocal instructions but operate on */
+/* prism locations instead of NODEs. */
+/******************************************************************************/
+
+static void
+pm_iseq_add_getlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line, int node_id, int idx, int level)
+{
+ if (iseq_local_block_param_p(iseq, idx, level)) {
+ ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, node_id, BIN(getblockparam), 2, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)));
+ }
+ else {
+ ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, node_id, BIN(getlocal), 2, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)));
+ }
+ if (level > 0) access_outer_variables(iseq, level, iseq_lvar_id(iseq, idx, level), Qfalse);
+}
+
+static void
+pm_iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line, int node_id, int idx, int level)
+{
+ if (iseq_local_block_param_p(iseq, idx, level)) {
+ ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, node_id, BIN(setblockparam), 2, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)));
+ }
+ else {
+ ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, node_id, BIN(setlocal), 2, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)));
+ }
+ update_lvar_state(iseq, level, idx);
+ if (level > 0) access_outer_variables(iseq, level, iseq_lvar_id(iseq, idx, level), Qtrue);
+}
+
+#define PUSH_GETLOCAL(seq, location, idx, level) \
+ pm_iseq_add_getlocal(iseq, (seq), (int) (location).line, (int) (location).node_id, (idx), (level))
+
+#define PUSH_SETLOCAL(seq, location, idx, level) \
+ pm_iseq_add_setlocal(iseq, (seq), (int) (location).line, (int) (location).node_id, (idx), (level))
+
+/******************************************************************************/
+/* These are helper macros for the compiler. */
+/******************************************************************************/
+
+#define OLD_ISEQ NEW_ISEQ
+#undef NEW_ISEQ
+
+#define NEW_ISEQ(node, name, type, line_no) \
+ pm_new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))
+
+#define OLD_CHILD_ISEQ NEW_CHILD_ISEQ
+#undef NEW_CHILD_ISEQ
+
+#define NEW_CHILD_ISEQ(node, name, type, line_no) \
+ pm_new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))
+
+#define PM_COMPILE(node) \
+ pm_compile_node(iseq, (node), ret, popped, scope_node)
+
+#define PM_COMPILE_INTO_ANCHOR(_ret, node) \
+ pm_compile_node(iseq, (node), _ret, popped, scope_node)
+
+#define PM_COMPILE_POPPED(node) \
+ pm_compile_node(iseq, (node), ret, true, scope_node)
+
+#define PM_COMPILE_NOT_POPPED(node) \
+ pm_compile_node(iseq, (node), ret, false, scope_node)
+
+// Direct-indexed lookup table. -1 means "not present".
+#define PM_INDEX_LOOKUP_TABLE_INIT { .values = NULL, .capacity = 0, .owned = false }
+
+static inline void
+pm_index_lookup_table_init(pm_index_lookup_table_t *table, int constants_size, rb_iseq_t *iseq)
+{
+ int capacity = constants_size + PM_INDEX_LOOKUP_SPECIALS;
+ table->values = compile_data_alloc2_type(iseq, int, capacity);
+ memset(table->values, -1, capacity * sizeof(int));
+ table->capacity = capacity;
+ table->owned = false;
+}
+
+/**
+ * Cached line lookup that avoids repeated binary searches. Since the compiler
+ * walks the AST roughly in source order, consecutive lookups tend to be for
+ * nearby byte offsets. We cache the last result index in the scope node and
+ * try a short linear probe from there before falling back to binary search.
+ */
+static inline pm_line_column_t
+pm_line_offset_list_line_column_cached(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line, size_t *last_line)
+{
+ size_t hint = *last_line;
+ size_t size = list->size;
+ const uint32_t *offsets = list->offsets;
+
+ RUBY_ASSERT(hint < size);
+
+ /* Check if the cursor is on the same line as the hint. */
+ if (offsets[hint] <= cursor) {
+ if (hint + 1 >= size || offsets[hint + 1] > cursor) {
+ *last_line = hint;
+ return ((pm_line_column_t) {
+ .line = ((int32_t) hint) + start_line,
+ .column = cursor - offsets[hint]
+ });
+ }
+
+ /* Linear scan forward (up to 8 lines before giving up). */
+ size_t limit = hint + 9;
+ if (limit > size) limit = size;
+ for (size_t idx = hint + 1; idx < limit; idx++) {
+ if (offsets[idx] > cursor) {
+ *last_line = idx - 1;
+ return ((pm_line_column_t) {
+ .line = ((int32_t) (idx - 1)) + start_line,
+ .column = cursor - offsets[idx - 1]
+ });
+ }
+ if (offsets[idx] == cursor) {
+ *last_line = idx;
+ return ((pm_line_column_t) { ((int32_t) idx) + start_line, 0 });
+ }
+ }
+ }
+ else {
+ /* Linear scan backward (up to 8 lines before giving up). */
+ size_t limit = hint > 8 ? hint - 8 : 0;
+ for (size_t idx = hint; idx > limit; idx--) {
+ if (offsets[idx - 1] <= cursor) {
+ *last_line = idx - 1;
+ return ((pm_line_column_t) {
+ .line = ((int32_t) (idx - 1)) + start_line,
+ .column = cursor - offsets[idx - 1]
+ });
+ }
+ }
+ }
+
+ /* Fall back to binary search. */
+ pm_line_column_t result = pm_line_offset_list_line_column(list, cursor, start_line);
+ *last_line = (size_t) (result.line - start_line);
+ return result;
+}
+
+/**
+ * The same as pm_line_offset_list_line_column_cached, but returning only the
+ * line number.
+ */
+static inline int32_t
+pm_line_offset_list_line_cached(const pm_line_offset_list_t *list, uint32_t cursor, int32_t start_line, size_t *last_line)
+{
+ return pm_line_offset_list_line_column_cached(list, cursor, start_line, last_line).line;
+}
+
+#define PM_NODE_START_LOCATION(node) \
+ ((pm_node_location_t) { .line = pm_line_offset_list_line_cached(scope_node->line_offsets, ((const pm_node_t *) (node))->location.start, scope_node->start_line, &scope_node->last_line), .node_id = ((const pm_node_t *) (node))->node_id })
+
+#define PM_NODE_END_LOCATION(node) \
+ ((pm_node_location_t) { .line = pm_line_offset_list_line_cached(scope_node->line_offsets, ((const pm_node_t *) (node))->location.start + ((const pm_node_t *) (node))->location.length, scope_node->start_line, &scope_node->last_line), .node_id = ((const pm_node_t *) (node))->node_id })
+
+#define PM_LOCATION_START_LOCATION(location, id) \
+ ((pm_node_location_t) { .line = pm_line_offset_list_line_cached(scope_node->line_offsets, (location)->start, scope_node->start_line, &scope_node->last_line), .node_id = id })
+
+#define PM_NODE_START_LINE_COLUMN(node) \
+ pm_line_offset_list_line_column_cached(scope_node->line_offsets, ((const pm_node_t *) (node))->location.start, scope_node->start_line, &scope_node->last_line)
+
+#define PM_NODE_END_LINE_COLUMN(node) \
+ pm_line_offset_list_line_column_cached(scope_node->line_offsets, ((const pm_node_t *) (node))->location.start + ((const pm_node_t *) (node))->location.length, scope_node->start_line, &scope_node->last_line)
+
+#define PM_LOCATION_START_LINE_COLUMN(location) \
+ pm_line_offset_list_line_column_cached(scope_node->line_offsets, (location)->start, scope_node->start_line, &scope_node->last_line)
+
+static int
+pm_location_line_number(const pm_parser_t *parser, const pm_location_t *location) {
+ return (int) pm_line_offset_list_line_column(pm_parser_line_offsets(parser), location->start, pm_parser_start_line(parser)).line;
+}
+
+/**
+ * Cached variants that use the scope node's hint for fast lookups during
+ * compilation (where access patterns are roughly sequential).
+ */
+static inline int
+pm_node_line_number_cached(const pm_node_t *node, pm_scope_node_t *scope_node)
+{
+ return (int) pm_line_offset_list_line_cached(scope_node->line_offsets, node->location.start, scope_node->start_line, &scope_node->last_line);
+}
+
+static inline int
+pm_location_line_number_cached(const pm_location_t *location, pm_scope_node_t *scope_node) {
+ return (int) pm_line_offset_list_line_cached(scope_node->line_offsets, location->start, scope_node->start_line, &scope_node->last_line);
+}
+
+/**
+ * Parse the value of a pm_integer_t into a Ruby Integer.
+ */
+static VALUE
+parse_integer_value(const pm_integer_t *integer)
+{
+ VALUE result;
+
+ if (integer->values == NULL) {
+ result = UINT2NUM(integer->value);
+ }
+ else {
+ // The pm_integer_t stores values as an array of uint32_t in
+ // least-significant-word-first order (base 2^32). We can convert
+ // directly to a Ruby Integer using rb_integer_unpack, avoiding the
+ // overhead of constructing a hex string and calling rb_funcall.
+ result = rb_integer_unpack(
+ integer->values,
+ integer->length,
+ sizeof(uint32_t),
+ 0,
+ INTEGER_PACK_LSWORD_FIRST | INTEGER_PACK_NATIVE_BYTE_ORDER
+ );
+ }
+
+ if (integer->negative) {
+ result = rb_int_uminus(result);
+ }
+
+ if (!SPECIAL_CONST_P(result)) {
+ RB_OBJ_SET_SHAREABLE(result); // bignum
+ }
+
+ return result;
+}
+
+/**
+ * Convert the value of an integer node into a Ruby Integer.
+ */
+static inline VALUE
+parse_integer(const pm_integer_node_t *node)
+{
+ return parse_integer_value(&node->value);
+}
+
+/**
+ * Convert the value of a float node into a Ruby Float.
+ */
+static VALUE
+parse_float(const pm_float_node_t *node)
+{
+ VALUE val = DBL2NUM(node->value);
+ if (!FLONUM_P(val)) {
+ RB_OBJ_SET_SHAREABLE(val);
+ }
+ return val;
+}
+
+/**
+ * Convert the value of a rational node into a Ruby Rational. Rational nodes can
+ * either be wrapping an integer node or a float node. If it's an integer node,
+ * we can reuse our parsing. If it's not, then we'll parse the numerator and
+ * then parse the denominator and create the rational from those two values.
+ */
+static VALUE
+parse_rational(const pm_rational_node_t *node)
+{
+ VALUE numerator = parse_integer_value(&node->numerator);
+ VALUE denominator = parse_integer_value(&node->denominator);
+
+ return rb_ractor_make_shareable(rb_rational_new(numerator, denominator));
+}
+
+/**
+ * Convert the value of an imaginary node into a Ruby Complex. Imaginary nodes
+ * can be wrapping an integer node, a float node, or a rational node. In all
+ * cases we will reuse parsing functions seen above to get the inner value, and
+ * then convert into an imaginary with rb_complex_raw.
+ */
+static VALUE
+parse_imaginary(const pm_imaginary_node_t *node)
+{
+ VALUE imaginary_part;
+ switch (PM_NODE_TYPE(node->numeric)) {
+ case PM_FLOAT_NODE: {
+ imaginary_part = parse_float((const pm_float_node_t *) node->numeric);
+ break;
+ }
+ case PM_INTEGER_NODE: {
+ imaginary_part = parse_integer((const pm_integer_node_t *) node->numeric);
+ break;
+ }
+ case PM_RATIONAL_NODE: {
+ imaginary_part = parse_rational((const pm_rational_node_t *) node->numeric);
+ break;
+ }
+ default:
+ rb_bug("Unexpected numeric type on imaginary number %s\n", pm_node_type(PM_NODE_TYPE(node->numeric)));
+ }
+
+ return RB_OBJ_SET_SHAREABLE(rb_complex_raw(INT2FIX(0), imaginary_part));
+}
+
+static inline VALUE
+parse_string(const pm_scope_node_t *scope_node, const pm_string_t *string)
+{
+ return rb_enc_str_new((const char *) pm_string_source(string), pm_string_length(string), scope_node->encoding);
+}
+
+/**
+ * Certain strings can have their encoding differ from the parser's encoding due
+ * to bytes or escape sequences that have the top bit set. This function handles
+ * creating those strings based on the flags set on the owning node.
+ */
+static inline VALUE
+parse_string_encoded(const pm_node_t *node, const pm_string_t *string, rb_encoding *default_encoding)
+{
+ rb_encoding *encoding;
+
+ if (node->flags & PM_ENCODING_FLAGS_FORCED_BINARY_ENCODING) {
+ encoding = rb_ascii8bit_encoding();
+ }
+ else if (node->flags & PM_ENCODING_FLAGS_FORCED_UTF8_ENCODING) {
+ encoding = rb_utf8_encoding();
+ }
+ else {
+ encoding = default_encoding;
+ }
+
+ return rb_enc_str_new((const char *) pm_string_source(string), pm_string_length(string), encoding);
+}
+
+static inline VALUE
+parse_static_literal_string(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, const pm_string_t *string)
+{
+ rb_encoding *encoding;
+
+ if (node->flags & PM_STRING_FLAGS_FORCED_BINARY_ENCODING) {
+ encoding = rb_ascii8bit_encoding();
+ }
+ else if (node->flags & PM_STRING_FLAGS_FORCED_UTF8_ENCODING) {
+ encoding = rb_utf8_encoding();
+ }
+ else {
+ encoding = scope_node->encoding;
+ }
+
+ VALUE value = rb_enc_literal_str((const char *) pm_string_source(string), pm_string_length(string), encoding);
+ rb_enc_str_coderange(value);
+
+ if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
+ int line_number = pm_node_line_number_cached(node, scope_node);
+ value = rb_ractor_make_shareable(rb_str_with_debug_created_info(value, rb_iseq_path(iseq), line_number));
+ }
+
+ return value;
+}
+
+static inline ID
+parse_string_symbol(const pm_scope_node_t *scope_node, const pm_symbol_node_t *symbol)
+{
+ rb_encoding *encoding;
+ if (symbol->base.flags & PM_SYMBOL_FLAGS_FORCED_UTF8_ENCODING) {
+ encoding = rb_utf8_encoding();
+ }
+ else if (symbol->base.flags & PM_SYMBOL_FLAGS_FORCED_BINARY_ENCODING) {
+ encoding = rb_ascii8bit_encoding();
+ }
+ else if (symbol->base.flags & PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING) {
+ encoding = rb_usascii_encoding();
+ }
+ else {
+ encoding = scope_node->encoding;
+ }
+
+ return rb_intern3((const char *) pm_string_source(&symbol->unescaped), pm_string_length(&symbol->unescaped), encoding);
+}
+
+static int
+pm_optimizable_range_item_p(const pm_node_t *node)
+{
+ return (!node || PM_NODE_TYPE_P(node, PM_INTEGER_NODE) || PM_NODE_TYPE_P(node, PM_NIL_NODE));
+}
+
+/** Raise an error corresponding to the invalid regular expression. */
+static VALUE
+parse_regexp_error(rb_iseq_t *iseq, int32_t line_number, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ VALUE error = rb_syntax_error_append(Qnil, rb_iseq_path(iseq), line_number, -1, NULL, "%" PRIsVALUE, args);
+ va_end(args);
+ rb_exc_raise(error);
+}
+
+static VALUE
+parse_regexp_string_part(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, const pm_string_t *unescaped, rb_encoding *implicit_regexp_encoding, rb_encoding *explicit_regexp_encoding)
+{
+ // If we were passed an explicit regexp encoding, then we need to double
+ // check that it's okay here for this fragment of the string.
+ rb_encoding *encoding;
+
+ if (explicit_regexp_encoding != NULL) {
+ encoding = explicit_regexp_encoding;
+ }
+ else if (node->flags & PM_STRING_FLAGS_FORCED_BINARY_ENCODING) {
+ encoding = rb_ascii8bit_encoding();
+ }
+ else if (node->flags & PM_STRING_FLAGS_FORCED_UTF8_ENCODING) {
+ encoding = rb_utf8_encoding();
+ }
+ else {
+ encoding = implicit_regexp_encoding;
+ }
+
+ VALUE string = rb_enc_str_new((const char *) pm_string_source(unescaped), pm_string_length(unescaped), encoding);
+ VALUE error = rb_reg_check_preprocess(string);
+
+ if (error != Qnil) parse_regexp_error(iseq, pm_node_line_number_cached(node, scope_node), "%" PRIsVALUE, rb_obj_as_string(error));
+ return string;
+}
+
+static VALUE
+pm_static_literal_concat(rb_iseq_t *iseq, const pm_node_list_t *nodes, pm_scope_node_t *scope_node, rb_encoding *implicit_regexp_encoding, rb_encoding *explicit_regexp_encoding, bool top)
+{
+ VALUE current = Qnil;
+
+ for (size_t index = 0; index < nodes->size; index++) {
+ const pm_node_t *part = nodes->nodes[index];
+ VALUE string;
+
+ switch (PM_NODE_TYPE(part)) {
+ case PM_STRING_NODE:
+ if (implicit_regexp_encoding != NULL) {
+ if (top) {
+ string = parse_regexp_string_part(iseq, scope_node, part, &((const pm_string_node_t *) part)->unescaped, implicit_regexp_encoding, explicit_regexp_encoding);
+ }
+ else {
+ string = parse_string_encoded(part, &((const pm_string_node_t *) part)->unescaped, scope_node->encoding);
+ VALUE error = rb_reg_check_preprocess(string);
+ if (error != Qnil) parse_regexp_error(iseq, pm_node_line_number_cached(part, scope_node), "%" PRIsVALUE, rb_obj_as_string(error));
+ }
+ }
+ else {
+ string = parse_string_encoded(part, &((const pm_string_node_t *) part)->unescaped, scope_node->encoding);
+ }
+ break;
+ case PM_INTERPOLATED_STRING_NODE:
+ string = pm_static_literal_concat(iseq, &((const pm_interpolated_string_node_t *) part)->parts, scope_node, implicit_regexp_encoding, explicit_regexp_encoding, false);
+ break;
+ case PM_EMBEDDED_STATEMENTS_NODE: {
+ const pm_embedded_statements_node_t *cast = (const pm_embedded_statements_node_t *) part;
+ string = pm_static_literal_concat(iseq, &cast->statements->body, scope_node, implicit_regexp_encoding, explicit_regexp_encoding, false);
+ break;
+ }
+ default:
+ RUBY_ASSERT(false && "unexpected node type in pm_static_literal_concat");
+ return Qnil;
+ }
+
+ if (current != Qnil) {
+ current = rb_str_concat(current, string);
+ }
+ else {
+ current = string;
+ }
+ }
+
+ return top ? rb_fstring(current) : current;
+}
+
+#define RE_OPTION_ENCODING_SHIFT 8
+#define RE_OPTION_ENCODING(encoding) (((encoding) & 0xFF) << RE_OPTION_ENCODING_SHIFT)
+#define ARG_ENCODING_NONE 32
+#define ARG_ENCODING_FIXED 16
+#define ENC_ASCII8BIT 1
+#define ENC_EUC_JP 2
+#define ENC_Windows_31J 3
+#define ENC_UTF8 4
+
+/**
+ * Check the prism flags of a regular expression-like node and return the flags
+ * that are expected by the CRuby VM.
+ */
+static int
+parse_regexp_flags(const pm_node_t *node)
+{
+ int flags = 0;
+
+ // Check "no encoding" first so that flags don't get clobbered
+ // We're calling `rb_char_to_option_kcode` in this case so that
+ // we don't need to have access to `ARG_ENCODING_NONE`
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT)) {
+ flags |= ARG_ENCODING_NONE;
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EUC_JP)) {
+ flags |= (ARG_ENCODING_FIXED | RE_OPTION_ENCODING(ENC_EUC_JP));
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J)) {
+ flags |= (ARG_ENCODING_FIXED | RE_OPTION_ENCODING(ENC_Windows_31J));
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_UTF_8)) {
+ flags |= (ARG_ENCODING_FIXED | RE_OPTION_ENCODING(ENC_UTF8));
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE)) {
+ flags |= ONIG_OPTION_IGNORECASE;
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_MULTI_LINE)) {
+ flags |= ONIG_OPTION_MULTILINE;
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EXTENDED)) {
+ flags |= ONIG_OPTION_EXTEND;
+ }
+
+ return flags;
+}
+
+#undef RE_OPTION_ENCODING_SHIFT
+#undef RE_OPTION_ENCODING
+#undef ARG_ENCODING_FIXED
+#undef ARG_ENCODING_NONE
+#undef ENC_ASCII8BIT
+#undef ENC_EUC_JP
+#undef ENC_Windows_31J
+#undef ENC_UTF8
+
+static rb_encoding *
+parse_regexp_encoding(const pm_scope_node_t *scope_node, const pm_node_t *node)
+{
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_FORCED_BINARY_ENCODING) || PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT)) {
+ return rb_ascii8bit_encoding();
+ }
+ else if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_UTF_8)) {
+ return rb_utf8_encoding();
+ }
+ else if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_EUC_JP)) {
+ return rb_enc_get_from_index(ENCINDEX_EUC_JP);
+ }
+ else if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J)) {
+ return rb_enc_get_from_index(ENCINDEX_Windows_31J);
+ }
+ else {
+ return NULL;
+ }
+}
+
+static VALUE
+parse_regexp(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, VALUE string)
+{
+ VALUE errinfo = rb_errinfo();
+
+ int32_t line_number = pm_node_line_number_cached(node, scope_node);
+ VALUE regexp = rb_reg_compile(string, parse_regexp_flags(node), (const char *) pm_string_source(pm_parser_filepath(scope_node->parser)), line_number);
+
+ if (NIL_P(regexp)) {
+ VALUE message = rb_attr_get(rb_errinfo(), idMesg);
+ rb_set_errinfo(errinfo);
+
+ parse_regexp_error(iseq, line_number, "%" PRIsVALUE, message);
+ return Qnil;
+ }
+
+ return RB_OBJ_SET_SHAREABLE(rb_obj_freeze(regexp));
+}
+
+static inline VALUE
+parse_regexp_literal(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, const pm_string_t *unescaped)
+{
+ rb_encoding *regexp_encoding = parse_regexp_encoding(scope_node, node);
+ if (regexp_encoding == NULL) regexp_encoding = scope_node->encoding;
+
+ VALUE string = rb_enc_str_new((const char *) pm_string_source(unescaped), pm_string_length(unescaped), regexp_encoding);
+ RB_OBJ_SET_SHAREABLE(string);
+ return parse_regexp(iseq, scope_node, node, string);
+}
+
+static inline VALUE
+parse_regexp_concat(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, const pm_node_list_t *parts)
+{
+ rb_encoding *explicit_regexp_encoding = parse_regexp_encoding(scope_node, node);
+ rb_encoding *implicit_regexp_encoding = explicit_regexp_encoding != NULL ? explicit_regexp_encoding : scope_node->encoding;
+
+ VALUE string = pm_static_literal_concat(iseq, parts, scope_node, implicit_regexp_encoding, explicit_regexp_encoding, false);
+ return parse_regexp(iseq, scope_node, node, string);
+}
+
+static void pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node);
+
+static int
+pm_interpolated_node_compile(rb_iseq_t *iseq, const pm_node_list_t *parts, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, rb_encoding *implicit_regexp_encoding, rb_encoding *explicit_regexp_encoding, bool mutable_result, bool frozen_result)
+{
+ int stack_size = 0;
+ size_t parts_size = parts->size;
+ bool interpolated = false;
+
+ if (parts_size > 0) {
+ VALUE current_string = Qnil;
+ pm_node_location_t current_location = *node_location;
+
+ for (size_t index = 0; index < parts_size; index++) {
+ const pm_node_t *part = parts->nodes[index];
+
+ if (PM_NODE_TYPE_P(part, PM_STRING_NODE)) {
+ const pm_string_node_t *string_node = (const pm_string_node_t *) part;
+ VALUE string_value;
+
+ if (implicit_regexp_encoding == NULL) {
+ string_value = parse_string_encoded(part, &string_node->unescaped, scope_node->encoding);
+ }
+ else {
+ string_value = parse_regexp_string_part(iseq, scope_node, (const pm_node_t *) string_node, &string_node->unescaped, implicit_regexp_encoding, explicit_regexp_encoding);
+ }
+
+ if (RTEST(current_string)) {
+ current_string = rb_str_concat(current_string, string_value);
+ }
+ else {
+ current_string = string_value;
+ if (index != 0) current_location = PM_NODE_END_LOCATION(part);
+ }
+ }
+ else {
+ interpolated = true;
+
+ if (
+ PM_NODE_TYPE_P(part, PM_EMBEDDED_STATEMENTS_NODE) &&
+ ((const pm_embedded_statements_node_t *) part)->statements != NULL &&
+ ((const pm_embedded_statements_node_t *) part)->statements->body.size == 1 &&
+ PM_NODE_TYPE_P(((const pm_embedded_statements_node_t *) part)->statements->body.nodes[0], PM_STRING_NODE)
+ ) {
+ const pm_string_node_t *string_node = (const pm_string_node_t *) ((const pm_embedded_statements_node_t *) part)->statements->body.nodes[0];
+ VALUE string_value;
+
+ if (implicit_regexp_encoding == NULL) {
+ string_value = parse_string_encoded(part, &string_node->unescaped, scope_node->encoding);
+ }
+ else {
+ string_value = parse_regexp_string_part(iseq, scope_node, (const pm_node_t *) string_node, &string_node->unescaped, implicit_regexp_encoding, explicit_regexp_encoding);
+ }
+
+ if (RTEST(current_string)) {
+ current_string = rb_str_concat(current_string, string_value);
+ }
+ else {
+ current_string = string_value;
+ current_location = PM_NODE_START_LOCATION(part);
+ }
+ }
+ else {
+ if (!RTEST(current_string)) {
+ rb_encoding *encoding;
+
+ if (implicit_regexp_encoding != NULL) {
+ if (explicit_regexp_encoding != NULL) {
+ encoding = explicit_regexp_encoding;
+ }
+ else if (pm_parser_encoding_us_ascii(scope_node->parser)) {
+ encoding = rb_ascii8bit_encoding();
+ }
+ else {
+ encoding = implicit_regexp_encoding;
+ }
+ }
+ else {
+ encoding = scope_node->encoding;
+ }
+
+ if (parts_size == 1) {
+ current_string = rb_enc_str_new(NULL, 0, encoding);
+ }
+ }
+
+ if (RTEST(current_string)) {
+ VALUE operand = rb_fstring(current_string);
+ PUSH_INSN1(ret, current_location, putobject, operand);
+ stack_size++;
+ }
+
+ PM_COMPILE_NOT_POPPED(part);
+
+ const pm_node_location_t current_location = PM_NODE_START_LOCATION(part);
+ PUSH_INSN(ret, current_location, dup);
+
+ {
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, idTo_s, 0, VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE, NULL, FALSE);
+ PUSH_INSN1(ret, current_location, objtostring, callinfo);
+ }
+
+ PUSH_INSN(ret, current_location, anytostring);
+
+ current_string = Qnil;
+ stack_size++;
+ }
+ }
+ }
+
+ if (RTEST(current_string)) {
+ current_string = rb_fstring(current_string);
+
+ if (stack_size == 0) {
+ if (frozen_result) {
+ PUSH_INSN1(ret, current_location, putobject, current_string);
+ } else if (mutable_result || interpolated) {
+ PUSH_INSN1(ret, current_location, dupstring, current_string);
+ } else {
+ PUSH_INSN1(ret, current_location, dupchilledstring, current_string);
+ }
+ } else {
+ PUSH_INSN1(ret, current_location, putobject, current_string);
+ }
+
+ current_string = Qnil;
+ stack_size++;
+ }
+ }
+ else {
+ PUSH_INSN(ret, *node_location, putnil);
+ }
+
+ return stack_size;
+}
+
+static void
+pm_compile_regexp_dynamic(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_list_t *parts, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ rb_encoding *explicit_regexp_encoding = parse_regexp_encoding(scope_node, node);
+ rb_encoding *implicit_regexp_encoding = explicit_regexp_encoding != NULL ? explicit_regexp_encoding : scope_node->encoding;
+
+ int length = pm_interpolated_node_compile(iseq, parts, node_location, ret, popped, scope_node, implicit_regexp_encoding, explicit_regexp_encoding, false, false);
+ PUSH_INSN2(ret, *node_location, toregexp, INT2FIX(parse_regexp_flags(node) & 0xFF), INT2FIX(length));
+}
+
+static VALUE
+pm_source_file_value(const pm_source_file_node_t *node, const pm_scope_node_t *scope_node)
+{
+ const pm_string_t *filepath = &node->filepath;
+ size_t length = pm_string_length(filepath);
+
+ if (length > 0) {
+ rb_encoding *filepath_encoding = scope_node->filepath_encoding != NULL ? scope_node->filepath_encoding : rb_utf8_encoding();
+ return rb_enc_interned_str((const char *) pm_string_source(filepath), length, filepath_encoding);
+ }
+ else {
+ return rb_fstring_lit("<compiled>");
+ }
+}
+
+/**
+ * Return a static literal string, optionally with attached debugging
+ * information.
+ */
+static VALUE
+pm_static_literal_string(rb_iseq_t *iseq, VALUE string, int line_number)
+{
+ if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
+ VALUE str = rb_str_with_debug_created_info(string, rb_iseq_path(iseq), line_number);
+ RB_OBJ_SET_SHAREABLE(str);
+ return str;
+ }
+ else {
+ return rb_fstring(string);
+ }
+}
+
+/**
+ * Certain nodes can be compiled literally. This function returns the literal
+ * value described by the given node. For example, an array node with all static
+ * literal values can be compiled into a literal array.
+ */
+static VALUE
+pm_static_literal_value(rb_iseq_t *iseq, const pm_node_t *node, pm_scope_node_t *scope_node)
+{
+ // Every node that comes into this function should already be marked as
+ // static literal. If it's not, then we have a bug somewhere.
+ RUBY_ASSERT(PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL));
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ARRAY_NODE: {
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+ const pm_node_list_t *elements = &cast->elements;
+
+ VALUE value = rb_ary_hidden_new(elements->size);
+ for (size_t index = 0; index < elements->size; index++) {
+ rb_ary_push(value, pm_static_literal_value(iseq, elements->nodes[index], scope_node));
+ }
+
+ RB_OBJ_SET_FROZEN_SHAREABLE(value);
+ return value;
+ }
+ case PM_FALSE_NODE:
+ return Qfalse;
+ case PM_FLOAT_NODE:
+ return parse_float((const pm_float_node_t *) node);
+ case PM_HASH_NODE: {
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+ const pm_node_list_t *elements = &cast->elements;
+
+ VALUE array = rb_ary_hidden_new(elements->size * 2);
+ for (size_t index = 0; index < elements->size; index++) {
+ RUBY_ASSERT(PM_NODE_TYPE_P(elements->nodes[index], PM_ASSOC_NODE));
+ const pm_assoc_node_t *cast = (const pm_assoc_node_t *) elements->nodes[index];
+ VALUE pair[2] = { pm_static_literal_value(iseq, cast->key, scope_node), pm_static_literal_value(iseq, cast->value, scope_node) };
+ rb_ary_cat(array, pair, 2);
+ }
+
+ VALUE value = rb_hash_alloc_fixed_size(Qfalse, elements->size);
+ rb_hash_bulk_insert(RARRAY_LEN(array), RARRAY_CONST_PTR(array), value);
+ RB_GC_GUARD(array);
+
+ RB_OBJ_SET_FROZEN_SHAREABLE(value);
+ return value;
+ }
+ case PM_IMAGINARY_NODE:
+ return parse_imaginary((const pm_imaginary_node_t *) node);
+ case PM_INTEGER_NODE:
+ return parse_integer((const pm_integer_node_t *) node);
+ case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: {
+ const pm_interpolated_match_last_line_node_t *cast = (const pm_interpolated_match_last_line_node_t *) node;
+ return parse_regexp_concat(iseq, scope_node, (const pm_node_t *) cast, &cast->parts);
+ }
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
+ const pm_interpolated_regular_expression_node_t *cast = (const pm_interpolated_regular_expression_node_t *) node;
+ return parse_regexp_concat(iseq, scope_node, (const pm_node_t *) cast, &cast->parts);
+ }
+ case PM_INTERPOLATED_STRING_NODE: {
+ VALUE string = pm_static_literal_concat(iseq, &((const pm_interpolated_string_node_t *) node)->parts, scope_node, NULL, NULL, false);
+ int line_number = pm_node_line_number_cached(node, scope_node);
+ return pm_static_literal_string(iseq, string, line_number);
+ }
+ case PM_INTERPOLATED_SYMBOL_NODE: {
+ const pm_interpolated_symbol_node_t *cast = (const pm_interpolated_symbol_node_t *) node;
+ VALUE string = pm_static_literal_concat(iseq, &cast->parts, scope_node, NULL, NULL, true);
+
+ return ID2SYM(rb_intern_str(string));
+ }
+ case PM_MATCH_LAST_LINE_NODE: {
+ const pm_match_last_line_node_t *cast = (const pm_match_last_line_node_t *) node;
+ return parse_regexp_literal(iseq, scope_node, (const pm_node_t *) cast, &cast->unescaped);
+ }
+ case PM_NIL_NODE:
+ return Qnil;
+ case PM_RATIONAL_NODE:
+ return parse_rational((const pm_rational_node_t *) node);
+ case PM_REGULAR_EXPRESSION_NODE: {
+ const pm_regular_expression_node_t *cast = (const pm_regular_expression_node_t *) node;
+ return parse_regexp_literal(iseq, scope_node, (const pm_node_t *) cast, &cast->unescaped);
+ }
+ case PM_SOURCE_ENCODING_NODE:
+ return rb_enc_from_encoding(scope_node->encoding);
+ case PM_SOURCE_FILE_NODE: {
+ const pm_source_file_node_t *cast = (const pm_source_file_node_t *) node;
+ return pm_source_file_value(cast, scope_node);
+ }
+ case PM_SOURCE_LINE_NODE:
+ return INT2FIX(pm_node_line_number_cached(node, scope_node));
+ case PM_STRING_NODE: {
+ const pm_string_node_t *cast = (const pm_string_node_t *) node;
+ return parse_static_literal_string(iseq, scope_node, node, &cast->unescaped);
+ }
+ case PM_SYMBOL_NODE:
+ return ID2SYM(parse_string_symbol(scope_node, (const pm_symbol_node_t *) node));
+ case PM_TRUE_NODE:
+ return Qtrue;
+ default:
+ rb_bug("Don't have a literal value for node type %s", pm_node_type(PM_NODE_TYPE(node)));
+ return Qfalse;
+ }
+}
+
+/**
+ * A helper for converting a pm_location_t into a rb_code_location_t.
+ */
+static rb_code_location_t
+pm_code_location(pm_scope_node_t *scope_node, const pm_node_t *node)
+{
+ const pm_line_column_t start_location = PM_NODE_START_LINE_COLUMN(node);
+ const pm_line_column_t end_location = PM_NODE_END_LINE_COLUMN(node);
+
+ return (rb_code_location_t) {
+ .beg_pos = { .lineno = start_location.line, .column = start_location.column },
+ .end_pos = { .lineno = end_location.line, .column = end_location.column }
+ };
+}
+
+/**
+ * A macro for determining if we should go through the work of adding branch
+ * coverage to the current iseq. We check this manually each time because we
+ * want to avoid the overhead of creating rb_code_location_t objects.
+ */
+#define PM_BRANCH_COVERAGE_P(iseq) (ISEQ_COVERAGE(iseq) && ISEQ_BRANCH_COVERAGE(iseq))
+
+static void
+pm_compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const pm_node_t *cond,
+ LABEL *then_label, LABEL *else_label, pm_scope_node_t *scope_node);
+
+static void
+pm_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_node_t *cond, LABEL *then_label, LABEL *else_label, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(cond);
+
+ DECL_ANCHOR(seq);
+
+ LABEL *label = NEW_LABEL(location.line);
+ if (!then_label) then_label = label;
+ else if (!else_label) else_label = label;
+
+ pm_compile_branch_condition(iseq, seq, cond, then_label, else_label, scope_node);
+
+ if (LIST_INSN_SIZE_ONE(seq)) {
+ INSN *insn = (INSN *) ELEM_FIRST_INSN(FIRST_ELEMENT(seq));
+ if (insn->insn_id == BIN(jump) && (LABEL *)(insn->operands[0]) == label) return;
+ }
+
+ if (label->refcnt) {
+ PUSH_LABEL(seq, label);
+ }
+
+ PUSH_SEQ(ret, seq);
+ return;
+}
+
+static void
+pm_compile_flip_flop_bound(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ if (PM_NODE_TYPE_P(node, PM_INTEGER_NODE)) {
+ PM_COMPILE_NOT_POPPED(node);
+
+ VALUE operand = ID2SYM(rb_intern("$."));
+ PUSH_INSN1(ret, location, getglobal, operand);
+
+ PUSH_SEND(ret, location, idEq, INT2FIX(1));
+ if (popped) PUSH_INSN(ret, location, pop);
+ }
+ else {
+ PM_COMPILE(node);
+ }
+}
+
+static void
+pm_compile_flip_flop(const pm_flip_flop_node_t *flip_flop_node, LABEL *else_label, LABEL *then_label, rb_iseq_t *iseq, const int lineno, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = { .line = lineno, .node_id = -1 };
+ LABEL *lend = NEW_LABEL(location.line);
+
+ int again = !(flip_flop_node->base.flags & PM_RANGE_FLAGS_EXCLUDE_END);
+
+ rb_num_t count = ISEQ_FLIP_CNT_INCREMENT(ISEQ_BODY(iseq)->local_iseq) + VM_SVAR_FLIPFLOP_START;
+ VALUE key = INT2FIX(count);
+
+ PUSH_INSN2(ret, location, getspecial, key, INT2FIX(0));
+ PUSH_INSNL(ret, location, branchif, lend);
+
+ if (flip_flop_node->left) {
+ pm_compile_flip_flop_bound(iseq, flip_flop_node->left, ret, popped, scope_node);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ PUSH_INSNL(ret, location, branchunless, else_label);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, setspecial, key);
+ if (!again) {
+ PUSH_INSNL(ret, location, jump, then_label);
+ }
+
+ PUSH_LABEL(ret, lend);
+ if (flip_flop_node->right) {
+ pm_compile_flip_flop_bound(iseq, flip_flop_node->right, ret, popped, scope_node);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ PUSH_INSNL(ret, location, branchunless, then_label);
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setspecial, key);
+ PUSH_INSNL(ret, location, jump, then_label);
+}
+
+static void pm_compile_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition);
+
+static void
+pm_compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const pm_node_t *cond, LABEL *then_label, LABEL *else_label, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(cond);
+
+again:
+ switch (PM_NODE_TYPE(cond)) {
+ case PM_AND_NODE: {
+ const pm_and_node_t *cast = (const pm_and_node_t *) cond;
+ pm_compile_logical(iseq, ret, cast->left, NULL, else_label, scope_node);
+
+ cond = cast->right;
+ goto again;
+ }
+ case PM_OR_NODE: {
+ const pm_or_node_t *cast = (const pm_or_node_t *) cond;
+ pm_compile_logical(iseq, ret, cast->left, then_label, NULL, scope_node);
+
+ cond = cast->right;
+ goto again;
+ }
+ case PM_FALSE_NODE:
+ case PM_NIL_NODE:
+ PUSH_INSNL(ret, location, jump, else_label);
+ return;
+ case PM_FLOAT_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INTEGER_NODE:
+ case PM_LAMBDA_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_TRUE_NODE:
+ PUSH_INSNL(ret, location, jump, then_label);
+ return;
+ case PM_FLIP_FLOP_NODE:
+ pm_compile_flip_flop((const pm_flip_flop_node_t *) cond, else_label, then_label, iseq, location.line, ret, false, scope_node);
+ return;
+ case PM_DEFINED_NODE: {
+ const pm_defined_node_t *cast = (const pm_defined_node_t *) cond;
+ pm_compile_defined_expr(iseq, cast->value, &location, ret, false, scope_node, true);
+ break;
+ }
+ default: {
+ DECL_ANCHOR(cond_seq);
+ pm_compile_node(iseq, cond, cond_seq, false, scope_node);
+
+ if (LIST_INSN_SIZE_ONE(cond_seq)) {
+ INSN *insn = (INSN *) ELEM_FIRST_INSN(FIRST_ELEMENT(cond_seq));
+
+ if (insn->insn_id == BIN(putobject)) {
+ if (RTEST(insn->operands[0])) {
+ PUSH_INSNL(ret, location, jump, then_label);
+ // maybe unreachable
+ return;
+ }
+ else {
+ PUSH_INSNL(ret, location, jump, else_label);
+ return;
+ }
+ }
+ }
+
+ PUSH_SEQ(ret, cond_seq);
+ break;
+ }
+ }
+
+ PUSH_INSNL(ret, location, branchunless, else_label);
+ PUSH_INSNL(ret, location, jump, then_label);
+}
+
+/**
+ * Compile an if or unless node.
+ */
+static void
+pm_compile_conditional(rb_iseq_t *iseq, const pm_node_location_t *node_location, pm_node_type_t type, const pm_node_t *node, const pm_statements_node_t *statements, const pm_node_t *subsequent, const pm_node_t *predicate, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ LABEL *then_label = NEW_LABEL(location.line);
+ LABEL *else_label = NEW_LABEL(location.line);
+ LABEL *end_label = NULL;
+
+ DECL_ANCHOR(cond_seq);
+ pm_compile_branch_condition(iseq, cond_seq, predicate, then_label, else_label, scope_node);
+ PUSH_SEQ(ret, cond_seq);
+
+ rb_code_location_t conditional_location = { 0 };
+ VALUE branches = Qfalse;
+
+ if (then_label->refcnt && else_label->refcnt && PM_BRANCH_COVERAGE_P(iseq)) {
+ conditional_location = pm_code_location(scope_node, node);
+ branches = decl_branch_base(iseq, PTR2NUM(node), &conditional_location, type == PM_IF_NODE ? "if" : "unless");
+ }
+
+ if (then_label->refcnt) {
+ PUSH_LABEL(ret, then_label);
+
+ DECL_ANCHOR(then_seq);
+
+ if (statements != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) statements, then_seq, popped, scope_node);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(then_seq, iseq);
+ }
+
+ if (else_label->refcnt) {
+ // Establish branch coverage for the then block.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location;
+
+ if (statements != NULL) {
+ branch_location = pm_code_location(scope_node, (const pm_node_t *) statements);
+ } else if (type == PM_IF_NODE) {
+ pm_line_column_t predicate_end = PM_NODE_END_LINE_COLUMN(predicate);
+ branch_location = (rb_code_location_t) {
+ .beg_pos = { .lineno = predicate_end.line, .column = predicate_end.column },
+ .end_pos = { .lineno = predicate_end.line, .column = predicate_end.column }
+ };
+ } else {
+ branch_location = conditional_location;
+ }
+
+ add_trace_branch_coverage(iseq, ret, &branch_location, branch_location.beg_pos.column, 0, type == PM_IF_NODE ? "then" : "else", branches);
+ }
+
+ end_label = NEW_LABEL(location.line);
+ PUSH_INSNL(then_seq, location, jump, end_label);
+ if (!popped) PUSH_INSN(then_seq, location, pop);
+ }
+
+ PUSH_SEQ(ret, then_seq);
+ }
+
+ if (else_label->refcnt) {
+ PUSH_LABEL(ret, else_label);
+
+ DECL_ANCHOR(else_seq);
+
+ if (subsequent != NULL) {
+ pm_compile_node(iseq, subsequent, else_seq, popped, scope_node);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(else_seq, iseq);
+ }
+
+ // Establish branch coverage for the else block.
+ if (then_label->refcnt && PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location;
+
+ if (subsequent == NULL) {
+ branch_location = conditional_location;
+ } else if (PM_NODE_TYPE_P(subsequent, PM_ELSE_NODE)) {
+ const pm_else_node_t *else_node = (const pm_else_node_t *) subsequent;
+ branch_location = pm_code_location(scope_node, else_node->statements != NULL ? ((const pm_node_t *) else_node->statements) : (const pm_node_t *) else_node);
+ } else {
+ branch_location = pm_code_location(scope_node, (const pm_node_t *) subsequent);
+ }
+
+ add_trace_branch_coverage(iseq, ret, &branch_location, branch_location.beg_pos.column, 1, type == PM_IF_NODE ? "else" : "then", branches);
+ }
+
+ PUSH_SEQ(ret, else_seq);
+ }
+
+ if (end_label) {
+ PUSH_LABEL(ret, end_label);
+ }
+
+ return;
+}
+
+/**
+ * Compile a while or until loop.
+ */
+static void
+pm_compile_loop(rb_iseq_t *iseq, const pm_node_location_t *node_location, pm_node_flags_t flags, enum pm_node_type type, const pm_node_t *node, const pm_statements_node_t *statements, const pm_node_t *predicate, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+
+ LABEL *prev_start_label = ISEQ_COMPILE_DATA(iseq)->start_label;
+ LABEL *prev_end_label = ISEQ_COMPILE_DATA(iseq)->end_label;
+ LABEL *prev_redo_label = ISEQ_COMPILE_DATA(iseq)->redo_label;
+
+ LABEL *next_label = ISEQ_COMPILE_DATA(iseq)->start_label = NEW_LABEL(location.line); /* next */
+ LABEL *redo_label = ISEQ_COMPILE_DATA(iseq)->redo_label = NEW_LABEL(location.line); /* redo */
+ LABEL *break_label = ISEQ_COMPILE_DATA(iseq)->end_label = NEW_LABEL(location.line); /* break */
+ LABEL *end_label = NEW_LABEL(location.line);
+ LABEL *adjust_label = NEW_LABEL(location.line);
+
+ LABEL *next_catch_label = NEW_LABEL(location.line);
+ LABEL *tmp_label = NULL;
+
+ // We're pushing onto the ensure stack because breaks need to break out of
+ // this loop and not break into the ensure statements within the same
+ // lexical scope.
+ struct iseq_compile_data_ensure_node_stack enl;
+ push_ensure_entry(iseq, &enl, NULL, NULL);
+
+ // begin; end while true
+ if (flags & PM_LOOP_FLAGS_BEGIN_MODIFIER) {
+ tmp_label = NEW_LABEL(location.line);
+ PUSH_INSNL(ret, location, jump, tmp_label);
+ }
+ else {
+ // while true; end
+ PUSH_INSNL(ret, location, jump, next_label);
+ }
+
+ PUSH_LABEL(ret, adjust_label);
+ PUSH_INSN(ret, location, putnil);
+ PUSH_LABEL(ret, next_catch_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, next_label);
+ if (tmp_label) PUSH_LABEL(ret, tmp_label);
+
+ PUSH_LABEL(ret, redo_label);
+
+ // Establish branch coverage for the loop.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t loop_location = pm_code_location(scope_node, node);
+ VALUE branches = decl_branch_base(iseq, PTR2NUM(node), &loop_location, type == PM_WHILE_NODE ? "while" : "until");
+
+ rb_code_location_t branch_location = statements != NULL ? pm_code_location(scope_node, (const pm_node_t *) statements) : loop_location;
+ add_trace_branch_coverage(iseq, ret, &branch_location, branch_location.beg_pos.column, 0, "body", branches);
+ }
+
+ if (statements != NULL) PM_COMPILE_POPPED((const pm_node_t *) statements);
+ PUSH_LABEL(ret, next_label);
+
+ if (type == PM_WHILE_NODE) {
+ pm_compile_branch_condition(iseq, ret, predicate, redo_label, end_label, scope_node);
+ }
+ else if (type == PM_UNTIL_NODE) {
+ pm_compile_branch_condition(iseq, ret, predicate, end_label, redo_label, scope_node);
+ }
+
+ PUSH_LABEL(ret, end_label);
+ PUSH_ADJUST_RESTORE(ret, adjust_label);
+ PUSH_INSN(ret, location, putnil);
+
+ PUSH_LABEL(ret, break_label);
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ PUSH_CATCH_ENTRY(CATCH_TYPE_BREAK, redo_label, break_label, NULL, break_label);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_NEXT, redo_label, break_label, NULL, next_catch_label);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_REDO, redo_label, break_label, NULL, ISEQ_COMPILE_DATA(iseq)->redo_label);
+
+ ISEQ_COMPILE_DATA(iseq)->start_label = prev_start_label;
+ ISEQ_COMPILE_DATA(iseq)->end_label = prev_end_label;
+ ISEQ_COMPILE_DATA(iseq)->redo_label = prev_redo_label;
+ ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = ISEQ_COMPILE_DATA(iseq)->ensure_node_stack->prev;
+
+ return;
+}
+
+// This recurses through scopes and finds the local index at any scope level
+// It also takes a pointer to depth, and increments depth appropriately
+// according to the depth of the local.
+static pm_local_index_t
+pm_lookup_local_index(rb_iseq_t *iseq, const pm_scope_node_t *scope_node, pm_constant_id_t constant_id, int start_depth)
+{
+ pm_local_index_t lindex = { 0 };
+ int local_index;
+
+ int level;
+ for (level = 0; level < start_depth; level++) {
+ scope_node = scope_node->previous;
+ }
+
+ while (!pm_index_lookup_table_lookup(&scope_node->index_lookup_table, constant_id, &local_index))
+ {
+ level++;
+
+ if (scope_node->previous) {
+ scope_node = scope_node->previous;
+ }
+ else {
+ // We have recursed up all scope nodes
+ // and have not found the local yet
+ rb_bug("Local with constant_id %u does not exist", (unsigned int) constant_id);
+ }
+ }
+
+ lindex.level = level;
+ lindex.index = scope_node->local_table_for_iseq_size - (int) local_index;
+ return lindex;
+}
+
+// This returns the CRuby ID which maps to the pm_constant_id_t
+//
+// Constant_ids in prism are indexes of the constants in prism's constant pool.
+// We add a constants mapping on the scope_node which is a mapping from
+// these constant_id indexes to the CRuby IDs that they represent.
+// This helper method allows easy access to those IDs
+static inline ID
+pm_constant_id_lookup(const pm_scope_node_t *scope_node, pm_constant_id_t constant_id)
+{
+ RUBY_ASSERT(constant_id >= 1 && constant_id <= pm_parser_constants_size(scope_node->parser));
+ return scope_node->constants[constant_id - 1];
+}
+
+static rb_iseq_t *
+pm_new_child_iseq(rb_iseq_t *iseq, pm_scope_node_t *node, VALUE name, const rb_iseq_t *parent, enum rb_iseq_type type, int line_no)
+{
+ debugs("[new_child_iseq]> ---------------------------------------\n");
+ int isolated_depth = ISEQ_COMPILE_DATA(iseq)->isolated_depth;
+ rb_iseq_t *ret_iseq = pm_iseq_build(node, name,
+ rb_iseq_path(iseq), rb_iseq_realpath(iseq),
+ line_no, parent,
+ isolated_depth ? isolated_depth + 1 : 0,
+ type, ISEQ_COMPILE_DATA(iseq)->option);
+ debugs("[new_child_iseq]< ---------------------------------------\n");
+ return ret_iseq;
+}
+
+static int
+pm_cpath_const_p(const pm_node_t *node)
+{
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CONSTANT_READ_NODE:
+ return TRUE;
+ case PM_CONSTANT_PATH_NODE:
+ {
+ const pm_node_t *parent = ((const pm_constant_path_node_t *) node)->parent;
+ if (!parent) return TRUE; /* ::Foo */
+ return pm_cpath_const_p(parent);
+ }
+ default:
+ return FALSE;
+ }
+}
+
+static int
+pm_compile_class_path(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ if (PM_NODE_TYPE_P(node, PM_CONSTANT_PATH_NODE)) {
+ const pm_node_t *parent = ((const pm_constant_path_node_t *) node)->parent;
+
+ if (parent) {
+ /* Bar::Foo or expr::Foo */
+ PM_COMPILE(parent);
+ int flags = VM_DEFINECLASS_FLAG_SCOPED;
+ if (!pm_cpath_const_p(parent)) {
+ flags |= VM_DEFINECLASS_FLAG_DYNAMIC_CREF;
+ }
+ return flags;
+ }
+ else {
+ /* toplevel class ::Foo */
+ PUSH_INSN1(ret, *node_location, putobject, rb_cObject);
+ return VM_DEFINECLASS_FLAG_SCOPED;
+ }
+ }
+ else {
+ /* class at cbase Foo */
+ PUSH_INSN1(ret, *node_location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+ return 0;
+ }
+}
+
+/**
+ * Compile either a call and write node or a call or write node. These look like
+ * method calls that are followed by a ||= or &&= operator.
+ */
+static void
+pm_compile_call_and_or_write_node(rb_iseq_t *iseq, bool and_node, const pm_node_t *receiver, const pm_node_t *value, pm_constant_id_t write_name, pm_constant_id_t read_name, bool safe_nav, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ LABEL *lfin = NEW_LABEL(location.line);
+ LABEL *lcfin = NEW_LABEL(location.line);
+ LABEL *lskip = NULL;
+
+ int flag = PM_NODE_TYPE_P(receiver, PM_SELF_NODE) ? VM_CALL_FCALL : 0;
+ ID id_read_name = pm_constant_id_lookup(scope_node, read_name);
+
+ PM_COMPILE_NOT_POPPED(receiver);
+ if (safe_nav) {
+ lskip = NEW_LABEL(location.line);
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchnil, lskip);
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND_WITH_FLAG(ret, location, id_read_name, INT2FIX(0), INT2FIX(flag));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ if (and_node) {
+ PUSH_INSNL(ret, location, branchunless, lcfin);
+ }
+ else {
+ PUSH_INSNL(ret, location, branchif, lcfin);
+ }
+
+ if (!popped) PUSH_INSN(ret, location, pop);
+ PM_COMPILE_NOT_POPPED(value);
+
+ if (!popped) {
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ }
+
+ ID id_write_name = pm_constant_id_lookup(scope_node, write_name);
+ PUSH_SEND_WITH_FLAG(ret, location, id_write_name, INT2FIX(1), INT2FIX(flag));
+ PUSH_INSNL(ret, location, jump, lfin);
+
+ PUSH_LABEL(ret, lcfin);
+ if (!popped) PUSH_INSN(ret, location, swap);
+
+ PUSH_LABEL(ret, lfin);
+
+ if (lskip && popped) PUSH_LABEL(ret, lskip);
+ PUSH_INSN(ret, location, pop);
+ if (lskip && !popped) PUSH_LABEL(ret, lskip);
+}
+
+static void pm_compile_shareable_constant_value(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_flags_t shareability, VALUE path, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, bool top);
+
+/**
+ * This function compiles a hash onto the stack. It is used to compile hash
+ * literals and keyword arguments. It is assumed that if we get here that the
+ * contents of the hash are not popped.
+ */
+static void
+pm_compile_hash_elements(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_list_t *elements, const pm_node_flags_t shareability, VALUE path, bool argument, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ // If this element is not popped, then we need to create the hash on the
+ // stack. Neighboring plain assoc nodes should be grouped together (either
+ // by newhash or hash merge). Double splat nodes should be merged using the
+ // merge_kwd method call.
+ const int max_stack_length = 0x100;
+ const unsigned int min_tmp_hash_length = 0x800;
+
+ int stack_length = 0;
+ bool first_chunk = true;
+
+ // This is an optimization wherein we keep track of whether or not the
+ // previous element was a static literal. If it was, then we do not attempt
+ // to check if we have a subhash that can be optimized. If it was not, then
+ // we do check.
+ bool static_literal = false;
+
+ DECL_ANCHOR(anchor);
+
+ // Convert pushed elements to a hash, and merge if needed.
+#define FLUSH_CHUNK \
+ if (stack_length) { \
+ if (first_chunk) { \
+ PUSH_SEQ(ret, anchor); \
+ PUSH_INSN1(ret, location, newhash, INT2FIX(stack_length)); \
+ first_chunk = false; \
+ } \
+ else { \
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); \
+ PUSH_INSN(ret, location, swap); \
+ PUSH_SEQ(ret, anchor); \
+ PUSH_SEND(ret, location, id_core_hash_merge_ptr, INT2FIX(stack_length + 1)); \
+ } \
+ INIT_ANCHOR(anchor); \
+ stack_length = 0; \
+ }
+
+ for (size_t index = 0; index < elements->size; index++) {
+ const pm_node_t *element = elements->nodes[index];
+
+ switch (PM_NODE_TYPE(element)) {
+ case PM_ASSOC_NODE: {
+ // Pre-allocation check (this branch can be omitted).
+ if (
+ (shareability == 0) &&
+ PM_NODE_FLAG_P(element, PM_NODE_FLAG_STATIC_LITERAL) && (
+ (!static_literal && ((index + min_tmp_hash_length) < elements->size)) ||
+ (first_chunk && stack_length == 0)
+ )
+ ) {
+ // Count the elements that are statically-known.
+ size_t count = 1;
+ while (index + count < elements->size && PM_NODE_FLAG_P(elements->nodes[index + count], PM_NODE_FLAG_STATIC_LITERAL)) count++;
+
+ if ((first_chunk && stack_length == 0) || count >= min_tmp_hash_length) {
+ // The subsequence of elements in this hash is long enough
+ // to merit its own hash.
+ VALUE ary = rb_ary_hidden_new(count);
+
+ // Create a hidden hash.
+ for (size_t tmp_end = index + count; index < tmp_end; index++) {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) elements->nodes[index];
+
+ VALUE elem[2] = {
+ pm_static_literal_value(iseq, assoc->key, scope_node),
+ pm_static_literal_value(iseq, assoc->value, scope_node)
+ };
+
+ rb_ary_cat(ary, elem, 2);
+ }
+ index --;
+
+ VALUE hash = rb_hash_alloc_fixed_size(Qfalse, RARRAY_LEN(ary) / 2);
+ rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary), hash);
+ RB_GC_GUARD(ary);
+ RB_OBJ_SET_FROZEN_SHAREABLE(hash);
+
+ // Emit optimized code.
+ FLUSH_CHUNK;
+ if (first_chunk) {
+ PUSH_INSN1(ret, location, duphash, hash);
+ first_chunk = false;
+ }
+ else {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, putobject, hash);
+ PUSH_SEND(ret, location, id_core_hash_merge_kwd, INT2FIX(2));
+ }
+
+ break;
+ }
+ else {
+ static_literal = true;
+ }
+ }
+ else {
+ static_literal = false;
+ }
+
+ // If this is a plain assoc node, then we can compile it directly
+ // and then add the total number of values on the stack.
+ if (shareability == 0) {
+ pm_compile_node(iseq, element, anchor, false, scope_node);
+ }
+ else {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) element;
+ pm_compile_shareable_constant_value(iseq, assoc->key, shareability, path, ret, scope_node, false);
+ pm_compile_shareable_constant_value(iseq, assoc->value, shareability, path, ret, scope_node, false);
+ }
+
+ if ((stack_length += 2) >= max_stack_length) FLUSH_CHUNK;
+ break;
+ }
+ case PM_ASSOC_SPLAT_NODE: {
+ FLUSH_CHUNK;
+
+ const pm_assoc_splat_node_t *assoc_splat = (const pm_assoc_splat_node_t *) element;
+ bool empty_hash = assoc_splat->value != NULL && (
+ (PM_NODE_TYPE_P(assoc_splat->value, PM_HASH_NODE) && ((const pm_hash_node_t *) assoc_splat->value)->elements.size == 0) ||
+ PM_NODE_TYPE_P(assoc_splat->value, PM_NIL_NODE)
+ );
+
+ bool first_element = first_chunk && stack_length == 0;
+ bool last_element = index == elements->size - 1;
+ bool only_element = first_element && last_element;
+
+ if (empty_hash) {
+ if (only_element && argument) {
+ // **{} appears at the only keyword argument in method call,
+ // so it won't be modified.
+ //
+ // This is only done for method calls and not for literal
+ // hashes, because literal hashes should always result in a
+ // new hash.
+ PUSH_INSN(ret, location, putnil);
+ }
+ else if (first_element) {
+ // **{} appears as the first keyword argument, so it may be
+ // modified. We need to create a fresh hash object.
+ PUSH_INSN1(ret, location, newhash, INT2FIX(0));
+ }
+ // Any empty keyword splats that are not the first can be
+ // ignored since merging an empty hash into the existing hash is
+ // the same as not merging it.
+ }
+ else {
+ if (only_element && argument) {
+ // ** is only keyword argument in the method call. Use it
+ // directly. This will be not be flagged as mutable. This is
+ // only done for method calls and not for literal hashes,
+ // because literal hashes should always result in a new
+ // hash.
+ if (shareability == 0) {
+ PM_COMPILE_NOT_POPPED(element);
+ }
+ else {
+ pm_compile_shareable_constant_value(iseq, element, shareability, path, ret, scope_node, false);
+ }
+ }
+ else {
+ // There is more than one keyword argument, or this is not a
+ // method call. In that case, we need to add an empty hash
+ // (if first keyword), or merge the hash to the accumulated
+ // hash (if not the first keyword).
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ if (first_element) {
+ PUSH_INSN1(ret, location, newhash, INT2FIX(0));
+ }
+ else {
+ PUSH_INSN(ret, location, swap);
+ }
+
+ if (shareability == 0) {
+ PM_COMPILE_NOT_POPPED(element);
+ }
+ else {
+ pm_compile_shareable_constant_value(iseq, element, shareability, path, ret, scope_node, false);
+ }
+
+ PUSH_SEND(ret, location, id_core_hash_merge_kwd, INT2FIX(2));
+ }
+ }
+
+ first_chunk = false;
+ static_literal = false;
+ break;
+ }
+ default:
+ RUBY_ASSERT("Invalid node type for hash" && false);
+ break;
+ }
+ }
+
+ FLUSH_CHUNK;
+#undef FLUSH_CHUNK
+}
+
+#define SPLATARRAY_FALSE 0
+#define SPLATARRAY_TRUE 1
+#define DUP_SINGLE_KW_SPLAT 2
+
+// This is details. Users should call pm_setup_args() instead.
+static int
+pm_setup_args_core(const pm_arguments_node_t *arguments_node, const pm_node_t *block, int *flags, const bool has_regular_blockarg, struct rb_callinfo_kwarg **kw_arg, int *dup_rest, rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, const pm_node_location_t *node_location)
+{
+ const pm_node_location_t location = *node_location;
+
+ int orig_argc = 0;
+ bool has_splat = false;
+ bool has_keyword_splat = false;
+
+ if (arguments_node == NULL) {
+ if (*flags & VM_CALL_FCALL) {
+ *flags |= VM_CALL_VCALL;
+ }
+ }
+ else {
+ const pm_node_list_t *arguments = &arguments_node->arguments;
+ has_keyword_splat = PM_NODE_FLAG_P(arguments_node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT);
+
+ // We count the number of elements post the splat node that are not keyword elements to
+ // eventually pass as an argument to newarray
+ int post_splat_counter = 0;
+ const pm_node_t *argument;
+
+ PM_NODE_LIST_FOREACH(arguments, index, argument) {
+ switch (PM_NODE_TYPE(argument)) {
+ // A keyword hash node contains all keyword arguments as AssocNodes and AssocSplatNodes
+ case PM_KEYWORD_HASH_NODE: {
+ const pm_keyword_hash_node_t *keyword_arg = (const pm_keyword_hash_node_t *) argument;
+ const pm_node_list_t *elements = &keyword_arg->elements;
+
+ if (has_keyword_splat || has_splat) {
+ *flags |= VM_CALL_KW_SPLAT;
+ has_keyword_splat = true;
+
+ if (elements->size > 1 || !(elements->size == 1 && PM_NODE_TYPE_P(elements->nodes[0], PM_ASSOC_SPLAT_NODE))) {
+ // A new hash will be created for the keyword arguments
+ // in this case, so mark the method as passing mutable
+ // keyword splat.
+ *flags |= VM_CALL_KW_SPLAT_MUT;
+ pm_compile_hash_elements(iseq, argument, elements, 0, Qundef, true, ret, scope_node);
+ }
+ else if (*dup_rest & DUP_SINGLE_KW_SPLAT) {
+ *flags |= VM_CALL_KW_SPLAT_MUT;
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, newhash, INT2FIX(0));
+ pm_compile_hash_elements(iseq, argument, elements, 0, Qundef, true, ret, scope_node);
+ PUSH_SEND(ret, location, id_core_hash_merge_kwd, INT2FIX(2));
+ }
+ else {
+ pm_compile_hash_elements(iseq, argument, elements, 0, Qundef, true, ret, scope_node);
+ }
+ }
+ else {
+ // We need to first figure out if all elements of the
+ // KeywordHashNode are AssocNodes with symbol keys.
+ if (PM_NODE_FLAG_P(keyword_arg, PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS)) {
+ // If they are all symbol keys then we can pass them as
+ // keyword arguments. The first thing we need to do is
+ // deduplicate. We'll do this using the combination of a
+ // Ruby hash and a Ruby array.
+ VALUE stored_indices = rb_hash_new();
+ VALUE keyword_indices = rb_ary_new_capa(elements->size);
+
+ size_t size = 0;
+ for (size_t element_index = 0; element_index < elements->size; element_index++) {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) elements->nodes[element_index];
+
+ // Retrieve the stored index from the hash for this
+ // keyword.
+ VALUE keyword = pm_static_literal_value(iseq, assoc->key, scope_node);
+ VALUE stored_index = rb_hash_aref(stored_indices, keyword);
+
+ // If this keyword was already seen in the hash,
+ // then mark the array at that index as false and
+ // decrement the keyword size.
+ if (!NIL_P(stored_index)) {
+ rb_ary_store(keyword_indices, NUM2LONG(stored_index), Qfalse);
+ size--;
+ }
+
+ // Store (and possibly overwrite) the index for this
+ // keyword in the hash, mark the array at that index
+ // as true, and increment the keyword size.
+ rb_hash_aset(stored_indices, keyword, ULONG2NUM(element_index));
+ rb_ary_store(keyword_indices, (long) element_index, Qtrue);
+ size++;
+ }
+
+ *kw_arg = rb_xmalloc_mul_add(size, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ *flags |= VM_CALL_KWARG;
+
+ VALUE *keywords = (*kw_arg)->keywords;
+ (*kw_arg)->references = 0;
+ (*kw_arg)->keyword_len = (int) size;
+
+ size_t keyword_index = 0;
+ for (size_t element_index = 0; element_index < elements->size; element_index++) {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) elements->nodes[element_index];
+ bool popped = true;
+
+ if (rb_ary_entry(keyword_indices, (long) element_index) == Qtrue) {
+ keywords[keyword_index++] = pm_static_literal_value(iseq, assoc->key, scope_node);
+ popped = false;
+ }
+
+ PM_COMPILE(assoc->value);
+ }
+
+ RUBY_ASSERT(keyword_index == size);
+ }
+ else {
+ // If they aren't all symbol keys then we need to
+ // construct a new hash and pass that as an argument.
+ orig_argc++;
+ *flags |= VM_CALL_KW_SPLAT;
+
+ size_t size = elements->size;
+ if (size > 1) {
+ // A new hash will be created for the keyword
+ // arguments in this case, so mark the method as
+ // passing mutable keyword splat.
+ *flags |= VM_CALL_KW_SPLAT_MUT;
+ }
+
+ for (size_t element_index = 0; element_index < size; element_index++) {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) elements->nodes[element_index];
+ PM_COMPILE_NOT_POPPED(assoc->key);
+ PM_COMPILE_NOT_POPPED(assoc->value);
+ }
+
+ PUSH_INSN1(ret, location, newhash, INT2FIX(size * 2));
+ }
+ }
+ break;
+ }
+ case PM_SPLAT_NODE: {
+ *flags |= VM_CALL_ARGS_SPLAT;
+ const pm_splat_node_t *splat_node = (const pm_splat_node_t *) argument;
+
+ if (splat_node->expression) {
+ PM_COMPILE_NOT_POPPED(splat_node->expression);
+ }
+ else {
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_MULT, 0);
+ PUSH_GETLOCAL(ret, location, index.index, index.level);
+ }
+
+ bool first_splat = !has_splat;
+
+ if (first_splat) {
+ // If this is the first splat array seen and it's not the
+ // last parameter, we want splatarray to dup it.
+ //
+ // foo(a, *b, c)
+ // ^^
+ if (index + 1 < arguments->size || has_regular_blockarg) {
+ PUSH_INSN1(ret, location, splatarray, (*dup_rest & SPLATARRAY_TRUE) ? Qtrue : Qfalse);
+ if (*dup_rest & SPLATARRAY_TRUE) *dup_rest &= ~SPLATARRAY_TRUE;
+ }
+ // If this is the first spalt array seen and it's the last
+ // parameter, we don't want splatarray to dup it.
+ //
+ // foo(a, *b)
+ // ^^
+ else {
+ PUSH_INSN1(ret, location, splatarray, Qfalse);
+ }
+ }
+ else {
+ // If this is not the first splat array seen and it is also
+ // the last parameter, we don't want splatarray to dup it
+ // and we need to concat the array.
+ //
+ // foo(a, *b, *c)
+ // ^^
+ PUSH_INSN(ret, location, concattoarray);
+ }
+
+ has_splat = true;
+ post_splat_counter = 0;
+
+ break;
+ }
+ case PM_FORWARDING_ARGUMENTS_NODE: { // not counted in argc return value
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+
+ if (ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->param.flags.forwardable) {
+ *flags |= VM_CALL_FORWARDING;
+
+ pm_local_index_t mult_local = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_DOT3, 0);
+ PUSH_GETLOCAL(ret, location, mult_local.index, mult_local.level);
+
+ break;
+ }
+
+ if (has_splat) {
+ // If we already have a splat, we're concatenating to existing array
+ orig_argc += 1;
+ } else {
+ orig_argc += 2;
+ }
+
+ *flags |= VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG | VM_CALL_KW_SPLAT;
+
+ // Forwarding arguments nodes are treated as foo(*, **, &)
+ // So foo(...) equals foo(*, **, &) and as such the local
+ // table for this method is known in advance
+ //
+ // Push the *
+ pm_local_index_t mult_local = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_MULT, 0);
+ PUSH_GETLOCAL(ret, location, mult_local.index, mult_local.level);
+
+ if (has_splat) {
+ // If we already have a splat, we need to concatenate arrays
+ PUSH_INSN(ret, location, concattoarray);
+ } else {
+ PUSH_INSN1(ret, location, splatarray, Qfalse);
+ }
+
+ // Push the **
+ pm_local_index_t pow_local = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_POW, 0);
+ PUSH_GETLOCAL(ret, location, pow_local.index, pow_local.level);
+
+ // Push the &
+ pm_local_index_t and_local = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_AND, 0);
+ PUSH_INSN2(ret, location, getblockparamproxy, INT2FIX(and_local.index + VM_ENV_DATA_SIZE - 1), INT2FIX(and_local.level));
+
+ break;
+ }
+ default: {
+ post_splat_counter++;
+ PM_COMPILE_NOT_POPPED(argument);
+
+ // If we have a splat and we've seen a splat, we need to process
+ // everything after the splat.
+ if (has_splat) {
+ // Stack items are turned into an array and concatenated in
+ // the following cases:
+ //
+ // If the next node is a splat:
+ //
+ // foo(*a, b, *c)
+ //
+ // If the next node is a kwarg or kwarg splat:
+ //
+ // foo(*a, b, c: :d)
+ // foo(*a, b, **c)
+ //
+ // If the next node is a forwarding argument:
+ //
+ // foo(*a, b, ...)
+ //
+ // If the next node is NULL (we have hit the end):
+ //
+ // foo(*a, b)
+ if (index == arguments->size - 1) {
+ RUBY_ASSERT(post_splat_counter > 0);
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(post_splat_counter));
+ }
+ else {
+ pm_node_t *next_arg = arguments->nodes[index + 1];
+
+ switch (PM_NODE_TYPE(next_arg)) {
+ // A keyword hash node contains all keyword arguments as AssocNodes and AssocSplatNodes
+ case PM_KEYWORD_HASH_NODE: {
+ PUSH_INSN1(ret, location, newarray, INT2FIX(post_splat_counter));
+ PUSH_INSN(ret, location, concatarray);
+ break;
+ }
+ case PM_SPLAT_NODE: {
+ PUSH_INSN1(ret, location, newarray, INT2FIX(post_splat_counter));
+ PUSH_INSN(ret, location, concatarray);
+ break;
+ }
+ case PM_FORWARDING_ARGUMENTS_NODE: {
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(post_splat_counter));
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ else {
+ orig_argc++;
+ }
+ }
+ }
+ }
+ }
+
+ if (has_splat) orig_argc++;
+ if (has_keyword_splat) orig_argc++;
+ return orig_argc;
+}
+
+/**
+ * True if the given kind of node could potentially mutate the array that is
+ * being splatted in a set of call arguments.
+ */
+static inline bool
+pm_setup_args_dup_rest_p(const pm_node_t *node)
+{
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BACK_REFERENCE_READ_NODE:
+ case PM_CLASS_VARIABLE_READ_NODE:
+ case PM_CONSTANT_READ_NODE:
+ case PM_FALSE_NODE:
+ case PM_FLOAT_NODE:
+ case PM_GLOBAL_VARIABLE_READ_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INSTANCE_VARIABLE_READ_NODE:
+ case PM_INTEGER_NODE:
+ case PM_LAMBDA_NODE:
+ case PM_LOCAL_VARIABLE_READ_NODE:
+ case PM_NIL_NODE:
+ case PM_NUMBERED_REFERENCE_READ_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SELF_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_TRUE_NODE:
+ return false;
+ case PM_CONSTANT_PATH_NODE: {
+ const pm_constant_path_node_t *cast = (const pm_constant_path_node_t *) node;
+ if (cast->parent != NULL) {
+ return pm_setup_args_dup_rest_p(cast->parent);
+ }
+ return false;
+ }
+ case PM_IMPLICIT_NODE:
+ return pm_setup_args_dup_rest_p(((const pm_implicit_node_t *) node)->value);
+ case PM_ARRAY_NODE: {
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ if (pm_setup_args_dup_rest_p(cast->elements.nodes[index])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ default:
+ return true;
+ }
+}
+
+/**
+ * Compile the argument parts of a call.
+ */
+static int
+pm_setup_args(const pm_arguments_node_t *arguments_node, const pm_node_t *block, int *flags, struct rb_callinfo_kwarg **kw_arg, rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, const pm_node_location_t *node_location)
+{
+ int dup_rest = SPLATARRAY_TRUE;
+
+ const pm_node_list_t *arguments;
+ size_t arguments_size;
+
+ // Calls like foo(1, *f, **hash) that use splat and kwsplat could be
+ // eligible for eliding duping the rest array (dup_reset=false).
+ if (
+ arguments_node != NULL &&
+ (arguments = &arguments_node->arguments, arguments_size = arguments->size) >= 2 &&
+ PM_NODE_FLAG_P(arguments_node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT) &&
+ !PM_NODE_FLAG_P(arguments_node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_MULTIPLE_SPLATS) &&
+ PM_NODE_TYPE_P(arguments->nodes[arguments_size - 1], PM_KEYWORD_HASH_NODE)
+ ) {
+ // Start by assuming that dup_rest=false, then check each element of the
+ // hash to ensure we don't need to flip it back to true (in case one of
+ // the elements could potentially mutate the array).
+ dup_rest = SPLATARRAY_FALSE;
+
+ const pm_keyword_hash_node_t *keyword_hash = (const pm_keyword_hash_node_t *) arguments->nodes[arguments_size - 1];
+ const pm_node_list_t *elements = &keyword_hash->elements;
+
+ for (size_t index = 0; dup_rest == SPLATARRAY_FALSE && index < elements->size; index++) {
+ const pm_node_t *element = elements->nodes[index];
+
+ switch (PM_NODE_TYPE(element)) {
+ case PM_ASSOC_NODE: {
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) element;
+ if (pm_setup_args_dup_rest_p(assoc->key) || pm_setup_args_dup_rest_p(assoc->value)) dup_rest = SPLATARRAY_TRUE;
+ break;
+ }
+ case PM_ASSOC_SPLAT_NODE: {
+ const pm_assoc_splat_node_t *assoc = (const pm_assoc_splat_node_t *) element;
+ if (assoc->value != NULL && pm_setup_args_dup_rest_p(assoc->value)) dup_rest = SPLATARRAY_TRUE;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+ int initial_dup_rest = dup_rest;
+ int argc;
+
+ if (block && PM_NODE_TYPE_P(block, PM_BLOCK_ARGUMENT_NODE)) {
+ // We compile the `&block_arg` expression first and stitch it later
+ // since the nature of the expression influences whether splat should
+ // duplicate the array.
+ bool regular_block_arg = true;
+ const pm_node_t *block_expr = ((const pm_block_argument_node_t *)block)->expression;
+
+ if (block_expr && pm_setup_args_dup_rest_p(block_expr)) {
+ dup_rest = SPLATARRAY_TRUE | DUP_SINGLE_KW_SPLAT;
+ initial_dup_rest = dup_rest;
+ }
+
+ DECL_ANCHOR(block_arg);
+ pm_compile_node(iseq, block, block_arg, false, scope_node);
+
+ *flags |= VM_CALL_ARGS_BLOCKARG;
+
+ if (LIST_INSN_SIZE_ONE(block_arg)) {
+ LINK_ELEMENT *elem = FIRST_ELEMENT(block_arg);
+ if (IS_INSN(elem)) {
+ INSN *iobj = (INSN *) elem;
+ if (iobj->insn_id == BIN(getblockparam)) {
+ iobj->insn_id = BIN(getblockparamproxy);
+ }
+
+ // Allow splat without duplication for simple one-instruction
+ // block arguments like `&arg`. It is known that this
+ // optimization can be too aggressive in some cases. See
+ // [Bug #16504].
+ regular_block_arg = false;
+ }
+ }
+
+ argc = pm_setup_args_core(arguments_node, block, flags, regular_block_arg, kw_arg, &dup_rest, iseq, ret, scope_node, node_location);
+ PUSH_SEQ(ret, block_arg);
+ }
+ else {
+ argc = pm_setup_args_core(arguments_node, block, flags, false, kw_arg, &dup_rest, iseq, ret, scope_node, node_location);
+ }
+
+ // If the dup_rest flag was consumed while compiling the arguments (which
+ // effectively means we found the splat node), then it would have changed
+ // during the call to pm_setup_args_core. In this case, we want to add the
+ // VM_CALL_ARGS_SPLAT_MUT flag.
+ if (*flags & VM_CALL_ARGS_SPLAT && dup_rest != initial_dup_rest) {
+ *flags |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+
+ return argc;
+}
+
+/**
+ * Compile an index operator write node, which is a node that is writing a value
+ * using the [] and []= methods. It looks like:
+ *
+ * foo[bar] += baz
+ *
+ * This breaks down to caching the receiver and arguments on the stack, calling
+ * the [] method, calling the operator method with the result of the [] method,
+ * and then calling the []= method with the result of the operator method.
+ */
+static void
+pm_compile_index_operator_write_node(rb_iseq_t *iseq, const pm_index_operator_write_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ if (!popped) PUSH_INSN(ret, location, putnil);
+
+ PM_COMPILE_NOT_POPPED(node->receiver);
+
+ int boff = (node->block == NULL ? 0 : 1);
+ int flag = PM_NODE_TYPE_P(node->receiver, PM_SELF_NODE) ? VM_CALL_FCALL : 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
+ int argc = pm_setup_args(node->arguments, (const pm_node_t *) node->block, &flag, &keywords, iseq, ret, scope_node, node_location);
+
+ if ((argc > 0 || boff) && (flag & VM_CALL_KW_SPLAT)) {
+ if (boff) {
+ PUSH_INSN(ret, location, splatkw);
+ }
+ else {
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN(ret, location, splatkw);
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ int dup_argn = argc + 1 + boff;
+ int keyword_len = 0;
+
+ if (keywords) {
+ keyword_len = keywords->keyword_len;
+ dup_argn += keyword_len;
+ }
+
+ PUSH_INSN1(ret, location, dupn, INT2FIX(dup_argn));
+ PUSH_SEND_R(ret, location, idAREF, INT2FIX(argc), NULL, INT2FIX(flag & ~(VM_CALL_ARGS_SPLAT_MUT | VM_CALL_KW_SPLAT_MUT)), keywords);
+ PM_COMPILE_NOT_POPPED(node->value);
+
+ ID id_operator = pm_constant_id_lookup(scope_node, node->binary_operator);
+ PUSH_SEND(ret, location, id_operator, INT2FIX(1));
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(dup_argn + 1));
+ }
+ if (flag & VM_CALL_ARGS_SPLAT) {
+ if (flag & VM_CALL_KW_SPLAT) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(2 + boff));
+
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ PUSH_INSN1(ret, location, splatarray, Qtrue);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(1));
+ PUSH_INSN1(ret, location, setn, INT2FIX(2 + boff));
+ PUSH_INSN(ret, location, pop);
+ }
+ else {
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(3));
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN(ret, location, pop);
+ }
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, splatarray, Qtrue);
+ PUSH_INSN(ret, location, swap);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(1));
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(3));
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc), NULL, INT2FIX(flag), keywords);
+ }
+ else if (flag & VM_CALL_KW_SPLAT) {
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(2));
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, setn, INT2FIX(3));
+ PUSH_INSN(ret, location, pop);
+ }
+ PUSH_INSN(ret, location, swap);
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+ else if (keyword_len) {
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, opt_reverse, INT2FIX(keyword_len + boff + 2));
+ PUSH_INSN1(ret, location, opt_reverse, INT2FIX(keyword_len + boff + 1));
+ PUSH_INSN(ret, location, pop);
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+ else {
+ if (boff > 0) {
+ PUSH_INSN(ret, location, swap);
+ }
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+
+ PUSH_INSN(ret, location, pop);
+}
+
+/**
+ * Compile an index control flow write node, which is a node that is writing a
+ * value using the [] and []= methods and the &&= and ||= operators. It looks
+ * like:
+ *
+ * foo[bar] ||= baz
+ *
+ * This breaks down to caching the receiver and arguments on the stack, calling
+ * the [] method, checking the result and then changing control flow based on
+ * it. If the value would result in a write, then the value is written using the
+ * []= method.
+ */
+static void
+pm_compile_index_control_flow_write_node(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_t *receiver, const pm_arguments_node_t *arguments, const pm_block_argument_node_t *block, const pm_node_t *value, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ if (!popped) PUSH_INSN(ret, location, putnil);
+ PM_COMPILE_NOT_POPPED(receiver);
+
+ int boff = (block == NULL ? 0 : 1);
+ int flag = PM_NODE_TYPE_P(receiver, PM_SELF_NODE) ? VM_CALL_FCALL : 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
+ int argc = pm_setup_args(arguments, (const pm_node_t *) block, &flag, &keywords, iseq, ret, scope_node, node_location);
+
+ if ((argc > 0 || boff) && (flag & VM_CALL_KW_SPLAT)) {
+ if (boff) {
+ PUSH_INSN(ret, location, splatkw);
+ }
+ else {
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN(ret, location, splatkw);
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ int dup_argn = argc + 1 + boff;
+ int keyword_len = 0;
+
+ if (keywords) {
+ keyword_len = keywords->keyword_len;
+ dup_argn += keyword_len;
+ }
+
+ PUSH_INSN1(ret, location, dupn, INT2FIX(dup_argn));
+ PUSH_SEND_R(ret, location, idAREF, INT2FIX(argc), NULL, INT2FIX(flag & ~(VM_CALL_ARGS_SPLAT_MUT | VM_CALL_KW_SPLAT_MUT)), keywords);
+
+ LABEL *label = NEW_LABEL(location.line);
+ LABEL *lfin = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ if (PM_NODE_TYPE_P(node, PM_INDEX_AND_WRITE_NODE)) {
+ PUSH_INSNL(ret, location, branchunless, label);
+ }
+ else {
+ PUSH_INSNL(ret, location, branchif, label);
+ }
+
+ PUSH_INSN(ret, location, pop);
+ PM_COMPILE_NOT_POPPED(value);
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(dup_argn + 1));
+ }
+
+ if (flag & VM_CALL_ARGS_SPLAT) {
+ if (flag & VM_CALL_KW_SPLAT) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(2 + boff));
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ PUSH_INSN1(ret, location, splatarray, Qtrue);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(1));
+ PUSH_INSN1(ret, location, setn, INT2FIX(2 + boff));
+ PUSH_INSN(ret, location, pop);
+ }
+ else {
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(3));
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN(ret, location, pop);
+ }
+ if (!(flag & VM_CALL_ARGS_SPLAT_MUT)) {
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, splatarray, Qtrue);
+ PUSH_INSN(ret, location, swap);
+ flag |= VM_CALL_ARGS_SPLAT_MUT;
+ }
+ PUSH_INSN1(ret, location, pushtoarray, INT2FIX(1));
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(3));
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc), NULL, INT2FIX(flag), keywords);
+ }
+ else if (flag & VM_CALL_KW_SPLAT) {
+ if (boff > 0) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(2));
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, setn, INT2FIX(3));
+ PUSH_INSN(ret, location, pop);
+ }
+
+ PUSH_INSN(ret, location, swap);
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+ else if (keyword_len) {
+ PUSH_INSN1(ret, location, opt_reverse, INT2FIX(keyword_len + boff + 1));
+ PUSH_INSN1(ret, location, opt_reverse, INT2FIX(keyword_len + boff + 0));
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+ else {
+ if (boff > 0) {
+ PUSH_INSN(ret, location, swap);
+ }
+ PUSH_SEND_R(ret, location, idASET, INT2FIX(argc + 1), NULL, INT2FIX(flag), keywords);
+ }
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, lfin);
+ PUSH_LABEL(ret, label);
+ if (!popped) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(dup_argn + 1));
+ }
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(dup_argn + 1));
+ PUSH_LABEL(ret, lfin);
+}
+
+// When we compile a pattern matching expression, we use the stack as a scratch
+// space to store lots of different values (consider it like we have a pattern
+// matching function and we need space for a bunch of different local
+// variables). The "base index" refers to the index on the stack where we
+// started compiling the pattern matching expression. These offsets from that
+// base index indicate the location of the various locals we need.
+#define PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE 0
+#define PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING 1
+#define PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P 2
+#define PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_MATCHEE 3
+#define PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_KEY 4
+
+// A forward declaration because this is the recursive function that handles
+// compiling a pattern. It can be reentered by nesting patterns, as in the case
+// of arrays or hashes.
+static int pm_compile_pattern(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *matched_label, LABEL *unmatched_label, bool in_single_pattern, bool use_deconstructed_cache, unsigned int base_index);
+
+/**
+ * This function generates the code to set up the error string and error_p
+ * locals depending on whether or not the pattern matched.
+ */
+static int
+pm_compile_pattern_generic_error(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, VALUE message, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ LABEL *match_succeeded_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, match_succeeded_label);
+
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putobject, message);
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(2));
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 1));
+
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+ PUSH_LABEL(ret, match_succeeded_label);
+
+ return COMPILE_OK;
+}
+
+/**
+ * This function generates the code to set up the error string and error_p
+ * locals depending on whether or not the pattern matched when the value needs
+ * to match a specific deconstructed length.
+ */
+static int
+pm_compile_pattern_length_error(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, VALUE message, VALUE length, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ LABEL *match_succeeded_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, match_succeeded_label);
+
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putobject, message);
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, length);
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(4));
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 1));
+
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+ PUSH_LABEL(ret, match_succeeded_label);
+
+ return COMPILE_OK;
+}
+
+/**
+ * This function generates the code to set up the error string and error_p
+ * locals depending on whether or not the pattern matched when the value needs
+ * to pass a specific #=== method call.
+ */
+static int
+pm_compile_pattern_eqq_error(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ LABEL *match_succeeded_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, match_succeeded_label);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ VALUE operand = rb_fstring_lit("%p === %p does not return true");
+ PUSH_INSN1(ret, location, putobject, operand);
+
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN1(ret, location, topn, INT2FIX(5));
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(3));
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 1));
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, match_succeeded_label);
+ PUSH_INSN1(ret, location, setn, INT2FIX(2));
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+
+ return COMPILE_OK;
+}
+
+/**
+ * This is a variation on compiling a pattern matching expression that is used
+ * to have the pattern matching instructions fall through to immediately after
+ * the pattern if it passes. Otherwise it jumps to the given unmatched_label
+ * label.
+ */
+static int
+pm_compile_pattern_match(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *unmatched_label, bool in_single_pattern, bool use_deconstructed_cache, unsigned int base_index)
+{
+ LABEL *matched_label = NEW_LABEL(pm_node_line_number_cached(node, scope_node));
+ CHECK(pm_compile_pattern(iseq, scope_node, node, ret, matched_label, unmatched_label, in_single_pattern, use_deconstructed_cache, base_index));
+ PUSH_LABEL(ret, matched_label);
+ return COMPILE_OK;
+}
+
+/**
+ * This function compiles in the code necessary to call #deconstruct on the
+ * value to match against. It raises appropriate errors if the method does not
+ * exist or if it returns the wrong type.
+ */
+static int
+pm_compile_pattern_deconstruct(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *deconstruct_label, LABEL *match_failed_label, LABEL *deconstructed_label, LABEL *type_error_label, bool in_single_pattern, bool use_deconstructed_cache, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ if (use_deconstructed_cache) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE));
+ PUSH_INSNL(ret, location, branchnil, deconstruct_label);
+
+ PUSH_INSN1(ret, location, topn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE));
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN1(ret, location, topn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE - 1));
+ PUSH_INSNL(ret, location, jump, deconstructed_label);
+ }
+ else {
+ PUSH_INSNL(ret, location, jump, deconstruct_label);
+ }
+
+ PUSH_LABEL(ret, deconstruct_label);
+ PUSH_INSN(ret, location, dup);
+
+ VALUE operand = ID2SYM(rb_intern("deconstruct"));
+ PUSH_INSN1(ret, location, putobject, operand);
+ PUSH_SEND(ret, location, idRespond_to, INT2FIX(1));
+
+ if (use_deconstructed_cache) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE + 1));
+ }
+
+ if (in_single_pattern) {
+ CHECK(pm_compile_pattern_generic_error(iseq, scope_node, node, ret, rb_fstring_lit("%p does not respond to #deconstruct"), base_index + 1));
+ }
+
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+ PUSH_SEND(ret, location, rb_intern("deconstruct"), INT2FIX(0));
+
+ if (use_deconstructed_cache) {
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE));
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, checktype, INT2FIX(T_ARRAY));
+ PUSH_INSNL(ret, location, branchunless, type_error_label);
+ PUSH_LABEL(ret, deconstructed_label);
+
+ return COMPILE_OK;
+}
+
+/**
+ * This function compiles in the code necessary to match against the optional
+ * constant path that is attached to an array, find, or hash pattern.
+ */
+static int
+pm_compile_pattern_constant(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *match_failed_label, bool in_single_pattern, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ PUSH_INSN(ret, location, dup);
+ PM_COMPILE_NOT_POPPED(node);
+
+ if (in_single_pattern) {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(2));
+ }
+ PUSH_INSN1(ret, location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
+ if (in_single_pattern) {
+ CHECK(pm_compile_pattern_eqq_error(iseq, scope_node, node, ret, base_index + 3));
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+ return COMPILE_OK;
+}
+
+/**
+ * When matching fails, an appropriate error must be raised. This function is
+ * responsible for compiling in those error raising instructions.
+ */
+static void
+pm_compile_pattern_error_handler(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *done_label, bool popped)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ LABEL *key_error_label = NEW_LABEL(location.line);
+ LABEL *cleanup_label = NEW_LABEL(location.line);
+
+ struct rb_callinfo_kwarg *kw_arg = rb_xmalloc_mul_add(2, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ kw_arg->references = 0;
+ kw_arg->keyword_len = 2;
+ kw_arg->keywords[0] = ID2SYM(rb_intern("matchee"));
+ kw_arg->keywords[1] = ID2SYM(rb_intern("key"));
+
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, topn, INT2FIX(PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+ PUSH_INSNL(ret, location, branchif, key_error_label);
+
+ PUSH_INSN1(ret, location, putobject, rb_eNoMatchingPatternError);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ {
+ VALUE operand = rb_fstring_lit("%p: %s");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_INSN1(ret, location, topn, INT2FIX(4));
+ PUSH_INSN1(ret, location, topn, INT2FIX(PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 6));
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(3));
+ PUSH_SEND(ret, location, id_core_raise, INT2FIX(2));
+ PUSH_INSNL(ret, location, jump, cleanup_label);
+
+ PUSH_LABEL(ret, key_error_label);
+ PUSH_INSN1(ret, location, putobject, rb_eNoMatchingPatternKeyError);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ {
+ VALUE operand = rb_fstring_lit("%p: %s");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_INSN1(ret, location, topn, INT2FIX(4));
+ PUSH_INSN1(ret, location, topn, INT2FIX(PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 6));
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(3));
+ PUSH_INSN1(ret, location, topn, INT2FIX(PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_MATCHEE + 4));
+ PUSH_INSN1(ret, location, topn, INT2FIX(PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_KEY + 5));
+ PUSH_SEND_R(ret, location, rb_intern("new"), INT2FIX(1), NULL, INT2FIX(VM_CALL_KWARG), kw_arg);
+ PUSH_SEND(ret, location, id_core_raise, INT2FIX(1));
+ PUSH_LABEL(ret, cleanup_label);
+
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(7));
+ if (!popped) PUSH_INSN(ret, location, putnil);
+ PUSH_INSNL(ret, location, jump, done_label);
+ PUSH_INSN1(ret, location, dupn, INT2FIX(5));
+ if (popped) PUSH_INSN(ret, location, putnil);
+}
+
+/**
+ * Compile a pattern matching expression.
+ */
+static int
+pm_compile_pattern(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t *node, LINK_ANCHOR *const ret, LABEL *matched_label, LABEL *unmatched_label, bool in_single_pattern, bool use_deconstructed_cache, unsigned int base_index)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ARRAY_PATTERN_NODE: {
+ // Array patterns in pattern matching are triggered by using commas in
+ // a pattern or wrapping it in braces. They are represented by a
+ // ArrayPatternNode. This looks like:
+ //
+ // foo => [1, 2, 3]
+ //
+ // It can optionally have a splat in the middle of it, which can
+ // optionally have a name attached.
+ const pm_array_pattern_node_t *cast = (const pm_array_pattern_node_t *) node;
+
+ const size_t requireds_size = cast->requireds.size;
+ const size_t posts_size = cast->posts.size;
+ const size_t minimum_size = requireds_size + posts_size;
+
+ bool rest_named = false;
+ bool use_rest_size = false;
+
+ if (cast->rest != NULL) {
+ rest_named = (PM_NODE_TYPE_P(cast->rest, PM_SPLAT_NODE) && ((const pm_splat_node_t *) cast->rest)->expression != NULL);
+ use_rest_size = (rest_named || (!rest_named && posts_size > 0));
+ }
+
+ LABEL *match_failed_label = NEW_LABEL(location.line);
+ LABEL *type_error_label = NEW_LABEL(location.line);
+ LABEL *deconstruct_label = NEW_LABEL(location.line);
+ LABEL *deconstructed_label = NEW_LABEL(location.line);
+
+ if (use_rest_size) {
+ PUSH_INSN1(ret, location, putobject, INT2FIX(0));
+ PUSH_INSN(ret, location, swap);
+ base_index++;
+ }
+
+ if (cast->constant != NULL) {
+ CHECK(pm_compile_pattern_constant(iseq, scope_node, cast->constant, ret, match_failed_label, in_single_pattern, base_index));
+ }
+
+ CHECK(pm_compile_pattern_deconstruct(iseq, scope_node, node, ret, deconstruct_label, match_failed_label, deconstructed_label, type_error_label, in_single_pattern, use_deconstructed_cache, base_index));
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(minimum_size));
+ PUSH_SEND(ret, location, cast->rest == NULL ? idEq : idGE, INT2FIX(1));
+ if (in_single_pattern) {
+ VALUE message = cast->rest == NULL ? rb_fstring_lit("%p length mismatch (given %p, expected %p)") : rb_fstring_lit("%p length mismatch (given %p, expected %p+)");
+ CHECK(pm_compile_pattern_length_error(iseq, scope_node, node, ret, message, INT2FIX(minimum_size), base_index + 1));
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+
+ for (size_t index = 0; index < requireds_size; index++) {
+ const pm_node_t *required = cast->requireds.nodes[index];
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(index));
+ PUSH_SEND(ret, location, idAREF, INT2FIX(1));
+ CHECK(pm_compile_pattern_match(iseq, scope_node, required, ret, match_failed_label, in_single_pattern, false, base_index + 1));
+ }
+
+ if (cast->rest != NULL) {
+ if (rest_named) {
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(requireds_size));
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(minimum_size));
+ PUSH_SEND(ret, location, idMINUS, INT2FIX(1));
+ PUSH_INSN1(ret, location, setn, INT2FIX(4));
+ PUSH_SEND(ret, location, idAREF, INT2FIX(2));
+ CHECK(pm_compile_pattern_match(iseq, scope_node, ((const pm_splat_node_t *) cast->rest)->expression, ret, match_failed_label, in_single_pattern, false, base_index + 1));
+ }
+ else if (posts_size > 0) {
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(minimum_size));
+ PUSH_SEND(ret, location, idMINUS, INT2FIX(1));
+ PUSH_INSN1(ret, location, setn, INT2FIX(2));
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ for (size_t index = 0; index < posts_size; index++) {
+ const pm_node_t *post = cast->posts.nodes[index];
+ PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN1(ret, location, putobject, INT2FIX(requireds_size + index));
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_SEND(ret, location, idPLUS, INT2FIX(1));
+ PUSH_SEND(ret, location, idAREF, INT2FIX(1));
+ CHECK(pm_compile_pattern_match(iseq, scope_node, post, ret, match_failed_label, in_single_pattern, false, base_index + 1));
+ }
+
+ PUSH_INSN(ret, location, pop);
+ if (use_rest_size) {
+ PUSH_INSN(ret, location, pop);
+ }
+
+ PUSH_INSNL(ret, location, jump, matched_label);
+ PUSH_INSN(ret, location, putnil);
+ if (use_rest_size) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ PUSH_LABEL(ret, type_error_label);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putobject, rb_eTypeError);
+
+ {
+ VALUE operand = rb_fstring_lit("deconstruct must return Array");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, location, id_core_raise, INT2FIX(2));
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, match_failed_label);
+ PUSH_INSN(ret, location, pop);
+ if (use_rest_size) {
+ PUSH_INSN(ret, location, pop);
+ }
+
+ PUSH_INSNL(ret, location, jump, unmatched_label);
+ break;
+ }
+ case PM_FIND_PATTERN_NODE: {
+ // Find patterns in pattern matching are triggered by using commas in
+ // a pattern or wrapping it in braces and using a splat on both the left
+ // and right side of the pattern. This looks like:
+ //
+ // foo => [*, 1, 2, 3, *]
+ //
+ // There can be any number of requireds in the middle. The splats on
+ // both sides can optionally have names attached.
+ const pm_find_pattern_node_t *cast = (const pm_find_pattern_node_t *) node;
+ const size_t size = cast->requireds.size;
+
+ LABEL *match_failed_label = NEW_LABEL(location.line);
+ LABEL *type_error_label = NEW_LABEL(location.line);
+ LABEL *deconstruct_label = NEW_LABEL(location.line);
+ LABEL *deconstructed_label = NEW_LABEL(location.line);
+
+ if (cast->constant) {
+ CHECK(pm_compile_pattern_constant(iseq, scope_node, cast->constant, ret, match_failed_label, in_single_pattern, base_index));
+ }
+
+ CHECK(pm_compile_pattern_deconstruct(iseq, scope_node, node, ret, deconstruct_label, match_failed_label, deconstructed_label, type_error_label, in_single_pattern, use_deconstructed_cache, base_index));
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(size));
+ PUSH_SEND(ret, location, idGE, INT2FIX(1));
+ if (in_single_pattern) {
+ CHECK(pm_compile_pattern_length_error(iseq, scope_node, node, ret, rb_fstring_lit("%p length mismatch (given %p, expected %p+)"), INT2FIX(size), base_index + 1));
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+
+ {
+ LABEL *while_begin_label = NEW_LABEL(location.line);
+ LABEL *next_loop_label = NEW_LABEL(location.line);
+ LABEL *find_succeeded_label = NEW_LABEL(location.line);
+ LABEL *find_failed_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idLength, INT2FIX(0));
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(size));
+ PUSH_SEND(ret, location, idMINUS, INT2FIX(1));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(0));
+ PUSH_LABEL(ret, while_begin_label);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, topn, INT2FIX(2));
+ PUSH_SEND(ret, location, idLE, INT2FIX(1));
+ PUSH_INSNL(ret, location, branchunless, find_failed_label);
+
+ for (size_t index = 0; index < size; index++) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+
+ if (index != 0) {
+ PUSH_INSN1(ret, location, putobject, INT2FIX(index));
+ PUSH_SEND(ret, location, idPLUS, INT2FIX(1));
+ }
+
+ PUSH_SEND(ret, location, idAREF, INT2FIX(1));
+ CHECK(pm_compile_pattern_match(iseq, scope_node, cast->requireds.nodes[index], ret, next_loop_label, in_single_pattern, false, base_index + 4));
+ }
+
+ const pm_splat_node_t *left = cast->left;
+
+ if (left->expression != NULL) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(0));
+ PUSH_INSN1(ret, location, topn, INT2FIX(2));
+ PUSH_SEND(ret, location, idAREF, INT2FIX(2));
+ CHECK(pm_compile_pattern_match(iseq, scope_node, left->expression, ret, find_failed_label, in_single_pattern, false, base_index + 4));
+ }
+
+ const pm_splat_node_t *right = cast->right;
+
+ if (right->expression != NULL) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(size));
+ PUSH_SEND(ret, location, idPLUS, INT2FIX(1));
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_SEND(ret, location, idAREF, INT2FIX(2));
+ pm_compile_pattern_match(iseq, scope_node, right->expression, ret, find_failed_label, in_single_pattern, false, base_index + 4);
+ }
+
+ PUSH_INSNL(ret, location, jump, find_succeeded_label);
+
+ PUSH_LABEL(ret, next_loop_label);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(1));
+ PUSH_SEND(ret, location, idPLUS, INT2FIX(1));
+ PUSH_INSNL(ret, location, jump, while_begin_label);
+
+ PUSH_LABEL(ret, find_failed_label);
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(3));
+ if (in_single_pattern) {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ {
+ VALUE operand = rb_fstring_lit("%p does not match to find pattern");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_INSN1(ret, location, topn, INT2FIX(2));
+ PUSH_SEND(ret, location, id_core_sprintf, INT2FIX(2));
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 1));
+
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+ }
+ PUSH_INSNL(ret, location, jump, match_failed_label);
+ PUSH_INSN1(ret, location, dupn, INT2FIX(3));
+
+ PUSH_LABEL(ret, find_succeeded_label);
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(3));
+ }
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, matched_label);
+ PUSH_INSN(ret, location, putnil);
+
+ PUSH_LABEL(ret, type_error_label);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putobject, rb_eTypeError);
+
+ {
+ VALUE operand = rb_fstring_lit("deconstruct must return Array");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, location, id_core_raise, INT2FIX(2));
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, match_failed_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, unmatched_label);
+
+ break;
+ }
+ case PM_HASH_PATTERN_NODE: {
+ // Hash patterns in pattern matching are triggered by using labels and
+ // values in a pattern or by using the ** operator. They are represented
+ // by the HashPatternNode. This looks like:
+ //
+ // foo => { a: 1, b: 2, **bar }
+ //
+ // It can optionally have an assoc splat in the middle of it, which can
+ // optionally have a name.
+ const pm_hash_pattern_node_t *cast = (const pm_hash_pattern_node_t *) node;
+
+ // We don't consider it a "rest" parameter if it's a ** that is unnamed.
+ bool has_rest = cast->rest != NULL && !(PM_NODE_TYPE_P(cast->rest, PM_ASSOC_SPLAT_NODE) && ((const pm_assoc_splat_node_t *) cast->rest)->value == NULL);
+ bool has_keys = cast->elements.size > 0 || cast->rest != NULL;
+
+ LABEL *match_failed_label = NEW_LABEL(location.line);
+ LABEL *type_error_label = NEW_LABEL(location.line);
+ VALUE keys = Qnil;
+
+ if (has_keys && !has_rest) {
+ keys = rb_ary_new_capa(cast->elements.size);
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ const pm_node_t *element = cast->elements.nodes[index];
+ RUBY_ASSERT(PM_NODE_TYPE_P(element, PM_ASSOC_NODE));
+
+ const pm_node_t *key = ((const pm_assoc_node_t *) element)->key;
+ RUBY_ASSERT(PM_NODE_TYPE_P(key, PM_SYMBOL_NODE));
+
+ VALUE symbol = ID2SYM(parse_string_symbol(scope_node, (const pm_symbol_node_t *) key));
+ rb_ary_push(keys, symbol);
+ }
+ }
+
+ if (cast->constant) {
+ CHECK(pm_compile_pattern_constant(iseq, scope_node, cast->constant, ret, match_failed_label, in_single_pattern, base_index));
+ }
+
+ PUSH_INSN(ret, location, dup);
+
+ {
+ VALUE operand = ID2SYM(rb_intern("deconstruct_keys"));
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, location, idRespond_to, INT2FIX(1));
+ if (in_single_pattern) {
+ CHECK(pm_compile_pattern_generic_error(iseq, scope_node, node, ret, rb_fstring_lit("%p does not respond to #deconstruct_keys"), base_index + 1));
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+
+ if (NIL_P(keys)) {
+ PUSH_INSN(ret, location, putnil);
+ }
+ else {
+ rb_obj_hide(keys);
+ RB_OBJ_SET_FROZEN_SHAREABLE(keys);
+ PUSH_INSN1(ret, location, duparray, keys);
+ RB_OBJ_WRITTEN(iseq, Qundef, keys);
+ }
+ PUSH_SEND(ret, location, rb_intern("deconstruct_keys"), INT2FIX(1));
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, checktype, INT2FIX(T_HASH));
+ PUSH_INSNL(ret, location, branchunless, type_error_label);
+
+ if (has_rest) {
+ PUSH_SEND(ret, location, rb_intern("dup"), INT2FIX(0));
+ }
+
+ if (has_keys) {
+ DECL_ANCHOR(match_values);
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ const pm_node_t *element = cast->elements.nodes[index];
+ RUBY_ASSERT(PM_NODE_TYPE_P(element, PM_ASSOC_NODE));
+
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) element;
+ const pm_node_t *key = assoc->key;
+ RUBY_ASSERT(PM_NODE_TYPE_P(key, PM_SYMBOL_NODE));
+
+ VALUE symbol = ID2SYM(parse_string_symbol(scope_node, (const pm_symbol_node_t *) key));
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, symbol);
+ PUSH_SEND(ret, location, rb_intern("key?"), INT2FIX(1));
+
+ if (in_single_pattern) {
+ LABEL *match_succeeded_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, match_succeeded_label);
+
+ {
+ VALUE operand = rb_str_freeze(rb_sprintf("key not found: %+"PRIsVALUE, symbol));
+ RB_OBJ_SET_SHAREABLE(operand);
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 2));
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 3));
+ PUSH_INSN1(ret, location, topn, INT2FIX(3));
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_MATCHEE + 4));
+ PUSH_INSN1(ret, location, putobject, symbol);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_KEY + 5));
+
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(4));
+ PUSH_LABEL(ret, match_succeeded_label);
+ }
+
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+ PUSH_INSN(match_values, location, dup);
+ PUSH_INSN1(match_values, location, putobject, symbol);
+ PUSH_SEND(match_values, location, has_rest ? rb_intern("delete") : idAREF, INT2FIX(1));
+
+ const pm_node_t *value = assoc->value;
+ if (PM_NODE_TYPE_P(value, PM_IMPLICIT_NODE)) {
+ value = ((const pm_implicit_node_t *) value)->value;
+ }
+
+ CHECK(pm_compile_pattern_match(iseq, scope_node, value, match_values, match_failed_label, in_single_pattern, false, base_index + 1));
+ }
+
+ PUSH_SEQ(ret, match_values);
+ }
+ else {
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idEmptyP, INT2FIX(0));
+ if (in_single_pattern) {
+ CHECK(pm_compile_pattern_generic_error(iseq, scope_node, node, ret, rb_fstring_lit("%p is not empty"), base_index + 1));
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+ }
+
+ if (has_rest) {
+ switch (PM_NODE_TYPE(cast->rest)) {
+ case PM_NO_KEYWORDS_PARAMETER_NODE: {
+ PUSH_INSN(ret, location, dup);
+ PUSH_SEND(ret, location, idEmptyP, INT2FIX(0));
+ if (in_single_pattern) {
+ pm_compile_pattern_generic_error(iseq, scope_node, node, ret, rb_fstring_lit("rest of %p is not empty"), base_index + 1);
+ }
+ PUSH_INSNL(ret, location, branchunless, match_failed_label);
+ break;
+ }
+ case PM_ASSOC_SPLAT_NODE: {
+ const pm_assoc_splat_node_t *splat = (const pm_assoc_splat_node_t *) cast->rest;
+ PUSH_INSN(ret, location, dup);
+ pm_compile_pattern_match(iseq, scope_node, splat->value, ret, match_failed_label, in_single_pattern, false, base_index + 1);
+ break;
+ }
+ default:
+ rb_bug("unreachable");
+ break;
+ }
+ }
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, matched_label);
+ PUSH_INSN(ret, location, putnil);
+
+ PUSH_LABEL(ret, type_error_label);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putobject, rb_eTypeError);
+
+ {
+ VALUE operand = rb_fstring_lit("deconstruct_keys must return Hash");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, location, id_core_raise, INT2FIX(2));
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, match_failed_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, unmatched_label);
+ break;
+ }
+ case PM_CAPTURE_PATTERN_NODE: {
+ // Capture patterns allow you to pattern match against an element in a
+ // pattern and also capture the value into a local variable. This looks
+ // like:
+ //
+ // [1] => [Integer => foo]
+ //
+ // In this case the `Integer => foo` will be represented by a
+ // CapturePatternNode, which has both a value (the pattern to match
+ // against) and a target (the place to write the variable into).
+ const pm_capture_pattern_node_t *cast = (const pm_capture_pattern_node_t *) node;
+
+ LABEL *match_failed_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ CHECK(pm_compile_pattern_match(iseq, scope_node, cast->value, ret, match_failed_label, in_single_pattern, use_deconstructed_cache, base_index + 1));
+ CHECK(pm_compile_pattern(iseq, scope_node, (const pm_node_t *) cast->target, ret, matched_label, match_failed_label, in_single_pattern, false, base_index));
+ PUSH_INSN(ret, location, putnil);
+
+ PUSH_LABEL(ret, match_failed_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, unmatched_label);
+
+ break;
+ }
+ case PM_LOCAL_VARIABLE_TARGET_NODE: {
+ // Local variables can be targeted by placing identifiers in the place
+ // of a pattern. For example, foo in bar. This results in the value
+ // being matched being written to that local variable.
+ const pm_local_variable_target_node_t *cast = (const pm_local_variable_target_node_t *) node;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+ PUSH_INSNL(ret, location, jump, matched_label);
+ break;
+ }
+ case PM_ALTERNATION_PATTERN_NODE: {
+ // Alternation patterns allow you to specify multiple patterns in a
+ // single expression using the | operator.
+ const pm_alternation_pattern_node_t *cast = (const pm_alternation_pattern_node_t *) node;
+
+ LABEL *matched_left_label = NEW_LABEL(location.line);
+ LABEL *unmatched_left_label = NEW_LABEL(location.line);
+
+ // First, we're going to attempt to match against the left pattern. If
+ // that pattern matches, then we'll skip matching the right pattern.
+ PUSH_INSN(ret, location, dup);
+ CHECK(pm_compile_pattern(iseq, scope_node, cast->left, ret, matched_left_label, unmatched_left_label, in_single_pattern, use_deconstructed_cache, base_index + 1));
+
+ // If we get here, then we matched on the left pattern. In this case we
+ // should pop out the duplicate value that we preemptively added to
+ // match against the right pattern and then jump to the match label.
+ PUSH_LABEL(ret, matched_left_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSNL(ret, location, jump, matched_label);
+ PUSH_INSN(ret, location, putnil);
+
+ // If we get here, then we didn't match on the left pattern. In this
+ // case we attempt to match against the right pattern.
+ PUSH_LABEL(ret, unmatched_left_label);
+ CHECK(pm_compile_pattern(iseq, scope_node, cast->right, ret, matched_label, unmatched_label, in_single_pattern, use_deconstructed_cache, base_index));
+ break;
+ }
+ case PM_PARENTHESES_NODE:
+ // Parentheses are allowed to wrap expressions in pattern matching and
+ // they do nothing since they can only wrap individual expressions and
+ // not groups. In this case we'll recurse back into this same function
+ // with the body of the parentheses.
+ return pm_compile_pattern(iseq, scope_node, ((const pm_parentheses_node_t *) node)->body, ret, matched_label, unmatched_label, in_single_pattern, use_deconstructed_cache, base_index);
+ case PM_PINNED_EXPRESSION_NODE:
+ // Pinned expressions are a way to match against the value of an
+ // expression that should be evaluated at runtime. This looks like:
+ // foo in ^(bar). To compile these, we compile the expression as if it
+ // were a literal value by falling through to the literal case.
+ node = ((const pm_pinned_expression_node_t *) node)->expression;
+ /* fallthrough */
+ case PM_ARRAY_NODE:
+ case PM_CLASS_VARIABLE_READ_NODE:
+ case PM_CONSTANT_PATH_NODE:
+ case PM_CONSTANT_READ_NODE:
+ case PM_FALSE_NODE:
+ case PM_FLOAT_NODE:
+ case PM_GLOBAL_VARIABLE_READ_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_INSTANCE_VARIABLE_READ_NODE:
+ case PM_IT_LOCAL_VARIABLE_READ_NODE:
+ case PM_INTEGER_NODE:
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
+ case PM_INTERPOLATED_STRING_NODE:
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ case PM_INTERPOLATED_X_STRING_NODE:
+ case PM_LAMBDA_NODE:
+ case PM_LOCAL_VARIABLE_READ_NODE:
+ case PM_NIL_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_RANGE_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SELF_NODE:
+ case PM_STRING_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_TRUE_NODE:
+ case PM_X_STRING_NODE: {
+ // These nodes are all simple patterns, which means we'll use the
+ // checkmatch instruction to match against them, which is effectively a
+ // VM-level === operator.
+ PM_COMPILE_NOT_POPPED(node);
+ if (in_single_pattern) {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(2));
+ }
+
+ PUSH_INSN1(ret, location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
+
+ if (in_single_pattern) {
+ pm_compile_pattern_eqq_error(iseq, scope_node, node, ret, base_index + 2);
+ }
+
+ PUSH_INSNL(ret, location, branchif, matched_label);
+ PUSH_INSNL(ret, location, jump, unmatched_label);
+ break;
+ }
+ case PM_PINNED_VARIABLE_NODE: {
+ // Pinned variables are a way to match against the value of a variable
+ // without it looking like you're trying to write to the variable. This
+ // looks like: foo in ^@bar. To compile these, we compile the variable
+ // that they hold.
+ const pm_pinned_variable_node_t *cast = (const pm_pinned_variable_node_t *) node;
+ CHECK(pm_compile_pattern(iseq, scope_node, cast->variable, ret, matched_label, unmatched_label, in_single_pattern, true, base_index));
+ break;
+ }
+ case PM_IF_NODE:
+ case PM_UNLESS_NODE: {
+ // If and unless nodes can show up here as guards on `in` clauses. This
+ // looks like:
+ //
+ // case foo
+ // in bar if baz?
+ // qux
+ // end
+ //
+ // Because we know they're in the modifier form and they can't have any
+ // variation on this pattern, we compile them differently (more simply)
+ // here than we would in the normal compilation path.
+ const pm_node_t *predicate;
+ const pm_node_t *statement;
+
+ if (PM_NODE_TYPE_P(node, PM_IF_NODE)) {
+ const pm_if_node_t *cast = (const pm_if_node_t *) node;
+ predicate = cast->predicate;
+
+ RUBY_ASSERT(cast->statements != NULL && cast->statements->body.size == 1);
+ statement = cast->statements->body.nodes[0];
+ }
+ else {
+ const pm_unless_node_t *cast = (const pm_unless_node_t *) node;
+ predicate = cast->predicate;
+
+ RUBY_ASSERT(cast->statements != NULL && cast->statements->body.size == 1);
+ statement = cast->statements->body.nodes[0];
+ }
+
+ CHECK(pm_compile_pattern_match(iseq, scope_node, statement, ret, unmatched_label, in_single_pattern, use_deconstructed_cache, base_index));
+ PM_COMPILE_NOT_POPPED(predicate);
+
+ if (in_single_pattern) {
+ LABEL *match_succeeded_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, dup);
+ if (PM_NODE_TYPE_P(node, PM_IF_NODE)) {
+ PUSH_INSNL(ret, location, branchif, match_succeeded_label);
+ }
+ else {
+ PUSH_INSNL(ret, location, branchunless, match_succeeded_label);
+ }
+
+ {
+ VALUE operand = rb_fstring_lit("guard clause does not return true");
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING + 1));
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSN1(ret, location, setn, INT2FIX(base_index + PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P + 2));
+
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, match_succeeded_label);
+ }
+
+ if (PM_NODE_TYPE_P(node, PM_IF_NODE)) {
+ PUSH_INSNL(ret, location, branchunless, unmatched_label);
+ }
+ else {
+ PUSH_INSNL(ret, location, branchif, unmatched_label);
+ }
+
+ PUSH_INSNL(ret, location, jump, matched_label);
+ break;
+ }
+ default:
+ // If we get here, then we have a node type that should not be in this
+ // position. This would be a bug in the parser, because a different node
+ // type should never have been created in this position in the tree.
+ rb_bug("Unexpected node type in pattern matching expression: %s", pm_node_type(PM_NODE_TYPE(node)));
+ break;
+ }
+
+ return COMPILE_OK;
+}
+
+#undef PM_PATTERN_BASE_INDEX_OFFSET_DECONSTRUCTED_CACHE
+#undef PM_PATTERN_BASE_INDEX_OFFSET_ERROR_STRING
+#undef PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_P
+#undef PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_MATCHEE
+#undef PM_PATTERN_BASE_INDEX_OFFSET_KEY_ERROR_KEY
+
+// Generate a scope node from the given node.
+void
+pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous)
+{
+ if (previous) {
+ // Copy inherited fields from the parent scope in one shot, then
+ // zero out the fields that are scope-specific.
+ *scope = *previous;
+ scope->locals = (pm_constant_id_list_t) { 0 };
+ scope->parameters = NULL;
+ scope->body = NULL;
+ scope->local_table_for_iseq_size = 0;
+ scope->index_lookup_table = (pm_index_lookup_table_t) PM_INDEX_LOOKUP_TABLE_INIT;
+ scope->pre_execution_anchor = NULL;
+ }
+ else {
+ memset(scope, 0, sizeof(pm_scope_node_t));
+ }
+
+ scope->base.type = PM_SCOPE_NODE;
+ scope->base.location.start = node->location.start;
+ scope->base.location.length = node->location.length;
+ scope->previous = previous;
+ scope->ast_node = (pm_node_t *) node;
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_BLOCK_NODE: {
+ const pm_block_node_t *cast = (const pm_block_node_t *) node;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ scope->parameters = cast->parameters;
+ break;
+ }
+ case PM_CLASS_NODE: {
+ const pm_class_node_t *cast = (const pm_class_node_t *) node;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_DEF_NODE: {
+ const pm_def_node_t *cast = (const pm_def_node_t *) node;
+ scope->parameters = (pm_node_t *) cast->parameters;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_ENSURE_NODE: {
+ const pm_ensure_node_t *cast = (const pm_ensure_node_t *) node;
+ scope->body = (pm_node_t *) node;
+
+ if (cast->statements != NULL) {
+ scope->base.location.start = cast->statements->base.location.start;
+ scope->base.location.length = cast->statements->base.location.length;
+ }
+
+ break;
+ }
+ case PM_FOR_NODE: {
+ const pm_for_node_t *cast = (const pm_for_node_t *) node;
+ scope->body = (pm_node_t *) cast->statements;
+ break;
+ }
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
+ RUBY_ASSERT(node->flags & PM_REGULAR_EXPRESSION_FLAGS_ONCE);
+ scope->body = (pm_node_t *) node;
+ break;
+ }
+ case PM_LAMBDA_NODE: {
+ const pm_lambda_node_t *cast = (const pm_lambda_node_t *) node;
+ scope->parameters = cast->parameters;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_MODULE_NODE: {
+ const pm_module_node_t *cast = (const pm_module_node_t *) node;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_POST_EXECUTION_NODE: {
+ const pm_post_execution_node_t *cast = (const pm_post_execution_node_t *) node;
+ scope->body = (pm_node_t *) cast->statements;
+ break;
+ }
+ case PM_PROGRAM_NODE: {
+ const pm_program_node_t *cast = (const pm_program_node_t *) node;
+ scope->body = (pm_node_t *) cast->statements;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_RESCUE_NODE: {
+ const pm_rescue_node_t *cast = (const pm_rescue_node_t *) node;
+ scope->body = (pm_node_t *) cast->statements;
+ break;
+ }
+ case PM_RESCUE_MODIFIER_NODE: {
+ const pm_rescue_modifier_node_t *cast = (const pm_rescue_modifier_node_t *) node;
+ scope->body = (pm_node_t *) cast->rescue_expression;
+ break;
+ }
+ case PM_SINGLETON_CLASS_NODE: {
+ const pm_singleton_class_node_t *cast = (const pm_singleton_class_node_t *) node;
+ scope->body = cast->body;
+ scope->locals = cast->locals;
+ break;
+ }
+ case PM_STATEMENTS_NODE: {
+ const pm_statements_node_t *cast = (const pm_statements_node_t *) node;
+ scope->body = (pm_node_t *) cast;
+ break;
+ }
+ default:
+ rb_bug("unreachable");
+ break;
+ }
+}
+
+void
+pm_scope_node_destroy(pm_scope_node_t *scope_node)
+{
+ if (scope_node->index_lookup_table.owned) {
+ xfree(scope_node->index_lookup_table.values);
+ }
+}
+
+/**
+ * We need to put the label "retry_end_l" immediately after the last "send"
+ * instruction. This because vm_throw checks if the break cont is equal to the
+ * index of next insn of the "send". (Otherwise, it is considered
+ * "break from proc-closure". See "TAG_BREAK" handling in "vm_throw_start".)
+ *
+ * Normally, "send" instruction is at the last. However, qcall under branch
+ * coverage measurement adds some instructions after the "send".
+ *
+ * Note that "invokesuper", "invokesuperforward" appears instead of "send".
+ */
+static void
+pm_compile_retry_end_label(rb_iseq_t *iseq, LINK_ANCHOR *const ret, LABEL *retry_end_l)
+{
+ INSN *iobj;
+ LINK_ELEMENT *last_elem = LAST_ELEMENT(ret);
+ iobj = IS_INSN(last_elem) ? (INSN*) last_elem : (INSN*) get_prev_insn((INSN*) last_elem);
+ while (!IS_INSN_ID(iobj, send) && !IS_INSN_ID(iobj, invokesuper) && !IS_INSN_ID(iobj, sendforward) && !IS_INSN_ID(iobj, invokesuperforward)) {
+ iobj = (INSN*) get_prev_insn(iobj);
+ }
+ ELEM_INSERT_NEXT(&iobj->link, (LINK_ELEMENT*) retry_end_l);
+
+ // LINK_ANCHOR has a pointer to the last element, but
+ // ELEM_INSERT_NEXT does not update it even if we add an insn to the
+ // last of LINK_ANCHOR. So this updates it manually.
+ if (&iobj->link == LAST_ELEMENT(ret)) {
+ ret->last = (LINK_ELEMENT*) retry_end_l;
+ }
+}
+
+static const char *
+pm_iseq_builtin_function_name(const pm_scope_node_t *scope_node, const pm_node_t *receiver, ID method_id)
+{
+ const char *name = rb_id2name(method_id);
+ static const char prefix[] = "__builtin_";
+ const size_t prefix_len = sizeof(prefix) - 1;
+
+ if (receiver == NULL) {
+ if (UNLIKELY(strncmp(prefix, name, prefix_len) == 0)) {
+ // __builtin_foo
+ return &name[prefix_len];
+ }
+ }
+ else if (PM_NODE_TYPE_P(receiver, PM_CALL_NODE)) {
+ if (PM_NODE_FLAG_P(receiver, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ const pm_call_node_t *cast = (const pm_call_node_t *) receiver;
+ if (pm_constant_id_lookup(scope_node, cast->name) == rb_intern_const("__builtin")) {
+ // __builtin.foo
+ return name;
+ }
+ }
+ }
+ else if (PM_NODE_TYPE_P(receiver, PM_CONSTANT_READ_NODE)) {
+ const pm_constant_read_node_t *cast = (const pm_constant_read_node_t *) receiver;
+ if (pm_constant_id_lookup(scope_node, cast->name) == rb_intern_const("Primitive")) {
+ // Primitive.foo
+ return name;
+ }
+ }
+
+ return NULL;
+}
+
+// Compile Primitive.attr! :leaf, ...
+static int
+pm_compile_builtin_attr(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_arguments_node_t *arguments, const pm_node_location_t *node_location)
+{
+ if (arguments == NULL) {
+ COMPILE_ERROR(iseq, node_location->line, "attr!: no argument");
+ return COMPILE_NG;
+ }
+
+ const pm_node_t *argument;
+ PM_NODE_LIST_FOREACH(&arguments->arguments, index, argument) {
+ if (!PM_NODE_TYPE_P(argument, PM_SYMBOL_NODE)) {
+ COMPILE_ERROR(iseq, node_location->line, "non symbol argument to attr!: %s", pm_node_type(PM_NODE_TYPE(argument)));
+ return COMPILE_NG;
+ }
+
+ VALUE symbol = pm_static_literal_value(iseq, argument, scope_node);
+ VALUE string = rb_sym2str(symbol);
+
+ if (strcmp(RSTRING_PTR(string), "leaf") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_LEAF;
+ }
+ else if (strcmp(RSTRING_PTR(string), "inline_block") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_INLINE_BLOCK;
+ }
+ else if (strcmp(RSTRING_PTR(string), "use_block") == 0) {
+ iseq_set_use_block(iseq);
+ }
+ else if (strcmp(RSTRING_PTR(string), "c_trace") == 0) {
+ // Let the iseq act like a C method in backtraces
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_C_TRACE;
+ }
+ else if (strcmp(RSTRING_PTR(string), "without_interrupts") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_WITHOUT_INTERRUPTS;
+ }
+ else {
+ COMPILE_ERROR(iseq, node_location->line, "unknown argument to attr!: %s", RSTRING_PTR(string));
+ return COMPILE_NG;
+ }
+ }
+
+ return COMPILE_OK;
+}
+
+static int
+pm_compile_builtin_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const pm_scope_node_t *scope_node, const pm_arguments_node_t *arguments, const pm_node_location_t *node_location, int popped)
+{
+ if (arguments == NULL) {
+ COMPILE_ERROR(iseq, node_location->line, "arg!: no argument");
+ return COMPILE_NG;
+ }
+
+ if (arguments->arguments.size != 1) {
+ COMPILE_ERROR(iseq, node_location->line, "arg!: too many argument");
+ return COMPILE_NG;
+ }
+
+ const pm_node_t *argument = arguments->arguments.nodes[0];
+ if (!PM_NODE_TYPE_P(argument, PM_SYMBOL_NODE)) {
+ COMPILE_ERROR(iseq, node_location->line, "non symbol argument to arg!: %s", pm_node_type(PM_NODE_TYPE(argument)));
+ return COMPILE_NG;
+ }
+
+ if (!popped) {
+ ID name = parse_string_symbol(scope_node, ((const pm_symbol_node_t *) argument));
+ int index = ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->local_table_size - get_local_var_idx(iseq, name);
+
+ debugs("id: %s idx: %d\n", rb_id2name(name), index);
+ PUSH_GETLOCAL(ret, *node_location, index, get_lvar_level(iseq));
+ }
+
+ return COMPILE_OK;
+}
+
+static int
+pm_compile_builtin_mandatory_only_method(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_call_node_t *call_node, const pm_node_location_t *node_location)
+{
+ const pm_node_t *ast_node = scope_node->ast_node;
+ if (!PM_NODE_TYPE_P(ast_node, PM_DEF_NODE)) {
+ rb_bug("mandatory_only?: not in method definition");
+ return COMPILE_NG;
+ }
+
+ const pm_def_node_t *def_node = (const pm_def_node_t *) ast_node;
+ const pm_parameters_node_t *parameters_node = def_node->parameters;
+ if (parameters_node == NULL) {
+ rb_bug("mandatory_only?: in method definition with no parameters");
+ return COMPILE_NG;
+ }
+
+ const pm_node_t *body_node = def_node->body;
+ if (body_node == NULL || !PM_NODE_TYPE_P(body_node, PM_STATEMENTS_NODE) || (((const pm_statements_node_t *) body_node)->body.size != 1) || !PM_NODE_TYPE_P(((const pm_statements_node_t *) body_node)->body.nodes[0], PM_IF_NODE)) {
+ rb_bug("mandatory_only?: not in method definition with plain statements");
+ return COMPILE_NG;
+ }
+
+ const pm_if_node_t *if_node = (const pm_if_node_t *) ((const pm_statements_node_t *) body_node)->body.nodes[0];
+ if (if_node->predicate != ((const pm_node_t *) call_node)) {
+ rb_bug("mandatory_only?: can't find mandatory node");
+ return COMPILE_NG;
+ }
+
+ pm_parameters_node_t parameters = {
+ .base = parameters_node->base,
+ .requireds = parameters_node->requireds
+ };
+
+ const pm_def_node_t def = {
+ .base = def_node->base,
+ .name = def_node->name,
+ .receiver = def_node->receiver,
+ .parameters = &parameters,
+ .body = (pm_node_t *) if_node->statements,
+ .locals = {
+ .ids = def_node->locals.ids,
+ .size = parameters_node->requireds.size,
+ .capacity = def_node->locals.capacity
+ }
+ };
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(&def.base, &next_scope_node, scope_node);
+
+ const rb_iseq_t *mandatory_only_iseq = pm_iseq_build(
+ &next_scope_node,
+ rb_iseq_base_label(iseq),
+ rb_iseq_path(iseq),
+ rb_iseq_realpath(iseq),
+ node_location->line,
+ NULL,
+ 0,
+ ISEQ_TYPE_METHOD,
+ ISEQ_COMPILE_DATA(iseq)->option
+ );
+ RB_OBJ_WRITE(iseq, &ISEQ_BODY(iseq)->mandatory_only_iseq, (VALUE)mandatory_only_iseq);
+
+ pm_scope_node_destroy(&next_scope_node);
+ return COMPILE_OK;
+}
+
+static int
+pm_compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, const pm_call_node_t *call_node, const pm_node_location_t *node_location, int popped, const rb_iseq_t *parent_block, const char *builtin_func)
+{
+ const pm_arguments_node_t *arguments = call_node->arguments;
+
+ if (parent_block != NULL) {
+ COMPILE_ERROR(iseq, node_location->line, "should not call builtins here.");
+ return COMPILE_NG;
+ }
+
+#define BUILTIN_INLINE_PREFIX "_bi"
+ char inline_func[sizeof(BUILTIN_INLINE_PREFIX) + DECIMAL_SIZE_OF(int)];
+ bool cconst = false;
+retry:;
+ const struct rb_builtin_function *bf = iseq_builtin_function_lookup(iseq, builtin_func);
+
+ if (bf == NULL) {
+ if (strcmp("cstmt!", builtin_func) == 0 || strcmp("cexpr!", builtin_func) == 0) {
+ // ok
+ }
+ else if (strcmp("cconst!", builtin_func) == 0) {
+ cconst = true;
+ }
+ else if (strcmp("cinit!", builtin_func) == 0) {
+ // ignore
+ return COMPILE_OK;
+ }
+ else if (strcmp("attr!", builtin_func) == 0) {
+ return pm_compile_builtin_attr(iseq, scope_node, arguments, node_location);
+ }
+ else if (strcmp("arg!", builtin_func) == 0) {
+ return pm_compile_builtin_arg(iseq, ret, scope_node, arguments, node_location, popped);
+ }
+ else if (strcmp("mandatory_only?", builtin_func) == 0) {
+ if (popped) {
+ rb_bug("mandatory_only? should be in if condition");
+ }
+ else if (!LIST_INSN_SIZE_ZERO(ret)) {
+ rb_bug("mandatory_only? should be put on top");
+ }
+
+ PUSH_INSN1(ret, *node_location, putobject, Qfalse);
+ return pm_compile_builtin_mandatory_only_method(iseq, scope_node, call_node, node_location);
+ }
+ else if (1) {
+ rb_bug("can't find builtin function:%s", builtin_func);
+ }
+ else {
+ COMPILE_ERROR(iseq, node_location->line, "can't find builtin function:%s", builtin_func);
+ return COMPILE_NG;
+ }
+
+ int inline_index = node_location->line;
+ snprintf(inline_func, sizeof(inline_func), BUILTIN_INLINE_PREFIX "%d", inline_index);
+ builtin_func = inline_func;
+ arguments = NULL;
+ goto retry;
+ }
+
+ if (cconst) {
+ typedef VALUE(*builtin_func0)(void *, VALUE);
+ VALUE const_val = (*(builtin_func0)(uintptr_t)bf->func_ptr)(NULL, Qnil);
+ PUSH_INSN1(ret, *node_location, putobject, const_val);
+ return COMPILE_OK;
+ }
+
+ // fprintf(stderr, "func_name:%s -> %p\n", builtin_func, bf->func_ptr);
+
+ DECL_ANCHOR(args_seq);
+
+ int flags = 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
+ int argc = pm_setup_args(arguments, call_node->block, &flags, &keywords, iseq, args_seq, scope_node, node_location);
+
+ if (argc != bf->argc) {
+ COMPILE_ERROR(iseq, node_location->line, "argc is not match for builtin function:%s (expect %d but %d)", builtin_func, bf->argc, argc);
+ return COMPILE_NG;
+ }
+
+ unsigned int start_index;
+ if (delegate_call_p(iseq, argc, args_seq, &start_index)) {
+ PUSH_INSN2(ret, *node_location, opt_invokebuiltin_delegate, bf, INT2FIX(start_index));
+ }
+ else {
+ PUSH_SEQ(ret, args_seq);
+ PUSH_INSN1(ret, *node_location, invokebuiltin, bf);
+ }
+
+ if (popped) PUSH_INSN(ret, *node_location, pop);
+ return COMPILE_OK;
+}
+
+/**
+ * Compile a call node into the given iseq.
+ */
+static void
+pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, ID method_id, LABEL *start)
+{
+ const pm_location_t *message_loc = &call_node->message_loc;
+ if (message_loc->length == 0) message_loc = &call_node->base.location;
+
+ const pm_node_location_t location = PM_LOCATION_START_LOCATION(message_loc, call_node->base.node_id);
+
+ LABEL *else_label = NEW_LABEL(location.line);
+ LABEL *end_label = NEW_LABEL(location.line);
+ LABEL *retry_end_l = NEW_LABEL(location.line);
+
+ VALUE branches = Qfalse;
+ rb_code_location_t code_location = { 0 };
+ int node_id = location.node_id;
+
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) {
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ uint32_t end_cursor = 0;
+ bool end_found = false;
+
+ if (call_node->closing_loc.length > 0) {
+ uint32_t cursor = call_node->closing_loc.start + call_node->closing_loc.length;
+ end_cursor = cursor;
+ end_found = true;
+ }
+
+ if (call_node->arguments != NULL) {
+ uint32_t cursor = call_node->arguments->base.location.start + call_node->arguments->base.location.length;
+ if (!end_found || cursor > end_cursor) {
+ end_cursor = cursor;
+ end_found = true;
+ }
+ }
+
+ if (call_node->message_loc.length > 0) {
+ uint32_t cursor = call_node->message_loc.start + call_node->message_loc.length;
+ if (!end_found || cursor > end_cursor) {
+ end_cursor = cursor;
+ end_found = true;
+ }
+ }
+
+ if (!end_found) {
+ end_cursor = call_node->closing_loc.start + call_node->closing_loc.length;
+ }
+
+ const pm_line_column_t start_location = PM_NODE_START_LINE_COLUMN(call_node);
+ const pm_line_column_t end_location = pm_line_offset_list_line_column_cached(scope_node->line_offsets, end_cursor, scope_node->start_line, &scope_node->last_line);
+
+ code_location = (rb_code_location_t) {
+ .beg_pos = { .lineno = start_location.line, .column = start_location.column },
+ .end_pos = { .lineno = end_location.line, .column = end_location.column }
+ };
+
+ branches = decl_branch_base(iseq, PTR2NUM(call_node), &code_location, "&.");
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchnil, else_label);
+
+ add_trace_branch_coverage(iseq, ret, &code_location, node_id, 0, "then", branches);
+ }
+
+ LINK_ELEMENT *opt_new_prelude = LAST_ELEMENT(ret);
+
+ int flags = 0;
+ struct rb_callinfo_kwarg *kw_arg = NULL;
+
+ int orig_argc = pm_setup_args(call_node->arguments, call_node->block, &flags, &kw_arg, iseq, ret, scope_node, &location);
+ const rb_iseq_t *previous_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ const rb_iseq_t *block_iseq = NULL;
+
+ if (call_node->block != NULL && PM_NODE_TYPE_P(call_node->block, PM_BLOCK_NODE)) {
+ // Scope associated with the block
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(call_node->block, &next_scope_node, scope_node);
+
+ block_iseq = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, pm_node_line_number_cached(call_node->block, scope_node));
+ pm_scope_node_destroy(&next_scope_node);
+ ISEQ_COMPILE_DATA(iseq)->current_block = block_iseq;
+ }
+ else {
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_VARIABLE_CALL)) {
+ flags |= VM_CALL_VCALL;
+ }
+
+ if (!flags) {
+ flags |= VM_CALL_ARGS_SIMPLE;
+ }
+ }
+
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY)) {
+ flags |= VM_CALL_FCALL;
+ }
+
+ if (!popped && PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE)) {
+ if (flags & VM_CALL_ARGS_BLOCKARG) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ if (flags & VM_CALL_ARGS_SPLAT) {
+ PUSH_INSN1(ret, location, putobject, INT2FIX(-1));
+ PUSH_SEND_WITH_FLAG(ret, location, idAREF, INT2FIX(1), INT2FIX(0));
+ }
+ PUSH_INSN1(ret, location, setn, INT2FIX(orig_argc + 3));
+ PUSH_INSN(ret, location, pop);
+ }
+ else if (flags & VM_CALL_ARGS_SPLAT) {
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(-1));
+ PUSH_SEND_WITH_FLAG(ret, location, idAREF, INT2FIX(1), INT2FIX(0));
+ PUSH_INSN1(ret, location, setn, INT2FIX(orig_argc + 2));
+ PUSH_INSN(ret, location, pop);
+ }
+ else {
+ PUSH_INSN1(ret, location, setn, INT2FIX(orig_argc + 1));
+ }
+ }
+
+ if ((flags & VM_CALL_KW_SPLAT) && (flags & VM_CALL_ARGS_BLOCKARG) && !(flags & VM_CALL_KW_SPLAT_MUT)) {
+ PUSH_INSN(ret, location, splatkw);
+ }
+
+ LABEL *not_basic_new = NEW_LABEL(location.line);
+ LABEL *not_basic_new_finish = NEW_LABEL(location.line);
+
+ bool inline_new = ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction &&
+ method_id == rb_intern("new") &&
+ call_node->block == NULL &&
+ (flags & VM_CALL_ARGS_BLOCKARG) == 0;
+
+ if (inline_new) {
+ if (LAST_ELEMENT(ret) == opt_new_prelude) {
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN(ret, location, swap);
+ }
+ else {
+ ELEM_INSERT_NEXT(opt_new_prelude, &new_insn_body(iseq, location.line, location.node_id, BIN(swap), 0)->link);
+ ELEM_INSERT_NEXT(opt_new_prelude, &new_insn_body(iseq, location.line, location.node_id, BIN(putnil), 0)->link);
+ }
+
+ // Jump unless the receiver uses the "basic" implementation of "new"
+ VALUE ci;
+ if (flags & VM_CALL_FORWARDING) {
+ ci = (VALUE)new_callinfo(iseq, method_id, orig_argc + 1, flags, kw_arg, 0);
+ }
+ else {
+ ci = (VALUE)new_callinfo(iseq, method_id, orig_argc, flags, kw_arg, 0);
+ }
+
+ PUSH_INSN2(ret, location, opt_new, ci, not_basic_new);
+ LABEL_REF(not_basic_new);
+ // optimized path
+ PUSH_SEND_R(ret, location, rb_intern("initialize"), INT2FIX(orig_argc), block_iseq, INT2FIX(flags | VM_CALL_FCALL), kw_arg);
+ PUSH_INSNL(ret, location, jump, not_basic_new_finish);
+
+ PUSH_LABEL(ret, not_basic_new);
+ // Fall back to normal send
+ PUSH_SEND_R(ret, location, method_id, INT2FIX(orig_argc), block_iseq, INT2FIX(flags), kw_arg);
+ PUSH_INSN(ret, location, swap);
+
+ PUSH_LABEL(ret, not_basic_new_finish);
+ PUSH_INSN(ret, location, pop);
+ }
+ else {
+ PUSH_SEND_R(ret, location, method_id, INT2FIX(orig_argc), block_iseq, INT2FIX(flags), kw_arg);
+ }
+
+ if (block_iseq && ISEQ_BODY(block_iseq)->catch_table) {
+ pm_compile_retry_end_label(iseq, ret, retry_end_l);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_BREAK, start, retry_end_l, block_iseq, retry_end_l);
+ }
+
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) {
+ PUSH_INSNL(ret, location, jump, end_label);
+ PUSH_LABEL(ret, else_label);
+ add_trace_branch_coverage(iseq, ret, &code_location, node_id, 1, "else", branches);
+ PUSH_LABEL(ret, end_label);
+ }
+
+ if (PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE) && !popped) {
+ PUSH_INSN(ret, location, pop);
+ }
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ ISEQ_COMPILE_DATA(iseq)->current_block = previous_block;
+}
+
+/**
+ * Compile and return the VALUE associated with the given back reference read
+ * node.
+ */
+static inline VALUE
+pm_compile_back_reference_ref(const pm_scope_node_t *scope_node, const pm_back_reference_read_node_t *node)
+{
+ const char *type = (const char *) (pm_parser_start(scope_node->parser) + node->base.location.start + 1);
+
+ // Since a back reference is `$<char>`, Ruby represents the ID as an
+ // rb_intern on the value after the `$`.
+ return INT2FIX(rb_intern2(type, 1)) << 1 | 1;
+}
+
+/**
+ * Compile and return the VALUE associated with the given numbered reference
+ * read node.
+ */
+static inline VALUE
+pm_compile_numbered_reference_ref(const pm_numbered_reference_read_node_t *node)
+{
+ return INT2FIX(node->number << 1);
+}
+
+static void
+pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition, LABEL **lfinish, bool explicit_receiver)
+{
+#define PUSH_VAL(type) (in_condition ? Qtrue : rb_iseq_defined_string(type))
+
+ // in_condition is the same as compile.c's needstr
+ enum defined_type dtype = DEFINED_NOT_DEFINED;
+ const pm_node_location_t location = *node_location;
+
+ switch (PM_NODE_TYPE(node)) {
+/* DEFINED_NIL ****************************************************************/
+ case PM_NIL_NODE:
+ // defined?(nil)
+ // ^^^
+ dtype = DEFINED_NIL;
+ break;
+/* DEFINED_IVAR ***************************************************************/
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ // defined?(@a)
+ // ^^
+ const pm_instance_variable_read_node_t *cast = (const pm_instance_variable_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ PUSH_INSN3(ret, location, definedivar, ID2SYM(name), get_ivar_ic_value(iseq, name), PUSH_VAL(DEFINED_IVAR));
+
+ return;
+ }
+/* DEFINED_LVAR ***************************************************************/
+ case PM_LOCAL_VARIABLE_READ_NODE:
+ // a = 1; defined?(a)
+ // ^
+ case PM_IT_LOCAL_VARIABLE_READ_NODE:
+ // 1.then { defined?(it) }
+ // ^^
+ dtype = DEFINED_LVAR;
+ break;
+/* DEFINED_GVAR ***************************************************************/
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ // defined?($a)
+ // ^^
+ const pm_global_variable_read_node_t *cast = (const pm_global_variable_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_GVAR), ID2SYM(name), PUSH_VAL(DEFINED_GVAR));
+
+ return;
+ }
+/* DEFINED_CVAR ***************************************************************/
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ // defined?(@@a)
+ // ^^^
+ const pm_class_variable_read_node_t *cast = (const pm_class_variable_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CVAR), ID2SYM(name), PUSH_VAL(DEFINED_CVAR));
+
+ return;
+ }
+/* DEFINED_CONST **************************************************************/
+ case PM_CONSTANT_READ_NODE: {
+ // defined?(A)
+ // ^
+ const pm_constant_read_node_t *cast = (const pm_constant_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CONST), ID2SYM(name), PUSH_VAL(DEFINED_CONST));
+
+ return;
+ }
+/* DEFINED_YIELD **************************************************************/
+ case PM_YIELD_NODE:
+ // defined?(yield)
+ // ^^^^^
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_YIELD), 0, PUSH_VAL(DEFINED_YIELD));
+
+ return;
+/* DEFINED_ZSUPER *************************************************************/
+ case PM_SUPER_NODE: {
+ // defined?(super 1, 2)
+ // ^^^^^^^^^^
+ const pm_super_node_t *cast = (const pm_super_node_t *) node;
+
+ if (cast->block != NULL && !PM_NODE_TYPE_P(cast->block, PM_BLOCK_ARGUMENT_NODE)) {
+ dtype = DEFINED_EXPR;
+ break;
+ }
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_ZSUPER), 0, PUSH_VAL(DEFINED_ZSUPER));
+ return;
+ }
+ case PM_FORWARDING_SUPER_NODE: {
+ // defined?(super)
+ // ^^^^^
+ const pm_forwarding_super_node_t *cast = (const pm_forwarding_super_node_t *) node;
+
+ if (cast->block != NULL) {
+ dtype = DEFINED_EXPR;
+ break;
+ }
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_ZSUPER), 0, PUSH_VAL(DEFINED_ZSUPER));
+ return;
+ }
+/* DEFINED_SELF ***************************************************************/
+ case PM_SELF_NODE:
+ // defined?(self)
+ // ^^^^
+ dtype = DEFINED_SELF;
+ break;
+/* DEFINED_TRUE ***************************************************************/
+ case PM_TRUE_NODE:
+ // defined?(true)
+ // ^^^^
+ dtype = DEFINED_TRUE;
+ break;
+/* DEFINED_FALSE **************************************************************/
+ case PM_FALSE_NODE:
+ // defined?(false)
+ // ^^^^^
+ dtype = DEFINED_FALSE;
+ break;
+/* DEFINED_ASGN ***************************************************************/
+ case PM_CALL_AND_WRITE_NODE:
+ // defined?(a.a &&= 1)
+ // ^^^^^^^^^
+ case PM_CALL_OPERATOR_WRITE_NODE:
+ // defined?(a.a += 1)
+ // ^^^^^^^^
+ case PM_CALL_OR_WRITE_NODE:
+ // defined?(a.a ||= 1)
+ // ^^^^^^^^^
+ case PM_CLASS_VARIABLE_AND_WRITE_NODE:
+ // defined?(@@a &&= 1)
+ // ^^^^^^^^^
+ case PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE:
+ // defined?(@@a += 1)
+ // ^^^^^^^^
+ case PM_CLASS_VARIABLE_OR_WRITE_NODE:
+ // defined?(@@a ||= 1)
+ // ^^^^^^^^^
+ case PM_CLASS_VARIABLE_WRITE_NODE:
+ // defined?(@@a = 1)
+ // ^^^^^^^
+ case PM_CONSTANT_AND_WRITE_NODE:
+ // defined?(A &&= 1)
+ // ^^^^^^^
+ case PM_CONSTANT_OPERATOR_WRITE_NODE:
+ // defined?(A += 1)
+ // ^^^^^^
+ case PM_CONSTANT_OR_WRITE_NODE:
+ // defined?(A ||= 1)
+ // ^^^^^^^
+ case PM_CONSTANT_PATH_AND_WRITE_NODE:
+ // defined?(A::A &&= 1)
+ // ^^^^^^^^^^
+ case PM_CONSTANT_PATH_OPERATOR_WRITE_NODE:
+ // defined?(A::A += 1)
+ // ^^^^^^^^^
+ case PM_CONSTANT_PATH_OR_WRITE_NODE:
+ // defined?(A::A ||= 1)
+ // ^^^^^^^^^^
+ case PM_CONSTANT_PATH_WRITE_NODE:
+ // defined?(A::A = 1)
+ // ^^^^^^^^
+ case PM_CONSTANT_WRITE_NODE:
+ // defined?(A = 1)
+ // ^^^^^
+ case PM_GLOBAL_VARIABLE_AND_WRITE_NODE:
+ // defined?($a &&= 1)
+ // ^^^^^^^^
+ case PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE:
+ // defined?($a += 1)
+ // ^^^^^^^
+ case PM_GLOBAL_VARIABLE_OR_WRITE_NODE:
+ // defined?($a ||= 1)
+ // ^^^^^^^^
+ case PM_GLOBAL_VARIABLE_WRITE_NODE:
+ // defined?($a = 1)
+ // ^^^^^^
+ case PM_INDEX_AND_WRITE_NODE:
+ // defined?(a[1] &&= 1)
+ // ^^^^^^^^^^
+ case PM_INDEX_OPERATOR_WRITE_NODE:
+ // defined?(a[1] += 1)
+ // ^^^^^^^^^
+ case PM_INDEX_OR_WRITE_NODE:
+ // defined?(a[1] ||= 1)
+ // ^^^^^^^^^^
+ case PM_INSTANCE_VARIABLE_AND_WRITE_NODE:
+ // defined?(@a &&= 1)
+ // ^^^^^^^^
+ case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE:
+ // defined?(@a += 1)
+ // ^^^^^^^
+ case PM_INSTANCE_VARIABLE_OR_WRITE_NODE:
+ // defined?(@a ||= 1)
+ // ^^^^^^^^
+ case PM_INSTANCE_VARIABLE_WRITE_NODE:
+ // defined?(@a = 1)
+ // ^^^^^^
+ case PM_LOCAL_VARIABLE_AND_WRITE_NODE:
+ // defined?(a &&= 1)
+ // ^^^^^^^
+ case PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE:
+ // defined?(a += 1)
+ // ^^^^^^
+ case PM_LOCAL_VARIABLE_OR_WRITE_NODE:
+ // defined?(a ||= 1)
+ // ^^^^^^^
+ case PM_LOCAL_VARIABLE_WRITE_NODE:
+ // defined?(a = 1)
+ // ^^^^^
+ case PM_MULTI_WRITE_NODE:
+ // defined?((a, = 1))
+ // ^^^^^^
+ dtype = DEFINED_ASGN;
+ break;
+/* DEFINED_EXPR ***************************************************************/
+ case PM_ALIAS_GLOBAL_VARIABLE_NODE:
+ // defined?((alias $a $b))
+ // ^^^^^^^^^^^
+ case PM_ALIAS_METHOD_NODE:
+ // defined?((alias a b))
+ // ^^^^^^^^^
+ case PM_AND_NODE:
+ // defined?(a and b)
+ // ^^^^^^^
+ case PM_BREAK_NODE:
+ // defined?(break 1)
+ // ^^^^^^^
+ case PM_CASE_MATCH_NODE:
+ // defined?(case 1; in 1; end)
+ // ^^^^^^^^^^^^^^^^^
+ case PM_CASE_NODE:
+ // defined?(case 1; when 1; end)
+ // ^^^^^^^^^^^^^^^^^^^
+ case PM_CLASS_NODE:
+ // defined?(class Foo; end)
+ // ^^^^^^^^^^^^^^
+ case PM_DEF_NODE:
+ // defined?(def a() end)
+ // ^^^^^^^^^^^
+ case PM_DEFINED_NODE:
+ // defined?(defined?(a))
+ // ^^^^^^^^^^^
+ case PM_FLIP_FLOP_NODE:
+ // defined?(not (a .. b))
+ // ^^^^^^
+ case PM_FLOAT_NODE:
+ // defined?(1.0)
+ // ^^^
+ case PM_FOR_NODE:
+ // defined?(for a in 1 do end)
+ // ^^^^^^^^^^^^^^^^^
+ case PM_IF_NODE:
+ // defined?(if a then end)
+ // ^^^^^^^^^^^^^
+ case PM_IMAGINARY_NODE:
+ // defined?(1i)
+ // ^^
+ case PM_INTEGER_NODE:
+ // defined?(1)
+ // ^
+ case PM_INTERPOLATED_MATCH_LAST_LINE_NODE:
+ // defined?(not /#{1}/)
+ // ^^^^^^
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE:
+ // defined?(/#{1}/)
+ // ^^^^^^
+ case PM_INTERPOLATED_STRING_NODE:
+ // defined?("#{1}")
+ // ^^^^^^
+ case PM_INTERPOLATED_SYMBOL_NODE:
+ // defined?(:"#{1}")
+ // ^^^^^^^
+ case PM_INTERPOLATED_X_STRING_NODE:
+ // defined?(`#{1}`)
+ // ^^^^^^
+ case PM_LAMBDA_NODE:
+ // defined?(-> {})
+ // ^^^^^
+ case PM_MATCH_LAST_LINE_NODE:
+ // defined?(not //)
+ // ^^^^^^
+ case PM_MATCH_PREDICATE_NODE:
+ // defined?(1 in 1)
+ // ^^^^^^
+ case PM_MATCH_REQUIRED_NODE:
+ // defined?(1 => 1)
+ // ^^^^^^
+ case PM_MATCH_WRITE_NODE:
+ // defined?(/(?<a>)/ =~ "")
+ // ^^^^^^^^^^^^^^
+ case PM_MODULE_NODE:
+ // defined?(module A end)
+ // ^^^^^^^^^^^^
+ case PM_NEXT_NODE:
+ // defined?(next 1)
+ // ^^^^^^
+ case PM_OR_NODE:
+ // defined?(a or b)
+ // ^^^^^^
+ case PM_POST_EXECUTION_NODE:
+ // defined?((END {}))
+ // ^^^^^^^^
+ case PM_RANGE_NODE:
+ // defined?(1..1)
+ // ^^^^
+ case PM_RATIONAL_NODE:
+ // defined?(1r)
+ // ^^
+ case PM_REDO_NODE:
+ // defined?(redo)
+ // ^^^^
+ case PM_REGULAR_EXPRESSION_NODE:
+ // defined?(//)
+ // ^^
+ case PM_RESCUE_MODIFIER_NODE:
+ // defined?(a rescue b)
+ // ^^^^^^^^^^
+ case PM_RETRY_NODE:
+ // defined?(retry)
+ // ^^^^^
+ case PM_RETURN_NODE:
+ // defined?(return)
+ // ^^^^^^
+ case PM_SINGLETON_CLASS_NODE:
+ // defined?(class << self; end)
+ // ^^^^^^^^^^^^^^^^^^
+ case PM_SOURCE_ENCODING_NODE:
+ // defined?(__ENCODING__)
+ // ^^^^^^^^^^^^
+ case PM_SOURCE_FILE_NODE:
+ // defined?(__FILE__)
+ // ^^^^^^^^
+ case PM_SOURCE_LINE_NODE:
+ // defined?(__LINE__)
+ // ^^^^^^^^
+ case PM_STRING_NODE:
+ // defined?("")
+ // ^^
+ case PM_SYMBOL_NODE:
+ // defined?(:a)
+ // ^^
+ case PM_UNDEF_NODE:
+ // defined?((undef a))
+ // ^^^^^^^
+ case PM_UNLESS_NODE:
+ // defined?(unless a then end)
+ // ^^^^^^^^^^^^^^^^^
+ case PM_UNTIL_NODE:
+ // defined?(until a do end)
+ // ^^^^^^^^^^^^^^
+ case PM_WHILE_NODE:
+ // defined?(while a do end)
+ // ^^^^^^^^^^^^^^
+ case PM_X_STRING_NODE:
+ // defined?(``)
+ // ^^
+ dtype = DEFINED_EXPR;
+ break;
+/* DEFINED_REF ****************************************************************/
+ case PM_BACK_REFERENCE_READ_NODE: {
+ // defined?($+)
+ // ^^
+ const pm_back_reference_read_node_t *cast = (const pm_back_reference_read_node_t *) node;
+ VALUE ref = pm_compile_back_reference_ref(scope_node, cast);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_REF), ref, PUSH_VAL(DEFINED_GVAR));
+
+ return;
+ }
+ case PM_NUMBERED_REFERENCE_READ_NODE: {
+ // defined?($1)
+ // ^^
+ const pm_numbered_reference_read_node_t *cast = (const pm_numbered_reference_read_node_t *) node;
+ VALUE ref = pm_compile_numbered_reference_ref(cast);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_REF), ref, PUSH_VAL(DEFINED_GVAR));
+
+ return;
+ }
+/* DEFINED_CONST_FROM *********************************************************/
+ case PM_CONSTANT_PATH_NODE: {
+ // defined?(A::A)
+ // ^^^^
+ const pm_constant_path_node_t *cast = (const pm_constant_path_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ if (cast->parent != NULL) {
+ if (!lfinish[1]) lfinish[1] = NEW_LABEL(location.line);
+ pm_compile_defined_expr0(iseq, cast->parent, node_location, ret, popped, scope_node, true, lfinish, false);
+
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ PM_COMPILE(cast->parent);
+ }
+ else {
+ PUSH_INSN1(ret, location, putobject, rb_cObject);
+ }
+
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CONST_FROM), ID2SYM(name), PUSH_VAL(DEFINED_CONST));
+ return;
+ }
+/* Containers *****************************************************************/
+ case PM_BEGIN_NODE: {
+ // defined?(begin end)
+ // ^^^^^^^^^
+ const pm_begin_node_t *cast = (const pm_begin_node_t *) node;
+
+ if (cast->rescue_clause == NULL && cast->ensure_clause == NULL && cast->else_clause == NULL) {
+ if (cast->statements == NULL) {
+ // If we have empty statements, then we want to return "nil".
+ dtype = DEFINED_NIL;
+ }
+ else if (cast->statements->body.size == 1) {
+ // If we have a begin node that is wrapping a single statement
+ // then we want to recurse down to that statement and compile
+ // it.
+ pm_compile_defined_expr0(iseq, cast->statements->body.nodes[0], node_location, ret, popped, scope_node, in_condition, lfinish, false);
+ return;
+ }
+ else {
+ // Otherwise, we have a begin wrapping multiple statements, in
+ // which case this is defined as "expression".
+ dtype = DEFINED_EXPR;
+ }
+ } else {
+ // If we have any of the other clauses besides the main begin/end,
+ // this is defined as "expression".
+ dtype = DEFINED_EXPR;
+ }
+
+ break;
+ }
+ case PM_PARENTHESES_NODE: {
+ // defined?(())
+ // ^^
+ const pm_parentheses_node_t *cast = (const pm_parentheses_node_t *) node;
+
+ if (cast->body == NULL) {
+ // If we have empty parentheses, then we want to return "nil".
+ dtype = DEFINED_NIL;
+ }
+ else if (PM_NODE_TYPE_P(cast->body, PM_STATEMENTS_NODE) && !PM_NODE_FLAG_P(cast, PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS)) {
+ // If we have a parentheses node that is wrapping a single statement
+ // then we want to recurse down to that statement and compile it.
+ pm_compile_defined_expr0(iseq, ((const pm_statements_node_t *) cast->body)->body.nodes[0], node_location, ret, popped, scope_node, in_condition, lfinish, false);
+ return;
+ }
+ else {
+ // Otherwise, we have parentheses wrapping multiple statements, in
+ // which case this is defined as "expression".
+ dtype = DEFINED_EXPR;
+ }
+
+ break;
+ }
+ case PM_ARRAY_NODE: {
+ // defined?([])
+ // ^^
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+
+ if (cast->elements.size > 0 && !lfinish[1]) {
+ lfinish[1] = NEW_LABEL(location.line);
+ }
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ pm_compile_defined_expr0(iseq, cast->elements.nodes[index], node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ }
+
+ dtype = DEFINED_EXPR;
+ break;
+ }
+ case PM_HASH_NODE:
+ // defined?({ a: 1 })
+ // ^^^^^^^^
+ case PM_KEYWORD_HASH_NODE: {
+ // defined?(a(a: 1))
+ // ^^^^
+ const pm_node_list_t *elements;
+
+ if (PM_NODE_TYPE_P(node, PM_HASH_NODE)) {
+ elements = &((const pm_hash_node_t *) node)->elements;
+ }
+ else {
+ elements = &((const pm_keyword_hash_node_t *) node)->elements;
+ }
+
+ if (elements->size > 0 && !lfinish[1]) {
+ lfinish[1] = NEW_LABEL(location.line);
+ }
+
+ for (size_t index = 0; index < elements->size; index++) {
+ pm_compile_defined_expr0(iseq, elements->nodes[index], node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ }
+
+ dtype = DEFINED_EXPR;
+ break;
+ }
+ case PM_ASSOC_NODE: {
+ // defined?({ a: 1 })
+ // ^^^^
+ const pm_assoc_node_t *cast = (const pm_assoc_node_t *) node;
+
+ pm_compile_defined_expr0(iseq, cast->key, node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ pm_compile_defined_expr0(iseq, cast->value, node_location, ret, popped, scope_node, true, lfinish, false);
+
+ return;
+ }
+ case PM_ASSOC_SPLAT_NODE: {
+ // defined?({ **a })
+ // ^^^^
+ const pm_assoc_splat_node_t *cast = (const pm_assoc_splat_node_t *) node;
+
+ if (cast->value == NULL) {
+ dtype = DEFINED_EXPR;
+ break;
+ }
+
+ pm_compile_defined_expr0(iseq, cast->value, node_location, ret, popped, scope_node, true, lfinish, false);
+ return;
+ }
+ case PM_IMPLICIT_NODE: {
+ // defined?({ a: })
+ // ^^
+ const pm_implicit_node_t *cast = (const pm_implicit_node_t *) node;
+ pm_compile_defined_expr0(iseq, cast->value, node_location, ret, popped, scope_node, in_condition, lfinish, false);
+ return;
+ }
+ case PM_CALL_NODE: {
+#define BLOCK_P(cast) ((cast)->block != NULL && PM_NODE_TYPE_P((cast)->block, PM_BLOCK_NODE))
+
+ // defined?(a(1, 2, 3))
+ // ^^^^^^^^^^
+ const pm_call_node_t *cast = ((const pm_call_node_t *) node);
+
+ if (BLOCK_P(cast)) {
+ dtype = DEFINED_EXPR;
+ break;
+ }
+
+ if (cast->receiver || cast->arguments || (cast->block && PM_NODE_TYPE_P(cast->block, PM_BLOCK_ARGUMENT_NODE))) {
+ if (!lfinish[1]) lfinish[1] = NEW_LABEL(location.line);
+ if (!lfinish[2]) lfinish[2] = NEW_LABEL(location.line);
+ }
+
+ if (cast->arguments) {
+ pm_compile_defined_expr0(iseq, (const pm_node_t *) cast->arguments, node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ }
+
+ if (cast->block && PM_NODE_TYPE_P(cast->block, PM_BLOCK_ARGUMENT_NODE)) {
+ pm_compile_defined_expr0(iseq, cast->block, node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ }
+
+ if (cast->receiver) {
+ if (PM_NODE_TYPE_P(cast->receiver, PM_CALL_NODE) && !BLOCK_P((const pm_call_node_t *) cast->receiver)) {
+ // Special behavior here where we chain calls together. This is
+ // the only path that sets explicit_receiver to true.
+ pm_compile_defined_expr0(iseq, cast->receiver, node_location, ret, popped, scope_node, true, lfinish, true);
+ PUSH_INSNL(ret, location, branchunless, lfinish[2]);
+
+ const pm_call_node_t *receiver = (const pm_call_node_t *) cast->receiver;
+ ID method_id = pm_constant_id_lookup(scope_node, receiver->name);
+
+ pm_compile_call(iseq, receiver, ret, popped, scope_node, method_id, NULL);
+ }
+ else {
+ pm_compile_defined_expr0(iseq, cast->receiver, node_location, ret, popped, scope_node, true, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ PM_COMPILE(cast->receiver);
+ }
+
+ ID method_id = pm_constant_id_lookup(scope_node, cast->name);
+
+ if (explicit_receiver) PUSH_INSN(ret, location, dup);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_METHOD), rb_id2sym(method_id), PUSH_VAL(DEFINED_METHOD));
+ }
+ else {
+ ID method_id = pm_constant_id_lookup(scope_node, cast->name);
+
+ PUSH_INSN(ret, location, putself);
+ if (explicit_receiver) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_FUNC), rb_id2sym(method_id), PUSH_VAL(DEFINED_METHOD));
+ }
+
+ return;
+
+#undef BLOCK_P
+ }
+ case PM_ARGUMENTS_NODE: {
+ // defined?(a(1, 2, 3))
+ // ^^^^^^^
+ const pm_arguments_node_t *cast = (const pm_arguments_node_t *) node;
+
+ for (size_t index = 0; index < cast->arguments.size; index++) {
+ pm_compile_defined_expr0(iseq, cast->arguments.nodes[index], node_location, ret, popped, scope_node, in_condition, lfinish, false);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+ }
+
+ dtype = DEFINED_EXPR;
+ break;
+ }
+ case PM_BLOCK_ARGUMENT_NODE:
+ // defined?(a(&b))
+ // ^^
+ dtype = DEFINED_EXPR;
+ break;
+ case PM_FORWARDING_ARGUMENTS_NODE:
+ // def a(...) = defined?(a(...))
+ // ^^^
+ dtype = DEFINED_EXPR;
+ break;
+ case PM_SPLAT_NODE: {
+ // def a(*) = defined?(a(*))
+ // ^
+ const pm_splat_node_t *cast = (const pm_splat_node_t *) node;
+
+ if (cast->expression == NULL) {
+ dtype = DEFINED_EXPR;
+ break;
+ }
+
+ pm_compile_defined_expr0(iseq, cast->expression, node_location, ret, popped, scope_node, in_condition, lfinish, false);
+
+ if (!lfinish[1]) lfinish[1] = NEW_LABEL(location.line);
+ PUSH_INSNL(ret, location, branchunless, lfinish[1]);
+
+ dtype = DEFINED_EXPR;
+ break;
+ }
+ case PM_SHAREABLE_CONSTANT_NODE:
+ // # shareable_constant_value: literal
+ // defined?(A = 1)
+ // ^^^^^
+ pm_compile_defined_expr0(iseq, ((const pm_shareable_constant_node_t *) node)->write, node_location, ret, popped, scope_node, in_condition, lfinish, explicit_receiver);
+ return;
+/* Unreachable (parameters) ***************************************************/
+ case PM_BLOCK_LOCAL_VARIABLE_NODE:
+ case PM_BLOCK_PARAMETER_NODE:
+ case PM_BLOCK_PARAMETERS_NODE:
+ case PM_FORWARDING_PARAMETER_NODE:
+ case PM_IMPLICIT_REST_NODE:
+ case PM_IT_PARAMETERS_NODE:
+ case PM_PARAMETERS_NODE:
+ case PM_KEYWORD_REST_PARAMETER_NODE:
+ case PM_NO_KEYWORDS_PARAMETER_NODE:
+ case PM_NO_BLOCK_PARAMETER_NODE:
+ case PM_NUMBERED_PARAMETERS_NODE:
+ case PM_OPTIONAL_KEYWORD_PARAMETER_NODE:
+ case PM_OPTIONAL_PARAMETER_NODE:
+ case PM_REQUIRED_KEYWORD_PARAMETER_NODE:
+ case PM_REQUIRED_PARAMETER_NODE:
+ case PM_REST_PARAMETER_NODE:
+/* Unreachable (pattern matching) *********************************************/
+ case PM_ALTERNATION_PATTERN_NODE:
+ case PM_ARRAY_PATTERN_NODE:
+ case PM_CAPTURE_PATTERN_NODE:
+ case PM_FIND_PATTERN_NODE:
+ case PM_HASH_PATTERN_NODE:
+ case PM_PINNED_EXPRESSION_NODE:
+ case PM_PINNED_VARIABLE_NODE:
+/* Unreachable (indirect writes) **********************************************/
+ case PM_CALL_TARGET_NODE:
+ case PM_CLASS_VARIABLE_TARGET_NODE:
+ case PM_CONSTANT_PATH_TARGET_NODE:
+ case PM_CONSTANT_TARGET_NODE:
+ case PM_GLOBAL_VARIABLE_TARGET_NODE:
+ case PM_INDEX_TARGET_NODE:
+ case PM_INSTANCE_VARIABLE_TARGET_NODE:
+ case PM_LOCAL_VARIABLE_TARGET_NODE:
+ case PM_MULTI_TARGET_NODE:
+/* Unreachable (clauses) ******************************************************/
+ case PM_ELSE_NODE:
+ case PM_ENSURE_NODE:
+ case PM_IN_NODE:
+ case PM_RESCUE_NODE:
+ case PM_WHEN_NODE:
+/* Unreachable (miscellaneous) ************************************************/
+ case PM_BLOCK_NODE:
+ case PM_EMBEDDED_STATEMENTS_NODE:
+ case PM_EMBEDDED_VARIABLE_NODE:
+ case PM_ERROR_RECOVERY_NODE:
+ case PM_PRE_EXECUTION_NODE:
+ case PM_PROGRAM_NODE:
+ case PM_SCOPE_NODE:
+ case PM_STATEMENTS_NODE:
+ rb_bug("Unreachable node in defined?: %s", pm_node_type(PM_NODE_TYPE(node)));
+ }
+
+ RUBY_ASSERT(dtype != DEFINED_NOT_DEFINED);
+ PUSH_INSN1(ret, location, putobject, PUSH_VAL(dtype));
+
+#undef PUSH_VAL
+}
+
+static void
+pm_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition, LABEL **lfinish)
+{
+ LINK_ELEMENT *lcur = ret->last;
+ pm_compile_defined_expr0(iseq, node, node_location, ret, popped, scope_node, in_condition, lfinish, false);
+
+ if (lfinish[1]) {
+ LABEL *lstart = NEW_LABEL(node_location->line);
+ LABEL *lend = NEW_LABEL(node_location->line);
+
+ struct rb_iseq_new_with_callback_callback_func *ifunc =
+ rb_iseq_new_with_callback_new_callback(build_defined_rescue_iseq, NULL);
+
+ const rb_iseq_t *rescue = new_child_iseq_with_callback(
+ iseq,
+ ifunc,
+ rb_str_concat(rb_str_new2("defined guard in "), ISEQ_BODY(iseq)->location.label),
+ iseq,
+ ISEQ_TYPE_RESCUE,
+ 0
+ );
+
+ lstart->rescued = LABEL_RESCUE_BEG;
+ lend->rescued = LABEL_RESCUE_END;
+
+ APPEND_LABEL(ret, lcur, lstart);
+ PUSH_LABEL(ret, lend);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
+ }
+}
+
+static void
+pm_compile_defined_expr(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node, bool in_condition)
+{
+ LABEL *lfinish[3];
+ LINK_ELEMENT *last = ret->last;
+
+ lfinish[0] = NEW_LABEL(node_location->line);
+ lfinish[1] = 0;
+ lfinish[2] = 0;
+
+ if (!popped) {
+ pm_defined_expr(iseq, node, node_location, ret, popped, scope_node, in_condition, lfinish);
+ }
+
+ if (lfinish[1]) {
+ ELEM_INSERT_NEXT(last, &new_insn_body(iseq, node_location->line, node_location->node_id, BIN(putnil), 0)->link);
+ PUSH_INSN(ret, *node_location, swap);
+
+ if (lfinish[2]) PUSH_LABEL(ret, lfinish[2]);
+ PUSH_INSN(ret, *node_location, pop);
+ PUSH_LABEL(ret, lfinish[1]);
+
+ }
+
+ PUSH_LABEL(ret, lfinish[0]);
+}
+
+// This is exactly the same as add_ensure_iseq, except it compiled
+// the node as a Prism node, and not a CRuby node
+static void
+pm_add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return, pm_scope_node_t *scope_node)
+{
+ RUBY_ASSERT(can_add_ensure_iseq(iseq));
+
+ struct iseq_compile_data_ensure_node_stack *enlp =
+ ISEQ_COMPILE_DATA(iseq)->ensure_node_stack;
+ struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
+ DECL_ANCHOR(ensure);
+
+ while (enlp) {
+ if (enlp->erange != NULL) {
+ DECL_ANCHOR(ensure_part);
+ LABEL *lstart = NEW_LABEL(0);
+ LABEL *lend = NEW_LABEL(0);
+
+ add_ensure_range(iseq, enlp->erange, lstart, lend);
+
+ ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enlp->prev;
+ PUSH_LABEL(ensure_part, lstart);
+ bool popped = true;
+ PM_COMPILE_INTO_ANCHOR(ensure_part, (const pm_node_t *) enlp->ensure_node);
+ PUSH_LABEL(ensure_part, lend);
+ PUSH_SEQ(ensure, ensure_part);
+ }
+ else {
+ if (!is_return) {
+ break;
+ }
+ }
+ enlp = enlp->prev;
+ }
+ ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = prev_enlp;
+ PUSH_SEQ(ret, ensure);
+}
+
+
+
+/**
+ * Insert a local into the local table for the iseq. This is used to create the
+ * local table in the correct order while compiling the scope. The locals being
+ * inserted are regular named locals, as opposed to special forwarding locals.
+ */
+static void
+pm_insert_local_index(pm_constant_id_t constant_id, int local_index, pm_index_lookup_table_t *index_lookup_table, rb_ast_id_table_t *local_table_for_iseq, pm_scope_node_t *scope_node)
+{
+ RUBY_ASSERT((constant_id & PM_SPECIAL_CONSTANT_FLAG) == 0);
+
+ ID local = pm_constant_id_lookup(scope_node, constant_id);
+ local_table_for_iseq->ids[local_index] = local;
+ pm_index_lookup_table_insert(index_lookup_table, constant_id, local_index);
+}
+
+/**
+ * Insert a special forwarding local (*, **, &, ...) into the local table.
+ */
+static void
+pm_insert_local_special(pm_constant_id_t special_id, ID local_name, int local_index, pm_index_lookup_table_t *index_lookup_table, rb_ast_id_table_t *local_table_for_iseq)
+{
+ local_table_for_iseq->ids[local_index] = local_name;
+ pm_index_lookup_table_insert(index_lookup_table, special_id, local_index);
+}
+
+/**
+ * Compile the locals of a multi target node that is used as a positional
+ * parameter in a method, block, or lambda definition. Note that this doesn't
+ * actually add any instructions to the iseq. Instead, it adds locals to the
+ * local and index lookup tables and increments the local index as necessary.
+ */
+static int
+pm_compile_destructured_param_locals(const pm_multi_target_node_t *node, pm_index_lookup_table_t *index_lookup_table, rb_ast_id_table_t *local_table_for_iseq, pm_scope_node_t *scope_node, int local_index)
+{
+ for (size_t index = 0; index < node->lefts.size; index++) {
+ const pm_node_t *left = node->lefts.nodes[index];
+
+ if (PM_NODE_TYPE_P(left, PM_REQUIRED_PARAMETER_NODE)) {
+ if (!PM_NODE_FLAG_P(left, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ pm_insert_local_index(((const pm_required_parameter_node_t *) left)->name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
+ local_index++;
+ }
+ }
+ else {
+ RUBY_ASSERT(PM_NODE_TYPE_P(left, PM_MULTI_TARGET_NODE));
+ local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) left, index_lookup_table, local_table_for_iseq, scope_node, local_index);
+ }
+ }
+
+ if (node->rest != NULL && PM_NODE_TYPE_P(node->rest, PM_SPLAT_NODE)) {
+ const pm_splat_node_t *rest = (const pm_splat_node_t *) node->rest;
+
+ if (rest->expression != NULL) {
+ RUBY_ASSERT(PM_NODE_TYPE_P(rest->expression, PM_REQUIRED_PARAMETER_NODE));
+
+ if (!PM_NODE_FLAG_P(rest->expression, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ pm_insert_local_index(((const pm_required_parameter_node_t *) rest->expression)->name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
+ local_index++;
+ }
+ }
+ }
+
+ for (size_t index = 0; index < node->rights.size; index++) {
+ const pm_node_t *right = node->rights.nodes[index];
+
+ if (PM_NODE_TYPE_P(right, PM_REQUIRED_PARAMETER_NODE)) {
+ if (!PM_NODE_FLAG_P(right, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ pm_insert_local_index(((const pm_required_parameter_node_t *) right)->name, local_index, index_lookup_table, local_table_for_iseq, scope_node);
+ local_index++;
+ }
+ }
+ else {
+ RUBY_ASSERT(PM_NODE_TYPE_P(right, PM_MULTI_TARGET_NODE));
+ local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) right, index_lookup_table, local_table_for_iseq, scope_node, local_index);
+ }
+ }
+
+ return local_index;
+}
+
+/**
+ * Compile a required parameter node that is part of a destructure that is used
+ * as a positional parameter in a method, block, or lambda definition.
+ */
+static inline void
+pm_compile_destructured_param_write(rb_iseq_t *iseq, const pm_required_parameter_node_t *node, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, node->name, 0);
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+}
+
+/**
+ * Compile a multi target node that is used as a positional parameter in a
+ * method, block, or lambda definition. Note that this is effectively the same
+ * as a multi write, but with the added context that all of the targets
+ * contained in the write are required parameter nodes. With this context, we
+ * know they won't have any parent expressions so we build a separate code path
+ * for this simplified case.
+ */
+static void
+pm_compile_destructured_param_writes(rb_iseq_t *iseq, const pm_multi_target_node_t *node, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ bool has_rest = (node->rest && PM_NODE_TYPE_P(node->rest, PM_SPLAT_NODE) && (((const pm_splat_node_t *) node->rest)->expression) != NULL);
+ bool has_rights = node->rights.size > 0;
+
+ int flag = (has_rest || has_rights) ? 1 : 0;
+ PUSH_INSN2(ret, location, expandarray, INT2FIX(node->lefts.size), INT2FIX(flag));
+
+ for (size_t index = 0; index < node->lefts.size; index++) {
+ const pm_node_t *left = node->lefts.nodes[index];
+
+ if (PM_NODE_TYPE_P(left, PM_REQUIRED_PARAMETER_NODE)) {
+ pm_compile_destructured_param_write(iseq, (const pm_required_parameter_node_t *) left, ret, scope_node);
+ }
+ else {
+ RUBY_ASSERT(PM_NODE_TYPE_P(left, PM_MULTI_TARGET_NODE));
+ pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) left, ret, scope_node);
+ }
+ }
+
+ if (has_rest) {
+ if (has_rights) {
+ PUSH_INSN2(ret, location, expandarray, INT2FIX(node->rights.size), INT2FIX(3));
+ }
+
+ const pm_node_t *rest = ((const pm_splat_node_t *) node->rest)->expression;
+ RUBY_ASSERT(PM_NODE_TYPE_P(rest, PM_REQUIRED_PARAMETER_NODE));
+
+ pm_compile_destructured_param_write(iseq, (const pm_required_parameter_node_t *) rest, ret, scope_node);
+ }
+
+ if (has_rights) {
+ if (!has_rest) {
+ PUSH_INSN2(ret, location, expandarray, INT2FIX(node->rights.size), INT2FIX(2));
+ }
+
+ for (size_t index = 0; index < node->rights.size; index++) {
+ const pm_node_t *right = node->rights.nodes[index];
+
+ if (PM_NODE_TYPE_P(right, PM_REQUIRED_PARAMETER_NODE)) {
+ pm_compile_destructured_param_write(iseq, (const pm_required_parameter_node_t *) right, ret, scope_node);
+ }
+ else {
+ RUBY_ASSERT(PM_NODE_TYPE_P(right, PM_MULTI_TARGET_NODE));
+ pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) right, ret, scope_node);
+ }
+ }
+ }
+}
+
+/**
+ * This is a node in the multi target state linked list. It tracks the
+ * information for a particular target that necessarily has a parent expression.
+ */
+typedef struct pm_multi_target_state_node {
+ // The pointer to the topn instruction that will need to be modified after
+ // we know the total stack size of all of the targets.
+ INSN *topn;
+
+ // The index of the stack from the base of the entire multi target at which
+ // the parent expression is located.
+ size_t stack_index;
+
+ // The number of slots in the stack that this node occupies.
+ size_t stack_size;
+
+ // The position of the node in the list of targets.
+ size_t position;
+
+ // A pointer to the next node in this linked list.
+ struct pm_multi_target_state_node *next;
+} pm_multi_target_state_node_t;
+
+/**
+ * As we're compiling a multi target, we need to track additional information
+ * whenever there is a parent expression on the left hand side of the target.
+ * This is because we need to go back and tell the expression where to fetch its
+ * parent expression from the stack. We use a linked list of nodes to track this
+ * information.
+ */
+typedef struct {
+ // The total number of slots in the stack that this multi target occupies.
+ size_t stack_size;
+
+ // The position of the current node being compiled. This is forwarded to
+ // nodes when they are allocated.
+ size_t position;
+
+ // A pointer to the head of this linked list.
+ pm_multi_target_state_node_t *head;
+
+ // A pointer to the tail of this linked list.
+ pm_multi_target_state_node_t *tail;
+} pm_multi_target_state_t;
+
+/**
+ * Push a new state node onto the multi target state.
+ */
+static void
+pm_multi_target_state_push(pm_multi_target_state_t *state, INSN *topn, size_t stack_size)
+{
+ pm_multi_target_state_node_t *node = ALLOC(pm_multi_target_state_node_t);
+ node->topn = topn;
+ node->stack_index = state->stack_size + 1;
+ node->stack_size = stack_size;
+ node->position = state->position;
+ node->next = NULL;
+
+ if (state->head == NULL) {
+ state->head = node;
+ state->tail = node;
+ }
+ else {
+ state->tail->next = node;
+ state->tail = node;
+ }
+
+ state->stack_size += stack_size;
+}
+
+/**
+ * Walk through a multi target state's linked list and update the topn
+ * instructions that were inserted into the write sequence to make sure they can
+ * correctly retrieve their parent expressions.
+ */
+static void
+pm_multi_target_state_update(pm_multi_target_state_t *state)
+{
+ // If nothing was ever pushed onto the stack, then we don't need to do any
+ // kind of updates.
+ if (state->stack_size == 0) return;
+
+ pm_multi_target_state_node_t *current = state->head;
+ pm_multi_target_state_node_t *previous;
+
+ while (current != NULL) {
+ VALUE offset = INT2FIX(state->stack_size - current->stack_index + current->position);
+ current->topn->operands[0] = offset;
+
+ // stack_size will be > 1 in the case that we compiled an index target
+ // and it had arguments. In this case, we use multiple topn instructions
+ // to grab up all of the arguments as well, so those offsets need to be
+ // updated as well.
+ if (current->stack_size > 1) {
+ INSN *insn = current->topn;
+
+ for (size_t index = 1; index < current->stack_size; index += 1) {
+ LINK_ELEMENT *element = get_next_insn(insn);
+ RUBY_ASSERT(IS_INSN(element));
+
+ insn = (INSN *) element;
+ RUBY_ASSERT(insn->insn_id == BIN(topn));
+
+ insn->operands[0] = offset;
+ }
+ }
+
+ previous = current;
+ current = current->next;
+
+ SIZED_FREE(previous);
+ }
+}
+
+static void
+pm_compile_multi_target_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const parents, LINK_ANCHOR *const writes, LINK_ANCHOR *const cleanup, pm_scope_node_t *scope_node, pm_multi_target_state_t *state);
+
+/**
+ * A target node represents an indirect write to a variable or a method call to
+ * a method ending in =. Compiling one of these nodes requires three sequences:
+ *
+ * * The first is to compile retrieving the parent expression if there is one.
+ * This could be the object that owns a constant or the receiver of a method
+ * call.
+ * * The second is to compile the writes to the targets. This could be writing
+ * to variables, or it could be performing method calls.
+ * * The third is to compile any cleanup that needs to happen, i.e., popping the
+ * appropriate number of values off the stack.
+ *
+ * When there is a parent expression and this target is part of a multi write, a
+ * topn instruction will be inserted into the write sequence. This is to move
+ * the parent expression to the top of the stack so that it can be used as the
+ * receiver of the method call or the owner of the constant. To facilitate this,
+ * we return a pointer to the topn instruction that was used to be later
+ * modified with the correct offset.
+ *
+ * These nodes can appear in a couple of places, but most commonly:
+ *
+ * * For loops - the index variable is a target node
+ * * Rescue clauses - the exception reference variable is a target node
+ * * Multi writes - the left hand side contains a list of target nodes
+ *
+ * For the comments with examples within this function, we'll use for loops as
+ * the containing node.
+ */
+static void
+pm_compile_target_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const parents, LINK_ANCHOR *const writes, LINK_ANCHOR *const cleanup, pm_scope_node_t *scope_node, pm_multi_target_state_t *state)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_LOCAL_VARIABLE_TARGET_NODE: {
+ // Local variable targets have no parent expression, so they only need
+ // to compile the write.
+ //
+ // for i in []; end
+ //
+ const pm_local_variable_target_node_t *cast = (const pm_local_variable_target_node_t *) node;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+
+ PUSH_SETLOCAL(writes, location, index.index, index.level);
+ break;
+ }
+ case PM_CLASS_VARIABLE_TARGET_NODE: {
+ // Class variable targets have no parent expression, so they only need
+ // to compile the write.
+ //
+ // for @@i in []; end
+ //
+ const pm_class_variable_target_node_t *cast = (const pm_class_variable_target_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ VALUE operand = ID2SYM(name);
+ PUSH_INSN2(writes, location, setclassvariable, operand, get_cvar_ic_value(iseq, name));
+ break;
+ }
+ case PM_CONSTANT_TARGET_NODE: {
+ // Constant targets have no parent expression, so they only need to
+ // compile the write.
+ //
+ // for I in []; end
+ //
+ const pm_constant_target_node_t *cast = (const pm_constant_target_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ VALUE operand = ID2SYM(name);
+ PUSH_INSN1(writes, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+ PUSH_INSN1(writes, location, setconstant, operand);
+ break;
+ }
+ case PM_GLOBAL_VARIABLE_TARGET_NODE: {
+ // Global variable targets have no parent expression, so they only need
+ // to compile the write.
+ //
+ // for $i in []; end
+ //
+ const pm_global_variable_target_node_t *cast = (const pm_global_variable_target_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ VALUE operand = ID2SYM(name);
+ PUSH_INSN1(writes, location, setglobal, operand);
+ break;
+ }
+ case PM_INSTANCE_VARIABLE_TARGET_NODE: {
+ // Instance variable targets have no parent expression, so they only
+ // need to compile the write.
+ //
+ // for @i in []; end
+ //
+ const pm_instance_variable_target_node_t *cast = (const pm_instance_variable_target_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ VALUE operand = ID2SYM(name);
+ PUSH_INSN2(writes, location, setinstancevariable, operand, get_ivar_ic_value(iseq, name));
+ break;
+ }
+ case PM_CONSTANT_PATH_TARGET_NODE: {
+ // Constant path targets have a parent expression that is the object
+ // that owns the constant. This needs to be compiled first into the
+ // parents sequence. If no parent is found, then it represents using the
+ // unary :: operator to indicate a top-level constant. In that case we
+ // need to push Object onto the stack.
+ //
+ // for I::J in []; end
+ //
+ const pm_constant_path_target_node_t *cast = (const pm_constant_path_target_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+
+ if (cast->parent != NULL) {
+ pm_compile_node(iseq, cast->parent, parents, false, scope_node);
+ }
+ else {
+ PUSH_INSN1(parents, location, putobject, rb_cObject);
+ }
+
+ if (state == NULL) {
+ PUSH_INSN(writes, location, swap);
+ }
+ else {
+ PUSH_INSN1(writes, location, topn, INT2FIX(1));
+ pm_multi_target_state_push(state, (INSN *) LAST_ELEMENT(writes), 1);
+ }
+
+ VALUE operand = ID2SYM(name);
+ PUSH_INSN1(writes, location, setconstant, operand);
+
+ if (state != NULL) {
+ PUSH_INSN(cleanup, location, pop);
+ }
+
+ break;
+ }
+ case PM_CALL_TARGET_NODE: {
+ // Call targets have a parent expression that is the receiver of the
+ // method being called. This needs to be compiled first into the parents
+ // sequence. These nodes cannot have arguments, so the method call is
+ // compiled with a single argument which represents the value being
+ // written.
+ //
+ // for i.j in []; end
+ //
+ const pm_call_target_node_t *cast = (const pm_call_target_node_t *) node;
+ ID method_id = pm_constant_id_lookup(scope_node, cast->name);
+
+ pm_compile_node(iseq, cast->receiver, parents, false, scope_node);
+
+ LABEL *safe_label = NULL;
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) {
+ safe_label = NEW_LABEL(location.line);
+ PUSH_INSN(parents, location, dup);
+ PUSH_INSNL(parents, location, branchnil, safe_label);
+ }
+
+ if (state != NULL) {
+ PUSH_INSN1(writes, location, topn, INT2FIX(1));
+ pm_multi_target_state_push(state, (INSN *) LAST_ELEMENT(writes), 1);
+ PUSH_INSN(writes, location, swap);
+ }
+
+ int flags = VM_CALL_ARGS_SIMPLE;
+ if (PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY)) flags |= VM_CALL_FCALL;
+
+ PUSH_SEND_WITH_FLAG(writes, location, method_id, INT2FIX(1), INT2FIX(flags));
+ if (safe_label != NULL && state == NULL) PUSH_LABEL(writes, safe_label);
+ PUSH_INSN(writes, location, pop);
+ if (safe_label != NULL && state != NULL) PUSH_LABEL(writes, safe_label);
+
+ if (state != NULL) {
+ PUSH_INSN(cleanup, location, pop);
+ }
+
+ break;
+ }
+ case PM_INDEX_TARGET_NODE: {
+ // Index targets have a parent expression that is the receiver of the
+ // method being called and any additional arguments that are being
+ // passed along with the value being written. The receiver and arguments
+ // both need to be on the stack. Note that this is even more complicated
+ // by the fact that these nodes can hold a block using the unary &
+ // operator.
+ //
+ // for i[:j] in []; end
+ //
+ const pm_index_target_node_t *cast = (const pm_index_target_node_t *) node;
+
+ pm_compile_node(iseq, cast->receiver, parents, false, scope_node);
+
+ int flags = 0;
+ struct rb_callinfo_kwarg *kwargs = NULL;
+ int argc = pm_setup_args(cast->arguments, (const pm_node_t *) cast->block, &flags, &kwargs, iseq, parents, scope_node, &location);
+
+ if (state != NULL) {
+ PUSH_INSN1(writes, location, topn, INT2FIX(argc + 1));
+ pm_multi_target_state_push(state, (INSN *) LAST_ELEMENT(writes), argc + 1);
+
+ if (argc == 0) {
+ PUSH_INSN(writes, location, swap);
+ }
+ else {
+ for (int index = 0; index < argc; index++) {
+ PUSH_INSN1(writes, location, topn, INT2FIX(argc + 1));
+ }
+ PUSH_INSN1(writes, location, topn, INT2FIX(argc + 1));
+ }
+ }
+
+ // The argc that we're going to pass to the send instruction is the
+ // number of arguments + 1 for the value being written. If there's a
+ // splat, then we need to insert newarray and concatarray instructions
+ // after the arguments have been written.
+ int ci_argc = argc + 1;
+ if (flags & VM_CALL_ARGS_SPLAT) {
+ ci_argc--;
+ PUSH_INSN1(writes, location, newarray, INT2FIX(1));
+ PUSH_INSN(writes, location, concatarray);
+ }
+
+ PUSH_SEND_R(writes, location, idASET, INT2NUM(ci_argc), NULL, INT2FIX(flags), kwargs);
+ PUSH_INSN(writes, location, pop);
+
+ if (state != NULL) {
+ if (argc != 0) {
+ PUSH_INSN(writes, location, pop);
+ }
+
+ for (int index = 0; index < argc + 1; index++) {
+ PUSH_INSN(cleanup, location, pop);
+ }
+ }
+
+ break;
+ }
+ case PM_MULTI_TARGET_NODE: {
+ // Multi target nodes represent a set of writes to multiple variables.
+ // The parent expressions are the combined set of the parent expressions
+ // of its inner target nodes.
+ //
+ // for i, j in []; end
+ //
+ size_t before_position;
+ if (state != NULL) {
+ before_position = state->position;
+ state->position--;
+ }
+
+ pm_compile_multi_target_node(iseq, node, parents, writes, cleanup, scope_node, state);
+ if (state != NULL) state->position = before_position;
+
+ break;
+ }
+ case PM_SPLAT_NODE: {
+ // Splat nodes capture all values into an array. They can be used
+ // as targets in assignments or for loops.
+ //
+ // for *x in []; end
+ //
+ const pm_splat_node_t *cast = (const pm_splat_node_t *) node;
+
+ if (cast->expression != NULL) {
+ pm_compile_target_node(iseq, cast->expression, parents, writes, cleanup, scope_node, state);
+ }
+
+ break;
+ }
+ default:
+ rb_bug("Unexpected node type: %s", pm_node_type(PM_NODE_TYPE(node)));
+ break;
+ }
+}
+
+/**
+ * Compile a multi target or multi write node. It returns the number of values
+ * on the stack that correspond to the parent expressions of the various
+ * targets.
+ */
+static void
+pm_compile_multi_target_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const parents, LINK_ANCHOR *const writes, LINK_ANCHOR *const cleanup, pm_scope_node_t *scope_node, pm_multi_target_state_t *state)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ const pm_node_list_t *lefts;
+ const pm_node_t *rest;
+ const pm_node_list_t *rights;
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_MULTI_TARGET_NODE: {
+ const pm_multi_target_node_t *cast = (const pm_multi_target_node_t *) node;
+ lefts = &cast->lefts;
+ rest = cast->rest;
+ rights = &cast->rights;
+ break;
+ }
+ case PM_MULTI_WRITE_NODE: {
+ const pm_multi_write_node_t *cast = (const pm_multi_write_node_t *) node;
+ lefts = &cast->lefts;
+ rest = cast->rest;
+ rights = &cast->rights;
+ break;
+ }
+ default:
+ rb_bug("Unsupported node %s", pm_node_type(PM_NODE_TYPE(node)));
+ break;
+ }
+
+ bool has_rest = (rest != NULL) && PM_NODE_TYPE_P(rest, PM_SPLAT_NODE) && ((const pm_splat_node_t *) rest)->expression != NULL;
+ bool has_posts = rights->size > 0;
+
+ // The first instruction in the writes sequence is going to spread the
+ // top value of the stack onto the number of values that we're going to
+ // write.
+ PUSH_INSN2(writes, location, expandarray, INT2FIX(lefts->size), INT2FIX((has_rest || has_posts) ? 1 : 0));
+
+ // We need to keep track of some additional state information as we're
+ // going through the targets because we will need to revisit them once
+ // we know how many values are being pushed onto the stack.
+ pm_multi_target_state_t target_state = { 0 };
+ if (state == NULL) state = &target_state;
+
+ size_t base_position = state->position;
+ size_t splat_position = (has_rest || has_posts) ? 1 : 0;
+
+ // Next, we'll iterate through all of the leading targets.
+ for (size_t index = 0; index < lefts->size; index++) {
+ const pm_node_t *target = lefts->nodes[index];
+ state->position = lefts->size - index + splat_position + base_position;
+ pm_compile_target_node(iseq, target, parents, writes, cleanup, scope_node, state);
+ }
+
+ // Next, we'll compile the rest target if there is one.
+ if (has_rest) {
+ const pm_node_t *target = ((const pm_splat_node_t *) rest)->expression;
+ state->position = 1 + rights->size + base_position;
+
+ if (has_posts) {
+ PUSH_INSN2(writes, location, expandarray, INT2FIX(rights->size), INT2FIX(3));
+ }
+
+ pm_compile_target_node(iseq, target, parents, writes, cleanup, scope_node, state);
+ }
+
+ // Finally, we'll compile the trailing targets.
+ if (has_posts) {
+ if (!has_rest && rest != NULL) {
+ PUSH_INSN2(writes, location, expandarray, INT2FIX(rights->size), INT2FIX(2));
+ }
+
+ for (size_t index = 0; index < rights->size; index++) {
+ const pm_node_t *target = rights->nodes[index];
+ state->position = rights->size - index + base_position;
+ pm_compile_target_node(iseq, target, parents, writes, cleanup, scope_node, state);
+ }
+ }
+}
+
+/**
+ * When compiling a for loop, we need to write the iteration variable to
+ * whatever expression exists in the index slot. This function performs that
+ * compilation.
+ */
+static void
+pm_compile_for_node_index(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_LOCAL_VARIABLE_TARGET_NODE: {
+ // For local variables, all we have to do is retrieve the value and then
+ // compile the index node.
+ PUSH_GETLOCAL(ret, location, 1, 0);
+ pm_compile_target_node(iseq, node, ret, ret, ret, scope_node, NULL);
+ break;
+ }
+ case PM_CLASS_VARIABLE_TARGET_NODE:
+ case PM_CONSTANT_TARGET_NODE:
+ case PM_GLOBAL_VARIABLE_TARGET_NODE:
+ case PM_INSTANCE_VARIABLE_TARGET_NODE:
+ case PM_CONSTANT_PATH_TARGET_NODE:
+ case PM_CALL_TARGET_NODE:
+ case PM_INDEX_TARGET_NODE: {
+ // For other targets, we need to potentially compile the parent or
+ // owning expression of this target, then retrieve the value, expand it,
+ // and then compile the necessary writes.
+ DECL_ANCHOR(writes);
+ DECL_ANCHOR(cleanup);
+
+ pm_multi_target_state_t state = { 0 };
+ state.position = 1;
+ pm_compile_target_node(iseq, node, ret, writes, cleanup, scope_node, &state);
+
+ PUSH_GETLOCAL(ret, location, 1, 0);
+ PUSH_INSN2(ret, location, expandarray, INT2FIX(1), INT2FIX(0));
+
+ PUSH_SEQ(ret, writes);
+ PUSH_SEQ(ret, cleanup);
+
+ pm_multi_target_state_update(&state);
+ break;
+ }
+ case PM_SPLAT_NODE:
+ case PM_MULTI_TARGET_NODE: {
+ DECL_ANCHOR(writes);
+ DECL_ANCHOR(cleanup);
+
+ pm_compile_target_node(iseq, node, ret, writes, cleanup, scope_node, NULL);
+
+ LABEL *not_single = NEW_LABEL(location.line);
+ LABEL *not_ary = NEW_LABEL(location.line);
+
+ // When there are multiple targets, we'll do a bunch of work to convert
+ // the value into an array before we expand it. Effectively we're trying
+ // to accomplish:
+ //
+ // (args.length == 1 && Array.try_convert(args[0])) || args
+ //
+ PUSH_GETLOCAL(ret, location, 1, 0);
+ PUSH_INSN(ret, location, dup);
+ PUSH_CALL(ret, location, idLength, INT2FIX(0));
+ PUSH_INSN1(ret, location, putobject, INT2FIX(1));
+ PUSH_CALL(ret, location, idEq, INT2FIX(1));
+ PUSH_INSNL(ret, location, branchunless, not_single);
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, INT2FIX(0));
+ PUSH_CALL(ret, location, idAREF, INT2FIX(1));
+ PUSH_INSN1(ret, location, putobject, rb_cArray);
+ PUSH_INSN(ret, location, swap);
+ PUSH_CALL(ret, location, rb_intern("try_convert"), INT2FIX(1));
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchunless, not_ary);
+ PUSH_INSN(ret, location, swap);
+
+ PUSH_LABEL(ret, not_ary);
+ PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, not_single);
+
+ if (PM_NODE_TYPE_P(node, PM_SPLAT_NODE)) {
+ const pm_splat_node_t *cast = (const pm_splat_node_t *) node;
+ PUSH_INSN2(ret, location, expandarray, INT2FIX(0), INT2FIX(cast->expression == NULL ? 0 : 1));
+ }
+
+ PUSH_SEQ(ret, writes);
+ PUSH_SEQ(ret, cleanup);
+ break;
+ }
+ default:
+ rb_bug("Unexpected node type for index in for node: %s", pm_node_type(PM_NODE_TYPE(node)));
+ break;
+ }
+}
+
+static void
+pm_compile_rescue(rb_iseq_t *iseq, const pm_begin_node_t *cast, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ LABEL *lstart = NEW_LABEL(node_location->line);
+ LABEL *lend = NEW_LABEL(node_location->line);
+ LABEL *lcont = NEW_LABEL(node_location->line);
+
+ pm_scope_node_t rescue_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast->rescue_clause, &rescue_scope_node, scope_node);
+
+ rb_iseq_t *rescue_iseq = NEW_CHILD_ISEQ(
+ &rescue_scope_node,
+ rb_str_concat(rb_str_new2("rescue in "), ISEQ_BODY(iseq)->location.label),
+ ISEQ_TYPE_RESCUE,
+ pm_node_line_number_cached((const pm_node_t *) cast->rescue_clause, scope_node)
+ );
+
+ pm_scope_node_destroy(&rescue_scope_node);
+
+ lstart->rescued = LABEL_RESCUE_BEG;
+ lend->rescued = LABEL_RESCUE_END;
+ PUSH_LABEL(ret, lstart);
+
+ bool prev_in_rescue = ISEQ_COMPILE_DATA(iseq)->in_rescue;
+ ISEQ_COMPILE_DATA(iseq)->in_rescue = true;
+
+ if (cast->statements != NULL) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) cast->statements);
+ }
+ else {
+ const pm_node_location_t location = PM_NODE_START_LOCATION(cast->rescue_clause);
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ ISEQ_COMPILE_DATA(iseq)->in_rescue = prev_in_rescue;
+ PUSH_LABEL(ret, lend);
+
+ if (cast->else_clause != NULL) {
+ if (!popped) PUSH_INSN(ret, *node_location, pop);
+ PM_COMPILE((const pm_node_t *) cast->else_clause);
+ }
+
+ PUSH_INSN(ret, *node_location, nop);
+ PUSH_LABEL(ret, lcont);
+
+ if (popped) PUSH_INSN(ret, *node_location, pop);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue_iseq, lcont);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, NULL, lstart);
+}
+
+static void
+pm_compile_ensure(rb_iseq_t *iseq, const pm_begin_node_t *cast, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_statements_node_t *statements = cast->ensure_clause->statements;
+
+ pm_node_location_t location;
+ if (statements != NULL) {
+ location = PM_NODE_START_LOCATION(statements);
+ }
+ else {
+ location = *node_location;
+ }
+
+ LABEL *lstart = NEW_LABEL(location.line);
+ LABEL *lend = NEW_LABEL(location.line);
+ LABEL *lcont = NEW_LABEL(location.line);
+
+ struct ensure_range er;
+ struct iseq_compile_data_ensure_node_stack enl;
+ struct ensure_range *erange;
+
+ DECL_ANCHOR(ensr);
+ if (statements != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) statements, ensr, true, scope_node);
+ }
+
+ LINK_ELEMENT *last = ensr->last;
+ bool last_leave = last && IS_INSN(last) && IS_INSN_ID(last, leave);
+
+ er.begin = lstart;
+ er.end = lend;
+ er.next = 0;
+ push_ensure_entry(iseq, &enl, &er, (void *) cast->ensure_clause);
+
+ PUSH_LABEL(ret, lstart);
+ if (cast->rescue_clause != NULL) {
+ pm_compile_rescue(iseq, cast, node_location, ret, popped | last_leave, scope_node);
+ }
+ else if (cast->statements != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) cast->statements, ret, popped | last_leave, scope_node);
+ }
+ else if (!(popped | last_leave)) {
+ PUSH_SYNTHETIC_PUTNIL(ret, iseq);
+ }
+
+ PUSH_LABEL(ret, lend);
+ PUSH_SEQ(ret, ensr);
+ if (!popped && last_leave) PUSH_INSN(ret, *node_location, putnil);
+ PUSH_LABEL(ret, lcont);
+ if (last_leave) PUSH_INSN(ret, *node_location, pop);
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast->ensure_clause, &next_scope_node, scope_node);
+
+ rb_iseq_t *child_iseq = NEW_CHILD_ISEQ(
+ &next_scope_node,
+ rb_str_concat(rb_str_new2("ensure in "), ISEQ_BODY(iseq)->location.label),
+ ISEQ_TYPE_ENSURE,
+ location.line
+ );
+
+ pm_scope_node_destroy(&next_scope_node);
+
+ erange = ISEQ_COMPILE_DATA(iseq)->ensure_node_stack->erange;
+ if (lstart->link.next != &lend->link) {
+ while (erange) {
+ PUSH_CATCH_ENTRY(CATCH_TYPE_ENSURE, erange->begin, erange->end, child_iseq, lcont);
+ erange = erange->next;
+ }
+ }
+ ISEQ_COMPILE_DATA(iseq)->ensure_node_stack = enl.prev;
+}
+
+/**
+ * Returns true if the given call node can use the opt_str_uminus or
+ * opt_str_freeze instructions as an optimization with the current iseq options.
+ */
+static inline bool
+pm_opt_str_freeze_p(const rb_iseq_t *iseq, const pm_call_node_t *node)
+{
+ return (
+ !PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION) &&
+ node->receiver != NULL &&
+ PM_NODE_TYPE_P(node->receiver, PM_STRING_NODE) &&
+ node->arguments == NULL &&
+ node->block == NULL &&
+ ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction
+ );
+}
+
+/**
+ * Compile the instructions necessary to read a constant, based on the options
+ * of the current iseq.
+ */
+static void
+pm_compile_constant_read(rb_iseq_t *iseq, VALUE name, const pm_location_t *name_loc, uint32_t node_id, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_LOCATION_START_LOCATION(name_loc, node_id);
+
+ if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
+ ISEQ_BODY(iseq)->ic_size++;
+ VALUE segments = rb_ary_new_from_args(1, name);
+ RB_OBJ_SET_SHAREABLE(segments);
+ PUSH_INSN1(ret, location, opt_getconstant_path, segments);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, getconstant, name);
+ }
+}
+
+/**
+ * Returns a Ruby array of the parts of the constant path node if it is constant
+ * reads all of the way down. If it isn't, then Qnil is returned.
+ */
+static VALUE
+pm_constant_path_parts(const pm_node_t *node, const pm_scope_node_t *scope_node)
+{
+ VALUE parts = rb_ary_new();
+
+ while (true) {
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CONSTANT_READ_NODE: {
+ const pm_constant_read_node_t *cast = (const pm_constant_read_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ rb_ary_unshift(parts, name);
+ return parts;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ const pm_constant_path_node_t *cast = (const pm_constant_path_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ rb_ary_unshift(parts, name);
+ if (cast->parent == NULL) {
+ rb_ary_unshift(parts, ID2SYM(idNULL));
+ return parts;
+ }
+
+ node = cast->parent;
+ break;
+ }
+ default:
+ return Qnil;
+ }
+ }
+}
+
+/**
+ * Compile a constant path into two sequences of instructions, one for the
+ * owning expression if there is one (prefix) and one for the constant reads
+ * (body).
+ */
+static void
+pm_compile_constant_path(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const prefix, LINK_ANCHOR *const body, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_CONSTANT_READ_NODE: {
+ const pm_constant_read_node_t *cast = (const pm_constant_read_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ PUSH_INSN1(body, location, putobject, Qtrue);
+ PUSH_INSN1(body, location, getconstant, name);
+ break;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ const pm_constant_path_node_t *cast = (const pm_constant_path_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ if (cast->parent == NULL) {
+ PUSH_INSN(body, location, pop);
+ PUSH_INSN1(body, location, putobject, rb_cObject);
+ PUSH_INSN1(body, location, putobject, Qtrue);
+ PUSH_INSN1(body, location, getconstant, name);
+ }
+ else {
+ pm_compile_constant_path(iseq, cast->parent, prefix, body, false, scope_node);
+ PUSH_INSN1(body, location, putobject, Qfalse);
+ PUSH_INSN1(body, location, getconstant, name);
+ }
+ break;
+ }
+ default:
+ PM_COMPILE_INTO_ANCHOR(prefix, node);
+ break;
+ }
+}
+
+/**
+ * Return the object that will be pushed onto the stack for the given node.
+ */
+static VALUE
+pm_compile_shareable_constant_literal(rb_iseq_t *iseq, const pm_node_t *node, pm_scope_node_t *scope_node)
+{
+ switch (PM_NODE_TYPE(node)) {
+ case PM_TRUE_NODE:
+ case PM_FALSE_NODE:
+ case PM_NIL_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_REGULAR_EXPRESSION_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_INTEGER_NODE:
+ case PM_FLOAT_NODE:
+ case PM_RATIONAL_NODE:
+ case PM_IMAGINARY_NODE:
+ case PM_SOURCE_ENCODING_NODE:
+ return pm_static_literal_value(iseq, node, scope_node);
+ case PM_STRING_NODE:
+ return parse_static_literal_string(iseq, scope_node, node, &((const pm_string_node_t *) node)->unescaped);
+ case PM_SOURCE_FILE_NODE:
+ return pm_source_file_value((const pm_source_file_node_t *) node, scope_node);
+ case PM_ARRAY_NODE: {
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+ VALUE result = rb_ary_new_capa(cast->elements.size);
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ VALUE element = pm_compile_shareable_constant_literal(iseq, cast->elements.nodes[index], scope_node);
+ if (element == Qundef) return Qundef;
+
+ rb_ary_push(result, element);
+ }
+
+ return rb_ractor_make_shareable(result);
+ }
+ case PM_HASH_NODE: {
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+ VALUE result = rb_hash_alloc_fixed_size(rb_cHash, cast->elements.size);
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ const pm_node_t *element = cast->elements.nodes[index];
+ if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE)) return Qundef;
+
+ const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) element;
+
+ VALUE key = pm_compile_shareable_constant_literal(iseq, assoc->key, scope_node);
+ if (key == Qundef) return Qundef;
+
+ VALUE value = pm_compile_shareable_constant_literal(iseq, assoc->value, scope_node);
+ if (value == Qundef) return Qundef;
+
+ rb_hash_aset(result, key, value);
+ }
+
+ return rb_ractor_make_shareable(result);
+ }
+ default:
+ return Qundef;
+ }
+}
+
+/**
+ * Compile the instructions for pushing the value that will be written to a
+ * shared constant.
+ */
+static void
+pm_compile_shareable_constant_value(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_flags_t shareability, VALUE path, LINK_ANCHOR *const ret, pm_scope_node_t *scope_node, bool top)
+{
+ VALUE literal = pm_compile_shareable_constant_literal(iseq, node, scope_node);
+ if (literal != Qundef) {
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ PUSH_INSN1(ret, location, putobject, literal);
+ return;
+ }
+
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ARRAY_NODE: {
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+
+ if (top) {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ }
+
+ for (size_t index = 0; index < cast->elements.size; index++) {
+ pm_compile_shareable_constant_value(iseq, cast->elements.nodes[index], shareability, path, ret, scope_node, false);
+ }
+
+ PUSH_INSN1(ret, location, newarray, INT2FIX(cast->elements.size));
+
+ if (top) {
+ ID method_id = (shareability & PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY) ? rb_intern("make_shareable_copy") : rb_intern("make_shareable");
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+
+ return;
+ }
+ case PM_HASH_NODE: {
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+
+ if (top) {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ }
+
+ pm_compile_hash_elements(iseq, (const pm_node_t *) cast, &cast->elements, shareability, path, false, ret, scope_node);
+
+ if (top) {
+ ID method_id = (shareability & PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY) ? rb_intern("make_shareable_copy") : rb_intern("make_shareable");
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+
+ return;
+ }
+ default: {
+ DECL_ANCHOR(value_seq);
+
+ pm_compile_node(iseq, node, value_seq, false, scope_node);
+ if (PM_NODE_TYPE_P(node, PM_INTERPOLATED_STRING_NODE)) {
+ PUSH_SEND_WITH_FLAG(value_seq, location, idUMinus, INT2FIX(0), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+
+ if (shareability & PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL) {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_SEQ(ret, value_seq);
+ if (!RB_OBJ_SHAREABLE_P(path)) {
+ RB_OBJ_SET_SHAREABLE(path);
+ }
+ PUSH_INSN1(ret, location, putobject, path);
+ PUSH_SEND_WITH_FLAG(ret, location, rb_intern("ensure_shareable"), INT2FIX(2), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+ else if (shareability & PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY) {
+ if (top) PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_SEQ(ret, value_seq);
+ if (top) PUSH_SEND_WITH_FLAG(ret, location, rb_intern("make_shareable_copy"), INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+ else if (shareability & PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING) {
+ if (top) PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_SEQ(ret, value_seq);
+ if (top) PUSH_SEND_WITH_FLAG(ret, location, rb_intern("make_shareable"), INT2FIX(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ }
+
+ break;
+ }
+ }
+}
+
+/**
+ * Compile a constant write node, either in the context of a ractor pragma or
+ * not.
+ */
+static void
+pm_compile_constant_write_node(rb_iseq_t *iseq, const pm_constant_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ ID name_id = pm_constant_id_lookup(scope_node, node->name);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, rb_id2str(name_id), ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+
+ VALUE operand = ID2SYM(name_id);
+ PUSH_INSN1(ret, location, setconstant, operand);
+}
+
+/**
+ * Compile a constant and write node, either in the context of a ractor pragma
+ * or not.
+ */
+static void
+pm_compile_constant_and_write_node(rb_iseq_t *iseq, const pm_constant_and_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, node->name));
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ pm_compile_constant_read(iseq, name, &node->name_loc, location.node_id, ret, scope_node);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchunless, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, name, ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+ PUSH_INSN1(ret, location, setconstant, name);
+ PUSH_LABEL(ret, end_label);
+}
+
+/**
+ * Compile a constant or write node, either in the context of a ractor pragma or
+ * not.
+ */
+static void
+pm_compile_constant_or_write_node(rb_iseq_t *iseq, const pm_constant_or_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, node->name));
+
+ LABEL *set_label = NEW_LABEL(location.line);
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CONST), name, Qtrue);
+ PUSH_INSNL(ret, location, branchunless, set_label);
+
+ pm_compile_constant_read(iseq, name, &node->name_loc, location.node_id, ret, scope_node);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchif, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+ PUSH_LABEL(ret, set_label);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, name, ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+ PUSH_INSN1(ret, location, setconstant, name);
+ PUSH_LABEL(ret, end_label);
+}
+
+/**
+ * Compile a constant operator write node, either in the context of a ractor
+ * pragma or not.
+ */
+static void
+pm_compile_constant_operator_write_node(rb_iseq_t *iseq, const pm_constant_operator_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, node->name));
+ ID method_id = pm_constant_id_lookup(scope_node, node->binary_operator);
+
+ pm_compile_constant_read(iseq, name, &node->name_loc, location.node_id, ret, scope_node);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, name, ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2NUM(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
+ PUSH_INSN1(ret, location, setconstant, name);
+}
+
+/**
+ * Creates a string that is used in ractor error messages to describe the
+ * constant path being written.
+ */
+static VALUE
+pm_constant_path_path(const pm_constant_path_node_t *node, const pm_scope_node_t *scope_node)
+{
+ VALUE parts = rb_ary_new();
+ rb_ary_push(parts, rb_id2str(pm_constant_id_lookup(scope_node, node->name)));
+
+ const pm_node_t *current = node->parent;
+ while (current != NULL && PM_NODE_TYPE_P(current, PM_CONSTANT_PATH_NODE)) {
+ const pm_constant_path_node_t *cast = (const pm_constant_path_node_t *) current;
+ rb_ary_unshift(parts, rb_id2str(pm_constant_id_lookup(scope_node, cast->name)));
+ current = cast->parent;
+ }
+
+ if (current == NULL) {
+ rb_ary_unshift(parts, rb_id2str(idNULL));
+ }
+ else if (PM_NODE_TYPE_P(current, PM_CONSTANT_READ_NODE)) {
+ rb_ary_unshift(parts, rb_id2str(pm_constant_id_lookup(scope_node, ((const pm_constant_read_node_t *) current)->name)));
+ }
+ else {
+ rb_ary_unshift(parts, rb_str_new_cstr("..."));
+ }
+
+ return rb_ary_join(parts, rb_str_new_cstr("::"));
+}
+
+/**
+ * Compile a constant path write node, either in the context of a ractor pragma
+ * or not.
+ */
+static void
+pm_compile_constant_path_write_node(rb_iseq_t *iseq, const pm_constant_path_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ const pm_constant_path_node_t *target = node->target;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, target->name));
+
+ if (target->parent) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) target->parent);
+ }
+ else {
+ PUSH_INSN1(ret, location, putobject, rb_cObject);
+ }
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, pm_constant_path_path(node->target, scope_node), ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (!popped) {
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ }
+
+ PUSH_INSN(ret, location, swap);
+ PUSH_INSN1(ret, location, setconstant, name);
+}
+
+/**
+ * Compile a constant path and write node, either in the context of a ractor
+ * pragma or not.
+ */
+static void
+pm_compile_constant_path_and_write_node(rb_iseq_t *iseq, const pm_constant_path_and_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ const pm_constant_path_node_t *target = node->target;
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, target->name));
+ LABEL *lfin = NEW_LABEL(location.line);
+
+ if (target->parent) {
+ PM_COMPILE_NOT_POPPED(target->parent);
+ }
+ else {
+ PUSH_INSN1(ret, location, putobject, rb_cObject);
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, getconstant, name);
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchunless, lfin);
+
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, pm_constant_path_path(node->target, scope_node), ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (popped) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ }
+ else {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(2));
+ PUSH_INSN(ret, location, swap);
+ }
+
+ PUSH_INSN1(ret, location, setconstant, name);
+ PUSH_LABEL(ret, lfin);
+
+ if (!popped) PUSH_INSN(ret, location, swap);
+ PUSH_INSN(ret, location, pop);
+}
+
+/**
+ * Compile a constant path or write node, either in the context of a ractor
+ * pragma or not.
+ */
+static void
+pm_compile_constant_path_or_write_node(rb_iseq_t *iseq, const pm_constant_path_or_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ const pm_constant_path_node_t *target = node->target;
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, target->name));
+ LABEL *lassign = NEW_LABEL(location.line);
+ LABEL *lfin = NEW_LABEL(location.line);
+
+ if (target->parent) {
+ PM_COMPILE_NOT_POPPED(target->parent);
+ }
+ else {
+ PUSH_INSN1(ret, location, putobject, rb_cObject);
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CONST_FROM), name, Qtrue);
+ PUSH_INSNL(ret, location, branchunless, lassign);
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, getconstant, name);
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, lfin);
+
+ if (!popped) PUSH_INSN(ret, location, pop);
+ PUSH_LABEL(ret, lassign);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, pm_constant_path_path(node->target, scope_node), ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ if (popped) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ }
+ else {
+ PUSH_INSN1(ret, location, dupn, INT2FIX(2));
+ PUSH_INSN(ret, location, swap);
+ }
+
+ PUSH_INSN1(ret, location, setconstant, name);
+ PUSH_LABEL(ret, lfin);
+
+ if (!popped) PUSH_INSN(ret, location, swap);
+ PUSH_INSN(ret, location, pop);
+}
+
+/**
+ * Compile a constant path operator write node, either in the context of a
+ * ractor pragma or not.
+ */
+static void
+pm_compile_constant_path_operator_write_node(rb_iseq_t *iseq, const pm_constant_path_operator_write_node_t *node, const pm_node_flags_t shareability, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ const pm_constant_path_node_t *target = node->target;
+
+ ID method_id = pm_constant_id_lookup(scope_node, node->binary_operator);
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, target->name));
+
+ if (target->parent) {
+ PM_COMPILE_NOT_POPPED(target->parent);
+ }
+ else {
+ PUSH_INSN1(ret, location, putobject, rb_cObject);
+ }
+
+ PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSN1(ret, location, getconstant, name);
+
+ if (shareability != 0) {
+ pm_compile_shareable_constant_value(iseq, node->value, shareability, pm_constant_path_path(node->target, scope_node), ret, scope_node, true);
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->value);
+ }
+
+ PUSH_CALL(ret, location, method_id, INT2FIX(1));
+ PUSH_INSN(ret, location, swap);
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, topn, INT2FIX(1));
+ PUSH_INSN(ret, location, swap);
+ }
+
+ PUSH_INSN1(ret, location, setconstant, name);
+}
+
+/**
+ * Many nodes in Prism can be marked as a static literal, which means slightly
+ * different things depending on which node it is. Occasionally we need to omit
+ * container nodes from static literal checks, which is where this macro comes
+ * in.
+ */
+#define PM_CONTAINER_P(node) (PM_NODE_TYPE_P(node, PM_ARRAY_NODE) || PM_NODE_TYPE_P(node, PM_HASH_NODE) || PM_NODE_TYPE_P(node, PM_RANGE_NODE))
+
+/**
+ * Compile a scope node, which is a special kind of node that represents a new
+ * lexical scope, attached to a node in the AST.
+ */
+static inline void
+pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped)
+{
+ const pm_node_location_t location = *node_location;
+ struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
+
+ pm_constant_id_list_t *locals = &scope_node->locals;
+ pm_parameters_node_t *parameters_node = NULL;
+ pm_node_list_t *keywords_list = NULL;
+ pm_node_list_t *optionals_list = NULL;
+ pm_node_list_t *posts_list = NULL;
+ pm_node_list_t *requireds_list = NULL;
+ pm_node_list_t *block_locals = NULL;
+ bool trailing_comma = false;
+
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_CLASS_NODE) || PM_NODE_TYPE_P(scope_node->ast_node, PM_MODULE_NODE)) {
+ PUSH_TRACE(ret, RUBY_EVENT_CLASS);
+ }
+
+ if (scope_node->parameters != NULL) {
+ switch (PM_NODE_TYPE(scope_node->parameters)) {
+ case PM_BLOCK_PARAMETERS_NODE: {
+ pm_block_parameters_node_t *cast = (pm_block_parameters_node_t *) scope_node->parameters;
+ parameters_node = cast->parameters;
+ block_locals = &cast->locals;
+
+ if (parameters_node) {
+ if (parameters_node->rest && PM_NODE_TYPE_P(parameters_node->rest, PM_IMPLICIT_REST_NODE)) {
+ trailing_comma = true;
+ }
+ }
+ break;
+ }
+ case PM_PARAMETERS_NODE: {
+ parameters_node = (pm_parameters_node_t *) scope_node->parameters;
+ break;
+ }
+ case PM_NUMBERED_PARAMETERS_NODE: {
+ uint32_t maximum = ((const pm_numbered_parameters_node_t *) scope_node->parameters)->maximum;
+ body->param.lead_num = maximum;
+ body->param.flags.ambiguous_param0 = maximum == 1;
+ break;
+ }
+ case PM_IT_PARAMETERS_NODE:
+ body->param.lead_num = 1;
+ body->param.flags.ambiguous_param0 = true;
+ break;
+ default:
+ rb_bug("Unexpected node type for parameters: %s", pm_node_type(PM_NODE_TYPE(scope_node->parameters)));
+ }
+ }
+
+ struct rb_iseq_param_keyword *keyword = NULL;
+
+ if (parameters_node) {
+ optionals_list = &parameters_node->optionals;
+ requireds_list = &parameters_node->requireds;
+ keywords_list = &parameters_node->keywords;
+ posts_list = &parameters_node->posts;
+ }
+ else if (scope_node->parameters && (PM_NODE_TYPE_P(scope_node->parameters, PM_NUMBERED_PARAMETERS_NODE) || PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE))) {
+ body->param.opt_num = 0;
+ }
+ else {
+ body->param.lead_num = 0;
+ body->param.opt_num = 0;
+ }
+
+ //********STEP 1**********
+ // Goal: calculate the table size for the locals, accounting for
+ // hidden variables and multi target nodes
+ size_t locals_size = locals->size;
+
+ // Index lookup table buffer size is only the number of the locals.
+ // We'll initialize it after computing table_size below.
+ pm_index_lookup_table_t index_lookup_table = PM_INDEX_LOOKUP_TABLE_INIT;
+
+ int table_size = (int) locals_size;
+
+ // For nodes have a hidden iteration variable. We add that to the local
+ // table size here.
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_FOR_NODE)) table_size++;
+
+ if (keywords_list && keywords_list->size) {
+ table_size++;
+ }
+
+ if (requireds_list) {
+ for (size_t i = 0; i < requireds_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one
+ // additional anonymous local not represented in the locals table
+ // We want to account for this in our table size
+ pm_node_t *required = requireds_list->nodes[i];
+ if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
+ table_size++;
+ }
+ else if (PM_NODE_TYPE_P(required, PM_REQUIRED_PARAMETER_NODE)) {
+ if (PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+ }
+
+ // If we have the `it` implicit local variable, we need to account for
+ // it in the local table size.
+ if (scope_node->parameters != NULL && PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE)) {
+ table_size++;
+ }
+
+ // Ensure there is enough room in the local table for any
+ // parameters that have been repeated
+ // ex: def underscore_parameters(_, _ = 1, _ = 2); _; end
+ // ^^^^^^^^^^^^
+ if (optionals_list && optionals_list->size) {
+ for (size_t i = 0; i < optionals_list->size; i++) {
+ pm_node_t * node = optionals_list->nodes[i];
+ if (PM_NODE_FLAG_P(node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+
+ // If we have an anonymous "rest" node, we'll need to increase the local
+ // table size to take it in to account.
+ // def m(foo, *, bar)
+ // ^
+ if (parameters_node) {
+ if (parameters_node->rest) {
+ if (!(PM_NODE_TYPE_P(parameters_node->rest, PM_IMPLICIT_REST_NODE))) {
+ if (!((const pm_rest_parameter_node_t *) parameters_node->rest)->name || PM_NODE_FLAG_P(parameters_node->rest, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+
+ // def foo(_, **_); _; end
+ // ^^^
+ if (parameters_node->keyword_rest) {
+ // def foo(...); end
+ // ^^^
+ // When we have a `...` as the keyword_rest, it's a forwarding_parameter_node and
+ // we need to leave space for 4 locals: *, **, &, ...
+ if (PM_NODE_TYPE_P(parameters_node->keyword_rest, PM_FORWARDING_PARAMETER_NODE)) {
+ // Only optimize specifically methods like this: `foo(...)`
+ if (requireds_list->size == 0 && optionals_list->size == 0 && keywords_list->size == 0) {
+ ISEQ_BODY(iseq)->param.flags.use_block = TRUE;
+ ISEQ_BODY(iseq)->param.flags.forwardable = TRUE;
+ table_size += 1;
+ }
+ else {
+ table_size += 4;
+ }
+ }
+ else {
+ const pm_keyword_rest_parameter_node_t *kw_rest = (const pm_keyword_rest_parameter_node_t *) parameters_node->keyword_rest;
+
+ // If it's anonymous or repeated, then we need to allocate stack space
+ if (!kw_rest->name || PM_NODE_FLAG_P(kw_rest, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+ }
+
+ if (posts_list) {
+ for (size_t i = 0; i < posts_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one
+ // additional anonymous local not represented in the locals table
+ // We want to account for this in our table size
+ pm_node_t *required = posts_list->nodes[i];
+ if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE) || PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+
+ if (keywords_list && keywords_list->size) {
+ for (size_t i = 0; i < keywords_list->size; i++) {
+ pm_node_t *keyword_parameter_node = keywords_list->nodes[i];
+ if (PM_NODE_FLAG_P(keyword_parameter_node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ table_size++;
+ }
+ }
+ }
+
+ if (parameters_node && parameters_node->block && PM_NODE_TYPE_P(parameters_node->block, PM_BLOCK_PARAMETER_NODE)) {
+ const pm_block_parameter_node_t *block_node = (const pm_block_parameter_node_t *) parameters_node->block;
+
+ if (PM_NODE_FLAG_P(block_node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER) || !block_node->name) {
+ table_size++;
+ }
+ }
+
+ // We can create local_table_for_iseq with the correct size
+ VALUE idtmp = 0;
+ rb_ast_id_table_t *local_table_for_iseq = ALLOCV(idtmp, sizeof(rb_ast_id_table_t) + table_size * sizeof(ID));
+ local_table_for_iseq->size = table_size;
+
+ // Init the direct-indexed lookup table. The capacity is based on the
+ // parser's constant pool size (for regular locals) plus special slots.
+ pm_index_lookup_table_init(&index_lookup_table, (int) pm_parser_constants_size(scope_node->parser), iseq);
+
+ //********END OF STEP 1**********
+
+ //********STEP 2**********
+ // Goal: populate iv index table as well as local table, keeping the
+ // layout of the local table consistent with the layout of the
+ // stack when calling the method
+ //
+ // Do a first pass on all of the parameters, setting their values in
+ // the local_table_for_iseq, _except_ for Multis who get a hidden
+ // variable in this step, and will get their names inserted in step 3
+
+ // local_index is a cursor that keeps track of the current
+ // index into local_table_for_iseq. The local table is actually a list,
+ // and the order of that list must match the order of the items pushed
+ // on the stack. We need to take in to account things pushed on the
+ // stack that _might not have a name_ (for example array destructuring).
+ // This index helps us know which item we're dealing with and also give
+ // those anonymous items temporary names (as below)
+ int local_index = 0;
+
+ // Here we figure out local table indices and insert them in to the
+ // index lookup table and local tables.
+ //
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^^^^^^^^^
+ if (requireds_list && requireds_list->size) {
+ for (size_t i = 0; i < requireds_list->size; i++, local_index++) {
+ ID local;
+
+ // For each MultiTargetNode, we're going to have one additional
+ // anonymous local not represented in the locals table. We want
+ // to account for this in our table size.
+ pm_node_t *required = requireds_list->nodes[i];
+
+ switch (PM_NODE_TYPE(required)) {
+ case PM_MULTI_TARGET_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^^^^^^
+ local = rb_make_temporary_id(local_index);
+ local_table_for_iseq->ids[local_index] = local;
+ break;
+ }
+ case PM_REQUIRED_PARAMETER_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^
+ const pm_required_parameter_node_t *param = (const pm_required_parameter_node_t *) required;
+
+ if (PM_NODE_FLAG_P(required, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, param->name);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(param->name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+
+ break;
+ }
+ default:
+ rb_bug("Unsupported node in requireds in parameters %s", pm_node_type(PM_NODE_TYPE(required)));
+ }
+ }
+
+ body->param.lead_num = (int) requireds_list->size;
+ body->param.flags.has_lead = true;
+ }
+
+ if (scope_node->parameters != NULL && PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE)) {
+ local_table_for_iseq->ids[local_index++] = idItImplicit;
+ }
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^
+ if (optionals_list && optionals_list->size) {
+ body->param.opt_num = (int) optionals_list->size;
+ body->param.flags.has_opt = true;
+
+ for (size_t i = 0; i < optionals_list->size; i++, local_index++) {
+ pm_node_t * node = optionals_list->nodes[i];
+ pm_constant_id_t name = ((const pm_optional_parameter_node_t *) node)->name;
+
+ if (PM_NODE_FLAG_P(node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, name);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ }
+ }
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^
+ if (parameters_node && parameters_node->rest) {
+ body->param.rest_start = local_index;
+
+ // If there's a trailing comma, we'll have an implicit rest node,
+ // and we don't want it to impact the rest variables on param
+ if (!(PM_NODE_TYPE_P(parameters_node->rest, PM_IMPLICIT_REST_NODE))) {
+ body->param.flags.has_rest = true;
+ RUBY_ASSERT(body->param.rest_start != -1);
+
+ pm_constant_id_t name = ((const pm_rest_parameter_node_t *) parameters_node->rest)->name;
+
+ if (name) {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^
+ if (PM_NODE_FLAG_P(parameters_node->rest, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, name);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ }
+ else {
+ // def foo(a, (b, *c, d), e = 1, *, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^
+ body->param.flags.anon_rest = true;
+ pm_insert_local_special(PM_CONSTANT_MULT, idMULT, local_index, &index_lookup_table, local_table_for_iseq);
+ }
+
+ local_index++;
+ }
+ }
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^^^^^^^^^
+ if (posts_list && posts_list->size) {
+ body->param.post_num = (int) posts_list->size;
+ body->param.post_start = local_index;
+ body->param.flags.has_post = true;
+
+ for (size_t i = 0; i < posts_list->size; i++, local_index++) {
+ ID local;
+
+ // For each MultiTargetNode, we're going to have one additional
+ // anonymous local not represented in the locals table. We want
+ // to account for this in our table size.
+ const pm_node_t *post_node = posts_list->nodes[i];
+
+ switch (PM_NODE_TYPE(post_node)) {
+ case PM_MULTI_TARGET_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^^^^^^
+ local = rb_make_temporary_id(local_index);
+ local_table_for_iseq->ids[local_index] = local;
+ break;
+ }
+ case PM_REQUIRED_PARAMETER_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^
+ const pm_required_parameter_node_t *param = (const pm_required_parameter_node_t *) post_node;
+
+ if (PM_NODE_FLAG_P(param, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, param->name);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(param->name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ break;
+ }
+ default:
+ rb_bug("Unsupported node in posts in parameters %s", pm_node_type(PM_NODE_TYPE(post_node)));
+ }
+ }
+ }
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^^^^^
+ // Keywords create an internal variable on the parse tree
+ if (keywords_list && keywords_list->size) {
+ keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
+ keyword->num = (int) keywords_list->size;
+
+ const VALUE default_values = rb_ary_hidden_new(1);
+ const VALUE complex_mark = rb_str_tmp_new(0);
+
+ for (size_t i = 0; i < keywords_list->size; i++) {
+ pm_node_t *keyword_parameter_node = keywords_list->nodes[i];
+ pm_constant_id_t name;
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^
+ if (PM_NODE_TYPE_P(keyword_parameter_node, PM_REQUIRED_KEYWORD_PARAMETER_NODE)) {
+ name = ((const pm_required_keyword_parameter_node_t *) keyword_parameter_node)->name;
+ keyword->required_num++;
+ ID local = pm_constant_id_lookup(scope_node, name);
+
+ if (PM_NODE_FLAG_P(keyword_parameter_node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ local_index++;
+ }
+ }
+
+ for (size_t i = 0; i < keywords_list->size; i++) {
+ pm_node_t *keyword_parameter_node = keywords_list->nodes[i];
+ pm_constant_id_t name;
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^
+ if (PM_NODE_TYPE_P(keyword_parameter_node, PM_OPTIONAL_KEYWORD_PARAMETER_NODE)) {
+ const pm_optional_keyword_parameter_node_t *cast = ((const pm_optional_keyword_parameter_node_t *) keyword_parameter_node);
+
+ pm_node_t *value = cast->value;
+ name = cast->name;
+
+ if (PM_NODE_FLAG_P(value, PM_NODE_FLAG_STATIC_LITERAL) && !PM_CONTAINER_P(value)) {
+ rb_ary_push(default_values, pm_static_literal_value(iseq, value, scope_node));
+ }
+ else {
+ rb_ary_push(default_values, complex_mark);
+ }
+
+ ID local = pm_constant_id_lookup(scope_node, name);
+ if (PM_NODE_FLAG_P(keyword_parameter_node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ local_index++;
+ }
+
+ }
+
+ if (RARRAY_LEN(default_values)) {
+ VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values));
+
+ for (int i = 0; i < RARRAY_LEN(default_values); i++) {
+ VALUE dv = RARRAY_AREF(default_values, i);
+ if (dv == complex_mark) dv = Qundef;
+ RB_OBJ_WRITE(iseq, &dvs[i], dv);
+ }
+
+ keyword->default_values = dvs;
+ }
+
+ // Hidden local for keyword arguments
+ keyword->bits_start = local_index;
+ ID local = rb_make_temporary_id(local_index);
+ local_table_for_iseq->ids[local_index] = local;
+ local_index++;
+
+ body->param.keyword = keyword;
+ body->param.flags.has_kw = true;
+ }
+
+ if (body->type == ISEQ_TYPE_BLOCK && local_index == 1 && requireds_list && requireds_list->size == 1 && !trailing_comma) {
+ body->param.flags.ambiguous_param0 = true;
+ }
+
+ if (parameters_node) {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^
+ if (parameters_node->keyword_rest) {
+ switch (PM_NODE_TYPE(parameters_node->keyword_rest)) {
+ case PM_NO_KEYWORDS_PARAMETER_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **nil, &n)
+ // ^^^^^
+ body->param.flags.accepts_no_kwarg = true;
+ break;
+ }
+ case PM_KEYWORD_REST_PARAMETER_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^
+ const pm_keyword_rest_parameter_node_t *kw_rest_node = (const pm_keyword_rest_parameter_node_t *) parameters_node->keyword_rest;
+ if (!body->param.flags.has_kw) {
+ body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
+ }
+
+ keyword->rest_start = local_index;
+ body->param.flags.has_kwrest = true;
+
+ pm_constant_id_t constant_id = kw_rest_node->name;
+ if (constant_id) {
+ if (PM_NODE_FLAG_P(kw_rest_node, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, constant_id);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(constant_id, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ }
+ else {
+ body->param.flags.anon_kwrest = true;
+ pm_insert_local_special(PM_CONSTANT_POW, idPow, local_index, &index_lookup_table, local_table_for_iseq);
+ }
+
+ local_index++;
+ break;
+ }
+ case PM_FORWARDING_PARAMETER_NODE: {
+ // def foo(...)
+ // ^^^
+ if (!ISEQ_BODY(iseq)->param.flags.forwardable) {
+ // Add the anonymous *
+ body->param.rest_start = local_index;
+ body->param.flags.has_rest = true;
+ body->param.flags.anon_rest = true;
+ pm_insert_local_special(PM_CONSTANT_MULT, idMULT, local_index++, &index_lookup_table, local_table_for_iseq);
+
+ // Add the anonymous **
+ RUBY_ASSERT(!body->param.flags.has_kw);
+ body->param.flags.has_kw = false;
+ body->param.flags.has_kwrest = true;
+ body->param.flags.anon_kwrest = true;
+ body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
+ keyword->rest_start = local_index;
+ pm_insert_local_special(PM_CONSTANT_POW, idPow, local_index++, &index_lookup_table, local_table_for_iseq);
+
+ // Add the anonymous &
+ body->param.block_start = local_index;
+ body->param.flags.has_block = true;
+ pm_insert_local_special(PM_CONSTANT_AND, idAnd, local_index++, &index_lookup_table, local_table_for_iseq);
+ }
+
+ // Add the ...
+ pm_insert_local_special(PM_CONSTANT_DOT3, idDot3, local_index++, &index_lookup_table, local_table_for_iseq);
+ break;
+ }
+ default:
+ rb_bug("node type %s not expected as keyword_rest", pm_node_type(PM_NODE_TYPE(parameters_node->keyword_rest)));
+ }
+ }
+
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^
+ if (parameters_node->block) {
+ switch (PM_NODE_TYPE(parameters_node->block)) {
+ case PM_BLOCK_PARAMETER_NODE: {
+ body->param.block_start = local_index;
+ body->param.flags.has_block = true;
+
+ iseq_set_use_block(iseq);
+
+ pm_constant_id_t name = ((const pm_block_parameter_node_t *) parameters_node->block)->name;
+
+ if (name) {
+ if (PM_NODE_FLAG_P(parameters_node->block, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
+ ID local = pm_constant_id_lookup(scope_node, name);
+ local_table_for_iseq->ids[local_index] = local;
+ }
+ else {
+ pm_insert_local_index(name, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ }
+ else {
+ pm_insert_local_special(PM_CONSTANT_AND, idAnd, local_index, &index_lookup_table, local_table_for_iseq);
+ }
+
+ local_index++;
+ break;
+ }
+ case PM_NO_BLOCK_PARAMETER_NODE: {
+ body->param.flags.accepts_no_block = true;
+ break;
+ }
+ default:
+ rb_bug("node type %s not expected as block parameter", pm_node_type(PM_NODE_TYPE(parameters_node->block)));
+ }
+ }
+ }
+
+ //********END OF STEP 2**********
+ // The local table is now consistent with expected
+ // stack layout
+
+ // If there's only one required element in the parameters
+ // CRuby needs to recognize it as an ambiguous parameter
+
+ //********STEP 3**********
+ // Goal: fill in the names of the parameters in MultiTargetNodes
+ //
+ // Go through requireds again to set the multis
+
+ if (requireds_list && requireds_list->size) {
+ for (size_t i = 0; i < requireds_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one
+ // additional anonymous local not represented in the locals table
+ // We want to account for this in our table size
+ const pm_node_t *required = requireds_list->nodes[i];
+
+ if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
+ local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) required, &index_lookup_table, local_table_for_iseq, scope_node, local_index);
+ }
+ }
+ }
+
+ // Go through posts again to set the multis
+ if (posts_list && posts_list->size) {
+ for (size_t i = 0; i < posts_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one
+ // additional anonymous local not represented in the locals table
+ // We want to account for this in our table size
+ const pm_node_t *post = posts_list->nodes[i];
+
+ if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
+ local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) post, &index_lookup_table, local_table_for_iseq, scope_node, local_index);
+ }
+ }
+ }
+
+ // Set any anonymous locals for the for node
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_FOR_NODE)) {
+ if (PM_NODE_TYPE_P(((const pm_for_node_t *) scope_node->ast_node)->index, PM_LOCAL_VARIABLE_TARGET_NODE)) {
+ body->param.lead_num++;
+ }
+ else {
+ body->param.rest_start = local_index;
+ body->param.flags.has_rest = true;
+ }
+
+ ID local = rb_make_temporary_id(local_index);
+ local_table_for_iseq->ids[local_index] = local;
+ local_index++;
+ }
+
+ // Fill in any NumberedParameters, if they exist
+ if (scope_node->parameters && PM_NODE_TYPE_P(scope_node->parameters, PM_NUMBERED_PARAMETERS_NODE)) {
+ int maximum = ((const pm_numbered_parameters_node_t *) scope_node->parameters)->maximum;
+ RUBY_ASSERT(0 < maximum && maximum <= 9);
+ for (int i = 0; i < maximum; i++, local_index++) {
+ const uint8_t param_name[] = { '_', '1' + i };
+ pm_constant_id_t constant_id = pm_parser_constant_find(scope_node->parser, param_name, 2);
+ RUBY_ASSERT(constant_id && "parser should fill in any gaps in numbered parameters");
+ pm_insert_local_index(constant_id, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ body->param.lead_num = maximum;
+ body->param.flags.has_lead = true;
+ }
+
+ // Fill in the anonymous `it` parameter, if it exists
+ if (scope_node->parameters && PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE)) {
+ body->param.lead_num = 1;
+ body->param.flags.has_lead = true;
+ }
+
+ //********END OF STEP 3**********
+
+ //********STEP 4**********
+ // Goal: fill in the method body locals
+ // To be explicit, these are the non-parameter locals
+ // We fill in the block_locals, if they exist
+ // lambda { |x; y| y }
+ // ^
+ if (block_locals && block_locals->size) {
+ for (size_t i = 0; i < block_locals->size; i++, local_index++) {
+ pm_constant_id_t constant_id = ((const pm_block_local_variable_node_t *) block_locals->nodes[i])->name;
+ pm_insert_local_index(constant_id, local_index, &index_lookup_table, local_table_for_iseq, scope_node);
+ }
+ }
+
+ // Fill in any locals we missed
+ if (scope_node->locals.size) {
+ for (size_t i = 0; i < scope_node->locals.size; i++) {
+ pm_constant_id_t constant_id = locals->ids[i];
+ if (constant_id) {
+ int existing;
+ if (!pm_index_lookup_table_lookup(&index_lookup_table, constant_id, &existing)) {
+ ID local = pm_constant_id_lookup(scope_node, constant_id);
+ local_table_for_iseq->ids[local_index] = local;
+ pm_index_lookup_table_insert(&index_lookup_table, constant_id, local_index);
+ local_index++;
+ }
+ }
+ }
+ }
+
+ //********END OF STEP 4**********
+
+ // We set the index_lookup_table on the scope node so we can
+ // refer to the parameters correctly.
+ scope_node->index_lookup_table = index_lookup_table;
+ iseq_calc_param_size(iseq);
+
+ if (ISEQ_BODY(iseq)->param.flags.forwardable) {
+ // We're treating `...` as a parameter so that frame
+ // pushing won't clobber it.
+ ISEQ_BODY(iseq)->param.size += 1;
+ }
+
+ // FIXME: args?
+ iseq_set_local_table(iseq, local_table_for_iseq, 0);
+ iseq_set_parameters_lvar_state(iseq);
+
+ scope_node->local_table_for_iseq_size = local_table_for_iseq->size;
+
+ if (keyword != NULL) {
+ size_t keyword_start_index = keyword->bits_start - keyword->num;
+ keyword->table = (ID *)&ISEQ_BODY(iseq)->local_table[keyword_start_index];
+ }
+
+ //********STEP 5************
+ // Goal: compile anything that needed to be compiled
+ if (optionals_list && optionals_list->size) {
+ LABEL **opt_table = (LABEL **) ALLOC_N(VALUE, optionals_list->size + 1);
+ LABEL *label;
+
+ // TODO: Should we make an api for NEW_LABEL where you can pass
+ // a pointer to the label it should fill out? We already
+ // have a list of labels allocated above so it seems wasteful
+ // to do the copies.
+ for (size_t i = 0; i < optionals_list->size; i++) {
+ label = NEW_LABEL(location.line);
+ opt_table[i] = label;
+ PUSH_LABEL(ret, label);
+ pm_node_t *optional_node = optionals_list->nodes[i];
+ PM_COMPILE_NOT_POPPED(optional_node);
+ }
+
+ // Set the last label
+ label = NEW_LABEL(location.line);
+ opt_table[optionals_list->size] = label;
+ PUSH_LABEL(ret, label);
+
+ body->param.opt_table = (const VALUE *) opt_table;
+ }
+
+ if (keywords_list && keywords_list->size) {
+ size_t optional_index = 0;
+ for (size_t i = 0; i < keywords_list->size; i++) {
+ pm_node_t *keyword_parameter_node = keywords_list->nodes[i];
+ pm_constant_id_t name;
+
+ switch (PM_NODE_TYPE(keyword_parameter_node)) {
+ case PM_OPTIONAL_KEYWORD_PARAMETER_NODE: {
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^^^
+ const pm_optional_keyword_parameter_node_t *cast = ((const pm_optional_keyword_parameter_node_t *) keyword_parameter_node);
+
+ pm_node_t *value = cast->value;
+ name = cast->name;
+
+ if (!PM_NODE_FLAG_P(value, PM_NODE_FLAG_STATIC_LITERAL) || PM_CONTAINER_P(value)) {
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, name, 0);
+ int kw_bits_idx = table_size - body->param.keyword->bits_start;
+ PUSH_INSN2(ret, location, checkkeyword, INT2FIX(kw_bits_idx + VM_ENV_DATA_SIZE - 1), INT2FIX(optional_index));
+ PUSH_INSNL(ret, location, branchif, end_label);
+ PM_COMPILE(value);
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+ PUSH_LABEL(ret, end_label);
+ }
+ optional_index++;
+ break;
+ }
+ case PM_REQUIRED_KEYWORD_PARAMETER_NODE:
+ // def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
+ // ^^
+ break;
+ default:
+ rb_bug("Unexpected keyword parameter node type %s", pm_node_type(PM_NODE_TYPE(keyword_parameter_node)));
+ }
+ }
+ }
+
+ if (requireds_list && requireds_list->size) {
+ for (size_t i = 0; i < requireds_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one additional
+ // anonymous local not represented in the locals table. We want
+ // to account for this in our table size.
+ const pm_node_t *required = requireds_list->nodes[i];
+
+ if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
+ PUSH_GETLOCAL(ret, location, table_size - (int)i, 0);
+ pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) required, ret, scope_node);
+ }
+ }
+ }
+
+ if (posts_list && posts_list->size) {
+ for (size_t i = 0; i < posts_list->size; i++) {
+ // For each MultiTargetNode, we're going to have one additional
+ // anonymous local not represented in the locals table. We want
+ // to account for this in our table size.
+ const pm_node_t *post = posts_list->nodes[i];
+
+ if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
+ PUSH_GETLOCAL(ret, location, table_size - body->param.post_start - (int) i, 0);
+ pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) post, ret, scope_node);
+ }
+ }
+ }
+
+ switch (body->type) {
+ case ISEQ_TYPE_PLAIN: {
+ RUBY_ASSERT(PM_NODE_TYPE_P(scope_node->ast_node, PM_INTERPOLATED_REGULAR_EXPRESSION_NODE));
+
+ const pm_interpolated_regular_expression_node_t *cast = (const pm_interpolated_regular_expression_node_t *) scope_node->ast_node;
+ pm_compile_regexp_dynamic(iseq, (const pm_node_t *) cast, &cast->parts, &location, ret, popped, scope_node);
+
+ break;
+ }
+ case ISEQ_TYPE_BLOCK: {
+ LABEL *start = ISEQ_COMPILE_DATA(iseq)->start_label = NEW_LABEL(0);
+ LABEL *end = ISEQ_COMPILE_DATA(iseq)->end_label = NEW_LABEL(0);
+ const pm_node_location_t block_location = { .line = body->location.first_lineno, .node_id = scope_node->ast_node->node_id };
+
+ start->rescued = LABEL_RESCUE_BEG;
+ end->rescued = LABEL_RESCUE_END;
+
+ // For nodes automatically assign the iteration variable to whatever
+ // index variable. We need to handle that write here because it has
+ // to happen in the context of the block. Note that this happens
+ // before the B_CALL tracepoint event.
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_FOR_NODE)) {
+ pm_compile_for_node_index(iseq, ((const pm_for_node_t *) scope_node->ast_node)->index, ret, scope_node);
+ }
+
+ PUSH_TRACE(ret, RUBY_EVENT_B_CALL);
+ PUSH_INSN(ret, block_location, nop);
+ PUSH_LABEL(ret, start);
+
+ if (scope_node->body != NULL) {
+ switch (PM_NODE_TYPE(scope_node->ast_node)) {
+ case PM_POST_EXECUTION_NODE: {
+ const pm_post_execution_node_t *cast = (const pm_post_execution_node_t *) scope_node->ast_node;
+ PUSH_INSN1(ret, block_location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ // We create another ScopeNode from the statements within the PostExecutionNode
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast->statements, &next_scope_node, scope_node);
+
+ const rb_iseq_t *block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(body->parent_iseq), ISEQ_TYPE_BLOCK, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ PUSH_CALL_WITH_BLOCK(ret, block_location, id_core_set_postexe, INT2FIX(0), block);
+ break;
+ }
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
+ const pm_interpolated_regular_expression_node_t *cast = (const pm_interpolated_regular_expression_node_t *) scope_node->ast_node;
+ pm_compile_regexp_dynamic(iseq, (const pm_node_t *) cast, &cast->parts, &location, ret, popped, scope_node);
+ break;
+ }
+ default:
+ pm_compile_node(iseq, scope_node->body, ret, popped, scope_node);
+ break;
+ }
+ }
+ else {
+ PUSH_INSN(ret, block_location, putnil);
+ }
+
+ PUSH_LABEL(ret, end);
+ PUSH_TRACE(ret, RUBY_EVENT_B_RETURN);
+ ISEQ_COMPILE_DATA(iseq)->last_line = body->location.code_location.end_pos.lineno;
+
+ /* wide range catch handler must put at last */
+ PUSH_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, NULL, start);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, NULL, end);
+ break;
+ }
+ case ISEQ_TYPE_ENSURE: {
+ const pm_node_location_t statements_location = (scope_node->body != NULL ? PM_NODE_START_LOCATION(scope_node->body) : location);
+ iseq_set_exception_local_table(iseq);
+
+ if (scope_node->body != NULL) {
+ PM_COMPILE_POPPED((const pm_node_t *) scope_node->body);
+ }
+
+ PUSH_GETLOCAL(ret, statements_location, 1, 0);
+ PUSH_INSN1(ret, statements_location, throw, INT2FIX(0));
+ return;
+ }
+ case ISEQ_TYPE_METHOD: {
+ ISEQ_COMPILE_DATA(iseq)->root_node = (const void *) scope_node->body;
+ PUSH_TRACE(ret, RUBY_EVENT_CALL);
+
+ if (scope_node->body) {
+ PM_COMPILE((const pm_node_t *) scope_node->body);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ ISEQ_COMPILE_DATA(iseq)->root_node = (const void *) scope_node->body;
+ PUSH_TRACE(ret, RUBY_EVENT_RETURN);
+
+ ISEQ_COMPILE_DATA(iseq)->last_line = body->location.code_location.end_pos.lineno;
+ break;
+ }
+ case ISEQ_TYPE_RESCUE: {
+ iseq_set_exception_local_table(iseq);
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_RESCUE_MODIFIER_NODE)) {
+ LABEL *lab = NEW_LABEL(location.line);
+ LABEL *rescue_end = NEW_LABEL(location.line);
+ PUSH_GETLOCAL(ret, location, LVAR_ERRINFO, 0);
+ PUSH_INSN1(ret, location, putobject, rb_eStandardError);
+ PUSH_INSN1(ret, location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
+ PUSH_INSNL(ret, location, branchif, lab);
+ PUSH_INSNL(ret, location, jump, rescue_end);
+ PUSH_LABEL(ret, lab);
+ PUSH_TRACE(ret, RUBY_EVENT_RESCUE);
+ PM_COMPILE((const pm_node_t *) scope_node->body);
+ PUSH_INSN(ret, location, leave);
+ PUSH_LABEL(ret, rescue_end);
+ PUSH_GETLOCAL(ret, location, LVAR_ERRINFO, 0);
+ }
+ else {
+ PM_COMPILE((const pm_node_t *) scope_node->ast_node);
+ }
+ PUSH_INSN1(ret, location, throw, INT2FIX(0));
+
+ return;
+ }
+ default:
+ if (scope_node->body) {
+ PM_COMPILE((const pm_node_t *) scope_node->body);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+ break;
+ }
+
+ if (PM_NODE_TYPE_P(scope_node->ast_node, PM_CLASS_NODE) || PM_NODE_TYPE_P(scope_node->ast_node, PM_MODULE_NODE)) {
+ const pm_node_location_t end_location = PM_NODE_END_LOCATION(scope_node->ast_node);
+ PUSH_TRACE(ret, RUBY_EVENT_END);
+ ISEQ_COMPILE_DATA(iseq)->last_line = end_location.line;
+ }
+
+ if (!PM_NODE_TYPE_P(scope_node->ast_node, PM_ENSURE_NODE)) {
+ const pm_node_location_t location = { .line = ISEQ_COMPILE_DATA(iseq)->last_line, .node_id = scope_node->ast_node->node_id };
+ PUSH_INSN(ret, location, leave);
+ }
+}
+
+static inline void
+pm_compile_alias_global_variable_node(rb_iseq_t *iseq, const pm_alias_global_variable_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ // alias $foo $bar
+ // ^^^^^^^^^^^^^^^
+ PUSH_INSN1(ret, *location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ {
+ const pm_location_t *name_loc = &node->new_name->location;
+ VALUE operand = ID2SYM(rb_intern3((const char *) (pm_parser_start(scope_node->parser) + name_loc->start), name_loc->length, scope_node->encoding));
+ PUSH_INSN1(ret, *location, putobject, operand);
+ }
+
+ {
+ const pm_location_t *name_loc = &node->old_name->location;
+ VALUE operand = ID2SYM(rb_intern3((const char *) (pm_parser_start(scope_node->parser) + name_loc->start), name_loc->length, scope_node->encoding));
+ PUSH_INSN1(ret, *location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, *location, id_core_set_variable_alias, INT2FIX(2));
+ if (popped) PUSH_INSN(ret, *location, pop);
+}
+
+static inline void
+pm_compile_alias_method_node(rb_iseq_t *iseq, const pm_alias_method_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ PUSH_INSN1(ret, *location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, *location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
+ PM_COMPILE_NOT_POPPED(node->new_name);
+ PM_COMPILE_NOT_POPPED(node->old_name);
+
+ PUSH_SEND(ret, *location, id_core_set_method_alias, INT2FIX(3));
+ if (popped) PUSH_INSN(ret, *location, pop);
+}
+
+static inline void
+pm_compile_and_node(rb_iseq_t *iseq, const pm_and_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ LABEL *end_label = NEW_LABEL(location->line);
+
+ PM_COMPILE_NOT_POPPED(node->left);
+ if (!popped) PUSH_INSN(ret, *location, dup);
+ PUSH_INSNL(ret, *location, branchunless, end_label);
+
+ if (!popped) PUSH_INSN(ret, *location, pop);
+ PM_COMPILE(node->right);
+ PUSH_LABEL(ret, end_label);
+}
+
+static inline void
+pm_compile_array_node(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_list_t *elements, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ // If every node in the array is static, then we can compile the entire
+ // array now instead of later.
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ // We're only going to compile this node if it's not popped. If it
+ // is popped, then we know we don't need to do anything since it's
+ // statically known.
+ if (!popped) {
+ if (elements->size) {
+ VALUE value = pm_static_literal_value(iseq, node, scope_node);
+ RB_OBJ_SET_FROZEN_SHAREABLE(value);
+ PUSH_INSN1(ret, *location, duparray, value);
+ }
+ else {
+ PUSH_INSN1(ret, *location, newarray, INT2FIX(0));
+ }
+ }
+ return;
+ }
+
+ // Here since we know there are possible side-effects inside the
+ // array contents, we're going to build it entirely at runtime.
+ // We'll do this by pushing all of the elements onto the stack and
+ // then combining them with newarray.
+ //
+ // If this array is popped, then this serves only to ensure we enact
+ // all side-effects (like method calls) that are contained within
+ // the array contents.
+ //
+ // We treat all sequences of non-splat elements as their
+ // own arrays, followed by a newarray, and then continually
+ // concat the arrays with the SplatNode nodes.
+ const int max_new_array_size = 0x100;
+ const unsigned int min_tmp_array_size = 0x40;
+
+ int new_array_size = 0;
+ bool first_chunk = true;
+
+ // This is an optimization wherein we keep track of whether or not
+ // the previous element was a static literal. If it was, then we do
+ // not attempt to check if we have a subarray that can be optimized.
+ // If it was not, then we do check.
+ bool static_literal = false;
+
+ // Either create a new array, or push to the existing array.
+#define FLUSH_CHUNK \
+ if (new_array_size) { \
+ if (first_chunk) PUSH_INSN1(ret, *location, newarray, INT2FIX(new_array_size)); \
+ else PUSH_INSN1(ret, *location, pushtoarray, INT2FIX(new_array_size)); \
+ first_chunk = false; \
+ new_array_size = 0; \
+ }
+
+ for (size_t index = 0; index < elements->size; index++) {
+ const pm_node_t *element = elements->nodes[index];
+
+ if (PM_NODE_TYPE_P(element, PM_SPLAT_NODE)) {
+ FLUSH_CHUNK;
+
+ const pm_splat_node_t *splat_element = (const pm_splat_node_t *) element;
+ if (splat_element->expression) {
+ PM_COMPILE_NOT_POPPED(splat_element->expression);
+ }
+ else {
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_MULT, 0);
+ PUSH_GETLOCAL(ret, *location, index.index, index.level);
+ }
+
+ if (first_chunk) {
+ // If this is the first element of the array then we
+ // need to splatarray the elements into the list.
+ PUSH_INSN1(ret, *location, splatarray, Qtrue);
+ first_chunk = false;
+ }
+ else {
+ PUSH_INSN(ret, *location, concattoarray);
+ }
+
+ static_literal = false;
+ }
+ else if (PM_NODE_TYPE_P(element, PM_KEYWORD_HASH_NODE)) {
+ if (new_array_size == 0 && first_chunk) {
+ PUSH_INSN1(ret, *location, newarray, INT2FIX(0));
+ first_chunk = false;
+ }
+ else {
+ FLUSH_CHUNK;
+ }
+
+ // If we get here, then this is the last element of the
+ // array/arguments, because it cannot be followed by
+ // anything else without a syntax error. This looks like:
+ //
+ // [foo, bar, baz: qux]
+ // ^^^^^^^^
+ //
+ // [foo, bar, **baz]
+ // ^^^^^
+ //
+ const pm_keyword_hash_node_t *keyword_hash = (const pm_keyword_hash_node_t *) element;
+ pm_compile_hash_elements(iseq, element, &keyword_hash->elements, 0, Qundef, false, ret, scope_node);
+
+ // This boolean controls the manner in which we push the
+ // hash onto the array. If it's all keyword splats, then we
+ // can use the very specialized pushtoarraykwsplat
+ // instruction to check if it's empty before we push it.
+ size_t splats = 0;
+ while (splats < keyword_hash->elements.size && PM_NODE_TYPE_P(keyword_hash->elements.nodes[splats], PM_ASSOC_SPLAT_NODE)) splats++;
+
+ if (keyword_hash->elements.size == splats) {
+ PUSH_INSN(ret, *location, pushtoarraykwsplat);
+ }
+ else {
+ new_array_size++;
+ }
+ }
+ else if (
+ PM_NODE_FLAG_P(element, PM_NODE_FLAG_STATIC_LITERAL) &&
+ !PM_CONTAINER_P(element) &&
+ !static_literal &&
+ ((index + min_tmp_array_size) < elements->size)
+ ) {
+ // If we have a static literal, then there's the potential
+ // to group a bunch of them together with a literal array
+ // and then concat them together.
+ size_t right_index = index + 1;
+ while (
+ right_index < elements->size &&
+ PM_NODE_FLAG_P(elements->nodes[right_index], PM_NODE_FLAG_STATIC_LITERAL) &&
+ !PM_CONTAINER_P(elements->nodes[right_index])
+ ) right_index++;
+
+ size_t tmp_array_size = right_index - index;
+ if (tmp_array_size >= min_tmp_array_size) {
+ VALUE tmp_array = rb_ary_hidden_new(tmp_array_size);
+
+ // Create the temporary array.
+ for (; tmp_array_size; tmp_array_size--)
+ rb_ary_push(tmp_array, pm_static_literal_value(iseq, elements->nodes[index++], scope_node));
+
+ index--; // about to be incremented by for loop
+ RB_OBJ_SET_FROZEN_SHAREABLE(tmp_array);
+
+ // Emit the optimized code.
+ FLUSH_CHUNK;
+ if (first_chunk) {
+ PUSH_INSN1(ret, *location, duparray, tmp_array);
+ first_chunk = false;
+ }
+ else {
+ PUSH_INSN1(ret, *location, putobject, tmp_array);
+ PUSH_INSN(ret, *location, concattoarray);
+ }
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(element);
+ if (++new_array_size >= max_new_array_size) FLUSH_CHUNK;
+ static_literal = true;
+ }
+ } else {
+ PM_COMPILE_NOT_POPPED(element);
+ if (++new_array_size >= max_new_array_size) FLUSH_CHUNK;
+ static_literal = false;
+ }
+ }
+
+ FLUSH_CHUNK;
+ if (popped) PUSH_INSN(ret, *location, pop);
+
+#undef FLUSH_CHUNK
+}
+
+static inline void
+pm_compile_break_node(rb_iseq_t *iseq, const pm_break_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ unsigned long throw_flag = 0;
+
+ if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0 && can_add_ensure_iseq(iseq)) {
+ /* while/until */
+ LABEL *splabel = NEW_LABEL(0);
+ PUSH_LABEL(ret, splabel);
+ PUSH_ADJUST(ret, *location, ISEQ_COMPILE_DATA(iseq)->redo_label);
+
+ if (node->arguments != NULL) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ pm_add_ensure_iseq(ret, iseq, 0, scope_node);
+ PUSH_INSNL(ret, *location, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else {
+ const rb_iseq_t *ip = iseq;
+
+ while (ip) {
+ if (!ISEQ_COMPILE_DATA(ip)) {
+ ip = 0;
+ break;
+ }
+
+ if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
+ throw_flag = VM_THROW_NO_ESCAPE_FLAG;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
+ throw_flag = 0;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
+ COMPILE_ERROR(iseq, location->line, "Invalid break");
+ return;
+ }
+ else {
+ ip = ISEQ_BODY(ip)->parent_iseq;
+ continue;
+ }
+
+ /* escape from block */
+ if (node->arguments != NULL) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ PUSH_INSN1(ret, *location, throw, INT2FIX(throw_flag | TAG_BREAK));
+ if (popped) PUSH_INSN(ret, *location, pop);
+
+ return;
+ }
+
+ COMPILE_ERROR(iseq, location->line, "Invalid break");
+ }
+}
+
+static inline void
+pm_compile_call_node(rb_iseq_t *iseq, const pm_call_node_t *node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ ID method_id = pm_constant_id_lookup(scope_node, node->name);
+
+ const pm_location_t *message_loc = &node->message_loc;
+ if (message_loc->length == 0) message_loc = &node->base.location;
+
+ const pm_node_location_t location = PM_LOCATION_START_LOCATION(message_loc, node->base.node_id);
+ const char *builtin_func;
+
+ if (UNLIKELY(iseq_has_builtin_function_table(iseq)) && (builtin_func = pm_iseq_builtin_function_name(scope_node, node->receiver, method_id)) != NULL) {
+ pm_compile_builtin_function_call(iseq, ret, scope_node, node, &location, popped, ISEQ_COMPILE_DATA(iseq)->current_block, builtin_func);
+ return;
+ }
+
+ LABEL *start = NEW_LABEL(location.line);
+ if (node->block) PUSH_LABEL(ret, start);
+
+ switch (method_id) {
+ case idUMinus: {
+ if (pm_opt_str_freeze_p(iseq, node)) {
+ VALUE value = parse_static_literal_string(iseq, scope_node, node->receiver, &((const pm_string_node_t * ) node->receiver)->unescaped);
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE);
+ PUSH_INSN2(ret, location, opt_str_uminus, value, callinfo);
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ break;
+ }
+ case idFreeze: {
+ if (pm_opt_str_freeze_p(iseq, node)) {
+ VALUE value = parse_static_literal_string(iseq, scope_node, node->receiver, &((const pm_string_node_t * ) node->receiver)->unescaped);
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, idFreeze, 0, 0, NULL, FALSE);
+ PUSH_INSN2(ret, location, opt_str_freeze, value, callinfo);
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ break;
+ }
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE) && !popped) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ if (node->receiver == NULL) {
+ PUSH_INSN(ret, location, putself);
+ }
+ else {
+ if (method_id == idCall && PM_NODE_TYPE_P(node->receiver, PM_LOCAL_VARIABLE_READ_NODE)) {
+ const pm_local_variable_read_node_t *read_node_cast = (const pm_local_variable_read_node_t *) node->receiver;
+ uint32_t node_id = node->receiver->node_id;
+ int idx, level;
+
+ if (iseq_block_param_id_p(iseq, pm_constant_id_lookup(scope_node, read_node_cast->name), &idx, &level)) {
+ ADD_ELEM(ret, (LINK_ELEMENT *) new_insn_body(iseq, location.line, node_id, BIN(getblockparamproxy), 2, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)));
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->receiver);
+ }
+ }
+ else {
+ PM_COMPILE_NOT_POPPED(node->receiver);
+ }
+ }
+
+ pm_compile_call(iseq, node, ret, popped, scope_node, method_id, start);
+ return;
+}
+
+static inline void
+pm_compile_call_operator_write_node(rb_iseq_t *iseq, const pm_call_operator_write_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ int flag = 0;
+
+ if (PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY)) {
+ flag = VM_CALL_FCALL;
+ }
+
+ PM_COMPILE_NOT_POPPED(node->receiver);
+
+ LABEL *safe_label = NULL;
+ if (PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) {
+ safe_label = NEW_LABEL(location->line);
+ PUSH_INSN(ret, *location, dup);
+ PUSH_INSNL(ret, *location, branchnil, safe_label);
+ }
+
+ PUSH_INSN(ret, *location, dup);
+
+ ID id_read_name = pm_constant_id_lookup(scope_node, node->read_name);
+ PUSH_SEND_WITH_FLAG(ret, *location, id_read_name, INT2FIX(0), INT2FIX(flag));
+
+ PM_COMPILE_NOT_POPPED(node->value);
+ ID id_operator = pm_constant_id_lookup(scope_node, node->binary_operator);
+ PUSH_SEND(ret, *location, id_operator, INT2FIX(1));
+
+ if (!popped) {
+ PUSH_INSN(ret, *location, swap);
+ PUSH_INSN1(ret, *location, topn, INT2FIX(1));
+ }
+
+ ID id_write_name = pm_constant_id_lookup(scope_node, node->write_name);
+ PUSH_SEND_WITH_FLAG(ret, *location, id_write_name, INT2FIX(1), INT2FIX(flag));
+
+ if (safe_label != NULL && popped) PUSH_LABEL(ret, safe_label);
+ PUSH_INSN(ret, *location, pop);
+ if (safe_label != NULL && !popped) PUSH_LABEL(ret, safe_label);
+}
+
+/**
+ * When we're compiling a case node, it's possible that we can speed it up using
+ * a dispatch hash, which will allow us to jump directly to the correct when
+ * clause body based on a hash lookup of the value. This can only happen when
+ * the conditions are literals that can be compiled into a hash key.
+ *
+ * This function accepts a dispatch hash and the condition of a when clause. It
+ * is responsible for compiling the condition into a hash key and then adding it
+ * to the dispatch hash.
+ *
+ * If the value can be successfully compiled into the hash, then this function
+ * returns the dispatch hash with the new key added. If the value cannot be
+ * compiled into the hash, then this function returns Qundef. In the case of
+ * Qundef, this function is signaling that the caller should abandon the
+ * optimization entirely.
+ */
+static VALUE
+pm_compile_case_node_dispatch(rb_iseq_t *iseq, VALUE dispatch, const pm_node_t *node, LABEL *label, pm_scope_node_t *scope_node)
+{
+ VALUE key = Qundef;
+ switch (PM_NODE_TYPE(node)) {
+ case PM_FLOAT_NODE: {
+ key = pm_static_literal_value(iseq, node, scope_node);
+ double intptr;
+
+ if (modf(RFLOAT_VALUE(key), &intptr) == 0.0) {
+ key = (FIXABLE(intptr) ? LONG2FIX((long) intptr) : rb_dbl2big(intptr));
+ }
+
+ break;
+ }
+ case PM_FALSE_NODE:
+ case PM_INTEGER_NODE:
+ case PM_NIL_NODE:
+ case PM_SOURCE_FILE_NODE:
+ case PM_SOURCE_LINE_NODE:
+ case PM_SYMBOL_NODE:
+ case PM_TRUE_NODE:
+ key = pm_static_literal_value(iseq, node, scope_node);
+ break;
+ case PM_STRING_NODE: {
+ const pm_string_node_t *cast = (const pm_string_node_t *) node;
+ key = parse_static_literal_string(iseq, scope_node, node, &cast->unescaped);
+ break;
+ }
+ default:
+ return Qundef;
+ }
+
+ cdhash_aset_if_missing(dispatch, key, (VALUE)label);
+ return dispatch;
+}
+
+/**
+ * Compile a case node, representing a case statement with when clauses.
+ */
+static inline void
+pm_compile_case_node(rb_iseq_t *iseq, const pm_case_node_t *cast, const pm_node_location_t *node_location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = *node_location;
+ const pm_node_list_t *conditions = &cast->conditions;
+
+ // This is the anchor that we will compile the conditions of the various
+ // `when` nodes into. If a match is found, they will need to jump into
+ // the body_seq anchor to the correct spot.
+ DECL_ANCHOR(cond_seq);
+
+ // This is the anchor that we will compile the bodies of the various
+ // `when` nodes into. We'll make sure that the clauses that are compiled
+ // jump into the correct spots within this anchor.
+ DECL_ANCHOR(body_seq);
+
+ // This is the label where all of the when clauses will jump to if they
+ // have matched and are done executing their bodies.
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ // If we have a predicate on this case statement, then it's going to
+ // compare all of the various when clauses to the predicate. If we
+ // don't, then it's basically an if-elsif-else chain.
+ if (cast->predicate == NULL) {
+ // Establish branch coverage for the case node.
+ VALUE branches = Qfalse;
+ rb_code_location_t case_location = { 0 };
+ int branch_id = 0;
+
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ case_location = pm_code_location(scope_node, (const pm_node_t *) cast);
+ branches = decl_branch_base(iseq, PTR2NUM(cast), &case_location, "case");
+ }
+
+ // Loop through each clauses in the case node and compile each of
+ // the conditions within them into cond_seq. If they match, they
+ // should jump into their respective bodies in body_seq.
+ for (size_t clause_index = 0; clause_index < conditions->size; clause_index++) {
+ const pm_when_node_t *clause = (const pm_when_node_t *) conditions->nodes[clause_index];
+ const pm_node_list_t *conditions = &clause->conditions;
+
+ int clause_lineno = pm_node_line_number_cached((const pm_node_t *) clause, scope_node);
+ LABEL *label = NEW_LABEL(clause_lineno);
+ PUSH_LABEL(body_seq, label);
+
+ // Establish branch coverage for the when clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location = pm_code_location(scope_node, clause->statements != NULL ? ((const pm_node_t *) clause->statements) : ((const pm_node_t *) clause));
+ add_trace_branch_coverage(iseq, body_seq, &branch_location, branch_location.beg_pos.column, branch_id++, "when", branches);
+ }
+
+ if (clause->statements != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) clause->statements, body_seq, popped, scope_node);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(body_seq, iseq);
+ }
+
+ PUSH_INSNL(body_seq, location, jump, end_label);
+
+ // Compile each of the conditions for the when clause into the
+ // cond_seq. Each one should have a unique condition and should
+ // jump to the subsequent one if it doesn't match.
+ for (size_t condition_index = 0; condition_index < conditions->size; condition_index++) {
+ const pm_node_t *condition = conditions->nodes[condition_index];
+
+ if (PM_NODE_TYPE_P(condition, PM_SPLAT_NODE)) {
+ pm_node_location_t cond_location = PM_NODE_START_LOCATION(condition);
+ PUSH_INSN(cond_seq, cond_location, putnil);
+ pm_compile_node(iseq, condition, cond_seq, false, scope_node);
+ PUSH_INSN1(cond_seq, cond_location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_WHEN | VM_CHECKMATCH_ARRAY));
+ PUSH_INSNL(cond_seq, cond_location, branchif, label);
+ }
+ else {
+ LABEL *next_label = NEW_LABEL(pm_node_line_number_cached(condition, scope_node));
+ pm_compile_branch_condition(iseq, cond_seq, condition, label, next_label, scope_node);
+ PUSH_LABEL(cond_seq, next_label);
+ }
+ }
+ }
+
+ // Establish branch coverage for the else clause (implicit or
+ // explicit).
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location;
+
+ if (cast->else_clause == NULL) {
+ branch_location = case_location;
+ } else if (cast->else_clause->statements == NULL) {
+ branch_location = pm_code_location(scope_node, (const pm_node_t *) cast->else_clause);
+ } else {
+ branch_location = pm_code_location(scope_node, (const pm_node_t *) cast->else_clause->statements);
+ }
+
+ add_trace_branch_coverage(iseq, cond_seq, &branch_location, branch_location.beg_pos.column, branch_id, "else", branches);
+ }
+
+ // Compile the else clause if there is one.
+ if (cast->else_clause != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) cast->else_clause, cond_seq, popped, scope_node);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(cond_seq, iseq);
+ }
+
+ // Finally, jump to the end label if none of the other conditions
+ // have matched.
+ PUSH_INSNL(cond_seq, location, jump, end_label);
+ PUSH_SEQ(ret, cond_seq);
+ }
+ else {
+ // Establish branch coverage for the case node.
+ VALUE branches = Qfalse;
+ rb_code_location_t case_location = { 0 };
+ int branch_id = 0;
+
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ case_location = pm_code_location(scope_node, (const pm_node_t *) cast);
+ branches = decl_branch_base(iseq, PTR2NUM(cast), &case_location, "case");
+ }
+
+ // This is the label where everything will fall into if none of the
+ // conditions matched.
+ LABEL *else_label = NEW_LABEL(location.line);
+
+ // It's possible for us to speed up the case node by using a
+ // dispatch hash. This is a hash that maps the conditions of the
+ // various when clauses to the labels of their bodies. If we can
+ // compile the conditions into a hash key, then we can use a hash
+ // lookup to jump directly to the correct when clause body.
+ VALUE dispatch = Qundef;
+ if (ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
+ dispatch = cdhash_new(0);
+ }
+
+ // We're going to loop through each of the conditions in the case
+ // node and compile each of their contents into both the cond_seq
+ // and the body_seq. Each condition will use its own label to jump
+ // from its conditions into its body.
+ //
+ // Note that none of the code in the loop below should be adding
+ // anything to ret, as we're going to be laying out the entire case
+ // node instructions later.
+ for (size_t clause_index = 0; clause_index < conditions->size; clause_index++) {
+ const pm_when_node_t *clause = (const pm_when_node_t *) conditions->nodes[clause_index];
+ pm_node_location_t clause_location = PM_NODE_START_LOCATION((const pm_node_t *) clause);
+
+ const pm_node_list_t *conditions = &clause->conditions;
+ LABEL *label = NEW_LABEL(clause_location.line);
+
+ // Compile each of the conditions for the when clause into the
+ // cond_seq. Each one should have a unique comparison that then
+ // jumps into the body if it matches.
+ for (size_t condition_index = 0; condition_index < conditions->size; condition_index++) {
+ const pm_node_t *condition = conditions->nodes[condition_index];
+ const pm_node_location_t condition_location = PM_NODE_START_LOCATION(condition);
+
+ // If we haven't already abandoned the optimization, then
+ // we're going to try to compile the condition into the
+ // dispatch hash.
+ if (dispatch != Qundef) {
+ dispatch = pm_compile_case_node_dispatch(iseq, dispatch, condition, label, scope_node);
+ }
+
+ if (PM_NODE_TYPE_P(condition, PM_SPLAT_NODE)) {
+ PUSH_INSN(cond_seq, condition_location, dup);
+ pm_compile_node(iseq, condition, cond_seq, false, scope_node);
+ PUSH_INSN1(cond_seq, condition_location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
+ }
+ else {
+ if (PM_NODE_TYPE_P(condition, PM_STRING_NODE)) {
+ const pm_string_node_t *string = (const pm_string_node_t *) condition;
+ VALUE value = parse_static_literal_string(iseq, scope_node, condition, &string->unescaped);
+ PUSH_INSN1(cond_seq, condition_location, putobject, value);
+ }
+ else {
+ pm_compile_node(iseq, condition, cond_seq, false, scope_node);
+ }
+
+ PUSH_INSN1(cond_seq, condition_location, topn, INT2FIX(1));
+ PUSH_SEND_WITH_FLAG(cond_seq, condition_location, idEqq, INT2NUM(1), INT2FIX(VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE));
+ }
+
+ PUSH_INSNL(cond_seq, condition_location, branchif, label);
+ }
+
+ // Now, add the label to the body and compile the body of the
+ // when clause. This involves popping the predicate, compiling
+ // the statements to be executed, and then compiling a jump to
+ // the end of the case node.
+ PUSH_LABEL(body_seq, label);
+ PUSH_INSN(body_seq, clause_location, pop);
+
+ // Establish branch coverage for the when clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location = pm_code_location(scope_node, clause->statements != NULL ? ((const pm_node_t *) clause->statements) : ((const pm_node_t *) clause));
+ add_trace_branch_coverage(iseq, body_seq, &branch_location, branch_location.beg_pos.column, branch_id++, "when", branches);
+ }
+
+ if (clause->statements != NULL) {
+ pm_compile_node(iseq, (const pm_node_t *) clause->statements, body_seq, popped, scope_node);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(body_seq, iseq);
+ }
+
+ PUSH_INSNL(body_seq, clause_location, jump, end_label);
+ }
+
+ // Now that we have compiled the conditions and the bodies of the
+ // various when clauses, we can compile the predicate, lay out the
+ // conditions, compile the fallback subsequent if there is one, and
+ // finally put in the bodies of the when clauses.
+ PM_COMPILE_NOT_POPPED(cast->predicate);
+
+ // If we have a dispatch hash, then we'll use it here to create the
+ // optimization.
+ if (dispatch != Qundef) {
+ PUSH_INSN(ret, location, dup);
+ RB_OBJ_SET_SHAREABLE(dispatch); // it is special that the hash is shareable but not frozen, because compile.c modify them. This Hahs instance is not accessible so it is safe to leave it.
+ PUSH_INSN2(ret, location, opt_case_dispatch, dispatch, else_label);
+ LABEL_REF(else_label);
+ }
+
+ PUSH_SEQ(ret, cond_seq);
+
+ // Compile either the explicit else clause or an implicit else
+ // clause.
+ PUSH_LABEL(ret, else_label);
+
+ if (cast->else_clause != NULL) {
+ pm_node_location_t else_location = PM_NODE_START_LOCATION(cast->else_clause->statements != NULL ? ((const pm_node_t *) cast->else_clause->statements) : ((const pm_node_t *) cast->else_clause));
+ PUSH_INSN(ret, else_location, pop);
+
+ // Establish branch coverage for the else clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location = pm_code_location(scope_node, cast->else_clause->statements != NULL ? ((const pm_node_t *) cast->else_clause->statements) : ((const pm_node_t *) cast->else_clause));
+ add_trace_branch_coverage(iseq, ret, &branch_location, branch_location.beg_pos.column, branch_id, "else", branches);
+ }
+
+ PM_COMPILE((const pm_node_t *) cast->else_clause);
+ PUSH_INSNL(ret, else_location, jump, end_label);
+ }
+ else {
+ PUSH_INSN(ret, location, pop);
+
+ // Establish branch coverage for the implicit else clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ add_trace_branch_coverage(iseq, ret, &case_location, case_location.beg_pos.column, branch_id, "else", branches);
+ }
+
+ if (!popped) PUSH_INSN(ret, location, putnil);
+ PUSH_INSNL(ret, location, jump, end_label);
+ }
+ }
+
+ PUSH_SEQ(ret, body_seq);
+ PUSH_LABEL(ret, end_label);
+}
+
+static inline void
+pm_compile_case_match_node(rb_iseq_t *iseq, const pm_case_match_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ // This is the anchor that we will compile the bodies of the various
+ // `in` nodes into. We'll make sure that the patterns that are compiled
+ // jump into the correct spots within this anchor.
+ DECL_ANCHOR(body_seq);
+
+ // This is the anchor that we will compile the patterns of the various
+ // `in` nodes into. If a match is found, they will need to jump into the
+ // body_seq anchor to the correct spot.
+ DECL_ANCHOR(cond_seq);
+
+ // This label is used to indicate the end of the entire node. It is
+ // jumped to after the entire stack is cleaned up.
+ LABEL *end_label = NEW_LABEL(location->line);
+
+ // This label is used as the fallback for the case match. If no match is
+ // found, then we jump to this label. This is either an `else` clause or
+ // an error handler.
+ LABEL *else_label = NEW_LABEL(location->line);
+
+ // We're going to use this to uniquely identify each branch so that we
+ // can track coverage information.
+ rb_code_location_t case_location = { 0 };
+ VALUE branches = Qfalse;
+ int branch_id = 0;
+
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ case_location = pm_code_location(scope_node, (const pm_node_t *) node);
+ branches = decl_branch_base(iseq, PTR2NUM(node), &case_location, "case");
+ }
+
+ // If there is only one pattern, then the behavior changes a bit. It
+ // effectively gets treated as a match required node (this is how it is
+ // represented in the other parser).
+ bool in_single_pattern = node->else_clause == NULL && node->conditions.size == 1;
+
+ // First, we're going to push a bunch of stuff onto the stack that is
+ // going to serve as our scratch space.
+ if (in_single_pattern) {
+ PUSH_INSN(ret, *location, putnil); // key error key
+ PUSH_INSN(ret, *location, putnil); // key error matchee
+ PUSH_INSN1(ret, *location, putobject, Qfalse); // key error?
+ PUSH_INSN(ret, *location, putnil); // error string
+ }
+
+ // Now we're going to compile the value to match against.
+ PUSH_INSN(ret, *location, putnil); // deconstruct cache
+ PM_COMPILE_NOT_POPPED(node->predicate);
+
+ // Next, we'll loop through every in clause and compile its body into
+ // the body_seq anchor and its pattern into the cond_seq anchor. We'll
+ // make sure the pattern knows how to jump correctly into the body if it
+ // finds a match.
+ for (size_t index = 0; index < node->conditions.size; index++) {
+ const pm_node_t *condition = node->conditions.nodes[index];
+ RUBY_ASSERT(PM_NODE_TYPE_P(condition, PM_IN_NODE));
+
+ const pm_in_node_t *in_node = (const pm_in_node_t *) condition;
+ const pm_node_location_t in_location = PM_NODE_START_LOCATION(in_node);
+ const pm_node_location_t pattern_location = PM_NODE_START_LOCATION(in_node->pattern);
+
+ if (branch_id) {
+ PUSH_INSN(body_seq, in_location, putnil);
+ }
+
+ LABEL *body_label = NEW_LABEL(in_location.line);
+ PUSH_LABEL(body_seq, body_label);
+ PUSH_INSN1(body_seq, in_location, adjuststack, INT2FIX(in_single_pattern ? 6 : 2));
+
+ // Establish branch coverage for the in clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location = pm_code_location(scope_node, in_node->statements != NULL ? ((const pm_node_t *) in_node->statements) : ((const pm_node_t *) in_node));
+ add_trace_branch_coverage(iseq, body_seq, &branch_location, branch_location.beg_pos.column, branch_id++, "in", branches);
+ }
+
+ if (in_node->statements != NULL) {
+ PM_COMPILE_INTO_ANCHOR(body_seq, (const pm_node_t *) in_node->statements);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(body_seq, iseq);
+ }
+
+ PUSH_INSNL(body_seq, in_location, jump, end_label);
+ LABEL *next_pattern_label = NEW_LABEL(pattern_location.line);
+
+ PUSH_INSN(cond_seq, pattern_location, dup);
+ pm_compile_pattern(iseq, scope_node, in_node->pattern, cond_seq, body_label, next_pattern_label, in_single_pattern, true, 2);
+ PUSH_LABEL(cond_seq, next_pattern_label);
+ LABEL_UNREMOVABLE(next_pattern_label);
+ }
+
+ if (node->else_clause != NULL) {
+ // If we have an `else` clause, then this becomes our fallback (and
+ // there is no need to compile in code to potentially raise an
+ // error).
+ const pm_else_node_t *else_node = node->else_clause;
+
+ PUSH_LABEL(cond_seq, else_label);
+ PUSH_INSN(cond_seq, *location, pop);
+ PUSH_INSN(cond_seq, *location, pop);
+
+ // Establish branch coverage for the else clause.
+ if (PM_BRANCH_COVERAGE_P(iseq)) {
+ rb_code_location_t branch_location = pm_code_location(scope_node, else_node->statements != NULL ? ((const pm_node_t *) else_node->statements) : ((const pm_node_t *) else_node));
+ add_trace_branch_coverage(iseq, cond_seq, &branch_location, branch_location.beg_pos.column, branch_id, "else", branches);
+ }
+
+ PM_COMPILE_INTO_ANCHOR(cond_seq, (const pm_node_t *) else_node);
+ PUSH_INSNL(cond_seq, *location, jump, end_label);
+ PUSH_INSN(cond_seq, *location, putnil);
+ if (popped) PUSH_INSN(cond_seq, *location, putnil);
+ }
+ else {
+ // Otherwise, if we do not have an `else` clause, we will compile in
+ // the code to handle raising an appropriate error.
+ PUSH_LABEL(cond_seq, else_label);
+
+ // Establish branch coverage for the implicit else clause.
+ add_trace_branch_coverage(iseq, cond_seq, &case_location, case_location.beg_pos.column, branch_id, "else", branches);
+
+ if (in_single_pattern) {
+ pm_compile_pattern_error_handler(iseq, scope_node, (const pm_node_t *) node, cond_seq, end_label, popped);
+ }
+ else {
+ PUSH_INSN1(cond_seq, *location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(cond_seq, *location, putobject, rb_eNoMatchingPatternError);
+ PUSH_INSN1(cond_seq, *location, topn, INT2FIX(2));
+ PUSH_SEND(cond_seq, *location, id_core_raise, INT2FIX(2));
+
+ PUSH_INSN1(cond_seq, *location, adjuststack, INT2FIX(3));
+ if (!popped) PUSH_INSN(cond_seq, *location, putnil);
+ PUSH_INSNL(cond_seq, *location, jump, end_label);
+ PUSH_INSN1(cond_seq, *location, dupn, INT2FIX(1));
+ if (popped) PUSH_INSN(cond_seq, *location, putnil);
+ }
+ }
+
+ // At the end of all of this compilation, we will add the code for the
+ // conditions first, then the various bodies, then mark the end of the
+ // entire sequence with the end label.
+ PUSH_SEQ(ret, cond_seq);
+ PUSH_SEQ(ret, body_seq);
+ PUSH_LABEL(ret, end_label);
+}
+
+static inline void
+pm_compile_forwarding_super_node(rb_iseq_t *iseq, const pm_forwarding_super_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const rb_iseq_t *block = NULL;
+ const rb_iseq_t *previous_block = NULL;
+ LABEL *retry_label = NULL;
+ LABEL *retry_end_l = NULL;
+
+ if (node->block != NULL) {
+ previous_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ ISEQ_COMPILE_DATA(iseq)->current_block = NULL;
+
+ retry_label = NEW_LABEL(location->line);
+ retry_end_l = NEW_LABEL(location->line);
+
+ PUSH_LABEL(ret, retry_label);
+ }
+ else {
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+ }
+
+ PUSH_INSN(ret, *location, putself);
+ int flag = VM_CALL_ZSUPER | VM_CALL_SUPER | VM_CALL_FCALL;
+
+ if (node->block != NULL) {
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) node->block, &next_scope_node, scope_node);
+
+ ISEQ_COMPILE_DATA(iseq)->current_block = block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, location->line);
+ pm_scope_node_destroy(&next_scope_node);
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) block);
+ }
+
+ DECL_ANCHOR(args);
+
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
+ const rb_iseq_t *local_iseq = body->local_iseq;
+ const struct rb_iseq_constant_body *const local_body = ISEQ_BODY(local_iseq);
+
+ int argc = 0;
+ int depth = get_lvar_level(iseq);
+
+ if (ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->param.flags.forwardable) {
+ flag |= VM_CALL_FORWARDING;
+ pm_local_index_t mult_local = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_DOT3, 0);
+ PUSH_GETLOCAL(ret, *location, mult_local.index, mult_local.level);
+
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, 0, 0, flag, NULL, block != NULL);
+ PUSH_INSN2(ret, *location, invokesuperforward, callinfo, block);
+
+ if (popped) PUSH_INSN(ret, *location, pop);
+ if (node->block) {
+ ISEQ_COMPILE_DATA(iseq)->current_block = previous_block;
+ }
+ return;
+ }
+
+ if (local_body->param.flags.has_lead) {
+ /* required arguments */
+ for (int i = 0; i < local_body->param.lead_num; i++) {
+ int idx = local_body->local_table_size - i;
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ }
+ argc += local_body->param.lead_num;
+ }
+
+ if (local_body->param.flags.has_opt) {
+ /* optional arguments */
+ for (int j = 0; j < local_body->param.opt_num; j++) {
+ int idx = local_body->local_table_size - (argc + j);
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ }
+ argc += local_body->param.opt_num;
+ }
+
+ if (local_body->param.flags.has_rest) {
+ /* rest argument */
+ int idx = local_body->local_table_size - local_body->param.rest_start;
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ PUSH_INSN1(args, *location, splatarray, Qfalse);
+
+ argc = local_body->param.rest_start + 1;
+ flag |= VM_CALL_ARGS_SPLAT;
+ }
+
+ if (local_body->param.flags.has_post) {
+ /* post arguments */
+ int post_len = local_body->param.post_num;
+ int post_start = local_body->param.post_start;
+
+ int j = 0;
+ for (; j < post_len; j++) {
+ int idx = local_body->local_table_size - (post_start + j);
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ }
+
+ if (local_body->param.flags.has_rest) {
+ // argc remains unchanged from rest branch
+ PUSH_INSN1(args, *location, newarray, INT2FIX(j));
+ PUSH_INSN(args, *location, concatarray);
+ }
+ else {
+ argc = post_len + post_start;
+ }
+ }
+
+ const struct rb_iseq_param_keyword *const local_keyword = local_body->param.keyword;
+ if (local_body->param.flags.has_kw) {
+ int local_size = local_body->local_table_size;
+ argc++;
+
+ PUSH_INSN1(args, *location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+
+ if (local_body->param.flags.has_kwrest) {
+ int idx = local_body->local_table_size - local_keyword->rest_start;
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ RUBY_ASSERT(local_keyword->num > 0);
+ PUSH_SEND(args, *location, rb_intern("dup"), INT2FIX(0));
+ }
+ else {
+ PUSH_INSN1(args, *location, newhash, INT2FIX(0));
+ }
+ int i = 0;
+ for (; i < local_keyword->num; ++i) {
+ ID id = local_keyword->table[i];
+ int idx = local_size - get_local_var_idx(local_iseq, id);
+
+ {
+ VALUE operand = ID2SYM(id);
+ PUSH_INSN1(args, *location, putobject, operand);
+ }
+
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ }
+
+ PUSH_SEND(args, *location, id_core_hash_merge_ptr, INT2FIX(i * 2 + 1));
+ flag |= VM_CALL_KW_SPLAT| VM_CALL_KW_SPLAT_MUT;
+ }
+ else if (local_body->param.flags.has_kwrest) {
+ int idx = local_body->local_table_size - local_keyword->rest_start;
+ PUSH_GETLOCAL(args, *location, idx, depth);
+ argc++;
+ flag |= VM_CALL_KW_SPLAT;
+ }
+
+ PUSH_SEQ(ret, args);
+
+ {
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, 0, argc, flag, NULL, block != NULL);
+ PUSH_INSN2(ret, *location, invokesuper, callinfo, block);
+ }
+
+ if (node->block != NULL) {
+ pm_compile_retry_end_label(iseq, ret, retry_end_l);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, block, retry_end_l);
+ ISEQ_COMPILE_DATA(iseq)->current_block = previous_block;
+ }
+
+ if (popped) PUSH_INSN(ret, *location, pop);
+}
+
+static inline void
+pm_compile_match_required_node(rb_iseq_t *iseq, const pm_match_required_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ LABEL *matched_label = NEW_LABEL(location->line);
+ LABEL *unmatched_label = NEW_LABEL(location->line);
+ LABEL *done_label = NEW_LABEL(location->line);
+
+ // First, we're going to push a bunch of stuff onto the stack that is
+ // going to serve as our scratch space.
+ PUSH_INSN(ret, *location, putnil); // key error key
+ PUSH_INSN(ret, *location, putnil); // key error matchee
+ PUSH_INSN1(ret, *location, putobject, Qfalse); // key error?
+ PUSH_INSN(ret, *location, putnil); // error string
+ PUSH_INSN(ret, *location, putnil); // deconstruct cache
+
+ // Next we're going to compile the value expression such that it's on
+ // the stack.
+ PM_COMPILE_NOT_POPPED(node->value);
+
+ // Here we'll dup it so that it can be used for comparison, but also be
+ // used for error handling.
+ PUSH_INSN(ret, *location, dup);
+
+ // Next we'll compile the pattern. We indicate to the pm_compile_pattern
+ // function that this is the only pattern that will be matched against
+ // through the in_single_pattern parameter. We also indicate that the
+ // value to compare against is 2 slots from the top of the stack (the
+ // base_index parameter).
+ pm_compile_pattern(iseq, scope_node, node->pattern, ret, matched_label, unmatched_label, true, true, 2);
+
+ // If the pattern did not match the value, then we're going to compile
+ // in our error handler code. This will determine which error to raise
+ // and raise it.
+ PUSH_LABEL(ret, unmatched_label);
+ pm_compile_pattern_error_handler(iseq, scope_node, (const pm_node_t *) node, ret, done_label, popped);
+
+ // If the pattern did match, we'll clean up the values we've pushed onto
+ // the stack and then push nil onto the stack if it's not popped.
+ PUSH_LABEL(ret, matched_label);
+ PUSH_INSN1(ret, *location, adjuststack, INT2FIX(6));
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ PUSH_INSNL(ret, *location, jump, done_label);
+
+ PUSH_LABEL(ret, done_label);
+}
+
+static inline void
+pm_compile_match_write_node(rb_iseq_t *iseq, const pm_match_write_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ LABEL *fail_label = NEW_LABEL(location->line);
+ LABEL *end_label = NEW_LABEL(location->line);
+
+ // First, we'll compile the call so that all of its instructions are
+ // present. Then we'll compile all of the local variable targets.
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->call);
+
+ // Now, check if the match was successful. If it was, then we'll
+ // continue on and assign local variables. Otherwise we'll skip over the
+ // assignment code.
+ {
+ VALUE operand = rb_id2sym(idBACKREF);
+ PUSH_INSN1(ret, *location, getglobal, operand);
+ }
+
+ PUSH_INSN(ret, *location, dup);
+ PUSH_INSNL(ret, *location, branchunless, fail_label);
+
+ // If there's only a single local variable target, we can skip some of
+ // the bookkeeping, so we'll put a special branch here.
+ size_t targets_count = node->targets.size;
+
+ if (targets_count == 1) {
+ const pm_node_t *target = node->targets.nodes[0];
+ RUBY_ASSERT(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_TARGET_NODE));
+
+ const pm_local_variable_target_node_t *local_target = (const pm_local_variable_target_node_t *) target;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, local_target->name, local_target->depth);
+
+ {
+ VALUE operand = rb_id2sym(pm_constant_id_lookup(scope_node, local_target->name));
+ PUSH_INSN1(ret, *location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, *location, idAREF, INT2FIX(1));
+ PUSH_LABEL(ret, fail_label);
+ PUSH_SETLOCAL(ret, *location, index.index, index.level);
+ if (popped) PUSH_INSN(ret, *location, pop);
+ return;
+ }
+
+ DECL_ANCHOR(fail_anchor);
+
+ // Otherwise there is more than one local variable target, so we'll need
+ // to do some bookkeeping.
+ for (size_t targets_index = 0; targets_index < targets_count; targets_index++) {
+ const pm_node_t *target = node->targets.nodes[targets_index];
+ RUBY_ASSERT(PM_NODE_TYPE_P(target, PM_LOCAL_VARIABLE_TARGET_NODE));
+
+ const pm_local_variable_target_node_t *local_target = (const pm_local_variable_target_node_t *) target;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, local_target->name, local_target->depth);
+
+ if (((size_t) targets_index) < (targets_count - 1)) {
+ PUSH_INSN(ret, *location, dup);
+ }
+
+ {
+ VALUE operand = rb_id2sym(pm_constant_id_lookup(scope_node, local_target->name));
+ PUSH_INSN1(ret, *location, putobject, operand);
+ }
+
+ PUSH_SEND(ret, *location, idAREF, INT2FIX(1));
+ PUSH_SETLOCAL(ret, *location, index.index, index.level);
+
+ PUSH_INSN(fail_anchor, *location, putnil);
+ PUSH_SETLOCAL(fail_anchor, *location, index.index, index.level);
+ }
+
+ // Since we matched successfully, now we'll jump to the end.
+ PUSH_INSNL(ret, *location, jump, end_label);
+
+ // In the case that the match failed, we'll loop through each local
+ // variable target and set all of them to `nil`.
+ PUSH_LABEL(ret, fail_label);
+ PUSH_INSN(ret, *location, pop);
+ PUSH_SEQ(ret, fail_anchor);
+
+ // Finally, we can push the end label for either case.
+ PUSH_LABEL(ret, end_label);
+ if (popped) PUSH_INSN(ret, *location, pop);
+}
+
+static inline void
+pm_compile_next_node(rb_iseq_t *iseq, const pm_next_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ if (ISEQ_COMPILE_DATA(iseq)->redo_label != 0 && can_add_ensure_iseq(iseq)) {
+ LABEL *splabel = NEW_LABEL(0);
+ PUSH_LABEL(ret, splabel);
+
+ if (node->arguments) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+ pm_add_ensure_iseq(ret, iseq, 0, scope_node);
+
+ PUSH_ADJUST(ret, *location, ISEQ_COMPILE_DATA(iseq)->redo_label);
+ PUSH_INSNL(ret, *location, jump, ISEQ_COMPILE_DATA(iseq)->start_label);
+
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else if (ISEQ_COMPILE_DATA(iseq)->end_label && can_add_ensure_iseq(iseq)) {
+ LABEL *splabel = NEW_LABEL(0);
+
+ PUSH_LABEL(ret, splabel);
+ PUSH_ADJUST(ret, *location, ISEQ_COMPILE_DATA(iseq)->start_label);
+
+ if (node->arguments != NULL) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ pm_add_ensure_iseq(ret, iseq, 0, scope_node);
+ PUSH_INSNL(ret, *location, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ splabel->unremovable = FALSE;
+
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else {
+ const rb_iseq_t *ip = iseq;
+ unsigned long throw_flag = 0;
+
+ while (ip) {
+ if (!ISEQ_COMPILE_DATA(ip)) {
+ ip = 0;
+ break;
+ }
+
+ throw_flag = VM_THROW_NO_ESCAPE_FLAG;
+ if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
+ /* while loop */
+ break;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
+ break;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
+ COMPILE_ERROR(iseq, location->line, "Invalid next");
+ return;
+ }
+
+ ip = ISEQ_BODY(ip)->parent_iseq;
+ }
+
+ if (ip != 0) {
+ if (node->arguments) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) node->arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ PUSH_INSN1(ret, *location, throw, INT2FIX(throw_flag | TAG_NEXT));
+ if (popped) PUSH_INSN(ret, *location, pop);
+ }
+ else {
+ COMPILE_ERROR(iseq, location->line, "Invalid next");
+ }
+ }
+}
+
+static inline void
+pm_compile_redo_node(rb_iseq_t *iseq, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ if (ISEQ_COMPILE_DATA(iseq)->redo_label && can_add_ensure_iseq(iseq)) {
+ LABEL *splabel = NEW_LABEL(0);
+
+ PUSH_LABEL(ret, splabel);
+ PUSH_ADJUST(ret, *location, ISEQ_COMPILE_DATA(iseq)->redo_label);
+ pm_add_ensure_iseq(ret, iseq, 0, scope_node);
+
+ PUSH_INSNL(ret, *location, jump, ISEQ_COMPILE_DATA(iseq)->redo_label);
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else if (ISEQ_BODY(iseq)->type != ISEQ_TYPE_EVAL && ISEQ_COMPILE_DATA(iseq)->start_label && can_add_ensure_iseq(iseq)) {
+ LABEL *splabel = NEW_LABEL(0);
+
+ PUSH_LABEL(ret, splabel);
+ pm_add_ensure_iseq(ret, iseq, 0, scope_node);
+ PUSH_ADJUST(ret, *location, ISEQ_COMPILE_DATA(iseq)->start_label);
+
+ PUSH_INSNL(ret, *location, jump, ISEQ_COMPILE_DATA(iseq)->start_label);
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else {
+ const rb_iseq_t *ip = iseq;
+
+ while (ip) {
+ if (!ISEQ_COMPILE_DATA(ip)) {
+ ip = 0;
+ break;
+ }
+
+ if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
+ break;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
+ break;
+ }
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
+ COMPILE_ERROR(iseq, location->line, "Invalid redo");
+ return;
+ }
+
+ ip = ISEQ_BODY(ip)->parent_iseq;
+ }
+
+ if (ip != 0) {
+ PUSH_INSN(ret, *location, putnil);
+ PUSH_INSN1(ret, *location, throw, INT2FIX(VM_THROW_NO_ESCAPE_FLAG | TAG_REDO));
+ if (popped) PUSH_INSN(ret, *location, pop);
+ }
+ else {
+ COMPILE_ERROR(iseq, location->line, "Invalid redo");
+ }
+ }
+}
+
+static inline void
+pm_compile_rescue_node(rb_iseq_t *iseq, const pm_rescue_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ iseq_set_exception_local_table(iseq);
+
+ // First, establish the labels that we need to be able to jump to within
+ // this compilation block.
+ LABEL *exception_match_label = NEW_LABEL(location->line);
+ LABEL *rescue_end_label = NEW_LABEL(location->line);
+
+ // Next, compile each of the exceptions that we're going to be
+ // handling. For each one, we'll add instructions to check if the
+ // exception matches the raised one, and if it does then jump to the
+ // exception_match_label label. Otherwise it will fall through to the
+ // subsequent check. If there are no exceptions, we'll only check
+ // StandardError.
+ const pm_node_list_t *exceptions = &node->exceptions;
+
+ if (exceptions->size > 0) {
+ for (size_t index = 0; index < exceptions->size; index++) {
+ PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0);
+ PM_COMPILE(exceptions->nodes[index]);
+ int checkmatch_flags = VM_CHECKMATCH_TYPE_RESCUE;
+ if (PM_NODE_TYPE_P(exceptions->nodes[index], PM_SPLAT_NODE)) {
+ checkmatch_flags |= VM_CHECKMATCH_ARRAY;
+ }
+ PUSH_INSN1(ret, *location, checkmatch, INT2FIX(checkmatch_flags));
+ PUSH_INSNL(ret, *location, branchif, exception_match_label);
+ }
+ }
+ else {
+ PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0);
+ PUSH_INSN1(ret, *location, putobject, rb_eStandardError);
+ PUSH_INSN1(ret, *location, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
+ PUSH_INSNL(ret, *location, branchif, exception_match_label);
+ }
+
+ // If none of the exceptions that we are matching against matched, then
+ // we'll jump straight to the rescue_end_label label.
+ PUSH_INSNL(ret, *location, jump, rescue_end_label);
+
+ // Here we have the exception_match_label, which is where the
+ // control-flow goes in the case that one of the exceptions matched.
+ // Here we will compile the instructions to handle the exception.
+ PUSH_LABEL(ret, exception_match_label);
+ PUSH_TRACE(ret, RUBY_EVENT_RESCUE);
+
+ // If we have a reference to the exception, then we'll compile the write
+ // into the instruction sequence. This can look quite different
+ // depending on the kind of write being performed.
+ if (node->reference) {
+ DECL_ANCHOR(writes);
+ DECL_ANCHOR(cleanup);
+
+ pm_compile_target_node(iseq, node->reference, ret, writes, cleanup, scope_node, NULL);
+ PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0);
+
+ PUSH_SEQ(ret, writes);
+ PUSH_SEQ(ret, cleanup);
+ }
+
+ // If we have statements to execute, we'll compile them here. Otherwise
+ // we'll push nil onto the stack.
+ if (node->statements != NULL) {
+ // We'll temporarily remove the end_label location from the iseq
+ // when compiling the statements so that next/redo statements
+ // inside the body will throw to the correct place instead of
+ // jumping straight to the end of this iseq
+ LABEL *prev_end = ISEQ_COMPILE_DATA(iseq)->end_label;
+ ISEQ_COMPILE_DATA(iseq)->end_label = NULL;
+
+ PM_COMPILE((const pm_node_t *) node->statements);
+
+ // Now restore the end_label
+ ISEQ_COMPILE_DATA(iseq)->end_label = prev_end;
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ PUSH_INSN(ret, *location, leave);
+
+ // Here we'll insert the rescue_end_label label, which is jumped to if
+ // none of the exceptions matched. It will cause the control-flow to
+ // either jump to the next rescue clause or it will fall through to the
+ // subsequent instruction returning the raised error.
+ PUSH_LABEL(ret, rescue_end_label);
+ if (node->subsequent != NULL) {
+ PM_COMPILE((const pm_node_t *) node->subsequent);
+ }
+ else {
+ PUSH_GETLOCAL(ret, *location, 1, 0);
+ }
+}
+
+static inline void
+pm_compile_return_node(rb_iseq_t *iseq, const pm_return_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_arguments_node_t *arguments = node->arguments;
+ enum rb_iseq_type type = ISEQ_BODY(iseq)->type;
+ LABEL *splabel = 0;
+
+ const rb_iseq_t *parent_iseq = iseq;
+ enum rb_iseq_type parent_type = ISEQ_BODY(parent_iseq)->type;
+ while (parent_type == ISEQ_TYPE_RESCUE || parent_type == ISEQ_TYPE_ENSURE) {
+ if (!(parent_iseq = ISEQ_BODY(parent_iseq)->parent_iseq)) break;
+ parent_type = ISEQ_BODY(parent_iseq)->type;
+ }
+
+ switch (parent_type) {
+ case ISEQ_TYPE_TOP:
+ case ISEQ_TYPE_MAIN:
+ if (arguments) {
+ rb_warn("argument of top-level return is ignored");
+ }
+ if (parent_iseq == iseq) {
+ type = ISEQ_TYPE_METHOD;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (type == ISEQ_TYPE_METHOD) {
+ splabel = NEW_LABEL(0);
+ PUSH_LABEL(ret, splabel);
+ PUSH_ADJUST(ret, *location, 0);
+ }
+
+ if (arguments != NULL) {
+ PM_COMPILE_NOT_POPPED((const pm_node_t *) arguments);
+ }
+ else {
+ PUSH_INSN(ret, *location, putnil);
+ }
+
+ if (type == ISEQ_TYPE_METHOD && can_add_ensure_iseq(iseq)) {
+ pm_add_ensure_iseq(ret, iseq, 1, scope_node);
+ PUSH_TRACE(ret, RUBY_EVENT_RETURN);
+ PUSH_INSN(ret, *location, leave);
+ PUSH_ADJUST_RESTORE(ret, splabel);
+ if (!popped) PUSH_INSN(ret, *location, putnil);
+ }
+ else {
+ PUSH_INSN1(ret, *location, throw, INT2FIX(TAG_RETURN));
+ if (popped) PUSH_INSN(ret, *location, pop);
+ }
+}
+
+static inline void
+pm_compile_super_node(rb_iseq_t *iseq, const pm_super_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ DECL_ANCHOR(args);
+
+ LABEL *retry_label = NEW_LABEL(location->line);
+ LABEL *retry_end_l = NEW_LABEL(location->line);
+
+ const rb_iseq_t *previous_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ const rb_iseq_t *current_block;
+ ISEQ_COMPILE_DATA(iseq)->current_block = current_block = NULL;
+
+ PUSH_LABEL(ret, retry_label);
+ PUSH_INSN(ret, *location, putself);
+
+ int flags = 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
+ int argc = pm_setup_args(node->arguments, node->block, &flags, &keywords, iseq, ret, scope_node, location);
+ bool is_forwardable = (node->arguments != NULL) && PM_NODE_FLAG_P(node->arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_FORWARDING);
+ flags |= VM_CALL_SUPER | VM_CALL_FCALL;
+
+ if (node->block && PM_NODE_TYPE_P(node->block, PM_BLOCK_NODE)) {
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(node->block, &next_scope_node, scope_node);
+
+ ISEQ_COMPILE_DATA(iseq)->current_block = current_block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, location->line);
+ pm_scope_node_destroy(&next_scope_node);
+ }
+
+ if (!node->block) {
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+ }
+
+ if ((flags & VM_CALL_ARGS_BLOCKARG) && (flags & VM_CALL_KW_SPLAT) && !(flags & VM_CALL_KW_SPLAT_MUT)) {
+ PUSH_INSN(args, *location, splatkw);
+ }
+
+ PUSH_SEQ(ret, args);
+ if (is_forwardable && ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->param.flags.forwardable) {
+ flags |= VM_CALL_FORWARDING;
+
+ {
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, 0, argc, flags, keywords, current_block != NULL);
+ PUSH_INSN2(ret, *location, invokesuperforward, callinfo, current_block);
+ }
+ }
+ else {
+ {
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, 0, argc, flags, keywords, current_block != NULL);
+ PUSH_INSN2(ret, *location, invokesuper, callinfo, current_block);
+ }
+
+ }
+
+ pm_compile_retry_end_label(iseq, ret, retry_end_l);
+
+ if (popped) PUSH_INSN(ret, *location, pop);
+ ISEQ_COMPILE_DATA(iseq)->current_block = previous_block;
+ PUSH_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, current_block, retry_end_l);
+}
+
+static inline void
+pm_compile_yield_node(rb_iseq_t *iseq, const pm_yield_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ switch (ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->type) {
+ case ISEQ_TYPE_TOP:
+ case ISEQ_TYPE_MAIN:
+ case ISEQ_TYPE_CLASS:
+ COMPILE_ERROR(iseq, location->line, "Invalid yield");
+ return;
+ default: /* valid */;
+ }
+
+ int argc = 0;
+ int flags = 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
+
+ if (node->arguments) {
+ argc = pm_setup_args(node->arguments, NULL, &flags, &keywords, iseq, ret, scope_node, location);
+ }
+
+ const struct rb_callinfo *callinfo = new_callinfo(iseq, 0, argc, flags, keywords, FALSE);
+ PUSH_INSN1(ret, *location, invokeblock, callinfo);
+
+ iseq_set_use_block(ISEQ_BODY(iseq)->local_iseq);
+ if (popped) PUSH_INSN(ret, *location, pop);
+
+ int level = 0;
+ for (const rb_iseq_t *tmp_iseq = iseq; tmp_iseq != ISEQ_BODY(iseq)->local_iseq; level++) {
+ tmp_iseq = ISEQ_BODY(tmp_iseq)->parent_iseq;
+ }
+
+ if (level > 0) access_outer_variables(iseq, level, rb_intern("yield"), true);
+}
+
+/**
+ * Compiles a prism node into instruction sequences.
+ *
+ * iseq - The current instruction sequence object (used for locals)
+ * node - The prism node to compile
+ * ret - The linked list of instructions to append instructions onto
+ * popped - True if compiling something with no side effects, so instructions don't
+ * need to be added
+ * scope_node - Stores parser and local information
+ */
+static void
+pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
+{
+ const pm_node_location_t location = PM_NODE_START_LOCATION(node);
+ int lineno = (int) location.line;
+
+ if (PM_NODE_TYPE_P(node, PM_BEGIN_NODE) && (((const pm_begin_node_t *) node)->statements == NULL) && (((const pm_begin_node_t *) node)->rescue_clause != NULL)) {
+ // If this node is a begin node and it has empty statements and also
+ // has a rescue clause, then the other parser considers it as
+ // starting on the same line as the rescue, as opposed to the
+ // location of the begin keyword. We replicate that behavior here.
+ lineno = (int) PM_NODE_START_LINE_COLUMN(((const pm_begin_node_t *) node)->rescue_clause).line;
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_NEWLINE) && ISEQ_COMPILE_DATA(iseq)->last_line != lineno) {
+ // If this node has the newline flag set and it is on a new line
+ // from the previous nodes that have been compiled for this ISEQ,
+ // then we need to emit a newline event.
+ int event = RUBY_EVENT_LINE;
+
+ ISEQ_COMPILE_DATA(iseq)->last_line = lineno;
+ if (lineno > 0 && ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
+ event |= RUBY_EVENT_COVERAGE_LINE;
+ }
+ PUSH_TRACE(ret, event);
+ }
+
+ switch (PM_NODE_TYPE(node)) {
+ case PM_ALIAS_GLOBAL_VARIABLE_NODE:
+ // alias $foo $bar
+ // ^^^^^^^^^^^^^^^
+ pm_compile_alias_global_variable_node(iseq, (const pm_alias_global_variable_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_ALIAS_METHOD_NODE:
+ // alias foo bar
+ // ^^^^^^^^^^^^^
+ pm_compile_alias_method_node(iseq, (const pm_alias_method_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_AND_NODE:
+ // a and b
+ // ^^^^^^^
+ pm_compile_and_node(iseq, (const pm_and_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_ARGUMENTS_NODE: {
+ // break foo
+ // ^^^
+ //
+ // These are ArgumentsNodes that are not compiled directly by their
+ // parent call nodes, used in the cases of NextNodes, ReturnNodes, and
+ // BreakNodes. They can create an array like ArrayNode.
+ const pm_arguments_node_t *cast = (const pm_arguments_node_t *) node;
+ const pm_node_list_t *elements = &cast->arguments;
+
+ if (elements->size == 1) {
+ // If we are only returning a single element through one of the jump
+ // nodes, then we will only compile that node directly.
+ PM_COMPILE(elements->nodes[0]);
+ }
+ else {
+ pm_compile_array_node(iseq, (const pm_node_t *) cast, elements, &location, ret, popped, scope_node);
+ }
+ return;
+ }
+ case PM_ARRAY_NODE: {
+ // [foo, bar, baz]
+ // ^^^^^^^^^^^^^^^
+ const pm_array_node_t *cast = (const pm_array_node_t *) node;
+ pm_compile_array_node(iseq, (const pm_node_t *) cast, &cast->elements, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_ASSOC_NODE: {
+ // { foo: 1 }
+ // ^^^^^^
+ //
+ // foo(bar: 1)
+ // ^^^^^^
+ const pm_assoc_node_t *cast = (const pm_assoc_node_t *) node;
+
+ PM_COMPILE(cast->key);
+ PM_COMPILE(cast->value);
+
+ return;
+ }
+ case PM_ASSOC_SPLAT_NODE: {
+ // { **foo }
+ // ^^^^^
+ //
+ // def foo(**); bar(**); end
+ // ^^
+ const pm_assoc_splat_node_t *cast = (const pm_assoc_splat_node_t *) node;
+
+ if (cast->value != NULL) {
+ PM_COMPILE(cast->value);
+ }
+ else if (!popped) {
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_POW, 0);
+ PUSH_GETLOCAL(ret, location, index.index, index.level);
+ }
+
+ return;
+ }
+ case PM_BACK_REFERENCE_READ_NODE: {
+ // $+
+ // ^^
+ if (!popped) {
+ const pm_back_reference_read_node_t *cast = (const pm_back_reference_read_node_t *) node;
+ VALUE backref = pm_compile_back_reference_ref(scope_node, cast);
+
+ PUSH_INSN2(ret, location, getspecial, INT2FIX(1), backref);
+ }
+ return;
+ }
+ case PM_BEGIN_NODE: {
+ // begin end
+ // ^^^^^^^^^
+ const pm_begin_node_t *cast = (const pm_begin_node_t *) node;
+
+ if (cast->ensure_clause) {
+ // Compiling the ensure clause will compile the rescue clause (if
+ // there is one), which will compile the begin statements.
+ pm_compile_ensure(iseq, cast, &location, ret, popped, scope_node);
+ }
+ else if (cast->rescue_clause) {
+ // Compiling rescue will compile begin statements (if applicable).
+ pm_compile_rescue(iseq, cast, &location, ret, popped, scope_node);
+ }
+ else {
+ // If there is neither ensure or rescue, the just compile the
+ // statements.
+ if (cast->statements != NULL) {
+ PM_COMPILE((const pm_node_t *) cast->statements);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(ret, iseq);
+ }
+ }
+ return;
+ }
+ case PM_BLOCK_ARGUMENT_NODE: {
+ // foo(&bar)
+ // ^^^^
+ const pm_block_argument_node_t *cast = (const pm_block_argument_node_t *) node;
+
+ if (cast->expression != NULL) {
+ PM_COMPILE(cast->expression);
+ }
+ else {
+ // If there's no expression, this must be block forwarding.
+ pm_local_index_t local_index = pm_lookup_local_index(iseq, scope_node, PM_CONSTANT_AND, 0);
+ PUSH_INSN2(ret, location, getblockparamproxy, INT2FIX(local_index.index + VM_ENV_DATA_SIZE - 1), INT2FIX(local_index.level));
+ }
+ return;
+ }
+ case PM_BREAK_NODE:
+ // break
+ // ^^^^^
+ //
+ // break foo
+ // ^^^^^^^^^
+ pm_compile_break_node(iseq, (const pm_break_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_CALL_NODE:
+ // foo
+ // ^^^
+ //
+ // foo.bar
+ // ^^^^^^^
+ //
+ // foo.bar() {}
+ // ^^^^^^^^^^^^
+ pm_compile_call_node(iseq, (const pm_call_node_t *) node, ret, popped, scope_node);
+ return;
+ case PM_CALL_AND_WRITE_NODE: {
+ // foo.bar &&= baz
+ // ^^^^^^^^^^^^^^^
+ const pm_call_and_write_node_t *cast = (const pm_call_and_write_node_t *) node;
+ pm_compile_call_and_or_write_node(iseq, true, cast->receiver, cast->value, cast->write_name, cast->read_name, PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION), &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CALL_OR_WRITE_NODE: {
+ // foo.bar ||= baz
+ // ^^^^^^^^^^^^^^^
+ const pm_call_or_write_node_t *cast = (const pm_call_or_write_node_t *) node;
+ pm_compile_call_and_or_write_node(iseq, false, cast->receiver, cast->value, cast->write_name, cast->read_name, PM_NODE_FLAG_P(cast, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION), &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CALL_OPERATOR_WRITE_NODE:
+ // foo.bar += baz
+ // ^^^^^^^^^^^^^^^
+ //
+ // Call operator writes occur when you have a call node on the left-hand
+ // side of a write operator that is not `=`. As an example,
+ // `foo.bar *= 1`. This breaks down to caching the receiver on the
+ // stack and then performing three method calls, one to read the value,
+ // one to compute the result, and one to write the result back to the
+ // receiver.
+ pm_compile_call_operator_write_node(iseq, (const pm_call_operator_write_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_CASE_NODE:
+ // case foo; when bar; end
+ // ^^^^^^^^^^^^^^^^^^^^^^^
+ pm_compile_case_node(iseq, (const pm_case_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_CASE_MATCH_NODE:
+ // case foo; in bar; end
+ // ^^^^^^^^^^^^^^^^^^^^^
+ //
+ // If you use the `case` keyword to create a case match node, it will
+ // match against all of the `in` clauses until it finds one that
+ // matches. If it doesn't find one, it can optionally fall back to an
+ // `else` clause. If none is present and a match wasn't found, it will
+ // raise an appropriate error.
+ pm_compile_case_match_node(iseq, (const pm_case_match_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_CLASS_NODE: {
+ // class Foo; end
+ // ^^^^^^^^^^^^^^
+ const pm_class_node_t *cast = (const pm_class_node_t *) node;
+
+ ID class_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE class_name = rb_str_freeze(rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(class_id)));
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &next_scope_node, scope_node);
+
+ const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(&next_scope_node, class_name, ISEQ_TYPE_CLASS, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ // TODO: Once we merge constant path nodes correctly, fix this flag
+ const int flags = VM_DEFINECLASS_TYPE_CLASS |
+ (cast->superclass ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) |
+ pm_compile_class_path(iseq, cast->constant_path, &location, ret, false, scope_node);
+
+ if (cast->superclass) {
+ PM_COMPILE_NOT_POPPED(cast->superclass);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ {
+ VALUE operand = ID2SYM(class_id);
+ PUSH_INSN3(ret, location, defineclass, operand, class_iseq, INT2FIX(flags));
+ }
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)class_iseq);
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_CLASS_VARIABLE_AND_WRITE_NODE: {
+ // @@foo &&= bar
+ // ^^^^^^^^^^^^^
+ const pm_class_variable_and_write_node_t *cast = (const pm_class_variable_and_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN2(ret, location, getclassvariable, name, get_cvar_ic_value(iseq, name_id));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchunless, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN2(ret, location, setclassvariable, name, get_cvar_ic_value(iseq, name_id));
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
+ // @@foo += bar
+ // ^^^^^^^^^^^^
+ const pm_class_variable_operator_write_node_t *cast = (const pm_class_variable_operator_write_node_t *) node;
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN2(ret, location, getclassvariable, name, get_cvar_ic_value(iseq, name_id));
+ PM_COMPILE_NOT_POPPED(cast->value);
+
+ ID method_id = pm_constant_id_lookup(scope_node, cast->binary_operator);
+ int flags = VM_CALL_ARGS_SIMPLE;
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2NUM(1), INT2FIX(flags));
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN2(ret, location, setclassvariable, name, get_cvar_ic_value(iseq, name_id));
+
+ return;
+ }
+ case PM_CLASS_VARIABLE_OR_WRITE_NODE: {
+ // @@foo ||= bar
+ // ^^^^^^^^^^^^^
+ const pm_class_variable_or_write_node_t *cast = (const pm_class_variable_or_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+ LABEL *start_label = NEW_LABEL(location.line);
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_CVAR), name, Qtrue);
+ PUSH_INSNL(ret, location, branchunless, start_label);
+
+ PUSH_INSN2(ret, location, getclassvariable, name, get_cvar_ic_value(iseq, name_id));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchif, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, start_label);
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN2(ret, location, setclassvariable, name, get_cvar_ic_value(iseq, name_id));
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_CLASS_VARIABLE_READ_NODE: {
+ // @@foo
+ // ^^^^^
+ if (!popped) {
+ const pm_class_variable_read_node_t *cast = (const pm_class_variable_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+ PUSH_INSN2(ret, location, getclassvariable, ID2SYM(name), get_cvar_ic_value(iseq, name));
+ }
+ return;
+ }
+ case PM_CLASS_VARIABLE_WRITE_NODE: {
+ // @@foo = 1
+ // ^^^^^^^^^
+ const pm_class_variable_write_node_t *cast = (const pm_class_variable_write_node_t *) node;
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+ PUSH_INSN2(ret, location, setclassvariable, ID2SYM(name), get_cvar_ic_value(iseq, name));
+
+ return;
+ }
+ case PM_CONSTANT_PATH_NODE: {
+ // Foo::Bar
+ // ^^^^^^^^
+ VALUE parts;
+
+ if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache && ((parts = pm_constant_path_parts(node, scope_node)) != Qnil)) {
+ ISEQ_BODY(iseq)->ic_size++;
+ RB_OBJ_SET_SHAREABLE(parts);
+ PUSH_INSN1(ret, location, opt_getconstant_path, parts);
+ }
+ else {
+ DECL_ANCHOR(prefix);
+ DECL_ANCHOR(body);
+
+ pm_compile_constant_path(iseq, node, prefix, body, popped, scope_node);
+ if (LIST_INSN_SIZE_ZERO(prefix)) {
+ PUSH_INSN(ret, location, putnil);
+ }
+ else {
+ PUSH_SEQ(ret, prefix);
+ }
+
+ PUSH_SEQ(ret, body);
+ }
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_CONSTANT_PATH_AND_WRITE_NODE: {
+ // Foo::Bar &&= baz
+ // ^^^^^^^^^^^^^^^^
+ const pm_constant_path_and_write_node_t *cast = (const pm_constant_path_and_write_node_t *) node;
+ pm_compile_constant_path_and_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_PATH_OR_WRITE_NODE: {
+ // Foo::Bar ||= baz
+ // ^^^^^^^^^^^^^^^^
+ const pm_constant_path_or_write_node_t *cast = (const pm_constant_path_or_write_node_t *) node;
+ pm_compile_constant_path_or_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
+ // Foo::Bar += baz
+ // ^^^^^^^^^^^^^^^
+ const pm_constant_path_operator_write_node_t *cast = (const pm_constant_path_operator_write_node_t *) node;
+ pm_compile_constant_path_operator_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_PATH_WRITE_NODE: {
+ // Foo::Bar = 1
+ // ^^^^^^^^^^^^
+ const pm_constant_path_write_node_t *cast = (const pm_constant_path_write_node_t *) node;
+ pm_compile_constant_path_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_READ_NODE: {
+ // Foo
+ // ^^^
+ const pm_constant_read_node_t *cast = (const pm_constant_read_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ pm_compile_constant_read(iseq, name, &cast->base.location, location.node_id, ret, scope_node);
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_CONSTANT_AND_WRITE_NODE: {
+ // Foo &&= bar
+ // ^^^^^^^^^^^
+ const pm_constant_and_write_node_t *cast = (const pm_constant_and_write_node_t *) node;
+ pm_compile_constant_and_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_OR_WRITE_NODE: {
+ // Foo ||= bar
+ // ^^^^^^^^^^^
+ const pm_constant_or_write_node_t *cast = (const pm_constant_or_write_node_t *) node;
+ pm_compile_constant_or_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_OPERATOR_WRITE_NODE: {
+ // Foo += bar
+ // ^^^^^^^^^^
+ const pm_constant_operator_write_node_t *cast = (const pm_constant_operator_write_node_t *) node;
+ pm_compile_constant_operator_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_CONSTANT_WRITE_NODE: {
+ // Foo = 1
+ // ^^^^^^^
+ const pm_constant_write_node_t *cast = (const pm_constant_write_node_t *) node;
+ pm_compile_constant_write_node(iseq, cast, 0, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_DEF_NODE: {
+ // def foo; end
+ // ^^^^^^^^^^^^
+ //
+ // def self.foo; end
+ // ^^^^^^^^^^^^^^^^^
+ const pm_def_node_t *cast = (const pm_def_node_t *) node;
+ ID method_name = pm_constant_id_lookup(scope_node, cast->name);
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &next_scope_node, scope_node);
+
+ rb_iseq_t *method_iseq = NEW_ISEQ(&next_scope_node, rb_id2str(method_name), ISEQ_TYPE_METHOD, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ if (cast->receiver) {
+ PM_COMPILE_NOT_POPPED(cast->receiver);
+ PUSH_INSN2(ret, location, definesmethod, ID2SYM(method_name), method_iseq);
+ }
+ else {
+ PUSH_INSN2(ret, location, definemethod, ID2SYM(method_name), method_iseq);
+ }
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) method_iseq);
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, putobject, ID2SYM(method_name));
+ }
+
+ return;
+ }
+ case PM_DEFINED_NODE: {
+ // defined?(a)
+ // ^^^^^^^^^^^
+ const pm_defined_node_t *cast = (const pm_defined_node_t *) node;
+ pm_compile_defined_expr(iseq, cast->value, &location, ret, popped, scope_node, false);
+ return;
+ }
+ case PM_EMBEDDED_STATEMENTS_NODE: {
+ // "foo #{bar}"
+ // ^^^^^^
+ const pm_embedded_statements_node_t *cast = (const pm_embedded_statements_node_t *) node;
+
+ if (cast->statements != NULL) {
+ PM_COMPILE((const pm_node_t *) (cast->statements));
+ }
+ else {
+ PUSH_SYNTHETIC_PUTNIL(ret, iseq);
+ }
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_EMBEDDED_VARIABLE_NODE: {
+ // "foo #@bar"
+ // ^^^^^
+ const pm_embedded_variable_node_t *cast = (const pm_embedded_variable_node_t *) node;
+ PM_COMPILE(cast->variable);
+ return;
+ }
+ case PM_FALSE_NODE: {
+ // false
+ // ^^^^^
+ if (!popped) {
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ }
+ return;
+ }
+ case PM_ENSURE_NODE: {
+ const pm_ensure_node_t *cast = (const pm_ensure_node_t *) node;
+
+ if (cast->statements != NULL) {
+ PM_COMPILE((const pm_node_t *) cast->statements);
+ }
+
+ return;
+ }
+ case PM_ELSE_NODE: {
+ // if foo then bar else baz end
+ // ^^^^^^^^^^^^
+ const pm_else_node_t *cast = (const pm_else_node_t *) node;
+
+ if (cast->statements != NULL) {
+ PM_COMPILE((const pm_node_t *) cast->statements);
+ }
+ else if (!popped) {
+ PUSH_SYNTHETIC_PUTNIL(ret, iseq);
+ }
+
+ return;
+ }
+ case PM_FLIP_FLOP_NODE: {
+ // if foo .. bar; end
+ // ^^^^^^^^^^
+ const pm_flip_flop_node_t *cast = (const pm_flip_flop_node_t *) node;
+
+ LABEL *final_label = NEW_LABEL(location.line);
+ LABEL *then_label = NEW_LABEL(location.line);
+ LABEL *else_label = NEW_LABEL(location.line);
+
+ pm_compile_flip_flop(cast, else_label, then_label, iseq, location.line, ret, popped, scope_node);
+
+ PUSH_LABEL(ret, then_label);
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSNL(ret, location, jump, final_label);
+ PUSH_LABEL(ret, else_label);
+ PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_LABEL(ret, final_label);
+
+ return;
+ }
+ case PM_FLOAT_NODE: {
+ // 1.0
+ // ^^^
+ if (!popped) {
+ VALUE operand = parse_float((const pm_float_node_t *) node);
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+ return;
+ }
+ case PM_FOR_NODE: {
+ // for foo in bar do end
+ // ^^^^^^^^^^^^^^^^^^^^^
+ const pm_for_node_t *cast = (const pm_for_node_t *) node;
+
+ LABEL *retry_label = NEW_LABEL(location.line);
+ LABEL *retry_end_l = NEW_LABEL(location.line);
+
+ // First, compile the collection that we're going to be iterating over.
+ PUSH_LABEL(ret, retry_label);
+ PM_COMPILE_NOT_POPPED(cast->collection);
+
+ // Next, create the new scope that is going to contain the block that
+ // will be passed to the each method.
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &next_scope_node, scope_node);
+
+ const rb_iseq_t *child_iseq = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ const rb_iseq_t *prev_block = ISEQ_COMPILE_DATA(iseq)->current_block;
+ ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq;
+
+ // Now, create the method call to each that will be used to iterate over
+ // the collection, and pass the newly created iseq as the block.
+ PUSH_SEND_WITH_BLOCK(ret, location, idEach, INT2FIX(0), child_iseq);
+ pm_compile_retry_end_label(iseq, ret, retry_end_l);
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ ISEQ_COMPILE_DATA(iseq)->current_block = prev_block;
+ PUSH_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, child_iseq, retry_end_l);
+ return;
+ }
+ case PM_FORWARDING_ARGUMENTS_NODE:
+ rb_bug("Cannot compile a ForwardingArgumentsNode directly\n");
+ return;
+ case PM_FORWARDING_SUPER_NODE:
+ // super
+ // ^^^^^
+ //
+ // super {}
+ // ^^^^^^^^
+ pm_compile_forwarding_super_node(iseq, (const pm_forwarding_super_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_GLOBAL_VARIABLE_AND_WRITE_NODE: {
+ // $foo &&= bar
+ // ^^^^^^^^^^^^
+ const pm_global_variable_and_write_node_t *cast = (const pm_global_variable_and_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+ PUSH_INSN1(ret, location, getglobal, name);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchunless, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN1(ret, location, setglobal, name);
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
+ // $foo += bar
+ // ^^^^^^^^^^^
+ const pm_global_variable_operator_write_node_t *cast = (const pm_global_variable_operator_write_node_t *) node;
+
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+ PUSH_INSN1(ret, location, getglobal, name);
+ PM_COMPILE_NOT_POPPED(cast->value);
+
+ ID method_id = pm_constant_id_lookup(scope_node, cast->binary_operator);
+ int flags = VM_CALL_ARGS_SIMPLE;
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2NUM(1), INT2FIX(flags));
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN1(ret, location, setglobal, name);
+
+ return;
+ }
+ case PM_GLOBAL_VARIABLE_OR_WRITE_NODE: {
+ // $foo ||= bar
+ // ^^^^^^^^^^^^
+ const pm_global_variable_or_write_node_t *cast = (const pm_global_variable_or_write_node_t *) node;
+ LABEL *set_label = NEW_LABEL(location.line);
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ PUSH_INSN(ret, location, putnil);
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ PUSH_INSN3(ret, location, defined, INT2FIX(DEFINED_GVAR), name, Qtrue);
+ PUSH_INSNL(ret, location, branchunless, set_label);
+
+ PUSH_INSN1(ret, location, getglobal, name);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchif, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, set_label);
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN1(ret, location, setglobal, name);
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_GLOBAL_VARIABLE_READ_NODE: {
+ // $foo
+ // ^^^^
+ const pm_global_variable_read_node_t *cast = (const pm_global_variable_read_node_t *) node;
+ VALUE name = ID2SYM(pm_constant_id_lookup(scope_node, cast->name));
+
+ PUSH_INSN1(ret, location, getglobal, name);
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_GLOBAL_VARIABLE_WRITE_NODE: {
+ // $foo = 1
+ // ^^^^^^^^
+ const pm_global_variable_write_node_t *cast = (const pm_global_variable_write_node_t *) node;
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+ PUSH_INSN1(ret, location, setglobal, ID2SYM(name));
+
+ return;
+ }
+ case PM_HASH_NODE: {
+ // {}
+ // ^^
+ //
+ // If every node in the hash is static, then we can compile the entire
+ // hash now instead of later.
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ // We're only going to compile this node if it's not popped. If it
+ // is popped, then we know we don't need to do anything since it's
+ // statically known.
+ if (!popped) {
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+
+ if (cast->elements.size == 0) {
+ PUSH_INSN1(ret, location, newhash, INT2FIX(0));
+ }
+ else {
+ VALUE value = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, duphash, value);
+ RB_OBJ_WRITTEN(iseq, Qundef, value);
+ }
+ }
+ }
+ else {
+ // Here since we know there are possible side-effects inside the
+ // hash contents, we're going to build it entirely at runtime. We'll
+ // do this by pushing all of the key-value pairs onto the stack and
+ // then combining them with newhash.
+ //
+ // If this hash is popped, then this serves only to ensure we enact
+ // all side-effects (like method calls) that are contained within
+ // the hash contents.
+ const pm_hash_node_t *cast = (const pm_hash_node_t *) node;
+ const pm_node_list_t *elements = &cast->elements;
+
+ if (popped) {
+ // If this hash is popped, then we can iterate through each
+ // element and compile it. The result of each compilation will
+ // only include the side effects of the element itself.
+ for (size_t index = 0; index < elements->size; index++) {
+ PM_COMPILE_POPPED(elements->nodes[index]);
+ }
+ }
+ else {
+ pm_compile_hash_elements(iseq, node, elements, 0, Qundef, false, ret, scope_node);
+ }
+ }
+
+ return;
+ }
+ case PM_IF_NODE: {
+ // if foo then bar end
+ // ^^^^^^^^^^^^^^^^^^^
+ //
+ // bar if foo
+ // ^^^^^^^^^^
+ //
+ // foo ? bar : baz
+ // ^^^^^^^^^^^^^^^
+ const pm_if_node_t *cast = (const pm_if_node_t *) node;
+ pm_compile_conditional(iseq, &location, PM_IF_NODE, (const pm_node_t *) cast, cast->statements, cast->subsequent, cast->predicate, ret, popped, scope_node);
+ return;
+ }
+ case PM_IMAGINARY_NODE: {
+ // 1i
+ // ^^
+ if (!popped) {
+ VALUE operand = parse_imaginary((const pm_imaginary_node_t *) node);
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+ return;
+ }
+ case PM_IMPLICIT_NODE: {
+ // Implicit nodes mark places in the syntax tree where explicit syntax
+ // was omitted, but implied. For example,
+ //
+ // { foo: }
+ //
+ // In this case a method call/local variable read is implied by virtue
+ // of the missing value. To compile these nodes, we simply compile the
+ // value that is implied, which is helpfully supplied by the parser.
+ const pm_implicit_node_t *cast = (const pm_implicit_node_t *) node;
+ PM_COMPILE(cast->value);
+ return;
+ }
+ case PM_IN_NODE: {
+ // In nodes are handled by the case match node directly, so we should
+ // never end up hitting them through this path.
+ rb_bug("Should not ever enter an in node directly");
+ return;
+ }
+ case PM_INDEX_OPERATOR_WRITE_NODE: {
+ // foo[bar] += baz
+ // ^^^^^^^^^^^^^^^
+ const pm_index_operator_write_node_t *cast = (const pm_index_operator_write_node_t *) node;
+ pm_compile_index_operator_write_node(iseq, cast, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_INDEX_AND_WRITE_NODE: {
+ // foo[bar] &&= baz
+ // ^^^^^^^^^^^^^^^^
+ const pm_index_and_write_node_t *cast = (const pm_index_and_write_node_t *) node;
+ pm_compile_index_control_flow_write_node(iseq, node, cast->receiver, cast->arguments, cast->block, cast->value, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_INDEX_OR_WRITE_NODE: {
+ // foo[bar] ||= baz
+ // ^^^^^^^^^^^^^^^^
+ const pm_index_or_write_node_t *cast = (const pm_index_or_write_node_t *) node;
+ pm_compile_index_control_flow_write_node(iseq, node, cast->receiver, cast->arguments, cast->block, cast->value, &location, ret, popped, scope_node);
+ return;
+ }
+ case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
+ // @foo &&= bar
+ // ^^^^^^^^^^^^
+ const pm_instance_variable_and_write_node_t *cast = (const pm_instance_variable_and_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN2(ret, location, getinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchunless, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN2(ret, location, setinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
+ // @foo += bar
+ // ^^^^^^^^^^^
+ const pm_instance_variable_operator_write_node_t *cast = (const pm_instance_variable_operator_write_node_t *) node;
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN2(ret, location, getinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+ PM_COMPILE_NOT_POPPED(cast->value);
+
+ ID method_id = pm_constant_id_lookup(scope_node, cast->binary_operator);
+ int flags = VM_CALL_ARGS_SIMPLE;
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2NUM(1), INT2FIX(flags));
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSN2(ret, location, setinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+
+ return;
+ }
+ case PM_INSTANCE_VARIABLE_OR_WRITE_NODE: {
+ // @foo ||= bar
+ // ^^^^^^^^^^^^
+ const pm_instance_variable_or_write_node_t *cast = (const pm_instance_variable_or_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ ID name_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE name = ID2SYM(name_id);
+
+ PUSH_INSN2(ret, location, getinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchif, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSN2(ret, location, setinstancevariable, name, get_ivar_ic_value(iseq, name_id));
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_INSTANCE_VARIABLE_READ_NODE: {
+ // @foo
+ // ^^^^
+ if (!popped) {
+ const pm_instance_variable_read_node_t *cast = (const pm_instance_variable_read_node_t *) node;
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+ PUSH_INSN2(ret, location, getinstancevariable, ID2SYM(name), get_ivar_ic_value(iseq, name));
+ }
+ return;
+ }
+ case PM_INSTANCE_VARIABLE_WRITE_NODE: {
+ // @foo = 1
+ // ^^^^^^^^
+ const pm_instance_variable_write_node_t *cast = (const pm_instance_variable_write_node_t *) node;
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ ID name = pm_constant_id_lookup(scope_node, cast->name);
+ PUSH_INSN2(ret, location, setinstancevariable, ID2SYM(name), get_ivar_ic_value(iseq, name));
+
+ return;
+ }
+ case PM_INTEGER_NODE: {
+ // 1
+ // ^
+ if (!popped) {
+ VALUE operand = parse_integer((const pm_integer_node_t *) node);
+ PUSH_INSN1(ret, location, putobject, operand);
+ }
+ return;
+ }
+ case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: {
+ // if /foo #{bar}/ then end
+ // ^^^^^^^^^^^^
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ if (!popped) {
+ VALUE regexp = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, regexp);
+ }
+ }
+ else {
+ pm_compile_regexp_dynamic(iseq, node, &((const pm_interpolated_match_last_line_node_t *) node)->parts, &location, ret, popped, scope_node);
+ }
+
+ PUSH_INSN1(ret, location, getglobal, rb_id2sym(idLASTLINE));
+ PUSH_SEND(ret, location, idEqTilde, INT2NUM(1));
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
+ // /foo #{bar}/
+ // ^^^^^^^^^^^^
+ if (PM_NODE_FLAG_P(node, PM_REGULAR_EXPRESSION_FLAGS_ONCE)) {
+ const rb_iseq_t *prevblock = ISEQ_COMPILE_DATA(iseq)->current_block;
+ const rb_iseq_t *block_iseq = NULL;
+ int ise_index = ISEQ_BODY(iseq)->ise_size++;
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(node, &next_scope_node, scope_node);
+
+ block_iseq = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ ISEQ_COMPILE_DATA(iseq)->current_block = block_iseq;
+ PUSH_INSN2(ret, location, once, block_iseq, INT2FIX(ise_index));
+ ISEQ_COMPILE_DATA(iseq)->current_block = prevblock;
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ if (!popped) {
+ VALUE regexp = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, regexp);
+ }
+ }
+ else {
+ pm_compile_regexp_dynamic(iseq, node, &((const pm_interpolated_regular_expression_node_t *) node)->parts, &location, ret, popped, scope_node);
+ if (popped) PUSH_INSN(ret, location, pop);
+ }
+
+ return;
+ }
+ case PM_INTERPOLATED_STRING_NODE: {
+ // "foo #{bar}"
+ // ^^^^^^^^^^^^
+ if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
+ if (!popped) {
+ VALUE string = pm_static_literal_value(iseq, node, scope_node);
+
+ if (PM_NODE_FLAG_P(node, PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN)) {
+ PUSH_INSN1(ret, location, putobject, string);
+ }
+ else if (PM_NODE_FLAG_P(node, PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE)) {
+ PUSH_INSN1(ret, location, dupstring, string);
+ }
+ else {
+ PUSH_INSN1(ret, location, dupchilledstring, string);
+ }
+ }
+ }
+ else {
+ const pm_interpolated_string_node_t *cast = (const pm_interpolated_string_node_t *) node;
+ int length = pm_interpolated_node_compile(iseq, &cast->parts, &location, ret, popped, scope_node, NULL, NULL, PM_NODE_FLAG_P(cast, PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE), PM_NODE_FLAG_P(cast, PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN));
+ if (length > 1) PUSH_INSN1(ret, location, concatstrings, INT2FIX(length));
+ if (popped) PUSH_INSN(ret, location, pop);
+ }
+
+ return;
+ }
+ case PM_INTERPOLATED_SYMBOL_NODE: {
+ // :"foo #{bar}"
+ // ^^^^^^^^^^^^^
+ const pm_interpolated_symbol_node_t *cast = (const pm_interpolated_symbol_node_t *) node;
+ int length = pm_interpolated_node_compile(iseq, &cast->parts, &location, ret, popped, scope_node, NULL, NULL, false, false);
+
+ if (length > 1) {
+ PUSH_INSN1(ret, location, concatstrings, INT2FIX(length));
+ }
+
+ if (!popped) {
+ PUSH_INSN(ret, location, intern);
+ }
+ else {
+ PUSH_INSN(ret, location, pop);
+ }
+
+ return;
+ }
+ case PM_INTERPOLATED_X_STRING_NODE: {
+ // `foo #{bar}`
+ // ^^^^^^^^^^^^
+ const pm_interpolated_x_string_node_t *cast = (const pm_interpolated_x_string_node_t *) node;
+
+ PUSH_INSN(ret, location, putself);
+
+ int length = pm_interpolated_node_compile(iseq, &cast->parts, &location, ret, false, scope_node, NULL, NULL, false, false);
+ if (length > 1) PUSH_INSN1(ret, location, concatstrings, INT2FIX(length));
+
+ PUSH_SEND_WITH_FLAG(ret, location, idBackquote, INT2NUM(1), INT2FIX(VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE));
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
+ // -> { it }
+ // ^^
+ if (!popped) {
+ pm_scope_node_t *current_scope_node = scope_node;
+ int level = 0;
+
+ while (current_scope_node) {
+ if (current_scope_node->parameters && PM_NODE_TYPE_P(current_scope_node->parameters, PM_IT_PARAMETERS_NODE)) {
+ PUSH_GETLOCAL(ret, location, current_scope_node->local_table_for_iseq_size, level);
+ return;
+ }
+
+ current_scope_node = current_scope_node->previous;
+ level++;
+ }
+ rb_bug("Local `it` does not exist");
+ }
+
+ return;
+ }
+ case PM_KEYWORD_HASH_NODE: {
+ // foo(bar: baz)
+ // ^^^^^^^^
+ const pm_keyword_hash_node_t *cast = (const pm_keyword_hash_node_t *) node;
+ const pm_node_list_t *elements = &cast->elements;
+
+ const pm_node_t *element;
+ PM_NODE_LIST_FOREACH(elements, index, element) {
+ PM_COMPILE(element);
+ }
+
+ if (!popped) PUSH_INSN1(ret, location, newhash, INT2FIX(elements->size * 2));
+ return;
+ }
+ case PM_LAMBDA_NODE: {
+ // -> {}
+ // ^^^^^
+ const pm_lambda_node_t *cast = (const pm_lambda_node_t *) node;
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(node, &next_scope_node, scope_node);
+
+ int opening_lineno = pm_location_line_number_cached(&cast->opening_loc, scope_node);
+ const rb_iseq_t *block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, opening_lineno);
+ pm_scope_node_destroy(&next_scope_node);
+
+ VALUE argc = INT2FIX(0);
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_CALL_WITH_BLOCK(ret, location, idLambda, argc, block);
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) block);
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_LOCAL_VARIABLE_AND_WRITE_NODE: {
+ // foo &&= bar
+ // ^^^^^^^^^^^
+ const pm_local_variable_and_write_node_t *cast = (const pm_local_variable_and_write_node_t *) node;
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ pm_local_index_t local_index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+ PUSH_GETLOCAL(ret, location, local_index.index, local_index.level);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchunless, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_SETLOCAL(ret, location, local_index.index, local_index.level);
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
+ // foo += bar
+ // ^^^^^^^^^^
+ const pm_local_variable_operator_write_node_t *cast = (const pm_local_variable_operator_write_node_t *) node;
+
+ pm_local_index_t local_index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+ PUSH_GETLOCAL(ret, location, local_index.index, local_index.level);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+
+ ID method_id = pm_constant_id_lookup(scope_node, cast->binary_operator);
+ PUSH_SEND_WITH_FLAG(ret, location, method_id, INT2NUM(1), INT2FIX(VM_CALL_ARGS_SIMPLE));
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_SETLOCAL(ret, location, local_index.index, local_index.level);
+
+ return;
+ }
+ case PM_LOCAL_VARIABLE_OR_WRITE_NODE: {
+ // foo ||= bar
+ // ^^^^^^^^^^^
+ const pm_local_variable_or_write_node_t *cast = (const pm_local_variable_or_write_node_t *) node;
+
+ LABEL *set_label = NEW_LABEL(location.line);
+ LABEL *end_label = NEW_LABEL(location.line);
+
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSNL(ret, location, branchunless, set_label);
+
+ pm_local_index_t local_index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+ PUSH_GETLOCAL(ret, location, local_index.index, local_index.level);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_INSNL(ret, location, branchif, end_label);
+ if (!popped) PUSH_INSN(ret, location, pop);
+
+ PUSH_LABEL(ret, set_label);
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_SETLOCAL(ret, location, local_index.index, local_index.level);
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_LOCAL_VARIABLE_READ_NODE: {
+ // foo
+ // ^^^
+ if (!popped) {
+ const pm_local_variable_read_node_t *cast = (const pm_local_variable_read_node_t *) node;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+ PUSH_GETLOCAL(ret, location, index.index, index.level);
+ }
+
+ return;
+ }
+ case PM_LOCAL_VARIABLE_WRITE_NODE: {
+ // foo = 1
+ // ^^^^^^^
+ const pm_local_variable_write_node_t *cast = (const pm_local_variable_write_node_t *) node;
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, cast->depth);
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+ return;
+ }
+ case PM_MATCH_LAST_LINE_NODE: {
+ // if /foo/ then end
+ // ^^^^^
+ VALUE regexp = pm_static_literal_value(iseq, node, scope_node);
+
+ PUSH_INSN1(ret, location, putobject, regexp);
+ PUSH_INSN2(ret, location, getspecial, INT2FIX(0), INT2FIX(0));
+ PUSH_SEND(ret, location, idEqTilde, INT2NUM(1));
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_MATCH_PREDICATE_NODE: {
+ // foo in bar
+ // ^^^^^^^^^^
+ const pm_match_predicate_node_t *cast = (const pm_match_predicate_node_t *) node;
+
+ // First, allocate some stack space for the cached return value of any
+ // calls to #deconstruct.
+ PUSH_INSN(ret, location, putnil);
+
+ // Next, compile the expression that we're going to match against.
+ PM_COMPILE_NOT_POPPED(cast->value);
+ PUSH_INSN(ret, location, dup);
+
+ // Now compile the pattern that is going to be used to match against the
+ // expression.
+ LABEL *matched_label = NEW_LABEL(location.line);
+ LABEL *unmatched_label = NEW_LABEL(location.line);
+ LABEL *done_label = NEW_LABEL(location.line);
+ pm_compile_pattern(iseq, scope_node, cast->pattern, ret, matched_label, unmatched_label, false, true, 2);
+
+ // If the pattern did not match, then compile the necessary instructions
+ // to handle pushing false onto the stack, then jump to the end.
+ PUSH_LABEL(ret, unmatched_label);
+ PUSH_INSN(ret, location, pop);
+ PUSH_INSN(ret, location, pop);
+
+ if (!popped) PUSH_INSN1(ret, location, putobject, Qfalse);
+ PUSH_INSNL(ret, location, jump, done_label);
+ PUSH_INSN(ret, location, putnil);
+
+ // If the pattern did match, then compile the necessary instructions to
+ // handle pushing true onto the stack, then jump to the end.
+ PUSH_LABEL(ret, matched_label);
+ PUSH_INSN1(ret, location, adjuststack, INT2FIX(2));
+ if (!popped) PUSH_INSN1(ret, location, putobject, Qtrue);
+ PUSH_INSNL(ret, location, jump, done_label);
+
+ PUSH_LABEL(ret, done_label);
+ return;
+ }
+ case PM_MATCH_REQUIRED_NODE:
+ // foo => bar
+ // ^^^^^^^^^^
+ //
+ // A match required node represents pattern matching against a single
+ // pattern using the => operator. For example,
+ //
+ // foo => bar
+ //
+ // This is somewhat analogous to compiling a case match statement with a
+ // single pattern. In both cases, if the pattern fails it should
+ // immediately raise an error.
+ pm_compile_match_required_node(iseq, (const pm_match_required_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_MATCH_WRITE_NODE:
+ // /(?<foo>foo)/ =~ bar
+ // ^^^^^^^^^^^^^^^^^^^^
+ //
+ // Match write nodes are specialized call nodes that have a regular
+ // expression with valid named capture groups on the left, the =~
+ // operator, and some value on the right. The nodes themselves simply
+ // wrap the call with the local variable targets that will be written
+ // when the call is executed.
+ pm_compile_match_write_node(iseq, (const pm_match_write_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_ERROR_RECOVERY_NODE:
+ rb_bug("A pm_error_recovery_node_t should not exist in prism's AST.");
+ return;
+ case PM_MODULE_NODE: {
+ // module Foo; end
+ // ^^^^^^^^^^^^^^^
+ const pm_module_node_t *cast = (const pm_module_node_t *) node;
+
+ ID module_id = pm_constant_id_lookup(scope_node, cast->name);
+ VALUE module_name = rb_str_freeze(rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(module_id)));
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &next_scope_node, scope_node);
+
+ const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(&next_scope_node, module_name, ISEQ_TYPE_CLASS, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ const int flags = VM_DEFINECLASS_TYPE_MODULE | pm_compile_class_path(iseq, cast->constant_path, &location, ret, false, scope_node);
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN3(ret, location, defineclass, ID2SYM(module_id), module_iseq, INT2FIX(flags));
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) module_iseq);
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_REQUIRED_PARAMETER_NODE: {
+ // def foo(bar); end
+ // ^^^
+ const pm_required_parameter_node_t *cast = (const pm_required_parameter_node_t *) node;
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, 0);
+
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+ return;
+ }
+ case PM_MULTI_WRITE_NODE: {
+ // foo, bar = baz
+ // ^^^^^^^^^^^^^^
+ //
+ // A multi write node represents writing to multiple values using an =
+ // operator. Importantly these nodes are only parsed when the left-hand
+ // side of the operator has multiple targets. The right-hand side of the
+ // operator having multiple targets represents an implicit array
+ // instead.
+ const pm_multi_write_node_t *cast = (const pm_multi_write_node_t *) node;
+
+ DECL_ANCHOR(writes);
+ DECL_ANCHOR(cleanup);
+
+ pm_multi_target_state_t state = { 0 };
+ state.position = popped ? 0 : 1;
+ pm_compile_multi_target_node(iseq, node, ret, writes, cleanup, scope_node, &state);
+
+ PM_COMPILE_NOT_POPPED(cast->value);
+ if (!popped) PUSH_INSN(ret, location, dup);
+
+ PUSH_SEQ(ret, writes);
+ if (!popped && state.stack_size >= 1) {
+ // Make sure the value on the right-hand side of the = operator is
+ // being returned before we pop the parent expressions.
+ PUSH_INSN1(ret, location, setn, INT2FIX(state.stack_size));
+ }
+
+ // Now, we need to go back and modify the topn instructions in order to
+ // ensure they can correctly retrieve the parent expressions.
+ pm_multi_target_state_update(&state);
+
+ PUSH_SEQ(ret, cleanup);
+ return;
+ }
+ case PM_NEXT_NODE:
+ // next
+ // ^^^^
+ //
+ // next foo
+ // ^^^^^^^^
+ pm_compile_next_node(iseq, (const pm_next_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_NIL_NODE: {
+ // nil
+ // ^^^
+ if (!popped) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ return;
+ }
+ case PM_NO_BLOCK_PARAMETER_NODE: {
+ // def foo(&nil); end
+ // ^^^^
+ ISEQ_BODY(iseq)->param.flags.accepts_no_block = TRUE;
+ return;
+ }
+ case PM_NO_KEYWORDS_PARAMETER_NODE: {
+ // def foo(**nil); end
+ // ^^^^^
+ ISEQ_BODY(iseq)->param.flags.accepts_no_kwarg = TRUE;
+ return;
+ }
+ case PM_NUMBERED_REFERENCE_READ_NODE: {
+ // $1
+ // ^^
+ if (!popped) {
+ const pm_numbered_reference_read_node_t *cast = (const pm_numbered_reference_read_node_t *) node;
+
+ if (cast->number != 0) {
+ VALUE ref = pm_compile_numbered_reference_ref(cast);
+ PUSH_INSN2(ret, location, getspecial, INT2FIX(1), ref);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+ }
+
+ return;
+ }
+ case PM_OR_NODE: {
+ // a or b
+ // ^^^^^^
+ const pm_or_node_t *cast = (const pm_or_node_t *) node;
+
+ LABEL *end_label = NEW_LABEL(location.line);
+ PM_COMPILE_NOT_POPPED(cast->left);
+
+ if (!popped) PUSH_INSN(ret, location, dup);
+ PUSH_INSNL(ret, location, branchif, end_label);
+
+ if (!popped) PUSH_INSN(ret, location, pop);
+ PM_COMPILE(cast->right);
+ PUSH_LABEL(ret, end_label);
+
+ return;
+ }
+ case PM_OPTIONAL_PARAMETER_NODE: {
+ // def foo(bar = 1); end
+ // ^^^^^^^
+ const pm_optional_parameter_node_t *cast = (const pm_optional_parameter_node_t *) node;
+ PM_COMPILE_NOT_POPPED(cast->value);
+
+ pm_local_index_t index = pm_lookup_local_index(iseq, scope_node, cast->name, 0);
+ PUSH_SETLOCAL(ret, location, index.index, index.level);
+
+ return;
+ }
+ case PM_PARENTHESES_NODE: {
+ // ()
+ // ^^
+ //
+ // (1)
+ // ^^^
+ const pm_parentheses_node_t *cast = (const pm_parentheses_node_t *) node;
+
+ if (cast->body != NULL) {
+ PM_COMPILE(cast->body);
+ }
+ else if (!popped) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ return;
+ }
+ case PM_PRE_EXECUTION_NODE: {
+ // BEGIN {}
+ // ^^^^^^^^
+ const pm_pre_execution_node_t *cast = (const pm_pre_execution_node_t *) node;
+
+ LINK_ANCHOR *outer_pre = scope_node->pre_execution_anchor;
+ RUBY_ASSERT(outer_pre != NULL);
+
+ // BEGIN{} nodes can be nested, so here we're going to do the same thing
+ // that we did for the top-level compilation where we create two
+ // anchors and then join them in the correct order into the resulting
+ // anchor.
+ DECL_ANCHOR(inner_pre);
+ scope_node->pre_execution_anchor = inner_pre;
+
+ DECL_ANCHOR(inner_body);
+
+ if (cast->statements != NULL) {
+ const pm_node_list_t *body = &cast->statements->body;
+
+ for (size_t index = 0; index < body->size; index++) {
+ pm_compile_node(iseq, body->nodes[index], inner_body, true, scope_node);
+ }
+ }
+
+ if (!popped) {
+ PUSH_INSN(inner_body, location, putnil);
+ }
+
+ // Now that everything has been compiled, join both anchors together
+ // into the correct outer pre execution anchor, and reset the value so
+ // that subsequent BEGIN{} nodes can be compiled correctly.
+ PUSH_SEQ(outer_pre, inner_pre);
+ PUSH_SEQ(outer_pre, inner_body);
+ scope_node->pre_execution_anchor = outer_pre;
+
+ return;
+ }
+ case PM_POST_EXECUTION_NODE: {
+ // END {}
+ // ^^^^^^
+ const rb_iseq_t *child_iseq;
+ const rb_iseq_t *prevblock = ISEQ_COMPILE_DATA(iseq)->current_block;
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init(node, &next_scope_node, scope_node);
+ child_iseq = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, lineno);
+ pm_scope_node_destroy(&next_scope_node);
+
+ ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq;
+
+ int is_index = ISEQ_BODY(iseq)->ise_size++;
+ PUSH_INSN2(ret, location, once, child_iseq, INT2FIX(is_index));
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) child_iseq);
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ ISEQ_COMPILE_DATA(iseq)->current_block = prevblock;
+
+ return;
+ }
+ case PM_RANGE_NODE: {
+ // 0..5
+ // ^^^^
+ const pm_range_node_t *cast = (const pm_range_node_t *) node;
+ bool exclude_end = PM_NODE_FLAG_P(cast, PM_RANGE_FLAGS_EXCLUDE_END);
+
+ if (pm_optimizable_range_item_p(cast->left) && pm_optimizable_range_item_p(cast->right)) {
+ if (!popped) {
+ const pm_node_t *left = cast->left;
+ const pm_node_t *right = cast->right;
+
+ VALUE val = rb_range_new(
+ (left && PM_NODE_TYPE_P(left, PM_INTEGER_NODE)) ? parse_integer((const pm_integer_node_t *) left) : Qnil,
+ (right && PM_NODE_TYPE_P(right, PM_INTEGER_NODE)) ? parse_integer((const pm_integer_node_t *) right) : Qnil,
+ exclude_end
+ );
+
+ RB_OBJ_SET_SHAREABLE(val);
+ PUSH_INSN1(ret, location, putobject, val);
+ }
+ }
+ else {
+ if (cast->left != NULL) {
+ PM_COMPILE(cast->left);
+ }
+ else if (!popped) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ if (cast->right != NULL) {
+ PM_COMPILE(cast->right);
+ }
+ else if (!popped) {
+ PUSH_INSN(ret, location, putnil);
+ }
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, newrange, INT2FIX(exclude_end ? 1 : 0));
+ }
+ }
+ return;
+ }
+ case PM_RATIONAL_NODE: {
+ // 1r
+ // ^^
+ if (!popped) {
+ PUSH_INSN1(ret, location, putobject, parse_rational((const pm_rational_node_t *) node));
+ }
+ return;
+ }
+ case PM_REDO_NODE:
+ // redo
+ // ^^^^
+ pm_compile_redo_node(iseq, &location, ret, popped, scope_node);
+ return;
+ case PM_REGULAR_EXPRESSION_NODE: {
+ // /foo/
+ // ^^^^^
+ if (!popped) {
+ VALUE regexp = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, regexp);
+ }
+ return;
+ }
+ case PM_RESCUE_NODE:
+ // begin; rescue; end
+ // ^^^^^^^
+ pm_compile_rescue_node(iseq, (const pm_rescue_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_RESCUE_MODIFIER_NODE: {
+ // foo rescue bar
+ // ^^^^^^^^^^^^^^
+ const pm_rescue_modifier_node_t *cast = (const pm_rescue_modifier_node_t *) node;
+
+ pm_scope_node_t rescue_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &rescue_scope_node, scope_node);
+
+ rb_iseq_t *rescue_iseq = NEW_CHILD_ISEQ(
+ &rescue_scope_node,
+ rb_str_concat(rb_str_new2("rescue in "), ISEQ_BODY(iseq)->location.label),
+ ISEQ_TYPE_RESCUE,
+ pm_node_line_number_cached(cast->rescue_expression, scope_node)
+ );
+
+ pm_scope_node_destroy(&rescue_scope_node);
+
+ LABEL *lstart = NEW_LABEL(location.line);
+ LABEL *lend = NEW_LABEL(location.line);
+ LABEL *lcont = NEW_LABEL(location.line);
+
+ lstart->rescued = LABEL_RESCUE_BEG;
+ lend->rescued = LABEL_RESCUE_END;
+
+ PUSH_LABEL(ret, lstart);
+ PM_COMPILE_NOT_POPPED(cast->expression);
+ PUSH_LABEL(ret, lend);
+
+ PUSH_INSN(ret, location, nop);
+ PUSH_LABEL(ret, lcont);
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ PUSH_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue_iseq, lcont);
+ PUSH_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, NULL, lstart);
+ return;
+ }
+ case PM_RETURN_NODE:
+ // return
+ // ^^^^^^
+ //
+ // return 1
+ // ^^^^^^^^
+ pm_compile_return_node(iseq, (const pm_return_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_RETRY_NODE: {
+ // retry
+ // ^^^^^
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_RESCUE) {
+ PUSH_INSN(ret, location, putnil);
+ PUSH_INSN1(ret, location, throw, INT2FIX(TAG_RETRY));
+ if (popped) PUSH_INSN(ret, location, pop);
+ }
+ else {
+ COMPILE_ERROR(iseq, location.line, "Invalid retry");
+ return;
+ }
+ return;
+ }
+ case PM_SCOPE_NODE:
+ pm_compile_scope_node(iseq, (pm_scope_node_t *) node, &location, ret, popped);
+ return;
+ case PM_SELF_NODE: {
+ // self
+ // ^^^^
+ if (!popped) {
+ PUSH_INSN(ret, location, putself);
+ }
+ return;
+ }
+ case PM_SHAREABLE_CONSTANT_NODE: {
+ // A value that is being written to a constant that is being marked as
+ // shared depending on the current lexical context.
+ const pm_shareable_constant_node_t *cast = (const pm_shareable_constant_node_t *) node;
+ pm_node_flags_t shareability = (cast->base.flags & (PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL | PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING | PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY));
+
+ switch (PM_NODE_TYPE(cast->write)) {
+ case PM_CONSTANT_WRITE_NODE:
+ pm_compile_constant_write_node(iseq, (const pm_constant_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_AND_WRITE_NODE:
+ pm_compile_constant_and_write_node(iseq, (const pm_constant_and_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_OR_WRITE_NODE:
+ pm_compile_constant_or_write_node(iseq, (const pm_constant_or_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_OPERATOR_WRITE_NODE:
+ pm_compile_constant_operator_write_node(iseq, (const pm_constant_operator_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_PATH_WRITE_NODE:
+ pm_compile_constant_path_write_node(iseq, (const pm_constant_path_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_PATH_AND_WRITE_NODE:
+ pm_compile_constant_path_and_write_node(iseq, (const pm_constant_path_and_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_PATH_OR_WRITE_NODE:
+ pm_compile_constant_path_or_write_node(iseq, (const pm_constant_path_or_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ case PM_CONSTANT_PATH_OPERATOR_WRITE_NODE:
+ pm_compile_constant_path_operator_write_node(iseq, (const pm_constant_path_operator_write_node_t *) cast->write, shareability, &location, ret, popped, scope_node);
+ break;
+ default:
+ rb_bug("Unexpected node type for shareable constant write: %s", pm_node_type(PM_NODE_TYPE(cast->write)));
+ break;
+ }
+
+ return;
+ }
+ case PM_SINGLETON_CLASS_NODE: {
+ // class << self; end
+ // ^^^^^^^^^^^^^^^^^^
+ const pm_singleton_class_node_t *cast = (const pm_singleton_class_node_t *) node;
+
+ pm_scope_node_t next_scope_node;
+ pm_scope_node_init((const pm_node_t *) cast, &next_scope_node, scope_node);
+ const rb_iseq_t *child_iseq = NEW_ISEQ(&next_scope_node, rb_fstring_lit("singleton class"), ISEQ_TYPE_CLASS, location.line);
+ pm_scope_node_destroy(&next_scope_node);
+
+ PM_COMPILE_NOT_POPPED(cast->expression);
+ PUSH_INSN(ret, location, putnil);
+
+ ID singletonclass;
+ CONST_ID(singletonclass, "singletonclass");
+
+ /* `class << self` in a class body and `class << Foo` (constant
+ receiver) are stable. All other forms are potentially dynamic. */
+ int sclass_flags = VM_DEFINECLASS_TYPE_SINGLETON_CLASS;
+ if (!(PM_NODE_TYPE_P(cast->expression, PM_SELF_NODE) &&
+ ISEQ_BODY(iseq)->type == ISEQ_TYPE_CLASS) &&
+ !pm_cpath_const_p(cast->expression)) {
+ sclass_flags |= VM_DEFINECLASS_FLAG_DYNAMIC_CREF;
+ }
+
+ PUSH_INSN3(ret, location, defineclass, ID2SYM(singletonclass), child_iseq, INT2FIX(sclass_flags));
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ RB_OBJ_WRITTEN(iseq, Qundef, (VALUE) child_iseq);
+
+ return;
+ }
+ case PM_SOURCE_ENCODING_NODE: {
+ // __ENCODING__
+ // ^^^^^^^^^^^^
+ if (!popped) {
+ VALUE value = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, value);
+ }
+ return;
+ }
+ case PM_SOURCE_FILE_NODE: {
+ // __FILE__
+ // ^^^^^^^^
+ if (!popped) {
+ const pm_source_file_node_t *cast = (const pm_source_file_node_t *) node;
+ VALUE string = pm_source_file_value(cast, scope_node);
+
+ if (PM_NODE_FLAG_P(cast, PM_STRING_FLAGS_FROZEN)) {
+ PUSH_INSN1(ret, location, putobject, string);
+ }
+ else if (PM_NODE_FLAG_P(cast, PM_STRING_FLAGS_MUTABLE)) {
+ PUSH_INSN1(ret, location, dupstring, string);
+ }
+ else {
+ PUSH_INSN1(ret, location, dupchilledstring, string);
+ }
+ }
+ return;
+ }
+ case PM_SOURCE_LINE_NODE: {
+ // __LINE__
+ // ^^^^^^^^
+ if (!popped) {
+ VALUE value = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, value);
+ }
+ return;
+ }
+ case PM_SPLAT_NODE: {
+ // foo(*bar)
+ // ^^^^
+ const pm_splat_node_t *cast = (const pm_splat_node_t *) node;
+ if (cast->expression) {
+ PM_COMPILE(cast->expression);
+ }
+
+ if (!popped) {
+ PUSH_INSN1(ret, location, splatarray, Qtrue);
+ }
+ return;
+ }
+ case PM_STATEMENTS_NODE: {
+ // A list of statements.
+ const pm_statements_node_t *cast = (const pm_statements_node_t *) node;
+ const pm_node_list_t *body = &cast->body;
+
+ if (body->size > 0) {
+ for (size_t index = 0; index < body->size - 1; index++) {
+ PM_COMPILE_POPPED(body->nodes[index]);
+ }
+ PM_COMPILE(body->nodes[body->size - 1]);
+ }
+ else {
+ PUSH_INSN(ret, location, putnil);
+ }
+ return;
+ }
+ case PM_STRING_NODE: {
+ // "foo"
+ // ^^^^^
+ if (!popped) {
+ const pm_string_node_t *cast = (const pm_string_node_t *) node;
+ VALUE value = parse_static_literal_string(iseq, scope_node, node, &cast->unescaped);
+
+ if (PM_NODE_FLAG_P(node, PM_STRING_FLAGS_FROZEN)) {
+ PUSH_INSN1(ret, location, putobject, value);
+ }
+ else if (PM_NODE_FLAG_P(node, PM_STRING_FLAGS_MUTABLE)) {
+ PUSH_INSN1(ret, location, dupstring, value);
+ }
+ else {
+ PUSH_INSN1(ret, location, dupchilledstring, value);
+ }
+ }
+ return;
+ }
+ case PM_SUPER_NODE:
+ // super()
+ // super(foo)
+ // super(...)
+ pm_compile_super_node(iseq, (const pm_super_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ case PM_SYMBOL_NODE: {
+ // :foo
+ // ^^^^
+ if (!popped) {
+ VALUE value = pm_static_literal_value(iseq, node, scope_node);
+ PUSH_INSN1(ret, location, putobject, value);
+ }
+ return;
+ }
+ case PM_TRUE_NODE: {
+ // true
+ // ^^^^
+ if (!popped) {
+ PUSH_INSN1(ret, location, putobject, Qtrue);
+ }
+ return;
+ }
+ case PM_UNDEF_NODE: {
+ // undef foo
+ // ^^^^^^^^^
+ const pm_undef_node_t *cast = (const pm_undef_node_t *) node;
+ const pm_node_list_t *names = &cast->names;
+
+ for (size_t index = 0; index < names->size; index++) {
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+ PUSH_INSN1(ret, location, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
+
+ PM_COMPILE_NOT_POPPED(names->nodes[index]);
+ PUSH_SEND(ret, location, id_core_undef_method, INT2NUM(2));
+
+ if (index < names->size - 1) {
+ PUSH_INSN(ret, location, pop);
+ }
+ }
+
+ if (popped) PUSH_INSN(ret, location, pop);
+ return;
+ }
+ case PM_UNLESS_NODE: {
+ // unless foo; bar end
+ // ^^^^^^^^^^^^^^^^^^^
+ //
+ // bar unless foo
+ // ^^^^^^^^^^^^^^
+ const pm_unless_node_t *cast = (const pm_unless_node_t *) node;
+ const pm_statements_node_t *statements = NULL;
+ if (cast->else_clause != NULL) {
+ statements = ((const pm_else_node_t *) cast->else_clause)->statements;
+ }
+
+ pm_compile_conditional(iseq, &location, PM_UNLESS_NODE, (const pm_node_t *) cast, statements, (const pm_node_t *) cast->statements, cast->predicate, ret, popped, scope_node);
+ return;
+ }
+ case PM_UNTIL_NODE: {
+ // until foo; bar end
+ // ^^^^^^^^^^^^^^^^^
+ //
+ // bar until foo
+ // ^^^^^^^^^^^^^
+ const pm_until_node_t *cast = (const pm_until_node_t *) node;
+ pm_compile_loop(iseq, &location, cast->base.flags, PM_UNTIL_NODE, (const pm_node_t *) cast, cast->statements, cast->predicate, ret, popped, scope_node);
+ return;
+ }
+ case PM_WHILE_NODE: {
+ // while foo; bar end
+ // ^^^^^^^^^^^^^^^^^^
+ //
+ // bar while foo
+ // ^^^^^^^^^^^^^
+ const pm_while_node_t *cast = (const pm_while_node_t *) node;
+ pm_compile_loop(iseq, &location, cast->base.flags, PM_WHILE_NODE, (const pm_node_t *) cast, cast->statements, cast->predicate, ret, popped, scope_node);
+ return;
+ }
+ case PM_X_STRING_NODE: {
+ // `foo`
+ // ^^^^^
+ const pm_x_string_node_t *cast = (const pm_x_string_node_t *) node;
+ VALUE value = parse_static_literal_string(iseq, scope_node, node, &cast->unescaped);
+
+ PUSH_INSN(ret, location, putself);
+ PUSH_INSN1(ret, location, putobject, value);
+ PUSH_SEND_WITH_FLAG(ret, location, idBackquote, INT2NUM(1), INT2FIX(VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE));
+ if (popped) PUSH_INSN(ret, location, pop);
+
+ return;
+ }
+ case PM_YIELD_NODE:
+ // yield
+ // ^^^^^
+ //
+ // yield 1
+ // ^^^^^^^
+ pm_compile_yield_node(iseq, (const pm_yield_node_t *) node, &location, ret, popped, scope_node);
+ return;
+ default:
+ rb_raise(rb_eNotImpError, "node type %s not implemented", pm_node_type(PM_NODE_TYPE(node)));
+ return;
+ }
+}
+
+#undef PM_CONTAINER_P
+
+/** True if the given iseq can have pre execution blocks. */
+static inline bool
+pm_iseq_pre_execution_p(rb_iseq_t *iseq)
+{
+ switch (ISEQ_BODY(iseq)->type) {
+ case ISEQ_TYPE_TOP:
+ case ISEQ_TYPE_EVAL:
+ case ISEQ_TYPE_MAIN:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**
+ * This is the main entry-point into the prism compiler. It accepts the iseq
+ * that it should be compiling instruction into and a pointer to the scope node
+ * that it should be compiling. It returns the established instruction sequence.
+ * Note that this function could raise Ruby errors if it encounters compilation
+ * errors or if there is a bug in the compiler.
+ */
+VALUE
+pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node)
+{
+ DECL_ANCHOR(ret);
+
+ if (pm_iseq_pre_execution_p(iseq)) {
+ // Because these ISEQs can have BEGIN{}, we're going to create two
+ // anchors to compile them, a "pre" and a "body". We'll mark the "pre"
+ // on the scope node so that when BEGIN{} is found, its contents will be
+ // added to the "pre" anchor.
+ DECL_ANCHOR(pre);
+ node->pre_execution_anchor = pre;
+
+ // Now we'll compile the body as normal. We won't compile directly into
+ // the "ret" anchor yet because we want to add the "pre" anchor to the
+ // beginning of the "ret" anchor first.
+ DECL_ANCHOR(body);
+ pm_compile_node(iseq, (const pm_node_t *) node, body, false, node);
+
+ // Now we'll join both anchors together so that the content is in the
+ // correct order.
+ PUSH_SEQ(ret, pre);
+ PUSH_SEQ(ret, body);
+ }
+ else {
+ // In other circumstances, we can just compile the node directly into
+ // the "ret" anchor.
+ pm_compile_node(iseq, (const pm_node_t *) node, ret, false, node);
+ }
+
+ CHECK(iseq_setup_insn(iseq, ret));
+ return iseq_setup(iseq, ret);
+}
+
+void
+pm_parse_result_init(pm_parse_result_t *result)
+{
+ memset(result, 0, sizeof(pm_parse_result_t));
+ result->arena = pm_arena_new();
+ result->options = pm_options_new();
+ pm_options_line_set(result->options, 1);
+}
+
+/**
+ * Free the internal memory associated with a pm_parse_result_t struct.
+ * Importantly this does not free the struct itself.
+ */
+void
+pm_parse_result_free(pm_parse_result_t *result)
+{
+ if (result->parsed) {
+ SIZED_FREE_N(result->node.constants, pm_parser_constants_size(result->node.parser));
+ pm_scope_node_destroy(&result->node);
+ }
+
+ if (result->parser) pm_parser_free(result->parser);
+ pm_arena_free(result->arena);
+ if (result->source) pm_source_free(result->source);
+ pm_options_free(result->options);
+}
+
+/** An error that is going to be formatted into the output. */
+typedef struct {
+ /** A pointer to the diagnostic that was generated during parsing. */
+ const pm_diagnostic_t *error;
+
+ /** The start line of the diagnostic message. */
+ int32_t line;
+
+ /** The column start of the diagnostic message. */
+ uint32_t column_start;
+
+ /** The column end of the diagnostic message. */
+ uint32_t column_end;
+} pm_parse_error_t;
+
+/** The format that will be used to format the errors into the output. */
+typedef struct {
+ /** The prefix that will be used for line numbers. */
+ const char *number_prefix;
+
+ /** The prefix that will be used for blank lines. */
+ const char *blank_prefix;
+
+ /** The divider that will be used between sections of source code. */
+ const char *divider;
+
+ /** The length of the blank prefix. */
+ size_t blank_prefix_length;
+
+ /** The length of the divider. */
+ size_t divider_length;
+} pm_parse_error_format_t;
+
+#define PM_COLOR_BOLD "\033[1m"
+#define PM_COLOR_GRAY "\033[2m"
+#define PM_COLOR_RED "\033[1;31m"
+#define PM_COLOR_RESET "\033[m"
+#define PM_ERROR_TRUNCATE 30
+
+/** Context struct for collecting errors via callback. */
+typedef struct {
+ pm_parse_error_t *errors;
+ size_t count;
+ size_t capacity;
+ const pm_line_offset_list_t *line_offsets;
+ int32_t start_line;
+} pm_error_collect_t;
+
+static void
+pm_error_collect_callback(const pm_diagnostic_t *diagnostic, void *data)
+{
+ pm_error_collect_t *ctx = (pm_error_collect_t *) data;
+ pm_location_t loc = pm_diagnostic_location(diagnostic);
+
+ pm_line_column_t start = pm_line_offset_list_line_column(ctx->line_offsets, loc.start, ctx->start_line);
+ pm_line_column_t end = pm_line_offset_list_line_column(ctx->line_offsets, loc.start + loc.length, ctx->start_line);
+
+ uint32_t column_end;
+ if (start.line == end.line) {
+ column_end = end.column;
+ } else {
+ column_end = (uint32_t) (ctx->line_offsets->offsets[start.line - ctx->start_line + 1] - ctx->line_offsets->offsets[start.line - ctx->start_line] - 1);
+ }
+
+ // Ensure we have at least one column of error.
+ if (start.column == column_end) column_end++;
+
+ // Insert into sorted position (insertion sort).
+ size_t index = 0;
+ while (
+ (index < ctx->count) &&
+ (
+ (ctx->errors[index].line < start.line) ||
+ ((ctx->errors[index].line == start.line) && (ctx->errors[index].column_start < start.column))
+ )
+ ) index++;
+
+ if (index < ctx->count) {
+ memmove(&ctx->errors[index + 1], &ctx->errors[index], sizeof(pm_parse_error_t) * (ctx->count - index));
+ }
+
+ ctx->errors[index] = (pm_parse_error_t) {
+ .error = diagnostic,
+ .line = start.line,
+ .column_start = start.column,
+ .column_end = column_end
+ };
+ ctx->count++;
+}
+
+static inline pm_parse_error_t *
+pm_parse_errors_format_sort(const pm_parser_t *parser, size_t error_count, const pm_line_offset_list_t *line_offsets) {
+ pm_parse_error_t *errors = xcalloc(error_count, sizeof(pm_parse_error_t));
+ if (errors == NULL) return NULL;
+
+ pm_error_collect_t ctx = {
+ .errors = errors,
+ .count = 0,
+ .capacity = error_count,
+ .line_offsets = line_offsets,
+ .start_line = pm_parser_start_line(parser)
+ };
+
+ pm_parser_errors_each(parser, pm_error_collect_callback, &ctx);
+
+ return errors;
+}
+
+static inline void
+pm_parse_errors_format_line(const pm_parser_t *parser, const pm_line_offset_list_t *line_offsets, const char *number_prefix, int32_t line, uint32_t column_start, uint32_t column_end, VALUE buffer) {
+ int32_t line_delta = line - pm_parser_start_line(parser);
+ assert(line_delta >= 0);
+
+ size_t index = (size_t) line_delta;
+ assert(index < line_offsets->size);
+
+ const uint8_t *start = &pm_parser_start(parser)[line_offsets->offsets[index]];
+ const uint8_t *end;
+
+ if (index >= line_offsets->size - 1) {
+ end = pm_parser_end(parser);
+ } else {
+ end = &pm_parser_start(parser)[line_offsets->offsets[index + 1]];
+ }
+
+ rb_str_catf(buffer, number_prefix, line);
+
+ // Here we determine if we should truncate the end of the line.
+ bool truncate_end = false;
+ if ((column_end != 0) && ((end - (start + column_end)) >= PM_ERROR_TRUNCATE)) {
+ const uint8_t *end_candidate = start + column_end + PM_ERROR_TRUNCATE;
+
+ for (const uint8_t *ptr = start; ptr < end_candidate;) {
+ size_t char_width = pm_parser_encoding_char_width(parser, ptr, pm_parser_end(parser) - ptr);
+
+ // If we failed to decode a character, then just bail out and
+ // truncate at the fixed width.
+ if (char_width == 0) break;
+
+ // If this next character would go past the end candidate,
+ // then we need to truncate before it.
+ if (ptr + char_width > end_candidate) {
+ end_candidate = ptr;
+ break;
+ }
+
+ ptr += char_width;
+ }
+
+ end = end_candidate;
+ truncate_end = true;
+ }
+
+ // Here we determine if we should truncate the start of the line.
+ if (column_start >= PM_ERROR_TRUNCATE) {
+ rb_str_cat(buffer, "... ", 4);
+ start += column_start;
+ }
+
+ rb_str_cat(buffer, (const char *) start, (size_t) (end - start));
+
+ if (truncate_end) {
+ rb_str_cat(buffer, " ...\n", 5);
+ } else if (end == pm_parser_end(parser) && end[-1] != '\n') {
+ rb_str_cat(buffer, "\n", 1);
+ }
+}
+
+/**
+ * Format a pre-sorted array of errors into the given buffer.
+ */
+static void
+pm_parse_errors_format_with(const pm_parser_t *parser, pm_parse_error_t *errors, size_t error_count, VALUE buffer, int highlight, bool inline_messages) {
+ assert(error_count != 0);
+
+ const int32_t start_line = pm_parser_start_line(parser);
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+
+ // Now we're going to determine how we're going to format line numbers and
+ // blank lines based on the maximum number of digits in the line numbers
+ // that are going to be displaid.
+ pm_parse_error_format_t error_format;
+ int32_t first_line_number = errors[0].line;
+ int32_t last_line_number = errors[error_count - 1].line;
+
+ // If we have a maximum line number that is negative, then we're going to
+ // use the absolute value for comparison but multiple by 10 to additionally
+ // have a column for the negative sign.
+ if (first_line_number < 0) first_line_number = (-first_line_number) * 10;
+ if (last_line_number < 0) last_line_number = (-last_line_number) * 10;
+ int32_t max_line_number = first_line_number > last_line_number ? first_line_number : last_line_number;
+
+ if (max_line_number < 10) {
+ if (highlight > 0) {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = PM_COLOR_GRAY "%1" PRIi32 " | " PM_COLOR_RESET,
+ .blank_prefix = PM_COLOR_GRAY " | " PM_COLOR_RESET,
+ .divider = PM_COLOR_GRAY " ~~~~~" PM_COLOR_RESET "\n"
+ };
+ } else {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = "%1" PRIi32 " | ",
+ .blank_prefix = " | ",
+ .divider = " ~~~~~\n"
+ };
+ }
+ } else if (max_line_number < 100) {
+ if (highlight > 0) {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = PM_COLOR_GRAY "%2" PRIi32 " | " PM_COLOR_RESET,
+ .blank_prefix = PM_COLOR_GRAY " | " PM_COLOR_RESET,
+ .divider = PM_COLOR_GRAY " ~~~~~~" PM_COLOR_RESET "\n"
+ };
+ } else {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = "%2" PRIi32 " | ",
+ .blank_prefix = " | ",
+ .divider = " ~~~~~~\n"
+ };
+ }
+ } else if (max_line_number < 1000) {
+ if (highlight > 0) {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = PM_COLOR_GRAY "%3" PRIi32 " | " PM_COLOR_RESET,
+ .blank_prefix = PM_COLOR_GRAY " | " PM_COLOR_RESET,
+ .divider = PM_COLOR_GRAY " ~~~~~~~" PM_COLOR_RESET "\n"
+ };
+ } else {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = "%3" PRIi32 " | ",
+ .blank_prefix = " | ",
+ .divider = " ~~~~~~~\n"
+ };
+ }
+ } else if (max_line_number < 10000) {
+ if (highlight > 0) {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = PM_COLOR_GRAY "%4" PRIi32 " | " PM_COLOR_RESET,
+ .blank_prefix = PM_COLOR_GRAY " | " PM_COLOR_RESET,
+ .divider = PM_COLOR_GRAY " ~~~~~~~~" PM_COLOR_RESET "\n"
+ };
+ } else {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = "%4" PRIi32 " | ",
+ .blank_prefix = " | ",
+ .divider = " ~~~~~~~~\n"
+ };
+ }
+ } else {
+ if (highlight > 0) {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = PM_COLOR_GRAY "%5" PRIi32 " | " PM_COLOR_RESET,
+ .blank_prefix = PM_COLOR_GRAY " | " PM_COLOR_RESET,
+ .divider = PM_COLOR_GRAY " ~~~~~~~~" PM_COLOR_RESET "\n"
+ };
+ } else {
+ error_format = (pm_parse_error_format_t) {
+ .number_prefix = "%5" PRIi32 " | ",
+ .blank_prefix = " | ",
+ .divider = " ~~~~~~~~\n"
+ };
+ }
+ }
+
+ error_format.blank_prefix_length = strlen(error_format.blank_prefix);
+ error_format.divider_length = strlen(error_format.divider);
+
+ // Now we're going to iterate through every error in our error list and
+ // display it. While we're iterating, we will display some padding lines of
+ // the source before the error to give some context. We'll be careful not to
+ // display the same line twice in case the errors are close enough in the
+ // source.
+ int32_t last_line = pm_parser_start_line(parser) - 1;
+ uint32_t last_column_start = 0;
+
+ for (size_t index = 0; index < error_count; index++) {
+ pm_parse_error_t *error = &errors[index];
+
+ // Here we determine how many lines of padding of the source to display,
+ // based on the difference from the last line that was displaid.
+ if (error->line - last_line > 1) {
+ if (error->line - last_line > 2) {
+ if ((index != 0) && (error->line - last_line > 3)) {
+ rb_str_cat(buffer, error_format.divider, error_format.divider_length);
+ }
+
+ rb_str_cat(buffer, " ", 2);
+ pm_parse_errors_format_line(parser, line_offsets, error_format.number_prefix, error->line - 2, 0, 0, buffer);
+ }
+
+ rb_str_cat(buffer, " ", 2);
+ pm_parse_errors_format_line(parser, line_offsets, error_format.number_prefix, error->line - 1, 0, 0, buffer);
+ }
+
+ // If this is the first error or we're on a new line, then we'll display
+ // the line that has the error in it.
+ if ((index == 0) || (error->line != last_line)) {
+ if (highlight > 1) {
+ rb_str_cat_cstr(buffer, PM_COLOR_RED "> " PM_COLOR_RESET);
+ } else if (highlight > 0) {
+ rb_str_cat_cstr(buffer, PM_COLOR_BOLD "> " PM_COLOR_RESET);
+ } else {
+ rb_str_cat_cstr(buffer, "> ");
+ }
+
+ last_column_start = error->column_start;
+
+ // Find the maximum column end of all the errors on this line.
+ uint32_t column_end = error->column_end;
+ for (size_t next_index = index + 1; next_index < error_count; next_index++) {
+ if (errors[next_index].line != error->line) break;
+ if (errors[next_index].column_end > column_end) column_end = errors[next_index].column_end;
+ }
+
+ pm_parse_errors_format_line(parser, line_offsets, error_format.number_prefix, error->line, error->column_start, column_end, buffer);
+ }
+
+ const uint8_t *start = &pm_parser_start(parser)[line_offsets->offsets[error->line - start_line]];
+ if (start == pm_parser_end(parser)) rb_str_cat(buffer, "\n", 1);
+
+ // Now we'll display the actual error message. We'll do this by first
+ // putting the prefix to the line, then a bunch of blank spaces
+ // depending on the column, then as many carets as we need to display
+ // the width of the error, then the error message itself.
+ //
+ // Note that this doesn't take into account the width of the actual
+ // character when displaid in the terminal. For some east-asian
+ // languages or emoji, this means it can be thrown off pretty badly. We
+ // will need to solve this eventually.
+ rb_str_cat(buffer, " ", 2);
+ rb_str_cat(buffer, error_format.blank_prefix, error_format.blank_prefix_length);
+
+ size_t column = 0;
+ if (last_column_start >= PM_ERROR_TRUNCATE) {
+ rb_str_cat(buffer, " ", 4);
+ column = last_column_start;
+ }
+
+ while (column < error->column_start) {
+ rb_str_cat(buffer, " ", 1);
+
+ size_t char_width = pm_parser_encoding_char_width(parser, start + column, pm_parser_end(parser) - (start + column));
+ column += (char_width == 0 ? 1 : char_width);
+ }
+
+ if (highlight > 1) rb_str_cat_cstr(buffer, PM_COLOR_RED);
+ else if (highlight > 0) rb_str_cat_cstr(buffer, PM_COLOR_BOLD);
+ rb_str_cat(buffer, "^", 1);
+
+ size_t char_width = pm_parser_encoding_char_width(parser, start + column, pm_parser_end(parser) - (start + column));
+ column += (char_width == 0 ? 1 : char_width);
+
+ while (column < error->column_end) {
+ rb_str_cat(buffer, "~", 1);
+
+ size_t char_width = pm_parser_encoding_char_width(parser, start + column, pm_parser_end(parser) - (start + column));
+ column += (char_width == 0 ? 1 : char_width);
+ }
+
+ if (highlight > 0) rb_str_cat_cstr(buffer, PM_COLOR_RESET);
+
+ if (inline_messages) {
+ rb_str_cat(buffer, " ", 1);
+ assert(error->error != NULL);
+
+ const char *message = pm_diagnostic_message(error->error);
+ rb_str_cat(buffer, message, strlen(message));
+ }
+
+ rb_str_cat(buffer, "\n", 1);
+
+ // Here we determine how many lines of padding to display after the
+ // error, depending on where the next error is in source.
+ last_line = error->line;
+ int32_t next_line;
+
+ if (index == error_count - 1) {
+ next_line = (((int32_t) line_offsets->size) + pm_parser_start_line(parser));
+
+ // If the file ends with a newline, subtract one from our "next_line"
+ // so that we don't output an extra line at the end of the file
+ if ((pm_parser_start(parser) + line_offsets->offsets[line_offsets->size - 1]) == pm_parser_end(parser)) {
+ next_line--;
+ }
+ }
+ else {
+ next_line = errors[index + 1].line;
+ }
+
+ if (next_line - last_line > 1) {
+ rb_str_cat(buffer, " ", 2);
+ pm_parse_errors_format_line(parser, line_offsets, error_format.number_prefix, ++last_line, 0, 0, buffer);
+ }
+
+ if (next_line - last_line > 1) {
+ rb_str_cat(buffer, " ", 2);
+ pm_parse_errors_format_line(parser, line_offsets, error_format.number_prefix, ++last_line, 0, 0, buffer);
+ }
+ }
+
+}
+
+/**
+ * Format the errors on the parser into the given buffer.
+ */
+static void
+pm_parse_errors_format(const pm_parser_t *parser, size_t error_count, VALUE buffer, int highlight, bool inline_messages) {
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+
+ pm_parse_error_t *errors = pm_parse_errors_format_sort(parser, error_count, line_offsets);
+ if (errors == NULL) return;
+
+ pm_parse_errors_format_with(parser, errors, error_count, buffer, highlight, inline_messages);
+ SIZED_FREE_N(errors, error_count);
+}
+
+#undef PM_ERROR_TRUNCATE
+#undef PM_COLOR_GRAY
+#undef PM_COLOR_RED
+#undef PM_COLOR_RESET
+
+/**
+ * Check if the given source slice is valid UTF-8. The location represents the
+ * location of the error, but the slice of the source will include the content
+ * of all of the lines that the error touches, so we need to check those parts
+ * as well.
+ */
+static bool
+pm_parse_process_error_utf8_p(const pm_parser_t *parser, pm_location_t location)
+{
+ const size_t start_line = pm_line_offset_list_line_column(pm_parser_line_offsets(parser), location.start, 1).line;
+ const size_t end_line = pm_line_offset_list_line_column(pm_parser_line_offsets(parser), location.start + location.length, 1).line;
+
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+ const uint8_t *start = pm_parser_start(parser) + line_offsets->offsets[start_line - 1];
+ const uint8_t *end = ((end_line == line_offsets->size) ? pm_parser_end(parser) : (pm_parser_start(parser) + line_offsets->offsets[end_line]));
+
+ rb_encoding *utf8 = rb_utf8_encoding();
+ while (start < end) {
+ int width = rb_enc_precise_mbclen((const char *) start, (const char *) end, utf8);
+ if (!MBCLEN_CHARFOUND_P(width)) return false;
+ start += MBCLEN_CHARFOUND_LEN(width);
+ }
+
+ return true;
+}
+
+/** Context for the error processing callback used in pm_parse_process_error. */
+typedef struct {
+ const pm_parse_result_t *result;
+ const pm_parser_t *parser;
+ const pm_string_t *filepath;
+ VALUE buffer;
+ int highlight;
+ bool valid_utf8;
+ bool found_argument_error;
+ bool found_load_error;
+ VALUE early_return;
+ const pm_diagnostic_t *first_error;
+ size_t error_count;
+} pm_process_error_ctx_t;
+
+static void
+pm_process_error_check_callback(const pm_diagnostic_t *diagnostic, void *data)
+{
+ pm_process_error_ctx_t *ctx = (pm_process_error_ctx_t *) data;
+ pm_location_t loc = pm_diagnostic_location(diagnostic);
+
+ if (ctx->first_error == NULL) ctx->first_error = diagnostic;
+ ctx->error_count++;
+
+ switch (pm_diagnostic_error_level(diagnostic)) {
+ case PM_ERROR_LEVEL_SYNTAX:
+ if (ctx->valid_utf8 && !pm_parse_process_error_utf8_p(ctx->parser, loc)) {
+ ctx->valid_utf8 = false;
+ }
+ break;
+ case PM_ERROR_LEVEL_ARGUMENT: {
+ if (ctx->found_argument_error || ctx->found_load_error) break;
+ ctx->found_argument_error = true;
+
+ int32_t line_number = (int32_t) pm_location_line_number(ctx->parser, &loc);
+
+ rb_str_catf(
+ ctx->buffer,
+ "%.*s:%" PRIi32 ": %s",
+ (int) pm_string_length(ctx->filepath),
+ pm_string_source(ctx->filepath),
+ line_number,
+ pm_diagnostic_message(diagnostic)
+ );
+
+ if (pm_parse_process_error_utf8_p(ctx->parser, loc)) {
+ rb_str_cat(ctx->buffer, "\n", 1);
+ // Format just this one error. We construct a single-element sorted
+ // array manually and call the format function with count=1.
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(ctx->parser);
+ int32_t start_line = pm_parser_start_line(ctx->parser);
+ pm_line_column_t start_lc = pm_line_offset_list_line_column(line_offsets, loc.start, start_line);
+ pm_line_column_t end_lc = pm_line_offset_list_line_column(line_offsets, loc.start + loc.length, start_line);
+
+ uint32_t col_end;
+ if (start_lc.line == end_lc.line) {
+ col_end = end_lc.column;
+ } else {
+ col_end = (uint32_t) (line_offsets->offsets[start_lc.line - start_line + 1] - line_offsets->offsets[start_lc.line - start_line] - 1);
+ }
+ if (start_lc.column == col_end) col_end++;
+
+ pm_parse_error_t single_error = {
+ .error = diagnostic,
+ .line = start_lc.line,
+ .column_start = start_lc.column,
+ .column_end = col_end
+ };
+ pm_parse_errors_format_with(ctx->parser, &single_error, 1, ctx->buffer, ctx->highlight, false);
+ }
+
+ ctx->early_return = rb_exc_new_str(rb_eArgError, ctx->buffer);
+ break;
+ }
+ case PM_ERROR_LEVEL_LOAD: {
+ if (ctx->found_argument_error || ctx->found_load_error) break;
+ ctx->found_load_error = true;
+
+ VALUE message = rb_enc_str_new_cstr(pm_diagnostic_message(diagnostic), rb_locale_encoding());
+ VALUE value = rb_exc_new3(rb_eLoadError, message);
+ rb_ivar_set(value, rb_intern_const("@path"), Qnil);
+ ctx->early_return = value;
+ break;
+ }
+ }
+}
+
+/** Callback for formatting non-UTF8 errors. */
+typedef struct {
+ const pm_parser_t *parser;
+ const pm_string_t *filepath;
+ VALUE buffer;
+ bool first;
+} pm_error_simple_format_ctx_t;
+
+static void
+pm_error_simple_format_callback(const pm_diagnostic_t *diagnostic, void *data)
+{
+ pm_error_simple_format_ctx_t *ctx = (pm_error_simple_format_ctx_t *) data;
+ pm_location_t loc = pm_diagnostic_location(diagnostic);
+
+ if (!ctx->first) rb_str_cat(ctx->buffer, "\n", 1);
+ ctx->first = false;
+
+ rb_str_catf(ctx->buffer, "%.*s:%" PRIi32 ": %s",
+ (int) pm_string_length(ctx->filepath),
+ pm_string_source(ctx->filepath),
+ (int32_t) pm_location_line_number(ctx->parser, &loc),
+ pm_diagnostic_message(diagnostic));
+}
+
+/**
+ * Generate an error object from the given parser that contains as much
+ * information as possible about the errors that were encountered.
+ */
+static VALUE
+pm_parse_process_error(const pm_parse_result_t *result)
+{
+ const pm_parser_t *parser = result->parser;
+ size_t error_count = pm_parser_errors_size(parser);
+
+ VALUE buffer = rb_str_buf_new(0);
+ const pm_string_t *filepath = pm_parser_filepath(parser);
+
+ int highlight = rb_stderr_tty_p();
+ if (highlight) {
+ const char *no_color = getenv("NO_COLOR");
+ highlight = (no_color == NULL || no_color[0] == '\0') ? 2 : 1;
+ }
+
+ // First pass: check for argument/load errors and UTF-8 validity.
+ pm_process_error_ctx_t ctx = {
+ .result = result,
+ .parser = parser,
+ .filepath = filepath,
+ .buffer = buffer,
+ .highlight = highlight,
+ .valid_utf8 = true,
+ .found_argument_error = false,
+ .found_load_error = false,
+ .early_return = Qundef,
+ .first_error = NULL,
+ .error_count = 0
+ };
+
+ pm_parser_errors_each(parser, pm_process_error_check_callback, &ctx);
+
+ // If we found an argument or load error, return it immediately.
+ if (ctx.early_return != Qundef) {
+ return ctx.early_return;
+ }
+
+ // Format the header line.
+ pm_location_t first_loc = pm_diagnostic_location(ctx.first_error);
+ rb_str_catf(
+ buffer,
+ "%.*s:%" PRIi32 ": syntax error%s found\n",
+ (int) pm_string_length(filepath),
+ pm_string_source(filepath),
+ (int32_t) pm_location_line_number(parser, &first_loc),
+ (error_count > 1) ? "s" : ""
+ );
+
+ if (ctx.valid_utf8) {
+ pm_parse_errors_format(parser, error_count, buffer, highlight, true);
+ }
+ else {
+ pm_error_simple_format_ctx_t simple_ctx = {
+ .parser = parser,
+ .filepath = filepath,
+ .buffer = buffer,
+ .first = true
+ };
+ pm_parser_errors_each(parser, pm_error_simple_format_callback, &simple_ctx);
+ }
+
+ rb_enc_associate(buffer, result->node.encoding);
+ VALUE error = rb_exc_new_str(rb_eSyntaxError, buffer);
+
+ rb_encoding *filepath_encoding = result->node.filepath_encoding != NULL ? result->node.filepath_encoding : rb_utf8_encoding();
+ VALUE path = rb_enc_str_new((const char *) pm_string_source(filepath), pm_string_length(filepath), filepath_encoding);
+
+ rb_ivar_set(error, rb_intern_const("@path"), path);
+
+ return error;
+}
+
+/** Context for interning constants via callback. */
+typedef struct {
+ ID *constants;
+ rb_encoding *encoding;
+ size_t index;
+} pm_intern_constants_ctx_t;
+
+static void
+pm_intern_constants_callback(const pm_constant_t *constant, void *data)
+{
+ pm_intern_constants_ctx_t *ctx = (pm_intern_constants_ctx_t *) data;
+ ctx->constants[ctx->index++] = rb_intern3((const char *) pm_constant_start(constant), pm_constant_length(constant), ctx->encoding);
+}
+
+/** Context for emitting warnings via callback. */
+typedef struct {
+ const pm_parser_t *parser;
+ rb_encoding *encoding;
+ const char *filepath;
+} pm_warning_emit_ctx_t;
+
+static void
+pm_warning_emit_callback(const pm_diagnostic_t *diagnostic, void *data) {
+ pm_warning_emit_ctx_t *ctx = (pm_warning_emit_ctx_t *) data;
+ pm_location_t loc = pm_diagnostic_location(diagnostic);
+ int line = pm_location_line_number(ctx->parser, &loc);
+
+ if (pm_diagnostic_warning_level(diagnostic) == PM_WARNING_LEVEL_VERBOSE) {
+ rb_enc_compile_warning(ctx->encoding, ctx->filepath, line, "%s", pm_diagnostic_message(diagnostic));
+ }
+ else {
+ rb_enc_compile_warn(ctx->encoding, ctx->filepath, line, "%s", pm_diagnostic_message(diagnostic));
+ }
+}
+
+/**
+ * Parse the parse result and raise a Ruby error if there are any syntax errors.
+ * It returns an error if one should be raised. It is assumed that the parse
+ * result object is zeroed out.
+ */
+static VALUE
+pm_parse_process(pm_parse_result_t *result, pm_node_t *node, VALUE *script_lines)
+{
+ pm_parser_t *parser = result->parser;
+
+ // First, set up the scope node so that the AST node is attached and can be
+ // freed regardless of whether or we return an error.
+ pm_scope_node_t *scope_node = &result->node;
+ rb_encoding *filepath_encoding = scope_node->filepath_encoding;
+ int coverage_enabled = scope_node->coverage_enabled;
+
+ pm_scope_node_init(node, scope_node, NULL);
+ scope_node->filepath_encoding = filepath_encoding;
+
+ const char *encoding_name = pm_parser_encoding_name(parser);
+ scope_node->encoding = rb_enc_find(encoding_name);
+ if (!scope_node->encoding) rb_bug("Encoding not found %s!", encoding_name);
+
+ scope_node->coverage_enabled = coverage_enabled;
+
+ // If RubyVM.keep_script_lines is set to true, then we need to create that
+ // array of script lines here.
+ if (script_lines != NULL) {
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+ *script_lines = rb_ary_new_capa(line_offsets->size);
+
+ for (size_t index = 0; index < line_offsets->size; index++) {
+ size_t offset = line_offsets->offsets[index];
+ size_t length = index == line_offsets->size - 1 ? ((size_t) (pm_parser_end(parser) - (pm_parser_start(parser) + offset))) : (line_offsets->offsets[index + 1] - offset);
+ rb_ary_push(*script_lines, rb_enc_str_new((const char *) pm_parser_start(parser) + offset, length, scope_node->encoding));
+ }
+
+ scope_node->script_lines = script_lines;
+ }
+
+ // Emit all of the various warnings from the parse.
+ pm_warning_emit_ctx_t warning_ctx = {
+ .parser = parser,
+ .encoding = scope_node->encoding,
+ .filepath = (const char *) pm_string_source(pm_parser_filepath(parser))
+ };
+ pm_parser_warnings_each(parser, pm_warning_emit_callback, &warning_ctx);
+
+ // If there are errors, raise an appropriate error and free the result.
+ if (pm_parser_errors_size(parser) > 0) {
+ VALUE error = pm_parse_process_error(result);
+
+ // TODO: We need to set the backtrace.
+ // rb_funcallv(error, rb_intern("set_backtrace"), 1, &path);
+ return error;
+ }
+
+ // Now set up the constant pool and intern all of the various constants into
+ // their corresponding IDs.
+ scope_node->parser = parser;
+ scope_node->options = result->options;
+ scope_node->line_offsets = pm_parser_line_offsets(parser);
+ scope_node->start_line = pm_parser_start_line(parser);
+ size_t constants_size = pm_parser_constants_size(parser);
+ scope_node->constants = constants_size ? xmalloc(constants_size * sizeof(ID)) : NULL;
+
+ pm_intern_constants_ctx_t intern_ctx = { .constants = scope_node->constants, .encoding = scope_node->encoding, .index = 0 };
+ pm_parser_constants_each(parser, pm_intern_constants_callback, &intern_ctx);
+
+ // If we got here, this is a success and we can return Qnil to indicate that
+ // no error should be raised.
+ result->parsed = true;
+ return Qnil;
+}
+
+/**
+ * Set the frozen_string_literal option based on the default value used by the
+ * CRuby compiler.
+ */
+static void
+pm_options_frozen_string_literal_init(pm_options_t *options)
+{
+ int frozen_string_literal = rb_iseq_opt_frozen_string_literal();
+
+ switch (frozen_string_literal) {
+ case ISEQ_FROZEN_STRING_LITERAL_UNSET:
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
+ pm_options_frozen_string_literal_set(options, false);
+ break;
+ case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
+ pm_options_frozen_string_literal_set(options, true);
+ break;
+ default:
+ rb_bug("pm_options_frozen_string_literal_init: invalid frozen_string_literal=%d", frozen_string_literal);
+ break;
+ }
+}
+
+/**
+ * Returns an array of ruby String objects that represent the lines of the
+ * source file that the given parser parsed.
+ */
+static inline VALUE
+pm_parse_file_script_lines(const pm_scope_node_t *scope_node, const pm_parser_t *parser)
+{
+ const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser);
+ const char *start = (const char *) pm_parser_start(parser);
+ const char *end = (const char *) pm_parser_end(parser);
+
+ // If we end exactly on a newline, then there's no need to push on a final
+ // segment. If we don't, then we need to push on the last offset up to the
+ // end of the string.
+ size_t last_offset = line_offsets->offsets[line_offsets->size - 1];
+ bool last_push = start + last_offset != end;
+
+ // Create the ruby strings that represent the lines of the source.
+ VALUE lines = rb_ary_new_capa(line_offsets->size - (last_push ? 0 : 1));
+
+ for (size_t index = 0; index < line_offsets->size - 1; index++) {
+ size_t offset = line_offsets->offsets[index];
+ size_t length = line_offsets->offsets[index + 1] - offset;
+
+ rb_ary_push(lines, rb_enc_str_new(start + offset, length, scope_node->encoding));
+ }
+
+ // Push on the last line if we need to.
+ if (last_push) {
+ rb_ary_push(lines, rb_enc_str_new(start + last_offset, end - (start + last_offset), scope_node->encoding));
+ }
+
+ return lines;
+}
+
+struct load_from_fd_args {
+ VALUE path;
+ VALUE io;
+ int open_mode;
+ int fd;
+};
+
+static VALUE
+close_file(VALUE args)
+{
+ struct load_from_fd_args *arg = (void *)args;
+ if (arg->fd != -1) {
+ close(arg->fd);
+ }
+ else if (!NIL_P(arg->io)) {
+ rb_io_close(arg->io);
+ }
+ return Qnil;
+}
+
+static VALUE
+load_content(VALUE args)
+{
+ struct load_from_fd_args *arg = (void *)args;
+ VALUE io = rb_io_fdopen(arg->fd, arg->open_mode, RSTRING_PTR(arg->path));
+ arg->io = io;
+ arg->fd = -1;
+ rb_io_wait(io, RB_INT2NUM(RUBY_IO_READABLE), Qnil);
+ return rb_funcall(io, rb_intern("read"), 0);
+}
+
+/**
+ * Attempt to load the file into memory. Return a Ruby error if the file cannot
+ * be read.
+ */
+VALUE
+pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error)
+{
+ pm_source_init_result_t init_result;
+ result->source = pm_source_mapped_new(RSTRING_PTR(filepath), O_RDONLY | O_NONBLOCK, &init_result);
+
+ if (init_result == PM_SOURCE_INIT_SUCCESS) {
+ pm_options_frozen_string_literal_init(result->options);
+ return Qnil;
+ }
+
+ int err;
+
+ // For non-regular files (pipes, character devices), we need to read
+ // through Ruby IO to properly release the GVL while waiting for data.
+ if (init_result == PM_SOURCE_INIT_ERROR_NON_REGULAR) {
+ struct load_from_fd_args args = {
+ .path = filepath,
+ .open_mode = O_RDONLY | O_NONBLOCK,
+ .fd = rb_cloexec_open(RSTRING_PTR(filepath), args.open_mode, 0),
+ .io = Qnil,
+ };
+ if (args.fd == -1) goto error_generic;
+ VALUE contents = rb_ensure(load_content, (VALUE)&args, close_file, (VALUE)&args);
+
+ if (!RB_TYPE_P(contents, T_STRING)) goto error_generic;
+
+ long len = RSTRING_LEN(contents);
+ if (len < 0) goto error_generic;
+
+ size_t length = (size_t) len;
+ uint8_t *source_data = xmalloc(length);
+ memcpy(source_data, RSTRING_PTR(contents), length);
+ result->source = pm_source_owned_new(source_data, length);
+
+ pm_options_frozen_string_literal_init(result->options);
+ return Qnil;
+ }
+
+ if (init_result == PM_SOURCE_INIT_ERROR_DIRECTORY) {
+ err = EISDIR;
+ } else {
+error_generic:
+#ifdef _WIN32
+ err = rb_w32_map_errno(GetLastError());
+#else
+ err = errno;
+#endif
+ }
+
+ VALUE error;
+ if (load_error) {
+ VALUE message = rb_str_buf_new_cstr(strerror(err));
+ rb_str_cat2(message, " -- ");
+ rb_str_append(message, filepath);
+
+ error = rb_exc_new3(rb_eLoadError, message);
+ rb_ivar_set(error, rb_intern_const("@path"), filepath);
+ } else {
+ error = rb_syserr_new(err, RSTRING_PTR(filepath));
+ RB_GC_GUARD(filepath);
+ }
+
+ return error;
+}
+
+/**
+ * Parse the given filepath and store the resulting scope node in the given
+ * parse result struct. It returns a Ruby error if the file cannot be read or
+ * if it cannot be parsed properly. It is assumed that the parse result object
+ * is zeroed out.
+ */
+VALUE
+pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines)
+{
+ result->node.filepath_encoding = rb_enc_get(filepath);
+ pm_options_filepath_set(result->options, RSTRING_PTR(filepath));
+ RB_GC_GUARD(filepath);
+
+ pm_options_version_for_current_ruby_set(result->options);
+
+ result->parser = pm_parser_new(result->arena, pm_source_source(result->source), pm_source_length(result->source), result->options);
+ pm_node_t *node = pm_parse(result->parser);
+
+ VALUE error = pm_parse_process(result, node, script_lines);
+
+ // If we're parsing a filepath, then we need to potentially support the
+ // SCRIPT_LINES__ constant, which can be a hash that has an array of lines
+ // of every read file.
+ ID id_script_lines = rb_intern("SCRIPT_LINES__");
+
+ if (rb_const_defined_at(rb_cObject, id_script_lines)) {
+ VALUE constant_script_lines = rb_const_get_at(rb_cObject, id_script_lines);
+
+ if (RB_TYPE_P(constant_script_lines, T_HASH)) {
+ rb_hash_aset(constant_script_lines, filepath, pm_parse_file_script_lines(&result->node, result->parser));
+ }
+ }
+
+ return error;
+}
+
+/**
+ * Load and then parse the given filepath. It returns a Ruby error if the file
+ * cannot be read or if it cannot be parsed properly.
+ */
+VALUE
+pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines)
+{
+ VALUE error = pm_load_file(result, filepath, false);
+ if (NIL_P(error)) {
+ error = pm_parse_file(result, filepath, script_lines);
+ }
+
+ return error;
+}
+
+/**
+ * Parse the given source that corresponds to the given filepath and store the
+ * resulting scope node in the given parse result struct. It is assumed that the
+ * parse result object is zeroed out. If the string fails to parse, then a Ruby
+ * error is returned.
+ */
+VALUE
+pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines)
+{
+ rb_encoding *encoding = rb_enc_get(source);
+ if (!rb_enc_asciicompat(encoding)) {
+ return rb_exc_new_cstr(rb_eArgError, "invalid source encoding");
+ }
+
+ pm_options_frozen_string_literal_init(result->options);
+ result->source = pm_source_constant_new((const uint8_t *) RSTRING_PTR(source), (size_t) RSTRING_LEN(source));
+ pm_options_encoding_set(result->options, rb_enc_name(encoding));
+
+ result->node.filepath_encoding = rb_enc_get(filepath);
+ pm_options_filepath_set(result->options, RSTRING_PTR(filepath));
+ RB_GC_GUARD(filepath);
+
+ pm_options_version_for_current_ruby_set(result->options);
+
+ result->parser = pm_parser_new(result->arena, pm_source_source(result->source), pm_source_length(result->source), result->options);
+ pm_node_t *node = pm_parse(result->parser);
+
+ return pm_parse_process(result, node, script_lines);
+}
+
+struct rb_stdin_wrapper {
+ VALUE rb_stdin;
+ int eof_seen;
+};
+
+static int
+pm_parse_stdin_eof(void *stream)
+{
+ struct rb_stdin_wrapper * wrapped_stdin = (struct rb_stdin_wrapper *)stream;
+ return wrapped_stdin->eof_seen;
+}
+
+VALUE rb_io_gets_limit_internal(VALUE io, long limit);
+
+/**
+ * An implementation of fgets that is suitable for use with Ruby IO objects.
+ */
+static char *
+pm_parse_stdin_fgets(char *string, int size, void *stream)
+{
+ RUBY_ASSERT(size > 0);
+
+ struct rb_stdin_wrapper * wrapped_stdin = (struct rb_stdin_wrapper *)stream;
+
+ VALUE line = rb_io_gets_limit_internal(wrapped_stdin->rb_stdin, size - 1);
+ if (NIL_P(line)) {
+ return NULL;
+ }
+
+ const char *cstr = RSTRING_PTR(line);
+ long length = RSTRING_LEN(line);
+
+ memcpy(string, cstr, length);
+ string[length] = '\0';
+
+ // We're reading strings from stdin via gets. We'll assume that if the
+ // string is smaller than the requested length, and doesn't end with a
+ // newline, that we hit EOF.
+ if (length < (size - 1) && string[length - 1] != '\n') {
+ wrapped_stdin->eof_seen = 1;
+ }
+
+ return string;
+}
+
+// We need access to this function when we're done parsing stdin.
+void rb_reset_argf_lineno(long n);
+
+/**
+ * Parse the source off STDIN and store the resulting scope node in the given
+ * parse result struct. It is assumed that the parse result object is zeroed
+ * out. If the stream fails to parse, then a Ruby error is returned.
+ */
+VALUE
+pm_parse_stdin(pm_parse_result_t *result)
+{
+ pm_options_frozen_string_literal_init(result->options);
+
+ struct rb_stdin_wrapper wrapped_stdin = {
+ rb_stdin,
+ 0
+ };
+
+ result->source = pm_source_stream_new((void *) &wrapped_stdin, pm_parse_stdin_fgets, pm_parse_stdin_eof);
+ pm_node_t *node = pm_parse_stream(&result->parser, result->arena, result->source, result->options);
+
+ // When we're done parsing, we reset $. because we don't want the fact that
+ // we went through an IO object to be visible to the user.
+ rb_reset_argf_lineno(0);
+
+ return pm_parse_process(result, node, NULL);
+}
+
+#define PM_VERSION_FOR_RELEASE(major, minor) PM_VERSION_FOR_RELEASE_IMPL(major, minor)
+#define PM_VERSION_FOR_RELEASE_IMPL(major, minor) #major "." #minor
+
+void pm_options_version_for_current_ruby_set(pm_options_t *options) {
+ const char *version = PM_VERSION_FOR_RELEASE(RUBY_API_VERSION_MAJOR, RUBY_API_VERSION_MINOR);
+ pm_options_version_set(options, version, strlen(version));
+}
+
+#undef NEW_ISEQ
+#define NEW_ISEQ OLD_ISEQ
+
+#undef NEW_CHILD_ISEQ
+#define NEW_CHILD_ISEQ OLD_CHILD_ISEQ
diff --git a/prism_compile.h b/prism_compile.h
new file mode 100644
index 0000000000..4485793902
--- /dev/null
+++ b/prism_compile.h
@@ -0,0 +1,198 @@
+#include "prism/prism.h"
+#include "ruby/encoding.h"
+
+/**
+ * the getlocal and setlocal instructions require two parameters. level is how
+ * many hops up the iseq stack one needs to go before finding the correct local
+ * table. The index is the index in that table where our variable is.
+ *
+ * Because these are always calculated and used together, we'll bind them
+ * together as a tuple.
+ */
+typedef struct pm_local_index_struct {
+ int index, level;
+} pm_local_index_t;
+
+// A declaration for the struct that lives in compile.c.
+struct iseq_link_anchor;
+
+/**
+ * A direct-indexed lookup table mapping constant IDs to local variable indices.
+ * Regular constant IDs (1..constants_size) index directly. Special forwarding
+ * parameter IDs (idMULT|FLAG, etc.) are mapped to 4 extra slots at the end.
+ *
+ * All lookups are O(1) — a single array dereference.
+ * The table is arena-allocated for child scopes (no explicit free needed).
+ */
+typedef struct {
+ /** Array of local indices, indexed by constant_id. -1 means not present. */
+ int *values;
+
+ /** Total number of slots (constants_size + PM_INDEX_LOOKUP_SPECIALS). */
+ int capacity;
+
+ /** Whether the values array is heap-allocated and needs explicit free. */
+ bool owned;
+} pm_index_lookup_table_t;
+
+/** Number of extra slots for special forwarding parameter IDs. */
+#define PM_INDEX_LOOKUP_SPECIALS 4
+
+/** Slot offsets for special forwarding parameters (relative to constants_size). */
+#define PM_SPECIAL_CONSTANT_FLAG ((pm_constant_id_t) (1 << 31))
+#define PM_INDEX_LOOKUP_SPECIAL_MULT 0
+#define PM_INDEX_LOOKUP_SPECIAL_POW 1
+#define PM_INDEX_LOOKUP_SPECIAL_AND 2
+#define PM_INDEX_LOOKUP_SPECIAL_DOT3 3
+
+/**
+ * Special constant IDs for forwarding parameters. These use bit 31 to
+ * distinguish them from regular prism constant pool IDs. The lower bits
+ * encode which special slot (0-3) they map to in the lookup table.
+ */
+#define PM_CONSTANT_MULT ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_MULT))
+#define PM_CONSTANT_POW ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_POW))
+#define PM_CONSTANT_AND ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_AND))
+#define PM_CONSTANT_DOT3 ((pm_constant_id_t) (PM_SPECIAL_CONSTANT_FLAG | PM_INDEX_LOOKUP_SPECIAL_DOT3))
+
+static inline int
+pm_index_lookup_table_index(const pm_index_lookup_table_t *table, pm_constant_id_t key)
+{
+ if (LIKELY(!(key & PM_SPECIAL_CONSTANT_FLAG))) {
+ return (int) key - 1;
+ }
+ return table->capacity - PM_INDEX_LOOKUP_SPECIALS + (int)(key & ~PM_SPECIAL_CONSTANT_FLAG);
+}
+
+static inline void
+pm_index_lookup_table_insert(pm_index_lookup_table_t *table, pm_constant_id_t key, int value)
+{
+ int idx = pm_index_lookup_table_index(table, key);
+ RUBY_ASSERT(idx >= 0 && idx < table->capacity);
+ table->values[idx] = value;
+}
+
+static inline int
+pm_index_lookup_table_lookup(const pm_index_lookup_table_t *table, pm_constant_id_t key, int *value)
+{
+ int idx = pm_index_lookup_table_index(table, key);
+ RUBY_ASSERT(idx >= 0 && idx < table->capacity);
+ if (table->values[idx] == -1) return 0;
+ *value = table->values[idx];
+ return 1;
+}
+
+static inline void
+pm_index_lookup_table_init_heap(pm_index_lookup_table_t *table, int constants_size)
+{
+ int cap = constants_size + PM_INDEX_LOOKUP_SPECIALS;
+ table->values = (int *) ruby_xmalloc(cap * sizeof(int));
+ memset(table->values, -1, cap * sizeof(int));
+ table->capacity = cap;
+ table->owned = true;
+}
+
+// ScopeNodes are helper nodes, and will never be part of the AST. We manually
+// declare them here to avoid generating them.
+typedef struct pm_scope_node {
+ pm_node_t base;
+ struct pm_scope_node *previous;
+ pm_node_t *ast_node;
+ pm_node_t *parameters;
+ pm_node_t *body;
+ pm_constant_id_list_t locals;
+
+ const pm_parser_t *parser;
+ const pm_options_t *options;
+ const pm_line_offset_list_t *line_offsets;
+ int32_t start_line;
+ rb_encoding *encoding;
+
+ /**
+ * This is a pointer to the list of script lines for the ISEQs that will be
+ * associated with this scope node. It is only set if
+ * RubyVM.keep_script_lines is true. If it is set, it will be set to a
+ * pointer to an array that is always stack allocated (so no GC marking is
+ * needed by this struct). If it is not set, it will be NULL. It is
+ * inherited by all child scopes.
+ */
+ VALUE *script_lines;
+
+ /**
+ * This is the encoding of the actual filepath object that will be used when
+ * a __FILE__ node is compiled or when the path has to be set on a syntax
+ * error.
+ */
+ rb_encoding *filepath_encoding;
+
+ // The size of the local table on the iseq which includes locals and hidden
+ // variables.
+ int local_table_for_iseq_size;
+
+ ID *constants;
+
+ /**
+ * A flat lookup table mapping constant IDs (or special IDs) to local
+ * variable indices. When allocated from the compile data arena (child
+ * scopes), no explicit free is needed. When heap-allocated (top-level
+ * scope in pm_parse_process), owned is set to true so destroy can free it.
+ */
+ pm_index_lookup_table_t index_lookup_table;
+
+ // The current coverage setting, passed down through the various scopes.
+ int coverage_enabled;
+
+ /**
+ * This will only be set on the top-level scope node. It will contain all of
+ * the instructions pertaining to BEGIN{} nodes.
+ */
+ struct iseq_link_anchor *pre_execution_anchor;
+
+ /**
+ * Cached line hint for line offset list lookups. Since the compiler walks
+ * the AST roughly in source order, consecutive lookups tend to be for
+ * nearby byte offsets. This avoids repeated binary searches.
+ */
+ size_t last_line;
+} pm_scope_node_t;
+
+void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous);
+void pm_scope_node_destroy(pm_scope_node_t *scope_node);
+
+typedef struct {
+ /** The arena allocator for AST-lifetime memory. */
+ pm_arena_t *arena;
+
+ /** The parser that will do the actual parsing. */
+ pm_parser_t *parser;
+
+ /** The options that will be passed to the parser. */
+ pm_options_t *options;
+
+ /** The source backing the parse (file, string, or stream). */
+ pm_source_t *source;
+
+ /** The resulting scope node that will hold the generated AST. */
+ pm_scope_node_t node;
+
+ /** Whether or not this parse result has performed its parsing yet. */
+ bool parsed;
+} pm_parse_result_t;
+
+void pm_parse_result_init(pm_parse_result_t *result);
+VALUE pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error);
+VALUE pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
+VALUE pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
+VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines);
+VALUE pm_parse_stdin(pm_parse_result_t *result);
+void pm_options_version_for_current_ruby_set(pm_options_t *options);
+void pm_parse_result_free(pm_parse_result_t *result);
+
+rb_iseq_t *pm_iseq_new(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type, int *error_state);
+rb_iseq_t *pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state);
+rb_iseq_t *pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state);
+rb_iseq_t *pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, int *error_state);
+rb_iseq_t *pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option, int *error_state);
+rb_iseq_t *pm_iseq_build(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option);
+
+VALUE pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node);
diff --git a/prism_init.c b/prism_init.c
new file mode 100644
index 0000000000..ddc87fad85
--- /dev/null
+++ b/prism_init.c
@@ -0,0 +1,9 @@
+#include "prism/extension.h"
+
+void ruby_init_ext(const char *name, void (*init)(void));
+
+void
+Init_Prism(void)
+{
+ ruby_init_ext("prism/prism.so", Init_prism);
+}
diff --git a/prism_xallocator.h b/prism_xallocator.h
new file mode 100644
index 0000000000..b1fcce48d8
--- /dev/null
+++ b/prism_xallocator.h
@@ -0,0 +1,6 @@
+#ifndef PRISM_XALLOCATOR_H
+#define PRISM_XALLOCATOR_H
+
+#include "ruby/internal/xmalloc.h"
+
+#endif /* PRISM_XALLOCATOR_H */
diff --git a/proc.c b/proc.c
index 17c837d164..bfdc2cc25b 100644
--- a/proc.c
+++ b/proc.c
@@ -15,23 +15,16 @@
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/gc.h"
+#include "internal/hash.h"
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/symbol.h"
#include "method.h"
#include "iseq.h"
#include "vm_core.h"
+#include "ractor_core.h"
#include "yjit.h"
-#if !defined(__GNUC__) || __GNUC__ < 5 || defined(__MINGW32__)
-# define NO_CLOBBERED(v) (*(volatile VALUE *)&(v))
-#else
-# define NO_CLOBBERED(v) (v)
-#endif
-
-#define UPDATE_TYPED_REFERENCE(_type, _ref) *(_type*)&_ref = (_type)rb_gc_location((VALUE)_ref)
-#define UPDATE_REFERENCE(_ref) UPDATE_TYPED_REFERENCE(VALUE, _ref)
-
const rb_cref_t *rb_vm_cref_in_context(VALUE self, VALUE cbase);
struct METHOD {
@@ -60,23 +53,6 @@ static VALUE proc_binding(VALUE self);
#define IS_METHOD_PROC_IFUNC(ifunc) ((ifunc)->func == bmcall)
-/* :FIXME: The way procs are cloned has been historically different from the
- * way everything else are. @shyouhei is not sure for the intention though.
- */
-#undef CLONESETUP
-static inline void
-CLONESETUP(VALUE clone, VALUE obj)
-{
- RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(obj));
- RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(clone));
-
- const VALUE flags = RUBY_FL_PROMOTED0 | RUBY_FL_PROMOTED1 | RUBY_FL_FINALIZE;
- rb_obj_setup(clone, rb_singleton_class_clone(obj),
- RB_FL_TEST_RAW(obj, ~flags));
- rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
- if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
-}
-
static void
block_mark_and_move(struct rb_block *block)
{
@@ -122,7 +98,7 @@ proc_memsize(const void *ptr)
return sizeof(rb_proc_t);
}
-static const rb_data_type_t proc_data_type = {
+const rb_data_type_t ruby_proc_data_type = {
"proc",
{
proc_mark_and_move,
@@ -133,6 +109,8 @@ static const rb_data_type_t proc_data_type = {
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
+#define proc_data_type ruby_proc_data_type
+
VALUE
rb_proc_alloc(VALUE klass)
{
@@ -151,8 +129,15 @@ static VALUE
proc_clone(VALUE self)
{
VALUE procval = rb_proc_dup(self);
- CLONESETUP(procval, self);
- return procval;
+ return rb_obj_clone_setup(self, procval, Qnil);
+}
+
+/* :nodoc: */
+static VALUE
+proc_dup(VALUE self)
+{
+ VALUE procval = rb_proc_dup(self);
+ return rb_obj_dup_setup(self, procval);
}
/*
@@ -273,7 +258,7 @@ static void
binding_free(void *ptr)
{
RUBY_FREE_ENTER("binding");
- ruby_xfree(ptr);
+ SIZED_FREE((rb_binding_t *)ptr);
RUBY_FREE_LEAVE("binding");
}
@@ -315,10 +300,8 @@ rb_binding_alloc(VALUE klass)
return obj;
}
-
-/* :nodoc: */
static VALUE
-binding_dup(VALUE self)
+binding_copy(VALUE self)
{
VALUE bindval = rb_binding_alloc(rb_cBinding);
rb_binding_t *src, *dst;
@@ -332,11 +315,16 @@ binding_dup(VALUE self)
/* :nodoc: */
static VALUE
+binding_dup(VALUE self)
+{
+ return rb_obj_dup_setup(self, binding_copy(self));
+}
+
+/* :nodoc: */
+static VALUE
binding_clone(VALUE self)
{
- VALUE bindval = binding_dup(self);
- CLONESETUP(bindval, self);
- return bindval;
+ return rb_obj_clone_setup(self, binding_copy(self), Qnil);
}
VALUE
@@ -371,7 +359,7 @@ rb_binding_new(void)
*
* # evaluate template in context of the object
* eval(template, user.get_binding)
- * #=> {:name=>"Joan", :position=>"manager"}
+ * #=> {name: "Joan", position: "manager"}
*
* Binding#local_variable_get can be used to access the variables
* whose names are reserved Ruby keywords:
@@ -397,19 +385,31 @@ rb_f_binding(VALUE self)
}
/*
- * call-seq:
- * binding.eval(string [, filename [,lineno]]) -> obj
+ * call-seq:
+ * binding.eval(string, filename = default_filename, lineno = 1) -> 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.
+ * Evaluates the Ruby expression(s) in +string+ in the context of
+ * +self+. Returns the result of the last expression:
*
- * def get_binding(param)
- * binding
- * end
+ * def get_binding(param) = binding
* b = get_binding("hello")
* b.eval("param") #=> "hello"
+ *
+ * If the optional +filename+ is given, it will be used as the
+ * filename of the evaluation (for <tt>__FILE__</tt> and errors).
+ * Otherwise, it will default to <tt>(eval at __FILE__:__LINE__)</tt>
+ * where <tt>__FILE__</tt> and <tt>__LINE__</tt> are the filename and
+ * line number of the caller, respectively:
+ *
+ * b.eval("puts __FILE__") # => "(eval at test.rb:4)"
+ * b.eval("puts __FILE__", "foobar.rb") # => "foobar.rb"
+ *
+ * If the optional +lineno+ is given, it will be used as the
+ * line number of the evaluation (for <tt>__LINE__</tt> and errors).
+ * Otherwise, it will default to 1:
+ *
+ * b.eval("puts __LINE__") # => 1
+ * b.eval("puts __LINE__", "foobar.rb", 10) # => 10
*/
static VALUE
@@ -423,7 +423,7 @@ bind_eval(int argc, VALUE *argv, VALUE bindval)
}
static const VALUE *
-get_local_variable_ptr(const rb_env_t **envp, ID lid)
+get_local_variable_ptr(const rb_env_t **envp, ID lid, bool search_outer)
{
const rb_env_t *env = *envp;
do {
@@ -433,11 +433,11 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid)
}
const rb_iseq_t *iseq = env->iseq;
- unsigned int i;
VM_ASSERT(rb_obj_is_iseq((VALUE)iseq));
- for (i=0; i<ISEQ_BODY(iseq)->local_table_size; i++) {
+ const unsigned int local_table_size = ISEQ_BODY(iseq)->local_table_size;
+ for (unsigned int i=0; i<local_table_size; i++) {
if (ISEQ_BODY(iseq)->local_table[i] == lid) {
if (ISEQ_BODY(iseq)->local_iseq == iseq &&
ISEQ_BODY(iseq)->param.flags.has_block &&
@@ -450,7 +450,9 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid)
}
*envp = env;
- return &env->env[i];
+ unsigned int last_lvar = env->env_size+VM_ENV_INDEX_LAST_LVAR
+ - 1 /* errinfo */;
+ return &env->env[last_lvar - (local_table_size - i)];
}
}
}
@@ -458,7 +460,7 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid)
*envp = NULL;
return NULL;
}
- } while ((env = rb_vm_env_prev_env(env)) != NULL);
+ } while (search_outer && (env = rb_vm_env_prev_env(env)) != NULL);
*envp = NULL;
return NULL;
@@ -477,13 +479,13 @@ check_local_id(VALUE bindval, volatile VALUE *pname)
if (lid) {
if (!rb_is_local_id(lid)) {
- rb_name_err_raise("wrong local variable name `%1$s' for %2$s",
+ rb_name_err_raise("wrong local variable name '%1$s' for %2$s",
bindval, ID2SYM(lid));
}
}
else {
if (!rb_is_local_name(name)) {
- rb_name_err_raise("wrong local variable name `%1$s' for %2$s",
+ rb_name_err_raise("wrong local variable name '%1$s' for %2$s",
bindval, name);
}
return 0;
@@ -520,6 +522,18 @@ bind_local_variables(VALUE bindval)
return rb_vm_env_local_variables(env);
}
+int
+rb_numparam_id_p(ID id)
+{
+ return (tNUMPARAM_1 << ID_SCOPE_SHIFT) <= id && id < ((tNUMPARAM_1 + 9) << ID_SCOPE_SHIFT);
+}
+
+int
+rb_implicit_param_p(ID id)
+{
+ return id == idItImplicit || rb_numparam_id_p(id);
+}
+
/*
* call-seq:
* binding.local_variable_get(symbol) -> obj
@@ -546,17 +560,21 @@ bind_local_variable_get(VALUE bindval, VALUE sym)
const rb_env_t *env;
if (!lid) goto undefined;
+ if (rb_numparam_id_p(lid)) {
+ rb_name_err_raise("numbered parameter '%1$s' is not a local variable",
+ bindval, ID2SYM(lid));
+ }
GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
- if ((ptr = get_local_variable_ptr(&env, lid)) != NULL) {
+ if ((ptr = get_local_variable_ptr(&env, lid, TRUE)) != NULL) {
return *ptr;
}
sym = ID2SYM(lid);
undefined:
- rb_name_err_raise("local variable `%1$s' is not defined for %2$s",
+ rb_name_err_raise("local variable '%1$s' is not defined for %2$s",
bindval, sym);
UNREACHABLE_RETURN(Qundef);
}
@@ -595,10 +613,14 @@ bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
const rb_env_t *env;
if (!lid) lid = rb_intern_str(sym);
+ if (rb_numparam_id_p(lid)) {
+ rb_name_err_raise("numbered parameter '%1$s' is not a local variable",
+ bindval, ID2SYM(lid));
+ }
GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
- if ((ptr = get_local_variable_ptr(&env, lid)) == NULL) {
+ if ((ptr = get_local_variable_ptr(&env, lid, TRUE)) == NULL) {
/* not found. create new env */
ptr = rb_binding_add_dynavars(bindval, bind, 1, &lid);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
@@ -638,10 +660,140 @@ bind_local_variable_defined_p(VALUE bindval, VALUE sym)
const rb_env_t *env;
if (!lid) return Qfalse;
+ if (rb_numparam_id_p(lid)) {
+ rb_name_err_raise("numbered parameter '%1$s' is not a local variable",
+ bindval, ID2SYM(lid));
+ }
GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
- return RBOOL(get_local_variable_ptr(&env, lid));
+ return RBOOL(get_local_variable_ptr(&env, lid, TRUE));
+}
+
+/*
+ * call-seq:
+ * binding.implicit_parameters -> Array
+ *
+ * Returns the names of numbered parameters and "it" parameter
+ * that are defined in the binding.
+ *
+ * def foo
+ * [42].each do
+ * it
+ * binding.implicit_parameters #=> [:it]
+ * end
+ *
+ * { k: 42 }.each do
+ * _2
+ * binding.implicit_parameters #=> [:_1, :_2]
+ * end
+ * end
+ *
+ */
+static VALUE
+bind_implicit_parameters(VALUE bindval)
+{
+ const rb_binding_t *bind;
+ const rb_env_t *env;
+
+ GetBindingPtr(bindval, bind);
+ env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
+
+ if (get_local_variable_ptr(&env, idItImplicit, FALSE)) {
+ return rb_ary_new_from_args(1, ID2SYM(idIt));
+ }
+
+ env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
+ return rb_vm_env_numbered_parameters(env);
+}
+
+/*
+ * call-seq:
+ * binding.implicit_parameter_get(symbol) -> obj
+ *
+ * Returns the value of the numbered parameter or "it" parameter.
+ *
+ * def foo
+ * [42].each do
+ * it
+ * binding.implicit_parameter_get(:it) #=> 42
+ * end
+ *
+ * { k: 42 }.each do
+ * _2
+ * binding.implicit_parameter_get(:_1) #=> :k
+ * binding.implicit_parameter_get(:_2) #=> 42
+ * end
+ * end
+ *
+ */
+static VALUE
+bind_implicit_parameter_get(VALUE bindval, VALUE sym)
+{
+ ID lid = check_local_id(bindval, &sym);
+ const rb_binding_t *bind;
+ const VALUE *ptr;
+ const rb_env_t *env;
+
+ if (lid == idIt) lid = idItImplicit;
+
+ if (!lid || !rb_implicit_param_p(lid)) {
+ rb_name_err_raise("'%1$s' is not an implicit parameter",
+ bindval, sym);
+ }
+
+ GetBindingPtr(bindval, bind);
+
+ env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
+ if ((ptr = get_local_variable_ptr(&env, lid, FALSE)) != NULL) {
+ return *ptr;
+ }
+
+ if (lid == idItImplicit) lid = idIt;
+ rb_name_err_raise("implicit parameter '%1$s' is not defined for %2$s", bindval, ID2SYM(lid));
+ UNREACHABLE_RETURN(Qundef);
+}
+
+/*
+ * call-seq:
+ * binding.implicit_parameter_defined?(symbol) -> obj
+ *
+ * Returns +true+ if the numbered parameter or "it" parameter exists.
+ *
+ * def foo
+ * [42].each do
+ * it
+ * binding.implicit_parameter_defined?(:it) #=> true
+ * binding.implicit_parameter_defined?(:_1) #=> false
+ * end
+ *
+ * { k: 42 }.each do
+ * _2
+ * binding.implicit_parameter_defined?(:_1) #=> true
+ * binding.implicit_parameter_defined?(:_2) #=> true
+ * binding.implicit_parameter_defined?(:_3) #=> false
+ * binding.implicit_parameter_defined?(:it) #=> false
+ * end
+ * end
+ *
+ */
+static VALUE
+bind_implicit_parameter_defined_p(VALUE bindval, VALUE sym)
+{
+ ID lid = check_local_id(bindval, &sym);
+ const rb_binding_t *bind;
+ const rb_env_t *env;
+
+ if (lid == idIt) lid = idItImplicit;
+
+ if (!lid || !rb_implicit_param_p(lid)) {
+ rb_name_err_raise("'%1$s' is not an implicit parameter",
+ bindval, sym);
+ }
+
+ GetBindingPtr(bindval, bind);
+ env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
+ return RBOOL(get_local_variable_ptr(&env, lid, FALSE));
}
/*
@@ -699,6 +851,32 @@ cfunc_proc_new(VALUE klass, VALUE ifunc)
return procval;
}
+VALUE
+rb_func_proc_dup(VALUE src_obj)
+{
+ RUBY_ASSERT(rb_typeddata_is_instance_of(src_obj, &proc_data_type));
+
+ rb_proc_t *src_proc;
+ GetProcPtr(src_obj, src_proc);
+ RUBY_ASSERT(vm_block_type(&src_proc->block) == block_type_ifunc);
+
+ cfunc_proc_t *proc;
+ VALUE proc_obj = TypedData_Make_Struct(rb_obj_class(src_obj), cfunc_proc_t, &proc_data_type, proc);
+
+ memcpy(&proc->basic, src_proc, sizeof(rb_proc_t));
+ RB_OBJ_WRITTEN(proc_obj, Qundef, proc->basic.block.as.captured.self);
+ RB_OBJ_WRITTEN(proc_obj, Qundef, proc->basic.block.as.captured.code.val);
+
+ const VALUE *src_ep = src_proc->block.as.captured.ep;
+ VALUE *ep = *(VALUE **)&proc->basic.block.as.captured.ep = proc->env + VM_ENV_DATA_SIZE - 1;
+ ep[VM_ENV_DATA_INDEX_FLAGS] = src_ep[VM_ENV_DATA_INDEX_FLAGS];
+ ep[VM_ENV_DATA_INDEX_ME_CREF] = src_ep[VM_ENV_DATA_INDEX_ME_CREF];
+ ep[VM_ENV_DATA_INDEX_SPECVAL] = src_ep[VM_ENV_DATA_INDEX_SPECVAL];
+ RB_OBJ_WRITE(proc_obj, &ep[VM_ENV_DATA_INDEX_ENV], src_ep[VM_ENV_DATA_INDEX_ENV]);
+
+ return proc_obj;
+}
+
static VALUE
sym_proc_new(VALUE klass, VALUE sym)
{
@@ -715,11 +893,6 @@ sym_proc_new(VALUE klass, VALUE sym)
struct vm_ifunc *
rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc)
{
- union {
- struct vm_ifunc_argc argc;
- VALUE packed;
- } arity;
-
if (min_argc < UNLIMITED_ARGUMENTS ||
#if SIZEOF_INT * 2 > SIZEOF_VALUE
min_argc >= (int)(1U << (SIZEOF_VALUE * CHAR_BIT) / 2) ||
@@ -736,18 +909,18 @@ rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int m
rb_raise(rb_eRangeError, "maximum argument number out of range: %d",
max_argc);
}
- arity.argc.min = min_argc;
- arity.argc.max = max_argc;
rb_execution_context_t *ec = GET_EC();
- VALUE ret = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)data, arity.packed, (VALUE)rb_vm_svar_lep(ec, ec->cfp));
- return (struct vm_ifunc *)ret;
-}
-VALUE
-rb_func_proc_new(rb_block_call_func_t func, VALUE val)
-{
- struct vm_ifunc *ifunc = rb_vm_ifunc_proc_new(func, (void *)val);
- return cfunc_proc_new(rb_cProc, (VALUE)ifunc);
+ struct vm_ifunc *ifunc = IMEMO_NEW(struct vm_ifunc, imemo_ifunc, (VALUE)rb_vm_svar_lep(ec, ec->cfp));
+
+ rb_gc_register_pinning_obj((VALUE)ifunc);
+
+ ifunc->func = func;
+ ifunc->data = data;
+ ifunc->argc.min = min_argc;
+ ifunc->argc.max = max_argc;
+
+ return ifunc;
}
VALUE
@@ -760,7 +933,7 @@ rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_a
static const char proc_without_block[] = "tried to create Proc object without a block";
static VALUE
-proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
+proc_new(VALUE klass, int8_t is_lambda)
{
VALUE procval;
const rb_execution_context_t *ec = GET_EC();
@@ -793,16 +966,8 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
break;
case block_handler_type_ifunc:
- return rb_vm_make_proc_lambda(ec, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
case block_handler_type_iseq:
- {
- const struct rb_captured_block *captured = VM_BH_TO_CAPT_BLOCK(block_handler);
- rb_control_frame_t *last_ruby_cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
- if (is_lambda && last_ruby_cfp && vm_cfp_forwarded_bh_p(last_ruby_cfp, block_handler)) {
- is_lambda = false;
- }
- return rb_vm_make_proc_lambda(ec, captured, klass, is_lambda);
- }
+ return rb_vm_make_proc_lambda(ec, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
}
VM_UNREACHABLE(proc_new);
return Qnil;
@@ -825,7 +990,7 @@ proc_new(VALUE klass, int8_t is_lambda, int8_t kernel)
static VALUE
rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
{
- VALUE block = proc_new(klass, FALSE, FALSE);
+ VALUE block = proc_new(klass, FALSE);
rb_obj_call_init_kw(block, argc, argv, RB_PASS_CALLED_KEYWORDS);
return block;
@@ -834,7 +999,7 @@ rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
VALUE
rb_block_proc(void)
{
- return proc_new(rb_cProc, FALSE, FALSE);
+ return proc_new(rb_cProc, FALSE);
}
/*
@@ -847,41 +1012,44 @@ rb_block_proc(void)
static VALUE
f_proc(VALUE _)
{
- return proc_new(rb_cProc, FALSE, TRUE);
+ return proc_new(rb_cProc, FALSE);
}
VALUE
rb_block_lambda(void)
{
- return proc_new(rb_cProc, TRUE, FALSE);
+ return proc_new(rb_cProc, TRUE);
}
static void
-f_lambda_warn(void)
+f_lambda_filter_non_literal(void)
{
rb_control_frame_t *cfp = GET_EC()->cfp;
VALUE block_handler = rb_vm_frame_block_handler(cfp);
- if (block_handler != VM_BLOCK_HANDLER_NONE) {
- switch (vm_block_handler_type(block_handler)) {
- case block_handler_type_iseq:
- if (RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)->ep == VM_BH_TO_ISEQ_BLOCK(block_handler)->ep) {
- return;
- }
- break;
- case block_handler_type_symbol:
+ if (block_handler == VM_BLOCK_HANDLER_NONE) {
+ // no block error raised else where
+ return;
+ }
+
+ switch (vm_block_handler_type(block_handler)) {
+ case block_handler_type_iseq:
+ if (RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)->ep == VM_BH_TO_ISEQ_BLOCK(block_handler)->ep) {
return;
- case block_handler_type_proc:
- if (rb_proc_lambda_p(VM_BH_TO_PROC(block_handler))) {
- return;
- }
- break;
- case block_handler_type_ifunc:
- break;
}
+ break;
+ case block_handler_type_symbol:
+ return;
+ case block_handler_type_proc:
+ if (rb_proc_lambda_p(VM_BH_TO_PROC(block_handler))) {
+ return;
+ }
+ break;
+ case block_handler_type_ifunc:
+ break;
}
- rb_warn_deprecated("lambda without a literal block", "the proc without lambda");
+ rb_raise(rb_eArgError, "the lambda method requires a literal block");
}
/*
@@ -895,7 +1063,7 @@ f_lambda_warn(void)
static VALUE
f_lambda(VALUE _)
{
- f_lambda_warn();
+ f_lambda_filter_non_literal();
return rb_block_lambda();
}
@@ -917,13 +1085,12 @@ f_lambda(VALUE _)
* Document-method: Proc#yield
*
* call-seq:
- * prc.call(params,...) -> obj
- * prc[params,...] -> obj
- * prc.(params,...) -> obj
- * prc.yield(params,...) -> obj
+ * call(...) -> obj
+ * self[...] -> obj
+ * yield(...) -> obj
*
- * Invokes the block, setting the block's parameters to the values in
- * <i>params</i> using something close to method calling semantics.
+ * Invokes the block, setting the block's parameters to the arguments
+ * using something close to method calling semantics.
* Returns the value of the last expression evaluated in the block.
*
* a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
@@ -977,7 +1144,12 @@ rb_proc_call_kw(VALUE self, VALUE args, int kw_splat)
VALUE vret;
rb_proc_t *proc;
int argc = check_argc(RARRAY_LEN(args));
- const VALUE *argv = RARRAY_CONST_PTR(args);
+
+ // rb_vm_invoke_proc may end up modifying argv as part of calling and so we
+ // must use RARRAY_PTR, which marks the array as WB_UNPROTECTED instead of
+ // RARRAY_CONST_PTR. Unfortunately this is worse for GC.
+ // See invoke_block_from_c_proc
+ VALUE *argv = RARRAY_PTR(args);
GetProcPtr(self, proc);
vret = rb_vm_invoke_proc(GET_EC(), proc, argc, argv,
kw_splat, VM_BLOCK_HANDLER_NONE);
@@ -1070,7 +1242,7 @@ rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
{
*max = ISEQ_BODY(iseq)->param.flags.has_rest == FALSE ?
ISEQ_BODY(iseq)->param.lead_num + ISEQ_BODY(iseq)->param.opt_num + ISEQ_BODY(iseq)->param.post_num +
- (ISEQ_BODY(iseq)->param.flags.has_kw == TRUE || ISEQ_BODY(iseq)->param.flags.has_kwrest == TRUE)
+ (ISEQ_BODY(iseq)->param.flags.has_kw == TRUE || ISEQ_BODY(iseq)->param.flags.has_kwrest == TRUE || ISEQ_BODY(iseq)->param.flags.forwardable == TRUE)
: UNLIMITED_ARGUMENTS;
return ISEQ_BODY(iseq)->param.lead_num + ISEQ_BODY(iseq)->param.post_num + (ISEQ_BODY(iseq)->param.flags.has_kw && ISEQ_BODY(iseq)->param.keyword->required_num > 0);
}
@@ -1166,10 +1338,10 @@ rb_block_pair_yield_optimizable(void)
min = rb_vm_block_min_max_arity(&block, &max);
switch (vm_block_type(&block)) {
- case block_handler_type_symbol:
+ case block_type_symbol:
return 0;
- case block_handler_type_proc:
+ case block_type_proc:
{
VALUE procval = block_handler;
rb_proc_t *proc;
@@ -1179,6 +1351,12 @@ rb_block_pair_yield_optimizable(void)
return min > 1;
}
+ case block_type_ifunc:
+ {
+ const struct vm_ifunc *ifunc = block.as.captured.code.ifunc;
+ if (ifunc->flags & IFUNC_YIELD_OPTIMIZABLE) return 1;
+ }
+
default:
return min > 1;
}
@@ -1200,10 +1378,10 @@ rb_block_arity(void)
block_setup(&block, block_handler);
switch (vm_block_type(&block)) {
- case block_handler_type_symbol:
+ case block_type_symbol:
return -1;
- case block_handler_type_proc:
+ case block_type_proc:
return rb_proc_arity(block_handler);
default:
@@ -1264,10 +1442,10 @@ rb_proc_get_iseq(VALUE self, int *is_proc)
}
/* call-seq:
- * prc == other -> true or false
- * prc.eql?(other) -> true or false
+ * self == other -> true or false
+ * eql?(other) -> true or false
*
- * Two procs are the same if, and only if, they were created from the same code block.
+ * Returns whether +self+ and +other+ were created from the same code block:
*
* def return_block(&block)
* block
@@ -1324,12 +1502,17 @@ proc_eq(VALUE self, VALUE other)
}
break;
case block_type_ifunc:
- if (self_block->as.captured.ep != \
- other_block->as.captured.ep ||
- self_block->as.captured.code.ifunc != \
+ if (self_block->as.captured.code.ifunc != \
other_block->as.captured.code.ifunc) {
return Qfalse;
}
+
+ if (memcmp(
+ ((cfunc_proc_t *)self_proc)->env,
+ ((cfunc_proc_t *)other_proc)->env,
+ sizeof(((cfunc_proc_t *)self_proc)->env))) {
+ return Qfalse;
+ }
break;
case block_type_proc:
if (self_block->as.proc != other_block->as.proc) {
@@ -1451,11 +1634,36 @@ rb_hash_proc(st_index_t hash, VALUE prc)
{
rb_proc_t *proc;
GetProcPtr(prc, proc);
- hash = rb_hash_uint(hash, (st_index_t)proc->block.as.captured.code.val);
- hash = rb_hash_uint(hash, (st_index_t)proc->block.as.captured.self);
- return rb_hash_uint(hash, (st_index_t)proc->block.as.captured.ep);
+
+ switch (vm_block_type(&proc->block)) {
+ case block_type_iseq:
+ hash = rb_st_hash_uint(hash, (st_index_t)proc->block.as.captured.code.iseq->body);
+ break;
+ case block_type_ifunc:
+ hash = rb_st_hash_uint(hash, (st_index_t)proc->block.as.captured.code.ifunc->func);
+ hash = rb_st_hash_uint(hash, (st_index_t)proc->block.as.captured.code.ifunc->data);
+ break;
+ case block_type_symbol:
+ hash = rb_st_hash_uint(hash, rb_any_hash(proc->block.as.symbol));
+ break;
+ case block_type_proc:
+ hash = rb_st_hash_uint(hash, rb_any_hash(proc->block.as.proc));
+ break;
+ default:
+ rb_bug("rb_hash_proc: unknown block type %d", vm_block_type(&proc->block));
+ }
+
+ /* ifunc procs have their own allocated ep. If an ifunc is duplicated, they
+ * will point to different ep but they should return the same hash code, so
+ * we cannot include the ep in the hash. */
+ if (vm_block_type(&proc->block) != block_type_ifunc) {
+ hash = rb_hash_uint(hash, (st_index_t)proc->block.as.captured.ep);
+ }
+
+ return hash;
}
+static VALUE sym_proc_cache = Qfalse;
/*
* call-seq:
@@ -1474,29 +1682,33 @@ rb_hash_proc(st_index_t hash, VALUE prc)
VALUE
rb_sym_to_proc(VALUE sym)
{
- static VALUE sym_proc_cache = Qfalse;
enum {SYM_PROC_CACHE_SIZE = 67};
- VALUE proc;
- long index;
- ID id;
- if (!sym_proc_cache) {
- sym_proc_cache = rb_ary_hidden_new(SYM_PROC_CACHE_SIZE * 2);
- rb_gc_register_mark_object(sym_proc_cache);
- rb_ary_store(sym_proc_cache, SYM_PROC_CACHE_SIZE*2 - 1, Qnil);
- }
+ if (rb_ractor_main_p()) {
+ if (!sym_proc_cache) {
+ sym_proc_cache = rb_ary_hidden_new(SYM_PROC_CACHE_SIZE);
+ rb_ary_store(sym_proc_cache, SYM_PROC_CACHE_SIZE - 1, Qnil);
+ }
- id = SYM2ID(sym);
- index = (id % SYM_PROC_CACHE_SIZE) << 1;
+ ID id = SYM2ID(sym);
+ long index = (id % SYM_PROC_CACHE_SIZE);
+ VALUE procval = RARRAY_AREF(sym_proc_cache, index);
+ if (RTEST(procval)) {
+ rb_proc_t *proc;
+ GetProcPtr(procval, proc);
+
+ if (proc->block.as.symbol == sym) {
+ return procval;
+ }
+ }
+
+ procval = sym_proc_new(rb_cProc, sym);
+ RARRAY_ASET(sym_proc_cache, index, procval);
- if (RARRAY_AREF(sym_proc_cache, index) == sym) {
- return RARRAY_AREF(sym_proc_cache, index + 1);
+ return RB_GC_GUARD(procval);
}
else {
- proc = sym_proc_new(rb_cProc, ID2SYM(id));
- RARRAY_ASET(sym_proc_cache, index, sym);
- RARRAY_ASET(sym_proc_cache, index + 1, proc);
- return proc;
+ return sym_proc_new(rb_cProc, sym);
}
}
@@ -1592,21 +1804,15 @@ bm_mark_and_move(void *ptr)
rb_gc_mark_and_move_ptr((rb_method_entry_t **)&data->me);
}
-static size_t
-bm_memsize(const void *ptr)
-{
- return sizeof(struct METHOD);
-}
-
static const rb_data_type_t method_data_type = {
"method",
{
bm_mark_and_move,
RUBY_TYPED_DEFAULT_FREE,
- bm_memsize,
+ NULL, // No external memory to report,
bm_mark_and_move,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE | RUBY_TYPED_FROZEN_SHAREABLE_NO_REC
};
VALUE
@@ -1659,6 +1865,8 @@ mnew_missing_by_name(VALUE klass, VALUE obj, VALUE *name, int scope, VALUE mclas
return mnew_missing(klass, obj, SYM2ID(vid), mclass);
}
+VALUE rb_zsuper_to_super(int argc, VALUE *argv, VALUE self);
+
static VALUE
mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
VALUE obj, ID id, VALUE mclass, int scope, int error)
@@ -1684,8 +1892,9 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
rb_print_inaccessible(klass, id, visi);
}
}
- if (me->def->type == VM_METHOD_TYPE_ZSUPER) {
- if (me->defined_class) {
+ if (me->def->type == VM_METHOD_TYPE_ZSUPER ||
+ (me->def->type == VM_METHOD_TYPE_CFUNC && me->def->body.cfunc.func == (rb_cfunc_t)rb_zsuper_to_super)) {
+ if (me->def->type == VM_METHOD_TYPE_ZSUPER && me->defined_class) {
VALUE klass = RCLASS_SUPER(RCLASS_ORIGIN(me->defined_class));
id = me->def->original_id;
me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
@@ -1700,7 +1909,7 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
method = TypedData_Make_Struct(mclass, struct METHOD, &method_data_type, data);
- if (obj == Qundef) {
+ if (UNDEF_P(obj)) {
RB_OBJ_WRITE(method, &data->recv, Qundef);
RB_OBJ_WRITE(method, &data->klass, Qundef);
}
@@ -1754,7 +1963,7 @@ method_entry_defined_class(const rb_method_entry_t *me)
*
* Document-class: Method
*
- * Method objects are created by Object#method, and are associated
+ * +Method+ objects are created by Object#method, 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
@@ -1780,10 +1989,9 @@ method_entry_defined_class(const rb_method_entry_t *me)
/*
* call-seq:
- * meth.eql?(other_meth) -> true or false
- * meth == other_meth -> true or false
+ * self == other -> true or false
*
- * Two method objects are equal if they are bound to the same
+ * Returns whether +self+ and +other+ are bound to the same
* object and refer to the same method definition and the classes
* defining the methods are the same class or module.
*/
@@ -1800,11 +2008,13 @@ method_eq(VALUE method, VALUE other)
return Qfalse;
Check_TypedStruct(method, &method_data_type);
- m1 = (struct METHOD *)DATA_PTR(method);
- m2 = (struct METHOD *)DATA_PTR(other);
+ m1 = (struct METHOD *)RTYPEDDATA_GET_DATA(method);
+ m2 = (struct METHOD *)RTYPEDDATA_GET_DATA(other);
klass1 = method_entry_defined_class(m1->me);
klass2 = method_entry_defined_class(m2->me);
+ if (RB_TYPE_P(klass1, T_ICLASS)) klass1 = RBASIC_CLASS(klass1);
+ if (RB_TYPE_P(klass2, T_ICLASS)) klass2 = RBASIC_CLASS(klass2);
if (!rb_method_entry_eq(m1->me, m2->me) ||
klass1 != klass2 ||
@@ -1964,14 +2174,34 @@ method_owner(VALUE obj)
return data->owner;
}
+/*
+ * call-seq:
+ * meth.box -> box or nil
+ *
+ * Returns the Ruby::Box where +meth+ is defined in.
+ */
+static VALUE
+method_box(VALUE obj)
+{
+ struct METHOD *data;
+ const rb_box_t *box;
+
+ TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
+ box = data->me->def->box;
+ if (!box) return Qnil;
+ if (box->box_object) return box->box_object;
+ rb_bug("Unexpected box on the method definition: %p", (void*) box);
+ UNREACHABLE_RETURN(Qnil);
+}
+
void
rb_method_name_error(VALUE klass, VALUE str)
{
-#define MSG(s) rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")
+#define MSG(s) rb_fstring_lit("undefined method '%1$s' for"s" '%2$s'")
VALUE c = klass;
VALUE s = Qundef;
- if (FL_TEST(c, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(c)) {
VALUE obj = RCLASS_ATTACHED_OBJECT(klass);
switch (BUILTIN_TYPE(obj)) {
@@ -2013,7 +2243,7 @@ obj_method(VALUE obj, VALUE vid, int scope)
* obj.method(sym) -> method
*
* Looks up the named method as a receiver in <i>obj</i>, returning a
- * Method object (or raising NameError). The Method object acts as a
+ * +Method+ object (or raising NameError). The +Method+ object acts as a
* closure in <i>obj</i>'s object instance, so instance variables and
* the value of <code>self</code> remain available.
*
@@ -2034,7 +2264,7 @@ obj_method(VALUE obj, VALUE vid, int scope)
* m = l.method("hello")
* m.call #=> "Hello, @iv = Fred"
*
- * Note that Method implements <code>to_proc</code> method, which
+ * Note that +Method+ implements <code>to_proc</code> method, which
* means it can be used with iterators.
*
* [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
@@ -2066,6 +2296,19 @@ rb_obj_public_method(VALUE obj, VALUE vid)
return obj_method(obj, vid, TRUE);
}
+static VALUE
+rb_obj_singleton_method_lookup(VALUE arg)
+{
+ VALUE *args = (VALUE *)arg;
+ return rb_obj_method(args[0], args[1]);
+}
+
+static VALUE
+rb_obj_singleton_method_lookup_fail(VALUE arg1, VALUE arg2)
+{
+ return Qfalse;
+}
+
/*
* call-seq:
* obj.singleton_method(sym) -> method
@@ -2093,13 +2336,13 @@ rb_obj_public_method(VALUE obj, VALUE vid)
VALUE
rb_obj_singleton_method(VALUE obj, VALUE vid)
{
- VALUE klass = rb_singleton_class_get(obj);
+ VALUE sc = rb_singleton_class_get(obj);
+ VALUE klass;
ID id = rb_check_id(&vid);
- if (NIL_P(klass)) {
- /* goto undef; */
- }
- else if (NIL_P(klass = RCLASS_ORIGIN(klass))) {
+ if (NIL_P(sc) ||
+ NIL_P(klass = RCLASS_ORIGIN(sc)) ||
+ !NIL_P(rb_special_singleton_class(obj))) {
/* goto undef; */
}
else if (! id) {
@@ -2108,22 +2351,27 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
/* else goto undef; */
}
else {
- const rb_method_entry_t *me = rb_method_entry_at(klass, id);
- vid = ID2SYM(id);
-
- if (UNDEFINED_METHOD_ENTRY_P(me)) {
- /* goto undef; */
- }
- else if (UNDEFINED_REFINED_METHOD_P(me->def)) {
- /* goto undef; */
- }
- else {
- return mnew_from_me(me, klass, klass, obj, id, rb_cMethod, FALSE);
+ VALUE args[2] = {obj, vid};
+ VALUE ruby_method = rb_rescue(rb_obj_singleton_method_lookup, (VALUE)args, rb_obj_singleton_method_lookup_fail, Qfalse);
+ if (ruby_method) {
+ struct METHOD *method = (struct METHOD *)RTYPEDDATA_GET_DATA(ruby_method);
+ VALUE lookup_class = RBASIC_CLASS(obj);
+ VALUE stop_class = rb_class_superclass(sc);
+ VALUE method_class = method->iclass;
+
+ /* Determine if method is in singleton class, or module included in or prepended to it */
+ do {
+ if (lookup_class == method_class) {
+ return ruby_method;
+ }
+ lookup_class = RCLASS_SUPER(lookup_class);
+ } while (lookup_class && lookup_class != stop_class);
}
}
/* undef: */
- rb_name_err_raise("undefined singleton method `%1$s' for `%2$s'",
+ vid = ID2SYM(id);
+ rb_name_err_raise("undefined singleton method '%1$s' for '%2$s'",
obj, vid);
UNREACHABLE_RETURN(Qundef);
}
@@ -2134,29 +2382,29 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
*
* Returns an +UnboundMethod+ representing the given
* instance method in _mod_.
+ * See +UnboundMethod+ about how to utilize it
*
- * 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_char {|b| Dispatcher[b].bind(self).call }
- * end
- * end
+ * class Person
+ * def initialize(name)
+ * @name = name
+ * end
*
- * interpreter = Interpreter.new
- * interpreter.interpret('dave')
+ * def hi
+ * puts "Hi, I'm #{@name}!"
+ * end
+ * end
+ *
+ * dave = Person.new('Dave')
+ * thomas = Person.new('Thomas')
+ *
+ * hi = Person.instance_method(:hi)
+ * hi.bind_call(dave)
+ * hi.bind_call(thomas)
*
* <em>produces:</em>
*
- * Hello there, Dave!
+ * Hi, I'm Dave!
+ * Hi, I'm Thomas!
*/
static VALUE
@@ -2218,10 +2466,10 @@ rb_mod_define_method_with_visibility(int argc, VALUE *argv, VALUE mod, const str
if (!id) id = rb_to_id(name);
if (is_method) {
- struct METHOD *method = (struct METHOD *)DATA_PTR(body);
+ struct METHOD *method = (struct METHOD *)RTYPEDDATA_GET_DATA(body);
if (method->me->owner != mod && !RB_TYPE_P(method->me->owner, T_MODULE) &&
!RTEST(rb_class_inherited_p(mod, method->me->owner))) {
- if (FL_TEST(method->me->owner, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(method->me->owner)) {
rb_raise(rb_eTypeError,
"can't bind singleton method to a different class");
}
@@ -2358,17 +2606,7 @@ rb_obj_define_method(int argc, VALUE *argv, VALUE obj)
static VALUE
top_define_method(int argc, VALUE *argv, VALUE obj)
{
- rb_thread_t *th = GET_THREAD();
- VALUE klass;
-
- klass = th->top_wrapper;
- if (klass) {
- rb_warning("main.define_method in the wrapped load is effective only in wrapper module");
- }
- else {
- klass = rb_cObject;
- }
- return rb_mod_define_method(argc, argv, klass);
+ return rb_mod_define_method(argc, argv, rb_top_main_class("define_method"));
}
/*
@@ -2395,8 +2633,8 @@ method_clone(VALUE self)
struct METHOD *orig, *data;
TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig);
- clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data);
- CLONESETUP(clone, self);
+ clone = TypedData_Make_Struct(rb_obj_class(self), struct METHOD, &method_data_type, data);
+ rb_obj_clone_setup(self, clone, Qnil);
RB_OBJ_WRITE(clone, &data->recv, orig->recv);
RB_OBJ_WRITE(clone, &data->klass, orig->klass);
RB_OBJ_WRITE(clone, &data->iclass, orig->iclass);
@@ -2405,47 +2643,46 @@ method_clone(VALUE self)
return clone;
}
-/* Document-method: Method#===
- *
- * call-seq:
- * method === obj -> result_of_method
- *
- * Invokes the method with +obj+ as the parameter like #call.
- * This allows a method object to be the target of a +when+ clause
- * in a case statement.
- *
- * require 'prime'
- *
- * case 1373
- * when Prime.method(:prime?)
- * # ...
- * end
- */
-
+/* :nodoc: */
+static VALUE
+method_dup(VALUE self)
+{
+ VALUE clone;
+ struct METHOD *orig, *data;
-/* Document-method: Method#[]
- *
- * call-seq:
- * meth[args, ...] -> obj
- *
- * Invokes the <i>meth</i> with the specified arguments, returning the
- * method's return value, like #call.
- *
- * m = 12.method("+")
- * m[3] #=> 15
- * m[20] #=> 32
- */
+ TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig);
+ clone = TypedData_Make_Struct(rb_obj_class(self), struct METHOD, &method_data_type, data);
+ rb_obj_dup_setup(self, clone);
+ RB_OBJ_WRITE(clone, &data->recv, orig->recv);
+ RB_OBJ_WRITE(clone, &data->klass, orig->klass);
+ RB_OBJ_WRITE(clone, &data->iclass, orig->iclass);
+ RB_OBJ_WRITE(clone, &data->owner, orig->owner);
+ RB_OBJ_WRITE(clone, &data->me, rb_method_entry_clone(orig->me));
+ return clone;
+}
/*
* call-seq:
- * meth.call(args, ...) -> obj
+ * call(...) -> obj
+ * self[...] -> obj
+ * self === obj -> result_of_method
*
- * Invokes the <i>meth</i> with the specified arguments, returning the
+ * Invokes +self+ with the specified arguments, returning the
* method's return value.
*
* m = 12.method("+")
* m.call(3) #=> 15
* m.call(20) #=> 32
+ *
+ * Using Method#=== allows a method object to be the target of a +when+ clause
+ * in a case statement.
+ *
+ * require 'prime'
+ *
+ * case 1373
+ * when Prime.method(:prime?)
+ * # ...
+ * end
*/
static VALUE
@@ -2507,7 +2744,7 @@ rb_method_call_with_block(int argc, const VALUE *argv, VALUE method, VALUE passe
*
* Document-class: UnboundMethod
*
- * Ruby supports two forms of objectified methods. Class Method is
+ * Ruby supports two forms of objectified methods. Class +Method+ 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 Object#method.
@@ -2570,7 +2807,7 @@ convert_umethod_to_method_components(const struct METHOD *data, VALUE recv, VALU
if (!NIL_P(refined_class)) methclass = refined_class;
}
if (!RB_TYPE_P(methclass, T_MODULE) && !RTEST(rb_obj_is_kind_of(recv, methclass))) {
- if (FL_TEST(methclass, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(methclass)) {
rb_raise(rb_eTypeError,
"singleton method called for a different object");
}
@@ -2849,7 +3086,11 @@ original_method_entry(VALUE mod, ID id)
while ((me = rb_method_entry(mod, id)) != 0) {
const rb_method_definition_t *def = me->def;
- if (def->type != VM_METHOD_TYPE_ZSUPER) break;
+
+ if (def->type != VM_METHOD_TYPE_ZSUPER &&
+ (def->type != VM_METHOD_TYPE_CFUNC ||
+ def->body.cfunc.func != (rb_cfunc_t)rb_zsuper_to_super)) break;
+
mod = RCLASS_SUPER(me->owner);
id = def->original_id;
}
@@ -2970,10 +3211,18 @@ rb_method_entry_location(const rb_method_entry_t *me)
/*
* call-seq:
- * meth.source_location -> [String, Integer]
+ * source_location -> location
+ *
+ * Returns a two-element array containing the Ruby source filename
+ * as a string and the line number integer where +self+ is defined:
+ *
+ * def greeting = "hello"
+ * method(:greeting).source_location # => ["test.rb", 1]
*
- * Returns the Ruby source filename and line number containing this method
- * or nil if this method was not defined in Ruby (i.e. native).
+ * Returns nil if +self+ is not a method defined in Ruby (i.e. defined
+ * using native code):
+ *
+ * Kernel.method(:puts).source_location # => nil
*/
VALUE
@@ -3070,6 +3319,18 @@ rb_method_parameters(VALUE method)
return method_def_parameters(rb_method_def(method));
}
+static inline VALUE
+append_param_name(VALUE str, VALUE name, const char *unnamed)
+{
+ if (!NIL_P(name)) {
+ rb_str_append(str, rb_sym2str(name));
+ }
+ else if (unnamed) {
+ rb_str_cat_cstr(str, unnamed);
+ }
+ return str;
+}
+
/*
* call-seq:
* meth.to_s -> string
@@ -3137,11 +3398,11 @@ method_inspect(VALUE method)
defined_class = RBASIC_CLASS(defined_class);
}
- if (data->recv == Qundef) {
+ if (UNDEF_P(data->recv)) {
// UnboundMethod
rb_str_buf_append(str, rb_inspect(defined_class));
}
- else if (FL_TEST(mklass, FL_SINGLETON)) {
+ else if (RCLASS_SINGLETON_P(mklass)) {
VALUE v = RCLASS_ATTACHED_OBJECT(mklass);
if (UNDEF_P(data->recv)) {
@@ -3161,7 +3422,7 @@ method_inspect(VALUE method)
}
else {
mklass = data->klass;
- if (FL_TEST(mklass, FL_SINGLETON)) {
+ if (RCLASS_SINGLETON_P(mklass)) {
VALUE v = RCLASS_ATTACHED_OBJECT(mklass);
if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) {
do {
@@ -3196,6 +3457,7 @@ method_inspect(VALUE method)
const VALUE keyrest = ID2SYM(rb_intern("keyrest"));
const VALUE block = ID2SYM(rb_intern("block"));
const VALUE nokey = ID2SYM(rb_intern("nokey"));
+ const VALUE noblock = ID2SYM(rb_intern("noblock"));
int forwarding = 0;
rb_str_buf_cat2(str, "(");
@@ -3213,47 +3475,34 @@ method_inspect(VALUE method)
for (int i = 0; i < RARRAY_LEN(params); i++) {
pair = RARRAY_AREF(params, i);
kind = RARRAY_AREF(pair, 0);
- name = RARRAY_AREF(pair, 1);
- // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?..
- if (NIL_P(name) || name == Qfalse) {
- // FIXME: can it be reduced to switch/case?
- if (kind == req || kind == opt) {
- name = rb_str_new2("_");
- }
- else if (kind == rest || kind == keyrest) {
- name = rb_str_new2("");
- }
- else if (kind == block) {
- name = rb_str_new2("block");
- }
- else if (kind == nokey) {
- name = rb_str_new2("nil");
- }
+ if (RARRAY_LEN(pair) > 1) {
+ name = RARRAY_AREF(pair, 1);
+ }
+ else {
+ name = Qnil;
}
if (kind == req) {
- rb_str_catf(str, "%"PRIsVALUE, name);
+ append_param_name(str, name, "_");
}
else if (kind == opt) {
- rb_str_catf(str, "%"PRIsVALUE"=...", name);
+ rb_str_cat_cstr(append_param_name(str, name, "_"), "=...");
}
else if (kind == keyreq) {
- rb_str_catf(str, "%"PRIsVALUE":", name);
+ rb_str_cat_cstr(append_param_name(str, name, NULL), ":");
}
else if (kind == key) {
- rb_str_catf(str, "%"PRIsVALUE": ...", name);
+ rb_str_cat_cstr(append_param_name(str, name, NULL), ": ...");
}
else if (kind == rest) {
- if (name == ID2SYM('*')) {
- rb_str_cat_cstr(str, forwarding ? "..." : "*");
- }
- else {
- rb_str_catf(str, "*%"PRIsVALUE, name);
+ rb_str_cat_cstr(str, forwarding ? "..." : "*");
+ if (name != ID2SYM('*')) {
+ append_param_name(str, name, NULL);
}
}
else if (kind == keyrest) {
if (name != ID2SYM(idPow)) {
- rb_str_catf(str, "**%"PRIsVALUE, name);
+ append_param_name(rb_str_cat_cstr(str, "**"), name, NULL);
}
else if (i > 0) {
rb_str_set_len(str, RSTRING_LEN(str) - 2);
@@ -3272,12 +3521,15 @@ method_inspect(VALUE method)
}
}
else {
- rb_str_catf(str, "&%"PRIsVALUE, name);
+ append_param_name(rb_str_cat_cstr(str, "&"), name, NULL);
}
}
else if (kind == nokey) {
rb_str_buf_cat2(str, "**nil");
}
+ else if (kind == noblock) {
+ rb_str_buf_cat2(str, "&nil");
+ }
if (i < RARRAY_LEN(params) - 1) {
rb_str_buf_cat2(str, ", ");
@@ -3343,12 +3595,14 @@ method_to_proc(VALUE method)
}
extern VALUE rb_find_defined_class_by_owner(VALUE current_class, VALUE target_owner);
+extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
+rb_cref_t * rb_vm_get_cref(const VALUE *ep);
/*
* call-seq:
* meth.super_method -> method
*
- * Returns a Method of superclass which would be called when super is used
+ * Returns a +Method+ of superclass which would be called when super is used
* or nil if there is no method on superclass.
*/
@@ -3369,11 +3623,76 @@ method_super_method(VALUE method)
mid = data->me->def->body.alias.original_me->def->original_id;
}
else {
- super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass));
+ VALUE klass = iclass;
+ if (RICLASS_FOR_REFINEMENT_P(klass)) {
+ // Refined methods need this check before superclass determination
+ klass = RBASIC(klass)->klass;
+ }
+ super_class = RCLASS_SUPER(RCLASS_ORIGIN(klass));
mid = data->me->def->original_id;
}
if (!super_class) return Qnil;
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass);
+
+ // For refined methods, skip refinements for the same definition, but consider
+ // refinements for superclass methods
+ const rb_method_definition_t *skip_def = RICLASS_FOR_REFINEMENT_P(iclass) ? data->me->def : NULL;
+
+ // Use the CREF of the Method/UnboundMethod, not the CREF of the caller of super_method.
+ // We must avoid the use of rb_callable_method_entry_with_refinements, as that will
+ // implicitly use the refinements activated in of the caller of super_method.
+ const rb_cref_t *cref = NULL;
+ switch (data->me->def->type) {
+ case VM_METHOD_TYPE_ISEQ:
+ cref = data->me->def->body.iseq.cref;
+ break;
+ case VM_METHOD_TYPE_BMETHOD: {
+ const rb_proc_t *proc;
+ GetProcPtr(data->me->def->body.bmethod.proc, proc);
+ const struct rb_block *block = &proc->block;
+ if (vm_block_type(block) == block_type_iseq)
+ cref = rb_vm_get_cref(block->as.captured.ep);
+ break;
+ }
+ default:
+ break;
+ }
+ VALUE klass = super_class;
+ me = NULL;
+ while (klass) {
+ const rb_callable_method_entry_t *cme = rb_callable_method_entry(klass, mid);
+ if (!cme) break;
+ if (cme->def->type != VM_METHOD_TYPE_REFINED) {
+ me = (rb_method_entry_t *)cme;
+ iclass = cme->defined_class;
+ break;
+ }
+ // Look through all CREF scopes for a refinement for cme->owner, mirroring
+ // the loop in search_refined_method.
+ const rb_cref_t *c;
+ for (c = cref; c; c = CREF_NEXT(c)) {
+ VALUE refs = CREF_REFINEMENTS(c);
+ if (NIL_P(refs)) continue;
+ VALUE r = rb_hash_lookup(refs, cme->owner);
+ if (NIL_P(r)) continue;
+ const rb_callable_method_entry_t *ref_cme = rb_callable_method_entry(r, mid);
+ if (!ref_cme) break;
+ if (ref_cme->def->type == VM_METHOD_TYPE_REFINED) continue;
+ if (skip_def && rb_method_definition_eq(ref_cme->def, skip_def)) continue;
+ me = (rb_method_entry_t *)ref_cme;
+ iclass = ref_cme->defined_class;
+ break;
+ }
+ if (me) break;
+ // No refined method found. Use orig_me if available, or normal method lookup
+ // in superclass otherwise.
+ const rb_method_entry_t *orig_me = cme->def->body.refined.orig_me;
+ if (orig_me) {
+ me = (rb_method_entry_t *)orig_me;
+ iclass = orig_me->defined_class ? orig_me->defined_class : cme->defined_class;
+ break;
+ }
+ klass = RCLASS_SUPER(cme->defined_class);
+ }
if (!me) return Qnil;
return mnew_internal(me, me->owner, iclass, data->recv, mid, rb_obj_class(method), FALSE, FALSE);
}
@@ -3421,9 +3740,15 @@ env_clone(const rb_env_t *env, const rb_cref_t *cref)
}
new_body = ALLOC_N(VALUE, env->env_size);
- MEMCPY(new_body, env->env, VALUE, env->env_size);
new_ep = &new_body[env->ep - env->env];
new_env = vm_env_new(new_ep, new_body, env->env_size, env->iseq);
+
+ /* The memcpy has to happen after the vm_env_new because it can trigger a
+ * GC compaction which can move the objects in the env. */
+ MEMCPY(new_body, env->env, VALUE, env->env_size);
+ /* VM_ENV_DATA_INDEX_ENV is set in vm_env_new but will get overwritten
+ * by the memcpy above. */
+ new_ep[VM_ENV_DATA_INDEX_ENV] = (VALUE)new_env;
RB_OBJ_WRITE(new_env, &new_ep[VM_ENV_DATA_INDEX_ME_CREF], (VALUE)cref);
VM_ASSERT(VM_ENV_ESCAPED_P(new_ep));
return new_env;
@@ -3480,7 +3805,7 @@ proc_binding(VALUE self)
env = VM_ENV_ENVVAL_PTR(block->as.captured.ep);
env = env_clone(env, method_cref(method));
/* set empty iseq */
- empty = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP);
+ empty = rb_iseq_new(Qnil, name, name, Qnil, 0, ISEQ_TYPE_TOP);
RB_OBJ_WRITE(env, &env->iseq, empty);
break;
}
@@ -3793,19 +4118,18 @@ rb_proc_compose_to_right(VALUE self, VALUE g)
/*
* call-seq:
- * meth << g -> a_proc
+ * self << g -> a_proc
*
- * Returns a proc that is the composition of this method and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls <i>g</i> with them
- * then calls this method with the result.
+ * Returns a proc that is the composition of the given +g+ and this method.
*
- * def f(x)
- * x * x
- * end
+ * The returned proc takes a variable number of arguments. It first calls +g+
+ * with the arguments, then calls +self+ with the return value of +g+.
+ *
+ * def f(ary) = ary << 'in f'
*
* f = self.method(:f)
- * g = proc {|x| x + x }
- * p (f << g).call(2) #=> 16
+ * g = proc { |ary| ary << 'in proc' }
+ * (f << g).call([]) # => ["in proc", "in f"]
*/
static VALUE
rb_method_compose_to_left(VALUE self, VALUE g)
@@ -3817,19 +4141,18 @@ rb_method_compose_to_left(VALUE self, VALUE g)
/*
* call-seq:
- * meth >> g -> a_proc
+ * self >> g -> a_proc
*
- * Returns a proc that is the composition of this method and the given <i>g</i>.
- * The returned proc takes a variable number of arguments, calls this method
- * with them then calls <i>g</i> with the result.
+ * Returns a proc that is the composition of this method and the given +g+.
*
- * def f(x)
- * x * x
- * end
+ * The returned proc takes a variable number of arguments. It first calls +self+
+ * with the arguments, then calls +g+ with the return value of +self+.
+ *
+ * def f(ary) = ary << 'in f'
*
* f = self.method(:f)
- * g = proc {|x| x + x }
- * p (f >> g).call(2) #=> 8
+ * g = proc { |ary| ary << 'in proc' }
+ * (f >> g).call([]) # => ["in f", "in proc"]
*/
static VALUE
rb_method_compose_to_right(VALUE self, VALUE g)
@@ -3887,12 +4210,13 @@ proc_ruby2_keywords(VALUE procval)
switch (proc->block.type) {
case block_type_iseq:
if (ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_rest &&
+ !ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_post &&
!ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_kw &&
!ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_kwrest) {
ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.ruby2_keywords = 1;
}
else {
- rb_warn("Skipping set of ruby2_keywords flag for proc (proc accepts keywords or proc does not accept argument splat)");
+ rb_warn("Skipping set of ruby2_keywords flag for proc (proc accepts keywords or post arguments or proc does not accept argument splat)");
}
break;
default:
@@ -4136,7 +4460,6 @@ proc_ruby2_keywords(VALUE procval)
* a proc by the <code>&</code> operator, and therefore can be
* consumed by iterators.
*
-
* class Greeter
* def initialize(greeting)
* @greeting = greeting
@@ -4152,8 +4475,8 @@ proc_ruby2_keywords(VALUE procval)
* ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"]
* ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"]
*
- * Of the Ruby core classes, this method is implemented by Symbol,
- * Method, and Hash.
+ * Of the Ruby core classes, this method is implemented by +Symbol+,
+ * +Method+, and +Hash+.
*
* :to_s.to_proc.call(1) #=> "1"
* [1, 2].map(&:to_s) #=> ["1", "2"]
@@ -4187,19 +4510,86 @@ proc_ruby2_keywords(VALUE procval)
* Since +return+ and +break+ exits the block itself in lambdas,
* lambdas cannot be orphaned.
*
- * == Numbered parameters
+ * == Anonymous block parameters
*
- * Numbered parameters are implicitly defined block parameters intended to
- * simplify writing short blocks:
+ * To simplify writing short blocks, Ruby provides two different types of
+ * anonymous parameters: +it+ (single parameter) and numbered ones: <tt>_1</tt>,
+ * <tt>_2</tt> and so on.
*
* # Explicit parameter:
* %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE
* (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25]
*
- * # Implicit parameter:
+ * # it:
+ * %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE
+ * (1..5).map { it**2 } # => [1, 4, 9, 16, 25]
+ *
+ * # Numbered parameter:
* %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE
* (1..5).map { _1**2 } # => [1, 4, 9, 16, 25]
*
+ * === +it+
+ *
+ * +it+ is a name that is available inside a block when no explicit parameters
+ * defined, as shown above.
+ *
+ * %w[test me please].each { puts it.upcase } # prints TEST, ME, PLEASE
+ * (1..5).map { it**2 } # => [1, 4, 9, 16, 25]
+ *
+ * +it+ is a "soft keyword": it is not a reserved name, and can be used as
+ * a name for methods and local variables:
+ *
+ * it = 5 # no warnings
+ * def it(&block) # RSpec-like API, no warnings
+ * # ...
+ * end
+ *
+ * +it+ can be used as a local variable even in blocks that use it as an
+ * implicit parameter (though this style is obviously confusing):
+ *
+ * [1, 2, 3].each {
+ * # takes a value of implicit parameter "it" and uses it to
+ * # define a local variable with the same name
+ * it = it**2
+ * p it
+ * }
+ *
+ * In a block with explicit parameters defined +it+ usage raises an exception:
+ *
+ * [1, 2, 3].each { |x| p it }
+ * # syntax error found (SyntaxError)
+ * # [1, 2, 3].each { |x| p it }
+ * # ^~ 'it' is not allowed when an ordinary parameter is defined
+ *
+ * But if a local name (variable or method) is available, it would be used:
+ *
+ * it = 5
+ * [1, 2, 3].each { |x| p it }
+ * # Prints 5, 5, 5
+ *
+ * Blocks using +it+ can be nested:
+ *
+ * %w[test me].each { it.each_char { p it } }
+ * # Prints "t", "e", "s", "t", "m", "e"
+ *
+ * Blocks using +it+ are considered to have one parameter:
+ *
+ * p = proc { it**2 }
+ * l = lambda { it**2 }
+ * p.parameters # => [[:opt]]
+ * p.arity # => 1
+ * l.parameters # => [[:req]]
+ * l.arity # => 1
+ *
+ * === Numbered parameters
+ *
+ * Numbered parameters are another way to name block parameters implicitly.
+ * Unlike +it+, numbered parameters allow to refer to several parameters
+ * in one block.
+ *
+ * %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE
+ * {a: 100, b: 200}.map { "#{_1} = #{_2}" } # => "a = 100", "b = 200"
+ *
* Parameter names from +_1+ to +_9+ are supported:
*
* [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 }
@@ -4214,11 +4604,16 @@ proc_ruby2_keywords(VALUE procval)
* [10, 20, 30].map { |x| _1**2 }
* # SyntaxError (ordinary parameter is defined)
*
+ * Numbered parameters can't be mixed with +it+ either:
+ *
+ * [10, 20, 30].map { _1 + it }
+ * # SyntaxError: 'it' is not allowed when a numbered parameter is already used
+ *
* To avoid conflicts, naming local variables or method
- * arguments +_1+, +_2+ and so on, causes a warning.
+ * arguments +_1+, +_2+ and so on, causes an error.
*
- * _1 = 'test'
- * # warning: `_1' is reserved as numbered parameter
+ * _1 = 'test'
+ * # ^~ _1 is reserved for numbered parameters (SyntaxError)
*
* Using implicit numbered parameters affects block's arity:
*
@@ -4232,14 +4627,12 @@ proc_ruby2_keywords(VALUE procval)
* Blocks with numbered parameters can't be nested:
*
* %w[test me].each { _1.each_char { p _1 } }
- * # SyntaxError (numbered parameter is already used in outer block here)
+ * # numbered parameter is already used in outer block (SyntaxError)
* # %w[test me].each { _1.each_char { p _1 } }
* # ^~
*
- * Numbered parameters were introduced in Ruby 2.7.
*/
-
void
Init_Proc(void)
{
@@ -4264,7 +4657,7 @@ Init_Proc(void)
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", rb_proc_dup, 0);
+ rb_define_method(rb_cProc, "dup", proc_dup, 0);
rb_define_method(rb_cProc, "hash", proc_hash, 0);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_alias(rb_cProc, "inspect", "to_s");
@@ -4300,6 +4693,7 @@ Init_Proc(void)
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, "dup", method_dup, 0);
rb_define_method(rb_cMethod, "call", rb_method_call_pass_called_kw, -1);
rb_define_method(rb_cMethod, "===", rb_method_call_pass_called_kw, -1);
rb_define_method(rb_cMethod, "curry", rb_method_curry, -1);
@@ -4322,6 +4716,8 @@ Init_Proc(void)
rb_define_method(rb_mKernel, "public_method", rb_obj_public_method, 1);
rb_define_method(rb_mKernel, "singleton_method", rb_obj_singleton_method, 1);
+ rb_define_method(rb_cMethod, "box", method_box, 0);
+
/* UnboundMethod */
rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
rb_undef_alloc_func(rb_cUnboundMethod);
@@ -4330,6 +4726,7 @@ Init_Proc(void)
rb_define_method(rb_cUnboundMethod, "eql?", unbound_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, "dup", method_dup, 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);
@@ -4392,6 +4789,8 @@ Init_Proc(void)
void
Init_Binding(void)
{
+ rb_gc_register_address(&sym_proc_cache);
+
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
@@ -4402,6 +4801,9 @@ Init_Binding(void)
rb_define_method(rb_cBinding, "local_variable_get", bind_local_variable_get, 1);
rb_define_method(rb_cBinding, "local_variable_set", bind_local_variable_set, 2);
rb_define_method(rb_cBinding, "local_variable_defined?", bind_local_variable_defined_p, 1);
+ rb_define_method(rb_cBinding, "implicit_parameters", bind_implicit_parameters, 0);
+ rb_define_method(rb_cBinding, "implicit_parameter_get", bind_implicit_parameter_get, 1);
+ rb_define_method(rb_cBinding, "implicit_parameter_defined?", bind_implicit_parameter_defined_p, 1);
rb_define_method(rb_cBinding, "receiver", bind_receiver, 0);
rb_define_method(rb_cBinding, "source_location", bind_location, 0);
rb_define_global_function("binding", rb_f_binding, 0);
diff --git a/process.c b/process.c
index ca09357d17..e443ccbe49 100644
--- a/process.c
+++ b/process.c
@@ -103,18 +103,20 @@ int initgroups(const char *, rb_gid_t);
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/hash.h"
+#include "internal/io.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/process.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "internal/warnings.h"
-#include "rjit.h"
#include "ruby/io.h"
#include "ruby/st.h"
#include "ruby/thread.h"
#include "ruby/util.h"
+#include "ractor_core.h"
#include "vm_core.h"
+#include "vm_sync.h"
#include "ruby/ractor.h"
/* define system APIs */
@@ -359,6 +361,8 @@ static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;
#endif
static ID id_hertz;
+static rb_pid_t cached_pid;
+
/* execv and execl are async-signal-safe since SUSv4 (POSIX.1-2008, XPG7) */
#if defined(__sun) && !defined(_XPG7) /* Solaris 10, 9, ... */
#define execv(path, argv) (rb_async_bug_errno("unreachable: async-signal-unsafe execv() is called", 0))
@@ -497,17 +501,29 @@ parent_redirect_close(int fd)
static VALUE
get_pid(void)
{
- return PIDT2NUM(getpid());
+ if (UNLIKELY(!cached_pid)) { /* 0 is not a valid pid */
+ cached_pid = getpid();
+ }
+ /* pid should be likely POSFIXABLE() */
+ return PIDT2NUM(cached_pid);
+}
+
+#if defined HAVE_WORKING_FORK || defined HAVE_DAEMON
+static void
+clear_pid_cache(void)
+{
+ cached_pid = 0;
}
+#endif
/*
* call-seq:
- * Process.pid -> integer
+ * Process.pid -> integer
*
- * Returns the process id of this process. Not available on all
- * platforms.
+ * Returns the process ID of the current process:
+ *
+ * Process.pid # => 15668
*
- * Process.pid #=> 27415
*/
static VALUE
@@ -524,18 +540,19 @@ get_ppid(void)
/*
* call-seq:
- * Process.ppid -> integer
+ * Process.ppid -> integer
+ *
+ * Returns the process ID of the parent of the current process:
*
- * Returns the process id of the parent of this process. Returns
- * untrustworthy value on Win32/64. Not available on all platforms.
+ * puts "Pid is #{Process.pid}."
+ * fork { puts "Parent pid is #{Process.ppid}." }
*
- * puts "I am #{Process.pid}"
- * Process.fork { puts "Dad is #{Process.ppid}" }
+ * Output:
*
- * <em>produces:</em>
+ * Pid is 271290.
+ * Parent pid is 271290.
*
- * I am 27417
- * Dad is 27417
+ * May not return a trustworthy value on certain platforms.
*/
static VALUE
@@ -549,30 +566,20 @@ proc_get_ppid(VALUE _)
*
* Document-class: Process::Status
*
- * Process::Status encapsulates the information on the
- * status of a running or terminated system process. The built-in
- * variable <code>$?</code> is either +nil+ or a
- * Process::Status object.
- *
- * fork { exit 99 } #=> 26557
- * Process.wait #=> 26557
- * $?.class #=> Process::Status
- * $?.to_i #=> 25344
- * $? >> 8 #=> 99
- * $?.stopped? #=> false
- * $?.exited? #=> true
- * $?.exitstatus #=> 99
- *
- * Posix systems record information on processes using a 16-bit
- * integer. The lower bits record the process status (stopped,
- * exited, signaled) and the upper bits possibly contain additional
- * information (for example the program's return code in the case of
- * exited processes). Pre Ruby 1.8, these bits were exposed directly
- * to the Ruby program. Ruby now encapsulates these in a
- * Process::Status object. To maximize compatibility,
- * however, these objects retain a bit-oriented interface. In the
- * descriptions that follow, when we talk about the integer value of
- * _stat_, we're referring to this 16 bit value.
+ * A Process::Status contains information about a system process.
+ *
+ * Thread-local variable <tt>$?</tt> is initially +nil+.
+ * Some methods assign to it a Process::Status object
+ * that represents a system process (either running or terminated):
+ *
+ * `ruby -e "exit 99"`
+ * stat = $? # => #<Process::Status: pid 1262862 exit 99>
+ * stat.class # => Process::Status
+ * stat.to_i # => 25344
+ * stat.stopped? # => false
+ * stat.exited? # => true
+ * stat.exitstatus # => 99
+ *
*/
static VALUE rb_cProcessStatus;
@@ -586,17 +593,17 @@ struct rb_process_status {
static const rb_data_type_t rb_process_status_type = {
.wrap_struct_name = "Process::Status",
.function = {
+ .dmark = NULL,
.dfree = RUBY_DEFAULT_FREE,
+ .dsize = NULL,
},
- .data = NULL,
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
};
static VALUE
rb_process_status_allocate(VALUE klass)
{
- struct rb_process_status *data = NULL;
-
+ struct rb_process_status *data;
return TypedData_Make_Struct(klass, struct rb_process_status, &rb_process_status_type, data);
}
@@ -608,18 +615,25 @@ rb_last_status_get(void)
/*
* call-seq:
- * Process.last_status -> Process::Status or nil
+ * Process.last_status -> Process::Status or nil
*
- * Returns the status of the last executed child process in the
- * current thread.
+ * Returns a Process::Status object representing the most recently exited
+ * child process in the current thread, or +nil+ if none:
*
- * Process.wait Process.spawn("ruby", "-e", "exit 13")
- * Process.last_status #=> #<Process::Status: pid 4825 exit 13>
+ * Process.spawn('ruby', '-e', 'exit 13')
+ * Process.wait
+ * Process.last_status # => #<Process::Status: pid 14396 exit 13>
*
- * If no child process has ever been executed in the current
- * thread, this returns +nil+.
+ * Process.spawn('ruby', '-e', 'exit 14')
+ * Process.wait
+ * Process.last_status # => #<Process::Status: pid 4692 exit 14>
+ *
+ * Process.spawn('ruby', '-e', 'exit 15')
+ * # 'exit 15' has not been reaped by #wait.
+ * Process.last_status # => #<Process::Status: pid 4692 exit 14>
+ * Process.wait
+ * Process.last_status # => #<Process::Status: pid 1380 exit 15>
*
- * Process.last_status #=> nil
*/
static VALUE
proc_s_last_status(VALUE mod)
@@ -631,8 +645,7 @@ VALUE
rb_process_status_new(rb_pid_t pid, int status, int error)
{
VALUE last_status = rb_process_status_allocate(rb_cProcessStatus);
-
- struct rb_process_status *data = RTYPEDDATA_DATA(last_status);
+ struct rb_process_status *data = RTYPEDDATA_GET_DATA(last_status);
data->pid = pid;
data->status = status;
data->error = error;
@@ -645,7 +658,8 @@ static VALUE
process_status_dump(VALUE status)
{
VALUE dump = rb_class_new_instance(0, 0, rb_cObject);
- struct rb_process_status *data = RTYPEDDATA_DATA(status);
+ struct rb_process_status *data;
+ TypedData_Get_Struct(status, struct rb_process_status, &rb_process_status_type, data);
if (data->pid) {
rb_ivar_set(dump, id_status, INT2NUM(data->status));
rb_ivar_set(dump, id_pid, PIDT2NUM(data->pid));
@@ -670,36 +684,42 @@ rb_last_status_set(int status, rb_pid_t pid)
GET_THREAD()->last_status = rb_process_status_new(pid, status, 0);
}
+static void
+last_status_clear(rb_thread_t *th)
+{
+ th->last_status = Qnil;
+}
+
void
rb_last_status_clear(void)
{
- GET_THREAD()->last_status = Qnil;
+ last_status_clear(GET_THREAD());
}
static rb_pid_t
-pst_pid(VALUE pst)
+pst_pid(VALUE status)
{
- struct rb_process_status *data = RTYPEDDATA_DATA(pst);
+ struct rb_process_status *data;
+ TypedData_Get_Struct(status, struct rb_process_status, &rb_process_status_type, data);
return data->pid;
}
static int
-pst_status(VALUE pst)
+pst_status(VALUE status)
{
- struct rb_process_status *data = RTYPEDDATA_DATA(pst);
+ struct rb_process_status *data;
+ TypedData_Get_Struct(status, struct rb_process_status, &rb_process_status_type, data);
return data->status;
}
/*
* call-seq:
- * stat.to_i -> integer
+ * to_i -> integer
*
- * Returns the bits in _stat_ as an Integer. Poking
- * around in these bits is platform dependent.
+ * Returns the system-dependent integer status of +self+:
*
- * fork { exit 0xab } #=> 26566
- * Process.wait #=> 26566
- * sprintf('%04x', $?.to_i) #=> "ab00"
+ * `cat /nop`
+ * $?.to_i # => 256
*/
static VALUE
@@ -713,13 +733,13 @@ pst_to_i(VALUE self)
/*
* call-seq:
- * stat.pid -> integer
+ * pid -> integer
*
- * Returns the process ID that this status object represents.
+ * Returns the process ID of the process:
+ *
+ * system("false")
+ * $?.pid # => 1247002
*
- * fork { exit } #=> 26569
- * Process.wait #=> 26569
- * $?.pid #=> 26569
*/
static VALUE
@@ -775,12 +795,13 @@ pst_message_status(VALUE str, int status)
/*
* call-seq:
- * stat.to_s -> string
+ * to_s -> string
*
- * Show pid and exit status as a string.
+ * Returns a string representation of +self+:
+ *
+ * `cat /nop`
+ * $?.to_s # => "pid 1262141 exit 1"
*
- * system("false")
- * p $?.to_s #=> "pid 12766 exit 1"
*
*/
@@ -802,12 +823,12 @@ pst_to_s(VALUE st)
/*
* call-seq:
- * stat.inspect -> string
+ * inspect -> string
*
- * Override the inspection method.
+ * Returns a string representation of +self+:
*
* system("false")
- * p $?.inspect #=> "#<Process::Status: pid 12861 exit 1>"
+ * $?.inspect # => "#<Process::Status: pid 1303494 exit 1>"
*
*/
@@ -833,10 +854,15 @@ pst_inspect(VALUE st)
/*
* call-seq:
- * stat == other -> true or false
+ * stat == other -> true or false
+ *
+ * Returns whether the value of #to_i == +other+:
+ *
+ * `cat /nop`
+ * stat = $? # => #<Process::Status: pid 1170366 exit 1>
+ * sprintf('%x', stat.to_i) # => "100"
+ * stat == 0x100 # => true
*
- * Returns +true+ if the integer value of _stat_
- * equals <em>other</em>.
*/
static VALUE
@@ -849,53 +875,11 @@ pst_equal(VALUE st1, VALUE st2)
/*
* call-seq:
- * stat & num -> integer
- *
- * Logical AND of the bits in _stat_ with <em>num</em>.
- *
- * fork { exit 0x37 }
- * Process.wait
- * sprintf('%04x', $?.to_i) #=> "3700"
- * sprintf('%04x', $? & 0x1e00) #=> "1600"
- */
-
-static VALUE
-pst_bitand(VALUE st1, VALUE st2)
-{
- int status = PST2INT(st1) & NUM2INT(st2);
-
- return INT2NUM(status);
-}
-
-
-/*
- * call-seq:
- * stat >> num -> integer
- *
- * Shift the bits in _stat_ right <em>num</em> places.
- *
- * fork { exit 99 } #=> 26563
- * Process.wait #=> 26563
- * $?.to_i #=> 25344
- * $? >> 8 #=> 99
- */
-
-static VALUE
-pst_rshift(VALUE st1, VALUE st2)
-{
- int status = PST2INT(st1) >> NUM2INT(st2);
-
- return INT2NUM(status);
-}
-
-
-/*
- * call-seq:
- * stat.stopped? -> true or false
+ * stopped? -> true or false
*
- * Returns +true+ if this process is stopped. This is only returned
- * if the corresponding #wait call had the Process::WUNTRACED flag
- * set.
+ * Returns +true+ if this process is stopped,
+ * and if the corresponding #wait call had the Process::WUNTRACED flag set,
+ * +false+ otherwise.
*/
static VALUE
@@ -909,10 +893,10 @@ pst_wifstopped(VALUE st)
/*
* call-seq:
- * stat.stopsig -> integer or nil
+ * stopsig -> integer or nil
*
- * Returns the number of the signal that caused _stat_ to stop
- * (or +nil+ if self is not stopped).
+ * Returns the number of the signal that caused the process to stop,
+ * or +nil+ if the process is not stopped.
*/
static VALUE
@@ -928,10 +912,10 @@ pst_wstopsig(VALUE st)
/*
* call-seq:
- * stat.signaled? -> true or false
+ * signaled? -> true or false
*
- * Returns +true+ if _stat_ terminated because of
- * an uncaught signal.
+ * Returns +true+ if the process terminated because of an uncaught signal,
+ * +false+ otherwise.
*/
static VALUE
@@ -945,11 +929,10 @@ pst_wifsignaled(VALUE st)
/*
* call-seq:
- * stat.termsig -> integer or nil
+ * termsig -> integer or nil
*
- * Returns the number of the signal that caused _stat_ to
- * terminate (or +nil+ if self was not terminated by an
- * uncaught signal).
+ * Returns the number of the signal that caused the process to terminate
+ * or +nil+ if the process was not terminated by an uncaught signal.
*/
static VALUE
@@ -965,11 +948,11 @@ pst_wtermsig(VALUE st)
/*
* call-seq:
- * stat.exited? -> true or false
+ * exited? -> true or false
*
- * Returns +true+ if _stat_ exited normally (for
- * example using an <code>exit()</code> call or finishing the
- * program).
+ * Returns +true+ if the process exited normally
+ * (for example using an <code>exit()</code> call or finishing the
+ * program), +false+ if not.
*/
static VALUE
@@ -983,20 +966,15 @@ pst_wifexited(VALUE st)
/*
* call-seq:
- * stat.exitstatus -> integer or nil
+ * exitstatus -> integer or nil
*
- * Returns the least significant eight bits of the return code of
- * _stat_. Only available if #exited? is +true+.
+ * Returns the least significant eight bits of the return code
+ * of the process if it has exited;
+ * +nil+ otherwise:
*
- * fork { } #=> 26572
- * Process.wait #=> 26572
- * $?.exited? #=> true
- * $?.exitstatus #=> 0
+ * `exit 99`
+ * $?.exitstatus # => 99
*
- * fork { exit 99 } #=> 26573
- * Process.wait #=> 26573
- * $?.exited? #=> true
- * $?.exitstatus #=> 99
*/
static VALUE
@@ -1012,10 +990,14 @@ pst_wexitstatus(VALUE st)
/*
* call-seq:
- * stat.success? -> true, false or nil
+ * success? -> true, false, or nil
+ *
+ * Returns:
+ *
+ * - +true+ if the process has completed successfully and exited.
+ * - +false+ if the process has completed unsuccessfully and exited.
+ * - +nil+ if the process has not exited.
*
- * Returns +true+ if _stat_ is successful, +false+ if not.
- * Returns +nil+ if #exited? is not +true+.
*/
static VALUE
@@ -1031,10 +1013,12 @@ pst_success_p(VALUE st)
/*
* call-seq:
- * stat.coredump? -> true or false
+ * coredump? -> true or false
*
- * Returns +true+ if _stat_ generated a coredump
- * when it terminated. Not available on all platforms.
+ * Returns +true+ if the process generated a coredump
+ * when it terminated, +false+ if not.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -1113,8 +1097,10 @@ rb_process_status_wait(rb_pid_t pid, int flags)
// We only enter the scheduler if we are "blocking":
if (!(flags & WNOHANG)) {
VALUE scheduler = rb_fiber_scheduler_current();
- VALUE result = rb_fiber_scheduler_process_wait(scheduler, pid, flags);
- if (!UNDEF_P(result)) return result;
+ if (scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_process_wait(scheduler, pid, flags);
+ if (!UNDEF_P(result)) return result;
+ }
}
struct waitpid_state waitpid_state;
@@ -1131,49 +1117,35 @@ rb_process_status_wait(rb_pid_t pid, int flags)
/*
* call-seq:
- * Process::Status.wait(pid=-1, flags=0) -> Process::Status
+ * Process::Status.wait(pid = -1, flags = 0) -> Process::Status
*
- * Waits for a child process to exit and returns a Process::Status object
- * containing information on that process. Which child it waits on
- * depends on the value of _pid_:
+ * Like Process.wait, but returns a Process::Status object
+ * (instead of an integer pid or nil);
+ * see Process.wait for the values of +pid+ and +flags+.
*
- * > 0:: Waits for the child whose process ID equals _pid_.
+ * If there are child processes,
+ * waits for a child process to exit and returns a Process::Status object
+ * containing information on that process;
+ * sets thread-local variable <tt>$?</tt>:
*
- * 0:: Waits for any child whose process group ID equals that of the
- * calling process.
+ * Process.spawn('cat /nop') # => 1155880
+ * Process::Status.wait # => #<Process::Status: pid 1155880 exit 1>
+ * $? # => #<Process::Status: pid 1155508 exit 1>
*
- * -1:: Waits for any child process (the default if no _pid_ is
- * given).
+ * If there is no child process,
+ * returns an "empty" Process::Status object
+ * that does not represent an actual process;
+ * does not set thread-local variable <tt>$?</tt>:
*
- * < -1:: Waits for any child whose process group ID equals the absolute
- * value of _pid_.
+ * Process::Status.wait # => #<Process::Status: pid -1 exit 0>
+ * $? # => #<Process::Status: pid 1155508 exit 1> # Unchanged.
*
- * The _flags_ argument may be a logical or of the flag values
- * Process::WNOHANG (do not block if no child available)
- * or Process::WUNTRACED (return stopped children that
- * haven't been reported). Not all flags are available on all
- * platforms, but a flag value of zero will work on all platforms.
+ * May invoke the scheduler hook Fiber::Scheduler#process_wait.
*
- * Returns +nil+ if there are no child processes.
* Not available on all platforms.
- *
- * May invoke the scheduler hook _process_wait_.
- *
- * fork { exit 99 } #=> 27429
- * Process::Status.wait #=> pid 27429 exit 99
- * $? #=> nil
- *
- * pid = fork { sleep 3 } #=> 27440
- * Time.now #=> 2008-03-08 19:56:16 +0900
- * Process::Status.wait(pid, Process::WNOHANG) #=> nil
- * Time.now #=> 2008-03-08 19:56:16 +0900
- * Process::Status.wait(pid, 0) #=> pid 27440 exit 99
- * Time.now #=> 2008-03-08 19:56:19 +0900
- *
- * This is an EXPERIMENTAL FEATURE.
*/
-VALUE
+static VALUE
rb_process_status_waitv(int argc, VALUE *argv, VALUE _)
{
rb_check_arity(argc, 0, 2);
@@ -1198,7 +1170,7 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
VALUE status = rb_process_status_wait(pid, flags);
if (NIL_P(status)) return 0;
- struct rb_process_status *data = RTYPEDDATA_DATA(status);
+ struct rb_process_status *data = rb_check_typeddata(status, &rb_process_status_type);
pid = data->pid;
if (st) *st = data->status;
@@ -1258,69 +1230,155 @@ proc_wait(int argc, VALUE *argv)
/*
* call-seq:
- * Process.wait() -> integer
- * Process.wait(pid=-1, flags=0) -> integer
- * Process.waitpid(pid=-1, flags=0) -> integer
- *
- * Waits for a child process to exit, returns its process id, and
- * sets <code>$?</code> to a Process::Status object
- * containing information on that process. Which child it waits on
- * depends on the value of _pid_:
- *
- * > 0:: Waits for the child whose process ID equals _pid_.
- *
- * 0:: Waits for any child whose process group ID equals that of the
- * calling process.
- *
- * -1:: Waits for any child process (the default if no _pid_ is
- * given).
- *
- * < -1:: Waits for any child whose process group ID equals the absolute
- * value of _pid_.
- *
- * The _flags_ argument may be a logical or of the flag values
- * Process::WNOHANG (do not block if no child available)
- * or Process::WUNTRACED (return stopped children that
- * haven't been reported). Not all flags are available on all
- * platforms, but a flag value of zero will work on all platforms.
- *
- * Calling this method raises a SystemCallError if there are no child
- * processes. Not available on all platforms.
- *
- * include Process
- * fork { exit 99 } #=> 27429
- * wait #=> 27429
- * $?.exitstatus #=> 99
- *
- * pid = fork { sleep 3 } #=> 27440
- * Time.now #=> 2008-03-08 19:56:16 +0900
- * waitpid(pid, Process::WNOHANG) #=> nil
- * Time.now #=> 2008-03-08 19:56:16 +0900
- * waitpid(pid, 0) #=> 27440
- * Time.now #=> 2008-03-08 19:56:19 +0900
+ * Process.wait(pid = -1, flags = 0) -> integer
+ *
+ * Waits for a suitable child process to exit, returns its process ID,
+ * and sets <tt>$?</tt> to a Process::Status object
+ * containing information on that process.
+ * Which child it waits for depends on the value of the given +pid+:
+ *
+ * - Positive integer: Waits for the child process whose process ID is +pid+:
+ *
+ * pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 230866
+ * pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 230891
+ * Process.wait(pid0) # => 230866
+ * $? # => #<Process::Status: pid 230866 exit 13>
+ * Process.wait(pid1) # => 230891
+ * $? # => #<Process::Status: pid 230891 exit 14>
+ * Process.wait(pid0) # Raises Errno::ECHILD
+ *
+ * - <tt>0</tt>: Waits for any child process whose group ID
+ * is the same as that of the current process:
+ *
+ * parent_pgpid = Process.getpgid(Process.pid)
+ * puts "Parent process group ID is #{parent_pgpid}."
+ * child0_pid = fork do
+ * puts "Child 0 pid is #{Process.pid}"
+ * child0_pgid = Process.getpgid(Process.pid)
+ * puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
+ * end
+ * child1_pid = fork do
+ * puts "Child 1 pid is #{Process.pid}"
+ * Process.setpgid(0, Process.pid)
+ * child1_pgid = Process.getpgid(Process.pid)
+ * puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
+ * end
+ * retrieved_pid = Process.wait(0)
+ * puts "Process.wait(0) returned pid #{retrieved_pid}, which is child 0 pid."
+ * begin
+ * Process.wait(0)
+ * rescue Errno::ECHILD => x
+ * puts "Raised #{x.class}, because child 1 process group ID differs from parent process group ID."
+ * end
+ *
+ * Output:
+ *
+ * Parent process group ID is 225764.
+ * Child 0 pid is 225788
+ * Child 0 process group ID is 225764 (same as parent's).
+ * Child 1 pid is 225789
+ * Child 1 process group ID is 225789 (different from parent's).
+ * Process.wait(0) returned pid 225788, which is child 0 pid.
+ * Raised Errno::ECHILD, because child 1 process group ID differs from parent process group ID.
+ *
+ * - <tt>-1</tt> (default): Waits for any child process:
+ *
+ * parent_pgpid = Process.getpgid(Process.pid)
+ * puts "Parent process group ID is #{parent_pgpid}."
+ * child0_pid = fork do
+ * puts "Child 0 pid is #{Process.pid}"
+ * child0_pgid = Process.getpgid(Process.pid)
+ * puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
+ * end
+ * child1_pid = fork do
+ * puts "Child 1 pid is #{Process.pid}"
+ * Process.setpgid(0, Process.pid)
+ * child1_pgid = Process.getpgid(Process.pid)
+ * puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
+ * sleep 3 # To force child 1 to exit later than child 0 exit.
+ * end
+ * child_pids = [child0_pid, child1_pid]
+ * retrieved_pid = Process.wait(-1)
+ * puts child_pids.include?(retrieved_pid)
+ * retrieved_pid = Process.wait(-1)
+ * puts child_pids.include?(retrieved_pid)
+ *
+ * Output:
+ *
+ * Parent process group ID is 228736.
+ * Child 0 pid is 228758
+ * Child 0 process group ID is 228736 (same as parent's).
+ * Child 1 pid is 228759
+ * Child 1 process group ID is 228759 (different from parent's).
+ * true
+ * true
+ *
+ * - Less than <tt>-1</tt>: Waits for any child whose process group ID is <tt>-pid</tt>:
+ *
+ * parent_pgpid = Process.getpgid(Process.pid)
+ * puts "Parent process group ID is #{parent_pgpid}."
+ * child0_pid = fork do
+ * puts "Child 0 pid is #{Process.pid}"
+ * child0_pgid = Process.getpgid(Process.pid)
+ * puts "Child 0 process group ID is #{child0_pgid} (same as parent's)."
+ * end
+ * child1_pid = fork do
+ * puts "Child 1 pid is #{Process.pid}"
+ * Process.setpgid(0, Process.pid)
+ * child1_pgid = Process.getpgid(Process.pid)
+ * puts "Child 1 process group ID is #{child1_pgid} (different from parent's)."
+ * end
+ * sleep 1
+ * retrieved_pid = Process.wait(-child1_pid)
+ * puts "Process.wait(-child1_pid) returned pid #{retrieved_pid}, which is child 1 pid."
+ * begin
+ * Process.wait(-child1_pid)
+ * rescue Errno::ECHILD => x
+ * puts "Raised #{x.class}, because there's no longer a child with process group id #{child1_pid}."
+ * end
+ *
+ * Output:
+ *
+ * Parent process group ID is 230083.
+ * Child 0 pid is 230108
+ * Child 0 process group ID is 230083 (same as parent's).
+ * Child 1 pid is 230109
+ * Child 1 process group ID is 230109 (different from parent's).
+ * Process.wait(-child1_pid) returned pid 230109, which is child 1 pid.
+ * Raised Errno::ECHILD, because there's no longer a child with process group id 230109.
+ *
+ * Argument +flags+ should be given as one of the following constants,
+ * or as the logical OR of both:
+ *
+ * - Process::WNOHANG: Does not block if no child process is available.
+ * - Process::WUNTRACED: May return a stopped child process, even if not yet reported.
+ *
+ * Not all flags are available on all platforms.
+ *
+ * Raises Errno::ECHILD if there is no suitable child process.
+ *
+ * Not available on all platforms.
+ *
+ * Process.waitpid is an alias for Process.wait.
*/
-
static VALUE
proc_m_wait(int c, VALUE *v, VALUE _)
{
return proc_wait(c, v);
}
-
/*
* call-seq:
- * Process.wait2(pid=-1, flags=0) -> [pid, status]
- * Process.waitpid2(pid=-1, flags=0) -> [pid, status]
- *
- * Waits for a child process to exit (see Process::waitpid for exact
- * semantics) and returns an array containing the process id and the
- * exit status (a Process::Status object) of that
- * child. Raises a SystemCallError if there are no child processes.
- *
- * Process.fork { exit 99 } #=> 27437
- * pid, status = Process.wait2
- * pid #=> 27437
- * status.exitstatus #=> 99
+ * Process.wait2(pid = -1, flags = 0) -> [pid, status]
+ *
+ * Like Process.waitpid, but returns an array
+ * containing the child process +pid+ and Process::Status +status+:
+ *
+ * pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581
+ * Process.wait2(pid)
+ * # => [309581, #<Process::Status: pid 309581 exit 13>]
+ *
+ * Process.waitpid2 is an alias for Process.wait2.
*/
static VALUE
@@ -1334,22 +1392,17 @@ proc_wait2(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * Process.waitall -> [ [pid1,status1], ...]
- *
- * Waits for all children, returning an array of
- * _pid_/_status_ pairs (where _status_ is a
- * Process::Status object).
+ * Process.waitall -> array
*
- * fork { sleep 0.2; exit 2 } #=> 27432
- * fork { sleep 0.1; exit 1 } #=> 27433
- * fork { exit 0 } #=> 27434
- * p Process.waitall
+ * Waits for all children, returns an array of 2-element arrays;
+ * each subarray contains the integer pid and Process::Status status
+ * for one of the reaped child processes:
*
- * <em>produces</em>:
+ * pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 325470
+ * pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 325495
+ * Process.waitall
+ * # => [[325470, #<Process::Status: pid 325470 exit 13>], [325495, #<Process::Status: pid 325495 exit 14>]]
*
- * [[30982, #<Process::Status: pid 30982 exit 0>],
- * [30979, #<Process::Status: pid 30979 exit 1>],
- * [30976, #<Process::Status: pid 30976 exit 2>]]
*/
static VALUE
@@ -1407,48 +1460,41 @@ rb_detach_process(rb_pid_t pid)
/*
* call-seq:
- * Process.detach(pid) -> thread
+ * Process.detach(pid) -> thread
*
- * Some operating systems retain the status of terminated child
- * processes until the parent collects that status (normally using
- * some variant of <code>wait()</code>). If the parent never collects
- * this status, the child stays around as a <em>zombie</em> process.
- * Process::detach prevents this by setting up a separate Ruby thread
- * whose sole job is to reap the status of the process _pid_ when it
- * terminates. Use #detach only when you do not intend to explicitly
- * wait for the child to terminate.
+ * Avoids the potential for a child process to become a
+ * {zombie process}[https://en.wikipedia.org/wiki/Zombie_process].
+ * Process.detach prevents this by setting up a separate Ruby thread
+ * whose sole job is to reap the status of the process _pid_ when it terminates.
*
- * The waiting thread returns the exit status of the detached process
- * when it terminates, so you can use Thread#join to
- * know the result. If specified _pid_ is not a valid child process
- * ID, the thread returns +nil+ immediately.
+ * This method is needed only when the parent process will never wait
+ * for the child process.
*
- * The waiting thread has #pid method which returns the pid.
+ * This example does not reap the second child process;
+ * that process appears as a zombie in the process status (+ps+) output:
*
- * In this first example, we don't reap the first child process, so
- * it appears as a zombie in the process status display.
+ * pid = Process.spawn('ruby', '-e', 'exit 13') # => 312691
+ * sleep(1)
+ * # Find zombies.
+ * system("ps -ho pid,state -p #{pid}")
*
- * p1 = fork { sleep 0.1 }
- * p2 = fork { sleep 0.2 }
- * Process.waitpid(p2)
- * sleep 2
- * system("ps -ho pid,state -p #{p1}")
+ * Output:
*
- * <em>produces:</em>
+ * 312716 Z
*
- * 27389 Z
+ * This example also does not reap the second child process,
+ * but it does detach the process so that it does not become a zombie:
*
- * In the next example, Process::detach is used to reap
- * the child automatically.
+ * pid = Process.spawn('ruby', '-e', 'exit 13') # => 313213
+ * thread = Process.detach(pid)
+ * sleep(1)
+ * # => #<Process::Waiter:0x00007f038f48b838 run>
+ * system("ps -ho pid,state -p #{pid}") # Finds no zombies.
*
- * p1 = fork { sleep 0.1 }
- * p2 = fork { sleep 0.2 }
- * Process.detach(p1)
- * Process.waitpid(p2)
- * sleep 2
- * system("ps -ho pid,state -p #{p1}")
+ * The waiting thread can return the pid of the detached child process:
+ *
+ * thread.join.pid # => 313262
*
- * <em>(produces no output)</em>
*/
static VALUE
@@ -1518,43 +1564,51 @@ before_exec(void)
before_exec_async_signal_safe();
}
-/* This function should be async-signal-safe. Actually it is. */
-static void
-after_exec_async_signal_safe(void)
-{
-}
-
static void
-after_exec_non_async_signal_safe(void)
+after_exec(void)
{
rb_thread_reset_timer_thread();
rb_thread_start_timer_thread();
}
-static void
-after_exec(void)
-{
- after_exec_async_signal_safe();
- after_exec_non_async_signal_safe();
-}
-
#if defined HAVE_WORKING_FORK || defined HAVE_DAEMON
static void
before_fork_ruby(void)
{
before_exec();
+ rb_gc_before_fork();
}
static void
-after_fork_ruby(void)
+after_fork_ruby(rb_pid_t pid)
{
- rb_threadptr_pending_interrupt_clear(GET_THREAD());
- after_exec();
+ rb_gc_after_fork(pid);
+
+ if (pid == 0) {
+ // child
+ clear_pid_cache();
+ rb_thread_atfork();
+ }
+ else {
+ // parent
+ after_exec();
+ }
}
#endif
#if defined(HAVE_WORKING_FORK)
+COMPILER_WARNING_PUSH
+#if __has_warning("-Wdeprecated-declarations") || RBIMPL_COMPILER_IS(GCC)
+COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
+#endif
+static inline rb_pid_t
+rb_fork(void)
+{
+ return fork();
+}
+COMPILER_WARNING_POP
+
/* try_with_sh and exec_with_sh should be async-signal-safe. Actually it is.*/
#define try_with_sh(err, prog, argv, envp) ((err == ENOEXEC) ? exec_with_sh((prog), (argv), (envp)) : (void)0)
static void
@@ -1686,7 +1740,7 @@ memsize_exec_arg(const void *ptr)
static const rb_data_type_t exec_arg_data_type = {
"exec_arg",
{mark_exec_arg, RUBY_TYPED_DEFAULT_FREE, memsize_exec_arg},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
#ifdef _WIN32
@@ -2150,7 +2204,7 @@ check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
if (SYMBOL_P(key))
rb_raise(rb_eArgError, "wrong exec option symbol: % "PRIsVALUE,
key);
- rb_raise(rb_eArgError, "wrong exec option");
+ rb_raise(rb_eArgError, "wrong exec option: %"PRIsVALUE, rb_obj_class(key));
}
return ST_CONTINUE;
}
@@ -2329,12 +2383,12 @@ rb_check_argv(int argc, VALUE *argv)
}
prog = RARRAY_AREF(tmp, 0);
argv[0] = RARRAY_AREF(tmp, 1);
- SafeStringValue(prog);
+ StringValue(prog);
StringValueCStr(prog);
prog = rb_str_new_frozen(prog);
}
for (i = 0; i < argc; i++) {
- SafeStringValue(argv[i]);
+ StringValue(argv[i]);
argv[i] = rb_str_new_frozen(argv[i]);
StringValueCStr(argv[i]);
}
@@ -2581,7 +2635,7 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL
}
rb_str_buf_cat(argv_str, (char *)&null, sizeof(null)); /* terminator for execve. */
eargp->invoke.cmd.argv_str =
- rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(argv_str);
+ rb_imemo_tmpbuf_new_from_an_RString(argv_str);
}
RB_GC_GUARD(execarg_obj);
}
@@ -2630,6 +2684,7 @@ rb_execarg_setenv(VALUE execarg_obj, VALUE env)
struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
env = !NIL_P(env) ? rb_check_exec_env(env, &eargp->path_env) : Qfalse;
eargp->env_modification = env;
+ RB_GC_GUARD(execarg_obj);
}
static int
@@ -2671,9 +2726,7 @@ open_func(void *ptr)
static void
rb_execarg_allocate_dup2_tmpbuf(struct rb_execarg *eargp, long len)
{
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
- rb_imemo_tmpbuf_set_ptr(tmpbuf, ruby_xmalloc(run_exec_dup2_tmpbuf_size(len)));
- eargp->dup2_tmpbuf = tmpbuf;
+ rb_alloc_tmp_buffer(&eargp->dup2_tmpbuf, run_exec_dup2_tmpbuf_size(len));
}
static VALUE
@@ -2775,7 +2828,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
p = NULL;
rb_str_buf_cat(envp_str, (char *)&p, sizeof(p));
eargp->envp_str =
- rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(envp_str);
+ rb_imemo_tmpbuf_new_from_an_RString(envp_str);
eargp->envp_buf = envp_buf;
/*
@@ -2827,6 +2880,7 @@ execarg_parent_end(VALUE execarg_obj)
}
errno = err;
+ RB_GC_GUARD(execarg_obj);
return execarg_obj;
}
@@ -2834,7 +2888,6 @@ void
rb_execarg_parent_end(VALUE execarg_obj)
{
execarg_parent_end(execarg_obj);
- RB_GC_GUARD(execarg_obj);
}
static void
@@ -2892,77 +2945,91 @@ NORETURN(static VALUE f_exec(int c, const VALUE *a, VALUE _));
/*
* call-seq:
- * exec([env,] command... [,options])
+ * exec([env, ] command_line, options = {})
+ * exec([env, ] exe_path, *args, options = {})
*
- * Replaces the current process by running the given external _command_, which
- * can take one of the following forms:
+ * Replaces the current process by doing one of the following:
*
- * [<code>exec(commandline)</code>]
- * command line string which is passed to the standard shell
- * [<code>exec(cmdname, arg1, ...)</code>]
- * command name and one or more arguments (no shell)
- * [<code>exec([cmdname, argv0], arg1, ...)</code>]
- * command name, +argv[0]+ and zero or more arguments (no shell)
+ * - Passing string +command_line+ to the shell.
+ * - Invoking the executable at +exe_path+.
*
- * In the first form, the string is taken as a command line that is subject to
- * shell expansion before being executed.
+ * This method has potential security vulnerabilities if called with untrusted input;
+ * see {Command Injection}[rdoc-ref:security/command_injection.rdoc].
+ *
+ * The new process is created using the
+ * {exec system call}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/execve.html];
+ * it may inherit some of its environment from the calling program
+ * (possibly including open file descriptors).
+ *
+ * Argument +env+, if given, is a hash that affects +ENV+ for the new process;
+ * see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ *
+ * Argument +options+ is a hash of options for the new process;
+ * see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ *
+ * The first required argument is one of the following:
+ *
+ * - +command_line+ if it is a string,
+ * and if it begins with a shell reserved word or special built-in,
+ * or if it contains one or more meta characters.
+ * - +exe_path+ otherwise.
+ *
+ * <b>Argument +command_line+</b>
+ *
+ * \String argument +command_line+ is a command line to be passed to a shell;
+ * it must begin with a shell reserved word, begin with a special built-in,
+ * or contain meta characters:
*
- * The standard shell always means <code>"/bin/sh"</code> on Unix-like systems,
- * otherwise, <code>ENV["RUBYSHELL"]</code> or <code>ENV["COMSPEC"]</code> on
- * Windows and similar. The command is passed as an argument to the
- * <code>"-c"</code> switch to the shell, except in the case of +COMSPEC+.
+ * exec('if true; then echo "Foo"; fi') # Shell reserved word.
+ * exec('exit') # Built-in.
+ * exec('date > date.tmp') # Contains meta character.
*
- * If the string from the first form (<code>exec("command")</code>) follows
- * these simple rules:
+ * The command line may also contain arguments and options for the command:
*
- * * no meta characters,
- * * not starting with shell reserved word or special built-in,
+ * exec('echo "Foo"')
*
- * Ruby invokes the command directly without shell.
+ * Output:
*
- * You can force shell invocation by adding ";" to the string (because ";" is
- * a meta character).
+ * Foo
*
- * Note that this behavior is observable by pid obtained
- * (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked
- * command, not shell.
+ * See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
*
- * In the second form (<code>exec("command1", "arg1", ...)</code>), the first
- * is taken as a command name and the rest are passed as parameters to command
- * with no shell expansion.
+ * Raises an exception if the new process could not execute.
*
- * In the third form (<code>exec(["command", "argv0"], "arg1", ...)</code>),
- * starting a two-element array at the beginning of the command, the first
- * element is the command to be executed, and the second argument is used as
- * the <code>argv[0]</code> value, which may show up in process listings.
+ * <b>Argument +exe_path+</b>
*
- * In order to execute the command, one of the <code>exec(2)</code> system
- * calls are used, so the running command may inherit some of the environment
- * of the original program (including open file descriptors).
+ * Argument +exe_path+ is one of the following:
*
- * This behavior is modified by the given +env+ and +options+ parameters. See
- * ::spawn for details.
+ * - The string path to an executable to be called.
+ * - A 2-element array containing the path to an executable
+ * and the string to be used as the name of the executing process.
*
- * If the command fails to execute (typically Errno::ENOENT when
- * it was not found) a SystemCallError exception is raised.
+ * Example:
*
- * This method modifies process attributes according to given +options+ before
- * <code>exec(2)</code> system call. See ::spawn for more details about the
- * given +options+.
+ * exec('/usr/bin/date')
*
- * The modified attributes may be retained when <code>exec(2)</code> system
- * call fails.
+ * Output:
*
- * For example, hard resource limits are not restorable.
+ * Sat Aug 26 09:38:00 AM CDT 2023
*
- * Consider to create a child process using ::spawn or Kernel#system if this
- * is not acceptable.
+ * Ruby invokes the executable directly.
+ * This form does not use the shell;
+ * see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
*
- * exec "echo *" # echoes list of files in current directory
- * # never get here
+ * exec('doesnt_exist') # Raises Errno::ENOENT
*
- * exec "echo", "*" # echoes an asterisk
- * # never get here
+ * If one or more +args+ is given, each is an argument or option
+ * to be passed to the executable:
+ *
+ * exec('echo', 'C*')
+ * exec('echo', 'hello', 'world')
+ *
+ * Output:
+ *
+ * C*
+ * hello world
+ *
+ * Raises an exception if the new process could not execute.
*/
static VALUE
@@ -2972,9 +3039,13 @@ f_exec(int c, const VALUE *a, VALUE _)
UNREACHABLE_RETURN(Qnil);
}
-#define ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0)
-#define ERRMSG1(str, a) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a)); } while (0)
-#define ERRMSG2(str, a, b) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a), (b)); } while (0)
+#define ERRMSG(str) \
+ ((errmsg && 0 < errmsg_buflen) ? \
+ (void)strlcpy(errmsg, (str), errmsg_buflen) : (void)0)
+
+#define ERRMSG_FMT(...) \
+ ((errmsg && 0 < errmsg_buflen) ? \
+ (void)snprintf(errmsg, errmsg_buflen, __VA_ARGS__) : (void)0)
static int fd_get_cloexec(int fd, char *errmsg, size_t errmsg_buflen);
static int fd_set_cloexec(int fd, char *errmsg, size_t errmsg_buflen);
@@ -3109,8 +3180,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
long n, i;
int ret;
int extra_fd = -1;
- struct rb_imemo_tmpbuf_struct *buf = (void *)tmpbuf;
- struct run_exec_dup2_fd_pair *pairs = (void *)buf->ptr;
+ struct run_exec_dup2_fd_pair *pairs = RB_IMEMO_TMPBUF_PTR(tmpbuf);
n = RARRAY_LEN(ary);
@@ -3187,6 +3257,14 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
ERRMSG("dup");
goto fail;
}
+ // without this, kqueue timer_th.event_fd fails with a reserved FD did not have close-on-exec
+ // in #assert_close_on_exec because the FD_CLOEXEC is not dup'd by default
+ if (fd_get_cloexec(pairs[i].oldfd, errmsg, errmsg_buflen)) {
+ if (fd_set_cloexec(extra_fd, errmsg, errmsg_buflen)) {
+ close(extra_fd);
+ goto fail;
+ }
+ }
rb_update_max_fd(extra_fd);
}
else {
@@ -3929,7 +4007,10 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep,
while (1) {
prefork();
disable_child_handler_before_fork(&old);
-#ifdef HAVE_WORKING_VFORK
+
+ // Older versions of ASAN does not work with vfork
+ // See https://github.com/google/sanitizers/issues/925
+#if defined(HAVE_WORKING_VFORK) && !defined(RUBY_ASAN_ENABLED)
if (!has_privilege())
pid = vfork();
else
@@ -4017,7 +4098,7 @@ fork_check_err(struct rb_process_status *status, int (*chfunc)(void*, char *, si
* The "async_signal_safe" name is a lie, but it is used by pty.c and
* maybe other exts. fork() is not async-signal-safe due to pthread_atfork
* and future POSIX revisions will remove it from a list of signal-safe
- * functions. rb_waitpid is not async-signal-safe since RJIT, either.
+ * functions. rb_waitpid is not async-signal-safe.
* For our purposes, we do not need async-signal-safety, here
*/
rb_pid_t
@@ -4036,48 +4117,47 @@ rb_fork_async_signal_safe(int *status,
return result;
}
-static rb_pid_t
-rb_fork_ruby2(struct rb_process_status *status)
+rb_pid_t
+rb_fork_ruby(int *status)
{
+ if (UNLIKELY(!rb_ractor_main_p())) {
+ rb_raise(rb_eRactorIsolationError, "can not fork from non-main Ractors");
+ }
+
+ struct rb_process_status child = {.status = 0};
rb_pid_t pid;
- int try_gc = 1, err;
+ int try_gc = 1, err = 0;
struct child_handler_disabler_state old;
- if (status) status->status = 0;
-
- while (1) {
+ do {
prefork();
- disable_child_handler_before_fork(&old);
+
before_fork_ruby();
- pid = rb_fork();
- err = errno;
- if (status) {
- status->pid = pid;
- status->error = err;
- }
- after_fork_ruby();
- disable_child_handler_fork_parent(&old); /* yes, bad name */
+ rb_thread_acquire_fork_lock();
+ disable_child_handler_before_fork(&old);
- if (pid >= 0) { /* fork succeed */
- if (pid == 0) rb_thread_atfork();
- return pid;
+ RB_VM_LOCKING() {
+ child.pid = pid = rb_fork();
+ child.error = err = errno;
}
- /* fork failed */
- if (handle_fork_error(err, status, NULL, &try_gc)) {
- return -1;
+ disable_child_handler_fork_parent(&old); /* yes, bad name */
+ if (
+#if defined(__FreeBSD__)
+ pid != 0 &&
+#endif
+ true) {
+ rb_thread_release_fork_lock();
}
- }
-}
-
-rb_pid_t
-rb_fork_ruby(int *status)
-{
- struct rb_process_status process_status = {0};
+ if (pid == 0) {
+ rb_thread_reset_fork_lock();
+ }
+ after_fork_ruby(pid);
- rb_pid_t pid = rb_fork_ruby2(&process_status);
+ /* repeat while fork failed but retryable */
+ } while (pid < 0 && handle_fork_error(err, &child, NULL, &try_gc) == 0);
- if (status) *status = process_status.status;
+ if (status) *status = child.status;
return pid;
}
@@ -4138,27 +4218,62 @@ rb_proc__fork(VALUE _obj)
/*
* call-seq:
- * Kernel.fork [{ block }] -> integer or nil
- * Process.fork [{ block }] -> integer or nil
- *
- * Creates a subprocess. If a block is specified, that block is run
- * in the subprocess, and the subprocess terminates with a status of
- * zero. Otherwise, the +fork+ call returns twice, once in the
- * parent, returning the process ID of the child, and once in the
- * child, returning _nil_. The child process can exit using
- * Kernel.exit! to avoid running any <code>at_exit</code>
- * functions. The parent process should use Process.wait to collect
- * the termination statuses of its children or use Process.detach to
- * register disinterest in their status; otherwise, the operating
- * system may accumulate zombie processes.
- *
- * The thread calling fork is the only thread in the created child process.
- * fork doesn't copy other threads.
- *
- * If fork is not usable, Process.respond_to?(:fork) returns false.
- *
- * Note that fork(2) is not available on some platforms like Windows and NetBSD 4.
- * Therefore you should use spawn() instead of fork().
+ * Process.fork { ... } -> integer or nil
+ * Process.fork -> integer or nil
+ *
+ * Creates a child process.
+ *
+ * With a block given, runs the block in the child process;
+ * on block exit, the child terminates with a status of zero:
+ *
+ * puts "Before the fork: #{Process.pid}"
+ * fork do
+ * puts "In the child process: #{Process.pid}"
+ * end # => 420520
+ * puts "After the fork: #{Process.pid}"
+ *
+ * Output:
+ *
+ * Before the fork: 420496
+ * After the fork: 420496
+ * In the child process: 420520
+ *
+ * With no block given, the +fork+ call returns twice:
+ *
+ * - Once in the parent process, returning the pid of the child process.
+ * - Once in the child process, returning +nil+.
+ *
+ * Example:
+ *
+ * puts "This is the first line before the fork (pid #{Process.pid})"
+ * puts fork
+ * puts "This is the second line after the fork (pid #{Process.pid})"
+ *
+ * Output:
+ *
+ * This is the first line before the fork (pid 420199)
+ * 420223
+ * This is the second line after the fork (pid 420199)
+ *
+ * This is the second line after the fork (pid 420223)
+ *
+ * In either case, the child process may exit using
+ * Kernel.exit! to avoid the call to Kernel#at_exit.
+ *
+ * To avoid zombie processes, the parent process should call either:
+ *
+ * - Process.wait, to collect the termination statuses of its children.
+ * - Process.detach, to register disinterest in their status.
+ *
+ * The thread calling +fork+ is the only thread in the created child process;
+ * +fork+ doesn't copy other threads.
+ *
+ * Note that method +fork+ is available on some platforms,
+ * but not on others:
+ *
+ * Process.respond_to?(:fork) # => true # Would be false on some.
+ *
+ * If not, you may use ::spawn instead of +fork+.
*/
static VALUE
@@ -4210,13 +4325,18 @@ exit_status_code(VALUE status)
NORETURN(static VALUE rb_f_exit_bang(int argc, VALUE *argv, VALUE obj));
/*
* call-seq:
- * Process.exit!(status=false)
+ * exit!(status = false)
+ * Process.exit!(status = false)
*
- * Exits the process immediately. No exit handlers are
- * run. <em>status</em> is returned to the underlying system as the
- * exit status.
+ * Exits the process immediately; no exit handlers are called.
+ * Returns exit status +status+ to the underlying operating system.
*
* Process.exit!(true)
+ *
+ * Values +true+ and +false+ for argument +status+
+ * indicate, respectively, success and failure;
+ * The meanings of integer values are system-dependent.
+ *
*/
static VALUE
@@ -4267,43 +4387,47 @@ rb_f_exit(int argc, const VALUE *argv)
NORETURN(static VALUE f_exit(int c, const VALUE *a, VALUE _));
/*
* call-seq:
- * exit(status=true)
- * Kernel::exit(status=true)
- * Process::exit(status=true)
- *
- * Initiates the termination of the Ruby script by raising the
- * SystemExit exception. This exception may be caught. The
- * optional parameter is used to return a status code to the invoking
- * environment.
- * +true+ and +FALSE+ of _status_ means success and failure
- * respectively. The interpretation of other integer values are
- * system dependent.
- *
- * 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
+ * exit(status = true)
+ * Process.exit(status = true)
+ *
+ * Initiates termination of the Ruby script by raising SystemExit;
+ * the exception may be caught.
+ * Returns exit status +status+ to the underlying operating system.
+ *
+ * Values +true+ and +false+ for argument +status+
+ * indicate, respectively, success and failure;
+ * The meanings of integer values are system-dependent.
+ *
+ * Example:
+ *
+ * begin
+ * exit
+ * puts 'Never get here.'
+ * rescue SystemExit
+ * puts 'Rescued a SystemExit exception.'
+ * end
+ * puts 'After begin block.'
+ *
+ * Output:
+ *
+ * Rescued a SystemExit exception.
+ * After begin block.
+ *
+ * Just prior to final termination,
+ * Ruby executes any at-exit procedures (see Kernel::at_exit)
+ * and any object finalizers (see ObjectSpace::define_finalizer).
+ *
+ * Example:
+ *
+ * at_exit { puts 'In at_exit function.' }
+ * ObjectSpace.define_finalizer('string', proc { puts 'In finalizer.' })
+ * exit
+ *
+ * Output:
+ *
+ * In at_exit function.
+ * In finalizer.
+ *
*/
static VALUE
@@ -4342,13 +4466,16 @@ NORETURN(static VALUE f_abort(int c, const VALUE *a, VALUE _));
/*
* call-seq:
- * abort
- * Kernel::abort([msg])
- * Process.abort([msg])
+ * abort
+ * Process.abort(msg = nil)
+ *
+ * Terminates execution immediately, effectively by calling
+ * <tt>Kernel.exit(false)</tt>.
*
- * Terminate execution immediately, effectively by calling
- * <code>Kernel.exit(false)</code>. If _msg_ is given, it is written
- * to STDERR prior to terminating.
+ * If string argument +msg+ is given,
+ * it is written to STDERR prior to termination;
+ * otherwise, if an exception was raised,
+ * prints its message and backtrace.
*/
static VALUE
@@ -4454,11 +4581,16 @@ static VALUE
do_spawn_process(VALUE arg)
{
struct spawn_args *argp = (struct spawn_args *)arg;
+
rb_execarg_parent_start1(argp->execarg);
- return (VALUE)rb_spawn_process(DATA_PTR(argp->execarg),
+
+ return (VALUE)rb_spawn_process(rb_execarg_get(argp->execarg),
argp->errmsg.ptr, argp->errmsg.buflen);
}
+NOINLINE(static rb_pid_t
+ rb_execarg_spawn(VALUE execarg_obj, char *errmsg, size_t errmsg_buflen));
+
static rb_pid_t
rb_execarg_spawn(VALUE execarg_obj, char *errmsg, size_t errmsg_buflen)
{
@@ -4467,8 +4599,10 @@ rb_execarg_spawn(VALUE execarg_obj, char *errmsg, size_t errmsg_buflen)
args.execarg = execarg_obj;
args.errmsg.ptr = errmsg;
args.errmsg.buflen = errmsg_buflen;
- return (rb_pid_t)rb_ensure(do_spawn_process, (VALUE)&args,
- execarg_parent_end, execarg_obj);
+
+ rb_pid_t r = (rb_pid_t)rb_ensure(do_spawn_process, (VALUE)&args,
+ execarg_parent_end, execarg_obj);
+ return r;
}
static rb_pid_t
@@ -4494,68 +4628,133 @@ rb_spawn(int argc, const VALUE *argv)
/*
* call-seq:
- * system([env,] command... [,options], exception: false) -> true, false or nil
+ * system([env, ] command_line, options = {}, exception: false) -> true, false, or nil
+ * system([env, ] exe_path, *args, options = {}, exception: false) -> true, false, or nil
+ *
+ * Creates a new child process by doing one of the following
+ * in that process:
*
- * Executes _command..._ in a subshell.
- * _command..._ is one of following forms.
+ * - Passing string +command_line+ to the shell.
+ * - Invoking the executable at +exe_path+.
*
* This method has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
+ * see {Command Injection}[rdoc-ref:security/command_injection.rdoc].
+ *
+ * Returns:
+ *
+ * - +true+ if the command exits with status zero.
+ * - +false+ if the exit status is a non-zero integer.
+ * - +nil+ if the command could not execute.
+ *
+ * Raises an exception (instead of returning +false+ or +nil+)
+ * if keyword argument +exception+ is set to +true+.
+ *
+ * Assigns the command's error status to <tt>$?</tt>.
+ *
+ * The new process is created using the
+ * {system system call}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/system.html];
+ * it may inherit some of its environment from the calling program
+ * (possibly including open file descriptors).
+ *
+ * Argument +env+, if given, is a hash that affects +ENV+ for the new process;
+ * see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ *
+ * Argument +options+ is a hash of options for the new process;
+ * see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ *
+ * The first required argument is one of the following:
*
- * [<code>commandline</code>]
- * command line string which is passed to the standard shell
- * [<code>cmdname, arg1, ...</code>]
- * command name and one or more arguments (no shell)
- * [<code>[cmdname, argv0], arg1, ...</code>]
- * command name, <code>argv[0]</code> and zero or more arguments (no shell)
+ * - +command_line+ if it is a string,
+ * and if it begins with a shell reserved word or special built-in,
+ * or if it contains one or more meta characters.
+ * - +exe_path+ otherwise.
*
- * system returns +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>.
+ * <b>Argument +command_line+</b>
*
- * If the <code>exception: true</code> argument is passed, the method
- * raises an exception instead of returning +false+ or +nil+.
+ * \String argument +command_line+ is a command line to be passed to a shell;
+ * it must begin with a shell reserved word, begin with a special built-in,
+ * or contain meta characters:
*
- * The arguments are processed in the same way as
- * for Kernel#spawn.
+ * system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
+ * system('exit') # => true # Built-in.
+ * system('date > /tmp/date.tmp') # => true # Contains meta character.
+ * system('date > /nop/date.tmp') # => false
+ * system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
*
- * The hash arguments, env and options, are same as #exec and #spawn.
- * See Kernel#spawn for details.
+ * Assigns the command's error status to <tt>$?</tt>:
*
- * system("echo *")
- * system("echo", "*")
+ * system('exit') # => true # Built-in.
+ * $? # => #<Process::Status: pid 640610 exit 0>
+ * system('date > /nop/date.tmp') # => false
+ * $? # => #<Process::Status: pid 640742 exit 2>
*
- * <em>produces:</em>
+ * The command line may also contain arguments and options for the command:
*
- * config.h main.rb
- * *
+ * system('echo "Foo"') # => true
*
- * Error handling:
+ * Output:
*
- * system("cat nonexistent.txt")
- * # => false
- * system("catt nonexistent.txt")
- * # => nil
+ * Foo
*
- * system("cat nonexistent.txt", exception: true)
- * # RuntimeError (Command failed with exit 1: cat)
- * system("catt nonexistent.txt", exception: true)
- * # Errno::ENOENT (No such file or directory - catt)
+ * See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
*
- * See Kernel#exec for the standard shell.
+ * Raises an exception if the new process could not execute.
+ *
+ * <b>Argument +exe_path+</b>
+ *
+ * Argument +exe_path+ is one of the following:
+ *
+ * - The string path to an executable to be called.
+ * - A 2-element array containing the path to an executable
+ * and the string to be used as the name of the executing process.
+ *
+ * Example:
+ *
+ * system('/usr/bin/date') # => true # Path to date on Unix-style system.
+ * system('foo') # => nil # Command failed.
+ *
+ * Output:
+ *
+ * Mon Aug 28 11:43:10 AM CDT 2023
+ *
+ * Assigns the command's error status to <tt>$?</tt>:
+ *
+ * system('/usr/bin/date') # => true
+ * $? # => #<Process::Status: pid 645605 exit 0>
+ * system('foo') # => nil
+ * $? # => #<Process::Status: pid 645608 exit 127>
+ *
+ * Ruby invokes the executable directly.
+ * This form does not use the shell;
+ * see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
+ *
+ * system('doesnt_exist') # => nil
+ *
+ * If one or more +args+ is given, each is an argument or option
+ * to be passed to the executable:
+ *
+ * system('echo', 'C*') # => true
+ * system('echo', 'hello', 'world') # => true
+ *
+ * Output:
+ *
+ * C*
+ * hello world
+ *
+ * Raises an exception if the new process could not execute.
*/
static VALUE
rb_f_system(int argc, VALUE *argv, VALUE _)
{
+ rb_thread_t *th = GET_THREAD();
VALUE execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE);
struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
struct rb_process_status status = {0};
eargp->status = &status;
- rb_last_status_clear();
+ last_status_clear(th);
// This function can set the thread's last status.
// May be different from waitpid_state.pid on exec failure.
@@ -4563,11 +4762,10 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
if (pid > 0) {
VALUE status = rb_process_status_wait(pid, 0);
- struct rb_process_status *data = RTYPEDDATA_DATA(status);
-
+ struct rb_process_status *data = rb_check_typeddata(status, &rb_process_status_type);
// Set the last status:
rb_obj_freeze(status);
- GET_THREAD()->last_status = status;
+ th->last_status = status;
if (data->status == EXIT_SUCCESS) {
return Qtrue;
@@ -4610,271 +4808,105 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * spawn([env,] command... [,options]) -> pid
- * Process.spawn([env,] command... [,options]) -> pid
- *
- * spawn executes specified command and return its pid.
- *
- * pid = spawn("tar xf ruby-2.0.0-p195.tar.bz2")
- * Process.wait pid
- *
- * pid = spawn(RbConfig.ruby, "-eputs'Hello, world!'")
- * Process.wait pid
- *
- * This method is similar to Kernel#system but it doesn't wait for the command
- * to finish.
- *
- * The parent process should
- * use Process.wait to collect
- * the termination status of its child or
- * use Process.detach to register
- * disinterest in their status;
- * otherwise, the operating system may accumulate zombie processes.
- *
- * spawn has bunch of options to specify process attributes:
- *
- * env: hash
- * name => val : set the environment variable
- * name => nil : unset the environment variable
- *
- * the keys and the values except for +nil+ must be strings.
- * command...:
- * commandline : command line string which is passed to the standard shell
- * cmdname, arg1, ... : command name and one or more arguments (This form does not use the shell. See below for caveats.)
- * [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
- * options: hash
- * clearing environment variables:
- * :unsetenv_others => true : clear environment variables except specified by env
- * :unsetenv_others => false : don't clear (default)
- * process group:
- * :pgroup => true or 0 : make a new process group
- * :pgroup => pgid : join the specified process group
- * :pgroup => nil : don't change the process group (default)
- * create new process group: Windows only
- * :new_pgroup => true : the new process is the root process of a new process group
- * :new_pgroup => false : don't create a new process group (default)
- * resource limit: resourcename is core, cpu, data, etc. See Process.setrlimit.
- * :rlimit_resourcename => limit
- * :rlimit_resourcename => [cur_limit, max_limit]
- * umask:
- * :umask => int
- * redirection:
- * key:
- * FD : single file descriptor in child process
- * [FD, FD, ...] : multiple file descriptor in child process
- * value:
- * FD : redirect to the file descriptor in parent process
- * string : redirect to file with open(string, "r" or "w")
- * [string] : redirect to file with open(string, File::RDONLY)
- * [string, open_mode] : redirect to file with open(string, open_mode, 0644)
- * [string, open_mode, perm] : redirect to file with open(string, open_mode, perm)
- * [:child, FD] : redirect to the redirected file descriptor
- * :close : close the file descriptor in child process
- * FD is one of follows
- * :in : the file descriptor 0 which is the standard input
- * :out : the file descriptor 1 which is the standard output
- * :err : the file descriptor 2 which is the standard error
- * integer : the file descriptor of specified the integer
- * io : the file descriptor specified as io.fileno
- * file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not
- * :close_others => false : inherit
- * current directory:
- * :chdir => str
- *
- * The <code>cmdname, arg1, ...</code> form does not use the shell.
- * However, on different OSes, different things are provided as
- * built-in commands. An example of this is +'echo'+, which is a
- * built-in on Windows, but is a normal program on Linux and Mac OS X.
- * This means that <code>Process.spawn 'echo', '%Path%'</code> will
- * display the contents of the <tt>%Path%</tt> environment variable
- * on Windows, but <code>Process.spawn 'echo', '$PATH'</code> prints
- * the literal <tt>$PATH</tt>.
- *
- * If a hash is given as +env+, the environment is
- * updated by +env+ before <code>exec(2)</code> in the child process.
- * If a pair in +env+ has nil as the value, the variable is deleted.
- *
- * # set FOO as BAR and unset BAZ.
- * pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
- *
- * If a hash is given as +options+,
- * it specifies
- * process group,
- * create new process group,
- * resource limit,
- * current directory,
- * umask and
- * redirects for the child process.
- * Also, it can be specified to clear environment variables.
- *
- * The <code>:unsetenv_others</code> key in +options+ specifies
- * to clear environment variables, other than specified by +env+.
- *
- * pid = spawn(command, :unsetenv_others=>true) # no environment variable
- * pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only
- *
- * The <code>:pgroup</code> key in +options+ specifies a process group.
- * The corresponding value should be true, zero, a positive integer, or nil.
- * true and zero cause the process to be a process leader of a new process group.
- * A non-zero positive integer causes the process to join the provided process group.
- * The default value, nil, causes the process to remain in the same process group.
- *
- * pid = spawn(command, :pgroup=>true) # process leader
- * pid = spawn(command, :pgroup=>10) # belongs to the process group 10
- *
- * The <code>:new_pgroup</code> key in +options+ specifies to pass
- * +CREATE_NEW_PROCESS_GROUP+ flag to <code>CreateProcessW()</code> that is
- * Windows API. This option is only for Windows.
- * true means the new process is the root process of the new process group.
- * The new process has CTRL+C disabled. This flag is necessary for
- * <code>Process.kill(:SIGINT, pid)</code> on the subprocess.
- * :new_pgroup is false by default.
- *
- * pid = spawn(command, :new_pgroup=>true) # new process group
- * pid = spawn(command, :new_pgroup=>false) # same process group
- *
- * The <code>:rlimit_</code><em>foo</em> key specifies a resource limit.
- * <em>foo</em> should be one of resource types such as <code>core</code>.
- * The corresponding value should be an integer or an array which have one or
- * two integers: same as cur_limit and max_limit arguments for
- * Process.setrlimit.
- *
- * cur, max = Process.getrlimit(:CORE)
- * pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary.
- * pid = spawn(command, :rlimit_core=>max) # enable core dump
- * pid = spawn(command, :rlimit_core=>0) # never dump core.
- *
- * The <code>:umask</code> key in +options+ specifies the umask.
- *
- * pid = spawn(command, :umask=>077)
- *
- * The :in, :out, :err, an integer, an IO and an array key specifies a redirection.
- * The redirection maps a file descriptor in the child process.
- *
- * For example, stderr can be merged into stdout as follows:
- *
- * pid = spawn(command, :err=>:out)
- * pid = spawn(command, 2=>1)
- * pid = spawn(command, STDERR=>:out)
- * pid = spawn(command, STDERR=>STDOUT)
- *
- * The hash keys specifies a file descriptor in the child process
- * started by #spawn.
- * :err, 2 and STDERR specifies the standard error stream (stderr).
- *
- * The hash values specifies a file descriptor in the parent process
- * which invokes #spawn.
- * :out, 1 and STDOUT specifies the standard output stream (stdout).
- *
- * In the above example,
- * the standard output in the child process is not specified.
- * So it is inherited from the parent process.
- *
- * The standard input stream (stdin) can be specified by :in, 0 and STDIN.
- *
- * A filename can be specified as a hash value.
- *
- * pid = spawn(command, :in=>"/dev/null") # read mode
- * pid = spawn(command, :out=>"/dev/null") # write mode
- * pid = spawn(command, :err=>"log") # write mode
- * pid = spawn(command, [:out, :err]=>"/dev/null") # write mode
- * pid = spawn(command, 3=>"/dev/null") # read mode
+ * spawn([env, ] command_line, options = {}) -> pid
+ * spawn([env, ] exe_path, *args, options = {}) -> pid
+ *
+ * Creates a new child process by doing one of the following
+ * in that process:
+ *
+ * - Passing string +command_line+ to the shell.
+ * - Invoking the executable at +exe_path+.
+ *
+ * This method has potential security vulnerabilities if called with untrusted input;
+ * see {Command Injection}[rdoc-ref:security/command_injection.rdoc].
+ *
+ * Returns the process ID (pid) of the new process,
+ * without waiting for it to complete.
*
- * For stdout and stderr (and combination of them),
- * it is opened in write mode.
- * Otherwise read mode is used.
+ * To avoid zombie processes, the parent process should call either:
*
- * For specifying flags and permission of file creation explicitly,
- * an array is used instead.
+ * - Process.wait, to collect the termination statuses of its children.
+ * - Process.detach, to register disinterest in their status.
*
- * pid = spawn(command, :in=>["file"]) # read mode is assumed
- * pid = spawn(command, :in=>["file", "r"])
- * pid = spawn(command, :out=>["log", "w"]) # 0644 assumed
- * pid = spawn(command, :out=>["log", "w", 0600])
- * pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600])
+ * The new process is created using the
+ * {exec system call}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/execve.html];
+ * it may inherit some of its environment from the calling program
+ * (possibly including open file descriptors).
*
- * The array specifies a filename, flags and permission.
- * The flags can be a string or an integer.
- * If the flags is omitted or nil, File::RDONLY is assumed.
- * The permission should be an integer.
- * If the permission is omitted or nil, 0644 is assumed.
+ * Argument +env+, if given, is a hash that affects +ENV+ for the new process;
+ * see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
*
- * If an array of IOs and integers are specified as a hash key,
- * all the elements are redirected.
+ * Argument +options+ is a hash of options for the new process;
+ * see {Execution Options}[rdoc-ref:Process@Execution+Options].
*
- * # stdout and stderr is redirected to log file.
- * # The file "log" is opened just once.
- * pid = spawn(command, [:out, :err]=>["log", "w"])
+ * The first required argument is one of the following:
*
- * Another way to merge multiple file descriptors is [:child, fd].
- * \[:child, fd] means the file descriptor in the child process.
- * This is different from fd.
- * For example, :err=>:out means redirecting child stderr to parent stdout.
- * But :err=>[:child, :out] means redirecting child stderr to child stdout.
- * They differ if stdout is redirected in the child process as follows.
+ * - +command_line+ if it is a string,
+ * and if it begins with a shell reserved word or special built-in,
+ * or if it contains one or more meta characters.
+ * - +exe_path+ otherwise.
*
- * # stdout and stderr is redirected to log file.
- * # The file "log" is opened just once.
- * pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out])
+ * <b>Argument +command_line+</b>
*
- * \[:child, :out] can be used to merge stderr into stdout in IO.popen.
- * In this case, IO.popen redirects stdout to a pipe in the child process
- * and [:child, :out] refers the redirected stdout.
+ * \String argument +command_line+ is a command line to be passed to a shell;
+ * it must begin with a shell reserved word, begin with a special built-in,
+ * or contain meta characters:
*
- * io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
- * p io.read #=> "out\nerr\n"
+ * spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word.
+ * Process.wait # => 798847
+ * spawn('exit') # => 798848 # Built-in.
+ * Process.wait # => 798848
+ * spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character.
+ * Process.wait # => 798849
+ * spawn('date > /nop/date.tmp') # => 798882 # Issues error message.
+ * Process.wait # => 798882
*
- * The <code>:chdir</code> key in +options+ specifies the current directory.
+ * The command line may also contain arguments and options for the command:
*
- * pid = spawn(command, :chdir=>"/var/tmp")
+ * spawn('echo "Foo"') # => 799031
+ * Process.wait # => 799031
*
- * spawn closes all non-standard unspecified descriptors by default.
- * The "standard" descriptors are 0, 1 and 2.
- * This behavior is specified by :close_others option.
- * :close_others doesn't affect the standard descriptors which are
- * closed only if :close is specified explicitly.
+ * Output:
*
- * pid = spawn(command, :close_others=>true) # close 3,4,5,... (default)
- * pid = spawn(command, :close_others=>false) # don't close 3,4,5,...
+ * Foo
*
- * :close_others is false by default for spawn and IO.popen.
+ * See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
*
- * Note that fds which close-on-exec flag is already set are closed
- * regardless of :close_others option.
+ * Raises an exception if the new process could not execute.
*
- * So IO.pipe and spawn can be used as IO.popen.
+ * <b>Argument +exe_path+</b>
*
- * # similar to r = IO.popen(command)
- * r, w = IO.pipe
- * pid = spawn(command, :out=>w) # r, w is closed in the child process.
- * w.close
+ * Argument +exe_path+ is one of the following:
*
- * :close is specified as a hash value to close a fd individually.
+ * - The string path to an executable to be called.
+ * - A 2-element array containing the path to an executable to be called,
+ * and the string to be used as the name of the executing process.
*
- * f = open(foo)
- * system(command, f=>:close) # don't inherit f.
+ * spawn('/usr/bin/date') # Path to date on Unix-style system.
+ * Process.wait
*
- * If a file descriptor need to be inherited,
- * io=>io can be used.
+ * Output:
*
- * # valgrind has --log-fd option for log destination.
- * # log_w=>log_w indicates log_w.fileno inherits to child process.
- * log_r, log_w = IO.pipe
- * pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w)
- * log_w.close
- * p log_r.read
+ * Mon Aug 28 11:43:10 AM CDT 2023
*
- * It is also possible to exchange file descriptors.
+ * Ruby invokes the executable directly.
+ * This form does not use the shell;
+ * see {Arguments args}[rdoc-ref:Process@Arguments+args] for caveats.
*
- * pid = spawn(command, :out=>:err, :err=>:out)
+ * If one or more +args+ is given, each is an argument or option
+ * to be passed to the executable:
*
- * The hash keys specify file descriptors in the child process.
- * The hash values specifies file descriptors in the parent process.
- * So the above specifies exchanging stdout and stderr.
- * Internally, +spawn+ uses an extra file descriptor to resolve such cyclic
- * file descriptor mapping.
+ * spawn('echo', 'C*') # => 799392
+ * Process.wait # => 799392
+ * spawn('echo', 'hello', 'world') # => 799393
+ * Process.wait # => 799393
*
- * See Kernel.exec for the standard shell.
+ * Output:
+ *
+ * C*
+ * hello world
+ *
+ * Raises an exception if the new process could not execute.
*/
static VALUE
@@ -4906,22 +4938,18 @@ rb_f_spawn(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * sleep([duration]) -> integer
- *
- * Suspends the current thread for _duration_ seconds (which may be any number,
- * including a +Float+ with fractional seconds). Returns the actual number of
- * seconds slept (rounded), which may be less than that asked for if another
- * thread calls Thread#run. Called without an argument, sleep()
- * will sleep forever.
- *
- * If the +duration+ is not supplied, or is +nil+, the thread sleeps forever.
- * Threads in this state may still be interrupted by other threads.
- *
- * Time.new #=> 2008-03-08 19:56:19 +0900
- * sleep 1.2 #=> 1
- * Time.new #=> 2008-03-08 19:56:20 +0900
- * sleep 1.9 #=> 2
- * Time.new #=> 2008-03-08 19:56:22 +0900
+ * sleep(secs = nil) -> slept_secs
+ *
+ * Suspends execution of the current thread for the number of seconds
+ * specified by numeric argument +secs+, or forever if +secs+ is +nil+;
+ * returns the integer number of seconds suspended (rounded).
+ *
+ * Time.new # => 2008-03-08 19:56:19 +0900
+ * sleep 1.2 # => 1
+ * Time.new # => 2008-03-08 19:56:20 +0900
+ * sleep 1.9 # => 2
+ * Time.new # => 2008-03-08 19:56:22 +0900
+ *
*/
static VALUE
@@ -4952,13 +4980,13 @@ rb_f_sleep(int argc, VALUE *argv, VALUE _)
#if (defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)) || defined(HAVE_GETPGID)
/*
* call-seq:
- * Process.getpgrp -> integer
+ * Process.getpgrp -> integer
+ *
+ * Returns the process group ID for the current process:
*
- * Returns the process group ID for this process. Not available on
- * all platforms.
+ * Process.getpgid(0) # => 25527
+ * Process.getpgrp # => 25527
*
- * Process.getpgid(0) #=> 25527
- * Process.getpgrp #=> 25527
*/
static VALUE
@@ -4984,10 +5012,11 @@ proc_getpgrp(VALUE _)
#if defined(HAVE_SETPGID) || (defined(HAVE_SETPGRP) && defined(SETPGRP_VOID))
/*
* call-seq:
- * Process.setpgrp -> 0
+ * Process.setpgrp -> 0
*
- * Equivalent to <code>setpgid(0,0)</code>. Not available on all
- * platforms.
+ * Equivalent to <tt>setpgid(0, 0)</tt>.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -5012,12 +5041,13 @@ proc_setpgrp(VALUE _)
#if defined(HAVE_GETPGID)
/*
* call-seq:
- * Process.getpgid(pid) -> integer
+ * Process.getpgid(pid) -> integer
*
- * Returns the process group ID for the given process id. Not
- * available on all platforms.
+ * Returns the process group ID for the given process ID +pid+:
+ *
+ * Process.getpgid(Process.ppid) # => 25527
*
- * Process.getpgid(Process.ppid()) #=> 25527
+ * Not available on all platforms.
*/
static VALUE
@@ -5037,10 +5067,12 @@ proc_getpgid(VALUE obj, VALUE pid)
#ifdef HAVE_SETPGID
/*
* call-seq:
- * Process.setpgid(pid, integer) -> 0
+ * Process.setpgid(pid, pgid) -> 0
*
- * Sets the process group ID of _pid_ (0 indicates this
- * process) to <em>integer</em>. Not available on all platforms.
+ * Sets the process group ID for the process given by process ID +pid+
+ * to +pgid+.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -5062,15 +5094,16 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
#ifdef HAVE_GETSID
/*
* call-seq:
- * Process.getsid() -> integer
- * Process.getsid(pid) -> integer
+ * Process.getsid(pid = nil) -> integer
*
- * Returns the session ID for the given process id. If not given,
- * return current process sid. Not available on all platforms.
+ * Returns the session ID of the given process ID +pid+,
+ * or of the current process if not given:
*
- * Process.getsid() #=> 27422
- * Process.getsid(0) #=> 27422
- * Process.getsid(Process.pid()) #=> 27422
+ * Process.getsid # => 27422
+ * Process.getsid(0) # => 27422
+ * Process.getsid(Process.pid()) # => 27422
+ *
+ * Not available on all platforms.
*/
static VALUE
proc_getsid(int argc, VALUE *argv, VALUE _)
@@ -5097,13 +5130,15 @@ static rb_pid_t ruby_setsid(void);
#endif
/*
* call-seq:
- * Process.setsid -> integer
+ * Process.setsid -> integer
*
- * Establishes this process as a new session and process group
- * leader, with no controlling tty. Returns the session id. Not
- * available on all platforms.
+ * Establishes the current process as a new session and process group leader,
+ * with no controlling tty;
+ * returns the session ID:
+ *
+ * Process.setsid # => 27422
*
- * Process.setsid #=> 27422
+ * Not available on all platforms.
*/
static VALUE
@@ -5122,7 +5157,7 @@ static rb_pid_t
ruby_setsid(void)
{
rb_pid_t pid;
- int ret;
+ int ret, fd;
pid = getpid();
#if defined(SETPGRP_VOID)
@@ -5151,19 +5186,26 @@ ruby_setsid(void)
#ifdef HAVE_GETPRIORITY
/*
* call-seq:
- * Process.getpriority(kind, integer) -> integer
- *
- * Gets the scheduling priority for specified process, process group,
- * or user. <em>kind</em> indicates the kind of entity to find: one
- * of Process::PRIO_PGRP,
- * Process::PRIO_USER, or
- * Process::PRIO_PROCESS. _integer_ is an id
- * indicating the particular process, process group, or user (an id
- * of 0 means _current_). Lower priorities are more favorable
- * for scheduling. Not available on all platforms.
- *
- * Process.getpriority(Process::PRIO_USER, 0) #=> 19
- * Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
+ * Process.getpriority(kind, id) -> integer
+ *
+ * Returns the scheduling priority for specified process, process group,
+ * or user.
+ *
+ * Argument +kind+ is one of:
+ *
+ * - Process::PRIO_PROCESS: return priority for process.
+ * - Process::PRIO_PGRP: return priority for process group.
+ * - Process::PRIO_USER: return priority for user.
+ *
+ * Argument +id+ is the ID for the process, process group, or user;
+ * zero specified the current ID for +kind+.
+ *
+ * Examples:
+ *
+ * Process.getpriority(Process::PRIO_USER, 0) # => 19
+ * Process.getpriority(Process::PRIO_PROCESS, 0) # => 19
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -5187,14 +5229,18 @@ proc_getpriority(VALUE obj, VALUE which, VALUE who)
#ifdef HAVE_GETPRIORITY
/*
* call-seq:
- * Process.setpriority(kind, integer, priority) -> 0
+ * Process.setpriority(kind, integer, priority) -> 0
*
* See Process.getpriority.
*
- * Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0
- * Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0
- * Process.getpriority(Process::PRIO_USER, 0) #=> 19
- * Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19
+ * Examples:
+ *
+ * Process.setpriority(Process::PRIO_USER, 0, 19) # => 0
+ * Process.setpriority(Process::PRIO_PROCESS, 0, 19) # => 0
+ * Process.getpriority(Process::PRIO_USER, 0) # => 19
+ * Process.getpriority(Process::PRIO_PROCESS, 0) # => 19
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -5442,22 +5488,24 @@ rlimit_resource_value(VALUE rval)
#if defined(HAVE_GETRLIMIT) && defined(RLIM2NUM)
/*
* call-seq:
- * Process.getrlimit(resource) -> [cur_limit, max_limit]
- *
- * Gets the resource limit of the process.
- * _cur_limit_ means current (soft) limit and
- * _max_limit_ means maximum (hard) limit.
- *
- * _resource_ indicates the kind of resource to limit.
- * It is specified as a symbol such as <code>:CORE</code>,
- * a string such as <code>"CORE"</code> or
- * a constant such as Process::RLIMIT_CORE.
- * See Process.setrlimit for details.
- *
- * _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY,
- * Process::RLIM_SAVED_MAX or
- * Process::RLIM_SAVED_CUR.
- * See Process.setrlimit and the system getrlimit(2) manual for details.
+ * Process.getrlimit(resource) -> [cur_limit, max_limit]
+ *
+ * Returns a 2-element array of the current (soft) limit
+ * and maximum (hard) limit for the given +resource+.
+ *
+ * Argument +resource+ specifies the resource whose limits are to be returned;
+ * see Process.setrlimit.
+ *
+ * Each of the returned values +cur_limit+ and +max_limit+ is an integer;
+ * see Process.setrlimit.
+ *
+ * Example:
+ *
+ * Process.getrlimit(:CORE) # => [0, 18446744073709551615]
+ *
+ * See Process.setrlimit.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -5477,54 +5525,54 @@ proc_getrlimit(VALUE obj, VALUE resource)
#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
/*
* call-seq:
- * Process.setrlimit(resource, cur_limit, max_limit) -> nil
- * Process.setrlimit(resource, cur_limit) -> nil
- *
- * Sets the resource limit of the process.
- * _cur_limit_ means current (soft) limit and
- * _max_limit_ means maximum (hard) limit.
- *
- * If _max_limit_ is not given, _cur_limit_ is used.
- *
- * _resource_ indicates the kind of resource to limit.
- * It should be a symbol such as <code>:CORE</code>,
- * a string such as <code>"CORE"</code> or
- * a constant such as Process::RLIMIT_CORE.
- * The available resources are OS dependent.
- * Ruby may support following resources.
- *
- * [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
- * [CORE] core size (bytes) (SUSv3)
- * [CPU] CPU time (seconds) (SUSv3)
- * [DATA] data segment (bytes) (SUSv3)
- * [FSIZE] file size (bytes) (SUSv3)
- * [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
- * [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux)
- * [NICE] ceiling on process's nice(2) value (number) (GNU/Linux)
- * [NOFILE] file descriptors (number) (SUSv3)
- * [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux)
- * [NPTS] number of pseudo terminals (number) (FreeBSD)
- * [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux)
- * [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux)
- * [RTTIME] CPU time for real-time process (us) (GNU/Linux)
- * [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD)
- * [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux)
- * [STACK] stack size (bytes) (SUSv3)
- *
- * _cur_limit_ and _max_limit_ may be
- * <code>:INFINITY</code>, <code>"INFINITY"</code> or
- * Process::RLIM_INFINITY,
- * which means that the resource is not limited.
- * They may be Process::RLIM_SAVED_MAX,
- * Process::RLIM_SAVED_CUR and
- * corresponding symbols and strings too.
- * See system setrlimit(2) manual for details.
- *
- * The following example raises the soft limit of core size to
- * the hard limit to try to make core dump possible.
+ * Process.setrlimit(resource, cur_limit, max_limit = cur_limit) -> nil
+ *
+ * Sets limits for the current process for the given +resource+
+ * to +cur_limit+ (soft limit) and +max_limit+ (hard limit);
+ * returns +nil+.
+ *
+ * Argument +resource+ specifies the resource whose limits are to be set;
+ * the argument may be given as a symbol, as a string, or as a constant
+ * beginning with <tt>Process::RLIMIT_</tt>
+ * (e.g., +:CORE+, <tt>'CORE'</tt>, or <tt>Process::RLIMIT_CORE</tt>.
+ *
+ * The resources available and supported are system-dependent,
+ * and may include (here expressed as symbols):
+ *
+ * - +:AS+: Total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD except 4.4BSD-Lite).
+ * - +:CORE+: Core size (bytes) (SUSv3).
+ * - +:CPU+: CPU time (seconds) (SUSv3).
+ * - +:DATA+: Data segment (bytes) (SUSv3).
+ * - +:FSIZE+: File size (bytes) (SUSv3).
+ * - +:MEMLOCK+: Total size for mlock(2) (bytes) (4.4BSD, GNU/Linux).
+ * - +:MSGQUEUE+: Allocation for POSIX message queues (bytes) (GNU/Linux).
+ * - +:NICE+: Ceiling on process's nice(2) value (number) (GNU/Linux).
+ * - +:NOFILE+: File descriptors (number) (SUSv3).
+ * - +:NPROC+: Number of processes for the user (number) (4.4BSD, GNU/Linux).
+ * - +:NPTS+: Number of pseudo terminals (number) (FreeBSD).
+ * - +:RSS+: Resident memory size (bytes) (4.2BSD, GNU/Linux).
+ * - +:RTPRIO+: Ceiling on the process's real-time priority (number) (GNU/Linux).
+ * - +:RTTIME+: CPU time for real-time process (us) (GNU/Linux).
+ * - +:SBSIZE+: All socket buffers (bytes) (NetBSD, FreeBSD).
+ * - +:SIGPENDING+: Number of queued signals allowed (signals) (GNU/Linux).
+ * - +:STACK+: Stack size (bytes) (SUSv3).
+ *
+ * Arguments +cur_limit+ and +max_limit+ may be:
+ *
+ * - Integers (+max_limit+ should not be smaller than +cur_limit+).
+ * - Symbol +:SAVED_MAX+, string <tt>'SAVED_MAX'</tt>,
+ * or constant <tt>Process::RLIM_SAVED_MAX</tt>: saved maximum limit.
+ * - Symbol +:SAVED_CUR+, string <tt>'SAVED_CUR'</tt>,
+ * or constant <tt>Process::RLIM_SAVED_CUR</tt>: saved current limit.
+ * - Symbol +:INFINITY+, string <tt>'INFINITY'</tt>,
+ * or constant <tt>Process::RLIM_INFINITY</tt>: no limit on resource.
+ *
+ * This example raises the soft limit of core size to
+ * the hard limit to try to make core dump possible:
*
* Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
*
+ * Not available on all platforms.
*/
static VALUE
@@ -5571,6 +5619,12 @@ check_gid_switch(void)
#if defined(HAVE_PWD_H)
+static inline bool
+login_not_found(int err)
+{
+ return (err == ENOTTY || err == ENXIO || err == ENOENT);
+}
+
/**
* Best-effort attempt to obtain the name of the login user, if any,
* associated with the process. Processes not descended from login(1) (or
@@ -5579,18 +5633,18 @@ check_gid_switch(void)
VALUE
rb_getlogin(void)
{
-#if ( !defined(USE_GETLOGIN_R) && !defined(USE_GETLOGIN) )
+# if !defined(USE_GETLOGIN_R) && !defined(USE_GETLOGIN)
return Qnil;
-#else
+# else
char MAYBE_UNUSED(*login) = NULL;
# ifdef USE_GETLOGIN_R
-#if defined(__FreeBSD__)
+# if defined(__FreeBSD__)
typedef int getlogin_r_size_t;
-#else
+# else
typedef size_t getlogin_r_size_t;
-#endif
+# endif
long loginsize = GETLOGIN_R_SIZE_INIT; /* maybe -1 */
@@ -5604,10 +5658,8 @@ rb_getlogin(void)
rb_str_set_len(maybe_result, loginsize);
int gle;
- errno = 0;
while ((gle = getlogin_r(login, (getlogin_r_size_t)loginsize)) != 0) {
-
- if (gle == ENOTTY || gle == ENXIO || gle == ENOENT) {
+ if (login_not_found(gle)) {
rb_str_resize(maybe_result, 0);
return Qnil;
}
@@ -5627,17 +5679,19 @@ rb_getlogin(void)
return Qnil;
}
+ rb_str_set_len(maybe_result, strlen(login));
return maybe_result;
-# elif USE_GETLOGIN
+# elif defined(USE_GETLOGIN)
errno = 0;
login = getlogin();
- if (errno) {
- if (errno == ENOTTY || errno == ENXIO || errno == ENOENT) {
+ int err = errno;
+ if (err) {
+ if (login_not_found(err)) {
return Qnil;
}
- rb_syserr_fail(errno, "getlogin");
+ rb_syserr_fail(err, "getlogin");
}
return login ? rb_str_new_cstr(login) : Qnil;
@@ -5646,10 +5700,46 @@ rb_getlogin(void)
#endif
}
+/* avoid treating as errors errno values that indicate "not found" */
+static inline bool
+pwd_not_found(int err)
+{
+ switch (err) {
+ case 0:
+ case ENOENT:
+ case ESRCH:
+ case EBADF:
+ case EPERM:
+ return true;
+ default:
+ return false;
+ }
+}
+
+# if defined(USE_GETPWNAM_R)
+struct getpwnam_r_args {
+ const char *login;
+ char *buf;
+ size_t bufsize;
+ struct passwd *result;
+ struct passwd pwstore;
+};
+
+# define GETPWNAM_R_ARGS(login_, buf_, bufsize_) (struct getpwnam_r_args) \
+ {.login = login_, .buf = buf_, .bufsize = bufsize_, .result = NULL}
+
+static void *
+nogvl_getpwnam_r(void *args)
+{
+ struct getpwnam_r_args *arg = args;
+ return (void *)(VALUE)getpwnam_r(arg->login, &arg->pwstore, arg->buf, arg->bufsize, &arg->result);
+}
+# endif
+
VALUE
rb_getpwdirnam_for_login(VALUE login_name)
{
-#if ( !defined(USE_GETPWNAM_R) && !defined(USE_GETPWNAM) )
+#if !defined(USE_GETPWNAM_R) && !defined(USE_GETPWNAM)
return Qnil;
#else
@@ -5658,13 +5748,11 @@ rb_getpwdirnam_for_login(VALUE login_name)
return Qnil;
}
- char *login = RSTRING_PTR(login_name);
+ const char *login = RSTRING_PTR(login_name);
- struct passwd *pwptr;
# ifdef USE_GETPWNAM_R
- struct passwd pwdnm;
char *bufnm;
long bufsizenm = GETPW_R_SIZE_INIT; /* maybe -1 */
@@ -5676,58 +5764,77 @@ rb_getpwdirnam_for_login(VALUE login_name)
bufnm = RSTRING_PTR(getpwnm_tmp);
bufsizenm = rb_str_capacity(getpwnm_tmp);
rb_str_set_len(getpwnm_tmp, bufsizenm);
+ struct getpwnam_r_args args = GETPWNAM_R_ARGS(login, bufnm, (size_t)bufsizenm);
int enm;
- errno = 0;
- while ((enm = getpwnam_r(login, &pwdnm, bufnm, bufsizenm, &pwptr)) != 0) {
-
- if (enm == ENOENT || enm== ESRCH || enm == EBADF || enm == EPERM) {
- /* not found; non-errors */
+ while ((enm = IO_WITHOUT_GVL_INT(nogvl_getpwnam_r, &args)) != 0) {
+ if (pwd_not_found(enm)) {
rb_str_resize(getpwnm_tmp, 0);
return Qnil;
}
- if (enm != ERANGE || bufsizenm >= GETPW_R_SIZE_LIMIT) {
+ if (enm != ERANGE || args.bufsize >= GETPW_R_SIZE_LIMIT) {
rb_str_resize(getpwnm_tmp, 0);
rb_syserr_fail(enm, "getpwnam_r");
}
- rb_str_modify_expand(getpwnm_tmp, bufsizenm);
- bufnm = RSTRING_PTR(getpwnm_tmp);
- bufsizenm = rb_str_capacity(getpwnm_tmp);
+ rb_str_modify_expand(getpwnm_tmp, (long)args.bufsize);
+ args.buf = RSTRING_PTR(getpwnm_tmp);
+ args.bufsize = (size_t)rb_str_capacity(getpwnm_tmp);
}
- if (pwptr == NULL) {
+ if (args.result == NULL) {
/* no record in the password database for the login name */
rb_str_resize(getpwnm_tmp, 0);
return Qnil;
}
/* found it */
- VALUE result = rb_str_new_cstr(pwptr->pw_dir);
+ VALUE result = rb_str_new_cstr(args.result->pw_dir);
rb_str_resize(getpwnm_tmp, 0);
return result;
-# elif USE_GETPWNAM
+# elif defined(USE_GETPWNAM)
+ struct passwd *pwptr;
errno = 0;
- pwptr = getpwnam(login);
- if (pwptr) {
- /* found it */
- return rb_str_new_cstr(pwptr->pw_dir);
- }
- if (errno
- /* avoid treating as errors errno values that indicate "not found" */
- && ( errno != ENOENT && errno != ESRCH && errno != EBADF && errno != EPERM)) {
- rb_syserr_fail(errno, "getpwnam");
+ if (!(pwptr = getpwnam(login))) {
+ int err = errno;
+
+ if (pwd_not_found(err)) {
+ return Qnil;
+ }
+
+ rb_syserr_fail(err, "getpwnam");
}
- return Qnil; /* not found */
+ /* found it */
+ return rb_str_new_cstr(pwptr->pw_dir);
# endif
#endif
}
+# if defined(USE_GETPWUID_R)
+struct getpwuid_r_args {
+ uid_t uid;
+ char *buf;
+ size_t bufsize;
+ struct passwd *result;
+ struct passwd pwstore;
+};
+
+# define GETPWUID_R_ARGS(uid_, buf_, bufsize_) (struct getpwuid_r_args) \
+ {.uid = uid_, .buf = buf_, .bufsize = bufsize_, .result = NULL}
+
+static void *
+nogvl_getpwuid_r(void *args)
+{
+ struct getpwuid_r_args *arg = args;
+ return (void *)(VALUE)getpwuid_r(arg->uid, &arg->pwstore, arg->buf, arg->bufsize, &arg->result);
+}
+# endif
+
/**
* Look up the user's dflt home dir in the password db, by uid.
*/
@@ -5740,11 +5847,8 @@ rb_getpwdiruid(void)
# else
uid_t ruid = getuid();
- struct passwd *pwptr;
-
# ifdef USE_GETPWUID_R
- struct passwd pwdid;
char *bufid;
long bufsizeid = GETPW_R_SIZE_INIT; /* maybe -1 */
@@ -5756,53 +5860,52 @@ rb_getpwdiruid(void)
bufid = RSTRING_PTR(getpwid_tmp);
bufsizeid = rb_str_capacity(getpwid_tmp);
rb_str_set_len(getpwid_tmp, bufsizeid);
+ struct getpwuid_r_args args = GETPWUID_R_ARGS(ruid, bufid, (size_t)bufsizeid);
int eid;
- errno = 0;
- while ((eid = getpwuid_r(ruid, &pwdid, bufid, bufsizeid, &pwptr)) != 0) {
-
- if (eid == ENOENT || eid== ESRCH || eid == EBADF || eid == EPERM) {
- /* not found; non-errors */
+ while ((eid = IO_WITHOUT_GVL_INT(nogvl_getpwuid_r, &args)) != 0) {
+ if (pwd_not_found(eid)) {
rb_str_resize(getpwid_tmp, 0);
return Qnil;
}
- if (eid != ERANGE || bufsizeid >= GETPW_R_SIZE_LIMIT) {
+ if (eid != ERANGE || args.bufsize >= GETPW_R_SIZE_LIMIT) {
rb_str_resize(getpwid_tmp, 0);
rb_syserr_fail(eid, "getpwuid_r");
}
- rb_str_modify_expand(getpwid_tmp, bufsizeid);
- bufid = RSTRING_PTR(getpwid_tmp);
- bufsizeid = rb_str_capacity(getpwid_tmp);
+ rb_str_modify_expand(getpwid_tmp, (long)args.bufsize);
+ args.buf = RSTRING_PTR(getpwid_tmp);
+ args.bufsize = (size_t)rb_str_capacity(getpwid_tmp);
}
- if (pwptr == NULL) {
+ if (args.result == NULL) {
/* no record in the password database for the uid */
rb_str_resize(getpwid_tmp, 0);
return Qnil;
}
/* found it */
- VALUE result = rb_str_new_cstr(pwptr->pw_dir);
+ VALUE result = rb_str_new_cstr(args.result->pw_dir);
rb_str_resize(getpwid_tmp, 0);
return result;
# elif defined(USE_GETPWUID)
+ struct passwd *pwptr;
errno = 0;
- pwptr = getpwuid(ruid);
- if (pwptr) {
- /* found it */
- return rb_str_new_cstr(pwptr->pw_dir);
- }
- if (errno
- /* avoid treating as errors errno values that indicate "not found" */
- && ( errno == ENOENT || errno == ESRCH || errno == EBADF || errno == EPERM)) {
- rb_syserr_fail(errno, "getpwuid");
+ if (!(pwptr = getpwuid(ruid))) {
+ int err = errno;
+
+ if (pwd_not_found(err)) {
+ return Qnil;
+ }
+
+ rb_syserr_fail(err, "getpwuid");
}
- return Qnil; /* not found */
+ /* found it */
+ return rb_str_new_cstr(pwptr->pw_dir);
# endif
#endif /* !defined(USE_GETPWUID_R) && !defined(USE_GETPWUID) */
@@ -5816,7 +5919,7 @@ rb_getpwdiruid(void)
* The Process::Sys module contains UID and GID
* functions which provide direct bindings to the system calls of the
* same names instead of the more-portable versions of the same
- * functionality found in the Process,
+ * functionality found in the +Process+,
* Process::UID, and Process::GID modules.
*/
@@ -5838,7 +5941,6 @@ obj2uid(VALUE id
const char *usrname = StringValueCStr(id);
struct passwd *pwptr;
#ifdef USE_GETPWNAM_R
- struct passwd pwbuf;
char *getpw_buf;
long getpw_buf_len;
int e;
@@ -5851,15 +5953,18 @@ obj2uid(VALUE id
getpw_buf_len = rb_str_capacity(*getpw_tmp);
rb_str_set_len(*getpw_tmp, getpw_buf_len);
errno = 0;
- while ((e = getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) != 0) {
- if (e != ERANGE || getpw_buf_len >= GETPW_R_SIZE_LIMIT) {
+ struct getpwnam_r_args args = GETPWNAM_R_ARGS((char *)usrname, getpw_buf, (size_t)getpw_buf_len);
+
+ while ((e = IO_WITHOUT_GVL_INT(nogvl_getpwnam_r, &args)) != 0) {
+ if (e != ERANGE || args.bufsize >= GETPW_R_SIZE_LIMIT) {
rb_str_resize(*getpw_tmp, 0);
rb_syserr_fail(e, "getpwnam_r");
}
- rb_str_modify_expand(*getpw_tmp, getpw_buf_len);
- getpw_buf = RSTRING_PTR(*getpw_tmp);
- getpw_buf_len = rb_str_capacity(*getpw_tmp);
+ rb_str_modify_expand(*getpw_tmp, (long)args.bufsize);
+ args.buf = RSTRING_PTR(*getpw_tmp);
+ args.bufsize = (size_t)rb_str_capacity(*getpw_tmp);
}
+ pwptr = args.result;
#else
pwptr = getpwnam(usrname);
#endif
@@ -5898,6 +6003,26 @@ p_uid_from_name(VALUE self, VALUE id)
#endif
#if defined(HAVE_GRP_H)
+# if defined(USE_GETGRNAM_R)
+struct getgrnam_r_args {
+ const char *name;
+ char *buf;
+ size_t bufsize;
+ struct group *result;
+ struct group grp;
+};
+
+# define GETGRNAM_R_ARGS(name_, buf_, bufsize_) (struct getgrnam_r_args) \
+ {.name = name_, .buf = buf_, .bufsize = bufsize_, .result = NULL}
+
+static void *
+nogvl_getgrnam_r(void *args)
+{
+ struct getgrnam_r_args *arg = args;
+ return (void *)(VALUE)getgrnam_r(arg->name, &arg->grp, arg->buf, arg->bufsize, &arg->result);
+}
+# endif
+
static rb_gid_t
obj2gid(VALUE id
# ifdef USE_GETGRNAM_R
@@ -5915,7 +6040,6 @@ obj2gid(VALUE id
const char *grpname = StringValueCStr(id);
struct group *grptr;
#ifdef USE_GETGRNAM_R
- struct group grbuf;
char *getgr_buf;
long getgr_buf_len;
int e;
@@ -5928,15 +6052,18 @@ obj2gid(VALUE id
getgr_buf_len = rb_str_capacity(*getgr_tmp);
rb_str_set_len(*getgr_tmp, getgr_buf_len);
errno = 0;
- while ((e = getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) != 0) {
- if (e != ERANGE || getgr_buf_len >= GETGR_R_SIZE_LIMIT) {
+ struct getgrnam_r_args args = GETGRNAM_R_ARGS(grpname, getgr_buf, (size_t)getgr_buf_len);
+
+ while ((e = IO_WITHOUT_GVL_INT(nogvl_getgrnam_r, &args)) != 0) {
+ if (e != ERANGE || args.bufsize >= GETGR_R_SIZE_LIMIT) {
rb_str_resize(*getgr_tmp, 0);
rb_syserr_fail(e, "getgrnam_r");
}
- rb_str_modify_expand(*getgr_tmp, getgr_buf_len);
- getgr_buf = RSTRING_PTR(*getgr_tmp);
- getgr_buf_len = rb_str_capacity(*getgr_tmp);
+ rb_str_modify_expand(*getgr_tmp, (long)args.bufsize);
+ args.buf = RSTRING_PTR(*getgr_tmp);
+ args.bufsize = (size_t)rb_str_capacity(*getgr_tmp);
}
+ grptr = args.result;
#elif defined(HAVE_GETGRNAM)
grptr = getgrnam(grpname);
#else
@@ -6103,13 +6230,14 @@ p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
/*
* call-seq:
- * Process.uid -> integer
- * Process::UID.rid -> integer
- * Process::Sys.getuid -> integer
+ * Process.uid -> integer
+ * Process::UID.rid -> integer
+ * Process::Sys.getuid -> integer
*
- * Returns the (real) user ID of this process.
+ * Returns the (real) user ID of the current process.
+ *
+ * Process.uid # => 1000
*
- * Process.uid #=> 501
*/
static VALUE
@@ -6123,10 +6251,13 @@ proc_getuid(VALUE obj)
#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRUID) || defined(HAVE_SETUID)
/*
* call-seq:
- * Process.uid= user -> numeric
+ * Process.uid = new_uid -> new_uid
+ *
+ * Sets the (user) user ID for the current process to +new_uid+:
*
- * Sets the (user) user ID for this process. Not available on all
- * platforms.
+ * Process.uid = 1000 # => 1000
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -6501,13 +6632,14 @@ p_sys_issetugid(VALUE obj)
/*
* call-seq:
- * Process.gid -> integer
- * Process::GID.rid -> integer
- * Process::Sys.getgid -> integer
+ * Process.gid -> integer
+ * Process::GID.rid -> integer
+ * Process::Sys.getgid -> integer
*
- * Returns the (real) group ID for this process.
+ * Returns the (real) group ID for the current process:
+ *
+ * Process.gid # => 1000
*
- * Process.gid #=> 500
*/
static VALUE
@@ -6521,9 +6653,12 @@ proc_getgid(VALUE obj)
#if defined(HAVE_SETRESGID) || defined(HAVE_SETREGID) || defined(HAVE_SETRGID) || defined(HAVE_SETGID)
/*
* call-seq:
- * Process.gid= integer -> integer
+ * Process.gid = new_gid -> new_gid
+ *
+ * Sets the group ID for the current process to +new_gid+:
+ *
+ * Process.gid = 1000 # => 1000
*
- * Sets the group ID for this process.
*/
static VALUE
@@ -6607,26 +6742,23 @@ maxgroups(void)
#ifdef HAVE_GETGROUPS
/*
* call-seq:
- * Process.groups -> array
+ * Process.groups -> array
*
- * Get an Array of the group IDs in the
- * supplemental group access list for this process.
+ * Returns an array of the group IDs
+ * in the supplemental group access list for the current process:
*
- * Process.groups #=> [27, 6, 10, 11]
+ * Process.groups # => [4, 24, 27, 30, 46, 122, 135, 136, 1000]
*
- * Note that this method is just a wrapper of getgroups(2).
- * This means that the following characteristics of
- * the result completely depend on your system:
+ * These properties of the returned array are system-dependent:
*
- * - the result is sorted
- * - the result includes effective GIDs
- * - the result does not include duplicated GIDs
- * - the result size does not exceed the value of Process.maxgroups
+ * - Whether (and how) the array is sorted.
+ * - Whether the array includes effective group IDs.
+ * - Whether the array includes duplicate group IDs.
+ * - Whether the array size exceeds the value of Process.maxgroups.
*
- * You can make sure to get a sorted unique GID list of
- * the current process by this expression:
+ * Use this call to get a sorted and unique array:
*
- * Process.groups.uniq.sort
+ * Process.groups.uniq.sort
*
*/
@@ -6663,14 +6795,14 @@ proc_getgroups(VALUE obj)
#ifdef HAVE_SETGROUPS
/*
* call-seq:
- * Process.groups= array -> array
+ * Process.groups = new_groups -> new_groups
*
- * Set the supplemental group access list to the given
- * Array of group IDs.
+ * Sets the supplemental group access list to the given
+ * array of group IDs.
*
- * Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
- * Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11]
- * Process.groups #=> [27, 6, 10, 11]
+ * Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
+ * Process.groups = [27, 6, 10, 11] # => [27, 6, 10, 11]
+ * Process.groups # => [27, 6, 10, 11]
*
*/
@@ -6712,19 +6844,21 @@ proc_setgroups(VALUE obj, VALUE ary)
#ifdef HAVE_INITGROUPS
/*
* call-seq:
- * Process.initgroups(username, gid) -> array
+ * Process.initgroups(username, gid) -> array
+ *
+ * Sets the supplemental group access list;
+ * the new list includes:
*
- * Initializes the supplemental group access list by reading the
- * system group database and using all groups of which the given user
- * is a member. The group with the specified _gid_ is also added to
- * the list. Returns the resulting Array of the GIDs of all the
- * groups in the supplementary group access list. Not available on
- * all platforms.
+ * - The group IDs of those groups to which the user given by +username+ belongs.
+ * - The group ID +gid+.
*
- * Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
- * Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11]
- * Process.groups #=> [30, 6, 10, 11]
+ * Example:
*
+ * Process.groups # => [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
+ * Process.initgroups('me', 30) # => [30, 6, 10, 11]
+ * Process.groups # => [30, 6, 10, 11]
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -6742,12 +6876,13 @@ proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
#if defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX)
/*
* call-seq:
- * Process.maxgroups -> integer
+ * Process.maxgroups -> integer
*
- * Returns the maximum number of GIDs allowed in the supplemental
- * group access list.
+ * Returns the maximum number of group IDs allowed
+ * in the supplemental group access list:
+ *
+ * Process.maxgroups # => 32
*
- * Process.maxgroups #=> 32
*/
static VALUE
@@ -6762,10 +6897,10 @@ proc_getmaxgroups(VALUE obj)
#ifdef HAVE_SETGROUPS
/*
* call-seq:
- * Process.maxgroups= integer -> integer
+ * Process.maxgroups = new_max -> new_max
*
- * Sets the maximum number of GIDs allowed in the supplemental group
- * access list.
+ * Sets the maximum number of group IDs allowed
+ * in the supplemental group access list.
*/
static VALUE
@@ -6796,16 +6931,22 @@ static int rb_daemon(int nochdir, int noclose);
/*
* call-seq:
- * Process.daemon() -> 0
- * Process.daemon(nochdir=nil,noclose=nil) -> 0
- *
- * 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.
- * Return zero on success, or raise one of Errno::*.
+ * Process.daemon(nochdir = nil, noclose = nil) -> 0
+ *
+ * Detaches the current process from its controlling terminal
+ * and runs it in the background as system daemon;
+ * returns zero.
+ *
+ * By default:
+ *
+ * - Changes the current working directory to the root directory.
+ * - Redirects $stdin, $stdout, and $stderr to the null device.
+ *
+ * If optional argument +nochdir+ is +true+,
+ * does not change the current working directory.
+ *
+ * If optional argument +noclose+ is +true+,
+ * does not redirect $stdin, $stdout, or $stderr.
*/
static VALUE
@@ -6824,6 +6965,8 @@ proc_daemon(int argc, VALUE *argv, VALUE _)
return INT2FIX(n);
}
+extern const char ruby_null_device[];
+
static int
rb_daemon(int nochdir, int noclose)
{
@@ -6831,8 +6974,7 @@ rb_daemon(int nochdir, int noclose)
#ifdef HAVE_DAEMON
before_fork_ruby();
err = daemon(nochdir, noclose);
- after_fork_ruby();
- rb_thread_atfork();
+ after_fork_ruby(0);
#else
int n;
@@ -6848,7 +6990,7 @@ rb_daemon(int nochdir, int noclose)
if (!nochdir)
err = chdir("/");
- if (!noclose && (n = rb_cloexec_open("/dev/null", O_RDWR, 0)) != -1) {
+ if (!noclose && (n = rb_cloexec_open(ruby_null_device, O_RDWR, 0)) != -1) {
rb_update_max_fd(n);
(void)dup2(n, 0);
(void)dup2(n, 1);
@@ -7061,13 +7203,14 @@ p_gid_change_privilege(VALUE obj, VALUE id)
/*
* call-seq:
- * Process.euid -> integer
- * Process::UID.eid -> integer
- * Process::Sys.geteuid -> integer
+ * Process.euid -> integer
+ * Process::UID.eid -> integer
+ * Process::Sys.geteuid -> integer
+ *
+ * Returns the effective user ID for the current process.
*
- * Returns the effective user ID for this process.
+ * Process.euid # => 501
*
- * Process.euid #=> 501
*/
static VALUE
@@ -7103,10 +7246,11 @@ proc_seteuid(rb_uid_t uid)
#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID)
/*
* call-seq:
- * Process.euid= user
+ * Process.euid = new_euid -> new_euid
*
- * Sets the effective user ID for this process. Not available on all
- * platforms.
+ * Sets the effective user ID for the current process.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -7184,14 +7328,15 @@ p_uid_grant_privilege(VALUE obj, VALUE id)
/*
* call-seq:
- * Process.egid -> integer
- * Process::GID.eid -> integer
- * Process::Sys.geteid -> integer
+ * Process.egid -> integer
+ * Process::GID.eid -> integer
+ * Process::Sys.geteid -> integer
*
- * Returns the effective group ID for this process. Not available on
- * all platforms.
+ * Returns the effective group ID for the current process:
*
- * Process.egid #=> 500
+ * Process.egid # => 500
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -7205,10 +7350,11 @@ proc_getegid(VALUE obj)
#if defined(HAVE_SETRESGID) || defined(HAVE_SETREGID) || defined(HAVE_SETEGID) || defined(HAVE_SETGID) || defined(_POSIX_SAVED_IDS)
/*
* call-seq:
- * Process.egid = integer -> integer
+ * Process.egid = new_egid -> new_egid
*
- * Sets the effective group ID for this process. Not available on all
- * platforms.
+ * Sets the effective group ID for the current process.
+ *
+ * Not available on all platforms.
*/
static VALUE
@@ -7681,14 +7827,15 @@ get_clk_tck(void)
/*
* call-seq:
- * Process.times -> aProcessTms
+ * Process.times -> process_tms
*
- * Returns a <code>Tms</code> structure (see Process::Tms)
- * that contains user and system CPU times for this process,
- * and also for children processes.
+ * Returns a Process::Tms structure that contains user and system CPU times
+ * for the current process, and for its children processes:
*
- * t = Process.times
- * [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00]
+ * Process.times
+ * # => #<struct Process::Tms utime=55.122118, stime=35.533068, cutime=0.0, cstime=0.002846>
+ *
+ * The precision is platform-defined.
*/
VALUE
@@ -7943,132 +8090,174 @@ ruby_real_ms_time(void)
# define NUM2CLOCKID(x) 0
#endif
+#define clock_failed(name, err, arg) do { \
+ int clock_error = (err); \
+ rb_syserr_fail_str(clock_error, rb_sprintf("clock_" name "(%+"PRIsVALUE")", (arg))); \
+ } while (0)
+
/*
* call-seq:
- * Process.clock_gettime(clock_id [, unit]) -> number
- *
- * Returns a time returned by POSIX clock_gettime() function.
- *
- * p Process.clock_gettime(Process::CLOCK_MONOTONIC)
- * #=> 896053.968060096
- *
- * +clock_id+ specifies a kind of clock.
- * It is specified as a constant which begins with <code>Process::CLOCK_</code>
- * such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC.
- *
- * The supported constants depends on OS and version.
- * Ruby provides following types of +clock_id+ if available.
- *
- * [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012
- * [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000
- * [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12
- * [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12
- * [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1
- * [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1
- * [CLOCK_REALTIME_FAST] FreeBSD 8.1
- * [CLOCK_REALTIME_PRECISE] FreeBSD 8.1
- * [CLOCK_REALTIME_COARSE] Linux 2.6.32
- * [CLOCK_REALTIME_ALARM] Linux 3.0
- * [CLOCK_MONOTONIC_FAST] FreeBSD 8.1
- * [CLOCK_MONOTONIC_PRECISE] FreeBSD 8.1
- * [CLOCK_MONOTONIC_COARSE] Linux 2.6.32
- * [CLOCK_MONOTONIC_RAW] Linux 2.6.28, macOS 10.12
- * [CLOCK_MONOTONIC_RAW_APPROX] macOS 10.12
- * [CLOCK_BOOTTIME] Linux 2.6.39
- * [CLOCK_BOOTTIME_ALARM] Linux 3.0
- * [CLOCK_UPTIME] FreeBSD 7.0, OpenBSD 5.5
- * [CLOCK_UPTIME_FAST] FreeBSD 8.1
- * [CLOCK_UPTIME_RAW] macOS 10.12
- * [CLOCK_UPTIME_RAW_APPROX] macOS 10.12
- * [CLOCK_UPTIME_PRECISE] FreeBSD 8.1
- * [CLOCK_SECOND] FreeBSD 8.1
- * [CLOCK_TAI] Linux 3.10
+ * Process.clock_gettime(clock_id, unit = :float_second) -> number
+ *
+ * Returns a clock time as determined by POSIX function
+ * {clock_gettime()}[https://man7.org/linux/man-pages/man3/clock_gettime.3.html]:
+ *
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID) # => 198.650379677
+ *
+ * Argument +clock_id+ should be a symbol or a constant that specifies
+ * the clock whose time is to be returned;
+ * see below.
+ *
+ * Optional argument +unit+ should be a symbol that specifies
+ * the unit to be used in the returned clock time;
+ * see below.
+ *
+ * <b>Argument +clock_id+</b>
+ *
+ * Argument +clock_id+ specifies the clock whose time is to be returned;
+ * it may be a constant such as <tt>Process::CLOCK_REALTIME</tt>,
+ * or a symbol shorthand such as +:CLOCK_REALTIME+.
+ *
+ * The supported clocks depend on the underlying operating system;
+ * this method supports the following clocks on the indicated platforms
+ * (raises Errno::EINVAL if called with an unsupported clock):
+ *
+ * - +:CLOCK_BOOTTIME+: Linux 2.6.39.
+ * - +:CLOCK_BOOTTIME_ALARM+: Linux 3.0.
+ * - +:CLOCK_MONOTONIC+: SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000.
+ * - +:CLOCK_MONOTONIC_COARSE+: Linux 2.6.32.
+ * - +:CLOCK_MONOTONIC_FAST+: FreeBSD 8.1.
+ * - +:CLOCK_MONOTONIC_PRECISE+: FreeBSD 8.1.
+ * - +:CLOCK_MONOTONIC_RAW+: Linux 2.6.28, macOS 10.12.
+ * - +:CLOCK_MONOTONIC_RAW_APPROX+: macOS 10.12.
+ * - +:CLOCK_PROCESS_CPUTIME_ID+: SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12.
+ * - +:CLOCK_PROF+: FreeBSD 3.0, OpenBSD 2.1.
+ * - +:CLOCK_REALTIME+: SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012.
+ * Time.now is recommended over +:CLOCK_REALTIME:.
+ * - +:CLOCK_REALTIME_ALARM+: Linux 3.0.
+ * - +:CLOCK_REALTIME_COARSE+: Linux 2.6.32.
+ * - +:CLOCK_REALTIME_FAST+: FreeBSD 8.1.
+ * - +:CLOCK_REALTIME_PRECISE+: FreeBSD 8.1.
+ * - +:CLOCK_SECOND+: FreeBSD 8.1.
+ * - +:CLOCK_TAI+: Linux 3.10.
+ * - +:CLOCK_THREAD_CPUTIME_ID+: SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12.
+ * - +:CLOCK_UPTIME+: FreeBSD 7.0, OpenBSD 5.5.
+ * - +:CLOCK_UPTIME_FAST+: FreeBSD 8.1.
+ * - +:CLOCK_UPTIME_PRECISE+: FreeBSD 8.1.
+ * - +:CLOCK_UPTIME_RAW+: macOS 10.12.
+ * - +:CLOCK_UPTIME_RAW_APPROX+: macOS 10.12.
+ * - +:CLOCK_VIRTUAL+: FreeBSD 3.0, OpenBSD 2.1.
*
* Note that SUS stands for Single Unix Specification.
* SUS contains POSIX and clock_gettime is defined in the POSIX part.
- * SUS defines CLOCK_REALTIME mandatory but
- * CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional.
- *
- * Also, several symbols are accepted as +clock_id+.
- * There are emulations for clock_gettime().
- *
- * For example, Process::CLOCK_REALTIME is defined as
- * +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available.
- *
- * Emulations for +CLOCK_REALTIME+:
- * [:GETTIMEOFDAY_BASED_CLOCK_REALTIME]
- * Use gettimeofday() defined by SUS.
- * (SUSv4 obsoleted it, though.)
- * The resolution is 1 microsecond.
- * [:TIME_BASED_CLOCK_REALTIME]
- * Use time() defined by ISO C.
- * The resolution is 1 second.
- *
- * Emulations for +CLOCK_MONOTONIC+:
- * [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC]
- * Use mach_absolute_time(), available on Darwin.
- * The resolution is CPU dependent.
- * [:TIMES_BASED_CLOCK_MONOTONIC]
- * Use the result value of times() defined by POSIX.
- * POSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)".
- * For example, GNU/Linux returns a value based on jiffies and it is monotonic.
- * However, 4.4BSD uses gettimeofday() and it is not monotonic.
- * (FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.)
- * The resolution is the clock tick.
- * "getconf CLK_TCK" command shows the clock ticks per second.
- * (The clock ticks per second is defined by HZ macro in older systems.)
- * If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and
- * cannot represent over 497 days.
- *
- * Emulations for +CLOCK_PROCESS_CPUTIME_ID+:
- * [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID]
- * Use getrusage() defined by SUS.
- * getrusage() is used with RUSAGE_SELF to obtain the time only for
- * the calling process (excluding the time for child processes).
- * The result is addition of user time (ru_utime) and system time (ru_stime).
- * The resolution is 1 microsecond.
- * [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID]
- * Use times() defined by POSIX.
- * The result is addition of user time (tms_utime) and system time (tms_stime).
- * tms_cutime and tms_cstime are ignored to exclude the time for child processes.
- * The resolution is the clock tick.
- * "getconf CLK_TCK" command shows the clock ticks per second.
- * (The clock ticks per second is defined by HZ macro in older systems.)
- * If it is 100, the resolution is 10 millisecond.
- * [:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID]
- * Use clock() defined by ISO C.
- * The resolution is 1/CLOCKS_PER_SEC.
- * CLOCKS_PER_SEC is the C-level macro defined by time.h.
- * SUS defines CLOCKS_PER_SEC is 1000000.
- * Non-Unix systems may define it a different value, though.
- * If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 microsecond.
- * If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer type, it cannot represent over 72 minutes.
- *
- * If the given +clock_id+ is not supported, Errno::EINVAL is raised.
- *
- * +unit+ specifies a type of the return value.
- *
- * [:float_second] number of seconds as a float (default)
- * [:float_millisecond] number of milliseconds as a float
- * [:float_microsecond] number of microseconds as a float
- * [:second] number of seconds as an integer
- * [:millisecond] number of milliseconds as an integer
- * [:microsecond] number of microseconds as an integer
- * [:nanosecond] number of nanoseconds as an integer
+ * SUS defines +:CLOCK_REALTIME+ as mandatory but
+ * +:CLOCK_MONOTONIC+, +:CLOCK_PROCESS_CPUTIME_ID+,
+ * and +:CLOCK_THREAD_CPUTIME_ID+ are optional.
+ *
+ * Certain emulations are used when the given +clock_id+
+ * is not supported directly:
+ *
+ * - Emulations for +:CLOCK_REALTIME+:
+ *
+ * - +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+:
+ * Use gettimeofday() defined by SUS (deprecated in SUSv4).
+ * The resolution is 1 microsecond.
+ * - +:TIME_BASED_CLOCK_REALTIME+:
+ * Use time() defined by ISO C.
+ * The resolution is 1 second.
+ *
+ * - Emulations for +:CLOCK_MONOTONIC+:
+ *
+ * - +:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC+:
+ * Use mach_absolute_time(), available on Darwin.
+ * The resolution is CPU dependent.
+ * - +:TIMES_BASED_CLOCK_MONOTONIC+:
+ * Use the result value of times() defined by POSIX, thus:
+ * >>>
+ * Upon successful completion, times() shall return the elapsed real time,
+ * in clock ticks, since an arbitrary point in the past
+ * (for example, system start-up time).
+ *
+ * For example, GNU/Linux returns a value based on jiffies and it is monotonic.
+ * However, 4.4BSD uses gettimeofday() and it is not monotonic.
+ * (FreeBSD uses +:CLOCK_MONOTONIC+ instead, though.)
+ *
+ * The resolution is the clock tick.
+ * "getconf CLK_TCK" command shows the clock ticks per second.
+ * (The clock ticks-per-second is defined by HZ macro in older systems.)
+ * If it is 100 and clock_t is 32 bits integer type,
+ * the resolution is 10 millisecond and cannot represent over 497 days.
+ *
+ * - Emulations for +:CLOCK_PROCESS_CPUTIME_ID+:
+ *
+ * - +:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID+:
+ * Use getrusage() defined by SUS.
+ * getrusage() is used with RUSAGE_SELF to obtain the time only for
+ * the calling process (excluding the time for child processes).
+ * The result is addition of user time (ru_utime) and system time (ru_stime).
+ * The resolution is 1 microsecond.
+ * - +:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID+:
+ * Use times() defined by POSIX.
+ * The result is addition of user time (tms_utime) and system time (tms_stime).
+ * tms_cutime and tms_cstime are ignored to exclude the time for child processes.
+ * The resolution is the clock tick.
+ * "getconf CLK_TCK" command shows the clock ticks per second.
+ * (The clock ticks per second is defined by HZ macro in older systems.)
+ * If it is 100, the resolution is 10 millisecond.
+ * - +:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID+:
+ * Use clock() defined by ISO C.
+ * The resolution is <tt>1/CLOCKS_PER_SEC</tt>.
+ * +CLOCKS_PER_SEC+ is the C-level macro defined by time.h.
+ * SUS defines +CLOCKS_PER_SEC+ as 1000000;
+ * other systems may define it differently.
+ * If +CLOCKS_PER_SEC+ is 1000000 (as in SUS),
+ * the resolution is 1 microsecond.
+ * If +CLOCKS_PER_SEC+ is 1000000 and clock_t is a 32-bit integer type,
+ * it cannot represent over 72 minutes.
+ *
+ * <b>Argument +unit+</b>
+ *
+ * Optional argument +unit+ (default +:float_second+)
+ * specifies the unit for the returned value.
+ *
+ * - +:float_microsecond+: Number of microseconds as a float.
+ * - +:float_millisecond+: Number of milliseconds as a float.
+ * - +:float_second+: Number of seconds as a float.
+ * - +:microsecond+: Number of microseconds as an integer.
+ * - +:millisecond+: Number of milliseconds as an integer.
+ * - +:nanosecond+: Number of nanoseconds as an integer.
+ * - +:second+: Number of seconds as an integer.
+ *
+ * Examples:
+ *
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond)
+ * # => 203605054.825
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond)
+ * # => 203643.696848
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :float_second)
+ * # => 203.762181929
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :microsecond)
+ * # => 204123212
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :millisecond)
+ * # => 204298
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond)
+ * # => 204602286036
+ * Process.clock_gettime(:CLOCK_PROCESS_CPUTIME_ID, :second)
+ * # => 204
*
* The underlying function, clock_gettime(), returns a number of nanoseconds.
* Float object (IEEE 754 double) is not enough to represent
- * the return value for CLOCK_REALTIME.
+ * the return value for +:CLOCK_REALTIME+.
* If the exact nanoseconds value is required, use +:nanosecond+ as the +unit+.
*
- * The origin (zero) of the returned value varies.
- * For example, system start up time, process start up time, the Epoch, etc.
+ * The origin (time zero) of the returned value is system-dependent,
+ * and may be, for example, system start up time,
+ * process start up time, the Epoch, etc.
*
- * The origin in CLOCK_REALTIME is defined as the Epoch
- * (1970-01-01 00:00:00 UTC).
- * But some systems count leap seconds and others doesn't.
- * So the result can be interpreted differently across systems.
- * Time.now is recommended over CLOCK_REALTIME.
+ * The origin in +:CLOCK_REALTIME+ is defined as the Epoch:
+ * <tt>1970-01-01 00:00:00 UTC</tt>;
+ * some systems count leap seconds and others don't,
+ * so the result may vary across systems.
*/
static VALUE
rb_clock_gettime(int argc, VALUE *argv, VALUE _)
@@ -8083,7 +8272,9 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
VALUE unit = (rb_check_arity(argc, 1, 2) == 2) ? argv[1] : Qnil;
VALUE clk_id = argv[0];
+#ifdef HAVE_CLOCK_GETTIME
clockid_t c;
+#endif
if (SYMBOL_P(clk_id)) {
#ifdef CLOCK_REALTIME
@@ -8243,15 +8434,17 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
gettime:
ret = clock_gettime(c, &ts);
if (ret == -1)
- rb_sys_fail("clock_gettime");
+ clock_failed("gettime", errno, clk_id);
tt.count = (int32_t)ts.tv_nsec;
tt.giga_count = ts.tv_sec;
denominators[num_denominators++] = 1000000000;
goto success;
#endif
}
- /* EINVAL emulates clock_gettime behavior when clock_id is invalid. */
- rb_syserr_fail(EINVAL, 0);
+ else {
+ rb_unexpected_type(clk_id, T_SYMBOL);
+ }
+ clock_failed("gettime", EINVAL, clk_id);
success:
return make_clock_result(&tt, numerators, num_numerators, denominators, num_denominators, unit);
@@ -8259,45 +8452,39 @@ rb_clock_gettime(int argc, VALUE *argv, VALUE _)
/*
* call-seq:
- * Process.clock_getres(clock_id [, unit]) -> number
+ * Process.clock_getres(clock_id, unit = :float_second) -> number
*
- * Returns an estimate of the resolution of a +clock_id+ using the POSIX
- * <code>clock_getres()</code> function.
+ * Returns a clock resolution as determined by POSIX function
+ * {clock_getres()}[https://man7.org/linux/man-pages/man3/clock_getres.3.html]:
*
- * Note the reported resolution is often inaccurate on most platforms due to
- * underlying bugs for this function and therefore the reported resolution
- * often differs from the actual resolution of the clock in practice.
- * Inaccurate reported resolutions have been observed for various clocks including
- * CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW when using Linux, macOS, BSD or AIX
- * platforms, when using ARM processors, or when using virtualization.
+ * Process.clock_getres(:CLOCK_REALTIME) # => 1.0e-09
*
- * +clock_id+ specifies a kind of clock.
- * See the document of +Process.clock_gettime+ for details.
- * +clock_id+ can be a symbol as for +Process.clock_gettime+.
+ * See Process.clock_gettime for the values of +clock_id+ and +unit+.
*
- * If the given +clock_id+ is not supported, Errno::EINVAL is raised.
+ * Examples:
*
- * +unit+ specifies the type of the return value.
- * +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+.
- * The default value, +:float_second+, is also the same as
- * +Process.clock_gettime+.
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond) # => 0.001
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond) # => 1.0e-06
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 1.0e-09
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :microsecond) # => 0
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :millisecond) # => 0
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond) # => 1
+ * Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :second) # => 0
*
- * +Process.clock_getres+ also accepts +:hertz+ as +unit+.
- * +:hertz+ means the reciprocal of +:float_second+.
+ * In addition to the values for +unit+ supported in Process.clock_gettime,
+ * this method supports +:hertz+, the integer number of clock ticks per second
+ * (which is the reciprocal of +:float_second+):
*
- * +:hertz+ can be used to obtain the exact value of
- * the clock ticks per second for the times() function and
- * CLOCKS_PER_SEC for the clock() function.
- *
- * <code>Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)</code>
- * returns the clock ticks per second.
- *
- * <code>Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)</code>
- * returns CLOCKS_PER_SEC.
- *
- * p Process.clock_getres(Process::CLOCK_MONOTONIC)
- * #=> 1.0e-09
+ * Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) # => 100.0
+ * Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 0.01
*
+ * <b>Accuracy</b>:
+ * Note that the returned resolution may be inaccurate on some platforms
+ * due to underlying bugs.
+ * Inaccurate resolutions have been reported for various clocks including
+ * +:CLOCK_MONOTONIC+ and +:CLOCK_MONOTONIC_RAW+
+ * on Linux, macOS, BSD or AIX platforms, when using ARM processors,
+ * or when using virtualization.
*/
static VALUE
rb_clock_getres(int argc, VALUE *argv, VALUE _)
@@ -8309,7 +8496,9 @@ rb_clock_getres(int argc, VALUE *argv, VALUE _)
timetick_int_t denominators[2];
int num_numerators = 0;
int num_denominators = 0;
+#ifdef HAVE_CLOCK_GETRES
clockid_t c;
+#endif
VALUE unit = (rb_check_arity(argc, 1, 2) == 2) ? argv[1] : Qnil;
VALUE clk_id = argv[0];
@@ -8416,15 +8605,17 @@ rb_clock_getres(int argc, VALUE *argv, VALUE _)
getres:
ret = clock_getres(c, &ts);
if (ret == -1)
- rb_sys_fail("clock_getres");
+ clock_failed("getres", errno, clk_id);
tt.count = (int32_t)ts.tv_nsec;
tt.giga_count = ts.tv_sec;
denominators[num_denominators++] = 1000000000;
goto success;
#endif
}
- /* EINVAL emulates clock_getres behavior when clock_id is invalid. */
- rb_syserr_fail(EINVAL, 0);
+ else {
+ rb_unexpected_type(clk_id, T_SYMBOL);
+ }
+ clock_failed("getres", EINVAL, clk_id);
success:
if (unit == ID2SYM(id_hertz)) {
@@ -8449,38 +8640,82 @@ get_PROCESS_ID(ID _x, VALUE *_y)
/*
* call-seq:
- * Process.kill(signal, pid, *pids) -> integer
- *
- * Sends the given signal to the specified process id(s) if _pid_ is positive.
- * If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal
- * to the group ID of the process. If _pid_ is negative, results are dependent
- * on the operating system. _signal_ may be an integer signal number or
- * a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is
- * negative (or starts with a minus sign), kills process groups instead of
- * processes. Not all signals are available on all platforms.
- * The keys and values of Signal.list are known signal names and numbers,
- * respectively.
- *
- * pid = fork do
- * Signal.trap("HUP") { puts "Ouch!"; exit }
- * # ... do some work ...
- * end
- * # ...
- * Process.kill("HUP", pid)
- * Process.wait
- *
- * <em>produces:</em>
+ * Process.kill(signal, *ids) -> count
+ *
+ * Sends a signal to each process specified by +ids+
+ * (which must specify at least one ID);
+ * returns the count of signals sent.
+ *
+ * For each given +id+, if +id+ is:
+ *
+ * - Positive, sends the signal to the process whose process ID is +id+.
+ * - Zero, send the signal to all processes in the current process group.
+ * - Negative, sends the signal to a system-dependent collection of processes.
+ *
+ * Argument +signal+ specifies the signal to be sent;
+ * the argument may be:
+ *
+ * - An integer signal number: e.g., +-29+, +0+, +29+.
+ * - A signal name (string), with or without leading <tt>'SIG'</tt>,
+ * and with or without a further prefixed minus sign (<tt>'-'</tt>):
+ * e.g.:
+ *
+ * - <tt>'SIGPOLL'</tt>.
+ * - <tt>'POLL'</tt>,
+ * - <tt>'-SIGPOLL'</tt>.
+ * - <tt>'-POLL'</tt>.
+ *
+ * - A signal symbol, with or without leading <tt>'SIG'</tt>,
+ * and with or without a further prefixed minus sign (<tt>'-'</tt>):
+ * e.g.:
+ *
+ * - +:SIGPOLL+.
+ * - +:POLL+.
+ * - <tt>:'-SIGPOLL'</tt>.
+ * - <tt>:'-POLL'</tt>.
+ *
+ * If +signal+ is:
+ *
+ * - A non-negative integer, or a signal name or symbol
+ * without prefixed <tt>'-'</tt>,
+ * each process with process ID +id+ is signalled.
+ * - A negative integer, or a signal name or symbol
+ * with prefixed <tt>'-'</tt>,
+ * each process group with group ID +id+ is signalled.
+ *
+ * Use method Signal.list to see which signals are supported
+ * by Ruby on the underlying platform;
+ * the method returns a hash of the string names
+ * and non-negative integer values of the supported signals.
+ * The size and content of the returned hash varies widely
+ * among platforms.
+ *
+ * Additionally, signal +0+ is useful to determine if the process exists.
+ *
+ * Example:
+ *
+ * pid = fork do
+ * Signal.trap('HUP') { puts 'Ouch!'; exit }
+ * # ... do some work ...
+ * end
+ * # ...
+ * Process.kill('HUP', pid)
+ * Process.wait
+ *
+ * Output:
*
* Ouch!
*
- * If _signal_ is an integer but wrong for signal, Errno::EINVAL or
- * RangeError will be raised. Otherwise unless _signal_ is a String
- * or a Symbol, and a known signal name, ArgumentError will be
- * raised.
+ * Exceptions:
+ *
+ * - Raises Errno::EINVAL or RangeError if +signal+ is an integer
+ * but invalid.
+ * - Raises ArgumentError if +signal+ is a string or symbol
+ * but invalid.
+ * - Raises Errno::ESRCH or RangeError if one of +ids+ is invalid.
+ * - Raises Errno::EPERM if needed permissions are not in force.
*
- * Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM
- * when failed because of no privilege, will be raised. In these
- * cases, signals may have been sent to preceding processes.
+ * In the last two cases, signals may have been sent to some processes.
*/
static VALUE
@@ -8494,23 +8729,456 @@ static VALUE rb_mProcUID;
static VALUE rb_mProcGID;
static VALUE rb_mProcID_Syscall;
+/*
+ * call-seq:
+ * Process.warmup -> true
+ *
+ * Notify the Ruby virtual machine that the boot sequence is finished,
+ * and that now is a good time to optimize the application. This is useful
+ * for long running applications.
+ *
+ * This method is expected to be called at the end of the application boot.
+ * If the application is deployed using a pre-forking model, +Process.warmup+
+ * should be called in the original process before the first fork.
+ *
+ * The actual optimizations performed are entirely implementation specific
+ * and may change in the future without notice.
+ *
+ * On CRuby, +Process.warmup+:
+ *
+ * * Performs a major GC.
+ * * Compacts the heap.
+ * * Promotes all surviving objects to the old generation.
+ * * Precomputes the coderange of all strings.
+ * * Frees all empty heap pages and increments the allocatable pages counter
+ * by the number of pages freed.
+ * * Invoke +malloc_trim+ if available to free empty malloc pages.
+ */
+
+static VALUE
+proc_warmup(VALUE _)
+{
+ RB_VM_LOCKING() {
+ rb_gc_prepare_heap();
+ }
+ return Qtrue;
+}
/*
* Document-module: Process
*
- * The module contains several groups of functionality for handling OS processes:
- *
- * * Low-level property introspection and management of the current process, like
- * Process.argv0, Process.pid;
- * * Low-level introspection of other processes, like Process.getpgid, Process.getpriority;
- * * Management of the current process: Process.abort, Process.exit, Process.daemon, etc.
- * (for convenience, most of those are also available as global functions
- * and module functions of Kernel);
- * * Creation and management of child processes: Process.fork, Process.spawn, and
- * related methods;
- * * Management of low-level system clock: Process.times and Process.clock_gettime,
- * which could be important for proper benchmarking and other elapsed
- * time measurement tasks.
+ * Module +Process+ represents a process in the underlying operating system.
+ * Its methods support management of the current process and its child processes.
+ *
+ * == Process Creation
+ *
+ * Each of the following methods executes a given command in a new process or subshell,
+ * or multiple commands in new processes and/or subshells.
+ * The choice of process or subshell depends on the form of the command;
+ * see {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
+ *
+ * - Process.spawn, Kernel#spawn: Executes the command;
+ * returns the new pid without waiting for completion.
+ * - Process.exec: Replaces the current process by executing the command.
+ *
+ * In addition:
+ *
+ * - Method Kernel#system executes a given command-line (string) in a subshell;
+ * returns +true+, +false+, or +nil+.
+ * - Method Kernel#` executes a given command-line (string) in a subshell;
+ * returns its $stdout string.
+ * - Module Open3 supports creating child processes
+ * with access to their $stdin, $stdout, and $stderr streams.
+ *
+ * === Execution Environment
+ *
+ * Optional leading argument +env+ is a hash of name/value pairs,
+ * where each name is a string and each value is a string or +nil+;
+ * each name/value pair is added to ENV in the new process.
+ *
+ * Process.spawn( 'ruby -e "p ENV[\"Foo\"]"')
+ * Process.spawn({'Foo' => '0'}, 'ruby -e "p ENV[\"Foo\"]"')
+ *
+ * Output:
+ *
+ * "0"
+ *
+ * The effect is usually similar to that of calling ENV#update with argument +env+,
+ * where each named environment variable is created or updated
+ * (if the value is non-+nil+),
+ * or deleted (if the value is +nil+).
+ *
+ * However, some modifications to the calling process may remain
+ * if the new process fails.
+ * For example, hard resource limits are not restored.
+ *
+ * === Argument +command_line+ or +exe_path+
+ *
+ * The required string argument is one of the following:
+ *
+ * - +command_line+ if it begins with a shell reserved word or special built-in,
+ * or if it contains one or more meta characters.
+ * - +exe_path+ otherwise.
+ *
+ * ==== Argument +command_line+
+ *
+ * \String argument +command_line+ is a command line to be passed to a shell;
+ * it must begin with a shell reserved word, begin with a special built-in,
+ * or contain meta characters:
+ *
+ * system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
+ * system('exit') # => true # Built-in.
+ * system('date > /tmp/date.tmp') # => true # Contains meta character.
+ * system('date > /nop/date.tmp') # => false
+ * system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
+ *
+ * The command line may also contain arguments and options for the command:
+ *
+ * system('echo "Foo"') # => true
+ *
+ * Output:
+ *
+ * Foo
+ *
+ * See {Execution Shell}[rdoc-ref:Process@Execution+Shell] for details about the shell.
+ *
+ * ==== Argument +exe_path+
+ *
+ * Argument +exe_path+ is one of the following:
+ *
+ * - The string path to an executable file to be called:
+ *
+ * Example:
+ *
+ * system('/usr/bin/date') # => true # Path to date on Unix-style system.
+ * system('foo') # => nil # Command execlution failed.
+ *
+ * Output:
+ *
+ * Thu Aug 31 10:06:48 AM CDT 2023
+ *
+ * A path or command name containing spaces without arguments cannot
+ * be distinguished from +command_line+ above, so you must quote or
+ * escape the entire command name using a shell in platform
+ * dependent manner, or use the array form below.
+ *
+ * If +exe_path+ does not contain any path separator, an executable
+ * file is searched from directories specified with the +PATH+
+ * environment variable. What the word "executable" means here is
+ * depending on platforms.
+ *
+ * Even if the file considered "executable", its content may not be
+ * in proper executable format. In that case, Ruby tries to run it
+ * by using <tt>/bin/sh</tt> on a Unix-like system, like system(3)
+ * does.
+ *
+ * File.write('shell_command', 'echo $SHELL', perm: 0o755)
+ * system('./shell_command') # prints "/bin/sh" or something.
+ *
+ * - A 2-element array containing the path to an executable
+ * and the string to be used as the name of the executing process:
+ *
+ * Example:
+ *
+ * pid = spawn(['sleep', 'Hello!'], '1') # 2-element array.
+ * p `ps -p #{pid} -o command=`
+ *
+ * Output:
+ *
+ * "Hello! 1\n"
+ *
+ * === Arguments +args+
+ *
+ * If +command_line+ does not contain shell meta characters except for
+ * spaces and tabs, or +exe_path+ is given, Ruby invokes the
+ * executable directly. This form does not use the shell:
+ *
+ * spawn("doesnt_exist") # Raises Errno::ENOENT
+ * spawn("doesnt_exist", "\n") # Raises Errno::ENOENT
+ *
+ * spawn("doesnt_exist\n") # => false
+ * # sh: 1: doesnot_exist: not found
+ *
+ * The error message is from a shell and would vary depending on your
+ * system.
+ *
+ * If one or more +args+ is given after +exe_path+, each is an
+ * argument or option to be passed to the executable:
+ *
+ * Example:
+ *
+ * system('echo', '<', 'C*', '|', '$SHELL', '>') # => true
+ *
+ * Output:
+ *
+ * < C* | $SHELL >
+ *
+ * However, there are exceptions on Windows. See {Execution Shell on
+ * Windows}[rdoc-ref:Process@Execution+Shell+on+Windows].
+ *
+ * If you want to invoke a path containing spaces with no arguments
+ * without shell, you will need to use a 2-element array +exe_path+.
+ *
+ * Example:
+ *
+ * path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
+ * spawn(path) # Raises Errno::ENOENT; No such file or directory - /Applications/Google
+ * spawn([path] * 2)
+ *
+ * === Execution Options
+ *
+ * Optional trailing argument +options+ is a hash of execution options.
+ *
+ * ==== Working Directory (+:chdir+)
+ *
+ * By default, the working directory for the new process is the same as
+ * that of the current process:
+ *
+ * Dir.chdir('/var')
+ * Process.spawn('ruby -e "puts Dir.pwd"')
+ *
+ * Output:
+ *
+ * /var
+ *
+ * Use option +:chdir+ to set the working directory for the new process:
+ *
+ * Process.spawn('ruby -e "puts Dir.pwd"', {chdir: '/tmp'})
+ *
+ * Output:
+ *
+ * /tmp
+ *
+ * The working directory of the current process is not changed:
+ *
+ * Dir.pwd # => "/var"
+ *
+ * ==== \File Redirection (\File Descriptor)
+ *
+ * Use execution options for file redirection in the new process.
+ *
+ * The key for such an option may be an integer file descriptor (fd),
+ * specifying a source,
+ * or an array of fds, specifying multiple sources.
+ *
+ * An integer source fd may be specified as:
+ *
+ * - _n_: Specifies file descriptor _n_.
+ *
+ * There are these shorthand symbols for fds:
+ *
+ * - +:in+: Specifies file descriptor 0 (STDIN).
+ * - +:out+: Specifies file descriptor 1 (STDOUT).
+ * - +:err+: Specifies file descriptor 2 (STDERR).
+ *
+ * The value given with a source is one of:
+ *
+ * - _n_:
+ * Redirects to fd _n_ in the parent process.
+ * - +filepath+:
+ * Redirects from or to the file at +filepath+ via <tt>open(filepath, mode, 0644)</tt>,
+ * where +mode+ is <tt>'r'</tt> for source +:in+,
+ * or <tt>'w'</tt> for source +:out+ or +:err+.
+ * - <tt>[filepath]</tt>:
+ * Redirects from the file at +filepath+ via <tt>open(filepath, 'r', 0644)</tt>.
+ * - <tt>[filepath, mode]</tt>:
+ * Redirects from or to the file at +filepath+ via <tt>open(filepath, mode, 0644)</tt>.
+ * - <tt>[filepath, mode, perm]</tt>:
+ * Redirects from or to the file at +filepath+ via <tt>open(filepath, mode, perm)</tt>.
+ * - <tt>[:child, fd]</tt>:
+ * Redirects to the redirected +fd+.
+ * - +:close+: Closes the file descriptor in child process.
+ *
+ * See {Access Modes}[rdoc-ref:File@Access+Modes]
+ * and {File Permissions}[rdoc-ref:File@File+Permissions].
+ *
+ * ==== Environment Variables (+:unsetenv_others+)
+ *
+ * By default, the new process inherits environment variables
+ * from the parent process;
+ * use execution option key +:unsetenv_others+ with value +true+
+ * to clear environment variables in the new process.
+ *
+ * Any changes specified by execution option +env+ are made after the new process
+ * inherits or clears its environment variables;
+ * see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ *
+ * ==== \File-Creation Access (+:umask+)
+ *
+ * Use execution option +:umask+ to set the file-creation access
+ * for the new process;
+ * see {Access Modes}[rdoc-ref:File@Access+Modes]:
+ *
+ * command = 'ruby -e "puts sprintf(\"0%o\", File.umask)"'
+ * options = {:umask => 0644}
+ * Process.spawn(command, options)
+ *
+ * Output:
+ *
+ * 0644
+ *
+ * ==== Process Groups (+:pgroup+ and +:new_pgroup+)
+ *
+ * By default, the new process belongs to the same
+ * {process group}[https://en.wikipedia.org/wiki/Process_group]
+ * as the parent process.
+ *
+ * To specify a different process group.
+ * use execution option +:pgroup+ with one of the following values:
+ *
+ * - +true+: Create a new process group for the new process.
+ * - _pgid_: Create the new process in the process group
+ * whose id is _pgid_.
+ *
+ * On Windows only, use execution option +:new_pgroup+ with value +true+
+ * to create a new process group for the new process.
+ *
+ * ==== Resource Limits
+ *
+ * Use execution options to set resource limits.
+ *
+ * The keys for these options are symbols of the form
+ * <tt>:rlimit_<i>resource_name</i></tt>,
+ * where _resource_name_ is the downcased form of one of the string
+ * resource names described at method Process.setrlimit.
+ * For example, key +:rlimit_cpu+ corresponds to resource limit <tt>'CPU'</tt>.
+ *
+ * The value for such as key is one of:
+ *
+ * - An integer, specifying both the current and maximum limits.
+ * - A 2-element array of integers, specifying the current and maximum limits.
+ *
+ * ==== \File Descriptor Inheritance
+ *
+ * By default, the new process inherits file descriptors from the parent process.
+ *
+ * Use execution option <tt>:close_others => true</tt> to modify that inheritance
+ * by closing non-standard fds (3 and greater) that are not otherwise redirected.
+ *
+ * === Execution Shell
+ *
+ * On a Unix-like system, the shell invoked is <tt>/bin/sh</tt>;
+ * the entire string +command_line+ is passed as an argument
+ * to {shell option -c}[https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html].
+ *
+ * The shell performs normal shell expansion on the command line:
+ *
+ * Example:
+ *
+ * system('echo $SHELL: C*') # => true
+ *
+ * Output:
+ *
+ * /bin/bash: CONTRIBUTING.md COPYING COPYING.ja
+ *
+ * ==== Execution Shell on Windows
+ *
+ * On Windows, the shell invoked is determined by environment variable
+ * +RUBYSHELL+, if defined, or +COMSPEC+ otherwise; the entire string
+ * +command_line+ is passed as an argument to <tt>-c</tt> option for
+ * +RUBYSHELL+, as well as <tt>/bin/sh</tt>, and {/c
+ * option}[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd]
+ * for +COMSPEC+. The shell is invoked automatically in the following
+ * cases:
+ *
+ * - The command is a built-in of +cmd.exe+, such as +echo+.
+ * - The executable file is a batch file; its name ends with +.bat+ or
+ * +.cmd+.
+ *
+ * Note that the command will still be invoked as +command_line+ form
+ * even when called in +exe_path+ form, because +cmd.exe+ does not
+ * accept a script name like <tt>/bin/sh</tt> does but only works with
+ * <tt>/c</tt> option.
+ *
+ * The standard shell +cmd.exe+ performs environment variable
+ * expansion but does not have globbing functionality:
+ *
+ * Example:
+ *
+ * system("echo %COMSPEC%: C*")' # => true
+ *
+ * Output:
+ *
+ * C:\WINDOWS\system32\cmd.exe: C*
+ *
+ * == What's Here
+ *
+ * === Current-Process Getters
+ *
+ * - ::argv0: Returns the process name as a frozen string.
+ * - ::egid: Returns the effective group ID.
+ * - ::euid: Returns the effective user ID.
+ * - ::getpgrp: Return the process group ID.
+ * - ::getrlimit: Returns the resource limit.
+ * - ::gid: Returns the (real) group ID.
+ * - ::pid: Returns the process ID.
+ * - ::ppid: Returns the process ID of the parent process.
+ * - ::uid: Returns the (real) user ID.
+ *
+ * === Current-Process Setters
+ *
+ * - ::egid=: Sets the effective group ID.
+ * - ::euid=: Sets the effective user ID.
+ * - ::gid=: Sets the (real) group ID.
+ * - ::setproctitle: Sets the process title.
+ * - ::setpgrp: Sets the process group ID of the process to zero.
+ * - ::setrlimit: Sets a resource limit.
+ * - ::setsid: Establishes the process as a new session and process group leader,
+ * with no controlling tty.
+ * - ::uid=: Sets the user ID.
+ *
+ * === Current-Process Execution
+ *
+ * - ::abort: Immediately terminates the process.
+ * - ::daemon: Detaches the process from its controlling terminal
+ * and continues running it in the background as system daemon.
+ * - ::exec: Replaces the process by running a given external command.
+ * - ::exit: Initiates process termination by raising exception SystemExit
+ * (which may be caught).
+ * - ::exit!: Immediately exits the process.
+ * - ::warmup: Notifies the Ruby virtual machine that the boot sequence
+ * for the application is completed,
+ * and that the VM may begin optimizing the application.
+ *
+ * === Child Processes
+ *
+ * - ::detach: Guards against a child process becoming a zombie.
+ * - ::fork: Creates a child process.
+ * - ::kill: Sends a given signal to processes.
+ * - ::spawn: Creates a child process.
+ * - ::wait, ::waitpid: Waits for a child process to exit; returns its process ID.
+ * - ::wait2, ::waitpid2: Waits for a child process to exit; returns its process ID and status.
+ * - ::waitall: Waits for all child processes to exit;
+ * returns their process IDs and statuses.
+ *
+ * === Process Groups
+ *
+ * - ::getpgid: Returns the process group ID for a process.
+ * - ::getpriority: Returns the scheduling priority
+ * for a process, process group, or user.
+ * - ::getsid: Returns the session ID for a process.
+ * - ::groups: Returns an array of the group IDs
+ * in the supplemental group access list for this process.
+ * - ::groups=: Sets the supplemental group access list
+ * to the given array of group IDs.
+ * - ::initgroups: Initializes the supplemental group access list.
+ * - ::last_status: Returns the status of the last executed child process
+ * in the current thread.
+ * - ::maxgroups: Returns the maximum number of group IDs allowed
+ * in the supplemental group access list.
+ * - ::maxgroups=: Sets the maximum number of group IDs allowed
+ * in the supplemental group access list.
+ * - ::setpgid: Sets the process group ID of a process.
+ * - ::setpriority: Sets the scheduling priority
+ * for a process, process group, or user.
+ *
+ * === Timing
+ *
+ * - ::clock_getres: Returns the resolution of a system clock.
+ * - ::clock_gettime: Returns the time from a system clock.
+ * - ::times: Returns a Process::Tms object containing times
+ * for the current process and its child processes.
+ *
*/
void
@@ -8580,8 +9248,6 @@ InitVM_process(void)
rb_define_singleton_method(rb_cProcessStatus, "wait", rb_process_status_waitv, -1);
rb_define_method(rb_cProcessStatus, "==", pst_equal, 1);
- rb_define_method(rb_cProcessStatus, "&", pst_bitand, 1);
- rb_define_method(rb_cProcessStatus, ">>", pst_rshift, 1);
rb_define_method(rb_cProcessStatus, "to_i", pst_to_i, 0);
rb_define_method(rb_cProcessStatus, "to_s", pst_to_s, 0);
rb_define_method(rb_cProcessStatus, "inspect", pst_inspect, 0);
@@ -8611,6 +9277,8 @@ InitVM_process(void)
rb_define_module_function(rb_mProcess, "getpriority", proc_getpriority, 2);
rb_define_module_function(rb_mProcess, "setpriority", proc_setpriority, 3);
+ rb_define_module_function(rb_mProcess, "warmup", proc_warmup, 0);
+
#ifdef HAVE_GETPRIORITY
/* see Process.setpriority */
rb_define_const(rb_mProcess, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
diff --git a/ractor.c b/ractor.c
index 8c367e17cb..f94c06cc73 100644
--- a/ractor.c
+++ b/ractor.c
@@ -3,22 +3,24 @@
#include "ruby/ruby.h"
#include "ruby/thread.h"
#include "ruby/ractor.h"
+#include "ruby/re.h"
#include "ruby/thread_native.h"
#include "vm_core.h"
-#include "eval_intern.h"
#include "vm_sync.h"
#include "ractor_core.h"
#include "internal/complex.h"
#include "internal/error.h"
#include "internal/gc.h"
#include "internal/hash.h"
+#include "internal/object.h"
+#include "internal/ractor.h"
#include "internal/rational.h"
#include "internal/struct.h"
+#include "internal/st.h"
#include "internal/thread.h"
#include "variable.h"
-#include "transient_heap.h"
#include "yjit.h"
-#include "rjit.h"
+#include "zjit.h"
VALUE rb_cRactor;
static VALUE rb_cRactorSelector;
@@ -33,14 +35,19 @@ static VALUE rb_cRactorMovedObject;
static void vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *r, const char *file, int line);
+
+#if RACTOR_CHECK_MODE > 0
+bool rb_ractor_ignore_belonging_flag = false;
+#endif
+
// Ractor locking
static void
ASSERT_ractor_unlocking(rb_ractor_t *r)
{
#if RACTOR_CHECK_MODE > 0
- // GET_EC is NULL in an RJIT worker
- if (rb_current_execution_context(false) != NULL && r->sync.locked_by == rb_ractor_self(GET_RACTOR())) {
+ const rb_execution_context_t *ec = rb_current_ec_noinline();
+ if (ec != NULL && r->sync.locked_by == rb_ractor_self(rb_ec_ractor_ptr(ec))) {
rb_bug("recursive ractor locking");
}
#endif
@@ -50,8 +57,8 @@ static void
ASSERT_ractor_locking(rb_ractor_t *r)
{
#if RACTOR_CHECK_MODE > 0
- // GET_EC is NULL in an RJIT worker
- if (rb_current_execution_context(false) != NULL && r->sync.locked_by != rb_ractor_self(GET_RACTOR())) {
+ const rb_execution_context_t *ec = rb_current_ec_noinline();
+ if (ec != NULL && r->sync.locked_by != rb_ractor_self(rb_ec_ractor_ptr(ec))) {
rp(r->sync.locked_by);
rb_bug("ractor lock is not acquired.");
}
@@ -61,24 +68,32 @@ ASSERT_ractor_locking(rb_ractor_t *r)
static void
ractor_lock(rb_ractor_t *r, const char *file, int line)
{
- RUBY_DEBUG_LOG2(file, line, "locking r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "locking r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
ASSERT_ractor_unlocking(r);
rb_native_mutex_lock(&r->sync.lock);
+ const rb_execution_context_t *ec = rb_current_ec_noinline();
+ if (ec) {
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ VM_ASSERT(!cr->malloc_gc_disabled);
+ cr->malloc_gc_disabled = true;
+ }
+
#if RACTOR_CHECK_MODE > 0
- if (rb_current_execution_context(false) != NULL) { // GET_EC is NULL in an RJIT worker
- r->sync.locked_by = rb_ractor_self(GET_RACTOR());
+ if (ec != NULL) {
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ r->sync.locked_by = rb_ractor_self(cr);
}
#endif
- RUBY_DEBUG_LOG2(file, line, "locked r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "locked r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
}
static void
ractor_lock_self(rb_ractor_t *cr, const char *file, int line)
{
- VM_ASSERT(cr == GET_RACTOR());
+ VM_ASSERT(cr == rb_ec_ractor_ptr(rb_current_ec_noinline()));
#if RACTOR_CHECK_MODE > 0
VM_ASSERT(cr->sync.locked_by != cr->pub.self);
#endif
@@ -92,15 +107,23 @@ ractor_unlock(rb_ractor_t *r, const char *file, int line)
#if RACTOR_CHECK_MODE > 0
r->sync.locked_by = Qnil;
#endif
+
+ const rb_execution_context_t *ec = rb_current_ec_noinline();
+ if (ec) {
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ VM_ASSERT(cr->malloc_gc_disabled);
+ cr->malloc_gc_disabled = false;
+ }
+
rb_native_mutex_unlock(&r->sync.lock);
- RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, GET_RACTOR() == r ? " (self)" : "");
+ RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");
}
static void
ractor_unlock_self(rb_ractor_t *cr, const char *file, int line)
{
- VM_ASSERT(cr == GET_RACTOR());
+ VM_ASSERT(cr == rb_ec_ractor_ptr(rb_current_ec_noinline()));
#if RACTOR_CHECK_MODE > 0
VM_ASSERT(cr->sync.locked_by == cr->pub.self);
#endif
@@ -112,18 +135,16 @@ ractor_unlock_self(rb_ractor_t *cr, const char *file, int line)
#define RACTOR_LOCK_SELF(r) ractor_lock_self(r, __FILE__, __LINE__)
#define RACTOR_UNLOCK_SELF(r) ractor_unlock_self(r, __FILE__, __LINE__)
-static void
-ractor_cond_wait(rb_ractor_t *r)
+void
+rb_ractor_lock_self(rb_ractor_t *r)
{
-#if RACTOR_CHECK_MODE > 0
- VALUE locked_by = r->sync.locked_by;
- r->sync.locked_by = Qnil;
-#endif
- rb_native_cond_wait(&r->sync.cond, &r->sync.lock);
+ RACTOR_LOCK_SELF(r);
+}
-#if RACTOR_CHECK_MODE > 0
- r->sync.locked_by = locked_by;
-#endif
+void
+rb_ractor_unlock_self(rb_ractor_t *r)
+{
+ RACTOR_UNLOCK_SELF(r);
}
// Ractor status
@@ -179,62 +200,81 @@ ractor_status_p(rb_ractor_t *r, enum ractor_status status)
// Ractor data/mark/free
-static struct rb_ractor_basket *ractor_queue_at(rb_ractor_t *r, struct rb_ractor_queue *rq, int i);
static void ractor_local_storage_mark(rb_ractor_t *r);
static void ractor_local_storage_free(rb_ractor_t *r);
-static void
-ractor_queue_mark(struct rb_ractor_queue *rq)
-{
- for (int i=0; i<rq->cnt; i++) {
- struct rb_ractor_basket *b = ractor_queue_at(NULL, rq, i);
- rb_gc_mark(b->sender);
-
- switch (b->type.e) {
- case basket_type_yielding:
- case basket_type_take_basket:
- case basket_type_deleted:
- case basket_type_reserved:
- // ignore
- break;
- default:
- rb_gc_mark(b->p.send.v);
- }
+static void ractor_sync_mark(rb_ractor_t *r);
+static void ractor_sync_free(rb_ractor_t *r);
+static size_t ractor_sync_memsize(const rb_ractor_t *r);
+static void ractor_sync_init(rb_ractor_t *r);
+
+static int
+mark_targeted_hook_list(st_data_t key, st_data_t value, st_data_t _arg)
+{
+ rb_hook_list_t *hook_list = (rb_hook_list_t*)value;
+
+ if (hook_list->type == hook_list_type_targeted_iseq) {
+ rb_gc_mark((VALUE)key);
+ }
+ else {
+ rb_method_definition_t *def = (rb_method_definition_t*)key;
+ RUBY_ASSERT(hook_list->type == hook_list_type_targeted_def);
+ rb_gc_mark(def->body.bmethod.proc);
}
+ rb_hook_list_mark(hook_list);
+
+ return ST_CONTINUE;
}
static void
ractor_mark(void *ptr)
{
rb_ractor_t *r = (rb_ractor_t *)ptr;
-
- ractor_queue_mark(&r->sync.recv_queue);
- ractor_queue_mark(&r->sync.takers_queue);
-
- rb_gc_mark(r->receiving_mutex);
+ bool checking_shareable = rb_gc_checking_shareable();
rb_gc_mark(r->loc);
rb_gc_mark(r->name);
- rb_gc_mark(r->r_stdin);
- rb_gc_mark(r->r_stdout);
- rb_gc_mark(r->r_stderr);
- rb_hook_list_mark(&r->pub.hooks);
-
- if (r->threads.cnt > 0) {
- rb_thread_t *th = 0;
- ccan_list_for_each(&r->threads.set, th, lt_node) {
- VM_ASSERT(th != NULL);
- rb_gc_mark(th->self);
+
+ if (!checking_shareable) {
+ // may unshareable objects
+ rb_gc_mark(r->r_stdin);
+ rb_gc_mark(r->r_stdout);
+ rb_gc_mark(r->r_stderr);
+ rb_gc_mark(r->verbose);
+ rb_gc_mark(r->debug);
+
+ // mark received messages
+ ractor_sync_mark(r);
+
+ rb_hook_list_mark(&r->pub.hooks);
+ if (r->pub.targeted_hooks.num_entries) {
+ st_foreach(&r->pub.targeted_hooks, mark_targeted_hook_list, 0);
}
+
+ if (r->threads.cnt > 0) {
+ rb_thread_t *th = 0;
+ ccan_list_for_each(&r->threads.set, th, lt_node) {
+ VM_ASSERT(th != NULL);
+ rb_gc_mark(th->self);
+ }
+ }
+
+ ractor_local_storage_mark(r);
}
+}
- ractor_local_storage_mark(r);
+static int
+free_targeted_hook_lists(st_data_t key, st_data_t val, st_data_t _arg)
+{
+ rb_hook_list_t *hook_list = (rb_hook_list_t*)val;
+ rb_hook_list_free(hook_list);
+ return ST_DELETE;
}
static void
-ractor_queue_free(struct rb_ractor_queue *rq)
+free_targeted_hooks(st_table *hooks_tbl)
{
- free(rq->baskets);
+ st_foreach(hooks_tbl, free_targeted_hook_lists, 0);
}
static void
@@ -242,19 +282,26 @@ ractor_free(void *ptr)
{
rb_ractor_t *r = (rb_ractor_t *)ptr;
RUBY_DEBUG_LOG("free r:%d", rb_ractor_id(r));
+ free_targeted_hooks(&r->pub.targeted_hooks);
rb_native_mutex_destroy(&r->sync.lock);
- rb_native_cond_destroy(&r->sync.cond);
- ractor_queue_free(&r->sync.recv_queue);
- ractor_queue_free(&r->sync.takers_queue);
+#ifdef RUBY_THREAD_WIN32_H
+ rb_native_cond_destroy(&r->sync.wakeup_cond);
+#endif
ractor_local_storage_free(r);
rb_hook_list_free(&r->pub.hooks);
- ruby_xfree(r);
-}
+ rb_st_free_embedded_table(&r->pub.targeted_hooks);
-static size_t
-ractor_queue_memsize(const struct rb_ractor_queue *rq)
-{
- return sizeof(struct rb_ractor_basket) * rq->size;
+ if (r->newobj_cache) {
+ RUBY_ASSERT(r == ruby_single_main_ractor);
+
+ rb_gc_ractor_cache_free(r->newobj_cache);
+ r->newobj_cache = NULL;
+ }
+
+ ractor_sync_free(r);
+ if (!r->main_ractor) {
+ SIZED_FREE(r);
+ }
}
static size_t
@@ -263,9 +310,7 @@ ractor_memsize(const void *ptr)
rb_ractor_t *r = (rb_ractor_t *)ptr;
// TODO: more correct?
- return sizeof(rb_ractor_t) +
- ractor_queue_memsize(&r->sync.recv_queue) +
- ractor_queue_memsize(&r->sync.takers_queue);
+ return sizeof(rb_ractor_t) + ractor_sync_memsize(r);
}
static const rb_data_type_t ractor_data_type = {
@@ -298,7 +343,8 @@ RACTOR_PTR(VALUE self)
return r;
}
-static rb_atomic_t ractor_last_id;
+#define MAIN_RACTOR_ID 1
+static rb_atomic_t ractor_last_id = MAIN_RACTOR_ID;
#if RACTOR_CHECK_MODE > 0
uint32_t
@@ -313,1493 +359,7 @@ rb_ractor_current_id(void)
}
#endif
-// Ractor queue
-
-static void
-ractor_queue_setup(struct rb_ractor_queue *rq)
-{
- rq->size = 2;
- rq->cnt = 0;
- rq->start = 0;
- rq->baskets = malloc(sizeof(struct rb_ractor_basket) * rq->size);
-}
-
-static struct rb_ractor_basket *
-ractor_queue_head(rb_ractor_t *r, struct rb_ractor_queue *rq)
-{
- if (r != NULL) ASSERT_ractor_locking(r);
- return &rq->baskets[rq->start];
-}
-
-static struct rb_ractor_basket *
-ractor_queue_at(rb_ractor_t *r, struct rb_ractor_queue *rq, int i)
-{
- if (r != NULL) ASSERT_ractor_locking(r);
- return &rq->baskets[(rq->start + i) % rq->size];
-}
-
-static void
-ractor_queue_advance(rb_ractor_t *r, struct rb_ractor_queue *rq)
-{
- ASSERT_ractor_locking(r);
-
- if (rq->reserved_cnt == 0) {
- rq->cnt--;
- rq->start = (rq->start + 1) % rq->size;
- rq->serial++;
- }
- else {
- ractor_queue_at(r, rq, 0)->type.e = basket_type_deleted;
- }
-}
-
-static bool
-ractor_queue_skip_p(rb_ractor_t *r, struct rb_ractor_queue *rq, int i)
-{
- struct rb_ractor_basket *b = ractor_queue_at(r, rq, i);
- return basket_type_p(b, basket_type_deleted) ||
- basket_type_p(b, basket_type_reserved);
-}
-
-static void
-ractor_queue_compact(rb_ractor_t *r, struct rb_ractor_queue *rq)
-{
- ASSERT_ractor_locking(r);
-
- while (rq->cnt > 0 && basket_type_p(ractor_queue_at(r, rq, 0), basket_type_deleted)) {
- ractor_queue_advance(r, rq);
- }
-}
-
-static bool
-ractor_queue_empty_p(rb_ractor_t *r, struct rb_ractor_queue *rq)
-{
- ASSERT_ractor_locking(r);
-
- if (rq->cnt == 0) {
- return true;
- }
-
- ractor_queue_compact(r, rq);
-
- for (int i=0; i<rq->cnt; i++) {
- if (!ractor_queue_skip_p(r, rq, i)) {
- return false;
- }
- }
-
- return true;
-}
-
-static bool
-ractor_queue_deq(rb_ractor_t *r, struct rb_ractor_queue *rq, struct rb_ractor_basket *basket)
-{
- ASSERT_ractor_locking(r);
-
- for (int i=0; i<rq->cnt; i++) {
- if (!ractor_queue_skip_p(r, rq, i)) {
- struct rb_ractor_basket *b = ractor_queue_at(r, rq, i);
- *basket = *b;
-
- // remove from queue
- b->type.e = basket_type_deleted;
- ractor_queue_compact(r, rq);
- return true;
- }
- }
-
- return false;
-}
-
-static void
-ractor_queue_enq(rb_ractor_t *r, struct rb_ractor_queue *rq, struct rb_ractor_basket *basket)
-{
- ASSERT_ractor_locking(r);
-
- if (rq->size <= rq->cnt) {
- rq->baskets = realloc(rq->baskets, sizeof(struct rb_ractor_basket) * rq->size * 2);
- for (int i=rq->size - rq->start; i<rq->cnt; i++) {
- rq->baskets[i + rq->start] = rq->baskets[i + rq->start - rq->size];
- }
- rq->size *= 2;
- }
- rq->baskets[(rq->start + rq->cnt++) % rq->size] = *basket;
- // fprintf(stderr, "%s %p->cnt:%d\n", RUBY_FUNCTION_NAME_STRING, (void *)rq, rq->cnt);
-}
-
-static void
-ractor_queue_delete(rb_ractor_t *r, struct rb_ractor_queue *rq, struct rb_ractor_basket *basket)
-{
- basket->type.e = basket_type_deleted;
-}
-
-// Ractor basket
-
-static VALUE ractor_reset_belonging(VALUE obj); // in this file
-
-static VALUE
-ractor_basket_value(struct rb_ractor_basket *b)
-{
- switch (b->type.e) {
- case basket_type_ref:
- break;
- case basket_type_copy:
- case basket_type_move:
- case basket_type_will:
- b->type.e = basket_type_ref;
- b->p.send.v = ractor_reset_belonging(b->p.send.v);
- break;
- default:
- rb_bug("unreachable");
- }
-
- return b->p.send.v;
-}
-
-static VALUE
-ractor_basket_accept(struct rb_ractor_basket *b)
-{
- VALUE v = ractor_basket_value(b);
-
- if (b->p.send.exception) {
- VALUE cause = v;
- VALUE err = rb_exc_new_cstr(rb_eRactorRemoteError, "thrown by remote Ractor.");
- rb_ivar_set(err, rb_intern("@ractor"), b->sender);
- rb_ec_setup_exception(NULL, err, cause);
- rb_exc_raise(err);
- }
-
- return v;
-}
-
-// Ractor synchronizations
-
-#if USE_RUBY_DEBUG_LOG
-static const char *
-wait_status_str(enum rb_ractor_wait_status wait_status)
-{
- switch ((int)wait_status) {
- case wait_none: return "none";
- case wait_receiving: return "receiving";
- case wait_taking: return "taking";
- case wait_yielding: return "yielding";
- case wait_receiving|wait_taking: return "receiving|taking";
- case wait_receiving|wait_yielding: return "receiving|yielding";
- case wait_taking|wait_yielding: return "taking|yielding";
- case wait_receiving|wait_taking|wait_yielding: return "receiving|taking|yielding";
- }
- rb_bug("unreachable");
-}
-
-static const char *
-wakeup_status_str(enum rb_ractor_wakeup_status wakeup_status)
-{
- switch (wakeup_status) {
- case wakeup_none: return "none";
- case wakeup_by_send: return "by_send";
- case wakeup_by_yield: return "by_yield";
- case wakeup_by_take: return "by_take";
- case wakeup_by_close: return "by_close";
- case wakeup_by_interrupt: return "by_interrupt";
- case wakeup_by_retry: return "by_retry";
- }
- rb_bug("unreachable");
-}
-
-static const char *
-basket_type_name(enum rb_ractor_basket_type type)
-{
- switch (type) {
- case basket_type_none: return "none";
- case basket_type_ref: return "ref";
- case basket_type_copy: return "copy";
- case basket_type_move: return "move";
- case basket_type_will: return "will";
- case basket_type_deleted: return "deleted";
- case basket_type_reserved: return "reserved";
- case basket_type_take_basket: return "take_basket";
- case basket_type_yielding: return "yielding";
- }
- VM_ASSERT(0);
- return NULL;
-}
-#endif // USE_RUBY_DEBUG_LOG
-
-static bool
-ractor_sleeping_by(const rb_ractor_t *r, enum rb_ractor_wait_status wait_status)
-{
- return (r->sync.wait.status & wait_status) && r->sync.wait.wakeup_status == wakeup_none;
-}
-
-static bool
-ractor_wakeup(rb_ractor_t *r, enum rb_ractor_wait_status wait_status, enum rb_ractor_wakeup_status wakeup_status)
-{
- ASSERT_ractor_locking(r);
-
- RUBY_DEBUG_LOG("r:%u wait_by:%s -> wait:%s wakeup:%s",
- rb_ractor_id(r),
- wait_status_str(r->sync.wait.status),
- wait_status_str(wait_status),
- wakeup_status_str(wakeup_status));
-
- if (ractor_sleeping_by(r, wait_status)) {
- r->sync.wait.wakeup_status = wakeup_status;
- rb_native_cond_broadcast(&r->sync.cond);
- return true;
- }
- else {
- return false;
- }
-}
-
-static void *
-ractor_sleep_wo_gvl(void *ptr)
-{
- rb_ractor_t *cr = ptr;
- RACTOR_LOCK_SELF(cr);
- {
- VM_ASSERT(cr->sync.wait.status != wait_none);
- if (cr->sync.wait.wakeup_status == wakeup_none) {
- ractor_cond_wait(cr);
- }
- cr->sync.wait.status = wait_none;
- }
- RACTOR_UNLOCK_SELF(cr);
- return NULL;
-}
-
-static void
-ractor_sleep_interrupt(void *ptr)
-{
- rb_ractor_t *r = ptr;
-
- RACTOR_LOCK(r);
- {
- ractor_wakeup(r, wait_receiving | wait_taking | wait_yielding, wakeup_by_interrupt);
- }
- RACTOR_UNLOCK(r);
-}
-
-typedef void (*ractor_sleep_cleanup_function)(rb_ractor_t *cr, void *p);
-
-static enum rb_ractor_wakeup_status
-ractor_sleep_with_cleanup(rb_execution_context_t *ec, rb_ractor_t *cr, enum rb_ractor_wait_status wait_status,
- ractor_sleep_cleanup_function cf_func, void *cf_data)
-{
- enum rb_ractor_wakeup_status wakeup_status;
- VM_ASSERT(GET_RACTOR() == cr);
-
- // TODO: multi-threads
- VM_ASSERT(cr->sync.wait.status == wait_none);
- VM_ASSERT(wait_status != wait_none);
- cr->sync.wait.status = wait_status;
- cr->sync.wait.wakeup_status = wakeup_none;
-
- // fprintf(stderr, "%s r:%p status:%s, wakeup_status:%s\n", RUBY_FUNCTION_NAME_STRING, (void *)cr,
- // wait_status_str(cr->sync.wait.status), wakeup_status_str(cr->sync.wait.wakeup_status));
-
- RUBY_DEBUG_LOG("sleep by %s", wait_status_str(wait_status));
-
- RACTOR_UNLOCK(cr);
- {
- rb_nogvl(ractor_sleep_wo_gvl, cr,
- ractor_sleep_interrupt, cr,
- RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_INTR_FAIL);
- }
- RACTOR_LOCK(cr);
-
- // rb_nogvl() can be canceled by interrupts
- if (cr->sync.wait.status != wait_none) {
- cr->sync.wait.status = wait_none;
- cr->sync.wait.wakeup_status = wakeup_by_interrupt;
-
- RACTOR_UNLOCK(cr);
- {
- if (cf_func) {
- int state;
- EC_PUSH_TAG(ec);
- if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- rb_thread_check_ints();
- }
- EC_POP_TAG();
-
- if (state) {
- (*cf_func)(cr, cf_data);
- EC_JUMP_TAG(ec, state);
- }
- }
- else {
- rb_thread_check_ints();
- }
- }
- RACTOR_LOCK(cr); // reachable?
- }
-
- // TODO: multi-thread
- wakeup_status = cr->sync.wait.wakeup_status;
- cr->sync.wait.wakeup_status = wakeup_none;
-
- RUBY_DEBUG_LOG("wakeup %s", wakeup_status_str(wakeup_status));
-
- return wakeup_status;
-}
-
-static enum rb_ractor_wakeup_status
-ractor_sleep(rb_execution_context_t *ec, rb_ractor_t *cr, enum rb_ractor_wait_status wait_status)
-{
- return ractor_sleep_with_cleanup(ec, cr, wait_status, NULL, NULL);
-}
-
-// Ractor.receive
-
-static void
-ractor_recursive_receive_if(rb_ractor_t *r)
-{
- if (r->receiving_mutex && rb_mutex_owned_p(r->receiving_mutex)) {
- rb_raise(rb_eRactorError, "can not call receive/receive_if recursively");
- }
-}
-
-static VALUE
-ractor_try_receive(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_queue *rq)
-{
- struct rb_ractor_basket basket;
- ractor_recursive_receive_if(cr);
- bool received = false;
-
- RACTOR_LOCK_SELF(cr);
- {
- RUBY_DEBUG_LOG("rq->cnt:%d", rq->cnt);
- received = ractor_queue_deq(cr, rq, &basket);
- }
- RACTOR_UNLOCK_SELF(cr);
-
- if (!received) {
- if (cr->sync.incoming_port_closed) {
- rb_raise(rb_eRactorClosedError, "The incoming port is already closed");
- }
- return Qundef;
- }
- else {
- return ractor_basket_accept(&basket);
- }
-}
-
-static void
-ractor_wait_receive(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_queue *rq)
-{
- VM_ASSERT(cr == rb_ec_ractor_ptr(ec));
- ractor_recursive_receive_if(cr);
-
- RACTOR_LOCK(cr);
- {
- while (ractor_queue_empty_p(cr, rq)) {
- ractor_sleep(ec, cr, wait_receiving);
- }
- }
- RACTOR_UNLOCK(cr);
-}
-
-static VALUE
-ractor_receive(rb_execution_context_t *ec, rb_ractor_t *cr)
-{
- VM_ASSERT(cr == rb_ec_ractor_ptr(ec));
- VALUE v;
- struct rb_ractor_queue *rq = &cr->sync.recv_queue;
-
- while (UNDEF_P(v = ractor_try_receive(ec, cr, rq))) {
- ractor_wait_receive(ec, cr, rq);
- }
-
- return v;
-}
-
-#if 0
-static void
-rq_dump(struct rb_ractor_queue *rq)
-{
- bool bug = false;
- for (int i=0; i<rq->cnt; i++) {
- struct rb_ractor_basket *b = ractor_queue_at(NULL, rq, i);
- fprintf(stderr, "%d (start:%d) type:%s %p %s\n", i, rq->start, basket_type_name(b->type),
- (void *)b, RSTRING_PTR(RARRAY_AREF(b->v, 1)));
- if (basket_type_p(b, basket_type_reserved) bug = true;
- }
- if (bug) rb_bug("!!");
-}
-#endif
-
-struct receive_block_data {
- rb_ractor_t *cr;
- struct rb_ractor_queue *rq;
- VALUE v;
- int index;
- bool success;
-};
-
-static void
-ractor_receive_if_lock(rb_ractor_t *cr)
-{
- VALUE m = cr->receiving_mutex;
- if (m == Qfalse) {
- m = cr->receiving_mutex = rb_mutex_new();
- }
- rb_mutex_lock(m);
-}
-
-static VALUE
-receive_if_body(VALUE ptr)
-{
- struct receive_block_data *data = (struct receive_block_data *)ptr;
-
- ractor_receive_if_lock(data->cr);
- VALUE block_result = rb_yield(data->v);
- rb_ractor_t *cr = data->cr;
-
- RACTOR_LOCK_SELF(cr);
- {
- struct rb_ractor_basket *b = ractor_queue_at(cr, data->rq, data->index);
- VM_ASSERT(basket_type_p(b, basket_type_reserved));
- data->rq->reserved_cnt--;
-
- if (RTEST(block_result)) {
- ractor_queue_delete(cr, data->rq, b);
- ractor_queue_compact(cr, data->rq);
- }
- else {
- b->type.e = basket_type_ref;
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-
- data->success = true;
-
- if (RTEST(block_result)) {
- return data->v;
- }
- else {
- return Qundef;
- }
-}
-
-static VALUE
-receive_if_ensure(VALUE v)
-{
- struct receive_block_data *data = (struct receive_block_data *)v;
- rb_ractor_t *cr = data->cr;
-
- if (!data->success) {
- RACTOR_LOCK_SELF(cr);
- {
- struct rb_ractor_basket *b = ractor_queue_at(cr, data->rq, data->index);
- VM_ASSERT(basket_type_p(b, basket_type_reserved));
- b->type.e = basket_type_deleted;
- data->rq->reserved_cnt--;
- }
- RACTOR_UNLOCK_SELF(cr);
- }
-
- rb_mutex_unlock(cr->receiving_mutex);
- return Qnil;
-}
-
-static VALUE
-ractor_receive_if(rb_execution_context_t *ec, VALUE crv, VALUE b)
-{
- if (!RTEST(b)) rb_raise(rb_eArgError, "no block given");
-
- rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
- unsigned int serial = (unsigned int)-1;
- int index = 0;
- struct rb_ractor_queue *rq = &cr->sync.recv_queue;
-
- while (1) {
- VALUE v = Qundef;
-
- ractor_wait_receive(ec, cr, rq);
-
- RACTOR_LOCK_SELF(cr);
- {
- if (serial != rq->serial) {
- serial = rq->serial;
- index = 0;
- }
-
- // check newer version
- for (int i=index; i<rq->cnt; i++) {
- if (!ractor_queue_skip_p(cr, rq, i)) {
- struct rb_ractor_basket *b = ractor_queue_at(cr, rq, i);
- v = ractor_basket_value(b);
- b->type.e = basket_type_reserved;
- rq->reserved_cnt++;
- index = i;
- break;
- }
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-
- if (!UNDEF_P(v)) {
- struct receive_block_data data = {
- .cr = cr,
- .rq = rq,
- .v = v,
- .index = index,
- .success = false,
- };
-
- VALUE result = rb_ensure(receive_if_body, (VALUE)&data,
- receive_if_ensure, (VALUE)&data);
-
- if (!UNDEF_P(result)) return result;
- index++;
- }
-
- RUBY_VM_CHECK_INTS(ec);
- }
-}
-
-static void
-ractor_send_basket(rb_execution_context_t *ec, rb_ractor_t *r, struct rb_ractor_basket *b)
-{
- bool closed = false;
-
- RACTOR_LOCK(r);
- {
- if (r->sync.incoming_port_closed) {
- closed = true;
- }
- else {
- ractor_queue_enq(r, &r->sync.recv_queue, b);
- ractor_wakeup(r, wait_receiving, wakeup_by_send);
- }
- }
- RACTOR_UNLOCK(r);
-
- if (closed) {
- rb_raise(rb_eRactorClosedError, "The incoming-port is already closed");
- }
-}
-
-// Ractor#send
-
-static VALUE ractor_move(VALUE obj); // in this file
-static VALUE ractor_copy(VALUE obj); // in this file
-
-static void
-ractor_basket_prepare_contents(VALUE obj, VALUE move, VALUE *pobj, enum rb_ractor_basket_type *ptype)
-{
- VALUE v;
- enum rb_ractor_basket_type type;
-
- if (rb_ractor_shareable_p(obj)) {
- type = basket_type_ref;
- v = obj;
- }
- else if (!RTEST(move)) {
- v = ractor_copy(obj);
- type = basket_type_copy;
- }
- else {
- type = basket_type_move;
- v = ractor_move(obj);
- }
-
- *pobj = v;
- *ptype = type;
-}
-
-static void
-ractor_basket_fill_(rb_ractor_t *cr, struct rb_ractor_basket *basket, VALUE obj, bool exc)
-{
- VM_ASSERT(cr == GET_RACTOR());
-
- basket->sender = cr->pub.self;
- basket->p.send.exception = exc;
- basket->p.send.v = obj;
-}
-
-static void
-ractor_basket_fill(rb_ractor_t *cr, struct rb_ractor_basket *basket, VALUE obj, VALUE move, bool exc)
-{
- VALUE v;
- enum rb_ractor_basket_type type;
- ractor_basket_prepare_contents(obj, move, &v, &type);
- ractor_basket_fill_(cr, basket, v, exc);
- basket->type.e = type;
-}
-
-static void
-ractor_basket_fill_will(rb_ractor_t *cr, struct rb_ractor_basket *basket, VALUE obj, bool exc)
-{
- ractor_basket_fill_(cr, basket, obj, exc);
- basket->type.e = basket_type_will;
-}
-
-static VALUE
-ractor_send(rb_execution_context_t *ec, rb_ractor_t *r, VALUE obj, VALUE move)
-{
- struct rb_ractor_basket basket;
- // TODO: Ractor local GC
- ractor_basket_fill(rb_ec_ractor_ptr(ec), &basket, obj, move, false);
- ractor_send_basket(ec, r, &basket);
- return r->pub.self;
-}
-
-// Ractor#take
-
-static bool
-ractor_take_has_will(rb_ractor_t *r)
-{
- ASSERT_ractor_locking(r);
-
- return basket_type_p(&r->sync.will_basket, basket_type_will);
-}
-
-static bool
-ractor_take_will(rb_ractor_t *r, struct rb_ractor_basket *b)
-{
- ASSERT_ractor_locking(r);
-
- if (ractor_take_has_will(r)) {
- *b = r->sync.will_basket;
- r->sync.will_basket.type.e = basket_type_none;
- return true;
- }
- else {
- VM_ASSERT(basket_type_p(&r->sync.will_basket, basket_type_none));
- return false;
- }
-}
-
-static bool
-ractor_take_will_lock(rb_ractor_t *r, struct rb_ractor_basket *b)
-{
- ASSERT_ractor_unlocking(r);
- bool taken;
-
- RACTOR_LOCK(r);
- {
- taken = ractor_take_will(r, b);
- }
- RACTOR_UNLOCK(r);
-
- return taken;
-}
-
-static bool
-ractor_register_take(rb_ractor_t *cr, rb_ractor_t *r, struct rb_ractor_basket *take_basket,
- bool is_take, struct rb_ractor_selector_take_config *config, bool ignore_error)
-{
- struct rb_ractor_basket b = {
- .type.e = basket_type_take_basket,
- .sender = cr->pub.self,
- .p = {
- .take = {
- .basket = take_basket,
- .config = config,
- },
- },
- };
- bool closed = false;
-
- RACTOR_LOCK(r);
- {
- if (is_take && ractor_take_will(r, take_basket)) {
- RUBY_DEBUG_LOG("take over a will of r:%d", rb_ractor_id(r));
- }
- else if (!is_take && ractor_take_has_will(r)) {
- RUBY_DEBUG_LOG("has_will");
- VM_ASSERT(config != NULL);
- config->closed = true;
- }
- else if (r->sync.outgoing_port_closed) {
- closed = true;
- }
- else {
- RUBY_DEBUG_LOG("register in r:%d", rb_ractor_id(r));
- ractor_queue_enq(r, &r->sync.takers_queue, &b);
-
- if (basket_none_p(take_basket)) {
- ractor_wakeup(r, wait_yielding, wakeup_by_take);
- }
- }
- }
- RACTOR_UNLOCK(r);
-
- if (closed) {
- if (!ignore_error) rb_raise(rb_eRactorClosedError, "The outgoing-port is already closed");
- return false;
- }
- else {
- return true;
- }
-}
-
-static bool
-ractor_deregister_take(rb_ractor_t *r, struct rb_ractor_basket *take_basket)
-{
- struct rb_ractor_queue *ts = &r->sync.takers_queue;
- bool deleted = false;
-
- RACTOR_LOCK(r);
- {
- if (r->sync.outgoing_port_closed) {
- // ok
- }
- else {
- for (int i=0; i<ts->cnt; i++) {
- struct rb_ractor_basket *b = ractor_queue_at(r, ts, i);
- if (basket_type_p(b, basket_type_take_basket) && b->p.take.basket == take_basket) {
- ractor_queue_delete(r, ts, b);
- deleted = true;
- }
- }
- if (deleted) {
- ractor_queue_compact(r, ts);
- }
- }
- }
- RACTOR_UNLOCK(r);
-
- return deleted;
-}
-
-static VALUE
-ractor_try_take(rb_ractor_t *cr, rb_ractor_t *r, struct rb_ractor_basket *take_basket)
-{
- bool taken;
-
- RACTOR_LOCK_SELF(cr);
- {
- if (basket_none_p(take_basket) || basket_type_p(take_basket, basket_type_yielding)) {
- taken = false;
- }
- else {
- taken = true;
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-
- if (taken) {
- RUBY_DEBUG_LOG("taken");
- if (basket_type_p(take_basket, basket_type_deleted)) {
- VM_ASSERT(r->sync.outgoing_port_closed);
- rb_raise(rb_eRactorClosedError, "The outgoing-port is already closed");
- }
- return ractor_basket_accept(take_basket);
- }
- else {
- RUBY_DEBUG_LOG("not taken");
- return Qundef;
- }
-}
-
-
-#if VM_CHECK_MODE > 0
-static bool
-ractor_check_specific_take_basket_lock(rb_ractor_t *r, struct rb_ractor_basket *tb)
-{
- bool ret = false;
- struct rb_ractor_queue *ts = &r->sync.takers_queue;
-
- RACTOR_LOCK(r);
- {
- for (int i=0; i<ts->cnt; i++) {
- struct rb_ractor_basket *b = ractor_queue_at(r, ts, i);
- if (basket_type_p(b, basket_type_take_basket) && b->p.take.basket == tb) {
- ret = true;
- break;
- }
- }
- }
- RACTOR_UNLOCK(r);
-
- return ret;
-}
-#endif
-
-static void
-ractor_take_cleanup(rb_ractor_t *cr, rb_ractor_t *r, struct rb_ractor_basket *tb)
-{
- retry:
- if (basket_none_p(tb)) { // not yielded yet
- if (!ractor_deregister_take(r, tb)) {
- // not in r's takers queue
- rb_thread_sleep(0);
- goto retry;
- }
- }
- else {
- VM_ASSERT(!ractor_check_specific_take_basket_lock(r, tb));
- }
-}
-
-struct take_wait_take_cleanup_data {
- rb_ractor_t *r;
- struct rb_ractor_basket *tb;
-};
-
-static void
-ractor_wait_take_cleanup(rb_ractor_t *cr, void *ptr)
-{
- struct take_wait_take_cleanup_data *data = (struct take_wait_take_cleanup_data *)ptr;
- ractor_take_cleanup(cr, data->r, data->tb);
-}
-
-static void
-ractor_wait_take(rb_execution_context_t *ec, rb_ractor_t *cr, rb_ractor_t *r, struct rb_ractor_basket *take_basket)
-{
- struct take_wait_take_cleanup_data data = {
- .r = r,
- .tb = take_basket,
- };
-
- RACTOR_LOCK_SELF(cr);
- {
- if (basket_none_p(take_basket) || basket_type_p(take_basket, basket_type_yielding)) {
- ractor_sleep_with_cleanup(ec, cr, wait_taking, ractor_wait_take_cleanup, &data);
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-}
-
-static VALUE
-ractor_take(rb_execution_context_t *ec, rb_ractor_t *r)
-{
- RUBY_DEBUG_LOG("from r:%u", rb_ractor_id(r));
- VALUE v;
- rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
-
- struct rb_ractor_basket take_basket = {
- .type.e = basket_type_none,
- .sender = 0,
- };
-
- ractor_register_take(cr, r, &take_basket, true, NULL, false);
-
- while (UNDEF_P(v = ractor_try_take(cr, r, &take_basket))) {
- ractor_wait_take(ec, cr, r, &take_basket);
- }
-
- VM_ASSERT(!basket_none_p(&take_basket));
- VM_ASSERT(!ractor_check_specific_take_basket_lock(r, &take_basket));
-
- return v;
-}
-
-// Ractor.yield
-
-static bool
-ractor_check_take_basket(rb_ractor_t *cr, struct rb_ractor_queue *rs)
-{
- ASSERT_ractor_locking(cr);
-
- for (int i=0; i<rs->cnt; i++) {
- struct rb_ractor_basket *b = ractor_queue_at(cr, rs, i);
- if (basket_type_p(b, basket_type_take_basket) &&
- basket_none_p(b->p.take.basket)) {
- return true;
- }
- }
-
- return false;
-}
-
-static bool
-ractor_deq_take_basket(rb_ractor_t *cr, struct rb_ractor_queue *rs, struct rb_ractor_basket *b)
-{
- ASSERT_ractor_unlocking(cr);
- struct rb_ractor_basket *first_tb = NULL;
- bool found = false;
-
- RACTOR_LOCK_SELF(cr);
- {
- while (ractor_queue_deq(cr, rs, b)) {
- if (basket_type_p(b, basket_type_take_basket)) {
- struct rb_ractor_basket *tb = b->p.take.basket;
-
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_none, basket_type_yielding) == basket_type_none) {
- found = true;
- break;
- }
- else {
- ractor_queue_enq(cr, rs, b);
- if (first_tb == NULL) first_tb = tb;
- struct rb_ractor_basket *head = ractor_queue_head(cr, rs);
- VM_ASSERT(head != NULL);
- if (basket_type_p(head, basket_type_take_basket) && head->p.take.basket == first_tb) {
- break; // loop detected
- }
- }
- }
- else {
- VM_ASSERT(basket_none_p(b));
- }
- }
-
- if (found && b->p.take.config && !b->p.take.config->oneshot) {
- ractor_queue_enq(cr, rs, b);
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-
- return found;
-}
-
-static bool
-ractor_try_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_queue *ts, VALUE obj, VALUE move, bool exc, bool is_will)
-{
- ASSERT_ractor_unlocking(cr);
-
- struct rb_ractor_basket b;
-
- if (ractor_deq_take_basket(cr, ts, &b)) {
- VM_ASSERT(basket_type_p(&b, basket_type_take_basket));
- VM_ASSERT(basket_type_p(b.p.take.basket, basket_type_yielding));
-
- rb_ractor_t *tr = RACTOR_PTR(b.sender);
- struct rb_ractor_basket *tb = b.p.take.basket;
- enum rb_ractor_basket_type type;
-
- RUBY_DEBUG_LOG("basket from r:%u", rb_ractor_id(tr));
-
- if (is_will) {
- type = basket_type_will;
- }
- else {
- int state;
-
- // begin
- EC_PUSH_TAG(ec);
- if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- // TODO: Ractor local GC
- ractor_basket_prepare_contents(obj, move, &obj, &type);
- }
- EC_POP_TAG();
- // rescue
- if (state) {
- RACTOR_LOCK_SELF(cr);
- {
- b.p.take.basket->type.e = basket_type_none;
- ractor_queue_enq(cr, ts, &b);
- }
- RACTOR_UNLOCK_SELF(cr);
- EC_JUMP_TAG(ec, state);
- }
- }
-
- RACTOR_LOCK(tr);
- {
- VM_ASSERT(basket_type_p(tb, basket_type_yielding));
- // fill atomic
- RUBY_DEBUG_LOG("fill %sbasket from r:%u", is_will ? "will " : "", rb_ractor_id(tr));
- ractor_basket_fill_(cr, tb, obj, exc);
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_yielding, type) != basket_type_yielding) {
- rb_bug("unreachable");
- }
- ractor_wakeup(tr, wait_taking, wakeup_by_yield);
- }
- RACTOR_UNLOCK(tr);
-
- return true;
- }
- else {
- RUBY_DEBUG_LOG("no take basket");
- return false;
- }
-}
-
-static void
-ractor_wait_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_queue *ts)
-{
- RACTOR_LOCK_SELF(cr);
- {
- while (!ractor_check_take_basket(cr, ts)) {
- ractor_sleep(ec, cr, wait_yielding);
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-}
-
-static VALUE
-ractor_yield(rb_execution_context_t *ec, rb_ractor_t *cr, VALUE obj, VALUE move)
-{
- struct rb_ractor_queue *ts = &cr->sync.takers_queue;
-
- while (!ractor_try_yield(ec, cr, ts, obj, move, false, false)) {
- ractor_wait_yield(ec, cr, ts);
- }
-
- return Qnil;
-}
-
-// Ractor::Selector
-
-struct rb_ractor_selector {
- rb_ractor_t *r;
- struct rb_ractor_basket take_basket;
- st_table *take_ractors; // rb_ractor_t * => (struct rb_ractor_selector_take_config *)
-};
-
-static int
-ractor_selector_mark_ractors_i(st_data_t key, st_data_t value, st_data_t data)
-{
- const rb_ractor_t *r = (rb_ractor_t *)key;
- rb_gc_mark(r->pub.self);
- return ST_CONTINUE;
-}
-
-static void
-ractor_selector_mark(void *ptr)
-{
- struct rb_ractor_selector *s = ptr;
-
- if (s->take_ractors) {
- st_foreach(s->take_ractors, ractor_selector_mark_ractors_i, 0);
- }
-
- switch (s->take_basket.type.e) {
- case basket_type_ref:
- case basket_type_copy:
- case basket_type_move:
- case basket_type_will:
- rb_gc_mark(s->take_basket.sender);
- rb_gc_mark(s->take_basket.p.send.v);
- break;
- default:
- break;
- }
-}
-
-static int
-ractor_selector_release_i(st_data_t key, st_data_t val, st_data_t data)
-{
- struct rb_ractor_selector *s = (struct rb_ractor_selector *)data;
- struct rb_ractor_selector_take_config *config = (struct rb_ractor_selector_take_config *)val;
-
- if (!config->closed) {
- ractor_deregister_take((rb_ractor_t *)key, &s->take_basket);
- }
- free(config);
- return ST_CONTINUE;
-}
-
-static void
-ractor_selector_free(void *ptr)
-{
- struct rb_ractor_selector *s = ptr;
- st_foreach(s->take_ractors, ractor_selector_release_i, (st_data_t)s);
- st_free_table(s->take_ractors);
- ruby_xfree(ptr);
-}
-
-static size_t
-ractor_selector_memsize(const void *ptr)
-{
- const struct rb_ractor_selector *s = ptr;
- return sizeof(struct rb_ractor_selector) +
- st_memsize(s->take_ractors) +
- s->take_ractors->num_entries * sizeof(struct rb_ractor_selector_take_config);
-}
-
-static const rb_data_type_t ractor_selector_data_type = {
- "ractor/selector",
- {
- ractor_selector_mark,
- ractor_selector_free,
- ractor_selector_memsize,
- NULL, // update
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
-};
-
-static struct rb_ractor_selector *
-RACTOR_SELECTOR_PTR(VALUE selv)
-{
- VM_ASSERT(rb_typeddata_is_kind_of(selv, &ractor_selector_data_type));
-
- return (struct rb_ractor_selector *)DATA_PTR(selv);
-}
-
-// Ractor::Selector.new
-
-static VALUE
-ractor_selector_create(VALUE crv)
-{
- struct rb_ractor_selector *s;
- VALUE selv = TypedData_Make_Struct(rb_cRactorSelector, struct rb_ractor_selector, &ractor_selector_data_type, s);
- s->take_basket.type.e = basket_type_reserved;
- s->take_ractors = st_init_numtable(); // ractor (ptr) -> take_config
- return selv;
-}
-
-// Ractor::Selector#add(r)
-
-static VALUE
-ractor_selector_add(rb_execution_context_t *ec, VALUE selv, VALUE rv)
-{
- if (!rb_ractor_p(rv)) {
- rb_raise(rb_eArgError, "Not a ractor object");
- }
-
- rb_ractor_t *r = RACTOR_PTR(rv);
- struct rb_ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
-
- if (st_lookup(s->take_ractors, (st_data_t)r, NULL)) {
- rb_raise(rb_eArgError, "already added");
- }
-
- struct rb_ractor_selector_take_config *config = malloc(sizeof(struct rb_ractor_selector_take_config));
- VM_ASSERT(config != NULL);
- config->closed = false;
- config->oneshot = false;
-
- if (ractor_register_take(rb_ec_ractor_ptr(ec), r, &s->take_basket, false, config, true)) {
- st_insert(s->take_ractors, (st_data_t)r, (st_data_t)config);
- }
-
- return rv;
-}
-
-// Ractor::Selector#remove(r)
-
-static VALUE
-ractor_selector_remove(rb_execution_context_t *ec, VALUE selv, VALUE rv)
-{
- if (!rb_ractor_p(rv)) {
- rb_raise(rb_eArgError, "Not a ractor object");
- }
-
- rb_ractor_t *r = RACTOR_PTR(rv);
- struct rb_ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
-
- RUBY_DEBUG_LOG("r:%u", rb_ractor_id(r));
-
- if (!st_lookup(s->take_ractors, (st_data_t)r, NULL)) {
- rb_raise(rb_eArgError, "not added yet");
- }
-
- ractor_deregister_take(r, &s->take_basket);
- struct rb_ractor_selector_take_config *config;
- st_delete(s->take_ractors, (st_data_t *)&r, (st_data_t *)&config);
- free(config);
-
- return rv;
-}
-
-// Ractor::Selector#clear
-
-struct ractor_selector_clear_data {
- VALUE selv;
- rb_execution_context_t *ec;
-};
-
-static int
-ractor_selector_clear_i(st_data_t key, st_data_t val, st_data_t data)
-{
- struct ractor_selector_clear_data *ptr = (struct ractor_selector_clear_data *)data;
- rb_ractor_t *r = (rb_ractor_t *)key;
- ractor_selector_remove(ptr->ec, ptr->selv, r->pub.self);
- return ST_CONTINUE;
-}
-
-static VALUE
-ractor_selector_clear(rb_execution_context_t *ec, VALUE selv)
-{
- struct ractor_selector_clear_data data = {
- .selv = selv,
- .ec = ec,
- };
- struct rb_ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
-
- st_foreach(s->take_ractors, ractor_selector_clear_i, (st_data_t)&data);
- st_clear(s->take_ractors);
- return selv;
-}
-
-static VALUE
-ractor_selector_empty_p(rb_execution_context_t *ec, VALUE selv)
-{
- struct rb_ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
- return s->take_ractors->num_entries == 0 ? Qtrue : Qfalse;
-}
-
-static int
-ractor_selector_wait_i(st_data_t key, st_data_t val, st_data_t dat)
-{
- rb_ractor_t *r = (rb_ractor_t *)key;
- struct rb_ractor_basket *tb = (struct rb_ractor_basket *)dat;
- int ret;
-
- if (!basket_none_p(tb)) {
- RUBY_DEBUG_LOG("already taken:%s", basket_type_name(tb->type.e));
- return ST_STOP;
- }
-
- RACTOR_LOCK(r);
- {
- if (basket_type_p(&r->sync.will_basket, basket_type_will)) {
- RUBY_DEBUG_LOG("r:%u has will", rb_ractor_id(r));
-
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_none, basket_type_will) == basket_type_none) {
- ractor_take_will(r, tb);
- ret = ST_STOP;
- }
- else {
- RUBY_DEBUG_LOG("has will, but already taken (%s)", basket_type_name(tb->type.e));
- ret = ST_CONTINUE;
- }
- }
- else if (r->sync.outgoing_port_closed) {
- RUBY_DEBUG_LOG("r:%u is closed", rb_ractor_id(r));
-
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_none, basket_type_deleted) == basket_type_none) {
- tb->sender = r->pub.self;
- ret = ST_STOP;
- }
- else {
- RUBY_DEBUG_LOG("closed, but already taken (%s)", basket_type_name(tb->type.e));
- ret = ST_CONTINUE;
- }
- }
- else {
- RUBY_DEBUG_LOG("wakeup r:%u", rb_ractor_id(r));
- ractor_wakeup(r, wait_yielding, wakeup_by_take);
- ret = ST_CONTINUE;
- }
- }
- RACTOR_UNLOCK(r);
-
- return ret;
-}
-
-// Ractor::Selector#wait
-
-static void
-ractor_selector_wait_cleaup(rb_ractor_t *cr, void *ptr)
-{
- struct rb_ractor_basket *tb = (struct rb_ractor_basket *)ptr;
-
- RACTOR_LOCK_SELF(cr);
- {
- while (basket_type_p(tb, basket_type_yielding)) rb_thread_sleep(0);
- // if tb->type is not none, taking is succeeded, but interruption ignore it unfortunately.
- tb->type.e = basket_type_reserved;
- }
- RACTOR_UNLOCK_SELF(cr);
-}
-
-static VALUE
-ractor_selector_wait(rb_execution_context_t *ec, VALUE selv, VALUE do_receivev, VALUE do_yieldv, VALUE yield_value, VALUE move)
-{
- struct rb_ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
- struct rb_ractor_basket *tb = &s->take_basket;
- struct rb_ractor_basket taken_basket;
- rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
- bool do_receive = !!RTEST(do_receivev);
- bool do_yield = !!RTEST(do_yieldv);
- VALUE ret_v, ret_r;
- enum rb_ractor_wait_status wait_status;
- struct rb_ractor_queue *rq = &cr->sync.recv_queue;
- struct rb_ractor_queue *ts = &cr->sync.takers_queue;
-
- RUBY_DEBUG_LOG("start");
-
- retry:
- RUBY_DEBUG_LOG("takers:%ld", s->take_ractors->num_entries);
-
- // setup wait_status
- wait_status = wait_none;
- if (s->take_ractors->num_entries > 0) wait_status |= wait_taking;
- if (do_receive) wait_status |= wait_receiving;
- if (do_yield) wait_status |= wait_yielding;
-
- RUBY_DEBUG_LOG("wait:%s", wait_status_str(wait_status));
-
- if (wait_status == wait_none) {
- rb_raise(rb_eRactorError, "no taking ractors");
- }
-
- // check recv_queue
- if (do_receive && (ret_v = ractor_try_receive(ec, cr, rq)) != Qundef) {
- ret_r = ID2SYM(rb_intern("receive"));
- goto success;
- }
-
- // check takers
- if (do_yield && ractor_try_yield(ec, cr, ts, yield_value, move, false, false)) {
- ret_v = Qnil;
- ret_r = ID2SYM(rb_intern("yield"));
- goto success;
- }
-
- // check take_basket
- VM_ASSERT(basket_type_p(&s->take_basket, basket_type_reserved));
- s->take_basket.type.e = basket_type_none;
- // kick all take target ractors
- st_foreach(s->take_ractors, ractor_selector_wait_i, (st_data_t)tb);
-
- RACTOR_LOCK_SELF(cr);
- {
- retry_waiting:
- while (1) {
- if (!basket_none_p(tb)) {
- RUBY_DEBUG_LOG("taken:%s from r:%u", basket_type_name(tb->type.e),
- tb->sender ? rb_ractor_id(RACTOR_PTR(tb->sender)) : 0);
- break;
- }
- if (do_receive && !ractor_queue_empty_p(cr, rq)) {
- RUBY_DEBUG_LOG("can receive (%d)", rq->cnt);
- break;
- }
- if (do_yield && ractor_check_take_basket(cr, ts)) {
- RUBY_DEBUG_LOG("can yield");
- break;
- }
-
- ractor_sleep_with_cleanup(ec, cr, wait_status, ractor_selector_wait_cleaup, tb);
- }
-
- taken_basket = *tb;
-
- // ensure
- // tb->type.e = basket_type_reserved # do it atomic in the following code
- if (taken_basket.type.e == basket_type_yielding ||
- RUBY_ATOMIC_CAS(tb->type.atomic, taken_basket.type.e, basket_type_reserved) != taken_basket.type.e) {
-
- if (basket_type_p(tb, basket_type_yielding)) {
- RACTOR_UNLOCK_SELF(cr);
- {
- rb_thread_sleep(0);
- }
- RACTOR_LOCK_SELF(cr);
- }
- goto retry_waiting;
- }
- }
- RACTOR_UNLOCK_SELF(cr);
-
- // check the taken resutl
- switch (taken_basket.type.e) {
- case basket_type_none:
- VM_ASSERT(do_receive || do_yield);
- goto retry;
- case basket_type_yielding:
- rb_bug("unreachable");
- case basket_type_deleted: {
- ractor_selector_remove(ec, selv, taken_basket.sender);
-
- rb_ractor_t *r = RACTOR_PTR(taken_basket.sender);
- if (ractor_take_will_lock(r, &taken_basket)) {
- RUBY_DEBUG_LOG("has_will");
- }
- else {
- RUBY_DEBUG_LOG("no will");
- // rb_raise(rb_eRactorClosedError, "The outgoing-port is already closed");
- // remove and retry wait
- goto retry;
- }
- break;
- }
- case basket_type_will:
- // no more messages
- ractor_selector_remove(ec, selv, taken_basket.sender);
- break;
- default:
- break;
- }
-
- RUBY_DEBUG_LOG("taken_basket:%s", basket_type_name(taken_basket.type.e));
-
- ret_v = ractor_basket_accept(&taken_basket);
- ret_r = taken_basket.sender;
- success:
- return rb_ary_new_from_args(2, ret_r, ret_v);
-}
-
-// Ractor#close_incoming
-
-static VALUE
-ractor_close_incoming(rb_execution_context_t *ec, rb_ractor_t *r)
-{
- VALUE prev;
-
- RACTOR_LOCK(r);
- {
- if (!r->sync.incoming_port_closed) {
- prev = Qfalse;
- r->sync.incoming_port_closed = true;
- if (ractor_wakeup(r, wait_receiving, wakeup_by_close)) {
- VM_ASSERT(ractor_queue_empty_p(r, &r->sync.recv_queue));
- RUBY_DEBUG_LOG("cancel receiving");
- }
- }
- else {
- prev = Qtrue;
- }
- }
- RACTOR_UNLOCK(r);
- return prev;
-}
-
-// Ractor#close_outgoing
-
-static VALUE
-ractor_close_outgoing(rb_execution_context_t *ec, rb_ractor_t *r)
-{
- VALUE prev;
-
- RACTOR_LOCK(r);
- {
- struct rb_ractor_queue *ts = &r->sync.takers_queue;
- rb_ractor_t *tr;
- struct rb_ractor_basket b;
-
- if (!r->sync.outgoing_port_closed) {
- prev = Qfalse;
- r->sync.outgoing_port_closed = true;
- }
- else {
- VM_ASSERT(ractor_queue_empty_p(r, ts));
- prev = Qtrue;
- }
-
- // wakeup all taking ractors
- while (ractor_queue_deq(r, ts, &b)) {
- if (basket_type_p(&b, basket_type_take_basket)) {
- tr = RACTOR_PTR(b.sender);
- struct rb_ractor_basket *tb = b.p.take.basket;
-
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_none, basket_type_yielding) == basket_type_none) {
- b.p.take.basket->sender = r->pub.self;
- if (RUBY_ATOMIC_CAS(tb->type.atomic, basket_type_yielding, basket_type_deleted) != basket_type_yielding) {
- rb_bug("unreachable");
- }
- RUBY_DEBUG_LOG("set delete for r:%u", rb_ractor_id(RACTOR_PTR(b.sender)));
- }
-
- if (b.p.take.config) {
- b.p.take.config->closed = true;
- }
-
- // TODO: deadlock-able?
- RACTOR_LOCK(tr);
- {
- ractor_wakeup(tr, wait_taking, wakeup_by_close);
- }
- RACTOR_UNLOCK(tr);
- }
- }
-
- // raising yielding Ractor
- ractor_wakeup(r, wait_yielding, wakeup_by_close);
-
- VM_ASSERT(ractor_queue_empty_p(r, ts));
- }
- RACTOR_UNLOCK(r);
- return prev;
-}
+#include "ractor_sync.c"
// creation/termination
@@ -1821,6 +381,13 @@ vm_insert_ractor0(rb_vm_t *vm, rb_ractor_t *r, bool single_ractor_mode)
ccan_list_add_tail(&vm->ractor.set, &r->vmlr_node);
vm->ractor.cnt++;
+
+ if (r->newobj_cache) {
+ VM_ASSERT(r == ruby_single_main_ractor);
+ }
+ else {
+ r->newobj_cache = rb_gc_ractor_cache_alloc(r);
+ }
}
static void
@@ -1829,16 +396,8 @@ cancel_single_ractor_mode(void)
// enable multi-ractor mode
RUBY_DEBUG_LOG("enable multi-ractor mode");
- VALUE was_disabled = rb_gc_enable();
-
- rb_gc_start();
- rb_transient_heap_evacuate();
-
- if (was_disabled) {
- rb_gc_disable();
- }
-
ruby_single_main_ractor = NULL;
+ rb_funcall(rb_cRactor, rb_intern("_activated"), 0);
}
static void
@@ -1889,8 +448,8 @@ vm_remove_ractor(rb_vm_t *vm, rb_ractor_t *cr)
}
vm->ractor.cnt--;
- /* Clear the cached freelist to prevent a memory leak. */
- rb_gc_ractor_newobj_cache_clear(&cr->newobj_cache);
+ rb_gc_ractor_cache_free(cr->newobj_cache);
+ cr->newobj_cache = NULL;
ractor_status_set(cr, ractor_terminated);
}
@@ -1904,29 +463,33 @@ ractor_alloc(VALUE klass)
VALUE rv = TypedData_Make_Struct(klass, rb_ractor_t, &ractor_data_type, r);
FL_SET_RAW(rv, RUBY_FL_SHAREABLE);
r->pub.self = rv;
+ r->next_ec_serial = 1;
VM_ASSERT(ractor_status_p(r, ractor_created));
return rv;
}
+static rb_ractor_t _main_ractor = {
+ .loc = Qnil,
+ .name = Qnil,
+ .pub.id = MAIN_RACTOR_ID,
+ .pub.self = Qnil,
+ .next_ec_serial = 1,
+ .main_ractor = true,
+};
+
rb_ractor_t *
rb_ractor_main_alloc(void)
{
- rb_ractor_t *r = ruby_mimmalloc(sizeof(rb_ractor_t));
- if (r == NULL) {
- fprintf(stderr, "[FATAL] failed to allocate memory for main ractor\n");
- exit(EXIT_FAILURE);
- }
- MEMZERO(r, rb_ractor_t, 1);
- r->pub.id = ++ractor_last_id;
- r->loc = Qnil;
- r->name = Qnil;
- r->pub.self = Qnil;
+ rb_ractor_t *r = &_main_ractor;
+ r->newobj_cache = rb_gc_ractor_cache_alloc(r);
ruby_single_main_ractor = r;
return r;
}
#if defined(HAVE_WORKING_FORK)
+// Set up the main Ractor for the VM after fork.
+// Puts us in "single Ractor mode"
void
rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th)
{
@@ -1942,9 +505,18 @@ rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th)
VM_ASSERT(vm->ractor.blocking_cnt == 0);
VM_ASSERT(vm->ractor.cnt == 1);
}
+
+void
+rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *r)
+{
+ rb_gc_ractor_cache_free(r->newobj_cache);
+ r->newobj_cache = NULL;
+ r->status_ = ractor_terminated;
+ ractor_sync_terminate_atfork(vm, r);
+}
#endif
-void rb_thread_sched_init(struct rb_thread_sched *);
+void rb_thread_sched_init(struct rb_thread_sched *, bool atfork);
void
rb_ractor_living_threads_init(rb_ractor_t *r)
@@ -1957,14 +529,12 @@ rb_ractor_living_threads_init(rb_ractor_t *r)
static void
ractor_init(rb_ractor_t *r, VALUE name, VALUE loc)
{
- ractor_queue_setup(&r->sync.recv_queue);
- ractor_queue_setup(&r->sync.takers_queue);
- rb_native_mutex_initialize(&r->sync.lock);
- rb_native_cond_initialize(&r->sync.cond);
- rb_native_cond_initialize(&r->barrier_wait_cond);
+ ractor_sync_init(r);
+ st_init_existing_numtable_with_size(&r->pub.targeted_hooks, 0);
+ r->pub.hooks.type = hook_list_type_ractor_local;
// thread management
- rb_thread_sched_init(&r->threads.sched);
+ rb_thread_sched_init(&r->threads.sched, false);
rb_ractor_living_threads_init(r);
// naming
@@ -1976,20 +546,24 @@ ractor_init(rb_ractor_t *r, VALUE name, VALUE loc)
rb_raise(rb_eArgError, "ASCII incompatible encoding (%s)",
rb_enc_name(enc));
}
- name = rb_str_new_frozen(name);
+ name = RB_OBJ_SET_SHAREABLE(rb_str_new_frozen(name));
}
- r->name = name;
+
+ if (!SPECIAL_CONST_P(loc)) RB_OBJ_SET_SHAREABLE(loc);
r->loc = loc;
+ r->name = name;
}
void
rb_ractor_main_setup(rb_vm_t *vm, rb_ractor_t *r, rb_thread_t *th)
{
- r->pub.self = TypedData_Wrap_Struct(rb_cRactor, &ractor_data_type, r);
+ VALUE rv = r->pub.self = TypedData_Wrap_Struct(rb_cRactor, &ractor_data_type, r);
FL_SET_RAW(r->pub.self, RUBY_FL_SHAREABLE);
ractor_init(r, Qnil, Qnil);
r->threads.main = th;
rb_ractor_living_threads_insert(r, th);
+
+ RB_GC_GUARD(rv);
}
static VALUE
@@ -1999,7 +573,6 @@ ractor_create(rb_execution_context_t *ec, VALUE self, VALUE loc, VALUE name, VAL
rb_ractor_t *r = RACTOR_PTR(rv);
ractor_init(r, name, loc);
- // can block here
r->pub.id = ractor_next_id();
RUBY_DEBUG_LOG("r:%u", r->pub.id);
@@ -2008,83 +581,59 @@ ractor_create(rb_execution_context_t *ec, VALUE self, VALUE loc, VALUE name, VAL
r->debug = cr->debug;
rb_yjit_before_ractor_spawn();
- rb_rjit_before_ractor_spawn();
+ rb_zjit_before_ractor_spawn();
rb_thread_create_ractor(r, args, block);
RB_GC_GUARD(rv);
return rv;
}
-static void
-ractor_yield_atexit(rb_execution_context_t *ec, rb_ractor_t *cr, VALUE v, bool exc)
+#if 0
+static VALUE
+ractor_create_func(VALUE klass, VALUE loc, VALUE name, VALUE args, rb_block_call_func_t func)
{
- if (cr->sync.outgoing_port_closed) {
- return;
- }
-
- ASSERT_ractor_unlocking(cr);
-
- struct rb_ractor_queue *ts = &cr->sync.takers_queue;
-
- retry:
- if (ractor_try_yield(ec, cr, ts, v, Qfalse, exc, true)) {
- // OK.
- }
- else {
- bool retry = false;
- RACTOR_LOCK(cr);
- {
- if (!ractor_check_take_basket(cr, ts)) {
- VM_ASSERT(cr->sync.wait.status == wait_none);
- RUBY_DEBUG_LOG("leave a will");
- ractor_basket_fill_will(cr, &cr->sync.will_basket, v, exc);
- }
- else {
- RUBY_DEBUG_LOG("rare timing!");
- retry = true; // another ractor is waiting for the yield.
- }
- }
- RACTOR_UNLOCK(cr);
+ VALUE block = rb_proc_new(func, Qnil);
+ return ractor_create(rb_current_ec_noinline(), klass, loc, name, args, block);
+}
+#endif
- if (retry) goto retry;
- }
+static void
+ractor_atexit(rb_execution_context_t *ec, rb_ractor_t *cr, VALUE result, bool exc)
+{
+ ractor_notify_exit(ec, cr, result, exc);
}
void
rb_ractor_atexit(rb_execution_context_t *ec, VALUE result)
{
rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
- ractor_yield_atexit(ec, cr, result, false);
+ ractor_atexit(ec, cr, result, false);
}
void
rb_ractor_atexit_exception(rb_execution_context_t *ec)
{
rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
- ractor_yield_atexit(ec, cr, ec->errinfo, true);
+ ractor_atexit(ec, cr, ec->errinfo, true);
}
void
rb_ractor_teardown(rb_execution_context_t *ec)
{
rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
- ractor_close_incoming(ec, cr);
- ractor_close_outgoing(ec, cr);
// sync with rb_ractor_terminate_interrupt_main_thread()
- RB_VM_LOCK_ENTER();
- {
+ RB_VM_LOCKING() {
VM_ASSERT(cr->threads.main != NULL);
cr->threads.main = NULL;
}
- RB_VM_LOCK_LEAVE();
}
void
rb_ractor_receive_parameters(rb_execution_context_t *ec, rb_ractor_t *r, int len, VALUE *ptr)
{
for (int i=0; i<len; i++) {
- ptr[i] = ractor_receive(ec, r);
+ ptr[i] = ractor_receive(ec, ractor_default_port(r));
}
}
@@ -2093,7 +642,7 @@ rb_ractor_send_parameters(rb_execution_context_t *ec, rb_ractor_t *r, VALUE args
{
int len = RARRAY_LENINT(args);
for (int i=0; i<len; i++) {
- ractor_send(ec, r, RARRAY_AREF(args, i), false);
+ ractor_send(ec, ractor_default_port(r), RARRAY_AREF(args, i), false);
}
}
@@ -2105,49 +654,30 @@ rb_ractor_main_p_(void)
return rb_ec_ractor_ptr(ec) == rb_ec_vm_ptr(ec)->ractor.main_ractor;
}
-bool
-rb_obj_is_main_ractor(VALUE gv)
-{
- if (!rb_ractor_p(gv)) return false;
- rb_ractor_t *r = DATA_PTR(gv);
- return r == GET_VM()->ractor.main_ractor;
-}
-
int
rb_ractor_living_thread_num(const rb_ractor_t *r)
{
return r->threads.cnt;
}
+// only for current ractor
VALUE
-rb_ractor_thread_list(rb_ractor_t *r)
+rb_ractor_thread_list(void)
{
+ rb_ractor_t *r = GET_RACTOR();
rb_thread_t *th = 0;
- VALUE *ts;
- int ts_cnt;
+ VALUE ary = rb_ary_new();
- RACTOR_LOCK(r);
- {
- ts = ALLOCA_N(VALUE, r->threads.cnt);
- ts_cnt = 0;
-
- ccan_list_for_each(&r->threads.set, th, lt_node) {
- switch (th->status) {
- case THREAD_RUNNABLE:
- case THREAD_STOPPED:
- case THREAD_STOPPED_FOREVER:
- ts[ts_cnt++] = th->self;
- default:
- break;
- }
+ ccan_list_for_each(&r->threads.set, th, lt_node) {
+ switch (th->status) {
+ case THREAD_RUNNABLE:
+ case THREAD_STOPPED:
+ case THREAD_STOPPED_FOREVER:
+ rb_ary_push(ary, th->self);
+ default:
+ break;
}
}
- RACTOR_UNLOCK(r);
-
- VALUE ary = rb_ary_new();
- for (int i=0; i<ts_cnt; i++) {
- rb_ary_push(ary, ts[i]);
- }
return ary;
}
@@ -2220,16 +750,15 @@ ractor_check_blocking(rb_ractor_t *cr, unsigned int remained_thread_cnt, const c
cr->threads.cnt == cr->threads.blocking_cnt + 1) {
// change ractor status: running -> blocking
rb_vm_t *vm = GET_VM();
- ASSERT_vm_unlocking();
- RB_VM_LOCK();
- {
+ RB_VM_LOCKING() {
rb_vm_ractor_blocking_cnt_inc(vm, cr, file, line);
}
- RB_VM_UNLOCK();
}
}
+void rb_threadptr_remove(rb_thread_t *th);
+
void
rb_ractor_living_threads_remove(rb_ractor_t *cr, rb_thread_t *th)
{
@@ -2237,6 +766,8 @@ rb_ractor_living_threads_remove(rb_ractor_t *cr, rb_thread_t *th)
RUBY_DEBUG_LOG("r->threads.cnt:%d--", cr->threads.cnt);
ractor_check_blocking(cr, cr->threads.cnt - 1, __FILE__, __LINE__);
+ rb_threadptr_remove(th);
+
if (cr->threads.cnt == 1) {
vm_remove_ractor(th->vm, cr);
}
@@ -2274,11 +805,9 @@ rb_ractor_blocking_threads_dec(rb_ractor_t *cr, const char *file, int line)
if (cr->threads.cnt == cr->threads.blocking_cnt) {
rb_vm_t *vm = GET_VM();
- RB_VM_LOCK_ENTER();
- {
+ RB_VM_LOCKING() {
rb_vm_ractor_blocking_cnt_dec(vm, cr, __FILE__, __LINE__);
}
- RB_VM_LOCK_LEAVE();
}
cr->threads.blocking_cnt--;
@@ -2332,25 +861,31 @@ ractor_terminal_interrupt_all(rb_vm_t *vm)
rb_ractor_t *r = 0;
ccan_list_for_each(&vm->ractor.set, r, vmlr_node) {
if (r != vm->ractor.main_ractor) {
+ RUBY_DEBUG_LOG("r:%d", rb_ractor_id(r));
rb_ractor_terminate_interrupt_main_thread(r);
}
}
}
}
+void rb_add_running_thread(rb_thread_t *th);
+void rb_del_running_thread(rb_thread_t *th);
+
void
rb_ractor_terminate_all(void)
{
rb_vm_t *vm = GET_VM();
rb_ractor_t *cr = vm->ractor.main_ractor;
+ RUBY_DEBUG_LOG("ractor.cnt:%d", (int)vm->ractor.cnt);
+
VM_ASSERT(cr == GET_RACTOR()); // only main-ractor's main-thread should kick it.
- if (vm->ractor.cnt > 1) {
- RB_VM_LOCK();
+ RB_VM_LOCK();
+ {
ractor_terminal_interrupt_all(vm); // kill all ractors
- RB_VM_UNLOCK();
}
+ RB_VM_UNLOCK();
rb_thread_terminate_all(GET_THREAD()); // kill other threads in main-ractor and wait
RB_VM_LOCK();
@@ -2361,7 +896,20 @@ rb_ractor_terminate_all(void)
// wait for 1sec
rb_vm_ractor_blocking_cnt_inc(vm, cr, __FILE__, __LINE__);
+ rb_del_running_thread(rb_ec_thread_ptr(cr->threads.running_ec));
rb_vm_cond_timedwait(vm, &vm->ractor.sync.terminate_cond, 1000 /* ms */);
+#ifdef RUBY_THREAD_PTHREAD_H
+ while (vm->ractor.sched.barrier_waiting) {
+ // A barrier is waiting. Threads relinquish the VM lock before joining the barrier and
+ // since we just acquired the VM lock back, we're blocking other threads from joining it.
+ // We loop until the barrier is over. We can't join this barrier because our thread isn't added to
+ // running_threads until the call below to `rb_add_running_thread`.
+ RB_VM_UNLOCK();
+ unsigned int lev;
+ RB_VM_LOCK_ENTER_LEV_NB(&lev);
+ }
+#endif
+ rb_add_running_thread(rb_ec_thread_ptr(cr->threads.running_ec));
rb_vm_ractor_blocking_cnt_dec(vm, cr, __FILE__, __LINE__);
ractor_terminal_interrupt_all(vm);
@@ -2373,7 +921,23 @@ rb_ractor_terminate_all(void)
rb_execution_context_t *
rb_vm_main_ractor_ec(rb_vm_t *vm)
{
- return vm->ractor.main_ractor->threads.running_ec;
+ /* This code needs to carefully work around two bugs:
+ * - Bug #20016: When M:N threading is enabled, running_ec is NULL if no thread is
+ * actually currently running (as opposed to without M:N threading, when
+ * running_ec will still point to the _last_ thread which ran)
+ * - Bug #20197: If the main thread is sleeping, setting its postponed job
+ * interrupt flag is pointless; it won't look at the flag until it stops sleeping
+ * for some reason. It would be better to set the flag on the running ec, which
+ * will presumably look at it soon.
+ *
+ * Solution: use running_ec if it's set, otherwise fall back to the main thread ec.
+ * This is still susceptible to some rare race conditions (what if the last thread
+ * to run just entered a long-running sleep?), but seems like the best balance of
+ * robustness and complexity.
+ */
+ rb_execution_context_t *running_ec = vm->ractor.main_ractor->threads.running_ec;
+ if (running_ec) { return running_ec; }
+ return vm->ractor.main_thread->ec;
}
static VALUE
@@ -2383,53 +947,46 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self)
}
/*
+ * Document-class: Ractor::Error
+ *
+ * The parent class of Ractor-related error classes.
+ */
+
+/*
* Document-class: Ractor::ClosedError
*
* Raised when an attempt is made to send a message to a closed port,
* or to retrieve a message from a closed and empty port.
- * Ports may be closed explicitly with Ractor#close_outgoing/close_incoming
+ * Ports may be closed explicitly with Ractor::Port#close
* and are closed implicitly when a Ractor terminates.
*
- * r = Ractor.new { sleep(500) }
- * r.close_outgoing
- * r.take # Ractor::ClosedError
- *
- * ClosedError is a descendant of StopIteration, so the closing of the ractor will break
- * the loops without propagating the error:
+ * port = Ractor::Port.new
+ * port.close
+ * port << "test" # Ractor::ClosedError
+ * port.receive # Ractor::ClosedError
*
- * r = Ractor.new do
- * loop do
- * msg = receive # raises ClosedError and loop traps it
- * puts "Received: #{msg}"
- * end
- * puts "loop exited"
- * end
- *
- * 3.times{|i| r << i}
- * r.close_incoming
- * r.take
- * puts "Continue successfully"
- *
- * This will print:
+ * ClosedError is a descendant of StopIteration, so the closing of a port will break
+ * out of loops without propagating the error.
+ */
+
+/*
+ * Document-class: Ractor::IsolationError
*
- * Received: 0
- * Received: 1
- * Received: 2
- * loop exited
- * Continue successfully
+ * Raised on attempt to make a Ractor-unshareable object
+ * Ractor-shareable.
*/
/*
* Document-class: Ractor::RemoteError
*
- * Raised on attempt to Ractor#take if there was an uncaught exception in the Ractor.
+ * Raised on Ractor#join or Ractor#value if there was an uncaught exception in the Ractor.
* Its +cause+ will contain the original exception, and +ractor+ is the original ractor
* it was raised in.
*
* r = Ractor.new { raise "Something weird happened" }
*
* begin
- * r.take
+ * r.value
* rescue => e
* p e # => #<Ractor::RemoteError: thrown by remote Ractor.>
* p e.ractor == r # => true
@@ -2441,7 +998,7 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self)
/*
* Document-class: Ractor::MovedError
*
- * Raised on an attempt to access an object which was moved in Ractor#send or Ractor.yield.
+ * Raised on an attempt to access an object which was moved in Ractor#send or Ractor::Port#send.
*
* r = Ractor.new { sleep }
*
@@ -2456,7 +1013,7 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self)
* Document-class: Ractor::MovedObject
*
* A special object which replaces any value that was moved to another ractor in Ractor#send
- * or Ractor.yield. Any attempt to access the object results in Ractor::MovedError.
+ * or Ractor::Port#send. Any attempt to access the object results in Ractor::MovedError.
*
* r = Ractor.new { receive }
*
@@ -2468,6 +1025,12 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self)
* # Ractor::MovedError (can not send any methods to a moved object)
*/
+/*
+ * Document-class: Ractor::UnsafeError
+ *
+ * Raised when Ractor-unsafe C-methods is invoked by a non-main Ractor.
+ */
+
// Main docs are in ractor.rb, but without this clause there are weird artifacts
// in their rendering.
/*
@@ -2502,8 +1065,7 @@ Init_Ractor(void)
rb_define_method(rb_cRactorMovedObject, "instance_eval", ractor_moved_missing, -1);
rb_define_method(rb_cRactorMovedObject, "instance_exec", ractor_moved_missing, -1);
- rb_cRactorSelector = rb_define_class_under(rb_cRactor, "Selector", rb_cObject);
- rb_undef_alloc_func(rb_cRactorSelector);
+ Init_RactorPort();
}
void
@@ -2597,6 +1159,50 @@ rb_ractor_hooks(rb_ractor_t *cr)
return &cr->pub.hooks;
}
+st_table *
+rb_ractor_targeted_hooks(rb_ractor_t *cr)
+{
+ return &cr->pub.targeted_hooks;
+}
+
+static void
+rb_obj_set_shareable_no_assert(VALUE obj)
+{
+ FL_SET_RAW(obj, FL_SHAREABLE);
+
+ if (rb_obj_gen_fields_p(obj)) {
+ VALUE fields = rb_obj_fields_no_ractor_check(obj);
+ if (imemo_type_p(fields, imemo_fields)) {
+ // no recursive mark
+ FL_SET_RAW(fields, FL_SHAREABLE);
+ }
+ }
+}
+
+#ifndef STRICT_VERIFY_SHAREABLE
+#define STRICT_VERIFY_SHAREABLE 0
+#endif
+
+bool
+rb_ractor_verify_shareable(VALUE obj)
+{
+#if STRICT_VERIFY_SHAREABLE
+ rb_gc_verify_shareable(obj);
+#endif
+ return true;
+}
+
+VALUE
+rb_obj_set_shareable(VALUE obj)
+{
+ RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
+
+ rb_obj_set_shareable_no_assert(obj);
+ RUBY_ASSERT(rb_ractor_verify_shareable(obj));
+
+ return obj;
+}
+
/// traverse function
// 2: stop search
@@ -2649,19 +1255,6 @@ obj_hash_traverse_i(VALUE key, VALUE val, VALUE ptr)
return ST_CONTINUE;
}
-static enum rb_id_table_iterator_result
-obj_hash_iv_traverse_i(VALUE val, void *ptr)
-{
- struct obj_traverse_callback_data *d = (struct obj_traverse_callback_data *)ptr;
-
- if (obj_traverse_i(val, d->data)) {
- d->stop = true;
- return ID_TABLE_STOP;
- }
-
- return ID_TABLE_CONTINUE;
-}
-
static void
obj_traverse_reachable_i(VALUE obj, void *ptr)
{
@@ -2677,12 +1270,26 @@ obj_traverse_rec(struct obj_traverse_data *data)
{
if (UNLIKELY(!data->rec)) {
data->rec_hash = rb_ident_hash_new();
+ rb_obj_hide(data->rec_hash);
data->rec = RHASH_ST_TABLE(data->rec_hash);
}
return data->rec;
}
static int
+obj_traverse_ivar_foreach_i(ID key, VALUE val, st_data_t ptr)
+{
+ struct obj_traverse_callback_data *d = (struct obj_traverse_callback_data *)ptr;
+
+ if (obj_traverse_i(val, d->data)) {
+ d->stop = true;
+ return ST_STOP;
+ }
+
+ return ST_CONTINUE;
+}
+
+static int
obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
{
if (RB_SPECIAL_CONST_P(obj)) return 0;
@@ -2697,15 +1304,14 @@ obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
// already traversed
return 0;
}
+ RB_OBJ_WRITTEN(data->rec_hash, Qundef, obj);
- if (UNLIKELY(FL_TEST_RAW(obj, FL_EXIVAR))) {
- struct gen_ivtbl *ivtbl;
- rb_ivar_generic_ivtbl_lookup(obj, &ivtbl);
- for (uint32_t i = 0; i < ivtbl->numiv; i++) {
- VALUE val = ivtbl->ivptr[i];
- if (!UNDEF_P(val) && obj_traverse_i(val, data)) return 1;
- }
- }
+ struct obj_traverse_callback_data d = {
+ .stop = false,
+ .data = data,
+ };
+ rb_ivar_foreach(obj, obj_traverse_ivar_foreach_i, (st_data_t)&d);
+ if (d.stop) return 1;
switch (BUILTIN_TYPE(obj)) {
// no child node
@@ -2715,33 +1321,16 @@ obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
case T_REGEXP:
case T_FILE:
case T_SYMBOL:
- case T_MATCH:
break;
case T_OBJECT:
- {
- if (rb_shape_obj_too_complex(obj)) {
- struct obj_traverse_callback_data d = {
- .stop = false,
- .data = data,
- };
- rb_id_table_foreach_values(ROBJECT_IV_HASH(obj), obj_hash_iv_traverse_i, &d);
- if (d.stop) return 1;
- }
- else {
- uint32_t len = ROBJECT_IV_COUNT(obj);
- VALUE *ptr = ROBJECT_IVPTR(obj);
-
- for (uint32_t i=0; i<len; i++) {
- VALUE val = ptr[i];
- if (!UNDEF_P(val) && obj_traverse_i(val, data)) return 1;
- }
- }
- }
+ /* Instance variables already traversed. */
break;
case T_ARRAY:
{
+ rb_ary_cancel_sharing(obj);
+
for (int i = 0; i < RARRAY_LENINT(obj); i++) {
VALUE e = rb_ary_entry(obj, i);
if (obj_traverse_i(e, data)) return 1;
@@ -2764,7 +1353,7 @@ obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
case T_STRUCT:
{
- long len = RSTRUCT_LEN(obj);
+ long len = RSTRUCT_LEN_RAW(obj);
const VALUE *ptr = RSTRUCT_CONST_PTR(obj);
for (long i=0; i<len; i++) {
@@ -2773,6 +1362,10 @@ obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
}
break;
+ case T_MATCH:
+ if (obj_traverse_i(RMATCH(obj)->str, data)) return 1;
+ break;
+
case T_RATIONAL:
if (obj_traverse_i(RRATIONAL(obj)->num, data)) return 1;
if (obj_traverse_i(RRATIONAL(obj)->den, data)) return 1;
@@ -2789,11 +1382,9 @@ obj_traverse_i(VALUE obj, struct obj_traverse_data *data)
.stop = false,
.data = data,
};
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
+ RB_VM_LOCKING_NO_BARRIER() {
rb_objspace_reachable_objects_from(obj, obj_traverse_reachable_i, &d);
}
- RB_VM_LOCK_LEAVE_NO_BARRIER();
if (d.stop) return 1;
}
break;
@@ -2855,65 +1446,105 @@ rb_obj_traverse(VALUE obj,
}
static int
-frozen_shareable_p(VALUE obj, bool *made_shareable)
+allow_frozen_shareable_p(VALUE obj)
{
if (!RB_TYPE_P(obj, T_DATA)) {
return true;
}
- else if (RTYPEDDATA_P(obj)) {
+ else {
const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
if (type->flags & RUBY_TYPED_FROZEN_SHAREABLE) {
return true;
}
- else if (made_shareable && rb_obj_is_proc(obj)) {
- // special path to make shareable Proc.
- rb_proc_ractor_make_shareable(obj);
- *made_shareable = true;
- VM_ASSERT(RB_OBJ_SHAREABLE_P(obj));
- return false;
- }
}
return false;
}
static enum obj_traverse_iterator_result
+make_shareable_check_shareable_freeze(VALUE obj, enum obj_traverse_iterator_result result)
+{
+ if (!RB_OBJ_FROZEN_RAW(obj)) {
+ rb_funcall(obj, idFreeze, 0);
+
+ if (UNLIKELY(!RB_OBJ_FROZEN_RAW(obj))) {
+ rb_raise(rb_eRactorError, "#freeze does not freeze object correctly");
+ }
+
+ if (RB_OBJ_SHAREABLE_P(obj)) {
+ return traverse_skip;
+ }
+ }
+
+ return result;
+}
+
+static int obj_refer_only_shareables_p(VALUE obj);
+
+static enum obj_traverse_iterator_result
make_shareable_check_shareable(VALUE obj)
{
VM_ASSERT(!SPECIAL_CONST_P(obj));
- bool made_shareable = false;
if (rb_ractor_shareable_p(obj)) {
return traverse_skip;
}
- else if (!frozen_shareable_p(obj, &made_shareable)) {
- if (made_shareable) {
- return traverse_skip;
+ else if (!allow_frozen_shareable_p(obj)) {
+ VM_ASSERT(RB_TYPE_P(obj, T_DATA));
+ const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
+
+ if (type->flags & RUBY_TYPED_FROZEN_SHAREABLE_NO_REC) {
+ if (obj_refer_only_shareables_p(obj)) {
+ make_shareable_check_shareable_freeze(obj, traverse_skip);
+ RB_OBJ_SET_SHAREABLE(obj);
+ return traverse_skip;
+ }
+ else {
+ rb_raise(rb_eRactorError,
+ "can not make shareable object for %+"PRIsVALUE" because it refers unshareable objects", obj);
+ }
+ }
+ else if (rb_obj_is_proc(obj)) {
+ rb_proc_ractor_make_shareable(obj, Qundef);
+ return traverse_cont;
}
else {
- rb_raise(rb_eRactorError, "can not make shareable object for %"PRIsVALUE, obj);
+ rb_raise(rb_eRactorError, "can not make shareable object for %+"PRIsVALUE, obj);
}
}
- if (!RB_OBJ_FROZEN_RAW(obj)) {
- rb_funcall(obj, idFreeze, 0);
-
- if (UNLIKELY(!RB_OBJ_FROZEN_RAW(obj))) {
- rb_raise(rb_eRactorError, "#freeze does not freeze object correctly");
- }
-
- if (RB_OBJ_SHAREABLE_P(obj)) {
- return traverse_skip;
+ switch (TYPE(obj)) {
+ case T_IMEMO:
+ return traverse_skip;
+ case T_OBJECT:
+ {
+ // If a T_OBJECT is shared and has no free capacity, we can't safely store the object_id inline,
+ // as it would require to move the object content into an external buffer.
+ // This is only a problem for T_OBJECT, given other types have external fields and can do RCU.
+ // To avoid this issue, we proactively create the object_id.
+ shape_id_t shape_id = RBASIC_SHAPE_ID(obj);
+ attr_index_t capacity = RSHAPE_CAPACITY(shape_id);
+ attr_index_t free_capacity = capacity - RSHAPE_LEN(shape_id);
+ if (!rb_shape_has_object_id(shape_id) && capacity && !free_capacity) {
+ rb_obj_id(obj);
+ }
}
+ break;
+ default:
+ break;
}
- return traverse_cont;
+ return make_shareable_check_shareable_freeze(obj, traverse_cont);
}
static enum obj_traverse_iterator_result
mark_shareable(VALUE obj)
{
- FL_SET_RAW(obj, RUBY_FL_SHAREABLE);
+ if (RB_TYPE_P(obj, T_STRING)) {
+ rb_str_make_independent(obj);
+ }
+
+ rb_obj_set_shareable_no_assert(obj);
return traverse_cont;
}
@@ -2930,10 +1561,7 @@ VALUE
rb_ractor_make_shareable_copy(VALUE obj)
{
VALUE copy = ractor_copy(obj);
- rb_obj_traverse(copy,
- make_shareable_check_shareable,
- null_leave, mark_shareable);
- return copy;
+ return rb_ractor_make_shareable(copy);
}
VALUE
@@ -2969,7 +1597,7 @@ shareable_p_enter(VALUE obj)
return traverse_skip;
}
else if (RB_OBJ_FROZEN_RAW(obj) &&
- frozen_shareable_p(obj, NULL)) {
+ allow_frozen_shareable_p(obj)) {
return traverse_cont;
}
@@ -2990,6 +1618,12 @@ rb_ractor_shareable_p_continue(VALUE obj)
}
#if RACTOR_CHECK_MODE > 0
+void
+rb_ractor_setup_belonging(VALUE obj)
+{
+ rb_ractor_setup_belonging_to(obj, rb_ractor_current_id());
+}
+
static enum obj_traverse_iterator_result
reset_belonging_enter(VALUE obj)
{
@@ -3080,28 +1714,28 @@ obj_hash_traverse_replace_i(st_data_t *key, st_data_t *val, st_data_t ptr, int e
return ST_CONTINUE;
}
-static enum rb_id_table_iterator_result
-obj_iv_hash_traverse_replace_foreach_i(VALUE val, void *data)
+static int
+obj_iv_hash_traverse_replace_foreach_i(st_data_t _key, st_data_t _val, st_data_t _data, int _x)
{
- return ID_TABLE_REPLACE;
+ return ST_REPLACE;
}
-static enum rb_id_table_iterator_result
-obj_iv_hash_traverse_replace_i(VALUE *val, void *ptr, int exists)
+static int
+obj_iv_hash_traverse_replace_i(st_data_t * _key, st_data_t * val, st_data_t ptr, int exists)
{
struct obj_traverse_replace_callback_data *d = (struct obj_traverse_replace_callback_data *)ptr;
struct obj_traverse_replace_data *data = d->data;
- if (obj_traverse_replace_i(*val, data)) {
+ if (obj_traverse_replace_i(*(VALUE *)val, data)) {
d->stop = true;
- return ID_TABLE_STOP;
+ return ST_STOP;
}
- else if (*val != data->replacement) {
- VALUE v = *val = data->replacement;
+ else if (*(VALUE *)val != data->replacement) {
+ VALUE v = *(VALUE *)val = data->replacement;
RB_OBJ_WRITTEN(d->src, Qundef, v);
}
- return ID_TABLE_CONTINUE;
+ return ST_CONTINUE;
}
static struct st_table *
@@ -3114,13 +1748,6 @@ obj_traverse_replace_rec(struct obj_traverse_replace_data *data)
return data->rec;
}
-#if USE_TRANSIENT_HEAP
-void rb_ary_transient_heap_evacuate(VALUE ary, int promote);
-void rb_obj_transient_heap_evacuate(VALUE obj, int promote);
-void rb_hash_transient_heap_evacuate(VALUE hash, int promote);
-void rb_struct_transient_heap_evacuate(VALUE st, int promote);
-#endif
-
static void
obj_refer_only_shareables_p_i(VALUE obj, void *ptr)
{
@@ -3135,11 +1762,9 @@ static int
obj_refer_only_shareables_p(VALUE obj)
{
int cnt = 0;
- RB_VM_LOCK_ENTER_NO_BARRIER();
- {
+ RB_VM_LOCKING_NO_BARRIER() {
rb_objspace_reachable_objects_from(obj, obj_refer_only_shareables_p_i, &cnt);
}
- RB_VM_LOCK_LEAVE_NO_BARRIER();
return cnt == 0;
}
@@ -3167,24 +1792,42 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
}
else {
st_insert(obj_traverse_replace_rec(data), (st_data_t)obj, replacement);
+ RB_OBJ_WRITTEN(data->rec_hash, Qundef, obj);
+ RB_OBJ_WRITTEN(data->rec_hash, Qundef, replacement);
}
if (!data->move) {
obj = replacement;
}
-#define CHECK_AND_REPLACE(v) do { \
+#define CHECK_AND_REPLACE(parent_obj, v) do { \
VALUE _val = (v); \
if (obj_traverse_replace_i(_val, data)) { return 1; } \
- else if (data->replacement != _val) { RB_OBJ_WRITE(obj, &v, data->replacement); } \
+ else if (data->replacement != _val) { RB_OBJ_WRITE(parent_obj, &v, data->replacement); } \
} while (0)
- if (UNLIKELY(FL_TEST_RAW(obj, FL_EXIVAR))) {
- struct gen_ivtbl *ivtbl;
- rb_ivar_generic_ivtbl_lookup(obj, &ivtbl);
- for (uint32_t i = 0; i < ivtbl->numiv; i++) {
- if (!UNDEF_P(ivtbl->ivptr[i])) {
- CHECK_AND_REPLACE(ivtbl->ivptr[i]);
+ if (UNLIKELY(rb_obj_gen_fields_p(obj))) {
+ VALUE fields_obj = rb_obj_fields_no_ractor_check(obj);
+
+ if (UNLIKELY(rb_obj_shape_complex_p(obj))) {
+ struct obj_traverse_replace_callback_data d = {
+ .stop = false,
+ .data = data,
+ .src = fields_obj,
+ };
+ rb_st_foreach_with_replace(
+ rb_imemo_fields_complex_tbl(fields_obj),
+ obj_iv_hash_traverse_replace_foreach_i,
+ obj_iv_hash_traverse_replace_i,
+ (st_data_t)&d
+ );
+ if (d.stop) return 1;
+ }
+ else {
+ uint32_t fields_count = RSHAPE_LEN(RBASIC_SHAPE_ID(obj));
+ VALUE *fields = rb_imemo_fields_ptr(fields_obj);
+ for (uint32_t i = 0; i < fields_count; i++) {
+ CHECK_AND_REPLACE(fields_obj, fields[i]);
}
}
}
@@ -3196,7 +1839,6 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
case T_REGEXP:
case T_FILE:
case T_SYMBOL:
- case T_MATCH:
break;
case T_STRING:
rb_str_make_independent(obj);
@@ -3204,30 +1846,26 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
case T_OBJECT:
{
- if (rb_shape_obj_too_complex(obj)) {
- struct rb_id_table * table = ROBJECT_IV_HASH(obj);
+ if (rb_obj_shape_complex_p(obj)) {
struct obj_traverse_replace_callback_data d = {
.stop = false,
.data = data,
.src = obj,
};
- rb_id_table_foreach_values_with_replace(table,
- obj_iv_hash_traverse_replace_foreach_i,
- obj_iv_hash_traverse_replace_i,
- (void *)&d);
+ rb_st_foreach_with_replace(
+ ROBJECT_FIELDS_HASH(obj),
+ obj_iv_hash_traverse_replace_foreach_i,
+ obj_iv_hash_traverse_replace_i,
+ (st_data_t)&d
+ );
+ if (d.stop) return 1;
}
else {
-#if USE_TRANSIENT_HEAP
- if (data->move) rb_obj_transient_heap_evacuate(obj, TRUE);
-#endif
+ uint32_t len = ROBJECT_FIELDS_COUNT_NOT_COMPLEX(obj);
+ VALUE *ptr = ROBJECT_FIELDS(obj);
- uint32_t len = ROBJECT_IV_COUNT(obj);
- VALUE *ptr = ROBJECT_IVPTR(obj);
-
- for (uint32_t i=0; i<len; i++) {
- if (!UNDEF_P(ptr[i])) {
- CHECK_AND_REPLACE(ptr[i]);
- }
+ for (uint32_t i = 0; i < len; i++) {
+ CHECK_AND_REPLACE(obj, ptr[i]);
}
}
}
@@ -3236,9 +1874,6 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
case T_ARRAY:
{
rb_ary_cancel_sharing(obj);
-#if USE_TRANSIENT_HEAP
- if (data->move) rb_ary_transient_heap_evacuate(obj, TRUE);
-#endif
for (int i = 0; i < RARRAY_LENINT(obj); i++) {
VALUE e = rb_ary_entry(obj, i);
@@ -3253,12 +1888,8 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
RB_GC_GUARD(obj);
}
break;
-
case T_HASH:
{
-#if USE_TRANSIENT_HEAP
- if (data->move) rb_hash_transient_heap_evacuate(obj, TRUE);
-#endif
struct obj_traverse_replace_callback_data d = {
.stop = false,
.data = data,
@@ -3283,25 +1914,26 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
case T_STRUCT:
{
-#if USE_TRANSIENT_HEAP
- if (data->move) rb_struct_transient_heap_evacuate(obj, TRUE);
-#endif
- long len = RSTRUCT_LEN(obj);
+ long len = RSTRUCT_LEN_RAW(obj);
const VALUE *ptr = RSTRUCT_CONST_PTR(obj);
for (long i=0; i<len; i++) {
- CHECK_AND_REPLACE(ptr[i]);
+ CHECK_AND_REPLACE(obj, ptr[i]);
}
}
break;
+ case T_MATCH:
+ CHECK_AND_REPLACE(obj, RMATCH(obj)->str);
+ break;
+
case T_RATIONAL:
- CHECK_AND_REPLACE(RRATIONAL(obj)->num);
- CHECK_AND_REPLACE(RRATIONAL(obj)->den);
+ CHECK_AND_REPLACE(obj, RRATIONAL(obj)->num);
+ CHECK_AND_REPLACE(obj, RRATIONAL(obj)->den);
break;
case T_COMPLEX:
- CHECK_AND_REPLACE(RCOMPLEX(obj)->real);
- CHECK_AND_REPLACE(RCOMPLEX(obj)->imag);
+ CHECK_AND_REPLACE(obj, RCOMPLEX(obj)->real);
+ CHECK_AND_REPLACE(obj, RCOMPLEX(obj)->imag);
break;
case T_DATA:
@@ -3360,35 +1992,19 @@ rb_obj_traverse_replace(VALUE obj,
}
}
-struct RVALUE {
- VALUE flags;
- VALUE klass;
- VALUE v1;
- VALUE v2;
- VALUE v3;
+static const bool wb_protected_types[RUBY_T_MASK] = {
+ [T_OBJECT] = true,
+ [T_HASH] = true,
+ [T_ARRAY] = true,
+ [T_STRING] = true,
+ [T_STRUCT] = true,
+ [T_COMPLEX] = true,
+ [T_REGEXP] = true,
+ [T_MATCH] = true,
+ [T_FLOAT] = true,
+ [T_RATIONAL] = true,
};
-static const VALUE fl_users = FL_USER1 | FL_USER2 | FL_USER3 |
- FL_USER4 | FL_USER5 | FL_USER6 | FL_USER7 |
- FL_USER8 | FL_USER9 | FL_USER10 | FL_USER11 |
- FL_USER12 | FL_USER13 | FL_USER14 | FL_USER15 |
- FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19;
-
-static void
-ractor_moved_bang(VALUE obj)
-{
- // invalidate src object
- struct RVALUE *rv = (void *)obj;
-
- rv->klass = rb_cRactorMovedObject;
- rv->v1 = 0;
- rv->v2 = 0;
- rv->v3 = 0;
- rv->flags = rv->flags & ~fl_users;
-
- // TODO: record moved location
-}
-
static enum obj_traverse_iterator_result
move_enter(VALUE obj, struct obj_traverse_replace_data *data)
{
@@ -3397,33 +2013,44 @@ move_enter(VALUE obj, struct obj_traverse_replace_data *data)
return traverse_skip;
}
else {
- data->replacement = rb_obj_alloc(RBASIC_CLASS(obj));
+ VALUE type = RB_BUILTIN_TYPE(obj);
+ size_t slot_size = rb_gc_obj_slot_size(obj);
+ VALUE moved = rb_newobj(GET_EC(), 0, type, RBASIC_SHAPE_ID(obj), wb_protected_types[type], slot_size);
+ MEMZERO(((struct RBasic *)moved) + 1, char, slot_size - sizeof(struct RBasic));
+ data->replacement = (VALUE)moved;
return traverse_cont;
}
}
-void rb_replace_generic_ivar(VALUE clone, VALUE obj); // variable.c
-
static enum obj_traverse_iterator_result
move_leave(VALUE obj, struct obj_traverse_replace_data *data)
{
- VALUE v = data->replacement;
- struct RVALUE *dst = (struct RVALUE *)v;
- struct RVALUE *src = (struct RVALUE *)obj;
+ // Copy flags
+ VALUE ignored_flags = RUBY_FL_PROMOTED;
+ RBASIC(data->replacement)->flags = (RBASIC(obj)->flags & ~ignored_flags) | (RBASIC(data->replacement)->flags & ignored_flags);
+ // Copy contents without the flags
+ memcpy(
+ (char *)data->replacement + sizeof(VALUE),
+ (char *)obj + sizeof(VALUE),
+ rb_gc_obj_slot_size(obj) - sizeof(VALUE)
+ );
- dst->flags = (dst->flags & ~fl_users) | (src->flags & fl_users);
+ // We've copied obj's references to the replacement
+ rb_gc_writebarrier_remember(data->replacement);
- dst->v1 = src->v1;
- dst->v2 = src->v2;
- dst->v3 = src->v3;
-
- if (UNLIKELY(FL_TEST_RAW(obj, FL_EXIVAR))) {
- rb_replace_generic_ivar(v, obj);
+ void rb_replace_generic_ivar(VALUE clone, VALUE obj); // variable.c
+ if (UNLIKELY(rb_obj_gen_fields_p(obj))) {
+ rb_replace_generic_ivar(data->replacement, obj);
}
- // TODO: generic_ivar
+ rb_gc_obj_id_moved(data->replacement);
+
+ VALUE flags = T_OBJECT | FL_FREEZE | (RBASIC(obj)->flags & FL_PROMOTED);
- ractor_moved_bang(obj);
+ // Avoid mutations using bind_call, etc.
+ MEMZERO((char *)obj, char, sizeof(struct RBasic));
+ RBASIC(obj)->flags = flags;
+ RBASIC_SET_CLASS_RAW(obj, rb_cRactorMovedObject);
return traverse_cont;
}
@@ -3439,6 +2066,31 @@ ractor_move(VALUE obj)
}
}
+static VALUE
+ractor_call_clone_try(VALUE obj)
+{
+ return rb_funcall(obj, idClone, 0);
+}
+
+static VALUE
+ractor_call_clone_rescue(VALUE obj, VALUE exc)
+{
+ rb_raise(rb_eRactorError, "can't clone unshareable instance of %"PRIsVALUE, rb_class_of(obj));
+ UNREACHABLE_RETURN(Qnil);
+}
+
+static VALUE
+ractor_obj_clone(VALUE obj)
+{
+ VALUE clone = rb_rescue(ractor_call_clone_try, obj, ractor_call_clone_rescue, obj);
+
+ if (obj == clone) {
+ rb_raise(rb_eRactorError, "#clone returned self");
+ }
+
+ return clone;
+}
+
static enum obj_traverse_iterator_result
copy_enter(VALUE obj, struct obj_traverse_replace_data *data)
{
@@ -3447,7 +2099,7 @@ copy_enter(VALUE obj, struct obj_traverse_replace_data *data)
return traverse_skip;
}
else {
- data->replacement = rb_obj_clone(obj);
+ data->replacement = ractor_obj_clone(obj);
return traverse_cont;
}
}
@@ -3492,7 +2144,7 @@ ractor_local_storage_mark_i(st_data_t key, st_data_t val, st_data_t dmy)
}
static enum rb_id_table_iterator_result
-idkey_local_storage_mark_i(ID id, VALUE val, void *dmy)
+idkey_local_storage_mark_i(VALUE val, void *dmy)
{
rb_gc_mark(val);
return ID_TABLE_CONTINUE;
@@ -3515,8 +2167,10 @@ ractor_local_storage_mark(rb_ractor_t *r)
}
if (r->idkey_local_storage) {
- rb_id_table_foreach(r->idkey_local_storage, idkey_local_storage_mark_i, NULL);
+ rb_id_table_foreach_values(r->idkey_local_storage, idkey_local_storage_mark_i, NULL);
}
+
+ rb_gc_mark(r->local_storage_store_lock);
}
static int
@@ -3579,15 +2233,13 @@ rb_ractor_local_storage_value_newkey(void)
void
rb_ractor_local_storage_delkey(rb_ractor_local_key_t key)
{
- RB_VM_LOCK_ENTER();
- {
+ RB_VM_LOCKING() {
if (freed_ractor_local_keys.cnt == freed_ractor_local_keys.capa) {
freed_ractor_local_keys.capa = freed_ractor_local_keys.capa ? freed_ractor_local_keys.capa * 2 : 4;
- REALLOC_N(freed_ractor_local_keys.keys, rb_ractor_local_key_t, freed_ractor_local_keys.capa);
+ SIZED_REALLOC_N(freed_ractor_local_keys.keys, rb_ractor_local_key_t, freed_ractor_local_keys.capa, freed_ractor_local_keys.cnt);
}
freed_ractor_local_keys.keys[freed_ractor_local_keys.cnt++] = key;
}
- RB_VM_LOCK_LEAVE();
}
static bool
@@ -3683,12 +2335,12 @@ void
rb_ractor_finish_marking(void)
{
for (int i=0; i<freed_ractor_local_keys.cnt; i++) {
- ruby_xfree(freed_ractor_local_keys.keys[i]);
+ SIZED_FREE(freed_ractor_local_keys.keys[i]);
}
freed_ractor_local_keys.cnt = 0;
if (freed_ractor_local_keys.capa > DEFAULT_KEYS_CAPA) {
freed_ractor_local_keys.capa = DEFAULT_KEYS_CAPA;
- REALLOC_N(freed_ractor_local_keys.keys, rb_ractor_local_key_t, DEFAULT_KEYS_CAPA);
+ SIZED_REALLOC_N(freed_ractor_local_keys.keys, rb_ractor_local_key_t, DEFAULT_KEYS_CAPA, freed_ractor_local_keys.capa);
}
}
@@ -3722,4 +2374,277 @@ ractor_local_value_set(rb_execution_context_t *ec, VALUE self, VALUE sym, VALUE
return val;
}
+struct ractor_local_storage_store_data {
+ rb_execution_context_t *ec;
+ struct rb_id_table *tbl;
+ ID id;
+ VALUE sym;
+};
+
+static VALUE
+ractor_local_value_store_i(VALUE ptr)
+{
+ VALUE val;
+ struct ractor_local_storage_store_data *data = (struct ractor_local_storage_store_data *)ptr;
+
+ if (rb_id_table_lookup(data->tbl, data->id, &val)) {
+ // after synchronization, we found already registered entry
+ }
+ else {
+ val = rb_yield(Qnil);
+ ractor_local_value_set(data->ec, Qnil, data->sym, val);
+ }
+ return val;
+}
+
+static VALUE
+ractor_local_value_store_if_absent(rb_execution_context_t *ec, VALUE self, VALUE sym)
+{
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ struct ractor_local_storage_store_data data = {
+ .ec = ec,
+ .sym = sym,
+ .id = SYM2ID(rb_to_symbol(sym)),
+ .tbl = cr->idkey_local_storage,
+ };
+ VALUE val;
+
+ if (data.tbl == NULL) {
+ data.tbl = cr->idkey_local_storage = rb_id_table_create(2);
+ }
+ else if (rb_id_table_lookup(data.tbl, data.id, &val)) {
+ // already set
+ return val;
+ }
+
+ if (!cr->local_storage_store_lock) {
+ cr->local_storage_store_lock = rb_mutex_new();
+ }
+
+ return rb_mutex_synchronize(cr->local_storage_store_lock, ractor_local_value_store_i, (VALUE)&data);
+}
+
+// shareable_proc
+
+static VALUE
+ractor_shareable_proc(rb_execution_context_t *ec, VALUE replace_self, bool is_lambda)
+{
+ if (!rb_ractor_shareable_p(replace_self)) {
+ rb_raise(rb_eRactorIsolationError, "self should be shareable: %" PRIsVALUE, replace_self);
+ }
+ else {
+ VALUE proc = is_lambda ? rb_block_lambda() : rb_block_proc();
+ return rb_proc_ractor_make_shareable(rb_proc_dup(proc), replace_self);
+ }
+}
+
+// Ractor#require
+
+struct cross_ractor_require {
+ VALUE port;
+ bool raised;
+
+ union {
+ struct {
+ VALUE feature;
+ } require;
+
+ struct {
+ VALUE module;
+ ID name;
+ } autoload;
+ } as;
+
+ bool silent;
+};
+
+RUBY_REFERENCES(cross_ractor_require_refs) = {
+ RUBY_REF_EDGE(struct cross_ractor_require, port),
+ RUBY_REF_EDGE(struct cross_ractor_require, as.require.feature),
+ RUBY_REF_END
+};
+
+static const rb_data_type_t cross_ractor_require_data_type = {
+ "ractor/cross_ractor_require",
+ {
+ RUBY_REFS_LIST_PTR(cross_ractor_require_refs),
+ RUBY_DEFAULT_FREE,
+ NULL, // memsize
+ NULL, // compact
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
+};
+
+static VALUE
+require_body(VALUE crr_obj)
+{
+ struct cross_ractor_require *crr;
+ TypedData_Get_Struct(crr_obj, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+ VALUE feature = crr->as.require.feature;
+
+ ID require;
+ CONST_ID(require, "require");
+
+ if (crr->silent) {
+ int rb_require_internal_silent(VALUE fname);
+ return INT2NUM(rb_require_internal_silent(feature));
+ }
+ else {
+ return rb_funcallv(Qnil, require, 1, &feature);
+ }
+}
+
+static VALUE
+require_rescue(VALUE crr_obj, VALUE errinfo)
+{
+ struct cross_ractor_require *crr;
+ TypedData_Get_Struct(crr_obj, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+ crr->raised = true;
+ return errinfo;
+}
+
+static VALUE
+require_result_send_body(VALUE ary)
+{
+ VALUE port = RARRAY_AREF(ary, 0);
+ VALUE results = RARRAY_AREF(ary, 1);
+
+ rb_execution_context_t *ec = GET_EC();
+
+ ractor_port_send(ec, port, results, Qfalse);
+ return Qnil;
+}
+
+static VALUE
+require_result_send_resuce(VALUE port, VALUE errinfo)
+{
+ // TODO: need rescue?
+ ractor_port_send(GET_EC(), port, errinfo, Qfalse);
+ return Qnil;
+}
+
+static VALUE
+ractor_require_protect(VALUE crr_obj, VALUE (*func)(VALUE))
+{
+ struct cross_ractor_require *crr;
+ TypedData_Get_Struct(crr_obj, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+
+ const bool silent = crr->silent;
+
+ VALUE debug, errinfo;
+ if (silent) {
+ debug = ruby_debug;
+ errinfo = rb_errinfo();
+ }
+
+ // get normal result or raised exception (with crr->raised == true)
+ VALUE result = rb_rescue2(func, crr_obj, require_rescue, crr_obj, rb_eException, 0);
+
+ if (silent) {
+ ruby_debug = debug;
+ rb_set_errinfo(errinfo);
+ }
+
+ rb_rescue2(require_result_send_body,
+ // [port, [result, raised]]
+ rb_ary_new_from_args(2, crr->port, rb_ary_new_from_args(2, result, crr->raised ? Qtrue : Qfalse)),
+ require_result_send_resuce, rb_eException, crr->port);
+
+ RB_GC_GUARD(crr_obj);
+ return Qnil;
+}
+
+static VALUE
+ractor_require_func(void *crr_obj)
+{
+ return ractor_require_protect((VALUE)crr_obj, require_body);
+}
+
+VALUE
+rb_ractor_require(VALUE feature, bool silent)
+{
+ // We're about to block on the main ractor, so if we're holding the global lock we'll deadlock.
+ ASSERT_vm_unlocking();
+
+ struct cross_ractor_require *crr;
+ VALUE crr_obj = TypedData_Make_Struct(0, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+ RB_OBJ_SET_SHAREABLE(crr_obj); // TODO: internal data?
+
+ // Convert feature to proper file path and make it shareable as fstring
+ RB_OBJ_WRITE(crr_obj, &crr->as.require.feature, rb_fstring(FilePathValue(feature)));
+ RB_OBJ_WRITE(crr_obj, &crr->port, rb_ractor_make_shareable(ractor_port_new(GET_RACTOR())));
+ crr->raised = false;
+ crr->silent = silent;
+
+ rb_execution_context_t *ec = GET_EC();
+ rb_ractor_t *main_r = GET_VM()->ractor.main_ractor;
+ rb_ractor_interrupt_exec(main_r, ractor_require_func, (void *)crr_obj, rb_interrupt_exec_flag_value_data);
+
+ // wait for require done
+ VALUE results = ractor_port_receive(ec, crr->port);
+ ractor_port_close(ec, crr->port);
+
+ VALUE exc = rb_ary_pop(results);
+ VALUE result = rb_ary_pop(results);
+ RB_GC_GUARD(crr_obj);
+
+ if (RTEST(exc)) {
+ rb_exc_raise(result);
+ }
+ else {
+ return result;
+ }
+}
+
+static VALUE
+ractor_require(rb_execution_context_t *ec, VALUE self, VALUE feature)
+{
+ return rb_ractor_require(feature, false);
+}
+
+static VALUE
+autoload_load_body(VALUE crr_obj)
+{
+ struct cross_ractor_require *crr;
+ TypedData_Get_Struct(crr_obj, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+ return rb_autoload_load(crr->as.autoload.module, crr->as.autoload.name);
+}
+
+static VALUE
+ractor_autoload_load_func(void *crr_obj)
+{
+ return ractor_require_protect((VALUE)crr_obj, autoload_load_body);
+}
+
+VALUE
+rb_ractor_autoload_load(VALUE module, ID name)
+{
+ struct cross_ractor_require *crr;
+ VALUE crr_obj = TypedData_Make_Struct(0, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
+ RB_OBJ_SET_SHAREABLE(crr_obj); // TODO: internal data?
+
+ RB_OBJ_WRITE(crr_obj, &crr->as.autoload.module, module);
+ RB_OBJ_WRITE(crr_obj, &crr->as.autoload.name, name);
+ RB_OBJ_WRITE(crr_obj, &crr->port, rb_ractor_make_shareable(ractor_port_new(GET_RACTOR())));
+
+ rb_execution_context_t *ec = GET_EC();
+ rb_ractor_t *main_r = GET_VM()->ractor.main_ractor;
+ rb_ractor_interrupt_exec(main_r, ractor_autoload_load_func, (void *)crr_obj, rb_interrupt_exec_flag_value_data);
+
+ // wait for require done
+ VALUE results = ractor_port_receive(ec, crr->port);
+ ractor_port_close(ec, crr->port);
+
+ VALUE exc = rb_ary_pop(results);
+ VALUE result = rb_ary_pop(results);
+ RB_GC_GUARD(crr_obj);
+
+ if (RTEST(exc)) {
+ rb_exc_raise(result);
+ }
+ else {
+ return result;
+ }
+}
+
#include "ractor.rbinc"
diff --git a/ractor.rb b/ractor.rb
index 5620eeec38..2dc60f5ff6 100644
--- a/ractor.rb
+++ b/ractor.rb
@@ -1,99 +1,54 @@
-# \Ractor is an Actor-model abstraction for Ruby that provides thread-safe parallel execution.
-#
-# Ractor.new makes a new \Ractor, which can run in parallel.
+# Ractor.new creates a new \Ractor, which can run in parallel with other ractors.
#
# # The simplest ractor
# r = Ractor.new {puts "I am in Ractor!"}
-# r.take # wait for it to finish
+# r.join # wait for it to finish
# # Here, "I am in Ractor!" is printed
#
# Ractors do not share all objects with each other. There are two main benefits to this: across ractors, thread-safety
# concerns such as data-races and race-conditions are not possible. The other benefit is parallelism.
#
# To achieve this, object sharing is limited across ractors.
-# For example, unlike in threads, ractors can't access all the objects available in other ractors. Even objects normally
+# Unlike in threads, ractors can't access all the objects available in other ractors. For example, objects normally
# available through variables in the outer scope are prohibited from being used across ractors.
#
# a = 1
# r = Ractor.new {puts "I am in Ractor! a=#{a}"}
# # fails immediately with
-# # ArgumentError (can not isolate a Proc because it accesses outer variables (a).)
+# # Ractor::IsolationError (can not isolate a Proc because it accesses outer variables (a).)
#
# The object must be explicitly shared:
# a = 1
# r = Ractor.new(a) { |a1| puts "I am in Ractor! a=#{a1}"}
#
-# On CRuby (the default implementation), Global Virtual Machine Lock (GVL) is held per ractor, so
-# ractors can perform in parallel without locking each other. This is unlike the situation with threads
-# on CRuby.
+# On CRuby (the default implementation), the Global Virtual Machine Lock (GVL) is held per ractor, so
+# ractors can run in parallel. This is unlike the situation with threads on CRuby.
#
# Instead of accessing shared state, objects should be passed to and from ractors by
# sending and receiving them as messages.
#
# a = 1
# r = Ractor.new do
-# a_in_ractor = receive # receive blocks until somebody passes a message
+# a_in_ractor = receive # receive blocks the Thread until our default port gets sent a message
# puts "I am in Ractor! a=#{a_in_ractor}"
# end
# r.send(a) # pass it
-# r.take
+# r.join
# # Here, "I am in Ractor! a=1" is printed
#
-# There are two pairs of methods for sending/receiving messages:
-#
-# * Ractor#send and Ractor.receive for when the _sender_ knows the receiver (push);
-# * Ractor.yield and Ractor#take for when the _receiver_ knows the sender (pull);
-#
# In addition to that, any arguments passed to Ractor.new are passed to the block and available there
-# as if received by Ractor.receive, and the last block value is sent outside of the
-# ractor as if sent by Ractor.yield.
-#
-# A little demonstration of a classic ping-pong:
-#
-# server = Ractor.new(name: "server") do
-# puts "Server starts: #{self.inspect}"
-# puts "Server sends: ping"
-# Ractor.yield 'ping' # The server doesn't know the receiver and sends to whoever interested
-# received = Ractor.receive # The server doesn't know the sender and receives from whoever sent
-# puts "Server received: #{received}"
-# end
-#
-# client = Ractor.new(server) do |srv| # The server is sent to the client, and available as srv
-# puts "Client starts: #{self.inspect}"
-# received = srv.take # The client takes a message from the server
-# puts "Client received from " \
-# "#{srv.inspect}: #{received}"
-# puts "Client sends to " \
-# "#{srv.inspect}: pong"
-# srv.send 'pong' # The client sends a message to the server
-# end
-#
-# [client, server].each(&:take) # Wait until they both finish
-#
-# This will output something like:
-#
-# Server starts: #<Ractor:#2 server test.rb:1 running>
-# Server sends: ping
-# Client starts: #<Ractor:#3 test.rb:8 running>
-# Client received from #<Ractor:#2 server test.rb:1 blocking>: ping
-# Client sends to #<Ractor:#2 server test.rb:1 blocking>: pong
-# Server received: pong
-#
-# Ractors receive their messages via the <em>incoming port</em>, and send them
-# to the <em>outgoing port</em>. Either one can be disabled with Ractor#close_incoming and
-# Ractor#close_outgoing, respectively. When a ractor terminates, its ports are closed
-# automatically.
+# as if received by Ractor.receive, and the last block value can be received with Ractor#value.
#
# == Shareable and unshareable objects
#
-# When an object is sent to and from a ractor, it's important to understand whether the
+# When an object is sent to a ractor, it's important to understand whether the
# object is shareable or unshareable. Most Ruby objects are unshareable objects. Even
# frozen objects can be unshareable if they contain (through their instance variables) unfrozen
# objects.
#
-# Shareable objects are those which can be used by several threads without compromising
+# Shareable objects are those which can be used by several ractors at once without compromising
# thread-safety, for example numbers, +true+ and +false+. Ractor.shareable? allows you to check this,
-# and Ractor.make_shareable tries to make the object shareable if it's not already, and gives an error
+# and Ractor.make_shareable tries to make the object shareable if it's not already and gives an error
# if it can't do it.
#
# Ractor.shareable?(1) #=> true -- numbers and other immutable basic values are shareable
@@ -109,24 +64,24 @@
# ary[0].frozen? #=> true
# ary[1].frozen? #=> true
#
-# When a shareable object is sent (via #send or Ractor.yield), no additional processing occurs
-# on it. It just becomes usable by both ractors. When an unshareable object is sent, it can be
-# either _copied_ or _moved_. The first is the default, and it copies the object fully by
+# When a shareable object is sent via #send, no additional processing occurs
+# on it and it becomes usable by both ractors. When an unshareable object is sent, it can be
+# either _copied_ or _moved_. Copying is the default, and it copies the object fully by
# deep cloning (Object#clone) the non-shareable parts of its structure.
#
-# data = ['foo', 'bar'.freeze]
+# data = ['foo'.dup, 'bar'.freeze]
# r = Ractor.new do
# data2 = Ractor.receive
# puts "In ractor: #{data2.object_id}, #{data2[0].object_id}, #{data2[1].object_id}"
# end
# r.send(data)
-# r.take
+# r.join
# puts "Outside : #{data.object_id}, #{data[0].object_id}, #{data[1].object_id}"
#
# This will output something like:
#
-# In ractor: 340, 360, 320
-# Outside : 380, 400, 320
+# In ractor: 8, 16, 24
+# Outside : 32, 40, 24
#
# Note that the object ids of the array and the non-frozen string inside the array have changed in
# the ractor because they are different objects. The second array's element, which is a
@@ -142,7 +97,7 @@
# puts "In ractor: #{data_in_ractor.object_id}, #{data_in_ractor[0].object_id}"
# end
# r.send(data, move: true)
-# r.take
+# r.join
# puts "Outside: moved? #{Ractor::MovedObject === data}"
# puts "Outside: #{data.inspect}"
#
@@ -152,12 +107,12 @@
# Outside: moved? true
# test.rb:9:in `method_missing': can not send any methods to a moved object (Ractor::MovedError)
#
-# Notice that even +inspect+ (and more basic methods like <tt>__id__</tt>) is inaccessible
+# Notice that even +inspect+ and more basic methods like <tt>__id__</tt> are inaccessible
# on a moved object.
#
-# Class and Module objects are shareable so the class/module definitions are shared between ractors.
-# \Ractor objects are also shareable. All operations on shareable objects are thread-safe, so the thread-safety property
-# will be kept. We can not define mutable shareable objects in Ruby, but C extensions can introduce them.
+# +Class+ and +Module+ objects are shareable and their class/module definitions are shared between ractors.
+# \Ractor objects are also shareable. All operations on shareable objects are thread-safe across ractors.
+# Defining mutable, shareable objects in Ruby is not possible, but C extensions can introduce them.
#
# It is prohibited to access (get) instance variables of shareable objects in other ractors if the values of the
# variables aren't shareable. This can occur because modules/classes are shareable, but they can have
@@ -177,7 +132,7 @@
# puts "I can't see #{cls.tricky}"
# cls.tricky = true # doesn't get here, but this would also raise an error
# end
-# r.take
+# r.join
# # I see C
# # can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
#
@@ -191,7 +146,7 @@
# puts "GOOD=#{GOOD}"
# puts "BAD=#{BAD}"
# end
-# r.take
+# r.join
# # GOOD=good
# # can not access non-shareable objects in constant Object::BAD by non-main Ractor. (NameError)
#
@@ -201,7 +156,7 @@
# puts "I see #{C}"
# puts "I can't see #{C.tricky}"
# end
-# r.take
+# r.join
# # I see C
# # can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
#
@@ -217,20 +172,21 @@
# a = 1
# Thread.new {puts "Thread in ractor: a=#{a}"}.join
# end
-# r.take
+# r.join
# # Here "Thread in ractor: a=1" will be printed
#
# == Note on code examples
#
-# In the examples below, sometimes we use the following method to wait for ractors that
-# are not currently blocked to finish (or to make progress).
+# In the examples below, sometimes we use the following method to wait for ractors
+# to make progress or finish.
#
# def wait
# sleep(0.1)
# end
#
-# It is **only for demonstration purposes** and shouldn't be used in a real code.
-# Most of the time, #take is used to wait for ractors to finish.
+# This is **only for demonstration purposes** and shouldn't be used in a real code.
+# Most of the time, #join is used to wait for ractors to finish and Ractor.receive is used
+# to wait for messages.
#
# == Reference
#
@@ -241,13 +197,13 @@ class Ractor
# call-seq:
# Ractor.new(*args, name: nil) {|*args| block } -> ractor
#
- # Create a new \Ractor with args and a block.
+ # Creates a new \Ractor with args and a block.
#
- # The given block (Proc) will be isolated (can't access any outer variables). +self+
+ # The given block (Proc) is isolated (can't access any outer variables). +self+
# inside the block will refer to the current \Ractor.
#
# r = Ractor.new { puts "Hi, I am #{self.inspect}" }
- # r.take
+ # r.join
# # Prints "Hi, I am #<Ractor:#2 test.rb:1 running>"
#
# Any +args+ passed are propagated to the block arguments by the same rules as
@@ -259,14 +215,14 @@ class Ractor
# r = Ractor.new(arg) {|received_arg|
# puts "Received: #{received_arg} (##{received_arg.object_id})"
# }
- # r.take
+ # r.join
# # Prints:
# # Passing: [1, 2, 3] (#280)
# # Received: [1, 2, 3] (#300)
#
# Ractor's +name+ can be set for debugging purposes:
#
- # r = Ractor.new(name: 'my ractor') {}; r.take
+ # r = Ractor.new(name: 'my ractor') {}; r.join
# p r
# #=> #<Ractor:#3 my ractor test.rb:1 terminated>
#
@@ -274,8 +230,8 @@ class Ractor
b = block # TODO: builtin bug
raise ArgumentError, "must be called with a block" unless block
if __builtin_cexpr!("RBOOL(ruby_single_main_ractor)")
- warn("Ractor is experimental, and the behavior may change in future versions of Ruby! " \
- "Also there are many implementation issues.", uplevel: 0, category: :experimental)
+ Kernel.warn("Ractor API is experimental and may change in future versions of Ruby.",
+ uplevel: 0, category: :experimental)
end
loc = caller_locations(1, 1).first
loc = "#{loc.path}:#{loc.lineno}"
@@ -291,13 +247,13 @@ class Ractor
}
end
- # Returns the number of Ractors currently running or blocking (waiting).
+ # Returns the number of ractors currently running or blocking (waiting).
#
# Ractor.count #=> 1
- # r = Ractor.new(name: 'example') { Ractor.yield(1) }
+ # r = Ractor.new(name: 'example') { Ractor.receive }
# Ractor.count #=> 2 (main + example ractor)
- # r.take # wait for Ractor.yield(1)
- # r.take # wait until r will finish
+ # r << 42 # r's Ractor.receive will resume
+ # r.join # wait for r's termination
# Ractor.count #=> 1
def self.count
__builtin_cexpr! %q{
@@ -307,246 +263,91 @@ class Ractor
#
# call-seq:
- # Ractor.select(*ractors, [yield_value:, move: false]) -> [ractor or symbol, obj]
- #
- # Wait for any ractor to have something in its outgoing port, read from this ractor, and
- # then return that ractor and the object received.
- #
- # r1 = Ractor.new {Ractor.yield 'from 1'}
- # r2 = Ractor.new {Ractor.yield 'from 2'}
- #
- # r, obj = Ractor.select(r1, r2)
- #
- # puts "received #{obj.inspect} from #{r.inspect}"
- # # Prints: received "from 1" from #<Ractor:#2 test.rb:1 running>
- # # But could just as well print "from r2" here, either prints could be first.
- #
- # If one of the given ractors is the current ractor, and it is selected, +r+ will contain
- # the +:receive+ symbol instead of the ractor object.
- #
- # r1 = Ractor.new(Ractor.current) do |main|
- # main.send 'to main'
- # Ractor.yield 'from 1'
+ # Ractor.select(*ractors_or_ports) -> [ractor or port, obj]
+ #
+ # Blocks the current Thread until one of the given ports has received a message. Returns an
+ # array of two elements where the first element is the Port and the second is the received object.
+ # This method can also accept Ractor objects themselves, and in that case will wait until one
+ # has terminated and return a two-element array where the first element is the ractor and the
+ # second is its termination value.
+ #
+ # p1, p2 = Ractor::Port.new, Ractor::Port.new
+ # ps = [p1, p2]
+ # rs = 2.times.map do |i|
+ # Ractor.new(ps.shift, i) do |p, i|
+ # sleep rand(0.99)
+ # p.send("r#{i}")
+ # sleep rand(0.99)
+ # "r#{i} done"
+ # end
# end
- # r2 = Ractor.new do
- # Ractor.yield 'from 2'
- # end
- #
- # r, obj = Ractor.select(r1, r2, Ractor.current)
- # puts "received #{obj.inspect} from #{r.inspect}"
- # # Could print: received "to main" from :receive
- #
- # If +yield_value+ is provided, that value may be yielded if another ractor is calling #take.
- # In this case, the pair <tt>[:yield, nil]</tt> is returned:
#
- # r1 = Ractor.new(Ractor.current) do |main|
- # puts "Received from main: #{main.take}"
+ # waiting_on = [p1, p2, *rs]
+ # until waiting_on.empty?
+ # received_on, obj = Ractor.select(*waiting_on)
+ # waiting_on.delete(received_on)
+ # puts obj
# end
#
- # puts "Trying to select"
- # r, obj = Ractor.select(r1, Ractor.current, yield_value: 123)
- # wait
- # puts "Received #{obj.inspect} from #{r.inspect}"
+ # # r0
+ # # r1
+ # # r1 done
+ # # r0 done
#
- # This will print:
+ # The following example is almost equivalent to <code>ractors.map(&:value)</code> except the thread
+ # is unblocked when any of the ractors has terminated as opposed to waiting for their termination in
+ # the array element order.
#
- # Trying to select
- # Received from main: 123
- # Received nil from :yield
+ # values = []
+ # until ractors.empty?
+ # r, val = Ractor.select(*ractors)
+ # ractors.delete(r)
+ # values << val
+ # end
#
- # +move+ boolean flag defines whether yielded value will be copied (default) or moved.
- def self.select(*ractors, yield_value: yield_unspecified = true, move: false)
- raise ArgumentError, 'specify at least one ractor or `yield_value`' if yield_unspecified && ractors.empty?
+ def self.select(*ports)
+ raise ArgumentError, 'specify at least one Ractor::Port or Ractor' if ports.empty?
- begin
- if ractors.delete Ractor.current
- do_receive = true
- else
- do_receive = false
- end
- selector = Ractor::Selector.new(*ractors)
+ monitors = {} # Ractor::Port => Ractor
- if yield_unspecified
- selector.wait receive: do_receive
+ ports = ports.map do |arg|
+ case arg
+ when Ractor
+ port = Ractor::Port.new
+ monitors[port] = arg
+ arg.monitor port
+ port
+ when Ractor::Port
+ arg
else
- selector.wait receive: do_receive, yield_value: yield_value, move: move
+ raise ArgumentError, "should be Ractor::Port or Ractor"
end
- ensure
- selector.clear
end
- end
- #
- # Ractor::Selector provides a functionality to wait multiple Ractor events.
- # Ractor::Selector#wait is more lightweight than Ractor.select()
- # because we don't have to specify all target ractors for each wait time.
- #
- # Ractor.select() uses Ractor::Selector internally to implement it.
- #
- class Selector
- # call-seq:
- # Ractor::Selector.new(*ractors)
- #
- # Creates a selector object.
- #
- # If a ractors parameter is given, it is same as the following code.
- #
- # selector = Ractor::Selector.new
- # ractors.each{|r| selector.add r}
- #
- def self.new(*rs)
- selector = __builtin_cexpr! %q{
- ractor_selector_create(self);
- }
- rs.each{|r| selector.add(r) }
- selector
- end
-
- # call-seq:
- # selector.add(ractor)
- #
- # Registers a ractor as a taking target by the selector.
- #
- def add r
- __builtin_ractor_selector_add r
- end
-
- # call-seq:
- # selector.remove(ractor)
- #
- # Deregisters a ractor as a taking target by the selector.
- #
- def remove r
- __builtin_ractor_selector_remove r
- end
-
- # call-seq:
- # selector.clear
- #
- # Deregisters all ractors.
- def clear
- __builtin_ractor_selector_clear
- end
-
- # call-seq:
- # selector.empty?
- #
- # Returns true if the number of ractors in the waiting set at the current time is zero.
- #
- # Note that even if <tt>#empty?</tt> returns false, the subsequent <tt>#wait</tt>
- # may raise an exception because other ractors may close the target ractors.
- #
- def empty?
- __builtin_ractor_selector_empty_p
- end
+ begin
+ result_port, obj = __builtin_ractor_select_internal(ports)
- # call-seq:
- # selector.wait(receive: false, yield_value: yield_value, move: false) -> [ractor or symbol, value]
- #
- # Waits Ractor events. It is lighter than Ractor.select() for many ractors.
- #
- # The simplest form is waiting for taking a value from one of
- # registerred ractors like that.
- #
- # selector = Ractor::Selector.new(r1, r2, r3)
- # r, v = selector.wait
- #
- # On this case, when r1, r2 or r3 is ready to take (yielding a value),
- # this method takes the value from the ready (yielded) ractor
- # and returns [the yielded ractor, the taking value].
- #
- # Note that if a take target ractor is closed, the ractor will be removed
- # automatically.
- #
- # If you also want to wait with receiving an object from other ractors,
- # you can specify receive: true keyword like:
- #
- # r, v = selector.wait receive: true
- #
- # On this case, wait for taking from r1, r2 or r3 and waiting for receving
- # a value from other ractors.
- # If it successes the receiving, it returns an array object [:receive, the received value].
- #
- # If you also want to wait with yielding a value, you can specify
- # :yield_value like:
- #
- # r, v = selector.wait yield_value: obj
- #
- # On this case wait for taking from r1, r2, or r3 and waiting for taking
- # yielding value (obj) by another ractor.
- # If antoher ractor takes the value (obj), it returns an array object [:yield, nil].
- #
- # You can specify a keyword parameter <tt>move: true</tt> like Ractor.yield(obj, move: true)
- #
- def wait receive: false, yield_value: yield_unspecified = true, move: false
- __builtin_ractor_selector_wait receive, !yield_unspecified, yield_value, move
+ if r = monitors[result_port]
+ [r, r.value]
+ else
+ [result_port, obj]
+ end
+ ensure
+ # close all ports for join
+ monitors.each do |port, r|
+ r.unmonitor port
+ port.close
+ end
end
end
#
# call-seq:
- # Ractor.receive -> msg
- #
- # Receive a message from the incoming port of the current ractor (which was
- # sent there by #send from another ractor).
- #
- # r = Ractor.new do
- # v1 = Ractor.receive
- # puts "Received: #{v1}"
- # end
- # r.send('message1')
- # r.take
- # # Here will be printed: "Received: message1"
- #
- # Alternatively, the private instance method +receive+ may be used:
- #
- # r = Ractor.new do
- # v1 = receive
- # puts "Received: #{v1}"
- # end
- # r.send('message1')
- # r.take
- # # This prints: "Received: message1"
- #
- # The method blocks if the queue is empty.
- #
- # r = Ractor.new do
- # puts "Before first receive"
- # v1 = Ractor.receive
- # puts "Received: #{v1}"
- # v2 = Ractor.receive
- # puts "Received: #{v2}"
- # end
- # wait
- # puts "Still not received"
- # r.send('message1')
- # wait
- # puts "Still received only one"
- # r.send('message2')
- # r.take
- #
- # Output:
- #
- # Before first receive
- # Still not received
- # Received: message1
- # Still received only one
- # Received: message2
- #
- # If close_incoming was called on the ractor, the method raises Ractor::ClosedError
- # if there are no more messages in the incoming queue:
- #
- # Ractor.new do
- # close_incoming
- # receive
- # end
- # wait
- # # in `receive': The incoming port is already closed => #<Ractor:#2 test.rb:1 running> (Ractor::ClosedError)
+ # Ractor.receive -> obj
#
+ # Receives a message from the current ractor's default port.
def self.receive
- __builtin_cexpr! %q{
- ractor_receive(ec, rb_ec_ractor_ptr(ec))
- }
+ Ractor.current.default_port.receive
end
class << self
@@ -555,280 +356,21 @@ class Ractor
# same as Ractor.receive
private def receive
- __builtin_cexpr! %q{
- ractor_receive(ec, rb_ec_ractor_ptr(ec))
- }
+ default_port.receive
end
alias recv receive
#
# call-seq:
- # Ractor.receive_if {|msg| block } -> msg
- #
- # Receive only a specific message.
- #
- # Instead of Ractor.receive, Ractor.receive_if can be given a pattern (or any
- # filter) in a block and you can choose the messages to accept that are available in
- # your ractor's incoming queue.
- #
- # r = Ractor.new do
- # p Ractor.receive_if{|msg| msg.match?(/foo/)} #=> "foo3"
- # p Ractor.receive_if{|msg| msg.match?(/bar/)} #=> "bar1"
- # p Ractor.receive_if{|msg| msg.match?(/baz/)} #=> "baz2"
- # end
- # r << "bar1"
- # r << "baz2"
- # r << "foo3"
- # r.take
- #
- # This will output:
- #
- # foo3
- # bar1
- # baz2
- #
- # If the block returns a truthy value, the message is removed from the incoming queue
- # and returned.
- # Otherwise, the message remains in the incoming queue and the next messages are checked
- # by the given block.
- #
- # If there are no messages left in the incoming queue, the method will
- # block until new messages arrive.
- #
- # If the block is escaped by break/return/exception/throw, the message is removed from
- # the incoming queue as if a truthy value had been returned.
- #
- # r = Ractor.new do
- # val = Ractor.receive_if{|msg| msg.is_a?(Array)}
- # puts "Received successfully: #{val}"
- # end
- #
- # r.send(1)
- # r.send('test')
- # wait
- # puts "2 non-matching sent, nothing received"
- # r.send([1, 2, 3])
- # wait
- #
- # Prints:
+ # ractor.send(msg, move: false) -> self
#
- # 2 non-matching sent, nothing received
- # Received successfully: [1, 2, 3]
- #
- # Note that you can not call receive/receive_if in the given block recursively.
- # You should not do any tasks in the block other than message filtration.
- #
- # Ractor.current << true
- # Ractor.receive_if{|msg| Ractor.receive}
- # #=> `receive': can not call receive/receive_if recursively (Ractor::Error)
- #
- def self.receive_if &b
- Primitive.ractor_receive_if b
- end
-
- # same as Ractor.receive_if
- private def receive_if &b
- Primitive.ractor_receive_if b
- end
-
- #
- # call-seq:
- # ractor.send(msg, move: false) -> self
- #
- # Send a message to a Ractor's incoming queue to be accepted by Ractor.receive.
- #
- # r = Ractor.new do
- # value = Ractor.receive
- # puts "Received #{value}"
- # end
- # r.send 'message'
- # # Prints: "Received: message"
- #
- # The method is non-blocking (will return immediately even if the ractor is not ready
- # to receive anything):
- #
- # r = Ractor.new {sleep(5)}
- # r.send('test')
- # puts "Sent successfully"
- # # Prints: "Sent successfully" immediately
- #
- # An attempt to send to a ractor which already finished its execution will raise Ractor::ClosedError.
- #
- # r = Ractor.new {}
- # r.take
- # p r
- # # "#<Ractor:#6 (irb):23 terminated>"
- # r.send('test')
- # # Ractor::ClosedError (The incoming-port is already closed)
- #
- # If close_incoming was called on the ractor, the method also raises Ractor::ClosedError.
- #
- # r = Ractor.new do
- # sleep(500)
- # receive
- # end
- # r.close_incoming
- # r.send('test')
- # # Ractor::ClosedError (The incoming-port is already closed)
- # # The error is raised immediately, not when the ractor tries to receive
- #
- # If the +obj+ is unshareable, by default it will be copied into the receiving ractor by deep cloning.
- # If <tt>move: true</tt> is passed, the object is _moved_ into the receiving ractor and becomes
- # inaccessible to the sender.
- #
- # r = Ractor.new {puts "Received: #{receive}"}
- # msg = 'message'
- # r.send(msg, move: true)
- # r.take
- # p msg
- #
- # This prints:
- #
- # Received: message
- # in `p': undefined method `inspect' for #<Ractor::MovedObject:0x000055c99b9b69b8>
- #
- # All references to the object and its parts will become invalid to the sender.
- #
- # r = Ractor.new {puts "Received: #{receive}"}
- # s = 'message'
- # ary = [s]
- # copy = ary.dup
- # r.send(ary, move: true)
- #
- # s.inspect
- # # Ractor::MovedError (can not send any methods to a moved object)
- # ary.class
- # # Ractor::MovedError (can not send any methods to a moved object)
- # copy.class
- # # => Array, it is different object
- # copy[0].inspect
- # # Ractor::MovedError (can not send any methods to a moved object)
- # # ...but its item was still a reference to `s`, which was moved
- #
- # If the object is shareable, <tt>move: true</tt> has no effect on it:
- #
- # r = Ractor.new {puts "Received: #{receive}"}
- # s = 'message'.freeze
- # r.send(s, move: true)
- # s.inspect #=> "message", still available
- #
- def send(obj, move: false)
- __builtin_cexpr! %q{
- ractor_send(ec, RACTOR_PTR(self), obj, move)
- }
+ # This is equivalent to Port#send to the ractor's #default_port.
+ def send(...)
+ default_port.send(...)
+ self
end
alias << send
- #
- # call-seq:
- # Ractor.yield(msg, move: false) -> nil
- #
- # Send a message to the current ractor's outgoing port to be accepted by #take.
- #
- # r = Ractor.new {Ractor.yield 'Hello from ractor'}
- # puts r.take
- # # Prints: "Hello from ractor"
- #
- # This method is blocking, and will return only when somebody consumes the
- # sent message.
- #
- # r = Ractor.new do
- # Ractor.yield 'Hello from ractor'
- # puts "Ractor: after yield"
- # end
- # wait
- # puts "Still not taken"
- # puts r.take
- #
- # This will print:
- #
- # Still not taken
- # Hello from ractor
- # Ractor: after yield
- #
- # If the outgoing port was closed with #close_outgoing, the method will raise:
- #
- # r = Ractor.new do
- # close_outgoing
- # Ractor.yield 'Hello from ractor'
- # end
- # wait
- # # `yield': The outgoing-port is already closed (Ractor::ClosedError)
- #
- # The meaning of the +move+ argument is the same as for #send.
- def self.yield(obj, move: false)
- __builtin_cexpr! %q{
- ractor_yield(ec, rb_ec_ractor_ptr(ec), obj, move)
- }
- end
-
- #
- # call-seq:
- # ractor.take -> msg
- #
- # Get a message from the ractor's outgoing port, which was put there by Ractor.yield or at ractor's
- # termination.
- #
- # r = Ractor.new do
- # Ractor.yield 'explicit yield'
- # 'last value'
- # end
- # puts r.take #=> 'explicit yield'
- # puts r.take #=> 'last value'
- # puts r.take # Ractor::ClosedError (The outgoing-port is already closed)
- #
- # The fact that the last value is also sent to the outgoing port means that +take+ can be used
- # as an analog of Thread#join ("just wait until ractor finishes"). However, it will raise if
- # somebody has already consumed that message.
- #
- # If the outgoing port was closed with #close_outgoing, the method will raise Ractor::ClosedError.
- #
- # r = Ractor.new do
- # sleep(500)
- # Ractor.yield 'Hello from ractor'
- # end
- # r.close_outgoing
- # r.take
- # # Ractor::ClosedError (The outgoing-port is already closed)
- # # The error would be raised immediately, not when ractor will try to receive
- #
- # If an uncaught exception is raised in the Ractor, it is propagated by take as a
- # Ractor::RemoteError.
- #
- # r = Ractor.new {raise "Something weird happened"}
- #
- # begin
- # r.take
- # rescue => e
- # p e # => #<Ractor::RemoteError: thrown by remote Ractor.>
- # p e.ractor == r # => true
- # p e.cause # => #<RuntimeError: Something weird happened>
- # end
- #
- # Ractor::ClosedError is a descendant of StopIteration, so the termination of the ractor will break
- # out of any loops that receive this message without propagating the error:
- #
- # r = Ractor.new do
- # 3.times {|i| Ractor.yield "message #{i}"}
- # "finishing"
- # end
- #
- # loop {puts "Received: " + r.take}
- # puts "Continue successfully"
- #
- # This will print:
- #
- # Received: message 0
- # Received: message 1
- # Received: message 2
- # Received: finishing
- # Continue successfully
- def take
- __builtin_cexpr! %q{
- ractor_take(ec, RACTOR_PTR(self))
- }
- end
-
def inspect
loc = __builtin_cexpr! %q{ RACTOR_PTR(self)->loc }
name = __builtin_cexpr! %q{ RACTOR_PTR(self)->name }
@@ -841,49 +383,25 @@ class Ractor
alias to_s inspect
- # The name set in Ractor.new, or +nil+.
+ # Returns the name set in Ractor.new, or +nil+.
def name
__builtin_cexpr! %q{RACTOR_PTR(self)->name}
end
class RemoteError
+ # The Ractor in which the uncaught exception was raised.
attr_reader :ractor
end
#
# call-seq:
- # ractor.close_incoming -> true | false
+ # ractor.close -> true | false
#
- # Closes the incoming port and returns whether it was already closed. All further attempts
- # to Ractor.receive in the ractor, and #send to the ractor will fail with Ractor::ClosedError.
+ # Closes the default port. Closing a port is allowed only by the ractor which created the port.
+ # Therefore, the receiver must be the current ractor.
#
- # r = Ractor.new {sleep(500)}
- # r.close_incoming #=> false
- # r.close_incoming #=> true
- # r.send('test')
- # # Ractor::ClosedError (The incoming-port is already closed)
- def close_incoming
- __builtin_cexpr! %q{
- ractor_close_incoming(ec, RACTOR_PTR(self));
- }
- end
-
- #
- # call-seq:
- # ractor.close_outgoing -> true | false
- #
- # Closes the outgoing port and returns whether it was already closed. All further attempts
- # to Ractor.yield in the ractor, and #take from the ractor will fail with Ractor::ClosedError.
- #
- # r = Ractor.new {sleep(500)}
- # r.close_outgoing #=> false
- # r.close_outgoing #=> true
- # r.take
- # # Ractor::ClosedError (The outgoing-port is already closed)
- def close_outgoing
- __builtin_cexpr! %q{
- ractor_close_outgoing(ec, RACTOR_PTR(self));
- }
+ def close
+ default_port.close
end
#
@@ -892,7 +410,7 @@ class Ractor
#
# Checks if the object is shareable by ractors.
#
- # Ractor.shareable?(1) #=> true -- numbers and other immutable basic values are frozen
+ # Ractor.shareable?(1) #=> true -- numbers are shareable
# Ractor.shareable?('foo') #=> false, unless the string is frozen due to # frozen_string_literal: true
# Ractor.shareable?('foo'.freeze) #=> true
#
@@ -907,7 +425,7 @@ class Ractor
# call-seq:
# Ractor.make_shareable(obj, copy: false) -> shareable_obj
#
- # Make +obj+ shareable between ractors.
+ # Makes +obj+ shareable between ractors.
#
# +obj+ and all the objects it refers to will be frozen, unless they are
# already shareable.
@@ -950,20 +468,367 @@ class Ractor
end
end
- # get a value from ractor-local storage
+ # Gets a value from ractor-local storage for the current Ractor.
+ # Obsolete, use Ractor.[] instead.
def [](sym)
+ if (self != Ractor.current)
+ raise RuntimeError, "Cannot get ractor local storage for non-current ractor"
+ end
Primitive.ractor_local_value(sym)
end
- # set a value in ractor-local storage
+ # Sets a value in ractor-local storage for the current Ractor.
+ # Obsolete, use Ractor.[]= instead.
def []=(sym, val)
+ if (self != Ractor.current)
+ raise RuntimeError, "Cannot set ractor local storage for non-current ractor"
+ end
Primitive.ractor_local_value_set(sym, val)
end
- # returns main ractor
+ # Gets a value from ractor-local storage for the current Ractor.
+ def self.[](sym)
+ Primitive.ractor_local_value(sym)
+ end
+
+ # Sets a value in ractor-local storage for the current Ractor.
+ def self.[]=(sym, val)
+ Primitive.ractor_local_value_set(sym, val)
+ end
+
+ # call-seq:
+ # Ractor.store_if_absent(key){ init_block }
+ #
+ # If the corresponding ractor-local value is not set, yields a value with
+ # init_block and stores the value in a thread-safe manner.
+ # This method returns the stored value.
+ #
+ # (1..10).map{
+ # Thread.new(it){|i|
+ # Ractor.store_if_absent(:s){ f(); i }
+ # #=> return stored value of key :s
+ # }
+ # }.map(&:value).uniq.size #=> 1 and f() is called only once
+ #
+ def self.store_if_absent(sym)
+ Primitive.attr! :use_block
+ Primitive.ractor_local_value_store_if_absent(sym)
+ end
+
+ # Returns the main ractor.
def self.main
__builtin_cexpr! %q{
rb_ractor_self(GET_VM()->ractor.main_ractor);
}
end
+
+ # Returns true if the current ractor is the main ractor.
+ def self.main?
+ __builtin_cexpr! %q{
+ RBOOL(GET_VM()->ractor.main_ractor == rb_ec_ractor_ptr(ec))
+ }
+ end
+
+ # internal method
+ def self._require feature # :nodoc:
+ if main?
+ super feature
+ else
+ Primitive.ractor_require feature
+ end
+ end
+
+ class << self
+ private
+
+ # internal method that is called when the first "Ractor.new" is called
+ def _activated # :nodoc:
+ Kernel.prepend Module.new{|m|
+ m.set_temporary_name '<RactorRequire>'
+
+ def require feature # :nodoc: -- otherwise RDoc outputs it as a class method
+ if Ractor.main?
+ super
+ else
+ Ractor._require feature
+ end
+ end
+ }
+ end
+ end
+
+ #
+ # call-seq:
+ # ractor.default_port -> port object
+ #
+ # Returns the default port of the Ractor.
+ #
+ def default_port
+ __builtin_cexpr! %q{
+ ractor_default_port_value(RACTOR_PTR(self))
+ }
+ end
+
+ #
+ # call-seq:
+ # ractor.join -> self
+ #
+ # Waits for the termination of the Ractor.
+ # If the Ractor was aborted (terminated by an unhandled exception),
+ # the exception is raised in the current ractor.
+ #
+ # Ractor.new{}.join #=> ractor
+ #
+ # Ractor.new{ raise "foo" }.join
+ # #=> raises the exception "foo (RuntimeError)"
+ #
+ def join
+ port = Port.new
+
+ self.monitor port
+ if port.receive == :aborted
+ __builtin_ractor_value
+ end
+
+ self
+ ensure
+ port.close
+ end
+
+ #
+ # call-seq:
+ # ractor.value -> obj
+ #
+ # Waits for +ractor+ to complete and returns its value or raises the exception
+ # which terminated the Ractor. The termination value will be moved to the calling
+ # Ractor. Therefore, at most 1 Ractor can receive another ractor's termination value.
+ #
+ # r = Ractor.new{ [1, 2] }
+ # r.value #=> [1, 2] (unshareable object)
+ #
+ # Ractor.new(r){|r| r.value} #=> Ractor::Error
+ #
+ def value
+ self.join
+ __builtin_ractor_value
+ end
+
+ #
+ # call-seq:
+ # ractor.monitor(port) -> self
+ #
+ # Registers the port as a monitoring port for this ractor. When the ractor terminates,
+ # the port receives a Symbol object.
+ #
+ # * +:exited+ is sent if the ractor terminates without an unhandled exception.
+ # * +:aborted+ is sent if the ractor terminates by an unhandled exception.
+ #
+ # r = Ractor.new{ some_task() }
+ # r.monitor(port = Ractor::Port.new)
+ # port.receive #=> :exited and r is terminated
+ #
+ # r = Ractor.new{ raise "foo" }
+ # r.monitor(port = Ractor::Port.new)
+ # port.receive #=> :aborted and r is terminated by the RuntimeError "foo"
+ #
+ def monitor port
+ __builtin_ractor_monitor(port)
+ end
+
+ #
+ # call-seq:
+ # ractor.unmonitor(port) -> self
+ #
+ # Unregisters the port from the monitoring ports for this ractor.
+ #
+ def unmonitor port
+ __builtin_ractor_unmonitor(port)
+ end
+
+ #
+ # call-seq:
+ # Ractor.shareable_proc(self: nil){} -> shareable proc
+ #
+ # Returns a shareable copy of the given block's Proc. The value of +self+
+ # in the Proc will be replaced with the value passed via the `self:` keyword,
+ # or +nil+ if not given.
+ #
+ # In a shareable Proc, access to any outer variables is prohibited.
+ #
+ # a = 42
+ # Ractor.shareable_proc{ p a }
+ # #=> can not isolate a Proc because it accesses outer variables (a). (Ractor::IsolationError)
+ #
+ # The value of `self` in the Proc must be a shareable object.
+ #
+ # Ractor.shareable_proc(self: self){}
+ # #=> self should be shareable: main (Ractor::IsolationError)
+ #
+ def self.shareable_proc self: nil
+ Primitive.attr! :use_block
+
+ __builtin_cexpr!(%Q{
+ ractor_shareable_proc(ec, *LOCAL_PTR(self), false)
+ })
+ end
+
+ #
+ # call-seq:
+ # Ractor.shareable_lambda(self: nil){} -> shareable lambda
+ #
+ # Same as Ractor.shareable_proc, but returns a lambda Proc.
+ #
+ def self.shareable_lambda self: nil
+ Primitive.attr! :use_block
+
+ __builtin_cexpr!(%Q{
+ ractor_shareable_proc(ec, *LOCAL_PTR(self), true)
+ })
+ end
+
+ # \Port objects transmit messages between Ractors.
+ class Port
+ #
+ # call-seq:
+ # port.receive -> msg
+ #
+ # Receives a message from the port (which was sent there by Port#send). Only the ractor
+ # that created the port can receive messages this way.
+ #
+ # port = Ractor::Port.new
+ # r = Ractor.new port do |port|
+ # port.send('message1')
+ # end
+ #
+ # v1 = port.receive
+ # puts "Received: #{v1}"
+ # r.join
+ # # This will print: "Received: message1"
+ #
+ # The method blocks the current Thread if the message queue is empty.
+ #
+ # port = Ractor::Port.new
+ # r = Ractor.new port do |port|
+ # wait
+ # puts "Still not received"
+ # port.send('message1')
+ # wait
+ # puts "Still received only one"
+ # port.send('message2')
+ # end
+ # puts "Before first receive"
+ # v1 = port.receive
+ # puts "Received: #{v1}"
+ # v2 = port.receive
+ # puts "Received: #{v2}"
+ # r.join
+ #
+ # Output:
+ #
+ # Before first receive
+ # Still not received
+ # Received: message1
+ # Still received only one
+ # Received: message2
+ #
+ # If the port is closed and there are no more messages in the message queue,
+ # the method raises Ractor::ClosedError.
+ #
+ # port = Ractor::Port.new
+ # port.close
+ # port.receive #=> raise Ractor::ClosedError
+ #
+ def receive
+ __builtin_cexpr! %q{
+ ractor_port_receive(ec, self)
+ }
+ end
+
+ #
+ # call-seq:
+ # port.send(msg, move: false) -> self
+ #
+ # Sends a message to the port to be accepted by port.receive.
+ #
+ # port = Ractor::Port.new
+ # r = Ractor.new(port) do |port|
+ # port.send 'message'
+ # end
+ # value = port.receive
+ # puts "Received #{value}"
+ # # Prints: "Received: message"
+ #
+ # The method is non-blocking (it will return immediately even if the ractor that created the port is not ready
+ # to receive anything):
+ #
+ # port = Ractor::Port.new
+ # r = Ractor.new(port) do |port|
+ # port.send 'test'
+ # puts "Sent successfully"
+ # # Prints: "Sent successfully" immediately
+ # end
+ #
+ # An attempt to send to a closed port will raise Ractor::ClosedError.
+ #
+ # r = Ractor.new {Ractor::Port.new}
+ # r.join
+ # p r
+ # # "#<Ractor:#6 (irb):23 terminated>"
+ # port = r.value
+ # port.send('test') # raise Ractor::ClosedError
+ #
+ # If the +obj+ is unshareable, by default it will be copied into the receiving ractor by deep cloning.
+ #
+ # If the object is shareable, a reference to the object will be sent to the receiving ractor.
+ #
+ def send obj, move: false
+ __builtin_cexpr! %q{
+ ractor_port_send(ec, self, obj, move)
+ }
+ end
+
+ alias << send
+
+ #
+ # call-seq:
+ # port.close
+ #
+ # Closes the port. Sending to a closed port is prohibited.
+ # Receiving is also prohibited if there are no messages in its message queue.
+ #
+ # Only the Ractor which created the port is allowed to close it.
+ #
+ # port = Ractor::Port.new
+ # Ractor.new port do |port|
+ # port.close #=> closing port by other ractors is not allowed (Ractor::Error)
+ # end.join
+ #
+ def close
+ __builtin_cexpr! %q{
+ ractor_port_close(ec, self)
+ }
+ end
+
+ #
+ # call-seq:
+ # port.closed? -> true/false
+ #
+ # Returns whether or not the port is closed.
+ def closed?
+ __builtin_cexpr! %q{
+ ractor_port_closed_p(ec, self);
+ }
+ end
+
+ #
+ # call-seq:
+ # port.inspect -> string
+ def inspect
+ "#<Ractor::Port to:\##{
+ __builtin_cexpr! "SIZET2NUM(rb_ractor_id((RACTOR_PORT_PTR(self)->r)))"
+ } id:#{
+ __builtin_cexpr! "SIZET2NUM(ractor_port_id(RACTOR_PORT_PTR(self)))"
+ }>"
+ end
+ end
end
diff --git a/ractor_core.h b/ractor_core.h
index 1b9003b6d8..c692ebbbbf 100644
--- a/ractor_core.h
+++ b/ractor_core.h
@@ -1,3 +1,4 @@
+#include "internal/gc.h"
#include "ruby/ruby.h"
#include "ruby/ractor.h"
#include "vm_core.h"
@@ -8,118 +9,39 @@
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
#endif
-enum rb_ractor_basket_type {
- // basket is empty
- basket_type_none,
-
- // value is available
- basket_type_ref,
- basket_type_copy,
- basket_type_move,
- basket_type_will,
-
- // basket should be deleted
- basket_type_deleted,
-
- // basket is reserved
- basket_type_reserved,
-
- // take_basket is available
- basket_type_take_basket,
-
- // basket is keeping by yielding ractor
- basket_type_yielding,
-};
-
-// per ractor taking configuration
-struct rb_ractor_selector_take_config {
- bool closed;
- bool oneshot;
-};
-
-struct rb_ractor_basket {
- union {
- enum rb_ractor_basket_type e;
- rb_atomic_t atomic;
- } type;
- VALUE sender;
-
- union {
- struct {
- VALUE v;
- bool exception;
- } send;
-
- struct {
- struct rb_ractor_basket *basket;
- struct rb_ractor_selector_take_config *config;
- } take;
- } p; // payload
-};
-
-static inline bool
-basket_type_p(struct rb_ractor_basket *b, enum rb_ractor_basket_type type)
-{
- return b->type.e == type;
-}
-
-static inline bool
-basket_none_p(struct rb_ractor_basket *b)
-{
- return basket_type_p(b, basket_type_none);
-}
-
-struct rb_ractor_queue {
- struct rb_ractor_basket *baskets;
- int start;
- int cnt;
- int size;
- unsigned int serial;
- unsigned int reserved_cnt;
-};
-
-enum rb_ractor_wait_status {
- wait_none = 0x00,
- wait_receiving = 0x01,
- wait_taking = 0x02,
- wait_yielding = 0x04,
- wait_moving = 0x08,
-};
-
-enum rb_ractor_wakeup_status {
- wakeup_none,
- wakeup_by_send,
- wakeup_by_yield,
- wakeup_by_take,
- wakeup_by_close,
- wakeup_by_interrupt,
- wakeup_by_retry,
-};
+// experimental flag because it is not sure it is the common pattern
+#define RUBY_TYPED_FROZEN_SHAREABLE_NO_REC RUBY_FL_FINALIZE
struct rb_ractor_sync {
// ractor lock
rb_nativethread_lock_t lock;
+
#if RACTOR_CHECK_MODE > 0
VALUE locked_by;
#endif
- rb_nativethread_cond_t cond;
- bool incoming_port_closed;
- bool outgoing_port_closed;
+#ifndef RUBY_THREAD_PTHREAD_H
+ rb_nativethread_cond_t wakeup_cond;
+#endif
- // All sent messages will be pushed into recv_queue
- struct rb_ractor_queue recv_queue;
+ // incoming messages
+ struct ractor_queue *recv_queue;
- // The following ractors waiting for the yielding by this ractor
- struct rb_ractor_queue takers_queue;
+ // waiting threads for receiving
+ struct ccan_list_head waiters;
- // Enabled if the ractor already terminated and not taken yet.
- struct rb_ractor_basket will_basket;
+ // ports
+ VALUE default_port_value;
+ struct st_table *ports;
+ size_t next_port_id;
- struct ractor_wait {
- enum rb_ractor_wait_status status;
- enum rb_ractor_wakeup_status wakeup_status;
- } wait;
+ // monitors
+ struct ccan_list_head monitors;
+
+ // value
+ rb_ractor_t *successor;
+ VALUE legacy;
+ bool legacy_exc;
};
// created
@@ -145,12 +67,7 @@ enum ractor_status {
struct rb_ractor_struct {
struct rb_ractor_pub pub;
-
struct rb_ractor_sync sync;
- VALUE receiving_mutex;
-
- // vm wide barrier synchronization
- rb_nativethread_cond_t barrier_wait_cond;
// thread management
struct {
@@ -162,6 +79,7 @@ struct rb_ractor_struct {
rb_execution_context_t *running_ec;
rb_thread_t *main;
} threads;
+
VALUE thgroup_default;
VALUE name;
@@ -173,8 +91,11 @@ struct rb_ractor_struct {
// ractor local data
+ rb_serial_t next_ec_serial;
+
st_table *local_storage;
struct rb_id_table *idkey_local_storage;
+ VALUE local_storage_store_lock;
VALUE r_stdin;
VALUE r_stdout;
@@ -182,15 +103,24 @@ struct rb_ractor_struct {
VALUE verbose;
VALUE debug;
- rb_ractor_newobj_cache_t newobj_cache;
-
- // gc.c rb_objspace_reachable_objects_from
- struct gc_mark_func_data_struct {
- void *data;
- void (*mark_func)(VALUE v, void *data);
- } *mfd;
+ bool malloc_gc_disabled;
+ bool main_ractor;
+ void *newobj_cache;
}; // rb_ractor_t is defined in vm_core.h
+enum ractor_wakeup_status {
+ wakeup_none,
+ wakeup_by_send,
+ wakeup_by_interrupt,
+ // wakeup_by_close,
+};
+
+struct ractor_waiter {
+ enum ractor_wakeup_status wakeup_status;
+ rb_thread_t *th;
+ struct ccan_list_node node;
+ rb_atomic_t event_serial;
+};
static inline VALUE
rb_ractor_self(const rb_ractor_t *r)
@@ -209,7 +139,7 @@ void rb_ractor_send_parameters(rb_execution_context_t *ec, rb_ractor_t *g, VALUE
VALUE rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc); // defined in thread.c
int rb_ractor_living_thread_num(const rb_ractor_t *);
-VALUE rb_ractor_thread_list(rb_ractor_t *r);
+VALUE rb_ractor_thread_list(void);
bool rb_ractor_p(VALUE rv);
void rb_ractor_living_threads_init(rb_ractor_t *r);
@@ -222,12 +152,17 @@ void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
void rb_ractor_terminate_all(void);
bool rb_ractor_main_p_(void);
-void rb_ractor_finish_marking(void);
void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
+void rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *th);
+VALUE rb_ractor_require(VALUE feature, bool silent);
+VALUE rb_ractor_autoload_load(VALUE space, ID id);
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
+st_table *rb_ractor_targeted_hooks(rb_ractor_t *cr);
RUBY_SYMBOL_EXPORT_BEGIN
+void rb_ractor_finish_marking(void);
+
bool rb_ractor_shareable_p_continue(VALUE obj);
// THIS FUNCTION SHOULD NOT CALL WHILE INCREMENTAL MARKING!!
@@ -278,8 +213,16 @@ rb_ractor_sleeper_thread_num(rb_ractor_t *r)
}
static inline void
-rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
+rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th, bool always_reset)
{
+ RUBY_DEBUG_LOG("th:%d->%u%s",
+ cr->threads.running_ec ? (int)rb_th_serial(cr->threads.running_ec->thread_ptr) : -1,
+ rb_th_serial(th), cr->threads.running_ec == th->ec ? " (same)" : "");
+
+ if (cr->threads.running_ec != th->ec || always_reset) {
+ th->running_time_us = 0;
+ }
+
if (cr->threads.running_ec != th->ec) {
if (0) {
ruby_debug_printf("rb_ractor_thread_switch ec:%p->%p\n",
@@ -290,31 +233,26 @@ rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
return;
}
- if (cr->threads.running_ec != th->ec) {
- th->running_time_us = 0;
- }
-
cr->threads.running_ec = th->ec;
VM_ASSERT(cr == GET_RACTOR());
}
#define rb_ractor_set_current_ec(cr, ec) rb_ractor_set_current_ec_(cr, ec, __FILE__, __LINE__)
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+void rb_current_ec_set(rb_execution_context_t *ec);
+#endif
static inline void
rb_ractor_set_current_ec_(rb_ractor_t *cr, rb_execution_context_t *ec, const char *file, int line)
{
#ifdef RB_THREAD_LOCAL_SPECIFIER
- #ifdef __APPLE__
rb_current_ec_set(ec);
- #else
- ruby_current_ec = ec;
- #endif
#else
native_tls_set(ruby_current_ec_key, ec);
#endif
RUBY_DEBUG_LOG2(file, line, "ec:%p->%p", (void *)cr->threads.running_ec, (void *)ec);
- VM_ASSERT(cr->threads.running_ec != ec);
+ VM_ASSERT(ec == NULL || cr->threads.running_ec != ec);
cr->threads.running_ec = ec;
}
@@ -327,6 +265,25 @@ rb_ractor_id(const rb_ractor_t *r)
return r->pub.id;
}
+static inline void
+rb_ractor_targeted_hooks_incr(rb_ractor_t *cr)
+{
+ cr->pub.targeted_hooks_cnt++;
+}
+
+static inline void
+rb_ractor_targeted_hooks_decr(rb_ractor_t *cr)
+{
+ RUBY_ASSERT(cr->pub.targeted_hooks_cnt > 0);
+ cr->pub.targeted_hooks_cnt--;
+}
+
+static inline unsigned int
+rb_ractor_targeted_hooks_cnt(rb_ractor_t *cr)
+{
+ return cr->pub.targeted_hooks_cnt;
+}
+
#if RACTOR_CHECK_MODE > 0
# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj)))
@@ -338,12 +295,6 @@ rb_ractor_setup_belonging_to(VALUE obj, uint32_t rid)
RACTOR_BELONGING_ID(obj) = rid;
}
-static inline void
-rb_ractor_setup_belonging(VALUE obj)
-{
- rb_ractor_setup_belonging_to(obj, rb_ractor_current_id());
-}
-
static inline uint32_t
rb_ractor_belonging(VALUE obj)
{
@@ -355,9 +306,13 @@ rb_ractor_belonging(VALUE obj)
}
}
+extern bool rb_ractor_ignore_belonging_flag;
+
static inline VALUE
rb_ractor_confirm_belonging(VALUE obj)
{
+ if (rb_ractor_ignore_belonging_flag) return obj;
+
uint32_t id = rb_ractor_belonging(obj);
if (id == 0) {
@@ -377,6 +332,14 @@ rb_ractor_confirm_belonging(VALUE obj)
}
return obj;
}
+
+static inline void
+rb_ractor_ignore_belonging(bool flag)
+{
+ rb_ractor_ignore_belonging_flag = flag;
+}
+
#else
#define rb_ractor_confirm_belonging(obj) obj
+#define rb_ractor_ignore_belonging(flag) (0)
#endif
diff --git a/ractor_sync.c b/ractor_sync.c
new file mode 100644
index 0000000000..44c84ded92
--- /dev/null
+++ b/ractor_sync.c
@@ -0,0 +1,1489 @@
+// this file is included by ractor.c
+
+struct ractor_port {
+ rb_ractor_t *r;
+ st_data_t id_;
+};
+
+static st_data_t
+ractor_port_id(const struct ractor_port *rp)
+{
+ return rp->id_;
+}
+
+static VALUE rb_cRactorPort;
+
+static VALUE ractor_receive(rb_execution_context_t *ec, const struct ractor_port *rp);
+static VALUE ractor_send(rb_execution_context_t *ec, const struct ractor_port *rp, VALUE obj, VALUE move);
+static VALUE ractor_try_send(rb_execution_context_t *ec, const struct ractor_port *rp, VALUE obj, VALUE move);
+static void ractor_add_port(rb_ractor_t *r, st_data_t id);
+
+static void
+ractor_port_mark(void *ptr)
+{
+ const struct ractor_port *rp = (struct ractor_port *)ptr;
+
+ if (rp->r) {
+ rb_gc_mark(rp->r->pub.self);
+ }
+}
+
+static const rb_data_type_t ractor_port_data_type = {
+ "ractor/port",
+ {
+ ractor_port_mark,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // memsize
+ NULL, // update
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE,
+};
+
+static st_data_t
+ractor_genid_for_port(rb_ractor_t *cr)
+{
+ // TODO: enough?
+ return cr->sync.next_port_id++;
+}
+
+static struct ractor_port *
+RACTOR_PORT_PTR(VALUE self)
+{
+ VM_ASSERT(rb_typeddata_is_kind_of(self, &ractor_port_data_type));
+ return RTYPEDDATA_GET_DATA(self);
+}
+
+static VALUE
+ractor_port_alloc(VALUE klass)
+{
+ struct ractor_port *rp;
+ VALUE rpv = TypedData_Make_Struct(klass, struct ractor_port, &ractor_port_data_type, rp);
+ rb_obj_freeze(rpv);
+ return rpv;
+}
+
+static VALUE
+ractor_port_init(VALUE rpv, rb_ractor_t *r)
+{
+ struct ractor_port *rp = RACTOR_PORT_PTR(rpv);
+
+ rp->r = r;
+ RB_OBJ_WRITTEN(rpv, Qundef, r->pub.self);
+ rp->id_ = ractor_genid_for_port(r);
+
+ ractor_add_port(r, ractor_port_id(rp));
+
+ rb_obj_freeze(rpv);
+
+ return rpv;
+}
+
+/*
+ * call-seq:
+ * Ractor::Port.new -> new_port
+ *
+ * Returns a new Ractor::Port object.
+ */
+static VALUE
+ractor_port_initialize(VALUE self)
+{
+ return ractor_port_init(self, GET_RACTOR());
+}
+
+/* :nodoc: */
+static VALUE
+ractor_port_initialize_copy(VALUE self, VALUE orig)
+{
+ struct ractor_port *dst = RACTOR_PORT_PTR(self);
+ struct ractor_port *src = RACTOR_PORT_PTR(orig);
+ dst->r = src->r;
+ RB_OBJ_WRITTEN(self, Qundef, dst->r->pub.self);
+ dst->id_ = ractor_port_id(src);
+
+ return self;
+}
+
+static VALUE
+ractor_port_new(rb_ractor_t *r)
+{
+ VALUE rpv = ractor_port_alloc(rb_cRactorPort);
+ ractor_port_init(rpv, r);
+ return rpv;
+}
+
+static bool
+ractor_port_p(VALUE self)
+{
+ return rb_typeddata_is_kind_of(self, &ractor_port_data_type);
+}
+
+static VALUE
+ractor_port_receive(rb_execution_context_t *ec, VALUE self)
+{
+ const struct ractor_port *rp = RACTOR_PORT_PTR(self);
+
+ if (rp->r != rb_ec_ractor_ptr(ec)) {
+ rb_raise(rb_eRactorError, "only allowed from the creator Ractor of this port");
+ }
+
+ return ractor_receive(ec, rp);
+}
+
+static VALUE
+ractor_port_send(rb_execution_context_t *ec, VALUE self, VALUE obj, VALUE move)
+{
+ const struct ractor_port *rp = RACTOR_PORT_PTR(self);
+ ractor_send(ec, rp, obj, RTEST(move));
+ return self;
+}
+
+static bool ractor_closed_port_p(rb_execution_context_t *ec, rb_ractor_t *r, const struct ractor_port *rp);
+static bool ractor_close_port(rb_execution_context_t *ec, rb_ractor_t *r, const struct ractor_port *rp);
+
+static VALUE
+ractor_port_closed_p(rb_execution_context_t *ec, VALUE self)
+{
+ const struct ractor_port *rp = RACTOR_PORT_PTR(self);
+
+ if (ractor_closed_port_p(ec, rp->r, rp)) {
+ return Qtrue;
+ }
+ else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+ractor_port_close(rb_execution_context_t *ec, VALUE self)
+{
+ const struct ractor_port *rp = RACTOR_PORT_PTR(self);
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+
+ if (cr != rp->r) {
+ rb_raise(rb_eRactorError, "closing port by other ractors is not allowed");
+ }
+
+ ractor_close_port(ec, cr, rp);
+ return self;
+}
+
+// ractor-internal
+
+// ractor-internal - ractor_basket
+
+enum ractor_basket_type {
+ // basket is empty
+ basket_type_none,
+
+ // value is available
+ basket_type_ref,
+ basket_type_copy,
+ basket_type_move,
+};
+
+struct ractor_basket {
+ enum ractor_basket_type type;
+ VALUE sender;
+ st_data_t port_id;
+
+ struct {
+ VALUE v;
+ bool exception;
+ } p; // payload
+
+ struct ccan_list_node node;
+};
+
+#if 0
+static inline bool
+ractor_basket_type_p(const struct ractor_basket *b, enum ractor_basket_type type)
+{
+ return b->type == type;
+}
+
+static inline bool
+ractor_basket_none_p(const struct ractor_basket *b)
+{
+ return ractor_basket_type_p(b, basket_type_none);
+}
+#endif
+
+static void
+ractor_basket_mark(const struct ractor_basket *b)
+{
+ rb_gc_mark(b->p.v);
+}
+
+static void
+ractor_basket_free(struct ractor_basket *b)
+{
+ SIZED_FREE(b);
+}
+
+static struct ractor_basket *
+ractor_basket_alloc(void)
+{
+ struct ractor_basket *b = ALLOC(struct ractor_basket);
+ return b;
+}
+
+// ractor-internal - ractor_queue
+
+struct ractor_queue {
+ struct ccan_list_head set;
+ bool closed;
+};
+
+static void
+ractor_queue_init(struct ractor_queue *rq)
+{
+ ccan_list_head_init(&rq->set);
+ rq->closed = false;
+}
+
+static struct ractor_queue *
+ractor_queue_new(void)
+{
+ struct ractor_queue *rq = ALLOC(struct ractor_queue);
+ ractor_queue_init(rq);
+ return rq;
+}
+
+static void
+ractor_queue_mark(const struct ractor_queue *rq)
+{
+ const struct ractor_basket *b;
+
+ ccan_list_for_each(&rq->set, b, node) {
+ ractor_basket_mark(b);
+ }
+}
+
+static void
+ractor_queue_free(struct ractor_queue *rq)
+{
+ struct ractor_basket *b, *nxt;
+
+ ccan_list_for_each_safe(&rq->set, b, nxt, node) {
+ ccan_list_del_init(&b->node);
+ ractor_basket_free(b);
+ }
+
+ VM_ASSERT(ccan_list_empty(&rq->set));
+
+ SIZED_FREE(rq);
+}
+
+RBIMPL_ATTR_MAYBE_UNUSED()
+static size_t
+ractor_queue_size(const struct ractor_queue *rq)
+{
+ size_t size = 0;
+ const struct ractor_basket *b;
+
+ ccan_list_for_each(&rq->set, b, node) {
+ size++;
+ }
+ return size;
+}
+
+static void
+ractor_queue_close(struct ractor_queue *rq)
+{
+ rq->closed = true;
+}
+
+static void
+ractor_queue_move(struct ractor_queue *dst_rq, struct ractor_queue *src_rq)
+{
+ struct ccan_list_head *src = &src_rq->set;
+ struct ccan_list_head *dst = &dst_rq->set;
+
+ dst->n.next = src->n.next;
+ dst->n.prev = src->n.prev;
+ dst->n.next->prev = &dst->n;
+ dst->n.prev->next = &dst->n;
+ ccan_list_head_init(src);
+}
+
+#if 0
+static struct ractor_basket *
+ractor_queue_head(rb_ractor_t *r, struct ractor_queue *rq)
+{
+ return ccan_list_top(&rq->set, struct ractor_basket, node);
+}
+#endif
+
+static bool
+ractor_queue_empty_p(rb_ractor_t *r, const struct ractor_queue *rq)
+{
+ return ccan_list_empty(&rq->set);
+}
+
+static struct ractor_basket *
+ractor_queue_deq(rb_ractor_t *r, struct ractor_queue *rq)
+{
+ VM_ASSERT(GET_RACTOR() == r);
+
+ return ccan_list_pop(&rq->set, struct ractor_basket, node);
+}
+
+static void
+ractor_queue_enq(rb_ractor_t *r, struct ractor_queue *rq, struct ractor_basket *basket)
+{
+ ccan_list_add_tail(&rq->set, &basket->node);
+}
+
+#if 0
+static void
+rq_dump(const struct ractor_queue *rq)
+{
+ int i=0;
+ struct ractor_basket *b;
+ ccan_list_for_each(&rq->set, b, node) {
+ fprintf(stderr, "%d type:%s %p\n", i, basket_type_name(b->type), (void *)b);
+ i++;
+ }
+}
+#endif
+
+static void ractor_delete_port(rb_ractor_t *cr, st_data_t id, bool locked);
+
+static struct ractor_queue *
+ractor_get_queue(rb_ractor_t *cr, st_data_t id, bool locked)
+{
+ VM_ASSERT(cr == GET_RACTOR());
+
+ struct ractor_queue *rq;
+
+ if (cr->sync.ports && st_lookup(cr->sync.ports, id, (st_data_t *)&rq)) {
+ if (rq->closed && ractor_queue_empty_p(cr, rq)) {
+ ractor_delete_port(cr, id, locked);
+ return NULL;
+ }
+ else {
+ return rq;
+ }
+ }
+ else {
+ return NULL;
+ }
+}
+
+// ractor-internal - ports
+
+static void
+ractor_add_port(rb_ractor_t *r, st_data_t id)
+{
+ struct ractor_queue *rq = ractor_queue_new();
+ ASSERT_ractor_unlocking(r);
+
+ RUBY_DEBUG_LOG("id:%u", (unsigned int)id);
+
+ RACTOR_LOCK(r);
+ {
+ st_insert(r->sync.ports, id, (st_data_t)rq);
+ }
+ RACTOR_UNLOCK(r);
+}
+
+static void
+ractor_delete_port_locked(rb_ractor_t *cr, st_data_t id)
+{
+ ASSERT_ractor_locking(cr);
+
+ RUBY_DEBUG_LOG("id:%u", (unsigned int)id);
+
+ struct ractor_queue *rq;
+
+ if (st_delete(cr->sync.ports, &id, (st_data_t *)&rq)) {
+ ractor_queue_free(rq);
+ }
+ else {
+ VM_ASSERT(0);
+ }
+}
+
+static void
+ractor_delete_port(rb_ractor_t *cr, st_data_t id, bool locked)
+{
+ if (locked) {
+ ractor_delete_port_locked(cr, id);
+ }
+ else {
+ RACTOR_LOCK_SELF(cr);
+ {
+ ractor_delete_port_locked(cr, id);
+ }
+ RACTOR_UNLOCK_SELF(cr);
+ }
+}
+
+static const struct ractor_port *
+ractor_default_port(rb_ractor_t *r)
+{
+ return RACTOR_PORT_PTR(r->sync.default_port_value);
+}
+
+static VALUE
+ractor_default_port_value(rb_ractor_t *r)
+{
+ return r->sync.default_port_value;
+}
+
+static bool
+ractor_closed_port_p(rb_execution_context_t *ec, rb_ractor_t *r, const struct ractor_port *rp)
+{
+ VM_ASSERT(rb_ec_ractor_ptr(ec) == rp->r ? 1 : (ASSERT_ractor_locking(rp->r), 1));
+
+ const struct ractor_queue *rq;
+
+ if (rp->r->sync.ports && st_lookup(rp->r->sync.ports, ractor_port_id(rp), (st_data_t *)&rq)) {
+ return rq->closed;
+ }
+ else {
+ return true;
+ }
+}
+
+static void ractor_deliver_incoming_messages(rb_execution_context_t *ec, rb_ractor_t *cr);
+static bool ractor_queue_empty_p(rb_ractor_t *r, const struct ractor_queue *rq);
+
+static bool
+ractor_close_port(rb_execution_context_t *ec, rb_ractor_t *cr, const struct ractor_port *rp)
+{
+ VM_ASSERT(cr == rp->r);
+ struct ractor_queue *rq = NULL;
+
+ RACTOR_LOCK_SELF(cr);
+ {
+ ractor_deliver_incoming_messages(ec, cr); // check incoming messages
+
+ if (st_lookup(rp->r->sync.ports, ractor_port_id(rp), (st_data_t *)&rq)) {
+ ractor_queue_close(rq);
+
+ if (ractor_queue_empty_p(cr, rq)) {
+ // delete from the table
+ ractor_delete_port(cr, ractor_port_id(rp), true);
+ }
+
+ // TODO: free rq
+ }
+ }
+ RACTOR_UNLOCK_SELF(cr);
+
+ return rq != NULL;
+}
+
+static int
+ractor_free_all_ports_i(st_data_t port_id, st_data_t val, st_data_t dat)
+{
+ struct ractor_queue *rq = (struct ractor_queue *)val;
+ // rb_ractor_t *cr = (rb_ractor_t *)dat;
+
+ ractor_queue_free(rq);
+ return ST_CONTINUE;
+}
+
+static void
+ractor_free_all_ports(rb_ractor_t *cr)
+{
+ if (cr->sync.ports) {
+ st_foreach(cr->sync.ports, ractor_free_all_ports_i, (st_data_t)cr);
+ st_free_table(cr->sync.ports);
+ cr->sync.ports = NULL;
+ }
+
+ if (cr->sync.recv_queue) {
+ ractor_queue_free(cr->sync.recv_queue);
+ cr->sync.recv_queue = NULL;
+ }
+}
+
+#if defined(HAVE_WORKING_FORK)
+static void
+ractor_sync_terminate_atfork(rb_vm_t *vm, rb_ractor_t *r)
+{
+ ractor_free_all_ports(r);
+ r->sync.legacy = Qnil;
+}
+#endif
+
+// Ractor#monitor
+
+struct ractor_monitor {
+ struct ractor_port port;
+ struct ccan_list_node node;
+};
+
+static void
+ractor_mark_monitors(rb_ractor_t *r)
+{
+ const struct ractor_monitor *rm;
+ ccan_list_for_each(&r->sync.monitors, rm, node) {
+ rb_gc_mark(rm->port.r->pub.self);
+ }
+}
+
+static VALUE
+ractor_exit_token(bool exc)
+{
+ if (exc) {
+ RUBY_DEBUG_LOG("aborted");
+ return ID2SYM(idAborted);
+ }
+ else {
+ RUBY_DEBUG_LOG("exited");
+ return ID2SYM(idExited);
+ }
+}
+
+static VALUE
+ractor_monitor(rb_execution_context_t *ec, VALUE self, VALUE port)
+{
+ rb_ractor_t *r = RACTOR_PTR(self);
+ bool terminated = false;
+ const struct ractor_port *rp = RACTOR_PORT_PTR(port);
+ struct ractor_monitor *rm = ALLOC(struct ractor_monitor);
+ rm->port = *rp; // copy port information
+
+ RACTOR_LOCK(r);
+ {
+ if (UNDEF_P(r->sync.legacy)) { // not terminated
+ RUBY_DEBUG_LOG("OK/r:%u -> port:%u@r%u", (unsigned int)rb_ractor_id(r), (unsigned int)ractor_port_id(&rm->port), (unsigned int)rb_ractor_id(rm->port.r));
+ ccan_list_add_tail(&r->sync.monitors, &rm->node);
+ }
+ else {
+ RUBY_DEBUG_LOG("NG/r:%u -> port:%u@r%u", (unsigned int)rb_ractor_id(r), (unsigned int)ractor_port_id(&rm->port), (unsigned int)rb_ractor_id(rm->port.r));
+ terminated = true;
+ }
+ }
+ RACTOR_UNLOCK(r);
+
+ if (terminated) {
+ SIZED_FREE(rm);
+ ractor_port_send(ec, port, ractor_exit_token(r->sync.legacy_exc), Qfalse);
+
+ return Qfalse;
+ }
+ else {
+ return Qtrue;
+ }
+}
+
+static VALUE
+ractor_unmonitor(rb_execution_context_t *ec, VALUE self, VALUE port)
+{
+ rb_ractor_t *r = RACTOR_PTR(self);
+ const struct ractor_port *rp = RACTOR_PORT_PTR(port);
+
+ RACTOR_LOCK(r);
+ {
+ if (UNDEF_P(r->sync.legacy)) { // not terminated
+ struct ractor_monitor *rm, *nxt;
+
+ ccan_list_for_each_safe(&r->sync.monitors, rm, nxt, node) {
+ if (ractor_port_id(&rm->port) == ractor_port_id(rp)) {
+ RUBY_DEBUG_LOG("r:%u -> port:%u@r%u",
+ (unsigned int)rb_ractor_id(r),
+ (unsigned int)ractor_port_id(&rm->port),
+ (unsigned int)rb_ractor_id(rm->port.r));
+ ccan_list_del(&rm->node);
+ SIZED_FREE(rm);
+ }
+ }
+ }
+ }
+ RACTOR_UNLOCK(r);
+
+ return self;
+}
+
+static void
+ractor_notify_exit(rb_execution_context_t *ec, rb_ractor_t *cr, VALUE legacy, bool exc)
+{
+ RUBY_DEBUG_LOG("exc:%d", exc);
+ VM_ASSERT(!UNDEF_P(legacy));
+ VM_ASSERT(cr->sync.legacy == Qundef);
+
+ RACTOR_LOCK_SELF(cr);
+ {
+ ractor_free_all_ports(cr);
+
+ cr->sync.legacy = legacy;
+ cr->sync.legacy_exc = exc;
+ }
+ RACTOR_UNLOCK_SELF(cr);
+
+ // send token
+
+ VALUE token = ractor_exit_token(exc);
+ struct ractor_monitor *rm, *nxt;
+
+ ccan_list_for_each_safe(&cr->sync.monitors, rm, nxt, node)
+ {
+ RUBY_DEBUG_LOG("port:%u@r%u", (unsigned int)ractor_port_id(&rm->port), (unsigned int)rb_ractor_id(rm->port.r));
+
+ ractor_try_send(ec, &rm->port, token, false);
+
+ ccan_list_del(&rm->node);
+ SIZED_FREE(rm);
+ }
+
+ VM_ASSERT(ccan_list_empty(&cr->sync.monitors));
+}
+
+// ractor-internal - initialize, mark, free, memsize
+
+static int
+ractor_mark_ports_i(st_data_t key, st_data_t val, st_data_t data)
+{
+ // id -> ractor_queue
+ const struct ractor_queue *rq = (struct ractor_queue *)val;
+ ractor_queue_mark(rq);
+ return ST_CONTINUE;
+}
+
+static void
+ractor_sync_mark(rb_ractor_t *r)
+{
+ rb_gc_mark(r->sync.default_port_value);
+
+ if (r->sync.ports) {
+ ractor_queue_mark(r->sync.recv_queue);
+ st_foreach(r->sync.ports, ractor_mark_ports_i, 0);
+ }
+
+ ractor_mark_monitors(r);
+}
+
+static int
+ractor_sync_free_ports_i(st_data_t _key, st_data_t val, st_data_t _args)
+{
+ struct ractor_queue *queue = (struct ractor_queue *)val;
+
+ ractor_queue_free(queue);
+
+ return ST_CONTINUE;
+}
+
+static void
+ractor_sync_free(rb_ractor_t *r)
+{
+ if (r->sync.recv_queue) {
+ ractor_queue_free(r->sync.recv_queue);
+ }
+
+ // maybe NULL
+ if (r->sync.ports) {
+ st_foreach(r->sync.ports, ractor_sync_free_ports_i, 0);
+ st_free_table(r->sync.ports);
+ r->sync.ports = NULL;
+ }
+}
+
+static size_t
+ractor_sync_memsize(const rb_ractor_t *r)
+{
+ if (r->sync.ports) {
+ return st_table_size(r->sync.ports);
+ }
+ else {
+ return 0;
+ }
+}
+
+static void
+ractor_sync_init(rb_ractor_t *r)
+{
+ // lock
+ rb_native_mutex_initialize(&r->sync.lock);
+
+ // monitors
+ ccan_list_head_init(&r->sync.monitors);
+
+ // waiters
+ ccan_list_head_init(&r->sync.waiters);
+
+ // receiving queue
+ r->sync.recv_queue = ractor_queue_new();
+
+ // ports
+ r->sync.ports = st_init_numtable();
+ r->sync.default_port_value = ractor_port_new(r);
+ FL_SET_RAW(r->sync.default_port_value, RUBY_FL_SHAREABLE); // only default ports are shareable
+
+ // legacy
+ r->sync.legacy = Qundef;
+
+#ifndef RUBY_THREAD_PTHREAD_H
+ rb_native_cond_initialize(&r->sync.wakeup_cond);
+#endif
+}
+
+// Ractor#value
+
+static rb_ractor_t *
+ractor_set_successor_once(rb_ractor_t *r, rb_ractor_t *cr)
+{
+ if (r->sync.successor == NULL) {
+ rb_ractor_t *successor = ATOMIC_PTR_CAS(r->sync.successor, NULL, cr);
+ return successor == NULL ? cr : successor;
+ }
+
+ return r->sync.successor;
+}
+
+static VALUE ractor_reset_belonging(VALUE obj);
+
+static VALUE
+ractor_make_remote_exception(VALUE cause, VALUE sender)
+{
+ VALUE err = rb_exc_new_cstr(rb_eRactorRemoteError, "thrown by remote Ractor.");
+ rb_ivar_set(err, rb_intern("@ractor"), sender);
+ rb_ec_setup_exception(NULL, err, cause);
+ return err;
+}
+
+static VALUE
+ractor_value(rb_execution_context_t *ec, VALUE self)
+{
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ rb_ractor_t *r = RACTOR_PTR(self);
+ rb_ractor_t *sr = ractor_set_successor_once(r, cr);
+
+ if (sr == cr) {
+ ractor_reset_belonging(r->sync.legacy);
+
+ if (r->sync.legacy_exc) {
+ rb_exc_raise(ractor_make_remote_exception(r->sync.legacy, self));
+ }
+ return r->sync.legacy;
+ }
+ else {
+ rb_raise(rb_eRactorError, "Only the successor ractor can take a value");
+ }
+}
+
+static VALUE ractor_move(VALUE obj); // in this file
+static VALUE ractor_copy(VALUE obj); // in this file
+
+static VALUE
+ractor_prepare_payload(rb_execution_context_t *ec, VALUE obj, enum ractor_basket_type *ptype)
+{
+ switch (*ptype) {
+ case basket_type_ref:
+ return obj;
+ case basket_type_move:
+ return ractor_move(obj);
+ default:
+ if (rb_ractor_shareable_p(obj)) {
+ *ptype = basket_type_ref;
+ return obj;
+ }
+ else {
+ *ptype = basket_type_copy;
+ return ractor_copy(obj);
+ }
+ }
+}
+
+static struct ractor_basket *
+ractor_basket_new(rb_execution_context_t *ec, VALUE obj, enum ractor_basket_type type, bool exc)
+{
+ VALUE v = ractor_prepare_payload(ec, obj, &type);
+
+ struct ractor_basket *b = ractor_basket_alloc();
+ b->type = type;
+ b->p.v = v;
+ b->p.exception = exc;
+ return b;
+}
+
+static VALUE
+ractor_basket_value(struct ractor_basket *b)
+{
+ switch (b->type) {
+ case basket_type_ref:
+ break;
+ case basket_type_copy:
+ case basket_type_move:
+ ractor_reset_belonging(b->p.v);
+ break;
+ default:
+ VM_ASSERT(0); // unreachable
+ }
+
+ VM_ASSERT(!RB_TYPE_P(b->p.v, T_NONE));
+ return b->p.v;
+}
+
+static VALUE
+ractor_basket_accept(struct ractor_basket *b)
+{
+ VALUE v = ractor_basket_value(b);
+
+ if (b->p.exception) {
+ VALUE err = ractor_make_remote_exception(v, b->sender);
+ ractor_basket_free(b);
+ rb_exc_raise(err);
+ }
+
+ ractor_basket_free(b);
+ return v;
+}
+
+// Ractor blocking by receive
+
+#if VM_CHECK_MODE > 0
+static bool
+ractor_waiter_included(rb_ractor_t *cr, rb_thread_t *th)
+{
+ ASSERT_ractor_locking(cr);
+
+ struct ractor_waiter *w;
+
+ ccan_list_for_each(&cr->sync.waiters, w, node) {
+ if (w->th == th) {
+ return true;
+ }
+ }
+
+ return false;
+}
+#endif
+
+#if USE_RUBY_DEBUG_LOG
+
+static const char *
+wakeup_status_str(enum ractor_wakeup_status wakeup_status)
+{
+ switch (wakeup_status) {
+ case wakeup_none: return "none";
+ case wakeup_by_send: return "by_send";
+ case wakeup_by_interrupt: return "by_interrupt";
+ // case wakeup_by_close: return "by_close";
+ }
+ rb_bug("unreachable");
+}
+
+static const char *
+basket_type_name(enum ractor_basket_type type)
+{
+ switch (type) {
+ case basket_type_none: return "none";
+ case basket_type_ref: return "ref";
+ case basket_type_copy: return "copy";
+ case basket_type_move: return "move";
+ }
+ VM_ASSERT(0);
+ return NULL;
+}
+
+#endif // USE_RUBY_DEBUG_LOG
+
+#ifdef RUBY_THREAD_PTHREAD_H
+
+//
+
+#else // win32
+
+static void
+ractor_cond_wait(rb_ractor_t *r)
+{
+#if RACTOR_CHECK_MODE > 0
+ VALUE locked_by = r->sync.locked_by;
+ r->sync.locked_by = Qnil;
+#endif
+ rb_native_cond_wait(&r->sync.wakeup_cond, &r->sync.lock);
+
+#if RACTOR_CHECK_MODE > 0
+ r->sync.locked_by = locked_by;
+#endif
+}
+
+static void *
+ractor_wait_no_gvl(void *ptr)
+{
+ struct ractor_waiter *waiter = (struct ractor_waiter *)ptr;
+ rb_ractor_t *cr = waiter->th->ractor;
+
+ RACTOR_LOCK_SELF(cr);
+ {
+ if (waiter->wakeup_status == wakeup_none) {
+ ractor_cond_wait(cr);
+ }
+ }
+ RACTOR_UNLOCK_SELF(cr);
+ return NULL;
+}
+
+static void
+rb_ractor_sched_wait(rb_execution_context_t *ec, rb_ractor_t *cr, rb_unblock_function_t *ubf, void *ptr)
+{
+ struct ractor_waiter *waiter = (struct ractor_waiter *)ptr;
+
+ RACTOR_UNLOCK(cr);
+ {
+ rb_nogvl(ractor_wait_no_gvl, waiter,
+ ubf, waiter,
+ RB_NOGVL_UBF_ASYNC_SAFE | RB_NOGVL_INTR_FAIL);
+ }
+ RACTOR_LOCK(cr);
+}
+
+static void
+rb_ractor_sched_wakeup(rb_ractor_t *r, rb_thread_t *th)
+{
+ // ractor lock is acquired
+ rb_native_cond_broadcast(&r->sync.wakeup_cond);
+}
+#endif
+
+static bool
+ractor_wakeup_all(rb_ractor_t *r, enum ractor_wakeup_status wakeup_status)
+{
+ ASSERT_ractor_unlocking(r);
+
+ RUBY_DEBUG_LOG("r:%u wakeup:%s", rb_ractor_id(r), wakeup_status_str(wakeup_status));
+
+ bool wakeup_p = false;
+
+ RACTOR_LOCK(r);
+ while (1) {
+ struct ractor_waiter *waiter = ccan_list_pop(&r->sync.waiters, struct ractor_waiter, node);
+
+ if (waiter) {
+ VM_ASSERT(waiter->wakeup_status == wakeup_none);
+
+ waiter->wakeup_status = wakeup_status;
+ rb_ractor_sched_wakeup(r, waiter->th);
+
+ wakeup_p = true;
+ }
+ else {
+ break;
+ }
+ }
+ RACTOR_UNLOCK(r);
+
+ return wakeup_p;
+}
+
+static void
+ubf_ractor_wait(void *ptr)
+{
+ struct ractor_waiter *waiter = (struct ractor_waiter *)ptr;
+
+ rb_thread_t *th = waiter->th;
+ rb_ractor_t *r = th->ractor;
+ rb_atomic_t event_serial = waiter->event_serial;
+
+ // clear ubf and nobody can kick UBF
+ th->unblock.func = NULL;
+ th->unblock.arg = NULL;
+
+ rb_native_mutex_unlock(&th->interrupt_lock);
+ {
+ RACTOR_LOCK(r);
+ {
+ if (RUBY_ATOMIC_LOAD(th->unblock.event_serial) == event_serial && waiter->wakeup_status == wakeup_none) {
+ RUBY_DEBUG_LOG("waiter:%p", (void *)waiter);
+
+ waiter->wakeup_status = wakeup_by_interrupt;
+ ccan_list_del(&waiter->node);
+
+ rb_ractor_sched_wakeup(r, waiter->th);
+ }
+ }
+ RACTOR_UNLOCK(r);
+ }
+ rb_native_mutex_lock(&th->interrupt_lock);
+}
+
+static enum ractor_wakeup_status
+ractor_wait(rb_execution_context_t *ec, rb_ractor_t *cr)
+{
+ rb_thread_t *th = rb_ec_thread_ptr(ec);
+
+ struct ractor_waiter waiter = {
+ .wakeup_status = wakeup_none,
+ .th = th,
+ };
+
+ RUBY_DEBUG_LOG("wait%s", "");
+
+ ASSERT_ractor_locking(cr);
+
+ VM_ASSERT(GET_RACTOR() == cr);
+ VM_ASSERT(!ractor_waiter_included(cr, th));
+
+ ccan_list_add_tail(&cr->sync.waiters, &waiter.node);
+
+ // resume another ready thread and wait for an event
+ rb_ractor_sched_wait(ec, cr, ubf_ractor_wait, &waiter);
+
+ if (waiter.wakeup_status == wakeup_none) {
+ ccan_list_del(&waiter.node);
+ }
+
+ RUBY_DEBUG_LOG("wakeup_status:%s", wakeup_status_str(waiter.wakeup_status));
+
+ RACTOR_UNLOCK_SELF(cr);
+ {
+ rb_ec_check_ints(ec);
+ }
+ RACTOR_LOCK_SELF(cr);
+
+ VM_ASSERT(!ractor_waiter_included(cr, th));
+ return waiter.wakeup_status;
+}
+
+static void
+ractor_deliver_incoming_messages(rb_execution_context_t *ec, rb_ractor_t *cr)
+{
+ ASSERT_ractor_locking(cr);
+ struct ractor_queue *recv_q = cr->sync.recv_queue;
+
+ struct ractor_basket *b;
+ while ((b = ractor_queue_deq(cr, recv_q)) != NULL) {
+ ractor_queue_enq(cr, ractor_get_queue(cr, b->port_id, true), b);
+ }
+}
+
+static bool
+ractor_check_received(rb_ractor_t *cr, struct ractor_queue *messages)
+{
+ struct ractor_queue *received_queue = cr->sync.recv_queue;
+ bool received = false;
+
+ ASSERT_ractor_locking(cr);
+
+ if (ractor_queue_empty_p(cr, received_queue)) {
+ RUBY_DEBUG_LOG("empty");
+ }
+ else {
+ received = true;
+
+ // messages <- incoming
+ ractor_queue_init(messages);
+ ractor_queue_move(messages, received_queue);
+ }
+
+ VM_ASSERT(ractor_queue_empty_p(cr, received_queue));
+
+ RUBY_DEBUG_LOG("received:%d", received);
+ return received;
+}
+
+static void
+ractor_wait_receive(rb_execution_context_t *ec, rb_ractor_t *cr)
+{
+ struct ractor_queue messages;
+ bool deliverred = false;
+
+ RACTOR_LOCK_SELF(cr);
+ {
+ if (ractor_check_received(cr, &messages)) {
+ deliverred = true;
+ }
+ else {
+ ractor_wait(ec, cr);
+ }
+ }
+ RACTOR_UNLOCK_SELF(cr);
+
+ if (deliverred) {
+ VM_ASSERT(!ractor_queue_empty_p(cr, &messages));
+ struct ractor_basket *b;
+
+ while ((b = ractor_queue_deq(cr, &messages)) != NULL) {
+ ractor_queue_enq(cr, ractor_get_queue(cr, b->port_id, false), b);
+ }
+ }
+}
+
+static VALUE
+ractor_try_receive(rb_execution_context_t *ec, rb_ractor_t *cr, const struct ractor_port *rp)
+{
+ struct ractor_queue *rq = ractor_get_queue(cr, ractor_port_id(rp), false);
+
+ if (rq == NULL) {
+ rb_raise(rb_eRactorClosedError, "The port was already closed");
+ }
+
+ struct ractor_basket *b = ractor_queue_deq(cr, rq);
+
+ if (rq->closed && ractor_queue_empty_p(cr, rq)) {
+ ractor_delete_port(cr, ractor_port_id(rp), false);
+ }
+
+ if (b) {
+ return ractor_basket_accept(b);
+ }
+ else {
+ return Qundef;
+ }
+}
+
+static VALUE
+ractor_receive(rb_execution_context_t *ec, const struct ractor_port *rp)
+{
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ VM_ASSERT(cr == rp->r);
+
+ RUBY_DEBUG_LOG("port:%u", (unsigned int)ractor_port_id(rp));
+
+ while (1) {
+ VALUE v = ractor_try_receive(ec, cr, rp);
+
+ if (v != Qundef) {
+ return v;
+ }
+ else {
+ ractor_wait_receive(ec, cr);
+ }
+ }
+}
+
+// Ractor#send
+
+static void
+ractor_send_basket(rb_execution_context_t *ec, const struct ractor_port *rp, struct ractor_basket *b, bool raise_on_error)
+{
+ bool closed = false;
+
+ RUBY_DEBUG_LOG("port:%u@r%u b:%s v:%p", (unsigned int)ractor_port_id(rp), rb_ractor_id(rp->r), basket_type_name(b->type), (void *)b->p.v);
+
+ RACTOR_LOCK(rp->r);
+ {
+ if (ractor_closed_port_p(ec, rp->r, rp)) {
+ closed = true;
+ }
+ else {
+ b->port_id = ractor_port_id(rp);
+ ractor_queue_enq(rp->r, rp->r->sync.recv_queue, b);
+ }
+ }
+ RACTOR_UNLOCK(rp->r);
+
+ // NOTE: ref r -> b->p.v is created, but Ractor is unprotected object, so no problem on that.
+
+ if (!closed) {
+ ractor_wakeup_all(rp->r, wakeup_by_send);
+ }
+ else {
+ RUBY_DEBUG_LOG("closed:%u@r%u", (unsigned int)ractor_port_id(rp), rb_ractor_id(rp->r));
+
+ if (raise_on_error) {
+ ractor_basket_free(b);
+ rb_raise(rb_eRactorClosedError, "The port was already closed");
+ }
+ }
+}
+
+static VALUE
+ractor_send0(rb_execution_context_t *ec, const struct ractor_port *rp, VALUE obj, VALUE move, bool raise_on_error)
+{
+ struct ractor_basket *b = ractor_basket_new(ec, obj, RTEST(move) ? basket_type_move : basket_type_none, false);
+ ractor_send_basket(ec, rp, b, raise_on_error);
+ RB_GC_GUARD(obj);
+ return rp->r->pub.self;
+}
+
+static VALUE
+ractor_send(rb_execution_context_t *ec, const struct ractor_port *rp, VALUE obj, VALUE move)
+{
+ return ractor_send0(ec, rp, obj, move, true);
+}
+
+static VALUE
+ractor_try_send(rb_execution_context_t *ec, const struct ractor_port *rp, VALUE obj, VALUE move)
+{
+ return ractor_send0(ec, rp, obj, move, false);
+}
+
+// Ractor::Selector
+
+struct ractor_selector {
+ struct st_table *ports; // rpv -> rp
+
+};
+
+static int
+ractor_selector_mark_i(st_data_t key, st_data_t val, st_data_t dmy)
+{
+ rb_gc_mark((VALUE)key); // rpv
+
+ return ST_CONTINUE;
+}
+
+static void
+ractor_selector_mark(void *ptr)
+{
+ struct ractor_selector *s = ptr;
+
+ if (s->ports) {
+ st_foreach(s->ports, ractor_selector_mark_i, 0);
+ }
+}
+
+static void
+ractor_selector_free(void *ptr)
+{
+ struct ractor_selector *s = ptr;
+ st_free_table(s->ports);
+ SIZED_FREE(s);
+}
+
+static size_t
+ractor_selector_memsize(const void *ptr)
+{
+ const struct ractor_selector *s = ptr;
+ size_t size = sizeof(struct ractor_selector);
+ if (s->ports) {
+ size += st_memsize(s->ports);
+ }
+ return size;
+}
+
+static const rb_data_type_t ractor_selector_data_type = {
+ "ractor/selector",
+ {
+ ractor_selector_mark,
+ ractor_selector_free,
+ ractor_selector_memsize,
+ NULL, // update
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+
+static struct ractor_selector *
+RACTOR_SELECTOR_PTR(VALUE selv)
+{
+ VM_ASSERT(rb_typeddata_is_kind_of(selv, &ractor_selector_data_type));
+ return (struct ractor_selector *)DATA_PTR(selv);
+}
+
+// Ractor::Selector.new
+
+static VALUE
+ractor_selector_create(VALUE klass)
+{
+ struct ractor_selector *s;
+ VALUE selv = TypedData_Make_Struct(klass, struct ractor_selector, &ractor_selector_data_type, s);
+ s->ports = st_init_numtable(); // TODO
+ return selv;
+}
+
+// Ractor::Selector#add(r)
+
+/*
+ * call-seq:
+ * add(ractor) -> ractor
+ *
+ * Adds _ractor_ to +self+. Raises an exception if _ractor_ is already added.
+ * Returns _ractor_.
+ */
+static VALUE
+ractor_selector_add(VALUE selv, VALUE rpv)
+{
+ if (!ractor_port_p(rpv)) {
+ rb_raise(rb_eArgError, "Not a Ractor::Port object");
+ }
+
+ struct ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
+ const struct ractor_port *rp = RACTOR_PORT_PTR(rpv);
+
+ if (st_lookup(s->ports, (st_data_t)rpv, NULL)) {
+ rb_raise(rb_eArgError, "already added");
+ }
+
+ st_insert(s->ports, (st_data_t)rpv, (st_data_t)rp);
+ RB_OBJ_WRITTEN(selv, Qundef, rpv);
+
+ return selv;
+}
+
+// Ractor::Selector#remove(r)
+
+/* call-seq:
+ * remove(ractor) -> ractor
+ *
+ * Removes _ractor_ from +self+. Raises an exception if _ractor_ is not added.
+ * Returns the removed _ractor_.
+ */
+static VALUE
+ractor_selector_remove(VALUE selv, VALUE rpv)
+{
+ if (!ractor_port_p(rpv)) {
+ rb_raise(rb_eArgError, "Not a Ractor::Port object");
+ }
+
+ struct ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
+
+ if (!st_lookup(s->ports, (st_data_t)rpv, NULL)) {
+ rb_raise(rb_eArgError, "not added yet");
+ }
+
+ st_delete(s->ports, (st_data_t *)&rpv, NULL);
+
+ return selv;
+}
+
+// Ractor::Selector#clear
+
+/*
+ * call-seq:
+ * clear -> self
+ *
+ * Removes all ractors from +self+. Raises +self+.
+ */
+static VALUE
+ractor_selector_clear(VALUE selv)
+{
+ struct ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
+ st_clear(s->ports);
+ return selv;
+}
+
+/*
+ * call-seq:
+ * empty? -> true or false
+ *
+ * Returns +true+ if no ractor is added.
+ */
+static VALUE
+ractor_selector_empty_p(VALUE selv)
+{
+ struct ractor_selector *s = RACTOR_SELECTOR_PTR(selv);
+ return s->ports->num_entries == 0 ? Qtrue : Qfalse;
+}
+
+// Ractor::Selector#wait
+
+struct ractor_selector_wait_data {
+ rb_ractor_t *cr;
+ rb_execution_context_t *ec;
+ bool found;
+ VALUE v;
+ VALUE rpv;
+};
+
+static int
+ractor_selector_wait_i(st_data_t key, st_data_t val, st_data_t data)
+{
+ struct ractor_selector_wait_data *p = (struct ractor_selector_wait_data *)data;
+ const struct ractor_port *rp = (const struct ractor_port *)val;
+
+ VALUE v = ractor_try_receive(p->ec, p->cr, rp);
+
+ if (v != Qundef) {
+ p->found = true;
+ p->v = v;
+ p->rpv = (VALUE)key;
+ return ST_STOP;
+ }
+ else {
+ return ST_CONTINUE;
+ }
+}
+
+static VALUE
+ractor_selector__wait(rb_execution_context_t *ec, VALUE selector)
+{
+ rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
+ struct ractor_selector *s = RACTOR_SELECTOR_PTR(selector);
+
+ struct ractor_selector_wait_data data = {
+ .ec = ec,
+ .cr = cr,
+ .found = false,
+ };
+
+ while (1) {
+ st_foreach(s->ports, ractor_selector_wait_i, (st_data_t)&data);
+
+ if (data.found) {
+ return rb_ary_new_from_args(2, data.rpv, data.v);
+ }
+
+ ractor_wait_receive(ec, cr);
+ }
+}
+
+/*
+ * call-seq:
+ * wait(receive: false, yield_value: undef, move: false) -> [ractor, value]
+ *
+ * Waits until any ractor in _selector_ can be active.
+ */
+static VALUE
+ractor_selector_wait(VALUE selector)
+{
+ return ractor_selector__wait(GET_EC(), selector);
+}
+
+static VALUE
+ractor_selector_new(int argc, VALUE *ractors, VALUE klass)
+{
+ VALUE selector = ractor_selector_create(klass);
+
+ for (int i=0; i<argc; i++) {
+ ractor_selector_add(selector, ractors[i]);
+ }
+
+ return selector;
+}
+
+static VALUE
+ractor_select_internal(rb_execution_context_t *ec, VALUE self, VALUE ports)
+{
+ VALUE selector = ractor_selector_new(RARRAY_LENINT(ports), (VALUE *)RARRAY_CONST_PTR(ports), rb_cRactorSelector);
+ VALUE result = ractor_selector__wait(ec, selector);
+
+ RB_GC_GUARD(selector);
+ RB_GC_GUARD(ports);
+ return result;
+}
+
+#ifndef USE_RACTOR_SELECTOR
+#define USE_RACTOR_SELECTOR 0
+#endif
+
+RUBY_SYMBOL_EXPORT_BEGIN
+void rb_init_ractor_selector(void);
+RUBY_SYMBOL_EXPORT_END
+
+/*
+ * Document-class: Ractor::Selector
+ * :nodoc: currently
+ *
+ * Selects multiple Ractors to be activated.
+ */
+void
+rb_init_ractor_selector(void)
+{
+ rb_cRactorSelector = rb_define_class_under(rb_cRactor, "Selector", rb_cObject);
+ rb_undef_alloc_func(rb_cRactorSelector);
+
+ rb_define_singleton_method(rb_cRactorSelector, "new", ractor_selector_new , -1);
+ rb_define_method(rb_cRactorSelector, "add", ractor_selector_add, 1);
+ rb_define_method(rb_cRactorSelector, "remove", ractor_selector_remove, 1);
+ rb_define_method(rb_cRactorSelector, "clear", ractor_selector_clear, 0);
+ rb_define_method(rb_cRactorSelector, "empty?", ractor_selector_empty_p, 0);
+ rb_define_method(rb_cRactorSelector, "wait", ractor_selector_wait, 0);
+}
+
+static void
+Init_RactorPort(void)
+{
+ rb_cRactorPort = rb_define_class_under(rb_cRactor, "Port", rb_cObject);
+ rb_define_alloc_func(rb_cRactorPort, ractor_port_alloc);
+ rb_define_method(rb_cRactorPort, "initialize", ractor_port_initialize, 0);
+ rb_define_method(rb_cRactorPort, "initialize_copy", ractor_port_initialize_copy, 1);
+
+#if USE_RACTOR_SELECTOR
+ rb_init_ractor_selector();
+#endif
+}
diff --git a/random.c b/random.c
index 4b5b7ab6c4..63f43a161a 100644
--- a/random.c
+++ b/random.c
@@ -73,7 +73,7 @@
#include "ruby/random.h"
#include "ruby/ractor.h"
-typedef int int_must_be_32bit_at_least[sizeof(int) * CHAR_BIT < 32 ? -1 : 1];
+STATIC_ASSERT(int_must_be_32bit_at_least, sizeof(int) * CHAR_BIT >= 32);
#include "missing/mt19937.c"
@@ -131,8 +131,9 @@ typedef struct {
static VALUE rand_init(const rb_random_interface_t *, rb_random_t *, VALUE);
static VALUE random_seed(VALUE);
-static void fill_random_seed(uint32_t *seed, size_t cnt);
+static void fill_random_seed(uint32_t *seed, size_t cnt, bool try_bytes);
static VALUE make_seed_value(uint32_t *ptr, size_t len);
+#define fill_random_bytes ruby_fill_random_bytes
RB_RANDOM_INTERFACE_DECLARE(rand_mt);
static const rb_random_interface_t random_mt_if = {
@@ -141,22 +142,31 @@ static const rb_random_interface_t random_mt_if = {
};
static rb_random_mt_t *
-rand_mt_start(rb_random_mt_t *r)
+rand_mt_start(rb_random_mt_t *r, VALUE obj)
{
if (!genrand_initialized(&r->mt)) {
r->base.seed = rand_init(&random_mt_if, &r->base, random_seed(Qundef));
+ if (obj) {
+ RB_OBJ_WRITTEN(obj, Qundef, r->base.seed);
+ }
}
return r;
}
static rb_random_t *
-rand_start(rb_random_mt_t *r)
+rand_start(rb_random_mt_t *r, VALUE obj)
{
- return &rand_mt_start(r)->base;
+ return &rand_mt_start(r, obj)->base;
}
static rb_ractor_local_key_t default_rand_key;
+void
+rb_free_default_rand_key(void)
+{
+ xfree(default_rand_key);
+}
+
static void
default_rand_mark(void *ptr)
{
@@ -185,7 +195,13 @@ default_rand(void)
static rb_random_mt_t *
default_mt(void)
{
- return rand_mt_start(default_rand());
+ return rand_mt_start(default_rand(), Qfalse);
+}
+
+static rb_random_t *
+default_rand_start(void)
+{
+ return &default_mt()->base;
}
unsigned int
@@ -214,7 +230,7 @@ int_pair_to_real_inclusive(uint32_t a, uint32_t b)
const uint128_t m = ((uint128_t)1 << dig) | 1;
uint128_t x = ((uint128_t)a << 32) | b;
r = (double)(uint64_t)((x * m) >> 64);
-#elif defined HAVE_UINT64_T && !MSC_VERSION_BEFORE(1300)
+#elif defined HAVE_UINT64_T
uint64_t x = ((uint64_t)a << dig_u) +
(((uint64_t)b + (a >> dig_u)) >> dig_r64);
r = (double)x;
@@ -256,7 +272,7 @@ const rb_data_type_t rb_random_data_type = {
random_free,
random_memsize,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
#define random_mt_mark rb_random_mark
@@ -277,7 +293,7 @@ static const rb_data_type_t random_mt_type = {
},
&rb_random_data_type,
(void *)&random_mt_if,
- RUBY_TYPED_FREE_IMMEDIATELY
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
static rb_random_t *
@@ -286,7 +302,7 @@ get_rnd(VALUE obj)
rb_random_t *ptr;
TypedData_Get_Struct(obj, rb_random_t, &rb_random_data_type, ptr);
if (RTYPEDDATA_TYPE(obj) == &random_mt_type)
- return rand_start((rb_random_mt_t *)ptr);
+ return rand_start((rb_random_mt_t *)ptr, obj);
return ptr;
}
@@ -299,31 +315,24 @@ get_rnd_mt(VALUE obj)
}
static rb_random_t *
-try_get_rnd(VALUE obj)
+try_get_rnd(VALUE obj, const rb_random_interface_t **rng_p)
{
if (obj == rb_cRandom) {
- return rand_start(default_rand());
+ *rng_p = &random_mt_if;
+ return default_rand_start();
}
if (!rb_typeddata_is_kind_of(obj, &rb_random_data_type)) return NULL;
- if (RTYPEDDATA_TYPE(obj) == &random_mt_type)
- return rand_start(DATA_PTR(obj));
- rb_random_t *rnd = DATA_PTR(obj);
+ const struct rb_data_type_struct *type = RTYPEDDATA_TYPE(obj);
+ *rng_p = type->data;
+ void *rnd = DATA_PTR(obj);
if (!rnd) {
rb_raise(rb_eArgError, "uninitialized random: %s",
RTYPEDDATA_TYPE(obj)->wrap_struct_name);
}
+ if (type == &random_mt_type) rnd = rand_start(rnd, obj);
return rnd;
}
-static const rb_random_interface_t *
-try_rand_if(VALUE obj, rb_random_t *rnd)
-{
- if (rnd == &default_rand()->base) {
- return &random_mt_if;
- }
- return rb_rand_if(obj);
-}
-
/* :nodoc: */
void
rb_random_base_init(rb_random_t *rnd)
@@ -344,15 +353,23 @@ random_alloc(VALUE klass)
static VALUE
rand_init_default(const rb_random_interface_t *rng, rb_random_t *rnd)
{
- VALUE seed, buf0 = 0;
+ VALUE seed;
size_t len = roomof(rng->default_seed_bits, 32);
- uint32_t *buf = ALLOCV_N(uint32_t, buf0, len+1);
- fill_random_seed(buf, len);
- rng->init(rnd, buf, len);
- seed = make_seed_value(buf, len);
- explicit_bzero(buf, len * sizeof(*buf));
- ALLOCV_END(buf0);
+ if (LIKELY(len)) {
+ VALUE buf0 = 0;
+ uint32_t *buf = ALLOCV_N(uint32_t, buf0, len);
+ fill_random_seed(buf, len, true);
+ rng->init(rnd, buf, len);
+ seed = make_seed_value(buf, len);
+ explicit_bzero(buf, len * sizeof(*buf));
+ ALLOCV_END(buf0);
+ }
+ else {
+ uint32_t minimul[1] = {0};
+ rng->init(rnd, minimul, 0);
+ seed = INT2FIX(0);
+ }
return seed;
}
@@ -371,8 +388,8 @@ rand_init(const rb_random_interface_t *rng, rb_random_t *rnd, VALUE seed)
INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
if (sign < 0)
sign = -sign;
- if (len <= 1) {
- rng->init_int32(rnd, len ? buf[0] : 0);
+ if (len == 1) {
+ rng->init_int32(rnd, buf[0]);
}
else {
if (sign != 2 && buf[len-1] == 1) /* remove leading-zero-guard */
@@ -396,8 +413,8 @@ rand_init(const rb_random_interface_t *rng, rb_random_t *rnd, VALUE seed)
static VALUE
random_init(int argc, VALUE *argv, VALUE obj)
{
- rb_random_t *rnd = try_get_rnd(obj);
- const rb_random_interface_t *rng = rb_rand_if(obj);
+ const rb_random_interface_t *rng = NULL;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
if (!rng) {
rb_raise(rb_eTypeError, "undefined random interface: %s",
@@ -415,10 +432,10 @@ random_init(int argc, VALUE *argv, VALUE obj)
argc = rb_check_arity(argc, 0, 1);
rb_check_frozen(obj);
if (argc == 0) {
- rnd->seed = rand_init_default(rng, rnd);
+ RB_OBJ_WRITE(obj, &rnd->seed, rand_init_default(rng, rnd));
}
else {
- rnd->seed = rand_init(rng, rnd, rb_to_int(argv[0]));
+ RB_OBJ_WRITE(obj, &rnd->seed, rand_init(rng, rnd, rb_to_int(argv[0])));
}
return obj;
}
@@ -431,23 +448,17 @@ random_init(int argc, VALUE *argv, VALUE obj)
# define USE_DEV_URANDOM 0
#endif
-#ifdef HAVE_GETENTROPY
-# define MAX_SEED_LEN_PER_READ 256
-static int
-fill_random_bytes_urandom(void *seed, size_t size)
-{
- unsigned char *p = (unsigned char *)seed;
- while (size) {
- size_t len = size < MAX_SEED_LEN_PER_READ ? size : MAX_SEED_LEN_PER_READ;
- if (getentropy(p, len) != 0) {
- return -1;
- }
- p += len;
- size -= len;
- }
- return 0;
-}
-#elif USE_DEV_URANDOM
+#if ! defined HAVE_GETRANDOM && defined __linux__ && defined __NR_getrandom
+# ifndef GRND_NONBLOCK
+# define GRND_NONBLOCK 0x0001 /* not defined in musl libc */
+# endif
+# define getrandom(ptr, size, flags) \
+ (ssize_t)syscall(__NR_getrandom, (ptr), (size), (flags))
+# define HAVE_GETRANDOM 1
+#endif
+
+/* fill random bytes by reading random device directly */
+#if USE_DEV_URANDOM
static int
fill_random_bytes_urandom(void *seed, size_t size)
{
@@ -487,15 +498,7 @@ fill_random_bytes_urandom(void *seed, size_t size)
# define fill_random_bytes_urandom(seed, size) -1
#endif
-#if ! defined HAVE_GETRANDOM && defined __linux__ && defined __NR_getrandom
-# ifndef GRND_NONBLOCK
-# define GRND_NONBLOCK 0x0001 /* not defined in musl libc */
-# endif
-# define getrandom(ptr, size, flags) \
- (ssize_t)syscall(__NR_getrandom, (ptr), (size), (flags))
-# define HAVE_GETRANDOM 1
-#endif
-
+/* fill random bytes by library */
#if 0
#elif defined MAC_OS_X_VERSION_10_7 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
@@ -513,7 +516,7 @@ fill_random_bytes_urandom(void *seed, size_t size)
# endif
static int
-fill_random_bytes_syscall(void *seed, size_t size, int unused)
+fill_random_bytes_lib(void *seed, size_t size)
{
#if USE_COMMON_RANDOM
CCRNGStatus status = CCRandomGenerateBytes(seed, size);
@@ -540,18 +543,16 @@ fill_random_bytes_syscall(void *seed, size_t size, int unused)
}
return 0;
}
-#elif defined(HAVE_ARC4RANDOM_BUF)
+#elif defined(HAVE_ARC4RANDOM_BUF) && \
+ ((defined(__OpenBSD__) && OpenBSD >= 201411) || \
+ (defined(__NetBSD__) && __NetBSD_Version__ >= 700000000) || \
+ (defined(__FreeBSD__) && __FreeBSD_version >= 1200079))
+// [Bug #15039] arc4random_buf(3) should used only if we know it is fork-safe
static int
-fill_random_bytes_syscall(void *buf, size_t size, int unused)
+fill_random_bytes_lib(void *buf, size_t size)
{
-#if (defined(__OpenBSD__) && OpenBSD >= 201411) || \
- (defined(__NetBSD__) && __NetBSD_Version__ >= 700000000) || \
- (defined(__FreeBSD__) && __FreeBSD_version >= 1200079)
arc4random_buf(buf, size);
return 0;
-#else
- return -1;
-#endif
}
#elif defined(_WIN32)
@@ -560,17 +561,15 @@ fill_random_bytes_syscall(void *buf, size_t size, int unused)
#endif
# if defined(CRYPT_VERIFYCONTEXT)
-STATIC_ASSERT(sizeof_HCRYPTPROV, sizeof(HCRYPTPROV) == sizeof(size_t));
-
/* Although HCRYPTPROV is not a HANDLE, it looks like
* INVALID_HANDLE_VALUE is not a valid value */
static const HCRYPTPROV INVALID_HCRYPTPROV = (HCRYPTPROV)INVALID_HANDLE_VALUE;
static void
-release_crypt(void *p)
+release_crypt(VALUE arg)
{
- HCRYPTPROV *ptr = p;
- HCRYPTPROV prov = (HCRYPTPROV)ATOMIC_SIZE_EXCHANGE(*ptr, INVALID_HCRYPTPROV);
+ HCRYPTPROV *ptr = (void *)arg;
+ HCRYPTPROV prov = (HCRYPTPROV)ATOMIC_PTR_EXCHANGE(*ptr, INVALID_HCRYPTPROV);
if (prov && prov != INVALID_HCRYPTPROV) {
CryptReleaseContext(prov, 0);
}
@@ -585,12 +584,11 @@ fill_random_bytes_crypt(void *seed, size_t size)
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
prov = INVALID_HCRYPTPROV;
}
- old_prov = (HCRYPTPROV)ATOMIC_SIZE_CAS(perm_prov, 0, prov);
+ old_prov = (HCRYPTPROV)ATOMIC_PTR_CAS(perm_prov, 0, prov);
if (LIKELY(!old_prov)) { /* no other threads acquired */
if (prov != INVALID_HCRYPTPROV) {
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 0
- rb_gc_register_mark_object(Data_Wrap_Struct(0, 0, release_crypt, &perm_prov));
+ /* register only once; perm_prov == 0 at the first call only */
+ rb_set_end_proc(release_crypt, (VALUE)&perm_prov);
}
}
else { /* another thread acquired */
@@ -602,7 +600,7 @@ fill_random_bytes_crypt(void *seed, size_t size)
}
if (prov == INVALID_HCRYPTPROV) return -1;
while (size > 0) {
- DWORD n = (size > (size_t)DWORD_MAX) ? DWORD_MAX : (DWORD)size;
+ DWORD n = (size > (size_t)DWORD_MAX) ? DWORD_MAX/2+1 : (DWORD)size;
if (!CryptGenRandom(prov, n, seed)) return -1;
seed = (char *)seed + n;
size -= n;
@@ -617,7 +615,7 @@ static int
fill_random_bytes_bcrypt(void *seed, size_t size)
{
while (size > 0) {
- ULONG n = (size > (size_t)ULONG_MAX) ? LONG_MAX : (ULONG)size;
+ ULONG n = (size > (size_t)ULONG_MAX) ? ULONG_MAX/2+1 : (ULONG)size;
if (BCryptGenRandom(NULL, seed, n, BCRYPT_USE_SYSTEM_PREFERRED_RNG))
return -1;
seed = (char *)seed + n;
@@ -627,11 +625,17 @@ fill_random_bytes_bcrypt(void *seed, size_t size)
}
static int
-fill_random_bytes_syscall(void *seed, size_t size, int unused)
+fill_random_bytes_lib(void *seed, size_t size)
{
if (fill_random_bytes_bcrypt(seed, size) == 0) return 0;
return fill_random_bytes_crypt(seed, size);
}
+#else
+# define fill_random_bytes_lib(seed, size) -1
+#endif
+
+/* fill random bytes by dedicated syscall */
+#if 0
#elif defined HAVE_GETRANDOM
static int
fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
@@ -655,6 +659,31 @@ fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
}
return -1;
}
+#elif defined(HAVE_GETENTROPY)
+/*
+ * The Open Group Base Specifications Issue 8 - IEEE Std 1003.1-2024
+ * https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html
+ *
+ * NOTE: `getentropy`(3) on Linux is implemented using `getrandom`(2),
+ * prefer the latter over this if both are defined.
+ */
+#ifndef GETENTROPY_MAX
+# define GETENTROPY_MAX 256
+#endif
+static int
+fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
+{
+ unsigned char *p = (unsigned char *)seed;
+ while (size) {
+ size_t len = size < GETENTROPY_MAX ? size : GETENTROPY_MAX;
+ if (getentropy(p, len) != 0) {
+ return -1;
+ }
+ p += len;
+ size -= len;
+ }
+ return 0;
+}
#else
# define fill_random_bytes_syscall(seed, size, need_secure) -1
#endif
@@ -664,14 +693,13 @@ ruby_fill_random_bytes(void *seed, size_t size, int need_secure)
{
int ret = fill_random_bytes_syscall(seed, size, need_secure);
if (ret == 0) return ret;
+ if (fill_random_bytes_lib(seed, size) == 0) return 0;
return fill_random_bytes_urandom(seed, size);
}
-#define fill_random_bytes ruby_fill_random_bytes
-
/* cnt must be 4 or more */
static void
-fill_random_seed(uint32_t *seed, size_t cnt)
+fill_random_seed(uint32_t *seed, size_t cnt, bool try_bytes)
{
static rb_atomic_t n = 0;
#if defined HAVE_CLOCK_GETTIME
@@ -681,10 +709,12 @@ fill_random_seed(uint32_t *seed, size_t cnt)
#endif
size_t len = cnt * sizeof(*seed);
- memset(seed, 0, len);
-
- fill_random_bytes(seed, len, FALSE);
+ if (try_bytes) {
+ fill_random_bytes(seed, len, FALSE);
+ return;
+ }
+ memset(seed, 0, len);
#if defined HAVE_CLOCK_GETTIME
clock_gettime(CLOCK_REALTIME, &tv);
seed[0] ^= tv.tv_nsec;
@@ -719,8 +749,8 @@ make_seed_value(uint32_t *ptr, size_t len)
return seed;
}
-#define with_random_seed(size, add) \
- for (uint32_t seedbuf[(size)+(add)], loop = (fill_random_seed(seedbuf, (size)), 1); \
+#define with_random_seed(size, add, try_bytes) \
+ for (uint32_t seedbuf[(size)+(add)], loop = (fill_random_seed(seedbuf, (size), try_bytes), 1); \
loop; explicit_bzero(seedbuf, (size)*sizeof(seedbuf[0])), loop = 0)
/*
@@ -735,7 +765,7 @@ static VALUE
random_seed(VALUE _)
{
VALUE v;
- with_random_seed(DEFAULT_SEED_CNT, 1) {
+ with_random_seed(DEFAULT_SEED_CNT, 1, true) {
v = make_seed_value(seedbuf, DEFAULT_SEED_CNT);
}
return v;
@@ -802,6 +832,7 @@ rand_mt_copy(VALUE obj, VALUE orig)
mt = &rnd1->mt;
*rnd1 = *rnd2;
+ RB_OBJ_WRITTEN(obj, Qundef, rnd1->base.seed);
mt->next = mt->state + numberof(mt->state) - mt->left + 1;
return obj;
}
@@ -884,12 +915,12 @@ rand_mt_load(VALUE obj, VALUE dump)
sizeof(*mt->state), 0,
INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
x = NUM2ULONG(left);
- if (x > numberof(mt->state)) {
+ if (x > numberof(mt->state) || x == 0) {
rb_raise(rb_eArgError, "wrong value");
}
mt->left = (unsigned int)x;
mt->next = mt->state + numberof(mt->state) - x + 1;
- rnd->base.seed = rb_to_int(seed);
+ RB_OBJ_WRITE(obj, &rnd->base.seed, rb_to_int(seed));
return obj;
}
@@ -948,7 +979,7 @@ static VALUE
rb_f_srand(int argc, VALUE *argv, VALUE obj)
{
VALUE seed, old;
- rb_random_mt_t *r = rand_mt_start(default_rand());
+ rb_random_mt_t *r = default_mt();
if (rb_check_arity(argc, 0, 1) == 0) {
seed = random_seed(obj);
@@ -1093,17 +1124,18 @@ random_int32(const rb_random_interface_t *rng, rb_random_t *rnd)
unsigned int
rb_random_int32(VALUE obj)
{
- rb_random_t *rnd = try_get_rnd(obj);
+ const rb_random_interface_t *rng;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
if (!rnd) {
uint32_t x;
obj_random_bytes(obj, &x, sizeof(x));
return (unsigned int)x;
}
- return random_int32(try_rand_if(obj, rnd), rnd);
+ return random_int32(rng, rnd);
}
static double
-random_real(VALUE obj, rb_random_t *rnd, int excl)
+random_real(VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd, int excl)
{
uint32_t a, b;
@@ -1114,7 +1146,6 @@ random_real(VALUE obj, rb_random_t *rnd, int excl)
b = x[1];
}
else {
- const rb_random_interface_t *rng = try_rand_if(obj, rnd);
if (rng->get_real) return rng->get_real(rnd, excl);
a = random_int32(rng, rnd);
b = random_int32(rng, rnd);
@@ -1136,7 +1167,8 @@ rb_int_pair_to_real(uint32_t a, uint32_t b, int excl)
double
rb_random_real(VALUE obj)
{
- rb_random_t *rnd = try_get_rnd(obj);
+ const rb_random_interface_t *rng;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
if (!rnd) {
VALUE v = rb_funcallv(obj, id_rand, 0, 0);
double d = NUM2DBL(v);
@@ -1148,7 +1180,7 @@ rb_random_real(VALUE obj)
}
return d;
}
- return random_real(obj, rnd, TRUE);
+ return random_real(obj, rng, rnd, TRUE);
}
static inline VALUE
@@ -1165,7 +1197,7 @@ ulong_to_num_plus_1(unsigned long n)
}
static unsigned long
-random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit)
+random_ulong_limited(VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd, unsigned long limit)
{
if (!limit) return 0;
if (!rnd) {
@@ -1190,13 +1222,14 @@ random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit)
} while (limit < val);
return val;
}
- return limited_rand(try_rand_if(obj, rnd), rnd, limit);
+ return limited_rand(rng, rnd, limit);
}
unsigned long
rb_random_ulong_limited(VALUE obj, unsigned long limit)
{
- rb_random_t *rnd = try_get_rnd(obj);
+ const rb_random_interface_t *rng;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
if (!rnd) {
VALUE lim = ulong_to_num_plus_1(limit);
VALUE v = rb_to_int(rb_funcallv_public(obj, id_rand, 1, &lim));
@@ -1209,11 +1242,11 @@ rb_random_ulong_limited(VALUE obj, unsigned long limit)
}
return r;
}
- return limited_rand(try_rand_if(obj, rnd), rnd, limit);
+ return limited_rand(rng, rnd, limit);
}
static VALUE
-random_ulong_limited_big(VALUE obj, rb_random_t *rnd, VALUE vmax)
+random_ulong_limited_big(VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd, VALUE vmax)
{
if (!rnd) {
VALUE v, vtmp;
@@ -1238,7 +1271,7 @@ random_ulong_limited_big(VALUE obj, rb_random_t *rnd, VALUE vmax)
ALLOCV_END(vtmp);
return v;
}
- return limited_big_rand(try_rand_if(obj, rnd), rnd, vmax);
+ return limited_big_rand(rng, rnd, vmax);
}
static VALUE
@@ -1264,8 +1297,9 @@ rand_bytes(const rb_random_interface_t *rng, rb_random_t *rnd, long n)
static VALUE
random_bytes(VALUE obj, VALUE len)
{
- rb_random_t *rnd = try_get_rnd(obj);
- return rand_bytes(rb_rand_if(obj), rnd, NUM2LONG(rb_to_int(len)));
+ const rb_random_interface_t *rng = NULL;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
+ return rand_bytes(rng, rnd, NUM2LONG(rb_to_int(len)));
}
void
@@ -1294,11 +1328,12 @@ rb_rand_bytes_int32(rb_random_get_int32_func *get_int32,
VALUE
rb_random_bytes(VALUE obj, long n)
{
- rb_random_t *rnd = try_get_rnd(obj);
+ const rb_random_interface_t *rng;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
if (!rnd) {
return obj_random_bytes(obj, NULL, n);
}
- return rand_bytes(try_rand_if(obj, rnd), rnd, n);
+ return rand_bytes(rng, rnd, n);
}
/*
@@ -1310,7 +1345,7 @@ rb_random_bytes(VALUE obj, long n)
static VALUE
random_s_bytes(VALUE obj, VALUE len)
{
- rb_random_t *rnd = rand_start(default_rand());
+ rb_random_t *rnd = default_rand_start();
return rand_bytes(&random_mt_if, rnd, NUM2LONG(rb_to_int(len)));
}
@@ -1332,7 +1367,7 @@ random_s_bytes(VALUE obj, VALUE len)
static VALUE
random_s_seed(VALUE obj)
{
- rb_random_mt_t *rnd = rand_mt_start(default_rand());
+ rb_random_mt_t *rnd = default_mt();
return rnd->base.seed;
}
@@ -1350,7 +1385,7 @@ range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp)
}
static VALUE
-rand_int(VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive)
+rand_int(VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd, VALUE vmax, int restrictive)
{
/* mt must be initialized */
unsigned long r;
@@ -1362,7 +1397,7 @@ rand_int(VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive)
if (restrictive) return Qnil;
max = -max;
}
- r = random_ulong_limited(obj, rnd, (unsigned long)max - 1);
+ r = random_ulong_limited(obj, rng, rnd, (unsigned long)max - 1);
return ULONG2NUM(r);
}
else {
@@ -1376,10 +1411,10 @@ rand_int(VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive)
if (FIXNUM_P(vmax)) {
long max = FIX2LONG(vmax);
if (max == -1) return Qnil;
- r = random_ulong_limited(obj, rnd, max);
+ r = random_ulong_limited(obj, rng, rnd, max);
return LONG2NUM(r);
}
- ret = random_ulong_limited_big(obj, rnd, vmax);
+ ret = random_ulong_limited_big(obj, rng, rnd, vmax);
RB_GC_GUARD(vmax);
return ret;
}
@@ -1423,7 +1458,7 @@ float_value(VALUE v)
}
static inline VALUE
-rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
+rand_range(VALUE obj, const rb_random_interface_t *rng, rb_random_t* rnd, VALUE range)
{
VALUE beg = Qundef, end = Qundef, vmax, v;
int excl = 0;
@@ -1438,7 +1473,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
fixnum:
if (FIXNUM_P(vmax)) {
if ((max = FIX2LONG(vmax) - excl) >= 0) {
- unsigned long r = random_ulong_limited(obj, rnd, (unsigned long)max);
+ unsigned long r = random_ulong_limited(obj, rng, rnd, (unsigned long)max);
v = ULONG2NUM(r);
}
}
@@ -1448,7 +1483,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
excl = 0;
goto fixnum;
}
- v = random_ulong_limited_big(obj, rnd, vmax);
+ v = random_ulong_limited_big(obj, rng, rnd, vmax);
}
}
else if (v = rb_check_to_float(vmax), !NIL_P(v)) {
@@ -1466,7 +1501,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
}
v = Qnil;
if (max > 0.0) {
- r = random_real(obj, rnd, excl);
+ r = random_real(obj, rng, rnd, excl);
if (scale > 1) {
return rb_float_new(+(+(+(r - 0.5) * max) * scale) + mid);
}
@@ -1499,7 +1534,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
return v;
}
-static VALUE rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd);
+static VALUE rand_random(int argc, VALUE *argv, VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd);
/*
* call-seq:
@@ -1515,9 +1550,11 @@ static VALUE rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd);
* prng.rand(100) # => 42
*
* When +max+ is a Float, +rand+ returns a random floating point number
- * between 0.0 and +max+, including 0.0 and excluding +max+.
+ * between 0.0 and +max+, including 0.0 and excluding +max+. Note that it
+ * behaves differently from Kernel.rand.
*
- * prng.rand(1.5) # => 1.4600282860034115
+ * prng.rand(1.5) # => 1.4600282860034115
+ * rand(1.5) # => 0
*
* When +range+ is a Range, +rand+ returns a random number where
* <code>range.member?(number) == true</code>.
@@ -1534,24 +1571,26 @@ static VALUE rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd);
static VALUE
random_rand(int argc, VALUE *argv, VALUE obj)
{
- VALUE v = rand_random(argc, argv, obj, try_get_rnd(obj));
+ const rb_random_interface_t *rng = NULL;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
+ VALUE v = rand_random(argc, argv, obj, rng, rnd);
check_random_number(v, argv);
return v;
}
static VALUE
-rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
+rand_random(int argc, VALUE *argv, VALUE obj, const rb_random_interface_t *rng, rb_random_t *rnd)
{
VALUE vmax, v;
if (rb_check_arity(argc, 0, 1) == 0) {
- return rb_float_new(random_real(obj, rnd, TRUE));
+ return rb_float_new(random_real(obj, rng, rnd, TRUE));
}
vmax = argv[0];
if (NIL_P(vmax)) return Qnil;
if (!RB_FLOAT_TYPE_P(vmax)) {
v = rb_check_to_int(vmax);
- if (!NIL_P(v)) return rand_int(obj, rnd, v, 1);
+ if (!NIL_P(v)) return rand_int(obj, rng, rnd, v, 1);
}
v = rb_check_to_float(vmax);
if (!NIL_P(v)) {
@@ -1560,12 +1599,12 @@ rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
return Qnil;
}
else {
- double r = random_real(obj, rnd, TRUE);
+ double r = random_real(obj, rng, rnd, TRUE);
if (max > 0.0) r *= max;
return rb_float_new(r);
}
}
- return rand_range(obj, rnd, vmax);
+ return rand_range(obj, rng, rnd, vmax);
}
/*
@@ -1583,9 +1622,10 @@ rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
static VALUE
rand_random_number(int argc, VALUE *argv, VALUE obj)
{
- rb_random_t *rnd = try_get_rnd(obj);
- VALUE v = rand_random(argc, argv, obj, rnd);
- if (NIL_P(v)) v = rand_random(0, 0, obj, rnd);
+ const rb_random_interface_t *rng = NULL;
+ rb_random_t *rnd = try_get_rnd(obj, &rng);
+ VALUE v = rand_random(argc, argv, obj, rng, rnd);
+ if (NIL_P(v)) v = rand_random(0, 0, obj, rng, rnd);
else if (!v) invalid_argument(argv[0]);
return v;
}
@@ -1655,25 +1695,28 @@ rand_mt_equal(VALUE self, VALUE other)
* Kernel.srand may be used to ensure that sequences of random numbers are
* reproducible between different runs of a program.
*
- * See also Random.rand.
+ * Related: Random.rand.
+ * rand(100.0) # => 64 (Integer because max.to_i is 100)
+ * Random.rand(100.0) # => 30.315320967824523
*/
static VALUE
rb_f_rand(int argc, VALUE *argv, VALUE obj)
{
VALUE vmax;
- rb_random_t *rnd = rand_start(default_rand());
+ const rb_random_interface_t *rng = &random_mt_if;
+ rb_random_t *rnd = default_rand_start();
if (rb_check_arity(argc, 0, 1) && !NIL_P(vmax = argv[0])) {
- VALUE v = rand_range(obj, rnd, vmax);
+ VALUE v = rand_range(obj, rng, rnd, vmax);
if (v != Qfalse) return v;
vmax = rb_to_int(vmax);
if (vmax != INT2FIX(0)) {
- v = rand_int(obj, rnd, vmax, 0);
+ v = rand_int(obj, rng, rnd, vmax, 0);
if (!NIL_P(v)) return v;
}
}
- return DBL2NUM(random_real(obj, rnd, TRUE));
+ return DBL2NUM(random_real(obj, rng, rnd, TRUE));
}
/*
@@ -1689,7 +1732,7 @@ rb_f_rand(int argc, VALUE *argv, VALUE obj)
static VALUE
random_s_rand(int argc, VALUE *argv, VALUE obj)
{
- VALUE v = rand_random(argc, argv, Qnil, rand_start(default_rand()));
+ VALUE v = rand_random(argc, argv, Qnil, &random_mt_if, default_rand_start());
check_random_number(v, argv);
return v;
}
@@ -1741,8 +1784,10 @@ st_index_t
rb_memhash(const void *ptr, long len)
{
sip_uint64_t h = sip_hash13(hash_salt.key.sip, ptr, len);
-#ifdef HAVE_UINT64_T
+#if SIZEOF_ST_INDEX_T >= 8
return (st_index_t)h;
+#elif defined HAVE_UINT64_T
+ return (st_index_t)((h >> 32) ^ h);
#else
return (st_index_t)(h.u32[0] ^ h.u32[1]);
#endif
@@ -1764,7 +1809,7 @@ Init_RandomSeedCore(void)
*/
struct MT mt;
- with_random_seed(DEFAULT_SEED_CNT, 0) {
+ with_random_seed(DEFAULT_SEED_CNT, 0, false) {
init_by_array(&mt, seedbuf, DEFAULT_SEED_CNT);
}
diff --git a/range.c b/range.c
index 546c152115..041cd93f73 100644
--- a/range.c
+++ b/range.c
@@ -34,6 +34,7 @@ static ID id_beg, id_end, id_excl;
#define id_succ idSucc
#define id_min idMin
#define id_max idMax
+#define id_plus '+'
static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
@@ -46,6 +47,7 @@ static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
static void
range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
{
+ // Changing this condition has implications for JITs. If you do, please let maintainers know.
if ((!FIXNUM_P(beg) || !FIXNUM_P(end)) && !NIL_P(beg) && !NIL_P(end)) {
VALUE v;
@@ -78,7 +80,7 @@ range_modify(VALUE range)
rb_check_frozen(range);
/* Ranges are immutable, so that they should be initialized only once. */
if (RANGE_EXCL(range) != Qnil) {
- rb_name_err_raise("`initialize' called twice", range, ID2SYM(idInitialize));
+ rb_name_err_raise("'initialize' called twice", range, ID2SYM(idInitialize));
}
}
@@ -152,14 +154,14 @@ recursive_equal(VALUE range, VALUE obj, int recur)
* call-seq:
* self == other -> true or false
*
- * Returns +true+ if and only if:
+ * Returns whether all of the following are true:
*
* - +other+ is a range.
* - <tt>other.begin == self.begin</tt>.
* - <tt>other.end == self.end</tt>.
* - <tt>other.exclude_end? == self.exclude_end?</tt>.
*
- * Otherwise returns +false+.
+ * Examples:
*
* r = (1..5)
* r == (1..5) # => true
@@ -198,11 +200,10 @@ range_eq(VALUE range, VALUE obj)
static int
r_less(VALUE a, VALUE b)
{
- VALUE r = rb_funcall(a, id_cmp, 1, b);
-
- if (NIL_P(r))
- return INT_MAX;
- return rb_cmpint(r, a, b);
+ VALUE r;
+#define rb_cmpint(cmp, a, b) (NIL_P(r = (cmp)) ? INT_MAX : rb_cmpint(r, (a), (b)))
+ return OPTIMIZED_CMP(a, b);
+#undef rb_cmpint
}
static VALUE
@@ -224,8 +225,8 @@ recursive_eql(VALUE range, VALUE obj, int recur)
* Returns +true+ if and only if:
*
* - +other+ is a range.
- * - <tt>other.begin eql? self.begin</tt>.
- * - <tt>other.end eql? self.end</tt>.
+ * - <tt>other.begin.eql?(self.begin)</tt>.
+ * - <tt>other.end.eql?(self.end)</tt>.
* - <tt>other.exclude_end? == self.exclude_end?</tt>.
*
* Otherwise returns +false+.
@@ -308,6 +309,9 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg)
}
}
+// NB: Two functions below (step_i_iter, sym_step_i and step_i) are used only to maintain the
+// backward-compatible behavior for string and symbol ranges with integer steps. If that branch
+// will be removed from range_step, these two can go, too.
static bool
step_i_iter(VALUE arg)
{
@@ -400,72 +404,138 @@ range_step_size(VALUE range, VALUE args, VALUE eobj)
/*
* call-seq:
- * step(n = 1) {|element| ... } -> self
- * step(n = 1) -> enumerator
+ * step(s = 1) {|element| ... } -> self
+ * step(s = 1) -> enumerator/arithmetic_sequence
*
- * Iterates over the elements of +self+.
+ * Iterates over the elements of range in steps of +s+. The iteration is performed
+ * by <tt>+</tt> operator:
*
- * With a block given and no argument,
- * calls the block each element of the range; returns +self+:
+ * (0..6).step(2) { puts _1 } #=> 1..5
+ * # Prints: 0, 2, 4, 6
*
- * a = []
- * (1..5).step {|element| a.push(element) } # => 1..5
- * a # => [1, 2, 3, 4, 5]
- * a = []
- * ('a'..'e').step {|element| a.push(element) } # => "a".."e"
- * a # => ["a", "b", "c", "d", "e"]
+ * # Iterate between two dates in step of 1 day (24 hours)
+ * (Time.utc(2022, 2, 24)..Time.utc(2022, 3, 1)).step(24*60*60) { puts _1 }
+ * # Prints:
+ * # 2022-02-24 00:00:00 UTC
+ * # 2022-02-25 00:00:00 UTC
+ * # 2022-02-26 00:00:00 UTC
+ * # 2022-02-27 00:00:00 UTC
+ * # 2022-02-28 00:00:00 UTC
+ * # 2022-03-01 00:00:00 UTC
*
- * With a block given and a positive integer argument +n+ given,
- * calls the block with element +0+, element +n+, element <tt>2n</tt>, and so on:
+ * If <tt> + step</tt> decreases the value, iteration is still performed when
+ * step +begin+ is higher than the +end+:
*
- * a = []
- * (1..5).step(2) {|element| a.push(element) } # => 1..5
- * a # => [1, 3, 5]
- * a = []
- * ('a'..'e').step(2) {|element| a.push(element) } # => "a".."e"
- * a # => ["a", "c", "e"]
+ * (0..6).step(-2) { puts _1 }
+ * # Prints nothing
+ *
+ * (6..0).step(-2) { puts _1 }
+ * # Prints: 6, 4, 2, 0
+ *
+ * (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step(-24*60*60) { puts _1 }
+ * # Prints:
+ * # 2022-03-01 00:00:00 UTC
+ * # 2022-02-28 00:00:00 UTC
+ * # 2022-02-27 00:00:00 UTC
+ * # 2022-02-26 00:00:00 UTC
+ * # 2022-02-25 00:00:00 UTC
+ * # 2022-02-24 00:00:00 UTC
+ *
+ * When the block is not provided, and range boundaries and step are Numeric,
+ * the method returns Enumerator::ArithmeticSequence.
+ *
+ * (1..5).step(2) # => ((1..5).step(2))
+ * (1.0..).step(1.5) #=> ((1.0..).step(1.5))
+ * (..3r).step(1/3r) #=> ((..3/1).step((1/3)))
+ *
+ * Enumerator::ArithmeticSequence can be further used as a value object for iteration
+ * or slicing of collections (see Array#[]). There is a convenience method #% with
+ * behavior similar to +step+ to produce arithmetic sequences more expressively:
+ *
+ * # Same as (1..5).step(2)
+ * (1..5) % 2 # => ((1..5).%(2))
+ *
+ * In a generic case, when the block is not provided, Enumerator is returned:
+ *
+ * ('a'..).step('b') #=> #<Enumerator: "a"..:step("b")>
+ * ('a'..).step('b').take(3) #=> ["a", "ab", "abb"]
+ *
+ * If +s+ is not provided, it is considered +1+ for ranges with numeric +begin+:
+ *
+ * (1..5).step { p _1 }
+ * # Prints: 1, 2, 3, 4, 5
+ *
+ * For non-Numeric ranges, step absence is an error:
+ *
+ * (Time.utc(2022, 3, 1)..Time.utc(2022, 2, 24)).step { p _1 }
+ * # raises: step is required for non-numeric ranges (ArgumentError)
*
- * With no block given, returns an enumerator,
- * which will be of class Enumerator::ArithmeticSequence if +self+ is numeric;
- * otherwise of class Enumerator:
+ * For backward compatibility reasons, String ranges support the iteration both with
+ * string step and with integer step. In the latter case, the iteration is performed
+ * by calculating the next values with String#succ:
*
- * e = (1..5).step(2) # => ((1..5).step(2))
- * e.class # => Enumerator::ArithmeticSequence
- * ('a'..'e').step # => #<Enumerator: ...>
+ * ('a'..'e').step(2) { p _1 }
+ * # Prints: a, c, e
+ * ('a'..'e').step { p _1 }
+ * # Default step 1; prints: a, b, c, d, e
*
- * Related: Range#%.
*/
static VALUE
range_step(int argc, VALUE *argv, VALUE range)
{
- VALUE b, e, step, tmp;
+ VALUE b, e, v, step;
+ int c, dir;
b = RANGE_BEG(range);
e = RANGE_END(range);
- step = (!rb_check_arity(argc, 0, 1) ? INT2FIX(1) : argv[0]);
+ v = b;
+
+ const VALUE b_num_p = rb_obj_is_kind_of(b, rb_cNumeric);
+ const VALUE e_num_p = rb_obj_is_kind_of(e, rb_cNumeric);
+ // For backward compatibility reasons (conforming to behavior before 3.4), String/Symbol
+ // supports both old behavior ('a'..).step(1) and new behavior ('a'..).step('a')
+ // Hence the additional conversion/additional checks.
+ const VALUE str_b = rb_check_string_type(b);
+ const VALUE sym_b = SYMBOL_P(b) ? rb_sym2str(b) : Qnil;
+
+ if (rb_check_arity(argc, 0, 1))
+ step = argv[0];
+ else {
+ if (b_num_p || !NIL_P(str_b) || !NIL_P(sym_b) || (NIL_P(b) && e_num_p))
+ step = INT2FIX(1);
+ else
+ rb_raise(rb_eArgError, "step is required for non-numeric ranges");
+ }
- if (!rb_block_given_p()) {
- if (!rb_obj_is_kind_of(step, rb_cNumeric)) {
- step = rb_to_int(step);
- }
- if (rb_equal(step, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step can't be 0");
- }
+ const VALUE step_num_p = rb_obj_is_kind_of(step, rb_cNumeric);
- const VALUE b_num_p = rb_obj_is_kind_of(b, rb_cNumeric);
- const VALUE e_num_p = rb_obj_is_kind_of(e, rb_cNumeric);
- if ((b_num_p && (NIL_P(e) || e_num_p)) || (NIL_P(b) && e_num_p)) {
+ if (step_num_p && b_num_p && rb_equal(step, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be 0");
+ }
+
+ if (!rb_block_given_p()) {
+ // This code is allowed to create even beginless ArithmeticSequence, which can be useful,
+ // e.g., for array slicing:
+ // ary[(..-1) % 3]
+ if (step_num_p && ((b_num_p && (NIL_P(e) || e_num_p)) || (NIL_P(b) && e_num_p))) {
return rb_arith_seq_new(range, ID2SYM(rb_frame_this_func()), argc, argv,
range_step_size, b, e, step, EXCL(range));
}
- RETURN_SIZED_ENUMERATOR(range, argc, argv, range_step_size);
+ // ...but generic Enumerator from beginless range is useless and probably an error.
+ if (NIL_P(b)) {
+ rb_raise(rb_eArgError, "#step for non-numeric beginless ranges is meaningless");
+ }
+
+ RETURN_SIZED_ENUMERATOR(range, argc, argv, 0);
}
- step = check_step_domain(step);
- VALUE iter[2] = {INT2FIX(1), step};
+ if (NIL_P(b)) {
+ rb_raise(rb_eArgError, "#step iteration for beginless ranges is meaningless");
+ }
if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(step)) {
+ /* perform summation of numbers in C until their reach Fixnum limit */
long i = FIX2LONG(b), unit = FIX2LONG(step);
do {
rb_yield(LONG2FIX(i));
@@ -473,70 +543,102 @@ range_step(int argc, VALUE *argv, VALUE range)
} while (FIXABLE(i));
b = LONG2NUM(i);
+ /* then switch to Bignum API */
for (;; b = rb_big_plus(b, step))
rb_yield(b);
}
- else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */
+ else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) {
+ /* fixnums are special: summation is performed in C for performance */
long end = FIX2LONG(e);
long i, unit = FIX2LONG(step);
- if (!EXCL(range))
- end += 1;
- i = FIX2LONG(b);
- while (i < end) {
- rb_yield(LONG2NUM(i));
- if (i + unit < i) break;
- i += unit;
+ if (unit < 0) {
+ if (!EXCL(range))
+ end -= 1;
+ i = FIX2LONG(b);
+ while (i > end) {
+ rb_yield(LONG2NUM(i));
+ i += unit;
+ }
}
+ else {
+ if (!EXCL(range))
+ end += 1;
+ i = FIX2LONG(b);
+ while (i < end) {
+ rb_yield(LONG2NUM(i));
+ i += unit;
+ }
+ }
+ }
+ else if (b_num_p && step_num_p && ruby_float_step(b, e, step, EXCL(range), TRUE)) {
+ /* done */
+ }
+ else if (!NIL_P(str_b) && FIXNUM_P(step)) {
+ // backwards compatibility behavior for String only, when no step/Integer step is passed
+ // See discussion in https://bugs.ruby-lang.org/issues/18368
+
+ VALUE iter[2] = {INT2FIX(1), step};
+ if (NIL_P(e)) {
+ rb_str_upto_endless_each(str_b, step_i, (VALUE)iter);
+ }
+ else {
+ rb_str_upto_each(str_b, e, EXCL(range), step_i, (VALUE)iter);
+ }
}
- else if (SYMBOL_P(b) && (NIL_P(e) || SYMBOL_P(e))) { /* symbols are special */
- b = rb_sym2str(b);
+ else if (!NIL_P(sym_b) && FIXNUM_P(step)) {
+ // same as above: backward compatibility for symbols
+
+ VALUE iter[2] = {INT2FIX(1), step};
+
if (NIL_P(e)) {
- rb_str_upto_endless_each(b, sym_step_i, (VALUE)iter);
+ rb_str_upto_endless_each(sym_b, sym_step_i, (VALUE)iter);
}
else {
- rb_str_upto_each(b, rb_sym2str(e), EXCL(range), sym_step_i, (VALUE)iter);
+ rb_str_upto_each(sym_b, rb_sym2str(e), EXCL(range), sym_step_i, (VALUE)iter);
}
}
- else if (ruby_float_step(b, e, step, EXCL(range), TRUE)) {
- /* done */
+ else if (NIL_P(e)) {
+ // endless range
+ for (;; v = rb_funcall(v, id_plus, 1, step))
+ rb_yield(v);
}
- 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) ? '<' : idLE;
- VALUE v = b;
- int i = 0;
+ else if (b_num_p && step_num_p && r_less(step, INT2FIX(0)) < 0) {
+ // iterate backwards, for consistency with ArithmeticSequence
+ if (EXCL(range)) {
+ for (; r_less(e, v) < 0; v = rb_funcall(v, id_plus, 1, step))
+ rb_yield(v);
+ }
+ else {
+ for (; (c = r_less(e, v)) <= 0; v = rb_funcall(v, id_plus, 1, step)) {
+ rb_yield(v);
+ if (!c) break;
+ }
+ }
- while (NIL_P(e) || RTEST(rb_funcall(v, op, 1, e))) {
+ }
+ else if ((dir = r_less(b, e)) == 0) {
+ if (!EXCL(range)) {
rb_yield(v);
- i++;
- v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step));
}
}
- else {
- tmp = rb_check_string_type(b);
-
- if (!NIL_P(tmp)) {
- b = tmp;
- if (NIL_P(e)) {
- rb_str_upto_endless_each(b, step_i, (VALUE)iter);
- }
- else {
- rb_str_upto_each(b, e, EXCL(range), step_i, (VALUE)iter);
- }
+ else if (dir == r_less(b, rb_funcall(b, id_plus, 1, step))) {
+ // Direction of the comparison. We use it as a comparison operator in cycle:
+ // if begin < end, the cycle performs while value < end (iterating forward)
+ // if begin > end, the cycle performs while value > end (iterating backward with
+ // a negative step)
+ // One preliminary addition to check the step moves iteration in the same direction as
+ // from begin to end; otherwise, the iteration should be empty.
+ if (EXCL(range)) {
+ for (; r_less(v, e) == dir; v = rb_funcall(v, id_plus, 1, step))
+ rb_yield(v);
}
else {
- if (!discrete_object_p(b)) {
- rb_raise(rb_eTypeError, "can't iterate from %s",
- rb_obj_classname(b));
+ for (; (c = r_less(v, e)) == dir || c == 0; v = rb_funcall(v, id_plus, 1, step)) {
+ rb_yield(v);
+ if (!c) break;
}
- if (!NIL_P(e))
- range_each_func(range, step_i, (VALUE)iter);
- else
- for (;; b = rb_funcallv(b, id_succ, 0, 0))
- step_i(b, (VALUE)iter);
}
}
return range;
@@ -545,29 +647,24 @@ range_step(int argc, VALUE *argv, VALUE range)
/*
* call-seq:
* %(n) {|element| ... } -> self
- * %(n) -> enumerator
+ * %(n) -> enumerator or arithmetic_sequence
*
- * Iterates over the elements of +self+.
+ * Same as #step (but doesn't provide default value for +n+).
+ * The method is convenient for experssive producing of Enumerator::ArithmeticSequence.
*
- * With a block given, calls the block with selected elements of the range;
- * returns +self+:
+ * array = [0, 1, 2, 3, 4, 5, 6]
*
- * a = []
- * (1..5).%(2) {|element| a.push(element) } # => 1..5
- * a # => [1, 3, 5]
- * a = []
- * ('a'..'e').%(2) {|element| a.push(element) } # => "a".."e"
- * a # => ["a", "c", "e"]
- *
- * With no block given, returns an enumerator,
- * which will be of class Enumerator::ArithmeticSequence if +self+ is numeric;
- * otherwise of class Enumerator:
+ * # slice each second element:
+ * seq = (0..) % 2 #=> ((0..).%(2))
+ * array[seq] #=> [0, 2, 4, 6]
+ * # or just
+ * array[(0..) % 2] #=> [0, 2, 4, 6]
*
- * e = (1..5) % 2 # => ((1..5).%(2))
- * e.class # => Enumerator::ArithmeticSequence
- * ('a'..'e') % 2 # => #<Enumerator: ...>
+ * Note that due to operator precedence in Ruby, parentheses are mandatory around range
+ * in this case:
*
- * Related: Range#step.
+ * (0..7) % 2 #=> ((0..7).%(2)) -- as expected
+ * 0..7 % 2 #=> 0..1 -- parsed as 0..(7 % 2)
*/
static VALUE
range_percent_step(VALUE range, VALUE step)
@@ -607,6 +704,10 @@ double_as_int64(double d)
static int
is_integer_p(VALUE v)
{
+ if (rb_integer_type_p(v)) {
+ return true;
+ }
+
ID id_integer_p;
VALUE is_int;
CONST_ID(id_integer_p, "integer?");
@@ -649,27 +750,30 @@ bsearch_integer_range(VALUE beg, VALUE end, int excl)
VALUE low = rb_to_int(beg);
VALUE high = rb_to_int(end);
- VALUE mid, org_high;
+ VALUE mid;
ID id_div;
CONST_ID(id_div, "div");
- if (excl) high = rb_funcall(high, '-', 1, INT2FIX(1));
- org_high = high;
+ if (!excl) high = rb_funcall(high, '+', 1, INT2FIX(1));
+ low = rb_funcall(low, '-', 1, INT2FIX(1));
- while (rb_cmpint(rb_funcall(low, id_cmp, 1, high), low, high) < 0) {
- mid = rb_funcall(rb_funcall(high, '+', 1, low), id_div, 1, INT2FIX(2));
+ /*
+ * This loop must continue while low + 1 < high.
+ * Instead of checking low + 1 < high, check low < mid, where mid = (low + high) / 2.
+ * This is to avoid the cost of calculating low + 1 on each iteration.
+ * Note that this condition replacement is valid because Integer#div always rounds
+ * towards negative infinity.
+ */
+ while (mid = rb_funcall(rb_funcall(high, '+', 1, low), id_div, 1, INT2FIX(2)),
+ rb_cmpint(rb_funcall(low, id_cmp, 1, mid), low, mid) < 0) {
BSEARCH_CHECK(mid);
if (smaller) {
high = mid;
}
else {
- low = rb_funcall(mid, '+', 1, INT2FIX(1));
+ low = mid;
}
}
- if (rb_equal(low, org_high)) {
- BSEARCH_CHECK(low);
- if (!smaller) return Qnil;
- }
return satisfied;
}
@@ -679,7 +783,7 @@ bsearch_integer_range(VALUE beg, VALUE end, int excl)
*
* Returns an element from +self+ selected by a binary search.
*
- * See {Binary Searching}[rdoc-ref:bsearch.rdoc].
+ * See {Binary Searching}[rdoc-ref:language/bsearch.rdoc].
*
*/
@@ -696,52 +800,58 @@ range_bsearch(VALUE range)
* by the mantissa. This is true with or without implicit bit.
*
* Finding the average of two ints needs to be careful about
- * potential overflow (since float to long can use 64 bits)
- * as well as the fact that -1/2 can be 0 or -1 in C89.
+ * potential overflow (since float to long can use 64 bits).
+ *
+ * The half-open interval (low, high] indicates where the target is located.
+ * The loop continues until low and high are adjacent.
+ *
+ * -1/2 can be either 0 or -1 in C89. However, when low and high are not adjacent,
+ * the rounding direction of mid = (low + high) / 2 does not affect the result of
+ * the binary search.
*
* Note that -0.0 is mapped to the same int as 0.0 as we don't want
* (-1...0.0).bsearch to yield -0.0.
*/
-#define BSEARCH(conv) \
+#define BSEARCH(conv, excl) \
do { \
RETURN_ENUMERATOR(range, 0, 0); \
- if (EXCL(range)) high--; \
- org_high = high; \
- while (low < high) { \
+ if (!(excl)) high++; \
+ low--; \
+ while (low + 1 < high) { \
mid = ((high < 0) == (low < 0)) ? low + ((high - low) / 2) \
- : (low < -high) ? -((-1 - low - high)/2 + 1) : (low + high) / 2; \
+ : (low + high) / 2; \
BSEARCH_CHECK(conv(mid)); \
if (smaller) { \
high = mid; \
} \
else { \
- low = mid + 1; \
+ low = mid; \
} \
} \
- if (low == org_high) { \
- BSEARCH_CHECK(conv(low)); \
- if (!smaller) return Qnil; \
- } \
return satisfied; \
} while (0)
+#define BSEARCH_FIXNUM(beg, end, excl) \
+ do { \
+ long low = FIX2LONG(beg); \
+ long high = FIX2LONG(end); \
+ long mid; \
+ BSEARCH(INT2FIX, (excl)); \
+ } while (0)
beg = RANGE_BEG(range);
end = RANGE_END(range);
if (FIXNUM_P(beg) && FIXNUM_P(end)) {
- long low = FIX2LONG(beg);
- long high = FIX2LONG(end);
- long mid, org_high;
- BSEARCH(INT2FIX);
+ BSEARCH_FIXNUM(beg, end, EXCL(range));
}
#if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T)
else if (RB_FLOAT_TYPE_P(beg) || RB_FLOAT_TYPE_P(end)) {
int64_t low = double_as_int64(NIL_P(beg) ? -HUGE_VAL : RFLOAT_VALUE(rb_Float(beg)));
int64_t high = double_as_int64(NIL_P(end) ? HUGE_VAL : RFLOAT_VALUE(rb_Float(end)));
- int64_t mid, org_high;
- BSEARCH(int64_as_double_to_num);
+ int64_t mid;
+ BSEARCH(int64_as_double_to_num, EXCL(range));
}
#endif
else if (is_integer_p(beg) && is_integer_p(end)) {
@@ -755,9 +865,15 @@ range_bsearch(VALUE range)
VALUE mid = rb_funcall(beg, '+', 1, diff);
BSEARCH_CHECK(mid);
if (smaller) {
- return bsearch_integer_range(beg, mid, 0);
+ if (FIXNUM_P(beg) && FIXNUM_P(mid)) {
+ BSEARCH_FIXNUM(beg, mid, false);
+ }
+ else {
+ return bsearch_integer_range(beg, mid, false);
+ }
}
diff = rb_funcall(diff, '*', 1, LONG2FIX(2));
+ beg = mid;
}
}
else if (NIL_P(beg) && is_integer_p(end)) {
@@ -767,9 +883,15 @@ range_bsearch(VALUE range)
VALUE mid = rb_funcall(end, '+', 1, diff);
BSEARCH_CHECK(mid);
if (!smaller) {
- return bsearch_integer_range(mid, end, 0);
+ if (FIXNUM_P(mid) && FIXNUM_P(end)) {
+ BSEARCH_FIXNUM(mid, end, false);
+ }
+ else {
+ return bsearch_integer_range(mid, end, false);
+ }
}
diff = rb_funcall(diff, '*', 1, LONG2FIX(2));
+ end = mid;
}
}
else {
@@ -791,6 +913,10 @@ sym_each_i(VALUE v, VALUE arg)
return each_i(rb_str_intern(v), arg);
}
+#define CANT_ITERATE_FROM(x) \
+ rb_raise(rb_eTypeError, "can't iterate from %s", \
+ rb_obj_classname(x))
+
/*
* call-seq:
* size -> non_negative_integer or Infinity or nil
@@ -802,7 +928,12 @@ sym_each_i(VALUE v, VALUE arg)
* (1..4).size # => 4
* (1...4).size # => 3
* (1..).size # => Infinity
- * ('a'..'z').size #=> nil
+ * ('a'..'z').size # => nil
+ *
+ * If +self+ is not iterable, raises an exception:
+ *
+ * (0.5..2.5).size # TypeError
+ * (..1).size # TypeError
*
* Related: Range#count.
*/
@@ -811,7 +942,8 @@ static VALUE
range_size(VALUE range)
{
VALUE b = RANGE_BEG(range), e = RANGE_END(range);
- if (rb_obj_is_kind_of(b, rb_cNumeric)) {
+
+ if (RB_INTEGER_TYPE_P(b)) {
if (rb_obj_is_kind_of(e, rb_cNumeric)) {
return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range));
}
@@ -819,15 +951,50 @@ range_size(VALUE range)
return DBL2NUM(HUGE_VAL);
}
}
- else if (NIL_P(b)) {
+
+ if (!discrete_object_p(b)) {
+ CANT_ITERATE_FROM(b);
+ }
+
+ return Qnil;
+}
+
+static VALUE
+range_reverse_size(VALUE range)
+{
+ VALUE b = RANGE_BEG(range), e = RANGE_END(range);
+
+ if (NIL_P(e)) {
+ CANT_ITERATE_FROM(e);
+ }
+
+ if (RB_INTEGER_TYPE_P(b)) {
if (rb_obj_is_kind_of(e, rb_cNumeric)) {
+ return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range));
+ }
+ else {
+ CANT_ITERATE_FROM(e);
+ }
+ }
+
+ if (NIL_P(b)) {
+ if (RB_INTEGER_TYPE_P(e)) {
return DBL2NUM(HUGE_VAL);
}
+ else {
+ CANT_ITERATE_FROM(e);
+ }
+ }
+
+ if (!discrete_object_p(b)) {
+ CANT_ITERATE_FROM(e);
}
return Qnil;
}
+#undef CANT_ITERATE_FROM
+
/*
* call-seq:
* to_a -> array
@@ -850,12 +1017,41 @@ range_to_a(VALUE range)
return rb_call_super(0, 0);
}
+/*
+ * call-seq:
+ * to_set -> set
+ *
+ * Returns a set containing the elements in +self+, if a finite collection;
+ * raises an exception otherwise.
+ *
+ * (1..4).to_set # => Set[1, 2, 3, 4]
+ * (1...4).to_set # => Set[1, 2, 3]
+ *
+ * (1..).to_set
+ * # in 'Range#to_set': cannot convert endless range to a set (RangeError)
+ *
+ */
+static VALUE
+range_to_set(VALUE range)
+{
+ if (NIL_P(RANGE_END(range))) {
+ rb_raise(rb_eRangeError, "cannot convert endless range to a set");
+ }
+ return rb_call_super(0, NULL);
+}
+
static VALUE
range_enum_size(VALUE range, VALUE args, VALUE eobj)
{
return range_size(range);
}
+static VALUE
+range_enum_reverse_size(VALUE range, VALUE args, VALUE eobj)
+{
+ return range_reverse_size(range);
+}
+
RBIMPL_ATTR_NORETURN()
static void
range_each_bignum_endless(VALUE beg)
@@ -999,6 +1195,144 @@ range_each(VALUE range)
return range;
}
+RBIMPL_ATTR_NORETURN()
+static void
+range_reverse_each_bignum_beginless(VALUE end)
+{
+ RUBY_ASSERT(RBIGNUM_NEGATIVE_P(end));
+
+ for (;; end = rb_big_minus(end, INT2FIX(1))) {
+ rb_yield(end);
+ }
+ UNREACHABLE;
+}
+
+static void
+range_reverse_each_bignum(VALUE beg, VALUE end)
+{
+ RUBY_ASSERT(RBIGNUM_POSITIVE_P(beg) == RBIGNUM_POSITIVE_P(end));
+
+ VALUE c;
+ while ((c = rb_big_cmp(beg, end)) != INT2FIX(1)) {
+ rb_yield(end);
+ if (c == INT2FIX(0)) break;
+ end = rb_big_minus(end, INT2FIX(1));
+ }
+}
+
+static void
+range_reverse_each_positive_bignum_section(VALUE beg, VALUE end)
+{
+ RUBY_ASSERT(!NIL_P(end));
+
+ if (FIXNUM_P(end) || RBIGNUM_NEGATIVE_P(end)) return;
+
+ if (NIL_P(beg) || FIXNUM_P(beg) || RBIGNUM_NEGATIVE_P(beg)) {
+ beg = LONG2NUM(FIXNUM_MAX + 1);
+ }
+
+ range_reverse_each_bignum(beg, end);
+}
+
+static void
+range_reverse_each_fixnum_section(VALUE beg, VALUE end)
+{
+ RUBY_ASSERT(!NIL_P(end));
+
+ if (!FIXNUM_P(beg)) {
+ if (!NIL_P(beg) && RBIGNUM_POSITIVE_P(beg)) return;
+
+ beg = LONG2FIX(FIXNUM_MIN);
+ }
+
+ if (!FIXNUM_P(end)) {
+ if (RBIGNUM_NEGATIVE_P(end)) return;
+
+ end = LONG2FIX(FIXNUM_MAX);
+ }
+
+ long b = FIX2LONG(beg);
+ long e = FIX2LONG(end);
+ for (long i = e; i >= b; --i) {
+ rb_yield(LONG2FIX(i));
+ }
+}
+
+static void
+range_reverse_each_negative_bignum_section(VALUE beg, VALUE end)
+{
+ RUBY_ASSERT(!NIL_P(end));
+
+ if (FIXNUM_P(end) || RBIGNUM_POSITIVE_P(end)) {
+ end = LONG2NUM(FIXNUM_MIN - 1);
+ }
+
+ if (NIL_P(beg)) {
+ range_reverse_each_bignum_beginless(end);
+ }
+
+ if (FIXNUM_P(beg) || RBIGNUM_POSITIVE_P(beg)) return;
+
+ range_reverse_each_bignum(beg, end);
+}
+
+/*
+ * call-seq:
+ * reverse_each {|element| ... } -> self
+ * reverse_each -> an_enumerator
+ *
+ * With a block given, passes each element of +self+ to the block in reverse order:
+ *
+ * a = []
+ * (1..4).reverse_each {|element| a.push(element) } # => 1..4
+ * a # => [4, 3, 2, 1]
+ *
+ * a = []
+ * (1...4).reverse_each {|element| a.push(element) } # => 1...4
+ * a # => [3, 2, 1]
+ *
+ * With no block given, returns an enumerator.
+ *
+ */
+
+static VALUE
+range_reverse_each(VALUE range)
+{
+ RETURN_SIZED_ENUMERATOR(range, 0, 0, range_enum_reverse_size);
+
+ VALUE beg = RANGE_BEG(range);
+ VALUE end = RANGE_END(range);
+ int excl = EXCL(range);
+
+ if (NIL_P(end)) {
+ rb_raise(rb_eTypeError, "can't iterate from %s",
+ rb_obj_classname(end));
+ }
+
+ if (FIXNUM_P(beg) && FIXNUM_P(end)) {
+ if (excl) {
+ if (end == LONG2FIX(FIXNUM_MIN)) return range;
+
+ end = rb_int_minus(end, INT2FIX(1));
+ }
+
+ range_reverse_each_fixnum_section(beg, end);
+ }
+ else if ((NIL_P(beg) || RB_INTEGER_TYPE_P(beg)) && RB_INTEGER_TYPE_P(end)) {
+ if (excl) {
+ end = rb_int_minus(end, INT2FIX(1));
+ }
+ range_reverse_each_positive_bignum_section(beg, end);
+ range_reverse_each_fixnum_section(beg, end);
+ range_reverse_each_negative_bignum_section(beg, end);
+ }
+ else {
+ return rb_call_super(0, NULL);
+ }
+
+ return range;
+}
+
/*
* call-seq:
* self.begin -> object
@@ -1094,33 +1428,58 @@ range_first(int argc, VALUE *argv, VALUE range)
return ary[1];
}
+static bool
+range_basic_each_p(VALUE range)
+{
+ return rb_method_basic_definition_p(CLASS_OF(range), idEach);
+}
+
+static bool
+integer_end_optimizable(VALUE range)
+{
+ VALUE b = RANGE_BEG(range);
+ if (!NIL_P(b) && !RB_INTEGER_TYPE_P(b)) return false;
+ VALUE e = RANGE_END(range);
+ if (!RB_INTEGER_TYPE_P(e)) return false;
+ if (RB_LIKELY(range_basic_each_p(range))) return true;
+ return false;
+}
+
static VALUE
rb_int_range_last(int argc, VALUE *argv, VALUE range)
{
static const VALUE ONE = INT2FIX(1);
- VALUE b, e, len_1, len, nv, ary;
+ VALUE b, e, len_1 = Qnil, len = Qnil, nv, ary;
int x;
long n;
- assert(argc > 0);
+ RUBY_ASSERT(argc > 0);
b = RANGE_BEG(range);
e = RANGE_END(range);
- assert(RB_INTEGER_TYPE_P(b) && RB_INTEGER_TYPE_P(e));
+ RUBY_ASSERT(NIL_P(b) || RB_INTEGER_TYPE_P(b), "b=%"PRIsVALUE, rb_obj_class(b));
+ RUBY_ASSERT(RB_INTEGER_TYPE_P(e), "e=%"PRIsVALUE, rb_obj_class(e));
x = EXCL(range);
- len_1 = rb_int_minus(e, b);
- if (x) {
- e = rb_int_minus(e, ONE);
- len = len_1;
+ if (!NIL_P(b)) {
+ len_1 = rb_int_minus(e, b);
+ if (x) {
+ e = rb_int_minus(e, ONE);
+ len = len_1;
+ }
+ else {
+ len = rb_int_plus(len_1, ONE);
+ }
}
else {
- len = rb_int_plus(len_1, ONE);
+ if (x) {
+ e = rb_int_minus(e, ONE);
+ }
}
- if (FIXNUM_ZERO_P(len) || rb_num_negative_p(len)) {
+ if (!NIL_P(len) && (FIXNUM_ZERO_P(len) || rb_num_negative_p(len))) {
return rb_ary_new_capa(0);
}
@@ -1131,7 +1490,7 @@ rb_int_range_last(int argc, VALUE *argv, VALUE range)
}
nv = LONG2NUM(n);
- if (RTEST(rb_int_gt(nv, len))) {
+ if (!NIL_P(b) && RTEST(rb_int_gt(nv, len))) {
nv = len;
n = NUM2LONG(nv);
}
@@ -1185,17 +1544,11 @@ rb_int_range_last(int argc, VALUE *argv, VALUE range)
static VALUE
range_last(int argc, VALUE *argv, VALUE range)
{
- VALUE b, e;
-
if (NIL_P(RANGE_END(range))) {
rb_raise(rb_eRangeError, "cannot get the last element of endless range");
}
if (argc == 0) return RANGE_END(range);
-
- b = RANGE_BEG(range);
- e = RANGE_END(range);
- if (RB_INTEGER_TYPE_P(b) && RB_INTEGER_TYPE_P(e) &&
- RB_LIKELY(rb_method_basic_definition_p(rb_cRange, idEach))) {
+ if (integer_end_optimizable(range)) {
return rb_int_range_last(argc, argv, range);
}
return rb_ary_last(argc, argv, rb_Array(range));
@@ -1210,7 +1563,7 @@ range_last(int argc, VALUE *argv, VALUE range)
* min(n) {|a, b| ... } -> array
*
* Returns the minimum value in +self+,
- * using method <tt><=></tt> or a given block for comparison.
+ * using method <tt>#<=></tt> or a given block for comparison.
*
* With no argument and no block given,
* returns the minimum-valued element of +self+.
@@ -1318,7 +1671,7 @@ range_min(int argc, VALUE *argv, VALUE range)
* max(n) {|a, b| ... } -> array
*
* Returns the maximum value in +self+,
- * using method <tt><=></tt> or a given block for comparison.
+ * using method <tt>#<=></tt> or a given block for comparison.
*
* With no argument and no block given,
* returns the maximum-valued element of +self+.
@@ -1403,12 +1756,27 @@ range_max(int argc, VALUE *argv, VALUE range)
VALUE b = RANGE_BEG(range);
- if (rb_block_given_p() || (EXCL(range) && !nm) || argc) {
+ if (rb_block_given_p() || (EXCL(range) && !nm)) {
if (NIL_P(b)) {
rb_raise(rb_eRangeError, "cannot get the maximum of beginless range with custom comparison method");
}
return rb_call_super(argc, argv);
}
+ else if (argc) {
+ VALUE ary[2];
+ ID reverse_each;
+ CONST_ID(reverse_each, "reverse_each");
+ rb_scan_args(argc, argv, "1", &ary[0]);
+ ary[1] = rb_ary_new2(NUM2LONG(ary[0]));
+ rb_block_call(range, reverse_each, 0, 0, first_i, (VALUE)ary);
+ return ary[1];
+#if 0
+ if (integer_end_optimizable(range)) {
+ return rb_int_range_last(argc, argv, range, true);
+ }
+ return rb_ary_reverse(rb_ary_last(argc, argv, rb_Array(range)));
+#endif
+ }
else {
int c = NIL_P(b) ? -1 : OPTIMIZED_CMP(b, e);
@@ -1419,13 +1787,13 @@ range_max(int argc, VALUE *argv, VALUE range)
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
}
if (c == 0) return Qnil;
- if (!RB_INTEGER_TYPE_P(b)) {
+ if (!NIL_P(b) && !RB_INTEGER_TYPE_P(b)) {
rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
}
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}
- return rb_funcall(e, '-', 1, INT2FIX(1));
+ return rb_int_minus(e,INT2FIX(1));
}
return e;
}
@@ -1437,10 +1805,10 @@ range_max(int argc, VALUE *argv, VALUE range)
* minmax {|a, b| ... } -> [object, object]
*
* Returns a 2-element array containing the minimum and maximum value in +self+,
- * either according to comparison method <tt><=></tt> or a given block.
+ * either according to comparison method <tt>#<=></tt> or a given block.
*
* With no block given, returns the minimum and maximum values,
- * using <tt><=></tt> for comparison:
+ * using <tt>#<=></tt> for comparison:
*
* (1..4).minmax # => [1, 4]
* (1...4).minmax # => [1, 3]
@@ -1681,15 +2049,13 @@ range_inspect(VALUE range)
}
static VALUE range_include_internal(VALUE range, VALUE val);
-static VALUE range_string_cover_internal(VALUE range, VALUE val);
VALUE rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive);
/*
* call-seq:
- * self === object -> true or false
+ * self === other -> true or false
*
- * Returns +true+ if +object+ is between <tt>self.begin</tt> and <tt>self.end</tt>.
- * +false+ otherwise:
+ * Returns whether +other+ is between <tt>self.begin</tt> and <tt>self.end</tt>:
*
* (1..4) === 2 # => true
* (1..4) === 5 # => false
@@ -1726,8 +2092,6 @@ VALUE rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive);
static VALUE
range_eqq(VALUE range, VALUE val)
{
- VALUE ret = range_string_cover_internal(range, val);
- if (!UNDEF_P(ret)) return ret;
return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val);
}
@@ -1769,36 +2133,24 @@ range_include(VALUE range, VALUE val)
return rb_call_super(1, &val);
}
-static VALUE
-range_string_cover_internal(VALUE range, VALUE val)
+static inline bool
+range_integer_edge_p(VALUE beg, VALUE end)
{
- VALUE beg = RANGE_BEG(range);
- VALUE end = RANGE_END(range);
- int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
- linear_object_p(beg) || linear_object_p(end);
+ return (!NIL_P(rb_check_to_integer(beg, "to_int")) ||
+ !NIL_P(rb_check_to_integer(end, "to_int")));
+}
- if (nv ||
- !NIL_P(rb_check_to_integer(beg, "to_int")) ||
- !NIL_P(rb_check_to_integer(end, "to_int"))) {
- return r_cover_p(range, beg, end, val);
- }
- else if (RB_TYPE_P(beg, T_STRING) || RB_TYPE_P(end, T_STRING)) {
- if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING)) {
- return r_cover_p(range, beg, end, val);
- }
- if (NIL_P(beg)) {
- VALUE r = rb_funcall(val, id_cmp, 1, end);
- if (NIL_P(r)) return Qfalse;
- if (RANGE_EXCL(range)) {
- return RBOOL(rb_cmpint(r, val, end) < 0);
- }
- return RBOOL(rb_cmpint(r, val, end) <= 0);
- }
- else if (NIL_P(end)) {
- VALUE r = rb_funcall(beg, id_cmp, 1, val);
- if (NIL_P(r)) return Qfalse;
- return RBOOL(rb_cmpint(r, beg, val) <= 0);
- }
+static inline bool
+range_string_range_p(VALUE beg, VALUE end)
+{
+ return RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING);
+}
+
+static inline VALUE
+range_include_fallback(VALUE beg, VALUE end, VALUE val)
+{
+ if (NIL_P(beg) && NIL_P(end)) {
+ if (linear_object_p(val)) return Qtrue;
}
if (NIL_P(beg) || NIL_P(end)) {
@@ -1816,20 +2168,14 @@ range_include_internal(VALUE range, VALUE val)
int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
linear_object_p(beg) || linear_object_p(end);
- if (nv ||
- !NIL_P(rb_check_to_integer(beg, "to_int")) ||
- !NIL_P(rb_check_to_integer(end, "to_int"))) {
+ if (nv || range_integer_edge_p(beg, end)) {
return r_cover_p(range, beg, end, val);
}
- else if (RB_TYPE_P(beg, T_STRING) && RB_TYPE_P(end, T_STRING)) {
+ else if (range_string_range_p(beg, end)) {
return rb_str_include_range_p(beg, end, val, RANGE_EXCL(range));
}
- if (NIL_P(beg) || NIL_P(end)) {
- rb_raise(rb_eTypeError, "cannot determine inclusion in beginless/endless ranges");
- }
-
- return Qundef;
+ return range_include_fallback(beg, end, val);
}
static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
@@ -1856,7 +2202,7 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* r.cover?(0) # => false
* r.cover?(5) # => false
* r.cover?('foo') # => false
-
+ *
* r = ('a'..'d')
* r.cover?('a') # => true
* r.cover?('d') # => true
@@ -1877,7 +2223,7 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* r.cover?(0) # => false
* r.cover?(4) # => false
* r.cover?('foo') # => false
-
+ *
* r = ('a'...'d')
* r.cover?('a') # => true
* r.cover?('c') # => true
@@ -1893,7 +2239,7 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* r.cover?(0..4) # => false
* r.cover?(1..5) # => false
* r.cover?('a'..'d') # => false
-
+ *
* r = (1...4)
* r.cover?(1..3) # => true
* r.cover?(1..4) # => false
@@ -1911,7 +2257,7 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* Returns +false+ if either:
*
* - The begin value of +self+ is larger than its end value.
- * - An internal call to <tt><=></tt> returns +nil+;
+ * - An internal call to <tt>#<=></tt> returns +nil+;
* that is, the operands are not comparable.
*
* Beginless ranges cover all values of the same type before the end,
@@ -2115,17 +2461,137 @@ range_count(int argc, VALUE *argv, VALUE range)
* Infinity. Just let it loop. */
return rb_call_super(argc, argv);
}
- else if (NIL_P(RANGE_END(range))) {
+
+ VALUE beg = RANGE_BEG(range), end = RANGE_END(range);
+
+ if (NIL_P(beg) || NIL_P(end)) {
/* We are confident that the answer is Infinity. */
return DBL2NUM(HUGE_VAL);
}
- else if (NIL_P(RANGE_BEG(range))) {
- /* We are confident that the answer is Infinity. */
- return DBL2NUM(HUGE_VAL);
+
+ if (is_integer_p(beg)) {
+ VALUE size = range_size(range);
+ if (!NIL_P(size)) {
+ return size;
+ }
}
- else {
- return rb_call_super(argc, argv);
+
+ return rb_call_super(argc, argv);
+}
+
+static bool
+empty_region_p(VALUE beg, VALUE end, int excl)
+{
+ if (NIL_P(beg)) return false;
+ if (NIL_P(end)) return false;
+ int less = r_less(beg, end);
+ /* empty range */
+ if (less > 0) return true;
+ if (excl && less == 0) return true;
+ return false;
+}
+
+/*
+ * call-seq:
+ * overlap?(range) -> true or false
+ *
+ * Returns +true+ if +range+ overlaps with +self+, +false+ otherwise:
+ *
+ * (0..2).overlap?(1..3) #=> true
+ * (0..2).overlap?(3..4) #=> false
+ * (0..).overlap?(..0) #=> true
+ *
+ * With non-range argument, raises TypeError.
+ *
+ * (1..3).overlap?(1) # TypeError
+ *
+ * Returns +false+ if an internal call to <tt>#<=></tt> returns +nil+;
+ * that is, the operands are not comparable.
+ *
+ * (1..3).overlap?('a'..'d') # => false
+ *
+ * Returns +false+ if +self+ or +range+ is empty. "Empty range" means
+ * that its begin value is larger than, or equal for an exclusive
+ * range, its end value.
+ *
+ * (4..1).overlap?(2..3) # => false
+ * (4..1).overlap?(..3) # => false
+ * (4..1).overlap?(2..) # => false
+ * (2...2).overlap?(1..2) # => false
+ *
+ * (1..4).overlap?(3..2) # => false
+ * (..4).overlap?(3..2) # => false
+ * (1..).overlap?(3..2) # => false
+ * (1..2).overlap?(2...2) # => false
+ *
+ * Returns +false+ if the begin value one of +self+ and +range+ is
+ * larger than, or equal if the other is an exclusive range, the end
+ * value of the other:
+ *
+ * (4..5).overlap?(2..3) # => false
+ * (4..5).overlap?(2...4) # => false
+ *
+ * (1..2).overlap?(3..4) # => false
+ * (1...3).overlap?(3..4) # => false
+ *
+ * Returns +false+ if the end value one of +self+ and +range+ is
+ * larger than, or equal for an exclusive range, the end value of the
+ * other:
+ *
+ * (4..5).overlap?(2..3) # => false
+ * (4..5).overlap?(2...4) # => false
+ *
+ * (1..2).overlap?(3..4) # => false
+ * (1...3).overlap?(3..4) # => false
+ *
+ * Note that the method wouldn't make any assumptions about the beginless
+ * range being actually empty, even if its upper bound is the minimum
+ * possible value of its type, so all this would return +true+:
+ *
+ * (...-Float::INFINITY).overlap?(...-Float::INFINITY) # => true
+ * (..."").overlap?(..."") # => true
+ * (...[]).overlap?(...[]) # => true
+ *
+ * Even if those ranges are effectively empty (no number can be smaller than
+ * <tt>-Float::INFINITY</tt>), they are still considered overlapping
+ * with themselves.
+ *
+ * Related: Range#cover?.
+ */
+
+static VALUE
+range_overlap(VALUE range, VALUE other)
+{
+ if (!rb_obj_is_kind_of(other, rb_cRange)) {
+ rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Range)",
+ rb_class_name(rb_obj_class(other)));
}
+
+ VALUE self_beg = RANGE_BEG(range);
+ VALUE self_end = RANGE_END(range);
+ int self_excl = EXCL(range);
+ VALUE other_beg = RANGE_BEG(other);
+ VALUE other_end = RANGE_END(other);
+ int other_excl = EXCL(other);
+
+ if (empty_region_p(self_beg, other_end, other_excl)) return Qfalse;
+ if (empty_region_p(other_beg, self_end, self_excl)) return Qfalse;
+
+ if (!NIL_P(self_beg) && !NIL_P(other_beg)) {
+ VALUE cmp = rb_funcall(self_beg, id_cmp, 1, other_beg);
+ if (NIL_P(cmp)) return Qfalse;
+ /* if both begin values are equal, no more comparisons needed */
+ if (rb_cmpint(cmp, self_beg, other_beg) == 0) return Qtrue;
+ }
+ else if (NIL_P(self_beg) && !NIL_P(self_end) && NIL_P(other_beg) && !NIL_P(other_end)) {
+ VALUE cmp = rb_funcall(self_end, id_cmp, 1, other_end);
+ return RBOOL(!NIL_P(cmp));
+ }
+
+ if (empty_region_p(self_beg, self_end, self_excl)) return Qfalse;
+ if (empty_region_p(other_beg, other_end, other_excl)) return Qfalse;
+
+ return Qtrue;
}
/* A \Range object represents a collection of values
@@ -2142,14 +2608,14 @@ range_count(int argc, VALUE *argv, VALUE range)
* (1...4).to_a # => [1, 2, 3]
* ('a'...'d').to_a # => ["a", "b", "c"]
*
- * A range may be created using method Range.new:
+ * - Method Range.new:
*
- * # Ranges that by default include the given end value.
- * Range.new(1, 4).to_a # => [1, 2, 3, 4]
- * Range.new('a', 'd').to_a # => ["a", "b", "c", "d"]
- * # Ranges that use third argument +exclude_end+ to exclude the given end value.
- * Range.new(1, 4, true).to_a # => [1, 2, 3]
- * Range.new('a', 'd', true).to_a # => ["a", "b", "c"]
+ * # Ranges that by default include the given end value.
+ * Range.new(1, 4).to_a # => [1, 2, 3, 4]
+ * Range.new('a', 'd').to_a # => ["a", "b", "c", "d"]
+ * # Ranges that use third argument +exclude_end+ to exclude the given end value.
+ * Range.new(1, 4, true).to_a # => [1, 2, 3]
+ * Range.new('a', 'd', true).to_a # => ["a", "b", "c"]
*
* == Beginless Ranges
*
@@ -2170,10 +2636,14 @@ range_count(int argc, VALUE *argv, VALUE range)
* A beginless range may be used to slice an array:
*
* a = [1, 2, 3, 4]
- * r = (..2) # => nil...2
- * a[r] # => [1, 2]
+ * # Include the third array element in the slice
+ * r = (..2) # => nil..2
+ * a[r] # => [1, 2, 3]
+ * # Exclude the third array element from the slice
+ * r = (...2) # => nil...2
+ * a[r] # => [1, 2]
*
- * \Method +each+ for a beginless range raises an exception.
+ * Method +each+ for a beginless range raises an exception.
*
* == Endless Ranges
*
@@ -2203,7 +2673,7 @@ range_count(int argc, VALUE *argv, VALUE range)
* r = (2..) # => 2..
* a[r] # => [3, 4]
*
- * \Method +each+ for an endless range calls the given block indefinitely:
+ * Method +each+ for an endless range calls the given block indefinitely:
*
* a = []
* r = (1..)
@@ -2213,19 +2683,19 @@ range_count(int argc, VALUE *argv, VALUE range)
* end
* a # => [2, 4, 6, 8, 10]
*
- * A range can be both beginless and endless. For literal beginless, endless
+ * A range can be both beginless and endless. For literal beginless, endless
* ranges, at least the beginning or end of the range must be given as an
* explicit nil value. It is recommended to use an explicit nil beginning and
- * implicit nil end, since that is what Ruby uses for Range#inspect:
+ * end, since that is what Ruby uses for Range#inspect:
*
- * (nil..) # => (nil..)
- * (..nil) # => (nil..)
- * (nil..nil) # => (nil..)
+ * (nil..) # => (nil..nil)
+ * (..nil) # => (nil..nil)
+ * (nil..nil) # => (nil..nil)
*
* == Ranges and Other Classes
*
* An object may be put into a range if its class implements
- * instance method <tt><=></tt>.
+ * instance method <tt>#<=></tt>.
* Ruby core classes that do so include Array, Complex, File::Stat,
* Float, Integer, Kernel, Module, Numeric, Rational, String, Symbol, and Time.
*
@@ -2257,15 +2727,15 @@ range_count(int argc, VALUE *argv, VALUE range)
* == Ranges and User-Defined Classes
*
* A user-defined class that is to be used in a range
- * must implement instance <tt><=></tt>;
+ * must implement instance method <tt>#<=></tt>;
* see Integer#<=>.
* To make iteration available, it must also implement
* instance method +succ+; see Integer#succ.
*
- * The class below implements both <tt><=></tt> and +succ+,
+ * The class below implements both <tt>#<=></tt> and +succ+,
* and so can be used both to construct ranges and to iterate over them.
* Note that the Comparable module is included
- * so the <tt>==</tt> method is defined in terms of <tt><=></tt>.
+ * so the <tt>==</tt> method is defined in terms of <tt>#<=></tt>.
*
* # Represent a string of 'X' characters.
* class Xs
@@ -2295,10 +2765,10 @@ range_count(int argc, VALUE *argv, VALUE range)
*
* == What's Here
*
- * First, what's elsewhere. \Class \Range:
+ * First, what's elsewhere. Class \Range:
*
- * - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
- * - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+ * - Inherits from {class Object}[rdoc-ref:Object@Whats+Here].
+ * - Includes {module Enumerable}[rdoc-ref:Enumerable@Whats+Here],
* which provides dozens of additional methods.
*
* Here, class \Range provides methods that are useful for:
@@ -2308,6 +2778,7 @@ range_count(int argc, VALUE *argv, VALUE range)
* - {Comparing}[rdoc-ref:Range@Methods+for+Comparing]
* - {Iterating}[rdoc-ref:Range@Methods+for+Iterating]
* - {Converting}[rdoc-ref:Range@Methods+for+Converting]
+ * - {Methods for Working with JSON}[rdoc-ref:Range@Methods+for+Working+with+JSON]
*
* === Methods for Creating a \Range
*
@@ -2342,7 +2813,7 @@ range_count(int argc, VALUE *argv, VALUE range)
* - #%: Requires argument +n+; calls the block with each +n+-th element of +self+.
* - #each: Calls the block with each element of +self+.
* - #step: Takes optional argument +n+ (defaults to 1);
- calls the block with each +n+-th element of +self+.
+ * calls the block with each +n+-th element of +self+.
*
* === Methods for Converting
*
@@ -2350,6 +2821,16 @@ range_count(int argc, VALUE *argv, VALUE range)
* - #to_a (aliased as #entries): Returns elements of +self+ in an array.
* - #to_s: Returns a string representation of +self+ (uses #to_s).
*
+ * === Methods for Working with \JSON
+ *
+ * - ::json_create: Returns a new \Range object constructed from the given object.
+ * - #as_json: Returns a 2-element hash representing +self+.
+ * - #to_json: Returns a \JSON string representing +self+.
+ *
+ * To make these methods available:
+ *
+ * require 'json/add/range'
+ *
*/
void
@@ -2374,6 +2855,7 @@ Init_Range(void)
rb_define_method(rb_cRange, "each", range_each, 0);
rb_define_method(rb_cRange, "step", range_step, -1);
rb_define_method(rb_cRange, "%", range_percent_step, 1);
+ rb_define_method(rb_cRange, "reverse_each", range_reverse_each, 0);
rb_define_method(rb_cRange, "bsearch", range_bsearch, 0);
rb_define_method(rb_cRange, "begin", range_begin, 0);
rb_define_method(rb_cRange, "end", range_end, 0);
@@ -2384,6 +2866,7 @@ Init_Range(void)
rb_define_method(rb_cRange, "minmax", range_minmax, 0);
rb_define_method(rb_cRange, "size", range_size, 0);
rb_define_method(rb_cRange, "to_a", range_to_a, 0);
+ rb_define_method(rb_cRange, "to_set", range_to_set, 0);
rb_define_method(rb_cRange, "entries", range_to_a, 0);
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
@@ -2394,4 +2877,5 @@ Init_Range(void)
rb_define_method(rb_cRange, "include?", range_include, 1);
rb_define_method(rb_cRange, "cover?", range_cover, 1);
rb_define_method(rb_cRange, "count", range_count, -1);
+ rb_define_method(rb_cRange, "overlap?", range_overlap, 1);
}
diff --git a/rational.c b/rational.c
index 58786b58ba..b031838d69 100644
--- a/rational.c
+++ b/rational.c
@@ -22,20 +22,27 @@
# define USE_GMP 0
#endif
#endif
-#if USE_GMP
-#include <gmp.h>
-#endif
#include "id.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/complex.h"
+#include "internal/error.h"
#include "internal/gc.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
#include "ruby_assert.h"
+#if USE_GMP
+RBIMPL_WARNING_PUSH()
+# ifdef _MSC_VER
+RBIMPL_WARNING_IGNORED(4146) /* for mpn_neg() */
+# endif
+# include <gmp.h>
+RBIMPL_WARNING_POP()
+#endif
+
#define ZERO INT2FIX(0)
#define ONE INT2FIX(1)
#define TWO INT2FIX(2)
@@ -169,22 +176,6 @@ f_idiv(VALUE x, VALUE y)
#define f_expt10(x) rb_int_pow(INT2FIX(10), x)
inline static int
-f_zero_p(VALUE x)
-{
- if (RB_INTEGER_TYPE_P(x)) {
- return FIXNUM_ZERO_P(x);
- }
- else if (RB_TYPE_P(x, T_RATIONAL)) {
- VALUE num = RRATIONAL(x)->num;
-
- return FIXNUM_ZERO_P(num);
- }
- return (int)rb_equal(x, ZERO);
-}
-
-#define f_nonzero_p(x) (!f_zero_p(x))
-
-inline static int
f_one_p(VALUE x)
{
if (RB_INTEGER_TYPE_P(x)) {
@@ -389,8 +380,8 @@ f_gcd(VALUE x, VALUE y)
{
VALUE r = f_gcd_orig(x, y);
if (f_nonzero_p(r)) {
- assert(f_zero_p(f_mod(x, r)));
- assert(f_zero_p(f_mod(y, r)));
+ RUBY_ASSERT(f_zero_p(f_mod(x, r)));
+ RUBY_ASSERT(f_zero_p(f_mod(y, r)));
}
return r;
}
@@ -413,11 +404,11 @@ f_lcm(VALUE x, VALUE y)
inline static VALUE
nurat_s_new_internal(VALUE klass, VALUE num, VALUE den)
{
- NEWOBJ_OF(obj, struct RRational, klass, T_RATIONAL | (RGENGC_WB_PROTECTED_RATIONAL ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(obj, struct RRational, klass, T_RATIONAL, sizeof(struct RRational));
RATIONAL_SET_NUM((VALUE)obj, num);
RATIONAL_SET_DEN((VALUE)obj, den);
- OBJ_FREEZE_RAW((VALUE)obj);
+ OBJ_FREEZE((VALUE)obj);
return (VALUE)obj;
}
@@ -455,8 +446,8 @@ nurat_int_value(VALUE num)
static void
nurat_canonicalize(VALUE *num, VALUE *den)
{
- assert(num); assert(RB_INTEGER_TYPE_P(*num));
- assert(den); assert(RB_INTEGER_TYPE_P(*den));
+ RUBY_ASSERT(num); RUBY_ASSERT(RB_INTEGER_TYPE_P(*num));
+ RUBY_ASSERT(den); RUBY_ASSERT(RB_INTEGER_TYPE_P(*den));
if (INT_NEGATIVE_P(*den)) {
*num = rb_int_uminus(*num);
*den = rb_int_uminus(*den);
@@ -496,16 +487,16 @@ nurat_s_canonicalize_internal_no_reduce(VALUE klass, VALUE num, VALUE den)
inline static VALUE
f_rational_new2(VALUE klass, VALUE x, VALUE y)
{
- assert(!k_rational_p(x));
- assert(!k_rational_p(y));
+ RUBY_ASSERT(!k_rational_p(x));
+ RUBY_ASSERT(!k_rational_p(y));
return nurat_s_canonicalize_internal(klass, x, y);
}
inline static VALUE
f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y)
{
- assert(!k_rational_p(x));
- assert(!k_rational_p(y));
+ RUBY_ASSERT(!k_rational_p(x));
+ RUBY_ASSERT(!k_rational_p(y));
return nurat_s_canonicalize_internal_no_reduce(klass, x, y);
}
@@ -602,14 +593,18 @@ nurat_denominator(VALUE self)
/*
* call-seq:
- * -rat -> rational
+ * -self -> rational
+ *
+ * Returns +self+, negated:
+ *
+ * -(1/3r) # => (-1/3)
+ * -(-1/3r) # => (1/3)
*
- * Negates +rat+.
*/
VALUE
rb_rational_uminus(VALUE self)
{
- const int unused = (assert(RB_TYPE_P(self, T_RATIONAL)), 0);
+ const int unused = (RUBY_ASSERT(RB_TYPE_P(self, T_RATIONAL)), 0);
get_dat1(self);
(void)unused;
return f_rational_new2(CLASS_OF(self), rb_int_uminus(dat->num), dat->den);
@@ -645,7 +640,7 @@ inline static VALUE
f_imul(long x, long y)
{
VALUE r = f_imul_orig(x, y);
- assert(f_eqeq_p(r, f_mul(LONG2NUM(x), LONG2NUM(y))));
+ RUBY_ASSERT(f_eqeq_p(r, f_mul(LONG2NUM(x), LONG2NUM(y))));
return r;
}
#endif
@@ -708,16 +703,27 @@ f_addsub(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
static double nurat_to_double(VALUE self);
/*
- * call-seq:
- * rat + numeric -> numeric
+ * call-seq:
+ * self + other -> numeric
+ *
+ * Returns the sum of +self+ and +other+:
+ *
+ * Rational(2, 3) + 0 # => (2/3)
+ * Rational(2, 3) + 1 # => (5/3)
+ * Rational(2, 3) + -1 # => (-1/3)
*
- * Performs addition.
+ * Rational(2, 3) + Complex(1, 0) # => ((5/3)+0i)
+ *
+ * Rational(2, 3) + Rational(1, 1) # => (5/3)
+ * Rational(2, 3) + Rational(3, 2) # => (13/6)
+ * Rational(2, 3) + Rational(3.0, 2.0) # => (13/6)
+ * Rational(2, 3) + Rational(3.1, 2.1) # => (30399297484750849/14186338826217063)
+ *
+ * For a computation involving Floats, the result may be inexact (see Float#+):
+ *
+ * Rational(2, 3) + 1.0 # => 1.6666666666666665
+ * Rational(2, 3) + Complex(1.0, 0.0) # => (1.6666666666666665+0.0i)
*
- * Rational(2, 3) + Rational(2, 3) #=> (4/3)
- * Rational(900) + Rational(1) #=> (901/1)
- * Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
- * Rational(9, 8) + 4 #=> (41/8)
- * Rational(20, 9) + 9.8 #=> 12.022222222222222
*/
VALUE
rb_rational_plus(VALUE self, VALUE other)
@@ -750,9 +756,9 @@ rb_rational_plus(VALUE self, VALUE other)
/*
* call-seq:
- * rat - numeric -> numeric
+ * self - other -> numeric
*
- * Performs subtraction.
+ * Returns the difference of +self+ and +other+:
*
* Rational(2, 3) - Rational(2, 3) #=> (0/1)
* Rational(900) - Rational(1) #=> (899/1)
@@ -794,7 +800,7 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
{
VALUE num, den;
- assert(RB_TYPE_P(self, T_RATIONAL));
+ RUBY_ASSERT(RB_TYPE_P(self, T_RATIONAL));
/* Integer#** can return Rational with Float right now */
if (RB_FLOAT_TYPE_P(anum) || RB_FLOAT_TYPE_P(aden) ||
@@ -805,10 +811,10 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
return DBL2NUM(x);
}
- assert(RB_INTEGER_TYPE_P(anum));
- assert(RB_INTEGER_TYPE_P(aden));
- assert(RB_INTEGER_TYPE_P(bnum));
- assert(RB_INTEGER_TYPE_P(bden));
+ RUBY_ASSERT(RB_INTEGER_TYPE_P(anum));
+ RUBY_ASSERT(RB_INTEGER_TYPE_P(aden));
+ RUBY_ASSERT(RB_INTEGER_TYPE_P(bnum));
+ RUBY_ASSERT(RB_INTEGER_TYPE_P(bden));
if (k == '/') {
VALUE t;
@@ -846,15 +852,17 @@ f_muldiv(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
/*
* call-seq:
- * rat * numeric -> numeric
+ * self * other -> numeric
*
- * Performs multiplication.
+ * Returns the numeric product of +self+ and +other+:
+ *
+ * Rational(9, 8) * 4 #=> (9/2)
+ * Rational(20, 9) * 9.8 #=> 21.77777777777778
+ * Rational(9, 8) * Complex(1, 2) # => ((9/8)+(9/4)*i)
+ * Rational(2, 3) * Rational(2, 3) #=> (4/9)
+ * Rational(900) * Rational(1) #=> (900/1)
+ * Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
*
- * Rational(2, 3) * Rational(2, 3) #=> (4/9)
- * Rational(900) * Rational(1) #=> (900/1)
- * Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
- * Rational(9, 8) * 4 #=> (9/2)
- * Rational(20, 9) * 9.8 #=> 21.77777777777778
*/
VALUE
rb_rational_mul(VALUE self, VALUE other)
@@ -887,10 +895,9 @@ rb_rational_mul(VALUE self, VALUE other)
/*
* call-seq:
- * rat / numeric -> numeric
- * rat.quo(numeric) -> numeric
+ * self / other -> numeric
*
- * Performs division.
+ * Returns the quotient of +self+ and +other+:
*
* Rational(2, 3) / Rational(2, 3) #=> (1/1)
* Rational(900) / Rational(1) #=> (900/1)
@@ -946,8 +953,8 @@ rb_rational_div(VALUE self, VALUE other)
* Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333
* Rational(2).fdiv(3) #=> 0.6666666666666666
*/
-static VALUE
-nurat_fdiv(VALUE self, VALUE other)
+VALUE
+rb_rational_fdiv(VALUE self, VALUE other)
{
VALUE div;
if (f_zero_p(other))
@@ -964,9 +971,9 @@ nurat_fdiv(VALUE self, VALUE other)
/*
* call-seq:
- * rat ** numeric -> numeric
+ * self ** exponent -> numeric
*
- * Performs exponentiation.
+ * Returns +self+ raised to the power +exponent+:
*
* Rational(2) ** Rational(3) #=> (8/1)
* Rational(10) ** -2 #=> (1/100)
@@ -1041,8 +1048,7 @@ rb_rational_pow(VALUE self, VALUE other)
}
}
else if (RB_BIGNUM_TYPE_P(other)) {
- rb_warn("in a**b, b may be too big");
- return rb_float_pow(nurat_to_f(self), other);
+ rb_raise(rb_eArgError, "exponent is too large");
}
else if (RB_FLOAT_TYPE_P(other) || RB_TYPE_P(other, T_RATIONAL)) {
return rb_float_pow(nurat_to_f(self), other);
@@ -1055,20 +1061,30 @@ rb_rational_pow(VALUE self, VALUE other)
/*
* call-seq:
- * rational <=> numeric -> -1, 0, +1, or nil
+ * self <=> other -> -1, 0, 1, or nil
+ *
+ * Compares +self+ and +other+.
+ *
+ * Returns:
*
- * Returns -1, 0, or +1 depending on whether +rational+ is
- * less than, equal to, or greater than +numeric+.
+ * - +-1+, if +self+ is less than +other+.
+ * - +0+, if the two values are the same.
+ * - +1+, if +self+ is greater than +other+.
+ * - +nil+, if the two values are incomparable.
*
- * +nil+ is returned if the two values are incomparable.
+ * Examples:
*
- * Rational(2, 3) <=> Rational(2, 3) #=> 0
- * Rational(5) <=> 5 #=> 0
- * Rational(2, 3) <=> Rational(1, 3) #=> 1
- * Rational(1, 3) <=> 1 #=> -1
- * Rational(1, 3) <=> 0.3 #=> 1
+ * Rational(2, 3) <=> Rational(4, 3) # => -1
+ * Rational(2, 1) <=> Rational(2, 1) # => 0
+ * Rational(2, 1) <=> 2 # => 0
+ * Rational(2, 1) <=> 2.0 # => 0
+ * Rational(2, 1) <=> Complex(2, 0) # => 0
+ * Rational(4, 3) <=> Rational(2, 3) # => 1
+ * Rational(4, 3) <=> :foo # => nil
+ *
+ * \Class \Rational includes module Comparable,
+ * each of whose methods uses Rational#<=> for comparison.
*
- * Rational(1, 3) <=> "0.3" #=> nil
*/
VALUE
rb_rational_cmp(VALUE self, VALUE other)
@@ -1113,9 +1129,9 @@ rb_rational_cmp(VALUE self, VALUE other)
/*
* call-seq:
- * rat == object -> true or false
+ * self == other -> true or false
*
- * Returns +true+ if +rat+ equals +object+ numerically.
+ * Returns whether +self+ and +other+ are numerically equal:
*
* Rational(2, 3) == Rational(2, 3) #=> true
* Rational(5) == 5 #=> true
@@ -1358,10 +1374,12 @@ nurat_round_half_even(VALUE self)
return num;
}
+static VALUE f_round_n(VALUE self, VALUE n, VALUE (*func)(VALUE)) ;
+
static VALUE
f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
{
- VALUE n, b, s;
+ VALUE n;
if (rb_check_arity(argc, 0, 1) == 0)
return (*func)(self);
@@ -1371,6 +1389,14 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
if (!k_integer_p(n))
rb_raise(rb_eTypeError, "not an integer");
+ return f_round_n(self, n, func);
+}
+
+static VALUE
+f_round_n(VALUE self, VALUE n, VALUE (*func)(VALUE))
+{
+ VALUE b, s;
+
b = f_expt10(n);
s = rb_rational_mul(self, b);
@@ -1401,8 +1427,7 @@ rb_rational_floor(VALUE self, int ndigits)
return nurat_floor(self);
}
else {
- VALUE n = INT2NUM(ndigits);
- return f_round_common(1, &n, self, nurat_floor);
+ return f_round_n(self, INT2NUM(ndigits), nurat_floor);
}
}
@@ -1545,9 +1570,22 @@ nurat_round_n(int argc, VALUE *argv, VALUE self)
}
VALUE
-rb_flo_round_by_rational(int argc, VALUE *argv, VALUE num)
+rb_flo_round_by_rational(VALUE num, int ndigits, enum ruby_num_rounding_mode mode)
+{
+ VALUE (*round_func)(VALUE) = ROUND_FUNC(mode, nurat_round);
+ return nurat_to_f(f_round_n(float_to_r(num), INT2NUM(ndigits), round_func));
+}
+
+VALUE
+rb_flo_ceil_by_rational(VALUE num, int ndigits)
+{
+ return nurat_to_f(f_round_n(float_to_r(num), INT2NUM(ndigits), nurat_ceil));
+}
+
+VALUE
+rb_flo_floor_by_rational(VALUE num, int ndigits)
{
- return nurat_to_f(nurat_round_n(argc, argv, float_to_r(num)));
+ return nurat_to_f(f_round_n(float_to_r(num), INT2NUM(ndigits), nurat_floor));
}
static double
@@ -1846,7 +1884,7 @@ nurat_loader(VALUE self, VALUE a)
nurat_canonicalize(&num, &den);
RATIONAL_SET_NUM((VALUE)dat, num);
RATIONAL_SET_DEN((VALUE)dat, den);
- OBJ_FREEZE_RAW(self);
+ OBJ_FREEZE(self);
return self;
}
@@ -2103,39 +2141,6 @@ rb_float_denominator(VALUE self)
/*
* call-seq:
- * to_r -> (0/1)
- *
- * Returns zero as a Rational:
- *
- * nil.to_r # => (0/1)
- *
- */
-static VALUE
-nilclass_to_r(VALUE self)
-{
- return rb_rational_new1(INT2FIX(0));
-}
-
-/*
- * call-seq:
- * rationalize(eps = nil) -> (0/1)
- *
- * Returns zero as a Rational:
- *
- * nil.rationalize # => (0/1)
- *
- * Argument +eps+ is ignored.
- *
- */
-static VALUE
-nilclass_rationalize(int argc, VALUE *argv, VALUE self)
-{
- rb_check_arity(argc, 0, 1);
- return nilclass_to_r(self);
-}
-
-/*
- * call-seq:
* int.to_r -> rational
*
* Returns the value as a rational.
@@ -2321,6 +2326,12 @@ islettere(int c)
return (c == 'e' || c == 'E');
}
+inline static int
+isletterr(int c)
+{
+ return (c == 'r' || c == 'R');
+}
+
static VALUE
negate_num(VALUE num)
{
@@ -2370,7 +2381,13 @@ read_num(const char **s, const char *const end, VALUE *num, VALUE *nexp)
ok = 1;
}
- if (ok && *s + 1 < end && islettere(**s)) {
+ if (!ok || *s >= end) {
+ /* failed or finish */
+ }
+ else if (isletterr(**s)) {
+ (*s)++;
+ }
+ else if (*s + 1 < end && islettere(**s)) {
(*s)++;
expsign = read_sign(s, end);
exp = rb_int_parse_cstr(*s, end-*s, &e, NULL,
@@ -2494,31 +2511,32 @@ string_to_r_strict(VALUE self, int raise)
/*
* call-seq:
- * str.to_r -> rational
- *
- * Returns the result of interpreting leading characters in +str+
- * as a rational. Leading whitespace and extraneous characters
- * past the end of a valid number are ignored.
- * Digit sequences can be separated by an underscore.
- * If there is not a valid number at the start of +str+,
- * zero is returned. This method never raises an exception.
- *
- * ' 2 '.to_r #=> (2/1)
- * '300/2'.to_r #=> (150/1)
- * '-9.2'.to_r #=> (-46/5)
- * '-9.2e2'.to_r #=> (-920/1)
- * '1_234_567'.to_r #=> (1234567/1)
- * '21 June 09'.to_r #=> (21/1)
- * '21/06/09'.to_r #=> (7/2)
- * 'BWV 1079'.to_r #=> (0/1)
- *
- * NOTE: "0.3".to_r isn't the same as 0.3.to_r. The former is
- * equivalent to "3/10".to_r, but the latter isn't so.
+ * str.to_r -> rational
*
- * "0.3".to_r == 3/10r #=> true
- * 0.3.to_r == 3/10r #=> false
+ * Returns the result of interpreting leading characters in +self+ as a rational value:
+ *
+ * '123'.to_r # => (123/1) # Integer literal.
+ * '300/2'.to_r # => (150/1) # Rational literal.
+ * '-9.2'.to_r # => (-46/5) # Float literal.
+ * '-9.2e2'.to_r # => (-920/1) # Float literal.
+ *
+ * Ignores leading and trailing whitespace, and trailing non-numeric characters:
+ *
+ * ' 2 '.to_r # => (2/1)
+ * '21-Jun-09'.to_r # => (21/1)
+ *
+ * Returns \Rational zero if there are no leading numeric characters.
+ *
+ * 'BWV 1079'.to_r # => (0/1)
+ *
+ * NOTE: <tt>'0.3'.to_r</tt> is equivalent to <tt>3/10r</tt>,
+ * but is different from <tt>0.3.to_r</tt>:
+ *
+ * '0.3'.to_r # => (3/10)
+ * 3/10r # => (3/10)
+ * 0.3.to_r # => (5404319552844595/18014398509481984)
*
- * See also Kernel#Rational.
+ * Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
*/
static VALUE
string_to_r(VALUE self)
@@ -2558,11 +2576,11 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise)
VALUE a1 = numv, a2 = denv;
int state;
- assert(!UNDEF_P(a1));
+ RUBY_ASSERT(!UNDEF_P(a1));
if (NIL_P(a1) || NIL_P(a2)) {
if (!raise) return Qnil;
- rb_raise(rb_eTypeError, "can't convert nil into Rational");
+ rb_cant_convert(Qnil, "Rational");
}
if (RB_TYPE_P(a1, T_COMPLEX)) {
@@ -2709,7 +2727,7 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass)
*
* You can convert certain objects to Rationals with:
*
- * - \Method #Rational.
+ * - Method #Rational.
*
* Examples
*
@@ -2773,7 +2791,7 @@ Init_Rational(void)
rb_define_method(rb_cRational, "*", rb_rational_mul, 1);
rb_define_method(rb_cRational, "/", rb_rational_div, 1);
rb_define_method(rb_cRational, "quo", rb_rational_div, 1);
- rb_define_method(rb_cRational, "fdiv", nurat_fdiv, 1);
+ rb_define_method(rb_cRational, "fdiv", rb_rational_fdiv, 1);
rb_define_method(rb_cRational, "**", nurat_expt, 1);
rb_define_method(rb_cRational, "<=>", rb_rational_cmp, 1);
@@ -2817,8 +2835,6 @@ Init_Rational(void)
rb_define_method(rb_cFloat, "numerator", rb_float_numerator, 0);
rb_define_method(rb_cFloat, "denominator", rb_float_denominator, 0);
- rb_define_method(rb_cNilClass, "to_r", nilclass_to_r, 0);
- rb_define_method(rb_cNilClass, "rationalize", nilclass_rationalize, -1);
rb_define_method(rb_cInteger, "to_r", integer_to_r, 0);
rb_define_method(rb_cInteger, "rationalize", integer_rationalize, -1);
rb_define_method(rb_cFloat, "to_r", float_to_r, 0);
diff --git a/re.c b/re.c
index aee0b741bd..63e2db81ac 100644
--- a/re.c
+++ b/re.c
@@ -16,7 +16,9 @@
#include "encindex.h"
#include "hrtime.h"
#include "internal.h"
+#include "internal/bignum.h"
#include "internal/encoding.h"
+#include "internal/error.h"
#include "internal/hash.h"
#include "internal/imemo.h"
#include "internal/re.h"
@@ -28,15 +30,13 @@
#include "ruby/encoding.h"
#include "ruby/re.h"
#include "ruby/util.h"
+#include "ractor_core.h"
VALUE rb_eRegexpError, rb_eRegexpTimeoutError;
typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN];
#define errcpy(err, msg) strlcpy((err), (msg), ONIG_MAX_ERROR_MESSAGE_LEN)
-#define BEG(no) (regs->beg[(no)])
-#define END(no) (regs->end[(no)])
-
#if 'a' == 97 /* it's ascii */
static const char casetable[] = {
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
@@ -88,6 +88,9 @@ static const char casetable[] = {
# error >>> "You lose. You will need a translation table for your character set." <<<
#endif
+// The process-global timeout for regexp matching
+rb_hrtime_t rb_reg_match_time_limit = 0;
+
int
rb_memcicmp(const void *x, const void *y, long len)
{
@@ -101,7 +104,7 @@ rb_memcicmp(const void *x, const void *y, long len)
return 0;
}
-#ifdef HAVE_MEMMEM
+#if defined(HAVE_MEMMEM) && !defined(__APPLE__)
static inline long
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
{
@@ -286,11 +289,6 @@ rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
#define KCODE_FIXED FL_USER4
-#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
char_to_option(int c)
{
@@ -450,7 +448,7 @@ rb_reg_expr_str(VALUE str, const char *s, long len,
}
static VALUE
-rb_reg_desc(const char *s, long len, VALUE re)
+rb_reg_desc(VALUE re)
{
rb_encoding *enc = rb_enc_get(re);
VALUE str = rb_str_buf_new2("/");
@@ -463,7 +461,11 @@ rb_reg_desc(const char *s, long len, VALUE re)
else {
rb_enc_associate(str, rb_usascii_encoding());
}
- rb_reg_expr_str(str, s, len, enc, resenc, '/');
+
+ VALUE src_str = RREGEXP_SRC(re);
+ rb_reg_expr_str(str, RSTRING_PTR(src_str), RSTRING_LEN(src_str), enc, resenc, '/');
+ RB_GC_GUARD(src_str);
+
rb_str_buf_cat2(str, "/");
if (re) {
char opts[OPTBUF_SIZE];
@@ -522,7 +524,7 @@ rb_reg_inspect(VALUE re)
if (!RREGEXP_PTR(re) || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
return rb_any_to_s(re);
}
- return rb_reg_desc(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), re);
+ return rb_reg_desc(re);
}
static VALUE rb_reg_str_with_term(VALUE re, int term);
@@ -538,7 +540,7 @@ static VALUE rb_reg_str_with_term(VALUE re, int term);
*
* The returned string may be used as an argument to Regexp.new,
* or as interpolated text for a
- * {Regexp literal}[rdoc-ref:regexp.rdoc@Regexp+Literal]:
+ * {Regexp interpolation}[rdoc-ref:Regexp@Interpolation+Mode]:
*
* r1 = Regexp.new(s0) # => /(?ix-m:ab+c)/
* r2 = /#{s0}/ # => /(?ix-m:ab+c)/
@@ -565,8 +567,6 @@ rb_reg_str_with_term(VALUE re, int term)
{
int options, opt;
const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
- long len;
- const UChar* ptr;
VALUE str = rb_str_buf_new2("(?");
char optbuf[OPTBUF_SIZE + 1]; /* for '-' */
rb_encoding *enc = rb_enc_get(re);
@@ -575,8 +575,9 @@ rb_reg_str_with_term(VALUE re, int term)
rb_enc_copy(str, re);
options = RREGEXP_PTR(re)->options;
- ptr = (UChar*)RREGEXP_SRC_PTR(re);
- len = RREGEXP_SRC_LEN(re);
+ VALUE src_str = RREGEXP_SRC(re);
+ const UChar *ptr = (UChar *)RSTRING_PTR(src_str);
+ long len = RSTRING_LEN(src_str);
again:
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?') {
int err = 1;
@@ -666,15 +667,17 @@ rb_reg_str_with_term(VALUE re, int term)
}
rb_enc_copy(str, re);
+ RB_GC_GUARD(src_str);
+
return str;
}
-NORETURN(static void rb_reg_raise(const char *s, long len, const char *err, VALUE re));
+NORETURN(static void rb_reg_raise(const char *err, VALUE re));
static void
-rb_reg_raise(const char *s, long len, const char *err, VALUE re)
+rb_reg_raise(const char *err, VALUE re)
{
- VALUE desc = rb_reg_desc(s, len, re);
+ VALUE desc = rb_reg_desc(re);
rb_raise(rb_eRegexpError, "%s: %"PRIsVALUE, err, desc);
}
@@ -953,24 +956,39 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu
* * <code>$'</code> is Regexp.last_match<code>.post_match</code>;
* * <code>$+</code> is Regexp.last_match<code>[ -1 ]</code> (the last capture).
*
- * See also "Special global variables" section in Regexp documentation.
+ * See also Regexp@Global+Variables.
*/
VALUE rb_cMatch;
static VALUE
-match_alloc(VALUE klass)
+match_alloc_n(VALUE klass, int num_regs)
{
- NEWOBJ_OF(match, struct RMatch, klass, T_MATCH | (RGENGC_WB_PROTECTED_MATCH ? FL_WB_PROTECTED : 0));
+ int capa = num_regs * 2;
+ size_t alloc_size = offsetof(struct RMatch, as) + sizeof(OnigPosition) * capa;
+ if (alloc_size < sizeof(struct RMatch)) {
+ alloc_size = sizeof(struct RMatch);
+ }
- match->str = Qfalse;
- match->rmatch = 0;
- match->regexp = Qfalse;
- match->rmatch = ZALLOC(struct rmatch);
+ VALUE flags = T_MATCH;
+ if (!rb_gc_size_allocatable_p(alloc_size)) {
+ alloc_size = sizeof(struct RMatch);
+ flags |= RMATCH_ONIG;
+ capa = 0;
+ }
+ NEWOBJ_OF(match, struct RMatch, klass, flags, alloc_size);
+ memset(((char *)match) + sizeof(struct RBasic), 0, alloc_size - sizeof(struct RBasic));
+ match->capa = capa;
return (VALUE)match;
}
+static VALUE
+match_alloc(VALUE klass)
+{
+ return match_alloc_n(klass, 0);
+}
+
int
rb_reg_region_copy(struct re_registers *to, const struct re_registers *from)
{
@@ -982,6 +1000,54 @@ rb_reg_region_copy(struct re_registers *to, const struct re_registers *from)
return ONIGERR_MEMORY;
}
+static void
+match_to_onig(VALUE match, int num_regs, const OnigPosition *src_beg, const OnigPosition *src_end)
+{
+ struct RMatch *rm = RMATCH(match);
+ struct re_registers tmp = {0};
+ if (onig_region_resize(&tmp, num_regs)) {
+ rb_memerror();
+ }
+ memcpy(tmp.beg, src_beg, num_regs * sizeof(OnigPosition));
+ memcpy(tmp.end, src_end, num_regs * sizeof(OnigPosition));
+ rm->as.onig = tmp;
+ FL_SET_RAW(match, RMATCH_ONIG);
+}
+
+void
+rb_match_ensure_onig(VALUE match)
+{
+ if (FL_TEST_RAW(match, RMATCH_ONIG)) return;
+ struct RMatch *rm = RMATCH(match);
+ int n = rm->num_regs;
+ match_to_onig(match, n, &rm->as.embed[0], &rm->as.embed[n]);
+}
+
+/* Replace `match`'s registers with a copy of (num_regs, beg, end). If the
+ * data does not fit in the embed form, the match is evicted to onig form.
+ * Raises on OOM. */
+static void
+match_set_regs(VALUE match, int num_regs, const OnigPosition *beg, const OnigPosition *end)
+{
+ struct RMatch *rm = RMATCH(match);
+
+ if (FL_TEST_RAW(match, RMATCH_ONIG)) {
+ if (onig_region_resize(&rm->as.onig, num_regs)) {
+ rb_memerror();
+ }
+ memcpy(rm->as.onig.beg, beg, num_regs * sizeof(OnigPosition));
+ memcpy(rm->as.onig.end, end, num_regs * sizeof(OnigPosition));
+ }
+ else if (num_regs * 2 <= rm->capa) {
+ memcpy(&rm->as.embed[0], beg, num_regs * sizeof(OnigPosition));
+ memcpy(&rm->as.embed[num_regs], end, num_regs * sizeof(OnigPosition));
+ }
+ else {
+ match_to_onig(match, num_regs, beg, end);
+ }
+ rm->num_regs = num_regs;
+}
+
typedef struct {
long byte_pos;
long char_pos;
@@ -1001,41 +1067,41 @@ pair_byte_cmp(const void *pair1, const void *pair2)
static void
update_char_offset(VALUE match)
{
- struct rmatch *rm = RMATCH(match)->rmatch;
- struct re_registers *regs;
+ struct RMatch *rm = RMATCH(match);
int i, num_regs, num_pos;
long c;
char *s, *p, *q;
rb_encoding *enc;
pair_t *pairs;
+ VALUE pairs_obj = Qnil;
if (rm->char_offset_num_allocated)
return;
- regs = &rm->regs;
- num_regs = rm->regs.num_regs;
+ num_regs = RMATCH_NREGS(match);
if (rm->char_offset_num_allocated < num_regs) {
- REALLOC_N(rm->char_offset, struct rmatch_offset, num_regs);
+ SIZED_REALLOC_N(rm->char_offset, struct rmatch_offset, num_regs, rm->char_offset_num_allocated);
rm->char_offset_num_allocated = num_regs;
+ FL_SET_RAW(match, RMATCH_OFFSETS_EXTERNAL);
}
enc = rb_enc_get(RMATCH(match)->str);
if (rb_enc_mbmaxlen(enc) == 1) {
for (i = 0; i < num_regs; i++) {
- rm->char_offset[i].beg = BEG(i);
- rm->char_offset[i].end = END(i);
+ rm->char_offset[i].beg = RMATCH_BEG(match, i);
+ rm->char_offset[i].end = RMATCH_END(match, i);
}
return;
}
- pairs = ALLOCA_N(pair_t, num_regs*2);
+ pairs = RB_ALLOCV_N(pair_t, pairs_obj, num_regs * 2);
num_pos = 0;
for (i = 0; i < num_regs; i++) {
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
continue;
- pairs[num_pos++].byte_pos = BEG(i);
- pairs[num_pos++].byte_pos = END(i);
+ pairs[num_pos++].byte_pos = RMATCH_BEG(match, i);
+ pairs[num_pos++].byte_pos = RMATCH_END(match, i);
}
qsort(pairs, num_pos, sizeof(pair_t), pair_byte_cmp);
@@ -1050,20 +1116,22 @@ update_char_offset(VALUE match)
for (i = 0; i < num_regs; i++) {
pair_t key, *found;
- if (BEG(i) < 0) {
+ if (RMATCH_BEG(match, i) < 0) {
rm->char_offset[i].beg = -1;
rm->char_offset[i].end = -1;
continue;
}
- key.byte_pos = BEG(i);
+ key.byte_pos = RMATCH_BEG(match, i);
found = bsearch(&key, pairs, num_pos, sizeof(pair_t), pair_byte_cmp);
rm->char_offset[i].beg = found->char_pos;
- key.byte_pos = END(i);
+ key.byte_pos = RMATCH_END(match, i);
found = bsearch(&key, pairs, num_pos, sizeof(pair_t), pair_byte_cmp);
rm->char_offset[i].end = found->char_pos;
}
+
+ RB_ALLOCV_END(pairs_obj);
}
static VALUE
@@ -1079,24 +1147,23 @@ match_check(VALUE match)
static VALUE
match_init_copy(VALUE obj, VALUE orig)
{
- struct rmatch *rm;
+ struct RMatch *rm = RMATCH(obj);
if (!OBJ_INIT_COPY(obj, orig)) return obj;
- RB_OBJ_WRITE(obj, &RMATCH(obj)->str, RMATCH(orig)->str);
- RB_OBJ_WRITE(obj, &RMATCH(obj)->regexp, RMATCH(orig)->regexp);
+ RB_OBJ_WRITE(obj, &rm->str, RMATCH(orig)->str);
+ RB_OBJ_WRITE(obj, &rm->regexp, RMATCH(orig)->regexp);
- rm = RMATCH(obj)->rmatch;
- if (rb_reg_region_copy(&rm->regs, RMATCH_REGS(orig)))
- rb_memerror();
+ match_set_regs(obj, RMATCH_NREGS(orig), RMATCH_BEG_PTR(orig), RMATCH_END_PTR(orig));
- if (RMATCH(orig)->rmatch->char_offset_num_allocated) {
- if (rm->char_offset_num_allocated < rm->regs.num_regs) {
- REALLOC_N(rm->char_offset, struct rmatch_offset, rm->regs.num_regs);
- rm->char_offset_num_allocated = rm->regs.num_regs;
+ if (RMATCH(orig)->char_offset_num_allocated) {
+ if (rm->char_offset_num_allocated < rm->num_regs) {
+ SIZED_REALLOC_N(rm->char_offset, struct rmatch_offset, rm->num_regs, rm->char_offset_num_allocated);
+ rm->char_offset_num_allocated = rm->num_regs;
+ FL_SET_RAW(obj, RMATCH_OFFSETS_EXTERNAL);
}
- MEMCPY(rm->char_offset, RMATCH(orig)->rmatch->char_offset,
- struct rmatch_offset, rm->regs.num_regs);
+ MEMCPY(rm->char_offset, RMATCH(orig)->char_offset,
+ struct rmatch_offset, rm->num_regs);
RB_GC_GUARD(orig);
}
@@ -1175,10 +1242,10 @@ static VALUE
match_size(VALUE match)
{
match_check(match);
- return INT2FIX(RMATCH_REGS(match)->num_regs);
+ return INT2FIX(RMATCH_NREGS(match));
}
-static int name_to_backref_number(struct re_registers *, VALUE, const char*, const char*);
+static int match_name_to_backref_number(VALUE match, VALUE name);
NORETURN(static void name_to_backref_error(VALUE name));
static void
@@ -1189,21 +1256,17 @@ name_to_backref_error(VALUE name)
}
static void
-backref_number_check(struct re_registers *regs, int i)
+backref_number_check(VALUE match, int i)
{
- if (i < 0 || regs->num_regs <= i)
+ if (i < 0 || RMATCH_NREGS(match) <= i)
rb_raise(rb_eIndexError, "index %d out of matches", i);
}
static int
match_backref_number(VALUE match, VALUE backref)
{
- const char *name;
int num;
- struct re_registers *regs = RMATCH_REGS(match);
- VALUE regexp = RMATCH(match)->regexp;
-
match_check(match);
if (SYMBOL_P(backref)) {
backref = rb_sym2str(backref);
@@ -1211,9 +1274,8 @@ match_backref_number(VALUE match, VALUE backref)
else if (!RB_TYPE_P(backref, T_STRING)) {
return NUM2INT(backref);
}
- name = StringValueCStr(backref);
- num = name_to_backref_number(regs, regexp, name, name + RSTRING_LEN(backref));
+ num = match_name_to_backref_number(match, backref);
if (num < 1) {
name_to_backref_error(backref);
@@ -1241,17 +1303,16 @@ static VALUE
match_offset(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
match_check(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
return rb_assoc_new(Qnil, Qnil);
update_char_offset(match);
- return rb_assoc_new(LONG2NUM(RMATCH(match)->rmatch->char_offset[i].beg),
- LONG2NUM(RMATCH(match)->rmatch->char_offset[i].end));
+ return rb_assoc_new(LONG2NUM(RMATCH(match)->char_offset[i].beg),
+ LONG2NUM(RMATCH(match)->char_offset[i].end));
}
/*
@@ -1276,14 +1337,59 @@ static VALUE
match_byteoffset(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
match_check(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
return rb_assoc_new(Qnil, Qnil);
- return rb_assoc_new(LONG2NUM(BEG(i)), LONG2NUM(END(i)));
+ return rb_assoc_new(LONG2NUM(RMATCH_BEG(match, i)), LONG2NUM(RMATCH_END(match, i)));
+}
+
+
+/*
+ * call-seq:
+ * bytebegin(n) -> integer
+ * bytebegin(name) -> integer
+ *
+ * :include: doc/matchdata/bytebegin.rdoc
+ *
+ */
+
+static VALUE
+match_bytebegin(VALUE match, VALUE n)
+{
+ int i = match_backref_number(match, n);
+
+ match_check(match);
+ backref_number_check(match, i);
+
+ if (RMATCH_BEG(match, i) < 0)
+ return Qnil;
+ return LONG2NUM(RMATCH_BEG(match, i));
+}
+
+
+/*
+ * call-seq:
+ * byteend(n) -> integer
+ * byteend(name) -> integer
+ *
+ * :include: doc/matchdata/byteend.rdoc
+ *
+ */
+
+static VALUE
+match_byteend(VALUE match, VALUE n)
+{
+ int i = match_backref_number(match, n);
+
+ match_check(match);
+ backref_number_check(match, i);
+
+ if (RMATCH_BEG(match, i) < 0)
+ return Qnil;
+ return LONG2NUM(RMATCH_END(match, i));
}
@@ -1300,16 +1406,15 @@ static VALUE
match_begin(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
match_check(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
return Qnil;
update_char_offset(match);
- return LONG2NUM(RMATCH(match)->rmatch->char_offset[i].beg);
+ return LONG2NUM(RMATCH(match)->char_offset[i].beg);
}
@@ -1326,16 +1431,15 @@ static VALUE
match_end(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
match_check(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
return Qnil;
update_char_offset(match);
- return LONG2NUM(RMATCH(match)->rmatch->char_offset[i].end);
+ return LONG2NUM(RMATCH(match)->char_offset[i].end);
}
/*
@@ -1368,11 +1472,10 @@ static VALUE
match_nth(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- long start = BEG(i), end = END(i);
+ long start = RMATCH_BEG(match, i), end = RMATCH_END(match, i);
if (start < 0)
return Qnil;
@@ -1412,17 +1515,16 @@ static VALUE
match_nth_length(VALUE match, VALUE n)
{
int i = match_backref_number(match, n);
- struct re_registers *regs = RMATCH_REGS(match);
match_check(match);
- backref_number_check(regs, i);
+ backref_number_check(match, i);
- if (BEG(i) < 0)
+ if (RMATCH_BEG(match, i) < 0)
return Qnil;
update_char_offset(match);
const struct rmatch_offset *const ofs =
- &RMATCH(match)->rmatch->char_offset[i];
+ &RMATCH(match)->char_offset[i];
return LONG2NUM(ofs->end - ofs->beg);
}
@@ -1443,53 +1545,39 @@ rb_match_unbusy(VALUE match)
int
rb_match_count(VALUE match)
{
- struct re_registers *regs;
if (NIL_P(match)) return -1;
- regs = RMATCH_REGS(match);
- if (!regs) return -1;
- return regs->num_regs;
+ return RMATCH_NREGS(match);
}
-int
-rb_match_nth_defined(int nth, VALUE match)
+static VALUE
+match_alloc_or_reuse(VALUE existing, int num_regs)
{
- struct re_registers *regs;
- if (NIL_P(match)) return FALSE;
- regs = RMATCH_REGS(match);
- if (!regs) return FALSE;
- if (nth >= regs->num_regs) {
- return FALSE;
+ if (!NIL_P(existing) &&
+ !FL_TEST(existing, MATCH_BUSY) &&
+ RMATCH(existing)->capa >= num_regs * 2) {
+ return existing;
}
- if (nth < 0) {
- nth += regs->num_regs;
- if (nth <= 0) return FALSE;
- }
- return (BEG(nth) != -1);
+ return match_alloc_n(rb_cMatch, num_regs);
}
static void
match_set_string(VALUE m, VALUE string, long pos, long len)
{
struct RMatch *match = (struct RMatch *)m;
- struct rmatch *rmatch = match->rmatch;
- RB_OBJ_WRITE(match, &RMATCH(match)->str, string);
- RB_OBJ_WRITE(match, &RMATCH(match)->regexp, Qnil);
- int err = onig_region_resize(&rmatch->regs, 1);
- if (err) rb_memerror();
- rmatch->regs.beg[0] = pos;
- rmatch->regs.end[0] = pos + len;
+ RB_OBJ_WRITE(match, &match->str, string);
+ RB_OBJ_WRITE(match, &match->regexp, Qnil);
+ OnigPosition beg = pos, end = pos + len;
+ match_set_regs(m, 1, &beg, &end);
}
-void
+VALUE
rb_backref_set_string(VALUE string, long pos, long len)
{
- VALUE match = rb_backref_get();
- if (NIL_P(match) || FL_TEST(match, MATCH_BUSY)) {
- match = match_alloc(rb_cMatch);
- }
+ VALUE match = match_alloc_or_reuse(rb_backref_get(), 1);
match_set_string(match, string, pos, len);
rb_backref_set(match);
+ return match;
}
/*
@@ -1538,25 +1626,15 @@ reg_enc_error(VALUE re, VALUE str)
{
rb_raise(rb_eEncCompatError,
"incompatible encoding regexp match (%s regexp with %s string)",
- rb_enc_name(rb_enc_get(re)),
- rb_enc_name(rb_enc_get(str)));
-}
-
-static inline int
-str_coderange(VALUE str)
-{
- int cr = ENC_CODERANGE(str);
- if (cr == ENC_CODERANGE_UNKNOWN) {
- cr = rb_enc_str_coderange(str);
- }
- return cr;
+ rb_enc_inspect_name(rb_enc_get(re)),
+ rb_enc_inspect_name(rb_enc_get(str)));
}
static rb_encoding*
rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
{
rb_encoding *enc = 0;
- int cr = str_coderange(str);
+ int cr = rb_enc_str_coderange(str);
if (cr == ENC_CODERANGE_BROKEN) {
rb_raise(rb_eArgError,
@@ -1592,24 +1670,25 @@ rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
}
regex_t *
-rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err)
+rb_reg_prepare_re(VALUE re, VALUE str)
{
- regex_t *reg = RREGEXP_PTR(re);
int r;
OnigErrorInfo einfo;
- const char *pattern;
VALUE unescaped;
rb_encoding *fixed_enc = 0;
rb_encoding *enc = rb_reg_prepare_enc(re, str, 1);
+ regex_t *reg = RREGEXP_PTR(re);
if (reg->enc == enc) return reg;
rb_reg_check(re);
- reg = RREGEXP_PTR(re);
- pattern = RREGEXP_SRC_PTR(re);
+ VALUE src_str = RREGEXP_SRC(re);
+ const char *pattern = RSTRING_PTR(src_str);
+
+ onig_errmsg_buffer err = "";
unescaped = rb_reg_preprocess(
- pattern, pattern + RREGEXP_SRC_LEN(re), enc,
+ pattern, pattern + RSTRING_LEN(src_str), enc,
&fixed_enc, err, 0);
if (NIL_P(unescaped)) {
@@ -1622,25 +1701,74 @@ rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err)
const char *ptr;
long len;
RSTRING_GETMEM(unescaped, ptr, len);
- r = onig_new(&reg, (UChar *)ptr, (UChar *)(ptr + len),
- reg->options, enc,
- OnigDefaultSyntax, &einfo);
+
+ /* If there are no other users of this regex, then we can directly overwrite it. */
+ if (ruby_single_main_ractor && RREGEXP(re)->usecnt == 0) {
+ regex_t tmp_reg;
+ r = onig_new_without_alloc(&tmp_reg, (UChar *)ptr, (UChar *)(ptr + len),
+ reg->options, enc,
+ OnigDefaultSyntax, &einfo);
+
+ if (r) {
+ /* There was an error so perform cleanups. */
+ onig_free_body(&tmp_reg);
+ }
+ else {
+ onig_free_body(reg);
+ /* There are no errors so set reg to tmp_reg. */
+ *reg = tmp_reg;
+ }
+ }
+ else {
+ r = onig_new(&reg, (UChar *)ptr, (UChar *)(ptr + len),
+ reg->options, enc,
+ OnigDefaultSyntax, &einfo);
+ }
+
if (r) {
onig_error_code_to_str((UChar*)err, r, &einfo);
- rb_reg_raise(pattern, RREGEXP_SRC_LEN(re), err, re);
+ rb_reg_raise(err, re);
}
reg->timelimit = timelimit;
RB_GC_GUARD(unescaped);
+ RB_GC_GUARD(src_str);
return reg;
}
-regex_t *
-rb_reg_prepare_re(VALUE re, VALUE str)
+OnigPosition
+rb_reg_onig_match(VALUE re, VALUE str,
+ OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args),
+ void *args, struct re_registers *regs)
{
- onig_errmsg_buffer err = "";
- return rb_reg_prepare_re0(re, str, err);
+ regex_t *reg = rb_reg_prepare_re(re, str);
+
+ bool tmpreg = reg != RREGEXP_PTR(re);
+ if (!tmpreg) RREGEXP(re)->usecnt++;
+
+ OnigPosition result = match(reg, str, regs, args);
+
+ if (!tmpreg) RREGEXP(re)->usecnt--;
+ if (tmpreg) {
+ onig_free(reg);
+ }
+
+ if (result < 0) {
+ switch (result) {
+ case ONIG_MISMATCH:
+ break;
+ case ONIGERR_TIMEOUT:
+ rb_raise(rb_eRegexpTimeoutError, "regexp match timeout");
+ default: {
+ onig_errmsg_buffer err = "";
+ onig_error_code_to_str((UChar*)err, (int)result);
+ rb_reg_raise(err, re);
+ }
+ }
+ }
+
+ return result;
}
long
@@ -1674,68 +1802,76 @@ rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int reverse)
return pos;
}
+struct reg_onig_search_args {
+ long pos;
+ long range;
+};
+
+static OnigPosition
+reg_onig_search(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr)
+{
+ struct reg_onig_search_args *args = (struct reg_onig_search_args *)args_ptr;
+ const char *ptr;
+ long len;
+ RSTRING_GETMEM(str, ptr, len);
+
+ return onig_search(
+ reg,
+ (UChar *)ptr,
+ (UChar *)(ptr + len),
+ (UChar *)(ptr + args->pos),
+ (UChar *)(ptr + args->range),
+ regs,
+ ONIG_OPTION_NONE);
+}
+
/* returns byte offset */
static long
rb_reg_search_set_match(VALUE re, VALUE str, long pos, int reverse, int set_backref_str, VALUE *set_match)
{
- long result;
- VALUE match;
- struct re_registers regi, *regs = &regi;
- char *start, *range;
- long len;
- regex_t *reg;
- int tmpreg;
- onig_errmsg_buffer err = "";
-
- RSTRING_GETMEM(str, start, len);
- range = start;
+ long len = RSTRING_LEN(str);
if (pos > len || pos < 0) {
rb_backref_set(Qnil);
return -1;
}
- reg = rb_reg_prepare_re0(re, str, err);
- tmpreg = reg != RREGEXP_PTR(re);
- if (!tmpreg) RREGEXP(re)->usecnt++;
+ struct reg_onig_search_args args = {
+ .pos = pos,
+ .range = reverse ? 0 : len,
+ };
- MEMZERO(regs, struct re_registers, 1);
- if (!reverse) {
- range += len;
- }
- result = onig_search(reg,
- (UChar*)start,
- ((UChar*)(start + len)),
- ((UChar*)(start + pos)),
- ((UChar*)range),
- regs, ONIG_OPTION_NONE);
- if (!tmpreg) RREGEXP(re)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(re)->usecnt) {
- onig_free(reg);
- }
- else {
- onig_free(RREGEXP_PTR(re));
- RREGEXP_PTR(re) = reg;
- }
- }
- if (result < 0) {
- if (regs == &regi)
- onig_region_free(regs, 0);
- if (result == ONIG_MISMATCH) {
- rb_backref_set(Qnil);
- return result;
- }
- else {
- onig_error_code_to_str((UChar*)err, (int)result);
- rb_reg_raise(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), err, re);
- }
+ rb_reg_check(re);
+
+ /* Stack-backed regs sized to max(num_mem+1, ONIG_NREGION) so
+ * onig_region_resize_clear takes its no-op branch. */
+ int n = RREGEXP_PTR(re)->num_mem + 1;
+ int cap = n < ONIG_NREGION ? ONIG_NREGION : n;
+ VALUE regs_buf;
+ OnigPosition *buf = ALLOCV_N(OnigPosition, regs_buf, (size_t)cap * 2);
+ struct re_registers regs = {
+ .allocated = cap,
+ .num_regs = 0,
+ .beg = buf,
+ .end = buf + cap,
+ };
+
+ OnigPosition result = rb_reg_onig_match(re, str, reg_onig_search, &args, &regs);
+
+ if (result == ONIG_MISMATCH) {
+ ALLOCV_END(regs_buf);
+ rb_backref_set(Qnil);
+ return ONIG_MISMATCH;
}
- match = match_alloc(rb_cMatch);
- memcpy(RMATCH_REGS(match), regs, sizeof(struct re_registers));
+ VALUE existing = (set_match && !NIL_P(*set_match)) ? *set_match : rb_backref_get();
+ VALUE match = match_alloc_or_reuse(existing, regs.num_regs);
+
+ match_set_regs(match, regs.num_regs, regs.beg, regs.end);
+ ALLOCV_END(regs_buf);
if (set_backref_str) {
RB_OBJ_WRITE(match, &RMATCH(match)->str, rb_str_new4(str));
+ rb_obj_reveal(match, rb_cMatch);
}
else {
/* Note that a MatchData object with RMATCH(match)->str == 0 is incomplete!
@@ -1753,82 +1889,59 @@ rb_reg_search_set_match(VALUE re, VALUE str, long pos, int reverse, int set_back
}
long
-rb_reg_search0(VALUE re, VALUE str, long pos, int reverse, int set_backref_str)
+rb_reg_search0(VALUE re, VALUE str, long pos, int reverse, int set_backref_str, VALUE *match)
{
- return rb_reg_search_set_match(re, str, pos, reverse, set_backref_str, NULL);
+ return rb_reg_search_set_match(re, str, pos, reverse, set_backref_str, match);
}
long
rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
{
- return rb_reg_search0(re, str, pos, reverse, 1);
+ return rb_reg_search_set_match(re, str, pos, reverse, 1, NULL);
}
-bool
-rb_reg_start_with_p(VALUE re, VALUE str)
+static OnigPosition
+reg_onig_match(regex_t *reg, VALUE str, struct re_registers *regs, void *_)
{
- long result;
- VALUE match;
- struct re_registers regi, *regs = &regi;
- regex_t *reg;
- int tmpreg;
- onig_errmsg_buffer err = "";
-
- reg = rb_reg_prepare_re0(re, str, err);
- tmpreg = reg != RREGEXP_PTR(re);
- if (!tmpreg) RREGEXP(re)->usecnt++;
-
- match = rb_backref_get();
- if (!NIL_P(match)) {
- if (FL_TEST(match, MATCH_BUSY)) {
- match = Qnil;
- }
- else {
- regs = RMATCH_REGS(match);
- }
- }
- if (NIL_P(match)) {
- MEMZERO(regs, struct re_registers, 1);
- }
const char *ptr;
long len;
RSTRING_GETMEM(str, ptr, len);
- result = onig_match(reg,
- (UChar*)(ptr),
- ((UChar*)(ptr + len)),
- (UChar*)(ptr),
- regs, ONIG_OPTION_NONE);
- if (!tmpreg) RREGEXP(re)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(re)->usecnt) {
- onig_free(reg);
- }
- else {
- onig_free(RREGEXP_PTR(re));
- RREGEXP_PTR(re) = reg;
- }
- }
- if (result < 0) {
- if (regs == &regi)
- onig_region_free(regs, 0);
- if (result == ONIG_MISMATCH) {
- rb_backref_set(Qnil);
- return false;
- }
- else {
- onig_error_code_to_str((UChar*)err, (int)result);
- rb_reg_raise(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), err, re);
- }
- }
- if (NIL_P(match)) {
- int err;
- match = match_alloc(rb_cMatch);
- err = rb_reg_region_copy(RMATCH_REGS(match), regs);
- onig_region_free(regs, 0);
- if (err) rb_memerror();
+ return onig_match(
+ reg,
+ (UChar *)ptr,
+ (UChar *)(ptr + len),
+ (UChar *)ptr,
+ regs,
+ ONIG_OPTION_NONE);
+}
+
+bool
+rb_reg_start_with_p(VALUE re, VALUE str)
+{
+ rb_reg_check(re);
+
+ int n = RREGEXP_PTR(re)->num_mem + 1;
+ int cap = n < ONIG_NREGION ? ONIG_NREGION : n;
+ VALUE regs_buf;
+ OnigPosition *buf = ALLOCV_N(OnigPosition, regs_buf, (size_t)cap * 2);
+ struct re_registers regs = {
+ .allocated = cap,
+ .num_regs = 0,
+ .beg = buf,
+ .end = buf + cap,
+ };
+
+ if (rb_reg_onig_match(re, str, reg_onig_match, NULL, &regs) == ONIG_MISMATCH) {
+ ALLOCV_END(regs_buf);
+ rb_backref_set(Qnil);
+ return false;
}
+ VALUE match = match_alloc_or_reuse(rb_backref_get(), regs.num_regs);
+ match_set_regs(match, regs.num_regs, regs.beg, regs.end);
+ ALLOCV_END(regs_buf);
+
RB_OBJ_WRITE(match, &RMATCH(match)->str, rb_str_new4(str));
RB_OBJ_WRITE(match, &RMATCH(match)->regexp, re);
rb_backref_set(match);
@@ -1839,18 +1952,17 @@ rb_reg_start_with_p(VALUE re, VALUE str)
VALUE
rb_reg_nth_defined(int nth, VALUE match)
{
- struct re_registers *regs;
if (NIL_P(match)) return Qnil;
match_check(match);
- regs = RMATCH_REGS(match);
- if (nth >= regs->num_regs) {
+ int num_regs = RMATCH_NREGS(match);
+ if (nth >= num_regs) {
return Qnil;
}
if (nth < 0) {
- nth += regs->num_regs;
+ nth += num_regs;
if (nth <= 0) return Qnil;
}
- return RBOOL(BEG(nth) != -1);
+ return RBOOL(RMATCH_BEG(match, nth) != -1);
}
VALUE
@@ -1858,21 +1970,20 @@ rb_reg_nth_match(int nth, VALUE match)
{
VALUE str;
long start, end, len;
- struct re_registers *regs;
if (NIL_P(match)) return Qnil;
match_check(match);
- regs = RMATCH_REGS(match);
- if (nth >= regs->num_regs) {
+ int num_regs = RMATCH_NREGS(match);
+ if (nth >= num_regs) {
return Qnil;
}
if (nth < 0) {
- nth += regs->num_regs;
+ nth += num_regs;
if (nth <= 0) return Qnil;
}
- start = BEG(nth);
+ start = RMATCH_BEG(match, nth);
if (start == -1) return Qnil;
- end = END(nth);
+ end = RMATCH_END(match, nth);
len = end - start;
str = rb_str_subseq(RMATCH(match)->str, start, len);
return str;
@@ -1906,13 +2017,11 @@ VALUE
rb_reg_match_pre(VALUE match)
{
VALUE str;
- struct re_registers *regs;
if (NIL_P(match)) return Qnil;
match_check(match);
- regs = RMATCH_REGS(match);
- if (BEG(0) == -1) return Qnil;
- str = rb_str_subseq(RMATCH(match)->str, 0, BEG(0));
+ if (RMATCH_BEG(match, 0) == -1) return Qnil;
+ str = rb_str_subseq(RMATCH(match)->str, 0, RMATCH_BEG(match, 0));
return str;
}
@@ -1940,33 +2049,45 @@ rb_reg_match_post(VALUE match)
{
VALUE str;
long pos;
- struct re_registers *regs;
if (NIL_P(match)) return Qnil;
match_check(match);
- regs = RMATCH_REGS(match);
- if (BEG(0) == -1) return Qnil;
+ if (RMATCH_BEG(match, 0) == -1) return Qnil;
str = RMATCH(match)->str;
- pos = END(0);
+ pos = RMATCH_END(match, 0);
str = rb_str_subseq(str, pos, RSTRING_LEN(str) - pos);
return str;
}
-VALUE
-rb_reg_match_last(VALUE match)
+static int
+match_last_index(VALUE match)
{
int i;
- struct re_registers *regs;
- if (NIL_P(match)) return Qnil;
+ if (NIL_P(match)) return -1;
match_check(match);
- regs = RMATCH_REGS(match);
- if (BEG(0) == -1) return Qnil;
+ if (RMATCH_BEG(match, 0) == -1) return -1;
- for (i=regs->num_regs-1; BEG(i) == -1 && i > 0; i--)
+ for (i = RMATCH_NREGS(match) - 1; RMATCH_BEG(match, i) == -1 && i > 0; i--)
;
- if (i == 0) return Qnil;
- return rb_reg_nth_match(i, match);
+ return i;
+}
+
+VALUE
+rb_reg_match_last(VALUE match)
+{
+ int i = match_last_index(match);
+ if (i <= 0) return Qnil;
+ long start = RMATCH_BEG(match, i);
+ return rb_str_subseq(RMATCH(match)->str, start, RMATCH_END(match, i) - start);
+}
+
+VALUE
+rb_reg_last_defined(VALUE match)
+{
+ int i = match_last_index(match);
+ if (i < 0) return Qnil;
+ return RBOOL(i);
}
static VALUE
@@ -1996,22 +2117,22 @@ last_paren_match_getter(ID _x, VALUE *_y)
static VALUE
match_array(VALUE match, int start)
{
- struct re_registers *regs;
VALUE ary;
VALUE target;
int i;
match_check(match);
- regs = RMATCH_REGS(match);
- ary = rb_ary_new2(regs->num_regs);
+ int num_regs = RMATCH_NREGS(match);
+ ary = rb_ary_new2(num_regs);
target = RMATCH(match)->str;
- for (i=start; i<regs->num_regs; i++) {
- if (regs->beg[i] == -1) {
+ for (i = start; i < num_regs; i++) {
+ long beg = RMATCH_BEG(match, i);
+ if (beg == -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_subseq(target, beg, RMATCH_END(match, i) - beg);
rb_ary_push(ary, str);
}
}
@@ -2062,7 +2183,7 @@ match_captures(VALUE match)
}
static int
-name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
+name_to_backref_number(const struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
{
if (NIL_P(regexp)) return -1;
return onig_name_to_backref_number(RREGEXP_PTR(regexp),
@@ -2075,7 +2196,27 @@ name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name
name_to_backref_number((regs), (re), (name_ptr), (name_end)))
static int
-namev_to_backref_number(struct re_registers *regs, VALUE re, VALUE name)
+match_name_to_backref_number(VALUE match, VALUE name)
+{
+ VALUE regexp = RMATCH(match)->regexp;
+ if (NIL_P(regexp)) return -1;
+
+ int *nums;
+ int n = onig_name_to_group_numbers(RREGEXP_PTR(regexp),
+ (const unsigned char *)RSTRING_PTR(name),
+ (const unsigned char *)RSTRING_END(name), &nums);
+ if (n < 0) return n;
+ if (n == 0) return ONIGERR_PARSER_BUG;
+ if (n == 1) return nums[0];
+ for (int i = n - 1; i >= 0; i--) {
+ if (RMATCH_BEG(match, nums[i]) != ONIG_REGION_NOTPOS)
+ return nums[i];
+ }
+ return nums[n - 1];
+}
+
+static int
+namev_to_backref_number(VALUE match, VALUE name)
{
int num;
@@ -2085,8 +2226,14 @@ namev_to_backref_number(struct re_registers *regs, VALUE re, VALUE name)
else if (!RB_TYPE_P(name, T_STRING)) {
return -1;
}
- num = NAME_TO_NUMBER(regs, re, name,
- RSTRING_PTR(name), RSTRING_END(name));
+
+ VALUE re = RMATCH(match)->regexp;
+ if (NIL_P(re) || !rb_enc_compatible(RREGEXP_SRC(re), name)) {
+ num = 0;
+ }
+ else {
+ num = match_name_to_backref_number(match, name);
+ }
if (num < 1) {
name_to_backref_error(name);
}
@@ -2096,7 +2243,7 @@ namev_to_backref_number(struct re_registers *regs, VALUE re, VALUE name)
static VALUE
match_ary_subseq(VALUE match, long beg, long len, VALUE result)
{
- long olen = RMATCH_REGS(match)->num_regs;
+ long olen = RMATCH_NREGS(match);
long j, end = olen < beg+len ? olen : beg+len;
if (NIL_P(result)) result = rb_ary_new_capa(len);
if (len == 0) return result;
@@ -2114,7 +2261,7 @@ static VALUE
match_ary_aref(VALUE match, VALUE idx, VALUE result)
{
long beg, len;
- int num_regs = RMATCH_REGS(match)->num_regs;
+ int num_regs = RMATCH_NREGS(match);
/* check if idx is Range */
switch (rb_range_beg_len(idx, &beg, &len, (long)num_regs, !NIL_P(result))) {
@@ -2131,12 +2278,12 @@ match_ary_aref(VALUE match, VALUE idx, VALUE result)
/*
* call-seq:
- * matchdata[index] -> string or nil
- * matchdata[start, length] -> array
- * matchdata[range] -> array
- * matchdata[name] -> string or nil
+ * self[offset] -> string or nil
+ * self[offset, size] -> array
+ * self[range] -> array
+ * self[name] -> string or nil
*
- * When arguments +index+, +start and +length+, or +range+ are given,
+ * When arguments +offset+, +offset+ and +size+, or +range+ are given,
* returns match and captures in the style of Array#[]:
*
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
@@ -2154,6 +2301,17 @@ match_ary_aref(VALUE match, VALUE idx, VALUE result)
* m['foo'] # => "h"
* m[:bar] # => "ge"
*
+ * If multiple captures have the same name, returns the last matched
+ * substring.
+ *
+ * m = /(?<foo>.)(?<foo>.+)/.match("hoge")
+ * # => #<MatchData "hoge" foo:"h" foo:"oge">
+ * m[:foo] #=> "oge"
+ *
+ * m = /\W(?<foo>.+)|\w(?<foo>.+)|(?<foo>.+)/.match("hoge")
+ * #<MatchData "hoge" foo:nil foo:"oge" foo:nil>
+ * m[:foo] #=> "oge"
+ *
*/
static VALUE
@@ -2169,7 +2327,7 @@ match_aref(int argc, VALUE *argv, VALUE match)
return rb_reg_nth_match(FIX2INT(idx), match);
}
else {
- int num = namev_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp, idx);
+ int num = namev_to_backref_number(match, idx);
if (num >= 0) {
return rb_reg_nth_match(num, match);
}
@@ -2181,7 +2339,7 @@ match_aref(int argc, VALUE *argv, VALUE match)
else {
long beg = NUM2LONG(idx);
long len = NUM2LONG(length);
- long num_regs = RMATCH_REGS(match)->num_regs;
+ long num_regs = RMATCH_NREGS(match);
if (len < 0) {
return Qnil;
}
@@ -2239,7 +2397,7 @@ match_values_at(int argc, VALUE *argv, VALUE match)
rb_ary_push(result, rb_reg_nth_match(FIX2INT(argv[i]), match));
}
else {
- int num = namev_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp, argv[i]);
+ int num = namev_to_backref_number(match, argv[i]);
if (num >= 0) {
rb_ary_push(result, rb_reg_nth_match(num, match));
}
@@ -2279,18 +2437,23 @@ match_to_s(VALUE match)
return str;
}
+struct named_captures_data {
+ VALUE hash;
+ VALUE match;
+ int symbolize;
+};
+
static int
match_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
int back_num, int *back_refs, OnigRegex regex, void *arg)
{
- struct MEMO *memo = MEMO_CAST(arg);
- VALUE hash = memo->v1;
- VALUE match = memo->v2;
- long symbolize = memo->u3.state;
+ struct named_captures_data *data = arg;
+ VALUE hash = data->hash;
+ VALUE match = data->match;
VALUE key = rb_enc_str_new((const char *)name, name_end-name, regex->enc);
- if (symbolize > 0) {
+ if (data->symbolize) {
key = rb_str_intern(key);
}
@@ -2316,7 +2479,7 @@ match_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
/*
* call-seq:
- * named_captures -> hash
+ * named_captures(symbolize_names: false) -> hash
*
* Returns a hash of the named captures;
* each key is a capture name; each value is its captured string or +nil+:
@@ -2337,22 +2500,47 @@ match_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
* # => #<MatchData "01" a:"0" a:"1">
* m.named_captures #=> {"a" => "1"}
*
+ * If keyword argument +symbolize_names+ is given
+ * a true value, the keys in the resulting hash are Symbols:
+ *
+ * m = /(?<a>.)(?<a>.)/.match("01")
+ * # => #<MatchData "01" a:"0" a:"1">
+ * m.named_captures(symbolize_names: true) #=> {:a => "1"}
+ *
*/
static VALUE
-match_named_captures(VALUE match)
+match_named_captures(int argc, VALUE *argv, VALUE match)
{
VALUE hash;
- struct MEMO *memo;
match_check(match);
if (NIL_P(RMATCH(match)->regexp))
return rb_hash_new();
+ VALUE opt;
+ int symbolize_names = 0;
+
+ rb_scan_args(argc, argv, "0:", &opt);
+
+ if (!NIL_P(opt)) {
+ static ID keyword_ids[1];
+
+ VALUE symbolize_names_val;
+
+ if (!keyword_ids[0]) {
+ keyword_ids[0] = rb_intern_const("symbolize_names");
+ }
+ rb_get_kwargs(opt, keyword_ids, 0, 1, &symbolize_names_val);
+ if (!UNDEF_P(symbolize_names_val) && RTEST(symbolize_names_val)) {
+ symbolize_names = 1;
+ }
+ }
+
hash = rb_hash_new();
- memo = MEMO_NEW(hash, match, 0);
+ struct named_captures_data data = { hash, match, symbolize_names };
- onig_foreach_name(RREGEXP(RMATCH(match)->regexp)->ptr, match_named_captures_iter, (void*)memo);
+ onig_foreach_name(RREGEXP(RMATCH(match)->regexp)->ptr, match_named_captures_iter, &data);
return hash;
}
@@ -2367,7 +2555,7 @@ match_named_captures(VALUE match)
* m.deconstruct_keys([:hours, :minutes]) # => {:hours => "18", :minutes => "37"}
* m.deconstruct_keys(nil) # => {:hours => "18", :minutes => "37", :seconds => "22"}
*
- * Returns an empty hash of no named captures were defined:
+ * Returns an empty hash if no named captures were defined:
*
* m = /(\d{2}):(\d{2}):(\d{2})/.match("18:37:22")
* m.deconstruct_keys(nil) # => {}
@@ -2388,10 +2576,9 @@ match_deconstruct_keys(VALUE match, VALUE keys)
if (NIL_P(keys)) {
h = rb_hash_new_with_size(onig_number_of_names(RREGEXP_PTR(RMATCH(match)->regexp)));
- struct MEMO *memo;
- memo = MEMO_NEW(h, match, 1);
+ struct named_captures_data data = { h, match, 1 };
- onig_foreach_name(RREGEXP_PTR(RMATCH(match)->regexp), match_named_captures_iter, (void*)memo);
+ onig_foreach_name(RREGEXP_PTR(RMATCH(match)->regexp), match_named_captures_iter, &data);
return h;
}
@@ -2412,8 +2599,7 @@ match_deconstruct_keys(VALUE match, VALUE keys)
name = rb_sym2str(key);
- int num = NAME_TO_NUMBER(RMATCH_REGS(match), RMATCH(match)->regexp, RMATCH(match)->regexp,
- RSTRING_PTR(name), RSTRING_END(name));
+ int num = match_name_to_backref_number(match, name);
if (num >= 0) {
rb_hash_aset(h, key, rb_reg_nth_match(num, match));
@@ -2466,10 +2652,10 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
}
/*
- * call-seq:
- * inspect -> string
+ * call-seq:
+ * inspect -> string
*
- * Returns a string representation of +self+:
+ * Returns a string representation of +self+:
*
* m = /.$/.match("foo")
* # => #<MatchData "o">
@@ -2484,7 +2670,6 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
* m.inspect # => "#<MatchData \"fo\" 1:\"f\" 2:nil 3:\"o\">"
*
* Related: MatchData#to_s.
- *
*/
static VALUE
@@ -2493,9 +2678,9 @@ match_inspect(VALUE match)
VALUE cname = rb_class_path(rb_obj_class(match));
VALUE str;
int i;
- struct re_registers *regs = RMATCH_REGS(match);
- int num_regs = regs->num_regs;
+ int num_regs = RMATCH_NREGS(match);
struct backref_name_tag *names;
+ VALUE names_obj = Qnil;
VALUE regexp = RMATCH(match)->regexp;
if (regexp == 0) {
@@ -2506,7 +2691,7 @@ match_inspect(VALUE match)
cname, rb_reg_nth_match(0, match));
}
- names = ALLOCA_N(struct backref_name_tag, num_regs);
+ names = RB_ALLOCV_N(struct backref_name_tag, names_obj, num_regs);
MEMZERO(names, struct backref_name_tag, num_regs);
onig_foreach_name(RREGEXP_PTR(regexp),
@@ -2534,6 +2719,7 @@ match_inspect(VALUE match)
}
rb_str_buf_cat2(str, ">");
+ RB_ALLOCV_END(names_obj);
return str;
}
@@ -2922,7 +3108,11 @@ escape_asis:
case '#':
if (extended_mode && !in_char_class) {
/* consume and ignore comment in extended regexp */
- while ((p < end) && ((c = *p++) != '\n'));
+ while ((p < end) && ((c = *p++) != '\n')) {
+ if ((c & 0x80) && !*encp && enc == rb_utf8_encoding()) {
+ *encp = enc;
+ }
+ }
break;
}
rb_str_buf_cat(buf, (char *)&c, 1);
@@ -2957,6 +3147,9 @@ escape_asis:
switch (c = *p++) {
default:
if (!(c & 0x80)) break;
+ if (!*encp && enc == rb_utf8_encoding()) {
+ *encp = enc;
+ }
--p;
/* fallthrough */
case '\\':
@@ -2990,55 +3183,55 @@ escape_asis:
parens++;
}
- for(s = p+1; s < end; s++) {
+ for (s = p+1; s < end; s++) {
switch(*s) {
- case 'x':
- local_extend = invert ? -1 : 1;
- break;
- case '-':
- invert = 1;
- break;
- case ':':
- case ')':
- if (local_extend == 0 ||
- (local_extend == -1 && !extended_mode) ||
- (local_extend == 1 && extended_mode)) {
- /* no changes to extended flag */
- goto fallthrough;
- }
+ case 'x':
+ local_extend = invert ? -1 : 1;
+ break;
+ case '-':
+ invert = 1;
+ break;
+ case ':':
+ case ')':
+ if (local_extend == 0 ||
+ (local_extend == -1 && !extended_mode) ||
+ (local_extend == 1 && extended_mode)) {
+ /* no changes to extended flag */
+ goto fallthrough;
+ }
- if (*s == ':') {
- /* change extended flag until ')' */
- int local_options = options;
- if (local_extend == 1) {
- local_options |= ONIG_OPTION_EXTEND;
- }
- else {
- local_options &= ~ONIG_OPTION_EXTEND;
- }
-
- rb_str_buf_cat(buf, (char *)&c, 1);
- int ret = unescape_nonascii0(&p, end, enc, buf, encp,
- has_property, err,
- local_options, 1);
- if (ret < 0) return ret;
- goto begin_scan;
+ if (*s == ':') {
+ /* change extended flag until ')' */
+ int local_options = options;
+ if (local_extend == 1) {
+ local_options |= ONIG_OPTION_EXTEND;
}
else {
- /* change extended flag for rest of expression */
- extended_mode = local_extend == 1;
- goto fallthrough;
+ local_options &= ~ONIG_OPTION_EXTEND;
}
- case 'i':
- case 'm':
- case 'a':
- case 'd':
- case 'u':
- /* other option flags, ignored during scanning */
- break;
- default:
- /* other character, no extended flag change*/
+
+ rb_str_buf_cat(buf, (char *)&c, 1);
+ int ret = unescape_nonascii0(&p, end, enc, buf, encp,
+ has_property, err,
+ local_options, 1);
+ if (ret < 0) return ret;
+ goto begin_scan;
+ }
+ else {
+ /* change extended flag for rest of expression */
+ extended_mode = local_extend == 1;
goto fallthrough;
+ }
+ case 'i':
+ case 'm':
+ case 'a':
+ case 'd':
+ case 'u':
+ /* other option flags, ignored during scanning */
+ break;
+ default:
+ /* other character, no extended flag change*/
+ goto fallthrough;
}
}
}
@@ -3145,7 +3338,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int options)
src_enc = rb_enc_get(str);
if (options & ARG_ENCODING_NONE &&
src_enc != ascii8bit) {
- if (str_coderange(str) != ENC_CODERANGE_7BIT)
+ if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT)
rb_raise(rb_eRegexpError, "/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
else
src_enc = ascii8bit;
@@ -3180,6 +3373,15 @@ rb_reg_preprocess_dregexp(VALUE ary, int options)
return result;
}
+static void
+rb_reg_initialize_check(VALUE obj)
+{
+ rb_check_frozen(obj);
+ if (RREGEXP_PTR(obj)) {
+ rb_raise(rb_eTypeError, "already initialized regexp");
+ }
+}
+
static int
rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
int options, onig_errmsg_buffer err,
@@ -3190,10 +3392,7 @@ rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
rb_encoding *fixed_enc = 0;
rb_encoding *a_enc = rb_ascii8bit_encoding();
- rb_check_frozen(obj);
- if (re->ptr)
- rb_raise(rb_eTypeError, "already initialized regexp");
- re->ptr = 0;
+ rb_reg_initialize_check(obj);
if (rb_enc_dummy_p(enc)) {
errcpy(err, "can't make regexp with dummy encoding");
@@ -3231,6 +3430,9 @@ rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
options & ARG_REG_OPTION_MASK, err,
sourcefile, sourceline);
if (!re->ptr) return -1;
+ if (RBASIC_CLASS(obj) == rb_cRegexp) {
+ OBJ_FREEZE(obj);
+ }
RB_GC_GUARD(unescaped);
return 0;
}
@@ -3239,10 +3441,13 @@ static void
reg_set_source(VALUE reg, VALUE str, rb_encoding *enc)
{
rb_encoding *regenc = rb_enc_get(reg);
+
if (regenc != enc) {
- str = rb_enc_associate(rb_str_dup(str), enc = regenc);
+ VALUE dup = rb_str_dup(str);
+ str = rb_enc_associate(dup, enc = regenc);
}
- RB_OBJ_WRITE(reg, &RREGEXP(reg)->src, rb_fstring(str));
+ str = rb_fstring(str);
+ RB_OBJ_WRITE(reg, &RREGEXP(reg)->src, str);
}
static int
@@ -3254,7 +3459,7 @@ rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err,
if (options & ARG_ENCODING_NONE) {
rb_encoding *ascii8bit = rb_ascii8bit_encoding();
if (enc != ascii8bit) {
- if (str_coderange(str) != ENC_CODERANGE_7BIT) {
+ if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
errcpy(err, "/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
return -1;
}
@@ -3267,10 +3472,10 @@ rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err,
return ret;
}
-static VALUE
+VALUE
rb_reg_s_alloc(VALUE klass)
{
- NEWOBJ_OF(re, struct RRegexp, klass, T_REGEXP | (RGENGC_WB_PROTECTED_REGEXP ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(re, struct RRegexp, klass, T_REGEXP, sizeof(struct RRegexp));
re->ptr = 0;
RB_OBJ_WRITE(re, &re->src, 0);
@@ -3318,11 +3523,12 @@ rb_reg_init_str_enc(VALUE re, VALUE s, rb_encoding *enc, int options)
}
VALUE
-rb_reg_new_ary(VALUE ary, int opt)
+rb_reg_new_from_values(long cnt, const VALUE *elements, int opt)
{
- VALUE re = rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
- rb_obj_freeze(re);
- return re;
+ const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, elements);
+ VALUE val = rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
+ rb_ary_clear(ary);
+ return val;
}
VALUE
@@ -3356,7 +3562,6 @@ rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
rb_set_errinfo(rb_reg_error_desc(str, options, err));
return Qnil;
}
- rb_obj_freeze(re);
return re;
}
@@ -3365,12 +3570,17 @@ static VALUE reg_cache;
VALUE
rb_reg_regcomp(VALUE str)
{
- if (reg_cache && RREGEXP_SRC_LEN(reg_cache) == RSTRING_LEN(str)
- && ENCODING_GET(reg_cache) == ENCODING_GET(str)
- && memcmp(RREGEXP_SRC_PTR(reg_cache), RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
- return reg_cache;
+ if (rb_ractor_main_p()) {
+ if (reg_cache && RREGEXP_SRC_LEN(reg_cache) == RSTRING_LEN(str)
+ && ENCODING_GET(reg_cache) == ENCODING_GET(str)
+ && memcmp(RREGEXP_SRC_PTR(reg_cache), RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
+ return reg_cache;
- return reg_cache = rb_reg_new_str(str, 0);
+ return reg_cache = rb_reg_new_str(str, 0);
+ }
+ else {
+ return rb_reg_new_str(str, 0);
+ }
}
static st_index_t reg_hash(VALUE re);
@@ -3405,10 +3615,10 @@ reg_hash(VALUE re)
/*
* call-seq:
- * regexp == object -> true or false
+ * self == other -> true or false
*
- * Returns +true+ if +object+ is another \Regexp whose pattern,
- * flags, and encoding are the same as +self+, +false+ otherwise:
+ * Returns whether +other+ is another \Regexp whose pattern,
+ * flags, and encoding are the same as +self+:
*
* /foo/ == Regexp.new('foo') # => true
* /foo/ == /foo/i # => false
@@ -3444,47 +3654,113 @@ rb_reg_equal(VALUE re1, VALUE re2)
static VALUE
match_hash(VALUE match)
{
- const struct re_registers *regs;
st_index_t hashval;
match_check(match);
hashval = rb_hash_start(rb_str_hash(RMATCH(match)->str));
hashval = rb_hash_uint(hashval, reg_hash(match_regexp(match)));
- regs = RMATCH_REGS(match);
- hashval = rb_hash_uint(hashval, regs->num_regs);
- hashval = rb_hash_uint(hashval, rb_memhash(regs->beg, regs->num_regs * sizeof(*regs->beg)));
- hashval = rb_hash_uint(hashval, rb_memhash(regs->end, regs->num_regs * sizeof(*regs->end)));
+ int num_regs = RMATCH_NREGS(match);
+ hashval = rb_hash_uint(hashval, num_regs);
+ hashval = rb_hash_uint(hashval, rb_memhash(RMATCH_BEG_PTR(match), num_regs * sizeof(OnigPosition)));
+ hashval = rb_hash_uint(hashval, rb_memhash(RMATCH_END_PTR(match), num_regs * sizeof(OnigPosition)));
hashval = rb_hash_end(hashval);
return ST2FIX(hashval);
}
/*
* call-seq:
- * matchdata == object -> true or false
+ * self == other -> true or false
*
- * Returns +true+ if +object+ is another \MatchData object
+ * Returns whether +other+ is another \MatchData object
* whose target string, regexp, match, and captures
- * are the same as +self+, +false+ otherwise.
+ * are the same as +self+.
*/
static VALUE
match_equal(VALUE match1, VALUE match2)
{
- const struct re_registers *regs1, *regs2;
-
if (match1 == match2) return Qtrue;
if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse;
if (!RMATCH(match1)->regexp || !RMATCH(match2)->regexp) return Qfalse;
if (!rb_str_equal(RMATCH(match1)->str, RMATCH(match2)->str)) return Qfalse;
if (!rb_reg_equal(match_regexp(match1), match_regexp(match2))) return Qfalse;
- regs1 = RMATCH_REGS(match1);
- regs2 = RMATCH_REGS(match2);
- if (regs1->num_regs != regs2->num_regs) return Qfalse;
- if (memcmp(regs1->beg, regs2->beg, regs1->num_regs * sizeof(*regs1->beg))) return Qfalse;
- if (memcmp(regs1->end, regs2->end, regs1->num_regs * sizeof(*regs1->end))) return Qfalse;
+ int num_regs = RMATCH_NREGS(match1);
+ if (num_regs != RMATCH_NREGS(match2)) return Qfalse;
+ if (memcmp(RMATCH_BEG_PTR(match1), RMATCH_BEG_PTR(match2), num_regs * sizeof(OnigPosition))) return Qfalse;
+ if (memcmp(RMATCH_END_PTR(match1), RMATCH_END_PTR(match2), num_regs * sizeof(OnigPosition))) return Qfalse;
return Qtrue;
}
+/*
+ * call-seq:
+ * integer_at(index, base = 10) -> integer or nil
+ * integer_at(name, base = 10) -> integer or nil
+ *
+ * Converts the matched substring to integer and return the result.
+ * +$~.integer_at(N)+ is equivalent to +$N&.to_i+.
+ *
+ * m = /(\d+{4})(\d+{2})(\d+{2})/.match("20260308")
+ * # => #<MatchData "20260308" 1:"2026" 2:"03" 3:"08">
+ * m.integer_at(0) # => 20260308
+ * m.integer_at(1) # => 2026
+ * m.integer_at(2) # => 3
+ * m.integer_at(3) # => 8
+ *
+ * m = /(?<y>\d+{4})(?<m>\d+{2})(?<d>\d+{2})/.match("20260308")
+ * m.integer_at("y") # => 2026
+ * m.integer_at("m") # => 3
+ * m.integer_at("d") # => 8
+ *
+ * If the substring does not match, returns +nil+.
+ *
+ * re = /(\d+)?/
+ * re.match("123").integer_at(1) #=> 123
+ * re.match("abc").integer_at(1) #=> nil
+ *
+ * The string is converted in decimal by default.
+ *
+ * /\d+/.match("011").integer_at(0) #=> 10
+ * /\d+/.match("011").integer_at(0, 12) #=> 13
+ * /\d+/.match("011").integer_at(0, 0) #=> 9
+ *
+ * See also MatchData#[], String#to_i.
+ */
+static VALUE
+match_integer_at(int argc, VALUE *argv, VALUE match)
+{
+ match_check(match);
+
+ int base = 10;
+ VALUE idx;
+ int nth;
+
+ argc = rb_check_arity(argc, 1, 2);
+ if (FIXNUM_P(idx = argv[0])) {
+ nth = NUM2INT(idx);
+ }
+ else if ((nth = namev_to_backref_number(match, idx)) < 0) {
+ name_to_backref_error(idx);
+ }
+
+ if (argc > 1 && (base = NUM2INT(argv[1])) < 0) {
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ }
+
+ if (nth >= RMATCH_NREGS(match)) return Qnil;
+ if (nth < 0 && (nth += RMATCH_NREGS(match)) <= 0) return Qnil;
+
+ long start = RMATCH_BEG(match, nth), end = RMATCH_END(match, nth);
+ if (start < 0) return Qnil;
+ RUBY_ASSERT(start <= end, "%ld > %ld", start, end);
+
+ VALUE str = RMATCH(match)->str;
+ RUBY_ASSERT(end <= RSTRING_LEN(str), "%ld > %ld", end, RSTRING_LEN(str));
+
+ char *endp;
+ return rb_int_parse_cstr(RSTRING_PTR(str) + start, end - start, &endp, NULL,
+ base, RB_INT_PARSE_DEFAULT);
+}
+
static VALUE
reg_operand(VALUE s, int check)
{
@@ -3524,12 +3800,11 @@ reg_match_pos(VALUE re, VALUE *strp, long pos, VALUE* set_match)
/*
* call-seq:
- * regexp =~ string -> integer or nil
+ * self =~ other -> integer or nil
*
* Returns the integer index (in characters) of the first match
- * for +self+ and +string+, or +nil+ if none;
- * also sets the
- * {rdoc-ref:Regexp Global Variables}[rdoc-ref:Regexp@Regexp+Global+Variables]:
+ * for +self+ and +other+, or +nil+ if none;
+ * updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables].
*
* /at/ =~ 'input data' # => 7
* $~ # => #<MatchData "at">
@@ -3540,9 +3815,9 @@ reg_match_pos(VALUE re, VALUE *strp, long pos, VALUE* set_match)
* if and only if +self+:
*
* - Is a regexp literal;
- * see {Regexp Literals}[rdoc-ref:literals.rdoc@Regexp+Literals].
+ * see {Regexp Literals}[rdoc-ref:syntax/literals.rdoc@Regexp+Literals].
* - Does not contain interpolations;
- * see {Regexp Interpolation}[rdoc-ref:Regexp@Regexp+Interpolation].
+ * see {Regexp interpolation}[rdoc-ref:Regexp@Interpolation+Mode].
* - Is at the left of the expression.
*
* Example:
@@ -3589,9 +3864,9 @@ rb_reg_match(VALUE re, VALUE str)
/*
* call-seq:
- * regexp === string -> true or false
+ * self === other -> true or false
*
- * Returns +true+ if +self+ finds a match in +string+:
+ * Returns whether +self+ finds a match in +other+:
*
* /^[a-z]*$/ === 'HELLO' # => false
* /^[A-Z]*$/ === 'HELLO' # => true
@@ -3745,12 +4020,6 @@ rb_reg_match_m_p(int argc, VALUE *argv, VALUE re)
VALUE
rb_reg_match_p(VALUE re, VALUE str, long pos)
{
- regex_t *reg;
- onig_errmsg_buffer err = "";
- OnigPosition result;
- const UChar *start, *end;
- int tmpreg;
-
if (NIL_P(str)) return Qfalse;
str = SYMBOL_P(str) ? rb_sym2str(str) : StringValue(str);
if (pos) {
@@ -3765,33 +4034,13 @@ rb_reg_match_p(VALUE re, VALUE str, long pos)
pos = beg - RSTRING_PTR(str);
}
}
- reg = rb_reg_prepare_re0(re, str, err);
- tmpreg = reg != RREGEXP_PTR(re);
- if (!tmpreg) RREGEXP(re)->usecnt++;
- start = ((UChar*)RSTRING_PTR(str));
- end = start + RSTRING_LEN(str);
- result = onig_search(reg, start, end, start + pos, end,
- NULL, ONIG_OPTION_NONE);
- if (!tmpreg) RREGEXP(re)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(re)->usecnt) {
- onig_free(reg);
- }
- else {
- onig_free(RREGEXP_PTR(re));
- RREGEXP_PTR(re) = reg;
- }
- }
- if (result < 0) {
- if (result == ONIG_MISMATCH) {
- return Qfalse;
- }
- else {
- onig_error_code_to_str((UChar*)err, (int)result);
- rb_reg_raise(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), err, re);
- }
- }
- return Qtrue;
+
+ struct reg_onig_search_args args = {
+ .pos = pos,
+ .range = RSTRING_LEN(str),
+ };
+
+ return rb_reg_onig_match(re, str, reg_onig_search, &args, NULL) == ONIG_MISMATCH ? Qfalse : Qtrue;
}
/*
@@ -3823,12 +4072,35 @@ static void
set_timeout(rb_hrtime_t *hrt, VALUE timeout)
{
double timeout_d = NIL_P(timeout) ? 0.0 : NUM2DBL(timeout);
- if (!NIL_P(timeout) && timeout_d <= 0) {
+ if (!NIL_P(timeout) && !(timeout_d > 0)) {
rb_raise(rb_eArgError, "invalid timeout: %"PRIsVALUE, timeout);
}
double2hrtime(hrt, timeout_d);
}
+static VALUE
+reg_copy(VALUE copy, VALUE orig)
+{
+ int r;
+ regex_t *re;
+
+ rb_reg_initialize_check(copy);
+ if ((r = onig_reg_copy(&re, RREGEXP_PTR(orig))) != 0) {
+ /* ONIGERR_MEMORY only */
+ rb_raise(rb_eRegexpError, "%s", onig_error_code_to_format(r));
+ }
+ RREGEXP_PTR(copy) = re;
+ RB_OBJ_WRITE(copy, &RREGEXP(copy)->src, RREGEXP(orig)->src);
+ RREGEXP_PTR(copy)->timelimit = RREGEXP_PTR(orig)->timelimit;
+ rb_enc_copy(copy, orig);
+ FL_SET_RAW(copy, FL_TEST_RAW(orig, KCODE_FIXED|REG_ENCODING_NONE));
+ if (RBASIC_CLASS(copy) == rb_cRegexp) {
+ OBJ_FREEZE(copy);
+ }
+
+ return copy;
+}
+
struct reg_init_args {
VALUE str;
VALUE timeout;
@@ -3838,7 +4110,6 @@ struct reg_init_args {
static VALUE reg_extract_args(int argc, VALUE *argv, struct reg_init_args *args);
static VALUE reg_init_args(VALUE self, VALUE str, rb_encoding *enc, int flags);
-void rb_warn_deprecated_to_remove(const char *removal, const char *fmt, const char *suggest, ...);
/*
* call-seq:
@@ -3898,11 +4169,19 @@ static VALUE
rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
{
struct reg_init_args args;
+ VALUE re = reg_extract_args(argc, argv, &args);
- reg_extract_args(argc, argv, &args);
- reg_init_args(self, args.str, args.enc, args.flags);
+ if (NIL_P(re)) {
+ reg_init_args(self, args.str, args.enc, args.flags);
+ }
+ else {
+ reg_copy(self, re);
+ }
set_timeout(&RREGEXP_PTR(self)->timelimit, args.timeout);
+ if (RBASIC_CLASS(self) == rb_cRegexp) {
+ OBJ_FREEZE(self);
+ }
return self;
}
@@ -4323,11 +4602,11 @@ rb_reg_init_copy(VALUE copy, VALUE re)
{
if (!OBJ_INIT_COPY(copy, re)) return copy;
rb_reg_check(re);
- return rb_reg_init_str(copy, RREGEXP_SRC(re), rb_reg_options(re));
+ return reg_copy(copy, re);
}
-VALUE
-rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
+static VALUE
+do_regsub(VALUE str, VALUE src, VALUE regexp, int num_regs, const OnigPosition *beg, const OnigPosition *end)
{
VALUE val = 0;
char *p, *s, *e;
@@ -4394,7 +4673,13 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
if (name_end < e) {
VALUE n = rb_str_subseq(str, (long)(name - RSTRING_PTR(str)),
(long)(name_end - name));
- if ((no = NAME_TO_NUMBER(regs, regexp, n, name, name_end)) < 1) {
+ struct re_registers tmp = {
+ .allocated = num_regs,
+ .num_regs = num_regs,
+ .beg = (OnigPosition *)beg,
+ .end = (OnigPosition *)end,
+ };
+ if ((no = NAME_TO_NUMBER(&tmp, regexp, n, name, name_end)) < 1) {
name_to_backref_error(n);
}
p = s = name_end + clen;
@@ -4414,16 +4699,16 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
break;
case '`':
- rb_enc_str_buf_cat(val, RSTRING_PTR(src), BEG(0), src_enc);
+ rb_enc_str_buf_cat(val, RSTRING_PTR(src), beg[0], src_enc);
continue;
case '\'':
- rb_enc_str_buf_cat(val, RSTRING_PTR(src)+END(0), RSTRING_LEN(src)-END(0), src_enc);
+ rb_enc_str_buf_cat(val, RSTRING_PTR(src)+end[0], RSTRING_LEN(src)-end[0], src_enc);
continue;
case '+':
- no = regs->num_regs-1;
- while (BEG(no) == -1 && no > 0) no--;
+ no = num_regs-1;
+ while (beg[no] == -1 && no > 0) no--;
if (no == 0) continue;
break;
@@ -4437,9 +4722,9 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
}
if (no >= 0) {
- if (no >= regs->num_regs) continue;
- if (BEG(no) == -1) continue;
- rb_enc_str_buf_cat(val, RSTRING_PTR(src)+BEG(no), END(no)-BEG(no), src_enc);
+ if (no >= num_regs) continue;
+ if (beg[no] == -1) continue;
+ rb_enc_str_buf_cat(val, RSTRING_PTR(src)+beg[no], end[no]-beg[no], src_enc);
}
}
@@ -4449,6 +4734,20 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
}
return val;
+#undef ASCGET
+}
+
+VALUE
+rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
+{
+ return do_regsub(str, src, regexp, regs->num_regs, regs->beg, regs->end);
+}
+
+VALUE
+rb_reg_regsub_match(VALUE str, VALUE src, VALUE match)
+{
+ return do_regsub(str, src, RMATCH(match)->regexp,
+ RMATCH_NREGS(match), RMATCH_BEG_PTR(match), RMATCH_END_PTR(match));
}
static VALUE
@@ -4495,9 +4794,9 @@ match_setter(VALUE val, ID _x, VALUE *_y)
* Regexp.last_match(n) -> string or nil
* Regexp.last_match(name) -> string or nil
*
- * With no argument, returns the value of <tt>$!</tt>,
+ * With no argument, returns the value of <tt>$~</tt>,
* which is the result of the most recent pattern match
- * (see {Regexp Global Variables}[rdoc-ref:Regexp@Regexp+Global+Variables]):
+ * (see {Regexp global variables}[rdoc-ref:Regexp@Global+Variables]):
*
* /c(.)t/ =~ 'cat' # => 0
* Regexp.last_match # => #<MatchData "cat" 1:"a">
@@ -4546,12 +4845,9 @@ re_warn(const char *s)
rb_warn("%s", s);
}
-// The process-global timeout for regexp matching
-rb_hrtime_t rb_reg_match_time_limit = 0;
-
// This function is periodically called during regexp matching
-void
-rb_reg_check_timeout(regex_t *reg, void *end_time_)
+bool
+rb_reg_timeout_p(regex_t *reg, void *end_time_)
{
rb_hrtime_t *end_time = (rb_hrtime_t *)end_time_;
@@ -4576,10 +4872,12 @@ rb_reg_check_timeout(regex_t *reg, void *end_time_)
}
else {
if (*end_time < rb_hrtime_now()) {
- // timeout is exceeded
- rb_raise(rb_eRegexpTimeoutError, "regexp match timeout");
+ // Timeout has exceeded
+ return true;
}
}
+
+ return false;
}
/*
@@ -4660,7 +4958,7 @@ rb_reg_timeout_get(VALUE re)
/*
* Document-class: Regexp
*
- * :include: doc/regexp.rdoc
+ * :include: doc/_regexp.rdoc
*/
void
@@ -4683,6 +4981,11 @@ Init_Regexp(void)
rb_gvar_ractor_local("$`");
rb_gvar_ractor_local("$'");
rb_gvar_ractor_local("$+");
+ rb_gvar_box_dynamic("$~");
+ rb_gvar_box_ready("$&");
+ rb_gvar_box_ready("$`");
+ rb_gvar_box_ready("$'");
+ rb_gvar_box_ready("$+");
rb_define_virtual_variable("$=", ignorecase_getter, ignorecase_setter);
@@ -4717,6 +5020,7 @@ Init_Regexp(void)
rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 0);
rb_define_method(rb_cRegexp, "timeout", rb_reg_timeout_get, 0);
+ /* Raised when regexp matching timed out. */
rb_eRegexpTimeoutError = rb_define_class_under(rb_cRegexp, "TimeoutError", rb_eRegexpError);
rb_define_singleton_method(rb_cRegexp, "timeout", rb_reg_s_timeout_get, 0);
rb_define_singleton_method(rb_cRegexp, "timeout=", rb_reg_s_timeout_set, 1);
@@ -4746,6 +5050,8 @@ Init_Regexp(void)
rb_define_method(rb_cMatch, "length", match_size, 0);
rb_define_method(rb_cMatch, "offset", match_offset, 1);
rb_define_method(rb_cMatch, "byteoffset", match_byteoffset, 1);
+ rb_define_method(rb_cMatch, "bytebegin", match_bytebegin, 1);
+ rb_define_method(rb_cMatch, "byteend", match_byteend, 1);
rb_define_method(rb_cMatch, "begin", match_begin, 1);
rb_define_method(rb_cMatch, "end", match_end, 1);
rb_define_method(rb_cMatch, "match", match_nth, 1);
@@ -4754,7 +5060,7 @@ Init_Regexp(void)
rb_define_method(rb_cMatch, "[]", match_aref, -1);
rb_define_method(rb_cMatch, "captures", match_captures, 0);
rb_define_alias(rb_cMatch, "deconstruct", "captures");
- rb_define_method(rb_cMatch, "named_captures", match_named_captures, 0);
+ rb_define_method(rb_cMatch, "named_captures", match_named_captures, -1);
rb_define_method(rb_cMatch, "deconstruct_keys", match_deconstruct_keys, 1);
rb_define_method(rb_cMatch, "values_at", match_values_at, -1);
rb_define_method(rb_cMatch, "pre_match", rb_reg_match_pre, 0);
@@ -4765,4 +5071,5 @@ Init_Regexp(void)
rb_define_method(rb_cMatch, "hash", match_hash, 0);
rb_define_method(rb_cMatch, "eql?", match_equal, 1);
rb_define_method(rb_cMatch, "==", match_equal, 1);
+ rb_define_method(rb_cMatch, "integer_at", match_integer_at, -1);
}
diff --git a/regcomp.c b/regcomp.c